From 5651828bf74edb760d67700942fc65d51c816e0a Mon Sep 17 00:00:00 2001 From: Neo2003 Date: Sat, 4 Oct 2008 06:17:19 -0500 Subject: [PATCH] [svn] * Added ACE for Linux and Windows (Thanks Derex for Linux part and partial Windows part) * Updated to 6721 and 676 * Fixed TrinityScript logo * Version updated to 0.2.6721.676 --HG-- branch : trunk rename : 6700-670 => 6721-676 --- 6700-670 => 6721-676 | 0 configure.ac | 12 +- dep/ACE_wrappers/AUTHORS | 13 + dep/ACE_wrappers/COPYING | 110 + dep/ACE_wrappers/ChangeLog | 6119 +++ dep/ACE_wrappers/FAQ | 1847 + dep/ACE_wrappers/Makefile.am | 16 + dep/ACE_wrappers/NEWS | 1345 + dep/ACE_wrappers/PROBLEM-REPORT-FORM | 90 + dep/ACE_wrappers/README | 222 + dep/ACE_wrappers/THANKS | 2289 + dep/ACE_wrappers/VERSION | 11 + dep/ACE_wrappers/ace/ACE.bor | 2312 + dep/ACE_wrappers/ace/ACE.cpp | 3444 ++ dep/ACE_wrappers/ace/ACE.h | 824 + dep/ACE_wrappers/ace/ACE.inl | 350 + dep/ACE_wrappers/ace/ACE_crc32.cpp | 161 + dep/ACE_wrappers/ace/ACE_crc_ccitt.cpp | 128 + dep/ACE_wrappers/ace/ACE_export.h | 76 + dep/ACE_wrappers/ace/ACE_vc71.vcproj | 5255 +++ dep/ACE_wrappers/ace/ACE_vc8.vcproj | 6640 +++ dep/ACE_wrappers/ace/ACE_vc9.vcproj | 6640 +++ dep/ACE_wrappers/ace/ARGV.cpp | 383 + dep/ACE_wrappers/ace/ARGV.h | 333 + dep/ACE_wrappers/ace/ARGV.inl | 104 + dep/ACE_wrappers/ace/ATM_Acceptor.cpp | 309 + dep/ACE_wrappers/ace/ATM_Acceptor.h | 123 + dep/ACE_wrappers/ace/ATM_Acceptor.inl | 43 + dep/ACE_wrappers/ace/ATM_Addr.cpp | 522 + dep/ACE_wrappers/ace/ATM_Addr.h | 197 + dep/ACE_wrappers/ace/ATM_Addr.inl | 37 + dep/ACE_wrappers/ace/ATM_Connector.cpp | 138 + dep/ACE_wrappers/ace/ATM_Connector.h | 164 + dep/ACE_wrappers/ace/ATM_Connector.inl | 132 + dep/ACE_wrappers/ace/ATM_Params.cpp | 20 + dep/ACE_wrappers/ace/ATM_Params.h | 214 + dep/ACE_wrappers/ace/ATM_Params.inl | 235 + dep/ACE_wrappers/ace/ATM_QoS.cpp | 631 + dep/ACE_wrappers/ace/ATM_QoS.h | 115 + dep/ACE_wrappers/ace/ATM_QoS.inl | 29 + dep/ACE_wrappers/ace/ATM_Stream.cpp | 290 + dep/ACE_wrappers/ace/ATM_Stream.h | 107 + dep/ACE_wrappers/ace/ATM_Stream.inl | 133 + dep/ACE_wrappers/ace/Acceptor.cpp | 1235 + dep/ACE_wrappers/ace/Acceptor.h | 688 + dep/ACE_wrappers/ace/Activation_Queue.cpp | 138 + dep/ACE_wrappers/ace/Activation_Queue.h | 173 + dep/ACE_wrappers/ace/Activation_Queue.inl | 31 + dep/ACE_wrappers/ace/Active_Map_Manager.cpp | 9 + dep/ACE_wrappers/ace/Active_Map_Manager.h | 116 + dep/ACE_wrappers/ace/Active_Map_Manager.inl | 95 + dep/ACE_wrappers/ace/Active_Map_Manager_T.cpp | 22 + dep/ACE_wrappers/ace/Active_Map_Manager_T.h | 211 + dep/ACE_wrappers/ace/Active_Map_Manager_T.inl | 311 + dep/ACE_wrappers/ace/Addr.cpp | 73 + dep/ACE_wrappers/ace/Addr.h | 103 + dep/ACE_wrappers/ace/Addr.inl | 61 + dep/ACE_wrappers/ace/Arg_Shifter.cpp | 230 + dep/ACE_wrappers/ace/Arg_Shifter.h | 221 + dep/ACE_wrappers/ace/Argv_Type_Converter.cpp | 204 + dep/ACE_wrappers/ace/Argv_Type_Converter.h | 119 + dep/ACE_wrappers/ace/Argv_Type_Converter.inl | 44 + dep/ACE_wrappers/ace/Array.h | 29 + dep/ACE_wrappers/ace/Array_Base.cpp | 235 + dep/ACE_wrappers/ace/Array_Base.h | 256 + dep/ACE_wrappers/ace/Array_Base.inl | 146 + dep/ACE_wrappers/ace/Array_Map.cpp | 299 + dep/ACE_wrappers/ace/Array_Map.h | 300 + dep/ACE_wrappers/ace/Array_Map.inl | 133 + dep/ACE_wrappers/ace/Assert.cpp | 24 + dep/ACE_wrappers/ace/Assert.h | 38 + dep/ACE_wrappers/ace/Asynch_Acceptor.cpp | 514 + dep/ACE_wrappers/ace/Asynch_Acceptor.h | 281 + dep/ACE_wrappers/ace/Asynch_Connector.cpp | 296 + dep/ACE_wrappers/ace/Asynch_Connector.h | 171 + dep/ACE_wrappers/ace/Asynch_IO.cpp | 1414 + dep/ACE_wrappers/ace/Asynch_IO.h | 1734 + dep/ACE_wrappers/ace/Asynch_IO_Impl.cpp | 117 + dep/ACE_wrappers/ace/Asynch_IO_Impl.h | 816 + dep/ACE_wrappers/ace/Asynch_IO_Impl.inl | 106 + dep/ACE_wrappers/ace/Asynch_Pseudo_Task.cpp | 130 + dep/ACE_wrappers/ace/Asynch_Pseudo_Task.h | 73 + dep/ACE_wrappers/ace/Atomic_Op.cpp | 310 + dep/ACE_wrappers/ace/Atomic_Op.h | 260 + dep/ACE_wrappers/ace/Atomic_Op.inl | 335 + dep/ACE_wrappers/ace/Atomic_Op_Sparc.c | 187 + dep/ACE_wrappers/ace/Atomic_Op_Sparc.h | 14 + dep/ACE_wrappers/ace/Atomic_Op_T.cpp | 82 + dep/ACE_wrappers/ace/Atomic_Op_T.h | 369 + dep/ACE_wrappers/ace/Atomic_Op_T.inl | 340 + dep/ACE_wrappers/ace/Auto_Event.cpp | 49 + dep/ACE_wrappers/ace/Auto_Event.h | 73 + dep/ACE_wrappers/ace/Auto_Event.inl | 12 + dep/ACE_wrappers/ace/Auto_Functor.cpp | 39 + dep/ACE_wrappers/ace/Auto_Functor.h | 127 + dep/ACE_wrappers/ace/Auto_Functor.inl | 134 + dep/ACE_wrappers/ace/Auto_IncDec_T.cpp | 34 + dep/ACE_wrappers/ace/Auto_IncDec_T.h | 91 + dep/ACE_wrappers/ace/Auto_IncDec_T.inl | 25 + dep/ACE_wrappers/ace/Auto_Ptr.cpp | 21 + dep/ACE_wrappers/ace/Auto_Ptr.h | 242 + dep/ACE_wrappers/ace/Auto_Ptr.inl | 171 + dep/ACE_wrappers/ace/Barrier.cpp | 197 + dep/ACE_wrappers/ace/Barrier.h | 215 + dep/ACE_wrappers/ace/Barrier.inl | 22 + dep/ACE_wrappers/ace/Base_Thread_Adapter.cpp | 128 + dep/ACE_wrappers/ace/Base_Thread_Adapter.h | 195 + dep/ACE_wrappers/ace/Base_Thread_Adapter.inl | 48 + .../ace/Based_Pointer_Repository.cpp | 119 + .../ace/Based_Pointer_Repository.h | 91 + dep/ACE_wrappers/ace/Based_Pointer_T.cpp | 121 + dep/ACE_wrappers/ace/Based_Pointer_T.h | 205 + dep/ACE_wrappers/ace/Based_Pointer_T.inl | 139 + dep/ACE_wrappers/ace/Basic_Stats.cpp | 78 + dep/ACE_wrappers/ace/Basic_Stats.h | 87 + dep/ACE_wrappers/ace/Basic_Stats.inl | 53 + dep/ACE_wrappers/ace/Basic_Types.cpp | 139 + dep/ACE_wrappers/ace/Basic_Types.h | 890 + dep/ACE_wrappers/ace/Basic_Types.inl | 954 + dep/ACE_wrappers/ace/Bound_Ptr.h | 388 + dep/ACE_wrappers/ace/Bound_Ptr.inl | 494 + dep/ACE_wrappers/ace/CDR_Base.cpp | 799 + dep/ACE_wrappers/ace/CDR_Base.h | 379 + dep/ACE_wrappers/ace/CDR_Base.inl | 255 + dep/ACE_wrappers/ace/CDR_Size.cpp | 262 + dep/ACE_wrappers/ace/CDR_Size.h | 241 + dep/ACE_wrappers/ace/CDR_Size.inl | 424 + dep/ACE_wrappers/ace/CDR_Stream.cpp | 2068 + dep/ACE_wrappers/ace/CDR_Stream.h | 1402 + dep/ACE_wrappers/ace/CDR_Stream.inl | 1728 + dep/ACE_wrappers/ace/CE_Screen_Output.cpp | 158 + dep/ACE_wrappers/ace/CE_Screen_Output.h | 109 + dep/ACE_wrappers/ace/CORBA_macros.h | 575 + dep/ACE_wrappers/ace/Cache_Map_Manager_T.cpp | 420 + dep/ACE_wrappers/ace/Cache_Map_Manager_T.h | 405 + dep/ACE_wrappers/ace/Cache_Map_Manager_T.inl | 245 + .../ace/Cached_Connect_Strategy_T.cpp | 734 + .../ace/Cached_Connect_Strategy_T.h | 262 + dep/ACE_wrappers/ace/Caching_Strategies_T.cpp | 59 + dep/ACE_wrappers/ace/Caching_Strategies_T.h | 552 + dep/ACE_wrappers/ace/Caching_Strategies_T.inl | 456 + dep/ACE_wrappers/ace/Caching_Utility_T.cpp | 499 + dep/ACE_wrappers/ace/Caching_Utility_T.h | 347 + dep/ACE_wrappers/ace/Capabilities.cpp | 355 + dep/ACE_wrappers/ace/Capabilities.h | 221 + dep/ACE_wrappers/ace/Capabilities.inl | 52 + dep/ACE_wrappers/ace/Cleanup.cpp | 192 + dep/ACE_wrappers/ace/Cleanup.h | 137 + dep/ACE_wrappers/ace/Cleanup.inl | 12 + dep/ACE_wrappers/ace/Cleanup_Strategies_T.cpp | 95 + dep/ACE_wrappers/ace/Cleanup_Strategies_T.h | 149 + dep/ACE_wrappers/ace/Codecs.cpp | 234 + dep/ACE_wrappers/ace/Codecs.h | 121 + dep/ACE_wrappers/ace/Codeset_IBM1047.cpp | 309 + dep/ACE_wrappers/ace/Codeset_IBM1047.h | 127 + dep/ACE_wrappers/ace/Codeset_Registry.cpp | 111 + dep/ACE_wrappers/ace/Codeset_Registry.h | 104 + dep/ACE_wrappers/ace/Codeset_Registry.inl | 102 + dep/ACE_wrappers/ace/Codeset_Registry_db.cpp | 33 + dep/ACE_wrappers/ace/Codeset_Symbols.h | 220 + .../ace/Condition_Recursive_Thread_Mutex.cpp | 129 + .../ace/Condition_Recursive_Thread_Mutex.h | 118 + dep/ACE_wrappers/ace/Condition_T.cpp | 122 + dep/ACE_wrappers/ace/Condition_T.h | 167 + dep/ACE_wrappers/ace/Condition_T.inl | 51 + .../ace/Condition_Thread_Mutex.cpp | 126 + dep/ACE_wrappers/ace/Condition_Thread_Mutex.h | 190 + .../ace/Condition_Thread_Mutex.inl | 74 + dep/ACE_wrappers/ace/Configuration.cpp | 2148 + dep/ACE_wrappers/ace/Configuration.h | 894 + dep/ACE_wrappers/ace/Configuration.inl | 13 + .../ace/Configuration_Import_Export.cpp | 670 + .../ace/Configuration_Import_Export.h | 215 + .../ace/Connection_Recycling_Strategy.cpp | 13 + .../ace/Connection_Recycling_Strategy.h | 63 + dep/ACE_wrappers/ace/Connector.cpp | 966 + dep/ACE_wrappers/ace/Connector.h | 563 + dep/ACE_wrappers/ace/Containers.cpp | 12 + dep/ACE_wrappers/ace/Containers.h | 71 + dep/ACE_wrappers/ace/Containers.inl | 25 + dep/ACE_wrappers/ace/Containers_T.cpp | 1932 + dep/ACE_wrappers/ace/Containers_T.h | 2073 + dep/ACE_wrappers/ace/Containers_T.inl | 479 + dep/ACE_wrappers/ace/Copy_Disabled.cpp | 23 + dep/ACE_wrappers/ace/Copy_Disabled.h | 65 + dep/ACE_wrappers/ace/Countdown_Time.cpp | 66 + dep/ACE_wrappers/ace/Countdown_Time.h | 80 + dep/ACE_wrappers/ace/DEV.cpp | 43 + dep/ACE_wrappers/ace/DEV.h | 78 + dep/ACE_wrappers/ace/DEV.inl | 18 + dep/ACE_wrappers/ace/DEV_Addr.cpp | 108 + dep/ACE_wrappers/ace/DEV_Addr.h | 90 + dep/ACE_wrappers/ace/DEV_Addr.inl | 51 + dep/ACE_wrappers/ace/DEV_Connector.cpp | 53 + dep/ACE_wrappers/ace/DEV_Connector.h | 110 + dep/ACE_wrappers/ace/DEV_Connector.inl | 34 + dep/ACE_wrappers/ace/DEV_IO.cpp | 131 + dep/ACE_wrappers/ace/DEV_IO.h | 185 + dep/ACE_wrappers/ace/DEV_IO.inl | 126 + dep/ACE_wrappers/ace/DLL.cpp | 267 + dep/ACE_wrappers/ace/DLL.h | 196 + dep/ACE_wrappers/ace/DLL_Manager.cpp | 787 + dep/ACE_wrappers/ace/DLL_Manager.h | 269 + dep/ACE_wrappers/ace/Date_Time.cpp | 10 + dep/ACE_wrappers/ace/Date_Time.h | 125 + dep/ACE_wrappers/ace/Date_Time.inl | 219 + dep/ACE_wrappers/ace/Default_Constants.h | 573 + dep/ACE_wrappers/ace/Dev_Poll_Reactor.cpp | 2516 ++ dep/ACE_wrappers/ace/Dev_Poll_Reactor.h | 1252 + dep/ACE_wrappers/ace/Dev_Poll_Reactor.inl | 228 + dep/ACE_wrappers/ace/Dirent.cpp | 7 + dep/ACE_wrappers/ace/Dirent.h | 122 + dep/ACE_wrappers/ace/Dirent.inl | 99 + dep/ACE_wrappers/ace/Dirent_Selector.cpp | 59 + dep/ACE_wrappers/ace/Dirent_Selector.h | 75 + dep/ACE_wrappers/ace/Dirent_Selector.inl | 19 + dep/ACE_wrappers/ace/Dump.cpp | 141 + dep/ACE_wrappers/ace/Dump.h | 172 + dep/ACE_wrappers/ace/Dump_T.cpp | 48 + dep/ACE_wrappers/ace/Dump_T.h | 82 + dep/ACE_wrappers/ace/Dynamic.cpp | 34 + dep/ACE_wrappers/ace/Dynamic.h | 75 + dep/ACE_wrappers/ace/Dynamic.inl | 34 + .../ace/Dynamic_Message_Strategy.cpp | 205 + .../ace/Dynamic_Message_Strategy.h | 217 + .../ace/Dynamic_Message_Strategy.inl | 75 + dep/ACE_wrappers/ace/Dynamic_Service.cpp | 63 + dep/ACE_wrappers/ace/Dynamic_Service.h | 89 + dep/ACE_wrappers/ace/Dynamic_Service.inl | 39 + dep/ACE_wrappers/ace/Dynamic_Service_Base.cpp | 101 + dep/ACE_wrappers/ace/Dynamic_Service_Base.h | 74 + .../ace/Dynamic_Service_Dependency.cpp | 51 + .../ace/Dynamic_Service_Dependency.h | 70 + dep/ACE_wrappers/ace/Encoding_Converter.cpp | 12 + dep/ACE_wrappers/ace/Encoding_Converter.h | 70 + .../ace/Encoding_Converter_Factory.cpp | 74 + .../ace/Encoding_Converter_Factory.h | 54 + dep/ACE_wrappers/ace/Env_Value_T.cpp | 12 + dep/ACE_wrappers/ace/Env_Value_T.h | 166 + dep/ACE_wrappers/ace/Env_Value_T.inl | 60 + dep/ACE_wrappers/ace/Event.cpp | 93 + dep/ACE_wrappers/ace/Event.h | 143 + dep/ACE_wrappers/ace/Event.inl | 18 + dep/ACE_wrappers/ace/Event_Handler.cpp | 396 + dep/ACE_wrappers/ace/Event_Handler.h | 388 + dep/ACE_wrappers/ace/Event_Handler.inl | 12 + dep/ACE_wrappers/ace/Event_Handler_T.cpp | 125 + dep/ACE_wrappers/ace/Event_Handler_T.h | 191 + dep/ACE_wrappers/ace/Event_Handler_T.inl | 135 + dep/ACE_wrappers/ace/Exception_Macros.h | 55 + dep/ACE_wrappers/ace/FIFO.cpp | 78 + dep/ACE_wrappers/ace/FIFO.h | 85 + dep/ACE_wrappers/ace/FIFO.inl | 25 + dep/ACE_wrappers/ace/FIFO_Recv.cpp | 88 + dep/ACE_wrappers/ace/FIFO_Recv.h | 85 + dep/ACE_wrappers/ace/FIFO_Recv.inl | 24 + dep/ACE_wrappers/ace/FIFO_Recv_Msg.cpp | 67 + dep/ACE_wrappers/ace/FIFO_Recv_Msg.h | 138 + dep/ACE_wrappers/ace/FIFO_Recv_Msg.inl | 137 + dep/ACE_wrappers/ace/FIFO_Send.cpp | 58 + dep/ACE_wrappers/ace/FIFO_Send.h | 75 + dep/ACE_wrappers/ace/FIFO_Send.inl | 24 + dep/ACE_wrappers/ace/FIFO_Send_Msg.cpp | 80 + dep/ACE_wrappers/ace/FIFO_Send_Msg.h | 91 + dep/ACE_wrappers/ace/FIFO_Send_Msg.inl | 53 + dep/ACE_wrappers/ace/FILE.cpp | 147 + dep/ACE_wrappers/ace/FILE.h | 139 + dep/ACE_wrappers/ace/FILE.inl | 18 + dep/ACE_wrappers/ace/FILE_Addr.cpp | 124 + dep/ACE_wrappers/ace/FILE_Addr.h | 89 + dep/ACE_wrappers/ace/FILE_Addr.inl | 34 + dep/ACE_wrappers/ace/FILE_Connector.cpp | 84 + dep/ACE_wrappers/ace/FILE_Connector.h | 113 + dep/ACE_wrappers/ace/FILE_Connector.inl | 36 + dep/ACE_wrappers/ace/FILE_IO.cpp | 145 + dep/ACE_wrappers/ace/FILE_IO.h | 170 + dep/ACE_wrappers/ace/FILE_IO.inl | 152 + dep/ACE_wrappers/ace/File_Lock.cpp | 72 + dep/ACE_wrappers/ace/File_Lock.h | 170 + dep/ACE_wrappers/ace/File_Lock.inl | 96 + dep/ACE_wrappers/ace/Filecache.cpp | 754 + dep/ACE_wrappers/ace/Filecache.h | 353 + dep/ACE_wrappers/ace/Flag_Manip.cpp | 95 + dep/ACE_wrappers/ace/Flag_Manip.h | 58 + dep/ACE_wrappers/ace/Flag_Manip.inl | 26 + dep/ACE_wrappers/ace/Framework_Component.cpp | 279 + dep/ACE_wrappers/ace/Framework_Component.h | 210 + dep/ACE_wrappers/ace/Framework_Component.inl | 39 + .../ace/Framework_Component_T.cpp | 33 + dep/ACE_wrappers/ace/Framework_Component_T.h | 71 + dep/ACE_wrappers/ace/Free_List.cpp | 163 + dep/ACE_wrappers/ace/Free_List.h | 150 + dep/ACE_wrappers/ace/Functor.cpp | 43 + dep/ACE_wrappers/ace/Functor.h | 593 + dep/ACE_wrappers/ace/Functor.inl | 284 + dep/ACE_wrappers/ace/Functor_String.cpp | 7 + dep/ACE_wrappers/ace/Functor_String.h | 141 + dep/ACE_wrappers/ace/Functor_String.inl | 56 + dep/ACE_wrappers/ace/Functor_T.cpp | 49 + dep/ACE_wrappers/ace/Functor_T.h | 158 + dep/ACE_wrappers/ace/Functor_T.inl | 42 + dep/ACE_wrappers/ace/Future.cpp | 436 + dep/ACE_wrappers/ace/Future.h | 387 + dep/ACE_wrappers/ace/Future_Set.cpp | 136 + dep/ACE_wrappers/ace/Future_Set.h | 146 + dep/ACE_wrappers/ace/GNUmakefile | 83 + dep/ACE_wrappers/ace/GNUmakefile.ACE | 485 + .../ace/GNUmakefile.ACE_FlReactor | 189 + .../ace/GNUmakefile.ACE_Qt3Reactor | 169 + .../ace/GNUmakefile.ACE_TkReactor | 163 + .../ace/GNUmakefile.ACE_XtReactor | 175 + dep/ACE_wrappers/ace/Get_Opt.cpp | 734 + dep/ACE_wrappers/ace/Get_Opt.h | 494 + dep/ACE_wrappers/ace/Get_Opt.inl | 97 + dep/ACE_wrappers/ace/Global_Macros.h | 1121 + dep/ACE_wrappers/ace/Guard_T.cpp | 61 + dep/ACE_wrappers/ace/Guard_T.h | 365 + dep/ACE_wrappers/ace/Guard_T.inl | 170 + dep/ACE_wrappers/ace/Handle_Gobbler.h | 68 + dep/ACE_wrappers/ace/Handle_Gobbler.inl | 78 + dep/ACE_wrappers/ace/Handle_Ops.cpp | 48 + dep/ACE_wrappers/ace/Handle_Ops.h | 50 + dep/ACE_wrappers/ace/Handle_Set.cpp | 570 + dep/ACE_wrappers/ace/Handle_Set.h | 240 + dep/ACE_wrappers/ace/Handle_Set.inl | 193 + .../ace/Hash_Cache_Map_Manager_T.cpp | 232 + .../ace/Hash_Cache_Map_Manager_T.h | 214 + .../ace/Hash_Cache_Map_Manager_T.inl | 73 + dep/ACE_wrappers/ace/Hash_Map_Manager.h | 31 + dep/ACE_wrappers/ace/Hash_Map_Manager_T.cpp | 530 + dep/ACE_wrappers/ace/Hash_Map_Manager_T.h | 1303 + dep/ACE_wrappers/ace/Hash_Map_Manager_T.inl | 1253 + .../ace/Hash_Map_With_Allocator_T.cpp | 35 + .../ace/Hash_Map_With_Allocator_T.h | 112 + .../ace/Hash_Map_With_Allocator_T.inl | 82 + .../ace/Hash_Multi_Map_Manager_T.cpp | 605 + .../ace/Hash_Multi_Map_Manager_T.h | 967 + .../ace/Hash_Multi_Map_Manager_T.inl | 994 + dep/ACE_wrappers/ace/Hashable.cpp | 36 + dep/ACE_wrappers/ace/Hashable.h | 65 + dep/ACE_wrappers/ace/Hashable.inl | 14 + dep/ACE_wrappers/ace/High_Res_Timer.cpp | 535 + dep/ACE_wrappers/ace/High_Res_Timer.h | 315 + dep/ACE_wrappers/ace/High_Res_Timer.inl | 153 + dep/ACE_wrappers/ace/ICMP_Socket.cpp | 186 + dep/ACE_wrappers/ace/ICMP_Socket.h | 110 + dep/ACE_wrappers/ace/INET_Addr.cpp | 1160 + dep/ACE_wrappers/ace/INET_Addr.h | 390 + dep/ACE_wrappers/ace/INET_Addr.inl | 257 + dep/ACE_wrappers/ace/IOStream.cpp | 665 + dep/ACE_wrappers/ace/IOStream.h | 512 + dep/ACE_wrappers/ace/IOStream_T.cpp | 247 + dep/ACE_wrappers/ace/IOStream_T.h | 297 + dep/ACE_wrappers/ace/IOStream_T.inl | 123 + dep/ACE_wrappers/ace/IO_Cntl_Msg.cpp | 51 + dep/ACE_wrappers/ace/IO_Cntl_Msg.h | 112 + dep/ACE_wrappers/ace/IO_Cntl_Msg.inl | 61 + dep/ACE_wrappers/ace/IO_SAP.cpp | 142 + dep/ACE_wrappers/ace/IO_SAP.h | 96 + dep/ACE_wrappers/ace/IO_SAP.inl | 42 + dep/ACE_wrappers/ace/IPC_SAP.cpp | 193 + dep/ACE_wrappers/ace/IPC_SAP.h | 96 + dep/ACE_wrappers/ace/IPC_SAP.inl | 40 + dep/ACE_wrappers/ace/If_Then_Else.h | 89 + dep/ACE_wrappers/ace/Init_ACE.cpp | 45 + dep/ACE_wrappers/ace/Init_ACE.h | 62 + dep/ACE_wrappers/ace/Intrusive_Auto_Ptr.cpp | 22 + dep/ACE_wrappers/ace/Intrusive_Auto_Ptr.h | 165 + dep/ACE_wrappers/ace/Intrusive_Auto_Ptr.inl | 147 + dep/ACE_wrappers/ace/Intrusive_List.cpp | 153 + dep/ACE_wrappers/ace/Intrusive_List.h | 144 + dep/ACE_wrappers/ace/Intrusive_List.inl | 40 + dep/ACE_wrappers/ace/Intrusive_List_Node.cpp | 27 + dep/ACE_wrappers/ace/Intrusive_List_Node.h | 85 + dep/ACE_wrappers/ace/Intrusive_List_Node.inl | 31 + dep/ACE_wrappers/ace/LOCK_SOCK_Acceptor.cpp | 35 + dep/ACE_wrappers/ace/LOCK_SOCK_Acceptor.h | 67 + dep/ACE_wrappers/ace/LSOCK.cpp | 181 + dep/ACE_wrappers/ace/LSOCK.h | 84 + dep/ACE_wrappers/ace/LSOCK.inl | 43 + dep/ACE_wrappers/ace/LSOCK_Acceptor.cpp | 143 + dep/ACE_wrappers/ace/LSOCK_Acceptor.h | 95 + dep/ACE_wrappers/ace/LSOCK_CODgram.cpp | 62 + dep/ACE_wrappers/ace/LSOCK_CODgram.h | 78 + dep/ACE_wrappers/ace/LSOCK_CODgram.inl | 30 + dep/ACE_wrappers/ace/LSOCK_Connector.cpp | 59 + dep/ACE_wrappers/ace/LSOCK_Connector.h | 91 + dep/ACE_wrappers/ace/LSOCK_Connector.inl | 27 + dep/ACE_wrappers/ace/LSOCK_Dgram.cpp | 71 + dep/ACE_wrappers/ace/LSOCK_Dgram.h | 74 + dep/ACE_wrappers/ace/LSOCK_Dgram.inl | 22 + dep/ACE_wrappers/ace/LSOCK_Stream.cpp | 137 + dep/ACE_wrappers/ace/LSOCK_Stream.h | 82 + dep/ACE_wrappers/ace/LSOCK_Stream.inl | 25 + dep/ACE_wrappers/ace/Lib_Find.cpp | 769 + dep/ACE_wrappers/ace/Lib_Find.h | 131 + dep/ACE_wrappers/ace/Local_Memory_Pool.cpp | 144 + dep/ACE_wrappers/ace/Local_Memory_Pool.h | 133 + dep/ACE_wrappers/ace/Local_Name_Space.cpp | 169 + dep/ACE_wrappers/ace/Local_Name_Space.h | 132 + dep/ACE_wrappers/ace/Local_Name_Space_T.cpp | 966 + dep/ACE_wrappers/ace/Local_Name_Space_T.h | 280 + dep/ACE_wrappers/ace/Local_Tokens.cpp | 1623 + dep/ACE_wrappers/ace/Local_Tokens.h | 1121 + dep/ACE_wrappers/ace/Local_Tokens.inl | 289 + dep/ACE_wrappers/ace/Lock.cpp | 88 + dep/ACE_wrappers/ace/Lock.h | 161 + dep/ACE_wrappers/ace/Lock.inl | 12 + dep/ACE_wrappers/ace/Lock_Adapter_T.cpp | 117 + dep/ACE_wrappers/ace/Lock_Adapter_T.h | 123 + dep/ACE_wrappers/ace/Lock_Adapter_T.inl | 16 + dep/ACE_wrappers/ace/Log_Msg.cpp | 2526 ++ dep/ACE_wrappers/ace/Log_Msg.h | 747 + dep/ACE_wrappers/ace/Log_Msg.inl | 235 + dep/ACE_wrappers/ace/Log_Msg_Backend.cpp | 14 + dep/ACE_wrappers/ace/Log_Msg_Backend.h | 88 + dep/ACE_wrappers/ace/Log_Msg_Callback.cpp | 13 + dep/ACE_wrappers/ace/Log_Msg_Callback.h | 69 + dep/ACE_wrappers/ace/Log_Msg_IPC.cpp | 111 + dep/ACE_wrappers/ace/Log_Msg_IPC.h | 79 + dep/ACE_wrappers/ace/Log_Msg_NT_Event_Log.cpp | 162 + dep/ACE_wrappers/ace/Log_Msg_NT_Event_Log.h | 72 + dep/ACE_wrappers/ace/Log_Msg_UNIX_Syslog.cpp | 207 + dep/ACE_wrappers/ace/Log_Msg_UNIX_Syslog.h | 76 + dep/ACE_wrappers/ace/Log_Priority.h | 85 + dep/ACE_wrappers/ace/Log_Record.cpp | 412 + dep/ACE_wrappers/ace/Log_Record.h | 223 + dep/ACE_wrappers/ace/Log_Record.inl | 123 + dep/ACE_wrappers/ace/Logging_Strategy.cpp | 566 + dep/ACE_wrappers/ace/Logging_Strategy.h | 195 + dep/ACE_wrappers/ace/MEM_Acceptor.cpp | 265 + dep/ACE_wrappers/ace/MEM_Acceptor.h | 192 + dep/ACE_wrappers/ace/MEM_Acceptor.inl | 103 + dep/ACE_wrappers/ace/MEM_Addr.cpp | 170 + dep/ACE_wrappers/ace/MEM_Addr.h | 155 + dep/ACE_wrappers/ace/MEM_Addr.inl | 111 + dep/ACE_wrappers/ace/MEM_Connector.cpp | 149 + dep/ACE_wrappers/ace/MEM_Connector.h | 179 + dep/ACE_wrappers/ace/MEM_Connector.inl | 30 + dep/ACE_wrappers/ace/MEM_IO.cpp | 574 + dep/ACE_wrappers/ace/MEM_IO.h | 310 + dep/ACE_wrappers/ace/MEM_IO.inl | 247 + dep/ACE_wrappers/ace/MEM_SAP.cpp | 97 + dep/ACE_wrappers/ace/MEM_SAP.h | 169 + dep/ACE_wrappers/ace/MEM_SAP.inl | 64 + dep/ACE_wrappers/ace/MEM_Stream.cpp | 47 + dep/ACE_wrappers/ace/MEM_Stream.h | 158 + dep/ACE_wrappers/ace/MEM_Stream.inl | 180 + dep/ACE_wrappers/ace/MMAP_Memory_Pool.cpp | 594 + dep/ACE_wrappers/ace/MMAP_Memory_Pool.h | 347 + dep/ACE_wrappers/ace/MMAP_Memory_Pool.inl | 21 + dep/ACE_wrappers/ace/Makefile.am | 341 + dep/ACE_wrappers/ace/Malloc.cpp | 187 + dep/ACE_wrappers/ace/Malloc.h | 396 + dep/ACE_wrappers/ace/Malloc.inl | 26 + dep/ACE_wrappers/ace/Malloc_Allocator.cpp | 361 + dep/ACE_wrappers/ace/Malloc_Allocator.h | 146 + dep/ACE_wrappers/ace/Malloc_Allocator.inl | 16 + dep/ACE_wrappers/ace/Malloc_Base.h | 168 + dep/ACE_wrappers/ace/Malloc_T.cpp | 1262 + dep/ACE_wrappers/ace/Malloc_T.h | 931 + dep/ACE_wrappers/ace/Malloc_T.inl | 184 + dep/ACE_wrappers/ace/Managed_Object.cpp | 25 + dep/ACE_wrappers/ace/Managed_Object.h | 168 + dep/ACE_wrappers/ace/Managed_Object.inl | 23 + dep/ACE_wrappers/ace/Manual_Event.cpp | 48 + dep/ACE_wrappers/ace/Manual_Event.h | 74 + dep/ACE_wrappers/ace/Manual_Event.inl | 12 + dep/ACE_wrappers/ace/Map.h | 32 + dep/ACE_wrappers/ace/Map_Manager.cpp | 701 + dep/ACE_wrappers/ace/Map_Manager.h | 719 + dep/ACE_wrappers/ace/Map_Manager.inl | 729 + dep/ACE_wrappers/ace/Map_T.cpp | 1343 + dep/ACE_wrappers/ace/Map_T.h | 1611 + dep/ACE_wrappers/ace/Map_T.inl | 415 + dep/ACE_wrappers/ace/Mem_Map.cpp | 310 + dep/ACE_wrappers/ace/Mem_Map.h | 235 + dep/ACE_wrappers/ace/Mem_Map.inl | 238 + dep/ACE_wrappers/ace/Memory_Pool.h | 31 + dep/ACE_wrappers/ace/Message_Block.cpp | 1273 + dep/ACE_wrappers/ace/Message_Block.h | 871 + dep/ACE_wrappers/ace/Message_Block.inl | 508 + dep/ACE_wrappers/ace/Message_Block_T.cpp | 54 + dep/ACE_wrappers/ace/Message_Block_T.h | 88 + dep/ACE_wrappers/ace/Message_Block_T.inl | 31 + dep/ACE_wrappers/ace/Message_Queue.cpp | 28 + dep/ACE_wrappers/ace/Message_Queue.h | 237 + dep/ACE_wrappers/ace/Message_Queue.inl | 12 + dep/ACE_wrappers/ace/Message_Queue_NT.cpp | 237 + dep/ACE_wrappers/ace/Message_Queue_NT.h | 231 + dep/ACE_wrappers/ace/Message_Queue_NT.inl | 131 + dep/ACE_wrappers/ace/Message_Queue_T.cpp | 2966 ++ dep/ACE_wrappers/ace/Message_Queue_T.h | 1563 + dep/ACE_wrappers/ace/Message_Queue_Vx.cpp | 368 + dep/ACE_wrappers/ace/Message_Queue_Vx.h | 227 + dep/ACE_wrappers/ace/Message_Queue_Vx.inl | 19 + dep/ACE_wrappers/ace/Method_Object.h | 38 + dep/ACE_wrappers/ace/Method_Request.cpp | 30 + dep/ACE_wrappers/ace/Method_Request.h | 100 + dep/ACE_wrappers/ace/Metrics_Cache.h | 140 + dep/ACE_wrappers/ace/Metrics_Cache_T.cpp | 237 + dep/ACE_wrappers/ace/Metrics_Cache_T.h | 243 + dep/ACE_wrappers/ace/Metrics_Cache_T.inl | 240 + dep/ACE_wrappers/ace/Min_Max.h | 70 + dep/ACE_wrappers/ace/Module.cpp | 273 + dep/ACE_wrappers/ace/Module.h | 215 + dep/ACE_wrappers/ace/Module.inl | 65 + dep/ACE_wrappers/ace/Monitor_Admin.cpp | 113 + dep/ACE_wrappers/ace/Monitor_Admin.h | 109 + .../ace/Monitor_Admin_Manager.cpp | 42 + dep/ACE_wrappers/ace/Monitor_Admin_Manager.h | 70 + dep/ACE_wrappers/ace/Monitor_Base.cpp | 402 + dep/ACE_wrappers/ace/Monitor_Base.h | 152 + dep/ACE_wrappers/ace/Monitor_Base.inl | 59 + .../ace/Monitor_Control_Action.cpp | 45 + dep/ACE_wrappers/ace/Monitor_Control_Action.h | 65 + .../ace/Monitor_Control_Types.cpp | 78 + dep/ACE_wrappers/ace/Monitor_Control_Types.h | 124 + .../ace/Monitor_Point_Registry.cpp | 172 + dep/ACE_wrappers/ace/Monitor_Point_Registry.h | 100 + dep/ACE_wrappers/ace/Monitor_Size.cpp | 47 + dep/ACE_wrappers/ace/Monitor_Size.h | 64 + dep/ACE_wrappers/ace/Msg_WFMO_Reactor.cpp | 85 + dep/ACE_wrappers/ace/Msg_WFMO_Reactor.h | 120 + dep/ACE_wrappers/ace/Msg_WFMO_Reactor.inl | 35 + dep/ACE_wrappers/ace/Multihomed_INET_Addr.cpp | 300 + dep/ACE_wrappers/ace/Multihomed_INET_Addr.h | 198 + dep/ACE_wrappers/ace/Multihomed_INET_Addr.inl | 15 + dep/ACE_wrappers/ace/Mutex.cpp | 125 + dep/ACE_wrappers/ace/Mutex.h | 192 + dep/ACE_wrappers/ace/Mutex.inl | 175 + dep/ACE_wrappers/ace/NT_Service.cpp | 618 + dep/ACE_wrappers/ace/NT_Service.h | 439 + dep/ACE_wrappers/ace/NT_Service.inl | 85 + dep/ACE_wrappers/ace/Name_Proxy.cpp | 209 + dep/ACE_wrappers/ace/Name_Proxy.h | 101 + dep/ACE_wrappers/ace/Name_Request_Reply.cpp | 577 + dep/ACE_wrappers/ace/Name_Request_Reply.h | 265 + dep/ACE_wrappers/ace/Name_Space.cpp | 73 + dep/ACE_wrappers/ace/Name_Space.h | 165 + dep/ACE_wrappers/ace/Naming_Context.cpp | 649 + dep/ACE_wrappers/ace/Naming_Context.h | 387 + dep/ACE_wrappers/ace/Naming_Context.inl | 44 + dep/ACE_wrappers/ace/Netlink_Addr.cpp | 68 + dep/ACE_wrappers/ace/Netlink_Addr.h | 120 + dep/ACE_wrappers/ace/Netlink_Addr.inl | 51 + dep/ACE_wrappers/ace/Node.cpp | 46 + dep/ACE_wrappers/ace/Node.h | 85 + dep/ACE_wrappers/ace/Notification_Queue.cpp | 228 + dep/ACE_wrappers/ace/Notification_Queue.h | 156 + dep/ACE_wrappers/ace/Notification_Queue.inl | 50 + .../ace/Notification_Strategy.cpp | 22 + dep/ACE_wrappers/ace/Notification_Strategy.h | 75 + .../ace/Notification_Strategy.inl | 31 + dep/ACE_wrappers/ace/Null_Barrier.h | 59 + dep/ACE_wrappers/ace/Null_Condition.h | 85 + dep/ACE_wrappers/ace/Null_Mutex.h | 232 + dep/ACE_wrappers/ace/Null_Semaphore.h | 105 + dep/ACE_wrappers/ace/Numeric_Limits.h | 270 + dep/ACE_wrappers/ace/OS.cpp | 53 + dep/ACE_wrappers/ace/OS.h | 329 + dep/ACE_wrappers/ace/OS.inl | 93 + dep/ACE_wrappers/ace/OS_Dirent.h | 32 + dep/ACE_wrappers/ace/OS_Errno.cpp | 47 + dep/ACE_wrappers/ace/OS_Errno.h | 101 + dep/ACE_wrappers/ace/OS_Errno.inl | 67 + .../ace/OS_Log_Msg_Attributes.cpp | 9 + dep/ACE_wrappers/ace/OS_Log_Msg_Attributes.h | 90 + .../ace/OS_Log_Msg_Attributes.inl | 12 + dep/ACE_wrappers/ace/OS_Memory.h | 338 + dep/ACE_wrappers/ace/OS_NS_Thread.cpp | 5333 +++ dep/ACE_wrappers/ace/OS_NS_Thread.h | 2025 + dep/ACE_wrappers/ace/OS_NS_Thread.inl | 3636 ++ dep/ACE_wrappers/ace/OS_NS_arpa_inet.cpp | 53 + dep/ACE_wrappers/ace/OS_NS_arpa_inet.h | 74 + dep/ACE_wrappers/ace/OS_NS_arpa_inet.inl | 98 + dep/ACE_wrappers/ace/OS_NS_ctype.cpp | 11 + dep/ACE_wrappers/ace/OS_NS_ctype.h | 130 + dep/ACE_wrappers/ace/OS_NS_ctype.inl | 163 + dep/ACE_wrappers/ace/OS_NS_dirent.cpp | 274 + dep/ACE_wrappers/ace/OS_NS_dirent.h | 153 + dep/ACE_wrappers/ace/OS_NS_dirent.inl | 184 + dep/ACE_wrappers/ace/OS_NS_dlfcn.cpp | 10 + dep/ACE_wrappers/ace/OS_NS_dlfcn.h | 69 + dep/ACE_wrappers/ace/OS_NS_dlfcn.inl | 286 + dep/ACE_wrappers/ace/OS_NS_errno.cpp | 11 + dep/ACE_wrappers/ace/OS_NS_errno.h | 100 + dep/ACE_wrappers/ace/OS_NS_errno.inl | 83 + dep/ACE_wrappers/ace/OS_NS_fcntl.cpp | 245 + dep/ACE_wrappers/ace/OS_NS_fcntl.h | 83 + dep/ACE_wrappers/ace/OS_NS_fcntl.inl | 23 + dep/ACE_wrappers/ace/OS_NS_macros.h | 114 + dep/ACE_wrappers/ace/OS_NS_math.cpp | 10 + dep/ACE_wrappers/ace/OS_NS_math.h | 115 + dep/ACE_wrappers/ace/OS_NS_math.inl | 41 + dep/ACE_wrappers/ace/OS_NS_netdb.cpp | 421 + dep/ACE_wrappers/ace/OS_NS_netdb.h | 146 + dep/ACE_wrappers/ace/OS_NS_netdb.inl | 750 + dep/ACE_wrappers/ace/OS_NS_poll.cpp | 10 + dep/ACE_wrappers/ace/OS_NS_poll.h | 66 + dep/ACE_wrappers/ace/OS_NS_poll.inl | 45 + dep/ACE_wrappers/ace/OS_NS_pwd.cpp | 10 + dep/ACE_wrappers/ace/OS_NS_pwd.h | 81 + dep/ACE_wrappers/ace/OS_NS_pwd.inl | 120 + dep/ACE_wrappers/ace/OS_NS_regex.cpp | 10 + dep/ACE_wrappers/ace/OS_NS_regex.h | 65 + dep/ACE_wrappers/ace/OS_NS_regex.inl | 39 + dep/ACE_wrappers/ace/OS_NS_signal.cpp | 26 + dep/ACE_wrappers/ace/OS_NS_signal.h | 153 + dep/ACE_wrappers/ace/OS_NS_signal.inl | 232 + dep/ACE_wrappers/ace/OS_NS_stdio.cpp | 462 + dep/ACE_wrappers/ace/OS_NS_stdio.h | 542 + dep/ACE_wrappers/ace/OS_NS_stdio.inl | 1211 + dep/ACE_wrappers/ace/OS_NS_stdlib.cpp | 872 + dep/ACE_wrappers/ace/OS_NS_stdlib.h | 332 + dep/ACE_wrappers/ace/OS_NS_stdlib.inl | 556 + dep/ACE_wrappers/ace/OS_NS_string.cpp | 377 + dep/ACE_wrappers/ace/OS_NS_string.h | 471 + dep/ACE_wrappers/ace/OS_NS_string.inl | 560 + dep/ACE_wrappers/ace/OS_NS_strings.cpp | 84 + dep/ACE_wrappers/ace/OS_NS_strings.h | 86 + dep/ACE_wrappers/ace/OS_NS_strings.inl | 59 + dep/ACE_wrappers/ace/OS_NS_stropts.cpp | 195 + dep/ACE_wrappers/ace/OS_NS_stropts.h | 172 + dep/ACE_wrappers/ace/OS_NS_stropts.inl | 201 + dep/ACE_wrappers/ace/OS_NS_sys_mman.cpp | 10 + dep/ACE_wrappers/ace/OS_NS_sys_mman.h | 97 + dep/ACE_wrappers/ace/OS_NS_sys_mman.inl | 297 + dep/ACE_wrappers/ace/OS_NS_sys_msg.cpp | 10 + dep/ACE_wrappers/ace/OS_NS_sys_msg.h | 77 + dep/ACE_wrappers/ace/OS_NS_sys_msg.inl | 78 + dep/ACE_wrappers/ace/OS_NS_sys_resource.cpp | 10 + dep/ACE_wrappers/ace/OS_NS_sys_resource.h | 67 + dep/ACE_wrappers/ace/OS_NS_sys_resource.inl | 98 + dep/ACE_wrappers/ace/OS_NS_sys_select.cpp | 10 + dep/ACE_wrappers/ace/OS_NS_sys_select.h | 77 + dep/ACE_wrappers/ace/OS_NS_sys_select.inl | 80 + dep/ACE_wrappers/ace/OS_NS_sys_sendfile.cpp | 53 + dep/ACE_wrappers/ace/OS_NS_sys_sendfile.h | 65 + dep/ACE_wrappers/ace/OS_NS_sys_sendfile.inl | 24 + dep/ACE_wrappers/ace/OS_NS_sys_shm.cpp | 10 + dep/ACE_wrappers/ace/OS_NS_sys_shm.h | 74 + dep/ACE_wrappers/ace/OS_NS_sys_shm.inl | 76 + dep/ACE_wrappers/ace/OS_NS_sys_socket.cpp | 161 + dep/ACE_wrappers/ace/OS_NS_sys_socket.h | 302 + dep/ACE_wrappers/ace/OS_NS_sys_socket.inl | 1002 + dep/ACE_wrappers/ace/OS_NS_sys_stat.cpp | 10 + dep/ACE_wrappers/ace/OS_NS_sys_stat.h | 149 + dep/ACE_wrappers/ace/OS_NS_sys_stat.inl | 292 + dep/ACE_wrappers/ace/OS_NS_sys_time.cpp | 10 + dep/ACE_wrappers/ace/OS_NS_sys_time.h | 69 + dep/ACE_wrappers/ace/OS_NS_sys_time.inl | 96 + dep/ACE_wrappers/ace/OS_NS_sys_uio.cpp | 130 + dep/ACE_wrappers/ace/OS_NS_sys_uio.h | 80 + dep/ACE_wrappers/ace/OS_NS_sys_uio.inl | 55 + dep/ACE_wrappers/ace/OS_NS_sys_utsname.cpp | 237 + dep/ACE_wrappers/ace/OS_NS_sys_utsname.h | 71 + dep/ACE_wrappers/ace/OS_NS_sys_wait.cpp | 9 + dep/ACE_wrappers/ace/OS_NS_sys_wait.h | 87 + dep/ACE_wrappers/ace/OS_NS_sys_wait.inl | 105 + dep/ACE_wrappers/ace/OS_NS_time.cpp | 637 + dep/ACE_wrappers/ace/OS_NS_time.h | 288 + dep/ACE_wrappers/ace/OS_NS_time.inl | 505 + dep/ACE_wrappers/ace/OS_NS_unistd.cpp | 900 + dep/ACE_wrappers/ace/OS_NS_unistd.h | 382 + dep/ACE_wrappers/ace/OS_NS_unistd.inl | 1193 + dep/ACE_wrappers/ace/OS_NS_wchar.cpp | 377 + dep/ACE_wrappers/ace/OS_NS_wchar.h | 199 + dep/ACE_wrappers/ace/OS_NS_wchar.inl | 87 + dep/ACE_wrappers/ace/OS_QoS.cpp | 476 + dep/ACE_wrappers/ace/OS_QoS.h | 449 + dep/ACE_wrappers/ace/OS_String.h | 32 + dep/ACE_wrappers/ace/OS_TLI.cpp | 9 + dep/ACE_wrappers/ace/OS_TLI.h | 285 + dep/ACE_wrappers/ace/OS_TLI.inl | 390 + dep/ACE_wrappers/ace/OS_Thread_Adapter.cpp | 153 + dep/ACE_wrappers/ace/OS_Thread_Adapter.h | 72 + dep/ACE_wrappers/ace/OS_main.cpp | 127 + dep/ACE_wrappers/ace/OS_main.h | 305 + dep/ACE_wrappers/ace/Obchunk.cpp | 36 + dep/ACE_wrappers/ace/Obchunk.h | 77 + dep/ACE_wrappers/ace/Obchunk.inl | 12 + dep/ACE_wrappers/ace/Object_Manager.cpp | 889 + dep/ACE_wrappers/ace/Object_Manager.h | 466 + dep/ACE_wrappers/ace/Object_Manager.inl | 40 + dep/ACE_wrappers/ace/Object_Manager_Base.cpp | 506 + dep/ACE_wrappers/ace/Object_Manager_Base.h | 248 + dep/ACE_wrappers/ace/Obstack.h | 31 + dep/ACE_wrappers/ace/Obstack_T.cpp | 226 + dep/ACE_wrappers/ace/Obstack_T.h | 134 + dep/ACE_wrappers/ace/Obstack_T.inl | 19 + dep/ACE_wrappers/ace/PI_Malloc.cpp | 165 + dep/ACE_wrappers/ace/PI_Malloc.h | 213 + dep/ACE_wrappers/ace/PI_Malloc.inl | 33 + dep/ACE_wrappers/ace/POSIX_Asynch_IO.cpp | 2421 ++ dep/ACE_wrappers/ace/POSIX_Asynch_IO.h | 1302 + dep/ACE_wrappers/ace/POSIX_CB_Proactor.cpp | 185 + dep/ACE_wrappers/ace/POSIX_CB_Proactor.h | 97 + dep/ACE_wrappers/ace/POSIX_Proactor.cpp | 2064 + dep/ACE_wrappers/ace/POSIX_Proactor.h | 659 + dep/ACE_wrappers/ace/POSIX_Proactor.inl | 13 + dep/ACE_wrappers/ace/Pagefile_Memory_Pool.cpp | 385 + dep/ACE_wrappers/ace/Pagefile_Memory_Pool.h | 201 + dep/ACE_wrappers/ace/Pagefile_Memory_Pool.inl | 54 + dep/ACE_wrappers/ace/Pair.h | 32 + dep/ACE_wrappers/ace/Pair_T.cpp | 16 + dep/ACE_wrappers/ace/Pair_T.h | 129 + dep/ACE_wrappers/ace/Pair_T.inl | 90 + dep/ACE_wrappers/ace/Parse_Node.cpp | 885 + dep/ACE_wrappers/ace/Parse_Node.h | 523 + dep/ACE_wrappers/ace/Ping_Socket.cpp | 377 + dep/ACE_wrappers/ace/Ping_Socket.h | 118 + dep/ACE_wrappers/ace/Ping_Socket.inl | 13 + dep/ACE_wrappers/ace/Pipe.cpp | 360 + dep/ACE_wrappers/ace/Pipe.h | 165 + dep/ACE_wrappers/ace/Pipe.inl | 188 + dep/ACE_wrappers/ace/Priority_Reactor.cpp | 188 + dep/ACE_wrappers/ace/Priority_Reactor.h | 100 + dep/ACE_wrappers/ace/Proactor.cpp | 1176 + dep/ACE_wrappers/ace/Proactor.h | 691 + dep/ACE_wrappers/ace/Proactor.inl | 80 + dep/ACE_wrappers/ace/Proactor_Impl.cpp | 21 + dep/ACE_wrappers/ace/Proactor_Impl.h | 265 + dep/ACE_wrappers/ace/Process.cpp | 1391 + dep/ACE_wrappers/ace/Process.h | 635 + dep/ACE_wrappers/ace/Process.inl | 412 + dep/ACE_wrappers/ace/Process_Manager.cpp | 1023 + dep/ACE_wrappers/ace/Process_Manager.h | 477 + dep/ACE_wrappers/ace/Process_Manager.inl | 13 + dep/ACE_wrappers/ace/Process_Mutex.cpp | 90 + dep/ACE_wrappers/ace/Process_Mutex.h | 216 + dep/ACE_wrappers/ace/Process_Mutex.inl | 118 + dep/ACE_wrappers/ace/Process_Semaphore.cpp | 111 + dep/ACE_wrappers/ace/Process_Semaphore.h | 161 + dep/ACE_wrappers/ace/Process_Semaphore.inl | 66 + dep/ACE_wrappers/ace/Profile_Timer.cpp | 443 + dep/ACE_wrappers/ace/Profile_Timer.h | 139 + dep/ACE_wrappers/ace/Profile_Timer.inl | 129 + dep/ACE_wrappers/ace/RB_Tree.cpp | 1250 + dep/ACE_wrappers/ace/RB_Tree.h | 904 + dep/ACE_wrappers/ace/RB_Tree.inl | 1169 + dep/ACE_wrappers/ace/README | 1866 + dep/ACE_wrappers/ace/RW_Mutex.cpp | 55 + dep/ACE_wrappers/ace/RW_Mutex.h | 141 + dep/ACE_wrappers/ace/RW_Mutex.inl | 83 + dep/ACE_wrappers/ace/RW_Process_Mutex.cpp | 54 + dep/ACE_wrappers/ace/RW_Process_Mutex.h | 144 + dep/ACE_wrappers/ace/RW_Process_Mutex.inl | 77 + dep/ACE_wrappers/ace/RW_Thread_Mutex.cpp | 45 + dep/ACE_wrappers/ace/RW_Thread_Mutex.h | 74 + dep/ACE_wrappers/ace/RW_Thread_Mutex.inl | 19 + dep/ACE_wrappers/ace/Reactor.cpp | 512 + dep/ACE_wrappers/ace/Reactor.h | 880 + dep/ACE_wrappers/ace/Reactor.inl | 498 + dep/ACE_wrappers/ace/Reactor_Impl.cpp | 15 + dep/ACE_wrappers/ace/Reactor_Impl.h | 569 + .../ace/Reactor_Notification_Strategy.cpp | 38 + .../ace/Reactor_Notification_Strategy.h | 66 + .../ace/Reactor_Notification_Strategy.inl | 19 + .../ace/Reactor_Timer_Interface.cpp | 16 + .../ace/Reactor_Timer_Interface.h | 60 + dep/ACE_wrappers/ace/Reactor_Token_T.cpp | 70 + dep/ACE_wrappers/ace/Reactor_Token_T.h | 93 + dep/ACE_wrappers/ace/Read_Buffer.cpp | 176 + dep/ACE_wrappers/ace/Read_Buffer.h | 129 + dep/ACE_wrappers/ace/Read_Buffer.inl | 32 + .../ace/Recursive_Thread_Mutex.cpp | 125 + dep/ACE_wrappers/ace/Recursive_Thread_Mutex.h | 194 + .../ace/Recursive_Thread_Mutex.inl | 95 + dep/ACE_wrappers/ace/Recyclable.cpp | 22 + dep/ACE_wrappers/ace/Recyclable.h | 79 + dep/ACE_wrappers/ace/Recyclable.inl | 20 + dep/ACE_wrappers/ace/Refcountable.h | 32 + dep/ACE_wrappers/ace/Refcountable_T.cpp | 25 + dep/ACE_wrappers/ace/Refcountable_T.h | 67 + dep/ACE_wrappers/ace/Refcountable_T.inl | 35 + dep/ACE_wrappers/ace/Refcounted_Auto_Ptr.cpp | 18 + dep/ACE_wrappers/ace/Refcounted_Auto_Ptr.h | 199 + dep/ACE_wrappers/ace/Refcounted_Auto_Ptr.inl | 190 + dep/ACE_wrappers/ace/Registry.cpp | 1121 + dep/ACE_wrappers/ace/Registry.h | 559 + dep/ACE_wrappers/ace/Registry_Name_Space.cpp | 293 + dep/ACE_wrappers/ace/Registry_Name_Space.h | 140 + dep/ACE_wrappers/ace/Remote_Name_Space.cpp | 380 + dep/ACE_wrappers/ace/Remote_Name_Space.h | 147 + dep/ACE_wrappers/ace/Remote_Tokens.cpp | 527 + dep/ACE_wrappers/ace/Remote_Tokens.h | 322 + dep/ACE_wrappers/ace/Remote_Tokens.inl | 48 + dep/ACE_wrappers/ace/Reverse_Lock_T.cpp | 93 + dep/ACE_wrappers/ace/Reverse_Lock_T.h | 139 + dep/ACE_wrappers/ace/Reverse_Lock_T.inl | 19 + dep/ACE_wrappers/ace/Rtems_init.c | 219 + dep/ACE_wrappers/ace/SOCK.cpp | 185 + dep/ACE_wrappers/ace/SOCK.h | 138 + dep/ACE_wrappers/ace/SOCK.inl | 39 + dep/ACE_wrappers/ace/SOCK_Acceptor.cpp | 406 + dep/ACE_wrappers/ace/SOCK_Acceptor.h | 178 + dep/ACE_wrappers/ace/SOCK_Acceptor.inl | 13 + dep/ACE_wrappers/ace/SOCK_CODgram.cpp | 151 + dep/ACE_wrappers/ace/SOCK_CODgram.h | 143 + dep/ACE_wrappers/ace/SOCK_CODgram.inl | 19 + dep/ACE_wrappers/ace/SOCK_Connector.cpp | 359 + dep/ACE_wrappers/ace/SOCK_Connector.h | 321 + dep/ACE_wrappers/ace/SOCK_Connector.inl | 38 + dep/ACE_wrappers/ace/SOCK_Dgram.cpp | 750 + dep/ACE_wrappers/ace/SOCK_Dgram.h | 239 + dep/ACE_wrappers/ace/SOCK_Dgram.inl | 167 + dep/ACE_wrappers/ace/SOCK_Dgram_Bcast.cpp | 380 + dep/ACE_wrappers/ace/SOCK_Dgram_Bcast.h | 140 + dep/ACE_wrappers/ace/SOCK_Dgram_Bcast.inl | 37 + dep/ACE_wrappers/ace/SOCK_Dgram_Mcast.cpp | 932 + dep/ACE_wrappers/ace/SOCK_Dgram_Mcast.h | 384 + dep/ACE_wrappers/ace/SOCK_Dgram_Mcast.inl | 52 + dep/ACE_wrappers/ace/SOCK_IO.cpp | 181 + dep/ACE_wrappers/ace/SOCK_IO.h | 136 + dep/ACE_wrappers/ace/SOCK_IO.inl | 123 + dep/ACE_wrappers/ace/SOCK_Netlink.cpp | 113 + dep/ACE_wrappers/ace/SOCK_Netlink.h | 106 + dep/ACE_wrappers/ace/SOCK_Netlink.inl | 37 + .../ace/SOCK_SEQPACK_Acceptor.cpp | 596 + dep/ACE_wrappers/ace/SOCK_SEQPACK_Acceptor.h | 190 + .../ace/SOCK_SEQPACK_Acceptor.inl | 13 + .../ace/SOCK_SEQPACK_Association.cpp | 339 + .../ace/SOCK_SEQPACK_Association.h | 202 + .../ace/SOCK_SEQPACK_Association.inl | 177 + .../ace/SOCK_SEQPACK_Connector.cpp | 443 + dep/ACE_wrappers/ace/SOCK_SEQPACK_Connector.h | 331 + .../ace/SOCK_SEQPACK_Connector.inl | 38 + dep/ACE_wrappers/ace/SOCK_Stream.cpp | 40 + dep/ACE_wrappers/ace/SOCK_Stream.h | 184 + dep/ACE_wrappers/ace/SOCK_Stream.inl | 177 + dep/ACE_wrappers/ace/SPIPE.cpp | 82 + dep/ACE_wrappers/ace/SPIPE.h | 116 + dep/ACE_wrappers/ace/SPIPE.inl | 18 + dep/ACE_wrappers/ace/SPIPE_Acceptor.cpp | 337 + dep/ACE_wrappers/ace/SPIPE_Acceptor.h | 168 + dep/ACE_wrappers/ace/SPIPE_Addr.cpp | 167 + dep/ACE_wrappers/ace/SPIPE_Addr.h | 122 + dep/ACE_wrappers/ace/SPIPE_Addr.inl | 59 + dep/ACE_wrappers/ace/SPIPE_Connector.cpp | 160 + dep/ACE_wrappers/ace/SPIPE_Connector.h | 118 + dep/ACE_wrappers/ace/SPIPE_Connector.inl | 15 + dep/ACE_wrappers/ace/SPIPE_Stream.cpp | 104 + dep/ACE_wrappers/ace/SPIPE_Stream.h | 171 + dep/ACE_wrappers/ace/SPIPE_Stream.inl | 275 + dep/ACE_wrappers/ace/SString.cpp | 550 + dep/ACE_wrappers/ace/SString.h | 499 + dep/ACE_wrappers/ace/SString.inl | 299 + dep/ACE_wrappers/ace/SStringfwd.h | 55 + dep/ACE_wrappers/ace/SUN_Proactor.cpp | 324 + dep/ACE_wrappers/ace/SUN_Proactor.h | 126 + dep/ACE_wrappers/ace/SV_Message.cpp | 24 + dep/ACE_wrappers/ace/SV_Message.h | 67 + dep/ACE_wrappers/ace/SV_Message.inl | 37 + dep/ACE_wrappers/ace/SV_Message_Queue.cpp | 44 + dep/ACE_wrappers/ace/SV_Message_Queue.h | 105 + dep/ACE_wrappers/ace/SV_Message_Queue.inl | 81 + dep/ACE_wrappers/ace/SV_Semaphore_Complex.cpp | 259 + dep/ACE_wrappers/ace/SV_Semaphore_Complex.h | 159 + dep/ACE_wrappers/ace/SV_Semaphore_Complex.inl | 84 + dep/ACE_wrappers/ace/SV_Semaphore_Simple.cpp | 237 + dep/ACE_wrappers/ace/SV_Semaphore_Simple.h | 197 + dep/ACE_wrappers/ace/SV_Semaphore_Simple.inl | 128 + dep/ACE_wrappers/ace/SV_Shared_Memory.cpp | 88 + dep/ACE_wrappers/ace/SV_Shared_Memory.h | 121 + dep/ACE_wrappers/ace/SV_Shared_Memory.inl | 118 + dep/ACE_wrappers/ace/Sample_History.cpp | 73 + dep/ACE_wrappers/ace/Sample_History.h | 91 + dep/ACE_wrappers/ace/Sample_History.inl | 26 + dep/ACE_wrappers/ace/Sbrk_Memory_Pool.cpp | 124 + dep/ACE_wrappers/ace/Sbrk_Memory_Pool.h | 118 + dep/ACE_wrappers/ace/Sched_Params.cpp | 332 + dep/ACE_wrappers/ace/Sched_Params.h | 232 + dep/ACE_wrappers/ace/Sched_Params.inl | 134 + dep/ACE_wrappers/ace/Select_Reactor.h | 69 + dep/ACE_wrappers/ace/Select_Reactor_Base.cpp | 1116 + dep/ACE_wrappers/ace/Select_Reactor_Base.h | 611 + dep/ACE_wrappers/ace/Select_Reactor_Base.inl | 152 + dep/ACE_wrappers/ace/Select_Reactor_T.cpp | 1598 + dep/ACE_wrappers/ace/Select_Reactor_T.h | 718 + dep/ACE_wrappers/ace/Select_Reactor_T.inl | 236 + dep/ACE_wrappers/ace/Semaphore.cpp | 62 + dep/ACE_wrappers/ace/Semaphore.h | 183 + dep/ACE_wrappers/ace/Semaphore.inl | 119 + dep/ACE_wrappers/ace/Service_Config.cpp | 619 + dep/ACE_wrappers/ace/Service_Config.h | 684 + dep/ACE_wrappers/ace/Service_Config.inl | 204 + dep/ACE_wrappers/ace/Service_Gestalt.cpp | 1296 + dep/ACE_wrappers/ace/Service_Gestalt.h | 510 + dep/ACE_wrappers/ace/Service_Gestalt.inl | 76 + dep/ACE_wrappers/ace/Service_Manager.cpp | 437 + dep/ACE_wrappers/ace/Service_Manager.h | 120 + dep/ACE_wrappers/ace/Service_Object.cpp | 180 + dep/ACE_wrappers/ace/Service_Object.h | 207 + dep/ACE_wrappers/ace/Service_Object.inl | 79 + dep/ACE_wrappers/ace/Service_Repository.cpp | 637 + dep/ACE_wrappers/ace/Service_Repository.h | 280 + dep/ACE_wrappers/ace/Service_Repository.inl | 51 + dep/ACE_wrappers/ace/Service_Templates.h | 29 + dep/ACE_wrappers/ace/Service_Types.cpp | 453 + dep/ACE_wrappers/ace/Service_Types.h | 206 + dep/ACE_wrappers/ace/Service_Types.inl | 32 + dep/ACE_wrappers/ace/Shared_Memory.cpp | 13 + dep/ACE_wrappers/ace/Shared_Memory.h | 58 + dep/ACE_wrappers/ace/Shared_Memory_MM.cpp | 111 + dep/ACE_wrappers/ace/Shared_Memory_MM.h | 120 + dep/ACE_wrappers/ace/Shared_Memory_MM.inl | 42 + dep/ACE_wrappers/ace/Shared_Memory_Pool.cpp | 461 + dep/ACE_wrappers/ace/Shared_Memory_Pool.h | 210 + dep/ACE_wrappers/ace/Shared_Memory_SV.cpp | 88 + dep/ACE_wrappers/ace/Shared_Memory_SV.h | 101 + dep/ACE_wrappers/ace/Shared_Memory_SV.inl | 30 + dep/ACE_wrappers/ace/Shared_Object.cpp | 54 + dep/ACE_wrappers/ace/Shared_Object.h | 62 + dep/ACE_wrappers/ace/Shared_Object.inl | 12 + dep/ACE_wrappers/ace/Sig_Adapter.cpp | 80 + dep/ACE_wrappers/ace/Sig_Adapter.h | 81 + dep/ACE_wrappers/ace/Sig_Handler.cpp | 614 + dep/ACE_wrappers/ace/Sig_Handler.h | 237 + dep/ACE_wrappers/ace/Sig_Handler.inl | 15 + dep/ACE_wrappers/ace/Signal.cpp | 221 + dep/ACE_wrappers/ace/Signal.h | 267 + dep/ACE_wrappers/ace/Signal.inl | 265 + dep/ACE_wrappers/ace/Singleton.cpp | 534 + dep/ACE_wrappers/ace/Singleton.h | 327 + dep/ACE_wrappers/ace/Singleton.inl | 42 + dep/ACE_wrappers/ace/Sock_Connect.cpp | 1603 + dep/ACE_wrappers/ace/Sock_Connect.h | 107 + dep/ACE_wrappers/ace/Stack_Trace.cpp | 696 + dep/ACE_wrappers/ace/Stack_Trace.h | 107 + dep/ACE_wrappers/ace/Static_Object_Lock.h | 78 + dep/ACE_wrappers/ace/Stats.cpp | 426 + dep/ACE_wrappers/ace/Stats.h | 222 + dep/ACE_wrappers/ace/Stats.inl | 104 + dep/ACE_wrappers/ace/Strategies.h | 33 + dep/ACE_wrappers/ace/Strategies_T.cpp | 1502 + dep/ACE_wrappers/ace/Strategies_T.h | 1076 + dep/ACE_wrappers/ace/Strategies_T.inl | 230 + dep/ACE_wrappers/ace/Stream.cpp | 619 + dep/ACE_wrappers/ace/Stream.h | 241 + dep/ACE_wrappers/ace/Stream.inl | 51 + dep/ACE_wrappers/ace/Stream_Modules.cpp | 380 + dep/ACE_wrappers/ace/Stream_Modules.h | 166 + dep/ACE_wrappers/ace/String_Base.cpp | 563 + dep/ACE_wrappers/ace/String_Base.h | 612 + dep/ACE_wrappers/ace/String_Base.inl | 159 + dep/ACE_wrappers/ace/String_Base_Const.cpp | 20 + dep/ACE_wrappers/ace/String_Base_Const.h | 52 + dep/ACE_wrappers/ace/Svc_Conf.h | 110 + dep/ACE_wrappers/ace/Svc_Conf.y | 376 + dep/ACE_wrappers/ace/Svc_Conf_Lexer.cpp | 676 + dep/ACE_wrappers/ace/Svc_Conf_Lexer.h | 70 + dep/ACE_wrappers/ace/Svc_Conf_Param.h | 142 + dep/ACE_wrappers/ace/Svc_Conf_Token_Table.h | 84 + dep/ACE_wrappers/ace/Svc_Conf_Tokens.h | 29 + dep/ACE_wrappers/ace/Svc_Conf_y.cpp | 1998 + dep/ACE_wrappers/ace/Svc_Handler.cpp | 525 + dep/ACE_wrappers/ace/Svc_Handler.h | 345 + dep/ACE_wrappers/ace/Synch.h | 65 + dep/ACE_wrappers/ace/Synch_Options.cpp | 110 + dep/ACE_wrappers/ace/Synch_Options.h | 163 + dep/ACE_wrappers/ace/Synch_T.cpp | 22 + dep/ACE_wrappers/ace/Synch_T.h | 42 + dep/ACE_wrappers/ace/Synch_Traits.h | 152 + dep/ACE_wrappers/ace/System_Time.cpp | 140 + dep/ACE_wrappers/ace/System_Time.h | 99 + dep/ACE_wrappers/ace/TLI.cpp | 273 + dep/ACE_wrappers/ace/TLI.h | 116 + dep/ACE_wrappers/ace/TLI.inl | 50 + dep/ACE_wrappers/ace/TLI_Acceptor.cpp | 553 + dep/ACE_wrappers/ace/TLI_Acceptor.h | 123 + dep/ACE_wrappers/ace/TLI_Connector.cpp | 256 + dep/ACE_wrappers/ace/TLI_Connector.h | 130 + dep/ACE_wrappers/ace/TLI_Connector.inl | 49 + dep/ACE_wrappers/ace/TLI_Stream.cpp | 229 + dep/ACE_wrappers/ace/TLI_Stream.h | 141 + dep/ACE_wrappers/ace/TLI_Stream.inl | 25 + dep/ACE_wrappers/ace/TP_Reactor.cpp | 686 + dep/ACE_wrappers/ace/TP_Reactor.h | 320 + dep/ACE_wrappers/ace/TP_Reactor.inl | 119 + dep/ACE_wrappers/ace/TSS_Adapter.cpp | 45 + dep/ACE_wrappers/ace/TSS_Adapter.h | 61 + dep/ACE_wrappers/ace/TSS_T.cpp | 725 + dep/ACE_wrappers/ace/TSS_T.h | 253 + dep/ACE_wrappers/ace/TSS_T.inl | 42 + dep/ACE_wrappers/ace/TTY_IO.cpp | 582 + dep/ACE_wrappers/ace/TTY_IO.h | 113 + dep/ACE_wrappers/ace/Task.cpp | 299 + dep/ACE_wrappers/ace/Task.h | 307 + dep/ACE_wrappers/ace/Task.inl | 77 + dep/ACE_wrappers/ace/Task_Ex_T.cpp | 114 + dep/ACE_wrappers/ace/Task_Ex_T.h | 205 + dep/ACE_wrappers/ace/Task_Ex_T.inl | 109 + dep/ACE_wrappers/ace/Task_T.cpp | 108 + dep/ACE_wrappers/ace/Task_T.h | 198 + dep/ACE_wrappers/ace/Task_T.inl | 105 + dep/ACE_wrappers/ace/Test_and_Set.cpp | 51 + dep/ACE_wrappers/ace/Test_and_Set.h | 75 + dep/ACE_wrappers/ace/Thread.cpp | 99 + dep/ACE_wrappers/ace/Thread.h | 282 + dep/ACE_wrappers/ace/Thread.inl | 286 + dep/ACE_wrappers/ace/Thread_Adapter.cpp | 228 + dep/ACE_wrappers/ace/Thread_Adapter.h | 100 + dep/ACE_wrappers/ace/Thread_Adapter.inl | 13 + dep/ACE_wrappers/ace/Thread_Control.cpp | 96 + dep/ACE_wrappers/ace/Thread_Control.h | 102 + dep/ACE_wrappers/ace/Thread_Control.inl | 46 + dep/ACE_wrappers/ace/Thread_Exit.cpp | 123 + dep/ACE_wrappers/ace/Thread_Exit.h | 111 + dep/ACE_wrappers/ace/Thread_Hook.cpp | 33 + dep/ACE_wrappers/ace/Thread_Hook.h | 65 + dep/ACE_wrappers/ace/Thread_Manager.cpp | 2221 + dep/ACE_wrappers/ace/Thread_Manager.h | 1264 + dep/ACE_wrappers/ace/Thread_Manager.inl | 307 + dep/ACE_wrappers/ace/Thread_Mutex.cpp | 62 + dep/ACE_wrappers/ace/Thread_Mutex.h | 175 + dep/ACE_wrappers/ace/Thread_Mutex.inl | 97 + dep/ACE_wrappers/ace/Thread_Semaphore.cpp | 62 + dep/ACE_wrappers/ace/Thread_Semaphore.h | 89 + dep/ACE_wrappers/ace/Thread_Semaphore.inl | 12 + dep/ACE_wrappers/ace/Throughput_Stats.cpp | 202 + dep/ACE_wrappers/ace/Throughput_Stats.h | 86 + dep/ACE_wrappers/ace/Time_Value.cpp | 264 + dep/ACE_wrappers/ace/Time_Value.h | 380 + dep/ACE_wrappers/ace/Time_Value.inl | 422 + dep/ACE_wrappers/ace/Timeprobe.cpp | 15 + dep/ACE_wrappers/ace/Timeprobe.h | 201 + dep/ACE_wrappers/ace/Timeprobe.inl | 14 + dep/ACE_wrappers/ace/Timeprobe_T.cpp | 427 + dep/ACE_wrappers/ace/Timeprobe_T.h | 220 + dep/ACE_wrappers/ace/Timer_Hash.h | 75 + dep/ACE_wrappers/ace/Timer_Hash_T.cpp | 873 + dep/ACE_wrappers/ace/Timer_Hash_T.h | 342 + dep/ACE_wrappers/ace/Timer_Heap.h | 41 + dep/ACE_wrappers/ace/Timer_Heap_T.cpp | 889 + dep/ACE_wrappers/ace/Timer_Heap_T.h | 338 + dep/ACE_wrappers/ace/Timer_List.h | 42 + dep/ACE_wrappers/ace/Timer_List_T.cpp | 418 + dep/ACE_wrappers/ace/Timer_List_T.h | 226 + dep/ACE_wrappers/ace/Timer_Queue.h | 52 + dep/ACE_wrappers/ace/Timer_Queue_Adapters.cpp | 361 + dep/ACE_wrappers/ace/Timer_Queue_Adapters.h | 261 + dep/ACE_wrappers/ace/Timer_Queue_Adapters.inl | 29 + dep/ACE_wrappers/ace/Timer_Queue_T.cpp | 481 + dep/ACE_wrappers/ace/Timer_Queue_T.h | 562 + dep/ACE_wrappers/ace/Timer_Queue_T.inl | 222 + dep/ACE_wrappers/ace/Timer_Queuefwd.h | 38 + dep/ACE_wrappers/ace/Timer_Wheel.h | 42 + dep/ACE_wrappers/ace/Timer_Wheel_T.cpp | 967 + dep/ACE_wrappers/ace/Timer_Wheel_T.h | 226 + dep/ACE_wrappers/ace/Token.cpp | 545 + dep/ACE_wrappers/ace/Token.h | 376 + dep/ACE_wrappers/ace/Token.inl | 176 + dep/ACE_wrappers/ace/Token_Collection.cpp | 294 + dep/ACE_wrappers/ace/Token_Collection.h | 243 + dep/ACE_wrappers/ace/Token_Collection.inl | 17 + dep/ACE_wrappers/ace/Token_Invariants.cpp | 355 + dep/ACE_wrappers/ace/Token_Invariants.h | 245 + dep/ACE_wrappers/ace/Token_Manager.cpp | 273 + dep/ACE_wrappers/ace/Token_Manager.h | 150 + dep/ACE_wrappers/ace/Token_Manager.inl | 25 + dep/ACE_wrappers/ace/Token_Request_Reply.cpp | 186 + dep/ACE_wrappers/ace/Token_Request_Reply.h | 270 + dep/ACE_wrappers/ace/Token_Request_Reply.inl | 205 + dep/ACE_wrappers/ace/Trace.cpp | 137 + dep/ACE_wrappers/ace/Trace.h | 96 + dep/ACE_wrappers/ace/Truncate.h | 1055 + dep/ACE_wrappers/ace/Typed_SV_Message.cpp | 30 + dep/ACE_wrappers/ace/Typed_SV_Message.h | 107 + dep/ACE_wrappers/ace/Typed_SV_Message.inl | 96 + .../ace/Typed_SV_Message_Queue.cpp | 56 + dep/ACE_wrappers/ace/Typed_SV_Message_Queue.h | 92 + .../ace/Typed_SV_Message_Queue.inl | 80 + dep/ACE_wrappers/ace/UNIX_Addr.cpp | 151 + dep/ACE_wrappers/ace/UNIX_Addr.h | 117 + dep/ACE_wrappers/ace/UNIX_Addr.inl | 57 + dep/ACE_wrappers/ace/UPIPE_Acceptor.cpp | 129 + dep/ACE_wrappers/ace/UPIPE_Acceptor.h | 99 + dep/ACE_wrappers/ace/UPIPE_Acceptor.inl | 14 + dep/ACE_wrappers/ace/UPIPE_Addr.h | 33 + dep/ACE_wrappers/ace/UPIPE_Connector.cpp | 101 + dep/ACE_wrappers/ace/UPIPE_Connector.h | 115 + dep/ACE_wrappers/ace/UPIPE_Connector.inl | 34 + dep/ACE_wrappers/ace/UPIPE_Stream.cpp | 234 + dep/ACE_wrappers/ace/UPIPE_Stream.h | 140 + dep/ACE_wrappers/ace/UPIPE_Stream.inl | 14 + .../ace/UTF16_Encoding_Converter.cpp | 364 + .../ace/UTF16_Encoding_Converter.h | 86 + .../ace/UTF16_Encoding_Converter.inl | 76 + .../ace/UTF32_Encoding_Converter.cpp | 254 + .../ace/UTF32_Encoding_Converter.h | 67 + .../ace/UTF8_Encoding_Converter.cpp | 92 + .../ace/UTF8_Encoding_Converter.h | 72 + dep/ACE_wrappers/ace/UUID.cpp | 554 + dep/ACE_wrappers/ace/UUID.h | 239 + dep/ACE_wrappers/ace/UUID.inl | 200 + dep/ACE_wrappers/ace/Unbounded_Queue.cpp | 434 + dep/ACE_wrappers/ace/Unbounded_Queue.h | 297 + dep/ACE_wrappers/ace/Unbounded_Queue.inl | 27 + dep/ACE_wrappers/ace/Unbounded_Set.cpp | 18 + dep/ACE_wrappers/ace/Unbounded_Set.h | 103 + dep/ACE_wrappers/ace/Unbounded_Set.inl | 49 + dep/ACE_wrappers/ace/Unbounded_Set_Ex.cpp | 499 + dep/ACE_wrappers/ace/Unbounded_Set_Ex.h | 347 + dep/ACE_wrappers/ace/Unbounded_Set_Ex.inl | 23 + dep/ACE_wrappers/ace/Value_Ptr.h | 167 + dep/ACE_wrappers/ace/Vector_T.cpp | 154 + dep/ACE_wrappers/ace/Vector_T.h | 316 + dep/ACE_wrappers/ace/Vector_T.inl | 107 + dep/ACE_wrappers/ace/Version.h | 9 + dep/ACE_wrappers/ace/Versioned_Namespace.h | 51 + dep/ACE_wrappers/ace/WFMO_Reactor.cpp | 2748 ++ dep/ACE_wrappers/ace/WFMO_Reactor.h | 1368 + dep/ACE_wrappers/ace/WFMO_Reactor.inl | 1200 + dep/ACE_wrappers/ace/WIN32_Asynch_IO.cpp | 3778 ++ dep/ACE_wrappers/ace/WIN32_Asynch_IO.h | 1937 + dep/ACE_wrappers/ace/WIN32_Proactor.cpp | 804 + dep/ACE_wrappers/ace/WIN32_Proactor.h | 325 + dep/ACE_wrappers/ace/XML_Svc_Conf.cpp | 15 + dep/ACE_wrappers/ace/XML_Svc_Conf.h | 65 + dep/ACE_wrappers/ace/XTI_ATM_Mcast.cpp | 70 + dep/ACE_wrappers/ace/XTI_ATM_Mcast.h | 137 + dep/ACE_wrappers/ace/XTI_ATM_Mcast.inl | 65 + dep/ACE_wrappers/ace/ace.rc | 38 + dep/ACE_wrappers/ace/ace_ce_dll.cfg | 1 + dep/ACE_wrappers/ace/ace_message_table.bin | Bin 0 -> 28 bytes dep/ACE_wrappers/ace/ace_wchar.cpp | 17 + dep/ACE_wrappers/ace/ace_wchar.h | 385 + dep/ACE_wrappers/ace/ace_wchar.inl | 183 + dep/ACE_wrappers/ace/checked_iterator.h | 58 + dep/ACE_wrappers/ace/codecs.mpb | 8 + dep/ACE_wrappers/ace/config-WinCE.h | 240 + dep/ACE_wrappers/ace/config-aix-5.x.h | 333 + dep/ACE_wrappers/ace/config-all.h | 89 + dep/ACE_wrappers/ace/config-borland-common.h | 66 + dep/ACE_wrappers/ace/config-cray.h | 213 + dep/ACE_wrappers/ace/config-cxx-common.h | 86 + dep/ACE_wrappers/ace/config-cygwin32.h | 206 + dep/ACE_wrappers/ace/config-doxygen.h | 120 + dep/ACE_wrappers/ace/config-freebsd.h | 284 + dep/ACE_wrappers/ace/config-g++-common.h | 136 + dep/ACE_wrappers/ace/config-ghs-common.h | 43 + dep/ACE_wrappers/ace/config-hpux-11.00.h | 449 + dep/ACE_wrappers/ace/config-icc-common.h | 113 + dep/ACE_wrappers/ace/config-integritySCA.h | 233 + .../ace/config-irix6.5.x-sgic++.h | 18 + dep/ACE_wrappers/ace/config-irix6.x-common.h | 257 + dep/ACE_wrappers/ace/config-irix6.x-g++.h | 23 + dep/ACE_wrappers/ace/config-irix6.x-sgic++.h | 36 + dep/ACE_wrappers/ace/config-linux-common.h | 448 + dep/ACE_wrappers/ace/config-linux.h | 75 + dep/ACE_wrappers/ace/config-lite.h | 164 + dep/ACE_wrappers/ace/config-lynxos.h | 162 + dep/ACE_wrappers/ace/config-macosx-leopard.h | 227 + dep/ACE_wrappers/ace/config-macosx-panther.h | 191 + dep/ACE_wrappers/ace/config-macosx-tiger.h | 219 + dep/ACE_wrappers/ace/config-macosx.h | 191 + dep/ACE_wrappers/ace/config-macros.h | 636 + dep/ACE_wrappers/ace/config-minimal.h | 39 + dep/ACE_wrappers/ace/config-mvs.h | 131 + dep/ACE_wrappers/ace/config-netbsd.h | 167 + dep/ACE_wrappers/ace/config-openbsd.h | 235 + dep/ACE_wrappers/ace/config-openvms.h | 195 + dep/ACE_wrappers/ace/config-pharlap.h | 90 + .../ace/config-posix-nonetworking.h | 86 + dep/ACE_wrappers/ace/config-posix.h | 73 + dep/ACE_wrappers/ace/config-qnx-neutrino.h | 137 + dep/ACE_wrappers/ace/config-qnx-rtp-62x.h | 129 + dep/ACE_wrappers/ace/config-qnx-rtp-common.h | 46 + dep/ACE_wrappers/ace/config-qnx-rtp-pre62x.h | 151 + dep/ACE_wrappers/ace/config-qnx-rtp.h | 25 + dep/ACE_wrappers/ace/config-rtems.h | 165 + .../ace/config-sco-5.0.0-nothread.h | 14 + dep/ACE_wrappers/ace/config-sco-5.0.0.h | 97 + dep/ACE_wrappers/ace/config-suncc-common.h | 67 + dep/ACE_wrappers/ace/config-sunos5.10.h | 51 + dep/ACE_wrappers/ace/config-sunos5.11.h | 15 + dep/ACE_wrappers/ace/config-sunos5.4-g++.h | 181 + .../ace/config-sunos5.4-sunc++-4.x.h | 190 + dep/ACE_wrappers/ace/config-sunos5.5.h | 417 + dep/ACE_wrappers/ace/config-sunos5.6.h | 126 + dep/ACE_wrappers/ace/config-sunos5.7.h | 78 + dep/ACE_wrappers/ace/config-sunos5.8.h | 39 + dep/ACE_wrappers/ace/config-sunos5.9.h | 18 + .../ace/config-tandem-nsk-mips-v2.h | 401 + .../ace/config-tandem-nsk-mips-v3.h | 471 + dep/ACE_wrappers/ace/config-tandem.h | 193 + dep/ACE_wrappers/ace/config-tru64.h | 154 + dep/ACE_wrappers/ace/config-unixware-7.1.0.h | 412 + .../ace/config-unixware-7.1.0.udk.h | 460 + dep/ACE_wrappers/ace/config-visualage.h | 20 + dep/ACE_wrappers/ace/config-vxworks.h | 55 + dep/ACE_wrappers/ace/config-vxworks5.x.h | 345 + dep/ACE_wrappers/ace/config-vxworks6.2.h | 328 + dep/ACE_wrappers/ace/config-vxworks6.3.h | 317 + dep/ACE_wrappers/ace/config-vxworks6.4.h | 340 + dep/ACE_wrappers/ace/config-vxworks6.5.h | 25 + dep/ACE_wrappers/ace/config-vxworks6.6.h | 29 + dep/ACE_wrappers/ace/config-win32-borland.h | 125 + dep/ACE_wrappers/ace/config-win32-common.h | 666 + dep/ACE_wrappers/ace/config-win32-dmc.h | 110 + dep/ACE_wrappers/ace/config-win32-ghs.h | 96 + dep/ACE_wrappers/ace/config-win32-interix.h | 100 + dep/ACE_wrappers/ace/config-win32-mingw.h | 100 + dep/ACE_wrappers/ace/config-win32-msvc-7.h | 125 + dep/ACE_wrappers/ace/config-win32-msvc-8.h | 148 + dep/ACE_wrappers/ace/config-win32-msvc-9.h | 140 + dep/ACE_wrappers/ace/config-win32-msvc.h | 169 + dep/ACE_wrappers/ace/config-win32.h | 93 + dep/ACE_wrappers/ace/config.h.in | 2163 + dep/ACE_wrappers/ace/filecache.mpb | 8 + dep/ACE_wrappers/ace/gethrtime.cpp | 60 + dep/ACE_wrappers/ace/iosfwd.h | 99 + .../ace/os_include/arpa/os_inet.h | 74 + dep/ACE_wrappers/ace/os_include/net/os_if.h | 119 + .../ace/os_include/netinet/os_in.h | 185 + .../ace/os_include/netinet/os_tcp.h | 46 + dep/ACE_wrappers/ace/os_include/os_aio.h | 47 + dep/ACE_wrappers/ace/os_include/os_assert.h | 46 + dep/ACE_wrappers/ace/os_include/os_byteswap.h | 41 + dep/ACE_wrappers/ace/os_include/os_complex.h | 42 + dep/ACE_wrappers/ace/os_include/os_cpio.h | 42 + dep/ACE_wrappers/ace/os_include/os_ctype.h | 45 + dep/ACE_wrappers/ace/os_include/os_dirent.h | 108 + dep/ACE_wrappers/ace/os_include/os_dlfcn.h | 101 + dep/ACE_wrappers/ace/os_include/os_errno.h | 153 + dep/ACE_wrappers/ace/os_include/os_fcntl.h | 106 + dep/ACE_wrappers/ace/os_include/os_fenv.h | 42 + dep/ACE_wrappers/ace/os_include/os_float.h | 42 + dep/ACE_wrappers/ace/os_include/os_fmtmsg.h | 42 + dep/ACE_wrappers/ace/os_include/os_fnmatch.h | 42 + dep/ACE_wrappers/ace/os_include/os_ftw.h | 44 + dep/ACE_wrappers/ace/os_include/os_glob.h | 42 + dep/ACE_wrappers/ace/os_include/os_grp.h | 44 + dep/ACE_wrappers/ace/os_include/os_iconv.h | 44 + dep/ACE_wrappers/ace/os_include/os_intrin.h | 57 + dep/ACE_wrappers/ace/os_include/os_inttypes.h | 46 + dep/ACE_wrappers/ace/os_include/os_iso646.h | 42 + dep/ACE_wrappers/ace/os_include/os_kstat.h | 43 + dep/ACE_wrappers/ace/os_include/os_langinfo.h | 44 + dep/ACE_wrappers/ace/os_include/os_libgen.h | 42 + dep/ACE_wrappers/ace/os_include/os_limits.h | 143 + dep/ACE_wrappers/ace/os_include/os_local.h | 44 + dep/ACE_wrappers/ace/os_include/os_math.h | 44 + dep/ACE_wrappers/ace/os_include/os_monetary.h | 44 + dep/ACE_wrappers/ace/os_include/os_mqueue.h | 44 + dep/ACE_wrappers/ace/os_include/os_ndbm.h | 44 + dep/ACE_wrappers/ace/os_include/os_netdb.h | 108 + dep/ACE_wrappers/ace/os_include/os_nl_types.h | 42 + dep/ACE_wrappers/ace/os_include/os_pdh.h | 45 + dep/ACE_wrappers/ace/os_include/os_pdhmsg.h | 41 + dep/ACE_wrappers/ace/os_include/os_poll.h | 42 + dep/ACE_wrappers/ace/os_include/os_pthread.h | 424 + dep/ACE_wrappers/ace/os_include/os_pwd.h | 58 + dep/ACE_wrappers/ace/os_include/os_regex.h | 48 + dep/ACE_wrappers/ace/os_include/os_sched.h | 52 + dep/ACE_wrappers/ace/os_include/os_search.h | 44 + .../ace/os_include/os_semaphore.h | 77 + dep/ACE_wrappers/ace/os_include/os_setjmp.h | 42 + dep/ACE_wrappers/ace/os_include/os_signal.h | 253 + dep/ACE_wrappers/ace/os_include/os_spawn.h | 46 + dep/ACE_wrappers/ace/os_include/os_stdarg.h | 50 + dep/ACE_wrappers/ace/os_include/os_stdbool.h | 42 + dep/ACE_wrappers/ace/os_include/os_stddef.h | 97 + dep/ACE_wrappers/ace/os_include/os_stdint.h | 141 + dep/ACE_wrappers/ace/os_include/os_stdio.h | 87 + dep/ACE_wrappers/ace/os_include/os_stdlib.h | 77 + dep/ACE_wrappers/ace/os_include/os_string.h | 76 + dep/ACE_wrappers/ace/os_include/os_strings.h | 52 + dep/ACE_wrappers/ace/os_include/os_stropts.h | 120 + dep/ACE_wrappers/ace/os_include/os_syslog.h | 42 + dep/ACE_wrappers/ace/os_include/os_tar.h | 42 + dep/ACE_wrappers/ace/os_include/os_termios.h | 46 + dep/ACE_wrappers/ace/os_include/os_tgmath.h | 45 + dep/ACE_wrappers/ace/os_include/os_time.h | 123 + dep/ACE_wrappers/ace/os_include/os_trace.h | 44 + dep/ACE_wrappers/ace/os_include/os_ucontext.h | 48 + dep/ACE_wrappers/ace/os_include/os_ulimit.h | 42 + dep/ACE_wrappers/ace/os_include/os_unistd.h | 203 + dep/ACE_wrappers/ace/os_include/os_utime.h | 44 + dep/ACE_wrappers/ace/os_include/os_utmpx.h | 44 + dep/ACE_wrappers/ace/os_include/os_wchar.h | 49 + dep/ACE_wrappers/ace/os_include/os_wctype.h | 45 + dep/ACE_wrappers/ace/os_include/os_wordexp.h | 44 + dep/ACE_wrappers/ace/os_include/sys/os_ipc.h | 74 + .../ace/os_include/sys/os_loadavg.h | 41 + dep/ACE_wrappers/ace/os_include/sys/os_mman.h | 122 + dep/ACE_wrappers/ace/os_include/sys/os_msg.h | 55 + .../ace/os_include/sys/os_pstat.h | 42 + .../ace/os_include/sys/os_resource.h | 104 + .../ace/os_include/sys/os_select.h | 59 + dep/ACE_wrappers/ace/os_include/sys/os_sem.h | 90 + dep/ACE_wrappers/ace/os_include/sys/os_shm.h | 48 + .../ace/os_include/sys/os_socket.h | 307 + dep/ACE_wrappers/ace/os_include/sys/os_stat.h | 127 + .../ace/os_include/sys/os_statvfs.h | 42 + .../ace/os_include/sys/os_sysctl.h | 41 + .../ace/os_include/sys/os_sysinfo.h | 39 + dep/ACE_wrappers/ace/os_include/sys/os_time.h | 60 + .../ace/os_include/sys/os_timeb.h | 49 + .../ace/os_include/sys/os_times.h | 44 + .../ace/os_include/sys/os_types.h | 158 + dep/ACE_wrappers/ace/os_include/sys/os_uio.h | 77 + dep/ACE_wrappers/ace/os_include/sys/os_un.h | 52 + .../ace/os_include/sys/os_utsname.h | 42 + dep/ACE_wrappers/ace/os_include/sys/os_wait.h | 97 + dep/ACE_wrappers/ace/other.mpb | 15 + dep/ACE_wrappers/ace/post.h | 22 + dep/ACE_wrappers/ace/pre.h | 24 + dep/ACE_wrappers/ace/streams.h | 138 + dep/ACE_wrappers/ace/svc_export.h | 44 + dep/ACE_wrappers/ace/svcconf.mpb | 58 + dep/ACE_wrappers/ace/token.mpb | 15 + dep/ACE_wrappers/ace/uuid.mpb | 8 + dep/ACE_wrappers/aclocal.m4 | 7555 ++++ dep/ACE_wrappers/configure.ac | 7483 ++++ dep/ACE_wrappers/m4/ace.m4 | 1770 + dep/ACE_wrappers/m4/ace_defines.m4 | 48 + dep/ACE_wrappers/m4/ace_func.m4 | 148 + dep/ACE_wrappers/m4/ace_functions.m4 | 27 + dep/ACE_wrappers/m4/ace_headers.m4 | 35 + dep/ACE_wrappers/m4/acinclude.m4 | 602 + dep/ACE_wrappers/m4/aio.m4 | 633 + dep/ACE_wrappers/m4/compiler.m4 | 426 + dep/ACE_wrappers/m4/config_h.m4 | 976 + dep/ACE_wrappers/m4/pkg.m4 | 156 + dep/ACE_wrappers/m4/platform.m4 | 545 + dep/ACE_wrappers/m4/subsets.m4 | 770 + dep/ACE_wrappers/m4/threads.m4 | 334 + dep/ACE_wrappers/m4/tls.m4 | 220 + dep/Makefile.am | 2 +- sql/mangos.sql | 30645 ++++++------- src/bindings/scripts/ScriptMgr.cpp | 5 +- src/bindings/scripts/VC71/71ScriptDev2.vcproj | 4 +- src/bindings/scripts/VC80/80ScriptDev2.vcproj | 8 +- src/bindings/scripts/VC90/90ScriptDev2.vcproj | 8 +- src/bindings/scripts/include/sc_creature.cpp | 1224 +- src/bindings/scripts/include/sc_gossip.h | 366 +- .../areatrigger/areatrigger_scripts.cpp | 88 +- .../scripts/scripts/boss/boss_emeriss.cpp | 312 +- .../scripts/scripts/boss/boss_lethon.cpp | 48 +- .../scripts/scripts/boss/boss_taerar.cpp | 612 +- .../scripts/scripts/boss/boss_ysondre.cpp | 492 +- .../scripts/scripts/creature/mob_event_ai.cpp | 2750 +- .../scripts/scripts/creature/mob_event_ai.h | 430 +- .../scripts/creature/mob_generic_creature.cpp | 344 +- .../scripts/scripts/creature/simple_ai.cpp | 588 +- .../scripts/scripts/creature/simple_ai.h | 148 +- .../scripts/scripts/custom/custom_example.cpp | 554 +- .../scripts/custom/custom_gossip_codebox.cpp | 162 +- src/bindings/scripts/scripts/custom/test.cpp | 402 +- .../scripts/scripts/go/go_scripts.cpp | 418 +- .../scripts/scripts/guard/guard_ai.cpp | 320 +- src/bindings/scripts/scripts/guard/guard_ai.h | 50 +- src/bindings/scripts/scripts/guard/guards.cpp | 8234 ++-- .../scripts/scripts/item/item_scripts.cpp | 1058 +- .../scripts/scripts/item/item_test.cpp | 84 +- .../scripts/scripts/npc/npc_escortAI.cpp | 608 +- .../scripts/scripts/npc/npc_escortAI.h | 170 +- .../scripts/scripts/npc/npc_innkeeper.cpp | 288 +- .../scripts/scripts/npc/npc_professions.cpp | 2410 +- .../scripts/scripts/npc/npcs_special.cpp | 1756 +- .../alterac_mountains/alterac_mountains.cpp | 124 +- .../auchenai_crypts/boss_exarch_maladaar.cpp | 810 +- .../mana_tombs/boss_nexusprince_shaffar.cpp | 626 +- .../mana_tombs/boss_pandemonius.cpp | 318 +- .../sethekk_halls/boss_darkweaver_syth.cpp | 882 +- .../sethekk_halls/boss_tailonking_ikiss.cpp | 512 +- .../sethekk_halls/def_sethekk_halls.h | 18 +- .../sethekk_halls/instance_sethekk_halls.cpp | 148 +- .../boss_ambassador_hellmaw.cpp | 446 +- .../boss_blackheart_the_inciter.cpp | 382 +- .../boss_grandmaster_vorpil.cpp | 588 +- .../shadow_labyrinth/boss_murmur.cpp | 384 +- .../shadow_labyrinth/def_shadow_labyrinth.h | 26 +- .../instance_shadow_labyrinth.cpp | 336 +- .../scripts/scripts/zone/azshara/azshara.cpp | 328 +- .../scripts/zone/azshara/boss_azuregos.cpp | 306 +- .../zone/azuremyst_isle/azuremyst_isle.cpp | 744 +- .../scripts/zone/barrens/the_barrens.cpp | 378 +- .../zone/black_temple/black_temple.cpp | 136 +- .../zone/black_temple/boss_bloodboil.cpp | 730 +- .../zone/black_temple/boss_illidan.cpp | 4933 +-- .../zone/black_temple/boss_mother_shahraz.cpp | 706 +- .../black_temple/boss_reliquary_of_souls.cpp | 2102 +- .../zone/black_temple/boss_shade_of_akama.cpp | 1626 +- .../zone/black_temple/boss_supremus.cpp | 812 +- .../black_temple/boss_teron_gorefiend.cpp | 1178 +- .../black_temple/boss_warlord_najentus.cpp | 870 +- .../zone/black_temple/def_black_temple.h | 68 +- .../zone/black_temple/illidari_council.cpp | 1770 +- .../black_temple/instance_black_temple.cpp | 504 +- .../blackrock_depths/blackrock_depths.cpp | 474 +- .../boss_ambassador_flamelash.cpp | 212 +- .../zone/blackrock_depths/boss_angerrel.cpp | 182 +- .../zone/blackrock_depths/boss_anubshiah.cpp | 230 +- .../zone/blackrock_depths/boss_doomrel.cpp | 278 +- .../zone/blackrock_depths/boss_doperel.cpp | 182 +- .../boss_emperor_dagran_thaurissan.cpp | 208 +- .../boss_general_angerforge.cpp | 334 +- .../zone/blackrock_depths/boss_gloomrel.cpp | 284 +- .../boss_gorosh_the_dervish.cpp | 162 +- .../zone/blackrock_depths/boss_grizzle.cpp | 172 +- .../zone/blackrock_depths/boss_haterel.cpp | 210 +- .../boss_high_interrogator_gerstahn.cpp | 210 +- .../zone/blackrock_depths/boss_magmus.cpp | 168 +- .../boss_moira_bronzebeard.cpp | 198 +- .../zone/blackrock_depths/boss_seethrel.cpp | 230 +- .../zone/blackrock_depths/boss_vilerel.cpp | 202 +- .../zone/blackrock_spire/boss_drakkisath.cpp | 202 +- .../zone/blackrock_spire/boss_gyth.cpp | 410 +- .../zone/blackrock_spire/boss_halycon.cpp | 190 +- .../blackrock_spire/boss_highlord_omokk.cpp | 262 +- .../boss_mother_smolderweb.cpp | 172 +- .../boss_overlord_wyrmthalak.cpp | 254 +- .../boss_pyroguard_emberseer.cpp | 186 +- .../boss_quartermaster_zigris.cpp | 170 +- .../blackrock_spire/boss_rend_blackhand.cpp | 182 +- .../boss_shadow_hunter_voshgajin.cpp | 190 +- .../zone/blackrock_spire/boss_the_beast.cpp | 186 +- .../blackrock_spire/boss_warmaster_voone.cpp | 242 +- .../boss_broodlord_lashlayer.cpp | 260 +- .../zone/blackwing_lair/boss_chromaggus.cpp | 640 +- .../zone/blackwing_lair/boss_ebonroc.cpp | 206 +- .../zone/blackwing_lair/boss_firemaw.cpp | 188 +- .../zone/blackwing_lair/boss_flamegor.cpp | 188 +- .../zone/blackwing_lair/boss_nefarian.cpp | 500 +- .../zone/blackwing_lair/boss_razorgore.cpp | 252 +- .../zone/blackwing_lair/boss_vaelastrasz.cpp | 556 +- .../blackwing_lair/boss_victor_nefarius.cpp | 798 +- .../instance_blackwing_lair.cpp | 16 +- .../blades_edge_mountains.cpp | 882 +- .../zone/blasted_lands/blasted_lands.cpp | 318 +- .../scripts/zone/blasted_lands/boss_kruul.cpp | 364 +- .../zone/bloodmyst_isle/bloodmyst_isle.cpp | 282 +- .../zone/burning_steppes/burning_steppes.cpp | 314 +- .../dark_portal/boss_aeonus.cpp | 274 +- .../dark_portal/boss_chrono_lord_deja.cpp | 248 +- .../dark_portal/boss_temporus.cpp | 335 +- .../caverns_of_time/hyjal/boss_archimonde.cpp | 1576 +- .../zone/caverns_of_time/hyjal/def_hyjal.h | 50 +- .../zone/caverns_of_time/hyjal/hyjal.cpp | 434 +- .../zone/caverns_of_time/hyjal/hyjalAI.cpp | 916 +- .../zone/caverns_of_time/hyjal/hyjalAI.h | 572 +- .../caverns_of_time/hyjal/instance_hyjal.cpp | 406 +- .../old_hillsbrad/boss_captain_skarloc.cpp | 354 +- .../old_hillsbrad/boss_epoch_hunter.cpp | 366 +- .../old_hillsbrad/boss_leutenant_drake.cpp | 492 +- .../old_hillsbrad/def_old_hillsbrad.h | 32 +- .../old_hillsbrad/instance_old_hillsbrad.cpp | 356 +- .../old_hillsbrad/old_hillsbrad.cpp | 1832 +- .../boss_fathomlord_karathress.cpp | 1118 +- .../boss_hydross_the_unstable.cpp | 714 +- .../serpent_shrine/boss_lady_vashj.cpp | 1862 +- .../boss_leotheras_the_blind.cpp | 697 +- .../boss_morogrim_tidewalker.cpp | 812 +- .../serpent_shrine/def_serpent_shrine.h | 52 +- .../instance_serpent_shrine.cpp | 454 +- .../slave_pens/boss_rokmar.cpp | 130 +- .../steam_vault/boss_hydromancer_thespia.cpp | 446 +- .../boss_mekgineer_steamrigger.cpp | 594 +- .../steam_vault/boss_warlord_kalithresh.cpp | 510 +- .../steam_vault/def_steam_vault.h | 32 +- .../steam_vault/instance_steam_vault.cpp | 340 +- .../underbog/boss_ghazan.cpp | 156 +- .../underbog/boss_hungarfen.cpp | 312 +- .../scripts/zone/darkshore/darkshore.cpp | 48 +- .../scripts/zone/deadmines/deadmines.cpp | 48 +- .../zone/deadmines/instance_deadmines.cpp | 44 +- .../scripts/zone/dun_morogh/dun_morogh.cpp | 196 +- .../dustwallow_marsh/dustwallow_marsh.cpp | 462 +- .../eastern_plaguelands.cpp | 360 +- .../zone/elwynn_forest/elwynn_forest.cpp | 196 +- .../zone/eversong_woods/eversong_woods.cpp | 326 +- .../scripts/scripts/zone/felwood/felwood.cpp | 178 +- .../scripts/scripts/zone/feralas/feralas.cpp | 170 +- .../scripts/zone/ghostlands/ghostlands.cpp | 268 +- .../scripts/zone/gruuls_lair/boss_gruul.cpp | 562 +- .../gruuls_lair/boss_high_king_maulgar.cpp | 1374 +- .../zone/gruuls_lair/def_gruuls_lair.h | 30 +- .../zone/gruuls_lair/instance_gruuls_lair.cpp | 278 +- .../blood_furnace/boss_broggok.cpp | 264 +- .../boss_kelidan_the_breaker.cpp | 506 +- .../blood_furnace/boss_the_maker.cpp | 320 +- .../boss_omor_the_unscarred.cpp | 556 +- .../boss_watchkeeper_gargolmar.cpp | 400 +- .../magtheridons_lair/boss_magtheridon.cpp | 874 +- .../magtheridons_lair/def_magtheridons_lair.h | 26 +- .../instance_magtheridons_lair.cpp | 232 +- .../shattered_halls/boss_nethekurse.cpp | 1010 +- .../boss_warbringer_omrogg.cpp | 828 +- .../shattered_halls/def_shattered_halls.h | 26 +- .../instance_shattered_halls.cpp | 228 +- .../boss_doomlord_kazzak.cpp | 282 +- .../hellfire_peninsula/hellfire_peninsula.cpp | 374 +- .../scripts/zone/ironforge/ironforge.cpp | 186 +- .../isle_of_queldanas/isle_of_queldanas.cpp | 310 +- .../scripts/zone/karazhan/boss_curator.cpp | 400 +- .../zone/karazhan/boss_maiden_of_virtue.cpp | 352 +- .../scripts/zone/karazhan/boss_midnight.cpp | 742 +- .../scripts/zone/karazhan/boss_moroes.cpp | 1736 +- .../zone/karazhan/boss_netherspite.cpp | 74 +- .../scripts/zone/karazhan/boss_nightbane.cpp | 66 +- .../zone/karazhan/boss_prince_malchezaar.cpp | 1292 +- .../zone/karazhan/boss_shade_of_aran.cpp | 1346 +- .../zone/karazhan/boss_terestian_illhoof.cpp | 908 +- .../scripts/zone/karazhan/bosses_opera.cpp | 2942 +- .../scripts/zone/karazhan/def_karazhan.h | 80 +- .../zone/karazhan/instance_karazhan.cpp | 506 +- .../scripts/zone/karazhan/karazhan.cpp | 940 +- .../scripts/zone/loch_modan/loch_modan.cpp | 182 +- .../boss_felblood_kaelthas.cpp | 1182 +- .../boss_priestess_delrissa.cpp | 2734 +- .../boss_selin_fireheart.cpp | 770 +- .../zone/magisters_terrace/boss_vexallus.cpp | 466 +- .../magisters_terrace/def_magisters_terrace.h | 58 +- .../instance_magisters_terrace.cpp | 390 +- .../maraudon/boss_celebras_the_cursed.cpp | 194 +- .../scripts/zone/maraudon/boss_landslide.cpp | 188 +- .../scripts/zone/maraudon/boss_noxxion.cpp | 298 +- .../zone/maraudon/boss_princess_theradras.cpp | 216 +- .../zone/molten_core/boss_baron_geddon.cpp | 210 +- .../scripts/zone/molten_core/boss_garr.cpp | 317 +- .../zone/molten_core/boss_gehennas.cpp | 182 +- .../zone/molten_core/boss_golemagg.cpp | 420 +- .../zone/molten_core/boss_lucifron.cpp | 180 +- .../zone/molten_core/boss_magmadar.cpp | 194 +- .../molten_core/boss_majordomo_executus.cpp | 266 +- .../zone/molten_core/boss_ragnaros.cpp | 634 +- .../zone/molten_core/boss_shazzrah.cpp | 242 +- .../molten_core/boss_sulfuron_harbinger.cpp | 430 +- .../zone/molten_core/def_molten_core.h | 42 +- .../zone/molten_core/instance_molten_core.cpp | 520 +- .../scripts/zone/molten_core/molten_core.cpp | 176 +- .../scripts/zone/moonglade/moonglade.cpp | 434 +- .../scripts/scripts/zone/mulgore/mulgore.cpp | 128 +- .../scripts/scripts/zone/nagrand/nagrand.cpp | 1136 +- .../zone/naxxramas/boss_anubrekhan.cpp | 430 +- .../scripts/zone/naxxramas/boss_faerlina.cpp | 404 +- .../scripts/zone/naxxramas/boss_feugen.cpp | 66 +- .../scripts/zone/naxxramas/boss_gluth.cpp | 348 +- .../scripts/zone/naxxramas/boss_gothik.cpp | 124 +- .../scripts/zone/naxxramas/boss_grobbulus.cpp | 60 +- .../scripts/zone/naxxramas/boss_heigan.cpp | 92 +- .../zone/naxxramas/boss_highlord_mograine.cpp | 356 +- .../scripts/zone/naxxramas/boss_kelthuzad.cpp | 1084 +- .../zone/naxxramas/boss_lady_blaumeux.cpp | 294 +- .../scripts/zone/naxxramas/boss_loatheb.cpp | 432 +- .../scripts/zone/naxxramas/boss_maexxna.cpp | 492 +- .../scripts/zone/naxxramas/boss_noth.cpp | 360 +- .../scripts/zone/naxxramas/boss_patchwerk.cpp | 320 +- .../scripts/zone/naxxramas/boss_razuvious.cpp | 334 +- .../scripts/zone/naxxramas/boss_sapphiron.cpp | 398 +- .../zone/naxxramas/boss_sir_zeliek.cpp | 292 +- .../scripts/zone/naxxramas/boss_stalagg.cpp | 70 +- .../scripts/zone/naxxramas/boss_thaddius.cpp | 98 +- .../zone/naxxramas/boss_thane_korthazz.cpp | 294 +- .../zone/naxxramas/instance_naxxramas.cpp | 48 +- .../scripts/zone/netherstorm/netherstorm.cpp | 846 +- .../scripts/zone/onyxias_lair/boss_onyxia.cpp | 458 +- .../scripts/zone/orgrimmar/orgrimmar.cpp | 530 +- .../boss_amnennar_the_coldbringer.cpp | 280 +- .../zone/ruins_of_ahnqiraj/boss_ayamiss.cpp | 214 +- .../zone/ruins_of_ahnqiraj/boss_buru.cpp | 48 +- .../zone/ruins_of_ahnqiraj/boss_kurinnaxx.cpp | 186 +- .../zone/ruins_of_ahnqiraj/boss_moam.cpp | 234 +- .../zone/ruins_of_ahnqiraj/boss_ossirian.cpp | 72 +- .../zone/ruins_of_ahnqiraj/boss_rajaxx.cpp | 84 +- .../instance_ruins_of_ahnqiraj.cpp | 48 +- .../scarlet_monastery/boss_arcanist_doan.cpp | 342 +- .../boss_azshir_the_sleepless.cpp | 194 +- .../boss_bloodmage_thalnos.cpp | 272 +- .../zone/scarlet_monastery/boss_herod.cpp | 394 +- .../boss_high_inquisitor_fairbanks.cpp | 264 +- .../boss_high_inquisitor_whitemane.cpp | 354 +- .../boss_houndmaster_loksey.cpp | 156 +- .../boss_interrogator_vishas.cpp | 226 +- .../boss_scarlet_commander_mograine.cpp | 320 +- .../zone/scarlet_monastery/boss_scorn.cpp | 200 +- .../scholomance/boss_darkmaster_gandling.cpp | 384 +- .../boss_death_knight_darkreaver.cpp | 118 +- .../boss_doctor_theolen_krastinov.cpp | 216 +- .../zone/scholomance/boss_illucia_barov.cpp | 232 +- .../scholomance/boss_instructor_malicia.cpp | 304 +- .../zone/scholomance/boss_jandice_barov.cpp | 434 +- .../scripts/zone/scholomance/boss_kormok.cpp | 310 +- .../scholomance/boss_lord_alexei_barov.cpp | 196 +- .../scholomance/boss_lorekeeper_polkelt.cpp | 226 +- .../scholomance/boss_ras_frostwhisper.cpp | 250 +- .../zone/scholomance/boss_the_ravenian.cpp | 236 +- .../scripts/zone/scholomance/boss_vectus.cpp | 190 +- .../zone/scholomance/def_scholomance.h | 30 +- .../zone/scholomance/instance_scholomance.cpp | 204 +- .../zone/searing_gorge/searing_gorge.cpp | 318 +- .../shadowfang_keep/def_shadowfang_keep.h | 24 +- .../instance_shadowfang_keep.cpp | 304 +- .../zone/shadowfang_keep/shadowfang_keep.cpp | 234 +- .../shadowmoon_valley/boss_doomwalker.cpp | 422 +- .../shadowmoon_valley/shadowmoon_valley.cpp | 1496 +- .../scripts/zone/shattrath/shattrath_city.cpp | 536 +- .../scripts/zone/silithus/silithus.cpp | 298 +- .../zone/silvermoon/silvermoon_city.cpp | 206 +- .../silverpine_forest/silverpine_forest.cpp | 200 +- .../stonetalon_mountains.cpp | 160 +- .../scripts/zone/stormwind/stormwind_city.cpp | 544 +- .../stranglethorn_vale/stranglethorn_vale.cpp | 214 +- .../zone/stratholme/boss_baron_rivendare.cpp | 430 +- .../stratholme/boss_baroness_anastari.cpp | 248 +- .../stratholme/boss_cannon_master_willey.cpp | 442 +- .../stratholme/boss_dathrohan_balnazzar.cpp | 632 +- .../stratholme/boss_magistrate_barthilas.cpp | 228 +- .../stratholme/boss_maleki_the_pallid.cpp | 238 +- .../zone/stratholme/boss_nerubenkan.cpp | 276 +- .../stratholme/boss_order_of_silver_hand.cpp | 322 +- .../stratholme/boss_postmaster_malown.cpp | 288 +- .../stratholme/boss_ramstein_the_gorger.cpp | 184 +- .../zone/stratholme/boss_timmy_the_cruel.cpp | 206 +- .../scripts/zone/stratholme/def_stratholme.h | 28 +- .../zone/stratholme/instance_stratholme.cpp | 154 +- .../scripts/zone/stratholme/stratholme.cpp | 670 +- .../zone/sunwell_plateau/boss_brutallus.cpp | 376 +- .../zone/sunwell_plateau/boss_kalecgos.cpp | 1314 +- .../sunwell_plateau/def_sunwell_plateau.h | 86 +- .../instance_sunwell_plateau.cpp | 550 +- .../scripts/scripts/zone/tanaris/tanaris.cpp | 804 +- .../zone/tempest_keep/arcatraz/arcatraz.cpp | 1224 +- .../arcatraz/boss_harbinger_skyriss.cpp | 760 +- .../zone/tempest_keep/arcatraz/def_arcatraz.h | 38 +- .../arcatraz/instance_arcatraz.cpp | 448 +- .../botanica/boss_high_botanist_freywinn.cpp | 430 +- .../zone/tempest_keep/botanica/boss_laj.cpp | 396 +- .../botanica/boss_warp_splinter.cpp | 576 +- .../tempest_keep/the_eye/boss_astromancer.cpp | 1108 +- .../tempest_keep/the_eye/boss_kaelthas.cpp | 3260 +- .../tempest_keep/the_eye/boss_void_reaver.cpp | 406 +- .../zone/tempest_keep/the_eye/def_the_eye.h | 40 +- .../tempest_keep/the_eye/instance_the_eye.cpp | 356 +- .../zone/tempest_keep/the_eye/the_eye.cpp | 196 +- .../boss_gatewatcher_gyrokill.cpp | 48 +- .../boss_gatewatcher_ironhand.cpp | 294 +- .../boss_nethermancer_sepethrea.cpp | 446 +- .../zone/temple_of_ahnqiraj/boss_bug_trio.cpp | 732 +- .../zone/temple_of_ahnqiraj/boss_cthun.cpp | 2720 +- .../zone/temple_of_ahnqiraj/boss_fankriss.cpp | 380 +- .../zone/temple_of_ahnqiraj/boss_huhuran.cpp | 286 +- .../zone/temple_of_ahnqiraj/boss_ouro.cpp | 280 +- .../zone/temple_of_ahnqiraj/boss_sartura.cpp | 542 +- .../zone/temple_of_ahnqiraj/boss_skeram.cpp | 628 +- .../temple_of_ahnqiraj/boss_twinemperors.cpp | 1396 +- .../zone/temple_of_ahnqiraj/boss_viscidus.cpp | 58 +- .../def_temple_of_ahnqiraj.h | 44 +- .../instance_temple_of_ahnqiraj.cpp | 330 +- .../mob_anubisath_sentinel.cpp | 688 +- .../zone/terokkar_forest/terokkar_forest.cpp | 798 +- .../zone/thunder_bluff/thunder_bluff.cpp | 272 +- .../zone/tirisfal_glades/tirisfal_glades.cpp | 176 +- .../scripts/zone/uldaman/boss_ironaya.cpp | 214 +- .../scripts/scripts/zone/uldaman/uldaman.cpp | 374 +- .../scripts/zone/undercity/undercity.cpp | 520 +- .../instance_wailing_caverns.cpp | 48 +- .../western_plaguelands.cpp | 352 +- .../zone/winterspring/winterspring.cpp | 314 +- .../scripts/zone/zangarmarsh/zangarmarsh.cpp | 566 +- .../scripts/zone/zulaman/boss_janalai.cpp | 1537 +- .../scripts/zone/zulaman/boss_nalorakk.cpp | 544 +- .../scripts/zone/zulaman/def_zulaman.h | 34 +- .../scripts/zone/zulaman/instance_zulaman.cpp | 274 +- .../scripts/scripts/zone/zulaman/zulaman.cpp | 216 +- .../scripts/zone/zulfarrak/zulfarrak.cpp | 448 +- .../scripts/zone/zulgurub/boss_arlokk.cpp | 422 +- .../scripts/zone/zulgurub/boss_gahzranka.cpp | 184 +- .../scripts/zone/zulgurub/boss_grilek.cpp | 184 +- .../scripts/zone/zulgurub/boss_hakkar.cpp | 512 +- .../scripts/zone/zulgurub/boss_hazzarah.cpp | 200 +- .../scripts/zone/zulgurub/boss_jeklik.cpp | 594 +- .../scripts/zone/zulgurub/boss_jindo.cpp | 580 +- .../scripts/zone/zulgurub/boss_mandokir.cpp | 622 +- .../scripts/zone/zulgurub/boss_marli.cpp | 520 +- .../scripts/zone/zulgurub/boss_renataki.cpp | 302 +- .../scripts/zone/zulgurub/boss_thekal.cpp | 1090 +- .../scripts/zone/zulgurub/boss_venoxis.cpp | 400 +- .../scripts/zone/zulgurub/boss_wushoolay.cpp | 168 +- .../scripts/zone/zulgurub/def_zulgurub.h | 72 +- .../zone/zulgurub/instance_zulgurub.cpp | 476 +- src/game/AggressorAI.cpp | 312 +- src/game/CharacterHandler.cpp | 10 +- src/game/Chat.cpp | 2234 +- src/game/Chat.h | 827 +- src/game/Creature.cpp | 3921 +- src/game/Creature.h | 1223 +- src/game/CreatureAISelector.cpp | 238 +- src/game/GossipDef.cpp | 1527 +- src/game/GossipDef.h | 399 +- src/game/GridNotifiers.h | 1624 +- src/game/GuardAI.cpp | 304 +- src/game/Guild.cpp | 3903 +- src/game/Guild.h | 872 +- src/game/Language.h | 1333 +- src/game/Level1.cpp | 4642 +- src/game/Level2.cpp | 7994 ++-- src/game/Level3.cpp | 10883 ++--- src/game/Makefile.am | 2 + src/game/NPCHandler.cpp | 1658 +- src/game/ObjectMgr.cpp | 13370 +++--- src/game/ObjectMgr.h | 1640 +- src/game/Player.cpp | 36263 ++++++++-------- src/game/Player.h | 4623 +- src/game/SharedDefines.h | 104 + src/game/Spell.cpp | 10185 +++-- src/game/Spell.h | 1389 +- src/game/SpellEffects.cpp | 12188 +++--- src/game/StatSystem.cpp | 1920 +- src/game/Unit.cpp | 21620 ++++----- src/game/Unit.h | 2667 +- src/game/WaypointMovementGenerator.cpp | 1300 +- src/game/World.cpp | 5006 +-- src/game/World.h | 12 +- src/game/WorldSession.cpp | 82 +- src/game/WorldSession.h | 10 +- src/game/WorldSocket.cpp | 1541 +- src/game/WorldSocket.h | 338 +- src/game/WorldSocketMgr.cpp | 363 +- src/game/WorldSocketMgr.h | 62 +- src/shared/Common.h | 46 +- src/shared/Database/DBCStructure.h | 1874 +- src/shared/Database/DBCfmt.cpp | 156 +- src/shared/Database/DatabaseEnv.h | 106 +- src/shared/Makefile.am | 2 + src/shared/Timer.h | 2 +- src/trinitycore/Makefile.am | 3 + src/trinitycore/Master.cpp | 183 +- src/trinitycore/TrinityCore.rc | 8 +- src/trinitycore/WorldRunnable.cpp | 3 + src/trinityrealm/Makefile.am | 3 + src/trinityrealm/TrinityRealm.rc | 8 +- win/TrinityCore No Script VC71.sln | 229 +- win/TrinityCore No Script VC80.sln | 23 +- win/TrinityCore No Scripts VC90.sln | 11 + win/TrinityCore VC71.sln | 229 +- win/TrinityCore VC80.sln | 23 +- win/TrinityCore VC90.sln | 11 + win/VC71/ACE_vc71.vcproj | 3799 ++ win/VC71/TrinityCore.vcproj | 446 +- win/VC71/TrinityRealm.vcproj | 364 +- win/VC71/game.vcproj | 1720 +- win/VC71/shared.vcproj | 868 +- win/VC80/ACE_vc8.vcproj | 5276 +++ win/VC80/TrinityCore.vcproj | 8 +- win/VC80/TrinityRealm.vcproj | 910 +- win/VC80/game.vcproj | 2642 +- win/VC80/shared.vcproj | 1542 +- win/VC90/ACE_vc9.vcproj | 5265 +++ win/VC90/TrinityCore.vcproj | 1000 +- win/VC90/TrinityRealm.vcproj | 888 +- win/VC90/game.vcproj | 2652 +- win/VC90/shared.vcproj | 1556 +- 1756 files changed, 578845 insertions(+), 187201 deletions(-) rename 6700-670 => 6721-676 (100%) create mode 100644 dep/ACE_wrappers/AUTHORS create mode 100644 dep/ACE_wrappers/COPYING create mode 100644 dep/ACE_wrappers/ChangeLog create mode 100644 dep/ACE_wrappers/FAQ create mode 100644 dep/ACE_wrappers/Makefile.am create mode 100644 dep/ACE_wrappers/NEWS create mode 100644 dep/ACE_wrappers/PROBLEM-REPORT-FORM create mode 100644 dep/ACE_wrappers/README create mode 100644 dep/ACE_wrappers/THANKS create mode 100644 dep/ACE_wrappers/VERSION create mode 100644 dep/ACE_wrappers/ace/ACE.bor create mode 100644 dep/ACE_wrappers/ace/ACE.cpp create mode 100644 dep/ACE_wrappers/ace/ACE.h create mode 100644 dep/ACE_wrappers/ace/ACE.inl create mode 100644 dep/ACE_wrappers/ace/ACE_crc32.cpp create mode 100644 dep/ACE_wrappers/ace/ACE_crc_ccitt.cpp create mode 100644 dep/ACE_wrappers/ace/ACE_export.h create mode 100644 dep/ACE_wrappers/ace/ACE_vc71.vcproj create mode 100644 dep/ACE_wrappers/ace/ACE_vc8.vcproj create mode 100644 dep/ACE_wrappers/ace/ACE_vc9.vcproj create mode 100644 dep/ACE_wrappers/ace/ARGV.cpp create mode 100644 dep/ACE_wrappers/ace/ARGV.h create mode 100644 dep/ACE_wrappers/ace/ARGV.inl create mode 100644 dep/ACE_wrappers/ace/ATM_Acceptor.cpp create mode 100644 dep/ACE_wrappers/ace/ATM_Acceptor.h create mode 100644 dep/ACE_wrappers/ace/ATM_Acceptor.inl create mode 100644 dep/ACE_wrappers/ace/ATM_Addr.cpp create mode 100644 dep/ACE_wrappers/ace/ATM_Addr.h create mode 100644 dep/ACE_wrappers/ace/ATM_Addr.inl create mode 100644 dep/ACE_wrappers/ace/ATM_Connector.cpp create mode 100644 dep/ACE_wrappers/ace/ATM_Connector.h create mode 100644 dep/ACE_wrappers/ace/ATM_Connector.inl create mode 100644 dep/ACE_wrappers/ace/ATM_Params.cpp create mode 100644 dep/ACE_wrappers/ace/ATM_Params.h create mode 100644 dep/ACE_wrappers/ace/ATM_Params.inl create mode 100644 dep/ACE_wrappers/ace/ATM_QoS.cpp create mode 100644 dep/ACE_wrappers/ace/ATM_QoS.h create mode 100644 dep/ACE_wrappers/ace/ATM_QoS.inl create mode 100644 dep/ACE_wrappers/ace/ATM_Stream.cpp create mode 100644 dep/ACE_wrappers/ace/ATM_Stream.h create mode 100644 dep/ACE_wrappers/ace/ATM_Stream.inl create mode 100644 dep/ACE_wrappers/ace/Acceptor.cpp create mode 100644 dep/ACE_wrappers/ace/Acceptor.h create mode 100644 dep/ACE_wrappers/ace/Activation_Queue.cpp create mode 100644 dep/ACE_wrappers/ace/Activation_Queue.h create mode 100644 dep/ACE_wrappers/ace/Activation_Queue.inl create mode 100644 dep/ACE_wrappers/ace/Active_Map_Manager.cpp create mode 100644 dep/ACE_wrappers/ace/Active_Map_Manager.h create mode 100644 dep/ACE_wrappers/ace/Active_Map_Manager.inl create mode 100644 dep/ACE_wrappers/ace/Active_Map_Manager_T.cpp create mode 100644 dep/ACE_wrappers/ace/Active_Map_Manager_T.h create mode 100644 dep/ACE_wrappers/ace/Active_Map_Manager_T.inl create mode 100644 dep/ACE_wrappers/ace/Addr.cpp create mode 100644 dep/ACE_wrappers/ace/Addr.h create mode 100644 dep/ACE_wrappers/ace/Addr.inl create mode 100644 dep/ACE_wrappers/ace/Arg_Shifter.cpp create mode 100644 dep/ACE_wrappers/ace/Arg_Shifter.h create mode 100644 dep/ACE_wrappers/ace/Argv_Type_Converter.cpp create mode 100644 dep/ACE_wrappers/ace/Argv_Type_Converter.h create mode 100644 dep/ACE_wrappers/ace/Argv_Type_Converter.inl create mode 100644 dep/ACE_wrappers/ace/Array.h create mode 100644 dep/ACE_wrappers/ace/Array_Base.cpp create mode 100644 dep/ACE_wrappers/ace/Array_Base.h create mode 100644 dep/ACE_wrappers/ace/Array_Base.inl create mode 100644 dep/ACE_wrappers/ace/Array_Map.cpp create mode 100644 dep/ACE_wrappers/ace/Array_Map.h create mode 100644 dep/ACE_wrappers/ace/Array_Map.inl create mode 100644 dep/ACE_wrappers/ace/Assert.cpp create mode 100644 dep/ACE_wrappers/ace/Assert.h create mode 100644 dep/ACE_wrappers/ace/Asynch_Acceptor.cpp create mode 100644 dep/ACE_wrappers/ace/Asynch_Acceptor.h create mode 100644 dep/ACE_wrappers/ace/Asynch_Connector.cpp create mode 100644 dep/ACE_wrappers/ace/Asynch_Connector.h create mode 100644 dep/ACE_wrappers/ace/Asynch_IO.cpp create mode 100644 dep/ACE_wrappers/ace/Asynch_IO.h create mode 100644 dep/ACE_wrappers/ace/Asynch_IO_Impl.cpp create mode 100644 dep/ACE_wrappers/ace/Asynch_IO_Impl.h create mode 100644 dep/ACE_wrappers/ace/Asynch_IO_Impl.inl create mode 100644 dep/ACE_wrappers/ace/Asynch_Pseudo_Task.cpp create mode 100644 dep/ACE_wrappers/ace/Asynch_Pseudo_Task.h create mode 100644 dep/ACE_wrappers/ace/Atomic_Op.cpp create mode 100644 dep/ACE_wrappers/ace/Atomic_Op.h create mode 100644 dep/ACE_wrappers/ace/Atomic_Op.inl create mode 100644 dep/ACE_wrappers/ace/Atomic_Op_Sparc.c create mode 100644 dep/ACE_wrappers/ace/Atomic_Op_Sparc.h create mode 100644 dep/ACE_wrappers/ace/Atomic_Op_T.cpp create mode 100644 dep/ACE_wrappers/ace/Atomic_Op_T.h create mode 100644 dep/ACE_wrappers/ace/Atomic_Op_T.inl create mode 100644 dep/ACE_wrappers/ace/Auto_Event.cpp create mode 100644 dep/ACE_wrappers/ace/Auto_Event.h create mode 100644 dep/ACE_wrappers/ace/Auto_Event.inl create mode 100644 dep/ACE_wrappers/ace/Auto_Functor.cpp create mode 100644 dep/ACE_wrappers/ace/Auto_Functor.h create mode 100644 dep/ACE_wrappers/ace/Auto_Functor.inl create mode 100644 dep/ACE_wrappers/ace/Auto_IncDec_T.cpp create mode 100644 dep/ACE_wrappers/ace/Auto_IncDec_T.h create mode 100644 dep/ACE_wrappers/ace/Auto_IncDec_T.inl create mode 100644 dep/ACE_wrappers/ace/Auto_Ptr.cpp create mode 100644 dep/ACE_wrappers/ace/Auto_Ptr.h create mode 100644 dep/ACE_wrappers/ace/Auto_Ptr.inl create mode 100644 dep/ACE_wrappers/ace/Barrier.cpp create mode 100644 dep/ACE_wrappers/ace/Barrier.h create mode 100644 dep/ACE_wrappers/ace/Barrier.inl create mode 100644 dep/ACE_wrappers/ace/Base_Thread_Adapter.cpp create mode 100644 dep/ACE_wrappers/ace/Base_Thread_Adapter.h create mode 100644 dep/ACE_wrappers/ace/Base_Thread_Adapter.inl create mode 100644 dep/ACE_wrappers/ace/Based_Pointer_Repository.cpp create mode 100644 dep/ACE_wrappers/ace/Based_Pointer_Repository.h create mode 100644 dep/ACE_wrappers/ace/Based_Pointer_T.cpp create mode 100644 dep/ACE_wrappers/ace/Based_Pointer_T.h create mode 100644 dep/ACE_wrappers/ace/Based_Pointer_T.inl create mode 100644 dep/ACE_wrappers/ace/Basic_Stats.cpp create mode 100644 dep/ACE_wrappers/ace/Basic_Stats.h create mode 100644 dep/ACE_wrappers/ace/Basic_Stats.inl create mode 100644 dep/ACE_wrappers/ace/Basic_Types.cpp create mode 100644 dep/ACE_wrappers/ace/Basic_Types.h create mode 100644 dep/ACE_wrappers/ace/Basic_Types.inl create mode 100644 dep/ACE_wrappers/ace/Bound_Ptr.h create mode 100644 dep/ACE_wrappers/ace/Bound_Ptr.inl create mode 100644 dep/ACE_wrappers/ace/CDR_Base.cpp create mode 100644 dep/ACE_wrappers/ace/CDR_Base.h create mode 100644 dep/ACE_wrappers/ace/CDR_Base.inl create mode 100644 dep/ACE_wrappers/ace/CDR_Size.cpp create mode 100644 dep/ACE_wrappers/ace/CDR_Size.h create mode 100644 dep/ACE_wrappers/ace/CDR_Size.inl create mode 100644 dep/ACE_wrappers/ace/CDR_Stream.cpp create mode 100644 dep/ACE_wrappers/ace/CDR_Stream.h create mode 100644 dep/ACE_wrappers/ace/CDR_Stream.inl create mode 100644 dep/ACE_wrappers/ace/CE_Screen_Output.cpp create mode 100644 dep/ACE_wrappers/ace/CE_Screen_Output.h create mode 100644 dep/ACE_wrappers/ace/CORBA_macros.h create mode 100644 dep/ACE_wrappers/ace/Cache_Map_Manager_T.cpp create mode 100644 dep/ACE_wrappers/ace/Cache_Map_Manager_T.h create mode 100644 dep/ACE_wrappers/ace/Cache_Map_Manager_T.inl create mode 100644 dep/ACE_wrappers/ace/Cached_Connect_Strategy_T.cpp create mode 100644 dep/ACE_wrappers/ace/Cached_Connect_Strategy_T.h create mode 100644 dep/ACE_wrappers/ace/Caching_Strategies_T.cpp create mode 100644 dep/ACE_wrappers/ace/Caching_Strategies_T.h create mode 100644 dep/ACE_wrappers/ace/Caching_Strategies_T.inl create mode 100644 dep/ACE_wrappers/ace/Caching_Utility_T.cpp create mode 100644 dep/ACE_wrappers/ace/Caching_Utility_T.h create mode 100644 dep/ACE_wrappers/ace/Capabilities.cpp create mode 100644 dep/ACE_wrappers/ace/Capabilities.h create mode 100644 dep/ACE_wrappers/ace/Capabilities.inl create mode 100644 dep/ACE_wrappers/ace/Cleanup.cpp create mode 100644 dep/ACE_wrappers/ace/Cleanup.h create mode 100644 dep/ACE_wrappers/ace/Cleanup.inl create mode 100644 dep/ACE_wrappers/ace/Cleanup_Strategies_T.cpp create mode 100644 dep/ACE_wrappers/ace/Cleanup_Strategies_T.h create mode 100644 dep/ACE_wrappers/ace/Codecs.cpp create mode 100644 dep/ACE_wrappers/ace/Codecs.h create mode 100644 dep/ACE_wrappers/ace/Codeset_IBM1047.cpp create mode 100644 dep/ACE_wrappers/ace/Codeset_IBM1047.h create mode 100644 dep/ACE_wrappers/ace/Codeset_Registry.cpp create mode 100644 dep/ACE_wrappers/ace/Codeset_Registry.h create mode 100644 dep/ACE_wrappers/ace/Codeset_Registry.inl create mode 100644 dep/ACE_wrappers/ace/Codeset_Registry_db.cpp create mode 100644 dep/ACE_wrappers/ace/Codeset_Symbols.h create mode 100644 dep/ACE_wrappers/ace/Condition_Recursive_Thread_Mutex.cpp create mode 100644 dep/ACE_wrappers/ace/Condition_Recursive_Thread_Mutex.h create mode 100644 dep/ACE_wrappers/ace/Condition_T.cpp create mode 100644 dep/ACE_wrappers/ace/Condition_T.h create mode 100644 dep/ACE_wrappers/ace/Condition_T.inl create mode 100644 dep/ACE_wrappers/ace/Condition_Thread_Mutex.cpp create mode 100644 dep/ACE_wrappers/ace/Condition_Thread_Mutex.h create mode 100644 dep/ACE_wrappers/ace/Condition_Thread_Mutex.inl create mode 100644 dep/ACE_wrappers/ace/Configuration.cpp create mode 100644 dep/ACE_wrappers/ace/Configuration.h create mode 100644 dep/ACE_wrappers/ace/Configuration.inl create mode 100644 dep/ACE_wrappers/ace/Configuration_Import_Export.cpp create mode 100644 dep/ACE_wrappers/ace/Configuration_Import_Export.h create mode 100644 dep/ACE_wrappers/ace/Connection_Recycling_Strategy.cpp create mode 100644 dep/ACE_wrappers/ace/Connection_Recycling_Strategy.h create mode 100644 dep/ACE_wrappers/ace/Connector.cpp create mode 100644 dep/ACE_wrappers/ace/Connector.h create mode 100644 dep/ACE_wrappers/ace/Containers.cpp create mode 100644 dep/ACE_wrappers/ace/Containers.h create mode 100644 dep/ACE_wrappers/ace/Containers.inl create mode 100644 dep/ACE_wrappers/ace/Containers_T.cpp create mode 100644 dep/ACE_wrappers/ace/Containers_T.h create mode 100644 dep/ACE_wrappers/ace/Containers_T.inl create mode 100644 dep/ACE_wrappers/ace/Copy_Disabled.cpp create mode 100644 dep/ACE_wrappers/ace/Copy_Disabled.h create mode 100644 dep/ACE_wrappers/ace/Countdown_Time.cpp create mode 100644 dep/ACE_wrappers/ace/Countdown_Time.h create mode 100644 dep/ACE_wrappers/ace/DEV.cpp create mode 100644 dep/ACE_wrappers/ace/DEV.h create mode 100644 dep/ACE_wrappers/ace/DEV.inl create mode 100644 dep/ACE_wrappers/ace/DEV_Addr.cpp create mode 100644 dep/ACE_wrappers/ace/DEV_Addr.h create mode 100644 dep/ACE_wrappers/ace/DEV_Addr.inl create mode 100644 dep/ACE_wrappers/ace/DEV_Connector.cpp create mode 100644 dep/ACE_wrappers/ace/DEV_Connector.h create mode 100644 dep/ACE_wrappers/ace/DEV_Connector.inl create mode 100644 dep/ACE_wrappers/ace/DEV_IO.cpp create mode 100644 dep/ACE_wrappers/ace/DEV_IO.h create mode 100644 dep/ACE_wrappers/ace/DEV_IO.inl create mode 100644 dep/ACE_wrappers/ace/DLL.cpp create mode 100644 dep/ACE_wrappers/ace/DLL.h create mode 100644 dep/ACE_wrappers/ace/DLL_Manager.cpp create mode 100644 dep/ACE_wrappers/ace/DLL_Manager.h create mode 100644 dep/ACE_wrappers/ace/Date_Time.cpp create mode 100644 dep/ACE_wrappers/ace/Date_Time.h create mode 100644 dep/ACE_wrappers/ace/Date_Time.inl create mode 100644 dep/ACE_wrappers/ace/Default_Constants.h create mode 100644 dep/ACE_wrappers/ace/Dev_Poll_Reactor.cpp create mode 100644 dep/ACE_wrappers/ace/Dev_Poll_Reactor.h create mode 100644 dep/ACE_wrappers/ace/Dev_Poll_Reactor.inl create mode 100644 dep/ACE_wrappers/ace/Dirent.cpp create mode 100644 dep/ACE_wrappers/ace/Dirent.h create mode 100644 dep/ACE_wrappers/ace/Dirent.inl create mode 100644 dep/ACE_wrappers/ace/Dirent_Selector.cpp create mode 100644 dep/ACE_wrappers/ace/Dirent_Selector.h create mode 100644 dep/ACE_wrappers/ace/Dirent_Selector.inl create mode 100644 dep/ACE_wrappers/ace/Dump.cpp create mode 100644 dep/ACE_wrappers/ace/Dump.h create mode 100644 dep/ACE_wrappers/ace/Dump_T.cpp create mode 100644 dep/ACE_wrappers/ace/Dump_T.h create mode 100644 dep/ACE_wrappers/ace/Dynamic.cpp create mode 100644 dep/ACE_wrappers/ace/Dynamic.h create mode 100644 dep/ACE_wrappers/ace/Dynamic.inl create mode 100644 dep/ACE_wrappers/ace/Dynamic_Message_Strategy.cpp create mode 100644 dep/ACE_wrappers/ace/Dynamic_Message_Strategy.h create mode 100644 dep/ACE_wrappers/ace/Dynamic_Message_Strategy.inl create mode 100644 dep/ACE_wrappers/ace/Dynamic_Service.cpp create mode 100644 dep/ACE_wrappers/ace/Dynamic_Service.h create mode 100644 dep/ACE_wrappers/ace/Dynamic_Service.inl create mode 100644 dep/ACE_wrappers/ace/Dynamic_Service_Base.cpp create mode 100644 dep/ACE_wrappers/ace/Dynamic_Service_Base.h create mode 100644 dep/ACE_wrappers/ace/Dynamic_Service_Dependency.cpp create mode 100644 dep/ACE_wrappers/ace/Dynamic_Service_Dependency.h create mode 100644 dep/ACE_wrappers/ace/Encoding_Converter.cpp create mode 100644 dep/ACE_wrappers/ace/Encoding_Converter.h create mode 100644 dep/ACE_wrappers/ace/Encoding_Converter_Factory.cpp create mode 100644 dep/ACE_wrappers/ace/Encoding_Converter_Factory.h create mode 100644 dep/ACE_wrappers/ace/Env_Value_T.cpp create mode 100644 dep/ACE_wrappers/ace/Env_Value_T.h create mode 100644 dep/ACE_wrappers/ace/Env_Value_T.inl create mode 100644 dep/ACE_wrappers/ace/Event.cpp create mode 100644 dep/ACE_wrappers/ace/Event.h create mode 100644 dep/ACE_wrappers/ace/Event.inl create mode 100644 dep/ACE_wrappers/ace/Event_Handler.cpp create mode 100644 dep/ACE_wrappers/ace/Event_Handler.h create mode 100644 dep/ACE_wrappers/ace/Event_Handler.inl create mode 100644 dep/ACE_wrappers/ace/Event_Handler_T.cpp create mode 100644 dep/ACE_wrappers/ace/Event_Handler_T.h create mode 100644 dep/ACE_wrappers/ace/Event_Handler_T.inl create mode 100644 dep/ACE_wrappers/ace/Exception_Macros.h create mode 100644 dep/ACE_wrappers/ace/FIFO.cpp create mode 100644 dep/ACE_wrappers/ace/FIFO.h create mode 100644 dep/ACE_wrappers/ace/FIFO.inl create mode 100644 dep/ACE_wrappers/ace/FIFO_Recv.cpp create mode 100644 dep/ACE_wrappers/ace/FIFO_Recv.h create mode 100644 dep/ACE_wrappers/ace/FIFO_Recv.inl create mode 100644 dep/ACE_wrappers/ace/FIFO_Recv_Msg.cpp create mode 100644 dep/ACE_wrappers/ace/FIFO_Recv_Msg.h create mode 100644 dep/ACE_wrappers/ace/FIFO_Recv_Msg.inl create mode 100644 dep/ACE_wrappers/ace/FIFO_Send.cpp create mode 100644 dep/ACE_wrappers/ace/FIFO_Send.h create mode 100644 dep/ACE_wrappers/ace/FIFO_Send.inl create mode 100644 dep/ACE_wrappers/ace/FIFO_Send_Msg.cpp create mode 100644 dep/ACE_wrappers/ace/FIFO_Send_Msg.h create mode 100644 dep/ACE_wrappers/ace/FIFO_Send_Msg.inl create mode 100644 dep/ACE_wrappers/ace/FILE.cpp create mode 100644 dep/ACE_wrappers/ace/FILE.h create mode 100644 dep/ACE_wrappers/ace/FILE.inl create mode 100644 dep/ACE_wrappers/ace/FILE_Addr.cpp create mode 100644 dep/ACE_wrappers/ace/FILE_Addr.h create mode 100644 dep/ACE_wrappers/ace/FILE_Addr.inl create mode 100644 dep/ACE_wrappers/ace/FILE_Connector.cpp create mode 100644 dep/ACE_wrappers/ace/FILE_Connector.h create mode 100644 dep/ACE_wrappers/ace/FILE_Connector.inl create mode 100644 dep/ACE_wrappers/ace/FILE_IO.cpp create mode 100644 dep/ACE_wrappers/ace/FILE_IO.h create mode 100644 dep/ACE_wrappers/ace/FILE_IO.inl create mode 100644 dep/ACE_wrappers/ace/File_Lock.cpp create mode 100644 dep/ACE_wrappers/ace/File_Lock.h create mode 100644 dep/ACE_wrappers/ace/File_Lock.inl create mode 100644 dep/ACE_wrappers/ace/Filecache.cpp create mode 100644 dep/ACE_wrappers/ace/Filecache.h create mode 100644 dep/ACE_wrappers/ace/Flag_Manip.cpp create mode 100644 dep/ACE_wrappers/ace/Flag_Manip.h create mode 100644 dep/ACE_wrappers/ace/Flag_Manip.inl create mode 100644 dep/ACE_wrappers/ace/Framework_Component.cpp create mode 100644 dep/ACE_wrappers/ace/Framework_Component.h create mode 100644 dep/ACE_wrappers/ace/Framework_Component.inl create mode 100644 dep/ACE_wrappers/ace/Framework_Component_T.cpp create mode 100644 dep/ACE_wrappers/ace/Framework_Component_T.h create mode 100644 dep/ACE_wrappers/ace/Free_List.cpp create mode 100644 dep/ACE_wrappers/ace/Free_List.h create mode 100644 dep/ACE_wrappers/ace/Functor.cpp create mode 100644 dep/ACE_wrappers/ace/Functor.h create mode 100644 dep/ACE_wrappers/ace/Functor.inl create mode 100644 dep/ACE_wrappers/ace/Functor_String.cpp create mode 100644 dep/ACE_wrappers/ace/Functor_String.h create mode 100644 dep/ACE_wrappers/ace/Functor_String.inl create mode 100644 dep/ACE_wrappers/ace/Functor_T.cpp create mode 100644 dep/ACE_wrappers/ace/Functor_T.h create mode 100644 dep/ACE_wrappers/ace/Functor_T.inl create mode 100644 dep/ACE_wrappers/ace/Future.cpp create mode 100644 dep/ACE_wrappers/ace/Future.h create mode 100644 dep/ACE_wrappers/ace/Future_Set.cpp create mode 100644 dep/ACE_wrappers/ace/Future_Set.h create mode 100644 dep/ACE_wrappers/ace/GNUmakefile create mode 100644 dep/ACE_wrappers/ace/GNUmakefile.ACE create mode 100644 dep/ACE_wrappers/ace/GNUmakefile.ACE_FlReactor create mode 100644 dep/ACE_wrappers/ace/GNUmakefile.ACE_Qt3Reactor create mode 100644 dep/ACE_wrappers/ace/GNUmakefile.ACE_TkReactor create mode 100644 dep/ACE_wrappers/ace/GNUmakefile.ACE_XtReactor create mode 100644 dep/ACE_wrappers/ace/Get_Opt.cpp create mode 100644 dep/ACE_wrappers/ace/Get_Opt.h create mode 100644 dep/ACE_wrappers/ace/Get_Opt.inl create mode 100644 dep/ACE_wrappers/ace/Global_Macros.h create mode 100644 dep/ACE_wrappers/ace/Guard_T.cpp create mode 100644 dep/ACE_wrappers/ace/Guard_T.h create mode 100644 dep/ACE_wrappers/ace/Guard_T.inl create mode 100644 dep/ACE_wrappers/ace/Handle_Gobbler.h create mode 100644 dep/ACE_wrappers/ace/Handle_Gobbler.inl create mode 100644 dep/ACE_wrappers/ace/Handle_Ops.cpp create mode 100644 dep/ACE_wrappers/ace/Handle_Ops.h create mode 100644 dep/ACE_wrappers/ace/Handle_Set.cpp create mode 100644 dep/ACE_wrappers/ace/Handle_Set.h create mode 100644 dep/ACE_wrappers/ace/Handle_Set.inl create mode 100644 dep/ACE_wrappers/ace/Hash_Cache_Map_Manager_T.cpp create mode 100644 dep/ACE_wrappers/ace/Hash_Cache_Map_Manager_T.h create mode 100644 dep/ACE_wrappers/ace/Hash_Cache_Map_Manager_T.inl create mode 100644 dep/ACE_wrappers/ace/Hash_Map_Manager.h create mode 100644 dep/ACE_wrappers/ace/Hash_Map_Manager_T.cpp create mode 100644 dep/ACE_wrappers/ace/Hash_Map_Manager_T.h create mode 100644 dep/ACE_wrappers/ace/Hash_Map_Manager_T.inl create mode 100644 dep/ACE_wrappers/ace/Hash_Map_With_Allocator_T.cpp create mode 100644 dep/ACE_wrappers/ace/Hash_Map_With_Allocator_T.h create mode 100644 dep/ACE_wrappers/ace/Hash_Map_With_Allocator_T.inl create mode 100644 dep/ACE_wrappers/ace/Hash_Multi_Map_Manager_T.cpp create mode 100644 dep/ACE_wrappers/ace/Hash_Multi_Map_Manager_T.h create mode 100644 dep/ACE_wrappers/ace/Hash_Multi_Map_Manager_T.inl create mode 100644 dep/ACE_wrappers/ace/Hashable.cpp create mode 100644 dep/ACE_wrappers/ace/Hashable.h create mode 100644 dep/ACE_wrappers/ace/Hashable.inl create mode 100644 dep/ACE_wrappers/ace/High_Res_Timer.cpp create mode 100644 dep/ACE_wrappers/ace/High_Res_Timer.h create mode 100644 dep/ACE_wrappers/ace/High_Res_Timer.inl create mode 100644 dep/ACE_wrappers/ace/ICMP_Socket.cpp create mode 100644 dep/ACE_wrappers/ace/ICMP_Socket.h create mode 100644 dep/ACE_wrappers/ace/INET_Addr.cpp create mode 100644 dep/ACE_wrappers/ace/INET_Addr.h create mode 100644 dep/ACE_wrappers/ace/INET_Addr.inl create mode 100644 dep/ACE_wrappers/ace/IOStream.cpp create mode 100644 dep/ACE_wrappers/ace/IOStream.h create mode 100644 dep/ACE_wrappers/ace/IOStream_T.cpp create mode 100644 dep/ACE_wrappers/ace/IOStream_T.h create mode 100644 dep/ACE_wrappers/ace/IOStream_T.inl create mode 100644 dep/ACE_wrappers/ace/IO_Cntl_Msg.cpp create mode 100644 dep/ACE_wrappers/ace/IO_Cntl_Msg.h create mode 100644 dep/ACE_wrappers/ace/IO_Cntl_Msg.inl create mode 100644 dep/ACE_wrappers/ace/IO_SAP.cpp create mode 100644 dep/ACE_wrappers/ace/IO_SAP.h create mode 100644 dep/ACE_wrappers/ace/IO_SAP.inl create mode 100644 dep/ACE_wrappers/ace/IPC_SAP.cpp create mode 100644 dep/ACE_wrappers/ace/IPC_SAP.h create mode 100644 dep/ACE_wrappers/ace/IPC_SAP.inl create mode 100644 dep/ACE_wrappers/ace/If_Then_Else.h create mode 100644 dep/ACE_wrappers/ace/Init_ACE.cpp create mode 100644 dep/ACE_wrappers/ace/Init_ACE.h create mode 100644 dep/ACE_wrappers/ace/Intrusive_Auto_Ptr.cpp create mode 100644 dep/ACE_wrappers/ace/Intrusive_Auto_Ptr.h create mode 100644 dep/ACE_wrappers/ace/Intrusive_Auto_Ptr.inl create mode 100644 dep/ACE_wrappers/ace/Intrusive_List.cpp create mode 100644 dep/ACE_wrappers/ace/Intrusive_List.h create mode 100644 dep/ACE_wrappers/ace/Intrusive_List.inl create mode 100644 dep/ACE_wrappers/ace/Intrusive_List_Node.cpp create mode 100644 dep/ACE_wrappers/ace/Intrusive_List_Node.h create mode 100644 dep/ACE_wrappers/ace/Intrusive_List_Node.inl create mode 100644 dep/ACE_wrappers/ace/LOCK_SOCK_Acceptor.cpp create mode 100644 dep/ACE_wrappers/ace/LOCK_SOCK_Acceptor.h create mode 100644 dep/ACE_wrappers/ace/LSOCK.cpp create mode 100644 dep/ACE_wrappers/ace/LSOCK.h create mode 100644 dep/ACE_wrappers/ace/LSOCK.inl create mode 100644 dep/ACE_wrappers/ace/LSOCK_Acceptor.cpp create mode 100644 dep/ACE_wrappers/ace/LSOCK_Acceptor.h create mode 100644 dep/ACE_wrappers/ace/LSOCK_CODgram.cpp create mode 100644 dep/ACE_wrappers/ace/LSOCK_CODgram.h create mode 100644 dep/ACE_wrappers/ace/LSOCK_CODgram.inl create mode 100644 dep/ACE_wrappers/ace/LSOCK_Connector.cpp create mode 100644 dep/ACE_wrappers/ace/LSOCK_Connector.h create mode 100644 dep/ACE_wrappers/ace/LSOCK_Connector.inl create mode 100644 dep/ACE_wrappers/ace/LSOCK_Dgram.cpp create mode 100644 dep/ACE_wrappers/ace/LSOCK_Dgram.h create mode 100644 dep/ACE_wrappers/ace/LSOCK_Dgram.inl create mode 100644 dep/ACE_wrappers/ace/LSOCK_Stream.cpp create mode 100644 dep/ACE_wrappers/ace/LSOCK_Stream.h create mode 100644 dep/ACE_wrappers/ace/LSOCK_Stream.inl create mode 100644 dep/ACE_wrappers/ace/Lib_Find.cpp create mode 100644 dep/ACE_wrappers/ace/Lib_Find.h create mode 100644 dep/ACE_wrappers/ace/Local_Memory_Pool.cpp create mode 100644 dep/ACE_wrappers/ace/Local_Memory_Pool.h create mode 100644 dep/ACE_wrappers/ace/Local_Name_Space.cpp create mode 100644 dep/ACE_wrappers/ace/Local_Name_Space.h create mode 100644 dep/ACE_wrappers/ace/Local_Name_Space_T.cpp create mode 100644 dep/ACE_wrappers/ace/Local_Name_Space_T.h create mode 100644 dep/ACE_wrappers/ace/Local_Tokens.cpp create mode 100644 dep/ACE_wrappers/ace/Local_Tokens.h create mode 100644 dep/ACE_wrappers/ace/Local_Tokens.inl create mode 100644 dep/ACE_wrappers/ace/Lock.cpp create mode 100644 dep/ACE_wrappers/ace/Lock.h create mode 100644 dep/ACE_wrappers/ace/Lock.inl create mode 100644 dep/ACE_wrappers/ace/Lock_Adapter_T.cpp create mode 100644 dep/ACE_wrappers/ace/Lock_Adapter_T.h create mode 100644 dep/ACE_wrappers/ace/Lock_Adapter_T.inl create mode 100644 dep/ACE_wrappers/ace/Log_Msg.cpp create mode 100644 dep/ACE_wrappers/ace/Log_Msg.h create mode 100644 dep/ACE_wrappers/ace/Log_Msg.inl create mode 100644 dep/ACE_wrappers/ace/Log_Msg_Backend.cpp create mode 100644 dep/ACE_wrappers/ace/Log_Msg_Backend.h create mode 100644 dep/ACE_wrappers/ace/Log_Msg_Callback.cpp create mode 100644 dep/ACE_wrappers/ace/Log_Msg_Callback.h create mode 100644 dep/ACE_wrappers/ace/Log_Msg_IPC.cpp create mode 100644 dep/ACE_wrappers/ace/Log_Msg_IPC.h create mode 100644 dep/ACE_wrappers/ace/Log_Msg_NT_Event_Log.cpp create mode 100644 dep/ACE_wrappers/ace/Log_Msg_NT_Event_Log.h create mode 100644 dep/ACE_wrappers/ace/Log_Msg_UNIX_Syslog.cpp create mode 100644 dep/ACE_wrappers/ace/Log_Msg_UNIX_Syslog.h create mode 100644 dep/ACE_wrappers/ace/Log_Priority.h create mode 100644 dep/ACE_wrappers/ace/Log_Record.cpp create mode 100644 dep/ACE_wrappers/ace/Log_Record.h create mode 100644 dep/ACE_wrappers/ace/Log_Record.inl create mode 100644 dep/ACE_wrappers/ace/Logging_Strategy.cpp create mode 100644 dep/ACE_wrappers/ace/Logging_Strategy.h create mode 100644 dep/ACE_wrappers/ace/MEM_Acceptor.cpp create mode 100644 dep/ACE_wrappers/ace/MEM_Acceptor.h create mode 100644 dep/ACE_wrappers/ace/MEM_Acceptor.inl create mode 100644 dep/ACE_wrappers/ace/MEM_Addr.cpp create mode 100644 dep/ACE_wrappers/ace/MEM_Addr.h create mode 100644 dep/ACE_wrappers/ace/MEM_Addr.inl create mode 100644 dep/ACE_wrappers/ace/MEM_Connector.cpp create mode 100644 dep/ACE_wrappers/ace/MEM_Connector.h create mode 100644 dep/ACE_wrappers/ace/MEM_Connector.inl create mode 100644 dep/ACE_wrappers/ace/MEM_IO.cpp create mode 100644 dep/ACE_wrappers/ace/MEM_IO.h create mode 100644 dep/ACE_wrappers/ace/MEM_IO.inl create mode 100644 dep/ACE_wrappers/ace/MEM_SAP.cpp create mode 100644 dep/ACE_wrappers/ace/MEM_SAP.h create mode 100644 dep/ACE_wrappers/ace/MEM_SAP.inl create mode 100644 dep/ACE_wrappers/ace/MEM_Stream.cpp create mode 100644 dep/ACE_wrappers/ace/MEM_Stream.h create mode 100644 dep/ACE_wrappers/ace/MEM_Stream.inl create mode 100644 dep/ACE_wrappers/ace/MMAP_Memory_Pool.cpp create mode 100644 dep/ACE_wrappers/ace/MMAP_Memory_Pool.h create mode 100644 dep/ACE_wrappers/ace/MMAP_Memory_Pool.inl create mode 100644 dep/ACE_wrappers/ace/Makefile.am create mode 100644 dep/ACE_wrappers/ace/Malloc.cpp create mode 100644 dep/ACE_wrappers/ace/Malloc.h create mode 100644 dep/ACE_wrappers/ace/Malloc.inl create mode 100644 dep/ACE_wrappers/ace/Malloc_Allocator.cpp create mode 100644 dep/ACE_wrappers/ace/Malloc_Allocator.h create mode 100644 dep/ACE_wrappers/ace/Malloc_Allocator.inl create mode 100644 dep/ACE_wrappers/ace/Malloc_Base.h create mode 100644 dep/ACE_wrappers/ace/Malloc_T.cpp create mode 100644 dep/ACE_wrappers/ace/Malloc_T.h create mode 100644 dep/ACE_wrappers/ace/Malloc_T.inl create mode 100644 dep/ACE_wrappers/ace/Managed_Object.cpp create mode 100644 dep/ACE_wrappers/ace/Managed_Object.h create mode 100644 dep/ACE_wrappers/ace/Managed_Object.inl create mode 100644 dep/ACE_wrappers/ace/Manual_Event.cpp create mode 100644 dep/ACE_wrappers/ace/Manual_Event.h create mode 100644 dep/ACE_wrappers/ace/Manual_Event.inl create mode 100644 dep/ACE_wrappers/ace/Map.h create mode 100644 dep/ACE_wrappers/ace/Map_Manager.cpp create mode 100644 dep/ACE_wrappers/ace/Map_Manager.h create mode 100644 dep/ACE_wrappers/ace/Map_Manager.inl create mode 100644 dep/ACE_wrappers/ace/Map_T.cpp create mode 100644 dep/ACE_wrappers/ace/Map_T.h create mode 100644 dep/ACE_wrappers/ace/Map_T.inl create mode 100644 dep/ACE_wrappers/ace/Mem_Map.cpp create mode 100644 dep/ACE_wrappers/ace/Mem_Map.h create mode 100644 dep/ACE_wrappers/ace/Mem_Map.inl create mode 100644 dep/ACE_wrappers/ace/Memory_Pool.h create mode 100644 dep/ACE_wrappers/ace/Message_Block.cpp create mode 100644 dep/ACE_wrappers/ace/Message_Block.h create mode 100644 dep/ACE_wrappers/ace/Message_Block.inl create mode 100644 dep/ACE_wrappers/ace/Message_Block_T.cpp create mode 100644 dep/ACE_wrappers/ace/Message_Block_T.h create mode 100644 dep/ACE_wrappers/ace/Message_Block_T.inl create mode 100644 dep/ACE_wrappers/ace/Message_Queue.cpp create mode 100644 dep/ACE_wrappers/ace/Message_Queue.h create mode 100644 dep/ACE_wrappers/ace/Message_Queue.inl create mode 100644 dep/ACE_wrappers/ace/Message_Queue_NT.cpp create mode 100644 dep/ACE_wrappers/ace/Message_Queue_NT.h create mode 100644 dep/ACE_wrappers/ace/Message_Queue_NT.inl create mode 100644 dep/ACE_wrappers/ace/Message_Queue_T.cpp create mode 100644 dep/ACE_wrappers/ace/Message_Queue_T.h create mode 100644 dep/ACE_wrappers/ace/Message_Queue_Vx.cpp create mode 100644 dep/ACE_wrappers/ace/Message_Queue_Vx.h create mode 100644 dep/ACE_wrappers/ace/Message_Queue_Vx.inl create mode 100644 dep/ACE_wrappers/ace/Method_Object.h create mode 100644 dep/ACE_wrappers/ace/Method_Request.cpp create mode 100644 dep/ACE_wrappers/ace/Method_Request.h create mode 100644 dep/ACE_wrappers/ace/Metrics_Cache.h create mode 100644 dep/ACE_wrappers/ace/Metrics_Cache_T.cpp create mode 100644 dep/ACE_wrappers/ace/Metrics_Cache_T.h create mode 100644 dep/ACE_wrappers/ace/Metrics_Cache_T.inl create mode 100644 dep/ACE_wrappers/ace/Min_Max.h create mode 100644 dep/ACE_wrappers/ace/Module.cpp create mode 100644 dep/ACE_wrappers/ace/Module.h create mode 100644 dep/ACE_wrappers/ace/Module.inl create mode 100644 dep/ACE_wrappers/ace/Monitor_Admin.cpp create mode 100644 dep/ACE_wrappers/ace/Monitor_Admin.h create mode 100644 dep/ACE_wrappers/ace/Monitor_Admin_Manager.cpp create mode 100644 dep/ACE_wrappers/ace/Monitor_Admin_Manager.h create mode 100644 dep/ACE_wrappers/ace/Monitor_Base.cpp create mode 100644 dep/ACE_wrappers/ace/Monitor_Base.h create mode 100644 dep/ACE_wrappers/ace/Monitor_Base.inl create mode 100644 dep/ACE_wrappers/ace/Monitor_Control_Action.cpp create mode 100644 dep/ACE_wrappers/ace/Monitor_Control_Action.h create mode 100644 dep/ACE_wrappers/ace/Monitor_Control_Types.cpp create mode 100644 dep/ACE_wrappers/ace/Monitor_Control_Types.h create mode 100644 dep/ACE_wrappers/ace/Monitor_Point_Registry.cpp create mode 100644 dep/ACE_wrappers/ace/Monitor_Point_Registry.h create mode 100644 dep/ACE_wrappers/ace/Monitor_Size.cpp create mode 100644 dep/ACE_wrappers/ace/Monitor_Size.h create mode 100644 dep/ACE_wrappers/ace/Msg_WFMO_Reactor.cpp create mode 100644 dep/ACE_wrappers/ace/Msg_WFMO_Reactor.h create mode 100644 dep/ACE_wrappers/ace/Msg_WFMO_Reactor.inl create mode 100644 dep/ACE_wrappers/ace/Multihomed_INET_Addr.cpp create mode 100644 dep/ACE_wrappers/ace/Multihomed_INET_Addr.h create mode 100644 dep/ACE_wrappers/ace/Multihomed_INET_Addr.inl create mode 100644 dep/ACE_wrappers/ace/Mutex.cpp create mode 100644 dep/ACE_wrappers/ace/Mutex.h create mode 100644 dep/ACE_wrappers/ace/Mutex.inl create mode 100644 dep/ACE_wrappers/ace/NT_Service.cpp create mode 100644 dep/ACE_wrappers/ace/NT_Service.h create mode 100644 dep/ACE_wrappers/ace/NT_Service.inl create mode 100644 dep/ACE_wrappers/ace/Name_Proxy.cpp create mode 100644 dep/ACE_wrappers/ace/Name_Proxy.h create mode 100644 dep/ACE_wrappers/ace/Name_Request_Reply.cpp create mode 100644 dep/ACE_wrappers/ace/Name_Request_Reply.h create mode 100644 dep/ACE_wrappers/ace/Name_Space.cpp create mode 100644 dep/ACE_wrappers/ace/Name_Space.h create mode 100644 dep/ACE_wrappers/ace/Naming_Context.cpp create mode 100644 dep/ACE_wrappers/ace/Naming_Context.h create mode 100644 dep/ACE_wrappers/ace/Naming_Context.inl create mode 100644 dep/ACE_wrappers/ace/Netlink_Addr.cpp create mode 100644 dep/ACE_wrappers/ace/Netlink_Addr.h create mode 100644 dep/ACE_wrappers/ace/Netlink_Addr.inl create mode 100644 dep/ACE_wrappers/ace/Node.cpp create mode 100644 dep/ACE_wrappers/ace/Node.h create mode 100644 dep/ACE_wrappers/ace/Notification_Queue.cpp create mode 100644 dep/ACE_wrappers/ace/Notification_Queue.h create mode 100644 dep/ACE_wrappers/ace/Notification_Queue.inl create mode 100644 dep/ACE_wrappers/ace/Notification_Strategy.cpp create mode 100644 dep/ACE_wrappers/ace/Notification_Strategy.h create mode 100644 dep/ACE_wrappers/ace/Notification_Strategy.inl create mode 100644 dep/ACE_wrappers/ace/Null_Barrier.h create mode 100644 dep/ACE_wrappers/ace/Null_Condition.h create mode 100644 dep/ACE_wrappers/ace/Null_Mutex.h create mode 100644 dep/ACE_wrappers/ace/Null_Semaphore.h create mode 100644 dep/ACE_wrappers/ace/Numeric_Limits.h create mode 100644 dep/ACE_wrappers/ace/OS.cpp create mode 100644 dep/ACE_wrappers/ace/OS.h create mode 100644 dep/ACE_wrappers/ace/OS.inl create mode 100644 dep/ACE_wrappers/ace/OS_Dirent.h create mode 100644 dep/ACE_wrappers/ace/OS_Errno.cpp create mode 100644 dep/ACE_wrappers/ace/OS_Errno.h create mode 100644 dep/ACE_wrappers/ace/OS_Errno.inl create mode 100644 dep/ACE_wrappers/ace/OS_Log_Msg_Attributes.cpp create mode 100644 dep/ACE_wrappers/ace/OS_Log_Msg_Attributes.h create mode 100644 dep/ACE_wrappers/ace/OS_Log_Msg_Attributes.inl create mode 100644 dep/ACE_wrappers/ace/OS_Memory.h create mode 100644 dep/ACE_wrappers/ace/OS_NS_Thread.cpp create mode 100644 dep/ACE_wrappers/ace/OS_NS_Thread.h create mode 100644 dep/ACE_wrappers/ace/OS_NS_Thread.inl create mode 100644 dep/ACE_wrappers/ace/OS_NS_arpa_inet.cpp create mode 100644 dep/ACE_wrappers/ace/OS_NS_arpa_inet.h create mode 100644 dep/ACE_wrappers/ace/OS_NS_arpa_inet.inl create mode 100644 dep/ACE_wrappers/ace/OS_NS_ctype.cpp create mode 100644 dep/ACE_wrappers/ace/OS_NS_ctype.h create mode 100644 dep/ACE_wrappers/ace/OS_NS_ctype.inl create mode 100644 dep/ACE_wrappers/ace/OS_NS_dirent.cpp create mode 100644 dep/ACE_wrappers/ace/OS_NS_dirent.h create mode 100644 dep/ACE_wrappers/ace/OS_NS_dirent.inl create mode 100644 dep/ACE_wrappers/ace/OS_NS_dlfcn.cpp create mode 100644 dep/ACE_wrappers/ace/OS_NS_dlfcn.h create mode 100644 dep/ACE_wrappers/ace/OS_NS_dlfcn.inl create mode 100644 dep/ACE_wrappers/ace/OS_NS_errno.cpp create mode 100644 dep/ACE_wrappers/ace/OS_NS_errno.h create mode 100644 dep/ACE_wrappers/ace/OS_NS_errno.inl create mode 100644 dep/ACE_wrappers/ace/OS_NS_fcntl.cpp create mode 100644 dep/ACE_wrappers/ace/OS_NS_fcntl.h create mode 100644 dep/ACE_wrappers/ace/OS_NS_fcntl.inl create mode 100644 dep/ACE_wrappers/ace/OS_NS_macros.h create mode 100644 dep/ACE_wrappers/ace/OS_NS_math.cpp create mode 100644 dep/ACE_wrappers/ace/OS_NS_math.h create mode 100644 dep/ACE_wrappers/ace/OS_NS_math.inl create mode 100644 dep/ACE_wrappers/ace/OS_NS_netdb.cpp create mode 100644 dep/ACE_wrappers/ace/OS_NS_netdb.h create mode 100644 dep/ACE_wrappers/ace/OS_NS_netdb.inl create mode 100644 dep/ACE_wrappers/ace/OS_NS_poll.cpp create mode 100644 dep/ACE_wrappers/ace/OS_NS_poll.h create mode 100644 dep/ACE_wrappers/ace/OS_NS_poll.inl create mode 100644 dep/ACE_wrappers/ace/OS_NS_pwd.cpp create mode 100644 dep/ACE_wrappers/ace/OS_NS_pwd.h create mode 100644 dep/ACE_wrappers/ace/OS_NS_pwd.inl create mode 100644 dep/ACE_wrappers/ace/OS_NS_regex.cpp create mode 100644 dep/ACE_wrappers/ace/OS_NS_regex.h create mode 100644 dep/ACE_wrappers/ace/OS_NS_regex.inl create mode 100644 dep/ACE_wrappers/ace/OS_NS_signal.cpp create mode 100644 dep/ACE_wrappers/ace/OS_NS_signal.h create mode 100644 dep/ACE_wrappers/ace/OS_NS_signal.inl create mode 100644 dep/ACE_wrappers/ace/OS_NS_stdio.cpp create mode 100644 dep/ACE_wrappers/ace/OS_NS_stdio.h create mode 100644 dep/ACE_wrappers/ace/OS_NS_stdio.inl create mode 100644 dep/ACE_wrappers/ace/OS_NS_stdlib.cpp create mode 100644 dep/ACE_wrappers/ace/OS_NS_stdlib.h create mode 100644 dep/ACE_wrappers/ace/OS_NS_stdlib.inl create mode 100644 dep/ACE_wrappers/ace/OS_NS_string.cpp create mode 100644 dep/ACE_wrappers/ace/OS_NS_string.h create mode 100644 dep/ACE_wrappers/ace/OS_NS_string.inl create mode 100644 dep/ACE_wrappers/ace/OS_NS_strings.cpp create mode 100644 dep/ACE_wrappers/ace/OS_NS_strings.h create mode 100644 dep/ACE_wrappers/ace/OS_NS_strings.inl create mode 100644 dep/ACE_wrappers/ace/OS_NS_stropts.cpp create mode 100644 dep/ACE_wrappers/ace/OS_NS_stropts.h create mode 100644 dep/ACE_wrappers/ace/OS_NS_stropts.inl create mode 100644 dep/ACE_wrappers/ace/OS_NS_sys_mman.cpp create mode 100644 dep/ACE_wrappers/ace/OS_NS_sys_mman.h create mode 100644 dep/ACE_wrappers/ace/OS_NS_sys_mman.inl create mode 100644 dep/ACE_wrappers/ace/OS_NS_sys_msg.cpp create mode 100644 dep/ACE_wrappers/ace/OS_NS_sys_msg.h create mode 100644 dep/ACE_wrappers/ace/OS_NS_sys_msg.inl create mode 100644 dep/ACE_wrappers/ace/OS_NS_sys_resource.cpp create mode 100644 dep/ACE_wrappers/ace/OS_NS_sys_resource.h create mode 100644 dep/ACE_wrappers/ace/OS_NS_sys_resource.inl create mode 100644 dep/ACE_wrappers/ace/OS_NS_sys_select.cpp create mode 100644 dep/ACE_wrappers/ace/OS_NS_sys_select.h create mode 100644 dep/ACE_wrappers/ace/OS_NS_sys_select.inl create mode 100644 dep/ACE_wrappers/ace/OS_NS_sys_sendfile.cpp create mode 100644 dep/ACE_wrappers/ace/OS_NS_sys_sendfile.h create mode 100644 dep/ACE_wrappers/ace/OS_NS_sys_sendfile.inl create mode 100644 dep/ACE_wrappers/ace/OS_NS_sys_shm.cpp create mode 100644 dep/ACE_wrappers/ace/OS_NS_sys_shm.h create mode 100644 dep/ACE_wrappers/ace/OS_NS_sys_shm.inl create mode 100644 dep/ACE_wrappers/ace/OS_NS_sys_socket.cpp create mode 100644 dep/ACE_wrappers/ace/OS_NS_sys_socket.h create mode 100644 dep/ACE_wrappers/ace/OS_NS_sys_socket.inl create mode 100644 dep/ACE_wrappers/ace/OS_NS_sys_stat.cpp create mode 100644 dep/ACE_wrappers/ace/OS_NS_sys_stat.h create mode 100644 dep/ACE_wrappers/ace/OS_NS_sys_stat.inl create mode 100644 dep/ACE_wrappers/ace/OS_NS_sys_time.cpp create mode 100644 dep/ACE_wrappers/ace/OS_NS_sys_time.h create mode 100644 dep/ACE_wrappers/ace/OS_NS_sys_time.inl create mode 100644 dep/ACE_wrappers/ace/OS_NS_sys_uio.cpp create mode 100644 dep/ACE_wrappers/ace/OS_NS_sys_uio.h create mode 100644 dep/ACE_wrappers/ace/OS_NS_sys_uio.inl create mode 100644 dep/ACE_wrappers/ace/OS_NS_sys_utsname.cpp create mode 100644 dep/ACE_wrappers/ace/OS_NS_sys_utsname.h create mode 100644 dep/ACE_wrappers/ace/OS_NS_sys_wait.cpp create mode 100644 dep/ACE_wrappers/ace/OS_NS_sys_wait.h create mode 100644 dep/ACE_wrappers/ace/OS_NS_sys_wait.inl create mode 100644 dep/ACE_wrappers/ace/OS_NS_time.cpp create mode 100644 dep/ACE_wrappers/ace/OS_NS_time.h create mode 100644 dep/ACE_wrappers/ace/OS_NS_time.inl create mode 100644 dep/ACE_wrappers/ace/OS_NS_unistd.cpp create mode 100644 dep/ACE_wrappers/ace/OS_NS_unistd.h create mode 100644 dep/ACE_wrappers/ace/OS_NS_unistd.inl create mode 100644 dep/ACE_wrappers/ace/OS_NS_wchar.cpp create mode 100644 dep/ACE_wrappers/ace/OS_NS_wchar.h create mode 100644 dep/ACE_wrappers/ace/OS_NS_wchar.inl create mode 100644 dep/ACE_wrappers/ace/OS_QoS.cpp create mode 100644 dep/ACE_wrappers/ace/OS_QoS.h create mode 100644 dep/ACE_wrappers/ace/OS_String.h create mode 100644 dep/ACE_wrappers/ace/OS_TLI.cpp create mode 100644 dep/ACE_wrappers/ace/OS_TLI.h create mode 100644 dep/ACE_wrappers/ace/OS_TLI.inl create mode 100644 dep/ACE_wrappers/ace/OS_Thread_Adapter.cpp create mode 100644 dep/ACE_wrappers/ace/OS_Thread_Adapter.h create mode 100644 dep/ACE_wrappers/ace/OS_main.cpp create mode 100644 dep/ACE_wrappers/ace/OS_main.h create mode 100644 dep/ACE_wrappers/ace/Obchunk.cpp create mode 100644 dep/ACE_wrappers/ace/Obchunk.h create mode 100644 dep/ACE_wrappers/ace/Obchunk.inl create mode 100644 dep/ACE_wrappers/ace/Object_Manager.cpp create mode 100644 dep/ACE_wrappers/ace/Object_Manager.h create mode 100644 dep/ACE_wrappers/ace/Object_Manager.inl create mode 100644 dep/ACE_wrappers/ace/Object_Manager_Base.cpp create mode 100644 dep/ACE_wrappers/ace/Object_Manager_Base.h create mode 100644 dep/ACE_wrappers/ace/Obstack.h create mode 100644 dep/ACE_wrappers/ace/Obstack_T.cpp create mode 100644 dep/ACE_wrappers/ace/Obstack_T.h create mode 100644 dep/ACE_wrappers/ace/Obstack_T.inl create mode 100644 dep/ACE_wrappers/ace/PI_Malloc.cpp create mode 100644 dep/ACE_wrappers/ace/PI_Malloc.h create mode 100644 dep/ACE_wrappers/ace/PI_Malloc.inl create mode 100644 dep/ACE_wrappers/ace/POSIX_Asynch_IO.cpp create mode 100644 dep/ACE_wrappers/ace/POSIX_Asynch_IO.h create mode 100644 dep/ACE_wrappers/ace/POSIX_CB_Proactor.cpp create mode 100644 dep/ACE_wrappers/ace/POSIX_CB_Proactor.h create mode 100644 dep/ACE_wrappers/ace/POSIX_Proactor.cpp create mode 100644 dep/ACE_wrappers/ace/POSIX_Proactor.h create mode 100644 dep/ACE_wrappers/ace/POSIX_Proactor.inl create mode 100644 dep/ACE_wrappers/ace/Pagefile_Memory_Pool.cpp create mode 100644 dep/ACE_wrappers/ace/Pagefile_Memory_Pool.h create mode 100644 dep/ACE_wrappers/ace/Pagefile_Memory_Pool.inl create mode 100644 dep/ACE_wrappers/ace/Pair.h create mode 100644 dep/ACE_wrappers/ace/Pair_T.cpp create mode 100644 dep/ACE_wrappers/ace/Pair_T.h create mode 100644 dep/ACE_wrappers/ace/Pair_T.inl create mode 100644 dep/ACE_wrappers/ace/Parse_Node.cpp create mode 100644 dep/ACE_wrappers/ace/Parse_Node.h create mode 100644 dep/ACE_wrappers/ace/Ping_Socket.cpp create mode 100644 dep/ACE_wrappers/ace/Ping_Socket.h create mode 100644 dep/ACE_wrappers/ace/Ping_Socket.inl create mode 100644 dep/ACE_wrappers/ace/Pipe.cpp create mode 100644 dep/ACE_wrappers/ace/Pipe.h create mode 100644 dep/ACE_wrappers/ace/Pipe.inl create mode 100644 dep/ACE_wrappers/ace/Priority_Reactor.cpp create mode 100644 dep/ACE_wrappers/ace/Priority_Reactor.h create mode 100644 dep/ACE_wrappers/ace/Proactor.cpp create mode 100644 dep/ACE_wrappers/ace/Proactor.h create mode 100644 dep/ACE_wrappers/ace/Proactor.inl create mode 100644 dep/ACE_wrappers/ace/Proactor_Impl.cpp create mode 100644 dep/ACE_wrappers/ace/Proactor_Impl.h create mode 100644 dep/ACE_wrappers/ace/Process.cpp create mode 100644 dep/ACE_wrappers/ace/Process.h create mode 100644 dep/ACE_wrappers/ace/Process.inl create mode 100644 dep/ACE_wrappers/ace/Process_Manager.cpp create mode 100644 dep/ACE_wrappers/ace/Process_Manager.h create mode 100644 dep/ACE_wrappers/ace/Process_Manager.inl create mode 100644 dep/ACE_wrappers/ace/Process_Mutex.cpp create mode 100644 dep/ACE_wrappers/ace/Process_Mutex.h create mode 100644 dep/ACE_wrappers/ace/Process_Mutex.inl create mode 100644 dep/ACE_wrappers/ace/Process_Semaphore.cpp create mode 100644 dep/ACE_wrappers/ace/Process_Semaphore.h create mode 100644 dep/ACE_wrappers/ace/Process_Semaphore.inl create mode 100644 dep/ACE_wrappers/ace/Profile_Timer.cpp create mode 100644 dep/ACE_wrappers/ace/Profile_Timer.h create mode 100644 dep/ACE_wrappers/ace/Profile_Timer.inl create mode 100644 dep/ACE_wrappers/ace/RB_Tree.cpp create mode 100644 dep/ACE_wrappers/ace/RB_Tree.h create mode 100644 dep/ACE_wrappers/ace/RB_Tree.inl create mode 100644 dep/ACE_wrappers/ace/README create mode 100644 dep/ACE_wrappers/ace/RW_Mutex.cpp create mode 100644 dep/ACE_wrappers/ace/RW_Mutex.h create mode 100644 dep/ACE_wrappers/ace/RW_Mutex.inl create mode 100644 dep/ACE_wrappers/ace/RW_Process_Mutex.cpp create mode 100644 dep/ACE_wrappers/ace/RW_Process_Mutex.h create mode 100644 dep/ACE_wrappers/ace/RW_Process_Mutex.inl create mode 100644 dep/ACE_wrappers/ace/RW_Thread_Mutex.cpp create mode 100644 dep/ACE_wrappers/ace/RW_Thread_Mutex.h create mode 100644 dep/ACE_wrappers/ace/RW_Thread_Mutex.inl create mode 100644 dep/ACE_wrappers/ace/Reactor.cpp create mode 100644 dep/ACE_wrappers/ace/Reactor.h create mode 100644 dep/ACE_wrappers/ace/Reactor.inl create mode 100644 dep/ACE_wrappers/ace/Reactor_Impl.cpp create mode 100644 dep/ACE_wrappers/ace/Reactor_Impl.h create mode 100644 dep/ACE_wrappers/ace/Reactor_Notification_Strategy.cpp create mode 100644 dep/ACE_wrappers/ace/Reactor_Notification_Strategy.h create mode 100644 dep/ACE_wrappers/ace/Reactor_Notification_Strategy.inl create mode 100644 dep/ACE_wrappers/ace/Reactor_Timer_Interface.cpp create mode 100644 dep/ACE_wrappers/ace/Reactor_Timer_Interface.h create mode 100644 dep/ACE_wrappers/ace/Reactor_Token_T.cpp create mode 100644 dep/ACE_wrappers/ace/Reactor_Token_T.h create mode 100644 dep/ACE_wrappers/ace/Read_Buffer.cpp create mode 100644 dep/ACE_wrappers/ace/Read_Buffer.h create mode 100644 dep/ACE_wrappers/ace/Read_Buffer.inl create mode 100644 dep/ACE_wrappers/ace/Recursive_Thread_Mutex.cpp create mode 100644 dep/ACE_wrappers/ace/Recursive_Thread_Mutex.h create mode 100644 dep/ACE_wrappers/ace/Recursive_Thread_Mutex.inl create mode 100644 dep/ACE_wrappers/ace/Recyclable.cpp create mode 100644 dep/ACE_wrappers/ace/Recyclable.h create mode 100644 dep/ACE_wrappers/ace/Recyclable.inl create mode 100644 dep/ACE_wrappers/ace/Refcountable.h create mode 100644 dep/ACE_wrappers/ace/Refcountable_T.cpp create mode 100644 dep/ACE_wrappers/ace/Refcountable_T.h create mode 100644 dep/ACE_wrappers/ace/Refcountable_T.inl create mode 100644 dep/ACE_wrappers/ace/Refcounted_Auto_Ptr.cpp create mode 100644 dep/ACE_wrappers/ace/Refcounted_Auto_Ptr.h create mode 100644 dep/ACE_wrappers/ace/Refcounted_Auto_Ptr.inl create mode 100644 dep/ACE_wrappers/ace/Registry.cpp create mode 100644 dep/ACE_wrappers/ace/Registry.h create mode 100644 dep/ACE_wrappers/ace/Registry_Name_Space.cpp create mode 100644 dep/ACE_wrappers/ace/Registry_Name_Space.h create mode 100644 dep/ACE_wrappers/ace/Remote_Name_Space.cpp create mode 100644 dep/ACE_wrappers/ace/Remote_Name_Space.h create mode 100644 dep/ACE_wrappers/ace/Remote_Tokens.cpp create mode 100644 dep/ACE_wrappers/ace/Remote_Tokens.h create mode 100644 dep/ACE_wrappers/ace/Remote_Tokens.inl create mode 100644 dep/ACE_wrappers/ace/Reverse_Lock_T.cpp create mode 100644 dep/ACE_wrappers/ace/Reverse_Lock_T.h create mode 100644 dep/ACE_wrappers/ace/Reverse_Lock_T.inl create mode 100644 dep/ACE_wrappers/ace/Rtems_init.c create mode 100644 dep/ACE_wrappers/ace/SOCK.cpp create mode 100644 dep/ACE_wrappers/ace/SOCK.h create mode 100644 dep/ACE_wrappers/ace/SOCK.inl create mode 100644 dep/ACE_wrappers/ace/SOCK_Acceptor.cpp create mode 100644 dep/ACE_wrappers/ace/SOCK_Acceptor.h create mode 100644 dep/ACE_wrappers/ace/SOCK_Acceptor.inl create mode 100644 dep/ACE_wrappers/ace/SOCK_CODgram.cpp create mode 100644 dep/ACE_wrappers/ace/SOCK_CODgram.h create mode 100644 dep/ACE_wrappers/ace/SOCK_CODgram.inl create mode 100644 dep/ACE_wrappers/ace/SOCK_Connector.cpp create mode 100644 dep/ACE_wrappers/ace/SOCK_Connector.h create mode 100644 dep/ACE_wrappers/ace/SOCK_Connector.inl create mode 100644 dep/ACE_wrappers/ace/SOCK_Dgram.cpp create mode 100644 dep/ACE_wrappers/ace/SOCK_Dgram.h create mode 100644 dep/ACE_wrappers/ace/SOCK_Dgram.inl create mode 100644 dep/ACE_wrappers/ace/SOCK_Dgram_Bcast.cpp create mode 100644 dep/ACE_wrappers/ace/SOCK_Dgram_Bcast.h create mode 100644 dep/ACE_wrappers/ace/SOCK_Dgram_Bcast.inl create mode 100644 dep/ACE_wrappers/ace/SOCK_Dgram_Mcast.cpp create mode 100644 dep/ACE_wrappers/ace/SOCK_Dgram_Mcast.h create mode 100644 dep/ACE_wrappers/ace/SOCK_Dgram_Mcast.inl create mode 100644 dep/ACE_wrappers/ace/SOCK_IO.cpp create mode 100644 dep/ACE_wrappers/ace/SOCK_IO.h create mode 100644 dep/ACE_wrappers/ace/SOCK_IO.inl create mode 100644 dep/ACE_wrappers/ace/SOCK_Netlink.cpp create mode 100644 dep/ACE_wrappers/ace/SOCK_Netlink.h create mode 100644 dep/ACE_wrappers/ace/SOCK_Netlink.inl create mode 100644 dep/ACE_wrappers/ace/SOCK_SEQPACK_Acceptor.cpp create mode 100644 dep/ACE_wrappers/ace/SOCK_SEQPACK_Acceptor.h create mode 100644 dep/ACE_wrappers/ace/SOCK_SEQPACK_Acceptor.inl create mode 100644 dep/ACE_wrappers/ace/SOCK_SEQPACK_Association.cpp create mode 100644 dep/ACE_wrappers/ace/SOCK_SEQPACK_Association.h create mode 100644 dep/ACE_wrappers/ace/SOCK_SEQPACK_Association.inl create mode 100644 dep/ACE_wrappers/ace/SOCK_SEQPACK_Connector.cpp create mode 100644 dep/ACE_wrappers/ace/SOCK_SEQPACK_Connector.h create mode 100644 dep/ACE_wrappers/ace/SOCK_SEQPACK_Connector.inl create mode 100644 dep/ACE_wrappers/ace/SOCK_Stream.cpp create mode 100644 dep/ACE_wrappers/ace/SOCK_Stream.h create mode 100644 dep/ACE_wrappers/ace/SOCK_Stream.inl create mode 100644 dep/ACE_wrappers/ace/SPIPE.cpp create mode 100644 dep/ACE_wrappers/ace/SPIPE.h create mode 100644 dep/ACE_wrappers/ace/SPIPE.inl create mode 100644 dep/ACE_wrappers/ace/SPIPE_Acceptor.cpp create mode 100644 dep/ACE_wrappers/ace/SPIPE_Acceptor.h create mode 100644 dep/ACE_wrappers/ace/SPIPE_Addr.cpp create mode 100644 dep/ACE_wrappers/ace/SPIPE_Addr.h create mode 100644 dep/ACE_wrappers/ace/SPIPE_Addr.inl create mode 100644 dep/ACE_wrappers/ace/SPIPE_Connector.cpp create mode 100644 dep/ACE_wrappers/ace/SPIPE_Connector.h create mode 100644 dep/ACE_wrappers/ace/SPIPE_Connector.inl create mode 100644 dep/ACE_wrappers/ace/SPIPE_Stream.cpp create mode 100644 dep/ACE_wrappers/ace/SPIPE_Stream.h create mode 100644 dep/ACE_wrappers/ace/SPIPE_Stream.inl create mode 100644 dep/ACE_wrappers/ace/SString.cpp create mode 100644 dep/ACE_wrappers/ace/SString.h create mode 100644 dep/ACE_wrappers/ace/SString.inl create mode 100644 dep/ACE_wrappers/ace/SStringfwd.h create mode 100644 dep/ACE_wrappers/ace/SUN_Proactor.cpp create mode 100644 dep/ACE_wrappers/ace/SUN_Proactor.h create mode 100644 dep/ACE_wrappers/ace/SV_Message.cpp create mode 100644 dep/ACE_wrappers/ace/SV_Message.h create mode 100644 dep/ACE_wrappers/ace/SV_Message.inl create mode 100644 dep/ACE_wrappers/ace/SV_Message_Queue.cpp create mode 100644 dep/ACE_wrappers/ace/SV_Message_Queue.h create mode 100644 dep/ACE_wrappers/ace/SV_Message_Queue.inl create mode 100644 dep/ACE_wrappers/ace/SV_Semaphore_Complex.cpp create mode 100644 dep/ACE_wrappers/ace/SV_Semaphore_Complex.h create mode 100644 dep/ACE_wrappers/ace/SV_Semaphore_Complex.inl create mode 100644 dep/ACE_wrappers/ace/SV_Semaphore_Simple.cpp create mode 100644 dep/ACE_wrappers/ace/SV_Semaphore_Simple.h create mode 100644 dep/ACE_wrappers/ace/SV_Semaphore_Simple.inl create mode 100644 dep/ACE_wrappers/ace/SV_Shared_Memory.cpp create mode 100644 dep/ACE_wrappers/ace/SV_Shared_Memory.h create mode 100644 dep/ACE_wrappers/ace/SV_Shared_Memory.inl create mode 100644 dep/ACE_wrappers/ace/Sample_History.cpp create mode 100644 dep/ACE_wrappers/ace/Sample_History.h create mode 100644 dep/ACE_wrappers/ace/Sample_History.inl create mode 100644 dep/ACE_wrappers/ace/Sbrk_Memory_Pool.cpp create mode 100644 dep/ACE_wrappers/ace/Sbrk_Memory_Pool.h create mode 100644 dep/ACE_wrappers/ace/Sched_Params.cpp create mode 100644 dep/ACE_wrappers/ace/Sched_Params.h create mode 100644 dep/ACE_wrappers/ace/Sched_Params.inl create mode 100644 dep/ACE_wrappers/ace/Select_Reactor.h create mode 100644 dep/ACE_wrappers/ace/Select_Reactor_Base.cpp create mode 100644 dep/ACE_wrappers/ace/Select_Reactor_Base.h create mode 100644 dep/ACE_wrappers/ace/Select_Reactor_Base.inl create mode 100644 dep/ACE_wrappers/ace/Select_Reactor_T.cpp create mode 100644 dep/ACE_wrappers/ace/Select_Reactor_T.h create mode 100644 dep/ACE_wrappers/ace/Select_Reactor_T.inl create mode 100644 dep/ACE_wrappers/ace/Semaphore.cpp create mode 100644 dep/ACE_wrappers/ace/Semaphore.h create mode 100644 dep/ACE_wrappers/ace/Semaphore.inl create mode 100644 dep/ACE_wrappers/ace/Service_Config.cpp create mode 100644 dep/ACE_wrappers/ace/Service_Config.h create mode 100644 dep/ACE_wrappers/ace/Service_Config.inl create mode 100644 dep/ACE_wrappers/ace/Service_Gestalt.cpp create mode 100644 dep/ACE_wrappers/ace/Service_Gestalt.h create mode 100644 dep/ACE_wrappers/ace/Service_Gestalt.inl create mode 100644 dep/ACE_wrappers/ace/Service_Manager.cpp create mode 100644 dep/ACE_wrappers/ace/Service_Manager.h create mode 100644 dep/ACE_wrappers/ace/Service_Object.cpp create mode 100644 dep/ACE_wrappers/ace/Service_Object.h create mode 100644 dep/ACE_wrappers/ace/Service_Object.inl create mode 100644 dep/ACE_wrappers/ace/Service_Repository.cpp create mode 100644 dep/ACE_wrappers/ace/Service_Repository.h create mode 100644 dep/ACE_wrappers/ace/Service_Repository.inl create mode 100644 dep/ACE_wrappers/ace/Service_Templates.h create mode 100644 dep/ACE_wrappers/ace/Service_Types.cpp create mode 100644 dep/ACE_wrappers/ace/Service_Types.h create mode 100644 dep/ACE_wrappers/ace/Service_Types.inl create mode 100644 dep/ACE_wrappers/ace/Shared_Memory.cpp create mode 100644 dep/ACE_wrappers/ace/Shared_Memory.h create mode 100644 dep/ACE_wrappers/ace/Shared_Memory_MM.cpp create mode 100644 dep/ACE_wrappers/ace/Shared_Memory_MM.h create mode 100644 dep/ACE_wrappers/ace/Shared_Memory_MM.inl create mode 100644 dep/ACE_wrappers/ace/Shared_Memory_Pool.cpp create mode 100644 dep/ACE_wrappers/ace/Shared_Memory_Pool.h create mode 100644 dep/ACE_wrappers/ace/Shared_Memory_SV.cpp create mode 100644 dep/ACE_wrappers/ace/Shared_Memory_SV.h create mode 100644 dep/ACE_wrappers/ace/Shared_Memory_SV.inl create mode 100644 dep/ACE_wrappers/ace/Shared_Object.cpp create mode 100644 dep/ACE_wrappers/ace/Shared_Object.h create mode 100644 dep/ACE_wrappers/ace/Shared_Object.inl create mode 100644 dep/ACE_wrappers/ace/Sig_Adapter.cpp create mode 100644 dep/ACE_wrappers/ace/Sig_Adapter.h create mode 100644 dep/ACE_wrappers/ace/Sig_Handler.cpp create mode 100644 dep/ACE_wrappers/ace/Sig_Handler.h create mode 100644 dep/ACE_wrappers/ace/Sig_Handler.inl create mode 100644 dep/ACE_wrappers/ace/Signal.cpp create mode 100644 dep/ACE_wrappers/ace/Signal.h create mode 100644 dep/ACE_wrappers/ace/Signal.inl create mode 100644 dep/ACE_wrappers/ace/Singleton.cpp create mode 100644 dep/ACE_wrappers/ace/Singleton.h create mode 100644 dep/ACE_wrappers/ace/Singleton.inl create mode 100644 dep/ACE_wrappers/ace/Sock_Connect.cpp create mode 100644 dep/ACE_wrappers/ace/Sock_Connect.h create mode 100644 dep/ACE_wrappers/ace/Stack_Trace.cpp create mode 100644 dep/ACE_wrappers/ace/Stack_Trace.h create mode 100644 dep/ACE_wrappers/ace/Static_Object_Lock.h create mode 100644 dep/ACE_wrappers/ace/Stats.cpp create mode 100644 dep/ACE_wrappers/ace/Stats.h create mode 100644 dep/ACE_wrappers/ace/Stats.inl create mode 100644 dep/ACE_wrappers/ace/Strategies.h create mode 100644 dep/ACE_wrappers/ace/Strategies_T.cpp create mode 100644 dep/ACE_wrappers/ace/Strategies_T.h create mode 100644 dep/ACE_wrappers/ace/Strategies_T.inl create mode 100644 dep/ACE_wrappers/ace/Stream.cpp create mode 100644 dep/ACE_wrappers/ace/Stream.h create mode 100644 dep/ACE_wrappers/ace/Stream.inl create mode 100644 dep/ACE_wrappers/ace/Stream_Modules.cpp create mode 100644 dep/ACE_wrappers/ace/Stream_Modules.h create mode 100644 dep/ACE_wrappers/ace/String_Base.cpp create mode 100644 dep/ACE_wrappers/ace/String_Base.h create mode 100644 dep/ACE_wrappers/ace/String_Base.inl create mode 100644 dep/ACE_wrappers/ace/String_Base_Const.cpp create mode 100644 dep/ACE_wrappers/ace/String_Base_Const.h create mode 100644 dep/ACE_wrappers/ace/Svc_Conf.h create mode 100644 dep/ACE_wrappers/ace/Svc_Conf.y create mode 100644 dep/ACE_wrappers/ace/Svc_Conf_Lexer.cpp create mode 100644 dep/ACE_wrappers/ace/Svc_Conf_Lexer.h create mode 100644 dep/ACE_wrappers/ace/Svc_Conf_Param.h create mode 100644 dep/ACE_wrappers/ace/Svc_Conf_Token_Table.h create mode 100644 dep/ACE_wrappers/ace/Svc_Conf_Tokens.h create mode 100644 dep/ACE_wrappers/ace/Svc_Conf_y.cpp create mode 100644 dep/ACE_wrappers/ace/Svc_Handler.cpp create mode 100644 dep/ACE_wrappers/ace/Svc_Handler.h create mode 100644 dep/ACE_wrappers/ace/Synch.h create mode 100644 dep/ACE_wrappers/ace/Synch_Options.cpp create mode 100644 dep/ACE_wrappers/ace/Synch_Options.h create mode 100644 dep/ACE_wrappers/ace/Synch_T.cpp create mode 100644 dep/ACE_wrappers/ace/Synch_T.h create mode 100644 dep/ACE_wrappers/ace/Synch_Traits.h create mode 100644 dep/ACE_wrappers/ace/System_Time.cpp create mode 100644 dep/ACE_wrappers/ace/System_Time.h create mode 100644 dep/ACE_wrappers/ace/TLI.cpp create mode 100644 dep/ACE_wrappers/ace/TLI.h create mode 100644 dep/ACE_wrappers/ace/TLI.inl create mode 100644 dep/ACE_wrappers/ace/TLI_Acceptor.cpp create mode 100644 dep/ACE_wrappers/ace/TLI_Acceptor.h create mode 100644 dep/ACE_wrappers/ace/TLI_Connector.cpp create mode 100644 dep/ACE_wrappers/ace/TLI_Connector.h create mode 100644 dep/ACE_wrappers/ace/TLI_Connector.inl create mode 100644 dep/ACE_wrappers/ace/TLI_Stream.cpp create mode 100644 dep/ACE_wrappers/ace/TLI_Stream.h create mode 100644 dep/ACE_wrappers/ace/TLI_Stream.inl create mode 100644 dep/ACE_wrappers/ace/TP_Reactor.cpp create mode 100644 dep/ACE_wrappers/ace/TP_Reactor.h create mode 100644 dep/ACE_wrappers/ace/TP_Reactor.inl create mode 100644 dep/ACE_wrappers/ace/TSS_Adapter.cpp create mode 100644 dep/ACE_wrappers/ace/TSS_Adapter.h create mode 100644 dep/ACE_wrappers/ace/TSS_T.cpp create mode 100644 dep/ACE_wrappers/ace/TSS_T.h create mode 100644 dep/ACE_wrappers/ace/TSS_T.inl create mode 100644 dep/ACE_wrappers/ace/TTY_IO.cpp create mode 100644 dep/ACE_wrappers/ace/TTY_IO.h create mode 100644 dep/ACE_wrappers/ace/Task.cpp create mode 100644 dep/ACE_wrappers/ace/Task.h create mode 100644 dep/ACE_wrappers/ace/Task.inl create mode 100644 dep/ACE_wrappers/ace/Task_Ex_T.cpp create mode 100644 dep/ACE_wrappers/ace/Task_Ex_T.h create mode 100644 dep/ACE_wrappers/ace/Task_Ex_T.inl create mode 100644 dep/ACE_wrappers/ace/Task_T.cpp create mode 100644 dep/ACE_wrappers/ace/Task_T.h create mode 100644 dep/ACE_wrappers/ace/Task_T.inl create mode 100644 dep/ACE_wrappers/ace/Test_and_Set.cpp create mode 100644 dep/ACE_wrappers/ace/Test_and_Set.h create mode 100644 dep/ACE_wrappers/ace/Thread.cpp create mode 100644 dep/ACE_wrappers/ace/Thread.h create mode 100644 dep/ACE_wrappers/ace/Thread.inl create mode 100644 dep/ACE_wrappers/ace/Thread_Adapter.cpp create mode 100644 dep/ACE_wrappers/ace/Thread_Adapter.h create mode 100644 dep/ACE_wrappers/ace/Thread_Adapter.inl create mode 100644 dep/ACE_wrappers/ace/Thread_Control.cpp create mode 100644 dep/ACE_wrappers/ace/Thread_Control.h create mode 100644 dep/ACE_wrappers/ace/Thread_Control.inl create mode 100644 dep/ACE_wrappers/ace/Thread_Exit.cpp create mode 100644 dep/ACE_wrappers/ace/Thread_Exit.h create mode 100644 dep/ACE_wrappers/ace/Thread_Hook.cpp create mode 100644 dep/ACE_wrappers/ace/Thread_Hook.h create mode 100644 dep/ACE_wrappers/ace/Thread_Manager.cpp create mode 100644 dep/ACE_wrappers/ace/Thread_Manager.h create mode 100644 dep/ACE_wrappers/ace/Thread_Manager.inl create mode 100644 dep/ACE_wrappers/ace/Thread_Mutex.cpp create mode 100644 dep/ACE_wrappers/ace/Thread_Mutex.h create mode 100644 dep/ACE_wrappers/ace/Thread_Mutex.inl create mode 100644 dep/ACE_wrappers/ace/Thread_Semaphore.cpp create mode 100644 dep/ACE_wrappers/ace/Thread_Semaphore.h create mode 100644 dep/ACE_wrappers/ace/Thread_Semaphore.inl create mode 100644 dep/ACE_wrappers/ace/Throughput_Stats.cpp create mode 100644 dep/ACE_wrappers/ace/Throughput_Stats.h create mode 100644 dep/ACE_wrappers/ace/Time_Value.cpp create mode 100644 dep/ACE_wrappers/ace/Time_Value.h create mode 100644 dep/ACE_wrappers/ace/Time_Value.inl create mode 100644 dep/ACE_wrappers/ace/Timeprobe.cpp create mode 100644 dep/ACE_wrappers/ace/Timeprobe.h create mode 100644 dep/ACE_wrappers/ace/Timeprobe.inl create mode 100644 dep/ACE_wrappers/ace/Timeprobe_T.cpp create mode 100644 dep/ACE_wrappers/ace/Timeprobe_T.h create mode 100644 dep/ACE_wrappers/ace/Timer_Hash.h create mode 100644 dep/ACE_wrappers/ace/Timer_Hash_T.cpp create mode 100644 dep/ACE_wrappers/ace/Timer_Hash_T.h create mode 100644 dep/ACE_wrappers/ace/Timer_Heap.h create mode 100644 dep/ACE_wrappers/ace/Timer_Heap_T.cpp create mode 100644 dep/ACE_wrappers/ace/Timer_Heap_T.h create mode 100644 dep/ACE_wrappers/ace/Timer_List.h create mode 100644 dep/ACE_wrappers/ace/Timer_List_T.cpp create mode 100644 dep/ACE_wrappers/ace/Timer_List_T.h create mode 100644 dep/ACE_wrappers/ace/Timer_Queue.h create mode 100644 dep/ACE_wrappers/ace/Timer_Queue_Adapters.cpp create mode 100644 dep/ACE_wrappers/ace/Timer_Queue_Adapters.h create mode 100644 dep/ACE_wrappers/ace/Timer_Queue_Adapters.inl create mode 100644 dep/ACE_wrappers/ace/Timer_Queue_T.cpp create mode 100644 dep/ACE_wrappers/ace/Timer_Queue_T.h create mode 100644 dep/ACE_wrappers/ace/Timer_Queue_T.inl create mode 100644 dep/ACE_wrappers/ace/Timer_Queuefwd.h create mode 100644 dep/ACE_wrappers/ace/Timer_Wheel.h create mode 100644 dep/ACE_wrappers/ace/Timer_Wheel_T.cpp create mode 100644 dep/ACE_wrappers/ace/Timer_Wheel_T.h create mode 100644 dep/ACE_wrappers/ace/Token.cpp create mode 100644 dep/ACE_wrappers/ace/Token.h create mode 100644 dep/ACE_wrappers/ace/Token.inl create mode 100644 dep/ACE_wrappers/ace/Token_Collection.cpp create mode 100644 dep/ACE_wrappers/ace/Token_Collection.h create mode 100644 dep/ACE_wrappers/ace/Token_Collection.inl create mode 100644 dep/ACE_wrappers/ace/Token_Invariants.cpp create mode 100644 dep/ACE_wrappers/ace/Token_Invariants.h create mode 100644 dep/ACE_wrappers/ace/Token_Manager.cpp create mode 100644 dep/ACE_wrappers/ace/Token_Manager.h create mode 100644 dep/ACE_wrappers/ace/Token_Manager.inl create mode 100644 dep/ACE_wrappers/ace/Token_Request_Reply.cpp create mode 100644 dep/ACE_wrappers/ace/Token_Request_Reply.h create mode 100644 dep/ACE_wrappers/ace/Token_Request_Reply.inl create mode 100644 dep/ACE_wrappers/ace/Trace.cpp create mode 100644 dep/ACE_wrappers/ace/Trace.h create mode 100644 dep/ACE_wrappers/ace/Truncate.h create mode 100644 dep/ACE_wrappers/ace/Typed_SV_Message.cpp create mode 100644 dep/ACE_wrappers/ace/Typed_SV_Message.h create mode 100644 dep/ACE_wrappers/ace/Typed_SV_Message.inl create mode 100644 dep/ACE_wrappers/ace/Typed_SV_Message_Queue.cpp create mode 100644 dep/ACE_wrappers/ace/Typed_SV_Message_Queue.h create mode 100644 dep/ACE_wrappers/ace/Typed_SV_Message_Queue.inl create mode 100644 dep/ACE_wrappers/ace/UNIX_Addr.cpp create mode 100644 dep/ACE_wrappers/ace/UNIX_Addr.h create mode 100644 dep/ACE_wrappers/ace/UNIX_Addr.inl create mode 100644 dep/ACE_wrappers/ace/UPIPE_Acceptor.cpp create mode 100644 dep/ACE_wrappers/ace/UPIPE_Acceptor.h create mode 100644 dep/ACE_wrappers/ace/UPIPE_Acceptor.inl create mode 100644 dep/ACE_wrappers/ace/UPIPE_Addr.h create mode 100644 dep/ACE_wrappers/ace/UPIPE_Connector.cpp create mode 100644 dep/ACE_wrappers/ace/UPIPE_Connector.h create mode 100644 dep/ACE_wrappers/ace/UPIPE_Connector.inl create mode 100644 dep/ACE_wrappers/ace/UPIPE_Stream.cpp create mode 100644 dep/ACE_wrappers/ace/UPIPE_Stream.h create mode 100644 dep/ACE_wrappers/ace/UPIPE_Stream.inl create mode 100644 dep/ACE_wrappers/ace/UTF16_Encoding_Converter.cpp create mode 100644 dep/ACE_wrappers/ace/UTF16_Encoding_Converter.h create mode 100644 dep/ACE_wrappers/ace/UTF16_Encoding_Converter.inl create mode 100644 dep/ACE_wrappers/ace/UTF32_Encoding_Converter.cpp create mode 100644 dep/ACE_wrappers/ace/UTF32_Encoding_Converter.h create mode 100644 dep/ACE_wrappers/ace/UTF8_Encoding_Converter.cpp create mode 100644 dep/ACE_wrappers/ace/UTF8_Encoding_Converter.h create mode 100644 dep/ACE_wrappers/ace/UUID.cpp create mode 100644 dep/ACE_wrappers/ace/UUID.h create mode 100644 dep/ACE_wrappers/ace/UUID.inl create mode 100644 dep/ACE_wrappers/ace/Unbounded_Queue.cpp create mode 100644 dep/ACE_wrappers/ace/Unbounded_Queue.h create mode 100644 dep/ACE_wrappers/ace/Unbounded_Queue.inl create mode 100644 dep/ACE_wrappers/ace/Unbounded_Set.cpp create mode 100644 dep/ACE_wrappers/ace/Unbounded_Set.h create mode 100644 dep/ACE_wrappers/ace/Unbounded_Set.inl create mode 100644 dep/ACE_wrappers/ace/Unbounded_Set_Ex.cpp create mode 100644 dep/ACE_wrappers/ace/Unbounded_Set_Ex.h create mode 100644 dep/ACE_wrappers/ace/Unbounded_Set_Ex.inl create mode 100644 dep/ACE_wrappers/ace/Value_Ptr.h create mode 100644 dep/ACE_wrappers/ace/Vector_T.cpp create mode 100644 dep/ACE_wrappers/ace/Vector_T.h create mode 100644 dep/ACE_wrappers/ace/Vector_T.inl create mode 100644 dep/ACE_wrappers/ace/Version.h create mode 100644 dep/ACE_wrappers/ace/Versioned_Namespace.h create mode 100644 dep/ACE_wrappers/ace/WFMO_Reactor.cpp create mode 100644 dep/ACE_wrappers/ace/WFMO_Reactor.h create mode 100644 dep/ACE_wrappers/ace/WFMO_Reactor.inl create mode 100644 dep/ACE_wrappers/ace/WIN32_Asynch_IO.cpp create mode 100644 dep/ACE_wrappers/ace/WIN32_Asynch_IO.h create mode 100644 dep/ACE_wrappers/ace/WIN32_Proactor.cpp create mode 100644 dep/ACE_wrappers/ace/WIN32_Proactor.h create mode 100644 dep/ACE_wrappers/ace/XML_Svc_Conf.cpp create mode 100644 dep/ACE_wrappers/ace/XML_Svc_Conf.h create mode 100644 dep/ACE_wrappers/ace/XTI_ATM_Mcast.cpp create mode 100644 dep/ACE_wrappers/ace/XTI_ATM_Mcast.h create mode 100644 dep/ACE_wrappers/ace/XTI_ATM_Mcast.inl create mode 100644 dep/ACE_wrappers/ace/ace.rc create mode 100644 dep/ACE_wrappers/ace/ace_ce_dll.cfg create mode 100644 dep/ACE_wrappers/ace/ace_message_table.bin create mode 100644 dep/ACE_wrappers/ace/ace_wchar.cpp create mode 100644 dep/ACE_wrappers/ace/ace_wchar.h create mode 100644 dep/ACE_wrappers/ace/ace_wchar.inl create mode 100644 dep/ACE_wrappers/ace/checked_iterator.h create mode 100644 dep/ACE_wrappers/ace/codecs.mpb create mode 100644 dep/ACE_wrappers/ace/config-WinCE.h create mode 100644 dep/ACE_wrappers/ace/config-aix-5.x.h create mode 100644 dep/ACE_wrappers/ace/config-all.h create mode 100644 dep/ACE_wrappers/ace/config-borland-common.h create mode 100644 dep/ACE_wrappers/ace/config-cray.h create mode 100644 dep/ACE_wrappers/ace/config-cxx-common.h create mode 100644 dep/ACE_wrappers/ace/config-cygwin32.h create mode 100644 dep/ACE_wrappers/ace/config-doxygen.h create mode 100644 dep/ACE_wrappers/ace/config-freebsd.h create mode 100644 dep/ACE_wrappers/ace/config-g++-common.h create mode 100644 dep/ACE_wrappers/ace/config-ghs-common.h create mode 100644 dep/ACE_wrappers/ace/config-hpux-11.00.h create mode 100644 dep/ACE_wrappers/ace/config-icc-common.h create mode 100644 dep/ACE_wrappers/ace/config-integritySCA.h create mode 100644 dep/ACE_wrappers/ace/config-irix6.5.x-sgic++.h create mode 100644 dep/ACE_wrappers/ace/config-irix6.x-common.h create mode 100644 dep/ACE_wrappers/ace/config-irix6.x-g++.h create mode 100644 dep/ACE_wrappers/ace/config-irix6.x-sgic++.h create mode 100644 dep/ACE_wrappers/ace/config-linux-common.h create mode 100644 dep/ACE_wrappers/ace/config-linux.h create mode 100644 dep/ACE_wrappers/ace/config-lite.h create mode 100644 dep/ACE_wrappers/ace/config-lynxos.h create mode 100644 dep/ACE_wrappers/ace/config-macosx-leopard.h create mode 100644 dep/ACE_wrappers/ace/config-macosx-panther.h create mode 100644 dep/ACE_wrappers/ace/config-macosx-tiger.h create mode 100644 dep/ACE_wrappers/ace/config-macosx.h create mode 100644 dep/ACE_wrappers/ace/config-macros.h create mode 100644 dep/ACE_wrappers/ace/config-minimal.h create mode 100644 dep/ACE_wrappers/ace/config-mvs.h create mode 100644 dep/ACE_wrappers/ace/config-netbsd.h create mode 100644 dep/ACE_wrappers/ace/config-openbsd.h create mode 100644 dep/ACE_wrappers/ace/config-openvms.h create mode 100644 dep/ACE_wrappers/ace/config-pharlap.h create mode 100644 dep/ACE_wrappers/ace/config-posix-nonetworking.h create mode 100644 dep/ACE_wrappers/ace/config-posix.h create mode 100644 dep/ACE_wrappers/ace/config-qnx-neutrino.h create mode 100644 dep/ACE_wrappers/ace/config-qnx-rtp-62x.h create mode 100644 dep/ACE_wrappers/ace/config-qnx-rtp-common.h create mode 100644 dep/ACE_wrappers/ace/config-qnx-rtp-pre62x.h create mode 100644 dep/ACE_wrappers/ace/config-qnx-rtp.h create mode 100644 dep/ACE_wrappers/ace/config-rtems.h create mode 100644 dep/ACE_wrappers/ace/config-sco-5.0.0-nothread.h create mode 100644 dep/ACE_wrappers/ace/config-sco-5.0.0.h create mode 100644 dep/ACE_wrappers/ace/config-suncc-common.h create mode 100644 dep/ACE_wrappers/ace/config-sunos5.10.h create mode 100644 dep/ACE_wrappers/ace/config-sunos5.11.h create mode 100644 dep/ACE_wrappers/ace/config-sunos5.4-g++.h create mode 100644 dep/ACE_wrappers/ace/config-sunos5.4-sunc++-4.x.h create mode 100644 dep/ACE_wrappers/ace/config-sunos5.5.h create mode 100644 dep/ACE_wrappers/ace/config-sunos5.6.h create mode 100644 dep/ACE_wrappers/ace/config-sunos5.7.h create mode 100644 dep/ACE_wrappers/ace/config-sunos5.8.h create mode 100644 dep/ACE_wrappers/ace/config-sunos5.9.h create mode 100644 dep/ACE_wrappers/ace/config-tandem-nsk-mips-v2.h create mode 100644 dep/ACE_wrappers/ace/config-tandem-nsk-mips-v3.h create mode 100644 dep/ACE_wrappers/ace/config-tandem.h create mode 100644 dep/ACE_wrappers/ace/config-tru64.h create mode 100644 dep/ACE_wrappers/ace/config-unixware-7.1.0.h create mode 100644 dep/ACE_wrappers/ace/config-unixware-7.1.0.udk.h create mode 100644 dep/ACE_wrappers/ace/config-visualage.h create mode 100644 dep/ACE_wrappers/ace/config-vxworks.h create mode 100644 dep/ACE_wrappers/ace/config-vxworks5.x.h create mode 100644 dep/ACE_wrappers/ace/config-vxworks6.2.h create mode 100644 dep/ACE_wrappers/ace/config-vxworks6.3.h create mode 100644 dep/ACE_wrappers/ace/config-vxworks6.4.h create mode 100644 dep/ACE_wrappers/ace/config-vxworks6.5.h create mode 100644 dep/ACE_wrappers/ace/config-vxworks6.6.h create mode 100644 dep/ACE_wrappers/ace/config-win32-borland.h create mode 100644 dep/ACE_wrappers/ace/config-win32-common.h create mode 100644 dep/ACE_wrappers/ace/config-win32-dmc.h create mode 100644 dep/ACE_wrappers/ace/config-win32-ghs.h create mode 100644 dep/ACE_wrappers/ace/config-win32-interix.h create mode 100644 dep/ACE_wrappers/ace/config-win32-mingw.h create mode 100644 dep/ACE_wrappers/ace/config-win32-msvc-7.h create mode 100644 dep/ACE_wrappers/ace/config-win32-msvc-8.h create mode 100644 dep/ACE_wrappers/ace/config-win32-msvc-9.h create mode 100644 dep/ACE_wrappers/ace/config-win32-msvc.h create mode 100644 dep/ACE_wrappers/ace/config-win32.h create mode 100644 dep/ACE_wrappers/ace/config.h.in create mode 100644 dep/ACE_wrappers/ace/filecache.mpb create mode 100644 dep/ACE_wrappers/ace/gethrtime.cpp create mode 100644 dep/ACE_wrappers/ace/iosfwd.h create mode 100644 dep/ACE_wrappers/ace/os_include/arpa/os_inet.h create mode 100644 dep/ACE_wrappers/ace/os_include/net/os_if.h create mode 100644 dep/ACE_wrappers/ace/os_include/netinet/os_in.h create mode 100644 dep/ACE_wrappers/ace/os_include/netinet/os_tcp.h create mode 100644 dep/ACE_wrappers/ace/os_include/os_aio.h create mode 100644 dep/ACE_wrappers/ace/os_include/os_assert.h create mode 100644 dep/ACE_wrappers/ace/os_include/os_byteswap.h create mode 100644 dep/ACE_wrappers/ace/os_include/os_complex.h create mode 100644 dep/ACE_wrappers/ace/os_include/os_cpio.h create mode 100644 dep/ACE_wrappers/ace/os_include/os_ctype.h create mode 100644 dep/ACE_wrappers/ace/os_include/os_dirent.h create mode 100644 dep/ACE_wrappers/ace/os_include/os_dlfcn.h create mode 100644 dep/ACE_wrappers/ace/os_include/os_errno.h create mode 100644 dep/ACE_wrappers/ace/os_include/os_fcntl.h create mode 100644 dep/ACE_wrappers/ace/os_include/os_fenv.h create mode 100644 dep/ACE_wrappers/ace/os_include/os_float.h create mode 100644 dep/ACE_wrappers/ace/os_include/os_fmtmsg.h create mode 100644 dep/ACE_wrappers/ace/os_include/os_fnmatch.h create mode 100644 dep/ACE_wrappers/ace/os_include/os_ftw.h create mode 100644 dep/ACE_wrappers/ace/os_include/os_glob.h create mode 100644 dep/ACE_wrappers/ace/os_include/os_grp.h create mode 100644 dep/ACE_wrappers/ace/os_include/os_iconv.h create mode 100644 dep/ACE_wrappers/ace/os_include/os_intrin.h create mode 100644 dep/ACE_wrappers/ace/os_include/os_inttypes.h create mode 100644 dep/ACE_wrappers/ace/os_include/os_iso646.h create mode 100644 dep/ACE_wrappers/ace/os_include/os_kstat.h create mode 100644 dep/ACE_wrappers/ace/os_include/os_langinfo.h create mode 100644 dep/ACE_wrappers/ace/os_include/os_libgen.h create mode 100644 dep/ACE_wrappers/ace/os_include/os_limits.h create mode 100644 dep/ACE_wrappers/ace/os_include/os_local.h create mode 100644 dep/ACE_wrappers/ace/os_include/os_math.h create mode 100644 dep/ACE_wrappers/ace/os_include/os_monetary.h create mode 100644 dep/ACE_wrappers/ace/os_include/os_mqueue.h create mode 100644 dep/ACE_wrappers/ace/os_include/os_ndbm.h create mode 100644 dep/ACE_wrappers/ace/os_include/os_netdb.h create mode 100644 dep/ACE_wrappers/ace/os_include/os_nl_types.h create mode 100644 dep/ACE_wrappers/ace/os_include/os_pdh.h create mode 100644 dep/ACE_wrappers/ace/os_include/os_pdhmsg.h create mode 100644 dep/ACE_wrappers/ace/os_include/os_poll.h create mode 100644 dep/ACE_wrappers/ace/os_include/os_pthread.h create mode 100644 dep/ACE_wrappers/ace/os_include/os_pwd.h create mode 100644 dep/ACE_wrappers/ace/os_include/os_regex.h create mode 100644 dep/ACE_wrappers/ace/os_include/os_sched.h create mode 100644 dep/ACE_wrappers/ace/os_include/os_search.h create mode 100644 dep/ACE_wrappers/ace/os_include/os_semaphore.h create mode 100644 dep/ACE_wrappers/ace/os_include/os_setjmp.h create mode 100644 dep/ACE_wrappers/ace/os_include/os_signal.h create mode 100644 dep/ACE_wrappers/ace/os_include/os_spawn.h create mode 100644 dep/ACE_wrappers/ace/os_include/os_stdarg.h create mode 100644 dep/ACE_wrappers/ace/os_include/os_stdbool.h create mode 100644 dep/ACE_wrappers/ace/os_include/os_stddef.h create mode 100644 dep/ACE_wrappers/ace/os_include/os_stdint.h create mode 100644 dep/ACE_wrappers/ace/os_include/os_stdio.h create mode 100644 dep/ACE_wrappers/ace/os_include/os_stdlib.h create mode 100644 dep/ACE_wrappers/ace/os_include/os_string.h create mode 100644 dep/ACE_wrappers/ace/os_include/os_strings.h create mode 100644 dep/ACE_wrappers/ace/os_include/os_stropts.h create mode 100644 dep/ACE_wrappers/ace/os_include/os_syslog.h create mode 100644 dep/ACE_wrappers/ace/os_include/os_tar.h create mode 100644 dep/ACE_wrappers/ace/os_include/os_termios.h create mode 100644 dep/ACE_wrappers/ace/os_include/os_tgmath.h create mode 100644 dep/ACE_wrappers/ace/os_include/os_time.h create mode 100644 dep/ACE_wrappers/ace/os_include/os_trace.h create mode 100644 dep/ACE_wrappers/ace/os_include/os_ucontext.h create mode 100644 dep/ACE_wrappers/ace/os_include/os_ulimit.h create mode 100644 dep/ACE_wrappers/ace/os_include/os_unistd.h create mode 100644 dep/ACE_wrappers/ace/os_include/os_utime.h create mode 100644 dep/ACE_wrappers/ace/os_include/os_utmpx.h create mode 100644 dep/ACE_wrappers/ace/os_include/os_wchar.h create mode 100644 dep/ACE_wrappers/ace/os_include/os_wctype.h create mode 100644 dep/ACE_wrappers/ace/os_include/os_wordexp.h create mode 100644 dep/ACE_wrappers/ace/os_include/sys/os_ipc.h create mode 100644 dep/ACE_wrappers/ace/os_include/sys/os_loadavg.h create mode 100644 dep/ACE_wrappers/ace/os_include/sys/os_mman.h create mode 100644 dep/ACE_wrappers/ace/os_include/sys/os_msg.h create mode 100644 dep/ACE_wrappers/ace/os_include/sys/os_pstat.h create mode 100644 dep/ACE_wrappers/ace/os_include/sys/os_resource.h create mode 100644 dep/ACE_wrappers/ace/os_include/sys/os_select.h create mode 100644 dep/ACE_wrappers/ace/os_include/sys/os_sem.h create mode 100644 dep/ACE_wrappers/ace/os_include/sys/os_shm.h create mode 100644 dep/ACE_wrappers/ace/os_include/sys/os_socket.h create mode 100644 dep/ACE_wrappers/ace/os_include/sys/os_stat.h create mode 100644 dep/ACE_wrappers/ace/os_include/sys/os_statvfs.h create mode 100644 dep/ACE_wrappers/ace/os_include/sys/os_sysctl.h create mode 100644 dep/ACE_wrappers/ace/os_include/sys/os_sysinfo.h create mode 100644 dep/ACE_wrappers/ace/os_include/sys/os_time.h create mode 100644 dep/ACE_wrappers/ace/os_include/sys/os_timeb.h create mode 100644 dep/ACE_wrappers/ace/os_include/sys/os_times.h create mode 100644 dep/ACE_wrappers/ace/os_include/sys/os_types.h create mode 100644 dep/ACE_wrappers/ace/os_include/sys/os_uio.h create mode 100644 dep/ACE_wrappers/ace/os_include/sys/os_un.h create mode 100644 dep/ACE_wrappers/ace/os_include/sys/os_utsname.h create mode 100644 dep/ACE_wrappers/ace/os_include/sys/os_wait.h create mode 100644 dep/ACE_wrappers/ace/other.mpb create mode 100644 dep/ACE_wrappers/ace/post.h create mode 100644 dep/ACE_wrappers/ace/pre.h create mode 100644 dep/ACE_wrappers/ace/streams.h create mode 100644 dep/ACE_wrappers/ace/svc_export.h create mode 100644 dep/ACE_wrappers/ace/svcconf.mpb create mode 100644 dep/ACE_wrappers/ace/token.mpb create mode 100644 dep/ACE_wrappers/ace/uuid.mpb create mode 100644 dep/ACE_wrappers/aclocal.m4 create mode 100644 dep/ACE_wrappers/configure.ac create mode 100644 dep/ACE_wrappers/m4/ace.m4 create mode 100644 dep/ACE_wrappers/m4/ace_defines.m4 create mode 100644 dep/ACE_wrappers/m4/ace_func.m4 create mode 100644 dep/ACE_wrappers/m4/ace_functions.m4 create mode 100644 dep/ACE_wrappers/m4/ace_headers.m4 create mode 100644 dep/ACE_wrappers/m4/acinclude.m4 create mode 100644 dep/ACE_wrappers/m4/aio.m4 create mode 100644 dep/ACE_wrappers/m4/compiler.m4 create mode 100644 dep/ACE_wrappers/m4/config_h.m4 create mode 100644 dep/ACE_wrappers/m4/pkg.m4 create mode 100644 dep/ACE_wrappers/m4/platform.m4 create mode 100644 dep/ACE_wrappers/m4/subsets.m4 create mode 100644 dep/ACE_wrappers/m4/threads.m4 create mode 100644 dep/ACE_wrappers/m4/tls.m4 create mode 100644 win/VC71/ACE_vc71.vcproj create mode 100644 win/VC80/ACE_vc8.vcproj create mode 100644 win/VC90/ACE_vc9.vcproj diff --git a/6700-670 b/6721-676 similarity index 100% rename from 6700-670 rename to 6721-676 diff --git a/configure.ac b/configure.ac index 7ff4ee43e09..070c7b55d12 100644 --- a/configure.ac +++ b/configure.ac @@ -11,9 +11,6 @@ ## Process this file with autoconf to produce a configure script. ## Prelude, basic settings for Autoconf -# PACKAGE: mangos -# VERSION: 0.12.0 (trunk) -# BUG-REPORT-ADDRESS: mangos-devs@lists.sourceforge.net AC_INIT( [trinitycore], [0.0.1], [devs@trinitycore.org]) AC_CONFIG_SRCDIR([src/shared/Base.cpp]) @@ -274,8 +271,17 @@ AC_CONFIG_FILES([ src/bindings/interface/Makefile ]) +## Configure ACE +AC_CONFIG_SUBDIRS([dep/ACE_wrappers]) + ## Disabled Makefiles, until they are ready for a successful make and # make dist run. +AC_CONFIG_COMMANDS([default],[ + echo "" + echo "Configuration of TrinityCore $PACKAGE_VERSION is now complete." + echo "" + ],[PACKAGE_VERSION=$PACKAGE_VERSION]) + ## Output files. AC_OUTPUT diff --git a/dep/ACE_wrappers/AUTHORS b/dep/ACE_wrappers/AUTHORS new file mode 100644 index 00000000000..3e474e06cc0 --- /dev/null +++ b/dep/ACE_wrappers/AUTHORS @@ -0,0 +1,13 @@ +Douglas C. Schmidt +d.schmidt@vanderbilt.edu + +Professor of Computer Science +Associate Chair of Computer Science and Engineering +Department of Electrical Engineering and Computer Science +Senior Researcher at the Institute for Software Integrated Systems (ISIS) +Vanderbilt University +Nashville, TN 37203 + +www.dre.vanderbilt.edu/~schmidt +TEL: (615) 343-8197 +FAX: (615) 343-7440 diff --git a/dep/ACE_wrappers/COPYING b/dep/ACE_wrappers/COPYING new file mode 100644 index 00000000000..1d96c4905d3 --- /dev/null +++ b/dep/ACE_wrappers/COPYING @@ -0,0 +1,110 @@ + + _________________________________________________________________ + + Copyright and Licensing Information for ACE(TM), TAO(TM), CIAO(TM), and + CoSMIC(TM) + + [1]ACE(TM), [2]TAO(TM), [3]CIAO(TM), and [4]CoSMIC(TM) (henceforth + referred to as "DOC software") are copyrighted by [5]Douglas C. + Schmidt and his [6]research group at [7]Washington University, + [8]University of California, Irvine, and [9]Vanderbilt University, + Copyright (c) 1993-2008, all rights reserved. Since DOC software is + open-source, freely available software, you are free to use, modify, + copy, and distribute--perpetually and irrevocably--the DOC software + source code and object code produced from the source, as well as copy + and distribute modified versions of this software. You must, however, + include this copyright statement along with any code built using DOC + software that you release. No copyright statement needs to be provided + if you just ship binary executables of your software products. + + You can use DOC software in commercial and/or binary software releases + and are under no obligation to redistribute any of your source code + that is built using DOC software. Note, however, that you may not do + anything to the DOC software code, such as copyrighting it yourself or + claiming authorship of the DOC software code, that will prevent DOC + software from being distributed freely using an open-source + development model. You needn't inform anyone that you're using DOC + software in your software, though we encourage you to let [10]us know + so we can promote your project in the [11]DOC software success + stories. + + The [12]ACE, [13]TAO, [14]CIAO, and [15]CoSMIC web sites are + maintained by the [16]DOC Group at the [17]Institute for Software + Integrated Systems (ISIS) and the [18]Center for Distributed Object + Computing of Washington University, St. Louis for the development of + open-source software as part of the open-source software community. + Submissions are provided by the submitter ``as is'' with no warranties + whatsoever, including any warranty of merchantability, noninfringement + of third party intellectual property, or fitness for any particular + purpose. In no event shall the submitter be liable for any direct, + indirect, special, exemplary, punitive, or consequential damages, + including without limitation, lost profits, even if advised of the + possibility of such damages. Likewise, DOC software is provided as is + with no warranties of any kind, including the warranties of design, + merchantability, and fitness for a particular purpose, + noninfringement, or arising from a course of dealing, usage or trade + practice. Washington University, UC Irvine, Vanderbilt University, + their employees, and students shall have no liability with respect to + the infringement of copyrights, trade secrets or any patents by DOC + software or any part thereof. Moreover, in no event will Washington + University, UC Irvine, or Vanderbilt University, their employees, or + students be liable for any lost revenue or profits or other special, + indirect and consequential damages. + + DOC software is provided with no support and without any obligation on + the part of Washington University, UC Irvine, Vanderbilt University, + their employees, or students to assist in its use, correction, + modification, or enhancement. A [19]number of companies around the + world provide commercial support for DOC software, however. + + DOC software is Y2K-compliant, as long as the underlying OS platform + is Y2K-compliant. Likewise, DOC software is compliant with the new US + daylight savings rule passed by Congress as "The Energy Policy Act of + 2005," which established new daylight savings times (DST) rules for + the United States that expand DST as of March 2007. Since DOC software + obtains time/date and calendaring information from operating systems + users will not be affected by the new DST rules as long as they + upgrade their operating systems accordingly. + + The names ACE(TM), TAO(TM), CIAO(TM), CoSMIC(TM), Washington + University, UC Irvine, and Vanderbilt University, may not be used to + endorse or promote products or services derived from this source + without express written permission from Washington University, UC + Irvine, or Vanderbilt University. This license grants no permission to + call products or services derived from this source ACE(TM), TAO(TM), + CIAO(TM), or CoSMIC(TM), nor does it grant permission for the name + Washington University, UC Irvine, or Vanderbilt University to appear + in their names. + + If you have any suggestions, additions, comments, or questions, please + let [20]me know. + + [21]Douglas C. Schmidt + _________________________________________________________________ + + Back to the [22]ACE home page. + +References + + 1. http://www.cs.wustl.edu/~schmidt/ACE.html + 2. http://www.cs.wustl.edu/~schmidt/TAO.html + 3. http://www.dre.vanderbilt.edu/CIAO/ + 4. http://www.dre.vanderbilt.edu/cosmic/ + 5. http://www.dre.vanderbilt.edu/~schmidt/ + 6. http://www.cs.wustl.edu/~schmidt/ACE-members.html + 7. http://www.wustl.edu/ + 8. http://www.uci.edu/ + 9. http://www.vanderbilt.edu/ + 10. mailto:doc_group@cs.wustl.edu + 11. http://www.cs.wustl.edu/~schmidt/ACE-users.html + 12. http://www.cs.wustl.edu/~schmidt/ACE.html + 13. http://www.cs.wustl.edu/~schmidt/TAO.html + 14. http://www.dre.vanderbilt.edu/CIAO/ + 15. http://www.dre.vanderbilt.edu/cosmic/ + 16. http://www.dre.vanderbilt.edu/ + 17. http://www.isis.vanderbilt.edu/ + 18. http://www.cs.wustl.edu/~schmidt/doc-center.html + 19. http://www.cs.wustl.edu/~schmidt/commercial-support.html + 20. mailto:d.schmidt@vanderbilt.edu + 21. http://www.dre.vanderbilt.edu/~schmidt/ + 22. http://www.cs.wustl.edu/ACE.html diff --git a/dep/ACE_wrappers/ChangeLog b/dep/ACE_wrappers/ChangeLog new file mode 100644 index 00000000000..6dc3c9d3436 --- /dev/null +++ b/dep/ACE_wrappers/ChangeLog @@ -0,0 +1,6119 @@ +Mon Sep 15 06:08:04 CDT 2008 Simon Massey + + * ACE version 5.6.6 released. + +Fri Sep 12 21:13:04 UTC 2008 Adam Mitz + + * bin/MakeProjectCreator/config/MPC.cfg: + + Changed how DDS_ROOT is referenced (for OpenDDS support). + +Fri Sep 12 12:56:15 UTC 2008 Johnny Willemsen + + Reverted change below, brakes VMS support + + Tue Sep 9 18:46:15 UTC 2008 Johnny Willemsen + * bin/mwc.pl: + * bin/mpc.pl: + Use FindBin::RealScript to get the real script name, that also + works when we have a symbolic link with a different name to + one of these scripts. This fixes bugzilla 3407 + +Thu Sep 11 14:55:00 UTC 2008 Simon Massey + + * bin/diff-builds.pl + * bin/diff-builds-and-group-fixed-tests-only.sh + + Make revision number appending to new test failures optional. + +Tue Sep 9 18:46:15 UTC 2008 Johnny Willemsen + + * bin/mwc.pl: + * bin/mpc.pl: + Use FindBin::RealScript to get the real script name, that also + works when we have a symbolic link with a different name to + one of these scripts. This fixes bugzilla 3407 + +Tue Sep 9 14:05:00 UTC 2008 Simon Massey + + * bin/diff-builds-and-group-fixed-tests-only.sh + Change the sort to cater from revision numbers. + +Tue Sep 9 13:39:00 UTC 2008 Simon Massey + + * bin/diff-builds.pl + typo vi / non-vi edit + +Tue Sep 9 13:35:00 UTC 2008 Simon Massey + + * bin/diff-builds.pl + Adjust for revision numbers. + +Tue Sep 9 11:36:15 UTC 2008 Johnny Willemsen + + * ace/OS_NS_time.cpp (strptime_emulation): + Clear the struct tm before filling it. Without we get a random + value back if the user doesn't use a full date. + +Tue Sep 9 11:31:15 UTC 2008 Johnny Willemsen + + * bin/MakeProjectCreator/modules/VXTestProjectCreator.pm: + * bin/MakeProjectCreator/templates/vxtest.mpd: + Also generate a vxtest file for libraries + +Thu Sep 4 14:39:33 UTC 2008 Ciju John + + * bin/diff-builds-and-group-fixed-tests-only.sh: + '-P' isn't a valid option on Ubantu linux (Bug 15051). Replacing + with Perl alternate. + +Wed Sep 3 10:23:15 UTC 2008 Johnny Willemsen + + * bin/tao_other_tests.lst: + Don't run OBV Typed events with micro and compact configurations + +Wed Sep 3 07:31:15 UTC 2008 Johnny Willemsen + + * bin/PerlACE/ProcessVX_Unix.pm: + * bin/PerlACE/ProcessVX_Win32.pm: + Added support for ACE_RUN_VX_TGTSRV_WORKINGDIR. Before starting + the executable we will do a chdir to this directory when it + is specified + +Wed Sep 3 07:10:15 UTC 2008 Johnny Willemsen + + * tests/Bound_Ptr_Test.cpp: + Don't use ACE_ASSERT, it is disabled in release mode and this test + had some real functionality placed within an ACE_ASSERT. This fixes + bugzilla 3415 + +Tue Sep 2 14:11:15 UTC 2008 Johnny Willemsen + + * bin/MakeProjectCreator/config/acedefaults.mpb: + Don't use ACE_LIB_TEXT but ACE_TEXT, the former has been deprecated + a long time ago + +Thu Aug 28 21:18:11 UTC 2008 Adam Mitz + + * bin/tao_orb_tests.lst: + * bin/tao_other_tests.lst: + + Removed "Exceptions" and "NO_EXCEPTIONS" as -Config options. + +Thu Aug 28 18:33:15 UTC 2008 Johnny Willemsen + + * bin/PerlACE/ProcessVX_Unix.pm: + * bin/PerlACE/ProcessVX_Win32.pm: + Improved prompt matching + +Thu Aug 28 13:04:15 UTC 2008 Johnny Willemsen + + * bin/auto_run_tests.pl: + The error when we can't chdir to a directory was confusing + + * bin/PerlACE/ProcessVX.pm: + * bin/PerlACE/ProcessVX_Unix.pm: + * bin/PerlACE/ProcessVX_Win32.pm: + Reduced duplicate code and added support for ACE_RUN_VX_STARTUP_SCRIPT + and ACE_RUN_VX_STARTUP_SCRIPT_ROOT with which we can specify a + startup script that is executed before the real application is started + + * bin/PerlACE/TestTarget_VxWorks.pm: + A VxWorks target has to be rebooted between tests + +Mon Aug 25 11:15:15 UTC 2008 Johnny Willemsen + + * bin/tao_other_tests.lst: + Added missing run_test.pl to the OBV/Typed_Events test + +Thu Aug 21 09:38:15 UTC 2008 Johnny Willemsen + + * docs/Download.html: + Added OpenSuSE build services as new rpm download location. + Removed ACE-install.sh reference, it is not part of the + archive anymore + +Thu Aug 21 06:54:15 UTC 2008 Johnny Willemsen + + * bin/MakeProjectCreator/templates/gnu.mpd: + Also check /usr/lib64 for the libs + + * bin/depgen.pl: + * bin/mpc.pl: + * bin/mwc.pl: + * bin/PerlACE/ConfigList.pm: + * bin/PerlACE/MSProject.pm: + * bin/PerlACE/Process.pm: + * bin/PerlACE/Process_Unix.pm: + * bin/PerlACE/Process_VMS.pm: + * bin/PerlACE/Process_Win32.pm: + * bin/PerlACE/ProcessLVRT.pm: + * bin/PerlACE/ProcessVX.pm: + * bin/PerlACE/ProcessVX_Unix.pm: + * bin/PerlACE/ProcessVX_Win32.pm: + * bin/PerlACE/Run_Test.pm: + * bin/PerlACE/TestTarget.pm: + * bin/PerlACE/TestTarget_LVRT.pm: + * bin/PerlACE/TestTarget_VxWorks.pm: + * bin/Uniqueid.pm: + Added missing shebang lines to fix rpm packaging warnings + +Wed Aug 20 09:38:15 UTC 2008 Johnny Willemsen + + * bin/MakeProjectCreator/modules/BorlandProjectCreator.pm: + * bin/MMakeProjectCreator/modules/BorlandWorkspaceCreator.pm: + Fixed bugzilla 3403. Migrated parts of the bmake type to this + generator, fixes issues when we need to go a directory up + in the workspace. As side effect the resulting Makefile.bor + is smaller in size which reduces the full size of the + distribution. In the near future I want to remove the borland + MPC generator and only use bmake. + +Wed Aug 20 09:08:15 UTC 2008 Johnny Willemsen + + * bin/PerlACE/ProcessVX_Unix.pm: + * bin/PerlACE/ProcessVX_Win32.pm: + Fixed a bug with putenv with rtp mode + +Tue Aug 19 19:06:15 UTC 2008 Johnny Willemsen + + * bin/PerlACE/ProcessVX_Unix.pm: + * bin/PerlACE/ProcessVX_Win32.pm: + Don't use cmd to send commands through telnet. The disadvantage + of the cmd method is that it only returns when the prompt + appears again. When this doesn't happen we don't get the output + of the last command into our build log or on the telnet client + +Tue Aug 19 14:01:15 UTC 2008 Johnny Willemsen + + * ace/config-win32-borland.h: + * ace/OS_NS_stdlib.inl: + * ace/config-win32-msvc.h: + CodeGear C++ Builder 2009 has wcstoull and strtoull + +Mon Aug 18 11:30:15 UTC 2008 Johnny Willemsen + + * ace/config-win32-borland.h: + CodeGear C++ Builder 2009 doesn't support inline assembly + +Mon Aug 18 10:17:15 UTC 2008 Johnny Willemsen + + * ACE-INSTALL.html: + Improved BCB instructions + +Sun Aug 17 18:04:15 UTC 2008 Johnny Willemsen + + * ACE-INSTALL.html: + * include/makeinclude/compiler.bor: + Added BCBVER 10/11/12 + +Sun Aug 17 07:30:15 UTC 2008 Johnny Willemsen + + * bin/mwc.pl: + * bin/mpc.pl: + Use RealBin to get the location of this script, that gives the + real location also in case we use a symbolic link to these + scripts. Thanks to Adam Mitz for pointing me to RealBin + +Fri Aug 15 11:07:00 UTC 2008 Simon Massey + + * make/makeinclude/platform_aix_ibm.GNU: + Added missing AIX compiler version 0800. + +Wed Aug 13 14:40:15 UTC 2008 Johnny Willemsen + + * ace/Truncate.h: + Added missing specializations for Borland C++. + +Wed Aug 13 14:18:15 UTC 2008 Johnny Willemsen + + * m4/ace_defines.m4: + * m4/ace_functions.m4: + * m4/ace_headers.m4: + Reverted change below, doesn't work on suse 11.1 yet + +Wed Aug 13 13:22:15 UTC 2008 Johnny Willemsen + + * m4/ace_defines.m4: + * m4/ace_functions.m4: + * m4/ace_headers.m4: + Updated these files to work with autoconf 2.62. Thanks to + Philipp Thomas for these patches. These + are needed to use autoconf on OpenSuSE Factory (11.1 beta). + This fixes bugzilla 3396. + +Wed Aug 13 11:55:15 UTC 2008 Johnny Willemsen + + * ace/Truncate.h: + Added missing specializations for Borland C++. + +Wed Aug 13 11:44:15 UTC 2008 Johnny Willemsen + + * rpmbuild/ace-tao-ciao.txt: + Made several improvements to this new spec file. Thanks to + Philipp Thomas for assisting with this + +Tue Aug 12 19:45:16 UTC 2008 Jeff Parsons + + * ace/Time_Value.inl: + * examples/OS/Process/process.cpp: + * examples/Misc/test_dump.h: + * examples/ASX/Event_Server/Event_Server/Supplier_Router.cpp: + * examples/ASX/Event_Server/Event_Server/Event_Analyzer.cpp: + * examples/ASX/Event_Server/Event_Server/Consumer_Router.cpp: + * examples/ASX/Message_Queue/buffer_stream.cpp: + * examples/ASX/Message_Queue/bounded_buffer.cpp: + * examples/ASX/Message_Queue/priority_buffer.cpp: + * examples/ASX/UPIPE_Event_Server/Supplier_Router.cpp: + * examples/ASX/UPIPE_Event_Server/Event_Analyzer.cpp: + * examples/ASX/UPIPE_Event_Server/event_server.cpp: + * examples/ASX/UPIPE_Event_Server/Consumer_Router.cpp: + * examples/Web_Crawler/Iterators.cpp: + * examples/Web_Crawler/URL_Visitor.cpp: + * examples/Web_Crawler/Mem_Map_Stream.cpp: + * examples/Shared_Malloc/test_malloc.cpp: + * examples/QOS/Simple/Sender_QoS_Event_Handler.cpp: + * examples/APG/ThreadPools/TP_Reactor.cpp: + * examples/IPC_SAP/FILE_SAP/client.cpp: + * examples/IPC_SAP/SOCK_SAP/CPP-inclient.cpp: + * examples/IPC_SAP/SPIPE_SAP/NPClient.cpp: + * examples/IPC_SAP/SSL_SAP/SSL-server-fancy.cpp: + * examples/IPC_SAP/SSL_SAP/SSL-client-simple.cpp: + * examples/IPC_SAP/SSL_SAP/SSL-client.cpp: + * examples/IPC_SAP/FIFO_SAP/FIFO-client.cpp: + * examples/Logger/client/logging_app.cpp: + * examples/Service_Configurator/IPC-tests/client/remote_stream_client_test.cpp: + * examples/Threads/thread_pool.cpp: + * examples/Threads/thread_specific.cpp: + * examples/Threads/task_four.cpp: + * examples/Reactor/Multicast/Log_Wrapper.cpp: + * examples/Reactor/WFMO_Reactor/Window_Messages.cpp: + * examples/Reactor/Proactor/test_cancel.cpp: + * examples/Reactor/Proactor/test_proactor.cpp: + * examples/Reactor/Misc/notification.cpp: + * examples/Connection/blocking/SPIPE-connector.cpp: + * examples/Mem_Map/file-reverse/file-reverse.cpp: + * examples/C++NPv1/Logging_Handler.cpp: + * examples/C++NPv1/Logging_Client.cpp: + * examples/C++NPv2/AC_Client_Logging_Daemon.cpp: + * examples/C++NPv2/Reactor_Logging_Server_Adapter.cpp: + * examples/C++NPv2/Client_Logging_Daemon.cpp: + * examples/C++NPv2/Service_Reporter.cpp: + * examples/C++NPv2/Logging_Handler.cpp: + + More truncation warning fixes. + +Tue Aug 12 18:15:08 UTC 2008 James H. Hill + + * docs/ace_guidelines.vsmacros: + + Update the macros file to ingore .xsd files. + + * docs/svn/config: + * docs/svn/svn-prefs.reg: + + Added .aspx files to the configuration preferences. + +Tue Aug 12 08:00:15 UTC 2008 Johnny Willemsen + + * ace/Thread_Manager.cpp: + Revert changes of bugzilla 3391, Thread_Pool_Test does fail + with the change + +Mon Aug 11 18:18:15 UTC 2008 Johnny Willemsen + + * tests/Log_Msg_Test.cpp: + Fixed unicode compile error + +Mon Aug 11 16:09:20 UTC 2008 Adam Mitz + + * bin/tao_orb_tests.lst: + + Exclude TAO/tests/Bug_3068_Regression from single-threaded builds. + +Mon Aug 11 13:49:00 UTC 2008 Simon Massey + + * tests/tests.mpc: + There were still some tests that produce test libraries that were + not updated when acelib was devorced from ace_output project. Such + tests need to either add the dependancy (to place their output in + the standard lib directory) or have "libout = ." to specify the + library to be placed locally in the test directory. + +Mon Aug 11 13:37:15 UTC 2008 Johnny Willemsen + + * ace/Thread_Manager.{h,cpp,inl}: + Make sure we don't miss any already terminated threads when doing + a join. Also made some code more readable, removed ancient AIX + workarounds. This fixes bugzilla 3391. Thanks to + for reporting this + + * ace/Containers_T.{h,cpp}: + Changed dont_remove to a bool + +Mon Aug 11 12:45:15 UTC 2008 Johnny Willemsen + + * ace/OS_NS_stdio.cpp: + Simplified some methods + +Mon Aug 11 08:56:15 UTC 2008 Johnny Willemsen + + * tests/Log_Msg_Test.cpp: + Extending testing of ACE_Log_Msg by enabling the format specifiers + tests and add a test for %T. Also removed the check for vsnprintf + to see that VxWorks 5.5.x still has a problem with buffer overflows. + In that case we have to fix that in ACE_Log_Msg. + + * ace/Log_Msg.cpp: + Fixed some buffer size calculations when ACE_TCHAR != char. Fixed + %T when wchar is used, thanks to Nathalie D'Amours + for reporting this. This fixes + bugzilla 3388 + + * ace/ACE.{h,cpp} (timestamp): + Use bool and sizes of buffers should have size_t as type + + * ace/MEM_Stream_Test.cpp: + Removed incorrect comment + +Mon Aug 11 07:36:15 UTC 2008 Johnny Willemsen + + * ace/Makefile.am: + Added missing header files. Thanks to haibin zhang + for reporting this + +Sun Aug 10 23:02:15 UTC 2008 Adam Mitz + + * ace/SSL/SSL_SOCK_Stream.inl (set_handle): + + Reverted back to the C-style cast that was there before Jeff's commit + because many compilers didn't like a reinterpret_cast here. + +Sat Aug 9 17:42:10 UTC 2008 Adam Mitz + + * ace/SSL/SSL_SOCK_Acceptor.cpp: + * ace/SSL/SSL_SOCK_Connector.cpp: + * ace/SSL/SSL_SOCK_Stream.inl: + * ace/SSL/SSL_SOCK_Stream.cpp: + * examples/Service_Configurator/IPC-tests/server/Handle_R_Stream.inl: + + Fixed compile errors in inline=0 and Win32-ssl builds. + ACE_Utils::truncate_cast can't cast ACE_HANDLE to int on Win32. + +Fri Aug 8 20:35:37 UTC 2008 Adam Mitz + + * ace/Stack_Trace.cpp: + + Glibc implementation: fixed whitespace + VxWorks (both kernel and RTP): VxWorks can return -1 for the number + of arguments when the actual number is unknown. + +Fri Aug 8 19:33:42 UTC 2008 Jeff Parsons + + * ace/Message_Queue_T.cpp: + * ace/SSL/SSL_Asynch_BIO.cpp: + * ace/SSL/SSL_SOCK_Acceptor.cpp: + * ace/SSL/SSL_Context.cpp: + * ace/SSL/SSL_Asynch_Stream.cpp: + * ace/SSL/SSL_SOCK_Connector.cpp: + * ace/SSL/SSL_SOCK_Stream.cpp: + * ace/SSL/SSL_SOCK_Stream.inl: + * Kokyu/DSRT_Sched_Queue_T.cpp: + * Kokyu/Default_Dispatcher_Impl.cpp: + * ACEXML/common/Transcode.cpp: + * ACEXML/common/HttpCharStream.cpp: + * ACEXML/common/Mem_Map_Stream.cpp: + * examples/Monitor/MC_Test_Utilities.cpp: + * examples/Service_Configurator/IPC-tests/server/Handle_Timeout.inl: + * examples/Service_Configurator/IPC-tests/server/Handle_Thr_Stream.cpp: + * examples/Service_Configurator/IPC-tests/server/Handle_L_FIFO.inl: + * examples/Service_Configurator/IPC-tests/server/Handle_Broadcast.inl: + * examples/Service_Configurator/IPC-tests/server/Handle_R_Stream.inl: + + Fixes for VC 7.1 warnings, mostly truncation. + +Fri Aug 8 17:58:28 UTC 2008 J.T. Conklin + + * configure.ac: + + Changed the ACE_NEW_THROWS_EXCEPTION feature test to use + setrlimit() (on systems that have it) to reduce the RLIMIT_DATA + limit so the test, which continuously allocates memory in order + to observe the behavior of out-of-memory conditions, will "fail" + quickly without unnecessarily consuming a lot of system + resources. Fixes bugzilla #3090. + +Fri Aug 8 14:42:11 UTC 2008 Johnny Willemsen + + * bin/fuzz.pl: + Also check cpp/inl files for RefCountServantBase + +Fri Aug 8 08:36:11 UTC 2008 Johnny Willemsen + + * ace/Truncate.h: + Added missing specializations for Borland C++. + +Fri Aug 8 08:17:11 UTC 2008 Johnny Willemsen + + * ace/Makefile.am: + Added missing Svc_Conf_Token_Table.h which was already in the MPC + file. Thanks to haibin zhang + for reporting this + +Thu Aug 7 21:59:58 UTC 2008 Adam Mitz + + * bin/tao_orb_tests.lst: + + Added the new test TAO/tests/Bug_3068_Regression. + +Thu Aug 7 20:21:29 UTC 2008 Jeff Parsons + + * ace/Process_Manager.cpp: + * ace/Asynch_IO.cpp: + * ace/Pagefile_Memory_Pool.cpp: + * ace/MEM_IO.cpp: + * ace/Time_Value.inl: + * ace/SV_Semaphore_Simple.cpp: + * ace/Thread_Manager.cpp: + * ace/MEM_IO.inl: + * ace/ETCL/ETCL_Interpreter.cpp: + * ace/UPIPE_Stream.cpp: + * ace/SOCK_Dgram.cpp: + * ace/FILE_IO.cpp: + * ace/OS_NS_unistd.cpp: + * ace/FIFO_Recv_Msg.inl: + * ace/CDR_Size.cpp: + * ace/ACE.cpp: + * ace/CDR_Stream.cpp: + + Added usage of ACE_Utils::truncate_cast<> + to get rid of conversion warnings, mostly from size_t + to ssize_t. + +Thu Aug 7 18:02:11 UTC 2008 Johnny Willemsen + + * NEWS: + ACE/TAO/CIAO now supports CodeGear C++ Builder 2009 + +Thu Aug 7 15:28:13 UTC 2008 Jeff Parsons + + * ace/Monitor_Control/Makefile.am: + + Added source file Null_Network_Interface_Monitor.cpp that + was overlooked until now. + +Wed Aug 6 18:45:11 UTC 2008 Johnny Willemsen + + * ace/ace.mpc: + Added a few missing header files + +Wed Aug 6 18:17:32 UTC 2008 Jeff Parsons + + * protocols/ace/HTBP/HTBP_Channel.cpp: + * ace/SSL/SSL_Asynch_Stream.cpp: + * performance-tests/TCP/tcp_test.cpp: + * performance-tests/UDP/udp_test.cpp: + * tests/Upgradable_RW_Test.cpp: + * tests/ARGV_Test.cpp: + * tests/OrdMultiSet_Test.cpp: + * apps/JAWS/server/HTTP_Server.cpp: + * apps/soreduce/Obj_Module.cpp: + * apps/soreduce/Library.cpp: + * apps/soreduce/soreduce.cpp: + * apps/soreduce/SO_Group.cpp: + * websvcs/lib/URL_Addr.cpp: + * examples/OS/Process/imore.cpp: + * examples/Connection/blocking/SPIPE-connector.cpp: + * examples/C++NPv2/AC_Client_Logging_Daemon.cpp: + * examples/C++NPv2/Client_Logging_Daemon.cpp: + + Cosmetic changes to eliminate warnings from + some Linux compilers. + +Wed Aug 6 13:40:00 UTC 2008 Simon Massey + + * docs/bczar/bczar.html: + Updated the "Bugzilla" section to match the current version + of bugzilla's interface. + +Wed Aug 6 13:01:11 UTC 2008 Johnny Willemsen + + * ace/SOCK_CODgram.cpp: + Fixed gcc 4.3 warnings + +Wed Aug 6 08:49:11 UTC 2008 Johnny Willemsen + + * examples/Connection/blocking/SPIPE-connector.cpp: + * examples/OS/Process/imore.cpp: + Fixed gcc 4.3 warnings + +Wed Aug 6 08:45:11 UTC 2008 Johnny Willemsen + + * examples/C++NPv2/AC_Client_Logging_Daemon.cpp: + * examples/C++NPv2/Client_Logging_Daemon.cpp: + Fixed gcc 4.3 warnings + +Wed Aug 6 08:12:11 UTC 2008 Johnny Willemsen + + * configure.ac: + * m4/ace.m4: + Use more cached values, improved detection of tcl. Add bzip2 + support + +Wed Aug 6 08:01:11 UTC 2008 Johnny Willemsen + + * ACEXML/common/ZipCharStream.cpp: + Fixed compile error in some builds + + * ACEXML/parser/parser/Parser.cpp: + Check for the dtd file using a / and \ path specifier. This + makes it possible to also use a / on windows to specify + the path. This fixes bugzilla 3352 + + * ACEXML/common/FileCharStream.h: + Doxygen fix + + * ACEXML/common/FileCharStream.cpp: + No need to check for a valid pointer before calling delete + +Tue Aug 5 19:33:26 2008 Steve Huston + + * ace/Log_Msg.cpp: Fixed tab characters. + + * ace/config-posix.h: Only set ACE_HAS_POSIX_SEM_TIMEOUT if the + _POSIX_TIMEOUTS feature test is not -1 (disabled). Fixes build + on HP-UX 11iv3. + + * examples/APG/ThreadPools/LF_ThreadPool.cpp (elect_new_leader): Log + the "Resiging and Electing" message at LM_DEBUG severity, not + LM_ERROR. This is on APG page 342. Thanks to Julien Vintrou for + pointing this out. + + * THANKS: Added Julien Vintrou. + +Tue Aug 5 20:19:28 UTC 2008 Steve Huston + + * ace/config-linux-common.h: Removed ACE_HAS_BROKEN_THREAD_KEYFREE. + Reverts change from + Thu Aug 9 13:39:12 UTC 2007 Johnny Willemsen + which is no longer needed. + +Tue Aug 5 18:51:02 UTC 2008 Jeff Parsons + + * ace/MMAP_Memory_Pool.cpp: + * ace/Service_Manager.cpp: + * ace/Stream.cpp: + * Kokyu/Dispatcher_Task.cpp: + * apps/gperf/src/List_Node.cpp: + * apps/gperf/src/Key_List.cpp: + * apps/gperf/src/Gen_Perf.cpp: + * apps/gperf/src/Iterator.cpp: + * apps/gperf/src/Hash_Table.cpp: + * ACEXML/common/ZipCharStream.cpp: + * ACEXML/common/HttpCharStream.cpp: + * ACEXML/parser/parser/Parser.inl: + * ASNMP/asnmp/asn1.cpp: + * ASNMP/asnmp/address.cpp: + + Cosmetic changes to eliminate warnings on + Fedora Rawhide. + +Tue Aug 5 18:37:11 UTC 2008 Johnny Willemsen + + * rpmbuild/ace-tao-init-fedora.tar.bz2: + * rpmbuild/ace-tao-init-suse.tar.bz2: + Seperated distribution specific files in two bz2 archives, + the rpm spec file will use one of them + +Tue Aug 5 16:41:03 UTC 2008 Steve Huston + + * ace/Log_Msg.h: Changed key_created_ from int to bool. + + * ace/Log_Msg.cpp (close): Two changes related to Bugzilla 2980: + - Remove the #if ACE_HAS_BROKEN_THREAD_KEYFREE - the code inside + that block was what should always be done - delete the ACE_Log_Msg + instance and reset the TSS value to 0 so it's not cleaned up again + later when the thread runs down. The whole idea of the + ACE_HAS_BROKEN_THREAD_KEYFREE seems dubious and should probably be + removed, but I haven't gone that far - there's one more use in + OS_NS_Thread which seems pertinent for LynxOS and I can't test + it, so it's still there - but should be reviewed and probably + removed. + - Free the TSS key - if setting key_created_ to 0, what's the point + of leaving the key? Any future attempt to get the per-thread value + would result in a new key being created. Again, freeing the key + has no affect on already-allocated instances. + This should resolve Bugzilla 2980 again. + +Tue Aug 5 14:33:11 UTC 2008 Johnny Willemsen + + * rpmbuild/ace-tao-ciao.txt: + Spec file that is work in progress. Didn't use spec as extension + because that gives problems with rpmbuild. + +Tue Aug 5 13:52:11 UTC 2008 Johnny Willemsen + + * ace/Guard_T.h: + * ace/Guard_T.inl: + * ace/TSS_T.cpp: + Changed block to a bool + + * ace/Guard_T.h: + Initialise owner_ to solve gcc 4.3 warnings + +Tue Aug 05 10:15:00 UTC 2008 Simon Massey + + * tests/Reactor_Remove_Resume_Test_Dev_Poll.cpp: + + I don't know why removing "TP_Reactor.h" stopped ACE.h from + being included; but is seems it was incidently included in + the previous (non-Dev_Poll) test. + +Tue Aug 5 08:02:11 UTC 2008 Johnny Willemsen + + * ACEXML/common/HttpCharStream.cpp: + Fixed gcc4.3 warning + +Tue Aug 5 07:53:11 UTC 2008 Johnny Willemsen + + * tests/Message_Queue_Test.cpp: + * tests/Message_Queue_Test_Ex.cpp: + Fixed gcc4.3 warning + +Tue Aug 5 07:11:11 UTC 2008 Johnny Willemsen + + * examples/IPC_SAP/SOCK_SAP/run_test + * examples/IPC_SAP/SOCK_SAP/summarize + * examples/IPC_SAP/SSL_SAP/summarize + * examples/IPC_SAP/SOCK_SAP/run_test.sh + * examples/IPC_SAP/SOCK_SAP/summarize.pl + * examples/IPC_SAP/SSL_SAP/summarize.pl + Renamed files to have an extension that matches the type of file + +Tue Aug 5 06:45:11 UTC 2008 Johnny Willemsen + + * bin/add_rel_link.sh: + Added missing path + +Mon Aug 4 19:58:20 UTC 2008 Steve Huston + + * ace/Process.cpp (inherit_environment): Re using Unicode from + Thu Jul 31 15:10:16 UTC 2008 Adam Mitz + only do it for systems that have ACE_HAS_WCHAR. Fixes a LabVIEW + Pharlap ETS build issue. + +Mon Aug 04 13:08:00 UTC 2008 Simon Massey + + * tests/Reactor_Remove_Resume_Test.cpp: + * tests/Reactor_Remove_Resume_Test_Dev_Poll.cpp: + * tests/run_test.lst: + * tests/tests.mpc: + + Split out the ACE_Dev_Poll_Reactor part of this test since + this is excersing a known problem with ACE_Dev_Poll_Reactor + (see Bugzilla 3178). + +Mon Aug 4 07:20:12 UTC 2008 Johnny Willemsen + + * ace/config-g++-common.h: + * ace/config-macros.h: + Moved definition of ACE_UNUSED_ARG for GC back to config-macros.h else + it isn't available when doing an autoconf build + +Fri Aug 1 10:59:55 UTC 2008 Adam Mitz + + * tests/Process_Env_Test.cpp: + + #ifdef-out the helper functions in the cases where the body of + run_main is also #ifdef'ed-out. + +Thu Jul 31 15:10:16 UTC 2008 Adam Mitz + + * ace/Process.cpp (inherit_environment): + + When "use_unicode_environment" is in effect, use the unicode env + block (GetEnvironmentStringsW) when copying the current environment + in order to inherit it (Win32 only). + + * tests/Process_Env_Test.cpp: + + Extended this test to verify that a large environment block is indeed + inherited by the spawned process. + +Thu Jul 31 13:16:00 UTC 2008 Simon Massey + + * bin/tao_orb_tests.lst: + + The QUICK test alternatives should have the same configs as + their non-quick alternative tests. This has been playing havok + with !Win32 tests on windows platforms that are using QUICK. + +Thu Jul 31 12:35:00 UTC 2008 Simon Massey + + * tests/run_test.lst: + * tests/tests.mpc: + * tests/Refcounted_Event_Handler_Test_DevPoll.cpp: + * tests/Reference_Counted_Event_Handler_Test_Dev_Poll.cpp: + + Test renamed (has to be less than 38 characters). + +Thu Jul 31 10:25:12 UTC 2008 Johnny Willemsen + + * ace/config-g++-common.h: + Use a different ACE_UNUSED_ARG macro for GCC 4.2 and newer. Moved + also the definition for gcc to this file instead of config-macros.h. + Thanks to Jules Colding , Jonathan Brannan + , and Ken Sedgwick + for providing the patches. This fixes bugzilla 3270 + + * ace/config-macros.h: + Don't define ACE_UNUSED_ARG for GCC + + * rpmbuild/ace-tao.spec: + Removed unused arg patch + + * rpmbuild/ace-tao-unusedarg.patch: + Removed, not needed anymore + +Thu Jul 31 10:20:00 UTC 2008 Simon Massey + + * tests/Reactor_Dispatch_Order_Test_Dev_Poll.cpp: + + To avoid warnings on platforms where: + #if defined (ACE_HAS_DEV_POLL) || defined (ACE_HAS_EVENT_POLL) + is false, this test has now been fully guarded and an alternate + main provided. + + * tests/Reference_Counted_Event_Handler_Test_Dev_Poll.cpp: + * tests/run_test.lst: + * tests/tests.mpc: + + Since the collated test scores are actually grouping both runs + of the original test together (they ignore parameters apparently), + a newly named test was needed. + +Thu Jul 31 10:05:12 UTC 2008 Johnny Willemsen + + * ace/config-macros.h: + Only define ACE_UNUSED_ARG when it is not defined yet. Makes it + easier to test how to resolve warnings with gcc 4.3 + +Wed Jul 30 14:03:12 UTC 2008 Johnny Willemsen + + * include/makeinclude/platform_vxworks6.2.GNU: + * include/makeinclude/platform_vxworks6.3.GNU: + Also convert slashes in HOST_ROOT + +Wed Jul 30 09:55:00 UTC 2008 Simon Massey + + * tests/tests.mpc: + + Missed adding the new Reactor_Dispatch_Order_Test_Dev_Poll + entry. + +Tue Jul 29 22:23:08 UTC 2008 J.T. Conklin + + * m4/ace.m4: + + Add ACE_PATH_BZIP2 feature test, sets ACE_BZIP2_CPPFLAGS, + ACE_BZIP2_LDFLAGS, and ACE_BZIP2_LIBS as needed when + --with-bzip2 is specified on the command line. + +Tue Jul 29 21:33:14 UTC 2008 J.T. Conklin + + * bin/MakeProjectCreator/config/automake.features: + + Add bzip2=1 + +Tue Jul 29 21:29:43 UTC 2008 J.T. Conklin + + * bin/MakeProjectCreator/config/ace_bzip2.mpb: + + New file, overrides definitions from MPC's bzip2.mpb for + automake build. + +Tue Jul 29 19:58:22 UTC 2008 Adam Mitz + + * bin/tao_orb_tests.lst: + + Reverted Tue Jul 29 14:21:32 UTC 2008 Adam Mitz + because the bug should now be fixed in TAO. + +Tue Jul 29 18:11:32 UTC 2008 Johnny Willemsen + + * bin/tao_orb_tests.lst: + TAO/tests/Bug_3000_Regression fails because that issue remains + unresolved, added !FIXED_BUGS_ONLY. + +Tue Jul 29 14:21:32 UTC 2008 Adam Mitz + + * bin/tao_orb_tests.lst: + + TAO/tests/Bug_3163_Regression fails because that issue remains + unresolved, added !FIXED_BUGS_ONLY. + +Tue Jul 29 12:45:00 UTC 2008 Simon Massey + + * tests/run_test.lst: + * tests/Reference_Counted_Event_Handler_Test.cpp: + + Corrected the disabling of ACE_Dev_Poll_Reactor test and split + the test into two runs once with this reactor test disabled + and once with just this reactor test enabled (marked with + !FIXED_BUGS_ONLY) due to internal problems with + ACE_Dev_Poll_Reactor. + +Tue Jul 29 12:14:00 UTC 2008 Simon Massey + + * tests/run_test.lst: + * tests/Reactor_Dispatch_Order_Test.cpp: + * tests/Reactor_Dispatch_Order_Test_Dev_Poll.cpp: + + These tests now actually return a failure if the test failed + instead of always returning 0. I have also split out the + problematic part of this test re-enabled by: + Wed Jul 9 19:07:24 2008 Steve Huston which itself reversed: + Sat Mar 29 08:16:57 UTC 2008 Johnny Willemsen that originally + disabled testing for ACE_Dev_Poll_Reactor due to internal + problems with ACE_Dev_Poll_Reactor. + +Mon Jul 28 13:39:13 2008 Johnny Willemsen + + * ace/config-macros.h: + * ace/streams.h: + Removed workarounds for ancient Borland C++ versions + +Mon Jul 28 13:32:13 2008 Johnny Willemsen + + * ace/Asynch_Acceptor.cpp: + * ace/WIN32_Asynch_IO.cpp: + Removed compiler checks + + * ace/OS_NS_stdio.cpp: + Don't check for Borland C++ but for ACE_HAS_NONCONST_FDOPEN + + * ace/OS_NS_stdio.inl: + Removed workaround for Borland C++ + +Mon Jul 28 13:10:13 2008 Johnny Willemsen + + * ace/Global_Macros.h: + Removed obsolete workaround for Borland C++ + +Mon Jul 28 13:03:13 2008 Johnny Willemsen + + * ace/ace_wchar.h: + Removed obsolete workaround for Borland C++ + +Mon Jul 28 11:52:13 2008 Johnny Willemsen + + * ace/Registry.cpp: + Don't declare a static object within a method because that + could lead to race conditions in a multi threaded program + + * ace/ace_qt4reactor.mpc: + Fixed bug in this file + +Mon Jul 28 11:40:13 2008 Johnny Willemsen + + * ace/ETCL/ETCL_Interpreter.h: + Doxygen fixes and made destructor virtual, this is a base class + + * ace/INET_Addr.cpp: + Const change + +Fri Jul 25 14:21:13 2008 Johnny Willemsen + + * ace/ace_qtreactor.mpc: + * ace/ace_qt3reactor.mpc: + Renamed qt to qt3, this builds and links the qtreactor + with qt3 + + * ace/ace_qt4reactor.mpc: + New project for qt4 + + You can set qt=1 and qt3=1 together or set qt4=1, but not + both at the same time. Thanks to Kees van Marle + for testing qt4 + +Fri Jul 25 14:13:13 2008 Johnny Willemsen + + * ace/QtReactor/QtReactor.cpp: + * ace/QtReactor/QtReactor.h: + Improved qt4 support + +Fri Jul 25 14:09:13 2008 Johnny Willemsen + + * bin/MakeProjectCreator/config/ace_qt3.mpb + * bin/MakeProjectCreator/config/ace_qt4.mpb + * bin/MakeProjectCreator/config/global.features: + Set qt3 and qt4 default to 0. qt4 has different libs + that we need to link with but also the qglobal.h is + located on a different location, so added ACE_HAS_QT4 + which is then used to select which qglobal.h we include. + + * bin/MakeProjectCreator/config/ace_qtreactor.mpb: + This is for qt3 so derive from ace_qt3 + +Thu Jul 24 19:04:13 2008 Steve Huston + + * ace/Containers_T.h: Improved documentation for ACE_DLList, noting + especially that T pointers inserted into the list are not deleted + when removed. Thank you to Bob Fiske for this improvement and sample + code to illustrate. + + * THANKS: Added Bob Fiske. + +Thu Jul 24 12:50:00 UTC 2008 Simon Massey + + * bin/diff-builds-and-group-fixed-tests-only.sh: + This shell script runs the perl diff-builds.pl script between + the date given as the first parameter and the current utc date. + The output is tidied up and any !FIXED_BUGS_ONLY bugs are + removed before being grouped and the failed tests counted. + +Thu Jul 24 08:10:00 UTC 2008 Simon Massey + + * bin/tao_orb_tests.lst: + * bin/tao_other_tests.lst: + Added config item !FIXED_BUGS_ONLY to tests that highlight + problems that have not yet been fixed. Please remove this + config item once the bugs have actually been fixed, and + include this config item with any newly added tests in the + future that fall into this category. + +Wed Jul 23 13:30:28 UTC 2008 Simon Massey + + * bin/PerlACE/Process_Win32.pm: + Allow named .bat files for windows. + +Wed Jul 23 13:08:28 UTC 2008 Johnny Willemsen + + * bin/generate_doxygen.pl: + * etc/tao_ziop.doxygen: + * html/index.html: + Added TAO ZIOP to the documentation + +Wed Jul 23 10:51:28 UTC 2008 Johnny Willemsen + + * ace/Select_Reactor_Base.h: + Doxygen change + + * ace/Select_Reactor_T.cpp: + * ace/Select_Reactor_T.h: + * ace/TP_Reactor.cpp: + * ace/TP_Reactor.h: + mask_signals should be a bool like in the base class + +Wed Jul 23 08:11:28 UTC 2008 Johnny Willemsen + + * ace/SOCK_Dgram_Mcast.cpp: + Use reentrant get_host_addr. This fixes bugzilla 3368. Thanks to + Yongming Wang for reporting this + +Tue Jul 22 15:02:00 UTC 2008 Simon Massey + + * bin/group_test_stats.sh: + Reverse and sort numerically so that highest number of + failures are listed first. + +Tue Jul 22 13:09:28 UTC 2008 Johnny Willemsen + + * bin/tao_orb_tests.lst: + Added ZIOP test + +Tue Jul 22 11:52:28 UTC 2008 Johnny Willemsen + + * bin/make_release.py: + Don't convert line ending for pdf files + +Tue Jul 22 09:55:28 UTC 2008 Johnny Willemsen + + * bin/MakeProjectCreator/config/global.features: + bzip2 is default disabled + +Tue Jul 22 07:36:28 UTC 2008 Johnny Willemsen + + * ace/CDR_Stream.{h,cpp,inl}: + Added setting for alignment which is needed for ZIOP where we want + to place back the wr_ptr to a previous location. Few const and layout + changes + +Mon Jul 21 13:09:28 UTC 2008 Johnny Willemsen + + * bin/tao_other_tests.lst: + Run nslist tests under vxworks + +Sat Jul 19 19:58:54 UTC 2008 Johnny Willemsen + + * ace/config-macosx-tiger.h: + Make sure we set the correct ACE_SIZEOF_LONG_DOUBLE value. Thanks + to Frank Förster for reporting this + +Thu Jul 17 20:24:11 UTC 2008 Steve Huston + + * ace/OS_NS_sys_socket.inl (recvfrom): For Pharlap ETS, correct for + a situation where recvfrom() returns a good address but an + unexpectedly short length. + +Tue Jul 15 17:29:22 UTC 2008 Jeff Parsons + + * examples/Monitor/Bytes_Sent/bytes_sent.cpp: + * examples/Monitor/Message_Queue_Size/message_queue_size.cpp: + * examples/Monitor/Constraint/constraint.cpp: + * examples/Monitor/CPU_Load/cpu_load.cpp: + * examples/Monitor/Num_Threads/num_threads.cpp: + * examples/Monitor/Group/group.cpp: + * examples/Monitor/Memory_Usage/memory_usage.cpp: + + Changes corresponding to the relocation in + + Tue Jul 15 17:19:14 UTC 2008 Jeff Parsons + +Tue Jul 15 17:19:14 UTC 2008 Jeff Parsons + + * ace/Monitor_Size.cpp: + * ace/Monitor_Control_Types.cpp: + * ace/Monitor_Control_Types.h: + * ace/Monitor_Base.cpp: + * ace/Monitor_Base.h: + * ace/Monitor_Base.inl: + * ace/Monitor_Control/Bytes_Received_Monitor.cpp: + * ace/Monitor_Control/Packets_Received_Monitor.cpp: + * ace/Monitor_Control/CPU_Load_Monitor.cpp: + * ace/Monitor_Control/Monitor_Group.cpp: + * ace/Monitor_Control/Memory_Usage_Monitor.cpp: + * ace/Monitor_Control/Monitor_Query.cpp: + * ace/Monitor_Control/Num_Threads_Monitor.cpp: + * ace/Monitor_Control/Bytes_Sent_Monitor.cpp: + * ace/Monitor_Control/Packets_Sent_Monitor.cpp: + + Relocated the statistics-related values from + Monitor_Base to Monitor_Control_Types. Also + inlined the information type accessor, the + constraint list accessor and the refcounting + methods. + +Tue Jul 15 01:27:54 UTC 2008 Johnny Willemsen + + * ace/config-win32-common.h: + Added pragma comment for iphlpapi.lib. Thanks to Yongming Wang + for reporting this + +Mon Jul 14 12:50:34 UTC 2008 Chad Elliott + + * NEWS: + + Added an entry for my change from Mon Jun 30 12:41:00 UTC 2008. + +Mon Jul 14 12:05:00 UTC 2008 Simon Massey + + * ace/Message_Queue_T.cpp: + + Correct void function dump returns from previous commit of: + Fri Jul 11 08:06:40 UTC 2008 James H. Hill + +Sat Jul 12 12:59:19 UTC 2008 Johnny Willemsen + + * ace/config-borland-common.h: + Removed BCB4 support + + * ace/ACE.cpp: + Const/layout changes + + * ace/Configuration.h: + Doxygen changes + + * ace/Monitor_Base.cpp (retrieve_and_clear): + Use clear_i to prevent deadlocks + + * ace/SOCK_IO.cpp: + Const changes + + * ace/Strategies_T.cpp: + layout changes + +Fri Jul 11 23:48:19 UTC 2008 Johnny Willemsen + + * bin/make_release.py: + Don't exclude the mwc files for vc8. Thanks to Michael Guntli + for reporting + this. This fixes bugzilla 3364 + +Fri Jul 11 14:41:19 UTC 2008 James H. Hill + + * NEWS: + + Updated the NEW file to reflect previous ChangeLog entry. + +Fri Jul 11 08:06:40 UTC 2008 James H. Hill + + * ace/Message_Queue_T.h: + * ace/Message_Queue_T.cpp: + + Implemented the iterator and reverse iterator for the + ACE_Message_Queue_Ex class. + +Wed Jul 9 21:20:13 UTC 2008 Ken Sedgwick + + * rpmbuild/README: + Added basic rpmbuild instructions. + +Wed Jul 9 19:07:24 2008 Steve Huston + + * tests/Reactor_Dispatch_Order_Test.cpp: Reversed this change: + Sat Mar 29 08:16:57 UTC 2008 Johnny Willemsen + which disabled testing for ACE_Dev_Poll_Reactor. Let's see what the + issues are then address and/or disable as needed. + Also fixed a cut/paste error. + +Wed Jul 9 18:37:57 2008 Steve Huston + + * tests/Reference_Counted_Event_Handler_Test.cpp: Enabled test for + Winsock 2 systems; previously only ran the ACE_WFMO_Reactor-based + test for non-Winsock 2 systems, where it is not supported. + +Wed Jul 9 17:45:40 UTC 2008 J.T. Conklin + + * m4/config_h.m4: + + Remove autoheader template for ACE_HAS_NON_BLOCKING_CONNECTS. + + * tests/MT_SOCK_Test.cpp: + + Remove use of ACE_HAS_NON_BLOCKING_CONNECTS feature test macro. + It was removed since ACE no longer supports any systems that + required it. + +Wed Jul 9 16:09:30 UTC 2008 J.T. Conklin + + * m4/config_h.m4: + * configure.ac: + + Remove feature test and autoheader template for + ACE_LACKS_WILDCARD_BIND. + + * ace/Sock_Connect.cpp: + + Remove use of ACE_LACKS_WILDCARD_BIND feature test macro. + + * ace/README: + + Remove ACE_LACKS_WILDCARD_BIND from the list of feature test + macros. It was removed since ACE no longer supports any systems + that required it. + +Wed Jul 9 16:02:32 UTC 2008 J.T. Conklin + + * configure.ac: + + Changed ACE_HAS_SIGVAL_SIGVAL_INT and ACE_HAS_SIGVAL_SIGVAL_PTR + feature tests to use "union sigval" instead of "sigval_t". The + former is what ACE uses; while the latter is a common extension, + it is not in the XPG3 specification. Thanks to Olli Savia. + +Wed Jul 9 14:23:00 UTC 2008 J.T. Conklin + + * ace/README: + + Remove ACE_HAS_TEMPLATE_SPECIALIZATION from list of feature + test macros. + +Wed Jul 9 14:18:26 UTC 2008 J.T. Conklin + + * m4/config_h.m4: + * configure.ac: + + Remove feature test and autoheader template for + ACE_HAS_DLFCN_H_BROKEN_EXTERN_C. + + * ace/os_include/os_dlfcn.h: + + Remove use of ACE_HAS_DLFCN_H_BROKEN_EXTERN_C feature test + macro. + + * ace/README: + + Remove ACE_HAS_DLFCN_H_BROKEN_EXTERN_C from the list of feature + test macros. It was removed since ACE no longer supports any + systems that required it. + +Wed Jul 9 09:20:03 UTC 2008 Olli Savia + + * ace/TTY_IO.h: + * ace/TTY_IO.cpp: + Removed deprecated 'parityenb' member from ACE_TTY_IO::Serial_Params + structure. + + * NEWS: + Added a note about change above. + +Tue Jul 8 21:53:31 UTC 2008 Douglas C. Schmidt + + * ace/Service_Manager.cpp (process_request): Ensure that requests + are processed using the global context, rather than the current + one. Thanks to Michael Doubez for suggesting this fix. + +Tue Jul 8 16:44:24 UTC 2008 J.T. Conklin + + * m4/config_h.m4: + + Remove autoheader template for ACE_HAS_BROKEN_HPUX_TEMPLATES. + + * netsvcs/lib/Server_Logging_Handler_T.cpp: + * netsvcs/lib/Server_Logging_Handler_T.h: + + Remove use of ACE_HAS_BROKEN_HPUX_TEMPLATES feature test macro. + + * ace/README: + + Remove ACE_HAS_BROKEN_HPUX_TEMPLATES from the list of feature + test macros. It was removed since ACE no longer supports any + systems that required it. + +Tue Jul 8 16:41:26 2008 Steve Huston + + * ace/WIN32_Asynch_IO.cpp (ACE_WIN32_Asynch_Write_Stream::write): For + Winsock 2-capable platforms, use WSASend() instead of WriteFile(). + The former performs an order of magnitude faster. Thanks to + Namrata Gandhi for running the Win32 native performance tests. + +Tue Jul 8 16:35:57 UTC 2008 J.T. Conklin + + * m4/config_h.m4: + * configure.ac: + + Remove feature test and autoheader template for + ACE_NEEDS_REGEXPR_H. It is no longer used by ACE. + + * ace/config-unixware-7.1.0.h: + * ace/config-unixware-7.1.0.udk.h: + + Remove the ACE_NEEDS_REGEXPR_H feature test macro definition. + It is no longer used by ACE. + +Tue Jul 8 16:06:46 UTC 2008 J.T. Conklin + + * NEWS: + + Document new --enable-rcsid option for autoconf build. + + * m4/ace.m4: + * m4/config_h.m4: + * m4/platform.m4: + + Add support of a new --enable-rcsid option for the autoconf + build. Previously, compiling RCS IDs into object files was + tightly coupled with the --enable-debug option and was always + disabled for certain operating systems. A separate option allows + the user to select this behavior independently. + +Tue Jul 8 14:41:08 2008 Steve Huston + + * tests/Reference_Counted_Event_Handler_Test.cpp: Fixed test cases + that I accidentally reversed in + Fri Jul 4 20:11:02 UTC 2008 Steve Huston + +Tue Jul 08 06:44:09 MST 2008 Trevor Fields + + * bin/PerlACE/Run_Test.pm: + + Added waitforfileoutput and waitforfileoutput_timed + methods that wait for output to appear in a file. + +Sun Jul 6 19:47:27 UTC 2008 Ken Sedgwick + + * rpmbuild/ace-tao.spec: + Added idl and pidl include files to tao-devel package. + +Sun Jul 6 18:28:58 UTC 2008 Ken Sedgwick + + * rpmbuild/ace-tao.spec: + * rpmbuild/ace-tao-orbsvcs-daemon.patch: + * rpmbuild/ace-tao-config.patch: + Updated for latest DOC Group release (x.6.6). + Tracked libACE_Monitor_Control name change. + Fixed broken patches. + +Fri Jul 4 20:11:02 UTC 2008 Steve Huston + + * ace/config-macros.h: Don't set ACE_HAS_PROCESS_SPAWN for + ACE_HAS_PHARLAP - there's only one process available. + + * ace/Recursive_Thread_Mutex.cpp (get_nesting_level): Add Pharlap ETS + to those platforms without access to the recursion count on a + recursive mutex. + + * tests/run_test.lst: Disable Sendfile_Test on LABVIEW_RT - it lacks + sendfile support. + + * tests/Reference_Counted_Event_Handler_Test.cpp: Replaced ACE_ASSERT + with ACE_ERROR; surrounded naked strings with ACE_TEXT; added a test + option for using ACE_Dev_Poll_Reactor where available. + + * tests/Service_Config_Test.cpp: Replaced ACE_ASSERT with ACE_ERROR. + + * tests/Thread_Pool_Reactor_Resume_Test.cpp: + * tests/Thread_Pool_Reactor_Test.cpp: Add ACE_HAS_PHARLAP to those + platforms that need to scale back the max number of connections + due to limited capacity. + +Thu Jul 3 21:42:54 UTC 2008 J.T. Conklin + + * configure.ac: + + Changed the feature test used for the existance of the sigval_t + type not to define ACE_LACKS_SIGVAL_T if it does not exist. + + However, it is still needed to set the ac_cv_type_sigval_t shell + variable, which is used to decide whether to perform the + ACE_HAS_SIGVAL_SIGVAL_INT and ACE_HAS_SIGVAL_SIGVAL_PTR feature + tests. + + This fixes (the newly reopened) bugzilla #2794. Thanks to Olli + Savi for suggesting taking another look. + +Thu Jul 3 16:38:35 UTC 2008 Chad Elliott + + * bin/MakeProjectCreator/templates/gnu.mpd: + + Added the use of 'postclean' to be used during the realclean + target. + +Wed Jul 2 18:30:15 UTC 2008 Jeff Parsons + + * ace/Monitor_Base.cpp (clear_i): + + Added resize of string array (if applicable) to 0. + + * ace/Monitor_Control/CPU_Load_Monitor.h: + * ace/Monitor_Control/Bytes_Received_Monitor.cpp: + * ace/Monitor_Control/Packets_Received_Monitor.cpp: + * ace/Monitor_Control/Memory_Usage_Monitor.h: + * ace/Monitor_Control/Num_Threads_Monitor.h: + * ace/Monitor_Control/CPU_Load_Monitor.cpp: + * ace/Monitor_Control/Memory_Usage_Monitor.cpp: + * ace/Monitor_Control/Num_Threads_Monitor.cpp: + * ace/Monitor_Control/Bytes_Sent_Monitor.cpp: + * ace/Monitor_Control/Packets_Sent_Monitor.cpp: + + Finished implementation of clear_i() method for all + platforms. + +Wed Jul 2 12:45:53 UTC 2008 Douglas C. Schmidt + + * Updated the COPYING file to make it consistent with what's on the website. + +Wed Jul 02 12:30:00 UTC 2008 Simon Massey + + * ace/Monitor_Control/Solaris_Network_Interface_Monitor.cpp: + + ACE_TEXT () and ACE_TEXT_ALWAYS_CHAR () required here. + +Wed Jul 02 12:05:00 UTC 2008 Simon Massey + + * ace/Framework_Component.cpp: + + Annoying text constant problem in a build. No need for ACE_TEXT() + here. + +Wed Jul 2 11:51:03 UTC 2008 Chad Elliott + + * tests/Makefile.am: + + Added the Process_Env_Test. + +Wed Jul 02 11:40:00 UTC 2008 Simon Massey + + * tests/Process_Env_Test.cpp: + + Annoyingly the ACE_RCSID() macro provides it's own ; + This fixes the "Process_Env_Test.cpp:23: error: extra ';'" error. + +Tue Jul 1 22:47:17 UTC 2008 Steve Huston + + * ace/Process.{h cpp}: Can't define or use the new convert_env_buffer() + method unless ACE_HAS_WCHAR is defined. This extra check is needed + for LabVIEW RT / Pharlap ETS because it purports to be Win32 but + does not have wide-char support. + +Tue Jul 1 14:20:00 UTC 2008 Simon Massey + + * bin/PythonACE/fuzz/check_no_tabs.py: + + Attempt to provide tabs check. + +Tue Jul 1 12:29:34 UTC 2008 Jeff Parsons + + * ace/Monitor_Control/Bytes_Received_Monitor.cpp: + * ace/Monitor_Control/Packets_Received_Monitor.cpp: + * ace/Monitor_Control/Bytes_Sent_Monitor.cpp: + * ace/Monitor_Control/Packets_Sent_Monitor.cpp: + + Cosmetic changes. + +Mon Jun 30 16:50:05 UTC 2008 Chad Elliott + + * ace/Process.h: + + Fixed a misplaced bit of code. + +Mon Jun 30 12:41:00 UTC 2008 Chad Elliott + + * ace/Process.h: + * ace/Process.cpp: + + Added an option to ACE_Process_Options to use a wchar_t environment + buffer instead of char. This is useful only on Windows with + ACE_USES_WCHAR undefined. The benefit of using a wchar_t + environment buffer is that it is not limited to 32kb as a char + environment buffer is. + + In ACE_Process::spawn(), convert the char environment buffer to a + wchar_t environment buffer if specified to do so in the process + options. + + * tests/Process_Env_Test.cpp: + * tests/run_test.lst: + * tests/tests.mpc: + + Added a test for the above feature. + +Fri Jun 27 18:04:52 UTC 2008 Steve Huston + + * include/makeinclude/rules.local.GNU: Removed the first setting of + CLEANUP_OBJS by itself - it was a duplicate of what's done in + CLEANUP_BIN's case, but with possibly an incorrect objext. Prevents + a main executable's object file from being deleted twice and ensures + only valid object file extension is used. Thanks to Howard Finer + for pointing this out. + +Fri Jun 27 16:08:27 UTC 2008 Steve Huston + + * include/makeinclude/rules.local.GNU: Add $(VOBJS) to CLEANUP_OBJS to + be sure all objects that go into a binary are cleaned up. + +Fri Jun 27 15:35:58 UTC 2008 J.T. Conklin + + * bin/MakeProjectCreator/modules/AutomakeWorkspaceHelper.pm: + + Changed TAO_IDLFLAGS to Rename executable from gperf to + ace_gperf. + +Fri Jun 27 14:58:17 UTC 2008 Jeff Parsons + + * ace/Monitor_Control/Solaris_Network_Interface_Monitor.h: + + Changed ACE_CString member to ACE_TString, to accommodate + wchar builds. + +Thu Jun 26 20:41:20 UTC 2008 J.T. Conklin + + * ace/Profile_Timer.cpp: + + Explictly #include "ace/OS_NS_fcntl.h" and "ace/OS_NS_unistd.h" + if ACE_HAS_PRUSAGE_T is defined. These headers are implicitly + #included with inline builds, but are required for builds + where inline has been disabled. + +Thu Jun 26 13:13:16 UTC 2008 Jeff Parsons + + * ace/Monitor_Control_Types.h: + * ace/Monitor_Base.cpp: + * ace/Monitor_Base.h: + * ace/Monitor_Control/Monitor_Group.h: + * ace/Monitor_Control/Monitor_Group.cpp: + + Restored support for string data type in + monitor storage, by moving data types, + members and methods from their original + location in an earlier version of the + Notification Service monitor classes, + to the appropriate locations in ACE. + +Thu Jun 26 02:45:21 UTC 2008 Phil Mesnier + + * THANKS: added Ittehad Shaikh + +Wed Jun 25 15:05:29 UTC 2008 J.T. Conklin + + * apps/gperf/src/Makefile.am: + + Rename executable from gperf to ace_gperf. + +Wed Jun 25 14:59:13 UTC 2008 J.T. Conklin + + * apps/gperf/tests/Makefile.am: + + Re-tabify. + +Wed Jun 25 14:09:52 UTC 2008 Johnny Willemsen + + * rpmbuild/ace-tao-config.patch + Removed ACE_GPERF + + * rpmbuild/ace-tao.spec: + Document changes + + * rpmbuild/ace-tao-gperf-info.patch: + Removed, not needed anymore + +Wed Jun 25 13:29:13 UTC 2008 J.T. Conklin + + * m4/config_h.m4: + * configure.ac: + + Remove feature test and autoheader template for + ACE_HAS_BROKEN_NETBSD_MSYNC. + + * ace/OS_NS_sys_mman.inl: + + Remove the use of the ACE_HAS_BROKEN_NETBSD_MSYNC feature test + macro. It was removed since ACE no longer supports the systems + that required it. + +Wed Jun 25 11:23:00 UTC 2008 Simon Massey + + * ace/Monitor_Control/Bytes_Received_Monitor.cpp: + + Tue Jun 24 11:46:41 UTC 2008 Jeff Parsons committed + Miss-cased ACE_TEXT. + +Wed Jun 25 10:00:00 UTC 2008 Simon Massey + + * bin/fuzz.pl: + + Enhance ACE_TMAIN and ORB_init checks for /* .. */ comments. + +Wed Jun 25 06:58:52 UTC 2008 Johnny Willemsen + + * apps/gperf/gperf.1: + * apps/gperf/gperf.info: + * apps/gperf/gperf.mpc: + * apps/gperf/gperf.texi: + * apps/gperf/ace_gperf.1: + * apps/gperf/ace_gperf.info: + * apps/gperf/ace_gperf.mpc: + * apps/gperf/ace_gperf.texi: + * apps/gperf/gperf/src/gperf.mpc: + * apps/gperf/gperf/tests/gperf_test.mpb: + * apps/gperf/gperf/tests/Makefile.am: + Renamed gperf to ace_gperf to make sure we always get the gperf + from ace, fedora also has a regular gperf package + + * include/makeinclude/platform_vxworks5.5.x.GNU: + * include/makeinclude/platform_vxworks6.2.GNU: + * include/makeinclude/platform_vxworks6.3.GNU: + Updated for gperf rename + + * rpmbuild/ace-tao.spec: + Removed gperf rename which only was done in the rpm package. + This fixes bugzilla 3342 + +Wed Jun 25 05:59:52 UTC 2008 J.T. Conklin + + * include/makeinclude/platform_netbsd.GNU: + + Conditionally set no_hidden_visibility to 1. + +Tue Jun 24 13:52:00 UTC 2008 Simon Massey + + * tests/Bug_2980_Regression_Test.cpp: + * tests/tests.mpc: + + Remove ACE_TMAIN from this test and stop it building on + wide systems (as per original test). The test can not use + ace directly. + +Tue Jun 24 13:30:31 2008 Steve Huston + + * ace/CDR_Stream.h: For ACE_OutputCDR, note that attempting to set a + specific byte order requires ACE_ENABLE_SWAP_ON_WRITE to have any + affect. Thanks to Howard Finer for pointing this out. + +Tue Jun 24 11:46:41 UTC 2008 Jeff Parsons + + * ace/Monitor_Control/Bytes_Received_Monitor.cpp: + * ace/Monitor_Control/Packets_Received_Monitor.cpp: + * ace/Monitor_Control/Bytes_Sent_Monitor.cpp: + * ace/Monitor_Control/Packets_Sent_Monitor.cpp: + + For Solaris and *BSD WChar builds, ACE_TEXT-ified the argument + in the call to the platform-specific base class + constructor. + +Tue Jun 24 11:02:00 UTC 2008 Simon Massey + + * ace/Svc_Conf_Token_Table.h: + + commit generated 3rd file. + Fix the dependancies for FC6_Compact_NoInline build. + +Tue Jun 24 09:45:00 UTC 2008 Simon Massey + + * tests/Bug_2980_Regression_Test.cpp: + * tests/tests.mpc: + + Manually add the ACE_TMAIN code to this test. + +Tue Jun 24 00:03:27 UTC 2008 J.T. Conklin + + * ace/Monitor_Control/BSD_Network_Interface_Monitor.cpp: + * ace/Monitor_Control/BSD_Network_Interface_Monitor.h: + + Changed to fetch current value in constructor, and subtract + that from subsequent values in each update() call. + +Mon Jun 23 15:28:00 UTC 2008 Simon Massey + + * ace/Svc_Conf_y.cpp: + + Fix fuzz errors incorrect ACE_TMAIN/main use; commit generated 2nd. + +Mon Jun 23 15:27:00 UTC 2008 Simon Massey + + * ace/Svc_Conf.y: + + Fix fuzz errors incorrect ACE_TMAIN/main use; commit source 1st. + +Mon Jun 23 13:51:23 UTC 2008 Jeff Parsons + + * ace/Monitor_Control/Windows_Monitor.h: + + Changed class member type from ACE_CString to ACE_TString + to accomondate Unicode builds. + + * ace/Monitor_Control/Windows_Monitor.cpp: + + Removed incorrect use of ACE_TEXT wrapper on a non-literal. + +Mon Jun 23 12:34:35 UTC 2008 Chad Elliott + + * bin/tao_other_tests.lst: + + Added the new Notify Timeout test. + +Mon Jun 23 12:09:26 UTC 2008 Douglas C. Schmidt + + * examples/C++NPv2/display_logfile.cpp: Divided an ACE_TCHAR + string by sizeof (ACE_TCHAR) to get the appropriate size. + Thanks to J.T. for reporting + this. + +Mon Jun 23 11:12:00 UTC 2008 Simon Massey + + * ace/Svc_Conf_y.cpp: + * bin/LabVIEW_RT/labview_test_controller/test.cpp: + * ASNMP/examples/trap/trap.cpp: + * ASNMP/examples/get/get.cpp: + * ASNMP/examples/get/get_async.cpp: + * ASNMP/examples/set/set.cpp: + * ASNMP/examples/next/next.cpp: + * ASNMP/examples/walk/walk.cpp: + * netsvcs/clients/Tokens/mutex/test_mutex.cpp: + * performance-tests/RPC/client.cpp: + * tests/Bug_2980_Regression_Test.cpp: + + Fix fuzz errors incorrect ACE_TMAIN/main use. + +Sun Jun 22 17:23:08 UTC 2008 Jeff Parsons + + * ace/Monitor_Control/CPU_Load_Monitor.cpp: + * ace/Monitor_Control/Memory_Usage_Monitor.cpp: + * ace/Monitor_Control/Num_Threads_Monitor.cpp: + + Fix to clear_i() implementation for these monitors that + compiled only on Windows. + +Fri Jun 20 20:40:50 UTC 2008 Jeff Parsons + + * ace/Monitor_Size.cpp: + * ace/Monitor_Base.cpp: + * ace/Monitor_Base.h: + + Moved stats features from the Notification Service monitor + class to the ACE base class. + + * ace/Monitor_Control/Windows_Multi_Instance_Monitor.cpp: + * ace/Monitor_Control/Linux_Network_Interface_Monitor.cpp: + * ace/Monitor_Control/CPU_Load_Monitor.h: + * ace/Monitor_Control/Bytes_Received_Monitor.cpp: + * ace/Monitor_Control/Windows_Monitor.h: + * ace/Monitor_Control/Packets_Received_Monitor.cpp: + * ace/Monitor_Control/Memory_Usage_Monitor.h: + * ace/Monitor_Control/Monitor_Group.h: + * ace/Monitor_Control/Null_Network_Interface_Monitor.cpp: + * ace/Monitor_Control/BSD_Network_Interface_Monitor.h: + * ace/Monitor_Control/Solaris_Network_Interface_Monitor.h: + * ace/Monitor_Control/Num_Threads_Monitor.h: + * ace/Monitor_Control/Bytes_Sent_Monitor.h: + * ace/Monitor_Control/CPU_Load_Monitor.cpp: + * ace/Monitor_Control/Packets_Sent_Monitor.h: + * ace/Monitor_Control/Windows_Monitor.cpp: + * ace/Monitor_Control/Monitor_Group.cpp: + * ace/Monitor_Control/Memory_Usage_Monitor.cpp: + * ace/Monitor_Control/Linux_Network_Interface_Monitor.h: + * ace/Monitor_Control/Windows_Multi_Instance_Monitor.h: + * ace/Monitor_Control/BSD_Network_Interface_Monitor.cpp: + * ace/Monitor_Control/Bytes_Received_Monitor.h: + * ace/Monitor_Control/Solaris_Network_Interface_Monitor.cpp: + * ace/Monitor_Control/Packets_Received_Monitor.h: + * ace/Monitor_Control/Null_Network_Interface_Monitor.h: + * ace/Monitor_Control/Num_Threads_Monitor.cpp: + * ace/Monitor_Control/Bytes_Sent_Monitor.cpp: + * ace/Monitor_Control/Packets_Sent_Monitor.cpp: + + Implemented overrides of clear_i() for all the OS + monitors. + +Fri Jun 20 20:25:12 UTC 2008 Steve Huston + + * bin/PerlACE/README: Edited to reflect the change in process for + referring to test components. Components are now referred to with + numbers instead of names. + + * bin/PerlACE/TestTarget.pm: In create_target(), warn if the component + is not a number. + + * bin/PerlACE/ProcessLVRT.pm: Don't try to close an undefined Telnet. + + * bin/tao_orb_tests.lst: Removed the LabVIEW_RT disabling on + Bug_2702_Regression, Oneway_Send_Timeouts, and Abstract_Interface. + + * tests/run_test.pl: Changed the target component from "ace" to 1 per + new component referring convention. + +Fri Jun 20 18:40:10 UTC 2008 Chad Elliott + + * bin/PerlACE/Run_Test.pm: + + Removed references to HostProcess and TargetProcess. + + * bin/PerlACE/TestTarget.pm: + * bin/PerlACE/TestTarget_VxWorks.pm: + + Added a new test target for VxWorks. It currently has no reboot + related functionality. + + * bin/PerlACE/TestTarget_LVRT.pm: + + Added the ability to accept multiple files for the DeleteFile + method as unlink does. + + * bin/PerlACE/HostProcess.pm: + * bin/PerlACE/TargetProcess.pm: + + Removed these files. + +Fri Jun 20 15:15:00 UTC 2008 Simon Massey + + * bin/fuzz.pl: + + Small bug in white space compaction. + +Fri Jun 20 14:15:00 UTC 2008 Simon Massey + + * bin/fuzz.pl: + + Enhance ACE_TMAIN check for multi-line detection and remove + detection level for this check. + +Fri Jun 20 12:09:53 UTC 2008 Chad Elliott + + * examples/IPC_SAP/SSL_SAP/SSL-client-simple.cpp: + * examples/IPC_SAP/SSL_SAP/SSL-client.cpp: + + Added static_cast's to avoid warnings from vc8. + +Thu Jun 19 16:21:07 2008 Steve Huston + + * ace/CDR_Base.h: + * ace/CDR_Stream.h: Added a enum to ACE_CDR with the values for + byte ordering specifier. Moved the setting of ACE_CDR_BYTE_ORDER + from CDR_Stream.h to CDR_Base.h so it can be used in the enum. + These make it easier for users to figure out what to do when they + want to force a specific byte ordering. + Also did a little more doxygen cleanup. + +Thu Jun 19 15:11:00 UTC 2008 Simon Massey + + * bin/fuzz.pl: + + Enable ORB_init() 3rd parameter null string check. + +Thu Jun 19 14:11:04 UTC 2008 J.T. Conklin + + * ace/Monitor_Control/BSD_Network_Interface_Monitor.cpp: + + Explicitly #include and for non-inline + builds. + +Wed Jun 18 17:36:34 UTC 2008 Yan Dai + + * ace/Stack_Trace.cpp: + + Moved pragma disable warning directives from inside of function to + outside to take effect. + +Wed Jun 18 17:27:51 2008 Steve Huston + + * ace/CDR_Stream.h: Some doxygen improvements. + +Wed Jun 18 15:36:11 UTC 2008 Phil Mesnier + + * bin/tao_orb_tests.lst: + + Added new run_test scripts for the special variants of the TAO + POA EndpointPolicy test. + +Wed Jun 18 13:20:00 UTC 2008 Simon Massey + + * bin/fuzz.pl: + + Redo check for wide character incompatabilty ORB_init() miss-use. + Caters for multi-line ORB_init. + +Wed Jun 18 12:16:48 UTC 2008 Chad Elliott + + * bin/PerlACE/Run_Test.pm: + + Increase the process start wait time for QNX. + +Wed Jun 18 10:43:20 UTC 2008 Johnny Willemsen + + * include/makeinclude/platform_linux_icc.GNU: + Don't use deprecated options + +Wed Jun 18 09:50:20 UTC 2008 Johnny Willemsen + + * README: + * ACE-INSTALL.html: + Updated + +Tue Jun 17 22:43:20 2008 Steve Huston + + * ace/Reactor.h: Clarify that calling remove_handler() for a signal + handler does not invoke the handler's handle_close() callback. Also + note that this behavior is under debate in Bugzilla #2368. Thanks to + Bill Kendall for calling this to attention. + + * THANKS: Added Bill Kendall. + +Tue Jun 17 15:36:49 UTC 2008 Yan Dai + + * ace/Stack_Trace.cpp: + + Disabled warning C4706 in load_dbghelp_library_if_needed() + and enabled afterwards on windows. + +Tue Jun 17 13:55:00 UTC 2008 Simon Massey + + * bin/fuzz.pl: + + Add check for wide character incompatabilty ORB_init() miss-use. + +Tue Jun 17 12:40:03 UTC 2008 J.T. Conklin + + * ace/Monitor_Control/BSD_Network_Interface_Monitor.cpp: + + Explicitly #include for non-inline builds. + +Tue Jun 17 09:30:00 UTC 2008 Simon Massey + + * apps/JAWS/clients/WebSTONE/src/bench.c: + * apps/JAWS/clients/WebSTONE/src/errexit.c: + * apps/JAWS/clients/WebSTONE/src/genrand.c: + * apps/JAWS/clients/WebSTONE/src/timefunc.c: + * apps/JAWS/clients/WebSTONE/src/webclient.c: + * apps/JAWS/clients/WebSTONE/src/webmaster.c: + + Fuzz errors, Untabify. + +Tue Jun 17 08:13:00 UTC 2008 Simon Massey + + * include/make_include/platform_sunos5_common.GNU: + + Changed default "kstat ?= 1" at Johnny Willemsens request. + +Tue Jun 17 06:42:51 UTC 2008 Yan Dai + + * ace/Stack_Trace.cpp: + + Fixed declared method (determine_starting_frame) never referenced + warning on HP aCC build. + +Mon Jun 16 21:26:05 UTC 2008 Abdullah Sowayan + + * bin/fuzz.pl: + + Enable check_for_tab for all files in the repository. + +Mon Jun 16 21:22:03 UTC 2008 Abdullah Sowayan + + * apps/JAWS/clients/Caching/Local_Locator.cpp: + * apps/JAWS/clients/WebSTONE/src/bench.c: + * apps/JAWS/clients/WebSTONE/src/errexit.c: + * apps/JAWS/clients/WebSTONE/src/genrand.c: + * apps/JAWS/clients/WebSTONE/src/get.c: + * apps/JAWS/clients/WebSTONE/src/gettimeofday.c: + * apps/JAWS/clients/WebSTONE/src/parse_file_list.c: + * apps/JAWS/clients/WebSTONE/src/rexec.c: + * apps/JAWS/clients/WebSTONE/src/statistics.c: + * apps/JAWS/clients/WebSTONE/src/sysdep.c: + * apps/JAWS/clients/WebSTONE/src/timefunc.c: + * apps/drwho/Hash_Table.cpp: + + Untabify. + +Mon Jun 16 20:24:45 UTC 2008 Abdullah Sowayan + + * apps/Gateway/Gateway/Connection_Handler.cpp: + * apps/Gateway/Gateway/Event_Forwarding_Discriminator.cpp: + * apps/Gateway/Peer/Options.cpp: + * apps/JAWS/clients/Blobby/Options.cpp: + * apps/JAWS/clients/Blobby/blobby.cpp: + * apps/JAWS/clients/Caching/ID_Generator.cpp: + * apps/JAWS/clients/Caching/Local_Locator.cpp: + * apps/JAWS/clients/Caching/Locator_Request_Reply.cpp: + * apps/JAWS/clients/Caching/URL_Properties.inl: + * apps/JAWS/clients/WebSTONE/src/bench.c: + * apps/JAWS/clients/WebSTONE/src/cgi-send.c: + * apps/JAWS/clients/WebSTONE/src/get.c: + * apps/JAWS/clients/WebSTONE/src/getopt.c: + * apps/JAWS/clients/WebSTONE/src/nsapi-send.c: + * apps/JAWS/server/HTTP_Config.cpp: + * apps/JAWS/server/HTTP_Handler.cpp: + * apps/JAWS/server/HTTP_Helpers.cpp: + * apps/JAWS/server/HTTP_Response.cpp: + * apps/JAWS/server/HTTP_Server.h: + * apps/JAWS/server/HTTP_Server.cpp: + * apps/JAWS/stress_testing/benchd.cpp: + * apps/JAWS/stress_testing/connection.cpp: + * apps/JAWS/stress_testing/http_tester.cpp: + * apps/JAWS2/JAWS/Cache_Hash_T.h: + * apps/JAWS2/JAWS/Hash_Bucket_T.h: + * apps/drwho/File_Manager.cpp: + * apps/drwho/Hash_Table.cpp: + * apps/drwho/PMC_All.cpp: + * apps/drwho/PMC_Flo.cpp: + * apps/drwho/PMC_Ruser.cpp: + * apps/drwho/PMC_Usr.cpp: + * apps/drwho/PMS_Ruser.cpp: + * apps/drwho/PM_Client.cpp: + * apps/drwho/Rwho_DB_Manager.cpp: + * apps/gperf/src/Gen_Perf.cpp: + + Untabify. + +Mon Jun 16 19:06:38 UTC 2008 William R. Otte + + * ace/config-borland-common.h: + * ace/config-hpux-11.00.h: + * ace/config-mvs.h: + * ace/config-win32-dmc.h: + * ace/config-win32-ghs.h: + * ace/config-win32-msvc.h: + + Fixes for MCPP preprocessing on Windows. + +Mon Jun 16 19:06:44 UTC 2008 Chad Elliott + + * ace/Acceptor.cpp: + * ace/Connector.cpp: + * ace/Strategies_T.cpp: + + Use the NORMAL_CLOSE_OPERATION enum value when closing the service + handler during activation. + +Mon Jun 16 18:33:34 UTC 2008 Abdullah Sowayan + + * examples/ASX/UPIPE_Event_Server/Peer_Router.cpp: + * examples/OS/Process/imore.cpp: + * examples/Reactor/Proactor/test_proactor3.cpp: + * examples/Service_Configurator/IPC-tests/server/Handle_R_Stream.cpp: + + Untabify. + +Mon Jun 16 18:00:26 UTC 2008 Abdullah Sowayan + + * ASNMP/examples/get/get.cpp: + * ASNMP/examples/get/get_async.cpp: + * ASNMP/examples/next/next.cpp: + * ASNMP/examples/set/set.cpp: + + Untabify. + +Mon Jun 16 17:53:00 UTC 2008 Abdullah Sowayan + + * examples/IPC_SAP/SPIPE_SAP/consumer_msg.cpp: + * examples/IPC_SAP/SPIPE_SAP/consumer_read.cpp: + * examples/IPC_SAP/TLI_SAP/db-client.cpp: + * examples/Log_Msg/Log_Msg_MFC/Log_Msg_MFC.h: + * examples/Log_Msg/Log_Msg_MFC/Log_Msg_MFCDlg.h: + * examples/Log_Msg/Log_Msg_MFC/StdAfx.h: + * examples/Log_Msg/Log_Msg_MFC/StdAfx.cpp: + * examples/Service_Configurator/IPC-tests/server/Handle_L_Dgram.inl: + + Untabify. + +Mon Jun 16 17:27:36 UTC 2008 Chad Elliott + + * bin/PerlACE/TargetProcess.pm: + + Remove the "use" of PerlACE::ProcessVX. It is already used in + PerlACE::Process and using it in this module causes things to be + evaluated incorrectly with respect to @ARGV. + +Mon Jun 16 17:01:19 UTC 2008 Abdullah Sowayan + + * bin/fuzz.pl: + + Enable check_for_tab check for ACE_ROOT/examples + +Mon Jun 16 16:54:25 UTC 2008 Abdullah Sowayan + + * examples/APG/Logging/Callback-2.h: + * examples/APG/Logging/Callback-3.h: + * examples/APG/Logging/Use_Logger.cpp: + * examples/APG/Threads/Message_Queue.cpp: + * examples/APG/Timers/CB.h: + * examples/APG/Timers/PCB.cpp: + * examples/ASX/CCM_App/SC_Server.cpp: + * examples/ASX/Event_Server/Event_Server/Consumer_Router.cpp: + * examples/ASX/Event_Server/Event_Server/Event_Analyzer.cpp: + * examples/ASX/Event_Server/Event_Server/Peer_Router.cpp: + * examples/ASX/Event_Server/Event_Server/Supplier_Router.cpp: + * examples/ASX/Message_Queue/bounded_buffer.cpp: + * examples/ASX/Message_Queue/priority_buffer.cpp: + * examples/ASX/UPIPE_Event_Server/Peer_Router.cpp: + * examples/Bounded_Packet_Relay/BPR_Drivers.cpp: + * examples/Bounded_Packet_Relay/Thread_Bounded_Packet_Relay.cpp: + * examples/Bounded_Packet_Relay/bpr_thread.cpp: + * examples/C++NPv2/display_logfile.cpp: + * examples/Connection/misc/Connection_Handler.h: + * examples/IPC_SAP/ATM_SAP/CPP-client.cpp: + * examples/IPC_SAP/ATM_SAP/CPP-server.cpp: + * examples/IPC_SAP/DEV_SAP/writer/writer.cpp: + * examples/IPC_SAP/FIFO_SAP/FIFO-Msg-server.cpp: + * examples/IPC_SAP/FIFO_SAP/FIFO-client.cpp: + * examples/IPC_SAP/FIFO_SAP/FIFO-test.cpp: + * examples/IPC_SAP/FILE_SAP/client.cpp: + * examples/IPC_SAP/SOCK_SAP/C-inclient.cpp: + * examples/IPC_SAP/SOCK_SAP/CPP-unclient.cpp: + * examples/IPC_SAP/SPIPE_SAP/NPServer.cpp: + * examples/IPC_SAP/SPIPE_SAP/producer_msg.cpp: + * examples/IPC_SAP/TLI_SAP/CPP-ATM-client.cpp: + * examples/IPC_SAP/TLI_SAP/CPP-ATM-server.cpp: + * examples/IPC_SAP/TLI_SAP/CPP-client.cpp: + * examples/IPC_SAP/TLI_SAP/CPP-server.cpp: + * examples/IPC_SAP/TLI_SAP/db-client.cpp: + * examples/IPC_SAP/TLI_SAP/ftp-client.cpp: + * examples/Log_Msg/Log_Msg_MFC/Log_Msg_MFC.h: + * examples/Log_Msg/Log_Msg_MFC/Log_Msg_MFC.cpp: + * examples/Log_Msg/Log_Msg_MFC/Log_Msg_MFCDlg.h: + * examples/Log_Msg/Log_Msg_MFC/Log_Msg_MFCDlg.cpp: + * examples/Logger/Acceptor-server/server_loggerd.h: + * examples/Logger/Acceptor-server/server_loggerd.cpp: + * examples/Logger/simple-server/Logging_Handler.cpp: + * examples/Logger/simple-server/server_loggerd.cpp: + * examples/Mem_Map/IO-tests/test_io.cpp: + * examples/Misc/test_get_opt.cpp: + * examples/Misc/test_profile_timer.cpp: + * examples/OS/Process/imore.cpp: + * examples/QOS/Change_Receiver_FlowSpec/Receiver_QoS_Event_Handler.cpp: + * examples/Reactor/FIFO/client.cpp: + * examples/Reactor/FIFO/server.cpp: + * examples/Reactor/Misc/notification.cpp: + * examples/Reactor/Misc/test_signals_1.cpp: + * examples/Reactor/Misc/test_signals_2.cpp: + * examples/Reactor/Ntalker/ntalker.cpp: + * examples/Reactor/Proactor/test_cancel.h: + * examples/Reactor/Proactor/test_cancel.cpp: + * examples/Reactor/Proactor/test_multiple_loops.cpp: + * examples/Reactor/Proactor/test_proactor3.cpp: + * examples/Reactor/Proactor/test_timeout.cpp: + * examples/Reactor/Proactor/test_timeout_st.cpp: + * examples/Registry/test_registry_update.cpp: + * examples/Service_Configurator/IPC-tests/client/broadcast_client_test.cpp: + * examples/Service_Configurator/IPC-tests/client/local_dgram_client_test.cpp: + * examples/Service_Configurator/IPC-tests/client/local_pipe_client_test.cpp: + * examples/Service_Configurator/IPC-tests/client/local_stream_client_test.cpp: + * examples/Service_Configurator/IPC-tests/server/Handle_L_CODgram.inl: + * examples/Service_Configurator/IPC-tests/server/Handle_L_Dgram.inl: + * examples/Service_Configurator/IPC-tests/server/Handle_L_FIFO.inl: + * examples/Service_Configurator/IPC-tests/server/Handle_L_Pipe.inl: + * examples/Service_Configurator/IPC-tests/server/Handle_L_SPIPE.inl: + * examples/Service_Configurator/IPC-tests/server/Handle_L_Stream.inl: + * examples/Service_Configurator/IPC-tests/server/Handle_R_Dgram.inl: + * examples/Service_Configurator/IPC-tests/server/Handle_Thr_Stream.cpp: + * examples/Service_Configurator/Misc/Timer_Service.cpp: + * examples/Shared_Memory/test_SV.cpp: + * examples/System_V_IPC/SV_Message_Queues/TMQ_Client.cpp: + * examples/Threads/recursive_mutex.cpp: + * examples/Threads/task_one.cpp: + * examples/Threads/thread_manager.cpp: + * examples/Threads/token.cpp: + + Untabify. + +Mon Jun 16 16:04:40 2008 Steve Huston + + * bin/PerlACE/TestTarget.pm: When getting the exe subdir for a + target, pick up the command line setting if the "default" target + is in use. This should fix the broken exesubdir TAO builds. + +Mon Jun 16 15:45:45 UTC 2008 Jeff Parsons + + * ace/Monitor_Control/Null_Network_Interface_Monitor.cpp: + * ace/Monitor_Control/Null_Network_Interface_Monitor.h: + + New files, defining a base class for tne network interface OS + monitors when the monitor framework itself is enabled but no + platform-specific OS monitor flags are defined, whether because + the platform itself does not support native system-level + monitoring, or because the Linux, Windows or Solaris OS + monitor flags has been turned off for some reason. + + * ace/Monitor_Control/Monitor_Control.mpc: + * ace/Monitor_Control/Bytes_Sent_Monitor.h: + * ace/Monitor_Control/Packets_Sent_Monitor.h: + * ace/Monitor_Control/Linux_Network_Interface_Monitor.h: + * ace/Monitor_Control/Bytes_Received_Monitor.h: + * ace/Monitor_Control/Packets_Received_Monitor.h: + + Incorporated the new no-op network interface monitor base class + into the existing network interface monitor classes. If this + new base class is used, the monitor's value will always be 0, + and its update() method will be a no-op. + +Mon Jun 16 12:12:16 UTC 2008 Jeff Parsons + + * ace/config-sunos5.5.h: + + Reverted addition of ACE_HAS_KSTAT flag in + + Fri Jun 13 14:00:00 UTC 2008 Jeff Parsons + + Thanks to Johnny Willemsen , we now + know that the correct way to do this is to set kstat=1 + in platform_macros.GNU. + +Mon Jun 16 11:28:11 UTC 2008 Abdullah Sowayan + + * bin/fuzz.pl: + + Enable check_for_tab check for TAO/tests/examples and TAO/performance-tests + +Mon Jun 16 10:30:00 UTC 2008 Simon Massey + + * tests/Max_Default_Port_Test.cpp: + + Un-tabify. + +Mon Jun 16 10:20:00 UTC 2008 Simon Massey + + * ace/Monitor_Control/BSD_Network_Interface_Moinitor.cpp: + + Correct Fuzz errors (removed NULL). + +Mon Jun 16 01:01:27 UTC 2008 Abdullah Sowayan + + * bin/fuzz.pl: + + Enable check_for_tab check for TAO/tests + +Sun Jun 15 16:03:29 UTC 2008 Abdullah Sowayan + + * bin/fuzz.pl: + + Enable check_for_tab check for TAO/orbsvcs + +Sun Jun 15 13:23:13 UTC 2008 Johnny Willemsen + + * ace/config-linux-common.h: + Added ACE_LACKS_STRRECVFD when no streams are available (like fc9) + + * rpmbuild/ace-tao-strrecvfd.patch: + Deleted + + * rpmbuild/ace-tao.spec: + Patch 6 is not needed anymore + + * ace/Strategies_T.h: + Doxygen change + +Sun Jun 15 03:08:53 UTC 2008 J.T. Conklin + + * ace/Monitor_Control/Monitor_Control.mpc: + + Add BSD_Network_Interface_Monitor.cpp to Source_Files section. + +Fri Jun 13 14:50:28 UTC 2008 Simon Massey + + Add BSD_Network_Interface_Monitor.cpp and + + untab-ified to remove fuzz errors. + +Fri Jun 13 14:45:28 UTC 2008 Jeff Parsons + + * ace/Monitor_Control/Windows_Multi_Instance_Monitor.cpp: + + Removed unused local variable. + +Fri Jun 13 14:31:35 UTC 2008 Adam Mitz + + * ace/Stack_Trace.cpp (Solaris section): + + Yesterday's addition of support for 64-bit SPARC broke on x86. + +Fri Jun 13 14:00:00 UTC 2008 Jeff Parsons + + * ace/config-sunos5.5.h: + + Added #define of ACE_HAS_KSTAT, used by the OS monitors in + ace/Monitor_Control on Solaris platforms to guard the + visibility of Solaris-specific code and base classes. + +Fri Jun 13 13:40:39 UTC 2008 J.T. Conklin + + * ace/Monitor_Control/Makefile.am: + + Add BSD_Network_Interface_Monitor.cpp and + Solaris_Network_Interface_Monitor.cpp to Headers_File section. + + * ace/Monitor_Control/Bytes_Received_Monitor.cpp: + * ace/Monitor_Control/Bytes_Received_Monitor.h: + * ace/Monitor_Control/Bytes_Sent_Monitor.cpp: + * ace/Monitor_Control/Bytes_Sent_Monitor.h: + * ace/Monitor_Control/Packets_Received_Monitor.cpp: + * ace/Monitor_Control/Packets_Received_Monitor.h: + * ace/Monitor_Control/Packets_Sent_Monitor.cpp: + * ace/Monitor_Control/Packets_Sent_Monitor.h: + + Inherit from BSD_Network_Interface_Monitor on FreeBSD, + NetBSD, and OpenBSD systems. + + * ace/Monitor_Control/BSD_Network_Interface_Monitor.cpp: + * ace/Monitor_Control/BSD_Network_Interface_Monitor.h: + + New files, network interface monitor for systems with 4.4BSD + derived network stack. + +Fri Jun 13 13:24:11 UTC 2008 Jeff Parsons + + * ace/Monitor_Control/Linux_Network_Interface_Monitor.cpp: + * ace/Monitor_Control/Bytes_Received_Monitor.cpp: + * ace/Monitor_Control/Packets_Received_Monitor.cpp: + * ace/Monitor_Control/Bytes_Sent_Monitor.h: + * ace/Monitor_Control/Packets_Sent_Monitor.h: + * ace/Monitor_Control/Linux_Network_Interface_Monitor.h: + * ace/Monitor_Control/Bytes_Received_Monitor.h: + * ace/Monitor_Control/Packets_Received_Monitor.h: + * ace/Monitor_Control/Bytes_Sent_Monitor.cpp: + * ace/Monitor_Control/Packets_Sent_Monitor.cpp: + + Added '|| defined (AIX)' to every occurrence of + '#if defined (linux)' to eliminate build errors on the + latter platform. + +Thu Jun 12 21:57:33 UTC 2008 J.T. Conklin + + * m4/config_h.m4: + * configure.ac: + + Remove feature test for ACE_HAS_TEMPLATE_SPECIALIZATION. + + * ace/config-borland-common.h: + * ace/config-cray.h: + * ace/config-cxx-common.h: + * ace/config-g++-common.h: + * ace/config-hpux-11.00.h: + * ace/config-icc-common.h: + * ace/config-integritySCA.h: + * ace/config-irix6.x-sgic++.h: + * ace/config-mvs.h: + * ace/config-openvms.h: + * ace/config-suncc-common.h: + * ace/config-sunos5.4-sunc++-4.x.h: + * ace/config-sunos5.5.h: + * ace/config-sunos5.6.h: + * ace/config-tandem-nsk-mips-v2.h: + * ace/config-tandem-nsk-mips-v3.h: + * ace/config-tru64.h: + * ace/config-unixware-7.1.0.udk.h: + * ace/config-win32-dmc.h: + * ace/config-win32-ghs.h: + * ace/config-win32-msvc-8.h: + * ace/config-win32-msvc-9.h: + * ace/config-win32-msvc-7.h: + + Remove unused #define of ACE_HAS_TEMPLATE_SPECIALIZATION. This + feature test macro is no longer used. + +Thu Jun 12 18:47:54 UTC 2008 Jeff Parsons + + * ace/Monitor_Control/Solaris_Network_Interface_Monitor.h: + * ace/Monitor_Control/Solaris_Network_Interface_Monitor.cpp: + + New files, containing a base class used with + Bytes_Received_Monitor, Bytes_Sent_Monitor, + Packets_Received_Monitor and Packets_Sent_Monitor + when they are compiled on Solaris platforms. + + * ace/Monitor_Control/Windows_Multi_Instance_Monitor.cpp: + * ace/Monitor_Control/Linux_Network_Interface_Monitor.cpp: + * ace/Monitor_Control/CPU_Load_Monitor.h: + * ace/Monitor_Control/Bytes_Received_Monitor.cpp: + * ace/Monitor_Control/Windows_Monitor.h: + * ace/Monitor_Control/Packets_Received_Monitor.cpp: + * ace/Monitor_Control/Memory_Usage_Monitor.h: + * ace/Monitor_Control/Monitor_Control.mpc: + * ace/Monitor_Control/Num_Threads_Monitor.h: + * ace/Monitor_Control/Bytes_Sent_Monitor.h: + * ace/Monitor_Control/CPU_Load_Monitor.cpp: + * ace/Monitor_Control/Packets_Sent_Monitor.h: + * ace/Monitor_Control/Windows_Monitor.cpp: + * ace/Monitor_Control/Memory_Usage_Monitor.cpp: + * ace/Monitor_Control/Linux_Network_Interface_Monitor.h: + * ace/Monitor_Control/Windows_Multi_Instance_Monitor.h: + * ace/Monitor_Control/Bytes_Received_Monitor.h: + * ace/Monitor_Control/Packets_Received_Monitor.h: + * ace/Monitor_Control/Num_Threads_Monitor.cpp: + * ace/Monitor_Control/Bytes_Sent_Monitor.cpp: + * ace/Monitor_Control/Packets_Sent_Monitor.cpp: + + - Changed required to complete the support of + network interface monitors on Solaris. + + - Changed guards for Windows-specific header file + inclusion to use the recently added ACE_HAS_PDH_H, + which in turn guards the definition of the + ACE_HAS_WIN32_PDH flag used in source code. + + - Changed the names of the platform-specific monitor + update methods to update_i(), from the distinct + names they had before. This changed allowed the + elimination of many #ifdef guards in source code. + +Thu Jun 12 17:42:47 UTC 2008 Steve Huston + + * bin/PerlACE/Process.pm: + * bin/PerlACE/Process_Win32.pm: Moved the Target sub from Process_Win32 + to Process so everybody can see it. Thanks to Chad Elliott for + finding and suggesting the correction for it. + +Thu Jun 12 16:04:33 UTC 2008 Steve Huston + + * bin/tao_orb_tests.lst: Disabled newly added tests on LabVIEW_RT. + + * bin/PerlACE/README: Describes how the ACE+TAO test procedures work. + Includes a description of how to drive the generalized ability to + redirect execution of tests off of the build host. + + * bin/PerlACE/TestTarget.pm: + * bin/PerlACE/TestTarget_LVRT.pm: + * bin/PerlACE/ProcessLVRT.pm: + * bin/PerlACE/Process_Win32.pm: Add the ability to configure various + aspects of ACE+TAO (+CIAO I guess, but haven't tried that) to run + on machines other than the build host and with alternate roots + (ACE_ROOT, TAO_ROOT). This is an effort to generalize the ability + to run off of the build host without adding more switches and options + and convoluted settings and platform-specific code in the main + scripts. The README file explains how to set up modules to extend + testing to other platforms. LabVIEW_RT is the only one there now; + VxWorks is an obvious addition and would allow a bunch of special-case + code to be removed from the main scripts. The test-driving script + does require some change to take advantage of this capability. ACE + tests in ACE_wrappers/tests have the change. A few TAO tests do + (see TAO ChangeLog). Without the changes to the test-driving script + everything behaves as it always did. + + * tests/run_test.pl: Uses the new TestTarget capability, naming the + test target "ace". Thus, to redirect these tests to another machine, + set the DOC_TEST_ACE environment variable with a configuration name + and set configuration variables accordingly. + +Thu Jun 12 14:38:19 UTC 2008 Adam Mitz + + * ace/Stack_Trace.h: + * ace/Stack_Trace.cpp: + + Added support for SPARCv9 (64-bit). + Reverted the Win32 assembly back to the simplest form, we had tried + to make it compatible with Borland but it still didn't work. As of + now ACE compiled by Borland will not generate stack traces. + +Thu Jun 12 12:17:52 UTC 2008 Chad Elliott + + * ace/Stack_Trace.cpp: + + Corrected Win32 assembler compilation error. + +Wed Jun 11 16:24:00 UTC 2008 Phil Mesnier + + * bin/tao_orb_tests.lst: + + Added new test case. + +Wed Jun 11 13:55:00 UTC 2008 Simon Massey + + * ace/Time_Value.inl: + * ace/Time_Value.h: + + Add extra inline void msec(int) that calls void msec(long) + to avoid amiguity between void msec(long) and void msec(_int64 &) + when natual sized integers are given (which seems to be + quite often). + +Wed Jun 11 13:02:22 UTC 2008 Chad Elliott + + * bin/PerlACE/Run_Test.pm: + + Replaced the "use PerlACE::Process". It is necessary to be loaded + inside this module to ensure that all of the command line options + can be processed. + +Wed Jun 11 04:17:42 UTC 2008 J.T. Conklin + + * m4/platform.m4: + + Remove ACE_HAS_AIX_BROKEN_SOCKET_HEADER definitions. + +Wed Jun 11 03:51:32 UTC 2008 J.T. Conklin + + * configure.ac: + * m4/config_h.m4: + + Remove feature test and autoheader template for + ACE_HAS_CHARPTR_SPRINTF. This feature test macro is no longer + used. + +Wed Jun 11 03:39:48 UTC 2008 J.T. Conklin + + * configure.ac: + * m4/config_h.m4: + + Remove feature test and autoheader template for + ACE_LACKS_FLOATING_POINT. This feature test macro is no longer + used. + +Wed Jun 11 03:33:31 UTC 2008 J.T. Conklin + + * configure.ac: + * m4/config_h.m4: + + Remove feature test and autoheader template for + ACE_HAS_TYPENAME_KEYWORD. This feature test macro is no longer + used. + +Wed Jun 11 03:31:02 UTC 2008 J.T. Conklin + + * configure.ac: + * m4/config_h.m4: + + Remove feature test and autoheader template for + ACE_HAS_SPARCWORKS_401_SIGNALS. This feature test macro is no + longer used. + +Wed Jun 11 02:57:12 UTC 2008 J.T. Conklin + + * m4/config_h.m4: + + Remove autoheader template for ACE_HAS_AIX_BROKEN_SOCKET_HEADER. + This feature test macro is no longer used. + +Wed Jun 11 02:52:16 UTC 2008 J.T. Conklin + + * configure.ac: + * m4/config_h.m4: + + Remove feature test and autoheader template for + ACE_SELECT_USES_INT. This feature test macro is no longer used. + +Wed Jun 11 02:48:07 UTC 2008 J.T. Conklin + + * m4/config_h.m4: + + Remove autoheader template for HAVE_RESTARTABLE_SYSCALLS. + This feature test macro is no longer used. + +Wed Jun 11 00:17:01 UTC 2008 J.T. Conklin + + * configure.ac: + * m4/config_h.m4: + + Remove feature test and autoheader template for + ACE_HAS_IRIX_53_SIGNALS. This feature test macro is no longer + used. + +Tue Jun 10 23:57:53 UTC 2008 J.T. Conklin + + * configure.ac: + * m4/config_h.m4: + + Remove feature tests and autoheader templates for + ACE_HAS_STD_TEMPLATE_SPECIALIZATION and + ACE_HAS_STD_TEMPLATE_CLASS_MEMBER_SPECIALIZATION. + These feature test macros are no longer used. + +Tue Jun 10 23:52:19 UTC 2008 J.T. Conklin + + * configure.ac: + * m4/config_h.m4: + + Remove feature test and autoheader template for + ACE_HAS_BROKEN_SAP_ANY. This feature test macro is no longer + used. + +Tue Jun 10 23:49:46 UTC 2008 J.T. Conklin + + * m4/config_h.m4: + + Remove autoheader template for ACE_HAS_BROKEN_NESTED_TEMPLATES. + This feature test macro is no longer used. + +Tue Jun 10 23:47:46 UTC 2008 J.T. Conklin + + * m4/config_h.m4: + + Remove autoheader template for ACE_HAS_SUNOS4_SIGNAL_T. + This feature test macro is no longer used. + +Tue Jun 10 23:45:34 UTC 2008 J.T. Conklin + + * configure.ac: + * m4/config_h.m4: + + Remove feature test and autoheader template for + ACE_HAS_BROKEN_CONDITIONAL_STRING_CAST. This feature test macro + is no longer used. + +Tue Jun 10 23:43:19 UTC 2008 J.T. Conklin + + * configure.ac: + * m4/config_h.m4: + + Remove feature test and autoheader template for + ACE_HAS_BROKEN_CONVERSIONS. This feature test macro is no + longer used. + +Tue Jun 10 23:41:11 UTC 2008 J.T. Conklin + + * configure.ac: + * m4/config_h.m4: + + Remove feature test and autoheader template for + ACE_HAS_BROKEN_NAMESPACES. This feature test macro is no longer + used. + +Tue Jun 10 23:39:09 UTC 2008 J.T. Conklin + + * m4/config_h.m4: + + Remove autoheader template for ACE_HAS_SYSCALL_GETRUSAGE. This + feature test macro is no longer used. + +Tue Jun 10 23:16:31 UTC 2008 J.T. Conklin + + * configure.ac: + * m4/config_h.m4: + + Remove feature test and autoheader template for + ACE_HAS_BROKEN_TIMESPEC_MEMBERS. This feature test macro is no + longer used. + +Tue Jun 10 21:28:23 UTC 2008 J.T. Conklin + + * m4/platform.m4: + + Add ACE_CHECK_GETNAME_RETURNS_RANDOM_SIN_ZERO feature check, + which sets the ACE_GETNAME_RETURNS_RANDOM_SIN_ZERO feature test + macro on Linux systems running kernels older than 2.5.47. This + is a compile time check, like was done in config-linux-common.h, + based on the value of LINUX_VERSION_CODE from . + This means ACE compiled on a newer Linux system but deployed on + an older one could result in run-time failures. + + Fixes Bugzilla #3132. + +Tue Jun 10 21:33:25 UTC 2008 Jeff Parsons + + * ace/CDR_Stream.h: + * ace/CDR_Stream.cpp: + + Replaced a Monitor class forward declaration with the full file + include, moved from the source file to the header file. This + move enables ACE monitor points to compile when inlining is + turned on. + +Tue Jun 10 18:46:24 UTC 2008 Yan Dai + + * ace/Stack_Trace.h: + + Updated comments to not exclude Borland from supported platforms. + + * ace/Stack_Trace.cpp: + + - Moved the label "x" from inside of asm to be outside. Some compiler + does not like it. + - Enabled LynxOS support and excluded support for gcc old versions before 3.3. + +Tue Jun 10 13:56:17 UTC 2008 Adam Mitz + + * ace/Stack_Trace.cpp: + + One more fix for Win32 wchar. + +Tue Jun 10 13:32:57 UTC 2008 Chad Elliott + + * tests/Bug_2980_Regression_Test.cpp: + + Avoid pointer-to-function and pointer-to-object warnings from g++. + +Tue Jun 10 12:53:05 UTC 2008 Chad Elliott + + * tests/SSL/SSL_Asynch_Stream_Test.cpp: + + Modified to avoid virtual method hiding. + +Tue Jun 10 11:37:09 UTC 2008 Chad Elliott + + * tests/Time_Value_Test.cpp: + + Added a static cast to avoid warnings on QNX. + +Tue Jun 10 10:57:00 UTC 2008 Simon Massey + + * ace/ACE.cpp: + + Correct presidence bug highlighted by FC9_GCC_430 build: + ACE.cpp:1429: warning: suggest parentheses around && within || + ACE.cpp:1665: warning: suggest parentheses around && within || + ACE.cpp:1853: warning: suggest parentheses around && within || + The default precidence is && before ||, but the way the || + statements were grouped, it was clear that was not the intended + resolution. + + Correct empty if statement bug highlighted by FC9_GCC_430 build: + ACE.cpp:2773: warning: suggest braces around empty body in an 'if' statement + + Also removed warnings by using empty braces: + ACE.cpp:3389: warning: suggest a space before ';' or explicit braces around empty body in 'while' statement + ACE.cpp:3414: warning: suggest a space before ';' or explicit braces around empty body in 'while' statement + + +Mon Jun 9 21:38:04 UTC 2008 Yan Dai + + * ace/Stack_Trace.cpp: + + Passed string literals instead of ACE_TEXT string to GetProcAddress as it + accepts LPCSTR which is defined as char*. This should fix wchar (Win32) + build errors. + +Mon Jun 9 20:52:52 2008 Steve Huston + + * ace/Asynch_IO.h: Doxygen improvements. + +Mon Jun 9 19:40:56 UTC 2008 Yan Dai + + * ace/Stack_Trace.h: + * ace/Stack_Trace.cpp: + + Excluded LynxOS, MinGW and Borland builds from stack trace supported + platforms. + +Mon Jun 09 14:46:00 UTC 2008 Simon Massey + + * ace/Stack_Trace.cpp: + * ace/Stack_Trace.h: + + Remove TEXT() and TCHAR Fuzz errors. + +Mon Jun 9 11:26:36 UTC 2008 Chad Elliott + + * ace/ace_for_tao.mpc: + + Added Stack_Trace.cpp since Log_Msg.cpp needs it. + +Mon Jun 09 10:42:00 UTC 2008 Simon Massey + + * ace/NT_Service.cpp: + + unambiguated call to time_value msec(long) at line 437 + caused by new uint64 non-const setter provided by: + Thu Jun 5 14:52:43 UTC 2008 Steve Huston + +Sun Jun 8 18:09:22 UTC 2008 J.T. Conklin + + * m4/platform.m4: + + Add ACE_CHECK_HAS_DLSYM_SEGFAULT_ON_INVALID_HANDLE feature + check, which sets the ACE_HAS_DLSYM_SEGFAULT_ON_INVALID_HANDLE + feature test macro on Linux and OpenBSD systems (as is done in + the canned config-*.h files). Fixes Bugzilla #3141. + +Sat Jun 7 13:56:56 UTC 2008 Chad Elliott + + * ace/Log_Msg.cpp: + + Use ACE_TEXT instead of ACE_LIB_TEXT. + +Sat Jun 7 03:28:01 UTC 2008 Yan Dai + + Merged in stack_trace_branch that added stack trace support. + + * NEWS: + + Add an entry for stack trace support. + + * ace/Log_Msg.h: + + Added comments for "%?". + + * ace/Log_Msg.cpp: + + Added new conversion character, the question mark, which gets + replaced by a stack trace on supported platforms. + + * ace/Stack_Trace.h: + * ace/Stack_Trace.cpp: + + Added new class that, on supported platforms, will take a + snapshot of the current stack when instantiated. + + * ace/ace.mpc: + + Added Stack_Trace in as source. + + * ace/config-macosx-leopard.h: + + Added ACE_HAS_EXECINFO_H define. + + * ace/Makefile.am: + + Added Stack_Trace.h and Stack_Trace.cpp. + + * configure.ac: + + Added checks for execinfo.h header. + + * tests/Stack_Trace_Test.cpp: + + New test. + + * tests/run_test.lst: + * tests/tests.mpc: + + Added Stack_Trace_Test in. + +Fri Jun 6 19:05:14 UTC 2008 Chad Elliott + + * bin/PerlACE/ProcessVX_Unix.pm: + * bin/PerlACE/ProcessVX_Win32.pm: + + Put an eval around the require of Net::Telnet so that these + modules can always be "used", but not necessarily employed. + + * bin/PerlACE/Run_Test.pm: + + Use PerlACE::TargetProcess and PerlACE::HostProcess so that all + test scripts may use them. + + * bin/PerlACE/TargetProcess.pm: + * bin/PerlACE/HostProcess.pm: + + Added modules to simplify the writing of test scripts so that + VxWorks testing can be transparent to the script itself. Having + two packages allows for role reversal (using the -reverse_roles + option to run_test.pl). For example, if you have a test that + consists of a server and a client, the script will look like this: + + $SV = new PerlACE::TargetProcess("server", "-o $iorfile"); + $CL = new PerlACE::HostProcess("client", "-k file://$iorfile"); + + If testing for VxWorks, the server process will be run on the + target and the client process will be run on the host. If the + -reverse_roles option is provided to run_test.pl, the server + process will run on the host and the client process will run on + the target. + +Fri Jun 06 13:00:00 UTC 2008 Simon Massey + + * ace/ACE.cpp: + + untabified. + +Fri Jun 06 11:10:00 UTC 2008 Simon Massey + + * ace/ACE.cpp: + + Added #include ace/OS_NS_fcntl.h to previous commit of + Thu Jun 5 23:46:14 UTC 2008 J.T. Conklin. + +Fri Jun 6 08:31:06 UTC 2008 Vladimir Zykov + + * ace/config-hpux-11.00.h: + According to Steve Huston HP-UX does provide strtoull and + wcstoull but they can be used not as straight forward as + in other compilers. I have no access to HP-UX so I added + corresponding TODO comment about ACE_LACKS_STRTOULL and + ACE_LACKS_WCSTOULL that I added previously. + + * ace/config-vxworks6.2.h: + * ace/config-vxworks6.4.h: + * ace/config-vxworks5.x.h: + * ace/config-vxworks6.3.h: + VxWorks doesn't provide wcstoull as well. + Added ACE_LACKS_WCSTOULL. + +Thu Jun 5 23:46:14 UTC 2008 J.T. Conklin + + * ace/ACE.cpp: + + Changed daemonize() to open /dev/null and duplicate the file + descriptor as descriptors 0, 1, and 2 if it is invoked with the + closed_all_handles flag set. This avoids problems with I/O + to/from stdin, stdout, and stderr; cin, cout, and cerr; + etc. being written to/read from whatever files/sockets/devices + associated with descriptors 0, 1, and 2 when they are reopened. + This fixes Bugzilla #3338. + +Thu Jun 5 16:30:58 2008 Steve Huston + + * NEWS: Added note concerning ACE_Time_Value changes from + Thu Jun 5 14:52:43 UTC 2008 Steve Huston + +Tue Jun 3 13:09:27 UTC 2008 Douglas C. Schmidt + + * ace/OS_main.h (wmain): Added + + ACE_BEGIN_VERSIONED_NAMESPACE_DECL + ACE_END_VERSIONED_NAMESPACE_DECL + + to the ace_wmain_i macro. Thanks to June Fang for reporting this. + +Thu Jun 5 14:52:43 UTC 2008 Steve Huston + + * ace/Time_Value.{h inl}: Added a non-const variant of + void msec(ACE_UINT64&) - this allows the msec(ACE_UINT64&) accessor + to be called on both const and non-const objects without error. + Fixes Bugzilla #3336. Thanks to Simon Massey for this idea. + + * tests/Time_Value_Test.cpp: Added a const-checking msec() call and + corrected the test case. + +Thu Jun 05 13:45:00 UTC 2008 Simon Massey + + * ace/Get_Opt.cpp: + * ace/Get_Opt.h: + * ace/Get_Opt.inl: + + As a conveniance in wide character builds allow the + options string to be specified as a standard narrow + string (that is converted internally). This type of + use is littered throughout the TAO code. + + * ace/OS_NS_stdio.cpp: + * ace/OS_NS_stdio.h: + * ace/OS_NS_stdio.inl: + + As a conveniance in wide character builds allow the + fopen() call to have parameters of mixed wide/narrow + type. This type of use is littered throughout the TAO + code. + + * ace/OS_NS_stdlib.inl: + + Correct the mkstemp facades, they were not returning + the modified template string under wide character builds, + this caused the tao_idl compiler to be unable to find + the pre-processed files to rename that it had just created. + + * examples/Log_Msg/Log_Msg_MFC/Log_Msg_MFC.mpc: + * examples/Log_Msg/Log_Msg_MFC/Log_Msg_Unicode_MFC.mpc: + + Deleted the Unicode specific version, normal one suffices + after all. + + * bin/tao_orb_tests.lst: + + Disabled problematic LynxOS test. + +Wed Jun 4 22:45:20 2008 Steve Huston + + * ace/config-pharlap.h: Added ACE_LACKS_FILELLOCKS. My changes from + Mon Apr 28 21:53:23 UTC 2008 Steve Huston + exposed a call to LockFileEx, which is not present on Pharlap + (and, therefore, not present in LabVIEW RT). The alternate API, + LockFile, is present on Pharlap but documented as unsupported. + Since the OS doesn't do multiple processes, there are more effective + ways to synchronize that file locks anyway. + +Wed Jun 4 20:59:16 UTC 2008 Ciju John + + * ace/SSL/SSL_Context.cpp: + Fix for Bug 3337. ::SSL_add_dir_cert_subjects_to_stack() isn't + ready for Windows. + +Wed Jun 4 17:12:10 UTC 2008 J.T. Conklin + + * ace/ACE.cpp (timestamp): + + Make sure to divide sizeof timebuf by sizeof (ACE_TCHAR) to + avoid buffer overflow. This is another instance of the same + problem fixed in: + + Mon Jun 2 15:26:57 UTC 2008 Douglas C. Schmidt + +Wed Jun 4 16:05:54 UTC 2008 Steve Huston + + * tests/Time_Value_Test.cpp: Added a test case for Bugzilla #3336 + as reported by Aaron Scamehorn. + +Wed Jun 4 14:36:55 UTC 2008 Jeff Parsons + + * ace/Monitor_Point_Registry.cpp: + * ace/Monitor_Base.cpp: + + Disabled warning messages reporting an unsuccessful unbind + of a monitor from the monitor point registry. In some + cases, it appears that the default process reactor singleton + is destroyed before the monitor point registry. The reactor + has an associated ACE_Message_Queue, which in turn has an + associated monitor. Somehow in the destruction of the + singleton, the normal chain of destructor calls, which + would remove the monitor from the registry, is bypassed, + leaving the removal to happen when the registry's + destructor is called and the entry in question is no longer + valid. In any case, this happens only at process shutdown, + and there is no memory leak. Ways to make this happen in + a more friendly fashion are being looked into. + +Tue Jun 3 16:14:39 UTC 2008 Ken Sedgwick + + * rpmbuild/ace-tao.spec: + * rpmbuild/ace-tao-unusedarg.patch: + * rpmbuild/ace-tao-strrecvfd.patch: + + Added ace-tao-strrecvfd.patch (related to bug #3291). + Changed make loop construct to abort when subcomponent fails. + Removed PSS from TAO build list. + Added ace-tao-unusedarg.patch (related to bug #3270). + Made qt3 BuildRequires conditional on Fedora version. + +Mon Jun 2 15:26:57 UTC 2008 Douglas C. Schmidt + + * ace/Log_Record.cpp (format_msg): Make sure to divide sizeof ctp + by sizeof (ACE_TCHAR) to avoid buffer overflow. Thanks to June + Fang for reporting this. + +Sun Jun 1 02:01:38 UTC 2008 Ken Sedgwick + + * rpmbuild/ace-tao.spec: + * rpmbuild/ace-tao-etc.tar.gz: + * rpmbuild/ace-tao-orbsvcs-daemon.patch: + + Added ace-tao-orbsvcs-daemon.patch to workaround + daemonization problems in rpm installed services. + Fixed tao-cosconcurrency command line arguments. + +Fri May 30 13:57:06 UTC 2008 Vladimir Zykov + + * ace/config-vxworks6.2.h: + * ace/config-vxworks6.4.h: + * ace/config-vxworks5.x.h: + * ace/config-vxworks6.3.h: + VxWorks doesn't provide strtoull(). + +Fri May 30 13:48:48 UTC 2008 Vladimir Zykov + + * ace/config-openvms.h: + OpenVMS doesn't provide wcstoull() function. + +Fri May 30 13:37:13 UTC 2008 Vladimir Zykov + + * ace/OS_NS_stdlib.inl: + Fixed MinGW builds. + + * ace/config-cygwin32.h: + Disabled wcstoull() on cygwin since it doesn't provide + such function. + +Fri May 30 13:17:55 UTC 2008 Simon Massey + + * test/INET_Addr_Test_IPV6.cpp: + Resolve Conflict #define INTERFACE with MFC under VC8. + +Fri May 30 10:07:55 UTC 2008 Vladimir Zykov + + * ace/config-win32-borland.h: + Borland compilers doesn't provide strtoull() and wcstoull(). + + * ace/config-sunos5.5.h: + * ace/config-sunos5.10.h: + wcstoull() didn't exist on Solaris until version 10. + + * ace/config-hpux-11.00.h: + HP-UX doesn't provide strtoull() and wcstoull(). + +Thu May 29 16:08:01 UTC 2008 Vladimir Zykov + + * ace/OS_NS_stdlib.cpp: + * ace/OS_NS_stdlib.inl: + * ace/OS_NS_stdlib.h: + + Added strtoull() function to ACE_OS. + + * configure.ac: + + Added a check for presence of strtoull() and wcstoull() + in the build environment. + +Thu May 29 15:15:00 UTC 2008 Simon Massey + + * ace/INET_Addr.cpp: + + Remove tabs to avoid fuzz warning. + +Thu May 29 10:15:00 UTC 2008 Simon Massey + + * tests/Bug_3332_Regression_Test.cpp: + + Remove signed/unsigned comparison warnings. + +Wed May 28 18:13:15 UTC 2008 J.T. Conklin + + * ace/INET_Addr.cpp: + * ace/INET_Addr.h: + + Changed ACE_INET_Addr::get_host_addr(char *, int) to be thread + safe by calling ACE_OS::inet_ntop() instead of + ACE_OS::inet_ntoa(). + + Changed ACE_INET_Addr::get_host_addr(void) to call + INET_Addr::get_host_addr(char *, size) with a static buffer. + + Removed the special cases for VxWorks in both of the above + methods which called inet_ntoa_b() which, according to comments, + was for efficency and thread safety. These are are now as + efficent and thread safe (or not, in the case of ACE_INET_Addr:: + get_host_addr(void)) as any other target platform, but no longer + need a string buffer member in every ACE_INET_Addr instance. + +Wed May 28 13:46:00 UTC 2008 Simon Massey + + * ace/Malloc.h: + Eliminate a warning from some fanicaly builds. + +Wed May 28 08:10:00 UTC 2008 Simon Massey + + * tests/Bug_3332_Regression_Test.cpp: + * tests/Bug_3332_Regression_Test.txt: + * tests/run_test.lst: + * tests/tests.mpc: + + Regression test for the change of: + Fri May 23 12:45:00 UTC 2008 * ace/RB_Tree.cpp. + +Tue May 27 23:10:33 UTC 2008 J.T. Conklin + + * ace/Makefile.am: + + Adding missing template and header files. + +Tue May 27 12:11:07 UTC 2008 Chad Elliott + + * ace/ace.mpc: + + Added missing template and header files. + +Mon May 26 13:54:38 UTC 2008 Olli Savia + + * ace/config-lynxos.h: + Defined ACE_LACKS_POLL_H. + +Mon May 26 07:28:23 UTC 2008 Ken Sedgwick + + * rpmbuild/ace-tao.spec: + Clarified the tao-cosevent and tao-rtevent "Summary" tags. + +Mon May 26 00:31:51 UTC 2008 Ken Sedgwick + + * rpmbuild/ace-tao.spec: + Fixed rpm build error: bad tar extraction command. + +Sun May 25 17:18:20 UTC 2008 Adam Mitz + + * ace/ace.mwc: + + s/MonitorControl/Monitor_Control/ + +Sun May 25 04:11:37 UTC 2008 Ken Sedgwick + + * rpmbuild/ace-tao.spec: + * rpmbuild/ace-tao-rnq.patch: + * rpmbuild/ace-tao-config-tmplvis.patch: + * rpmbuild/ace-tao-hasicmp.patch: + * rpmbuild/ace-tao-obstack.patch: + * rpmbuild/ace-tao-config-ipv6.patch: + Removed ace-tao-obstack.patch, no longer needed. + Converted ace-tao-config-ipv6.patch into conditional rpm script. + Converted ace-tao-rnq.patch into conditional rpm script. + Converted ace-tao-config-tmplvis.patch and ace-tao-hasicmp.patch + into rpm script. + +Sat May 24 19:50:46 UTC 2008 J.T. Conklin + + * bin/MakeProjectCreator/modules/AutomakeWorkspaceHelper.pm: + + Adjust libpaths now that ACE_MonitorControl library has been + renamed to just ACE_Monitor_Control. + +Fri May 23 14:20:48 UTC 2008 J.T. Conklin + + * m4/platform.m4: + + Added *mingw64* case in ACE_SET_PLATFORM_MACROS and + ACE_CHECK_FORMAT_SPECIFIERS feature test macros. + +Fri May 23 12:45:00 UTC 2008 Simon Massey + + * ace/RB_Tree.cpp: + + Enhancement to stop external pointers to retained items being + invalidated upon key deletion. + +Fri May 23 12:14:54 UTC 2008 Jeff Parsons + + * ace/Monitor_Control/Auto_Update_Starter.h: + + Updated filename (which was recently changed) in a comment. + Thanks to Simon Massey for + reporting the fuzz warning. + +Fri May 23 08:14:38 UTC 2008 Olli Savia + + * tests/run_test.lst: + + Run Bug_2980_Regression_Test on LynxOS. + +Fri May 23 00:18:24 UTC 2008 J.T. Conklin + + * ace/Makefile.am: + + Rename MonitorControl subdirectory to Monitor_Control, to + adapt to this change: + + Wed May 21 19:01:10 UTC 2008 Jeff Parsons + +Thu May 22 23:04:38 UTC 2008 J.T. Conklin + + * configure.ac: + + Rename MonitorControl subdirectory to Monitor_Control, to + adapt to this change: + + Wed May 21 19:01:10 UTC 2008 Jeff Parsons + +Thu May 22 19:29:35 UTC 2008 Jeff Parsons + + * ace/Monitor_Base.h (clear): + + Made the method virtual, since it's overridden in the + TAO Notification Service monitors and we are now using + the ACE monitor registry which stores everyhing as the + ACE base class monitor. + +Thu May 22 14:56:10 UTC 2008 Johnny Willemsen + + * bin/PerlACE/ProcessVX_Unix.pm: + * bin/PerlACE/ProcessVX_Win32.pm: + Added support for ACE_RUN_VX_EXE_SUBDIR which can be used when + the vxworks executables are build in a subdirectory + +Thu May 22 09:47:10 UTC 2008 Johnny Willemsen + + * rpmbuild/ace-tao-codeset.patch: + * ace/Codeset_Registry_db.cpp: + Merged patch into the regular registry + + * ace/OS_NS_sys_uio.cpp: + Const change + + * ace/Service_Config.cpp: + Layout change + + * rpmbuild/ace-tao.spec: + Removed codeset patch + +Thu May 22 09:37:10 UTC 2008 Johnny Willemsen + + * rpmbuild/* + New directory with files needed to create rpm's for ACE/TAO. + These files will be improved and we will check whether the + rpm patches can be integrated into the real config files. + Thanks to Ken Sedgwick for + delivering these files. + +Wed May 21 19:01:10 UTC 2008 Jeff Parsons + + * ace/MonitorControl/*: + + Changed directory name to Monitor_Control and renamed all + contained files, classes, libs, MPC projects, ifdef guards, + and macros similarly, to better conform to the ACE style. + + * ace/Monitor_Point_Registry.cpp: + * ace/Monitor_Admin.h: + * ace/Monitor_Admin.cpp: + * bin/MakeProjectCreator/config/ace_mc.mpb: + * examples/Monitor/Bytes_Sent/bytes_sent.cpp: + * examples/Monitor/Bytes_Sent/Makefile.am: + * examples/Monitor/Message_Queue_Size/message_queue_size.cpp: + * examples/Monitor/Message_Queue_Size/Makefile.am: + * examples/Monitor/Constraint/constraint.cpp: + * examples/Monitor/Constraint/Makefile.am: + * examples/Monitor/CPU_Load/cpu_load.cpp: + * examples/Monitor/CPU_Load/Makefile.am: + * examples/Monitor/Num_Threads/Makefile.am: + * examples/Monitor/Num_Threads/num_threads.cpp: + * examples/Monitor/Group/Makefile.am: + * examples/Monitor/Group/group.cpp: + * examples/Monitor/Memory_Usage/Makefile.am: + * examples/Monitor/Memory_Usage/memory_usage.cpp: + + Changes corresponding to the renaming above. + +Wed May 21 14:06:13 UTC 2008 Jeff Parsons + + * ace/Monitor_Base.h: + * ace/Monitor_Base.cpp: + + Made the update() method non pure virtual. + +Tue May 20 19:33:29 UTC 2008 Jeff Parsons + + * ace/Message_Queue_T.cpp: + + Added the stringified process id to the construction of + the message queue size monitor's name, since some tests + were showing that message queues were being created with + the same hex address in different processes. + +Tue May 20 17:55:39 UTC 2008 Chad Elliott + + * ace/Svc_Handler.h: + + Added an enum to be used as flags parameter for close(). + + * ace/Acceptor.cpp: + * ace/Connector.cpp: + * ace/Strategies_T.cpp: + + Use the new enum during the call to close() on the service handler + to indicate the circumstances behind the closure. + + This is part of a set of commits for Bug 2935. + +Tue May 20 09:45:21 UTC 2008 Johnny Willemsen + + * ace/Ping_Socket.{h,cpp}: + Use bool + +Mon May 19 19:26:21 UTC 2008 Johnny Willemsen + + * tests/Log_Msg_Test.cpp: + On VxWorks/LynxOS we didn't test the buffer overflow, but we + shouldn't test this when ACE_LACKS_VSNPRINTF is defined + because it will then fail + +Mon May 19 19:13:21 UTC 2008 Johnny Willemsen + + * ace/Hash_Map_Manager_T.h: + Doxygen change + + * ace/Hash_Map_Manager_T.cpp (shared_find) + Set errno to ENOENT when the size is zero + +Mon May 19 19:08:21 UTC 2008 Johnny Willemsen + + * bin/tao_orb_tests.lst: + Added 2085 and 2243 + +Mon May 19 14:19:21 UTC 2008 Johnny Willemsen + + * docs/bczar/bczar.html: + Updated mailing lists + + * docs/Download.html: + * etc/index.html: + Updated for x.6.5 + + * ace/config-openvms.h: + Removed sock max of 64kb + +Mon May 19 02:53:21 CDT 2008 Johnny Willemsen + + * ACE version 5.6.5 released. + +Fri May 16 10:13:15 UTC 2008 Johnny Willemsen + + Reverted change below, causes problems in the builds + * include/makeinclude/platform_linux.GNU: + Only set DLD and LD when they are not set yet + +Fri May 16 07:50:15 UTC 2008 Johnny Willemsen + + * tests/Based_Pointer_Test.cpp: + Also define a public destructor to silence the gnu warning that + we only have private + +Fri May 16 07:49:15 UTC 2008 Johnny Willemsen + + * examples/Monitor/Num_Threads/num_threads.cpp: + Fixed compile errors when monitoring framework is disabled + +Fri May 16 07:41:15 UTC 2008 Johnny Willemsen + + * examples/APG/Streams/Answerer.cpp: + * examples/APG/Streams/EndTask.h: + Replaced EndTask with TheEndTask to resolve a name conflict + when using MinGW + +Fri May 16 07:18:15 UTC 2008 Johnny Willemsen + + * include/makeinclude/platform_linux.GNU: + * include/makeinclude/platform_linux_common.GNU: + Support lib64 paths to detect certain features. Thanks to Ken + Sedgwick for reporting this + + * include/makeinclude/platform_linux.GNU: + Only set DLD and LD when they are not set yet + +Thu May 15 14:00:15 UTC 2008 Johnny Willemsen + + * ace/Based_Pointer_T.{h,inl}: + * tests/Based_Pointer_Test.cpp: + Fixed bugzilla 3285, make it possible to use + ACE_Based_Pointer. Thanks to Thomas Brownridge + for reporting this. + +Thu May 15 12:36:42 UTC 2008 Phil Mesnier + + * ace/MMAP_Memory_Pool.cpp: + When using a default base address of 0x0 and otherwise wanting + a fixed address, a special flag was used to imply that after the + first address is selected the system in a call to ::mmap() + subsequent calls to ::mmap() reuse the selected base address + as a fixed address. This may cause problems with reloading + persistent data if the stored data contains pointers and the + system selected base address changes from run to run. + + * ace/config-linux-common.h: + The default base address for the x86-64 platform cannot be 0x0. + Doing so causes the system to choose an address which for some + unknown reason causes SEGV errors in Malloc_T. The linux-specific + mmap flag, MAP_32BIT, resolves those segv errors, but on x86-64 + using 0x0 as the default base address on subsequent runs cause + a different assigned base address to be selected. If the data + in the mapped memory contains pointers to mapped memory, those + are then wrong and cause SEGV crashs. By experimentation, it + seems the default base address for powerpc is appropriate for + x86-64. + +Thu May 15 10:19:15 UTC 2008 Johnny Willemsen + + * include/makeinclude/rules.lib.GNU: + Fixed OpenVMS specific part + +Thu May 15 10:17:15 UTC 2008 Johnny Willemsen + + * ace/Unbounded_Set_Ex.cpp: + Fixed bug in the insert method + + * ace/Unbounded_Set_Test.cpp: + Extended this test to reproduce the bug above and replaced all + ACE_ASSERTS with if checks + +Thu May 15 10:05:00 UTC 2008 Simon Massey + + * bin/msvc_mpc_auto_compile.pl: + Split orbsvcs out from ciao build. + +Thu May 15 07:09:15 UTC 2008 Johnny Willemsen + + * ace/ace.mpc: + Added config-win32-msvc9.h, thanks to for + reporting this + +Wed May 14 20:41:17 2008 Steve Huston + + * ace/Thread_Manager.h: Expanded the documentation, particularly for + spawn[_n]. + +Wed May 14 18:30:15 UTC 2008 Johnny Willemsen + + * ace/config-irix6.x-common.h: + * ace/config-linux-common.h: + * ace/config-sunos5.4-g++.h: + * ace/config-sunos5.4-sunc++-4.x.h: + * ace/config-sunos5.5.h: + * ace/config-tandem.h: + * ace/config-unixware-7.1.0.h: + * ace/config-unixware-7.1.0.udk.h: + * ace/MonitorControl/MemoryUsageMonitor.cpp: + * ace/MonitorControl/MemoryUsageMonitor.h: + * ace/OS.inl: + * ace/os_include/os_unistd.h: + * ace/os_include/sys/os_resource.h: + * ace/POSIX_Proactor.cpp: + * ace/configure.ac: + Seems we already had a ACE_HAS_SYSINFO but this is a different + method but with the same name as we use in the monitoring code. + Added ACE_HAS_SYS_SYSTEMINFO_H as new define, renamed the + linux define to ACE_HAS_LINUX_SYSINFO + +Wed May 14 18:14:15 UTC 2008 Johnny Willemsen + + * ace/ACE.cpp: + Layout changes + + * ace/config-vxworks5.x.h: + * ace/OS_NS_unistd.inl: + * ace/Sock_Connect.cpp: + Extended for VxWorks Medusa + + * ace/Logging_Strategy.cpp: + Initialise pointer with 0 + +Wed May 14 14:26:15 UTC 2008 Johnny Willemsen + + * include/makeinclude/platform_vxworks5.5.x.GNU: + Detect medusa pid/pcd/pne + +Wed May 14 12:34:15 UTC 2008 Johnny Willemsen + + * ace/os_include/os_pdhmsg.h: + New file + + * ace/config-win32-common.h: + Added ACE_HAS_PDHMSG_H + + * ace/config-win32-mingw.h: + * ace/config-WinCE.h: + Added ACE_LACKS_PDHMSG_H + + * ace/Makefile.am: + Added new file + + * ace/MonitorControl/WindowsMultiInstanceMonitor.cpp: + Use new os_pdhmsg.h + +Wed May 14 12:24:15 UTC 2008 Johnny Willemsen + + * ace/os_include/os_kstat.h: + * ace/os_include/sys/os_sysinfo.h: + New header files + + * ace/os_include/os_glob.h: + * ace/os_include/sys/os_statvfs.h: + Removed not needed includes + + * configure.ac: + Added check for sysinfo.h + + * ace/config-linux-common.h: + Added ACE_HAS_SYSINFO and ACE_HAS_SYSINFO_H + + * ace/Makefile.am: + Added new files + + * ace/MonitorControl/CPULoadMonitor.h: + * ace/MonitorControl/MemoryUsageMonitor.cpp: + * ace/MonitorControl/MemoryUsageMonitor.h: + Use the new defines and header files + +Wed May 14 10:41:15 UTC 2008 Johnny Willemsen + + * ace/*: + * examples/Monitor/*: + Renamed MonitorControl namespace to Monitor_Control to comply + to ACE coding guidelines + +Wed May 14 09:48:15 UTC 2008 Johnny Willemsen + + * tests/run_test.lst: + Enabled some more tests on vxworks + +Tue May 13 19:20:15 UTC 2008 Johnny Willemsen + + * bin/diff-builds.pl: + Updated for move of test stats + +Mon May 12 12:19:15 UTC 2008 Jeff Parsons + + * examples/Monitor/MC_Test_Utilities.h: + * examples/Monitor/Bytes_Sent/bytes_sent.cpp: + * examples/Monitor/Message_Queue_Size/message_queue_size.cpp: + * examples/Monitor/Constraint/constraint.cpp: + * examples/Monitor/CPU_Load/cpu_load.cpp: + * examples/Monitor/MC_Test_Utilities.cpp: + * examples/Monitor/Group/group.cpp: + * examples/Monitor/Memory_Usage/memory_usage.cpp: + + Added appropriate preprocessor guards to ensure a + successful build when ACE_HAS_MONITOR_FRAMEWORK is + defined as 0. + + * examples/Monitor/Message_Queue_Size/Message_Queue_Size.mpc: + + Removed outdated macro additions from project. + +Fri May 9 18:58:52 UTC 2008 Iliyan Jeliazkov + + * ace/Service_Config.h: + * ace/Service_Config.inl: + * ace/Service_Config.cpp: + * ace/Service_Gestalt.cpp: + + Calling ACE_Service_Config::open() does not correctly initialize + the SC global state (process name, in particular but others + too). Fixing bug#3319. + +Fri May 9 17:58:21 UTC 2008 J.T. Conklin + + * bin/MakeProjectCreator/modules/AutomakeWorkspaceHelper.pm: + + Revert changes of: + Thu May 8 22:13:24 UTC 2008 J.T. Conklin + + Now that ETCL Parser library has been renamed back to + ACE_ETCL_Parser. + +Fri May 9 17:55:39 UTC 2008 J.T. Conklin + + * examples/Monitor/Bytes_Sent/Makefile.am: + * examples/Monitor/Message_Queue_Size/Makefile.am: + * examples/Monitor/Constraint/Makefile.am: + * examples/Monitor/CPU_Load/Makefile.am: + * examples/Monitor/Num_Threads/Makefile.am: + * examples/Monitor/Group/Makefile.am: + * examples/Monitor/Memory_Usage/Makefile.am: + * ace/ETCL/Makefile.am: + * ace/MonitorControl/Makefile.am: + + Regenerated. + +Fri May 9 14:17:11 UTC 2008 William R. Otte + + * include/makeinclude/platform_macosx_icc.GNU: + + Support for ICC on Intel Macs. + +Fri May 9 12:04:15 UTC 2008 Johnny Willemsen + + * ace/config-all.h: + Added ACE_HAS_MONITOR_POINTS which currently is set to 0. We will + enable this in a few builds to test them in detail. This way the + user can decide to enable the monitor framework but not get the + ACE builtin monitor points + + * ace/CDR_Stream.cpp: + * ace/CDR_Stream.h: + * ace/CDR_Stream.inl: + * ace/Message_Queue_T.cpp: + * ace/Message_Queue_T.h: + Added monitor points + + * ace/Codeset_IBM1047.cpp: + Removed code to silence the hp compiler, this is not needed in other + files + +Fri May 9 11:44:59 UTC 2008 Jeff Parsons + + * bin/MakeProjectCreator/config/ace_etcl_parser.mpb: + + Changed the filename etcl_parser.mpb to the one + above, for consistency in the names of ACE-related + files. Also changed the corresponding library name + to ACE_ETCL_Parser. + + * ace/ETCL/ACE_ETCL_Parser.pc.in: + + Changed the name of ETCL_Parser.pc.in likewise. + Also changed the contents of this file accordingly. + + * ace/ETCL/ETCL.mpc: + * ace/MonitorControl/MonitorControl.mpc: + * bin/MakeProjectCreator/config/ace_mc.mpb: + + Changes corresponding to the name changes above. + +Thu May 8 23:03:15 UTC 2008 J.T. Conklin + + * bin/MakeProjectCreator/config/ace_zlib.mpb: + + ACE-specific zlib base project that overrides library settings + in MPC's own zlib base project for the automake build. + +Thu May 8 22:13:24 UTC 2008 J.T. Conklin + + * bin/MakeProjectCreator/modules/AutomakeWorkspaceHelper.pm: + + Adjust libpaths now that ACE_ETCL_Parser library has been + renamed to just ETCL_Parser. + +Thu May 8 22:07:40 UTC 2008 J.T. Conklin + + * ace/ETCL/Makefile.am: + + Regenerated. + + * ace/ETCL/ACE_ETCL.pc.in: + * ace/ETCL/ETCL_Parser.pc.in: + + New pkg-config template files. + + * ace/ETCL/ETCL.mpc: + + Add Pkgconfig_Files sections for ACE_ETCL and ETCL_Parser + projects. + +Thu May 8 21:06:29 UTC 2008 Jeff Parsons + + * ace/ETCL/ETCL_Constraint_Visitor.h: + * ace/ETCL/ETCL_Constraint_Visitor.cpp: + + Removed a no-op method mean to be overridden + in derived visitors, but then abandoned. + +Fri May 2 17:45:13 UTC 2008 Douglas C. Schmidt + + * docs/ACE-guidelines.html: Updated the style guide to discuss the + use of '_' vs intercaps. + +Thu May 8 10:51:29 UTC 2008 Steve Huston + + * include/makeinclude/platform_sunos5_g++.GNU: Ensure -pipe is not + inserted into CCFLAGS twice. Similar to earlier change from + Wed Jan 23 17:23:31 UTC 2008 Steve Huston + Fixes Bugzilla #3232. + +Thu May 8 08:06:10 UTC 2008 Johnny Willemsen + + * ace/ETCL/ETCL_l.cpp: + * ace/ETCL/ETCL_y.cpp: + Fixed casing of include + +Wed May 7 19:28:35 UTC 2008 Steve Huston + + * ace/Unbounded_Set.{h inl}: Replaced typedef BASE with base_type. + Avoids a BASE macro on AIX. + +Wed May 7 19:02:51 UTC 2008 Jeff Parsons + + * ace/ETCL/ETCL_include: + + Removed this directory. + + * ace/ETCL/etcl_parser_export.h: + + Relocated here from ace/ETCL/ETCL_include. + + * bin/MakeProjectCreator/config/etcl_parser.mpb: + + Renamed this file from ace_etcl_parser.mpb. + + * ace/ETCL/ETCL_l.cpp: + * ace/ETCL/ETCL.yy + * ace/ETCL/ETCL_Interpreter.cpp: + * ace/ETCL/ETCL.ll: + * ace/ETCL/ETCL_y.cpp: + * ace/ETCL/ETCL_Interpreter.h: + * ace/ETCL/ETCL.mpc: + * ace/MonitorControl/MonitorControl.mpc: + * bin/MakeProjectCreator/config/ace_mc.mpb: + + All changes in this checkin are to remove + unnecessary things as a result of making the + ETCL parser the only one used. The corresponding + parser in TAO is eliminated. + +Wed May 7 17:11:10 UTC 2008 Johnny Willemsen + + * include/makeinclude/platform_linux_icc.GNU: + Added ICC 11.0 + +Wed May 7 14:28:54 UTC 2008 Chad Elliott + + * bin/ChangeLogEditor/FileLocatorFactory.pm: + + Changed to detect Subversion before CVS. + +Wed May 7 14:12:10 UTC 2008 Johnny Willemsen + + * tests/Bug_3319_Regression_Test.cpp: + * tests/run_test.lst: + * tests/tests.mpc: + Added regression for bugzilla 3319 + +Wed May 7 10:52:10 UTC 2008 Johnny Willemsen + + * ace/Hash_Map_Manager_T.cpp: + Fixed GCC warning about maybe unitialised use and also + use prefix decrement and no need for some intermediate variables + +Wed May 7 08:42:10 UTC 2008 Johnny Willemsen + + * ace/config-vxworks5.x.h: + Added ACE_HAS_4_4BSD_SENDMSG_RECVMSG + +Wed May 7 07:03:29 UTC 2008 William R. Otte + + * ace/Unbounded_Set.h + + Fuzz fix. + +Wed May 7 06:33:30 UTC 2008 William R. Otte + + * ace/Unbounded_Set.inl + + Fix unused argument warning. + +Tue May 6 17:03:17 UTC 2008 William R. Otte + + * ace/Hash_Map_Manager_T.cpp: + Fixed segfault if shared_find is called on a map of size zero. + + * ace/Log_Msg.h: + + Comments for trace_active were swapped. + + * ace/Node.h: + * ace/Node.cpp: + * ace/Unbounded_Set.h: + * ace/Unbounded_Set.inl: + * ace/Unbounded_Set.cpp: + * ace/Unbounded_Set_Ex.h: + * ace/Unbounded_Set_Ex.inl: + * ace/Unbounded_Set_Ex.cpp: + + Extended the Unbounded_Set to include a comparator template parameter, + which must implement operator (), which returns true if the items are + equivalent. This class has been renamed Unbounded_Set_Ex. + + Unbounded_Set is now implemented in terms of Unbounded_Set_Ex with a + comparator that uses operator== to compare the items. + + * ace/Service_Gestalt.h: + * tests/Unbounded_Set_Test.cpp: + + Slight updates to conform with new implementation. + + * NEWS + + Added description for above. + +Tue May 6 12:37:43 UTC 2008 Jeff Parsons + + * ace/ETCL/ETCL_Constraint.h: + * ace/ETCL/ETCL_Constraint_Visitor.cpp: + * ace/ETCL/ETCL_Constraint_Visitor.h: + * ace/ETCL/ETCL_Constraint.inl: + * ace/ETCL/ETCL_Constraint.cpp: + + Moved code from the TAO ETCL classes to base classes + here. + +Tue May 6 08:27:10 UTC 2008 Johnny Willemsen + + * bin/PerlACE/ProcessVX_Unix.pm: + * bin/PerlACE/ProcessVX_Win32.pm: + Added support for ACE_RUN_VX_TGT_TELNET_HOST and + ACE_RUN_VX_TGT_TELNET_PORT so that an explicit telnet server + can be configured. If not specified we use ACE_RUN_VX_TGTHOST + which also specifies the ip address that is used as endpoint + for the corba servers + +Mon May 5 17:09:10 UTC 2008 Johnny Willemsen + + * include/makeinclude/build_dll.bor: + * include/makeinclude/build_exe.bor: + * include/makeinclude/build_lib.bor: + Handle files with cxx extension just as we could handle cpp files + +Mon May 5 07:53:10 UTC 2008 Johnny Willemsen + + * ace/os_include/os_pdh.h: + New os_include file for pdh.h + + * ace/configure.ac: + Added check for pdh.h + + * ace/Makefile.am: + Added new file + + * ace/config-win32-common.h: + * ace/config-win32-mingw.h: + * ace/config-WinCE.h: + Windows has pdh.h, but not MinGW and not WinCE + + * ace/MonitorControl/BytesReceivedMonitor.cpp: + * ace/MonitorControl/BytesReceivedMonitor.h: + * ace/MonitorControl/BytesSentMonitor.cpp: + * ace/MonitorControl/BytesSentMonitor.h: + * ace/MonitorControl/CPULoadMonitor.cpp: + * ace/MonitorControl/CPULoadMonitor.h: + * ace/MonitorControl/MemoryUsageMonitor.cpp: + * ace/MonitorControl/MemoryUsageMonitor.h: + * ace/MonitorControl/NumThreadsMonitor.cpp: + * ace/MonitorControl/NumThreadsMonitor.h: + * ace/MonitorControl/PacketsReceivedMonitor.cpp: + * ace/MonitorControl/PacketsReceivedMonitor.h: + * ace/MonitorControl/PacketsSentMonitor.cpp: + * ace/MonitorControl/PacketsSentMonitor.h: + * ace/MonitorControl/WindowsMonitor.cpp: + * ace/MonitorControl/WindowsMonitor.h: + * ace/MonitorControl/WindowsMultiInstanceMonitor.cpp: + * ace/MonitorControl/WindowsMultiInstanceMonitor.h: + Use ACE_HAS_WIN32_PDH instead of ACE_WIN32 because with WinCE and + MinGW we don't have pdh on windows + +Mon May 5 07:37:10 UTC 2008 Johnny Willemsen + + * examples/Monitor/CPU_Load/cpu_load.cpp: + * examples/Monitor/Group/group.cpp: + Fixed C90 warnings + +Mon May 5 07:30:10 UTC 2008 Johnny Willemsen + + * examples/Monitor/MC_Test_Utilities.mpc: + Don't build with ace_for_tao enabled + +Sat May 3 17:00:07 UTC 2008 J.T. Conklin + + * bin/MakeProjectCreator/modules/AutomakeWorkspaceHelper.pm: + + Add relative libdirs for new ACE_ETCL, ACE_ETCL_Parser, and + ACE_MonitorControl libraries. + +Sat May 3 13:47:21 UTC 2008 J.T. Conklin + + * examples/Makefile.am: + + Regenerated. + +Fri May 2 23:58:38 UTC 2008 J.T. Conklin + + * configure.ac: + + Build new example directories. + + * examples/Monitor/Bytes_Sent/Makefile.am: + * examples/Monitor/Message_Queue_Size/Makefile.am: + * examples/Monitor/Constraint/Makefile.am: + * examples/Monitor/CPU_Load/Makefile.am: + * examples/Monitor/Num_Threads/Makefile.am: + * examples/Monitor/Group/Makefile.am: + * examples/Monitor/Memory_Usage/Makefile.am: + * examples/Monitor/Makefile.am: + * examples/Semaphores/Makefile.am: + + New Makefile.am's. + +Fri May 2 23:29:06 UTC 2008 J.T. Conklin + + * ace/ETCL/Makefile.am: + + Regenerated. + + * ace/ETCL/ETCL.mpc: + + Add automake specific rule for includes. + +Fri May 2 22:53:46 UTC 2008 J.T. Conklin + + * configure.ac: + + Build ace/ETCL and ace/MonitorControl. + +Fri May 2 21:54:40 UTC 2008 J.T. Conklin + + * ace/ETCL/Makefile.am: + * ace/MonitorControl/Makefile.am: + + New Makefile.am's. + + * ace/Makefile.am: + + Regenerated. + +Fri May 2 18:36:41 UTC 2008 Jeff Parsons + + * ace/ETCL/ETCL_Interpreter.h: + + Fix for build problems with versioned namespaces turned on. + +Fri May 2 17:50:10 UTC 2008 Johnny Willemsen + + * ace/config-vxworks6.2.h: + * ace/config-vxworks6.3.h: + * ace/config-vxworks6.4.h: + Only define _C99 when it is not defined yet + +Fri May 2 17:20:37 UTC 2008 Steve Huston + + * tests/Message_Queue_Test.cpp: Removed the delay sleep between loop + iterations - it causes the test to time out too often. Increased + the message count back to multiples of 100,000. + +Fri May 2 15:34:55 UTC 2008 Steve Huston + + * tests/RW_Process_Mutex_Test.cpp: Fixed compile warning about + redundant variable. + +Fri May 2 11:07:10 UTC 2008 Johnny Willemsen + + * ace/MMAP_Memory_Pool.{h,cpp}: + Doxygen improvements and moved the documentation about the + handle_signal method from the cpp to the header file so that + it appears in the doxygen documentation + +Fri May 2 09:36:10 UTC 2008 Johnny Willemsen + + * bin/tao_orb_tests.lst: + Added Bug_3315_Regression + +Fri May 2 08:25:10 UTC 2008 Johnny Willemsen + + * bin/msvc_static_order.lst: + Added new libs + +Fri May 2 08:15:10 UTC 2008 Johnny Willemsen + + * ace/ace_for_tao.mpc: + Added new monitor files + +Fri May 2 08:04:10 UTC 2008 Johnny Willemsen + + * ace/Monitor_Admin.cpp + * ace/Monitor_Admin.h + * ace/MonitorControl/AutoUpdateStarter.cpp + * ace/MonitorControl/AutoUpdateStarter.h + * ace/MonitorControl/MonitorControl_utils.h + Updated for naming conventions + +Fri May 2 07:47:10 UTC 2008 Johnny Willemsen + + * examples/Monitor/Bytes_Sent/bytes_sent.cpp + * examples/Monitor/Constraint/constraint.cpp + * examples/Monitor/CPU_Load/cpu_load.cpp + * examples/Monitor/Group/group.cpp + * examples/Monitor/Memory_Usage/memory_usage.cpp + * examples/Monitor/Message_Queue_Size/message_queue_size.cpp + * examples/Monitor/Num_Threads/num_threads.cpp + Updated include + + * examples/Monitor/Bytes_Sent/Bytes_Sent.mpc + * examples/Monitor/Constraint/Constraint.mpc + * examples/Monitor/Num_Threads/Num_Threads.mpc + * examples/Monitor/Group/Group.mpc + * examples/Monitor/CPU_Load/CPU_Load.mpc + * examples/Monitor/Message_Queue_Size/Message_Queue_Size.mpc + Don't build with ace_for_tao + +Thu May 1 22:35:17 UTC 2008 Steve Huston + + * ace/MonitorControl/MonitorControl.mpc: + * bin/MakeProjectCreator/config/ace_mc.mpb: + Avoid wince - it lacks the needed PDH capability. + +Thu May 1 18:27:10 UTC 2008 Johnny Willemsen + + * ace/MonitorControl/MonitorControl.mpc: + * bin/MakeProjectCreator/config/ace_mc.mpb: + Use ACE_MonitorControl as shared library name + +Thu May 1 17:31:01 UTC 2008 Iliyan Jeliazkov + + * ace/Service_Config.cpp: Removed an assert guarding the case when + the current thread has no associated configuration context. Added + code that would initialize the thread's configuration context with + the global, instead. This addresses bug# 3315. + +Thu May 1 17:11:48 UTC 2008 Jeff Parsons + + * ace/ace.mwc: + + Added MonitorControl directory to the workspace. + +Thu May 1 17:05:37 UTC 2008 Jeff Parsons + + * ace/MonitorControl/PacketsSentMonitor.h: + * ace/MonitorControl/WindowsMultiInstanceMonitor.cpp: + * ace/MonitorControl/WindowsMonitor.cpp: + * ace/MonitorControl/PacketsReceivedMonitor.cpp: + * ace/MonitorControl/MonitorGroup.h: + * ace/MonitorControl/MonitorQuery.h: + * ace/MonitorControl/NumThreadsMonitor.cpp: + * ace/MonitorControl/PacketsSentMonitor.cpp: + * ace/MonitorControl/MonitorGroup.cpp: + * ace/MonitorControl/WindowsMultiInstanceMonitor.h: + * ace/MonitorControl/WindowsMonitor.h: + * ace/MonitorControl/MonitorControl_utils.h: + * ace/MonitorControl/MonitorQuery.cpp: + * ace/MonitorControl/PacketsReceivedMonitor.h: + * ace/MonitorControl/NumThreadsMonitor.h: + + Changed header includes to be consistently relative + to $ACE_ROOT. + +Thu May 1 16:11:12 UTC 2008 Jeff Parsons + + * MonitorControl/*: + + Moved this directory to $ACE_ROOT/ace. + +Thu May 1 15:56:58 UTC 2008 Steve Huston + + * tests/run_test.lst: Change Bug_2980_Regression_Test's !MSVC to + !Win32. The test won't run on Windows per its comments, but no + XML configs set MSVC - they set Win32. + +Thu May 1 15:27:25 UTC 2008 Steve Huston + + * tests/Message_Queue_Test.cpp: In the counting test, run multiples + of 50,000 instead of 100,000, blocks. The test is timing out on a + number of platforms. + + * tests/RW_Process_Mutex_Test.cpp: Fix signed/unsigned warnings and + wchar build error. Changed the default lock name to something other + than the program's name. Using the program name produces "text + file busy" when attempting a file lock on it... doh... + +Thu May 1 14:47:33 UTC 2008 Jeff Parsons + + * MonitorControl/examples/*: + + Removed this directory and moved its contents to + $ACE_ROOT/examples/Monitor. + + * bin/MakeProjectCreator/config/acelib.mpb: + + Cosmetic changes. + +Thu May 1 14:37:03 UTC 2008 Chad Elliott + + * bin/MakeProjectCreator/modules/VXTestProjectCreator.pm: + + Override the warn_useless_project() method so that we are no + longer warned about "no useful targets" for this project type. + +Wed Apr 30 22:01:10 UTC 2008 Steve Huston + + * tests/RW_Process_Mutex_Test.cpp: New test for proper functioning + of ACE_RW_Process_Mutex. + + * tests/tests.mpc: + * tests/run_test.lst: Add RW_Process_Mutex_Test. + +Wed Apr 30 21:14:45 UTC 2008 James H. Hill + + * ace/Hash_Map_Manager_T.h: + + Two of the backwards compatible iterators for + ACE_Hash_Map_Manager incorrectly defined the iterator_category + trait based on the container_type, which does not have an + iterator_category. Now the trait is defined in terms of its + base class. This resolved Bugzilla Bug #3314. + +Wed Apr 30 16:49:27 UTC 2008 Jeff Parsons + + * MonitorControl/PacketsSentMonitor.h: + * MonitorControl/BytesReceivedMonitor.h: + * MonitorControl/PacketsReceivedMonitor.h: + * MonitorControl/BytesSentMonitor.h: + + Added include of export header file, since it's not + pulled in indirectly on Solaris builds. + + * MonitorControl/WindowsMultiInstanceMonitor.cpp: + + Fixed signed/unsigned comparison warnings on wchar builds. + +Wed Apr 30 16:24:41 UTC 2008 Jeff Parsons + + * MonitorControl/CPULoadMonitor.cpp: + * MonitorControl/WindowsMonitor.cpp: + * MonitorControl/WindowsMultiInstanceMonitor.cpp: + * MonitorControl/MemoryUsageMonitor.cpp: + * MonitorControl/NumThreadsMonitor.cpp: + * MonitorControl/LinuxNetworkInterfaceMonitor.cpp: + + Fixed wchar build errors. + +Wed Apr 30 13:49:52 UTC 2008 Steve Huston + + * ace/UUID.cpp (get_timestamp_and_clocksequence): Case clock sequence + value using ACE_UINT16 instead of u_char to prevent duplicates + when many UUIDs are generated quickly. Thanks to Wim van den Boogaard + for this fix. Resolves Bugzilla #3313. + +Tue Apr 29 19:52:48 UTC 2008 Steve Huston + + * ace/Proactor.cpp: Simplify the timer_handler_ task spawn and + shutdown. Also, if close() sees an error from the implementation's + close, don't stop closing. Things are most likely already ripped + apart too far to recover from, and it's likely to cause a hang to + just try to stop closing now. + + * ace/POSIX_Asynch_IO.cpp: Correctly handle the ACE_Message_Block + pointers passed to operations and later updating when complete. + Thanks to Fernando C. Jeronymo for diagnosing this problem. + + * THANKS: Added Fernando C. Jeronymo to the Hall of Fame. + + * tests/Proactor_UDP_Test.cpp: Fix to close down correctly in + half-duplex mode. + +Tue Apr 29 19:12:53 UTC 2008 Jeff Parsons + + * bin/MakeProjectCreator/config/ace_etcl_parser.mpb: + + Changed the path of the 'includes' line to match + the new location of ETCL. + + * MonitorControl/Constraint_Interpreter.cpp: + * MonitorControl/Constraint_Visitor.h: + * MonitorControl/Constraint_Visitor.cpp: + * MonitorControl/Constraint_Interpreter.h: + + Updated #includes to match the new location of ETCL. + + * MonitorControl/AutoUpdateStarter.h: + + Moved location of enabled monitors check, it was + previous to any place it could see the #define in + an included file. + + * MonitorControl/examples/Constraint/constraint.cpp: + * MonitorControl/examples/CPU_Load/cpu_load.cpp: + * MonitorControl/examples/Group/group.cpp: + + Some compile warnings fixed. + +Tue Apr 29 18:37:10 UTC 2008 Johnny Willemsen + + * MonitorControl/AutoUpdateStarter.h: + * MonitorControl/Constraint_Interpreter.h: + * MonitorControl/Constraint_Visitor.h: + * MonitorControl/LinuxNetworkInterfaceMonitor.h: + * MonitorControl/MonitorControl.h: + * MonitorControl/MonitorQuery.h: + * MonitorControl/WindowsMonitor.h: + * MonitorControl/WindowsMultiInstanceMonitor.h: + Make sure we have at least one include before pragma once + +Tue Apr 29 18:27:10 UTC 2008 Johnny Willemsen + + * docs/bczar/bczar.html: + * etc/index.html: + Updated Beta to Micro + +Tue Apr 29 18:02:22 UTC 2008 Jeff Parsons + + * ETCL/*: + + Moved this directory and all its contents to $ACE_ROOT/ace. + Also changed #includes to be relative to $ACE_ROOT. + + * ace/ace.mwc: + + Added ETCL directory. + + * docs/svn/svn-prefs.reg: + + Added *.diff to list. + +Tue Apr 29 17:45:10 UTC 2008 Johnny Willemsen + + * MonitorControl/examples/Bytes_Sent/bytes_sent.cpp: + * MonitorControl/examples/Constraint/constraint.cpp: + * MonitorControl/examples/CPU_Load/cpu_load.cpp: + * MonitorControl/examples/Group/group.cpp: + * MonitorControl/examples/Memory_Usage/memory_usage.cpp: + * MonitorControl/examples/Message_Queue_Size/message_queue_size.cpp: + * MonitorControl/examples/Num_Threads/num_threads.cpp: + Updated main for unicode + +Tue Apr 29 13:14:10 UTC 2008 Johnny Willemsen + + * tests/Test_Output.cpp: + Check for ACE_VXWORKS + +Tue Apr 29 13:12:10 UTC 2008 Johnny Willemsen + + * MonitorControl/AutoUpdateStarter.cpp: + * MonitorControl/Constraint_Interpreter.cpp: + * MonitorControl/Constraint_Interpreter.h: + * MonitorControl/Constraint_Visitor.cpp: + * MonitorControl/Constraint_Visitor.h: + * MonitorControl/CPULoadMonitor.cpp: + * MonitorControl/LinuxNetworkInterfaceMonitor.cpp: + * MonitorControl/NumThreadsMonitor.cpp: + * MonitorControl/WindowsMonitor.cpp: + * MonitorControl/WindowsMultiInstanceMonitor.cpp: + Updated includes to fix errors and improve compile speed when + this lib is disabled + +Tue Apr 29 08:16:10 UTC 2008 Johnny Willemsen + + * bin/MakeProjectCreator/templates/vxtest.mpd: + Zap empty line + + * bin/PerlACE/ProcessVX.pm: + * bin/PerlACE/ProcessVX_Unix.pm: + * bin/PerlACE/ProcessVX_Win32.pm: + Improved handling of vxtest file + +Tue Apr 29 07:23:10 UTC 2008 Johnny Willemsen + + * ace/MEM_Connector.cpp: + * ace/Service_Manager.cpp: + * ace/SOCK_Dgram_Mcast.cpp: + Reverted accidental commits from Doug + +Tue Apr 29 06:32:10 UTC 2008 Johnny Willemsen + + * bin/MakeProjectCreator/modules/VXTestProjectCreator.pm: + Generate exename.vxtest instead of project name + + * bin/MakeProjectCreator/templates/vxtest.mpd: + Don't generate ld < + +Mon Apr 28 22:34:10 UTC 2008 Steve Huston + + * tests/Proactor_UDP_Test.cpp: Fix compile errors on non-Windows. + +Mon Apr 28 21:53:23 UTC 2008 Steve Huston + + * docs/ACE-development-process.html: Fix a few remaining nits. + + * ace/OS_NS_stdio.inl: Removed all the pre-ACE_HAS_WINNT4 code in the + file locks methods. This was the only place left in ACE that + referred to ACE_HAS_WINNT4; all pre-NT4 support was removed last + year from the rest of ACE. This also corrects behavior of file + locks as well as ACE_RW_Process_Mutex. + + * ace/RW_Process_Mutex.h: Doxygen improvements. + + * ace/SOCK_CODgram.h: Doxygen improvements. + + * ace/SOCK_CODgram.cpp (open): If either of the local or remote + addresses is specified, use its address family rather than the + value of protocol_family. If both are specified, they must match. + + * tests/Message_Queue_Test.cpp: Added a counting test to validate the + queue's message counting. + + * tests/Proactor_UDP_Test.cpp: New test for UDP with ACE_Proactor. + + * tests/tests.mpc: + * tests/run_test.lst: Add Proactor_UDP_Test. + +Mon Apr 28 19:21:54 UTC 2008 Johnny Willemsen + + * bin/PerlACE/ProcessVX.pm: + * bin/PerlACE/ProcessVX_Unix.pm: + * bin/PerlACE/ProcessVX_Win32.pm: + Use the vxtest file when testing shared non rtp + +Mon Apr 28 19:06:10 UTC 2008 Jeff Parsons + + * MonitorControl/MonitorControl.h: + + Added ACE_HAS_MONITOR_FRAMEWORK guard to this file. + +Mon Apr 28 18:24:54 UTC 2008 Johnny Willemsen + + * ace/ace_wchar.h: + Added defines needed to build MonitorControl unicode + + * MonitorControl/WindowsMonitor.cpp: + * MonitorControl/WindowsMultiInstanceMonitor.cpp: + Make a correct difference between unicode and non unicode builds + + * ace/Strategies_T.{h,inl}: + Refcount from base is now a long + +Mon Apr 28 18:23:55 UTC 2008 Adam Mitz + + * bin/PerlACE/ProcessVX_Unix.pm: + + Fixed a bug in my previous commit of this file, + $cmdnr was not updated when the unload commands were added. + +Mon Apr 28 17:59:43 UTC 2008 Jeff Parsons + + * Constraint_Interpreter.cpp: + * Constraint_Visitor.h: + * MonitorGroup.h: + * MonitorQuery.h: + * AutoUpdateStarter.h: + * Constraint_Visitor.cpp: + * MonitorGroup.cpp: + * Constraint_Interpreter.h: + * MonitorQuery.cpp: + * AutoUpdateStarter.cpp: + * MonitorControl_utils.h: + + Added ACE_HAS_MONITOR_FRAMEWORK guards + similarly to the other files in the library. + +Mon Apr 28 17:54:54 UTC 2008 Johnny Willemsen + + * MonitorControl/BytesReceivedMonitor.cpp: + * MonitorControl/BytesSentMonitor.cpp: + * MonitorControl/CPULoadMonitor.cpp: + * MonitorControl/MemoryUsageMonitor.cpp: + * MonitorControl/NumThreadsMonitor.cpp: + * MonitorControl/PacketsReceivedMonitor.cpp: + * MonitorControl/PacketsSentMonitor.cpp: + * MonitorControl/WindowsMonitor.cpp: + * MonitorControl/WindowsMonitor.h: + * MonitorControl/WindowsMultiInstanceMonitor.cpp: + * MonitorControl/WindowsMultiInstanceMonitor.h: + Fixed unicode compile problems on windows + +Mon Apr 28 13:25:54 UTC 2008 Johnny Willemsen + + * examples/APG/Streams/streams.mpc: + * examples/C++NPv2/C++NPv2.mpc: + Use base projects + +Mon Apr 28 13:20:40 UTC 2008 Douglas C. Schmidt + + * ace/Vector_T.inl (ACE_Vector): Take another shot at fixing the + max_size() problem. + +Mon Apr 28 12:45:18 UTC 2008 Chad Elliott + + * bin/tao_orb_tests.lst: + + Added the new TAO HandleExhaustion test for all but Windows. + +Mon Apr 28 12:21:55 UTC 2008 Douglas C. Schmidt + + * ace/Vector_T.inl (ACE_Vector): Zapped the "this->" in "this->max_size()". + Thanks to Karl-Heinz for reporting this. + +Mon Apr 28 12:13:54 UTC 2008 Johnny Willemsen + + * include/makeinclude/platform_sunos5_common.GNU: + Added kstat support needed for monitoring lib on solaris + +Mon Apr 28 12:05:54 UTC 2008 Johnny Willemsen + + * MonitorControl/*: + Merge from MonitorControl branch. + +Mon Apr 28 11:37:54 UTC 2008 Johnny Willemsen + + * ace/config-all.h: + * ace/Global_Macros.h: + Moved set of define to config-all + + * ace/Truncate.h: + * ace/Condition_T.h: + Doxygen fix + +Mon Apr 28 11:36:46 UTC 2008 Chad Elliott + + * ace/Acceptor.h: + * ace/Acceptor.cpp: + + Added a virtual method to facilitate the configurable handling of + accept() errors. + +Mon Apr 28 11:30:54 UTC 2008 Johnny Willemsen + + * ETCL/*: + New ETCL library for ACE + + * bin/MakeProjectCreator/config/ace_etcl.mpb: + * bin/MakeProjectCreator/config/ace_etcl_parser.mpb: + * bin/MakeProjectCreator/config/ace_mc.mpb: + New base projects + + * bin/MakeProjectCreator/config/acenosubsets.mpb: + Layout changes + +Mon Apr 28 10:31:54 UTC 2008 Johnny Willemsen + + * ace/Monitor_Admin.cpp: + * ace/Monitor_Admin.h: + * ace/Monitor_Admin_Manager.cpp: + * ace/Monitor_Admin_Manager.h: + * ace/Monitor_Base.cpp: + * ace/Monitor_Base.h: + * ace/Monitor_Base.inl: + * ace/Monitor_Control_Action.cpp: + * ace/Monitor_Control_Action.h: + * ace/Monitor_Control_Types.cpp: + * ace/Monitor_Control_Types.h: + * ace/Monitor_Point_Registry.cpp: + * ace/Monitor_Point_Registry.h: + * ace/ace.mpc: + * ace/Global_Macros.h: + First commit coming from the Monitor branch. This will add a + monitoring framework to ACE with which size of queues, cpu load + and other resources can be monitored. + +Sun Apr 27 05:55:54 UTC 2008 Johnny Willemsen + + * ace/Service_Object.cpp: + Fixed big introduced by some cleanup I did + +Fri Apr 25 21:47:54 UTC 2008 Adam Mitz + + * bin/MakeProjectCreator/templates/vxtest.mpd: + * bin/PerlACE/ProcessVX_Unix.pm: + + Began integration of the foo.vxtest files into the actual testing + process. This needs to get enhanced in ProcessVX_Win32.pm too. + +Fri Apr 25 21:21:56 UTC 2008 Adam Mitz + + * ace/Object_Manager.cpp: + + Removed a comment that no longer applies. + + * bin/PerlACE/Process_Win32.pm: + + Changed the check for failure to spawn a process, in order to avoid + a race condition (the spawned process exits normally before we even + check its status). + + * bin/auto_run_tests.pl: + + With -s, account for different parameter formatting requirements in + the win32 and posix sandbox programs. + +Fri Apr 25 14:25:00 UTC 2008 Simon Massey + + * tests/Unload_libACE.cpp: + I've backed out this change due to lack of time to chase up + the lack of macro definitions. This will need to be revisited. + +Fri Apr 25 10:40:00 UTC 2008 Simon Massey + + * tests/Unload_libACE.cpp: + This test wasn't using ACE_TMAIN. + +Fri Apr 25 09:10:00 UTC 2008 Simon Massey + + * bin/MakeProjectCreator/config/global.features: + * examples/Log_Mgs/Log_Msg_MFC/Log_Mgs_MFC.mpc: + Feature name "uses_wchar" already used within ACE/TAO. Replaces + the "unicode" feature name. Template / project names within MPC + still named unicode. + +Thu Apr 24 18:45:32 UTC 2008 Johnny Willemsen + + * ace/config-linux-common.h: + When ACE_LACKS_STROPTS_H not is defined we assume we have + strbut so we set ACE_HAS_STRBUF_T + +Thu Apr 24 16:47:16 UTC 2008 Chad Elliott + + * bin/tao_orb_tests.lst: + + The DLL_ORB test requires threads. Disable it when the ST config + is used. + +Thu Apr 24 15:05:50 UTC 2008 Simon McQueen + + * bin/tao_orb_tests.lst: + + Scheduled new regression test for bug #3299. + +Thu Apr 24 09:55:00 UTC 2008 Simon Massey + + * bin/MakeProjectCreator/config/ace_unicode.mpb: + * bin/MakeProjectCreator/config/global.features: + Default unicode=0 feature. Unicode does not depend upon MFC, + may be used together as necessary. + + * examples/Log_Mgs/Log_Msg_MFC/Log_Mgs_MFC.mpc: + * examples/Log_Mgs/Log_Msg_MFC/Log_Mgs_Unicode_MFC.mpc: + Split out the unicode requirements. + +Thu Apr 24 05:58:32 UTC 2008 Johnny Willemsen + + * ace/Refcountable_T.{cpp,inl}: + Use ACE_INLINE + +Thu Apr 24 05:47:32 UTC 2008 Johnny Willemsen + + * ace/config-posix.h: + Reverted change below, already made a similar change which is less risky + + Thu Apr 17 19:27:23 UTC 2008 Douglas C. Schmidt + * ace/config-posix.h: Added a check for + + #if defined _XOPEN_STREAMS && _XOPEN_STREAMS == -1 + # define ACE_LACKS_STROPTS_H + #endif + + so that ACE will compile properly on Fedora 8. Thanks to + Jules Colding for this fix. + +Thu Apr 17 19:27:23 UTC 2008 Douglas C. Schmidt + + * ace/config-posix.h: Added a check for + + #if defined _XOPEN_STREAMS && _XOPEN_STREAMS == -1 + # define ACE_LACKS_STROPTS_H + #endif + + so that ACE will compile properly on Fedora 8. Thanks to + Jules Colding for this fix. + +Wed Apr 23 18:29:32 UTC 2008 Johnny Willemsen + + * ace/Refcountable.{h,cpp,inl}: + * ace/Refcountable_T.{h,cpp,inl}: + Changed ACE_Refcountable to ACE_Refcountable_T which has a + trait for the type of lock. ACE_Refcountable is now a typedef + of ACE_Refcountable_T. Also the refcount + type is now a long so that we can make use of the Atomic_Op + optimizations on some platforms + + * ace/ace.mpc: + * ace/Makefile.am: + Updated for the change above + +Wed Apr 23 14:49:32 UTC 2008 Johnny Willemsen + + * ace/config-linux-common.h: + When _XOPEN_STREAMS is defined to -1 we don't have stropts.h, + this fixes bugzilla 3291. Thanks to Jules Colding + for reporting this + +Wed Apr 23 14:10:32 UTC 2008 Johnny Willemsen + + * docs/ACE-development-process.html: + We are using svn as repository + +Wed Apr 23 14:01:32 UTC 2008 Johnny Willemsen + + * bin/generate_rel_manpages: + Corrected doxygen path + + * bin/group_test_stats.sh: + Helper script to analyze test stat diffs + + * ace/Sig_Handler.{h,cpp}: + Doxygen changes and changed third_party_sig_handler flag to a + bool + + * ace/Service_Repository.{h,cpp}: + Changed ignore_suspended to a bool + + * ace/Intrusive_Auto_Ptr.h: + Fixed typo in comment + + * ace/config-vxworks6.2.h: + * ace/config-vxworks6.3.h: + * ace/config-vxworks6.4.h: + Removed workaround that is only needed with VxWorks 5.5.1 + + * ace/Codeset_Registry_db.cpp: + Added UCS2 and correct short names. This fixes bugzilla 3295 + + * ace/Codeset_IBM1047.h: + Doxygen changes + + * ace/Cleanup_Strategies_T.h: + Layout changes + + * ace/Service_Gestalt.{h,inl}: + No need for virtual methods, use bool and doxygen changes + + * ace/Service_Manager.h: + Explicitly mark destructor as virtual + + * ace/Service_Object.{h,cpp,inl}: + Use bool + +Wed Apr 23 01:53:32 CDT 2008 Johnny Willemsen + + * ACE version 5.6.4 released. + +Wed Apr 16 13:06:05 UTC 2008 Iliyan Jeliazkov + + * ace/ARGV.cpp: + Don't quote quotes already quoted. + +Mon Apr 14 12:10:57 UTC 2008 Johnny Willemsen + + * tests/run_test.pl: + Don't run 2980 when WCHAR is set + +Mon Apr 14 11:08:57 UTC 2008 Johnny Willemsen + + * ace/Threading_Helper_T.cpp: + Removed + + * ace/Makefile.am: + Removed file above + + * ace/Service_Config.{h,cpp,inl}: + Changed the template instantiations like we have for Atomic_Op. + +Mon Apr 14 09:54:57 UTC 2008 Johnny Willemsen + + * tests/tests.mpc: + Don't build 2980 with wchar enabled and added empty resource + file section + +Mon Apr 14 08:59:57 UTC 2008 Johnny Willemsen + + * ace/Threading_Helper_T.cpp: + Added new file with the threading helper template code. This resolves + the strange link problems with BCB. This file is included in the + Service_Config.h file + + * ace/Makefile.am: + Added new files + + * ace/Service_Config.{h,cpp,inl}: + Include the new Threading_Helper_T.cpp and removed the implementation + from these files + + * tests/tests.mpc: + Added missing include for bug 2980 + + * ace/Codeset_Registry.h: + Fixed typo in comment + + * ace/Shared_Object.h: + Doxygen changes + +Mon Apr 14 01:56:06 UTC 2008 Iliyan Jeliazkov + + * ace/Service_Config.h: + * ace/Service_Config.inl: + * ace/Service_Config.cpp: + + Moved ACE_Threading_Helper ctor and dtor implementaion + inline. This makes them available to code that indirectly + references the threadkey_ member (like, in examples/). This + should resolve link-time problems with borland compilers. + + * tests/Bug_2980_Regression_Test.cpp (unloadDll): + + Fixing warnings about missing extern "C" qualifier in call to + pthread_create. + +Sun Apr 13 07:27:57 UTC 2008 Johnny Willemsen + + * ace/OS_NS_Thread.cpp (_vx_call_entry): + Set the sc::current before calling main. This resolves the + sc asserts with vxworks kernel mode. Thanks to Iliyan + for suggesting this addition + +Fri Apr 11 17:36:34 UTC 2008 Douglas C. Schmidt + + * docs/Download.html: + * docs/ACE-development-process.html: + * docs/ACE-bug-process.html: Updated these files to use the major, + minor, and micro release terminology. + +Fri Apr 11 15:26:08 UTC 2008 Iliyan Jeliazkov + + * tests/Bug_2980_Regression_Test.cpp: + * tests/run_test.lst: + + Including config-lite.h: the driver is non-ACE but it still + needs to know platform-specific stuff, like threads usage, + etc. + +Fri Apr 11 01:51:13 UTC 2008 Iliyan Jeliazkov + + * ace/Svc_Conf_Tokens.h: + * ace/svcconf.mpb: + + Fixing a fuzz build warning of a missing $Id. Also, not all + make(1)'s have $(MV), so changing mpb to use just "mv" + +Thu Apr 10 22:32:58 UTC 2008 Iliyan Jeliazkov + + * ace/Service_Config.h: + * ace/Service_Config.cpp: + + Fixing compile problems with single-thread-only builds - using + the compiler's abilities (partial specialization) to generate + appropriate code. + + * ace/Svc_Conf.h: + * ace/Svc_Conf_Token_Table.h: + * ace/Svc_Conf_Tokens.h: + * ace/Svc_Conf_y.cpp: + * ace/svcconf.mpb: + + Changes to fix compile problems related to versioned namespace + use. Eliminated custom token file post-processing - replaced + with a wrapper header file (yacc(1) is now producing + Token_Table.h, which gets included in Tokens.h) + +Thu Apr 10 14:42:04 UTC 2008 Iliyan Jeliazkov + + * ace/Svc_Conf.h: + + Adding YYSTYPE_IS_DECLARED to prevent yacc(1) from trying to use a + trivial definition of YYSTYPE. + + * ace/Svc_Conf.y: + + Fixing an unused variable warning. Adding an YYSTYPE guard. + + * ace/Svc_Conf_Tokens.h: + * ace/Svc_Conf_y.cpp: + * ace/svcconf.mpb: + + Undefining YYSTYPE_IS_DECLARED at the bottom of Svc_Conf_Tokens.h + prevents it from leaking and poluting the global namespace. This + allows other yacc(1) based parsers to be used in ACE + apps. Cleaning up and recording generated files. + +Thu Apr 10 13:27:13 UTC 2008 Chad Elliott + + * tests/Bug_2980_Regression_Test.cpp: + + Fixed compilation issues and reversed the CAN_RUN_TEST check to + get it to run on non-win32 and non-vxworks operating systems. + +Thu Apr 10 10:11:57 UTC 2008 Johnny Willemsen + + * ace/Dynamic_Service.inl: + Corrected method signatures + +Thu Apr 10 10:03:57 UTC 2008 Johnny Willemsen + + * tests/Bug_2980_Regression_Test.cpp: + Fixed BCB compile error + +Thu Apr 10 07:13:57 UTC 2008 Johnny Willemsen + + * include/makeinclude/platform_linux_pgi.GNU: + Removed deprecated linker flags + + * ace/Dev_Poll_Reactor.cpp: + * ace/Notification_Queue.cpp: + * ace/Service_Config.cpp: + * ace/Service_Object.cpp: + * ace/Sock_Connect.cpp: + Added missing includes + + * ace/Notification_Queue.cpp: + * ace/Notification_Queue.inl: + Added missing versioned namespace macros + +Thu Apr 10 06:41:57 UTC 2008 Johnny Willemsen + + * ace/Service_Gestalt.h: + Added include of Guard_T.h + + * include/makeinclude/platform_linux_pgi.GNU: + Updated for latest pgCC version + +Thu Apr 10 00:50:53 UTC 2008 Iliyan Jeliazkov + + * tests/Bug_2980_Regression_Test.cpp: + * tests/tests.mpc: + + Fixing a compile problem with no-threads builds. + +Wed Apr 9 22:05:30 UTC 2008 Iliyan Jeliazkov + + * ace/Svc_Conf.h: + * ace/Svc_Conf.y: + * ace/Svc_Conf_Lexer.h: + * ace/Svc_Conf_Lexer.cpp: + * ace/Svc_Conf_Param.h: + * ace/Svc_Conf_Tokens.h: + * ace/Svc_Conf_y.cpp: + * ace/svcconf.mpb: + + Simplified the build sequence reducing the number of additional + transformations needed for Bison's parser output. That includes + the elimination of the ACE_YY prefix, which was necessary only + because of these transformations. Added ACE_TEXT around naked + string literals. Fixed build warnings with unicode builds. + +Wed Apr 9 20:22:46 UTC 2008 Iliyan Jeliazkov + + * ace/Service_Repository.cpp: + Fixing relocate_i to both account for empty slots _and_ provide + useful logging. + +Wed Apr 9 18:24:57 UTC 2008 Johnny Willemsen + + * bin/tao_orb_tests.lst: + Don't run 3171 with CORBA/e micro + +Wed Apr 9 11:50:27 UTC 2008 Chad Elliott + + * bin/MakeProjectCreator/modules/VXTestProjectCreator.pm: + + Added a need_to_write_project override method to only allow the + project file to be written if it is an executable project. + + * bin/MakeProjectCreator/modules/VXTestWorkspaceCreator.pm: + + Fixed a bug where an invalid base module was used in the @ISA. + +Wed Apr 9 11:41:57 UTC 2008 Johnny Willemsen + + * tests/Bug_2980_Regression_Test.cpp: + Check for ACE_VXWORKS + +Wed Apr 9 11:11:57 UTC 2008 Johnny Willemsen + + * ace/Svc_Conf_y.cpp: + Fixed unicode build problems + +Wed Apr 9 08:06:57 UTC 2008 Johnny Willemsen + + * ace/Svc_Conf.y: + * ace/Svc_Conf_y.cpp: + Fixed unicode build problems + +Wed Apr 9 07:18:57 UTC 2008 Johnny Willemsen + + * ace/Service_Config.h: + Export ACE_Threading_Helper, it is used as protected class + member + + * ace/Service_Gestalt.cpp: + Don't use ACE_LIB_TEXT + + * ace/High_Res_Timer.h: + * ace/Based_Pointer_T.h: + Doxygen changes + + * ace/Naming_Context.cpp: + Fixed gcc 4.3 warning + + * ace/OS_NS_errno.h (last_error): + Give the argument a name so that doxygen can do its work + + * ace/Select_Reactor_T.cpp: + Use scoping + + * ace/MMAP_Memory_Pool.{h,cpp}: + Add a bool flag to indicate whether the signal handler has to + be installed or not. Made some other flags bool and win32 there + is no need have a signal handler as member. This fixes bugzilla + 3290 + +Wed Apr 9 02:43:37 UTC 2008 Iliyan Jeliazkov + + * ace/Dynamic_Service.inl (instance): + Adjusting interface to take a smart pointer. + + * ace/OS_NS_unistd.cpp (argv_to_string): + Adding interpretation for tabs and new line characters as + characters to trigger quoting. + + * ace/Service_Config.h: + * ace/Service_Config.cpp: + * ace/Service_Gestalt.h: + * ace/Service_Gestalt.inl: + * ace/Service_Gestalt.cpp: + * ace/Service_Repository.cpp: + Reformatting, updating comments and logging. + +Wed Apr 9 01:21:42 UTC 2008 Douglas C. Schmidt + + * ace/Condition_T.cpp (wait): Fixed a bug where the mutex + parameter wasn't being used properly if abstime was 0. Thanks + to Andriy Gapon for reporting this. + +Mon Apr 7 18:49:57 UTC 2008 Johnny Willemsen + + * bin/MakeProjectCreator/docs/templates/gnu.txt: + Document linkflags + +Mon Apr 7 15:21:38 UTC 2008 Iliyan Jeliazkov + + This the second part of the SC refatoring. It builds on top of + the intrusive refcounting mechanism introduced earlier to improve + design and eliminate memory issues (leaks, SEGV on shutdown) + + * ace/Service_Config.cpp (open_i,ACE_Service_Config): + + Moved the implicit configuration file handling from open_i to + the SG instance. Eliminated close_svcs() by incorporating its + functionality in close(). + + * ace/Service_Config.inl: + * ace/Service_Config.h (ACE_Service_Config_Guard,ACE_Service_Config): + + Removing the inheritance relationship between Service Config and + Service Gestalt. To simplify the memory management, SC becomes an + interface to the actual configuration data managed by SG. Coupled + with the reference counting of SG instances, this ensures correct + memory management in multi-threaded environments where both the + TSS and the user code may trigger SG finalization. + + Introducing ACE_Threading_Helper to simplify TSS management + (RAII idiom). Changed ACE_Service_Config_Guard to use the new + smart pointer for SG. Doxygen comments cleanup. + + * ace/Svc_Conf.y: + * ace/Svc_Conf_y.cpp: + + Fixing unused function definition + + * tests/Bug_2980_Regression_Test.cpp: + + Updating the test to prevent it from breaking vxWorks builds + which appear to lack a declaration for dlopen() + +Sun Apr 6 01:53:13 UTC 2008 Iliyan Jeliazkov + + * ace/Service_Gestalt.cpp: + + Fixing unused variable warning. + + * ace/Svc_Conf_y.cpp: + * ace/svcconf.mpb: + + Ensuring there are no TAB characters present in the generated + file. + + * tests/run_test.lst: + + Excluding Bug_2980_Regression as it is not runnable on vxWorks. + +Sat Apr 5 16:21:50 UTC 2008 Iliyan Jeliazkov + + * ace/Service_Config.inl: + * ace/Service_Config.cpp: + * ace/Service_Gestalt.cpp: + * ace/Service_Gestalt.h: + + Making SG intrusively refcountable by introducing + intrusive_{add,remove}_ref methods and a refcounter. Adding + skip_default_svc_conf_file parameter in process_directives. + + * ace/svcconf.mpb: + * tests/Object_Manager_Flipping_Test.cpp: + + Reformatting and cleanup. + +Sat Apr 5 13:42:57 UTC 2008 Johnny Willemsen + + * tests/Bug_2980_Regression_Test.cpp: + Fixed argument not used warnings + +Sat Apr 5 13:36:57 UTC 2008 Johnny Willemsen + + * ace/Parse_Node.cpp: + Moved include out of versioned namespace block + +Sat Apr 5 11:50:40 UTC 2008 Iliyan Jeliazkov + + * ace/Parse_Node.cpp: + * ace/Svc_Conf.y: + * ace/Svc_Conf_Tokens.h: + * ace/Svc_Conf_y.cpp: + + Replacing ACE_LIB_TEXT with ACE_TEXT + +Fri Apr 4 21:43:35 UTC 2008 Iliyan Jeliazkov + + * THANKS: + + Adding Michael Carter for reporting + and debugging bug 3007. + + * ace/Base_Thread_Adapter.h: + * ace/Base_Thread_Adapter.cpp: + + Storing a pointer to SG that was current in the parent thread, + which enables correct "inheritance" of the SG in the child thread. + + * ace/Parse_Node.h: + * ace/Parse_Node.cpp: + + Fixing ACE_Stream_Node::{apply,link} to ensure the modules are linked + together and initialized correctly - see bug# 2916. Moving the + initialization code out of the yacc parser, here. + + * ace/Service_Object.cpp: + * ace/Service_Types.cpp: + + Improving the log output in fini(). + + * ace/Service_Repository.h: + + Eliminating an unused parameter static_only from relocate_i() + + * ace/Service_Repository.cpp: + + Simplified relocate_i() and fixed an error that was causing it to + choose incorrect ranges of service indexes to relocate. + Eliminated the boolean static_only parameter as it was always + being set to true. Changed remove() to eliminate the "packing" + code and updated the few other methods, which assumed there are no + "gaps" in the service storage. + + * ace/Svc_Conf.h: + * ace/Svc_Conf.y: + * ace/Svc_Conf_Tokens.h: + * ace/Svc_Conf_y.cpp: + + Adding an overloaded yyerror that takes just a string to comply + with the changed bison template. Moving the module initialization + code out of the parser. See ACE_Stream_Node class and bug# 2916. + + * ace/Thread_Adapter.cpp: + + The invoke() method, which runs in the new thread, initializes the + thread-specific configuration context. This scheme ensures any + newly spawned thread would inherit the spawning thread's service + configuration context. + + * ace/ace.mpc: + + Adding Intrusive_Auto_Ptr to the list. + + * ace/svcconf.mpb: + + Updated for the grammar updates, see bug# 2916. + + * examples/ASX/CCM_App/ASX_CCM_App.mpc: + * examples/ASX/CCM_App/CCM_App.cpp: + + The DLL names are case-sensitive on *nix. Minor layout changes. + + * tests/Object_Manager_Flipping_Test.cpp: + + Updated to use the Intrusive_Auto_Ptr + + * tests/run_test.lst: + * tests/tests.mpc: + + Adding Bug_2980_Regression_Test + +Fri Apr 4 18:27:57 UTC 2008 Johnny Willemsen + + * configure.ac: + Fixed iostream detection. This fixes bugzilla 3288 + This to Thomas Girard + for reporting this. + +Thu Apr 3 14:13:57 UTC 2008 Johnny Willemsen + + * include/makeinclude/platform_vxworks5.5.x.GNU: + * include/makeinclude/platform_vxworks6.2.GNU: + * include/makeinclude/platform_vxworks6.3.GNU: + Changed the make variable from which we zap the -ansi and also support + this with the diab compiler + +Thu Apr 3 09:40:00 UTC 2008 Simon Massey + + * apps/JAWS/stress_testing/benchd.cpp: + + Using "interface" as the descriptive name of a parameter seems to + cause VC8 (when building with MFC) to assume you mean a struct type + and it raises an incorrect systax error. + +Thu Apr 3 07:05:57 UTC 2008 Johnny Willemsen + + * bin/MakeProjectCreator/templates/gnu.mpd: + Generate link_groups also when staticflags are not set + +Wed Apr 2 21:40:00 UTC 2008 J.T. Conklin + + * configure.ac: + + Fix typo in ACE_HAS_BSWAP_{16,32,64} feature tests. + This to Thomas Girard + for reporting this. + +Wed Apr 2 20:22:50 UTC 2008 Iliyan Jeliazkov + + * ace/Intrusive_Auto_Ptr.h: + * ace/Intrusive_Auto_Ptr.inl: + + Correcting a problem with VC71 + +Wed Apr 2 11:06:30 UTC 2008 Vladimir Zykov + + * bin/tao_orb_tests.lst: + + Enabled a TAO/tests/Collocated_Forwarding on vxworks and + vxworks_rtp. + +Wed Apr 2 09:05:57 UTC 2008 Johnny Willemsen + + * include/makeinclude/platform_vxworks5.5.x.GNU: + * include/makeinclude/platform_vxworks6.2.GNU: + * include/makeinclude/platform_vxworks6.3.GNU: + Add no_cflags_ansi and no_ccflags_ansi which if set do remove the + -ansi compiler flag + +Wed Apr 2 08:14:57 UTC 2008 Johnny Willemsen + + * ace/config-linux-common.h: + Replaced ACE_HAS_VOIDPTR_GETTIMEOFDAY with + ACE_HAS_TIMEZONE_GETTIMEOFDAY, this fixes bugzilla 3145 + This to Thomas Girard + for reporting this + +Wed Apr 2 07:51:57 UTC 2008 Johnny Willemsen + + * tests/run_test.lst: + Enabled a few tests on VxWorks again, in the past rebooting a + crashed target was problematic but that is not an issue anymore + +Tue Apr 1 14:20:34 UTC 2008 Vladimir Zykov + + * bin/tao_orb_tests.lst: + Added a new test for collocated forwarding case. + +Tue Apr 1 12:58:57 UTC 2008 Johnny Willemsen + + * bin/tao_other_tests.lst: + Added OBV typed event test + +Tue Apr 1 12:52:57 UTC 2008 Johnny Willemsen + + * bin/tao_orb_tests.lst: + Add the DSI Gateway exception test, they should run, the scoreboard + will show if they run + +Tue Apr 1 08:33:57 UTC 2008 Johnny Willemsen + + * include/makeinclude/platform_openvms.GNU: + Set ACE_OPENVMS_IA64 on Itanium + + * include/makeinclude/rules.lib.GNU: + Only use a special AR rule on OpenVMS IA64 + +Tue Apr 1 07:38:57 UTC 2008 Johnny Willemsen + + * tests/Intrusive_Auto_Ptr_Test.cpp: + Fixed argument not used warning + +Tue Apr 1 07:34:57 UTC 2008 Johnny Willemsen + + * bin/tao_other_tests.lst: + Enabled a few tests for vxworks + +Tue Apr 1 07:12:57 UTC 2008 Johnny Willemsen + + * tests/Reactor_Dispatch_Order_Test.cpp: + Only run the reactor once, this will lead to the failing of this test + when using the WFMO Reactor which seems to be a old issue that needs + to get addressed + +Tue Apr 1 06:54:57 UTC 2008 Johnny Willemsen + + * bin/tao_other_tests.lst: + Disabled most tests for vxworks and vxworks_rtp, we first need to + convert a lot of scripts to support vxworks + +Mon Mar 31 21:48:58 UTC 2008 J.T. Conklin + + * configure.ac: + + Changed to avoid feature test for pthread_getaffinity_np() and + pthread_setaffinity_np() if system does not have cpu_set_t. In + that case, the pthread functions are amost certainly not + compatible. + + * ace/Makefile.am: + + Add Intrusive_Auto_Ptr.cpp, Intrusive_Auto_Ptr.h, and + Intrusive_Auto_ptr.inl to nobase_include_HEADERS. + +Mon Mar 31 18:56:40 UTC 2008 Iliyan Jeliazkov + + * ace/Refcounted_Auto_Ptr.h: + * ace/Refcounted_Auto_Ptr.inl: + * ace/Refcounted_Auto_Ptr.cpp: + + Reverting the changes because a) they are not really necessary + for the refactoring of the service config, and; b) the AIX + compiler appears to not deal well with implicit conversion + definitions, to template member types. + +Mon Mar 31 16:15:17 UTC 2008 Iliyan Jeliazkov + + * tests/tests.mpc: + + Adding Intrusive_Auto_Ptr_Test to the list + +Mon Mar 31 14:52:58 UTC 2008 Iliyan Jeliazkov + + * ace/Intrusive_Auto_Ptr.h: + * ace/Intrusive_Auto_Ptr.cpp: + * ace/Refcounted_Auto_Ptr.h: + * ace/Refcounted_Auto_Ptr.inl: + * ace/Refcounted_Auto_Ptr.cpp: + + Added preprocessor guards for proper inlining. Qualified + the type name in the implementation of opretator + unspecified_bool_type () to appease GCC 3.x + +Mon Mar 31 13:50:45 UTC 2008 Iliyan Jeliazkov + + * tests/run_test.lst: + + Adding Intrusive_Auto_Ptr_Test to the list + +Mon Mar 31 12:09:20 UTC 2008 Chad Elliott + + * bin/MakeProjectCreator/modules/AutomakeWorkspaceHelper.pm: + + Always reference Kokyu libraries from $(ACE_BUILDDIR) instead of + $(top_builddir) so that it will work from both ACE and TAO. + +Mon Mar 31 11:00:57 UTC 2008 Johnny Willemsen + + * tests/Bug_2980_Regression_Dll.cpp: + * tests/Bug_2980_Regression_Test.cpp: + Fixed fuzz errors + +Mon Mar 31 08:59:57 UTC 2008 Johnny Willemsen + + * tests/OS_Test.cpp: + Added test for ACE_OS::last_error() + +Sun Mar 30 19:54:23 UTC 2008 Iliyan Jeliazkov + + This is the first step of merging the changes from the gestalt + refactoring branch. It includes only changes that are merely + peripheral, without impacting the actual configuration mechanism + - yet. + + * ace/ARGV.h: + * ace/ARGV.cpp: + + Introducing a ctor that takes the number of parameters in argv, + thus eliminating the requirement to have argv 0-terminated. This + requirement can be a hard to satisfy in cases where the argv has + been "manualy constructed", i.e. not provided by the OS + environment. + + * ace/Intrusive_Auto_Ptr.h: + * ace/Intrusive_Auto_Ptr.inl: + * ace/Intrusive_Auto_Ptr.cpp: + + Added an intrusive auto pointer implementation. It is a reference + counted auto pointer that can be used for types with explicit + reference management implementations. + + * ace/OS_NS_unistd.h: + * ace/OS_NS_unistd.cpp: + + Introducing new argv_to_string which takes an explicit argc + argument and relaxes the requirement on argv (to be 0-terminated). + + * ace/Refcounted_Auto_Ptr.h: + * ace/Refcounted_Auto_Ptr.inl: + + Adding a mechanism that provides a correct conversion to boolean + for smart pointers, which preserves the smantics of "if (ap) ..." + without the unwanted side effects. Credit goes to Andrei + Alexandrescu's Modern C++ Design book. + + * ace/Service_Types.cpp: + + Cosmetics: adding this-> to member references. + + * examples/ASX/CCM_App/ASX_CCM_App.mpc: + * examples/ASX/CCM_App/CCM_App.cpp: + + Fixing a problem that precludes the test from running correctly + on *nix - the DLL names are not case-insensitive. Minor layout + changes. + + * tests/Intrusive_Auto_Ptr_Test.cpp: + + A test for the new auto ptr. + + * tests/Bug_2980_Regression_Dll.cpp: + * tests/Bug_2980_Regression_Test.cpp: + * tests/run_test.lst: + * tests/tests.mpc: + + Addded a test for bug 2980. Thanks to Lothar Werzinger for contributing the code. + +Sun Mar 30 18:54:57 UTC 2008 Johnny Willemsen + + * bin/PerlACE/ProcessVX_Win32.pm: + Handle single quotes in the executable arguments + +Sat Mar 29 08:16:57 UTC 2008 Johnny Willemsen + + * tests/Reactor_Dispatch_Order_Test.cpp: + Dev_Poll reactor displays other bugs, so disable this part of + the test + + * ace/Select_Reactor_Base.cpp: + Position the iterator on the first element that is none zero, fixes + crashing of the reactor_dispatch_order_test on non windows platforms + +Fri Mar 28 17:18:50 UTC 2008 Steve Huston + + * ace/CDR_Stream.cpp (write_long_placeholder, write_short_placeholder): + Be careful to adjust and grow the stream's block before taking + the pointer that's returned to the user. Thanks to Alain Kocelniak + for this fix. + + * ace/CDR_Stream.h: Note that the placeholder methods return 0 if + the method fails due to insufficient memory. + + * THANKS: Added Alain Kocelniak to the Hall of Fame. + +Fri Mar 28 15:40:03 UTC 2008 Chad Elliott + + * tests/unload_libace.mpb: + + Inhert from vc_warnings instead of duplicating part of it's + functionality. + +Fri Mar 28 09:24:25 UTC 2008 Vladimir Zykov + + * bin/tao_orb_tests.lst: + + Enabled a test to Bug_3276_Regression. + +Fri Mar 28 09:17:57 UTC 2008 Johnny Willemsen + + * tests/Reactor_Dispatch_Order_Test.cpp: + Extended this test to also test suspend/resume_handlers and the + dev_poll reactor. Thanks to Russell Morra for extending this test + + * ace/ACE.cpp: + * ace/High_Res_Timer.inl: + Layout changes + + * ace/Hash_Map_Manager_T.cpp: + Use prefix increment instead of postfix + + * ace/High_Res_Timer.h: + * ace/Reactor.h: + * ace/Select_Reactor_Base.h: + Doxygen changes + + * ace/Select_Reactor_Base.inl: + Fixed done implementation. This fixes bugzilla 3267 + + * ace/String_Base.cpp: + Initialise pointer with 0 + + * ace/WFMO_Reactor.{h,cpp,inl}: + Bool changes, fixed implementation of suspend_handlers/resume_handlers, + the to_be_added set modifications where not done correctly + +Thu Mar 27 19:09:57 UTC 2008 Johnny Willemsen + + * bin/tao_orb_tests.lst: + * bin/tao_other_tests.lst: + Diabled 3251/3252 in a static build + +Thu Mar 27 16:27:44 UTC 2008 Adam Mitz + + * ace/Object_Manager.cpp: + + In Win32 debug builds with ACE_DISABLE_WIN32_ERROR_WINDOWS, also + redirect assert messages to stderr instead of GUI message boxes. + +Thu Mar 27 16:17:57 UTC 2008 Johnny Willemsen + + * docs/ACE-bug-process.html: + * docs/ACE-development-process.html: + * docs/ACE-guidelines.html: + * docs/usage-bugzilla.html: + Updated bugzilla location + +Thu Mar 27 15:52:57 UTC 2008 Johnny Willemsen + + * bin/MakeProjectCreator/modules/VXTestProjectCreator.pm: + * bin/MakeProjectCreator/modules/VXTestWorkspaceCreator.pm: + * bin/MakeProjectCreator/templates/vxtest.mpd: + New MPC generator called vxtest. This will generate the loading + of the downloadable kernel modules for an application. + +Thu Mar 27 14:07:27 UTC 2008 J.T. Conklin + + * configure.ac: + + #include in ACE_HAS_BSWAP_{16,32,64} feature tests. + Resolves bugzilla issue #3134. + +Thu Mar 27 12:54:57 UTC 2008 Johnny Willemsen + + * include/makeinclude/platform_vxworks6.3.GNU: + Small change to get the VxWorks shared library build further + +Thu Mar 27 12:46:48 UTC 2008 Chad Elliott + + * tests/SSL/Thread_Pool_Reactor_SSL_Test.cpp: + + Changed ACE_TMAIN to run_main for the non-threaded portion of the + #ifdef. ACE_TMAIN is defined in Main.cpp. + +Thu Mar 27 12:37:18 UTC 2008 Chad Elliott + + * ASNMP/asnmp/snmperrs.h: + + Added an unknown error code message to the pErrs array to avoid + getting a garbage pointer from Snmp::error_string() in the event + that the error code is outside the valid range. + +Thu Mar 27 11:11:57 UTC 2008 Johnny Willemsen + + * ace/Free_List.cpp: + Fixed ambiguous else with GCC 4.3. Thanks to Jules Colding + for reporting this + +Thu Mar 27 10:36:18 UTC 2008 Simon McQueen + + * include/makeinclude/wrapper_macros.GNU: + + Make it possible to specify an alternate name / location for + platform_macros.GNU. This fixes bug #3269. + +Wed Mar 26 15:32:01 UTC 2008 Adam Mitz + + * bin/MakeProjectCreator/templates/gnu.mpd: + + Corrected my change from yesterday so that it works properly for + executable projects that pull in source files from other directories. + +Tue Mar 25 18:02:52 UTC 2008 Chad Elliott + + * ASNMP/asnmp/wpdu.cpp: + + Added an intermediate integer to avoid type-punned pointer + dereferencing. + +Tue Mar 25 14:19:31 UTC 2008 Adam Mitz + + * bin/MakeProjectCreator/templates/gnu.mpd: + + When generating the linker command line for executable linked against + static libs, exclude the "libFoo.a" form of the libraries. They are + already accounted for by "-lFoo" arguments. This resolved Bugzilla + Bug #3266. + +Tue Mar 25 10:43:57 UTC 2008 Johnny Willemsen + + * netsvcs/lib/Server_Logging_Handler.cpp: + Corrected static template member instantiation to resolve compile + error on OpenVMS Alpha + +Tue Mar 25 10:12:57 UTC 2008 Johnny Willemsen + + * include/makeinclude/platform_openvms.GNU: + Disable warnings on IA64 without using GNV, that doesn't work + in all cases + +Tue Mar 25 09:08:57 UTC 2008 Johnny Willemsen + + * ace/INET_Addr.cpp: + Detect sockets that are bigger then ACE_MAX_DEFAULT_PORT. + Thanks to Patrick Rabau for + reporting this. This fixes bugzilla 3264 + + * tests/INET_Addr_Test.cpp: + Added a test for an overflow of the port number + + * ace/Hash_Map_Manager_T.{h,inl}: + Changed head argument of the iterators to a bool + + * ace/Reactor.h: + * ace/Reactor_Impl.h: + Doxygen changes + +Tue Mar 25 00:38:33 UTC 2008 J.T. Conklin + + * ace/Makefile.am: + + Add Configuration.inl to nobase_include_HEADERS. + +Mon Mar 24 16:21:30 UTC 2008 Douglas C. Schmidt + + * ace/OS_NS_Thread.cpp (event_timedwait): Fixed this code so that + it will treat 0 using "wait indefinitely" semantics for Windows + and all other OS platforms. Thanks to Paul Carter for contributing this. + +Mon Mar 24 16:13:51 UTC 2008 Douglas C. Schmidt + + * tests/Manual_Event_Test.cpp (worker): Added a test to ensure + that a null pointer works properly for the + ACE_Manual_Event::wait() method. Thanks to Paul Carter for contributing this. + +Mon Mar 24 15:43:28 UTC 2008 Abdullah Sowayan + + * bin/MakeProjectCreator/config/MPC.cfg: + + MPC can now be configured to recognize ACE_TMAIN as an executable + entry point. We no longer need to explicitly state that a project will + be an executable in the MPC file, MPC will automatically deduce that + the project is an executable given the presence of ACE_TMAIN. + + This change above relates to the following change in MPC: + Mon Mar 24 15:18:28 UTC 2008 Chad Elliott + +Mon Mar 24 02:25:58 UTC 2008 Douglas C. Schmidt + + * COPYING: Updated the license a bit based on feedback from Tom + Callaway" . These changes will + enable ACE+TAO to be shipped with Fedora. + +Fri Mar 21 16:12:53 UTC 2008 Steve Huston + + * ace/OS_NS_unistd.cpp (num_processors_online): Count the online + processors for Windows, not just the number present. + + * tests/OS_Test.cpp: Sanity-check the num_processors_online() value. + +Fri Mar 21 15:10:57 UTC 2008 Johnny Willemsen + + * ace/FoxReactor/FoxReactor.cpp: + Fix 64bit issues, this fixes bugzilla 3248 + This to Thomas Girard + for reporting this + +Fri Mar 21 10:46:57 UTC 2008 Johnny Willemsen + + * m4/ace.m4: + Changed gperf check + + * apps/Makefile.aml: + Updated gperf check. This fixes bugzilla 3249. + This to Thomas Girard + for reporting this + +Fri Mar 21 10:06:57 UTC 2008 Johnny Willemsen + + * ace/config-vxworks.h: + If ACE_VXWORKS is not defined try to figure out which vxworks + version we are using based on some vxworks version defines + + * ace/Select_Reactor_Base.h: + Doxygen changes and made the constructor of + ACE_Select_Reactor_Handler_Repository_Iterator explicit + + * ace/Process.{h,cpp}: + Layout change + +Thu Mar 20 15:34:18 UTC 2008 Chad Elliott + + * bin/MakeProjectCreator/config/acedefaults.mpb: + + Changed the ACE_LD_DECORATOR_STR macro to use $(LIBMODIFIER) + instead of $(ILIBMODIFIER) for the bmake project type. + +Thu Mar 20 12:42:57 UTC 2008 Johnny Willemsen + + * ace/Addr.h: + Layout change + + * ace/High_Res_Timer.cpp: + Changed supported flag to a bool + + * ace/INET_Addr.h: + Doxygen change + + * ace/Svc_Conf.h: + Moved regular include before pragma once + +Wed Mar 19 13:45:00 UTC 2008 Simon Massey + + * ace/tao_orb_tests.lst: + Remove TAO/tests/Bug_1482_Regression from LynxOS. + +Wed Mar 19 11:41:57 UTC 2008 Johnny Willemsen + + * ace/Process_Manager.h: + * ace/Semaphore.h: + * ace/SOCK.h: + * ace/SOCK_IO.h: + Doxygen changes + + * ace/Service_Gestalt.h: + Removed not needed forward declaration + + * ace/OS_NS_Thread.h: + Layout change + +Tue Mar 18 20:17:55 UTC 2008 Steve Huston + + * bin/PerlACE/ProcessLVRT.pm: + * bin/PerlACE/TestTarget_LVRT.pm: Handle timeouts to the target better + and smarten up the way it gets log files from a failed target. + + * bin/PerlACE/TestTarget.pm: + * bin/PerlACE/TestTarget_LVRT.pm: Add a GetFile() method to get a file + from the target to the local machine. By default, it does nothing. + It's meant for use by targets that don't necessarily have locally + accessible file systems, such as LabVIEW RT. + + * bin/Run_Test.pm: + * bin/PerlACE/Process_Win32.pm: Add support for running tests on + LabVIEW RT similarly to the way they're done on VxWorks; TAO tests + run the server on the target and the client on the host. + + * bin/LabVIEW_RT/labview_test_controller/labview_test_controller.cpp: + Catch exceptions and try to report it to stderr before the machine + locks up, dies, etc. + +Tue Mar 18 07:33:57 UTC 2008 Johnny Willemsen + + * include/makeinclude/platform_openvms.GNU: + Removed -Wc/DISTINGUISH_NESTED_ENUMS, only needed for one test + +Mon Mar 14 09:17:57 UTC 2008 Johnny Willemsen + + * bin/tao_other_tests.lst: + Added 3252 + +Mon Mar 14 09:07:57 UTC 2008 Johnny Willemsen + + * bin/tao_orb_tests.lst: + Added 3251 + +Fri Mar 14 19:57:57 UTC 2008 Johnny Willemsen + + * include/makeinclude/platform_aix_g++.GNU: + Improved support for buildbits=64 + +Fri Mar 14 19:09:57 UTC 2008 Johnny Willemsen + + * ace/INET_Addr.cpp: + Fixe warning with GCC 4.2 on AIX + +Fri Mar 14 19:07:57 UTC 2008 Johnny Willemsen + + * include/makeinclude/platform_aix_g++.GNU: + Disable visibility by default. With GCC 4.2 on AIX we get warnings + that visibility is not supported in that configuration + +Fri Mar 14 15:02:33 UTC 2008 Ciju John + + * bin/tao_other_tests.lst: + Turn on the Notify Persistent_POA test. + +Fri Mar 14 09:30:57 UTC 2008 Johnny Willemsen + + * include/makeinclude/platform_aix_g++.GNU: + Don't use -mcpu=common, that is an ancient default of AIX 5.1 + +Thu Mar 13 12:41:57 UTC 2008 Johnny Willemsen + + * include/makeinclude/platform_aix_g++.GNU: + Fixed support for buildbits=32/64 + +Wed Mar 12 19:49:57 UTC 2008 Johnny Willemsen + + Reverted the gperf change below, breaks all autoconf builds + + Wed Mar 12 06:55:57 UTC 2008 Johnny Willemsen + * m4/ace.m4: + Added enable-aio, enable-ipo and fixed gperf handling. + This to Thomas Girard + for reporting this + +Wed Mar 12 15:08:57 UTC 2008 Johnny Willemsen + + * bin/PerlACE/ProcessVX.pm: + Fix retry mechanism for the iBoot bar + +Wed Mar 12 12:59:57 UTC 2008 Johnny Willemsen + + * m4/ace.m4: + Added support for fox, thanks to Thomas Girard + for reporting this. + This fixes bugzilla 3147 + +Wed Mar 12 11:59:57 UTC 2008 Johnny Willemsen + + * ace/FoxReactor/FoxReactor.{h,cpp}: + Removed check for ACE_HAS_FOX + + * include/makeinclude/wrapper_macros.GNU: + Changed fox handling, matches the other reactors. Thanks to + Thomas Girard for + reporting this. This resolves bugzilla 3248 + + * include/makeinclude/platform_aix_ibm.GNU: + Added support for Visual Age 9 + +Wed Mar 12 11:53:57 UTC 2008 Johnny Willemsen + + * ace/FoxReactor/FoxReactor.h: + Added missing include, thanks to Thomas Girard + for reporting this + +Wed Mar 12 07:07:57 UTC 2008 Johnny Willemsen + + * ace/FoxReactor/FoxReactor.cpp: + Fixed compile errors, thanks to Thomas Girard + for reporting this + +Wed Mar 12 06:59:57 UTC 2008 Johnny Willemsen + + * ace/ace.mwc: + * bin/MakeProjectCreator/config/global.features: + Added fox reactor, thanks to Thomas Girard + for reporting this + +Wed Mar 12 06:55:57 UTC 2008 Johnny Willemsen + + * m4/ace.m4: + Added enable-aio, enable-ipo and fixed gperf handling. + This to Thomas Girard + for reporting this + +Tue Mar 11 12:24:43 UTC 2008 Steve Huston + + * ace/Svc_Conf.h: Add #include "ace/config.h" so a setting for + ACE_LACKS_PRAGMA_ONCE can be seen. Fixes compile warnings. + +Tue Mar 11 12:20:02 UTC 2008 Steve Huston + + * ace/Log_Msg.cpp (log): Fixed compile error. No need to use + ACE_TEXT_ALWAYS_CHAR for a char* literal. + +Mon Mar 10 22:27:09 UTC 2008 Nanbor Wang + + * ace/Svc_Conf.h: Removed redundant inclusion of Obstack.h. It is + included later in Svc_Conf_Param.h. Removing this extra + inclusion allows us to build on MacOS Leopard with optimization + enabled. + +Mon Mar 10 15:35:02 UTC 2008 Steve Huston + + * ace/Log_Msg.{h cpp} (log): For %C, clearly note that it always prints + a narrow-char string, and adjust the va_arg to match. Thanks to + Russell Morra for reporting this issue. + +Mon Mar 10 13:20:57 UTC 2008 Johnny Willemsen + + * tests/Multicast_Test.cpp: + When sending fails, print the ip address we are using in the error + message. + +Sat Mar 8 16:23:57 UTC 2008 Douglas C. Schmidt + + * ace/WIN32_Asynch_IO.cpp (send): Enhanced the code to allow sends + of 0-sized datagrams. Thanks to Andi Heusser for this fix. + +Thu Mar 6 16:49:18 UTC 2008 Johnny Willemsen + + * include/makeinclude/rules.lib.GNU: + Rearranged some rules to make sure c/C files are compiled with the + C compiler on OpenVMS + +Thu Mar 6 13:10:18 UTC 2008 Johnny Willemsen + + * include/makeinclude/platform_openvms.GNU: + Improved this file + +Thu Mar 6 10:33:18 UTC 2008 Johnny Willemsen + + * include/makeinclude/platform_openvms.GNU: + Removed restriction that only a shared or static build can be done + +Wed Mar 5 07:54:18 UTC 2008 Johnny Willemsen + + * bin/tao_orb_tests.lst: + Don't run the parallel connect strategy test on VxWorks 5.5, the + command length of the shell is not long enough. + +Tue Mar 4 09:27:18 UTC 2008 Johnny Willemsen + + * bin/ProcessVX.pm: + Added a retry to the iPass protocol code, in a full test run + we sometimes see that the reboot has failed. With this retry + we hopefully get rid of those false test failures + +Tue Mar 4 05:54:22 UTC 2008 William Otte + + * bin/svn_props.py: + Automatically set default properties when svn complains. + +Mon Mar 3 11:22:18 UTC 2008 Johnny Willemsen + + * bin/MakeProjectCreator/templates/bor.mpd: + Just single line comments + + * bin/MakeProjectCreator/templates/gnu.mpd: + Check VXWORKSLINK for 1 + +Mon Mar 3 11:10:18 UTC 2008 Johnny Willemsen + + * include/makeinclude/platform_vxworks5.5.x.GNU: + * include/makeinclude/platform_vxworks6.2.GNU: + * include/makeinclude/platform_vxworks6.3.GNU: + * include/makeinclude/rules.bin.GNU: + * include/makeinclude/rules.lib.GNU: + Use 1 for VXWORKSLINK instead of true. Added footprint=1 + as flag to specify that you are doing a footprint build + +Mon Mar 3 10:49:28 UTC 2008 Abdullah Sowayan + + * apps/JAWS/clients/WebSTONE/src/cgi-send.c: + * apps/JAWS/clients/WebSTONE/src/genrand.c: + * apps/JAWS/clients/WebSTONE/src/webmaster.c: + * contrib/utility/Example/CommandLine/Foo/command.cpp: + * contrib/utility/Example/ExH/BadCast/bad_cast.cpp: + * contrib/utility/Example/ExH/Compound/compound.cpp: + * contrib/utility/Example/ExH/HelloWorld/hello_world.cpp: + * contrib/utility/Example/ExH/LogicToSystem/logic_to_system.cpp: + * contrib/utility/Example/Hetero/Container/container.cpp: + * contrib/utility/Example/Introspection/InheritanceTree/inheritance_tree.cpp: + * contrib/utility/Example/Introspection/Traversal/driver.cpp: + * contrib/utility/Test/ExH/Converter/converter.cpp: + * contrib/utility/Test/ExH/Inline/inline.cpp: + * contrib/utility/Test/ExH/Logic/DescriptiveException/descriptive_exception.cpp: + * contrib/utility/Test/ExH/System/DescriptiveException/descriptive_exception.cpp: + * contrib/utility/Test/Introspection/Inline/inline.cpp: + * contrib/utility/Test/Synch/Inline/inline.cpp: + * etc/xlc_dummy.cpp: + * examples/Reactor/Proactor/test_aiocb.cpp: + * examples/Reactor/Proactor/test_aiosig.cpp: + + Disable fuzz's check_for_improper_main_declaration check on these files. + These files don't use ACE. + + * examples/Reactor/WFMO_Reactor/Multithreading.cpp: + * examples/Reactor/WFMO_Reactor/Registration.cpp: + * examples/Reactor/WFMO_Reactor/Registry_Changes.cpp: + * examples/Threads/task_three.cpp: + + Use the proper form of ACE_TMAIN. Namely, the argv parameter + should be "ACE_TCHAR *argv[]" instead of "ACE_TCHAR **argv" + or "ACE_TCHAR *[]" instead of "ACE_TCHAR **" + + * apps/JAWS3/bench/average.cpp: + * netsvcs/clients/Tokens/invariant/invariant.cpp: + + Use ACE_TMAIN instead of main as the program entry point to comply + with ACE/TAO/CIAO coding standards. + +Mon Mar 3 08:58:18 UTC 2008 Johnny Willemsen + + * include/makeinclude/platform_openvms.GNU: + Improved this file + +Mon Mar 3 07:30:18 UTC 2008 Johnny Willemsen + + * include/makeinclude/platform_openvms.GNU: + Don't set INSLIB + +Mon Mar 3 07:00:18 UTC 2008 Johnny Willemsen + + * include/makeinclude/rules.local.GNU: + Rearranged some rules so that C files are compiled with the + C compiler on OpenVMS + +Mon Mar 3 06:57:18 UTC 2008 Johnny Willemsen + + * bin/ProcessVX.pm: + Added support to specify a custom password for the iBoot + +Sun Mar 2 20:04:18 UTC 2008 Johnny Willemsen + + * bin/ProcessVX.pm: + Integrated some OCI changes for the iBoot + +Sun Mar 2 19:32:18 UTC 2008 Johnny Willemsen + + * bin/auto_run_tests.pl: + Use ACE_ROOT as defailt root test directory instead of the current + directory + +Sun Mar 2 18:53:12 UTC 2008 Abdullah Sowayan + + * ASNMP/agent/main.cpp: + * ace/Svc_Conf_y.cpp: + * apps/JAWS3/jaws3/main.cpp: + * examples/Mem_Map/IO-tests/test_io.cpp: + * examples/Reactor/Multicast/client.cpp: + * examples/Reactor/Multicast/server.cpp: + * examples/Reactor/Proactor/test_aiocb_ace.cpp: + * examples/System_V_IPC/SV_Shared_Memory/SV_Shared_Memory_Test.cpp: + * netsvcs/clients/Naming/Dump_Restore/createfile.cpp: + * netsvcs/clients/Tokens/collection/collection.cpp: + * netsvcs/clients/Tokens/collection/rw_locks.cpp: + * netsvcs/clients/Tokens/deadlock/deadlock_detection_test.cpp: + * netsvcs/clients/Tokens/invariant/invariant.cpp: + * netsvcs/clients/Tokens/manual/manual.cpp: + * netsvcs/clients/Tokens/mutex/test_mutex.cpp: + * netsvcs/clients/Tokens/rw_lock/rw_locks.cpp: + * performance-tests/Misc/context_switch_time.cpp: + * performance-tests/Misc/test_guard.cpp: + * performance-tests/Server_Concurrency/Leader_Follower/RT_CORBA_Leader_Follower.cpp: + * performance-tests/Server_Concurrency/Queue_Based_Workers/RT_CORBA_Workers.cpp: + * performance-tests/TTCP/ACE-C++/wrapper-new-ttcp.cpp: + + Use ACE_TMAIN instead of main as the program entry point to comply + with ACE/TAO/CIAO coding standards. + + * examples/Mem_Map/IO-tests/Mem_Map_IO_Tests.mpc: + + MPC doesn't recognize ACE_TMAIN as an entry point, as such, we need + to explicitly set exename in the MPC file. + + * apps/JAWS/clients/WebSTONE/src/webclient.c: + * contrib/utility/Example/CommandLine/Foo/foo.cpp: + * performance-tests/Synch-Benchmarks/context.c: + * performance-tests/TTCP/C/new-ttcp.cpp: + * tests/Unload_libACE.cpp: + + Disable fuzz's check_for_improper_main_declaration check on these files. + These files don't use ACE. + +Sat Mar 1 19:09:18 UTC 2008 Johnny Willemsen + + * bin/auto_run_tests.pl: + Added -r as option to specify an alternate root test directory + instead of the current directory. Combined this with -l we can + then run perl scripts for testing project code. + +Thu Feb 28 16:08:18 UTC 2008 Johnny Willemsen + + * bin/generate_compile_stats.sh: + Added --compiler as option so that we can specify a different + compiler then gcc + +Thu Feb 28 08:32:18 UTC 2008 Johnny Willemsen + + * docs/ACE-bug-process.html: + Removed cvs + +Wed Feb 27 19:28:18 UTC 2008 William Otte + + * bin/MakeProjectCreator/config/global.features: + disable mcpp by default. + +Tue Feb 26 15:52:37 UTC 2008 Johnny Willemsen + + * include/makeinclude/platform_openvms.GNU: + Added support for buildbits=64 + +Tue Feb 26 09:18:37 UTC 2008 Johnny Willemsen + + * include/makeinclude/platform_openvms.GNU: + Added some compiler flags to reduce the number of warnings/errors + in the OpenVMS builds + +Mon Feb 25 19:44:37 UTC 2008 Johnny Willemsen + + * bin/PerlACE/Process_Unix.pm: + * bin/PerlACE/Process_Win32.pm: + Added IgnoreHostRoot which can be set from a test script. That way + when doing cross host testing we can make sure we don't get the + executable from the host root directory. This is for example usefull + when we want to spawn perl or another system utility + + * bin/PerlACE/Run_Test.pm: + Removed commented out line + +Mon Feb 25 14:30:37 UTC 2008 Johnny Willemsen + + * include/makeinclude/platform_vxwork6.2.GNU: + * include/makeinclude/platform_vxwork6.3.GNU: + Added LD_PARTIALFLAGS which can be set for footprint builds + +Mon Feb 25 08:13:37 UTC 2008 Johnny Willemsen + + * ace/config-macros.h: + Set ACE_HAS_INTEGRAL_TYPE_THR_FUNC_RETURN when + ACE_THR_FUNC_RETURN is an integral type + + * ace/Task.cpp: + Use ACE_HAS_INTEGRAL_TYPE_THR_FUNC_RETURN to determine whether + we can do a reinterpret_cast or static_cast. This is much easier + then checking all compilers + +Sun Feb 24 19:37:37 UTC 2008 Johnny Willemsen + + * ace/Configuration.cpp: + * ace/Configuration.h: + * ace/Configuration.inl: + Added new inline file + + * ace/Get_Opt.cpp: + Prefix increment + + * ace/Event_Handler.h: + Removed commented out code + +Sat Feb 23 06:56:37 UTC 2008 Johnny Willemsen + + * include/makeinclude/platform_openvms.GNU: + OpenVMS doesn't have rwho + +Fri Feb 22 18:55:37 UTC 2008 Johnny Willemsen + + * ace/Message_Queue_NT.h: + Fixed wrong include + +Fri Feb 22 14:20:37 UTC 2008 Johnny Willemsen + + * ace/Message_Queue.{h,cpp,inl}: + * ace/Message_Queue_NT.{h,cpp,inl}: + * tests/Message_Queue_Test.cpp: + * ace/ace.mpc: + * ace/Makefile.am: + Moved ACE_Message_Queue_NT to its own file + +Fri Feb 22 08:54:37 UTC 2008 Johnny Willemsen + + * bin/global.features: + Default optimize_collocated_invocations to 1 + +Fri Feb 22 00:34:17 UTC 2008 Steve Huston + + * bin/tao_orb_tests.lst: Added !LabVIEW_RT to all tests that haven't + been adapted to the non-local filesystem mechanism I invented to run + tests for LabVIEW RT targets (and can also be used for other target + types). Now I can enable TAO tests for the LabVIEW RT scoreboard + build. + +Thu Feb 21 15:25:37 UTC 2008 Johnny Willemsen + + * docs/Download.html: + Updated download links to point to x.6.3 + + * etc/index.html: + Updated for x.6.3 + +Thu Feb 21 02:34:37 CST 2008 Johnny Willemsen + + * ACE version 5.6.3 released. + +Local Variables: +mode: change-log +add-log-time-format: (lambda () (progn (setq tz (getenv "TZ")) (set-time-zone-rule "UTC") (setq time (format-time-string "%a %b %e %H:%M:%S %Z %Y" (current-time))) (set-time-zone-rule tz) time)) +indent-tabs-mode: nil +End: diff --git a/dep/ACE_wrappers/FAQ b/dep/ACE_wrappers/FAQ new file mode 100644 index 00000000000..c184fbde84c --- /dev/null +++ b/dep/ACE_wrappers/FAQ @@ -0,0 +1,1847 @@ +There are many changes and improvements in the new version of ACE. +The ChangeLog file contains complete details about all of them. + +I've tested ACE thoroughly on Solaris 2.3 and 2.4 with the SunC++ 4.x +compiler and Centerline 2.x. I've also tested it with the SunC++ 3.x +compiler on the SunOS 4.x platform. However, I've not been able to +test it on other platforms. If anyone has time to do that, and can +report the results back to me I'd appreciate that. + +Please let me know if you have any questions or comments. + + Doug + +---------------------------------------- + +1. SIGHUP + +> 1) Where the heck does the HUP signal get registered for the +> $ACE_ROOT/tests/Service_Configurator/server stuff? I looked there and +> in $ACE_ROOT/libsrc/Service_Configurator. No luck. I guess I am +> just blind from reading. + + Take a look in ./libsrc/Service_Configurator/Service_Config.h. +The constructor for Service_Config is where it happens: + + Service_Config (int ignore_defaults = 0, + size_t size = Service_Config::MAX_SERVICES, + int signum = SIGHUP); + +---------------------------------------- +2. Multi-threaded Signal_Handler support + +> It appears Signal_Handler is +> not setup for multi-threaded apps. How do you handle signals +> in different threads? Do I have to put in the hooks in my app or should +> it go in the Threads arena? + + Ah, good question... My design follows the approach espoused +by Sun. Basically, they suggest that you implement per-thread signal +handling atop of the basic UNIX signal handlers (or in the case of +ACE, the handle_signal() callbacks on Event_Handler subclasses) by +using the thread id returned by thr_self() to index into a search +structure containing the handlers. This should be pretty straight +forward to layer atop the existing ACE Signal_Handler mechanisms. +However, you might ask yourself whether you really want (1) separate +signal handler *functionality* in different threads or (2) different +threads that mask out certain signals. The latter might be easier to +implement and reason about! + +---------------------------------------- +3. Problems compiling ACE with G++ + +> I substituted -lg++ for -lC in macro_wrappers.GNU and ran make. +> +> Most stuff seemed to build. Continually got messages like the following: +> ld: /usr2/tss/jvm/ACE_wrappers/lib/libASX.a: warning: archive has no table of c +> ontents; add one using ranlib(1) +> ld: /usr2/tss/jvm/ACE_wrappers/lib/libThreads.a: warning: archive has no table +> of contents; add one using ranlib(1) +> ld: /usr2/tss/jvm/ACE_wrappers/lib/libSPIPE.a: warning: archive has no table of +> contents; add one using ranlib(1) +> ld: /usr2/tss/jvm/ACE_wrappers/lib/libASX.a: warning: archive has no table of c +> ontents; add one using ranlib(1) +> ld: /usr2/tss/jvm/ACE_wrappers/lib/libThreads.a: warning: archive has no table +> of contents; add one using ranlib(1) +> ld: /usr2/tss/jvm/ACE_wrappers/lib/libSPIPE.a: warning: archive has no table of +> contents; add one using ranlib(1) + +> no matter how many times I used ranlib or removed the libraries and re-compiled +> or whatever. Perhaps these are System V specific and will not work on 4.1.3? + + Yes, that's exactly right. If you look at the files, they all +contain ifdef's for features that aren't included in the +./include/makeinclude/wrapper_macros.GNU file. To make this more +obvious, I've enclosed the following message in the ACE-INSTALL.html file: + + * Sun OS 4.1.x + + Note that on SunOS 4.x you may get warnings from the + linker that "archive has no table of contents; add + one using ranlib(1)" for certain libraries (e.g., + libASX.a, libThreads.a, and libSPIPE.a). This + occurs since SunOS 4.x does not support these features. + +> never able to get .so -- assume these are shared libraries that gcc can not +> deal with. + + Yes, if you use the stock gcc/gas/gnu ld +compiler/assembler/linker, you won't get shared libraries to work. It +is possible to hack this by using the "collect" version of g++. +However, as usual, I strongly advise people to stay away from g++ if +you want to use shared libraries or templates. + +> got some linker errors as follows: +> +> g++ -g -DACE_NTRACE -DACE_HAS_MT_SAFE_SOCKETS -DACE_HAS_NO_T_ERRNO -DACE_HAS_ +> OLD_MALLOC -DACE_HAS_POLL -DACE_HAS_SEMUN -DACE_HAS_SETOWN -DACE_HAS_STRBUF_T - +> DACE_HAS_STREAMS -DACE_HAS_SVR4_DYNAMIC_LINKING -DACE_HAS_TIUSER_H -DACE_HAS_SY +> S_FILIO_H -DACE_PAGE_SIZE=4096 -DACE_HAS_ALLOCA -DACE_HAS_CPLUSPLUS_HEADERS -DA +> CE_HAS_SVR4_SIGNAL_T -DACE_HAS_STRERROR -DMALLOC_STATS -I/usr2/tss/jvm/ACE_wrap +> pers/include -I/usr2/tss/jvm/ACE_wrappers/libsrc/Shared_Malloc -o test_malloc +> .obj/test_malloc.o -L/usr2/tss/jvm/ACE_wrappers/lib -Bstatic -lSemaphores -lS +> hared_Malloc -lShared_Memory -lReactor -lThreads -lMem_Map -lLog_Msg -lFIFO -lI +> PC_SAP -lMisc -lnsl -lg++ +> ld: /usr2/tss/jvm/ACE_wrappers/lib/libThreads.a: warning: archive has no table +> of contents; add one using ranlib(1) +> ld: Undefined symbol +> _free__t6Malloc2Z18Shared_Memory_PoolZ13PROCESS_MUTEXPv +> _free__t6Malloc2Z17Local_Memory_PoolZ10Null_MutexPv +> _malloc__t6Malloc2Z18Shared_Memory_PoolZ13PROCESS_MUTEXUl +> _malloc__t6Malloc2Z17Local_Memory_PoolZ10Null_MutexUl +> _remove__t6Malloc2Z17Local_Memory_PoolZ10Null_Mutex +> ___t6Malloc2Z17Local_Memory_PoolZ10Null_Mutex +> _print_stats__t6Malloc2Z17Local_Memory_PoolZ10Null_Mutex +> _remove__t6Malloc2Z18Shared_Memory_PoolZ13PROCESS_MUTEX +> ___t6Malloc2Z18Shared_Memory_PoolZ13PROCESS_MUTEX +> _print_stats__t6Malloc2Z18Shared_Memory_PoolZ13PROCESS_MUTEX +> collect2: ld returned 2 exit status +> gcc: file path prefix `static' never used +> make[2]: *** [test_malloc] Error 1 +> make[2]: Leaving directory `/usr2/tss/jvm/ACE_wrappers/tests/Shared_Malloc' +> <======== End all: /usr2/tss/jvm/ACE_wrappers/tests/Shared_Malloc + + That looks like a problem that G++ has with templates. I +don't know of any reasonable solution to this problem using g++. + +> Finally decided there was enough stuff that it looked like I might have some +> thing so I tried to run some tests and could not find so much as one piece +> of documentation that might give me some clue about running tests. + +You should take a look at ./tests/Service_Configurator/server/README +file. That explains how to run the more complicated tests. As for +the other tests, it is pretty straight forward if you look at the +./tests/IPC_SAP/SOCK_SAP and ./tests/Reactor/* directory code to +figure out how to run the tests. I don't have a Q/A department, so +any documentation has to come from volunteers. + +---------------------------------------- +4. Is there any docs or man pages on the Log_Record class? + +There is a paper in the C++_wrappers_doc.tar.Z file on ics.uci.edu +called reactor2.ps that has some examples of using Log_Record. The +./apps/Logger directories show several examples using Log_Record. +Finally, the source code for Log_Record is pretty short (though it +clearly could be commented better ;-)). + +---------------------------------------- +5. Signal handling prototypes + +> According to the man page on sigaction on our system, that line +> should look something like the following: +> +> sa.sa_handler = SIG_DFL; + + The problem is that most versions of UNIX I've come across +don't have a correct prototype for this field of struct sigaction. +That's why I define two variants of signal handler typedefs: one that +is a typedef of the "correct version" (which I call SignalHandler) and +one of which is a typedef of the "incorrect version" (which I call +SignalHandlerV). You might check out the sysincludes.h file to see +how it is defining SignalHandlerV and make sure this matches what your +OS/Compiler defines in + +---------------------------------------- +6. Omitting shared libraries + +> Can anyone tell me a way to turn off the creation of the shared libraries +> in the ACE build. + +You can simply comment out the LIB target in the $ACE_ROOT/ace/Makefile +or change the BUILD target from + +BUILD = $(VLIB) $(VSHLIB) $(SHLIBA) + +to + +BUILD = $(VSHLIB) $(SHLIBA) + +---------------------------------------- +7. DCE threading and signal handling + +>Reading the DCE docs leaves me confused as to how to make everyone +>work together in a happy hormonious whole. May basic need is to catch +>asynchronous signals so i can release some global resources before +>the process exits. + +You need to spawn a separate thread to handle signals. As part of +your init, do this: + pthread_create(&tid, thread_attr, signal_catcher, NULL); + pthread_detach(&tid); + +Where signal_catcher is like this: +static void * +signal_catcher(void *arg) +{ + static int catch_sigs[] = { + SIGHUP, SIGINT, SIGQUIT, SIGTERM, SIGCHLD + }; + sigset_t catch_these; + int i; + error_status_t st; + + for ( ; ; ) { + sigemptyset(&catch_these); + for (i = 0; i < sizeof catch_sigs / sizeof catch_sigs[0]; i++) + sigaddset(&catch_these, catch_sigs[i]); + i = sigwait(&catch_these); + /* Note continue below, to re-do the loop. */ + switch (i) { + default: + fprintf(stderr, "Caught signal %d. Exiting.\n", i); + CLEANUP_AND_EXIT(); + /* NOTREACHED */ +#if defined(SIGCHLD) + case SIGCHLD: + srvrexec__reap(); + continue; +#endif /* defined(SIGCHLD) */ + } + } + return NULL; +} +---------------------------------------- +8. + +> I have installed ACE2.15.5 on SunOS 4.1.3 with gcc2.6.0. I run the test program +> ---server_test. The static is OK, but error found when I commented out the first +> one and uncommented out the second one in the svc.conf file: +> +> #static Svc_Manager "-d -p 3912" +> dynamic Remote_Brdcast Service_Object * .shobj/Handle_Broadcast.so:remote_broad +> cast "-p 10001" +> +> The error goes like this: +> +> ----------- +> jupiter[12] %server_test -d +> starting up daemon server_test +> opening static service Svc_Manager +> did static on Svc_Manager, error = 0 +> signal signal 1 occurred +> beginning reconfiguration at Sat Feb 25 13:40:29 1995 +> Segmentation fault (core dumped) +> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +My guess is that the code generated by GCC on SunOS 4.x does not +correctly initialize static variables from shared libraries. The +SunC++ 4.0.x compiler does this correctly on Solaris 2.x (though I +believe that on SunOS 4.x it doesn't work without some extra coaxing). + +In general, I try to avoid using ACE's explicit dynamic linking +mechanisms on SunOS 4.x and GCC. You can write plenty of interesting +and useful code with ACE without using those features. Those tests +are mostly there to illustrate the "proof of concept." +---------------------------------------- +9. + +> a) I noticed the default constructor for the reactor does an open w/ defaults. +> Does this mean I need to close it if I wish to re-open it with different +> size and restart values? + + No. With the latest versions of ACE, you can now just call +open() with a new size and it will correctly resize the internal +tables to fit. + +> b) What is the usage difference between the normal FD_Set objects +> (rd/wr/ex_handle_mask_) and the ready FD_Set objects +> (rd/wr/ex_handle_mask_ready)? + + The normal FD_Sets (now called Handle_Set in ACE 3.0.5) holds +the "waitable" descriptors (these are the descriptors given to +select() or poll()). In contrast, the ready FD_Sets may be set by +Event_Handler subclasses (by called the set_ready() API) to indicate +to the Reactor that they want to be redispatched on the next go-round +*without* blocking. If you look at the Reactor code, you'll see that +the wait_for() method checks the ready sets first and doesn't block if +there are any bits set in those masks. This features makes it +possible for Event_Handlers to control subsequent dispatching policies +of the Reactor. + +> c) What does the positive return value do from an event handler callback: +> -1 detaches the event handler for that mask +> 0 does nothing - keeps the event handler registered for that mask +> >0 resets a bit in the current dispatching mask (I think) - does this mean +> this event will be called again before the current dispatch cycle is done? + +Almost... (it's tied in with my description of the ready sets above). +It means that once the Reactor finishes cycling through the set of +descriptors it got back from select() or poll(), it will redispatch +the ready set descriptors before sleeping. + +> Without direct access to the bit masks in X, I'm not sure I could emulate +> this activity - what do you think? + +I'm not sure. I'm not enough of an X guru. Maybe someone else on the +list knows the answer to this? + +> d) If I let X do the select blocking, will that have any affect on +> the Reactor performing signal handling? + + Yes, I think that will cause problems since the Reactor relies +on a "handshake" between its Signal_Handler component and its +handle_events loop to properly handle signals. + +> e) Is the Poll method preferred over Select if it is available - why? + +For systems that implement select() in terms of poll() (e.g., Solaris +2.x) then it may be somewhat faster. Otherwise, it doesn't really +matter since (1) they (should) do the same thing and (2) the end user +shouldn't notice any change in behavior. + +---------------------------------------- +10. + +> I would very much like to evaluate/use the ACE Toolkit, +> but am limited as to disk space on our system. +> What is the total disk space required for a compiled, +> usable toolkit? + +The source code itself is around 2 Meg, uncompressed. + +The compiled version of ACE is around 90 Meg compiled with the SunC++ +4.x compiler (naturally, this will differ with other compilers). +However, of this amount, about 40 meg are for the libraries, and +another 50 meg are for the test programs. Naturally, you don't need +to keep the test programs compiled. + +The postscript documentation is around 5 Meg, compressed. + +---------------------------------------- +11. + +> This is regarding the newer release of ACE and pertaining to the library +> archive file. My question is, if all the ".o" files are archived into one +> single "libACE.a", does it increase the size of the executable program? + +No. The use of a *.a file allows the linker to extract out only those +*.o files that are actually used by the program. + +> If it does, then does a large executable program mean possibility of it being +> slower? + + No. + +---------------------------------------- +12. + +> What happens if I have several reactors in a process (e.g. in different +> threads)? +> +> Programmer 1 decides to register at reactor 1 in his thread 1 a signal handler +> for SIGUSR. +> Programmer 2 decides to register at reactor 2 in his thread 2 a signal handler +> for SIGUSR. + + Naturally, the behavior of this all depends on the semantics +of the threads package... In Solaris 2.x, signal handlers are shared +by all threads. Moreover, the Reactor uses a static table to hold the +thread handlers. Thus, only one of the handler's would be registered +(i.e., whichever one was registered second). + +> Programmer 3 designs the process and decides to have thread 1 and thread 2 +> running in the same process and also makes use of a third party software library +> that internally has also registered a signal handler (not at the reactor) for +> SIGUSR. + + Now you've got big problems! This is an example of a +limitation with UNIX signal handlers... In general, it's a bad idea +to use signal handlers if you can avoid it. This is yet another +reason why. + +> When looking into Ace/ACE_wrappers/tests/Reactor/misc/signal_tester.C you +> have shown a way to do this by marking the dummy file_descriptor of the +> Sig_Handler object ready for reading asynchronously. The handle_input() +> routine of Sig_Handler object will then be dispatched synchronously. +> But what happens if I have several reactors. +> The asynchronously dispatched +> handle_signal() routine does not know via which reactor it has been registered +> so in which reactor to modify the dummy file_descriptor. +> Is your suggestion to have just one process global reactor in such a case? + + Yes, precisely. I would *strongly* recommend against using +several reactors within separate threads within the same process if +you are going to be having them handle signals. Can you use 1 +reactor and/or have one reactor handle signals within a process? + +> One thing we want to do is the priorization of Event_Handlers. I.e. in case +> of concurrent events the sequence in which the Event_Handler methods will be +> activated depends on their priority relative to each other. +> We have two choices: +> - complete priorization, which means a high priority Input Event_Handler may +> be activated prior to a lower prioritized Output Event_Handler (and doing +> so violating the 'hardcoded rule' that output must be done prior to input). +> - priorization only in categories, which means all Output Event_handler are +> ordered by their priority regardless of priorities for the category of Input +> Event_Handlers. The priority is fixed between the categories, i.e. first +> output then input then out-of-band. +> +> Right now I would think that we have to use the second choice if we want to +> use the feature of asynchronous output with automatical re-queueing. Am I right +> ? + + Hum, that's an interesting problem. It might be better to +subclass the Reactor to form a new class called Priority_Reactor. +This subclass would override the Reactor's dispatch method and +dispatch the event handlers in "priority" order. I've never done +that, but I don't think it would be all that difficult. + +---------------------------------------- +13. + +> Is the Orbix (aka CORBA) version still around? + +Nope, IONA does not support Orbix-2.X nor Orbix-3.0 anymore (the +versions of Orbix that the ACE code was based upon). Plus we didn't +maintain this code for ages, so it probably was broken too. + +---------------------------------------- +14. +> We are using your ACE software and ran into a problem which may or may not +> be related to the mutex locks. The question may have more to do with how +> mutex locks should be used. We had a class which was using your mutex +> lock wrapper. Each member function of the class acquired the lock before +> processing and released on exiting the function. Some member functions may +> call other member functions. The following is an example: +> +> class foo { +> +> void a() +> { +> MT( Mutex_Block m( this->lock_ )); +> +> if( cond ) +> b(); +> } +> +> void b() +> { +> MT( Mutex_Block m( this->lock_ )); +> +> if( cond ) +> a(); +> } +> +> }; +> +> Is this valid ? My assumtpion is that the mutex lock is recursive and +> the same thread can acquire the lock multiple times in different member +> functions. + + Ah, that's a great question since there are subtle and +pernicious problems lurking in the approach you are trying above. +Basically, Solaris mutex locks are *not* recursive (don't ask why...) +Thus, if you want to design an application like the one above you'll +need to use one or more of the following patterns: + +---------------------------------------- +A. Use recursive mutexes. Although these are not available in + Solaris directly they are supported in the later versions + of ACE. You might want to take a look at the latest + version (./gnu/ACE-3.1.9.tar.Z). It's got lots of new + support for threading and synchronization. In that case, + you simply do the following: + + class Foo + { + public: + void a() + { + MT( Guard > m( this->lock_ )); + b (); + } + + void b() + { + MT( Guard > m( this->lock_ )); + b_i (); + } + + }; + + The advantage with this is that it requires almost no + changes to existing code. The disadvantage is that + recursive locks are just slightly more expensive. + +B. Have two layers of methods (a) which are public and acquire + the Mutex and then call down to methods in layer (b), which + are private and do all the work. Methods in layer b assume + that the locks are held. This avoids the deadlock problem + caused by non-recursive mutexes. Here's what this approach + looks like (using the more recent ACE class names): + + class Foo + { + public: + void b() + { + MT( Guard m( this->lock_ )); + b_i (); + } + + void b_i() + { + if( cond ) + a_i(); + } + + void a_i() + { + if( cond ) + b_i(); + } + + void a() + { + MT( Guard m( this->lock_ )); + a_i (); + } + + }; + + The advantage here is that inline functions can basically + remove all performance overhead. The disadvantage is that + you need to maintain two sets of interfaces. + +C. Yet another approach is to release locks when calling + other methods, like this: + + class Foo + { + public: + void b() + { + MT( Guard m( this->lock_ )); + m.release (); + a (); + m.acquire (); + } + + void a() + { + MT( Guard m( this->lock_ )); + m.release (); + b (); + m.acquire (); + } + + }; + + The disadvantage with this, of course, is that you + greatly increase your locking overhead. In addition, + you need to be very careful about introducing race + conditions into the code. The primary reason for + using this approach is if you need to call back to + code that you don't have any control over (such as + OS I/O routines) and you don't want to hold the + lock for an indefinite period of time. +---------------------------------------- + + BTW, all three of these patterns are used in the ACE Reactor +class category. The Reactor has a number of fairly complex +concurrency control and callback issues it must deal with and I've +found it useful to use all three of these patterns jointly. + + I'd be interested to hear any comments on these approaches. + + Doug +---------------------------------------- +15. + +> I am working on Solaris 2.3 and trying to understand how to get around +> the problem of trying to open a Socket connection to a remote host that +> is "dead". Of course you get a nice long process block if the socket +> is in Blocking mode (TCP lets you know when you can continue - how polite). +> +> So how does a non-blocking connect work with respect to using +> the Reactor and a SOCK_Stream object to coordinate the opening +> of the connection? Do I wait on the OUTPUT event for the FD? +> How do I know if the connect worked or possibly timed-out? Is +> this a reliable approach (I read somewhere that this will only +> work if the STREAMS module is at the top of the protocol stack +> - MAN page I think)? + +An example of implementing this is in the Gateway sample application +in the new ACE. It's also encapsulated in the Connector<> pattern of +the Connection class category in ./libsrc/Connection. You may want to +take a look at those two things for concrete usage examples. + +However, the basics of getting non-blocking to work are: +- set socket to non-blocking +- initiate connect() request +- if connect() returned 0 you're connected +- if connect() returned -1 and errno is EWOULDBLOCK (or EAGAIN, depending +on where you are), then register an event handler for read and write events +on the socket +- any other errno value is fatal + +When an event is returned +- no matter which event you get back (read or write), you may have gotten +the event out of error. Thus, re-attempt the connect() and check to see if +errno is EISCONN (if it's not there's a problem!) +- if errno was EISCONN, the connection is ready to go, otherwise you must +handle an error condition + +If you want to "time out" after a certain period of time, consider +registering for a timer event with Reactor. If the timer goes off before +the connection succeeds, close down the appropriate socket. + +> Is using a separate thread to make the connection a better way to avoid +> the potentialy long block in the main thread during the connect call? + +You could do that, but it can all be accomplised in a single process using +the facilities available. +---------------------------------------- +16. + +> I was wondering, does the Reactor class have the ability to prioritize +> activity on the registered event handlers? + + The default strategy for the Reactor's dispatch routine +(Reactor::dispatch) does not prioritize dispatching other than to +dispatch callbacks in ascending order from 0 -> maxhandlep1. + +> We have a requirment to be able to process both real-time, as well as, stored +> telemetry and ERMs concurrently. Real-time needs to be processed at a higher +> priority than stored data. Our design is based on both real-time and stored +> data coming into our process via separate sockets. + + I can think of several ways to do this: + + 1. Use dup() or dup2() to organize your sockets such that the + higher priority sockets come first in the Handle_Sets that + the Reactor uses to dispatch sockets. This is pretty easy + if you don't want to muck with the Reactor code at all. + + 2. You could subclass Reactor::dispatch() and revise it so + that it dispatches according to some other criteria that + you define in order to ensure your prioritization of + sockets. + +BTW, I'm not sure what you mean by "real-time" but I assume that you +are aware that there is no true "real-time" scheduling for network I/O +in Solaris. However, if by "real-time" you mean "higher priority" +then either of the above strategies should work fine. +---------------------------------------- +17. + +> I compiled the new ACE 3.2.0 's apps/Gateway. The compiling went +> through without any errors. But I could not get it running, neither single +> threaded nor multi-threaded. The cc_config and rt_config files entries are given +> below. Also the machine configurations are given below. Does it need some more +> settings or some patch !!?? + + I believe you are seeing the effects of the dreaded Sun MP bug +with non-blocking connects. The easy work around for now is simply to +give the "-b" option to the Gateway::init() routine via the svc.conf +file: + +dynamic Gateway Service_Object *.shobj/Gateway.so:_alloc_gatewayd() active + "-b -d -c cc_config -f rt_config" + +If you check line 137 of the Gateway::parse_args() method you'll see +what this does. +---------------------------------------- +18. + +How to get ACE to work with GCC C++ templates. + +The first and foremost thing to do is to get the latest version of GCC +(2.7.2) and also get the template repository patches from + +ftp://ftp.cygnus.com/pub/g++/gcc-2.7.1-repo.gz + +This will get the ball rolling... + +Here is some more info on G++ templates courtesy of Medhi TABATABAI +: + +Where's the Template? +===================== + + C++ templates are the first language feature to require more +intelligence from the environment than one usually finds on a UNIX +system. Somehow the compiler and linker have to make sure that each +template instance occurs exactly once in the executable if it is +needed, and not at all otherwise. There are two basic approaches to +this problem, which I will refer to as the Borland model and the +Cfront model. + +Borland model + Borland C++ solved the template instantiation problem by adding + the code equivalent of common blocks to their linker; template + instances are emitted in each translation unit that uses them, and + they are collapsed together at run time. The advantage of this + model is that the linker only has to consider the object files + themselves; there is no external complexity to worry about. This + disadvantage is that compilation time is increased because the + template code is being compiled repeatedly. Code written for this + model tends to include definitions of all member templates in the + header file, since they must be seen to be compiled. + +Cfront model + The AT&T C++ translator, Cfront, solved the template instantiation + problem by creating the notion of a template repository, an + automatically maintained place where template instances are + stored. As individual object files are built, notes are placed in + the repository to record where templates and potential type + arguments were seen so that the subsequent instantiation step + knows where to find them. At link time, any needed instances are + generated and linked in. The advantages of this model are more + optimal compilation speed and the ability to use the system + linker; to implement the Borland model a compiler vendor also + needs to replace the linker. The disadvantages are vastly + increased complexity, and thus potential for error; theoretically, + this should be just as transparent, but in practice it has been + very difficult to build multiple programs in one directory and one + program in multiple directories using Cfront. Code written for + this model tends to separate definitions of non-inline member + templates into a separate file, which is magically found by the + link preprocessor when a template needs to be instantiated. + + Currently, g++ implements neither automatic model. The g++ team +hopes to have a repository working for 2.7.0. In the mean time, you +have three options for dealing with template instantiations: + + 1. Do nothing. Pretend g++ does implement automatic instantiation + management. Code written for the Borland model will work fine, but + each translation unit will contain instances of each of the + templates it uses. In a large program, this can lead to an + unacceptable amount of code duplication. + + 2. Add `#pragma interface' to all files containing template + definitions. For each of these files, add `#pragma implementation + "FILENAME"' to the top of some `.C' file which `#include's it. + Then compile everything with -fexternal-templates. The templates + will then only be expanded in the translation unit which + implements them (i.e. has a `#pragma implementation' line for the + file where they live); all other files will use external + references. If you're lucky, everything should work properly. If + you get undefined symbol errors, you need to make sure that each + template instance which is used in the program is used in the file + which implements that template. If you don't have any use for a + particular instance in that file, you can just instantiate it + explicitly, using the syntax from the latest C++ working paper: + + template class A; + template ostream& operator << (ostream&, const A&); + + This strategy will work with code written for either model. If + you are using code written for the Cfront model, the file + containing a class template and the file containing its member + templates should be implemented in the same translation unit. + + A slight variation on this approach is to use the flag + -falt-external-templates instead; this flag causes template + instances to be emitted in the translation unit that implements + the header where they are first instantiated, rather than the one + which implements the file where the templates are defined. This + header must be the same in all translation units, or things are + likely to break. + + *See Declarations and Definitions in One Header: C++ Interface, + for more discussion of these pragmas. + + 3. Explicitly instantiate all the template instances you use, and + compile with -fno-implicit-templates. This is probably your best + bet; it may require more knowledge of exactly which templates you + are using, but it's less mysterious than the previous approach, + and it doesn't require any `#pragma's or other g++-specific code. + You can scatter the instantiations throughout your program, you + can create one big file to do all the instantiations, or you can + create tiny files like + + #include "Foo.h" + #include "Foo.cc" + + template class Foo; + + for each instance you need, and create a template instantiation + library from those. I'm partial to the last, but your mileage may + vary. If you are using Cfront-model code, you can probably get + away with not using -fno-implicit-templates when compiling files + that don't `#include' the member template definitions. + +4. Placing a function that looks like this near the top of a .C file + that uses any inline template member functions permits proper inlining: + + // #ifdef __GNUG__ + // This function works around the g++ problem with inline template member + // calls not being inlined ONLY in the first block (in a compilation + // unit) from which they are called. + // This function is inline and is never called, so it does not produce + // any executable code. The "if" statements avoid compiler warnings about + // unused variables. + inline + void + gcc_inline_template_member_function_instantiator() + { + if ( (List *) 0 ); + } + // #endif // __GNUG__ + + other prerequisites: + -- All inline template member functions should be defined in + the template class header. Otherwise, g++ will not inline + nested inline template member function calls. + -- Template .h and .C files should NOT include iostream.h + (and therefore debugging.h). + This is because iostream.h indirectly includes other + GNU headers that have unprotected #pragma interface, + which is incompatible with -fno-implicit-templates and optimal + space savings. + -- inline virtual destructors will not be inlined, unless necessary, + if you want to save every last byte + -- be sure that -Winline is enabled + +---------------------------------------- +19. + +> 1. when are dynamically loaded objects removed from the Service_Config. + +The Service Configurator calls dlclose() when a "remove Service_Name" +directive is encountered in the svc.conf file (or programmatically +when the Service_Config::remove() method is invoked). Check out the +code in ./libsrc/Service_Config/Service_Repository.i and +./libsrc/Service_Config/Service_Config.i to see exactly what happens. + +> 2. In the Service Configurator, when an item is entered in the svc.conf +> how dow you know which items will be invoked as threads and +> which items are forked. I know that static items are executed +> internally. + + No! It's totally up to the subclass of Service_Object to +decide whetehr threading/forking/single-threading is used. Check out +the ./apps/Logger/Service_Configurator_Logger for examples of +single-threaded and multi-threaded configuration. +---------------------------------------- +20. + +> I have been reading the Service Configurator Logger. I was wondering about +> cleanup of new objects. In the handle_input method for the Acceptor a new +> svc_handler is allocated for each new input request and deleted in the +> handle_close. I was wondering how handle close was called when a client who +> has created a socket terminates the connection (i.e., when is handle_close +> called). + +handle_close() is automatically called by the Reactor when a +handle_input()/handle_output()/etc. method returns -1. This is the +"hook" that instructs the Reactor to call handle_**() and then remove +the Event_Handler object from its internal tables. + +---------------------------------------- +21. + +> How does the Logger know to remove the client socket and the svc_handler object. +> Does he recieve an exception. + + No. when the client terminates the underlying TCP/IP +implementation sends a RESET message to the logger host. This is +delivered to the logger process as a 0-sized read(). It then knows to +close down. + +> What I am worried about is a leak. Where by alot of clients connect and +> disconnect and the server does not cleanup correctly. Such as a core dump +> from the client where he cannot close correctly. + + That's handled by the underlying TCP (assuming it is +implemented correctly...). + +> What I am doing is attempting to convert the logger example into an alarm +> manager for remote nodes. In this application a node may be powered down +> there by terminating a Logger/Alarm server connection abnormally, this could +> leave the Logger with many dangling sockets and allocated svc_handler objects. + + If the TCP implementation doesn't handle this correctly then +the standard way of dealing with it is to have an Event_Handler use a +watchdog timer to periodically "poll" the client to make sure it is +still connected. BTW, PCs tend to have more problems with this than +UNIX boxes since when they are turned off the TCP implementation may +not be able to send a RESET... +---------------------------------------- +22. + +Using templates with Centerline. + +Centerline uses ptlink to process the C++ templates. ptlink expect the +template declarations and definitions (app.h and app.C) to reside in +the same directory. This works fine for the ACE hierarchy since +everything is a link to the appropriate src directory (include/*.[hi] +--> ../src/). When a users of the ACE distribution attempts to include +the ACE classes in an existing application hierarchy this problem will +arise if ptlink is used. + +The solution is to create a link to the declaration file from the +definition file directory and use the "-I" to point to the definition +directory. + +---------------------------------------- + +23. + +> When I try to compile $ACE_ROOT/src/Message_Queue.C on a Solaris +> 5.3 system using SUNPro CC 4.0, the compiler aborts with a Signal 10 +> (Bus Error). Our copy of CC 4.0 is over a year old and I do not +> know if any patches or upgrades exist for it. If they do, then we +> have not applied them to our compiler. + + Several other people have run across this as well. It turns +out that there is a bug in the Sun 4.0.0 C++ compiler that will get a +bus error when -g is used. If you compilg Message_Queue.C *without* +-g then it works fine. The later versions of SunC++ don't have this +bug. I'd recommend that you upgrade as soon as possible. + +---------------------------------------- + +24. + +> I have added a dynamic service to the Service Configurator. This new service +> fails on the load because it uses application libraries that are not shared +> object libraries (i.e., objects in libApp.a). I am assuming from the error +> message that the problem is the mix match of shared and non-shared objects. + + Right, exactly. + +> I was wondering if there is an easy way to add static services to the +> Service Configurator. The example directory listing static service is +> very tightly coupled with the Service_Config object. Is there another +> way of adding static services. + + Sure, that's easy. The best way to do this is to use the +interfaces of the Service_Respository class to configure static +services into the Service_Config. A good example of how to do this is +in Service_Config.[Chi]: + +int +Service_Config::load_defaults (void) +{ + for (Static_Svc_Descriptor *sl = Service_Config::service_list_; sl->name_ != 0; sl++) + { + Service_Type *stp = ace_create_service_type (sl->name_, sl->type_, + (const void *) (*sl->alloc_)(), + sl->flags_); + if (stp == 0) + continue; + + const Service_Record *sr = new Service_Record (sl->name_, stp, 0, sl->active_); + + if (Service_Config::svc_rep->insert (sr) == -1) + return -1; + } + return 0; +} + +---------------------------------------- +25. + +> 8. Do you have examples of the SYNC/ASYNC pattern? + + Yes. Check out the following: + + 1. The latest version of ./apps/Gateway/Gateway has + an example of this when you compile with the USE_OUTPUT_MT + flag. In this case, the Reactor performs the "Async" + processing, which multiplexes all incoming messages from peers + arriving on Input_Channels. These messages are then queued + up at the appropriate Output_Channels. Each Output_Channel + runs in a separate thread, performing the "Sync" + processing. + + 2. Also, the latest version of the OOCP-tutorial4.ps.gz + file available from wuarchive.wustl.edu in the + directory /languages/c++/ACE/ACE-documentation shows + an example of using the Half-Sync/Half-Async pattern + to build an Image Server. I'm using this as an + example in my tutorials these days. + +---------------------------------------- +26. + +> We had a discussion about something we saw in the new ACE code. +> I thing there was a member function of a class that was doing a +> "delete this". Is this safe? + +In general it is safe as long as (1) the object has been allocated +dynamically off the heap and (2) you don't try to access the object +after it has been deleted. You'll note that I tend to use this idiom +in places where an object is registered with the Reactor, which must +then must ensure the object cleans itself up when handle_close() is +called. Note that to ensure (1) I try to declare the destructor +"private" or "protected" so that the object must be allocated off the +heap (some compilers have a problem with this, so I may not be as +consistent as I ought to...). + +---------------------------------------- +27. + +> 5. What is the correct way for building a modified ACE library? +> Changing in "libsrc" or in "include" directory? +> When I make a complete new directory, how can I get introduced +> the dependencies within my new makefile, can you give a short hint? + +Sure, no problem. For instance, here's what I did tonight when I +added the new Thread_Specific.[hiC] files to ACE: + + 1. Created three new files Thread_Specific.[hiC] in + ./libsrc/Threads. + + 2. cd'd to ../../include/ace and did a + + % ln -s ../../libsrc/Threads/Thread_Specific.[hi] . + + 3. cd'd to ../../src and did a + + % ln -s ../../libsrc/Threads/Thread_Specific.C . + + 4. then I did + + % make depend + + on the ./src directory, which updated the dependencies. + +---------------------------------------- +28. The following is from Neil B. Cohen (nbc@metsci.com), who is + writing about how to work around problems he's found with HP/UX. + +I've been trying to compile the latest beta (3.2.9) on an HP running +HPUX9.05 for the past week or so. I've had problems with templates up +and down the line. I finally discovered (after some discussions with +the HP support people) that they have made numerous changes to their +C++ compiler recently to fix problems with templates and +exceptions. If you are trying to compile ACE under HPUX with anything +less than version 3.70 of the HP compiler, you may have serious +problems (we were using v3.50 which came with the machine when we +bought it a few months ago). + +Also, unlike earlier ACE versions, I was forced to add the following +line to the rules.lib.GNU file to "close" the library - ie. force the +various template files to be instantiated and linked to the ACE +library itself. I don't know if this is necessary, or the only way to +make things work, but it seems to do the job for my system. + +in rules.lib.GNU... + +$(VLIB): $(VOBJS) + - CC -pts -pth -ptb -ptv -I$(ACE_ROOT)/include $(VOBJS) + $(AR) $(ARFLAGS) $@ $? ./ptrepository/*.o + -$(RANLIB) $@ + -chmod a+r $@ + +I added the CC line, and added the "./ptrepository/*.o" to the $(AR) +cmd. Sun has an -xar option, I believe that does something similar to +this. Also - note that I'm not sure that the "-ptb" option is +necessary. I added that before we upgraded the compiler, so it may not +be needed now... + +---------------------------------------- +29. + +> I just ran my program with Purify, and it is telling me that there +> is at least one large (~4k) memory leak in +> ACE_Thread_Specific. This may or may not be serious, +> but it is probably worth looking into. + +Right, that's ok. This is data that's allocated on a "per-thread" +basis the first time a thread makes a call using the LM_ERROR or +LM_DEBUG macros. The data isn't freed-up until the thread exits. + +---------------------------------------- + +30. + +> In my trying to use the Reactor pattern for my application I +> noticed that I had to couple my eventHandler derived objects with a +> specific IPC_SAP mechanism. To use some of your own examples your +> Client_Stream object contains a TLI_Stream object to use in data +> transfer. My application calls for determining the communication +> mechanism at run time. To do this my eventHandler must be able to +> create the appropriate IPC_Stream object at run time and use its +> methods through a super class casting. The problem is that there is no +> super class with the virtual methods for send, recv, etc. To solve my +> problem I will create that super class and have the TLI ( as well as +> other wrapper objects) inherit from it instead of IPC_SAP. My question +> is I am suspicious of why ACE wasn't designed with that in mind? Is my +> application that unique ? or is there a better way to do this that I +> am not aware of ? Your help in this matter will be much appreciated. + +ACE was developed using static binding for IPC_SAP in order to +emphasize speed of execution over dynamic flexibility *in the core +infrastructure*. To do otherwise would have penalized the performance +of *all* applications in order to handle the relatively infrequent +case where you want to be able to swap mechanisms at run-time. + +Since it is straightforward to create an abstract class like the one +you describe above I decided to make this a "layered" service rather +than use this mechanism in the core of ACE. + +BTW, I would not modify TLI_SAP and SOCK_SAP to inherit from a new +class. Instead, I would use the Bridge and Adapter patterns from the +"Gang of Four" patterns catalog and do something like this: + +---------------------------------------- +// Abstract base class +class ACE_IPC_Stream +{ +public: + virtual ssize_t recv (void *buf, size_t bytes) = 0; + virtual ssize_t send (const void *buf, size_t bytes) = 0; + virtual ACE_HANDLE get_handle (void) const = 0; + // ... +}; +---------------------------------------- + +and then create new classes like + +---------------------------------------- +template +class ACE_IPC_Stream_T : public ACE_IPC_Stream +{ +public: + virtual ssize_t recv (void *buf, size_t bytes) + { + return this->ipc_.recv (buf, bytes); + } + + virtual ssize_t send (const void *buf, size_t bytes) + { + return this->ipc_.send (buf, bytes); + } + + virtual ACE_HANDLE get_handle (void) + { + return this->ipc_.get_handle (); + } + // ... + +private: + IPC ipc_; + // Target of delegation + // (e.g., ACE_SOCK_Stream or ACE_TLI_Stream). +} +---------------------------------------- + +Then you could write code that operated on ACE_SAP *'s to get a +generic interface, but that reused existing code like SOCK_SAP and +TLI_SAP, e.g., + +---------------------------------------- +class My_Event_Handler : public ACE_Event_Handler +{ +public: + My_Event_Handler (void) { + // Figure out which IPC mechanism to use somehow: + + if (use_tli) + this->my_ipc_ = new ACE_SAP_IPC; + else if (use_sockets) + this->my_ipc_ = new ACE_SAP_IPC; + else + ... + } + +private: + ACE_IPC_Stream *my_ipc_; +}; +---------------------------------------- + +There are obviously details left out here, but this is the general idea. + +---------------------------------------- +31. + +> I was trying to view your 'Writting example applications in CORBA' article +> /tutorial using ghostview but the .ps file seems to be corrupted ( I tried to +> ftp it more than once). Any help would be much appreciated. + +There are two solutions to this problem (which seems to be caused by a +weird interaction between ghostview and the "psnup" program I use to +generate the slides 4-up on a page): + + 1. If you want to print them or view them 1-up on a page you + can edit the postscript file and remove the first 551 + lines or so (which are generated by the psnup script). + This will cause the document to be printed 1-up rather than + 4-up. + + 2. You can try to print the 4-up file on a postscript printer. + Believe it or not, this typically works, even though ghostview + can't handle it! + +---------------------------------------- +32. + +> We would like to use the Reactor class as a static member on some of +> our classes (one per process) so that we can see and use the Reactor +> witnin each process on a global level. We are using it to set +> timers several levels down in our class trees and don't want to pass +> a pointer to it through all of our constructors. My question is: +> are there any static initialization dependencies that you know of +> when using the default "do nothing" constructor of the Reactor that +> could prevent use from using it as a static member variable? Thanks +> for any advice on this issue. + +The only problems you'll have are the typical ones about "order of +initialization" of statics in separate files. You'll also have to +live with the default size of the I/O handler table, which probably +isn't a problem since the max is something like 1024 or so. + +BTW, I solve this problem in ACE via the Service_Config::reactor, +which is a static *pointer* to a Reactor. If you really wanted to +make this work nicely, you could use the Singleton pattern from the +"Gang of Four" patterns catalog. That should solve your problem even +more elegantly! + +---------------------------------------- +33. +> I just got the ACE-3.3 version and am trying it on the HP-UX. +> I run into a small problem while cloning the directories that +> might be worth fixing. +> +> I made a directory called ACE_WRAPPERS/HP-UXA.09.05-g1, cd to it +> and run "make -f ../Makefile clone". when I look in src, I have: +> Acceptor.C@ -> ../libsrc/Connection/Acceptor.C +> +> However, ../libsrc does not exist. It is not one of the CLONE +> variables in ACE_WRAPPERS/Makefile. I don't think you'd want to +> clone libsrc too, since its files don't change. + +I think you can solve this problem as follows: + +% cd ACE_WRAPPERS +% setenv ACE_ROOT $cwd +% cd HP-UXA.09.05-g1 +% make -f ../Makefile clone +% setenv ACE_ROOT $cwd +% make + +That should build the links correctly since they'll point to the +absolute, rather than relative, pathnames! + +---------------------------------------- +34. + +> Our quality personal has asked me the following questions for which +> I think you are the right guy for answering that: + +> o How long is ACE used in industrial products? + +It was first used at Ericsson starting in the fall of 1992, so that +makes it about 3 years now. + +> o What are reference projects comparable to ours that use ACE? + +The ones I have directly worked with include: + +Motorola -- satellite communication control +Kodak Health Imaging Systems -- enterprise medical imaging +Siemens -- enterprise medical imaging +Ericsson/GE Mobile Communications -- telecommunication switch management +Bellcore -- ATM switch signal software + +In addition, there are probably about 100 or more other companies that +have used ACE in commercial products. The current mailing list has +about 300 people from about 230 different companies and universities. +If you'd like additional info, please let me know. + +> o How many persons have contributed on testing and writing error +> reports for ACE? + +Around 60 or so. All the contributors are listed by name and email +address at the end of the README file distributed with the ACE release. + +> o How many bug fixes have been made since ACE was public domain? + +All information related to bug fixes is available in the ChangeLog +file distributed with the ACE release (I could count these for you if +you need that level of detail). + +> o How many literature is there on ACE? + +All articles published about ACE are referenced in the BIBLIOGRAPHY +file in the top-level directory of ACE. + +---------------------------------------- + +35. + +> We are currently evaluating ACE for use on a new telecom switch. +> Many of us like ACE but are having trouble convincing some team +> members that wrappers are better than using the direct Unix +> system calls. + +> I have read your papers that came with ACE, but was wondering if there +> are other papers that address the benefits (or problems) of wrappers? + +This topic has been discussed in other places, most notably the book +by Erich Gamma and Richard Helm and Ralph Johnson and John Vlissides +called "Design Patterns: Elements of Reusable Object-Oriented +Software" (Addison-Wesley, 1994), where it is described in terms of +the "Adapter" pattern. + +Very briefly, there are several key reasons why you should *not* use +UNIX system calls directly (regardless of whether you use ACE or not). + +1. Portability -- + + Unless you plan to develop code on only 1 UNIX platform (and + you never plan to upgrade from that platform as it goes + through new releases of the OS) you'll run across many, many + non-portable features. It's beyond the scope of this + FAQ to name them all, but just take a look at ACE sometime + and you'll see all the #ifdefs I've had to add to deal with + non-compatible OSs and compilers. Most of these are centralized + in one place in ACE (in the ace/OS.*files), but it took a lot + of work to factor this out. By using wrappers, you can avoid + most of this problem in the bulk of your application code + and avoid revisiting all of these issues yourself. + + In addition, ACE is now ported to other platforms (e.g., + Windows NT and Windows 95). If you want to write code that + is portable across platforms, wrappers are a good way to + accomplish this. + +2. Ease of programming -- + + I'd go as far as to say that anyone who wants to program + applications using C-level APIs like sockets or TLI is not + serious about developing industrial strength, robust, and easy + to maintain software. Sockets and TLI are *incredibly* + error-prone and tedious to use, in addition to being + non-portable. I've got a paper that discusses this in detail + at URL http://www.cs.wustl.edu/~schmidt/PDF/COOTS-95.pdf + +3. Incorporation with higher-level patterns and programming methods -- + + Here's where the Adapter pattern stuff really pays + off. For example, by making all the UNIX network + programming interfaces and synchronization mechanisms + have the same API I can write very powerful higher-level + patterns (e.g., Connector and Acceptor) that generalize + over these mechanisms. For proof of this, take a look + at the ./tests/Connection/non_blocking directory + in the latest ACE-beta.tar.gz at wuarchive.wustl.edu + in the /languages/c++/ACE directory. It implements + the same exact program that can be parameterized + with sockets, TLI, and STREAM pipes *without* + modifying any application source code. It is + literally impossible to do this without wrappers. + +---------------------------------------- +36. + +> How can I use a kind of "Reactor" in such a way that a reading +> thread can notice the arrival of new data on several shared memory +> areas ? + +Ah, that is a tricky issue! The underlying problem is that UNIX is +inconsistent with respect to the ability to "wait" on different +sources of events. In this case, Windows NT is much more consistent +(but it has its own set of problems...). + +> Poll, Select and Reactor (so far I read) assume that file +> descriptors are present, which is not the case with shared memory. + +That's correct (though to be more precise, the Reactor can also deal +with signals, as I discuss below). + +> Is there a common and efficient way to deal with that kind of +> situation, or do I have to insert extra ipc mechanisms (based on +> descriptors) ? + +There are several solutions: + +1. Use the Reactor's signal handling capability (see the + ./tests/Reactor/misc/signal_tester.C for an example) + and have the process/thread that writes to shared + data send a signal to the reader process(es). The + disadvantage of this is that your code needs to + be signal-safe now... + +2. Use a combination of SPIPE_Streams and the Reactor + to implement a simple "notification protocol," e.g., + the receiver process has an Event_Handler with a + SPIPE_Stream in it that can be notified when the + sender process writes data to shared memory. + The disadvantage here is that there's an extra + trip through the kernel, though the overhead + is very small since you only need to send 1 byte. + +3. Use threads and either bypass the Reactor altogether + or integrate the threads with the Reactor using its + Reactor::notify() mechanism (see the + ./tests/Reactor/misc/notification.C file for an + example of how Reactor::notify() works). The + disadvantage of this approach is that it won't + work for platforms that lack threads. + +---------------------------------------- +37. + +> What do you think about wrapping communication methodologies in C++ streams? +> What I mean is having defining a stream and extractor/insertor functions +> which the underlying implementation reads/writes on comm mechanisms instead of +> files. I would think this to be a very general interface for all comms +> implementations. All user code would look the same, but the underlying stream +> implementations would be different. Whether the stream functionality would +> be defined by the stream itself (eg tcpstream) or with manipulators +> (eg commstream cs; cs << tcp;) is up for grabs in my mind. +> +> Anyhow, I was wondering your input... + +That technique has been used for a long time. In fact, there are +several freely available versions of iostreams that do this and +RogueWave also sells a new product (Net.h++) that does this. I think +this approach is fine for simple applications. + +However, it doesn't really work well if you need to write +sophisticated distributed applications that must use features like +non-blocking I/O, concurrency, or that must be highly robust against +the types of errors that occur in a distributed system. + +For these kinds of systems you either need some type of ORB, or you +need to write the apps with lower-level C++ wrappers like the ones +provided by ACE. + +---------------------------------------- + +38. + +> What is the difference between cont() and next() in an ACE_Message_Block? + +Ah, good question. cont() gives you a pointer to the next +Message_Block in a chain of Message_Block fragments that all belong to +the same logical message. In contrast, next() (and prev()) return +pointers to the next (and previous) Message_Block in the doubly linked +list of Message_Blocks on a Message_Queue. + +BTW, this is *exactly* the same structure as in System V Streams... + +> Which would I use if I wanted to add a header and a trailer, each stored in +> ACE_Message_Blocks of their own, to another ACE_Message_Block? + +You should use cont() for that. Does that make sense? +---------------------------------------- + +39. + +> I think that your site is cool, but it's being a terrible tease in +> that I really want to read the contents, but don't know anything +> about x-gzip formatting. I'm running Netscape 2.0 under MS Windows +> NT. + +To view PostScript files under Win32 you will need a PostScript +viewer such as GSview. You can find GSview and Ghostscript (which is +needed to run GSview) at http://www.cs.wisc.edu/~ghost/. + +It seems that both Netscape and Internet Explorer mangles the names +of downloaded files to reflect their content type, so *.ps.gz files +are saved as *_ps.ps instead. Fortunately, GSview as of version 2.2 +supports gzip compressed postscript. When set up as a viewer for +Postscript files, files with mangled names can be viewed by GSview +without any preprocessing. + +---------------------------------------- + +40. + +> What I am doing is +> 1. Making an ACE_SOCK_Dgram and let it choose the next available port number. +> 2. Making a message that will be broadcasted to X number of servers. This +> message has a port number which the server will use to send its reply. +> 3. Broadcast the message to a fixed port number. +> 4. Wait for replies from the servers. +> +> +> It looks like I need "ACE::bind_port" to return the port number that +> it picked and "ACE_SOCK_Dgram::shared_open" will need it store the +> port number so I could call some function like +> ACE_SOCK_Dgram::get_port_number or it would need to return the port +> number instead of the handle(I could always call +> ACE_SOCK_Dgram::get_handle if I needed the handle). +> +> Is there I way to get the port number that I have missed? + +Sure, can't you just do this: + +// Defaults to all "zeros", so bind will pick port. +ACE_INET_Addr dg_addr; + +ACE_SOCK_Dgram dg; + +dg.open (dg_addr); + +dg.get_local_addr (dg_addr); + +dg_addr.get_port_number (); + +---------------------------------------- + +41. How can you rename a core file? + +new_disposition.sa_handler = &Handle_Coredump_Signal; +sigemptyset(&new_disposition.sa_mask); +sigaddset(&new_disposition.sa_mask,SIGCHLD); +new_disposition.sa_flags = 0; +sigaction(SIGSEGV,&new_disposition,&old_disposition); + +***************** + +void +Handle_Coredump_Signal(void) +{ + int status; + pid_t child; + char new_core_name[64]; + + if(0 == (child = fork())) + { + abort(); + } + else + { + if(-1 == waitpid(child,&status,NULL)) + { + exit(-1); + } + sprintf(new_core_name,"core_%d",getpid()); + rename("core",new_core_name); + exit(0); + } +} + +---------------------------------------- + +42. + +> I have seen 2 different inlining policies in ACE +> +> 1) The .i file is included unconditionally by both the .h and .C file +> and all functions in the .i file carry the "inline" keyword. + +Right. Those are for cases where I *always* want to inline those +methods. I do this mostly for very short wrapper methods (e.g., +read() or write()) that are likely to be on the "fast path" of an +application. + +> 2) The .i file is included by the .h file ONLY if __INLINE__ is defined +> for the compile. This causes the functions in the .i file to be +> compiled as inline functions (INLINE translates to inline in this case). +> If __INLINE__ is not defined, the .i file is only included by the .C +> file and the functions do NOT carry the "inline" keyword. + +I do this for cases where it's really not essential to have those +methods inline, but some users might want to compile ACE that was if +they want to eliminate all the wrapper function-call overhead. For +instance, I'll typically do this when I'm running benchmarks. + +---------------------------------------- + +43. Integrating ACE and CORBA + +> Our goal is to implement a CORBA-II compliant application. I am +> trying to conceptually visualize the applicability to ACE to this +> attempt (which we're pretty excited about), and I was hoping you'd +> offer any opinions / observations that you might have. + +We've successfully integrated ACE with several implementations of +CORBA (in particular Orbix 1.3 and 2.0) and used it in a number of +commercial applications. In these systems, we use ACE for a number of +tasks, including the following: + +1. Intra-application concurrency control, threading, and + synchronization via the ACE_Thread_Manager and Synch* classes. + +2. Dynamic linking of services via the ACE_Service_Config. + +3. Integration of event loops via the ACE_Reactor. + +4. Management of shared memory via ACE_Malloc. + +5. High-performance network I/O via the ACE_SOCK* wrappers. + +plus many more. + +You can find out more info about the ACE/CORBA integration and the +performance issues associated with it in the following paper: + +http://www.cs.wustl.edu/~schmidt/PDF/COOTS-96.pdf + +---------------------------------------- + +44. + +> Can the Reactor's event loop be called recursively? + +This is not advisable. The Reactor's dispatch() method is not +reentrant (though it is thread-safe) since it maintains state about +the active descriptors it is iterating over. Therefore, depending on +the descriptors you're selecting on, you could end up with spurious +handle_*() callbacks if you make nested calls to the +Reactor::handle_events() method. + +> For example, if I have a program that sets up some event handlers +> and then calls, in an infinite loop, ACE_Reactor::handle_events(). +> Can one of the event handlers call handle_events() again if it needs +> to block, while allowing other event handlers a chance to run? + +I'm not sure if this is really a good idea, even if the Reactor were +reentrant. In particular, what good does it do for one Event_Handler +to "block" by calling handle_events() again? The event the handler is +waiting for will likely be dispatched by the nested handle_events() +call! So when you returned back from the nested call to +handle_events() it will be tricky to know what state you were in and +how to proceed. + +Here's how I design my single-threaded systems that have to deal with +this: + + 1. I use a single event loop based on the Reactor, which acts + a cooperative multi-tasking scheduler/dispatcher. + + 2. I then program all Event_Handler's as non-blocking I/O + objects. This is straightforward to do for both input and + output using the ACE_Reactor::schedule_wakeup() and + ACE_Reactor::cancel_wakeup() methods (available with the + latest version of ACE). + + 3. Then, whenever an Event_Handler must block on I/O, it + queues up its state on an ACE_Message_Queue, calls + ACE_Reactor::schedule_wakeup(), and returns to the + main event loop so that other Event_Handlers can be + dispatched. When the I/O is ready, the Reactor will + call back to the appropriate handle_* method, which + can pick up the state it left in the Message_Queue and + continue. + +There are a number of places to find more information on this sort of +design: + + 1. $ACE_ROOT/apps/Gateway/Gateway/Channel.cpp -- + This Gateway application example shows the C++ code. + + 2. http://www.cs.wustl.edu/~schmidt/PDF/TAPOS-00.pdf -- + This paper describes the underlying patterns. + + 3. http://www.cs.wustl.edu/~schmidt/PDF/OONP-tutorial4.pdf + -- This tutorial explains the source code and + the patterns. + +BTW, I'll be describing patterns for this type of design challenge in +my tutorial at USENIX COOTS in June. Please check out +http://www.cs.wustl.edu/~schmidt/COOTS-96.html for more info. + +---------------------------------------- + +45. + +> In one of my programs, a process needs to receive input from +> multiple input sources. One of the input sources is a file +> descriptor while another is a message queue. Is there a clean way to +> integrate this a message queue source into the Reactor class so that +> both inputs are handled uniformly? + +Do you have multiple threads on your platform? If not, then life will +be *very* tough and you'll basically have to use multiple processes to +do what you're trying to do. There is *no* portable way to combine +System V message queues and file descriptors on UNIX, unfortunately. + +If you do have threads, the easiest thing to do is to have a thread +reading the message queue and redirecting the messages into the +Reactor via its notify() method. + +Please take a look at the program called + +examples/Reactor/Misc/notification.cpp + +for an example. + +---------------------------------------- + +46. + +> I'm writing a program to find out the address for a socket. The +> idea is that we open an ACE_Acceptor (and will eventually perform +> accept() on it.) Before we can do that we need to find out the +> address of the ACE_Acceptor so that we can publish it (for others to +> be able to connect to it.) The trouble is that the call +> ACE_INET_Addr::get_host_name () prints "localhost" as the host name +> while I would like to principal host name to be printed instead. + +All ACE_INET_Addr::get_host_name() is doing is calling +ACE_OS::gethostbyaddr(), which in turn will call the socket +gethostbyaddr() function. I suspect that what you should do is +something like the following: + +ACE_Acceptor listener (ACE_Addr::sap_any); + +ACE_INET_Addr addr; + +listener.get_local_addr (addr); + +char *host = addr.get_host_name (); + +if (::strcmp (host, "localhost") == 0) +{ + char name[MAXHOSTNAMELEN]; + ACE_OS::hostname (name, sizeof name); + cerr << name << endl; +} +else + cerr << host << endl; + +---------------------------------------- + +47. + +> Could you please point me to stuff dealing with asynchronous cross +> platform socket calls. I want to use non blocking socket calls on +> both UNIX and NT. + +Sure, no problem. Take a look at the + +./examples/Connection/non_blocking/ + +directory. There are a number of examples there. In addition, there +are examples of non-blocking connections in + +./examples/IPC_SAP/SOCK_SAP/CPP-inclient.cpp + +The code that actually enables the non-blocking socket I/O is in +ace/IPC_SAP.cpp + +---------------------------------------- + +48. + +> Is ACE exception-safe? If I throw an exception out of event +> handler, will the Reactor code clean itself? + +Yes, that should be ok. In general, the two things to watch out for +with exceptions are: + + 1. Memory leaks -- There shouldn't be any memory leaks internally + to the Reactor since it doesn't allocate any memory when + dispatching event handlers. + + 2. Locks -- In the MT_SAFE version of ACE, the Reactor acquires + an internal lock before dispatching Event_Handler callbacks. + However, this lock is controlled by an ACE_Guard, whose + destructor will release the lock if exceptions are thrown + from an Event_Handler. + +---------------------------------------- + +49. + +> I am building a Shared memory manager object using MMAP and MALLOC +> basically as: +> +> typedef ACE_Malloc SHMALLOC; +> +> I noticed that the ACE_MMAP_Memory_Pool class provides for the users +> to specify a Semaphore key. However, once I use it via the +> ACE_Malloc<..>::ACE_Malloc(const char* poolname) constructor, I lose +> this option. + +Yes, that is correct. That design decision was made to keep a clean +interface that will work for all the various types of memory pools. + +> Is there any recommended way to specialize ACE classes to allow this +> key to be overridden? + +Yes indeed, you just create a new subclass (e.g., class +My_Memory_Pool) that inherits from ACE_MMAP_Memory_Pool and then you +pass in the appropriate key to the constructor of ACE_MMAP_Memory_Pool +in the constructor of My_Memory_Pool. Then you just say: + +typedef ACE_Malloc SHMALLOC; + +Please check out the file: + +examples/Shared_Malloc/Malloc.cpp + +which illustrates more or less how to do this. + +---------------------------------------- + +50. + +> What is the best way to turn on TRACE output in ACE. I commented +> out the #define ACE_NTRACE 1 in config.h and rebuilt ACE and the +> examples. + +The best way to do this is to say + +#define ACE_NTRACE 0 + +in config.h. + +> When I run the CPP-inserver example in examples/IPC_SAP/SOCK_SAP, I +> get some trace output but not everything I would expect to see. + +Can you please let me know what you'd expect to see that you're not +seeing? Some of the ACE_TRACE macros for the lower-level ACE methods +are commented out to avoid problems with infinite recursion (i.e., +tracing the ACE_Trace calls...). I haven't had a chance to go over +all of these indepth, but I know that it should be possible to turn +many of them back on. + +> It would be nice to have a runtime option for turning trace on and +> off. + +There already is. In fact, there are two ways to do it. +If you want to control tracing for the entire process, please check +out ACE_Trace::start_tracing() and ACE_Trace::stop_tracing(). + +If you want to control tracing on a per-thread basis please take a +look at the ACE_Log_Msg class. There are methods called +stop_tracing() and start_tracing() that do what you want. + +---------------------------------------- + +51. + +> I've been using an acceptor and a connector in one (OS-) process. +> What does happen, if a signal is sent to this process? Is the signal +> processed by every ACE_Event_Handler (or its descendants) that is +> around? The manual page simply states that handle signal is called +> as soon as a signal is triggered by the OS. + +How this signal is handled depends on several factors: + +1. Whether your using ACE_Sig_Handler or ACE_Sig_Handlers to register + the signal handlers. + +2. If you're using ACE_Sig_Handler, then the ACE_Event_Handler * that + you've most recently registered to handle the signal will + have it's handle_signal() method called back by the Reactor. + +3. If you're using ACE_Sig_Handlers, then all of the ACE_Event_Handler * + that you've register will be called back. + +For examples of how this works, please check out + +$ACE_ROOT/examples/Reactor/Misc/test_signals.cpp + +This contains a long comment that explains precisely how everything +works! diff --git a/dep/ACE_wrappers/Makefile.am b/dep/ACE_wrappers/Makefile.am new file mode 100644 index 00000000000..2d84dbdadc7 --- /dev/null +++ b/dep/ACE_wrappers/Makefile.am @@ -0,0 +1,16 @@ +## Process this file with automake to create Makefile.in +## +## $Id: Makefile.am 80826 2008-03-04 14:51:23Z wotte $ +## +## This file was generated by MPC. Any changes made directly to +## this file will be lost the next time it is generated. +## +## MPC Command: +## /acebuilds/ACE_wrappers-repository/bin/mwc.pl -include /acebuilds/MPC/config -include /acebuilds/MPC/templates -feature_file /acebuilds/ACE_wrappers-repository/local.features -noreldefs -type automake -exclude build,Kokyu + +SUBDIRS = \ + ace + +ACLOCAL = @ACLOCAL@ +ACLOCAL_AMFLAGS = -I m4 +AUTOMAKE_OPTIONS = foreign diff --git a/dep/ACE_wrappers/NEWS b/dep/ACE_wrappers/NEWS new file mode 100644 index 00000000000..1c0f15d2c58 --- /dev/null +++ b/dep/ACE_wrappers/NEWS @@ -0,0 +1,1345 @@ +PLANNED MAJOR CHANGES "SOMETIME IN THE FUTURE" (i.e., exact beta not known) +=========================================================================== + +. RPM packaging as part of the release process by the doc_group (Remedy and user community) + +. Remove BCB6, BCB2006, and the borland MPC template after the release of x.6.6 + +USER VISIBLE CHANGES BETWEEN ACE-5.6.5 and ACE-5.6.6 +==================================================== + +. Added an option to the ACE_Process_Options class to use a wchar_t + environment buffer on Windows. + +. A new configure option, --enable-rcsid, was added to the autoconf build. + This is used to embed RCS IDs in object files. + +. A new method was added: void ACE_Time_Value::msec (ACE_UINT64&) + This method, like the existing msec(ACE_UINT64&)const method, obtains the + time value in milliseconds and stores it in the passed ACE_UINT64 object. + This method was added so that msec(ACE_UINT64&) can be called on both + const and non-const ACE_Time_Value objects without triggering compile errors. + Fixes Bugzilla #3336. + +. Added ACE_Stack_Trace class to allow users to obtain a stack trace + within their application on supported platforms. A new conversion + character, the question mark, was added to ACE_Log_Msg for stack + trace logging. + +. Added iterator support to ACE_Message_Queue_Ex class. The resulted in + the addition of ACE_Message_Queue_Ex_Iterator class and + ACE_Message_Queue_Ex_Reverse_Iterator class. + +. Renamed gperf to ace_gperf to prevent clashes with the regular gperf + tool that is available in linux distributions + +. Added support for FC9 + +. Added support for OpenSuSE 11.0 + +. Improved support for GCC 4.2 and 4.3 + +. Added support for CodeGear C++ Builder 2009 + +USER VISIBLE CHANGES BETWEEN ACE-5.6.4 and ACE-5.6.5 +==================================================== + +. Added new Monitoring lib that can be used to store and retrieve + counters. This is disabled by default because it is not 100% + finished yet, with the next release it will be enabled by default + +. Fixed bug in ACE_Service_Config when it was used from a thread + not spawned by ACE + +. Add VxWorks 6.x kernel mode with shared library support to ACE + +. Extended the implementation of Unbounded_Set, which has been + renamed Unbounded_Set_Ex, to accept a second parameter which is + a comparator that implements operator() which returns true if + the items are equivalent. Unbounded_Set has been reimplemented + in terms of Unbounded_Set_Ex using a comparator that uses operator==, + which captures the previous behavior. + +. Added support for Intel C++ on MacOSX + +USER VISIBLE CHANGES BETWEEN ACE-5.6.3 and ACE-5.6.4 +==================================================== + +. Reworked the relationship between ACE_Service_Config and + ACE_Service_Gestalt + +. Improved autoconf support + +. Improved AIX with gcc support + +. Improved OpenVMS support + +. Improved VxWorks support + +USER VISIBLE CHANGES BETWEEN ACE-5.6.2 and ACE-5.6.3 +==================================================== + +. Deprecated Visual Age 5 and older + +. Closed a rare race condition hole whereby ACE_Atomic_Op<> function + pointers would not be fully initialized prior to use. See bugzilla + 3185 for details. + +. Tweaks to support MacOS X Leopard (10.5 and 10.5.1) on Intel + +. Fixed compile problems with MinGW with GCC 4.2. Do note that we do see + much more test failures then when using GCC 3.4. + +. Changed to use synchronous exception handling with msvc 8/9 which is the + default. Asynchrous exception handling does catch access violations but + it leads to lower performance and other problems. See also bugzilla 3169 + +. Make ace_main extern C with VxWorks so that it doesn't get mangled + +. Fixed compile errors and warnings for VxWorks 6.6 + +. Added an MPC generator for the WindRiver Workbench 2.6 which is shipped + with VxWorks 6.4 + +. Added support for CodeGear C++ Builder 2007 with December 2007 update + installed + +. Added support for VxWorks 5.5.1 + +. Implemented the const reverse iterator for ACE_Hash_Map_Manager_Ex + +. Increased support for using ACE_Hash_Map_Manager_Ex with STL + functions based on latest standard C++ draft + +USER VISIBLE CHANGES BETWEEN ACE-5.6.1 and ACE-5.6.2 +==================================================== + +. ACE-ified the UUID class, which will change user applications slightly. + +. Added support for Sun Studio 12 + +. Added support for Intel C++ 10.1 + +. Fixed runtime problems with VxWorks 6.x in kernel mode, several improvements + have been made to ACE, but also some problems in the VxWorks kernel have + been found for which WindRiver has made patches. + +. Added support for VxWorks 6.5 kernel mode + +. Added support for MacOS 10.5 + +. Support for MacOS 10.4 is now deprecated. + +. Added support for OpenSuSE 10.3 + +. Added support for RedHat 5.1 + +. Added support for Microsoft Visual Studio 2008 + +. Added support for Fedora Core 8 + +. Added support for Ubuntu 7.10 + +. With Ubuntu 7.04 and 7.10 we can't use visibility, that results in + unresolved externals when building some tests. With lsb_release we + now detect Ubuntu 7.04 and 7.10 automatically and then we disable + visibility + +. Removed deprecated (un)subscribe methods from ACE_SOCK_Dgram_Mcast + +. Added an additional replace() method to ACE_OuptutCDR for replacing a + ACE_CDR::Short value. Also added write_long_placeholder() and + write_short_placeholder() to properly align the stream's write pointer, + write a placeholder value and return the placeholder's pointer. The pointer + can later be used in a call to replace() to replace the placeholder with a + different value. + +. Initial support for VxWorks 6.6 + +. Removed support for pthread draft 4, 6, & 7. This makes the ACE threading + code much cleaner + +. Improved autoconf support + +. Fixed TSS emulation problems + +. Changed ACE_thread_t and ACE_hthread_t to int for VxWorks kernel mode. All + thread creation methods do have an additional const char* argument to + specify the task name, this now also works with pthread support enabled + +. Use bool in much more interfaces where this is possible + +. Added support for Debian Etch + +. Fixed ACE CDR LongDouble support on VxWorks 6.x + +. Added Microsoft Visual Studio 2008 project files to the release packages + +. Fixed a few bugs in the ACE_Vector template + +USER VISIBLE CHANGES BETWEEN ACE-5.6 and ACE-5.6.1 +==================================================== + +. Added support for CodeGear RAD Studio 2007 + +. Added support for CodeGear C++ Builder 2007 Update 3 + +. Modified the definiton of ACE_DEFAULT_THREAD_KEYS on Windows so it + is based on the version of the OS as defined by Microsoft in this web + page: http://tinyurl.com/2jqcmd + This fixes bugzilla #2753 + +USER VISIBLE CHANGES BETWEEN ACE-5.5.10 and ACE-5.6 +==================================================== + +. OpenVMS 8.3 on IA64 port + +. Added autoconf support for Intel C++ 10.0 + +. Improved autoconf support on Linux, Solaris, NetBSD and HPUX + +. CodeGear C++ Builder 2007 Update 2 support + +. The netsvcs's client logging daemon has a new configuration option, + -llocal-ip[:local-port], which can be used to specify the local IP + address and port number for the client logging daemon's connection to + the server logging daemon. If the -l option is specified with an IP + address but not a port number, an unused port number is selected. + +. A new ACE+TAO port to LabVIEW RT 8.2 with Pharlap ETS. The host build + environment is Windows with Microsoft Visual Studio .NET 2003 (VC7.1). + Please see the ACE-INSTALL.html file for build instructions. + +USER VISIBLE CHANGES BETWEEN ACE-5.5.9 and ACE-5.5.10 +==================================================== + +. The ACE_utsname struct, used in the ACE_OS::uname() function when the + platform doesn't provide the standard utsname struct, was changed. It + defines a number of text fields and their types were changed from + ACE_TCHAR[] to char[] in order to be consistent with all other platforms. + This removes the need to write different code for platforms where + ACE_LACKS_UTSNAME_T is set and that have wide characters (most probably + Windows). Fixes Bugzilla #2665. + +. The ACE::daemonize() "close_all_handles" parameter was changed from + an "int" to a "bool" to better reflect how it is used. + +. VxWorks 6.5 support. Compilation of the core libraries has been validated + but no runtime testing has been performed. + +. CodeGear C++ Builder 2007 support. + +. The FaCE utility was moved from the ACE_wrappers/apps directory to + ACE_wrappers/contrib. It is used for testing ACE+TAO apps on WinCE. + See the ACE_wrappers/contrib/FaCE/README file for more information. + +. ACE_INET_Addr::set (u_short port, char *host_name, ...) now favors IPv6 + addresses when compiled with ACE_HAS_IPV6 defined and the supplied address + family is AF_UNSPEC. This means that if host_name has an IPv6 address in + DNS or /etc/hosts, that will be used over an IPv4 address. If no IPv6 + address exists for host_name, then its IPv4 address will be used. + +. Intel C++ 10.0 support + +. Support for the version of vc8 for 64-bit (AMD64) shipped with the Microsoft + Platform SDK. + +. Fixed ACE_Vector::swap() (bugzilla #2951). + +. Make use of the Atomic_Op optimizations on Intel EM64T processors. The + Atomic_Op is now several times faster on EM64T then with previous versions + of ACE + +USER VISIBLE CHANGES BETWEEN ACE-5.5.8 and ACE-5.5.9 +==================================================== + +. Use Intel C++ specific optimizations for Linux on IA64 + +. Improved support for ACE_OS::fgetc. Added support for ACE_OS::fputc, + ACE_OS::getc, ACE_OS::putc and ACE_OS::ungetc. + +. Added support for ACE_OS::log2(double) and improved support for + ACE::log2(u_long). + +. Shared library builds on AIX now produce a libxxx.so file instead of the + previous practice of producing libxxx.a(shr.o). + +. GCC 4.1.2 that comes with Fedora 7 seems to have a fix for the visibility + attribute we use for the singletons. F7 users will therefore need to + define the following in your config.h file. + ACE_GCC_HAS_TEMPLATE_INSTANTIATION_VISIBILITY_ATTRS 1 + +. Fixed (rare) problem in TP_Reactor where incorrect event handler was + resumed. + +. Reduced footprint on some platforms, particularly those that use + g++ >= 3.3. + +USER VISIBLE CHANGES BETWEEN ACE-5.5.7 and ACE-5.5.8 +==================================================== + +. Extended ACE_Event constructor with optional LPSECURITY_ATTRIBUTES + argument + +. Added support for QT4 + +. Added support to integrate with the FOX Toolkit (www.fox-toolkit.org) + +. Added support for Microsoft Visual Studio Code Name "Orcas", which is + the msvc9 beta + +. Added ability to provide an optional priority when calling + ACE_Message_Queue_Ex::enqueue_prio(). There was previously no way + to specify a priority for queueing. + +. Removed support for Visual Age on Windows. + +. ACE will compile once again with ACE_LACKS_CDR_ALIGNMENT #defined. + +. ACE_Process_Manager::terminate() no longer removes the process from the + process descriptor table; the pid remains available in order to call + ACE_Process_Manager::wait(). + +USER VISIBLE CHANGES BETWEEN ACE-5.5.6 and ACE-5.5.7 +==================================================== + +. ACE 5.5 contained a set of pragmas which prevented Visual Studio 2005 (VC8) + from issuing warnings where C run-time functions are used but a more + secure alternative is available. For more information on the C run-time + issues and Microsoft's response, please see the following MSDN page: + http://msdn2.microsoft.com/en-us/library/8ef0s5kh(VS.80).aspx. + In this beta, the pragmas which prevented the warnings have been removed. + The ACE library has been reviewed and most of the use of "unsafe" functions + has been fixed where possible. Since not all of the warnings emanating from + ACE are situations that can or should be fixed, the ACE VC8 projects will + prevent the warnings while building the ACE kit and its contained examples, + tests, etc. The warnings are disabled by adding Microsoft-specified macros + to the compile line via MPC. If desired, the warnings can be re-enabled by + regenerating the project files with different MPC features. Note, however, + that while ACE without warnings caused by the new C run-time functions, your + application builds may trigger these warnings either by use of the "unsafe" + C run-time functions or via use of an inlined ACE_OS method which uses it. + If the warning is caused by an ACE_OS method, there is a more safe alternate + available, probably located by appending _r to the method name (e.g., + instead of using ACE_OS::ctime(), use ACE_OS::ctime_r()). + There are other cases where the compiler may have issued warnings and ACE + prevented this via a #pragma. These #pragmas have been removed as well. + This may cause your application builds to trigger more warnings from VC8 + than past ACE versions. You should review your code and either correct + the code or disable the warnings locally, as appropriate. + +. The "release" argument to a number of ACE_String_Base<> methods was changed + from int to bool to more accurately reflect its purpose. The following + methods were changed: + + ACE_String_Base (const CHAR *s, + ACE_Allocator *the_allocator = 0, + int release = 1); + to + ACE_String_Base (const CHAR *s, + ACE_Allocator *the_allocator = 0, + bool release = true); + + ACE_String_Base (const CHAR *s, + size_type len, + ACE_Allocator *the_allocator = 0, + int release = 1); + to + ACE_String_Base (const CHAR *s, + size_type len, + ACE_Allocator *the_allocator = 0, + bool release = true); + + void set (const CHAR * s, int release = 1); + to + void set (const CHAR * s, bool release = true); + + void set (const CHAR * s, size_type len, int release); + to + void set (const CHAR * s, size_type len, bool release); + + void clear (int release = 0); + to + void clear (bool release = false); + + Since ACE_String_Base forms the basis of the ACE_CString and ACE_TString + classes, this may ripple out to user application code. If you encounter + errors in this area while building your applications, replace the + int argument you are passing to the method now with either true or false. + +. Solutions for the eVC3/4 platform have been removed from this + release. Note that we package WinCE projects/workspaces for use + with VC8. + +. There were 3 new ACE_Log_Msg logging format specifiers added to make logging + easier for types that may change sizes across platforms. These all take one + argument, and the new formats are: + %b - format a ssize_t value + %B - format a size_t value + %: - format a time_t value + +. The ace/Time_Request_Reply.h and ace/Time_Request_Reply.cpp files were + moved from $ACE_ROOT/ace to $ACE_ROOT/netsvcs/lib. The time arguments in + the public API to ACE_Time_Request were changed from ACE_UINT32 to time_t + and the portions of the on-wire protocol that contains time was changed from + ACE_UINT32 to ACE_UINT64. Thus, code that uses the ACE_Time_Request class + to transfer time information will not interoperate properly with prior + ACE versions. This will affect uses of the netsvcs time clerk/server. + +. The portion of the ACE_Name_Request class that carries the on-wire seconds + portion of a timeout value was changed from ACE_UINT32 to ACE_UINT64. This + means that Name server/clients at ACE 5.5.7 and higher will not interoperate + properly with previous ACE versions' name servers/clients. + +. In the ACE_Log_Record (ACE_Log_Priority, long, long) constructor, the + second argument, long time_stamp, was changed to be of type time_t. This + aligns the type with the expected value, a time stamp such as that returned + from ACE_OS::time(). + +. Added support for VxWorks 6.x cross compilation using a Windows host + system + +. Added support for VxWorks 6.x using the diab compiler + +. The destructor of ACE_Event_Handler no longer calls + purge_pending_notifications(). Please see bugzilla #2845 for the full + rationale. + (http://deuce.doc.wustl.edu/bugzilla/show_bug.cgi?id=2845) + +USER VISIBLE CHANGES BETWEEN ACE-5.5.5 and ACE-5.5.6 +==================================================== + +. The ACE_TYPENAME macro has been added to those that are not + available when the ACE_LACKS_DEPRECATED_MACROS config option is set + (it is not set by default). You are encouraged to replace the use of + ACE_TYPENAME with the C++ typename keyword before the ACE_TYPENAME + macros is removed from ACE in the future. + +. A new script, rm_exception_macros.pl, has been added to help users + remove the use of the ACE exception macros from their own code. + +USER VISIBLE CHANGES BETWEEN ACE-5.5.4 and ACE-5.5.5 +==================================================== + +. The prebuild MPC keyword is now supported by the gnuace project type. + This fixes Bugzilla #2713. + +. Support for Windows earlier than NT 4 SP2 was removed. ACE will not build + for Windows 95, 98, Me, etc. out of the box any longer. + +. Reformat stringified IPv6 addresses to use [addr]:port when printing + addresses that contain ':' such as "::1". + +. Added method to ACE_INET_Addr to determine if address is IPv6 or + IPv4 multicast. + +. Fixed a bug in ACE_Async_Timer_Adapter_Timer_Queue_Adapter where the + gettimeofday function of the timer queue was ignored when setting the alarm. + +. Fixed a problem where, on Solaris 9 onwards, calling + ACE_OS::thr_create(THR_NEW_LWP) more than 2^15 (65535) times in a + process will fail. See changelog entry from "Wed Jan 3 22:31:05 UTC + 2007 Chris Cleeland " for more information. + +. Fixed a bug in ACE_QtReactor where the two select() calls in that function + might select on different handler sets. + +. ACE_SOCK_IO::recvv(iovec[], size_t, const ACE_Time_Value* = 0) and + ACE_SOCK_IO::sendv (const iovec[], size_t, const ACE_Time_Value* = 0) methods + were changed to specify the iovec count argument as int instead of size_t + since it gets reduced to int in the underlying OS calls (usually). + +. The following deprecated methods were removed: + + ssize_t ACE_SOCK_IO::recv (iovec iov[], + size_t n, + const ACE_Time_Value *timeout = 0) const; + + ssize_t ACE_SOCK_IO::recv (iovec *io_vec, + const ACE_Time_Value *timeout = 0) const; + + ssize_t ACE_SOCK_IO::send (const iovec iov[], + size_t n, + const ACE_Time_Value *timeout = 0) const; + + These were previously replaced with more specific recvv() and sendv() + methods. + +. The ACE_Service_Repository::find(const ACE_TCHAR name[], + const ACE_Service_Type **srp = 0, + int ignore_suspended = true) const + method's 'ignore_suspended' parameter was changed from int to bool to + reflect it's purpose as a yes/no indicator. + +. Added --enable-ace-reactor-notification-queue configure script + option to the autoconf build for enabling the Reactor's userspace + notification queue (defines ACE_HAS_REACTOR_NOTIFICATION_QUEUE in + config.h). + +. The int ACE_OutputCDR::consolidate(void) method was contributed by + Howard Finer at Sonus Networks. This method consolidates any continuation + blocks used by an ACE_OutputCDR object into a single block. It's useful for + situations which require access to a single memory area containing the + encoded stream, regardless of its length, when the length cannot be known + in advance. + +. There are a number of new methods defined on ACE_String_Base: + + size_t capacity (void) const: This method returns the number + of allocated CHAR units in the string object. + + void fast_resize (size_t): This method manage the sizing/reallocating + of the string, but doesn't do the memory setting of resize(). + + bool operator!= (const CHAR *) const + bool operator== (const CHAR *) const: These methods compare the + string with a nul-terminated CHAR* string. + + nonmember functions operator== and operator!= where also added + that compare const ACE_String_Base and const CHAR*; these make + it possible to switch ACE_String and CHAR* on either side of + the operator. + + Thank you to Kelly Hickel for these additions. + +. There are 2 new build options on the traditional make command: + dmalloc and mtrace. When specified at build time (e.g. make mtrace=1) + the PLATFORM_DMALLOC_CPPFLAGS and/or PLATFORM_MTRACE_CPPFLAGS values + are added to CPPFLAGS. For dmalloc, the PLATFORM_DMALLOC_LDFLAGS and + PLATFORM_DMALLOC_LIBS are added to LDFLAGS and LIBS, respectively. + Thank you to Howard Finer for supplying these additions. + +. Added the ability to specify additional purify and quantify command-line + options by setting PLATFORM_PURIFY_OPTIONS and PLATFORM_QUANTIFY_OPTIONS, + respectively. Thank you to Howard Finer for supplying these additions. + +. Added the ability to use trio (http://sourceforge.net/projects/ctrio/) + if platform lacks decent support for vsnprintf. trio support is + enabled by defining trio=1 in plaform_macros.GNU + +. Removed Irix 5, DGUX, and m88k support + +. Improved LynxOS 4.2 support + +. VxWorks 6.4 support + +. Added support for FC6. Because the GCC 4.1.1 version that gets shipped + has a fix for the visibility attribute we use for the singletons + you will need to define the following in your config.h file. This can't be + done automatically because SuSE 10.2 gets shipped with GCC 4.1.2 but + doesn't have the same fix + ACE_GCC_HAS_TEMPLATE_INSTANTIATION_VISIBILITY_ATTRS 1 + +. RTEMS port + +USER VISIBLE CHANGES BETWEEN ACE-5.5.3 and ACE-5.5.4 +==================================================== + +. Added appropriate intptr_t and uintptr_t typedefs on platforms that + don't provide them (i.e. when ACE_LACKS_INTPTR_T is defined). + +. Added ability to explicitly choose support for 32 bit or 64 bit file + offsets on all platforms. Define the _FILE_OFFSET_BITS preprocessor + symbol to either 32 or 64 to choose the desired number of file + offset bits. This preprocessor symbol is supported natively by most + UNIX and UNIX-like operating systems, and supported by ACE on + Windows. Use the new ACE_OFF_T typedef to refer to file offsets + across UNIX and Windows portably. + +. 64-bit file offsets are now enabled by default in Win64 + configurations. + +. Improved support for 64 bit platforms (64 bit addresses, etc). + +. Added STL-style traits, iterators and a swap() method to the + ACE_Array_Base<> class template. + +. Added STL-style traits and iterator accessors to the + ACE_Hash_Map_Manager_Ex<> class template, as well as new find() and + unbind() methods that return (as an "out" parameter) and accept + iterators, respectively. + +. Greatly improved event handler dispatch performance in + select()-based reactors (e.g. ACE_Select_Reactor and ACE_TP_Reactor) + for large handle sets on Windows. Previous event handler search + were linear, and are now constant on average. + +. Addressed a number of Coverity errors (CHECKED_RETURN, DEADCODE, + LOCK, USE_AFTER_FREE, RESOURCE_LEAK, FORWARD_NULL). + +. Added STL-style "element_type" trait to all ACE auto_ptr class + templates. + +. Removed support for LynxOS 3.x. + +. Resolved Bugzilla #2701 to ensure fini() is called for all + Service Objects upon calling ACE_Service_Config::close() + +. VxWorks 5.5.2 has been tested, for ACE the support is exactly + the same as for VxWorks 5.5.1. No specific defines or flags have + to be used. + +USER VISIBLE CHANGES BETWEEN ACE-5.5.2 and ACE-5.5.3 +==================================================== + +. Added the base projects for executionmanager_stub and plan_generator. + +. Added the ACE_Hash_MultiMap_Manager class and its test file. + +. Changed the ACE_Synch_Options::operator[] method to return bool rather than + int. The value returned is a yes/no indication of whether or not the + specified option(s) are set in the object. + +. Changed the prototype(s) for ACE::debug () to return (and take) a + bool. This is consistent with the original intent for this + feature. If you have been using it like 'ACE::debug () > 0' or + 'ACE::debug (1)', you may have to rebuild ACE. The value of the + ACE_DEBUG environment variable can be used to specify the initial + value for ACE::debug(), at the process start up. + +. An assembler (within a C source file) based implementation for SPARC + of atomic operations suitable for use with the + ACE_Atomic_Op and + ACE_Atomic_Op specializations has + been added. Currently, it can only be enabled by setting the + atomic_ops_sparc make macro to 1 when using the GNUACE build system with + the Solaris SunCC compiler. It should be noted that this requires the + -xarch=v8plus (or higher) be added to the CFLAGS make macro or the + assembler code will not compile. + +. The ACE_Message_Queue_Ex_N class + is new, contributed by Guy Peleg . + ACE_Message_Queue_Ex_N is + similar to ACE_Message_Queue_Ex in that the object queued is a + template parameter. However, ACE_Message_Queue_Ex_N allows the + enqueueing and dequeueing of multiple chained objects at once. This + wasn't added to ACE_Message_Queue_Ex because the chained object + functionality requires the ACE_MESSAGE_TYPE class to have a + ACE_MESSAGE_TYPE *next (void) const method, analogous to + ACE_Message_Block::next(), to follow the chain and this would + probably break existing applications using ACE_Message_Queue_Ex. + The ACE_wrappers/tests/Message_Queue_Test_Ex.cpp test has an example of + how to use the new class. + +. The selector and comparator function pointer arguments to ACE_OS::scandir() + and ACE_Dirent_Selector are now marked as extern "C" to enforce their + use with a C RTL function. User code that defines functions which are + passed as the selector or comparator arguments which are not declared + extern "C" may generate compile warnings. To resolve this, add extern "C" + to the function's signature. See ACE_wrappers/tests/Dirent_Test.cpp for + an example. + +. To address a problem in the ACE string interface that prevented + substring or character searches in very large strings (e.g. greater + than the maximum value of an ssize_t type) from being correctly + reported to the caller, the find(), rfind() and strstr() methods now + return an unsigned integer (size_t) instead of a signed one + (ssize_t). Affected classes include: + + * ACE_CString + * ACE_WString + * ACE_TString + * ACE_NS_WString + + Unless you have been explicitly using -1 instead of npos when + comparing the return value of find(), rfind() and strstr(), and/or + assigning the return value to ssize_t you should not see any + difference. A new size_type typedef has been added to the ACE string + class to aid developers. This typedef is analogous to the standard + C++ string::size_type typedef. + + The ACE_String_Base<>::strstr() documentation and the default + rfind() argument erroneously referred to -1 instead of npos. Those + instances have been corrected. + + To summarize, a "no position" condition is denoted using the npos + constant, not -1. It can be referred directly by scoping it with the + appropriate string class (e.g. ACE_CString::npos, ACE_WString::npos, + etc). + +. Changing the shared library extension for hpux ia64 to ".so". On + HP-UX 11i Version 1.5 the naming scheme is lib*.sl for PA and + lib*.so on IPF. + +. The ACE_Refcounted_Auto_Ptr reset() and release() methods were changed + per Bugzilla #1925. They will both now detach from the underlying + ACE_Refcounted_Auto_Ptr_Rep object; reset() will create a new one for + the new pointer specified as its argument. This change may cause referenced + objects to be deleted in cases where previous ACE versions would not have. + +. The return type of "ACE_Refcounted_Auto_Ptr::null (void) const" changed + from int to bool. It's possible values, true and false, have not changed. + +. TTY_IO now accepts "none" as a valid parity value. Due to this change + 'parityenb' member is now deprecated and will be removed in the future. + The users of TTY_IO class should change their code to use only 'paritymode' + member for parity control and leave 'parityenb' unchanged (it is + enabled by default in class constructor). + +. Support for Intel C++ 9.1 on Windows and Linux + +. VxWorks 6.3 support + +. Fixed Bugzilla #2648 to make sure ACE_Service_Object::fini() + is called iff ACE_Service_Object::init() succeeded, as per + C++NPv2. + +. Added preliminary support for Mac OS X 10.4 on Intel CPU's. + +. Fixed Bugzilla #2602 to re-enable XML Service Configurator + file support. + +USER VISIBLE CHANGES BETWEEN ACE-5.5.1 and ACE-5.5.2 +==================================================== + +. Added support for: + - VxWorks 6.2 for the rtp model using pthread support + - OpenVMS 8.2 for Alpha + +. Removed code and configurations that provided support for: + - Visual C++ 6.0 and 7.0 + - Chorus + - pSOS + - KAI C++ on all platforms + +. Explicit template instantiation support has been removed. This effectively + removes support for Sun Forte 6 and 7 which required explicit template + instantiation to build ACE reliably. + +. Added support for multiple independent Service Repositories through + configuration contexts called "Gestalt". Full backwards compatibility + is maintained through the existing ACE_Service_Config static methods, + while direct individual repository access is enabled through instances + of the new ACE_Service_Gestalt class. ACE_Service_Config has changed to + a specialization of ACE_Service_Gestalt and is only responsible for the + process-wide configuration. + +. To support dynamically-sized ACE_Log_Record messages, the netsvcs + logging components now use ACE CDR encoding and transfer mechanisms + inspired by the examples in Chapter 4 of the C++NPv1 book. + The client and server logging daemons in ACE 5.5.2 and forward will + not interoperate with those in previous ACE versions. + +. Added a wrapper for the sendfile API (ACE_OS::sendfile()). + +. Added support for netlink sockets on Linux. + +. Added a new method, ACE_Task::last_thread(). This method returns the thread + ID (ACE_thread_t) of the last thread to exit from the ACE_Task object. + Users checking to see if a thread is the last one out (for example, to know + when to perform cleanup operations) should compare the current thread ID to + the return value from last_thread(). This is a change from the previously + recommended practice (C++NPv2, page 189) of comparing the return value of + thr_count() with 0. + +. Changed the first argument to ACE_OS::strptime() to be 'const' which + matches its usual usage in POSIX strptime(). This change allows users to + pass const strings in - a common use case. + +. Made part of the file support in ACE 64bit but we have some places where + 32bit types are used, this could lead to some conversion warnings which + will be addressed in the near future, but getting everything 64bit + compliant is a lot of work. + +USER VISIBLE CHANGES BETWEEN ACE-5.5 and ACE-5.5.1 +==================================================== + +. Added support for the --enable-symbol-visibility configure option + to the autoconf build infrastructure instead of solely relying on + feature tests to enable/disable symbol visibility support. This + avoids build problems with icc, etc. + +. Added support for the --enable-fl-reactor configure option to the + autoconf build infrastructure to build the ACE_FlReactor library. + +. Added support for the --enable-qt-reactor configure option to the + autoconf build infrastructure to build the ACE_QtReactor library. + +. Added support for the --enable-xt-reactor configure option to the + autoconf build infrastructure to build the ACE_XtReactor library. + +. Fixed a bug that would cause timer IDs from ACE_Timer_Heap to be + improperly duplicated under certain conditions (Bugzilla #2447). + +. Fixed ACE_SSL_Context::private_key(), context(), and dh_params() methods + to allow retrying a file load after a failed call. + +. Fixed ACE_SSL_Asynch_Stream so it can be instantiated; also moved the + declarations for ACE_SSL_Asynch_Read_Stream_Result, + ACE_SSL_Asynch_Write_Stream_Result, and ACE_SSL_Asynch_Result classes + to the ace/SSL/SSL_Asynch_Stream.h file so applications can see them. + +USER VISIBLE CHANGES BETWEEN ACE-5.4.10 and ACE-5.5 +==================================================== + +. Added a platform macros option "templates=manual", currently only + applies to AIX 5.3 with XL 7 compiler. It allows the user to tell the + compiler to set -qnotempinc and -qnotemplateregistry and works well + in static builds. + +. ACE and its tests compile error free with GCC 4.1 pre release. + +. ACE_Recursive_Thread_Mutex::get_nesting_level() fixed for 64-bit Windows + XP on amd64/EM64T hardware. + +. Many build-time fixes for Windows Mobile 5 and Windows PocketPC 2003 using + Visual Studio .NET 2005 (VC8). + +. Added support for the --enable-tk-reactor configure option to the + autoconf build infrastructure to build the ACE_TkReactor library. + +USER VISIBLE CHANGES BETWEEN ACE-5.4.9 and ACE-5.4.10 +==================================================== + +. Fixed a bug in ACE_Timer_Heap_T::cancel(). + +. Improved ACE_Time_Value support for boundary conditions. + +. Fixed problems with operator placement delete on certain C++ compilers. + +. Fixed a bug with the ACE_SPIPE_Acceptor on Windows. + +. Correctly set sockaddr_in.sin_len and sockaddr_in6.sin6_len on + platforms that have these fields. + +. Avoided problems with namespace pollution for max() macros. + +. Many fixes for ACE_LACKS* and ACE_HAS* macros for autoconfig. + +USER VISIBLE CHANGES BETWEEN ACE-5.4.8 and ACE-5.4.9 +==================================================== + +. Added dozens of new ACE_LACKS and ACE_HAS defines which are used to + simplify the ACE_OS layer + +. Constructors of ACE_Time_Value have been made explicit to prevent + implicit conversions. + +. Added a shutdown() method to ACE_Barrier. The new method aborts the + wait by all threads. + +. Changed the behavior of ACE_Message_Queue::enqueue_head() and + enqueue_tail(). If the enqueued message block has other blocks + chained to it via its next() pointer, the entire chain of blocks + will be enqueued at once. + +. Improved the support for high-resolution timers with + ACE_Timer_Queue_Adapter. + +. Make it possible to disable file caching in JAWS. + +. Improved ACE_Pipe implementation so that it uses localhost to avoid + firewall problems. + +. Added Unicode support to the Service Configurator. + +USER VISIBLE CHANGES BETWEEN ACE-5.4.7 and ACE-5.4.8 +==================================================== + +. Improved IPv6 support + +. Improved 64bit portability + +. TTY_IO overhaul + - Improved documentation. + - It is now possible to request infinite timeout in portable manner. + This can be achieved by setting negative value to readtimeoutmsec. + - Various bugs fixed and portability issues resolved. + +. Subset ACE for TAO and TAO Services + +. Support for Intel C++ 9.0 on Windows and Linux + +. Support for Microsoft Visual Studio 2005 (aka VC8) for Win32 as well + as the Windows CE platforms Pocket PC 2003 and Windows Mobile 5. + Solution/project files are generated with an appended "_vc8" for + Win32 and "_WinCE" for the CE platforms. See + ACE_wrappers/docs/CE-status.txt for more information. + +. Completed implementation of ACE_Dev_Poll_Reactor using the Linux epoll + facility; tested on Red Hat Enterprise Linux 4. + +. The in-memory size of an ACE_RB_Tree will be smaller due to rearranged + placement of pointers. + +. Added an optimization to CDR stream to ignores alignment when marshaling + data. Use this new ACE_LACKS_CDR_ALIGNMENT compile-time option only + when the ACE_DISABLE_SWAP_ON_READ macro is enabled. This new option + requires ACE CDR engine to do both marshaling and demarshaling, and + when this option is enabled the encoded streams are no longer + compliant with the CORBA CDR specification. + +. Developed Feature Oriented Customizer (FOCUS) tool to enable + specialization of middleware frameworks such as Reactor and Protocol + framework. FOCUS provides an XML based transformation engine, where + the transformations to specialize the components are captured in XML + file and a weaver specializes the code. + +. Added support for unrolling ACE_OS::memcpy copy loop where + applicable to improve performance. Autoconf tests empirically + determine whether loop unrolling is at least 10% better than default + version. + +. Added support for an ACE "versioned" namespace. When enabled, ACE + library sources will be placed within a namespace of the user's + choice or a namespace of the form ACE_5_4_7 by default, where + "5_4_7" is the ACE major, minor and beta versions. The default may + be overridden by defining the ACE_VERSIONED_NAMESPACE_NAME + preprocessor symbol. Enable overall versioned namespace support by + adding "versioned_namespace=1" to your MPC default.features file. + +USER VISIBLE CHANGES BETWEEN ACE-5.4.6 and ACE-5.4.7 +==================================================== + +. Support for shared libraries with VxWorks + +. Support for Solaris 10 on x86 with Sun Studio 10 (C++ 5.7). + +. Extended ACE_OS::event_xxx implementation to support platforms + having either PThread support with Process Shared condition + variables or POSIX semaphores with named (process shared) + semaphore support or using the new FIFO based semaphores. + +. ACE_OS::closesocket() no longer calls ACE_OS::shutdown() on any platform + while closing the socket. It previously called ACE_OS::shutdown() on + HP-UX. Removing this call fixes the fork-and-close programming paradigm + that's common to many networked applications. + +. RMCast + - Support for message fragmentation. This will allow + for messages larger than 64K. + - Support for flow control. + - Timed recv() in RMCast::Socket. + - Per-instance configurable protocol parameters (e.g., message + retention time, NAK timeout, etc). + +USER VISIBLE CHANGES BETWEEN ACE-5.4.5 and ACE-5.4.6 +==================================================== + +. Updated RMCast to include + - Reactor-compatible interface. + - Message unavailability reporting. + - Protocol documentation. + +. Added support for 64bit Visual Age on AIX + +. Improved g++ 4.0 support. A number of RTTI related problems have been + fixed. + +. Smaller footprint. + +. Fixed memory leaks ACE_DLL and ACE_Log_Msg classes. + +. The ACE::ICMP_Socket and ACE::Ping_Socket classes were moved out of + the ACE namespace and "flattened" to ACE_ICMP_Socket and + ACE_Ping_Socket to be consistent with the rest of ACE. + +. ACE_INET_Addr::set_address() - fixed a possible struct member + alignment issue when building an IPv4-mapped IPv6 address. + +. Added a new ACE::wild_match() function to match a string based on + wildcards. + +. Added efficient overloads for string concatenation to the + ACE_String_Base class. + +. Added support for the use of pthread_getschedparam on MacOS X. + +. Fixed an issue with static initialization of TSS related classes on + static builds for Windows. + +USER VISIBLE CHANGES BETWEEN ACE-5.4.4 and ACE-5.4.5 +==================================================== + +. Remove special handling in the Thread Specific Storage(TSS) code + that released the TSS key for ACE_TSS. ACE_TSS has + been changed to explicitly free the TSS key when necessary. + +. On Win32 systems: detect thread termination via a hook in DLLMain + for ACE.dll. This allows cleanup of TSS objects for non-ACE threads + that use ACE functions. The most common case was threads that used + ACE logging. Formerly any TSS objects created by these threads would + be leaked. + +. Added support for GNU G++ 4.0. The x.4.5 beta takes advantage of + g++ 4.0's symbol visibility. This feature is conceptually similar + to MS Windows "__declspec(dllexport)" DLL functionality. Using this + new g++ feature results in substantially improved ACE/TAO/CIAO + shared library binaries. A subset of the improvements include the + following: + + * The number of unnecessarily exported DSO/DLL symbols is + greatly reduced, resulting in faster program start times. + * Smaller footprint. + * Improved performance since run-time indirection of internal + symbols is no longer needed. + + No changes to the ACE/TAO sources were necessary to support this + feature since the required visibility attributes were hidden behind + the various "*_Export" macros (formerly only useful for MS Windows + DLLs) used throughout ACE/TAO. + +. The ACE_Reactor destructor will now call close() on the referenced reactor + implementation. This assures that all handlers are notified before the + ACE_Reactor object that's most likely referenced in these handlers is + invalid. Although this should not be a user-visible change, it did catch + some ACE tests off guard destroying reactor implementations and ACE_Reactor + interfaces in the wrong order, so it may come up in the field as well. + When using dynamically allocated reactor implementations, do not destroy + the implementation object before the ACE_Reactor interface object. Use of + the ACE_Reactor constructor's delete_implementation argument (with a value + of 1) is recommended when dynamically allocating reactor implementations. + +. Improved performance of HTBP by not requiring a lookup of peer hostname. + +. Added new ACE_SizeCDR stream which allows one to calculate size of the + representation without writing anything. + +. Number of improvements in RMCast, reliable multicast implementation. + +USER VISIBLE CHANGES BETWEEN ACE-5.4.3 and ACE-5.4.4 +==================================================== + +. The ace-config script has been replaced by pkg-config metadata files + which are installed in ${prefix}/lib/pkgconfig by the automake build. + +. Remove ACE_OS::gets() implementation. While this ACE implementation + of gets() did not contain the security holes that all standard + gets() implementations have, keeping it around only serves to foster + confusion since (1) some may incorrectly assume that this + ACE-specific gets() implementation has the same holes as standard + ones, and (2) invoking it with a default size argument so that it + looks like a standard gets() call results in behavior that is + different from the standard. Use ACE_OS::fgets() instead. + +. Removed ACE_Unbounded_Set_Ex, this gave the false idea that it had + thread safe iterators. Use ACE_Unbounded_Set instead + +. Improved VxWorks support for static libraries. Shared libraries do cause + several known problems which will be fixed in the x.4.5 release. + +. Removed the usage of the ACE_x_cast macros, we are using the C++ casts + from now on. The ACE_x_cast macros are deprecated and will be removed + after the x.5.1 release + +. Some improvements in autoconf support; better detection of available + OS and compiler features. + +. Fixed bugs in ACE TSS emulation + +USER VISIBLE CHANGES BETWEEN ACE-5.4.2 and ACE-5.4.3 +==================================================== + +. Improved Cygwin 1.5.12 support, 90% of the tests now succeed + +. Improved OpenVMS support. + +. Added ability to use fltk with Cygwin/MinGW + +. Added ACE_INT64 that defines a native 64 bit type. + +. Added 'q' as usable specifier for ACE_Log_Msg to print out int64 bit number. + +. Added better support for Intel C++ compilers. + +. Improved HPUX support. + +. Added a new directory ("ACE_wrappers/protocols/ace") for new protocols + that are not directly components of ACE, but are relate to ACE and + defined a new protocol, HTBP (Hypertext Tunneling, Bidirectional + Protocol) providing ACE_Acceptor/Connector/Stream semantics over a + connection owned by an HTTP proxy. Test cases in + ACE_wrappers/tests/HTBP provide examples of use. + +. Performace enhancement in TP_Reactor's handle_timer_events method [Bug + 1971]. + +. Various changes to permit ACE to execute on HP NonStop platform (e.g + support for its pthreads version). + +. Updated HP NonStop configuration files (config-tandem-nsk). + +. The "ACE" pseudo-namespace is now a true C++ namespace. Transitional + pseudo-namespaces that were only meant to be used internally by ACE, + such as "ACE_Sock_Connect", no longer exist. + +. ACE_CDR::Boolean type is now a true C++ "bool" on all platforms except + MSVC++ 6. We plan to deprecate MSVC++ 6 support sometime after the + x.5 release of ACE+TAO+CIAO, so we recommend you start migrating to a + later version of MSVC++. + +. More GNU g++ 3.4.x fixes. + +. Added ICMP and "ping" socket support. + +. Added mkstemp() emulation. + +. Fixed problem on Linux < 2.5.47 platforms where equality comparison of + two logically equal sockaddr_in structure instances would incorrectly + fail. + +. Support for wide characters has been improved on non-Windows + platforms. + +. A number of Windows CE problems have been fixed. + +. ACE's loading of DLLs (for example, as a result of loading synamic + services) has been changed to use the native OS's facilities for + locating the DLL instead of searching LD_LIBRARY_PATH (or its + equivalent) then loading the DLL using a full pathname. This restores + enforcement of a platform's loading and security policy. To use the + old DLL locating method, add ACE_MUST_HELP_DLOPEN_SEARCH_PATH to your + config.h file before building ACE. + +. A number of errors in the APG example programs have been corrected. + +. Select_Reactor and Priority_Reactor performance improved. [Bug 1890] + +. Wide-char functionality on POSIX (Linux, etc.) + +. TSS memory leak fixes [Bug 1542] + +. Ported to HPUX 11i v2 on Itanium + +. Added code to ACE for platform RedHat AS 3.0 on Opteron. + +. Changed ACE::crc32() family of functions to NOT fold in the length of + the string/buffer/iovec into the CRC. + + +USER VISIBLE CHANGES BETWEEN ACE-5.4.1 and ACE-5.4.2 +==================================================== + +. Support for g++ 3.4.1. + +. All ACE Makefiles, project files, etc, are now generated by OCI's + "MakeProjectCreator" (MPC) tool. Makefiles and project files for + commonly used configurations have been pre-generated and distributed + with the beta(s). Please see: + + $ACE_ROOT/ACE-INSTALL.html + + for information on how to use MPC with ACE. + +. Improved Doxygen documentation. + +. Reduced header file dependencies, which should speedup compilation + and help minimize static footprint. + +. ACE now requires support for the following standard C++ features: + + - "bool" keyword + + - "mutable" keyword + + - "explicit" keyword + + - C++ casts (e.g. static_cast<>, reinterpret_cast<>, dynamic_cast<> + and const_cast<>) + + If you're using a compiler that does NOT support these features + please contact Steve Huston for support. + +. Changed the select()-based reactor implementations to scan for + broken handles to remove based on the registered handles, not on + event handlers. This allows for bad handles to be removed from the + reactor even if the event handler doesn't implement get_handle() the + way we expect. + +. Support for Pthreads native recursive mutexes was added. This + capability is specified to ACE_OS::mutex_init() as an optional + argument, lock_type. To fix confusion from an earlier attempt to add + this functionality, the meaning of the old 'type' argument to + ACE_OS::thread_mutex_init() is changed. It previously combined the + scope and type. Now it is just the type (e.g. recursive), as the + scope is inherent in the method used. For clarification on + ACE_HAS_RECURSIVE_MUTEXES, it means that the platform is capable of + them, not that they always are, as one would expect. However, before + Pthreads had recursion added, it was never optional. Now it is. + +. Initial support for new Linux sys_epoll() interface in + Dev_Poll_Reactor. The obsolete Linux /dev/epoll interface is no + longer supported. + +. Improved Cygwin support. + - Threading works without problems. + - Problems with shared memory, process shared mutexes, multicast and + some other small things still exist. + +. New OpenVMS port. + - This is for the latest version of OpenVMS with all available ECOs + applied. Basic stuff works without problems. Advanced features + still need some work. + +. Usage of ASYS_INLINE is deprecated in ACE. Use ACE_INLINE instead. + +. All inline source files now end in ".inl". The previous ".i" + extension is generally used for preprocessed C sources. + +. Autoconf support has been improved and fixed on a number of + platforms, including the BSD variants (e.g. FreeBSD). It is still + not the preferred way to configure most platforms, but it is ready + for wider testing. Please report any problems found to + ace-bugs@cs.wustl.edu. + +. A number of fixes were made to quiet compile errors and warnings on + 64-bit Windows. + +. For builds on AIX using Visual Age C++, the make rtti option default + was changed to 1, enabling RTTI by default. + +. ACE_Service_Repository::remove() has a new, optional argument that + can receive the service record pointer for the removed service. If + the pointer is returned to the caller, it is not deleted. If the + pointer is not returned to the caller (the default) it is deleted + (this is the historic behavior). + +. The tutorials in ACE_wrappers/docs have been removed. They were not + being maintained and caused confusion in a number of cases. Now that + there are complete examples that match the printed books (C++NPv1, + C++NPv2, APG), the older tutorials are no longer useful. Please see + + $ACE_ROOT/examples/C++NPv1/ + $ACE_ROOT/examples/C++NPv2/ + $ACE_ROOT/examples/APG/ + + for the source code of the examples in those books. + +. ACE_String_Base::fast_clear() is a new method which sets the string + length to 0. Doesn't release string-allocated memory, but if the + memory was externally supplied, it is no longer referenced from the + string object. + +. A true C++ "bool" is now used as the CDR stream boolean type, if + supported by the compiler. + +. Renamed AIX 5L configuration header from config-aix5.1.h to + config-aix-5.x.h. + +. All C++ equality, relational and logical operators now return bool + instead of int, as is the norm for modern C++. + +. Added new ACE_OS::realpath() implementation. Contributed by Olli + Savia + + +USER VISIBLE CHANGES BETWEEN ACE-5.4 and ACE-5.4.1 +==================================================== + +ACE +--- + +. Fixed "make install" support in ACE+autoconf configurations. + +. Fixed autoconf support on Solaris. + +. Corrected invalid `aux' directory (on MS Windows) found in ACE + distribution. + +. ACE/TAO build now without problems with MinGW and all ACE tests run + now without problems + +. Added some more support for the new CBuilderX Preview compiler, this + is not 100% ready yet because the compiler is still a preview and + has its own problems. + +. Added Visual SlickEdit 8.1 MPC template + +. Added workaround for compile problems in Borland Release builds + +. Cygwin 1.5.9 is now supported + +. Tests for IPV6 have been added + +. Implement lstat() so that it'll use stat() on platforms that don't + support lstat(). + +. Problems related to ACE_Event_Handler usage in WFMO_Reactor was + fixed. + +. A wrapper for rmdir () has been added. + +. Threads spawned in thread-per-connection mode never inherited the + priority. This problem was fixed and this fix is consistent with the + C++ NPV* books. + +. Fixed memory leaks with ACE_String_Base::resize () + +. Enable the usage of native recursive mutexes for the implementation + of ACE recursive mutexes on Linux. + +. The ACE Proactor framework can now be enabled for AIX 5.2. Since AIO + functionality is not run-time enabled by default on AIX 5.2, the ACE + Proactor code is not built by default on AIX. To enable it, the + config.h file must contain #define ACE_HAS_AIO_CALLS before + including the config-aix-5.1.h file. + +. The ACE_POSIX_CB_Proactor implementation is now built on all + platforms except LynxOS. + + +USER VISIBLE CHANGES BETWEEN ACE-5.3.6 and ACE-5.4 +================================================== + +ACE: +--- +. Added a new makefile commandline flag, static_link, that can be + used to force static linking when static_libs_only is turned on. It + uses the new STATIC_LINK_FLAG variable and is currently only + implemented for for GNU ld, i.e., it adds the "-static" option to + LDFLAGS. It's turned off by default since using it causes the + footprint to go up by almost 1 MB on Linux, since it links all the + system and compiler .a files, but can be turned on if users + want/need to use it, by enabling both static_libs_only and static_link. + + +. Added macros ACE_USES_GPROF which enables users to use gprof in a + multithreaded environment with ACE libs. + +. Added a new functor template class, ACE_Malloc_Lock_Adapter_T, + that's used by ACE_Malloc_T as a factory for the ACE_LOCK template + parameter, and allows the use of locking strategy classes, like + ACE_Process_Semaphore and ACE_Thread_Semaphore that don't have a + satisfactory ctor taking a single required ACE_TCHAR* parameter, to + be adapted to work with ACE_Malloc_T. + +. The source code examples from "The ACE Programmer's Guide" book by + Huston, Syyid, and Johnston, are now located in + $ACE_ROOT/examples/APG. + +. Support for GNU autoconf is now in ACE. Please see ACE-INSTALL.html + for details. + +. Fixed problems that prevented ACE from being compiled on LynxOS + 4.0.0. + +. Fixed compilation error which prevented ACE from being compiled when + ACE_COMPILE_TIMEPROBES was set to 1. + +. Preliminary support for Tandem NSK has been added. + +. Lots of bug fixes with TLI and XPG5. Please see $ACE_ROOT/ChangeLog + for details. + +. Fixed ACE_OS::event_timedwait() and ACE_OS::event_wait() so that + they use a while loop around the ACE_OS::cond_[timed]wait() calls to + avoid problems with spurious wakeups, etc. + +. ACE's wrapper around getipnodebyname() and getipnodebyaddr () has + been made go through the IPv4-only case on ACE_WIN32. Since Windows + IPv6 implementation doesn't offer support (at thistime) for + getipnodebyname() the code has been changed to use the IPV4 part of + the code. + +. Install with Borland C++ of ACE library fixed + +ACEXML: +------- + +. Fixed memory leak in ACEXML parser. + +. Fixed implementations of rewind() in all the CharStreams. They were + broken previously. + +. Fixed bugs in the parser associated with incorrect handling of PE + References for keywords. diff --git a/dep/ACE_wrappers/PROBLEM-REPORT-FORM b/dep/ACE_wrappers/PROBLEM-REPORT-FORM new file mode 100644 index 00000000000..5382135f458 --- /dev/null +++ b/dep/ACE_wrappers/PROBLEM-REPORT-FORM @@ -0,0 +1,90 @@ +[Please use the PRF form below to submit bug reports, problem reports, + etc., to the ACE developers and interested users. Send to + ace-bugs@cs.wustl.edu. If you are using OCI, PrismTech, or + Riverace's versions of ACE do not send bugs to this mailing list, but + instead contact those companies for support. Please also send your + PRF as plain ASCII text, _not_ uuencoded or as an attachment. + + We prefer that all bug reports be submitted through our bug tracking + system. See $ACE_ROOT/docs/usage-bugzilla.html for more information + about how to do this. If you are unsure as to whether your problem + is a real bug or not then please submit your question to the mailing + list using the following form. Not using the problem report form + will make it harder or impossible to identify the problem, and in + many cases we will be unable to help at all. Also please try to + browse bugzilla and the ChangeLog files to find out if your problem + has been solved in a more recent version of ACE. + + To ensure that you see responses, please do one of the following: + + 1) Subscribe to the ace-bugs mail list, by sending email with + contents "subscribe ace-bugs" to majordomo@cs.wustl.edu. + + 2) Or, monitor the comp.soft-sys.ace newsgroup for responses. + + Replace/remove all the explanatory text in brackets before mailing. + + Please send this form as ASCII text only. Do _not_ send it as an + attachment, or as tar'ed, compressed and/or uuencoded text. And + limit line lengths to less than 80 characters. + + PLEASE make your Subject: line as descriptive as possible. + Subjects like "ACE bug" or "bug report" are not helpful! + Also, do _not_ include the word "help" in the Subject!] + + When including your config.h and platform_macros.GNU files as requested + below, only include the contents if you use the recommended method of + including the platform-specific file in your file. If you use a link + to the platform-specific file, simply state which one - DO NOT + include an entire platform-specific configuration file in the form. + +8<----------8<----------8<----------8<----------8<----------8<----------8<---- + +To: ace-bugs@cs.wustl.edu +Subject: [area]: [synopsis] + + ACE VERSION: 5.6.6 + + HOST MACHINE and OPERATING SYSTEM: + If on Windows based OS's, which version of WINSOCK do you + use?: + + TARGET MACHINE and OPERATING SYSTEM, if different from HOST: + COMPILER NAME AND VERSION (AND PATCHLEVEL): + + THE $ACE_ROOT/ace/config.h FILE [if you use a link to a platform- + specific file, simply state which one]: + + THE $ACE_ROOT/include/makeinclude/platform_macros.GNU FILE [if you + use a link to a platform-specific file, simply state which one + (unless this isn't used in this case, e.g., with Microsoft Visual + C++)]: + + CONTENTS OF $ACE_ROOT/bin/MakeProjectCreator/config/default.features + (used by MPC when you generate your own makefiles): + + AREA/CLASS/EXAMPLE AFFECTED: +[What example failed? What module failed to compile?] + + DOES THE PROBLEM AFFECT: + COMPILATION? + LINKING? + On Unix systems, did you run make realclean first? + EXECUTION? + OTHER (please specify)? +[Please indicate whether ACE, your application, or both are affected.] + + SYNOPSIS: +[Brief description of the problem] + + DESCRIPTION: +[Detailed description of problem. Don't just say " +doesn't work, here's a fix," explain what your program does +to get to the state. ] + + REPEAT BY: +[What you did to get the error; include test program or session +transcript if at all possible. ] + + SAMPLE FIX/WORKAROUND: +[If available ] diff --git a/dep/ACE_wrappers/README b/dep/ACE_wrappers/README new file mode 100644 index 00000000000..1b46d7fd6f4 --- /dev/null +++ b/dep/ACE_wrappers/README @@ -0,0 +1,222 @@ +This document is also available at the following URL: + +http://www.cs.wustl.edu/~schmidt/ACE.html + +All software and documentation is available via both anonymous ftp and +the World Wide Web.] + +THE ADAPTIVE COMMUNICATION ENVIRONMENT (ACE) + +An Object-Oriented Network Programming Toolkit + +---------------------------------------- + +Overview of ACE + +The ADAPTIVE Communication Environment (ACE) is an object-oriented +(OO) toolkit that implements fundamental design patterns for +communication software. ACE provides a rich set of reusable C++ +wrappers and frameworks that perform common communication software +tasks across a range of OS platforms, including Win32/Win64, most +versions of UNIX (e.g., SunOS, HP-UX , AIX, Linux, NetBSD, and FreeBSD), +real-time operating systems (e.g., VxWorks, Chorus, LynxOS, and QNX), +OpenVMS, and MVS OpenEdition. A single source tree is used for all +these platforms and porting ACE to other platforms is relatively easy. + +The communication software components provided by ACE include event +demultiplexing and event handler dispatching, service initialization, +interprocess communication, shared memory management, message routing, +dynamic (re)configuration of distributed services, multi-threading, +and concurrency control. There are both C++ and Java versions of ACE +available. + +ACE is targeted for developers of high-performance and real-time +communication services and applications on UNIX, POSIX, and Win32 +platforms. ACE simplifies the development of OO network applications +and services that utilize interprocess communication, event +demultiplexing, explicit dynamic linking, and concurrency. ACE +automates system configuration and reconfiguration by dynamically +linking services into applications at run-time and executing these +services in one or more processes or threads. + +ACE is currently used in commercial projects and products by dozens of +companies including Ericsson, Bellcore, Siemens, Motorola, Kodak, +Boeing, Lucent, DEC, Lockheed Martin, and SAIC. Commercial support +for ACE is available from several companies as listed at +http://www.cs.wustl.edu/~schmidt/commercial-support.html + +---------------------------------------- + +C++ Wrappers for OS Interfaces + +The lower-level portions of ACE provide a set of portable and +type-secure C++ wrappers that encapsulate the following C language OS +interfaces: + + . IPC mechanisms + -- e.g., Internet- and UNIX-domain sockets, TLI, Named + Pipes (for UNIX and Win32) and STREAM pipes; + + . Event demultiplexing + -- e.g., select(), poll(), and Win32 + WaitForMultipleObjects and I/O completion ports; + + . Multi-threading and synchronization + -- e.g., Solaris threads, POSIX Pthreads, and Win32 + threads; + + . Explicit dynamic linking + -- e.g., dlopen/dlsym on UNIX and LoadLibrary/GetProc + on Win32; + + . Memory-mapped files and shared memory management + -- e.g., BSD mmap(), SYSV shared memory, and Win32 + shared memory; + + . System V IPC + -- e.g., shared memory, semaphores, message queues. + +The OS Adaptation Layer shields the upper levels of ACE from platform +dependencies associated with the underlying OS interfaces. + +---------------------------------------- + +Frameworks and Class Categories + +ACE also contains a higher-level network programming framework that +integrates and enhances the lower-level C++ wrappers. This framework +supports the dynamic configuration of concurrent distributed services +into applications. The framework portion of ACE contains the +following class categories: + + . The Reactor + -- Supports both Reactive and Proactive I/O; + + . The Service Configurator + -- Support dynamic (re)configuration of objects; + + . The ADAPTIVE Service Executive + -- A user-level implementation of System V STREAMS, + that supports modular integration of + hierarchically-related communicaion services; + + . Concurrency + -- Various types of higher-level concurrency + control and synchronization patterns (such as + Polymorphic Futures and Active Objects); + + . Shared Malloc + -- Components for managing dynamically allocation + of shared and local memory; + +---------------------------------------- + +Distributed Services and Components + +Finally, ACE provides a standard library of distributed services that +are packaged as components. These service components play two roles +in ACE: + + 1. They provide reusable components for common distributed + system tasks such as logging, naming, locking, and time + synchronization. + + 2. They illustrate how to utilize ACE features such as the + Reactor, Service Configurator, Service Initialization, + Concurrency, and IPC components. + +---------------------------------------- + +Middleware Applications + +ACE has been used in research and development projects at many +universities and companies. For instance, it has been used to build +avionics systems at Boeing, telecommunication systems at Bellcore, +Ericsson, Motorola, and Lucent; medical imaging systems at Siemens and +Kodak; and many academic research projects. Two example middleware +applications provided with the ACE release include: + + 1. The ACE ORB (TAO) -- TAO is a real-time implementation of + CORBA built using the framework components and patterns + provided by ACE. + + 2. JAWS -- JAWS is a high-performance, adaptive Web server + built using the components in ACE. + +---------------------------------------- + +OBTAINING ACE + +The current ACE release is provided as a tar file that is around 3 Meg +compressed using GNU gzip. ACE may be obtained electronically from +http://www.cs.wustl.edu/~schmidt/ACE-obtain.html. This release +contains the source code, test drivers, and example applications +(including JAWS) for C++ wrapper libraries and the higher-level ACE +network programming framework developed as part of the ADAPTIVE +project at the University of California, Irvine and at Washington +University, St. Louis. + +You can get The ACE ORB (TAO) in a companion release at +http://www.cs.wustl.edu/~schmidt/TAO.html. + +---------------------------------------- + +ACE DOCUMENTATION AND TUTORIALS + +Many of the C++ wrappers and higher-level components have been +described in issues of the C++ Report, as well as in proceedings of +many journals, conferences, and workshops. + +A collection of white papers and tutorial handouts are included at +ftp://wuarchive.wustl.edu/languages/c++/ACE/ACE-documentation. This +directory contains postscript versions of various papers that describe +different aspects of ACE. + +I update these papers periodically to reflect changes to the ACE +architecture. Therefore, you might want to check the date on the +files to make sure that you have read the most recent versions of +these papers. + +This material is also available available via the WWW at URL: + +http://www.cs.wustl.edu/~schmidt/ACE.html + +---------------------------------------- + +ACE MAILING LIST AND NEWSGROUP + +A mailing list, ace-users@list.isis.vanderbilt.edu, is available for discussing +bug fixes, enhancements, and porting issues regarding ACE. Please +send mail to me at the ace-users-request@list.isis.vanderbilt.edu +if you'd like to join the mailing list. There is also a USENET newsgroup +called comp.soft-sys.ace. Please see +http://www.cs.wustl.edu/~schmidt/ACE-mail.html for details on how to +subscribe to the mailing list. + +---------------------------------------- + +BUILDING AND INSTALLING ACE + +Please refer to the http://www.cs.wustl.edu/~schmidt/ACE-install.html +file for information on how to build and test the ACE wrappers. The +BIBLIOGRAPHY file contains information on where to obtain articles +that describe the ACE wrappers and the ADAPTIVE system in more detail. + +The current release has been tested extensively, but if you find any +bugs, please report them to the ACE mailing list +ace-users@cs.wustl.edu using the $ACE_ROOT/PROBLEM-REPORT-FORM. +Please use the same form to submit questions, comments, etc. +To ensure that you see responses, please do one of the following: + + 1) Subscribe to the ace-users mail list, by sending email with + contents "subscribe ace-users" to + ace-users-request@list.isis.vanderbilt.edu. + + 2) Or, monitor the comp.soft-sys.ace newsgroup for responses. + +---------------------------------------- + +ACKNOWLEDGEMENTS + +Please see the file `$ACE_ROOT/THANKS' for a list of the thousands of +people who've contributed to ACE and TAO over the years. diff --git a/dep/ACE_wrappers/THANKS b/dep/ACE_wrappers/THANKS new file mode 100644 index 00000000000..269b5fd7d3c --- /dev/null +++ b/dep/ACE_wrappers/THANKS @@ -0,0 +1,2289 @@ +ACKNOWLEDGEMENTS + +ACE and TAO have been deeply influenced and improved by the following +members of my research group at Washington University in St. Louis, the +University of California at Irvine, and Vanderbilt University in Nashville. + +Everett Anderson +Alexander Babu Arulanthu +Shawn Atkins +Jaiganesh Balasubramanian +Krishnakumar Balasubramanian +Matt Braun +Darrell Brunsch +Dante J. Cannarozzi +Sharath R. Cholleti +Chris Cleeland +Angelo Corsaro +Gan Deng +Mayur Deshpande +Eric Ding +George Edwards +Sergio Flores-Gaitan +Chris Gill +Andrew G. Gilpin +Aniruddha Gokhale +Priyanka Gontla +Pradeep Gore +Matthew P. Hampton +Tim Harrison +John Heitmann +James Hill +Shawn Hannan +Don Hinton +Joe Hoffert +James Hu +Huang-Ming Huang +Frank A. Hunleth +Prashant Jain +Shanshan Jiang +Vishal Kachroo +Michael Kircher +Boris Kolpackov +Arvind S. Krishna +Yamuna Krishnamurthy +Fred Kuhns +David Levine +Tao Lu +Mike Moran +Sumedh Mungee +Balachandran Natarajan +Will Otte +Kirthika Parameswaran +Krishnakumar Pathayapura +Stoyan Paunov +Carlos O'Ryan +Ossama Othman +Jeff Parsons +Irfan Pyarali +Nilabja Roy +Lucas Seibert +Diego Sevilla Ruiz +Nishanth Shankaran +Marina Spivak +Venkita Subramonian +Nagarajan Surendran +Cassia Tatibana +Sumant Tambe +Gabriele Trombetti +Emre Turkay +Nanbor Wang +Seth Widoff +Jules White +Friedhelm Wolf +Torben Worm +Ming Xiong + +I would also like to thank all the following people who have also +contributed to ACE and TAO over the years: + +Paul Stephenson +Olaf Kruger +Ed Brown +Lee Baker +Alex Ranous +Mark Patton +Steffen Winther Sorensen +Troy Warner +Stacy Mahlon +Charles Eads +Mark Frutig +Todd Hoff +George +Brad Needham +Leslee Xu +Detlef Becker +Bruce Worden +Chris Tarr +Bill Sears +Greg Lavender +Steve Warwick +Mats Sundvall +Andreas Ueltschi +Nigel Hooke +Medhi Tabatabai +Stuart Powell +Bin Mu +Andrew McGowan +Ken Konecki +John P. Hearn +Giang Hoang Nguyen +Carlos Garcia Braschi +Jam Hamidi +Eric Vaughan +Karlheinz Dorn +Gerhard Lenzer +Steve Ritter +Chandra Venkatapathy +Matt Stevens +Bob Vistica +David Trumble +George Reynolds +Hans Rohnert +Alex V. Maclinovsky +Todd Blanchard +Rob Clairmont +Christian Millour +Neil B. Cohen +Dieter Quehl +Reginald S. Perry +James Morris +Mark Seaborn +Phil Brooks +E. Jason Scheck +Daniel Proulx +Bill Tang +John Huchinson +Jack Erickson +Byron Walton +Bill Lear +Mark Zusman +Aurelio Nocerino +Walt Akers +Greg Baker +Alexandre Karev +Pramod Kumar Singh +Bryon Rigg +Brad Brown +Patty Genualdi +Eshel Liran +Mick Adams +Chris Eich +Mike Flinn +Audun Tornquist +Sandeep Joshi +Bernd Hofner +Craig Perras +Kirk Sinnard +Matthew Newhook +Gerolf Wendland +Phil Mesnier +Ross Dargahi +Richard Orr +Rich Ryan +Jan Rychter +Tom Marrs <0002104588 at mcimail dot com> +Bob Olson +Jean-Francois Ripouteau +Ajit Sagar +Ashish Singhai +David Sames +Gonzalo Diethelm +Raj +Darrin Edelman +Steve Weismuller +Eric C. Newton +Andres Kruse +Ramesh Nagabushnam +Antonio Tortorici +Nigel Lowe +Tom Leith +Michael Fortinsky +Marco Sommerau +Gary Salsbery +Eric Beser +Alfred Keller +John Lu +James Mansion +Jesper S. M|ller +Chris Lahey +Michael R"uger +Istvan Buki +Greg Wilson +Garrett Conaty +Brad Flood +Marius Kjeldahl +Steve Huston +Eugene K. Plaude +Joseph DeAngelis +Kim Gillies +Luca Priorelli +Alan Stewart +Hani Yakan +William L. Gerecke +Craig Johnston +Pierre-Yves Duval +Rochi Febo Dommarco +Jonathan Biggar +Scott Shupe +Chuck Gehr +Avi Nash +Padhu Ramalingam +Jay Denkberg +Ayman Farahat +Tilo Christ +rev +Hamutal Yanay +Vital Aza +Alex Villazon +David Artus +Todd Barkalow +Alexander Smundak +Thilo Kielmann +Matthias Kerkhoff +Fred LaBar +Hanan Herzog +Eric Parker +James Michael Dwyer +Arun Katkere +Bob Dunmire +Sandro Doro +Robert Lyng +Phil Logan +John Cosby +Wayne Vucenic +Harry Gunnarsson +James CE Johnson +Samuel_Bercovici +Per Andersson +Anthony McConnell +Mark Rabotnikov +John Bossom +Rino Simioni +Slawomir Kuzniar +Rob Jordan +Michael Maxie +John Cosby +Nigel Owen +Jorn Jensen +Paul Roman +Dave Mayerhoefer +Bert Craytor +Joey Zhu +Arthur J. Lewis +Michael R. MacFaden +Paul Han +Jeff Morgan +Arturo Montes +Elliot Lau +Mark Wright +Michael Newton +Kumar Neelakantan +Scott Halstead +Jean-Marc Strauss +Adam Porter +Hakan Kallberg +Eric Dean Russell +Daniel Montalibet +Norbert Rapp +Ganesh Pai +Berni Merkle +Tom Wright +Torbjorn Lindgren +Mike Bernat +Brian Mendel +Jeremy Buch +Kevin Boyle +Kevin Martindale +Luis Lopes +Adrian Salt +Hongbo Xu +Michael Hartman +Tom Dobridge +Rich Christy +Satoshi Ueno +Eugene R. Somdahl +Robert Head +Ivan Murphy +Jan Perman +Shankar Krishnamoorthy +Reza Roodsari +Jim Crossley +Johannes Gutleber +Yigong Liu +Erik Urdang +Mike Schweiger +Anthony Mutiso +Jeff R. Hayes +David Brackman +Dave Moore +Joseph Cross +Cherif Sleiman +Stefan Ericsson +Thanh Ma +Oleg Krivosheev +Stephen Coy +Bob Laferriere +Satheesh Kumar MG +Karen Amestoy +Jeff Richard +Samuel Melamed +Vladimir Schipunov +Felix Popp +Billy Quinn +Michael McKnight +Huiying Shen +Alex Chan +Aaron Valdivia +Edan Ayal +Jeffrey Peterson +Neil Lavelle +Steven Wohlever +Manojkumar Acharya +Evgeny Beskrovny +Kirill Rybaltchenko +Laura Paterno +Ben Eng +Mike Kamrad +Marios Zikos +Mark L Boriack +Mark Hyett +Valik Solrzano Barboza +John Connett +Tom Arbuckle +Stephen Henry +Dani Flexer +Michael Hoffman +John Lindal +Dustin Laurence +Ernie Makris +Timothy A. Brown +Pat McNerthney +Lori Anderson +Erik Margraf +Bryan Doerr +Adam Miller +Thomas Jordan +Keith Nicewarner +Frederic Andres +Achint Sandhu +Mitch Kuninsky +Alex Chan +Jeff Hellzen +Thomas Venturella +Philippe O'Reilly +Stan Leeson +Richard Keizer +Edgar Villanueva +Oliver Kellogg +Dave Meyer +Thomas Hampson +Jay Kistler +Scott Snyder +Mark Evans +Todd Pack +Mark Maris +Jason Katz +Jim Penny +Chris Ryan +J dot Russell Noseworthy +Carol Sanders +Jerry Bickle +Paul von Behren +Sudish Joseph +Loren Rittle +Alexander Ovsiankin +Ravi Nagabhyru +Tom Brusehaver +Dave Tallman +Monish Rajpal +Garry Brother +Andreas Schuelke +Ganapathi +James Garrison +Brad Walton +Paul Motuzenko +Kurt Sussman +Rob Thornton +Chanaka Liyanaarachchi +Saneyasu +Steve Kay +Greg White +Ki-hyun Yoon +Umar Syyid +Bill Fulton +Amancio Hasty +Zoran Ivanovic +Sree Oggu +James Risinger +Leo Modica +Bob Scott +Mark Kettner +Kent Watsen +Chris Healey +Philippe Klein +William S. Lear +John Geiss +Ernesto Guisado +Stuart Myles +Lothar Werzinger +Andrew Harbick +Pavel Motuzenko +Ross J. Lillie +Sam Hauer +Frank J. Hodum +David Miron +Anton van Straaten +Joe Covalesky +Bill Backstrom +Jeff Franks +John Mulhern <9107 at mn3 dot lawson dot lawson dot com> +Johan Lundin +Eric Powers +Gabriel Lima +Doug Anderson +Hongyin Quan +Maximilian Hoferer +Kevin Stanley +Jeff Greif +Jeff McDaniel +Andreas Geisler +Bob McWhirter +Daniel Winder +Zheng Han +Christa Schwanninger +Byron Harris +Barney Dalton +Peter Gorgia +Dirk Broer +Joseph E. LaPrade +Goran Lowkrantz +Susan Liebeskind +Dana Hackman +Margherita Vittone Wiersma +Priya Narasimhan +Jeff Hopper +Mats Nilsson +Dongwook Kim +Don Davis +Alberto Villarica +XuYifeng +Tom Shields +Krishna Padmasola +Andre Folkers +Paul Sexton +Marc Lehmann +Anne Blankert +Raja Ati +Clinton Carr +Peter Liqun Na +Frank Adcock +Xu Yifeng +Valery Arkhangorodsky +Alan Scheinine +Andrew G. Harvey +Dann Corbit +James +Jason Milley +Ulf Jaehrig +Peter Nordlund +Mark Weel +Tres Seaver +Erik Koerber +Eric R. Medley +David O'Farrell +Amir Bahmanyari +Ian Wright +David Janello +Rich Wellner +Fernando D. Mato Mira +Jonathan Reis +Seung-Lee Hoon +Russell L. Carter +Bill Hall +Brian Gilstrap +Balaji Srinivasan +Anders W. Tell +Larry Lachman +Terry Rosenbaum +Rainer Blome +Kirk Ellett +Sunil Kumar +T Stach +Ron Barack +Daniel Nieten +Paul K. Fisher +Jim Buck +Olivier Lau +Achim Stindt +Fredrik Lindahl +Joseph Weihs +Serge Kolgan +James Megquier +Martin Krumpolec +Michael Thomas +Vicentini Emanuele +Bob Price +Ramiro Penataro Blanco +Sigg Pascal +Ivan Leong +Virginie Amar +Tom Ziomek +Hamish Friedlander +Mark De Jong +Knut Johannessen +Leif Jakobsmeier +Jon Lindgren +Steve Vinoski +Christian Mueffling +Victor Yu +Jeff Donner +Joe Loyall +Stanislav Meduna +Christian Korn +Ron Barack +Steve Totten +Faron Dutton +Gary York +Patty Hair +Ivan Pascal +William A. Hoffman +Mark Lucovsky +Greg Holtmeyer +Jody Hagins +Patrice Bensoussan +Keith Brown +Barry Hoggard +Peter J. Mason +Jerry D. De Master +Greg Gallant +wym +Karel Zuiderveld +Mike Goldman +Peter Gross +Greg Ross +Stanford S. Guillory +Peter Weat +Magnus Karlsson +Andreas Tobler +John Aughey +Knut-Havard Aksnes +Eric Mitchell +Tommy Andreasen +Slava Galperin +Jeff Olszewski +Sudhanshu Garg +Mike Preradovic +Greg Harrison +Sangwoo Jin +Jacques Salerian +Steve Coleman +Diethard Ohrt +Jacob Jones +Phil Ruelle +Sush Bankapura +Eric Covington +Darren Whobrey +Mason Taube +Rod Joseph +Hans Horsmann +Kevin Royalty +Souhad Mcheik +Mark Little +Tim Stack +Marc Engel +Uma Markandu +Henrik Nordberg +Tad Jarosinski +Andy Marchewka +Neal Norwitz +Frederic Maria +David Hooker +Christian Destor +Andrew Hobson +Andre Folkers +Torsten Kuepper +Hao Ruan +Alexander Davidovich +Cristian Ferretti +N Becker +Yaolong Lan +Elias Sreih +Liang Chen +Mark Laffoon +Ti Z +Brian Dance +Alexey Gadzhiev +Francois Bernier +Bill Rizzi +Peter Windle +Jaepil Kim +Dmitry Goldshtain +Carl Grinstead +Henric Jungheim +Michael Preobrazhensky +Gregory D. Fee +Roland Gigler +Frank Buschmann +Eric Eide +Don Busch +Thomas Lockhart +David Hauck +Keith Rohrer +Tim Rose +Sam Rhine +Chris Schleicher +Margaret Reitz +Thomas Mehrkam +Erik Ivanenko +Sarmeesha Reddy +Steven Tine +Dave Steele +Simeon Simeonov +David H. Whittington +Ian MacDonald +Hans Ridder +Todd Mullanix +Hai Vu +Paul Francis +Kristopher Johnson +Dave Butenhof +Dominic Williams +Srikumar Kareti +Ian Pepper +Kevin Lyda +James D. Rucker +Brian Wallis +Sandeep Goyal +English Malc +Frank O'Dwyer +Long Hoang +Steven D. Chen +Alain Magloire +Jim Rogers +Nick Sawadsky +David Brownell +Richard Stallman +Casey Lucas +Brian C. Olson +Joseph A. Condlin +Serge Du +Mike Mazurek +Christian Schuderer +John R. Taylor +Bill Tovrea +Wallace Owen +Vyacheslav A. Batenin +Edwin D. Windes +Christopher Kohlhoff +Andreas Terstegge +Stefaan Kiebooms +Keith Nichol +Rebecca Sanford +Ram Vishnuvajjala +Tom Bradley +Shaun Ohagan +Dale Wood +Robert Flanders +Gul Onural +Stephen E Blake +Eric S Rosenthal +Sridevi Subramanian +Bruce Trask +Jake Hamby +Rick Weisner +Dennis C. De Mars +V dot Lakshmanan +Hata Yoshiaki +Vidya Narayanan +Sean Landis +Youzhong Liu +John Weald +Gilbert Roulot +Gildo Medeiros Junior +Brian Peterson +Fabrice Podlyski +Darren DeRidder +John Tucker +Oleg Orlov +Timothy Canham +Randy Heiland +Joyce Fu +Surender Kumar +Pradeep Avasthi +Guicheney Christophe +Madhu Konety +Isaac Stoddard +Alvarez +Peter Brandstrom +Eugene Surovegin +Thaddeus Olczyk +John Chludzinski +Pedro Alves Ferreira +Bruce Edge +Dan Butler +Ron MacKenzie +Craig Rodrigues +Phil Y. Wang +David Brock +John Morey +Dwayne Burns +Denis Ouellet +Stefan Ullrich +Brian Raven +Gheorghe Aprotosoaie +Carsten Zerbst +Paul Calabrese +Stephane Chatre +James Whitledge +Erik Johannes +Alex Hornby +Riaz Syed +Clarence M. Weaver +Roger Egbers +Ralf Kluthe +Ruud Diterwich +Bill Nesbitt +Will Skunk +David Digby +Timothy Schimke +Jim Robinson +Peter Mueller +Raghu Nambiath +Mike Gingell +David McCann +Ruediger Franke +Brian Jones +Michael Garvin +Mike Vitalo +Kirk Davies +Arno Pernozzoli +Trey Grubbs +Matthias Schumann +John Gathright +Alexander Villatora +Hoang Duong +Michael Roth +Craig Anderson +Mitsuhiko Hara +Weihai Yu +Tal Lev-Ami +Chris Zimman +Rick Wesson +Sridhara Rao Dasu +Walter Welzel +Anthony Shipman +Tobin Bergen-Hill +Toshio Hori +John Mink +Duane Binder +Randall Sharo +Dave Madden +Cliff_H_Campbell +Narendra Ravi +Krishnakumar B. +David Sunwall +Brian Wright +Yosi Sarusi +Robert Shewan +Skye Sweeney +Lars Immisch +Stefan Wendt +Herbert +Clarence Bishop +Giga Giguashvili +Philipp Slusallek +Matthew Davis +Janusz Stopa +Rusty Conover +Alex Mintz +Phillippe Merle +Mark Winrock +Boris Kaminer +Martin Botzler +Lorin Hochstein +Wenli Bai +Harry Forry +Jose Rubio +Joerg Pommnitz +Mogens Hansen +Shafiek Savahl +Pierre Grondin +John Masiyowski +Uwe Landrock +Klaus Banzer +Probal Bhattacharjya +Dmitri Katchalov +Alok Gupta +Chien Yueh +John K. Black +Kamen Penev +Gregory Yarmit +Jarek Tomaszewski +Siegurd Weber +Fabrizio Giannotti +Harald Finster +Fritz Bosch +Charles Frasch +Chris Hafey +Rick Hess +David Dunn +Jaymes Galvin +Marat +Sergey Nemanov +Vladimir Kondratiev +John Glynn +Raymond Wiker +Michael Pitman +Joseph Jefferson +Engelbert Staller +George Ball +Dennis Noll +Ronald Fischer +Marvin Allen Wolfthal +Dan Gilboa +Sean Boudreau +Shalini Yajnik +Matt Thompson +Peter C Chien +Bruce Alderson +Christoph Poggemann +Travis Shirk +Alain Sauron +David Delano +Boris Sukholitko +Brian Mason +Thomas Groth +Damien Dufour +Paulo Breda Vieira +Samuel Stickland +Bryan Van de Ven +Greg Siebers +Rob Gabbot +Paul Carreiro +Jovan Kilibarda +Derek Dominish +Devesh Kothari +Stephen Moon +Hani Mawlawi +Benedikt Eric Heinen +Jason Topaz +Alexander Dergatch +Airat A. Sadreev +Klaus Hofmann +Miroslav Koncar +Extern Chatterji +Zach Frey +Ruibiao Qiu +Marcelo Matus +R Seshardi +Stephan Kulow +Alexander Belopolsky +Ben Bourner +Lalitha Chinthamani +Thomas Huang +Sankaranarayanan K. V +Ephraim Vider +Reid Spencer +Kevin Dalley +Jan Nielsen +Jochen Linkohr +Mirko Brandner +Yuval Yosef +Chad Elliott +David X. Callaway +Soren Ilsoe +Eric Hopper +Martin Johnson +Pierre Oberson +Chris Uzdavinis +Ishay Green +Andrey Nechypurenko +Charlie Duke +Jonathan Luellen +Andrew Psaltis +Erik Jones +Ted Burghart +Mike Winter +Judy Ward +Ken Block +Jamshid Afshar +Jerry Jiang +Rob Ruff +Hugh Arnold +Hessel Idzenga +Mark C. Barnes +Suresh Kannan +Alex Scholte +Greg Jansen +Raj Narayanaswamy +Iain Melville +Daniel Lang
+Chris Leishman +Klemen Zagar +Rick Ohnemus +Adamo, Vince +Defang Zhou +Dave Zumbro +Ted Nolan +Jianfei Xu +Alvin C. Shih +J dot Scott Evans +Alex Luk +Kenneth Osenbroch +Jason Czavislak +Alex Chachanashvili +Gilbert Grosdidier +James Briggs +Herbert Wang +Anders Olsson +Sergey Gnilitsky +David Wicks +Girish Birajdar +Hajdukiewicz Markus +Gerwin Robert +Alia Atlas +David Hall +Todd Gruhn +John Hickin +Alex Brown +Rich Seibel +Jim Scheller +Bob Bouterse +Sandeep Adwankar +W Craig Trader +Bruce McIntosh +Natarajan Kalpathy +David O'Farrell +Bob Bouterse +Malcolm Spence +Dong-Yueh Liu +Craig Ball +Norbert Krain +Adrian Miranda +Cody Dean +Hans Scharkowitz +Charles Meier +Tim Sim +Shalabh Bhatnagar +Charles Scott +Espen Harlinn +mulder +Richard L. Johnson +Tam Nguyen +Jeff Graham +Ralph Loader +Ji Wuliu +Wada Hiroshi +Sal Amander +Torsten Pfuetzenreuter +John M. Mills +David McWeeny +Florian Lackerbauer +Manuel Benche +Steve Luoma +Roger Tragin +Alex Bangs +Yangfen Qiu +Johnny Chen +John Foresteire +Larry Peacock +Francisco Bravo +Antti Valtokari +John Smyder +Mathew Samuel +Conrad Hughes +John Rodgers +Charles Taurines +James Lacey +Nick Pratt +Xiaojun Wu +George Lafortune +Aoxiang Xu +Dima Skvortsov +Moore Y. Cao +Wai Keung Fung +Michael Laing +Benoit Viaud +Ken Weinert +Ferran Boladeres Salvad +Steve Vranyes +Jim Melton +Ron Klein +Anuj Singhal +Henrik Kai +Dominic Hughes +Lior Shalev +Charlie Duke +William Horn +Greg Hall +Aviad Eden +Vianney Lecroart +Russell Mora +Samir Shaikh +Eric Yee +Matt Emerson +Yiu L. Lee +Pedro Brandao +Hakon Innerdal +Sami Aario +Ingo Dahm +Vijay Aswadhati +Xiaowen Wang + +Warren Miller +Youngkwan Cho +Dorr H. Clark +Dave McNeely +Eric Malenfant +Roland Fischer +Alexander Libman +Roger Larsson +Martin Stack +Michael Ravits +Derek Viljoen +Hamed Azizadah +Keo Kelly +Joachim Achtzehnter +Tomer Amiaz +Sergey Osokin +Nick Logvinov +Viatcheslav Batenine +Shashi Bhushan +Javier Corrales +J dot Randy Pitz +Richard Reitmeyer +Xavier Montet +Letha Etzkorn +James Dabbs +Matej Sekoranja +Mattias Eriksson +Nicoletta Viale +George Reid +Kim Lester +Wilson Chan +William Rucklidge +Victor Krebss +Chander P. Thareja +John Mills +Haifeng Lee +Hans Utz +Askok Kumar Kalanithi +Chris Able +John Hiltenbrand +Steve Hespelt +Peter Fischer +Madhu Ramachandran +Caleb Epstein +Bruno Marconi +Ken Childress +Michael Kramer +Johnny Willemsen +Jonathan Astle +Javier Lopez Sanchez +Nir Drang +Albert Wijnja +Marcel Van Der Weert +Mervyn Quah +Giovanni Zito +Matthew Adams +Sameer Schabungbam +Jeff Butler +Roland Rüdenauer +John Buckman +Guy Rosen + +Bennett R. Stabile +Paul Caffrey +Low Aik long +Michael Rinne +Jaffar Shaikh +Roger Beck +Trueman Bill +Harold Bien +Mateu Batle +Philip Miller +Base V Paul +Evghenii Filippov +Mike Curtis +Jessie Ragsdale +Shourya Sarcar +Eric Crampton +Sandip Patel +ChenXu +Vsevolod Novikov +Brendan Corcoran +Steve Sivier +Rick Schneeman +Klaus H. Wolf +Jean-Christophe Dubois +Michael Hampel +Wei Zheng +Bernd Annamaier +Joachim Tremouroux +Momchil Velikov +Munagala Ramanath +Kevin Marshall +David Channon +Andy Guy +Oscar Rodriquez +Jonathan Cano +Alain Decamps +Paul Rubel +Jon Loeliger +Ricardo Chan +Sarabjeet Duhra +Michael Rushton +Arno Pernozzoli +Calum Mitchell +Jerry Odenwelder +Kent Stewart +Alexander Kogan +Michael Lindner +Arnaud Compan +Michael Searles +Bogdan Jeram +Sebastian Schubert +Li Zhou +Shivakumar Patil +Steve Olson +Allen Broadman +Yuriy Zaporozhets +Joe Guan +Attilio Dona +McGanahan Skjellifetti +Matthias Wittig +David Allen +Edwin McKay +Scott Bolin +Mike Anderson +David Singer +Nick Lin +Ron Hashimshony +Max Khon +Jonas Nordin +Jonathan Stockdale +Jean-Francois Daune +Wei Chiang +Rick Stille +Kirill Kuolechov +Edwin Wrench +Yung Trinh +Richard Eperjesi +Ben Strong +David Karr +Sathish Tiptur +Lu Yunhai +Christian Ewald +Samuel Qi Luo +Sergey Logvin +Orlando Ribeiro +Doug Warner +Kevin Regan +Andy Olson +Max Voronoy +Alexandr Gavrilov +Scott Gunn +Mason Deaver +Richard Huber +Glen Osterhout +YingLi +Haka +Sam Chong +Virgilijus Globis +Stefan Scherer +Pim Philipse +Michael Grove +John Mackenzie +Ricky Marek +Patrick Maassen +Christian Schuhegger +David L Smith +Rainer Doerntge +Tompa +Derek Horton +Shameek Basu +Dipti Jain +Eric Zuur +Jeffrey J. Persch +Rahul Shukla +Pierre Fayolle +Greg McCain +Matt Cheers +Benjamin Fry +Ram Ben-Yakir +Eric Desamore +John Ashmun +Przemyslaw Marciniak +Carsten Madsen +David Sperry +Ted Horst +Diana Arroyo +Benny Prijono +Roland Ziegler +Stelios Sfakianakis +Mike Letchworth +Brian Gilmer +James Dunham +Juergen Pfreundt +Joel Sherrill +Jules Colding +Stephane Pion +Raghu Narayan +Richard Goold +Nathalie D'Amours +Albert Pariante +Stephen Torri +Philippe Perrin +Gunnar Buason +David Hanvey +Jeff McNiel +Georg Lohrer +Rachel G Smith +Tom Lake +Logan Modahala +Jean Malenfant +Victor Poznyak +Juan Jose Comellas +James Dorsey +Benot Desmeules +Tom Moog +Stan Pinte +Dayisi +Peter Georgakakis +Richard Hardgrave +Mark Drijver +Guy Bolton King +Carlton Teel +Alexandre Cervieri +Darren Griffith +Sam Mok +Josh Curry +Norman Wilson +Itzhak Briskman +James Kanyok +Corey Trager +Kirat Singh +Oleg Pavliv +Frederick Niemi +Andrew Munro +Nicolas Huynh +Kevin Burge +Wayne Erchak +Yew Khong See +Greg Thompson +Mike Pyle +Kobi Cohen-Arazi +Israel Illescas Gomez +Brodie Thiesfield +Erik Toubro Nielsen +Masaoud T. Moonim +Steve Witten +Gil Rapaport +Boris Temkin +Steve Perkins +Jerry Thomas +cuma +Ron Heald +Andrew Finnell +Dan Levi +Rob Andzik +James Maynard +Francois Rioux +Ophir Bleiberg +Allen Kelly +Victor Pitchouc +Srikanth Vedire +J Shane Culpepper +Steffen Hieber +Craig L. Ching +Ben Howard +Rich Newman +Kelly F. Hickel +David Trusty +Burkhard Neppert +Crawford Lodge +Scott Gaa +Jenny Kowald +Oren Zeev-Ben-Mordehai +Holger P. Krekel +Glenn Popelka +Tibor Kiss +Robert Davidson +Peter Crowther +Mouna Seri +Vladimir Chovanec +Alexander Rieger +Glen Coakley +Scott Plant +Wilfried Reinoehl +Sangeetha Ramadurai +Victor Chernenko +Frank Wolf +Christophe Galerne +Scott Harris +Stefan Kluehspies +Egon Wuchner +Ugendreshwar Kudupudi +Ekkehard Hoffmann +Ted Krovetz +Grzegorz Sikora +Fabris +Christina Junru +Patrick Rabau +Hyman Rosen +Torbjorn Backstrom +Robert Burke +Olivier Brunet +Bret Clark +Steve Rahn +Bertrand Motuelle +Blair Zajac +Gary Duzan +Garry Shamis +Eamonn Saunders +Yev Omenzel +John E Hein +Tino Schwarze +Gergely Timar +Peter Phillips +Yury Kuznesov +Daniel Manfis +Massimo Pichini +Eyal Neuman +Dave Hale +Giulio Agostini +Werner Buchert +Kevin Cline +Mahesh Varadarajan +Olof Lindfors +Tom Wagner +Kyle Brost +Vincent Nicolas +Jonathan Wackley +Jan Kalin +Andreas Huggel +Alain Totouom +Tushar Nair +Sunny Leung +Bonifides Bautista +Brad Hoskins +Donald Acton +Hagen Ulrich +Adrian Mercieca +Lars Steubesand +Heping He +Leo Kov +Suresh N +David Arndt +Tad Hetke +Graeme Clark +Gu Song +Chris Hughes +Fikri Pribadi +Ioulia Passynkova +Steve Osselton +Doron Rajwan +Stuart Jones +Guillaume Renaud +Tommy Svensson +Jstwo +Hartmut Quast +Ulrich Voigt +Syed Wasim Ali +Bo Balder +Michael Sawczyn +Ildar Gabdulline +David Yongqiang Wang +Shahzad Aslam-Mir +Andrew Foster +C Chan +Alexey Chalimov +Andrea Bernicchia +Praphul Menon +Patrick N +Garth Watney +Jim Connelly +Eyal Lubetzky +Gaoyan Xie +Michael Brinkmann +Chatchai Khumboa +Andrey Shkinev +Michael Graf +Justin Michel +Robert Martin +Charles Meidinger +Petr Tuma +Greg Burley +Marvin Greenberg +Mike Connors +Ben Flight +Bob Jolliffe +Jesse +Robert Handl +Keith Snively +Ahmed Riza +Miljenko Norsic +David Robison +Preston Elder +Eric Peters +Edward A Thompson +Eugene Alterman +Patrick Cosmo +Ran Kohavi +Harvinder Sawhney +Sorin Iordachescu +Mahesh Vedantam +Brian Olson +Roy Sharon +Charlie Grames +Tom Howard +Michael Gillmann +Yaniv Ben Ari +Victor Terber +David Sanders +Yoram Zini +Sean McCauliff +Shmulik Regev +Andrew L. Shwaika +Gerhard Voss +Gregor Bruce +Ian Cahoon +Alexei I. Adamovich +Sohail Husain +Jerome Julius +William R Volz +Koushik Banerjee +Zoran Cetusic +Patrick Bennett +Felix Wyss +Tim Rydell +Petr Shelomovsky +Juliana Diniz +Yuval Cohen +Timothy Kilbourn +Marc Walrave +Petru Marginean +Paresh Raote +Donna Maskell +Steve Ige +Marco Kranawetter +Christian Veleba +Olli Savia +Bhaskara Rao G +M Schulze +John Michael Zorko +Ami Bar +David Smith +Peter van Merkerk +Bill Dyer +Rodney Morris +Mark Hoffmann +Markus Wild +Joe Hayes +Chip Jones +Patrick J Lardieri +Ken O'Brien +Daniel Troesser +Ivan Pazymenko +Dan Green +Cyrille Chepelov +Peter Heitman +Paxton Mason +Yan Dai +Sean I. Luzader +Renjie Tang +Max V. Zinal +Stan Sosnovsky +Ariel Peltz +Carsten Prescher +Raghuram Shetty +Val Dumiterscu +Oleg Kraynov +Stephan Gudmundson +Frank Kuhlman +Denis Otchenashko +Marc M Adkins +Jon Lambert +Rainer Lucas +Allan S Iverson +Jeffrey Shaffer +Oleg Burlachenko +Jian Chen +Jeff Paciga +Laurent Sabourin +Frank Rybak +Tim Iskander +Michele Amoretti +Ido Yellin +Eric Page +Kevin Heifner +James Haiar +Pavel Repin +Whitney Kew +Tom Phan +Andrew Guy +Bharathi Kangatharan +Jean Quinsat +Ma Ting Chong +Andrew Sutton +Ansgar Konermann +Amir Kunst +Daniel Garrido +Andy Alvarez +Soeren Gerlach +Vitaly Prapirny +Sasha Agranov +Ruwanganie Gunatilleke +Peter Kullmann

+Lyn Headley +Jeff Adams +Alexander Maack +Timothy Culp +Oleg Terletsky +Bill Tonseth +Frank Pilhofer +Eric Quere +Keith Thornton +Nathan Krasney +Marek Maleta +David Smith +Dimitrije Jankovic +Frank O. Flemisch +Cary Steinmetz +Ty Tenait +Nitin Mallya +Nick Cross +Christopher W. Midgley +Wanjia +Shanliang Cheng +Andy Ling +Stephen Howard +Carsten T. Nielsen +Adee Ran + +Davide Pasetto +Michael Hornok +Wim van den Boogaard +Carol Hunsicker +Joseph Sarbak +Ruslan Zasukhin +Colin Weaver +Kew Whitney +Sean Ogle +Tim Bradley +Kier Schmitt +George Varsamis +Alan Tanga +Bertin Colpron +Jeff Wilson +Dmitry Khrapov +Francois +Laxmikant Bopalkar +Steven Gardner +Ronald Berger +Jeremy Altavilla +Brian Appel +Lan Zhineng +Leen Van Kampen +James Beale +Mark Xu +Umberto Mascia +Marcel Loose +Christian Klutz +Ville Lehtiniemi +Chumsu Kim +Schone Mullerin +Cemal Yimaz +Newton Aird +Frederic Motte +Roger Weeks +Gautam Thaker +Christophe Juniet +Jeff W +Geir Berset +Ken Sedgwick +Vince Mounts +Vladislav Zverev +Erich Hochmuth +Nick S. Petrov +Dmitry Botcharnikov +Philippe Haussy

+K2 +Eric Frias +Antonio Saraiva +Sean M. Paus +Yuanfang Zhang +Jonathan Franklin +Cristian Ungureanu +Tommy Persson +Christian Barheine +Ole Husgaard +Victor Kirk +Sandeep Neema +Mike Curtis +Artashes Ghazaryan +Ashok Sadasivan +Andreas Koehler +Thomas Devanneaux +Paul Marquis +Ed Skees +Marc Alter +Martin Geliot +Simon McQueen +Jason Pasion +Philipp Leibfried +Erwin Rol +Dirk Moermans +Huseyin Calgin +Jaroslaw Nozderko +Sharon Caspi +Thomas Natterer +Wilbur Lang +Rick Marlborough +David-A O-Brien +Shelton Tang +Frederic Langlet +Antonio Leonforte +Pablo d'Angelo +Christophe Vedel +Uwe Jaeger +Viktor Ransmayr +Daniel Bell +Mathias Waack +Mike Nordell +Tufan Oruk +Tim Smith +Andy King +Eric Strennen +Abhay Kulkarni +Ron Muck +Ma Weida +Terry Lao +Volker Boerchers +Tim Pullen +Marc Tardif +Guan Joe +Petr Ferschmann +Greg Mulyar +Max F. Bilyk +Danile White +Andrew Marlow +Michael F"olsl +Vincent Chau +Theo Landman +Igor Pisarenko +Dima Scub +Volodymyr Orlenko +Grigory +Michael Soden +Dennis Sporcic +Emmanuel Thevenot Beaufort +Denis Parnaland +Matthias Blankenhaus +Wolfgang Schroeder +Mario Hofmann +Bruce MacDonald +Jeffrey Graham +Otis Nyandoro +Ray Limpus +Dmitri Belogaj +Will Christof +Ferran Boladeres Salvad +Juan Carlos Montes Costa +Edward Scott +Steve Spencer +Fukasawa Mitsuo +Martin Brown +Terry Mihm +Jeff Gray +Rob Eger +Leonid Kvetnyi +Rudolf Weber +Sergei Pimenov +David Kinder +Sebastien Lalonde +Jia Wan +Bertin Colpron +Weston Markham +Bryan Thrall +Subhabrata Biswas +Dave Ryan +Zsolt Zsoldos +Tongzhe Cui +Braden McDaniel +Richard Woodring +Andras Lang +Scott Gammil +Nick Lewycky +Ira Burton +Thomas Wiegert +Craig Watcham +Pit Linnartz +Peder Norgaard +David Ohlemacher +Ken Kane +Bill Church +Udo Berninger +Vincent Korkos +Martin Corino +Terry Lacy +Branko Mijic +Jeff Kelley +Daniel Hannum +Jason Cohen +Nick Kukuczka +Andrew Voumard +Anand +D.J. Dwyer +Douglas A Stuart +Victor N. +Francesco Baldi +Michael Rice +Jesse Greenwald +Raymond Hoofman +Jason Smith +Danta Cannarozzi +Valery Salamakha +Karim Fodil-Lemelin +Wenlong Tang +Manish Jain +Robin Farine +Roland Schimmack +Roy Pollock +Eric Held +Kees van Marle +Dieter Knueppel +Amol Tambe +Emiliano Berenbaum +Scott Clarke +Sunil Rottoo +Martin Habets +Todd Cooper +Serkan Unsal +Milan Cvetkovic +Didier Becu +Dan Halbert +Jerome Waibel +Stephan Frenzel +Bruce Jones +Tim Hawes +Philip Leishman +Alexander Jasper +Gerard Grant +Trevor Fields +Jeff Dugan +Jeff Mirwaisi +Alain Dupont +Stephan Bettermann +David McKen +Adam Fanello +Matthieu Vansteene +Sean Rooney +Enrico Detoma +Onopin V. Mikhail +Edward R. Mulholland +Brian Buesker +Vladimir Naylov +Ted Mules +Mike Hepburn +Dale Wilson +Thomas Girard +Malcolm McRoberts +Dror Tirosh +Chris Sontag +Moran Levi +UV Wildner +Alan l Batongbacal +Gary Maxey +Yoav Borer +Andre Kleibeuker +Andy Bellafaire +John Fletcher +Terry Ware +Pierre Pacchioni +Roger Beathard +Konstantinos Margaritis +Stephen Procter +Christoph Liebig +Andre Kostur +Markus Stenberg +Jonathan Pollack +Si Mong Park +Hakim Souami +Paul Morrison +John Poplett +Heiko Bachmann +Andrew Metcalfe +Simon Dutkowski +Mickael P. Golovin +Shannon Barber +Brad Orner +Michelangelo Nottoli +Peter Bekiesch +Martin Kaul +Lukas Gruetzmacher +Robert Schiele +Matthew Grosso +Akim Boyko +Nils Sandoy +Daniel Miranda +Hans-Peter Bock +Dmitri Hrapof +Denny Kolb +Daniel Buchs +Matt Murphy +Brian Nelson +Avi Ouziel +Matthew Gillen +Chris Reed +Andrew Reid +Praveen Sharma +Yi Zuo +Raphael Bossek +Richard G. Hash +Karl Tredwell +Norm Whitehead +Jiang Wei +Kevin Bryan +Zvika Ashani +Thomas Costa +Dom Monteiro +Jean-Marc Prud'homme +Yury Osadchy +Pavan Mandalkar +Scott Willey +David Calkins +Wu Yongwei +Karen L. Regner +Michel Drapeau +Hans Bos +Kevin Stacy +Liat +Andreas Wagner +Steven Xie +Kris Dekeyser +Matthew Harris +Abhijit Sachdev +Mikael Lundqvist +Peter Hercek +Jay Welch +Angel Roman +Jessica Pistole +Paolo Carlini +Eric Whorter +Vincent Seignole +Jingbin An +Roland Meub +Marek Brudka +Levente Torok +Panagiotis Issaris +Mehrdad Nazari +Pierre Bisaillon +Rob Boyer +Scott Gammill +Bayu Hendradjaya +Randy Hammon +Bill Cassanova +Matthew Corey +Vinod Kumar +Mirek Pabich +Christian Egeler +J.T. Conklin +Dale Hawkins +Bill Hopkins +David Fleeman +Merlin Ran +Kevin Christian +Trina Wisler +Bae-Sik Chon +Benjamin Bronk +Dave Craig +Ofira Shaer +Ciaran Moran +Thomas Rohner +Ken Descoteaux +Claas-Hinrich Dommreis +Yateen Joshi +Sergei Kuchin +Theckla Louchios +Randy Secrest +Patrice Marques +Stanislaw Trytek +Mattias Nilsson +Michael Hollins +Dave Knox +Lance Paine +Brian Waltersdorf +Johann Kandlbauer +Adam Rymarczuk +Heiko Nardmann +J. Abelardo Gutierrez +Roger Sala +Razi Ben-Yehuda +Geo Sebastian +Simon Massey +Rich Shapiro +Ramiro Morales +Andrew Athan +Sebastien Roy +Matthew Townsend +Rick Robinson +John D. Robertson +Paul Lew +Eider Oliveira +Jeff Jones +Jean-Christophe Cota +Paul +Vincent Newsum +Vasili Goutas +Iliyan Jeliazkov +Shlomi Yaakobovich +Todd Marshall +Ciju John +Yuk Ming Kwok +Honorato Saavedra +Domingos Monteiro +Bill Somerville +Bjorn Roald +Michi Henning +Xue Yong Zhi +Ertugrul Sorar +Simone Viani +Rohan Mars +Robert S. Iakobashvili +Chris Hammond +Vincent Spano +Nuno Silva +Greg Bostrum +Dipa Suri +Adam Howell +Steven Frare +Dave Dalapati +Arjun Thounaojam +Michael Altmann +Steven Patrick +Pete McCann +William Nagel +M. C. Gahan +Thia Chang Chao +Gao Xianchao +Huang Rui +Sam Abbe +Mike McGahan +David Michael +Steve D. Baker +Martina Yen +Kim ByeongSu +Doug McCorkle +YiQing Xiong +Peter Falsh +Don Sharp +Arto Jalkanen +Scott Zionic +Diana Ukleja +Shaun Cooley +Aapo Mäkinen +Matt Emerson +Sean Parker +Mark Wilson +Joerg Rockel +Phil Chen +Stefan Morrow +Bruce Elliot +Mitscher Dubreus +Brian O'Connor +Ron Wilson +Peter Grotrian +Alex Ott +D. J. Stachniak +Slava Gorelik +Wolfgang Fischer +Nicholas Todd +Arno Wilhelm +Andreas Schuler +Altaf Aali +Vemund Handeland +Mario Di Giacomo +Raoul Gough +Aaron +Rohini Madhavan +Alan Balasuar +Will Chai +Paul Koch +Dave Giovannini +Dave Varnell +Howard Finer +Mark Callaghan +Hanson Lu +Gavin Yu +Srikanth Gopal +Like Ma +Alvin Msg +Angela Ziegenhorn +Sam Mesh +Felix Perez Alamillo +Steven T. Hatton +Yevgen Galchenko +Timothy Wayne Gomez +Ventimiglia Chere +Frederick Heckel +Ian Zagorskih +Olivier Guérin +Abdel Rigumye +James Damour +Alan Anderson +Vito Bico +Aldo Texier +J H Choi +Mike Chartier +Nikolay Metchev +Anand Rathi +Vitaly Belekhov +Dorian Hileaga +Steve Williams +Paul Friberg

+Zachi Klopman +Jin Zhi Ye +David Carlton +Feng Li +Michael van der Westhuizen +Jan Zima +Francesco Salvestrini +Sandeep Deshpande +Hubert Talbot +Oh Yoon Sik +Anton Bakanovskiy +Toha Bakanovsky +David Faure +Robert Hancock +Peter Oslej +Yongming Wang +Vadim Iosevich +Mike Knight +Nathan Anderson +Eyal Car +Jonathan Sprinkle +Vladimir Panov +Volker Lukas +Bryan Cassell +Guy Peleg +Wallace Zhang +Richard Ward +Alan Stokes +Rick Taylor +Tobias Herzke +Paul Felix +Jan Ohlenburg +Eric Tiangang +David Hawkins +Michael Klein +Sandro Santos Andrade +Richard Spence +Thomas E Lackey +luxi78 at gmail dot com +John Lilley +Abdullah Sowayan +Nathan Bamford +Zoltan Molnar +William Byrne +Karl Schmitt +Ron DeAngelis +Alex Sheh +Daniel Wagner <__daniel___ at icg do tu-graz dot ac dot at> +Nemoy Michael +Marc Brown +Andrew Keane +Martin Kolleck +Tino Riethmueller +Adam Mitz +Frank Rehberger +Aaron Scamehorn +Alan Kierstead +Sven-Uwe Sieler-Hornke +Spencer Vanroekel +Dan Pozdol +Yauheni Akhotnikau +Axter +Roopa Pundaleeka +JR Andreassen +Mockey Chen +Vincent Joseph +Igor Mammedov +Yuan +Adrian Tulloch +Dmitriy Kuznetsov +Steve Orner +Bob Ronak +Aleksandar Vukajlovic +esIgnacio Alvarez +Sergey Zubarev +Qingbo Cai +David White +Jason Zhang +Mark Paulus +Willie Chen +Martin Cornelius +Mohit Kapoor +David Gibbs +Gary Fernandez +Jason Zhao +Keith Muzzioli +John Black +David Chu +Kevin Hu +Yasser Zabuair +Phlip +Michelle Zheng +Gerolf Reinwardt +Paul Robinson +Popeye Cai +David Highley +Sonicfly Zhou +Phil Billingham +David Giovannini +Paul Daugherty +Robert Schwebel +William Cote +Ben Creech +Michael Reed +Heesuk Shin +Hong Xing +Winston Zhang +Stefan Naewe +Graeme Bell +Eric Danielou +Wei Jiang +Dale Boan +Christoph Schmalhofer +Amnon Berger +Ephy Levy +Don Meek +Liu Qian +Nzer Zaidenberg +Birgit Platt +Andy Salnikov +Hieu Ngyuen +Andriy Gapon +Andy Wang +Zhamak Dehghani +Charles Calkins +Manuel Traut +Drew Reynaud +Artur DeEsperanto +Scott Mitchell +Thomas Vanier +N Johnson +Adam Nagel +Robert Neumann +Venkat +Juraj Ivancic +Daniel Black +Richard Ridgway +Vadym Ridosh +Viola Wang +Ray Lischner +Sergey Kosenko +Pavel Zaichenko +Paul Riley +Nelson Filipe Ferreira Gonçalves +Harry Goldschmitt +Sail Zeng +Markus Henschel +Asif Lodhi +Andrew Schnable +Grigoriy Zeleniy +Yves Alloyer +Waba +Scott Mark +Bjoern Rasmussen +Ian C White +Dennis Chernoivanov +Werner Burger +Andres Hurtis +Joe French +M. Arshad Khan +Hans van't Hag +Roland Sun +Vance Maverick +John McCabe +Andres Oportus +Olof Granered +Eric Hughes +Zhenghao Shi +Alexander Kornienko +Ben Mohlenhoff +Bill Bruns +Dmitriy Nikitinskiy +Ravi Kanth +Ian Roberts +Patrick Spiering +Duane Beck +Kanghee Yoon +Xu Liang +Leo Lei +Jules d'Entremont +Rajiv K. Shukla +Haibin Zhang +Vikram Karandikar +Kim J. Schmock +Venkat Forums +James Marsh +Shaolong Xiang +Christoph Hofmann +Vladimir Zykov +Daniel de Angelis Cordeiro +Hal Black +Peter Korf +Norbert Thoden +Premkumar P +David Beck +Hayim Shaul +Erman Balcik +Torsten Saliwada +Nathan Glasser +Grégor Boirie +Alex Solan +Venkat Sidhabathuni +Nathan Ernst +Kun Niu +Karl-Heinz Wind +Oliver Spang +Hu Yi +Joe Seward +Tom Callaway +Alick Nie +Douglas Atique +Nayeem Khan +Sorin Voicu-Comendant +Andi Heusser +Paul Carter +Michael Carter +Alain Kocelniak +Alvaro Vega Garcia +Fernando C. Jeronymo +Stephen Mouring +Tim +Thomas Brownridge +June Fang +Bill Kendall +Ittehad Shaikh +Michael Doubez +Namrata Gandhi <...> +Michael Guntli +Frank Förster +Roger Leblanc +Bob Fiske +Julien Vintrou +Jonathan Brannan +antred +Nathalie D'Amours +Mele Giovanni +Philipp Thomas + +I would particularly like to thank Paul Stephenson, who worked with me +at Ericsson in the early 1990's. Paul devised the recursive Makefile +scheme that underlies the ACE distribution and also spent countless +hours with me discussing object-oriented techniques for developing +distributed application frameworks. + +Finally, I'd also like to thank Todd L. Montgomery , +fellow heavy metal head, for fulfilling his quest to get ACE to +compile with GCC! + +In conclusion, our goal is to see ACE+TAO+CIAO continue to evolve and +become a more comprehensive, robust, and well-documented C++ class +library that is freely available to researchers and developers. If +you have any improvements, suggestions, and or comments, we'd like to +hear about it. Please see the instructions in + +$ACE_ROOT/PROBLEM-REPORT-FORM +$TAO_ROOT/PROBLEM-REPORT-FORM +$CIAO_ROOT/PROBLEM-REPORT-FORM + +for instructions on submitting suggestions or fixes. + + Thanks, + + Douglas C. Schmidt + d.schmidt at vanderbilt.edu diff --git a/dep/ACE_wrappers/VERSION b/dep/ACE_wrappers/VERSION new file mode 100644 index 00000000000..0c1423ad06d --- /dev/null +++ b/dep/ACE_wrappers/VERSION @@ -0,0 +1,11 @@ +This is ACE version 5.6.6, released Mon Sep 15 06:08:04 CDT 2008 + +If you have any problems with or questions about ACE, please send +email to the ACE mailing list (ace-users@cs.wustl.edu), using the form +found in the file PROBLEM-REPORT-FORM. To ensure that you see responses, +please do one of the following: + + 1) Subscribe to the ace-users mail list, by sending email with + contents "subscribe ace-users" to majordomo@cs.wustl.edu. + + 2) Or, monitor the comp.soft-sys.ace newsgroup for responses. diff --git a/dep/ACE_wrappers/ace/ACE.bor b/dep/ACE_wrappers/ace/ACE.bor new file mode 100644 index 00000000000..4eb982fcd05 --- /dev/null +++ b/dep/ACE_wrappers/ace/ACE.bor @@ -0,0 +1,2312 @@ +# Makefile for building the ACE library with Borland C++ Make + +NAME = ACE + +NO_FULL_PATH=1 + +OBJFILES = \ + $(OBJDIR)\ACE.$(OBJ_EXT) \ + $(OBJDIR)\ACE_crc32.$(OBJ_EXT) \ + $(OBJDIR)\ACE_crc_ccitt.$(OBJ_EXT) \ + $(OBJDIR)\ace_wchar.$(OBJ_EXT) \ + $(OBJDIR)\Activation_Queue.$(OBJ_EXT) \ + $(OBJDIR)\Active_Map_Manager.$(OBJ_EXT) \ + $(OBJDIR)\Addr.$(OBJ_EXT) \ + $(OBJDIR)\Argv_Type_Converter.$(OBJ_EXT) \ + $(OBJDIR)\Assert.$(OBJ_EXT) \ + $(OBJDIR)\Asynch_IO.$(OBJ_EXT) \ + $(OBJDIR)\Asynch_IO_Impl.$(OBJ_EXT) \ + $(OBJDIR)\Asynch_Pseudo_Task.$(OBJ_EXT) \ + $(OBJDIR)\ATM_Acceptor.$(OBJ_EXT) \ + $(OBJDIR)\ATM_Addr.$(OBJ_EXT) \ + $(OBJDIR)\ATM_Connector.$(OBJ_EXT) \ + $(OBJDIR)\ATM_Params.$(OBJ_EXT) \ + $(OBJDIR)\ATM_QoS.$(OBJ_EXT) \ + $(OBJDIR)\ATM_Stream.$(OBJ_EXT) \ + $(OBJDIR)\Atomic_Op.$(OBJ_EXT) \ + $(OBJDIR)\Atomic_Op_Sparc.$(OBJ_EXT) \ + $(OBJDIR)\Auto_Event.$(OBJ_EXT) \ + $(OBJDIR)\Barrier.$(OBJ_EXT) \ + $(OBJDIR)\Base_Thread_Adapter.$(OBJ_EXT) \ + $(OBJDIR)\Based_Pointer_Repository.$(OBJ_EXT) \ + $(OBJDIR)\Basic_Stats.$(OBJ_EXT) \ + $(OBJDIR)\Basic_Types.$(OBJ_EXT) \ + $(OBJDIR)\Capabilities.$(OBJ_EXT) \ + $(OBJDIR)\CDR_Base.$(OBJ_EXT) \ + $(OBJDIR)\CDR_Size.$(OBJ_EXT) \ + $(OBJDIR)\CDR_Stream.$(OBJ_EXT) \ + $(OBJDIR)\Cleanup.$(OBJ_EXT) \ + $(OBJDIR)\Codecs.$(OBJ_EXT) \ + $(OBJDIR)\Codeset_IBM1047.$(OBJ_EXT) \ + $(OBJDIR)\Codeset_Registry.$(OBJ_EXT) \ + $(OBJDIR)\Codeset_Registry_db.$(OBJ_EXT) \ + $(OBJDIR)\Condition_Recursive_Thread_Mutex.$(OBJ_EXT) \ + $(OBJDIR)\Condition_Thread_Mutex.$(OBJ_EXT) \ + $(OBJDIR)\Configuration.$(OBJ_EXT) \ + $(OBJDIR)\Configuration_Import_Export.$(OBJ_EXT) \ + $(OBJDIR)\Connection_Recycling_Strategy.$(OBJ_EXT) \ + $(OBJDIR)\Containers.$(OBJ_EXT) \ + $(OBJDIR)\Copy_Disabled.$(OBJ_EXT) \ + $(OBJDIR)\Countdown_Time.$(OBJ_EXT) \ + $(OBJDIR)\Date_Time.$(OBJ_EXT) \ + $(OBJDIR)\DEV.$(OBJ_EXT) \ + $(OBJDIR)\DEV_Addr.$(OBJ_EXT) \ + $(OBJDIR)\DEV_Connector.$(OBJ_EXT) \ + $(OBJDIR)\DEV_IO.$(OBJ_EXT) \ + $(OBJDIR)\Dev_Poll_Reactor.$(OBJ_EXT) \ + $(OBJDIR)\Dirent.$(OBJ_EXT) \ + $(OBJDIR)\Dirent_Selector.$(OBJ_EXT) \ + $(OBJDIR)\DLL.$(OBJ_EXT) \ + $(OBJDIR)\DLL_Manager.$(OBJ_EXT) \ + $(OBJDIR)\Dump.$(OBJ_EXT) \ + $(OBJDIR)\Dynamic.$(OBJ_EXT) \ + $(OBJDIR)\Dynamic_Message_Strategy.$(OBJ_EXT) \ + $(OBJDIR)\Dynamic_Service_Base.$(OBJ_EXT) \ + $(OBJDIR)\Dynamic_Service_Dependency.$(OBJ_EXT) \ + $(OBJDIR)\Encoding_Converter.$(OBJ_EXT) \ + $(OBJDIR)\Encoding_Converter_Factory.$(OBJ_EXT) \ + $(OBJDIR)\Event.$(OBJ_EXT) \ + $(OBJDIR)\Event_Handler.$(OBJ_EXT) \ + $(OBJDIR)\FIFO.$(OBJ_EXT) \ + $(OBJDIR)\FIFO_Recv.$(OBJ_EXT) \ + $(OBJDIR)\FIFO_Recv_Msg.$(OBJ_EXT) \ + $(OBJDIR)\FIFO_Send.$(OBJ_EXT) \ + $(OBJDIR)\FIFO_Send_Msg.$(OBJ_EXT) \ + $(OBJDIR)\FILE.$(OBJ_EXT) \ + $(OBJDIR)\FILE_Addr.$(OBJ_EXT) \ + $(OBJDIR)\FILE_Connector.$(OBJ_EXT) \ + $(OBJDIR)\FILE_IO.$(OBJ_EXT) \ + $(OBJDIR)\File_Lock.$(OBJ_EXT) \ + $(OBJDIR)\Filecache.$(OBJ_EXT) \ + $(OBJDIR)\Flag_Manip.$(OBJ_EXT) \ + $(OBJDIR)\Framework_Component.$(OBJ_EXT) \ + $(OBJDIR)\Functor.$(OBJ_EXT) \ + $(OBJDIR)\Functor_String.$(OBJ_EXT) \ + $(OBJDIR)\Get_Opt.$(OBJ_EXT) \ + $(OBJDIR)\gethrtime.$(OBJ_EXT) \ + $(OBJDIR)\Handle_Ops.$(OBJ_EXT) \ + $(OBJDIR)\Handle_Set.$(OBJ_EXT) \ + $(OBJDIR)\Hashable.$(OBJ_EXT) \ + $(OBJDIR)\High_Res_Timer.$(OBJ_EXT) \ + $(OBJDIR)\ICMP_Socket.$(OBJ_EXT) \ + $(OBJDIR)\INET_Addr.$(OBJ_EXT) \ + $(OBJDIR)\Init_ACE.$(OBJ_EXT) \ + $(OBJDIR)\IO_Cntl_Msg.$(OBJ_EXT) \ + $(OBJDIR)\IO_SAP.$(OBJ_EXT) \ + $(OBJDIR)\IOStream.$(OBJ_EXT) \ + $(OBJDIR)\IPC_SAP.$(OBJ_EXT) \ + $(OBJDIR)\Lib_Find.$(OBJ_EXT) \ + $(OBJDIR)\Local_Memory_Pool.$(OBJ_EXT) \ + $(OBJDIR)\Local_Name_Space.$(OBJ_EXT) \ + $(OBJDIR)\Local_Tokens.$(OBJ_EXT) \ + $(OBJDIR)\Lock.$(OBJ_EXT) \ + $(OBJDIR)\Log_Msg.$(OBJ_EXT) \ + $(OBJDIR)\Log_Msg_Backend.$(OBJ_EXT) \ + $(OBJDIR)\Log_Msg_Callback.$(OBJ_EXT) \ + $(OBJDIR)\Log_Msg_IPC.$(OBJ_EXT) \ + $(OBJDIR)\Log_Msg_NT_Event_Log.$(OBJ_EXT) \ + $(OBJDIR)\Log_Msg_UNIX_Syslog.$(OBJ_EXT) \ + $(OBJDIR)\Log_Record.$(OBJ_EXT) \ + $(OBJDIR)\Logging_Strategy.$(OBJ_EXT) \ + $(OBJDIR)\LSOCK.$(OBJ_EXT) \ + $(OBJDIR)\LSOCK_Acceptor.$(OBJ_EXT) \ + $(OBJDIR)\LSOCK_CODgram.$(OBJ_EXT) \ + $(OBJDIR)\LSOCK_Connector.$(OBJ_EXT) \ + $(OBJDIR)\LSOCK_Dgram.$(OBJ_EXT) \ + $(OBJDIR)\LSOCK_Stream.$(OBJ_EXT) \ + $(OBJDIR)\Malloc.$(OBJ_EXT) \ + $(OBJDIR)\Malloc_Allocator.$(OBJ_EXT) \ + $(OBJDIR)\Manual_Event.$(OBJ_EXT) \ + $(OBJDIR)\MEM_Acceptor.$(OBJ_EXT) \ + $(OBJDIR)\MEM_Addr.$(OBJ_EXT) \ + $(OBJDIR)\MEM_Connector.$(OBJ_EXT) \ + $(OBJDIR)\MEM_IO.$(OBJ_EXT) \ + $(OBJDIR)\Mem_Map.$(OBJ_EXT) \ + $(OBJDIR)\MEM_SAP.$(OBJ_EXT) \ + $(OBJDIR)\MEM_Stream.$(OBJ_EXT) \ + $(OBJDIR)\Message_Block.$(OBJ_EXT) \ + $(OBJDIR)\Message_Queue.$(OBJ_EXT) \ + $(OBJDIR)\Message_Queue_NT.$(OBJ_EXT) \ + $(OBJDIR)\Message_Queue_Vx.$(OBJ_EXT) \ + $(OBJDIR)\Method_Request.$(OBJ_EXT) \ + $(OBJDIR)\MMAP_Memory_Pool.$(OBJ_EXT) \ + $(OBJDIR)\Monitor_Admin.$(OBJ_EXT) \ + $(OBJDIR)\Monitor_Admin_Manager.$(OBJ_EXT) \ + $(OBJDIR)\Monitor_Base.$(OBJ_EXT) \ + $(OBJDIR)\Monitor_Control_Action.$(OBJ_EXT) \ + $(OBJDIR)\Monitor_Control_Types.$(OBJ_EXT) \ + $(OBJDIR)\Monitor_Point_Registry.$(OBJ_EXT) \ + $(OBJDIR)\Monitor_Size.$(OBJ_EXT) \ + $(OBJDIR)\Msg_WFMO_Reactor.$(OBJ_EXT) \ + $(OBJDIR)\Multihomed_INET_Addr.$(OBJ_EXT) \ + $(OBJDIR)\Mutex.$(OBJ_EXT) \ + $(OBJDIR)\Name_Proxy.$(OBJ_EXT) \ + $(OBJDIR)\Name_Request_Reply.$(OBJ_EXT) \ + $(OBJDIR)\Name_Space.$(OBJ_EXT) \ + $(OBJDIR)\Naming_Context.$(OBJ_EXT) \ + $(OBJDIR)\Netlink_Addr.$(OBJ_EXT) \ + $(OBJDIR)\Notification_Queue.$(OBJ_EXT) \ + $(OBJDIR)\Notification_Strategy.$(OBJ_EXT) \ + $(OBJDIR)\NT_Service.$(OBJ_EXT) \ + $(OBJDIR)\Obchunk.$(OBJ_EXT) \ + $(OBJDIR)\Object_Manager.$(OBJ_EXT) \ + $(OBJDIR)\Object_Manager_Base.$(OBJ_EXT) \ + $(OBJDIR)\OS_Errno.$(OBJ_EXT) \ + $(OBJDIR)\OS_Log_Msg_Attributes.$(OBJ_EXT) \ + $(OBJDIR)\OS_main.$(OBJ_EXT) \ + $(OBJDIR)\OS_NS_arpa_inet.$(OBJ_EXT) \ + $(OBJDIR)\OS_NS_ctype.$(OBJ_EXT) \ + $(OBJDIR)\OS_NS_dirent.$(OBJ_EXT) \ + $(OBJDIR)\OS_NS_dlfcn.$(OBJ_EXT) \ + $(OBJDIR)\OS_NS_errno.$(OBJ_EXT) \ + $(OBJDIR)\OS_NS_fcntl.$(OBJ_EXT) \ + $(OBJDIR)\OS_NS_math.$(OBJ_EXT) \ + $(OBJDIR)\OS_NS_netdb.$(OBJ_EXT) \ + $(OBJDIR)\OS_NS_poll.$(OBJ_EXT) \ + $(OBJDIR)\OS_NS_pwd.$(OBJ_EXT) \ + $(OBJDIR)\OS_NS_regex.$(OBJ_EXT) \ + $(OBJDIR)\OS_NS_signal.$(OBJ_EXT) \ + $(OBJDIR)\OS_NS_stdio.$(OBJ_EXT) \ + $(OBJDIR)\OS_NS_stdlib.$(OBJ_EXT) \ + $(OBJDIR)\OS_NS_string.$(OBJ_EXT) \ + $(OBJDIR)\OS_NS_strings.$(OBJ_EXT) \ + $(OBJDIR)\OS_NS_stropts.$(OBJ_EXT) \ + $(OBJDIR)\OS_NS_sys_mman.$(OBJ_EXT) \ + $(OBJDIR)\OS_NS_sys_msg.$(OBJ_EXT) \ + $(OBJDIR)\OS_NS_sys_resource.$(OBJ_EXT) \ + $(OBJDIR)\OS_NS_sys_select.$(OBJ_EXT) \ + $(OBJDIR)\OS_NS_sys_sendfile.$(OBJ_EXT) \ + $(OBJDIR)\OS_NS_sys_shm.$(OBJ_EXT) \ + $(OBJDIR)\OS_NS_sys_socket.$(OBJ_EXT) \ + $(OBJDIR)\OS_NS_sys_stat.$(OBJ_EXT) \ + $(OBJDIR)\OS_NS_sys_time.$(OBJ_EXT) \ + $(OBJDIR)\OS_NS_sys_uio.$(OBJ_EXT) \ + $(OBJDIR)\OS_NS_sys_utsname.$(OBJ_EXT) \ + $(OBJDIR)\OS_NS_sys_wait.$(OBJ_EXT) \ + $(OBJDIR)\OS_NS_Thread.$(OBJ_EXT) \ + $(OBJDIR)\OS_NS_time.$(OBJ_EXT) \ + $(OBJDIR)\OS_NS_unistd.$(OBJ_EXT) \ + $(OBJDIR)\OS_NS_wchar.$(OBJ_EXT) \ + $(OBJDIR)\OS_QoS.$(OBJ_EXT) \ + $(OBJDIR)\OS_Thread_Adapter.$(OBJ_EXT) \ + $(OBJDIR)\OS_TLI.$(OBJ_EXT) \ + $(OBJDIR)\Pagefile_Memory_Pool.$(OBJ_EXT) \ + $(OBJDIR)\Parse_Node.$(OBJ_EXT) \ + $(OBJDIR)\PI_Malloc.$(OBJ_EXT) \ + $(OBJDIR)\Ping_Socket.$(OBJ_EXT) \ + $(OBJDIR)\Pipe.$(OBJ_EXT) \ + $(OBJDIR)\POSIX_Asynch_IO.$(OBJ_EXT) \ + $(OBJDIR)\POSIX_CB_Proactor.$(OBJ_EXT) \ + $(OBJDIR)\POSIX_Proactor.$(OBJ_EXT) \ + $(OBJDIR)\Priority_Reactor.$(OBJ_EXT) \ + $(OBJDIR)\Proactor.$(OBJ_EXT) \ + $(OBJDIR)\Proactor_Impl.$(OBJ_EXT) \ + $(OBJDIR)\Process.$(OBJ_EXT) \ + $(OBJDIR)\Process_Manager.$(OBJ_EXT) \ + $(OBJDIR)\Process_Mutex.$(OBJ_EXT) \ + $(OBJDIR)\Process_Semaphore.$(OBJ_EXT) \ + $(OBJDIR)\Profile_Timer.$(OBJ_EXT) \ + $(OBJDIR)\Reactor.$(OBJ_EXT) \ + $(OBJDIR)\Reactor_Impl.$(OBJ_EXT) \ + $(OBJDIR)\Reactor_Notification_Strategy.$(OBJ_EXT) \ + $(OBJDIR)\Reactor_Timer_Interface.$(OBJ_EXT) \ + $(OBJDIR)\Read_Buffer.$(OBJ_EXT) \ + $(OBJDIR)\Recursive_Thread_Mutex.$(OBJ_EXT) \ + $(OBJDIR)\Recyclable.$(OBJ_EXT) \ + $(OBJDIR)\Registry.$(OBJ_EXT) \ + $(OBJDIR)\Registry_Name_Space.$(OBJ_EXT) \ + $(OBJDIR)\Remote_Name_Space.$(OBJ_EXT) \ + $(OBJDIR)\Remote_Tokens.$(OBJ_EXT) \ + $(OBJDIR)\Rtems_init.$(OBJ_EXT) \ + $(OBJDIR)\RW_Mutex.$(OBJ_EXT) \ + $(OBJDIR)\RW_Process_Mutex.$(OBJ_EXT) \ + $(OBJDIR)\RW_Thread_Mutex.$(OBJ_EXT) \ + $(OBJDIR)\Sample_History.$(OBJ_EXT) \ + $(OBJDIR)\Sbrk_Memory_Pool.$(OBJ_EXT) \ + $(OBJDIR)\Sched_Params.$(OBJ_EXT) \ + $(OBJDIR)\Select_Reactor_Base.$(OBJ_EXT) \ + $(OBJDIR)\Semaphore.$(OBJ_EXT) \ + $(OBJDIR)\Service_Config.$(OBJ_EXT) \ + $(OBJDIR)\Service_Gestalt.$(OBJ_EXT) \ + $(OBJDIR)\Service_Manager.$(OBJ_EXT) \ + $(OBJDIR)\Service_Object.$(OBJ_EXT) \ + $(OBJDIR)\Service_Repository.$(OBJ_EXT) \ + $(OBJDIR)\Service_Types.$(OBJ_EXT) \ + $(OBJDIR)\Shared_Memory.$(OBJ_EXT) \ + $(OBJDIR)\Shared_Memory_MM.$(OBJ_EXT) \ + $(OBJDIR)\Shared_Memory_Pool.$(OBJ_EXT) \ + $(OBJDIR)\Shared_Memory_SV.$(OBJ_EXT) \ + $(OBJDIR)\Shared_Object.$(OBJ_EXT) \ + $(OBJDIR)\Sig_Adapter.$(OBJ_EXT) \ + $(OBJDIR)\Sig_Handler.$(OBJ_EXT) \ + $(OBJDIR)\Signal.$(OBJ_EXT) \ + $(OBJDIR)\SOCK.$(OBJ_EXT) \ + $(OBJDIR)\SOCK_Acceptor.$(OBJ_EXT) \ + $(OBJDIR)\SOCK_CODgram.$(OBJ_EXT) \ + $(OBJDIR)\Sock_Connect.$(OBJ_EXT) \ + $(OBJDIR)\SOCK_Connector.$(OBJ_EXT) \ + $(OBJDIR)\SOCK_Dgram.$(OBJ_EXT) \ + $(OBJDIR)\SOCK_Dgram_Bcast.$(OBJ_EXT) \ + $(OBJDIR)\SOCK_Dgram_Mcast.$(OBJ_EXT) \ + $(OBJDIR)\SOCK_IO.$(OBJ_EXT) \ + $(OBJDIR)\SOCK_Netlink.$(OBJ_EXT) \ + $(OBJDIR)\SOCK_SEQPACK_Acceptor.$(OBJ_EXT) \ + $(OBJDIR)\SOCK_SEQPACK_Association.$(OBJ_EXT) \ + $(OBJDIR)\SOCK_SEQPACK_Connector.$(OBJ_EXT) \ + $(OBJDIR)\SOCK_Stream.$(OBJ_EXT) \ + $(OBJDIR)\SPIPE.$(OBJ_EXT) \ + $(OBJDIR)\SPIPE_Acceptor.$(OBJ_EXT) \ + $(OBJDIR)\SPIPE_Addr.$(OBJ_EXT) \ + $(OBJDIR)\SPIPE_Connector.$(OBJ_EXT) \ + $(OBJDIR)\SPIPE_Stream.$(OBJ_EXT) \ + $(OBJDIR)\SString.$(OBJ_EXT) \ + $(OBJDIR)\Stack_Trace.$(OBJ_EXT) \ + $(OBJDIR)\Stats.$(OBJ_EXT) \ + $(OBJDIR)\String_Base_Const.$(OBJ_EXT) \ + $(OBJDIR)\SUN_Proactor.$(OBJ_EXT) \ + $(OBJDIR)\SV_Message.$(OBJ_EXT) \ + $(OBJDIR)\SV_Message_Queue.$(OBJ_EXT) \ + $(OBJDIR)\SV_Semaphore_Complex.$(OBJ_EXT) \ + $(OBJDIR)\SV_Semaphore_Simple.$(OBJ_EXT) \ + $(OBJDIR)\SV_Shared_Memory.$(OBJ_EXT) \ + $(OBJDIR)\Svc_Conf_Lexer.$(OBJ_EXT) \ + $(OBJDIR)\Svc_Conf_y.$(OBJ_EXT) \ + $(OBJDIR)\Synch_Options.$(OBJ_EXT) \ + $(OBJDIR)\System_Time.$(OBJ_EXT) \ + $(OBJDIR)\Task.$(OBJ_EXT) \ + $(OBJDIR)\Thread.$(OBJ_EXT) \ + $(OBJDIR)\Thread_Adapter.$(OBJ_EXT) \ + $(OBJDIR)\Thread_Control.$(OBJ_EXT) \ + $(OBJDIR)\Thread_Exit.$(OBJ_EXT) \ + $(OBJDIR)\Thread_Hook.$(OBJ_EXT) \ + $(OBJDIR)\Thread_Manager.$(OBJ_EXT) \ + $(OBJDIR)\Thread_Mutex.$(OBJ_EXT) \ + $(OBJDIR)\Thread_Semaphore.$(OBJ_EXT) \ + $(OBJDIR)\Throughput_Stats.$(OBJ_EXT) \ + $(OBJDIR)\Time_Value.$(OBJ_EXT) \ + $(OBJDIR)\Timeprobe.$(OBJ_EXT) \ + $(OBJDIR)\TLI.$(OBJ_EXT) \ + $(OBJDIR)\TLI_Acceptor.$(OBJ_EXT) \ + $(OBJDIR)\TLI_Connector.$(OBJ_EXT) \ + $(OBJDIR)\TLI_Stream.$(OBJ_EXT) \ + $(OBJDIR)\Token.$(OBJ_EXT) \ + $(OBJDIR)\Token_Collection.$(OBJ_EXT) \ + $(OBJDIR)\Token_Invariants.$(OBJ_EXT) \ + $(OBJDIR)\Token_Manager.$(OBJ_EXT) \ + $(OBJDIR)\Token_Request_Reply.$(OBJ_EXT) \ + $(OBJDIR)\TP_Reactor.$(OBJ_EXT) \ + $(OBJDIR)\Trace.$(OBJ_EXT) \ + $(OBJDIR)\TSS_Adapter.$(OBJ_EXT) \ + $(OBJDIR)\TTY_IO.$(OBJ_EXT) \ + $(OBJDIR)\UNIX_Addr.$(OBJ_EXT) \ + $(OBJDIR)\UPIPE_Acceptor.$(OBJ_EXT) \ + $(OBJDIR)\UPIPE_Connector.$(OBJ_EXT) \ + $(OBJDIR)\UPIPE_Stream.$(OBJ_EXT) \ + $(OBJDIR)\UTF16_Encoding_Converter.$(OBJ_EXT) \ + $(OBJDIR)\UTF32_Encoding_Converter.$(OBJ_EXT) \ + $(OBJDIR)\UTF8_Encoding_Converter.$(OBJ_EXT) \ + $(OBJDIR)\UUID.$(OBJ_EXT) \ + $(OBJDIR)\WFMO_Reactor.$(OBJ_EXT) \ + $(OBJDIR)\WIN32_Asynch_IO.$(OBJ_EXT) \ + $(OBJDIR)\WIN32_Proactor.$(OBJ_EXT) \ + $(OBJDIR)\XML_Svc_Conf.$(OBJ_EXT) \ + $(OBJDIR)\XTI_ATM_Mcast.$(OBJ_EXT) + +LFLAGS = \ + -L"." \ + -j"." \ + -L"..\lib" \ + -j"..\lib" + +RESDIR = . + +RESOURCE = $(OBJDIR)\ace.res + +RC_FLAGS = \ + -i".." + + +!ifdef STATIC +LIB_FLAGS = \ + -DACE_AS_STATIC_LIBS +!else +DLL_FLAGS = \ + -DACE_BUILD_DLL +!endif + +CFLAGS = \ + -I".." \ + $(LIB_FLAGS) \ + $(DLL_FLAGS) + +CPPDIR = . +CDIR = . + +INCDIR_NAME = stage-10168\ACE_wrappers\ace + +# build_files rules + + +# test_files rules + + +# pkgconfig_files rules + + +# Override defaults in outputdir.bor +INSTALL_THIS_TARGET = 1 + +INCLUDES_INSTALL=1 +BINDIR = ..\lib + +!include <$(ACE_ROOT)\include\makeinclude\build_library.bor> + +includes_install: $(INCLUDES) + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Acceptor.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Acceptor.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y ACE.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\ACE.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y ACE_export.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\ACE_export.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y ace_wchar.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\ace_wchar.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Activation_Queue.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Activation_Queue.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Active_Map_Manager.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Active_Map_Manager.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Active_Map_Manager_T.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Active_Map_Manager_T.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Addr.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Addr.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Arg_Shifter.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Arg_Shifter.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y ARGV.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\ARGV.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Argv_Type_Converter.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Argv_Type_Converter.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Array.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Array.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Array_Base.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Array_Base.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Array_Map.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Array_Map.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Assert.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Assert.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Asynch_Acceptor.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Asynch_Acceptor.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Asynch_Connector.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Asynch_Connector.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Asynch_IO.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Asynch_IO.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Asynch_IO_Impl.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Asynch_IO_Impl.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Asynch_Pseudo_Task.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Asynch_Pseudo_Task.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y ATM_Acceptor.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\ATM_Acceptor.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y ATM_Addr.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\ATM_Addr.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y ATM_Connector.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\ATM_Connector.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y ATM_Params.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\ATM_Params.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y ATM_QoS.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\ATM_QoS.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y ATM_Stream.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\ATM_Stream.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Atomic_Op.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Atomic_Op.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Atomic_Op_Sparc.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Atomic_Op_Sparc.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Atomic_Op_T.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Atomic_Op_T.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Auto_Event.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Auto_Event.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Auto_Functor.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Auto_Functor.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Auto_IncDec_T.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Auto_IncDec_T.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Auto_Ptr.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Auto_Ptr.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Barrier.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Barrier.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Base_Thread_Adapter.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Base_Thread_Adapter.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Based_Pointer_Repository.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Based_Pointer_Repository.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Based_Pointer_T.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Based_Pointer_T.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Basic_Stats.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Basic_Stats.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Basic_Types.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Basic_Types.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Bound_Ptr.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Bound_Ptr.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Cache_Map_Manager_T.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Cache_Map_Manager_T.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Cached_Connect_Strategy_T.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Cached_Connect_Strategy_T.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Caching_Strategies_T.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Caching_Strategies_T.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Caching_Utility_T.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Caching_Utility_T.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Capabilities.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Capabilities.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y CDR_Base.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\CDR_Base.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y CDR_Size.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\CDR_Size.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y CDR_Stream.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\CDR_Stream.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y CE_Screen_Output.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\CE_Screen_Output.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y checked_iterator.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\checked_iterator.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Cleanup.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Cleanup.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Cleanup_Strategies_T.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Cleanup_Strategies_T.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Codecs.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Codecs.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Codeset_IBM1047.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Codeset_IBM1047.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Codeset_Registry.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Codeset_Registry.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Codeset_Symbols.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Codeset_Symbols.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Condition_Recursive_Thread_Mutex.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Condition_Recursive_Thread_Mutex.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Condition_T.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Condition_T.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Condition_Thread_Mutex.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Condition_Thread_Mutex.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y config-aix-5.x.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\config-aix-5.x.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y config-all.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\config-all.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y config-borland-common.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\config-borland-common.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y config-cray.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\config-cray.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y config-cxx-common.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\config-cxx-common.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y config-cygwin32.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\config-cygwin32.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y config-doxygen.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\config-doxygen.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y config-freebsd.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\config-freebsd.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y config-g++-common.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\config-g++-common.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y config-ghs-common.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\config-ghs-common.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y config-hpux-11.00.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\config-hpux-11.00.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y config-icc-common.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\config-icc-common.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y config-integritySCA.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\config-integritySCA.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y config-irix6.5.x-sgic++.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\config-irix6.5.x-sgic++.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y config-irix6.x-common.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\config-irix6.x-common.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y config-irix6.x-g++.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\config-irix6.x-g++.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y config-irix6.x-sgic++.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\config-irix6.x-sgic++.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y config-linux-common.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\config-linux-common.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y config-linux.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\config-linux.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y config-lite.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\config-lite.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y config-lynxos.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\config-lynxos.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y config-macosx-leopard.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\config-macosx-leopard.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y config-macosx-panther.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\config-macosx-panther.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y config-macosx-tiger.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\config-macosx-tiger.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y config-macosx.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\config-macosx.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y config-macros.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\config-macros.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y config-minimal.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\config-minimal.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y config-mvs.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\config-mvs.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y config-netbsd.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\config-netbsd.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y config-openbsd.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\config-openbsd.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y config-openvms.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\config-openvms.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y config-pharlap.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\config-pharlap.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y config-posix-nonetworking.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\config-posix-nonetworking.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y config-posix.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\config-posix.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y config-qnx-neutrino.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\config-qnx-neutrino.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y config-qnx-rtp-62x.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\config-qnx-rtp-62x.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y config-qnx-rtp-common.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\config-qnx-rtp-common.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y config-qnx-rtp-pre62x.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\config-qnx-rtp-pre62x.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y config-qnx-rtp.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\config-qnx-rtp.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y config-rtems.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\config-rtems.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y config-sco-5.0.0-nothread.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\config-sco-5.0.0-nothread.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y config-sco-5.0.0.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\config-sco-5.0.0.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y config-suncc-common.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\config-suncc-common.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y config-sunos5.10.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\config-sunos5.10.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y config-sunos5.11.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\config-sunos5.11.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y config-sunos5.4-g++.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\config-sunos5.4-g++.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y config-sunos5.4-sunc++-4.x.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\config-sunos5.4-sunc++-4.x.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y config-sunos5.5.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\config-sunos5.5.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y config-sunos5.6.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\config-sunos5.6.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y config-sunos5.7.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\config-sunos5.7.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y config-sunos5.8.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\config-sunos5.8.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y config-sunos5.9.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\config-sunos5.9.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y config-tandem-nsk-mips-v2.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\config-tandem-nsk-mips-v2.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y config-tandem-nsk-mips-v3.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\config-tandem-nsk-mips-v3.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y config-tandem.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\config-tandem.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y config-tru64.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\config-tru64.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y config-unixware-7.1.0.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\config-unixware-7.1.0.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y config-unixware-7.1.0.udk.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\config-unixware-7.1.0.udk.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y config-visualage.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\config-visualage.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y config-vxworks.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\config-vxworks.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y config-vxworks5.x.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\config-vxworks5.x.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y config-vxworks6.2.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\config-vxworks6.2.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y config-vxworks6.3.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\config-vxworks6.3.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y config-vxworks6.4.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\config-vxworks6.4.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y config-vxworks6.5.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\config-vxworks6.5.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y config-vxworks6.6.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\config-vxworks6.6.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y config-win32-borland.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\config-win32-borland.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y config-win32-common.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\config-win32-common.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y config-win32-dmc.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\config-win32-dmc.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y config-win32-ghs.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\config-win32-ghs.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y config-win32-interix.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\config-win32-interix.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y config-win32-mingw.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\config-win32-mingw.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y config-win32-msvc-7.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\config-win32-msvc-7.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y config-win32-msvc-8.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\config-win32-msvc-8.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y config-win32-msvc-9.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\config-win32-msvc-9.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y config-win32-msvc.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\config-win32-msvc.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y config-win32.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\config-win32.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y config-WinCE.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\config-WinCE.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y config.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\config.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Configuration.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Configuration.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Configuration_Import_Export.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Configuration_Import_Export.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Connection_Recycling_Strategy.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Connection_Recycling_Strategy.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Connector.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Connector.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Containers.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Containers.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Containers_T.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Containers_T.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Copy_Disabled.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Copy_Disabled.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y CORBA_macros.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\CORBA_macros.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Countdown_Time.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Countdown_Time.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Date_Time.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Date_Time.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Default_Constants.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Default_Constants.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y DEV.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\DEV.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y DEV_Addr.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\DEV_Addr.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y DEV_Connector.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\DEV_Connector.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y DEV_IO.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\DEV_IO.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Dev_Poll_Reactor.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Dev_Poll_Reactor.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Dirent.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Dirent.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Dirent_Selector.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Dirent_Selector.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y DLL.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\DLL.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y DLL_Manager.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\DLL_Manager.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Dump.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Dump.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Dump_T.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Dump_T.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Dynamic.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Dynamic.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Dynamic_Message_Strategy.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Dynamic_Message_Strategy.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Dynamic_Service.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Dynamic_Service.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Dynamic_Service_Base.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Dynamic_Service_Base.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Dynamic_Service_Dependency.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Dynamic_Service_Dependency.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Encoding_Converter.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Encoding_Converter.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Encoding_Converter_Factory.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Encoding_Converter_Factory.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Env_Value_T.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Env_Value_T.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Event.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Event.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Event_Handler.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Event_Handler.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Event_Handler_T.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Event_Handler_T.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Exception_Macros.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Exception_Macros.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y FIFO.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\FIFO.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y FIFO_Recv.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\FIFO_Recv.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y FIFO_Recv_Msg.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\FIFO_Recv_Msg.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y FIFO_Send.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\FIFO_Send.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y FIFO_Send_Msg.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\FIFO_Send_Msg.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y FILE.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\FILE.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y FILE_Addr.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\FILE_Addr.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y FILE_Connector.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\FILE_Connector.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y FILE_IO.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\FILE_IO.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y File_Lock.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\File_Lock.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Filecache.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Filecache.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Flag_Manip.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Flag_Manip.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Framework_Component.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Framework_Component.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Framework_Component_T.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Framework_Component_T.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Free_List.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Free_List.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Functor.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Functor.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Functor_String.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Functor_String.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Functor_T.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Functor_T.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Future.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Future.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Future_Set.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Future_Set.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Get_Opt.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Get_Opt.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Global_Macros.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Global_Macros.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Guard_T.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Guard_T.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Handle_Gobbler.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Handle_Gobbler.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Handle_Ops.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Handle_Ops.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Handle_Set.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Handle_Set.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Hash_Cache_Map_Manager_T.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Hash_Cache_Map_Manager_T.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Hash_Map_Manager.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Hash_Map_Manager.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Hash_Map_Manager_T.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Hash_Map_Manager_T.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Hash_Map_With_Allocator_T.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Hash_Map_With_Allocator_T.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Hash_Multi_Map_Manager_T.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Hash_Multi_Map_Manager_T.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Hashable.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Hashable.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y High_Res_Timer.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\High_Res_Timer.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y ICMP_Socket.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\ICMP_Socket.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y If_Then_Else.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\If_Then_Else.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y INET_Addr.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\INET_Addr.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Init_ACE.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Init_ACE.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Intrusive_Auto_Ptr.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Intrusive_Auto_Ptr.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Intrusive_List.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Intrusive_List.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Intrusive_List_Node.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Intrusive_List_Node.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y IO_Cntl_Msg.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\IO_Cntl_Msg.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y IO_SAP.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\IO_SAP.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y iosfwd.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\iosfwd.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y IOStream.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\IOStream.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y IOStream_T.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\IOStream_T.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y IPC_SAP.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\IPC_SAP.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Lib_Find.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Lib_Find.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Local_Memory_Pool.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Local_Memory_Pool.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Local_Name_Space.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Local_Name_Space.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Local_Name_Space_T.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Local_Name_Space_T.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Local_Tokens.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Local_Tokens.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Lock.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Lock.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Lock_Adapter_T.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Lock_Adapter_T.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y LOCK_SOCK_Acceptor.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\LOCK_SOCK_Acceptor.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Log_Msg.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Log_Msg.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Log_Msg_Backend.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Log_Msg_Backend.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Log_Msg_Callback.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Log_Msg_Callback.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Log_Msg_IPC.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Log_Msg_IPC.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Log_Msg_NT_Event_Log.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Log_Msg_NT_Event_Log.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Log_Msg_UNIX_Syslog.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Log_Msg_UNIX_Syslog.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Log_Priority.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Log_Priority.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Log_Record.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Log_Record.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Logging_Strategy.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Logging_Strategy.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y LSOCK.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\LSOCK.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y LSOCK_Acceptor.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\LSOCK_Acceptor.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y LSOCK_CODgram.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\LSOCK_CODgram.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y LSOCK_Connector.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\LSOCK_Connector.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y LSOCK_Dgram.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\LSOCK_Dgram.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y LSOCK_Stream.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\LSOCK_Stream.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Malloc.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Malloc.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Malloc_Allocator.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Malloc_Allocator.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Malloc_Base.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Malloc_Base.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Malloc_T.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Malloc_T.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Managed_Object.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Managed_Object.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Manual_Event.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Manual_Event.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Map.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Map.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Map_Manager.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Map_Manager.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Map_T.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Map_T.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y MEM_Acceptor.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\MEM_Acceptor.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y MEM_Addr.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\MEM_Addr.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y MEM_Connector.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\MEM_Connector.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y MEM_IO.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\MEM_IO.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Mem_Map.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Mem_Map.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y MEM_SAP.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\MEM_SAP.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y MEM_Stream.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\MEM_Stream.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Memory_Pool.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Memory_Pool.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Message_Block.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Message_Block.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Message_Block_T.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Message_Block_T.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Message_Queue.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Message_Queue.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Message_Queue_NT.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Message_Queue_NT.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Message_Queue_T.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Message_Queue_T.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Message_Queue_Vx.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Message_Queue_Vx.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Method_Object.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Method_Object.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Method_Request.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Method_Request.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Metrics_Cache.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Metrics_Cache.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Metrics_Cache_T.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Metrics_Cache_T.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Min_Max.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Min_Max.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y MMAP_Memory_Pool.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\MMAP_Memory_Pool.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Module.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Module.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Monitor_Admin.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Monitor_Admin.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Monitor_Admin_Manager.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Monitor_Admin_Manager.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Monitor_Base.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Monitor_Base.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Monitor_Control_Action.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Monitor_Control_Action.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Monitor_Control_Types.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Monitor_Control_Types.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Monitor_Point_Registry.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Monitor_Point_Registry.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Monitor_Size.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Monitor_Size.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Msg_WFMO_Reactor.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Msg_WFMO_Reactor.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Multihomed_INET_Addr.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Multihomed_INET_Addr.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Mutex.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Mutex.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Name_Proxy.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Name_Proxy.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Name_Request_Reply.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Name_Request_Reply.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Name_Space.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Name_Space.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Naming_Context.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Naming_Context.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Netlink_Addr.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Netlink_Addr.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Node.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Node.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Notification_Queue.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Notification_Queue.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Notification_Strategy.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Notification_Strategy.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y NT_Service.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\NT_Service.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Null_Barrier.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Null_Barrier.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Null_Condition.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Null_Condition.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Null_Mutex.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Null_Mutex.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Null_Semaphore.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Null_Semaphore.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Numeric_Limits.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Numeric_Limits.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Obchunk.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Obchunk.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Object_Manager.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Object_Manager.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Object_Manager_Base.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Object_Manager_Base.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Obstack.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Obstack.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Obstack_T.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Obstack_T.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y OS.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\OS.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y OS_Dirent.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\OS_Dirent.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y OS_Errno.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\OS_Errno.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\arpa mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\arpa + -© /Y os_include\arpa\os_inet.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\arpa\os_inet.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\net mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\net + -© /Y os_include\net\os_if.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\net\os_if.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\netinet mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\netinet + -© /Y os_include\netinet\os_in.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\netinet\os_in.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\netinet mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\netinet + -© /Y os_include\netinet\os_tcp.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\netinet\os_tcp.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include + -© /Y os_include\os_aio.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\os_aio.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include + -© /Y os_include\os_assert.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\os_assert.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include + -© /Y os_include\os_byteswap.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\os_byteswap.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include + -© /Y os_include\os_complex.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\os_complex.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include + -© /Y os_include\os_cpio.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\os_cpio.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include + -© /Y os_include\os_ctype.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\os_ctype.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include + -© /Y os_include\os_dirent.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\os_dirent.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include + -© /Y os_include\os_dlfcn.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\os_dlfcn.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include + -© /Y os_include\os_errno.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\os_errno.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include + -© /Y os_include\os_fcntl.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\os_fcntl.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include + -© /Y os_include\os_fenv.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\os_fenv.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include + -© /Y os_include\os_float.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\os_float.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include + -© /Y os_include\os_fmtmsg.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\os_fmtmsg.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include + -© /Y os_include\os_fnmatch.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\os_fnmatch.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include + -© /Y os_include\os_ftw.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\os_ftw.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include + -© /Y os_include\os_glob.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\os_glob.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include + -© /Y os_include\os_grp.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\os_grp.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include + -© /Y os_include\os_iconv.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\os_iconv.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include + -© /Y os_include\os_intrin.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\os_intrin.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include + -© /Y os_include\os_inttypes.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\os_inttypes.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include + -© /Y os_include\os_iso646.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\os_iso646.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include + -© /Y os_include\os_kstat.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\os_kstat.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include + -© /Y os_include\os_langinfo.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\os_langinfo.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include + -© /Y os_include\os_libgen.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\os_libgen.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include + -© /Y os_include\os_limits.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\os_limits.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include + -© /Y os_include\os_local.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\os_local.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include + -© /Y os_include\os_math.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\os_math.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include + -© /Y os_include\os_monetary.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\os_monetary.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include + -© /Y os_include\os_mqueue.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\os_mqueue.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include + -© /Y os_include\os_ndbm.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\os_ndbm.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include + -© /Y os_include\os_netdb.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\os_netdb.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include + -© /Y os_include\os_nl_types.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\os_nl_types.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include + -© /Y os_include\os_pdh.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\os_pdh.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include + -© /Y os_include\os_pdhmsg.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\os_pdhmsg.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include + -© /Y os_include\os_poll.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\os_poll.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include + -© /Y os_include\os_pthread.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\os_pthread.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include + -© /Y os_include\os_pwd.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\os_pwd.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include + -© /Y os_include\os_regex.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\os_regex.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include + -© /Y os_include\os_sched.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\os_sched.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include + -© /Y os_include\os_search.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\os_search.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include + -© /Y os_include\os_semaphore.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\os_semaphore.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include + -© /Y os_include\os_setjmp.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\os_setjmp.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include + -© /Y os_include\os_signal.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\os_signal.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include + -© /Y os_include\os_spawn.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\os_spawn.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include + -© /Y os_include\os_stdarg.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\os_stdarg.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include + -© /Y os_include\os_stdbool.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\os_stdbool.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include + -© /Y os_include\os_stddef.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\os_stddef.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include + -© /Y os_include\os_stdint.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\os_stdint.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include + -© /Y os_include\os_stdio.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\os_stdio.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include + -© /Y os_include\os_stdlib.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\os_stdlib.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include + -© /Y os_include\os_string.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\os_string.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include + -© /Y os_include\os_strings.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\os_strings.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include + -© /Y os_include\os_stropts.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\os_stropts.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include + -© /Y os_include\os_syslog.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\os_syslog.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include + -© /Y os_include\os_tar.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\os_tar.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include + -© /Y os_include\os_termios.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\os_termios.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include + -© /Y os_include\os_tgmath.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\os_tgmath.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include + -© /Y os_include\os_time.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\os_time.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include + -© /Y os_include\os_trace.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\os_trace.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include + -© /Y os_include\os_ucontext.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\os_ucontext.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include + -© /Y os_include\os_ulimit.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\os_ulimit.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include + -© /Y os_include\os_unistd.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\os_unistd.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include + -© /Y os_include\os_utime.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\os_utime.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include + -© /Y os_include\os_utmpx.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\os_utmpx.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include + -© /Y os_include\os_wchar.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\os_wchar.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include + -© /Y os_include\os_wctype.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\os_wctype.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include + -© /Y os_include\os_wordexp.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\os_wordexp.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\sys mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\sys + -© /Y os_include\sys\os_ipc.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\sys\os_ipc.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\sys mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\sys + -© /Y os_include\sys\os_loadavg.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\sys\os_loadavg.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\sys mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\sys + -© /Y os_include\sys\os_mman.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\sys\os_mman.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\sys mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\sys + -© /Y os_include\sys\os_msg.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\sys\os_msg.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\sys mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\sys + -© /Y os_include\sys\os_pstat.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\sys\os_pstat.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\sys mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\sys + -© /Y os_include\sys\os_resource.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\sys\os_resource.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\sys mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\sys + -© /Y os_include\sys\os_select.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\sys\os_select.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\sys mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\sys + -© /Y os_include\sys\os_sem.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\sys\os_sem.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\sys mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\sys + -© /Y os_include\sys\os_shm.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\sys\os_shm.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\sys mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\sys + -© /Y os_include\sys\os_socket.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\sys\os_socket.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\sys mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\sys + -© /Y os_include\sys\os_stat.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\sys\os_stat.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\sys mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\sys + -© /Y os_include\sys\os_statvfs.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\sys\os_statvfs.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\sys mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\sys + -© /Y os_include\sys\os_sysctl.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\sys\os_sysctl.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\sys mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\sys + -© /Y os_include\sys\os_sysinfo.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\sys\os_sysinfo.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\sys mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\sys + -© /Y os_include\sys\os_time.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\sys\os_time.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\sys mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\sys + -© /Y os_include\sys\os_timeb.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\sys\os_timeb.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\sys mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\sys + -© /Y os_include\sys\os_times.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\sys\os_times.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\sys mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\sys + -© /Y os_include\sys\os_types.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\sys\os_types.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\sys mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\sys + -© /Y os_include\sys\os_uio.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\sys\os_uio.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\sys mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\sys + -© /Y os_include\sys\os_un.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\sys\os_un.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\sys mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\sys + -© /Y os_include\sys\os_utsname.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\sys\os_utsname.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\sys mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\sys + -© /Y os_include\sys\os_wait.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\os_include\sys\os_wait.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y OS_Log_Msg_Attributes.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\OS_Log_Msg_Attributes.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y OS_main.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\OS_main.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y OS_Memory.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\OS_Memory.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y OS_NS_arpa_inet.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\OS_NS_arpa_inet.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y OS_NS_ctype.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\OS_NS_ctype.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y OS_NS_dirent.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\OS_NS_dirent.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y OS_NS_dlfcn.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\OS_NS_dlfcn.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y OS_NS_errno.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\OS_NS_errno.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y OS_NS_fcntl.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\OS_NS_fcntl.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y OS_NS_macros.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\OS_NS_macros.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y OS_NS_math.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\OS_NS_math.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y OS_NS_netdb.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\OS_NS_netdb.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y OS_NS_poll.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\OS_NS_poll.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y OS_NS_pwd.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\OS_NS_pwd.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y OS_NS_regex.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\OS_NS_regex.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y OS_NS_signal.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\OS_NS_signal.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y OS_NS_stdio.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\OS_NS_stdio.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y OS_NS_stdlib.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\OS_NS_stdlib.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y OS_NS_string.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\OS_NS_string.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y OS_NS_strings.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\OS_NS_strings.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y OS_NS_stropts.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\OS_NS_stropts.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y OS_NS_sys_mman.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\OS_NS_sys_mman.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y OS_NS_sys_msg.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\OS_NS_sys_msg.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y OS_NS_sys_resource.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\OS_NS_sys_resource.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y OS_NS_sys_select.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\OS_NS_sys_select.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y OS_NS_sys_sendfile.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\OS_NS_sys_sendfile.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y OS_NS_sys_shm.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\OS_NS_sys_shm.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y OS_NS_sys_socket.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\OS_NS_sys_socket.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y OS_NS_sys_stat.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\OS_NS_sys_stat.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y OS_NS_sys_time.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\OS_NS_sys_time.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y OS_NS_sys_uio.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\OS_NS_sys_uio.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y OS_NS_sys_utsname.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\OS_NS_sys_utsname.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y OS_NS_sys_wait.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\OS_NS_sys_wait.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y OS_NS_Thread.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\OS_NS_Thread.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y OS_NS_time.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\OS_NS_time.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y OS_NS_unistd.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\OS_NS_unistd.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y OS_NS_wchar.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\OS_NS_wchar.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y OS_QoS.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\OS_QoS.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y OS_String.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\OS_String.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y OS_Thread_Adapter.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\OS_Thread_Adapter.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y OS_TLI.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\OS_TLI.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Pagefile_Memory_Pool.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Pagefile_Memory_Pool.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Pair.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Pair.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Pair_T.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Pair_T.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Parse_Node.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Parse_Node.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y PI_Malloc.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\PI_Malloc.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Ping_Socket.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Ping_Socket.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Pipe.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Pipe.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y POSIX_Asynch_IO.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\POSIX_Asynch_IO.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y POSIX_CB_Proactor.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\POSIX_CB_Proactor.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y POSIX_Proactor.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\POSIX_Proactor.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y post.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\post.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y pre.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\pre.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Priority_Reactor.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Priority_Reactor.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Proactor.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Proactor.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Proactor_Impl.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Proactor_Impl.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Process.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Process.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Process_Manager.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Process_Manager.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Process_Mutex.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Process_Mutex.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Process_Semaphore.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Process_Semaphore.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Profile_Timer.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Profile_Timer.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y RB_Tree.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\RB_Tree.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Reactor.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Reactor.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Reactor_Impl.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Reactor_Impl.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Reactor_Notification_Strategy.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Reactor_Notification_Strategy.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Reactor_Timer_Interface.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Reactor_Timer_Interface.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Reactor_Token_T.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Reactor_Token_T.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Read_Buffer.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Read_Buffer.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Recursive_Thread_Mutex.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Recursive_Thread_Mutex.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Recyclable.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Recyclable.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Refcountable.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Refcountable.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Refcountable_T.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Refcountable_T.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Refcounted_Auto_Ptr.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Refcounted_Auto_Ptr.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Registry.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Registry.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Registry_Name_Space.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Registry_Name_Space.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Remote_Name_Space.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Remote_Name_Space.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Remote_Tokens.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Remote_Tokens.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Reverse_Lock_T.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Reverse_Lock_T.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y RW_Mutex.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\RW_Mutex.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y RW_Process_Mutex.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\RW_Process_Mutex.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y RW_Thread_Mutex.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\RW_Thread_Mutex.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Sample_History.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Sample_History.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Sbrk_Memory_Pool.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Sbrk_Memory_Pool.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Sched_Params.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Sched_Params.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Select_Reactor.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Select_Reactor.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Select_Reactor_Base.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Select_Reactor_Base.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Select_Reactor_T.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Select_Reactor_T.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Semaphore.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Semaphore.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Service_Config.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Service_Config.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Service_Gestalt.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Service_Gestalt.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Service_Manager.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Service_Manager.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Service_Object.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Service_Object.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Service_Repository.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Service_Repository.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Service_Templates.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Service_Templates.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Service_Types.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Service_Types.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Shared_Memory.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Shared_Memory.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Shared_Memory_MM.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Shared_Memory_MM.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Shared_Memory_Pool.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Shared_Memory_Pool.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Shared_Memory_SV.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Shared_Memory_SV.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Shared_Object.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Shared_Object.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Sig_Adapter.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Sig_Adapter.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Sig_Handler.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Sig_Handler.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Signal.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Signal.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Singleton.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Singleton.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y SOCK.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\SOCK.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y SOCK_Acceptor.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\SOCK_Acceptor.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y SOCK_CODgram.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\SOCK_CODgram.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Sock_Connect.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Sock_Connect.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y SOCK_Connector.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\SOCK_Connector.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y SOCK_Dgram.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\SOCK_Dgram.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y SOCK_Dgram_Bcast.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\SOCK_Dgram_Bcast.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y SOCK_Dgram_Mcast.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\SOCK_Dgram_Mcast.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y SOCK_IO.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\SOCK_IO.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y SOCK_Netlink.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\SOCK_Netlink.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y SOCK_SEQPACK_Acceptor.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\SOCK_SEQPACK_Acceptor.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y SOCK_SEQPACK_Association.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\SOCK_SEQPACK_Association.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y SOCK_SEQPACK_Connector.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\SOCK_SEQPACK_Connector.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y SOCK_Stream.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\SOCK_Stream.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y SPIPE.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\SPIPE.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y SPIPE_Acceptor.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\SPIPE_Acceptor.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y SPIPE_Addr.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\SPIPE_Addr.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y SPIPE_Connector.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\SPIPE_Connector.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y SPIPE_Stream.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\SPIPE_Stream.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y SString.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\SString.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y SStringfwd.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\SStringfwd.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Stack_Trace.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Stack_Trace.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Static_Object_Lock.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Static_Object_Lock.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Stats.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Stats.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Strategies.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Strategies.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Strategies_T.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Strategies_T.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Stream.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Stream.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Stream_Modules.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Stream_Modules.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y streams.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\streams.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y String_Base.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\String_Base.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y String_Base_Const.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\String_Base_Const.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y SUN_Proactor.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\SUN_Proactor.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y SV_Message.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\SV_Message.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y SV_Message_Queue.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\SV_Message_Queue.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y SV_Semaphore_Complex.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\SV_Semaphore_Complex.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y SV_Semaphore_Simple.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\SV_Semaphore_Simple.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y SV_Shared_Memory.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\SV_Shared_Memory.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Svc_Conf.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Svc_Conf.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Svc_Conf_Lexer.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Svc_Conf_Lexer.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Svc_Conf_Param.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Svc_Conf_Param.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Svc_Conf_Token_Table.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Svc_Conf_Token_Table.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Svc_Conf_Tokens.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Svc_Conf_Tokens.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y svc_export.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\svc_export.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Svc_Handler.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Svc_Handler.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Synch.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Synch.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Synch_Options.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Synch_Options.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Synch_T.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Synch_T.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Synch_Traits.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Synch_Traits.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y System_Time.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\System_Time.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Task.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Task.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Task_Ex_T.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Task_Ex_T.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Task_T.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Task_T.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Test_and_Set.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Test_and_Set.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Thread.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Thread.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Thread_Adapter.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Thread_Adapter.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Thread_Control.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Thread_Control.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Thread_Exit.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Thread_Exit.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Thread_Hook.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Thread_Hook.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Thread_Manager.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Thread_Manager.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Thread_Mutex.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Thread_Mutex.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Thread_Semaphore.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Thread_Semaphore.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Throughput_Stats.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Throughput_Stats.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Time_Value.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Time_Value.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Timeprobe.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Timeprobe.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Timeprobe_T.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Timeprobe_T.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Timer_Hash.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Timer_Hash.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Timer_Hash_T.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Timer_Hash_T.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Timer_Heap.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Timer_Heap.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Timer_Heap_T.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Timer_Heap_T.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Timer_List.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Timer_List.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Timer_List_T.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Timer_List_T.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Timer_Queue.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Timer_Queue.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Timer_Queue_Adapters.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Timer_Queue_Adapters.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Timer_Queue_T.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Timer_Queue_T.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Timer_Queuefwd.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Timer_Queuefwd.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Timer_Wheel.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Timer_Wheel.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Timer_Wheel_T.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Timer_Wheel_T.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y TLI.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\TLI.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y TLI_Acceptor.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\TLI_Acceptor.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y TLI_Connector.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\TLI_Connector.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y TLI_Stream.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\TLI_Stream.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Token.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Token.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Token_Collection.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Token_Collection.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Token_Invariants.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Token_Invariants.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Token_Manager.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Token_Manager.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Token_Request_Reply.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Token_Request_Reply.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y TP_Reactor.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\TP_Reactor.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Trace.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Trace.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Truncate.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Truncate.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y TSS_Adapter.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\TSS_Adapter.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y TSS_T.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\TSS_T.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y TTY_IO.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\TTY_IO.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Typed_SV_Message.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Typed_SV_Message.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Typed_SV_Message_Queue.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Typed_SV_Message_Queue.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Unbounded_Queue.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Unbounded_Queue.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Unbounded_Set.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Unbounded_Set.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Unbounded_Set_Ex.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Unbounded_Set_Ex.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y UNIX_Addr.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\UNIX_Addr.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y UPIPE_Acceptor.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\UPIPE_Acceptor.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y UPIPE_Addr.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\UPIPE_Addr.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y UPIPE_Connector.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\UPIPE_Connector.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y UPIPE_Stream.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\UPIPE_Stream.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y UTF16_Encoding_Converter.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\UTF16_Encoding_Converter.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y UTF32_Encoding_Converter.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\UTF32_Encoding_Converter.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y UTF8_Encoding_Converter.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\UTF8_Encoding_Converter.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y UUID.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\UUID.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Value_Ptr.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Value_Ptr.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Vector_T.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Vector_T.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Version.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Version.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Versioned_Namespace.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\Versioned_Namespace.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y WFMO_Reactor.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\WFMO_Reactor.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y WIN32_Asynch_IO.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\WIN32_Asynch_IO.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y WIN32_Proactor.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\WIN32_Proactor.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y XML_Svc_Conf.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\XML_Svc_Conf.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y XTI_ATM_Mcast.h $(INSTALL_DIR)\include\$(INCDIR_NAME)\XTI_ATM_Mcast.h 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Acceptor.cpp $(INSTALL_DIR)\include\$(INCDIR_NAME)\Acceptor.cpp 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Active_Map_Manager_T.cpp $(INSTALL_DIR)\include\$(INCDIR_NAME)\Active_Map_Manager_T.cpp 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Arg_Shifter.cpp $(INSTALL_DIR)\include\$(INCDIR_NAME)\Arg_Shifter.cpp 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y ARGV.cpp $(INSTALL_DIR)\include\$(INCDIR_NAME)\ARGV.cpp 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Array_Base.cpp $(INSTALL_DIR)\include\$(INCDIR_NAME)\Array_Base.cpp 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Array_Map.cpp $(INSTALL_DIR)\include\$(INCDIR_NAME)\Array_Map.cpp 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Asynch_Acceptor.cpp $(INSTALL_DIR)\include\$(INCDIR_NAME)\Asynch_Acceptor.cpp 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Asynch_Connector.cpp $(INSTALL_DIR)\include\$(INCDIR_NAME)\Asynch_Connector.cpp 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Atomic_Op_T.cpp $(INSTALL_DIR)\include\$(INCDIR_NAME)\Atomic_Op_T.cpp 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Auto_Functor.cpp $(INSTALL_DIR)\include\$(INCDIR_NAME)\Auto_Functor.cpp 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Auto_IncDec_T.cpp $(INSTALL_DIR)\include\$(INCDIR_NAME)\Auto_IncDec_T.cpp 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Auto_Ptr.cpp $(INSTALL_DIR)\include\$(INCDIR_NAME)\Auto_Ptr.cpp 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Based_Pointer_T.cpp $(INSTALL_DIR)\include\$(INCDIR_NAME)\Based_Pointer_T.cpp 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Cache_Map_Manager_T.cpp $(INSTALL_DIR)\include\$(INCDIR_NAME)\Cache_Map_Manager_T.cpp 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Cached_Connect_Strategy_T.cpp $(INSTALL_DIR)\include\$(INCDIR_NAME)\Cached_Connect_Strategy_T.cpp 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Caching_Strategies_T.cpp $(INSTALL_DIR)\include\$(INCDIR_NAME)\Caching_Strategies_T.cpp 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Caching_Utility_T.cpp $(INSTALL_DIR)\include\$(INCDIR_NAME)\Caching_Utility_T.cpp 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Cleanup_Strategies_T.cpp $(INSTALL_DIR)\include\$(INCDIR_NAME)\Cleanup_Strategies_T.cpp 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Condition_T.cpp $(INSTALL_DIR)\include\$(INCDIR_NAME)\Condition_T.cpp 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Connector.cpp $(INSTALL_DIR)\include\$(INCDIR_NAME)\Connector.cpp 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Containers_T.cpp $(INSTALL_DIR)\include\$(INCDIR_NAME)\Containers_T.cpp 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Dump_T.cpp $(INSTALL_DIR)\include\$(INCDIR_NAME)\Dump_T.cpp 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Dynamic_Service.cpp $(INSTALL_DIR)\include\$(INCDIR_NAME)\Dynamic_Service.cpp 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Env_Value_T.cpp $(INSTALL_DIR)\include\$(INCDIR_NAME)\Env_Value_T.cpp 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Event_Handler_T.cpp $(INSTALL_DIR)\include\$(INCDIR_NAME)\Event_Handler_T.cpp 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Framework_Component_T.cpp $(INSTALL_DIR)\include\$(INCDIR_NAME)\Framework_Component_T.cpp 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Free_List.cpp $(INSTALL_DIR)\include\$(INCDIR_NAME)\Free_List.cpp 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Functor_T.cpp $(INSTALL_DIR)\include\$(INCDIR_NAME)\Functor_T.cpp 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Future.cpp $(INSTALL_DIR)\include\$(INCDIR_NAME)\Future.cpp 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Future_Set.cpp $(INSTALL_DIR)\include\$(INCDIR_NAME)\Future_Set.cpp 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Guard_T.cpp $(INSTALL_DIR)\include\$(INCDIR_NAME)\Guard_T.cpp 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Hash_Cache_Map_Manager_T.cpp $(INSTALL_DIR)\include\$(INCDIR_NAME)\Hash_Cache_Map_Manager_T.cpp 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Hash_Map_Manager_T.cpp $(INSTALL_DIR)\include\$(INCDIR_NAME)\Hash_Map_Manager_T.cpp 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Hash_Map_With_Allocator_T.cpp $(INSTALL_DIR)\include\$(INCDIR_NAME)\Hash_Map_With_Allocator_T.cpp 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Hash_Multi_Map_Manager_T.cpp $(INSTALL_DIR)\include\$(INCDIR_NAME)\Hash_Multi_Map_Manager_T.cpp 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Intrusive_Auto_Ptr.cpp $(INSTALL_DIR)\include\$(INCDIR_NAME)\Intrusive_Auto_Ptr.cpp 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Intrusive_List.cpp $(INSTALL_DIR)\include\$(INCDIR_NAME)\Intrusive_List.cpp 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Intrusive_List_Node.cpp $(INSTALL_DIR)\include\$(INCDIR_NAME)\Intrusive_List_Node.cpp 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y IOStream_T.cpp $(INSTALL_DIR)\include\$(INCDIR_NAME)\IOStream_T.cpp 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Local_Name_Space_T.cpp $(INSTALL_DIR)\include\$(INCDIR_NAME)\Local_Name_Space_T.cpp 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Lock_Adapter_T.cpp $(INSTALL_DIR)\include\$(INCDIR_NAME)\Lock_Adapter_T.cpp 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y LOCK_SOCK_Acceptor.cpp $(INSTALL_DIR)\include\$(INCDIR_NAME)\LOCK_SOCK_Acceptor.cpp 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Malloc_T.cpp $(INSTALL_DIR)\include\$(INCDIR_NAME)\Malloc_T.cpp 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Managed_Object.cpp $(INSTALL_DIR)\include\$(INCDIR_NAME)\Managed_Object.cpp 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Map_Manager.cpp $(INSTALL_DIR)\include\$(INCDIR_NAME)\Map_Manager.cpp 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Map_T.cpp $(INSTALL_DIR)\include\$(INCDIR_NAME)\Map_T.cpp 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Message_Block_T.cpp $(INSTALL_DIR)\include\$(INCDIR_NAME)\Message_Block_T.cpp 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Message_Queue_T.cpp $(INSTALL_DIR)\include\$(INCDIR_NAME)\Message_Queue_T.cpp 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Metrics_Cache_T.cpp $(INSTALL_DIR)\include\$(INCDIR_NAME)\Metrics_Cache_T.cpp 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Module.cpp $(INSTALL_DIR)\include\$(INCDIR_NAME)\Module.cpp 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Node.cpp $(INSTALL_DIR)\include\$(INCDIR_NAME)\Node.cpp 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Obstack_T.cpp $(INSTALL_DIR)\include\$(INCDIR_NAME)\Obstack_T.cpp 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Pair_T.cpp $(INSTALL_DIR)\include\$(INCDIR_NAME)\Pair_T.cpp 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y RB_Tree.cpp $(INSTALL_DIR)\include\$(INCDIR_NAME)\RB_Tree.cpp 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Reactor_Token_T.cpp $(INSTALL_DIR)\include\$(INCDIR_NAME)\Reactor_Token_T.cpp 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Refcountable_T.cpp $(INSTALL_DIR)\include\$(INCDIR_NAME)\Refcountable_T.cpp 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Refcounted_Auto_Ptr.cpp $(INSTALL_DIR)\include\$(INCDIR_NAME)\Refcounted_Auto_Ptr.cpp 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Reverse_Lock_T.cpp $(INSTALL_DIR)\include\$(INCDIR_NAME)\Reverse_Lock_T.cpp 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Select_Reactor_T.cpp $(INSTALL_DIR)\include\$(INCDIR_NAME)\Select_Reactor_T.cpp 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Singleton.cpp $(INSTALL_DIR)\include\$(INCDIR_NAME)\Singleton.cpp 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Strategies_T.cpp $(INSTALL_DIR)\include\$(INCDIR_NAME)\Strategies_T.cpp 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Stream.cpp $(INSTALL_DIR)\include\$(INCDIR_NAME)\Stream.cpp 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Stream_Modules.cpp $(INSTALL_DIR)\include\$(INCDIR_NAME)\Stream_Modules.cpp 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y String_Base.cpp $(INSTALL_DIR)\include\$(INCDIR_NAME)\String_Base.cpp 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Svc_Handler.cpp $(INSTALL_DIR)\include\$(INCDIR_NAME)\Svc_Handler.cpp 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Synch_T.cpp $(INSTALL_DIR)\include\$(INCDIR_NAME)\Synch_T.cpp 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Task_Ex_T.cpp $(INSTALL_DIR)\include\$(INCDIR_NAME)\Task_Ex_T.cpp 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Task_T.cpp $(INSTALL_DIR)\include\$(INCDIR_NAME)\Task_T.cpp 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Test_and_Set.cpp $(INSTALL_DIR)\include\$(INCDIR_NAME)\Test_and_Set.cpp 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Timeprobe_T.cpp $(INSTALL_DIR)\include\$(INCDIR_NAME)\Timeprobe_T.cpp 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Timer_Hash_T.cpp $(INSTALL_DIR)\include\$(INCDIR_NAME)\Timer_Hash_T.cpp 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Timer_Heap_T.cpp $(INSTALL_DIR)\include\$(INCDIR_NAME)\Timer_Heap_T.cpp 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Timer_List_T.cpp $(INSTALL_DIR)\include\$(INCDIR_NAME)\Timer_List_T.cpp 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Timer_Queue_Adapters.cpp $(INSTALL_DIR)\include\$(INCDIR_NAME)\Timer_Queue_Adapters.cpp 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Timer_Queue_T.cpp $(INSTALL_DIR)\include\$(INCDIR_NAME)\Timer_Queue_T.cpp 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Timer_Wheel_T.cpp $(INSTALL_DIR)\include\$(INCDIR_NAME)\Timer_Wheel_T.cpp 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y TSS_T.cpp $(INSTALL_DIR)\include\$(INCDIR_NAME)\TSS_T.cpp 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Typed_SV_Message.cpp $(INSTALL_DIR)\include\$(INCDIR_NAME)\Typed_SV_Message.cpp 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Typed_SV_Message_Queue.cpp $(INSTALL_DIR)\include\$(INCDIR_NAME)\Typed_SV_Message_Queue.cpp 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Unbounded_Queue.cpp $(INSTALL_DIR)\include\$(INCDIR_NAME)\Unbounded_Queue.cpp 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Unbounded_Set.cpp $(INSTALL_DIR)\include\$(INCDIR_NAME)\Unbounded_Set.cpp 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Unbounded_Set_Ex.cpp $(INSTALL_DIR)\include\$(INCDIR_NAME)\Unbounded_Set_Ex.cpp 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Vector_T.cpp $(INSTALL_DIR)\include\$(INCDIR_NAME)\Vector_T.cpp 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y ACE.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\ACE.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y ace_wchar.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\ace_wchar.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Activation_Queue.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Activation_Queue.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Active_Map_Manager.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Active_Map_Manager.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Active_Map_Manager_T.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Active_Map_Manager_T.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Addr.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Addr.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y ARGV.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\ARGV.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Argv_Type_Converter.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Argv_Type_Converter.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Array_Base.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Array_Base.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Array_Map.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Array_Map.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Asynch_IO_Impl.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Asynch_IO_Impl.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y ATM_Acceptor.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\ATM_Acceptor.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y ATM_Addr.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\ATM_Addr.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y ATM_Connector.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\ATM_Connector.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y ATM_Params.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\ATM_Params.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y ATM_QoS.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\ATM_QoS.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y ATM_Stream.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\ATM_Stream.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Atomic_Op.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Atomic_Op.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Atomic_Op_T.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Atomic_Op_T.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Auto_Event.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Auto_Event.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Auto_Functor.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Auto_Functor.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Auto_IncDec_T.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Auto_IncDec_T.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Auto_Ptr.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Auto_Ptr.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Barrier.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Barrier.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Base_Thread_Adapter.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Base_Thread_Adapter.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Based_Pointer_T.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Based_Pointer_T.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Basic_Stats.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Basic_Stats.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Basic_Types.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Basic_Types.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Bound_Ptr.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Bound_Ptr.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Cache_Map_Manager_T.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Cache_Map_Manager_T.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Caching_Strategies_T.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Caching_Strategies_T.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Capabilities.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Capabilities.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y CDR_Base.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\CDR_Base.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y CDR_Size.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\CDR_Size.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y CDR_Stream.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\CDR_Stream.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Cleanup.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Cleanup.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Codeset_Registry.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Codeset_Registry.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Condition_T.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Condition_T.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Condition_Thread_Mutex.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Condition_Thread_Mutex.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Configuration.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Configuration.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Containers.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Containers.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Containers_T.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Containers_T.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Date_Time.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Date_Time.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y DEV.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\DEV.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y DEV_Addr.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\DEV_Addr.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y DEV_Connector.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\DEV_Connector.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y DEV_IO.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\DEV_IO.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Dev_Poll_Reactor.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Dev_Poll_Reactor.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Dirent.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Dirent.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Dirent_Selector.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Dirent_Selector.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Dynamic.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Dynamic.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Dynamic_Message_Strategy.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Dynamic_Message_Strategy.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Dynamic_Service.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Dynamic_Service.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Env_Value_T.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Env_Value_T.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Event.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Event.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Event_Handler.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Event_Handler.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Event_Handler_T.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Event_Handler_T.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y FIFO.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\FIFO.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y FIFO_Recv.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\FIFO_Recv.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y FIFO_Recv_Msg.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\FIFO_Recv_Msg.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y FIFO_Send.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\FIFO_Send.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y FIFO_Send_Msg.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\FIFO_Send_Msg.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y FILE.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\FILE.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y FILE_Addr.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\FILE_Addr.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y FILE_Connector.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\FILE_Connector.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y FILE_IO.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\FILE_IO.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y File_Lock.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\File_Lock.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Flag_Manip.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Flag_Manip.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Framework_Component.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Framework_Component.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Functor.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Functor.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Functor_String.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Functor_String.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Functor_T.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Functor_T.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Get_Opt.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Get_Opt.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Guard_T.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Guard_T.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Handle_Gobbler.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Handle_Gobbler.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Handle_Set.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Handle_Set.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Hash_Cache_Map_Manager_T.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Hash_Cache_Map_Manager_T.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Hash_Map_Manager_T.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Hash_Map_Manager_T.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Hash_Map_With_Allocator_T.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Hash_Map_With_Allocator_T.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Hash_Multi_Map_Manager_T.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Hash_Multi_Map_Manager_T.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Hashable.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Hashable.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y High_Res_Timer.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\High_Res_Timer.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y INET_Addr.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\INET_Addr.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Intrusive_Auto_Ptr.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Intrusive_Auto_Ptr.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Intrusive_List.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Intrusive_List.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Intrusive_List_Node.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Intrusive_List_Node.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y IO_Cntl_Msg.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\IO_Cntl_Msg.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y IO_SAP.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\IO_SAP.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y IOStream_T.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\IOStream_T.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y IPC_SAP.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\IPC_SAP.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Local_Tokens.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Local_Tokens.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Lock.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Lock.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Lock_Adapter_T.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Lock_Adapter_T.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Log_Msg.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Log_Msg.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Log_Record.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Log_Record.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y LSOCK.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\LSOCK.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y LSOCK_CODgram.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\LSOCK_CODgram.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y LSOCK_Connector.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\LSOCK_Connector.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y LSOCK_Dgram.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\LSOCK_Dgram.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y LSOCK_Stream.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\LSOCK_Stream.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Malloc.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Malloc.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Malloc_Allocator.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Malloc_Allocator.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Malloc_T.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Malloc_T.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Managed_Object.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Managed_Object.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Manual_Event.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Manual_Event.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Map_Manager.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Map_Manager.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Map_T.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Map_T.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y MEM_Acceptor.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\MEM_Acceptor.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y MEM_Addr.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\MEM_Addr.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y MEM_Connector.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\MEM_Connector.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y MEM_IO.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\MEM_IO.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Mem_Map.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Mem_Map.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y MEM_SAP.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\MEM_SAP.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y MEM_Stream.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\MEM_Stream.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Message_Block.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Message_Block.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Message_Block_T.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Message_Block_T.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Message_Queue.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Message_Queue.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Message_Queue_NT.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Message_Queue_NT.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Message_Queue_Vx.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Message_Queue_Vx.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Metrics_Cache_T.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Metrics_Cache_T.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y MMAP_Memory_Pool.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\MMAP_Memory_Pool.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Module.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Module.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Monitor_Base.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Monitor_Base.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Msg_WFMO_Reactor.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Msg_WFMO_Reactor.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Multihomed_INET_Addr.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Multihomed_INET_Addr.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Mutex.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Mutex.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Naming_Context.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Naming_Context.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Netlink_Addr.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Netlink_Addr.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Notification_Queue.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Notification_Queue.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Notification_Strategy.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Notification_Strategy.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y NT_Service.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\NT_Service.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Obchunk.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Obchunk.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Object_Manager.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Object_Manager.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Obstack_T.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Obstack_T.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y OS.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\OS.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y OS_Errno.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\OS_Errno.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y OS_Log_Msg_Attributes.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\OS_Log_Msg_Attributes.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y OS_NS_arpa_inet.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\OS_NS_arpa_inet.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y OS_NS_ctype.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\OS_NS_ctype.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y OS_NS_dirent.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\OS_NS_dirent.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y OS_NS_dlfcn.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\OS_NS_dlfcn.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y OS_NS_errno.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\OS_NS_errno.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y OS_NS_fcntl.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\OS_NS_fcntl.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y OS_NS_math.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\OS_NS_math.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y OS_NS_netdb.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\OS_NS_netdb.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y OS_NS_poll.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\OS_NS_poll.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y OS_NS_pwd.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\OS_NS_pwd.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y OS_NS_regex.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\OS_NS_regex.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y OS_NS_signal.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\OS_NS_signal.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y OS_NS_stdio.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\OS_NS_stdio.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y OS_NS_stdlib.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\OS_NS_stdlib.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y OS_NS_string.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\OS_NS_string.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y OS_NS_strings.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\OS_NS_strings.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y OS_NS_stropts.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\OS_NS_stropts.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y OS_NS_sys_mman.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\OS_NS_sys_mman.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y OS_NS_sys_msg.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\OS_NS_sys_msg.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y OS_NS_sys_resource.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\OS_NS_sys_resource.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y OS_NS_sys_select.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\OS_NS_sys_select.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y OS_NS_sys_sendfile.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\OS_NS_sys_sendfile.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y OS_NS_sys_shm.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\OS_NS_sys_shm.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y OS_NS_sys_socket.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\OS_NS_sys_socket.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y OS_NS_sys_stat.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\OS_NS_sys_stat.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y OS_NS_sys_time.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\OS_NS_sys_time.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y OS_NS_sys_uio.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\OS_NS_sys_uio.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y OS_NS_sys_wait.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\OS_NS_sys_wait.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y OS_NS_Thread.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\OS_NS_Thread.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y OS_NS_time.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\OS_NS_time.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y OS_NS_unistd.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\OS_NS_unistd.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y OS_NS_wchar.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\OS_NS_wchar.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y OS_TLI.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\OS_TLI.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Pagefile_Memory_Pool.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Pagefile_Memory_Pool.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Pair_T.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Pair_T.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y PI_Malloc.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\PI_Malloc.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Ping_Socket.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Ping_Socket.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Pipe.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Pipe.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y POSIX_Proactor.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\POSIX_Proactor.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Proactor.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Proactor.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Process.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Process.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Process_Manager.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Process_Manager.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Process_Mutex.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Process_Mutex.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Process_Semaphore.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Process_Semaphore.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Profile_Timer.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Profile_Timer.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y RB_Tree.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\RB_Tree.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Reactor.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Reactor.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Reactor_Notification_Strategy.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Reactor_Notification_Strategy.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Read_Buffer.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Read_Buffer.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Recursive_Thread_Mutex.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Recursive_Thread_Mutex.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Recyclable.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Recyclable.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Refcountable_T.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Refcountable_T.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Refcounted_Auto_Ptr.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Refcounted_Auto_Ptr.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Remote_Tokens.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Remote_Tokens.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Reverse_Lock_T.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Reverse_Lock_T.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y RW_Mutex.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\RW_Mutex.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y RW_Process_Mutex.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\RW_Process_Mutex.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y RW_Thread_Mutex.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\RW_Thread_Mutex.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Sample_History.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Sample_History.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Sched_Params.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Sched_Params.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Select_Reactor_Base.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Select_Reactor_Base.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Select_Reactor_T.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Select_Reactor_T.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Semaphore.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Semaphore.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Service_Config.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Service_Config.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Service_Gestalt.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Service_Gestalt.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Service_Object.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Service_Object.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Service_Repository.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Service_Repository.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Service_Types.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Service_Types.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Shared_Memory_MM.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Shared_Memory_MM.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Shared_Memory_SV.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Shared_Memory_SV.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Shared_Object.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Shared_Object.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Sig_Handler.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Sig_Handler.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Signal.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Signal.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Singleton.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Singleton.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y SOCK.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\SOCK.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y SOCK_Acceptor.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\SOCK_Acceptor.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y SOCK_CODgram.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\SOCK_CODgram.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y SOCK_Connector.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\SOCK_Connector.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y SOCK_Dgram.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\SOCK_Dgram.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y SOCK_Dgram_Bcast.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\SOCK_Dgram_Bcast.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y SOCK_Dgram_Mcast.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\SOCK_Dgram_Mcast.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y SOCK_IO.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\SOCK_IO.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y SOCK_Netlink.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\SOCK_Netlink.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y SOCK_SEQPACK_Acceptor.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\SOCK_SEQPACK_Acceptor.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y SOCK_SEQPACK_Association.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\SOCK_SEQPACK_Association.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y SOCK_SEQPACK_Connector.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\SOCK_SEQPACK_Connector.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y SOCK_Stream.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\SOCK_Stream.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y SPIPE.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\SPIPE.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y SPIPE_Addr.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\SPIPE_Addr.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y SPIPE_Connector.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\SPIPE_Connector.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y SPIPE_Stream.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\SPIPE_Stream.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y SString.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\SString.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Stats.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Stats.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Strategies_T.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Strategies_T.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Stream.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Stream.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y String_Base.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\String_Base.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y SV_Message.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\SV_Message.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y SV_Message_Queue.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\SV_Message_Queue.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y SV_Semaphore_Complex.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\SV_Semaphore_Complex.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y SV_Semaphore_Simple.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\SV_Semaphore_Simple.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y SV_Shared_Memory.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\SV_Shared_Memory.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Task.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Task.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Task_Ex_T.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Task_Ex_T.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Task_T.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Task_T.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Thread.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Thread.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Thread_Adapter.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Thread_Adapter.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Thread_Control.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Thread_Control.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Thread_Manager.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Thread_Manager.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Thread_Mutex.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Thread_Mutex.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Thread_Semaphore.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Thread_Semaphore.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Time_Value.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Time_Value.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Timeprobe.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Timeprobe.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Timer_Queue_Adapters.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Timer_Queue_Adapters.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Timer_Queue_T.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Timer_Queue_T.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y TLI.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\TLI.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y TLI_Connector.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\TLI_Connector.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y TLI_Stream.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\TLI_Stream.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Token.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Token.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Token_Collection.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Token_Collection.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Token_Manager.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Token_Manager.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Token_Request_Reply.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Token_Request_Reply.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y TP_Reactor.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\TP_Reactor.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y TSS_T.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\TSS_T.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Typed_SV_Message.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Typed_SV_Message.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Typed_SV_Message_Queue.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Typed_SV_Message_Queue.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Unbounded_Queue.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Unbounded_Queue.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Unbounded_Set.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Unbounded_Set.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Unbounded_Set_Ex.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Unbounded_Set_Ex.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y UNIX_Addr.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\UNIX_Addr.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y UPIPE_Acceptor.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\UPIPE_Acceptor.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y UPIPE_Connector.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\UPIPE_Connector.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y UPIPE_Stream.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\UPIPE_Stream.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y UTF16_Encoding_Converter.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\UTF16_Encoding_Converter.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y UUID.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\UUID.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y Vector_T.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\Vector_T.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y WFMO_Reactor.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\WFMO_Reactor.inl 1> NUL + -@if not exist $(INSTALL_DIR)\include\$(INCDIR_NAME)\. mkdir $(INSTALL_DIR)\include\$(INCDIR_NAME)\. + -© /Y XTI_ATM_Mcast.inl $(INSTALL_DIR)\include\$(INCDIR_NAME)\XTI_ATM_Mcast.inl 1> NUL + +realclean: + @-rem + diff --git a/dep/ACE_wrappers/ace/ACE.cpp b/dep/ACE_wrappers/ace/ACE.cpp new file mode 100644 index 00000000000..4980b2d7344 --- /dev/null +++ b/dep/ACE_wrappers/ace/ACE.cpp @@ -0,0 +1,3444 @@ +// $Id: ACE.cpp 82581 2008-08-11 08:58:24Z johnnyw $ + +#include "ace/ACE.h" + +#include "ace/Basic_Types.h" +#include "ace/Handle_Set.h" +#include "ace/Auto_Ptr.h" +#include "ace/SString.h" +#include "ace/Version.h" +#include "ace/Message_Block.h" +#include "ace/Log_Msg.h" +#include "ace/OS_NS_sys_select.h" +#include "ace/OS_NS_string.h" +#include "ace/OS_NS_strings.h" +#include "ace/OS_NS_signal.h" +#include "ace/OS_NS_stdio.h" +#include "ace/OS_NS_sys_resource.h" +#include "ace/OS_NS_sys_wait.h" +#include "ace/OS_NS_sys_time.h" +#include "ace/OS_NS_time.h" +#include "ace/OS_NS_sys_uio.h" +#include "ace/OS_NS_sys_stat.h" +#include "ace/OS_NS_ctype.h" +#include "ace/OS_NS_fcntl.h" +#include "ace/OS_TLI.h" +#include "ace/Truncate.h" + +#if defined (ACE_VXWORKS) && (ACE_VXWORKS < 0x620) +extern "C" int maxFiles; +#endif /* ACE_VXWORKS */ + +#if !defined (__ACE_INLINE__) +#include "ace/ACE.inl" +#endif /* __ACE_INLINE__ */ + +#if defined (ACE_HAS_POLL) && defined (ACE_HAS_LIMITED_SELECT) +# include "ace/OS_NS_poll.h" +#endif /* ACE_HAS_POLL && ACE_HAS_LIMITED_SELECT */ + + +ACE_RCSID (ace, + ACE, + "$Id: ACE.cpp 82581 2008-08-11 08:58:24Z johnnyw $") + + +// Open versioned namespace, if enabled by the user. + ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +namespace ACE +{ + // private: + // Used internally so not exported. + + // Size of allocation granularity. + size_t allocation_granularity_ = 0; + + // Size of a VM page. + size_t pagesize_ = 0; + + // Are we debugging ACE? + // Keeps track of whether we're in some global debug mode. + char debug_; +} + + +int +ACE::out_of_handles (int error) +{ + // EMFILE is common to all platforms. + if (error == EMFILE || +#if defined (ACE_WIN32) + // On Win32, we need to check for ENOBUFS also. + error == ENOBUFS || +#elif defined (HPUX) + // On HPUX, we need to check for EADDRNOTAVAIL also. + error == EADDRNOTAVAIL || +#elif defined (linux) + // On linux, we need to check for ENOENT also. + error == ENOENT || + // For RedHat5.2, need to check for EINVAL too. + error == EINVAL || + // Without threads check for EOPNOTSUPP + error == EOPNOTSUPP || +#elif defined (sun) + // On sun, we need to check for ENOSR also. + error == ENOSR || + // Without threads check for ENOTSUP + error == ENOTSUP || +#elif defined (__FreeBSD__) + // On FreeBSD we need to check for EOPNOTSUPP (LinuxThreads) or + // ENOSYS (libc_r threads) also. + error == EOPNOTSUPP || + error == ENOSYS || +#elif defined (__OpenBSD__) + // OpenBSD appears to return EBADF. + error == EBADF || +#elif defined (__sgi) // irix + error == ENOTSUP || +#elif defined (DIGITAL_UNIX) // osf1 + error == ENOTSUP || +#endif /* ACE_WIN32 */ + error == ENFILE) + return 1; + else + return 0; +} + +u_int +ACE::major_version (void) +{ + return ACE_MAJOR_VERSION; +} + +u_int +ACE::minor_version (void) +{ + return ACE_MINOR_VERSION; +} + +u_int +ACE::beta_version (void) +{ + return ACE_BETA_VERSION; +} + +const ACE_TCHAR * +ACE::compiler_name (void) +{ +#ifdef ACE_CC_NAME + return ACE_CC_NAME; +#else + return ACE_TEXT (""); +#endif +} + +u_int +ACE::compiler_major_version (void) +{ +#ifdef ACE_CC_MAJOR_VERSION + return ACE_CC_MAJOR_VERSION; +#else + return 0; +#endif +} + +u_int +ACE::compiler_minor_version (void) +{ +#ifdef ACE_CC_MINOR_VERSION + return ACE_CC_MINOR_VERSION; +#else + return 0; +#endif +} + +u_int +ACE::compiler_beta_version (void) +{ +#ifdef ACE_CC_BETA_VERSION + return ACE_CC_BETA_VERSION; +#else + return 0; +#endif +} + +bool +ACE::debug (void) +{ + static const char* debug = ACE_OS::getenv ("ACE_DEBUG"); + return (ACE::debug_ != 0) ? ACE::debug_ : (debug != 0 ? (*debug != '0'): false); +} + +void +ACE::debug (bool onoff) +{ + ACE::debug_ = onoff; +} + +int +ACE::select (int width, + ACE_Handle_Set *readfds, + ACE_Handle_Set *writefds, + ACE_Handle_Set *exceptfds, + const ACE_Time_Value *timeout) +{ + int result = ACE_OS::select (width, + readfds ? readfds->fdset () : 0, + writefds ? writefds->fdset () : 0, + exceptfds ? exceptfds->fdset () : 0, + timeout); + if (result > 0) + { +# if !defined (ACE_WIN32) + // This isn't needed for Windows... it's a no-op anyway. + if (readfds) + readfds->sync ((ACE_HANDLE) width); + if (writefds) + writefds->sync ((ACE_HANDLE) width); + if (exceptfds) + exceptfds->sync ((ACE_HANDLE) width); +#endif /* ACE_WIN32 */ + } + return result; +} + +int +ACE::select (int width, + ACE_Handle_Set &readfds, + const ACE_Time_Value *timeout) +{ + int result = ACE_OS::select (width, + readfds.fdset (), + 0, + 0, + timeout); + +#if !defined (ACE_WIN32) + if (result > 0) + readfds.sync ((ACE_HANDLE) width); +#endif /* ACE_WIN32 */ + return result; +} + +int +ACE::terminate_process (pid_t pid) +{ +#if defined (ACE_HAS_PHARLAP) + ACE_UNUSED_ARG (pid); + ACE_NOTSUP_RETURN (-1); +#elif defined (ACE_WIN32) + // Create a handle for the given process id. + ACE_HANDLE process_handle = + ::OpenProcess (PROCESS_TERMINATE, + FALSE, // New handle is not inheritable. + pid); + + if (process_handle == ACE_INVALID_HANDLE + || process_handle == 0) + return -1; + else + { + // Kill the process associated with process_handle. + BOOL terminate_result = + ::TerminateProcess (process_handle, 0); + // Free up the kernel resources. + ACE_OS::close (process_handle); + return terminate_result ? 0 : -1; + } +#else + return ACE_OS::kill (pid, 9); +#endif /* ACE_HAS_PHARLAP */ +} + +int +ACE::process_active (pid_t pid) +{ +#if !defined(ACE_WIN32) + if (ACE_OS::kill (pid, 0) == 0) + return 1; + else if (errno == ESRCH) + return 0; + else + return -1; +#else + // Create a handle for the given process id. + ACE_HANDLE process_handle = + ::OpenProcess (PROCESS_QUERY_INFORMATION, FALSE, pid); + if (process_handle == ACE_INVALID_HANDLE || process_handle == 0) + return 0; + else + { + DWORD status; + int result = 1; + if (::GetExitCodeProcess (process_handle, + &status) == 0 + || status != STILL_ACTIVE) + result = 0; + + ::CloseHandle (process_handle); + return result; + } +#endif /* !ACE_WIN32 */ +} + +const ACE_TCHAR * +ACE::execname (const ACE_TCHAR *old_name) +{ +#if defined (ACE_WIN32) + const ACE_TCHAR *suffix = ACE_OS::strrchr (old_name, ACE_TEXT ('.')); + if (suffix == 0 || ACE_OS::strcasecmp (suffix, ACE_TEXT (".exe")) != 0) + { + ACE_TCHAR *new_name = 0; + + size_t size = + ACE_OS::strlen (old_name) + + ACE_OS::strlen (ACE_TEXT (".exe")) + + 1; + + ACE_NEW_RETURN (new_name, + ACE_TCHAR[size], + 0); + ACE_TCHAR *end = new_name; + + end = ACE_OS::strecpy (new_name, old_name); + + // Concatenate the .exe suffix onto the end of the executable. + // end points _after_ the terminating nul. + ACE_OS::strcpy (end - 1, ACE_TEXT (".exe")); + + return new_name; + } +#endif /* ACE_WIN32 */ + return old_name; +} + +u_long +ACE::hash_pjw (const char *str, size_t len) +{ + u_long hash = 0; + + for (size_t i = 0; i < len; i++) + { + const char temp = str[i]; + hash = (hash << 4) + (temp * 13); + + u_long g = hash & 0xf0000000; + + if (g) + { + hash ^= (g >> 24); + hash ^= g; + } + } + + return hash; +} + +u_long +ACE::hash_pjw (const char *str) +{ + return ACE::hash_pjw (str, ACE_OS::strlen (str)); +} + +#if defined (ACE_HAS_WCHAR) +u_long +ACE::hash_pjw (const wchar_t *str, size_t len) +{ + u_long hash = 0; + + for (size_t i = 0; i < len; i++) + { + // @@ UNICODE: Does this function do the correct thing with wchar's? + + const wchar_t temp = str[i]; + hash = (hash << 4) + (temp * 13); + + u_long g = hash & 0xf0000000; + + if (g) + { + hash ^= (g >> 24); + hash ^= g; + } + } + + return hash; +} + +u_long +ACE::hash_pjw (const wchar_t *str) +{ + return ACE::hash_pjw (str, ACE_OS::strlen (str)); +} +#endif /* ACE_HAS_WCHAR */ + +#if !defined (ACE_HAS_WINCE) +ACE_TCHAR * +ACE::strenvdup (const ACE_TCHAR *str) +{ + ACE_TRACE ("ACE::strenvdup"); + + return ACE_OS::strenvdup (str); +} +#endif /* ACE_HAS_WINCE */ + +/* + +Examples: + +Source NT UNIX +================================================================== +netsvc netsvc.dll libnetsvc.so +(PATH will be (LD_LIBRARY_PATH +evaluated) evaluated) + +libnetsvc.dll libnetsvc.dll libnetsvc.dll + warning +netsvc.so netsvc.so + warning libnetsvc.so + +..\../libs/netsvc ..\..\libs\netsvc.dll ../../libs/netsvc.so +(absolute path used) (absolute path used) + +*/ + +const ACE_TCHAR * +ACE::basename (const ACE_TCHAR *pathname, ACE_TCHAR delim) +{ + ACE_TRACE ("ACE::basename"); + const ACE_TCHAR *temp = ACE_OS::strrchr (pathname, delim); + + if (temp == 0) + return pathname; + else + return temp + 1; +} + +const ACE_TCHAR * +ACE::dirname (const ACE_TCHAR *pathname, ACE_TCHAR delim) +{ + ACE_TRACE ("ACE::dirname"); + static ACE_TCHAR return_dirname[MAXPATHLEN + 1]; + + const ACE_TCHAR *temp = ACE_OS::strrchr (pathname, delim); + + if (temp == 0) + { + return_dirname[0] = '.'; + return_dirname[1] = '\0'; + + return return_dirname; + } + else + { + // When the len is truncated, there are problems! This should + // not happen in normal circomstances + size_t len = temp - pathname + 1; + if (len > (sizeof return_dirname / sizeof (ACE_TCHAR))) + len = sizeof return_dirname / sizeof (ACE_TCHAR); + + ACE_OS::strsncpy (return_dirname, + pathname, + len); + return return_dirname; + } +} + +ssize_t +ACE::recv (ACE_HANDLE handle, + void *buf, + size_t len, + int flags, + const ACE_Time_Value *timeout) +{ + if (timeout == 0) + return ACE_OS::recv (handle, (char *) buf, len, flags); + else + { + int val = 0; + if (ACE::enter_recv_timedwait (handle, timeout, val) ==-1) + return -1; + else + { + ssize_t bytes_transferred = + ACE_OS::recv (handle, (char *) buf, len, flags); + ACE::restore_non_blocking_mode (handle, val); + return bytes_transferred; + } + } +} + +#if defined (ACE_HAS_TLI) + +ssize_t +ACE::t_rcv (ACE_HANDLE handle, + void *buf, + size_t len, + int *flags, + const ACE_Time_Value *timeout) +{ + if (timeout == 0) + return ACE_OS::t_rcv (handle, (char *) buf, len, flags); + else + { + int val = 0; + if (ACE::enter_recv_timedwait (handle, timeout, val) ==-1) + return -1; + else + { + ssize_t bytes_transferred = + ACE_OS::t_rcv (handle, (char *) buf, len, flags); + ACE::restore_non_blocking_mode (handle, val); + return bytes_transferred; + } + } +} + +#endif /* ACE_HAS_TLI */ + +ssize_t +ACE::recv (ACE_HANDLE handle, + void *buf, + size_t n, + const ACE_Time_Value *timeout) +{ + if (timeout == 0) + return ACE::recv_i (handle, buf, n); + else + { + int val = 0; + if (ACE::enter_recv_timedwait (handle, timeout, val) == -1) + return -1; + else + { + ssize_t bytes_transferred = ACE::recv_i (handle, buf, n); + ACE::restore_non_blocking_mode (handle, val); + return bytes_transferred; + } + } +} + +ssize_t +ACE::recvmsg (ACE_HANDLE handle, + struct msghdr *msg, + int flags, + const ACE_Time_Value *timeout) +{ + if (timeout == 0) + return ACE_OS::recvmsg (handle, msg, flags); + else + { + int val = 0; + if (ACE::enter_recv_timedwait (handle, timeout, val) == -1) + return -1; + else + { + ssize_t bytes_transferred = ACE_OS::recvmsg (handle, msg, flags); + ACE::restore_non_blocking_mode (handle, val); + return bytes_transferred; + } + } +} + +ssize_t +ACE::recvfrom (ACE_HANDLE handle, + char *buf, + int len, + int flags, + struct sockaddr *addr, + int *addrlen, + const ACE_Time_Value *timeout) +{ + if (timeout == 0) + return ACE_OS::recvfrom (handle, buf, len, flags, addr, addrlen); + else + { + int val = 0; + if (ACE::enter_recv_timedwait (handle, timeout, val) == -1) + return -1; + else + { + ssize_t bytes_transferred = + ACE_OS::recvfrom (handle, buf, len, flags, addr, addrlen); + ACE::restore_non_blocking_mode (handle, val); + return bytes_transferred; + } + } +} + +ssize_t +ACE::recv_n_i (ACE_HANDLE handle, + void *buf, + size_t len, + int flags, + size_t *bt) +{ + size_t temp; + size_t &bytes_transferred = bt == 0 ? temp : *bt; + ssize_t n; + + for (bytes_transferred = 0; + bytes_transferred < len; + bytes_transferred += n) + { + // Try to transfer as much of the remaining data as possible. + n = ACE_OS::recv (handle, + static_cast (buf) + bytes_transferred, + len - bytes_transferred, + flags); + // Check EOF. + if (n == 0) + return 0; + + // Check for other errors. + if (n == -1) + { + // Check for possible blocking. + if (errno == EWOULDBLOCK) + { + // Wait for the blocking to subside. + int const result = ACE::handle_read_ready (handle, 0); + + // Did select() succeed? + if (result != -1) + { + // Blocking subsided. Continue data transfer. + n = 0; + continue; + } + } + + // Other data transfer or select() failures. + return -1; + } + } + + return static_cast (bytes_transferred); +} + +ssize_t +ACE::recv_n_i (ACE_HANDLE handle, + void *buf, + size_t len, + int flags, + const ACE_Time_Value *timeout, + size_t *bt) +{ + size_t temp; + size_t &bytes_transferred = bt == 0 ? temp : *bt; + ssize_t n; + ssize_t result = 0; + int error = 0; + + int val = 0; + ACE::record_and_set_non_blocking_mode (handle, val); + + for (bytes_transferred = 0; + bytes_transferred < len; + bytes_transferred += n) + { + // Try to transfer as much of the remaining data as possible. + // Since the socket is in non-blocking mode, this call will not + // block. + n = ACE_OS::recv (handle, + static_cast (buf) + bytes_transferred, + len - bytes_transferred, + flags); + + // Check for errors. + if (n == 0 || + n == -1) + { + // Check for possible blocking. + if (n == -1 && + errno == EWOULDBLOCK) + { + // Wait upto for the blocking to subside. + int rtn = ACE::handle_read_ready (handle, + timeout); + + // Did select() succeed? + if (rtn != -1) + { + // Blocking subsided in period. Continue + // data transfer. + n = 0; + continue; + } + } + + // Wait in select() timed out or other data transfer or + // select() failures. + error = 1; + result = n; + break; + } + } + + ACE::restore_non_blocking_mode (handle, val); + + if (error) + return result; + else + return static_cast (bytes_transferred); +} + +#if defined (ACE_HAS_TLI) + +ssize_t +ACE::t_rcv_n_i (ACE_HANDLE handle, + void *buf, + size_t len, + int *flags, + size_t *bt) +{ + size_t temp; + size_t &bytes_transferred = bt == 0 ? temp : *bt; + ssize_t n; + + for (bytes_transferred = 0; + bytes_transferred < len; + bytes_transferred += n) + { + // Try to transfer as much of the remaining data as possible. + n = ACE_OS::t_rcv (handle, + (char *) buf + bytes_transferred, + len - bytes_transferred, + flags); + // Check EOF. + if (n == 0) + return 0; + + // Check for other errors. + if (n == -1) + { + // Check for possible blocking. + if (errno == EWOULDBLOCK) + { + // Wait for the blocking to subside. + int result = ACE::handle_read_ready (handle, + 0); + + // Did select() succeed? + if (result != -1) + { + // Blocking subsided. Continue data transfer. + n = 0; + continue; + } + } + + // Other data transfer or select() failures. + return -1; + } + } + + return bytes_transferred; +} + +ssize_t +ACE::t_rcv_n_i (ACE_HANDLE handle, + void *buf, + size_t len, + int *flags, + const ACE_Time_Value *timeout, + size_t *bt) +{ + size_t temp; + size_t &bytes_transferred = bt == 0 ? temp : *bt; + ssize_t n; + ssize_t result = 0; + int error = 0; + + int val = 0; + ACE::record_and_set_non_blocking_mode (handle, val); + + for (bytes_transferred = 0; + bytes_transferred < len; + bytes_transferred += n) + { + // Try to transfer as much of the remaining data as possible. + // Since the socket is in non-blocking mode, this call will not + // block. + n = ACE_OS::t_rcv (handle, + (char *) buf + bytes_transferred, + len - bytes_transferred, + flags); + + // Check for errors. + if (n == 0 || + n == -1) + { + // Check for possible blocking. + if (n == -1 && + errno == EWOULDBLOCK) + { + // Wait upto for the blocking to subside. + int rtn = ACE::handle_read_ready (handle, + timeout); + + // Did select() succeed? + if (rtn != -1) + { + // Blocking subsided in period. Continue + // data transfer. + n = 0; + continue; + } + } + + // Wait in select() timed out or other data transfer or + // select() failures. + error = 1; + result = n; + break; + } + } + + ACE::restore_non_blocking_mode (handle, val); + + if (error) + return result; + else + return bytes_transferred; +} + +#endif /* ACE_HAS_TLI */ + +ssize_t +ACE::recv_n_i (ACE_HANDLE handle, + void *buf, + size_t len, + size_t *bt) +{ + size_t temp; + size_t &bytes_transferred = bt == 0 ? temp : *bt; + ssize_t n; + + for (bytes_transferred = 0; + bytes_transferred < len; + bytes_transferred += n) + { + // Try to transfer as much of the remaining data as possible. + n = ACE::recv_i (handle, + static_cast (buf) + bytes_transferred, + len - bytes_transferred); + // Check EOF. + if (n == 0) + { + return 0; + } + // Check for other errors. + if (n == -1) + { + // Check for possible blocking. + if (errno == EWOULDBLOCK) + { + // Wait for the blocking to subside. + int result = ACE::handle_read_ready (handle, + 0); + + // Did select() succeed? + if (result != -1) + { + // Blocking subsided. Continue data transfer. + n = 0; + continue; + } + } + + // Other data transfer or select() failures. + return -1; + } + } + + return static_cast (bytes_transferred); +} + +ssize_t +ACE::recv_n_i (ACE_HANDLE handle, + void *buf, + size_t len, + const ACE_Time_Value *timeout, + size_t *bt) +{ + size_t temp; + size_t &bytes_transferred = bt == 0 ? temp : *bt; + ssize_t n; + ssize_t result = 0; + int error = 0; + + int val = 0; + ACE::record_and_set_non_blocking_mode (handle, val); + + for (bytes_transferred = 0; + bytes_transferred < len; + bytes_transferred += n) + { + // Try to transfer as much of the remaining data as possible. + // Since the socket is in non-blocking mode, this call will not + // block. + n = ACE::recv_i (handle, + static_cast (buf) + bytes_transferred, + len - bytes_transferred); + + // Check for errors. + if (n == 0 || + n == -1) + { + // Check for possible blocking. + if (n == -1 && + errno == EWOULDBLOCK) + { + // Wait upto for the blocking to subside. + int rtn = ACE::handle_read_ready (handle, + timeout); + + // Did select() succeed? + if (rtn != -1) + { + // Blocking subsided in period. Continue + // data transfer. + n = 0; + continue; + } + } + + // Wait in select() timed out or other data transfer or + // select() failures. + error = 1; + result = n; + break; + } + } + + ACE::restore_non_blocking_mode (handle, val); + + if (error) + return result; + else + return static_cast (bytes_transferred); +} + +// This is basically an interface to ACE_OS::readv, that doesn't use +// the struct iovec explicitly. The ... can be passed as an arbitrary +// number of (char *ptr, int len) tuples. However, the count N is the +// *total* number of trailing arguments, *not* a couple of the number +// of tuple pairs! + +ssize_t +ACE::recv (ACE_HANDLE handle, size_t n, ...) +{ + va_list argp; + int total_tuples = static_cast (n / 2); + iovec *iovp; +#if defined (ACE_HAS_ALLOCA) + iovp = (iovec *) alloca (total_tuples * sizeof (iovec)); +#else + ACE_NEW_RETURN (iovp, + iovec[total_tuples], + -1); +#endif /* !defined (ACE_HAS_ALLOCA) */ + + va_start (argp, n); + + for (int i = 0; i < total_tuples; i++) + { + iovp[i].iov_base = va_arg (argp, char *); + iovp[i].iov_len = va_arg (argp, int); + } + + ssize_t result = ACE_OS::recvv (handle, iovp, total_tuples); +#if !defined (ACE_HAS_ALLOCA) + delete [] iovp; +#endif /* !defined (ACE_HAS_ALLOCA) */ + va_end (argp); + return result; +} + +ssize_t +ACE::recvv (ACE_HANDLE handle, + iovec *iov, + int iovcnt, + const ACE_Time_Value *timeout) +{ + if (timeout == 0) + return ACE_OS::recvv (handle, iov, iovcnt); + else + { + int val = 0; + if (ACE::enter_recv_timedwait (handle, timeout, val) == -1) + return -1; + else + { + ssize_t bytes_transferred = ACE_OS::recvv (handle, iov, iovcnt); + ACE::restore_non_blocking_mode (handle, val); + return bytes_transferred; + } + } +} + +ssize_t +ACE::recvv_n_i (ACE_HANDLE handle, + iovec *iov, + int iovcnt, + size_t *bt) +{ + size_t temp; + size_t &bytes_transferred = bt == 0 ? temp : *bt; + bytes_transferred = 0; + + for (int s = 0; + s < iovcnt; + ) + { + // Try to transfer as much of the remaining data as possible. + ssize_t n = ACE_OS::recvv (handle, + iov + s, + iovcnt - s); + // Check EOF. + if (n == 0) + return 0; + + // Check for other errors. + if (n == -1) + { + // Check for possible blocking. + if (errno == EWOULDBLOCK) + { + // Wait for the blocking to subside. + int result = ACE::handle_read_ready (handle, + 0); + + // Did select() succeed? + if (result != -1) + { + // Blocking subsided. Continue data transfer. + n = 0; + continue; + } + } + + // Other data transfer or select() failures. + return -1; + } + + for (bytes_transferred += n; + s < iovcnt + && n >= static_cast (iov[s].iov_len); + s++) + n -= iov[s].iov_len; + + if (n != 0) + { + char *base = static_cast (iov[s].iov_base); + iov[s].iov_base = base + n; + iov[s].iov_len = iov[s].iov_len - n; + } + } + + return ACE_Utils::truncate_cast (bytes_transferred); +} + +ssize_t +ACE::recvv_n_i (ACE_HANDLE handle, + iovec *iov, + int iovcnt, + const ACE_Time_Value *timeout, + size_t *bt) +{ + size_t temp; + size_t &bytes_transferred = bt == 0 ? temp : *bt; + bytes_transferred = 0; + ssize_t result = 0; + int error = 0; + + int val = 0; + ACE::record_and_set_non_blocking_mode (handle, val); + + for (int s = 0; + s < iovcnt; + ) + { + // Try to transfer as much of the remaining data as possible. + // Since the socket is in non-blocking mode, this call will not + // block. + ssize_t n = ACE_OS::recvv (handle, + iov + s, + iovcnt - s); + + // Check for errors. + if (n == 0 || + n == -1) + { + // Check for possible blocking. + if (n == -1 && + errno == EWOULDBLOCK) + { + // Wait upto for the blocking to subside. + int rtn = ACE::handle_read_ready (handle, + timeout); + + // Did select() succeed? + if (rtn != -1) + { + // Blocking subsided in period. Continue + // data transfer. + n = 0; + continue; + } + } + + // Wait in select() timed out or other data transfer or + // select() failures. + error = 1; + result = n; + break; + } + + for (bytes_transferred += n; + s < iovcnt + && n >= static_cast (iov[s].iov_len); + s++) + n -= iov[s].iov_len; + + if (n != 0) + { + char *base = reinterpret_cast (iov[s].iov_base); + iov[s].iov_base = base + n; + iov[s].iov_len = iov[s].iov_len - n; + } + } + + ACE::restore_non_blocking_mode (handle, val); + + if (error) + { + return result; + } + else + { + return ACE_Utils::truncate_cast (bytes_transferred); + } +} + +ssize_t +ACE::recv_n (ACE_HANDLE handle, + ACE_Message_Block *message_block, + const ACE_Time_Value *timeout, + size_t *bt) +{ + size_t temp; + size_t &bytes_transferred = bt == 0 ? temp : *bt; + bytes_transferred = 0; + + iovec iov[ACE_IOV_MAX]; + int iovcnt = 0; + + while (message_block != 0) + { + // Our current message block chain. + const ACE_Message_Block *current_message_block = message_block; + + while (current_message_block != 0) + { + size_t current_message_block_length = + current_message_block->length (); + char *this_rd_ptr = current_message_block->rd_ptr (); + + // Check if this block has any space for incoming data. + while (current_message_block_length > 0) + { + u_long const this_chunk_length = + ACE_Utils::truncate_cast ( + current_message_block_length); + + // Collect the data in the iovec. + iov[iovcnt].iov_base = this_rd_ptr; + iov[iovcnt].iov_len = this_chunk_length; + current_message_block_length -= this_chunk_length; + this_rd_ptr += this_chunk_length; + + // Increment iovec counter. + ++iovcnt; + + // The buffer is full make a OS call. @@ TODO find a way to + // find ACE_IOV_MAX for platforms that do not define it rather + // than simply setting ACE_IOV_MAX to some arbitrary value such + // as 16. + if (iovcnt == ACE_IOV_MAX) + { + size_t current_transfer = 0; + + ssize_t const result = ACE::recvv_n (handle, + iov, + iovcnt, + timeout, + ¤t_transfer); + + // Add to total bytes transferred. + bytes_transferred += current_transfer; + + // Errors. + if (result == -1 || result == 0) + return result; + + // Reset iovec counter. + iovcnt = 0; + } + } + + // Select the next message block in the chain. + current_message_block = current_message_block->cont (); + } + + // Selection of the next message block chain. + message_block = message_block->next (); + } + + // Check for remaining buffers to be sent. This will happen when + // ACE_IOV_MAX is not a multiple of the number of message blocks. + if (iovcnt != 0) + { + size_t current_transfer = 0; + + ssize_t const result = ACE::recvv_n (handle, + iov, + iovcnt, + timeout, + ¤t_transfer); + + // Add to total bytes transferred. + bytes_transferred += current_transfer; + + // Errors. + if (result == -1 || result == 0) + { + return result; + } + } + + // Return total bytes transferred. + return ACE_Utils::truncate_cast (bytes_transferred); +} + +ssize_t +ACE::send (ACE_HANDLE handle, + const void *buf, + size_t n, + int flags, + const ACE_Time_Value *timeout) +{ + if (timeout == 0) + return ACE_OS::send (handle, (const char *) buf, n, flags); + else + { + int val = 0; + if (ACE::enter_send_timedwait (handle, timeout, val) == -1) + return -1; + else + { + ssize_t bytes_transferred = ACE_OS::send (handle, (const char *) buf, n, flags); + ACE::restore_non_blocking_mode (handle, val); + return bytes_transferred; + } + } +} + +#if defined (ACE_HAS_TLI) + +ssize_t +ACE::t_snd (ACE_HANDLE handle, + const void *buf, + size_t n, + int flags, + const ACE_Time_Value *timeout) +{ + if (timeout == 0) + return ACE_OS::t_snd (handle, (const char *) buf, n, flags); + else + { + int val = 0; + if (ACE::enter_send_timedwait (handle, timeout, val) == -1) + return -1; + else + { + ssize_t bytes_transferred = ACE_OS::t_snd (handle, (const char *) buf, n, flags); + ACE::restore_non_blocking_mode (handle, val); + return bytes_transferred; + } + } +} + +#endif /* ACE_HAS_TLI */ + +ssize_t +ACE::send (ACE_HANDLE handle, + const void *buf, + size_t n, + const ACE_Time_Value *timeout) +{ + if (timeout == 0) + return ACE::send_i (handle, buf, n); + else + { + int val = 0; + if (ACE::enter_send_timedwait (handle, timeout, val) == -1) + return -1; + else + { + ssize_t bytes_transferred = ACE::send_i (handle, buf, n); + ACE::restore_non_blocking_mode (handle, val); + return bytes_transferred; + } + } +} + +ssize_t +ACE::sendmsg (ACE_HANDLE handle, + const struct msghdr *msg, + int flags, + const ACE_Time_Value *timeout) +{ + if (timeout == 0) + return ACE_OS::sendmsg (handle, msg, flags); + else + { + int val = 0; + if (ACE::enter_send_timedwait (handle, timeout, val) == -1) + return -1; + else + { + ssize_t bytes_transferred = ACE_OS::sendmsg (handle, msg, flags); + ACE::restore_non_blocking_mode (handle, val); + return bytes_transferred; + } + } +} + +ssize_t +ACE::sendto (ACE_HANDLE handle, + const char *buf, + int len, + int flags, + const struct sockaddr *addr, + int addrlen, + const ACE_Time_Value *timeout) +{ + if (timeout == 0) + return ACE_OS::sendto (handle, buf, len, flags, addr, addrlen); + else + { + int val = 0; + if (ACE::enter_send_timedwait (handle, timeout, val) == -1) + return -1; + else + { + ssize_t bytes_transferred = + ACE_OS::sendto (handle, buf, len, flags, addr, addrlen); + ACE::restore_non_blocking_mode (handle, val); + return bytes_transferred; + } + } +} + +ssize_t +ACE::send_n_i (ACE_HANDLE handle, + const void *buf, + size_t len, + int flags, + size_t *bt) +{ + size_t temp; + size_t &bytes_transferred = bt == 0 ? temp : *bt; + ssize_t n; + + for (bytes_transferred = 0; + bytes_transferred < len; + bytes_transferred += n) + { + // Try to transfer as much of the remaining data as possible. + n = ACE_OS::send (handle, + (char *) buf + bytes_transferred, + len - bytes_transferred, + flags); + // Check EOF. + if (n == 0) + return 0; + + // Check for other errors. + if (n == -1) + { + // Check for possible blocking. +#if defined (ACE_WIN32) + if (errno == EWOULDBLOCK) // If enobufs no need to loop +#else + if (errno == EWOULDBLOCK || errno == ENOBUFS) +#endif /* ACE_WIN32 */ + { + // Wait for the blocking to subside. + int result = ACE::handle_write_ready (handle, + 0); + + // Did select() succeed? + if (result != -1) + { + // Blocking subsided. Continue data transfer. + n = 0; + continue; + } + } + + // Other data transfer or select() failures. + return -1; + } + } + + return ACE_Utils::truncate_cast (bytes_transferred); +} + +ssize_t +ACE::send_n_i (ACE_HANDLE handle, + const void *buf, + size_t len, + int flags, + const ACE_Time_Value *timeout, + size_t *bt) +{ + size_t temp; + size_t &bytes_transferred = bt == 0 ? temp : *bt; + ssize_t n; + ssize_t result = 0; + int error = 0; + + int val = 0; + ACE::record_and_set_non_blocking_mode (handle, val); + + for (bytes_transferred = 0; + bytes_transferred < len; + bytes_transferred += n) + { + // Try to transfer as much of the remaining data as possible. + // Since the socket is in non-blocking mode, this call will not + // block. + n = ACE_OS::send (handle, + (char *) buf + bytes_transferred, + len - bytes_transferred, + flags); + + // Check for errors. + if (n == 0 || + n == -1) + { + // Check for possible blocking. + if (n == -1 && + (errno == EWOULDBLOCK || errno == ENOBUFS)) + { + // Wait upto for the blocking to subside. + int rtn = ACE::handle_write_ready (handle, + timeout); + + // Did select() succeed? + if (rtn != -1) + { + // Blocking subsided in period. Continue + // data transfer. + n = 0; + continue; + } + } + + // Wait in select() timed out or other data transfer or + // select() failures. + error = 1; + result = n; + break; + } + } + + ACE::restore_non_blocking_mode (handle, val); + + if (error) + { + return result; + } + else + { + return ACE_Utils::truncate_cast (bytes_transferred); + } +} + +#if defined (ACE_HAS_TLI) + +ssize_t +ACE::t_snd_n_i (ACE_HANDLE handle, + const void *buf, + size_t len, + int flags, + size_t *bt) +{ + size_t temp; + size_t &bytes_transferred = bt == 0 ? temp : *bt; + ssize_t n; + + for (bytes_transferred = 0; + bytes_transferred < len; + bytes_transferred += n) + { + // Try to transfer as much of the remaining data as possible. + n = ACE_OS::t_snd (handle, + (char *) buf + bytes_transferred, + len - bytes_transferred, + flags); + // Check EOF. + if (n == 0) + return 0; + + // Check for other errors. + if (n == -1) + { + // Check for possible blocking. + if (errno == EWOULDBLOCK || errno == ENOBUFS) + { + // Wait for the blocking to subside. + int result = ACE::handle_write_ready (handle, + 0); + + // Did select() succeed? + if (result != -1) + { + // Blocking subsided. Continue data transfer. + n = 0; + continue; + } + } + + // Other data transfer or select() failures. + return -1; + } + } + + return bytes_transferred; +} + +ssize_t +ACE::t_snd_n_i (ACE_HANDLE handle, + const void *buf, + size_t len, + int flags, + const ACE_Time_Value *timeout, + size_t *bt) +{ + size_t temp; + size_t &bytes_transferred = bt == 0 ? temp : *bt; + ssize_t n; + ssize_t result = 0; + int error = 0; + + int val = 0; + ACE::record_and_set_non_blocking_mode (handle, val); + + for (bytes_transferred = 0; + bytes_transferred < len; + bytes_transferred += n) + { + // Try to transfer as much of the remaining data as possible. + // Since the socket is in non-blocking mode, this call will not + // block. + n = ACE_OS::t_snd (handle, + (char *) buf + bytes_transferred, + len - bytes_transferred, + flags); + + // Check for errors. + if (n == 0 || + n == -1) + { + // Check for possible blocking. + if (n == -1 && + errno == EWOULDBLOCK || errno == ENOBUFS) + { + // Wait upto for the blocking to subside. + int rtn = ACE::handle_write_ready (handle, + timeout); + + // Did select() succeed? + if (rtn != -1) + { + // Blocking subsided in period. Continue + // data transfer. + n = 0; + continue; + } + } + + // Wait in select() timed out or other data transfer or + // select() failures. + error = 1; + result = n; + break; + } + } + + ACE::restore_non_blocking_mode (handle, val); + + if (error) + return result; + else + return bytes_transferred; +} + +#endif /* ACE_HAS_TLI */ + +ssize_t +ACE::send_n_i (ACE_HANDLE handle, + const void *buf, + size_t len, + size_t *bt) +{ + size_t temp; + size_t &bytes_transferred = bt == 0 ? temp : *bt; + ssize_t n; + + for (bytes_transferred = 0; + bytes_transferred < len; + bytes_transferred += n) + { + // Try to transfer as much of the remaining data as possible. + n = ACE::send_i (handle, + (char *) buf + bytes_transferred, + len - bytes_transferred); + // Check EOF. + if (n == 0) + { + return 0; + } + + // Check for other errors. + if (n == -1) + { + // Check for possible blocking. + if (errno == EWOULDBLOCK || errno == ENOBUFS) + { + // Wait for the blocking to subside. + int result = ACE::handle_write_ready (handle, + 0); + + // Did select() succeed? + if (result != -1) + { + // Blocking subsided. Continue data transfer. + n = 0; + continue; + } + } + + // Other data transfer or select() failures. + return -1; + } + } + + return ACE_Utils::truncate_cast (bytes_transferred); +} + +ssize_t +ACE::send_n_i (ACE_HANDLE handle, + const void *buf, + size_t len, + const ACE_Time_Value *timeout, + size_t *bt) +{ + size_t temp; + size_t &bytes_transferred = bt == 0 ? temp : *bt; + ssize_t n; + ssize_t result = 0; + int error = 0; + + int val = 0; + ACE::record_and_set_non_blocking_mode (handle, val); + + for (bytes_transferred = 0; + bytes_transferred < len; + bytes_transferred += n) + { + // Try to transfer as much of the remaining data as possible. + // Since the socket is in non-blocking mode, this call will not + // block. + n = ACE::send_i (handle, + (char *) buf + bytes_transferred, + len - bytes_transferred); + + // Check for errors. + if (n == 0 || + n == -1) + { + // Check for possible blocking. + if (n == -1 && + (errno == EWOULDBLOCK || errno == ENOBUFS)) + { + // Wait upto for the blocking to subside. + int rtn = ACE::handle_write_ready (handle, + timeout); + + // Did select() succeed? + if (rtn != -1) + { + // Blocking subsided in period. Continue + // data transfer. + n = 0; + continue; + } + } + + // Wait in select() timed out or other data transfer or + // select() failures. + error = 1; + result = n; + break; + } + } + + ACE::restore_non_blocking_mode (handle, val); + + if (error) + { + return result; + } + else + { + return ACE_Utils::truncate_cast (bytes_transferred); + } +} + +// Send N char *ptrs and int lengths. Note that the char *'s precede +// the ints (basically, an varargs version of writev). The count N is +// the *total* number of trailing arguments, *not* a couple of the +// number of tuple pairs! + +ssize_t +ACE::send (ACE_HANDLE handle, size_t n, ...) +{ + va_list argp; + int total_tuples = static_cast (n / 2); + iovec *iovp; +#if defined (ACE_HAS_ALLOCA) + iovp = (iovec *) alloca (total_tuples * sizeof (iovec)); +#else + ACE_NEW_RETURN (iovp, + iovec[total_tuples], + -1); +#endif /* !defined (ACE_HAS_ALLOCA) */ + + va_start (argp, n); + + for (int i = 0; i < total_tuples; i++) + { + iovp[i].iov_base = va_arg (argp, char *); + iovp[i].iov_len = va_arg (argp, int); + } + + ssize_t result = ACE_OS::sendv (handle, iovp, total_tuples); +#if !defined (ACE_HAS_ALLOCA) + delete [] iovp; +#endif /* !defined (ACE_HAS_ALLOCA) */ + va_end (argp); + return result; +} + +ssize_t +ACE::sendv (ACE_HANDLE handle, + const iovec *iov, + int iovcnt, + const ACE_Time_Value *timeout) +{ + if (timeout == 0) + return ACE_OS::sendv (handle, iov, iovcnt); + else + { + int val = 0; + if (ACE::enter_send_timedwait (handle, timeout, val) == -1) + return -1; + else + { + ssize_t bytes_transferred = ACE_OS::sendv (handle, iov, iovcnt); + ACE::restore_non_blocking_mode (handle, val); + return bytes_transferred; + } + } +} + +ssize_t +ACE::sendv_n_i (ACE_HANDLE handle, + const iovec *i, + int iovcnt, + size_t *bt) +{ + size_t temp; + size_t &bytes_transferred = bt == 0 ? temp : *bt; + bytes_transferred = 0; + + iovec *iov = const_cast (i); + + for (int s = 0; + s < iovcnt; + ) + { + // Try to transfer as much of the remaining data as possible. + ssize_t n = ACE_OS::sendv (handle, + iov + s, + iovcnt - s); + // Check EOF. + if (n == 0) + return 0; + + // Check for other errors. + if (n == -1) + { + // Check for possible blocking. + if (errno == EWOULDBLOCK || errno == ENOBUFS) + { + // Wait for the blocking to subside. + int result = ACE::handle_write_ready (handle, + 0); + + // Did select() succeed? + if (result != -1) + { + // Blocking subsided. Continue data transfer. + n = 0; + continue; + } + } + + // Other data transfer or select() failures. + return -1; + } + + for (bytes_transferred += n; + s < iovcnt + && n >= static_cast (iov[s].iov_len); + s++) + n -= iov[s].iov_len; + + if (n != 0) + { + char *base = reinterpret_cast (iov[s].iov_base); + iov[s].iov_base = base + n; + iov[s].iov_len = iov[s].iov_len - n; + } + } + + return ACE_Utils::truncate_cast (bytes_transferred); +} + +ssize_t +ACE::sendv_n_i (ACE_HANDLE handle, + const iovec *i, + int iovcnt, + const ACE_Time_Value *timeout, + size_t *bt) +{ + size_t temp; + size_t &bytes_transferred = bt == 0 ? temp : *bt; + bytes_transferred = 0; + ssize_t result = 0; + int error = 0; + + int val = 0; + ACE::record_and_set_non_blocking_mode (handle, val); + + iovec *iov = const_cast (i); + + for (int s = 0; + s < iovcnt; + ) + { + // Try to transfer as much of the remaining data as possible. + // Since the socket is in non-blocking mode, this call will not + // block. + ssize_t n = ACE_OS::sendv (handle, + iov + s, + iovcnt - s); + + // Check for errors. + if (n == 0 || + n == -1) + { + // Check for possible blocking. + if (n == -1 && + (errno == EWOULDBLOCK || errno == ENOBUFS)) + { + // Wait upto for the blocking to subside. + int rtn = ACE::handle_write_ready (handle, + timeout); + + // Did select() succeed? + if (rtn != -1) + { + // Blocking subsided in period. Continue + // data transfer. + n = 0; + continue; + } + } + + // Wait in select() timed out or other data transfer or + // select() failures. + error = 1; + result = n; + break; + } + + for (bytes_transferred += n; + s < iovcnt + && n >= static_cast (iov[s].iov_len); + s++) + n -= iov[s].iov_len; + + if (n != 0) + { + char *base = reinterpret_cast (iov[s].iov_base); + iov[s].iov_base = base + n; + iov[s].iov_len = iov[s].iov_len - n; + } + } + + ACE::restore_non_blocking_mode (handle, val); + + if (error) + { + return result; + } + else + { + return ACE_Utils::truncate_cast (bytes_transferred); + } +} + +ssize_t +ACE::write_n (ACE_HANDLE handle, + const ACE_Message_Block *message_block, + size_t *bt) +{ + size_t temp; + size_t &bytes_transferred = bt == 0 ? temp : *bt; + bytes_transferred = 0; + + iovec iov[ACE_IOV_MAX]; + int iovcnt = 0; + + while (message_block != 0) + { + // Our current message block chain. + const ACE_Message_Block *current_message_block = message_block; + + while (current_message_block != 0) + { + size_t current_message_block_length = + current_message_block->length (); + char *this_block_ptr = current_message_block->rd_ptr (); + + // Check if this block has any data to be sent. + while (current_message_block_length > 0) + { + u_long const this_chunk_length = + ACE_Utils::truncate_cast ( + current_message_block_length); + + // Collect the data in the iovec. + iov[iovcnt].iov_base = this_block_ptr; + iov[iovcnt].iov_len = this_chunk_length; + current_message_block_length -= this_chunk_length; + this_block_ptr += this_chunk_length; + + // Increment iovec counter. + ++iovcnt; + + // The buffer is full make a OS call. @@ TODO find a way to + // find ACE_IOV_MAX for platforms that do not define it rather + // than simply setting ACE_IOV_MAX to some arbitrary value such + // as 16. + if (iovcnt == ACE_IOV_MAX) + { + size_t current_transfer = 0; + + ssize_t const result = ACE::writev_n (handle, + iov, + iovcnt, + ¤t_transfer); + + // Add to total bytes transferred. + bytes_transferred += current_transfer; + + // Errors. + if (result == -1 || result == 0) + return result; + + // Reset iovec counter. + iovcnt = 0; + } + } + + // Select the next message block in the chain. + current_message_block = current_message_block->cont (); + } + + // Selection of the next message block chain. + message_block = message_block->next (); + } + + // Check for remaining buffers to be sent. This will happen when + // ACE_IOV_MAX is not a multiple of the number of message blocks. + if (iovcnt != 0) + { + size_t current_transfer = 0; + + ssize_t const result = ACE::writev_n (handle, + iov, + iovcnt, + ¤t_transfer); + + // Add to total bytes transferred. + bytes_transferred += current_transfer; + + // Errors. + if (result == -1 || result == 0) + return result; + } + + // Return total bytes transferred. + return ACE_Utils::truncate_cast (bytes_transferred); +} + +ssize_t +ACE::send_n (ACE_HANDLE handle, + const ACE_Message_Block *message_block, + const ACE_Time_Value *timeout, + size_t *bt) +{ + size_t temp; + size_t &bytes_transferred = bt == 0 ? temp : *bt; + bytes_transferred = 0; + + iovec iov[ACE_IOV_MAX]; + int iovcnt = 0; + + while (message_block != 0) + { + // Our current message block chain. + const ACE_Message_Block *current_message_block = message_block; + + while (current_message_block != 0) + { + char *this_block_ptr = current_message_block->rd_ptr (); + size_t current_message_block_length = + current_message_block->length (); + + // Check if this block has any data to be sent. + while (current_message_block_length > 0) + { + u_long const this_chunk_length = + ACE_Utils::truncate_cast ( + current_message_block_length); + + // Collect the data in the iovec. + iov[iovcnt].iov_base = this_block_ptr; + iov[iovcnt].iov_len = this_chunk_length; + current_message_block_length -= this_chunk_length; + this_block_ptr += this_chunk_length; + + // Increment iovec counter. + ++iovcnt; + + // The buffer is full make a OS call. @@ TODO find a way to + // find ACE_IOV_MAX for platforms that do not define it rather + // than simply setting ACE_IOV_MAX to some arbitrary value such + // as 16. + if (iovcnt == ACE_IOV_MAX) + { + size_t current_transfer = 0; + + ssize_t const result = ACE::sendv_n (handle, + iov, + iovcnt, + timeout, + ¤t_transfer); + + // Add to total bytes transferred. + bytes_transferred += current_transfer; + + // Errors. + if (result == -1 || result == 0) + return result; + + // Reset iovec counter. + iovcnt = 0; + } + } + + // Select the next message block in the chain. + current_message_block = current_message_block->cont (); + } + + // Selection of the next message block chain. + message_block = message_block->next (); + } + + // Check for remaining buffers to be sent. This will happen when + // ACE_IOV_MAX is not a multiple of the number of message blocks. + if (iovcnt != 0) + { + size_t current_transfer = 0; + + ssize_t const result = ACE::sendv_n (handle, + iov, + iovcnt, + timeout, + ¤t_transfer); + + // Add to total bytes transferred. + bytes_transferred += current_transfer; + + // Errors. + if (result == -1 || result == 0) + { + return result; + } + } + + // Return total bytes transferred. + return ACE_Utils::truncate_cast (bytes_transferred); +} + +ssize_t +ACE::readv_n (ACE_HANDLE handle, + iovec *iov, + int iovcnt, + size_t *bt) +{ + size_t temp; + size_t &bytes_transferred = bt == 0 ? temp : *bt; + bytes_transferred = 0; + + for (int s = 0; + s < iovcnt; + ) + { + ssize_t n = ACE_OS::readv (handle, + iov + s, + iovcnt - s); + + if (n == -1 || n == 0) + return n; + + for (bytes_transferred += n; + s < iovcnt + && n >= static_cast (iov[s].iov_len); + s++) + n -= iov[s].iov_len; + + if (n != 0) + { + char *base = reinterpret_cast (iov[s].iov_base); + iov[s].iov_base = base + n; + iov[s].iov_len = iov[s].iov_len - n; + } + } + + return ACE_Utils::truncate_cast (bytes_transferred); +} + +ssize_t +ACE::writev_n (ACE_HANDLE handle, + const iovec *i, + int iovcnt, + size_t *bt) +{ + size_t temp; + size_t &bytes_transferred = bt == 0 ? temp : *bt; + bytes_transferred = 0; + + iovec *iov = const_cast (i); + + for (int s = 0; + s < iovcnt; + ) + { + ssize_t n = ACE_OS::writev (handle, + iov + s, + iovcnt - s); + + if (n == -1 || n == 0) + { + return n; + } + + for (bytes_transferred += n; + s < iovcnt + && n >= static_cast (iov[s].iov_len); + s++) + n -= iov[s].iov_len; + + if (n != 0) + { + char *base = reinterpret_cast (iov[s].iov_base); + iov[s].iov_base = base + n; + iov[s].iov_len = iov[s].iov_len - n; + } + } + + return ACE_Utils::truncate_cast (bytes_transferred); +} + +int +ACE::handle_ready (ACE_HANDLE handle, + const ACE_Time_Value *timeout, + int read_ready, + int write_ready, + int exception_ready) +{ +#if defined (ACE_HAS_POLL) && defined (ACE_HAS_LIMITED_SELECT) + ACE_UNUSED_ARG (write_ready); + ACE_UNUSED_ARG (exception_ready); + + struct pollfd fds; + + fds.fd = handle; + fds.events = read_ready ? POLLIN : POLLOUT; + fds.revents = 0; + + int result = ACE_OS::poll (&fds, 1, timeout); +#else + ACE_Handle_Set handle_set; + handle_set.set_bit (handle); + + // Wait for data or for the timeout to elapse. + int select_width; +# if defined (ACE_WIN32) + // This arg is ignored on Windows and causes pointer truncation + // warnings on 64-bit compiles. + select_width = 0; +# else + select_width = int (handle) + 1; +# endif /* ACE_WIN64 */ + int result = ACE_OS::select (select_width, + read_ready ? handle_set.fdset () : 0, // read_fds. + write_ready ? handle_set.fdset () : 0, // write_fds. + exception_ready ? handle_set.fdset () : 0, // exception_fds. + timeout); + +#endif /* ACE_HAS_POLL && ACE_HAS_LIMITED_SELECT */ + + switch (result) + { + case 0: // Timer expired. + errno = ETIME; + /* FALLTHRU */ + case -1: // we got here directly - select() returned -1. + return -1; + case 1: // Handle has data. + /* FALLTHRU */ + default: // default is case result > 0; return a + // ACE_ASSERT (result == 1); + return result; + } +} + +int +ACE::enter_recv_timedwait (ACE_HANDLE handle, + const ACE_Time_Value *timeout, + int &val) +{ + int result = ACE::handle_read_ready (handle, + timeout); + + if (result == -1) + return -1; + + ACE::record_and_set_non_blocking_mode (handle, + val); + + return result; +} + +int +ACE::enter_send_timedwait (ACE_HANDLE handle, + const ACE_Time_Value *timeout, + int &val) +{ + int result = ACE::handle_write_ready (handle, + timeout); + + if (result == -1) + return -1; + + ACE::record_and_set_non_blocking_mode (handle, + val); + + return result; +} + +void +ACE::record_and_set_non_blocking_mode (ACE_HANDLE handle, + int &val) +{ + // We need to record whether we are already *in* nonblocking mode, + // so that we can correctly reset the state when we're done. + val = ACE::get_flags (handle); + + if (ACE_BIT_DISABLED (val, ACE_NONBLOCK)) + // Set the handle into non-blocking mode if it's not already in + // it. + ACE::set_flags (handle, ACE_NONBLOCK); +} + +void +ACE::restore_non_blocking_mode (ACE_HANDLE handle, + int val) +{ + if (ACE_BIT_DISABLED (val, + ACE_NONBLOCK)) + { + // Save/restore errno. + ACE_Errno_Guard error (errno); + // Only disable ACE_NONBLOCK if we weren't in non-blocking mode + // originally. + ACE::clr_flags (handle, ACE_NONBLOCK); + } +} + + +// Format buffer into printable format. This is useful for debugging. +// Portions taken from mdump by J.P. Knight (J.P.Knight@lut.ac.uk) +// Modifications by Todd Montgomery. + +size_t +ACE::format_hexdump (const char *buffer, + size_t size, + ACE_TCHAR *obuf, + size_t obuf_sz) +{ + ACE_TRACE ("ACE::format_hexdump"); + + u_char c; + ACE_TCHAR textver[16 + 1]; + + // We can fit 16 bytes output in text mode per line, 4 chars per byte. + size_t maxlen = (obuf_sz / 68) * 16; + + if (size > maxlen) + size = maxlen; + + size_t i; + + size_t lines = size / 16; + for (i = 0; i < lines; i++) + { + size_t j; + + for (j = 0 ; j < 16; j++) + { + c = (u_char) buffer[(i << 4) + j]; // or, buffer[i*16+j] + ACE_OS::sprintf (obuf, + ACE_TEXT ("%02x "), + c); + obuf += 3; + if (j == 7) + { + ACE_OS::sprintf (obuf, + ACE_TEXT (" ")); + ++obuf; + } + textver[j] = ACE_OS::ace_isprint (c) ? c : '.'; + } + + textver[j] = 0; + + ACE_OS::sprintf (obuf, + ACE_TEXT (" %s\n"), + textver); + + while (*obuf != '\0') + ++obuf; + } + + if (size % 16) + { + for (i = 0 ; i < size % 16; i++) + { + c = (u_char) buffer[size - size % 16 + i]; + ACE_OS::sprintf (obuf, + ACE_TEXT ("%02x "), + c); + obuf += 3; + if (i == 7) + { + ACE_OS::sprintf (obuf, + ACE_TEXT (" ")); + ++obuf; + } + textver[i] = ACE_OS::ace_isprint (c) ? c : '.'; + } + + for (i = size % 16; i < 16; i++) + { + ACE_OS::sprintf (obuf, + ACE_TEXT (" ")); + obuf += 3; + if (i == 7) + { + ACE_OS::sprintf (obuf, + ACE_TEXT (" ")); + ++obuf; + } + textver[i] = ' '; + } + + textver[i] = 0; + ACE_OS::sprintf (obuf, + ACE_TEXT (" %s\n"), + textver); + } + return size; +} + +// Returns the current timestamp in the form +// "hour:minute:second:microsecond." The month, day, and year are +// also stored in the beginning of the date_and_time array. + +ACE_TCHAR * +ACE::timestamp (ACE_TCHAR date_and_time[], + size_t date_and_timelen, + bool return_pointer_to_first_digit) +{ + //ACE_TRACE ("ACE::timestamp"); + + if (date_and_timelen < 35) + { + errno = EINVAL; + return 0; + } + +#if defined (WIN32) + // Emulate Unix. Win32 does NOT support all the UNIX versions + // below, so DO we need this ifdef. + static const ACE_TCHAR *day_of_week_name[] = + { + ACE_TEXT ("Sun"), + ACE_TEXT ("Mon"), + ACE_TEXT ("Tue"), + ACE_TEXT ("Wed"), + ACE_TEXT ("Thu"), + ACE_TEXT ("Fri"), + ACE_TEXT ("Sat") + }; + + static const ACE_TCHAR *month_name[] = + { + ACE_TEXT ("Jan"), + ACE_TEXT ("Feb"), + ACE_TEXT ("Mar"), + ACE_TEXT ("Apr"), + ACE_TEXT ("May"), + ACE_TEXT ("Jun"), + ACE_TEXT ("Jul"), + ACE_TEXT ("Aug"), + ACE_TEXT ("Sep"), + ACE_TEXT ("Oct"), + ACE_TEXT ("Nov"), + ACE_TEXT ("Dec") + }; + + SYSTEMTIME local; + ::GetLocalTime (&local); + + ACE_OS::sprintf (date_and_time, + ACE_TEXT ("%3s %3s %2d %04d %02d:%02d:%02d.%06d"), + day_of_week_name[local.wDayOfWeek], + month_name[local.wMonth - 1], + (int) local.wDay, + (int) local.wYear, + (int) local.wHour, + (int) local.wMinute, + (int) local.wSecond, + (int) (local.wMilliseconds * 1000)); + return &date_and_time[15 + (return_pointer_to_first_digit != 0)]; +#else /* UNIX */ + ACE_TCHAR timebuf[26]; // This magic number is based on the ctime(3c) man page. + ACE_Time_Value cur_time = ACE_OS::gettimeofday (); + time_t secs = cur_time.sec (); + + ACE_OS::ctime_r (&secs, + timebuf, + sizeof timebuf / sizeof (ACE_TCHAR)); + // date_and_timelen > sizeof timebuf! + ACE_OS::strsncpy (date_and_time, + timebuf, + date_and_timelen); + ACE_TCHAR yeartmp[5]; + ACE_OS::strsncpy (yeartmp, + &date_and_time[20], + 5); + ACE_TCHAR timetmp[9]; + ACE_OS::strsncpy (timetmp, + &date_and_time[11], + 9); + ACE_OS::sprintf (&date_and_time[11], +# if defined (ACE_USES_WCHAR) + ACE_TEXT ("%ls %ls.%06ld"), +# else + ACE_TEXT ("%s %s.%06ld"), +# endif /* ACE_USES_WCHAR */ + yeartmp, + timetmp, + cur_time.usec ()); + date_and_time[33] = '\0'; + return &date_and_time[15 + (return_pointer_to_first_digit != 0)]; +#endif /* WIN32 */ +} + +// This function rounds the request to a multiple of the page size. + +size_t +ACE::round_to_pagesize (size_t len) +{ + ACE_TRACE ("ACE::round_to_pagesize"); + + if (ACE::pagesize_ == 0) + ACE::pagesize_ = ACE_OS::getpagesize (); + + return (len + (ACE::pagesize_ - 1)) & ~(ACE::pagesize_ - 1); +} + +size_t +ACE::round_to_allocation_granularity (size_t len) +{ + ACE_TRACE ("ACE::round_to_allocation_granularity"); + + if (ACE::allocation_granularity_ == 0) + ACE::allocation_granularity_ = ACE_OS::allocation_granularity (); + + return (len + (ACE::allocation_granularity_ - 1)) & ~(ACE::allocation_granularity_ - 1); +} + +ACE_HANDLE +ACE::handle_timed_complete (ACE_HANDLE h, + const ACE_Time_Value *timeout, + int is_tli) +{ + ACE_TRACE ("ACE::handle_timed_complete"); + +#if !defined (ACE_WIN32) && defined (ACE_HAS_POLL) && defined (ACE_HAS_LIMITED_SELECT) + + struct pollfd fds; + + fds.fd = h; + fds.events = POLLIN | POLLOUT; + fds.revents = 0; + +#else + ACE_Handle_Set rd_handles; + ACE_Handle_Set wr_handles; + + rd_handles.set_bit (h); + wr_handles.set_bit (h); +#endif /* !ACE_WIN32 && ACE_HAS_POLL && ACE_HAS_LIMITED_SELECT */ + +#if defined (ACE_WIN32) + // Winsock is different - it sets the exception bit for failed connect, + // unlike other platforms, where the read bit is set. + ACE_Handle_Set ex_handles; + ex_handles.set_bit (h); +#endif /* ACE_WIN32 */ + + bool need_to_check = false; + bool known_failure = false; + +#if defined (ACE_WIN32) + int n = ACE_OS::select (0, // Ignored on Windows: int (h) + 1, + 0, + wr_handles, + ex_handles, + timeout); +#else +# if defined (ACE_HAS_POLL) && defined (ACE_HAS_LIMITED_SELECT) + + int n = ACE_OS::poll (&fds, 1, timeout); + +# else + int n = ACE_OS::select (int (h) + 1, + rd_handles, + wr_handles, + 0, + timeout); +# endif /* ACE_HAS_POLL && ACE_HAS_LIMITED_SELECT */ +#endif /* ACE_WIN32 */ + + // If we failed to connect within the time period allocated by the + // caller, then we fail (e.g., the remote host might have been too + // busy to accept our call). + if (n <= 0) + { + if (n == 0 && timeout != 0) + errno = ETIME; + return ACE_INVALID_HANDLE; + } + + // Usually, a ready-for-write handle is successfully connected, and + // ready-for-read (exception on Win32) is a failure. On fails, we + // need to grab the error code via getsockopt. On possible success for + // any platform where we can't tell just from select() (e.g. AIX), + // we also need to check for success/fail. +#if defined (ACE_WIN32) + ACE_UNUSED_ARG (is_tli); + + // On Win32, ex_handle set indicates a failure. We'll do the check + // to try and get an errno value, but the connect failed regardless of + // what getsockopt says about the error. + if (ex_handles.is_set (h)) + { + need_to_check = true; + known_failure = true; + } +#elif defined (ACE_VXWORKS) + ACE_UNUSED_ARG (is_tli); + + // Force the check on VxWorks. The read handle for "h" is not set, + // so "need_to_check" is false at this point. The write handle is + // set, for what it's worth. + need_to_check = true; +#else + if (is_tli) + +# if defined (ACE_HAS_POLL) && defined (ACE_HAS_LIMITED_SELECT) + need_to_check = (fds.revents & POLLIN) && !(fds.revents & POLLOUT); +# else + need_to_check = rd_handles.is_set (h) && !wr_handles.is_set (h); +# endif /* ACE_HAS_POLL && ACE_HAS_LIMITED_SELECT */ + + else +#if defined(AIX) + // AIX is broken... both success and failed connect will set the + // write handle only, so always check. + need_to_check = true; +#else +# if defined (ACE_HAS_POLL) && defined (ACE_HAS_LIMITED_SELECT) + need_to_check = (fds.revents & POLLIN); +# else + need_to_check = rd_handles.is_set (h); +# endif /* ACE_HAS_POLL && ACE_HAS_LIMITED_SELECT */ +#endif /* AIX */ +#endif /* ACE_WIN32 */ + + if (need_to_check) + { +#if defined (SOL_SOCKET) && defined (SO_ERROR) + int sock_err = 0; + int sock_err_len = sizeof (sock_err); + int sockopt_ret = ACE_OS::getsockopt (h, SOL_SOCKET, SO_ERROR, + (char *)&sock_err, &sock_err_len); + if (sockopt_ret < 0) + { + h = ACE_INVALID_HANDLE; + } + + if (sock_err != 0 || known_failure) + { + h = ACE_INVALID_HANDLE; + errno = sock_err; + } +#else + char dummy; + + // The following recv() won't block provided that the + // ACE_NONBLOCK flag has not been turned off . + n = ACE::recv (h, &dummy, 1, MSG_PEEK); + + // If no data was read/peeked at, check to see if it's because + // of a non-connected socket (and therefore an error) or there's + // just no data yet. + if (n <= 0) + { + if (n == 0) + { + errno = ECONNREFUSED; + h = ACE_INVALID_HANDLE; + } + else if (errno != EWOULDBLOCK && errno != EAGAIN) + h = ACE_INVALID_HANDLE; + } +#endif + } + + // 1. The HANDLE is ready for writing and doesn't need to be checked or + // 2. recv() returned an indication of the state of the socket - if there is + // either data present, or a recv is legit but there's no data yet, + // the connection was successfully established. + return h; +} + +// Wait up to amount of time to accept a connection. + +int +ACE::handle_timed_accept (ACE_HANDLE listener, + ACE_Time_Value *timeout, + int restart) +{ + ACE_TRACE ("ACE::handle_timed_accept"); + // Make sure we don't bomb out on erroneous values. + if (listener == ACE_INVALID_HANDLE) + return -1; + +#if defined (ACE_HAS_POLL) && defined (ACE_HAS_LIMITED_SELECT) + + struct pollfd fds; + + fds.fd = listener; + fds.events = POLLIN; + fds.revents = 0; + +#else + // Use the select() implementation rather than poll(). + ACE_Handle_Set rd_handle; + rd_handle.set_bit (listener); +#endif /* ACE_HAS_POLL && ACE_HAS_LIMITED_SELECT */ + + // We need a loop here if is enabled. + + for (;;) + { +#if defined (ACE_HAS_POLL) && defined (ACE_HAS_LIMITED_SELECT) + + int n = ACE_OS::poll (&fds, 1, timeout); + +#else + int select_width; +# if defined (ACE_WIN32) + // This arg is ignored on Windows and causes pointer truncation + // warnings on 64-bit compiles. + select_width = 0; +# else + select_width = int (listener) + 1; +# endif /* ACE_WIN32 */ + int n = ACE_OS::select (select_width, + rd_handle, 0, 0, + timeout); +#endif /* ACE_HAS_POLL && ACE_HAS_LIMITED_SELECT */ + + switch (n) + { + case -1: + if (errno == EINTR && restart) + continue; + else + return -1; + /* NOTREACHED */ + case 0: + if (timeout != 0 + && timeout->sec () == 0 + && timeout->usec () == 0) + errno = EWOULDBLOCK; + else + errno = ETIMEDOUT; + return -1; + /* NOTREACHED */ + case 1: + return 0; + /* NOTREACHED */ + default: + errno = EINVAL; + return -1; + /* NOTREACHED */ + } + } +} + +// Make the current process a UNIX daemon. This is based on Stevens +// code from APUE. + +int +ACE::daemonize (const ACE_TCHAR pathname[], + bool close_all_handles, + const ACE_TCHAR program_name[]) +{ + ACE_TRACE ("ACE::daemonize"); +#if !defined (ACE_LACKS_FORK) + pid_t pid = ACE_OS::fork (); + + if (pid == -1) + return -1; + else if (pid != 0) + ACE_OS::exit (0); // Parent exits. + + // 1st child continues. + ACE_OS::setsid (); // Become session leader. + + ACE_OS::signal (SIGHUP, SIG_IGN); + + pid = ACE_OS::fork (program_name); + + if (pid != 0) + ACE_OS::exit (0); // First child terminates. + + // Second child continues. + + if (pathname != 0) + // change working directory. + ACE_OS::chdir (pathname); + + ACE_OS::umask (0); // clear our file mode creation mask. + + // Close down the I/O handles. + if (close_all_handles) + { + for (int i = ACE::max_handles () - 1; i >= 0; i--) + ACE_OS::close (i); + + int fd = ACE_OS::open ("/dev/null", O_RDWR, 0); + if (fd != -1) + { + ACE_OS::dup2 (fd, ACE_STDIN); + ACE_OS::dup2 (fd, ACE_STDOUT); + ACE_OS::dup2 (fd, ACE_STDERR); + + if (fd > ACE_STDERR) + ACE_OS::close (fd); + } + } + + return 0; +#else + ACE_UNUSED_ARG (pathname); + ACE_UNUSED_ARG (close_all_handles); + ACE_UNUSED_ARG (program_name); + + ACE_NOTSUP_RETURN (-1); +#endif /* ACE_LACKS_FORK */ +} + +pid_t +ACE::fork (const ACE_TCHAR *program_name, + int avoid_zombies) +{ + if (avoid_zombies == 0) + return ACE_OS::fork (program_name); + else + { + // This algorithm is adapted from an example in the Stevens book + // "Advanced Programming in the Unix Environment" and an item in + // Andrew Gierth's Unix Programming FAQ. It creates an orphan + // process that's inherited by the init process; init cleans up + // when the orphan process terminates. + // + // Another way to avoid zombies is to ignore or catch the + // SIGCHLD signal; we don't use that approach here. + + pid_t pid = ACE_OS::fork (); + if (pid == 0) + { + // The child process forks again to create a grandchild. + switch (ACE_OS::fork (program_name)) + { + case 0: // grandchild returns 0. + return 0; + case -1: // assumes all errnos are < 256 + ACE_OS::_exit (errno); + default: // child terminates, orphaning grandchild + ACE_OS::_exit (0); + } + } + + // Parent process waits for child to terminate. + ACE_exitcode status; + if (pid < 0 || ACE_OS::waitpid (pid, &status, 0) < 0) + return -1; + + // child terminated by calling exit()? + if (WIFEXITED ((status))) + { + // child terminated normally? + if (WEXITSTATUS ((status)) == 0) + return 1; + else + errno = WEXITSTATUS ((status)); + } + else + // child didn't call exit(); perhaps it received a signal? + errno = EINTR; + + return -1; + } +} + +int +ACE::max_handles (void) +{ + ACE_TRACE ("ACE::max_handles"); +#if defined (RLIMIT_NOFILE) && !defined (ACE_LACKS_RLIMIT) + rlimit rl; + int const r = ACE_OS::getrlimit (RLIMIT_NOFILE, &rl); +# if !defined (RLIM_INFINITY) + if (r == 0) + return rl.rlim_cur; +# else + if (r == 0 && rl.rlim_cur != RLIM_INFINITY) + return rl.rlim_cur; + // If == RLIM_INFINITY, fall through to the ACE_LACKS_RLIMIT sections +# endif /* RLIM_INFINITY */ +#endif /* RLIMIT_NOFILE && !ACE_LACKS_RLIMIT */ + +#if defined (_SC_OPEN_MAX) + return ACE_OS::sysconf (_SC_OPEN_MAX); +#elif defined (ACE_VXWORKS) && (ACE_VXWORKS < 0x620) + return maxFiles; +#elif defined (FD_SETSIZE) + return FD_SETSIZE; +#else + ACE_NOTSUP_RETURN (-1); +#endif /* _SC_OPEN_MAX */ +} + +// Set the number of currently open handles in the process. +// +// If NEW_LIMIT == -1 set the limit to the maximum allowable. +// Otherwise, set it to be the value of NEW_LIMIT. + +int +ACE::set_handle_limit (int new_limit, + int increase_limit_only) +{ + ACE_TRACE ("ACE::set_handle_limit"); + int cur_limit = ACE::max_handles (); + int max_limit = cur_limit; + + if (cur_limit == -1) + return -1; + +#if !defined (ACE_LACKS_RLIMIT) && defined (RLIMIT_NOFILE) + struct rlimit rl; + + ACE_OS::memset ((void *) &rl, 0, sizeof rl); + int r = ACE_OS::getrlimit (RLIMIT_NOFILE, &rl); + if (r == 0) + max_limit = rl.rlim_max; +#endif /* ACE_LACKS_RLIMIT */ + + if (new_limit == -1) + new_limit = max_limit; + + if (new_limit < 0) + { + errno = EINVAL; + return -1; + } + else if (new_limit > cur_limit) + { + // Increase the limit. +#if !defined (ACE_LACKS_RLIMIT) && defined (RLIMIT_NOFILE) + rl.rlim_cur = new_limit; + return ACE_OS::setrlimit (RLIMIT_NOFILE, &rl); +#elif defined (ACE_LACKS_RLIMIT_NOFILE) + return 0; +#else + // Must return EINVAL errno. + ACE_NOTSUP_RETURN (-1); +#endif /* ACE_LACKS_RLIMIT */ + } + else if (increase_limit_only == 0) + { + // Decrease the limit. +#if !defined (ACE_LACKS_RLIMIT) && defined (RLIMIT_NOFILE) + rl.rlim_cur = new_limit; + return ACE_OS::setrlimit (RLIMIT_NOFILE, &rl); +#else + // We give a chance to platforms without RLIMIT to work. + // Instead of ACE_NOTSUP_RETURN (0), just return 0 because + // new_limit is <= cur_limit, so it's a no-op. + return 0; +#endif /* ACE_LACKS_RLIMIT */ + } + + return 0; +} + +// Euclid's greatest common divisor algorithm. +u_long +ACE::gcd (u_long x, u_long y) +{ + while (y != 0) + { + u_long r = x % y; + x = y; + y = r; + } + + return x; +} + + +// Calculates the minimum enclosing frame size for the given values. +u_long +ACE::minimum_frame_size (u_long period1, u_long period2) +{ + // if one of the periods is zero, treat it as though it as + // uninitialized and return the other period as the frame size + if (0 == period1) + { + return period2; + } + if (0 == period2) + { + return period1; + } + + // if neither is zero, find the greatest common divisor of the two periods + u_long greatest_common_divisor = ACE::gcd (period1, period2); + + // explicitly consider cases to reduce risk of possible overflow errors + if (greatest_common_divisor == 1) + { + // periods are relative primes: just multiply them together + return period1 * period2; + } + else if (greatest_common_divisor == period1) + { + // the first period divides the second: return the second + return period2; + } + else if (greatest_common_divisor == period2) + { + // the second period divides the first: return the first + return period1; + } + else + { + // the current frame size and the entry's effective period + // have a non-trivial greatest common divisor: return the + // product of factors divided by those in their gcd. + return (period1 * period2) / greatest_common_divisor; + } +} + + +u_long +ACE::is_prime (const u_long n, + const u_long min_factor, + const u_long max_factor) +{ + if (n > 3) + for (u_long factor = min_factor; + factor <= max_factor; + ++factor) + if (n / factor * factor == n) + return factor; + + return 0; +} + +const ACE_TCHAR * +ACE::sock_error (int error) +{ +#if defined (ACE_WIN32) + static ACE_TCHAR unknown_msg[64]; + + switch (error) + { + case WSAVERNOTSUPPORTED: + return ACE_TEXT ("version of WinSock not supported"); + /* NOTREACHED */ + case WSASYSNOTREADY: + return ACE_TEXT ("WinSock not present or not responding"); + /* NOTREACHED */ + case WSAEINVAL: + return ACE_TEXT ("app version not supported by DLL"); + /* NOTREACHED */ + case WSAHOST_NOT_FOUND: + return ACE_TEXT ("Authoritive: Host not found"); + /* NOTREACHED */ + case WSATRY_AGAIN: + return ACE_TEXT ("Non-authoritive: host not found or server failure"); + /* NOTREACHED */ + case WSANO_RECOVERY: + return ACE_TEXT ("Non-recoverable: refused or not implemented"); + /* NOTREACHED */ + case WSANO_DATA: + return ACE_TEXT ("Valid name, no data record for type"); + /* NOTREACHED */ + /* + case WSANO_ADDRESS: + return "Valid name, no MX record"; + */ + case WSANOTINITIALISED: + return ACE_TEXT ("WSA Startup not initialized"); + /* NOTREACHED */ + case WSAENETDOWN: + return ACE_TEXT ("Network subsystem failed"); + /* NOTREACHED */ + case WSAEINPROGRESS: + return ACE_TEXT ("Blocking operation in progress"); + /* NOTREACHED */ + case WSAEINTR: + return ACE_TEXT ("Blocking call cancelled"); + /* NOTREACHED */ + case WSAEAFNOSUPPORT: + return ACE_TEXT ("address family not supported"); + /* NOTREACHED */ + case WSAEMFILE: + return ACE_TEXT ("no file handles available"); + /* NOTREACHED */ + case WSAENOBUFS: + return ACE_TEXT ("no buffer space available"); + /* NOTREACHED */ + case WSAEPROTONOSUPPORT: + return ACE_TEXT ("specified protocol not supported"); + /* NOTREACHED */ + case WSAEPROTOTYPE: + return ACE_TEXT ("protocol wrong type for this socket"); + /* NOTREACHED */ + case WSAESOCKTNOSUPPORT: + return ACE_TEXT ("socket type not supported for address family"); + /* NOTREACHED */ + case WSAENOTSOCK: + return ACE_TEXT ("handle is not a socket"); + /* NOTREACHED */ + case WSAEWOULDBLOCK: + return ACE_TEXT ("resource temporarily unavailable"); + /* NOTREACHED */ + case WSAEADDRINUSE: + return ACE_TEXT ("address already in use"); + /* NOTREACHED */ + case WSAECONNABORTED: + return ACE_TEXT ("connection aborted"); + /* NOTREACHED */ + case WSAECONNRESET: + return ACE_TEXT ("connection reset"); + /* NOTREACHED */ + case WSAENOTCONN: + return ACE_TEXT ("not connected"); + /* NOTREACHED */ + case WSAETIMEDOUT: + return ACE_TEXT ("connection timed out"); + /* NOTREACHED */ + case WSAECONNREFUSED: + return ACE_TEXT ("connection refused"); + /* NOTREACHED */ + case WSAEHOSTDOWN: + return ACE_TEXT ("host down"); + /* NOTREACHED */ + case WSAEHOSTUNREACH: + return ACE_TEXT ("host unreachable"); + /* NOTREACHED */ + case WSAEADDRNOTAVAIL: + return ACE_TEXT ("address not available"); + /* NOTREACHED */ + case WSAEISCONN: + return ACE_TEXT ("socket is already connected"); + /* NOTREACHED */ + case WSAENETRESET: + return ACE_TEXT ("network dropped connection on reset"); + /* NOTREACHED */ + case WSAEMSGSIZE: + return ACE_TEXT ("message too long"); + /* NOTREACHED */ + case WSAENETUNREACH: + return ACE_TEXT ("network is unreachable"); + /* NOTREACHED */ + case WSAEFAULT: + return ACE_TEXT ("bad address"); + /* NOTREACHED */ + case WSAEDISCON: + return ACE_TEXT ("graceful shutdown in progress"); + /* NOTREACHED */ + case WSAEACCES: + return ACE_TEXT ("permission denied"); + /* NOTREACHED */ + case WSAESHUTDOWN: + return ACE_TEXT ("cannot send after socket shutdown"); + /* NOTREACHED */ + case WSAEPROCLIM: + return ACE_TEXT ("too many processes"); + /* NOTREACHED */ + case WSAEALREADY: + return ACE_TEXT ("operation already in progress"); + /* NOTREACHED */ + case WSAEPFNOSUPPORT: + return ACE_TEXT ("protocol family not supported"); + /* NOTREACHED */ + case WSAENOPROTOOPT: + return ACE_TEXT ("bad protocol option"); + /* NOTREACHED */ + case WSATYPE_NOT_FOUND: + return ACE_TEXT ("class type not found"); + /* NOTREACHED */ + case WSAEOPNOTSUPP: + return ACE_TEXT ("operation not supported"); + /* NOTREACHED */ + case WSAEDESTADDRREQ: + return ACE_TEXT ("destination address required"); + /* NOTREACHED */ + default: + ACE_OS::sprintf (unknown_msg, ACE_TEXT ("unknown error: %d"), error); + return unknown_msg; + /* NOTREACHED */ + } +#else + ACE_UNUSED_ARG (error); + ACE_NOTSUP_RETURN (0); +#endif /* ACE_WIN32 */ +} + +bool +ACE::is_sock_error (int error) +{ +#if defined (ACE_WIN32) + switch (error) + { + case WSAVERNOTSUPPORTED: + case WSASYSNOTREADY: + case WSAEINVAL: + case WSAHOST_NOT_FOUND: + case WSATRY_AGAIN: + case WSANO_RECOVERY: + case WSANO_DATA: + /* + case WSANO_ADDRESS: + */ + case WSANOTINITIALISED: + case WSAENETDOWN: + case WSAEINPROGRESS: + case WSAEINTR: + case WSAEAFNOSUPPORT: + case WSAEMFILE: + case WSAENOBUFS: + case WSAEPROTONOSUPPORT: + case WSAEPROTOTYPE: + case WSAESOCKTNOSUPPORT: + case WSAENOTSOCK: + case WSAEWOULDBLOCK: + case WSAEADDRINUSE: + case WSAECONNABORTED: + case WSAECONNRESET: + case WSAENOTCONN: + case WSAETIMEDOUT: + case WSAECONNREFUSED: + case WSAEHOSTDOWN: + case WSAEHOSTUNREACH: + case WSAEADDRNOTAVAIL: + case WSAEISCONN: + case WSAENETRESET: + case WSAEMSGSIZE: + case WSAENETUNREACH: + case WSAEFAULT: + case WSAEDISCON: + case WSAEACCES: + case WSAESHUTDOWN: + case WSAEPROCLIM: + case WSAEALREADY: + case WSAEPFNOSUPPORT: + case WSAENOPROTOOPT: + case WSATYPE_NOT_FOUND: + case WSAEOPNOTSUPP: + return true; + } +#else + ACE_UNUSED_ARG (error); +#endif /* ACE_WIN32 */ + return false; +} + +char * +ACE::strndup (const char *str, size_t n) +{ + const char *t = str; + size_t len; + + // Figure out how long this string is (remember, it might not be + // NUL-terminated). + + for (len = 0; + len < n && *t++ != '\0'; + len++) + continue; + + char *s; + ACE_ALLOCATOR_RETURN (s, + (char *) ACE_OS::malloc (len + 1), + 0); + return ACE_OS::strsncpy (s, str, len + 1); +} + +#if defined (ACE_HAS_WCHAR) +wchar_t * +ACE::strndup (const wchar_t *str, size_t n) +{ + const wchar_t *t = str; + size_t len; + + // Figure out how long this string is (remember, it might not be + // NUL-terminated). + + for (len = 0; + len < n && *t++ != '\0'; + len++) + continue; + + wchar_t *s; + ACE_ALLOCATOR_RETURN (s, + static_cast ( + ACE_OS::malloc ((len + 1) * sizeof (wchar_t))), + 0); + return ACE_OS::strsncpy (s, str, len + 1); +} +#endif /* ACE_HAS_WCHAR */ + +char * +ACE::strnnew (const char *str, size_t n) +{ + const char *t = str; + size_t len; + + // Figure out how long this string is (remember, it might not be + // NUL-terminated). + + for (len = 0; + len < n && *t++ != L'\0'; + len++) + continue; + + char *s; + ACE_NEW_RETURN (s, + char[len + 1], + 0); + return ACE_OS::strsncpy (s, str, len + 1); +} + +#if defined (ACE_HAS_WCHAR) +wchar_t * +ACE::strnnew (const wchar_t *str, size_t n) +{ + const wchar_t *t = str; + size_t len; + + // Figure out how long this string is (remember, it might not be + // NUL-terminated). + + for (len = 0; + len < n && *t++ != ACE_TEXT_WIDE ('\0'); + len++) + continue; + + wchar_t *s; + ACE_NEW_RETURN (s, + wchar_t[len + 1], + 0); + return ACE_OS::strsncpy (s, str, len + 1); +} +#endif /* ACE_HAS_WCHAR */ + +const char * +ACE::strend (const char *s) +{ + while (*s++ != '\0') + continue; + + return s; +} + +#if defined ACE_HAS_WCHAR +const wchar_t * +ACE::strend (const wchar_t *s) +{ + while (*s++ != ACE_TEXT_WIDE ('\0')) + continue; + + return s; +} +#endif + +char * +ACE::strnew (const char *s) +{ + if (s == 0) + return 0; + char *t = 0; + ACE_NEW_RETURN (t, + char [ACE_OS::strlen (s) + 1], + 0); + if (t == 0) + return 0; + else + return ACE_OS::strcpy (t, s); +} + +#if defined (ACE_HAS_WCHAR) +wchar_t * +ACE::strnew (const wchar_t *s) +{ + if (s == 0) + return 0; + wchar_t *t = 0; + ACE_NEW_RETURN (t, + wchar_t[ACE_OS::strlen (s) + 1], + 0); + if (t == 0) + return 0; + else + return ACE_OS::strcpy (t, s); +} +#endif /* ACE_HAS_WCHAR */ + +inline static bool equal_char(char a, char b, bool case_sensitive) +{ + if (case_sensitive) + return a == b; + return ACE_OS::ace_tolower(a) == ACE_OS::ace_tolower(b); +} + +bool +ACE::wild_match(const char* str, const char* pat, bool case_sensitive) +{ + if (str == pat) + return true; + if (pat == 0 || str == 0) + return false; + + bool star = false; + const char* s = str; + const char* p = pat; + while (*s != '\0') + { + if (*p == '*') + { + star = true; + pat = p; + while (*++pat == '*') {} + + if (*pat == '\0') + return true; + p = pat; + } + else if (*p == '?') + { + ++s; + ++p; + } + else if (! equal_char(*s, *p, case_sensitive)) + { + if (!star) + return false; + s = ++str; + p = pat; + } + else + { + ++s; + ++p; + } + } + if (*p == '*') + while (*++p == '*') {} + + return *p == '\0'; +} + +// Close versioned namespace, if enabled by the user. +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/ACE.h b/dep/ACE_wrappers/ace/ACE.h new file mode 100644 index 00000000000..654bbb3230f --- /dev/null +++ b/dep/ACE_wrappers/ace/ACE.h @@ -0,0 +1,824 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file ACE.h + * + * $Id: ACE.h 82581 2008-08-11 08:58:24Z johnnyw $ + * + * This file contains value added ACE functions that extend the + * behavior of the UNIX and Win32 OS calls. + * + * All these ACE static functions are consolidated in a single place + * in order to manage the namespace better. These functions are put + * here rather than in @c ACE_OS in order to separate concerns. + * + * @author Douglas C. Schmidt + */ +//============================================================================= + +#ifndef ACE_ACE_H +#define ACE_ACE_H + +#include /**/ "ace/pre.h" + +#include "ace/config-lite.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/OS_NS_math.h" +#include "ace/Flag_Manip.h" +#include "ace/Handle_Ops.h" +#include "ace/Lib_Find.h" +#include "ace/Init_ACE.h" +#include "ace/Sock_Connect.h" +#include "ace/Default_Constants.h" + +#if defined (ACE_EXPORT_MACRO) +# undef ACE_EXPORT_MACRO +#endif +#define ACE_EXPORT_MACRO ACE_Export + +// Open versioned namespace, if enabled by the user. +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +// Forward declarations. +class ACE_Time_Value; +class ACE_Message_Block; +class ACE_Handle_Set; + +/** + * @namespace ACE + * + * @brief The namespace containing the ACE framework itself. + * + * The ACE namespace contains all types (classes, structures, + * typedefs, etc), and global functions and variables in the ACE + * framework. + */ +namespace ACE +{ + // = ACE version information. + /// e.g., the "5" in ACE 5.1.12. + extern ACE_Export u_int major_version (void); + + /// e.g., the "1" in ACE 5.1.12. + extern ACE_Export u_int minor_version (void); + + /// e.g., the "12" in ACE 5.1.12. + /// Returns 0 for "stable" (non-beta) releases. + extern ACE_Export u_int beta_version (void); + + // = C++ compiler version information. + /// E.g., the "SunPro C++" in SunPro C++ 4.32.0 + extern ACE_Export const ACE_TCHAR * compiler_name (void); + + /// E.g., the "4" in SunPro C++ 4.32.0 + extern ACE_Export u_int compiler_major_version (void); + + /// E.g., the "32" in SunPro C++ 4.32.0 + extern ACE_Export u_int compiler_minor_version (void); + + /// E.g., the "0" in SunPro C++ 4.32.0 + extern ACE_Export u_int compiler_beta_version (void); + + /// Check if error indicates the process being out of handles (file + /// descriptors). + extern ACE_Export int out_of_handles (int error); + + /// Simple wildcard matching function supporting '*' and '?' + /// return true if string s matches pattern. + extern ACE_Export bool wild_match(const char* s, const char* pattern, bool case_sensitive = true); + + /** + * @name I/O operations + * + * Notes on common parameters: + * + * @a handle is the connected endpoint that will be used for I/O. + * + * @a buf is the buffer to write from or receive into. + * + * @a len is the number of bytes to transfer. + * + * The @a timeout parameter in the following methods indicates how + * long to blocking trying to transfer data. If @a timeout == 0, + * then the call behaves as a normal send/recv call, i.e., for + * blocking sockets, the call will block until action is possible; + * for non-blocking sockets, @c EWOULDBLOCK will be returned if no + * action is immediately possible. + * + * If @a timeout != 0, the call will wait until the relative time + * specified in @a *timeout elapses. + * + * The "_n()" I/O methods keep looping until all the data has been + * transferred. These methods also work for sockets in non-blocking + * mode i.e., they keep looping on @c EWOULDBLOCK. @a timeout is + * used to make sure we keep making progress, i.e., the same timeout + * value is used for every I/O operation in the loop and the timeout + * is not counted down. + * + * The return values for the "*_n()" methods match the return values + * from the non "_n()" methods and are specified as follows: + * + * - On complete transfer, the number of bytes transferred is returned. + * - On timeout, -1 is returned, @c errno == @c ETIME. + * - On error, -1 is returned, @c errno is set to appropriate error. + * - On @c EOF, 0 is returned, @c errno is irrelevant. + * + * On partial transfers, i.e., if any data is transferred before + * timeout / error / @c EOF, @a bytes_transferred> will contain the + * number of bytes transferred. + * + * Methods with @a iovec parameter are I/O vector variants of the + * I/O operations. + * + * Methods with the extra @a flags argument will always result in + * @c send getting called. Methods without the extra @a flags + * argument will result in @c send getting called on Win32 + * platforms, and @c write getting called on non-Win32 platforms. + */ + //@{ + extern ACE_Export ssize_t recv (ACE_HANDLE handle, + void *buf, + size_t len, + int flags, + const ACE_Time_Value *timeout = 0); + +#if defined (ACE_HAS_TLI) + + extern ACE_Export ssize_t t_rcv (ACE_HANDLE handle, + void *buf, + size_t len, + int *flags, + const ACE_Time_Value *timeout = 0); + +#endif /* ACE_HAS_TLI */ + + extern ACE_Export ssize_t recv (ACE_HANDLE handle, + void *buf, + size_t len, + const ACE_Time_Value *timeout = 0); + + extern ACE_Export ssize_t recvmsg (ACE_HANDLE handle, + struct msghdr *msg, + int flags, + const ACE_Time_Value *timeout = 0); + + extern ACE_Export ssize_t recvfrom (ACE_HANDLE handle, + char *buf, + int len, + int flags, + struct sockaddr *addr, + int *addrlen, + const ACE_Time_Value *timeout = 0); + + ACE_NAMESPACE_INLINE_FUNCTION + ssize_t recv_n (ACE_HANDLE handle, + void *buf, + size_t len, + int flags, + const ACE_Time_Value *timeout = 0, + size_t *bytes_transferred = 0); + +#if defined (ACE_HAS_TLI) + + ACE_NAMESPACE_INLINE_FUNCTION + ssize_t t_rcv_n (ACE_HANDLE handle, + void *buf, + size_t len, + int *flags, + const ACE_Time_Value *timeout = 0, + size_t *bytes_transferred = 0); + +#endif /* ACE_HAS_TLI */ + + ACE_NAMESPACE_INLINE_FUNCTION + ssize_t recv_n (ACE_HANDLE handle, + void *buf, + size_t len, + const ACE_Time_Value *timeout = 0, + size_t *bytes_transferred = 0); + + /// Receive into a variable number of pieces. + /** + * Accepts a variable, caller-specified, number of pointer/length + * pairs. Arguments following @a n are char *, size_t pairs. + * + * @param handle The I/O handle to receive on + * @param n The total number of char *, size_t pairs following @a n. + * + * @return -1 on error, else total number of bytes received. + */ + extern ACE_Export ssize_t recv (ACE_HANDLE handle, size_t n, ...); + + extern ACE_Export ssize_t recvv (ACE_HANDLE handle, + iovec *iov, + int iovcnt, + const ACE_Time_Value *timeout = 0); + + ACE_NAMESPACE_INLINE_FUNCTION + ssize_t recvv_n (ACE_HANDLE handle, + iovec *iov, + int iovcnt, + const ACE_Time_Value *timeout = 0, + size_t *bytes_transferred = 0); + + extern ACE_Export ssize_t recv_n (ACE_HANDLE handle, + ACE_Message_Block *message_block, + const ACE_Time_Value *timeout = 0, + size_t *bytes_transferred = 0); + + extern ACE_Export ssize_t send (ACE_HANDLE handle, + const void *buf, + size_t len, + int flags, + const ACE_Time_Value *timeout = 0); + +#if defined (ACE_HAS_TLI) + + extern ACE_Export ssize_t t_snd (ACE_HANDLE handle, + const void *buf, + size_t len, + int flags, + const ACE_Time_Value *timeout = 0); + +#endif /* ACE_HAS_TLI */ + + extern ACE_Export ssize_t send (ACE_HANDLE handle, + const void *buf, + size_t len, + const ACE_Time_Value *timeout = 0); + + extern ACE_Export ssize_t sendmsg (ACE_HANDLE handle, + const struct msghdr *msg, + int flags, + const ACE_Time_Value *timeout = 0); + + extern ACE_Export ssize_t sendto (ACE_HANDLE handle, + const char *buf, + int len, + int flags, + const struct sockaddr *addr, + int addrlen, + const ACE_Time_Value *timeout = 0); + + ACE_NAMESPACE_INLINE_FUNCTION + ssize_t send_n (ACE_HANDLE handle, + const void *buf, + size_t len, + int flags, + const ACE_Time_Value *timeout = 0, + size_t *bytes_transferred = 0); + +#if defined (ACE_HAS_TLI) + + ACE_NAMESPACE_INLINE_FUNCTION + ssize_t t_snd_n (ACE_HANDLE handle, + const void *buf, + size_t len, + int flags, + const ACE_Time_Value *timeout = 0, + size_t *bytes_transferred = 0); + +#endif /* ACE_HAS_TLI */ + + ACE_NAMESPACE_INLINE_FUNCTION + ssize_t send_n (ACE_HANDLE handle, + const void *buf, + size_t len, + const ACE_Time_Value *timeout = 0, + size_t *bytes_transferred = 0); + + /// Varargs variant. + extern ACE_Export ssize_t send (ACE_HANDLE handle, size_t n, ...); + + extern ACE_Export ssize_t sendv (ACE_HANDLE handle, + const iovec *iov, + int iovcnt, + const ACE_Time_Value *timeout = 0); + + ACE_NAMESPACE_INLINE_FUNCTION + ssize_t sendv_n (ACE_HANDLE handle, + const iovec *iov, + int iovcnt, + const ACE_Time_Value *timeout = 0, + size_t *bytes_transferred = 0); + + /// Send all the @a message_blocks chained through their @c next and + /// @c cont pointers. This call uses the underlying OS gather-write + /// operation to reduce the domain-crossing penalty. + extern ACE_Export ssize_t send_n (ACE_HANDLE handle, + const ACE_Message_Block *message_block, + const ACE_Time_Value *timeout = 0, + size_t *bytes_transferred = 0); + + // = File system I/O functions (these don't support timeouts). + + ACE_NAMESPACE_INLINE_FUNCTION + ssize_t read_n (ACE_HANDLE handle, + void *buf, + size_t len, + size_t *bytes_transferred = 0); + + ACE_NAMESPACE_INLINE_FUNCTION + ssize_t write_n (ACE_HANDLE handle, + const void *buf, + size_t len, + size_t *bytes_transferred = 0); + + /// Write all the @a message_blocks chained through their @c next + /// and @c cont pointers. This call uses the underlying OS + /// gather-write operation to reduce the domain-crossing penalty. + extern ACE_Export ssize_t write_n (ACE_HANDLE handle, + const ACE_Message_Block *message_block, + size_t *bytes_transferred = 0); + + extern ACE_Export ssize_t readv_n (ACE_HANDLE handle, + iovec *iov, + int iovcnt, + size_t *bytes_transferred = 0); + + extern ACE_Export ssize_t writev_n (ACE_HANDLE handle, + const iovec *iov, + int iovcnt, + size_t *bytes_transferred = 0); + //@} + + /** + * Wait up to @a timeout amount of time to passively establish a + * connection. This method doesn't perform the @c accept, it just + * does the timed wait. + */ + extern ACE_Export int handle_timed_accept (ACE_HANDLE listener, + ACE_Time_Value *timeout, + int restart); + + /** + * Wait up to @a timeout amount of time to complete an actively + * established non-blocking connection. If @a is_tli is non-0 then + * we are being called by a TLI wrapper (which behaves slightly + * differently from a socket wrapper). + */ + extern ACE_Export ACE_HANDLE handle_timed_complete ( + ACE_HANDLE listener, + const ACE_Time_Value *timeout, + int is_tli = 0); + + /** + * Reset the limit on the number of open handles. If @a new_limit + * == -1 set the limit to the maximum allowable. Otherwise, set + * the limit value to @a new_limit. If @a increase_limit_only is + * non-0 then only allow increases to the limit. + */ + extern ACE_Export int set_handle_limit (int new_limit = -1, + int increase_limit_only = 0); + + /** + * Returns the maximum number of open handles currently permitted in + * this process. This maximum may be extended using + * @c ACE::set_handle_limit. + */ + extern ACE_Export int max_handles (void); + + // = String functions +#if !defined (ACE_HAS_WINCE) + /** + * Return a dynamically allocated duplicate of @a str, substituting + * the environment variable if @c str[0] @c == @c '$'. Note that + * the pointer is allocated with @c ACE_OS::malloc and must be freed + * by @c ACE_OS::free. + */ + extern ACE_Export ACE_TCHAR *strenvdup (const ACE_TCHAR *str); +#endif /* ACE_HAS_WINCE */ + + /// Returns a pointer to the "end" of the string, i.e., the character + /// past the '\0'. + extern ACE_Export const char *strend (const char *s); + + /// This method is just like @c strdup, except that it uses + /// @c operator @c new rather than @c malloc. If @a s is NULL + /// returns NULL rather than segfaulting. + extern ACE_Export char *strnew (const char *s); + + /// Delete the memory allocated by @c strnew. + ACE_NAMESPACE_INLINE_FUNCTION void strdelete (char *s); + + /// Create a fresh new copy of @a str, up to @a n chars long. Uses + /// @c ACE_OS::malloc to allocate the new string. + extern ACE_Export char *strndup (const char *str, size_t n); + + /// Create a fresh new copy of @a str, up to @a n chars long. Uses + /// @c ACE_OS::malloc to allocate the new string. + extern ACE_Export char *strnnew (const char *str, size_t n); + +#if defined (ACE_HAS_WCHAR) + extern ACE_Export const wchar_t *strend (const wchar_t *s); + + extern ACE_Export wchar_t *strnew (const wchar_t *s); + + ACE_NAMESPACE_INLINE_FUNCTION void strdelete (wchar_t *s); + + extern ACE_Export wchar_t *strndup (const wchar_t *str, size_t n); + + extern ACE_Export wchar_t *strnnew (const wchar_t *str, size_t n); + +#endif /* ACE_HAS_WCHAR */ + + /** + * On Windows, determines if a specified pathname ends with ".exe" + * (not case sensitive). If on Windows and there is no ".exe" suffix, + * a new ACE_TCHAR array is allocated and a copy of @c pathname with + * the ".exe" suffix is copied into it. In this case, the caller is + * responsible for calling delete [] on the returned pointer. + * + * @param pathname The name to check for a proper suffix. + * + * @retval @c pathname if there is a proper suffix for Windows. This is + * always the return value for non-Windows platforms. + * @retval If a suffix needs to be added, returns a pointer to new[] + * allocated memory containing the original @c pathname plus + * a ".exe" suffix. The caller is responsible for freeing the + * memory using delete []. + */ + extern ACE_Export const ACE_TCHAR *execname (const ACE_TCHAR *pathname); + + /** + * Returns the "basename" of a @a pathname separated by @a delim. + * For instance, the basename of "/tmp/foo.cpp" is "foo.cpp" when + * @a delim is @a '/'. + */ + extern ACE_Export const ACE_TCHAR *basename (const ACE_TCHAR *pathname, + ACE_TCHAR delim = + ACE_DIRECTORY_SEPARATOR_CHAR); + + /** + * Returns the "dirname" of a @a pathname. For instance, the + * dirname of "/tmp/foo.cpp" is "/tmp" when @a delim is @a '/'. If + * @a pathname has no @a delim ".\0" is returned. This method does + * not modify @a pathname and is not reentrant. + */ + extern ACE_Export const ACE_TCHAR *dirname (const ACE_TCHAR *pathname, + ACE_TCHAR delim = + ACE_DIRECTORY_SEPARATOR_CHAR); + + /** + * Returns the current timestamp in the form + * "hour:minute:second:microsecond." The month, day, and year are + * also stored in the beginning of the @a date_and_time array, which + * is a user-supplied array of size @a time_len> @c ACE_TCHARs. + * Returns 0 if unsuccessful, else returns pointer to beginning of the + * "time" portion of @a date_and_time. If @a + * return_pointer_to_first_digit is 0 then return a pointer to the + * space before the time, else return a pointer to the beginning of + * the time portion. + */ + extern ACE_Export ACE_TCHAR *timestamp (ACE_TCHAR date_and_time[], + size_t time_len, + bool return_pointer_to_first_digit = false); + + /** + * if @a avoid_zombies == 0 call @c ACE_OS::fork directly, else + * create an orphan process that's inherited by the init process; + * init cleans up when the orphan process terminates so we don't + * create zombies. Returns -1 on failure and either the child PID + * on success if @a avoid_zombies == 0 or 1 on success if @a + * avoid_zombies != 0 (this latter behavior is a known bug that + * needs to be fixed). + */ + extern ACE_Export pid_t fork ( + const ACE_TCHAR *program_name = ACE_TEXT (""), + int avoid_zombies = 0); + + /** + * Become a daemon process using the algorithm in Richard Stevens + * "Advanced Programming in the UNIX Environment." If + * @a close_all_handles is non-zero then all open file handles are + * closed. + */ + extern ACE_Export int daemonize ( + const ACE_TCHAR pathname[] = ACE_TEXT ("/"), + bool close_all_handles = ACE_DEFAULT_CLOSE_ALL_HANDLES, + const ACE_TCHAR program_name[] = ACE_TEXT ("")); + + // = Miscellaneous functions. + /// Rounds the request to a multiple of the page size. + extern ACE_Export size_t round_to_pagesize (size_t len); + + /// Rounds the request to a multiple of the allocation granularity. + extern ACE_Export size_t round_to_allocation_granularity (size_t len); + + // @@ UNICODE what about buffer? + /// Format buffer into printable format. This is useful for + /// debugging. + extern ACE_Export size_t format_hexdump (const char *buffer, size_t size, + ACE_TCHAR *obuf, size_t obuf_sz); + + /// Computes the hash value of {str} using the "Hash PJW" routine. + extern ACE_Export u_long hash_pjw (const char *str); + + /// Computes the hash value of {str} using the "Hash PJW" routine. + extern ACE_Export u_long hash_pjw (const char *str, size_t len); + +#if defined (ACE_HAS_WCHAR) + /// Computes the hash value of {str} using the "Hash PJW" routine. + extern ACE_Export u_long hash_pjw (const wchar_t *str); + + /// Computes the hash value of {str} using the "Hash PJW" routine. + extern ACE_Export u_long hash_pjw (const wchar_t *str, size_t len); +#endif /* ACE_HAS_WCHAR */ + + /// Computes CRC-CCITT for the string. + extern ACE_Export ACE_UINT16 crc_ccitt(const char *str); + + /// Computes CRC-CCITT for the buffer. + extern ACE_Export ACE_UINT16 crc_ccitt(const void *buf, size_t len, + ACE_UINT16 crc = 0); + + /// Computes CRC-CCITT for the @ len iovec buffers. + extern ACE_Export ACE_UINT16 crc_ccitt(const iovec *iov, int len, + ACE_UINT16 crc = 0); + + /// Computes the ISO 8802-3 standard 32 bits CRC for the string. + extern ACE_Export ACE_UINT32 crc32 (const char *str); + + /// Computes the ISO 8802-3 standard 32 bits CRC for the buffer. + extern ACE_Export ACE_UINT32 crc32 (const void *buf, size_t len, + ACE_UINT32 crc = 0); + + /// Computes the ISO 8802-3 standard 32 bits CRC for the + /// @ len iovec buffers. + extern ACE_Export ACE_UINT32 crc32 (const iovec *iov, int len, + ACE_UINT32 crc = 0); + + /// Euclid's greatest common divisor algorithm. + extern ACE_Export u_long gcd (u_long x, u_long y); + + /// Calculates the minimum enclosing frame size for the given values. + extern ACE_Export u_long minimum_frame_size (u_long period1, u_long period2); + + /** + * Function that can burn up noticeable CPU time: brute-force + * determination of whether number @a n is prime. Returns 0 if + * it is prime, or the smallest factor if it is not prime. + * @a min_factor and @a max_factor can be used to partition the work + * among threads. For just one thread, typical values are 2 and + * n/2. + */ + extern ACE_Export u_long is_prime (const u_long n, + const u_long min_factor, + const u_long max_factor); + + /// Map troublesome win32 errno values to values that standard C + /// strerr function understands. Thank you Microsoft. + extern ACE_Export int map_errno (int error); + + /// Returns a string containing the error message corresponding to a + /// WinSock error. This works around an omission in the Win32 API. + /// @internal + extern ACE_Export const ACE_TCHAR * sock_error (int error); + + /// Determins whether the given error code corresponds to to a + /// WinSock error. If so returns true, false otherwise. + /// @internal + extern ACE_Export bool is_sock_error (int error); + + /** + * Checks if process with {pid} is still alive. Returns 1 if it is + * still alive, 0 if it isn't alive, and -1 if something weird + * happened. + */ + extern ACE_Export int process_active (pid_t pid); + + /** + * Terminate the process abruptly with id @a pid. On Win32 platforms + * this uses {TerminateProcess} and on POSIX platforms is uses + * {kill} with the -9 (SIGKILL) signal, which cannot be caught or + * ignored. Note that this call is potentially dangerous to use + * since the process being terminated may not have a chance to + * cleanup before it shuts down. + */ + extern ACE_Export int terminate_process (pid_t pid); + + /** + * This method uses process id and object pointer to come up with a + * machine wide unique name. The process ID will provide uniqueness + * between processes on the same machine. The "this" pointer of the + * {object} will provide uniqueness between other "live" objects in + * the same process. The uniqueness of this name is therefore only + * valid for the life of {object}. + */ + ACE_NAMESPACE_INLINE_FUNCTION void unique_name (const void *object, + ACE_TCHAR *name, + size_t length); + + /// Computes the base 2 logarithm of {num}. + ACE_NAMESPACE_INLINE_FUNCTION u_long log2 (u_long num); + + /// Hex conversion utility. + ACE_NAMESPACE_INLINE_FUNCTION ACE_TCHAR nibble2hex (u_int n); + + /// Convert a hex character to its byte representation. + ACE_NAMESPACE_INLINE_FUNCTION u_char hex2byte (ACE_TCHAR c); + + // = Set/get the debug level. + extern ACE_Export bool debug (void); + extern ACE_Export void debug (bool onoff); + + /// Wrapper facade for @c select that uses @c ACE_Handle_Sets. + extern ACE_Export int select (int width, + ACE_Handle_Set *readfds, + ACE_Handle_Set *writefds = 0, + ACE_Handle_Set *exceptfds = 0, + const ACE_Time_Value *timeout = 0); + + /// Wrapper facade for the most common use of @c select that uses + /// @c ACE_Handle_Sets. + extern ACE_Export int select (int width, + ACE_Handle_Set &readfds, + const ACE_Time_Value *timeout = 0); + + /// Timed wait for handle to get read ready. + ACE_NAMESPACE_INLINE_FUNCTION + int handle_read_ready (ACE_HANDLE handle, + const ACE_Time_Value *timeout); + + /// Timed wait for handle to get write ready. + ACE_NAMESPACE_INLINE_FUNCTION + int handle_write_ready (ACE_HANDLE handle, + const ACE_Time_Value *timeout); + + /// Timed wait for handle to get exception ready. + ACE_NAMESPACE_INLINE_FUNCTION + int handle_exception_ready (ACE_HANDLE handle, + const ACE_Time_Value *timeout); + + /// Timed wait for handle to get read, write, or exception ready. + extern ACE_Export int handle_ready (ACE_HANDLE handle, + const ACE_Time_Value *timeout, + int read_ready, + int write_ready, + int exception_ready); + + /// Wait for @a timeout before proceeding to a @c recv operation. + /// @a val keeps track of whether we're in non-blocking mode or + /// not. + extern ACE_Export int enter_recv_timedwait (ACE_HANDLE handle, + const ACE_Time_Value *timeout, + int &val); + + /// Wait for @a timeout before proceeding to a @c send operation. + /// @a val keeps track of whether we're in non-blocking mode or + /// not. + extern ACE_Export int enter_send_timedwait (ACE_HANDLE handle, + const ACE_Time_Value* timeout, + int &val); + + /// This makes sure that @a handle is set into non-blocking mode. + /// @a val keeps track of whether were in non-blocking mode or not. + extern ACE_Export void record_and_set_non_blocking_mode (ACE_HANDLE handle, + int &val); + + /// Cleanup after a timed operation, restore the appropriate + /// non-blocking status of @a handle. + extern ACE_Export void restore_non_blocking_mode (ACE_HANDLE handle, + int val); + + // private: + // These functions aren't meant to be used internally, so they are + // not exported. + + // + // = Recv_n helpers + // + + ACE_NAMESPACE_INLINE_FUNCTION ssize_t recv_i (ACE_HANDLE handle, + void *buf, + size_t len); + + extern ACE_Export ssize_t recv_n_i (ACE_HANDLE handle, + void *buf, + size_t len, + int flags, + size_t *bytes_transferred); + + extern ACE_Export ssize_t recv_n_i (ACE_HANDLE handle, + void *buf, + size_t len, + int flags, + const ACE_Time_Value *timeout, + size_t *bytes_transferred); + +#if defined (ACE_HAS_TLI) + + extern ACE_Export ssize_t t_rcv_n_i (ACE_HANDLE handle, + void *buf, + size_t len, + int *flags, + size_t *bytes_transferred); + + extern ACE_Export ssize_t t_rcv_n_i (ACE_HANDLE handle, + void *buf, + size_t len, + int *flags, + const ACE_Time_Value *timeout, + size_t *bytes_transferred); + +#endif /* ACE_HAS_TLI */ + + extern ACE_Export ssize_t recv_n_i (ACE_HANDLE handle, + void *buf, + size_t len, + size_t *bytes_transferred); + + extern ACE_Export ssize_t recv_n_i (ACE_HANDLE handle, + void *buf, + size_t len, + const ACE_Time_Value *timeout, + size_t *bytes_transferred); + + extern ACE_Export ssize_t recvv_n_i (ACE_HANDLE handle, + iovec *iov, + int iovcnt, + size_t *bytes_transferred); + + extern ACE_Export ssize_t recvv_n_i (ACE_HANDLE handle, + iovec *iov, + int iovcnt, + const ACE_Time_Value *timeout, + size_t *bytes_transferred); + + // + // = Send_n helpers + // + + ACE_NAMESPACE_INLINE_FUNCTION ssize_t send_i (ACE_HANDLE handle, + const void *buf, + size_t len); + + extern ACE_Export ssize_t send_n_i (ACE_HANDLE handle, + const void *buf, + size_t len, + int flags, + size_t *bytes_transferred); + + extern ACE_Export ssize_t send_n_i (ACE_HANDLE handle, + const void *buf, + size_t len, + int flags, + const ACE_Time_Value *timeout, + size_t *bytes_transferred); + +#if defined (ACE_HAS_TLI) + + extern ACE_Export ssize_t t_snd_n_i (ACE_HANDLE handle, + const void *buf, + size_t len, + int flags, + size_t *bytes_transferred); + + extern ACE_Export ssize_t t_snd_n_i (ACE_HANDLE handle, + const void *buf, + size_t len, + int flags, + const ACE_Time_Value *timeout, + size_t *bytes_transferred); + +#endif /* ACE_HAS_TLI */ + + extern ACE_Export ssize_t send_n_i (ACE_HANDLE handle, + const void *buf, + size_t len, + size_t *bytes_transferred); + + extern ACE_Export ssize_t send_n_i (ACE_HANDLE handle, + const void *buf, + size_t len, + const ACE_Time_Value *timeout, + size_t *bytes_transferred); + + extern ACE_Export ssize_t sendv_n_i (ACE_HANDLE handle, + const iovec *iov, + int iovcnt, + size_t *bytes_transferred); + + extern ACE_Export ssize_t sendv_n_i (ACE_HANDLE handle, + const iovec *iov, + int iovcnt, + const ACE_Time_Value *timeout, + size_t *bytes_transferred); + +} + +// Close versioned namespace, if enabled by the user. +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +#include "ace/ACE.inl" +#endif /* __ACE_INLINE__ */ + +#include /**/ "ace/post.h" + +#endif /* ACE_ACE_H */ diff --git a/dep/ACE_wrappers/ace/ACE.inl b/dep/ACE_wrappers/ace/ACE.inl new file mode 100644 index 00000000000..f800ac80a32 --- /dev/null +++ b/dep/ACE_wrappers/ace/ACE.inl @@ -0,0 +1,350 @@ +// -*- C++ -*- +// +// $Id: ACE.inl 80826 2008-03-04 14:51:23Z wotte $ + +#include "ace/OS_NS_unistd.h" +#include "ace/OS_NS_Thread.h" +#include "ace/OS_NS_ctype.h" +#include "ace/OS_NS_sys_socket.h" + +// Open versioned namespace, if enabled by the user. +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + + +// Wrappers for methods that have been moved to ACE_OS. + +ACE_INLINE ssize_t +ACE::read_n (ACE_HANDLE handle, + void *buf, + size_t len, + size_t *bytes_transferred) +{ + return ACE_OS::read_n (handle, + buf, + len, + bytes_transferred); +} + +ACE_INLINE ssize_t +ACE::write_n (ACE_HANDLE handle, + const void *buf, + size_t len, + size_t *bytes_transferred) +{ + return ACE_OS::write_n (handle, + buf, + len, + bytes_transferred); +} + +ACE_INLINE ssize_t +ACE::recv_n (ACE_HANDLE handle, + void *buf, + size_t len, + int flags, + const ACE_Time_Value *timeout, + size_t *bytes_transferred) +{ + if (timeout == 0) + return ACE::recv_n_i (handle, + buf, + len, + flags, + bytes_transferred); + else + return ACE::recv_n_i (handle, + buf, + len, + flags, + timeout, + bytes_transferred); +} + +#if defined (ACE_HAS_TLI) + +ACE_INLINE ssize_t +ACE::t_rcv_n (ACE_HANDLE handle, + void *buf, + size_t len, + int *flags, + const ACE_Time_Value *timeout, + size_t *bytes_transferred) +{ + if (timeout == 0) + return ACE::t_rcv_n_i (handle, + buf, + len, + flags, + bytes_transferred); + else + return ACE::t_rcv_n_i (handle, + buf, + len, + flags, + timeout, + bytes_transferred); +} + +#endif /* ACE_HAS_TLI */ + +ACE_INLINE ssize_t +ACE::recv_n (ACE_HANDLE handle, + void *buf, + size_t len, + const ACE_Time_Value *timeout, + size_t *bytes_transferred) +{ + if (timeout == 0) + return ACE::recv_n_i (handle, + buf, + len, + bytes_transferred); + else + return ACE::recv_n_i (handle, + buf, + len, + timeout, + bytes_transferred); +} + +ACE_INLINE ssize_t +ACE::recvv_n (ACE_HANDLE handle, + iovec *iov, + int iovcnt, + const ACE_Time_Value *timeout, + size_t *bytes_transferred) +{ + if (timeout == 0) + return ACE::recvv_n_i (handle, + iov, + iovcnt, + bytes_transferred); + else + return ACE::recvv_n_i (handle, + iov, + iovcnt, + timeout, + bytes_transferred); +} + +ACE_INLINE ssize_t +ACE::send_n (ACE_HANDLE handle, + const void *buf, + size_t len, + int flags, + const ACE_Time_Value *timeout, + size_t *bytes_transferred) +{ + if (timeout == 0) + return ACE::send_n_i (handle, + buf, + len, + flags, + bytes_transferred); + else + return ACE::send_n_i (handle, + buf, + len, + flags, + timeout, + bytes_transferred); +} + +#if defined (ACE_HAS_TLI) + +ACE_INLINE ssize_t +ACE::t_snd_n (ACE_HANDLE handle, + const void *buf, + size_t len, + int flags, + const ACE_Time_Value *timeout, + size_t *bytes_transferred) +{ + if (timeout == 0) + return ACE::t_snd_n_i (handle, + buf, + len, + flags, + bytes_transferred); + else + return ACE::t_snd_n_i (handle, + buf, + len, + flags, + timeout, + bytes_transferred); +} + +#endif /* ACE_HAS_TLI */ + +ACE_INLINE ssize_t +ACE::send_n (ACE_HANDLE handle, + const void *buf, + size_t len, + const ACE_Time_Value *timeout, + size_t *bytes_transferred) +{ + if (timeout == 0) + return ACE::send_n_i (handle, + buf, + len, + bytes_transferred); + else + return ACE::send_n_i (handle, + buf, + len, + timeout, + bytes_transferred); +} + +ACE_INLINE ssize_t +ACE::sendv_n (ACE_HANDLE handle, + const iovec *iov, + int iovcnt, + const ACE_Time_Value *timeout, + size_t *bytes_transferred) +{ + if (timeout == 0) + return ACE::sendv_n_i (handle, + iov, + iovcnt, + bytes_transferred); + else + return ACE::sendv_n_i (handle, + iov, + iovcnt, + timeout, + bytes_transferred); +} + +ACE_INLINE ssize_t +ACE::send_i (ACE_HANDLE handle, const void *buf, size_t len) +{ +#if defined (ACE_WIN32) || defined (HPUX) + return ACE_OS::send (handle, (const char *) buf, len); +#else + return ACE_OS::write (handle, (const char *) buf, len); +#endif /* ACE_WIN32 */ +} + +ACE_INLINE ssize_t +ACE::recv_i (ACE_HANDLE handle, void *buf, size_t len) +{ +#if defined (ACE_WIN32) || defined (ACE_OPENVMS) || defined (ACE_TANDEM_T1248_PTHREADS) + return ACE_OS::recv (handle, (char *) buf, len); +#else + return ACE_OS::read (handle, (char *) buf, len); +#endif /* ACE_WIN32 */ +} + +ACE_INLINE int +ACE::handle_read_ready (ACE_HANDLE handle, + const ACE_Time_Value *timeout) +{ + return ACE::handle_ready (handle, + timeout, + 1, + 0, + 0); +} + +ACE_INLINE int +ACE::handle_write_ready (ACE_HANDLE handle, + const ACE_Time_Value *timeout) +{ + return ACE::handle_ready (handle, + timeout, + 0, + 1, + 0); +} + +ACE_INLINE int +ACE::handle_exception_ready (ACE_HANDLE handle, + const ACE_Time_Value *timeout) +{ + return ACE::handle_ready (handle, + timeout, + 0, + 0, + 1); +} + +ACE_INLINE void +ACE::strdelete (char *s) +{ + delete [] s; +} + +#if defined (ACE_HAS_WCHAR) +ACE_INLINE void +ACE::strdelete (wchar_t *s) +{ + delete [] s; +} +#endif /* ACE_HAS_WCHAR */ + +ACE_INLINE void +ACE::unique_name (const void *object, + ACE_TCHAR *name, + size_t length) +{ + ACE_OS::unique_name (object, name, length); +} + +ACE_INLINE u_long +ACE::log2 (u_long num) +{ + u_long log = 0; + + for (; num > 1; ++log) + num >>= 1; + + return log; +} + +ACE_INLINE ACE_TCHAR +ACE::nibble2hex (u_int n) +{ + // Hexadecimal characters. +#if defined (ACE_VXWORKS) && !defined (__DCPLUSPLUS__) + // temporary solution to prevent Windriver GNU toolchains from spewing + // loads of warnings when inlining. + // problem (incorrect warning leftover from older GNU) has been reported as + // TSR to Windriver. + const ACE_TCHAR hex_chars[] = ACE_TEXT ("0123456789abcdef"); +#else + static const ACE_TCHAR hex_chars[] = ACE_TEXT ("0123456789abcdef"); +#endif + + // Yes, this works for UNICODE + return hex_chars[n & 0x0f]; +} + +ACE_INLINE int +ACE::map_errno (int error) +{ +#if defined (ACE_WIN32) + switch (error) + { + case WSAEWOULDBLOCK: + return EAGAIN; // Same as UNIX errno EWOULDBLOCK. + } +#endif /* ACE_WIN32 */ + + return error; +} + +ACE_INLINE u_char +ACE::hex2byte (ACE_TCHAR c) +{ + if (ACE_OS::ace_isdigit (c)) + return (u_char) (c - ACE_TEXT ('0')); + else if (ACE_OS::ace_islower (c)) + return (u_char) (10 + c - ACE_TEXT ('a')); + else + return (u_char) (10 + c - ACE_TEXT ('A')); +} + +// Close versioned namespace, if enabled by the user. +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/ACE_crc32.cpp b/dep/ACE_wrappers/ace/ACE_crc32.cpp new file mode 100644 index 00000000000..70d93e6b598 --- /dev/null +++ b/dep/ACE_wrappers/ace/ACE_crc32.cpp @@ -0,0 +1,161 @@ +// $Id: ACE_crc32.cpp 80826 2008-03-04 14:51:23Z wotte $ + +#include "ace/ACE.h" + +ACE_RCSID (ace, + ACE_crc32, + "$Id: ACE_crc32.cpp 80826 2008-03-04 14:51:23Z wotte $") + + +namespace +{ + /*****************************************************************/ + /* */ + /* CRC LOOKUP TABLE */ + /* ================ */ + /* The following CRC lookup table was generated automagically */ + /* by the Rocksoft^tm Model CRC Algorithm Table Generation */ + /* Program V1.0 using the following model parameters: */ + /* */ + /* Width : 4 bytes. */ + /* Poly : 0x04C11DB7L */ + /* Reverse : TRUE. */ + /* */ + /* For more information on the Rocksoft^tm Model CRC Algorithm, */ + /* see the document titled "A Painless Guide to CRC Error */ + /* Detection Algorithms" by Ross Williams */ + /* (ross@guest.adelaide.edu.au.). This document is likely to be */ + /* in the FTP archive "ftp.adelaide.edu.au/pub/rocksoft". */ + /* */ + /*****************************************************************/ + + const ACE_UINT32 crc_table[] = + { + 0x00000000L, 0x77073096L, 0xEE0E612CL, 0x990951BAL, + 0x076DC419L, 0x706AF48FL, 0xE963A535L, 0x9E6495A3L, + 0x0EDB8832L, 0x79DCB8A4L, 0xE0D5E91EL, 0x97D2D988L, + 0x09B64C2BL, 0x7EB17CBDL, 0xE7B82D07L, 0x90BF1D91L, + 0x1DB71064L, 0x6AB020F2L, 0xF3B97148L, 0x84BE41DEL, + 0x1ADAD47DL, 0x6DDDE4EBL, 0xF4D4B551L, 0x83D385C7L, + 0x136C9856L, 0x646BA8C0L, 0xFD62F97AL, 0x8A65C9ECL, + 0x14015C4FL, 0x63066CD9L, 0xFA0F3D63L, 0x8D080DF5L, + 0x3B6E20C8L, 0x4C69105EL, 0xD56041E4L, 0xA2677172L, + 0x3C03E4D1L, 0x4B04D447L, 0xD20D85FDL, 0xA50AB56BL, + 0x35B5A8FAL, 0x42B2986CL, 0xDBBBC9D6L, 0xACBCF940L, + 0x32D86CE3L, 0x45DF5C75L, 0xDCD60DCFL, 0xABD13D59L, + 0x26D930ACL, 0x51DE003AL, 0xC8D75180L, 0xBFD06116L, + 0x21B4F4B5L, 0x56B3C423L, 0xCFBA9599L, 0xB8BDA50FL, + 0x2802B89EL, 0x5F058808L, 0xC60CD9B2L, 0xB10BE924L, + 0x2F6F7C87L, 0x58684C11L, 0xC1611DABL, 0xB6662D3DL, + 0x76DC4190L, 0x01DB7106L, 0x98D220BCL, 0xEFD5102AL, + 0x71B18589L, 0x06B6B51FL, 0x9FBFE4A5L, 0xE8B8D433L, + 0x7807C9A2L, 0x0F00F934L, 0x9609A88EL, 0xE10E9818L, + 0x7F6A0DBBL, 0x086D3D2DL, 0x91646C97L, 0xE6635C01L, + 0x6B6B51F4L, 0x1C6C6162L, 0x856530D8L, 0xF262004EL, + 0x6C0695EDL, 0x1B01A57BL, 0x8208F4C1L, 0xF50FC457L, + 0x65B0D9C6L, 0x12B7E950L, 0x8BBEB8EAL, 0xFCB9887CL, + 0x62DD1DDFL, 0x15DA2D49L, 0x8CD37CF3L, 0xFBD44C65L, + 0x4DB26158L, 0x3AB551CEL, 0xA3BC0074L, 0xD4BB30E2L, + 0x4ADFA541L, 0x3DD895D7L, 0xA4D1C46DL, 0xD3D6F4FBL, + 0x4369E96AL, 0x346ED9FCL, 0xAD678846L, 0xDA60B8D0L, + 0x44042D73L, 0x33031DE5L, 0xAA0A4C5FL, 0xDD0D7CC9L, + 0x5005713CL, 0x270241AAL, 0xBE0B1010L, 0xC90C2086L, + 0x5768B525L, 0x206F85B3L, 0xB966D409L, 0xCE61E49FL, + 0x5EDEF90EL, 0x29D9C998L, 0xB0D09822L, 0xC7D7A8B4L, + 0x59B33D17L, 0x2EB40D81L, 0xB7BD5C3BL, 0xC0BA6CADL, + 0xEDB88320L, 0x9ABFB3B6L, 0x03B6E20CL, 0x74B1D29AL, + 0xEAD54739L, 0x9DD277AFL, 0x04DB2615L, 0x73DC1683L, + 0xE3630B12L, 0x94643B84L, 0x0D6D6A3EL, 0x7A6A5AA8L, + 0xE40ECF0BL, 0x9309FF9DL, 0x0A00AE27L, 0x7D079EB1L, + 0xF00F9344L, 0x8708A3D2L, 0x1E01F268L, 0x6906C2FEL, + 0xF762575DL, 0x806567CBL, 0x196C3671L, 0x6E6B06E7L, + 0xFED41B76L, 0x89D32BE0L, 0x10DA7A5AL, 0x67DD4ACCL, + 0xF9B9DF6FL, 0x8EBEEFF9L, 0x17B7BE43L, 0x60B08ED5L, + 0xD6D6A3E8L, 0xA1D1937EL, 0x38D8C2C4L, 0x4FDFF252L, + 0xD1BB67F1L, 0xA6BC5767L, 0x3FB506DDL, 0x48B2364BL, + 0xD80D2BDAL, 0xAF0A1B4CL, 0x36034AF6L, 0x41047A60L, + 0xDF60EFC3L, 0xA867DF55L, 0x316E8EEFL, 0x4669BE79L, + 0xCB61B38CL, 0xBC66831AL, 0x256FD2A0L, 0x5268E236L, + 0xCC0C7795L, 0xBB0B4703L, 0x220216B9L, 0x5505262FL, + 0xC5BA3BBEL, 0xB2BD0B28L, 0x2BB45A92L, 0x5CB36A04L, + 0xC2D7FFA7L, 0xB5D0CF31L, 0x2CD99E8BL, 0x5BDEAE1DL, + 0x9B64C2B0L, 0xEC63F226L, 0x756AA39CL, 0x026D930AL, + 0x9C0906A9L, 0xEB0E363FL, 0x72076785L, 0x05005713L, + 0x95BF4A82L, 0xE2B87A14L, 0x7BB12BAEL, 0x0CB61B38L, + 0x92D28E9BL, 0xE5D5BE0DL, 0x7CDCEFB7L, 0x0BDBDF21L, + 0x86D3D2D4L, 0xF1D4E242L, 0x68DDB3F8L, 0x1FDA836EL, + 0x81BE16CDL, 0xF6B9265BL, 0x6FB077E1L, 0x18B74777L, + 0x88085AE6L, 0xFF0F6A70L, 0x66063BCAL, 0x11010B5CL, + 0x8F659EFFL, 0xF862AE69L, 0x616BFFD3L, 0x166CCF45L, + 0xA00AE278L, 0xD70DD2EEL, 0x4E048354L, 0x3903B3C2L, + 0xA7672661L, 0xD06016F7L, 0x4969474DL, 0x3E6E77DBL, + 0xAED16A4AL, 0xD9D65ADCL, 0x40DF0B66L, 0x37D83BF0L, + 0xA9BCAE53L, 0xDEBB9EC5L, 0x47B2CF7FL, 0x30B5FFE9L, + 0xBDBDF21CL, 0xCABAC28AL, 0x53B39330L, 0x24B4A3A6L, + 0xBAD03605L, 0xCDD70693L, 0x54DE5729L, 0x23D967BFL, + 0xB3667A2EL, 0xC4614AB8L, 0x5D681B02L, 0x2A6F2B94L, + 0xB40BBE37L, 0xC30C8EA1L, 0x5A05DF1BL, 0x2D02EF8DL + }; + + /*****************************************************************/ + /* End of CRC Lookup Table */ + /*****************************************************************/ +} + +#define COMPUTE(var, ch) (var) = (crc_table[(var ^ ch) & 0xFF] ^ (var >> 8)) + +// Open versioned namespace, if enabled by the user. +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_UINT32 +ACE::crc32 (const char *string) +{ + ACE_UINT32 crc = 0xFFFFFFFF; + + for (const char *p = string; + *p != 0; + ++p) + { + COMPUTE (crc, *p); + } + + return ~crc; +} + +ACE_UINT32 +ACE::crc32 (const void *buffer, size_t len, ACE_UINT32 crc) +{ + crc = ~crc; + + for (const char *p = (const char *) buffer, + *e = (const char *) buffer + len; + p != e; + ++p) + { + COMPUTE (crc, *p); + } + + return ~crc; +} + +ACE_UINT32 +ACE::crc32 (const iovec *iov, int len, ACE_UINT32 crc) +{ + crc = ~crc; + + for (int i = 0; i < len; ++i) + { + for (const char *p = (const char *) iov[i].iov_base, + *e = (const char *) iov[i].iov_base + iov[i].iov_len; + p != e; + ++p) + COMPUTE (crc, *p); + } + + return ~crc; +} + +// Close versioned namespace, if enabled by the user. +ACE_END_VERSIONED_NAMESPACE_DECL + +#undef COMPUTE diff --git a/dep/ACE_wrappers/ace/ACE_crc_ccitt.cpp b/dep/ACE_wrappers/ace/ACE_crc_ccitt.cpp new file mode 100644 index 00000000000..ef7f5d65bd1 --- /dev/null +++ b/dep/ACE_wrappers/ace/ACE_crc_ccitt.cpp @@ -0,0 +1,128 @@ +// $Id: ACE_crc_ccitt.cpp 80826 2008-03-04 14:51:23Z wotte $ + +#include "ace/ACE.h" + +ACE_RCSID (ace, + ACE_crc_ccitt, + "$Id: ACE_crc_ccitt.cpp 80826 2008-03-04 14:51:23Z wotte $") + +namespace +{ + /*****************************************************************/ + /* */ + /* CRC LOOKUP TABLE */ + /* ================ */ + /* The following CRC lookup table was generated automagically */ + /* by the Rocksoft^tm Model CRC Algorithm Table Generation */ + /* Program V1.0 using the following model parameters: */ + /* */ + /* Width : 2 bytes. */ + /* Poly : 0x1021 */ + /* Reverse : TRUE. */ + /* */ + /* For more information on the Rocksoft^tm Model CRC Algorithm, */ + /* see the document titled "A Painless Guide to CRC Error */ + /* Detection Algorithms" by Ross Williams */ + /* (ross@guest.adelaide.edu.au.). This document is likely to be */ + /* in the FTP archive "ftp.adelaide.edu.au/pub/rocksoft". */ + /* */ + /*****************************************************************/ + + const ACE_UINT16 crc_table[] = + { + 0x0000, 0x1189, 0x2312, 0x329B, 0x4624, 0x57AD, 0x6536, 0x74BF, + 0x8C48, 0x9DC1, 0xAF5A, 0xBED3, 0xCA6C, 0xDBE5, 0xE97E, 0xF8F7, + 0x1081, 0x0108, 0x3393, 0x221A, 0x56A5, 0x472C, 0x75B7, 0x643E, + 0x9CC9, 0x8D40, 0xBFDB, 0xAE52, 0xDAED, 0xCB64, 0xF9FF, 0xE876, + 0x2102, 0x308B, 0x0210, 0x1399, 0x6726, 0x76AF, 0x4434, 0x55BD, + 0xAD4A, 0xBCC3, 0x8E58, 0x9FD1, 0xEB6E, 0xFAE7, 0xC87C, 0xD9F5, + 0x3183, 0x200A, 0x1291, 0x0318, 0x77A7, 0x662E, 0x54B5, 0x453C, + 0xBDCB, 0xAC42, 0x9ED9, 0x8F50, 0xFBEF, 0xEA66, 0xD8FD, 0xC974, + 0x4204, 0x538D, 0x6116, 0x709F, 0x0420, 0x15A9, 0x2732, 0x36BB, + 0xCE4C, 0xDFC5, 0xED5E, 0xFCD7, 0x8868, 0x99E1, 0xAB7A, 0xBAF3, + 0x5285, 0x430C, 0x7197, 0x601E, 0x14A1, 0x0528, 0x37B3, 0x263A, + 0xDECD, 0xCF44, 0xFDDF, 0xEC56, 0x98E9, 0x8960, 0xBBFB, 0xAA72, + 0x6306, 0x728F, 0x4014, 0x519D, 0x2522, 0x34AB, 0x0630, 0x17B9, + 0xEF4E, 0xFEC7, 0xCC5C, 0xDDD5, 0xA96A, 0xB8E3, 0x8A78, 0x9BF1, + 0x7387, 0x620E, 0x5095, 0x411C, 0x35A3, 0x242A, 0x16B1, 0x0738, + 0xFFCF, 0xEE46, 0xDCDD, 0xCD54, 0xB9EB, 0xA862, 0x9AF9, 0x8B70, + 0x8408, 0x9581, 0xA71A, 0xB693, 0xC22C, 0xD3A5, 0xE13E, 0xF0B7, + 0x0840, 0x19C9, 0x2B52, 0x3ADB, 0x4E64, 0x5FED, 0x6D76, 0x7CFF, + 0x9489, 0x8500, 0xB79B, 0xA612, 0xD2AD, 0xC324, 0xF1BF, 0xE036, + 0x18C1, 0x0948, 0x3BD3, 0x2A5A, 0x5EE5, 0x4F6C, 0x7DF7, 0x6C7E, + 0xA50A, 0xB483, 0x8618, 0x9791, 0xE32E, 0xF2A7, 0xC03C, 0xD1B5, + 0x2942, 0x38CB, 0x0A50, 0x1BD9, 0x6F66, 0x7EEF, 0x4C74, 0x5DFD, + 0xB58B, 0xA402, 0x9699, 0x8710, 0xF3AF, 0xE226, 0xD0BD, 0xC134, + 0x39C3, 0x284A, 0x1AD1, 0x0B58, 0x7FE7, 0x6E6E, 0x5CF5, 0x4D7C, + 0xC60C, 0xD785, 0xE51E, 0xF497, 0x8028, 0x91A1, 0xA33A, 0xB2B3, + 0x4A44, 0x5BCD, 0x6956, 0x78DF, 0x0C60, 0x1DE9, 0x2F72, 0x3EFB, + 0xD68D, 0xC704, 0xF59F, 0xE416, 0x90A9, 0x8120, 0xB3BB, 0xA232, + 0x5AC5, 0x4B4C, 0x79D7, 0x685E, 0x1CE1, 0x0D68, 0x3FF3, 0x2E7A, + 0xE70E, 0xF687, 0xC41C, 0xD595, 0xA12A, 0xB0A3, 0x8238, 0x93B1, + 0x6B46, 0x7ACF, 0x4854, 0x59DD, 0x2D62, 0x3CEB, 0x0E70, 0x1FF9, + 0xF78F, 0xE606, 0xD49D, 0xC514, 0xB1AB, 0xA022, 0x92B9, 0x8330, + 0x7BC7, 0x6A4E, 0x58D5, 0x495C, 0x3DE3, 0x2C6A, 0x1EF1, 0x0F78 + }; + + /*****************************************************************/ + /* End of CRC Lookup Table */ + /*****************************************************************/ +} + +#define COMPUTE(var, ch) (var) = (crc_table[(var ^ ch) & 0xFF] ^ (var >> 8)) + +// Open versioned namespace, if enabled by the user. +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_UINT16 +ACE::crc_ccitt (const char *string) +{ + ACE_UINT16 crc = 0xFFFF; + + for (const char *p = string; + *p != 0; + ++p) + { + COMPUTE (crc, *p); + } + + return ~crc; +} + +ACE_UINT16 +ACE::crc_ccitt (const void *buffer, size_t len, ACE_UINT16 crc) +{ + crc = ~crc; + + for (const char *p = (const char *) buffer, + *e = (const char *) buffer + len; + p != e; + ++p) + { + COMPUTE (crc, *p); + } + + return ~crc; +} + +ACE_UINT16 +ACE::crc_ccitt (const iovec *iov, int len, ACE_UINT16 crc) +{ + crc = ~crc; + + for (int i = 0; i < len; ++i) + { + for (const char *p = (const char *) iov[i].iov_base, + *e = (const char *) iov[i].iov_base + iov[i].iov_len; + p != e; + ++p) + COMPUTE (crc, *p); + } + + return ~crc; +} + +// Close versioned namespace, if enabled by the user. +ACE_END_VERSIONED_NAMESPACE_DECL + +#undef COMPUTE diff --git a/dep/ACE_wrappers/ace/ACE_export.h b/dep/ACE_wrappers/ace/ACE_export.h new file mode 100644 index 00000000000..8ad2a33ebaf --- /dev/null +++ b/dep/ACE_wrappers/ace/ACE_export.h @@ -0,0 +1,76 @@ +// -*- C++ -*- +// $Id: ACE_export.h 80826 2008-03-04 14:51:23Z wotte $ +// Definition for Win32 Export directives. +// This file is generated automatically by +// generate_export_file.pl +// ------------------------------ + +#ifndef ACE_EXPORT_H +#define ACE_EXPORT_H + +#include "ace/config-lite.h" + +#if defined (ACE_AS_STATIC_LIBS) + +# if !defined (ACE_HAS_DLL) +# define ACE_HAS_DLL 0 +# endif /* ! ACE_HAS_DLL */ +#else +# if !defined (ACE_HAS_DLL) +# define ACE_HAS_DLL 1 +# endif /* ! ACE_HAS_DLL */ +#endif /* ACE_AS_STATIC_LIB */ + +#if defined (ACE_HAS_DLL) +# if (ACE_HAS_DLL == 1) +# if defined (ACE_BUILD_DLL) +# define ACE_Export ACE_Proper_Export_Flag +# define ACE_SINGLETON_DECLARATION(T) ACE_EXPORT_SINGLETON_DECLARATION (T) +# define ACE_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# else +# define ACE_Export ACE_Proper_Import_Flag +# define ACE_SINGLETON_DECLARATION(T) ACE_IMPORT_SINGLETON_DECLARATION (T) +# define ACE_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# endif /* ACE_BUILD_DLL */ +# else +# define ACE_Export +# define ACE_SINGLETON_DECLARATION(T) +# define ACE_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# endif /* ! ACE_HAS_DLL == 1 */ +#else +# define ACE_Export +# define ACE_SINGLETON_DECLARATION(T) +# define ACE_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +#endif /* ACE_HAS_DLL */ + +// Added by hand to help with ACE_OS namespace +#if defined (__TANDEM) && defined (USE_EXPLICIT_EXPORT) +#define ACE_NAMESPACE_STORAGE_CLASS ACE_EXPORT_MACRO extern +#else +#define ACE_NAMESPACE_STORAGE_CLASS extern ACE_EXPORT_MACRO +#endif + +#if defined (__ACE_INLINE__) +# if defined (_MSC_VER) || defined (__MINGW32__) || defined (CYGWIN32) || \ + (defined (__SUNPRO_CC) && __SUNPRO_CC >= 0x560) || \ + (defined (__HP_aCC) && (__HP_aCC >= 60500)) || \ + (defined (__sgi) && \ + defined (_COMPILER_VERSION) && _COMPILER_VERSION <= 730) +# define ACE_NAMESPACE_INLINE_FUNCTION inline +# else +# define ACE_NAMESPACE_INLINE_FUNCTION ACE_NAMESPACE_STORAGE_CLASS inline +# endif +# define ACE_INLINE_TEMPLATE_FUNCTION inline +#else +# define ACE_NAMESPACE_INLINE_FUNCTION ACE_NAMESPACE_STORAGE_CLASS +// Microsoft Visual C++ will accept 'extern'; others refuse. +# if defined (_MSC_VER) || defined (__BORLANDC__) +# define ACE_INLINE_TEMPLATE_FUNCTION ACE_Export +# else +# define ACE_INLINE_TEMPLATE_FUNCTION +# endif +#endif + +#endif /* ACE_EXPORT_H */ + +// End of auto generated file. diff --git a/dep/ACE_wrappers/ace/ACE_vc71.vcproj b/dep/ACE_wrappers/ace/ACE_vc71.vcproj new file mode 100644 index 00000000000..37533296844 --- /dev/null +++ b/dep/ACE_wrappers/ace/ACE_vc71.vcproj @@ -0,0 +1,5255 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dep/ACE_wrappers/ace/ACE_vc8.vcproj b/dep/ACE_wrappers/ace/ACE_vc8.vcproj new file mode 100644 index 00000000000..d287eff2d1a --- /dev/null +++ b/dep/ACE_wrappers/ace/ACE_vc8.vcproj @@ -0,0 +1,6640 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dep/ACE_wrappers/ace/ACE_vc9.vcproj b/dep/ACE_wrappers/ace/ACE_vc9.vcproj new file mode 100644 index 00000000000..15041fc81ef --- /dev/null +++ b/dep/ACE_wrappers/ace/ACE_vc9.vcproj @@ -0,0 +1,6640 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dep/ACE_wrappers/ace/ARGV.cpp b/dep/ACE_wrappers/ace/ARGV.cpp new file mode 100644 index 00000000000..edfd4efa790 --- /dev/null +++ b/dep/ACE_wrappers/ace/ARGV.cpp @@ -0,0 +1,383 @@ +// $Id: ARGV.cpp 81374 2008-04-16 13:07:47Z iliyan $ + +#ifndef ACE_ARGV_CPP +#define ACE_ARGV_CPP + +#include "ace/Log_Msg.h" +#include "ace/OS_NS_unistd.h" +#include "ace/OS_NS_string.h" +#include "ace/OS_Memory.h" + +#if !defined (__ACE_INLINE__) +#include "ace/ARGV.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(ace, ARGV, "$Id: ARGV.cpp 81374 2008-04-16 13:07:47Z iliyan $") + +// Open versioned namespace, if enabled by the user. +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_ALLOC_HOOK_DEFINE (ACE_ARGV_Queue_Entry) +ACE_ALLOC_HOOK_DEFINE (ACE_ARGV) + +template +void +ACE_ARGV_Queue_Entry_T::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + ACE_TRACE ("ACE_ARGV_Queue_Entry_T::dump"); + + ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("arg_ = %s"), this->arg_)); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("quote_arg_ = %d"), (int)this->quote_arg_)); + ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); +#endif /* ACE_HAS_DUMP */ +} + +template +void +ACE_ARGV_T::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + ACE_TRACE ("ACE_ARGV_T::dump"); + + ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("argc_ = %d"), this->argc_)); + + ACE_ARGV *this_obj = const_cast (this); + + for (int i = 0; i < this->argc_; i++) + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("\nargv_[%i] = %s"), + i, + this_obj->argv ()[i])); + + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nbuf = %s\n"), this->buf_)); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\n"))); + ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); +#endif /* ACE_HAS_DUMP */ +} + +// Creates this->argv_ out of this->buf_. New memory is allocated for +// each element of the array. This is used by the array-to-string +// style constructor and for creating this->argv_ when in iterative +// mode. + +template +int +ACE_ARGV_T::string_to_argv (void) +{ + ACE_TRACE ("ACE_ARGV_T::string_to_argv"); + + return ACE_OS::string_to_argv (this->buf_, + this->argc_, + this->argv_, + this->substitute_env_args_); +} + +template +ACE_ARGV_T::ACE_ARGV_T (const CHAR_TYPE buf[], + bool substitute_env_args) + : substitute_env_args_ (substitute_env_args), + iterative_ (false), + argc_ (0), + argv_ (0), + buf_ (0), + length_ (0), + queue_ () +{ + ACE_TRACE ("ACE_ARGV_T::ACE_ARGV_T CHAR_TYPE[] to CHAR_TYPE *[]"); + + if (buf == 0 || buf[0] == 0) + return; + + // Make an internal copy of the string. + ACE_NEW (this->buf_, + CHAR_TYPE[ACE_OS::strlen (buf) + 1]); + ACE_OS::strcpy (this->buf_, buf); + + // Create this->argv_. + if (this->string_to_argv () == -1) + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("%p\n"), + ACE_TEXT ("string_to_argv"))); +} + +template +ACE_ARGV_T::ACE_ARGV_T (CHAR_TYPE *argv[], + bool substitute_env_args, + bool quote_arg) + : substitute_env_args_ (substitute_env_args), + iterative_ (false), + argc_ (0), + argv_ (0), + buf_ (0), + length_ (0), + queue_ () +{ + ACE_TRACE ("ACE_ARGV_T::ACE_ARGV_T CHAR_TYPE*[] to CHAR_TYPE[]"); + + if (argv == 0 || argv[0] == 0) + return; + + this->argc_ = ACE_OS::argv_to_string (argv, + this->buf_, + substitute_env_args, + quote_arg); +} + +template +ACE_ARGV_T::ACE_ARGV_T (int argc, + CHAR_TYPE *argv[], + bool substitute_env_args, + bool quote_arg) + : substitute_env_args_ (substitute_env_args), + iterative_ (false), + argc_ (0), + argv_ (0), + buf_ (0), + length_ (0), + queue_ () +{ + ACE_TRACE ("ACE_ARGV_T::ACE_ARGV_T int,CHAR_TYPE*[] to CHAR_TYPE[]"); + + this->argc_ = ACE_OS::argv_to_string (argc, + argv, + this->buf_, + substitute_env_args, + quote_arg); +} + + +template +ACE_ARGV_T::ACE_ARGV_T (CHAR_TYPE *first_argv[], + CHAR_TYPE *second_argv[], + bool substitute_env_args, + bool quote_args) + : substitute_env_args_ (substitute_env_args), + iterative_ (false), + argc_ (0), + argv_ (0), + buf_ (0), + length_ (0), + queue_ () +{ + ACE_TRACE ("ACE_ARGV_T::ACE_ARGV_T CHAR_TYPE*[] + CHAR_TYPE *[] to CHAR_TYPE[]"); + + int first_argc = 0; + int second_argc = 0; + + CHAR_TYPE *first_buf = 0; + CHAR_TYPE *second_buf = 0; + + // convert the first argv to a string + if (first_argv != 0 && first_argv[0] != 0) + { + first_argc = ACE_OS::argv_to_string (first_argv, + first_buf, + substitute_env_args, + quote_args); + } + + // convert the second argv to a string + if (second_argv != 0 && second_argv[0] != 0) + { + second_argc = ACE_OS::argv_to_string (second_argv, + second_buf, + substitute_env_args, + quote_args); + } + + // Add the number of arguments in both the argvs. + this->argc_ = first_argc + second_argc; + + size_t buf_len = + ACE_OS::strlen (first_buf) + ACE_OS::strlen (second_buf) + 1; + + // Allocate memory to the lenght of the combined argv string. + ACE_NEW (this->buf_, + CHAR_TYPE[buf_len + 1]); + + // copy the first argv string to the buffer + ACE_OS::strcpy (this->buf_, first_buf); + + // concatenate the second argv string to the buffer + ACE_OS::strcat (this->buf_, second_buf); + + // Delete the first and second buffers + delete [] first_buf; + delete [] second_buf; +} + +template +ACE_ARGV_T::ACE_ARGV_T (bool substitute_env_args) + : substitute_env_args_ (substitute_env_args), + iterative_ (true), + argc_ (0), + argv_ (0), + buf_ (0), + length_ (0), + queue_ () +{ + ACE_TRACE ("ACE_ARGV_T::ACE_ARGV_T Iterative"); + + // Nothing to do yet -- the user puts in arguments via add () +} + +template +int +ACE_ARGV_T::add (const CHAR_TYPE *next_arg, bool quote_arg) +{ + // Only allow this to work in the "iterative" verion -- the + // ACE_ARGVs created with the one argument constructor. + if (!this->iterative_) + { + errno = EINVAL; + return -1; + } + + this->length_ += ACE_OS::strlen (next_arg); + if (quote_arg && ACE_OS::strchr (next_arg, ' ') != 0) + { + this->length_ += 2; + if (ACE_OS::strchr (next_arg, '"') != 0) + for (const CHAR_TYPE * p = next_arg; *p != '\0'; ++p) + if (*p == '"') ++this->length_; + } + else + { + quote_arg = false; + } + + // Put the new argument at the end of the queue. + if (this->queue_.enqueue_tail (ACE_ARGV_Queue_Entry_T (next_arg, quote_arg)) == -1) + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("Can't add more to ARGV queue")), + -1); + + ++this->argc_; + + // Wipe argv_ and buf_ away so that they will be recreated if the + // user calls argv () or buf (). + if (this->argv_ != 0) + { + for (int i = 0; this->argv_[i] != 0; i++) + ACE_OS::free ((void *) this->argv_[i]); + + delete [] this->argv_; + this->argv_ = 0; + } + + delete [] this->buf_; + this->buf_ = 0; + + return 0; +} + +template +int +ACE_ARGV_T::add (CHAR_TYPE *argv[], bool quote_args) +{ + for (int i = 0; argv[i] != 0; i++) + if (this->add (argv[i], quote_args) == -1) + return -1; + + return 0; +} + +// Free up argv_ and buf_ + +template +ACE_ARGV_T::~ACE_ARGV_T (void) +{ + ACE_TRACE ("ACE_ARGV_T::~ACE_ARGV_T"); + + if (this->argv_ != 0) + for (int i = 0; this->argv_[i] != 0; i++) + ACE_OS::free ((void *) this->argv_[i]); + + delete [] this->argv_; + delete [] this->buf_; +} + +// Create buf_ out of the queue_. This is only used in the +// "iterative" mode. + +template +int +ACE_ARGV_T::create_buf_from_queue (void) +{ + ACE_TRACE ("ACE_ARGV_T::create_buf_from_queue"); + + // If the are no arguments, don't do anything + if (this->argc_ <= 0) + return -1; + + delete [] this->buf_; + + ACE_NEW_RETURN (this->buf_, + CHAR_TYPE[this->length_ + this->argc_], + -1); + + // Get an iterator over the queue + ACE_Unbounded_Queue_Iterator > iter (this->queue_); + + ACE_ARGV_Queue_Entry_T *arg = 0; + CHAR_TYPE *ptr = this->buf_; + size_t len; + + while (!iter.done ()) + { + // Get next argument from the queue. + iter.next (arg); + iter.advance (); + + if (arg->quote_arg_) + { + *ptr++ = '"'; + if (ACE_OS::strchr (arg->arg_, '"') != 0) + { + CHAR_TYPE prev = 0; + for (const CHAR_TYPE * p = arg->arg_; *p != '\0'; ++p) + { + if (*p == '"' && prev != '\\') *ptr++ = '\\'; + prev = *ptr++ = *p; + } + } + else + { + len = ACE_OS::strlen (arg->arg_); + // Copy the argument into buf_ + ACE_OS::memcpy ((void *) ptr, + (const void *) (arg->arg_), + len * sizeof (CHAR_TYPE)); + // Move the pointer down. + ptr += len; + } + *ptr++ = '"'; + } + else + { + len = ACE_OS::strlen (arg->arg_); + // Copy the argument into buf_ + ACE_OS::memcpy ((void *) ptr, + (const void *) (arg->arg_), + len * sizeof (CHAR_TYPE)); + // Move the pointer down. + ptr += len; + } + + // Put in an argument separating space. + *ptr++ = ' '; + } + + // Put in the NUL terminator + ptr[-1] = '\0'; + + return 0; +} + +// Close versioned namespace, if enabled by the user. +ACE_END_VERSIONED_NAMESPACE_DECL + +#endif /* ACE_ARGV_CPP */ diff --git a/dep/ACE_wrappers/ace/ARGV.h b/dep/ACE_wrappers/ace/ARGV.h new file mode 100644 index 00000000000..66e71810a95 --- /dev/null +++ b/dep/ACE_wrappers/ace/ARGV.h @@ -0,0 +1,333 @@ +// -*- C++ -*- + +//========================================================================== +/** + * @file ARGV.h + * + * $Id: ARGV.h 81156 2008-03-30 20:56:47Z iliyan $ + * + * @author Doug Schmidt + * @author Everett Anderson + */ +//========================================================================== + +#ifndef ACE_ARGUMENT_VECTOR_H +#define ACE_ARGUMENT_VECTOR_H +#include /**/ "ace/pre.h" + +#include /**/ "ace/ACE_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/Global_Macros.h" +#include "ace/Unbounded_Queue.h" + +// Open versioned namespace, if enabled by the user. +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +/** + * @class ACE_ARGV_Queue_Entry_T + * + * @brief An entry in the queue which keeps user supplied arguments. + */ +template +class ACE_ARGV_Queue_Entry_T +{ +public: + // = Initialization and termination. + /// Initialize a ACE_ARGV_Queue_Entry_T. + ACE_ARGV_Queue_Entry_T (void); + + /** + * Initialize a ACE_ARGV_Queue_Entry_T. + * + * @param arg Pointer to an argument + * + * @param quote_arg The argument @a arg need to be quoted + * while adding to the vector. + */ + ACE_ARGV_Queue_Entry_T (const CHAR_TYPE *arg, + bool quote_arg); + + /** + * Initialize a ACE_ARGV_Queue_Entry_T. + * + * @param entry Pointer to a queue entry + */ + ACE_ARGV_Queue_Entry_T (const ACE_ARGV_Queue_Entry_T &entry); + + /// We need this destructor to keep some compilers from complaining. + /// It's just a no-op, however. + ~ACE_ARGV_Queue_Entry_T (void); + + /// Dump the state of this object. + void dump (void) const; + + // Declare the dynamic allocation hooks. + ACE_ALLOC_HOOK_DECLARE; + + /// Pointer to the argument. + const CHAR_TYPE * arg_; + + /// The argument need to be quoted while adding to the vector. + bool quote_arg_; +}; + +/** + * @class ACE_ARGV_T + * + * @brief Builds a counted argument vector (ala argc/argv) from either + * a string or a set of separate tokens. This class preserves whitespace + * within tokens only if the whitespace-containing token is enclosed in + * either single (') or double (") quotes. This is consistent with the + * expected behavior if an argument vector obtained using this class is + * passed to, for example, ACE_Get_Opt. + * + * This class can substitute environment variable values for tokens that + * are environment variable references (e.g., @c $VAR). This only works + * if the token is an environment variable reference and nothing else; it + * doesn't substitute environment variable references within a token. + * For example, @c $HOME/file will not substitute the value of the HOME + * environment variable. + */ +template +class ACE_ARGV_T +{ +public: + // = Initialization and termination. + /** + * Splits the specified string into an argument vector. Arguments in the + * string are delimited by whitespace. Whitespace-containing arguments + * must be enclosed in quotes, either single (') or double ("). + * + * @param buf A nul-terminated CHAR_TYPE array to split into arguments + * for the vector. + * + * @param substitute_env_args If non-zero, any token that is an + * environment variable reference (e.g., @c $VAR) will have + * its environment variable value in the resultant vector + * in place of the environment variable name. + */ + explicit ACE_ARGV_T (const CHAR_TYPE buf[], + bool substitute_env_args = true); + + /** + * Initializes the argument vector from a set of arguments. Any environment + * variable references are translated (if applicable) during execution of + * this method. In contrast with ACE_ARGV_T(CHAR_TYPE *[], bool, bool), this + * ctor does not require argv to be 0-terminated as the number of arguments + * is provided explicitely. + * + * @param argc The number of arguments in the argv array. + * + * @param argv An array of tokens to initialize the object with. All needed + * data is copied from @a argv during this call; the pointers + * in @a argv are not needed after this call, and the memory + * referred to by @a argv is not referenced by this object. + * + * @param substitute_env_args If non-zero, any element of @a argv that is + * an environment variable reference (e.g., @c $VAR) will have + * its environment variable value in the resultant vector + * in place of the environment variable name. + * + * @param quote_args If non-zero each argument @a argv[i] needs to + * be enclosed in double quotes ('"'). + */ + explicit ACE_ARGV_T (int argc, + CHAR_TYPE *argv[], + bool substitute_env_args = true, + bool quote_args = false); + + /** + * Initializes the argument vector from a set of arguments. Any environment + * variable references are translated (if applicable) during execution of + * this method. + * + * @param argv An array of tokens to initialize the object with. The + * array must be terminated with a 0 pointer. All needed + * data is copied from @a argv during this call; the pointers + * in @a argv are not needed after this call, and the memory + * referred to by @a argv is not referenced by this object. + * + * @param substitute_env_args If non-zero, any element of @a argv that is + * an environment variable reference (e.g., @c $VAR) will have + * its environment variable value in the resultant vector + * in place of the environment variable name. + * + * @param quote_args If non-zero each argument @a argv[i] needs to + * be enclosed in double quotes ('"'). + */ + explicit ACE_ARGV_T (CHAR_TYPE *argv[], + bool substitute_env_args = true, + bool quote_args = false); + + /** + * Initializes the argument vector from two combined argument vectors. + * + * @param first_argv An array of tokens to initialize the object with. + * The array must be terminated with a 0 pointer. + * @param second_argv An array of tokens that is concatenated with the + * the tokens in @a first_argv. The array must be + * terminated with a 0 pointer. + * @param substitute_env_args If non-zero, any element of @a first_argv + * or @a second_argv that is an environment variable + * reference (e.g., @c $VAR) will have its environment + * variable value in the resultant vector in place + * of the environment variable name. + * + * @param quote_args If non-zero each arguments @a first_argv[i] and + * @a second_argv[i] needs to be enclosed + * in double quotes ('"'). + */ + ACE_ARGV_T (CHAR_TYPE *first_argv[], + CHAR_TYPE *second_argv[], + bool substitute_env_args = true, + bool quote_args = false); + + /** + * Initialize this object so arguments can be added later using one + * of the add methods. This is referred to as the @i iterative method + * of adding arguments to this object. + */ + explicit ACE_ARGV_T (bool substitute_env_args = true); + + /// Destructor. + ~ACE_ARGV_T (void); + + /** @name Accessor methods + * + * These methods access the argument vector contained in this object. + */ + //@{ + /** + * Returns the specified element of the current argument vector. + * + * @param index Index to the desired element. + * + * @retval Pointer to the indexed string. + * @retval 0 if @a index is out of bounds. + */ + const CHAR_TYPE *operator[] (size_t index); + + /** + * Returns the current argument vector. The returned pointers are to data + * maintained internally to this class. Do not change or delete either the + * pointers or the memory to which they refer. + */ + CHAR_TYPE **argv (void); + + /// Returns the current number of arguments. + int argc (void) const; + + /** + * Returns a single string form of the current arguments. The returned + * pointer refers to memory maintained internally to this class. Do not + * change or delete it. + */ + const CHAR_TYPE *buf (void); + + //@} + + /// Dump the state of this object. + void dump (void) const; + + // Declare the dynamic allocation hooks. + ACE_ALLOC_HOOK_DECLARE; + + /** + * Add another argument. This only works in the iterative mode. + * + * @note This method copies the specified pointer, but not the data + * contained in the referenced memory. Thus, if the content of + * the memory referred to by @a next_arg are changed after this + * method returns, the results are undefined. + * + * @param next_arg Pointer to the next argument to add to the vector. + * + * @param quote_arg The argument @a next_arg need to be quoted while + * adding to the vector. + * + * @retval 0 on success; -1 on failure. Most likely @c errno values are: + * - EINVAL: This object is not in iterative mode. + * - ENOMEM: Not enough memory available to save @a next_arg. + */ + int add (const CHAR_TYPE *next_arg, bool quote_arg = false); + + /** + * Add an array of arguments. This only works in the iterative mode. + * + * @note This method copies the specified pointers, but not the data + * contained in the referenced memory. Thus, if the content of + * the memory referred to by any of the @a argv elements is + * changed after this method returns, the results are undefined. + * + * @param argv Pointers to the arguments to add to the vector. + * @a argv must be terminated by a 0 pointer. + * + * @param quote_args If non-zero each argument @a argv[i] needs to + * be enclosed in double quotes ('"'). + * + * @retval 0 on success; -1 on failure. Most likely @c errno values are: + * - EINVAL: This object is not in iterative mode. + * - ENOMEM: Not enough memory available to save @a next_arg. + */ + int add (CHAR_TYPE *argv[], bool quote_args = false); + +private: + /// Copy constructor not implemented. + ACE_UNIMPLEMENTED_FUNC (ACE_ARGV_T (const ACE_ARGV_T&)) + + /// Assignment operator not implemented. + ACE_UNIMPLEMENTED_FUNC (ACE_ARGV_T operator= (const ACE_ARGV_T&)) + + /// Creates buf_ from the queue of added args, deletes previous buf_. + int create_buf_from_queue (void); + + /// Converts buf_ into the CHAR_TYPE *argv[] format. + int string_to_argv (void); + + /// Replace args with environment variable values? + bool substitute_env_args_; + + bool iterative_; + + /// Number of arguments in the ARGV array. + int argc_; + + /// The array of string arguments. + CHAR_TYPE **argv_; + + /// Buffer containing the contents. + CHAR_TYPE *buf_; + + /// Total length of the arguments in the queue, not counting + /// separating spaces + size_t length_; + + /// Queue which keeps user supplied arguments. This is only + /// active in the "iterative" mode. + ACE_Unbounded_Queue > queue_; +}; + +typedef ACE_ARGV_Queue_Entry_T ACE_ARGV_Queue_Entry; +typedef ACE_ARGV_T ACE_ARGV; + +// Close versioned namespace, if enabled by the user. +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +#include "ace/ARGV.inl" +#endif /* __ACE_INLINE__ */ + +#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) +#include "ace/ARGV.cpp" +#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ + +#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) +#pragma implementation ("ARGV.cpp") +#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ + +#include /**/ "ace/post.h" +#endif /* ACE_ARGUMENT_VECTOR_H */ diff --git a/dep/ACE_wrappers/ace/ARGV.inl b/dep/ACE_wrappers/ace/ARGV.inl new file mode 100644 index 00000000000..fdc5b13d7c3 --- /dev/null +++ b/dep/ACE_wrappers/ace/ARGV.inl @@ -0,0 +1,104 @@ +/* -*- C++ -*- */ +// $Id: ARGV.inl 80826 2008-03-04 14:51:23Z wotte $ + +#include "ace/Global_Macros.h" + +// Open versioned namespace, if enabled by the user. +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +template ACE_INLINE +ACE_ARGV_Queue_Entry_T::ACE_ARGV_Queue_Entry_T (void) + : arg_(0), + quote_arg_(false) +{ + // No-op +} + +template ACE_INLINE +ACE_ARGV_Queue_Entry_T::ACE_ARGV_Queue_Entry_T (const CHAR_TYPE *arg, + bool quote_arg) + : arg_(arg), + quote_arg_(quote_arg) +{ + // No-op +} + +template ACE_INLINE +ACE_ARGV_Queue_Entry_T::ACE_ARGV_Queue_Entry_T (const ACE_ARGV_Queue_Entry_T &entry) + : arg_(entry.arg_), + quote_arg_(entry.quote_arg_) +{ + // No-op +} + +template ACE_INLINE +ACE_ARGV_Queue_Entry_T::~ACE_ARGV_Queue_Entry_T (void) +{ + // No-op just to keep some compilers happy... +} + +// Return the number of args +template +ACE_INLINE int +ACE_ARGV_T::argc (void) const +{ + ACE_TRACE ("ACE_ARGV_T::argc"); + // Try to create the argv_ if it isn't there + ACE_ARGV_T *nonconst_this = + const_cast *> (this); + (void) nonconst_this->argv (); + return this->argc_; +} + +// Return the arguments in a space-separated string +template +ACE_INLINE const CHAR_TYPE * +ACE_ARGV_T::buf (void) +{ + ACE_TRACE ("ACE_ARGV_T::buf"); + + if (this->buf_ == 0 && this->iterative_) + this->create_buf_from_queue (); + + return (const CHAR_TYPE *) this->buf_; +} + +// Return the arguments in an entry-per-argument array + +template +ACE_INLINE CHAR_TYPE ** +ACE_ARGV_T::argv (void) +{ + ACE_TRACE ("ACE_ARGV_T::argv"); + + // Try to create the argv_ if it isn't there + if (this->argv_ == 0) + { + if (this->iterative_ && this->buf_ == 0) + this->create_buf_from_queue (); + + // Convert buf_ to argv_ + if (this->string_to_argv () == -1) + return (CHAR_TYPE **) 0; + } + + return (CHAR_TYPE **) this->argv_; +} + +// Subscript operator. + +template +ACE_INLINE const CHAR_TYPE * +ACE_ARGV_T::operator[] (size_t i) +{ + ACE_TRACE ("ACE_ARGV_T::operator[]"); + + // Don't go out of bounds. + if (i >= static_cast (this->argc_)) + return 0; + + return (const CHAR_TYPE *) this->argv ()[i]; +} + +// Close versioned namespace, if enabled by the user. +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/ATM_Acceptor.cpp b/dep/ACE_wrappers/ace/ATM_Acceptor.cpp new file mode 100644 index 00000000000..1aa6c6d7096 --- /dev/null +++ b/dep/ACE_wrappers/ace/ATM_Acceptor.cpp @@ -0,0 +1,309 @@ +// $Id: ATM_Acceptor.cpp 80826 2008-03-04 14:51:23Z wotte $ + +#include "ace/ATM_Acceptor.h" + +ACE_RCSID(ace, ATM_Acceptor, "$Id: ATM_Acceptor.cpp 80826 2008-03-04 14:51:23Z wotte $") + +#if defined (ACE_HAS_ATM) + +#if defined (ACE_HAS_LINUX_ATM) +#include /**/ "linux/atmdev.h" +#endif /* ACE_HAS_LINUX_ATM */ + +#if !defined (__ACE_INLINE__) +#include "ace/ATM_Acceptor.inl" +#endif /* __ACE_INLINE__ */ + + +// Open versioned namespace, if enabled by the user. +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +// Put the actual definitions of the ACE_ATM_Request and +// ACE_ATM_Request_Queue classes here to hide them from clients... + +ACE_ALLOC_HOOK_DEFINE(ACE_ATM_Acceptor) + +ACE_ATM_Acceptor::ACE_ATM_Acceptor (void) +{ + ACE_TRACE ("ACE_ATM_Acceptor::ACE_ATM_Acceptor"); +} + +ACE_ATM_Acceptor::~ACE_ATM_Acceptor (void) +{ + ACE_TRACE ("ACE_ATM_Acceptor::~ACE_ATM_Acceptor"); +} + +int +ACE_ATM_Acceptor::get_local_addr (ACE_ATM_Addr &local_addr) +{ + ACE_TRACE ("ACE_ATM_Acceptor::get_local_addr"); + +#if defined (ACE_HAS_FORE_ATM_WS2) + unsigned long ret = 0; + DWORD deviceID = 0; + ATM_ADDRESS addr; + struct sockaddr_atm *laddr; + + if (::WSAIoctl ((int) ((ACE_SOCK_Acceptor *)this) -> get_handle (), + SIO_GET_ATM_ADDRESS, + (LPVOID) &deviceID, + sizeof (DWORD), + (LPVOID)&addr, + sizeof (ATM_ADDRESS), + &ret, + 0, + 0) == SOCKET_ERROR) { + ACE_OS::printf ("ATM_Acceptor (get_local_addr): WSIoctl: %d\n", + ::WSAGetLastError ()); + return -1; + } + + laddr = (struct sockaddr_atm *)local_addr.get_addr (); + ACE_OS::memcpy ((void *)& (laddr -> satm_number), + (void *)&addr, + ATM_ADDR_SIZE - 1); + + return 0; +#elif defined (ACE_HAS_FORE_ATM_XTI) + ACE_UNUSED_ARG (local_addr); + + return 0; +#elif defined (ACE_HAS_LINUX_ATM) + ATM_Addr *myaddr = (ATM_Addr *)local_addr.get_addr (); + int addrlen = sizeof (myaddr->sockaddratmsvc); + + if (ACE_OS::getsockname (acceptor_.get_handle (), + (struct sockaddr *) & (myaddr->sockaddratmsvc), + &addrlen) < 0) { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("ATM_Acceptor (get_local_addr): ioctl: %d\n"), + errno)); + return -1; + } + + return (0); +#else + ACE_UNUSED_ARG (local_addr); + + return 0; +#endif /* ACE_HAS_FORE_ATM_WS2 && ACE_HAS_FORE_ATM_XTI */ +} + +ACE_HANDLE +ACE_ATM_Acceptor::open (const ACE_Addr &remote_sap, + int backlog, + ACE_ATM_Params params) +{ + ACE_TRACE ("ACE_ATM_Acceptor::open"); +#if defined (ACE_HAS_FORE_ATM_XTI) + ACE_HANDLE handle = acceptor_.open (remote_sap, + params.get_reuse_addr (), + params.get_oflag (), + params.get_info (), + backlog, + params.get_device ()); + return (handle == ACE_INVALID_HANDLE ? -1 : 0); +#elif defined (ACE_HAS_FORE_ATM_WS2) + struct sockaddr_atm local_atm_addr; + ACE_HANDLE ret; + DWORD flags = 0; + + /* Create a local endpoint of communication */ + + // Only leaves can listen. + flags = ACE_FLAG_MULTIPOINT_C_LEAF | ACE_FLAG_MULTIPOINT_D_LEAF; + + if ((ret = ACE_OS::socket (AF_ATM, + SOCK_RAW, + ATMPROTO_AAL5, + 0, + 0, + flags)) + == ACE_INVALID_HANDLE) { + ACE_OS::printf ("Acceptor (open): socket %d\n", + ::WSAGetLastError ()); + return (ret); + } + + ((ACE_SOCK_Acceptor *)this) -> set_handle (ret); + + /* Set up the address information to become a server */ + ACE_OS::memset ((void *) &local_atm_addr, 0, sizeof local_atm_addr); + local_atm_addr.satm_family = AF_ATM; + local_atm_addr.satm_number.AddressType = SAP_FIELD_ANY_AESA_REST; + local_atm_addr.satm_number.Addr[ ATM_ADDR_SIZE - 1 ] + = ((ACE_ATM_Addr *)&remote_sap) -> get_selector (); + local_atm_addr.satm_blli.Layer2Protocol = SAP_FIELD_ANY; + local_atm_addr.satm_blli.Layer3Protocol = SAP_FIELD_ABSENT; + local_atm_addr.satm_bhli.HighLayerInfoType = SAP_FIELD_ABSENT; + + /* Associate address with endpoint */ + if (ACE_OS::bind (((ACE_SOCK_Acceptor *)this) -> get_handle (), + reinterpret_cast (&local_atm_addr), + sizeof local_atm_addr) == -1) { + ACE_OS::printf ("Acceptor (open): bind %d\n", ::WSAGetLastError ()); + return (ACE_INVALID_HANDLE); + } + + /* Make endpoint listen for service requests */ + if (ACE_OS::listen (( (ACE_SOCK_Acceptor *)this) -> get_handle (), + backlog) + == -1) { + ACE_OS::printf ("Acceptor (open): listen %d\n", ::WSAGetLastError ()); + return (ACE_INVALID_HANDLE); + } + + return 0; +#elif defined (ACE_HAS_LINUX_ATM) + //we need to set the qos before binding to the socket + //use remote_sap as local_sap + + ACE_ATM_Addr local_sap; + ATM_Addr *local_sap_addr = (ATM_Addr*)local_sap.get_addr (); + ACE_ATM_QoS def_qos; + ATM_QoS qos = def_qos.get_qos (); + + ACE_HANDLE handle; + if ((handle = ACE_OS::socket (params.get_protocol_family (), + params.get_type (), + params.get_protocol (), + params.get_protocol_info (), + params.get_sock_group (), + params.get_flags () + )) + == ACE_INVALID_HANDLE) { + ACE_DEBUG (LM_DEBUG, + ACE_TEXT ("Acceptor (socket): socket %d\n"), + errno); + return (ACE_INVALID_HANDLE); + } + + ((ACE_SOCK_Acceptor *)this) -> set_handle (handle); + if (ACE_OS::setsockopt (handle, + SOL_ATM, + SO_ATMQOS, + reinterpret_cast (&qos), + sizeof (qos)) < 0) { + ACE_OS::printf ("Acceptor (setsockopt): setsockopt:%d\n", + errno); + } + + struct atmif_sioc req; + struct sockaddr_atmsvc aux_addr[1024]; + + req.number = 0; + req.arg = aux_addr; + req.length = sizeof (aux_addr); + if (ACE_OS::ioctl (handle, + ATM_GETADDR, + &req) < 0) { + ACE_OS::perror ("Acceptor (setsockopt): ioctl:"); + } + else { + local_sap_addr->sockaddratmsvc = aux_addr[0]; + } + local_sap.set_selector (( (ACE_ATM_Addr*)&remote_sap)->get_selector ()); + + if (ACE_OS::bind (handle, + reinterpret_cast ( + &(local_sap_addr->sockaddratmsvc)), + sizeof (local_sap_addr->sockaddratmsvc) + ) == -1) { + ACE_DEBUG (LM_DEBUG, + ACE_TEXT ("Acceptor (open): bind %d\n"), + errno); + return -1; + } + // Make endpoint listen for service requests + if (ACE_OS::listen (handle, + backlog) + == -1) { + ACE_DEBUG (LM_DEBUG, + ACE_TEXT ("Acceptor (listen): listen %d\n"), + errno); + return -1; + } + + return 0; +#else + ACE_UNUSED_ARG (remote_sap); + ACE_UNUSED_ARG (backlog); + ACE_UNUSED_ARG (params); +#endif /* ACE_HAS_FORE_ATM_XTI/ACE_HAS_FORE_ATM_WS2/ACE_HAS_LINUX_ATM */ +} + +int +ACE_ATM_Acceptor::accept (ACE_ATM_Stream &new_sap, + ACE_Addr *remote_addr, + ACE_Time_Value *timeout, + int restart, + int reset_new_handle, + ACE_ATM_Params params, + ACE_ATM_QoS qos) +{ + ACE_TRACE ("ACE_ATM_Acceptor::accept"); +#if defined (ACE_HAS_FORE_ATM_XTI) + ATM_QoS optbuf = qos.get_qos (); + + return (acceptor_.accept (new_sap.get_stream (), + remote_addr, + timeout, + restart, + reset_new_handle, + params.get_rw_flag (), + params.get_user_data (), + &optbuf)); +#elif defined (ACE_HAS_FORE_ATM_WS2) + ACE_HANDLE n_handle; + ACE_HANDLE s_handle = ((ACE_SOCK_Acceptor *) this) -> get_handle (); + struct sockaddr_atm *cli_addr + = (struct sockaddr_atm *)remote_addr -> get_addr (); + int caddr_len = sizeof (struct sockaddr_atm); + + do { + n_handle = ACE_OS::accept (s_handle, + reinterpret_cast (cli_addr), + &caddr_len); + } while (n_handle == ACE_INVALID_HANDLE && errno == EINTR); + + ((ACE_ATM_Addr *)remote_addr) -> set (cli_addr, + ((ACE_ATM_Addr *)remote_addr) -> get_selector ()); + ((ACE_IPC_SAP *)&new_sap) -> set_handle (n_handle); + + return 0; +#elif defined (ACE_HAS_LINUX_ATM) + ACE_UNUSED_ARG (params); + + ACE_HANDLE s_handle = ((ACE_SOCK_Acceptor *) this) -> get_handle (); + struct atm_qos accept_qos = qos.get_qos (); + + if (ACE_OS::setsockopt (s_handle, + SOL_ATM, + SO_ATMQOS, + reinterpret_cast (&accept_qos), + sizeof (accept_qos)) < 0) { + ACE_OS::printf ("Acceptor (accept): error setting Qos"); + } + + return (acceptor_.accept (new_sap.get_stream (), + remote_addr, + timeout, + restart, + reset_new_handle)); +#else + ACE_UNUSED_ARG (new_sap); + ACE_UNUSED_ARG (remote_addr); + ACE_UNUSED_ARG (timeout); + ACE_UNUSED_ARG (restart); + ACE_UNUSED_ARG (reset_new_handle); + ACE_UNUSED_ARG (params); + ACE_UNUSED_ARG (qos); + return (0); +#endif /* ACE_HAS_FORE_ATM_XTI */ +} + +// Close versioned namespace, if enabled by the user. +ACE_END_VERSIONED_NAMESPACE_DECL + + +#endif /* ACE_HAS_ATM */ diff --git a/dep/ACE_wrappers/ace/ATM_Acceptor.h b/dep/ACE_wrappers/ace/ATM_Acceptor.h new file mode 100644 index 00000000000..c69e2f8540d --- /dev/null +++ b/dep/ACE_wrappers/ace/ATM_Acceptor.h @@ -0,0 +1,123 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file ATM_Acceptor.h + * + * $Id: ATM_Acceptor.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Joe Hoffert + */ +//============================================================================= + + +#ifndef ACE_ATM_ACCEPTOR_H +#define ACE_ATM_ACCEPTOR_H +#include /**/ "ace/pre.h" + +#include /**/ "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#if defined (ACE_HAS_ATM) + +#include "ace/ATM_Stream.h" +#include "ace/ATM_Params.h" +#include "ace/ATM_QoS.h" + +#if defined (ACE_HAS_LINUX_ATM) +#include /**/ "atm.h" +#endif /* ACE_HAS_LINUX_ATM */ + +#if defined (ACE_HAS_FORE_ATM_WS2) || defined (ACE_HAS_LINUX_ATM) +#include "ace/SOCK_Acceptor.h" +ACE_BEGIN_VERSIONED_NAMESPACE_DECL +typedef ACE_SOCK_Acceptor ATM_Acceptor; +ACE_END_VERSIONED_NAMESPACE_DECL +#elif defined (ACE_HAS_FORE_ATM_XTI) +#include "ace/TLI_Acceptor.h" +ACE_BEGIN_VERSIONED_NAMESPACE_DECL +typedef ACE_TLI_Acceptor ATM_Acceptor; +ACE_END_VERSIONED_NAMESPACE_DECL +#endif // ACE_HAS_FORE_ATM_WS2 || ACE_HAS_LINUX_ATM + +// Open versioned namespace, if enabled by the user. +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +// Forward declarations. +class ACE_Time_Value; + +/** + * @class ACE_ATM_Acceptor + * + * @brief Defines the member functions for ACE_ATM_Acceptor abstraction. + * + * This class wraps up the ACE_SOCK_Acceptor and ACE_TLI_Acceptor + * to make the mechanism for the ATM protocol transparent. + */ +class ACE_Export ACE_ATM_Acceptor +{ + +public: + // = Initialization and termination methods. + /// Default constructor. + ACE_ATM_Acceptor (void); + + ~ACE_ATM_Acceptor (); + + /// Initiate a passive mode connection. + ACE_ATM_Acceptor (const ACE_Addr &remote_sap, + int backlog = ACE_DEFAULT_BACKLOG, + ACE_ATM_Params params = ACE_ATM_Params()); + + /// Initiate a passive mode socket. + ACE_HANDLE open (const ACE_Addr &remote_sap, + int backlog = ACE_DEFAULT_BACKLOG, + ACE_ATM_Params params = ACE_ATM_Params()); + + /// Close down the acceptor and release resources. + int close (void); + + // = Passive connection acceptance method. + + /// Accept a new data transfer connection. A @a timeout of 0 means + /// block forever, a @a timeout of {0, 0} means poll. @a restart == 1 + /// means "restart if interrupted." + int accept (ACE_ATM_Stream &new_sap, + ACE_Addr *remote_addr = 0, + ACE_Time_Value *timeout = 0, + int restart = 1, + int reset_new_handle = 0, + ACE_ATM_Params params = ACE_ATM_Params(), + ACE_ATM_QoS qos = ACE_ATM_QoS()); + + /// Get the local address currently listening on + int get_local_addr( ACE_ATM_Addr &local_addr ); + + // = Meta-type info + typedef ACE_ATM_Addr PEER_ADDR; + typedef ACE_ATM_Stream PEER_STREAM; + + /// Dump the state of an object. + void dump (void) const; + + /// Declare the dynamic allocation hooks. + ACE_ALLOC_HOOK_DECLARE; + +private: + ATM_Acceptor acceptor_; +}; + +// Close versioned namespace, if enabled by the user. +ACE_END_VERSIONED_NAMESPACE_DECL + + +#if defined (__ACE_INLINE__) +#include "ace/ATM_Acceptor.inl" +#endif /* __ACE_INLINE__ */ + +#endif /* ACE_HAS_ATM */ +#include /**/ "ace/post.h" +#endif /* ACE_ATM_ACCEPTOR_H */ diff --git a/dep/ACE_wrappers/ace/ATM_Acceptor.inl b/dep/ACE_wrappers/ace/ATM_Acceptor.inl new file mode 100644 index 00000000000..fa60c4ad89a --- /dev/null +++ b/dep/ACE_wrappers/ace/ATM_Acceptor.inl @@ -0,0 +1,43 @@ +// -*- C++ -*- +// +// $Id: ATM_Acceptor.inl 80826 2008-03-04 14:51:23Z wotte $ + +// Open versioned namespace, if enabled by the user. +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_INLINE void +ACE_ATM_Acceptor::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + ACE_TRACE ("ACE_ATM_Acceptor::dump"); +#endif /* ACE_HAS_DUMP */ +} + +ACE_INLINE +ACE_ATM_Acceptor::ACE_ATM_Acceptor (const ACE_Addr &remote_sap, + int backlog, + ACE_ATM_Params params) +{ + ACE_TRACE ("ACE_ATM_Acceptor::ACE_ATM_Acceptor"); + + //FUZZ: disable check_for_lack_ACE_OS + if (open (remote_sap, backlog, params) < 0) + //FUZZ: enable check_for_lack_ACE_OS + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("%p\n"), + ACE_TEXT ("ACE_ATM_Acceptor::ACE_ATM_Acceptor"))); +} + +ACE_INLINE +int +ACE_ATM_Acceptor::close (void) +{ +#if defined (ACE_HAS_FORE_ATM_XTI) || defined (ACE_HAS_FORE_ATM_WS2) || defined (ACE_HAS_LINUX_ATM) + return (acceptor_.close()); +#else + return 0; +#endif // ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_ATM_WS2 || ACE_HAS_LINUX_ATM +} + +// Close versioned namespace, if enabled by the user. +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/ATM_Addr.cpp b/dep/ACE_wrappers/ace/ATM_Addr.cpp new file mode 100644 index 00000000000..739a8076359 --- /dev/null +++ b/dep/ACE_wrappers/ace/ATM_Addr.cpp @@ -0,0 +1,522 @@ +// $Id: ATM_Addr.cpp 80826 2008-03-04 14:51:23Z wotte $ + +// Defines the Internet domain address family address format. + +#include "ace/ATM_Addr.h" +#if defined (ACE_HAS_ATM) + +#include "ace/Log_Msg.h" + +#if defined (ACE_HAS_FORE_ATM_WS2) +#include /**/ "forews2.h" +#endif /* ACE_HAS_FORE_ATM_WS2 */ + +#if !defined (__ACE_INLINE__) +#include "ace/ATM_Addr.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(ace, ATM_Addr, "$Id: ATM_Addr.cpp 80826 2008-03-04 14:51:23Z wotte $") + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_ALLOC_HOOK_DEFINE(ACE_ATM_Addr) + +#if defined (ACE_HAS_FORE_ATM_XTI) || defined (ACE_HAS_FORE_ATM_WS2) +#define BHLI_MAGIC "FORE_ATM" +// This is line rate in cells/s for an OC-3 MM interface. +const long ACE_ATM_Addr::LINE_RATE = 353207; +const int ACE_ATM_Addr::OPT_FLAGS_CPID = 0x1; +const int ACE_ATM_Addr::OPT_FLAGS_PMP = 0x2; +const int ACE_ATM_Addr::DEFAULT_SELECTOR = 0x99; +#elif defined (ACE_HAS_LINUX_ATM) +//pbrandao:for Linux: +//pbrandao:for now stick with current definitions +//pbrandao:see if later need to change +const long ACE_ATM_Addr::LINE_RATE = 353207; +const int ACE_ATM_Addr::OPT_FLAGS_CPID = 0; +const int ACE_ATM_Addr::OPT_FLAGS_PMP = 0; +const int ACE_ATM_Addr::DEFAULT_SELECTOR = 0x99; +#else +const long ACE_ATM_Addr::LINE_RATE = 0L; +const int ACE_ATM_Addr::OPT_FLAGS_CPID = 0; +const int ACE_ATM_Addr::OPT_FLAGS_PMP = 0; +const int ACE_ATM_Addr::DEFAULT_SELECTOR = 0x0; +#endif /* ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_ATM_WS2 || ACE_HAS_LINUX_ATM */ + +// Default constructor + +ACE_ATM_Addr::ACE_ATM_Addr (u_char selector) +#if defined (ACE_HAS_FORE_ATM_XTI) || defined (ACE_HAS_FORE_ATM_WS2) + : ACE_Addr (AF_ATM, +#elif defined (ACE_HAS_LINUX_ATM) + : ACE_Addr (PF_ATMSVC, +#else + : ACE_Addr (AF_UNSPEC, +#endif /* ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_ATM_WS2 || ACE_HAS_LINUX_ATM */ + sizeof this->atm_addr_) +{ + // ACE_TRACE ("ACE_ATM_Addr::ACE_ATM_Addr"); + (void) ACE_OS::memset ((void *) &this->atm_addr_, + 0, + sizeof this->atm_addr_); + this->init (selector); +} + +// Copy constructor. + +ACE_ATM_Addr::ACE_ATM_Addr (const ACE_ATM_Addr &sap, + u_char selector) +#if defined (ACE_HAS_FORE_ATM_XTI) || defined (ACE_HAS_FORE_ATM_WS2) + : ACE_Addr (AF_ATM, +#elif defined (ACE_HAS_LINUX_ATM) + : ACE_Addr (PF_ATMSVC, +#else + : ACE_Addr (AF_UNSPEC, +#endif /* ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_ATM_WS2 || ACE_HAS_LINUX_ATM */ + sizeof this->atm_addr_) +{ + ACE_TRACE ("ACE_ATM_Addr::ACE_ATM_Addr"); + this->set (sap, selector); +#if defined (ACE_HAS_LINUX_ATM) + this->atm_addr_.sockaddratmsvc.sas_family = PF_ATMSVC; + this->atm_addr_.atmsap.blli[0].l3_proto = ATM_L3_NONE; + this->atm_addr_.atmsap.blli[0].l2_proto = ATM_L2_NONE; + this->atm_addr_.atmsap.bhli.hl_type = ATM_HL_NONE; +#endif /* ACE_HAS_LINUX_ATM */ +} + +ACE_ATM_Addr::ACE_ATM_Addr (const ATM_Addr *sap, + u_char selector) +#if defined (ACE_HAS_FORE_ATM_XTI) || defined (ACE_HAS_FORE_ATM_WS2) + : ACE_Addr (AF_ATM, +#elif defined (ACE_HAS_LINUX_ATM) + : ACE_Addr (PF_ATMSVC, +#else + : ACE_Addr (AF_UNSPEC, +#endif /* ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_ATM_WS2 || ACE_HAS_LINUX_ATM */ + sizeof this->atm_addr_) +{ + ACE_TRACE ("ACE_ATM_Addr::ACE_ATM_Addr"); + this->set (sap, selector); +} + + +ACE_ATM_Addr::ACE_ATM_Addr (const ACE_TCHAR sap[], + u_char selector) +#if defined (ACE_HAS_FORE_ATM_XTI) || defined (ACE_HAS_FORE_ATM_WS2) + : ACE_Addr (AF_ATM, +#elif defined (ACE_HAS_LINUX_ATM) + : ACE_Addr (PF_ATMSVC, +#else + : ACE_Addr (AF_UNSPEC, +#endif /* ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_ATM_WS2 || ACE_HAS_LINUX_ATM */ + sizeof this->atm_addr_) +{ + ACE_TRACE ("ACE_ATM_Addr::ACE_ATM_Addr"); + this->set (sap, selector); +} + +ACE_ATM_Addr::~ACE_ATM_Addr (void) +{ +} + +// Return the address. + +void * +ACE_ATM_Addr::get_addr (void) const +{ + ACE_TRACE ("ACE_ATM_Addr::get_addr"); + return (void *) &this->atm_addr_; +} + +void +ACE_ATM_Addr::init (u_char selector) +{ +#if defined (ACE_HAS_FORE_ATM_XTI) + // Note: this approach may be FORE implementation-specific. When we + // bind with tag_addr ABSENT and tag_selector PRESENT, only the + // selector (i.e. address[19]) is used by the TP. The rest of the + // local address is filled in by the TP and can be obtained via the + // 'ret' parameter or with t_getname ()/t_getprotaddr (). + + atm_addr_.addressType = (u_int16_t) AF_ATM; + + atm_addr_.sap.t_atm_sap_addr.SVE_tag_addr = (int8_t) T_ATM_ABSENT; + atm_addr_.sap.t_atm_sap_addr.SVE_tag_selector = (int8_t) T_ATM_PRESENT; + + atm_addr_.sap.t_atm_sap_addr.address_format = (u_int8_t) T_ATM_ENDSYS_ADDR; + atm_addr_.sap.t_atm_sap_addr.address_length = ATMNSAP_ADDR_LEN; + atm_addr_.sap.t_atm_sap_addr.address[ATMNSAP_ADDR_LEN - 1] = selector; + + atm_addr_.sap.t_atm_sap_layer2.SVE_tag = (int8_t) T_ATM_ABSENT; + atm_addr_.sap.t_atm_sap_layer3.SVE_tag = (int8_t) T_ATM_ABSENT; + + atm_addr_.sap.t_atm_sap_appl.SVE_tag = (int8_t) T_ATM_PRESENT; + atm_addr_.sap.t_atm_sap_appl.ID_type = (u_int8_t) T_ATM_USER_APP_ID; + + ACE_OS::memcpy (atm_addr_.sap.t_atm_sap_appl.ID.user_defined_ID, + BHLI_MAGIC, + sizeof atm_addr_.sap.t_atm_sap_appl.ID); +#elif defined (ACE_HAS_FORE_ATM_WS2) + ACE_OS::memset ((void *)&atm_addr_, 0, sizeof atm_addr_); + atm_addr_.satm_number.Addr[ ATM_ADDR_SIZE - 1 ] = (char)selector; + atm_addr_.satm_family = AF_ATM; + atm_addr_.satm_number.AddressType = ATM_NSAP; + atm_addr_.satm_number.NumofDigits = ATM_ADDR_SIZE; + atm_addr_.satm_blli.Layer2Protocol = SAP_FIELD_ABSENT; + atm_addr_.satm_blli.Layer3Protocol = SAP_FIELD_ABSENT; + atm_addr_.satm_bhli.HighLayerInfoType = SAP_FIELD_ABSENT; + + // Need to know the correspondence. + //atm_addr_.sap.t_atm_sap_appl.SVE_tag = (int8_t) T_ATM_PRESENT; + //atm_addr_.sap.t_atm_sap_appl.ID_type = (u_int8_t) T_ATM_USER_APP_ID; + //ACE_OS::memcpy (atm_addr_.sap.t_atm_sap_appl.ID.user_defined_ID, + // BHLI_MAGIC, + // sizeof atm_addr_.sap.t_atm_sap_appl.ID); +#elif defined (ACE_HAS_LINUX_ATM) + atm_addr_.sockaddratmsvc.sas_family = AF_ATMSVC; + atm_addr_.sockaddratmsvc.sas_addr.prv[ATM_ESA_LEN - 1] = (char)selector; + atm_addr_.atmsap.blli[0].l3_proto = ATM_L3_NONE; + atm_addr_.atmsap.blli[0].l2_proto = ATM_L2_NONE; + atm_addr_.atmsap.bhli.hl_type = ATM_HL_NONE; +#else + ACE_UNUSED_ARG (selector); +#endif /* ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_ATM_WS2 || ACE_HAS_LINUX_ATM */ +} + +int +ACE_ATM_Addr::set (const ACE_ATM_Addr &sap, + u_char selector) +{ + ACE_TRACE ("ACE_ATM_Addr::set"); + + this->init (selector); + + this->ACE_Addr::base_set (sap.get_type (), + sap.get_size ()); + +#if defined (ACE_HAS_FORE_ATM_XTI) || defined (ACE_HAS_FORE_ATM_WS2) + ACE_ASSERT (sap.get_type () == AF_ATM); +#elif defined (ACE_HAS_LINUX_ATM) + ACE_ASSERT (sap.get_type () == PF_ATMSVC); +#endif /* ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_ATM_WS2 */ + + (void) ACE_OS::memcpy ((void *) &this->atm_addr_, + (void *) &sap.atm_addr_, + sizeof this->atm_addr_); + return 0; +} + +int +ACE_ATM_Addr::set (const ATM_Addr *sap, + u_char selector) +{ + ACE_TRACE ("ACE_ATM_Addr::set"); + + this->init (selector); + +#if defined (ACE_HAS_FORE_ATM_XTI) || defined (ACE_HAS_FORE_ATM_WS2) + this->ACE_Addr::base_set (AF_ATM, +#elif defined (ACE_HAS_LINUX_ATM) + this->ACE_Addr::base_set (PF_ATMSVC, +#else + this->ACE_Addr::base_set (AF_UNSPEC, +#endif /* ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_ATM_WS2 */ + sizeof (*sap)); + + (void) ACE_OS::memcpy ((void *) &this->atm_addr_, + (void *) sap, + sizeof this->atm_addr_); + return 0; +} + +int +ACE_ATM_Addr::set (const ACE_TCHAR address[], + u_char selector) +{ + ACE_TRACE ("ACE_ATM_Addr::set"); + int ret; + + this->init (selector); + +#if defined (ACE_HAS_FORE_ATM_XTI) + atm_addr_.sap.t_atm_sap_addr.SVE_tag_addr = + (int8_t) T_ATM_PRESENT; +#endif /* ACE_HAS_FORE_ATM_XTI */ + + ret = this -> string_to_addr (address); + this -> set_selector (selector); + return ret; +} + +// Transform the string into the current addressing format. + +int +ACE_ATM_Addr::string_to_addr (const ACE_TCHAR sap[]) +{ + ACE_TRACE ("ACE_ATM_Addr::string_to_addr"); + +#if defined (ACE_HAS_FORE_ATM_XTI) || defined (ACE_HAS_FORE_ATM_WS2) + this->ACE_Addr::base_set (AF_ATM, +#elif defined (ACE_HAS_LINUX_ATM) + this->ACE_Addr::base_set (PF_ATMSVC, +#else + this->ACE_Addr::base_set (AF_UNSPEC, +#endif /* ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_ATM_WS2 || ACE_HAS_LINUX_ATM */ + sizeof this->atm_addr_); +#if defined (ACE_HAS_FORE_ATM_XTI) + struct hostent *entry; + struct atmnsap_addr *nsap; + + // Yow, someone gave us a NULL ATM address! + if (sap == 0) + { + errno = EINVAL; + return -1; + } + else if ((entry = gethostbyname_atmnsap ((ACE_TCHAR *)sap)) != 0) + { + ACE_OS::memcpy (atm_addr_.sap.t_atm_sap_addr.address, + entry->h_addr_list[0], + ATMNSAP_ADDR_LEN - 1); + } + else if ((nsap = atmnsap_addr (sap)) != 0) + { + ACE_OS::memcpy (atm_addr_.sap.t_atm_sap_addr.address, + nsap->atmnsap, + ATMNSAP_ADDR_LEN); + } + else { + errno = EINVAL; + return -1; + } +#elif defined (ACE_HAS_FORE_ATM_WS2) + DWORD dwValue; + HANDLE hLookup; + WSAQUERYSETW qsRestrictions; + CSADDR_INFO csaBuffer; + WCHAR tmpWStr[100]; + + MultiByteToWideChar (CP_ACP, MB_PRECOMPOSED, sap, -1, tmpWStr, 100); + + csaBuffer.LocalAddr.iSockaddrLength = sizeof (struct sockaddr_atm); + csaBuffer.LocalAddr.lpSockaddr = (struct sockaddr *)&atm_addr_; + csaBuffer.RemoteAddr.iSockaddrLength = sizeof (struct sockaddr_atm); + csaBuffer.RemoteAddr.lpSockaddr = (struct sockaddr *)&atm_addr_; + + qsRestrictions.dwSize = sizeof (WSAQUERYSETW); + qsRestrictions.lpszServiceInstanceName = 0; + qsRestrictions.lpServiceClassId = &FORE_NAME_CLASS; + qsRestrictions.lpVersion = 0; + qsRestrictions.lpszComment = 0; + qsRestrictions.dwNameSpace = FORE_NAME_SPACE; + qsRestrictions.lpNSProviderId = 0; + qsRestrictions.lpszContext = L""; + qsRestrictions.dwNumberOfProtocols = 0; + qsRestrictions.lpafpProtocols = 0; + qsRestrictions.lpszQueryString = tmpWStr; + qsRestrictions.dwNumberOfCsAddrs = 1; + qsRestrictions.lpcsaBuffer = &csaBuffer; + qsRestrictions.lpBlob = 0; //&blob; + + if (::WSALookupServiceBeginW (&qsRestrictions, LUP_RETURN_ALL, &hLookup) + == SOCKET_ERROR) { + ACE_OS::printf ("Error: WSALookupServiceBeginW failed! %d\n", + ::WSAGetLastError ()); + return -1; + } + + dwValue = sizeof (WSAQUERYSETW); + + if (::WSALookupServiceNextW (hLookup, 0, &dwValue, &qsRestrictions) + == SOCKET_ERROR) { + if (WSAGetLastError () != WSA_E_NO_MORE) { + ACE_OS::printf ("Error: WSALookupServiceNextW failed! %d\n", + ::WSAGetLastError ()); + return -1; + } + } + + if (WSALookupServiceEnd (hLookup) == SOCKET_ERROR) { + ACE_OS::printf ("Error : WSALookupServiceEnd failed! %d \n", + ::WSAGetLastError ()); + errno = EINVAL; + return -1; + } +#elif defined (ACE_HAS_LINUX_ATM) + if (sap == 0 || !ACE_OS::strcmp (sap,"")) { + errno = EINVAL; + return -1; + } + + if (text2atm ((ACE_TCHAR *)sap, + (struct sockaddr *)& (atm_addr_.sockaddratmsvc), + sizeof (atm_addr_.sockaddratmsvc), + T2A_SVC | T2A_NAME) < 0) { + ACE_DEBUG (LM_DEBUG, + "Error : text2atm failed!\n"); + errno = EINVAL; + return -1; + } +#else + ACE_UNUSED_ARG (sap); + + return 0; +#endif /* ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_ATM_WS2 || ACE_HAS_LINUX_ATM */ + +#if defined (ACE_HAS_FORE_ATM_XTI) || defined (ACE_HAS_FORE_ATM_WS2) || defined (ACE_HAS_LINUX_ATM) + return 0; +#endif /* ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_ATM_WS2 */ +} + +// Transform the current address into string format. + +int +ACE_ATM_Addr::addr_to_string (ACE_TCHAR addr[], + size_t addrlen) const +{ + ACE_TRACE ("ACE_ATM_Addr::addr_to_string"); + +#if defined (ACE_HAS_FORE_ATM_XTI) + ACE_TCHAR buffer[MAXNAMELEN + 1]; + struct atmnsap_addr nsap; + ACE_OS::memcpy (nsap.atmnsap, + atm_addr_.sap.t_atm_sap_addr.address, + ATMNSAP_ADDR_LEN); + ACE_OS::sprintf (buffer, + ACE_TEXT ("%s"), + atmnsap_ntoa (nsap)); + + size_t total_len = ACE_OS::strlen (buffer) + sizeof ('\0'); + + if (addrlen < total_len) + return -1; + else + ACE_OS::strcpy (addr, buffer); + + return 0; +#elif defined (ACE_HAS_FORE_ATM_WS2) + ACE_TCHAR buffer[MAXNAMELEN + 1]; + int i; + + if (addrlen < ATM_ADDR_SIZE + 1) + return -1; + + for (i = 0; i < ATM_ADDR_SIZE; i++) { + buffer[ i * 3 ] = '\0'; + ACE_OS::sprintf (buffer, ACE_TEXT ("%s%02x."), + buffer, + atm_addr_.satm_number.Addr[ i ]); + } + + buffer[ ATM_ADDR_SIZE * 3 - 1 ] = '\0'; + ACE_OS::strcpy (addr, buffer); + + return 0; +#elif defined (ACE_HAS_LINUX_ATM) + ACE_TCHAR buffer[MAX_ATM_ADDR_LEN + 1]; + int total_len; + if ((total_len = atm2text (buffer, + sizeof buffer, + (struct sockaddr *)& (atm_addr_.sockaddratmsvc), + A2T_PRETTY)) < 0) { + ACE_DEBUG ((LM_DEBUG,"ACE_ATM_Addr (addr_to_string): atm2text failed\n")); + return -1; + } + if (addrlen < (size_t)total_len) + return -1; + else + ACE_OS::strcpy (addr, + buffer); + + return 0; +#else + ACE_UNUSED_ARG (addr); + ACE_UNUSED_ARG (addrlen); + return -1; +#endif /* ACE_HAS_FORE_ATM_XTI && ACE_HAS_FORE_ATM_WS2 */ +} + +const ACE_TCHAR * +ACE_ATM_Addr::addr_to_string (void) const +{ + ACE_TRACE ("ACE_ATM_Addr::addr_to_string"); + + static ACE_TCHAR addr[MAXHOSTNAMELEN + 1]; + if (this->addr_to_string (addr, + MAXHOSTNAMELEN + 1) < 0) + return 0; + + return addr; +} + +// Set a pointer to the address. +void +ACE_ATM_Addr::set_addr (void *addr, int len) +{ + ACE_TRACE ("ACE_ATM_Addr::set_addr"); + +#if defined (ACE_HAS_FORE_ATM_XTI) || defined (ACE_HAS_FORE_ATM_WS2) + this->ACE_Addr::base_set (AF_ATM, +#elif defined (ACE_HAS_LINUX_ATM) + this->ACE_Addr::base_set (PF_ATMSVC, +#else + this->ACE_Addr::base_set (AF_UNSPEC, +#endif /* ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_WS2 */ + len); + ACE_OS::memcpy ((void *) &this->atm_addr_, + (void *) addr, len); +} + +// Compare two addresses for inequality. + +bool +ACE_ATM_Addr::operator != (const ACE_ATM_Addr &sap) const +{ + ACE_TRACE ("ACE_ATM_Addr::operator !="); + return ! ((*this) == sap); +} + +// Compare two addresses for equality. + +bool +ACE_ATM_Addr::operator == (const ACE_ATM_Addr &sap) const +{ + ACE_TRACE ("ACE_ATM_Addr::operator =="); + +#if defined (ACE_HAS_LINUX_ATM) + return (atm_equal ((const struct sockaddr *)& (this->atm_addr_.sockaddratmsvc), + (const struct sockaddr *)& (sap.atm_addr_.sockaddratmsvc), + 0, + 0) + && + sap_equal (& (this->atm_addr_.atmsap), + & (sap.atm_addr_.atmsap), + 0)); +#else + return ACE_OS::memcmp (&atm_addr_, + &sap.atm_addr_, + sizeof (ATM_Addr)) == 0; +#endif /* ACE_HAS_LINUX_ATM */ +} + +void +ACE_ATM_Addr::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + ACE_TRACE ("ACE_ATM_Addr::dump"); + + ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); + + ACE_TCHAR s[ACE_MAX_FULLY_QUALIFIED_NAME_LEN + 16]; + ACE_OS::sprintf (s, + ACE_TEXT ("%s"), + this->addr_to_string ()); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("%s"), s)); + ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); +#endif /* ACE_HAS_DUMP */ +} + +ACE_END_VERSIONED_NAMESPACE_DECL + +#endif /* ACE_HAS_ATM */ diff --git a/dep/ACE_wrappers/ace/ATM_Addr.h b/dep/ACE_wrappers/ace/ATM_Addr.h new file mode 100644 index 00000000000..7fa93f1492c --- /dev/null +++ b/dep/ACE_wrappers/ace/ATM_Addr.h @@ -0,0 +1,197 @@ +// -*- C++ -*- + +//========================================================================== +/** + * @file ATM_Addr.h + * + * $Id: ATM_Addr.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Joe Hoffert + */ +//========================================================================== + +#ifndef ACE_ATM_ADDR_H +#define ACE_ATM_ADDR_H +#include /**/ "ace/pre.h" + +#include /**/ "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#if defined (ACE_HAS_ATM) + +#include /**/ "ace/ACE_export.h" +#include "ace/Addr.h" + +#if defined (ACE_HAS_FORE_ATM_XTI) +ACE_BEGIN_VERSIONED_NAMESPACE_DECL +typedef ATMSAPAddress ATM_Addr; +ACE_END_VERSIONED_NAMESPACE_DECL +#elif defined (ACE_HAS_FORE_ATM_WS2) +#define FORE_NAME_SPACE NS_ALL +ACE_BEGIN_VERSIONED_NAMESPACE_DECL +typedef struct sockaddr_atm ATM_Addr; +ACE_END_VERSIONED_NAMESPACE_DECL +#elif defined (ACE_HAS_LINUX_ATM) + +#include /**/ "atm.h" + +// Open versioned namespace, if enabled by the user. +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +//pbrandao:as Linux has this 2 structs separeted we "link it" here +typedef struct _linux_atm_addr +{ + struct sockaddr_atmsvc sockaddratmsvc; + struct atm_sap atmsap; +} ATM_Addr; +#else +typedef int ATM_Addr; +#endif /* ACE_HAS_FORE_ATM_XTI/ACE_HAS_FORE_ATM_WS2/ACE_HAS_LINUX_ATM */ + +/** + * @class ACE_ATM_Addr + * + * @brief Defines the ATM domain address family address format. + */ +class ACE_Export ACE_ATM_Addr : public ACE_Addr +{ +public: + // Constants used for ATM options + static const long LINE_RATE; + static const int OPT_FLAGS_CPID; + static const int OPT_FLAGS_PMP; + static const int DEFAULT_SELECTOR; + + // = Initialization methods. + /// Default constructor. + ACE_ATM_Addr (u_char selector = DEFAULT_SELECTOR); + + /// Copy constructor. + ACE_ATM_Addr (const ACE_ATM_Addr &, + u_char selector = DEFAULT_SELECTOR); + + /** + * Creates an ACE_ATM_Addr from an ATMSAPAddress structure. This + * is vendor specific (FORE systems). May need to change when other + * vendors are supported. + */ + ACE_ATM_Addr (const ATM_Addr *, + u_char selector = DEFAULT_SELECTOR); + + /** + * Initializes an ACE_ATM_Addr from the which can be + * "atm-address" (e.g., + * "47.0005.80.ffe100.0000.f20f.2200.0020480694f9.00") or "hostname" + * (e.g., "frisbee.cs.wustl.edu"). + */ + ACE_ATM_Addr (const ACE_TCHAR sap[], + u_char selector = DEFAULT_SELECTOR); + + /// Default dtor. + ~ACE_ATM_Addr (void); + + // = Initialization methods (useful after object construction). + /// Default initialization for non-address values (e.g., + /// t_atm_sap_addr.SVE_tag_addr, t_atm_sap_addr.SVE_tag_selector) + void init (u_char selector = DEFAULT_SELECTOR); + + /// Initializes from another ACE_ATM_Addr. + int set (const ACE_ATM_Addr &, + u_char selector = DEFAULT_SELECTOR); + + /** + * Initializes an ACE_ATM_Addr from an ATMSAPAddress/sockaddr_atm + * structure. This is vendor specific (FORE systems). May need to + * change when other vendors are supported. + */ + int set (const ATM_Addr *, + u_char selector = DEFAULT_SELECTOR); + + /** + * Initializes an ACE_ATM_Addr from the which can be + * "atm-address" (e.g., + * "47.0005.80.ffe100.0000.f20f.2200.0020480694f9.00") or "hostname" + * (e.g., "frisbee.cs.wustl.edu"). + */ + int set (const ACE_TCHAR sap[], + u_char selector = DEFAULT_SELECTOR); + + /** + * Initializes an ACE_ATM_Addr from the which can be + * "atm-address" (e.g., + * "47.0005.80.ffe100.0000.f20f.2200.0020480694f9.00") or "hostname" + * (e.g., "frisbee.cs.wustl.edu"). + */ + virtual int string_to_addr (const ACE_TCHAR sap[]); + + /** + * Return the character representation of the ATM address (e.g., + * "47.0005.80.ffe100.0000.f20f.2200.0020480694f9.00") storing it in + * the @a addr (which is assumed to be bytes long). This + * version is reentrant. Returns -1 if the of the @a addr + * is too small, else 0. + */ + virtual int addr_to_string (ACE_TCHAR addr[], + size_t addrlen) const; + + /** + * Return the character representation of the ATM address (e.g., + * "47.0005.80.ffe100.0000.f20f.2200.0020480694f9.00"). Returns -1 + * if the of the is too small, else 0.(This version + * is non-reentrant since it returns a pointer to a static data + * area.) + */ + const ACE_TCHAR *addr_to_string (void) const; + + /// Return a pointer to the underlying network address. + virtual void *get_addr (void) const; + + /// Set a pointer to the address. + virtual void set_addr (void *, int); + + /// Return the selector for network address. + u_char get_selector (void) const; + + /// Set the selector for the network address. + void set_selector (u_char selector); + + /** + * Compare two addresses for equality. The addresses are considered + * equal if they contain the same ATM address. Q: Is there any + * other check for equality needed for ATM? + */ + bool operator == (const ACE_ATM_Addr &SAP) const; + + /// Compare two addresses for inequality. + bool operator != (const ACE_ATM_Addr &SAP) const; + + /// Dump the state of an object. + void dump (void) const; + + /// Declare the dynamic allocation hooks. + ACE_ALLOC_HOOK_DECLARE; + +// char *construct_options (ACE_HANDLE fd, +// int qos_kb, +// int flags, +// long *optsize); +// // Construct options for ATM connections + +private: + ATM_Addr atm_addr_; +}; + +// Close versioned namespace, if enabled by the user. +ACE_END_VERSIONED_NAMESPACE_DECL + + +#if defined (__ACE_INLINE__) +#include "ace/ATM_Addr.inl" +#endif /* __ACE_INLINE__ */ + +#endif /* ACE_HAS_ATM */ +#include /**/ "ace/post.h" +#endif /* ACE_ATM_ADDR_H */ diff --git a/dep/ACE_wrappers/ace/ATM_Addr.inl b/dep/ACE_wrappers/ace/ATM_Addr.inl new file mode 100644 index 00000000000..55f43d6613a --- /dev/null +++ b/dep/ACE_wrappers/ace/ATM_Addr.inl @@ -0,0 +1,37 @@ +// -*- C++ -*- +// +// $Id: ATM_Addr.inl 80826 2008-03-04 14:51:23Z wotte $ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_INLINE u_char +ACE_ATM_Addr::get_selector (void) const +{ + ACE_TRACE ("ACE_ATM_Addr::get_selector"); +#if defined (ACE_HAS_FORE_ATM_XTI) + return atm_addr_.sap.t_atm_sap_addr.address[ATMNSAP_ADDR_LEN - 1]; +#elif defined (ACE_HAS_FORE_ATM_WS2) + return atm_addr_.satm_number.Addr[ ATM_ADDR_SIZE - 1 ]; +#elif defined (ACE_HAS_LINUX_ATM) + return atm_addr_.sockaddratmsvc.sas_addr.prv[ATM_ESA_LEN - 1]; +#else + return 0; +#endif /* ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_ATM_WS2 || ACE_HAS_LINUX_ATM */ +} + +ACE_INLINE void +ACE_ATM_Addr::set_selector (u_char selector) +{ + ACE_TRACE ("ACE_ATM_Addr::set_selector"); +#if defined (ACE_HAS_FORE_ATM_XTI) + atm_addr_.sap.t_atm_sap_addr.address[ATMNSAP_ADDR_LEN - 1] = selector; +#elif defined (ACE_HAS_FORE_ATM_WS2) + atm_addr_.satm_number.Addr[ ATM_ADDR_SIZE - 1 ] = selector; +#elif defined (ACE_HAS_LINUX_ATM) + atm_addr_.sockaddratmsvc.sas_addr.prv[ATM_ESA_LEN - 1] = selector; +#else + ACE_UNUSED_ARG (selector); +#endif /* ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_ATM_WS2 || ACE_HAS_LINUX_ATM */ +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/ATM_Connector.cpp b/dep/ACE_wrappers/ace/ATM_Connector.cpp new file mode 100644 index 00000000000..c1ce226adce --- /dev/null +++ b/dep/ACE_wrappers/ace/ATM_Connector.cpp @@ -0,0 +1,138 @@ +// ATM_Connector.cpp +// $Id: ATM_Connector.cpp 80826 2008-03-04 14:51:23Z wotte $ + +#include "ace/ATM_Connector.h" +#if defined (ACE_HAS_ATM) + +#include "ace/Handle_Set.h" + +ACE_RCSID(ace, ATM_Connector, "$Id: ATM_Connector.cpp 80826 2008-03-04 14:51:23Z wotte $") + +#if !defined (__ACE_INLINE__) +#include "ace/ATM_Connector.inl" +#endif /* __ACE_INLINE__ */ + +// Open versioned namespace, if enabled by the user. +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_ALLOC_HOOK_DEFINE(ACE_ATM_Connector) + +ACE_ATM_Connector::ACE_ATM_Connector (void) +{ + ACE_TRACE ("ACE_ATM_Connector::ACE_ATM_Connector"); +} + +// Actively connect and produce a new ACE_ATM_Stream if things go well... +// Connect the to the , waiting up to +// amount of time if necessary. + +int +ACE_ATM_Connector::connect (ACE_ATM_Stream &new_stream, + const ACE_ATM_Addr &remote_sap, + ACE_ATM_Params params, + ACE_ATM_QoS options, + ACE_Time_Value *timeout, + const ACE_ATM_Addr &local_sap, + int reuse_addr, + int flags, + int perms) +{ + ACE_TRACE ("ACE_ATM_Connector::connect"); +#if defined (ACE_HAS_FORE_ATM_XTI) + return connector_.connect(new_stream.get_stream(), + remote_sap, + timeout, + local_sap, + reuse_addr, + flags, + perms, + params.get_device(), + params.get_info(), + params.get_rw_flag(), + params.get_user_data(), + &options.get_qos()); +#elif defined (ACE_HAS_FORE_ATM_WS2) + ACE_DEBUG(LM_DEBUG, + ACE_TEXT ("ATM_Connector(connect): set QoS parameters\n" )); + + ACE_HANDLE s = new_stream.get_handle(); + struct sockaddr_atm *saddr = ( struct sockaddr_atm *)remote_sap.get_addr(); + ACE_QoS cqos = options.get_qos(); + + ACE_QoS_Params qos_params = ACE_QoS_Params(0, + 0, + &cqos, + 0, + 0); + + ACE_DEBUG(LM_DEBUG, + ACE_TEXT ("ATM_Connector(connect): connecting...\n")); + + int result = ACE_OS::connect( s, + ( struct sockaddr *)saddr, + sizeof( struct sockaddr_atm ), + qos_params ); + + if ( result != 0 ) + ACE_OS::printf( "ATM_Connector(connect): connection failed, %d\n", + ::WSAGetLastError()); + + return result; +#elif defined (ACE_HAS_LINUX_ATM) + ACE_UNUSED_ARG (params); + ACE_UNUSED_ARG (timeout); + ACE_UNUSED_ARG (reuse_addr); + ACE_UNUSED_ARG (perms); + ACE_UNUSED_ARG (flags); + + ACE_HANDLE handle = new_stream.get_handle(); + ATM_QoS qos =options.get_qos(); + ATM_Addr *local_addr=(ATM_Addr*)local_sap.get_addr(), + *remote_addr=(ATM_Addr*)remote_sap.get_addr(); + + if (ACE_OS::setsockopt(handle, + SOL_ATM, + SO_ATMSAP, + reinterpret_cast (&(local_addr->atmsap)), + sizeof(local_addr->atmsap)) < 0) { + ACE_OS::printf( "ATM_Connector(connect): unable to set atmsap %d\nContinuing...", + errno); + } + if (ACE_OS::setsockopt(handle, + SOL_ATM, + SO_ATMQOS, + reinterpret_cast (&qos), + sizeof(qos)) < 0) { + ACE_DEBUG((LM_DEBUG,ACE_TEXT ("ATM_Connector(connect): unable to set qos %d\n"), + errno)); + return -1; + } + + int result = ACE_OS::connect(handle, + (struct sockaddr *)&(remote_addr->sockaddratmsvc), + sizeof( remote_addr->sockaddratmsvc)); + + if ( result != 0 ) + ACE_DEBUG(LM_DEBUG, + ACE_TEXT ("ATM_Connector(connect): connection failed, %d\n"), + errno); + + return result; +#else + ACE_UNUSED_ARG (new_stream); + ACE_UNUSED_ARG (remote_sap); + ACE_UNUSED_ARG (params); + ACE_UNUSED_ARG (options); + ACE_UNUSED_ARG (timeout); + ACE_UNUSED_ARG (local_sap); + ACE_UNUSED_ARG (reuse_addr); + ACE_UNUSED_ARG (flags); + ACE_UNUSED_ARG (perms); + return 0; +#endif /* ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_ATM_WS2 || ACE_HAS_LINUX_ATM */ +} + +// Close versioned namespace, if enabled by the user. +ACE_END_VERSIONED_NAMESPACE_DECL + +#endif /* ACE_HAS_ATM */ diff --git a/dep/ACE_wrappers/ace/ATM_Connector.h b/dep/ACE_wrappers/ace/ATM_Connector.h new file mode 100644 index 00000000000..cbeedeea7f6 --- /dev/null +++ b/dep/ACE_wrappers/ace/ATM_Connector.h @@ -0,0 +1,164 @@ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file ATM_Connector.h + * + * $Id: ATM_Connector.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Joe Hoffert + */ +//============================================================================= + +#ifndef ACE_ATM_CONNECTOR_H +#define ACE_ATM_CONNECTOR_H +#include /**/ "ace/pre.h" + +#include /**/ "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#if defined (ACE_HAS_ATM) + +#include "ace/ATM_Stream.h" +#include "ace/ATM_Params.h" +#include "ace/ATM_QoS.h" + +#if defined (ACE_WIN32) || defined (ACE_HAS_LINUX_ATM) +#include "ace/SOCK_Connector.h" +ACE_BEGIN_VERSIONED_NAMESPACE_DECL +typedef ACE_SOCK_Connector ATM_Connector; +ACE_END_VERSIONED_NAMESPACE_DECL +#else +#include "ace/XTI_ATM_Mcast.h" +ACE_BEGIN_VERSIONED_NAMESPACE_DECL +typedef ACE_XTI_ATM_Mcast ATM_Connector; +// Open versioned namespace, if enabled by the user. +ACE_END_VERSIONED_NAMESPACE_DECL +#endif + +// Open versioned namespace, if enabled by the user. +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +/** + * @class ACE_ATM_Connector + * + * @brief Defines an active connection factory for the ACE_ATM C++ + * wrappers. + */ +class ACE_Export ACE_ATM_Connector +{ +public: + // = Initialization methods. + /// Default constructor. + ACE_ATM_Connector (void); + + /** + * Actively connect and produce a @a new_stream if things go well. + * The @a remote_sap is the address that we are trying to connect + * with. The are the parameters needed for either socket + * or XTI/ATM connections. The @a timeout is the amount of time to + * wait to connect. If it's 0 then we block indefinitely. If + * *timeout == {0, 0} then the connection is done using non-blocking + * mode. In this case, if the connection can't be made immediately + * the value of -1 is returned with @c errno == EWOULDBLOCK. If + * *timeout > {0, 0} then this is the maximum amount of time to wait before + * timing out. If the time expires before the connection is made + * @c errno == ETIME. The @a local_sap is the value of local address + * to bind to. If it's the default value of then + * the user is letting the OS do the binding. If @a reuse_addr == 1 + * then the is reused, even if it hasn't been cleanedup yet. + */ + ACE_ATM_Connector (ACE_ATM_Stream &new_stream, + const ACE_ATM_Addr &remote_sap, + ACE_ATM_Params params = ACE_ATM_Params(), + ACE_ATM_QoS options = ACE_ATM_QoS(), + ACE_Time_Value *timeout = 0, + const ACE_ATM_Addr &local_sap = ACE_ATM_Addr( "", 0 ), + int reuse_addr = 0, +#if defined (ACE_WIN32) + int flags = 0, +#else + int flags = O_RDWR, +#endif /* ACE_WIN32 */ + int perms = 0); + + /** + * Actively connect and produce a @a new_stream if things go well. + * The @a remote_sap is the address that we are trying to connect + * with. The are the parameters needed for either socket + * or XTI/ATM connections. The @a timeout is the amount of time to + * wait to connect. If it's 0 then we block indefinitely. If + * *timeout == {0, 0} then the connection is done using non-blocking + * mode. In this case, if the connection can't be made immediately + * the value of -1 is returned with @c errno == EWOULDBLOCK. If + * *timeout > {0, 0} then this is the maximum amount of time to wait before + * timing out. If the time expires before the connection is made + * @c errno == ETIME. The @a local_sap is the value of local address + * to bind to. If it's the default value of then + * the user is letting the OS do the binding. If @a reuse_addr == 1 + * then the is reused, even if it hasn't been cleanedup yet. + */ + int connect (ACE_ATM_Stream &new_stream, + const ACE_ATM_Addr &remote_sap, + ACE_ATM_Params params = ACE_ATM_Params(), + ACE_ATM_QoS options = ACE_ATM_QoS(), + ACE_Time_Value *timeout = 0, + const ACE_ATM_Addr &local_sap = ACE_ATM_Addr( "", + 0 ), + int reuse_addr = 0, +#if defined (ACE_WIN32) + int flags = 0, +#else + int flags = O_RDWR, +#endif /* ACE_WIN32 */ + int perms = 0); + + /** + * Try to complete a non-blocking connection. + * If connection completion is successful then @a new_stream contains + * the connected ACE_SOCK_Stream. If @a remote_sap is non-NULL then it + * will contain the address of the connected peer. + */ + int complete (ACE_ATM_Stream &new_stream, + ACE_ATM_Addr *remote_sap, + ACE_Time_Value *tv); + + /** + * Actively add a leaf to the root (i.e., point-to-multipoint). The + * @a remote_sap is the address of the leaf that we + * are trying to add. + */ + int add_leaf (ACE_ATM_Stream ¤t_stream, + const ACE_Addr &remote_sap, + ACE_ATM_QoS &qos); + + /// Resets any event associations on this handle + int reset_new_handle (ACE_HANDLE handle); + + // = Meta-type info + typedef ACE_ATM_Addr PEER_ADDR; + typedef ACE_ATM_Stream PEER_STREAM; + + /// Dump the state of an object. + void dump (void) const; + + /// Declare the dynamic allocation hooks. + ACE_ALLOC_HOOK_DECLARE; + +private: + ATM_Connector connector_; +}; + +// Open versioned namespace, if enabled by the user. +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +#include "ace/ATM_Connector.inl" +#endif /* __ACE_INLINE__ */ + +#endif /* ACE_HAS_ATM */ +#include /**/ "ace/post.h" +#endif /* ACE_ATM_CONNECTOR_H */ diff --git a/dep/ACE_wrappers/ace/ATM_Connector.inl b/dep/ACE_wrappers/ace/ATM_Connector.inl new file mode 100644 index 00000000000..0b89cbf0828 --- /dev/null +++ b/dep/ACE_wrappers/ace/ATM_Connector.inl @@ -0,0 +1,132 @@ +// -*- C++ -*- +// +// $Id: ATM_Connector.inl 80826 2008-03-04 14:51:23Z wotte $ + +// Open versioned namespace, if enabled by the user. +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_INLINE void +ACE_ATM_Connector::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + ACE_TRACE ("ACE_ATM_Connector::dump"); +#endif /* ACE_HAS_DUMP */ +} + +ACE_INLINE +ACE_ATM_Connector::ACE_ATM_Connector (ACE_ATM_Stream &new_stream, + const ACE_ATM_Addr &remote_sap, + ACE_ATM_Params params, + ACE_ATM_QoS options, + ACE_Time_Value *timeout, + const ACE_ATM_Addr &local_sap, + int reuse_addr, + int flags, + int perms) +{ + ACE_TRACE ("ACE_ATM_Connector::ACE_ATM_Connector"); + if ((ACE_HANDLE)this->connect (new_stream, + remote_sap, + params, + options, + timeout, + local_sap, + reuse_addr, + flags, + perms) == ACE_INVALID_HANDLE + && timeout != 0 && !(errno == EWOULDBLOCK || errno == ETIME)) + ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"), + ACE_TEXT ("ACE_ATM_Stream::ACE_ATM_Stream"))); +} + +// Try to complete a non-blocking connection. + +ACE_INLINE +int +ACE_ATM_Connector::complete (ACE_ATM_Stream &new_stream, + ACE_ATM_Addr *remote_sap, + ACE_Time_Value *tv) +{ + ACE_TRACE ("ACE_ATM_Connector::complete"); +#if defined (ACE_HAS_ATM) + return connector_.complete(new_stream.get_stream(), + remote_sap, + tv); +#else + ACE_UNUSED_ARG(new_stream); + ACE_UNUSED_ARG(remote_sap); + ACE_UNUSED_ARG(tv); + return 0; +#endif +} + +ACE_INLINE +int +ACE_ATM_Connector::add_leaf (ACE_ATM_Stream ¤t_stream, + const ACE_Addr &remote_sap, + ACE_ATM_QoS &qos) +{ + ACE_TRACE ("ACE_ATM_Connector::add_leaf"); +#if defined (ACE_HAS_FORE_ATM_XTI) + return connector_.add_leaf(current_stream.get_stream(), + remote_sap, + leaf_id, + timeout); +#elif defined (ACE_HAS_FORE_ATM_WS2) + struct sockaddr_atm *saddr = (struct sockaddr_atm *)remote_sap.get_addr(); + ACE_QoS cqos = qos.get_qos(); + int addr_len = sizeof( struct sockaddr_atm ); + + ACE_QoS_Params qos_params(0, + 0, + &cqos, + 0, + (JL_SENDER_ONLY)); + + ACE_OS::printf( "ATM_Connector::add_leaf: connecting...\n" ); + + ACE_HANDLE result = ACE_OS::join_leaf(current_stream.get_handle(), + (struct sockaddr *)saddr, + addr_len, + qos_params); + + if ( result == ACE_INVALID_HANDLE ) + ACE_OS::printf( "ATM_Connector(add_leaf): connection failed, %d\n", + ::WSAGetLastError()); + + return (result != ACE_INVALID_HANDLE); +#elif defined (ACE_HAS_LINUX_ATM) + ACE_OS::printf("ATM_Connector(add_leaf): not yet implemented in Linux \n"); + + ACE_UNUSED_ARG(current_stream); + ACE_UNUSED_ARG(remote_sap); + ACE_UNUSED_ARG(leaf_id); + ACE_UNUSED_ARG(timeout); + + return 0; +#else + ACE_UNUSED_ARG(current_stream); + ACE_UNUSED_ARG(remote_sap); + ACE_UNUSED_ARG(leaf_id); + ACE_UNUSED_ARG(timeout); + return 0; +#endif +} + +ACE_INLINE +int +ACE_ATM_Connector::reset_new_handle (ACE_HANDLE handle) +{ +#if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) + // Reset the event association + return ::WSAEventSelect ((SOCKET) handle, + 0, + 0); +#else /* !defined ACE_HAS_WINSOCK2 */ + ACE_UNUSED_ARG (handle); + return 0; +#endif /* ACE_WIN32 */ +} + +// Close versioned namespace, if enabled by the user. +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/ATM_Params.cpp b/dep/ACE_wrappers/ace/ATM_Params.cpp new file mode 100644 index 00000000000..70a05f1d71b --- /dev/null +++ b/dep/ACE_wrappers/ace/ATM_Params.cpp @@ -0,0 +1,20 @@ +// $Id: ATM_Params.cpp 80826 2008-03-04 14:51:23Z wotte $ + +#include "ace/ATM_Params.h" + +#if defined (ACE_HAS_ATM) + +ACE_RCSID(ace, ATM_Params, "$Id: ATM_Params.cpp 80826 2008-03-04 14:51:23Z wotte $") + +#if !defined (__ACE_INLINE__) +#include "ace/ATM_Params.inl" +#endif /* __ACE_INLINE__ */ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_ALLOC_HOOK_DEFINE(ACE_ATM_Params) + +ACE_END_VERSIONED_NAMESPACE_DECL + +#endif /* ACE_HAS_ATM */ + diff --git a/dep/ACE_wrappers/ace/ATM_Params.h b/dep/ACE_wrappers/ace/ATM_Params.h new file mode 100644 index 00000000000..d1e8c923118 --- /dev/null +++ b/dep/ACE_wrappers/ace/ATM_Params.h @@ -0,0 +1,214 @@ +// -*- C++ -*- + +//========================================================================== +/** + * @file ATM_Params.h + * + * $Id: ATM_Params.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Joe Hoffert + */ +//========================================================================== + + +#ifndef ACE_ATM_PARAMS_H +#define ACE_ATM_PARAMS_H +#include /**/ "ace/pre.h" + +#include /**/ "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#if defined (ACE_HAS_ATM) + +#include /**/ "ace/ACE_export.h" + +#if defined (ACE_HAS_FORE_ATM_XTI) +#include "ace/TLI.h" +#define ATM_PROTOCOL_DEFAULT 0 +typedef struct t_info Param_Info; +typedef struct netbuf Param_Udata; +#elif defined (ACE_HAS_FORE_ATM_WS2) +#include "ace/SOCK.h" +#define ATM_PROTOCOL_DEFAULT ATMPROTO_AAL5 +#define ACE_XTI_ATM_DEVICE "" +typedef int Param_Info; +typedef int Param_Udata; +#elif defined (ACE_HAS_LINUX_ATM) +#include /**/ "atm.h" +#define AF_ATM PF_ATMSVC +#define ACE_XTI_ATM_DEVICE "" +#define ATM_PROTOCOL_DEFAULT ATM_AAL5 +typedef int Param_Info; +typedef int Param_Udata; +#else +#define ACE_XTI_ATM_DEVICE "" +typedef int Param_Info; +typedef int Param_Udata; +#endif /* ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_ATM_WS2 || ACE_HAS_LINUX_ATM */ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +/** + * @class ACE_ATM_Params + * + * @brief Wrapper class that simplifies the information passed to the ATM + * enabled ACE_ATM_Connector class. + */ +class ACE_Export ACE_ATM_Params +{ +public: + /** + * Initialize the data members. This class combines options from + * ACE_SOCK_Connector (@a protocol_family, @a protocol, , + * @a protocol_info, , and @a flags) and + * ACE_TLI_Connector (, , , , and ) + * so that either mechanism can be used transparently for ATM. + */ + ACE_ATM_Params (int rw_flag = 1, + const char device[] = ACE_XTI_ATM_DEVICE, + Param_Info *info = 0, + Param_Udata *udata = 0, + int oflag = O_RDWR, + int protocol_family = AF_ATM, + int protocol = ATM_PROTOCOL_DEFAULT, + int type = +#if defined (ACE_HAS_LINUX_ATM) + SOCK_DGRAM, +#else + SOCK_RAW, +#endif /* ACE_HAS_LINUX_ATM */ + ACE_Protocol_Info *protocol_info = 0, + ACE_SOCK_GROUP g = 0, + u_long flags + = ACE_FLAG_MULTIPOINT_C_ROOT + | ACE_FLAG_MULTIPOINT_D_ROOT, // connector by default + int reuse_addr = 0); + + /// Destructor. + ~ACE_ATM_Params (); + + /// Get protocol family. + int get_protocol_family (void) const; + + /// Set protocol family. + void set_protocol_family (int); + + /// Get protocol. + int get_protocol (void) const; + + /// Set protocol. + void set_protocol (int); + + /// Get type. + int get_type (void) const; + + /// Set type. + void set_type (int); + + /// Get protocol info. + ACE_Protocol_Info *get_protocol_info( void ); + + /// Set protocol info. + void set_protocol_info( ACE_Protocol_Info *); + + /// Get socket group. + ACE_SOCK_GROUP get_sock_group( void ); + + /// Set socket group. + void set_sock_group( ACE_SOCK_GROUP ); + + /// Get socket flags. + u_long get_flags( void ); + + /// Set socket flags. + void set_flags( u_long ); + + /// Get reuse_addr flag. + int get_reuse_addr (void) const; + + /// Set reuse_addr flag. + void set_reuse_addr (int); + + /// Get device. + const char* get_device (void) const; + + /// Get info. + Param_Info* get_info (void) const; + + /// Set info. + void set_info (Param_Info *); + + /// Get r/w flag. + int get_rw_flag (void) const; + + /// Set r/w flag. + void set_rw_flag (int); + + /// Get user data. + Param_Udata* get_user_data (void) const; + + /// Set user data. + void set_user_data (Param_Udata*); + + /// Get open flag. + int get_oflag (void) const; + + /// Set open flag. + void set_oflag (int); + + /// Dump the state of an object. + void dump (void) const; + + /// Declare the dynamic allocation hooks. + ACE_ALLOC_HOOK_DECLARE; + +private: + /// Protocol family for sockets connections. + int protocol_family_; + + /// Protocol for sockets connections. + int protocol_; + + /// Type for opening sockets. + int type_; + + /// Information about the protocol. + ACE_Protocol_Info *protocol_info_; + + /// Socket group used (for sockets only). + ACE_SOCK_GROUP group_; + + /// Flags for sockets (for sockets only). + u_long flags_; + + /// Flag for reusing address for opening sockets. + int reuse_addr_; + + /// Device name for XTI/ATM connections. + const char *device_; + + /// Info for XTI/ATM connections. + Param_Info *info_; + + /// R/W flag for XTI/ATM connections. + int rw_flag_; + + /// User data for XTI/ATM connections. + Param_Udata *udata_; + + /// Open flag for XTI/ATM connections. + int oflag_; +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +#include "ace/ATM_Params.inl" +#endif /* __ACE_INLINE__ */ + +#endif /* ACE_HAS_ATM */ +#include /**/ "ace/post.h" +#endif /* ACE_ATM_PARAMS_H */ diff --git a/dep/ACE_wrappers/ace/ATM_Params.inl b/dep/ACE_wrappers/ace/ATM_Params.inl new file mode 100644 index 00000000000..de2a4d45127 --- /dev/null +++ b/dep/ACE_wrappers/ace/ATM_Params.inl @@ -0,0 +1,235 @@ +// -*- C++ -*- +// +// $Id: ATM_Params.inl 80826 2008-03-04 14:51:23Z wotte $ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_INLINE void +ACE_ATM_Params::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + ACE_TRACE ("ACE_ATM_Params::dump"); +#endif /* ACE_HAS_DUMP */ +} + +ACE_INLINE +ACE_ATM_Params::ACE_ATM_Params (int rw_flag, + const char device[], + Param_Info *info, + Param_Udata *udata, + int oflag, + int protocol_family, + int protocol, + int type, + ACE_Protocol_Info *protocol_info, + ACE_SOCK_GROUP g, + u_long flags, + int reuse_addr) + : protocol_family_(protocol_family), + protocol_(protocol), + type_(type), + protocol_info_(protocol_info), + group_(g), + flags_(flags), + reuse_addr_(reuse_addr), + device_(device), + info_(info), + rw_flag_(rw_flag), + udata_(udata), + oflag_(oflag) +{ + ACE_TRACE ("ACE_ATM_Params::ACE_ATM_Params"); +} + +// Default dtor. +ACE_INLINE +ACE_ATM_Params::~ACE_ATM_Params (void) +{ + ACE_TRACE ("ACE_ATM_Params::~ACE_ATM_Params"); +} + +ACE_INLINE +int +ACE_ATM_Params::get_protocol_family (void) const +{ + ACE_TRACE ("ACE_ATM_Params::get_protocol_family"); + return protocol_family_; +} + +ACE_INLINE +void +ACE_ATM_Params::set_protocol_family (int family) +{ + ACE_TRACE ("ACE_ATM_Params::set_protocol_family"); + protocol_family_ = family; +} + +ACE_INLINE +int +ACE_ATM_Params::get_protocol (void) const +{ + ACE_TRACE ("ACE_ATM_Params::get_protocol"); + return protocol_; +} + +ACE_INLINE +void +ACE_ATM_Params::set_protocol (int protocol) +{ + ACE_TRACE ("ACE_ATM_Params::set_protocol"); + protocol_ = protocol; +} + +ACE_INLINE +int +ACE_ATM_Params::get_type (void) const +{ + ACE_TRACE ("ACE_ATM_Params::get_type"); + return type_; +} + +ACE_INLINE +void +ACE_ATM_Params::set_type (int type) +{ + ACE_TRACE ("ACE_ATM_Params::set_type"); + type_ = type; +} + +ACE_INLINE +ACE_Protocol_Info* +ACE_ATM_Params::get_protocol_info( void ) +{ + ACE_TRACE ("ACE_ATM_Params::get_protocol_info"); + return protocol_info_; +} + +ACE_INLINE +void +ACE_ATM_Params::set_protocol_info( ACE_Protocol_Info *protocol_info ) +{ + ACE_TRACE ("ACE_ATM_Params::set_protocol_info"); + protocol_info_ = protocol_info; +} + +ACE_INLINE +ACE_SOCK_GROUP +ACE_ATM_Params::get_sock_group( void ) +{ + ACE_TRACE ("ACE_ATM_Params::get_sock_group"); + return group_; +} + +ACE_INLINE +void +ACE_ATM_Params::set_sock_group( ACE_SOCK_GROUP g ) +{ + ACE_TRACE ("ACE_ATM_Params::set_sock_group"); + group_ = g; +} + +ACE_INLINE +u_long +ACE_ATM_Params::get_flags( void ) +{ + ACE_TRACE ("ACE_ATM_Params::get_flags"); + return flags_; +} + +ACE_INLINE +void +ACE_ATM_Params::set_flags( u_long flags) +{ + ACE_TRACE ("ACE_ATM_Params::set_flags"); + flags_ = flags; +} + +ACE_INLINE +int +ACE_ATM_Params::get_reuse_addr (void) const +{ + ACE_TRACE ("ACE_ATM_Params::get_reuse_addr"); + return reuse_addr_; +} + +ACE_INLINE +void +ACE_ATM_Params::set_reuse_addr (int reuse_addr) +{ + ACE_TRACE ("ACE_ATM_Params::set_reuse_addr"); + reuse_addr_ = reuse_addr; +} + +ACE_INLINE +const char* +ACE_ATM_Params::get_device (void) const +{ + ACE_TRACE ("ACE_ATM_Params::get_device"); + return device_; +} + +ACE_INLINE +Param_Info* +ACE_ATM_Params::get_info (void) const +{ + ACE_TRACE ("ACE_ATM_Params::get_info"); + return info_; +} + +ACE_INLINE +void +ACE_ATM_Params::set_info (Param_Info* info) +{ + ACE_TRACE ("ACE_ATM_Params::set_info"); + info_ = info; +} + +ACE_INLINE +int +ACE_ATM_Params::get_rw_flag (void) const +{ + ACE_TRACE ("ACE_ATM_Params::get_rw_flag"); + return rw_flag_; +} + +ACE_INLINE +void +ACE_ATM_Params::set_rw_flag (int rw_flag) +{ + ACE_TRACE ("ACE_ATM_Params::set_rw_flag"); + rw_flag_ = rw_flag; +} + +ACE_INLINE +Param_Udata* +ACE_ATM_Params::get_user_data (void) const +{ + ACE_TRACE ("ACE_ATM_Params::get_user_data"); + return udata_; +} + +ACE_INLINE +void +ACE_ATM_Params::set_user_data (Param_Udata *udata) +{ + ACE_TRACE ("ACE_ATM_Params::set_user_data"); + udata_ = udata; +} + +ACE_INLINE +int +ACE_ATM_Params::get_oflag (void) const +{ + ACE_TRACE ("ACE_ATM_Params::get_oflag"); + return oflag_; +} + +ACE_INLINE +void +ACE_ATM_Params::set_oflag (int oflag) +{ + ACE_TRACE ("ACE_ATM_Params::set_oflag"); + oflag_ = oflag; +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/ATM_QoS.cpp b/dep/ACE_wrappers/ace/ATM_QoS.cpp new file mode 100644 index 00000000000..d5405d042a6 --- /dev/null +++ b/dep/ACE_wrappers/ace/ATM_QoS.cpp @@ -0,0 +1,631 @@ +// $Id: ATM_QoS.cpp 80826 2008-03-04 14:51:23Z wotte $ + +#include "ace/ATM_QoS.h" + +ACE_RCSID(ace, ATM_QoS, "$Id: ATM_QoS.cpp 80826 2008-03-04 14:51:23Z wotte $") + +#if defined (ACE_HAS_ATM) + +#if !defined (__ACE_INLINE__) +#include "ace/ATM_QoS.inl" +#endif /* __ACE_INLINE__ */ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +#if defined (ACE_HAS_FORE_ATM_XTI) || defined (ACE_HAS_FORE_ATM_WS2) +#define BHLI_MAGIC "FORE_ATM" +// This is line rate in cells/s for an OC-3 MM interface. +const long ACE_ATM_QoS::LINE_RATE = 353207; +const int ACE_ATM_QoS::OPT_FLAGS_CPID = 0x1; +const int ACE_ATM_QoS::OPT_FLAGS_PMP = 0x2; +const int ACE_ATM_QoS::DEFAULT_SELECTOR = 0x99; +const int ACE_ATM_QoS::DEFAULT_PKT_SIZE = 8192; +#elif defined (ACE_HAS_LINUX_ATM) +//pbrandao:for Linux: +//pbrandao:for now stick with current definitions +//pbrandao:see if later need to change +const long ACE_ATM_QoS::LINE_RATE = 353207; +const int ACE_ATM_QoS::OPT_FLAGS_CPID = 0x1; +const int ACE_ATM_QoS::OPT_FLAGS_PMP = 0x2; +const int ACE_ATM_QoS::DEFAULT_SELECTOR = 0x99; +const int ACE_ATM_QoS::DEFAULT_PKT_SIZE = 8192; +#else +const long ACE_ATM_QoS::LINE_RATE = 0L; +const int ACE_ATM_QoS::OPT_FLAGS_CPID = 0; +const int ACE_ATM_QoS::OPT_FLAGS_PMP = 0; +const int ACE_ATM_QoS::DEFAULT_SELECTOR = 0x0; +const int ACE_ATM_QoS::DEFAULT_PKT_SIZE = 0; +#endif /* ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_ATM_WS2 || ACE_HAS_LINUX_ATM */ + +ACE_ALLOC_HOOK_DEFINE(ACE_ATM_QoS) + +ACE_ATM_QoS::ACE_ATM_QoS (int pktSize) +{ + ACE_TRACE ("ACE_ATM_QoS::ACE_ATM_QoS"); +#if defined (ACE_HAS_LINUX_ATM) + ACE_OS::memset(&qos_, 0, sizeof(qos_)); + qos_.aal = ATM_PROTOCOL_DEFAULT; + qos_.rxtp.traffic_class = ATM_ANYCLASS; + qos_.rxtp.max_sdu = pktSize; + qos_.txtp.traffic_class = ATM_ANYCLASS; + qos_.txtp.max_sdu = pktSize; +#else + ACE_UNUSED_ARG (pktSize); +#endif /* ACE_HAS_LINUX_ATM */ +} + +ACE_ATM_QoS::ACE_ATM_QoS(int rate, + int pktSize) +{ + ACE_TRACE( "ACE_ATM_QoS::ACE_ATM_QoS" ); +#if defined (ACE_HAS_FORE_ATM_WS2) + AAL_PARAMETERS_IE ie_aalparams; + ATM_TRAFFIC_DESCRIPTOR_IE ie_td; + ATM_BROADBAND_BEARER_CAPABILITY_IE ie_bbc; + ATM_QOS_CLASS_IE ie_qos; + Q2931_IE *ie_ptr; + int size; + + // Setting up cbr parameters ... + ie_aalparams.AALType = AALTYPE_5; + ie_aalparams.AALSpecificParameters.AAL5Parameters.ForwardMaxCPCSSDUSize + = pktSize; // was 1516; + ie_aalparams.AALSpecificParameters.AAL5Parameters.BackwardMaxCPCSSDUSize + = pktSize; // was 1516; + ie_aalparams.AALSpecificParameters.AAL5Parameters.Mode = AAL5_MODE_MESSAGE; + ie_aalparams.AALSpecificParameters.AAL5Parameters.SSCSType = AAL5_SSCS_NULL; + + size = sizeof(Q2931_IE_TYPE) + sizeof(ULONG) + sizeof(AAL_PARAMETERS_IE); + + ie_td.Forward.PeakCellRate_CLP0 = SAP_FIELD_ABSENT; + ie_td.Forward.PeakCellRate_CLP01 = rate; + ie_td.Forward.SustainableCellRate_CLP0 = SAP_FIELD_ABSENT; + ie_td.Forward.SustainableCellRate_CLP01 = SAP_FIELD_ABSENT; + ie_td.Forward.MaxBurstSize_CLP0 = SAP_FIELD_ABSENT; + ie_td.Forward.MaxBurstSize_CLP01 = SAP_FIELD_ABSENT; + ie_td.Forward.Tagging = SAP_FIELD_ABSENT; + + ie_td.Backward.PeakCellRate_CLP0 = SAP_FIELD_ABSENT; + ie_td.Backward.PeakCellRate_CLP01 = rate; + ie_td.Backward.SustainableCellRate_CLP0 = SAP_FIELD_ABSENT; + ie_td.Backward.SustainableCellRate_CLP01 = SAP_FIELD_ABSENT; + ie_td.Backward.MaxBurstSize_CLP0 = SAP_FIELD_ABSENT; + ie_td.Backward.MaxBurstSize_CLP01 = SAP_FIELD_ABSENT; + ie_td.Backward.Tagging = SAP_FIELD_ABSENT; + + ie_td.BestEffort = 0; // Note: this must be set to zero for CBR. + + size += sizeof( Q2931_IE_TYPE ) + + sizeof( ULONG ) + + sizeof( ATM_TRAFFIC_DESCRIPTOR_IE ); + + ie_bbc.BearerClass = BCOB_X; + ie_bbc.TrafficType = TT_CBR; + ie_bbc.TimingRequirements = TR_END_TO_END; + ie_bbc.ClippingSusceptability = CLIP_NOT; + ie_bbc.UserPlaneConnectionConfig = UP_P2P; + + size += sizeof( Q2931_IE_TYPE ) + + sizeof( ULONG ) + + sizeof( ATM_BROADBAND_BEARER_CAPABILITY_IE ); + + ie_qos.QOSClassForward = QOS_CLASS1; + ie_qos.QOSClassBackward = QOS_CLASS1; // This may not be really used + // since we do only simplex data xfer. + + size += sizeof(Q2931_IE_TYPE) + sizeof(ULONG) + sizeof(ATM_QOS_CLASS_IE); + + qos_.ProviderSpecific.buf = (char *) ACE_OS::malloc(size); + if (qos_.ProviderSpecific.buf == 0) { + ACE_ERROR((LM_ERROR, + ACE_TEXT ("ACE_ATM_QoS::ACE_ATM_QoS: Unable to allocate %d bytes for qos_.ProviderSpecific.buf\n"), + size)); + return; + } + qos_.ProviderSpecific.len = size; + ACE_OS::memset(qos_.ProviderSpecific.buf, 0, size); + + ie_ptr = (Q2931_IE *) qos_.ProviderSpecific.buf; + ie_ptr->IEType = IE_AALParameters; + ie_ptr->IELength = sizeof( Q2931_IE_TYPE ) + + sizeof( ULONG ) + + sizeof( AAL_PARAMETERS_IE ); + ACE_OS::memcpy(ie_ptr->IE, &ie_aalparams, sizeof(AAL_PARAMETERS_IE)); + + ie_ptr = (Q2931_IE *) ((char *)ie_ptr + ie_ptr->IELength); + ie_ptr->IEType = IE_TrafficDescriptor; + ie_ptr->IELength = sizeof( Q2931_IE_TYPE ) + + sizeof( ULONG ) + + sizeof( ATM_TRAFFIC_DESCRIPTOR_IE ); + ACE_OS::memcpy(ie_ptr->IE, &ie_td, sizeof(ATM_TRAFFIC_DESCRIPTOR_IE)); + + ie_ptr = (Q2931_IE *) ((char *)ie_ptr + ie_ptr->IELength); + ie_ptr->IEType = IE_BroadbandBearerCapability; + ie_ptr->IELength = sizeof( Q2931_IE_TYPE ) + + sizeof( ULONG ) + + sizeof( ATM_BROADBAND_BEARER_CAPABILITY_IE ); + ACE_OS::memcpy(ie_ptr->IE, + &ie_bbc, + sizeof(ATM_BROADBAND_BEARER_CAPABILITY_IE)); + + ie_ptr = (Q2931_IE *) ((char *)ie_ptr + ie_ptr->IELength); + ie_ptr->IEType = IE_QOSClass; + ie_ptr->IELength = sizeof( Q2931_IE_TYPE ) + + sizeof( ULONG ) + + sizeof( ATM_QOS_CLASS_IE ); + ACE_OS::memcpy(ie_ptr->IE, &ie_qos, sizeof(ATM_QOS_CLASS_IE)); + + // qos_.SendingFlowspec.TokenRate = 0xffffffff; + // qos_.SendingFlowspec.TokenBucketSize = 0xffffffff; + // qos_.SendingFlowspec.PeakBandwidth = 0xffffffff; + // qos_.SendingFlowspec.Latency = 0xffffffff; + // qos_.SendingFlowspec.DelayVariation = 0xffffffff; + // qos_.SendingFlowspec.ServiceType = SERVICETYPE_BESTEFFORT; + // This will most probably be ignored by the service provider. + // qos_.SendingFlowspec.MaxSduSize = 0xffffffff; + // qos_.SendingFlowspec.MinimumPolicedSize = 0xffffffff; + + // qos_.ReceivingFlowspec.TokenRate = 0xffffffff; + // qos_.ReceivingFlowspec.TokenBucketSize = 0xffffffff; + // qos_.ReceivingFlowspec.PeakBandwidth = 0xffffffff; + // qos_.ReceivingFlowspec.Latency = 0xffffffff; + // qos_.ReceivingFlowspec.DelayVariation = 0xffffffff; + // qos_.ReceivingFlowspec.ServiceType = SERVICETYPE_BESTEFFORT; + // This will most probably be ignored by the service provider. + // qos_.ReceivingFlowspec.MaxSduSize = 0xffffffff; + // qos_.ReceivingFlowspec.MinimumPolicedSize = 0; + + ACE_Flow_Spec send_fspec( 0xffffffff, + 0xffffffff, + 0xffffffff, + 0xffffffff, + 0xffffffff, + SERVICETYPE_BESTEFFORT, + // This will most probably ignored by SP. + 0xffffffff, + 0xffffffff, + 15, + ACE_DEFAULT_THREAD_PRIORITY ), + recv_fspec( 0xffffffff, + 0xffffffff, + 0xffffffff, + 0xffffffff, + 0xffffffff, + SERVICETYPE_BESTEFFORT, + // This will most probably ignored by SP. + 0xffffffff, + 0, + 15, + ACE_DEFAULT_THREAD_PRIORITY ); + + qos_.sending_flowspec (send_fspec); + qos_.receiving_flowspec (recv_fspec); +#elif defined (ACE_HAS_FORE_ATM_XTI) + ACE_UNUSED_ARG (rate); + ACE_UNUSED_ARG (pktSize); +#elif defined (ACE_HAS_LINUX_ATM) + ACE_OS::memset(&qos_, + 0, + sizeof(qos_)); + qos_.aal = ATM_PROTOCOL_DEFAULT; + qos_.rxtp.max_sdu = pktSize; + + if (rate > 0) { + qos_.rxtp.pcr = rate; + qos_.rxtp.traffic_class = ATM_CBR; + qos_.txtp.traffic_class = ATM_CBR; + qos_.txtp.pcr = rate; + } + else { + qos_.rxtp.traffic_class = ATM_UBR; + qos_.txtp.traffic_class = ATM_UBR; + } + + qos_.txtp.max_sdu = pktSize; +#else + ACE_UNUSED_ARG (rate); +#endif /* ACE_HAS_FORE_ATM_WS2 || ACE_HAS_FORE_ATM_XTI || ACE_HAS_LINUX_ATM */ +} + +void +ACE_ATM_QoS::set_cbr_rate (int rate, + int pktSize) +{ + ACE_TRACE ("ACE_ATM_QoS::set_cbr_rate"); +#if defined (ACE_HAS_FORE_ATM_WS2) + /* + AAL_PARAMETERS_IE ie_aalparams; + ATM_TRAFFIC_DESCRIPTOR_IE ie_td; + ATM_BROADBAND_BEARER_CAPABILITY_IE ie_bbc; + ATM_QOS_CLASS_IE ie_qos; + Q2931_IE *ie_ptr; + int size; + */ + + ACE_OS::printf( "ATM_QoS(set_cbr_rate): set rate to %d c/s\n", rate ); + + // Setting up cbr parameters ... + /* + FORE has changed this - we no longer specify QoS this way + ie_aalparams.AALType = AALTYPE_5; + ie_aalparams.AALSpecificParameters.AAL5Parameters.ForwardMaxCPCSSDUSize + = pktSize; // was 1516; + ie_aalparams.AALSpecificParameters.AAL5Parameters.BackwardMaxCPCSSDUSize + = pktSize; // was 1516; + ie_aalparams.AALSpecificParameters.AAL5Parameters.Mode = AAL5_MODE_MESSAGE; + ie_aalparams.AALSpecificParameters.AAL5Parameters.SSCSType = AAL5_SSCS_NULL; + + size = sizeof(Q2931_IE_TYPE) + sizeof(ULONG) + sizeof(AAL_PARAMETERS_IE); + + ie_td.Forward.PeakCellRate_CLP0 = SAP_FIELD_ABSENT; + ie_td.Forward.PeakCellRate_CLP01 = rate; + ie_td.Forward.SustainableCellRate_CLP0 = SAP_FIELD_ABSENT; + ie_td.Forward.SustainableCellRate_CLP01 = SAP_FIELD_ABSENT; + ie_td.Forward.MaxBurstSize_CLP0 = SAP_FIELD_ABSENT; + ie_td.Forward.MaxBurstSize_CLP01 = SAP_FIELD_ABSENT; + ie_td.Forward.Tagging = SAP_FIELD_ABSENT; + + ie_td.Backward.PeakCellRate_CLP0 = SAP_FIELD_ABSENT; + ie_td.Backward.PeakCellRate_CLP01 = rate; + ie_td.Backward.SustainableCellRate_CLP0 = SAP_FIELD_ABSENT; + ie_td.Backward.SustainableCellRate_CLP01 = SAP_FIELD_ABSENT; + ie_td.Backward.MaxBurstSize_CLP0 = SAP_FIELD_ABSENT; + ie_td.Backward.MaxBurstSize_CLP01 = SAP_FIELD_ABSENT; + ie_td.Backward.Tagging = SAP_FIELD_ABSENT; + + ie_td.BestEffort = 0; // Note: this must be set to zero for CBR. + + size += sizeof( Q2931_IE_TYPE ) + + sizeof( ULONG ) + + sizeof( ATM_TRAFFIC_DESCRIPTOR_IE ); + + ie_bbc.BearerClass = BCOB_X; + ie_bbc.TrafficType = TT_CBR; + ie_bbc.TimingRequirements = TR_END_TO_END; + ie_bbc.ClippingSusceptability = CLIP_NOT; + ie_bbc.UserPlaneConnectionConfig = UP_P2P; + + size += sizeof(Q2931_IE_TYPE) + + sizeof(ULONG) + + sizeof(ATM_BROADBAND_BEARER_CAPABILITY_IE); + + ie_qos.QOSClassForward = QOS_CLASS1; + ie_qos.QOSClassBackward = QOS_CLASS1; // This may not be really used + // since we only simplex data xfer. + + size += sizeof(Q2931_IE_TYPE) + sizeof(ULONG) + sizeof(ATM_QOS_CLASS_IE); + + qos_.ProviderSpecific.buf = (char *) ACE_OS::malloc(size); + if (qos_.ProviderSpecific.buf == 0) { + ACE_ERROR((LM_ERROR, + ACE_TEXT ("ACE_ATM_QoS::ACE_ATM_QoS: Unable to allocate %d bytes for qos_.ProviderSpecific.buf\n"), + size)); + return; + } + qos_.ProviderSpecific.len = size; + ACE_OS::memset(qos_.ProviderSpecific.buf, 0, size); + + ie_ptr = (Q2931_IE *) qos_.ProviderSpecific.buf; + ie_ptr->IEType = IE_AALParameters; + ie_ptr->IELength = sizeof( Q2931_IE_TYPE ) + + sizeof( ULONG ) + + sizeof( AAL_PARAMETERS_IE ); + ACE_OS::memcpy(ie_ptr->IE, &ie_aalparams, sizeof(AAL_PARAMETERS_IE)); + + ie_ptr = (Q2931_IE *) ((char *)ie_ptr + ie_ptr->IELength); + ie_ptr->IEType = IE_TrafficDescriptor; + ie_ptr->IELength = sizeof( Q2931_IE_TYPE ) + + sizeof( ULONG ) + + sizeof( ATM_TRAFFIC_DESCRIPTOR_IE ); + ACE_OS::memcpy(ie_ptr->IE, &ie_td, sizeof(ATM_TRAFFIC_DESCRIPTOR_IE)); + + ie_ptr = (Q2931_IE *) ((char *)ie_ptr + ie_ptr->IELength); + ie_ptr->IEType = IE_BroadbandBearerCapability; + ie_ptr->IELength = sizeof( Q2931_IE_TYPE ) + + sizeof( ULONG ) + + sizeof( ATM_BROADBAND_BEARER_CAPABILITY_IE ); + ACE_OS::memcpy( ie_ptr->IE, + &ie_bbc, + sizeof( ATM_BROADBAND_BEARER_CAPABILITY_IE )); + + ie_ptr = (Q2931_IE *) ((char *)ie_ptr + ie_ptr->IELength); + ie_ptr->IEType = IE_QOSClass; + ie_ptr->IELength = sizeof(Q2931_IE_TYPE) + sizeof(ULONG) + + sizeof(ATM_QOS_CLASS_IE); + ACE_OS::memcpy(ie_ptr->IE, &ie_qos, sizeof(ATM_QOS_CLASS_IE)); + */ + + const int BYTES_PER_ATM_CELL = 53; + ACE_OS::memset(&qos_, 0, sizeof(ATM_QoS)); + // Setting the token rate sets the minimum rate. 3 Mbits/sec seems too high. + // Certainly for Vaudeville audio, we only need about 1000 c/s which is + // 424000 bits/sec which is 53000 bytes/sec. + //qos_.SendingFlowspec.TokenRate = 3*(1024*128); // 3Mbits/sec + qos_.SendingFlowspec.TokenRate = 53000; // 1000 cells/sec + qos_.SendingFlowspec.TokenBucketSize = 32*1024; // our block size + //ourQos.SendingFlowspec.PeakBandwidth = ourQos.SendingFlowspec.TokenRate; + qos_.SendingFlowspec.ServiceType = SERVICETYPE_GUARANTEED; + // Peak bandwidth is in bytes/sec. The rate is specified in cells/sec so + // we need to convert from cells/sec to bytes/sec (i.e., multiply by 53). + qos_.SendingFlowspec.PeakBandwidth = rate * BYTES_PER_ATM_CELL; + qos_.SendingFlowspec.Latency = -1; // we don't care too much + qos_.SendingFlowspec.DelayVariation = -1; // we don't care too much + // no provider-specific data allowed on ATM + qos_.ProviderSpecific.buf=0; + qos_.ProviderSpecific.len=0; + // unidirectional P2MP; we don't need to setup the Receiving flowspec + + //qos_.SendingFlowspec.TokenRate = 0xffffffff; + //qos_.SendingFlowspec.TokenBucketSize = 0xffffffff; + //qos_.SendingFlowspec.PeakBandwidth = 0xffffffff; + //qos_.SendingFlowspec.Latency = 0xffffffff; + //qos_.SendingFlowspec.DelayVariation = 0xffffffff; + //qos_.SendingFlowspec.ServiceType = SERVICETYPE_BESTEFFORT; + // This will most probably be ignored by the service provider. + //qos_.SendingFlowspec.MaxSduSize = 0xffffffff; + //qos_.SendingFlowspec.MinimumPolicedSize = 0xffffffff; + + //qos_.ReceivingFlowspec.TokenRate = 0xffffffff; + //qos_.ReceivingFlowspec.TokenBucketSize = 0xffffffff; + //qos_.ReceivingFlowspec.PeakBandwidth = 0xffffffff; + //qos_.ReceivingFlowspec.Latency = 0xffffffff; + //qos_.ReceivingFlowspec.DelayVariation = 0xffffffff; + //qos_.ReceivingFlowspec.ServiceType = SERVICETYPE_BESTEFFORT; + // This will most probably be ignored by the service provider. + //qos_.ReceivingFlowspec.MaxSduSize = 0xffffffff; + //qos_.ReceivingFlowspec.MinimumPolicedSize = 0; + + /* + ACE_Flow_Spec send_fspec( 0xffffffff, + 0xffffffff, + 0xffffffff, + 0xffffffff, + 0xffffffff, + SERVICETYPE_BESTEFFORT, + // This will most probably ignored by SP. + 0xffffffff, + 0xffffffff, + 15, + ACE_DEFAULT_THREAD_PRIORITY ), + recv_fspec( 0xffffffff, + 0xffffffff, + 0xffffffff, + 0xffffffff, + 0xffffffff, + SERVICETYPE_BESTEFFORT, + // This will most probably ignored by SP. + 0xffffffff, + 0, + 15, + ACE_DEFAULT_THREAD_PRIORITY ); + + qos_.sending_flowspec( send_fspec ); + qos_.receiving_flowspec( recv_fspec ); + */ +#elif defined (ACE_HAS_FORE_ATM_XTI) + ACE_UNUSED_ARG (rate); + ACE_UNUSED_ARG (pktSize); +#elif defined (ACE_HAS_LINUX_ATM) + ACE_UNUSED_ARG (pktSize); + + qos_.rxtp.traffic_class = ATM_CBR; + qos_.rxtp.pcr = rate; + qos_.txtp.traffic_class = ATM_CBR; + qos_.txtp.pcr = rate; +#else + ACE_UNUSED_ARG (rate); +#endif /* ACE_HAS_FORE_ATM_WS2 || ACE_HAS_FORE_ATM_XTI || ACE_HAS_LINUX_ATM */ +} + +void +ACE_ATM_QoS::set_rate (ACE_HANDLE fd, + int rate, + int flags) +{ + ACE_TRACE ("ACE_ATM_QoS::set_rate"); +#if defined (ACE_HAS_FORE_ATM_WS2) || defined (ACE_HAS_LINUX_ATM) + set_cbr_rate( rate ); + + ACE_UNUSED_ARG( fd ); + ACE_UNUSED_ARG( flags ); +#elif defined (ACE_HAS_FORE_ATM_XTI) + long optlen = 0; + qos_.buf = construct_options(fd, + rate, + flags, + &optlen); + qos_.len = optlen; +#else + ACE_UNUSED_ARG (rate); +#endif /* ACE_HAS_FORE_ATM_WS2 || ACE_HAS_LINUX_ATM || ACE_HAS_FORE_ATM_XTI */ +} + +char* +ACE_ATM_QoS::construct_options (ACE_HANDLE fd, + int rate, + int flags, + long *len) +{ +#if defined (ACE_HAS_FORE_ATM_WS2) || defined (ACE_HAS_LINUX_ATM) + ACE_UNUSED_ARG (fd); + ACE_UNUSED_ARG (rate); + ACE_UNUSED_ARG (flags); + ACE_UNUSED_ARG (len); + return (0); +#elif defined (ACE_HAS_FORE_ATM_XTI) + struct t_opthdr *popt; + char *buf; + int qos_cells; + struct t_info info; + + if (ACE_OS::t_getinfo (fd, &info) == -1) + { + ACE_OS::t_error ("t_getinfo"); + return 0; + } + + buf = (char *) ACE_OS::malloc (info.options); + + if (buf == 0) + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("Unable to allocate %d bytes for options\n"), + info.options), + 0); + + popt = (struct t_opthdr *) buf; + + if (flags & OPT_FLAGS_CPID) + { + // This constructs the T_ATM_ORIG_ADDR option, which is used to + // signal the UNI 3.1 Calling Party ID Information Element. + t_atm_addr *source_addr; + + popt->len = sizeof (struct t_opthdr) + sizeof (t_atm_addr); + popt->level = T_ATM_SIGNALING; + popt->name = T_ATM_ORIG_ADDR; + popt->status = 0; + + source_addr = + (t_atm_addr *)((char *) popt + sizeof (struct t_opthdr)); + + source_addr->address_format = T_ATM_ENDSYS_ADDR; + source_addr->address_length = ATMNSAP_ADDR_LEN; + + ATMSAPAddress local_addr; + struct t_bind boundaddr; + + boundaddr.addr.maxlen = sizeof(local_addr); + boundaddr.addr.buf = (char *) &local_addr; + + //if (ACE_OS::t_getprotaddr(fd, &boundaddr, 0) < 0) { + if (ACE_OS::t_getname(fd, + &boundaddr.addr, + LOCALNAME) < 0) + { + ACE_OS::t_error("t_getname (local_address)"); + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("Can't get local address!\n"))); + ACE_OS::free (buf); + return 0; + } + + ACE_OS::memcpy(source_addr->address, + local_addr.sap.t_atm_sap_addr.address, + ATMNSAP_ADDR_LEN); + + popt = T_OPT_NEXTHDR (buf, info.options , popt); + } + + // This constructs all options necessary (bearer cap., QoS, and + // Traffic Descriptor) to signal for a CBR connection with the + // specified QoS in kbit/sec., and/or specify a PMP connection. + + // For FORE 200e cards, the adapter shapes traffic to CBR with rate + // equal to PCR CLP=0+1 (traffic.forward.PCR_all_traffic) + + qos_cells = (rate * 1000) / (48*8); + + if ((qos_cells > 0 && qos_cells < LINE_RATE) + || (ACE_BIT_ENABLED (flags, OPT_FLAGS_PMP))) + { + struct t_atm_bearer *bearer; + struct t_atm_traffic *traffic; + + // T_ATM_BEARER_CAP: Broadband bearer capability + popt->len = sizeof (struct t_opthdr) + sizeof (struct t_atm_bearer); + popt->level = T_ATM_SIGNALING; + popt->name = T_ATM_BEARER_CAP; + popt->status = 0; + + bearer = (struct t_atm_bearer *)((char *) popt + + sizeof (struct t_opthdr)); + bearer->bearer_class = T_ATM_CLASS_X; + + if (qos_cells) + { + bearer->traffic_type = T_ATM_CBR; + bearer->timing_requirements = T_ATM_END_TO_END; + } + else + { + bearer->traffic_type = 0; // UBR + bearer->timing_requirements = 0; + } + bearer->clipping_susceptibility = T_ATM_NULL; + + if (ACE_BIT_ENABLED (flags, OPT_FLAGS_PMP)) + bearer->connection_configuration = T_ATM_1_TO_MANY; + else + bearer->connection_configuration = T_ATM_1_TO_1; + + popt = T_OPT_NEXTHDR (buf, info.options, popt); + + // T_ATM_TRAFFIC: traffic descriptor + popt->len = sizeof (struct t_opthdr) + sizeof (struct t_atm_traffic); + popt->level = T_ATM_SIGNALING; + popt->name = T_ATM_TRAFFIC; + popt->status = 0; + + traffic = (struct t_atm_traffic *)((char *) popt + + sizeof (struct t_opthdr)); + + traffic->forward.PCR_high_priority = T_ATM_ABSENT; + traffic->forward.PCR_all_traffic = qos_cells ? qos_cells : LINE_RATE; + traffic->forward.SCR_high_priority = T_ATM_ABSENT; + traffic->forward.SCR_all_traffic = T_ATM_ABSENT; + traffic->forward.MBS_high_priority = T_ATM_ABSENT; + traffic->forward.MBS_all_traffic = T_ATM_ABSENT; + traffic->forward.tagging = T_NO; + + traffic->backward.PCR_high_priority = T_ATM_ABSENT; + traffic->backward.PCR_all_traffic = + (ACE_BIT_ENABLED (flags, OPT_FLAGS_PMP)) + ? 0 : qos_cells ? qos_cells : LINE_RATE; + traffic->backward.SCR_high_priority = T_ATM_ABSENT; + traffic->backward.SCR_all_traffic = T_ATM_ABSENT; + traffic->backward.MBS_high_priority = T_ATM_ABSENT; + traffic->backward.MBS_all_traffic = T_ATM_ABSENT; + traffic->backward.tagging = T_NO; + + traffic->best_effort = qos_cells ? T_NO : T_YES; + + popt = T_OPT_NEXTHDR (buf, + info.options, + popt); + } + + if (qos_cells > 0 && qos_cells < LINE_RATE) + { + struct t_atm_qos *qos; + + // T_ATM_QOS: Quality of Service + popt->len = sizeof (struct t_opthdr) + sizeof (struct t_atm_qos); + popt->level = T_ATM_SIGNALING; + popt->name = T_ATM_QOS; + popt->status = 0; + + qos = (struct t_atm_qos *)((char *) popt + sizeof (struct t_opthdr)); + qos->coding_standard = T_ATM_ITU_CODING; + qos->forward.qos_class = T_ATM_QOS_CLASS_1; + qos->backward.qos_class = T_ATM_QOS_CLASS_1; + + popt = T_OPT_NEXTHDR (buf, info.options, popt); + } + + // Return actual size of options and option buffer to user. + *len = (char *) popt - buf; + + return buf; +#else + ACE_UNUSED_ARG (fd); + ACE_UNUSED_ARG (rate); + ACE_UNUSED_ARG (flag); + ACE_UNUSED_ARG (len); + return (0); +#endif /* ACE_HAS_FORE_ATM_WS2 */ +} + +ACE_END_VERSIONED_NAMESPACE_DECL + +#endif /* ACE_HAS_ATM */ + diff --git a/dep/ACE_wrappers/ace/ATM_QoS.h b/dep/ACE_wrappers/ace/ATM_QoS.h new file mode 100644 index 00000000000..4e35f3fddb4 --- /dev/null +++ b/dep/ACE_wrappers/ace/ATM_QoS.h @@ -0,0 +1,115 @@ +// -*- C++ -*- + +//========================================================================== +/** + * @file ATM_QoS.h + * + * $Id: ATM_QoS.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Joe Hoffert + */ +//========================================================================== + + +#ifndef ACE_ATM_QoS_H +#define ACE_ATM_QoS_H +#include /**/ "ace/pre.h" + +#include /**/ "ace/config-all.h" + +#if !defined(ACE_LACKS_PRAGMA_ONCE) +#pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#if defined (ACE_HAS_ATM) + +#if defined (ACE_HAS_FORE_ATM_WS2) +ACE_BEGIN_VERSIONED_NAMESPACE_DECL +// just map to WS2 GQOS struct +typedef ACE_QoS ATM_QoS; +ACE_END_VERSIONED_NAMESPACE_DECL +#elif defined (ACE_HAS_FORE_ATM_XTI) +ACE_BEGIN_VERSIONED_NAMESPACE_DECL +typedef struct netbuf ATM_QoS; +ACE_END_VERSIONED_NAMESPACE_DECL +#elif defined (ACE_HAS_LINUX_ATM) +#include /**/ "atm.h" +#include "ace/ATM_Params.h" +ACE_BEGIN_VERSIONED_NAMESPACE_DECL +typedef struct atm_qos ATM_QoS; +ACE_END_VERSIONED_NAMESPACE_DECL +#else +ACE_BEGIN_VERSIONED_NAMESPACE_DECL +typedef int ATM_QoS; +ACE_END_VERSIONED_NAMESPACE_DECL +#endif /* ACE_HAS_FORE_ATM_WS2 || ACE_HAS_FORE_ATM_XTI || ACE_HAS_LINUX_ATM */ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +/** + * @class ACE_ATM_QoS + * + * @brief Define the QoS parameters for ATM + * + * This class wraps up QoS parameters for both ATM/XTI and + * ATM/WinSock2 to make the mechanism for the ATM protocol + * transparent. + */ +class ACE_Export ACE_ATM_QoS +{ +public: + // Constants used for ATM options + static const long LINE_RATE; + static const int OPT_FLAGS_CPID; + static const int OPT_FLAGS_PMP; + static const int DEFAULT_SELECTOR; + static const int DEFAULT_PKT_SIZE; + + // = Initializattion and termination methods. + /// Default constructor. + ACE_ATM_QoS(int = DEFAULT_PKT_SIZE); + + /// Constructor with a CBR rate. + ACE_ATM_QoS(int, + int = DEFAULT_PKT_SIZE); + + ~ACE_ATM_QoS (); + + /// Set the rate. + void set_rate (ACE_HANDLE, + int, + int); + + /// Set CBR rate in cells per second. + void set_cbr_rate (int, + int = DEFAULT_PKT_SIZE); + + /// Get ATM_QoS struct. + ATM_QoS get_qos (void); + + /// Dump the state of an object. + void dump (void) const; + + /// Declare the dynamic allocation hooks. + ACE_ALLOC_HOOK_DECLARE; + +protected: + /// Construct QoS options. + char* construct_options(ACE_HANDLE, + int, + int, + long*); + +private: + ATM_QoS qos_; +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +#include "ace/ATM_QoS.inl" +#endif /* __ACE_INLINE__ */ + +#endif /* ACE_HAS_ATM */ +#include /**/ "ace/post.h" +#endif /* ACE_ATM_QoS_H */ diff --git a/dep/ACE_wrappers/ace/ATM_QoS.inl b/dep/ACE_wrappers/ace/ATM_QoS.inl new file mode 100644 index 00000000000..52b5211190d --- /dev/null +++ b/dep/ACE_wrappers/ace/ATM_QoS.inl @@ -0,0 +1,29 @@ +// -*- C++ -*- +// +// $Id: ATM_QoS.inl 80826 2008-03-04 14:51:23Z wotte $ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_INLINE void +ACE_ATM_QoS::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + ACE_TRACE ("ACE_ATM_QoS::dump"); +#endif /* ACE_HAS_DUMP */ +} + +ACE_INLINE +ACE_ATM_QoS::~ACE_ATM_QoS () +{ + ACE_TRACE ("ACE_ATM_QoS::~ACE_ATM_QoS"); +} + +ACE_INLINE +ATM_QoS +ACE_ATM_QoS::get_qos (void) +{ + ACE_TRACE ("ACE_ATM_QoS::get_qos"); + return qos_; +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/ATM_Stream.cpp b/dep/ACE_wrappers/ace/ATM_Stream.cpp new file mode 100644 index 00000000000..affb891475a --- /dev/null +++ b/dep/ACE_wrappers/ace/ATM_Stream.cpp @@ -0,0 +1,290 @@ +// $Id: ATM_Stream.cpp 80826 2008-03-04 14:51:23Z wotte $ + +#include "ace/ATM_Stream.h" + +ACE_RCSID (ace, ATM_Stream, "$Id: ATM_Stream.cpp 80826 2008-03-04 14:51:23Z wotte $") + +#if defined (ACE_HAS_ATM) + +#if !defined (__ACE_INLINE__) +#include "ace/ATM_Stream.inl" +#endif /* __ACE_INLINE__ */ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_ALLOC_HOOK_DEFINE (ACE_ATM_Stream) + +char* +ACE_ATM_Stream::get_peer_name (void) const +{ + ACE_TRACE ("ACE_ATM_Stream::get_peer_name"); +#if defined (ACE_HAS_FORE_ATM_XTI) + // // Use t_getprotaddr for XTI/ATM + // struct t_bind *localaddr + // = (struct t_bind *) ACE_OS::t_alloc (get_handle (), + // T_BIND, + // T_ADDR); + // struct t_bind *peeraddr + // = (struct t_bind *) ACE_OS::t_alloc (get_handle (), + // T_BIND, + // T_ADDR); + // ::t_getprotaddr (get_handle (), + // localaddr, + // peeraddr); + + // char* connected_name = (char*) ACE_OS::malloc (peeraddr->addr.len + 1); + // ACE_OS::strcpy (connected_name, + // peeraddr->addr.buf); + // ACE_OS::t_free ((char *) localaddr, + // T_BIND); + // ACE_OS::t_free ((char *) peeraddr, + // T_BIND); + // return (connected_name); + +#error "This doesn't seem to work. May need to jimmy-rig something with the" +#error "/etc/xti_hosts file - Ugh!" + + ACE_ATM_Addr sa; + struct netbuf name; + name.maxlen = sa.get_size (); + name.buf = (char *) sa.get_addr (); + ACE_OS::t_getname (this->get_handle (), &name, REMOTENAME); + // ACE_OS::ioctl (this->get_handle (), + // TI_GETPEERNAME, + // &name); + return (name.buf); + +#elif defined (ACE_HAS_FORE_ATM_WS2) + // Use getpeername for WinSock2. + struct sockaddr_atm name; + ACE_OS::memset (&name, 0, sizeof (name)); + int nameSize = sizeof (name); + + if (ACE_OS::getpeername (this->get_handle (), + (struct sockaddr *) &name, + &nameSize) != 0) { + return 0; + } + + char buffer[256]; + for (unsigned int index = 0; index < ATM_ADDR_SIZE - 1; index++) { + buffer[ index * 3 ] = '\0'; + ACE_OS::sprintf (buffer, "%s%02x.", buffer, name.satm_number.Addr[ index ]); + } + buffer[ (ATM_ADDR_SIZE - 1) * 3 ] = '\0'; + ACE_OS::sprintf (buffer, "%s%02x.", buffer, 0); + buffer[ ATM_ADDR_SIZE * 3 - 1 ] = '\0'; + for (index = 0; index < ACE_OS::strlen (buffer); ++index) + buffer[index] = ACE_OS::ace_tolower (buffer[index]); + + ifstream atm_hosts ("C:/WINNT/atmhosts"); + assert (atm_hosts.is_open ()); + + // Find the host address in the ATM hosts file and return the + // host name + char line[256]; + char *host_ptr, *host_name = 0; + ACE_NEW_RETURN (host_name, char[256], 0); + while (!atm_hosts.eof ()) { + atm_hosts.getline (line, 256); + // Convert the line to lower case to ease comparison + for (index = 0; index < ACE_OS::strlen (line); ++index) + line[index] = ACE_OS::ace_tolower (line[index]); + if (ACE_OS::strstr (line, buffer) != 0) + { + char *strtok_p; + // Grab the second token which is the host name + ACE_OS::strtok_r (line, " \t", &strtok_p); + host_ptr = ACE_OS::strtok (0, " \t", &strtok_p); + ACE_OS::strcpy (host_name, host_ptr); + break; + } + } + + return host_name; +#elif defined (ACE_HAS_LINUX_ATM) + ATM_Addr name; + int nameSize = sizeof (name.sockaddratmsvc); + + if (ACE_OS::getpeername (this->get_handle (), + (struct sockaddr *) & (name.sockaddratmsvc), + &nameSize) < 0) { + ACE_OS::perror ("ACE_ATM_Stream (get_peer_name) : "); + return 0; + } + + static ACE_TCHAR buffer[MAX_ATM_ADDR_LEN + 1]; + int total_len; + if ((total_len = atm2text (buffer,sizeof buffer, + (struct sockaddr *) & (name.sockaddratmsvc), + A2T_PRETTY|A2T_NAME)) < 0) { + ACE_DEBUG ((LM_DEBUG,ACE_TEXT ("ACE_ATM_Stream (get_peer_name) :%d"),errno)); + return 0; + } + + return (char*) buffer; +#else + return 0; +#endif /* ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_ATM_WS2 || ACE_HAS_LINUX_ATM */ +} + +ACE_HANDLE +ACE_ATM_Stream::get_handle (void) const +{ + ACE_TRACE ("ACE_ATM_Stream::get_handle"); +#if defined (ACE_HAS_FORE_ATM_XTI) || defined (ACE_HAS_FORE_ATM_WS2) || defined (ACE_HAS_LINUX_ATM) + return stream_.get_handle (); +#else + return 0; +#endif /* ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_ATM_WS2 || ACE_HAS_LINUX_ATM */ +} + +int +ACE_ATM_Stream::get_vpi_vci (ACE_UINT16 &vpi, + ACE_UINT16 &vci) const +{ + ACE_TRACE ("ACE_ATM_Stream::get_vpi_vci"); +#if defined (ACE_HAS_FORE_ATM_XTI) + struct t_atm_conn_prop conn_prop; + char* connect_opts = (char *) &conn_prop; + int opt_size = sizeof (t_atm_conn_prop); + struct t_info info; + struct t_optmgmt opt_req, opt_ret; + + if (ACE_OS::t_getinfo (stream_.get_handle (), + &info) < 0) + { + ACE_OS::t_error ("t_getinfo"); + return -1; + } + + char *buf_req = (char *) ACE_OS::malloc (info.options); + if (buf_req == 0) + { + ACE_OS::fprintf (stderr, + "Unable to allocate %ld bytes for options\n", + info.options); + return -1; + } + + char *buf_ret = (char *) ACE_OS::malloc (info.options); + if (buf_ret == 0) + { + ACE_OS::fprintf (stderr, + "Unable to allocate %ld bytes for options\n", + info.options); + return -1; + } + + ACE_OS::memset (&opt_req, 0, sizeof (opt_req)); + ACE_OS::memset (&opt_ret, 0, sizeof (opt_ret)); + + struct t_opthdr *popt = (struct t_opthdr *) buf_req; + struct t_opthdr *popt_ret = (struct t_opthdr *) buf_ret; + + popt->len= sizeof (struct t_opthdr) + opt_size; + + // We are only concerned with SVCs so no other check or values are needed + // here. + popt->level = T_ATM_SIGNALING; + popt->name = T_ATM_CONN_PROP; + popt->status = 0; + + opt_req.opt.len = popt->len; + opt_req.opt.buf = (char *) popt; + opt_req.flags = T_CURRENT; + + popt = T_OPT_NEXTHDR (buf_req, + info.options, + popt); + opt_ret.opt.maxlen = info.options; + opt_ret.opt.buf = (char *) popt_ret; + + if (ACE_OS::t_optmgmt (stream_.get_handle (), + &opt_req, + &opt_ret) < 0) { + ACE_OS::t_error ("t_optmgmt"); + return -1; + } + + ACE_OS::memcpy (connect_opts, + (char *) popt_ret + sizeof (struct t_opthdr), + opt_size); + + ACE_OS::free (buf_ret); + ACE_OS::free (buf_req); + + vpi = conn_prop.vpi; + vci = conn_prop.vci; + return (0); +#elif defined (ACE_HAS_FORE_ATM_WS2) + ATM_CONNECTION_ID connID; + DWORD bytes = 0; + + if (::WSAIoctl ((int) this -> get_handle (), + SIO_GET_ATM_CONNECTION_ID, + 0, + 0, + (LPVOID) &connID, + sizeof (ATM_CONNECTION_ID), + &bytes, + 0, + 0) + == SOCKET_ERROR) { + ACE_OS::printf ("Error: WSAIoctl %d\n", WSAGetLastError ()); + } + + vpi = (ACE_UINT16) connID.VPI; + vci = (ACE_UINT16) connID.VCI; + + return 0; +#elif defined (ACE_HAS_LINUX_ATM) +#if defined (SO_ATMPVC) /* atm version>=0.62 */ + struct sockaddr_atmpvc mypvcaddr; + int addrpvclen = sizeof (mypvcaddr); + if (ACE_OS::getsockopt (stream_.get_handle (), + SOL_ATM, + SO_ATMPVC, + reinterpret_cast (&mypvcaddr), + &addrpvclen) < 0) { + ACE_DEBUG (LM_DEBUG, + ACE_TEXT ("ACE_ATM_Stream::get_vpi_vci: getsockopt %d\n"), + errno); + return -1; + } + vpi = (ACE_UINT16) mypvcaddr.sap_addr.vpi; + vci = (ACE_UINT16) mypvcaddr.sap_addr.vci; + + return 0; +#elif defined (SO_VCID) /* patch for atm version 0.59 */ + struct atm_vcid mypvcid; + int pvcidlen = sizeof (mypvcid); + if (ACE_OS::getsockopt (stream_.get_handle (), + SOL_ATM,SO_VCID, + reinterpret_cast (&mypvcid), + &pvcidlen) < 0) { + ACE_DEBUG (LM_DEBUG, + ACE_TEXT ("ACE_ATM_Stream::get_vpi_vci: getsockopt %d\n"), + errno); + return -1; + } + vpi = (ACE_UINT16) mypvcid.vpi; + vci = (ACE_UINT16) mypvcid.vci; + + return 0; +#else + ACE_DEBUG (LM_DEBUG, + ACE_TEXT ("ACE_ATM_Stream::get_vpi_vci: Not implemented in this ATM version. Update to >= 0.62\n Or patch 0.59")); + ACE_UNUSED_ARG (vci); + ACE_UNUSED_ARG (vpi); + + return (-1); +#endif /* SO_ATMPVC || SO_VCID */ +#else + return (-1); +#endif /* ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_ATM_WS2 || ACE_HAS_LINUX_ATM */ +} + +ACE_END_VERSIONED_NAMESPACE_DECL + +#endif /* ACE_HAS_ATM */ diff --git a/dep/ACE_wrappers/ace/ATM_Stream.h b/dep/ACE_wrappers/ace/ATM_Stream.h new file mode 100644 index 00000000000..41ffb0da32e --- /dev/null +++ b/dep/ACE_wrappers/ace/ATM_Stream.h @@ -0,0 +1,107 @@ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file ATM_Stream.h + * + * $Id: ATM_Stream.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Joe Hoffert + */ +//============================================================================= + + +#ifndef ACE_ATM_STREAM_H +#define ACE_ATM_STREAM_H +#include /**/ "ace/pre.h" + +#include /**/ "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#if defined (ACE_HAS_ATM) + +#include "ace/ATM_Addr.h" +#include "ace/ATM_Params.h" + +#if defined (ACE_WIN32) +#include "ace/SOCK_Stream.h" +ACE_BEGIN_VERSIONED_NAMESPACE_DECL +typedef ACE_SOCK_Stream ATM_Stream; +ACE_END_VERSIONED_NAMESPACE_DECL +#else +#include "ace/TLI_Stream.h" +ACE_BEGIN_VERSIONED_NAMESPACE_DECL +typedef ACE_TLI_Stream ATM_Stream; +ACE_END_VERSIONED_NAMESPACE_DECL +#endif + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +/** + * @class ACE_ATM_Stream + * + * @brief Defines the member functions for ACE_ATM_Stream abstraction. + */ +class ACE_Export ACE_ATM_Stream +{ +public: + // = Initialization and termination methods. + /// Default constructor. + ACE_ATM_Stream (void); + + // = ATM-specific open and shutdown operations. + /// open the stream. + int open (ACE_ATM_Params params = ACE_ATM_Params()); + + /// Close down and release resources. + int close (void); + + /// Get the underlying handle. + ACE_HANDLE get_handle (void) const; + + /// Get the underlying stream. + ATM_Stream& get_stream (void); + + /// Get the name of the connected host. + char* get_peer_name (void) const; + + /// Get the VPI and VCI of the stream. + int get_vpi_vci (ACE_UINT16 &vpi, + ACE_UINT16 &vci) const; + + /// Recv an n byte buffer from the connected transport mechanism. + ssize_t recv (void *buf, + size_t n, + int *flags = 0) const; + + /// Send exactly n bytes to the connected transport mechanism. + ssize_t send_n (const void *buf, + size_t n, + int flags) const; + + // = Meta-type info + typedef ACE_ATM_Addr PEER_ADDR; + + /// Dump the state of an object. + void dump (void) const; + + /// Declare the dynamic allocation hooks. + ACE_ALLOC_HOOK_DECLARE; + +private: + /// Typedef'd to the appropriate stream mechanism above. + ATM_Stream stream_; +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +#include "ace/ATM_Stream.inl" +#endif /* __ACE_INLINE__ */ + +#endif /* ACE_HAS_ATM */ +#include /**/ "ace/post.h" +#endif /* ACE_ATM_STREAM_H */ diff --git a/dep/ACE_wrappers/ace/ATM_Stream.inl b/dep/ACE_wrappers/ace/ATM_Stream.inl new file mode 100644 index 00000000000..087c1ed440b --- /dev/null +++ b/dep/ACE_wrappers/ace/ATM_Stream.inl @@ -0,0 +1,133 @@ +// -*- C++ -*- +// +// $Id: ATM_Stream.inl 80826 2008-03-04 14:51:23Z wotte $ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_INLINE void +ACE_ATM_Stream::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + ACE_TRACE ("ACE_ATM_Stream::dump"); +#endif /* ACE_HAS_DUMP */ +} + +ACE_INLINE +ACE_ATM_Stream::ACE_ATM_Stream (void) +{ + ACE_TRACE ("ACE_ATM_Stream::ACE_ATM_Stream"); +} + +ACE_INLINE +int +ACE_ATM_Stream::open (ACE_ATM_Params params) +{ + ACE_TRACE ("ACE_ATM_Stream::open"); +#if defined (ACE_HAS_FORE_ATM_XTI) + ACE_HANDLE handle = stream_.open (params.get_device(), + params.get_oflag(), + params.get_info()); + return (handle == ACE_INVALID_HANDLE ? -1 : 0); +#elif defined (ACE_HAS_FORE_ATM_WS2) + params.set_flags( ACE_FLAG_MULTIPOINT_C_ROOT | ACE_FLAG_MULTIPOINT_D_ROOT ); + + int retval = stream_.open (params.get_type(), + params.get_protocol_family(), + params.get_protocol(), + params.get_protocol_info(), + params.get_sock_group(), + params.get_flags(), + params.get_reuse_addr()); + if (retval == -1) + return -1; + + struct sockaddr_atm sock_addr; + + ACE_OS::memset(&sock_addr, 0, sizeof(struct sockaddr_atm)); + sock_addr.satm_family = AF_ATM; + sock_addr.satm_number.AddressType=ADDR_ANY; + sock_addr.satm_number.NumofDigits = ATM_ADDR_SIZE; + sock_addr.satm_blli.Layer2Protocol = SAP_FIELD_ABSENT; + sock_addr.satm_blli.Layer3Protocol = SAP_FIELD_ABSENT; + sock_addr.satm_bhli.HighLayerInfoType = SAP_FIELD_ABSENT; + if (ACE_OS::bind(get_handle(), + (struct sockaddr FAR *)&sock_addr, + sizeof(struct sockaddr_atm)) < 0) + { + ACE_OS::printf("Error binding local address: %d",WSAGetLastError()); + return -1; + } + + return 0; +#else + ACE_UNUSED_ARG(params); + return 0; +#endif /* ACE_HAS_FORE_ATM_XTI */ +} + +ACE_INLINE +int +ACE_ATM_Stream::close (void) +{ + ACE_TRACE ("ACE_ATM_Stream::close"); +#if defined (ACE_HAS_FORE_ATM_XTI) || defined (ACE_HAS_FORE_ATM_WS2) + return stream_.close (); +#else + return 0; +#endif /* ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_ATM_WS2 */ +} + +ACE_INLINE +ATM_Stream& +ACE_ATM_Stream::get_stream (void) +{ + ACE_TRACE ("ACE_ATM_Stream::get_stream"); + return stream_; +} + +ACE_INLINE +ssize_t +ACE_ATM_Stream::recv (void *buf, + size_t n, + int *flags) const +{ + ACE_TRACE ("ACE_ATM_Stream::recv"); +#if defined (ACE_HAS_FORE_ATM_XTI) + return stream_.recv (buf, + n, + flags); +#elif defined (ACE_HAS_FORE_ATM_WS2) + return stream_.recv (buf, + n); +#else + ACE_UNUSED_ARG(buf); + ACE_UNUSED_ARG(n); + ACE_UNUSED_ARG(flags); + return (0); +#endif /* ACE_HAS_FORE_ATM_XTI */ +} + +ACE_INLINE +ssize_t +ACE_ATM_Stream::send_n (const void *buf, + size_t n, + int flags) const +{ + ACE_TRACE ("ACE_ATM_Stream::send_n"); +#if defined (ACE_HAS_FORE_ATM_XTI) + return stream_.send_n (buf, + n, + flags); +#elif defined (ACE_HAS_FORE_ATM_WS2) + return stream_.send_n (buf, + n, + flags); +#else + ACE_UNUSED_ARG(buf); + ACE_UNUSED_ARG(n); + ACE_UNUSED_ARG(flags); + return (0); +#endif /* ACE_HAS_FORE_ATM_XTI */ +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Acceptor.cpp b/dep/ACE_wrappers/ace/Acceptor.cpp new file mode 100644 index 00000000000..1ba51af5e5a --- /dev/null +++ b/dep/ACE_wrappers/ace/Acceptor.cpp @@ -0,0 +1,1235 @@ +#ifndef ACE_ACCEPTOR_CPP +#define ACE_ACCEPTOR_CPP + +#include "ace/ACE.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/Acceptor.h" +#include "ace/Handle_Set.h" +#include "ace/Svc_Handler.h" +#include "ace/WFMO_Reactor.h" +#include "ace/OS_NS_stdio.h" +#include "ace/OS_NS_string.h" +#include "ace/OS_NS_sys_select.h" + +ACE_RCSID (ace, + Acceptor, + "$Id: Acceptor.cpp 81991 2008-06-16 19:05:40Z elliott_c $") + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_ALLOC_HOOK_DEFINE(ACE_Acceptor) + +template void +ACE_Acceptor::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + ACE_TRACE ("ACE_Acceptor::dump"); + + ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); + this->peer_acceptor_.dump (); + ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); +#endif /* ACE_HAS_DUMP */ +} + +template +ACE_Acceptor::operator ACE_PEER_ACCEPTOR & () const +{ + ACE_TRACE ("ACE_Acceptor::operator ACE_PEER_ACCEPTOR &"); + return (ACE_PEER_ACCEPTOR &) this->peer_acceptor_; +} + +template ACE_PEER_ACCEPTOR & +ACE_Acceptor::acceptor (void) const +{ + ACE_TRACE ("ACE_Acceptor::acceptor"); + return const_cast (this->peer_acceptor_); +} + +// Returns ACE_HANDLE of the underlying Acceptor_Strategy. + +template ACE_HANDLE +ACE_Acceptor::get_handle (void) const +{ + ACE_TRACE ("ACE_Acceptor::get_handle"); + return this->peer_acceptor_.get_handle (); +} + +// Initialize the appropriate strategies for creation, passive +// connection acceptance, and concurrency, and then register +// with the Reactor and listen for connection requests at the +// designated . + +template int +ACE_Acceptor::open + (const ACE_PEER_ACCEPTOR_ADDR &local_addr, + ACE_Reactor *reactor, + int flags, + int use_select, + int reuse_addr) +{ + ACE_TRACE ("ACE_Acceptor::open"); + this->flags_ = flags; + this->use_select_ = use_select; + this->reuse_addr_ = reuse_addr; + this->peer_acceptor_addr_ = local_addr; + + // Must supply a valid Reactor to Acceptor::open()... + + if (reactor == 0) + { + errno = EINVAL; + return -1; + } + + if (this->peer_acceptor_.open (local_addr, reuse_addr) == -1) + return -1; + + // Set the peer acceptor's handle into non-blocking mode. This is a + // safe-guard against the race condition that can otherwise occur + // between the time when indicates that a passive-mode + // socket handle is "ready" and when we call . During this + // interval, the client can shutdown the connection, in which case, + // the call can hang! + if (this->accept_strategy_->acceptor ().enable (ACE_NONBLOCK) != 0) + return -1; + + // Initialize the concurrency strategy. + + if (con_s == 0) + { + ACE_NEW_RETURN (con_s, + CONCURRENCY_STRATEGY, + -1); + this->delete_concurrency_strategy_ = true; + } + this->concurrency_strategy_ = con_s; + + // Initialize the scheduling strategy. + + if (sch_s == 0) + { + ACE_NEW_RETURN (sch_s, + SCHEDULING_STRATEGY, + -1); + this->delete_scheduling_strategy_ = true; + } + this->scheduling_strategy_ = sch_s; + + this->use_select_ = use_select; + + return this->reactor ()->register_handler + (this, + ACE_Event_Handler::ACCEPT_MASK); +} + +// Simple constructor. + +template +ACE_Strategy_Acceptor::ACE_Strategy_Acceptor + (const ACE_TCHAR service_name[], + const ACE_TCHAR service_description[], + int use_select, + int reuse_addr) + : creation_strategy_ (0), + delete_creation_strategy_ (false), + accept_strategy_ (0), + delete_accept_strategy_ (false), + concurrency_strategy_ (0), + delete_concurrency_strategy_ (false), + scheduling_strategy_ (0), + delete_scheduling_strategy_ (false), + service_name_ (0), + service_description_ (0) +{ + ACE_TRACE ("ACE_Strategy_Acceptor::ACE_Strategy_Acceptor"); + + if (service_name != 0) + ACE_ALLOCATOR (this->service_name_, + ACE_OS::strdup (service_name)); + if (service_description != 0) + ACE_ALLOCATOR (this->service_description_, + ACE_OS::strdup (service_description)); + this->use_select_ = use_select; + this->reuse_addr_ = reuse_addr; +} + +template +ACE_Strategy_Acceptor::ACE_Strategy_Acceptor + (const ACE_PEER_ACCEPTOR_ADDR &addr, + ACE_Reactor *reactor, + ACE_Creation_Strategy *cre_s, + ACE_Accept_Strategy *acc_s, + ACE_Concurrency_Strategy *con_s, + ACE_Scheduling_Strategy *sch_s, + const ACE_TCHAR service_name[], + const ACE_TCHAR service_description[], + int use_select, + int reuse_addr) + : creation_strategy_ (0), + delete_creation_strategy_ (false), + accept_strategy_ (0), + delete_accept_strategy_ (false), + concurrency_strategy_ (0), + delete_concurrency_strategy_ (false), + scheduling_strategy_ (0), + delete_scheduling_strategy_ (false), + service_name_ (0), + service_description_ (0) +{ + ACE_TRACE ("ACE_Strategy_Acceptor::ACE_Strategy_Acceptor"); + + if (this->open (addr, + reactor, + cre_s, + acc_s, + con_s, + sch_s, + service_name, + service_description, + use_select, + reuse_addr) == -1) + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("%p\n"), + ACE_TEXT ("ACE_Strategy_Acceptor::ACE_Strategy_Acceptor"))); +} + +// Perform termination activities when is removed from the +// . + +template int +ACE_Strategy_Acceptor::handle_close (ACE_HANDLE, + ACE_Reactor_Mask) +{ + ACE_TRACE ("ACE_Strategy_Acceptor::handle_close"); + // Guard against multiple closes. + if (this->reactor () != 0) + { + ACE_HANDLE handle = this->get_handle (); + + if (this->delete_creation_strategy_) + delete this->creation_strategy_; + this->delete_creation_strategy_ = false; + this->creation_strategy_ = 0; + + if (this->delete_accept_strategy_) + delete this->accept_strategy_; + this->delete_accept_strategy_ = false; + this->accept_strategy_ = 0; + + if (this->delete_concurrency_strategy_) + delete this->concurrency_strategy_; + this->delete_concurrency_strategy_ = false; + this->concurrency_strategy_ = 0; + + if (this->delete_scheduling_strategy_) + delete this->scheduling_strategy_; + this->delete_scheduling_strategy_ = false; + this->scheduling_strategy_ = 0; + + // We must use the obtained *before* we deleted the + // accept_strategy_... + + this->reactor ()->remove_handler + (handle, + ACE_Event_Handler::ACCEPT_MASK | ACE_Event_Handler::DONT_CALL); + + // Set the Reactor to 0 so that we don't try to close down + // again. + this->reactor (0); + } + return 0; +} + +// Bridge method for creating a . The strategy for +// creating a are configured into the Acceptor via it's +// . The default is to create a new +// . However, subclasses can override this strategy to +// perform creation in any way that they like (such as +// creating subclass instances of , using a singleton, +// dynamically linking the handler, etc.). + +template int +ACE_Strategy_Acceptor::make_svc_handler (SVC_HANDLER *&sh) +{ + ACE_TRACE ("ACE_Strategy_Acceptor::make_svc_handler"); + return this->creation_strategy_->make_svc_handler (sh); +} + +// Bridge method for accepting the new connection into the +// . The default behavior delegates to the +// in the Acceptor_Strategy. + +template int +ACE_Strategy_Acceptor::accept_svc_handler + (SVC_HANDLER *svc_handler) +{ + ACE_TRACE ("ACE_Strategy_Acceptor::accept_svc_handler"); + return this->accept_strategy_->accept_svc_handler (svc_handler); +} + +// Bridge method for activating a with the appropriate +// concurrency strategy. The default behavior of this method is to +// activate the SVC_HANDLER by calling its open() method (which allows +// the SVC_HANDLER to define its own concurrency strategy). However, +// subclasses can override this strategy to do more sophisticated +// concurrency activations (such as creating the SVC_HANDLER as an +// "active object" via multi-threading or multi-processing). + +template int +ACE_Strategy_Acceptor::activate_svc_handler + (SVC_HANDLER *svc_handler) +{ + ACE_TRACE ("ACE_Strategy_Acceptor::activate_svc_handler"); + return this->concurrency_strategy_->activate_svc_handler + (svc_handler, + (void *) this); +} + +template +ACE_Strategy_Acceptor::~ACE_Strategy_Acceptor (void) +{ + ACE_TRACE ("ACE_Strategy_Acceptor::~ACE_Strategy_Acceptor"); + ACE_OS::free ((void *) this->service_name_); + ACE_OS::free ((void *) this->service_description_); + this->handle_close (); +} + +// Signal the server to shutdown gracefully. + +template int +ACE_Strategy_Acceptor::handle_signal (int, siginfo_t *, ucontext_t *) +{ + ACE_Reactor::instance()->end_reactor_event_loop (); + return 0; +} + +template int +ACE_Strategy_Acceptor::info (ACE_TCHAR **strp, + size_t length) const +{ + ACE_TRACE ("ACE_Strategy_Acceptor::info"); + + ACE_TCHAR buf[BUFSIZ]; + ACE_TCHAR service_addr_str[BUFSIZ]; + ACE_PEER_ACCEPTOR_ADDR addr; + + if (this->acceptor ().get_local_addr (addr) == -1) + return -1; + else if (addr.addr_to_string (service_addr_str, + sizeof service_addr_str) == -1) + return -1; + + // @@ Should add the protocol in... + ACE_OS::sprintf (buf, + ACE_TEXT ("%s\t %s #%s\n"), + this->service_name_ == 0 + ? ACE_TEXT ("") + : this->service_name_, + service_addr_str, + this->service_description_ == 0 + ? ACE_TEXT ("") + : this->service_description_); + + if (*strp == 0 && (*strp = ACE_OS::strdup (buf)) == 0) + return -1; + else + ACE_OS::strsncpy (*strp, buf, length); + return static_cast (ACE_OS::strlen (buf)); +} + +template int +ACE_Strategy_Acceptor::fini (void) +{ + ACE_TRACE ("ACE_Strategy_Acceptor::fini"); + return this->ACE_Strategy_Acceptor::handle_close (); +} + +ACE_ALLOC_HOOK_DEFINE(ACE_Oneshot_Acceptor) + +template void +ACE_Oneshot_Acceptor::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + ACE_TRACE ("ACE_Oneshot_Acceptor::dump"); + + ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nsvc_handler_ = %x"), this->svc_handler_)); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nrestart_ = %d"), this->restart_)); + this->peer_acceptor_.dump (); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("delete_concurrency_strategy_ = %d"), + delete_concurrency_strategy_)); + this->concurrency_strategy_->dump (); + ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); +#endif /* ACE_HAS_DUMP */ +} + +template int +ACE_Oneshot_Acceptor::open + (const ACE_PEER_ACCEPTOR_ADDR &local_addr, + ACE_Reactor *reactor, + ACE_Concurrency_Strategy *con_s) +{ + ACE_TRACE ("ACE_Oneshot_Acceptor::open"); + this->reactor (reactor); + + // Initialize the concurrency strategy. + + if (con_s == 0) + { + ACE_NEW_RETURN (con_s, + ACE_Concurrency_Strategy, + -1); + this->delete_concurrency_strategy_ = true; + } + this->concurrency_strategy_ = con_s; + + // Reuse the addr, even if it is already in use...! + return this->peer_acceptor_.open (local_addr, 1); +} + +template +ACE_Oneshot_Acceptor::ACE_Oneshot_Acceptor (void) + : delete_concurrency_strategy_ (false) +{ + ACE_TRACE ("ACE_Oneshot_Acceptor::ACE_Oneshot_Acceptor"); + this->reactor (0); +} + +template +ACE_Oneshot_Acceptor::ACE_Oneshot_Acceptor + (const ACE_PEER_ACCEPTOR_ADDR &local_addr, + ACE_Reactor *reactor, + ACE_Concurrency_Strategy *cs) + : delete_concurrency_strategy_ (false) +{ + ACE_TRACE ("ACE_Oneshot_Acceptor::ACE_Oneshot_Acceptor"); + if (this->open (local_addr, reactor, cs) == -1) + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("%p\n"), + ACE_TEXT ("ACE_Oneshot_Acceptor::ACE_Oneshot_Acceptor"))); +} + +template +ACE_Oneshot_Acceptor::~ACE_Oneshot_Acceptor (void) +{ + ACE_TRACE ("ACE_Oneshot_Acceptor::~ACE_Oneshot_Acceptor"); + this->handle_close (); +} + +template int +ACE_Oneshot_Acceptor::close (void) +{ + ACE_TRACE ("ACE_Oneshot_Acceptor::close"); + return this->handle_close (); +} + +template int +ACE_Oneshot_Acceptor::handle_close (ACE_HANDLE, + ACE_Reactor_Mask) +{ + ACE_TRACE ("ACE_Oneshot_Acceptor::handle_close"); + + // Guard against multiple closes. + if (this->delete_concurrency_strategy_) + { + delete this->concurrency_strategy_; + this->delete_concurrency_strategy_ = false; + this->concurrency_strategy_ = 0; + } + // Note that if we aren't actually registered with the + // ACE_Reactor then it's ok for this call to fail... + + if (this->reactor ()) + this->reactor ()->remove_handler + (this, + ACE_Event_Handler::ACCEPT_MASK | ACE_Event_Handler::DONT_CALL); + + if (this->peer_acceptor_.close () == -1) + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("close\n"))); + return 0; +} + +template int +ACE_Oneshot_Acceptor::handle_timeout + (const ACE_Time_Value &tv, + const void *arg) +{ + ACE_TRACE ("ACE_Oneshot_Acceptor::handle_timeout"); + errno = ETIME; + + if (this->svc_handler_->handle_timeout (tv, arg) == -1) + this->svc_handler_->handle_close (this->svc_handler_->get_handle (), + ACE_Event_Handler::TIMER_MASK); + + // Since we aren't necessarily registered with the Reactor, don't + // bother to check the return value here... + if (this->reactor ()) + this->reactor ()->remove_handler (this, + ACE_Event_Handler::ACCEPT_MASK); + return 0; +} + +template int +ACE_Oneshot_Acceptor::cancel (void) +{ + ACE_TRACE ("ACE_Oneshot_Acceptor::cancel"); + return this->reactor () && this->reactor ()->cancel_timer (this); +} + +template int +ACE_Oneshot_Acceptor::register_handler + (SVC_HANDLER *svc_handler, + const ACE_Synch_Options &synch_options, + int restart) +{ + ACE_TRACE ("ACE_Oneshot_Acceptor::register_handler"); + // Can't do this if we don't have a Reactor. + if (this->reactor () == 0) + { + errno = EINVAL; + return -1; + } + else + { + this->svc_handler_ = svc_handler; + this->restart_ = restart; + ACE_Time_Value *tv = (ACE_Time_Value *) synch_options.time_value (); + + if (tv != 0 + && this->reactor ()->schedule_timer (this, + synch_options.arg (), + *tv) == 0) + return -1; + else + return this->reactor ()->register_handler + (this, + ACE_Event_Handler::ACCEPT_MASK); + } +} + +// Bridge method for activating a with the appropriate +// concurrency strategy. The default behavior of this method is to +// activate the SVC_HANDLER by calling its open() method (which allows +// the SVC_HANDLER to define its own concurrency strategy). However, +// subclasses can override this strategy to do more sophisticated +// concurrency activations (such as creating the SVC_HANDLER as an +// "active object" via multi-threading or multi-processing). + +template int +ACE_Oneshot_Acceptor::activate_svc_handler + (SVC_HANDLER *svc_handler) +{ + ACE_TRACE ("ACE_Oneshot_Acceptor::activate_svc_handler"); + return this->concurrency_strategy_->activate_svc_handler + (svc_handler, + (void *) this); +} + +// Factors out the code shared between the and +// methods. + +template int +ACE_Oneshot_Acceptor::shared_accept + (SVC_HANDLER *svc_handler, + ACE_PEER_ACCEPTOR_ADDR *remote_addr, + ACE_Time_Value *timeout, + int restart, + int reset_new_handle) +{ + ACE_TRACE ("ACE_Oneshot_Acceptor::shared_accept"); + if (svc_handler == 0) + return -1; + + // Accept connection into the Svc_Handler. + else if (this->peer_acceptor_.accept (svc_handler->peer (), // stream + remote_addr, // remote address + timeout, // timeout + restart, // restart + reset_new_handle // reset new handle + ) == -1) + { + // Check whether we just timed out or whether we failed... + if (!(errno == EWOULDBLOCK || errno == ETIME)) + // Close down handler to avoid memory leaks. + svc_handler->close (CLOSE_DURING_NEW_CONNECTION); + return -1; + } + // Activate the using the designated concurrency + // strategy (note that this method becomes responsible for handling + // errors and freeing up the memory if things go awry...) + else + return this->activate_svc_handler (svc_handler); +} + +// Make a SVC_HANDLER, accept the connection into the SVC_HANDLER, and +// then activate the SVC_HANDLER. Note that SVC_HANDLER::open() +// decides what type of concurrency strategy to use. + +template int +ACE_Oneshot_Acceptor::accept + (SVC_HANDLER *svc_handler, + ACE_PEER_ACCEPTOR_ADDR *remote_addr, + const ACE_Synch_Options &synch_options, + int restart, + int reset_new_handle) +{ + ACE_TRACE ("ACE_Oneshot_Acceptor::accept"); + // Note that if timeout == ACE_Time_Value (x, y) where (x > 0 || y > + // 0) then this->connector_.connect() will block synchronously. If + // is set then we don't want this to happen (since we + // want the ACE_Reactor to do the timeout asynchronously). + // Therefore, we'll force this->connector_ to use ACE_Time_Value (0, + // 0) in this case... + + ACE_Time_Value *timeout; + int use_reactor = synch_options[ACE_Synch_Options::USE_REACTOR]; + + if (use_reactor) + timeout = (ACE_Time_Value *) &ACE_Time_Value::zero; + else + timeout = (ACE_Time_Value *) synch_options.time_value (); + + if (this->shared_accept (svc_handler, // stream + remote_addr, // remote address + timeout, // timeout + restart, // restart + reset_new_handle // reset new handler + ) == -1) + { + if (use_reactor && errno == EWOULDBLOCK) + // We couldn't accept right away, so let's wait in the + // . + this->register_handler (svc_handler, + synch_options, + restart); + return -1; + } + return 0; +} + +// Accepts one pending connection from a client (since we're the +// "oneshot" Acceptor). + +template int +ACE_Oneshot_Acceptor::handle_input (ACE_HANDLE) +{ + ACE_TRACE ("ACE_Oneshot_Acceptor::handle_input"); + int result = 0; + + // Cancel any timer that might be pending. + this->cancel (); + + // Try to find out if the implementation of the reactor that we are + // using requires us to reset the event association for the newly + // created handle. This is because the newly created handle will + // inherit the properties of the listen handle, including its event + // associations. + int reset_new_handle = this->reactor ()->uses_event_associations (); + + // There is a use-case whereby this object will be gone upon return + // from shared_accept - if the Svc_Handler deletes this Oneshot_Acceptor + // during the shared_accept/activation steps. So, do whatever we need + // to do with this object before calling shared_accept. + if (this->reactor ()) + this->reactor ()->remove_handler + (this, + ACE_Event_Handler::ACCEPT_MASK | ACE_Event_Handler::DONT_CALL); + + if (this->shared_accept (this->svc_handler_, // stream + 0, // remote address + 0, // timeout + this->restart_, // restart + reset_new_handle // reset new handle + ) == -1) + result = -1; + + return result; +} + +// Hook called by the explicit dynamic linking facility. + +template int +ACE_Oneshot_Acceptor::init (int, ACE_TCHAR *[]) +{ + ACE_TRACE ("ACE_Oneshot_Acceptor::init"); + return -1; +} + +template int +ACE_Oneshot_Acceptor::fini (void) +{ + ACE_TRACE ("ACE_Oneshot_Acceptor::fini"); + return this->handle_close (); +} + +template int +ACE_Oneshot_Acceptor::info (ACE_TCHAR **strp, + size_t length) const +{ + ACE_TRACE ("ACE_Oneshot_Acceptor::info"); + ACE_TCHAR buf[BUFSIZ]; + ACE_TCHAR addr_str[BUFSIZ]; + ACE_PEER_ACCEPTOR_ADDR addr; + + if (this->peer_acceptor_.get_local_addr (addr) == -1) + return -1; + else if (addr.addr_to_string (addr_str, sizeof addr_str) == -1) + return -1; + + ACE_OS::sprintf (buf, + ACE_TEXT ("%s\t %s %s"), + ACE_TEXT ("ACE_Oneshot_Acceptor"), + addr_str, + ACE_TEXT ("#oneshot acceptor factory\n")); + + if (*strp == 0 && (*strp = ACE_OS::strdup (buf)) == 0) + return -1; + else + ACE_OS::strsncpy (*strp, buf, length); + return static_cast (ACE_OS::strlen (buf)); +} + +template int +ACE_Oneshot_Acceptor::suspend (void) +{ + ACE_TRACE ("ACE_Oneshot_Acceptor::suspend"); + return this->reactor () && this->reactor ()->suspend_handler (this); +} + +template int +ACE_Oneshot_Acceptor::resume (void) +{ + ACE_TRACE ("ACE_Oneshot_Acceptor::resume"); + return this->reactor () && this->reactor ()->resume_handler (this); +} + +// Returns ACE_HANDLE of the underlying peer_acceptor. + +template ACE_HANDLE +ACE_Oneshot_Acceptor::get_handle (void) const +{ + ACE_TRACE ("ACE_Oneshot_Acceptor::get_handle"); + return this->peer_acceptor_.get_handle (); +} + +template ACE_PEER_ACCEPTOR & +ACE_Oneshot_Acceptor::acceptor (void) const +{ + ACE_TRACE ("ACE_Oneshot_Acceptor::acceptor"); + return (ACE_PEER_ACCEPTOR &) this->peer_acceptor_; +} + +template +ACE_Oneshot_Acceptor::operator ACE_PEER_ACCEPTOR & () const +{ + ACE_TRACE ("ACE_Oneshot_Acceptor::operator ACE_PEER_ACCEPTOR &"); + return (ACE_PEER_ACCEPTOR &) this->peer_acceptor_; +} + +ACE_END_VERSIONED_NAMESPACE_DECL + +#endif /* ACE_ACCEPTOR_CPP */ diff --git a/dep/ACE_wrappers/ace/Acceptor.h b/dep/ACE_wrappers/ace/Acceptor.h new file mode 100644 index 00000000000..88329be53a4 --- /dev/null +++ b/dep/ACE_wrappers/ace/Acceptor.h @@ -0,0 +1,688 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Acceptor.h + * + * $Id: Acceptor.h 81460 2008-04-28 11:34:23Z elliott_c $ + * + * @author Douglas C. Schmidt + */ +//============================================================================= + +#ifndef ACE_ACCEPTOR_H +#define ACE_ACCEPTOR_H + +#include /**/ "ace/pre.h" + +#include "ace/Service_Object.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/Strategies_T.h" +#include "ace/Synch_Options.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +/** + * @class ACE_Acceptor + * + * @brief Abstract factory for creating a service handler + * (SVC_HANDLER), accepting into the SVC_HANDLER, and + * activating the SVC_HANDLER. + * + * Implements the basic strategy for passively establishing + * connections with clients. An ACE_Acceptor is parameterized + * by concrete types that conform to the interfaces of + * PEER_ACCEPTOR and SVC_HANDLER. The PEER_ACCEPTOR is + * instantiated with a transport mechanism that passively + * establishes connections. The SVC_HANDLER is instantiated + * with a concrete type that performs the application-specific + * service. An ACE_Acceptor inherits from ACE_Service_Object, + * which in turn inherits from ACE_Event_Handler. This enables + * the ACE_Reactor to dispatch the ACE_Acceptor's handle_input + * method when connection events occur. The handle_input method + * performs the ACE_Acceptor's default creation, connection + * establishment, and service activation strategies. These + * strategies can be overridden by subclasses individually or as + * a group. + */ +template +class ACE_Acceptor : public ACE_Service_Object +{ +public: + + // Useful STL-style traits. + typedef ACE_PEER_ACCEPTOR_ADDR addr_type; + typedef ACE_PEER_ACCEPTOR acceptor_type; + typedef SVC_HANDLER handler_type; + typedef typename SVC_HANDLER::stream_type stream_type; + + /// "Do-nothing" constructor. + ACE_Acceptor (ACE_Reactor * = 0, + int use_select = 1); + + /** + * Open the contained @c PEER_ACCEPTOR object to begin listening, and + * register with the specified reactor for accept events. An + * acceptor can only listen to one port at a time, so make sure to + * @c close() the acceptor before calling @c open() again. + * + * The @c PEER_ACCEPTOR handle is put into non-blocking mode as a + * safeguard against the race condition that can otherwise occur + * between the time when the passive-mode socket handle is "ready" + * and when the actual @c accept() call is made. During this + * interval, the client can shutdown the connection, in which case, + * the @c accept() call can hang. + * + * @param local_addr The address to listen at. + * @param reactor Pointer to the ACE_Reactor instance to register + * this object with. The default is the singleton. + * @param flags Flags to control what mode an accepted socket + * will be put into after it is accepted. The only + * legal value for this argument is @c ACE_NONBLOCK, + * which enables non-blocking mode on the accepted + * peer stream object in @c SVC_HANDLER. The default + * is 0. + * @param use_select Affects behavior when called back by the reactor + * when a connection can be accepted. If non-zero, + * this object will accept all pending connections, + * intead of just the one that triggered the reactor + * callback. Uses ACE_OS::select() internally to + * detect any remaining acceptable connections. + * The default is 1. + * @param reuse_addr Passed to the @c PEER_ACCEPTOR::open() method with + * @p local_addr. Generally used to request that the + * OS allow reuse of the listen port. The default is 1. + */ + ACE_Acceptor (const ACE_PEER_ACCEPTOR_ADDR &local_addr, + ACE_Reactor *reactor = ACE_Reactor::instance (), + int flags = 0, + int use_select = 1, + int reuse_addr = 1); + + /** + * Open the contained @c PEER_ACCEPTOR object to begin listening, and + * register with the specified reactor for accept events. An + * acceptor can only listen to one port at a time, so make sure to + * @c close() the acceptor before calling @c open() again. + * + * The @c PEER_ACCEPTOR handle is put into non-blocking mode as a + * safeguard against the race condition that can otherwise occur + * between the time when the passive-mode socket handle is "ready" + * and when the actual @c accept() call is made. During this + * interval, the client can shutdown the connection, in which case, + * the @c accept() call can hang. + * + * @param local_addr The address to listen at. + * @param reactor Pointer to the ACE_Reactor instance to register + * this object with. The default is the singleton. + * @param flags Flags to control what mode an accepted socket + * will be put into after it is accepted. The only + * legal value for this argument is @c ACE_NONBLOCK, + * which enables non-blocking mode on the accepted + * peer stream object in @c SVC_HANDLER. The default + * is 0. + * @param use_select Affects behavior when called back by the reactor + * when a connection can be accepted. If non-zero, + * this object will accept all pending connections, + * intead of just the one that triggered the reactor + * callback. Uses ACE_OS::select() internally to + * detect any remaining acceptable connections. + * The default is 1. + * @param reuse_addr Passed to the @c PEER_ACCEPTOR::open() method with + * @p local_addr. Generally used to request that the + * OS allow reuse of the listen port. The default is 1. + * + * @retval 0 Success + * @retval -1 Failure, @c errno contains an error code. + */ + virtual int open (const ACE_PEER_ACCEPTOR_ADDR &local_addr, + ACE_Reactor *reactor = ACE_Reactor::instance (), + int flags = 0, + int use_select = 1, + int reuse_addr = 1); + + /// Close down the Acceptor's resources. + virtual ~ACE_Acceptor (void); + + /// Return the underlying PEER_ACCEPTOR object. + virtual operator ACE_PEER_ACCEPTOR &() const; + + /// Return the underlying PEER_ACCEPTOR object. + virtual ACE_PEER_ACCEPTOR &acceptor (void) const; + + /// Returns the listening acceptor's {ACE_HANDLE}. + virtual ACE_HANDLE get_handle (void) const; + + /// Close down the Acceptor + virtual int close (void); + + /// In the event that an accept fails, this method will be called and + /// the return value will be returned from handle_input(). + virtual int handle_accept_error (void); + + /// Dump the state of an object. + void dump (void) const; + + /// Declare the dynamic allocation hooks. + ACE_ALLOC_HOOK_DECLARE; + +protected: + // = The following three methods define the Acceptor's strategies + // for creating, accepting, and activating SVC_HANDLER's, + // respectively. + + /** + * Bridge method for creating a SVC_HANDLER. The default is to + * create a new {SVC_HANDLER} if {sh} == 0, else {sh} is unchanged. + * However, subclasses can override this policy to perform + * SVC_HANDLER creation in any way that they like (such as creating + * subclass instances of SVC_HANDLER, using a singleton, dynamically + * linking the handler, etc.). Returns -1 on failure, else 0. + */ + virtual int make_svc_handler (SVC_HANDLER *&sh); + + /** + * Bridge method for accepting the new connection into the + * . The default behavior delegates to the + * PEER_ACCEPTOR::accept. + */ + virtual int accept_svc_handler (SVC_HANDLER *svc_handler); + + /** + * Bridge method for activating a {svc_handler} with the appropriate + * concurrency strategy. The default behavior of this method is to + * activate the SVC_HANDLER by calling its {open} method (which + * allows the SVC_HANDLER to define its own concurrency strategy). + * However, subclasses can override this strategy to do more + * sophisticated concurrency activations (such as making the + * SVC_HANDLER as an "active object" via multi-threading or + * multi-processing). + */ + virtual int activate_svc_handler (SVC_HANDLER *svc_handler); + + // = Demultiplexing hooks. + /// Perform termination activities when {this} is removed from the + /// {reactor}. + virtual int handle_close (ACE_HANDLE = ACE_INVALID_HANDLE, + ACE_Reactor_Mask = ACE_Event_Handler::ALL_EVENTS_MASK); + + /// Accepts all pending connections from clients, and creates and + /// activates SVC_HANDLERs. + virtual int handle_input (ACE_HANDLE); + + // = Dynamic linking hooks. + /// Default version does no work and returns -1. Must be overloaded + /// by application developer to do anything meaningful. + virtual int init (int argc, ACE_TCHAR *argv[]); + + /// Calls {handle_close}. + virtual int fini (void); + + /// Default version returns address info in {buf}. + virtual int info (ACE_TCHAR **buf, size_t) const; + +public: + // = Service management hooks. + /// This method calls {Reactor::suspend}. + virtual int suspend (void); + + /// This method calls {Reactor::resume}. + virtual int resume (void); + +protected: + /// Concrete factory for accepting connections from clients... + ACE_PEER_ACCEPTOR peer_acceptor_; + + /// Needed to reopen the socket if {accept} fails. + ACE_PEER_ACCEPTOR_ADDR peer_acceptor_addr_; + + /** + * Flags that indicate how {SVC_HANDLER}'s should be initialized + * prior to being activated. Right now, the only flag that is + * processed is {ACE_NONBLOCK}, which enabled non-blocking I/O on + * the {SVC_HANDLER} when it is opened. + */ + int flags_; + + /// Flag that indicates whether it shall use {select} in the + /// {accept}-loop. + int use_select_; + + /// Needed to reopen the socket if {accept} fails. + int reuse_addr_; +}; + +/** + * @class ACE_Strategy_Acceptor + * + * @brief Abstract factory for creating a service handler + * (SVC_HANDLER), accepting into the SVC_HANDLER, and activating + * the SVC_HANDLER. + * + * Implements a flexible and extensible set of strategies for + * passively establishing connections with clients. There are + * three main strategies: (1) creating a SVC_HANDLER, (2) + * passively accepting a new connection from a client into the + * SVC_HANDLER, and (3) activating the SVC_HANDLER with a + * particular concurrency mechanism. + */ +template +class ACE_Strategy_Acceptor + : public ACE_Acceptor +{ +public: + + // Useful STL-style traits. + typedef ACE_Creation_Strategy + creation_strategy_type; + typedef ACE_Accept_Strategy + accept_strategy_type; + typedef ACE_Concurrency_Strategy + concurrency_strategy_type; + typedef ACE_Scheduling_Strategy scheduling_strategy_type; + typedef ACE_Acceptor + base_type; + + // = Define some useful (old style) traits. + typedef ACE_Creation_Strategy CREATION_STRATEGY; + typedef ACE_Accept_Strategy ACCEPT_STRATEGY; + typedef ACE_Concurrency_Strategy CONCURRENCY_STRATEGY; + typedef ACE_Scheduling_Strategy SCHEDULING_STRATEGY; + + + + /// Default constructor. + ACE_Strategy_Acceptor (const ACE_TCHAR service_name[] = 0, + const ACE_TCHAR service_description[] = 0, + int use_select = 1, + int reuse_addr = 1); + + /** + * Initialize the appropriate strategies for creation, passive + * connection acceptance, and concurrency, and then register {this} + * with the Reactor and listen for connection requests at the + * designated {local_addr}. + */ + ACE_Strategy_Acceptor (const ACE_PEER_ACCEPTOR_ADDR &local_addr, + ACE_Reactor * = ACE_Reactor::instance (), + ACE_Creation_Strategy * = 0, + ACE_Accept_Strategy * = 0, + ACE_Concurrency_Strategy * = 0, + ACE_Scheduling_Strategy * = 0, + const ACE_TCHAR service_name[] = 0, + const ACE_TCHAR service_description[] = 0, + int use_select = 1, + int reuse_addr = 1); + + /** + * Open the contained @c PEER_ACCEPTOR object to begin listening, and + * register with the specified reactor for accept events. + * + * The @c PEER_ACCEPTOR handle is put into non-blocking mode as a + * safeguard against the race condition that can otherwise occur + * between the time when the passive-mode socket handle is "ready" + * and when the actual @c accept call is made. During this + * interval, the client can shutdown the connection, in which case, + * the {accept} call can hang. + * + * @param local_addr The address to listen at. + * @param reactor Pointer to the ACE_Reactor instance to register + * this object with. The default is the singleton. + * @param flags Flags to control what mode an accepted socket + * will be put into after it is accepted. The only + * legal value for this argument is @c ACE_NONBLOCK, + * which enables non-blocking mode on the accepted + * peer stream object in @c SVC_HANDLER. The default + * is 0. + * @param use_select Affects behavior when called back by the reactor + * when a connection can be accepted. If non-zero, + * this object will accept all pending connections, + * intead of just the one that triggered the reactor + * callback. Uses ACE_OS::select() internally to + * detect any remaining acceptable connections. + * The default is 1. + * @param reuse_addr Passed to the @c PEER_ACCEPTOR::open() method with + * @p local_addr. Generally used to request that the + * OS allow reuse of the listen port. The default is 1. + * + * @retval 0 Success + * @retval -1 Failure, @c errno contains an error code. + */ + virtual int open (const ACE_PEER_ACCEPTOR_ADDR &local_addr, + ACE_Reactor *reactor, + int flags = 0, + int use_select = 1, + int reuse_addr = 1); + + /** + * Initialize the appropriate strategies for creation, passive + * connection acceptance, and concurrency, and then register {this} + * with the Reactor and listen for connection requests at the + * designated {local_addr}. + */ + virtual int open (const ACE_PEER_ACCEPTOR_ADDR &, + ACE_Reactor * = ACE_Reactor::instance (), + ACE_Creation_Strategy * = 0, + ACE_Accept_Strategy * =0, + ACE_Concurrency_Strategy * = 0, + ACE_Scheduling_Strategy * = 0, + const ACE_TCHAR *service_name = 0, + const ACE_TCHAR *service_description = 0, + int use_select = 1, + int reuse_addr = 1); + + /// Close down the Strategy_Acceptor's resources. + virtual ~ACE_Strategy_Acceptor (void); + + /// Return the underlying PEER_ACCEPTOR object. + virtual operator ACE_PEER_ACCEPTOR &() const; + + /// Return the underlying PEER_ACCEPTOR object. + virtual ACE_PEER_ACCEPTOR &acceptor (void) const; + + /// Returns the listening acceptor's {ACE_HANDLE}. + virtual ACE_HANDLE get_handle (void) const; + + /// Dump the state of an object. + void dump (void) const; + + /// Declare the dynamic allocation hooks. + ACE_ALLOC_HOOK_DECLARE; + + // = Service management hooks. + + /// This method delegates to the {Scheduling_Strategy}'s {suspend} + /// method. + virtual int suspend (void); + + /// This method delegates to the {Scheduling_Strategy}'s {resume} + /// method. + virtual int resume (void); + +protected: + + /// Calls {handle_close} when dynamically unlinked. + virtual int fini (void); + + /// Default version returns address info in {buf}. + virtual int info (ACE_TCHAR **buf, size_t) const; + + // = The following three methods define the {Acceptor}'s strategies + // for creating, accepting, and activating {SVC_HANDLER}'s, + // respectively. + + /** + * Bridge method for creating a {SVC_HANDLER}. The strategy for + * creating a {SVC_HANDLER} are configured into the Acceptor via + * it's {creation_strategy_}. The default is to create a new + * {SVC_HANDLER} if {sh} == 0, else {sh} is unchanged. However, + * subclasses can override this policy to perform {SVC_HANDLER} + * creation in any way that they like (such as creating subclass + * instances of {SVC_HANDLER}, using a singleton, dynamically + * linking the handler, etc.). Returns -1 on failure, else 0. + */ + virtual int make_svc_handler (SVC_HANDLER *&); + + /** + * Bridge method for accepting the new connection into the + * {SVC_HANDLER}. The default behavior delegates to the + * {PEER_ACCEPTOR::accept} in the {Acceptor_Strategy}. + */ + virtual int accept_svc_handler (SVC_HANDLER *svc_handler); + + /** + * Bridge method for activating a {SVC_HANDLER} with the appropriate + * concurrency strategy. The default behavior of this method is to + * activate the {SVC_HANDLER} by calling its {open} method (which + * allows the {SVC_HANDLER} to define its own concurrency strategy). + * However, subclasses can override this strategy to do more + * sophisticated concurrency activations (such as creating the + * {SVC_HANDLER} as an "active object" via multi-threading or + * multi-processing). + */ + virtual int activate_svc_handler (SVC_HANDLER *svc_handler); + + // = Demultiplexing hooks. + /// Perform termination activities when {this} is removed from the + /// {Reactor}. + virtual int handle_close (ACE_HANDLE = ACE_INVALID_HANDLE, + ACE_Reactor_Mask = ACE_Event_Handler::ALL_EVENTS_MASK); + + /// Handle SIGINT. + virtual int handle_signal (int signum, siginfo_t *, ucontext_t *); + + // = These data members are "logically private" but are put in the + // protected part in case subclasses want to access them. + + // = Strategy objects. + + /// Creation strategy for an Acceptor. + CREATION_STRATEGY *creation_strategy_; + + /// true if {Acceptor} created the creation strategy and thus should + /// delete it, else false. + bool delete_creation_strategy_; + + /// Accept strategy for an {Acceptor}. + ACCEPT_STRATEGY *accept_strategy_; + + /// true if {Acceptor} created the accept strategy and thus should delete + /// it, else false. + bool delete_accept_strategy_; + + /// Concurrency strategy for an {Acceptor}. + CONCURRENCY_STRATEGY *concurrency_strategy_; + + /// true if {Acceptor} created the concurrency strategy and thus should + /// delete it, else false. + bool delete_concurrency_strategy_; + + /// Scheduling strategy for an {Acceptor}. + SCHEDULING_STRATEGY *scheduling_strategy_; + + /// true if {Acceptor} created the scheduling strategy and thus should + /// delete it, else false. + bool delete_scheduling_strategy_; + + // = Service information objects. + + /// Name of the service. + ACE_TCHAR *service_name_; + + /// Description of the service. + ACE_TCHAR *service_description_; + + /// Address that the {Strategy_Acceptor} uses to listen for + /// connections. + ACE_PEER_ACCEPTOR_ADDR service_addr_; +}; + +/** + * @class ACE_Oneshot_Acceptor + * + * @brief Generic factory for passively connecting clients and creating + * exactly one service handler (SVC_HANDLER). + * + * This class works similarly to the regular {ACE_Acceptor}, + * with the following differences: + * 1. This class doesn't automagically register {this} with the + * {ACE_Reactor} since it expects to have its {accept} method + * called directly. However, it stashes the {ACE_Reactor} + * pointer away in case it's needed later to finish accepting + * a connection asynchronously. + * 2. The class doesn't need an {ACE_Creation_Strategy} (since + * the user supplies the SVC_HANDLER) or an + * {ACE_Accept_Strategy} (since this class only accepts one + * connection and then removes all traces of itself from the + * {ACE_Reactor} if it was registered for asynchronous + * accepts). + */ +template +class ACE_Oneshot_Acceptor : public ACE_Service_Object +{ +public: + + // Useful STL-style traits. + typedef ACE_PEER_ACCEPTOR_ADDR addr_type; + typedef ACE_PEER_ACCEPTOR acceptor_type; + typedef SVC_HANDLER handler_type; + typedef typename SVC_HANDLER::stream_type stream_type; + + /// Constructor. + ACE_Oneshot_Acceptor (void); + + /** + * Initialize the appropriate strategies for concurrency and then + * open the {peer_acceptor} at the designated {local_addr}. Note + * that unlike the {ACE_Acceptor} and {ACE_Strategy_Acceptor}, this + * method does NOT register {this} acceptor with the {reactor} at + * this point -- it just stashes the {reactor} away in case it's + * needed later. + */ + ACE_Oneshot_Acceptor (const ACE_PEER_ACCEPTOR_ADDR &local_addr, + ACE_Reactor *reactor = ACE_Reactor::instance (), + ACE_Concurrency_Strategy * = 0); + + /** + * Initialize the appropriate strategies for concurrency and then + * open the {peer_acceptor} at the designated {local_addr}. Note + * that unlike the {ACE_Acceptor} and {ACE_Strategy_Acceptor}, this + * method does NOT register {this} acceptor with the {reactor} at + * this point -- it just stashes the {reactor} away in case it's + * needed later. + */ + int open (const ACE_PEER_ACCEPTOR_ADDR &, + ACE_Reactor *reactor = ACE_Reactor::instance (), + ACE_Concurrency_Strategy * = 0); + + /// Close down the {Oneshot_Acceptor}. + virtual ~ACE_Oneshot_Acceptor (void); + + // = Explicit factory operation. + /// Create a {SVC_HANDLER}, accept the connection into the + /// {SVC_HANDLER}, and activate the {SVC_HANDLER}. + virtual int accept (SVC_HANDLER * = 0, + ACE_PEER_ACCEPTOR_ADDR *remote_addr = 0, + const ACE_Synch_Options &synch_options = ACE_Synch_Options::defaults, + int restart = 1, + int reset_new_handle = 0); + + /// Cancel a oneshot acceptor that was started asynchronously. + virtual int cancel (void); + + /// Return the underlying {PEER_ACCEPTOR} object. + virtual operator ACE_PEER_ACCEPTOR &() const; + + /// Return the underlying {PEER_ACCEPTOR} object. + virtual ACE_PEER_ACCEPTOR &acceptor (void) const; + + /// Close down the {Oneshot_Acceptor}. + virtual int close (void); + + /// Dump the state of an object. + void dump (void) const; + + /// Declare the dynamic allocation hooks. + ACE_ALLOC_HOOK_DECLARE; + +protected: + /** + * Bridge method for activating a {svc_handler} with the appropriate + * concurrency strategy. Default behavior is to activate the + * {SVC_HANDLER} as a "passive object." However, subclasses can + * override this strategy to do more sophisticated concurrency + * activations (such as creating the {SVC_HANDLER} as an "active + * object" via multi-threading or multi-processing). + */ + virtual int activate_svc_handler (SVC_HANDLER *svc_handler); + + /// Factors out the code shared between the {accept} and + /// {handle_input} methods. + int shared_accept (SVC_HANDLER *svc_handler, + ACE_PEER_ACCEPTOR_ADDR *remote_addr, + ACE_Time_Value *timeout, + int restart, + int reset_new_handle); + + // = Demultiplexing hooks. + /// Returns the listening acceptor's {ACE_HANDLE}. + virtual ACE_HANDLE get_handle (void) const; + + /// Perform termination activities when {this} is removed from the + /// {reactor}. + virtual int handle_close (ACE_HANDLE = ACE_INVALID_HANDLE, + ACE_Reactor_Mask = ACE_Event_Handler::ALL_EVENTS_MASK); + + /// Accept one connection from a client and activates the + /// SVC_HANDLER. + virtual int handle_input (ACE_HANDLE); + + /// Called when an acceptor times out... + virtual int handle_timeout (const ACE_Time_Value &tv, + const void *arg); + + // = Dynamic linking hooks. + /// Default version does no work and returns -1. Must be overloaded + /// by application developer to do anything meaningful. + virtual int init (int argc, ACE_TCHAR *argv[]); + + /// Default version does no work and returns -1. Must be overloaded + /// by application developer to do anything meaningful. + virtual int fini (void); + + /// Default version returns address info in {buf}. + virtual int info (ACE_TCHAR **, size_t) const; + + // = Service management hooks. + /// Default version does no work and returns -1. Must be overloaded + /// by application developer to do anything meaningful. + virtual int suspend (void); + + /// Default version does no work and returns -1. Must be overloaded + /// by application developer to do anything meaningful. + virtual int resume (void); + +private: + /** + * Insert ourselves into the {ACE_Reactor} so that we can continue + * accepting this connection asynchronously. This method should NOT + * be called by developers directly. + */ + int register_handler (SVC_HANDLER *svc_handler, + const ACE_Synch_Options &options, + int restart); + + /// Hold the svc_handler_ across asynchrony boundaries. + SVC_HANDLER *svc_handler_; + + /// Hold the restart flag across asynchrony boundaries. + int restart_; + + /// Factory that establishes connections passively. + ACE_PEER_ACCEPTOR peer_acceptor_; + + /// Concurrency strategy for an Acceptor. + ACE_Concurrency_Strategy *concurrency_strategy_; + + /// true if Acceptor created the concurrency strategy and thus should + /// delete it, else false. + bool delete_concurrency_strategy_; +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) +#include "ace/Acceptor.cpp" +#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ + +#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) +#pragma implementation ("Acceptor.cpp") +#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ + +#include /**/ "ace/post.h" + +#endif /* ACE_ACCEPTOR_H */ diff --git a/dep/ACE_wrappers/ace/Activation_Queue.cpp b/dep/ACE_wrappers/ace/Activation_Queue.cpp new file mode 100644 index 00000000000..f18ada06eb1 --- /dev/null +++ b/dep/ACE_wrappers/ace/Activation_Queue.cpp @@ -0,0 +1,138 @@ +#include "ace/Activation_Queue.h" + +#if !defined (__ACE_INLINE__) +#include "ace/Activation_Queue.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/Log_Msg.h" +#include "ace/Method_Request.h" +#include "ace/Malloc_Base.h" +#include "ace/Time_Value.h" + +ACE_RCSID (ace, + Activation_Queue, + "$Id: Activation_Queue.cpp 80826 2008-03-04 14:51:23Z wotte $") + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +void +ACE_Activation_Queue::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("delete_queue_ = %d\n"), + this->delete_queue_)); + ACE_DEBUG ((LM_INFO, ACE_TEXT ("queue_: \n"))); + if (this->queue_) + this->queue_->dump(); + else + //FUZZ: disable check_for_NULL + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(NULL)\n"))); + //FUZZ: enable check_for_NULL + + ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); +#endif /* ACE_HAS_DUMP */ +} + +ACE_Activation_Queue::ACE_Activation_Queue (ACE_Message_Queue *new_queue, + ACE_Allocator *alloc, + ACE_Allocator *db_alloc) + : delete_queue_ (false) + , allocator_(alloc) + , data_block_allocator_(db_alloc) +{ + if (this->allocator_ == 0) + this->allocator_ = ACE_Allocator::instance (); + + if (new_queue) + this->queue_ = new_queue; + else + { + ACE_NEW (this->queue_, + ACE_Message_Queue); + this->delete_queue_ = true; + } +} + +void +ACE_Activation_Queue::queue (ACE_Message_Queue *q) +{ + // Destroy the internal queue if one exist. + if (this->delete_queue_) + { + // Destroy the current queue. + delete this->queue_; + + // Set the flag to false. NOTE that the delete_queue_ flag is a + // flag used to only indicate whether or not if an internal + // ACE_Message_Queue has been created, therefore, it will not + // affect the user if the user decided to replace the queue with + // their own queue no matter how many time they call on this + // function. + this->delete_queue_ = false; + } + + queue_ = q; +} + +ACE_Activation_Queue::~ACE_Activation_Queue (void) +{ + if (this->delete_queue_) + delete this->queue_; +} + +ACE_Method_Request * +ACE_Activation_Queue::dequeue (ACE_Time_Value *tv) +{ + ACE_Message_Block *mb = 0; + + // Dequeue the message. + if (this->queue_->dequeue_head (mb, tv) != -1) + { + // Get the next . + ACE_Method_Request *mr = + reinterpret_cast (mb->base ()); + // Delete the message block. + mb->release (); + return mr; + } + else + return 0; +} + +int +ACE_Activation_Queue::enqueue (ACE_Method_Request *mr, + ACE_Time_Value *tv) +{ + ACE_Message_Block *mb = 0; + + // We pass sizeof (*mr) here so that flow control will work + // correctly. Since we also pass note that no unnecessary + // memory is actually allocated -- just the size field is set. + ACE_NEW_MALLOC_RETURN (mb, + static_cast (this->allocator_->malloc (sizeof (ACE_Message_Block))), + ACE_Message_Block (sizeof (*mr), // size + ACE_Message_Block::MB_DATA, // type + 0, // cont + (char *) mr, // data + 0, // allocator + 0, // locking strategy + mr->priority (), // priority + ACE_Time_Value::zero, // execution time + ACE_Time_Value::max_time, // absolute time of deadline + this->data_block_allocator_, // data_block allocator + this->allocator_), // message_block allocator + -1); + + // Enqueue in priority order. + int const result = this->queue_->enqueue_prio (mb, tv); + + // Free ACE_Message_Block if enqueue_prio failed. + if (result == -1) + ACE_DES_FREE (mb, this->allocator_->free, ACE_Message_Block); + + return result; +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Activation_Queue.h b/dep/ACE_wrappers/ace/Activation_Queue.h new file mode 100644 index 00000000000..454640474c1 --- /dev/null +++ b/dep/ACE_wrappers/ace/Activation_Queue.h @@ -0,0 +1,173 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Activation_Queue.h + * + * $Id: Activation_Queue.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Andres Kruse + * @author Douglas C. Schmidt + */ +//============================================================================= + +#ifndef ACE_ACTIVATION_QUEUE_H +#define ACE_ACTIVATION_QUEUE_H + +#include /**/ "ace/pre.h" + +#include /**/ "ace/ACE_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/Message_Queue.h" +#include "ace/Condition_Thread_Mutex.h" + +/// Define to be compatible with the terminology in the POSA2 book! +#define ACE_Activation_List ACE_Activation_Queue + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +class ACE_Method_Request; + +/** + * @class ACE_Activation_Queue + * + * @brief Reifies a method into a request. Subclasses typically + * represent necessary state and behavior. + * + * Maintains a priority-ordered queue of ACE_Method_Request objects. + * A scheduler class (often derived from ACE_Task) subsequently removes + * each method request and invokes its @c call() method. + * + * This class is discussed in depth in the Active Object chapter + * of POSA2. In that book, it is referred to as an Activation List. + * + * @sa ACE_Method_Request + */ +class ACE_Export ACE_Activation_Queue +{ +public: + // = Initialization and termination methods. + /// Constructor. + /** + * Initializes a new activation queue. + * + * @param new_queue The activation queue uses an ACE_Message_Queue to + * queue and order the method requests. If this argument + * is 0, a new ACE_Message_Queue is created for this + * object's use and will be deleted when this object is + * destroyed. If a non-zero pointer is supplied, the + * passed object will be used and will not be deleted when + * this object is destroyed. If an ACE_Task is being created + * to act as the scheduler, for instance, its + * ACE_Message_Queue pointer can be passed to this object. + * @param alloc Optional, the allocator to use when allocating + * ACE_Message_Block instances that wrap the method requests + * queued to this activation queue. Defaults to + * ACE_Allocator::instance(). + * @param db_alloc Optional, the allocator to use when allocating + * data blocks for the ACE_Message_Block instances that + * wrap the method requests queued to this activation queue. + * Defaults to ACE_Allocator::instance(). + */ + ACE_Activation_Queue (ACE_Message_Queue *new_queue = 0, + ACE_Allocator *alloc = 0, + ACE_Allocator *db_alloc = 0); + + /// Destructor. + virtual ~ACE_Activation_Queue (void); + + // = Activate Queue operations. + + /// Dequeue the next available ACE_Method_Request. + /** + * @param tv If 0, the method will block until a method request is + * available, else will wait until the absolute time specified + * in the referenced ACE_Time_Value. This method will return, + * earlier, however, if queue is closed, deactivated, or when + * a signal occurs. + * + * @retval Pointer to the dequeued ACE_Method_Request object. + * @retval 0 an error occurs; errno contains further information. If + * the specified timeout elapses, errno will be @c EWOULDBLOCK. + */ + ACE_Method_Request *dequeue (ACE_Time_Value *tv = 0); + + /// Enqueue the ACE_Method_Request in priority order. + /** + * The priority of the method request is obtained via the @c priority() + * method of the queued method request. Priority ordering is determined + * by the ACE_Message_Queue class; 0 is the lowest priority. + * + * @param new_method_request Pointer to the ACE_Method_Request object to + * queue. This object's @c priority() method is called to obtain + * the priority. + * @param tv If 0, the method will block until the method request can + * be queued, else will wait until the absolute time specified + * in the referenced ACE_Time_Value. This method will return, + * earlier, however, if queue is closed, deactivated, or when + * a signal occurs. + * + * @retval >0 The number of method requests on the queue after adding + * the specified request. + * @retval -1 if an error occurs; errno contains further information. If + * the specified timeout elapses, errno will be @c EWOULDBLOCK. + */ + int enqueue (ACE_Method_Request *new_method_request, ACE_Time_Value *tv = 0); + + /// Get the current number of method objects in the queue. + size_t method_count (void) const; + + /// Returns 1 if the queue is empty, 0 otherwise. + int is_empty (void) const; + + /// Returns 1 if the queue is full, 0 otherwise. + int is_full (void) const; + + /// Dump the state of an request. + void dump (void) const; + + /// Get a pointer to the underlying queue. + ACE_Message_Queue *queue (void) const; + + /// Set the pointer to the underlying queue. + void queue (ACE_Message_Queue *q); + + /// Declare the dynamic allocation hooks. + ACE_ALLOC_HOOK_DECLARE; + +private: + + // = Prevent copying and assignment. + ACE_Activation_Queue (const ACE_Activation_Queue &); + void operator= (const ACE_Activation_Queue &); + +protected: + + /// Stores the Method_Requests. + ACE_Message_Queue *queue_; + + /// Keeps track of whether we need to delete the queue. + bool delete_queue_; + +private: + + /// Allocation strategy of the queue. + ACE_Allocator *allocator_; + + /// Allocation strategy of the message blocks. + ACE_Allocator *data_block_allocator_; + +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +#include "ace/Activation_Queue.inl" +#endif /* __ACE_INLINE__ */ + +#include /**/ "ace/post.h" +#endif /* ACE_ACTIVATION_QUEUE_H */ diff --git a/dep/ACE_wrappers/ace/Activation_Queue.inl b/dep/ACE_wrappers/ace/Activation_Queue.inl new file mode 100644 index 00000000000..4c0ffc049d3 --- /dev/null +++ b/dep/ACE_wrappers/ace/Activation_Queue.inl @@ -0,0 +1,31 @@ +// -*- C++ -*- +// +// $Id: Activation_Queue.inl 80826 2008-03-04 14:51:23Z wotte $ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_INLINE size_t +ACE_Activation_Queue::method_count (void) const +{ + return queue_->message_count (); +} + +ACE_INLINE int +ACE_Activation_Queue::is_full (void) const +{ + return queue_->is_full (); +} + +ACE_INLINE int +ACE_Activation_Queue::is_empty (void) const +{ + return queue_->is_empty (); +} + +ACE_INLINE ACE_Message_Queue * +ACE_Activation_Queue::queue (void) const +{ + return queue_; +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Active_Map_Manager.cpp b/dep/ACE_wrappers/ace/Active_Map_Manager.cpp new file mode 100644 index 00000000000..6ec891b5d10 --- /dev/null +++ b/dep/ACE_wrappers/ace/Active_Map_Manager.cpp @@ -0,0 +1,9 @@ +// $Id: Active_Map_Manager.cpp 80826 2008-03-04 14:51:23Z wotte $ + +#include "ace/Active_Map_Manager.h" + +ACE_RCSID(ace, Active_Map_Manager, "$Id: Active_Map_Manager.cpp 80826 2008-03-04 14:51:23Z wotte $") + +#if !defined (__ACE_INLINE__) +#include "ace/Active_Map_Manager.inl" +#endif /* __ACE_INLINE__ */ diff --git a/dep/ACE_wrappers/ace/Active_Map_Manager.h b/dep/ACE_wrappers/ace/Active_Map_Manager.h new file mode 100644 index 00000000000..d1558b1463b --- /dev/null +++ b/dep/ACE_wrappers/ace/Active_Map_Manager.h @@ -0,0 +1,116 @@ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file Active_Map_Manager.h + * + * $Id: Active_Map_Manager.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Irfan Pyarali + */ +//============================================================================= + + +#ifndef ACE_ACTIVE_MAP_MANAGER_H +#define ACE_ACTIVE_MAP_MANAGER_H +#include /**/ "ace/pre.h" + +#include /**/ "ace/ACE_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/Basic_Types.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +/** + * @class ACE_Active_Map_Manager_Key + * + * @brief Key used in the Active Object Map. + * + * This key keeps information of the index and the generation + * count of the slot it represents. Since the index information + * is part of the key, lookups are super fast and predictable, + */ +class ACE_Export ACE_Active_Map_Manager_Key +{ +public: + /// Default constructor. + ACE_Active_Map_Manager_Key (void); + + /** + * Constructor given the @a slot_index and @a slot_generation number. + * This is useful once the user has somehow recovered the + * @a slot_index and @a slot_generation number from the client. + */ + ACE_Active_Map_Manager_Key (ACE_UINT32 slot_index, + ACE_UINT32 slot_generation); + + /// Get the slot_index. + ACE_UINT32 slot_index (void) const; + + /// Set the slot_index. + void slot_index (ACE_UINT32 i); + + /// Get the slot_generation number. + ACE_UINT32 slot_generation (void) const; + + /// Set the slot_generation number. + void slot_generation (ACE_UINT32 g); + + /// Size required to store information about active key. + static size_t size (void); + + /// Recover state of active key from @a data. User must make sure + /// that @a data encoded using the encode() method. + void decode (const void *data); + + /// Encode state of the active key into @a data. @a data must be as + /// big as the value returned from . + void encode (void *data) const; + + /// Compare keys. + bool operator== (const ACE_Active_Map_Manager_Key &rhs) const; + bool operator!= (const ACE_Active_Map_Manager_Key &rhs) const; + + // = This really should be protected but because of template + // friends, they are not. + + /// Increment the number. + void increment_slot_generation_count (void); + +private: + + /** + * @brief Data for the Active Object Map Key. + * + * This separate structure makes it easier to manage copying + * the index and the generation to and from the user buffer. + * + */ + struct key_data + { + /// Slot index in the active map. + ACE_UINT32 slot_index_; + + /// Slot generation number of slot in the active map. + ACE_UINT32 slot_generation_; + }; + + /// Data for the Active Object Map Key. + key_data key_data_; +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +#include "ace/Active_Map_Manager.inl" +#endif /* __ACE_INLINE__ */ + +// Include the templates here. +#include "ace/Active_Map_Manager_T.h" + +#include /**/ "ace/post.h" +#endif /* ACE_ACTIVE_MAP_MANAGER_H */ diff --git a/dep/ACE_wrappers/ace/Active_Map_Manager.inl b/dep/ACE_wrappers/ace/Active_Map_Manager.inl new file mode 100644 index 00000000000..df90ada6a00 --- /dev/null +++ b/dep/ACE_wrappers/ace/Active_Map_Manager.inl @@ -0,0 +1,95 @@ +// -*- C++ -*- +// +// $Id: Active_Map_Manager.inl 80826 2008-03-04 14:51:23Z wotte $ + +#include "ace/OS_NS_string.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_INLINE +ACE_Active_Map_Manager_Key::ACE_Active_Map_Manager_Key (void) +{ + // If you change ~0, please change ACE_Map_Manager::free_list_id() + // accordingly. + this->key_data_.slot_index_ = (ACE_UINT32) ~0; + this->key_data_.slot_generation_ = 0; +} + +ACE_INLINE +ACE_Active_Map_Manager_Key::ACE_Active_Map_Manager_Key (ACE_UINT32 slot_index, + ACE_UINT32 slot_generation) +{ + this->key_data_.slot_index_ = slot_index; + this->key_data_.slot_generation_ = slot_generation; +} + +ACE_INLINE ACE_UINT32 +ACE_Active_Map_Manager_Key::slot_index (void) const +{ + return this->key_data_.slot_index_; +} + +ACE_INLINE ACE_UINT32 +ACE_Active_Map_Manager_Key::slot_generation (void) const +{ + return this->key_data_.slot_generation_; +} + +ACE_INLINE bool +ACE_Active_Map_Manager_Key::operator== (const ACE_Active_Map_Manager_Key &rhs) const +{ + return + this->key_data_.slot_index_ == rhs.key_data_.slot_index_ && + this->key_data_.slot_generation_ == rhs.key_data_.slot_generation_; +} + +ACE_INLINE bool +ACE_Active_Map_Manager_Key::operator!= (const ACE_Active_Map_Manager_Key &rhs) const +{ + return !this->operator== (rhs); +} + +ACE_INLINE void +ACE_Active_Map_Manager_Key::slot_index (ACE_UINT32 i) +{ + this->key_data_.slot_index_ = i; +} + +ACE_INLINE void +ACE_Active_Map_Manager_Key::slot_generation (ACE_UINT32 g) +{ + this->key_data_.slot_generation_ = g; +} + +ACE_INLINE void +ACE_Active_Map_Manager_Key::increment_slot_generation_count (void) +{ + ++this->key_data_.slot_generation_; +} + +/* static */ +ACE_INLINE size_t +ACE_Active_Map_Manager_Key::size (void) +{ + return sizeof (ACE_UINT32) + sizeof (ACE_UINT32); +} + +ACE_INLINE void +ACE_Active_Map_Manager_Key::decode (const void *data) +{ + // Copy the information from the user buffer into the key. + ACE_OS::memcpy (&this->key_data_, + data, + sizeof this->key_data_); +} + +ACE_INLINE void +ACE_Active_Map_Manager_Key::encode (void *data) const +{ + // Copy the key data to the user buffer. + ACE_OS::memcpy (data, + &this->key_data_, + sizeof this->key_data_); +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Active_Map_Manager_T.cpp b/dep/ACE_wrappers/ace/Active_Map_Manager_T.cpp new file mode 100644 index 00000000000..732cc295117 --- /dev/null +++ b/dep/ACE_wrappers/ace/Active_Map_Manager_T.cpp @@ -0,0 +1,22 @@ +// $Id: Active_Map_Manager_T.cpp 80826 2008-03-04 14:51:23Z wotte $ + +#ifndef ACE_ACTIVE_MAP_MANAGER_T_CPP +#define ACE_ACTIVE_MAP_MANAGER_T_CPP + +#include "ace/Active_Map_Manager_T.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#if !defined (__ACE_INLINE__) +#include "ace/Active_Map_Manager_T.inl" +#endif /* __ACE_INLINE__ */ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_ALLOC_HOOK_DEFINE(ACE_Active_Map_Manager) + +ACE_END_VERSIONED_NAMESPACE_DECL + +#endif /* ACE_ACTIVE_MAP_MANAGER_T_CPP */ diff --git a/dep/ACE_wrappers/ace/Active_Map_Manager_T.h b/dep/ACE_wrappers/ace/Active_Map_Manager_T.h new file mode 100644 index 00000000000..f63d4353723 --- /dev/null +++ b/dep/ACE_wrappers/ace/Active_Map_Manager_T.h @@ -0,0 +1,211 @@ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file Active_Map_Manager_T.h + * + * $Id: Active_Map_Manager_T.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Irfan Pyarali + */ +//============================================================================= + + +#ifndef ACE_ACTIVE_MAP_MANAGER_T_H +#define ACE_ACTIVE_MAP_MANAGER_T_H +#include /**/ "ace/pre.h" + +#include "ace/Map_Manager.h" +#include "ace/Active_Map_Manager.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/Null_Mutex.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +/** + * @class ACE_Active_Map_Manager + * + * @brief Define a map abstraction that associates system generated + * keys with user specified values. + * + * Since the key is system generated, searches are very fast and + * take a constant amount of time. + */ +template +class ACE_Active_Map_Manager : public ACE_Map_Manager +{ +public: + + // = Traits. + typedef ACE_Active_Map_Manager_Key key_type; + typedef T mapped_type; + + typedef ACE_Map_Entry ENTRY; + typedef ACE_Map_Iterator ITERATOR; + typedef ACE_Map_Reverse_Iterator REVERSE_ITERATOR; + + typedef ENTRY entry; + typedef ITERATOR iterator; + typedef REVERSE_ITERATOR reverse_iterator; + + // = Initialization and termination methods. + /// Initialize a with the ACE_DEFAULT_MAP_SIZE. + ACE_Active_Map_Manager (ACE_Allocator *alloc = 0); + + /// Initialize a with @a size entries. + ACE_Active_Map_Manager (size_t size, + ACE_Allocator *alloc = 0); + + /// Close down a and release dynamically + /// allocated resources. + ~ACE_Active_Map_Manager (void); + + /// Initialize a with size @a length. + int open (size_t length = ACE_DEFAULT_MAP_SIZE, + ACE_Allocator *alloc = 0); + + /// Close down a and release dynamically + /// allocated resources. + int close (void); + + /// Add @a value to the map, and the corresponding key produced by the + /// Active_Map_Manager is returned through @a key. + int bind (const T &value, + ACE_Active_Map_Manager_Key &key); + + /// Add @a value to the map. The user does not care about the + /// corresponding key produced by the Active_Map_Manager. + int bind (const T &value); + + /** + * Reserves a slot in the internal structure and returns the key and + * a pointer to the value. User should place their @a value into + * <*internal_value>. This method is useful in reducing the number + * of copies required in some cases. Note that is + * only a temporary pointer and will change when the map resizes. + * Therefore, the user should use the pointer immediately and not + * hold on to it. + */ + int bind (ACE_Active_Map_Manager_Key &key, + T *&internal_value); + + /// Reassociate @a key with @a value. The function fails if @a key is + /// not in the map. + int rebind (const ACE_Active_Map_Manager_Key &key, + const T &value); + + /** + * Reassociate @a key with @a value, storing the old value into the + * "out" parameter @a old_value. The function fails if @a key is not + * in the map. + */ + int rebind (const ACE_Active_Map_Manager_Key &key, + const T &value, + T &old_value); + + /** + * Reassociate @a key with @a value, storing the old key and value + * into the "out" parameter @a old_key and @a old_value. The function + * fails if @a key is not in the map. + */ + int rebind (const ACE_Active_Map_Manager_Key &key, + const T &value, + ACE_Active_Map_Manager_Key &old_key, + T &old_value); + + /// Locate @a value associated with @a key. + int find (const ACE_Active_Map_Manager_Key &key, + T &value) const; + + /// Is @a key in the map? + int find (const ACE_Active_Map_Manager_Key &key) const; + + /** + * Locate @a value associated with @a key. The value is returned via + * and hence a copy is saved. Note that + * is only a temporary pointer and will change when + * the map resizes. Therefore, the user should use the pointer + * immediately and not hold on to it. + */ + int find (const ACE_Active_Map_Manager_Key &key, + T *&internal_value) const; + + // Creates a key. User should place their @a value into + // <*internal_value>. This method is useful in reducing the number + // of copies required in some cases. + + /// Remove @a key from the map. + int unbind (const ACE_Active_Map_Manager_Key &key); + + /// Remove @a key from the map, and return the @a value associated with + /// @a key. + int unbind (const ACE_Active_Map_Manager_Key &key, + T &value); + + /** + * Locate @a value associated with @a key. The value is returned via + * and hence a copy is saved. Note that + * is only a temporary pointer and will change when + * the map resizes or when this slot is reused. Therefore, the user + * should use the pointer immediately and not hold on to it. + */ + int unbind (const ACE_Active_Map_Manager_Key &key, + T *&internal_value); + + /// Return the current size of the map. + size_t current_size (void) const; + + /// Return the total size of the map. + size_t total_size (void) const; + + /// Returns a key that cannot be found in the map. + static const ACE_Active_Map_Manager_Key npos (void); + + /// Dump the state of an object. + void dump (void) const; + + // = STL styled iterator factory functions. + + /// Return forward iterator. + ACE_Map_Iterator begin (void); + ACE_Map_Iterator end (void); + + /// Return reverse iterator. + ACE_Map_Reverse_Iterator rbegin (void); + ACE_Map_Reverse_Iterator rend (void); + + /// Declare the dynamic allocation hooks. + ACE_ALLOC_HOOK_DECLARE; + +protected: + + /// Private base class + typedef ACE_Map_Manager ACE_AMM_BASE; + +private: + + // = Disallow these operations. + ACE_UNIMPLEMENTED_FUNC (void operator= (const ACE_Active_Map_Manager &)) + ACE_UNIMPLEMENTED_FUNC (ACE_Active_Map_Manager (const ACE_Active_Map_Manager &)) +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +#include "ace/Active_Map_Manager_T.inl" +#endif /* __ACE_INLINE__ */ + +#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) +#include "ace/Active_Map_Manager_T.cpp" +#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ + +#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) +#pragma implementation ("Active_Map_Manager_T.cpp") +#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ + +#include /**/ "ace/post.h" +#endif /* ACE_ACTIVE_MAP_MANAGER_T_H */ diff --git a/dep/ACE_wrappers/ace/Active_Map_Manager_T.inl b/dep/ACE_wrappers/ace/Active_Map_Manager_T.inl new file mode 100644 index 00000000000..647b55ebd56 --- /dev/null +++ b/dep/ACE_wrappers/ace/Active_Map_Manager_T.inl @@ -0,0 +1,311 @@ +// -*- C++ -*- +// +// $Id: Active_Map_Manager_T.inl 80826 2008-03-04 14:51:23Z wotte $ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +template ACE_INLINE int +ACE_Active_Map_Manager::bind (ACE_Active_Map_Manager_Key &key, + T *&internal_value) +{ + ACE_UINT32 slot_index; + int result = this->next_free (slot_index); + + if (result == 0) + { + // Move from free list to occupied list + this->move_from_free_list_to_occupied_list (slot_index); + + // Reset the key. + this->search_structure_[slot_index].ext_id_.increment_slot_generation_count (); + this->search_structure_[slot_index].ext_id_.slot_index (slot_index); + + // Copy the key for the user. + key = this->search_structure_[slot_index].ext_id_; + + // This is where the user should place the value. + internal_value = &this->search_structure_[slot_index].int_id_; + + // Update the current size. + ++this->cur_size_; + } + + return result; +} + +template ACE_INLINE int +ACE_Active_Map_Manager::bind (const T &value, + ACE_Active_Map_Manager_Key &key) +{ + T *internal_value = 0; + int result = this->bind (key, + internal_value); + + if (result == 0) + { + // Store new value. + *internal_value = value; + } + + return result; +} + +template ACE_INLINE int +ACE_Active_Map_Manager::bind (const T &value) +{ + ACE_Active_Map_Manager_Key key; + return this->bind (value, key); +} + +template ACE_INLINE int +ACE_Active_Map_Manager::find (const ACE_Active_Map_Manager_Key &key, + T *&internal_value) const +{ + ACE_UINT32 slot_index = key.slot_index (); + ACE_UINT32 slot_generation = key.slot_generation (); + + if (slot_index > this->total_size_ || +#if defined (ACE_HAS_LAZY_MAP_MANAGER) + this->search_structure_[slot_index].free_ || +#endif /* ACE_HAS_LAZY_MAP_MANAGER */ + this->search_structure_[slot_index].ext_id_.slot_generation () != slot_generation || + this->search_structure_[slot_index].ext_id_.slot_index () == + (ACE_UINT32)this->free_list_id ()) + { + return -1; + } + else + { + // This is where the user value is. + internal_value = &this->search_structure_[slot_index].int_id_; + } + + return 0; +} + +template ACE_INLINE int +ACE_Active_Map_Manager::find (const ACE_Active_Map_Manager_Key &key) const +{ + T *internal_value = 0; + return this->find (key, + internal_value); +} + +template ACE_INLINE int +ACE_Active_Map_Manager::find (const ACE_Active_Map_Manager_Key &key, + T &value) const +{ + T *internal_value = 0; + int result = this->find (key, + internal_value); + + if (result == 0) + value = *internal_value; + + return result; +} + +template ACE_INLINE int +ACE_Active_Map_Manager::rebind (const ACE_Active_Map_Manager_Key &key, + const T &value) +{ + int result = this->find (key); + + if (result == 0) + { + // Store new value. + this->search_structure_[key.slot_index ()].int_id_ = value; + } + + return result; +} + +template ACE_INLINE int +ACE_Active_Map_Manager::rebind (const ACE_Active_Map_Manager_Key &key, + const T &value, + T &old_value) +{ + int result = this->find (key); + + if (result == 0) + { + // Copy old value. + old_value = this->search_structure_[key.slot_index ()].int_id_; + + // Store new value. + this->search_structure_[key.slot_index ()].int_id_ = value; + } + + return result; +} + +template ACE_INLINE int +ACE_Active_Map_Manager::rebind (const ACE_Active_Map_Manager_Key &key, + const T &value, + ACE_Active_Map_Manager_Key &old_key, + T &old_value) +{ + int result = this->find (key); + + if (result == 0) + { + // Copy old key. + old_key = this->search_structure_[key.slot_index ()].ext_id_; + + // Copy old value. + old_value = this->search_structure_[key.slot_index ()].int_id_; + + // Store new value. + this->search_structure_[key.slot_index ()].int_id_ = value; + } + + return result; +} + +template ACE_INLINE int +ACE_Active_Map_Manager::unbind (const ACE_Active_Map_Manager_Key &key, + T *&internal_value) +{ + int result = this->find (key, + internal_value); + + if (result == 0) + { + ACE_UINT32 slot_index = key.slot_index (); + +#if defined (ACE_HAS_LAZY_MAP_MANAGER) + + // + // In the case of lazy map managers, the movement of free slots + // from the occupied list to the free list is delayed until we + // run out of free slots in the free list. + // + + this->search_structure_[slot_index].free_ = 1; + +#else + + // Move from occupied list to free list. + this->move_from_occupied_list_to_free_list (slot_index); + +#endif /* ACE_HAS_LAZY_MAP_MANAGER */ + + // Reset the slot_index. This will tell us that this entry is free. + this->search_structure_[slot_index].ext_id_.slot_index (this->free_list_id ()); + + // Update the current size. + --this->cur_size_; + } + + return result; +} + +template ACE_INLINE int +ACE_Active_Map_Manager::unbind (const ACE_Active_Map_Manager_Key &key, + T &value) +{ + T *internal_value; + int result = this->unbind (key, + internal_value); + + if (result == 0) + { + // Copy old value. + value = *internal_value; + } + + return result; +} + +template ACE_INLINE int +ACE_Active_Map_Manager::unbind (const ACE_Active_Map_Manager_Key &key) +{ + T *internal_value; + return this->unbind (key, + internal_value); +} + +template ACE_INLINE +ACE_Active_Map_Manager::ACE_Active_Map_Manager (ACE_Allocator *alloc) + : ACE_AMM_BASE (alloc) +{ +} + +template ACE_INLINE +ACE_Active_Map_Manager::ACE_Active_Map_Manager (size_t size, + ACE_Allocator *alloc) + : ACE_AMM_BASE (size, + alloc) +{ +} + +template ACE_INLINE +ACE_Active_Map_Manager::~ACE_Active_Map_Manager (void) +{ +} + +template ACE_INLINE int +ACE_Active_Map_Manager::open (size_t length, + ACE_Allocator *alloc) +{ + return ACE_AMM_BASE::open (length, alloc); +} + +template ACE_INLINE int +ACE_Active_Map_Manager::close (void) +{ + return ACE_AMM_BASE::close (); +} + +template ACE_INLINE size_t +ACE_Active_Map_Manager::current_size (void) const +{ + return ACE_AMM_BASE::current_size (); +} + +template ACE_INLINE size_t +ACE_Active_Map_Manager::total_size (void) const +{ + return ACE_AMM_BASE::total_size (); +} + +/* static */ +template ACE_INLINE const ACE_Active_Map_Manager_Key +ACE_Active_Map_Manager::npos (void) +{ + return ACE_Active_Map_Manager_Key (~0, ~0); +} + +template ACE_INLINE void +ACE_Active_Map_Manager::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + ACE_AMM_BASE::dump (); +#endif /* ACE_HAS_DUMP */ +} + +template ACE_Map_Iterator +ACE_Active_Map_Manager::begin (void) +{ + return ACE_AMM_BASE::begin (); +} + +template ACE_INLINE ACE_Map_Iterator +ACE_Active_Map_Manager::end (void) +{ + return ACE_AMM_BASE::end (); +} + +template ACE_INLINE ACE_Map_Reverse_Iterator +ACE_Active_Map_Manager::rbegin (void) +{ + return ACE_AMM_BASE::rbegin (); +} + +template ACE_INLINE ACE_Map_Reverse_Iterator +ACE_Active_Map_Manager::rend (void) +{ + return ACE_AMM_BASE::rend (); +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Addr.cpp b/dep/ACE_wrappers/ace/Addr.cpp new file mode 100644 index 00000000000..fb338f9ac17 --- /dev/null +++ b/dep/ACE_wrappers/ace/Addr.cpp @@ -0,0 +1,73 @@ +// $Id: Addr.cpp 80826 2008-03-04 14:51:23Z wotte $ + +#include "ace/Addr.h" + + +ACE_RCSID (ace, + Addr, + "$Id: Addr.cpp 80826 2008-03-04 14:51:23Z wotte $") + + +#if !defined (__ACE_INLINE__) +#include "ace/Addr.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/Log_Msg.h" +#include "ace/os_include/sys/os_socket.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +// Note: this object requires static construction and destruction. +/* static */ +const ACE_Addr ACE_Addr::sap_any (AF_ANY, -1); + +ACE_ALLOC_HOOK_DEFINE(ACE_Addr) + + +// Initializes instance variables. Note that 0 is an unspecified +// protocol family type... + +ACE_Addr::ACE_Addr (int type, int size) : + addr_type_ (type), + addr_size_ (size) +{ +} + +ACE_Addr::~ACE_Addr (void) +{ +} + +void * +ACE_Addr::get_addr (void) const +{ + return 0; +} + +void +ACE_Addr::set_addr (void *, int) +{ +} + +// Initializes instance variables. + +void +ACE_Addr::base_set (int type, int size) +{ + this->addr_type_ = type; + this->addr_size_ = size; +} + +void +ACE_Addr::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + ACE_TRACE ("ACE_Addr::dump"); + + ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("addr_type_ = %d"), this->addr_type_)); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\naddr_size_ = %d"), this->addr_size_)); + ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); +#endif /* ACE_HAS_DUMP */ +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Addr.h b/dep/ACE_wrappers/ace/Addr.h new file mode 100644 index 00000000000..e58ffe2c0f5 --- /dev/null +++ b/dep/ACE_wrappers/ace/Addr.h @@ -0,0 +1,103 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Addr.h + * + * $Id: Addr.h 81030 2008-03-20 12:43:29Z johnnyw $ + * + * @author Douglas C. Schmidt + */ +//============================================================================= + +#ifndef ACE_ADDR_H +#define ACE_ADDR_H + +#include /**/ "ace/pre.h" + +#include /**/ "ace/ACE_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +/** + * @class ACE_Addr + * + * @brief Defines the base class for the "address family independent" + * address format. + */ +class ACE_Export ACE_Addr +{ +public: + // = Initialization and termination methods. + /// Initializes instance variables. + ACE_Addr (int type = -1, int size = -1); + + /// Destructor. + virtual ~ACE_Addr (void); + + // = Get/set the size of the address. + + /// Return the size of the address. + int get_size (void) const; + + /// Sets the size of the address. + void set_size (int size); + + // = Get/set the type of the address. + + /// Get the type of the address. + int get_type (void) const; + + /// Set the type of the address. + void set_type (int type); + + /// Return a pointer to the address. + virtual void *get_addr (void) const; + + /// Set a pointer to the address. + virtual void set_addr (void *, int len); + + // = Equality/inequality tests + /// Check for address equality. + bool operator == (const ACE_Addr &sap) const; + + /// Check for address inequality. + bool operator != (const ACE_Addr &sap) const; + + /// Initializes instance variables. + void base_set (int type, int size); + + /// Wild-card address. + static const ACE_Addr sap_any; + + /// Returns a hash value. This should be overwritten by a subclass + /// that can produce a better hash value. + virtual unsigned long hash (void) const; + + /// Dump the state of an object. + void dump (void) const; + + /// Declare the dynamic allocation hooks. + ACE_ALLOC_HOOK_DECLARE; + +protected: + /// e.g., AF_UNIX, AF_INET, AF_SPIPE, etc. + int addr_type_; + + /// Number of bytes in the address. + int addr_size_; +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +#include "ace/Addr.inl" +#endif /* __ACE_INLINE__ */ + +#include /**/ "ace/post.h" + +#endif /* ACE_ADDR_H */ diff --git a/dep/ACE_wrappers/ace/Addr.inl b/dep/ACE_wrappers/ace/Addr.inl new file mode 100644 index 00000000000..44fd495a6e9 --- /dev/null +++ b/dep/ACE_wrappers/ace/Addr.inl @@ -0,0 +1,61 @@ +// -*- C++ -*- +// +// $Id: Addr.inl 80826 2008-03-04 14:51:23Z wotte $ + +// Return the address of the address. + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_INLINE bool +ACE_Addr::operator == (const ACE_Addr &sap) const +{ + return (sap.addr_type_ == this->addr_type_ && + sap.addr_size_ == this->addr_size_ ); +} + +ACE_INLINE bool +ACE_Addr::operator != (const ACE_Addr &sap) const +{ + return (sap.addr_type_ != this->addr_type_ || + sap.addr_size_ != this->addr_size_ ); +} + +// Return the size of the address. + +ACE_INLINE int +ACE_Addr::get_size (void) const +{ + return this->addr_size_; +} + +// Sets the size of the address. + +ACE_INLINE void +ACE_Addr::set_size (int size) +{ + this->addr_size_ = size; +} + +// Return the type of the address. + +ACE_INLINE int +ACE_Addr::get_type (void) const +{ + return this->addr_type_; +} + +// Set the type of the address. + +ACE_INLINE void +ACE_Addr::set_type (int type) +{ + this->addr_type_ = type; +} + +ACE_INLINE unsigned long +ACE_Addr::hash (void) const +{ + return 0; +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Arg_Shifter.cpp b/dep/ACE_wrappers/ace/Arg_Shifter.cpp new file mode 100644 index 00000000000..43d5074db9d --- /dev/null +++ b/dep/ACE_wrappers/ace/Arg_Shifter.cpp @@ -0,0 +1,230 @@ +#ifndef ACE_ARG_SHIFTER_T_CPP +#define ACE_ARG_SHIFTER_T_CPP + +#include "ace/Arg_Shifter.h" +#include "ace/OS_NS_string.h" +#include "ace/OS_NS_strings.h" +#include "ace/OS_Errno.h" +#include "ace/OS_Memory.h" + +ACE_RCSID (ace, + Arg_Shifter, + "$Id: Arg_Shifter.cpp 80826 2008-03-04 14:51:23Z wotte $") + + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +template +ACE_Arg_Shifter_T::ACE_Arg_Shifter_T (int& argc, + const CHAR_TYPE** argv, + const CHAR_TYPE** temp) + : argc_ (argc), + total_size_ (argc), + temp_ (temp), + argv_ (argv), + current_index_ (0), + back_ (argc - 1), + front_ (0) +{ + this->init (); +} + +template +ACE_Arg_Shifter_T::ACE_Arg_Shifter_T (int& argc, + CHAR_TYPE** argv, + CHAR_TYPE** temp) + : argc_ (argc), + total_size_ (argc), + temp_ ((const CHAR_TYPE **) temp), + argv_ ((const CHAR_TYPE **) argv), + current_index_ (0), + back_ (argc - 1), + front_ (0) +{ + this->init (); +} + +template +void +ACE_Arg_Shifter_T::init (void) +{ + // If not provided with one, allocate a temporary array. + if (this->temp_ == 0) + ACE_NEW (this->temp_, + const CHAR_TYPE *[this->total_size_]); + + if (this->temp_ != 0) + { + // Fill the temporary array. + this->argc_ = 0; + for (int i = 0; i < this->total_size_; i++) + { + this->temp_[i] = this->argv_[i]; + this->argv_[i] = 0; + } + } + else + { + // Allocation failed, prohibit iteration. + this->current_index_ = this->argc_; + this->front_ = this->argc_; + } +} + +template +ACE_Arg_Shifter_T::~ACE_Arg_Shifter_T (void) +{ + // Delete the temporary vector. + delete [] temp_; +} + +template +const CHAR_TYPE * +ACE_Arg_Shifter_T::get_current (void) const +{ + const CHAR_TYPE * retval = 0; + + if (this->is_anything_left ()) + retval = this->temp_[current_index_]; + + return retval; +} + +template +const CHAR_TYPE * +ACE_Arg_Shifter_T::get_the_parameter (const CHAR_TYPE *flag) +{ + // the return 0's abound because this method + // would otherwise be a deep if { } else { } + + // check to see if any arguments still exist + if (!this->is_anything_left()) + return 0; + + // check to see if the flag is the argument + int const offset = this->cur_arg_strncasecmp (flag); + if (offset == -1) + return 0; + + if (offset == 0) + { + this->consume_arg (); + + if (!this->is_parameter_next()) + { + return 0; + } + } + // the parameter is in the middle somewhere... + return this->temp_[current_index_] + offset; +} + +template +int +ACE_Arg_Shifter_T::cur_arg_strncasecmp (const CHAR_TYPE *flag) +{ + // Check for a current argument + if (this->is_anything_left()) + { + size_t const flag_length = ACE_OS::strlen (flag); + + // Check for presence of the flag + if (ACE_OS::strncasecmp(this->temp_[current_index_], + flag, + flag_length) == 0) + { + if (ACE_OS::strlen(temp_[current_index_]) == + flag_length) + { + // match and lengths are equal + return 0; + } + else + { + // matches, with more info to boot! + size_t const remaining = ACE_OS::strspn + (this->temp_[current_index_] + flag_length, + ACE_TEXT (" ")) + flag_length; + return static_cast (remaining); + } + } + } + // failure + return -1; +} + +template +int +ACE_Arg_Shifter_T::consume_arg (int number) +{ + int retval = 0; + + // Stick knowns at the end of the vector (consumed). + if (this->is_anything_left() >= number) + { + for (int i = 0, j = this->back_ - (number - 1); + i < number; + ++i, ++j, ++this->current_index_) + this->argv_[j] = this->temp_[this->current_index_]; + + this->back_ -= number; + retval = 1; + } + + return retval; +} + +template +int +ACE_Arg_Shifter_T::ignore_arg (int number) +{ + int retval = 0; + + // Keep unknowns at the head of the vector. + if (this->is_anything_left () >= number) + { + for (int i = 0; + i < number; + i++, this->current_index_++, this->front_++) + this->argv_[this->front_] = this->temp_[this->current_index_]; + + retval = 1; + this->argc_ += number; + } + + return retval; +} + +template +int +ACE_Arg_Shifter_T::is_anything_left (void) const +{ + return this->total_size_ - this->current_index_; +} + +template +int +ACE_Arg_Shifter_T::is_option_next (void) const +{ + return this->is_anything_left () && + this->temp_[this->current_index_][0] == '-'; +} + +template +int +ACE_Arg_Shifter_T::is_parameter_next (void) const +{ + return this->is_anything_left () + && this->temp_[this->current_index_][0] != '-'; +} + +template +int +ACE_Arg_Shifter_T::num_ignored_args (void) const +{ + return this->front_; +} + +ACE_END_VERSIONED_NAMESPACE_DECL + +#endif /* ACE_ATOMIC_OP_T_CPP */ diff --git a/dep/ACE_wrappers/ace/Arg_Shifter.h b/dep/ACE_wrappers/ace/Arg_Shifter.h new file mode 100644 index 00000000000..e143e57d1a7 --- /dev/null +++ b/dep/ACE_wrappers/ace/Arg_Shifter.h @@ -0,0 +1,221 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Arg_Shifter.h + * + * $Id: Arg_Shifter.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Seth Widoff + */ +//============================================================================= + +#ifndef ACE_ARG_SHIFTER_H +#define ACE_ARG_SHIFTER_H + +#include /**/ "ace/pre.h" + +#include /**/ "ace/ACE_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/Global_Macros.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +/** + * @class ACE_Arg_Shifter_T + * + * @brief This ADT operates on a specified set of arguments (@a argv). + * As known arguments are scanned, they are shifted to the back of the + * @a argv vector, so deeper levels of argument parsing can locate the yet + * unprocessed arguments at the beginning of the vector. + * + * The @c ACE_Arg_Shifter copies the pointers of the @a argv vector + * into a temporary array. As the @c ACE_Arg_Shifter iterates over + * the copied vector, it places known arguments in the rear of the + * vector, leaving the unknown ones in the beginning. So, after having + * visited all the arguments in the temporary vector, @c ACE_Arg_Shifter + * has placed all the unknown arguments in their original order at + * the front of original @a argv. + */ +template +class ACE_Arg_Shifter_T +{ +public: + // = Initialization and termination methods. + /** + * Initialize the ACE_Arg_Shifter to the vector over which to + * iterate. Optionally, also provide the temporary array for + * use in shifting the arguments. If ACE_Arg_Shifter must allocate + * the temporary vector internally and dynamic allocation fails, the + * ACE_Arg_Shifter will set all indicators to end of the vector, + * forbidding iteration. Following iteration over @a argv, the + * @a argc value will be updated to contain the number of + * unconsumed arguments. + * @param argc The number of strings in @a argv. @a argc will be + * updated to reflect the number of unconsumed arguments. + * @param argv The argument vector to shift. The string pointers in + * the vector will be reordered to place the @a argc unconsumed + * arguments at the front of the vector. + * @param temp A vector of @c CHAR_TYPE pointers at least @a argc + * elements long. The vector will be used for argument shifting as + * the specified @a argv vector is consumed. The vector must not + * be modified while this object exists. If this argument is 0 + * (the default) the object will allocate and free the temporary + * vector transparently. + */ + ACE_Arg_Shifter_T (int& argc, + const CHAR_TYPE **argv, + const CHAR_TYPE **temp = 0); + + /// Same behavior as the preceding constructor, but without the + /// "const" qualifier. + ACE_Arg_Shifter_T (int& argc, + CHAR_TYPE **argv, + CHAR_TYPE **temp = 0); + + /// Destructor. + ~ACE_Arg_Shifter_T (void); + + /// Get the current head of the vector. + const CHAR_TYPE *get_current (void) const; + + /** + * If the @a flag matches the current_arg of arg shifter + * this method will attempt to return the associated + * parameter value + * + * Safe to call without checking that a current arg exists + * + * In the following examples, a pointer to the char* "value" is ret + * + * eg: main -foobar value, main -FooBar value + * main -FOOBARvalue + * + * all of the above will all match the @a flag == -FooBar + * and will return a char* to "value" + * + * main -foobar 4 would succeed and return a char* to "4" + * main -foobar -4 does not succeed (-4 is not a parameter) + * but instead, would return 0 + * + * 0 is returned: + * If the current argument does not match flag + * If there is no parameter found after a 'matched' flag + * + * If the flag is matched and the flag and paramter DO NOT RUN + * together, the flag is consumed, the parameter is returned, + * and the new current argument is the parameter value. + * ie '-foobarflag VALUE' leaves the new cur arg == "VALUE" + * + * If the flag is matched and the flag and parameter RUN + * together '-foobarflagVALUE', the flag is NOT consumed + * and the cur arg is left pointing to the entire flag/value pair + */ + const CHAR_TYPE *get_the_parameter (const CHAR_TYPE* flag); + + /** + * Check if the current argument matches (case insensitive) + * + * ------------------------------------------------------------ + * + * Case A: Perfect Match (case insensitive) + * 0 is returned. + * + * ie: when current_arg = "-foobar" or "-FOOBAR" or "-fooBAR" + * this->cur_arg_strncasecmp ("-FooBar); + * will return 0 + * + * ------------------------------------------------------------ + * + * Case B: Perfect Match (case insensitive) but the current_arg + * is longer than the flag. Returns a number equal to the index + * in the char* indicating the start of the extra characters + * + * ie: when current_arg = "-foobar98023" + * this->cur_arg_strncasecmp ("-FooBar); + * will return 7 + * + * Notice: this number will always be > 0 + * + * ------------------------------------------------------------ + * + * Case C: If neither of Case A or B is met (no match) + * then -1 is returned + */ + int cur_arg_strncasecmp (const CHAR_TYPE *flag); + + /// Consume @a number argument(s) by sticking them/it on the end of + /// the vector. + int consume_arg (int number = 1); + + /// Place @a number arguments in the same relative order ahead of the + /// known arguments in the vector. + int ignore_arg (int number = 1); + + /// Returns the number of args left to see in the vector. + int is_anything_left (void) const; + + /// Returns 1 if there's a next item in the vector and it begins with + /// '-'. + int is_option_next (void) const; + + /// Returns 1 if there's a next item in the vector and it doesn't + /// begin with '-'. + int is_parameter_next (void) const; + + /// Returns the number of irrelevant args seen. + int num_ignored_args (void) const; + +private: + /// Copy Constructor should not be used. + ACE_UNIMPLEMENTED_FUNC (ACE_Arg_Shifter_T (const ACE_Arg_Shifter_T&)) + + /// Assignment '=' operator should not be used. + ACE_UNIMPLEMENTED_FUNC (ACE_Arg_Shifter_T operator= (const ACE_Arg_Shifter_T&)) + + /// Refactor the constructor logic. + void init (void); + + /// The size of the argument vector. + int& argc_; + + /// The size of argv_. + int total_size_; + + /// The temporary array over which we traverse. + const CHAR_TYPE **temp_; + + /// The array in which the arguments are reordered. + const CHAR_TYPE **argv_; + + /// The element in we're currently examining. + int current_index_; + + /// The index of in which we'll stick the next unknown + /// argument. + int back_; + + /// The index of in which we'll stick the next known + /// argument. + int front_; +}; + +typedef ACE_Arg_Shifter_T ACE_Arg_Shifter; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) +#include "ace/Arg_Shifter.cpp" +#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ + +#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) +#pragma implementation ("Arg_Shifter.cpp") +#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ + +#include /**/ "ace/post.h" + +#endif /* ACE_ARG_SHIFTER_H */ diff --git a/dep/ACE_wrappers/ace/Argv_Type_Converter.cpp b/dep/ACE_wrappers/ace/Argv_Type_Converter.cpp new file mode 100644 index 00000000000..d594e65450c --- /dev/null +++ b/dep/ACE_wrappers/ace/Argv_Type_Converter.cpp @@ -0,0 +1,204 @@ +// $Id: Argv_Type_Converter.cpp 80826 2008-03-04 14:51:23Z wotte $ + +#include "ace/Argv_Type_Converter.h" + +#if !defined (__ACE_INLINE__) +#include "ace/Argv_Type_Converter.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID (ace, + Argv_Type_Converter, + "$Id: Argv_Type_Converter.cpp 80826 2008-03-04 14:51:23Z wotte $") + +#include "ace/OS_NS_string.h" +#include "ace/OS_Errno.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +#if defined (ACE_USES_WCHAR) +ACE_Argv_Type_Converter::ACE_Argv_Type_Converter (int &argc, wchar_t** argv) + : saved_argc_ (argc), + char_argv_ (0), + wchar_argv_ (argv), + before_pass_argc_ (argc), + original_type_ (true), + wchar_passed_ (false), + char_passed_ (false) +{ + this->initialize (); + + for (int i = 0; i < argc; ++i) + this->char_argv_[i] = ACE_OS::strdup (ACE_TEXT_ALWAYS_CHAR (argv[i])); +} +#endif // ACE_USES_WCHAR + + +ACE_Argv_Type_Converter::ACE_Argv_Type_Converter (int &argc, char **argv) + : saved_argc_(argc), + char_argv_(argv) +#if defined (ACE_USES_WCHAR) + , wchar_argv_(0), + before_pass_argc_(argc), + original_type_(false), + wchar_passed_(false), + char_passed_(false) +{ + this->initialize(); + + for (int i = 0; i < argc; ++i) + this->wchar_argv_[i] = ACE_OS::strdup (ACE_TEXT_ANTI_TO_TCHAR (argv[i])); +} +#else +{ +} +#endif // ACE_USES_WCHAR + +ACE_Argv_Type_Converter::~ACE_Argv_Type_Converter (void) +{ +#if defined (ACE_USES_WCHAR) + // selectively delete the 'copy' of argv + if (this->original_type_) + { + // if original type is wchar_t + if (this->char_passed_) + this->align_wchar_with_char (); + + for (int i = 0; i < this->before_pass_argc_; ++i) + ACE_OS::free (this->char_argv_[i]); + + delete [] this->char_argv_; + } + else + { + // if original type is char + if (this->wchar_passed_) + this->align_char_with_wchar (); + + for (int i = 0; i < this->before_pass_argc_; ++i) + ACE_OS::free (this->wchar_argv_[i]); + + delete [] this->wchar_argv_; + } +#endif // ACE_USES_WCHAR +} + +#if defined (ACE_USES_WCHAR) +void +ACE_Argv_Type_Converter::initialize (void) +{ + if (this->original_type_) + { + // Make a copy of argv in 'char'. type Create one more argv entry + // than original argc for the NULL. + ACE_NEW (char_argv_, + char *[this->saved_argc_ + 1]); + this->char_argv_[saved_argc_] = 0; // last entry of argv is + // always a NULL + } + else + { + // make a copy of argv in 'wchar_t' type + ACE_NEW (this->wchar_argv_, + wchar_t*[this->saved_argc_ + 1]); + this->wchar_argv_[saved_argc_] = 0; + } +} + + +void +ACE_Argv_Type_Converter::align_char_with_wchar (void) +{ + int wchar_argv_index = 0; + wchar_t* match_argv = this->wchar_argv_[0]; // pick the initial entry + + while (wchar_argv_index < this->saved_argc_) + { + // if n'th entries of both argv lists are different + if (ACE_OS::strcmp (this->char_argv_[wchar_argv_index], + ACE_TEXT_ALWAYS_CHAR (match_argv)) != 0) + { + // loop through the wchar argv list entries that are after + // wchar_argv_index + for (int i = wchar_argv_index + 1; i < before_pass_argc_; ++i) + { + if (ACE_OS::strcmp (this->char_argv_[i], + ACE_TEXT_ALWAYS_CHAR (match_argv)) == 0) + { + // swap the pointers in the char argv list + char *temp = this->char_argv_[wchar_argv_index]; + this->char_argv_[wchar_argv_index] = this->char_argv_[i]; + this->char_argv_[i] = temp; + break; + } + } + } + + // move to the next wchar argv list entry + match_argv = this->wchar_argv_[++wchar_argv_index]; + } + + this->cleanup (); +} + +void +ACE_Argv_Type_Converter::align_wchar_with_char (void) +{ + int char_argv_index = 0; + char* match_argv = this->char_argv_[0]; // pick the initial entry + + while (char_argv_index < saved_argc_) + { + // if n'th entries of both argv lists are different + if (ACE_OS::strcmp ( + ACE_TEXT_ALWAYS_CHAR (this->wchar_argv_[char_argv_index]), + match_argv) != 0) + { + // loop through the wchar argv list entries that are after + // wchar_argv_index + for (int i = char_argv_index + 1; i < this->before_pass_argc_; ++i) + { + if (ACE_OS::strcmp ( + ACE_TEXT_ALWAYS_CHAR(this->wchar_argv_[i]), + match_argv) == 0) { + // swap the pointers in the char argv list + wchar_t* temp = this->wchar_argv_[char_argv_index]; + this->wchar_argv_[char_argv_index] = this->wchar_argv_[i]; + this->wchar_argv_[i] = temp; + break; + } + } + } + + // move to the next wchar argv list entry + match_argv = this->char_argv_[++char_argv_index]; + } + + this->cleanup(); +} + +void +ACE_Argv_Type_Converter::cleanup (void) +{ + for (int i = this->saved_argc_; i < this->before_pass_argc_; ++i) + { + // Check whether it's ours to delete. + if (original_type_) + { + ACE_OS::free (this->char_argv_[i]); + this->char_argv_[i] = 0; + } + else + { + ACE_OS::free (this->wchar_argv_[i]); + this->wchar_argv_[i] = 0; + } + } + + this->before_pass_argc_ = this->saved_argc_; + + this->wchar_passed_ = false; + this->char_passed_ = false; +} +#endif // ACE_USES_WCHAR + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Argv_Type_Converter.h b/dep/ACE_wrappers/ace/Argv_Type_Converter.h new file mode 100644 index 00000000000..ee2c541ed74 --- /dev/null +++ b/dep/ACE_wrappers/ace/Argv_Type_Converter.h @@ -0,0 +1,119 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Argv_Type_Converter.h + * + * $Id: Argv_Type_Converter.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Si Mong Park + */ +//============================================================================= + +#ifndef ACE_ARGV_TYPE_CONVERTER_H +#define ACE_ARGV_TYPE_CONVERTER_H + +#include /**/ "ace/pre.h" + +#include /**/ "ace/ACE_export.h" +#include "ace/OS_Memory.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +/** + * @class ACE_Argv_Type_Converter + * + * @brief To convert 'char' input/command line parameter to 'wchar_t'. + * + * This class is to convert 'char' type command line paramter to + * wide-character (wchar_t) format and stores the copy of it. + * This is useful for all classes that use 'char**' argv but cannot + * be converted into 'ACE_TCHAR**' version. + * Note that the converted data will be lost upon destruction, so + * classes should use this class as their data member. + */ +class ACE_Export ACE_Argv_Type_Converter +{ +public: + + ACE_Argv_Type_Converter (int &argc, char** argv); + +#if defined (ACE_USES_WCHAR) + ACE_Argv_Type_Converter (int &argc, wchar_t** argv); +#endif // ACE_USES_WCHAR + + ~ACE_Argv_Type_Converter (void); + + /// Returns the pointer of converted command line. + ACE_TCHAR** get_TCHAR_argv (void); + + /// Returns the pointer of ASCII (char) command line. + char** get_ASCII_argv (void); + + /// Returns the number of sub paramters (argc). + int& get_argc (void); + +private: + + /// Copy Constructor should not be used. + ACE_Argv_Type_Converter (const ACE_Argv_Type_Converter&); + + /// Assignment '=' operator should not be used. + ACE_Argv_Type_Converter operator= (const ACE_Argv_Type_Converter&); + +#if defined (ACE_USES_WCHAR) + + /// Perform common initialization for two Ctor's. + void initialize (void); + + /// Align all entries in the char type argv list with wchar_t type + /// argv list. + void align_char_with_wchar (void); + + /// Align all entries in the wchar_t type argv list with char type + /// argv list. + void align_wchar_with_char (void); + + /// Clean up removed (comsumed) argv entries and reset the pass flags. + void cleanup (void); +#endif // ACE_USES_WCHAR + +private: + /// Original number of input paramter, same as 'argc'. + int &saved_argc_; + + /// Data member pointer that contains converted argv in ACE_ANTI_TCHAR. + char** char_argv_; + +#if defined (ACE_USES_WCHAR) + /// Data member pointer that contains converted argv in ACE_TCHAR. + wchar_t** wchar_argv_; + + /// argc value before any argv has been passed. + int before_pass_argc_; + + /// false represents original argv passed in is char, and true + /// represents wchar_t. + bool const original_type_; + + /// true indicates wchar_t type argv has been passed. + bool wchar_passed_; + + /// true indicates char type argv has been passed. + bool char_passed_; +#endif /* ACE_USES_WCHAR */ +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +#include "ace/Argv_Type_Converter.inl" +#endif /* __ACE_INLINE__ */ + +#include /**/ "ace/post.h" + +#endif /* ACE_ARGV_TYPE_CONVERTER_H */ diff --git a/dep/ACE_wrappers/ace/Argv_Type_Converter.inl b/dep/ACE_wrappers/ace/Argv_Type_Converter.inl new file mode 100644 index 00000000000..e4b0ed5a059 --- /dev/null +++ b/dep/ACE_wrappers/ace/Argv_Type_Converter.inl @@ -0,0 +1,44 @@ +// -*- C++ -*- +// +// $Id: Argv_Type_Converter.inl 80826 2008-03-04 14:51:23Z wotte $ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_INLINE ACE_TCHAR** +ACE_Argv_Type_Converter::get_TCHAR_argv (void) +{ +#if defined (ACE_USES_WCHAR) + if (this->char_passed_) + { + this->align_wchar_with_char (); + } + + this->wchar_passed_ = true; + return this->wchar_argv_; +#else + return this->char_argv_; +#endif // ACE_USES_WCHAR +} + +ACE_INLINE char** +ACE_Argv_Type_Converter::get_ASCII_argv (void) +{ +#if defined (ACE_USES_WCHAR) + if (this->wchar_passed_) + { + this->align_char_with_wchar (); + } + + this->char_passed_ = true; +#endif // ACE_USES_WCHAR + + return this->char_argv_; +} + +ACE_INLINE int& +ACE_Argv_Type_Converter::get_argc (void) +{ + return this->saved_argc_; +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Array.h b/dep/ACE_wrappers/ace/Array.h new file mode 100644 index 00000000000..3caaa7b719b --- /dev/null +++ b/dep/ACE_wrappers/ace/Array.h @@ -0,0 +1,29 @@ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file Array.h + * + * $Id: Array.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @deprecated + * + * @note This file has been deprecated and will soon go away. You + * should directly include "Containers_T.h" instead. + * + * @author Douglas C. Schmidt + */ +//============================================================================= + +#ifndef ACE_ARRAY_H +#define ACE_ARRAY_H +#include /**/ "ace/pre.h" + +#include "ace/Containers_T.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include /**/ "ace/post.h" +#endif /* ACE_ARRAY_H */ diff --git a/dep/ACE_wrappers/ace/Array_Base.cpp b/dep/ACE_wrappers/ace/Array_Base.cpp new file mode 100644 index 00000000000..49e42e1ad98 --- /dev/null +++ b/dep/ACE_wrappers/ace/Array_Base.cpp @@ -0,0 +1,235 @@ +// $Id: Array_Base.cpp 80826 2008-03-04 14:51:23Z wotte $ + +#ifndef ACE_ARRAY_BASE_CPP +#define ACE_ARRAY_BASE_CPP + +#include "ace/Array_Base.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#if !defined (__ACE_INLINE__) +#include "ace/Array_Base.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/Malloc_Base.h" +#include "ace/os_include/os_errno.h" + +#include + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +// Dynamically initialize an array. +template +ACE_Array_Base::ACE_Array_Base (typename ACE_Array_Base::size_type size, + ACE_Allocator *alloc) + : max_size_ (size), + cur_size_ (size), + allocator_ (alloc) +{ + if (this->allocator_ == 0) + this->allocator_ = ACE_Allocator::instance (); + + if (size != 0) + { + ACE_ALLOCATOR (this->array_, + (T *) this->allocator_->malloc (size * sizeof (T))); + for (size_type i = 0; i < size; ++i) + new (&array_[i]) T; + } + else + this->array_ = 0; +} + +template +ACE_Array_Base::ACE_Array_Base (typename ACE_Array_Base::size_type size, + const T &default_value, + ACE_Allocator *alloc) + : max_size_ (size), + cur_size_ (size), + allocator_ (alloc) +{ + if (this->allocator_ == 0) + this->allocator_ = ACE_Allocator::instance (); + + if (size != 0) + { + ACE_ALLOCATOR (this->array_, + (T *) this->allocator_->malloc (size * sizeof (T))); + for (size_type i = 0; i < size; ++i) + new (&array_[i]) T (default_value); + } + else + this->array_ = 0; +} + +// The copy constructor (performs initialization). + +template +ACE_Array_Base::ACE_Array_Base (const ACE_Array_Base &s) + : max_size_ (s.size ()), + cur_size_ (s.size ()), + allocator_ (s.allocator_) +{ + if (this->allocator_ == 0) + this->allocator_ = ACE_Allocator::instance (); + + ACE_ALLOCATOR (this->array_, + (T *) this->allocator_->malloc (s.size () * sizeof (T))); + for (size_type i = 0; i < this->size (); ++i) + new (&this->array_[i]) T (s.array_[i]); +} + +// Assignment operator (performs assignment). + +template void +ACE_Array_Base::operator= (const ACE_Array_Base &s) +{ + // Check for "self-assignment". + + if (this != &s) + { + if (this->max_size_ < s.size ()) + { + // Need to reallocate memory. + + // Strongly exception-safe assignment. + // + // Note that we're swapping the allocators here, too. + // Should we? Probably. "*this" should be a duplicate of + // the "right hand side". + ACE_Array_Base tmp (s); + this->swap (tmp); + } + else + { + // Underlying array is large enough. No need to reallocate + // memory. + // + // "*this" still owns the memory for the underlying array. + // Do not swap out the allocator. + // + // @@ Why don't we just drop the explicit destructor and + // placement operator new() calls with a straight + // element-by-element assignment? Is the existing + // approach more efficient? + // -Ossama + + ACE_DES_ARRAY_NOFREE (this->array_, + s.size (), + T); + + this->cur_size_ = s.size (); + + for (size_type i = 0; i < this->size (); ++i) + new (&this->array_[i]) T (s.array_[i]); + } + } +} + +// Set an item in the array at location slot. + +template int +ACE_Array_Base::set (const T &new_item, + typename ACE_Array_Base::size_type slot) +{ + if (this->in_range (slot)) + { + this->array_[slot] = new_item; + return 0; + } + else + return -1; +} + +// Get an item in the array at location slot. + +template int +ACE_Array_Base::get (T &item, + typename ACE_Array_Base::size_type slot) const +{ + if (this->in_range (slot)) + { + // Copies the item. If you don't want to copy, use operator [] + // instead (but then you'll be responsible for range checking). + item = this->array_[slot]; + return 0; + } + else + return -1; +} + +template int +ACE_Array_Base::max_size (typename ACE_Array_Base::size_type new_size) +{ + if (new_size > this->max_size_) + { + T *tmp = 0; + + ACE_ALLOCATOR_RETURN (tmp, + (T *) this->allocator_->malloc (new_size * sizeof (T)), + -1); + for (size_type i = 0; i < this->cur_size_; ++i) + new (&tmp[i]) T (this->array_[i]); + + // Initialize the new portion of the array that exceeds the + // previously allocated section. + for (size_type j = this->cur_size_; j < new_size; ++j) + new (&tmp[j]) T; + + ACE_DES_ARRAY_FREE (this->array_, + this->max_size_, + this->allocator_->free, + T); + this->array_ = tmp; + this->max_size_ = new_size; + this->cur_size_ = new_size; + } + + return 0; +} + +template int +ACE_Array_Base::size (typename ACE_Array_Base::size_type new_size) +{ + int const r = this->max_size (new_size); + + if (r == 0) + this->cur_size_ = new_size; + + return r; +} + +template +void +ACE_Array_Base::swap (ACE_Array_Base & rhs) +{ + std::swap (this->max_size_ , rhs.max_size_); + std::swap (this->cur_size_ , rhs.cur_size_); + std::swap (this->array_ , rhs.array_); + std::swap (this->allocator_, rhs.allocator_); +} + +// **************************************************************** + +template int +ACE_Array_Iterator::next (T *&item) +{ + // ACE_TRACE ("ACE_Array_Iterator::next"); + + if (this->done ()) + { + item = 0; + return 0; + } + else + { + item = &array_[current_]; + return 1; + } +} + +ACE_END_VERSIONED_NAMESPACE_DECL + +#endif /* ACE_ARRAY_BASE_CPP */ diff --git a/dep/ACE_wrappers/ace/Array_Base.h b/dep/ACE_wrappers/ace/Array_Base.h new file mode 100644 index 00000000000..44e2812552d --- /dev/null +++ b/dep/ACE_wrappers/ace/Array_Base.h @@ -0,0 +1,256 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Array_Base.h + * + * $Id: Array_Base.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Douglas C. Schmidt + */ +//============================================================================= + +#ifndef ACE_ARRAY_BASE_H +#define ACE_ARRAY_BASE_H + +#include /**/ "ace/pre.h" + +#include /**/ "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/Global_Macros.h" +#include "ace/Malloc_Base.h" +#include /* For reverse_iterator adapters */ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +// Forward declaration. +template class ACE_Array_Iterator; + +/** + * @class ACE_Array_Base + * + * @brief Implement a simple dynamic array + * + * This parametric class implements a simple dynamic array; + * resizing must be controlled by the user. No comparison or find + * operations are implemented. + */ +template +class ACE_Array_Base +{ +public: + + // Old/ACE-style traits. + typedef T TYPE; + typedef ACE_Array_Iterator ITERATOR; + + // STL-style typedefs/traits. + typedef T value_type; + typedef value_type * iterator; + typedef value_type const * const_iterator; + typedef value_type & reference; + typedef value_type const & const_reference; + typedef value_type * pointer; + typedef value_type const * const_pointer; + typedef ptrdiff_t difference_type; + typedef ACE_Allocator::size_type size_type; + + ACE_DECLARE_STL_REVERSE_ITERATORS + + // = Initialization and termination methods. + + /// Dynamically create an uninitialized array. + ACE_Array_Base (size_type size = 0, + ACE_Allocator * the_allocator = 0); + + /// Dynamically initialize the entire array to the . + ACE_Array_Base (size_type size, + T const & default_value, + ACE_Allocator * the_allocator = 0); + + /** + * The copy constructor performs initialization by making an exact + * copy of the contents of parameter , i.e., *this == s will + * return true. + */ + ACE_Array_Base (ACE_Array_Base const & s); + + /** + * Assignment operator performs an assignment by making an exact + * copy of the contents of parameter , i.e., *this == s will + * return true. Note that if the of is >= than + * we can copy it without reallocating. However, if + * is < we must delete the , + * reallocate a new , and then copy the contents of . + */ + void operator= (ACE_Array_Base const & s); + + /// Clean up the array (e.g., delete dynamically allocated memory). + ~ACE_Array_Base (void); + + // = Set/get methods. + + /// Set item in the array at location @a slot. Doesn't + /// perform range checking. + T & operator[] (size_type slot); + + /// Get item in the array at location @a slot. Doesn't + /// perform range checking. + T const & operator[] (size_type slot) const; + + /// Set an item in the array at location @a slot. Returns + /// -1 if @a slot is not in range, else returns 0. + int set (T const & new_item, size_type slot); + + /** + * Get an item in the array at location @a slot. Returns -1 if + * @a slot is not in range, else returns 0. Note that this function + * copies the item. If you want to avoid the copy, you can use + * the const operator [], but then you'll be responsible for range checking. + */ + int get (T & item, size_type slot) const; + + /// Returns the of the array. + size_type size (void) const; + + /** + * Changes the size of the array to match . + * It copies the old contents into the new array. + * Return -1 on failure. + */ + int size (size_type new_size); + + /// Returns the of the array. + size_type max_size (void) const; + + /** + * Changes the size of the array to match . + * It copies the old contents into the new array. + * Return -1 on failure. + * It does not affect new_size + */ + int max_size (size_type new_size); + + /** + * @name Forward Iterator Accessors + * + * Forward iterator accessors. + */ + //@{ + iterator begin (void); + iterator end (void); + const_iterator begin (void) const; + const_iterator end (void) const; + //@} + + /** + * @name Reverse Iterator Accessors + * + * Reverse iterator accessors. + */ + //@{ + reverse_iterator rbegin (void); + reverse_iterator rend (void); + const_reverse_iterator rbegin (void) const; + const_reverse_iterator rend (void) const; + //@} + + /// Swap the contents of this array with the given @a array in + /// an exception-safe manner. + void swap (ACE_Array_Base & array); + +protected: + + /// Returns 1 if @a slot is within range, i.e., 0 >= @a slot < + /// , else returns 0. + bool in_range (size_type slot) const; + + /// Maximum size of the array, i.e., the total number of elements + /// in . + size_type max_size_; + + /** + * Current size of the array. This starts out being == to + * . However, if we are assigned a smaller array, then + * will become less than . The purpose of + * keeping track of both sizes is to avoid reallocating memory if we + * don't have to. + */ + size_type cur_size_; + + /// Pointer to the array's storage buffer. + value_type * array_; + + /// Allocation strategy of the ACE_Array_Base. + ACE_Allocator * allocator_; + + friend class ACE_Array_Iterator; +}; + +// **************************************************************** + +/** + * @class ACE_Array_Iterator + * + * @brief Implement an iterator over an ACE_Array. + * + * This iterator is safe in the face of array element deletions. + * But it is NOT safe if the array is resized (via the ACE_Array + * assignment operator) during iteration. That would be very + * odd, and dangerous. + */ +template +class ACE_Array_Iterator +{ +public: + // = Initialization method. + ACE_Array_Iterator (ACE_Array_Base &); + + // = Iteration methods. + + /// Pass back the that hasn't been seen in the Array. + /// Returns 0 when all items have been seen, else 1. + int next (T *&next_item); + + /// Move forward by one element in the Array. Returns 0 when all the + /// items in the Array have been seen, else 1. + int advance (void); + + /// Returns 1 when all items have been seen, else 0. + int done (void) const; + + /// Dump the state of an object. + void dump (void) const; + + /// Declare the dynamic allocation hooks. + ACE_ALLOC_HOOK_DECLARE; + +private: + /// Pointer to the current item in the iteration. + size_t current_; + + /// Pointer to the Array we're iterating over. + ACE_Array_Base &array_; +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +#include "ace/Array_Base.inl" +#endif /* __ACE_INLINE__ */ + +#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) +#include "ace/Array_Base.cpp" +#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ + +#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) +#pragma implementation ("Array_Base.cpp") +#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ + +#include /**/ "ace/post.h" + +#endif /* ACE_ARRAY_BASE_H */ diff --git a/dep/ACE_wrappers/ace/Array_Base.inl b/dep/ACE_wrappers/ace/Array_Base.inl new file mode 100644 index 00000000000..046c1bffc89 --- /dev/null +++ b/dep/ACE_wrappers/ace/Array_Base.inl @@ -0,0 +1,146 @@ +// -*- C++ -*- +// +// $Id: Array_Base.inl 80826 2008-03-04 14:51:23Z wotte $ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +// Clean up the array (e.g., delete dynamically allocated memory). +template ACE_INLINE +ACE_Array_Base::~ACE_Array_Base (void) +{ + ACE_DES_ARRAY_FREE (this->array_, + this->max_size_, + this->allocator_->free, + T); +} + +template +ACE_INLINE typename ACE_Array_Base::iterator +ACE_Array_Base::begin (void) +{ + return this->array_; +} + +template +ACE_INLINE typename ACE_Array_Base::iterator +ACE_Array_Base::end (void) +{ + return this->array_ + this->cur_size_; +} + +template +ACE_INLINE typename ACE_Array_Base::const_iterator +ACE_Array_Base::begin (void) const +{ + return this->array_; +} + +template +ACE_INLINE typename ACE_Array_Base::const_iterator +ACE_Array_Base::end (void) const +{ + return this->array_ + this->cur_size_; +} + +template +ACE_INLINE typename ACE_Array_Base::reverse_iterator +ACE_Array_Base::rbegin (void) +{ + return reverse_iterator (this->end ()); +} + +template +ACE_INLINE typename ACE_Array_Base::reverse_iterator +ACE_Array_Base::rend (void) +{ + return reverse_iterator (this->begin ()); +} + +template +ACE_INLINE typename ACE_Array_Base::const_reverse_iterator +ACE_Array_Base::rbegin (void) const +{ + return const_reverse_iterator (this->end ()); +} + +template +ACE_INLINE typename ACE_Array_Base::const_reverse_iterator +ACE_Array_Base::rend (void) const +{ + return const_reverse_iterator (this->begin ()); +} + +template ACE_INLINE typename ACE_Array_Base::size_type +ACE_Array_Base::size (void) const +{ + return this->cur_size_; +} + +template ACE_INLINE typename ACE_Array_Base::size_type +ACE_Array_Base::max_size (void) const +{ + return this->max_size_; +} + +template ACE_INLINE bool +ACE_Array_Base::in_range (typename ACE_Array_Base::size_type index) const +{ + return index < this->cur_size_; +} + +template ACE_INLINE T & +ACE_Array_Base::operator[] (typename ACE_Array_Base::size_type index) +{ + return this->array_[index]; +} + +template ACE_INLINE const T & +ACE_Array_Base::operator[] (typename ACE_Array_Base::size_type index) const +{ + return this->array_[index]; +} + +// **************************************************************** + +template ACE_INLINE void +ACE_Array_Iterator::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + // ACE_TRACE ("ACE_Array_Iterator::dump"); +#endif /* ACE_HAS_DUMP */ +} + +template ACE_INLINE +ACE_Array_Iterator::ACE_Array_Iterator (ACE_Array_Base &a) + : current_ (0), + array_ (a) +{ + // ACE_TRACE ("ACE_Array_Iterator::ACE_Array_Iterator"); +} + +template ACE_INLINE int +ACE_Array_Iterator::advance (void) +{ + // ACE_TRACE ("ACE_Array_Iterator::advance"); + + if (this->current_ < array_.size ()) + { + ++this->current_; + return 1; + } + else + { + // Already finished iterating. + return 0; + } +} + +template ACE_INLINE int +ACE_Array_Iterator::done (void) const +{ + ACE_TRACE ("ACE_Array_Iterator::done"); + + return this->current_ >= array_.size (); +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Array_Map.cpp b/dep/ACE_wrappers/ace/Array_Map.cpp new file mode 100644 index 00000000000..5530a8b54b6 --- /dev/null +++ b/dep/ACE_wrappers/ace/Array_Map.cpp @@ -0,0 +1,299 @@ +// $Id: Array_Map.cpp 80826 2008-03-04 14:51:23Z wotte $ + +#ifndef ACE_ARRAY_MAP_CPP +#define ACE_ARRAY_MAP_CPP + +#include "ace/Array_Map.h" + +#ifndef __ACE_INLINE__ +# include "ace/Array_Map.inl" +#endif /* !__ACE_INLINE__ */ + +#include "ace/checked_iterator.h" + +#include + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +#ifndef ACE_LACKS_MEMBER_TEMPLATES +template +template +ACE_Array_Map::ACE_Array_Map (InputIterator f, + InputIterator l) + : size_ (l - f) + , capacity_ (size_) + , nodes_ (size_ == 0 ? 0 : new value_type[size_]) +{ + (void) std::copy (f, + l, + ACE_make_checked_array_iterator (this->begin (), + this->size_)); + +// iterator n = this->begin (); + +// for (InputIterator i = f; i != l; ++i, ++n) +// *n = *i; +} +#else +template +ACE_Array_Map::ACE_Array_Map ( + typename ACE_Array_Map::const_iterator f, + typename ACE_Array_Map::const_iterator l) + : size_ (l - f) + , capacity_ (size_) + , nodes_ (size_ == 0 ? 0 : new value_type[size_]) +{ + (void) std::copy (f, + l, + ACE_make_checked_array_iterator (this->begin (), + this->size_)); + +// iterator n = this->begin (); + +// for (const_iterator i = f; i != l; ++i, ++n) +// *n = *i; +} +#endif /* !ACE_LACKS_MEMBER_TEMPLATES */ + +template +ACE_Array_Map::ACE_Array_Map ( + ACE_Array_Map const & map) + : size_ (map.size_) + , capacity_ (map.size_) + , nodes_ (size_ == 0 ? 0 : new value_type[size_]) +{ + std::copy (map.begin (), + map.end (), + ACE_make_checked_array_iterator (this->begin (), + this->size_)); + +// iterator f = map.begin (); +// iterator l = map.end (); +// iterator n = this->begin (); + +// for (iterator i = f; i != l; ++i, ++n) +// *n = *i; +} + +template +ACE_Array_Map::~ACE_Array_Map (void) +{ + delete[] this->nodes_; +} + +template +void +ACE_Array_Map::swap ( + ACE_Array_Map & map) +{ + std::swap (this->size_, map.size_); + std::swap (this->capacity_, map.capacity_); + std::swap (this->nodes_, map.nodes_); +} + +template +std::pair::iterator, bool> +ACE_Array_Map::insert ( + typename ACE_Array_Map::value_type const & x) +{ + // Linear insertion due to linear duplicate key search. + + bool inserted = false; + iterator i = this->find (x.first); + + if (i == this->end ()) + { + // Add the element to the array. + + size_type const old_size = this->size (); + this->grow (1); // Increase size by at least one. + + i = this->begin () + old_size; + *i = x; + + ++this->size_; + + inserted = true; + } + + return std::make_pair (i, inserted); +} + +#ifndef ACE_LACKS_MEMBER_TEMPLATES +template +template +void +ACE_Array_Map::insert (InputIterator f, InputIterator l) +{ + this->grow (l - f); // Preallocate storage. + + for (InputIterator i = f; i != l; ++i) + { + (void) this->insert (*i); + } +} +#else +template +void +ACE_Array_Map::insert ( + typename ACE_Array_Map::const_iterator f, + typename ACE_Array_Map::const_iterator l) +{ + this->grow (l - f); // Preallocate storage. + + for (const_iterator i = f; i != l; ++i) + { + (void) this->insert (*i); + } +} +#endif /* ACE_LACKS_MEMBER_TEMPLATES */ + +template +void +ACE_Array_Map::erase ( + typename ACE_Array_Map::iterator pos) +{ + iterator const first = this->begin (); + iterator const last = this->end (); + + if (pos >= first && pos < last) + { + if (pos != last - 1) + { + // Relocate the tail element to the location of the erased + // element to prevent introduction of "holes" in the + // underlying array. + *pos = *(last - 1); + } + + // Explicitly destroy the tail element by assigning a default + // constructed instance to it. Note that this also works for + // the case of a map of size 1. + *(last - 1) = value_type (); + + --this->size_; + } +} + +template +typename ACE_Array_Map::size_type +ACE_Array_Map::erase ( + typename ACE_Array_Map::key_type const & k) +{ + iterator pos = this->find (k); + + size_type const old_size = this->size_; + + this->erase (pos); + + return old_size - this->size_; +} + +template +void +ACE_Array_Map::erase ( + typename ACE_Array_Map::iterator first, + typename ACE_Array_Map::iterator last) +{ + if (this->begin () <= first && first < last && last < this->end ()) + for (iterator i = first; i != last; ++i) + this->erase (i); +} + +template +void +ACE_Array_Map::clear (void) +{ + this->size_ = 0; // No need to deallocate array nor destroy elements. +} + +template +typename ACE_Array_Map::iterator +ACE_Array_Map::find ( + typename ACE_Array_Map::key_type const & k) +{ + iterator const the_end = this->end (); + + EqualTo eq; + + for (iterator i = this->begin (); i != the_end; ++i) + if (eq (k, i->first)) + return i; + + return this->end (); +} + +template +typename ACE_Array_Map::const_iterator +ACE_Array_Map::find ( + typename ACE_Array_Map::key_type const & k) const +{ + const_iterator const the_end = this->end (); + + EqualTo eq; + + for (const_iterator i = this->begin (); i != the_end; ++i) + if (eq (k, i->first)) + return i; + + return this->end (); +} + +template +void +ACE_Array_Map::grow ( + typename ACE_Array_Map::size_type s) +{ + if (this->size () + s > this->capacity_) + { + // This implementation focuses more on static footprint than + // speed. + + // Strongly exception safe. + + ACE_Array_Map temp (this->size () + s); + + std::copy (this->begin (), + this->end (), + ACE_make_checked_array_iterator (temp.begin (), + temp.capacity_)); + + size_type const n = this->size (); // Do not swap out the size + // since we bypassed the + // temporary map's element + // counting code. + this->swap (temp); + + this->size_ = n; + } +} + +// --------------------------------------------------------------- + +template +bool +operator== (ACE_Array_Map const & lhs, + ACE_Array_Map const & rhs) +{ + // Do not include Array_Map capacity in comparison. It isn't useful + // in this case. + + return (lhs.size () == rhs.size () + && std::equal (lhs.begin (), + lhs.end (), + ACE_make_checked_array_iterator (rhs.begin (), + rhs.size ()))); +} + +template +bool +operator< (ACE_Array_Map const & lhs, + ACE_Array_Map const & rhs) +{ + return std::lexicographical_compare (lhs.begin (), lhs.end (), + rhs.begin (), rhs.end ()); +} + +ACE_END_VERSIONED_NAMESPACE_DECL + +#endif /* ACE_ARRAY_MAP_CPP */ diff --git a/dep/ACE_wrappers/ace/Array_Map.h b/dep/ACE_wrappers/ace/Array_Map.h new file mode 100644 index 00000000000..67aa8d94b23 --- /dev/null +++ b/dep/ACE_wrappers/ace/Array_Map.h @@ -0,0 +1,300 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Array_Map.h + * + * $Id: Array_Map.h 80826 2008-03-04 14:51:23Z wotte $ + * + * Light weight array-based map with fast iteration but linear + * (i.e. O(n)) search times. STL-style interface is exposed. + * + * @note This class requires the STL generic algorithms and + * reverse_iterator adapter. + * + * @author Ossama Othman + */ +//============================================================================= + + +#ifndef ACE_ARRAY_MAP_H +#define ACE_ARRAY_MAP_H + +#include /**/ "ace/pre.h" + +#include "ace/config-lite.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include +#include +#include + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +/** + * @class ACE_Array_Map + * + * @brief Light weight array-based map with fast iteration, but linear + * (i.e. O(n)) search times. + * + * Map implementation that focuses on small footprint and fast + * iteration. Search times are, however, linear (O(n)) meaning that + * this map isn't suitable for large data sets that will be searched + * in performance critical areas of code. Iteration over large data + * sets, however, is faster than linked list-based maps, for example, + * since spatial locality is maximized through the use of contiguous + * arrays as the underlying storage. + * @par + * An @c ACE_Array_Map is a unique associative container, meaning that + * duplicate values may not be added to the map. It is also pair + * associative (value_type is a std::pair<>). It is not a sorted + * container. + * @par + * An STL @c std::map -like interface is exposed by this class + * portability. Furthermore, this map's iterators are compatible with + * STL algorithms. + * @par + * Requirements and Performance Characteristics + * - Internal Structure + * Array + * - Duplicates allowed? + * No + * - Random access allowed? + * Yes + * - Search speed + * O(n) + * - Insert/replace speed + * O(n), can be longer if the map has to resize + * - Iterator still valid after change to container? + * No + * - Frees memory for removed elements? + * Yes + * - Items inserted by + * Value + * - Requirements for key type + * -# Default constructor + * -# Copy constructor + * -# operator= + * -# operator== + * - Requirements for object type + * -# Default constructor + * -# Copy constructor + * -# operator= + */ +template > +class ACE_Array_Map +{ +public: + + // STL-style typedefs/traits. + typedef Key key_type; + typedef Value data_type; + typedef std::pair value_type; + typedef value_type * iterator; + typedef value_type const * const_iterator; + typedef value_type & reference; + typedef value_type const & const_reference; + typedef value_type * pointer; + typedef value_type const * const_pointer; + typedef ptrdiff_t difference_type; + typedef size_t size_type; + + ACE_DECLARE_STL_REVERSE_ITERATORS + + /// Default Constructor. + /** + * Create an empty map with a preallocated buffer of size @a s. + */ + ACE_Array_Map (size_type s = 0); + +#ifndef ACE_LACKS_MEMBER_TEMPLATES + template + ACE_Array_Map (InputIterator f, InputIterator l); +#else + ACE_Array_Map (const_iterator f, const_iterator l); +#endif /* !ACE_LACKS_MEMBER_TEMPLATES */ + + ACE_Array_Map (ACE_Array_Map const & map); + ACE_Array_Map & operator= (ACE_Array_Map const & map); + + /// Destructor. + ~ACE_Array_Map (void); + + /** + * @name Forward Iterator Accessors + * + * Forward iterator accessors. + */ + //@{ + iterator begin (void); + iterator end (void); + const_iterator begin (void) const; + const_iterator end (void) const; + //@} + + /** + * @name Reverse Iterator Accessors + * + * Reverse iterator accessors. + */ + //@{ + reverse_iterator rbegin (void); + reverse_iterator rend (void); + const_reverse_iterator rbegin (void) const; + const_reverse_iterator rend (void) const; + //@} + + /// Return current size of map. + /** + * @return The number of elements in the map. + */ + size_type size (void) const; + + /// Maximum number of elements the map can hold. + size_type max_size (void) const; + + /// Return @c true if the map is empty, else @c false. + bool is_empty (void) const; // ACE style + + /** + * Return @c true if the map is empty, else @c false. We recommend + * using @c is_empty() instead since it's more consistent with the + * ACE container naming conventions. + */ + bool empty (void) const; // STL style + + /// Swap the contents of this map with the given @a map in an + /// exception-safe manner. + void swap (ACE_Array_Map & map); + + /// Insert the value @a x into the map. + /** + * STL-style map insertion method. + * + * @param x @c std::pair containing key and datum. + * + * @return @c std::pair::second will be @c false if the map already + * contains a value with the same key as @a x. + */ + std::pair insert (value_type const & x); + +#ifndef ACE_LACKS_MEMBER_TEMPLATES + /// Insert range of elements into map. + template + void insert (InputIterator f, InputIterator l); +#else + /// Insert range of elements into map. + void insert (const_iterator f, const_iterator l); +#endif /* ACE_LACKS_MEMBER_TEMPLATES */ + + /// Remove element at position @a pos from the map. + void erase (iterator pos); + + /// Remove element corresponding to key @a k from the map. + /** + * @return Number of elements that were erased. + */ + size_type erase (key_type const & k); + + /// Remove range of elements [@a first, @a last) from the map. + /** + * @note [@a first, @a last) must be valid range within the map. + */ + void erase (iterator first, iterator last); + + /// Clear contents of map. + /** + * @note This a constant time (O(1)) operation. + */ + void clear (void); + + /** + * @name Search Operations + * + * Search the map for data corresponding to key @a k. + */ + //@{ + /** + * @return @c end() if data corresponding to key @a k is not in the + * map. + */ + iterator find (key_type const & k); + + /** + * @return @c end() if data corresponding to key @a k is not in the + * map. + */ + const_iterator find (key_type const & k) const; + //@} + + /// Count the number of elements corresponding to key @a k. + /** + * @return In the case of this map, the count will always be one if + * such exists in the map. + */ + size_type count (key_type const & k); + + /// Convenience array index operator. + /** + * Array index operator that allows insertion and retrieval of + * elements using an array index syntax, such as: + * @par + * map["Foo"] = 12; + */ + data_type & operator[] (key_type const & k); + +private: + + /// Increase size of underlying buffer by @a s. + void grow (size_type s); + +private: + + /// Number of elements in the map. + size_type size_; + + /// Current size of underlying array. + /** + * @note @c capacity_ is always greater than or equal to @c size_; + */ + size_type capacity_; + + /// Underlying array containing keys and data. + value_type * nodes_; + +}; + +// -------------------------------------------------------------- + +/// @c ACE_Array_Map equality operator. +template +bool operator== (ACE_Array_Map const & lhs, + ACE_Array_Map const & rhs); + +/// @c ACE_Array_Map lexicographical comparison operator. +template +bool operator< (ACE_Array_Map const & lhs, + ACE_Array_Map const & rhs); + +// -------------------------------------------------------------- + +ACE_END_VERSIONED_NAMESPACE_DECL + +#ifdef __ACE_INLINE__ +# include "ace/Array_Map.inl" +#endif /* __ACE_INLINE__ */ + +#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) +# include "ace/Array_Map.cpp" +#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ + +#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) +#pragma implementation ("Array_Map.cpp") +#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ + +#include /**/ "ace/post.h" + +#endif /* ACE_ARRAY_MAP_H */ diff --git a/dep/ACE_wrappers/ace/Array_Map.inl b/dep/ACE_wrappers/ace/Array_Map.inl new file mode 100644 index 00000000000..b053dc0a441 --- /dev/null +++ b/dep/ACE_wrappers/ace/Array_Map.inl @@ -0,0 +1,133 @@ +// -*- C++ -*- +// +// $Id: Array_Map.inl 80826 2008-03-04 14:51:23Z wotte $ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +template +ACE_INLINE +ACE_Array_Map::ACE_Array_Map ( + typename ACE_Array_Map::size_type s) + : size_ (0) + , capacity_ (s) + , nodes_ (s == 0 ? 0 : new value_type[s]) +{ +} + +template +ACE_INLINE ACE_Array_Map & +ACE_Array_Map::operator= ( + ACE_Array_Map const & map) +{ + // Strongly exception-safe assignment. + + ACE_Array_Map temp (map); + this->swap (temp); + return *this; +} + +template +ACE_INLINE typename ACE_Array_Map::iterator +ACE_Array_Map::begin (void) +{ + return this->nodes_; +} + +template +ACE_INLINE typename ACE_Array_Map::iterator +ACE_Array_Map::end (void) +{ + return this->nodes_ + this->size_; +} + +template +ACE_INLINE typename ACE_Array_Map::const_iterator +ACE_Array_Map::begin (void) const +{ + return this->nodes_; +} + +template +ACE_INLINE typename ACE_Array_Map::const_iterator +ACE_Array_Map::end (void) const +{ + return this->nodes_ + this->size_; +} + +template +ACE_INLINE typename ACE_Array_Map::reverse_iterator +ACE_Array_Map::rbegin (void) +{ + return reverse_iterator (this->end ()); +} + +template +ACE_INLINE typename ACE_Array_Map::reverse_iterator +ACE_Array_Map::rend (void) +{ + return reverse_iterator (this->begin ()); +} + +template +ACE_INLINE typename ACE_Array_Map::const_reverse_iterator +ACE_Array_Map::rbegin (void) const +{ + return const_reverse_iterator (this->end ()); +} + +template +ACE_INLINE typename ACE_Array_Map::const_reverse_iterator +ACE_Array_Map::rend (void) const +{ + return const_reverse_iterator (this->begin ()); +} + +template +ACE_INLINE typename ACE_Array_Map::size_type +ACE_Array_Map::size (void) const +{ + return this->size_; +} + +template +ACE_INLINE typename ACE_Array_Map::size_type +ACE_Array_Map::max_size (void) const +{ + return size_type (-1) / sizeof (value_type); +} + +template +ACE_INLINE bool +ACE_Array_Map::is_empty (void) const +{ + return this->size_ == 0; +} + +// The following method is deprecated. + +template +ACE_INLINE bool +ACE_Array_Map::empty (void) const +{ + return this->is_empty (); +} + +template +ACE_INLINE typename ACE_Array_Map::size_type +ACE_Array_Map::count ( + typename ACE_Array_Map::key_type const & k) +{ + return + (this->find (k) == this->end () ? 0 : 1); // Only one datum per key. +} + +template +ACE_INLINE typename ACE_Array_Map::data_type & +ACE_Array_Map::operator[] ( + typename ACE_Array_Map::key_type const & k) +{ + iterator i = (this->insert (value_type (k, data_type ()))).first; + return (*i).second; +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Assert.cpp b/dep/ACE_wrappers/ace/Assert.cpp new file mode 100644 index 00000000000..4a71c9e5a9d --- /dev/null +++ b/dep/ACE_wrappers/ace/Assert.cpp @@ -0,0 +1,24 @@ +// $Id: Assert.cpp 80826 2008-03-04 14:51:23Z wotte $ + +#include "ace/Assert.h" +#include "ace/Log_Msg.h" + +ACE_RCSID(ace, Assert, "$Id: Assert.cpp 80826 2008-03-04 14:51:23Z wotte $") + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +// The following ASSERT macro is courtesy of Alexandre Karev +// . +void +__ace_assert(const char *file, int line, const ACE_TCHAR *expression) +{ + int error = ACE_Log_Msg::last_error_adapter (); + ACE_Log_Msg *log = ACE_Log_Msg::instance (); + + log->set (file, line, -1, error, log->restart (), + log->msg_ostream (), log->msg_callback ()); + + log->log (LM_ERROR, ACE_TEXT ("ACE_ASSERT: file %N, line %l assertion failed for '%s'.%a\n"), expression, -1); +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Assert.h b/dep/ACE_wrappers/ace/Assert.h new file mode 100644 index 00000000000..cf28a4a89fe --- /dev/null +++ b/dep/ACE_wrappers/ace/Assert.h @@ -0,0 +1,38 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Assert.h + * + * $Id: Assert.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Douglas C. Schmidt + */ +//============================================================================= + +#ifndef ACE_ASSERT_H +#define ACE_ASSERT_H + +#include /**/ "ace/pre.h" + +#include /**/ "ace/ACE_export.h" + +#include /**/ "ace/config-all.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL +ACE_Export void __ace_assert(const char *file, int line, const ACE_TCHAR *expression); +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (ACE_NDEBUG) +#define ACE_ASSERT(x) \ + (static_cast(0)) +#else +#define ACE_ASSERT(X) \ + ((X) \ + ? static_cast(0) \ + : ACE_VERSIONED_NAMESPACE_NAME::__ace_assert(__FILE__, __LINE__, ACE_TEXT_CHAR_TO_TCHAR (#X))) +#endif /* ACE_NDEBUG */ + +#include /**/ "ace/post.h" + +#endif /* ACE_ASSERT */ diff --git a/dep/ACE_wrappers/ace/Asynch_Acceptor.cpp b/dep/ACE_wrappers/ace/Asynch_Acceptor.cpp new file mode 100644 index 00000000000..12aeebe0db6 --- /dev/null +++ b/dep/ACE_wrappers/ace/Asynch_Acceptor.cpp @@ -0,0 +1,514 @@ +/* -*- C++ -*- */ +// $Id: Asynch_Acceptor.cpp 82444 2008-07-28 13:33:07Z johnnyw $ + +#ifndef ACE_ASYNCH_ACCEPTOR_C +#define ACE_ASYNCH_ACCEPTOR_C + +#include "ace/Asynch_Acceptor.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +ACE_RCSID(ace, Asynch_Acceptor, "$Id: Asynch_Acceptor.cpp 82444 2008-07-28 13:33:07Z johnnyw $") + +#if defined (ACE_HAS_WIN32_OVERLAPPED_IO) || defined (ACE_HAS_AIO_CALLS) +// This only works on platforms that support async i/o. + +#include "ace/OS_Errno.h" +#include "ace/OS_Memory.h" +#include "ace/OS_NS_sys_socket.h" +#include "ace/Log_Msg.h" +#include "ace/Message_Block.h" +#include "ace/INET_Addr.h" +#include "ace/SOCK_Stream.h" +#include "ace/Sock_Connect.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +template +ACE_Asynch_Acceptor::ACE_Asynch_Acceptor (void) + : listen_handle_ (ACE_INVALID_HANDLE), + pass_addresses_ (false), + validate_new_connection_ (false), + reissue_accept_ (1), + bytes_to_read_ (0) +{ +} + +template +ACE_Asynch_Acceptor::~ACE_Asynch_Acceptor (void) +{ + // Close down the listen socket + if (this->listen_handle_ != ACE_INVALID_HANDLE) + { + ACE_OS::closesocket (this->listen_handle_); + this->listen_handle_ = ACE_INVALID_HANDLE; + } +} + +template int +ACE_Asynch_Acceptor::open (const ACE_INET_Addr &address, + size_t bytes_to_read, + bool pass_addresses, + int backlog, + int reuse_addr, + ACE_Proactor *proactor, + bool validate_new_connection, + int reissue_accept, + int number_of_initial_accepts) +{ + ACE_TRACE ("ACE_Asynch_Acceptor<>::open"); + + this->proactor (proactor); + this->pass_addresses_ = pass_addresses; + this->bytes_to_read_ = bytes_to_read; + this->validate_new_connection_ = validate_new_connection; + this->reissue_accept_ = reissue_accept; + this->addr_family_ = address.get_type (); + + // Create the listener socket + this->listen_handle_ = ACE_OS::socket (address.get_type (), SOCK_STREAM, 0); + if (this->listen_handle_ == ACE_INVALID_HANDLE) + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("%p\n"), + ACE_TEXT ("ACE_OS::socket")), + -1); + // Initialize the ACE_Asynch_Accept + if (this->asynch_accept_.open (*this, + this->listen_handle_, + 0, + this->proactor ()) == -1) + { + ACE_Errno_Guard g (errno); + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("%p\n"), + ACE_TEXT ("ACE_Asynch_Accept::open"))); + ACE_OS::closesocket (this->listen_handle_); + this->listen_handle_ = ACE_INVALID_HANDLE; + return -1; + } + + if (reuse_addr) + { + // Reuse the address + int one = 1; + if (ACE_OS::setsockopt (this->listen_handle_, + SOL_SOCKET, + SO_REUSEADDR, + (const char*) &one, + sizeof one) == -1) + { + ACE_Errno_Guard g (errno); + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("%p\n"), + ACE_TEXT ("ACE_OS::setsockopt"))); + ACE_OS::closesocket (this->listen_handle_); + this->listen_handle_ = ACE_INVALID_HANDLE; + return -1; + } + } + + // If port is not specified, bind to any port. + static ACE_INET_Addr sa (ACE_sap_any_cast (const ACE_INET_Addr &)); + + if (address == sa && + ACE::bind_port (this->listen_handle_, + INADDR_ANY, + address.get_type()) == -1) + { + ACE_Errno_Guard g (errno); + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("%p\n"), + ACE_TEXT ("ACE::bind_port"))); + ACE_OS::closesocket (this->listen_handle_); + this->listen_handle_ = ACE_INVALID_HANDLE; + return -1; + } + + // Bind to the specified port. + if (ACE_OS::bind (this->listen_handle_, + reinterpret_cast (address.get_addr ()), + address.get_size ()) == -1) + { + ACE_Errno_Guard g (errno); + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("%p\n"), + ACE_TEXT ("ACE_OS::bind"))); + ACE_OS::closesocket (this->listen_handle_); + this->listen_handle_ = ACE_INVALID_HANDLE; + return -1; + } + + // Start listening. + if (ACE_OS::listen (this->listen_handle_, backlog) == -1) + { + ACE_Errno_Guard g (errno); + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("%p\n"), + ACE_TEXT ("ACE_OS::listen"))); + ACE_OS::closesocket (this->listen_handle_); + this->listen_handle_ = ACE_INVALID_HANDLE; + return -1; + } + + // For the number of . + if (number_of_initial_accepts == -1) + number_of_initial_accepts = backlog; + + for (int i = 0; i < number_of_initial_accepts; i++) + { + // Initiate accepts. + if (this->accept (bytes_to_read) == -1) + { + ACE_Errno_Guard g (errno); + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("%p\n"), + ACE_TEXT ("ACE_Asynch_Acceptor::accept"))); + ACE_OS::closesocket (this->listen_handle_); + this->listen_handle_ = ACE_INVALID_HANDLE; + return -1; + } + } + + return 0; +} + +template int +ACE_Asynch_Acceptor::set_handle (ACE_HANDLE listen_handle) +{ + ACE_TRACE ("ACE_Asynch_Acceptor<>::set_handle"); + + // Take ownership of the + this->listen_handle_ = listen_handle; + + // Reinitialize the ACE_Asynch_Accept + if (this->asynch_accept_.open (*this, + this->listen_handle_, + 0, + this->proactor ()) == -1) + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("%p\n"), + ACE_TEXT ("ACE_Asynch_Accept::open")), + -1); + return 0; +} + +template ACE_HANDLE +ACE_Asynch_Acceptor::get_handle (void) const +{ + return this->listen_handle_; +} + +template int +ACE_Asynch_Acceptor::accept (size_t bytes_to_read, const void *act) +{ + ACE_TRACE ("ACE_Asynch_Acceptor<>::accept"); + + ACE_Message_Block *message_block = 0; + // The space_needed calculation is drive by needs of Windows. POSIX doesn't + // need to extra 16 bytes, but it doesn't hurt. + size_t space_needed = sizeof (sockaddr_in) + 16; +#if defined (ACE_HAS_IPV6) + if (PF_INET6 == this->addr_family_) + space_needed = sizeof (sockaddr_in6) + 16; +#endif /* ACE_HAS_IPV6 */ + space_needed = (2 * space_needed) + bytes_to_read; + + // Create a new message block big enough for the addresses and data + ACE_NEW_RETURN (message_block, + ACE_Message_Block (space_needed), + -1); + + // Initiate asynchronous accepts + if (this->asynch_accept_.accept (*message_block, + bytes_to_read, + ACE_INVALID_HANDLE, + act, + 0, + ACE_SIGRTMIN, + this->addr_family_) == -1) + { + // Cleanup on error + message_block->release (); + return -1; + } + return 0; +} + +template void +ACE_Asynch_Acceptor::handle_accept (const ACE_Asynch_Accept::Result &result) +{ + ACE_TRACE ("ACE_Asynch_Acceptor<>::handle_accept"); + + // Variable for error tracking + int error = 0; + + // If the asynchronous accept fails. + if (!result.success () || result.accept_handle () == ACE_INVALID_HANDLE) + { + error = 1; + } + +#if defined (ACE_WIN32) + // In order to use accept handle with other Window Sockets 1.1 + // functions, we call the setsockopt function with the + // SO_UPDATE_ACCEPT_CONTEXT option. This option initializes the + // socket so that other Windows Sockets routines to access the + // socket correctly. + if (!error && + ACE_OS::setsockopt (result.accept_handle (), + SOL_SOCKET, + SO_UPDATE_ACCEPT_CONTEXT, + (char *) &this->listen_handle_, + sizeof (this->listen_handle_)) == -1) + { + error = 1; + } +#endif /* ACE_WIN32 */ + + // Parse address. + ACE_INET_Addr local_address; + ACE_INET_Addr remote_address; + if (!error && + (this->validate_new_connection_ || this->pass_addresses_)) + // Parse the addresses. + this->parse_address (result, + remote_address, + local_address); + + // Validate remote address + if (!error && + this->validate_new_connection_ && + (this->validate_connection (result, remote_address, local_address) == -1)) + { + error = 1; + } + + HANDLER *new_handler = 0; + if (!error) + { + // The Template method + new_handler = this->make_handler (); + if (new_handler == 0) + { + error = 1; + } + } + + // If no errors + if (!error) + { + // Update the Proactor. + new_handler->proactor (this->proactor ()); + + // Pass the addresses + if (this->pass_addresses_) + new_handler->addresses (remote_address, + local_address); + + // Pass the ACT + if (result.act () != 0) + new_handler->act (result.act ()); + + // Set up the handler's new handle value + new_handler->handle (result.accept_handle ()); + + // Initiate the handler + new_handler->open (result.accept_handle (), + result.message_block ()); + } + + // On failure, no choice but to close the socket + if (error && + result.accept_handle() != ACE_INVALID_HANDLE ) + ACE_OS::closesocket (result.accept_handle ()); + + // Delete the dynamically allocated message_block + result.message_block ().release (); + + // Start off another asynchronous accept to keep the backlog going, + // unless we closed the listen socket already (from the destructor), + // or this callback is the result of a canceled/aborted accept. + if (this->should_reissue_accept () && + this->listen_handle_ != ACE_INVALID_HANDLE +#if defined (ACE_WIN32) + && result.error () != ERROR_OPERATION_ABORTED +#else + && result.error () != ECANCELED +#endif + ) + this->accept (this->bytes_to_read_); +} + +template int +ACE_Asynch_Acceptor::validate_connection + (const ACE_Asynch_Accept::Result& /* result */, + const ACE_INET_Addr& /* remote */, + const ACE_INET_Addr& /* local */) +{ + // Default implementation always validates the remote address. + return 0; +} + +template int +ACE_Asynch_Acceptor::cancel (void) +{ + ACE_TRACE ("ACE_Asynch_Acceptor<>::cancel"); + + // All I/O operations that are canceled will complete with the error + // ERROR_OPERATION_ABORTED. All completion notifications for the I/O + // operations will occur normally. +#if defined (ACE_HAS_WIN32_OVERLAPPED_IO) + return (int) ::CancelIo (this->listen_handle_); +#else + // Supported now + return this->asynch_accept_.cancel(); +#endif /* defined (ACE_HAS_WIN32_OVERLAPPED_IO) */ +} + +template void +ACE_Asynch_Acceptor::parse_address (const + ACE_Asynch_Accept::Result &result, + ACE_INET_Addr &remote_address, + ACE_INET_Addr &local_address) +{ + ACE_TRACE ("ACE_Asynch_Acceptor<>::parse_address"); + +#if defined (ACE_HAS_AIO_CALLS) + + // Use an ACE_SOCK to get the addresses - it knows how to deal with + // ACE_INET_Addr objects and get IPv4/v6 addresses. + ACE_SOCK_Stream str (result.accept_handle ()); + str.get_local_addr (local_address); + str.get_remote_addr (remote_address); + +#elif defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) + + ACE_Message_Block &message_block = result.message_block (); + + sockaddr *local_addr = 0; + sockaddr *remote_addr = 0; + int local_size = 0; + int remote_size = 0; + // This matches setup in accept(). + size_t addr_size = sizeof (sockaddr_in) + 16; +#if defined (ACE_HAS_IPV6) + if (this->addr_family_ == PF_INET6) + addr_size = sizeof (sockaddr_in6) + 16; +#endif /* ACE_HAS_IPV6 */ + + ::GetAcceptExSockaddrs (message_block.rd_ptr (), + static_cast (this->bytes_to_read_), + static_cast (addr_size), + static_cast (addr_size), + &local_addr, + &local_size, + &remote_addr, + &remote_size); + + local_address.set (reinterpret_cast (local_addr), + local_size); + remote_address.set (reinterpret_cast (remote_addr), + remote_size); +#else + // just in case + errno = ENOTSUP; +#endif /* defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) */ + return; +} + +template ACE_HANDLE +ACE_Asynch_Acceptor::handle (void) const +{ + return this->listen_handle_; +} + +template void +ACE_Asynch_Acceptor::handle (ACE_HANDLE h) +{ + ACE_Handler::handle (h); +} + +template ACE_Asynch_Accept & +ACE_Asynch_Acceptor::asynch_accept (void) +{ + return this->asynch_accept_; +} + +template HANDLER * +ACE_Asynch_Acceptor::make_handler (void) +{ + // Default behavior + HANDLER *handler = 0; + ACE_NEW_RETURN (handler, + HANDLER, + 0); + return handler; +} + +/* static */ +template size_t +ACE_Asynch_Acceptor::address_size (void) +{ + return sizeof (sockaddr) + sizeof (sockaddr_in); +} + +template bool +ACE_Asynch_Acceptor::pass_addresses (void) const +{ + return this->pass_addresses_; +} + +template void +ACE_Asynch_Acceptor::pass_addresses (bool new_value) +{ + this->pass_addresses_ = new_value; +} + +template bool +ACE_Asynch_Acceptor::validate_new_connection (void) const +{ + return this->validate_new_connection_; +} + +template void +ACE_Asynch_Acceptor::validate_new_connection (bool new_value) +{ + this->validate_new_connection_ = new_value; +} + +template int +ACE_Asynch_Acceptor::reissue_accept (void) const +{ + return this->reissue_accept_; +} + +template void +ACE_Asynch_Acceptor::reissue_accept (int new_value) +{ + this->reissue_accept_ = new_value; +} + +template size_t +ACE_Asynch_Acceptor::bytes_to_read (void) const +{ + return this->bytes_to_read_; +} + +template void +ACE_Asynch_Acceptor::bytes_to_read (size_t new_value) +{ + this->bytes_to_read_ = new_value; +} + +template int +ACE_Asynch_Acceptor::should_reissue_accept (void) +{ + return this->reissue_accept_; +} + +ACE_END_VERSIONED_NAMESPACE_DECL + +#endif /* ACE_WIN32 || ACE_HAS_AIO_CALLS */ +#endif /* ACE_ASYNCH_ACCEPTOR_C */ diff --git a/dep/ACE_wrappers/ace/Asynch_Acceptor.h b/dep/ACE_wrappers/ace/Asynch_Acceptor.h new file mode 100644 index 00000000000..29872d59482 --- /dev/null +++ b/dep/ACE_wrappers/ace/Asynch_Acceptor.h @@ -0,0 +1,281 @@ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file Asynch_Acceptor.h + * + * $Id: Asynch_Acceptor.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Irfan Pyarali (irfan@cs.wustl.edu) + */ +//============================================================================= + +#ifndef ACE_ASYNCH_ACCEPTOR_H +#define ACE_ASYNCH_ACCEPTOR_H +#include /**/ "ace/pre.h" + +#include /**/ "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#if defined (ACE_HAS_WIN32_OVERLAPPED_IO) || defined (ACE_HAS_AIO_CALLS) +// This only works on platforms that support async i/o. + +#include "ace/Default_Constants.h" +#include "ace/Asynch_IO.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +// Forward declarations +class ACE_Message_Block; +class ACE_INET_Addr; + +/** + * @class ACE_Asynch_Acceptor + * + * @brief This class is an example of the Acceptor Pattern. This class + * will accept new connections and create new HANDLER to handle + * the new connections. + * + * Unlike the ACE_Acceptor, however, this class is designed to + * be used asynchronously. + */ +template +class ACE_Asynch_Acceptor : public ACE_Handler +{ +public: + /// A do nothing constructor. + ACE_Asynch_Acceptor (void); + + /// Virtual destruction + virtual ~ACE_Asynch_Acceptor (void); + + /** + * @c open starts one or more asynchronous accept requests on a + * @a address. Each accept operation may optionally read an + * initial buffer from the new connection when accepted. + * + * @param address The address to listen/accept connections on. + * If the address does not specify a port, a random + * port is selected and bound. + * @param bytes_to_read Optional, specifies the maximum number of bytes + * to read with the accept. The buffer for the initial + * data is allocated internally and passed to the + * @c ACE_Service_Handler::open() hook method. It is + * legitimate only during the @c open() method and must + * be copied if required after @c open() returns. + * This pre-read function works only on Windows. + * @param pass_addresses Optional, a non-zero value indicates that + * the local and peer addresses should be passed to the + * associated @c ACE_Service_Handler::addresses() method + * after any call to @c validate_new_connection() and prior + * to the @c open() hook method call. + * @param backlog Optional, defaulting to @c ACE_DEFAULT_ASYNCH_BACKLOG (which + * can be adjusted in your platform's @c config.h file). + * Specifies the listening backlog for the listening socket. + * @param reuse_addr Optional, indicates whether the @c SO_REUSEADDR + * option is set on the listening socket or not. + * @param proactor Optional, pointer to the @c ACE_Proactor to use for + * demultiplexing asynchronous accepts. If 0, the + * process's singleton @c ACE_Proactor is used. + * @param validate_new_connection Optional, if true, this object's + * @c validate_connection() method is called after + * the accept completes, but before the service handler's + * @c open() hook method is called. If @c + * validate_connection() returns -1, the newly-accepted + * socket is immediately closed, and the @c addresses() + * method is not called. + * @param reissue_accept Optional, if non-zero (the default), a new + * asynchronous accept operation is started after each + * completion, whether the completion is for success or + * failure, and whether or not a successfully-accepted + * connection is subsequently refused. + * @param number_of_initial_accepts Optional, the number of asynchronous + * accepts that are started immediately. If -1 (the + * default), the value of @a backlog is used. + * + * @note On Windows, the peer address is only available at the time + * the connection is accepted. Therefore, if you require the peer + * address on Windows, do not rely on the + * @c ACE_SOCK::get_remote_addr() method - it won't work. You must + * supply a non-zero value for @a pass_addresses and obtain the + * peer address in the @c ACE_Service_Handler::addresses() method. + * + * @see ACE_INET_Addr + * @see ACE_Service_Handler + */ + virtual int open (const ACE_INET_Addr &address, + size_t bytes_to_read = 0, + bool pass_addresses = false, + int backlog = ACE_DEFAULT_ASYNCH_BACKLOG, + int reuse_addr = 1, + ACE_Proactor *proactor = 0, + bool validate_new_connection = false, + int reissue_accept = 1, + int number_of_initial_accepts = -1); + + /// Get the underlying handle. + virtual ACE_HANDLE get_handle (void) const; + + /** + * Set the underlying listen handle. It is the user's responsibility + * to make sure that the old listen handle has been appropriately + * closed and the all outstanding asynchronous operations have + * either completed or have been canceled on the old listen handle. + */ + virtual int set_handle (ACE_HANDLE handle); + + /// This initiates a new asynchronous accept operation. + /** + * You need only call this method if the @a reissue_accept argument + * passed to @c open() was 0. + */ + virtual int accept (size_t bytes_to_read = 0, const void *act = 0); + + /** + * Cancels all pending accepts operations issued by this object. + * + * @note On Windows, only accept operations initiated by the calling thread + * are canceled. + */ + virtual int cancel (void); + + /** + * Template method to validate peer before service is opened. + * This method is called after a new connection is accepted if the + * @a validate_connection argument to @c open() was non-zero or + * the @c validate_new_connection() method is called to turn this + * feature on. The default implementation returns 0. Users can + * reimplement this method to perform validation of the peer + * using it's address, running an authentication procedure (such as + * SSL) or anything else necessary or desireable. The return value + * from this method determines whether or not ACE will continue + * opening the service or abort the connection. + * + * @param result Result of the connection acceptance. + * @param remote Peer's address. + * @param local Local address connection was accepted at. + * + * @retval -1 ACE_Asynch_Acceptor will close the connection, and + * the service will not be opened. + * @retval 0 Service opening will proceeed. + */ + virtual int validate_connection (const ACE_Asynch_Accept::Result& result, + const ACE_INET_Addr &remote, + const ACE_INET_Addr& local); + + /** + * Template method for deciding whether to reissue accept. + * + * This hook method is called after each accept completes to decide if + * another accept should be initiated. If the method returns a non-zero + * value, another accept is initiated. + * + * The default implemenation always returns the value passed as the + * @c open() method's @a reissue_accept argument. That value can also + * be changed using the @c reissue_accept() method. + */ + virtual int should_reissue_accept (void); + + // + // These are low level tweaking methods + // + + /// Get flag that indicates if parsing and passing of addresses to + /// the service_handler is necessary. + virtual bool pass_addresses (void) const; + + /// Set flag that indicates if parsing and passing of addresses to + /// the service_handler is necessary. + virtual void pass_addresses (bool new_value); + + /// Get flag that indicates if address validation is required. + virtual bool validate_new_connection (void) const; + + /// Set flag that indicates if address validation is required. + virtual void validate_new_connection (bool new_value); + + /// Get flag that indicates if a new accept should be reissued when a accept + /// completes. + virtual int reissue_accept (void) const; + + /// Set flag that indicates if a new accept should be reissued when a accept + /// completes. + virtual void reissue_accept (int new_value); + + /// Get bytes to be read with the call. + virtual size_t bytes_to_read (void) const; + + /// Set bytes to be read with the call. + virtual void bytes_to_read (size_t new_value); + + /// @deprecated address_size() assumes IPv4 use, so is not always valid. + /// This method will be removed after ACE 5.5. Internal uses have been + /// changes to base needed sizes on the addr_family_ member. + static size_t address_size (void); + +protected: + + /// This is called when an outstanding accept completes. + virtual void handle_accept (const ACE_Asynch_Accept::Result &result); + + /// Return the listen handle. + ACE_HANDLE handle (void) const; + /// Set the listen handle. + void handle (ACE_HANDLE h); + + /// This parses the address from read buffer. + void parse_address (const ACE_Asynch_Accept::Result &result, + ACE_INET_Addr &remote_address, + ACE_INET_Addr &local_address); + + /// Return the asynch accept object. + ACE_Asynch_Accept &asynch_accept (void); + + /** + * This is the template method used to create new handler. + * Subclasses must overwrite this method if a new handler creation + * strategy is required. + */ + virtual HANDLER *make_handler (void); + +private: + /// Handle used to listen for new connections. + ACE_HANDLE listen_handle_; + + /// Asynch_Accept used to make life easier :-) + ACE_Asynch_Accept asynch_accept_; + + /// Flag that indicates if parsing of addresses is necessary. + bool pass_addresses_; + + /// Flag that indicates if address validation is required. + bool validate_new_connection_; + + /// Flag that indicates if a new accept should be reissued when a + /// accept completes. + int reissue_accept_; + + /// Bytes to be read with the call. + size_t bytes_to_read_; + + /// Address family used to open this object. Obtained from @a address passed + /// to @c open(). + int addr_family_; +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) +#include "ace/Asynch_Acceptor.cpp" +#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ + +#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) +#pragma implementation ("Asynch_Acceptor.cpp") +#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ + +#endif /* ACE_HAS_WIN32_OVERLAPPED_IO || ACE_HAS_AIO_CALLS */ +#include /**/ "ace/post.h" +#endif /* ACE_ASYNCH_ACCEPTOR_H */ diff --git a/dep/ACE_wrappers/ace/Asynch_Connector.cpp b/dep/ACE_wrappers/ace/Asynch_Connector.cpp new file mode 100644 index 00000000000..3d493069f00 --- /dev/null +++ b/dep/ACE_wrappers/ace/Asynch_Connector.cpp @@ -0,0 +1,296 @@ +// $Id: Asynch_Connector.cpp 80826 2008-03-04 14:51:23Z wotte $ + +#ifndef ACE_ASYNCH_CONNECTOR_CPP +#define ACE_ASYNCH_CONNECTOR_CPP + +#include "ace/Asynch_Connector.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#if (defined (ACE_WIN32) || defined (ACE_HAS_AIO_CALLS)) && !defined(ACE_HAS_WINCE) +// This only works on platforms that support async I/O. + +#include "ace/OS_NS_sys_socket.h" +#include "ace/OS_Memory.h" +#include "ace/Flag_Manip.h" +#include "ace/Log_Msg.h" +#include "ace/Message_Block.h" +#include "ace/INET_Addr.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +template +ACE_Asynch_Connector::ACE_Asynch_Connector (void) + : pass_addresses_ (false), + validate_new_connection_ (false) +{ +} + +template +ACE_Asynch_Connector::~ACE_Asynch_Connector (void) +{ + //this->asynch_connect_.close (); +} + +template int +ACE_Asynch_Connector::open (bool pass_addresses, + ACE_Proactor *proactor, + bool validate_new_connection) +{ + this->proactor (proactor); + this->pass_addresses_ = pass_addresses; + this->validate_new_connection_ = validate_new_connection; + + // Initialize the ACE_Asynch_Connect + if (this->asynch_connect_.open (*this, + ACE_INVALID_HANDLE, + 0, + this->proactor ()) == -1) + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("%p\n"), + ACE_TEXT ("ACE_Asynch_Connect::open")), + -1); + return 0; +} + +template int +ACE_Asynch_Connector::connect (const ACE_INET_Addr & remote_sap, + const ACE_INET_Addr & local_sap, + int reuse_addr, + const void *act) +{ + // Initiate asynchronous connect + if (this->asynch_connect_.connect (ACE_INVALID_HANDLE, + remote_sap, + local_sap, + reuse_addr, + act) == -1) + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("%p\n"), + ACE_TEXT ("ACE_Asynch_Connect::connect")), + -1); + return 0; +} + +template void +ACE_Asynch_Connector::handle_connect (const ACE_Asynch_Connect::Result &result) +{ + // Variable for error tracking + int error = 0; + + // If the asynchronous connect fails. + if (!result.success () || + result.connect_handle () == ACE_INVALID_HANDLE) + { + error = 1; + } + + if (result.error () != 0) + { + error = 1; + } + + // set blocking mode + if (!error && + ACE::clr_flags + (result.connect_handle (), ACE_NONBLOCK) != 0) + { + error = 1; + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("%p\n"), + ACE_TEXT ("ACE_Asynch_Connector::handle_connect : Set blocking mode"))); + } + + // Parse the addresses. + ACE_INET_Addr local_address; + ACE_INET_Addr remote_address; + if (!error && + (this->validate_new_connection_ || this->pass_addresses_)) + this->parse_address (result, + remote_address, + local_address); + + // Call validate_connection even if there was an error - it's the only + // way the application can learn the connect disposition. + if (this->validate_new_connection_ && + this->validate_connection (result, remote_address, local_address) == -1) + { + error = 1; + } + + HANDLER *new_handler = 0; + if (!error) + { + // The Template method + new_handler = this->make_handler (); + if (new_handler == 0) + { + error = 1; + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("%p\n"), + ACE_TEXT ("ACE_Asynch_Connector::handle_connect : Making of new handler failed"))); + } + } + + // If no errors + if (!error) + { + // Update the Proactor. + new_handler->proactor (this->proactor ()); + + // Pass the addresses + if (this->pass_addresses_) + new_handler->addresses (remote_address, + local_address); + + // Pass the ACT + if (result.act () != 0) + new_handler->act (result.act ()); + + // Set up the handler's new handle value + new_handler->handle (result.connect_handle ()); + + ACE_Message_Block mb; + + // Initiate the handler with empty message block; + new_handler->open (result.connect_handle (), mb); + } + + // On failure, no choice but to close the socket + if (error && + result.connect_handle() != ACE_INVALID_HANDLE) + ACE_OS::closesocket (result.connect_handle ()); +} + +template int +ACE_Asynch_Connector::validate_connection + (const ACE_Asynch_Connect::Result &, + const ACE_INET_Addr & /* remote_address */, + const ACE_INET_Addr & /* local_address */) +{ + // Default implementation always validates the remote address. + return 0; +} + +template int +ACE_Asynch_Connector::cancel (void) +{ + return this->asynch_connect_.cancel (); +} + +template void +ACE_Asynch_Connector::parse_address (const ACE_Asynch_Connect::Result &result, + ACE_INET_Addr &remote_address, + ACE_INET_Addr &local_address) +{ +#if defined (ACE_HAS_IPV6) + // Getting the addresses. + sockaddr_in6 local_addr; + sockaddr_in6 remote_addr; +#else + // Getting the addresses. + sockaddr_in local_addr; + sockaddr_in remote_addr; +#endif /* ACE_HAS_IPV6 */ + + // Get the length. + int local_size = sizeof (local_addr); + int remote_size = sizeof (remote_addr); + + // Get the local address. + if (ACE_OS::getsockname (result.connect_handle (), + reinterpret_cast (&local_addr), + &local_size) < 0) + ACE_ERROR ((LM_ERROR, + ACE_TEXT("%p\n"), + ACE_TEXT("ACE_Asynch_Connector:: failed"))); + + // Get the remote address. + if (ACE_OS::getpeername (result.connect_handle (), + reinterpret_cast (&remote_addr), + &remote_size) < 0) + ACE_ERROR ((LM_ERROR, + ACE_TEXT("%p\n"), + ACE_TEXT("ACE_Asynch_Connector:: failed"))); + + // Set the addresses. + local_address.set (reinterpret_cast (&local_addr), + local_size); + remote_address.set (reinterpret_cast (&remote_addr), + remote_size); + +#if 0 + // @@ Just debugging. + char local_address_buf [BUFSIZ]; + char remote_address_buf [BUFSIZ]; + + if (local_address.addr_to_string (local_address_buf, + sizeof local_address_buf) == -1) + ACE_ERROR ((LM_ERROR, + "Error:%m:can't obtain local_address's address string")); + + ACE_DEBUG ((LM_DEBUG, + "ACE_Asynch_Connector::parse_address : " + "Local address %s\n", + local_address_buf)); + + if (remote_address.addr_to_string (remote_address_buf, + sizeof remote_address_buf) == -1) + ACE_ERROR ((LM_ERROR, + "Error:%m:can't obtain remote_address's address string")); + + ACE_DEBUG ((LM_DEBUG, + "ACE_Asynch_Connector::parse_address : " + "Remote address %s\n", + remote_address_buf)); +#endif /* 0 */ + + return; +} + + +template ACE_Asynch_Connect & +ACE_Asynch_Connector::asynch_connect (void) +{ + return this->asynch_connect_; +} + +template HANDLER * +ACE_Asynch_Connector::make_handler (void) +{ + // Default behavior + HANDLER *handler = 0; + ACE_NEW_RETURN (handler, HANDLER, 0); + return handler; +} + +template bool +ACE_Asynch_Connector::pass_addresses (void) const +{ + return this->pass_addresses_; +} + +template void +ACE_Asynch_Connector::pass_addresses (bool new_value) +{ + this->pass_addresses_ = new_value; +} + +template bool +ACE_Asynch_Connector::validate_new_connection (void) const +{ + return this->validate_new_connection_; +} + +template void +ACE_Asynch_Connector::validate_new_connection (bool new_value) +{ + this->validate_new_connection_ = new_value; +} + +ACE_END_VERSIONED_NAMESPACE_DECL + +#endif /* ACE_WIN32 || ACE_HAS_AIO_CALLS */ +#endif /* ACE_ASYNCH_CONNECTOR_CPP */ diff --git a/dep/ACE_wrappers/ace/Asynch_Connector.h b/dep/ACE_wrappers/ace/Asynch_Connector.h new file mode 100644 index 00000000000..7c7969cc20d --- /dev/null +++ b/dep/ACE_wrappers/ace/Asynch_Connector.h @@ -0,0 +1,171 @@ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file Asynch_Connector.h + * + * $Id: Asynch_Connector.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Alexander Libman + */ +//============================================================================= + +#ifndef ACE_ASYNCH_CONNECTOR_H +#define ACE_ASYNCH_CONNECTOR_H +#include /**/ "ace/pre.h" + +#include /**/ "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#if (defined (ACE_WIN32) || defined (ACE_HAS_AIO_CALLS)) && !defined(ACE_HAS_WINCE) +// This only works on platforms that support async i/o. + +#include "ace/Asynch_IO.h" +#include "ace/INET_Addr.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +// Forward declarations +class ACE_Message_Block; + +/** + * @class ACE_Asynch_Connector + * + * @brief This class is an example of the Connector pattern. This class + * will establish new connections and create new HANDLER objects to handle + * the new connections. + * + * Unlike the ACE_Connector, however, this class is designed to + * be used asynchronously with the ACE Proactor framework. + */ + +template +class ACE_Asynch_Connector : public ACE_Handler +{ +public: + /// A do nothing constructor. + ACE_Asynch_Connector (void); + + /// Virtual destruction + virtual ~ACE_Asynch_Connector (void); + + /** + * This opens asynch connector + */ + virtual int open (bool pass_addresses = false, + ACE_Proactor *proactor = 0, + bool validate_new_connection = true); + + /// This initiates a new asynchronous connect + virtual int connect (const ACE_INET_Addr &remote_sap, + const ACE_INET_Addr &local_sap = + (const ACE_INET_Addr &)ACE_Addr::sap_any, + int reuse_addr = 1, + const void *act = 0); + + /** + * This cancels all pending accepts operations that were issued by + * the calling thread. + * + * @note On Windows, this method does not cancel connect operations + * issued by other threads. + * + * @note On POSIX, delegates cancelation to ACE_POSIX_Asynch_Connect. + */ + virtual int cancel (void); + + + /** + * Template method to validate peer before service is opened. + * This method is called when the connection attempt completes, + * whether it succeeded or failed, if the @a validate_connection + * argument to @c open() was non-zero or the @c validate_new_connection() + * method is called to turn this feature on. The default implementation + * returns 0. Users can (and probably should) reimplement this method + * to learn about the success or failure of the connection attempt. + * If the connection completed successfully, this method can be used to + * perform validation of the peer using it's address, running an + * authentication procedure (such as SSL) or anything else necessary or + * desireable. The return value from this method determines whether or + * not ACE will continue opening the service or abort the connection. + * + * @param result Result of the connection acceptance. Use + * result.success() to determine success or failure of + * the connection attempt. + * @param remote Peer's address. If the connection failed, this object + * is undefined. + * @param local Local address connection was completed from. If the + * connection failed, this object is undefined. + * + * @retval -1 ACE_Asynch_Connector will close the connection, and + * the service will not be opened. + * @retval 0 Service opening will proceeed. + * @return Return value is ignored if the connection attempt failed. + */ + virtual int validate_connection (const ACE_Asynch_Connect::Result& result, + const ACE_INET_Addr &remote, + const ACE_INET_Addr& local); + + // + // These are low level tweaking methods + // + + /// Set and get flag that indicates if parsing and passing of + /// addresses to the service_handler is necessary. + virtual bool pass_addresses (void) const; + virtual void pass_addresses (bool new_value); + + /// Set and get flag that indicates if address validation is + /// required. + virtual bool validate_new_connection (void) const; + virtual void validate_new_connection (bool new_value); + +protected: + + /// This is called when an outstanding accept completes. + virtual void handle_connect (const ACE_Asynch_Connect::Result &result); + + + /// This parses the address from read buffer. + void parse_address (const ACE_Asynch_Connect::Result &result, + ACE_INET_Addr &remote_address, + ACE_INET_Addr &local_address); + + /// Return the asynch Connect object. + ACE_Asynch_Connect & asynch_connect (void); + + /** + * This is the template method used to create new handler. + * Subclasses must overwrite this method if a new handler creation + * strategy is required. + */ + virtual HANDLER *make_handler (void); + +private: + + /// Asynch_Connect used to make life easier :-) + ACE_Asynch_Connect asynch_connect_; + + /// Flag that indicates if parsing of addresses is necessary. + bool pass_addresses_; + + /// Flag that indicates if address validation is required. + bool validate_new_connection_; +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) +#include "ace/Asynch_Connector.cpp" +#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ + +#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) +#pragma implementation ("Asynch_Connector.cpp") +#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ + +#endif /* ACE_WIN32 || ACE_HAS_AIO_CALLS */ +#include /**/ "ace/post.h" +#endif /* ACE_ASYNCH_CONNECTOR_H */ diff --git a/dep/ACE_wrappers/ace/Asynch_IO.cpp b/dep/ACE_wrappers/ace/Asynch_IO.cpp new file mode 100644 index 00000000000..26bba31a3a9 --- /dev/null +++ b/dep/ACE_wrappers/ace/Asynch_IO.cpp @@ -0,0 +1,1414 @@ +// $Id: Asynch_IO.cpp 82559 2008-08-07 20:23:07Z parsons $ + +#include "ace/Asynch_IO.h" + +ACE_RCSID(ace, Asynch_IO, "$Id: Asynch_IO.cpp 82559 2008-08-07 20:23:07Z parsons $") + +#if defined (ACE_HAS_WIN32_OVERLAPPED_IO) || defined (ACE_HAS_AIO_CALLS) +// This only works on platforms with Asynchronous IO + +#include "ace/Proactor.h" +#include "ace/Message_Block.h" +#include "ace/INET_Addr.h" +#include "ace/Asynch_IO_Impl.h" +#include "ace/os_include/os_errno.h" +#include "ace/Truncate.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +size_t +ACE_Asynch_Result::bytes_transferred (void) const +{ + return this->implementation ()->bytes_transferred (); +} + +const void * +ACE_Asynch_Result::act (void) const +{ + return this->implementation ()->act (); +} + +int +ACE_Asynch_Result::success (void) const +{ + return this->implementation ()->success (); +} + +const void * +ACE_Asynch_Result::completion_key (void) const +{ + return this->implementation ()->completion_key (); +} + +unsigned long +ACE_Asynch_Result::error (void) const +{ + return this->implementation ()->error (); +} + +ACE_HANDLE +ACE_Asynch_Result::event (void) const +{ + return this->implementation ()->event (); +} + +unsigned long +ACE_Asynch_Result::offset (void) const +{ + return this->implementation ()->offset (); +} + +unsigned long +ACE_Asynch_Result::offset_high (void) const +{ + return this->implementation ()->offset_high (); +} + +int +ACE_Asynch_Result::priority (void) const +{ + return this->implementation ()->priority (); +} + +int +ACE_Asynch_Result::signal_number (void) const +{ + return this->implementation ()->signal_number (); +} + +ACE_Asynch_Result::ACE_Asynch_Result (ACE_Asynch_Result_Impl *implementation) + : implementation_ (implementation) +{ +} + +ACE_Asynch_Result::~ACE_Asynch_Result (void) +{ + // Proactor deletes the implementation when the finishes. +} + +ACE_Asynch_Result_Impl * +ACE_Asynch_Result::implementation (void) const +{ + return this->implementation_; +} + +// ********************************************************************* + +int +ACE_Asynch_Operation::open (ACE_Handler &handler, + ACE_HANDLE handle, + const void *completion_key, + ACE_Proactor *proactor) +{ + return this->implementation ()->open (handler.proxy (), + handle, + completion_key, + proactor); +} + +int +ACE_Asynch_Operation::cancel (void) +{ + if (0 == this->implementation ()) + { + errno = EFAULT; + return -1; + } + return this->implementation ()->cancel (); +} + +ACE_Proactor * +ACE_Asynch_Operation::proactor (void) const +{ + if (0 == this->implementation ()) + { + errno = EFAULT; + return 0; + } + return this->implementation ()->proactor (); +} + +ACE_Asynch_Operation::ACE_Asynch_Operation (void) +{ +} + +ACE_Asynch_Operation::~ACE_Asynch_Operation (void) +{ +} + +ACE_Proactor * +ACE_Asynch_Operation::get_proactor (ACE_Proactor *user_proactor, + ACE_Handler &handler) const +{ + if (user_proactor == 0) + { + // Grab the singleton proactor if proactor> is zero + user_proactor = handler.proactor (); + if (user_proactor == 0) + user_proactor = ACE_Proactor::instance (); + } + + return user_proactor; +} + +// ************************************************************ + +ACE_Asynch_Read_Stream::ACE_Asynch_Read_Stream (void) + : implementation_ (0) +{ +} + +ACE_Asynch_Read_Stream::~ACE_Asynch_Read_Stream (void) +{ + // Delete the implementation. + delete this->implementation_; + this->implementation_ = 0; +} + +int +ACE_Asynch_Read_Stream::open (ACE_Handler &handler, + ACE_HANDLE handle, + const void *completion_key, + ACE_Proactor *proactor) +{ + // Get a proactor for/from the user. + proactor = this->get_proactor (proactor, handler); + + // Now let us get the implementation initialized. + if ((this->implementation_ = proactor->create_asynch_read_stream ()) == 0) + return -1; + + // Call the method of the base class. + return ACE_Asynch_Operation::open (handler, + handle, + completion_key, + proactor); +} + +int +ACE_Asynch_Read_Stream::read (ACE_Message_Block &message_block, + size_t bytes_to_read, + const void *act, + int priority, + int signal_number) +{ + if (0 == this->implementation_) + { + errno = EFAULT; + return -1; + } + return this->implementation_->read (message_block, + bytes_to_read, + act, + priority, + signal_number); +} + +#if defined (ACE_HAS_WIN32_OVERLAPPED_IO) +int +ACE_Asynch_Read_Stream::readv (ACE_Message_Block &message_block, + size_t bytes_to_read, + const void *act, + int priority, + int signal_number) +{ + if (0 == this->implementation_) + { + errno = EFAULT; + return -1; + } + return this->implementation_->readv (message_block, + bytes_to_read, + act, + priority, + signal_number); +} +#endif /* ACE_HAS_WIN32_OVERLAPPED_IO */ + +ACE_Asynch_Operation_Impl * +ACE_Asynch_Read_Stream::implementation (void) const +{ + return this->implementation_; +} + +// ************************************************************ + +size_t +ACE_Asynch_Read_Stream::Result::bytes_to_read (void) const +{ + return this->implementation ()->bytes_to_read (); +} + +ACE_Message_Block & +ACE_Asynch_Read_Stream::Result::message_block (void) const +{ + return this->implementation ()->message_block (); +} + +ACE_HANDLE +ACE_Asynch_Read_Stream::Result::handle (void) const +{ + return this->implementation ()->handle (); +} + +ACE_Asynch_Read_Stream::Result::Result (ACE_Asynch_Read_Stream_Result_Impl *implementation) + : ACE_Asynch_Result (implementation), + implementation_ (implementation) +{ +} + +ACE_Asynch_Read_Stream::Result::~Result (void) +{ + // Proactor will delete the implementation after is + // finished. +} + +ACE_Asynch_Read_Stream_Result_Impl * +ACE_Asynch_Read_Stream::Result::implementation (void) const +{ + return this->implementation_; +} + +// *************************************************** + +ACE_Asynch_Write_Stream::ACE_Asynch_Write_Stream (void) + : implementation_ (0) +{ +} + +ACE_Asynch_Write_Stream::~ACE_Asynch_Write_Stream (void) +{ + // Delete the implementation. + delete this->implementation_; + this->implementation_ = 0; +} + +int +ACE_Asynch_Write_Stream::open (ACE_Handler &handler, + ACE_HANDLE handle, + const void *completion_key, + ACE_Proactor *proactor) +{ + // Get a proactor for/from the user. + proactor = this->get_proactor (proactor, handler); + + // Now let us get the implementation initialized. + if ((this->implementation_ = proactor->create_asynch_write_stream ()) == 0) + return -1; + + // Call the method of the base class. + return ACE_Asynch_Operation::open (handler, + handle, + completion_key, + proactor); +} + +int +ACE_Asynch_Write_Stream::write (ACE_Message_Block &message_block, + size_t bytes_to_write, + const void *act, + int priority, + int signal_number) +{ + if (0 == this->implementation_) + { + errno = EFAULT; + return -1; + } + return this->implementation_->write (message_block, + bytes_to_write, + act, + priority, + signal_number); +} + +#if defined (ACE_HAS_WIN32_OVERLAPPED_IO) +int +ACE_Asynch_Write_Stream::writev (ACE_Message_Block &message_block, + size_t bytes_to_write, + const void *act, + int priority, + int signal_number) +{ + if (0 == this->implementation_) + { + errno = EFAULT; + return -1; + } + return this->implementation_->writev (message_block, + bytes_to_write, + act, + priority, + signal_number); +} +#endif /* ACE_HAS_WIN32_OVERLAPPED_IO */ + +ACE_Asynch_Operation_Impl * +ACE_Asynch_Write_Stream::implementation (void) const +{ + return this->implementation_; +} + +// ************************************************************ + +size_t +ACE_Asynch_Write_Stream::Result::bytes_to_write (void) const +{ + return this->implementation ()->bytes_to_write (); +} + +ACE_Message_Block & +ACE_Asynch_Write_Stream::Result::message_block (void) const +{ + return this->implementation ()->message_block (); +} + +ACE_HANDLE +ACE_Asynch_Write_Stream::Result::handle (void) const +{ + return this->implementation ()->handle (); +} + +ACE_Asynch_Write_Stream::Result::Result (ACE_Asynch_Write_Stream_Result_Impl *implementation) + : ACE_Asynch_Result (implementation), + implementation_ (implementation) +{ +} + +ACE_Asynch_Write_Stream::Result::~Result (void) +{ + // Proactor will delte the implementation when the call + // finishes. +} + +ACE_Asynch_Write_Stream_Result_Impl * +ACE_Asynch_Write_Stream::Result::implementation (void) const +{ + return this->implementation_; +} + +// ************************************************************ + +ACE_Asynch_Read_File::ACE_Asynch_Read_File (void) + : implementation_ (0) +{ +} + +ACE_Asynch_Read_File::~ACE_Asynch_Read_File (void) +{ + // Delete the implementation. + delete this->implementation_; + this->implementation_ = 0; +} + +int +ACE_Asynch_Read_File::open (ACE_Handler &handler, + ACE_HANDLE handle, + const void *completion_key, + ACE_Proactor *proactor) +{ + // Get a proactor for/from the user. + proactor = this->get_proactor (proactor, handler); + + // Now let us get the implementation initialized. + if ((this->implementation_ = proactor->create_asynch_read_file ()) == 0) + return -1; + + // Call the method of the base class. + return ACE_Asynch_Operation::open (handler, + handle, + completion_key, + proactor); +} + +int +ACE_Asynch_Read_File::read (ACE_Message_Block &message_block, + size_t bytes_to_read, + unsigned long offset, + unsigned long offset_high, + const void *act, + int priority, + int signal_number) +{ + if (0 == this->implementation_) + { + errno = EFAULT; + return -1; + } + return this->implementation_->read (message_block, + bytes_to_read, + offset, + offset_high, + act, + priority, + signal_number); +} + +#if (defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)) +int +ACE_Asynch_Read_File::readv (ACE_Message_Block &message_block, + size_t bytes_to_read, + unsigned long offset, + unsigned long offset_high, + const void *act, + int priority, + int signal_number) +{ + if (0 == this->implementation_) + { + errno = EFAULT; + return -1; + } + return this->implementation_->readv (message_block, + bytes_to_read, + offset, + offset_high, + act, + priority, + signal_number); +} +#endif /* (defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)) */ + +ACE_Asynch_Operation_Impl * +ACE_Asynch_Read_File::implementation (void) const +{ + return this->implementation_; +} + +// ************************************************************ + +ACE_Asynch_Read_File::Result::Result (ACE_Asynch_Read_File_Result_Impl *implementation) + : ACE_Asynch_Read_Stream::Result (implementation), + implementation_ (implementation) +{ +} + +ACE_Asynch_Read_File::Result::~Result (void) +{ + // Proactor will delete the implementation when call + // completes. +} + +ACE_Asynch_Read_File_Result_Impl * +ACE_Asynch_Read_File::Result::implementation (void) const +{ + return this->implementation_; +} + +// ************************************************************ + +ACE_Asynch_Write_File::ACE_Asynch_Write_File (void) + : implementation_ (0) +{ +} + +ACE_Asynch_Write_File::~ACE_Asynch_Write_File (void) +{ + // Delete the implementation. + delete this->implementation_; + this->implementation_ = 0; +} + +int +ACE_Asynch_Write_File::open (ACE_Handler &handler, + ACE_HANDLE handle, + const void *completion_key, + ACE_Proactor *proactor) +{ + // Get a proactor for/from the user. + proactor = this->get_proactor (proactor, handler); + + // Now let us get the implementation initialized. + if ((this->implementation_ = proactor->create_asynch_write_file ()) == 0) + return -1; + + // Call the method of the base class. + return ACE_Asynch_Operation::open (handler, + handle, + completion_key, + proactor); +} + +int +ACE_Asynch_Write_File::write (ACE_Message_Block &message_block, + size_t bytes_to_write, + unsigned long offset, + unsigned long offset_high, + const void *act, + int priority, + int signal_number) +{ + if (0 == this->implementation_) + { + errno = EFAULT; + return -1; + } + return this->implementation_->write (message_block, + bytes_to_write, + offset, + offset_high, + act, + priority, + signal_number); +} + +#if (defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)) +int +ACE_Asynch_Write_File::writev (ACE_Message_Block &message_block, + size_t bytes_to_write, + unsigned long offset, + unsigned long offset_high, + const void *act, + int priority, + int signal_number) +{ + if (0 == this->implementation_) + { + errno = EFAULT; + return -1; + } + return this->implementation_->writev (message_block, + bytes_to_write, + offset, + offset_high, + act, + priority, + signal_number); +} +#endif /* (defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)) */ + +ACE_Asynch_Operation_Impl * +ACE_Asynch_Write_File::implementation (void) const +{ + return this->implementation_; +} + +// ************************************************************ + +ACE_Asynch_Write_File::Result::Result (ACE_Asynch_Write_File_Result_Impl *implementation) + : ACE_Asynch_Write_Stream::Result (implementation), + implementation_ (implementation) +{ +} + +ACE_Asynch_Write_File::Result::~Result (void) +{ + // Proactor will delete the implementation when the call + // completes. +} + +ACE_Asynch_Write_File_Result_Impl * +ACE_Asynch_Write_File::Result::implementation (void) const +{ + return this->implementation_; +} + +// ********************************************************************* + +ACE_Asynch_Accept::ACE_Asynch_Accept (void) + : implementation_ (0) +{ +} + +ACE_Asynch_Accept::~ACE_Asynch_Accept (void) +{ + // Delete the implementation. + delete this->implementation_; + this->implementation_ = 0; +} + +int +ACE_Asynch_Accept::open (ACE_Handler &handler, + ACE_HANDLE handle, + const void *completion_key, + ACE_Proactor *proactor) +{ + // Get a proactor for/from the user. + proactor = this->get_proactor (proactor, handler); + + // Now let us get the implementation initialized. + if ((this->implementation_ = proactor->create_asynch_accept ()) == 0) + return -1; + + // Call the method of the base class. + return ACE_Asynch_Operation::open (handler, + handle, + completion_key, + proactor); +} + +int +ACE_Asynch_Accept::accept (ACE_Message_Block &message_block, + size_t bytes_to_read, + ACE_HANDLE accept_handle, + const void *act, + int priority, + int signal_number, + int addr_family) +{ + if (0 == this->implementation_) + { + errno = EFAULT; + return -1; + } + return this->implementation_->accept (message_block, + bytes_to_read, + accept_handle, + act, + priority, + signal_number, + addr_family); +} + +ACE_Asynch_Operation_Impl * +ACE_Asynch_Accept::implementation (void) const +{ + return this->implementation_; +} + +// ************************************************************ + +size_t +ACE_Asynch_Accept::Result::bytes_to_read (void) const +{ + return this->implementation ()->bytes_to_read (); +} + +ACE_Message_Block & +ACE_Asynch_Accept::Result::message_block (void) const +{ + return this->implementation ()->message_block (); +} + +ACE_HANDLE +ACE_Asynch_Accept::Result::listen_handle (void) const +{ + return this->implementation ()->listen_handle (); +} + +ACE_HANDLE +ACE_Asynch_Accept::Result::accept_handle (void) const +{ + return this->implementation ()->accept_handle (); +} + +ACE_Asynch_Accept::Result::Result (ACE_Asynch_Accept_Result_Impl *implementation) + : ACE_Asynch_Result (implementation), + implementation_ (implementation) +{ +} + +ACE_Asynch_Accept::Result::~Result (void) +{ + // Proactor will delete the implementation when the call + // completes. +} + +ACE_Asynch_Accept_Result_Impl * +ACE_Asynch_Accept::Result::implementation (void) const +{ + return this->implementation_; +} + + + +// ********************************************************************* + +ACE_Asynch_Connect::ACE_Asynch_Connect (void) + : implementation_ (0) +{ +} + +ACE_Asynch_Connect::~ACE_Asynch_Connect (void) +{ + // Delete the implementation. + delete this->implementation_; + this->implementation_ = 0; +} + +int +ACE_Asynch_Connect::open (ACE_Handler &handler, + ACE_HANDLE handle, + const void *completion_key, + ACE_Proactor *proactor) +{ + // Get a proactor for/from the user. + proactor = this->get_proactor (proactor, handler); + + // Now let us get the implementation initialized. + if ((this->implementation_ = proactor->create_asynch_connect ()) == 0) + return -1; + + // Call the method of the base class. + return ACE_Asynch_Operation::open (handler, + handle, + completion_key, + proactor); +} + +int +ACE_Asynch_Connect::connect (ACE_HANDLE connect_handle, + const ACE_Addr & remote_sap, + const ACE_Addr & local_sap, + int reuse_addr, + const void *act, + int priority, + int signal_number) +{ + if (0 == this->implementation_) + { + errno = EFAULT; + return -1; + } + return this->implementation_->connect (connect_handle, + remote_sap, + local_sap, + reuse_addr, + act, + priority, + signal_number); +} + +ACE_Asynch_Operation_Impl * +ACE_Asynch_Connect::implementation (void) const +{ + return this->implementation_; +} + +// ************************************************************ + +ACE_Asynch_Connect::Result::Result (ACE_Asynch_Connect_Result_Impl *implementation) + : ACE_Asynch_Result (implementation), + implementation_ (implementation) +{ +} + +ACE_Asynch_Connect::Result::~Result (void) +{ + // Proactor will delete the implementation when the call + // completes. +} + +ACE_HANDLE +ACE_Asynch_Connect::Result::connect_handle (void) const +{ + return this->implementation ()->connect_handle (); +} + + +ACE_Asynch_Connect_Result_Impl * +ACE_Asynch_Connect::Result::implementation (void) const +{ + return this->implementation_; +} + +// ************************************************************ + +ACE_Asynch_Transmit_File::ACE_Asynch_Transmit_File (void) + : implementation_ (0) +{ +} + +ACE_Asynch_Transmit_File::~ACE_Asynch_Transmit_File (void) +{ + // Delete the implementation. + delete this->implementation_; + this->implementation_ = 0; +} + +int +ACE_Asynch_Transmit_File::open (ACE_Handler &handler, + ACE_HANDLE handle, + const void *completion_key, + ACE_Proactor *proactor) +{ + // Get a proactor for/from the user. + proactor = this->get_proactor (proactor, handler); + + // Now let us get the implementation initialized. + if ((this->implementation_ = proactor->create_asynch_transmit_file ()) == 0) + return -1; + + // Call the method of the base class. + return ACE_Asynch_Operation::open (handler, + handle, + completion_key, + proactor); +} + +int +ACE_Asynch_Transmit_File::transmit_file (ACE_HANDLE file, + Header_And_Trailer *header_and_trailer, + size_t bytes_to_write, + unsigned long offset, + unsigned long offset_high, + size_t bytes_per_send, + unsigned long flags, + const void *act, + int priority, + int signal_number) +{ + if (0 == this->implementation_) + { + errno = EFAULT; + return -1; + } + return this->implementation_->transmit_file (file, + header_and_trailer, + bytes_to_write, + offset, + offset_high, + bytes_per_send, + flags, + act, + priority, + signal_number); +} + +ACE_Asynch_Operation_Impl * +ACE_Asynch_Transmit_File::implementation (void) const +{ + return this->implementation_; +} + +// **************************************************************************** + +ACE_HANDLE +ACE_Asynch_Transmit_File::Result::socket (void) const +{ + return this->implementation ()->socket (); +} + +ACE_HANDLE +ACE_Asynch_Transmit_File::Result::file (void) const +{ + return this->implementation ()->file (); +} + +ACE_Asynch_Transmit_File::Header_And_Trailer * +ACE_Asynch_Transmit_File::Result::header_and_trailer (void) const +{ + return this->implementation ()->header_and_trailer (); +} + +size_t +ACE_Asynch_Transmit_File::Result::bytes_to_write (void) const +{ + return this->implementation ()->bytes_to_write (); +} + +size_t +ACE_Asynch_Transmit_File::Result::bytes_per_send (void) const +{ + return this->implementation ()->bytes_per_send (); +} + +unsigned long +ACE_Asynch_Transmit_File::Result::flags (void) const +{ + return this->implementation ()->flags (); +} + +ACE_Asynch_Transmit_File::Result::Result (ACE_Asynch_Transmit_File_Result_Impl *implementation) + : ACE_Asynch_Result (implementation), + implementation_ (implementation) +{ +} + +ACE_Asynch_Transmit_File::Result::~Result (void) +{ +} + +ACE_Asynch_Transmit_File_Result_Impl * +ACE_Asynch_Transmit_File::Result::implementation (void) const +{ + return this->implementation_; +} + +// ************************************************************ + +ACE_Asynch_Transmit_File::Header_And_Trailer::Header_And_Trailer (ACE_Message_Block *header, + size_t header_bytes, + ACE_Message_Block *trailer, + size_t trailer_bytes) + : header_ (header), + header_bytes_ (header_bytes), + trailer_ (trailer), + trailer_bytes_ (trailer_bytes) +{ +} + +ACE_Asynch_Transmit_File::Header_And_Trailer::~Header_And_Trailer (void) +{ +} + +void +ACE_Asynch_Transmit_File::Header_And_Trailer::header_and_trailer (ACE_Message_Block *header, + size_t header_bytes, + ACE_Message_Block *trailer, + size_t trailer_bytes) +{ + this->header (header); + this->header_bytes (header_bytes); + this->trailer (trailer); + this->trailer_bytes (trailer_bytes); +} + +ACE_Message_Block * +ACE_Asynch_Transmit_File::Header_And_Trailer::header (void) const +{ + return this->header_; +} + +void +ACE_Asynch_Transmit_File::Header_And_Trailer::header (ACE_Message_Block *message_block) +{ + this->header_ = message_block; +} + +size_t +ACE_Asynch_Transmit_File::Header_And_Trailer::header_bytes (void) const +{ + return this->header_bytes_; +} + +void +ACE_Asynch_Transmit_File::Header_And_Trailer::header_bytes (size_t bytes) +{ + this->header_bytes_ = bytes; +} + +ACE_Message_Block * +ACE_Asynch_Transmit_File::Header_And_Trailer::trailer (void) const +{ + return this->trailer_; +} + +void +ACE_Asynch_Transmit_File::Header_And_Trailer::trailer (ACE_Message_Block *message_block) +{ + this->trailer_ = message_block; +} + +size_t +ACE_Asynch_Transmit_File::Header_And_Trailer::trailer_bytes (void) const +{ + return this->trailer_bytes_; +} + +void +ACE_Asynch_Transmit_File::Header_And_Trailer::trailer_bytes (size_t bytes) +{ + this->trailer_bytes_ = bytes; +} + +ACE_LPTRANSMIT_FILE_BUFFERS +ACE_Asynch_Transmit_File::Header_And_Trailer::transmit_buffers (void) +{ + // If both are zero, return zero + if (this->header_ == 0 && this->trailer_ == 0) + { + return 0; + } + else + { + // Something is valid + + // If header is valid, set the fields + if (this->header_ != 0) + { + this->transmit_buffers_.Head = this->header_->rd_ptr (); +#if defined (ACE_WIN64) || defined (ACE_WIN32) + this->transmit_buffers_.HeadLength = + ACE_Utils::truncate_cast (this->header_bytes_); +#else + this->transmit_buffers_.HeadLength = this->header_bytes_; +#endif /* ACE_WIN64 || ACE_WIN32 */ + } + else + { + this->transmit_buffers_.Head = 0; + this->transmit_buffers_.HeadLength = 0; + } + + // If trailer is valid, set the fields + if (this->trailer_ != 0) + { + this->transmit_buffers_.Tail = this->trailer_->rd_ptr (); +#if defined(ACE_WIN64) || defined (ACE_WIN32) + this->transmit_buffers_.TailLength = + ACE_Utils::truncate_cast (this->trailer_bytes_); +#else + this->transmit_buffers_.TailLength = this->trailer_bytes_; +#endif /* ACE_WIN64 || ACE_WIN32 */ + } + else + { + this->transmit_buffers_.Tail = 0; + this->transmit_buffers_.TailLength = 0; + } + + // Return the transmit buffers + return &this->transmit_buffers_; + } +} + +// ********************************************************************* + +ACE_Handler::ACE_Handler (void) + : proactor_ (0), handle_ (ACE_INVALID_HANDLE) +{ + ACE_Handler::Proxy *p; + ACE_NEW (p, ACE_Handler::Proxy (this)); + this->proxy_.reset (p); +} + +ACE_Handler::ACE_Handler (ACE_Proactor *d) + : proactor_ (d), handle_ (ACE_INVALID_HANDLE) +{ + ACE_Handler::Proxy *p; + ACE_NEW (p, ACE_Handler::Proxy (this)); + this->proxy_.reset (p); +} + +ACE_Handler::~ACE_Handler (void) +{ + ACE_Handler::Proxy *p = this->proxy_.get (); + if (p) + p->reset (); +} + +void +ACE_Handler::handle_read_stream (const ACE_Asynch_Read_Stream::Result & /* result */) +{ +} + +void +ACE_Handler::handle_write_stream (const ACE_Asynch_Write_Stream::Result & /* result */) +{ +} + +void +ACE_Handler::handle_write_dgram (const ACE_Asynch_Write_Dgram::Result & /* result */) +{ +} + +void +ACE_Handler::handle_read_dgram (const ACE_Asynch_Read_Dgram::Result & /* result */) +{ +} + +void +ACE_Handler::handle_accept (const ACE_Asynch_Accept::Result & /* result */) +{ +} + +void +ACE_Handler::handle_connect (const ACE_Asynch_Connect::Result & /* result */) +{ +} + +void +ACE_Handler::handle_transmit_file (const ACE_Asynch_Transmit_File::Result & /* result */) +{ +} + +void +ACE_Handler::handle_read_file (const ACE_Asynch_Read_File::Result & /* result */) +{ +} + +void +ACE_Handler::handle_write_file (const ACE_Asynch_Write_File::Result & /* result */) +{ +} + +void +ACE_Handler::handle_time_out (const ACE_Time_Value & /* tv */, + const void * /* act */) +{ +} + +void +ACE_Handler::handle_wakeup (void) +{ +} + +ACE_Proactor * +ACE_Handler::proactor (void) +{ + return this->proactor_; +} + +void +ACE_Handler::proactor (ACE_Proactor *p) +{ + this->proactor_ = p; +} + +ACE_HANDLE +ACE_Handler::handle (void) const +{ + return this->handle_; +} + +void +ACE_Handler::handle (ACE_HANDLE h) +{ + this->handle_ = h; +} + +ACE_Refcounted_Auto_Ptr & +ACE_Handler::proxy (void) +{ + return this->proxy_; +} + +// ************************************************************ + +ACE_Service_Handler::ACE_Service_Handler (void) +{ +} + +ACE_Service_Handler::~ACE_Service_Handler (void) +{ +} + +void +ACE_Service_Handler::addresses (const ACE_INET_Addr & /* remote_address */, + const ACE_INET_Addr & /* local_address */ ) +{ +} + +void +ACE_Service_Handler::act (const void *) +{ +} + +void +ACE_Service_Handler::open (ACE_HANDLE, + ACE_Message_Block &) +{ +} + + +// ************************************************************ + +ACE_Asynch_Read_Dgram::ACE_Asynch_Read_Dgram (void) + : implementation_ (0) +{ +} + +ACE_Asynch_Read_Dgram::~ACE_Asynch_Read_Dgram (void) +{ + // Delete the implementation. + delete this->implementation_; + this->implementation_ = 0; +} + +int +ACE_Asynch_Read_Dgram::open (ACE_Handler &handler, + ACE_HANDLE handle, + const void *completion_key, + ACE_Proactor *proactor) +{ + // Get a proactor for/from the user. + proactor = this->get_proactor (proactor, handler); + + // Now let us get the implementation initialized. + if ((this->implementation_ = proactor->create_asynch_read_dgram ()) == 0) + return -1; + + // Call the method of the base class. + return ACE_Asynch_Operation::open (handler, + handle, + completion_key, + proactor); +} + +ssize_t +ACE_Asynch_Read_Dgram::recv (ACE_Message_Block *message_block, + size_t &number_of_bytes_recvd, + int flags, + int protocol_family, + const void *act, + int priority, + int signal_number) +{ + if (0 == this->implementation_) + { + errno = EFAULT; + return -1; + } + return this->implementation_->recv (message_block, + number_of_bytes_recvd, + flags, + protocol_family, + act, + priority, + signal_number); +} + +ACE_Asynch_Operation_Impl * +ACE_Asynch_Read_Dgram::implementation (void) const +{ + return this->implementation_; +} + +// ************************************************************ + +int +ACE_Asynch_Read_Dgram::Result::remote_address (ACE_Addr& addr) const +{ + return this->implementation ()->remote_address (addr); +} + +ACE_Message_Block* +ACE_Asynch_Read_Dgram::Result::message_block (void) const +{ + return this->implementation ()->message_block (); +} + +int +ACE_Asynch_Read_Dgram::Result::flags (void) const +{ + return this->implementation ()->flags (); +} + +size_t +ACE_Asynch_Read_Dgram::Result::bytes_to_read (void) const +{ + return this->implementation ()->bytes_to_read (); +} + +ACE_HANDLE +ACE_Asynch_Read_Dgram::Result::handle (void) const +{ + return this->implementation ()->handle(); +} + +ACE_Asynch_Read_Dgram::Result::Result (ACE_Asynch_Read_Dgram_Result_Impl *implementation) +: ACE_Asynch_Result (implementation), + implementation_ (implementation) +{ +} + +ACE_Asynch_Read_Dgram::Result::~Result (void) +{ +} + +ACE_Asynch_Read_Dgram_Result_Impl * +ACE_Asynch_Read_Dgram::Result::implementation (void) const +{ + return this->implementation_; +} + +// ************************************************************ + + +ACE_Asynch_Write_Dgram::ACE_Asynch_Write_Dgram (void) + : implementation_ (0) +{ +} + +ACE_Asynch_Write_Dgram::~ACE_Asynch_Write_Dgram (void) +{ + // Delete the implementation. + delete this->implementation_; + this->implementation_ = 0; +} + +int +ACE_Asynch_Write_Dgram::open (ACE_Handler &handler, + ACE_HANDLE handle, + const void *completion_key, + ACE_Proactor *proactor) +{ + // Get a proactor for/from the user. + proactor = this->get_proactor (proactor, handler); + + // Now let us get the implementation initialized. + if ((this->implementation_ = proactor->create_asynch_write_dgram ()) == 0) + return -1; + + // Call the method of the base class. + return ACE_Asynch_Operation::open (handler, + handle, + completion_key, + proactor); +} + +ssize_t +ACE_Asynch_Write_Dgram::send (ACE_Message_Block *message_block, + size_t &number_of_bytes_sent, + int flags, + const ACE_Addr& remote_addr, + const void *act, + int priority, + int signal_number) +{ + if (0 == this->implementation_) + { + errno = EFAULT; + return -1; + } + return this->implementation_->send (message_block, + number_of_bytes_sent, + flags, + remote_addr, + act, + priority, + signal_number); +} + +ACE_Asynch_Operation_Impl * +ACE_Asynch_Write_Dgram::implementation (void) const +{ + return this->implementation_; +} + +// ************************************************************ + +size_t +ACE_Asynch_Write_Dgram::Result::bytes_to_write (void) const +{ + return this->implementation ()->bytes_to_write (); +} + +ACE_Message_Block* +ACE_Asynch_Write_Dgram::Result::message_block () const +{ + return this->implementation ()->message_block (); +} + +int +ACE_Asynch_Write_Dgram::Result::flags (void) const +{ + return this->implementation ()->flags (); +} + +ACE_HANDLE +ACE_Asynch_Write_Dgram::Result::handle (void) const +{ + return this->implementation ()->handle (); +} + +ACE_Asynch_Write_Dgram_Result_Impl * +ACE_Asynch_Write_Dgram::Result::implementation (void) const +{ + return this->implementation_; +} + +ACE_Asynch_Write_Dgram::Result::Result (ACE_Asynch_Write_Dgram_Result_Impl *implementation) +: ACE_Asynch_Result (implementation), + implementation_ (implementation) +{ +} + +ACE_Asynch_Write_Dgram::Result::~Result (void) +{ +} + +ACE_END_VERSIONED_NAMESPACE_DECL + +#endif /* ACE_HAS_WIN32_OVERLAPPED_IO || ACE_HAS_AIO_CALLS */ diff --git a/dep/ACE_wrappers/ace/Asynch_IO.h b/dep/ACE_wrappers/ace/Asynch_IO.h new file mode 100644 index 00000000000..6aeb21fe58e --- /dev/null +++ b/dep/ACE_wrappers/ace/Asynch_IO.h @@ -0,0 +1,1734 @@ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file Asynch_IO.h + * + * $Id: Asynch_IO.h 81870 2008-06-09 20:53:53Z shuston $ + * + * This works on Win32 (defined (ACE_WIN32) && !defined + * (ACE_HAS_WINCE)) platforms and on POSIX4 platforms with {aio_*} + * routines (defined (ACE_HAS_AIO_CALLS)) + * + * On Win32 platforms, the implementation of + * {ACE_Asynch_Transmit_File} and {ACE_Asynch_Accept} are only + * supported if ACE_HAS_WINSOCK2 is defined or you are on WinNT 4.0 + * or higher. + * + * @author Irfan Pyarali + * @author Tim Harrison + * @author Alexander Babu Arulanthu + * @author Roger Tragin + * @author Alexander Libman + */ +//============================================================================= + +#ifndef ACE_ASYNCH_IO_H +#define ACE_ASYNCH_IO_H +#include /**/ "ace/pre.h" + +#include /**/ "ace/ACE_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +#pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#if defined (ACE_HAS_WIN32_OVERLAPPED_IO) || defined (ACE_HAS_AIO_CALLS) + +#include "ace/Synch_Traits.h" +#if defined (ACE_HAS_THREADS) +# include "ace/Thread_Mutex.h" +#else +# include "ace/Null_Mutex.h" +#endif /* ACE_HAS_THREADS */ +#include "ace/Refcounted_Auto_Ptr.h" + +#include "ace/os_include/os_signal.h" +#include "ace/os_include/sys/os_socket.h" +#include "ace/os_include/sys/os_types.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +# if defined (ACE_HAS_WIN32_OVERLAPPED_IO) +typedef TRANSMIT_FILE_BUFFERS ACE_TRANSMIT_FILE_BUFFERS; +typedef LPTRANSMIT_FILE_BUFFERS ACE_LPTRANSMIT_FILE_BUFFERS; +typedef PTRANSMIT_FILE_BUFFERS ACE_PTRANSMIT_FILE_BUFFERS; + +# define ACE_INFINITE INFINITE +# define ACE_STATUS_TIMEOUT STATUS_TIMEOUT +# define ACE_WAIT_FAILED WAIT_FAILED +# define ACE_WAIT_TIMEOUT WAIT_TIMEOUT +# else /* ACE_HAS_WIN32_OVERLAPPED_IO */ +struct ACE_TRANSMIT_FILE_BUFFERS +{ + void *Head; + size_t HeadLength; + void *Tail; + size_t TailLength; +}; +typedef ACE_TRANSMIT_FILE_BUFFERS* ACE_PTRANSMIT_FILE_BUFFERS; +typedef ACE_TRANSMIT_FILE_BUFFERS* ACE_LPTRANSMIT_FILE_BUFFERS; + +# if !defined (ACE_INFINITE) +# define ACE_INFINITE LONG_MAX +# endif /* ACE_INFINITE */ +# define ACE_STATUS_TIMEOUT LONG_MAX +# define ACE_WAIT_FAILED LONG_MAX +# define ACE_WAIT_TIMEOUT LONG_MAX +# endif /* ACE_HAS_WIN32_OVERLAPPED_IO */ + +// Forward declarations +class ACE_Proactor; +class ACE_Handler; +class ACE_Message_Block; +class ACE_INET_Addr; +class ACE_Addr; + +// Forward declarations +class ACE_Asynch_Result_Impl; +class ACE_Time_Value; + +/** + * @class ACE_Asynch_Result + * + * @brief An interface base class which allows users access to common + * information related to an asynchronous operation. + * + * An interface base class from which you can obtain some basic + * information like the number of bytes transferred, the ACT + * associated with the asynchronous operation, indication of + * success or failure, etc. Subclasses may want to store more + * information that is particular to the asynchronous operation + * it represents. + */ +class ACE_Export ACE_Asynch_Result +{ + +public: + /// Number of bytes transferred by the operation. + size_t bytes_transferred (void) const; + + /// ACT associated with the operation. + const void *act (void) const; + + /// Did the operation succeed? + int success (void) const; + + /** + * This is the ACT associated with the handle on which the + * Asynch_Operation takes place. + * + * On WIN32, this returns the ACT associated with the handle when it + * was registered with the I/O completion port. + * + * @@ This is not implemented for POSIX4 platforms. Returns 0. + */ + const void *completion_key (void) const; + + /// Error value if the operation fails. + unsigned long error (void) const; + + /** + * On WIN32, this returns the event associated with the OVERLAPPED + * structure. + * + * This returns ACE_INVALID_HANDLE on POSIX4-Unix platforms. + */ + ACE_HANDLE event (void) const; + + /** + * This really makes sense only when doing file I/O. + * + * On WIN32, these are represented in the OVERLAPPED datastructure. + * + * @@ On POSIX4-Unix, offset_high should be supported using + * aiocb64. + */ + unsigned long offset (void) const; + unsigned long offset_high (void) const; + + /** + * Priority of the operation. + * + * On POSIX4-Unix, this is supported. Priority works like {nice} in + * Unix. Negative values are not allowed. 0 means priority of the + * operation same as the process priority. 1 means priority of the + * operation is one less than process. And so forth. + * + * On Win32, this is a no-op. + */ + int priority (void) const; + + /** + * POSIX4 real-time signal number to be used for the + * operation. {signal_number} ranges from ACE_SIGRTMIN to ACE_SIGRTMAX. By + * default, ACE_SIGRTMIN is used to issue {aio_} calls. This is a no-op + * on non-POSIX4 systems and returns 0. + */ + int signal_number (void) const; + + + /// Destructor. + virtual ~ACE_Asynch_Result (void); + +protected: + /// Constructor. This implementation will not be deleted. The + /// implementation will be deleted by the Proactor. + ACE_Asynch_Result (ACE_Asynch_Result_Impl *implementation); + + /// Get the implementation class. + ACE_Asynch_Result_Impl *implementation (void) const; + + /// Implementation class. + ACE_Asynch_Result_Impl *implementation_; +}; + +// Forward declarations +class ACE_Asynch_Operation_Impl; + +/** + * @class ACE_Asynch_Operation + * + * @brief This is an interface base class for all asynch + * operations. The resposiblility of this class is to forward + * all methods to its delegation/implementation class, e.g., + * ACE_WIN32_Asynch_Operation or ACE_POSIX_Asynch_Operation. + * + * There are some attributes and functionality which is common + * to all asychronous operations. The delegation classes of this + * class will factor out this code. + */ +class ACE_Export ACE_Asynch_Operation +{ + +public: + /** + * Initializes the factory with information which will be used with + * each asynchronous call. If ({handle} == ACE_INVALID_HANDLE), + * {ACE_Handler::handle} will be called on the {handler} to get the + * correct handle. + */ + int open (ACE_Handler &handler, + ACE_HANDLE handle, + const void *completion_key, + ACE_Proactor *proactor); + + /** + * (Attempts to) cancel the asynchronous operation pending against + * the {handle} registered with this Operation. + * + * All completion notifications for the I/O operations will occur + * normally. + * + * = Return Values: + * + * -1 : Operation failed. (can get only in POSIX). + * 0 : All the operations were cancelled. + * 1 : All the operations were already finished in this + * handle. Unable to cancel them. + * 2 : Atleast one of the requested operations cannot be + * cancelled. + * + * There is slight difference in the semantics between NT and POSIX + * platforms which is given below. + * + * = Win32 : + * + * cancels all pending accepts operations that were issued by the + * calling thread. The function does not cancel asynchronous + * operations issued by other threads. + * All I/O operations that are canceled will complete with the + * error ERROR_OPERATION_ABORTED. + * + * = POSIX: + * + * Attempts to cancel one or more asynchronous I/O requests + * currently outstanding against the {handle} registered in this + * operation. + * For requested operations that are successfully canceled, the + * associated error status is set to ECANCELED. + */ + int cancel (void); + + + // = Access methods. + + /// Return the underlying proactor. + ACE_Proactor* proactor (void) const; + + /// Destructor. + virtual ~ACE_Asynch_Operation (void); + +protected: + /// Constructor. + ACE_Asynch_Operation (void); + + /// Return the underlying implementation class. + virtual ACE_Asynch_Operation_Impl *implementation (void) const = 0; + + /// Get a proactor for/from the user + ACE_Proactor *get_proactor (ACE_Proactor *user_proactor, + ACE_Handler &handler) const; +}; + +// Forward declarations +class ACE_Asynch_Read_Stream_Result_Impl; +class ACE_Asynch_Read_Stream_Impl; + +/** + * @class ACE_Asynch_Read_Stream + * + * @brief This class is a factory for starting off asynchronous reads + * on a stream. This class forwards all methods to its + * implementation class. + * + * Once {open} is called, multiple asynchronous {read}s can + * started using this class. An ACE_Asynch_Read_Stream::Result + * will be passed back to the {handler} when the asynchronous + * reads completes through the {ACE_Handler::handle_read_stream} + * callback. + */ +class ACE_Export ACE_Asynch_Read_Stream : public ACE_Asynch_Operation +{ + +public: + /// A do nothing constructor. + ACE_Asynch_Read_Stream (void); + + /// Destructor + virtual ~ACE_Asynch_Read_Stream (void); + + /** + * Initializes the factory with information which will be used with + * each asynchronous call. + * + * @param handler The ACE_Handler that will be called to handle completions + * for operations initiated using this factory. + * @param handle The handle that future read operations will use. + * If handle == @c ACE_INVALID_HANDLE, + * ACE_Handler::handle() will be called on @ handler + * to get the correct handle. + * + * @retval 0 for success. + * @retval -1 for failure; consult @c errno for further information. + */ + int open (ACE_Handler &handler, + ACE_HANDLE handle = ACE_INVALID_HANDLE, + const void *completion_key = 0, + ACE_Proactor *proactor = 0); + + /** + * Initiate an asynchronous read operation. + * + * @param message_block The ACE_Message_Block to receive the data. + * Received bytes will be placed in the block + * beginning at its current write pointer. + * If data is read, the message block's write + * pointer will be advanced by the number of + * bytes read. + * @param num_bytes_to_read The maximum number of bytes to read. + * @param act Asynchronous Completion Token; passed through to + * the completion handler in the Result object. + * @param priority Priority of the operation. On POSIX4-Unix, + * this is supported. Works like @c nice in Unix. + * Negative values are not allowed. 0 means + * priority of the operation same as the process + * priority. 1 means priority of the operation is + * one less than process priority, etc. + * Ignored on Windows. + * @param signal_number The POSIX4 real-time signal number to be used + * to signal completion of the operation. Values + * range from ACE_SIGRTMIN to ACE_SIGRTMAX. + * This argument is ignored on non-POSIX4 systems. + */ + int read (ACE_Message_Block &message_block, + size_t num_bytes_to_read, + const void *act = 0, + int priority = 0, + int signal_number = ACE_SIGRTMIN); + +#if defined (ACE_HAS_WIN32_OVERLAPPED_IO) + /** + * Same as above but with scatter support, through chaining of composite + * message blocks using the continuation field. + */ + int readv (ACE_Message_Block &message_block, + size_t num_bytes_to_read, + const void *act = 0, + int priority = 0, + int signal_number = ACE_SIGRTMIN); +#endif /* defined (ACE_HAS_WIN32_OVERLAPPED_IO) */ + + /// Return the underlying implementation class. + // (this should be protected...) + virtual ACE_Asynch_Operation_Impl *implementation (void) const; + +protected: + /// Implementation class that all methods will be forwarded to. + ACE_Asynch_Read_Stream_Impl *implementation_; + +public: +/** + * @class Result + * + * @brief This is the class which will be passed back to the + * ACE_Handler::handle_read_stream when the asynchronous read completes. + * This class forwards all the methods to the implementation classes. + * + * This class has all the information necessary for the + * handler to uniquiely identify the completion of the + * asynchronous read. + */ + class ACE_Export Result : public ACE_Asynch_Result + { + + /// The concrete implementation result classes only construct this + /// class. + friend class ACE_POSIX_Asynch_Read_Stream_Result; + friend class ACE_WIN32_Asynch_Read_Stream_Result; + + public: + /// The number of bytes which were requested at the start of the + /// asynchronous read. + size_t bytes_to_read (void) const; + + /// Message block which contains the read data. + ACE_Message_Block &message_block (void) const; + + /// I/O handle used for reading. + ACE_HANDLE handle (void) const; + + /// Get the implementation class. + ACE_Asynch_Read_Stream_Result_Impl *implementation (void) const; + + protected: + /// Constructor. + Result (ACE_Asynch_Read_Stream_Result_Impl *implementation); + + /// Destructor. + virtual ~Result (void); + + /// The implementation class. + ACE_Asynch_Read_Stream_Result_Impl *implementation_; + }; +}; + +// Forward declarations +class ACE_Asynch_Write_Stream_Impl; +class ACE_Asynch_Write_Stream_Result_Impl; + +/** + * @class ACE_Asynch_Write_Stream + * + * @brief This class is a factory for initiating asynchronous writes + * on a connected TCP/IP stream. This class forwards all methods to its + * implementation class. + * + * Once open() is called, multiple asynchronous writes can be + * started using this class. An ACE_Asynch_Write_Stream::Result + * will be passed to the ACE_Handler::handle_write_stream() method on the + * opened ACE_Handler object when the asynchronous write completes. + */ +class ACE_Export ACE_Asynch_Write_Stream : public ACE_Asynch_Operation +{ + +public: + /// A do nothing constructor. + ACE_Asynch_Write_Stream (void); + + /// Destructor. + virtual ~ACE_Asynch_Write_Stream (void); + + /** + * Initializes the factory with information which will be used with + * each asynchronous operation. + * + * @param handler ACE_Handler to be notified when operations initiated + * via this factory complete. The handle_write_stream() + * method will be called on this object. + * @param handle The socket handle to initiate write operations on. + * If handle is @c ACE_INVALID_HANDLE, + * ACE_Handler::handle() will be called on handler to + * get the handle value. + * @param completion_key A token that is passed to the completion handler. + * @param proactor The ACE_Proactor object which will control operation + * completion and dispatching the results to handler. + * If this is 0, the process's singleton ACE_Proactor + * will be used. + * + * @retval 0 for success. + * @retval -1 for failure; consult @c errno for further information. + */ + int open (ACE_Handler &handler, + ACE_HANDLE handle = ACE_INVALID_HANDLE, + const void *completion_key = 0, + ACE_Proactor *proactor = 0); + + /** + * Initiates an asynchronous write on a socket. If the operation completes + * the ACE_Handler object registered in open() will receive a completion + * callback via its handle_write_stream() method. + * + * @param bytes_to_write The number of bytes to write. + * @param message_block The ACE_Message_Block containing data to write. + * Data is written to the socket beginning at the + * block's rd_ptr. Upon successful completion + * of the write operation, the message_block rd_ptr + * is updated to reflect the data that was written. + * @param act Token that is passed through to the completion + * handler. + * @param priority Priority of the operation. This argument only has + * an affect on POSIX4-Unix. Works like @c nice in + * Unix; negative values are not allowed. 0 means + * priority of the operation same as the process + * priority. 1 means priority of the operation is one + * less than the process, and so forth. + * @param signal_number The POSIX4 real-time signal number to be used + * for the operation. signal_number ranges from + * ACE_SIGRTMIN to ACE_SIGRTMAX. This argument is + * not used on other platforms. + * + * @retval 0 for success, and the handle_write_stream associated + * with the opened ACE_Handler will be called. An + * instance of ACE_Asynch_Write_Stream::Result will be + * passed to the completion handler. + * @retval -1 for failure; consult @c errno for further information. + */ + int write (ACE_Message_Block &message_block, + size_t bytes_to_write, + const void *act = 0, + int priority = 0, + int signal_number = ACE_SIGRTMIN); + +#if defined (ACE_HAS_WIN32_OVERLAPPED_IO) + /** + * Same as above but with gather support, through chaining of composite + * message blocks using the continuation field. + */ + int writev (ACE_Message_Block &message_block, + size_t bytes_to_write, + const void *act = 0, + int priority = 0, + int signal_number = ACE_SIGRTMIN); +#endif /* defined (ACE_HAS_WIN32_OVERLAPPED_IO) */ + + /// Return the underlying implementation class. + /// @todo (this should be protected...) + virtual ACE_Asynch_Operation_Impl *implementation (void) const; + +protected: + /// Implementation class that all methods will be forwarded to. + ACE_Asynch_Write_Stream_Impl *implementation_; + +public: +/** + * @class Result + * + * @brief This is that class which will be passed back to the + * ACE_Handler when the asynchronous write completes. This class + * forwards all the methods to the implementation class. + * + * This class has all the information necessary for the + * handler to uniquiely identify the completion of the + * asynchronous write. + */ + class ACE_Export Result : public ACE_Asynch_Result + { + + /// The concrete implementation result classes only construct this + /// class. + friend class ACE_POSIX_Asynch_Write_Stream_Result; + friend class ACE_WIN32_Asynch_Write_Stream_Result; + + public: + /// The number of bytes which were requested at the start of the + /// asynchronous write. + size_t bytes_to_write (void) const; + + /// Message block that contains the data to be written. + ACE_Message_Block &message_block (void) const; + + /// I/O handle used for writing. + ACE_HANDLE handle (void) const; + + /// Get the implementation class. + ACE_Asynch_Write_Stream_Result_Impl *implementation (void) const; + + protected: + /// Constructor. + Result (ACE_Asynch_Write_Stream_Result_Impl *implementation); + + /// Destructor. + virtual ~Result (void); + + /// Implementation class. + ACE_Asynch_Write_Stream_Result_Impl *implementation_; + }; +}; + +// Forward declarations +class ACE_Asynch_Read_File_Impl; +class ACE_Asynch_Read_File_Result_Impl; + +/** + * @class ACE_Asynch_Read_File + * + * @brief This class is a factory for starting off asynchronous reads + * on a file. This class forwards all methods to its + * implementation class. + * + * Once open() is called, multiple asynchronous reads can + * started using this class. An ACE_Asynch_Read_File::Result + * will be passed back to the completion handler's + * ACE_Handler::handle_read_file() method when each asynchronous + * read completes. + * This class differs slightly from ACE_Asynch_Read_Stream as it + * allows the user to specify an offset for the read. + */ +class ACE_Export ACE_Asynch_Read_File : public ACE_Asynch_Read_Stream +{ + +public: + /// A do nothing constructor. + ACE_Asynch_Read_File (void); + + /// Destructor. + virtual ~ACE_Asynch_Read_File (void); + + /** + * Initializes the factory with information which will be used with + * each asynchronous operation. + * + * @param handler ACE_Handler to be notified when operations initiated + * via this factory complete. The + * ACE_Handler::handle_read_file() method will be + * called on this object. + * @param handle The file handle to initiate read operations on. + * If handle is @c ACE_INVALID_HANDLE, + * ACE_Handler::handle() will be called on handler to + * get the handle value. + * @param completion_key A token that is passed to the completion handler. + * @param proactor The ACE_Proactor object which will control operation + * completion and dispatching the results to handler. + * If this is 0, the process's singleton ACE_Proactor + * will be used. + * + * @retval 0 for success. + * @retval -1 for failure; consult @c errno for further information. + */ + int open (ACE_Handler &handler, + ACE_HANDLE handle = ACE_INVALID_HANDLE, + const void *completion_key = 0, + ACE_Proactor *proactor = 0); + + /** + * This starts off an asynchronous read. Upto {bytes_to_read} will + * be read and stored in the {message_block}. The read will start + * at {offset} from the beginning of the file. Priority of the + * operation is specified by {priority}. On POSIX4-Unix, this is + * supported. Works like {nice} in Unix. Negative values are not + * allowed. 0 means priority of the operation same as the process + * priority. 1 means priority of the operation is one less than + * process. And so forth. On Win32, this argument is a no-op. + * {signal_number} is the POSIX4 real-time signal number to be used + * for the operation. {signal_number} ranges from ACE_SIGRTMIN to + * ACE_SIGRTMAX. This argument is a no-op on non-POSIX4 systems. + */ + int read (ACE_Message_Block &message_block, + size_t bytes_to_read, + unsigned long offset = 0, + unsigned long offset_high = 0, + const void *act = 0, + int priority = 0, + int signal_number = ACE_SIGRTMIN); + +#if (defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)) + /** + * Same as above but with scatter support, through chaining of composite + * message blocks using the continuation field. + * @note In win32 Each data block payload must be at least the size of a system + * memory page and must be aligned on a system memory page size boundary + */ + int readv (ACE_Message_Block &message_block, + size_t bytes_to_read, + unsigned long offset = 0, + unsigned long offset_high = 0, + const void *act = 0, + int priority = 0, + int signal_number = ACE_SIGRTMIN); +#endif /* (defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)) */ + + /// Return the underlying implementation class. + // (this should be protected...) + virtual ACE_Asynch_Operation_Impl *implementation (void) const; + +protected: + /// Delegation/implementation class that all methods will be + /// forwarded to. + ACE_Asynch_Read_File_Impl *implementation_; + +public: +/** + * @class Result + * + * @brief This is that class which will be passed back to the + * {handler} when the asynchronous read completes. This class + * forwards all the methods to the implementation class. + * + * This class has all the information necessary for the + * {handler} to uniquiely identify the completion of the + * asynchronous read. + * This class differs slightly from + * ACE_Asynch_Read_Stream::Result as it calls back + * {ACE_Handler::handle_read_file} on the {handler} instead of + * {ACE_Handler::handle_read_stream}. No additional state is + * required by this class as ACE_Asynch_Result can store the + * {offset}. + */ + class ACE_Export Result : public ACE_Asynch_Read_Stream::Result + { + + /// The concrete implementation result classes only construct this + /// class. + friend class ACE_POSIX_Asynch_Read_File_Result; + friend class ACE_WIN32_Asynch_Read_File_Result; + + public: + /// Get the implementation class. + ACE_Asynch_Read_File_Result_Impl *implementation (void) const; + + protected: + /// Constructor. This implementation will not be deleted. + Result (ACE_Asynch_Read_File_Result_Impl *implementation); + + /// Destructor. + virtual ~Result (void); + + /// The implementation class. + ACE_Asynch_Read_File_Result_Impl *implementation_; + + private: + /// Here just to provide an dummpy implementation, since the + /// one auto generated by MSVC is flagged as infinitely recursive + void operator= (Result &) {} + }; +}; + +// Forward declarations +class ACE_Asynch_Write_File_Impl; +class ACE_Asynch_Write_File_Result_Impl; + +/** + * @class ACE_Asynch_Write_File + * + * @brief This class is a factory for starting off asynchronous writes + * on a file. This class forwards all methods to its + * implementation class. + * + * Once {open} is called, multiple asynchronous {write}s can be + * started using this class. A ACE_Asynch_Write_File::Result + * will be passed back to the {handler} when the asynchronous + * writes completes through the {ACE_Handler::handle_write_file} + * callback. + * This class differs slightly from ACE_Asynch_Write_Stream as + * it allows the user to specify an offset for the write. + */ +class ACE_Export ACE_Asynch_Write_File : public ACE_Asynch_Write_Stream +{ + +public: + /// A do nothing constructor. + ACE_Asynch_Write_File (void); + + /// Destructor. + virtual ~ACE_Asynch_Write_File (void); + + /** + * Initializes the factory with information which will be used with + * each asynchronous call. If ({handle} == ACE_INVALID_HANDLE), + * {ACE_Handler::handle} will be called on the {handler} to get the + * correct handle. + */ + int open (ACE_Handler &handler, + ACE_HANDLE handle = ACE_INVALID_HANDLE, + const void *completion_key = 0, + ACE_Proactor *proactor = 0); + + /** + * This starts off an asynchronous write. Upto {bytes_to_write} + * will be written from the {message_block}, starting at the + * block's {rd_ptr}. The write will go to the file, starting + * {offset} bytes from the beginning of the file. Priority of the + * operation is specified by {priority}. On POSIX4-Unix, this is + * supported. Works like {nice} in Unix. Negative values are not + * allowed. 0 means priority of the operation same as the process + * priority. 1 means priority of the operation is one less than + * process. And so forth. On Win32, this is a no-op. + * {signal_number} is the POSIX4 real-time signal number to be used + * for the operation. {signal_number} ranges from ACE_SIGRTMIN to + * ACE_SIGRTMAX. This argument is a no-op on non-POSIX4 systems. + */ + int write (ACE_Message_Block &message_block, + size_t bytes_to_write, + unsigned long offset = 0, + unsigned long offset_high = 0, + const void *act = 0, + int priority = 0, + int signal_number = ACE_SIGRTMIN); + +#if (defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)) + /** + * Same as above but with gather support, through chaining of composite + * message blocks using the continuation field. + * @note In win32 Each data block payload must be at least the size of a system + * memory page and must be aligned on a system memory page size boundary + */ + int writev (ACE_Message_Block &message_block, + size_t bytes_to_write, + unsigned long offset = 0, + unsigned long offset_high = 0, + const void *act = 0, + int priority = 0, + int signal_number = ACE_SIGRTMIN); +#endif /* (defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)) */ + + /// Return the underlying implementation class. + // (this should be protected...) + virtual ACE_Asynch_Operation_Impl *implementation (void) const; + +protected: + /// Implementation object. + ACE_Asynch_Write_File_Impl *implementation_; + +public: +/** + * @class Result + * + * @brief This is that class which will be passed back to the + * {handler} when the asynchronous write completes. This class + * forwards all the methods to the implementation class. + * + * This class has all the information necessary for the + * {handler} to uniquiely identify the completion of the + * asynchronous write. + * This class differs slightly from + * ACE_Asynch_Write_Stream::Result as it calls back + * {ACE_Handler::handle_write_file} on the {handler} instead + * of {ACE_Handler::handle_write_stream}. No additional state + * is required by this class as ACE_Asynch_Result can store + * the {offset}. + */ + class ACE_Export Result : public ACE_Asynch_Write_Stream::Result + { + + /// The concrete implementation result classes only construct this + /// class. + friend class ACE_POSIX_Asynch_Write_File_Result; + friend class ACE_WIN32_Asynch_Write_File_Result; + + public: + /// Get the implementation class. + ACE_Asynch_Write_File_Result_Impl *implementation (void) const; + + protected: + /// Constructor. This implementation will not be deleted. + Result (ACE_Asynch_Write_File_Result_Impl *implementation); + + /// Destructor. + virtual ~Result (void); + + /// The implementation class. + ACE_Asynch_Write_File_Result_Impl *implementation_; + + private: + /// Here just to provide an dummpy implementation, since the + /// one auto generated by MSVC is flagged as infinitely recursive + void operator= (Result &) {}; + }; +}; + +// Forward declarations +class ACE_Asynch_Accept_Result_Impl; +class ACE_Asynch_Accept_Impl; + +/** + * @class ACE_Asynch_Accept + * + * @brief This class is a factory for starting off asynchronous accepts + * on a listen handle. This class forwards all methods to its + * implementation class. + * + * Once {open} is called, multiple asynchronous {accept}s can + * started using this class. A ACE_Asynch_Accept::Result will + * be passed back to the {handler} when the asynchronous accept + * completes through the {ACE_Handler::handle_accept} + * callback. + */ +class ACE_Export ACE_Asynch_Accept : public ACE_Asynch_Operation +{ + +public: + /// A do nothing constructor. + ACE_Asynch_Accept (void); + + /// Destructor. + virtual ~ACE_Asynch_Accept (void); + + /** + * Initializes the factory with information which will be used with + * each asynchronous call. If ({handle} == ACE_INVALID_HANDLE), + * {ACE_Handler::handle} will be called on the {handler} to get the + * correct handle. + */ + int open (ACE_Handler &handler, + ACE_HANDLE handle = ACE_INVALID_HANDLE, + const void *completion_key = 0, + ACE_Proactor *proactor = 0); + + /** + * This starts off an asynchronous accept. The asynchronous accept + * call also allows any initial data to be returned to the + * handler specified to @c open(). + * @param message_block A message block to receive initial data, as well + * as the local and remote addresses when the + * connection is made. Since the block receives + * the addresses regardless of whether or not + * initial data is available or requested, the + * message block size must be at least + * @a bytes_to_read plus two times the size of + * the addresses used (IPv4 or IPv6). + * @param bytes_to_read The maximum number of bytes of initial data + * to read into @a message_block. + * @param accept_handle The handle that the new connection will be + * accepted on. If @c INVALID_HANDLE, a new + * handle will be created using @a addr_family. + * @param act Value to be passed in result when operation + * completes. + * @param priority Priority of the operation. On POSIX4-Unix, this + * is supported. Works like @c nice in Unix. + * Negative values are not allowed. 0 means + * priority of the operation same as the process + * priority. 1 means priority of the operation is + * one less than process. And so forth. + * On Win32, this argument is ignored. + * @param signal_number The POSIX4 real-time signal number to be used + * for the operation. Value range is from + * @c ACE_SIGRTMIN to @c ACE_SIGRTMAX. + * This argument is ignored on non-POSIX4 systems. + * @param addr_family The address family to use if @a accept_handle + * is @c ACE_INVALID_HANDLE and a new handle must + * be opened. Values are @c AF_INET and @c PF_INET6. + */ + int accept (ACE_Message_Block &message_block, + size_t bytes_to_read, + ACE_HANDLE accept_handle = ACE_INVALID_HANDLE, + const void *act = 0, + int priority = 0, + int signal_number = ACE_SIGRTMIN, + int addr_family = AF_INET); + + /// Return the underlying implementation class. + // (this should be protected...) + virtual ACE_Asynch_Operation_Impl *implementation (void) const; + +protected: + /// Delegation/implementation class that all methods will be + /// forwarded to. + ACE_Asynch_Accept_Impl *implementation_; + +public: +/** + * @class Result + * + * @brief This is that class which will be passed back to the + * {handler} when the asynchronous accept completes. + * + * This class has all the information necessary for the + * {handler} to uniquiely identify the completion of the + * asynchronous accept. + */ + class ACE_Export Result : public ACE_Asynch_Result + { + + /// The concrete implementation result classes only construct this + /// class. + friend class ACE_POSIX_Asynch_Accept_Result; + friend class ACE_WIN32_Asynch_Accept_Result; + + public: + /// The number of bytes which were requested at the start of the + /// asynchronous accept. + size_t bytes_to_read (void) const; + + /// Message block which contains the read data. + ACE_Message_Block &message_block (void) const; + + /// I/O handle used for accepting new connections. + ACE_HANDLE listen_handle (void) const; + + /// I/O handle for the new connection. + ACE_HANDLE accept_handle (void) const; + + /// Get the implementation. + ACE_Asynch_Accept_Result_Impl *implementation (void) const; + + protected: + /// Contructor. Implementation will not be deleted. + Result (ACE_Asynch_Accept_Result_Impl *implementation); + + /// Destructor. + virtual ~Result (void); + + /// Impelmentation class. + ACE_Asynch_Accept_Result_Impl *implementation_; + }; +}; +// Forward declarations +class ACE_Asynch_Connect_Result_Impl; +class ACE_Asynch_Connect_Impl; + +/** + * @class ACE_Asynch_Connect + * + * @brief This class is a factory for starting off asynchronous connects + * This class forwards all methods to its implementation class. + * + * Once @c open is called, multiple asynchronous connect operationss can + * started using this class. A ACE_Asynch_Connect::Result will + * be passed back to the associated ACE_Handler when the asynchronous connect + * completes through the ACE_Handler::handle_connect() callback. + */ +class ACE_Export ACE_Asynch_Connect : public ACE_Asynch_Operation +{ + +public: + /// A do nothing constructor. + ACE_Asynch_Connect (void); + + /// Destructor. + virtual ~ACE_Asynch_Connect (void); + + /** + * Initializes the factory with information which will be used with + * each asynchronous call. + * + * @note @arg handle is ignored and should be @c ACE_INVALID_HANDLE. + */ + int open (ACE_Handler &handler, + ACE_HANDLE handle = ACE_INVALID_HANDLE, + const void *completion_key = 0, + ACE_Proactor *proactor = 0); + + /** + * This starts off an asynchronous Connect. + */ + int connect (ACE_HANDLE connect_handle, + const ACE_Addr & remote_sap, + const ACE_Addr & local_sap, + int reuse_addr, + const void *act=0, + int priority = 0, + int signal_number = ACE_SIGRTMIN); + + /// Return the underlying implementation class. + // (this should be protected...) + virtual ACE_Asynch_Operation_Impl *implementation (void) const; + +protected: + /// Delegation/implementation class that all methods will be + /// forwarded to. + ACE_Asynch_Connect_Impl *implementation_; + +public: +/** + * @class Result + * + * @brief This is that class which will be passed back to the + * handler when the asynchronous connect completes. + * + * This class has all the information necessary for the + * handler to uniquely identify the completion of the + * asynchronous connect. + */ + class ACE_Export Result : public ACE_Asynch_Result + { + + /// The concrete implementation result classes only construct this + /// class. + friend class ACE_POSIX_Asynch_Connect_Result; + friend class ACE_WIN32_Asynch_Connect_Result; + + public: + + /// I/O handle for the connection. + ACE_HANDLE connect_handle (void) const; + + /// Get the implementation. + ACE_Asynch_Connect_Result_Impl *implementation (void) const; + + protected: + /// Contructor. Implementation will not be deleted. + Result (ACE_Asynch_Connect_Result_Impl *implementation); + + /// Destructor. + virtual ~Result (void); + + /// Impelmentation class. + ACE_Asynch_Connect_Result_Impl *implementation_; + }; +}; + +// Forward declarations +class ACE_Asynch_Transmit_File_Result_Impl; +class ACE_Asynch_Transmit_File_Impl; + +/** + * @class ACE_Asynch_Transmit_File + * + * @brief This class is a factory for starting off asynchronous + * transmit files on a stream. + * + * Once {open} is called, multiple asynchronous {transmit_file}s + * can started using this class. A + * ACE_Asynch_Transmit_File::Result will be passed back to the + * {handler} when the asynchronous transmit file completes + * through the {ACE_Handler::handle_transmit_file} callback. + * The transmit_file function transmits file data over a + * connected network connection. The function uses the operating + * system's cache manager to retrieve the file data. This + * function provides high-performance file data transfer over + * network connections. This function would be of great use in + * a Web Server, Image Server, etc. + */ +class ACE_Export ACE_Asynch_Transmit_File : public ACE_Asynch_Operation +{ + +public: + // Forward declarations + class Header_And_Trailer; + + /// A do nothing constructor. + ACE_Asynch_Transmit_File (void); + + /// Destructor. + virtual ~ACE_Asynch_Transmit_File (void); + + /** + * Initializes the factory with information which will be used with + * each asynchronous call. If ({handle} == ACE_INVALID_HANDLE), + * {ACE_Handler::handle} will be called on the {handler} to get the + * correct handle. + */ + int open (ACE_Handler &handler, + ACE_HANDLE handle = ACE_INVALID_HANDLE, + const void *completion_key = 0, + ACE_Proactor *proactor = 0); + + /** + * This starts off an asynchronous transmit file. The {file} is a + * handle to an open file. {header_and_trailer} is a pointer to a + * data structure that contains pointers to data to send before and + * after the file data is sent. Set this parameter to 0 if you only + * want to transmit the file data. Upto {bytes_to_write} will be + * written to the {socket}. If you want to send the entire file, + * let {bytes_to_write} = 0. {bytes_per_send} is the size of each + * block of data sent per send operation. Please read the Win32 + * documentation on what the flags should be. Priority of the + * operation is specified by {priority}. On POSIX4-Unix, this is + * supported. Works like {nice} in Unix. Negative values are not + * allowed. 0 means priority of the operation same as the process + * priority. 1 means priority of the operation is one less than + * process. And so forth. On Win32, this is a no-op. + * {signal_number} is the POSIX4 real-time signal number to be used + * for the operation. {signal_number} ranges from ACE_SIGRTMIN to + * ACE_SIGRTMAX. This argument is a no-op on non-POSIX4 systems. + */ + int transmit_file (ACE_HANDLE file, + Header_And_Trailer *header_and_trailer = 0, + size_t bytes_to_write = 0, + unsigned long offset = 0, + unsigned long offset_high = 0, + size_t bytes_per_send = 0, + unsigned long flags = 0, + const void *act = 0, + int priority = 0, + int signal_number = ACE_SIGRTMIN); + + /// Return the underlying implementation class. + // (this should be protected...) + virtual ACE_Asynch_Operation_Impl *implementation (void) const; + +protected: + /// The implementation class. + ACE_Asynch_Transmit_File_Impl *implementation_; + +public: +/** + * @class Result + * + * @brief This is that class which will be passed back to the + * {handler} when the asynchronous transmit file completes. + * + * This class has all the information necessary for the + * {handler} to uniquiely identify the completion of the + * asynchronous transmit file. + */ + class ACE_Export Result : public ACE_Asynch_Result + { + + /// The concrete implementation result classes only construct this + /// class. + friend class ACE_POSIX_Asynch_Transmit_File_Result; + friend class ACE_WIN32_Asynch_Transmit_File_Result; + + public: + /// Socket used for transmitting the file. + ACE_HANDLE socket (void) const; + + /// File from which the data is read. + ACE_HANDLE file (void) const; + + /// Header and trailer data associated with this transmit file. + Header_And_Trailer *header_and_trailer (void) const; + + /// The number of bytes which were requested at the start of the + /// asynchronous transmit file. + size_t bytes_to_write (void) const; + + /// Number of bytes per send requested at the start of the transmit + /// file. + size_t bytes_per_send (void) const; + + /// Flags which were passed into transmit file. + unsigned long flags (void) const; + + /// Get the implementation class. + ACE_Asynch_Transmit_File_Result_Impl *implementation (void) const; + + protected: + /// Constructor. + Result (ACE_Asynch_Transmit_File_Result_Impl *implementation); + + /// Destructor. + virtual ~Result (void); + + /// The implementation class. + ACE_Asynch_Transmit_File_Result_Impl *implementation_; + }; + +/** + * @class Header_And_Trailer + * + * @brief The class defines a data structure that contains pointers + * to data to send before and after the file data is sent. + * + * This class provides a wrapper over TRANSMIT_FILE_BUFFERS + * and provided a consistent use of ACE_Message_Blocks. + */ + class ACE_Export Header_And_Trailer + { + + public: + /// Constructor. + Header_And_Trailer (ACE_Message_Block *header = 0, + size_t header_bytes = 0, + ACE_Message_Block *trailer = 0, + size_t trailer_bytes = 0); + + /// Destructor + virtual ~Header_And_Trailer (void); + + /// This method allows all the member to be set in one fell swoop. + void header_and_trailer (ACE_Message_Block *header = 0, + size_t header_bytes = 0, + ACE_Message_Block *trailer = 0, + size_t trailer_bytes = 0); + + /// Get header which goes before the file data. + ACE_Message_Block *header (void) const; + + /// Set header which goes before the file data. + void header (ACE_Message_Block *message_block); + + /// Get size of the header data. + size_t header_bytes (void) const; + + /// Set size of the header data. + void header_bytes (size_t bytes); + + /// Get trailer which goes after the file data. + ACE_Message_Block *trailer (void) const; + + /// Set trailer which goes after the file data. + void trailer (ACE_Message_Block *message_block); + + /// Get size of the trailer data. + size_t trailer_bytes (void) const; + + /// Set size of the trailer data. + void trailer_bytes (size_t bytes); + + /// Conversion routine. + ACE_LPTRANSMIT_FILE_BUFFERS transmit_buffers (void); + + protected: + /// Header data. + ACE_Message_Block *header_; + + /// Size of header data. + size_t header_bytes_; + + /// Trailer data. + ACE_Message_Block *trailer_; + + /// Size of trailer data. + size_t trailer_bytes_; + + /// Target data structure. + ACE_TRANSMIT_FILE_BUFFERS transmit_buffers_; + }; +}; + + +// Forward declarations +class ACE_Asynch_Read_Dgram_Result_Impl; +class ACE_Asynch_Read_Dgram_Impl; +class ACE_Addr; + +/** + * @class ACE_Asynch_Read_Dgram + * + * @brief This class is a factory for starting off asynchronous reads + * on a UDP socket. This class forwards all methods to its + * implementation class. + * + * Once {open} is called, multiple asynchronous {read}s can be + * started using this class. An ACE_Asynch_Read_Dgram::Result + * will be passed back to the {handler} when the asynchronous + * reads completes through the {ACE_Handler::handle_read_dgram} + * callback. + */ +class ACE_Export ACE_Asynch_Read_Dgram : public ACE_Asynch_Operation +{ + +public: + /// A do nothing constructor. + ACE_Asynch_Read_Dgram (void); + + /// Destructor + virtual ~ACE_Asynch_Read_Dgram (void); + + /** + * Initializes the factory with information which will be used with + * each asynchronous call. If ({handle} == ACE_INVALID_HANDLE), + * {ACE_Handler::handle} will be called on the {handler} to get the + * correct handle. + */ + int open (ACE_Handler &handler, + ACE_HANDLE handle = ACE_INVALID_HANDLE, + const void *completion_key = 0, + ACE_Proactor *proactor = 0); + + /** This starts off an asynchronous read. Upto + * {message_block->total_size()} will be read and stored in the + * {message_block}. {message_block}'s {wr_ptr} will be updated to reflect + * the added bytes if the read operation is successfully completed. + * Return code of 1 means immediate success and {number_of_bytes_recvd} + * will contain number of bytes read. The {ACE_Handler::handle_read_dgram} + * method will still be called. Return code of 0 means the IO will + * complete proactively. Return code of -1 means there was an error, use + * errno to get the error code. + * + * Scatter/gather is supported on WIN32 by using the {message_block->cont()} + * method. Up to ACE_IOV_MAX {message_block}'s are supported. Upto + * {message_block->size()} bytes will be read into each {message block} for + * a total of {message_block->total_size()} bytes. All {message_block}'s + * {wr_ptr}'s will be updated to reflect the added bytes for each + * {message_block} + * + * Priority of the operation is specified by {priority}. On POSIX4-Unix, + * this is supported. Works like {nice} in Unix. Negative values are not + * allowed. 0 means priority of the operation same as the process + * priority. 1 means priority of the operation is one less than + * process. And so forth. On Win32, {priority} is a no-op. + * {signal_number} is the POSIX4 real-time signal number to be used + * for the operation. {signal_number} ranges from ACE_SIGRTMIN to + * ACE_SIGRTMAX. This argument is a no-op on non-POSIX4 systems. + */ + ssize_t recv (ACE_Message_Block *message_block, + size_t &number_of_bytes_recvd, + int flags, + int protocol_family = PF_INET, + const void *act = 0, + int priority = 0, + int signal_number = ACE_SIGRTMIN); + + /// Return the underlying implementation class. + // (this should be protected...) + virtual ACE_Asynch_Operation_Impl *implementation (void) const; + +protected: + /// Implementation class that all methods will be forwarded to. + ACE_Asynch_Read_Dgram_Impl *implementation_; + +public: +/** + * @class Result + * + * @brief This is the class which will be passed back to the + * {handler} when the asynchronous read completes. This class + * forwards all the methods to the implementation classes. + * + * This class has all the information necessary for the + * {handler} to uniquiely identify the completion of the + * asynchronous read. + */ + class ACE_Export Result : public ACE_Asynch_Result + { + + /// The concrete implementation result classes only construct this + /// class. + friend class ACE_POSIX_Asynch_Read_Dgram_Result; + friend class ACE_WIN32_Asynch_Read_Dgram_Result; + + public: + + /// The number of bytes which were requested at the start of the + /// asynchronous read. + size_t bytes_to_read (void) const; + + /// Message block which contains the read data + ACE_Message_Block *message_block (void) const; + + /// The flags used in the read + int flags (void) const; + + /// The address of where the packet came from + int remote_address (ACE_Addr& addr) const; + + /// I/O handle used for reading. + ACE_HANDLE handle (void) const; + + /// Get the implementation class. + ACE_Asynch_Read_Dgram_Result_Impl *implementation (void) const; + + protected: + /// Constructor. + Result (ACE_Asynch_Read_Dgram_Result_Impl *implementation); + + /// Destructor. + virtual ~Result (void); + + /// The implementation class. + ACE_Asynch_Read_Dgram_Result_Impl *implementation_; + }; +}; + +// Forward declarations +class ACE_Asynch_Write_Dgram_Impl; +class ACE_Asynch_Write_Dgram_Result_Impl; + +/** + * @class ACE_Asynch_Write_Dgram + * + * @brief This class is a factory for starting off asynchronous writes + * on a UDP socket. This class forwards all methods to its + * implementation class. + * + * Once {open} is called, multiple asynchronous {writes}s can + * started using this class. An ACE_Asynch_Write_Dgram::Result + * will be passed back to the {handler} when the asynchronous + * write completes through the + * {ACE_Handler::handle_write_dgram} callback. + */ +class ACE_Export ACE_Asynch_Write_Dgram : public ACE_Asynch_Operation +{ + +public: + /// A do nothing constructor. + ACE_Asynch_Write_Dgram (void); + + /// Destructor. + virtual ~ACE_Asynch_Write_Dgram (void); + + /** + * Initializes the factory with information which will be used with + * each asynchronous call. If ({handle} == ACE_INVALID_HANDLE), + * {ACE_Handler::handle} will be called on the {handler} to get the + * correct handle. + */ + int open (ACE_Handler &handler, + ACE_HANDLE handle = ACE_INVALID_HANDLE, + const void *completion_key = 0, + ACE_Proactor *proactor = 0); + + /** This starts off an asynchronous send. Upto + * {message_block->total_length()} will be sent. {message_block}'s + * {rd_ptr} will be updated to reflect the sent bytes if the send operation + * is successfully completed. + * Return code of 1 means immediate success and {number_of_bytes_sent} + * is updated to number of bytes sent. The {ACE_Handler::handle_write_dgram} + * method will still be called. Return code of 0 means the IO will + * complete proactively. Return code of -1 means there was an error, use + * errno to get the error code. + * + * Scatter/gather is supported on WIN32 by using the {message_block->cont()} + * method. Up to ACE_IOV_MAX {message_block}'s are supported. Upto + * {message_block->length()} bytes will be sent from each {message block} + * for a total of {message_block->total_length()} bytes. All + * {message_block}'s {rd_ptr}'s will be updated to reflect the bytes sent + * from each {message_block}. + * + * Priority of the operation is specified by {priority}. On POSIX4-Unix, + * this is supported. Works like {nice} in Unix. Negative values are not + * allowed. 0 means priority of the operation same as the process + * priority. 1 means priority of the operation is one less than + * process. And so forth. On Win32, this argument is a no-op. + * {signal_number} is the POSIX4 real-time signal number to be used + * for the operation. {signal_number} ranges from ACE_SIGRTMIN to + * ACE_SIGRTMAX. This argument is a no-op on non-POSIX4 systems. + */ + ssize_t send (ACE_Message_Block *message_block, + size_t &number_of_bytes_sent, + int flags, + const ACE_Addr& remote_addr, + const void *act = 0, + int priority = 0, + int signal_number = ACE_SIGRTMIN); + + /// Return the underlying implementation class. + // (this should be protected...) + virtual ACE_Asynch_Operation_Impl *implementation (void) const; + +protected: + /// Implementation class that all methods will be forwarded to. + ACE_Asynch_Write_Dgram_Impl *implementation_; + +public: +/** + * @class Result + * + * @brief This is that class which will be passed back to the + * {handler} when the asynchronous write completes. This class + * forwards all the methods to the implementation class. + * + * This class has all the information necessary for the + * {handler} to uniquiely identify the completion of the + * asynchronous write. + */ + class ACE_Export Result : public ACE_Asynch_Result + { + + /// The concrete implementation result classes only construct this + /// class. + friend class ACE_POSIX_Asynch_Write_Dgram_Result; + friend class ACE_WIN32_Asynch_Write_Dgram_Result; + + public: + + /// The number of bytes which were requested at the start of the + /// asynchronous write. + size_t bytes_to_write (void) const; + + /// Message block which contains the sent data + ACE_Message_Block *message_block (void) const; + + /// The flags using in the write + int flags (void) const; + + /// I/O handle used for writing. + ACE_HANDLE handle (void) const; + + /// Get the implementation class. + ACE_Asynch_Write_Dgram_Result_Impl *implementation (void) const; + + protected: + /// Constructor. + Result (ACE_Asynch_Write_Dgram_Result_Impl *implementation); + + /// Destructor. + virtual ~Result (void); + + /// Implementation class. + ACE_Asynch_Write_Dgram_Result_Impl *implementation_; + }; +}; + + +/** + * @class ACE_Handler + * + * @brief This base class defines the interface for receiving the + * results of asynchronous operations. + * + * Subclasses of this class will fill in appropriate methods. + */ +class ACE_Export ACE_Handler +{ +public: + /// A do nothing constructor. + ACE_Handler (void); + + /// A do nothing constructor which allows proactor to be set to \. + ACE_Handler (ACE_Proactor *p); + + /// Virtual destruction. + virtual ~ACE_Handler (void); + + /// This method will be called when an asynchronous read completes on + /// a stream. + virtual void handle_read_stream (const ACE_Asynch_Read_Stream::Result &result); + + /// This method will be called when an asynchronous write completes + /// on a UDP socket. + virtual void handle_write_dgram (const ACE_Asynch_Write_Dgram::Result &result); + + /// This method will be called when an asynchronous read completes on + /// a UDP socket. + virtual void handle_read_dgram (const ACE_Asynch_Read_Dgram::Result &result); + + /// This method will be called when an asynchronous write completes + /// on a stream. + virtual void handle_write_stream (const ACE_Asynch_Write_Stream::Result &result); + + /// This method will be called when an asynchronous read completes on + /// a file. + virtual void handle_read_file (const ACE_Asynch_Read_File::Result &result); + + /// This method will be called when an asynchronous write completes + /// on a file. + virtual void handle_write_file (const ACE_Asynch_Write_File::Result &result); + + /// This method will be called when an asynchronous accept completes. + virtual void handle_accept (const ACE_Asynch_Accept::Result &result); + + /// This method will be called when an asynchronous connect completes. + virtual void handle_connect (const ACE_Asynch_Connect::Result &result); + + /// This method will be called when an asynchronous transmit file + /// completes. + virtual void handle_transmit_file (const ACE_Asynch_Transmit_File::Result &result); + + /// Called when timer expires. {tv} was the requested time value and + /// {act} is the ACT passed when scheduling the timer. + virtual void handle_time_out (const ACE_Time_Value &tv, + const void *act = 0); + + /** + * This is method works with the {run_event_loop} of the + * ACE_Proactor. A special {Wake_Up_Completion} is used to wake up + * all the threads that are blocking for completions. + */ + virtual void handle_wakeup (void); + + /// Get the proactor associated with this handler. + ACE_Proactor *proactor (void); + + /// Set the proactor. + void proactor (ACE_Proactor *p); + + /** + * Get the I/O handle used by this {handler}. This method will be + * called by the ACE_Asynch_* classes when an ACE_INVALID_HANDLE is + * passed to {open}. + */ + virtual ACE_HANDLE handle (void) const; + + /// Set the ACE_HANDLE value for this Handler. + virtual void handle (ACE_HANDLE); + + /** + * @class Proxy + * + * @brief The Proxy class acts as a proxy for dispatch of completions + * to operations issued for the associated handler. It allows the handler + * to be deleted while operations are outstanding. The proxy must be used + * to get the ACE_Handler pointer for dispatching, and if it's 0, the + * handler is no longer valid and the result should not be dispatched. + */ + class ACE_Export Proxy + { + public: + Proxy (ACE_Handler *handler) : handler_ (handler) {}; + void reset (void) { this->handler_ = 0; }; + ACE_Handler *handler (void) { return this->handler_; }; + private: + ACE_Handler *handler_; + }; + typedef ACE_Refcounted_Auto_Ptr + Proxy_Ptr; + + Proxy_Ptr &proxy (void); + +protected: + /// The proactor associated with this handler. + ACE_Proactor *proactor_; + + /// The ACE_HANDLE in use with this handler. + ACE_HANDLE handle_; + + /// Refers to proxy for this handler. + ACE_Refcounted_Auto_Ptr proxy_; + + ACE_UNIMPLEMENTED_FUNC (ACE_Handler (const ACE_Handler &)) + ACE_UNIMPLEMENTED_FUNC (ACE_Handler operator= (const ACE_Handler &)) +}; + +// Forward declarations +class ACE_INET_Addr; + +// Forward declarations +template +class ACE_Asynch_Acceptor; + +/** + * @class ACE_Service_Handler + * + * @brief This base class defines the interface for the + * ACE_Asynch_Acceptor to call into when new connection are + * accepted. + * + * Subclasses of this class will fill in appropriate methods to + * define application specific behavior. + */ +class ACE_Export ACE_Service_Handler : public ACE_Handler +{ + + /// The Acceptor is the factory and therefore should have special + /// privileges. + friend class ACE_Asynch_Acceptor; + +public: + /// A do nothing constructor. + ACE_Service_Handler (void); + + /// Virtual destruction. + virtual ~ACE_Service_Handler (void); + + /** + * {open} is called by ACE_Asynch_Acceptor to initialize a new + * instance of ACE_Service_Handler that has been created after the + * new connection is accepted. The handle for the new connection is + * passed along with the initial data that may have shown up. + */ + virtual void open (ACE_HANDLE new_handle, + ACE_Message_Block &message_block); + + // protected: + // This should be corrected after the correct semantics of the + // friend has been figured out. + + /// Called by ACE_Asynch_Acceptor to pass the addresses of the new + /// connections. + virtual void addresses (const ACE_INET_Addr &remote_address, + const ACE_INET_Addr &local_address); + + /// Called by ACE_Asynch_Acceptor to pass the act. + virtual void act (const void *); +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#endif /* ACE_WIN32 || ACE_HAS_AIO_CALLS*/ +#include /**/ "ace/post.h" +#endif /* ACE_ASYNCH_IO_H */ diff --git a/dep/ACE_wrappers/ace/Asynch_IO_Impl.cpp b/dep/ACE_wrappers/ace/Asynch_IO_Impl.cpp new file mode 100644 index 00000000000..b4b47eda55c --- /dev/null +++ b/dep/ACE_wrappers/ace/Asynch_IO_Impl.cpp @@ -0,0 +1,117 @@ +// $Id: Asynch_IO_Impl.cpp 80826 2008-03-04 14:51:23Z wotte $ + +#include "ace/Asynch_IO_Impl.h" + +#if defined (ACE_HAS_WIN32_OVERLAPPED_IO) || defined (ACE_HAS_AIO_CALLS) +// This only works on Win32 platforms and on Unix platforms supporting +// aio calls. + +#if !defined (__ACE_INLINE__) +#include "ace/Asynch_IO_Impl.inl" +#endif /* __ACE_INLINE__ */ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_Asynch_Result_Impl::~ACE_Asynch_Result_Impl (void) +{ +} + +ACE_Asynch_Operation_Impl::~ACE_Asynch_Operation_Impl (void) +{ +} + +ACE_Asynch_Read_Stream_Impl::~ACE_Asynch_Read_Stream_Impl (void) +{ +} + +ACE_Asynch_Read_Stream_Result_Impl::~ACE_Asynch_Read_Stream_Result_Impl (void) +{ +} + +ACE_Asynch_Write_Stream_Impl::~ACE_Asynch_Write_Stream_Impl (void) +{ +} + +ACE_Asynch_Write_Stream_Result_Impl::~ACE_Asynch_Write_Stream_Result_Impl (void) +{ +} + +ACE_Asynch_Read_File_Impl::~ACE_Asynch_Read_File_Impl (void) +{ +} + +ACE_Asynch_Write_File_Impl::~ACE_Asynch_Write_File_Impl (void) +{ +} + +ACE_Asynch_Read_File_Result_Impl::~ACE_Asynch_Read_File_Result_Impl (void) +{ +} + +ACE_Asynch_Write_File_Result_Impl::~ACE_Asynch_Write_File_Result_Impl (void) +{ +} + +ACE_Asynch_Accept_Result_Impl::~ACE_Asynch_Accept_Result_Impl (void) +{ +} + +ACE_Asynch_Connect_Result_Impl::~ACE_Asynch_Connect_Result_Impl (void) +{ +} + +ACE_Asynch_Accept_Impl::~ACE_Asynch_Accept_Impl (void) +{ +} + +ACE_Asynch_Connect_Impl::~ACE_Asynch_Connect_Impl (void) +{ +} + +ACE_Asynch_Transmit_File_Impl::~ACE_Asynch_Transmit_File_Impl (void) +{ +} + +ACE_Asynch_Transmit_File_Result_Impl::~ACE_Asynch_Transmit_File_Result_Impl (void) +{ +} + +ACE_Asynch_Read_Dgram_Impl::~ACE_Asynch_Read_Dgram_Impl (void) +{ +} + +ACE_Asynch_Read_Dgram_Impl::ACE_Asynch_Read_Dgram_Impl (void) +{ +} + +ACE_Asynch_Write_Dgram_Impl::~ACE_Asynch_Write_Dgram_Impl (void) +{ +} + +ACE_Asynch_Write_Dgram_Impl::ACE_Asynch_Write_Dgram_Impl (void) +{ +} + +//*********************************************** + +ACE_Asynch_Read_Dgram_Result_Impl::~ACE_Asynch_Read_Dgram_Result_Impl (void) +{ +} + +ACE_Asynch_Read_Dgram_Result_Impl::ACE_Asynch_Read_Dgram_Result_Impl (void) +{ +} + +//*********************************************** + +ACE_Asynch_Write_Dgram_Result_Impl::~ACE_Asynch_Write_Dgram_Result_Impl (void) +{ +} + +ACE_Asynch_Write_Dgram_Result_Impl::ACE_Asynch_Write_Dgram_Result_Impl (void) +{ +} + +ACE_END_VERSIONED_NAMESPACE_DECL + +#endif /* ACE_HAS_WIN32_OVERLAPPED_IO || ACE_HAS_AIO_CALLS */ diff --git a/dep/ACE_wrappers/ace/Asynch_IO_Impl.h b/dep/ACE_wrappers/ace/Asynch_IO_Impl.h new file mode 100644 index 00000000000..06eb5c10a87 --- /dev/null +++ b/dep/ACE_wrappers/ace/Asynch_IO_Impl.h @@ -0,0 +1,816 @@ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file Asynch_IO_Impl.h + * + * $Id: Asynch_IO_Impl.h 80826 2008-03-04 14:51:23Z wotte $ + * + * + * This class contains asbtract base classes for all the concrete + * implementation classes for the various asynchronous operations + * that are used with the Praoctor. + * + * + * @author Irfan Pyarali (irfan@cs.wustl.edu) + * @author Tim Harrison (harrison@cs.wustl.edu) + * @author Alexander Babu Arulanthu + * @author Roger Tragin + * @author Alexander Libman + */ +//============================================================================= + +#ifndef ACE_ASYNCH_IO_IMPL_H +#define ACE_ASYNCH_IO_IMPL_H +#include /**/ "ace/pre.h" + +#include /**/ "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +#pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#if defined (ACE_HAS_WIN32_OVERLAPPED_IO) || defined (ACE_HAS_AIO_CALLS) +// This only works on Win32 platforms and on Unix platforms supporting +// aio calls. + +#include "ace/Asynch_IO.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +// Forward declaration. +class ACE_Proactor_Impl; + +/** + * @class ACE_Asynch_Result_Impl + * + * @brief Abstract base class for the all the classes that provide + * concrete implementations for ACE_Asynch_Result. + * + */ +class ACE_Export ACE_Asynch_Result_Impl +{ +public: + virtual ~ACE_Asynch_Result_Impl (void); + + /// Number of bytes transferred by the operation. + virtual size_t bytes_transferred (void) const = 0; + + /// ACT associated with the operation. + virtual const void *act (void) const = 0; + + /// Did the operation succeed? + virtual int success (void) const = 0; + + /// This ACT is not the same as the ACT associated with the + /// asynchronous operation. + virtual const void *completion_key (void) const = 0; + + /// Error value if the operation fail. + virtual u_long error (void) const = 0; + + /// Event associated with the OVERLAPPED structure. + virtual ACE_HANDLE event (void) const = 0; + + /// This really make sense only when doing file I/O. + virtual u_long offset (void) const = 0; + virtual u_long offset_high (void) const = 0; + + /// Priority of the operation. + virtual int priority (void) const = 0; + + /** + * POSIX4 real-time signal number to be used for the + * operation. ranges from SIGRTMIN to SIGRTMAX. By + * default, SIGRTMIN is used to issue calls. This is a no-op + * on non-POSIX4 systems and returns 0. + */ + virtual int signal_number (void) const = 0; + + // protected: + // + // These two should really be protected. But sometimes it + // simplifies code to be able to "fake" a result. Use carefully. + /// This is called when the asynchronous operation completes. + virtual void complete (size_t bytes_transferred, + int success, + const void *completion_key, + u_long error = 0) = 0; + + /// Post @c this to the Proactor's completion port. + virtual int post_completion (ACE_Proactor_Impl *proactor) = 0; + +protected: + /// Do-nothing constructor. + ACE_Asynch_Result_Impl (void); +}; + +/** + * @class ACE_Asynch_Operation_Impl + * + * @brief Abstract base class for all the concrete implementation + * classes that provide different implementations for the + * ACE_Asynch_Operation. + */ +class ACE_Export ACE_Asynch_Operation_Impl +{ +public: + virtual ~ACE_Asynch_Operation_Impl (void); + + /** + * Initializes the factory with information which will be used with + * each asynchronous call. If @a handle == ACE_INVALID_HANDLE, + * ACE_Handler::handle() will be called on the proxied handler to get the + * correct handle. + */ + virtual int open (const ACE_Handler::Proxy_Ptr &handler_proxy, + ACE_HANDLE handle, + const void *completion_key, + ACE_Proactor *proactor) = 0; + + /** + * This cancels all pending accepts operations that were issued by + * the calling thread. The function does not cancel asynchronous + * operations issued by other threads. + */ + virtual int cancel (void) = 0; + + // = Access methods. + + /// Return the underlying proactor. + virtual ACE_Proactor* proactor (void) const = 0; + +protected: + /// Do-nothing constructor. + ACE_Asynch_Operation_Impl (void); +}; + +/** + * @class ACE_Asynch_Read_Stream_Impl + * + * @brief Abstract base class for all the concrete implementation + * classes that provide different implementations for the + * ACE_Asynch_Read_Stream + * + */ +class ACE_Export ACE_Asynch_Read_Stream_Impl : public virtual ACE_Asynch_Operation_Impl +{ +public: + virtual ~ACE_Asynch_Read_Stream_Impl (void); + + /// This starts off an asynchronous read. Upto @a bytes_to_read will + /// be read and stored in the @a message_block. + virtual int read (ACE_Message_Block &message_block, + size_t bytes_to_read, + const void *act, + int priority, + int signal_number) = 0; + +#if (defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)) + /** + * Same as above but with scatter support, through chaining of composite + * message blocks using the continuation field. + */ + virtual int readv (ACE_Message_Block &message_block, + size_t bytes_to_read, + const void *act, + int priority, + int signal_number) = 0; +#endif /* (defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)) */ + +protected: + /// Do-nothing constructor. + ACE_Asynch_Read_Stream_Impl (void); +}; + +/** + * @class ACE_Asynch_Read_Stream_Result_Impl + * + * @brief Abstract base class for all the concrete implementation + * classes that provide different implementations for the + * ACE_Asynch_Read_Stream::Result class. + * + */ +class ACE_Export ACE_Asynch_Read_Stream_Result_Impl : public virtual ACE_Asynch_Result_Impl +{ +public: + virtual ~ACE_Asynch_Read_Stream_Result_Impl (void); + + /// The number of bytes which were requested at the start of the + /// asynchronous read. + virtual size_t bytes_to_read (void) const = 0; + + /// Message block which contains the read data. + virtual ACE_Message_Block &message_block (void) const = 0; + + /// I/O handle used for reading. + virtual ACE_HANDLE handle (void) const = 0; + +protected: + /// Do-nothing constructor. + ACE_Asynch_Read_Stream_Result_Impl (void); +}; + +/** + * @class ACE_Asynch_Write_Stream_Impl + * + * @brief Abstract base class for all the concrete implementation + * classes that provide different implementations for the + * ACE_Asynch_Write_Stream class. + * + */ +class ACE_Export ACE_Asynch_Write_Stream_Impl : public virtual ACE_Asynch_Operation_Impl +{ +public: + virtual ~ACE_Asynch_Write_Stream_Impl (void); + + /// This starts off an asynchronous write. Upto @a bytes_to_write + /// will be written from the @a message_block. + virtual int write (ACE_Message_Block &message_block, + size_t bytes_to_write, + const void *act, + int priority, + int signal_number) = 0; + +#if (defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)) + /** + * Same as above but with gather support, through chaining of composite + * message blocks using the continuation field. + */ + virtual int writev (ACE_Message_Block &message_block, + size_t bytes_to_write, + const void *act, + int priority, + int signal_number) = 0; +#endif /* (defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)) */ + +protected: + /// Do-nothing constructor. + ACE_Asynch_Write_Stream_Impl (void); +}; + +/** + * @class ACE_Asynch_Write_Stream_Result_Impl + * + * @brief Abstract base class for all the concrete implementation + * classes that provide different implementations for the + * ACE_Asynch_Write_Stream::Result. + * + */ +class ACE_Export ACE_Asynch_Write_Stream_Result_Impl : public virtual ACE_Asynch_Result_Impl +{ +public: + virtual ~ACE_Asynch_Write_Stream_Result_Impl (void); + + /// The number of bytes which were requested at the start of the + /// asynchronous write. + virtual size_t bytes_to_write (void) const = 0; + + /// Message block that contains the data to be written. + virtual ACE_Message_Block &message_block (void) const = 0; + + /// I/O handle used for writing. + virtual ACE_HANDLE handle (void) const = 0; + +protected: + /// Do-nothing constructor. + ACE_Asynch_Write_Stream_Result_Impl (void); +}; + +/** + * @class ACE_Asynch_Read_File_Impl + * + * @brief Abstract base class for all the concrete implementation + * classes that provide different implementations for the + * ACE_Asynch_Read_File::Result. + * + */ +class ACE_Export ACE_Asynch_Read_File_Impl : public virtual ACE_Asynch_Read_Stream_Impl +{ +public: + virtual ~ACE_Asynch_Read_File_Impl (void); + + /** + * This starts off an asynchronous read. Upto @a bytes_to_read will + * be read and stored in the @a message_block. The read will start + * at @a offset from the beginning of the file. + */ + virtual int read (ACE_Message_Block &message_block, + size_t bytes_to_read, + u_long offset, + u_long offset_high, + const void *act, + int priority, + int signal_number) = 0; + +#if (defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)) + /** + * Same as above but with scatter support, through chaining of composite + * message blocks using the continuation field. + * @note In win32 Each data block payload must be at least the size of a system + * memory page and must be aligned on a system memory page size boundary + */ + virtual int readv (ACE_Message_Block &message_block, + size_t bytes_to_read, + u_long offset, + u_long offset_high, + const void *act, + int priority, + int signal_number) = 0; +#endif /* (defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)) */ + + /// This starts off an asynchronous read. Upto @a bytes_to_read will + /// be read and stored in the @a message_block. + virtual int read (ACE_Message_Block &message_block, + size_t bytes_to_read, + const void *act, + int priority, + int signal_number) = 0; + +#if (defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)) + /** + * Same as above but with scatter support, through chaining of composite + * message blocks using the continuation field. + */ + virtual int readv (ACE_Message_Block &message_block, + size_t bytes_to_read, + const void *act, + int priority, + int signal_number) = 0; +#endif /* (defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)) */ + +protected: + /// Do-nothing constructor. + ACE_Asynch_Read_File_Impl (void); +}; + +/** + * @class ACE_Asynch_Read_File_Result_Impl + * + * @brief This is the abstract base class for all the concrete + * implementation classes for ACE_Asynch_Read_File::Result. + * + */ +class ACE_Export ACE_Asynch_Read_File_Result_Impl : public virtual ACE_Asynch_Read_Stream_Result_Impl +{ +public: + /// Destructor. + virtual ~ACE_Asynch_Read_File_Result_Impl (void); + +protected: + /// Do-nothing constructor. + ACE_Asynch_Read_File_Result_Impl (void); +}; + +/** + * @class ACE_Asynch_Write_File_Impl + * + * @brief Abstract base class for all the concrete implementation + * classes that provide different implementations for the + * ACE_Asynch_Write_File. + * + */ +class ACE_Export ACE_Asynch_Write_File_Impl : public virtual ACE_Asynch_Write_Stream_Impl +{ +public: + virtual ~ACE_Asynch_Write_File_Impl (void); + + /** + * This starts off an asynchronous write. Upto @a bytes_to_write + * will be write and stored in the @a message_block. The write will + * start at @a offset from the beginning of the file. + */ + virtual int write (ACE_Message_Block &message_block, + size_t bytes_to_write, + u_long offset, + u_long offset_high, + const void *act, + int priority, + int signal_number) = 0; + +#if (defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)) + /** + * Same as above but with gather support, through chaining of composite + * message blocks using the continuation field. + * @note In win32 Each data block payload must be at least the size of a system + * memory page and must be aligned on a system memory page size boundary + */ + virtual int writev (ACE_Message_Block &message_block, + size_t bytes_to_write, + u_long offset, + u_long offset_high, + const void *act, + int priority, + int signal_number) = 0; +#endif /* (defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)) */ + + /// This starts off an asynchronous write. Upto @a bytes_to_write + /// will be written from the @a message_block. + virtual int write (ACE_Message_Block &message_block, + size_t bytes_to_write, + const void *act, + int priority, + int signal_number) = 0; + +#if (defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)) + /** + * Same as above but with gather support, through chaining of composite + * message blocks using the continuation field. + */ + virtual int writev (ACE_Message_Block &message_block, + size_t bytes_to_write, + const void *act, + int priority, + int signal_number) = 0; +#endif /* (defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)) */ + +protected: + /// Do-nothing constructor. + ACE_Asynch_Write_File_Impl (void); +}; + +/** + * @class ACE_Asynch_Write_File_Result_Impl + * + * @brief This is the abstract base class for all the concrete + * implementation classes that provide different implementations + * for the ACE_Asynch_Write_File::Result. + * + */ +class ACE_Export ACE_Asynch_Write_File_Result_Impl : public virtual ACE_Asynch_Write_Stream_Result_Impl +{ +public: + virtual ~ACE_Asynch_Write_File_Result_Impl (void); + +protected: + /// Do-nothing constructor. + ACE_Asynch_Write_File_Result_Impl (void); +}; + +/** + * @class ACE_Asynch_Accept_Impl + * + * @brief Abstract base class for all the concrete implementation + * classes that provide different implementations for the + * ACE_Asynch_Accept. + * + */ +class ACE_Export ACE_Asynch_Accept_Impl : public virtual ACE_Asynch_Operation_Impl +{ +public: + virtual ~ACE_Asynch_Accept_Impl (void); + + /** + * This starts off an asynchronous accept. The asynchronous accept + * call also allows any initial data to be returned to the + * . Upto @a bytes_to_read will be read and stored in the + * @a message_block. The @a accept_handle will be used for the + * call. If (@a accept_handle == INVALID_HANDLE), a new + * handle will be created. + * + * @a message_block must be specified. This is because the address of + * the new connection is placed at the end of this buffer. + */ + virtual int accept (ACE_Message_Block &message_block, + size_t bytes_to_read, + ACE_HANDLE accept_handle, + const void *act, + int priority, + int signal_number, + int addr_family) = 0; + +protected: + /// Do-nothing constructor. + ACE_Asynch_Accept_Impl (void); +}; + +/** + * @class ACE_Asynch_Accept_Result_Impl + * + * @brief Abstract base class for all the concrete implementation + * classes that provide different implementations for the + * ACE_Asynch_Accept. + * + */ +class ACE_Export ACE_Asynch_Accept_Result_Impl : public virtual ACE_Asynch_Result_Impl +{ +public: + virtual ~ACE_Asynch_Accept_Result_Impl (void); + + /// The number of bytes which were requested at the start of the + /// asynchronous accept. + virtual size_t bytes_to_read (void) const = 0; + + /// Message block which contains the read data. + virtual ACE_Message_Block &message_block (void) const = 0; + + /// I/O handle used for accepting new connections. + virtual ACE_HANDLE listen_handle (void) const = 0; + + /// I/O handle for the new connection. + virtual ACE_HANDLE accept_handle (void) const = 0; + +protected: + /// Do-nothing constructor. + ACE_Asynch_Accept_Result_Impl (void); +}; + + +/** + * @class ACE_Asynch_Connect_Impl + * + * @brief Abstract base class for all the concrete implementation + * classes that provide different implementations for the + * ACE_Asynch_Connect. + * + */ +class ACE_Export ACE_Asynch_Connect_Impl : public virtual ACE_Asynch_Operation_Impl +{ +public: + virtual ~ACE_Asynch_Connect_Impl (void); + + /** + * This starts off an asynchronous connect + */ + virtual int connect (ACE_HANDLE connect_handle, + const ACE_Addr & remote_sap, + const ACE_Addr & local_sap, + int reuse_addr, + const void *act, + int priority, + int signal_number) = 0; + +protected: + /// Do-nothing constructor. + ACE_Asynch_Connect_Impl (void); +}; + +/** + * @class ACE_Asynch_Connect_Result_Impl + * + * @brief Abstract base class for all the concrete implementation + * classes that provide different implementations for the + * ACE_Asynch_Connect. + * + */ +class ACE_Export ACE_Asynch_Connect_Result_Impl : public virtual ACE_Asynch_Result_Impl +{ +public: + virtual ~ACE_Asynch_Connect_Result_Impl (void); + + /// I/O handle for the connection. + virtual ACE_HANDLE connect_handle (void) const = 0; + +protected: + /// Do-nothing constructor. + ACE_Asynch_Connect_Result_Impl (void); +}; + + +/** + * @class ACE_Asynch_Transmit_File_Impl + * + * @brief Abstract base class for all the concrete implementation + * classes that provide different implementations for the + * ACE_Asynch_Transmit_File. + * + */ +class ACE_Asynch_Transmit_File_Impl : public virtual ACE_Asynch_Operation_Impl +{ +public: + virtual ~ACE_Asynch_Transmit_File_Impl (void); + + /// This starts off an asynchronous transmit file. + virtual int transmit_file (ACE_HANDLE file, + ACE_Asynch_Transmit_File::Header_And_Trailer *header_and_trailer, + size_t bytes_to_write, + u_long offset, + u_long offset_high, + size_t bytes_per_send, + u_long flags, + const void *act, + int priority, + int signal_number) = 0; + +protected: + /// Do-nothing constructor. + ACE_Asynch_Transmit_File_Impl (void); +}; + +/** + * @class ACE_Asynch_Transmit_File_Result_Impl + * + * @brief Abstract base class for all the concrete implementation + * classes that provide different implementations for the + * ACE_Asynch_Transmit_File::Result. + * + */ +class ACE_Export ACE_Asynch_Transmit_File_Result_Impl : public virtual ACE_Asynch_Result_Impl +{ +public: + virtual ~ACE_Asynch_Transmit_File_Result_Impl (void); + + /// Socket used for transmitting the file. + virtual ACE_HANDLE socket (void) const = 0; + + /// File from which the data is read. + virtual ACE_HANDLE file (void) const = 0; + + /// Header and trailer data associated with this transmit file. + virtual ACE_Asynch_Transmit_File::Header_And_Trailer *header_and_trailer (void) const = 0; + + /// The number of bytes which were requested at the start of the + /// asynchronous transmit file. + virtual size_t bytes_to_write (void) const = 0; + + /// Number of bytes per send requested at the start of the transmit + /// file. + virtual size_t bytes_per_send (void) const = 0; + + /// Flags which were passed into transmit file. + virtual u_long flags (void) const = 0; + +protected: + /// Do-nothing constructor. + ACE_Asynch_Transmit_File_Result_Impl (void); +}; + + +/** + * @class ACE_Asynch_Read_Dgram_Impl + * + * @brief Abstract base class for all the concrete implementation + * classes that provide different implementations for the + * ACE_Asynch_Read_Dgram + * + */ +class ACE_Export ACE_Asynch_Read_Dgram_Impl : public virtual ACE_Asynch_Operation_Impl +{ +public: + virtual ~ACE_Asynch_Read_Dgram_Impl (void); + + /** This starts off an asynchronous read. Upto + * total_size()> will be read and stored in the + * @a message_block. @a message_block's will be updated to reflect + * the added bytes if the read operation is successful completed. + * Return code of 1 means immediate success and + * will contain number of bytes read. The + * method will still be called. Return code of 0 means the IO will + * complete proactively. Return code of -1 means there was an error, use + * errno to get the error code. + * + * Scatter/gather is supported on WIN32 by using the cont()> + * method. Up to ACE_IOV_MAX @a message_block's are supported. Upto + * size()> bytes will be read into each for + * a total of total_size()> bytes. All @a message_block's + * 's will be updated to reflect the added bytes for each + * @a message_block + * + * Priority of the operation is specified by @a priority. On POSIX4-Unix, + * this is supported. Works like in Unix. Negative values are not + * allowed. 0 means priority of the operation same as the process + * priority. 1 means priority of the operation is one less than + * process. And so forth. On Win32, @a priority is a no-op. + * @a signal_number is the POSIX4 real-time signal number to be used + * for the operation. @a signal_number ranges from ACE_SIGRTMIN to + * ACE_SIGRTMAX. This argument is a no-op on non-POSIX4 systems. + */ + virtual ssize_t recv (ACE_Message_Block *message_block, + size_t &number_of_bytes_recvd, + int flags, + int protocol_family, + const void *act, + int priority, + int signal_number) = 0; + +protected: + /// Do-nothing constructor. + ACE_Asynch_Read_Dgram_Impl (void); +}; + +/** + * @class ACE_Asynch_Read_Dgram_Result_Impl + * + * @brief Abstract base class for all the concrete implementation + * classes that provide different implementations for the + * ACE_Asynch_Read_Dgram::Result class. + * + */ +class ACE_Export ACE_Asynch_Read_Dgram_Result_Impl : public virtual ACE_Asynch_Result_Impl +{ +public: + virtual ~ACE_Asynch_Read_Dgram_Result_Impl (void); + + /// Message block which contains the read data + virtual ACE_Message_Block *message_block (void) const = 0; + + /// The number of bytes which were requested at the start of the + /// asynchronous read. + virtual size_t bytes_to_read (void) const = 0; + + /// The address of where the packet came from + virtual int remote_address (ACE_Addr& addr) const = 0; + + /// The flags used in the read + virtual int flags (void) const = 0; + + /// I/O handle used for reading. + virtual ACE_HANDLE handle (void) const = 0; + +protected: + /// Do-nothing constructor. + ACE_Asynch_Read_Dgram_Result_Impl (void); +}; + +/** + * @class ACE_Asynch_Write_Dgram_Impl + * + * @brief Abstract base class for all the concrete implementation + * classes that provide different implementations for the + * ACE_Asynch_Write_Dgram class. + * + */ +class ACE_Export ACE_Asynch_Write_Dgram_Impl : public virtual ACE_Asynch_Operation_Impl +{ +public: + virtual ~ACE_Asynch_Write_Dgram_Impl (void); + + /** This starts off an asynchronous send. Upto + * total_length()> will be sent. @a message_block's + * will be updated to reflect the sent bytes if the send operation + * is successful completed. + * Return code of 1 means immediate success and + * is updated to number of bytes sent. The + * method will still be called. Return code of 0 means the IO will + * complete proactively. Return code of -1 means there was an error, use + * errno to get the error code. + * + * Scatter/gather is supported on WIN32 by using the cont()> + * method. Up to ACE_IOV_MAX @a message_block's are supported. Upto + * length()> bytes will be sent from each + * for a total of total_length()> bytes. All + * @a message_block's 's will be updated to reflect the bytes sent + * from each @a message_block. + * + * Priority of the operation is specified by @a priority. On POSIX4-Unix, + * this is supported. Works like in Unix. Negative values are not + * allowed. 0 means priority of the operation same as the process + * priority. 1 means priority of the operation is one less than + * process. And so forth. On Win32, this argument is a no-op. + * @a signal_number is the POSIX4 real-time signal number to be used + * for the operation. @a signal_number ranges from ACE_SIGRTMIN to + * ACE_SIGRTMAX. This argument is a no-op on non-POSIX4 systems. + */ + virtual ssize_t send (ACE_Message_Block *message_block, + size_t &number_of_bytes_sent, + int flags, + const ACE_Addr &addr, + const void *act, + int priority, + int signal_number) = 0; + +protected: + /// Do-nothing constructor. + ACE_Asynch_Write_Dgram_Impl (void); +}; + +/** + * @class ACE_Asynch_Write_Dgram_Result_Impl + * + * @brief Abstract base class for all the concrete implementation + * classes that provide different implementations for the + * ACE_Asynch_Write_Dgram::Result class. + * + */ +class ACE_Export ACE_Asynch_Write_Dgram_Result_Impl : public virtual ACE_Asynch_Result_Impl +{ +public: + virtual ~ACE_Asynch_Write_Dgram_Result_Impl (void); + + /// The number of bytes which were requested at the start of the + /// asynchronous write. + virtual size_t bytes_to_write (void) const = 0; + + /// Message block which contains the sent data + virtual ACE_Message_Block *message_block (void) const = 0; + + /// The flags using in the write + virtual int flags (void) const = 0; + + /// I/O handle used for writing. + virtual ACE_HANDLE handle (void) const = 0; + +protected: + /// Do-nothing constructor. + ACE_Asynch_Write_Dgram_Result_Impl (void); +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +#include "ace/Asynch_IO_Impl.inl" +#endif /* __ACE_INLINE__ */ + +#endif /* ACE_HAS_WIN32_OVERLAPPED_IO || ACE_HAS_AIO_CALLS */ +#include /**/ "ace/post.h" +#endif /* ACE_ASYNCH_IO_IMPL_H */ diff --git a/dep/ACE_wrappers/ace/Asynch_IO_Impl.inl b/dep/ACE_wrappers/ace/Asynch_IO_Impl.inl new file mode 100644 index 00000000000..60dc69dfb31 --- /dev/null +++ b/dep/ACE_wrappers/ace/Asynch_IO_Impl.inl @@ -0,0 +1,106 @@ +// -*- C++ -*- +// +// $Id: Asynch_IO_Impl.inl 80826 2008-03-04 14:51:23Z wotte $ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_INLINE +ACE_Asynch_Result_Impl::ACE_Asynch_Result_Impl (void) +{ +} + +ACE_INLINE +ACE_Asynch_Operation_Impl::ACE_Asynch_Operation_Impl (void) +{ +} + +ACE_INLINE +ACE_Asynch_Read_Stream_Impl::ACE_Asynch_Read_Stream_Impl (void) + : ACE_Asynch_Operation_Impl () +{ +} + +ACE_INLINE +ACE_Asynch_Read_Stream_Result_Impl::ACE_Asynch_Read_Stream_Result_Impl (void) + : ACE_Asynch_Result_Impl () +{ +} + +ACE_INLINE +ACE_Asynch_Write_Stream_Impl::ACE_Asynch_Write_Stream_Impl (void) + : ACE_Asynch_Operation_Impl () +{ +} + +ACE_INLINE +ACE_Asynch_Write_Stream_Result_Impl::ACE_Asynch_Write_Stream_Result_Impl (void) + : ACE_Asynch_Result_Impl () +{ +} + +ACE_INLINE +ACE_Asynch_Read_File_Impl::ACE_Asynch_Read_File_Impl (void) + : ACE_Asynch_Operation_Impl (), + ACE_Asynch_Read_Stream_Impl () +{ +} + +ACE_INLINE +ACE_Asynch_Read_File_Result_Impl::ACE_Asynch_Read_File_Result_Impl (void) + : ACE_Asynch_Result_Impl (), + ACE_Asynch_Read_Stream_Result_Impl () +{ +} + +ACE_INLINE +ACE_Asynch_Write_File_Impl::ACE_Asynch_Write_File_Impl (void) + : ACE_Asynch_Operation_Impl (), + ACE_Asynch_Write_Stream_Impl () +{ +} + +ACE_INLINE +ACE_Asynch_Write_File_Result_Impl::ACE_Asynch_Write_File_Result_Impl (void) + : ACE_Asynch_Result_Impl (), + ACE_Asynch_Write_Stream_Result_Impl () +{ +} + +ACE_INLINE +ACE_Asynch_Accept_Impl::ACE_Asynch_Accept_Impl (void) + : ACE_Asynch_Operation_Impl () +{ +} + +ACE_INLINE +ACE_Asynch_Accept_Result_Impl::ACE_Asynch_Accept_Result_Impl (void) + : ACE_Asynch_Result_Impl () +{ +} + +ACE_INLINE +ACE_Asynch_Connect_Impl::ACE_Asynch_Connect_Impl (void) + : ACE_Asynch_Operation_Impl () +{ +} + +ACE_INLINE +ACE_Asynch_Connect_Result_Impl::ACE_Asynch_Connect_Result_Impl (void) + : ACE_Asynch_Result_Impl () +{ +} + + +ACE_INLINE +ACE_Asynch_Transmit_File_Impl::ACE_Asynch_Transmit_File_Impl (void) + : ACE_Asynch_Operation_Impl () +{ +} + +ACE_INLINE +ACE_Asynch_Transmit_File_Result_Impl::ACE_Asynch_Transmit_File_Result_Impl (void) + : ACE_Asynch_Result_Impl () +{ +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Asynch_Pseudo_Task.cpp b/dep/ACE_wrappers/ace/Asynch_Pseudo_Task.cpp new file mode 100644 index 00000000000..94f0d6980ed --- /dev/null +++ b/dep/ACE_wrappers/ace/Asynch_Pseudo_Task.cpp @@ -0,0 +1,130 @@ +// $Id: Asynch_Pseudo_Task.cpp 80826 2008-03-04 14:51:23Z wotte $ + +#include "ace/Asynch_Pseudo_Task.h" + +#include "ace/OS_NS_errno.h" +#include "ace/OS_NS_signal.h" + +ACE_RCSID(ace, Asynch_Pseudo_Task, "$Id: Asynch_Pseudo_Task.cpp 80826 2008-03-04 14:51:23Z wotte $") + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_Asynch_Pseudo_Task::ACE_Asynch_Pseudo_Task () + : select_reactor_ (), // should be initialized before reactor_ + reactor_ (&select_reactor_, 0) // don't delete implementation +{ +} + +ACE_Asynch_Pseudo_Task::~ACE_Asynch_Pseudo_Task () +{ + this->stop (); +} + +int +ACE_Asynch_Pseudo_Task::start (void) +{ + if (this->reactor_.initialized () == 0) + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("%N:%l:%p\n"), + ACE_TEXT ("start reactor is not initialized")), + -1); + + return this->activate () == -1 ? -1 : 0; // If started, return 0 +} + +int +ACE_Asynch_Pseudo_Task::stop (void) +{ + if (this->thr_count () == 0) // already stopped + return 0; + + if (this->reactor_.end_reactor_event_loop () == -1) + return -1; + + this->wait (); + this->reactor_.close (); + return 0; +} + +int +ACE_Asynch_Pseudo_Task::svc (void) +{ +#if !defined (ACE_WIN32) + + sigset_t RT_signals; + + sigemptyset (&RT_signals); + for (int si = ACE_SIGRTMIN; si <= ACE_SIGRTMAX; si++) + sigaddset (&RT_signals, si); + + if (ACE_OS::pthread_sigmask (SIG_BLOCK, &RT_signals, 0) != 0) + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("Error:(%P | %t):%p\n"), + ACE_TEXT ("pthread_sigmask"))); +#endif + + reactor_.owner (ACE_Thread::self ()); + reactor_.run_reactor_event_loop (); + + return 0; +} + + + +int +ACE_Asynch_Pseudo_Task::register_io_handler (ACE_HANDLE handle, + ACE_Event_Handler *handler, + ACE_Reactor_Mask mask, + int flg_suspend) +{ + // Register the handler with the reactor. + if (-1 == this->reactor_.register_handler (handle, handler, mask)) + return -1; + + if (flg_suspend == 0) + return 0; + + // Suspend the handle now. Enable only when the accept is issued + // by the application. + if (this->reactor_.suspend_handler (handle) == -1) + { + ACE_ERROR + ((LM_ERROR, + ACE_TEXT ("%N:%l:%p\n"), + ACE_TEXT ("register_io_handler (suspended)"))); + this->reactor_.remove_handler (handle, ACE_Event_Handler::ALL_EVENTS_MASK + | ACE_Event_Handler::DONT_CALL); + return -1; + } + + return 0; +} + +int +ACE_Asynch_Pseudo_Task::remove_io_handler (ACE_HANDLE handle) +{ + return this->reactor_.remove_handler (handle, + ACE_Event_Handler::ALL_EVENTS_MASK + | ACE_Event_Handler::DONT_CALL); +} + +int +ACE_Asynch_Pseudo_Task::remove_io_handler (ACE_Handle_Set &set) +{ + return this->reactor_.remove_handler (set, ACE_Event_Handler::ALL_EVENTS_MASK + | ACE_Event_Handler::DONT_CALL); +} + +int +ACE_Asynch_Pseudo_Task::suspend_io_handler (ACE_HANDLE handle) +{ + return this->reactor_.suspend_handler (handle); +} + +int +ACE_Asynch_Pseudo_Task::resume_io_handler (ACE_HANDLE handle) +{ + return this->reactor_.resume_handler (handle); +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Asynch_Pseudo_Task.h b/dep/ACE_wrappers/ace/Asynch_Pseudo_Task.h new file mode 100644 index 00000000000..6e2c3a1d427 --- /dev/null +++ b/dep/ACE_wrappers/ace/Asynch_Pseudo_Task.h @@ -0,0 +1,73 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Asynch_Pseudo_Task.h + * + * $Id: Asynch_Pseudo_Task.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Alexander Libman + */ +//============================================================================= + +#ifndef ACE_ASYNCH_PSEUDO_TASK_H +#define ACE_ASYNCH_PSEUDO_TASK_H + +#include /**/ "ace/pre.h" + +#include /**/ "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +#pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/Reactor.h" +#include "ace/Select_Reactor.h" +#include "ace/Task.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +/* + * Specialization hook to replace the Reactor with the + * concrete Reactor implementation, e.g., select_st, + * select_mt etc. + */ +//@@ REACTOR_SPL_INCLUDE_FORWARD_DECL_ADD_HOOK + +/** + * @class ACE_Asynch_Pseudo_Task + * + */ +class ACE_Export ACE_Asynch_Pseudo_Task : public ACE_Task +{ +public: + ACE_Asynch_Pseudo_Task(); + virtual ~ACE_Asynch_Pseudo_Task(); + + int start (void); + int stop (void); + + int register_io_handler (ACE_HANDLE handle, + ACE_Event_Handler *handler, + ACE_Reactor_Mask mask, + int flg_suspend); + + int remove_io_handler (ACE_HANDLE handle); + int remove_io_handler (ACE_Handle_Set &set); + int resume_io_handler (ACE_HANDLE handle); + int suspend_io_handler (ACE_HANDLE handle); + +protected: + virtual int svc (void); + + /// Should be initialized before reactor_ + ACE_Select_Reactor select_reactor_; + + ACE_Reactor reactor_; +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#include /**/ "ace/post.h" + +#endif /* ACE_ASYNCH_PSEUDO_TASK_H */ diff --git a/dep/ACE_wrappers/ace/Atomic_Op.cpp b/dep/ACE_wrappers/ace/Atomic_Op.cpp new file mode 100644 index 00000000000..57139ac853b --- /dev/null +++ b/dep/ACE_wrappers/ace/Atomic_Op.cpp @@ -0,0 +1,310 @@ +// $Id: Atomic_Op.cpp 80826 2008-03-04 14:51:23Z wotte $ + +#include "ace/Atomic_Op.h" +#include "ace/OS_NS_unistd.h" + +ACE_RCSID (ace, + Atomic_Op, + "$Id: Atomic_Op.cpp 80826 2008-03-04 14:51:23Z wotte $") + +#if !defined (__ACE_INLINE__) +#include "ace/Atomic_Op.inl" +#endif /* __ACE_INLINE__ */ + +#if defined (ACE_HAS_BUILTIN_ATOMIC_OP) + +#if defined (ACE_INCLUDE_ATOMIC_OP_SPARC) +# include "ace/Atomic_Op_Sparc.h" +#endif /* ACE_INCLUDE_ATOMIC_OP_SPARC */ + +namespace { + +#if defined (_MSC_VER) +// Disable "no return value" warning, as we will be putting +// the return values directly into the EAX register. +#pragma warning (push) +#pragma warning (disable: 4035) +#endif /* _MSC_VER */ + +long +single_cpu_increment (volatile long *value) +{ +#if defined (ACE_HAS_INTEL_ASSEMBLY) + long tmp = 1; + unsigned long addr = reinterpret_cast (value); + asm( "xadd %0, (%1)" : "+r"(tmp) : "r"(addr) ); + return tmp + 1; +#elif defined (sun) || \ + (defined (__SUNPRO_CC) && (defined (__i386) || defined (__x86_64))) + return ace_atomic_add_long ( + reinterpret_cast (value), 1); +#elif defined(__GNUC__) && defined(PPC) + long tmp; + asm("lwz %0,%1" : "=r" (tmp) : "m" (*value) ); + asm("addi %0,%0,1" : "+r" (tmp) ); + asm("stw %0,%1" : "+r" (tmp), "=m" (*value) ); + return tmp; +#else /* ACE_HAS_INTEL_ASSEMBLY*/ + ACE_UNUSED_ARG (value); + ACE_NOTSUP_RETURN (-1); +#endif /* ACE_HAS_INTEL_ASSEMBLY*/ +} + +long +single_cpu_decrement (volatile long *value) +{ +#if defined (ACE_HAS_INTEL_ASSEMBLY) + long tmp = -1; + unsigned long addr = reinterpret_cast (value); + asm( "xadd %0, (%1)" : "+r"(tmp) : "r"(addr) ); + return tmp - 1; +#elif defined (sun) || \ + (defined (__SUNPRO_CC) && (defined (__i386) || defined (__x86_64))) + return ace_atomic_add_long ( + reinterpret_cast (value), -1); +#elif defined(__GNUC__) && defined(PPC) + long tmp; + asm("lwz %0,%1" : "=r" (tmp) : "m" (*value) ); + asm("addi %0,%0,-1" : "+r" (tmp) ); + asm("stw %0,%1" : "+r" (tmp), "=m" (*value) ); + return tmp; +#else /* ACE_HAS_INTEL_ASSEMBLY*/ + ACE_UNUSED_ARG (value); + ACE_NOTSUP_RETURN (-1); +#endif /* ACE_HAS_INTEL_ASSEMBLY*/ +} + +long +single_cpu_exchange (volatile long *value, long rhs) +{ +#if defined (ACE_HAS_INTEL_ASSEMBLY) + unsigned long addr = reinterpret_cast (value); + asm( "xchg %0, (%1)" : "+r"(rhs) : "r"(addr) ); + return rhs; +#elif defined (sun) || \ + (defined (__SUNPRO_CC) && (defined (__i386) || defined (__x86_64))) + return ace_atomic_swap_long ( + reinterpret_cast (value), rhs); +#elif defined(__GNUC__) && defined(PPC) + long tmp; + asm("lwz %0,%1" : "=r" (tmp) : "m" (rhs) ); + asm("stw %0,%1" : "+r" (tmp), "=m" (*value) ); + return tmp; +#else /* ACE_HAS_INTEL_ASSEMBLY*/ + ACE_UNUSED_ARG (value); + ACE_UNUSED_ARG (rhs); + ACE_NOTSUP_RETURN (-1); +#endif /* ACE_HAS_INTEL_ASSEMBLY*/ +} + +long +single_cpu_exchange_add (volatile long *value, long rhs) +{ +#if defined (ACE_HAS_INTEL_ASSEMBLY) + unsigned long addr = reinterpret_cast (value); + asm( "xadd %0, (%1)" : "+r"(rhs) : "r"(addr) ); + return rhs; +#elif defined (sun) || \ + (defined (__SUNPRO_CC) && (defined (__i386) || defined (__x86_64))) + return ace_atomic_swap_add_long ( + reinterpret_cast (value), rhs); +#elif defined(__GNUC__) && defined(PPC) + long tmp; + asm("add %0,%1,%2" : "=r" (tmp) : "r" (*value), "r" (rhs) ); + asm("stw %0,%1" : "+r" (tmp), "=m" (*value) ); + return tmp; +#elif defined (WIN32) && !defined (ACE_HAS_INTERLOCKED_EXCHANGEADD) +# if defined (_MSC_VER) + __asm + { + mov eax, rhs + mov edx, value + xadd [edx], eax + } + // Return value is already in EAX register. +# elif defined (__BORLANDC__) + _EAX = rhs; + _EDX = reinterpret_cast (value); + __emit__(0x0F, 0xC1, 0x02); // xadd [edx], eax + // Return value is already in EAX register. +# else /* _MSC_VER */ + ACE_UNUSED_ARG (value); + ACE_UNUSED_ARG (rhs); + ACE_NOTSUP_RETURN (-1); +# endif /* _MSC_VER */ +#else /* ACE_HAS_INTEL_ASSEMBLY*/ + ACE_UNUSED_ARG (value); + ACE_UNUSED_ARG (rhs); + ACE_NOTSUP_RETURN (-1); +#endif /* ACE_HAS_INTEL_ASSEMBLY*/ +} + +long +multi_cpu_increment (volatile long *value) +{ +#if defined (ACE_HAS_INTEL_ASSEMBLY) + long tmp = 1; + unsigned long addr = reinterpret_cast (value); + asm( "lock ; xadd %0, (%1)" : "+r"(tmp) : "r"(addr) ); + return tmp + 1; +#elif defined (sun) || \ + (defined (__SUNPRO_CC) && (defined (__i386) || defined (__x86_64))) + return ace_atomic_add_long ( + reinterpret_cast (value), 1); +#else /* ACE_HAS_INTEL_ASSEMBLY*/ + ACE_UNUSED_ARG (value); + ACE_NOTSUP_RETURN (-1); +#endif /* ACE_HAS_INTEL_ASSEMBLY*/ +} + +long +multi_cpu_decrement (volatile long *value) +{ +#if defined (ACE_HAS_INTEL_ASSEMBLY) + long tmp = -1; + unsigned long addr = reinterpret_cast (value); + asm( "lock ; xadd %0, (%1)" : "+r"(tmp) : "r"(addr) ); + return tmp - 1; +#elif defined (sun) || \ + (defined (__SUNPRO_CC) && (defined (__i386) || defined (__x86_64))) + return ace_atomic_add_long ( + reinterpret_cast (value), -1); +#else /* ACE_HAS_INTEL_ASSEMBLY*/ + ACE_UNUSED_ARG (value); + ACE_NOTSUP_RETURN (-1); +#endif /* ACE_HAS_INTEL_ASSEMBLY*/ +} + +long +multi_cpu_exchange (volatile long *value, long rhs) +{ +#if defined (ACE_HAS_INTEL_ASSEMBLY) + unsigned long addr = reinterpret_cast (value); + // The XCHG instruction automatically follows LOCK semantics + asm( "xchg %0, (%1)" : "+r"(rhs) : "r"(addr) ); + return rhs; +#elif defined (sun) || \ + (defined (__SUNPRO_CC) && (defined (__i386) || defined (__x86_64))) + return ace_atomic_swap_long ( + reinterpret_cast (value), rhs); +#else /* ACE_HAS_INTEL_ASSEMBLY*/ + ACE_UNUSED_ARG (value); + ACE_UNUSED_ARG (rhs); + ACE_NOTSUP_RETURN (-1); +#endif /* ACE_HAS_INTEL_ASSEMBLY*/ +} + +long +multi_cpu_exchange_add (volatile long *value, long rhs) +{ +#if defined (ACE_HAS_INTEL_ASSEMBLY) + unsigned long addr = reinterpret_cast (value); + asm( "lock ; xadd %0, (%1)" : "+r"(rhs) : "r"(addr) ); + return rhs; +#elif defined (sun) || \ + (defined (__SUNPRO_CC) && (defined (__i386) || defined (__x86_64))) + return ace_atomic_swap_add_long ( + reinterpret_cast (value), rhs); +#elif defined (WIN32) && !defined (ACE_HAS_INTERLOCKED_EXCHANGEADD) +# if defined (_MSC_VER) + __asm + { + mov eax, rhs + mov edx, value + lock xadd [edx], eax + } + // Return value is already in EAX register. +# elif defined (__BORLANDC__) + _EAX = rhs; + _EDX = reinterpret_cast (value); + __emit__(0xF0, 0x0F, 0xC1, 0x02); // lock xadd [edx], eax + // Return value is already in EAX register. +# else /* _MSC_VER */ + ACE_UNUSED_ARG (value); + ACE_UNUSED_ARG (rhs); + ACE_NOTSUP_RETURN (-1); +# endif /* _MSC_VER */ +#else /* ACE_HAS_INTEL_ASSEMBLY*/ + ACE_UNUSED_ARG (value); + ACE_UNUSED_ARG (rhs); + ACE_NOTSUP_RETURN (-1); +#endif /* ACE_HAS_INTEL_ASSEMBLY*/ +} + +#if defined (_MSC_VER) +#pragma warning (pop) +#endif /* _MSC_VER */ + +} // end namespace + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +long (*ACE_Atomic_Op::increment_fn_) (volatile long *) = multi_cpu_increment; +long (*ACE_Atomic_Op::decrement_fn_) (volatile long *) = multi_cpu_decrement; +long (*ACE_Atomic_Op::exchange_fn_) (volatile long *, long) = multi_cpu_exchange; +long (*ACE_Atomic_Op::exchange_add_fn_) (volatile long *, long) = multi_cpu_exchange_add; + +void +ACE_Atomic_Op::init_functions (void) +{ + if (ACE_OS::num_processors () == 1) + { + increment_fn_ = single_cpu_increment; + decrement_fn_ = single_cpu_decrement; + exchange_fn_ = single_cpu_exchange; + exchange_add_fn_ = single_cpu_exchange_add; + } + else + { + increment_fn_ = multi_cpu_increment; + decrement_fn_ = multi_cpu_decrement; + exchange_fn_ = multi_cpu_exchange; + exchange_add_fn_ = multi_cpu_exchange_add; + } +} + +void +ACE_Atomic_Op::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); + ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); +#endif /* ACE_HAS_DUMP */ +} + +long (*ACE_Atomic_Op::increment_fn_) (volatile long *) = multi_cpu_increment; +long (*ACE_Atomic_Op::decrement_fn_) (volatile long *) = multi_cpu_decrement; +long (*ACE_Atomic_Op::exchange_fn_) (volatile long *, long) = multi_cpu_exchange; +long (*ACE_Atomic_Op::exchange_add_fn_) (volatile long *, long) = multi_cpu_exchange_add; + +void +ACE_Atomic_Op::init_functions (void) +{ + if (ACE_OS::num_processors () == 1) + { + increment_fn_ = single_cpu_increment; + decrement_fn_ = single_cpu_decrement; + exchange_fn_ = single_cpu_exchange; + exchange_add_fn_ = single_cpu_exchange_add; + } + else + { + increment_fn_ = multi_cpu_increment; + decrement_fn_ = multi_cpu_decrement; + exchange_fn_ = multi_cpu_exchange; + exchange_add_fn_ = multi_cpu_exchange_add; + } +} + +void +ACE_Atomic_Op::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); + ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); +#endif /* ACE_HAS_DUMP */ +} + +ACE_END_VERSIONED_NAMESPACE_DECL + +#endif /* ACE_HAS_BUILTIN_ATOMIC_OP */ diff --git a/dep/ACE_wrappers/ace/Atomic_Op.h b/dep/ACE_wrappers/ace/Atomic_Op.h new file mode 100644 index 00000000000..196b9208f3a --- /dev/null +++ b/dep/ACE_wrappers/ace/Atomic_Op.h @@ -0,0 +1,260 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Atomic_Op.h + * + * $Id: Atomic_Op.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Douglas C. Schmidt + */ +//============================================================================= + +#ifndef ACE_ATOMIC_OP_H +#define ACE_ATOMIC_OP_H +#include /**/ "ace/pre.h" + +#include /**/ "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/Thread_Mutex.h" + +// Include the templates here. +#include "ace/Atomic_Op_T.h" + +// Determine whether builtin atomic op support is +// available on this platform. +#if defined (ACE_HAS_THREADS) +# if defined (WIN32) +# if defined (ACE_HAS_INTRINSIC_INTERLOCKED) +# define ACE_HAS_BUILTIN_ATOMIC_OP +# endif /* ACE_HAS_INTRINSIC_INTERLOCKED */ +# if defined (ACE_HAS_INTERLOCKED_EXCHANGEADD) +# define ACE_HAS_BUILTIN_ATOMIC_OP +# else /* ACE_HAS_INTERLOCKED_EXCHANGEADD */ + // Inline assembly emulation of InterlockedExchangeAdd + // is currently only implemented for MSVC (x86 only) and Borland. +# if (defined (_MSC_VER) && defined (_M_IX86)) || defined (__BORLANDC__) +# define ACE_HAS_BUILTIN_ATOMIC_OP +# endif /* _MSC_VER || __BORLANDC__ */ +# endif /* ACE_HAS_INTERLOCKED_EXCHANGEADD */ +# elif defined (ACE_HAS_INTEL_ASSEMBLY) +# define ACE_HAS_BUILTIN_ATOMIC_OP +# endif /* WIN32 */ +#endif /* ACE_HAS_THREADS */ + +#if defined (ACE_HAS_BUILTIN_ATOMIC_OP) + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +/** + * @class ACE_Atomic_Op + * + * @brief Specialization of ACE_Atomic_Op for platforms that + * support atomic integer operations. + * + * Specialization of ACE_Atomic_Op for platforms that support atomic + * integer operations. + */ +template<> +class ACE_Export ACE_Atomic_Op +{ +public: + /// Initialize to 0. + ACE_Atomic_Op (void); + + /// Initialize to c. + ACE_Atomic_Op (long c); + + /// Manage copying... + ACE_Atomic_Op (const ACE_Atomic_Op &c); + + /// Atomically pre-increment . + long operator++ (void); + + /// Atomically post-increment . + long operator++ (int); + + /// Atomically increment by rhs. + long operator+= (long rhs); + + /// Atomically pre-decrement . + long operator-- (void); + + /// Atomically post-decrement . + long operator-- (int); + + /// Atomically decrement by rhs. + long operator-= (long rhs); + + /// Atomically compare with rhs. + bool operator== (long rhs) const; + + /// Atomically compare with rhs. + bool operator!= (long rhs) const; + + /// Atomically check if greater than or equal to rhs. + bool operator>= (long rhs) const; + + /// Atomically check if greater than rhs. + bool operator> (long rhs) const; + + /// Atomically check if less than or equal to rhs. + bool operator<= (long rhs) const; + + /// Atomically check if less than rhs. + bool operator< (long rhs) const; + + /// Atomically assign rhs to . + ACE_Atomic_Op &operator= (long rhs); + + /// Atomically assign to . + ACE_Atomic_Op &operator= (const ACE_Atomic_Op &rhs); + + /// Explicitly return . + long value (void) const; + + /// Dump the state of an object. + void dump (void) const; + + /// Explicitly return (by reference). + volatile long &value_i (void); + + // ACE_ALLOC_HOOK_DECLARE; + // Declare the dynamic allocation hooks. + + /// Used during ACE object manager initialization to optimize the fast + /// atomic op implementation according to the number of CPUs. + static void init_functions (void); + +private: + + // This function cannot be supported by this template specialization. + // If you need access to an underlying lock, use the ACE_Atomic_Op_Ex + // template instead. + ACE_Thread_Mutex &mutex (void); + +private: + + /// Current object decorated by the atomic op. + volatile long value_; + + // Pointers to selected atomic op implementations. + static long (*increment_fn_) (volatile long *); + static long (*decrement_fn_) (volatile long *); + static long (*exchange_fn_) (volatile long *, long); + static long (*exchange_add_fn_) (volatile long *, long); +}; + +/** + * @class ACE_Atomic_Op + * + * @brief Specialization of ACE_Atomic_Op for platforms that + * support atomic integer operations. + * + * Specialization of ACE_Atomic_Op for platforms that support atomic + * integer operations. + */ +template<> +class ACE_Export ACE_Atomic_Op +{ +public: + /// Initialize to 0. + ACE_Atomic_Op (void); + + /// Initialize to c. + ACE_Atomic_Op (unsigned long c); + + /// Manage copying... + ACE_Atomic_Op (const ACE_Atomic_Op &c); + + /// Atomically pre-increment . + unsigned long operator++ (void); + + /// Atomically post-increment . + unsigned long operator++ (int); + + /// Atomically increment by rhs. + unsigned long operator+= (unsigned long rhs); + + /// Atomically pre-decrement . + unsigned long operator-- (void); + + /// Atomically post-decrement . + unsigned long operator-- (int); + + /// Atomically decrement by rhs. + unsigned long operator-= (unsigned long rhs); + + /// Atomically compare with rhs. + bool operator== (unsigned long rhs) const; + + /// Atomically compare with rhs. + bool operator!= (unsigned long rhs) const; + + /// Atomically check if greater than or equal to rhs. + bool operator>= (unsigned long rhs) const; + + /// Atomically check if greater than rhs. + bool operator> (unsigned long rhs) const; + + /// Atomically check if less than or equal to rhs. + bool operator<= (unsigned long rhs) const; + + /// Atomically check if less than rhs. + bool operator< (unsigned long rhs) const; + + /// Atomically assign rhs to . + ACE_Atomic_Op &operator= (unsigned long rhs); + + /// Atomically assign to . + ACE_Atomic_Op &operator= (const ACE_Atomic_Op &rhs); + + /// Explicitly return . + unsigned long value (void) const; + + /// Dump the state of an object. + void dump (void) const; + + /// Explicitly return (by reference). + volatile unsigned long &value_i (void); + + // ACE_ALLOC_HOOK_DECLARE; + // Declare the dynamic allocation hooks. + + /// Used during ACE object manager initialization to optimize the fast + /// atomic op implementation according to the number of CPUs. + static void init_functions (void); + +private: + + // This function cannot be supported by this template specialization. + // If you need access to an underlying lock, use the ACE_Atomic_Op_Ex + // template instead. + ACE_Thread_Mutex &mutex (void); + +private: + + /// Current object decorated by the atomic op. + volatile unsigned long value_; + + // Pointers to selected atomic op implementations. + static long (*increment_fn_) (volatile long *); + static long (*decrement_fn_) (volatile long *); + static long (*exchange_fn_) (volatile long *, long); + static long (*exchange_add_fn_) (volatile long *, long); +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#endif /* ACE_HAS_BUILTIN_ATOMIC_OP */ + +#if defined (__ACE_INLINE__) +#include "ace/Atomic_Op.inl" +#endif /* __ACE_INLINE__ */ + +#include /**/ "ace/post.h" +#endif /*ACE_ATOMIC_OP_H*/ diff --git a/dep/ACE_wrappers/ace/Atomic_Op.inl b/dep/ACE_wrappers/ace/Atomic_Op.inl new file mode 100644 index 00000000000..ed6bfbdbc1b --- /dev/null +++ b/dep/ACE_wrappers/ace/Atomic_Op.inl @@ -0,0 +1,335 @@ +// -*- C++ -*- +// +// $Id: Atomic_Op.inl 80826 2008-03-04 14:51:23Z wotte $ + +#if defined (ACE_HAS_BUILTIN_ATOMIC_OP) + +#if defined (ACE_HAS_INTRINSIC_INTERLOCKED) +# include "ace/os_include/os_intrin.h" + +#pragma intrinsic (_InterlockedExchange, _InterlockedExchangeAdd, _InterlockedIncrement, _InterlockedDecrement) +#endif /* ACE_HAS_INTRINSIC_INTERLOCKED */ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_INLINE +ACE_Atomic_Op::ACE_Atomic_Op (void) + : value_ (0) +{ +} + +ACE_INLINE +ACE_Atomic_Op::ACE_Atomic_Op (long c) + : value_ (c) +{ +} + +ACE_INLINE +ACE_Atomic_Op::ACE_Atomic_Op ( + const ACE_Atomic_Op &rhs) + : value_ (rhs.value_) +{ +} + +ACE_INLINE long +ACE_Atomic_Op::operator++ (void) +{ +#if defined (ACE_HAS_INTRINSIC_INTERLOCKED) + return ::_InterlockedIncrement (const_cast (&this->value_)); +#elif defined (WIN32) + return ::InterlockedIncrement (const_cast (&this->value_)); +#else /* WIN32 */ + return (*increment_fn_) (&this->value_); +#endif /* WIN32 */ +} + +ACE_INLINE long +ACE_Atomic_Op::operator++ (int) +{ + return ++*this - 1; +} + +ACE_INLINE long +ACE_Atomic_Op::operator-- (void) +{ +#if defined (ACE_HAS_INTRINSIC_INTERLOCKED) + return ::_InterlockedDecrement (const_cast (&this->value_)); +#elif defined (WIN32) + return ::InterlockedDecrement (const_cast (&this->value_)); +#else /* WIN32 */ + return (*decrement_fn_) (&this->value_); +#endif /* WIN32 */ +} + +ACE_INLINE long +ACE_Atomic_Op::operator-- (int) +{ + return --*this + 1; +} + +ACE_INLINE long +ACE_Atomic_Op::operator+= (long rhs) +{ +#if defined (ACE_HAS_INTRINSIC_INTERLOCKED) + return ::_InterlockedExchangeAdd (const_cast (&this->value_), + rhs) + rhs; +#elif defined (WIN32) && defined (ACE_HAS_INTERLOCKED_EXCHANGEADD) + return ::InterlockedExchangeAdd (const_cast (&this->value_), + rhs) + rhs; +#else /* WIN32 && ACE_HAS_INTERLOCKED_EXCHANGEADD */ + return (*exchange_add_fn_) (&this->value_, rhs) + rhs; +#endif /* WIN32 && ACE_HAS_INTERLOCKED_EXCHANGEADD */ +} + +ACE_INLINE long +ACE_Atomic_Op::operator-= (long rhs) +{ +#if defined (ACE_HAS_INTRINSIC_INTERLOCKED) + return ::_InterlockedExchangeAdd (const_cast (&this->value_), + -rhs) - rhs; +#elif defined (WIN32) && defined (ACE_HAS_INTERLOCKED_EXCHANGEADD) + return ::InterlockedExchangeAdd (const_cast (&this->value_), + -rhs) - rhs; +#else /* WIN32 && ACE_HAS_INTERLOCKED_EXCHANGEADD */ + return (*exchange_add_fn_) (&this->value_, -rhs) - rhs; +#endif /* WIN32 && ACE_HAS_INTERLOCKED_EXCHANGEADD */ +} + +ACE_INLINE bool +ACE_Atomic_Op::operator== (long rhs) const +{ + return (this->value_ == rhs); +} + +ACE_INLINE bool +ACE_Atomic_Op::operator!= (long rhs) const +{ + return (this->value_ != rhs); +} + +ACE_INLINE bool +ACE_Atomic_Op::operator>= (long rhs) const +{ + return (this->value_ >= rhs); +} + +ACE_INLINE bool +ACE_Atomic_Op::operator> (long rhs) const +{ + return (this->value_ > rhs); +} + +ACE_INLINE bool +ACE_Atomic_Op::operator<= (long rhs) const +{ + return (this->value_ <= rhs); +} + +ACE_INLINE bool +ACE_Atomic_Op::operator< (long rhs) const +{ + return (this->value_ < rhs); +} + +ACE_INLINE ACE_Atomic_Op & +ACE_Atomic_Op::operator= (long rhs) +{ +#if defined (ACE_HAS_INTRINSIC_INTERLOCKED) + ::_InterlockedExchange (const_cast (&this->value_), rhs); +#elif defined (WIN32) + ::InterlockedExchange (const_cast (&this->value_), rhs); +#else /* WIN32 */ + (*exchange_fn_) (&this->value_, rhs); +#endif /* WIN32 */ + return *this; +} + +ACE_INLINE ACE_Atomic_Op & +ACE_Atomic_Op::operator= ( + const ACE_Atomic_Op &rhs) +{ +#if defined (ACE_HAS_INTRINSIC_INTERLOCKED) + ::_InterlockedExchange (const_cast (&this->value_), rhs.value_); +#elif defined (WIN32) + ::InterlockedExchange (const_cast (&this->value_), rhs.value_); +#else /* WIN32 */ + (*exchange_fn_) (&this->value_, rhs.value_); +#endif /* WIN32 */ + return *this; +} + +ACE_INLINE long +ACE_Atomic_Op::value (void) const +{ + return this->value_; +} + +ACE_INLINE volatile long & +ACE_Atomic_Op::value_i (void) +{ + return this->value_; +} + + +ACE_INLINE +ACE_Atomic_Op::ACE_Atomic_Op (void) + : value_ (0) +{ +} + +ACE_INLINE +ACE_Atomic_Op::ACE_Atomic_Op (unsigned long c) + : value_ (c) +{ +} + +ACE_INLINE +ACE_Atomic_Op::ACE_Atomic_Op ( + const ACE_Atomic_Op &rhs) + : value_ (rhs.value_) +{ +} + +ACE_INLINE unsigned long +ACE_Atomic_Op::operator++ (void) +{ +#if defined (ACE_HAS_INTRINSIC_INTERLOCKED) + return static_cast (::_InterlockedIncrement (const_cast (reinterpret_cast(&this->value_)))); +#elif defined (WIN32) + return static_cast (::InterlockedIncrement (const_cast (reinterpret_cast(&this->value_)))); +#else /* WIN32 */ + return static_cast ((*increment_fn_) (reinterpret_cast (&this->value_))); +#endif /* WIN32 */ +} + +ACE_INLINE unsigned long +ACE_Atomic_Op::operator++ (int) +{ + return ++*this - 1; +} + +ACE_INLINE unsigned long +ACE_Atomic_Op::operator-- (void) +{ +#if defined (ACE_HAS_INTRINSIC_INTERLOCKED) + return static_cast (::_InterlockedDecrement (const_cast (reinterpret_cast(&this->value_)))); +#elif defined (WIN32) + return static_cast (::InterlockedDecrement (const_cast (reinterpret_cast(&this->value_)))); +#else /* WIN32 */ + return static_cast ((*decrement_fn_) (reinterpret_cast (&this->value_))); +#endif /* WIN32 */ +} + +ACE_INLINE unsigned long +ACE_Atomic_Op::operator-- (int) +{ + return --*this + 1; +} + +ACE_INLINE unsigned long +ACE_Atomic_Op::operator+= (unsigned long rhs) +{ +#if defined (ACE_HAS_INTRINSIC_INTERLOCKED) + return static_cast (::_InterlockedExchangeAdd (const_cast (reinterpret_cast (&this->value_)), + rhs)) + rhs; +#elif defined (WIN32) && defined (ACE_HAS_INTERLOCKED_EXCHANGEADD) + return static_cast (::InterlockedExchangeAdd (const_cast (reinterpret_cast (&this->value_)), + rhs)) + rhs; +#else /* WIN32 && ACE_HAS_INTERLOCKED_EXCHANGEADD */ + return static_cast ((*exchange_add_fn_) (reinterpret_cast (&this->value_), rhs)) + rhs; +#endif /* WIN32 && ACE_HAS_INTERLOCKED_EXCHANGEADD */ +} + +ACE_INLINE unsigned long +ACE_Atomic_Op::operator-= (unsigned long rhs) +{ +#if defined (ACE_HAS_INTRINSIC_INTERLOCKED) + return static_cast (::_InterlockedExchangeAdd (const_cast (reinterpret_cast(&this->value_)), + -static_cast(rhs))) - rhs; +#elif defined (WIN32) && defined (ACE_HAS_INTERLOCKED_EXCHANGEADD) + return static_cast (::InterlockedExchangeAdd (const_cast (reinterpret_cast(&this->value_)), + -static_cast(rhs))) - rhs; +#else /* WIN32 && ACE_HAS_INTERLOCKED_EXCHANGEADD */ + long l_rhs = static_cast (rhs); + return static_cast ((*exchange_add_fn_) (reinterpret_cast (&this->value_), -l_rhs)) - rhs; +#endif /* WIN32 && ACE_HAS_INTERLOCKED_EXCHANGEADD */ +} + +ACE_INLINE bool +ACE_Atomic_Op::operator== (unsigned long rhs) const +{ + return (this->value_ == rhs); +} + +ACE_INLINE bool +ACE_Atomic_Op::operator!= (unsigned long rhs) const +{ + return (this->value_ != rhs); +} + +ACE_INLINE bool +ACE_Atomic_Op::operator>= (unsigned long rhs) const +{ + return (this->value_ >= rhs); +} + +ACE_INLINE bool +ACE_Atomic_Op::operator> (unsigned long rhs) const +{ + return (this->value_ > rhs); +} + +ACE_INLINE bool +ACE_Atomic_Op::operator<= (unsigned long rhs) const +{ + return (this->value_ <= rhs); +} + +ACE_INLINE bool +ACE_Atomic_Op::operator< (unsigned long rhs) const +{ + return (this->value_ < rhs); +} + +ACE_INLINE ACE_Atomic_Op & +ACE_Atomic_Op::operator= (unsigned long rhs) +{ +#if defined (ACE_HAS_INTRINSIC_INTERLOCKED) + ::_InterlockedExchange (const_cast (reinterpret_cast (&this->value_)), rhs); +#elif defined (WIN32) + ::InterlockedExchange (const_cast (reinterpret_cast (&this->value_)), rhs); +#else /* WIN32 */ + (*exchange_fn_) (reinterpret_cast (&this->value_), rhs); +#endif /* WIN32 */ + return *this; +} + +ACE_INLINE ACE_Atomic_Op & +ACE_Atomic_Op::operator= ( + const ACE_Atomic_Op &rhs) +{ +#if defined (ACE_HAS_INTRINSIC_INTERLOCKED) + ::_InterlockedExchange (const_cast (reinterpret_cast (&this->value_)), rhs.value_); +#elif defined (WIN32) + ::InterlockedExchange (const_cast (reinterpret_cast (&this->value_)), rhs.value_); +#else /* WIN32 */ + (*exchange_fn_) (reinterpret_cast (&this->value_), rhs.value_); +#endif /* WIN32 */ + return *this; +} + +ACE_INLINE unsigned long +ACE_Atomic_Op::value (void) const +{ + return this->value_; +} + +ACE_INLINE volatile unsigned long & +ACE_Atomic_Op::value_i (void) +{ + return this->value_; +} + +ACE_END_VERSIONED_NAMESPACE_DECL + +#endif /* ACE_HAS_BUILTIN_ATOMIC_OP */ diff --git a/dep/ACE_wrappers/ace/Atomic_Op_Sparc.c b/dep/ACE_wrappers/ace/Atomic_Op_Sparc.c new file mode 100644 index 00000000000..842673e58cc --- /dev/null +++ b/dep/ACE_wrappers/ace/Atomic_Op_Sparc.c @@ -0,0 +1,187 @@ +/* $Id: Atomic_Op_Sparc.c 80826 2008-03-04 14:51:23Z wotte $ + * + * This is a C file for a reason. The Sun C++ compiler does not accept + * inline assembler. + * + * Portions of this code are based on atomic operations found in the + * linux kernel source code. + */ + +#if defined (ACE_INCLUDE_ATOMIC_OP_SPARC) + +#if defined(__i386) && defined(__SUNPRO_C) +static void +__sunpro_asm_code() { + __asm("\n\ + .globl ace_atomic_add_long \n\ + .type ace_atomic_add_long,@function \n\ + .align 4 \n\ +ace_atomic_add_long: \n\ + movl 0x00000004(%esp), %edx \n\ + movl 0x00000008(%esp), %eax \n\ + lock; xadd %eax, (%edx) \n\ + addl 0x00000008(%esp), %eax \n\ + ret \n\ + "); + + __asm("\n\ + .globl ace_atomic_swap_long \n\ + .type ace_atomic_swap_long,@function \n\ + .align 4 \n\ +ace_atomic_swap_long: \n\ + movl 0x00000004(%esp), %edx \n\ + movl 0x00000008(%esp), %eax \n\ + xchg %eax, (%edx) \n\ + ret \n\ + "); + + __asm("\n\ + .globl ace_atomic_swap_add_long \n\ + .type ace_atomic_swap_add_long,@function \n\ + .align 4 \n\ +ace_atomic_swap_add_long: \n\ + movl 0x00000004(%esp), %edx \n\ + movl 0x00000008(%esp), %eax \n\ + lock; xadd %eax, (%edx) \n\ + ret \n\ + "); +} + +#elif defined(__x86_64) && defined(__SUNPRO_C) + +static void +__sunpro_asm_code() { + __asm("\n\ + .globl ace_atomic_add_long \n\ + .type ace_atomic_add_long,@function \n\ + .align 16 \n\ +ace_atomic_add_long: \n\ + movq %rsi, %rax \n\ + lock; xaddq %rax, (%rdi) \n\ + addq %rsi, %rax \n\ + ret \n\ + "); + + __asm("\n\ + .globl ace_atomic_swap_long \n\ + .type ace_atomic_swap_long,@function \n\ + .align 16 \n\ +ace_atomic_swap_long: \n\ + xchgq %rsi, (%rdi) \n\ + movq %rsi, %rax \n\ + ret \n\ + "); + + __asm("\n\ + .globl ace_atomic_swap_add_long \n\ + .type ace_atomic_swap_add_long,@function \n\ + .align 16 \n\ +ace_atomic_swap_add_long: \n\ + lock; xaddq %rsi, (%rdi) \n\ + movq %rsi, %rax \n\ + ret \n\ + "); +} + +#elif defined (__sparcv9) + +unsigned long +ace_atomic_add_long (volatile unsigned long *dest, long rhs) +{ + __asm ("restore\n" + "ldx [%o0], %o2\n" + ".again_add:\n" + "add %o2, %o1, %o3\n" + "casx [%o0], %o2, %o3\n" + "cmp %o2, %o3\n" + "bne,pn %xcc, .again_add\n" + "mov %o3, %o2\n" + "retl\n" + "add %o2, %o1, %o0\n"); +} + +unsigned long +ace_atomic_swap_long (volatile unsigned long *dest, unsigned long rhs) +{ + __asm ("restore\n" + "ldx [%o0], %o2\n" + ".again_swap:\n" + "mov %o1, %o3\n" + "casx [%o0], %o2, %o3\n" + "cmp %o2, %o3\n" + "bne,pn %xcc, .again_swap\n" + "mov %o3, %o2\n" + "retl\n" + "mov %o3, %o0\n"); +} + +unsigned long +ace_atomic_swap_add_long (volatile unsigned long *dest, long rhs) +{ + __asm ("restore\n" + "ldx [%o0], %o2\n" + ".again_swap_add:\n" + "mov %o2, %o4\n" + "add %o2, %o1, %o3\n" + "casx [%o0], %o2, %o3\n" + "cmp %o2, %o3\n" + "bne,pn %xcc, .again_swap_add\n" + "mov %o3, %o2\n" + "retl\n" + "mov %o4, %o0\n"); +} + +#else + +unsigned long +ace_atomic_add_long (volatile unsigned long *dest, long rhs) +{ + __asm ("restore\n" + "ld [%o0], %o2\n" + ".again_add:\n" + "add %o2, %o1, %o3\n" + "cas [%o0], %o2, %o3\n" + "cmp %o2, %o3\n" + "bne,pn %icc, .again_add\n" + "mov %o3, %o2\n" + "retl\n" + "add %o2, %o1, %o0\n"); +} + +unsigned long +ace_atomic_swap_long (volatile unsigned long *dest, unsigned long rhs) +{ + __asm ("restore\n" + "ld [%o0], %o2\n" + ".again_swap:\n" + "mov %o1, %o3\n" + "cas [%o0], %o2, %o3\n" + "cmp %o2, %o3\n" + "bne,pn %icc, .again_swap\n" + "mov %o3, %o2\n" + "retl\n" + "mov %o3, %o0\n"); +} + +unsigned long +ace_atomic_swap_add_long (volatile unsigned long *dest, long rhs) +{ + __asm ("restore\n" + "ld [%o0], %o2\n" + ".again_swap_add:\n" + "mov %o2, %o4\n" + "add %o2, %o1, %o3\n" + "cas [%o0], %o2, %o3\n" + "cmp %o2, %o3\n" + "bne,pn %icc, .again_swap_add\n" + "mov %o3, %o2\n" + "retl\n" + "mov %o4, %o0\n"); +} + +# endif /* __sparcv9 */ + +#elif !defined (__GNUC__) && !defined (__INTEL_COMPILER) +/* Make compilers stop complaining about an empty translation unit */ +static int shut_up_compiler = 0; +#endif /* ACE_INCLUDE_ATOMIC_OP_SPARC */ diff --git a/dep/ACE_wrappers/ace/Atomic_Op_Sparc.h b/dep/ACE_wrappers/ace/Atomic_Op_Sparc.h new file mode 100644 index 00000000000..75b9ad6eaa2 --- /dev/null +++ b/dep/ACE_wrappers/ace/Atomic_Op_Sparc.h @@ -0,0 +1,14 @@ +/* -*- C++ -*- */ +// $Id: Atomic_Op_Sparc.h 80826 2008-03-04 14:51:23Z wotte $ + +#ifndef ACE_ATOMIC_OP_SPARC_H +#define ACE_ATOMIC_OP_SPARC_H + +extern "C" +{ + unsigned long ace_atomic_add_long (volatile unsigned long *dest, long rhs); + unsigned long ace_atomic_swap_long (volatile unsigned long *dest, unsigned long rhs); + unsigned long ace_atomic_swap_add_long (volatile unsigned long *dest, long rhs); +} + +#endif /* ACE_ATOMIC_OP_SPARC_H */ diff --git a/dep/ACE_wrappers/ace/Atomic_Op_T.cpp b/dep/ACE_wrappers/ace/Atomic_Op_T.cpp new file mode 100644 index 00000000000..7f14370c6dd --- /dev/null +++ b/dep/ACE_wrappers/ace/Atomic_Op_T.cpp @@ -0,0 +1,82 @@ +#ifndef ACE_ATOMIC_OP_T_CPP +#define ACE_ATOMIC_OP_T_CPP + +#include "ace/Atomic_Op_T.h" + +#ifdef ACE_HAS_DUMP +# include "ace/Log_Msg.h" +#endif /* ACE_HAS_DUMP */ + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#if !defined (__ACE_INLINE__) +#include "ace/Atomic_Op_T.inl" +#endif /* __ACE_INLINE__ */ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_ALLOC_HOOK_DEFINE(ACE_Atomic_Op_Ex) +ACE_ALLOC_HOOK_DEFINE(ACE_Atomic_Op) + +ACE_RCSID(ace, Atomic_Op_T, "$Id: Atomic_Op_T.cpp 80826 2008-03-04 14:51:23Z wotte $") + +// ************************************************* +template ACE_LOCK & +ACE_Atomic_Op_Ex::mutex (void) +{ + // ACE_TRACE ("ACE_Atomic_Op_Ex::mutex"); + return this->mutex_; +} + +template +void +ACE_Atomic_Op_Ex::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + // ACE_TRACE ("ACE_Atomic_Op_Ex::dump"); + ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); + this->mutex_.dump (); + ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); +#endif /* ACE_HAS_DUMP */ +} + +template +ACE_Atomic_Op_Ex::ACE_Atomic_Op_Ex (ACE_LOCK & mtx) + : mutex_ (mtx) + , value_ (0) +{ + // ACE_TRACE ("ACE_Atomic_Op_Ex::ACE_Atomic_Op_Ex"); +} + +template +ACE_Atomic_Op_Ex::ACE_Atomic_Op_Ex ( + ACE_LOCK & mtx, + typename ACE_Atomic_Op_Ex::arg_type c) + : mutex_ (mtx) + , value_ (c) +{ + // ACE_TRACE ("ACE_Atomic_Op_Ex::ACE_Atomic_Op_Ex"); +} + +// **************************************************************** + +template +ACE_Atomic_Op::ACE_Atomic_Op (void) + : impl_ (this->own_mutex_) +{ + // ACE_TRACE ("ACE_Atomic_Op::ACE_Atomic_Op"); +} + +template +ACE_Atomic_Op::ACE_Atomic_Op ( + typename ACE_Atomic_Op::arg_type c) + : impl_ (own_mutex_, c) +{ + // ACE_TRACE ("ACE_Atomic_Op::ACE_Atomic_Op"); +} + +ACE_END_VERSIONED_NAMESPACE_DECL + +#endif /* ACE_ATOMIC_OP_T_CPP */ diff --git a/dep/ACE_wrappers/ace/Atomic_Op_T.h b/dep/ACE_wrappers/ace/Atomic_Op_T.h new file mode 100644 index 00000000000..13bd7dbbf88 --- /dev/null +++ b/dep/ACE_wrappers/ace/Atomic_Op_T.h @@ -0,0 +1,369 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Atomic_Op_T.h + * + * $Id: Atomic_Op_T.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Douglas C. Schmidt + */ +//============================================================================= + +#ifndef ACE_ATOMIC_OP_T_H +#define ACE_ATOMIC_OP_T_H +#include /**/ "ace/pre.h" + +#include /**/ "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +template +struct ACE_Type_Traits +{ + typedef TYPE const & parameter_type; +}; + +template<> +struct ACE_Type_Traits +{ + typedef bool parameter_type; +}; + +template<> +struct ACE_Type_Traits +{ + typedef char parameter_type; +}; + +template<> +struct ACE_Type_Traits +{ + typedef signed char parameter_type; +}; + +template<> +struct ACE_Type_Traits +{ + typedef unsigned char parameter_type; +}; + +template<> +struct ACE_Type_Traits +{ + typedef short parameter_type; +}; + +template<> +struct ACE_Type_Traits +{ + typedef unsigned short parameter_type; +}; + +template<> +struct ACE_Type_Traits +{ + typedef int parameter_type; +}; + +template<> +struct ACE_Type_Traits +{ + typedef unsigned int parameter_type; +}; + +template<> +struct ACE_Type_Traits +{ + typedef long parameter_type; +}; + +template<> +struct ACE_Type_Traits +{ + typedef unsigned long parameter_type; +}; + +#ifndef ACE_LACKS_LONGLONG_T +template<> +struct ACE_Type_Traits +{ + typedef long long parameter_type; +}; +#endif /* !ACE_LACKS_LONGLONG_T */ + +#if !defined (ACE_LACKS_LONGLONG_T) \ + && !defined (ACE_LACKS_UNSIGNEDLONGLONG_T) +template<> +struct ACE_Type_Traits +{ + typedef unsigned long long parameter_type; +}; +#endif /* !ACE_LACKS_LONGLONG_T && !ACE_LACKS_UNSIGNEDLONGLONG_T */ + +template<> +struct ACE_Type_Traits +{ + typedef float parameter_type; +}; + +template<> +struct ACE_Type_Traits +{ + typedef double parameter_type; +}; + +template<> +struct ACE_Type_Traits +{ + typedef long double parameter_type; +}; + +template +struct ACE_Type_Traits +{ + typedef TYPE* parameter_type; +}; + +/** + * @class ACE_Atomic_Op_Ex + * + * @brief Transparently parameterizes synchronization into basic + * arithmetic operations. + * + * This class is described in an article in the July/August 1994 + * issue of the C++ Report magazine. It implements a + * templatized version of the Decorator pattern from the GoF book. + * + * ACE_Atomic_Op_Ex objects must be constructed with a reference + * to an existing lock. A single lock can be shared between + * multiple ACE_Atomic_Op_Ex objects. If you do not require this + * ability consider using the ACE_Atomic_Op class instead, which + * may be able to take advantage of platform-specific + * optimisations to provide atomic operations without requiring a + * lock. + */ +template +class ACE_Atomic_Op_Ex +{ +public: + + typedef typename ACE_Type_Traits::parameter_type arg_type; + + // = Initialization methods. + + /// Initialize @c value_ to 0. + ACE_Atomic_Op_Ex (ACE_LOCK & mtx); + + /// Initialize @c value_ to c. + ACE_Atomic_Op_Ex (ACE_LOCK & mtx, arg_type c); + + // = Accessors. + + /// Atomically pre-increment @c value_. + TYPE operator++ (void); + + /// Atomically post-increment @c value_. + TYPE operator++ (int); + + /// Atomically increment @c value_ by rhs. + TYPE operator+= (arg_type rhs); + + /// Atomically pre-decrement @c value_. + TYPE operator-- (void); + + /// Atomically post-decrement @c value_. + TYPE operator-- (int); + + /// Atomically decrement @c value_ by rhs. + TYPE operator-= (arg_type rhs); + + /// Atomically compare @c value_ with rhs. + bool operator== (arg_type rhs) const; + + /// Atomically compare @c value_ with rhs. + bool operator!= (arg_type rhs) const; + + /// Atomically check if @c value_ greater than or equal to rhs. + bool operator>= (arg_type rhs) const; + + /// Atomically check if @c value_ greater than rhs. + bool operator> (arg_type rhs) const; + + /// Atomically check if @c value_ less than or equal to rhs. + bool operator<= (arg_type rhs) const; + + /// Atomically check if @c value_ less than rhs. + bool operator< (arg_type rhs) const; + + /// Atomically assign rhs to @c value_. + ACE_Atomic_Op_Ex &operator= (arg_type rhs); + + /// Atomically assign to @c value_. + ACE_Atomic_Op_Ex &operator= ( + ACE_Atomic_Op_Ex const & rhs); + + /// Explicitly return @c value_. + TYPE value (void) const; + + /// Dump the state of an object. + void dump (void) const; + + // ACE_ALLOC_HOOK_DECLARE; + // Declare the dynamic allocation hooks. + + /// Manage copying... + ACE_Atomic_Op_Ex (ACE_Atomic_Op_Ex const &); + + /** + * Returns a reference to the underlying . This makes it + * possible to acquire the lock explicitly, which can be useful in + * some cases if you instantiate the with an + * ACE_Recursive_Mutex or ACE_Process_Mutex. @note the right + * name would be lock_, but HP/C++ will choke on that! + */ + ACE_LOCK & mutex (void); + + /** + * Explicitly return @c value_ (by reference). This gives the user + * full, unrestricted access to the underlying value. This method + * will usually be used in conjunction with explicit access to the + * lock. Use with care ;-) + */ + TYPE & value_i (void); + +private: + /// Type of synchronization mechanism. + ACE_LOCK & mutex_; + + /// Current object decorated by the atomic op. + TYPE value_; +}; + +/** + * @class ACE_Atomic_Op + * + * @brief Transparently parameterizes synchronization into basic + * arithmetic operations. + * + * This class is described in an article in the July/August 1994 + * issue of the C++ Report magazine. It implements a + * templatized version of the Decorator pattern from the GoF book. + * + * Certain platforms may provide a template specialization for + * ACE_Atomic_Op that provides optimized + * atomic integer operations without actually requiring a mutex. + */ +template +class ACE_Atomic_Op +{ +public: + + typedef typename ACE_Type_Traits::parameter_type arg_type; + + /// Initialize @c value_ to 0. + ACE_Atomic_Op (void); + + /// Initialize @c value_ to c. + ACE_Atomic_Op (arg_type c); + + /// Manage copying... + ACE_Atomic_Op (ACE_Atomic_Op const & c); + + /// Atomically assign rhs to @c value_. + ACE_Atomic_Op & operator= (arg_type rhs); + + /// Atomically assign to @c value_. + ACE_Atomic_Op & operator= ( + ACE_Atomic_Op const & rhs); + + /// Atomically pre-increment @c value_. + TYPE operator++ (void); + + /// Atomically post-increment @c value_. + TYPE operator++ (int); + + /// Atomically increment @c value_ by rhs. + TYPE operator+= (arg_type rhs); + + /// Atomically pre-decrement @c value_. + TYPE operator-- (void); + + /// Atomically post-decrement @c value_. + TYPE operator-- (int); + + /// Atomically decrement @c value_ by rhs. + TYPE operator-= (arg_type rhs); + + /// Atomically compare @c value_ with rhs. + bool operator== (arg_type rhs) const; + + /// Atomically compare @c value_ with rhs. + bool operator!= (arg_type rhs) const; + + /// Atomically check if @c value_ greater than or equal to rhs. + bool operator>= (arg_type rhs) const; + + /// Atomically check if @c value_ greater than rhs. + bool operator> (arg_type rhs) const; + + /// Atomically check if @c value_ less than or equal to rhs. + bool operator<= (arg_type rhs) const; + + /// Atomically check if @c value_ less than rhs. + bool operator< (arg_type rhs) const; + + /// Explicitly return @c value_. + TYPE value (void) const; + + /// Dump the state of an object. + void dump (void) const; + + /** + * Returns a reference to the underlying . This makes it + * possible to acquire the lock explicitly, which can be useful in + * some cases if you instantiate the ACE_Atomic_Op with an + * ACE_Recursive_Mutex or ACE_Process_Mutex. + * + * @deprecated This member function is deprecated and so may go away in + * the future. If you need access to the underlying mutex, consider + * using the ACE_Atomic_Op_Ex template instead. + */ + ACE_LOCK & mutex (void); + + /** + * Explicitly return @c value_ (by reference). This gives the user + * full, unrestricted access to the underlying value. This method + * will usually be used in conjunction with explicit access to the + * lock. Use with care ;-) + */ + TYPE & value_i (void); + +private: + /// Type of synchronization mechanism. + ACE_LOCK own_mutex_; + + /// Underlying atomic op implementation. + ACE_Atomic_Op_Ex impl_; +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +#include "ace/Atomic_Op_T.inl" +#endif /* __ACE_INLINE__ */ + +#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) +#include "ace/Atomic_Op_T.cpp" +#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ + +#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) +#pragma implementation ("Atomic_Op_T.cpp") +#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ + +#include /**/ "ace/post.h" +#endif /*ACE_ATOMIC_OP_T_H*/ diff --git a/dep/ACE_wrappers/ace/Atomic_Op_T.inl b/dep/ACE_wrappers/ace/Atomic_Op_T.inl new file mode 100644 index 00000000000..ff051b0cbce --- /dev/null +++ b/dep/ACE_wrappers/ace/Atomic_Op_T.inl @@ -0,0 +1,340 @@ +// -*- C++ -*- +// +// $Id: Atomic_Op_T.inl 80826 2008-03-04 14:51:23Z wotte $ + +#include "ace/Guard_T.h" + +#include + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +// +// ACE_Atomic_Op_Ex inline functions +// + +template +ACE_INLINE TYPE +ACE_Atomic_Op_Ex::operator++ (void) +{ + // ACE_TRACE ("ACE_Atomic_Op_Ex::operator++"); + ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->mutex_, this->value_); + return ++this->value_; +} + +template +ACE_INLINE TYPE +ACE_Atomic_Op_Ex::operator+= ( + typename ACE_Atomic_Op_Ex::arg_type rhs) +{ + // ACE_TRACE ("ACE_Atomic_Op_Ex::operator+="); + ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->mutex_, this->value_); + return this->value_ += rhs; +} + +template +ACE_INLINE TYPE +ACE_Atomic_Op_Ex::operator-- (void) +{ + // ACE_TRACE ("ACE_Atomic_Op_Ex::operator--"); + ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->mutex_, this->value_); + return --this->value_; +} + +template +ACE_INLINE TYPE +ACE_Atomic_Op_Ex::operator-= ( + typename ACE_Atomic_Op_Ex::arg_type rhs) +{ + // ACE_TRACE ("ACE_Atomic_Op_Ex::operator-="); + ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->mutex_, this->value_); + return this->value_ -= rhs; +} + +template +ACE_INLINE +ACE_Atomic_Op_Ex::ACE_Atomic_Op_Ex ( + ACE_Atomic_Op_Ex const & rhs) + : mutex_ (rhs.mutex_) + , value_ (rhs.value ()) // rhs.value() returns atomically +{ + // ACE_TRACE ("ACE_Atomic_Op_Ex::ACE_Atomic_Op_Ex"); +} + +template +ACE_INLINE TYPE +ACE_Atomic_Op_Ex::operator++ (int) +{ + // ACE_TRACE ("ACE_Atomic_Op_Ex::operator++"); + ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->mutex_, this->value_); + return this->value_++; +} + +template +ACE_INLINE TYPE +ACE_Atomic_Op_Ex::operator-- (int) +{ + // ACE_TRACE ("ACE_Atomic_Op_Ex::operator--"); + ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->mutex_, this->value_); + return this->value_--; +} + +template +ACE_INLINE bool +ACE_Atomic_Op_Ex::operator== ( + typename ACE_Atomic_Op_Ex::arg_type rhs) const +{ + // ACE_TRACE ("ACE_Atomic_Op_Ex::operator=="); + ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->mutex_, false); + return this->value_ == rhs; +} + +template +ACE_INLINE bool +ACE_Atomic_Op_Ex::operator!= ( + typename ACE_Atomic_Op_Ex::arg_type rhs) const +{ + // ACE_TRACE ("ACE_Atomic_Op_Ex::operator!="); + return !(*this == rhs); +} + +template +ACE_INLINE bool +ACE_Atomic_Op_Ex::operator>= ( + typename ACE_Atomic_Op_Ex::arg_type rhs) const +{ + // ACE_TRACE ("ACE_Atomic_Op_Ex::operator>="); + ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->mutex_, false); + return this->value_ >= rhs; +} + +template +ACE_INLINE bool +ACE_Atomic_Op_Ex::operator> ( + typename ACE_Atomic_Op_Ex::arg_type rhs) const +{ + // ACE_TRACE ("ACE_Atomic_Op_Ex::operator>"); + ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->mutex_, false); + return this->value_ > rhs; +} + +template +ACE_INLINE bool +ACE_Atomic_Op_Ex::operator<= ( + typename ACE_Atomic_Op_Ex::arg_type rhs) const +{ + // ACE_TRACE ("ACE_Atomic_Op_Ex::operator<="); + ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->mutex_, false); + return this->value_ <= rhs; +} + +template +ACE_INLINE bool +ACE_Atomic_Op_Ex::operator< ( + typename ACE_Atomic_Op_Ex::arg_type rhs) const +{ + // ACE_TRACE ("ACE_Atomic_Op_Ex::operator<"); + ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->mutex_, false); + return this->value_ < rhs; +} + +template +ACE_INLINE ACE_Atomic_Op_Ex & +ACE_Atomic_Op_Ex::operator= ( + ACE_Atomic_Op_Ex const & rhs) +{ + // ACE_TRACE ("ACE_Atomic_Op_Ex::operator="); + + ACE_Atomic_Op_Ex tmp (rhs); + + ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->mutex_, *this); + std::swap (this->value_, tmp.value_); + + return *this; +} + +template +ACE_INLINE TYPE +ACE_Atomic_Op_Ex::value (void) const +{ + // ACE_TRACE ("ACE_Atomic_Op_Ex::value"); + ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->mutex_, this->value_); + return this->value_; +} + +template +ACE_INLINE TYPE & +ACE_Atomic_Op_Ex::value_i (void) +{ + // Explicitly return (by reference). This gives the user + // full, unrestricted access to the underlying value. This method + // will usually be used in conjunction with explicit access to the + // lock. Use with care ;-) + return this->value_; +} + +template +ACE_INLINE ACE_Atomic_Op_Ex & +ACE_Atomic_Op_Ex::operator= ( + typename ACE_Atomic_Op_Ex::arg_type rhs) +{ + // ACE_TRACE ("ACE_Atomic_Op_Ex::operator="); + ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->mutex_, *this); + this->value_ = rhs; + return *this; +} + +// +// ACE_Atomic_Op inline functions +// + +template ACE_INLINE +ACE_Atomic_Op::ACE_Atomic_Op ( + ACE_Atomic_Op const & rhs) + : impl_ (own_mutex_, rhs.value ()) +{ + // ACE_TRACE ("ACE_Atomic_Op::ACE_Atomic_Op"); +} + + +template +ACE_INLINE ACE_Atomic_Op & +ACE_Atomic_Op::operator= ( + typename ACE_Atomic_Op::arg_type i) +{ + this->impl_ = i; + return *this; +} + +template +ACE_INLINE ACE_Atomic_Op & +ACE_Atomic_Op::operator= ( + ACE_Atomic_Op const & rhs) +{ + this->impl_ = rhs.impl_; + return *this; +} + +template +ACE_INLINE TYPE +ACE_Atomic_Op::operator++ (void) +{ + return ++this->impl_; +} + +template +ACE_INLINE TYPE +ACE_Atomic_Op::operator++ (int) +{ + return this->impl_++; +} + +template +ACE_INLINE TYPE +ACE_Atomic_Op::operator+= ( + typename ACE_Atomic_Op::arg_type rhs) +{ + return this->impl_ += rhs; +} + +template +ACE_INLINE TYPE +ACE_Atomic_Op::operator-- (void) +{ + return --this->impl_; +} + +template +ACE_INLINE TYPE +ACE_Atomic_Op::operator-- (int) +{ + return this->impl_--; +} + +template +ACE_INLINE TYPE +ACE_Atomic_Op::operator-= ( + typename ACE_Atomic_Op::arg_type rhs) +{ + return this->impl_ -= rhs; +} + +template +ACE_INLINE bool +ACE_Atomic_Op::operator== ( + typename ACE_Atomic_Op::arg_type rhs) const +{ + return this->impl_ == rhs; +} + +template +ACE_INLINE bool +ACE_Atomic_Op::operator!= ( + typename ACE_Atomic_Op::arg_type rhs) const +{ + return this->impl_ != rhs; +} + +template +ACE_INLINE bool +ACE_Atomic_Op::operator>= ( + typename ACE_Atomic_Op::arg_type rhs) const +{ + return this->impl_ >= rhs; +} + +template +ACE_INLINE bool +ACE_Atomic_Op::operator> ( + typename ACE_Atomic_Op::arg_type rhs) const +{ + return this->impl_ > rhs; +} + +template +ACE_INLINE bool +ACE_Atomic_Op::operator<= ( + typename ACE_Atomic_Op::arg_type rhs) const +{ + return this->impl_ <= rhs; +} + +template +ACE_INLINE bool +ACE_Atomic_Op::operator< ( + typename ACE_Atomic_Op::arg_type rhs) const +{ + return this->impl_ < rhs; +} + +template +ACE_INLINE TYPE +ACE_Atomic_Op::value (void) const +{ + return this->impl_.value (); +} + +template +ACE_INLINE void +ACE_Atomic_Op::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + this->impl_.dump (); +#endif /* ACE_HAS_DUMP */ + return; +} + +template +ACE_INLINE ACE_LOCK & +ACE_Atomic_Op::mutex (void) +{ + return this->own_mutex_; +} + +template +ACE_INLINE TYPE & +ACE_Atomic_Op::value_i (void) +{ + return this->impl_.value_i (); +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Auto_Event.cpp b/dep/ACE_wrappers/ace/Auto_Event.cpp new file mode 100644 index 00000000000..51efcf7605b --- /dev/null +++ b/dep/ACE_wrappers/ace/Auto_Event.cpp @@ -0,0 +1,49 @@ +// $Id: Auto_Event.cpp 80826 2008-03-04 14:51:23Z wotte $ + +#include "ace/Auto_Event.h" + +#if !defined (__ACE_INLINE__) +#include "ace/Auto_Event.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID (ace, + Auto_Event, + "$Id: Auto_Event.cpp 80826 2008-03-04 14:51:23Z wotte $") + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_Auto_Event::ACE_Auto_Event (int initial_state, + int type, + const char *name, + void *arg) + : ACE_Event (0, + initial_state, + type, + ACE_TEXT_CHAR_TO_TCHAR (name), + arg) +{ +} + +#if defined (ACE_HAS_WCHAR) +ACE_Auto_Event::ACE_Auto_Event (int initial_state, + int type, + const wchar_t *name, + void *arg) + : ACE_Event (0, + initial_state, + type, + ACE_TEXT_WCHAR_TO_TCHAR (name), + arg) +{ +} +#endif /* ACE_HAS_WCHAR */ + +void +ACE_Auto_Event::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + ACE_Event::dump (); +#endif /* ACE_HAS_DUMP */ +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Auto_Event.h b/dep/ACE_wrappers/ace/Auto_Event.h new file mode 100644 index 00000000000..042f82ed2ff --- /dev/null +++ b/dep/ACE_wrappers/ace/Auto_Event.h @@ -0,0 +1,73 @@ +// -*- C++ -*- + +//========================================================================== +/** + * @file Auto_Event.h + * + * $Id: Auto_Event.h 80826 2008-03-04 14:51:23Z wotte $ + * + * Moved from Synch.h. + * + * @author Douglas C. Schmidt + */ +//========================================================================== + +#ifndef ACE_AUTO_EVENT_H +#define ACE_AUTO_EVENT_H +#include /**/ "ace/pre.h" + +#include /**/ "ace/ACE_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/Event.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +/** + * @class ACE_Auto_Event + * + * @brief Auto Events. + * + * Specialization of Event mechanism which wakes up one waiting + * thread on . All platforms support process-scope locking + * support. However, only Win32 platforms support global naming and + * system-scope locking support. + */ +class ACE_Export ACE_Auto_Event : public ACE_Event +{ +public: + /// Constructor which will create auto event + ACE_Auto_Event (int initial_state = 0, + int type = USYNC_THREAD, + const char *name = 0, + void *arg = 0); + +#if defined (ACE_HAS_WCHAR) + /// Constructor which will create auto event (wchar_t version) + ACE_Auto_Event (int initial_state, + int type, + const wchar_t *name, + void *arg = 0); +#endif /* ACE_HAS_WCHAR */ + + /// Default dtor. + ~ACE_Auto_Event (void); + + /// Dump the state of an object. + void dump (void) const; + + /// Declare the dynamic allocation hooks + ACE_ALLOC_HOOK_DECLARE; +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +#include "ace/Auto_Event.inl" +#endif /* __ACE_INLINE__ */ + +#include /**/ "ace/post.h" +#endif /* ACE_AUTO_EVENT_H */ diff --git a/dep/ACE_wrappers/ace/Auto_Event.inl b/dep/ACE_wrappers/ace/Auto_Event.inl new file mode 100644 index 00000000000..b614e0b0d77 --- /dev/null +++ b/dep/ACE_wrappers/ace/Auto_Event.inl @@ -0,0 +1,12 @@ +// -*- C++ -*- +// +// $Id: Auto_Event.inl 80826 2008-03-04 14:51:23Z wotte $ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_INLINE +ACE_Auto_Event::~ACE_Auto_Event (void) +{ +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Auto_Functor.cpp b/dep/ACE_wrappers/ace/Auto_Functor.cpp new file mode 100644 index 00000000000..9d0dc79aa52 --- /dev/null +++ b/dep/ACE_wrappers/ace/Auto_Functor.cpp @@ -0,0 +1,39 @@ +// $Id: Auto_Functor.cpp 80826 2008-03-04 14:51:23Z wotte $ + +#ifndef ACE_AUTO_FUNCTOR_CPP +#define ACE_AUTO_FUNCTOR_CPP + +#include "ace/Auto_Functor.h" + +#if !defined(__ACE_INLINE__) +# include "ace/Auto_Functor.inl" +#endif /* __ACE_INLINE__ */ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +template +ACE_Utils::Auto_Functor::~Auto_Functor() +{ + reset(0); +} + +template void +ACE_Utils::Auto_Functor::reset(X * p) +{ + if(p_ != 0) + { + f_(p_); + } + p_ = p; +} + +templatevoid +ACE_Utils::Auto_Functor::reset(X * p, Functor f) +{ + reset(p); + f_ = f; +} + +ACE_END_VERSIONED_NAMESPACE_DECL + +#endif /*ACE_AUTO_FUNCTOR_CPP*/ diff --git a/dep/ACE_wrappers/ace/Auto_Functor.h b/dep/ACE_wrappers/ace/Auto_Functor.h new file mode 100644 index 00000000000..2c2b81eb265 --- /dev/null +++ b/dep/ACE_wrappers/ace/Auto_Functor.h @@ -0,0 +1,127 @@ +// -*- C++ -*- +//============================================================================= +/** + * @file Auto_Functor.h + * + * $Id: Auto_Functor.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Carlos O'Ryan + */ +//============================================================================= +#ifndef ACE_AUTO_FUNCTOR_H +#define ACE_AUTO_FUNCTOR_H +#include /**/ "ace/pre.h" + +#include /**/ "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/Global_Macros.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +namespace ACE_Utils +{ +/** + * @class Auto_Functor_Ref + * + * @brief Helper class to implement assignment and copy-construction + * as expected + */ +template +struct Auto_Functor_Ref +{ + X * p_; + Functor f_; + + Auto_Functor_Ref(X * p, Functor f); +}; + +/** + * @class Auto_Functor + * + * @brief Helper template to implement auto_ptr<>-like classes, but + * executing a functor in the destructor, instead of always + * deleting things. + * + * The functor is called in the destructor, and it must implement: + * + * Functor() throw();
+ * Functor(Functor const &) throw();
+ * Functor & operator=(Functor const &) throw();
+ * void operator()(X * p) throw();
+ * + */ +template +class Auto_Functor +{ +public: + typedef X element_type; + typedef Functor functor_type; + + /// Constructor + explicit Auto_Functor (X * p = 0, + Functor functor = Functor()); // throw() + + Auto_Functor (Auto_Functor & rhs); // throw() + + Auto_Functor& operator= (Auto_Functor & rhs); // throw() + +#if !defined(ACE_LACKS_MEMBER_TEMPLATES) + template + Auto_Functor(Auto_Functor& rhs); // throw() + + template + Auto_Functor& operator= (Auto_Functor& rhs); // throw() +#endif /* ACE_LACKS_MEMBER_TEMPLATES */ + + ~Auto_Functor(); // throw() + + X & operator*() const; // throw() + + X * operator->() const; // throw() + + X * get(); // throw() + + X * release(); // throw() + + void reset (X * p = 0); // throw() + + void reset (X * p, Functor f); // throw() + + Functor const & functor() const; // throw() + + Auto_Functor(Auto_Functor_Ref rhs); // throw() + + Auto_Functor & operator=(Auto_Functor_Ref rhs); // throw() + +#if !defined(ACE_LACKS_MEMBER_TEMPLATES) + template operator Auto_Functor_Ref(); // throw() + + template operator Auto_Functor(); // throw() +#else + operator Auto_Functor_Ref(); // throw() +#endif /* ACE_LACKS_MEMBER_TEMPLATES */ + +private: + X * p_; + + Functor f_; +}; + +} // namespace ACE_Utils + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined(__ACE_INLINE__) +# include "ace/Auto_Functor.inl" +#endif /* __ACE_INLINE__ */ + +#if defined(ACE_TEMPLATES_REQUIRE_SOURCE) +# include "ace/Auto_Functor.cpp" +#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ + +#include /**/ "ace/post.h" +#endif /* ACE_AUTO_FUNCTOR_H*/ diff --git a/dep/ACE_wrappers/ace/Auto_Functor.inl b/dep/ACE_wrappers/ace/Auto_Functor.inl new file mode 100644 index 00000000000..d4cb2cc0473 --- /dev/null +++ b/dep/ACE_wrappers/ace/Auto_Functor.inl @@ -0,0 +1,134 @@ +// -*- C++ -*- +// +// $Id: Auto_Functor.inl 80826 2008-03-04 14:51:23Z wotte $ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +template ACE_INLINE +ACE_Utils::Auto_Functor_Ref:: +Auto_Functor_Ref(X * p, Functor f) + : p_(p) + , f_(f) +{ +} + +template ACE_INLINE +ACE_Utils::Auto_Functor::Auto_Functor(X * p, Functor f) + : p_(p) + , f_(f) +{ +} + +template ACE_INLINE +ACE_Utils::Auto_Functor::Auto_Functor(Auto_Functor & rhs) + : p_(rhs.release()) + , f_(rhs.f_) +{ +} + +template +ACE_INLINE ACE_Utils::Auto_Functor& +ACE_Utils::Auto_Functor:: operator=(Auto_Functor & rhs) +{ + reset(rhs.release()); + f_ = rhs.f_; + return *this; +} + +#if !defined(ACE_LACKS_MEMBER_TEMPLATES) +template template ACE_INLINE +ACE_Utils::Auto_Functor::Auto_Functor(Auto_Functor& rhs) + : p_(rhs.release()) + , f_(rhs.f_) +{ +} + +template template +ACE_INLINE ACE_Utils::Auto_Functor& +ACE_Utils::Auto_Functor::operator=(Auto_Functor& rhs) +{ + reset(rhs.release()); + return *this; +} +#endif /* ACE_LACKS_MEMBER_TEMPLATES */ + +template ACE_INLINE X & +ACE_Utils::Auto_Functor::operator*() const +{ + return *p_; +} + +template +ACE_INLINE X * +ACE_Utils::Auto_Functor::operator->() const +{ + return p_; +} + +template +ACE_INLINE X * +ACE_Utils::Auto_Functor::get() +{ + return p_; +} + +template +ACE_INLINE X * +ACE_Utils::Auto_Functor::release() +{ + X * tmp = p_; + p_ = 0; + return tmp; +} + +template +ACE_INLINE Functor const & +ACE_Utils::Auto_Functor::functor() const +{ + return f_; +} + +template ACE_INLINE +ACE_Utils::Auto_Functor::Auto_Functor(Auto_Functor_Ref rhs) + : p_(rhs.p_) + , f_(rhs.f_) +{ +} + +template +ACE_INLINE ACE_Utils::Auto_Functor & +ACE_Utils::Auto_Functor::operator=(Auto_Functor_Ref rhs) +{ + if(rhs.p_ != p_) + { + reset(rhs.p_); + f_ = rhs.f_; + } + return *this; +} + +#if !defined(ACE_LACKS_MEMBER_TEMPLATES) + +template template ACE_INLINE +ACE_Utils::Auto_Functor::operator ACE_Utils::Auto_Functor_Ref() +{ + return ACE_Utils::Auto_Functor_Ref(release(), f_); +} + +template template ACE_INLINE +ACE_Utils::Auto_Functor::operator ACE_Utils::Auto_Functor() +{ + return ACE_Utils::Auto_Functor(release(), f_); +} + +#else + +templateACE_INLINE +ACE_Utils::Auto_Functor::operator ACE_Utils::Auto_Functor_Ref() +{ + return ACE_Utils::Auto_Functor_Ref(release(), f_); +} + +#endif /* ACE_LACKS_MEMBER_TEMPLATES */ + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Auto_IncDec_T.cpp b/dep/ACE_wrappers/ace/Auto_IncDec_T.cpp new file mode 100644 index 00000000000..ccef122edcf --- /dev/null +++ b/dep/ACE_wrappers/ace/Auto_IncDec_T.cpp @@ -0,0 +1,34 @@ +// $Id: Auto_IncDec_T.cpp 80826 2008-03-04 14:51:23Z wotte $ + +#ifndef ACE_AUTO_INCDEC_T_CPP +#define ACE_AUTO_INCDEC_T_CPP + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/Auto_IncDec_T.h" +#include "ace/Log_Msg.h" + +#if !defined (__ACE_INLINE__) +#include "ace/Auto_IncDec_T.inl" +#endif /* __ACE_INLINE__ */ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_ALLOC_HOOK_DEFINE(ACE_Auto_IncDec) + +template void +ACE_Auto_IncDec::dump (void) const +{ +#if defined (ACE_HAS_DUMP) +// ACE_TRACE ("ACE_Auto_IncDec::dump"); + + ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); + ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); +#endif /* ACE_HAS_DUMP */ +} + +ACE_END_VERSIONED_NAMESPACE_DECL + +#endif /* ACE_AUTO_INCDEC_T_CPP */ diff --git a/dep/ACE_wrappers/ace/Auto_IncDec_T.h b/dep/ACE_wrappers/ace/Auto_IncDec_T.h new file mode 100644 index 00000000000..01677101db5 --- /dev/null +++ b/dep/ACE_wrappers/ace/Auto_IncDec_T.h @@ -0,0 +1,91 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Auto_IncDec_T.h + * + * $Id: Auto_IncDec_T.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Edan Ayal + */ +//============================================================================= + + +#ifndef ACE_AUTO_INCDEC_T_H +#define ACE_AUTO_INCDEC_T_H + +#include /**/ "ace/pre.h" + +#include /**/ "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/Global_Macros.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +/** + * @class ACE_Auto_IncDec + * + * @brief This class automatically increments and decrements a + * parameterized counter. + * + * This data structure is meant to be used within a method, + * function, or scope. The actual parameter given for the + * template parameter + * must provide at least operators ++ and --. + */ +template +class ACE_Auto_IncDec +{ +public: + + /// Implicitly increment the counter. + ACE_Auto_IncDec (ACE_SAFELY_INCREMENTABLE_DECREMENTABLE &counter); + + /// Implicitly decrement the counter. + ~ACE_Auto_IncDec (void); + + /// Dump the state of an object. + void dump (void) const; + +protected: + /// Reference to the counter + /// we're incrementing/decrementing. + ACE_SAFELY_INCREMENTABLE_DECREMENTABLE &counter_; + +private: + // = Prevent assignment and initialization. + ACE_UNIMPLEMENTED_FUNC (void operator= (const + ACE_Auto_IncDec &)) + ACE_UNIMPLEMENTED_FUNC (ACE_Auto_IncDec (const + ACE_Auto_IncDec &)) +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +#include "ace/Auto_IncDec_T.inl" +#endif /* __ACE_INLINE__ */ + +#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) +#include "ace/Auto_IncDec_T.cpp" +// On Win32 platforms, this code will be included as template source +// code and will not be inlined. Therefore, we first turn off +// ACE_INLINE, set it to be nothing, include the code, and then turn +// ACE_INLINE back to its original setting. All this nonsense is +// necessary, since the generic template code that needs to be +// specialized cannot be inlined, else the compiler will ignore the +// specialization code. Also, the specialization code *must* be +// inlined or the compiler will ignore the specializations. +#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ + +#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) +#pragma implementation ("Auto_IncDec_T.cpp") +#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ + +#include /**/ "ace/post.h" + +#endif /* ACE_AUTO_INCDEC_T_H */ diff --git a/dep/ACE_wrappers/ace/Auto_IncDec_T.inl b/dep/ACE_wrappers/ace/Auto_IncDec_T.inl new file mode 100644 index 00000000000..e61980e7192 --- /dev/null +++ b/dep/ACE_wrappers/ace/Auto_IncDec_T.inl @@ -0,0 +1,25 @@ +// -*- C++ -*- +// +// $Id: Auto_IncDec_T.inl 80826 2008-03-04 14:51:23Z wotte $ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +// Implicitly and automatically increment the counter. + +template ACE_INLINE +ACE_Auto_IncDec::ACE_Auto_IncDec + (ACE_SAFELY_INCREMENTABLE_DECREMENTABLE &counter) + : counter_ (counter) +{ + ++this->counter_; +} + +// Implicitly and automatically decrement the counter. + +template ACE_INLINE +ACE_Auto_IncDec::~ACE_Auto_IncDec (void) +{ + --this->counter_; +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Auto_Ptr.cpp b/dep/ACE_wrappers/ace/Auto_Ptr.cpp new file mode 100644 index 00000000000..791bd482a23 --- /dev/null +++ b/dep/ACE_wrappers/ace/Auto_Ptr.cpp @@ -0,0 +1,21 @@ +// $Id: Auto_Ptr.cpp 80826 2008-03-04 14:51:23Z wotte $ + +#ifndef ACE_AUTO_PTR_CPP +#define ACE_AUTO_PTR_CPP + +#include "ace/Auto_Ptr.h" + +#if !defined (__ACE_INLINE__) +#include "ace/Auto_Ptr.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(ace, Auto_Ptr, "$Id: Auto_Ptr.cpp 80826 2008-03-04 14:51:23Z wotte $") + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_ALLOC_HOOK_DEFINE(ACE_Auto_Basic_Ptr) +ACE_ALLOC_HOOK_DEFINE(ACE_Auto_Basic_Array_Ptr) + +ACE_END_VERSIONED_NAMESPACE_DECL + +#endif /* ACE_AUTO_PTR_CPP */ diff --git a/dep/ACE_wrappers/ace/Auto_Ptr.h b/dep/ACE_wrappers/ace/Auto_Ptr.h new file mode 100644 index 00000000000..3183019aceb --- /dev/null +++ b/dep/ACE_wrappers/ace/Auto_Ptr.h @@ -0,0 +1,242 @@ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file Auto_Ptr.h + * + * $Id: Auto_Ptr.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Doug Schmidt + * @author Irfan Pyarali + * @author Jack Reeves + * @author Dr. Harald M. Mueller + */ +//============================================================================= + +#ifndef ACE_AUTO_PTR_H +#define ACE_AUTO_PTR_H +#include /**/ "ace/pre.h" + +#include /**/ "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#if defined (_MSC_VER) +// Suppress warning e.g. "return type for +// 'ACE_Auto_Array_Pointer::operator ->' is 'type *' (i.e., not a UDT +// or reference to a UDT. Will produce errors if applied using infix +// notation)" +# pragma warning(push) +# pragma warning(disable: 4284) +#endif /* _MSC_VER */ + + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +/** + * @class ACE_Auto_Basic_Ptr + * + * @brief Implements the draft C++ standard auto_ptr abstraction. + * This class allows one to work on non-object (basic) types + */ +template +class ACE_Auto_Basic_Ptr +{ +public: + typedef X element_type; + + // = Initialization and termination methods + explicit ACE_Auto_Basic_Ptr (X * p = 0) : p_ (p) {} + + ACE_Auto_Basic_Ptr (ACE_Auto_Basic_Ptr & ap); + ACE_Auto_Basic_Ptr &operator= (ACE_Auto_Basic_Ptr & rhs); + ~ACE_Auto_Basic_Ptr (void); + + // = Accessor methods. + X &operator *() const; + X *get (void) const; + X *release (void); + void reset (X * p = 0); + + /// Dump the state of an object. + void dump (void) const; + + /// Declare the dynamic allocation hooks. + ACE_ALLOC_HOOK_DECLARE; + +protected: + X *p_; +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if !defined (ACE_LACKS_AUTO_PTR) && \ + defined (ACE_HAS_STANDARD_CPP_LIBRARY) && \ + (ACE_HAS_STANDARD_CPP_LIBRARY != 0) +#include +#if defined (ACE_USES_STD_NAMESPACE_FOR_STDCPP_LIB) && \ + (ACE_USES_STD_NAMESPACE_FOR_STDCPP_LIB != 0) +using std::auto_ptr; +#endif /* ACE_USES_STD_NAMESPACE_FOR_STDCPP_LIB */ +#else /* ACE_HAS_STANDARD_CPP_LIBRARY */ + +/** + * @class auto_ptr + * + * @brief Implements the draft C++ standard auto_ptr abstraction. + */ +template +class auto_ptr : public ACE_Auto_Basic_Ptr +{ +public: + typedef X element_type; + + // = Initialization and termination methods + explicit auto_ptr (X * p = 0) : ACE_Auto_Basic_Ptr (p) {} + auto_ptr (auto_ptr & ap) : ACE_Auto_Basic_Ptr (ap.release ()) {} + + X *operator-> () const; +}; + +#endif /* ACE_HAS_STANDARD_CPP_LIBRARY */ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +/** + * @brief Implements the draft C++ standard auto_ptr abstraction. + * This version can be used instead of auto_ptr, and obviates + * the need for the ACE_AUTO_PTR_RESET macro on platforms like + * VC6 where the auto_ptr is broken. + */ +template +class ACE_Auto_Ptr : public ACE_Auto_Basic_Ptr +{ +public: + typedef X element_type; + + // = Initialization and termination methods + explicit ACE_Auto_Ptr (X * p = 0) : ACE_Auto_Basic_Ptr (p) {} + + X *operator-> () const; +}; + +/** + * @class ACE_Auto_Basic_Array_Ptr + * + * @brief Implements an extension to the draft C++ standard auto_ptr + * abstraction. This class allows one to work on non-object + * (basic) types that must be treated as an array, e.g., + * deallocated via "delete [] foo". + */ +template +class ACE_Auto_Basic_Array_Ptr +{ +public: + typedef X element_type; + + // = Initialization and termination methods. + explicit ACE_Auto_Basic_Array_Ptr (X * p = 0) : p_ (p) {} + + ACE_Auto_Basic_Array_Ptr (ACE_Auto_Basic_Array_Ptr & ap); + ACE_Auto_Basic_Array_Ptr &operator= (ACE_Auto_Basic_Array_Ptr & rhs); + ~ACE_Auto_Basic_Array_Ptr (void); + + // = Accessor methods. + X & operator* () const; + X & operator[] (int i) const; + X * get (void) const; + X * release (void); + void reset (X * p = 0); + + /// Dump the state of an object. + void dump (void) const; + + /// Declare the dynamic allocation hooks. + ACE_ALLOC_HOOK_DECLARE; + +protected: + X * p_; +}; + +/** + * @class ACE_Auto_Array_Ptr + * + * @brief Implements an extension to the draft C++ standard auto_ptr + * abstraction. + */ +template +class ACE_Auto_Array_Ptr : public ACE_Auto_Basic_Array_Ptr +{ +public: + typedef X element_type; + + // = Initialization and termination methods. + explicit ACE_Auto_Array_Ptr (X *p = 0) + : ACE_Auto_Basic_Array_Ptr (p) {} + + X *operator-> () const; +}; + + +/** + * @brief Reset given @c auto_ptr element to new element. + * + * Some platforms have an older version of auto_ptr support, which + * lacks reset, and cannot be disabled easily. Portability to these + * platforms requires use of this function template. This function + * template also works for the @c ACE_Auto_{Basic_}Array_Ptr class + * template, as well. + */ +template +inline void +ACE_auto_ptr_reset (AUTO_PTR_TYPE & ap, + PTR_TYPE * p) +{ +#if defined (ACE_AUTO_PTR_LACKS_RESET) + // Allow compiler to adjust pointer to potential base class pointer + // of element type found in auto_ptr. + typename AUTO_PTR_TYPE::element_type * const tp = p; + if (tp != ap.get ()) + { + ap = AUTO_PTR_TYPE (tp); + } +#else + ap.reset (p); +#endif /* ACE_AUTO_PTR_LACKS_RESET */ +} + +ACE_END_VERSIONED_NAMESPACE_DECL + +// Some platforms have an older version of auto_ptr +// support, which lacks reset, and cannot be disabled +// easily. Portability to these platforms requires +// use of the following ACE_AUTO_PTR_RESET macro. +// +// The TYPE macro parameter is no longer necessary but we leave it +// around for backward compatibility. This is also the reason why the +// ACE_auto_ptr_reset function template is not called +// ACE_AUTO_PTR_RESET. +# define ACE_AUTO_PTR_RESET(AUTOPTR,NEWPTR,TYPE) \ + ACE_auto_ptr_reset (AUTOPTR, NEWPTR); + +#if defined (__ACE_INLINE__) +#include "ace/Auto_Ptr.inl" +#endif /* __ACE_INLINE__ */ + +#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) +#include "ace/Auto_Ptr.cpp" +#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ + +#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) +#pragma implementation ("Auto_Ptr.cpp") +#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ + +#if defined (_MSC_VER) +// Restore the warning state to what it was before entry. +# pragma warning(pop) +#endif /* _MSC_VER */ + +#include /**/ "ace/post.h" +#endif /* ACE_AUTO_PTR_H */ diff --git a/dep/ACE_wrappers/ace/Auto_Ptr.inl b/dep/ACE_wrappers/ace/Auto_Ptr.inl new file mode 100644 index 00000000000..9ea47c3f208 --- /dev/null +++ b/dep/ACE_wrappers/ace/Auto_Ptr.inl @@ -0,0 +1,171 @@ +// -*- C++ -*- +// +// $Id: Auto_Ptr.inl 80826 2008-03-04 14:51:23Z wotte $ + +#include "ace/Global_Macros.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +template ACE_INLINE void +ACE_Auto_Basic_Ptr::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + ACE_TRACE ("ACE_Auto_Basic_Ptr::dump"); +#endif /* ACE_HAS_DUMP */ +} + +template ACE_INLINE void +ACE_Auto_Basic_Array_Ptr::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + ACE_TRACE ("ACE_Auto_Basic_Array_Ptr::dump"); +#endif /* ACE_HAS_DUMP */ +} + +template ACE_INLINE +ACE_Auto_Basic_Ptr::ACE_Auto_Basic_Ptr (ACE_Auto_Basic_Ptr &rhs) + : p_ (rhs.release ()) +{ + ACE_TRACE ("ACE_Auto_Basic_Ptr::ACE_Auto_Basic_Ptr"); +} + +template ACE_INLINE X * +ACE_Auto_Basic_Ptr::get (void) const +{ + ACE_TRACE ("ACE_Auto_Basic_Ptr::get"); + return this->p_; +} + +template ACE_INLINE X * +ACE_Auto_Basic_Ptr::release (void) +{ + ACE_TRACE ("ACE_Auto_Basic_Ptr::release"); + X *old = this->p_; + this->p_ = 0; + return old; +} + +template ACE_INLINE void +ACE_Auto_Basic_Ptr::reset (X *p) +{ + ACE_TRACE ("ACE_Auto_Basic_Ptr::reset"); + if (this->get () != p) + delete this->get (); + this->p_ = p; +} + +template ACE_INLINE ACE_Auto_Basic_Ptr & +ACE_Auto_Basic_Ptr::operator= (ACE_Auto_Basic_Ptr &rhs) +{ + ACE_TRACE ("ACE_Auto_Basic_Ptr::operator="); + if (this != &rhs) + { + this->reset (rhs.release ()); + } + return *this; +} + +template ACE_INLINE +ACE_Auto_Basic_Ptr::~ACE_Auto_Basic_Ptr (void) +{ + ACE_TRACE ("ACE_Auto_Basic_Ptr::~ACE_Auto_Basic_Ptr"); + delete this->get (); +} + +template ACE_INLINE X & +ACE_Auto_Basic_Ptr::operator *() const +{ + ACE_TRACE ("ACE_Auto_Basic_Ptr::operator *()"); + return *this->get (); +} + +#if defined (ACE_LACKS_AUTO_PTR) || \ + !defined (ACE_HAS_STANDARD_CPP_LIBRARY) || \ + (ACE_HAS_STANDARD_CPP_LIBRARY == 0) + +template ACE_INLINE X * +auto_ptr::operator-> () const +{ + ACE_TRACE ("auto_ptr::operator->"); + return this->get (); +} + +#endif /* ACE_HAS_STANDARD_CPP_LIBRARY */ + +template ACE_INLINE X * +ACE_Auto_Ptr::operator-> () const +{ + ACE_TRACE ("ACE_Auto_Ptr::operator->"); + return this->get (); +} + +template ACE_INLINE X * +ACE_Auto_Basic_Array_Ptr::get (void) const +{ + ACE_TRACE ("ACE_Auto_Basic_Array_Ptr::get"); + return this->p_; +} + +template ACE_INLINE X * +ACE_Auto_Basic_Array_Ptr::release (void) +{ + ACE_TRACE ("ACE_Auto_Basic_Array_Ptr::release"); + X *old = this->p_; + this->p_ = 0; + return old; +} + +template ACE_INLINE void +ACE_Auto_Basic_Array_Ptr::reset (X *p) +{ + ACE_TRACE ("ACE_Auto_Basic_Array_Ptr::reset"); + if (this->get () != p) + delete [] this->get (); + this->p_ = p; +} + +template ACE_INLINE +ACE_Auto_Basic_Array_Ptr::ACE_Auto_Basic_Array_Ptr (ACE_Auto_Basic_Array_Ptr &rhs) + : p_ (rhs.release ()) +{ + ACE_TRACE ("ACE_Auto_Basic_Array_Ptr::ACE_Auto_Basic_Array_Ptr"); +} + +template ACE_INLINE ACE_Auto_Basic_Array_Ptr & +ACE_Auto_Basic_Array_Ptr::operator= (ACE_Auto_Basic_Array_Ptr &rhs) +{ + ACE_TRACE ("ACE_Auto_Basic_Array_Ptr::operator="); + if (this != &rhs) + { + this->reset (rhs.release ()); + } + return *this; +} + +template ACE_INLINE +ACE_Auto_Basic_Array_Ptr::~ACE_Auto_Basic_Array_Ptr (void) +{ + ACE_TRACE ("ACE_Auto_Basic_Array_Ptr::~ACE_Auto_Basic_Array_Ptr"); + delete [] this->get (); +} + +template ACE_INLINE X & +ACE_Auto_Basic_Array_Ptr::operator *() const +{ + return *this->get (); +} + +template ACE_INLINE X & +ACE_Auto_Basic_Array_Ptr::operator[](int i) const +{ + X *array = this->get (); + return array[i]; +} + +template ACE_INLINE X * +ACE_Auto_Array_Ptr::operator->() const +{ + return this->get (); +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Barrier.cpp b/dep/ACE_wrappers/ace/Barrier.cpp new file mode 100644 index 00000000000..f3f4454b724 --- /dev/null +++ b/dep/ACE_wrappers/ace/Barrier.cpp @@ -0,0 +1,197 @@ +// $Id: Barrier.cpp 80826 2008-03-04 14:51:23Z wotte $ + +#include "ace/Barrier.h" + +#if defined (ACE_HAS_THREADS) + +#if !defined (__ACE_INLINE__) +#include "ace/Barrier.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/Guard_T.h" +#include "ace/OS_NS_errno.h" + +#if defined (ACE_HAS_DUMP) +# include "ace/Log_Msg.h" +#endif /* ACE_HAS_DUMP */ + +ACE_RCSID (ace, + Barrier, + "$Id: Barrier.cpp 80826 2008-03-04 14:51:23Z wotte $") + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_ALLOC_HOOK_DEFINE(ACE_Sub_Barrier) + +void +ACE_Sub_Barrier::dump (void) const +{ +#if defined (ACE_HAS_DUMP) +// ACE_TRACE ("ACE_Sub_Barrier::dump"); + + ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); + this->barrier_finished_.dump (); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("running_threads_ = %d"), this->running_threads_)); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\n"))); + ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); +#endif /* ACE_HAS_DUMP */ +} + +ACE_Sub_Barrier::ACE_Sub_Barrier (unsigned int count, + ACE_Thread_Mutex &lock, + const ACE_TCHAR *name, + void *arg) + : barrier_finished_ (lock, name, arg), + running_threads_ (count) +{ +// ACE_TRACE ("ACE_Sub_Barrier::ACE_Sub_Barrier"); +} + +ACE_ALLOC_HOOK_DEFINE(ACE_Barrier) + +void +ACE_Barrier::dump (void) const +{ +#if defined (ACE_HAS_DUMP) +// ACE_TRACE ("ACE_Barrier::dump"); + + ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); + this->lock_.dump (); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("current_generation_ = %d"), this->current_generation_)); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\ncount_ = %d"), this->count_)); + this->sub_barrier_1_.dump (); + this->sub_barrier_2_.dump (); + ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); +#endif /* ACE_HAS_DUMP */ +} + +ACE_Barrier::ACE_Barrier (unsigned int count, + const ACE_TCHAR *name, + void *arg) + : lock_ (name, (ACE_mutexattr_t *) arg), + current_generation_ (0), + count_ (count), + sub_barrier_1_ (count, lock_, name, arg), + sub_barrier_2_ (count, lock_, name, arg) +{ + ACE_TRACE ("ACE_Barrier::ACE_Barrier"); + this->sub_barrier_[0] = &this->sub_barrier_1_; + this->sub_barrier_[1] = &this->sub_barrier_2_; +} + +int +ACE_Barrier::wait (void) +{ + ACE_TRACE ("ACE_Barrier::wait"); + ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1); + + ACE_Sub_Barrier *sbp = + this->sub_barrier_[this->current_generation_]; + + // Check for shutdown... + if (sbp == 0) + { + errno = ESHUTDOWN; + return -1; + } + + int retval = 0; + + if (sbp->running_threads_ == 1) + { + // We're the last running thread, so swap generations and tell + // all the threads waiting on the barrier to continue on their + // way. + sbp->running_threads_ = this->count_; + // Swap generations. + this->current_generation_ = 1 - this->current_generation_; + sbp->barrier_finished_.broadcast (); + } + else + { + --sbp->running_threads_; + + // Block until all the other threads wait(). + while (sbp->running_threads_ != this->count_) + sbp->barrier_finished_.wait (); + + // We're awake and the count has completed. See if it completed + // because all threads hit the barrier, or because the barrier + // was shut down. + if (this->sub_barrier_[this->current_generation_] == 0) + { + errno = ESHUTDOWN; + retval = -1; + } + } + + return retval; +} + +int +ACE_Barrier::shutdown (void) +{ + ACE_TRACE ("ACE_Barrier::shutdown"); + ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1); + + ACE_Sub_Barrier *sbp = + this->sub_barrier_[this->current_generation_]; + + // Check for shutdown... + if (sbp == 0) + { + errno = ESHUTDOWN; + return -1; + } + + // Flag the shutdown + this->sub_barrier_[0] = 0; + this->sub_barrier_[1] = 0; + // Tell all the threads waiting on the barrier to continue on their way. + sbp->running_threads_ = this->count_; + sbp->barrier_finished_.broadcast (); + + return 0; +} + +ACE_ALLOC_HOOK_DEFINE(ACE_Thread_Barrier) + +ACE_Thread_Barrier::ACE_Thread_Barrier (unsigned int count, + const ACE_TCHAR *name) + : ACE_Barrier (count, name) +{ +// ACE_TRACE ("ACE_Thread_Barrier::ACE_Thread_Barrier"); +} + +void +ACE_Thread_Barrier::dump (void) const +{ +#if defined (ACE_HAS_DUMP) +// ACE_TRACE ("ACE_Thread_Barrier::dump"); + ACE_Barrier::dump (); +#endif /* ACE_HAS_DUMP */ +} + +#if 0 +ACE_ALLOC_HOOK_DEFINE(ACE_Process_Barrier) + +ACE_Process_Barrier::ACE_Process_Barrier (u_int count, + const ACE_TCHAR *name) + : ACE_Barrier (count, USYNC_PROCESS, name) +{ +// ACE_TRACE ("ACE_Process_Barrier::ACE_Process_Barrier"); +} + +void +ACE_Process_Barrier::dump (void) const +{ +#if defined (ACE_HAS_DUMP) +// ACE_TRACE ("ACE_Process_Barrier::dump"); + ACE_Barrier::dump (); +#endif /* ACE_HAS_DUMP */ +} +#endif /* 0 */ + +ACE_END_VERSIONED_NAMESPACE_DECL + +#endif /* ACE_HAS_THREADS */ diff --git a/dep/ACE_wrappers/ace/Barrier.h b/dep/ACE_wrappers/ace/Barrier.h new file mode 100644 index 00000000000..189ff07e4cc --- /dev/null +++ b/dep/ACE_wrappers/ace/Barrier.h @@ -0,0 +1,215 @@ +// -*- C++ -*- + +//========================================================================== +/** + * @file Barrier.h + * + * $Id: Barrier.h 80826 2008-03-04 14:51:23Z wotte $ + * + * Moved from Synch.h. + * + * @author Douglas C. Schmidt + */ +//========================================================================== + +#ifndef ACE_BARRIER_H +#define ACE_BARRIER_H +#include /**/ "ace/pre.h" + +#include /**/ "ace/ACE_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include /**/ "ace/config-all.h" + +// ACE platform supports some form of threading. +#if !defined (ACE_HAS_THREADS) + +#include "ace/OS_NS_errno.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +/** + * @class ACE_Barrier + * + * @brief This is a no-op to make ACE "syntactically consistent." + */ +class ACE_Export ACE_Barrier +{ +public: + ACE_Barrier (unsigned int, const ACE_TCHAR * = 0, void * = 0) {} + ~ACE_Barrier (void) {} + int wait (void) { ACE_NOTSUP_RETURN (-1); } + void dump (void) const {} +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#else /* ACE_HAS_THREADS */ + +#include "ace/Condition_Thread_Mutex.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +struct ACE_Export ACE_Sub_Barrier +{ + // = Initialization. + ACE_Sub_Barrier (unsigned int count, + ACE_Thread_Mutex &lock, + const ACE_TCHAR *name = 0, + void *arg = 0); + + ~ACE_Sub_Barrier (void); + + /// True if this generation of the barrier is done. + ACE_Condition_Thread_Mutex barrier_finished_; + + /// Number of threads that are still running. + int running_threads_; + + /// Dump the state of an object. + void dump (void) const; + + /// Declare the dynamic allocation hooks. + ACE_ALLOC_HOOK_DECLARE; +}; + +/** + * @class ACE_Barrier + * + * @brief Implements "barrier synchronization". + * + * This class allows number of threads to synchronize + * their completion of (one round of) a task, which is known as + * "barrier synchronization". After all the threads call + * on the barrier they are all atomically released and can begin a new + * round. + * + * This implementation uses a "sub-barrier generation numbering" + * scheme to avoid overhead and to ensure that all threads wait to + * leave the barrier correct. This code is based on an article from + * SunOpsis Vol. 4, No. 1 by Richard Marejka + * (Richard.Marejka@canada.sun.com). + */ +class ACE_Export ACE_Barrier +{ +public: + /// Initialize the barrier to synchronize @a count threads. + ACE_Barrier (unsigned int count, + const ACE_TCHAR *name = 0, + void *arg = 0); + + /// Default dtor. + ~ACE_Barrier (void); + + /// Block the caller until all @c count threads have called @c wait and + /// then allow all the caller threads to continue in parallel. + /// + /// @retval 0 after successfully waiting for all threads to wait. + /// @retval -1 if an error occurs or the barrier is shut + /// down (@sa shutdown ()). + int wait (void); + + /// Shut the barrier down, aborting the wait of all waiting threads. + /// Any threads waiting on the barrier when it is shut down will return with + /// value -1, errno ESHUTDOWN. + /// + /// @retval 0 for success, -1 if already shut down. + /// + /// @since ACE beta 5.4.9. + int shutdown (void); + + /// Dump the state of an object. + void dump (void) const; + + /// Declare the dynamic allocation hooks. + ACE_ALLOC_HOOK_DECLARE; + +protected: + /// Serialize access to the barrier state. + ACE_Thread_Mutex lock_; + + /// Either 0 or 1, depending on whether we are the first generation + /// of waiters or the next generation of waiters. + int current_generation_; + + /// Total number of threads that can be waiting at any one time. + int count_; + + /** + * We keep two @c sub_barriers, one for the first "generation" of + * waiters, and one for the next "generation" of waiters. This + * efficiently solves the problem of what to do if all the first + * generation waiters don't leave the barrier before one of the + * threads calls wait() again (i.e., starts up the next generation + * barrier). + */ + ACE_Sub_Barrier sub_barrier_1_; + ACE_Sub_Barrier sub_barrier_2_; + ACE_Sub_Barrier *sub_barrier_[2]; + +private: + // = Prevent assignment and initialization. + void operator= (const ACE_Barrier &); + ACE_Barrier (const ACE_Barrier &); +}; + +#if 0 +/** + * @class ACE_Process_Barrier + * + * @brief Implements "barrier synchronization" using ACE_Process_Mutexes! + * + * This class is just a simple wrapper for ACE_Barrier that + * selects the USYNC_PROCESS variant for the locks. + */ +class ACE_Export ACE_Process_Barrier : public ACE_Barrier +{ +public: + /// Create a Process_Barrier, passing in the optional @a name. + ACE_Process_Barrier (unsigned int count, const ACE_TCHAR *name = 0); + + /// Dump the state of an object. + void dump (void) const; + + /// Declare the dynamic allocation hooks. + ACE_ALLOC_HOOK_DECLARE; +}; +#endif /* 0 */ + +/** + * @class ACE_Thread_Barrier + * + * @brief Implements "barrier synchronization" using ACE_Thread_Mutexes! + * + * This class is just a simple wrapper for ACE_Barrier that + * selects the USYNC_THREAD variant for the locks. + */ +class ACE_Export ACE_Thread_Barrier : public ACE_Barrier +{ +public: + /// Create a Thread_Barrier, passing in the optional @a name. + ACE_Thread_Barrier (unsigned int count, const ACE_TCHAR *name = 0); + + /// Default dtor. + ~ACE_Thread_Barrier (void); + + /// Dump the state of an object. + void dump (void) const; + + /// Declare the dynamic allocation hooks. + ACE_ALLOC_HOOK_DECLARE; +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +#include "ace/Barrier.inl" +#endif /* __ACE_INLINE__ */ + +#endif /* !ACE_HAS_THREADS */ + +#include /**/ "ace/post.h" +#endif /* ACE_BARRIER_H */ diff --git a/dep/ACE_wrappers/ace/Barrier.inl b/dep/ACE_wrappers/ace/Barrier.inl new file mode 100644 index 00000000000..10430d917a3 --- /dev/null +++ b/dep/ACE_wrappers/ace/Barrier.inl @@ -0,0 +1,22 @@ +// -*- C++ -*- +// +// $Id: Barrier.inl 80826 2008-03-04 14:51:23Z wotte $ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_INLINE +ACE_Sub_Barrier::~ACE_Sub_Barrier (void) +{ +} + +ACE_INLINE +ACE_Barrier::~ACE_Barrier (void) +{ +} + +ACE_INLINE +ACE_Thread_Barrier::~ACE_Thread_Barrier (void) +{ +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Base_Thread_Adapter.cpp b/dep/ACE_wrappers/ace/Base_Thread_Adapter.cpp new file mode 100644 index 00000000000..94386ee1df7 --- /dev/null +++ b/dep/ACE_wrappers/ace/Base_Thread_Adapter.cpp @@ -0,0 +1,128 @@ +// $Id: Base_Thread_Adapter.cpp 81239 2008-04-04 22:28:48Z iliyan $ + +#include "ace/Base_Thread_Adapter.h" + +ACE_RCSID (ace, + Base_Thread_Adapter, + "$Id: Base_Thread_Adapter.cpp 81239 2008-04-04 22:28:48Z iliyan $") + +#if !defined (ACE_HAS_INLINED_OSCALLS) +# include "ace/Base_Thread_Adapter.inl" +#endif /* ACE_HAS_INLINED_OSCALLS */ + +#if defined (ACE_HAS_TSS_EMULATION) +# include "ace/OS_NS_Thread.h" +#endif /* ACE_HAS_TSS_EMULATION */ + +#include "ace/Service_Config.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_INIT_LOG_MSG_HOOK ACE_Base_Thread_Adapter::init_log_msg_hook_ = 0; +ACE_INHERIT_LOG_MSG_HOOK ACE_Base_Thread_Adapter::inherit_log_msg_hook_ = 0; +ACE_CLOSE_LOG_MSG_HOOK ACE_Base_Thread_Adapter::close_log_msg_hook_ = 0; +ACE_SYNC_LOG_MSG_HOOK ACE_Base_Thread_Adapter::sync_log_msg_hook_ = 0; +ACE_THR_DESC_LOG_MSG_HOOK ACE_Base_Thread_Adapter::thr_desc_log_msg_hook_ = 0; + +ACE_Base_Thread_Adapter::ACE_Base_Thread_Adapter ( + ACE_THR_FUNC user_func, + void *arg, + ACE_THR_C_FUNC entry_point, + ACE_OS_Thread_Descriptor *td +#if defined (ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS) + , ACE_SEH_EXCEPT_HANDLER selector + , ACE_SEH_EXCEPT_HANDLER handler +#endif /* ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS */ + ) + : user_func_ (user_func) + , arg_ (arg) + , entry_point_ (entry_point) + , thr_desc_ (td) + , ctx_ (ACE_Service_Config::current()) +{ + ACE_OS_TRACE ("ACE_Base_Thread_Adapter::ACE_Base_Thread_Adapter"); + + if (ACE_Base_Thread_Adapter::init_log_msg_hook_ != 0) + (*ACE_Base_Thread_Adapter::init_log_msg_hook_) ( + this->log_msg_attributes_ +# if defined (ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS) + , selector + , handler +# endif /* ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS */ + ); +#ifdef ACE_USES_GPROF + getitimer (ITIMER_PROF, &itimer_); +#endif // ACE_USES_GPROF +} + +ACE_Base_Thread_Adapter::~ACE_Base_Thread_Adapter (void) +{ +} + +void +ACE_Base_Thread_Adapter::inherit_log_msg (void) +{ + if (ACE_Base_Thread_Adapter::inherit_log_msg_hook_ != 0) + (*ACE_Base_Thread_Adapter::inherit_log_msg_hook_)( + this->thr_desc_, + this->log_msg_attributes_); + + // Initialize the proper configuration context for the new thread + // Placed here since inherit_log_msg() gets called from any of our + // descendants (before self-destructing) + ACE_Service_Config::current (this->ctx_); +} + +void +ACE_Base_Thread_Adapter::close_log_msg (void) +{ + if (ACE_Base_Thread_Adapter::close_log_msg_hook_ != 0) + (*ACE_Base_Thread_Adapter::close_log_msg_hook_) (); +} + +void +ACE_Base_Thread_Adapter::sync_log_msg (const ACE_TCHAR *prg) +{ + if (ACE_Base_Thread_Adapter::sync_log_msg_hook_ != 0) + (*ACE_Base_Thread_Adapter::sync_log_msg_hook_) (prg); +} + +ACE_OS_Thread_Descriptor * +ACE_Base_Thread_Adapter::thr_desc_log_msg (void) +{ + if (ACE_Base_Thread_Adapter::thr_desc_log_msg_hook_ != 0) + return (*ACE_Base_Thread_Adapter::thr_desc_log_msg_hook_) (); + return 0; +} + +ACE_END_VERSIONED_NAMESPACE_DECL + +// Run the thread entry point for the . This must +// be an extern "C" to make certain compilers happy... + +extern "C" ACE_THR_FUNC_RETURN +ACE_THREAD_ADAPTER_NAME (void *args) +{ + ACE_OS_TRACE ("ACE_THREAD_ADAPTER_NAME"); + +#if defined (ACE_HAS_TSS_EMULATION) + // As early as we can in the execution of the new thread, allocate + // its local TS storage. Allocate it on the stack, to save dynamic + // allocation/dealloction. + void *ts_storage[ACE_TSS_Emulation::ACE_TSS_THREAD_KEYS_MAX]; + ACE_TSS_Emulation::tss_open (ts_storage); +#endif /* ACE_HAS_TSS_EMULATION */ + + ACE_Base_Thread_Adapter * const thread_args = + static_cast (args); + +#ifdef ACE_USES_GPROF + setitimer (ITIMER_PROF, thread_args->timerval (), 0); +#endif // ACE_USES_GPROF + + // Invoke the user-supplied function with the args. + ACE_THR_FUNC_RETURN status = thread_args->invoke (); + + return status; +} + diff --git a/dep/ACE_wrappers/ace/Base_Thread_Adapter.h b/dep/ACE_wrappers/ace/Base_Thread_Adapter.h new file mode 100644 index 00000000000..b36d18e4f13 --- /dev/null +++ b/dep/ACE_wrappers/ace/Base_Thread_Adapter.h @@ -0,0 +1,195 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Base_Thread_Adapter.h + * + * $Id: Base_Thread_Adapter.h 81239 2008-04-04 22:28:48Z iliyan $ + * + * @author Nanbor Wang + */ +//============================================================================= + +#ifndef ACE_BASE_THREAD_ADAPTER_H +#define ACE_BASE_THREAD_ADAPTER_H +#include /**/ "ace/pre.h" + +#include "ace/OS_Log_Msg_Attributes.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include /**/ "ace/ACE_export.h" +#include "ace/OS_Log_Msg_Attributes.h" + +#ifdef ACE_USES_GPROF +#include "os_include/sys/os_time.h" +#endif // ACE_USES_GPROF + +#if (defined (ACE_HAS_VERSIONED_NAMESPACE) && ACE_HAS_VERSIONED_NAMESPACE == 1) +# define ACE_THREAD_ADAPTER_NAME ACE_PREPROC_CONCATENATE(ACE_VERSIONED_NAMESPACE_NAME, _ace_thread_adapter) +#else +# define ACE_THREAD_ADAPTER_NAME ace_thread_adapter +#endif /* ACE_HAS_VERSIONED_NAMESPACE == 1 */ + +// Run the thread entry point for the ACE_Thread_Adapter. This must +// be an extern "C" to make certain compilers happy... + +extern "C" ACE_Export ACE_THR_FUNC_RETURN ACE_THREAD_ADAPTER_NAME (void *args); + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +/** + * @class ACE_OS_Thread_Descriptor + * + * @brief Parent class of all ACE_Thread_Descriptor classes. + * = + * Container for ACE_Thread_Descriptor members that are + * used in ACE_OS. + */ +class ACE_Export ACE_OS_Thread_Descriptor +{ +public: + /// Get the thread creation flags. + long flags (void) const; + +protected: + /// For use by ACE_Thread_Descriptor. + ACE_OS_Thread_Descriptor (long flags = 0); + + /** + * Keeps track of whether this thread was created "detached" or not. + * If a thread is *not* created detached then if someone calls + * , we need to join with that thread (and + * close down the handle). + */ + long flags_; +}; + + + +class ACE_Service_Gestalt; + + +/** + * @class ACE_Base_Thread_Adapter + * + * @brief Base class for all the Thread_Adapters. + * + * Converts a C++ function into a function that can be + * called from a thread creation routine + * (e.g., pthread_create() or _beginthreadex()) that expects an + * extern "C" entry point. This class also makes it possible to + * transparently provide hooks to register a thread with an + * ACE_Thread_Manager. + * This class is used in ACE_OS::thr_create(). In general, the + * thread that creates an object of this class is different from + * the thread that calls @c invoke() on this object. Therefore, + * the @c invoke() method is responsible for deleting itself. + */ +class ACE_Export ACE_Base_Thread_Adapter +{ +public: + + virtual ~ACE_Base_Thread_Adapter (void); + + /// Virtual method invoked by the thread entry point. + virtual ACE_THR_FUNC_RETURN invoke (void) = 0; + + /// Accessor for the C entry point function to the OS thread creation + /// routine. + ACE_THR_C_FUNC entry_point (void); + +#ifdef ACE_USES_GPROF + /// Accessor to the itimer_ + /// followed http://sam.zoy.org/writings/programming/gprof.html + struct itimerval* timerval (void); +#endif // ACE_USES_PROF + + /// Invoke the close_log_msg_hook, if it is present + static void close_log_msg (void); + + /// Invoke the sync_log_msg_hook, if it is present + static void sync_log_msg (const ACE_TCHAR *prog_name); + + /// Invoke the thr_desc_log_msg_hook, if it is present + static ACE_OS_Thread_Descriptor *thr_desc_log_msg (void); + +protected: + /// Constructor. + ACE_Base_Thread_Adapter (ACE_THR_FUNC user_func, + void *arg, + ACE_THR_C_FUNC entry_point = (ACE_THR_C_FUNC) ACE_THREAD_ADAPTER_NAME, + ACE_OS_Thread_Descriptor *td = 0 +# if defined (ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS) + , ACE_SEH_EXCEPT_HANDLER selector = 0 + , ACE_SEH_EXCEPT_HANDLER handler = 0 +# endif /* ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS */ + ); + /// Inherit the logging features if the parent thread has an + /// ACE_Log_Msg. + void inherit_log_msg (void); + +private: + /// The hooks to inherit and cleanup the Log_Msg attributes + static ACE_INIT_LOG_MSG_HOOK init_log_msg_hook_; + static ACE_INHERIT_LOG_MSG_HOOK inherit_log_msg_hook_; + static ACE_CLOSE_LOG_MSG_HOOK close_log_msg_hook_; + static ACE_SYNC_LOG_MSG_HOOK sync_log_msg_hook_; + static ACE_THR_DESC_LOG_MSG_HOOK thr_desc_log_msg_hook_; + + /// Set the Log_Msg hooks + static void set_log_msg_hooks (ACE_INIT_LOG_MSG_HOOK init_hook, + ACE_INHERIT_LOG_MSG_HOOK inherit_hook, + ACE_CLOSE_LOG_MSG_HOOK close_hook, + ACE_SYNC_LOG_MSG_HOOK sync_hook, + ACE_THR_DESC_LOG_MSG_HOOK thr_desc); + + /// Allow the ACE_Log_Msg class to set its hooks. + friend class ACE_Log_Msg; + +protected: + /// Thread startup function passed in by the user (C++ linkage). + ACE_THR_FUNC user_func_; + + /// Argument to thread startup function. + void *arg_; + + /// Entry point to the underlying OS thread creation call (C + /// linkage). + ACE_THR_C_FUNC entry_point_; + + /** + * Optional thread descriptor. Passing this pointer in will force + * the spawned thread to cache this location in and wait + * until fills in all information in thread + * descriptor. + */ + ACE_OS_Thread_Descriptor *thr_desc_; + + /// The ACE_Log_Msg attributes. + ACE_OS_Log_Msg_Attributes log_msg_attributes_; + + /// That is usefull for gprof, define itimerval +#ifdef ACE_USES_GPROF + struct itimerval itimer_; +#endif // ACE_USES_GPROF + + /// Keep a reference to the configuration context that spawns the + /// thread so the child can inherit it. + ACE_Service_Gestalt * const ctx_; +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +# if defined (ACE_HAS_INLINED_OSCALLS) +# if defined (ACE_INLINE) +# undef ACE_INLINE +# endif /* ACE_INLINE */ +# define ACE_INLINE inline +# include "ace/Base_Thread_Adapter.inl" +# endif /* ACE_HAS_INLINED_OSCALLS */ + +#include /**/ "ace/post.h" +#endif /* ACE_BASE_THREAD_ADAPTER_H */ diff --git a/dep/ACE_wrappers/ace/Base_Thread_Adapter.inl b/dep/ACE_wrappers/ace/Base_Thread_Adapter.inl new file mode 100644 index 00000000000..3bac80246dd --- /dev/null +++ b/dep/ACE_wrappers/ace/Base_Thread_Adapter.inl @@ -0,0 +1,48 @@ +// -*- C++ -*- +// +// $Id: Base_Thread_Adapter.inl 80826 2008-03-04 14:51:23Z wotte $ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_INLINE long +ACE_OS_Thread_Descriptor::flags (void) const +{ + return flags_; +} + +ACE_INLINE +ACE_OS_Thread_Descriptor::ACE_OS_Thread_Descriptor (long flags) + : flags_ (flags) +{ +} + +ACE_INLINE void +ACE_Base_Thread_Adapter::set_log_msg_hooks ( + ACE_INIT_LOG_MSG_HOOK init_hook, + ACE_INHERIT_LOG_MSG_HOOK inherit_hook, + ACE_CLOSE_LOG_MSG_HOOK close_hook, + ACE_SYNC_LOG_MSG_HOOK sync_hook, + ACE_THR_DESC_LOG_MSG_HOOK thr_desc_hook) +{ + ACE_Base_Thread_Adapter::init_log_msg_hook_ = init_hook; + ACE_Base_Thread_Adapter::inherit_log_msg_hook_ = inherit_hook; + ACE_Base_Thread_Adapter::close_log_msg_hook_ = close_hook; + ACE_Base_Thread_Adapter::sync_log_msg_hook_ = sync_hook; + ACE_Base_Thread_Adapter::thr_desc_log_msg_hook_ = thr_desc_hook; +} + +ACE_INLINE ACE_THR_C_FUNC +ACE_Base_Thread_Adapter::entry_point (void) +{ + return this->entry_point_; +} + +#ifdef ACE_USES_GPROF +ACE_INLINE itimerval* +ACE_Base_Thread_Adapter::timerval (void) +{ + return &(this->itimer_); +} +#endif // ACE_USES_GPROF + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Based_Pointer_Repository.cpp b/dep/ACE_wrappers/ace/Based_Pointer_Repository.cpp new file mode 100644 index 00000000000..4ebe8b82c7a --- /dev/null +++ b/dep/ACE_wrappers/ace/Based_Pointer_Repository.cpp @@ -0,0 +1,119 @@ +// $Id: Based_Pointer_Repository.cpp 80826 2008-03-04 14:51:23Z wotte $ + +#include "ace/Map_Manager.h" +#include "ace/Based_Pointer_Repository.h" +#include "ace/Guard_T.h" +#include "ace/Null_Mutex.h" +#include "ace/Synch_Traits.h" +#include "ace/RW_Thread_Mutex.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +/** + * @class ACE_Based_Pointer_Repository_Rep + * + * @brief Implementation for the ACE_Based_Pointer_Repository. + * + * Every memory pool in ACE binds it's mapping base address and + * the mapped size to this repository every time it maps/remaps a + * new chunk of memory successfully. + */ +class ACE_Based_Pointer_Repository_Rep +{ +public: + // Useful typedefs. + typedef ACE_Map_Manager MAP_MANAGER; + typedef ACE_Map_Iterator MAP_ITERATOR; + typedef ACE_Map_Entry MAP_ENTRY; + + /// Keeps track of the mapping between addresses and their associated + /// values. + MAP_MANAGER addr_map_; + + /// Synchronize concurrent access to the map. + ACE_SYNCH_MUTEX lock_; +}; + +ACE_Based_Pointer_Repository::ACE_Based_Pointer_Repository (void) +{ + ACE_TRACE ("ACE_Based_Pointer_Repository::ACE_Based_Pointer_Repository"); + ACE_NEW (this->rep_, + ACE_Based_Pointer_Repository_Rep); +} + +ACE_Based_Pointer_Repository::~ACE_Based_Pointer_Repository (void) +{ + ACE_TRACE ("ACE_Based_Pointer_Repository::~ACE_Based_Pointer_Repository"); + delete this->rep_; +} + +// Search for appropriate base address in repository + +int +ACE_Based_Pointer_Repository::find (void *addr, void *&base_addr) +{ + ACE_TRACE ("ACE_Based_Pointer_Repository::find"); + ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, mon, this->rep_->lock_, -1); + ACE_Based_Pointer_Repository_Rep::MAP_ENTRY *ce = 0; + + for (ACE_Based_Pointer_Repository_Rep::MAP_ITERATOR iter (this->rep_->addr_map_); + iter.next (ce) != 0; + iter.advance ()) + // Check to see if is within any of the regions. + if (addr >= ce->ext_id_ + && addr < ((char *)ce->ext_id_ + ce->int_id_)) + { + // Assign the base address. + base_addr = ce->ext_id_; + return 1; + } + + // Assume base address 0 (e.g., if new'ed). + base_addr = 0; + return 0; +} + +// Bind a new entry to the repository or update the size of an +// existing entry. + +int +ACE_Based_Pointer_Repository::bind (void *addr, size_t size) +{ + ACE_TRACE ("ACE_Based_Pointer_Repository::bind"); + ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, mon, this->rep_->lock_, -1); + + return this->rep_->addr_map_.rebind (addr, size); +} + +// Unbind a base from the repository. + +int +ACE_Based_Pointer_Repository::unbind (void *addr) +{ + ACE_TRACE ("ACE_Based_Pointer_Repository::unbind"); + ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, mon, this->rep_->lock_, -1); + ACE_Based_Pointer_Repository_Rep::MAP_ENTRY *ce = 0; + + // Search for service handlers that requested notification. + + for (ACE_Based_Pointer_Repository_Rep::MAP_ITERATOR iter (this->rep_->addr_map_); + iter.next (ce) != 0; + iter.advance ()) + { + // Check to see if is within any of the regions and if + // so, unbind the key from the map. + if (addr >= ce->ext_id_ + && addr < ((char *)ce->ext_id_ + ce->int_id_)) + // Unbind base address. + return this->rep_->addr_map_.unbind (ce->ext_id_); + } + + return 0; +} + +#if defined (ACE_HAS_EXPLICIT_STATIC_TEMPLATE_MEMBER_INSTANTIATION) +template ACE_Singleton * + ACE_Singleton::singleton_; +#endif /* ACE_HAS_EXPLICIT_STATIC_TEMPLATE_MEMBER_INSTANTIATION */ + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Based_Pointer_Repository.h b/dep/ACE_wrappers/ace/Based_Pointer_Repository.h new file mode 100644 index 00000000000..f674a8de78d --- /dev/null +++ b/dep/ACE_wrappers/ace/Based_Pointer_Repository.h @@ -0,0 +1,91 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Based_Pointer_Repository.h + * + * $Id: Based_Pointer_Repository.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Dietrich Quehl + * @author Douglas C. Schmidt + */ +//============================================================================= + +#ifndef ACE_BASED_POINTER_REPOSITORY_H +#define ACE_BASED_POINTER_REPOSITORY_H + +#include /**/ "ace/pre.h" + +#include /**/ "ace/ACE_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/Singleton.h" +#include "ace/Synch_Traits.h" +#include "ace/os_include/os_stddef.h" + + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +// Forward decl., using the "Cheshire Cat" technique. +class ACE_Based_Pointer_Repository_Rep; + +/** + * @class ACE_Based_Pointer_Repository + * + * @brief Maps pointers to the base address of the region to which each + * pointer belongs. + */ +class ACE_Export ACE_Based_Pointer_Repository +{ +public: + // = Use ACE_Null_Mutex to allow locking while iterating. + + // = Initialization and termination methods. + ACE_Based_Pointer_Repository (void); + ~ACE_Based_Pointer_Repository (void); + + // = Search structure methods. + /** + * Return the appropriate @a base_addr region that contains @a addr. + * Returns 1 on success and 0 if the @a addr isn't contained in any + * @a base_addr region. + */ + int find (void *addr, + void *&base_addr); + + /// Bind a new entry to the repository or update the size of an + /// existing entry. Returns 0 on success and -1 on failure. + int bind (void *addr, + size_t size); + + /// Unbind from the repository the that @a addr is + /// contained within. + int unbind (void *addr); + +private: + + /// Use the "Cheshire-Cat" technique to hide the implementation in + /// order to avoid circular #include dependencies. + ACE_Based_Pointer_Repository_Rep *rep_; + +}; + +// ---------------------------------- + +/// Declare a process wide singleton +ACE_SINGLETON_DECLARE (ACE_Singleton, + ACE_Based_Pointer_Repository, + ACE_SYNCH_RW_MUTEX) + +/// Provide a Singleton access point to the based pointer repository. +typedef ACE_Singleton + ACE_BASED_POINTER_REPOSITORY; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#include /**/ "ace/post.h" + +#endif /* ACE_BASED_POINTER_REPOSITORY_H */ diff --git a/dep/ACE_wrappers/ace/Based_Pointer_T.cpp b/dep/ACE_wrappers/ace/Based_Pointer_T.cpp new file mode 100644 index 00000000000..b85774db48d --- /dev/null +++ b/dep/ACE_wrappers/ace/Based_Pointer_T.cpp @@ -0,0 +1,121 @@ +// $Id: Based_Pointer_T.cpp 80826 2008-03-04 14:51:23Z wotte $ + +#ifndef ACE_BASED_POINTER_T_CPP +#define ACE_BASED_POINTER_T_CPP + +#include "ace/Based_Pointer_T.h" +#include "ace/Based_Pointer_Repository.h" +#include "ace/Log_Msg.h" + +# define ACE_TRACEX(X) ACE_Trace ____ (ACE_TEXT (X), __LINE__, ACE_TEXT (__FILE__)) + +#if !defined (__ACE_INLINE__) +#include "ace/Based_Pointer_T.inl" +#endif /* __ACE_INLINE__ */ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +template +ACE_Based_Pointer::ACE_Based_Pointer (void) +{ + ACE_TRACE ("ACE_Based_Pointer::ACE_Based_Pointer"); +} + +template void +ACE_Based_Pointer_Basic::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + ACE_TRACE ("ACE_Based_Pointer_Basic::dump"); + + ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\ntarget_ = %d\n"), this->target_)); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("base_offset_ = %d\n"), this->base_offset_)); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("computed pointer = %x\n"), + (CONCRETE *)(ACE_COMPUTE_BASED_POINTER (this)))); + ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); +#endif /* ACE_HAS_DUMP */ +} + +template +ACE_Based_Pointer::ACE_Based_Pointer (CONCRETE *initial) + : ACE_Based_Pointer_Basic (initial) +{ + ACE_TRACE ("ACE_Based_Pointer_Basic::ACE_Based_Pointer_Basic"); +} + +template +ACE_Based_Pointer::ACE_Based_Pointer (const void* base_addr, int) + : ACE_Based_Pointer_Basic (base_addr, 0) +{ + ACE_TRACE ("ACE_Based_Pointer_Basic::ACE_Based_Pointer_Basic"); +} + +template +ACE_Based_Pointer_Basic::ACE_Based_Pointer_Basic (void) + : target_ (0), + base_offset_ (0) +{ + ACE_TRACE ("ACE_Based_Pointer_Basic::ACE_Based_Pointer_Basic"); + void *base_addr = 0; + + // Find the base address associated with our pointer. Note + // that it's ok for to return 0, which simply indicates that + // the address is not in memory-mapped virtual address space. + ACE_BASED_POINTER_REPOSITORY::instance ()->find (this, + base_addr); + this->base_offset_ = (char *) this - (char *) base_addr; +} + +template +ACE_Based_Pointer_Basic::ACE_Based_Pointer_Basic (const void *base_addr, int) + : target_ (0), + base_offset_ (0) +{ + ACE_TRACE ("ACE_Based_Pointer_Basic::ACE_Based_Pointer_Basic"); + this->base_offset_ = (char *) this - (char *) base_addr; +} + +template +ACE_Based_Pointer_Basic::ACE_Based_Pointer_Basic (CONCRETE *rhs) + : target_ (0), + base_offset_ (0) +{ + ACE_TRACE ("ACE_Based_Pointer_Basic::ACE_Based_Pointer_Basic"); + + if (rhs == 0) + // Store a value of that indicate "NULL" pointer. + this->target_ = -1; + else + { + void *base_addr = 0; + + // Find the base address associated with the pointer. + // Note that it's ok for to return 0, which simply + // indicates that the address is not in memory-mapped virtual + // address space. + ACE_BASED_POINTER_REPOSITORY::instance ()->find (this, + base_addr); + this->base_offset_ = (char *) this - (char *) base_addr; + this->target_ = ((char *) rhs - (char *) base_addr); + } +} + +template +ACE_Based_Pointer_Basic::ACE_Based_Pointer_Basic (const ACE_Based_Pointer_Basic &) +{ + ACE_TRACE ("ACE_Based_Pointer_Basic::ACE_Based_Pointer_Basic"); + + ACE_ASSERT (0); // not implemented. +} + +template +ACE_Based_Pointer::ACE_Based_Pointer (const ACE_Based_Pointer &rhs) + : ACE_Based_Pointer_Basic (rhs) +{ + ACE_TRACE ("ACE_Based_Pointer::ACE_Based_Pointer"); + ACE_ASSERT (0); // not implemented. +} + +ACE_END_VERSIONED_NAMESPACE_DECL + +#endif /* ACE_BASED_POINTER_T_CPP */ diff --git a/dep/ACE_wrappers/ace/Based_Pointer_T.h b/dep/ACE_wrappers/ace/Based_Pointer_T.h new file mode 100644 index 00000000000..802e73ca0d3 --- /dev/null +++ b/dep/ACE_wrappers/ace/Based_Pointer_T.h @@ -0,0 +1,205 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Based_Pointer_T.h + * + * $Id: Based_Pointer_T.h 81705 2008-05-15 14:02:02Z johnnyw $ + * + * @author Dietrich Quehl + * @author Douglas C. Schmidt + */ +//============================================================================= + +#ifndef ACE_BASED_POINTER_T_H +#define ACE_BASED_POINTER_T_H + +#include /**/ "ace/pre.h" + +#include /**/ "ace/config-all.h" +#include "ace/Basic_Types.h" + +#if defined (_MSC_VER) +// Suppress warning e.g. "return type for +// 'ACE_Based_Pointer::operator ->' is 'long *' (i.e., not a UDT +// or reference to a UDT. Will produce errors if applied using infix +// notation)" +#pragma warning(disable: 4284) +#endif /* _MSC_VER */ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +/** + * @class ACE_Based_Pointer_Basic + * + * @brief A proxy that keeps track of the relative offset of a "pointer" + * from its base address. + * This class makes it possible to transparently use "pointers" in + * shared memory as easily as programming with pointers to local + * memory. In particular, we don't need to ensure that the base + * addresses of all the pointers are mapped into separate + * processes at the same absolute memory base address. + */ +template +class ACE_Based_Pointer_Basic +{ +public: + /** + * This constructor initializes the by asking the + * Singleton for the base address of + * the memory region within which it is instantiated. Two results + * are possible: + * + * 1. An has stored a base address/size pair and the + * new based-pointer instance is located between the base address and + * the base address + size - 1. In this case, the repository + * returns the base address. + * + * 2. No suitable address/size pair was found. The repository + * assumes an address in the regular (not mapped) virtual address + * space of the process and returns 0. In this case, the + * based-pointer uses its address as an offset to it's base + * address 0. + */ + ACE_Based_Pointer_Basic (void); + + /** + * Initialize this object using the @a initial pointer. This + * constructor initializes the by asking the + * Singleton for the base address of + * the memory region within which it is instantiated. Three results + * are possible: + * + * 1. An has stored a base address/size pair and the + * new based-pointer instance is located between the base address and + * the base address + size - 1. In this case, the repository + * returns the base address. + * + * 2. No suitable address/size pair was found. The repository + * assumes an address in the regular (not mapped) virtual address + * space of the process and returns 0. In this case, the + * based-pointer uses its address as an offset to its base + * address 0. + * + * 3. If @a initial is 0 then set the value of to -1, which + * indicates a "NULL" pointer. + */ + ACE_Based_Pointer_Basic (CONCRETE *initial); + + /// Copy constructor. + ACE_Based_Pointer_Basic (const ACE_Based_Pointer_Basic &); + + /// Constructor for know base address. @a o is only used to + /// resolve overload ambiguity. + ACE_Based_Pointer_Basic (const void *base_addr, int o); + + /// Pseudo-assignment operator. + void operator = (CONCRETE *from); + + /// Pseudo-assignment operator. + void operator = (const ACE_Based_Pointer_Basic &); + + /// Dereference operator. + CONCRETE operator * (void) const; + + /// Less than operator. + bool operator < (const ACE_Based_Pointer_Basic &) const; + + /// Less than or equal operator. + bool operator <= (const ACE_Based_Pointer_Basic &) const; + + /// Greater than operator. + bool operator > (const ACE_Based_Pointer_Basic &) const; + + /// Greater than or equal operator. + bool operator >= (const ACE_Based_Pointer_Basic &) const; + + /// Equality operator. + bool operator == (const ACE_Based_Pointer_Basic &) const; + + /// Inequality operator. + bool operator != (const ACE_Based_Pointer_Basic &) const; + + /// Subscript operator. + CONCRETE operator [](int index) const; + + /// Increment operator. + void operator+= (int index); + + /// Returns the underlying memory address of the smart pointer. + operator CONCRETE *() const; + + /// Returns the underlying memory address of the smart pointer. + CONCRETE *addr (void) const; + + /// Declare the dynamic allocation hooks. + ACE_ALLOC_HOOK_DECLARE; + + /// Dump the state of the object. + void dump (void) const; + +protected: + ptrdiff_t target_; + + /// Keep track of our offset from the base pointer. + ptrdiff_t base_offset_; +}; + +/** + * @class ACE_Based_Pointer + * + * @brief A smart proxy that keeps track of the relative offset of a + * "pointer" from its base address. + * + * This class makes it possible to transparently use "pointers" in + * shared memory as easily as programming with pointers to local + * memory by overloading the C++ delegation operator ->(). + */ +template +class ACE_Based_Pointer : public ACE_Based_Pointer_Basic +{ +public: + // = Initialization method. + /// Constructor. See constructor for ACE_Based_Pointer_Basic for + /// details. + ACE_Based_Pointer (void); + + /// Initialize this object using the pointer. See + /// constructor for ACE_Based_Pointer_Basic for details. + ACE_Based_Pointer (CONCRETE *initial); + + /// Initialize this object with known @a base_addr. @a dummy is + /// a dummy value used to resolve overload ambiguity and it + /// otherwise ignored. + ACE_Based_Pointer (const void *base_addr, int dummy); + + /// Copy constructor (not implemented yet). + ACE_Based_Pointer (const ACE_Based_Pointer &); + + /// Assignment operator. + void operator = (const ACE_Based_Pointer &); + + /// Pseudo-assignment operator. + void operator = (CONCRETE *from); + + /// The C++ "delegation operator". + CONCRETE *operator-> (void); +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +#include "ace/Based_Pointer_T.inl" +#endif /* __ACE_INLINE__ */ + +#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) +#include "ace/Based_Pointer_T.cpp" +#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ + +#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) +#pragma implementation ("Based_Pointer_T.cpp") +#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ + +#include /**/ "ace/post.h" + +#endif /* ACE_BASED_POINTER_T_H */ diff --git a/dep/ACE_wrappers/ace/Based_Pointer_T.inl b/dep/ACE_wrappers/ace/Based_Pointer_T.inl new file mode 100644 index 00000000000..ba6a5aa511b --- /dev/null +++ b/dep/ACE_wrappers/ace/Based_Pointer_T.inl @@ -0,0 +1,139 @@ +// -*- C++ -*- +// +// $Id: Based_Pointer_T.inl 81705 2008-05-15 14:02:02Z johnnyw $ + +#define ACE_COMPUTE_BASED_POINTER(P) (((char *) (P) - (P)->base_offset_) + (P)->target_) +#include "ace/Global_Macros.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +template ACE_INLINE CONCRETE * +ACE_Based_Pointer::operator->(void) +{ + ACE_TRACE ("ACE_Based_Pointer::operator->"); + return reinterpret_cast (ACE_COMPUTE_BASED_POINTER (this)); +} + +template ACE_INLINE void +ACE_Based_Pointer_Basic::operator = (CONCRETE *rhs) +{ + ACE_TRACE ("ACE_Based_Pointer_Basic::operator ="); + if (rhs == 0) + // Store a value of that indicate "NULL" pointer. + this->target_ = -1; + else + this->target_ = ((char *) rhs + - ((char *) this - this->base_offset_)); +} + +template ACE_INLINE void +ACE_Based_Pointer::operator = (CONCRETE *rhs) +{ + ACE_TRACE ("ACE_Based_Pointer::operator ="); + if (rhs == 0) + // Store a value of that indicate "NULL" pointer. + this->target_ = -1; + else + this->target_ = ((char *) rhs + - ((char *) this - this->base_offset_)); +} + +template ACE_INLINE CONCRETE +ACE_Based_Pointer_Basic::operator *(void) const +{ + ACE_TRACE ("ACE_Based_Pointer_Basic::operator *"); + return *reinterpret_cast (ACE_COMPUTE_BASED_POINTER (this)); +} + +template ACE_INLINE CONCRETE * +ACE_Based_Pointer_Basic::addr (void) const +{ + ACE_TRACE ("ACE_Based_Pointer_Basic::addr"); + + if (this->target_ == -1) + return 0; + else + return reinterpret_cast (ACE_COMPUTE_BASED_POINTER (this)); +} + +template ACE_INLINE +ACE_Based_Pointer_Basic::operator CONCRETE *() const +{ + ACE_TRACE ("ACE_Based_Pointer_Basic::operator CONCRETE *()"); + + return this->addr (); +} + +template ACE_INLINE CONCRETE +ACE_Based_Pointer_Basic::operator [] (int index) const +{ + ACE_TRACE ("ACE_Based_Pointer_Basic::operator []"); + CONCRETE *c = + reinterpret_cast (ACE_COMPUTE_BASED_POINTER (this)); + return c[index]; +} + +template ACE_INLINE void +ACE_Based_Pointer_Basic::operator += (int index) +{ + ACE_TRACE ("ACE_Based_Pointer_Basic::operator +="); + this->base_offset_ += (index * sizeof (CONCRETE)); +} + +template ACE_INLINE bool +ACE_Based_Pointer_Basic::operator == (const ACE_Based_Pointer_Basic &rhs) const +{ + ACE_TRACE ("ACE_Based_Pointer_Basic::operator =="); + return ACE_COMPUTE_BASED_POINTER (this) == ACE_COMPUTE_BASED_POINTER (&rhs); +} + +template ACE_INLINE bool +ACE_Based_Pointer_Basic::operator != (const ACE_Based_Pointer_Basic &rhs) const +{ + ACE_TRACE ("ACE_Based_Pointer_Basic::operator !="); + return !(*this == rhs); +} + +template ACE_INLINE bool +ACE_Based_Pointer_Basic::operator < (const ACE_Based_Pointer_Basic &rhs) const +{ + ACE_TRACE ("ACE_Based_Pointer_Basic::operator <"); + return ACE_COMPUTE_BASED_POINTER (this) < ACE_COMPUTE_BASED_POINTER (&rhs); +} + +template ACE_INLINE bool +ACE_Based_Pointer_Basic::operator <= (const ACE_Based_Pointer_Basic &rhs) const +{ + ACE_TRACE ("ACE_Based_Pointer_Basic::operator <="); + return ACE_COMPUTE_BASED_POINTER (this) <= ACE_COMPUTE_BASED_POINTER (&rhs); +} + +template ACE_INLINE bool +ACE_Based_Pointer_Basic::operator > (const ACE_Based_Pointer_Basic &rhs) const +{ + ACE_TRACE ("ACE_Based_Pointer_Basic::operator >"); + return ACE_COMPUTE_BASED_POINTER (this) > ACE_COMPUTE_BASED_POINTER (&rhs); +} + +template ACE_INLINE bool +ACE_Based_Pointer_Basic::operator >= (const ACE_Based_Pointer_Basic &rhs) const +{ + ACE_TRACE ("ACE_Based_Pointer_Basic::operator >="); + return ACE_COMPUTE_BASED_POINTER (this) >= ACE_COMPUTE_BASED_POINTER (&rhs); +} + +template ACE_INLINE void +ACE_Based_Pointer_Basic::operator= (const ACE_Based_Pointer_Basic &rhs) +{ + ACE_TRACE ("ACE_Based_Pointer_Basic::operator="); + *this = rhs.addr (); +} + +template ACE_INLINE void +ACE_Based_Pointer::operator= (const ACE_Based_Pointer &rhs) +{ + ACE_TRACE ("ACE_Based_Pointer::operator="); + *this = rhs.addr (); +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Basic_Stats.cpp b/dep/ACE_wrappers/ace/Basic_Stats.cpp new file mode 100644 index 00000000000..fe678333d89 --- /dev/null +++ b/dep/ACE_wrappers/ace/Basic_Stats.cpp @@ -0,0 +1,78 @@ +// $Id: Basic_Stats.cpp 80826 2008-03-04 14:51:23Z wotte $ + +#include "ace/Basic_Stats.h" +#include "ace/Log_Msg.h" + +#if !defined (__ACE_INLINE__) +#include "ace/Basic_Stats.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(ace, + Basic_Stats, + "$Id: Basic_Stats.cpp 80826 2008-03-04 14:51:23Z wotte $") + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +void +ACE_Basic_Stats::accumulate (const ACE_Basic_Stats &rhs) +{ + if (rhs.samples_count_ == 0) + return; + + if (this->samples_count_ == 0) + { + this->min_ = rhs.min_; + this->min_at_ = rhs.min_at_; + + this->max_ = rhs.max_; + this->max_at_ = rhs.max_at_; + } + else + { + if (this->min_ > rhs.min_) + { + this->min_ = rhs.min_; + this->min_at_ = rhs.min_at_; + } + if (this->max_ < rhs.max_) + { + this->max_ = rhs.max_; + this->max_at_ = rhs.max_at_; + } + } + + this->samples_count_ += rhs.samples_count_; + this->sum_ += rhs.sum_; +} + +void +ACE_Basic_Stats::dump_results (const ACE_TCHAR *msg, ACE_UINT32 sf) const +{ +#ifndef ACE_NLOGGING + if (this->samples_count () == 0u) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("%s : no data collected\n"), msg)); + return; + } + + ACE_UINT64 avg = this->sum_ / this->samples_count_; + + ACE_UINT64 l_min = this->min_ / sf; + ACE_UINT64 l_max = this->max_ / sf; + ACE_UINT64 l_avg = avg / sf; + + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("%s latency : %Q[%d]/%Q/%Q[%d] (min/avg/max)\n"), + msg, + l_min, this->min_at_, + l_avg, + l_max, this->max_at_)); + +#else + ACE_UNUSED_ARG (msg); + ACE_UNUSED_ARG (sf); +#endif /* ACE_NLOGGING */ +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Basic_Stats.h b/dep/ACE_wrappers/ace/Basic_Stats.h new file mode 100644 index 00000000000..bff1ff29f65 --- /dev/null +++ b/dep/ACE_wrappers/ace/Basic_Stats.h @@ -0,0 +1,87 @@ + +//============================================================================= +/** + * @file Basic_Stats.h + * + * $Id: Basic_Stats.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Carlos O'Ryan + */ +//============================================================================= + + +#ifndef ACE_BASIC_STATS_H +#define ACE_BASIC_STATS_H +#include /**/ "ace/pre.h" + +#include /**/ "ace/config-all.h" +#include "ace/Basic_Types.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +/// Collect basic stats about a series of samples +/** + * Compute the average and standard deviation (aka jitter) for an + * arbitrary number of samples, using constant space. + * Normally used for latency statistics. + */ +class ACE_Export ACE_Basic_Stats +{ +public: + /// Constructor + /** + * The number of samples is pre-allocated, and cannot changes once + * the class is initialized. + */ + ACE_Basic_Stats (void); + + /// The number of samples received so far + ACE_UINT32 samples_count (void) const; + + /// Record one sample. + void sample (ACE_UINT64 value); + + /// Update the values to reflect the stats in @a rhs. + void accumulate (const ACE_Basic_Stats &rhs); + + /// Dump all the samples + /** + * Prints out the results, using @a msg as a prefix for each message and + * scaling all the numbers by @a scale_factor. The latter is useful because + * high resolution timer samples are acquired in clock ticks, but often + * presented in microseconds. + */ + void dump_results (const ACE_TCHAR *msg, + ACE_UINT32 scale_factor) const; + + /// The number of samples + ACE_UINT32 samples_count_; + + /// The minimum value + ACE_UINT64 min_; + + /// The number of the sample that had the minimum value + ACE_UINT32 min_at_; + + /// The maximum value + ACE_UINT64 max_; + + /// The number of the sample that had the maximum value + ACE_UINT32 max_at_; + + /// The sum of all the values + ACE_UINT64 sum_; +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +#include "ace/Basic_Stats.inl" +#endif /* __ACE_INLINE__ */ + +#include /**/ "ace/post.h" +#endif /* ACE_BASIC_STATS_H */ diff --git a/dep/ACE_wrappers/ace/Basic_Stats.inl b/dep/ACE_wrappers/ace/Basic_Stats.inl new file mode 100644 index 00000000000..e2f153884e3 --- /dev/null +++ b/dep/ACE_wrappers/ace/Basic_Stats.inl @@ -0,0 +1,53 @@ +// -*- C++ -*- +// +// $Id: Basic_Stats.inl 80826 2008-03-04 14:51:23Z wotte $ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_INLINE +ACE_Basic_Stats::ACE_Basic_Stats (void) + : samples_count_ (0) + , min_ (0) + , min_at_ (0) + , max_ (0) + , max_at_ (0) + , sum_ (0) +{ +} + +ACE_INLINE ACE_UINT32 +ACE_Basic_Stats::samples_count (void) const +{ + return this->samples_count_; +} + +ACE_INLINE void +ACE_Basic_Stats::sample (ACE_UINT64 value) +{ + ++this->samples_count_; + + if (this->samples_count_ == 1u) + { + this->min_ = value; + this->min_at_ = this->samples_count_; + this->max_ = value; + this->max_at_ = this->samples_count_; + } + else + { + if (this->min_ > value) + { + this->min_ = value; + this->min_at_ = this->samples_count_; + } + if (this->max_ < value) + { + this->max_ = value; + this->max_at_ = this->samples_count_; + } + } + + this->sum_ += value; +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Basic_Types.cpp b/dep/ACE_wrappers/ace/Basic_Types.cpp new file mode 100644 index 00000000000..42ae83c0b2a --- /dev/null +++ b/dep/ACE_wrappers/ace/Basic_Types.cpp @@ -0,0 +1,139 @@ +#include "ace/Basic_Types.h" + +#if !defined (__ACE_INLINE__) +# include "ace/Basic_Types.inl" +#endif /* ! __ACE_INLINE__ */ + + +ACE_RCSID (ace, + Basic_Types, + "$Id: Basic_Types.cpp 80826 2008-03-04 14:51:23Z wotte $") + + +#if defined (ACE_LACKS_LONGLONG_T) && !defined (ACE_LACKS_UNSIGNEDLONGLONG_T) +# include "ace/Log_Msg.h" +# include "ace/OS_NS_stdio.h" +# include "ace/OS_NS_string.h" +# if !defined (ACE_LACKS_IOSTREAM_TOTALLY) +// FUZZ: disable check_for_streams_include +# include "ace/streams.h" +# endif /* ! ACE_LACKS_IOSTREAM_TOTALLY */ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +void +ACE_U_LongLong::output (FILE *file) const +{ + if (h_ () > 0) + ACE_OS::fprintf (file, "0x%lx%0*lx", h_ (), 2 * sizeof l_ (), l_ ()); + else + ACE_OS::fprintf (file, "0x%lx", l_ ()); +} + + +ACE_TCHAR * +ACE_U_LongLong::as_string (ACE_TCHAR *output, + unsigned int base, + unsigned int uppercase) const +{ + if (*this == 0) + { + ACE_OS::strcpy(output, "0"); + } + else + { + switch(base) + { + case 8: + { + unsigned int index = 0; + int bshift = 31; + while(bshift >= 1) + { + unsigned int sval = (this->h_ () >> bshift) & 7; + if (sval > 0 || index != 0) + { + output[index] = sval + '0'; + ++index; + } + bshift -= 3; + } + bshift = 30; + while(bshift >= 0) + { + unsigned int sval = (this->l_ () >> bshift) & 7; + // Combine the last bit of hi with the first 3-bit digit + if (bshift == 30) + { + sval |= (this->h_ () & 1) << 2; + } + if (sval > 0 || index != 0) + { + output[index] = sval + '0'; + ++index; + } + bshift -= 3; + } + output[index] = '\0'; + break; + } + case 10: + { + ACE_OS::sprintf(output, "%.0f", *this / 1.0); + break; + } + case 16: + { + if (this->h_ () != 0) + { + ACE_OS::sprintf(output, + (uppercase ? "%lX%0*lX" : "%lx%0*lx"), + this->h_ (), 2 * sizeof this->l_ (), + this->l_ ()); + } + else + { + ACE_OS::sprintf(output, + (uppercase ? "%lX" : "%lx"), this->l_ ()); + + } + break; + } + default: + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("Unsupported base = %u\n"), base)); + output[0] = '\0'; + } + } + } + + return output; +} + + +# if !defined (ACE_LACKS_IOSTREAM_TOTALLY) +ostream& +operator<< (ostream& os, const ACE_U_LongLong& ll) +{ +#ifdef __TANDEM && (__CPLUSPLUS_VERSION >= 3) + unsigned long flags = os.flags(); +#else + unsigned long flags = os.setf(0); +#endif + char buffer[32]; + + if ((flags & ios::oct) != 0) + os << ll.as_string (buffer, 8); + else if ((flags & ios::hex) != 0) + os << ll.as_string (buffer, 16, (flags & ios::uppercase)); + else + os << ll.as_string (buffer); + return os; +} +# endif + +ACE_END_VERSIONED_NAMESPACE_DECL + +#endif /* ACE_LACKS_LONGLONG_T */ + diff --git a/dep/ACE_wrappers/ace/Basic_Types.h b/dep/ACE_wrappers/ace/Basic_Types.h new file mode 100644 index 00000000000..8e46abf305d --- /dev/null +++ b/dep/ACE_wrappers/ace/Basic_Types.h @@ -0,0 +1,890 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Basic_Types.h + * + * $Id: Basic_Types.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author David L. Levine + * + * #defines the list of preprocessor macros below. The config.h file can + * pre-define any of these to short-cut the definitions. This is usually + * only necessary if the preprocessor does all of its math using integers. + * + * Sizes of built-in types: + * - ACE_SIZEOF_CHAR + * - ACE_SIZEOF_WCHAR + * - ACE_SIZEOF_SHORT + * - ACE_SIZEOF_INT + * - ACE_SIZEOF_LONG + * - ACE_SIZEOF_LONG_LONG + * - ACE_SIZEOF_VOID_P + * - ACE_SIZEOF_FLOAT + * - ACE_SIZEOF_DOUBLE + * - ACE_SIZEOF_LONG_DOUBLE + * + * Wrappers for built-in types of specific sizes: + * - ACE_USHORT16 (For backward compatibility. Use ACE_UINT16 instead.) + * - ACE_INT8 + * - ACE_UINT8 + * - ACE_INT16 + * - ACE_UINT16 + * - ACE_INT32 + * - ACE_UINT32 + * - ACE_UINT64 + * (@note ACE_INT64 is partly defined, there is no ACE_LongLong for + * platforms that don't have a native 8-byte integer type.) + * + * Byte-order (endian-ness) determination: + * ACE_BYTE_ORDER, to either ACE_BIG_ENDIAN or ACE_LITTLE_ENDIAN + * + * + */ +//============================================================================= + +#include "ace/config-lite.h" + +#ifndef ACE_BASIC_TYPES_H +# define ACE_BASIC_TYPES_H + +# include /**/ "ace/pre.h" + +# if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +# endif /* ACE_LACKS_PRAGMA_ONCE */ + +// Pull in definitions +# include "ace/os_include/os_limits.h" // Integer limits +# include "ace/os_include/os_float.h" // Floating point limits +# include "ace/os_include/os_stdlib.h" // Other types +# include "ace/os_include/os_stddef.h" // Get ptrdiff_t - see further comments below + +# if defined(ACE_LACKS_LONGLONG_T) +# include "ace/os_include/os_stdio.h" // For long long emulation +# endif /* ACE_LACKS_LONGLONG_T */ + +# include "ace/os_include/sys/os_types.h" + +# if !defined (ACE_LACKS_SYS_PARAM_H) +# include /**/ +# endif /* ACE_LACKS_SYS_PARAM_H */ + +# include "ace/ACE_export.h" + +# if !defined (ACE_LACKS_STDINT_H) +# include +# endif +# if !defined (ACE_LACKS_INTTYPES_H) +# include +# endif + +#ifdef ACE_LACKS_INTPTR_T +# include "ace/If_Then_Else.h" + +// This intptr_t typedef is here instead of +// since it depends on the template +// metaprogramming in . + +// We could compare ACE_SIZEOF_VOID_P against ACE_SIZEOF_LONG, etc. +// However, that depends on the ACE preprocessor symbol definitions in +// the platform-specific configuration header being correct. +// The template meta-programming approach we take below, +// i.e. determining the type at compile-time rather than at +// preprocessing-time, will work for all platforms, and does not +// depend on ACE developer-defined configuration parameters. + +typedef ACE::If_Then_Else< + (sizeof (void*) == sizeof (signed int)), + signed int, + ACE::If_Then_Else< + (sizeof (void*) == sizeof (signed long)), + signed long, +#ifdef ACE_LACKS_LONGLONG_T + void /* Unknown. Force an invalid type */ +#else + ACE::If_Then_Else< + (sizeof (void*) == sizeof (signed long long)), + signed long long, + void /* Unknown. Force an invalid type */ + >::result_type +#endif /* ACE_LACKS_LONGLONG_T */ + >::result_type + >::result_type intptr_t; + +typedef ACE::If_Then_Else< + (sizeof (void*) == sizeof (unsigned int)), + unsigned int, + ACE::If_Then_Else< + (sizeof (void*) == sizeof (unsigned long)), + unsigned long, +#ifdef ACE_LACKS_UNSIGNEDLONGLONG_T + void /* Unknown. Force an invalid type */ +#else + ACE::If_Then_Else< + (sizeof (void*) == sizeof (unsigned long long)), + unsigned long long, + void /* Unknown. Force an invalid type */ + >::result_type +#endif /* ACE_LACKS_UNSIGNEDLONGLONG_T */ + >::result_type + >::result_type uintptr_t; + +#endif /* ACE_LACKS_INTPTR_T */ + +// A char always has 1 byte, by definition. +# define ACE_SIZEOF_CHAR 1 + +// Unfortunately, there isn't a portable way to determine the size of a wchar. +// So we just define them on a platform basis. If the platform doesn't +// define it and it's an XPG4 system, assume wchar_t is 4 bytes. Some code +// uses ACE_SIZEOF_WCHAR in preprocessor statements, so sizeof() isn't valid. +// If the platform config doesn't set this, and this guess is wrong, +// Basic_Types_Test should catch the inconsistency. +# if defined (ACE_HAS_WCHAR) +# if !defined (ACE_SIZEOF_WCHAR) +# if defined (ACE_HAS_XPG4_MULTIBYTE_CHAR) +# define ACE_SIZEOF_WCHAR 4 +# else +// 0 so the Basic_Types test will catch this. +# define ACE_SIZEOF_WCHAR 0 +# endif /* ACE_HAS_XPG4_MULTIBYTE_CHAR */ +# endif /* !ACE_SIZEOF_WCHAR */ +# endif /* ACE_HAS_WCHAR */ + +// The number of bytes in a short. +# if !defined (ACE_SIZEOF_SHORT) +# if (USHRT_MAX) == 255U +# define ACE_SIZEOF_SHORT 1 +# elif (USHRT_MAX) == 65535U +# define ACE_SIZEOF_SHORT 2 +# elif (USHRT_MAX) == 4294967295U +# define ACE_SIZEOF_SHORT 4 +# elif (USHRT_MAX) == 18446744073709551615U +# define ACE_SIZEOF_SHORT 8 +# else +# error: unsupported short size, must be updated for this platform! +# endif /* USHRT_MAX */ +# endif /* !defined (ACE_SIZEOF_SHORT) */ + +// The number of bytes in an int. +# if !defined (ACE_SIZEOF_INT) +# if (UINT_MAX) == 65535U +# define ACE_SIZEOF_INT 2 +# elif (UINT_MAX) == 4294967295U +# define ACE_SIZEOF_INT 4 +# elif (UINT_MAX) == 18446744073709551615U +# define ACE_SIZEOF_INT 8 +# else +# error: unsupported int size, must be updated for this platform! +# endif /* UINT_MAX */ +# endif /* !defined (ACE_SIZEOF_INT) */ + +// The number of bytes in a long. +# if !defined (ACE_SIZEOF_LONG) +# if (ULONG_MAX) == 65535UL +# define ACE_SIZEOF_LONG 2 +# elif ((ULONG_MAX) == 4294967295UL) +# define ACE_SIZEOF_LONG 4 +# elif ((ULONG_MAX) == 18446744073709551615UL) +# define ACE_SIZEOF_LONG 8 +# else +# error: unsupported long size, must be updated for this platform! +# endif /* ULONG_MAX */ +# endif /* !defined (ACE_SIZEOF_LONG) */ + +// The number of bytes in a long long. +# if !defined (ACE_SIZEOF_LONG_LONG) +# if defined (ACE_LACKS_LONGLONG_T) +# define ACE_SIZEOF_LONG_LONG 8 +# elif defined (ULLONG_MAX) +# if ((ULLONG_MAX) == 4294967295ULL) +# define ACE_SIZEOF_LONG_LONG 4 +# elif ((ULLONG_MAX) == 18446744073709551615ULL) +# define ACE_SIZEOF_LONG_LONG 8 +# endif +# elif defined (ULONGLONG_MAX) +# if ((ULONGLONG_MAX) == 4294967295ULL) +# define ACE_SIZEOF_LONG_LONG 4 +# elif ((ULONGLONG_MAX) == 18446744073709551615ULL) +# define ACE_SIZEOF_LONG_LONG 8 +# endif +# endif +# // If we can't determine the size of long long, assume it is 8 +# // instead of erroring out. (Either ULLONG_MAX and ULONGLONG_MAX +# // may not be supported; or an extended C/C++ dialect may need to +# // be selected. If this assumption is wrong, it can be addressed +# // in the platform-specific config header. +# if !defined (ACE_SIZEOF_LONG_LONG) +# define ACE_SIZEOF_LONG_LONG 8 +# endif +# endif /* !defined (ACE_SIZEOF_LONG_LONG) */ + + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +// The sizes of the commonly implemented types are now known. Set up +// typedefs for whatever we can. Some of these are needed for certain +// cases of ACE_UINT64, so do them before the 64-bit stuff. + +#if defined (ACE_INT8_TYPE) + typedef ACE_INT8_TYPE ACE_INT8; +#elif defined (ACE_HAS_INT8_T) + typedef int8_t ACE_INT8; +#elif !defined (ACE_LACKS_SIGNED_CHAR) + typedef signed char ACE_INT8; +#else + typedef char ACE_INT8; +#endif /* defined (ACE_INT8_TYPE) */ + +#if defined (ACE_UINT8_TYPE) + typedef ACE_UINT8_TYPE ACE_UINT8; +#elif defined (ACE_HAS_UINT8_T) + typedef uint8_t ACE_UINT8; +#else + typedef unsigned char ACE_UINT8; +#endif /* defined (ACE_UINT8_TYPE) */ + +#if defined (ACE_INT16_TYPE) + typedef ACE_INT16_TYPE ACE_INT16; +#elif defined (ACE_HAS_INT16_T) + typedef int16_t ACE_INT16; +#elif ACE_SIZEOF_SHORT == 2 + typedef short ACE_INT16; +#elif ACE_SIZEOF_INT == 2 + typedef int ACE_INT16; +#else +# error Have to add to the ACE_INT16 type setting +#endif /* defined (ACE_INT16_TYPE) */ + +#if defined (ACE_UINT16_TYPE) + typedef ACE_UINT16_TYPE ACE_UINT16; +#elif defined (ACE_HAS_UINT16_T) + typedef uint16_t ACE_UINT16; +#elif ACE_SIZEOF_SHORT == 2 + typedef unsigned short ACE_UINT16; +#elif ACE_SIZEOF_INT == 2 + typedef unsigned int ACE_UINT16; +#else +# error Have to add to the ACE_UINT16 type setting +#endif /* defined (ACE_UINT16_TYPE) */ + +#if defined (ACE_INT32_TYPE) + typedef ACE_INT32_TYPE ACE_INT32; +#elif defined (ACE_HAS_INT32_T) + typedef int32_t ACE_INT32; +#elif ACE_SIZEOF_INT == 4 + typedef int ACE_INT32; +#elif ACE_SIZEOF_LONG == 4 + typedef long ACE_INT32; +#else +# error Have to add to the ACE_INT32 type setting +#endif /* defined (ACE_INT32_TYPE) */ + +#if defined (ACE_UINT32_TYPE) + typedef ACE_UINT32_TYPE ACE_UINT32; +#elif defined (ACE_HAS_UINT32_T) + typedef uint32_t ACE_UINT32; +#elif ACE_SIZEOF_INT == 4 + typedef unsigned int ACE_UINT32; +#elif ACE_SIZEOF_LONG == 4 + typedef unsigned long ACE_UINT32; +#else +# error Have to add to the ACE_UINT32 type setting +#endif /* defined (ACE_UINT32_TYPE) */ + +#if defined (ACE_INT64_TYPE) + typedef ACE_INT64_TYPE ACE_INT64; +#elif defined (ACE_HAS_INT64_T) + typedef int64_t ACE_INT64; +#elif ACE_SIZEOF_LONG == 8 + typedef long ACE_INT64; +#elif !defined (ACE_LACKS_LONGLONG_T) && ACE_SIZEOF_LONG_LONG == 8 +# ifdef __GNUC__ + // Silence g++ "-pedantic" warnings regarding use of "long long" + // type. + __extension__ +# endif /* __GNUC__ */ + typedef long long ACE_INT64; +#endif /* defined (ACE_INT64_TYPE) */ + +#if !(defined (ACE_LACKS_LONGLONG_T) || defined (ACE_LACKS_UNSIGNEDLONGLONG_T)) +/* See matching #if around ACE_U_LongLong class declaration below */ + +# if defined (ACE_UINT64_TYPE) + typedef ACE_UINT64_TYPE ACE_UINT64; +# elif defined (ACE_HAS_UINT64_T) + typedef uint64_t ACE_UINT64; +# elif ACE_SIZEOF_LONG == 8 + typedef unsigned long ACE_UINT64; +# elif ACE_SIZEOF_LONG_LONG == 8 +# ifdef __GNUC__ + // Silence g++ "-pedantic" warnings regarding use of "long long" + // type. + __extension__ +# endif /* __GNUC__ */ + typedef unsigned long long ACE_UINT64; +# endif /* defined (ACE_UINT64_TYPE) */ +#endif /* !(ACE_LACKS_LONGLONG_T || ACE_LACKS_UNSIGNEDLONGLONG_T) */ + + +typedef ACE_UINT16 ACE_USHORT16; // @@ Backward compatibility. + +// Define a generic byte for use in codecs +typedef unsigned char ACE_Byte; + +// Define a pseudo wide character type when wchar is not supported so we +// can support basic wide character string operations. + +# if defined (ACE_HAS_WCHAR) || defined (ACE_HAS_XPG4_MULTIBYTE_CHAR) +# define ACE_WINT_T wint_t +# define ACE_WCHAR_T wchar_t +# else +# define ACE_WINT_T ACE_UINT16 +# define ACE_WCHAR_T ACE_UINT16 +# endif /* ACE_HAS_WCHAR */ + +// The number of bytes in a void *. +# ifndef ACE_SIZEOF_VOID_P +# define ACE_SIZEOF_VOID_P ACE_SIZEOF_LONG +# endif /* ACE_SIZEOF_VOID_P */ + +// Type for doing arithmetic on pointers ... as elsewhere, we assume +// that unsigned versions of a type are the same size as the signed +// version of the same type. +# if defined (ACE_HAS_WINCE) && (_WIN32_WCE < 400) +typedef unsigned long ptrdiff_t; // evc3, PocketPC don't defined ptrdiff_t +# endif + +ACE_END_VERSIONED_NAMESPACE_DECL + +// Byte-order (endian-ness) determination. +# if defined (BYTE_ORDER) +# if (BYTE_ORDER == LITTLE_ENDIAN) +# define ACE_LITTLE_ENDIAN 0x0123 +# define ACE_BYTE_ORDER ACE_LITTLE_ENDIAN +# elif (BYTE_ORDER == BIG_ENDIAN) +# define ACE_BIG_ENDIAN 0x3210 +# define ACE_BYTE_ORDER ACE_BIG_ENDIAN +# else +# error: unknown BYTE_ORDER! +# endif /* BYTE_ORDER */ +# elif defined (_BYTE_ORDER) +# if (_BYTE_ORDER == _LITTLE_ENDIAN) +# define ACE_LITTLE_ENDIAN 0x0123 +# define ACE_BYTE_ORDER ACE_LITTLE_ENDIAN +# elif (_BYTE_ORDER == _BIG_ENDIAN) +# define ACE_BIG_ENDIAN 0x3210 +# define ACE_BYTE_ORDER ACE_BIG_ENDIAN +# else +# error: unknown _BYTE_ORDER! +# endif /* _BYTE_ORDER */ +# elif defined (__BYTE_ORDER) +# if (__BYTE_ORDER == __LITTLE_ENDIAN) +# define ACE_LITTLE_ENDIAN 0x0123 +# define ACE_BYTE_ORDER ACE_LITTLE_ENDIAN +# elif (__BYTE_ORDER == __BIG_ENDIAN) +# define ACE_BIG_ENDIAN 0x3210 +# define ACE_BYTE_ORDER ACE_BIG_ENDIAN +# else +# error: unknown __BYTE_ORDER! +# endif /* __BYTE_ORDER */ +# else /* ! BYTE_ORDER && ! __BYTE_ORDER */ + // We weren't explicitly told, so we have to figure it out . . . +# if defined (i386) || defined (__i386__) || defined (_M_IX86) || \ + defined (vax) || defined (__alpha) || defined (__LITTLE_ENDIAN__) || \ + defined (ARM) || defined (_M_IA64) || defined (__ia64__) || \ + defined (_M_AMD64) || defined (__amd64) + // We know these are little endian. +# define ACE_LITTLE_ENDIAN 0x0123 +# define ACE_BYTE_ORDER ACE_LITTLE_ENDIAN +# else + // Otherwise, we assume big endian. +# define ACE_BIG_ENDIAN 0x3210 +# define ACE_BYTE_ORDER ACE_BIG_ENDIAN +# endif +# endif /* ! BYTE_ORDER && ! __BYTE_ORDER */ + +// Byte swapping macros to deal with differences between little endian +// and big endian machines. Note that "long" here refers to 32 bit +// quantities. +# define ACE_SWAP_LONG(L) ((ACE_SWAP_WORD ((L) & 0xFFFF) << 16) \ + | ACE_SWAP_WORD(((L) >> 16) & 0xFFFF)) +# define ACE_SWAP_WORD(L) ((((L) & 0x00FF) << 8) | (((L) & 0xFF00) >> 8)) + +# if defined (ACE_LITTLE_ENDIAN) +# define ACE_HTONL(X) ACE_SWAP_LONG (X) +# define ACE_NTOHL(X) ACE_SWAP_LONG (X) +# define ACE_IDL_NCTOHL(X) (X) +# define ACE_IDL_NSTOHL(X) (X) +# else +# define ACE_HTONL(X) X +# define ACE_NTOHL(X) X +# define ACE_IDL_NCTOHL(X) (X << 24) +# define ACE_IDL_NSTOHL(X) ((X) << 16) +# endif /* ACE_LITTLE_ENDIAN */ + +# if defined (ACE_LITTLE_ENDIAN) +# define ACE_HTONS(x) ACE_SWAP_WORD(x) +# define ACE_NTOHS(x) ACE_SWAP_WORD(x) +# else +# define ACE_HTONS(x) x +# define ACE_NTOHS(x) x +# endif /* ACE_LITTLE_ENDIAN */ + +#if defined (ACE_LACKS_LONGLONG_T) + // This throws away the high 32 bits. It's very unlikely that a + // pointer will be more than 32 bits wide if the platform does not + // support 64-bit integers. +# define ACE_LONGLONG_TO_PTR(PTR_TYPE, L) \ + reinterpret_cast (L.lo ()) +#elif defined (ACE_OPENVMS) && (!defined (__INITIAL_POINTER_SIZE) || (__INITIAL_POINTER_SIZE < 64)) +# define ACE_LONGLONG_TO_PTR(PTR_TYPE, L) \ + reinterpret_cast (static_cast (L)) +#else /* ! ACE_LACKS_LONGLONG_T */ +# define ACE_LONGLONG_TO_PTR(PTR_TYPE, L) \ + reinterpret_cast (static_cast (L)) +#endif /* ! ACE_LACKS_LONGLONG_T */ + +// If the platform lacks an unsigned long long, define one. +#if defined (ACE_LACKS_LONGLONG_T) || defined (ACE_LACKS_UNSIGNEDLONGLONG_T) +// Forward declaration for streams +# include "ace/iosfwd.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +/** + * @class ACE_U_LongLong + * + * @brief Unsigned long long for platforms that don't have one. + * + * Provide our own unsigned long long. This is intended to be + * use with ACE_High_Res_Timer, so the division operator assumes + * that the quotient fits into a u_long. + * Please note that the constructor takes (optionally) two values. + * The high one contributes 0x100000000 times its value. So, + * for example, (0, 2) is _not_ 20000000000, but instead + * 0x200000000. To emphasize this, the default values are expressed + * in hex, and output () dumps the value in hex. + */ + class ACE_Export ACE_U_LongLong + { + public: + // = Initialization and termination methods. +#if defined (ACE_LACKS_UNSIGNEDLONGLONG_T) + ACE_U_LongLong (const long long value = 0x0); +#else + ACE_U_LongLong (const ACE_UINT32 lo = 0x0, const ACE_UINT32 hi = 0x0); +#endif + ACE_U_LongLong (const ACE_U_LongLong &); + ACE_U_LongLong &operator= (const ACE_U_LongLong &); + ACE_U_LongLong &operator= (const ACE_INT32 &); + ACE_U_LongLong &operator= (const ACE_UINT32 &); + ~ACE_U_LongLong (void); + + // = Overloaded relation operators. + bool operator== (const ACE_U_LongLong &) const; + bool operator== (const ACE_UINT32) const; + bool operator!= (const ACE_U_LongLong &) const; + bool operator!= (const ACE_UINT32) const; + bool operator< (const ACE_U_LongLong &) const; + bool operator< (const ACE_UINT32) const; + bool operator<= (const ACE_U_LongLong &) const; + bool operator<= (const ACE_UINT32) const; + bool operator> (const ACE_U_LongLong &) const; + bool operator> (const ACE_UINT32) const; + bool operator>= (const ACE_U_LongLong &) const; + bool operator>= (const ACE_UINT32) const; + + ACE_U_LongLong operator+ (const ACE_U_LongLong &) const; + ACE_U_LongLong operator+ (const ACE_UINT32) const; + ACE_U_LongLong operator- (const ACE_U_LongLong &) const; + ACE_U_LongLong operator- (const ACE_UINT32) const; + ACE_U_LongLong operator* (const ACE_UINT32) const; + ACE_U_LongLong &operator*= (const ACE_UINT32); + + ACE_U_LongLong operator<< (const unsigned int) const; + ACE_U_LongLong &operator<<= (const unsigned int); + ACE_U_LongLong operator>> (const unsigned int) const; + ACE_U_LongLong &operator>>= (const unsigned int); + + double operator/ (const double) const; + + ACE_U_LongLong &operator+= (const ACE_U_LongLong &); + ACE_U_LongLong &operator+= (const ACE_UINT32); + ACE_U_LongLong &operator-= (const ACE_U_LongLong &); + ACE_U_LongLong &operator-= (const ACE_UINT32); + ACE_U_LongLong &operator++ (); + ACE_U_LongLong &operator-- (); + const ACE_U_LongLong operator++ (int); + const ACE_U_LongLong operator-- (int); + ACE_U_LongLong &operator|= (const ACE_U_LongLong); + ACE_U_LongLong &operator|= (const ACE_UINT32); + ACE_U_LongLong &operator&= (const ACE_U_LongLong); + ACE_U_LongLong &operator&= (const ACE_UINT32); + + // Note that the following take ACE_UINT32 arguments. These are + // typical use cases, and easy to implement. But, they limit the + // return values to 32 bits as well. There are no checks for + // overflow. + ACE_UINT32 operator/ (const ACE_UINT32) const; + ACE_UINT32 operator% (const ACE_UINT32) const; + + // The following only operate on the lower 32 bits (they take only + // 32 bit arguments). + ACE_UINT32 operator| (const ACE_INT32) const; + ACE_UINT32 operator& (const ACE_INT32) const; + + // The following operators convert their arguments to + // ACE_UINT32. So, there may be information loss if they are + // used. + ACE_U_LongLong operator* (const ACE_INT32) const; + ACE_U_LongLong &operator*= (const ACE_INT32); + ACE_UINT32 operator/ (const ACE_INT32) const; +# if ACE_SIZEOF_INT == 4 + ACE_UINT32 operator/ (const unsigned long) const; + ACE_UINT32 operator/ (const long) const; +# else /* ACE_SIZEOF_INT != 4 */ + ACE_UINT32 operator/ (const unsigned int) const; + ACE_UINT32 operator/ (const int) const; +# endif /* ACE_SIZEOF_INT != 4 */ + + // = Helper methods. + /// Outputs the value to the FILE, in hex. + void output (FILE * = stdout) const; + + ACE_TCHAR *as_string (ACE_TCHAR *string, + unsigned int base = 10, + unsigned int uppercase = 0) const; + + ACE_UINT32 hi (void) const; + ACE_UINT32 lo (void) const; + + void hi (const ACE_UINT32 hi); + void lo (const ACE_UINT32 lo); + +#if defined (ACE_LACKS_UNSIGNEDLONGLONG_T) + long long to_int64 (void) const; +# endif + + private: + +#if defined (ACE_LACKS_UNSIGNEDLONGLONG_T) + long long data_; +#else + public: + struct ace_hi_lo_correct_endian + { +# if defined (ACE_BIG_ENDIAN) + /// High 32 bits. + ACE_UINT32 hi_; + /// Low 32 bits. + ACE_UINT32 lo_; + +# else + + /// Low 32 bits. + ACE_UINT32 lo_; + /// High 32 bits. + ACE_UINT32 hi_; +# endif /* ! ACE_BIG_ENDIAN */ + }; + private: + union + { + struct ace_hi_lo_correct_endian data_; + + /// To ensure alignment on 8-byte boundary. + double for_alignment_; + }; + + // @note the following four accessors are inlined here in + // order to minimize the extent of the data_ struct. It's + // only used here; the .i and .cpp files use the accessors. + + /// Internal utility function to hide access through struct. + const ACE_UINT32 &h_ () const { return data_.hi_; } + + /// Internal utility function to hide access through struct. + ACE_UINT32 &h_ () { return data_.hi_; } + + /// Internal utility function to hide access through struct. + const ACE_UINT32 &l_ () const { return data_.lo_; } + + /// Internal utility function to hide access through struct. + ACE_UINT32 &l_ () { return data_.lo_; } + + // @note the above four accessors are inlined here in + // order to minimize the extent of the data_ struct. It's + // only used here; the .inl and .cpp files use the accessors. + + /// These functions are used to implement multiplication. + ACE_UINT32 ul_shift (ACE_UINT32 a, + ACE_UINT32 c_in, + ACE_UINT32 *c_out) const; + ACE_U_LongLong ull_shift (ACE_U_LongLong a, + ACE_UINT32 c_in, + ACE_UINT32 *c_out) const; + ACE_U_LongLong ull_add (ACE_U_LongLong a, + ACE_U_LongLong b, + ACE_UINT32 *carry) const; + ACE_U_LongLong ull_mult (ACE_U_LongLong a, + ACE_UINT32 b, + ACE_UINT32 *carry) const; +#endif // ACE_LACKS_UNSIGNEDLONGLONG_T + }; + + typedef ACE_U_LongLong ACE_UINT64; + +#if !defined (ACE_LACKS_IOSTREAM_TOTALLY) + ostream &operator<< (ostream &, const ACE_U_LongLong &); +#endif /* ! ACE_LACKS_IOSTREAM_TOTALLY */ + +ACE_END_VERSIONED_NAMESPACE_DECL + +# endif /* ACE_LACKS_LONGLONG_T */ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +// Conversions from ACE_UINT64 to ACE_UINT32. ACE_CU64_TO_CU32 should +// be used on const ACE_UINT64's. +# if defined (ACE_LACKS_LONGLONG_T) || defined (ACE_LACKS_UNSIGNEDLONGLONG_T) +inline ACE_UINT32 +ACE_U64_TO_U32 (ACE_U_LongLong const & n) +{ + /** + * @note We could add a cast operator to ACE_U_LongLong but that may + * cause more problems than it solves. Force users to perform + * an explicit cast via ACE_{C}U64_TO_{C}U32. + */ + return n.lo (); +} + +inline ACE_UINT32 +ACE_CU64_TO_CU32 (ACE_U_LongLong const & n) +{ + return ACE_U64_TO_U32 (n); +} +# else /* ! ACE_LACKS_LONGLONG_T */ +inline ACE_UINT32 +ACE_U64_TO_U32 (ACE_UINT64 n) +{ + return static_cast (n); +} + +inline ACE_UINT32 +ACE_CU64_TO_CU32 (ACE_UINT64 n) +{ + return static_cast (n); +} +# endif /* ! ACE_LACKS_LONGLONG_T */ + +ACE_END_VERSIONED_NAMESPACE_DECL + +// 64-bit literals require special marking on some platforms. +# if defined (ACE_LACKS_LONGLONG_T) + // Can only specify 32-bit arguments. +# define ACE_UINT64_LITERAL(n) n ## UL + // This one won't really work, but it'll keep + // some compilers happy until we have better support +# define ACE_INT64_LITERAL(n) n ## L +# elif defined (ACE_WIN32) +# if defined (__MINGW32__) +# define ACE_UINT64_LITERAL(n) n ## ull +# define ACE_INT64_LITERAL(n) n ## ll +# else +# define ACE_UINT64_LITERAL(n) n ## ui64 +# define ACE_INT64_LITERAL(n) n ## i64 +# endif /* defined (__MINGW32__) */ +# elif defined (__TANDEM) +# define ACE_UINT64_LITERAL(n) n ## LL +# define ACE_INT64_LITERAL(n) n ## LL +# else /* ! ACE_WIN32 && ! ACE_LACKS_LONGLONG_T */ +# define ACE_UINT64_LITERAL(n) n ## ull +# define ACE_INT64_LITERAL(n) n ## ll +# endif /* ! ACE_WIN32 && ! ACE_LACKS_LONGLONG_T */ + +#if !defined (ACE_INT8_FORMAT_SPECIFIER) +# if defined (PRId8) +# define ACE_INT8_FORMAT_SPECIFIER ACE_TEXT ("%") ACE_TEXT (PRId8) +# else +# define ACE_INT8_FORMAT_SPECIFIER ACE_TEXT ("%d") +# endif /* defined (PRId8) */ +#endif /* ACE_INT8_FORMAT_SPECIFIER */ + +#if !defined (ACE_UINT8_FORMAT_SPECIFIER) +# if defined (PRIu8) +# define ACE_UINT8_FORMAT_SPECIFIER ACE_TEXT ("%") ACE_TEXT (PRIu8) +# else +# define ACE_UINT8_FORMAT_SPECIFIER ACE_TEXT ("%u") +# endif /* defined (PRIu8) */ +#endif /* ACE_UINT8_FORMAT_SPECIFIER */ + +#if !defined (ACE_INT16_FORMAT_SPECIFIER) +# if defined (PRId16) +# define ACE_INT16_FORMAT_SPECIFIER ACE_TEXT ("%") ACE_TEXT (PRId16) +# else +# define ACE_INT16_FORMAT_SPECIFIER ACE_TEXT ("%d") +# endif /* defined (PRId16) */ +#endif /* ACE_INT16_FORMAT_SPECIFIER */ + +#if !defined (ACE_UINT16_FORMAT_SPECIFIER) +# if defined (PRIu16) +# define ACE_UINT16_FORMAT_SPECIFIER ACE_TEXT ("%") ACE_TEXT (PRIu16) +# else +# define ACE_UINT16_FORMAT_SPECIFIER ACE_TEXT ("%u") +# endif /* defined (PRIu16) */ +#endif /* ACE_UINT16_FORMAT_SPECIFIER */ + +#if !defined (ACE_INT32_FORMAT_SPECIFIER) +# if defined (PRId32) +# define ACE_INT32_FORMAT_SPECIFIER ACE_TEXT ("%") ACE_TEXT (PRId32) +# elif ACE_SIZEOF_INT == 4 +# define ACE_INT32_FORMAT_SPECIFIER ACE_TEXT ("%d") +# else +# define ACE_INT32_FORMAT_SPECIFIER ACE_TEXT ("%ld") +# endif /* defined (PRId32) */ +#endif /* ACE_INT32_FORMAT_SPECIFIER */ + +#if !defined (ACE_UINT32_FORMAT_SPECIFIER) +# if defined (PRIu32) +# define ACE_UINT32_FORMAT_SPECIFIER ACE_TEXT ("%") ACE_TEXT (PRIu32) +# elif ACE_SIZEOF_INT == 4 +# define ACE_UINT32_FORMAT_SPECIFIER ACE_TEXT ("%u") +# else +# define ACE_UINT32_FORMAT_SPECIFIER ACE_TEXT ("%lu") +# endif /* defined (PRIu32) */ +#endif /* ACE_UINT32_FORMAT_SPECIFIER */ + +#if !defined (ACE_INT64_FORMAT_SPECIFIER) +# if defined (PRId64) +# define ACE_INT64_FORMAT_SPECIFIER ACE_TEXT ("%") ACE_TEXT (PRId64) +# elif ACE_SIZEOF_LONG == 8 +# define ACE_INT64_FORMAT_SPECIFIER ACE_TEXT ("%ld") +# else +# define ACE_INT64_FORMAT_SPECIFIER ACE_TEXT ("%lld") +# endif /* defined (PRId64) */ +#endif /* ACE_INT64_FORMAT_SPECIFIER */ + +#if !defined (ACE_UINT64_FORMAT_SPECIFIER) +# if defined (PRIu64) +# define ACE_UINT64_FORMAT_SPECIFIER ACE_TEXT ("%") ACE_TEXT (PRIu64) +# elif ACE_SIZEOF_LONG == 8 +# define ACE_UINT64_FORMAT_SPECIFIER ACE_TEXT ("%lu") +# else +# define ACE_UINT64_FORMAT_SPECIFIER ACE_TEXT ("%llu") +# endif /* defined (PRIu64) */ +#endif /* ACE_UINT64_FORMAT_SPECIFIER */ + +#if !defined (ACE_SSIZE_T_FORMAT_SPECIFIER) +# if defined (ACE_WIN64) +# define ACE_SSIZE_T_FORMAT_SPECIFIER ACE_TEXT ("%I64d") +# else +# define ACE_SSIZE_T_FORMAT_SPECIFIER ACE_TEXT ("%d") +# endif /* ACE_WIN64 */ +#endif /* ACE_SSIZE_T_FORMAT_SPECIFIER */ + +#if !defined (ACE_SIZE_T_FORMAT_SPECIFIER) +# if defined (ACE_WIN64) +# define ACE_SIZE_T_FORMAT_SPECIFIER ACE_TEXT ("%I64u") +# else +# define ACE_SIZE_T_FORMAT_SPECIFIER ACE_TEXT ("%u") +# endif /* ACE_WIN64 */ +#endif /* ACE_SIZE_T_FORMAT_SPECIFIER */ + +// Cast from UINT64 to a double requires an intermediate cast to INT64 +// on some platforms. +# if defined (ACE_LACKS_LONGLONG_T) + // Only use the low 32 bits. +# define ACE_UINT64_DBLCAST_ADAPTER(n) ACE_U64_TO_U32 (n) +# elif defined (ACE_LACKS_UNSIGNEDLONGLONG_T) +# define ACE_UINT64_DBLCAST_ADAPTER(n) ((n).to_int64 ()) +# elif defined (ACE_WIN32) +# define ACE_UINT64_DBLCAST_ADAPTER(n) static_cast<__int64> (n) +# else /* ! ACE_WIN32 && ! ACE_LACKS_LONGLONG_T */ +# define ACE_UINT64_DBLCAST_ADAPTER(n) (n) +# endif /* ! ACE_WIN32 && ! ACE_LACKS_LONGLONG_T */ + + +// The number of bytes in a float. +# ifndef ACE_SIZEOF_FLOAT +# if FLT_MAX_EXP == 128 +# define ACE_SIZEOF_FLOAT 4 +# elif FLT_MAX_EXP == 1024 +# define ACE_SIZEOF_FLOAT 8 +# else +# error: unsupported float size, must be updated for this platform! +# endif /* FLT_MAX_EXP */ +# endif /* ACE_SIZEOF_FLOAT */ + +// The number of bytes in a double. +# ifndef ACE_SIZEOF_DOUBLE +# if DBL_MAX_EXP == 128 +# define ACE_SIZEOF_DOUBLE 4 +# elif DBL_MAX_EXP == 1024 +# define ACE_SIZEOF_DOUBLE 8 +# else +# error: unsupported double size, must be updated for this platform! +# endif /* DBL_MAX_EXP */ +# endif /* ACE_SIZEOF_DOUBLE */ + +// The number of bytes in a long double. +# ifndef ACE_SIZEOF_LONG_DOUBLE +# if LDBL_MAX_EXP == 128 +# define ACE_SIZEOF_LONG_DOUBLE 4 +# elif LDBL_MAX_EXP == 1024 +# define ACE_SIZEOF_LONG_DOUBLE 8 +# elif LDBL_MAX_EXP == 16384 +# if defined (LDBL_DIG) && LDBL_DIG == 18 +# if defined (__ia64) || defined (__x86_64) +# define ACE_SIZEOF_LONG_DOUBLE 16 +# else /* ! __ia64 */ +# define ACE_SIZEOF_LONG_DOUBLE 12 +# endif /* __ia64 */ +# else /* ! LDBL_DIG || LDBL_DIG != 18 */ +# define ACE_SIZEOF_LONG_DOUBLE 16 +# endif /* ! LDBL_DIG || LDBL_DIG != 18 */ +# else +# error: unsupported double size, must be updated for this platform! +# endif /* LDBL_MAX_EXP */ +# endif /* ACE_SIZEOF_LONG_DOUBLE */ + +// Max and min sizes for the ACE integer types. +#define ACE_CHAR_MAX 0x7F +#define ACE_CHAR_MIN -(ACE_CHAR_MAX)-1 +#define ACE_OCTET_MAX 0xFF +#define ACE_INT16_MAX 0x7FFF +#define ACE_INT16_MIN -(ACE_INT16_MAX)-1 +#define ACE_UINT16_MAX 0xFFFF +#define ACE_WCHAR_MAX ACE_UINT16_MAX +#define ACE_INT32_MAX 0x7FFFFFFF +#define ACE_INT32_MIN -(ACE_INT32_MAX)-1 +#define ACE_UINT32_MAX 0xFFFFFFFF +#define ACE_INT64_MAX ACE_INT64_LITERAL(0x7FFFFFFFFFFFFFFF) +#define ACE_INT64_MIN -(ACE_INT64_MAX)-1 + +#if defined (ACE_LACKS_UNSIGNEDLONGLONG_T) +// ACE_U_LongLong's constructor accepts a "long long" in this +// case. Set it to ACE_U_LongLong (-1) since the bit pattern for long +// long (-1) is the same as the maximum unsigned long long value. +# define ACE_UINT64_MAX ACE_U_LongLong (ACE_INT64_LITERAL (0xFFFFFFFFFFFFFFFF)) +#elif defined (ACE_LACKS_LONGLONG_T) +// ACE_U_LongLong's constructor accepts an ACE_UINT32 low and high +// pair of parameters. +# define ACE_UINT64_MAX ACE_U_LongLong (0xFFFFFFFFu, 0xFFFFFFFFu) +#else +# define ACE_UINT64_MAX ACE_UINT64_LITERAL (0xFFFFFFFFFFFFFFFF) +#endif /* ACE_LACKS_UNSIGNEDLONGLONG_T */ + +// These use ANSI/IEEE format. +#define ACE_FLT_MAX 3.402823466e+38F +#define ACE_FLT_MIN 1.175494351e-38F +#define ACE_DBL_MAX 1.7976931348623158e+308 +#define ACE_DBL_MIN 2.2250738585072014e-308 + +# if defined (__ACE_INLINE__) +# include "ace/Basic_Types.inl" +# endif /* __ACE_INLINE__ */ + +# include /**/ "ace/post.h" +#endif /* ACE_BASIC_TYPES_H */ diff --git a/dep/ACE_wrappers/ace/Basic_Types.inl b/dep/ACE_wrappers/ace/Basic_Types.inl new file mode 100644 index 00000000000..c6f0013d45e --- /dev/null +++ b/dep/ACE_wrappers/ace/Basic_Types.inl @@ -0,0 +1,954 @@ +// -*- C++ -*- +// +// $Id: Basic_Types.inl 80826 2008-03-04 14:51:23Z wotte $ + +# if !defined (ACE_LACKS_LONGLONG_T) && defined (ACE_LACKS_UNSIGNEDLONGLONG_T) + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +// Implementation for ACE_U_LongLong when we have signed long long +// but no unsigned long long. + +ACE_INLINE +ACE_U_LongLong::ACE_U_LongLong (const long long value) + : data_ (value) +{ +} + +ACE_INLINE ACE_UINT32 +ACE_U_LongLong::hi (void) const +{ + return (data_ >> 32) & 0xFFFFFFFF; +} + +ACE_INLINE ACE_UINT32 +ACE_U_LongLong::lo (void) const +{ + return data_ & 0xFFFFFFFF; +} + +ACE_INLINE void +ACE_U_LongLong::hi (const ACE_UINT32 hi) +{ + data_ = hi; + data_ <<= 32; +} + +ACE_INLINE void +ACE_U_LongLong::lo (const ACE_UINT32 lo) +{ + data_ = lo; +} + +ACE_INLINE long long +ACE_U_LongLong::to_int64 (void) const +{ + return data_; +} + +ACE_INLINE +ACE_U_LongLong::~ACE_U_LongLong (void) +{ +} + +ACE_INLINE bool +ACE_U_LongLong::operator== (const ACE_U_LongLong &n) const +{ + return data_ == n.data_; +} + +ACE_INLINE bool +ACE_U_LongLong::operator== (const ACE_UINT32 n) const +{ + return data_ == n; +} + +ACE_INLINE bool +ACE_U_LongLong::operator!= (const ACE_U_LongLong &n) const +{ + return ! (*this == n); +} + +ACE_INLINE bool +ACE_U_LongLong::operator!= (const ACE_UINT32 n) const +{ + return ! (*this == n); +} + +ACE_INLINE bool +ACE_U_LongLong::operator< (const ACE_U_LongLong &n) const +{ + if (data_ > 0) + if (n.data_ > 0) + return data_ < n.data_; + else + return true; + else + if (n.data_ > 0) + return false; + else + return data_ < n.data_; +} + +ACE_INLINE bool +ACE_U_LongLong::operator< (const ACE_UINT32 n) const +{ + return operator< (static_cast (n)); +} + +ACE_INLINE bool +ACE_U_LongLong::operator<= (const ACE_U_LongLong &n) const +{ + if (data_ == n.data_) return true; + + return data_ < n.data_; +} + +ACE_INLINE bool +ACE_U_LongLong::operator<= (const ACE_UINT32 n) const +{ + return operator<= (static_cast (n)); +} + +ACE_INLINE bool +ACE_U_LongLong::operator> (const ACE_U_LongLong &n) const +{ + if (data_ > 0) + if (n.data_ > 0) + return data_ > n.data_; + else + return false; + else + if (n.data_ > 0) + return true; + else + return data_ > n.data_; +} + +ACE_INLINE bool +ACE_U_LongLong::operator> (const ACE_UINT32 n) const +{ + return operator> (static_cast (n)); +} + +ACE_INLINE bool +ACE_U_LongLong::operator>= (const ACE_U_LongLong &n) const +{ + if (data_ == n.data_) return true; + + return data_ > n.data_; +} + +ACE_INLINE bool +ACE_U_LongLong::operator>= (const ACE_UINT32 n) const +{ + return operator>= (static_cast (n)); +} + +ACE_INLINE +ACE_U_LongLong::ACE_U_LongLong (const ACE_U_LongLong &n) + : data_ (n.data_) +{ +} + +ACE_INLINE ACE_U_LongLong & +ACE_U_LongLong::operator= (const ACE_U_LongLong &n) +{ + data_ = n.data_; + + return *this; +} + +ACE_INLINE ACE_U_LongLong & +ACE_U_LongLong::operator= (const ACE_INT32 &rhs) +{ + if (rhs >= 0) + { + data_ = rhs; + data_ &= 0xFFFFFFFF; + } + else + { + // We do not handle the case where a negative 32 bit integer is + // assigned to this representation of a 64 bit unsigned integer. + // The "undefined behavior" behavior performed by this + // implementation is to simply set all bits to zero. + data_ = 0; + } + + return *this; +} + +ACE_INLINE ACE_U_LongLong & +ACE_U_LongLong::operator= (const ACE_UINT32 &rhs) +{ + data_ = rhs; + + return *this; +} + + +ACE_INLINE ACE_U_LongLong +ACE_U_LongLong::operator+ (const ACE_U_LongLong &n) const +{ + return data_ + n.data_; +} + +ACE_INLINE ACE_U_LongLong +ACE_U_LongLong::operator+ (const ACE_UINT32 n) const +{ + return operator+ (static_cast (n)); +} + +ACE_INLINE ACE_U_LongLong +ACE_U_LongLong::operator- (const ACE_U_LongLong &n) const +{ + return data_ - n.data_; +} + +ACE_INLINE ACE_U_LongLong +ACE_U_LongLong::operator- (const ACE_UINT32 n) const +{ + return operator- (static_cast (n)); +} + +ACE_INLINE ACE_U_LongLong +ACE_U_LongLong::operator<< (const u_int n) const +{ + return data_ << n; +} + +ACE_INLINE ACE_U_LongLong & +ACE_U_LongLong::operator<<= (const u_int n) +{ + data_ <<= n; + + return *this; +} + +ACE_INLINE ACE_U_LongLong +ACE_U_LongLong::operator>> (const u_int n) const +{ + return data_ >> n; +} + +ACE_INLINE ACE_U_LongLong & +ACE_U_LongLong::operator>>= (const u_int n) +{ + data_ >>= n; + + return *this; +} + +ACE_INLINE double +ACE_U_LongLong::operator/ (const double n) const +{ + return data_ / n; +} + +ACE_INLINE ACE_U_LongLong & +ACE_U_LongLong::operator+= (const ACE_U_LongLong &n) +{ + data_ += n.data_; + + return *this; +} + +ACE_INLINE ACE_U_LongLong & +ACE_U_LongLong::operator+= (const ACE_UINT32 n) +{ + return operator+= (static_cast (n)); +} + +ACE_INLINE ACE_U_LongLong +ACE_U_LongLong::operator* (const ACE_UINT32 n) const +{ + return data_ * n; +} + +ACE_INLINE ACE_U_LongLong & +ACE_U_LongLong::operator*= (const ACE_UINT32 n) +{ + data_ *= n; + + return *this; +} + +ACE_INLINE ACE_U_LongLong & +ACE_U_LongLong::operator-= (const ACE_U_LongLong &n) +{ + data_ -= n.data_; + + return *this; +} + +ACE_INLINE ACE_U_LongLong & +ACE_U_LongLong::operator-= (const ACE_UINT32 n) +{ + return operator-= (static_cast (n)); +} + +ACE_INLINE ACE_U_LongLong & +ACE_U_LongLong::operator++ () +{ + ++data_; + + return *this; +} + +ACE_INLINE ACE_U_LongLong & +ACE_U_LongLong::operator-- () +{ + --data_; + + return *this; +} + +ACE_INLINE const ACE_U_LongLong +ACE_U_LongLong::operator++ (int) +{ + // Post-increment operator should always be implemented in terms of + // the pre-increment operator to enforce consistent semantics. + ACE_U_LongLong temp (*this); + ++*this; + return temp; +} + +ACE_INLINE const ACE_U_LongLong +ACE_U_LongLong::operator-- (int) +{ + // Post-decrement operator should always be implemented in terms of + // the pre-decrement operator to enforce consistent semantics. + ACE_U_LongLong temp (*this); + --*this; + return temp; +} + +ACE_INLINE ACE_U_LongLong & +ACE_U_LongLong::operator|= (const ACE_U_LongLong n) +{ + data_ |= n.data_; + + return *this; +} + +ACE_INLINE ACE_U_LongLong & +ACE_U_LongLong::operator|= (const ACE_UINT32 n) +{ + return operator|= (static_cast (n)); +} + +ACE_INLINE ACE_U_LongLong & +ACE_U_LongLong::operator&= (const ACE_U_LongLong n) +{ + data_ &= n.data_; + + return *this; +} + +ACE_INLINE ACE_U_LongLong & +ACE_U_LongLong::operator&= (const ACE_UINT32 n) +{ + return operator&= (static_cast (n)); +} + +ACE_INLINE ACE_UINT32 +ACE_U_LongLong::operator/ (const ACE_UINT32 n) const +{ + return data_ / n; +} + +ACE_INLINE ACE_UINT32 +ACE_U_LongLong::operator% (const ACE_UINT32 n) const +{ + return data_ % n; +} + +ACE_INLINE ACE_UINT32 +ACE_U_LongLong::operator| (const ACE_INT32 n) const +{ + return data_ | n; +} + +ACE_INLINE ACE_UINT32 +ACE_U_LongLong::operator& (const ACE_INT32 n) const +{ + return data_ & n; +} + +ACE_INLINE ACE_U_LongLong +ACE_U_LongLong::operator* (const ACE_INT32 n) const +{ + return operator* ((ACE_UINT32) n); +} + +ACE_INLINE ACE_U_LongLong & +ACE_U_LongLong::operator*= (const ACE_INT32 n) +{ + return operator*= ((ACE_UINT32) n); +} + +ACE_INLINE ACE_UINT32 +ACE_U_LongLong::operator/ (const ACE_INT32 n) const +{ + return operator/ ((ACE_UINT32) n); +} + +#if ACE_SIZEOF_INT == 4 +ACE_INLINE ACE_UINT32 +ACE_U_LongLong::operator/ (const u_long n) const +{ + return operator/ ((ACE_UINT32) n); +} + +ACE_INLINE ACE_UINT32 +ACE_U_LongLong::operator/ (const long n) const +{ + return operator/ ((ACE_UINT32) n); +} + +#else /* ACE_SIZEOF_INT != 4 */ +ACE_INLINE ACE_UINT32 +ACE_U_LongLong::operator/ (const u_int n) const +{ + return operator/ ((ACE_UINT32) n); +} + +ACE_INLINE ACE_UINT32 +ACE_U_LongLong::operator/ (const int n) const +{ + return operator/ ((ACE_UINT32) n); +} +#endif + +ACE_END_VERSIONED_NAMESPACE_DECL + +#elif defined (ACE_LACKS_LONGLONG_T) + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_INLINE +ACE_U_LongLong::ACE_U_LongLong (const ACE_UINT32 lo, const ACE_UINT32 hi) +{ + h_ () = hi; + l_ () = lo; +} + +ACE_INLINE ACE_UINT32 +ACE_U_LongLong::hi (void) const +{ + return h_ (); +} + +ACE_INLINE ACE_UINT32 +ACE_U_LongLong::lo (void) const +{ + return l_ (); +} + +ACE_INLINE void +ACE_U_LongLong::hi (const ACE_UINT32 hi) +{ + h_ () = hi; +} + +ACE_INLINE void +ACE_U_LongLong::lo (const ACE_UINT32 lo) +{ + l_ () = lo; +} + +ACE_INLINE +ACE_U_LongLong::~ACE_U_LongLong (void) +{ +} + +ACE_INLINE bool +ACE_U_LongLong::operator== (const ACE_U_LongLong &n) const +{ + return h_ () == n.h_ () && l_ () == n.l_ (); +} + +ACE_INLINE bool +ACE_U_LongLong::operator== (const ACE_UINT32 n) const +{ + return h_ () == 0 && l_ () == n; +} + +ACE_INLINE bool +ACE_U_LongLong::operator!= (const ACE_U_LongLong &n) const +{ + return ! (*this == n); +} + +ACE_INLINE bool +ACE_U_LongLong::operator!= (const ACE_UINT32 n) const +{ + return ! (*this == n); +} + +ACE_INLINE bool +ACE_U_LongLong::operator< (const ACE_U_LongLong &n) const +{ + return h_ () < n.h_ () ? 1 + : h_ () > n.h_ () ? 0 + : l_ () < n.l_ (); +} + +ACE_INLINE bool +ACE_U_LongLong::operator< (const ACE_UINT32 n) const +{ + return operator< (static_cast (n)); +} + +ACE_INLINE bool +ACE_U_LongLong::operator<= (const ACE_U_LongLong &n) const +{ + return h_ () < n.h_ () ? 1 + : h_ () > n.h_ () ? 0 + : l_ () <= n.l_ (); +} + +ACE_INLINE bool +ACE_U_LongLong::operator<= (const ACE_UINT32 n) const +{ + return operator<= (static_cast (n)); +} + +ACE_INLINE bool +ACE_U_LongLong::operator> (const ACE_U_LongLong &n) const +{ + return h_ () > n.h_ () ? 1 + : h_ () < n.h_ () ? 0 + : l_ () > n.l_ (); +} + +ACE_INLINE bool +ACE_U_LongLong::operator> (const ACE_UINT32 n) const +{ + return operator> (static_cast (n)); +} + +ACE_INLINE bool +ACE_U_LongLong::operator>= (const ACE_U_LongLong &n) const +{ + return h_ () > n.h_ () ? 1 + : h_ () < n.h_ () ? 0 + : l_ () >= n.l_ (); +} + +ACE_INLINE bool +ACE_U_LongLong::operator>= (const ACE_UINT32 n) const +{ + return operator>= (static_cast (n)); +} + +ACE_INLINE +ACE_U_LongLong::ACE_U_LongLong (const ACE_U_LongLong &n) +{ + h_ () = n.h_ (); + l_ () = n.l_ (); +} + +ACE_INLINE ACE_U_LongLong & +ACE_U_LongLong::operator= (const ACE_U_LongLong &n) +{ + h_ () = n.h_ (); + l_ () = n.l_ (); + + return *this; +} + +ACE_INLINE ACE_U_LongLong & +ACE_U_LongLong::operator= (const ACE_INT32 &rhs) +{ + if (rhs >= 0) + { + l_ () = static_cast (rhs); + h_ () = 0; + } + else + { + // We do not handle the case where a negative 32 bit integer is + // assigned to this representation of a 64 bit unsigned integer. + // The "undefined behavior" behavior performed by this + // implementation is to simply set all bits to zero. + l_ () = 0; + h_ () = 0; + } + + return *this; +} + +ACE_INLINE ACE_U_LongLong & +ACE_U_LongLong::operator= (const ACE_UINT32 &rhs) +{ + l_ () = rhs; + h_ () = 0; + + return *this; +} + + +ACE_INLINE ACE_U_LongLong +ACE_U_LongLong::operator+ (const ACE_U_LongLong &n) const +{ + ACE_U_LongLong ret (l_ () + n.l_ (), h_ () + n.h_ ()); + if (ret.l_ () < n.l_ ()) /* carry */ ++ret.h_ (); + + return ret; +} + +ACE_INLINE ACE_U_LongLong +ACE_U_LongLong::operator+ (const ACE_UINT32 n) const +{ + return operator+ (static_cast (n)); +} + +ACE_INLINE ACE_U_LongLong +ACE_U_LongLong::operator- (const ACE_U_LongLong &n) const +{ + ACE_U_LongLong ret (l_ () - n.l_ (), h_ () - n.h_ ()); + if (l_ () < n.l_ ()) /* borrow */ --ret.h_ (); + + return ret; +} + +ACE_INLINE ACE_U_LongLong +ACE_U_LongLong::operator- (const ACE_UINT32 n) const +{ + return operator- (static_cast (n)); +} + +ACE_INLINE ACE_U_LongLong +ACE_U_LongLong::operator<< (const u_int n) const +{ + const ACE_UINT32 carry_mask = l_ () >> (32 - n); + ACE_U_LongLong ret (n < 32 ? l_ () << n : 0, + n < 32 ? (h_ () << n) | carry_mask : carry_mask); + + return ret; +} + +ACE_INLINE ACE_U_LongLong & +ACE_U_LongLong::operator<<= (const u_int n) +{ + const ACE_UINT32 carry_mask = l_ () >> (32 - n); + h_ () = n < 32 ? (h_ () << n) | carry_mask : carry_mask; + + // g++ 2.7.2.3/Solaris 2.5.1 doesn't modify l_ () if shifted by 32. + l_ () = n < 32 ? l_ () << n : 0; + + return *this; +} + +ACE_INLINE ACE_U_LongLong +ACE_U_LongLong::operator>> (const u_int n) const +{ + const ACE_UINT32 carry_mask = h_ () << (32 - n); + ACE_U_LongLong ret (n < 32 ? (l_ () >> n) | carry_mask : 0, + n < 32 ? h_ () >> n : 0); + + return ret; +} + +ACE_INLINE ACE_U_LongLong & +ACE_U_LongLong::operator>>= (const u_int n) +{ + const ACE_UINT32 carry_mask = h_ () << (32 - n); + l_ () = n < 32 ? (l_ () >> n) | carry_mask : carry_mask; + h_ () = n < 32 ? h_ () >> n : 0; + + return *this; +} + +ACE_INLINE double +ACE_U_LongLong::operator/ (const double n) const +{ + // See the derivation above in operator/ (const ACE_UINT32). + + return ((double) 0xffffffffu - n + 1.0) / n * h_ () + + (double) h_ () + (double) l_ () / n; +} + +ACE_INLINE ACE_U_LongLong & +ACE_U_LongLong::operator+= (const ACE_U_LongLong &n) +{ + h_ () += n.h_ (); + l_ () += n.l_ (); + if (l_ () < n.l_ ()) /* carry */ ++h_ (); + + return *this; +} + +ACE_INLINE ACE_U_LongLong & +ACE_U_LongLong::operator+= (const ACE_UINT32 n) +{ + return operator+= (static_cast (n)); +} + +#define ACE_HIGHBIT (~(~0UL >> 1)) + +ACE_INLINE ACE_UINT32 +ACE_U_LongLong::ul_shift (ACE_UINT32 a, ACE_UINT32 c_in, ACE_UINT32 *c_out) const +{ + const ACE_UINT32 b = (a << 1) | c_in; + *c_out = (*c_out << 1) + ((a & ACE_HIGHBIT) > 0); + + return b; +} + +ACE_INLINE ACE_U_LongLong +ACE_U_LongLong::ull_shift (ACE_U_LongLong a, + ACE_UINT32 c_in, + ACE_UINT32 *c_out) const +{ + ACE_U_LongLong b; + + b.l_ () = (a.l_ () << 1) | c_in; + c_in = ((a.l_ () & ACE_HIGHBIT) > 0); + b.h_ () = (a.h_ () << 1) | c_in; + *c_out = (*c_out << 1) + ((a.h_ () & ACE_HIGHBIT) > 0); + + return b; +} + +ACE_INLINE ACE_U_LongLong +ACE_U_LongLong::ull_add (ACE_U_LongLong a, ACE_U_LongLong b, ACE_UINT32 *carry) const +{ + ACE_U_LongLong r (0, 0); + ACE_UINT32 c1, c2, c3, c4; + + c1 = a.l_ () % 2; + c2 = b.l_ () % 2; + c3 = 0; + + r.l_ () = a.l_ ()/2 + b.l_ ()/2 + (c1+c2)/2; + r.l_ () = ul_shift (r.l_ (), (c1+c2)%2, &c3); + + c1 = a.h_ () % 2; + c2 = b.h_ () % 2; + c4 = 0; + + r.h_ () = a.h_ ()/2 + b.h_ ()/2 + (c1+c2+c3)/2; + r.h_ () = ul_shift (r.h_ (), (c1+c2+c3)%2, &c4); + + *carry = c4; + + return r; +} + +ACE_INLINE ACE_U_LongLong +ACE_U_LongLong::ull_mult (ACE_U_LongLong a, ACE_UINT32 b, ACE_UINT32 *carry) const +{ + register ACE_UINT32 mask = ACE_HIGHBIT; + const ACE_U_LongLong zero (0, 0); + ACE_U_LongLong accum (0, 0); + ACE_UINT32 c; + + *carry = 0; + if (b > 0) + do + { + accum = ull_shift (accum, 0U, carry); + if (b & mask) + accum = ull_add (accum, a, &c); + else + accum = ull_add (accum, zero, &c); + *carry += c; + mask >>= 1; + } + while (mask > 0); + + return accum; +} + +ACE_INLINE ACE_U_LongLong +ACE_U_LongLong::operator* (const ACE_UINT32 n) const +{ + ACE_UINT32 carry; // will throw the carry away + + return ull_mult (*this, n, &carry); +} + +ACE_INLINE ACE_U_LongLong & +ACE_U_LongLong::operator*= (const ACE_UINT32 n) +{ + ACE_UINT32 carry; // will throw the carry away + + return *this = ull_mult (*this, n, &carry); +} + +ACE_INLINE ACE_U_LongLong & +ACE_U_LongLong::operator-= (const ACE_U_LongLong &n) +{ + h_ () -= n.h_ (); + if (l_ () < n.l_ ()) /* borrow */ --h_ (); + l_ () -= n.l_ (); + + return *this; +} + +ACE_INLINE ACE_U_LongLong & +ACE_U_LongLong::operator-= (const ACE_UINT32 n) +{ + return operator-= (static_cast (n)); +} + +ACE_INLINE ACE_U_LongLong & +ACE_U_LongLong::operator++ () +{ + ++l_ (); + if (l_ () == 0) /* carry */ ++h_ (); + + return *this; +} + +ACE_INLINE ACE_U_LongLong & +ACE_U_LongLong::operator-- () +{ + if (l_ () == 0) /* borrow */ --h_ (); + --l_ (); + + return *this; +} + +ACE_INLINE const ACE_U_LongLong +ACE_U_LongLong::operator++ (int) +{ + // Post-increment operator should always be implemented in terms of + // the pre-increment operator to enforce consistent semantics. + ACE_U_LongLong temp (*this); + ++*this; + return temp; +} + +ACE_INLINE const ACE_U_LongLong +ACE_U_LongLong::operator-- (int) +{ + // Post-decrement operator should always be implemented in terms of + // the pre-decrement operator to enforce consistent semantics. + ACE_U_LongLong temp (*this); + --*this; + return temp; +} + +ACE_INLINE ACE_U_LongLong & +ACE_U_LongLong::operator|= (const ACE_U_LongLong n) +{ + l_ () |= n.l_ (); + h_ () |= n.h_ (); + + return *this; +} + +ACE_INLINE ACE_U_LongLong & +ACE_U_LongLong::operator|= (const ACE_UINT32 n) +{ + return operator|= (static_cast (n)); +} + +ACE_INLINE ACE_U_LongLong & +ACE_U_LongLong::operator&= (const ACE_U_LongLong n) +{ + l_ () &= n.l_ (); + h_ () &= n.h_ (); + + return *this; +} + +ACE_INLINE ACE_U_LongLong & +ACE_U_LongLong::operator&= (const ACE_UINT32 n) +{ + return operator&= (static_cast (n)); +} + +ACE_INLINE ACE_UINT32 +ACE_U_LongLong::operator/ (const ACE_UINT32 n) const +{ + // This takes advantage of the fact that the return type has only 32 + // bits. Replace 0x100000000 with 0xffffffff + 1 because the former + // has 33 bits. + // Quotient = (0x100000000u * hi_ + lo_) / n + // = ((0x100000000u - n + n) * hi_ + lo_) / n + // = ((0x100000000u - n) / n * hi_ + hi_ * n / n + lo_ / n + // = (0x100000000u - n) / n * hi_ + hi_ + lo_ / n + // = (0xffffffffu - n + 1) / n * hi_ + hi_ + lo_ / n + + return (0xffffffffu - n + 1) / n * h_ () + h_ () + l_ () / n; +} + +ACE_INLINE ACE_UINT32 +ACE_U_LongLong::operator% (const ACE_UINT32 n) const +{ + // Because the argument is an ACE_UINT32, the result can never be + // bigger than 32 bits. Replace 0x100000000 with 0xffffffff + 1 + // because the former has 33 bits. + // Mod = (0x100000000u * hi_ + lo_) % n + // = (0x100000000u % n * hi_ + lo_ % n) % n + // = ((0x100000000u - n) % n * hi_ + lo_ % n) % n + // = ((0xffffffffu - n + 1) % n * hi_ + lo_ % n) % n + + return ((0xffffffff - n + 1) % n * h_ () + l_ () % n) % n; +} + +ACE_INLINE ACE_UINT32 +ACE_U_LongLong::operator| (const ACE_INT32 n) const +{ + return l_ () | n; +} + +ACE_INLINE ACE_UINT32 +ACE_U_LongLong::operator& (const ACE_INT32 n) const +{ + return l_ () & n; +} + +ACE_INLINE ACE_U_LongLong +ACE_U_LongLong::operator* (const ACE_INT32 n) const +{ + return operator* ((ACE_UINT32) n); +} + +ACE_INLINE ACE_U_LongLong & +ACE_U_LongLong::operator*= (const ACE_INT32 n) +{ + return operator*= ((ACE_UINT32) n); +} + +ACE_INLINE ACE_UINT32 +ACE_U_LongLong::operator/ (const ACE_INT32 n) const +{ + return operator/ ((ACE_UINT32) n); +} + +#if ACE_SIZEOF_INT == 4 +ACE_INLINE ACE_UINT32 +ACE_U_LongLong::operator/ (const u_long n) const +{ + return operator/ ((ACE_UINT32) n); +} + +ACE_INLINE ACE_UINT32 +ACE_U_LongLong::operator/ (const long n) const +{ + return operator/ ((ACE_UINT32) n); +} + +#else /* ACE_SIZEOF_INT != 4 */ +ACE_INLINE ACE_UINT32 +ACE_U_LongLong::operator/ (const u_int n) const +{ + return operator/ ((ACE_UINT32) n); +} + +ACE_INLINE ACE_UINT32 +ACE_U_LongLong::operator/ (const int n) const +{ + return operator/ ((ACE_UINT32) n); +} +#endif /* ACE_SIZEOF_INT != 4 */ + +ACE_END_VERSIONED_NAMESPACE_DECL + +#endif /* ACE_LACKS_LONGLONG_T || ACE_LACKS_UNSIGNEDLONGLONG_T */ diff --git a/dep/ACE_wrappers/ace/Bound_Ptr.h b/dep/ACE_wrappers/ace/Bound_Ptr.h new file mode 100644 index 00000000000..ec7384e0d6c --- /dev/null +++ b/dep/ACE_wrappers/ace/Bound_Ptr.h @@ -0,0 +1,388 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Bound_Ptr.h + * + * $Id: Bound_Ptr.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Christopher Kohlhoff + * @author Boris Kolpackov + */ +//============================================================================= + +#ifndef ACE_BOUND_PTR_H +#define ACE_BOUND_PTR_H + +#include /**/ "ace/pre.h" + +#include /**/ "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/Auto_Ptr.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +/** + * @class ACE_Bound_Ptr_Counter + * + * @brief An ACE_Bound_Ptr_Counter object encapsulates an + * object reference count. + * + * Do not use this class directly, use ACE_Strong_Bound_Ptr or + * ACE_Weak_Bound_Ptr instead. + */ +template +class ACE_Bound_Ptr_Counter +{ +public: + /// Declare the dynamic allocation hooks. + ACE_ALLOC_HOOK_DECLARE; + + ACE_Bound_Ptr_Counter (long init_obj_ref_count = 0); + ~ACE_Bound_Ptr_Counter (void); + + /// Create a ACE_Bound_Ptr_Counter and initialize the + /// reference count to indicate ownership by a strong pointer. + static ACE_Bound_Ptr_Counter *create_strong (void); + + /// Increase both the object and counter reference counts and return + /// the new object reference count. A return value of -1 indicates + /// that the object has already been destroyed. + static long attach_strong (ACE_Bound_Ptr_Counter *counter); + + /// Decreases both the object and counter reference counts and + /// deletes whichever has no more references. Returns the new object + /// reference count. + static long detach_strong (ACE_Bound_Ptr_Counter *counter); + + /// Create a ACE_Bound_Ptr_Counter and initialize the + /// reference count to indicate no ownership. + static ACE_Bound_Ptr_Counter *create_weak (void); + + /// Increase the counter reference count and return argument. + static void attach_weak (ACE_Bound_Ptr_Counter *counter); + + /// Decreases the counter reference count and deletes the counter if + /// it has no more references. + static void detach_weak (ACE_Bound_Ptr_Counter *counter); + + /// Determine whether the object has been deleted. + static bool object_was_deleted (ACE_Bound_Ptr_Counter *counter); + +private: + + /// Allocate a new ACE_Bound_Ptr_Counter instance, + /// returning NULL if it cannot be created. + static ACE_Bound_Ptr_Counter *internal_create (long init_obj_ref_count); + +private: + + /// Reference count of underlying object. Is set to -1 once the + /// object has been destroyed to indicate to all weak pointers that + /// it is no longer valid. + long obj_ref_count_; + + /// Reference count of this counter. + long self_ref_count_; + + /// Mutex variable to synchronize access to the reference counts. + ACE_LOCK lock_; +}; + +// Forward decl. +template class ACE_Weak_Bound_Ptr; + +/** + * @class ACE_Strong_Bound_Ptr + * + * @brief This class implements support for a reference counted + * pointer. + * + * Assigning or copying instances of an ACE_Strong_Bound_Ptr will + * automatically increment the reference count of the underlying object. + * When the last instance of an ACE_Strong_Bound_Ptr that references a + * particular object is destroyed or overwritten, it will invoke delete + * on its underlying pointer. + */ +template +class ACE_Strong_Bound_Ptr +{ +public: + /// Constructor that initializes an ACE_Strong_Bound_Ptr to point to the + /// object \ immediately. + explicit ACE_Strong_Bound_Ptr (X *p = 0); + + /// Constructor that initializes an ACE_Strong_Bound_Ptr by stealing + /// ownership of an object from an auto_ptr. + explicit ACE_Strong_Bound_Ptr (auto_ptr p); + + /// Copy constructor binds @c this and @a r to the same object. + ACE_Strong_Bound_Ptr (const ACE_Strong_Bound_Ptr &r); + + /// Constructor binds @c this and @a r to the same object. + ACE_Strong_Bound_Ptr (const ACE_Weak_Bound_Ptr &r); + + /// Copy constructor binds @c this and @a r to the same object if + /// Y* can be implicitly converted to X*. + template + ACE_Strong_Bound_Ptr (const ACE_Strong_Bound_Ptr &r) + : counter_ (r.counter_), + ptr_ (dynamic_cast(r.ptr_)) + { + // This ctor is temporarily defined here to increase our chances + // of being accepted by broken compilers. + // + COUNTER::attach_strong (this->counter_); + } + + /// Destructor. + ~ACE_Strong_Bound_Ptr (void); + + /// Assignment operator that binds @c this and @a r to the same object. + void operator = (const ACE_Strong_Bound_Ptr &r); + + /// Assignment operator that binds @c this and @a r to the same object. + void operator = (const ACE_Weak_Bound_Ptr &r); + + /// Assignment operator that binds @c this and @a r to the same object + /// if Y* can be implicitly converted to X*. + template + ACE_Weak_Bound_Ptr& + operator= (const ACE_Strong_Bound_Ptr &r) + { + // This operator is temporarily defined here to increase our chances + // of being accepted by broken compilers. + // + + // This will work if &r == this, by first increasing the ref count + + COUNTER *new_counter = r.counter_; + X* new_ptr = dynamic_cast (r.ptr_); + COUNTER::attach_strong (new_counter); + if (COUNTER::detach_strong (this->counter_) == 0) + delete this->ptr_; + this->counter_ = new_counter; + this->ptr_ = new_ptr; + + return *this; + } + + /// Equality operator that returns @c true if both + /// ACE_Strong_Bound_Ptr instances point to the same underlying + /// object. + /** + * @note It also returns @c true if both objects have just been + * instantiated and not used yet. + */ + bool operator == (const ACE_Strong_Bound_Ptr &r) const; + + /// Equality operator that returns true if the ACE_Strong_Bound_Ptr + /// and ACE_Weak_Bound_Ptr objects point to the same underlying + /// object. + /** + * @note It also returns @c true if both objects have just been + * instantiated and not used yet. + */ + bool operator == (const ACE_Weak_Bound_Ptr &r) const; + + /// Equality operator that returns @c true if the + /// ACE_Strong_Bound_Ptr and the raw pointer point to the same + /// underlying object. + bool operator == (X *p) const; + + /// Inequality operator, which is the opposite of equality. + bool operator != (const ACE_Strong_Bound_Ptr &r) const; + + /// Inequality operator, which is the opposite of equality. + bool operator != (const ACE_Weak_Bound_Ptr &r) const; + + /// Inequality operator, which is the opposite of equality. + bool operator != (X *p) const; + + /// Redirection operator + X *operator-> (void) const; + + /// Dereference operator + X &operator * (void) const; + + /// Get the pointer value. + X *get (void) const; + + /// Resets the ACE_Strong_Bound_Ptr to refer to a different + /// underlying object. + void reset (X *p = 0); + + /// Resets the ACE_Strong_Bound_Ptr to refer to a different + /// underlying object, ownership of which is stolen from the + /// auto_ptr. + void reset (auto_ptr p); + + /// Allows us to check for NULL on all ACE_Strong_Bound_Ptr + /// objects. + int null (void) const; + + /// Declare the dynamic allocation hooks. + ACE_ALLOC_HOOK_DECLARE; + +private: + typedef X X_t; // This indirection is for Borland C++. + + friend class ACE_Weak_Bound_Ptr; + + template + friend class ACE_Strong_Bound_Ptr; + + /// The ACE_Bound_Ptr_Counter type. + typedef ACE_Bound_Ptr_Counter COUNTER; + + /// The reference counter. + COUNTER *counter_; + + /// The underlying object. + X *ptr_; +}; + +/** + * @class ACE_Weak_Bound_Ptr + * + * @brief This class implements support for a weak pointer that complements + * ACE_Strong_Bound_Ptr. + * + * Unlike ACE_Strong_Bound_Ptr, assigning or copying instances of an + * ACE_Weak_Bound_Ptr will not automatically increment the reference + * count of the underlying object. What ACE_Weak_Bound_Ptr does is + * preserve the knowledge that the object is in fact reference + * counted, and thus provides an alternative to raw pointers where + * non-ownership associations must be maintained. When the last + * instance of an ACE_Strong_Bound_Ptr that references a particular + * object is destroyed or overwritten, the corresponding + * ACE_Weak_Bound_Ptr instances are set to NULL. + */ +template +class ACE_Weak_Bound_Ptr +{ +public: + /// Constructor that initializes an ACE_Weak_Bound_Ptr to point to + /// the object \ immediately. + explicit ACE_Weak_Bound_Ptr (X *p = 0); + + /// Copy constructor binds @c this and @a r to the same object. + ACE_Weak_Bound_Ptr (const ACE_Weak_Bound_Ptr &r); + + /// Constructor binds @c this and @a r to the same object. + ACE_Weak_Bound_Ptr (const ACE_Strong_Bound_Ptr &r); + + /// Destructor. + ~ACE_Weak_Bound_Ptr (void); + + /// Assignment operator that binds @c this and @a r to the same object. + void operator = (const ACE_Weak_Bound_Ptr &r); + + /// Assignment operator that binds @c this and @a r to the same object. + void operator = (const ACE_Strong_Bound_Ptr &r); + + /// Equality operator that returns @c true if both + /// ACE_Weak_Bound_Ptr objects point to the same underlying object. + /** + * @note It also returns @c true if both objects have just been + * instantiated and not used yet. + */ + bool operator == (const ACE_Weak_Bound_Ptr &r) const; + + /// Equality operator that returns @c true if the ACE_Weak_Bound_Ptr + /// and ACE_Strong_Bound_Ptr objects point to the same underlying + /// object. + /** + * @note It also returns @c true if both objects have just been + * instantiated and not used yet. + */ + bool operator == (const ACE_Strong_Bound_Ptr &r) const; + + /// Equality operator that returns @c true if the ACE_Weak_Bound_Ptr + /// and the raw pointer point to the same underlying object. + bool operator == (X *p) const; + + /// Inequality operator, which is the opposite of equality. + bool operator != (const ACE_Weak_Bound_Ptr &r) const; + + /// Inequality operator, which is the opposite of equality. + bool operator != (const ACE_Strong_Bound_Ptr &r) const; + + /// Inequality operator, which is the opposite of equality. + bool operator != (X *p) const; + + /// Redirection operator. + /** + * It returns a temporary strong pointer and makes use of the + * chaining properties of operator-> to ensure that the underlying + * object does not disappear while you are using it. If you are + * certain of the lifetimes of the object, and do not want to incur + * the locking overhead, then use the unsafe_get method instead. + */ + ACE_Strong_Bound_Ptr operator-> (void) const; + + /// Obtain a strong pointer corresponding to this weak pointer. This + /// function is useful to create a temporary strong pointer for + /// conversion to a reference. + ACE_Strong_Bound_Ptr strong (void) const; + + /// Get the pointer value. Warning: this does not affect the + /// reference count of the underlying object, so it may disappear on + /// you while you are using it if you are not careful. + X *unsafe_get (void) const; + + /// Resets the ACE_Weak_Bound_Ptr to refer to a different underlying + /// object. + void reset (X *p = 0); + + /// Increment the reference count on the underlying object. + /** + * Returns the new reference count on the object. This function may + * be used to integrate the bound pointers into an external + * reference counting mechanism such as those used by COM or CORBA + * servants. + */ + long add_ref (void); + + /// Decrement the reference count on the underlying object, which is deleted + /// if the count has reached zero. + /** + * Returns the new reference count on the object. This function may + * be used to integrate the bound pointers into an external + * reference counting mechanism such as those used by COM or CORBA + * servants. + */ + long remove_ref (void); + + /// Allows us to check for NULL on all ACE_Weak_Bound_Ptr objects. + int null (void) const; + + /// Declare the dynamic allocation hooks. + ACE_ALLOC_HOOK_DECLARE; + +private: + typedef X X_t; // This indirection is for Borland C++. + + friend class ACE_Strong_Bound_Ptr; + + /// The ACE_Bound_Ptr_Counter type. + typedef ACE_Bound_Ptr_Counter COUNTER; + + /// The reference counter. + COUNTER *counter_; + + /// The underlying object. + X *ptr_; +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#include "ace/Bound_Ptr.inl" + +#include /**/ "ace/post.h" + +#endif /* ACE_BOUND_PTR_H */ diff --git a/dep/ACE_wrappers/ace/Bound_Ptr.inl b/dep/ACE_wrappers/ace/Bound_Ptr.inl new file mode 100644 index 00000000000..540a5516eab --- /dev/null +++ b/dep/ACE_wrappers/ace/Bound_Ptr.inl @@ -0,0 +1,494 @@ +/* -*- C++ -*- */ +// $Id: Bound_Ptr.inl 80826 2008-03-04 14:51:23Z wotte $ + +// Bound_Ptr.i + +#include "ace/Guard_T.h" +#if !defined (ACE_NEW_THROWS_EXCEPTIONS) +# include "ace/Log_Msg.h" +#endif /* ACE_NEW_THROWS_EXCEPTIONS */ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +template inline ACE_Bound_Ptr_Counter * +ACE_Bound_Ptr_Counter::internal_create (long init_obj_ref_count) +{ + ACE_Bound_Ptr_Counter *temp = 0; + ACE_NEW_RETURN (temp, + ACE_Bound_Ptr_Counter (init_obj_ref_count), + 0); + return temp; +} + +template inline ACE_Bound_Ptr_Counter * +ACE_Bound_Ptr_Counter::create_strong (void) +{ + // Set initial object reference count to 1. + ACE_Bound_Ptr_Counter *temp = internal_create (1); +#if defined (ACE_NEW_THROWS_EXCEPTIONS) + if (temp == 0) + ACE_throw_bad_alloc; +#else + ACE_ASSERT (temp != 0); +#endif /* ACE_NEW_THROWS_EXCEPTIONS */ + return temp; +} + + + +template inline long +ACE_Bound_Ptr_Counter::attach_strong (ACE_Bound_Ptr_Counter* counter) +{ + ACE_GUARD_RETURN (ACE_LOCK, guard, counter->lock_, -1); + + // Can't attach a strong pointer to an object that has already been deleted. + if (counter->obj_ref_count_ == -1) + return -1; + + long new_obj_ref_count = ++counter->obj_ref_count_; + ++counter->self_ref_count_; + + return new_obj_ref_count; +} + +template inline long +ACE_Bound_Ptr_Counter::detach_strong (ACE_Bound_Ptr_Counter* counter) +{ + ACE_Bound_Ptr_Counter *counter_del = 0; + long new_obj_ref_count; + + { + ACE_GUARD_RETURN (ACE_LOCK, guard, counter->lock_, -1); + + if ((new_obj_ref_count = --counter->obj_ref_count_) == 0) + // Change the object reference count to -1 to indicate that the + // object has been deleted, as opposed to a weak pointer that + // simply hasn't had any strong pointers created from it yet. + counter->obj_ref_count_ = -1; + + if (--counter->self_ref_count_ == 0) + // Since counter contains the lock held by the ACE_Guard, the + // guard needs to be released before freeing the memory holding + // the lock. So save the pointer to free, then release, then + // free. + counter_del = counter; + + } // Release the lock + + delete counter_del; + + return new_obj_ref_count; +} + +template inline ACE_Bound_Ptr_Counter * +ACE_Bound_Ptr_Counter::create_weak (void) +{ + // Set initial object reference count to 0. + + ACE_Bound_Ptr_Counter *temp = internal_create (0); +#if defined (ACE_NEW_THROWS_EXCEPTIONS) + if (temp == 0) + ACE_throw_bad_alloc; +#else + ACE_ASSERT (temp != 0); +#endif /* ACE_NEW_THROWS_EXCEPTIONS */ + return temp; +} + +template inline void +ACE_Bound_Ptr_Counter::attach_weak (ACE_Bound_Ptr_Counter* counter) +{ + ACE_GUARD (ACE_LOCK, guard, counter->lock_); + + ++counter->self_ref_count_; +} + +template inline void +ACE_Bound_Ptr_Counter::detach_weak (ACE_Bound_Ptr_Counter* counter) +{ + ACE_Bound_Ptr_Counter *counter_del = 0; + + { + ACE_GUARD (ACE_LOCK, guard, counter->lock_); + + if (--counter->self_ref_count_ == 0) + // Since counter contains the lock held by the ACE_Guard, the + // guard needs to be released before freeing the memory holding + // the lock. So save the pointer to free, then release, then + // free. + counter_del = counter; + + } // Release the lock + + delete counter_del; +} + +template inline bool +ACE_Bound_Ptr_Counter::object_was_deleted (ACE_Bound_Ptr_Counter *counter) +{ + ACE_GUARD_RETURN (ACE_LOCK, guard, counter->lock_, 0); + + return counter->obj_ref_count_ == -1; +} + +template inline +ACE_Bound_Ptr_Counter::ACE_Bound_Ptr_Counter (long init_obj_ref_count) + : obj_ref_count_ (init_obj_ref_count), + self_ref_count_ (1) +{ +} + +template inline +ACE_Bound_Ptr_Counter::~ACE_Bound_Ptr_Counter (void) +{ +} + +template inline +ACE_Strong_Bound_Ptr::ACE_Strong_Bound_Ptr (X *p) + : counter_ (COUNTER::create_strong ()), + ptr_ (p) +{ +} + +template inline +ACE_Strong_Bound_Ptr::ACE_Strong_Bound_Ptr (auto_ptr p) + : counter_ (COUNTER::create_strong ()), + ptr_ (p.release()) +{ +} + +template inline +ACE_Strong_Bound_Ptr::ACE_Strong_Bound_Ptr (const ACE_Strong_Bound_Ptr &r) + : counter_ (r.counter_), + ptr_ (r.ptr_) +{ + COUNTER::attach_strong (this->counter_); +} + +template inline +ACE_Strong_Bound_Ptr::ACE_Strong_Bound_Ptr (const ACE_Weak_Bound_Ptr &r) + : counter_ (r.counter_), + ptr_ (r.ptr_) +{ + // When creating a strong pointer from a weak one we can't assume that the + // underlying object still exists. Therefore we must check for a return value + // of -1, which indicates that the object has been destroyed. + if (COUNTER::attach_strong (this->counter_) == -1) + { + // Underlying object has already been deleted, so set this pointer to null. + this->counter_ = COUNTER::create_strong (); + this->ptr_ = 0; + } +} + +template inline +ACE_Strong_Bound_Ptr::~ACE_Strong_Bound_Ptr (void) +{ + if (COUNTER::detach_strong (this->counter_) == 0) + delete this->ptr_; +} + +template inline void +ACE_Strong_Bound_Ptr::operator = (const ACE_Strong_Bound_Ptr &rhs) +{ + // This will work if &r == this, by first increasing the ref count, but + // why go through all that? + if (&rhs == this) + return; + + COUNTER *new_counter = rhs.counter_; + X_t *new_ptr = rhs.ptr_; + COUNTER::attach_strong (new_counter); + if (COUNTER::detach_strong (this->counter_) == 0) + delete this->ptr_; + this->counter_ = new_counter; + this->ptr_ = new_ptr; +} + +template inline void +ACE_Strong_Bound_Ptr::operator = (const ACE_Weak_Bound_Ptr &rhs) +{ + // This will work if &r == this, by first increasing the ref count, but + // why go through all that? + if (&rhs == this) + return; + + COUNTER *new_counter = rhs.counter_; + X_t *new_ptr = rhs.ptr_; + + // When creating a strong pointer from a weak one we can't assume that the + // underlying object still exists. Therefore we must check for a return value + // of -1, which indicates that the object has been destroyed. + if (COUNTER::attach_strong (new_counter) == -1) + { + // Underlying object has already been deleted, so set this pointer to null. + new_counter = COUNTER::create_strong (); + new_ptr = 0; + } + + if (COUNTER::detach_strong (this->counter_) == 0) + delete this->ptr_; + this->counter_ = new_counter; + this->ptr_ = new_ptr; +} + +template inline bool +ACE_Strong_Bound_Ptr::operator== (const ACE_Strong_Bound_Ptr &r) const +{ + return this->ptr_ == r.ptr_; +} + +template inline bool +ACE_Strong_Bound_Ptr::operator== (const ACE_Weak_Bound_Ptr &r) const +{ + // Use the weak pointer's operator== since it will check for null. + return r == *this; +} + +template inline bool +ACE_Strong_Bound_Ptr::operator== (X *p) const +{ + return this->ptr_ == p; +} + +template inline bool +ACE_Strong_Bound_Ptr::operator!= (const ACE_Strong_Bound_Ptr &r) const +{ + return this->ptr_ != r.ptr_; +} + +template inline bool +ACE_Strong_Bound_Ptr::operator!= (const ACE_Weak_Bound_Ptr &r) const +{ + // Use the weak pointer's operator!= since it will check for null. + return r != *this; +} + +template inline bool +ACE_Strong_Bound_Ptr::operator!= (X *p) const +{ + return this->ptr_ != p; +} + +template inline X * +ACE_Strong_Bound_Ptr::operator-> (void) const +{ + return this->ptr_; +} + +template inline X & +ACE_Strong_Bound_Ptr::operator *() const +{ + return *this->ptr_; +} + +template inline X* +ACE_Strong_Bound_Ptr::get (void) const +{ + return this->ptr_; +} + +template inline int +ACE_Strong_Bound_Ptr::null (void) const +{ + return this->ptr_ == 0; +} + +template inline void +ACE_Strong_Bound_Ptr::reset (X *p) +{ + COUNTER *old_counter = this->counter_; + X_t *old_ptr = this->ptr_; + this->counter_ = COUNTER::create_strong (); + this->ptr_ = p; + if (COUNTER::detach_strong (old_counter) == 0) + delete old_ptr; +} + +template inline void +ACE_Strong_Bound_Ptr::reset (auto_ptr p) +{ + COUNTER *old_counter = this->counter_; + X_t *old_ptr = this->ptr_; + this->counter_ = COUNTER::create_strong (); + this->ptr_ = p.release (); + if (COUNTER::detach_strong (old_counter) == 0) + delete old_ptr; +} + +template inline +ACE_Weak_Bound_Ptr::ACE_Weak_Bound_Ptr (X *p) + : counter_ (COUNTER::create_weak ()), + ptr_ (p) +{ +} + +template inline +ACE_Weak_Bound_Ptr::ACE_Weak_Bound_Ptr (const ACE_Weak_Bound_Ptr &r) + : counter_ (r.counter_), + ptr_ (r.ptr_) +{ + COUNTER::attach_weak (this->counter_); +} + +template inline +ACE_Weak_Bound_Ptr::ACE_Weak_Bound_Ptr (const ACE_Strong_Bound_Ptr &r) + : counter_ (r.counter_), + ptr_ (r.ptr_) +{ + COUNTER::attach_weak (this->counter_); +} + +template inline +ACE_Weak_Bound_Ptr::~ACE_Weak_Bound_Ptr (void) +{ + COUNTER::detach_weak (this->counter_); +} + +template inline void +ACE_Weak_Bound_Ptr::operator = (const ACE_Weak_Bound_Ptr &rhs) +{ + // This will work if &rhs == this, by first increasing the ref count + COUNTER *new_counter = rhs.counter_; + COUNTER::attach_weak (new_counter); + COUNTER::detach_weak (this->counter_); + this->counter_ = new_counter; + this->ptr_ = rhs.ptr_; +} + +template inline void +ACE_Weak_Bound_Ptr::operator = (const ACE_Strong_Bound_Ptr &rhs) +{ + // This will work if &rhs == this, by first increasing the ref count + COUNTER *new_counter = rhs.counter_; + COUNTER::attach_weak (new_counter); + COUNTER::detach_weak (this->counter_); + this->counter_ = new_counter; + this->ptr_ = rhs.ptr_; +} + +template inline bool +ACE_Weak_Bound_Ptr::operator== (const ACE_Weak_Bound_Ptr &r) const +{ + // A weak pointer must behave as though it is automatically set to null + // if the underlying object has been deleted. + if (COUNTER::object_was_deleted (this->counter_)) + return r.ptr_ == 0; + + return this->ptr_ == r.ptr_; +} + +template inline bool +ACE_Weak_Bound_Ptr::operator== (const ACE_Strong_Bound_Ptr &r) const +{ + // A weak pointer must behave as though it is automatically set to null + // if the underlying object has been deleted. + if (COUNTER::object_was_deleted (this->counter_)) + return r.ptr_ == 0; + + return this->ptr_ == r.ptr_; +} + +template inline bool +ACE_Weak_Bound_Ptr::operator== (X *p) const +{ + // A weak pointer must behave as though it is automatically set to null + // if the underlying object has been deleted. + if (COUNTER::object_was_deleted (this->counter_)) + return p == 0; + + return this->ptr_ == p; +} + +template inline bool +ACE_Weak_Bound_Ptr::operator!= (const ACE_Weak_Bound_Ptr &r) const +{ + // A weak pointer must behave as though it is automatically set to null + // if the underlying object has been deleted. + if (COUNTER::object_was_deleted (this->counter_)) + return r.ptr_ != 0; + + return this->ptr_ != r.ptr_; +} + +template inline bool +ACE_Weak_Bound_Ptr::operator!= (const ACE_Strong_Bound_Ptr &r) const +{ + // A weak pointer must behave as though it is automatically set to null + // if the underlying object has been deleted. + if (COUNTER::object_was_deleted (this->counter_)) + return r.ptr_ != 0; + + return this->ptr_ != r.ptr_; +} + +template inline bool +ACE_Weak_Bound_Ptr::operator!= (X *p) const +{ + // A weak pointer must behave as though it is automatically set to null + // if the underlying object has been deleted. + if (COUNTER::object_was_deleted (this->counter_)) + return p != 0; + + return this->ptr_ != p; +} + +template inline ACE_Strong_Bound_Ptr +ACE_Weak_Bound_Ptr::operator-> (void) const +{ + return ACE_Strong_Bound_Ptr (*this); +} + +template inline ACE_Strong_Bound_Ptr +ACE_Weak_Bound_Ptr::strong (void) const +{ + return ACE_Strong_Bound_Ptr (*this); +} + +template inline X* +ACE_Weak_Bound_Ptr::unsafe_get (void) const +{ + // We do not check if the object has been deleted, since this operation + // is defined to be unsafe! + return this->ptr_; +} + +template inline int +ACE_Weak_Bound_Ptr::null (void) const +{ + // A weak pointer must behave as though it is automatically set to null + // if the underlying object has been deleted. + if (COUNTER::object_was_deleted (this->counter_)) + return 1; + + return this->ptr_ == 0; +} + +template inline void +ACE_Weak_Bound_Ptr::reset (X *p) +{ + COUNTER *old_counter = this->counter_; + this->counter_ = COUNTER::create_weak (); + this->ptr_ = p; + COUNTER::detach_weak (old_counter); +} + +template inline long +ACE_Weak_Bound_Ptr::add_ref () +{ + return COUNTER::attach_strong (counter_); +} + +template inline long +ACE_Weak_Bound_Ptr::remove_ref () +{ + long new_obj_ref_count = COUNTER::detach_strong (counter_); + if (new_obj_ref_count == 0) + { + delete this->ptr_; + this->ptr_ = 0; + } + return new_obj_ref_count; +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/CDR_Base.cpp b/dep/ACE_wrappers/ace/CDR_Base.cpp new file mode 100644 index 00000000000..dab8978fd61 --- /dev/null +++ b/dep/ACE_wrappers/ace/CDR_Base.cpp @@ -0,0 +1,799 @@ +#include "ace/CDR_Base.h" + +#if !defined (__ACE_INLINE__) +# include "ace/CDR_Base.inl" +#endif /* ! __ACE_INLINE__ */ + +#include "ace/Message_Block.h" +#include "ace/OS_Memory.h" +#include "ace/OS_NS_string.h" + +ACE_RCSID (ace, + CDR_Base, + "$Id: CDR_Base.cpp 80826 2008-03-04 14:51:23Z wotte $") + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +#if defined (NONNATIVE_LONGDOUBLE) +static const ACE_INT16 max_eleven_bit = 0x3ff; +static const ACE_INT16 max_fifteen_bit = 0x3fff; +#endif /* NONNATIVE_LONGDOUBLE */ + +// +// See comments in CDR_Base.inl about optimization cases for swap_XX_array. +// + +void +ACE_CDR::swap_2_array (char const * orig, char* target, size_t n) +{ + // ACE_ASSERT(n > 0); The caller checks that n > 0 + + // We pretend that AMD64/GNU G++ systems have a Pentium CPU to + // take advantage of the inline assembly implementation. + + // Later, we try to read in 32 or 64 bit chunks, + // so make sure we don't do that for unaligned addresses. +#if ACE_SIZEOF_LONG == 8 && \ + !((defined(__amd64__) || defined (__x86_64__)) && defined(__GNUG__)) + char const * const o8 = ACE_ptr_align_binary (orig, 8); + while (orig < o8 && n > 0) + { + ACE_CDR::swap_2 (orig, target); + orig += 2; + target += 2; + --n; + } +#else + char const * const o4 = ACE_ptr_align_binary (orig, 4); + // this is an _if_, not a _while_. The mistmatch can only be by 2. + if (orig != o4) + { + ACE_CDR::swap_2 (orig, target); + orig += 2; + target += 2; + --n; + } +#endif + if (n == 0) + return; + + // + // Loop unrolling. Here be dragons. + // + + // (n & (~3)) is the greatest multiple of 4 not bigger than n. + // In the while loop ahead, orig will move over the array by 8 byte + // increments (4 elements of 2 bytes). + // end marks our barrier for not falling outside. + char const * const end = orig + 2 * (n & (~3)); + + // See if we're aligned for writting in 64 or 32 bit chunks... +#if ACE_SIZEOF_LONG == 8 && \ + !((defined(__amd64__) || defined (__x86_64__)) && defined(__GNUG__)) + if (target == ACE_ptr_align_binary (target, 8)) +#else + if (target == ACE_ptr_align_binary (target, 4)) +#endif + { + while (orig < end) + { +#if defined (ACE_HAS_INTEL_ASSEMBLY) + unsigned int a = + * reinterpret_cast (orig); + unsigned int b = + * reinterpret_cast (orig + 4); + asm ( "bswap %1" : "=r" (a) : "0" (a) ); + asm ( "bswap %1" : "=r" (b) : "0" (b) ); + asm ( "rol $16, %1" : "=r" (a) : "0" (a) ); + asm ( "rol $16, %1" : "=r" (b) : "0" (b) ); + * reinterpret_cast (target) = a; + * reinterpret_cast (target + 4) = b; +#elif defined(ACE_HAS_PENTIUM) \ + && (defined(_MSC_VER) || defined(__BORLANDC__)) \ + && !defined(ACE_LACKS_INLINE_ASSEMBLY) + __asm mov ecx, orig; + __asm mov edx, target; + __asm mov eax, [ecx]; + __asm mov ebx, 4[ecx]; + __asm bswap eax; + __asm bswap ebx; + __asm rol eax, 16; + __asm rol ebx, 16; + __asm mov [edx], eax; + __asm mov 4[edx], ebx; +#elif ACE_SIZEOF_LONG == 8 + // 64 bit architecture. + register unsigned long a = + * reinterpret_cast (orig); + + register unsigned long a1 = (a & 0x00ff00ff00ff00ffUL) << 8; + register unsigned long a2 = (a & 0xff00ff00ff00ff00UL) >> 8; + + a = (a1 | a2); + + * reinterpret_cast (target) = a; +#else + register ACE_UINT32 a = + * reinterpret_cast (orig); + register ACE_UINT32 b = + * reinterpret_cast (orig + 4); + + register ACE_UINT32 a1 = (a & 0x00ff00ffU) << 8; + register ACE_UINT32 b1 = (b & 0x00ff00ffU) << 8; + register ACE_UINT32 a2 = (a & 0xff00ff00U) >> 8; + register ACE_UINT32 b2 = (b & 0xff00ff00U) >> 8; + + a = (a1 | a2); + b = (b1 | b2); + + * reinterpret_cast (target) = a; + * reinterpret_cast (target + 4) = b; +#endif + orig += 8; + target += 8; + } + } + else + { + // We're out of luck. We have to write in 2 byte chunks. + while (orig < end) + { +#if defined (ACE_HAS_INTEL_ASSEMBLY) + unsigned int a = + * reinterpret_cast (orig); + unsigned int b = + * reinterpret_cast (orig + 4); + asm ( "bswap %1" : "=r" (a) : "0" (a) ); + asm ( "bswap %1" : "=r" (b) : "0" (b) ); + // We're little endian. + * reinterpret_cast (target + 2) + = (unsigned short) (a & 0xffff); + * reinterpret_cast (target + 6) + = (unsigned short) (b & 0xffff); + asm ( "shrl $16, %1" : "=r" (a) : "0" (a) ); + asm ( "shrl $16, %1" : "=r" (b) : "0" (b) ); + * reinterpret_cast (target + 0) + = (unsigned short) (a & 0xffff); + * reinterpret_cast (target + 4) + = (unsigned short) (b & 0xffff); +#elif defined (ACE_HAS_PENTIUM) \ + && (defined (_MSC_VER) || defined (__BORLANDC__)) \ + && !defined (ACE_LACKS_INLINE_ASSEMBLY) + __asm mov ecx, orig; + __asm mov edx, target; + __asm mov eax, [ecx]; + __asm mov ebx, 4[ecx]; + __asm bswap eax; + __asm bswap ebx; + // We're little endian. + __asm mov 2[edx], ax; + __asm mov 6[edx], bx; + __asm shr eax, 16; + __asm shr ebx, 16; + __asm mov 0[edx], ax; + __asm mov 4[edx], bx; +#elif ACE_SIZEOF_LONG == 8 + // 64 bit architecture. + register unsigned long a = + * reinterpret_cast (orig); + + register unsigned long a1 = (a & 0x00ff00ff00ff00ffUL) << 8; + register unsigned long a2 = (a & 0xff00ff00ff00ff00UL) >> 8; + + a = (a1 | a2); + + ACE_UINT16 b1 = static_cast (a >> 48); + ACE_UINT16 b2 = static_cast ((a >> 32) & 0xffff); + ACE_UINT16 b3 = static_cast ((a >> 16) & 0xffff); + ACE_UINT16 b4 = static_cast (a & 0xffff); + +#if defined(ACE_LITTLE_ENDIAN) + * reinterpret_cast (target) = b4; + * reinterpret_cast (target + 2) = b3; + * reinterpret_cast (target + 4) = b2; + * reinterpret_cast (target + 6) = b1; +#else + * reinterpret_cast (target) = b1; + * reinterpret_cast (target + 2) = b2; + * reinterpret_cast (target + 4) = b3; + * reinterpret_cast (target + 6) = b4; +#endif +#else + register ACE_UINT32 a = + * reinterpret_cast (orig); + register ACE_UINT32 b = + * reinterpret_cast (orig + 4); + + register ACE_UINT32 a1 = (a & 0x00ff00ff) << 8; + register ACE_UINT32 b1 = (b & 0x00ff00ff) << 8; + register ACE_UINT32 a2 = (a & 0xff00ff00) >> 8; + register ACE_UINT32 b2 = (b & 0xff00ff00) >> 8; + + a = (a1 | a2); + b = (b1 | b2); + + ACE_UINT32 c1 = static_cast (a >> 16); + ACE_UINT32 c2 = static_cast (a & 0xffff); + ACE_UINT32 c3 = static_cast (b >> 16); + ACE_UINT32 c4 = static_cast (b & 0xffff); + +#if defined(ACE_LITTLE_ENDIAN) + * reinterpret_cast (target) = c2; + * reinterpret_cast (target + 2) = c1; + * reinterpret_cast (target + 4) = c4; + * reinterpret_cast (target + 6) = c3; +#else + * reinterpret_cast (target) = c1; + * reinterpret_cast (target + 2) = c2; + * reinterpret_cast (target + 4) = c3; + * reinterpret_cast (target + 6) = c4; +#endif +#endif + + orig += 8; + target += 8; + } + } + + // (n & 3) == (n % 4). + switch (n&3) { + case 3: + ACE_CDR::swap_2 (orig, target); + orig += 2; + target += 2; + case 2: + ACE_CDR::swap_2 (orig, target); + orig += 2; + target += 2; + case 1: + ACE_CDR::swap_2 (orig, target); + } +} + +void +ACE_CDR::swap_4_array (char const * orig, char* target, size_t n) +{ + // ACE_ASSERT (n > 0); The caller checks that n > 0 + +#if ACE_SIZEOF_LONG == 8 + // Later, we read from *orig in 64 bit chunks, + // so make sure we don't generate unaligned readings. + char const * const o8 = ACE_ptr_align_binary (orig, 8); + // The mismatch can only be by 4. + if (orig != o8) + { + ACE_CDR::swap_4 (orig, target); + orig += 4; + target += 4; + --n; + } +#endif /* ACE_SIZEOF_LONG == 8 */ + + if (n == 0) + return; + + // + // Loop unrolling. Here be dragons. + // + + // (n & (~3)) is the greatest multiple of 4 not bigger than n. + // In the while loop, orig will move over the array by 16 byte + // increments (4 elements of 4 bytes). + // ends marks our barrier for not falling outside. + char const * const end = orig + 4 * (n & (~3)); + +#if ACE_SIZEOF_LONG == 8 + // 64 bits architecture. + // See if we can write in 8 byte chunks. + if (target == ACE_ptr_align_binary (target, 8)) + { + while (orig < end) + { + register unsigned long a = + * reinterpret_cast (orig); + register unsigned long b = + * reinterpret_cast (orig + 8); + +#if defined(ACE_HAS_INTEL_ASSEMBLY) + asm ("bswapq %1" : "=r" (a) : "0" (a)); + asm ("bswapq %1" : "=r" (b) : "0" (b)); + asm ("rol $32, %1" : "=r" (a) : "0" (a)); + asm ("rol $32, %1" : "=r" (b) : "0" (b)); +#else + register unsigned long a84 = (a & 0x000000ff000000ffL) << 24; + register unsigned long b84 = (b & 0x000000ff000000ffL) << 24; + register unsigned long a73 = (a & 0x0000ff000000ff00L) << 8; + register unsigned long b73 = (b & 0x0000ff000000ff00L) << 8; + register unsigned long a62 = (a & 0x00ff000000ff0000L) >> 8; + register unsigned long b62 = (b & 0x00ff000000ff0000L) >> 8; + register unsigned long a51 = (a & 0xff000000ff000000L) >> 24; + register unsigned long b51 = (b & 0xff000000ff000000L) >> 24; + + a = (a84 | a73 | a62 | a51); + b = (b84 | b73 | b62 | b51); +#endif + + * reinterpret_cast (target) = a; + * reinterpret_cast (target + 8) = b; + + orig += 16; + target += 16; + } + } + else + { + // We are out of luck, we have to write in 4 byte chunks. + while (orig < end) + { + register unsigned long a = + * reinterpret_cast (orig); + register unsigned long b = + * reinterpret_cast (orig + 8); + +#if defined(ACE_HAS_INTEL_ASSEMBLY) + asm ("bswapq %1" : "=r" (a) : "0" (a)); + asm ("bswapq %1" : "=r" (b) : "0" (b)); + asm ("rol $32, %1" : "=r" (a) : "0" (a)); + asm ("rol $32, %1" : "=r" (b) : "0" (b)); +#else + register unsigned long a84 = (a & 0x000000ff000000ffL) << 24; + register unsigned long b84 = (b & 0x000000ff000000ffL) << 24; + register unsigned long a73 = (a & 0x0000ff000000ff00L) << 8; + register unsigned long b73 = (b & 0x0000ff000000ff00L) << 8; + register unsigned long a62 = (a & 0x00ff000000ff0000L) >> 8; + register unsigned long b62 = (b & 0x00ff000000ff0000L) >> 8; + register unsigned long a51 = (a & 0xff000000ff000000L) >> 24; + register unsigned long b51 = (b & 0xff000000ff000000L) >> 24; + + a = (a84 | a73 | a62 | a51); + b = (b84 | b73 | b62 | b51); +#endif + + ACE_UINT32 c1 = static_cast (a >> 32); + ACE_UINT32 c2 = static_cast (a & 0xffffffff); + ACE_UINT32 c3 = static_cast (b >> 32); + ACE_UINT32 c4 = static_cast (b & 0xffffffff); + +#if defined (ACE_LITTLE_ENDIAN) + * reinterpret_cast (target + 0) = c2; + * reinterpret_cast (target + 4) = c1; + * reinterpret_cast (target + 8) = c4; + * reinterpret_cast (target + 12) = c3; +#else + * reinterpret_cast (target + 0) = c1; + * reinterpret_cast (target + 4) = c2; + * reinterpret_cast (target + 8) = c3; + * reinterpret_cast (target + 12) = c4; +#endif + orig += 16; + target += 16; + } + } + +#else /* ACE_SIZEOF_LONG != 8 */ + + while (orig < end) + { +#if defined (ACE_HAS_PENTIUM) && defined (__GNUG__) + register unsigned int a = + *reinterpret_cast (orig); + register unsigned int b = + *reinterpret_cast (orig + 4); + register unsigned int c = + *reinterpret_cast (orig + 8); + register unsigned int d = + *reinterpret_cast (orig + 12); + + asm ("bswap %1" : "=r" (a) : "0" (a)); + asm ("bswap %1" : "=r" (b) : "0" (b)); + asm ("bswap %1" : "=r" (c) : "0" (c)); + asm ("bswap %1" : "=r" (d) : "0" (d)); + + *reinterpret_cast (target) = a; + *reinterpret_cast (target + 4) = b; + *reinterpret_cast (target + 8) = c; + *reinterpret_cast (target + 12) = d; +#elif defined (ACE_HAS_PENTIUM) \ + && (defined (_MSC_VER) || defined (__BORLANDC__)) \ + && !defined (ACE_LACKS_INLINE_ASSEMBLY) + __asm mov eax, orig + __asm mov esi, target + __asm mov edx, [eax] + __asm mov ecx, 4[eax] + __asm mov ebx, 8[eax] + __asm mov eax, 12[eax] + __asm bswap edx + __asm bswap ecx + __asm bswap ebx + __asm bswap eax + __asm mov [esi], edx + __asm mov 4[esi], ecx + __asm mov 8[esi], ebx + __asm mov 12[esi], eax +#else + register ACE_UINT32 a = + * reinterpret_cast (orig); + register ACE_UINT32 b = + * reinterpret_cast (orig + 4); + register ACE_UINT32 c = + * reinterpret_cast (orig + 8); + register ACE_UINT32 d = + * reinterpret_cast (orig + 12); + + // Expect the optimizer reordering this A LOT. + // We leave it this way for clarity. + a = (a << 24) | ((a & 0xff00) << 8) | ((a & 0xff0000) >> 8) | (a >> 24); + b = (b << 24) | ((b & 0xff00) << 8) | ((b & 0xff0000) >> 8) | (b >> 24); + c = (c << 24) | ((c & 0xff00) << 8) | ((c & 0xff0000) >> 8) | (c >> 24); + d = (d << 24) | ((d & 0xff00) << 8) | ((d & 0xff0000) >> 8) | (d >> 24); + + * reinterpret_cast (target) = a; + * reinterpret_cast (target + 4) = b; + * reinterpret_cast (target + 8) = c; + * reinterpret_cast (target + 12) = d; +#endif + + orig += 16; + target += 16; + } + +#endif /* ACE_SIZEOF_LONG == 8 */ + + // (n & 3) == (n % 4). + switch (n & 3) { + case 3: + ACE_CDR::swap_4 (orig, target); + orig += 4; + target += 4; + case 2: + ACE_CDR::swap_4 (orig, target); + orig += 4; + target += 4; + case 1: + ACE_CDR::swap_4 (orig, target); + } +} + +// +// We don't benefit from unrolling in swap_8_array and swap_16_array +// (swap_8 and swap_16 are big enough). +// +void +ACE_CDR::swap_8_array (char const * orig, char* target, size_t n) +{ + // ACE_ASSERT(n > 0); The caller checks that n > 0 + + char const * const end = orig + 8*n; + while (orig < end) + { + swap_8 (orig, target); + orig += 8; + target += 8; + } +} + +void +ACE_CDR::swap_16_array (char const * orig, char* target, size_t n) +{ + // ACE_ASSERT(n > 0); The caller checks that n > 0 + + char const * const end = orig + 16*n; + while (orig < end) + { + swap_16 (orig, target); + orig += 16; + target += 16; + } +} + +void +ACE_CDR::mb_align (ACE_Message_Block *mb) +{ +#if !defined (ACE_CDR_IGNORE_ALIGNMENT) + char * const start = ACE_ptr_align_binary (mb->base (), + ACE_CDR::MAX_ALIGNMENT); +#else + char * const start = mb->base (); +#endif /* ACE_CDR_IGNORE_ALIGNMENT */ + mb->rd_ptr (start); + mb->wr_ptr (start); +} + +int +ACE_CDR::grow (ACE_Message_Block *mb, size_t minsize) +{ + size_t newsize = + ACE_CDR::first_size (minsize + ACE_CDR::MAX_ALIGNMENT); + + if (newsize <= mb->size ()) + return 0; + + ACE_Data_Block *db = + mb->data_block ()->clone_nocopy (0, newsize); + + if (db == 0) + return -1; + + // Do the equivalent of ACE_CDR::mb_align() here to avoid having + // to allocate an ACE_Message_Block on the stack thereby avoiding + // the manipulation of the data blocks reference count + size_t mb_len = mb->length (); + char *start = ACE_ptr_align_binary (db->base (), + ACE_CDR::MAX_ALIGNMENT); + + ACE_OS::memcpy (start, mb->rd_ptr (), mb_len); + mb->data_block (db); + + // Setting the data block on the mb resets the read and write + // pointers back to the beginning. We must set the rd_ptr to the + // aligned start and adjust the write pointer to the end + mb->rd_ptr (start); + mb->wr_ptr (start + mb_len); + + // Remove the DONT_DELETE flags from mb + mb->clr_self_flags (ACE_Message_Block::DONT_DELETE); + + return 0; +} + +size_t +ACE_CDR::total_length (const ACE_Message_Block* begin, + const ACE_Message_Block* end) +{ + size_t l = 0; + // Compute the total size. + for (const ACE_Message_Block *i = begin; + i != end; + i = i->cont ()) + l += i->length (); + return l; +} + +void +ACE_CDR::consolidate (ACE_Message_Block *dst, + const ACE_Message_Block *src) +{ + if (src == 0) + return; + + size_t newsize = + ACE_CDR::first_size (ACE_CDR::total_length (src, 0) + + ACE_CDR::MAX_ALIGNMENT); + dst->size (newsize); + +#if !defined (ACE_CDR_IGNORE_ALIGNMENT) + // We must copy the contents of into the new buffer, but + // respecting the alignment. + ptrdiff_t srcalign = + ptrdiff_t(src->rd_ptr ()) % ACE_CDR::MAX_ALIGNMENT; + ptrdiff_t dstalign = + ptrdiff_t(dst->rd_ptr ()) % ACE_CDR::MAX_ALIGNMENT; + ptrdiff_t offset = srcalign - dstalign; + if (offset < 0) + offset += ACE_CDR::MAX_ALIGNMENT; + dst->rd_ptr (static_cast (offset)); + dst->wr_ptr (dst->rd_ptr ()); +#endif /* ACE_CDR_IGNORE_ALIGNMENT */ + + for (const ACE_Message_Block* i = src; + i != 0; + i = i->cont ()) + { + // If the destination and source are the same, do not + // attempt to copy the data. Just update the write pointer. + if (dst->wr_ptr () != i->rd_ptr ()) + dst->copy (i->rd_ptr (), i->length ()); + else + dst->wr_ptr (i->length ()); + } +} + +#if defined (NONNATIVE_LONGLONG) +bool +ACE_CDR::LongLong::operator== (const ACE_CDR::LongLong &rhs) const +{ + return this->h == rhs.h && this->l == rhs.l; +} + +bool +ACE_CDR::LongLong::operator!= (const ACE_CDR::LongLong &rhs) const +{ + return this->l != rhs.l || this->h != rhs.h; +} + +#endif /* NONNATIVE_LONGLONG */ + +#if defined (NONNATIVE_LONGDOUBLE) +ACE_CDR::LongDouble& +ACE_CDR::LongDouble::assign (const ACE_CDR::LongDouble::NativeImpl& rhs) +{ + ACE_OS::memset (this->ld, 0, sizeof (this->ld)); + + if (sizeof (rhs) == 8) + { +#if defined (ACE_LITTLE_ENDIAN) + static const size_t byte_zero = 1; + static const size_t byte_one = 0; + char rhs_ptr[16]; + ACE_CDR::swap_8 (reinterpret_cast (&rhs), rhs_ptr); +#else + static const size_t byte_zero = 0; + static const size_t byte_one = 1; + const char* rhs_ptr = reinterpret_cast (&rhs); +#endif + ACE_INT16 sign = static_cast ( + static_cast (rhs_ptr[0])) & 0x8000; + ACE_INT16 exponent = ((rhs_ptr[0] & 0x7f) << 4) | + ((rhs_ptr[1] >> 4) & 0xf); + const char* exp_ptr = reinterpret_cast (&exponent); + + // Infinity and NaN have an exponent of 0x7ff in 64-bit IEEE + if (exponent == 0x7ff) + { + exponent = 0x7fff; + } + else + { + exponent = (exponent - max_eleven_bit) + max_fifteen_bit; + } + exponent |= sign; + + // Store the sign bit and exponent + this->ld[0] = exp_ptr[byte_zero]; + this->ld[1] = exp_ptr[byte_one]; + + // Store the mantissa. In an 8 byte double, it is split by + // 4 bits (because of the 12 bits for sign and exponent), so + // we have to shift and or the rhs to get the right bytes. + size_t li = 2; + bool direction = true; + for (size_t ri = 1; ri < sizeof (rhs);) + { + if (direction) + { + this->ld[li] |= ((rhs_ptr[ri] << 4) & 0xf0); + direction = false; + ++ri; + } + else + { + this->ld[li] |= ((rhs_ptr[ri] >> 4) & 0xf); + direction = true; + ++li; + } + } +#if defined (ACE_LITTLE_ENDIAN) + ACE_OS::memcpy (rhs_ptr, this->ld, sizeof (this->ld)); + ACE_CDR::swap_16 (rhs_ptr, this->ld); +#endif + } + else + { + ACE_OS::memcpy(this->ld, + reinterpret_cast (&rhs), sizeof (rhs)); + } + return *this; +} + +ACE_CDR::LongDouble& +ACE_CDR::LongDouble::assign (const ACE_CDR::LongDouble& rhs) +{ + if (this != &rhs) + *this = rhs; + return *this; +} + +bool +ACE_CDR::LongDouble::operator== (const ACE_CDR::LongDouble &rhs) const +{ + return ACE_OS::memcmp (this->ld, rhs.ld, 16) == 0; +} + +bool +ACE_CDR::LongDouble::operator!= (const ACE_CDR::LongDouble &rhs) const +{ + return ACE_OS::memcmp (this->ld, rhs.ld, 16) != 0; +} + +ACE_CDR::LongDouble::operator ACE_CDR::LongDouble::NativeImpl () const +{ + ACE_CDR::LongDouble::NativeImpl ret = 0.0; + char* lhs_ptr = reinterpret_cast (&ret); + + if (sizeof (ret) == 8) + { +#if defined (ACE_LITTLE_ENDIAN) + static const size_t byte_zero = 1; + static const size_t byte_one = 0; + char copy[16]; + ACE_CDR::swap_16 (this->ld, copy); +#else + static const size_t byte_zero = 0; + static const size_t byte_one = 1; + const char* copy = this->ld; +#endif + ACE_INT16 exponent = 0; + char* exp_ptr = reinterpret_cast (&exponent); + exp_ptr[byte_zero] = copy[0]; + exp_ptr[byte_one] = copy[1]; + + ACE_INT16 sign = (exponent & 0x8000); + exponent &= 0x7fff; + + // Infinity and NaN have an exponent of 0x7fff in 128-bit IEEE + if (exponent == 0x7fff) + { + exponent = 0x7ff; + } + else + { + exponent = (exponent - max_fifteen_bit) + max_eleven_bit; + } + exponent = (exponent << 4) | sign; + + // Store the sign and exponent + lhs_ptr[0] = exp_ptr[byte_zero]; + lhs_ptr[1] = exp_ptr[byte_one]; + + // Store the mantissa. In an 8 byte double, it is split by + // 4 bits (because of the 12 bits for sign and exponent), so + // we have to shift and or the rhs to get the right bytes. + size_t li = 1; + bool direction = true; + for (size_t ri = 2; li < sizeof (ret);) { + if (direction) + { + lhs_ptr[li] |= ((copy[ri] >> 4) & 0xf); + direction = false; + ++li; + } + else + { + lhs_ptr[li] |= ((copy[ri] & 0xf) << 4); + direction = true; + ++ri; + } + } + +#if defined (ACE_LITTLE_ENDIAN) + ACE_CDR::swap_8 (lhs_ptr, lhs_ptr); +#endif + } + else + { + ACE_OS::memcpy(lhs_ptr, this->ld, sizeof (ret)); + } + + // This bit of code is unnecessary. However, this code is + // necessary to work around a bug in the gcc 4.1.1 optimizer. + ACE_CDR::LongDouble tmp; + tmp.assign (ret); + + return ret; +} +#endif /* NONNATIVE_LONGDOUBLE */ + +#if defined(_UNICOS) && !defined(_CRAYMPP) +// placeholders to get things compiling +ACE_CDR::Float::Float (void) +{ +} + +ACE_CDR::Float::Float (const float & /* init */) +{ +} + +ACE_CDR::Float & +ACE_CDR::Float::operator= (const float & /* rhs */) +{ + return *this; +} + +bool +ACE_CDR::Float::operator!= (const ACE_CDR::Float & /* rhs */) const +{ + return false; +} +#endif /* _UNICOS */ + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/CDR_Base.h b/dep/ACE_wrappers/ace/CDR_Base.h new file mode 100644 index 00000000000..9c5851b2206 --- /dev/null +++ b/dep/ACE_wrappers/ace/CDR_Base.h @@ -0,0 +1,379 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file CDR_Base.h + * + * $Id: CDR_Base.h 82088 2008-06-19 16:22:16Z shuston $ + * + * ACE Common Data Representation (CDR) basic types. + * + * The current implementation assumes that the host has 1-byte, + * 2-byte and 4-byte integral types, and that it has single + * precision and double precision IEEE floats. + * Those assumptions are pretty good these days, with Crays being + * the only known exception. + * + * + * @author TAO version by + * @author Aniruddha Gokhale + * @author Carlos O'Ryan + * @author ACE version by + * @author Jeff Parsons + * @author Istvan Buki + */ +//============================================================================= + + +#ifndef ACE_CDR_BASE_H +#define ACE_CDR_BASE_H + +#include /**/ "ace/pre.h" + +#include /**/ "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/Basic_Types.h" +#include "ace/Default_Constants.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +// Stuff used by the ACE CDR classes. Watch these values... they're also used +// in the ACE_CDR Byte_Order enum below. +#if defined ACE_LITTLE_ENDIAN +# define ACE_CDR_BYTE_ORDER 1 +// little endian encapsulation byte order has value = 1 +#else /* ! ACE_LITTLE_ENDIAN */ +# define ACE_CDR_BYTE_ORDER 0 +// big endian encapsulation byte order has value = 0 +#endif /* ! ACE_LITTLE_ENDIAN */ + +class ACE_Message_Block; + +/** + * @class ACE_CDR + * + * @brief Keep constants and some routines common to both Output and + * Input CDR streams. + */ +class ACE_Export ACE_CDR +{ +public: + // = Constants defined by the CDR protocol. + // By defining as many of these constants as possible as enums we + // ensure they get inlined and avoid pointless static memory + // allocations. + + enum + { + // Note that some of these get reused as part of the standard + // binary format: unsigned is the same size as its signed cousin, + // float is LONG_SIZE, and double is LONGLONG_SIZE. + + OCTET_SIZE = 1, + SHORT_SIZE = 2, + LONG_SIZE = 4, + LONGLONG_SIZE = 8, + LONGDOUBLE_SIZE = 16, + + OCTET_ALIGN = 1, + SHORT_ALIGN = 2, + LONG_ALIGN = 4, + LONGLONG_ALIGN = 8, + /// @note the CORBA LongDouble alignment requirements do not + /// match its size... + LONGDOUBLE_ALIGN = 8, + + /// Maximal CDR 1.1 alignment: "quad precision" FP (i.e. "CDR::Long + /// double", size as above). + MAX_ALIGNMENT = 8, + + /// The default buffer size. + /** + * @todo We want to add options to control this + * default value, so this constant should be read as the default + * default value ;-) + */ + DEFAULT_BUFSIZE = ACE_DEFAULT_CDR_BUFSIZE, + + /// The buffer size grows exponentially until it reaches this size; + /// afterwards it grows linearly using the next constant + EXP_GROWTH_MAX = ACE_DEFAULT_CDR_EXP_GROWTH_MAX, + + /// Once exponential growth is ruled out the buffer size increases + /// in chunks of this size, note that this constants have the same + /// value right now, but it does not need to be so. + LINEAR_GROWTH_CHUNK = ACE_DEFAULT_CDR_LINEAR_GROWTH_CHUNK + }; + + /** + * @enum Byte_Order + * + * Defines values for the byte_order argument to ACE_OutputCDR and + * ACE_InputCDR. + */ + enum Byte_Order + { + /// Use big-endian order (also known as network byte order). + BYTE_ORDER_BIG_ENDIAN = 0, + /// Use little-endian order. + BYTE_ORDER_LITTLE_ENDIAN = 1, + /// Use whichever byte order is native to this machine. + BYTE_ORDER_NATIVE = ACE_CDR_BYTE_ORDER + }; + + /** + * Do byte swapping for each basic IDL type size. There exist only + * routines to put byte, halfword (2 bytes), word (4 bytes), + * doubleword (8 bytes) and quadword (16 byte); because those are + * the IDL basic type sizes. + */ + static void swap_2 (char const *orig, char *target); + static void swap_4 (char const *orig, char *target); + static void swap_8 (char const *orig, char *target); + static void swap_16 (char const *orig, char *target); + static void swap_2_array (char const *orig, + char *target, + size_t length); + static void swap_4_array (char const *orig, + char *target, + size_t length); + static void swap_8_array (char const *orig, + char *target, + size_t length); + static void swap_16_array (char const *orig, + char *target, + size_t length); + + /// Align the message block to ACE_CDR::MAX_ALIGNMENT, + /// set by the CORBA spec at 8 bytes. + static void mb_align (ACE_Message_Block *mb); + + /** + * Compute the size of the smallest buffer that can contain at least + * @a minsize bytes. + * To understand how a "best fit" is computed look at the + * algorithm in the code. + * Basically the buffers grow exponentially, up to a certain point, + * then the buffer size grows linearly. + * The advantage of this algorithm is that is rapidly grows to a + * large value, but does not explode at the end. + */ + static size_t first_size (size_t minsize); + + /// Compute not the smallest, but the second smallest buffer that + /// will fir @a minsize bytes. + static size_t next_size (size_t minsize); + + /** + * Increase the capacity of mb to contain at least @a minsize bytes. + * If @a minsize is zero the size is increased by an amount at least + * large enough to contain any of the basic IDL types. + * @retval -1 Failure + * @retval 0 Success. + */ + static int grow (ACE_Message_Block *mb, size_t minsize); + + /// Copy a message block chain into a single message block, + /// preserving the alignment of the first message block of the + /// original stream, not the following message blocks. + static void consolidate (ACE_Message_Block *dst, + const ACE_Message_Block *src); + + static size_t total_length (const ACE_Message_Block *begin, + const ACE_Message_Block *end); + + /** + * @name Basic OMG IDL Types + * + * These types are for use in the CDR classes. The cleanest way to + * avoid complaints from all compilers is to define them all. + */ + //@{ + typedef bool Boolean; + typedef unsigned char Octet; + typedef char Char; + typedef ACE_WCHAR_T WChar; + typedef ACE_INT16 Short; + typedef ACE_UINT16 UShort; + typedef ACE_INT32 Long; + typedef ACE_UINT32 ULong; + typedef ACE_UINT64 ULongLong; + +# if (defined (_MSC_VER)) || (defined (__BORLANDC__)) + typedef __int64 LongLong; +# elif ACE_SIZEOF_LONG == 8 && !defined(_CRAYMPP) + typedef long LongLong; +# elif defined(__TANDEM) + typedef long long LongLong; +# elif ACE_SIZEOF_LONG_LONG == 8 && !defined (ACE_LACKS_LONGLONG_T) +# if defined (sun) && !defined (ACE_LACKS_U_LONGLONG_T) + // sun #defines u_longlong_t, maybe other platforms do also. + // Use it, at least with g++, so that its -pedantic doesn't + // complain about no ANSI C++ long long. + typedef longlong_t LongLong; +# else + // LynxOS 2.5.0 and Linux don't have u_longlong_t. + typedef long long LongLong; +# endif /* sun */ +# else /* no native 64 bit integer type */ +# define NONNATIVE_LONGLONG + struct ACE_Export LongLong + { +# if defined (ACE_BIG_ENDIAN) + ACE_CDR::Long h; + ACE_CDR::Long l; +# else + ACE_CDR::Long l; + ACE_CDR::Long h; +# endif /* ! ACE_BIG_ENDIAN */ + + /** + * @name Overloaded Relation Operators. + * + * The canonical comparison operators. + */ + //@{ + bool operator== (const LongLong &rhs) const; + bool operator!= (const LongLong &rhs) const; + //@} + }; +# endif /* no native 64 bit integer type */ + +# if defined (NONNATIVE_LONGLONG) +# define ACE_CDR_LONGLONG_INITIALIZER {0,0} +# else +# define ACE_CDR_LONGLONG_INITIALIZER 0 +# endif /* NONNATIVE_LONGLONG */ + +# if ACE_SIZEOF_FLOAT == 4 + typedef float Float; +# else /* ACE_SIZEOF_FLOAT != 4 */ + struct Float + { +# if ACE_SIZEOF_INT == 4 + // Use unsigned int to get word alignment. + unsigned int f; +# else /* ACE_SIZEOF_INT != 4 */ + // Applications will probably have trouble with this. + char f[4]; +# if defined(_UNICOS) && !defined(_CRAYMPP) + Float (void); + Float (const float &init); + Float & operator= (const float &rhs); + bool operator!= (const Float &rhs) const; +# endif /* _UNICOS */ +# endif /* ACE_SIZEOF_INT != 4 */ + }; +# endif /* ACE_SIZEOF_FLOAT != 4 */ + +# if ACE_SIZEOF_DOUBLE == 8 + typedef double Double; +# else /* ACE_SIZEOF_DOUBLE != 8 */ + struct Double + { +# if ACE_SIZEOF_LONG == 8 + // Use u long to get word alignment. + unsigned long f; +# else /* ACE_SIZEOF_INT != 8 */ + // Applications will probably have trouble with this. + char f[8]; +# endif /* ACE_SIZEOF_INT != 8 */ + }; +# endif /* ACE_SIZEOF_DOUBLE != 8 */ + + // 94-9-32 Appendix A defines a 128 bit floating point "long + // double" data type, with greatly extended precision and four + // more bits of exponent (compared to "double"). This is an IDL + // extension, not yet standard. + +# if ACE_SIZEOF_LONG_DOUBLE == 16 + typedef long double LongDouble; +# define ACE_CDR_LONG_DOUBLE_INITIALIZER 0 +# define ACE_CDR_LONG_DOUBLE_ASSIGNMENT(LHS, RHS) LHS = RHS +# else +# define NONNATIVE_LONGDOUBLE +# define ACE_CDR_LONG_DOUBLE_INITIALIZER {{0}} +# define ACE_CDR_LONG_DOUBLE_ASSIGNMENT(LHS, RHS) LHS.assign (RHS) + struct ACE_Export LongDouble + { + // VxWorks' compiler (gcc 2.96) gets confused by the operator long + // double, so we avoid using long double as the NativeImpl. + // Linux's x86 long double format (12 or 16 bytes) is incompatible + // with Windows, Solaris, AIX, MacOS X and HP-UX (and probably others) + // long double format (8 or 16 bytes). If you need 32-bit Linux to + // inter-operate with 64-bit Linux you will want to define this + // macro to 0 so that "long double" is used. Otherwise, do not define + // this macro. +# if defined (ACE_CDR_IMPLEMENT_WITH_NATIVE_DOUBLE) && \ + (ACE_CDR_IMPLEMENT_WITH_NATIVE_DOUBLE == 1) + typedef double NativeImpl; +# else + typedef long double NativeImpl; +# endif /* ACE_CDR_IMPLEMENT_WITH_NATIVE_DOUBLE==1 */ + + char ld[16]; + + LongDouble& assign (const NativeImpl& rhs); + LongDouble& assign (const LongDouble& rhs); + + bool operator== (const LongDouble &rhs) const; + bool operator!= (const LongDouble &rhs) const; + + LongDouble& operator*= (const NativeImpl rhs) { + return this->assign (static_cast (*this) * rhs); + } + LongDouble& operator/= (const NativeImpl rhs) { + return this->assign (static_cast (*this) / rhs); + } + LongDouble& operator+= (const NativeImpl rhs) { + return this->assign (static_cast (*this) + rhs); + } + LongDouble& operator-= (const NativeImpl rhs) { + return this->assign (static_cast (*this) - rhs); + } + LongDouble& operator++ () { + return this->assign (static_cast (*this) + 1); + } + LongDouble& operator-- () { + return this->assign (static_cast (*this) - 1); + } + LongDouble operator++ (int) { + LongDouble ldv = *this; + this->assign (static_cast (*this) + 1); + return ldv; + } + LongDouble operator-- (int) { + LongDouble ldv = *this; + this->assign (static_cast (*this) - 1); + return ldv; + } + + operator NativeImpl () const; + }; +# endif /* ACE_SIZEOF_LONG_DOUBLE != 16 */ + + //@} + +#if !defined (ACE_CDR_GIOP_MAJOR_VERSION) +# define ACE_CDR_GIOP_MAJOR_VERSION 1 +#endif /*ACE_CDR_GIOP_MAJOR_VERSION */ + +#if !defined (ACE_CDR_GIOP_MINOR_VERSION) +# define ACE_CDR_GIOP_MINOR_VERSION 2 +#endif /* ACE_CDR_GIOP_MINOR_VERSION */ +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +# include "ace/CDR_Base.inl" +#endif /* __ACE_INLINE__ */ + + +#include /**/ "ace/post.h" + +#endif /* ACE_CDR_BASE_H */ diff --git a/dep/ACE_wrappers/ace/CDR_Base.inl b/dep/ACE_wrappers/ace/CDR_Base.inl new file mode 100644 index 00000000000..85373170af7 --- /dev/null +++ b/dep/ACE_wrappers/ace/CDR_Base.inl @@ -0,0 +1,255 @@ +// -*- C++ -*- +// +// $Id: CDR_Base.inl 80826 2008-03-04 14:51:23Z wotte $ + +#if defined (ACE_HAS_INTRINSIC_BYTESWAP) +// Take advantage of MSVC++ byte swapping compiler intrinsics (found +// in ). +# pragma intrinsic (_byteswap_ushort, _byteswap_ulong, _byteswap_uint64) +#endif /* ACE_HAS_INTRINSIC_BYTESWAP */ + +#if defined (ACE_HAS_BSWAP_16) || defined (ACE_HAS_BSWAP_32) || defined (ACE_HAS_BSWAP_64) +# include "ace/os_include/os_byteswap.h" +#endif + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +// +// The ACE_CDR::swap_X and ACE_CDR::swap_X_array routines are broken +// in 5 cases for optimization: +// +// * MSVC++ 7.1 or better +// => Compiler intrinsics +// +// * AMD64 CPU + gnu g++ +// => gcc amd64 inline assembly. +// +// * x86 Pentium CPU + gnu g++ +// (ACE_HAS_PENTIUM && __GNUG__) +// => gcc x86 inline assembly. +// +// * x86 Pentium CPU and (_MSC_VER) or BORLAND C++) +// (ACE_HAS_PENTIUM && ( _MSC_VER || __BORLANDC__ ) +// => MSC x86 inline assembly. +// +// * 64 bit architecture +// (ACE_SIZEOF_LONG == 8) +// => shift/masks using 64bit words. +// +// * default +// (none of the above) +// => shift/masks using 32bit words. +// +// +// Some things you could find useful to know if you intend to mess +// with this optimizations for swaps: +// +// * MSVC++ don't assume register values are conserved between +// statements. So you can clobber any register you want, +// whenever you want (well not *anyone* really, see manual). +// The MSVC++ optimizer will try to pick different registers +// for the C++ statements sorrounding your asm block, and if +// it's not possible will use the stack. +// +// * If you clobber registers with asm statements in gcc, you +// better do it in an asm-only function, or save/restore them +// before/after in the stack. If not, sorrounding C statements +// could end using the same registers and big-badda-bum (been +// there, done that...). The big-badda-bum could happen *even +// if you specify the clobbered register in your asm's*. +// Even better, use gcc asm syntax for detecting the register +// asigned to a certain variable so you don't have to clobber any +// register directly. +// + +ACE_INLINE void +ACE_CDR::swap_2 (const char *orig, char* target) +{ +#if defined (ACE_HAS_INTRINSIC_BYTESWAP) + // Take advantage of MSVC++ compiler intrinsic byte swapping + // function. + *reinterpret_cast (target) = + _byteswap_ushort (*reinterpret_cast (orig)); +#elif defined (ACE_HAS_BSWAP16) + *reinterpret_cast (target) = + bswap16 (*reinterpret_cast (orig)); +#elif defined (ACE_HAS_BSWAP_16) + *reinterpret_cast (target) = + bswap_16 (*reinterpret_cast (orig)); +#elif defined(ACE_HAS_INTEL_ASSEMBLY) + unsigned short a = + *reinterpret_cast (orig); + asm( "rolw $8, %0" : "=r" (a) : "0" (a) ); + *reinterpret_cast (target) = a; +#elif defined (ACE_HAS_PENTIUM) \ + && (defined(_MSC_VER) || defined(__BORLANDC__)) \ + && !defined(ACE_LACKS_INLINE_ASSEMBLY) + __asm mov ebx, orig; + __asm mov ecx, target; + __asm mov ax, [ebx]; + __asm rol ax, 8; + __asm mov [ecx], ax; +#else + register ACE_UINT16 usrc = * reinterpret_cast (orig); + register ACE_UINT16* udst = reinterpret_cast (target); + *udst = (usrc << 8) | (usrc >> 8); +#endif /* ACE_HAS_PENTIUM */ +} + +ACE_INLINE void +ACE_CDR::swap_4 (const char* orig, char* target) +{ +#if defined (ACE_HAS_INTRINSIC_BYTESWAP) + // Take advantage of MSVC++ compiler intrinsic byte swapping + // function. + *reinterpret_cast (target) = + _byteswap_ulong (*reinterpret_cast (orig)); +#elif defined (ACE_HAS_BSWAP32) + *reinterpret_cast (target) = + bswap32 (*reinterpret_cast (orig)); +#elif defined (ACE_HAS_BSWAP_32) + *reinterpret_cast (target) = + bswap_32 (*reinterpret_cast (orig)); +#elif defined(ACE_HAS_INTEL_ASSEMBLY) + // We have ACE_HAS_PENTIUM, so we know the sizeof's. + register unsigned int j = + *reinterpret_cast (orig); + asm ("bswap %1" : "=r" (j) : "0" (j)); + *reinterpret_cast (target) = j; +#elif defined(ACE_HAS_PENTIUM) \ + && (defined(_MSC_VER) || defined(__BORLANDC__)) \ + && !defined(ACE_LACKS_INLINE_ASSEMBLY) + __asm mov ebx, orig; + __asm mov ecx, target; + __asm mov eax, [ebx]; + __asm bswap eax; + __asm mov [ecx], eax; +#else + register ACE_UINT32 x = * reinterpret_cast (orig); + x = (x << 24) | ((x & 0xff00) << 8) | ((x & 0xff0000) >> 8) | (x >> 24); + * reinterpret_cast (target) = x; +#endif /* ACE_HAS_INTRINSIC_BYTESWAP */ +} + +ACE_INLINE void +ACE_CDR::swap_8 (const char* orig, char* target) +{ +#if defined (ACE_HAS_INTRINSIC_BYTESWAP) + // Take advantage of MSVC++ compiler intrinsic byte swapping + // function. + *reinterpret_cast (target) = + _byteswap_uint64 (*reinterpret_cast (orig)); +#elif defined (ACE_HAS_BSWAP64) + *reinterpret_cast (target) = + bswap64 (*reinterpret_cast (orig)); +#elif defined (ACE_HAS_BSWAP_64) + *reinterpret_cast (target) = + bswap_64 (*reinterpret_cast (orig)); +#elif (defined (__amd64__) || defined (__x86_64__)) && defined(__GNUG__) + register unsigned long x = + * reinterpret_cast (orig); + asm ("bswapq %1" : "=r" (x) : "0" (x)); + *reinterpret_cast (target) = x; +#elif defined(ACE_HAS_PENTIUM) && defined(__GNUG__) + register unsigned int i = + *reinterpret_cast (orig); + register unsigned int j = + *reinterpret_cast (orig + 4); + asm ("bswap %1" : "=r" (i) : "0" (i)); + asm ("bswap %1" : "=r" (j) : "0" (j)); + *reinterpret_cast (target + 4) = i; + *reinterpret_cast (target) = j; +#elif defined(ACE_HAS_PENTIUM) \ + && (defined(_MSC_VER) || defined(__BORLANDC__)) \ + && !defined(ACE_LACKS_INLINE_ASSEMBLY) + __asm mov ecx, orig; + __asm mov edx, target; + __asm mov eax, [ecx]; + __asm mov ebx, 4[ecx]; + __asm bswap eax; + __asm bswap ebx; + __asm mov 4[edx], eax; + __asm mov [edx], ebx; +#elif ACE_SIZEOF_LONG == 8 + // 64 bit architecture. + register unsigned long x = + * reinterpret_cast (orig); + register unsigned long x84 = (x & 0x000000ff000000ffUL) << 24; + register unsigned long x73 = (x & 0x0000ff000000ff00UL) << 8; + register unsigned long x62 = (x & 0x00ff000000ff0000UL) >> 8; + register unsigned long x51 = (x & 0xff000000ff000000UL) >> 24; + x = (x84 | x73 | x62 | x51); + x = (x << 32) | (x >> 32); + *reinterpret_cast (target) = x; +#else + register ACE_UINT32 x = + * reinterpret_cast (orig); + register ACE_UINT32 y = + * reinterpret_cast (orig + 4); + x = (x << 24) | ((x & 0xff00) << 8) | ((x & 0xff0000) >> 8) | (x >> 24); + y = (y << 24) | ((y & 0xff00) << 8) | ((y & 0xff0000) >> 8) | (y >> 24); + * reinterpret_cast (target) = y; + * reinterpret_cast (target + 4) = x; +#endif /* ACE_HAS_INTRINSIC_BYTESWAP */ +} + +ACE_INLINE void +ACE_CDR::swap_16 (const char* orig, char* target) +{ + swap_8 (orig + 8, target); + swap_8 (orig, target + 8); +} + +ACE_INLINE size_t +ACE_CDR::first_size (size_t minsize) +{ + if (minsize == 0) + return ACE_CDR::DEFAULT_BUFSIZE; + + size_t newsize = ACE_CDR::DEFAULT_BUFSIZE; + while (newsize < minsize) + { + if (newsize < ACE_CDR::EXP_GROWTH_MAX) + { + // We grow exponentially at the beginning, this is fast and + // reduces the number of allocations. + + // Quickly multiply by two using a bit shift. This is + // guaranteed to work since the variable is an unsigned + // integer. + newsize <<= 1; + } + else + { + // but continuing with exponential growth can result in over + // allocations and easily yield an allocation failure. + // So we grow linearly when the buffer is too big. + newsize += ACE_CDR::LINEAR_GROWTH_CHUNK; + } + } + return newsize; +} + +ACE_INLINE size_t +ACE_CDR::next_size (size_t minsize) +{ + size_t newsize = ACE_CDR::first_size (minsize); + + if (newsize == minsize) + { + // If necessary increment the size + if (newsize < ACE_CDR::EXP_GROWTH_MAX) + // Quickly multiply by two using a bit shift. This is + // guaranteed to work since the variable is an unsigned + // integer. + newsize <<= 1; + else + newsize += ACE_CDR::LINEAR_GROWTH_CHUNK; + } + + return newsize; +} + +ACE_END_VERSIONED_NAMESPACE_DECL + +// **************************************************************** diff --git a/dep/ACE_wrappers/ace/CDR_Size.cpp b/dep/ACE_wrappers/ace/CDR_Size.cpp new file mode 100644 index 00000000000..96970927037 --- /dev/null +++ b/dep/ACE_wrappers/ace/CDR_Size.cpp @@ -0,0 +1,262 @@ +#include "ace/CDR_Size.h" +#include "ace/SString.h" +#include "ace/OS_Memory.h" +#include "ace/Truncate.h" + +#if !defined (__ACE_INLINE__) +# include "ace/CDR_Size.inl" +#endif /* ! __ACE_INLINE__ */ + +ACE_RCSID (ace, + CDR_Size, + "$Id: CDR_Size.cpp 82559 2008-08-07 20:23:07Z parsons $") + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_CDR::Boolean +ACE_SizeCDR::write_wchar (ACE_CDR::WChar x) +{ + // Note: translator framework is not supported. + // + if (ACE_OutputCDR::wchar_maxbytes () == 0) + { + errno = EACCES; + return (this->good_bit_ = false); + } + + if (static_cast (major_version_) == 1 + && static_cast (minor_version_) == 2) + { + ACE_CDR::Octet len = + static_cast (ACE_OutputCDR::wchar_maxbytes ()); + + if (this->write_1 (&len)) + { + if (ACE_OutputCDR::wchar_maxbytes () == sizeof(ACE_CDR::WChar)) + { + return + this->write_octet_array ( + reinterpret_cast (&x), + static_cast (len)); + } + else + { + if (ACE_OutputCDR::wchar_maxbytes () == 2) + { + ACE_CDR::Short sx = static_cast (x); + return + this->write_octet_array ( + reinterpret_cast (&sx), + static_cast (len)); + } + else + { + ACE_CDR::Octet ox = static_cast (x); + return + this->write_octet_array ( + reinterpret_cast (&ox), + static_cast (len)); + } + } + } + } + else if (static_cast (minor_version_) == 0) + { // wchar is not allowed with GIOP 1.0. + errno = EINVAL; + return (this->good_bit_ = false); + } + + if (ACE_OutputCDR::wchar_maxbytes () == sizeof (ACE_CDR::WChar)) + { + const void *temp = &x; + return this->write_4 (reinterpret_cast (temp)); + } + else if (ACE_OutputCDR::wchar_maxbytes () == 2) + { + ACE_CDR::Short sx = static_cast (x); + return this->write_2 (reinterpret_cast (&sx)); + } + + ACE_CDR::Octet ox = static_cast (x); + return this->write_1 (reinterpret_cast (&ox)); +} + +ACE_CDR::Boolean +ACE_SizeCDR::write_string (ACE_CDR::ULong len, + const ACE_CDR::Char *x) +{ + // Note: translator framework is not supported. + // + if (len != 0) + { + if (this->write_ulong (len + 1)) + return this->write_char_array (x, len + 1); + } + else + { + // Be nice to programmers: treat nulls as empty strings not + // errors. (OMG-IDL supports languages that don't use the C/C++ + // notion of null v. empty strings; nulls aren't part of the OMG-IDL + // string model.) + if (this->write_ulong (1)) + return this->write_char (0); + } + + return (this->good_bit_ = false); +} + +ACE_CDR::Boolean +ACE_SizeCDR::write_string (const ACE_CString &x) +{ + // @@ Leave this method in here, not the `.i' file so that we don't + // have to unnecessarily pull in the `ace/SString.h' header. + return this->write_string (static_cast (x.length ()), + x.c_str()); +} + +ACE_CDR::Boolean +ACE_SizeCDR::write_wstring (ACE_CDR::ULong len, + const ACE_CDR::WChar *x) +{ + // Note: translator framework is not supported. + // + if (ACE_OutputCDR::wchar_maxbytes () == 0) + { + errno = EACCES; + return (this->good_bit_ = false); + } + + if (static_cast (this->major_version_) == 1 + && static_cast (this->minor_version_) == 2) + { + if (x != 0) + { + //In GIOP 1.2 the length field contains the number of bytes + //the wstring occupies rather than number of wchars + //Taking sizeof might not be a good way! This is a temporary fix. + ACE_CDR::Boolean good_ulong = + this->write_ulong ( + ACE_Utils::truncate_cast ( + ACE_OutputCDR::wchar_maxbytes () * len)); + + if (good_ulong) + { + return this->write_wchar_array (x, len); + } + } + else + { + //In GIOP 1.2 zero length wstrings are legal + return this->write_ulong (0); + } + } + + else + if (x != 0) + { + if (this->write_ulong (len + 1)) + return this->write_wchar_array (x, len + 1); + } + else if (this->write_ulong (1)) + return this->write_wchar (0); + return (this->good_bit_ = false); +} + +ACE_CDR::Boolean +ACE_SizeCDR::write_1 (const ACE_CDR::Octet *) +{ + this->adjust (1); + return true; +} + +ACE_CDR::Boolean +ACE_SizeCDR::write_2 (const ACE_CDR::UShort *) +{ + this->adjust (ACE_CDR::SHORT_SIZE); + return true; +} + +ACE_CDR::Boolean +ACE_SizeCDR::write_4 (const ACE_CDR::ULong *) +{ + this->adjust (ACE_CDR::LONG_SIZE); + return true; +} + +ACE_CDR::Boolean +ACE_SizeCDR::write_8 (const ACE_CDR::ULongLong *) +{ + this->adjust (ACE_CDR::LONGLONG_SIZE); + return true; +} + +ACE_CDR::Boolean +ACE_SizeCDR::write_16 (const ACE_CDR::LongDouble *) +{ + this->adjust (ACE_CDR::LONGDOUBLE_SIZE, + ACE_CDR::LONGDOUBLE_ALIGN); + return true; +} + +ACE_CDR::Boolean +ACE_SizeCDR::write_wchar_array_i (const ACE_CDR::WChar *, + ACE_CDR::ULong length) +{ + if (length == 0) + return true; + + size_t const align = (ACE_OutputCDR::wchar_maxbytes () == 2) ? + ACE_CDR::SHORT_ALIGN : + ACE_CDR::OCTET_ALIGN; + + this->adjust (ACE_OutputCDR::wchar_maxbytes () * length, align); + return true; +} + + +ACE_CDR::Boolean +ACE_SizeCDR::write_array (const void *, + size_t size, + size_t align, + ACE_CDR::ULong length) +{ + if (length == 0) + return true; + + this->adjust (size * length, align); + return true; +} + +ACE_CDR::Boolean +ACE_SizeCDR::write_boolean_array (const ACE_CDR::Boolean*, + ACE_CDR::ULong length) +{ + this->adjust (length, 1); + return true; +} + +void +ACE_SizeCDR::adjust (size_t size) +{ + adjust (size, size); +} + +void +ACE_SizeCDR::adjust (size_t size, + size_t align) +{ +#if !defined (ACE_LACKS_CDR_ALIGNMENT) + const size_t offset = ACE_align_binary (size_, align) - size_; + size_ += offset; +#endif /* ACE_LACKS_CDR_ALIGNMENT */ + size_ += size; +} + +ACE_CDR::Boolean +operator<< (ACE_SizeCDR &ss, const ACE_CString &x) +{ + ss.write_string (x); + return ss.good_bit (); +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/CDR_Size.h b/dep/ACE_wrappers/ace/CDR_Size.h new file mode 100644 index 00000000000..a0b3c462ca8 --- /dev/null +++ b/dep/ACE_wrappers/ace/CDR_Size.h @@ -0,0 +1,241 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file CDR_Size.h + * + * $Id: CDR_Size.h 80826 2008-03-04 14:51:23Z wotte $ + * + * + * ACE Common Data Representation (CDR) size-calculating stream. + * + * + * The current implementation assumes that the host has 1-byte, + * 2-byte and 4-byte integral types, and that it has single + * precision and double precision IEEE floats. + * Those assumptions are pretty good these days, with Crays beign + * the only known exception. + * + * + * @author Boris Kolpackov + * + */ +//============================================================================= + +#ifndef ACE_CDR_SIZE_H +#define ACE_CDR_SIZE_H + +#include /**/ "ace/pre.h" + +#include "ace/CDR_Base.h" +#include "ace/CDR_Stream.h" // for ACE_OutputCDR::from_* + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/SStringfwd.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +/** + * @class ACE_SizeCDR + * + * @brief A CDR stream for calculating size of the representation. + * + */ +class ACE_Export ACE_SizeCDR +{ +public: + /// Default constructor. + ACE_SizeCDR (ACE_CDR::Octet major_version = ACE_CDR_GIOP_MAJOR_VERSION, + ACE_CDR::Octet minor_version = ACE_CDR_GIOP_MINOR_VERSION); + + /// Returns @c false if an error has ocurred. + bool good_bit (void) const; + + + /// Reset current size. + void reset (void); + + + /// Return current size. + size_t total_length (void) const; + + + // Return 0 on failure and 1 on success. + //@{ @name Size-calculating pseudo-write operations + ACE_CDR::Boolean write_boolean (ACE_CDR::Boolean x); + ACE_CDR::Boolean write_char (ACE_CDR::Char x); + ACE_CDR::Boolean write_wchar (ACE_CDR::WChar x); + ACE_CDR::Boolean write_octet (ACE_CDR::Octet x); + ACE_CDR::Boolean write_short (ACE_CDR::Short x); + ACE_CDR::Boolean write_ushort (ACE_CDR::UShort x); + ACE_CDR::Boolean write_long (ACE_CDR::Long x); + ACE_CDR::Boolean write_ulong (ACE_CDR::ULong x); + ACE_CDR::Boolean write_longlong (const ACE_CDR::LongLong &x); + ACE_CDR::Boolean write_ulonglong (const ACE_CDR::ULongLong &x); + ACE_CDR::Boolean write_float (ACE_CDR::Float x); + ACE_CDR::Boolean write_double (const ACE_CDR::Double &x); + ACE_CDR::Boolean write_longdouble (const ACE_CDR::LongDouble &x); + + /// For string we offer methods that accept a precomputed length. + ACE_CDR::Boolean write_string (const ACE_CDR::Char *x); + ACE_CDR::Boolean write_string (ACE_CDR::ULong len, + const ACE_CDR::Char *x); + ACE_CDR::Boolean write_string (const ACE_CString &x); + ACE_CDR::Boolean write_wstring (const ACE_CDR::WChar *x); + ACE_CDR::Boolean write_wstring (ACE_CDR::ULong length, + const ACE_CDR::WChar *x); + //@} + + /// @note the portion written starts at and ends + /// at . + /// The length is *NOT* stored into the CDR stream. + //@{ @name Array write operations + ACE_CDR::Boolean write_boolean_array (const ACE_CDR::Boolean *x, + ACE_CDR::ULong length); + ACE_CDR::Boolean write_char_array (const ACE_CDR::Char *x, + ACE_CDR::ULong length); + ACE_CDR::Boolean write_wchar_array (const ACE_CDR::WChar* x, + ACE_CDR::ULong length); + ACE_CDR::Boolean write_octet_array (const ACE_CDR::Octet* x, + ACE_CDR::ULong length); + ACE_CDR::Boolean write_short_array (const ACE_CDR::Short *x, + ACE_CDR::ULong length); + ACE_CDR::Boolean write_ushort_array (const ACE_CDR::UShort *x, + ACE_CDR::ULong length); + ACE_CDR::Boolean write_long_array (const ACE_CDR::Long *x, + ACE_CDR::ULong length); + ACE_CDR::Boolean write_ulong_array (const ACE_CDR::ULong *x, + ACE_CDR::ULong length); + ACE_CDR::Boolean write_longlong_array (const ACE_CDR::LongLong* x, + ACE_CDR::ULong length); + ACE_CDR::Boolean write_ulonglong_array (const ACE_CDR::ULongLong *x, + ACE_CDR::ULong length); + ACE_CDR::Boolean write_float_array (const ACE_CDR::Float *x, + ACE_CDR::ULong length); + ACE_CDR::Boolean write_double_array (const ACE_CDR::Double *x, + ACE_CDR::ULong length); + ACE_CDR::Boolean write_longdouble_array (const ACE_CDR::LongDouble* x, + ACE_CDR::ULong length); + + /// + /// Adjust to @a size and count octets. + void adjust (size_t size); + + /// As above, but now the size and alignment requirements may be + /// different. + void adjust (size_t size, + size_t align); + +private: + /// disallow copying... + ACE_SizeCDR (const ACE_SizeCDR& rhs); + ACE_SizeCDR& operator= (const ACE_SizeCDR& rhs); + + ACE_CDR::Boolean write_1 (const ACE_CDR::Octet *x); + ACE_CDR::Boolean write_2 (const ACE_CDR::UShort *x); + ACE_CDR::Boolean write_4 (const ACE_CDR::ULong *x); + ACE_CDR::Boolean write_8 (const ACE_CDR::ULongLong *x); + ACE_CDR::Boolean write_16 (const ACE_CDR::LongDouble *x); + + /** + * write an array of @a length elements, each of @a size bytes and the + * start aligned at a multiple of . The elements are assumed + * to be packed with the right alignment restrictions. It is mostly + * designed for buffers of the basic types. + * + * This operation uses ; as explained above it is expected + * that using assignment is faster that for one element, + * but for several elements should be more efficient, it + * could be interesting to find the break even point and optimize + * for that case, but that would be too platform dependent. + */ + ACE_CDR::Boolean write_array (const void *x, + size_t size, + size_t align, + ACE_CDR::ULong length); + + + ACE_CDR::Boolean write_wchar_array_i (const ACE_CDR::WChar* x, + ACE_CDR::ULong length); + +private: + /// Set to false when an error ocurrs. + bool good_bit_; + + /// Current size. + size_t size_; + +protected: + /// GIOP version information + ACE_CDR::Octet major_version_; + ACE_CDR::Octet minor_version_; +}; + +// @@ This operator should not be inlined since they force SString.h +// to be included in this header. +extern ACE_Export ACE_CDR::Boolean operator<< (ACE_SizeCDR &ss, + const ACE_CString &x); + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +# include "ace/CDR_Size.inl" +#else /* __ACE_INLINE__ */ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +// Not used by CORBA or TAO +extern ACE_Export ACE_CDR::Boolean operator<< (ACE_SizeCDR &ss, + ACE_CDR::Char x); + +// CDR size-calculating output operators for primitive types + +extern ACE_Export ACE_CDR::Boolean operator<< (ACE_SizeCDR &ss, + ACE_CDR::Short x); +extern ACE_Export ACE_CDR::Boolean operator<< (ACE_SizeCDR &ss, + ACE_CDR::UShort x); +extern ACE_Export ACE_CDR::Boolean operator<< (ACE_SizeCDR &ss, + ACE_CDR::Long x); +extern ACE_Export ACE_CDR::Boolean operator<< (ACE_SizeCDR &ss, + ACE_CDR::ULong x); +extern ACE_Export ACE_CDR::Boolean operator<< (ACE_SizeCDR &ss, + ACE_CDR::LongLong x); +extern ACE_Export ACE_CDR::Boolean operator<< (ACE_SizeCDR &ss, + ACE_CDR::ULongLong x); +extern ACE_Export ACE_CDR::Boolean operator<< (ACE_SizeCDR& ss, + ACE_CDR::LongDouble x); +extern ACE_Export ACE_CDR::Boolean operator<< (ACE_SizeCDR &ss, + ACE_CDR::Float x); +extern ACE_Export ACE_CDR::Boolean operator<< (ACE_SizeCDR &ss, + ACE_CDR::Double x); + +// CDR size-calculating output operator from helper classes + +extern ACE_Export ACE_CDR::Boolean operator<< (ACE_SizeCDR &ss, + ACE_OutputCDR::from_boolean x); +extern ACE_Export ACE_CDR::Boolean operator<< (ACE_SizeCDR &ss, + ACE_OutputCDR::from_char x); +extern ACE_Export ACE_CDR::Boolean operator<< (ACE_SizeCDR &ss, + ACE_OutputCDR::from_wchar x); +extern ACE_Export ACE_CDR::Boolean operator<< (ACE_SizeCDR &ss, + ACE_OutputCDR::from_octet x); +extern ACE_Export ACE_CDR::Boolean operator<< (ACE_SizeCDR &ss, + ACE_OutputCDR::from_string x); +extern ACE_Export ACE_CDR::Boolean operator<< (ACE_SizeCDR &ss, + ACE_OutputCDR::from_wstring x); +extern ACE_Export ACE_CDR::Boolean operator<< (ACE_SizeCDR &ss, + const ACE_CDR::Char* x); +extern ACE_Export ACE_CDR::Boolean operator<< (ACE_SizeCDR &ss, + const ACE_CDR::WChar* x); + +ACE_END_VERSIONED_NAMESPACE_DECL + +#endif /* __ACE_INLINE__ */ + + +#include /**/ "ace/post.h" + +#endif /* ACE_CDR_SIZE_H */ diff --git a/dep/ACE_wrappers/ace/CDR_Size.inl b/dep/ACE_wrappers/ace/CDR_Size.inl new file mode 100644 index 00000000000..4ea81523faf --- /dev/null +++ b/dep/ACE_wrappers/ace/CDR_Size.inl @@ -0,0 +1,424 @@ +// -*- C++ -*- +// +// $Id: CDR_Size.inl 80826 2008-03-04 14:51:23Z wotte $ + +#include "ace/OS_NS_string.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_INLINE +ACE_SizeCDR::ACE_SizeCDR (ACE_CDR::Octet major_version, + ACE_CDR::Octet minor_version) + : good_bit_ (true), + size_ (0), + major_version_ (major_version), + minor_version_ (minor_version) +{ +} + +ACE_INLINE bool +ACE_SizeCDR::good_bit (void) const +{ + return this->good_bit_; +} + +ACE_INLINE void +ACE_SizeCDR::reset (void) +{ + this->size_ = 0; +} + +ACE_INLINE size_t +ACE_SizeCDR::total_length (void) const +{ + return this->size_; +} + + +// Encode the CDR stream. + +ACE_INLINE ACE_CDR::Boolean +ACE_SizeCDR::write_octet (ACE_CDR::Octet x) +{ + return this->write_1 (reinterpret_cast (&x)); +} + +ACE_INLINE ACE_CDR::Boolean +ACE_SizeCDR::write_boolean (ACE_CDR::Boolean x) +{ + return (ACE_CDR::Boolean) this->write_octet (x ? (ACE_CDR::Octet) 1 : (ACE_CDR::Octet) 0); +} + +ACE_INLINE ACE_CDR::Boolean +ACE_SizeCDR::write_char (ACE_CDR::Char x) +{ + // Note: translator framework is not supported. + // + return this->write_1 (reinterpret_cast (&x)); +} + +ACE_INLINE ACE_CDR::Boolean +ACE_SizeCDR::write_short (ACE_CDR::Short x) +{ + return this->write_2 (reinterpret_cast (&x)); +} + +ACE_INLINE ACE_CDR::Boolean +ACE_SizeCDR::write_ushort (ACE_CDR::UShort x) +{ + return this->write_2 (reinterpret_cast (&x)); +} + +ACE_INLINE ACE_CDR::Boolean +ACE_SizeCDR::write_long (ACE_CDR::Long x) +{ + return this->write_4 (reinterpret_cast (&x)); +} + +ACE_INLINE ACE_CDR::Boolean +ACE_SizeCDR::write_ulong (ACE_CDR::ULong x) +{ + return this->write_4 (reinterpret_cast (&x)); +} + +ACE_INLINE ACE_CDR::Boolean +ACE_SizeCDR::write_longlong (const ACE_CDR::LongLong &x) +{ + return this->write_8 (reinterpret_cast (&x)); +} + +ACE_INLINE ACE_CDR::Boolean +ACE_SizeCDR::write_ulonglong (const ACE_CDR::ULongLong &x) +{ + const void *temp = &x; + return this->write_8 (reinterpret_cast (temp)); +} + +ACE_INLINE ACE_CDR::Boolean +ACE_SizeCDR::write_float (ACE_CDR::Float x) +{ + const void *temp = &x; + return this->write_4 (reinterpret_cast (temp)); +} + +ACE_INLINE ACE_CDR::Boolean +ACE_SizeCDR::write_double (const ACE_CDR::Double &x) +{ + const void *temp = &x; + return this->write_8 (reinterpret_cast (temp)); +} + +ACE_INLINE ACE_CDR::Boolean +ACE_SizeCDR::write_longdouble (const ACE_CDR::LongDouble &x) +{ + const void *temp = &x; + return this->write_16 (reinterpret_cast (temp)); +} + +ACE_INLINE ACE_CDR::Boolean +ACE_SizeCDR::write_string (const ACE_CDR::Char *x) +{ + if (x != 0) + { + const ACE_CDR::ULong len = + static_cast (ACE_OS::strlen (x)); + return this->write_string (len, x); + } + return this->write_string (0, 0); +} + +ACE_INLINE ACE_CDR::Boolean +ACE_SizeCDR::write_wstring (const ACE_CDR::WChar *x) +{ + if (x != 0) + { + ACE_CDR::ULong len = + static_cast (ACE_OS::strlen (x)); + return this->write_wstring (len, x); + } + return this->write_wstring (0, 0); +} + +ACE_INLINE ACE_CDR::Boolean +ACE_SizeCDR::write_char_array (const ACE_CDR::Char *x, + ACE_CDR::ULong length) +{ + // Note: translator framework is not supported. + // + return this->write_array (x, + ACE_CDR::OCTET_SIZE, + ACE_CDR::OCTET_ALIGN, + length); +} + +ACE_INLINE ACE_CDR::Boolean +ACE_SizeCDR::write_wchar_array (const ACE_CDR::WChar* x, + ACE_CDR::ULong length) +{ + // Note: translator framework is not supported. + // + if (ACE_OutputCDR::wchar_maxbytes () == 0) + { + errno = EACCES; + return (ACE_CDR::Boolean) (this->good_bit_ = false); + } + if (ACE_OutputCDR::wchar_maxbytes () == sizeof (ACE_CDR::WChar)) + return this->write_array (x, + sizeof (ACE_CDR::WChar), + sizeof (ACE_CDR::WChar) == 2 + ? ACE_CDR::SHORT_ALIGN + : ACE_CDR::LONG_ALIGN, + length); + return this->write_wchar_array_i (x,length); +} + +ACE_INLINE ACE_CDR::Boolean +ACE_SizeCDR::write_octet_array (const ACE_CDR::Octet* x, + ACE_CDR::ULong length) +{ + return this->write_array (x, + ACE_CDR::OCTET_SIZE, + ACE_CDR::OCTET_ALIGN, + length); +} + +ACE_INLINE ACE_CDR::Boolean +ACE_SizeCDR::write_short_array (const ACE_CDR::Short *x, + ACE_CDR::ULong length) +{ + return this->write_array (x, + ACE_CDR::SHORT_SIZE, + ACE_CDR::SHORT_ALIGN, + length); +} + +ACE_INLINE ACE_CDR::Boolean +ACE_SizeCDR::write_ushort_array (const ACE_CDR::UShort *x, + ACE_CDR::ULong length) +{ + return this->write_array (x, + ACE_CDR::SHORT_SIZE, + ACE_CDR::SHORT_ALIGN, + length); +} + +ACE_INLINE ACE_CDR::Boolean +ACE_SizeCDR::write_long_array (const ACE_CDR::Long *x, + ACE_CDR::ULong length) +{ + return this->write_array (x, + ACE_CDR::LONG_SIZE, + ACE_CDR::LONG_ALIGN, + length); +} + +ACE_INLINE ACE_CDR::Boolean +ACE_SizeCDR::write_ulong_array (const ACE_CDR::ULong *x, + ACE_CDR::ULong length) +{ + return this->write_array (x, + ACE_CDR::LONG_SIZE, + ACE_CDR::LONG_ALIGN, + length); +} + +ACE_INLINE ACE_CDR::Boolean +ACE_SizeCDR::write_longlong_array (const ACE_CDR::LongLong *x, + ACE_CDR::ULong length) +{ + return this->write_array (x, + ACE_CDR::LONGLONG_SIZE, + ACE_CDR::LONGLONG_ALIGN, + length); +} + +ACE_INLINE ACE_CDR::Boolean +ACE_SizeCDR::write_ulonglong_array (const ACE_CDR::ULongLong *x, + ACE_CDR::ULong length) +{ + return this->write_array (x, + ACE_CDR::LONGLONG_SIZE, + ACE_CDR::LONGLONG_ALIGN, + length); +} + +ACE_INLINE ACE_CDR::Boolean +ACE_SizeCDR::write_float_array (const ACE_CDR::Float *x, + ACE_CDR::ULong length) +{ + return this->write_array (x, + ACE_CDR::LONG_SIZE, + ACE_CDR::LONG_ALIGN, + length); +} + + +ACE_INLINE ACE_CDR::Boolean +ACE_SizeCDR::write_double_array (const ACE_CDR::Double *x, + ACE_CDR::ULong length) +{ + return this->write_array (x, + ACE_CDR::LONGLONG_SIZE, + ACE_CDR::LONGLONG_ALIGN, + length); +} + +ACE_INLINE ACE_CDR::Boolean +ACE_SizeCDR::write_longdouble_array (const ACE_CDR::LongDouble* x, + ACE_CDR::ULong length) +{ + return this->write_array (x, + ACE_CDR::LONGDOUBLE_SIZE, + ACE_CDR::LONGDOUBLE_ALIGN, + length); +} + + +// **************************************************************** + + +ACE_INLINE ACE_CDR::Boolean +operator<< (ACE_SizeCDR &ss, ACE_CDR::Char x) +{ + ss.write_char (x); + return (ACE_CDR::Boolean) ss.good_bit (); +} + +ACE_INLINE ACE_CDR::Boolean +operator<< (ACE_SizeCDR &ss, ACE_CDR::Short x) +{ + ss.write_short (x); + return (ACE_CDR::Boolean) ss.good_bit (); +} + +ACE_INLINE ACE_CDR::Boolean +operator<< (ACE_SizeCDR &ss, ACE_CDR::UShort x) +{ + ss.write_ushort (x); + return (ACE_CDR::Boolean) ss.good_bit (); +} + +ACE_INLINE ACE_CDR::Boolean +operator<< (ACE_SizeCDR &ss, ACE_CDR::Long x) +{ + ss.write_long (x); + return (ACE_CDR::Boolean) ss.good_bit (); +} + +ACE_INLINE ACE_CDR::Boolean +operator<< (ACE_SizeCDR &ss, ACE_CDR::ULong x) +{ + ss.write_ulong (x); + return (ACE_CDR::Boolean) ss.good_bit (); +} + +ACE_INLINE ACE_CDR::Boolean +operator<< (ACE_SizeCDR &ss, ACE_CDR::LongLong x) +{ + ss.write_longlong (x); + return (ACE_CDR::Boolean) ss.good_bit (); +} + +ACE_INLINE ACE_CDR::Boolean +operator<< (ACE_SizeCDR &ss, ACE_CDR::ULongLong x) +{ + ss.write_ulonglong (x); + return (ACE_CDR::Boolean) ss.good_bit (); +} + +ACE_INLINE ACE_CDR::Boolean +operator<< (ACE_SizeCDR &ss, ACE_CDR::LongDouble x) +{ + ss.write_longdouble (x); + return (ACE_CDR::Boolean) ss.good_bit (); +} + +ACE_INLINE ACE_CDR::Boolean +operator<< (ACE_SizeCDR &ss, ACE_CDR::Float x) +{ + ss.write_float (x); + return (ACE_CDR::Boolean) ss.good_bit (); +} + +ACE_INLINE ACE_CDR::Boolean +operator<< (ACE_SizeCDR &ss, ACE_CDR::Double x) +{ + ss.write_double (x); + return (ACE_CDR::Boolean) ss.good_bit (); +} + +ACE_INLINE ACE_CDR::Boolean +operator<< (ACE_SizeCDR &ss, const ACE_CDR::Char *x) +{ + ss.write_string (x); + return (ACE_CDR::Boolean) ss.good_bit (); +} + +ACE_INLINE ACE_CDR::Boolean +operator<< (ACE_SizeCDR &ss, const ACE_CDR::WChar *x) +{ + ss.write_wstring (x); + return (ACE_CDR::Boolean) ss.good_bit (); +} + +// The following use the helper classes +ACE_INLINE ACE_CDR::Boolean +operator<< (ACE_SizeCDR &ss, ACE_OutputCDR::from_boolean x) +{ + ss.write_boolean (x.val_); + return (ACE_CDR::Boolean) ss.good_bit (); +} + +ACE_INLINE ACE_CDR::Boolean +operator<< (ACE_SizeCDR &ss, ACE_OutputCDR::from_char x) +{ + ss.write_char (x.val_); + return (ACE_CDR::Boolean) ss.good_bit (); +} + +ACE_INLINE ACE_CDR::Boolean +operator<< (ACE_SizeCDR &ss, ACE_OutputCDR::from_wchar x) +{ + ss.write_wchar (x.val_); + return (ACE_CDR::Boolean) ss.good_bit (); +} + +ACE_INLINE ACE_CDR::Boolean +operator<< (ACE_SizeCDR &ss, ACE_OutputCDR::from_octet x) +{ + ss.write_octet (x.val_); + return (ACE_CDR::Boolean) ss.good_bit (); +} + +ACE_INLINE ACE_CDR::Boolean +operator<< (ACE_SizeCDR &ss, ACE_OutputCDR::from_string x) +{ + ACE_CDR::ULong len = 0; + + if (x.val_ != 0) + { + len = static_cast (ACE_OS::strlen (x.val_)); + } + + ss.write_string (len, x.val_); + return + (ACE_CDR::Boolean) (ss.good_bit () && (!x.bound_ || len <= x.bound_)); +} + +ACE_INLINE ACE_CDR::Boolean +operator<< (ACE_SizeCDR &ss, ACE_OutputCDR::from_wstring x) +{ + ACE_CDR::ULong len = 0; + + if (x.val_ != 0) + { + len = static_cast (ACE_OS::strlen (x.val_)); + } + + ss.write_wstring (len, x.val_); + return + (ACE_CDR::Boolean) (ss.good_bit () && (!x.bound_ || len <= x.bound_)); +} + + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/CDR_Stream.cpp b/dep/ACE_wrappers/ace/CDR_Stream.cpp new file mode 100644 index 00000000000..80b405467ec --- /dev/null +++ b/dep/ACE_wrappers/ace/CDR_Stream.cpp @@ -0,0 +1,2068 @@ +#include "ace/CDR_Stream.h" +#include "ace/SString.h" +#include "ace/Auto_Ptr.h" +#include "ace/Truncate.h" + +#if !defined (__ACE_INLINE__) +# include "ace/CDR_Stream.inl" +#endif /* ! __ACE_INLINE__ */ + +ACE_RCSID (ace, + CDR_Stream, + "$Id: CDR_Stream.cpp 82559 2008-08-07 20:23:07Z parsons $") + +// **************************************************************** + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +size_t ACE_OutputCDR::wchar_maxbytes_ = sizeof (ACE_CDR::WChar); + +ACE_OutputCDR::ACE_OutputCDR (size_t size, + int byte_order, + ACE_Allocator *buffer_allocator, + ACE_Allocator *data_block_allocator, + ACE_Allocator *message_block_allocator, + size_t memcpy_tradeoff, + ACE_CDR::Octet major_version, + ACE_CDR::Octet minor_version) + : start_ ((size ? size : (size_t) ACE_CDR::DEFAULT_BUFSIZE) + ACE_CDR::MAX_ALIGNMENT, + ACE_Message_Block::MB_DATA, + 0, + 0, + buffer_allocator, + 0, + 0, + ACE_Time_Value::zero, + ACE_Time_Value::max_time, + data_block_allocator, + message_block_allocator), +#if !defined (ACE_LACKS_CDR_ALIGNMENT) + current_alignment_ (0), +#endif /* ACE_LACKS_CDR_ALIGNMENT */ + current_is_writable_ (true), + do_byte_swap_ (byte_order != ACE_CDR_BYTE_ORDER), + good_bit_ (true), + memcpy_tradeoff_ (memcpy_tradeoff), + major_version_ (major_version), + minor_version_ (minor_version), + char_translator_ (0), + wchar_translator_ (0) + +{ + ACE_CDR::mb_align (&this->start_); + this->current_ = &this->start_; + +#if defined (ACE_HAS_MONITOR_POINTS) && (ACE_HAS_MONITOR_POINTS == 1) + ACE_NEW (this->monitor_, + ACE::Monitor_Control::Size_Monitor); + this->monitor_->receive (this->total_length ()); +#endif /* ACE_HAS_MONITOR_POINTS==1 */ +} + +ACE_OutputCDR::ACE_OutputCDR (char *data, + size_t size, + int byte_order, + ACE_Allocator *buffer_allocator, + ACE_Allocator *data_block_allocator, + ACE_Allocator *message_block_allocator, + size_t memcpy_tradeoff, + ACE_CDR::Octet major_version, + ACE_CDR::Octet minor_version) + : start_ (size, + ACE_Message_Block::MB_DATA, + 0, + data, + buffer_allocator, + 0, + 0, + ACE_Time_Value::zero, + ACE_Time_Value::max_time, + data_block_allocator, + message_block_allocator), +#if !defined (ACE_LACKS_CDR_ALIGNMENT) + current_alignment_ (0), +#endif /* ACE_LACKS_CDR_ALIGNMENT */ + current_is_writable_ (true), + do_byte_swap_ (byte_order != ACE_CDR_BYTE_ORDER), + good_bit_ (true), + memcpy_tradeoff_ (memcpy_tradeoff), + major_version_ (major_version), + minor_version_ (minor_version), + char_translator_ (0), + wchar_translator_ (0) +{ + // We cannot trust the buffer to be properly aligned + ACE_CDR::mb_align (&this->start_); + this->current_ = &this->start_; + +#if defined (ACE_HAS_MONITOR_POINTS) && (ACE_HAS_MONITOR_POINTS == 1) + ACE_NEW (this->monitor_, + ACE::Monitor_Control::Size_Monitor); + this->monitor_->receive (this->total_length ()); +#endif /* ACE_HAS_MONITOR_POINTS==1 */ +} + +ACE_OutputCDR::ACE_OutputCDR (ACE_Data_Block *data_block, + int byte_order, + ACE_Allocator *message_block_allocator, + size_t memcpy_tradeoff, + ACE_CDR::Octet major_version, + ACE_CDR::Octet minor_version) + : start_ (data_block, + ACE_Message_Block::DONT_DELETE, + message_block_allocator), +#if !defined (ACE_LACKS_CDR_ALIGNMENT) + current_alignment_ (0), +#endif /* ACE_LACKS_CDR_ALIGNMENT */ + current_is_writable_ (true), + do_byte_swap_ (byte_order != ACE_CDR_BYTE_ORDER), + good_bit_ (true), + memcpy_tradeoff_ (memcpy_tradeoff), + major_version_ (major_version), + minor_version_ (minor_version), + char_translator_ (0), + wchar_translator_ (0) +{ + // We cannot trust the buffer to be properly aligned + ACE_CDR::mb_align (&this->start_); + this->current_ = &this->start_; + +#if defined (ACE_HAS_MONITOR_POINTS) && (ACE_HAS_MONITOR_POINTS == 1) + ACE_NEW (this->monitor_, + ACE::Monitor_Control::Size_Monitor); + this->monitor_->receive (this->total_length ()); +#endif /* ACE_HAS_MONITOR_POINTS==1 */ +} + +ACE_OutputCDR::ACE_OutputCDR (ACE_Message_Block *data, + int byte_order, + size_t memcpy_tradeoff, + ACE_CDR::Octet major_version, + ACE_CDR::Octet minor_version) + : start_ (data->data_block ()->duplicate ()), +#if !defined (ACE_LACKS_CDR_ALIGNMENT) + current_alignment_ (0), +#endif /* ACE_LACKS_CDR_ALIGNMENT */ + current_is_writable_ (true), + do_byte_swap_ (byte_order != ACE_CDR_BYTE_ORDER), + good_bit_ (true), + memcpy_tradeoff_ (memcpy_tradeoff), + major_version_ (major_version), + minor_version_ (minor_version), + char_translator_ (0), + wchar_translator_ (0) +{ + // We cannot trust the buffer to be properly aligned + ACE_CDR::mb_align (&this->start_); + this->current_ = &this->start_; + +#if defined (ACE_HAS_MONITOR_POINTS) && (ACE_HAS_MONITOR_POINTS == 1) + ACE_NEW (this->monitor_, + ACE::Monitor_Control::Size_Monitor); + this->monitor_->receive (this->total_length ()); +#endif /* ACE_HAS_MONITOR_POINTS==1 */ +} + +/*static*/ void +ACE_OutputCDR::wchar_maxbytes (size_t maxbytes) +{ + ACE_OutputCDR::wchar_maxbytes_ = maxbytes; +} + +/*static*/ size_t +ACE_OutputCDR::wchar_maxbytes () +{ + return ACE_OutputCDR::wchar_maxbytes_; +} + +int +ACE_OutputCDR::grow_and_adjust (size_t size, + size_t align, + char*& buf) +{ + if (!this->current_is_writable_ + || this->current_->cont () == 0 + || this->current_->cont ()->size () < size + ACE_CDR::MAX_ALIGNMENT) + { + // Calculate the new buffer's length; if growing for encode, we + // don't grow in "small" chunks because of the cost. + size_t cursize = this->current_->size (); + if (this->current_->cont () != 0) + cursize = this->current_->cont ()->size (); + size_t minsize = size; + +#if !defined (ACE_LACKS_CDR_ALIGNMENT) + minsize += ACE_CDR::MAX_ALIGNMENT; +#endif /* ACE_LACKS_CDR_ALIGNMENT */ + + // Make sure that there is enough room for bytes, but + // also make it bigger than whatever our current size is. + if (minsize < cursize) + minsize = cursize; + + size_t const newsize = ACE_CDR::next_size (minsize); + + this->good_bit_ = false; + ACE_Message_Block* tmp = 0; + ACE_NEW_RETURN (tmp, + ACE_Message_Block (newsize, + ACE_Message_Block::MB_DATA, + 0, + 0, + this->current_->data_block ()->allocator_strategy (), + 0, + 0, + ACE_Time_Value::zero, + ACE_Time_Value::max_time, + this->current_->data_block ()->data_block_allocator ()), + -1); + + // Message block initialization may fail while the construction + // succeds. Since as a matter of policy, ACE may throw no + // exceptions, we have to do a separate check like this. + if (tmp != 0 && tmp->size () < newsize) + { + delete tmp; + errno = ENOMEM; + return -1; + } + + this->good_bit_ = true; + +#if !defined (ACE_LACKS_CDR_ALIGNMENT) + // The new block must start with the same alignment as the + // previous block finished. + ptrdiff_t const tmpalign = + reinterpret_cast (tmp->rd_ptr ()) % ACE_CDR::MAX_ALIGNMENT; + ptrdiff_t const curalign = + static_cast (this->current_alignment_) % ACE_CDR::MAX_ALIGNMENT; + ptrdiff_t offset = curalign - tmpalign; + if (offset < 0) + offset += ACE_CDR::MAX_ALIGNMENT; + tmp->rd_ptr (static_cast (offset)); + tmp->wr_ptr (tmp->rd_ptr ()); +#endif /* ACE_LACKS_CDR_ALIGNMENT */ + + // grow the chain and set the current block. + tmp->cont (this->current_->cont ()); + this->current_->cont (tmp); + } + this->current_ = this->current_->cont (); + this->current_is_writable_ = true; + + return this->adjust (size, align, buf); +} + +ACE_CDR::Boolean +ACE_OutputCDR::write_wchar (ACE_CDR::WChar x) +{ + if (this->wchar_translator_ != 0) + return (this->good_bit_ = this->wchar_translator_->write_wchar (*this, x)); + if (ACE_OutputCDR::wchar_maxbytes_ == 0) + { + errno = EACCES; + return (this->good_bit_ = false); + } + if (static_cast (major_version_) == 1 + && static_cast (minor_version_) == 2) + { + ACE_CDR::Octet len = + static_cast (ACE_OutputCDR::wchar_maxbytes_); + if (this->write_1 (&len)) + { + if (ACE_OutputCDR::wchar_maxbytes_ == sizeof(ACE_CDR::WChar)) + return + this->write_octet_array ( + reinterpret_cast (&x), + static_cast (len)); + else + if (ACE_OutputCDR::wchar_maxbytes_ == 2) + { + ACE_CDR::Short sx = static_cast (x); + return + this->write_octet_array ( + reinterpret_cast (&sx), + static_cast (len)); + } + else + { + ACE_CDR::Octet ox = static_cast (x); + return + this->write_octet_array ( + reinterpret_cast (&ox), + static_cast (len)); + } + } + } + else if (static_cast (minor_version_) == 0) + { // wchar is not allowed with GIOP 1.0. + errno = EINVAL; + return (this->good_bit_ = false); + } + if (ACE_OutputCDR::wchar_maxbytes_ == sizeof (ACE_CDR::WChar)) + { + void const * const temp = &x; + return + this->write_4 (reinterpret_cast (temp)); + } + else if (ACE_OutputCDR::wchar_maxbytes_ == 2) + { + ACE_CDR::Short sx = static_cast (x); + return this->write_2 (reinterpret_cast (&sx)); + } + ACE_CDR::Octet ox = static_cast (x); + return this->write_1 (reinterpret_cast (&ox)); +} + +ACE_CDR::Boolean +ACE_OutputCDR::write_string (ACE_CDR::ULong len, + const ACE_CDR::Char *x) +{ + // @@ This is a slight violation of "Optimize for the common case", + // i.e. normally the translator will be 0, but OTOH the code is + // smaller and should be better for the cache ;-) ;-) + if (this->char_translator_ != 0) + return this->char_translator_->write_string (*this, len, x); + + if (len != 0) + { + if (this->write_ulong (len + 1)) + return this->write_char_array (x, len + 1); + } + else + { + // Be nice to programmers: treat nulls as empty strings not + // errors. (OMG-IDL supports languages that don't use the C/C++ + // notion of null v. empty strings; nulls aren't part of the OMG-IDL + // string model.) + if (this->write_ulong (1)) + return this->write_char (0); + } + + return (this->good_bit_ = false); +} + +ACE_CDR::Boolean +ACE_OutputCDR::write_string (const ACE_CString &x) +{ + // @@ Leave this method in here, not the `.i' file so that we don't + // have to unnecessarily pull in the `ace/SString.h' header. + return this->write_string (static_cast (x.length ()), + x.c_str()); +} + +ACE_CDR::Boolean +ACE_OutputCDR::write_wstring (ACE_CDR::ULong len, + const ACE_CDR::WChar *x) +{ + // @@ This is a slight violation of "Optimize for the common case", + // i.e. normally the translator will be 0, but OTOH the code is + // smaller and should be better for the cache ;-) ;-) + // What do we do for GIOP 1.2??? + if (this->wchar_translator_ != 0) + return this->wchar_translator_->write_wstring (*this, len, x); + if (ACE_OutputCDR::wchar_maxbytes_ == 0) + { + errno = EACCES; + return (this->good_bit_ = false); + } + + if (static_cast (this->major_version_) == 1 + && static_cast (this->minor_version_) == 2) + { + if (x != 0) + { + //In GIOP 1.2 the length field contains the number of bytes + //the wstring occupies rather than number of wchars + //Taking sizeof might not be a good way! This is a temporary fix. + ACE_CDR::Boolean good_ulong = + this->write_ulong ( + ACE_Utils::truncate_cast ( + ACE_OutputCDR::wchar_maxbytes_ * len)); + + if (good_ulong) + { + return this->write_wchar_array (x, len); + } + } + else + { + //In GIOP 1.2 zero length wstrings are legal + return this->write_ulong (0); + } + } + + else + if (x != 0) + { + if (this->write_ulong (len + 1)) + return this->write_wchar_array (x, len + 1); + } + else if (this->write_ulong (1)) + return this->write_wchar (0); + return (this->good_bit_ = false); +} + +ACE_CDR::Boolean +ACE_OutputCDR::write_octet_array_mb (const ACE_Message_Block* mb) +{ + // If the buffer is small and it fits in the current message + // block it is be cheaper just to copy the buffer. + for (const ACE_Message_Block* i = mb; + i != 0; + i = i->cont ()) + { + size_t const length = i->length (); + + // If the mb does not own its data we are forced to make a copy. + if (ACE_BIT_ENABLED (i->flags (), + ACE_Message_Block::DONT_DELETE)) + { + if (! this->write_array (i->rd_ptr (), + ACE_CDR::OCTET_SIZE, + ACE_CDR::OCTET_ALIGN, + static_cast (length))) + return (this->good_bit_ = false); + continue; + } + + if (length < this->memcpy_tradeoff_ + && this->current_->wr_ptr () + length < this->current_->end ()) + { + if (! this->write_array (i->rd_ptr (), + ACE_CDR::OCTET_SIZE, + ACE_CDR::OCTET_ALIGN, + static_cast (length))) + return (this->good_bit_ = false); + continue; + } + + ACE_Message_Block* cont = 0; + this->good_bit_ = false; + ACE_NEW_RETURN (cont, + ACE_Message_Block (i->data_block ()->duplicate ()), + false); + this->good_bit_ = true; + + if (this->current_->cont () != 0) + ACE_Message_Block::release (this->current_->cont ()); + cont->rd_ptr (i->rd_ptr ()); + cont->wr_ptr (i->wr_ptr ()); + + this->current_->cont (cont); + this->current_ = cont; + this->current_is_writable_ = false; +#if !defined (ACE_LACKS_CDR_ALIGNMENT) + this->current_alignment_ = + (this->current_alignment_ + cont->length ()) % ACE_CDR::MAX_ALIGNMENT; +#endif /* ACE_LACKS_CDR_ALIGNMENT */ + } + + return true; +} + +ACE_CDR::Boolean +ACE_OutputCDR::write_1 (const ACE_CDR::Octet *x) +{ + char *buf = 0; + if (this->adjust (1, buf) == 0) + { + *reinterpret_cast (buf) = *x; + return true; + } + + return false; +} + +ACE_CDR::Boolean +ACE_OutputCDR::write_2 (const ACE_CDR::UShort *x) +{ + char *buf = 0; + if (this->adjust (ACE_CDR::SHORT_SIZE, buf) == 0) + { +#if !defined (ACE_ENABLE_SWAP_ON_WRITE) + *reinterpret_cast (buf) = *x; + return true; +#else + if (!this->do_byte_swap_) + { + *reinterpret_cast (buf) = *x; + return true; + } + else + { + ACE_CDR::swap_2 (reinterpret_cast (x), buf); + return true; + } +#endif /* ACE_ENABLE_SWAP_ON_WRITE */ + } + + return false; +} + +ACE_CDR::Boolean +ACE_OutputCDR::write_4 (const ACE_CDR::ULong *x) +{ + char *buf = 0; + if (this->adjust (ACE_CDR::LONG_SIZE, buf) == 0) + { +#if !defined (ACE_ENABLE_SWAP_ON_WRITE) + *reinterpret_cast (buf) = *x; + return true; +#else + if (!this->do_byte_swap_) + { + *reinterpret_cast (buf) = *x; + return true; + } + else + { + ACE_CDR::swap_4 (reinterpret_cast (x), buf); + return true; + } +#endif /* ACE_ENABLE_SWAP_ON_WRITE */ + } + + return false; +} + +ACE_CDR::Boolean +ACE_OutputCDR::write_8 (const ACE_CDR::ULongLong *x) +{ + char *buf = 0; + + if (this->adjust (ACE_CDR::LONGLONG_SIZE, buf) == 0) + { +#if defined (__arm__) + // Convert to Intel format (12345678 => 56781234) + const char *orig = reinterpret_cast (x); + char *target = buf; + register ACE_UINT32 x = + *reinterpret_cast (orig); + register ACE_UINT32 y = + *reinterpret_cast (orig + 4); + *reinterpret_cast (target) = y; + *reinterpret_cast (target + 4) = x; + return true; +#else +# if !defined (ACE_ENABLE_SWAP_ON_WRITE) + *reinterpret_cast (buf) = *x; + return true; +# else + if (!this->do_byte_swap_) + { + *reinterpret_cast (buf) = *x; + return true; + } + else + { + ACE_CDR::swap_8 (reinterpret_cast (x), buf); + return true; + } +# endif /* ACE_ENABLE_SWAP_ON_WRITE */ +#endif /* !__arm__ */ + } + + return false; +} + +ACE_CDR::Boolean +ACE_OutputCDR::write_16 (const ACE_CDR::LongDouble *x) +{ + char* buf = 0; + if (this->adjust (ACE_CDR::LONGDOUBLE_SIZE, + ACE_CDR::LONGDOUBLE_ALIGN, + buf) == 0) + { +#if !defined (ACE_ENABLE_SWAP_ON_WRITE) + *reinterpret_cast (buf) = *x; + return 1; +#else + if (!this->do_byte_swap_) + { + *reinterpret_cast (buf) = *x; + return true; + } + else + { + ACE_CDR::swap_16 (reinterpret_cast (x), buf); + return true; + } +#endif /* ACE_ENABLE_SWAP_ON_WRITE */ + } + + return false; +} + +ACE_CDR::Boolean +ACE_OutputCDR::write_wchar_array_i (const ACE_CDR::WChar *x, + ACE_CDR::ULong length) +{ + if (length == 0) + return true; + char* buf = 0; + size_t const align = (ACE_OutputCDR::wchar_maxbytes_ == 2) ? + ACE_CDR::SHORT_ALIGN : + ACE_CDR::OCTET_ALIGN; + + if (this->adjust (ACE_OutputCDR::wchar_maxbytes_ * length, align, buf) == 0) + { + if (ACE_OutputCDR::wchar_maxbytes_ == 2) + { + ACE_CDR::UShort *sb = reinterpret_cast (buf); + for (size_t i = 0; i < length; ++i) +#if !defined (ACE_ENABLE_SWAP_ON_WRITE) + sb[i] = static_cast (x[i]); +#else + if (!this->do_byte_swap_) + sb[i] = static_cast (x[i]); + else + { + ACE_CDR::UShort sx = static_cast (x[i]); + ACE_CDR::swap_2 (reinterpret_cast (&sx), &buf[i * 2]); + } +#endif /* ACE_ENABLE_SWAP_ON_WRITE */ + } + else + { + for (size_t i = 0; i < length; ++i) + buf[i] = static_cast (x[i]); + } + return this->good_bit_; + } + return false; +} + + +ACE_CDR::Boolean +ACE_OutputCDR::write_array (const void *x, + size_t size, + size_t align, + ACE_CDR::ULong length) +{ + if (length == 0) + return true; + char *buf = 0; + if (this->adjust (size * length, align, buf) == 0) + { +#if !defined (ACE_ENABLE_SWAP_ON_WRITE) + ACE_OS::memcpy (buf, x, size*length); + return true; +#else + if (!this->do_byte_swap_ || size == 1) + { + ACE_OS::memcpy (buf, x, size*length); + return true; + } + else + { + const char *source = reinterpret_cast (x); + switch (size) + { + case 2: + ACE_CDR::swap_2_array (source, buf, length); + return true; + case 4: + ACE_CDR::swap_4_array (source, buf, length); + return true; + case 8: + ACE_CDR::swap_8_array (source, buf, length); + return true; + case 16: + ACE_CDR::swap_16_array (source, buf, length); + return true; + default: + // TODO: print something? + this->good_bit_ = false; + return false; + } + } +#endif /* ACE_ENABLE_SWAP_ON_WRITE */ + } + this->good_bit_ = false; + return false; +} + + +ACE_CDR::Boolean +ACE_OutputCDR::write_boolean_array (const ACE_CDR::Boolean* x, + ACE_CDR::ULong length) +{ + // It is hard to optimize this, the spec requires that on the wire + // booleans be represented as a byte with value 0 or 1, but in + // memory it is possible (though very unlikely) that a boolean has + // a non-zero value (different from 1). + // We resort to a simple loop. + ACE_CDR::Boolean const * const end = x + length; + + for (ACE_CDR::Boolean const * i = x; + i != end && this->good_bit (); + ++i) + (void) this->write_boolean (*i); + + return this->good_bit (); +} + + +char * +ACE_OutputCDR::write_long_placeholder (void) +{ + char *buf = 0; + if (this->adjust (ACE_CDR::LONG_SIZE, buf) == 0) + *reinterpret_cast (buf) = 0; + else + buf = 0; + return buf; +} + + +char * +ACE_OutputCDR::write_short_placeholder (void) +{ + char *buf = 0; + if (this->adjust (ACE_CDR::SHORT_SIZE, buf) == 0) + *reinterpret_cast (buf) = 0; + else + buf = 0; + return buf; +} + + +ACE_CDR::Boolean +ACE_OutputCDR::replace (ACE_CDR::Long x, char* loc) +{ + if (this->find (loc) == 0) + return false; + +#if !defined (ACE_ENABLE_SWAP_ON_WRITE) + *reinterpret_cast (loc) = x; +#else + if (!this->do_byte_swap_) + { + *reinterpret_cast (loc) = x; + } + else + { + ACE_CDR::swap_4 (reinterpret_cast (&x), loc); + } +#endif /* ACE_ENABLE_SWAP_ON_WRITE */ + + return true; +} + + +ACE_CDR::Boolean +ACE_OutputCDR::replace (ACE_CDR::Short x, char* loc) +{ + if (this->find (loc) == 0) + return false; + +#if !defined (ACE_ENABLE_SWAP_ON_WRITE) + *reinterpret_cast (loc) = x; +#else + if (!this->do_byte_swap_) + { + *reinterpret_cast (loc) = x; + } + else + { + ACE_CDR::swap_2 (reinterpret_cast (&x), loc); + } +#endif /* ACE_ENABLE_SWAP_ON_WRITE */ + + return true; +} + + +int +ACE_OutputCDR::consolidate (void) +{ + // Optimize by only doing something if we need to + if (this->current_ != &this->start_) + { + // Set the number of bytes in the top-level block, reallocating + // if necessary. The rd_ptr and wr_ptr remain at the original offsets + // into the buffer, even if it is reallocated. + // Return an error if the allocation failed. + size_t const newsize = + ACE_CDR::first_size (this->total_length () + + ACE_CDR::MAX_ALIGNMENT); + if (this->start_.size (newsize) < 0) + { + return -1; + } + + // Consolidate the chain into the first block. NOTE that + // ACE_CDR::consolidate can not be used since we don't want to + // overwrite what is already in the first block. We just append it since + // the read and write pointers weren't affected by the resizing above. + // We also don't have to worry about alignment since the start block is + // already aligned. + // NOTE also we know there is a continuation since we checked for it + // above. There is therefore no reason to check for a 0 continuation + // field here. + ACE_Message_Block *cont = this->start_.cont (); + for (const ACE_Message_Block* i = cont; i != 0; i = i->cont ()) + { + this->start_.copy (i->rd_ptr (), i->length ()); + } + + // Release the old blocks that were consolidated and reset the + // current_ and current_is_writable_ to reflect the single used block. + ACE_Message_Block::release (cont); + this->start_.cont (0); + this->current_ = &this->start_; + this->current_is_writable_ = true; + } + + return 0; +} + + +ACE_Message_Block* +ACE_OutputCDR::find (char* loc) +{ + ACE_Message_Block* mb = 0; + for (mb = &this->start_; mb != 0; mb = mb->cont ()) + { + if (loc <= mb->wr_ptr () && loc >= mb->rd_ptr ()) + { + break; + } + } + + return mb; +} + +#if defined (ACE_HAS_MONITOR_POINTS) && (ACE_HAS_MONITOR_POINTS == 1) + +void +ACE_OutputCDR::register_monitor (const char *id) +{ + this->monitor_->name (id); + this->monitor_->add_to_registry (); +} + +void +ACE_OutputCDR::unregister_monitor (void) +{ + this->monitor_->remove_from_registry (); +} + +#endif /* ACE_HAS_MONITOR_POINTS==1 */ + +// **************************************************************** + +ACE_InputCDR::ACE_InputCDR (const char *buf, + size_t bufsiz, + int byte_order, + ACE_CDR::Octet major_version, + ACE_CDR::Octet minor_version) + : start_ (buf, bufsiz), + do_byte_swap_ (byte_order != ACE_CDR_BYTE_ORDER), + good_bit_ (true), + major_version_ (major_version), + minor_version_ (minor_version), + char_translator_ (0), + wchar_translator_ (0) +{ + this->start_.wr_ptr (bufsiz); + +#if defined (ACE_HAS_MONITOR_POINTS) && (ACE_HAS_MONITOR_POINTS == 1) + ACE_NEW (this->monitor_, + ACE::Monitor_Control::Size_Monitor); + this->monitor_->receive (bufsiz); +#endif /* ACE_HAS_MONITOR_POINTS==1 */ +} + +ACE_InputCDR::ACE_InputCDR (size_t bufsiz, + int byte_order, + ACE_CDR::Octet major_version, + ACE_CDR::Octet minor_version) + : start_ (bufsiz), + do_byte_swap_ (byte_order != ACE_CDR_BYTE_ORDER), + good_bit_ (true), + major_version_ (major_version), + minor_version_ (minor_version), + char_translator_ (0), + wchar_translator_ (0) +{ +#if defined (ACE_HAS_MONITOR_POINTS) && (ACE_HAS_MONITOR_POINTS == 1) + ACE_NEW (this->monitor_, + ACE::Monitor_Control::Size_Monitor); + this->monitor_->receive (bufsiz); +#endif /* ACE_HAS_MONITOR_POINTS==1 */ +} + +ACE_InputCDR::ACE_InputCDR (const ACE_Message_Block *data, + int byte_order, + ACE_CDR::Octet major_version, + ACE_CDR::Octet minor_version, + ACE_Lock* lock) + : start_ (0, ACE_Message_Block::MB_DATA, 0, 0, 0, lock), + good_bit_ (true), + major_version_ (major_version), + minor_version_ (minor_version), + char_translator_ (0), + wchar_translator_ (0) +{ +#if defined (ACE_HAS_MONITOR_POINTS) && (ACE_HAS_MONITOR_POINTS == 1) + ACE_NEW (this->monitor_, + ACE::Monitor_Control::Size_Monitor); + this->monitor_->receive (this->start_.total_size ()); +#endif /* ACE_HAS_MONITOR_POINTS==1 */ + + this->reset (data, byte_order); +} + +ACE_InputCDR::ACE_InputCDR (ACE_Data_Block *data, + ACE_Message_Block::Message_Flags flag, + int byte_order, + ACE_CDR::Octet major_version, + ACE_CDR::Octet minor_version) + : start_ (data, flag), + do_byte_swap_ (byte_order != ACE_CDR_BYTE_ORDER), + good_bit_ (true), + major_version_ (major_version), + minor_version_ (minor_version), + char_translator_ (0), + wchar_translator_ (0) +{ +#if defined (ACE_HAS_MONITOR_POINTS) && (ACE_HAS_MONITOR_POINTS == 1) + ACE_NEW (this->monitor_, + ACE::Monitor_Control::Size_Monitor); + this->monitor_->receive (data->size ()); +#endif /* ACE_HAS_MONITOR_POINTS==1 */ +} + +ACE_InputCDR::ACE_InputCDR (ACE_Data_Block *data, + ACE_Message_Block::Message_Flags flag, + size_t rd_pos, + size_t wr_pos, + int byte_order, + ACE_CDR::Octet major_version, + ACE_CDR::Octet minor_version) + : start_ (data, flag), + do_byte_swap_ (byte_order != ACE_CDR_BYTE_ORDER), + good_bit_ (true), + major_version_ (major_version), + minor_version_ (minor_version), + char_translator_ (0), + wchar_translator_ (0) +{ + // Set the read pointer + this->start_.rd_ptr (rd_pos); + + // Set the write pointer after doing a sanity check. + char* wrpos = this->start_.base () + wr_pos; + + if (this->start_.end () >= wrpos) + { + this->start_.wr_ptr (wr_pos); + } + +#if defined (ACE_HAS_MONITOR_POINTS) && (ACE_HAS_MONITOR_POINTS == 1) + ACE_NEW (this->monitor_, + ACE::Monitor_Control::Size_Monitor); + this->monitor_->receive (data->size ()); +#endif /* ACE_HAS_MONITOR_POINTS==1 */ +} + +ACE_InputCDR::ACE_InputCDR (const ACE_InputCDR& rhs, + size_t size, + ACE_CDR::Long offset) + : start_ (rhs.start_, + ACE_CDR::MAX_ALIGNMENT), + do_byte_swap_ (rhs.do_byte_swap_), + good_bit_ (true), + major_version_ (rhs.major_version_), + minor_version_ (rhs.minor_version_), + char_translator_ (rhs.char_translator_), + wchar_translator_ (rhs.wchar_translator_) +{ +#if !defined (ACE_LACKS_CDR_ALIGNMENT) + // Align the base pointer assuming that the incoming stream is also + // aligned the way we are aligned + char *incoming_start = ACE_ptr_align_binary (rhs.start_.base (), + ACE_CDR::MAX_ALIGNMENT); +#else + char *incoming_start = rhs.start_.base (); +#endif /* ACE_LACKS_CDR_ALIGNMENT */ + + const size_t newpos = + (rhs.start_.rd_ptr() - incoming_start) + offset; + + if (newpos <= this->start_.space () + && newpos + size <= this->start_.space ()) + { + this->start_.rd_ptr (newpos); + this->start_.wr_ptr (newpos + size); + } + else + { + this->good_bit_ = false; + } + +#if defined (ACE_HAS_MONITOR_POINTS) && (ACE_HAS_MONITOR_POINTS == 1) + ACE_NEW (this->monitor_, + ACE::Monitor_Control::Size_Monitor); + this->monitor_->receive (this->start_.total_size ()); +#endif /* ACE_HAS_MONITOR_POINTS==1 */ +} + +ACE_InputCDR::ACE_InputCDR (const ACE_InputCDR& rhs, + size_t size) + : start_ (rhs.start_, + ACE_CDR::MAX_ALIGNMENT), + do_byte_swap_ (rhs.do_byte_swap_), + good_bit_ (true), + major_version_ (rhs.major_version_), + minor_version_ (rhs.minor_version_), + char_translator_ (rhs.char_translator_), + wchar_translator_ (rhs.wchar_translator_) +{ +#if !defined (ACE_LACKS_CDR_ALIGNMENT) + // Align the base pointer assuming that the incoming stream is also + // aligned the way we are aligned + char *incoming_start = ACE_ptr_align_binary (rhs.start_.base (), + ACE_CDR::MAX_ALIGNMENT); +#else + char *incoming_start = rhs.start_.base (); +#endif /* ACE_LACKS_CDR_ALIGNMENT */ + + const size_t newpos = + rhs.start_.rd_ptr() - incoming_start; + + if (newpos <= this->start_.space () + && newpos + size <= this->start_.space ()) + { + // Notice that ACE_Message_Block::duplicate may leave the + // wr_ptr() with a higher value than what we actually want. + this->start_.rd_ptr (newpos); + this->start_.wr_ptr (newpos + size); + + ACE_CDR::Octet byte_order = 0; + (void) this->read_octet (byte_order); + this->do_byte_swap_ = (byte_order != ACE_CDR_BYTE_ORDER); + } + else + { + this->good_bit_ = false; + } + +#if defined (ACE_HAS_MONITOR_POINTS) && (ACE_HAS_MONITOR_POINTS == 1) + ACE_NEW (this->monitor_, + ACE::Monitor_Control::Size_Monitor); + this->monitor_->receive (this->start_.total_size ()); +#endif /* ACE_HAS_MONITOR_POINTS==1 */ +} + +ACE_InputCDR::ACE_InputCDR (const ACE_InputCDR& rhs) + : start_ (rhs.start_, + ACE_CDR::MAX_ALIGNMENT), + do_byte_swap_ (rhs.do_byte_swap_), + good_bit_ (true), + major_version_ (rhs.major_version_), + minor_version_ (rhs.minor_version_), + char_translator_ (rhs.char_translator_), + wchar_translator_ (rhs.wchar_translator_) +{ +#if !defined (ACE_LACKS_CDR_ALIGNMENT) + char *buf = ACE_ptr_align_binary (rhs.start_.base (), + ACE_CDR::MAX_ALIGNMENT); +#else + char *buf = rhs.start_.base (); +#endif /* ACE_LACKS_CDR_ALIGNMENT */ + + size_t rd_offset = rhs.start_.rd_ptr () - buf; + size_t wr_offset = rhs.start_.wr_ptr () - buf; + this->start_.rd_ptr (rd_offset); + this->start_.wr_ptr (wr_offset); + +#if defined (ACE_HAS_MONITOR_POINTS) && (ACE_HAS_MONITOR_POINTS == 1) + ACE_NEW (this->monitor_, + ACE::Monitor_Control::Size_Monitor); + this->monitor_->receive (this->start_.total_size ()); +#endif /* ACE_HAS_MONITOR_POINTS==1 */ +} + +ACE_InputCDR::ACE_InputCDR (ACE_InputCDR::Transfer_Contents x) + : start_ (x.rhs_.start_.data_block ()), + do_byte_swap_ (x.rhs_.do_byte_swap_), + good_bit_ (true), + major_version_ (x.rhs_.major_version_), + minor_version_ (x.rhs_.minor_version_), + char_translator_ (x.rhs_.char_translator_), + wchar_translator_ (x.rhs_.wchar_translator_) +{ + this->start_.rd_ptr (x.rhs_.start_.rd_ptr ()); + this->start_.wr_ptr (x.rhs_.start_.wr_ptr ()); + + ACE_Data_Block* db = this->start_.data_block ()->clone_nocopy (); + (void) x.rhs_.start_.replace_data_block (db); + +#if defined (ACE_HAS_MONITOR_POINTS) && (ACE_HAS_MONITOR_POINTS == 1) + ACE_NEW (this->monitor_, + ACE::Monitor_Control::Size_Monitor); + this->monitor_->receive (this->start_.total_size ()); +#endif /* ACE_HAS_MONITOR_POINTS==1 */ +} + +ACE_InputCDR& +ACE_InputCDR::operator= (const ACE_InputCDR& rhs) +{ + if (this != &rhs) + { + this->start_.data_block (rhs.start_.data_block ()->duplicate ()); + this->start_.rd_ptr (rhs.start_.rd_ptr ()); + this->start_.wr_ptr (rhs.start_.wr_ptr ()); + this->do_byte_swap_ = rhs.do_byte_swap_; + this->good_bit_ = true; + this->char_translator_ = rhs.char_translator_; + this->major_version_ = rhs.major_version_; + this->minor_version_ = rhs.minor_version_; + } + +#if defined (ACE_HAS_MONITOR_POINTS) && (ACE_HAS_MONITOR_POINTS == 1) + this->monitor_->receive (this->start_.total_size ()); +#endif /* ACE_HAS_MONITOR_POINTS==1 */ + + return *this; +} + +ACE_InputCDR::ACE_InputCDR (const ACE_OutputCDR& rhs, + ACE_Allocator* buffer_allocator, + ACE_Allocator* data_block_allocator, + ACE_Allocator* message_block_allocator) + : start_ (rhs.total_length () + ACE_CDR::MAX_ALIGNMENT, + ACE_Message_Block::MB_DATA, + 0, + 0, + buffer_allocator, + 0, + 0, + ACE_Time_Value::zero, + ACE_Time_Value::max_time, + data_block_allocator, + message_block_allocator), + do_byte_swap_ (rhs.do_byte_swap_), + good_bit_ (true), + major_version_ (rhs.major_version_), + minor_version_ (rhs.minor_version_), + char_translator_ (rhs.char_translator_), + wchar_translator_ (rhs.wchar_translator_) +{ + ACE_CDR::mb_align (&this->start_); + for (const ACE_Message_Block *i = rhs.begin (); + i != rhs.end (); + i = i->cont ()) + { + this->start_.copy (i->rd_ptr (), i->length ()); + } + +#if defined (ACE_HAS_MONITOR_POINTS) && (ACE_HAS_MONITOR_POINTS == 1) + ACE_NEW (this->monitor_, + ACE::Monitor_Control::Size_Monitor); + this->monitor_->receive (this->start_.total_size ()); +#endif /* ACE_HAS_MONITOR_POINTS==1 */ +} + +ACE_CDR::Boolean +ACE_InputCDR::skip_wchar (void) +{ + if (static_cast (major_version_) == 1 + && static_cast (minor_version_) == 2) + { + ACE_CDR::Octet len; + if (this->read_1 (&len)) + return this->skip_bytes (static_cast (len)); + } + else + { + ACE_CDR::WChar x; + void * const temp = &x; + if (ACE_OutputCDR::wchar_maxbytes_ == 2) + return this->read_2 (reinterpret_cast (temp)); + else + return this->read_4 (reinterpret_cast (temp)); + } + + return (this->good_bit_ = false); +} + +ACE_CDR::Boolean +ACE_InputCDR::read_wchar (ACE_CDR::WChar& x) +{ + if (this->wchar_translator_ != 0) + { + this->good_bit_ = this->wchar_translator_->read_wchar (*this,x); + return this->good_bit_; + } + if (ACE_OutputCDR::wchar_maxbytes_ == 0) + { + errno = EACCES; + return (this->good_bit_ = false); + } + + if (ACE_OutputCDR::wchar_maxbytes_ == sizeof (ACE_CDR::WChar)) + { + if (static_cast (major_version_) == 1 + && static_cast (minor_version_) == 2) + { + ACE_CDR::Octet len; + + if (this->read_1 (&len)) + return this->read_array + (reinterpret_cast (&x), + static_cast (len), + ACE_CDR::OCTET_ALIGN, + 1); + + else + return (this->good_bit_ = false); + } + + void * const temp = &x; + if (sizeof (ACE_CDR::WChar) == 2) + return this->read_2 (reinterpret_cast (temp)); + else + return this->read_4 (reinterpret_cast (temp)); + } + + if (static_cast (major_version_) == 1 + && static_cast (minor_version_) == 2) + { + ACE_CDR::Octet len; + + if (this->read_1 (&len)) + { + if (len == 2) + { + ACE_CDR::Short sx; + if (this->read_array + (reinterpret_cast (&sx), + static_cast (len), + ACE_CDR::OCTET_ALIGN, + 1)) + { + x = static_cast (sx); + return true; + } + } + else + { + ACE_CDR::Octet ox; + if (this->read_array + (reinterpret_cast (&ox), + static_cast (len), + ACE_CDR::OCTET_ALIGN, + 1)) + { + x = static_cast (ox); + return true; + } + } + } + } + else + { + if (ACE_OutputCDR::wchar_maxbytes_ == 2) + { + ACE_CDR::UShort sx; + if (this->read_2 (reinterpret_cast (&sx))) + { + x = static_cast (sx); + return true; + } + } + else + { + ACE_CDR::Octet ox; + if (this->read_1 (&ox)) + { + x = static_cast (ox); + return true; + } + + } + } + return (this->good_bit_ = false); +} + +ACE_CDR::Boolean +ACE_InputCDR::read_string (ACE_CDR::Char *&x) +{ + // @@ This is a slight violation of "Optimize for the common case", + // i.e. normally the translator will be 0, but OTOH the code is + // smaller and should be better for the cache ;-) ;-) + if (this->char_translator_ != 0) + { + this->good_bit_ = this->char_translator_->read_string (*this, x); + return this->good_bit_; + } + + ACE_CDR::ULong len = 0; + + if (!this->read_ulong (len)) + return false; + + // A check for the length being too great is done later in the + // call to read_char_array but we want to have it done before + // the memory is allocated. + if (len > 0 && len <= this->length()) + { + ACE_NEW_RETURN (x, + ACE_CDR::Char[len], + 0); + + ACE_Auto_Basic_Array_Ptr safe_data (x); + + if (this->read_char_array (x, len)) + { + (void) safe_data.release (); + return true; + } + } + else if (len == 0) + { + // Convert any null strings to empty strings since empty + // strings can cause crashes. (See bug 58.) + ACE_NEW_RETURN (x, + ACE_CDR::Char[1], + 0); + ACE_OS::strcpy (const_cast (x), ""); + return true; + } + + x = 0; + return (this->good_bit_ = false); +} + +ACE_CDR::Boolean +ACE_InputCDR::read_string (ACE_CString &x) +{ + ACE_CDR::Char * data = 0; + if (this->read_string (data)) + { + ACE_Auto_Basic_Array_Ptr safe_data (data); + x = data; + return true; + } + + x = ""; + return (this->good_bit_ = false); +} + +ACE_CDR::Boolean +ACE_InputCDR::read_wstring (ACE_CDR::WChar*& x) +{ + // @@ This is a slight violation of "Optimize for the common case", + // i.e. normally the translator will be 0, but OTOH the code is + // smaller and should be better for the cache ;-) ;-) + if (this->wchar_translator_ != 0) + { + this->good_bit_ = this->wchar_translator_->read_wstring (*this, x); + return this->good_bit_; + } + if (ACE_OutputCDR::wchar_maxbytes_ == 0) + { + errno = EACCES; + return (this->good_bit_ = false); + } + + ACE_CDR::ULong len = 0; + + if (!this->read_ulong (len)) + { + return false; + } + + // A check for the length being too great is done later in the + // call to read_char_array but we want to have it done before + // the memory is allocated. + if (len > 0 && len <= this->length ()) + { + ACE_Auto_Basic_Array_Ptr safe_data; + + if (static_cast (this->major_version_) == 1 + && static_cast (this->minor_version_) == 2) + { + len /= + ACE_Utils::truncate_cast ( + ACE_OutputCDR::wchar_maxbytes_); + + //allocating one extra for the null character needed by applications + ACE_NEW_RETURN (x, + ACE_CDR::WChar [len + 1], + false); + + ACE_auto_ptr_reset (safe_data, x); + + if (this->read_wchar_array (x, len)) + { + + //Null character used by applications to find the end of + //the wstring + //Is this okay with the GIOP 1.2 spec?? + x[len] = '\x00'; + + (void) safe_data.release (); + + return true; + } + } + else + { + ACE_NEW_RETURN (x, + ACE_CDR::WChar [len], + false); + + ACE_auto_ptr_reset (safe_data, x); + + if (this->read_wchar_array (x, len)) + { + (void) safe_data.release (); + + return true; + } + } + } + else if (len == 0) + { + // Convert any null strings to empty strings since empty + // strings can cause crashes. (See bug 58.) + ACE_NEW_RETURN (x, + ACE_CDR::WChar[1], + false); + x[0] = '\x00'; + return true; + } + + this->good_bit_ = false; + x = 0; + return false; +} + +ACE_CDR::Boolean +ACE_InputCDR::read_array (void* x, + size_t size, + size_t align, + ACE_CDR::ULong length) +{ + if (length == 0) + return true; + char* buf = 0; + + if (this->adjust (size * length, align, buf) == 0) + { +#if defined (ACE_DISABLE_SWAP_ON_READ) + ACE_OS::memcpy (x, buf, size*length); +#else + if (!this->do_byte_swap_ || size == 1) + ACE_OS::memcpy (x, buf, size*length); + else + { + char *target = reinterpret_cast (x); + switch (size) + { + case 2: + ACE_CDR::swap_2_array (buf, target, length); + break; + case 4: + ACE_CDR::swap_4_array (buf, target, length); + break; + case 8: + ACE_CDR::swap_8_array (buf, target, length); + break; + case 16: + ACE_CDR::swap_16_array (buf, target, length); + break; + default: + // TODO: print something? + this->good_bit_ = false; + return false; + } + } +#endif /* ACE_DISABLE_SWAP_ON_READ */ + return this->good_bit_; + } + return false; +} + +ACE_CDR::Boolean +ACE_InputCDR::read_wchar_array_i (ACE_CDR::WChar* x, + ACE_CDR::ULong length) +{ + if (length == 0) + return true; + char* buf = 0; + size_t const align = (ACE_OutputCDR::wchar_maxbytes_ == 2) ? + ACE_CDR::SHORT_ALIGN : + ACE_CDR::OCTET_ALIGN; + + if (this->adjust (ACE_OutputCDR::wchar_maxbytes_ * length, align, buf) == 0) + { + if (ACE_OutputCDR::wchar_maxbytes_ == 2) + { + ACE_CDR::UShort *sb = reinterpret_cast (buf); + for (size_t i = 0; i < length; ++i) +#if defined (ACE_DISABLE_SWAP_ON_READ) + x[i] = static_cast (sb[i]); +#else + if (!this->do_byte_swap_) + x[i] = static_cast (sb[i]); + else + { + ACE_CDR::UShort sx; + ACE_CDR::swap_2 (&buf[i * 2], reinterpret_cast (&sx)); + x[i] = static_cast (sx); + } +#endif /* ACE_DISABLE_SWAP_ON_READ */ + } + else + { + for (size_t i = 0; i < length; ++i) + x[i] = static_cast (buf[i]); + } + return this->good_bit_; + } + return false; +} + + +ACE_CDR::Boolean +ACE_InputCDR::read_boolean_array (ACE_CDR::Boolean *x, + ACE_CDR::ULong length) +{ + // Make sure the length of the array isn't greater than the length of + // the stream. + if (length > this->length ()) + { + this->good_bit_ = false; + return false; + } + + // It is hard to optimize this, the spec requires that on the wire + // booleans be represented as a byte with value 0 or 1, but in + // memory it is possible (though very unlikely) that a boolean has + // a non-zero value (different from 1). + // We resort to a simple loop. + for (ACE_CDR::ULong i = 0; i != length && this->good_bit_; ++i) + (void) this->read_boolean (x[i]); + + return this->good_bit_; +} + +ACE_CDR::Boolean +ACE_InputCDR::read_1 (ACE_CDR::Octet *x) +{ + if (this->rd_ptr () < this->wr_ptr ()) + { + *x = *reinterpret_cast (this->rd_ptr ()); + this->start_.rd_ptr (1); + return true; + } + + this->good_bit_ = false; + return false; +} + +ACE_CDR::Boolean +ACE_InputCDR::read_2 (ACE_CDR::UShort *x) +{ + char *buf = 0; + if (this->adjust (ACE_CDR::SHORT_SIZE, buf) == 0) + { +#if !defined (ACE_DISABLE_SWAP_ON_READ) + if (!this->do_byte_swap_) + *x = *reinterpret_cast (buf); + else + ACE_CDR::swap_2 (buf, reinterpret_cast (x)); +#else + *x = *reinterpret_cast (buf); +#endif /* ACE_DISABLE_SWAP_ON_READ */ + return true; + } + this->good_bit_ = false; + return false; +} + +ACE_CDR::Boolean +ACE_InputCDR::read_4 (ACE_CDR::ULong *x) +{ + char *buf = 0; + if (this->adjust (ACE_CDR::LONG_SIZE, buf) == 0) + { +#if !defined (ACE_DISABLE_SWAP_ON_READ) + if (!this->do_byte_swap_) + *x = *reinterpret_cast (buf); + else + ACE_CDR::swap_4 (buf, reinterpret_cast (x)); +#else + *x = *reinterpret_cast (buf); +#endif /* ACE_DISABLE_SWAP_ON_READ */ + return true; + } + this->good_bit_ = false; + return false; +} + +ACE_CDR::Boolean +ACE_InputCDR::read_8 (ACE_CDR::ULongLong *x) +{ + char *buf = 0; + + if (this->adjust (ACE_CDR::LONGLONG_SIZE, buf) == 0) + { +#if !defined (ACE_DISABLE_SWAP_ON_READ) +# if defined (__arm__) + if (!this->do_byte_swap_) + { + // Convert from Intel format (12345678 => 56781234) + const char *orig = buf; + char *target = reinterpret_cast (x); + register ACE_UINT32 x = + *reinterpret_cast (orig); + register ACE_UINT32 y = + *reinterpret_cast (orig + 4); + *reinterpret_cast (target) = y; + *reinterpret_cast (target + 4) = x; + } + else + { + // Convert from Sparc format (12345678 => 43218765) + const char *orig = buf; + char *target = reinterpret_cast (x); + register ACE_UINT32 x = + *reinterpret_cast (orig); + register ACE_UINT32 y = + *reinterpret_cast (orig + 4); + x = (x << 24) | ((x & 0xff00) << 8) | ((x & 0xff0000) >> 8) | (x >> 24); + y = (y << 24) | ((y & 0xff00) << 8) | ((y & 0xff0000) >> 8) | (y >> 24); + *reinterpret_cast (target) = x; + *reinterpret_cast (target + 4) = y; + } +# else + if (!this->do_byte_swap_) + *x = *reinterpret_cast (buf); + else + ACE_CDR::swap_8 (buf, reinterpret_cast (x)); +# endif /* !__arm__ */ +#else + *x = *reinterpret_cast (buf); +#endif /* ACE_DISABLE_SWAP_ON_READ */ + return true; + } + + this->good_bit_ = false; + return false; +} + +ACE_CDR::Boolean +ACE_InputCDR::read_16 (ACE_CDR::LongDouble *x) +{ + char *buf = 0; + if (this->adjust (ACE_CDR::LONGDOUBLE_SIZE, + ACE_CDR::LONGDOUBLE_ALIGN, + buf) == 0) + { +#if !defined (ACE_DISABLE_SWAP_ON_READ) + if (!this->do_byte_swap_) + *x = *reinterpret_cast (buf); + else + ACE_CDR::swap_16 (buf, reinterpret_cast (x)); +#else + *x = *reinterpret_cast (buf); +#endif /* ACE_DISABLE_SWAP_ON_READ */ + return true; + } + + this->good_bit_ = false; + return false; +} + +ACE_CDR::Boolean +ACE_InputCDR::skip_string (void) +{ + ACE_CDR::ULong len = 0; + if (this->read_ulong (len)) + { + if (this->rd_ptr () + len <= this->wr_ptr ()) + { + this->rd_ptr (len); + return true; + } + this->good_bit_ = false; + } + return false; +} + +ACE_CDR::Boolean +ACE_InputCDR::skip_wstring (void) +{ + ACE_CDR::ULong len = 0; + ACE_CDR::Boolean continue_skipping = read_ulong (len); + + if (continue_skipping && len != 0) + { + if (static_cast (this->major_version_) == 1 + && static_cast (this->minor_version_) == 2) + continue_skipping = this->skip_bytes ((size_t)len); + else + while (continue_skipping && len--) + continue_skipping = this->skip_wchar (); + } + return continue_skipping; +} + +ACE_CDR::Boolean +ACE_InputCDR::skip_bytes (size_t len) +{ + if (this->rd_ptr () + len <= this->wr_ptr ()) + { + this->rd_ptr (len); + return true; + } + this->good_bit_ = false; + return false; +} + +int +ACE_InputCDR::grow (size_t newsize) +{ + if (ACE_CDR::grow (&this->start_, newsize) == -1) + return -1; + + ACE_CDR::mb_align (&this->start_); + this->start_.wr_ptr (newsize); + +#if defined (ACE_HAS_MONITOR_POINTS) && (ACE_HAS_MONITOR_POINTS == 1) + if (newsize > this->start_.total_size ()) + { + this->monitor_->receive (newsize); + } +#endif /* ACE_HAS_MONITOR_POINTS==1 */ + + return 0; +} + +void +ACE_InputCDR::reset (const ACE_Message_Block* data, + int byte_order) +{ + this->reset_byte_order (byte_order); + ACE_CDR::consolidate (&this->start_, data); + +#if defined (ACE_HAS_MONITOR_POINTS) && (ACE_HAS_MONITOR_POINTS == 1) + this->monitor_->receive (this->start_.total_size ()); +#endif /* ACE_HAS_MONITOR_POINTS==1 */ +} + +void +ACE_InputCDR::steal_from (ACE_InputCDR &cdr) +{ + this->do_byte_swap_ = cdr.do_byte_swap_; + this->start_.data_block (cdr.start_.data_block ()->duplicate ()); + + // If the message block had a DONT_DELETE flags, just clear it off.. + this->start_.clr_self_flags (ACE_Message_Block::DONT_DELETE); + this->start_.rd_ptr (cdr.start_.rd_ptr ()); + + this->start_.wr_ptr (cdr.start_.wr_ptr ()); + this->major_version_ = cdr.major_version_; + this->minor_version_ = cdr.minor_version_; + cdr.reset_contents (); + +#if defined (ACE_HAS_MONITOR_POINTS) && (ACE_HAS_MONITOR_POINTS == 1) + this->monitor_->receive (this->start_.total_size ()); +#endif /* ACE_HAS_MONITOR_POINTS==1 */ +} + +void +ACE_InputCDR::exchange_data_blocks (ACE_InputCDR &cdr) +{ + // Exchange byte orders + int const byte_order = cdr.do_byte_swap_; + cdr.do_byte_swap_ = this->do_byte_swap_; + this->do_byte_swap_ = byte_order; + + // Get the destination read and write pointers + size_t const drd_pos = + cdr.start_.rd_ptr () - cdr.start_.base (); + size_t const dwr_pos = + cdr.start_.wr_ptr () - cdr.start_.base (); + + // Get the source read & write pointers + size_t const srd_pos = + this->start_.rd_ptr () - this->start_.base (); + size_t const swr_pos = + this->start_.wr_ptr () - this->start_.base (); + + // Exchange data_blocks. Dont release any of the data blocks. + ACE_Data_Block *dnb = + this->start_.replace_data_block (cdr.start_.data_block ()); + cdr.start_.replace_data_block (dnb); + + // Exchange the flags information.. + ACE_Message_Block::Message_Flags df = cdr.start_.self_flags (); + ACE_Message_Block::Message_Flags sf = this->start_.self_flags (); + + cdr.start_.clr_self_flags (df); + this->start_.clr_self_flags (sf); + + cdr.start_.set_self_flags (sf); + this->start_.set_self_flags (df); + + // Reset the pointers to zero before it is set again. + cdr.start_.reset (); + this->start_.reset (); + + // Set the read and write pointers. + if (cdr.start_.size () >= srd_pos) + { + cdr.start_.rd_ptr (srd_pos); + } + + if (cdr.start_.size () >= swr_pos) + { + cdr.start_.wr_ptr (swr_pos); + } + + if (this->start_.size () >= drd_pos) + { + this->start_.rd_ptr (drd_pos); + } + + if (this->start_.size () >= dwr_pos) + { + this->start_.wr_ptr (dwr_pos); + } + + ACE_CDR::Octet const dmajor = cdr.major_version_; + ACE_CDR::Octet const dminor = cdr.minor_version_; + + // Exchange the GIOP version info + cdr.major_version_ = this->major_version_; + cdr.minor_version_ = this->minor_version_; + + this->major_version_ = dmajor; + this->minor_version_ = dminor; + +#if defined (ACE_HAS_MONITOR_POINTS) && (ACE_HAS_MONITOR_POINTS == 1) + this->monitor_->receive (this->start_.total_size ()); +#endif /* ACE_HAS_MONITOR_POINTS==1 */ +} + +ACE_Data_Block * +ACE_InputCDR::clone_from (ACE_InputCDR &cdr) +{ + this->do_byte_swap_ = cdr.do_byte_swap_; + + // Get the read & write pointer positions in the incoming CDR + // streams + char *rd_ptr = cdr.start_.rd_ptr (); + char *wr_ptr = cdr.start_.wr_ptr (); + + // Now reset the incoming CDR stream + cdr.start_.reset (); + + // As we have reset the stream, try to align the underlying message + // block in the incoming stream + ACE_CDR::mb_align (&cdr.start_); + + // Get the read & write pointer positions again + char *nrd_ptr = cdr.start_.rd_ptr (); + char *nwr_ptr = cdr.start_.wr_ptr (); + + // Actual length of the stream is.. + // @todo: This will look idiotic, but we dont seem to have much of a + // choice. How do we calculate the length of the incoming stream? + // Calling the method before calling reset () would give us the + // wrong length of the stream that needs copying. So we do the + // calulation like this + // (1) We get the and positions of the incoming + // stream. + // (2) Then we reset the stream and then align it. + // (3) We get the and positions again. (Points #1 + // thru #3 has been done already) + // (4) The difference in the and positions gives + // us the following, the actual bytes traversed by the and + // . + // (5) The bytes traversed by the is the actual length of + // the stream. + + // Actual bytes traversed + size_t rd_bytes = rd_ptr - nrd_ptr; + size_t wr_bytes = wr_ptr - nwr_ptr; + + ACE_CDR::mb_align (&this->start_); + + ACE_Data_Block *db = + this->start_.data_block (); + + // If the size of the data that needs to be copied are higher than + // what is available, then do a reallocation. + if (wr_bytes > (this->start_.size () - ACE_CDR::MAX_ALIGNMENT)) + { + // @@NOTE: We need to probably add another method to the message + // block interface to simplify this + db = + cdr.start_.data_block ()->clone_nocopy (); + + if (db == 0 || db->size ((wr_bytes) + + ACE_CDR::MAX_ALIGNMENT) == -1) + return 0; + + // Replace our data block by using the incoming CDR stream. + db = this->start_.replace_data_block (db); + + // Align the start_ message block. + ACE_CDR::mb_align (&this->start_); + + // Clear the DONT_DELETE flag if it has been set + this->start_.clr_self_flags (ACE_Message_Block::DONT_DELETE); + } + + // Now do the copy + (void) ACE_OS::memcpy (this->start_.wr_ptr (), + cdr.start_.rd_ptr (), + wr_bytes); + + // Set the read pointer position to the same point as that was in + // cdr. + this->start_.rd_ptr (rd_bytes); + this->start_.wr_ptr (wr_bytes); + + // We have changed the read & write pointers for the incoming + // stream. Set them back to the positions that they were before.. + cdr.start_.rd_ptr (rd_bytes); + cdr.start_.wr_ptr (wr_bytes); + + this->major_version_ = cdr.major_version_; + this->minor_version_ = cdr.minor_version_; + + // Copy the char/wchar translators + this->char_translator_ = cdr.char_translator_; + this->wchar_translator_ = cdr.wchar_translator_; + +#if defined (ACE_HAS_MONITOR_POINTS) && (ACE_HAS_MONITOR_POINTS == 1) + this->monitor_->receive (this->start_.total_size ()); +#endif /* ACE_HAS_MONITOR_POINTS==1 */ + + return db; +} + +ACE_Message_Block* +ACE_InputCDR::steal_contents (void) +{ + ACE_Message_Block* block = this->start_.clone (); + this->start_.data_block (block->data_block ()->clone ()); + + // If at all our message had a DONT_DELETE flag set, just clear it + // off. + this->start_.clr_self_flags (ACE_Message_Block::DONT_DELETE); + + ACE_CDR::mb_align (&this->start_); + +#if defined (ACE_HAS_MONITOR_POINTS) && (ACE_HAS_MONITOR_POINTS == 1) + this->monitor_->receive (this->start_.total_size ()); +#endif /* ACE_HAS_MONITOR_POINTS==1 */ + + return block; +} + +void +ACE_InputCDR::reset_contents (void) +{ + this->start_.data_block (this->start_.data_block ()->clone_nocopy ()); + + // Reset the flags... + this->start_.clr_self_flags (ACE_Message_Block::DONT_DELETE); + +#if defined (ACE_HAS_MONITOR_POINTS) && (ACE_HAS_MONITOR_POINTS == 1) + this->monitor_->receive (this->start_.total_size ()); +#endif /* ACE_HAS_MONITOR_POINTS==1 */ +} + +#if defined (ACE_HAS_MONITOR_POINTS) && (ACE_HAS_MONITOR_POINTS == 1) + +void +ACE_InputCDR::register_monitor (const char *id) +{ + this->monitor_->name (id); + this->monitor_->add_to_registry (); +} + +void +ACE_InputCDR::unregister_monitor (void) +{ + this->monitor_->remove_from_registry (); +} + +#endif /* ACE_HAS_MONITOR_POINTS==1 */ + +// -------------------------------------------------------------- + +ACE_Char_Codeset_Translator::~ACE_Char_Codeset_Translator (void) +{ +} + +// -------------------------------------------------------------- + +ACE_WChar_Codeset_Translator::~ACE_WChar_Codeset_Translator (void) +{ +} + +// -------------------------------------------------------------- + +ACE_CDR::Boolean +operator<< (ACE_OutputCDR &os, const ACE_CString &x) +{ + os.write_string (x); + return os.good_bit (); +} + +ACE_CDR::Boolean +operator>> (ACE_InputCDR &is, ACE_CString &x) +{ + is.read_string (x); + return is.good_bit (); +} + +#if defined (GEN_OSTREAM_OPS) + +std::ostream& +operator<< (std::ostream &os, ACE_OutputCDR::from_boolean x) +{ + return (x.val_ ? os << "true" : os << "false"); +} + +std::ostream& +operator<< (std::ostream &os, ACE_OutputCDR::from_char x) +{ + return os << '\'' << x.val_ << '\''; +} + +std::ostream& +operator<< (std::ostream &os, ACE_OutputCDR::from_wchar x) +{ + os.setf (ios_base::showbase); + os.setf (ios_base::hex, ios_base::basefield); + os << x.val_; + os.unsetf (ios_base::showbase); + os.setf (ios_base::dec, ios_base::basefield); + return os; +} + +std::ostream& +operator<< (std::ostream &os, ACE_OutputCDR::from_octet x) +{ + // Same format (hex) and no risk of overflow. + ACE_CDR::WChar w = static_cast (x.val_); + ACE_OutputCDR::from_wchar tmp (w); + return os << tmp; +} + +#endif /* GEN_OSTREAM_OPS */ + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/CDR_Stream.h b/dep/ACE_wrappers/ace/CDR_Stream.h new file mode 100644 index 00000000000..a9c789f41d7 --- /dev/null +++ b/dep/ACE_wrappers/ace/CDR_Stream.h @@ -0,0 +1,1402 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file CDR_Stream.h + * + * $Id: CDR_Stream.h 82350 2008-07-22 07:36:47Z johnnyw $ + * + * ACE Common Data Representation (CDR) marshaling and demarshaling + * classes. + * + * This implementation was inspired in the CDR class in SunSoft's + * IIOP engine, but has a completely different implementation and a + * different interface too. + * + * The current implementation assumes that the host has 1-byte, + * 2-byte and 4-byte integral types, and that it has single + * precision and double precision IEEE floats. + * Those assumptions are pretty good these days, with Crays being + * the only known exception. + * + * Optimizations + * ------------- + * ACE_LACKS_CDR_ALIGNMENT + * @author Arvind S. Krishna + * + * CDR stream ignores alignment when marshaling data. Use this option + * only when ACE_DISABLE_SWAP_ON_READ can be enabled. This option requires + * ACE CDR engine to do both marshaling and demarshaling. + * + * + * @author TAO version by Aniruddha Gokhale + * @author Carlos O'Ryan + * @author ACE version by Jeff Parsons + * @author Istvan Buki + * @author Codeset translation by Jim Rogers + */ +//============================================================================= + +#ifndef ACE_CDR_STREAM_H +#define ACE_CDR_STREAM_H + +#include /**/ "ace/pre.h" + +#include "ace/CDR_Base.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/SStringfwd.h" +#include "ace/Message_Block.h" + +#if defined (GEN_OSTREAM_OPS) +#include "ace/streams.h" +#endif /* GEN_OSTREAM_OPS */ + +#if defined (ACE_HAS_MONITOR_POINTS) && (ACE_HAS_MONITOR_POINTS == 1) +#include "Monitor_Size.h" +#endif /* ACE_HAS_MONITOR_POINTS==1 */ + + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +class ACE_Char_Codeset_Translator; +class ACE_WChar_Codeset_Translator; + +class ACE_InputCDR; + +/** + * @class ACE_OutputCDR + * + * @brief A CDR stream for marshalling data, most often for transmission to + * another system which may or may not have the same byte order. + * + * This class is based on the the CORBA spec for Java (98-02-29), + * java class omg.org.CORBA.portable.OutputStream. It diverts in + * a few ways: + * @li Operations taking arrays don't have offsets, because in C++ + * it is easier to describe an array starting from x+offset. + * @li Operations return an error status, because exceptions are + * not widely available in C++ (yet). + */ +class ACE_Export ACE_OutputCDR +{ +public: + /** + * The Codeset translators need access to some private members to + * efficiently marshal arrays + * For reading from an output CDR stream. + */ + friend class ACE_Char_Codeset_Translator; + friend class ACE_WChar_Codeset_Translator; + friend class ACE_InputCDR; + + /** + * Default constructor; allows one to set byte ordering, allocators, and + * tuning information. + * + * @param size Causes constructor to preallocate @a size bytes; if + * @a size is 0 it allocates the default size. + * + * @param byte_order The byte order that data will have within this + * object. Unless otherwise specified, the byte order + * will be the order native to the hardware this is + * executed on. To force the marshalled data to have + * a specific order, specify one of the values defined + * in ACE_CDR::Byte_Order. + * @note The @c ACE_ENABLE_SWAP_ON_WRITE config macro + * must be set for any local byte swapping to occur + * as data is inserted into an ACE_OutputCDR object. + */ + ACE_OutputCDR (size_t size = 0, + int byte_order = ACE_CDR::BYTE_ORDER_NATIVE, + ACE_Allocator* buffer_allocator = 0, + ACE_Allocator* data_block_allocator = 0, + ACE_Allocator* message_block_allocator = 0, + size_t memcpy_tradeoff = ACE_DEFAULT_CDR_MEMCPY_TRADEOFF, + ACE_CDR::Octet major_version = ACE_CDR_GIOP_MAJOR_VERSION, + ACE_CDR::Octet minor_version = ACE_CDR_GIOP_MINOR_VERSION); + + /// Build a CDR stream with an initial buffer, it will *not* remove + /// , since it did not allocated it. It's important to be careful + /// with the alignment of . + /** + * Create an output stream from an arbitrary buffer, care must be + * exercised with alignment, because this contructor will align if + * needed. In this case @a data will not point to the start of the + * output stream. @c begin()->rd_ptr() points to the start of the + * output stream. See @c ACE_ptr_align_binary() to properly align a + * pointer and use ACE_CDR::MAX_ALIGNMENT for the correct alignment. + */ + ACE_OutputCDR (char *data, + size_t size, + int byte_order = ACE_CDR::BYTE_ORDER_NATIVE, + ACE_Allocator* buffer_allocator = 0, + ACE_Allocator* data_block_allocator = 0, + ACE_Allocator* message_block_allocator = 0, + size_t memcpy_tradeoff = ACE_DEFAULT_CDR_MEMCPY_TRADEOFF, + ACE_CDR::Octet giop_major_version = ACE_CDR_GIOP_MAJOR_VERSION, + ACE_CDR::Octet giop_minor_version = ACE_CDR_GIOP_MINOR_VERSION); + + /// Build a CDR stream with an initial data block, it will *not* remove + /// , since it did not allocated it. It's important to be + // careful with the alignment of . + /** + * Create an output stream from an arbitrary data block, care must be + * exercised with alignment, because this contructor will align if + * needed. In this case @a data_block will not point to the + * start of the output stream. begin()->rd_ptr() points to the start + * off the output stream. See ACE_ptr_align_binary() to properly align a + * pointer and use ACE_CDR::MAX_ALIGNMENT for the correct alignment. + */ + ACE_OutputCDR (ACE_Data_Block *data_block, + int byte_order = ACE_CDR::BYTE_ORDER_NATIVE, + ACE_Allocator* message_block_allocator = 0, + size_t memcpy_tradeoff = ACE_DEFAULT_CDR_MEMCPY_TRADEOFF, + ACE_CDR::Octet giop_major_version = ACE_CDR_GIOP_MAJOR_VERSION, + ACE_CDR::Octet giop_minor_version = ACE_CDR_GIOP_MINOR_VERSION); + + /// Build a CDR stream with an initial Message_Block chain, it will + /// *not* remove @a data, since it did not allocate it. + ACE_OutputCDR (ACE_Message_Block *data, + int byte_order = ACE_CDR::BYTE_ORDER_NATIVE, + size_t memcpy_tradeoff = ACE_DEFAULT_CDR_MEMCPY_TRADEOFF, + ACE_CDR::Octet giop_major_version = ACE_CDR_GIOP_MAJOR_VERSION, + ACE_CDR::Octet giop_minor_version = ACE_CDR_GIOP_MINOR_VERSION); + + /// destructor + ~ACE_OutputCDR (void); + + /** + * Disambiguate overload when inserting booleans, octets, chars, and + * bounded strings. + */ + //@{ @name Helper classes + + struct ACE_Export from_boolean + { + explicit from_boolean (ACE_CDR::Boolean b); + ACE_CDR::Boolean val_; + }; + + struct ACE_Export from_octet + { + explicit from_octet (ACE_CDR::Octet o); + ACE_CDR::Octet val_; + }; + + struct ACE_Export from_char + { + explicit from_char (ACE_CDR::Char c); + ACE_CDR::Char val_; + }; + + struct ACE_Export from_wchar + { + explicit from_wchar (ACE_CDR::WChar wc); + ACE_CDR::WChar val_; + }; + + struct ACE_Export from_string + { + from_string (ACE_CDR::Char* s, + ACE_CDR::ULong b, + ACE_CDR::Boolean nocopy = 0); + from_string (const ACE_CDR::Char* s, + ACE_CDR::ULong b, + ACE_CDR::Boolean nocopy = 0); + ACE_CDR::Char *val_; + ACE_CDR::ULong bound_; + ACE_CDR::Boolean nocopy_; + }; + + struct ACE_Export from_wstring + { + from_wstring (ACE_CDR::WChar* ws, + ACE_CDR::ULong b, + ACE_CDR::Boolean nocopy = 0); + from_wstring (const ACE_CDR::WChar* ws, + ACE_CDR::ULong b, + ACE_CDR::Boolean nocopy = 0); + ACE_CDR::WChar *val_; + ACE_CDR::ULong bound_; + ACE_CDR::Boolean nocopy_; + }; + //@} + + /** + * @{ @name Write operations + * Return 0 on failure and 1 on success. + */ + ACE_CDR::Boolean write_boolean (ACE_CDR::Boolean x); + ACE_CDR::Boolean write_char (ACE_CDR::Char x); + ACE_CDR::Boolean write_wchar (ACE_CDR::WChar x); + ACE_CDR::Boolean write_octet (ACE_CDR::Octet x); + ACE_CDR::Boolean write_short (ACE_CDR::Short x); + ACE_CDR::Boolean write_ushort (ACE_CDR::UShort x); + ACE_CDR::Boolean write_long (ACE_CDR::Long x); + ACE_CDR::Boolean write_ulong (ACE_CDR::ULong x); + ACE_CDR::Boolean write_longlong (const ACE_CDR::LongLong &x); + ACE_CDR::Boolean write_ulonglong (const ACE_CDR::ULongLong &x); + ACE_CDR::Boolean write_float (ACE_CDR::Float x); + ACE_CDR::Boolean write_double (const ACE_CDR::Double &x); + ACE_CDR::Boolean write_longdouble (const ACE_CDR::LongDouble &x); + + /// For string we offer methods that accept a precomputed length. + ACE_CDR::Boolean write_string (const ACE_CDR::Char *x); + ACE_CDR::Boolean write_string (ACE_CDR::ULong len, + const ACE_CDR::Char *x); + ACE_CDR::Boolean write_string (const ACE_CString &x); + ACE_CDR::Boolean write_wstring (const ACE_CDR::WChar *x); + ACE_CDR::Boolean write_wstring (ACE_CDR::ULong length, + const ACE_CDR::WChar *x); + //@} + + /// @note the portion written starts at and ends + /// at . + /// The length is *NOT* stored into the CDR stream. + //@{ @name Array write operations + ACE_CDR::Boolean write_boolean_array (const ACE_CDR::Boolean *x, + ACE_CDR::ULong length); + ACE_CDR::Boolean write_char_array (const ACE_CDR::Char *x, + ACE_CDR::ULong length); + ACE_CDR::Boolean write_wchar_array (const ACE_CDR::WChar* x, + ACE_CDR::ULong length); + ACE_CDR::Boolean write_octet_array (const ACE_CDR::Octet* x, + ACE_CDR::ULong length); + ACE_CDR::Boolean write_short_array (const ACE_CDR::Short *x, + ACE_CDR::ULong length); + ACE_CDR::Boolean write_ushort_array (const ACE_CDR::UShort *x, + ACE_CDR::ULong length); + ACE_CDR::Boolean write_long_array (const ACE_CDR::Long *x, + ACE_CDR::ULong length); + ACE_CDR::Boolean write_ulong_array (const ACE_CDR::ULong *x, + ACE_CDR::ULong length); + ACE_CDR::Boolean write_longlong_array (const ACE_CDR::LongLong* x, + ACE_CDR::ULong length); + ACE_CDR::Boolean write_ulonglong_array (const ACE_CDR::ULongLong *x, + ACE_CDR::ULong length); + ACE_CDR::Boolean write_float_array (const ACE_CDR::Float *x, + ACE_CDR::ULong length); + ACE_CDR::Boolean write_double_array (const ACE_CDR::Double *x, + ACE_CDR::ULong length); + ACE_CDR::Boolean write_longdouble_array (const ACE_CDR::LongDouble* x, + ACE_CDR::ULong length); + + /// Write an octet array contained inside a MB, this can be optimized + /// to minimize copies. + ACE_CDR::Boolean write_octet_array_mb (const ACE_Message_Block* mb); + //@} + + /** + * @{ @name Placeholder/replace operations + * Facilitates writing a placeholder into a CDR stream to be replaced + * later with a different value. + * + * @note An example use for this facility is: + * @code + ACE_OutputCDR strm; + ... // insert values... + char *pos = strm.write_long_placeholder (); + ... // insert more values + ACE_CDR::Long real_val; // Somehow assign the "correct" value + strm.replace (real_val, pos); // Replace earlier placeholder + @endcode + */ + + /** + * Write a placeholder into the stream. The placeholder's pointer + * is returned so it may later be passed as the @a loc argument to + * replace (). + * These methods align the stream's write pointer properly prior to + * writing the placeholder. + * + * @retval Pointer to the placeholder; 0 if there is not enough space + * in the stream and memory could not be allocated. + */ + char* write_long_placeholder (void); + char* write_short_placeholder (void); + + /** + * Writes a new value into a specific location. This is commonly + * used to update a prior "placeholder" location in the stream. + * The specified location is assumed to have proper CDR alignment for the + * type to insert. This requirement is satisfied by using one of the + * placeholder-writing methods to align the stream for the anticipated + * value and obtain the correct location. + * Treatment of @a x with repect to byte swapping is the same as for when + * any value is inserted. + * + * @param x The value to insert into the specified location. + * @param loc The location at which to insert @a x. @a loc must be a valid + * position within the stream's current set of message blocks. + * + * @sa write_long_placeholder(), write_short_placeholder () + */ + ACE_CDR::Boolean replace (ACE_CDR::Long x, char* loc); + ACE_CDR::Boolean replace (ACE_CDR::Short x, char* loc); + //@} + + /** + * Return 0 on failure and 1 on success. + */ + //@{ @name Append contents of own CDR stream to another + ACE_CDR::Boolean append_boolean (ACE_InputCDR &); + ACE_CDR::Boolean append_char (ACE_InputCDR &); + ACE_CDR::Boolean append_wchar (ACE_InputCDR &); + ACE_CDR::Boolean append_octet (ACE_InputCDR &); + ACE_CDR::Boolean append_short (ACE_InputCDR &); + ACE_CDR::Boolean append_ushort (ACE_InputCDR &); + ACE_CDR::Boolean append_long (ACE_InputCDR &); + ACE_CDR::Boolean append_ulong (ACE_InputCDR &); + ACE_CDR::Boolean append_longlong (ACE_InputCDR &); + ACE_CDR::Boolean append_ulonglong (ACE_InputCDR &); + ACE_CDR::Boolean append_float (ACE_InputCDR &); + ACE_CDR::Boolean append_double (ACE_InputCDR &); + ACE_CDR::Boolean append_longdouble (ACE_InputCDR &); + + ACE_CDR::Boolean append_wstring (ACE_InputCDR &); + ACE_CDR::Boolean append_string (ACE_InputCDR &); + //@} + + /// Returns @c false if an error has ocurred. + /** + * @note The only expected error is to run out of memory. + */ + bool good_bit (void) const; + + /// Reuse the CDR stream to write on the old buffer. + void reset (void); + + /// Add the length of each message block in the chain. + size_t total_length (void) const; + + /** + * Return the start of the message block chain for this CDR stream. + * @note The complete CDR stream is represented by a chain of + * message blocks. + */ + const ACE_Message_Block *begin (void) const; + + /// Return the last message in the chain that is is use. + const ACE_Message_Block *end (void) const; + + /// Return the message block in chain. + const ACE_Message_Block *current (void) const; + + /// Replace the message block chain with a single message block. + /** + * Upon successful completion, there will be a single message block + * containing the data from the complete message block chain. + * + * @note The only expected error is to run out of memory. + */ + int consolidate (void); + + /** + * Access the underlying buffer (read only). @note This + * method only returns a pointer to the first block in the + * chain. + */ + const char *buffer (void) const; + + /** + * Return the size of first message block in the block chain. @note This + * method only returns information about the first block in the + * chain. + */ + size_t length (void) const; + + /** + * Utility function to allow the user more flexibility. + * Pads the stream up to the nearest -byte boundary. + * Argument MUST be a power of 2. + * Returns 0 on success and -1 on failure. + */ + int align_write_ptr (size_t alignment); + + /// Access the codeset translators. They can be null! + ACE_Char_Codeset_Translator *char_translator (void) const; + ACE_WChar_Codeset_Translator *wchar_translator (void) const; + + /// Set the char codeset translator. + void char_translator (ACE_Char_Codeset_Translator *); + /// Set the wchar codeset translator. + void wchar_translator (ACE_WChar_Codeset_Translator *); + + /// set the global size of serialized wchars. This may be different + /// than the size of a wchar_t. + static void wchar_maxbytes (size_t max_bytes); + + /// access the serialized size of wchars. + static size_t wchar_maxbytes (void); + + /** + * Return alignment of the wr_ptr(), with respect to the start of + * the CDR stream. This is not the same as the alignment of + * current->wr_ptr()! + */ + size_t current_alignment (void) const; + + void current_alignment (size_t current_alignment); + + /** + * Returns (in @a buf) the next position in the buffer aligned to + * @a size, it advances the Message_Block wr_ptr past the data + * (i.e., @a buf + @a size). If necessary it grows the Message_Block + * buffer. Sets the good_bit to false and returns a -1 on failure. + */ + int adjust (size_t size, + char *&buf); + + /// As above, but now the size and alignment requirements may be + /// different. + int adjust (size_t size, + size_t align, + char *&buf); + + /// Returns true if this stream is writing in non-native byte order + /// and false otherwise. For example, it would be true if either + /// ACE_ENABLE_SWAP_ON_WRITE is defined or a specific byte order was + /// specified for this stream. + bool do_byte_swap (void) const; + + /// Returns the byte order this stream is marshaling data in. Will be one + /// of the values in ACE_CDR::Byte_Order. + int byte_order (void) const; + + /// For use by a gateway, which creates the output stream for the + /// reply to the client in its native byte order, but which must + /// send the reply in the byte order of the target's reply to the + /// gateway. + void reset_byte_order (int byte_order); + + /// set GIOP version info + void set_version (ACE_CDR::Octet major, ACE_CDR::Octet minor); + + /// Set the underlying GIOP version.. + void get_version (ACE_CDR::Octet &major, ACE_CDR::Octet &minor); + +#if defined (ACE_HAS_MONITOR_POINTS) && (ACE_HAS_MONITOR_POINTS == 1) + /// Register and unregister our buffer size monitor. + void register_monitor (const char* id); + void unregister_monitor (void); +#endif /* ACE_HAS_MONITOR_POINTS==1 */ + +private: + + // Find the message block in the chain of message blocks + // that the provide location locates. + ACE_Message_Block* find (char* loc); + + /// disallow copying... + ACE_OutputCDR (const ACE_OutputCDR& rhs); + ACE_OutputCDR& operator= (const ACE_OutputCDR& rhs); + + ACE_CDR::Boolean write_1 (const ACE_CDR::Octet *x); + ACE_CDR::Boolean write_2 (const ACE_CDR::UShort *x); + ACE_CDR::Boolean write_4 (const ACE_CDR::ULong *x); + ACE_CDR::Boolean write_8 (const ACE_CDR::ULongLong *x); + ACE_CDR::Boolean write_16 (const ACE_CDR::LongDouble *x); + + /** + * write an array of @a length elements, each of @a size bytes and the + * start aligned at a multiple of . The elements are assumed + * to be packed with the right alignment restrictions. It is mostly + * designed for buffers of the basic types. + * + * This operation uses ; as explained above it is expected + * that using assignment is faster that for one element, + * but for several elements should be more efficient, it + * could be interesting to find the break even point and optimize + * for that case, but that would be too platform dependent. + */ + ACE_CDR::Boolean write_array (const void *x, + size_t size, + size_t align, + ACE_CDR::ULong length); + + + ACE_CDR::Boolean write_wchar_array_i (const ACE_CDR::WChar* x, + ACE_CDR::ULong length); + + + /** + * Grow the CDR stream. When it returns @a buf contains a pointer to + * memory in the CDR stream, with at least @a size bytes ahead of it + * and aligned to an boundary. It moved the to . + */ + int grow_and_adjust (size_t size, + size_t align, + char *&buf); + +private: + /// The start of the chain of message blocks. + ACE_Message_Block start_; + + /// The current block in the chain where we are writing. + ACE_Message_Block *current_; + +#if !defined (ACE_LACKS_CDR_ALIGNMENT) + /** + * The current alignment as measured from the start of the buffer. + * Usually this coincides with the alignment of the buffer in + * memory, but, when we chain another buffer this "quasi invariant" + * is broken. + * The current_alignment is used to readjust the buffer following + * the stolen message block. + */ + size_t current_alignment_; +#endif /* ACE_LACKS_CDR_ALIGNMENT */ + + /** + * Is the current block writable. When we steal a buffer from the + * user and just chain it into the message block we are not supposed + * to write on it, even if it is past the start and end of the + * buffer. + */ + bool current_is_writable_; + + /** + * If not zero swap bytes at writing so the created CDR stream byte + * order does *not* match the machine byte order. The motivation + * for such a beast is that in some setting a few (fast) machines + * can be serving hundreds of slow machines with the opposite byte + * order, so it makes sense (as a load balancing device) to put the + * responsibility in the writers. THIS IS NOT A STANDARD IN CORBA, + * USE AT YOUR OWN RISK + */ + bool do_byte_swap_; + + /// Set to false when an error ocurrs. + bool good_bit_; + + /// Break-even point for copying. + size_t const memcpy_tradeoff_; + +#if defined (ACE_HAS_MONITOR_POINTS) && (ACE_HAS_MONITOR_POINTS == 1) + ACE::Monitor_Control::Size_Monitor *monitor_; +#endif /* ACE_HAS_MONITOR_POINTS==1 */ + +protected: + /// GIOP version information + ACE_CDR::Octet major_version_; + ACE_CDR::Octet minor_version_; + + /// If not nil, invoke for translation of character and string data. + ACE_Char_Codeset_Translator *char_translator_; + ACE_WChar_Codeset_Translator *wchar_translator_; + + /** + * Some wide char codesets may be defined with a maximum number + * of bytes that is smaller than the size of a wchar_t. This means + * that the CDR cannot simply memcpy a block of wchars to and from + * the stream, but must instead realign the bytes appropriately. + * In cases when wchar i/o is not allowed, such as with GIOP 1.0, + * or not having a native wchar codeset defined, the maxbytes is + * set to zero, indicating no wchar data is allowed. + */ + static size_t wchar_maxbytes_; +}; + + +// **************************************************************** + +/** + * @class ACE_InputCDR + * + * @brief A CDR stream for demarshalling CDR-encoded data. + * + * This class is based on the the CORBA spec for Java (98-02-29), + * java class omg.org.CORBA.portable.InputStream. It diverts in a + * few ways: + * @li Operations to retrieve basic types take parameters by + * reference. + * @li Operations taking arrays don't have offsets, because in C++ + * it is easier to describe an array starting from x+offset. + * @li Operations return an error status, because exceptions are + * not widely available in C++ (yet). + */ +class ACE_Export ACE_InputCDR +{ +public: + // The translators need privileged access to efficiently demarshal + // arrays and such. + friend class ACE_Char_Codeset_Translator; + friend class ACE_WChar_Codeset_Translator; + + /** + * Create an input stream from an arbitrary buffer. The buffer must + * be properly aligned because this contructor will *not* work if + * the buffer is aligned unproperly.See ACE_ptr_align_binary() for + * instructions on how to align a pointer properly and use + * ACE_CDR::MAX_ALIGNMENT for the correct alignment. + */ + ACE_InputCDR (const char *buf, + size_t bufsiz, + int byte_order = ACE_CDR::BYTE_ORDER_NATIVE, + ACE_CDR::Octet major_version = ACE_CDR_GIOP_MAJOR_VERSION, + ACE_CDR::Octet minor_version = ACE_CDR_GIOP_MINOR_VERSION); + + /// Create an empty input stream. The caller is responsible for + /// putting the right data and providing the right alignment. + ACE_InputCDR (size_t bufsiz, + int byte_order = ACE_CDR::BYTE_ORDER_NATIVE, + ACE_CDR::Octet major_version = ACE_CDR_GIOP_MAJOR_VERSION, + ACE_CDR::Octet minor_version = ACE_CDR_GIOP_MINOR_VERSION); + + /// Create an input stream from an ACE_Message_Block + /** + * The alignment of the @a data block is carried into the new + * ACE_InputCDR object. This constructor either increments the + * @a data reference count, or copies the data (if it's a compound + * message block) so the caller can release the block immediately + * upon return. + */ + ACE_InputCDR (const ACE_Message_Block *data, + int byte_order = ACE_CDR::BYTE_ORDER_NATIVE, + ACE_CDR::Octet major_version = ACE_CDR_GIOP_MAJOR_VERSION, + ACE_CDR::Octet minor_version = ACE_CDR_GIOP_MINOR_VERSION, + ACE_Lock* lock = 0); + + /// Create an input stream from an ACE_Data_Block. The + /// indicates whether the can be deleted by the CDR stream + /// or not + ACE_InputCDR (ACE_Data_Block *data, + ACE_Message_Block::Message_Flags flag = 0, + int byte_order = ACE_CDR::BYTE_ORDER_NATIVE, + ACE_CDR::Octet major_version = ACE_CDR_GIOP_MAJOR_VERSION, + ACE_CDR::Octet minor_version = ACE_CDR_GIOP_MINOR_VERSION); + + /// Create an input stream from an ACE_Data_Block. It also sets the + /// read and write pointers at the desired positions. This would be + /// helpful if the applications desires to create a new CDR stream + /// from a semi-processed datablock. + ACE_InputCDR (ACE_Data_Block *data, + ACE_Message_Block::Message_Flags flag, + size_t read_pointer_position, + size_t write_pointer_position, + int byte_order = ACE_CDR::BYTE_ORDER_NATIVE, + ACE_CDR::Octet major_version = ACE_CDR_GIOP_MAJOR_VERSION, + ACE_CDR::Octet minor_version = ACE_CDR_GIOP_MINOR_VERSION); + + /** + * These make a copy of the current stream state, but do not copy + * the internal buffer, so the same stream can be read multiple + * times efficiently. + */ + ACE_InputCDR (const ACE_InputCDR& rhs); + + ACE_InputCDR& operator= (const ACE_InputCDR& rhs); + + /// When interpreting indirected TypeCodes it is useful to make a + /// "copy" of the stream starting in the new position. + ACE_InputCDR (const ACE_InputCDR& rhs, + size_t size, + ACE_CDR::Long offset); + + /// This creates an encapsulated stream, the first byte must be (per + /// the spec) the byte order of the encapsulation. + ACE_InputCDR (const ACE_InputCDR& rhs, + size_t size); + + /// Create an input CDR from an output CDR. + ACE_InputCDR (const ACE_OutputCDR& rhs, + ACE_Allocator* buffer_allocator = 0, + ACE_Allocator* data_block_allocator = 0, + ACE_Allocator* message_block_allocator = 0); + + /// Helper class to transfer the contents from one input CDR to + /// another without requiring any extra memory allocations, data + /// copies or too many temporaries. + struct ACE_Export Transfer_Contents + { + Transfer_Contents (ACE_InputCDR &rhs); + + ACE_InputCDR &rhs_; + }; + /// Transfer the contents from to a new CDR + ACE_InputCDR (Transfer_Contents rhs); + + /// Destructor + ~ACE_InputCDR (void); + + /// Disambiguate overloading when extracting octets, chars, + /// booleans, and bounded strings + //@{ @name Helper classes + + struct ACE_Export to_boolean + { + explicit to_boolean (ACE_CDR::Boolean &b); + ACE_CDR::Boolean &ref_; + }; + + struct ACE_Export to_char + { + explicit to_char (ACE_CDR::Char &c); + ACE_CDR::Char &ref_; + }; + + struct ACE_Export to_wchar + { + explicit to_wchar (ACE_CDR::WChar &wc); + ACE_CDR::WChar &ref_; + }; + + struct ACE_Export to_octet + { + explicit to_octet (ACE_CDR::Octet &o); + ACE_CDR::Octet &ref_; + }; + + struct ACE_Export to_string + { + /** + * @deprecated The constructor taking a non-const string is now + * deprecated (C++ mapping 00-01-02), but we keep it + * around for backward compatibility. + */ + to_string (ACE_CDR::Char *&s, + ACE_CDR::ULong b); + to_string (const ACE_CDR::Char *&s, + ACE_CDR::ULong b); + const ACE_CDR::Char *&val_; + ACE_CDR::ULong bound_; + }; + + struct ACE_Export to_wstring + { + /// The constructor taking a non-const wstring is + /// now deprecated (C++ mapping 00-01-02), but we + /// keep it around for backward compatibility. + to_wstring (ACE_CDR::WChar *&ws, + ACE_CDR::ULong b); + to_wstring (const ACE_CDR::WChar *&ws, + ACE_CDR::ULong b); + const ACE_CDR::WChar *&val_; + ACE_CDR::ULong bound_; + }; + //@} + + /** + * Return @c false on failure and @c true on success. + */ + //@{ @name Read basic IDL types + ACE_CDR::Boolean read_boolean (ACE_CDR::Boolean& x); + ACE_CDR::Boolean read_char (ACE_CDR::Char &x); + ACE_CDR::Boolean read_wchar (ACE_CDR::WChar& x); + ACE_CDR::Boolean read_octet (ACE_CDR::Octet& x); + ACE_CDR::Boolean read_short (ACE_CDR::Short &x); + ACE_CDR::Boolean read_ushort (ACE_CDR::UShort &x); + ACE_CDR::Boolean read_long (ACE_CDR::Long &x); + ACE_CDR::Boolean read_ulong (ACE_CDR::ULong &x); + ACE_CDR::Boolean read_longlong (ACE_CDR::LongLong& x); + ACE_CDR::Boolean read_ulonglong (ACE_CDR::ULongLong& x); + ACE_CDR::Boolean read_float (ACE_CDR::Float &x); + ACE_CDR::Boolean read_double (ACE_CDR::Double &x); + ACE_CDR::Boolean read_longdouble (ACE_CDR::LongDouble &x); + + ACE_CDR::Boolean read_string (ACE_CDR::Char *&x); + ACE_CDR::Boolean read_string (ACE_CString &x); + ACE_CDR::Boolean read_wstring (ACE_CDR::WChar*& x); + //@} + + /** + * The buffer @a x must be large enough to contain @a length + * elements. + * Return @c false on failure and @c true on success. + */ + //@{ @name Read basic IDL types arrays + ACE_CDR::Boolean read_boolean_array (ACE_CDR::Boolean* x, + ACE_CDR::ULong length); + ACE_CDR::Boolean read_char_array (ACE_CDR::Char *x, + ACE_CDR::ULong length); + ACE_CDR::Boolean read_wchar_array (ACE_CDR::WChar* x, + ACE_CDR::ULong length); + ACE_CDR::Boolean read_octet_array (ACE_CDR::Octet* x, + ACE_CDR::ULong length); + ACE_CDR::Boolean read_short_array (ACE_CDR::Short *x, + ACE_CDR::ULong length); + ACE_CDR::Boolean read_ushort_array (ACE_CDR::UShort *x, + ACE_CDR::ULong length); + ACE_CDR::Boolean read_long_array (ACE_CDR::Long *x, + ACE_CDR::ULong length); + ACE_CDR::Boolean read_ulong_array (ACE_CDR::ULong *x, + ACE_CDR::ULong length); + ACE_CDR::Boolean read_longlong_array (ACE_CDR::LongLong* x, + ACE_CDR::ULong length); + ACE_CDR::Boolean read_ulonglong_array (ACE_CDR::ULongLong* x, + ACE_CDR::ULong length); + ACE_CDR::Boolean read_float_array (ACE_CDR::Float *x, + ACE_CDR::ULong length); + ACE_CDR::Boolean read_double_array (ACE_CDR::Double *x, + ACE_CDR::ULong length); + ACE_CDR::Boolean read_longdouble_array (ACE_CDR::LongDouble* x, + ACE_CDR::ULong length); + //@} + + /** + * Return @c false on failure and @c true on success. + */ + //@{ @name Skip elements + ACE_CDR::Boolean skip_boolean (void); + ACE_CDR::Boolean skip_char (void); + ACE_CDR::Boolean skip_wchar (void); + ACE_CDR::Boolean skip_octet (void); + ACE_CDR::Boolean skip_short (void); + ACE_CDR::Boolean skip_ushort (void); + ACE_CDR::Boolean skip_long (void); + ACE_CDR::Boolean skip_ulong (void); + ACE_CDR::Boolean skip_longlong (void); + ACE_CDR::Boolean skip_ulonglong (void); + ACE_CDR::Boolean skip_float (void); + ACE_CDR::Boolean skip_double (void); + ACE_CDR::Boolean skip_longdouble (void); + //@} + + /** + * The next field must be a string, this method skips it. It is + * useful in parsing a TypeCode. + * @return @c false on failure and @c true on success. + */ + ACE_CDR::Boolean skip_wstring (void); + ACE_CDR::Boolean skip_string (void); + + /// Skip @a n bytes in the CDR stream. + /** + * @return @c false on failure and @c true on success. + */ + ACE_CDR::Boolean skip_bytes (size_t n); + + /// returns @c false if a problem has been detected. + bool good_bit (void) const; + + /** + * @return The start of the message block chain for this CDR + * stream. + * + * @note In the current implementation the chain has length 1, but + * we are planning to change that. + */ + const ACE_Message_Block* start (void) const; + + // = The following functions are useful to read the contents of the + // CDR stream from a socket or file. + + /** + * Grow the internal buffer, reset @c rd_ptr to the first byte in + * the new buffer that is properly aligned, and set @c wr_ptr to @c + * rd_ptr @c + @c newsize + */ + int grow (size_t newsize); + + /** + * After reading and partially parsing the contents the user can + * detect a change in the byte order, this method will let him/her + * change it. + */ + void reset_byte_order (int byte_order); + + /// Re-initialize the CDR stream, copying the contents of the chain + /// of message_blocks starting from @a data. + void reset (const ACE_Message_Block *data, + int byte_order); + + /// Steal the contents from the current CDR. + ACE_Message_Block *steal_contents (void); + + /// Steal the contents of @a cdr and make a shallow copy into this + /// stream. + void steal_from (ACE_InputCDR &cdr); + + /// Exchange data blocks with the caller of this method. The read + /// and write pointers are also exchanged. + /** + * @note We now do only with the start_ message block. + */ + void exchange_data_blocks (ACE_InputCDR &cdr); + + /// Copy the data portion from the @c cdr to this cdr and return the + /// data content (ie. the ACE_Data_Block) from this CDR to the + /// caller. + /** + * @note The caller is responsible for managing the memory of the + * returned ACE_Data_Block. + */ + ACE_Data_Block* clone_from (ACE_InputCDR &cdr); + + /// Re-initialize the CDR stream, forgetting about the old contents + /// of the stream and allocating a new buffer (from the allocators). + void reset_contents (void); + + /// Returns the current position for the @c rd_ptr. + char* rd_ptr (void); + + /// Returns the current position for the @c wr_ptr. + char* wr_ptr (void); + + /// Return how many bytes are left in the stream. + size_t length (void) const; + + /** + * Utility function to allow the user more flexibility. + * Skips up to the nearest @a alignment-byte boundary. + * Argument MUST be a power of 2. + * + * @return 0 on success and -1 on failure. + */ + int align_read_ptr (size_t alignment); + + /// If @c true then this stream is writing in non-native byte order. + /// This is only meaningful if ACE_ENABLE_SWAP_ON_WRITE is defined. + bool do_byte_swap (void) const; + + /// If @c do_byte_swap() returns @c false, this returns + /// ACE_CDR_BYTE_ORDER else it returns !ACE_CDR_BYTE_ORDER. + int byte_order (void) const; + + /// Access the codeset translators. They can be nil! + ACE_Char_Codeset_Translator *char_translator (void) const; + ACE_WChar_Codeset_Translator *wchar_translator (void) const; + + /// Set the codeset translators. + void char_translator (ACE_Char_Codeset_Translator *); + void wchar_translator (ACE_WChar_Codeset_Translator *); + + /** + * Returns (in @a buf) the next position in the buffer aligned to + * @a size. It advances the Message_Block @c rd_ptr past the data + * (i.e., @c buf @c + @c size). Sets the good_bit to @c false and + * returns a -1 on failure. + */ + int adjust (size_t size, + char *&buf); + + /// As above, but now the size and alignment requirements may be + /// different. + int adjust (size_t size, + size_t align, + char *&buf); + + /// Set the underlying GIOP version.. + void set_version (ACE_CDR::Octet major, ACE_CDR::Octet minor); + + /// Set the underlying GIOP version.. + void get_version (ACE_CDR::Octet &major, ACE_CDR::Octet &minor); + +#if defined (ACE_HAS_MONITOR_POINTS) && (ACE_HAS_MONITOR_POINTS == 1) + /// Register and unregister our buffer size monitor. + void register_monitor (const char* id); + void unregister_monitor (void); +#endif /* ACE_HAS_MONITOR_POINTS==1 */ + +protected: + + /// The start of the chain of message blocks, even though in the + /// current version the chain always has length 1. + ACE_Message_Block start_; + + /// The CDR stream byte order does not match the one on the machine, + /// swapping is needed while reading. + bool do_byte_swap_; + + /// set to @c false when an error occurs. + bool good_bit_; + + /// The GIOP versions for this stream + ACE_CDR::Octet major_version_; + ACE_CDR::Octet minor_version_; + + /// If not nil, invoke for translation of character and string data. + ACE_Char_Codeset_Translator *char_translator_; + ACE_WChar_Codeset_Translator *wchar_translator_; + +#if defined (ACE_HAS_MONITOR_POINTS) && (ACE_HAS_MONITOR_POINTS == 1) + ACE::Monitor_Control::Size_Monitor *monitor_; +#endif /* ACE_HAS_MONITOR_POINTS==1 */ + +private: + + ACE_CDR::Boolean read_1 (ACE_CDR::Octet *x); + ACE_CDR::Boolean read_2 (ACE_CDR::UShort *x); + ACE_CDR::Boolean read_4 (ACE_CDR::ULong *x); + ACE_CDR::Boolean read_8 (ACE_CDR::ULongLong *x); + ACE_CDR::Boolean read_16 (ACE_CDR::LongDouble *x); + + // Several types can be read using the same routines, since TAO + // tries to use native types with known size for each CORBA type. + // We could use void* or char* to make the interface more + // consistent, but using native types let us exploit the strict + // alignment requirements of CDR streams and implement the + // operations using asignment. + + /** + * Read an array of @a length elements, each of @a size bytes and the + * start aligned at a multiple of . The elements are assumed + * to be packed with the right alignment restrictions. It is mostly + * designed for buffers of the basic types. + * + * This operation uses ; as explained above it is expected + * that using assignment is faster that for one element, + * but for several elements should be more efficient, it + * could be interesting to find the break even point and optimize + * for that case, but that would be too platform dependent. + */ + ACE_CDR::Boolean read_array (void* x, + size_t size, + size_t align, + ACE_CDR::ULong length); + + /** + * On those occasions when the native codeset for wchar is smaller than + * the size of a wchar_t, such as using UTF-16 with a 4-byte wchar_t, a + * special form of reading the array is needed. Actually, this should be + * a default translator. + */ + ACE_CDR::Boolean read_wchar_array_i (ACE_CDR::WChar * x, + ACE_CDR::ULong length); + + /// Move the rd_ptr ahead by @a offset bytes. + void rd_ptr (size_t offset); + + /// Points to the continuation field of the current message block. + char* end (void); +}; + +// **************************************************************** + +/** + * @class ACE_Char_Codeset_Translator + * + * @brief Codeset translation routines common to both Output and Input + * CDR streams. + * + * This class is a base class for defining codeset translation + * routines to handle the character set translations required by + * both CDR Input streams and CDR Output streams. + * + * Translators are reference counted. This allows for stateful as well + * as stateless translators. Stateless translators will be allocated + * once whereas CDR Streams own their own copy of a stateful translator. + */ +class ACE_Export ACE_Char_Codeset_Translator +{ +public: + virtual ~ACE_Char_Codeset_Translator (); + + /// Read a single character from the stream, converting from the + /// stream codeset to the native codeset + virtual ACE_CDR::Boolean read_char (ACE_InputCDR&, + ACE_CDR::Char&) = 0; + + /// Read a string from the stream, including the length, converting + /// the characters from the stream codeset to the native codeset + virtual ACE_CDR::Boolean read_string (ACE_InputCDR&, + ACE_CDR::Char *&) = 0; + + /// Read an array of characters from the stream, converting the + /// characters from the stream codeset to the native codeset. + virtual ACE_CDR::Boolean read_char_array (ACE_InputCDR&, + ACE_CDR::Char*, + ACE_CDR::ULong) = 0; + + /// Write a single character to the stream, converting from the + /// native codeset to the stream codeset + virtual ACE_CDR::Boolean write_char (ACE_OutputCDR&, + ACE_CDR::Char) = 0; + + /// Write a string to the stream, including the length, converting + /// from the native codeset to the stream codeset + virtual ACE_CDR::Boolean write_string (ACE_OutputCDR&, + ACE_CDR::ULong, + const ACE_CDR::Char*) = 0; + + /// Write an array of characters to the stream, converting from the + /// native codeset to the stream codeset + virtual ACE_CDR::Boolean write_char_array (ACE_OutputCDR&, + const ACE_CDR::Char*, + ACE_CDR::ULong) = 0; + + virtual ACE_CDR::ULong ncs () = 0; + virtual ACE_CDR::ULong tcs () = 0; +protected: + /// Children have access to low-level routines because they cannot + /// use read_char or something similar (it would recurse). + ACE_CDR::Boolean read_1 (ACE_InputCDR& input, + ACE_CDR::Octet *x); + ACE_CDR::Boolean write_1 (ACE_OutputCDR& output, + const ACE_CDR::Octet *x); + + /// Efficiently read @a length elements of size @a size each from + /// into ; the data must be aligned to . + ACE_CDR::Boolean read_array (ACE_InputCDR& input, + void* x, + size_t size, + size_t align, + ACE_CDR::ULong length); + + /** + * Efficiently write @a length elements of size @a size from into + * . Before inserting the elements enough padding is added + * to ensure that the elements will be aligned to in the + * stream. + */ + ACE_CDR::Boolean write_array (ACE_OutputCDR& output, + const void *x, + size_t size, + size_t align, + ACE_CDR::ULong length); + + /** + * Exposes the stream implementation of , this is useful in + * many cases to minimize memory allocations during marshaling. + * On success @a buf will contain a contiguous area in the CDR stream + * that can hold @a size bytes aligned to . + * Results + */ + int adjust (ACE_OutputCDR& out, + size_t size, + size_t align, + char *&buf); + + /// Used by derived classes to set errors in the CDR stream. + void good_bit (ACE_OutputCDR& out, bool bit); + + /// Obtain the CDR Stream's major & minor version values. + ACE_CDR::Octet major_version (ACE_InputCDR& input); + ACE_CDR::Octet minor_version (ACE_InputCDR& input); + ACE_CDR::Octet major_version (ACE_OutputCDR& output); + ACE_CDR::Octet minor_version (ACE_OutputCDR& output); +}; + +// **************************************************************** + +/** + * @class ACE_WChar_Codeset_Translator + * + * @brief Codeset translation routines common to both Output and Input + * CDR streams. + * + * This class is a base class for defining codeset translation + * routines to handle the character set translations required by + * both CDR Input streams and CDR Output streams. + */ +class ACE_Export ACE_WChar_Codeset_Translator +{ +public: + virtual ~ACE_WChar_Codeset_Translator (); + + virtual ACE_CDR::Boolean read_wchar (ACE_InputCDR&, + ACE_CDR::WChar&) = 0; + virtual ACE_CDR::Boolean read_wstring (ACE_InputCDR&, + ACE_CDR::WChar *&) = 0; + virtual ACE_CDR::Boolean read_wchar_array (ACE_InputCDR&, + ACE_CDR::WChar*, + ACE_CDR::ULong) = 0; + virtual ACE_CDR::Boolean write_wchar (ACE_OutputCDR&, + ACE_CDR::WChar) = 0; + virtual ACE_CDR::Boolean write_wstring (ACE_OutputCDR&, + ACE_CDR::ULong, + const ACE_CDR::WChar*) = 0; + virtual ACE_CDR::Boolean write_wchar_array (ACE_OutputCDR&, + const ACE_CDR::WChar*, + ACE_CDR::ULong) = 0; + + virtual ACE_CDR::ULong ncs () = 0; + virtual ACE_CDR::ULong tcs () = 0; +protected: + /// Children have access to low-level routines because they cannot + /// use read_char or something similar (it would recurse). + ACE_CDR::Boolean read_1 (ACE_InputCDR& input, + ACE_CDR::Octet *x); + ACE_CDR::Boolean read_2 (ACE_InputCDR& input, + ACE_CDR::UShort *x); + ACE_CDR::Boolean read_4 (ACE_InputCDR& input, + ACE_CDR::ULong *x); + ACE_CDR::Boolean write_1 (ACE_OutputCDR& output, + const ACE_CDR::Octet *x); + ACE_CDR::Boolean write_2 (ACE_OutputCDR& output, + const ACE_CDR::UShort *x); + ACE_CDR::Boolean write_4 (ACE_OutputCDR& output, + const ACE_CDR::ULong *x); + + /// Efficiently read @a length elements of size @a size each from + /// into ; the data must be aligned to . + ACE_CDR::Boolean read_array (ACE_InputCDR& input, + void* x, + size_t size, + size_t align, + ACE_CDR::ULong length); + + /** + * Efficiently write @a length elements of size @a size from into + * . Before inserting the elements enough padding is added + * to ensure that the elements will be aligned to in the + * stream. + */ + ACE_CDR::Boolean write_array (ACE_OutputCDR& output, + const void *x, + size_t size, + size_t align, + ACE_CDR::ULong length); + + /** + * Exposes the stream implementation of , this is useful in + * many cases to minimize memory allocations during marshaling. + * On success @a buf will contain a contiguous area in the CDR stream + * that can hold @a size bytes aligned to . + * Results + */ + int adjust (ACE_OutputCDR& out, + size_t size, + size_t align, + char *&buf); + + /// Used by derived classes to set errors in the CDR stream. + void good_bit (ACE_OutputCDR& out, bool bit); + + /// Obtain the CDR Stream's major & minor version values. + ACE_CDR::Octet major_version (ACE_InputCDR& input); + ACE_CDR::Octet minor_version (ACE_InputCDR& input); + ACE_CDR::Octet major_version (ACE_OutputCDR& output); + ACE_CDR::Octet minor_version (ACE_OutputCDR& output); + +}; + +// @@ These operators should not be inlined since they force SString.h +// to be included in this header. +extern ACE_Export ACE_CDR::Boolean operator<< (ACE_OutputCDR &os, + const ACE_CString &x); + +extern ACE_Export ACE_CDR::Boolean operator>> (ACE_InputCDR &is, + ACE_CString &x); + + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +# include "ace/CDR_Stream.inl" +#else /* __ACE_INLINE__ */ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +// Not used by CORBA or TAO +extern ACE_Export ACE_CDR::Boolean operator<< (ACE_OutputCDR &os, + ACE_CDR::Char x); +// CDR output operators for primitive types + +extern ACE_Export ACE_CDR::Boolean operator<< (ACE_OutputCDR &os, + ACE_CDR::Short x); +extern ACE_Export ACE_CDR::Boolean operator<< (ACE_OutputCDR &os, + ACE_CDR::UShort x); +extern ACE_Export ACE_CDR::Boolean operator<< (ACE_OutputCDR &os, + ACE_CDR::Long x); +extern ACE_Export ACE_CDR::Boolean operator<< (ACE_OutputCDR &os, + ACE_CDR::ULong x); +extern ACE_Export ACE_CDR::Boolean operator<< (ACE_OutputCDR &os, + ACE_CDR::LongLong x); +extern ACE_Export ACE_CDR::Boolean operator<< (ACE_OutputCDR &os, + ACE_CDR::ULongLong x); +extern ACE_Export ACE_CDR::Boolean operator<< (ACE_OutputCDR& os, + ACE_CDR::LongDouble x); +extern ACE_Export ACE_CDR::Boolean operator<< (ACE_OutputCDR &os, + ACE_CDR::Float x); +extern ACE_Export ACE_CDR::Boolean operator<< (ACE_OutputCDR &os, + ACE_CDR::Double x); + +// CDR output operator from helper classes + +extern ACE_Export ACE_CDR::Boolean operator<< (ACE_OutputCDR &os, + ACE_OutputCDR::from_boolean x); +extern ACE_Export ACE_CDR::Boolean operator<< (ACE_OutputCDR &os, + ACE_OutputCDR::from_char x); +extern ACE_Export ACE_CDR::Boolean operator<< (ACE_OutputCDR &os, + ACE_OutputCDR::from_wchar x); +extern ACE_Export ACE_CDR::Boolean operator<< (ACE_OutputCDR &os, + ACE_OutputCDR::from_octet x); +extern ACE_Export ACE_CDR::Boolean operator<< (ACE_OutputCDR &os, + ACE_OutputCDR::from_string x); +extern ACE_Export ACE_CDR::Boolean operator<< (ACE_OutputCDR &os, + ACE_OutputCDR::from_wstring x); +extern ACE_Export ACE_CDR::Boolean operator<< (ACE_OutputCDR &os, + const ACE_CDR::Char* x); +extern ACE_Export ACE_CDR::Boolean operator<< (ACE_OutputCDR &os, + const ACE_CDR::WChar* x); + +// Not used by CORBA or TAO +extern ACE_Export ACE_CDR::Boolean operator>> (ACE_InputCDR &is, + ACE_CDR::Char &x); +// CDR input operators for primitive types + +extern ACE_Export ACE_CDR::Boolean operator>> (ACE_InputCDR &is, + ACE_CDR::Short &x); +extern ACE_Export ACE_CDR::Boolean operator>> (ACE_InputCDR &is, + ACE_CDR::UShort &x); +extern ACE_Export ACE_CDR::Boolean operator>> (ACE_InputCDR &is, + ACE_CDR::Long &x); +extern ACE_Export ACE_CDR::Boolean operator>> (ACE_InputCDR &is, + ACE_CDR::ULong &x); +extern ACE_Export ACE_CDR::Boolean operator>> (ACE_InputCDR &is, + ACE_CDR::LongLong &x); +extern ACE_Export ACE_CDR::Boolean operator>> (ACE_InputCDR &is, + ACE_CDR::ULongLong &x); +extern ACE_Export ACE_CDR::Boolean operator>> (ACE_InputCDR &is, + ACE_CDR::LongDouble &x); +extern ACE_Export ACE_CDR::Boolean operator>> (ACE_InputCDR &is, + ACE_CDR::Float &x); +extern ACE_Export ACE_CDR::Boolean operator>> (ACE_InputCDR &is, + ACE_CDR::Double &x); + +// CDR input operator from helper classes + +extern ACE_Export ACE_CDR::Boolean operator>> (ACE_InputCDR &is, + ACE_InputCDR::to_boolean x); +extern ACE_Export ACE_CDR::Boolean operator>> (ACE_InputCDR &is, + ACE_InputCDR::to_char x); +extern ACE_Export ACE_CDR::Boolean operator>> (ACE_InputCDR &is, + ACE_InputCDR::to_wchar x); +extern ACE_Export ACE_CDR::Boolean operator>> (ACE_InputCDR &is, + ACE_InputCDR::to_octet x); +extern ACE_Export ACE_CDR::Boolean operator>> (ACE_InputCDR &is, + ACE_InputCDR::to_string x); +extern ACE_Export ACE_CDR::Boolean operator>> (ACE_InputCDR &is, + ACE_InputCDR::to_wstring x); +extern ACE_Export ACE_CDR::Boolean operator>> (ACE_InputCDR &is, + ACE_CDR::Char*& x); +extern ACE_Export ACE_CDR::Boolean operator>> (ACE_InputCDR &is, + ACE_CDR::WChar*& x); + +ACE_END_VERSIONED_NAMESPACE_DECL + +#endif /* __ACE_INLINE__ */ + +#if defined (GEN_OSTREAM_OPS) + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +// ostream insertion operators for debugging code generated from IDL. All +// but these below are either in generated code itself or are unambiguous +// primitive types. + +ACE_Export std::ostream& operator<< (std::ostream &os, + ACE_OutputCDR::from_boolean x); + +ACE_Export std::ostream& operator<< (std::ostream &os, + ACE_OutputCDR::from_char x); + +ACE_Export std::ostream& operator<< (std::ostream &os, + ACE_OutputCDR::from_wchar x); + +ACE_Export std::ostream& operator<< (std::ostream &os, + ACE_OutputCDR::from_octet x); + +ACE_END_VERSIONED_NAMESPACE_DECL + +#endif /* GEN_OSTREAM_OPS */ + +#include /**/ "ace/post.h" + +#endif /* ACE_CDR_STREAM_H */ diff --git a/dep/ACE_wrappers/ace/CDR_Stream.inl b/dep/ACE_wrappers/ace/CDR_Stream.inl new file mode 100644 index 00000000000..9fef2d8fab0 --- /dev/null +++ b/dep/ACE_wrappers/ace/CDR_Stream.inl @@ -0,0 +1,1728 @@ +// -*- C++ -*- +// +// $Id: CDR_Stream.inl 82350 2008-07-22 07:36:47Z johnnyw $ + +#include "ace/OS_NS_string.h" +#include "ace/OS_Memory.h" + +// **************************************************************** + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +// implementing the special types +ACE_INLINE +ACE_OutputCDR::from_boolean::from_boolean (ACE_CDR::Boolean b) + : val_ (b) +{ +} + +ACE_INLINE +ACE_InputCDR::to_boolean::to_boolean (ACE_CDR::Boolean &b) + : ref_ (b) +{ +} + +ACE_INLINE +ACE_OutputCDR::from_octet::from_octet (ACE_CDR::Octet o) + : val_ (o) +{ +} + +ACE_INLINE +ACE_InputCDR::to_octet::to_octet (ACE_CDR::Octet &o) + : ref_ (o) +{ +} + +ACE_INLINE +ACE_OutputCDR::from_char::from_char (ACE_CDR::Char c) + : val_ (c) +{ +} + +ACE_INLINE +ACE_InputCDR::to_char::to_char (ACE_CDR::Char &c) + : ref_ (c) +{ +} + +ACE_INLINE +ACE_OutputCDR::from_wchar::from_wchar (ACE_CDR::WChar wc) + : val_ (wc) +{ +} + +ACE_INLINE +ACE_InputCDR::to_wchar::to_wchar (ACE_CDR::WChar &wc) + : ref_ (wc) +{ +} + +ACE_INLINE +ACE_OutputCDR::from_string::from_string (ACE_CDR::Char *s, + ACE_CDR::ULong b, + ACE_CDR::Boolean nocopy) + : val_ (s), + bound_ (b), + nocopy_ (nocopy) +{ +} + +ACE_INLINE +ACE_OutputCDR::from_string::from_string (const ACE_CDR::Char *s, + ACE_CDR::ULong b, + ACE_CDR::Boolean nocopy) + : val_ (const_cast (s)), + bound_ (b), + nocopy_ (nocopy) +{ +} + +ACE_INLINE +ACE_InputCDR::to_string::to_string (ACE_CDR::Char *&s, + ACE_CDR::ULong b) + : val_ (const_cast (s)), + bound_ (b) +{ +} + +ACE_INLINE +ACE_InputCDR::to_string::to_string (const ACE_CDR::Char *&s, + ACE_CDR::ULong b) + : val_ (s), + bound_ (b) +{ +} + +ACE_INLINE +ACE_OutputCDR::from_wstring::from_wstring (ACE_CDR::WChar *ws, + ACE_CDR::ULong b, + ACE_CDR::Boolean nocopy) + : val_ (ws), + bound_ (b), + nocopy_ (nocopy) +{ +} + +ACE_INLINE +ACE_OutputCDR::from_wstring::from_wstring (const ACE_CDR::WChar *ws, + ACE_CDR::ULong b, + ACE_CDR::Boolean nocopy) + : val_ (const_cast (ws)), + bound_ (b), + nocopy_ (nocopy) +{ +} + +ACE_INLINE +ACE_InputCDR::to_wstring::to_wstring (ACE_CDR::WChar *&ws, + ACE_CDR::ULong b) + : val_ (const_cast (ws)), + bound_ (b) +{ +} + +ACE_INLINE +ACE_InputCDR::to_wstring::to_wstring (const ACE_CDR::WChar *&ws, + ACE_CDR::ULong b) + : val_ (ws), + bound_ (b) +{ +} + +ACE_INLINE +ACE_InputCDR::Transfer_Contents::Transfer_Contents (ACE_InputCDR &rhs) + : rhs_ (rhs) +{ +} + +// **************************************************************** + +ACE_INLINE +ACE_OutputCDR::~ACE_OutputCDR (void) +{ + if (this->start_.cont () != 0) + { + ACE_Message_Block::release (this->start_.cont ()); + this->start_.cont (0); + } + + this->current_ = 0; + +#if defined (ACE_HAS_MONITOR_POINTS) && (ACE_HAS_MONITOR_POINTS == 1) + this->monitor_->remove_ref (); +#endif /* ACE_HAS_MONITOR_POINTS==1 */ +} + +ACE_INLINE void +ACE_OutputCDR::reset (void) +{ + this->current_ = &this->start_; + this->current_is_writable_ = true; + ACE_CDR::mb_align (&this->start_); + +#if !defined (ACE_LACKS_CDR_ALIGNMENT) + this->current_alignment_ = 0; +#endif /* ACE_LACKS_CDR_ALIGNMENT */ + + // It is tempting not to remove the memory, but we need to do so to + // release any potential user buffers chained in the continuation + // field. + + ACE_Message_Block * const cont = this->start_.cont (); + if (cont) + { + ACE_Message_Block::release (cont); + this->start_.cont (0); + } + +#if defined (ACE_HAS_MONITOR_POINTS) && (ACE_HAS_MONITOR_POINTS == 1) + this->monitor_->receive (this->start_.total_size ()); +#endif /* ACE_HAS_MONITOR_POINTS==1 */ +} + +// Encode the CDR stream. + +ACE_INLINE ACE_CDR::Boolean +ACE_OutputCDR::write_octet (ACE_CDR::Octet x) +{ + return this->write_1 (&x); +} + +ACE_INLINE ACE_CDR::Boolean +ACE_OutputCDR::write_boolean (ACE_CDR::Boolean x) +{ + return + static_cast ( + this->write_octet ( + x + ? static_cast (1) + : static_cast (0))); +} + +ACE_INLINE ACE_CDR::Boolean +ACE_OutputCDR::write_char (ACE_CDR::Char x) +{ + if (this->char_translator_ == 0) + { + ACE_CDR::Octet temp = static_cast (x); + return this->write_1 (&temp); + } + return this->char_translator_->write_char (*this, x); +} + +ACE_INLINE ACE_CDR::Boolean +ACE_OutputCDR::write_short (ACE_CDR::Short x) +{ + ACE_CDR::UShort temp = static_cast (x); + return this->write_2 (&temp); +} + +ACE_INLINE ACE_CDR::Boolean +ACE_OutputCDR::write_ushort (ACE_CDR::UShort x) +{ + return this->write_2 (&x); +} + +ACE_INLINE ACE_CDR::Boolean +ACE_OutputCDR::write_long (ACE_CDR::Long x) +{ + ACE_CDR::ULong temp = static_cast (x); + return this->write_4 (&temp); +} + +ACE_INLINE ACE_CDR::Boolean +ACE_OutputCDR::write_ulong (ACE_CDR::ULong x) +{ + return this->write_4 (&x); +} + +ACE_INLINE ACE_CDR::Boolean +ACE_OutputCDR::write_longlong (const ACE_CDR::LongLong &x) +{ + void const * const temp = &x; + return this->write_8 (reinterpret_cast (temp)); +} + +ACE_INLINE ACE_CDR::Boolean +ACE_OutputCDR::write_ulonglong (const ACE_CDR::ULongLong &x) +{ + return this->write_8 (&x); +} + +ACE_INLINE ACE_CDR::Boolean +ACE_OutputCDR::write_float (ACE_CDR::Float x) +{ + void const * const temp = &x; + return this->write_4 (reinterpret_cast (temp)); +} + +ACE_INLINE ACE_CDR::Boolean +ACE_OutputCDR::write_double (const ACE_CDR::Double &x) +{ + void const * const temp = &x; + return this->write_8 (reinterpret_cast (temp)); +} + +ACE_INLINE ACE_CDR::Boolean +ACE_OutputCDR::write_longdouble (const ACE_CDR::LongDouble &x) +{ + return this->write_16 (&x); +} + +ACE_INLINE ACE_CDR::Boolean +ACE_OutputCDR::write_string (const ACE_CDR::Char *x) +{ + if (x) + { + ACE_CDR::ULong const len = + static_cast (ACE_OS::strlen (x)); + return this->write_string (len, x); + } + + return this->write_string (0, 0); +} + +ACE_INLINE ACE_CDR::Boolean +ACE_OutputCDR::write_wstring (const ACE_CDR::WChar *x) +{ + if (x) + { + ACE_CDR::ULong const len = + static_cast (ACE_OS::strlen (x)); + return this->write_wstring (len, x); + } + + return this->write_wstring (0, 0); +} + +ACE_INLINE ACE_CDR::Boolean +ACE_OutputCDR::write_char_array (const ACE_CDR::Char *x, + ACE_CDR::ULong length) +{ + if (this->char_translator_ == 0) + return this->write_array (x, + ACE_CDR::OCTET_SIZE, + ACE_CDR::OCTET_ALIGN, + length); + return this->char_translator_->write_char_array (*this, x, length); +} + +ACE_INLINE ACE_CDR::Boolean +ACE_OutputCDR::write_wchar_array (const ACE_CDR::WChar* x, + ACE_CDR::ULong length) +{ + if (this->wchar_translator_) + return this->wchar_translator_->write_wchar_array (*this, x, length); + + if (ACE_OutputCDR::wchar_maxbytes_ == 0) + { + errno = EACCES; + return (ACE_CDR::Boolean) (this->good_bit_ = false); + } + + if (ACE_OutputCDR::wchar_maxbytes_ == sizeof (ACE_CDR::WChar)) + return this->write_array (x, + sizeof (ACE_CDR::WChar), + sizeof (ACE_CDR::WChar) == 2 + ? ACE_CDR::SHORT_ALIGN + : ACE_CDR::LONG_ALIGN, + length); + return this->write_wchar_array_i (x,length); +} + +ACE_INLINE ACE_CDR::Boolean +ACE_OutputCDR::write_octet_array (const ACE_CDR::Octet* x, + ACE_CDR::ULong length) +{ + return this->write_array (x, + ACE_CDR::OCTET_SIZE, + ACE_CDR::OCTET_ALIGN, + length); +} + +ACE_INLINE ACE_CDR::Boolean +ACE_OutputCDR::write_short_array (const ACE_CDR::Short *x, + ACE_CDR::ULong length) +{ + return this->write_array (x, + ACE_CDR::SHORT_SIZE, + ACE_CDR::SHORT_ALIGN, + length); +} + +ACE_INLINE ACE_CDR::Boolean +ACE_OutputCDR::write_ushort_array (const ACE_CDR::UShort *x, + ACE_CDR::ULong length) +{ + return this->write_array (x, + ACE_CDR::SHORT_SIZE, + ACE_CDR::SHORT_ALIGN, + length); +} + +ACE_INLINE ACE_CDR::Boolean +ACE_OutputCDR::write_long_array (const ACE_CDR::Long *x, + ACE_CDR::ULong length) +{ + return this->write_array (x, + ACE_CDR::LONG_SIZE, + ACE_CDR::LONG_ALIGN, + length); +} + +ACE_INLINE ACE_CDR::Boolean +ACE_OutputCDR::write_ulong_array (const ACE_CDR::ULong *x, + ACE_CDR::ULong length) +{ + return this->write_array (x, + ACE_CDR::LONG_SIZE, + ACE_CDR::LONG_ALIGN, + length); +} + +ACE_INLINE ACE_CDR::Boolean +ACE_OutputCDR::write_longlong_array (const ACE_CDR::LongLong *x, + ACE_CDR::ULong length) +{ + return this->write_array (x, + ACE_CDR::LONGLONG_SIZE, + ACE_CDR::LONGLONG_ALIGN, + length); +} + +ACE_INLINE ACE_CDR::Boolean +ACE_OutputCDR::write_ulonglong_array (const ACE_CDR::ULongLong *x, + ACE_CDR::ULong length) +{ + return this->write_array (x, + ACE_CDR::LONGLONG_SIZE, + ACE_CDR::LONGLONG_ALIGN, + length); +} + +ACE_INLINE ACE_CDR::Boolean +ACE_OutputCDR::write_float_array (const ACE_CDR::Float *x, + ACE_CDR::ULong length) +{ + return this->write_array (x, + ACE_CDR::LONG_SIZE, + ACE_CDR::LONG_ALIGN, + length); +} + + +ACE_INLINE ACE_CDR::Boolean +ACE_OutputCDR::write_double_array (const ACE_CDR::Double *x, + ACE_CDR::ULong length) +{ + return this->write_array (x, + ACE_CDR::LONGLONG_SIZE, + ACE_CDR::LONGLONG_ALIGN, + length); +} + +ACE_INLINE ACE_CDR::Boolean +ACE_OutputCDR::write_longdouble_array (const ACE_CDR::LongDouble* x, + ACE_CDR::ULong length) +{ + return this->write_array (x, + ACE_CDR::LONGDOUBLE_SIZE, + ACE_CDR::LONGDOUBLE_ALIGN, + length); +} + +ACE_INLINE bool +ACE_OutputCDR::good_bit (void) const +{ + return this->good_bit_; +} + +ACE_INLINE int +ACE_OutputCDR::adjust (size_t size, + size_t align, + char*& buf) +{ + if (!this->current_is_writable_) + return this->grow_and_adjust (size, align, buf); + +#if !defined (ACE_LACKS_CDR_ALIGNMENT) + size_t const offset = + ACE_align_binary (this->current_alignment_, align) + - this->current_alignment_; + + buf = this->current_->wr_ptr () + offset; +#else + buf = this->current_->wr_ptr (); +#endif /* ACE_LACKS_CDR_ALIGNMENT */ + + char * const end = buf + size; + + if (end <= this->current_->end () && + end >= buf) + { +#if !defined (ACE_LACKS_CDR_ALIGNMENT) + this->current_alignment_ += offset + size; +#endif /* ACE_LACKS_CDR_ALIGNMENT */ + this->current_->wr_ptr (end); + +#if defined (ACE_HAS_MONITOR_POINTS) && (ACE_HAS_MONITOR_POINTS == 1) + this->monitor_->receive (this->total_length ()); +#endif /* ACE_HAS_MONITOR_POINTS==1 */ + + return 0; + } + + return this->grow_and_adjust (size, align, buf); +} + +ACE_INLINE int +ACE_OutputCDR::adjust (size_t size, char*& buf) +{ + return this->adjust (size, size, buf); +} + +ACE_INLINE void +ACE_OutputCDR::set_version (ACE_CDR::Octet major, ACE_CDR::Octet minor) +{ + this->major_version_ = major; + this->minor_version_ = minor; +} + +ACE_INLINE void +ACE_OutputCDR::get_version (ACE_CDR::Octet &major, ACE_CDR::Octet &minor) +{ + major = this->major_version_; + minor = this->minor_version_; +} + + +ACE_INLINE const ACE_Message_Block* +ACE_OutputCDR::begin (void) const +{ + return &this->start_; +} + +ACE_INLINE const ACE_Message_Block* +ACE_OutputCDR::end (void) const +{ + return this->current_->cont (); +} + +ACE_INLINE const ACE_Message_Block* +ACE_OutputCDR::current (void) const +{ + return this->current_; +} + +ACE_INLINE size_t +ACE_OutputCDR::total_length (void) const +{ + return ACE_CDR::total_length (this->begin (), this->end ()); +} + +ACE_INLINE const char* +ACE_OutputCDR::buffer (void) const +{ + return this->start_.rd_ptr (); +} + +ACE_INLINE size_t +ACE_OutputCDR::length (void) const +{ + return this->start_.length (); +} + +ACE_INLINE bool +ACE_OutputCDR::do_byte_swap (void) const +{ + return this->do_byte_swap_; +} + +ACE_INLINE int +ACE_OutputCDR::byte_order (void) const +{ + if (this->do_byte_swap ()) + return !ACE_CDR_BYTE_ORDER; + else + return ACE_CDR_BYTE_ORDER; +} + +ACE_INLINE void +ACE_OutputCDR::reset_byte_order (int byte_order) +{ + this->do_byte_swap_ = (byte_order != ACE_CDR_BYTE_ORDER); +} + +ACE_INLINE size_t +ACE_OutputCDR::current_alignment (void) const +{ +#if !defined (ACE_LACKS_CDR_ALIGNMENT) + return this->current_alignment_; +#else + // Default value set to 0 + return 0; +#endif /* ACE_LACKS_CDR_ALIGNMENT */ +} + +ACE_INLINE void +ACE_OutputCDR::current_alignment (size_t current_alignment) +{ +#if !defined (ACE_LACKS_CDR_ALIGNMENT) + this->current_alignment_ = current_alignment; +#else + ACE_UNUSED_ARG (current_alignment); + return 0; +#endif /* ACE_LACKS_CDR_ALIGNMENT */ +} + +ACE_INLINE int +ACE_OutputCDR::align_write_ptr (size_t alignment) +{ +#if !defined (ACE_LACKS_CDR_ALIGNMENT) + char *dummy; + return this->adjust (0, alignment, dummy); +#else + ACE_UNUSED_ARG (alignment); + // A return value of -1 from this function is used + // to indicate failure, returning 0 + return 0; +#endif /* ACE_LACKS_CDR_ALIGNMENT */ +} + +ACE_INLINE ACE_Char_Codeset_Translator * +ACE_OutputCDR::char_translator (void) const +{ + return this->char_translator_; +} + +ACE_INLINE ACE_WChar_Codeset_Translator * +ACE_OutputCDR::wchar_translator (void) const +{ + return this->wchar_translator_; +} + +ACE_INLINE void +ACE_OutputCDR::char_translator (ACE_Char_Codeset_Translator * ctran) +{ + this->char_translator_ = ctran; +} + +ACE_INLINE void +ACE_OutputCDR::wchar_translator (ACE_WChar_Codeset_Translator * wctran) +{ + this->wchar_translator_ = wctran; +} + +// **************************************************************** + +ACE_INLINE +ACE_InputCDR::~ACE_InputCDR (void) +{ +#if defined (ACE_HAS_MONITOR_POINTS) && (ACE_HAS_MONITOR_POINTS == 1) + this->monitor_->remove_ref (); +#endif /* ACE_HAS_MONITOR_POINTS==1 */ +} + +ACE_INLINE ACE_CDR::Boolean +ACE_InputCDR::read_octet (ACE_CDR::Octet& x) +{ + return this->read_1 (&x); +} + +ACE_INLINE ACE_CDR::Boolean +ACE_InputCDR::read_boolean (ACE_CDR::Boolean& x) +{ + ACE_CDR::Octet tmp = 0; + (void) this->read_octet (tmp); + x = tmp ? true : false; + return (ACE_CDR::Boolean) this->good_bit_; +} + +ACE_INLINE ACE_CDR::Boolean +ACE_InputCDR::read_char (ACE_CDR::Char &x) +{ + if (this->char_translator_ == 0) + { + void *temp = &x; + return this->read_1 (reinterpret_cast (temp)); + } + return this->char_translator_->read_char (*this, x); +} + + +ACE_INLINE ACE_CDR::Boolean +ACE_InputCDR::read_short (ACE_CDR::Short &x) +{ + void *temp = &x; + return this->read_2 (reinterpret_cast (temp)); +} + +ACE_INLINE ACE_CDR::Boolean +ACE_InputCDR::read_ushort (ACE_CDR::UShort &x) +{ + return this->read_2 (&x); +} + + +ACE_INLINE ACE_CDR::Boolean +ACE_InputCDR::read_long (ACE_CDR::Long &x) +{ + void *temp = &x; + return this->read_4 (reinterpret_cast (temp)); +} + + +ACE_INLINE ACE_CDR::Boolean +ACE_InputCDR::read_ulong (ACE_CDR::ULong &x) +{ + return this->read_4 (&x); +} + + +ACE_INLINE ACE_CDR::Boolean +ACE_InputCDR::read_longlong (ACE_CDR::LongLong &x) +{ + void *temp = &x; + return this->read_8 (reinterpret_cast (temp)); +} + +ACE_INLINE ACE_CDR::Boolean +ACE_InputCDR::read_ulonglong (ACE_CDR::ULongLong &x) +{ + return this->read_8 (&x); +} + +ACE_INLINE ACE_CDR::Boolean +ACE_InputCDR::read_float (ACE_CDR::Float &x) +{ + void *temp = &x; + return this->read_4 (reinterpret_cast (temp)); +} + +ACE_INLINE ACE_CDR::Boolean +ACE_InputCDR::read_double (ACE_CDR::Double &x) +{ + void *temp = &x; + return this->read_8 (reinterpret_cast (temp)); +} + +ACE_INLINE ACE_CDR::Boolean +ACE_InputCDR::read_longdouble (ACE_CDR::LongDouble &x) +{ + return this->read_16 (&x); +} + +ACE_INLINE size_t +ACE_InputCDR::length (void) const +{ + return this->start_.length (); +} + +ACE_INLINE ACE_CDR::Boolean +ACE_InputCDR::read_char_array (ACE_CDR::Char* x, + ACE_CDR::ULong length) +{ + // Make sure the length of the array isn't greater than the length of + // the stream. + if (length > this->length ()) + { + this->good_bit_ = false; + return false; + } + + if (this->char_translator_ == 0) + return this->read_array (x, + ACE_CDR::OCTET_SIZE, + ACE_CDR::OCTET_ALIGN, + length); + return this->char_translator_->read_char_array (*this, x, length); +} + +ACE_INLINE ACE_CDR::Boolean +ACE_InputCDR::read_wchar_array (ACE_CDR::WChar* x, + ACE_CDR::ULong length) +{ + // Make sure the length of the array isn't greater than the length of + // the stream. + if (length * ACE_OutputCDR::wchar_maxbytes_ > this->length ()) + { + this->good_bit_ = false; + return false; + } + + if (this->wchar_translator_ != 0) + return this->wchar_translator_->read_wchar_array (*this, x, length); + if (ACE_OutputCDR::wchar_maxbytes_ != sizeof (ACE_CDR::WChar)) + return this->read_wchar_array_i (x, length); + return this->read_array (x, + sizeof (ACE_CDR::WChar), + sizeof (ACE_CDR::WChar) == 2 + ? ACE_CDR::SHORT_ALIGN + : ACE_CDR::LONG_ALIGN, + length); +} + +ACE_INLINE ACE_CDR::Boolean +ACE_InputCDR::read_octet_array (ACE_CDR::Octet* x, + ACE_CDR::ULong length) +{ + // Make sure the length of the array isn't greater than the length of + // the stream. + if (length * ACE_CDR::OCTET_SIZE > this->length ()) + { + this->good_bit_ = false; + return false; + } + + return this->read_array (x, + ACE_CDR::OCTET_SIZE, + ACE_CDR::OCTET_ALIGN, + length); +} + +ACE_INLINE ACE_CDR::Boolean +ACE_InputCDR::read_short_array (ACE_CDR::Short *x, + ACE_CDR::ULong length) +{ + // Make sure the length of the array isn't greater than the length of + // the stream. + if (length * ACE_CDR::SHORT_SIZE > this->length ()) + { + this->good_bit_ = false; + return false; + } + + return this->read_array (x, + ACE_CDR::SHORT_SIZE, + ACE_CDR::SHORT_ALIGN, + length); +} + +ACE_INLINE ACE_CDR::Boolean +ACE_InputCDR::read_ushort_array (ACE_CDR::UShort *x, + ACE_CDR::ULong length) +{ + // Make sure the length of the array isn't greater than the length of + // the stream. + if (length * ACE_CDR::SHORT_SIZE > this->length ()) + { + this->good_bit_ = false; + return false; + } + + return this->read_array (x, + ACE_CDR::SHORT_SIZE, + ACE_CDR::SHORT_ALIGN, + length); +} + +ACE_INLINE ACE_CDR::Boolean +ACE_InputCDR::read_long_array (ACE_CDR::Long *x, + ACE_CDR::ULong length) +{ + // Make sure the length of the array isn't greater than the length of + // the stream. + if (length * ACE_CDR::LONG_SIZE > this->length ()) + { + this->good_bit_ = false; + return false; + } + + return this->read_array (x, + ACE_CDR::LONG_SIZE, + ACE_CDR::LONG_ALIGN, + length); +} + +ACE_INLINE ACE_CDR::Boolean +ACE_InputCDR::read_ulong_array (ACE_CDR::ULong *x, + ACE_CDR::ULong length) +{ + // Make sure the length of the array isn't greater than the length of + // the stream. + if (length * ACE_CDR::LONG_SIZE > this->length ()) + { + this->good_bit_ = false; + return false; + } + + return this->read_array (x, + ACE_CDR::LONG_SIZE, + ACE_CDR::LONG_ALIGN, + length); +} + +ACE_INLINE ACE_CDR::Boolean +ACE_InputCDR::read_longlong_array (ACE_CDR::LongLong *x, + ACE_CDR::ULong length) +{ + // Make sure the length of the array isn't greater than the length of + // the stream. + if (length * ACE_CDR::LONGLONG_SIZE > this->length ()) + { + this->good_bit_ = false; + return false; + } + + return this->read_array (x, + ACE_CDR::LONGLONG_SIZE, + ACE_CDR::LONGLONG_ALIGN, + length); +} + +ACE_INLINE ACE_CDR::Boolean +ACE_InputCDR::read_ulonglong_array (ACE_CDR::ULongLong *x, + ACE_CDR::ULong length) +{ + // Make sure the length of the array isn't greater than the length of + // the stream. + if (length * ACE_CDR::LONGLONG_SIZE > this->length ()) + { + this->good_bit_ = false; + return false; + } + + return this->read_array (x, + ACE_CDR::LONGLONG_SIZE, + ACE_CDR::LONGLONG_ALIGN, + length); +} + +ACE_INLINE ACE_CDR::Boolean +ACE_InputCDR::read_float_array (ACE_CDR::Float *x, + ACE_CDR::ULong length) +{ + // Make sure the length of the array isn't greater than the length of + // the stream. + if (length * ACE_CDR::LONG_SIZE > this->length ()) + { + this->good_bit_ = false; + return false; + } + + return this->read_array (x, + ACE_CDR::LONG_SIZE, + ACE_CDR::LONG_ALIGN, + length); +} + + +ACE_INLINE ACE_CDR::Boolean +ACE_InputCDR::read_double_array (ACE_CDR::Double *x, + ACE_CDR::ULong length) +{ + // Make sure the length of the array isn't greater than the length of + // the stream. + if (length * ACE_CDR::LONGLONG_SIZE > this->length ()) + { + this->good_bit_ = false; + return false; + } + + return this->read_array (x, + ACE_CDR::LONGLONG_SIZE, + ACE_CDR::LONGLONG_ALIGN, + length); +} + +ACE_INLINE ACE_CDR::Boolean +ACE_InputCDR::read_longdouble_array (ACE_CDR::LongDouble* x, + ACE_CDR::ULong length) +{ + // Make sure the length of the array isn't greater than the length of + // the stream. + if (length * ACE_CDR::LONGDOUBLE_SIZE > this->length ()) + { + this->good_bit_ = false; + return false; + } + return this->read_array (x, + ACE_CDR::LONGDOUBLE_SIZE, + ACE_CDR::LONGDOUBLE_ALIGN, + length); +} + +ACE_INLINE ACE_CDR::Boolean +ACE_InputCDR::skip_octet (void) +{ + ACE_CDR::Octet x; + return this->read_1 (&x); +} + +ACE_INLINE ACE_CDR::Boolean +ACE_InputCDR::skip_char (void) +{ + return this->skip_octet (); // sizeof (Char) == sizeof (Octet) +} + +ACE_INLINE ACE_CDR::Boolean +ACE_InputCDR::skip_boolean (void) +{ + return this->skip_octet () && this->good_bit_; +} + +ACE_INLINE ACE_CDR::Boolean +ACE_InputCDR::skip_ushort (void) +{ + ACE_CDR::UShort x; + return this->read_2 (&x); +} + +ACE_INLINE ACE_CDR::Boolean +ACE_InputCDR::skip_short (void) +{ + return this->skip_ushort (); +} + +ACE_INLINE ACE_CDR::Boolean +ACE_InputCDR::skip_ulong (void) +{ + ACE_CDR::ULong x; + return this->read_4 (&x); +} + +ACE_INLINE ACE_CDR::Boolean +ACE_InputCDR::skip_long (void) +{ + return this->skip_ulong (); // sizeof (Long) == sizeof (ULong) +} + +ACE_INLINE ACE_CDR::Boolean +ACE_InputCDR::skip_ulonglong (void) +{ + ACE_CDR::ULongLong x; + return this->read_8 (&x); +} + +ACE_INLINE ACE_CDR::Boolean +ACE_InputCDR::skip_longlong (void) +{ + return this->skip_ulonglong (); // sizeof (LongLong) == sizeof (ULongLong) +} + +ACE_INLINE ACE_CDR::Boolean +ACE_InputCDR::skip_float (void) +{ + return this->skip_ulong (); // sizeof(Float) == sizeof (ULong) +} + +ACE_INLINE ACE_CDR::Boolean +ACE_InputCDR::skip_double (void) +{ + return this->skip_ulonglong (); // sizeof(Double) == sizeof (ULongLong) +} + +ACE_INLINE ACE_CDR::Boolean +ACE_InputCDR::skip_longdouble (void) +{ + ACE_CDR::LongDouble x; + return this->read_16 (&x); +} + +ACE_INLINE char* +ACE_InputCDR::end (void) +{ + return this->start_.end (); +} + +ACE_INLINE void +ACE_InputCDR::rd_ptr (size_t offset) +{ + this->start_.rd_ptr (offset); +} + +ACE_INLINE char* +ACE_InputCDR::rd_ptr (void) +{ + return this->start_.rd_ptr (); +} + +ACE_INLINE char* +ACE_InputCDR::wr_ptr (void) +{ + return this->start_.wr_ptr (); +} + +ACE_INLINE int +ACE_InputCDR::adjust (size_t size, + size_t align, + char*& buf) +{ +#if !defined (ACE_LACKS_CDR_ALIGNMENT) + buf = ACE_ptr_align_binary (this->rd_ptr (), align); +#else + buf = this->rd_ptr (); +#endif /* ACE_LACKS_CDR_ALIGNMENT */ + + char * const end = buf + size; + if (end <= this->wr_ptr ()) + { + this->start_.rd_ptr (end); + return 0; + } + + this->good_bit_ = false; + return -1; +#if defined (ACE_LACKS_CDR_ALIGNMENT) + ACE_UNUSED_ARG (align); +#endif /* ACE_LACKS_CDR_ALIGNMENT */ +} + +ACE_INLINE int +ACE_InputCDR::adjust (size_t size, + char*& buf) +{ + return this->adjust (size, size, buf); +} + +ACE_INLINE const ACE_Message_Block* +ACE_InputCDR::start (void) const +{ + return &this->start_; +} + +ACE_INLINE bool +ACE_InputCDR::good_bit (void) const +{ + return this->good_bit_; +} + +// **************************************************************** + +ACE_INLINE ACE_CDR::Boolean +operator<< (ACE_OutputCDR &os, ACE_CDR::Char x) +{ + os.write_char (x); + return (ACE_CDR::Boolean) os.good_bit (); +} + +ACE_INLINE ACE_CDR::Boolean +operator<< (ACE_OutputCDR &os, ACE_CDR::Short x) +{ + os.write_short (x); + return (ACE_CDR::Boolean) os.good_bit (); +} + +ACE_INLINE ACE_CDR::Boolean +operator<< (ACE_OutputCDR &os, ACE_CDR::UShort x) +{ + os.write_ushort (x); + return (ACE_CDR::Boolean) os.good_bit (); +} + +ACE_INLINE ACE_CDR::Boolean +operator<< (ACE_OutputCDR &os, ACE_CDR::Long x) +{ + os.write_long (x); + return (ACE_CDR::Boolean) os.good_bit (); +} + +ACE_INLINE ACE_CDR::Boolean +operator<< (ACE_OutputCDR &os, ACE_CDR::ULong x) +{ + os.write_ulong (x); + return (ACE_CDR::Boolean) os.good_bit (); +} + +ACE_INLINE ACE_CDR::Boolean +operator<< (ACE_OutputCDR &os, ACE_CDR::LongLong x) +{ + os.write_longlong (x); + return (ACE_CDR::Boolean) os.good_bit (); +} + +ACE_INLINE ACE_CDR::Boolean +operator<< (ACE_OutputCDR &os, ACE_CDR::ULongLong x) +{ + os.write_ulonglong (x); + return (ACE_CDR::Boolean) os.good_bit (); +} + +ACE_INLINE ACE_CDR::Boolean +operator<< (ACE_OutputCDR &os, ACE_CDR::LongDouble x) +{ + os.write_longdouble (x); + return (ACE_CDR::Boolean) os.good_bit (); +} + +ACE_INLINE ACE_CDR::Boolean +operator<< (ACE_OutputCDR &os, ACE_CDR::Float x) +{ + os.write_float (x); + return (ACE_CDR::Boolean) os.good_bit (); +} + +ACE_INLINE ACE_CDR::Boolean +operator<< (ACE_OutputCDR &os, ACE_CDR::Double x) +{ + os.write_double (x); + return (ACE_CDR::Boolean) os.good_bit (); +} + +ACE_INLINE ACE_CDR::Boolean +operator<< (ACE_OutputCDR &os, const ACE_CDR::Char *x) +{ + os.write_string (x); + return (ACE_CDR::Boolean) os.good_bit (); +} + +ACE_INLINE ACE_CDR::Boolean +operator<< (ACE_OutputCDR &os, const ACE_CDR::WChar *x) +{ + os.write_wstring (x); + return (ACE_CDR::Boolean) os.good_bit (); +} + +// The following use the helper classes +ACE_INLINE ACE_CDR::Boolean +operator<< (ACE_OutputCDR &os, ACE_OutputCDR::from_boolean x) +{ + (void) os.write_boolean (x.val_); + return (ACE_CDR::Boolean) os.good_bit (); +} + +ACE_INLINE ACE_CDR::Boolean +operator<< (ACE_OutputCDR &os, ACE_OutputCDR::from_char x) +{ + os.write_char (x.val_); + return (ACE_CDR::Boolean) os.good_bit (); +} + +ACE_INLINE ACE_CDR::Boolean +operator<< (ACE_OutputCDR &os, ACE_OutputCDR::from_wchar x) +{ + os.write_wchar (x.val_); + return (ACE_CDR::Boolean) os.good_bit (); +} + +ACE_INLINE ACE_CDR::Boolean +operator<< (ACE_OutputCDR &os, ACE_OutputCDR::from_octet x) +{ + os.write_octet (x.val_); + return (ACE_CDR::Boolean) os.good_bit (); +} + +ACE_INLINE ACE_CDR::Boolean +operator<< (ACE_OutputCDR &os, ACE_OutputCDR::from_string x) +{ + ACE_CDR::ULong len = 0; + + if (x.val_ != 0) + { + len = static_cast (ACE_OS::strlen (x.val_)); + } + + os.write_string (len, x.val_); + return + (ACE_CDR::Boolean) (os.good_bit () && (!x.bound_ || len <= x.bound_)); +} + +ACE_INLINE ACE_CDR::Boolean +operator<< (ACE_OutputCDR &os, ACE_OutputCDR::from_wstring x) +{ + ACE_CDR::ULong len = 0; + + if (x.val_ != 0) + { + len = static_cast (ACE_OS::strlen (x.val_)); + } + + os.write_wstring (len, x.val_); + return + (ACE_CDR::Boolean) (os.good_bit () && (!x.bound_ || len <= x.bound_)); +} + +// **************************************************************** + +ACE_INLINE ACE_CDR::Boolean +operator>> (ACE_InputCDR &is, ACE_CDR::Char &x) +{ + return is.read_char (x) && is.good_bit (); +} + +ACE_INLINE ACE_CDR::Boolean +operator>> (ACE_InputCDR &is, ACE_CDR::Short &x) +{ + return is.read_short (x) && is.good_bit (); +} + +ACE_INLINE ACE_CDR::Boolean +operator>> (ACE_InputCDR &is, ACE_CDR::UShort &x) +{ + return is.read_ushort (x) && is.good_bit (); +} + +ACE_INLINE ACE_CDR::Boolean +operator>>(ACE_InputCDR &is, ACE_CDR::Long &x) +{ + return is.read_long (x) && is.good_bit (); +} + +ACE_INLINE ACE_CDR::Boolean +operator>> (ACE_InputCDR &is, ACE_CDR::ULong &x) +{ + return is.read_ulong (x) && is.good_bit (); +} + +ACE_INLINE ACE_CDR::Boolean +operator>> (ACE_InputCDR& is, ACE_CDR::LongLong &x) +{ + return is.read_longlong (x) && is.good_bit (); +} + +ACE_INLINE ACE_CDR::Boolean +operator>> (ACE_InputCDR& is, ACE_CDR::ULongLong &x) +{ + return is.read_ulonglong (x) && is.good_bit (); +} + +ACE_INLINE ACE_CDR::Boolean +operator>> (ACE_InputCDR& is, ACE_CDR::LongDouble &x) +{ + return is.read_longdouble (x) && is.good_bit (); +} + +ACE_INLINE ACE_CDR::Boolean +operator>> (ACE_InputCDR &is, ACE_CDR::Float &x) +{ + return is.read_float (x) && is.good_bit (); +} + +ACE_INLINE ACE_CDR::Boolean +operator>> (ACE_InputCDR &is, ACE_CDR::Double &x) +{ + return is.read_double (x) && is.good_bit (); +} + +ACE_INLINE ACE_CDR::Boolean +operator>> (ACE_InputCDR &is, ACE_CDR::Char *&x) +{ + return is.read_string (x) && is.good_bit (); +} + +ACE_INLINE ACE_CDR::Boolean +operator>> (ACE_InputCDR &is, ACE_CDR::WChar *&x) +{ + return is.read_wstring (x) && is.good_bit (); +} + +// The following use the helper classes +ACE_INLINE ACE_CDR::Boolean +operator>> (ACE_InputCDR &is, ACE_InputCDR::to_boolean x) +{ + return is.read_boolean (x.ref_); +} + +ACE_INLINE ACE_CDR::Boolean +operator>> (ACE_InputCDR &is, ACE_InputCDR::to_char x) +{ + return is.read_char (x.ref_) && is.good_bit (); +} + +ACE_INLINE ACE_CDR::Boolean +operator>> (ACE_InputCDR &is, ACE_InputCDR::to_wchar x) +{ + return is.read_wchar (x.ref_) && is.good_bit (); +} + +ACE_INLINE ACE_CDR::Boolean +operator>> (ACE_InputCDR &is, ACE_InputCDR::to_octet x) +{ + return is.read_octet (x.ref_) && is.good_bit (); +} + +ACE_INLINE ACE_CDR::Boolean +operator>> (ACE_InputCDR &is, ACE_InputCDR::to_string x) +{ + // check if the bounds are satisfied + return + (is.read_string (const_cast (x.val_)) + && is.good_bit () + && (!x.bound_ + || ACE_OS::strlen (x.val_) <= x.bound_)); +} + +ACE_INLINE ACE_CDR::Boolean +operator>> (ACE_InputCDR &is, ACE_InputCDR::to_wstring x) +{ + // check if the bounds are satisfied + return + (is.read_wstring (const_cast (x.val_)) + && is.good_bit () + && (!x.bound_ + || ACE_OS::strlen (x.val_) <= x.bound_)); +} + +// *************************************************************************** +// We must define these methods here because they use the "read_*" inlined +// methods of the ACE_InputCDR class +// *************************************************************************** + +ACE_INLINE ACE_CDR::Boolean +ACE_OutputCDR::append_boolean (ACE_InputCDR &stream) +{ + ACE_CDR::Boolean x; + return stream.read_boolean (x) ? this->write_boolean (x) : false; +} + +ACE_INLINE ACE_CDR::Boolean +ACE_OutputCDR::append_char (ACE_InputCDR &stream) +{ + ACE_CDR::Char x; + return stream.read_char (x) ? this->write_char (x) : false; +} + +ACE_INLINE ACE_CDR::Boolean +ACE_OutputCDR::append_wchar (ACE_InputCDR &stream) +{ + ACE_CDR::WChar x; + return stream.read_wchar (x) ? this->write_wchar (x) : false; +} + +ACE_INLINE ACE_CDR::Boolean +ACE_OutputCDR::append_octet (ACE_InputCDR &stream) +{ + ACE_CDR::Octet x; + return stream.read_octet (x) ? this->write_octet (x) : false; +} + +ACE_INLINE ACE_CDR::Boolean +ACE_OutputCDR::append_short (ACE_InputCDR &stream) +{ + ACE_CDR::Short x; + return stream.read_short (x) ? this->write_short (x) : false; +} + +ACE_INLINE ACE_CDR::Boolean +ACE_OutputCDR::append_ushort (ACE_InputCDR &stream) +{ + ACE_CDR::UShort x; + return stream.read_ushort (x) ? this->write_ushort (x) : false; +} + +ACE_INLINE ACE_CDR::Boolean +ACE_OutputCDR::append_long (ACE_InputCDR &stream) +{ + ACE_CDR::Long x; + return stream.read_long (x) ? this->write_long (x) : false; +} + +ACE_INLINE ACE_CDR::Boolean +ACE_OutputCDR::append_ulong (ACE_InputCDR &stream) +{ + ACE_CDR::ULong x; + return stream.read_ulong (x) ? this->write_ulong (x) : false; +} + +ACE_INLINE ACE_CDR::Boolean +ACE_OutputCDR::append_longlong (ACE_InputCDR &stream) +{ + ACE_CDR::LongLong x; + return stream.read_longlong (x) ? this->write_longlong (x) : false; +} + +ACE_INLINE ACE_CDR::Boolean +ACE_OutputCDR::append_ulonglong (ACE_InputCDR &stream) +{ + ACE_CDR::ULongLong x; + return stream.read_ulonglong (x) ? this->write_ulonglong (x) : false; +} + +ACE_INLINE ACE_CDR::Boolean +ACE_OutputCDR::append_float (ACE_InputCDR &stream) +{ + ACE_CDR::Float x; + return stream.read_float (x) ? this->write_float (x) : false; +} + +ACE_INLINE ACE_CDR::Boolean +ACE_OutputCDR::append_double (ACE_InputCDR &stream) +{ + ACE_CDR::Double x; + return stream.read_double (x) ? this->write_double (x) : false; +} + +ACE_INLINE ACE_CDR::Boolean +ACE_OutputCDR::append_longdouble (ACE_InputCDR &stream) +{ + ACE_CDR::LongDouble x; + return stream.read_longdouble (x) ? this->write_longdouble (x) : false; +} + +ACE_INLINE ACE_CDR::Boolean +ACE_OutputCDR::append_string (ACE_InputCDR &stream) +{ + ACE_CDR::Char *x = 0; + ACE_CDR::Boolean const flag = + (stream.read_string (x) ? this->write_string (x) : false); + delete [] x; + return flag; +} + +ACE_INLINE ACE_CDR::Boolean +ACE_OutputCDR::append_wstring (ACE_InputCDR &stream) +{ + ACE_CDR::WChar *x = 0; + ACE_CDR::Boolean const flag = + (stream.read_wstring (x) ? this->write_wstring (x) : false); + delete [] x; + return flag; +} + +ACE_INLINE void +ACE_InputCDR::reset_byte_order (int byte_order) +{ + this->do_byte_swap_ = (byte_order != ACE_CDR_BYTE_ORDER); +} + +ACE_INLINE bool +ACE_InputCDR::do_byte_swap (void) const +{ + return this->do_byte_swap_; +} + +ACE_INLINE int +ACE_InputCDR::byte_order (void) const +{ + return this->do_byte_swap () ? !ACE_CDR_BYTE_ORDER : ACE_CDR_BYTE_ORDER; +} + +ACE_INLINE int +ACE_InputCDR::align_read_ptr (size_t alignment) +{ +#if !defined (ACE_LACKS_CDR_ALIGNMENT) + char *buf = ACE_ptr_align_binary (this->rd_ptr (), + alignment); +#else + char *buf = this->rd_ptr (); +#endif /* ACE_LACKS_CDR_ALIGNMENT */ + + if (buf <= this->wr_ptr ()) + { + this->start_.rd_ptr (buf); + return 0; + } + + this->good_bit_ = false; + return -1; +} + +ACE_INLINE void +ACE_InputCDR::set_version (ACE_CDR::Octet major, ACE_CDR::Octet minor) +{ + this->major_version_ = major; + this->minor_version_ = minor; +} + +ACE_INLINE void +ACE_InputCDR::get_version (ACE_CDR::Octet &major, ACE_CDR::Octet &minor) +{ + major = this->major_version_; + minor = this->minor_version_; +} + +ACE_INLINE ACE_Char_Codeset_Translator * +ACE_InputCDR::char_translator (void) const +{ + return this->char_translator_; +} + +ACE_INLINE ACE_WChar_Codeset_Translator * +ACE_InputCDR::wchar_translator (void) const +{ + return this->wchar_translator_; +} + + +ACE_INLINE void +ACE_InputCDR::char_translator (ACE_Char_Codeset_Translator * ctran) +{ + this->char_translator_ = ctran; +} + +ACE_INLINE void +ACE_InputCDR::wchar_translator (ACE_WChar_Codeset_Translator * wctran) +{ + this->wchar_translator_ = wctran; +} + +// **************************************************************** + +ACE_INLINE ACE_CDR::Boolean +ACE_Char_Codeset_Translator::read_1 (ACE_InputCDR& input, + ACE_CDR::Octet *x) +{ + return input.read_1 (x); +} + +ACE_INLINE ACE_CDR::Boolean +ACE_Char_Codeset_Translator::write_1 (ACE_OutputCDR& output, + const ACE_CDR::Octet *x) +{ + return output.write_1 (x); +} + +ACE_INLINE ACE_CDR::Boolean +ACE_Char_Codeset_Translator::read_array (ACE_InputCDR& in, + void* x, + size_t size, + size_t align, + ACE_CDR::ULong length) +{ + return in.read_array (x, size, align, length); +} + +ACE_INLINE ACE_CDR::Boolean +ACE_Char_Codeset_Translator::write_array (ACE_OutputCDR& out, + const void *x, + size_t size, + size_t align, + ACE_CDR::ULong length) +{ + return out.write_array(x, size, align, length); +} + +ACE_INLINE int +ACE_Char_Codeset_Translator::adjust (ACE_OutputCDR& out, + size_t size, + size_t align, + char *&buf) +{ + return out.adjust(size, align, buf); +} + +ACE_INLINE void +ACE_Char_Codeset_Translator::good_bit (ACE_OutputCDR& out, bool bit) +{ + out.good_bit_ = bit; +} + +ACE_INLINE ACE_CDR::Octet +ACE_Char_Codeset_Translator::major_version (ACE_InputCDR& input) +{ + return input.major_version_; +} + +ACE_INLINE ACE_CDR::Octet +ACE_Char_Codeset_Translator::minor_version (ACE_InputCDR& input) +{ + return input.minor_version_; +} + +ACE_INLINE ACE_CDR::Octet +ACE_Char_Codeset_Translator::major_version (ACE_OutputCDR& output) +{ + return output.major_version_; +} + +ACE_INLINE ACE_CDR::Octet +ACE_Char_Codeset_Translator::minor_version (ACE_OutputCDR& output) +{ + return output.minor_version_; +} + +// **************************************************************** + +ACE_INLINE ACE_CDR::Boolean +ACE_WChar_Codeset_Translator::read_1 (ACE_InputCDR& input, + ACE_CDR::Octet *x) +{ + return input.read_1 (x); +} + +ACE_INLINE ACE_CDR::Boolean +ACE_WChar_Codeset_Translator::read_2 (ACE_InputCDR& input, + ACE_CDR::UShort *x) +{ + return input.read_2 (x); +} + +ACE_INLINE ACE_CDR::Boolean +ACE_WChar_Codeset_Translator::read_4 (ACE_InputCDR& input, + ACE_CDR::ULong *x) +{ + return input.read_4 (x); +} + +ACE_INLINE ACE_CDR::Boolean +ACE_WChar_Codeset_Translator::write_1 (ACE_OutputCDR& output, + const ACE_CDR::Octet *x) +{ + return output.write_1 (x); +} + +ACE_INLINE ACE_CDR::Boolean +ACE_WChar_Codeset_Translator::write_2 (ACE_OutputCDR& output, + const ACE_CDR::UShort *x) +{ + return output.write_2 (x); +} + +ACE_INLINE ACE_CDR::Boolean +ACE_WChar_Codeset_Translator::write_4 (ACE_OutputCDR& output, + const ACE_CDR::ULong *x) +{ + return output.write_4 (x); +} + +ACE_INLINE ACE_CDR::Boolean +ACE_WChar_Codeset_Translator::read_array (ACE_InputCDR& in, + void* x, + size_t size, + size_t align, + ACE_CDR::ULong length) +{ + return in.read_array (x, size, align, length); +} + +ACE_INLINE ACE_CDR::Boolean +ACE_WChar_Codeset_Translator::write_array (ACE_OutputCDR& out, + const void *x, + size_t size, + size_t align, + ACE_CDR::ULong length) +{ + return out.write_array(x, size, align, length); +} + +ACE_INLINE int +ACE_WChar_Codeset_Translator::adjust (ACE_OutputCDR& out, + size_t size, + size_t align, + char *&buf) +{ + return out.adjust(size, align, buf); +} + +ACE_INLINE void +ACE_WChar_Codeset_Translator::good_bit (ACE_OutputCDR& out, bool bit) +{ + out.good_bit_ = bit; +} + +ACE_INLINE ACE_CDR::Octet +ACE_WChar_Codeset_Translator::major_version (ACE_InputCDR& input) +{ + return input.major_version_; +} + +ACE_INLINE ACE_CDR::Octet +ACE_WChar_Codeset_Translator::minor_version (ACE_InputCDR& input) +{ + return input.minor_version_; +} + +ACE_INLINE ACE_CDR::Octet +ACE_WChar_Codeset_Translator::major_version (ACE_OutputCDR& output) +{ + return output.major_version_; +} + +ACE_INLINE ACE_CDR::Octet +ACE_WChar_Codeset_Translator::minor_version (ACE_OutputCDR& output) +{ + return output.minor_version_; +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/CE_Screen_Output.cpp b/dep/ACE_wrappers/ace/CE_Screen_Output.cpp new file mode 100644 index 00000000000..dfd3d717a1f --- /dev/null +++ b/dep/ACE_wrappers/ace/CE_Screen_Output.cpp @@ -0,0 +1,158 @@ +// $Id: CE_Screen_Output.cpp 80826 2008-03-04 14:51:23Z wotte $ + +#include "ace/CE_Screen_Output.h" +#if defined (ACE_HAS_WINCE) + +#include "ace/Log_Msg.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_CE_Screen_Output::ACE_CE_Screen_Output(HWND hEdit) +: handler_(hEdit) +, pFile_(0) +{ +} + +ACE_CE_Screen_Output::ACE_CE_Screen_Output() +: handler_(0) +, pFile_(0) +{ +} + +ACE_CE_Screen_Output::~ACE_CE_Screen_Output() +{ + if (pFile_ != 0) { + fclose(pFile_); + } +} + +void ACE_CE_Screen_Output::log(ACE_Log_Record &log_record) +{ + ACE_TCHAR verbose_msg[ACE_Log_Record::MAXVERBOSELOGMSGLEN]; + int result = log_record.format_msg (ACE_TEXT("WindozeCE"), // host name + 0, // verbose flag + verbose_msg); + + if (result == 0) + { + verbose_msg[ ACE_OS::strlen(verbose_msg) - 1 ] = 0; // CE does not like '\n' by itself. + *this << verbose_msg << endl; + } +} + +void ACE_CE_Screen_Output::SetOutputWindow(HWND hEdit) +{ + handler_ = hEdit; +} + +void ACE_CE_Screen_Output::clear() +{ + SetWindowText(handler_, 0); +} + +ACE_CE_Screen_Output& ACE_CE_Screen_Output::operator << (ACE_TCHAR* output) +{ + int length = GetWindowTextLength(handler_); + SendMessage(handler_, EM_SETSEL, length, length); + SendMessage(handler_, EM_REPLACESEL, 0, (LPARAM)output); + + if (pFile_ != 0) + { + fwprintf(pFile_, L"%s", output); + } + + return *this; +} + +ACE_CE_Screen_Output& ACE_CE_Screen_Output::operator << (const ACE_TCHAR* output) +{ + ACE_TCHAR* buffer = ACE_OS::strdup(output); + if (buffer != 0) + { + *this << buffer; + delete buffer; + } + return *this; +} + +ACE_CE_Screen_Output& ACE_CE_Screen_Output::operator << (ACE_ANTI_TCHAR* output) +{ + *this << ACE_TEXT_CHAR_TO_TCHAR(output); + return *this; +} + +ACE_CE_Screen_Output& ACE_CE_Screen_Output::operator << (const ACE_ANTI_TCHAR* output) +{ + *this << ACE_TEXT_CHAR_TO_TCHAR(output); + return *this; +} + +ACE_CE_Screen_Output& ACE_CE_Screen_Output::operator << (char output) +{ + *this << (int)output; + return *this; +} + +ACE_CE_Screen_Output& ACE_CE_Screen_Output::operator << (unsigned char output) +{ + *this << (int)output; + return *this; +} + +ACE_CE_Screen_Output& ACE_CE_Screen_Output::operator << (unsigned short output) +{ + ACE_TCHAR buffer[20]; + wsprintf(buffer, ACE_TEXT("%u"), output); + *this << buffer; + return *this; +} + +ACE_CE_Screen_Output& ACE_CE_Screen_Output::operator << (int output) +{ + ACE_TCHAR buffer[20]; + wsprintf(buffer, ACE_TEXT("%d"), output); + *this << buffer; + return *this; +} + +ACE_CE_Screen_Output& ACE_CE_Screen_Output::operator << (unsigned int output) +{ + ACE_TCHAR buffer[20]; + wsprintf(buffer, ACE_TEXT("%du"), output); + *this << buffer; + return *this; +} + +ACE_CE_Screen_Output& ACE_CE_Screen_Output::operator << (float output) +{ + ACE_TCHAR buffer[20]; + swprintf(buffer, ACE_TEXT("%f"), output); + *this << buffer; + return *this; +} + +ACE_CE_Screen_Output& ACE_CE_Screen_Output::operator << (long output) +{ + ACE_TCHAR buffer[20]; + wsprintf(buffer, ACE_TEXT("%l"), output); + *this << buffer; + return *this; +} + +ACE_CE_Screen_Output& ACE_CE_Screen_Output::operator << (unsigned long output) +{ + ACE_TCHAR buffer[20]; + wsprintf(buffer, ACE_TEXT("%lu"), output); + *this << buffer; + return *this; +} + +ACE_CE_Screen_Output& ACE_CE_Screen_Output::operator << (FILE* pFile) +{ + pFile_ = pFile; + return *this; +} + +ACE_END_VERSIONED_NAMESPACE_DECL + +#endif // ACE_HAS_WINCE diff --git a/dep/ACE_wrappers/ace/CE_Screen_Output.h b/dep/ACE_wrappers/ace/CE_Screen_Output.h new file mode 100644 index 00000000000..ba2bc7c02b5 --- /dev/null +++ b/dep/ACE_wrappers/ace/CE_Screen_Output.h @@ -0,0 +1,109 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file CE_Screen_Output.h + * + * $Id: CE_Screen_Output.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Si Mong Park + */ +//============================================================================= + +#ifndef ACE_CE_SCREEN_OUTPUT_H +#define ACE_CE_SCREEN_OUTPUT_H + +#include /**/ "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +#pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#if defined (ACE_HAS_WINCE) + +#include "ace/Log_Msg_Callback.h" +#include "ace/Log_Record.h" + +namespace +{ + const ACE_TCHAR endl[] = ACE_TEXT("\r\n"); + const ACE_TCHAR tab[] = ACE_TEXT("\t"); +} + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +/** + * @class ACE_CE_Screen_Output + * + * @brief Replacement of text output for Windows CE. + * + * This class allows standard text output to be displayed on + * text window for Windows CE. Generally, all ACE output will + * go through under CE if and only if user uses WindozeCE + * implementation by using main_ce instead of main. + * Also, for the easier debugging purpose, object pointer of + * this class can be gotten from ACE_Log_Msg::msg_callback() + * and then can be used directly by user just like cout stream. + */ +class ACE_Export ACE_CE_Screen_Output : public ACE_Log_Msg_Callback +{ +public: + + ACE_CE_Screen_Output (HWND hEdit); + + ACE_CE_Screen_Output (void); + + virtual ~ACE_CE_Screen_Output(); + + /// Implementation of pure virtual function from ACE_Log_Msg_Callback. + virtual void log (ACE_Log_Record &log_record); + + /// Interface to specify active window handle. + void SetOutputWindow (HWND hWnd); + + void clear (void); + + /// Stream insertion operator that performs actual print out. + /** + * @note This is the only one operator that performs output. All + * other perators convert the type and use this operator + * underneath. + */ + ACE_CE_Screen_Output& operator << (ACE_TCHAR*); + ACE_CE_Screen_Output& operator << (const ACE_TCHAR*); + + ACE_CE_Screen_Output& operator << (ACE_ANTI_TCHAR* output); + ACE_CE_Screen_Output& operator << (const ACE_ANTI_TCHAR* output); + + ACE_CE_Screen_Output& operator << (char output); + ACE_CE_Screen_Output& operator << (unsigned char output); + + ACE_CE_Screen_Output& operator << (unsigned short output); + + ACE_CE_Screen_Output& operator << (int output); + ACE_CE_Screen_Output& operator << (unsigned int output); + + ACE_CE_Screen_Output& operator << (float output); + + ACE_CE_Screen_Output& operator << (long output); + ACE_CE_Screen_Output& operator << (unsigned long output); + + ACE_CE_Screen_Output& operator << (FILE* pFile); + +private: + + ACE_CE_Screen_Output (ACE_CE_Screen_Output&); + +private: + + HWND handler_; + + /// FILE pointer that used to save output to file. This class does + /// not own the file handler pointer. + FILE* pFile_; +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#endif // ACE_HAS_WINCE +#endif // ACE_CE_SCREEN_OUTPUT_H diff --git a/dep/ACE_wrappers/ace/CORBA_macros.h b/dep/ACE_wrappers/ace/CORBA_macros.h new file mode 100644 index 00000000000..beab26b7f04 --- /dev/null +++ b/dep/ACE_wrappers/ace/CORBA_macros.h @@ -0,0 +1,575 @@ +// -*- C++ -*- + +// ============================================================================ +/** + * @file CORBA_macros.h + * + * $Id: CORBA_macros.h 80826 2008-03-04 14:51:23Z wotte $ + * + * Writing code that is portable between platforms with or without + * native C++ exceptions is hard. The following macros offer some + * help on this task, mostly oriented to making the ORB code and the + * IDL generated code portable. + * + * @author Nanbor Wang + * @author Aniruddha Gokhale + * @author Carlos O'Ryan , et al. + */ +// ============================================================================ + +// Macros for handling CORBA exceptions. + +#ifndef ACE_CORBA_MACROS_H +#define ACE_CORBA_MACROS_H + +#include /**/ "ace/pre.h" + +#include /**/ "ace/config-all.h" + +# if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +# endif /* ACE_LACKS_PRAGMA_ONCE */ + +#define ACE_ENV_POLLUTE_NAMES + +#include "ace/Exception_Macros.h" + +// The Windows MFC exception mechanism requires that a caught CException +// (including the CMemoryException in use here) be freed using its Delete() +// method. Thus, when MFC is in use and we're catching exceptions as a result +// of new(), the exception's Delete() method has to be called. No other +// platform imposes this sort of restriction/requirement. The Windows +// config stuff (at least for MSVC/MFC) defines a ACE_del_bad_alloc macro +// that works with its ACE_bad_alloc macro to implement this cleanup +// requirement. Since no other platform requires this, define it as +// empty here. +#if !defined (ACE_del_bad_alloc) +# define ACE_del_bad_alloc +#endif + +#if !defined (ACE_LACKS_DEPRECATED_MACROS) + +// If you wish to you use these macros for emulating exceptions on +// platforms which lack native exception support, you need to do the +// following: +// 1. Define a class Exception. You can name it as you please. This class +// should be at the root of the inheritance hierarchy of all the +// exceptions used in your application. It should define at a minimum +// the following pure virtual methods: +// a) _downcast () - Which allows narrowing of the base exception type to a +// derived type. +// b) _raise() - Which throws an exception of type Exception. +// +// Classes which derive from these should implement these operations. +// +// 2. Define a class Environment. You can name it as you please. This class +// is an exception holder. This class is always on the stack. It should +// support at a minimum the following methods: +// a) exception() - Which returns the Exception held in the current +// Environment. +// b) exception (Exception* foo) - Which replaces/sets the Exception +// held in the current Environment with foo. +// b) clear() - Which resets a particular instance of Environment. +// c) A copy constructor and an assignment operator. +// +// Note that the above description assumes that you use the following +// macros only within a particular domain. For example, if your +// application has to interoperate across domains, then you need to define +// an exception adapter to translate exceptions from one domain to +// exceptions in the other. Please refer to Stroustrup's book on how to do +// this. If your use case is this complex, you would be better off with +// going with native exceptions rather than emulated exceptions, though +// the macros should still work if you defined your adapter class as +// ACE_EXCEPTION_TYPE. + + +// The following macros assume that an environment variable is passed +// in/out of each function that can throw an exception. The type of the +// environment variable is defined by ACE_ENV_TYPE. + +#if !defined (ACE_ENV_TYPE) +# define ACE_ENV_TYPE CORBA::Environment +#endif /* ACE_ENV_TYPE */ + +// The name of the variable is defined by ACE_TRY_ENV. Below is the name +// that we use by default. If you wish to change it you can redefine +// ACE_TRY_ENV to change the default name. Also ACE_ADOPT_ENV allows the +// use of non-standard name within a scope. + +#if !defined (ACE_TRY_ENV) +# define ACE_TRY_ENV _ACE_CORBA_Environment_variable +#endif /* ACE_TRY_ENV */ + +// The base type of Exception from which all the other exception types are +// derived. You can set this to any type as you please. By default, it is +// set to CORBA::Exception. + +#if !defined (ACE_EXCEPTION_TYPE) +# define ACE_EXCEPTION_TYPE CORBA::Exception +#endif /* ACE_EXCEPTION_TYPE */ + +// This method is used to get the default value of the Environment +// variable. In the case of TAO, this variable is part of the TSS ORB +// resources and the method TAO_default_environment() returns the +// Environment variable. + +#if !defined (ACE_DEFAULT_GET_ENV_METHOD) +# define ACE_DEFAULT_GET_ENV_METHOD TAO_default_environment +#endif /* ACE_DEFAULT_GET_ENV_METHOD */ + +// This is the exception caught by ACE_CATCHANY. +#if !defined (ACE_ANY_EXCEPTION) +# define ACE_ANY_EXCEPTION ex +#endif /* ACE_ANY_EXCEPTION */ + +// Declare a new environment variable on the stack. The type of the +// environment variable is determined by ACE_ENV_TYPE. +#if defined (ACE_USES_NATIVE_EXCEPTIONS) +// Don't instantiate an emulated exception environment at all when +// using native C++ exception support. It won't be used. +# define ACE_DECLARE_NEW_ENV +#else +# define ACE_DECLARE_NEW_ENV \ + ACE_ENV_TYPE ACE_TRY_ENV +#endif /* ACE_USES_NATIVE_EXCEPTIONS */ + +// Provided for backward compatibility purposes. Don't use it in new code. +// Use the definition above along with defining ACE_ENV_TYPE. + +#if defined (ACE_ENV_POLLUTE_NAMES) +# define ACE_DECLARE_NEW_CORBA_ENV ACE_DECLARE_NEW_ENV +#endif /* ACE_ENV_POLLUTE_NAMES */ + +#if defined (ACE_USES_NATIVE_EXCEPTIONS) +// ----------------------------------------------------------------- + +// Provided for backward compatibility purposes. Don't use it in new code. +#if defined (ACE_ENV_POLLUTE_NAMES) +# define ACE_ADOPT_CORBA_ENV(ENV) +#endif /* ACE_ENV_POLLUTE_NAMES */ + +#define ACE_ADOPT_ENV (ENV) + +// No need to check. Native exceptions handle the control flow +// automatically when an exception occurs. +# define ACE_CHECK + +// Used when the function requires a return value. +# define ACE_CHECK_RETURN(RETV) + +// ACE_THROW_INT should not be used by the user. +# define ACE_THROW_INT(EXCEPTION) \ + throw EXCEPTION + +// Throwing an exception is easy. These two macros should _NOT_ be +// used within try blocks. +# define ACE_THROW(EXCEPTION) \ + throw EXCEPTION + +// Throwing an exception when the function requires a return value. +# define ACE_THROW_RETURN(EXCEPTION,RETV) \ + throw EXCEPTION + +// For compilers with native exceptions, we can simply use try to try. ;-) +// do {} while (0) is required to avoid compilation warnings. +# define ACE_TRY \ + do \ + { \ + try \ + { +# define ACE_TRY_NEW_ENV \ + do \ + { \ + try \ + { +# define ACE_TRY_EX(LABEL) \ + do \ + { \ + try \ + { + +// No need to check for exceptions within try block for compilers with +// native exceptions. +# define ACE_TRY_CHECK +# define ACE_TRY_CHECK_EX(LABEL) + +// Likewise, throwing exceptions within try blocks is easy. +# define ACE_TRY_THROW(EXCEPTION) throw EXCEPTION +# define ACE_TRY_THROW_EX(EXCEPTION,LABEL) throw EXCEPTION + +// Same thing for catch. +# define ACE_CATCH(EXCEPTION,VAR) \ + } \ + catch (EXCEPTION & VAR) \ + { \ + ACE_UNUSED_ARG (VAR); + +# define ACE_CATCHANY \ + ACE_CATCH(ACE_EXCEPTION_TYPE, ACE_ANY_EXCEPTION) + +# define ACE_CATCHALL \ + } \ + catch (...) \ + { + +# if defined (ACE_HAS_DEPRECATED_ACE_RETHROW) +# define ACE_RETHROW throw +# endif /* ACE_HAS_DEPRECATED_ACE_RETHROW */ + +// Rethrowing the exception from catch blocks. +# define ACE_RE_THROW throw +# define ACE_RE_THROW_EX(LABEL) throw + +// Close the catch block. +# define ACE_ENDTRY \ + } \ + } while (0) + +#else /* ! ACE_USES_NATIVE_EXCEPTIONS */ +// ----------------------------------------------------------------- + +// When handling compilers without native exceptions, things get a bit +// hairy. Exceptions are simulated using ACE_ENV_TYPE. The trick here is to +// make sure the flow-of-control can simulate the case when native +// exceptions occur... + +#if defined (ACE_ENV_POLLUTE_NAMES) +# define ACE_ADOPT_CORBA_ENV(ENV) ACE_ENV_TYPE &ACE_TRY_ENV = ENV +#endif /* ACE_ENV_POLLUTE_NAMES */ + +# define ACE_ADOPT_ENV(ENV) ACE_ENV_TYPE &ACE_TRY_ENV = ENV + +// Follow every statement that could throw exceptions with ACE_CHECK or +// ACE_CHECK_RETURN. These two macros should _NOT_ be used within try +// blocks. Use ACE_TRY_CHECK or ACE_TRY_CHECK_EX instead. +# define ACE_CHECK \ + if (ACE_TRY_ENV . exception () != 0) \ + return +// When function requires a return value +# define ACE_CHECK_RETURN(RETV) \ + if (ACE_TRY_ENV . exception () != 0) \ + return RETV + +// ACE_THROW_INT should not be used by the user. +# define ACE_THROW_INT(EXCEPTION) ACE_TRY_ENV.exception (new EXCEPTION) + +// Throwing exceptions will inevitably cause a return from the current +// function. These two macros should _NOT_ be used within try blocks. Use +// ACE_TRY_THROW or ACE_TRY_THROW_EX instead. +# define ACE_THROW(EXCEPTION) \ + do \ + { \ + ACE_TRY_ENV.exception (new EXCEPTION); \ + return; \ + } while (0) + +# define ACE_THROW_RETURN(EXCEPTION,RETV) \ + do \ + { \ + ACE_TRY_ENV.exception (new EXCEPTION); \ + return RETV; \ + } while (0) + +// ACE_TRY sets up flags to control program flow. ACE_TRY_FLAG acts like a +// one-shot flip-flop. When an exception occurs (detected using +// ACE_TRY_CHECK,) ACE_TRY_FLAG will be reset and the control goes back +// into ACE_TRY_LABEL. Since ACE_TRY_FLAG is reset, the try block won't get +// executed again and the control proceeds to the following catch blocks. +// ACE_EXCEPTION_NOT_CAUGHT flag is used to prevent catching an exception +// twice. This macro assumes there's already an ACE_ENV_TYPE variable +// ACE_TRY_ENV defined (which should be the case normally) +# define ACE_TRY \ + do { \ + int ACE_TRY_FLAG = 1; \ + int ACE_EXCEPTION_NOT_CAUGHT = 1; \ + ACE_TRY_LABEL: \ + if (ACE_TRY_FLAG) \ + do { + +// ACE_TRY_NEW_ENV functions like the macro ACE_TRY but defines a new +// ACE_ENV_TYPE variable ACE_TRY_ENV. It is most often used in the outer +// most function where no ACE_TRY_ENV is available. +# define ACE_TRY_NEW_ENV \ + do { \ + ACE_DECLARE_NEW_ENV;\ + int ACE_TRY_FLAG = 1; \ + int ACE_EXCEPTION_NOT_CAUGHT = 1; \ + ACE_TRY_LABEL: \ + if (ACE_TRY_FLAG) \ + do { + +// ACE_TRY_EX works exactly like ACE_TRY macro except the label used in the +// try block is customizable to avoid name clashing. It should be used when +// nested try blocks or multiple try blocks are required, in the same +// function. +# define ACE_TRY_EX(LABEL) \ + do { \ + int ACE_TRY_FLAG = 1; \ + int ACE_EXCEPTION_NOT_CAUGHT = 1; \ + ACE_TRY_LABEL ## LABEL: \ + if (ACE_TRY_FLAG) \ + do { + +// Check for exceptions within try blocks. +# define ACE_TRY_CHECK \ + { \ + if (ACE_TRY_ENV.exception () != 0) \ + { \ + ACE_TRY_FLAG = 0; \ + goto ACE_TRY_LABEL; \ + } \ + } + +// Checking exception within EX try blocks. +# define ACE_TRY_CHECK_EX(LABEL) \ + { \ + if (ACE_TRY_ENV.exception () != 0) \ + { \ + ACE_TRY_FLAG = 0; \ + goto ACE_TRY_LABEL ## LABEL; \ + } \ + } + +// Throwing exception within TRY blocks. +# define ACE_TRY_THROW(EXCEPTION) \ + { \ + ACE_TRY_ENV.exception (new EXCEPTION); \ + ACE_TRY_FLAG = 0; \ + goto ACE_TRY_LABEL; \ + } + +# define ACE_TRY_THROW_EX(EXCEPTION,LABEL) \ + { \ + ACE_TRY_ENV.exception (new EXCEPTION); \ + ACE_TRY_FLAG = 0; \ + goto ACE_TRY_LABEL ## LABEL; \ + } + +// When exceptions occur or try block finishes execution without exception, +// control will continue in the catch block. This macro first checks if +// there's any uncaught exception left. If all the conditions are met, we +// have caught an exception. It then resets ACE_EXCEPTION_NOT_CAUGHT to +// prevent subsequent catch blocks from catching the same exception again, +// and extracts out the underlying exception in ACE_TRY_ENV. We also make a +// copy of ACE_TRY_ENV in ACE_CAUGHT_ENV, in case we want to rethrow the +// exception. ACE_TRY_ENV is cleared out after the exception is caught so +// you should not use ACE_TRY_ENV within the catch block(You should use the +// exception directly). +# define ACE_CATCH(TYPE,VAR) \ + } while (0); \ + do \ + if (ACE_TRY_ENV.exception () != 0 && ACE_EXCEPTION_NOT_CAUGHT && \ + TYPE::_downcast(ACE_TRY_ENV.exception ()) != 0) \ + { \ + ACE_ENV_TYPE ACE_CAUGHT_ENV = ACE_TRY_ENV;\ + ACE_EXCEPTION_NOT_CAUGHT = 0; \ + TYPE &VAR = *TYPE::_downcast (ACE_CAUGHT_ENV.exception ()); \ + ACE_UNUSED_ARG (VAR); \ + ACE_TRY_ENV.clear (); + +// ACE_CATCHANY uses ACE_CATCH to catch all exceptions derived from +// ACE_EXCEPTION_TYPE +# define ACE_CATCHANY ACE_CATCH (ACE_EXCEPTION_TYPE, ACE_ANY_EXCEPTION) + +// Since there's no other exception for compilers without exception +// support, we simply catch all ACE_EXCEPTION_TYPE exceptions for +// ACE_CATCHALL. +# define ACE_CATCHALL ACE_CATCHANY + +# if defined (ACE_HAS_DEPRECATED_ACE_RETHROW) +# define ACE_RETHROW \ + do \ + ACE_TRY_ENV = ACE_CAUGHT_ENV; \ + while (0) +# endif /* ACE_HAS_DEPRECATED_ACE_RETHROW */ + +// Rethrowing exception within catch blocks. Notice that we depend on the +// ACE_CHECK/ACE_CHECK_RETURN following the ACE_ENDTRY, or ACE_TRY_CHECK/ +// ACE_TRY_CHECK_EX following the ACE_ENDTRY when the catch block is within +// another try block, to do the "Right Thing[TM]." +# define ACE_RE_THROW \ + do {\ + ACE_TRY_ENV = ACE_CAUGHT_ENV; \ + goto ACE_TRY_LABEL; \ + } while (0) +# define ACE_RE_THROW_EX(LABEL) \ + do {\ + ACE_TRY_ENV = ACE_CAUGHT_ENV; \ + goto ACE_TRY_LABEL ## LABEL; \ + } while (0) + +// Close the try block. Since exceptions may not get caught, and exceptions +// can also be rethrown from the catch block, it's always a good idea to +// follow ACE_ENDTRY with ACE_CHECK or ACE_TRY_CHECK (depending on the +// context.) +# define ACE_ENDTRY \ + } while (0); \ + } while (0) + +#endif /* ! ACE_USES_NATIVE_EXCEPTIONS */ + +#endif /* !ACE_LACKS_DEPRECATED_MACROS */ + +// ACE_HAS_EXCEPTIONS is not the same as ACE_NEW_THROWS_EXCEPTIONS. +#if defined(ACE_NEW_THROWS_EXCEPTIONS) + +# if defined (ACE_HAS_NEW_NOTHROW) + +# define ACE_NEW_THROW_EX(POINTER,CONSTRUCTOR,EXCEPTION) \ + do { POINTER = new (ACE_nothrow) CONSTRUCTOR; \ + if (POINTER == 0) { throw EXCEPTION; } \ + } while (0) + +# else + +# define ACE_NEW_THROW_EX(POINTER,CONSTRUCTOR,EXCEPTION) \ + do { try { POINTER = new CONSTRUCTOR; } \ + catch (ACE_bad_alloc) { ACE_del_bad_alloc throw EXCEPTION; } \ + } while (0) + +# endif /* ACE_HAS_NEW_NOTHROW */ + +#else /* ! ACE_NEW_THROWS_EXCEPTIONS */ + +# define ACE_NEW_THROW_EX(POINTER,CONSTRUCTOR,EXCEPTION) \ + do { POINTER = new CONSTRUCTOR; \ + if (POINTER == 0) { throw EXCEPTION; } \ + } while (0) + +#endif /* ACE_NEW_THROWS_EXCEPTIONS */ + +# define ACE_GUARD_THROW_EX(MUTEX,OBJ,LOCK,EXCEPTION) \ + ACE_Guard< MUTEX > OBJ (LOCK); \ + if (OBJ.locked () == 0) throw EXCEPTION; + +# define ACE_READ_GUARD_THROW_EX(MUTEX,OBJ,LOCK,EXCEPTION) \ + ACE_Read_Guard< MUTEX > OBJ (LOCK); \ + if (OBJ.locked () == 0) throw EXCEPTION; + +# define ACE_WRITE_GUARD_THROW_EX(MUTEX,OBJ,LOCK,EXCEPTION) \ + ACE_Write_Guard< MUTEX > OBJ (LOCK); \ + if (OBJ.locked () == 0) throw EXCEPTION; + +#if !defined (ACE_LACKS_DEPRECATED_MACROS) + +//@{ +/** + * @name Native C++ exceptions portability macros. + * + * The following macros are used to write code portable between platforms + * with and without native C++ exception support. Their main goal is to + * hide the presence of the ACE_ENV_TYPE argument, but they collaborate + * with the ACE_TRY_* macros to emulate the try/catch blocks. + */ + +/// Define a macro to emit code only when ACE_ENV_TYPE is used +#if !defined (ACE_USES_NATIVE_EXCEPTIONS) || defined (ACE_ENV_BKWD_COMPAT) +# define ACE_ENV_EMIT_CODE(X) X +#else +# define ACE_ENV_EMIT_CODE(X) +#endif /* ACE_USES_NATIVE_EXCEPTIONS && ! ACE_ENV_BKWD_COMPAT */ + +/// Another macro to emit code only when ACE_ENV_TYPE is used +#if !defined (ACE_USES_NATIVE_EXCEPTIONS) || defined (ACE_ENV_BKWD_COMPAT) +# define ACE_ENV_EMIT_CODE2(X,Y) X,Y +#else +# define ACE_ENV_EMIT_CODE2(X,Y) +#endif /* ACE_USES_NATIVE_EXCEPTIONS && ! ACE_ENV_BKWD_COMPAT */ + +/// Helper macro +#define ACE_ENV_EMIT_DUMMY + +/// Declare a ACE_ENV_TYPE argument as the last argument of a +/// function +/** + * Normally this macro is used as follows: + * + * void my_funct (int x, int y ACE_ENV_ARG_DECL); + * + * Its purpose is to provide developers (and users) with a mechanism to + * write code that is portable to platforms with and without native C++ + * exceptions. + */ +#define ACE_ENV_ARG_DECL \ + ACE_ENV_EMIT_CODE2(ACE_ENV_EMIT_DUMMY, \ + ACE_ENV_TYPE &ACE_TRY_ENV) + +/// Declare a ACE_ENV_TYPE argument with the default value obtained from +/// the ORB/application. +/** + * It is similar to ACE_ENV_ARG_DECL. The name of the default environment + * getter method needs to be changed when switching ORBs or when used with + * another application. + */ +#define ACE_ENV_ARG_DECL_WITH_DEFAULTS \ + ACE_ENV_EMIT_CODE2(ACE_ENV_EMIT_DUMMY, \ + ACE_ENV_TYPE &ACE_TRY_ENV = \ + ACE_DEFAULT_GET_ENV_METHOD ()) + +/// Declare a ACE_ENV_TYPE argument that is not used by the +/// function definition. +/** + * Similar to ACE_ENV_ARG_DECL, but the formal parameter name is dropped to + * avoid warnings about unused parameters + */ +#define ACE_ENV_ARG_DECL_NOT_USED \ + ACE_ENV_EMIT_CODE2(ACE_ENV_EMIT_DUMMY, \ + ACE_ENV_TYPE &) + +/// Declare a ACE_ENV_TYPE argument for methods that do not take any other +/// parameters +#define ACE_ENV_SINGLE_ARG_DECL \ + ACE_ENV_EMIT_CODE(ACE_ENV_TYPE &ACE_TRY_ENV) + +/// Declare a ACE_ENV_TYPE argument with a default value for methods that +/// do not take any other parameters. The name of the default environment +/// getter method needs to be changed when switching ORBs or when used in +/// another application. +#define ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS \ + ACE_ENV_EMIT_CODE(ACE_ENV_TYPE &ACE_TRY_ENV = \ + ACE_DEFAULT_GET_ENV_METHOD ()) + +/// Declare a ACE_ENV_TYPE argument for methods which don't use it. +#define ACE_ENV_SINGLE_ARG_DECL_NOT_USED \ + ACE_ENV_EMIT_CODE(ACE_ENV_TYPE &) + +/// Use the ACE_ENV_TYPE argument in a nested call +#define ACE_ENV_ARG_PARAMETER \ + ACE_ENV_EMIT_CODE2(ACE_ENV_EMIT_DUMMY, \ + ACE_TRY_ENV) + +/// Use the ACE_ENV_TYPE argument in a nested call, assuming that the +/// called function takes only the ACE_TRY_ENV argument. +#define ACE_ENV_SINGLE_ARG_PARAMETER \ + ACE_ENV_EMIT_CODE(ACE_TRY_ENV) + +/// Eliminate unused argument warnings about ACE_TRY_ENV +#define ACE_ENV_ARG_NOT_USED \ + ACE_ENV_EMIT_CODE(ACE_UNUSED_ARG(ACE_TRY_ENV)) +//@} + +#if !defined (ACE_USES_NATIVE_EXCEPTIONS) +// This thing can be moved above when we drop ACE_ENV_BKWD_COMPAT. +# define ACE_ENV_RAISE(ex) ACE_TRY_ENV.exception (ex) +#else +# define ACE_ENV_RAISE(ex) (ex)->_raise () +#endif /* ACE_USES_NATIVE_EXCEPTIONS */ + +// ============================================================ + +// Print out a TAO exception. This is not CORBA compliant. +# define ACE_PRINT_TAO_EXCEPTION(EX,INFO) \ + EX._tao_print_exception (INFO) + +// Print out a CORBA exception. There is not portable way to +// dump a CORBA exception. If you are using other ORB implementation, +// redefine the macro to get what you want. +# if !defined ACE_PRINT_EXCEPTION +# define ACE_PRINT_EXCEPTION(EX,INFO) ACE_PRINT_TAO_EXCEPTION(EX,INFO) +# endif /* ACE_PRINT_EXCEPTION */ + +#endif /* !ACE_LACKS_DEPRECATED_MACROS */ + +#include /**/ "ace/post.h" + +#endif /* ACE_CORBA_MACROS_H */ diff --git a/dep/ACE_wrappers/ace/Cache_Map_Manager_T.cpp b/dep/ACE_wrappers/ace/Cache_Map_Manager_T.cpp new file mode 100644 index 00000000000..f87031eb0d7 --- /dev/null +++ b/dep/ACE_wrappers/ace/Cache_Map_Manager_T.cpp @@ -0,0 +1,420 @@ +// $Id: Cache_Map_Manager_T.cpp 80826 2008-03-04 14:51:23Z wotte $ + +#ifndef ACE_CACHE_MAP_MANAGER_T_CPP +#define ACE_CACHE_MAP_MANAGER_T_CPP + +#include "ace/Cache_Map_Manager_T.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +#pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/Log_Msg.h" +#include "ace/Malloc_Base.h" + +#if !defined (__ACE_INLINE__) +#include "ace/Cache_Map_Manager_T.inl" +#endif /* __ACE_INLINE__ */ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_ALLOC_HOOK_DEFINE(ACE_Cache_Map_Manager) + +ACE_ALLOC_HOOK_DEFINE(ACE_Cache_Map_Iterator) + +ACE_ALLOC_HOOK_DEFINE(ACE_Cache_Map_Reverse_Iterator) + +#define ACE_T1 class KEY, class VALUE, class CMAP_TYPE, class ITERATOR_IMPL, class REVERSE_ITERATOR_IMPL, class CACHING_STRATEGY, class ATTRIBUTES +#define ACE_T2 KEY, VALUE, CMAP_TYPE, ITERATOR_IMPL, REVERSE_ITERATOR_IMPL, CACHING_STRATEGY, ATTRIBUTES + +template +ACE_Cache_Map_Manager::ACE_Cache_Map_Manager (CACHING_STRATEGY &caching_s, + size_t size, + ACE_Allocator *alloc) + : caching_strategy_ (caching_s) +{ + if (this->open (size, alloc) == -1) + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("%p\n"), + ACE_TEXT ("ACE_Cache_Map_Manager::ACE_Cache_Map_Manager"))); + +} + +template +ACE_Cache_Map_Manager::~ACE_Cache_Map_Manager (void) +{ + this->close (); +} + +template int +ACE_Cache_Map_Manager::open (size_t length, + ACE_Allocator *alloc) +{ + return this->map_.open (length, + alloc); +} + +template int +ACE_Cache_Map_Manager::close (void) +{ + return this->map_.close (); +} + +template int +ACE_Cache_Map_Manager::bind (const KEY &key, + const VALUE &value) +{ + // Insert an entry which has the and the which + // is the combination of the and the attributes of the + // caching strategy. + CACHE_VALUE cache_value (value, + this->caching_strategy_.attributes ()); + + int bind_result = this->map_.bind (key, + cache_value); + + if (bind_result != -1) + { + + int result = this->caching_strategy_.notify_bind (bind_result, + cache_value.second ()); + + if (result == -1) + { + + this->map_.unbind (key); + + // Unless the notification goes thru the bind operation is + // not complete. + bind_result = -1; + + } + + } + + return bind_result; +} + + +template int +ACE_Cache_Map_Manager::rebind (const KEY &key, + const VALUE &value) +{ + CACHE_VALUE cache_value (value, + this->caching_strategy_.attributes ()); + + int rebind_result = this->map_.rebind (key, + cache_value); + + if (rebind_result != -1) + { + + int result = this->caching_strategy_.notify_rebind (rebind_result, + cache_value.second ()); + + if (result == -1) + { + + // Make sure the unbind operation is done only when the + // notification fails after a bind which is denoted by + // rebind_result = 0 + if (rebind_result == 0) + this->map_.unbind (key); + + // Unless the notification goes thru the rebind operation is + // not complete. + rebind_result = -1; + + } + + } + + return rebind_result; +} + + +template int +ACE_Cache_Map_Manager::rebind (const KEY &key, + const VALUE &value, + VALUE &old_value) +{ + CACHE_VALUE cache_value (value, + this->caching_strategy_.attributes ()); + + CACHE_VALUE old_cache_value (old_value, + this->caching_strategy_.attributes ()); + + int rebind_result = this->map_.rebind (key, + cache_value, + old_cache_value); + + if (rebind_result != -1) + { + + int result = this->caching_strategy_.notify_rebind (rebind_result, + cache_value.second ()); + + if (result == -1) + { + + // Make sure the unbind operation is done only when the + // notification fails after a bind which is denoted by + // rebind_result = 0 + if (rebind_result == 0) + this->map_.unbind (key); + + // Unless the notification goes thru the rebind operation is + // not complete. + rebind_result = -1; + + } + else + { + + old_value = old_cache_value.first (); + + } + + } + + return rebind_result; +} + +template int +ACE_Cache_Map_Manager::rebind (const KEY &key, + const VALUE &value, + KEY &old_key, + VALUE &old_value) +{ + CACHE_VALUE cache_value (value, + this->caching_strategy_.attributes ()); + + CACHE_VALUE old_cache_value (old_value, + this->caching_strategy_.attributes ()); + + int rebind_result = this->map_.rebind (key, + cache_value, + old_key, + old_cache_value); + + if (rebind_result != -1) + { + + int result = this->caching_strategy_.notify_rebind (rebind_result, + cache_value.second ()); + + if (result == -1) + { + + // Make sure the unbind operation is done only when the + // notification fails after a bind which is denoted by + // rebind_result = 0 + if (rebind_result == 0) + this->map_.unbind (key); + + // Unless the notification goes thru the rebind operation is + // not complete. + rebind_result = -1; + + } + else + { + + old_value = old_cache_value.first (); + + } + + } + + return rebind_result; +} + +template int +ACE_Cache_Map_Manager::trybind (const KEY &key, + VALUE &value) +{ + CACHE_VALUE cache_value (value, + this->caching_strategy_.attributes ()); + + int trybind_result = this->map_.trybind (key, + cache_value); + + if (trybind_result != -1) + { + + int result = this->caching_strategy_.notify_trybind (trybind_result, + cache_value.second ()); + + if (result == -1) + { + + // If the entry has got inserted into the map, it is removed + // due to failure. + if (trybind_result == 0) + this->map_.unbind (key); + + trybind_result = -1; + + } + else + { + + // If an attempt is made to bind an existing entry the value + // is overwritten with the value from the map. + if (trybind_result == 1) + value = cache_value.first (); + + } + + } + + return trybind_result; +} + +template int +ACE_Cache_Map_Manager::find (const KEY &key, + VALUE &value) +{ + // Lookup the key and populate the . + CACHE_VALUE cache_value; + + int find_result = this->map_.find (key, + cache_value); + + if (find_result != -1) + { + + int result = this->caching_strategy_.notify_find (find_result, + cache_value.second ()); + + // Unless the find and notification operations go thru, this + // method is not successful. + if (result == -1) + find_result = -1; + else + { + + // Since the has now changed after the + // notification, we need to bind to the map again. + int rebind_result = this->map_.rebind (key, + cache_value); + if (rebind_result == -1) + find_result = -1; + else + value = cache_value.first (); + + } + + } + + return find_result; +} + +template int +ACE_Cache_Map_Manager::find (const KEY &key) +{ + // Lookup the key and populate the . + CACHE_VALUE cache_value; + + int find_result = this->map_.find (key, + cache_value); + + if (find_result != -1) + { + + int result = this->caching_strategy_.notify_find (find_result, + cache_value.second ()); + + // Unless the find and notification operations go thru, this + // method is not successful. + if (result == -1) + find_result = -1; + else + { + + // Since the has now changed after the + // notification, we need to bind to the map again. + int rebind_result = this->map_.rebind (key, + cache_value); + + if (rebind_result == -1) + find_result = -1; + + } + + } + + return find_result; +} + + +template int +ACE_Cache_Map_Manager::unbind (const KEY &key) +{ + // Remove the entry from the cache. + CACHE_VALUE cache_value; + + int unbind_result = this->map_.unbind (key, + cache_value); + + if (unbind_result != -1) + { + + int result = this->caching_strategy_.notify_unbind (unbind_result, + cache_value.second ()); + + if (result == -1) + unbind_result = -1; + + } + + return unbind_result; +} + +template int +ACE_Cache_Map_Manager::unbind (const KEY &key, + VALUE &value) +{ + // Remove the entry from the cache. + CACHE_VALUE cache_value; + + int unbind_result = this->map_.unbind (key, + cache_value); + + if (unbind_result != -1) + { + + int result = this->caching_strategy_.notify_unbind (unbind_result, + cache_value.second ()); + + if (result == -1) + unbind_result = -1; + else + value = cache_value.first (); + + } + + return unbind_result; +} + +template void +ACE_Cache_Map_Manager::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + this->map_.dump (); + + this->caching_strategy_.dump (); +#endif /* ACE_HAS_DUMP */ +} + +#undef ACE_T1 +#undef ACE_T2 + +template +ACE_Cache_Map_Iterator::~ACE_Cache_Map_Iterator (void) +{ +} + +ACE_END_VERSIONED_NAMESPACE_DECL + +#endif /* ACE_CACHE_MAP_MANAGER_T_CPP */ diff --git a/dep/ACE_wrappers/ace/Cache_Map_Manager_T.h b/dep/ACE_wrappers/ace/Cache_Map_Manager_T.h new file mode 100644 index 00000000000..060a8b38aac --- /dev/null +++ b/dep/ACE_wrappers/ace/Cache_Map_Manager_T.h @@ -0,0 +1,405 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Cache_Map_Manager_T.h + * + * $Id: Cache_Map_Manager_T.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Kirthika Parameswaran + */ +//============================================================================= + +#ifndef ACE_CACHE_MAP_MANAGER_T_H +#define ACE_CACHE_MAP_MANAGER_T_H + +#include /**/ "ace/pre.h" + +#include /**/ "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/Default_Constants.h" +#include "ace/Global_Macros.h" +#include "ace/Pair_T.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +// Forward declaration. +class ACE_Allocator; + +#define ACE_Cache_Map_Iterator ACMI +#define ACE_Cache_Map_Reverse_Iterator ACMRI + +template +class ACE_Cache_Map_Iterator; + +template +class ACE_Cache_Map_Reverse_Iterator; + +// For linkers that cant grok long names. +#define ACE_Cache_Map_Manager ACMM + +/** + * @class ACE_Cache_Map_Manager + * + * @brief Defines a abstraction that will purge entries from a map. + * + * The will manage the map it contains + * and provide purging on demand from the map. The strategy for + * caching is decided by the user and provided to the Cache + * Manager. The Cache Manager acts as a agent and communicates + * between the Map and the Strategy for purging entries from the + * map. + * No locking mechanism provided since locking at this level + * isn't efficient. Locking has to be provided by the + * application. + */ +template +class ACE_Cache_Map_Manager +{ +public: + + // = Traits. + typedef KEY key_type; + typedef VALUE mapped_type; + typedef CMAP_TYPE map_type; + typedef CACHING_STRATEGY caching_strategy_type; + + typedef ITERATOR_IMPL ITERATOR_IMPLEMENTATION; + typedef REVERSE_ITERATOR_IMPL REVERSE_ITERATOR_IMPLEMENTATION; + + friend class ACE_Cache_Map_Iterator; + friend class ACE_Cache_Map_Reverse_Iterator; + + // = ACE-style iterator typedefs. + typedef ACE_Cache_Map_Iterator + ITERATOR; + typedef ACE_Cache_Map_Reverse_Iterator + REVERSE_ITERATOR; + + // = STL-style iterator typedefs. + typedef ITERATOR + iterator; + typedef REVERSE_ITERATOR + reverse_iterator; + + /** + * The actual value mapped to the key in the map. The + * are used by the strategy and is transparent to the user of this + * class. + */ + typedef ACE_Pair CACHE_VALUE; + + // = Initialization and termination methods. + + /// Initialize a with and + /// @a size entries. + ACE_Cache_Map_Manager (CACHING_STRATEGY &caching_strategy, + size_t size = ACE_DEFAULT_MAP_SIZE, + ACE_Allocator *alloc = 0); + + /// Close down a and release dynamically allocated + /// resources. + virtual ~ACE_Cache_Map_Manager (void); + + /// Initialize a cache with size @a length. + int open (size_t length = ACE_DEFAULT_MAP_SIZE, + ACE_Allocator *alloc = 0); + + /// Close down a cache and release dynamically allocated resources. + int close (void); + + /** + * Associate @a key with @a value. If @a key is already in the CMAP_TYPE + * then the ENTRY is not changed. Returns 0 if a new entry is bound + * successfully, returns 1 if an attempt is made to bind an existing + * entry, and returns -1 if failures occur. + */ + int bind (const KEY &key, + const VALUE &value); + + /** + * Lookup entry in the cache. If it is not found, returns -1. + * If the @a key is located in the CMAP_TYPE object, the CACHING_STRATEGY is + * notified of it via notify_find (int result, ATTRIBUTES &attribute). + * If notify_find also returns 0 (success), then this function returns + * 0 (success) and sets the cached value in @a value. + */ + int find (const KEY &key, + VALUE &value); + + /** + * Lookup entry in the cache. If it is not found, returns -1. + * If the @a key is located in the CMAP_TYPE object, the CACHING_STRATEGY is + * notified of it via notify_find (int result, ATTRIBUTES &attribute). + * If notify_find also returns 0 (success), then this function returns + * 0 (success). + */ + int find (const KEY &key); + + /** + * Reassociate the @a key with @a value. If the @a key already exists + * in the cache then returns 1, on a new bind returns 0 and returns + * -1 in case of any failures. + */ + int rebind (const KEY &key, + const VALUE &value); + + /** + * Reassociate @a key with @a value, storing the old value into the + * "out" parameter @a old_value. The function fails if @a key is not + * in the cache for caches that do not allow user specified keys. + * However, for caches that allow user specified keys, if the key is + * not in the cache, a new @a key / @a value association is created. + */ + int rebind (const KEY &key, + const VALUE &value, + VALUE &old_value); + + /** + * Reassociate @a key with @a value, storing the old key and value + * into the "out" parameters @a old_key and @a old_value. The + * function fails if @a key is not in the cache for caches that do + * not allow user specified keys. However, for caches that allow + * user specified keys, if the key is not in the cache, a new + * @a key / @a value association is created. + */ + int rebind (const KEY &key, + const VALUE &value, + KEY &old_key, + VALUE &old_value); + + /** + * Associate @a key with @a value if and only if @a key is not in the + * cache. If @a key is already in the cache, then the @a value + * parameter is overwritten with the existing value in the + * cache. Returns 0 if a new @a key / @a value association is created. + * Returns 1 if an attempt is made to bind an existing entry. This + * function fails for maps that do not allow user specified keys. + */ + int trybind (const KEY &key, + VALUE &value); + + /// Remove @a key from the cache. + int unbind (const KEY &key); + + /// Remove @a key from the cache, and return the @a value associated with + /// @a key. + int unbind (const KEY &key, + VALUE &value); + + /// Remove entries from the cache depending upon the strategy. + int purge (void); + + /// Return the current size of the cache. + size_t current_size (void) const; + + /// Return the total size of the cache. + size_t total_size (void) const; + + /// Dumps the state of the object. + void dump (void) const; + + // = STL styled iterator factory functions. + + /// Return forward iterator. + ITERATOR begin (void); + ITERATOR end (void); + + /// Return reverse iterator. + REVERSE_ITERATOR rbegin (void); + REVERSE_ITERATOR rend (void); + + /// The map managed by the Cache_Map_Manager. + CMAP_TYPE &map (void); + + /// The caching strategy used on the cache. + CACHING_STRATEGY &caching_strategy (void); + +protected: + + /// The underlying map which needs to be cached. + CMAP_TYPE map_; + + /// The strategy to be followed for caching entries in the map. + CACHING_STRATEGY &caching_strategy_; + +private: + + // = Disallow these operations. + ACE_UNIMPLEMENTED_FUNC (void operator= (const ACE_Cache_Map_Manager &)) + ACE_UNIMPLEMENTED_FUNC (ACE_Cache_Map_Manager (const ACE_Cache_Map_Manager &)) + +}; + +/** + * @class ACE_Cache_Map_Iterator + * + * @brief Defines a iterator for the Cache_Map_Manager. + * + * Implementation to be provided by the iterator of the map + * managed by the ACE_Cache_Map_Manager. + */ +template +class ACE_Cache_Map_Iterator +{ + +public: + + // = Traits. + /// The actual value mapped to the key in the cache. The + /// are used by the strategy and is transperant to the cache user. + typedef ACE_Reference_Pair + value_type; + typedef ACE_Pair + CACHE_VALUE; + + // = Initialisation and termination methods. + + ACE_Cache_Map_Iterator (const IMPLEMENTATION &iterator_impl); + + /// Copy constructor. + ACE_Cache_Map_Iterator (const ACE_Cache_Map_Iterator &rhs); + + virtual ~ACE_Cache_Map_Iterator (void); + + // = Iteration methods. + + /// assignment operator. + ACE_Cache_Map_Iterator &operator= + (const ACE_Cache_Map_Iterator &rhs); + + /// Comparision operators. + bool operator== (const ACE_Cache_Map_Iterator &rhs) const; + bool operator!= (const ACE_Cache_Map_Iterator &rhs) const; + + /// Returns a reference to the internal element @c this is pointing + /// to. + ACE_Reference_Pair operator* (void) const; + + // = STL styled iteration, compare, and reference functions. + + /// Prefix advance + ACE_Cache_Map_Iterator &operator++ (void); + + /// Postfix advance. + ACE_Cache_Map_Iterator operator++ (int); + + /// Prefix reverse. + ACE_Cache_Map_Iterator &operator-- (void); + + /// Postfix reverse. + ACE_Cache_Map_Iterator operator-- (int); + + /// Returns the iterator of the internal map in the custody of the + /// Cache_Map_Manager. + IMPLEMENTATION &iterator_implementation (void); + + /// Dump the state of an object. + void dump (void) const; + + /// Declare the dynamic allocation hooks. + ACE_ALLOC_HOOK_DECLARE; + +protected: + /// The actual iterator which iterates internally on the map + /// belonging to the Cache_Map_Manager. + IMPLEMENTATION iterator_implementation_; +}; + +/** + * @class ACE_Cache_Map_Reverse_Iterator + * + * @brief Defines a reverse iterator for the Cache_Map_Manager. + * + * Implementation to be provided by the reverse iterator of the map + * managed by thr Cache_Map_manager. + */ +template +class ACE_Cache_Map_Reverse_Iterator +{ +public: + + // = Traits. + /// The actual value mapped to the key in the cache. The + /// are used by the strategy and is transperant to the cache user. + typedef ACE_Reference_Pair value_type; + typedef ACE_Pair CACHE_VALUE; + + // = Initialisation and termination methods. + + ACE_Cache_Map_Reverse_Iterator (const REVERSE_IMPLEMENTATION &iterator_impl); + + /// Copy constructor. + ACE_Cache_Map_Reverse_Iterator (const ACE_Cache_Map_Reverse_Iterator &rhs); + + ~ACE_Cache_Map_Reverse_Iterator (void); + + // = Iteration methods. + + /// Assignment operator. + ACE_Cache_Map_Reverse_Iterator &operator= + (const ACE_Cache_Map_Reverse_Iterator &rhs); + + /// Comparision operators. + bool operator== (const ACE_Cache_Map_Reverse_Iterator &rhs) const; + bool operator!= (const ACE_Cache_Map_Reverse_Iterator &rhs) const; + + /// Returns a reference to the internal element @c this is pointing + /// to. + ACE_Reference_Pair operator* (void) const; + + // = STL styled iteration, compare, and reference functions. + + /// Prefix advance + ACE_Cache_Map_Reverse_Iterator &operator++ (void); + + /// Postfix advance. + ACE_Cache_Map_Reverse_Iterator operator++ (int); + + /// Prefix reverse. + ACE_Cache_Map_Reverse_Iterator &operator-- (void); + + /// Postfix reverse. + ACE_Cache_Map_Reverse_Iterator operator-- (int); + + /// Returns the iterator of the internal map in the custody of the + /// Cache_Map_Manager. + REVERSE_IMPLEMENTATION &iterator_implementation (void); + + /// Dump the state of an object. + void dump (void) const; + + /// Declare the dynamic allocation hooks. + ACE_ALLOC_HOOK_DECLARE; + +protected: + /// The actual iterator which iterates internally on the map + /// belonging to the Cache_Map_Manager. + REVERSE_IMPLEMENTATION reverse_iterator_implementation_; +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +#include "ace/Cache_Map_Manager_T.inl" +#endif /* __ACE_INLINE__ */ + +#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) +#include "ace/Cache_Map_Manager_T.cpp" +#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ + +#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) +#pragma implementation ("Cache_Map_Manager_T.cpp") +#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ + +#include /**/ "ace/post.h" + +#endif /* ACE_CACHE_MAP_MANAGER_T_H */ diff --git a/dep/ACE_wrappers/ace/Cache_Map_Manager_T.inl b/dep/ACE_wrappers/ace/Cache_Map_Manager_T.inl new file mode 100644 index 00000000000..bcd48bd33e9 --- /dev/null +++ b/dep/ACE_wrappers/ace/Cache_Map_Manager_T.inl @@ -0,0 +1,245 @@ +// -*- C++ -*- +// +//$Id: Cache_Map_Manager_T.inl 80826 2008-03-04 14:51:23Z wotte $ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +template ACE_INLINE int +ACE_Cache_Map_Manager::purge (void) +{ + return this->caching_strategy ().caching_utility ().clear_cache (this->map_, + this->caching_strategy ().purge_percent ()); +} + +template ACE_INLINE size_t +ACE_Cache_Map_Manager::current_size (void) const +{ + return this->map_.current_size (); +} + +template ACE_INLINE size_t +ACE_Cache_Map_Manager::total_size (void) const +{ + return this->map_.total_size (); +} + +template ACE_INLINE CMAP_TYPE & +ACE_Cache_Map_Manager::map (void) +{ + return this->map_; +} + +template ACE_INLINE CACHING_STRATEGY & +ACE_Cache_Map_Manager::caching_strategy (void) +{ + return this->caching_strategy_; +} + +template ACE_INLINE ACE_Cache_Map_Iterator +ACE_Cache_Map_Manager::begin (void) +{ + return ITERATOR (this->map_.begin ()); +} + +template ACE_INLINE ACE_Cache_Map_Iterator +ACE_Cache_Map_Manager::end (void) +{ + return ITERATOR (this->map_.end ()); +} + +template ACE_INLINE ACE_Cache_Map_Reverse_Iterator +ACE_Cache_Map_Manager::rbegin (void) +{ + return REVERSE_ITERATOR (this->map_.rbegin ()); +} +template ACE_INLINE ACE_Cache_Map_Reverse_Iterator +ACE_Cache_Map_Manager::rend (void) +{ + return REVERSE_ITERATOR (this->map_.rend ()); +} + +//////////////////////////////////////////////////////////////////////////////// + +template ACE_INLINE +ACE_Cache_Map_Iterator::ACE_Cache_Map_Iterator (const ACE_Cache_Map_Iterator &rhs) + : iterator_implementation_ (rhs.iterator_implementation_) +{ +} + +template ACE_INLINE ACE_Cache_Map_Iterator & +ACE_Cache_Map_Iterator::operator= (const ACE_Cache_Map_Iterator &rhs) +{ + this->iterator_implementation_ = rhs.iterator_implementation_; + return *this; +} + +template ACE_INLINE bool +ACE_Cache_Map_Iterator::operator== (const ACE_Cache_Map_Iterator &rhs) const +{ + return this->iterator_implementation_ == rhs.iterator_implementation_; +} + +template ACE_INLINE bool +ACE_Cache_Map_Iterator::operator!= (const ACE_Cache_Map_Iterator &rhs) const +{ + return this->iterator_implementation_ != rhs.iterator_implementation_; +} + +template ACE_INLINE ACE_Reference_Pair +ACE_Cache_Map_Iterator::operator* (void) const +{ + value_type retn ((*this->iterator_implementation_).ext_id_, + (*this->iterator_implementation_).int_id_.first ()); + return retn; +} + +template ACE_INLINE +ACE_Cache_Map_Iterator & +ACE_Cache_Map_Iterator::operator++ (void) +{ + ++this->iterator_implementation_; + return *this; +} + +template ACE_INLINE +ACE_Cache_Map_Iterator +ACE_Cache_Map_Iterator::operator++ (int) +{ + ACE_Cache_Map_Iterator retn = *this; + ++this->iterator_implementation_; + return retn; +} + +template ACE_INLINE +ACE_Cache_Map_Iterator & +ACE_Cache_Map_Iterator::operator-- (void) +{ + --this->iterator_implementation_; + return *this; +} + +template ACE_INLINE +ACE_Cache_Map_Iterator +ACE_Cache_Map_Iterator::operator-- (int) +{ + ACE_Cache_Map_Iterator retn = *this; + --this->iterator_implementation_; + return retn; +} + +template ACE_INLINE void +ACE_Cache_Map_Iterator::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + this->iterator_implementation_.dump (); +#endif /* ACE_HAS_DUMP */ +} + +template ACE_INLINE +ACE_Cache_Map_Iterator::ACE_Cache_Map_Iterator (const IMPLEMENTATION &iterator_impl) + : iterator_implementation_ (iterator_impl) +{ +} + +template ACE_INLINE IMPLEMENTATION & +ACE_Cache_Map_Iterator::iterator_implementation (void) +{ + return this->iterator_implementation_; +} + +//////////////////////////////////////////////////////////////////////////////// + +template ACE_INLINE +ACE_Cache_Map_Reverse_Iterator::ACE_Cache_Map_Reverse_Iterator (const ACE_Cache_Map_Reverse_Iterator &rhs) + : reverse_iterator_implementation_ (rhs.reverse_iterator_implementation_) +{ +} + +template ACE_INLINE +ACE_Cache_Map_Reverse_Iterator::~ACE_Cache_Map_Reverse_Iterator (void) +{ +} + +template ACE_INLINE ACE_Cache_Map_Reverse_Iterator & +ACE_Cache_Map_Reverse_Iterator::operator= (const ACE_Cache_Map_Reverse_Iterator &rhs) +{ + this->reverse_iterator_implementation_ = rhs.reverse_iterator_implementation_; + return *this; +} + +template ACE_INLINE bool +ACE_Cache_Map_Reverse_Iterator::operator== (const ACE_Cache_Map_Reverse_Iterator &rhs) const +{ + return this->reverse_iterator_implementation_ == rhs.reverse_iterator_implementation_; +} + +template ACE_INLINE bool +ACE_Cache_Map_Reverse_Iterator::operator!= (const ACE_Cache_Map_Reverse_Iterator &rhs) const +{ + return this->reverse_iterator_implementation_ != rhs.reverse_iterator_implementation_; +} + +template ACE_INLINE ACE_Reference_Pair +ACE_Cache_Map_Reverse_Iterator::operator* (void) const +{ + value_type retv ((*this->reverse_iterator_implementation_).ext_id_, + (*this->reverse_iterator_implementation_).int_id_.first ()); + return retv; +} + +template ACE_INLINE +ACE_Cache_Map_Reverse_Iterator & +ACE_Cache_Map_Reverse_Iterator::operator++ (void) +{ + ++this->reverse_iterator_implementation_; + return *this; +} + +template ACE_INLINE +ACE_Cache_Map_Reverse_Iterator +ACE_Cache_Map_Reverse_Iterator::operator++ (int) +{ + ACE_Cache_Map_Reverse_Iterator retn = *this; + ++this->reverse_iterator_implementation_; + return retn; +} + +template ACE_INLINE +ACE_Cache_Map_Reverse_Iterator & +ACE_Cache_Map_Reverse_Iterator::operator-- (void) +{ + --this->reverse_iterator_implementation_; + return *this; +} + +template ACE_INLINE +ACE_Cache_Map_Reverse_Iterator +ACE_Cache_Map_Reverse_Iterator::operator-- (int) +{ + ACE_Cache_Map_Reverse_Iterator retn = *this; + --this->reverse_iterator_implementation_; + return retn; +} + + +template ACE_INLINE void +ACE_Cache_Map_Reverse_Iterator::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + this->reverse_iterator_implementation_.dump (); +#endif /* ACE_HAS_DUMP */ +} + +template ACE_INLINE +ACE_Cache_Map_Reverse_Iterator::ACE_Cache_Map_Reverse_Iterator (const REVERSE_IMPLEMENTATION &iterator_impl) + : reverse_iterator_implementation_(iterator_impl) +{ +} + +template ACE_INLINE REVERSE_IMPLEMENTATION & +ACE_Cache_Map_Reverse_Iterator::iterator_implementation (void) +{ + return this->reverse_iterator_implementation_; +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Cached_Connect_Strategy_T.cpp b/dep/ACE_wrappers/ace/Cached_Connect_Strategy_T.cpp new file mode 100644 index 00000000000..1f9ad0abde6 --- /dev/null +++ b/dep/ACE_wrappers/ace/Cached_Connect_Strategy_T.cpp @@ -0,0 +1,734 @@ +//$Id: Cached_Connect_Strategy_T.cpp 80826 2008-03-04 14:51:23Z wotte $ + +#ifndef ACE_CACHED_CONNECT_STRATEGY_T_CPP +#define ACE_CACHED_CONNECT_STRATEGY_T_CPP + +#include "ace/Cached_Connect_Strategy_T.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +#pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/ACE.h" +#include "ace/Service_Repository.h" +#include "ace/Service_Types.h" +#include "ace/Thread_Manager.h" +#include "ace/WFMO_Reactor.h" +#include "ace/Pair_T.h" + +#define ACE_T1 class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class CACHING_STRATEGY, class ATTRIBUTES, class MUTEX +#define ACE_T2 SVC_HANDLER, ACE_PEER_CONNECTOR_2, CACHING_STRATEGY, ATTRIBUTES, MUTEX + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +template +ACE_Cached_Connect_Strategy_Ex::ACE_Cached_Connect_Strategy_Ex +(CACHING_STRATEGY &caching_s, + ACE_Creation_Strategy *cre_s, + ACE_Concurrency_Strategy *con_s, + ACE_Recycling_Strategy *rec_s, + MUTEX *lock, + int delete_lock) + : CCSBASE (cre_s, con_s, rec_s, lock, delete_lock), + connection_cache_ (caching_s) +{ + if (this->open (cre_s, con_s, rec_s) == -1) + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("%p\n"), + ACE_TEXT ("ACE_Cached_Connect_Strategy_Ex\n"))); +} + +template +ACE_Cached_Connect_Strategy_Ex::~ACE_Cached_Connect_Strategy_Ex (void) +{ + cleanup (); +} + + +template int +ACE_Cached_Connect_Strategy_Ex::check_hint_i +(SVC_HANDLER *&sh, + const ACE_PEER_CONNECTOR_ADDR &remote_addr, + ACE_Time_Value *timeout, + const ACE_PEER_CONNECTOR_ADDR &local_addr, + int reuse_addr, + int flags, + int perms, + ACE_Hash_Map_Entry, ACE_Pair > *&entry, + int &found) +{ + ACE_UNUSED_ARG (remote_addr); + ACE_UNUSED_ARG (timeout); + ACE_UNUSED_ARG (local_addr); + ACE_UNUSED_ARG (reuse_addr); + ACE_UNUSED_ARG (flags); + ACE_UNUSED_ARG (perms); + + found = 0; + + // Get the recycling act for the svc_handler + CONNECTION_CACHE_ENTRY *possible_entry = + (CONNECTION_CACHE_ENTRY *) sh->recycling_act (); + + // Check to see if the hint svc_handler has been closed down + if (possible_entry->ext_id_.recycle_state () == ACE_RECYCLABLE_CLOSED) + { + // If close, decrement refcount + if (possible_entry->ext_id_.decrement () == 0) + { + // If refcount goes to zero, close down the svc_handler + possible_entry->int_id_.first ()->recycler (0, 0); + possible_entry->int_id_.first ()->close (); + this->purge_i (possible_entry); + } + + // Hint not successful + found = 0; + + // Reset hint + sh = 0; + } + + // If hint is not closed, see if it is connected to the correct + // address and is recyclable + else if ((possible_entry->ext_id_.recycle_state () == ACE_RECYCLABLE_IDLE_AND_PURGABLE || + possible_entry->ext_id_.recycle_state () == ACE_RECYCLABLE_IDLE_BUT_NOT_PURGABLE) && + possible_entry->ext_id_.subject () == remote_addr) + { + // Hint successful + found = 1; + + // Tell the that it should prepare itself for + // being recycled. + this->prepare_for_recycling (sh); + + // + // Update the caching attributes directly since we don't do a + // find() on the cache map. + // + + // Indicates successful find. + int find_result = 0; + + int result = this->caching_strategy ().notify_find (find_result, + possible_entry->int_id_.second ()); + + if (result == -1) + return result; + } + else + { + // This hint will not be used. + possible_entry->ext_id_.decrement (); + + // Hint not successful + found = 0; + + // If is not connected to the correct address or is busy, + // we will not use it. + sh = 0; + } + + if (found) + entry = possible_entry; + + return 0; +} + +template int +ACE_Cached_Connect_Strategy_Ex::find_or_create_svc_handler_i +(SVC_HANDLER *&sh, + const ACE_PEER_CONNECTOR_ADDR &remote_addr, + ACE_Time_Value *timeout, + const ACE_PEER_CONNECTOR_ADDR &local_addr, + int reuse_addr, + int flags, + int perms, + ACE_Hash_Map_Entry, ACE_Pair > *&entry, + int &found) +{ + REFCOUNTED_HASH_RECYCLABLE_ADDRESS search_addr (remote_addr); + + // Try to find the address in the cache. Only if we don't find it + // do we create a new and connect it with the server. + while (this->find (search_addr, entry) != -1) + { + // We found a cached svc_handler. + // Get the cached + sh = entry->int_id_.first (); + + // Is the connection clean? + int state_result = + ACE::handle_ready (sh->peer ().get_handle (), + &ACE_Time_Value::zero, + 1, // read ready + 0, // write ready + 1);// exception ready + + if (state_result == 1) + { + + if (sh->close () == -1) + return -1; + + sh = 0; + + // Cycle it once again.. + } + else if ((state_result == -1) && (errno == ETIME)) + { + // Found!!! + // Set the flag + found = 1; + + // Tell the that it should prepare itself for + // being recycled. + if (this->prepare_for_recycling (sh) == -1) + return -1; + + return 0; + } + else + { + return -1; + } + } + + // Not found... + + // Set the flag + found = 0; + + // We need to use a temporary variable here since we are not + // allowed to change because other threads may use this + // when we let go of the lock during the OS level connect. + // + // Note that making a new svc_handler, connecting remotely, + // binding to the map, and assigning of the hint and recycler + // should be atomic to the outside world. + SVC_HANDLER *potential_handler = 0; + + // Create a new svc_handler + if (this->make_svc_handler (potential_handler) == -1) + return -1; + + // Connect using the svc_handler. + if (this->cached_connect (potential_handler, + remote_addr, + timeout, + local_addr, + reuse_addr, + flags, + perms) == -1) + { + // Close the svc handler. + potential_handler->close (0); + + return -1; + } + else + { + // Insert the new SVC_HANDLER instance into the cache. + if (this->connection_cache_.bind (search_addr, + potential_handler, + entry) == -1) + { + // Close the svc handler and reset . + potential_handler->close (0); + + return -1; + } + + // Everything succeeded as planned. Assign to + // . + sh = potential_handler; + + // Set the recycler and the recycling act + + this->assign_recycler (sh, this, entry); + } + + return 0; +} + +template int +ACE_Cached_Connect_Strategy_Ex::cached_connect (SVC_HANDLER *&sh, + const ACE_PEER_CONNECTOR_ADDR &remote_addr, + ACE_Time_Value *timeout, + const ACE_PEER_CONNECTOR_ADDR &local_addr, + int reuse_addr, + int flags, + int perms) +{ + // Actively establish the connection. This is a timed blocking + // connect. + if (this->new_connection (sh, + remote_addr, + timeout, + local_addr, + reuse_addr, + flags, + perms) == -1) + { + // If connect() failed because of timeouts, we have to reject + // the connection entirely. This is necessary since currently + // there is no way for the non-blocking connects to complete and + // for the to notify the cache of the completion of + // connect(). + + if (errno == EWOULDBLOCK || errno == ETIMEDOUT) + errno = ENOTSUP; + else if (ACE::out_of_handles (errno) || errno == EADDRINUSE) + { + // If the connect failed due to the process running out of + // file descriptors then, auto_purging of some connections + // are done from the CONNECTION_CACHE. This frees the + // descriptors which get used in the connect process and + // hence the same method is called again! + if (this->purge_connections () == -1) + return -1; + + // Try connecting again. + if (this->new_connection (sh, + remote_addr, + timeout, + local_addr, + reuse_addr, + flags, + perms) == -1) + { + if (errno == EWOULDBLOCK || errno == ETIMEDOUT) + errno = ENOTSUP; + return -1; + } + } + else + { + return -1; + } + } + + return 0; + +} + + +template int +ACE_Cached_Connect_Strategy_Ex::connect_svc_handler_i +(SVC_HANDLER *&sh, + const ACE_PEER_CONNECTOR_ADDR &remote_addr, + ACE_Time_Value *timeout, + const ACE_PEER_CONNECTOR_ADDR &local_addr, + int reuse_addr, + int flags, + int perms, + int& found) +{ + CONNECTION_CACHE_ENTRY *entry = 0; + + // Check if the user passed a hint svc_handler + if (sh != 0) + { + int result = this->check_hint_i (sh, + remote_addr, + timeout, + local_addr, + reuse_addr, + flags, + perms, + entry, + found); + if (result != 0) + return result; + } + + // If not found + if (!found) + { + int result = this->find_or_create_svc_handler_i (sh, + remote_addr, + timeout, + local_addr, + reuse_addr, + flags, + perms, + entry, + found); + + if (result != 0) + return result; + + // Increment the refcount + entry->ext_id_.increment (); + } + + // For all successful cases: mark the in the cache + // as being . Therefore recyclable is BUSY. + entry->ext_id_.recycle_state (ACE_RECYCLABLE_BUSY); + + return 0; +} + + +template int +ACE_Cached_Connect_Strategy_Ex::cache_i (const void *recycling_act) +{ + // The wonders and perils of ACT + CONNECTION_CACHE_ENTRY *entry = (CONNECTION_CACHE_ENTRY *) recycling_act; + + // Mark the in the cache as not being . + // Therefore recyclable is IDLE. + entry->ext_id_.recycle_state (ACE_RECYCLABLE_IDLE_AND_PURGABLE); + + return 0; +} + +template int +ACE_Cached_Connect_Strategy_Ex::recycle_state_i (const void *recycling_act, + ACE_Recyclable_State new_state) +{ + // The wonders and perils of ACT + CONNECTION_CACHE_ENTRY *entry = (CONNECTION_CACHE_ENTRY *) recycling_act; + + // Mark the in the cache as not being . + // Therefore recyclable is IDLE. + entry->ext_id_.recycle_state (new_state); + + return 0; +} + +template ACE_Recyclable_State +ACE_Cached_Connect_Strategy_Ex::recycle_state_i (const void *recycling_act) const +{ + // The wonders and perils of ACT + CONNECTION_CACHE_ENTRY *entry = (CONNECTION_CACHE_ENTRY *) recycling_act; + + // Mark the in the cache as not being . + // Therefore recyclable is IDLE. + return entry->ext_id_.recycle_state (); +} + +template int +ACE_Cached_Connect_Strategy_Ex::purge_i (const void *recycling_act) +{ + // The wonders and perils of ACT + CONNECTION_CACHE_ENTRY *entry = (CONNECTION_CACHE_ENTRY *) recycling_act; + + return this->connection_cache_.unbind (entry); +} + + +template int +ACE_Cached_Connect_Strategy_Ex::mark_as_closed_i (const void *recycling_act) +{ + // The wonders and perils of ACT + CONNECTION_CACHE_ENTRY *entry = (CONNECTION_CACHE_ENTRY *) recycling_act; + + // Mark the in the cache as CLOSED. + entry->ext_id_.recycle_state (ACE_RECYCLABLE_CLOSED); + + return 0; +} + +template int +ACE_Cached_Connect_Strategy_Ex::cleanup_hint_i (const void *recycling_act, + void **act_holder) +{ + // Reset the <*act_holder> in the confines and protection of the + // lock. + if (act_holder) + *act_holder = 0; + + // The wonders and perils of ACT + CONNECTION_CACHE_ENTRY *entry = (CONNECTION_CACHE_ENTRY *) recycling_act; + + // Decrement the refcount on the . + int refcount = entry->ext_id_.decrement (); + + // If the svc_handler state is closed and the refcount == 0, call + // close() on svc_handler. + if (entry->ext_id_.recycle_state () == ACE_RECYCLABLE_CLOSED && + refcount == 0) + { + entry->int_id_.first ()->recycler (0, 0); + entry->int_id_.first ()->close (); + this->purge_i (entry); + } + + return 0; +} + +template int +ACE_Cached_Connect_Strategy_Ex::purge_connections (void) +{ + return this->connection_cache_.purge (); +} + +template CACHING_STRATEGY & +ACE_Cached_Connect_Strategy_Ex::caching_strategy (void) +{ + return this->connection_cache_.caching_strategy (); +} + +template int +ACE_Cached_Connect_Strategy_Ex::find (ACE_Refcounted_Hash_Recyclable &search_addr, + ACE_Hash_Map_Entry, ACE_Pair > *&entry) +{ + typedef ACE_Hash_Map_Bucket_Iterator, + ACE_Hash, + ACE_Equal_To, + ACE_Null_Mutex> + CONNECTION_CACHE_BUCKET_ITERATOR; + + CONNECTION_CACHE_BUCKET_ITERATOR iterator (this->connection_cache_.map (), + search_addr); + + CONNECTION_CACHE_BUCKET_ITERATOR end (this->connection_cache_.map (), + search_addr, + 1); + + for (; + iterator != end; + ++iterator) + { + REFCOUNTED_HASH_RECYCLABLE_ADDRESS &addr = (*iterator).ext_id_; + + if (addr.recycle_state () != ACE_RECYCLABLE_IDLE_AND_PURGABLE && + addr.recycle_state () != ACE_RECYCLABLE_IDLE_BUT_NOT_PURGABLE) + continue; + + if (addr.subject () != search_addr.subject ()) + continue; + + entry = &(*iterator); + + // + // Update the caching attributes directly since we don't do a + // find() on the cache map. + // + + // Indicates successful find. + int find_result = 0; + + int result = this->caching_strategy ().notify_find (find_result, + entry->int_id_.second ()); + + if (result == -1) + return result; + + return 0; + } + + return -1; +} + +template void +ACE_Cached_Connect_Strategy_Ex::cleanup (void) +{ + // Excluded other threads from changing the cache while we cleanup + ACE_GUARD (MUTEX, ace_mon, *this->lock_); + + // Close down all cached service handlers. + typename CONNECTION_CACHE::ITERATOR iter = this->connection_cache_.begin (); + while (iter != this->connection_cache_.end ()) + { + if ((*iter).second () != 0) + { + // save entry for future use + CONNECTION_CACHE_ENTRY *entry = (CONNECTION_CACHE_ENTRY *) + (*iter).second ()->recycling_act (); + + // close handler + (*iter).second ()->recycler (0, 0); + (*iter).second ()->close (); + + // remember next iter + typename CONNECTION_CACHE::ITERATOR next_iter = iter; + ++next_iter; + + // purge the item from the hash + this->purge_i (entry); + + // assign next iter + iter = next_iter; + } + else + ++iter; + } +} + +ACE_ALLOC_HOOK_DEFINE(ACE_Cached_Connect_Strategy_Ex) +///////////////////////////////////////////////////////////////////////// + +template +ACE_Bounded_Cached_Connect_Strategy::ACE_Bounded_Cached_Connect_Strategy +(size_t max_size, + CACHING_STRATEGY &caching_s, + ACE_Creation_Strategy *cre_s, + ACE_Concurrency_Strategy *con_s, + ACE_Recycling_Strategy *rec_s, + MUTEX *lock, + int delete_lock) + : CCSEBASE (caching_s, cre_s, con_s, rec_s, lock, delete_lock), + max_size_ (max_size) +{ +} + +template +ACE_Bounded_Cached_Connect_Strategy::~ACE_Bounded_Cached_Connect_Strategy(void) +{ +} + +template +int +ACE_Bounded_Cached_Connect_Strategy::find_or_create_svc_handler_i +(SVC_HANDLER *&sh, + const ACE_PEER_CONNECTOR_ADDR &remote_addr, + ACE_Time_Value *timeout, + const ACE_PEER_CONNECTOR_ADDR &local_addr, + int reuse_addr, + int flags, + int perms, + ACE_Hash_Map_Entry, + ACE_Pair > *&entry, + int &found) +{ + + REFCOUNTED_HASH_RECYCLABLE_ADDRESS search_addr (remote_addr); + + // Try to find the address in the cache. Only if we don't find it + // do we create a new and connect it with the server. + while (this->find (search_addr, entry) != -1) + { + // We found a cached svc_handler. + // Get the cached + sh = entry->int_id_.first (); + + // Is the connection clean? + int state_result= ACE::handle_ready (sh->peer ().get_handle (), + &ACE_Time_Value::zero, + 1, // read ready + 0, // write ready + 1);// exception ready + + if (state_result == 1) + { + // The connection was disconnected during idle. + // close the svc_handler down. + if (sh->close () == -1) + { + ACE_ASSERT (0); + return -1; + } + sh = 0; + // and rotate once more... + } + else if ((state_result == -1) && (errno == ETIME)) + { + // Found!!! + // Set the flag + found = 1; + + // Tell the that it should prepare itself for + // being recycled. + if (this->prepare_for_recycling (sh) == -1) + { + ACE_ASSERT (0); + return -1; + } + + return 0; + } + else // some other return value or error... + { + ACE_ASSERT (0); // just to see it coming + + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("(%t)ACE_Bounded_Cached_Connect_Strategy<>::") + ACE_TEXT ("find_or_create_svc_handler_i - ") + ACE_TEXT ("error polling server socket state.\n"))); + + return -1; + } + } + + // Not found... + + // Set the flag + found = 0; + + // Check the limit of handlers... + if ((this->max_size_ > 0) && + (this->connection_cache_.current_size () >= this->max_size_)) + { + // Try to purge idle connections + if (this->purge_connections () == -1) + return -1; + + // Check limit again. + if (this->connection_cache_.current_size () >= this->max_size_) + // still too much! + return -1; + + // OK, we have room now... + } + + // We need to use a temporary variable here since we are not + // allowed to change because other threads may use this + // when we let go of the lock during the OS level connect. + // + // Note that making a new svc_handler, connecting remotely, + // binding to the map, and assigning of the hint and recycler + // should be atomic to the outside world. + SVC_HANDLER *potential_handler = 0; + + // Create a new svc_handler + if (this->make_svc_handler (potential_handler) == -1) + return -1; + + // Connect using the svc_handler. + if (this->cached_connect (potential_handler, + remote_addr, + timeout, + local_addr, + reuse_addr, + flags, + perms) == -1) + { + // Close the svc handler. + potential_handler->close (0); + return -1; + } + else + { + // Insert the new SVC_HANDLER instance into the cache. + if (this->connection_cache_.bind (search_addr, + potential_handler, + entry) == -1) + { + // Close the svc handler and reset . + potential_handler->close (0); + + return -1; + } + + // Everything succeeded as planned. Assign to + // . + sh = potential_handler; + + // Set the recycler and the recycling act + this->assign_recycler (sh, this, entry); + } + + return 0; +} + +ACE_ALLOC_HOOK_DEFINE(ACE_Bounded_Cached_Connect_Strategy) + +ACE_END_VERSIONED_NAMESPACE_DECL + +#undef ACE_T1 +#undef ACE_T2 + +#endif /* ACE_CACHED_CONNECT_STRATEGY_T_CPP */ diff --git a/dep/ACE_wrappers/ace/Cached_Connect_Strategy_T.h b/dep/ACE_wrappers/ace/Cached_Connect_Strategy_T.h new file mode 100644 index 00000000000..15517ddc38c --- /dev/null +++ b/dep/ACE_wrappers/ace/Cached_Connect_Strategy_T.h @@ -0,0 +1,262 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Cached_Connect_Strategy_T.h + * + * $Id: Cached_Connect_Strategy_T.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Kirthika Parameswaran + */ +//============================================================================= + +#ifndef CACHED_CONNECT_STRATEGY_T_H +#define CACHED_CONNECT_STRATEGY_T_H + +#include /**/ "ace/pre.h" + +#include /**/ "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/Strategies_T.h" +#include "ace/Hash_Cache_Map_Manager_T.h" +#include "ace/Caching_Strategies_T.h" +#include "ace/Functor_T.h" +#include "ace/Pair_T.h" + +// For linkers which cant grok long names... +#define ACE_Cached_Connect_Strategy_Ex ACCSE + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +/** + * @class ACE_Cached_Connect_Strategy_Ex + * + * @brief A connection strategy which caches connections to peers + * (represented by SVC_HANDLER instances), thereby allowing + * subsequent re-use of unused, but available, connections. + * + * is intended to be used as a + * plug-in connection strategy for ACE_Strategy_Connector. + * It's added value is re-use of established connections and + * tweaking the role of the cache as per the caching strategy. + */ +template +class ACE_Cached_Connect_Strategy_Ex + : public ACE_Cached_Connect_Strategy +{ +public: + /// Constructor + ACE_Cached_Connect_Strategy_Ex ( + CACHING_STRATEGY &caching_s, + ACE_Creation_Strategy *cre_s = 0, + ACE_Concurrency_Strategy *con_s = 0, + ACE_Recycling_Strategy *rec_s = 0, + MUTEX *lock = 0, + int delete_lock = 0); + + /// Destructor + virtual ~ACE_Cached_Connect_Strategy_Ex (void); + + /// Explicit purging of connection entries from the connection cache. + virtual int purge_connections (void); + + /// Mark as closed (non-locking version). This is used during the cleanup of the + /// connections purged. + virtual int mark_as_closed_i (const void *recycling_act); + + /** + * Since g++ version < 2.8 arent happy with templates, this special + * method had to be devised to avoid memory leaks and perform + * cleanup of the . + */ + void cleanup (void); + + // = Typedefs for managing the map + typedef ACE_Refcounted_Hash_Recyclable + REFCOUNTED_HASH_RECYCLABLE_ADDRESS; + typedef ACE_Hash_Cache_Map_Manager, + ACE_Equal_To, + CACHING_STRATEGY, + ATTRIBUTES> + CONNECTION_CACHE; + typedef typename CONNECTION_CACHE::CACHE_ENTRY CONNECTION_CACHE_ENTRY; + typedef typename CONNECTION_CACHE::key_type KEY; + typedef typename CONNECTION_CACHE::mapped_type VALUE; + + typedef ACE_Recyclable_Handler_Cleanup_Strategy, + ACE_Hash_Map_Manager_Ex, + ACE_Hash, + ACE_Equal_To, + MUTEX> > + CLEANUP_STRATEGY; + + typedef ACE_Cached_Connect_Strategy + CCSBASE; + + // = Accessor. + CACHING_STRATEGY &caching_strategy (void); + +protected: + + /// Find an idle handle. + int find (ACE_Refcounted_Hash_Recyclable &search_addr, + ACE_Hash_Map_Entry, ACE_Pair > *&entry); + + /// Remove from cache (non-locking version). + virtual int purge_i (const void *recycling_act); + + /// Add to cache (non-locking version). + virtual int cache_i (const void *recycling_act); + + /// Get/Set (non-locking version). + virtual int recycle_state_i (const void *recycling_act, + ACE_Recyclable_State new_state); + virtual ACE_Recyclable_State recycle_state_i (const void *recycling_act) const; + + /// Cleanup hint and reset <*act_holder> to zero if . + virtual int cleanup_hint_i (const void *recycling_act, + void **act_holder); + + // = Helpers + int check_hint_i (SVC_HANDLER *&sh, + const ACE_PEER_CONNECTOR_ADDR &remote_addr, + ACE_Time_Value *timeout, + const ACE_PEER_CONNECTOR_ADDR &local_addr, + int reuse_addr, + int flags, + int perms, + ACE_Hash_Map_Entry, ACE_Pair > *&entry, + int &found); + + virtual int find_or_create_svc_handler_i (SVC_HANDLER *&sh, + const ACE_PEER_CONNECTOR_ADDR &remote_addr, + ACE_Time_Value *timeout, + const ACE_PEER_CONNECTOR_ADDR &local_addr, + int reuse_addr, + int flags, + int perms, + ACE_Hash_Map_Entry, ACE_Pair > *&entry, + int &found); + + virtual int connect_svc_handler_i (SVC_HANDLER *&sh, + const ACE_PEER_CONNECTOR_ADDR &remote_addr, + ACE_Time_Value *timeout, + const ACE_PEER_CONNECTOR_ADDR &local_addr, + int reuse_addr, + int flags, + int perms, + int &found); + + /** + * Connection of the svc_handler with the remote host. This method + * also encapsulates the connection done with auto_purging under the + * hood. If the connect failed due to the process running out of + * file descriptors then, auto_purging of some connections are done + * from the CONNECTION_CACHE. This frees the descriptors which get + * used in the connect process and hence the connect operation can + * succeed. + */ + virtual int cached_connect (SVC_HANDLER *&sh, + const ACE_PEER_CONNECTOR_ADDR &remote_addr, + ACE_Time_Value *timeout, + const ACE_PEER_CONNECTOR_ADDR &local_addr, + int reuse_addr, + int flags, + int perms); + + /// Table that maintains the cache of connected SVC_HANDLERs. + CONNECTION_CACHE connection_cache_; +}; + +///////////////////////////////////////////////////////////////////////////// + +// For linkers which cant grok long names... +#define ACE_Bounded_Cached_Connect_Strategy ABCCS + +/** + * @class ACE_Bounded_Cached_Connect_Strategy + * + * @brief A connection strategy which caches connections to peers + * (represented by SVC_HANDLER instances), thereby allowing + * subsequent re-use of unused, but available, connections. + * This strategy should be used when the cache is bounded by + * maximum size. + * + * is intended to be used as a + * plug-in connection strategy for ACE_Strategy_Connector. + * It's added value is re-use of established connections and + * tweaking the role of the cache as per the caching strategy. + * Thanks to Edan Ayal for contributing this + * class and Susan Liebeskind for + * brainstorming about it. + */ +template +class ACE_Bounded_Cached_Connect_Strategy + : public ACE_Cached_Connect_Strategy_Ex +{ + + typedef ACE_Cached_Connect_Strategy_Ex + CCSEBASE; + + // = Typedefs for managing the map + typedef ACE_Refcounted_Hash_Recyclable + REFCOUNTED_HASH_RECYCLABLE_ADDRESS; + +public: + + /// Constructor + ACE_Bounded_Cached_Connect_Strategy (size_t max_size, + CACHING_STRATEGY &caching_s, + ACE_Creation_Strategy *cre_s = 0, + ACE_Concurrency_Strategy *con_s = 0, + ACE_Recycling_Strategy *rec_s = 0, + MUTEX *lock = 0, + int delete_lock = 0); + + /// Destructor + virtual ~ACE_Bounded_Cached_Connect_Strategy (void); + + /// Declare the dynamic allocation hooks. + ACE_ALLOC_HOOK_DECLARE; + +protected: + + virtual int find_or_create_svc_handler_i (SVC_HANDLER *&sh, + const ACE_PEER_CONNECTOR_ADDR &remote_addr, + ACE_Time_Value *timeout, + const ACE_PEER_CONNECTOR_ADDR &local_addr, + int reuse_addr, + int flags, + int perms, + ACE_Hash_Map_Entry, + ACE_Pair > *&entry, + int &found); + +protected: + + /// max items in the cache, used as a bound for the creation of svc_handlers. + size_t max_size_; +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) +#include "ace/Cached_Connect_Strategy_T.cpp" +#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ + +#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) +#pragma implementation ("Cached_Connect_Strategy_T.cpp") +#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ + +#include /**/ "ace/post.h" +#endif /* CACHED_CONNECT_STRATEGY_T_H */ diff --git a/dep/ACE_wrappers/ace/Caching_Strategies_T.cpp b/dep/ACE_wrappers/ace/Caching_Strategies_T.cpp new file mode 100644 index 00000000000..2b0fd4e764a --- /dev/null +++ b/dep/ACE_wrappers/ace/Caching_Strategies_T.cpp @@ -0,0 +1,59 @@ +//$Id: Caching_Strategies_T.cpp 80826 2008-03-04 14:51:23Z wotte $ + +#ifndef ACE_CACHING_STRATEGIES_T_CPP +#define ACECACHING_STRATEGIES_T_CPP + +#include "ace/Caching_Strategies_T.h" +#include "ace/Log_Msg.h" + +#if !defined (__ACE_INLINE__) +#include "ace/Caching_Strategies_T.inl" +#endif /* __ACE_INLINE__ */ + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +#pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +template +ACE_Caching_Strategy::~ACE_Caching_Strategy (void) +{ +} + +////////////////////////////////////////////////////////////////////////////////// + +template +ACE_LRU_Caching_Strategy::ACE_LRU_Caching_Strategy (void) + : timer_ (0), + purge_percent_ (10) +{ +} + +//////////////////////////////////////////////////////////////////////////////////////////////// + +template +ACE_LFU_Caching_Strategy::ACE_LFU_Caching_Strategy (void) + : purge_percent_ (10) +{ +} + +//////////////////////////////////////////////////////////////////////////////////////////////// + +template +ACE_FIFO_Caching_Strategy::ACE_FIFO_Caching_Strategy (void) + : order_ (0), + purge_percent_ (10) +{ +} + +//////////////////////////////////////////////////////////////////////////////////////////////// + +ACE_ALLOC_HOOK_DEFINE(ACE_LRU_Caching_Strategy) +ACE_ALLOC_HOOK_DEFINE(ACE_LFU_Caching_Strategy) +ACE_ALLOC_HOOK_DEFINE(ACE_FIFO_Caching_Strategy) +ACE_ALLOC_HOOK_DEFINE(ACE_Null_Caching_Strategy) + +ACE_END_VERSIONED_NAMESPACE_DECL + +#endif /* ACE_CACHING_STRATEGIES_T_CPP */ diff --git a/dep/ACE_wrappers/ace/Caching_Strategies_T.h b/dep/ACE_wrappers/ace/Caching_Strategies_T.h new file mode 100644 index 00000000000..e4b0817aa26 --- /dev/null +++ b/dep/ACE_wrappers/ace/Caching_Strategies_T.h @@ -0,0 +1,552 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Caching_Strategies_T.h + * + * $Id: Caching_Strategies_T.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Kirthika Parameswaran + */ +//============================================================================= + +#ifndef ACE_CACHING_STRATEGIES_H +#define ACE_CACHING_STRATEGIES_H + +#include /**/ "ace/pre.h" + +#include /**/ "ace/config-all.h" +#include "ace/Caching_Utility_T.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#if defined(_MSC_VER) +#pragma warning(disable:4503) +#endif /* _MSC_VER */ + +// For linkers that cant grok long names. +#define ACE_Caching_Strategy ACS + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +/** + * @class ACE_Caching_Strategy + * + * @brief This class is an abstract base class for a caching strategy. + * + * This class consists of all the interfaces a caching strategy should + * have and is used in association with the + * ACE_Caching_Strategy_Adaptor. + */ +template +class ACE_Caching_Strategy +{ +public: + /// Destructor. + virtual ~ACE_Caching_Strategy (void); + + /// Accessor method for the timer attributes. + virtual ATTRIBUTES attributes (void) = 0; + + /// Get the percentage of entries to purge. + virtual double purge_percent (void) = 0; + + /// Set the percentage of entries to purge. + virtual void purge_percent (double percentage) = 0; + + // = Strategy related Operations + + /// This method acts as a notification about the CONTAINERs bind + /// method call. + virtual int notify_bind (int result, + const ATTRIBUTES &attr) = 0; + + /// This method acts as a notification about the CONTAINERs find + /// method call + virtual int notify_find (int result, + ATTRIBUTES &attr) = 0; + + /// This method acts as a notification about the CONTAINERs unbind + /// method call + virtual int notify_unbind (int result, + const ATTRIBUTES &attr) = 0; + + /// This method acts as a notification about the CONTAINERs trybind + /// method call + virtual int notify_trybind (int result, + ATTRIBUTES &attr) = 0; + + /// This method acts as a notification about the CONTAINERs rebind + /// method call + virtual int notify_rebind (int result, + const ATTRIBUTES &attr) = 0; + + /// Purge the cache. + virtual CACHING_UTILITY &caching_utility (void) = 0; + + /// Dumps the state of the object. + virtual void dump (void) const = 0; +}; + +////////////////////////////////////////////////////////////////////////// + +#define ACE_Caching_Strategy_Adapter ACSA + +/** + * @class ACE_Caching_Strategy_Adapter + * + * @brief This class follows the Adaptor pattern and is used to provide + * External Polymorphism by deriving from ACE_Caching_Strategy. + * + * This class simply delegates all requests to the + * IMPLEMNETATION object within. This class should be passed in + * place of the the abstract base ACE_Caching_Strategy class as + * part of the External Polymorphism pattern. + */ +template +class ACE_Caching_Strategy_Adapter + : public ACE_Caching_Strategy +{ + +public: + + /// Constructor. + ACE_Caching_Strategy_Adapter (IMPLEMENTATION *implementation = 0, + bool delete_implementation = false); + + /// Destructor. + ~ACE_Caching_Strategy_Adapter (void); + + /// Accessor method for the timer attributes. + ATTRIBUTES attributes (void); + + /// Get the percentage of entries to purge. + double purge_percent (void); + + /// Set the percentage of entries to purge. + void purge_percent (double percentage); + + // = Strategy related Operations + + /// This method acts as a notification about the CONTAINERs bind + /// method call. + int notify_bind (int result, + const ATTRIBUTES &attr); + + /// This method acts as a notification about the CONTAINERs find + /// method call + int notify_find (int result, + ATTRIBUTES &attr); + + /// This method acts as a notification about the CONTAINERs unbind + /// method call + int notify_unbind (int result, + const ATTRIBUTES &attr); + + /// This method acts as a notification about the CONTAINERs trybind + /// method call + int notify_trybind (int result, + ATTRIBUTES &attr); + + /// This method acts as a notification about the CONTAINERs rebind + /// method call + int notify_rebind (int result, + const ATTRIBUTES &attr); + + /// Accessor to the implementation. + IMPLEMENTATION &implementation (void); + + /// Purge the cache. + CACHING_UTILITY &caching_utility (void); + + /// Dumps the state of the object. + void dump (void) const; + +private: + + /// Implementation class. + IMPLEMENTATION *implementation_; + + /// Do we need to delete the implementation? + bool delete_implementation_; +}; + +////////////////////////////////////////////////////////////////////////// +#define ACE_LRU_Caching_Strategy ALRU + +/** + * @class ACE_LRU_Caching_Strategy + * + * @brief Defines a Least Recently Used strategy which will decide on + * the item to be removed from the cache. + * + * This is a strategy which makes use of a virtual timer which + * is updated whenever an item is inserted or looked up in the + * container. When the need of purging entries arises, the items + * with the lowest timer values are removed. + * Explanation of the template parameter list: + * CONTAINER is any map with entries of type . + * The ATTRIBUTES are the deciding factor for purging of entries + * and should logically be included with the VALUE. Some ways of + * doing this are: As being a member of the VALUE or VALUE being + * ACE_Pair. The CACHING_UTILITY is the + * class which can be plugged in and which decides the entries + * to purge. + */ +template +class ACE_LRU_Caching_Strategy +{ +public: + + // Traits. + typedef ATTRIBUTES CACHING_ATTRIBUTES; + + // = Initialisation and termination. + + /** + * The is the map in which the entries reside. The + * timer attribute is initialed to zero in this constructor. And + * the field denotes the percentage of the entries + * in the cache which can be purged automagically and by default is + * set to 10%. + */ + ACE_LRU_Caching_Strategy (void); + + // = Operations of the strategy. + + /// Accessor method for the timer attributes. + ATTRIBUTES attributes (void); + + /// Get the percentage of entries to purge. + double purge_percent (void); + + /// Set the percentage of entries to purge. + void purge_percent (double percentage); + + // = Strategy related Operations + + /// This method acts as a notification about the CONTAINERs bind + /// method call. + int notify_bind (int result, + const ATTRIBUTES &attr); + + /// This method acts as a notification about the CONTAINERs find + /// method call + int notify_find (int result, + ATTRIBUTES &attr); + + /// This method acts as a notification about the CONTAINERs unbind + /// method call + int notify_unbind (int result, + const ATTRIBUTES &attr); + + + /// This method acts as a notification about the CONTAINERs trybind + /// method call + int notify_trybind (int result, + ATTRIBUTES &attr); + + /// This method acts as a notification about the CONTAINERs rebind + /// method call + int notify_rebind (int result, + const ATTRIBUTES &attr); + + /// Purge the cache. + CACHING_UTILITY &caching_utility (void); + + /// Dumps the state of the object. + void dump (void) const; + +private: + + /// This element is the one which is the deciding factor for purging + /// of an ITEM. + ATTRIBUTES timer_; + + /// The level about which the purging will happen automagically. + double purge_percent_; + + /// This is the helper class which will decide and expunge entries + /// from the cache. + CACHING_UTILITY caching_utility_; +}; + +////////////////////////////////////////////////////////////////////////// +#define ACE_LFU_Caching_Strategy ALFU + +/** + * @class ACE_LFU_Caching_Strategy + * + * @brief Defines a Least Frequently Used strategy for which will decide on + * the item to be removed from the cache. + * + * A attribute is tagged to each item which increments whenever + * the item is bound or looked up in the cache. Thus it denotes + * the frequency of use. According to the value of the attribute + * the item is removed from the CONTAINER i.e cache. + * Explanation of the template parameter list: + * CONTAINER is any map with entries of type . + * The ATTRIBUTES are the deciding factor for purging of entries + * and should logically be included with the VALUE. Some ways of + * doing this are: As being a member of the VALUE or VALUE being + * ACE_Pair. The CACHING_UTILITY is the + * class which can be plugged in and which decides the entries + * to purge. + */ +template +class ACE_LFU_Caching_Strategy +{ + +public: + + // Traits. + typedef ATTRIBUTES CACHING_ATTRIBUTES; + + // = Initialisation and termination methods. + + /** + * The is the map in which the entries reside. The + * timer attribute is initialed to zero in this constructor. And + * the field denotes the percentage of the entries + * in the cache which can be purged automagically and by default is + * set to 10%. + */ + ACE_LFU_Caching_Strategy (void); + + // = Strategy methods. + + /// Access the attributes. + ATTRIBUTES attributes (void); + + /// Get the percentage of entries to purge. + double purge_percent (void); + + /// Set the percentage of entries to purge. + void purge_percent (double percentage); + + // = Strategy related Operations + + /// This method acts as a notification about the CONTAINERs bind + /// method call. + int notify_bind (int result, + const ATTRIBUTES &attr); + + /// Lookup notification. + int notify_find (int result, + ATTRIBUTES &attr); + + /// This method acts as a notification about the CONTAINERs unbind + /// method call + int notify_unbind (int result, + const ATTRIBUTES &attr); + + /// This method acts as a notification about the CONTAINERs trybind + /// method call + int notify_trybind (int result, + ATTRIBUTES &attr); + + /// This method acts as a notification about the CONTAINERs rebind + /// method call + int notify_rebind (int result, + const ATTRIBUTES &attr); + + /// Purge the cache. + CACHING_UTILITY &caching_utility (void); + + /// Dumps the state of the object. + void dump (void) const; + +private: + + /// The level about which the purging will happen automagically. + double purge_percent_; + + /// This is the helper class which will decide and expunge entries + /// from the cache. + CACHING_UTILITY caching_utility_; +}; + +///////////////////////////////////////////////////////////// +#define ACE_FIFO_Caching_Strategy AFIFO + +/** + * @class ACE_FIFO_Caching_Strategy + * + * @brief The First In First Out strategy is implemented wherein each + * item is ordered. + * + * The order tag of each item is used to decide the item to be + * removed from the cache. The items with least order are removed. + * Explanation of the template parameter list: + * CONTAINER is any map with entries of type . + * The ATTRIBUTES are the deciding factor for purging of entries + * and should logically be included with the VALUE. Some ways of + * doing this are: As being a member of the VALUE or VALUE being + * ACE_Pair. The CACHING_UTILITY is the + * class which can be plugged in and which decides the entries + * to purge. + */ +template +class ACE_FIFO_Caching_Strategy +{ + +public: + + typedef ATTRIBUTES CACHING_ATTRIBUTES; + + // = Initialisation and termination. + + /** + * The is the map in which the entries reside. The + * timer attribute is initialed to zero in this constructor. And + * the field denotes the percentage of the entries + * in the cache which can be purged automagically and by default is + * set to 10%. + */ + ACE_FIFO_Caching_Strategy (void); + + // = Strategy methods. + + /// Accessor method. + ATTRIBUTES attributes (void); + + /// Get the percentage of entries to purge. + double purge_percent (void); + + /// Set the percentage of entries to purge. + void purge_percent (double percentage); + + // = Strategy related Operations + + /// Notification for an item getting bound into the cache. + int notify_bind (int result, + const ATTRIBUTES &attr); + + /// This method acts as a notification about the CONTAINERs find + /// method call + int notify_find (int result, + ATTRIBUTES &attr); + + /// This method acts as a notification about the CONTAINERs unbind + /// method call + int notify_unbind (int result, + const ATTRIBUTES &attr); + + /// This method acts as a notification about the CONTAINERs trybind + /// method call + int notify_trybind (int result, + ATTRIBUTES &attr); + + /// Notification for an item getting bound again into the cache. + int notify_rebind (int result, + const ATTRIBUTES &attr); + + /// Purge the cache. + CACHING_UTILITY &caching_utility (void); + + /// Dumps the state of the object. + void dump (void) const; + +private: + + /// The order is the deciding factor for the item to be removed from + /// the cache. + ATTRIBUTES order_; + + /// The level about which the purging will happen automagically. + double purge_percent_; + + /// This is the helper class which will decide and expunge entries + /// from the cache. + CACHING_UTILITY caching_utility_; +}; + +////////////////////////////////////////////////////////////////////// +#define ACE_Null_Caching_Strategy ANULL + +/** + * @class ACE_Null_Caching_Strategy + * + * @brief The is a special caching strategy which doesnt have the purging + * feature. + * + * No purging provided. To be used when purging might be too expensive + * an operation. + */ +template +class ACE_Null_Caching_Strategy +{ + +public: + + // = Traits. + typedef ATTRIBUTES CACHING_ATTRIBUTES; + + // = Strategy methods. All are NO_OP methods!!! + + /// Accessor method. + ATTRIBUTES attributes (void); + + /// Get the percentage of entries to purge. + double purge_percent (void); + + /// Set the percentage of entries to purge. + void purge_percent (double percentage); + + // = Strategy related Operations + + /// Notification for an item getting bound into the cache. + int notify_bind (int result, + const ATTRIBUTES &attr); + + /// This method acts as a notification about the CONTAINERs find + /// method call + int notify_find (int result, + ATTRIBUTES &attr); + + /// This method acts as a notification about the CONTAINERs unbind + /// method call + int notify_unbind (int result, + const ATTRIBUTES &attr); + + /// This method acts as a notification about the CONTAINERs trybind + /// method call + int notify_trybind (int result, + ATTRIBUTES &attr); + + /// Notification for an item getting bound again into the cache. + int notify_rebind (int result, + const ATTRIBUTES &attr); + + /// Purge the cache. + CACHING_UTILITY &caching_utility (void); + + /// Dumps the state of the object. + void dump (void) const; + +private: + + /// This is the helper class which will decide and expunge entries + /// from the cache. + CACHING_UTILITY caching_utility_; +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +#include "ace/Caching_Strategies_T.inl" +#endif /* __ACE_INLINE__ */ + +#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) +#include "ace/Caching_Strategies_T.cpp" +#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ + +#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) +#pragma implementation ("Caching_Strategies_T.cpp") +#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ + +#include /**/ "ace/post.h" + +#endif /* ACE_CACHING_STRATEGIES_H */ diff --git a/dep/ACE_wrappers/ace/Caching_Strategies_T.inl b/dep/ACE_wrappers/ace/Caching_Strategies_T.inl new file mode 100644 index 00000000000..41fa2d30301 --- /dev/null +++ b/dep/ACE_wrappers/ace/Caching_Strategies_T.inl @@ -0,0 +1,456 @@ +// -*-C++-*- +// +//$Id: Caching_Strategies_T.inl 80826 2008-03-04 14:51:23Z wotte $ + +////////////////////////////////////////////////////////////////////////////////// + +#include "ace/OS_Memory.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +template ACE_INLINE +ACE_Caching_Strategy_Adapter::ACE_Caching_Strategy_Adapter (IMPLEMENTATION *implementation, + bool delete_implementation) + : implementation_ (implementation), + delete_implementation_ (delete_implementation) +{ + if (this->implementation_ == 0) + { + ACE_NEW (this->implementation_, + IMPLEMENTATION); + this->delete_implementation_ = true; + } +} + +template ACE_INLINE +ACE_Caching_Strategy_Adapter::~ACE_Caching_Strategy_Adapter (void) +{ + if (this->delete_implementation_) + { + delete this->implementation_; + this->delete_implementation_ = false; + this->implementation_ = 0; + } +} + +template ACE_INLINE ATTRIBUTES +ACE_Caching_Strategy_Adapter::attributes (void) +{ + return this->implementation_->attributes (); +} + +template ACE_INLINE double +ACE_Caching_Strategy_Adapter::purge_percent (void) +{ + return this->implementation_->purge_percent (); +} + +template ACE_INLINE void +ACE_Caching_Strategy_Adapter::purge_percent (double percentage) +{ + this->implementation_->purge_percent (percentage); +} + +template ACE_INLINE int +ACE_Caching_Strategy_Adapter::notify_bind (int result, + const ATTRIBUTES &attr) +{ + return this->implementation_->notify_bind (result, + attr); +} + +template ACE_INLINE int +ACE_Caching_Strategy_Adapter::notify_find (int result, + ATTRIBUTES &attr) +{ + return this->implementation_->notify_find (result, + attr); +} + +template ACE_INLINE int +ACE_Caching_Strategy_Adapter::notify_unbind (int result, + const ATTRIBUTES &attr) +{ + return this->implementation_->notify_unbind (result, + attr); +} + +template ACE_INLINE int +ACE_Caching_Strategy_Adapter::notify_trybind (int result, + ATTRIBUTES &attr) +{ + return this->implementation_->notify_trybind (result, + attr); +} + +template ACE_INLINE int +ACE_Caching_Strategy_Adapter::notify_rebind (int result, + const ATTRIBUTES &attr) +{ + return this->implementation_->notify_rebind (result, + attr); +} + +template ACE_INLINE IMPLEMENTATION & +ACE_Caching_Strategy_Adapter::implementation (void) +{ + return *this->implementation_; +} + +template ACE_INLINE CACHING_UTILITY & +ACE_Caching_Strategy_Adapter::caching_utility (void) +{ + return this->implementation_->caching_utility (); +} + +template ACE_INLINE void +ACE_Caching_Strategy_Adapter::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + ACE_TRACE ("ACE_Caching_Strategy_Adapter::dump"); + + ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); + ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); +#endif /* ACE_HAS_DUMP */ +} + +////////////////////////////////////////////////////////////////////////////////// + +template ACE_INLINE ATTRIBUTES +ACE_LRU_Caching_Strategy::attributes (void) +{ + return this->timer_; +} + +template ACE_INLINE double +ACE_LRU_Caching_Strategy::purge_percent (void) +{ + return this->purge_percent_; +} + +template ACE_INLINE void +ACE_LRU_Caching_Strategy::purge_percent (double percentage) +{ + this->purge_percent_ = percentage; +} + +template ACE_INLINE int +ACE_LRU_Caching_Strategy::notify_bind ( + int result, + const ATTRIBUTES & /* attr */) +{ + if (result == 0) + ++this->timer_; + + return result; +} + +template ACE_INLINE int +ACE_LRU_Caching_Strategy::notify_find ( + int result, + ATTRIBUTES &attr) +{ + if (result == 0) + { + attr = this->timer_; + ++this->timer_; + } + + return result; +} + +template ACE_INLINE int +ACE_LRU_Caching_Strategy::notify_unbind ( + int result, + const ATTRIBUTES & /* attr */) +{ + return result; +} + +template ACE_INLINE int +ACE_LRU_Caching_Strategy::notify_trybind ( + int result, + ATTRIBUTES & /* attr */) +{ + return result; +} + +template ACE_INLINE int +ACE_LRU_Caching_Strategy::notify_rebind ( + int result, + const ATTRIBUTES & /* attr */) +{ + if (result == 0) + ++this->timer_; + + return result; +} + +template ACE_INLINE CACHING_UTILITY & +ACE_LRU_Caching_Strategy::caching_utility (void) +{ + return this->caching_utility_; +} + +template ACE_INLINE void +ACE_LRU_Caching_Strategy::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + ACE_TRACE ("ACE_LRU_Caching_Strategy::dump"); + + ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("timer_ = %d "), this->timer_)); + ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); +#endif /* ACE_HAS_DUMP */ +} + +////////////////////////////////////////////////////////////////////////////////// + +template ACE_INLINE ATTRIBUTES +ACE_LFU_Caching_Strategy::attributes (void) +{ + return 0; +} + +template ACE_INLINE double +ACE_LFU_Caching_Strategy::purge_percent (void) +{ + return this->purge_percent_; +} + +template ACE_INLINE void +ACE_LFU_Caching_Strategy::purge_percent (double percentage) +{ + this->purge_percent_ = percentage; +} + +template ACE_INLINE int +ACE_LFU_Caching_Strategy::notify_bind (int result, + const ATTRIBUTES & /* attr */) +{ + + return result; +} + +template ACE_INLINE int +ACE_LFU_Caching_Strategy::notify_find (int result, + ATTRIBUTES &attr) +{ + if (result == 0) + ++attr; + + return result; +} + +template ACE_INLINE int +ACE_LFU_Caching_Strategy::notify_trybind (int result, + ATTRIBUTES & /* attr */) +{ + return result; +} + +template ACE_INLINE int +ACE_LFU_Caching_Strategy::notify_rebind (int result, + const ATTRIBUTES & /* attr */) +{ + return result; +} + +template ACE_INLINE int +ACE_LFU_Caching_Strategy::notify_unbind (int result, + const ATTRIBUTES & /* attr */) +{ + return result; +} + +template ACE_INLINE CACHING_UTILITY & +ACE_LFU_Caching_Strategy::caching_utility (void) +{ + return this->caching_utility_; +} + +template ACE_INLINE void +ACE_LFU_Caching_Strategy::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + ACE_TRACE ("ACE_LFU_Caching_Strategy::dump"); + + ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); + ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); +#endif /* ACE_HAS_DUMP */ +} + +////////////////////////////////////////////////////////////////////////////////////// + +template ACE_INLINE ATTRIBUTES +ACE_FIFO_Caching_Strategy::attributes (void) +{ + return this->order_; +} + +template ACE_INLINE double +ACE_FIFO_Caching_Strategy::purge_percent (void) +{ + return this->purge_percent_; +} + +template ACE_INLINE void +ACE_FIFO_Caching_Strategy::purge_percent (double percentage) +{ + this->purge_percent_ = percentage; +} + +template ACE_INLINE int +ACE_FIFO_Caching_Strategy::notify_bind (int result, + const ATTRIBUTES &attr) +{ + ACE_UNUSED_ARG (attr); + + if (result == 0) + ++this->order_; + + return result; +} + +template ACE_INLINE int +ACE_FIFO_Caching_Strategy::notify_find (int result, + ATTRIBUTES &attr) +{ + ACE_UNUSED_ARG (attr); + + return result; +} + +template ACE_INLINE int +ACE_FIFO_Caching_Strategy::notify_unbind (int result, + const ATTRIBUTES &attr) +{ + ACE_UNUSED_ARG (attr); + + return result; +} + +template ACE_INLINE int +ACE_FIFO_Caching_Strategy::notify_trybind (int result, + ATTRIBUTES &attr) +{ + ACE_UNUSED_ARG (attr); + + return result; +} + +template ACE_INLINE int +ACE_FIFO_Caching_Strategy::notify_rebind (int result, + const ATTRIBUTES &attr) +{ + ACE_UNUSED_ARG (attr); + + if (result == 0) + ++this->order_; + + return result; +} + +template ACE_INLINE CACHING_UTILITY & +ACE_FIFO_Caching_Strategy::caching_utility (void) +{ + return this->caching_utility_; +} + +template ACE_INLINE void +ACE_FIFO_Caching_Strategy::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + ACE_TRACE ("ACE_FIFO_Caching_Strategy::dump"); + + ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("order_ = %d "), this->order_)); + ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); +#endif /* ACE_HAS_DUMP */ +} + +////////////////////////////////////////////////////////////////////////////////// + +template ACE_INLINE ATTRIBUTES +ACE_Null_Caching_Strategy::attributes (void) +{ + return 0; +} + +template ACE_INLINE double +ACE_Null_Caching_Strategy::purge_percent (void) +{ + return 0; +} + +template ACE_INLINE void +ACE_Null_Caching_Strategy::purge_percent (double percentage) +{ + ACE_UNUSED_ARG (percentage); +} + +template ACE_INLINE int +ACE_Null_Caching_Strategy::notify_bind (int result, + const ATTRIBUTES &attr) +{ + ACE_UNUSED_ARG (attr); + + return result; +} + +template ACE_INLINE int +ACE_Null_Caching_Strategy::notify_find (int result, + ATTRIBUTES &attr) +{ + ACE_UNUSED_ARG (attr); + + return result; +} + +template ACE_INLINE int +ACE_Null_Caching_Strategy::notify_unbind (int result, + const ATTRIBUTES &attr) +{ + ACE_UNUSED_ARG (attr); + + return result; +} + +template ACE_INLINE int +ACE_Null_Caching_Strategy::notify_trybind (int result, + ATTRIBUTES &attr) +{ + ACE_UNUSED_ARG (attr); + + return result; +} + +template ACE_INLINE int +ACE_Null_Caching_Strategy::notify_rebind (int result, + const ATTRIBUTES &attr) +{ + ACE_UNUSED_ARG (attr); + + return result; +} + +template ACE_INLINE CACHING_UTILITY & +ACE_Null_Caching_Strategy::caching_utility (void) +{ + return this->caching_utility_; +} + +template ACE_INLINE void +ACE_Null_Caching_Strategy::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + ACE_TRACE ("ACE_Null_Caching_Strategy::dump"); + + ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); + ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); +#endif /* ACE_HAS_DUMP */ +} + +ACE_END_VERSIONED_NAMESPACE_DECL + +////////////////////////////////////////////////////////////////////////////////// diff --git a/dep/ACE_wrappers/ace/Caching_Utility_T.cpp b/dep/ACE_wrappers/ace/Caching_Utility_T.cpp new file mode 100644 index 00000000000..a03a4575891 --- /dev/null +++ b/dep/ACE_wrappers/ace/Caching_Utility_T.cpp @@ -0,0 +1,499 @@ +// $Id: Caching_Utility_T.cpp 80826 2008-03-04 14:51:23Z wotte $ + +#ifndef ACE_CACHING_UTILITY_T_CPP +#define ACE_CACHING_UTILITY_T_CPP + +#include "ace/Caching_Utility_T.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +#pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/Min_Max.h" +#include "ace/OS_Memory.h" +#include "ace/Recyclable.h" + +////////////////////////////////////////////////////////////////////////////// + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +template +ACE_Pair_Caching_Utility::ACE_Pair_Caching_Utility (ACE_Cleanup_Strategy *cleanup_strategy, + int delete_cleanup_strategy) + : cleanup_strategy_ (cleanup_strategy), + delete_cleanup_strategy_ (delete_cleanup_strategy) +{ + if (cleanup_strategy == 0) + { + ACE_NEW (this->cleanup_strategy_, + CLEANUP_STRATEGY); + this->delete_cleanup_strategy_ = 1; + } +} + +template +ACE_Pair_Caching_Utility::~ACE_Pair_Caching_Utility (void) +{ + if (this->delete_cleanup_strategy_) + delete this->cleanup_strategy_; +} + +template int +ACE_Pair_Caching_Utility::clear_cache (CONTAINER &container, + double purge_percent) +{ + // Check that the purge_percent is non-zero. + if (purge_percent == 0) + return 0; + + // Get the number of entries in the container. + size_t current_map_size = container.current_size (); + + // Also whether the number of entries in the cache! + // Oops! then there is no way out but exiting. So return an error. + if (current_map_size == 0) + return 0; + + // Calculate the no of entries to remove from the cache depending + // upon the . + size_t const entries_to_remove + = ACE_MAX (static_cast (1), + static_cast (static_cast (purge_percent) + / 100 * current_map_size)); + KEY *key_to_remove = 0; + VALUE *value_to_remove = 0; + + for (size_t i = 0; i < entries_to_remove ; ++i) + { + this->minimum (container, + key_to_remove, + value_to_remove); + + // Simply verifying that the key is non-zero. + // This is important for strategies where the minimum + // entry cant be found due to constraints on the type of entry + // to remove. + if (key_to_remove == 0) + return 0; + + if (this->cleanup_strategy_->cleanup (container, + key_to_remove, + value_to_remove) == -1) + return -1; + + } + + return 0; +} + +template void +ACE_Pair_Caching_Utility::minimum (CONTAINER &container, + KEY *&key_to_remove, + VALUE *&value_to_remove) +{ + // Starting values. + ITERATOR iter = container.begin (); + ITERATOR end = container.end (); + ATTRIBUTES min = (*iter).int_id_.second (); + key_to_remove = &(*iter).ext_id_; + value_to_remove = &(*iter).int_id_; + + // The iterator moves thru the container searching for the entry + // with the lowest ATTRIBUTES. + for (++iter; + iter != end; + ++iter) + { + if (min > (*iter).int_id_.second ()) + { + // Ah! an item with lower ATTTRIBUTES... + min = (*iter).int_id_.second (); + key_to_remove = &(*iter).ext_id_; + value_to_remove = &(*iter).int_id_; + } + } +} + +//////////////////////////////////////////////////////////////////////////////////////////////////////// + +template +ACE_Recyclable_Handler_Caching_Utility::ACE_Recyclable_Handler_Caching_Utility (ACE_Cleanup_Strategy *cleanup_strategy, + int delete_cleanup_strategy) + : cleanup_strategy_ (cleanup_strategy), + delete_cleanup_strategy_ (delete_cleanup_strategy) +{ + if (cleanup_strategy == 0) + { + ACE_NEW (this->cleanup_strategy_, + CLEANUP_STRATEGY); + this->delete_cleanup_strategy_ = 1; + } +} + +template +ACE_Recyclable_Handler_Caching_Utility::~ACE_Recyclable_Handler_Caching_Utility (void) +{ + if (this->delete_cleanup_strategy_) + delete this->cleanup_strategy_; +} + +template int +ACE_Recyclable_Handler_Caching_Utility::clear_cache (CONTAINER &container, + double purge_percent) +{ + // Check that the purge_percent is non-zero. + if (purge_percent == 0) + return 0; + + // Get the number of entries in the container. + size_t current_map_size = container.current_size (); + + // Also whether the number of entries in the cache is just one! + // Oops! then there is no way out but exiting. So return an error. + // if (current_map_size <= 1) + if (current_map_size == 0) + return 0; + + // Calculate the no of entries to remove from the cache depending + // upon the . + size_t const entries_to_remove + = ACE_MAX (static_cast (1), + static_cast (static_cast (purge_percent) + / 100 * current_map_size)); + + KEY *key_to_remove = 0; + VALUE *value_to_remove = 0; + + for (size_t i = 0; i < entries_to_remove ; ++i) + { + this->minimum (container, + key_to_remove, + value_to_remove); + + // Simply verifying that the key is non-zero. + // This is important for strategies where the minimum + // entry cant be found due to constraints on the type of entry + // to remove. + if (key_to_remove == 0) + return 0; + + if (this->cleanup_strategy_->cleanup (container, + key_to_remove, + value_to_remove) == -1) + return -1; + } + + return 0; +} + +template void +ACE_Recyclable_Handler_Caching_Utility::minimum (CONTAINER &container, + KEY *&key_to_remove, + VALUE *&value_to_remove) +{ + // Starting values. + ITERATOR end = container.end (); + ITERATOR iter = container.begin (); + ATTRIBUTES min = (*iter).int_id_.second (); + key_to_remove = 0; + value_to_remove = 0; + // Found the minimum entry to be purged? + int found = 0; + + // The iterator moves thru the container searching for the entry + // with the lowest ATTRIBUTES. + for (; + iter != end; + ++iter) + { + // If the entry isnt IDLE_AND_PURGABLE continue until you reach + // the first entry which can be purged. This is the minimum with + // which you will compare the rest of the purgable entries. + if ((*iter).ext_id_.recycle_state () == ACE_RECYCLABLE_IDLE_AND_PURGABLE || + (*iter).ext_id_.recycle_state () == ACE_RECYCLABLE_PURGABLE_BUT_NOT_IDLE) + { + if (found == 0) + { + min = (*iter).int_id_.second (); + key_to_remove = &(*iter).ext_id_; + value_to_remove = &(*iter).int_id_; + found = 1; + } + else + { + // Ah! an entry with lower ATTTRIBUTES... + if (min > (*iter).int_id_.second ()) + { + min = (*iter).int_id_.second (); + key_to_remove = &(*iter).ext_id_; + value_to_remove = &(*iter).int_id_; + } + } + } + } +} + +//////////////////////////////////////////////////////////////////////////////// + +template +ACE_Refcounted_Recyclable_Handler_Caching_Utility::ACE_Refcounted_Recyclable_Handler_Caching_Utility (ACE_Cleanup_Strategy *cleanup_strategy, + int delete_cleanup_strategy) + : cleanup_strategy_ (cleanup_strategy), + delete_cleanup_strategy_ (delete_cleanup_strategy), + marked_as_closed_entries_ (0) +{ + if (cleanup_strategy == 0) + { + ACE_NEW (this->cleanup_strategy_, + CLEANUP_STRATEGY); + this->delete_cleanup_strategy_ = 1; + } +} + +template +ACE_Refcounted_Recyclable_Handler_Caching_Utility::~ACE_Refcounted_Recyclable_Handler_Caching_Utility (void) +{ + if (this->delete_cleanup_strategy_) + delete this->cleanup_strategy_; +} + +template int +ACE_Refcounted_Recyclable_Handler_Caching_Utility::clear_cache (CONTAINER &container, + double purge_percent) +{ + // Check that the purge_percent is non-zero. + if (purge_percent == 0) + return 0; + + // Get the number of entries in the container which can be considered for purging. + size_t const available_entries = + container.current_size () - this->marked_as_closed_entries_; + + // Also whether the number of entries in the cache zero. + // Oops! then there is no way out but exiting. + if (available_entries <= 0) + return 0; + + // Calculate the no of entries to remove from the cache depending + // upon the . + size_t entries_to_remove + = ACE_MAX (static_cast (1), + static_cast (static_cast (purge_percent) + / 100 * available_entries)); + + if (entries_to_remove >= available_entries || entries_to_remove == 0) + entries_to_remove = available_entries - 1; + + KEY *key_to_remove = 0; + VALUE *value_to_remove = 0; + + for (size_t i = 0; i < entries_to_remove ; ++i) + { + this->minimum (container, + key_to_remove, + value_to_remove); + + // Simply verifying that the key is non-zero. + // This is important for strategies where the minimum + // entry cant be found due to constraints on the type of entry + // to remove. + if (key_to_remove == 0) + return 0; + + if (this->cleanup_strategy_->cleanup (container, + key_to_remove, + value_to_remove) == -1) + return -1; + + ++this->marked_as_closed_entries_; + } + + return 0; +} + +template void +ACE_Refcounted_Recyclable_Handler_Caching_Utility::minimum (CONTAINER &container, + KEY *&key_to_remove, + VALUE *&value_to_remove) +{ + // Starting values. + ITERATOR end = container.end (); + ITERATOR iter = container.begin (); + ATTRIBUTES min = (*iter).int_id_.second (); + key_to_remove = 0; + value_to_remove = 0; + // Found the minimum entry to be purged? + int found = 0; + + // The iterator moves thru the container searching for the entry + // with the lowest ATTRIBUTES. + for (; + iter != end; + ++iter) + { + // If the entry isnt IDLE_AND_PURGABLE continue until you reach + // the first entry which can be purged. This is the minimum with + // which you will compare the rest of the purgable entries. + if ((*iter).ext_id_.recycle_state () == ACE_RECYCLABLE_IDLE_AND_PURGABLE || + (*iter).ext_id_.recycle_state () == ACE_RECYCLABLE_PURGABLE_BUT_NOT_IDLE) + { + if (found == 0) + { + min = (*iter).int_id_.second (); + key_to_remove = &(*iter).ext_id_; + value_to_remove = &(*iter).int_id_; + found = 1; + } + else + { + // Ah! an entry with lower ATTTRIBUTES... + if (min > (*iter).int_id_.second ()) + { + min = (*iter).int_id_.second (); + key_to_remove = &(*iter).ext_id_; + value_to_remove = &(*iter).int_id_; + } + } + } + } +} + +//////////////////////////////////////////////////////////////////////////////// + +template +ACE_Handler_Caching_Utility::ACE_Handler_Caching_Utility (ACE_Cleanup_Strategy *cleanup_strategy, + int delete_cleanup_strategy) + : cleanup_strategy_ (cleanup_strategy), + delete_cleanup_strategy_ (delete_cleanup_strategy) +{ + if (cleanup_strategy == 0) + { + ACE_NEW (this->cleanup_strategy_, + CLEANUP_STRATEGY); + this->delete_cleanup_strategy_ = 1; + } +} + +template +ACE_Handler_Caching_Utility::~ACE_Handler_Caching_Utility (void) +{ + if (this->delete_cleanup_strategy_) + delete this->cleanup_strategy_; +} + +template int +ACE_Handler_Caching_Utility::clear_cache (CONTAINER &container, + double purge_percent) +{ + // Check that the purge_percent is non-zero. + if (purge_percent == 0) + return 0; + + // Get the number of entries in the container. + size_t current_map_size = container.current_size (); + + // Also whether the number of entries in the cache is just one! + // Oops! then there is no way out but exiting. So return an error. + if (current_map_size == 0) + return 0; + + // Calculate the no of entries to remove from the cache depending + // upon the . + size_t entries_to_remove + = ACE_MAX (static_cast (1), + static_cast (static_cast (purge_percent) + / 100 * current_map_size)); + + KEY *key_to_remove = 0; + VALUE *value_to_remove = 0; + + for (size_t i = 0; i < entries_to_remove ; ++i) + { + this->minimum (container, + key_to_remove, + value_to_remove); + + if (this->cleanup_strategy_->cleanup (container, + key_to_remove, + value_to_remove) == -1) + return -1; + } + + return 0; +} + +template void +ACE_Handler_Caching_Utility::minimum (CONTAINER &container, + KEY *&key_to_remove, + VALUE *&value_to_remove) +{ + // Starting values. + ITERATOR iter = container.begin (); + ITERATOR end = container.end (); + ATTRIBUTES min = (*iter).int_id_->caching_attributes (); + key_to_remove = &(*iter).ext_id_; + value_to_remove = &(*iter).int_id_; + + // The iterator moves thru the container searching for the entry + // with the lowest ATTRIBUTES. + for (++iter; + iter != end; + ++iter) + { + if (min > (*iter).int_id_->caching_attributes () && + (*iter).int_id_->active () != 1) + { + // Ah! an item with lower ATTTRIBUTES... + min = (*iter).int_id_->caching_attributes (); + key_to_remove = &(*iter).ext_id_; + value_to_remove = &(*iter).int_id_; + } + } +} + +//////////////////////////////////////////////////////////////////////////////////////////////////////// + +template +ACE_Null_Caching_Utility::ACE_Null_Caching_Utility (ACE_Cleanup_Strategy *cleanup_strategy, + int delete_cleanup_strategy) + : cleanup_strategy_ (cleanup_strategy), + delete_cleanup_strategy_ (delete_cleanup_strategy) +{ + if (cleanup_strategy == 0) + { + ACE_NEW (this->cleanup_strategy_, + CLEANUP_STRATEGY); + this->delete_cleanup_strategy_ = 1; + } +} + +template +ACE_Null_Caching_Utility::~ACE_Null_Caching_Utility (void) +{ + if (this->delete_cleanup_strategy_) + delete this->cleanup_strategy_; +} + +template int +ACE_Null_Caching_Utility::clear_cache (CONTAINER &container, + double purge_percent) +{ + ACE_UNUSED_ARG (container); + ACE_UNUSED_ARG (purge_percent); + + return 0; +} + +template void +ACE_Null_Caching_Utility::minimum (CONTAINER &container, + KEY *&key_to_remove, + VALUE *&value_to_remove) +{ + ACE_UNUSED_ARG (container); + ACE_UNUSED_ARG (key_to_remove); + ACE_UNUSED_ARG (value_to_remove); +} + +ACE_END_VERSIONED_NAMESPACE_DECL + +#endif /* ACE_CACHING_UTILITY_T_CPP */ diff --git a/dep/ACE_wrappers/ace/Caching_Utility_T.h b/dep/ACE_wrappers/ace/Caching_Utility_T.h new file mode 100644 index 00000000000..5428682d099 --- /dev/null +++ b/dep/ACE_wrappers/ace/Caching_Utility_T.h @@ -0,0 +1,347 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Caching_Utility_T.h + * + * $Id: Caching_Utility_T.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Kirthika Parameswaran + */ +//============================================================================= + +#ifndef ACE_CACHING_UTILITY_H +#define ACE_CACHING_UTILITY_H + +#include /**/ "ace/pre.h" + +#include /**/ "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/Global_Macros.h" +#include "ace/Cleanup_Strategies_T.h" + +// For linkers that cant grok long names. +#define ACE_Pair_Caching_Utility APUTIL + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +/** + * @class ACE_Pair_Caching_Utility + * + * @brief Defines a helper class for the Caching Strategies. + * + * This class defines the methods commonly used by the different + * caching strategies. For instance: method which + * decides and purges the entry from the container. @note This + * class helps in the caching_strategies using a container + * containing entries of > + * kind. The attributes helps in deciding the entries to be + * purged. The Cleanup_Strategy is the callback class to which the + * entries to be cleaned up will be delegated. + */ +template +class ACE_Pair_Caching_Utility +{ +public: + + typedef ACE_Cleanup_Strategy CLEANUP_STRATEGY; + + /// Constructor. + ACE_Pair_Caching_Utility (ACE_Cleanup_Strategy *cleanup_strategy = 0, + int delete_cleanup_strategy = 0); + + /// Destructor. + ~ACE_Pair_Caching_Utility (void); + + /** + * Purge entries from the @a container. The Cleanup_Strategy will do the + * actual job of cleanup once the entries to be cleaned up are decided. + */ + int clear_cache (CONTAINER &container, + double purge_percent); + +protected: + + /// Find the entry with minimum caching attributes. + void minimum (CONTAINER &container, + KEY *&key_to_remove, + VALUE *&value_to_remove); + + /// The cleanup strategy which can be used to destroy the entries of + /// the container. + CLEANUP_STRATEGY *cleanup_strategy_; + + /// Whether the cleanup_strategy should be destroyed or not. + int delete_cleanup_strategy_; + + ACE_UNIMPLEMENTED_FUNC (void operator= (const ACE_Pair_Caching_Utility &)) + ACE_UNIMPLEMENTED_FUNC (ACE_Pair_Caching_Utility (const ACE_Pair_Caching_Utility &)) +}; + +//////////////////////////////////////////////////////////////////////////////// +#define ACE_Recyclable_Handler_Caching_Utility ARHUTIL + +/** + * @class ACE_Recyclable_Handler_Caching_Utility + * + * @brief Defines a helper class for the Caching Strategies. + * + * This class defines the methods commonly used by the different + * caching strategies. For instance: method which + * decides and purges the entry from the container. @note This + * class helps in the caching_strategies using a container + * containing entries of kind. The attributes + * helps in deciding the entries to be purged. The + * Cleanup_Strategy is the callback class to which the entries to + * be cleaned up will be delegated. + */ +template +class ACE_Recyclable_Handler_Caching_Utility +{ + +public: + + typedef ACE_Recyclable_Handler_Cleanup_Strategy CLEANUP_STRATEGY; + typedef ACE_Cleanup_Strategy CLEANUP_STRATEGY_BASE; + + /// Constructor. + ACE_Recyclable_Handler_Caching_Utility (ACE_Cleanup_Strategy *cleanup_strategy = 0, + int delete_cleanup_strategy = 0); + + /// Destructor. + ~ACE_Recyclable_Handler_Caching_Utility (void); + + /** + * Purge entries from the . The Cleanup_Strategy will do + * the actual job of cleanup once the entries to be cleaned up are + * decided. + */ + int clear_cache (CONTAINER &container, + double purge_percent); + +protected: + + /// Find the entry with minimum caching attributes. + void minimum (CONTAINER &container, + KEY *&key_to_remove, + VALUE *&value_to_remove); + + /// This is the default Cleanup Strategy for this utility. + CLEANUP_STRATEGY_BASE *cleanup_strategy_; + + /// Whether the cleanup_strategy should be destroyed or not. + int delete_cleanup_strategy_; + +private: + ACE_UNIMPLEMENTED_FUNC (void operator= (const ACE_Recyclable_Handler_Caching_Utility &)) + ACE_UNIMPLEMENTED_FUNC (ACE_Recyclable_Handler_Caching_Utility (const ACE_Recyclable_Handler_Caching_Utility &)) +}; + +/////////////////////////////////////////////////////////////////////////// +#define ACE_Refcounted_Recyclable_Handler_Caching_Utility ARRHUTIL + +/** + * @class ACE_Refcounted_Recyclable_Handler_Caching_Utility + * + * @brief Defines a helper class for the Caching Strategies. + * + * This class defines the methods commonly used by the different + * caching strategies. For instance: clear_cache () method which + * decides and purges the entry from the container. @note This + * class helps in the caching_strategies using a container + * containing entries of kind. The attributes helps in + * deciding the entries to be purged. The Cleanup_Strategy is the + * callback class to which the entries to be cleaned up will be + * delegated. + */ +template +class ACE_Refcounted_Recyclable_Handler_Caching_Utility +{ + +public: + + typedef ACE_Refcounted_Recyclable_Handler_Cleanup_Strategy CLEANUP_STRATEGY; + typedef ACE_Cleanup_Strategy CLEANUP_STRATEGY_BASE; + + /// Constructor. + ACE_Refcounted_Recyclable_Handler_Caching_Utility (ACE_Cleanup_Strategy *cleanup_strategy = 0, + int delete_cleanup_strategy = 0); + + /// Destructor. + ~ACE_Refcounted_Recyclable_Handler_Caching_Utility (void); + + /** + * Purge entries from the . The Cleanup_Strategy will do + * the actual job of cleanup once the entries to be cleaned up are + * decided. + */ + int clear_cache (CONTAINER &container, + double purge_percent); + +protected: + + /// Find the entry with minimum caching attributes. + void minimum (CONTAINER &container, + KEY *&key_to_remove, + VALUE *&value_to_remove); + + /// This is the default Cleanup Strategy for this utility. + CLEANUP_STRATEGY_BASE *cleanup_strategy_; + + /// Whether the cleanup_strategy should be destroyed or not. + int delete_cleanup_strategy_; + + /** + * This figure denotes the number of entries are there in the + * container which have been marked as closed already but might + * not have been unbound from the container. + */ + size_t marked_as_closed_entries_; + +private: + ACE_UNIMPLEMENTED_FUNC (void operator= (const ACE_Refcounted_Recyclable_Handler_Caching_Utility &)) + ACE_UNIMPLEMENTED_FUNC (ACE_Refcounted_Recyclable_Handler_Caching_Utility (const ACE_Refcounted_Recyclable_Handler_Caching_Utility &)) +}; + +//////////////////////////////////////////////////////////////////////////////////////// + +/** + * @class ACE_Handler_Caching_Utility + * + * @brief Defines a helper class for the Caching Strategies. + * + * This class defines the methods commonly used by the different + * caching strategies. For instance: method which + * decides and purges the entry from the container. @note This + * class helps in the caching_strategies using a container + * containing entries of kind where the HANDLER + * contains the caching attributes which help in deciding the + * entries to be purged. The Cleanup_Strategy is the callback + * class to which the entries to be cleaned up will be delegated. + */ +template +class ACE_Handler_Caching_Utility +{ +public: + + typedef ACE_Handler_Cleanup_Strategy CLEANUP_STRATEGY; + typedef ACE_Cleanup_Strategy CLEANUP_STRATEGY_BASE; + + /// Constructor. + ACE_Handler_Caching_Utility (ACE_Cleanup_Strategy *cleanup_strategy = 0, + int delete_cleanup_strategy = 0); + + /// Destructor. + ~ACE_Handler_Caching_Utility (void); + + /** + * Purge entries from the . The Cleanup_Strategy will do + * the actual job of cleanup once the entries to be cleaned up are + * decided. + */ + int clear_cache (CONTAINER &container, + double purge_percent); + +protected: + + /** + * Find the entry with minimum caching attributes. This is handler + * specific since this utility is to be used very specifically for + * handler who have caching_attributes for server side acched + * connection management. + */ + void minimum (CONTAINER &container, + KEY *&key_to_remove, + VALUE *&value_to_remove); + + /// The cleanup strategy which can be used to destroy the entries of + /// the container. + CLEANUP_STRATEGY_BASE *cleanup_strategy_; + + /// Whether the cleanup_strategy should be destroyed or not. + int delete_cleanup_strategy_; + +private: + ACE_UNIMPLEMENTED_FUNC (void operator= (const ACE_Handler_Caching_Utility &)) + ACE_UNIMPLEMENTED_FUNC (ACE_Handler_Caching_Utility (const ACE_Handler_Caching_Utility &)) +}; + +/////////////////////////////////////////////////////////////////////////// +#define ACE_Null_Caching_Utility ANUTIL +/** + * @class ACE_Null_Caching_Utility + * + * @brief Defines a dummy helper class for the Caching Strategies. + * + * This class defines the methods commonly used by the different + * caching strategies. For instance: method which + * decides and purges the entry from the container. @note This + * class is be used with the Null_Caching_Strategy. The + * Cleanup_Strategy is the callback class to which the entries to + * be cleaned up will be delegated. + */ +template +class ACE_Null_Caching_Utility +{ +public: + + typedef ACE_Null_Cleanup_Strategy CLEANUP_STRATEGY; + typedef ACE_Cleanup_Strategy CLEANUP_STRATEGY_BASE; + + /// Constructor. + ACE_Null_Caching_Utility (ACE_Cleanup_Strategy *cleanup_strategy = 0, + int delete_cleanup_strategy = 0); + + /// Destructor. + ~ACE_Null_Caching_Utility (void); + + /** + * Purge entries from the . The Cleanup_Strategy will do + * the actual job of cleanup once the entries to be cleaned up are + * decided. @note Here it is a no-op. + */ + int clear_cache (CONTAINER &container, + double purge_percent); + +protected: + + /** + * Find the entry with minimum caching attributes. This is handler + * specific since this utility is to be used very specifically for + * handler who have caching_attributes for server side acched + * connection management.@note Here it is a no-op. + */ + void minimum (CONTAINER &container, + KEY *&key_to_remove, + VALUE *&value_to_remove); + + /// The cleanup strategy which can be used to destroy the entries of + /// the container. + CLEANUP_STRATEGY_BASE *cleanup_strategy_; + + /// Whether the cleanup_strategy should be destroyed or not. + int delete_cleanup_strategy_; + +private: + ACE_UNIMPLEMENTED_FUNC (void operator= (const ACE_Null_Caching_Utility &)) + ACE_UNIMPLEMENTED_FUNC (ACE_Null_Caching_Utility (const ACE_Null_Caching_Utility &)) +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) +#include "ace/Caching_Utility_T.cpp" +#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ + +#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) +#pragma implementation ("Caching_Utility_T.cpp") +#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ + +#include /**/ "ace/post.h" + +#endif /* ACE_CACHING_UTILITY_H */ diff --git a/dep/ACE_wrappers/ace/Capabilities.cpp b/dep/ACE_wrappers/ace/Capabilities.cpp new file mode 100644 index 00000000000..5d46e75472a --- /dev/null +++ b/dep/ACE_wrappers/ace/Capabilities.cpp @@ -0,0 +1,355 @@ +#include "ace/Capabilities.h" +#include "ace/OS_NS_ctype.h" +#include "ace/OS_Memory.h" +#include "ace/OS_NS_string.h" + +#if !defined (__ACE_INLINE__) +#include "ace/Capabilities.inl" +#endif /* !__ACE_INLINE__ */ + +#include "ace/OS_NS_stdio.h" + +ACE_RCSID (ace, + Capabilities, + "$Id: Capabilities.cpp 80826 2008-03-04 14:51:23Z wotte $") + + +#define ACE_ESC ((ACE_TCHAR)0x1b) + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_CapEntry::~ACE_CapEntry (void) +{ +} + +ACE_Capabilities::ACE_Capabilities (void) + : caps_ () +{ +} + +ACE_Capabilities::~ACE_Capabilities (void) +{ + this->resetcaps (); +} + +const ACE_TCHAR * +ACE_Capabilities::parse (const ACE_TCHAR *buf, ACE_TString &cap) +{ + while (*buf != ACE_TEXT ('\0') && *buf != ACE_TEXT (',')) + { + if (*buf == ACE_TEXT ('\\')) + { + ++buf; + if (*buf == ACE_TEXT ('E') || *buf == ACE_TEXT ('e')) + { + cap += ACE_ESC; + ++buf; + continue; + } + else if (*buf == ACE_TEXT ('r')) + { + cap += ACE_TEXT ('\r'); + ++buf; + continue; + } + else if (*buf == ACE_TEXT ('n')) + { + cap += ACE_TEXT ('\n'); + ++buf; + continue; + } + else if (*buf == ACE_TEXT ('t')) + { + cap += ACE_TEXT ('\t'); + ++buf; + continue; + } + else if (*buf == ACE_TEXT ('\\')) + { + cap += *buf++; + continue; + } + if (ACE_OS::ace_isdigit(*buf)) + { + // @@ UNICODE Does this work with unicode? + int oc = 0; + for (int i = 0; + i < 3 && *buf && ACE_OS::ace_isdigit (*buf); + i++) + oc = oc * 8 + (*buf++ - ACE_TEXT ('0')); + + cap += (ACE_TCHAR) oc; + continue; + } + } + cap += *buf++; + } + return buf; +} + +const ACE_TCHAR * +ACE_Capabilities::parse (const ACE_TCHAR *buf, int &cap) +{ + int n = 0; + + while (*buf && ACE_OS::ace_isdigit (*buf)) + n = n * 10 + (*buf++ - ACE_TEXT ('0')); + + cap = n; + + return buf; +} + +void +ACE_Capabilities::resetcaps (void) +{ + for (CAPABILITIES_MAP::ITERATOR iter (this->caps_); + !iter.done (); + iter.advance ()) + { + CAPABILITIES_MAP::ENTRY *entry = 0; + iter.next (entry); + delete entry->int_id_; + } + + this->caps_.close (); + this->caps_.open (); +} + +int +ACE_Capabilities::fillent (const ACE_TCHAR *buf) +{ + this->resetcaps (); + while (*buf) + { + ACE_TString s; + int n; + ACE_TString name; + ACE_CapEntry *ce; + + // Skip blanks + while (*buf && ACE_OS::ace_isspace(*buf)) buf++; + // If we get end of line return + + if (*buf == ACE_TEXT ('\0')) + break; + + if (*buf == ACE_TEXT ('#')) + { + while (*buf && *buf != ACE_TEXT ('\n')) + buf++; + if (*buf == ACE_TEXT ('\n')) + buf++; + continue; + } + while(*buf && *buf != ACE_TEXT ('=') + && *buf!= ACE_TEXT ('#') + && *buf != ACE_TEXT (',')) + name += *buf++; + + // If name is null. + switch (*buf) + { + case ACE_TEXT ('='): + // String property + buf = this->parse (buf + 1, s); + ACE_NEW_RETURN (ce, + ACE_StringCapEntry (s), + -1); + if (this->caps_.bind (name, ce) == -1) + { + delete ce; + return -1; + } + break; + case ACE_TEXT ('#'): + // Integer property + buf = this->parse (buf + 1, n); + ACE_NEW_RETURN (ce, + ACE_IntCapEntry (n), + -1); + if (this->caps_.bind (name, ce) == -1) + { + delete ce; + return -1; + } + break; + case ACE_TEXT (','): + // Boolean + ACE_NEW_RETURN (ce, + ACE_BoolCapEntry (1), + -1); + if (this->caps_.bind (name, ce) == -1) + { + delete ce; + return -1; + } + break; + default: + return 0; + } + + if (*buf++ != ACE_TEXT (',')) + return -1; + } + + return 0; +} + +int +ACE_Capabilities::is_entry (const ACE_TCHAR *name, const ACE_TCHAR *line) +{ + for (;;) + { + // Skip blanks or irrelevant characters + while (*line && ACE_OS::ace_isspace(*line)) + ++line; + + // End of line reached + if (*line == ACE_TEXT ('\0')) + break; + + // Build the entry name + ACE_TString nextname; + while (*line && *line != ACE_TEXT ('|') && *line != ACE_TEXT (',')) + nextname += *line++; + + // We have found the required entry? + if (ACE_OS::strcmp (nextname.c_str (), name) == 0) + return 1; + + // Skip puntuaction char if neccesary. + if (*line == ACE_TEXT ('|') || *line == ACE_TEXT (',')) + ++line; + else + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("Invalid entry\n"))); + break; + } + } + return 0; +} + +int +ACE_Capabilities::getline (FILE *fp, ACE_TString &line) +{ + int ch; + + line.set (0, 0); + + while ((ch = ACE_OS::fgetc (fp)) != EOF && ch != ACE_TEXT ('\n')) + line += (ACE_TCHAR) ch; + + if (ch == EOF && line.length () == 0) + return -1; + else + return 0; +} + +int +ACE_Capabilities::getval (const ACE_TCHAR *keyname, ACE_TString &val) +{ + ACE_CapEntry* cap = 0; + if (this->caps_.find (keyname, cap) == -1) + return -1; + + ACE_StringCapEntry *scap = + dynamic_cast (cap); + if (scap == 0) + return -1; + + val = scap->getval (); + return 0; +} + +int +ACE_Capabilities::getval (const ACE_TCHAR *keyname, int &val) +{ + ACE_CapEntry *cap = 0; + if (this->caps_.find (keyname, cap) == -1) + return -1; + + ACE_IntCapEntry *icap = + dynamic_cast (cap); + if (icap != 0) + { + val = icap->getval (); + return 0; + } + + ACE_BoolCapEntry *bcap = + dynamic_cast (cap); + + if (bcap == 0) + return -1; + + val = bcap->getval (); + return 0; +} + +#if !defined (ACE_IS_SPLITTING) +static int +is_empty (const ACE_TCHAR *line) +{ + while (*line && ACE_OS::ace_isspace (*line)) + ++line; + + return *line == ACE_TEXT ('\0') || *line == ACE_TEXT ('#'); +} + +static int +is_line (const ACE_TCHAR *line) +{ + while (*line && ACE_OS::ace_isspace (*line)) + ++line; + + return *line != ACE_TEXT ('\0'); +} +#endif /* !ACE_IS_SPLITTING */ + +int +ACE_Capabilities::getent (const ACE_TCHAR *fname, const ACE_TCHAR *name) +{ + FILE *fp = ACE_OS::fopen (fname, ACE_TEXT ("r")); + + if (fp == 0) + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("Can't open %s file\n"), + fname), + -1); + + int done; + ACE_TString line; + + while (0 == (done = (this->getline (fp, line) == -1)) + && is_empty (line.c_str ())) + continue; + + while (!done) + { + ACE_TString newline; + ACE_TString description; + + while (0 == (done = (this->getline (fp, newline) == -1))) + if (is_line (newline.c_str ())) + description += newline; + else + break; + + if (this->is_entry (name, line.c_str())) + { + ACE_OS::fclose (fp); + return this->fillent (description.c_str ()); + } + + line = newline; + while (!done && is_empty (line.c_str ())) + done = this->getline (fp, line) == -1; + } + + ACE_OS::fclose (fp); + return -1; +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Capabilities.h b/dep/ACE_wrappers/ace/Capabilities.h new file mode 100644 index 00000000000..e893d987c08 --- /dev/null +++ b/dep/ACE_wrappers/ace/Capabilities.h @@ -0,0 +1,221 @@ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file Capabilities.h + * + * $Id: Capabilities.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Arturo Montes + */ +//============================================================================= + + +#ifndef ACE_CAPABILITIES_H +#define ACE_CAPABILITIES_H +#include /**/ "ace/pre.h" + +#include /**/ "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/Null_Mutex.h" +#include "ace/Hash_Map_Manager_T.h" +#include "ace/Containers.h" +#include "ace/SString.h" +#include "ace/Functor_String.h" + +#if defined (ACE_IS_SPLITTING) +# include "ace/OS_NS_ctype.h" +#endif /* ACE_IS_SPLITTING */ + + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +/** + * @class ACE_CapEntry + * + * @brief This class is the base class for all ACE Capabilities entry + * subclasses. + * + * This class is not instantiable and does not provide accessors + * or methods. If you want to add a new kind of attribute subclass + * this class and dynamic_cast to proper subclass. + */ +class ACE_Export ACE_CapEntry +{ +public: + + virtual ~ACE_CapEntry (void); + +protected: + + enum + { + ACE_INTCAP = 0, + ACE_STRINGCAP = 1, + ACE_BOOLCAP = 2 + }; + + ACE_CapEntry (int captype); + +protected: + + int captype_; + +}; + +/** + * @class ACE_IntCapEntry + * + * @brief This class implement the ACE Integer Capability subclass. + * + * This is a container class for ACE Capabilities integer container + * values. + */ +class ACE_Export ACE_IntCapEntry : public ACE_CapEntry +{ +public: + ACE_IntCapEntry (int val); + int getval (void) const; + +protected: + int val_; +}; + +/** + * @class ACE_StringCapEntry + * + * @brief This class implement the ACE String Capability subclass. + * + * This is a container class for ACE Capabilities String container + * values. + */ +class ACE_Export ACE_StringCapEntry : public ACE_CapEntry +{ +public: + ACE_StringCapEntry (const ACE_TString &val); + ACE_TString getval (void) const; + +protected: + ACE_TString val_; +}; + +/** + * @class ACE_BoolCapEntry + * + * @brief This class implement the ACE Bool Capability subclass. + * + * This is a container class for ACE Capabilities bool container + * values. + */ +class ACE_Export ACE_BoolCapEntry : public ACE_CapEntry +{ +public: + ACE_BoolCapEntry (int val); + int getval (void) const; + +protected: + int val_; +}; + +/** + * @class ACE_Capabilities + * + * @brief This class implement the ACE Capabilities. + * + * This is a container class for ACE Capabilities + * values. Currently exist three different capability values: + * (integer), (bool) and + * (String). An ACE_Capabilities is a + * unordered set of pair = (, *). Where + * the first component is the name of capability and the second + * component is a pointer to the capability value container. A + * is a container for ACE_Capabilities, the + * ACE_Capabilities has a name in the file, as a termcap file. + */ +class ACE_Export ACE_Capabilities +{ +public: + + typedef ACE_Hash_Map_Manager_Ex, ACE_Equal_To, ACE_Null_Mutex> CAPABILITIES_MAP; + + /// The Constructor + ACE_Capabilities (void); + + /// The Destructor + ~ACE_Capabilities(void); + +public: + + /// Get a string entry. + int getval (const ACE_TCHAR *ent, ACE_TString &val); + + /// Get an integer entry. + int getval (const ACE_TCHAR *ent, int &val); + + /// Get the ACE_Capabilities name from FILE fname and load the + /// associated capabitily entries in map. + int getent (const ACE_TCHAR *fname, const ACE_TCHAR *name); + +protected: + + /// Parse an integer property + const ACE_TCHAR *parse (const ACE_TCHAR *buf, int &cap); + + /// Parse a string property + const ACE_TCHAR *parse (const ACE_TCHAR *buf, ACE_TString &cap); + + /// Fill the ACE_Capabilities with description in ent. + int fillent(const ACE_TCHAR *ent); + + /// Parse a cap entry + int parseent (const ACE_TCHAR *name, ACE_TCHAR *line); + + /// Get a line from FILE input stream + int getline (FILE* fp, + ACE_TString &line); + + /// Is a valid entry + int is_entry (const ACE_TCHAR *name, const ACE_TCHAR *line); + + /// Reset the set of capabilities + void resetcaps (void); + +private: + + /// This is the set of ACE_CapEntry. + CAPABILITIES_MAP caps_; + +}; + +#if defined (ACE_IS_SPLITTING) +int +is_empty (const ACE_TCHAR *line) +{ + while (*line && ACE_OS::ace_isspace (*line)) + ++line; + + return *line == ACE_TEXT ('\0') || *line == ACE_TEXT ('#'); +} + +int +is_line (const ACE_TCHAR *line) +{ + while (*line && ACE_OS::ace_isspace (*line)) + ++line; + + return *line != ACE_TEXT ('\0'); +} +#endif /* ACE_IS_SPLITTING */ + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +#include "ace/Capabilities.inl" +#endif /* __ACE_INLINE__ */ + +#include /**/ "ace/post.h" +#endif /* __ACE_CAPABILITIES_H__ */ diff --git a/dep/ACE_wrappers/ace/Capabilities.inl b/dep/ACE_wrappers/ace/Capabilities.inl new file mode 100644 index 00000000000..37284b28696 --- /dev/null +++ b/dep/ACE_wrappers/ace/Capabilities.inl @@ -0,0 +1,52 @@ +// -*- C++ -*- +// +// $Id: Capabilities.inl 80826 2008-03-04 14:51:23Z wotte $ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_INLINE +ACE_CapEntry::ACE_CapEntry (int captype) + : captype_ (captype) +{ +} + +ACE_INLINE +ACE_IntCapEntry::ACE_IntCapEntry (int val) + : ACE_CapEntry (ACE_INTCAP), + val_ (val) +{ +} + +ACE_INLINE int +ACE_IntCapEntry::getval (void) const +{ + return val_; +} + +ACE_INLINE +ACE_StringCapEntry::ACE_StringCapEntry (const ACE_TString &val) + : ACE_CapEntry (ACE_STRINGCAP), + val_ (val) +{ +} + +ACE_INLINE ACE_TString +ACE_StringCapEntry::getval (void) const +{ + return val_; +} + +ACE_INLINE +ACE_BoolCapEntry::ACE_BoolCapEntry (int val) + : ACE_CapEntry (ACE_BOOLCAP), + val_(val) +{ +} + +ACE_INLINE int +ACE_BoolCapEntry::getval (void) const +{ + return val_; +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Cleanup.cpp b/dep/ACE_wrappers/ace/Cleanup.cpp new file mode 100644 index 00000000000..752ffb40b4f --- /dev/null +++ b/dep/ACE_wrappers/ace/Cleanup.cpp @@ -0,0 +1,192 @@ +// $Id: Cleanup.cpp 80826 2008-03-04 14:51:23Z wotte $ + +#include "ace/Cleanup.h" + +ACE_RCSID (ace, + Cleanup, + "$Id: Cleanup.cpp 80826 2008-03-04 14:51:23Z wotte $") + +#if !defined (ACE_HAS_INLINED_OSCALLS) +# include "ace/Cleanup.inl" +#endif /* ACE_HAS_INLINED_OSCALLS */ + +#include "ace/OS_Memory.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +void +ACE_Cleanup::cleanup (void *) +{ + delete this; +} + + +ACE_Cleanup::~ACE_Cleanup (void) +{ +} + +/*****************************************************************************/ + +extern "C" void +ACE_CLEANUP_DESTROYER_NAME (ACE_Cleanup *object, void *param) +{ + object->cleanup (param); +} + +/*****************************************************************************/ + +ACE_Cleanup_Info::ACE_Cleanup_Info (void) + : object_ (0), + cleanup_hook_ (0), + param_ (0) +{ +} + +bool +ACE_Cleanup_Info::operator== (const ACE_Cleanup_Info &o) const +{ + return o.object_ == this->object_ + && o.cleanup_hook_ == this->cleanup_hook_ + && o.param_ == this->param_; +} + +bool +ACE_Cleanup_Info::operator!= (const ACE_Cleanup_Info &o) const +{ + return !(*this == o); +} + +/*****************************************************************************/ + +/** + * @class ACE_Cleanup_Info_Node + * + * @brief For maintaining a list of ACE_Cleanup_Info items. + * + * For internal use by ACE_Object_Manager. + */ +class ACE_Cleanup_Info_Node +{ +public: + ACE_Cleanup_Info_Node (void); + ACE_Cleanup_Info_Node (const ACE_Cleanup_Info &new_info, + ACE_Cleanup_Info_Node *next); + ~ACE_Cleanup_Info_Node (void); + ACE_Cleanup_Info_Node *insert (const ACE_Cleanup_Info &); +private: + ACE_Cleanup_Info cleanup_info_; + ACE_Cleanup_Info_Node *next_; + + friend class ACE_OS_Exit_Info; +}; + +ACE_Cleanup_Info_Node::ACE_Cleanup_Info_Node (void) + : cleanup_info_ (), + next_ (0) +{ +} + +ACE_Cleanup_Info_Node::ACE_Cleanup_Info_Node (const ACE_Cleanup_Info &new_info, + ACE_Cleanup_Info_Node *next) + : cleanup_info_ (new_info), + next_ (next) +{ +} + +ACE_Cleanup_Info_Node::~ACE_Cleanup_Info_Node (void) +{ + delete next_; +} + +ACE_Cleanup_Info_Node * +ACE_Cleanup_Info_Node::insert (const ACE_Cleanup_Info &new_info) +{ + ACE_Cleanup_Info_Node *new_node = 0; + + ACE_NEW_RETURN (new_node, + ACE_Cleanup_Info_Node (new_info, this), + 0); + + return new_node; +} + +/*****************************************************************************/ + +ACE_OS_Exit_Info::ACE_OS_Exit_Info (void) +{ + ACE_NEW (registered_objects_, ACE_Cleanup_Info_Node); +} + +ACE_OS_Exit_Info::~ACE_OS_Exit_Info (void) +{ + delete registered_objects_; + registered_objects_ = 0; +} + +int +ACE_OS_Exit_Info::at_exit_i (void *object, + ACE_CLEANUP_FUNC cleanup_hook, + void *param) +{ + ACE_Cleanup_Info new_info; + new_info.object_ = object; + new_info.cleanup_hook_ = cleanup_hook; + new_info.param_ = param; + + // Return -1 and sets errno if unable to allocate storage. Enqueue + // at the head and dequeue from the head to get LIFO ordering. + + ACE_Cleanup_Info_Node *new_node = 0; + + if ((new_node = registered_objects_->insert (new_info)) == 0) + return -1; + else + { + registered_objects_ = new_node; + return 0; + } +} + +int +ACE_OS_Exit_Info::find (void *object) +{ + // Check for already in queue, and return 1 if so. + for (ACE_Cleanup_Info_Node *iter = registered_objects_; + iter && iter->next_ != 0; + iter = iter->next_) + { + if (iter->cleanup_info_.object_ == object) + { + // The object has already been registered. + return 1; + } + } + + return 0; +} + +void +ACE_OS_Exit_Info::call_hooks (void) +{ + // Call all registered cleanup hooks, in reverse order of + // registration. + for (ACE_Cleanup_Info_Node *iter = registered_objects_; + iter && iter->next_ != 0; + iter = iter->next_) + { + ACE_Cleanup_Info &info = iter->cleanup_info_; + if (info.cleanup_hook_ == reinterpret_cast ( + ACE_CLEANUP_DESTROYER_NAME)) + // The object is an ACE_Cleanup. + ACE_CLEANUP_DESTROYER_NAME ( + reinterpret_cast (info.object_), + info.param_); + else if (info.object_ == &ace_exit_hook_marker) + // The hook is an ACE_EXIT_HOOK. + (* reinterpret_cast (info.cleanup_hook_)) (); + else + (*info.cleanup_hook_) (info.object_, info.param_); + } +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Cleanup.h b/dep/ACE_wrappers/ace/Cleanup.h new file mode 100644 index 00000000000..8ea0360580c --- /dev/null +++ b/dep/ACE_wrappers/ace/Cleanup.h @@ -0,0 +1,137 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Cleanup.h + * + * $Id: Cleanup.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Douglas C. Schmidt + * @author Jesper S. M|ller + * @author and a cast of thousands... + * + * Originally in OS.h. + */ +//============================================================================= + +#ifndef ACE_CLEANUP_H +# define ACE_CLEANUP_H + +# include /**/ "ace/pre.h" + +# include "ace/config-lite.h" + +# if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +# endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include /**/ "ace/ACE_export.h" + +#if (defined (ACE_HAS_VERSIONED_NAMESPACE) && ACE_HAS_VERSIONED_NAMESPACE == 1) +# include "ace/Global_Macros.h" +# define ACE_CLEANUP_DESTROYER_NAME ACE_PREPROC_CONCATENATE(ACE_VERSIONED_NAMESPACE_NAME, _ace_cleanup_destroyer) +#else +# define ACE_CLEANUP_DESTROYER_NAME ace_cleanup_destroyer +#endif /* ACE_HAS_VERSIONED_NAMESPACE == 1 */ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +/** + * @class ACE_Cleanup + * + * @brief Base class for objects that are cleaned by ACE_Object_Manager. + */ +class ACE_Export ACE_Cleanup +{ +public: + /// No-op constructor. + ACE_Cleanup (void); + + /// Destructor. + virtual ~ACE_Cleanup (void); + + /// Cleanup method that, by default, simply deletes itself. + virtual void cleanup (void *param = 0); +}; + +// Adapter for cleanup, used by ACE_Object_Manager. +extern "C" ACE_Export +void ACE_CLEANUP_DESTROYER_NAME (ACE_Cleanup *, void *param = 0); + +/** + * @class ACE_Cleanup_Info + * + * @brief Hold cleanup information for thread/process + */ +class ACE_Export ACE_Cleanup_Info +{ +public: + /// Default constructor. + ACE_Cleanup_Info (void); + + /// Equality operator. + bool operator== (const ACE_Cleanup_Info &o) const; + + /// Inequality operator. + bool operator!= (const ACE_Cleanup_Info &o) const; + + /// Point to object that gets passed into the . + void *object_; + + /// Cleanup hook that gets called back. + ACE_CLEANUP_FUNC cleanup_hook_; + + /// Parameter passed to the . + void *param_; +}; + +class ACE_Cleanup_Info_Node; + +/** + * @class ACE_OS_Exit_Info + * + * @brief Hold Object Manager cleanup (exit) information. + * + * For internal use by the ACE library, only. + */ +class ACE_Export ACE_OS_Exit_Info +{ +public: + /// Default constructor. + ACE_OS_Exit_Info (void); + + /// Destructor. + ~ACE_OS_Exit_Info (void); + + /// Use to register a cleanup hook. + int at_exit_i (void *object, ACE_CLEANUP_FUNC cleanup_hook, void *param); + + /// Look for a registered cleanup hook object. Returns 1 if already + /// registered, 0 if not. + int find (void *object); + + /// Call all registered cleanup hooks, in reverse order of + /// registration. + void call_hooks (); + +private: + /** + * Keeps track of all registered objects. The last node is only + * used to terminate the list (it doesn't contain a valid + * ACE_Cleanup_Info). + */ + ACE_Cleanup_Info_Node *registered_objects_; +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +# if defined (ACE_HAS_INLINED_OSCALLS) +# if defined (ACE_INLINE) +# undef ACE_INLINE +# endif /* ACE_INLINE */ +# define ACE_INLINE inline +# include "ace/Cleanup.inl" +# endif /* ACE_HAS_INLINED_OSCALLS */ + +# include /**/ "ace/post.h" +#endif /* ACE_CLEANUP_H */ diff --git a/dep/ACE_wrappers/ace/Cleanup.inl b/dep/ACE_wrappers/ace/Cleanup.inl new file mode 100644 index 00000000000..9c36d6b1ffd --- /dev/null +++ b/dep/ACE_wrappers/ace/Cleanup.inl @@ -0,0 +1,12 @@ +// -*- C++ -*- +// +// $Id: Cleanup.inl 80826 2008-03-04 14:51:23Z wotte $ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_INLINE +ACE_Cleanup::ACE_Cleanup (void) +{ +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Cleanup_Strategies_T.cpp b/dep/ACE_wrappers/ace/Cleanup_Strategies_T.cpp new file mode 100644 index 00000000000..32965993774 --- /dev/null +++ b/dep/ACE_wrappers/ace/Cleanup_Strategies_T.cpp @@ -0,0 +1,95 @@ +//$Id: Cleanup_Strategies_T.cpp 80826 2008-03-04 14:51:23Z wotte $ + +#ifndef ACE_CLEANUP_STRATEGIES_T_CPP +#define ACE_CLEANUP_STRATEGIES_T_CPP + +#include "ace/Cleanup_Strategies_T.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +#pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +//////////////////////////////////////////////////////////////////////////// + +template +ACE_Cleanup_Strategy::~ACE_Cleanup_Strategy (void) +{ +} + +template int +ACE_Cleanup_Strategy::cleanup (CONTAINER &container, + KEY *key, + VALUE *) +{ + return container.unbind (*key); +} + +//////////////////////////////////////////////////////////////////////////// + +template int +ACE_Recyclable_Handler_Cleanup_Strategy::cleanup ( + CONTAINER &container, + KEY *key, + VALUE *) +{ + VALUE value; + + if (container.unbind (*key, value) == -1) + return -1; + + value.first ()->recycler (0, 0); + + value.first ()->close (); + + return 0; +} + +///////////////////////////////////////////////////////////////////////////// + +template int +ACE_Refcounted_Recyclable_Handler_Cleanup_Strategy::cleanup ( + CONTAINER &, + KEY *, + VALUE *value) +{ + return value->first ()->handle_close_i (); +} + +//////////////////////////////////////////////////////////////////////////// + +template int +ACE_Handler_Cleanup_Strategy::cleanup ( + CONTAINER &container, + KEY *key, + VALUE *value) +{ + // Remove the item from cache only if the handler isnt in use. + if ((*value)->active () == 0) + { + (*value)->close (); + + if (container.unbind (*key) == -1) + return -1; + + } + + return 0; +} + +//////////////////////////////////////////////////////////////////////////// + +template int +ACE_Null_Cleanup_Strategy::cleanup (CONTAINER &, + KEY *, + VALUE *) +{ + return 0; +} + +ACE_END_VERSIONED_NAMESPACE_DECL + +#endif /* ACE_CLEANUP_STRATEGIES_T_CPP */ diff --git a/dep/ACE_wrappers/ace/Cleanup_Strategies_T.h b/dep/ACE_wrappers/ace/Cleanup_Strategies_T.h new file mode 100644 index 00000000000..ca51b47b10f --- /dev/null +++ b/dep/ACE_wrappers/ace/Cleanup_Strategies_T.h @@ -0,0 +1,149 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Cleanup_Strategies_T.h + * + * $Id: Cleanup_Strategies_T.h 81388 2008-04-23 14:02:05Z johnnyw $ + * + * @author Kirthika Parameswaran + */ +//============================================================================= + + +#ifndef CLEANUP_STRATEGIES_H +#define CLEANUP_STRATEGIES_H +#include /**/ "ace/pre.h" + +#include /**/ "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +// For linkers that cant grok long names. +#define ACE_Cleanup_Strategy ACLE + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +/** + * @class ACE_Cleanup_Strategy + * + * @brief Defines a default strategy to be followed for cleaning up + * entries from a map which is the container. + * + * By default the entry to be cleaned up is removed from the + * container. + */ +template +class ACE_Cleanup_Strategy +{ + +public: + + /// Destructor. + virtual ~ACE_Cleanup_Strategy (void); + + /// The method which will do the cleanup of the entry in the container. + virtual int cleanup (CONTAINER &container, KEY *key, VALUE *value); +}; + +////////////////////////////////////////////////////////////////////// +#define ACE_Recyclable_Handler_Cleanup_Strategy ARHCLE + +/** + * @class ACE_Recyclable_Handler_Cleanup_Strategy + * + * @brief Defines a strategy to be followed for cleaning up + * entries which are svc_handlers from a container. + * + * The entry to be cleaned up is removed from the container. + * Here, since we are dealing with svc_handlers specifically, we + * perform a couple of extra operations. @note To be used when + * the handler is recyclable. + */ +template +class ACE_Recyclable_Handler_Cleanup_Strategy : public ACE_Cleanup_Strategy +{ + +public: + + /// The method which will do the cleanup of the entry in the container. + virtual int cleanup (CONTAINER &container, KEY *key, VALUE *value); +}; + +////////////////////////////////////////////////////////////////////// +#define ACE_Refcounted_Recyclable_Handler_Cleanup_Strategy ARRHCLE + +/** + * @class ACE_Refcounted_Recyclable_Handler_Cleanup_Strategy + * + * @brief Defines a strategy to be followed for cleaning up + * entries which are svc_handlers from a container. + * + * The entry to be cleaned up is removed from the container. + * Here, since we are dealing with recyclable svc_handlers with + * addresses which are refcountable specifically, we perform a + * couple of extra operations and do so without any locking. + */ +template +class ACE_Refcounted_Recyclable_Handler_Cleanup_Strategy : public ACE_Cleanup_Strategy +{ +public: + /// The method which will do the cleanup of the entry in the container. + virtual int cleanup (CONTAINER &container, KEY *key, VALUE *value); +}; + +////////////////////////////////////////////////////////////////////// + +/** + * @class ACE_Handler_Cleanup_Strategy + * + * @brief Defines a strategy to be followed for cleaning up + * entries which are svc_handlers from a container. + * + * The entry to be cleaned up is removed from the container. + * Here, since we are dealing with svc_handlers specifically, we + * perform a couple of extra operations. @note This cleanup strategy + * should be used in the case when the handler has the caching + * attributes. + */ +template +class ACE_Handler_Cleanup_Strategy : public ACE_Cleanup_Strategy +{ +public: + /// The method which will do the cleanup of the entry in the container. + virtual int cleanup (CONTAINER &container, KEY *key, VALUE *value); +}; + +////////////////////////////////////////////////////////////////////// +#define ACE_Null_Cleanup_Strategy ANCLE + +/** + * @class ACE_Null_Cleanup_Strategy + * + * @brief Defines a do-nothing implementation of the cleanup strategy. + * + * This class simply does nothing at all! Can be used to nullify + * the effect of the Cleanup Strategy. + */ +template +class ACE_Null_Cleanup_Strategy : public ACE_Cleanup_Strategy +{ +public: + /// The dummy cleanup method. + virtual int cleanup (CONTAINER &container, KEY *key, VALUE *value); +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) +#include "ace/Cleanup_Strategies_T.cpp" +#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ + +#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) +#pragma implementation ("Cleanup_Strategies_T.cpp") +#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ + +#include /**/ "ace/post.h" +#endif /* CLEANUP_STRATEGIES_H */ diff --git a/dep/ACE_wrappers/ace/Codecs.cpp b/dep/ACE_wrappers/ace/Codecs.cpp new file mode 100644 index 00000000000..71491fe1c44 --- /dev/null +++ b/dep/ACE_wrappers/ace/Codecs.cpp @@ -0,0 +1,234 @@ +#include "ace/Codecs.h" +#include "ace/Log_Msg.h" +#include "ace/OS_Memory.h" +#include "ace/OS_NS_ctype.h" + +ACE_RCSID (ace, + Codecs, + "$Id: Codecs.cpp 80826 2008-03-04 14:51:23Z wotte $") + +namespace +{ + // Just in case ... +#undef alphabet +#undef pad +#undef max_columns + + // Symbols which form the Base64 alphabet (Defined as per RFC 2045) + ACE_Byte const alphabet[] = + "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; + + // The padding character used in the encoding + ACE_Byte const pad = '='; + + // Number of columns per line of encoded output (Can have a maximum + // value of 76). + int const max_columns = 72; +} + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +bool ACE_Base64::init_ = false; + +ACE_Byte ACE_Base64::decoder_[256]; + +ACE_Byte ACE_Base64::member_[256]; + +ACE_Byte* +ACE_Base64::encode (const ACE_Byte* input, + const size_t input_len, + size_t* output_len, + bool is_chunked) +{ + if (!ACE_Base64::init_) + ACE_Base64::init(); + + if (!input) + return 0; + + ACE_Byte* result = 0; + + size_t length = ((input_len + 2) / 3) * 4; + size_t num_lines = length / max_columns + 1; + length += num_lines + 1; + ACE_NEW_RETURN (result, ACE_Byte[length], 0); + + int char_count = 0; + int bits = 0; + size_t pos = 0; + int cols = 0; + + for (size_t i = 0; i < input_len; ++i) + { + bits += input[i]; + ++char_count; + + if (char_count == 3) + { + result[pos++] = alphabet[bits >> 18]; + result[pos++] = alphabet[(bits >> 12) & 0x3f]; + result[pos++] = alphabet[(bits >> 6) & 0x3f]; + result[pos++] = alphabet[bits & 0x3f]; + cols += 4; + if (cols == max_columns) { + if (is_chunked) + result[pos++] = '\n'; + cols = 0; + } + bits = 0; + char_count = 0; + } + else + { + bits <<= 8; + } + } + + if (char_count != 0) + { + bits <<= (16 - (8 * char_count)); + result[pos++] = alphabet[bits >> 18]; + result[pos++] = alphabet[(bits >> 12) & 0x3f]; + cols += 2; + if (char_count == 1) + { + result[pos++] = pad; + result[pos++] = pad; + cols += 2; + } + else + { + result[pos++] = alphabet[(bits >> 6) & 0x3f]; + result[pos++] = pad; + cols += 2; + } + } + + if (cols > 0 && is_chunked) + result[pos++] = '\n'; + + result[pos] = 0; + *output_len = pos; + return result; +} + +size_t +ACE_Base64::length (const ACE_Byte* input) +{ + if (!ACE_Base64::init_) + ACE_Base64::init(); + + ACE_Byte* ptr = const_cast (input); + while (*ptr != 0 && + (member_[*(ptr)] == 1 || *ptr == pad + || ACE_OS::ace_isspace (*ptr))) + ++ptr; + size_t len = ptr - input; + len = ((len + 3) / 4) * 3 + 1 ; + return len; +} + +ACE_Byte* +ACE_Base64::decode (const ACE_Byte* input, size_t* output_len) +{ + if (!ACE_Base64::init_) + ACE_Base64::init(); + + if (!input) + return 0; + + size_t result_len = ACE_Base64::length (input); + ACE_Byte* result = 0; + ACE_NEW_RETURN (result, ACE_Byte[result_len], 0); + + ACE_Byte* ptr = const_cast (input); + while (*ptr != 0 && + (member_[*(ptr)] == 1 || *ptr == pad + || ACE_OS::ace_isspace (*ptr))) + ++ptr; + size_t input_len = ptr - input; + + int char_count = 0; + int bits = 0; + size_t pos = 0; + + size_t i = 0; + for (; i < input_len; ++i) + { + if (input[i] == pad) + break; + if (!ACE_Base64::member_[input[i]]) + continue; + bits += decoder_[input[i]]; + ++char_count; + + if (char_count == 4) + { + result[pos++] = static_cast (bits >> 16); + result[pos++] = static_cast ((bits >> 8) & 0xff); + result[pos++] = static_cast (bits & 0xff); + bits = 0; + char_count = 0; + } + else + { + bits <<= 6; + } + } + + int errors = 0; + if ( i == input_len) + { + if (char_count) + { + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("Decoding incomplete: atleast %d bits truncated\n"), + (4 - char_count) * 6)); + ++errors; + } + } + else + { + switch (char_count) + { + case 1: + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("Decoding incomplete: atleast 2 bits missing\n"))); + ++errors; + break; + case 2: + result[pos++] = static_cast (bits >> 10); + break; + case 3: + result[pos++] = static_cast (bits >> 16); + result[pos++] = static_cast ((bits >> 8) & 0xff); + break; + } + } + + if (errors) + { + delete[] result; + return 0; + } + result[pos] = 0; + *output_len = pos; + return result; +} + +void +ACE_Base64::init () +{ + if (!ACE_Base64::init_) + { + for (ACE_Byte i = 0; i < sizeof (alphabet); ++i) + { + ACE_Base64::decoder_[alphabet[i]] = i; + ACE_Base64::member_ [alphabet[i]] = 1; + } + ACE_Base64::init_ = true; + } + return; +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Codecs.h b/dep/ACE_wrappers/ace/Codecs.h new file mode 100644 index 00000000000..2c4227dd0ad --- /dev/null +++ b/dep/ACE_wrappers/ace/Codecs.h @@ -0,0 +1,121 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Codecs.h + * + * $Id: Codecs.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Krishnakumar B + * + * Codecs is a generic wrapper for various encoding and decoding + * mechanisms. Currently it includes Base64 content transfer-encoding as + * specified by RFC 2045, Multipurpose Internet Mail Extensions (MIME) Part + * One: Format of Internet Message Bodies. + * + */ +//============================================================================= + +#ifndef ACE_CODECS_H +#define ACE_CODECS_H + +#include /**/ "ace/pre.h" + +#include /**/ "ace/ACE_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/Basic_Types.h" +#include "ace/Global_Macros.h" + + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +/** + * @class ACE_Base64 + * + * @brief Encode/Decode a stream of bytes according to Base64 encoding. + * + * This class provides methods to encode or decode a stream of bytes + * to/from Base64 encoding. It doesn't convert the input stream to a + * canonical form before encoding. + * + */ +class ACE_Export ACE_Base64 +{ +public: + + //@{ + + /** + * Encodes a stream of bytes to Base64 data + * + * @param input Binary data in byte stream. + * @param input_len Length of the byte stream. + * @param output_len Length of the encoded Base64 byte stream. + * @param is_chunked If true, terminate 72 character blocks with newline + * @return Encoded Base64 data in byte stream or NULL if input data cannot + * be encoded. + */ + + static ACE_Byte* encode (const ACE_Byte* input, + const size_t input_len, + size_t* output_len, + bool is_chunked = true); + /** + * Decodes a stream of Base64 to bytes data + * + * @param input Encoded Base64 data in byte stream. + * @param output_len Length of the binary byte stream. + * @return Binary data in byte stream or NULL if input data cannot + * be encoded. + */ + static ACE_Byte* decode (const ACE_Byte* input, + size_t* output_len); + + /** + * Return the length of the encoded input data + * + * @param input Encoded Base64 data in byte stream. + * @return Length of the encoded Base64 data. + * + */ + static size_t length (const ACE_Byte* input); + + //@} + +protected: + + // Prevent default construction. + ACE_Base64 (void) {} + +private: + + // Preventing copying and assignment. + ACE_Base64 (ACE_Base64 const &); + ACE_Base64 & operator= (ACE_Base64 const &); + + /// Initialize the tables for encoding/decoding. + static void init (void); + +private: + + /// Alphabet used for decoding i.e decoder_[alphabet_[i = 0..63]] = i + static ACE_Byte decoder_[]; + + /// Alphabet used to check valid range of encoded input i.e + /// member_[alphabet_[0..63]] = 1 + static ACE_Byte member_[]; + + /// Boolean to denote whether initialization is complete + static bool init_; + +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#include /**/ "ace/post.h" + +#endif /* ACE_CODECS_H */ diff --git a/dep/ACE_wrappers/ace/Codeset_IBM1047.cpp b/dep/ACE_wrappers/ace/Codeset_IBM1047.cpp new file mode 100644 index 00000000000..91582cf4ef3 --- /dev/null +++ b/dep/ACE_wrappers/ace/Codeset_IBM1047.cpp @@ -0,0 +1,309 @@ + +//============================================================================= +/** + * @file Codeset_IBM1047.cpp + * + * $Id: Codeset_IBM1047.cpp 81661 2008-05-09 12:05:34Z johnnyw $ + * + * Defines the arrays required to convert between ISO8859 (aka + * Latin/1) and IBM1047 (aka EBCDIC). + * + * + * @author Jim Rogers (jrogers@viasoft.com) + */ +//============================================================================= + + +#include "ace/Codeset_IBM1047.h" + +#if defined (ACE_HAS_EBCDIC) + +ACE_RCSID (ace, + Codeset_IBM1047, + "$Id: Codeset_IBM1047.cpp 81661 2008-05-09 12:05:34Z johnnyw $") + +#include "ace/OS_Memory.h" +#include "ace/OS_NS_string.h" + +namespace +{ + char const to_IBM1047[] = + { + "\x00\x01\x02\x03\x37\x2D\x2E\x2F\x16\x05\x25\x0B\x0C\x0D\x0E\x0F" // 00-0F + "\x10\x11\x12\x13\x3C\x3D\x32\x26\x18\x19\x3F\x27\x22\x1D\x35\x1F" // 10-1F + "\x40\x5A\x7F\x7B\x5B\x6C\x50\x7D\x4D\x5D\x5C\x4E\x6B\x60\x4B\x61" // 20-2F + "\xF0\xF1\xF2\xF3\xF4\xF5\xF6\xF7\xF8\xF9\x7A\x5E\x4C\x7E\x6E\x6F" // 30-3F + "\x7C\xC1\xC2\xC3\xC4\xC5\xC6\xC7\xC8\xC9\xD1\xD2\xD3\xD4\xD5\xD6" // 40-4F + "\xD7\xD8\xD9\xE2\xE3\xE4\xE5\xE6\xE7\xE8\xE9\xAD\xE0\xBD\x5F\x6D" // 50-5F + "\x79\x81\x82\x83\x84\x85\x86\x87\x88\x89\x91\x92\x93\x94\x95\x96" // 60-6F + "\x97\x98\x99\xA2\xA3\xA4\xA5\xA6\xA7\xA8\xA9\xC0\x4F\xD0\xA1\x07" // 70-7F + "\x43\x20\x21\x1C\x23\xEB\x24\x9B\x71\x28\x38\x49\x90\xBA\xEC\xDF" // 80-8F + "\x45\x29\x2A\x9D\x72\x2B\x8A\x9A\x67\x56\x64\x4A\x53\x68\x59\x46" // 90-9F + "\xEA\xDA\x2C\xDE\x8B\x55\x41\xFE\x58\x51\x52\x48\x69\xDB\x8E\x8D" // A0-AF + "\x73\x74\x75\xFA\x15\xB0\xB1\xB3\xB4\xB5\x6A\xB7\xB8\xB9\xCC\xBC" // B0-BF + "\xAB\x3E\x3B\x0A\xBF\x8F\x3A\x14\xA0\x17\xCB\xCA\x1A\x1B\x9C\x04" // C0-CF + "\x34\xEF\x1E\x06\x08\x09\x77\x70\xBE\xBB\xAC\x54\x63\x65\x66\x62" // D0-DF + "\x30\x42\x47\x57\xEE\x33\xB6\xE1\xCD\xED\x36\x44\xCE\xCF\x31\xAA" // E0-EF + "\xFC\x9E\xAE\x8C\xDD\xDC\x39\xFB\x80\xAF\xFD\x78\x76\xB2\x9F\xFF" // F0-FF +}; + + char const from_IBM1047[] = + { + "\x00\x01\x02\x03\xCF\x09\xD3\x7F\xD4\xD5\xC3\x0B\x0C\x0D\x0E\x0F" // 00-0F + "\x10\x11\x12\x13\xC7\xB4\x08\xC9\x18\x19\xCC\xCD\x83\x1D\xD2\x1F" // 10-1F + "\x81\x82\x1C\x84\x86\x0A\x17\x1B\x89\x91\x92\x95\xA2\x05\x06\x07" // 20-2F + "\x20\xEE\x16\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\xC1\x1A" // 30-3F + "\x20\xA6\xE1\x80\xEB\x90\x9F\xE2\xAB\x8B\x9B\x2E\x3C\x28\x2B\x7C" // 40-4F + "\x26\xA9\xAA\x9C\xDB\xA5\x99\xE3\xA8\x9E\x21\x24\x2A\x29\x3B\x5E" // 50-5F + "\x2D\x2F\xDF\xDC\x9A\xDD\xDE\x98\x9D\xAC\xBA\x2C\x25\x5F\x3E\x3F" // 60-6F + "\xD7\x88\x94\xB0\xB1\xB2\xFC\xD6\xFB\x60\x3A\x23\x40\x27\x3D\x22" // 70-7F + "\xF8\x61\x62\x63\x64\x65\x66\x67\x68\x69\x96\xA4\xF3\xAF\xAE\xC5" // 80-8F + "\x8C\x6A\x6B\x6C\x6D\x6E\x6F\x70\x71\x72\x97\x87\xCE\x93\xF1\xFE" // 90-9F + "\xC8\x7E\x73\x74\x75\x76\x77\x78\x79\x7A\xEF\xC0\xDA\x5B\xF2\xF9" // A0-AF + "\xB5\xB6\xFD\xB7\xB8\xB9\xE6\xBB\xBC\xBD\x8D\xD9\xBF\x5D\xD8\xC4" // B0-BF + "\x7B\x41\x42\x43\x44\x45\x46\x47\x48\x49\xCB\xCA\xBE\xE8\xEC\xED" // C0-CF + "\x7D\x4A\x4B\x4C\x4D\x4E\x4F\x50\x51\x52\xA1\xAD\xF5\xF4\xA3\x8F" // D0-DF + "\x5C\xE7\x53\x54\x55\x56\x57\x58\x59\x5A\xA0\x85\x8E\xE9\xE4\xD1" // E0-EF + "\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\xB3\xF7\xF0\xFA\xA7\xFF" // F0-FF + }; +} + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_IBM1047_ISO8859::ACE_IBM1047_ISO8859 (void) +{ +} + +ACE_IBM1047_ISO8859::~ACE_IBM1047_ISO8859 (void) +{ +} + +ACE_CDR::ULong +ACE_IBM1047_ISO8859::ncs () +{ + return 0x10020417; +} + +ACE_CDR::ULong +ACE_IBM1047_ISO8859::tcs () +{ + return 0x00010001; +} + +ACE_CDR::Boolean +ACE_IBM1047_ISO8859::read_char (ACE_InputCDR &in, + ACE_CDR::Char &x) +{ + if (this->read_1 (in, reinterpret_cast (&x))) + { + x = to_IBM1047[x]; + return 1; + } + return 0; +} + +ACE_CDR::Boolean +ACE_IBM1047_ISO8859::read_string (ACE_InputCDR& in, + ACE_CDR::Char *& x) +{ + ACE_CDR::ULong len; + + in.read_ulong (len); + + if (len > 0) + { + ACE_NEW_RETURN (x, + ACE_CDR::Char[len], + 0); + + if (this->read_char_array (in, x, len)) + return 1; + + delete [] x; + } + + x = 0; + return 0; +} + +ACE_CDR::Boolean +ACE_IBM1047_ISO8859::read_char_array (ACE_InputCDR& in, + ACE_CDR::Char* x, + ACE_CDR::ULong len) +{ + if (this->read_array (in, + x, + ACE_CDR::OCTET_SIZE, + ACE_CDR::OCTET_ALIGN, + len)) + { + for (ACE_CDR::ULong i = 0; i != len; ++i) + x[i] = to_IBM1047[x[i]]; + + return 1; + } + + return 0; +} + +ACE_CDR::Boolean +ACE_IBM1047_ISO8859::write_char (ACE_OutputCDR& out, + ACE_CDR::Char x) +{ + return + this->write_1 (out, + reinterpret_cast (&from_IBM1047[x])); +} + +ACE_CDR::Boolean +ACE_IBM1047_ISO8859::write_string (ACE_OutputCDR& out, + ACE_CDR::ULong len, + const ACE_CDR::Char* x) +{ + if (out.write_ulong (len + 1)) + return this->write_char_array (out, x, len + 1); + return 0; +} + +ACE_CDR::Boolean +ACE_IBM1047_ISO8859::write_char_array (ACE_OutputCDR& out, + const ACE_CDR::Char* x, + ACE_CDR::ULong len) +{ + char *buf = 0; + if (this->adjust (out, len, 1, buf) == 0) + { + ACE_OS::memcpy (buf, x, len); + + for (ACE_CDR::ULong i = 0; i != len; ++i) + buf[i] = from_IBM1047[buf[i]]; + + return 1; + } + + this->good_bit(out, 0); + return 0; +} + +// **************************************************************** + +ACE_ISO8859_IBM1047::ACE_ISO8859_IBM1047 (void) +{ +} + +ACE_ISO8859_IBM1047::~ACE_ISO8859_IBM1047 (void) +{ +} + +ACE_CDR::ULong +ACE_ISO8859_IBM1047::ncs () +{ + return 0x00010001; +} + +ACE_CDR::ULong +ACE_ISO8859_IBM1047::tcs () +{ + return 0x10020417; +} + +ACE_CDR::Boolean +ACE_ISO8859_IBM1047::read_char (ACE_InputCDR& in, + ACE_CDR::Char& x) +{ + if (this->read_1 (in, reinterpret_cast (&x))) + { + x = from_IBM1047[x]; + return 1; + } + return 0; +} + +ACE_CDR::Boolean +ACE_ISO8859_IBM1047::read_string (ACE_InputCDR &in, + ACE_CDR::Char *&x) +{ + ACE_CDR::ULong len; + + in.read_ulong (len); + + if (len > 0) + { + ACE_NEW_RETURN (x, + ACE_CDR::Char[len], + 0); + + if (this->read_char_array (in, x, len)) + return 1; + + delete [] x; + } + + x = 0; + return 0; +} + +ACE_CDR::Boolean +ACE_ISO8859_IBM1047::read_char_array (ACE_InputCDR &in, + ACE_CDR::Char *x, + ACE_CDR::ULong len) +{ + if (this->read_array (in, + x, + ACE_CDR::OCTET_SIZE, + ACE_CDR::OCTET_ALIGN, + len)) + { + for (ACE_CDR::ULong i = 0; i != len; ++i) + x[i] = from_IBM1047[x[i]]; + + return 1; + } + + return 0; +} + +ACE_CDR::Boolean +ACE_ISO8859_IBM1047::write_char (ACE_OutputCDR &out, + ACE_CDR::Char x) +{ + return + this->write_1 (out, + reinterpret_cast (&to_IBM1047[x])); +} + +ACE_CDR::Boolean +ACE_ISO8859_IBM1047::write_string (ACE_OutputCDR& out, + ACE_CDR::ULong len, + const ACE_CDR::Char* x) +{ + if (out.write_ulong (len + 1)) + return this->write_char_array (out, x, len + 1); + else + return 0; +} + +ACE_CDR::Boolean +ACE_ISO8859_IBM1047::write_char_array (ACE_OutputCDR &out, + const ACE_CDR::Char *x, + ACE_CDR::ULong len) +{ + char *buf = 0; + + if (this->adjust (out, len, 1, buf) == 0) + { + ACE_OS::memcpy (buf, x, len); + + for (ACE_CDR::ULong i = 0; i != len; ++i) + buf[i] = to_IBM1047[buf[i]]; + + return 1; + } + + this->good_bit (out, 0); + return 0; +} + +ACE_END_VERSIONED_NAMESPACE_DECL + +#endif /* ACE_HAS_EBCDIC */ diff --git a/dep/ACE_wrappers/ace/Codeset_IBM1047.h b/dep/ACE_wrappers/ace/Codeset_IBM1047.h new file mode 100644 index 00000000000..3caa8881fbf --- /dev/null +++ b/dep/ACE_wrappers/ace/Codeset_IBM1047.h @@ -0,0 +1,127 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Codeset_IBM1047.h + * + * $Id: Codeset_IBM1047.h 81388 2008-04-23 14:02:05Z johnnyw $ + * + * Declares the arrays required to convert between ISO8859 (aka + * Latin/1) and IBM1047 (aka EBCDIC). + * + * @author Jim Rogers (jrogers@viasoft.com) + */ +//============================================================================= + + +#ifndef ACE_CODESET_IMB1047_H +#define ACE_CODESET_IMB1047_H +#include /**/ "ace/pre.h" + +#include /**/ "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#if defined (ACE_HAS_EBCDIC) + +#include "ace/CDR_Stream.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +// **************************************************************** + +/** + * @class ACE_IBM1047_ISO8859 + * + * @brief Codeset translation specialization. + * + * This class performs the codeset translation: + * - Native: IBM_1047 (i.e. EBCDIC) + * - Stream: ISO-8859 (i.e. Latin/1) + */ +class ACE_Export ACE_IBM1047_ISO8859 : public ACE_Char_Codeset_Translator +{ +public: + /// A do nothing constructor. + ACE_IBM1047_ISO8859 (void); + + /// Virtual destruction + virtual ~ACE_IBM1047_ISO8859 (void); + + // = Documented in $ACE_ROOT/ace/CDR_Stream.h + virtual ACE_CDR::Boolean read_char (ACE_InputCDR &, + ACE_CDR::Char &); + virtual ACE_CDR::Boolean read_string (ACE_InputCDR &, + ACE_CDR::Char *&); + virtual ACE_CDR::Boolean read_char_array (ACE_InputCDR &, + ACE_CDR::Char *, + ACE_CDR::ULong); + virtual ACE_CDR::Boolean write_char (ACE_OutputCDR &, + ACE_CDR::Char); + virtual ACE_CDR::Boolean write_string (ACE_OutputCDR &, + ACE_CDR::ULong, + const ACE_CDR::Char *); + virtual ACE_CDR::Boolean write_char_array (ACE_OutputCDR &, + const ACE_CDR::Char *, + ACE_CDR::ULong); + + /// Return the native codeset ID as defined in the OSF code and character + /// set registry, 0x10020417 + virtual ACE_CDR::ULong ncs (); + /// Return the translated codeset ID as defined in the OSF code and character + /// set registry, 0x00010001 + virtual ACE_CDR::ULong tcs (); +}; + +/** + * @class ACE_ISO8859_IBM1047 + * + * @brief Codeset translation specialization. + * + * This class performs the codeset translation: + * - Native: ISO-8859 (i.e. Latin/1) + * - Stream: IBM-1047 (i.e. EBCDIC) + */ +class ACE_Export ACE_ISO8859_IBM1047 : public ACE_Char_Codeset_Translator +{ +public: + /// A do nothing constructor. + ACE_ISO8859_IBM1047 (void); + + /// Virtual destruction + virtual ~ACE_ISO8859_IBM1047 (void); + + // = Documented in $ACE_ROOT/ace/CDR_Stream.h + virtual ACE_CDR::Boolean read_char (ACE_InputCDR &, + ACE_CDR::Char &); + virtual ACE_CDR::Boolean read_string (ACE_InputCDR &, + ACE_CDR::Char *&); + virtual ACE_CDR::Boolean read_char_array (ACE_InputCDR &, + ACE_CDR::Char *, + ACE_CDR::ULong); + virtual ACE_CDR::Boolean write_char (ACE_OutputCDR &, + ACE_CDR::Char); + virtual ACE_CDR::Boolean write_string (ACE_OutputCDR &, + ACE_CDR::ULong, + const ACE_CDR::Char *); + virtual ACE_CDR::Boolean write_char_array (ACE_OutputCDR &, + const ACE_CDR::Char *, + ACE_CDR::ULong); + + /// Return the native codeset ID as defined in the OSF code and character + /// set registry, 0x00010001 + virtual ACE_CDR::ULong ncs (); + /// Return the translated codeset ID as defined in the OSF code and character + /// set registry, 0x10020417 + virtual ACE_CDR::ULong tcs (); +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#endif /* ACE_EBCDIC */ + +#include /**/ "ace/post.h" + +#endif /* ACE_CODESET_IMB1047_H */ diff --git a/dep/ACE_wrappers/ace/Codeset_Registry.cpp b/dep/ACE_wrappers/ace/Codeset_Registry.cpp new file mode 100644 index 00000000000..c23ef37231a --- /dev/null +++ b/dep/ACE_wrappers/ace/Codeset_Registry.cpp @@ -0,0 +1,111 @@ +//============================================================================= +/** + * @file Codeset_Registry.cpp + * + * $Id: Codeset_Registry.cpp 80826 2008-03-04 14:51:23Z wotte $ + * + * emulated codset regstry functions + * + * + * @author Phil Mesnier + */ +//============================================================================= + +#include "ace/Codeset_Registry.h" +#include "ace/OS_Memory.h" +#include "ace/OS_NS_string.h" + +// $Id: Codeset_Registry.cpp 80826 2008-03-04 14:51:23Z wotte $ + +#if !defined (__ACE_INLINE__) +#include "ace/Codeset_Registry.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID (ace, + Codeset_Registry, + "$Id: Codeset_Registry.cpp 80826 2008-03-04 14:51:23Z wotte $") + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +int +ACE_Codeset_Registry::locale_to_registry_i (const ACE_CString &locale, + ACE_CDR::ULong &codeset_id, + ACE_CDR::UShort *num_sets, + ACE_CDR::UShort **char_sets) +{ + registry_entry const *element = 0; + for (size_t i = 0; element == 0 && i < num_registry_entries_; i++) + if (ACE_OS::strcmp (registry_db_[i].loc_name_, locale.c_str ()) == 0) + element = ®istry_db_[i]; + if (element == 0) + return 0; + codeset_id = element->codeset_id_; + if (num_sets != 0) + *num_sets = element->num_sets_; + if (char_sets != 0) + { + ACE_NEW_RETURN (*char_sets,ACE_CDR::UShort[element->num_sets_],0); + ACE_OS::memcpy (*char_sets, element->char_sets_, + element->num_sets_ * sizeof (ACE_CDR::UShort)); + } + return 1; +} + +int +ACE_Codeset_Registry::registry_to_locale_i (ACE_CDR::ULong codeset_id, + ACE_CString &locale, + ACE_CDR::UShort *num_sets, + ACE_CDR::UShort **char_sets) +{ + registry_entry const *element = 0; + for (size_t i = 0; element == 0 && i < num_registry_entries_; i++) + if (codeset_id == registry_db_[i].codeset_id_) + element = ®istry_db_[i]; + if (element == 0) + return 0; + locale.set (element->loc_name_); + if (num_sets != 0) + *num_sets = element->num_sets_; + if (char_sets != 0) + { + ACE_NEW_RETURN (*char_sets,ACE_CDR::UShort[element->num_sets_],0); + ACE_OS::memcpy (*char_sets, element->char_sets_, + element->num_sets_ * sizeof (ACE_CDR::UShort)); + } + return 1; +} + +int +ACE_Codeset_Registry::is_compatible_i (ACE_CDR::ULong codeset_id, + ACE_CDR::ULong other) +{ + registry_entry const *lhs = 0; + registry_entry const *rhs = 0; + for (size_t i = 0; (lhs == 0 || rhs == 0) && i < num_registry_entries_; i++) + { + if (codeset_id == registry_db_[i].codeset_id_) + lhs = ®istry_db_[i]; + if (other == registry_db_[i].codeset_id_) + rhs = ®istry_db_[i]; + } + + if (lhs == 0 || rhs == 0) + return 0; + + for (ACE_CDR::UShort l = 0; l < lhs->num_sets_; l++) + for (ACE_CDR::UShort r = 0; r < rhs->num_sets_; r++) + if (rhs->char_sets_[r] == lhs->char_sets_[l]) + return 1; + return 0; +} + +ACE_CDR::Short +ACE_Codeset_Registry::get_max_bytes_i (ACE_CDR::ULong codeset_id) +{ + for (size_t i = 0; i < num_registry_entries_; i++) + if (codeset_id == registry_db_[i].codeset_id_) + return registry_db_[i].max_bytes_; + return 0; +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Codeset_Registry.h b/dep/ACE_wrappers/ace/Codeset_Registry.h new file mode 100644 index 00000000000..e72c435f82b --- /dev/null +++ b/dep/ACE_wrappers/ace/Codeset_Registry.h @@ -0,0 +1,104 @@ +// -*- C++ -*- +//============================================================================= +/** + * @file Codeset_Registry.h + * + * $Id: Codeset_Registry.h 81348 2008-04-14 09:00:32Z johnnyw $ + * + * ACE wrapper around access functions for the OSF's DCE codeset registry + * access functions + * + * For environments that intrinsicly support the DCE defined access functions, + * the methods in this class are simply wrappers. On other platforms, emulation + * is provided. The motivation for this class is to support interoperability + * via translators and the CDR streams, primarily in TAO, but this capability + * is not restricted to CORBA. + * + * The emulated functionality supports Open Group RFC #40, currently RFC 40.2, + * www.opengroup.org/tech/rfc/rfc40.2.html + * + * @author Phil Mesnier + */ +//============================================================================= + +#ifndef ACE_CODESET_REGISTRY_H +#define ACE_CODESET_REGISTRY_H + +#include /**/ "ace/pre.h" +#include "ace/SString.h" +#include "ace/CDR_Base.h" +#include "ace/Codeset_Symbols.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#if defined (ACE_HAS_DCE_CODESET_REGISTRY) +#include /**/ +#endif /* ACE_HAS_DCE_CODESET_REGISTRY */ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +class ACE_Export ACE_Codeset_Registry +{ +public: + + /// Based on a locale string, find the registry value and optional codeset + /// collection. This wraps the dce_cs_loc_to_rgy function, or emulates it. + static int locale_to_registry (const ACE_CString &locale, + ACE_CDR::ULong &codeset_id, + ACE_CDR::UShort * = 0, + ACE_CDR::UShort ** = 0); + + /// Based on a registry value, find the locale string and optional codeset + /// collection. This wraps the dce_cs_rgy_to_loc function, or emulates it. + static int registry_to_locale (ACE_CDR::ULong codeset_id, + ACE_CString &locale, + ACE_CDR::UShort * = 0, + ACE_CDR::UShort ** = 0); + + /// Tell if two codesets are compatible. This wraps the + /// rpc_cs_char_set_compat_check function. + static int is_compatible (ACE_CDR::ULong codeset_id, + ACE_CDR::ULong other); + + /// Return the max number of bytes required to represent a single character. + /// This wraps the rpc_rgy_get_max_bytes function. + static ACE_CDR::Short get_max_bytes (ACE_CDR::ULong codeset_id); + + enum {max_charsets_ = 5}; +protected: + typedef struct { + const char * desc_; + const char * loc_name_; + ACE_CDR::ULong codeset_id_; + ACE_CDR::UShort num_sets_; + ACE_CDR::UShort char_sets_[max_charsets_]; + ACE_CDR::UShort max_bytes_; + } registry_entry; + +private: + static size_t const num_registry_entries_; + static registry_entry const registry_db_[]; + + static int locale_to_registry_i (const ACE_CString &locale, + ACE_CDR::ULong &codeset_id, + ACE_CDR::UShort * = 0, + ACE_CDR::UShort ** = 0); + static int registry_to_locale_i (ACE_CDR::ULong codeset_id, + ACE_CString &locale, + ACE_CDR::UShort * = 0, + ACE_CDR::UShort ** = 0); + static int is_compatible_i (ACE_CDR::ULong codeset_id, + ACE_CDR::ULong other); + static ACE_CDR::Short get_max_bytes_i (ACE_CDR::ULong codeset_id); +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +#include "ace/Codeset_Registry.inl" +#endif /* __ACE_INLINE__ */ + +#include /**/ "ace/post.h" +#endif /* ACE_CODESET_REGISTRY_H */ diff --git a/dep/ACE_wrappers/ace/Codeset_Registry.inl b/dep/ACE_wrappers/ace/Codeset_Registry.inl new file mode 100644 index 00000000000..4419cf5e7fc --- /dev/null +++ b/dep/ACE_wrappers/ace/Codeset_Registry.inl @@ -0,0 +1,102 @@ +// -*- C++ -*- +//============================================================================= +/** + * @file Codeset_Registry.inl + * + * $Id: Codeset_Registry.inl 80826 2008-03-04 14:51:23Z wotte $ + * + * ACE wrapper around access functions for the OSF's DCE codeset registry + * access functions - the inline functions either call the system supplied + * DCE based codeset regsitry function, or calls the emulation + * + * + * @author Phil Mesnier + */ +//============================================================================= + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_INLINE +int +ACE_Codeset_Registry::locale_to_registry(const ACE_CString &locale, + ACE_CDR::ULong &codeset_id, + ACE_CDR::UShort *num_sets, + ACE_CDR::UShort **char_sets) +{ +#if defined (ACE_HAS_DCE_CODESET_REGISTRY) + error_status_t result; + dce_cs_loc_to_rgy (locale.c_str(), + &codeset_id, + num_sets, + char_sets, + &result); + return (result == dce_cs_c_ok) ? 1 : 0; +#else + return ACE_Codeset_Registry::locale_to_registry_i (locale, + codeset_id, + num_sets, + char_sets); +#endif /* ACE_HAS_DCE_CODESET_REGISTRY */ +} + +// based on a registry value, find the locale string and optional codeset +// collection. This wraps the dce_cs_rgy_to_loc function, or emulates it. +ACE_INLINE +int +ACE_Codeset_Registry::registry_to_locale(ACE_CDR::ULong codeset_id, + ACE_CString &locale, + ACE_CDR::UShort *num_sets, + ACE_CDR::UShort **char_sets) +{ +#if defined (ACE_HAS_DCE_CODESET_REGISTRY) + error_status_t result; + char *buffer; + dce_cs_rgy_to_loc (codeset_id, + &buffer, + num_sets, + char_sets, + &result); + locale.set(buffer); // does a copy :-( + free (buffer); + return (result == dce_cs_c_ok) ? 1 : 0; +#else + return ACE_Codeset_Registry::registry_to_locale_i (codeset_id, + locale, + num_sets, + char_sets); +#endif /* ACE_HAS_DCE_CODESET_REGISTRY */ +} + +// Tell if two codesets are compatible. This wraps the +// rpc_cs_char_set_compat_check function. +ACE_INLINE +int +ACE_Codeset_Registry::is_compatible (ACE_CDR::ULong codeset_id, + ACE_CDR::ULong other) +{ +#if defined (ACE_HAS_DCE_CODESET_REGISTRY) + error_status_t result; + rpc_cs_char_set_compat_check(codeset_id,other,&result); + return (result == rpc_s_ok) ? 1 : 0; +#else + return ACE_Codeset_Registry::is_compatible_i (codeset_id,other); +#endif /* ACE_HAS_DCE_CODESET_REGISTRY */ +} + +// Return the max number of bytes required to represent a single character. +// This wraps the rpc_rgy_get_max_bytes function. +ACE_INLINE +ACE_CDR::Short +ACE_Codeset_Registry::get_max_bytes (ACE_CDR::ULong codeset_id) +{ +#if defined (ACE_HAS_DCE_CODESET_REGISTRY) + error_status_t result; + short max_bytes; + rpc_rgy_get_max_bytes(codeset_id,&max_bytes,&result); + return (result == rpc_s_ok) ? (short)max_bytes : 0; +#else + return ACE_Codeset_Registry::get_max_bytes_i (codeset_id); +#endif /* ACE_HAS_DCE_CODESET_REGISTRY */ +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Codeset_Registry_db.cpp b/dep/ACE_wrappers/ace/Codeset_Registry_db.cpp new file mode 100644 index 00000000000..32b38631c6f --- /dev/null +++ b/dep/ACE_wrappers/ace/Codeset_Registry_db.cpp @@ -0,0 +1,33 @@ +/* $Id: Codeset_Registry_db.cpp 81756 2008-05-22 09:47:33Z johnnyw $ + * Codeset registry DB, generated Fri Feb 28 21:01:30 2003 + * source: code_set_registry1.2g.txt + * + * To populate the registry_db, construct a codeset registry text file based + * on the OSF's Character and Code Set Registry. See DCE RFC 40.1 for details + * on obtaining the full text for the current registry. Once you have composed + * a text file containing all the desired codeset information, build and run + * mkcsregdb. The source is in $ACE_ROOT/apps/mkcsregdb. It will generate a new + * copy of this file, with the registry_db_ array properly initialized. + */ + +#include "ace/Codeset_Registry.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_Codeset_Registry::registry_entry const +ACE_Codeset_Registry::registry_db_[] = +{ + {"ISO/IEC 10646-1:1993; UCS-2, Level 1","UCS-2",0x00010100,1,{0x1000},2}, + {"ISO 8859-1:1987; Latin Alphabet No. 1","ISO8859_1",0x00010001,1,{0x0011},1}, + {"IBM-1047 (CCSID 01047); Latin-1 Open System","EBCDIC",0x10020417,1,{0x0011},1}, + {"ISO/IEC 10646-1:1993; UCS-4, Level 1","UCS-4",0x00010104,1,{0x1000},4}, + {"ISO/IEC 10646-1:1993; UTF-16, UCS Transformation Format 16-bit form","UTF-16",0x00010109,1,{0x1000},2}, + {"X/Open UTF-8; UCS Transformation Format 8 (UTF-8)","UTF-8",0x05010001,1,{0x1000},6}, + {"ISO/IEC 8859-5:1988; Latin-Cyrillic Alphabet","ISO-8859-5",0x00010005,1,{0x0015},1}, + {"IBM-1251 (CCSID 01251); MS Windows Cyrillic","CP1251",0x100204e3,1,{0x0015},1}, + {"IBM-855 (CCSID 04951); Cyrillic Personal Computer","CP855",0x10021357,1,{0x0015},1} +}; + +size_t const ACE_Codeset_Registry::num_registry_entries_ = 9; + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Codeset_Symbols.h b/dep/ACE_wrappers/ace/Codeset_Symbols.h new file mode 100644 index 00000000000..6ffe198c1a9 --- /dev/null +++ b/dep/ACE_wrappers/ace/Codeset_Symbols.h @@ -0,0 +1,220 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Codeset_Symbols.h + * + * $Id: Codeset_Symbols.h 80826 2008-03-04 14:51:23Z wotte $ + * + * Symbolic names for codeset ids. + * + * @author Dale Wilson (wilson_d@ociweb.com) + */ +//============================================================================= +#ifndef CODESET_SYMBOLS_H +#define CODESET_SYMBOLS_H + +// These numbers are assigned by the OpenGroup, a database is +// available at +// +// ftp://ftp.opengroup.org/pub/code_set_registry/ +// +// Alas, the database is in a semi-regular text file -- difficult to use. +// The following C/C++-friendly version of the codeset ids was captured +// from Version 1.2g of the registry. +// +#define ACE_CODESET_ID_ISO_8859_1 0x00010001U +#define ACE_CODESET_ID_ISO_8859_2 0x00010002U +#define ACE_CODESET_ID_ISO_8859_3 0x00010003U +#define ACE_CODESET_ID_ISO_8859_4 0x00010004U +#define ACE_CODESET_ID_ISO_8859_5 0x00010005U +#define ACE_CODESET_ID_ISO_8859_6 0x00010006U +#define ACE_CODESET_ID_ISO_8859_7 0x00010007U +#define ACE_CODESET_ID_ISO_8859_8 0x00010008U +#define ACE_CODESET_ID_ISO_8859_9 0x00010009U +#define ACE_CODESET_ID_ISO_8859_10 0x0001000AU +#define ACE_CODESET_ID_ISO_8859_15 0x0001000FU +#define ACE_CODESET_ID_ISO_646 0x00010020U +#define ACE_CODESET_ID_ISO_UCS_2_LEVEL_1 0x00010100U +#define ACE_CODESET_ID_ISO_UCS_2_LEVEL_2 0x00010101U +#define ACE_CODESET_ID_ISO_UCS_2_LEVEL_3 0x00010102U +#define ACE_CODESET_ID_ISO_UCS_4_LEVEL_1 0x00010104U +#define ACE_CODESET_ID_ISO_UCS_4_LEVEL_2 0x00010105U +#define ACE_CODESET_ID_ISO_UCS_4_LEVEL_3 0x00010106U +#define ACE_CODESET_ID_ISO_UTF_8 0x00010108U +#define ACE_CODESET_ID_ISO_UTF_16 0x00010109U +#define ACE_CODESET_ID_JIS_X0201 0x00030001U +#define ACE_CODESET_ID_JIS_X0208_1978 0x00030004U +#define ACE_CODESET_ID_JIS_X0208_1983 0x00030005U +#define ACE_CODESET_ID_JIS_X0208_1990 0x00030006U +#define ACE_CODESET_ID_JIS_X0212 0x0003000AU +#define ACE_CODESET_ID_JIS_EUCJP 0x00030010U +#define ACE_CODESET_ID_KS_C5601 0x00040001U +#define ACE_CODESET_ID_KS_C5657 0x00040002U +#define ACE_CODESET_ID_KS_EUCKR 0x0004000AU +#define ACE_CODESET_ID_CNS_11643_1986 0x00050001U +#define ACE_CODESET_ID_CNS_11643_1992 0x00050002U +#define ACE_CODESET_ID_CNS_EUCTW_1991 0x0005000AU +#define ACE_CODESET_ID_CNS_EUCTW_1993 0x00050010U +#define ACE_CODESET_ID_TIS_620_25290X000B0001U +#define ACE_CODESET_ID_TTB_CCDC 0x000D0001U +#define ACE_CODESET_ID_OSF_JAPANESE_UJIS 0x05000010U +#define ACE_CODESET_ID_OSF_JAPANESE_SJIS_1 0x05000011U +#define ACE_CODESET_ID_OSF_JAPANESE_SJIS_2 0x05000012U +#define ACE_CODESET_ID_XOPEN_UTF_8 0x05010001U +#define ACE_CODESET_ID_JVC_EUCJP 0x05020001U +#define ACE_CODESET_ID_JVC_SJIS 0x05020002U +#define ACE_CODESET_ID_DEC_KANJI 0x10000001U +#define ACE_CODESET_ID_SUPER_DEC_KANJI 0x10000002U +#define ACE_CODESET_ID_DEC_SHIFT_JIS 0x10000003U +#define ACE_CODESET_ID_HP_ROMAN8 0x10010001U +#define ACE_CODESET_ID_HP_KANA8 0x10010002U +#define ACE_CODESET_ID_HP_ARABIC8 0x10010003U +#define ACE_CODESET_ID_HP_GREEK8 0x10010004U +#define ACE_CODESET_ID_HP_HEBREW8 0x10010005U +#define ACE_CODESET_ID_HP_TURKISH8 0x10010006U +#define ACE_CODESET_ID_HP15CN 0x10010007U +#define ACE_CODESET_ID_HP_BIG5 0x10010008U +#define ACE_CODESET_ID_HP_JAPANESE15__SJIS_ 0x10010009U +#define ACE_CODESET_ID_HP_SJISHI 0x1001000AU +#define ACE_CODESET_ID_HP_SJISPC 0x1001000BU +#define ACE_CODESET_ID_HP_UJIS 0x1001000CU +#define ACE_CODESET_ID_IBM_037 0x10020025U +#define ACE_CODESET_ID_IBM_273 0x10020111U +#define ACE_CODESET_ID_IBM_277 0x10020115U +#define ACE_CODESET_ID_IBM_278 0x10020116U +#define ACE_CODESET_ID_IBM_280 0x10020118U +#define ACE_CODESET_ID_IBM_282 0x1002011AU +#define ACE_CODESET_ID_IBM_284 0x1002011CU +#define ACE_CODESET_ID_IBM_285 0x1002011DU +#define ACE_CODESET_ID_IBM_290 0x10020122U +#define ACE_CODESET_ID_IBM_297 0x10020129U +#define ACE_CODESET_ID_IBM_300 0x1002012CU +#define ACE_CODESET_ID_IBM_301 0x1002012DU +#define ACE_CODESET_ID_IBM_420 0x100201A4U +#define ACE_CODESET_ID_IBM_424 0x100201A8U +#define ACE_CODESET_ID_IBM_437 0x100201B5U +#define ACE_CODESET_ID_IBM_500 0x100201F4U +#define ACE_CODESET_ID_IBM_833 0x10020341U +#define ACE_CODESET_ID_IBM_834 0x10020342U +#define ACE_CODESET_ID_IBM_835 0x10020343U +#define ACE_CODESET_ID_IBM_836 0x10020344U +#define ACE_CODESET_ID_IBM_837 0x10020345U +#define ACE_CODESET_ID_IBM_838 0x10020346U +#define ACE_CODESET_ID_IBM_839 0x10020347U +#define ACE_CODESET_ID_IBM_850 0x10020352U +#define ACE_CODESET_ID_IBM_852 0x10020354U +#define ACE_CODESET_ID_IBM_855 0x10020357U +#define ACE_CODESET_ID_IBM_856 0x10020358U +#define ACE_CODESET_ID_IBM_857 0x10020359U +#define ACE_CODESET_ID_IBM_861 0x1002035DU +#define ACE_CODESET_ID_IBM_862 0x1002035EU +#define ACE_CODESET_ID_IBM_863 0x1002035FU +#define ACE_CODESET_ID_IBM_864 0x10020360U +#define ACE_CODESET_ID_IBM_866 0x10020362U +#define ACE_CODESET_ID_IBM_868 0x10020364U +#define ACE_CODESET_ID_IBM_869 0x10020365U +#define ACE_CODESET_ID_IBM_870 0x10020366U +#define ACE_CODESET_ID_IBM_871 0x10020367U +#define ACE_CODESET_ID_IBM_874 0x1002036AU +#define ACE_CODESET_ID_IBM_875 0x1002036BU +#define ACE_CODESET_ID_IBM_880 0x10020370U +#define ACE_CODESET_ID_IBM_891 0x1002037BU +#define ACE_CODESET_ID_IBM_896 0x10020380U +#define ACE_CODESET_ID_IBM_897 0x10020381U +#define ACE_CODESET_ID_IBM_903 0x10020387U +#define ACE_CODESET_ID_IBM_904 0x10020388U +#define ACE_CODESET_ID_IBM_918 0x10020396U +#define ACE_CODESET_ID_IBM_921 0x10020399U +#define ACE_CODESET_ID_IBM_922 0x1002039AU +#define ACE_CODESET_ID_IBM_926 0x1002039EU +#define ACE_CODESET_ID_IBM_927 0x1002039FU +#define ACE_CODESET_ID_IBM_928 0x100203A0U +#define ACE_CODESET_ID_IBM_929 0x100203A1U +#define ACE_CODESET_ID_IBM_930 0x100203A2U +#define ACE_CODESET_ID_IBM_932 0x100203A4U +#define ACE_CODESET_ID_IBM_933 0x100203A5U +#define ACE_CODESET_ID_IBM_934 0x100203A6U +#define ACE_CODESET_ID_IBM_935 0x100203A7U +#define ACE_CODESET_ID_IBM_936 0x100203A8U +#define ACE_CODESET_ID_IBM_937 0x100203A9U +#define ACE_CODESET_ID_IBM_938 0x100203AAU +#define ACE_CODESET_ID_IBM_939 0x100203ABU +#define ACE_CODESET_ID_IBM_941 0x100203ADU +#define ACE_CODESET_ID_IBM_942 0x100203AEU +#define ACE_CODESET_ID_IBM_943 0x100203AFU +#define ACE_CODESET_ID_IBM_946 0x100203B2U +#define ACE_CODESET_ID_IBM_947 0x100203B3U +#define ACE_CODESET_ID_IBM_948 0x100203B4U +#define ACE_CODESET_ID_IBM_949 0x100203B5U +#define ACE_CODESET_ID_IBM_950 0x100203B6U +#define ACE_CODESET_ID_IBM_951 0x100203B7U +#define ACE_CODESET_ID_IBM_955 0x100203BBU +#define ACE_CODESET_ID_IBM_964 0x100203C4U +#define ACE_CODESET_ID_IBM_970 0x100203CAU +#define ACE_CODESET_ID_IBM_1006 0x100203EEU +#define ACE_CODESET_ID_IBM_1025 0x10020401U +#define ACE_CODESET_ID_IBM_1026 0x10020402U +#define ACE_CODESET_ID_IBM_1027 0x10020403U +#define ACE_CODESET_ID_IBM_1040 0x10020410U +#define ACE_CODESET_ID_IBM_1041 0x10020411U +#define ACE_CODESET_ID_IBM_1043 0x10020413U +#define ACE_CODESET_ID_IBM_1046 0x10020416U +#define ACE_CODESET_ID_IBM_1047 0x10020417U +#define ACE_CODESET_ID_IBM_1088 0x10020440U +#define ACE_CODESET_ID_IBM_1097 0x10020449U +#define ACE_CODESET_ID_IBM_1098 0x1002044AU +#define ACE_CODESET_ID_IBM_1112 0x10020458U +#define ACE_CODESET_ID_IBM_1114 0x1002045AU +#define ACE_CODESET_ID_IBM_1115 0x1002045BU +#define ACE_CODESET_ID_IBM_1122 0x10020462U +#define ACE_CODESET_ID_IBM_1250 0x100204E2U +#define ACE_CODESET_ID_IBM_1251 0x100204E3U +#define ACE_CODESET_ID_IBM_1252 0x100204E4U +#define ACE_CODESET_ID_IBM_1253 0x100204E5U +#define ACE_CODESET_ID_IBM_1254 0x100204E6U +#define ACE_CODESET_ID_IBM_1255 0x100204E7U +#define ACE_CODESET_ID_IBM_1256 0x100204E8U +#define ACE_CODESET_ID_IBM_1257 0x100204E9U +#define ACE_CODESET_ID_IBM_1380 0x10020564U +#define ACE_CODESET_ID_IBM_1381 0x10020565U +#define ACE_CODESET_ID_IBM_1383 0x10020567U +#define ACE_CODESET_ID_IBM_4396 0x1002112CU +#define ACE_CODESET_ID_IBM_4946 0x10021352U +#define ACE_CODESET_ID_IBM_4948 0x10021354U +#define ACE_CODESET_ID_IBM_4951 0x10021357U +#define ACE_CODESET_ID_IBM_4952 0x10021358U +#define ACE_CODESET_ID_IBM_4953 0x10021359U +#define ACE_CODESET_ID_IBM_4960 0x10021360U +#define ACE_CODESET_ID_IBM_4964 0x10021364U +#define ACE_CODESET_ID_IBM_4965 0x10021365U +#define ACE_CODESET_ID_IBM_5026 0x100213A2U +#define ACE_CODESET_ID_IBM_5031 0x100213A7U +#define ACE_CODESET_ID_IBM_5035 0x100213ABU +#define ACE_CODESET_ID_IBM_5048 0x100213B8U +#define ACE_CODESET_ID_IBM_5049 0x100213B9U +#define ACE_CODESET_ID_IBM_5067 0x100213CBU +#define ACE_CODESET_ID_IBM_8612 0x100221A4U +#define ACE_CODESET_ID_IBM_9025 0x10022341U +#define ACE_CODESET_ID_IBM_9026 0x10022342U +#define ACE_CODESET_ID_IBM_9030 0x10022346U +#define ACE_CODESET_ID_IBM_9056 0x10022360U +#define ACE_CODESET_ID_IBM_9066 0x1002236AU +#define ACE_CODESET_ID_IBM_9125 0x100223A5U +#define ACE_CODESET_ID_IBM_25426 0x10026352U +#define ACE_CODESET_ID_IBM_25432 0x10026358U +#define ACE_CODESET_ID_IBM_1042 0x10026412U +#define ACE_CODESET_ID_IBM_28709 0x10027025U +#define ACE_CODESET_ID_IBM_33624 0x10028358U +#define ACE_CODESET_ID_IBM_33722 0x100283BAU +#define ACE_CODESET_ID_HTCSJIS 0x10030001U +#define ACE_CODESET_ID_HTCUJIS 0x10030002U +#define ACE_CODESET_ID_FUJITSU_U90 0x10040001U +#define ACE_CODESET_ID_FUJITSU_S90 0x10040002U +#define ACE_CODESET_ID_FUJITSU_R90 0x10040003U +#define ACE_CODESET_ID_EBCDIC_ASCII_AND_JEF 0x10040004U +#define ACE_CODESET_ID_EBCDIC_KATAKANA_AND_JEF 0x10040005U +#define ACE_CODESET_ID_EBCDIC_JAPANESE_ENGLISH_AND_JEF 0x10040006U + +#define ACE_CODESET_ID_TAO_BACKWARD_COMPATIBLE 0xf54414F0U +#endif // CODESET_SYMBOLS_H diff --git a/dep/ACE_wrappers/ace/Condition_Recursive_Thread_Mutex.cpp b/dep/ACE_wrappers/ace/Condition_Recursive_Thread_Mutex.cpp new file mode 100644 index 00000000000..2a12b132f24 --- /dev/null +++ b/dep/ACE_wrappers/ace/Condition_Recursive_Thread_Mutex.cpp @@ -0,0 +1,129 @@ +// -*- C++ -*- + +/** + * @file Condition_Recursive_Thread_Mutex.cpp + * + * $Id: Condition_Recursive_Thread_Mutex.cpp 80826 2008-03-04 14:51:23Z wotte $ + * + * Originally in Synch.cpp + * + * @author Douglas C. Schmidt + */ + +#include "ace/Condition_Recursive_Thread_Mutex.h" + +#if defined (ACE_HAS_THREADS) + +#if defined (ACE_HAS_DUMP) +# include "ace/Log_Msg.h" +#endif /* ACE_HAS_DUMP */ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +int +ACE_Condition::remove (void) +{ + return ACE_OS::cond_destroy (&this->cond_); +} + +void +ACE_Condition::dump (void) const +{ +#if defined (ACE_HAS_DUMP) +// ACE_TRACE ("ACE_Condition::dump"); + + ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); + // No dump method for ACE_cond_t even in emulated mode. + // cond_.dump (); + this->mutex_.dump (); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\n"))); + ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); +#endif /* ACE_HAS_DUMP */ +} + +ACE_Condition::~ACE_Condition (void) +{ + this->remove (); +} + +ACE_Condition::ACE_Condition (ACE_Recursive_Thread_Mutex &m) + : mutex_ (m) +{ + ACE_OS::cond_init (&this->cond_); +} + +int +ACE_Condition::wait (const ACE_Time_Value *abstime) +{ + return this->wait (this->mutex_, abstime); +} + +int +ACE_Condition::wait (ACE_Recursive_Thread_Mutex &mutex, + const ACE_Time_Value *abstime) +{ + ACE_recursive_mutex_state mutex_state_holder; + ACE_recursive_thread_mutex_t &recursive_mutex = mutex.mutex (); + + if (ACE_OS::recursive_mutex_cond_unlock (&recursive_mutex, + mutex_state_holder) == -1) + return -1; + + // We wait on the condition, specifying the nesting mutex. For platforms + // with ACE_HAS_RECURSIVE_MUTEXES, this is the recursive mutex itself, + // and is the same as recursive_mutex, above. The caller should have been + // holding the lock on entry to this method, and it is still held. + // For other platforms, this is the nesting mutex that guards the + // ACE_recursive_mutex_t internals, and recursive_mutex_cond_unlock() + // returned with the lock held, but waiters primed and waiting to be + // released. At cond_wait below, the mutex will be released. + // On return, it will be reacquired. + const int result = abstime == 0 + ? ACE_OS::cond_wait (&this->cond_, + &mutex.get_nesting_mutex ()) + : ACE_OS::cond_timedwait (&this->cond_, + &mutex.get_nesting_mutex (), + const_cast (abstime)); + // We are holding the mutex, whether the wait succeeded or failed. + // Stash errno (in case it failed) and then we need to reset the + // recursive mutex state to what it was on entry to this method. + // Resetting it may require a wait for another thread to release + // the ACE_recursive_thread_mutex_t if this is a platform without + // ACE_HAS_RECURSIVE_MUTEXES, and recursive_mutex_cond_relock() takes + // care of that. + { + ACE_Errno_Guard error (errno); + ACE_OS::recursive_mutex_cond_relock (&recursive_mutex, + mutex_state_holder); + } + + return result; +} + +int +ACE_Condition::signal (void) +{ + return ACE_OS::cond_signal (&this->cond_); +} + +int +ACE_Condition::broadcast (void) +{ + return ACE_OS::cond_broadcast (&this->cond_); +} + +ACE_Recursive_Thread_Mutex & +ACE_Condition::mutex (void) +{ + return this->mutex_; +} + +ACE_Condition_Recursive_Thread_Mutex::ACE_Condition_Recursive_Thread_Mutex ( + ACE_Recursive_Thread_Mutex &m) : + ACE_Condition (m) +{ +} + +ACE_END_VERSIONED_NAMESPACE_DECL + +#endif /* ACE_HAS_THREADS */ diff --git a/dep/ACE_wrappers/ace/Condition_Recursive_Thread_Mutex.h b/dep/ACE_wrappers/ace/Condition_Recursive_Thread_Mutex.h new file mode 100644 index 00000000000..f3c4b525780 --- /dev/null +++ b/dep/ACE_wrappers/ace/Condition_Recursive_Thread_Mutex.h @@ -0,0 +1,118 @@ +// -*- C++ -*- + +//========================================================================== +/** + * @file Condition_Recursive_Thread_Mutex.h + * + * $Id: Condition_Recursive_Thread_Mutex.h 80826 2008-03-04 14:51:23Z wotte $ + * + * Moved from Synch.h. + * + * @author Douglas C. Schmidt + */ +//========================================================================== + +#ifndef ACE_CONDITION_RECURSIVE_THREAD_MUTEX_H +#define ACE_CONDITION_RECURSIVE_THREAD_MUTEX_H +#include /**/ "ace/pre.h" + +#include /**/ "ace/ACE_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#if !defined (ACE_HAS_THREADS) +# include "ace/Null_Condition.h" +#else /* ACE_HAS_THREADS */ +#include "ace/Recursive_Thread_Mutex.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +template class ACE_Condition; + +/** + * @class ACE_Condition + * + * @brief ACE_Condition template specialization written using + * @a ACE_Recursive_Thread_Mutex. This allows threads to block until + * shared data changes state using recursive mutexes. + */ +template<> +class ACE_Export ACE_Condition +{ +public: + /// Initialize the condition variable with a recursive mutex. + ACE_Condition (ACE_Recursive_Thread_Mutex &m); + + /// Implicitly destroy the condition variable. + ~ACE_Condition (void); + + /** + * Explicitly destroy the condition variable. Note that only one + * thread should call this method since it doesn't protect against + * race conditions. + */ + int remove (void); + + /** + * Block on condition, or until absolute time-of-day has passed. If + * abstime == 0 use "blocking" semantics. Else, if + * != 0 and the call times out before the condition is signaled + * returns -1 and sets errno to ETIME. + */ + int wait (const ACE_Time_Value *abstime = 0); + + /** + * Block on condition or until absolute time-of-day has passed. If + * abstime == 0 use "blocking" wait() semantics on the recursive @a mutex + * passed as a parameter (this is useful if you need to store the + * in shared memory). Else, if != 0 and the + * call times out before the condition is signaled returns -1 + * and sets errno to ETIME. + */ + int wait (ACE_Recursive_Thread_Mutex &mutex, + const ACE_Time_Value *abstime = 0); + + /// Signal one waiting thread. + int signal (void); + + /// Signal *all* waiting threads. + int broadcast (void); + + /// Returns a reference to the underlying mutex; + ACE_Recursive_Thread_Mutex &mutex (void); + + /// Dump the state of an object. + void dump (void) const; + +private: + + // = Prevent assignment and copying. + void operator= (const ACE_Condition &); + ACE_Condition (const ACE_Condition &); + +private: + + /// A normal (i.e., non-recursive) condition variable. + ACE_cond_t cond_; + + /// Reference to the recursive mutex. + ACE_Recursive_Thread_Mutex &mutex_; + +}; + +class ACE_Export ACE_Condition_Recursive_Thread_Mutex + : public ACE_Condition +{ +public: + /// Initialize the condition variable with a recursive mutex. + ACE_Condition_Recursive_Thread_Mutex (ACE_Recursive_Thread_Mutex &m); +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#endif /* !ACE_HAS_THREADS */ + +#include /**/ "ace/post.h" +#endif /* ACE_CONDITION_RECURSIVE_THREAD_MUTEX_H */ diff --git a/dep/ACE_wrappers/ace/Condition_T.cpp b/dep/ACE_wrappers/ace/Condition_T.cpp new file mode 100644 index 00000000000..a2ebff1538e --- /dev/null +++ b/dep/ACE_wrappers/ace/Condition_T.cpp @@ -0,0 +1,122 @@ +// $Id: Condition_T.cpp 81283 2008-04-09 01:28:18Z schmidt $ + +#ifndef ACE_CONDITION_T_CPP +#define ACE_CONDITION_T_CPP + +#include "ace/Condition_T.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#if defined (ACE_HAS_THREADS) + +#include "ace/Log_Msg.h" + +#if !defined (__ACE_INLINE__) +#include "ace/Condition_T.inl" +#endif /* __ACE_INLINE__ */ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_ALLOC_HOOK_DEFINE(ACE_Condition) + +template void +ACE_Condition::dump (void) const +{ +#if defined (ACE_HAS_DUMP) +// ACE_TRACE ("ACE_Condition::dump"); + + ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\n"))); + ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); +#endif /* ACE_HAS_DUMP */ +} + +template +ACE_Thread_Condition::ACE_Thread_Condition (MUTEX &m, + const ACE_TCHAR *name, + void *arg) + : ACE_Condition (m, USYNC_THREAD, name, arg) +{ +// ACE_TRACE ("ACE_Thread_Condition::ACE_Thread_Condition"); +} + +template void +ACE_Thread_Condition::dump (void) const +{ +#if defined (ACE_HAS_DUMP) +// ACE_TRACE ("ACE_Thread_Condition::dump"); + + ACE_Condition::dump (); +#endif /* ACE_HAS_DUMP */ +} + +template +ACE_Condition::ACE_Condition (MUTEX &m, + int type, + const ACE_TCHAR *name, + void *arg) + : + mutex_ (m) +{ + // ACE_TRACE ("ACE_Condition::ACE_Condition"); + + if (ACE_OS::cond_init (&this->cond_, + (short) type, + name, + arg) != 0) + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("%p\n"), + ACE_TEXT ("ACE_Condition::ACE_Condition"))); +} + +template +ACE_Condition::~ACE_Condition (void) +{ + // ACE_TRACE ("ACE_Condition::~ACE_Condition"); + + if (this->remove () == -1) + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("%p\n"), + ACE_TEXT ("ACE_Condition::~ACE_Condition"))); +} + +template int +ACE_Condition::wait (void) +{ + // ACE_TRACE ("ACE_Condition::wait"); + return ACE_OS::cond_wait (&this->cond_, + &this->mutex_.lock_); +} + +template int +ACE_Condition::wait (MUTEX &mutex, + const ACE_Time_Value *abstime) +{ +// ACE_TRACE ("ACE_Condition::wait"); + if (abstime == 0) + return ACE_OS::cond_wait (&this->cond_, + &mutex.lock_); + else + return ACE_OS::cond_timedwait (&this->cond_, + &mutex.lock_, + (ACE_Time_Value *) abstime); +} + +// Peform an "alertable" timed wait. If the argument ABSTIME == 0 +// then we do a regular cond_wait(), else we do a timed wait for up to +// ABSTIME using the Solaris cond_timedwait() function. + +template int +ACE_Condition::wait (const ACE_Time_Value *abstime) +{ +// ACE_TRACE ("ACE_Condition::wait"); + return this->wait (this->mutex_, abstime); +} + +ACE_END_VERSIONED_NAMESPACE_DECL + +#endif /* ACE_HAS_THREADS */ + +#endif /* ACE_CONDITION_T_CPP */ diff --git a/dep/ACE_wrappers/ace/Condition_T.h b/dep/ACE_wrappers/ace/Condition_T.h new file mode 100644 index 00000000000..936ce821777 --- /dev/null +++ b/dep/ACE_wrappers/ace/Condition_T.h @@ -0,0 +1,167 @@ +// -*- C++ -*- + +//========================================================================== +/** + * @file Condition_T.h + * + * $Id: Condition_T.h 81462 2008-04-28 11:39:40Z johnnyw $ + * + * Moved from Synch.h. + * + * @author Douglas C. Schmidt + */ +//========================================================================== + +#ifndef ACE_CONDITION_T_H +#define ACE_CONDITION_T_H + +#include /**/ "ace/pre.h" + +#include "ace/OS_NS_Thread.h" +#include "ace/Lock.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#if defined (ACE_HAS_THREADS) /* ACE platform supports some form of threading. */ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +class ACE_Time_Value; + +/** + * @class ACE_Condition + * + * @brief ACE_Condition variable wrapper, which allows threads to block + * until shared data changes state. + * + * A condition variable enables threads to atomically block and + * test the condition under the protection of a mutual exclu- + * sion lock (mutex) until the condition is satisfied. That is, + * the mutex must have been held by the thread before calling + * wait or signal on the condition. If the condition is false, + * a thread blocks on a condition variable and atomically + * releases the mutex that is waiting for the condition to + * change. If another thread changes the condition, it may wake + * up waiting threads by signaling the associated condition + * variable. The waiting threads, upon awakening, reacquire the + * mutex and re-evaluate the condition. + * Note, you can only parameterize with + * @a ACE_Thread_Mutex, @a ACE_Recursive_Thread_Mutex, or @a ACE_Null_Mutex. + */ +template +class ACE_Condition +{ +public: + // = Initialiation and termination methods. + /// Initialize the condition variable. + ACE_Condition (MUTEX &m, int type = USYNC_THREAD, + const ACE_TCHAR *name = 0, void *arg = 0); + + /// Implicitly destroy the condition variable. + ~ACE_Condition (void); + + // = Lock accessors. + /** + * Block on condition, or until absolute time-of-day has passed. If + * @a abstime == 0 use "blocking" semantics. Else, if @a abstime + * != 0 and the call times out before the condition is signaled + * returns -1 and sets errno to ETIME. + */ + int wait (const ACE_Time_Value *abstime); + + /// Block on condition. + int wait (void); + + /** + * Block on condition or until absolute time-of-day has passed. If + * abstime == 0 use "blocking" wait() semantics on the + * passed as a parameter (this is useful if you need to store the + * in shared memory). Else, if != 0 and the + * call times out before the condition is signaled returns -1 + * and sets errno to ETIME. + */ + int wait (MUTEX &mutex, const ACE_Time_Value *abstime = 0); + + /// Signal one waiting thread. + int signal (void); + + /// Signal *all* waiting threads. + int broadcast (void); + + // = Utility methods. + /// Explicitly destroy the condition variable. + int remove (void); + + /// Returns a reference to the underlying mutex_; + MUTEX &mutex (void); + + /// Dump the state of an object. + void dump (void) const; + + // ACE_ALLOC_HOOK_DECLARE; + // Declare the dynamic allocation hooks. + +protected: + /// Condition variable. + ACE_cond_t cond_; + + /// Reference to mutex lock. + MUTEX &mutex_; + +private: + // = Prevent assignment and initialization. + ACE_UNIMPLEMENTED_FUNC (void operator= (const ACE_Condition &)) + ACE_UNIMPLEMENTED_FUNC (ACE_Condition (const ACE_Condition &)) +}; + +/** + * @class ACE_Thread_Condition + * + * @brief ACE_Condition variable wrapper that works within processes. + * + * A condition variable enables threads to atomically block and + * test the condition under the protection of a mutual exclu- + * sion lock (mutex) until the condition is satisfied. That is, + * the mutex must have been held by the thread before calling + * wait or signal on the condition. If the condition is false, + * a thread blocks on a condition variable and atomically + * releases the mutex that is waiting for the condition to + * change. If another thread changes the condition, it may wake + * up waiting threads by signaling the associated condition + * variable. The waiting threads, upon awakening, reacquire the + * mutex and re-evaluate the condition. + */ +template +class ACE_Thread_Condition : public ACE_Condition +{ +public: + // = Initialization method. + ACE_Thread_Condition (MUTEX &m, const ACE_TCHAR *name = 0, void *arg = 0); + + /// Dump the state of an object. + void dump (void) const; + + // ACE_ALLOC_HOOK_DECLARE; + // Declare the dynamic allocation hooks. +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +#include "ace/Condition_T.inl" +#endif /* __ACE_INLINE__ */ + +#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) +#include "ace/Condition_T.cpp" +#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ + +#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) +#pragma implementation ("Condition_T.cpp") +#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ + +#endif /* ACE_HAS_THREADS */ + +#include /**/ "ace/post.h" +#endif /* ACE_CONDITION_T_H */ diff --git a/dep/ACE_wrappers/ace/Condition_T.inl b/dep/ACE_wrappers/ace/Condition_T.inl new file mode 100644 index 00000000000..e3b452734a2 --- /dev/null +++ b/dep/ACE_wrappers/ace/Condition_T.inl @@ -0,0 +1,51 @@ +// -*- C++ -*- +// +// $Id: Condition_T.inl 80826 2008-03-04 14:51:23Z wotte $ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +template ACE_INLINE int +ACE_Condition::remove (void) +{ + // ACE_TRACE ("ACE_Condition::remove"); + + // cond_destroy() is called in a loop if the condition variable is + // BUSY. This avoids a condition where a condition is signaled and + // because of some timing problem, the thread that is to be signaled + // has called the cond_wait routine after the signal call. Since + // the condition signal is not queued in any way, deadlock occurs. + + int result = 0; + + while ((result = ACE_OS::cond_destroy (&this->cond_)) == -1 + && errno == EBUSY) + { + ACE_OS::cond_broadcast (&this->cond_); + ACE_OS::thr_yield (); + } + + return result; +} + +template ACE_INLINE MUTEX & +ACE_Condition::mutex (void) +{ + // ACE_TRACE ("ACE_Condition::mutex"); + return this->mutex_; +} + +template ACE_INLINE int +ACE_Condition::signal (void) +{ +// ACE_TRACE ("ACE_Condition::signal"); + return ACE_OS::cond_signal (&this->cond_); +} + +template ACE_INLINE int +ACE_Condition::broadcast (void) +{ +// ACE_TRACE ("ACE_Condition::broadcast"); + return ACE_OS::cond_broadcast (&this->cond_); +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Condition_Thread_Mutex.cpp b/dep/ACE_wrappers/ace/Condition_Thread_Mutex.cpp new file mode 100644 index 00000000000..c9f2620e432 --- /dev/null +++ b/dep/ACE_wrappers/ace/Condition_Thread_Mutex.cpp @@ -0,0 +1,126 @@ +/* -*- C++ -*- */ +/** + * @file Condition_Thread_Mutex.cpp + * + * $Id: Condition_Thread_Mutex.cpp 80826 2008-03-04 14:51:23Z wotte $ + * + * Originally in Synch.cpp + * + * @author Douglas C. Schmidt + */ + +#include "ace/Condition_Thread_Mutex.h" + +#if defined (ACE_HAS_THREADS) + +#if !defined (__ACE_INLINE__) +#include "ace/Condition_Thread_Mutex.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/Log_Msg.h" + +ACE_RCSID(ace, Condition_Thread_Mutex, "$Id: Condition_Thread_Mutex.cpp 80826 2008-03-04 14:51:23Z wotte $") + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_ALLOC_HOOK_DEFINE(ACE_Condition_Thread_Mutex) + +void +ACE_Condition_Thread_Mutex::dump (void) const +{ +#if defined (ACE_HAS_DUMP) +// ACE_TRACE ("ACE_Condition_Thread_Mutex::dump"); + + ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\n"))); +#if defined (ACE_WIN32) + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("waiters = %d\n"), + this->cond_.waiters ())); +#endif /* ACE_WIN32 */ + ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); +#endif /* ACE_HAS_DUMP */ +} + +ACE_Condition_Thread_Mutex::ACE_Condition_Thread_Mutex (ACE_Thread_Mutex &m, + const ACE_TCHAR *name, + void *arg) + : mutex_ (m), + removed_ (false) +{ +// ACE_TRACE ("ACE_Condition_Thread_Mutex::ACE_Condition_Thread_Mutex"); + if (ACE_OS::cond_init (&this->cond_, + (short) USYNC_THREAD, + name, + arg) != 0) + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("%p\n"), + ACE_TEXT ("ACE_Condition_Thread_Mutex::ACE_Condition_Thread_Mutex"))); +} + +ACE_Condition_Thread_Mutex:: +ACE_Condition_Thread_Mutex (ACE_Thread_Mutex &m, + ACE_Condition_Attributes &attributes, + const ACE_TCHAR *name, + void *arg) + : mutex_ (m), + removed_ (false) +{ +// ACE_TRACE ("ACE_Condition_Thread_Mutex::ACE_Condition_Thread_Mutex"); + if (ACE_OS::cond_init (&this->cond_, attributes.attributes_, + name, arg) != 0) + ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"), + ACE_TEXT ("ACE_Condition_Thread_Mutex::ACE_Condition_Thread_Mutex"))); +} + +ACE_Condition_Thread_Mutex::~ACE_Condition_Thread_Mutex (void) +{ +// ACE_TRACE ("ACE_Condition_Thread_Mutex::~ACE_Condition_Thread_Mutex"); + this->remove (); +} + +// Peform an "alertable" timed wait. If the argument == 0 +// then we do a regular , else we do a timed wait for up to +// using the function. + +int +ACE_Condition_Thread_Mutex::wait (void) +{ +// ACE_TRACE ("ACE_Condition_Thread_Mutex::wait"); + return ACE_OS::cond_wait (&this->cond_, &this->mutex_.lock_); +} + +int +ACE_Condition_Thread_Mutex::wait (ACE_Thread_Mutex &mutex, + const ACE_Time_Value *abstime) +{ +// ACE_TRACE ("ACE_Condition_Thread_Mutex::wait"); + return ACE_OS::cond_timedwait (&this->cond_, + &mutex.lock_, + const_cast (abstime)); +} + +int +ACE_Condition_Thread_Mutex::wait (const ACE_Time_Value *abstime) +{ +// ACE_TRACE ("ACE_Condition_Thread_Mutex::wait"); + return this->wait (this->mutex_, abstime); +} + +int +ACE_Condition_Thread_Mutex::signal (void) +{ +// ACE_TRACE ("ACE_Condition_Thread_Mutex::signal"); + return ACE_OS::cond_signal (&this->cond_); +} + +int +ACE_Condition_Thread_Mutex::broadcast (void) +{ +// ACE_TRACE ("ACE_Condition_Thread_Mutex::broadcast"); + return ACE_OS::cond_broadcast (&this->cond_); +} + +ACE_END_VERSIONED_NAMESPACE_DECL + +#endif /* ACE_HAS_THREADS */ diff --git a/dep/ACE_wrappers/ace/Condition_Thread_Mutex.h b/dep/ACE_wrappers/ace/Condition_Thread_Mutex.h new file mode 100644 index 00000000000..693ff0820aa --- /dev/null +++ b/dep/ACE_wrappers/ace/Condition_Thread_Mutex.h @@ -0,0 +1,190 @@ +// -*- C++ -*- + +//========================================================================== +/** + * @file Condition_Thread_Mutex.h + * + * $Id: Condition_Thread_Mutex.h 80826 2008-03-04 14:51:23Z wotte $ + * + * Moved from Synch.h. + * + * @author Douglas C. Schmidt + */ +//========================================================================== + +#ifndef ACE_CONDITION_THREAD_MUTEX_H +#define ACE_CONDITION_THREAD_MUTEX_H +#include /**/ "ace/pre.h" + +#include /**/ "ace/ACE_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#if !defined (ACE_HAS_THREADS) +# include "ace/Null_Condition.h" +#else /* ACE_HAS_THREADS */ +// ACE platform supports some form of threading. + +#include "ace/Thread_Mutex.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +class ACE_Time_Value; + +class ACE_Export ACE_Condition_Attributes +{ +public: + /// Constructor + ACE_Condition_Attributes (int type = ACE_DEFAULT_SYNCH_TYPE); + + /// Destructor + ~ACE_Condition_Attributes (void); + +private: + friend class ACE_Condition_Thread_Mutex; + + /// The attributes + ACE_condattr_t attributes_; + +private: + // = Prevent assignment and initialization. + void operator= (const ACE_Condition_Attributes &); + ACE_Condition_Attributes (const ACE_Condition_Attributes &); +}; + +/** + * @class ACE_Condition_Thread_Mutex + * + * @brief ACE_Condition variable wrapper written using ACE_Mutexes This + * allows threads to block until shared data changes state. + * A condition variable enables threads to atomically block and + * test the condition under the protection of a mutual exclu- + * sion lock (mutex) until the condition is satisfied. That is, + * the mutex must have been held by the thread before calling + * wait or signal on the condition. If the condition is false, + * a thread blocks on a condition variable and atomically + * releases the mutex that is waiting for the condition to + * change. If another thread changes the condition, it may wake + * up waiting threads by signaling the associated condition + * variable. The waiting threads, upon awakening, reacquire the + * mutex and re-evaluate the condition. + * + * This should be an instantiation of ACE_Condition but problems + * with compilers precludes this... + */ +class ACE_Export ACE_Condition_Thread_Mutex +{ +public: + /// Initialize the condition variable. + ACE_Condition_Thread_Mutex (ACE_Thread_Mutex &m, + const ACE_TCHAR *name = 0, + void *arg = 0); + + /// Initialize the condition variable. + ACE_Condition_Thread_Mutex (ACE_Thread_Mutex &m, + ACE_Condition_Attributes &attributes, + const ACE_TCHAR *name = 0, + void *arg = 0); + + /// Implicitly destroy the condition variable. + ~ACE_Condition_Thread_Mutex (void); + + /** + * Explicitly destroy the condition variable. Note that only one + * thread should call this method since it doesn't protect against + * race conditions. + */ + int remove (void); + + /** + * Block on condition, or until absolute time-of-day has passed. If + * abstime == 0 use "blocking" semantics. Else, if @a abstime + * != 0 and the call times out before the condition is signaled + * returns -1 and sets errno to ETIME. + */ + int wait (const ACE_Time_Value *abstime); + + /// Block on condition. + int wait (void); + + /** + * Block on condition or until absolute time-of-day has passed. If + * abstime == 0 use "blocking" wait() semantics on the + * passed as a parameter (this is useful if you need to store the + * in shared memory). Else, if @a abstime != 0 and the + * call times out before the condition is signaled returns -1 + * and sets errno to ETIME. + */ + int wait (ACE_Thread_Mutex &mutex, const ACE_Time_Value *abstime = 0); + + /// Signal one waiting thread. + int signal (void); + + /// Signal *all* waiting threads. + int broadcast (void); + + /// Returns a reference to the underlying mutex; + ACE_Thread_Mutex &mutex (void); + + /// Dump the state of an object. + void dump (void) const; + + /// Declare the dynamic allocation hooks. + ACE_ALLOC_HOOK_DECLARE; + +protected: + /// Condition variable. + ACE_cond_t cond_; + + /// Reference to mutex lock. + ACE_Thread_Mutex &mutex_; + + /// Keeps track of whether has been called yet to avoid + /// multiple calls, e.g., explicitly and implicitly in the + /// destructor. This flag isn't protected by a lock, so make sure + /// that you don't have multiple threads simultaneously calling + /// on the same object, which is a bad idea anyway... + bool removed_; + +private: + // = Prevent assignment and initialization. + void operator= (const ACE_Condition_Thread_Mutex &); + ACE_Condition_Thread_Mutex (const ACE_Condition_Thread_Mutex &); +}; + +#if 0 +// The following class is commented out since there doesn't +// appear to be a portable and robust means of implementing this +// functionality across platforms. If you know of a portable and +// robust way to implement this functionality please let us know. + +/** + * @class ACE_Process_Condition + * + * @brief ACE_Condition variable wrapper that works across processes. + */ +class ACE_Export ACE_Process_Condition +{ +public: + ACE_Process_Condition (MUTEX &m, const ACE_TCHAR *name = 0, void *arg = 0); + + /// Dump the state of an object. + void dump (void) const; + + // ACE_ALLOC_HOOK_DECLARE; + // Declare the dynamic allocation hooks. +}; +#endif /* 0 */ + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +#include "ace/Condition_Thread_Mutex.inl" +#endif /* __ACE_INLINE__ */ + +#endif /* !ACE_HAS_THREADS */ + +#include /**/ "ace/post.h" +#endif /* ACE_CONDITION_THREAD_MUTEX_H */ diff --git a/dep/ACE_wrappers/ace/Condition_Thread_Mutex.inl b/dep/ACE_wrappers/ace/Condition_Thread_Mutex.inl new file mode 100644 index 00000000000..851269e4af6 --- /dev/null +++ b/dep/ACE_wrappers/ace/Condition_Thread_Mutex.inl @@ -0,0 +1,74 @@ +// -*- C++ -*- +// +// $Id: Condition_Thread_Mutex.inl 80826 2008-03-04 14:51:23Z wotte $ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_INLINE +ACE_Condition_Attributes::ACE_Condition_Attributes (int type) +{ + (void) ACE_OS::condattr_init (this->attributes_, type); +} + +ACE_INLINE +ACE_Condition_Attributes::~ACE_Condition_Attributes (void) +{ + ACE_OS::condattr_destroy (this->attributes_); +} + +ACE_INLINE int +ACE_Condition_Thread_Mutex::remove (void) +{ +// ACE_TRACE ("ACE_Condition_Thread_Mutex::remove"); + + // is called in a loop if the condition variable is + // BUSY. This avoids a condition where a condition is signaled and + // because of some timing problem, the thread that is to be signaled + // has called the cond_wait routine after the signal call. Since + // the condition signal is not queued in any way, deadlock occurs. + + int result = 0; + + if (!this->removed_) + { + this->removed_ = true; + + while ((result = ACE_OS::cond_destroy (&this->cond_)) == -1 + && errno == EBUSY) + { + ACE_OS::cond_broadcast (&this->cond_); + ACE_OS::thr_yield (); + } + } + return result; +} + +ACE_INLINE ACE_Thread_Mutex & +ACE_Condition_Thread_Mutex::mutex (void) +{ +// ACE_TRACE ("ACE_Condition_Thread_Mutex::mutex"); + return this->mutex_; +} + +#if 0 +template void +ACE_Process_Condition::dump (void) const +{ +#if defined (ACE_HAS_DUMP) +// ACE_TRACE ("ACE_Process_Condition::dump"); + + ACE_Condition::dump (); +#endif /* ACE_HAS_DUMP */ +} + +template +ACE_Process_Condition::ACE_Process_Condition (MUTEX &m, + const ACE_TCHAR *name, + void *arg) + : ACE_Condition (m, USYNC_PROCESS, name, arg) +{ +// ACE_TRACE ("ACE_Process_Condition::ACE_Process_Condition"); +} +#endif /* 0 */ + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Configuration.cpp b/dep/ACE_wrappers/ace/Configuration.cpp new file mode 100644 index 00000000000..734482f0e55 --- /dev/null +++ b/dep/ACE_wrappers/ace/Configuration.cpp @@ -0,0 +1,2148 @@ +// $Id: Configuration.cpp 80826 2008-03-04 14:51:23Z wotte $ +#include "ace/Configuration.h" +#include "ace/Auto_Ptr.h" +#include "ace/SString.h" +#include "ace/OS_NS_string.h" +#include "ace/OS_NS_strings.h" + +// Can remove this when import_config and export_config are removed from +// ACE_Configuration. They're deprecated at ACE 5.2. +#include "ace/Configuration_Import_Export.h" + +#if !defined (ACE_LACKS_ACCESS) +# include "ace/OS_NS_unistd.h" +#endif /* ACE_LACKS_ACCESS */ + +#if !defined (__ACE_INLINE__) +#include "ace/Configuration.inl" +#endif /* __ACE_INLINE__ */ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_Section_Key_Internal::ACE_Section_Key_Internal (void) + : ref_count_ (0) +{ +} + +ACE_Section_Key_Internal::~ACE_Section_Key_Internal (void) +{ +} + +int +ACE_Section_Key_Internal::add_ref (void) +{ + ++ref_count_; + return 0; +} + +int +ACE_Section_Key_Internal::dec_ref (void) +{ + if (!--ref_count_) + delete this; + return 0; +} + +ACE_Configuration_Section_Key::ACE_Configuration_Section_Key (void) + : key_ (0) +{ +} + +ACE_Configuration_Section_Key::~ACE_Configuration_Section_Key (void) +{ + if (key_) + key_->dec_ref (); +} + +ACE_Configuration_Section_Key::ACE_Configuration_Section_Key (ACE_Section_Key_Internal* key) + : key_ (key) +{ + if (key_) + key_->add_ref (); +} + +ACE_Configuration_Section_Key::ACE_Configuration_Section_Key (const ACE_Configuration_Section_Key& rhs) + : key_ (rhs.key_) +{ + if (key_) + key_->add_ref (); +} + +ACE_Configuration_Section_Key& +ACE_Configuration_Section_Key::operator= (const ACE_Configuration_Section_Key& rhs) +{ + if (this != &rhs) + { + if (key_) + key_->dec_ref (); + + key_ = rhs.key_; + + if (key_) + key_->add_ref (); + } + return *this; +} + +////////////////////////////////////////////////////////////////////////////// + +ACE_TCHAR ACE_Configuration::NULL_String_ = '\0'; + +ACE_Configuration::ACE_Configuration (void) + : root_ () +{ +} + +ACE_Configuration::~ACE_Configuration (void) +{ +} + +ACE_Section_Key_Internal* +ACE_Configuration::get_internal_key (const ACE_Configuration_Section_Key& key) +{ + return key.key_; +} + +int +ACE_Configuration::expand_path (const ACE_Configuration_Section_Key& key, + const ACE_TString& path_in, + ACE_Configuration_Section_Key& key_out, + int create) +{ + // Make a copy of key + ACE_Configuration_Section_Key current_section = key; + ACE_Auto_Basic_Array_Ptr pData (path_in.rep ()); + ACE_Tokenizer parser (pData.get ()); + parser.delimiter_replace ('\\', '\0'); + parser.delimiter_replace ('/', '\0'); + + for (ACE_TCHAR *temp = parser.next (); + temp != 0; + temp = parser.next ()) + { + // Open the section + if (open_section (current_section, + temp, + create, + key_out)) + return -1; + + current_section = key_out; + } + + return 0; + +} + +// import_config and export_config are here for backward compatibility, +// and have been deprecated. +int +ACE_Configuration::export_config (const ACE_TCHAR* filename) +{ + ACE_Registry_ImpExp exporter (*this); + return exporter.export_config (filename); +} + +int +ACE_Configuration::import_config (const ACE_TCHAR* filename) +{ + ACE_Registry_ImpExp importer (*this); + return importer.import_config (filename); +} + +int +ACE_Configuration::validate_name (const ACE_TCHAR* name, int allow_path) +{ + // Invalid character set + const ACE_TCHAR* reject = + allow_path ? ACE_TEXT ("][") : ACE_TEXT ("\\]["); + + // Position of the first invalid character or terminating null. + size_t const pos = ACE_OS::strcspn (name, reject); + + // Check if it is an invalid character. + if (name[pos] != ACE_TEXT ('\0')) + { + errno = EINVAL; + return -1; + } + + // The first character can never be a path separator. + if (name[0] == ACE_TEXT ('\\')) + { + errno = EINVAL; + return -1; + } + + // Validate length. + if (pos == 0 || pos > 255) + { + errno = ENAMETOOLONG; + return -1; + } + + return 0; +} + +int +ACE_Configuration::validate_value_name (const ACE_TCHAR* name) +{ + if (name == 0 || *name == this->NULL_String_) + return 0; + + return this->validate_name (name); +} + +const ACE_Configuration_Section_Key& +ACE_Configuration::root_section (void) const +{ + return root_; +} + +/** + * Determine if the contents of this object is the same as the + * contents of the object on the right hand side. + * Returns 1 (True) if they are equal and 0 (False) if they are not equal + */ +bool +ACE_Configuration::operator== (const ACE_Configuration& rhs) const +{ + bool rc = true; + int sectionIndex = 0; + ACE_TString sectionName; + ACE_Configuration *nonconst_this = const_cast (this); + ACE_Configuration &nonconst_rhs = const_cast (rhs); + + const ACE_Configuration_Section_Key& rhsRoot = rhs.root_section (); + ACE_Configuration_Section_Key rhsSection; + ACE_Configuration_Section_Key thisSection; + + // loop through each section in this object + while ((rc) && (nonconst_this->enumerate_sections (this->root_, + sectionIndex, + sectionName) == 0)) + { + // find that section in the rhs object + if (nonconst_rhs.open_section (rhsRoot, + sectionName.c_str (), + 0, + rhsSection) != 0) + { + // If the rhs object does not contain the section then we are + // not equal. + rc = false; + } + else if (nonconst_this->open_section (this->root_, + sectionName.c_str (), + 0, + thisSection) != 0) + { + // if there is some error opening the section in this object + rc = false; + } + else + { + // Well the sections match + int valueIndex = 0; + ACE_TString valueName; + VALUETYPE valueType; + VALUETYPE rhsType; + + // Enumerate each value in this section + while ((rc) && nonconst_this->enumerate_values (thisSection, + valueIndex, + valueName, + valueType) == 0) + { + // look for the same value in the rhs section + if (nonconst_rhs.find_value (rhsSection, + valueName.c_str (), + rhsType) != 0) + { + // We're not equal if the same value cannot + // be found in the rhs object. + rc = false; + } + else if (valueType != rhsType) + { + // we're not equal if the types do not match. + rc = false; + } + else + { + // finally compare values. + if (valueType == STRING) + { + ACE_TString thisString, rhsString; + if (nonconst_this->get_string_value (thisSection, + valueName.c_str (), + thisString) != 0) + { + // we're not equal if we cannot get this string + rc = false; + } + else if (nonconst_rhs.get_string_value ( + rhsSection, + valueName.c_str (), + rhsString) != 0) + { + // we're not equal if we cannot get rhs string + rc = false; + } + rc = (thisString == rhsString); + } + else if (valueType == INTEGER) + { + u_int thisInt = 0; + u_int rhsInt = 0; + if (nonconst_this->get_integer_value ( + thisSection, + valueName.c_str (), + thisInt) != 0) + { + // we're not equal if we cannot get this int + rc = false; + } + else if (nonconst_rhs.get_integer_value ( + rhsSection, + valueName.c_str (), + rhsInt) != 0) + { + // we're not equal if we cannot get rhs int + rc = false; + } + rc = (thisInt == rhsInt); + } + else if (valueType == BINARY) + { + void* thisData = 0; + void* rhsData = 0; + size_t thisLength = 0; + size_t rhsLength = 0; + if (nonconst_this->get_binary_value (thisSection, + valueName.c_str (), + thisData, + thisLength) != 0) + { + // we're not equal if we cannot get this data + rc = false; + } + else if (nonconst_rhs.get_binary_value ( + rhsSection, + valueName.c_str (), + rhsData, + rhsLength) != 0) + { + // we're not equal if we cannot get this data + rc = false; + } + + rc = (thisLength == rhsLength); + // are the length's the same? + + if (rc) + { + unsigned char* thisCharData = + (unsigned char*)thisData; + unsigned char* rhsCharData = (unsigned char*)rhsData; + // yes, then check each element + for (size_t count = 0; + (rc) && (count < thisLength); + count++) + { + rc = (* (thisCharData + count) == * (rhsCharData + count)); + } + + delete [] thisCharData; + delete [] rhsCharData; + }// end if the length's match + } + // We should never have valueTypes of INVALID, therefore + // we're not comparing them. How would we since we have + // no get operation for invalid types. + // So, if we have them, we guess they are equal. + + }// end else if values match. + + ++valueIndex; + + }// end value while loop + + // look in the rhs for values not in this + valueIndex = 0; + while ((rc) && (nonconst_rhs.enumerate_values (rhsSection, + valueIndex, + valueName, + rhsType) == 0)) + { + // look for the same value in this section + if (nonconst_this->find_value (thisSection, + valueName.c_str (), + valueType) != 0) + { + // We're not equal if the same value cannot + // be found in the rhs object. + rc = false; + } + ++valueIndex; + }// end while for rhs values not in this. + + }// end else if sections match. + + ++sectionIndex; + + }// end section while loop + + // Finally, make sure that there are no sections in rhs that do not + // exist in this + sectionIndex = 0; + while ((rc) + && (nonconst_rhs.enumerate_sections (rhsRoot, + sectionIndex, + sectionName) == 0)) + { + // find the section in this + if (nonconst_this->open_section (this->root_, + sectionName.c_str (), + 0, + thisSection) != 0) + { + // if there is some error opening the section in this object + rc = false; + } + else if (nonconst_rhs.open_section (rhsRoot, + sectionName.c_str (), + 0, + rhsSection) != 0) + { + // If the rhs object does not contain the section then we + // are not equal. + rc = false; + } + ++sectionIndex; + } + return rc; +} + +bool +ACE_Configuration::operator!= (const ACE_Configuration& rhs) const +{ + return !(*this == rhs); +} + +////////////////////////////////////////////////////////////////////////////// + +#if defined (ACE_WIN32) && !defined (ACE_LACKS_WIN32_REGISTRY) + +static const int ACE_DEFAULT_BUFSIZE = 256; + +static const ACE_TCHAR *temp_name (const ACE_TCHAR *name) +{ + if (name && *name == ACE_Configuration::NULL_String_) + return 0; + return name; +} + +ACE_Section_Key_Win32::ACE_Section_Key_Win32 (HKEY hKey) + : hKey_ (hKey) +{ +} + +ACE_Section_Key_Win32::~ACE_Section_Key_Win32 (void) +{ + ::RegCloseKey (hKey_); +} + +////////////////////////////////////////////////////////////////////////////// + +bool +ACE_Configuration_Win32Registry::operator== (const ACE_Configuration_Win32Registry &rhs) const +{ + ACE_UNUSED_ARG (rhs); + return true; +} + +bool +ACE_Configuration_Win32Registry::operator!= (const ACE_Configuration_Win32Registry &rhs) const +{ + ACE_UNUSED_ARG (rhs); + return true; +} + +ACE_Configuration_Win32Registry::ACE_Configuration_Win32Registry (HKEY hKey) +{ + ACE_Section_Key_Win32 *temp = 0; + + ACE_NEW (temp, ACE_Section_Key_Win32 (hKey)); + + root_ = ACE_Configuration_Section_Key (temp); +} + + +ACE_Configuration_Win32Registry::~ACE_Configuration_Win32Registry (void) +{ +} + +int +ACE_Configuration_Win32Registry::open_section (const ACE_Configuration_Section_Key& base, + const ACE_TCHAR* sub_section, + int create, + ACE_Configuration_Section_Key& result) +{ + if (validate_name (sub_section, 1)) + return -1; + + HKEY base_key; + if (load_key (base, base_key)) + return -1; + + int errnum; + HKEY result_key; + if ((errnum = ACE_TEXT_RegOpenKeyEx (base_key, + sub_section, + 0, + KEY_ALL_ACCESS, + &result_key)) != ERROR_SUCCESS) + { + if (!create) + { + errno = errnum; + return -1; + } + + if ((errnum = ACE_TEXT_RegCreateKeyEx (base_key, + sub_section, + 0, + 0, + REG_OPTION_NON_VOLATILE, + KEY_ALL_ACCESS, + 0, + &result_key, +#if defined (__MINGW32__) + (PDWORD) 0 +#else + 0 +#endif /* __MINGW32__ */ + )) != ERROR_SUCCESS) + { + errno = errnum; + return -1; + } + } + + ACE_Section_Key_Win32 *temp; + + ACE_NEW_RETURN (temp, ACE_Section_Key_Win32 (result_key), -1); + result = ACE_Configuration_Section_Key (temp); + return 0; +} + +int +ACE_Configuration_Win32Registry::remove_section (const ACE_Configuration_Section_Key& key, + const ACE_TCHAR* sub_section, + int recursive) +{ + if (validate_name (sub_section)) + return -1; + + HKEY base_key; + if (load_key (key, base_key)) + return -1; + + if (recursive) + { + ACE_Configuration_Section_Key section; + if (open_section (key, sub_section, 0, section)) + return -1; + + HKEY sub_key; + if (load_key (section, sub_key)) + return -1; + + ACE_TCHAR name_buffer[ACE_DEFAULT_BUFSIZE]; + DWORD buffer_size = ACE_DEFAULT_BUFSIZE; + // Note we don't increment the index because the + // enumeration becomes invalid if we change the + // subkey, which we do when we delete it. By leaving + // it 0, we always delete the top entry + while (ACE_TEXT_RegEnumKeyEx (sub_key, + 0, + name_buffer, + &buffer_size, + 0, + 0, + 0, + 0) == ERROR_SUCCESS) + { + remove_section (section, name_buffer, 1); + buffer_size = ACE_DEFAULT_BUFSIZE; + } + } + + int errnum; + errnum = ACE_TEXT_RegDeleteKey (base_key, sub_section); + if (errnum != ERROR_SUCCESS) + { + errno = errnum; + return -1; + } + + return 0; +} + +int +ACE_Configuration_Win32Registry::enumerate_values (const ACE_Configuration_Section_Key& key, + int index, + ACE_TString& name, + VALUETYPE& type) +{ + HKEY base_key; + if (load_key (key, base_key)) + return -1; + + ACE_TCHAR name_buffer[ACE_DEFAULT_BUFSIZE]; + DWORD buffer_size = ACE_DEFAULT_BUFSIZE; + DWORD value_type; + + int rc = ACE_TEXT_RegEnumValue (base_key, + index, + name_buffer, + &buffer_size, + 0, + &value_type, + 0, + 0); + if (rc == ERROR_NO_MORE_ITEMS) + return 1; + else if (rc != ERROR_SUCCESS) + { + errno = rc; + return -1; + } + + name = name_buffer; + + switch (value_type) + { + case REG_BINARY: + type = BINARY; + break; + case REG_SZ: + type = STRING; + break; + case REG_DWORD: + type = INTEGER; + break; + default: + type = INVALID; + } + + return 0; +} + +int +ACE_Configuration_Win32Registry::enumerate_sections (const ACE_Configuration_Section_Key& key, + int index, + ACE_TString& name) +{ + HKEY base_key; + if (load_key (key, base_key)) + return -1; + + ACE_TCHAR name_buffer[ACE_DEFAULT_BUFSIZE]; + DWORD buffer_size = ACE_DEFAULT_BUFSIZE; + int rc = ACE_TEXT_RegEnumKeyEx (base_key, + index, + name_buffer, + &buffer_size, + 0, + 0, + 0, + 0); + if (rc == ERROR_NO_MORE_ITEMS) + return 1; + else if (rc != ERROR_MORE_DATA && rc != ERROR_SUCCESS) + { + errno = rc; + return -1; + } + + name = name_buffer; + + return 0; +} + +int +ACE_Configuration_Win32Registry::set_string_value (const ACE_Configuration_Section_Key& key, + const ACE_TCHAR* name, + const ACE_TString& value) +{ + const ACE_TCHAR *t_name = temp_name (name); + if (validate_value_name (t_name)) + return -1; + + HKEY base_key; + if (load_key (key, base_key)) + return -1; + + int errnum; + DWORD len = static_cast (value.length () + 1); + len *= sizeof (ACE_TCHAR); + if ((errnum = ACE_TEXT_RegSetValueEx (base_key, + t_name, + 0, + REG_SZ, + (BYTE *) value.fast_rep (), + len)) + != ERROR_SUCCESS) + { + errno = errnum; + return -1; + } + + return 0; +} + +int +ACE_Configuration_Win32Registry::set_integer_value (const ACE_Configuration_Section_Key& key, + const ACE_TCHAR* name, + u_int value) +{ + const ACE_TCHAR *t_name = temp_name (name); + if (validate_value_name (t_name)) + return -1; + + HKEY base_key; + if (load_key (key, base_key)) + return -1; + + int errnum; + if ((errnum = ACE_TEXT_RegSetValueEx (base_key, + t_name, + 0, + REG_DWORD, + (BYTE *) &value, + sizeof (value))) != ERROR_SUCCESS) + { + errno = errnum; + return -1; + } + + return 0; +} + +int +ACE_Configuration_Win32Registry::set_binary_value (const ACE_Configuration_Section_Key& key, + const ACE_TCHAR* name, + const void* data, + size_t length) +{ + const ACE_TCHAR *t_name = temp_name (name); + if (validate_value_name (t_name)) + return -1; + + HKEY base_key; + if (load_key (key, base_key)) + return -1; + + int errnum; + if ((errnum = ACE_TEXT_RegSetValueEx (base_key, + t_name, + 0, + REG_BINARY, + (BYTE *) data, + static_cast (length))) + != ERROR_SUCCESS) + { + errno = errnum; + return -1; + } + + return 0; +} + +int +ACE_Configuration_Win32Registry::get_string_value (const ACE_Configuration_Section_Key& key, + const ACE_TCHAR* name, + ACE_TString& value) +{ + const ACE_TCHAR *t_name = temp_name (name); + if (validate_value_name (t_name)) + return -1; + + HKEY base_key; + if (load_key (key, base_key)) + return -1; + + // Get the size of the binary data from windows + int errnum; + DWORD buffer_length = 0; + DWORD type; + if ((errnum = ACE_TEXT_RegQueryValueEx (base_key, + t_name, + 0, + &type, + (BYTE *) 0, + &buffer_length)) != ERROR_SUCCESS) + { + errno = errnum; + return -1; + } + + if (type != REG_SZ) + { + errno = ERROR_INVALID_DATATYPE; + return -1; + } + + ACE_TCHAR *temp = 0; + ACE_NEW_RETURN (temp, + ACE_TCHAR[buffer_length], + -1); + + ACE_Auto_Basic_Array_Ptr buffer (temp); + + if ((errnum = ACE_TEXT_RegQueryValueEx (base_key, + t_name, + 0, + &type, + (BYTE *) buffer.get (), + &buffer_length)) != ERROR_SUCCESS) + { + errno = errnum; + return -1; + } + + value = buffer.get (); + return 0; +} + +int +ACE_Configuration_Win32Registry::get_integer_value (const ACE_Configuration_Section_Key& key, + const ACE_TCHAR* name, + u_int& value) +{ + const ACE_TCHAR *t_name = temp_name (name); + if (validate_value_name (t_name)) + return -1; + + HKEY base_key; + if (load_key (key, base_key)) + return -1; + + int errnum; + DWORD length = sizeof (value); + DWORD type; + if ((errnum = ACE_TEXT_RegQueryValueEx (base_key, + t_name, + 0, + &type, + (BYTE *) &value, + &length)) != ERROR_SUCCESS) + { + errno = errnum; + return -1; + } + + if (type != REG_DWORD) + { + errno = ERROR_INVALID_DATATYPE; + return -1; + } + + return 0; +} + +int +ACE_Configuration_Win32Registry::get_binary_value ( + const ACE_Configuration_Section_Key &key, + const ACE_TCHAR *name, + void *&data, + size_t &length) +{ + const ACE_TCHAR *t_name = temp_name (name); + if (validate_value_name (t_name)) + return -1; + + HKEY base_key; + if (load_key (key, base_key)) + return -1; + + // Get the size of the binary data from windows + int errnum; + DWORD buffer_length = 0; + DWORD type; + if ((errnum = ACE_TEXT_RegQueryValueEx (base_key, + t_name, + 0, + &type, + (BYTE *) 0, + &buffer_length)) != ERROR_SUCCESS) + { + errno = errnum; + return -1; + } + + if (type != REG_BINARY) + { + errno = ERROR_INVALID_DATATYPE; + return -1; + } + + length = buffer_length; + + BYTE * the_data = 0; + ACE_NEW_RETURN (the_data, BYTE[length], -1); + ACE_Auto_Basic_Array_Ptr safe_data (the_data); + + if ((errnum = ACE_TEXT_RegQueryValueEx (base_key, + t_name, + 0, + &type, + the_data, + &buffer_length)) != ERROR_SUCCESS) + { + data = 0; + errno = errnum; + return -1; + } + + data = safe_data.release (); + + return 0; +} + +int +ACE_Configuration_Win32Registry::find_value (const ACE_Configuration_Section_Key& key, + const ACE_TCHAR* name, + VALUETYPE& type_out) +{ + const ACE_TCHAR *t_name = temp_name (name); + if (validate_value_name (t_name)) + return -1; + + HKEY base_key; + if (load_key (key, base_key)) + return -1; + + DWORD buffer_length=0; + DWORD type; + int result=ACE_TEXT_RegQueryValueEx (base_key, + t_name, + 0, + &type, + 0, + &buffer_length); + if (result != ERROR_SUCCESS) + { + errno = result; + return -1; + } + + switch (type) + { + case REG_SZ: + type_out = STRING; + break; + case REG_DWORD: + type_out = INTEGER; + break; + case REG_BINARY: + type_out = BINARY; + break; + default: + return -1; // unknown type + } + + return 0; +} + +int +ACE_Configuration_Win32Registry::remove_value (const ACE_Configuration_Section_Key& key, + const ACE_TCHAR* name) +{ + const ACE_TCHAR *t_name = temp_name (name); + if (validate_value_name (t_name)) + return -1; + + HKEY base_key; + if (load_key (key, base_key)) + return -1; + + int errnum; + if ((errnum = ACE_TEXT_RegDeleteValue (base_key, t_name)) != ERROR_SUCCESS) + { + errno = errnum; + return -1; + } + + return 0; +} + + +int +ACE_Configuration_Win32Registry::load_key (const ACE_Configuration_Section_Key& key, + HKEY& hKey) +{ + ACE_Section_Key_Win32* pKey = dynamic_cast (get_internal_key (key)); + if (!pKey) + return -1; + + hKey = pKey->hKey_; + return 0; +} + +HKEY +ACE_Configuration_Win32Registry::resolve_key (HKEY hKey, + const ACE_TCHAR* path, + int create) +{ + HKEY result = 0; + // Make a copy of hKey + int errnum; +#if defined (ACE_HAS_WINCE) + if ((errnum = RegOpenKeyEx (hKey, 0, 0, 0, &result)) != ERROR_SUCCESS) +#else + if ((errnum = RegOpenKey (hKey, 0, &result)) != ERROR_SUCCESS) +#endif // ACE_HAS_WINCE + { + errno = errnum; + return 0; + } + + // recurse through the path + ACE_TCHAR *temp_path = 0; + ACE_NEW_RETURN (temp_path, + ACE_TCHAR[ACE_OS::strlen (path) + 1], + 0); + ACE_Auto_Basic_Array_Ptr pData (temp_path); + ACE_OS::strcpy (pData.get (), path); + ACE_Tokenizer parser (pData.get ()); + parser.delimiter_replace ('\\', '\0'); + parser.delimiter_replace ('/', '\0'); + + for (ACE_TCHAR *temp = parser.next (); + temp != 0; + temp = parser.next ()) + { + // Open the key + HKEY subkey; + +#if defined (ACE_HAS_WINCE) + if ((errnum = ACE_TEXT_RegOpenKeyEx (result, + temp, + 0, + 0, + &subkey)) != ERROR_SUCCESS) +#else + if ((errnum = ACE_TEXT_RegOpenKey (result, + temp, + &subkey)) != ERROR_SUCCESS) +#endif // ACE_HAS_WINCE + { + // try creating it + if (!create || (errnum = ACE_TEXT_RegCreateKeyEx (result, + temp, + 0, + 0, + 0, + KEY_ALL_ACCESS, + 0, + &subkey, +#if defined (__MINGW32__) + (PDWORD) 0 +#else + 0 +#endif /* __MINGW32__ */ + )) !=ERROR_SUCCESS) + { + errno = errnum; + // error + ::RegCloseKey (result); + return 0; + } + } + // release our open key handle + ::RegCloseKey (result); + result = subkey; + } + + return result; +} + +#endif /* ACE_WIN32 && !ACE_LACKS_WIN32_REGISTRY */ + +/////////////////////////////////////////////////////////////// + +ACE_Configuration_Value_IntId::ACE_Configuration_Value_IntId (void) + : type_ (ACE_Configuration::INVALID), + length_ (0) +{ + this->data_.ptr_ = 0; +} + +ACE_Configuration_Value_IntId::ACE_Configuration_Value_IntId (ACE_TCHAR* string) + : type_ (ACE_Configuration::STRING), + length_ (0) +{ + this->data_.ptr_ = string; +} + +ACE_Configuration_Value_IntId::ACE_Configuration_Value_IntId (u_int integer) + : type_ (ACE_Configuration::INTEGER), + length_ (0) +{ + this->data_.int_ = integer; +} + +ACE_Configuration_Value_IntId::ACE_Configuration_Value_IntId (void* data, size_t length) + : type_ (ACE_Configuration::BINARY), + length_ (length) +{ + this->data_.ptr_ = data; +} + +ACE_Configuration_Value_IntId::ACE_Configuration_Value_IntId (const ACE_Configuration_Value_IntId& rhs) + : type_ (rhs.type_), + data_ (rhs.data_), + length_ (rhs.length_) +{ +} + +ACE_Configuration_Value_IntId::~ACE_Configuration_Value_IntId (void) +{ +} + +ACE_Configuration_Value_IntId& ACE_Configuration_Value_IntId::operator= (const ACE_Configuration_Value_IntId& rhs) +{ + if (this != &rhs) + { + type_ = rhs.type_; + data_ = rhs.data_; + length_ = rhs.length_; + } + return *this; +} + +void +ACE_Configuration_Value_IntId::free (ACE_Allocator *alloc) +{ + if (this->type_ == ACE_Configuration::STRING + || this->type_ == ACE_Configuration::BINARY) + alloc->free (data_.ptr_); + // Do nothing in other cases... +} + +ACE_Configuration_ExtId::ACE_Configuration_ExtId (void) + : name_ (0) +{ +} + +ACE_Configuration_ExtId::ACE_Configuration_ExtId (const ACE_TCHAR* name) + : name_ (name) +{ +} + +ACE_Configuration_ExtId::ACE_Configuration_ExtId (const ACE_Configuration_ExtId& rhs) + : name_ (rhs.name_) +{ +} + +ACE_Configuration_ExtId::~ACE_Configuration_ExtId (void) +{ +} + +ACE_Configuration_ExtId& ACE_Configuration_ExtId::operator= (const ACE_Configuration_ExtId& rhs) +{ + if (this != &rhs) + name_ = rhs.name_; + + return *this; +} + +bool +ACE_Configuration_ExtId::operator== (const ACE_Configuration_ExtId& rhs) const +{ + return (ACE_OS::strcasecmp (name_, rhs.name_) == 0); +} + +bool +ACE_Configuration_ExtId::operator!= (const ACE_Configuration_ExtId& rhs) const +{ + return !this->operator== (rhs); +} + +u_long +ACE_Configuration_ExtId::hash (void) const +{ + ACE_TString temp (name_, 0, false); + return temp.hash (); +} + +void +ACE_Configuration_ExtId::free (ACE_Allocator *alloc) +{ + alloc->free ((void *) (name_)); +} + +/////////////////////////////////////////////////////////////////////// + +ACE_Configuration_Section_IntId::ACE_Configuration_Section_IntId (void) + : value_hash_map_ (0), + section_hash_map_ (0) +{ +} + +ACE_Configuration_Section_IntId::ACE_Configuration_Section_IntId (VALUE_MAP* value_hash_map, SUBSECTION_MAP* section_hash_map) + : value_hash_map_ (value_hash_map), + section_hash_map_ (section_hash_map) +{ +} + +ACE_Configuration_Section_IntId::ACE_Configuration_Section_IntId (const ACE_Configuration_Section_IntId& rhs) + : value_hash_map_ (rhs.value_hash_map_), + section_hash_map_ (rhs.section_hash_map_) +{ + +} + +ACE_Configuration_Section_IntId::~ACE_Configuration_Section_IntId () +{ +} + +ACE_Configuration_Section_IntId& +ACE_Configuration_Section_IntId::operator= (const ACE_Configuration_Section_IntId& rhs) +{ + if (this != &rhs) + { + value_hash_map_ = rhs.value_hash_map_; + section_hash_map_ = rhs.section_hash_map_; + } + return *this; +} + +void +ACE_Configuration_Section_IntId::free (ACE_Allocator *alloc) +{ + alloc->free ((void *) (value_hash_map_)); + alloc->free ((void *) (section_hash_map_)); +} + +ACE_Configuration_Section_Key_Heap::ACE_Configuration_Section_Key_Heap (const ACE_TCHAR* path) + : path_ (0), + value_iter_ (0), + section_iter_ (0) +{ + path_ = ACE_OS::strdup (path); +} + +ACE_Configuration_Section_Key_Heap::~ACE_Configuration_Section_Key_Heap () +{ + delete value_iter_; + delete section_iter_; + ACE_OS::free (path_); +} + +////////////////////////////////////////////////////////////////////////////// + +ACE_Configuration_Heap::ACE_Configuration_Heap (void) + : allocator_ (0), + index_ (0), + default_map_size_ (0) +{ + ACE_Configuration_Section_Key_Heap *temp = 0; + + ACE_NEW (temp, ACE_Configuration_Section_Key_Heap (ACE_TEXT (""))); + root_ = ACE_Configuration_Section_Key (temp); +} + +ACE_Configuration_Heap::~ACE_Configuration_Heap (void) +{ + if (allocator_) + allocator_->sync (); + + delete allocator_; +} + +int +ACE_Configuration_Heap::open (size_t default_map_size) +{ + default_map_size_ = default_map_size; + // Create the allocator with the appropriate options. + // The name used for the lock is the same as one used + // for the file. + ACE_NEW_RETURN (this->allocator_, + HEAP_ALLOCATOR (), + -1); + return create_index (); +} + + +int +ACE_Configuration_Heap::open (const ACE_TCHAR* file_name, + void* base_address, + size_t default_map_size) +{ + default_map_size_ = default_map_size; + + // Make sure that the file name is of the legal length. + if (ACE_OS::strlen (file_name) >= MAXNAMELEN + MAXPATHLEN) + { + errno = ENAMETOOLONG; + return -1; + } + + ACE_MMAP_Memory_Pool::OPTIONS options (base_address); + + // Create the allocator with the appropriate options. The name used + // for the lock is the same as one used for the file. + ACE_NEW_RETURN (this->allocator_, + PERSISTENT_ALLOCATOR (file_name, + file_name, + &options), + -1); + +#if !defined (ACE_LACKS_ACCESS) + // Now check if the backing store has been created successfully. + if (ACE_OS::access (file_name, F_OK) != 0) + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("create_index\n")), + -1); +#endif /* ACE_LACKS_ACCESS */ + + return create_index (); +} + +int +ACE_Configuration_Heap::create_index (void) +{ + void *section_index = 0; + + // This is the easy case since if we find hash table in the + // memory-mapped file we know it's already initialized. + if (this->allocator_->find (ACE_CONFIG_SECTION_INDEX, section_index) == 0) + this->index_ = (SECTION_MAP *) section_index; + + // Create a new (because we've just created a new + // memory-mapped file). + else + { + size_t index_size = sizeof (SECTION_MAP); + section_index = this->allocator_->malloc (index_size); + + if (section_index == 0 + || create_index_helper (section_index) == -1 + || this->allocator_->bind (ACE_CONFIG_SECTION_INDEX, + section_index) == -1) + { + // Attempt to clean up. + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("create_index failed\n"))); + this->allocator_->remove (); + return -1; + } + // Add the root section + return new_section (ACE_TEXT (""), root_); + } + return 0; +} + +int +ACE_Configuration_Heap::create_index_helper (void *buffer) +{ + ACE_ASSERT (this->allocator_); + this->index_ = new (buffer) SECTION_MAP (this->allocator_); + return 0; +} + +int +ACE_Configuration_Heap::load_key (const ACE_Configuration_Section_Key& key, + ACE_TString& name) +{ + ACE_ASSERT (this->allocator_); + ACE_Configuration_Section_Key_Heap* pKey = + dynamic_cast (get_internal_key (key)); + + if (!pKey) + { + return -1; + } + + ACE_TString temp (pKey->path_, 0, false); + name.assign_nocopy (temp); + return 0; +} + + +int +ACE_Configuration_Heap::add_section (const ACE_Configuration_Section_Key& base, + const ACE_TCHAR* sub_section, + ACE_Configuration_Section_Key& result) +{ + ACE_ASSERT (this->allocator_); + ACE_TString section; + if (load_key (base, section)) + return -1; + + // Find the base section + ACE_Configuration_ExtId ExtId (section.fast_rep ()); + ACE_Configuration_Section_IntId IntId; + if (index_->find (ExtId, IntId, allocator_)) + return -1; + + // See if this section already exists + ACE_Configuration_ExtId SubSectionExtId (sub_section); + int ignored = 0; + + if (!IntId.section_hash_map_->find (SubSectionExtId, ignored, allocator_)) + { + // already exists! + errno = EEXIST; + return -1; + } + + // Create the new section name + // only prepend a separater if were not at the root + if (section.length ()) + section += ACE_TEXT ("\\"); + + section += sub_section; + + // Add it to the base section + ACE_TCHAR* pers_name = (ACE_TCHAR *) allocator_->malloc ((ACE_OS::strlen (sub_section) + 1) * sizeof (ACE_TCHAR)); + ACE_OS::strcpy (pers_name, sub_section); + ACE_Configuration_ExtId SSExtId (pers_name); + if (IntId.section_hash_map_->bind (SSExtId, ignored, allocator_)) + { + allocator_->free (pers_name); + return -1; + } + return (new_section (section, result)); +} + +int +ACE_Configuration_Heap::new_section (const ACE_TString& section, + ACE_Configuration_Section_Key& result) +{ + ACE_ASSERT (this->allocator_); + // Create a new section and add it to the global list + + // Allocate memory for items to be stored in the table. + size_t section_len = section.length () + 1; + ACE_TCHAR *ptr = (ACE_TCHAR*) this->allocator_->malloc (section_len * sizeof (ACE_TCHAR)); + + int return_value = -1; + + if (ptr == 0) + return -1; + else + { + // Populate memory with data. + ACE_OS::strcpy (ptr, section.fast_rep ()); + + void *value_hash_map = 0; + size_t map_size = sizeof (VALUE_MAP); + value_hash_map = this->allocator_->malloc (map_size); + + // If allocation failed ... + if (value_hash_map == 0) + return -1; + + // Initialize allocated hash map through placement new. + if (value_open_helper (default_map_size_, value_hash_map ) == -1) + { + this->allocator_->free (value_hash_map ); + return -1; + } + + // create the section map + void* section_hash_map = 0; + map_size = sizeof (SUBSECTION_MAP); + section_hash_map = this->allocator_->malloc (map_size); + + // If allocation failed + if (section_hash_map == 0) + return -1; + + // initialize allocated hash map through placement new + if (section_open_helper (default_map_size_, section_hash_map) == -1) + { + this->allocator_->free (value_hash_map ); + this->allocator_->free (section_hash_map); + return -1; + } + + ACE_Configuration_ExtId name (ptr); + ACE_Configuration_Section_IntId entry ((VALUE_MAP*) value_hash_map, + (SUBSECTION_MAP*) section_hash_map); + + // Do a normal bind. This will fail if there's already an + // entry with the same name. + return_value = this->index_->bind (name, entry, this->allocator_); + + if (return_value == 1 /* Entry already existed so bind failed. */ + || return_value == -1 /* Unable to bind for other reasons. */) + { + // Free our dynamically allocated memory. + this->allocator_->free (static_cast (ptr)); + return return_value; + } + + // If bind () succeed, it will automatically sync + // up the map manager entry. However, we must sync up our + // name/value memory. + this->allocator_->sync (ptr, section_len); + } + + // set the result + ACE_Configuration_Section_Key_Heap *temp; + ACE_NEW_RETURN (temp, + ACE_Configuration_Section_Key_Heap (ptr), + -1); + result = ACE_Configuration_Section_Key (temp); + return return_value; +} + +int +ACE_Configuration_Heap::value_open_helper (size_t hash_table_size, + void *buffer) +{ + ACE_ASSERT (this->allocator_); + new (buffer) VALUE_MAP (hash_table_size, this->allocator_); + return 0; +} + +int +ACE_Configuration_Heap::section_open_helper (size_t hash_table_size, + void *buffer) +{ + ACE_ASSERT (this->allocator_); + new (buffer) SUBSECTION_MAP (hash_table_size, this->allocator_); + return 0; +} + +int +ACE_Configuration_Heap::open_section (const ACE_Configuration_Section_Key& base, + const ACE_TCHAR* sub_section, + int create, + ACE_Configuration_Section_Key& result) +{ + ACE_ASSERT (this->allocator_); + if (validate_name (sub_section, 1)) // 1 == allow_path + return -1; + + result = base; + + for (const ACE_TCHAR* separator; + (separator = ACE_OS::strchr (sub_section, ACE_TEXT ('\\'))) != 0; + ) + { + ACE_TString simple_section (sub_section, separator - sub_section); + int ret_val = + open_simple_section (result, simple_section.c_str (), create, result); + if (ret_val) + return ret_val; + sub_section = separator + 1; + } + + return open_simple_section (result, sub_section, create, result); +} + +int +ACE_Configuration_Heap::open_simple_section (const ACE_Configuration_Section_Key& base, + const ACE_TCHAR* sub_section, + int create, + ACE_Configuration_Section_Key& result) +{ + ACE_TString section (0, 0, false); + + if (load_key (base, section)) + { + return -1; + } + + // Only add the \\ if were not at the root + if (section.length ()) + { + section += ACE_TEXT ("\\"); + } + + section += sub_section; + + // resolve the section + ACE_Configuration_ExtId ExtId (section.fast_rep ()); + ACE_Configuration_Section_IntId IntId; + + if (index_->find (ExtId, IntId, allocator_)) + { + if (!create) + { + errno = ENOENT; + return -1; + } + + return add_section (base, sub_section, result); + } + + ACE_Configuration_Section_Key_Heap *temp; + ACE_NEW_RETURN (temp, + ACE_Configuration_Section_Key_Heap (section.fast_rep ()), + -1); + result = ACE_Configuration_Section_Key (temp); + return 0; +} + +int +ACE_Configuration_Heap::remove_section (const ACE_Configuration_Section_Key& key, + const ACE_TCHAR* sub_section, + int recursive) +{ + ACE_ASSERT (this->allocator_); + if (validate_name (sub_section)) + return -1; + + ACE_TString section; + if (load_key (key, section)) + return -1; + + // Find this key + ACE_Configuration_ExtId ParentExtId (section.fast_rep ()); + ACE_Configuration_Section_IntId ParentIntId; + if (index_->find (ParentExtId, ParentIntId, allocator_)) + return -1;// no parent key + + // Find this subkey + if (section.length ()) + section += ACE_TEXT ("\\"); + + section += sub_section; + ACE_Configuration_ExtId SectionExtId (section.fast_rep ()); + SECTION_HASH::ENTRY* section_entry; + SECTION_HASH* hashmap = index_; + if (hashmap->find (SectionExtId, section_entry)) + return -1; + + if (recursive) + { + ACE_Configuration_Section_Key section; + if (open_section (key, sub_section, 0, section)) + return -1; + + int index = 0; + ACE_TString name; + while (!enumerate_sections (section, index, name)) + { + if (remove_section (section, name.fast_rep (), 1)) + return -1; + + ++index; + } + } + + // Now make sure we dont have any subkeys + if (section_entry->int_id_.section_hash_map_->current_size ()) + { + errno = ENOTEMPTY; + return -1; + } + + // Now remove subkey from parent key + ACE_Configuration_ExtId SubSExtId (sub_section); + SUBSECTION_HASH::ENTRY* subsection_entry; + if (((SUBSECTION_HASH*)ParentIntId.section_hash_map_)-> + find (SubSExtId, subsection_entry)) + return -1; + + if (ParentIntId.section_hash_map_->unbind (SubSExtId, allocator_)) + return -1; + + subsection_entry->ext_id_.free (allocator_); + + // Remember the pointers so we can free them after we unbind + ACE_Configuration_ExtId ExtIdToFree (section_entry->ext_id_); + ACE_Configuration_Section_IntId IntIdToFree (section_entry->int_id_); + + // iterate over all values and free memory + VALUE_HASH* value_hash_map = section_entry->int_id_.value_hash_map_; + VALUE_HASH::ITERATOR value_iter = value_hash_map->begin (); + while (!value_iter.done ()) + { + VALUE_HASH::ENTRY* value_entry = 0; + if (!value_iter.next (value_entry)) + return 1; + + value_entry->ext_id_.free (allocator_); + value_entry->int_id_.free (allocator_); + + value_iter.advance (); + } + + // remove it + if (index_->unbind (SectionExtId, allocator_)) + return -1; + + value_hash_map->close (); + section_entry->int_id_.section_hash_map_->close (allocator_); + + // Free the memory + ExtIdToFree.free (allocator_); + IntIdToFree.free (allocator_); + + return 0; +} + +int +ACE_Configuration_Heap::enumerate_values (const ACE_Configuration_Section_Key& key, + int index, + ACE_TString& name, + VALUETYPE& type) +{ + ACE_ASSERT (this->allocator_); + ACE_Configuration_Section_Key_Heap* pKey = + dynamic_cast (get_internal_key (key)); + if (!pKey) + return -1; + + name = pKey->path_; + + // resolve the section + ACE_Configuration_ExtId ExtId (pKey->path_); + ACE_Configuration_Section_IntId IntId; + if (index_->find (ExtId, IntId, allocator_)) + return -1; + + // Handle iterator resets + if (index == 0) + { + ACE_Hash_Map_Manager_Ex, + ACE_Equal_To, + ACE_Null_Mutex>* hash_map = IntId.value_hash_map_; + delete pKey->value_iter_; + + ACE_NEW_RETURN (pKey->value_iter_, + VALUE_HASH::ITERATOR (hash_map->begin ()), + -1); + } + + // Get the next entry + ACE_Hash_Map_Entry* entry = 0; + + if (!pKey->value_iter_->next (entry)) + return 1; + + // Return the value of the iterator and advance it + name = entry->ext_id_.name_; + type = entry->int_id_.type_; + pKey->value_iter_->advance (); + + return 0; +} + +int +ACE_Configuration_Heap::enumerate_sections (const ACE_Configuration_Section_Key& key, + int index, + ACE_TString& name) +{ + ACE_ASSERT (this->allocator_); + // cast to a heap section key + ACE_Configuration_Section_Key_Heap* pKey = + dynamic_cast (get_internal_key (key)); + if (!pKey) + return -1; // not a heap key! + + // resolve the section + ACE_Configuration_ExtId ExtId (pKey->path_); + ACE_Configuration_Section_IntId IntId; + if (index_->find (ExtId, IntId, allocator_)) + return -1; // unknown section + + // Handle iterator resets + if (index == 0) + { + if (pKey->section_iter_) + delete pKey->section_iter_; + + ACE_NEW_RETURN (pKey->section_iter_, + SUBSECTION_HASH::ITERATOR (IntId.section_hash_map_->begin ()), + -1); + } + + // Get the next entry + ACE_Hash_Map_Entry* entry = 0; + if (!pKey->section_iter_->next (entry)) + return 1; + + // Return the value of the iterator and advance it + pKey->section_iter_->advance (); + name = entry->ext_id_.name_; + + return 0; +} + +int +ACE_Configuration_Heap::set_string_value (const ACE_Configuration_Section_Key& key, + const ACE_TCHAR* name, + const ACE_TString& value) +{ + ACE_ASSERT (this->allocator_); + const ACE_TCHAR *t_name = name ? name : &this->NULL_String_; + if (validate_value_name (t_name)) + return -1; + + ACE_TString section; + if (load_key (key, section)) + return -1; + + ACE_Configuration_ExtId section_ext (section.fast_rep ()); + ACE_Configuration_Section_IntId section_int; + if (index_->find (section_ext, section_int, allocator_)) + return -1; + + // Get the entry for this item (if it exists) + VALUE_HASH::ENTRY* entry; + ACE_Configuration_ExtId item_name (t_name); + if (section_int.value_hash_map_->VALUE_HASH::find (item_name, entry) == 0) + { + // found item, replace it + // Free the old value + entry->int_id_.free (allocator_); + // Allocate the new value in this heap + ACE_TCHAR* pers_value = + (ACE_TCHAR *) allocator_->malloc ((value.length () + 1) * sizeof (ACE_TCHAR)); + ACE_OS::strcpy (pers_value, value.fast_rep ()); + ACE_Configuration_Value_IntId new_value_int (pers_value); + entry->int_id_ = new_value_int; + } + else + { + // it doesn't exist, bind it + ACE_TCHAR* pers_name = + (ACE_TCHAR *) allocator_->malloc ((ACE_OS::strlen (t_name) + 1) * sizeof (ACE_TCHAR)); + ACE_OS::strcpy (pers_name, t_name); + ACE_TCHAR* pers_value = + (ACE_TCHAR *) allocator_->malloc ((value.length () + 1) * sizeof (ACE_TCHAR)); + ACE_OS::strcpy (pers_value, value.fast_rep ()); + ACE_Configuration_ExtId item_name (pers_name); + ACE_Configuration_Value_IntId item_value (pers_value); + if (section_int.value_hash_map_->bind (item_name, item_value, allocator_)) + { + allocator_->free (pers_value); + allocator_->free (pers_name); + return -1; + } + return 0; + } + + return 0; +} + +int +ACE_Configuration_Heap::set_integer_value (const ACE_Configuration_Section_Key& key, + const ACE_TCHAR* name, + u_int value) +{ + ACE_ASSERT (this->allocator_); + const ACE_TCHAR *t_name = name ? name : &this->NULL_String_; + if (validate_value_name (t_name)) + return -1; + + // Get the section name from the key + ACE_TString section; + if (load_key (key, section)) + return -1; + + // Find this section + ACE_Configuration_ExtId section_ext (section.fast_rep ()); + ACE_Configuration_Section_IntId section_int; + if (index_->find (section_ext, section_int, allocator_)) + return -1; // section does not exist + + // Get the entry for this item (if it exists) + VALUE_HASH::ENTRY* entry; + ACE_Configuration_ExtId item_name (t_name); + if (section_int.value_hash_map_->VALUE_HASH::find (item_name, entry) == 0) + { + // found item, replace it + ACE_Configuration_Value_IntId new_value_int (value); + entry->int_id_ = new_value_int; + } + else + { + // it doesn't exist, bind it + ACE_TCHAR* pers_name = + (ACE_TCHAR *) allocator_->malloc ((ACE_OS::strlen (t_name) + 1) * sizeof (ACE_TCHAR)); + ACE_OS::strcpy (pers_name, t_name); + ACE_Configuration_ExtId item_name (pers_name); + ACE_Configuration_Value_IntId item_value (value); + if (section_int.value_hash_map_->bind (item_name, item_value, allocator_)) + { + allocator_->free (pers_name); + return -1; + } + return 0; + } + + return 0; +} + +int +ACE_Configuration_Heap::set_binary_value (const ACE_Configuration_Section_Key& key, + const ACE_TCHAR* name, + const void* data, + size_t length) +{ + ACE_ASSERT (this->allocator_); + const ACE_TCHAR *t_name = name ? name : &this->NULL_String_; + if (validate_value_name (t_name)) + return -1; + + // Get the section name from the key + ACE_TString section; + if (load_key (key, section)) + return -1; + + // Find this section + ACE_Configuration_ExtId section_ext (section.fast_rep ()); + ACE_Configuration_Section_IntId section_int; + if (index_->find (section_ext, section_int, allocator_)) + return -1; // section does not exist + + // Get the entry for this item (if it exists) + VALUE_HASH::ENTRY* entry; + ACE_Configuration_ExtId item_name (t_name); + if (section_int.value_hash_map_->VALUE_HASH::find (item_name, entry) == 0) + { + // found item, replace it + // Free the old value + entry->int_id_.free (allocator_); + // Allocate the new value in this heap + ACE_TCHAR* pers_value = (ACE_TCHAR *) allocator_->malloc (length); + ACE_OS::memcpy (pers_value, data, length); + ACE_Configuration_Value_IntId new_value_int (pers_value, length); + entry->int_id_ = new_value_int; + } + else + { + // it doesn't exist, bind it + ACE_TCHAR* pers_name = + (ACE_TCHAR *) allocator_->malloc ((ACE_OS::strlen (t_name) + 1) * sizeof (ACE_TCHAR)); + ACE_OS::strcpy (pers_name, t_name); + ACE_TCHAR* pers_value = (ACE_TCHAR *) allocator_->malloc (length); + ACE_OS::memcpy (pers_value, data, length); + ACE_Configuration_ExtId item_name (pers_name); + ACE_Configuration_Value_IntId item_value (pers_value, length); + if (section_int.value_hash_map_->bind (item_name, item_value, allocator_)) + { + allocator_->free (pers_value); + allocator_->free (pers_name); + return -1; + } + return 0; + } + + return 0; +} + +int +ACE_Configuration_Heap::get_string_value (const ACE_Configuration_Section_Key& key, + const ACE_TCHAR* name, + ACE_TString& value) +{ + ACE_ASSERT (this->allocator_); + const ACE_TCHAR *t_name = name ? name : &this->NULL_String_; + if (validate_value_name (t_name)) + return -1; + + // Get the section name from the key + ACE_TString section; + if (load_key (key, section)) + return -1; + + // Find this section + ACE_Configuration_ExtId ExtId (section.fast_rep ()); + ACE_Configuration_Section_IntId IntId; + if (index_->find (ExtId, IntId, allocator_)) + return -1; // section does not exist + + // See if it exists first + ACE_Configuration_ExtId VExtId (t_name); + ACE_Configuration_Value_IntId VIntId; + if (IntId.value_hash_map_->find (VExtId, VIntId, allocator_)) + return -1; // unknown value + + // Check type + if (VIntId.type_ != ACE_Configuration::STRING) + { + errno = ENOENT; + return -1; + } + + // everythings ok, return the data + value = static_cast (VIntId.data_.ptr_); + return 0; +} + +int +ACE_Configuration_Heap::get_integer_value (const ACE_Configuration_Section_Key& key, + const ACE_TCHAR* name, + u_int& value) +{ + ACE_ASSERT (this->allocator_); + + const ACE_TCHAR *t_name = name ? name : &this->NULL_String_; + if (validate_value_name (t_name)) + return -1; + + // Get the section name from the key + ACE_TString section (0, 0, false); + + if (this->load_key (key, section) != 0) + { + return -1; + } + + // Find this section + ACE_Configuration_ExtId ExtId (section.fast_rep ()); + ACE_Configuration_Section_IntId IntId; + + if (index_->find (ExtId, IntId, allocator_) != 0) + { + return -1; // section does not exist + } + + + // See if it exists first + ACE_Configuration_ExtId VExtId (t_name); + ACE_Configuration_Value_IntId VIntId; + + if (IntId.value_hash_map_->find (VExtId, VIntId, allocator_) != 0) + { + return -1; // unknown value + } + + // Check type + if (VIntId.type_ != ACE_Configuration::INTEGER) + { + errno = ENOENT; + return -1; + } + + // Everythings ok, return the data + value = VIntId.data_.int_; + return 0; +} + +int +ACE_Configuration_Heap::get_binary_value ( + const ACE_Configuration_Section_Key& key, + const ACE_TCHAR* name, + void*& data, + size_t& length) +{ + ACE_ASSERT (this->allocator_); + const ACE_TCHAR *t_name = name ? name : &this->NULL_String_; + if (validate_value_name (t_name)) + return -1; + + // Get the section name from the key + ACE_TString section; + if (load_key (key, section)) + return -1; + + // Find this section + ACE_Configuration_ExtId ExtId (section.fast_rep ()); + ACE_Configuration_Section_IntId IntId; + if (index_->find (ExtId, IntId, allocator_)) + return -1; // section does not exist + + ACE_Configuration_ExtId VExtId (t_name); + ACE_Configuration_Value_IntId VIntId; + // See if it exists first + if (IntId.value_hash_map_->find (VExtId, VIntId, allocator_)) + return -1; // unknown value + + // Check type + if (VIntId.type_ != ACE_Configuration::BINARY) + { + errno = ENOENT; + return -1; + } + + // Make a copy + ACE_NEW_RETURN (data, char[VIntId.length_], -1); + ACE_OS::memcpy (data, VIntId.data_.ptr_, VIntId.length_); + length = VIntId.length_; + return 0; +} + +int +ACE_Configuration_Heap::find_value (const ACE_Configuration_Section_Key& key, + const ACE_TCHAR* name, + VALUETYPE& type_out) +{ + ACE_ASSERT (this->allocator_); + const ACE_TCHAR *t_name = name ? name : &this->NULL_String_; + if (validate_value_name (t_name)) + return -1; + + // Get the section name from the key + ACE_TString section; + if (load_key (key, section)) + return -1; + + // Find this section + ACE_Configuration_ExtId ExtId (section.fast_rep ()); + ACE_Configuration_Section_IntId IntId; + if (index_->find (ExtId, IntId, allocator_)) + return -1; // section does not exist + + // Find it + ACE_Configuration_ExtId ValueExtId (t_name); + VALUE_HASH::ENTRY* value_entry; + if (((VALUE_HASH *) IntId.value_hash_map_)->find (ValueExtId, value_entry)) + return -1; // value does not exist + + type_out = value_entry->int_id_.type_; + return 0; +} + +int +ACE_Configuration_Heap::remove_value (const ACE_Configuration_Section_Key& key, + const ACE_TCHAR* name) +{ + ACE_ASSERT (this->allocator_); + const ACE_TCHAR *t_name = name ? name : &this->NULL_String_; + if (validate_value_name (t_name)) + return -1; + + // Get the section name from the key + ACE_TString section; + if (load_key (key, section)) + return -1; + + // Find this section + ACE_Configuration_ExtId ExtId (section.fast_rep ()); + ACE_Configuration_Section_IntId IntId; + if (index_->find (ExtId, IntId, allocator_)) + return -1; // section does not exist + + // Find it + ACE_Configuration_ExtId ValueExtId (t_name); + VALUE_HASH::ENTRY* value_entry; + if (((VALUE_HASH *) IntId.value_hash_map_)->find (ValueExtId, value_entry)) + return -1; + + // free it + value_entry->ext_id_.free (allocator_); + value_entry->int_id_.free (allocator_); + + // Unbind it + if (IntId.value_hash_map_->unbind (ValueExtId, allocator_)) + return -1; + + return 0; +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Configuration.h b/dep/ACE_wrappers/ace/Configuration.h new file mode 100644 index 00000000000..a0098c8ec7e --- /dev/null +++ b/dep/ACE_wrappers/ace/Configuration.h @@ -0,0 +1,894 @@ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file Configuration.h + * + * $Id: Configuration.h 82294 2008-07-12 13:03:37Z johnnyw $ + * + * @author Chris Hafey + * + * The ACE configuration API provides a portable abstraction for + * program configuration similar to the Microsoft Windows registry. + * The API supports a tree based hierarchy of configuration sections. Each + * section contains other sections or values. Values may contain string, + * unsigned integer and binary data. + * + * @note These classes are not thread safe, if multiple threads use these + * classes, you are responsible for serializing access. + * + * For examples of using this class, see: + * -# The test code in ACE_wrappers/test + * -# wxConfigViewer, a Windows like Registry Editor for ACE_Configuration + * -# TAO's IFR, it makes extensive use of ACE_Configuration + * + * @todo Templatize this class with an ACE_LOCK to provide thread safety + */ +//============================================================================= + +#ifndef ACE_CONFIGURATION_H +#define ACE_CONFIGURATION_H +#include /**/ "ace/pre.h" + +#include "ace/SStringfwd.h" +#include "ace/Hash_Map_With_Allocator_T.h" +#include "ace/Malloc_T.h" +#include "ace/MMAP_Memory_Pool.h" +#include "ace/Local_Memory_Pool.h" +#include "ace/Synch_Traits.h" + + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +// configurable parameters + +#if !defined (ACE_CONFIG_SECTION_INDEX) +# define ACE_CONFIG_SECTION_INDEX "Config_Section_Index" +#endif /* ! ACE_CONFIG_SECTION_INDEX */ + +#if !defined (ACE_DEFAULT_CONFIG_SECTION_SIZE) +#define ACE_DEFAULT_CONFIG_SECTION_SIZE 16 +#endif /* ACE_DEFAULT_CONFIG_SECTION_SIZE */ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +/** + * @class ACE_Section_Key_Internal + * + * @internal + * + * @brief A base class for internal handles to section keys for + * configuration implementations + * + * Implementations subclass this base class to represent a + * section key. + */ +class ACE_Export ACE_Section_Key_Internal +{ +public: + /// Virtual destructor, make sure descendants are virtual! + virtual ~ACE_Section_Key_Internal (void); + + /// Increment reference count + virtual int add_ref (void); + + /// Decrement reference count. Will delete this if count gets to 0 + virtual int dec_ref (void); +protected: + ACE_Section_Key_Internal (void); + ACE_Section_Key_Internal (const ACE_Section_Key_Internal& rhs); + ACE_Section_Key_Internal& operator= (ACE_Section_Key_Internal& rhs); + + u_int ref_count_; +}; + +/** + * @class ACE_Configuration_Section_Key + * + * @brief Reference counted wrapper for ACE_Section_Key_Internal. + * + * Reference counted wrapper class for the abstract internal + * section key. A user gets one of these to represent a section + * in the configuration database. + */ +class ACE_Export ACE_Configuration_Section_Key +{ + friend class ACE_Configuration; +public: + /// Default constructor. + ACE_Configuration_Section_Key (void); + + /// Constructor that initializes to a pointer to a concrete internal key. + /** + * @param key The section key to reference. Calls add_ref() with @a key. + */ + explicit ACE_Configuration_Section_Key (ACE_Section_Key_Internal *key); + + /// Copy constructor, increments the reference count on the key. + ACE_Configuration_Section_Key (const ACE_Configuration_Section_Key &rhs); + + /// Destructor, decrements reference count on the referenced key. + ~ACE_Configuration_Section_Key (void); + + /// Assignment operator, increments reference count for this object + /// and decrements it on @a rhs. + ACE_Configuration_Section_Key & + operator= (const ACE_Configuration_Section_Key &rhs); +private: + ACE_Section_Key_Internal *key_; +}; + +/** + * @class ACE_Configuration + * + * @internal + * + * @brief Base class for configuration databases + * + * This class provides an interface for configuration databases. A concrete + * class is required that implements the interface. + * + * @sa ACE_Configuration_Heap + * @sa ACE_Configuration_Win32Registry + */ +class ACE_Export ACE_Configuration +{ +public: + /// Enumeration for the various types of values we can store. + enum VALUETYPE + { + STRING, + INTEGER, + BINARY, + INVALID + }; + + /// Destructor + virtual ~ACE_Configuration (void); + + /// Obtain a reference to the root section of this configuration. + /* + * @return Reference to the configuration's root section. Note that + * it is a const reference. + */ + virtual const ACE_Configuration_Section_Key& root_section (void) const; + + /** + * Opens a named section in an existing section. + * + * @param base Existing section in which to open the named section. + * @param sub_section Name of the section to open. + * @param create If zero, the named section must exist. If non-zero, + * the named section will be created if it does not exist. + * @param result Reference; receives the section key for the new + * section. + * + * @retval 0 for success. + * @retval -1 for error; ACE_OS::last_error() retrieves error code. + */ + virtual int open_section (const ACE_Configuration_Section_Key &base, + const ACE_TCHAR *sub_section, + int create, + ACE_Configuration_Section_Key& result) = 0; + + /// Removes a named section. + /** + * @param key Section key to remove the named section from. + * @param sub_section Name of the section to remove. + * @param recursive If non zero, any subkeys below @a sub_section are + * removed as well. + * + * @retval 0 for success. + * @retval -1 for error; ACE_OS::last_error() retrieves error code. + */ + virtual int remove_section (const ACE_Configuration_Section_Key &key, + const ACE_TCHAR *sub_section, + int recursive) = 0; + + /** + * Enumerates through the values in a section. + * + * @param key Section key to iterate through. + * @param index Iteration position. Must be zero on the first call to + * iterate through @a key. Increment @a index by one on each + * successive call to this method. + * @param name Receives the value's name. + * @param type Receives the value's data type. + * + * @note You may not delete or add values while enumerating. If the + * section is modified during enumeration, results are undefined; + * you must restart the enumeration from index 0. + * + * @retval 0 for success, @a name and @a type are valid. + * @retval 1 there are no more values in the section. + * @retval -1 for error; ACE_OS::last_error() retrieves error code. + */ + virtual int enumerate_values (const ACE_Configuration_Section_Key& key, + int index, + ACE_TString& name, + VALUETYPE& type) = 0; + + /** + * Enumerates through the subsections in a section. + * + * @param key Section key to iterate through. + * @param index Iteration position. Must be zero on the first call to + * iterate through @a key. Increment @a index by one on each + * successive call to this method. + * @param name Receives the subsection's name. + * + * @note You may not modify the @a key section while enumerating. If the + * section is modified during enumeration, results are undefined; + * you must restart the enumeration from index 0. + * + * @retval 0 for success, @a name has a valid name. + * @retval 1 there are no more subsections in the section. + * @retval -1 for error; ACE_OS::last_error() retrieves error code. + */ + virtual int enumerate_sections (const ACE_Configuration_Section_Key& key, + int index, ACE_TString& name) = 0; + + /// Sets a string-typed value. + /** + * @param key Configuration section to set the value in. + * @param name Name of the configuration value to set. If a value with + * the specified name exists, it is replaced. + * @param value The string to set the configuration value to. + * + * @retval 0 for success. + * @retval -1 for error; ACE_OS::last_error() retrieves error code. + */ + virtual int set_string_value (const ACE_Configuration_Section_Key& key, + const ACE_TCHAR* name, + const ACE_TString& value) = 0; + + /// Sets a integer-typed value. + /** + * @param key Configuration section to set the value in. + * @param name Name of the configuration value to set. If a value with + * the specified name exists, it is replaced. + * @param value The integer to set the configuration value to. + * + * @retval 0 for success. + * @retval -1 for error; ACE_OS::last_error() retrieves error code. + */ + virtual int set_integer_value (const ACE_Configuration_Section_Key& key, + const ACE_TCHAR* name, + u_int value) = 0; + + /// Sets a binary-typed value. + /** + * @param key Configuration section to set the value in. + * @param name Name of the configuration value to set. If a value with + * the specified name exists, it is replaced. + * @param data Pointer to the binary data for the value. + * @param length Number of bytes for the new value. + * + * @retval 0 for success. + * @retval -1 for error; ACE_OS::last_error() retrieves error code. + */ + virtual int set_binary_value (const ACE_Configuration_Section_Key& key, + const ACE_TCHAR* name, + const void* data, + size_t length) = 0; + + /// Gets a string-typed value. + /** + * @param key Configuration section to get the value from. + * @param name Name of the configuration value to get. + * @param value Receives the configuration value if it exists and + * has type STRING. + * + * @retval 0 for success. + * @retval -1 for error; ACE_OS::last_error() retrieves error code. + */ + virtual int get_string_value (const ACE_Configuration_Section_Key& key, + const ACE_TCHAR* name, + ACE_TString& value) = 0; + + /// Gets an integer-typed value. + /** + * @param key Configuration section to get the value from. + * @param name Name of the configuration value to get. + * @param value Receives the configuration value if it exists and + * has type INTEGER. + * + * @retval 0 for success. + * @retval -1 for error; ACE_OS::last_error() retrieves error code. + */ + virtual int get_integer_value (const ACE_Configuration_Section_Key& key, + const ACE_TCHAR* name, + u_int& value) = 0; + + /// Gets a binary-typed value. + /** + * @param key Configuration section to get the value from. + * @param name Name of the configuration value to get. + * @param data Receives a pointer to memory holding the binary data + * for the value. This method allocates the memory pointed + * to using operator new[]. The caller is responsible for + * freeing the memory using operator delete[]. + * @param length Receives the number of bytes in the value. + * + * @retval 0 for success; caller is responsible for freeing the + * returned memory. + * @retval -1 for error; ACE_OS::last_error() retrieves error code. + */ + virtual int get_binary_value (const ACE_Configuration_Section_Key& key, + const ACE_TCHAR* name, + void*& data, + size_t& length) = 0; + + /** + * Retrieves the type of a named configuration value. + * + * @param key Configuration section to look up the name in. + * @param name Name of the configuration value to get the type of. + * @param type Receives the data type of the named value, if it exists. + * + * @retval 0 for success. + * @retval -1 for error; ACE_OS::last_error() retrieves error code. + */ + virtual int find_value(const ACE_Configuration_Section_Key& key, + const ACE_TCHAR* name, + VALUETYPE& type) = 0; + + /// Removes a named value. + /** + * @param key Configuration section to remove the named value from. + * @param name Name of the configuration value to remove. + * + * @retval 0 for success. + * @retval -1 for error; ACE_OS::last_error() retrieves error code. + */ + virtual int remove_value (const ACE_Configuration_Section_Key& key, + const ACE_TCHAR* name) = 0; + + /** + * Expands @a path_in to @a key_out from @a key. If create is true, + * the subsections are created. Returns 0 on success, non zero on + * error The path consists of sections separated by the backslash + * '\' or forward slash '/'. + * Returns 0 on success, -1 if + virtual ~ACE_Section_Key_Win32 (void); + + // Not used + ACE_Section_Key_Win32 (const ACE_Section_Key_Win32& rhs); + ACE_Section_Key_Win32& operator= (const ACE_Section_Key_Win32& rhs); +}; + +/** + * @class ACE_Configuration_Win32Registry + * + * @brief The win32 registry implementation of a configuration database + * + * The win32 implementation basically makes calls through to the + * registry functions. The API is very similar so very little + * work must be done + */ +class ACE_Export ACE_Configuration_Win32Registry : public ACE_Configuration +{ +public: + + /** + * Constructor for registry configuration database. hKey is the + * base registry key to attach to. This class takes ownership of + * hKey, it will invoke on it upon destruction. + */ + explicit ACE_Configuration_Win32Registry (HKEY hKey); + + /// Destructor + virtual ~ACE_Configuration_Win32Registry (void); + + virtual int open_section (const ACE_Configuration_Section_Key& base, + const ACE_TCHAR* sub_section, + int create, + ACE_Configuration_Section_Key& result); + + virtual int remove_section (const ACE_Configuration_Section_Key& key, + const ACE_TCHAR* sub_section, + int recursive); + + virtual int enumerate_values (const ACE_Configuration_Section_Key& key, + int index, + ACE_TString& name, + VALUETYPE& type); + + virtual int enumerate_sections (const ACE_Configuration_Section_Key& key, + int index, + ACE_TString& name); + + virtual int set_string_value (const ACE_Configuration_Section_Key& key, + const ACE_TCHAR* name, + const ACE_TString& value); + + virtual int set_integer_value (const ACE_Configuration_Section_Key& key, + const ACE_TCHAR* name, + u_int value); + + virtual int set_binary_value (const ACE_Configuration_Section_Key& key, + const ACE_TCHAR* name, + const void* data, + size_t length); + + virtual int get_string_value (const ACE_Configuration_Section_Key& key, + const ACE_TCHAR* name, + ACE_TString& value); + + virtual int get_integer_value (const ACE_Configuration_Section_Key& key, + const ACE_TCHAR* name, + u_int& value); + + virtual int get_binary_value (const ACE_Configuration_Section_Key& key, + const ACE_TCHAR* name, + void*& data, + size_t& length); + + virtual int find_value(const ACE_Configuration_Section_Key& key, + const ACE_TCHAR* name, + VALUETYPE& type); + + /// Removes the the value @a name from @a key. returns non zero on error + virtual int remove_value (const ACE_Configuration_Section_Key& key, + const ACE_TCHAR* name); + + /** + * This method traverses through . It is useful when + * you want the HKEY for a specific registry key, especially when + * initializing this implementation. Caller is responsible for + * closeing this key when it is no longer used. If create is 1 + * (default) the keys are create if they don't already exist. + * Returns 0 on error + */ + static HKEY resolve_key (HKEY hKey, + const ACE_TCHAR* path, + int create = 1); + virtual bool operator== (const ACE_Configuration_Win32Registry &rhs) const; + virtual bool operator!= (const ACE_Configuration_Win32Registry &rhs) const; + +protected: + + /// Gets the HKEY for a configuration section + int load_key (const ACE_Configuration_Section_Key& key, HKEY& hKey); + + // Not used + ACE_Configuration_Win32Registry (void); + ACE_Configuration_Win32Registry (const ACE_Configuration_Win32Registry& rhs); + ACE_Configuration_Win32Registry& operator= (const ACE_Configuration_Win32Registry& rhs); +}; +#endif /* ACE_WIN32 && !ACE_LACKS_WIN32_REGISTRY */ + +// ACE_Allocator version + +typedef ACE_Allocator_Adapter > + PERSISTENT_ALLOCATOR; +typedef ACE_Allocator_Adapter > + HEAP_ALLOCATOR; + +/** + * @class ACE_Configuration_ExtId + * + * @brief External ID for the section and value hash + * + * Contains a pointer to the section or value name. + */ +class ACE_Export ACE_Configuration_ExtId +{ +public: + /// Defeault ctor + ACE_Configuration_ExtId (void); + + /// Named constructor + explicit ACE_Configuration_ExtId (const ACE_TCHAR* name); + + /// Copy ctor + ACE_Configuration_ExtId (const ACE_Configuration_ExtId& rhs); + + /// destructor + ~ACE_Configuration_ExtId (void); + + /// Assignment operator + ACE_Configuration_ExtId& operator= (const ACE_Configuration_ExtId& rhs); + + /// Equality comparison operator (must match name_). + bool operator== (const ACE_Configuration_ExtId &rhs) const; + + /// Inequality comparison operator. + bool operator!= (const ACE_Configuration_ExtId &rhs) const; + + /// Frees the name of the value. needed since we don't know the + /// allocator name_ was created in + void free (ACE_Allocator *alloc); + + /// function is required in order for this class to be usable by + /// ACE_Hash_Map_Manager. + u_long hash (void) const; + + // = Data members. + + const ACE_TCHAR * name_; + + // Accessors + const ACE_TCHAR *name (void); +}; + +typedef ACE_Hash_Map_With_Allocator + SUBSECTION_MAP; +typedef ACE_Hash_Map_Manager_Ex, + ACE_Equal_To, + ACE_Null_Mutex> + SUBSECTION_HASH; + +/// @deprecated Deprecated typedef. Use the SUBSECTION_HASH::ENTRY trait instead. +typedef SUBSECTION_HASH::ENTRY SUBSECTION_ENTRY; + +/** + * @class ACE_Configuration_Value_IntId + * + * @brief The section hash table internal value class + * + * This class is present as the internal portion of a section's + * value hash table It may store string, integer or binary data. + */ +class ACE_Export ACE_Configuration_Value_IntId +{ +public: + /// Default constructor + ACE_Configuration_Value_IntId (void); + + /// String constructor, takes ownership of string + explicit ACE_Configuration_Value_IntId (ACE_TCHAR* string); + + /// Integer constructor + explicit ACE_Configuration_Value_IntId (u_int integer); + + /// Binary constructor, takes ownership of data + ACE_Configuration_Value_IntId (void* data, size_t length); + + /// Copy ctor + ACE_Configuration_Value_IntId (const ACE_Configuration_Value_IntId& rhs); + + /// Destructor + ~ACE_Configuration_Value_IntId (void); + + /// Assignment operator + ACE_Configuration_Value_IntId& operator= ( + const ACE_Configuration_Value_IntId& rhs); + + void free (ACE_Allocator *alloc); + + // = Data members. + + /** + * Points to the string value or binary data or IS the integer + * Length is only used when type_ == BINARY + */ + ACE_Configuration::VALUETYPE type_; + union { + void * ptr_; + u_int int_; + } data_; + size_t length_; +}; + +typedef ACE_Hash_Map_With_Allocator + VALUE_MAP; +typedef ACE_Hash_Map_Manager_Ex, + ACE_Equal_To, + ACE_Null_Mutex> + VALUE_HASH; + +// Deprecated typedef. Use the VALUE_HASH::ENTRY trait instead. +typedef VALUE_HASH::ENTRY VALUE_ENTRY; + +/** + * @class ACE_Configuration_Section_IntId + * + * @brief The internal ID for a section hash table + * + * Contains a hash table containing value name/values + */ +class ACE_Export ACE_Configuration_Section_IntId +{ +public: + /// Default ctor + ACE_Configuration_Section_IntId (void); + + /// Named ctor + ACE_Configuration_Section_IntId (VALUE_MAP* value_hash_map, + SUBSECTION_MAP* section_hash_map); + + /// Copy ctor + ACE_Configuration_Section_IntId (const ACE_Configuration_Section_IntId& rhs); + + /// Destructor + ~ACE_Configuration_Section_IntId (void); + + /// Assignment operator + ACE_Configuration_Section_IntId& operator= ( + const ACE_Configuration_Section_IntId& rhs); + + /// Frees the hash table and all its values + void free (ACE_Allocator *alloc); + + // = Data Members. + VALUE_MAP* value_hash_map_; + + SUBSECTION_MAP* section_hash_map_; +}; + +typedef ACE_Hash_Map_With_Allocator + SECTION_MAP; +typedef ACE_Hash_Map_Manager_Ex, + ACE_Equal_To, + ACE_Null_Mutex> + SECTION_HASH; + +// Deprecated typedef. Use the SECTION_HASH::ENTRY trait instead. +typedef SECTION_HASH::ENTRY SECTION_ENTRY; + +/** + * @class ACE_Configuration_Section_Key_Heap + * + * @brief Internal section key class for heap based configuration + * database. + * + * Contains a value iterator and full path name of section. + */ +class ACE_Export ACE_Configuration_Section_Key_Heap + : public ACE_Section_Key_Internal +{ +public: + /// Constructor based on the full path of the section + ACE_Configuration_Section_Key_Heap (const ACE_TCHAR* path); + + /// The path itself + ACE_TCHAR* path_; + + /// The value iterator + VALUE_HASH::ITERATOR* value_iter_; + + /// The sub section iterator + SUBSECTION_HASH::ITERATOR* section_iter_; +protected: + /// Destructor - will delete the iterators + virtual ~ACE_Configuration_Section_Key_Heap (void); + + // Not used + ACE_Configuration_Section_Key_Heap (const ACE_Configuration_Section_Key_Heap& rhs); + ACE_Configuration_Section_Key_Heap& operator= (const ACE_Configuration_Section_Key_Heap& rhs); +}; + +/** + * @class ACE_Configuration_Heap + * + * @brief The concrete implementation of a allocator based + * configuration database + * + * This class uses ACE's Allocators to manage a memory + * representation of a configuration database. A persistent heap + * may be used to store configurations persistently + * + * @note Before using this class you must call one of the open methods. + * + * @todo + * - Need to investigate what happens if memory mapped file gets mapped to + * a location different than it was created with. + */ +class ACE_Export ACE_Configuration_Heap : public ACE_Configuration +{ +public: + + /// Default ctor + ACE_Configuration_Heap (void); + + /// Destructor + virtual ~ACE_Configuration_Heap (void); + + /// Opens a configuration based on a file name + int open (const ACE_TCHAR* file_name, + void* base_address = ACE_DEFAULT_BASE_ADDR, + size_t default_map_size = ACE_DEFAULT_CONFIG_SECTION_SIZE); + + /// Opens a heap based configuration + int open (size_t default_map_size = ACE_DEFAULT_CONFIG_SECTION_SIZE); + + virtual int open_section (const ACE_Configuration_Section_Key& base, + const ACE_TCHAR* sub_section, + int create, ACE_Configuration_Section_Key& result); + + virtual int remove_section (const ACE_Configuration_Section_Key& key, + const ACE_TCHAR* sub_section, + int recursive); + + virtual int enumerate_values (const ACE_Configuration_Section_Key& key, + int index, + ACE_TString& name, + VALUETYPE& type); + + virtual int enumerate_sections (const ACE_Configuration_Section_Key& key, + int index, + ACE_TString& name); + + virtual int set_string_value (const ACE_Configuration_Section_Key& key, + const ACE_TCHAR* name, + const ACE_TString& value); + + virtual int set_integer_value (const ACE_Configuration_Section_Key& key, + const ACE_TCHAR* name, + u_int value); + + virtual int set_binary_value (const ACE_Configuration_Section_Key& key, + const ACE_TCHAR* name, + const void* data, + size_t length); + + virtual int get_string_value (const ACE_Configuration_Section_Key& key, + const ACE_TCHAR* name, + ACE_TString& value); + + virtual int get_integer_value (const ACE_Configuration_Section_Key& key, + const ACE_TCHAR* name, + u_int& value); + + virtual int get_binary_value (const ACE_Configuration_Section_Key& key, + const ACE_TCHAR* name, + void* &data, + size_t &length); + + virtual int find_value(const ACE_Configuration_Section_Key& key, + const ACE_TCHAR* name, + VALUETYPE& type); + + /// Removes the the value @a name from @a key. returns non zero on error + virtual int remove_value (const ACE_Configuration_Section_Key& key, + const ACE_TCHAR* name); + +private: + /// @a sub_section may not contain path separators + int open_simple_section (const ACE_Configuration_Section_Key &base, + const ACE_TCHAR *sub_section, + int create, ACE_Configuration_Section_Key &result); + /// Adds a new section + int add_section (const ACE_Configuration_Section_Key &base, + const ACE_TCHAR *sub_section, + ACE_Configuration_Section_Key &result); + + /// Helper for the method. + int create_index (void); + + /// Helper for create_index() method: places hash table into an + /// allocated space. + int create_index_helper (void *buffer); + + int value_open_helper (size_t hash_table_size, void *buffer); + + int section_open_helper (size_t hash_table_size, void *buffer); + + int load_key (const ACE_Configuration_Section_Key& key, ACE_TString& name); + + int new_section (const ACE_TString& section, + ACE_Configuration_Section_Key& result); + + ACE_Configuration_Heap (const ACE_Configuration_Heap& rhs); + ACE_Configuration_Heap& operator= (const ACE_Configuration_Heap& rhs); + + ACE_Allocator *allocator_; + SECTION_MAP *index_; + size_t default_map_size_; +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +#include "ace/Configuration.inl" +#endif /* __ACE_INLINE__ */ + +#include /**/ "ace/post.h" +#endif /* ACE_CONFIGURATION_H */ diff --git a/dep/ACE_wrappers/ace/Configuration.inl b/dep/ACE_wrappers/ace/Configuration.inl new file mode 100644 index 00000000000..19c2c591bf4 --- /dev/null +++ b/dep/ACE_wrappers/ace/Configuration.inl @@ -0,0 +1,13 @@ +// -*- C++ -*- +// +// $Id: Configuration.inl 80826 2008-03-04 14:51:23Z wotte $ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_INLINE const ACE_TCHAR* +ACE_Configuration_ExtId::name (void) +{ + return name_; +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Configuration_Import_Export.cpp b/dep/ACE_wrappers/ace/Configuration_Import_Export.cpp new file mode 100644 index 00000000000..88e6d66f2b9 --- /dev/null +++ b/dep/ACE_wrappers/ace/Configuration_Import_Export.cpp @@ -0,0 +1,670 @@ +// $Id: Configuration_Import_Export.cpp 80826 2008-03-04 14:51:23Z wotte $ + +#include "ace/Configuration_Import_Export.h" +#include "ace/OS_Errno.h" +#include "ace/OS_NS_stdio.h" +#include "ace/OS_NS_ctype.h" +#include "ace/OS_NS_string.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_Config_ImpExp_Base::ACE_Config_ImpExp_Base (ACE_Configuration& config) + : config_ (config) +{ +} + +ACE_Config_ImpExp_Base::~ACE_Config_ImpExp_Base (void) +{ +} + +ACE_Registry_ImpExp::ACE_Registry_ImpExp (ACE_Configuration& config) + : ACE_Config_ImpExp_Base (config) +{ +} + +ACE_Registry_ImpExp::~ACE_Registry_ImpExp (void) +{ +} + +// Imports the configuration database from filename. +// No existing data is removed. +int +ACE_Registry_ImpExp::import_config (const ACE_TCHAR* filename) +{ + if (0 == filename) + { + errno = EINVAL; + return -1; + } + FILE* in = ACE_OS::fopen (filename, ACE_TEXT ("r")); + if (!in) + return -1; + + u_int buffer_size = 4096; + u_int read_pos = 0; + ACE_TCHAR *buffer = 0; + ACE_NEW_NORETURN (buffer, ACE_TCHAR[buffer_size]); + if (!buffer) + { + ACE_Errno_Guard guard (errno); + (void) ACE_OS::fclose (in); + return -1; + } + ACE_Configuration_Section_Key section; + ACE_TCHAR *end = 0; + + while (ACE_OS::fgets (buffer+read_pos, buffer_size - read_pos, in)) + { + // Check if we got all the line. + end = ACE_OS::strrchr (buffer + read_pos, + ACE_TEXT ('\n')); // look for end of line + if (!end) // we havn't reach the end of the line yet + { + // allocate a new buffer - double size the previous one + ACE_TCHAR *temp_buffer; + ACE_NEW_NORETURN (temp_buffer, ACE_TCHAR[buffer_size * 2]); + if (!temp_buffer) + { + ACE_Errno_Guard guard (errno); + delete [] buffer; + (void) ACE_OS::fclose (in); + return -1; + } + + // copy the beginnning of the line + ACE_OS::memcpy (temp_buffer, buffer, buffer_size); + read_pos = buffer_size - 1; + buffer_size *= 2; + delete [] buffer; + buffer = temp_buffer; + continue; + } + read_pos = 0; + + // Check for a comment + if (buffer[0] == ACE_TEXT (';') || buffer[0] == ACE_TEXT ('#')) + continue; + + if (buffer[0] == ACE_TEXT ('[')) + { + // We have a new section here, strip out the section name + end = ACE_OS::strrchr (buffer, ACE_TEXT (']')); + if (!end) + { + ACE_OS::fclose (in); + delete [] buffer; + return -3; + } + *end = 0; + + if (config_.expand_path (config_.root_section (), buffer + 1, section, 1)) + { + ACE_OS::fclose (in); + delete [] buffer; + return -3; + } + continue; + } // end if firs char is a [ + + if (buffer[0] == ACE_TEXT ('"')) + { + // we have a value + end = ACE_OS::strchr (buffer+1, '"'); + if (!end) // no closing quote, not a value so just skip it + continue; + + // null terminate the name + *end = 0; + ACE_TCHAR* name = buffer + 1; + end+=2; + // determine the type + if (*end == '\"') + { + // string type + // truncate trailing " + ++end; + ACE_TCHAR* trailing = ACE_OS::strrchr (end, '"'); + if (trailing) + *trailing = 0; + if (config_.set_string_value (section, name, end)) + { + ACE_OS::fclose (in); + delete [] buffer; + return -4; + } + } + else if (ACE_OS::strncmp (end, ACE_TEXT ("dword:"), 6) == 0) + { + // number type + ACE_TCHAR* endptr = 0; + unsigned long value = ACE_OS::strtoul (end + 6, &endptr, 16); + if (config_.set_integer_value (section, name, value)) + { + ACE_OS::fclose (in); + delete [] buffer; + return -4; + } + } + else if (ACE_OS::strncmp (end, ACE_TEXT ("hex:"), 4) == 0) + { + // binary type + size_t string_length = ACE_OS::strlen (end + 4); + // divide by 3 to get the actual buffer length + size_t length = string_length / 3; + size_t remaining = length; + u_char* data = 0; + ACE_NEW_RETURN (data, + u_char[length], + -1); + u_char* out = data; + ACE_TCHAR* inb = end + 4; + ACE_TCHAR* endptr = 0; + while (remaining) + { + u_char charin = (u_char) ACE_OS::strtoul (inb, &endptr, 16); + *out = charin; + ++out; + --remaining; + inb += 3; + } + if (config_.set_binary_value (section, name, data, length)) + { + ACE_OS::fclose (in); + delete [] data; + delete [] buffer; + return -4; + } + else + delete [] data; + } + else + { + // invalid type, ignore + continue; + } + }// end if first char is a " + else + { + // if the first character is not a ", [, ;, or # we may be + // processing a file in the old format. + // Try and process the line as such and if it fails, + // return an error + int rc = process_previous_line_format (buffer, section); + if (rc != 0) + { + ACE_OS::fclose (in); + delete [] buffer; + return rc; + } + } // end if maybe old format + } // end while fgets + + if (ferror (in)) + { + ACE_OS::fclose (in); + delete [] buffer; + return -1; + } + + ACE_OS::fclose (in); + delete [] buffer; + return 0; +} + +// This method exports the entire configuration database to . +// Once the file is opened this method calls 'export_section' passing +// the root section. +int +ACE_Registry_ImpExp::export_config (const ACE_TCHAR* filename) +{ + if (0 == filename) + { + errno = EINVAL; + return -1; + } + int result = -1; + + FILE* out = ACE_OS::fopen (filename, ACE_TEXT ("w")); + if (out) + { + result = this->export_section (config_.root_section (), + ACE_TEXT (""), + out); + // The data may have been buffered and will be flush on close, + // so we need to check that the close succeeds. + if (ACE_OS::fclose (out) < 0) + result = -7; + } + return result; +} + +// Method provided by derived classes in order to write one section +// to the file specified. Called by export_config when exporting +// the entire configuration object. + +int +ACE_Registry_ImpExp::export_section (const ACE_Configuration_Section_Key& section, + const ACE_TString& path, + FILE* out) +{ + // don't export the root + if (path.length ()) + { + // Write out the section header + ACE_TString header = ACE_TEXT ("["); + header += path; + header += ACE_TEXT ("]"); + header += ACE_TEXT (" \n"); + if (ACE_OS::fputs (header.fast_rep (), out) < 0) + return -1; + // Write out each value + int index = 0; + ACE_TString name; + ACE_Configuration::VALUETYPE type; + ACE_TString line; + ACE_TCHAR int_value[32]; + ACE_TCHAR bin_value[3]; + void* binary_data; + size_t binary_length; + ACE_TString string_value; + while (!config_.enumerate_values (section, index, name, type)) + { + line = ACE_TEXT ("\"") + name + ACE_TEXT ("\"="); + switch (type) + { + case ACE_Configuration::INTEGER: + { + u_int value; + if (config_.get_integer_value (section, name.fast_rep (), value)) + return -2; + ACE_OS::sprintf (int_value, ACE_TEXT ("%08x"), value); + line += ACE_TEXT ("dword:"); + line += int_value; + break; + } + case ACE_Configuration::STRING: + { + if (config_.get_string_value (section, + name.fast_rep (), + string_value)) + return -2; + line += ACE_TEXT ("\""); + line += string_value + ACE_TEXT ("\""); + break; + } +#ifdef _WIN32 + case ACE_Configuration::INVALID: + break; // JDO added break. Otherwise INVALID is processed + // like BINARY. If that's correct, please remove the + // break and these comments +#endif + case ACE_Configuration::BINARY: + { + // not supported yet - maybe use BASE64 codeing? + if (config_.get_binary_value (section, + name.fast_rep (), + binary_data, + binary_length)) + return -2; + line += ACE_TEXT ("hex:"); + unsigned char* ptr = (unsigned char*)binary_data; + while (binary_length) + { + if (ptr != binary_data) + { + line += ACE_TEXT (","); + } + ACE_OS::sprintf (bin_value, ACE_TEXT ("%02x"), *ptr); + line += bin_value; + --binary_length; + ++ptr; + } + delete [] (char*) binary_data; + break; + } + default: + return -3; + } + line += ACE_TEXT ("\n"); + if (ACE_OS::fputs (line.fast_rep (), out) < 0) + return -4; + ++index; + } + } + // Export all sub sections + int index = 0; + ACE_TString name; + ACE_Configuration_Section_Key sub_key; + ACE_TString sub_section; + while (!config_.enumerate_sections (section, index, name)) + { + ACE_TString sub_section (path); + if (path.length ()) + sub_section += ACE_TEXT ("\\"); + sub_section += name; + if (config_.open_section (section, name.fast_rep (), 0, sub_key)) + return -5; + if (export_section (sub_key, sub_section.fast_rep (), out)) + return -6; + ++index; + } + return 0; +} + +// +// This method read the line format origionally used in ACE 5.1 +// +int +ACE_Registry_ImpExp::process_previous_line_format (ACE_TCHAR* buffer, + ACE_Configuration_Section_Key& section) +{ + // Chop any cr/lf at the end of the line. + ACE_TCHAR *endp = ACE_OS::strpbrk (buffer, ACE_TEXT ("\r\n")); + if (endp != 0) + *endp = '\0'; + + // assume this is a value, read in the value name + ACE_TCHAR* end = ACE_OS::strchr (buffer, '='); + if (end) // no =, not a value so just skip it + { + // null terminate the name + *end = 0; + ++end; + // determine the type + if (*end == '\"') + { + // string type + if(config_.set_string_value (section, buffer, end + 1)) + return -4; + } + else if (*end == '#') + { + // number type + u_int value = ACE_OS::atoi (end + 1); + if (config_.set_integer_value (section, buffer, value)) + return -4; + } + } + return 0; +} // end read_previous_line_format + + +ACE_Ini_ImpExp::ACE_Ini_ImpExp (ACE_Configuration& config) + : ACE_Config_ImpExp_Base (config) +{ +} + +ACE_Ini_ImpExp::~ACE_Ini_ImpExp (void) +{ +} + +// Method to read file and populate object. +int +ACE_Ini_ImpExp::import_config (const ACE_TCHAR* filename) +{ + if (0 == filename) + { + errno = EINVAL; + return -1; + } + FILE* in = ACE_OS::fopen (filename, ACE_TEXT ("r")); + if (!in) + return -1; + + // @@ Make this a dynamic size! + ACE_TCHAR buffer[4096]; + ACE_Configuration_Section_Key section; + while (ACE_OS::fgets (buffer, sizeof buffer, in)) + { + ACE_TCHAR *line = this->squish (buffer); + // Check for a comment and blank line + if (line[0] == ACE_TEXT (';') || + line[0] == ACE_TEXT ('#') || + line[0] == '\0') + continue; + + if (line[0] == ACE_TEXT ('[')) + { + // We have a new section here, strip out the section name + ACE_TCHAR* end = ACE_OS::strrchr (line, ACE_TEXT (']')); + if (!end) + { + ACE_OS::fclose (in); + return -3; + } + *end = 0; + + if (config_.expand_path (config_.root_section (), + line + 1, + section, + 1)) + { + ACE_OS::fclose (in); + return -3; + } + + continue; + } + + // We have a line; name ends at equal sign. + ACE_TCHAR *end = ACE_OS::strchr (line, ACE_TEXT ('=')); + if (end == 0) // No '=' + { + ACE_OS::fclose (in); + return -3; + } + *end++ = '\0'; + ACE_TCHAR *name = this->squish (line); +#if 0 + if (ACE_OS::strlen (name) == 0) // No name; just an '=' + { + ACE_OS::fclose (in); + return -3; + } +#endif + // Now find the start of the value + ACE_TCHAR *value = this->squish (end); + size_t value_len = ACE_OS::strlen (value); + if (value_len > 0) + { + // ACE 5.2 (and maybe earlier) exported strings may be enclosed + // in quotes. If string is quote-delimited, strip the quotes. + // Newer exported files don't have quote delimiters. + if (value[0] == ACE_TEXT ('"') && + value[value_len - 1] == ACE_TEXT ('"')) + { + // Strip quotes off both ends. + value[value_len - 1] = '\0'; + ++value; + } + } + + if (config_.set_string_value (section, name, value)) + { + ACE_OS::fclose (in); + return -4; + } + } // end while fgets + + if (ferror (in)) + { + ACE_OS::fclose (in); + return -1; + } + + ACE_OS::fclose (in); + return 0; +} + +// This method exports the entire configuration database to . +// Once the file is opened this method calls 'export_section' passing +// the root section. +int +ACE_Ini_ImpExp::export_config (const ACE_TCHAR* filename) +{ + if (0 == filename) + { + errno = EINVAL; + return -1; + } + int result = -1; + + FILE* out = ACE_OS::fopen (filename, ACE_TEXT ("w")); + if (out) + { + result = this->export_section (config_.root_section (), + ACE_TEXT (""), + out); + // The data may have been buffered and will be flush on close, + // so we need to check that the close succeeds. + if (ACE_OS::fclose (out) < 0) + result = -7; + } + return result; +} + +// Method provided by derived classes in order to write one section to the +// file specified. Called by export_config when exporting the entire +// configuration objet + +int +ACE_Ini_ImpExp::export_section (const ACE_Configuration_Section_Key& section, + const ACE_TString& path, + FILE* out) +{ + // don't export the root + if (path.length ()) + { + // Write out the section header + ACE_TString header = ACE_TEXT ("["); + header += path; + header += ACE_TEXT ("]\n"); + if (ACE_OS::fputs (header.fast_rep (), out) < 0) + return -1; + // Write out each value + int index = 0; + ACE_TString name; + ACE_Configuration::VALUETYPE type; + ACE_TString line; + ACE_TCHAR int_value[32]; + ACE_TCHAR bin_value[3]; + void* binary_data; + size_t binary_length; + ACE_TString string_value; + while (!config_.enumerate_values (section, index, name, type)) + { + line = name + ACE_TEXT ("="); + switch (type) + { + case ACE_Configuration::INTEGER: + { + u_int value; + if (config_.get_integer_value (section, name.fast_rep (), value)) + return -2; + ACE_OS::sprintf (int_value, ACE_TEXT ("%08x"), value); + line += int_value; + break; + } + case ACE_Configuration::STRING: + { + if (config_.get_string_value (section, + name.fast_rep (), + string_value)) + return -2; + line += string_value; + break; + } +#ifdef _WIN32 + case ACE_Configuration::INVALID: + break; // JDO added break. Otherwise INVALID is processed + // like BINARY. If that's correct, please remove the + // break and these comments +#endif + case ACE_Configuration::BINARY: + { + // not supported yet - maybe use BASE64 codeing? + if (config_.get_binary_value (section, + name.fast_rep (), + binary_data, + binary_length)) + return -2; + line += ACE_TEXT ("\""); + unsigned char* ptr = (unsigned char*)binary_data; + while (binary_length) + { + if (ptr != binary_data) + { + line += ACE_TEXT (","); + } + ACE_OS::sprintf (bin_value, ACE_TEXT ("%02x"), *ptr); + line += bin_value; + --binary_length; + ++ptr; + } + line += ACE_TEXT ("\""); + delete [] (char *) binary_data; + break; + } + default: + return -3; + + }// end switch on type + + line += ACE_TEXT ("\n"); + if (ACE_OS::fputs (line.fast_rep (), out) < 0) + return -4; + ++index; + }// end while enumerating values + } + // Export all sub sections + int index = 0; + ACE_TString name; + ACE_Configuration_Section_Key sub_key; + ACE_TString sub_section; + while (!config_.enumerate_sections (section, index, name)) + { + ACE_TString sub_section (path); + if (path.length ()) + sub_section += ACE_TEXT ("\\"); + sub_section += name; + if (config_.open_section (section, name.fast_rep (), 0, sub_key)) + return -5; + if (export_section (sub_key, sub_section.fast_rep (), out)) + return -6; + ++index; + } + return 0; + +} + +// Method to squish leading and trailing whitespaces from a string. +// Whitespace is defined as: spaces (' '), tabs ('\t') or end-of-line +// (cr/lf). The terminating nul is moved up to expunge trailing +// whitespace and the returned pointer points at the first +// non-whitespace character in the string, which may be the nul +// terminator if the string is all whitespace. + +ACE_TCHAR * +ACE_Ini_ImpExp::squish (ACE_TCHAR *src) +{ + ACE_TCHAR *cp = 0; + + if (src == 0) + return 0; + + // Start at the end and work backwards over all whitespace. + for (cp = src + ACE_OS::strlen (src) - 1; + cp != src; + --cp) + if (!ACE_OS::ace_isspace (*cp)) + break; + cp[1] = '\0'; // Chop trailing whitespace + + // Now start at the beginning and move over all whitespace. + for (cp = src; ACE_OS::ace_isspace (*cp); ++cp) + continue; + + return cp; +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Configuration_Import_Export.h b/dep/ACE_wrappers/ace/Configuration_Import_Export.h new file mode 100644 index 00000000000..e93544bee29 --- /dev/null +++ b/dep/ACE_wrappers/ace/Configuration_Import_Export.h @@ -0,0 +1,215 @@ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file Configuration_Import_Export.h + * + * $Id: Configuration_Import_Export.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Jerry D. Odenwelder Jr. + * Chris Hafey + * + * Classes defined in this file provide the ability to import and export + * ACE Configuration objects to/from disk files. The base class + * ACE_Config_ImpExp_Base provides the common functionality and the derived + * classes implement the import/export functionality for the specific format. + * + * @todo + * - Add locking for thread safety. + * - Provide ability to read file in one format and write in another. + * - See todo's in each class + */ +//============================================================================= + +#ifndef ACE_CONFIGURATION_IMPORT_EXPORT_H +#define ACE_CONFIGURATION_IMPORT_EXPORT_H +#include /**/ "ace/pre.h" + +#include "ace/Configuration.h" +#include "ace/SString.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +/** + * @class ACE_Config_ImpExp_Base + * + * @brief Base class for file import/export configuration. + * + * This class provides base functionality for configuration objects + * that are persisted in files. It takes an ACE_Configuration + * object that it populates with the data read. + * + */ +class ACE_Export ACE_Config_ImpExp_Base +{ +public: + /// Constructor taking the ACE_Configuration to import/export to + ACE_Config_ImpExp_Base (ACE_Configuration& config); + + /** + * Destructor + */ + virtual ~ACE_Config_ImpExp_Base (void); + + /** + * Imports the configuration database from @a filename. + * No existing data is removed. + */ + virtual int import_config (const ACE_TCHAR* filename) = 0; + + /** + * This method exports the entire configuration database to @a filename. + * Once the file is opened this method calls 'export_section' passing + * the root section. + */ + virtual int export_config (const ACE_TCHAR* filename) = 0; + +protected: + ACE_Configuration &config_; + +private: + ACE_Config_ImpExp_Base (const ACE_Config_ImpExp_Base&); + ACE_Config_ImpExp_Base& operator= (const ACE_Config_ImpExp_Base&); +}; + +/** + * @class ACE_Registry_ImpExp + * + * @brief Configuration object that imports/exports data to a file formatted + * using the Win32 Registry file export format. This format looks like + * [Section] + * "key"="String Data" + * "key"=dword: numeric data in hexidecimal format + * "key"=hex: binary data + * + * @todo + * - Add dynamic buffer when importing. currently it will not allow + * importing of values greater than a fixed ammount (4096 bytes) + * + */ +class ACE_Export ACE_Registry_ImpExp : public ACE_Config_ImpExp_Base +{ +public: + /// Construction + ACE_Registry_ImpExp (ACE_Configuration&); + + /// Destruction. + virtual ~ACE_Registry_ImpExp (void); + + /** + * Imports the configuration database from filename. + * No existing data is removed. + */ + virtual int import_config (const ACE_TCHAR* filename); + + /** + * This method exports the entire configuration database to @a filename. + * Once the file is opened this method calls export_section() passing + * the root section. + */ + virtual int export_config (const ACE_TCHAR* filename); + +private: + int export_section (const ACE_Configuration_Section_Key& section, + const ACE_TString& path, + FILE* out); + + int process_previous_line_format (ACE_TCHAR* buffer, + ACE_Configuration_Section_Key& section); + + ACE_Registry_ImpExp ( const ACE_Registry_ImpExp&); + ACE_Registry_ImpExp& operator= ( const ACE_Registry_ImpExp&); +}; + +/** + * @class ACE_Ini_ImpExp + * + * @brief Imports the configuration database from filename as strings. + * Allows non-typed values. (no #, dword: hex:, etc. prefixes) and + * skips whitespace (tabs and spaces) as in standard .ini and .conf + * files. Values (to right of equal sign) can be double quote + * delimited to embed tabs and spaces in the string. + * Caller must convert string to type. + * + * This method allows for lines in the .ini or .conf file like this: + * + * TimeToLive = 100 + * Delay = FALSE + * Flags = FF34 + * Heading = "ACE - Adaptive Communication Environment" + * + * (note leading whitespace (tabs) in examples below) + * + * SeekIndex = 14 + * TraceLevel = 6 # Can comment lines like this + * Justification = left_justified + * + * The caller can then retrieve the string with the regular + * function and convert the string to the + * desired data type. + * + * @todo + * - Strings with embedded newlines cause the import to fail + * - Strings with embedded quotes " cause the import to fail + * - Importing/exporting for values in the root section does not work + * - Add dynamic buffer when importing. currently it will not allow + * importing of values greater than a fixed ammount (4096 bytes) +*/ +class ACE_Export ACE_Ini_ImpExp : public ACE_Config_ImpExp_Base +{ +public: + /** + * Construction + */ + ACE_Ini_ImpExp (ACE_Configuration&); + + /** + * Destructor + */ + virtual ~ACE_Ini_ImpExp (void); + + /** + * Imports the configuration database from filename. + * No existing data is removed. + */ + virtual int import_config (const ACE_TCHAR* filename); + + /** + * This method exports the entire configuration database to @a filename. + * Once the file is opened this method calls export_section() passing + * the root section. + */ + virtual int export_config (const ACE_TCHAR* filename); + +private: + /** + * Method provided by derived classes in order to write one section + * to the file specified. Called by export_config() when exporting + * the entire configuration object. + */ + int export_section (const ACE_Configuration_Section_Key& section, + const ACE_TString& path, + FILE* out); + + /** + * Method to squish leading and trailing whitespaces in a string. + * Whitespace is defined as: spaces (' '), tabs ('\\t') or cr/lf. + * Returns a pointer to the first non-whitespace character in the + * buffer provided, or a pointer to the terminating null if the string + * is all whitespace. The terminating null is moved forward to the + * first character past the last non-whitespace. + */ + ACE_TCHAR *squish (ACE_TCHAR *src); + + ACE_Ini_ImpExp (const ACE_Ini_ImpExp&); + ACE_Ini_ImpExp& operator= (const ACE_Ini_ImpExp&); +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#include /**/ "ace/post.h" +#endif /* ACE_CONFIGURATION_IMPORT_EXPORT_H */ diff --git a/dep/ACE_wrappers/ace/Connection_Recycling_Strategy.cpp b/dep/ACE_wrappers/ace/Connection_Recycling_Strategy.cpp new file mode 100644 index 00000000000..78b08884340 --- /dev/null +++ b/dep/ACE_wrappers/ace/Connection_Recycling_Strategy.cpp @@ -0,0 +1,13 @@ +#include "ace/Connection_Recycling_Strategy.h" + + +ACE_RCSID(ace, Connection_Recycling_Strategy, "$Id: Connection_Recycling_Strategy.cpp 80826 2008-03-04 14:51:23Z wotte $") + + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_Connection_Recycling_Strategy::~ACE_Connection_Recycling_Strategy (void) +{ +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Connection_Recycling_Strategy.h b/dep/ACE_wrappers/ace/Connection_Recycling_Strategy.h new file mode 100644 index 00000000000..75169638dcf --- /dev/null +++ b/dep/ACE_wrappers/ace/Connection_Recycling_Strategy.h @@ -0,0 +1,63 @@ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file Connection_Recycling_Strategy.h + * + * $Id: Connection_Recycling_Strategy.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Doug Schmidt + */ +//============================================================================= +#ifndef ACE_CONNECTION_RECYCLING_STRATEGY_H +#define ACE_CONNECTION_RECYCLING_STRATEGY_H +#include /**/ "ace/pre.h" + +#include "ace/Recyclable.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +/** + * @class ACE_Connection_Recycling_Strategy + * + * @brief Defines the interface for a connection recycler. + */ +class ACE_Export ACE_Connection_Recycling_Strategy +{ +public: + /// Virtual Destructor + virtual ~ACE_Connection_Recycling_Strategy (void); + + /// Remove from cache. + virtual int purge (const void *recycling_act) = 0; + + /// Add to cache. + virtual int cache (const void *recycling_act) = 0; + + virtual int recycle_state (const void *recycling_act, + ACE_Recyclable_State new_state) = 0; + + /// Get/Set recycle_state. + virtual ACE_Recyclable_State recycle_state (const void *recycling_act) const = 0; + + /// Mark as closed. + virtual int mark_as_closed (const void *recycling_act) = 0; + + /// Mark as closed.(non-locking version) + virtual int mark_as_closed_i (const void *recycling_act) = 0; + + /// Cleanup hint and reset @a act_holder to zero if @a act_holder != 0. + virtual int cleanup_hint (const void *recycling_act, + void **act_holder = 0) = 0; + +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#include /**/ "ace/post.h" + +#endif /*ACE_CONNECTION_RECYCLING_STRATEGY*/ diff --git a/dep/ACE_wrappers/ace/Connector.cpp b/dep/ACE_wrappers/ace/Connector.cpp new file mode 100644 index 00000000000..3e68abc097a --- /dev/null +++ b/dep/ACE_wrappers/ace/Connector.cpp @@ -0,0 +1,966 @@ +// $Id: Connector.cpp 81991 2008-06-16 19:05:40Z elliott_c $ + +#ifndef ACE_CONNECTOR_CPP +#define ACE_CONNECTOR_CPP + +#include "ace/Connector.h" +#include "ace/ACE.h" +#include "ace/OS_NS_stdio.h" +#include "ace/OS_NS_string.h" +#include "ace/os_include/os_fcntl.h" /* Has ACE_NONBLOCK */ + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_ALLOC_HOOK_DEFINE(ACE_Connector) + +template +ACE_NonBlocking_Connect_Handler::ACE_NonBlocking_Connect_Handler +(ACE_Connector_Base &connector, + SVC_HANDLER *sh, + long id) + : connector_ (connector) + , svc_handler_ (sh) + , timer_id_ (id) +{ + ACE_TRACE ("ACE_NonBlocking_Connect_Handler::ACE_NonBlocking_Connect_Handler"); + + this->reference_counting_policy ().value + (ACE_Event_Handler::Reference_Counting_Policy::ENABLED); +} + +template SVC_HANDLER * +ACE_NonBlocking_Connect_Handler::svc_handler (void) +{ + ACE_TRACE ("ACE_NonBlocking_Connect_Handler::svc_handler"); + return this->svc_handler_; +} + +template long +ACE_NonBlocking_Connect_Handler::timer_id (void) +{ + ACE_TRACE ("ACE_NonBlocking_Connect_Handler::timer_id"); + return this->timer_id_; +} + +template void +ACE_NonBlocking_Connect_Handler::timer_id (long id) +{ + ACE_TRACE ("ACE_NonBlocking_Connect_Handler::timer_id"); + this->timer_id_ = id; +} + +template void +ACE_NonBlocking_Connect_Handler::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + ACE_TRACE ("ACE_NonBlocking_Connect_Handler::dump"); + + ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("svc_handler_ = %x"), this->svc_handler_)); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\ntimer_id_ = %d"), this->timer_id_)); + ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); +#endif /* ACE_HAS_DUMP */ +} + +template bool +ACE_NonBlocking_Connect_Handler::close (SVC_HANDLER *&sh) +{ + // Make sure that we haven't already initialized the Svc_Handler. + if (!this->svc_handler_) + return false; + + { + // Exclusive access to the Reactor. + ACE_GUARD_RETURN (ACE_Lock, + ace_mon, + this->reactor ()->lock (), + 0); + + // Double check. + if (!this->svc_handler_) + return false; + + // Remember the Svc_Handler. + sh = this->svc_handler_; + ACE_HANDLE h = sh->get_handle (); + this->svc_handler_ = 0; + + // Remove this handle from the set of non-blocking handles + // in the Connector. + this->connector_.non_blocking_handles ().remove (h); + + // Cancel timer. + if (this->reactor ()->cancel_timer (this->timer_id (), + 0, + 0) == -1) + return false; + + // Remove from Reactor. + if (this->reactor ()->remove_handler ( + h, + ACE_Event_Handler::ALL_EVENTS_MASK) == -1) + return false; + } + + return true; +} + + +template int +ACE_NonBlocking_Connect_Handler::handle_timeout +(const ACE_Time_Value &tv, + const void *arg) +{ + // This method is called if a connection times out before completing. + ACE_TRACE ("ACE_NonBlocking_Connect_Handler::handle_timeout"); + + SVC_HANDLER *svc_handler = 0; + int retval = this->close (svc_handler) ? 0 : -1; + + // Forward to the SVC_HANDLER the that was passed in as a + // magic cookie during ACE_Connector::connect(). This gives the + // SVC_HANDLER an opportunity to take corrective action (e.g., wait + // a few milliseconds and try to reconnect again. + if (svc_handler != 0 && svc_handler->handle_timeout (tv, arg) == -1) + svc_handler->handle_close (svc_handler->get_handle (), + ACE_Event_Handler::TIMER_MASK); + + return retval; +} + + +template int +ACE_NonBlocking_Connect_Handler::handle_input (ACE_HANDLE) +{ + // Called when a failure occurs during asynchronous connection + // establishment. + ACE_TRACE ("ACE_NonBlocking_Connect_Handler::handle_input"); + + SVC_HANDLER *svc_handler = 0; + int const retval = this->close (svc_handler) ? 0 : -1; + + // Close Svc_Handler. + if (svc_handler != 0) + svc_handler->close (NORMAL_CLOSE_OPERATION); + + return retval; +} + +template int +ACE_NonBlocking_Connect_Handler::handle_output (ACE_HANDLE handle) +{ + // Called when a connection is establishment asynchronous. + ACE_TRACE ("ACE_NonBlocking_Connect_Handler::handle_output"); + + // Grab the connector ref before smashing ourselves in close(). + ACE_Connector_Base &connector = this->connector_; + SVC_HANDLER *svc_handler = 0; + int const retval = this->close (svc_handler) ? 0 : -1; + + if (svc_handler != 0) + connector.initialize_svc_handler (handle, svc_handler); + + return retval; +} + +template int +ACE_NonBlocking_Connect_Handler::handle_exception (ACE_HANDLE h) +{ + // On Win32, the except mask must also be set for asynchronous + // connects. + ACE_TRACE ("ACE_NonBlocking_Connect_Handler::handle_exception"); + return this->handle_output (h); +} + +template int +ACE_NonBlocking_Connect_Handler::resume_handler (void) +{ + return ACE_Event_Handler::ACE_EVENT_HANDLER_NOT_RESUMED; +} + +template void +ACE_Connector::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + ACE_TRACE ("ACE_Connector::dump"); + + ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nflags_ = %d"), this->flags_)); + ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); +#endif /* ACE_HAS_DUMP */ +} + +template int +ACE_Connector::make_svc_handler (SVC_HANDLER *&sh) +{ + ACE_TRACE ("ACE_Connector::make_svc_handler"); + + if (sh == 0) + ACE_NEW_RETURN (sh, + SVC_HANDLER, + -1); + + // Set the reactor of the newly created to the same + // reactor that this is using. + sh->reactor (this->reactor ()); + return 0; +} + +template int +ACE_Connector::activate_svc_handler (SVC_HANDLER *svc_handler) +{ + ACE_TRACE ("ACE_Connector::activate_svc_handler"); + // No errors initially + int error = 0; + + // See if we should enable non-blocking I/O on the 's + // peer. + if (ACE_BIT_ENABLED (this->flags_, ACE_NONBLOCK) != 0) + { + if (svc_handler->peer ().enable (ACE_NONBLOCK) == -1) + error = 1; + } + // Otherwise, make sure it's disabled by default. + else if (svc_handler->peer ().disable (ACE_NONBLOCK) == -1) + error = 1; + + // We are connected now, so try to open things up. + if (error || svc_handler->open ((void *) this) == -1) + { + // Make sure to close down the to avoid descriptor + // leaks. + // The connection was already made; so this close is a "normal" + // close operation. + svc_handler->close (NORMAL_CLOSE_OPERATION); + return -1; + } + else + return 0; +} + +template ACE_PEER_CONNECTOR & +ACE_Connector::connector (void) const +{ + return const_cast (this->connector_); +} + +template int +ACE_Connector::connect_svc_handler +(SVC_HANDLER *&svc_handler, + const ACE_PEER_CONNECTOR_ADDR &remote_addr, + ACE_Time_Value *timeout, + const ACE_PEER_CONNECTOR_ADDR &local_addr, + int reuse_addr, + int flags, + int perms) +{ + ACE_TRACE ("ACE_Connector::connect_svc_handler"); + + return this->connector_.connect (svc_handler->peer (), + remote_addr, + timeout, + local_addr, + reuse_addr, + flags, + perms); +} + +template int +ACE_Connector::connect_svc_handler +(SVC_HANDLER *&svc_handler, + SVC_HANDLER *&sh_copy, + const ACE_PEER_CONNECTOR_ADDR &remote_addr, + ACE_Time_Value *timeout, + const ACE_PEER_CONNECTOR_ADDR &local_addr, + int reuse_addr, + int flags, + int perms) +{ + ACE_TRACE ("ACE_Connector::connect_svc_handler"); + + sh_copy = svc_handler; + return this->connector_.connect (svc_handler->peer (), + remote_addr, + timeout, + local_addr, + reuse_addr, + flags, + perms); +} + +template int +ACE_Connector::open (ACE_Reactor *r, int flags) +{ + ACE_TRACE ("ACE_Connector::open"); + this->reactor (r); + this->flags_ = flags; + return 0; +} + +template +ACE_Connector::ACE_Connector (ACE_Reactor *r, + int flags) +{ + ACE_TRACE ("ACE_Connector::ACE_Connector"); + (void) this->open (r, flags); +} + +template int +ACE_Connector::connect +(SVC_HANDLER *&sh, + const ACE_PEER_CONNECTOR_ADDR &remote_addr, + const ACE_Synch_Options &synch_options, + const ACE_PEER_CONNECTOR_ADDR &local_addr, + int reuse_addr, + int flags, + int perms) +{ + // Initiate connection to peer. + return this->connect_i (sh, + 0, + remote_addr, + synch_options, + local_addr, + reuse_addr, + flags, + perms); +} + +template int +ACE_Connector::connect +(SVC_HANDLER *&sh, + SVC_HANDLER *&sh_copy, + const ACE_PEER_CONNECTOR_ADDR &remote_addr, + const ACE_Synch_Options &synch_options, + const ACE_PEER_CONNECTOR_ADDR &local_addr, + int reuse_addr, + int flags, + int perms) +{ + // Initiate connection to peer. + return this->connect_i (sh, + &sh_copy, + remote_addr, + synch_options, + local_addr, + reuse_addr, + flags, + perms); +} + +template int +ACE_Connector::connect_i +(SVC_HANDLER *&sh, + SVC_HANDLER **sh_copy, + const ACE_PEER_CONNECTOR_ADDR &remote_addr, + const ACE_Synch_Options &synch_options, + const ACE_PEER_CONNECTOR_ADDR &local_addr, + int reuse_addr, + int flags, + int perms) +{ + ACE_TRACE ("ACE_Connector::connect_i"); + + // If the user hasn't supplied us with a we'll use the + // factory method to create one. Otherwise, things will remain as + // they are... + if (this->make_svc_handler (sh) == -1) + return -1; + + ACE_Time_Value *timeout = 0; + int const use_reactor = synch_options[ACE_Synch_Options::USE_REACTOR]; + + if (use_reactor) + timeout = const_cast (&ACE_Time_Value::zero); + else + timeout = const_cast (synch_options.time_value ()); + + int result; + if (sh_copy == 0) + result = this->connect_svc_handler (sh, + remote_addr, + timeout, + local_addr, + reuse_addr, + flags, + perms); + else + result = this->connect_svc_handler (sh, + *sh_copy, + remote_addr, + timeout, + local_addr, + reuse_addr, + flags, + perms); + + // Activate immediately if we are connected. + if (result != -1) + return this->activate_svc_handler (sh); + + // Delegate to connection strategy. + if (use_reactor && ACE_OS::last_error () == EWOULDBLOCK) + { + // If the connection hasn't completed and we are using + // non-blocking semantics then register + // ACE_NonBlocking_Connect_Handler with the ACE_Reactor so that + // it will call us back when the connection is complete or we + // timeout, whichever comes first... + int result; + + if (sh_copy == 0) + result = this->nonblocking_connect (sh, synch_options); + else + result = this->nonblocking_connect (*sh_copy, synch_options); + + // If for some reason the call failed, then + // will be set to the new error. If the call succeeds, however, + // we need to make sure that remains set to + // . + if (result == 0) + errno = EWOULDBLOCK; + } + else + { + // Save/restore errno. + ACE_Errno_Guard error (errno); + // Make sure to close down the service handler to avoid handle + // leaks. + if (sh_copy == 0) + { + if (sh) + sh->close (CLOSE_DURING_NEW_CONNECTION); + } + else if (*sh_copy) + (*sh_copy)->close (CLOSE_DURING_NEW_CONNECTION); + } + + return -1; +} + +template int +ACE_Connector::connect_n +(size_t n, + SVC_HANDLER *sh[], + ACE_PEER_CONNECTOR_ADDR remote_addrs[], + ACE_TCHAR *failed_svc_handlers, + const ACE_Synch_Options &synch_options) +{ + int result = 0; + + for (size_t i = 0; i < n; i++) + { + if (this->connect (sh[i], remote_addrs[i], synch_options) == -1 + && !(synch_options[ACE_Synch_Options::USE_REACTOR] + && errno == EWOULDBLOCK)) + { + result = -1; + if (failed_svc_handlers != 0) + // Mark this entry as having failed. + failed_svc_handlers[i] = 1; + } + else if (failed_svc_handlers != 0) + // Mark this entry as having succeeded. + failed_svc_handlers[i] = 0; + } + + return result; +} + +// Cancel a that was started asynchronously. +template int +ACE_Connector::cancel (SVC_HANDLER *sh) +{ + ACE_TRACE ("ACE_Connector::cancel"); + + ACE_Event_Handler *handler = + this->reactor ()->find_handler (sh->get_handle ()); + + if (handler == 0) + return -1; + + // find_handler() increments handler's refcount; ensure we decrement it. + ACE_Event_Handler_var safe_handler (handler); + + NBCH *nbch = + dynamic_cast (handler); + + if (nbch == 0) + return -1; + + SVC_HANDLER *tmp_sh = 0; + + if (nbch->close (tmp_sh) == false) + return -1; + + return 0; +} + +template int +ACE_Connector::nonblocking_connect +(SVC_HANDLER *sh, + const ACE_Synch_Options &synch_options) +{ + ACE_TRACE ("ACE_Connector::nonblocking_connect"); + + // Must have a valid Reactor for non-blocking connects to work. + if (this->reactor () == 0) + return -1; + + // Register the pending SVC_HANDLER so that it can be activated + // later on when the connection completes. + + ACE_HANDLE handle = sh->get_handle (); + long timer_id = -1; + ACE_Time_Value *tv = 0; + NBCH *nbch = 0; + + ACE_NEW_RETURN (nbch, + NBCH (*this, + sh, + -1), + -1); + + ACE_Event_Handler_var safe_nbch (nbch); + + // Exclusive access to the Reactor. + ACE_GUARD_RETURN (ACE_Lock, ace_mon, this->reactor ()->lock (), -1); + + // Register handle with the reactor for connection events. + ACE_Reactor_Mask mask = ACE_Event_Handler::CONNECT_MASK; + if (this->reactor ()->register_handler (handle, + nbch, + mask) == -1) + goto reactor_registration_failure; + + // Add handle to non-blocking handle set. + this->non_blocking_handles ().insert (handle); + + // If we're starting connection under timer control then we need to + // schedule a timeout with the ACE_Reactor. + tv = const_cast (synch_options.time_value ()); + if (tv != 0) + { + timer_id = + this->reactor ()->schedule_timer (nbch, + synch_options.arg (), + *tv); + if (timer_id == -1) + goto timer_registration_failure; + + // Remember timer id. + nbch->timer_id (timer_id); + } + + return 0; + + // Undo previous actions using the ol' "goto label and fallthru" + // trick... + timer_registration_failure: + + // Remove from Reactor. + this->reactor ()->remove_handler (handle, mask); + + // Remove handle from the set of non-blocking handles. + this->non_blocking_handles ().remove (handle); + + /* FALLTHRU */ + + reactor_registration_failure: + // Close the svc_handler + + sh->close (CLOSE_DURING_NEW_CONNECTION); + + return -1; +} + +template +ACE_Connector::~ACE_Connector (void) +{ + ACE_TRACE ("ACE_Connector::~ACE_Connector"); + + this->close (); +} + +template void +ACE_Connector::initialize_svc_handler +(ACE_HANDLE handle, + SVC_HANDLER *svc_handler) +{ + // Try to find out if the reactor uses event associations for the + // handles it waits on. If so we need to reset it. + int reset_new_handle = + this->reactor ()->uses_event_associations (); + + if (reset_new_handle) + this->connector_.reset_new_handle (handle); + + // Transfer ownership of the ACE_HANDLE to the SVC_HANDLER. + svc_handler->set_handle (handle); + + ACE_PEER_CONNECTOR_ADDR raddr; + + // Check to see if we're connected. + if (svc_handler->peer ().get_remote_addr (raddr) != -1) + this->activate_svc_handler (svc_handler); + else // Somethings gone wrong, so close down... + { +#if defined (ACE_WIN32) + // Win32 (at least prior to Windows 2000) has a timing problem. + // If you check to see if the connection has completed too fast, + // it will fail - so wait 35 milliseconds to let it catch up. + ACE_Time_Value tv (0, ACE_NON_BLOCKING_BUG_DELAY); + ACE_OS::sleep (tv); + if (svc_handler->peer ().get_remote_addr (raddr) != -1) + this->activate_svc_handler (svc_handler); + else // do the svc handler close below... +#endif /* ACE_WIN32 */ + svc_handler->close (NORMAL_CLOSE_OPERATION); + } +} + +template void +ACE_Connector::reactor (ACE_Reactor *reactor) +{ + this->reactor_ = reactor; +} + +template ACE_Reactor * +ACE_Connector::reactor (void) const +{ + return this->reactor_; +} + +template ACE_Unbounded_Set & +ACE_Connector::non_blocking_handles (void) +{ + return this->non_blocking_handles_; +} + +template int +ACE_Connector::close (void) +{ + // If there are no non-blocking handle pending, return immediately. + if (this->non_blocking_handles ().size () == 0) + return 0; + + // Exclusive access to the Reactor. + ACE_GUARD_RETURN (ACE_Lock, ace_mon, this->reactor ()->lock (), -1); + + // Go through all the non-blocking handles. It is necessary to + // create a new iterator each time because we remove from the handle + // set when we cancel the Svc_Handler. + ACE_HANDLE *handle = 0; + while (1) + { + ACE_Unbounded_Set_Iterator + iterator (this->non_blocking_handles ()); + if (!iterator.next (handle)) + break; + + ACE_Event_Handler *handler = + this->reactor ()->find_handler (*handle); + if (handler == 0) + { + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("%t: Connector::close h %d, no handler\n"), + *handle)); + // Remove handle from the set of non-blocking handles. + this->non_blocking_handles ().remove (*handle); + continue; + } + + // find_handler() incremented handler's refcount; ensure it's decremented + ACE_Event_Handler_var safe_handler (handler); + NBCH *nbch = dynamic_cast (handler); + if (nbch == 0) + { + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("%t: Connector::close h %d handler %@ ") + ACE_TEXT ("not a legit handler\n"), + *handle, + handler)); + // Remove handle from the set of non-blocking handles. + this->non_blocking_handles ().remove (*handle); + continue; + } + SVC_HANDLER *svc_handler = nbch->svc_handler (); + + // Cancel the non-blocking connection. + this->cancel (svc_handler); + + // Close the associated Svc_Handler. + svc_handler->close (NORMAL_CLOSE_OPERATION); + } + + return 0; +} + +template int +ACE_Connector::fini (void) +{ + ACE_TRACE ("ACE_Connector::fini"); + + return this->close (); +} + +// Hook called by the explicit dynamic linking facility. + +template int +ACE_Connector::init (int, ACE_TCHAR *[]) +{ + ACE_TRACE ("ACE_Connector::init"); + return -1; +} + +template int +ACE_Connector::suspend (void) +{ + ACE_TRACE ("ACE_Connector::suspend"); + return -1; +} + +template int +ACE_Connector::resume (void) +{ + ACE_TRACE ("ACE_Connector::resume"); + return -1; +} + +template int +ACE_Connector::info (ACE_TCHAR **strp, size_t length) const +{ + ACE_TRACE ("ACE_Connector::info"); + ACE_TCHAR buf[BUFSIZ]; + + ACE_OS::sprintf (buf, + ACE_TEXT ("%s\t %s"), + ACE_TEXT ("ACE_Connector"), + ACE_TEXT ("# connector factory\n")); + + if (*strp == 0 && (*strp = ACE_OS::strdup (buf)) == 0) + return -1; + else + ACE_OS::strsncpy (*strp, buf, length); + return static_cast (ACE_OS::strlen (buf)); +} + +template int +ACE_Strategy_Connector::open (ACE_Reactor *r, + int flags) +{ + ACE_TRACE ("ACE_Strategy_Connector::open"); + return this->open (r, 0, 0, 0, flags); +} + +template int +ACE_Strategy_Connector::open +(ACE_Reactor *r, + ACE_Creation_Strategy *cre_s, + ACE_Connect_Strategy *conn_s, + ACE_Concurrency_Strategy *con_s, + int flags) +{ + ACE_TRACE ("ACE_Strategy_Connector::open"); + + this->reactor (r); + + // @@ Not implemented yet. + // this->flags_ = flags; + ACE_UNUSED_ARG (flags); + + // Initialize the creation strategy. + + // First we decide if we need to clean up. + if (this->creation_strategy_ != 0 && + this->delete_creation_strategy_ && + cre_s != 0) + { + delete this->creation_strategy_; + this->creation_strategy_ = 0; + this->delete_creation_strategy_ = false; + } + + if (cre_s != 0) + this->creation_strategy_ = cre_s; + else if (this->creation_strategy_ == 0) + { + ACE_NEW_RETURN (this->creation_strategy_, + CREATION_STRATEGY, + -1); + this->delete_creation_strategy_ = true; + } + + + // Initialize the accept strategy. + + if (this->connect_strategy_ != 0 && + this->delete_connect_strategy_ && + conn_s != 0) + { + delete this->connect_strategy_; + this->connect_strategy_ = 0; + this->delete_connect_strategy_ = false; + } + + if (conn_s != 0) + this->connect_strategy_ = conn_s; + else if (this->connect_strategy_ == 0) + { + ACE_NEW_RETURN (this->connect_strategy_, + CONNECT_STRATEGY, + -1); + this->delete_connect_strategy_ = true; + } + + // Initialize the concurrency strategy. + + if (this->concurrency_strategy_ != 0 && + this->delete_concurrency_strategy_ && + con_s != 0) + { + delete this->concurrency_strategy_; + this->concurrency_strategy_ = 0; + this->delete_concurrency_strategy_ = false; + } + + if (con_s != 0) + this->concurrency_strategy_ = con_s; + else if (this->concurrency_strategy_ == 0) + { + ACE_NEW_RETURN (this->concurrency_strategy_, + CONCURRENCY_STRATEGY, + -1); + this->delete_concurrency_strategy_ = true; + } + + return 0; +} + +template +ACE_Strategy_Connector::ACE_Strategy_Connector +(ACE_Reactor *reactor, + ACE_Creation_Strategy *cre_s, + ACE_Connect_Strategy *conn_s, + ACE_Concurrency_Strategy *con_s, + int flags) + : creation_strategy_ (0), + delete_creation_strategy_ (false), + connect_strategy_ (0), + delete_connect_strategy_ (false), + concurrency_strategy_ (0), + delete_concurrency_strategy_ (false) +{ + ACE_TRACE ("ACE_Connector::ACE_Strategy_Connector"); + + if (this->open (reactor, cre_s, conn_s, con_s, flags) == -1) + ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("ACE_Strategy_Connector::ACE_Strategy_Connector"))); +} + +template +ACE_Strategy_Connector::~ACE_Strategy_Connector (void) +{ + ACE_TRACE ("ACE_Strategy_Connector::~ACE_Strategy_Connector"); + + // Close down + this->close (); +} + +template int +ACE_Strategy_Connector::close (void) +{ + if (this->delete_creation_strategy_) + delete this->creation_strategy_; + this->delete_creation_strategy_ = false; + this->creation_strategy_ = 0; + + if (this->delete_connect_strategy_) + delete this->connect_strategy_; + this->delete_connect_strategy_ = false; + this->connect_strategy_ = 0; + + if (this->delete_concurrency_strategy_) + delete this->concurrency_strategy_; + this->delete_concurrency_strategy_ = false; + this->concurrency_strategy_ = 0; + + return SUPER::close (); +} + +template int +ACE_Strategy_Connector::make_svc_handler (SVC_HANDLER *&sh) +{ + return this->creation_strategy_->make_svc_handler (sh); +} + +template int +ACE_Strategy_Connector::connect_svc_handler +(SVC_HANDLER *&sh, + const ACE_PEER_CONNECTOR_ADDR &remote_addr, + ACE_Time_Value *timeout, + const ACE_PEER_CONNECTOR_ADDR &local_addr, + int reuse_addr, + int flags, + int perms) +{ + return this->connect_strategy_->connect_svc_handler (sh, + remote_addr, + timeout, + local_addr, + reuse_addr, + flags, + perms); +} + +template int +ACE_Strategy_Connector::connect_svc_handler +(SVC_HANDLER *&sh, + SVC_HANDLER *&sh_copy, + const ACE_PEER_CONNECTOR_ADDR &remote_addr, + ACE_Time_Value *timeout, + const ACE_PEER_CONNECTOR_ADDR &local_addr, + int reuse_addr, + int flags, + int perms) +{ + return this->connect_strategy_->connect_svc_handler (sh, + sh_copy, + remote_addr, + timeout, + local_addr, + reuse_addr, + flags, + perms); +} + +template int +ACE_Strategy_Connector::activate_svc_handler (SVC_HANDLER *svc_handler) +{ + return this->concurrency_strategy_->activate_svc_handler (svc_handler, this); +} + +template ACE_Creation_Strategy * +ACE_Strategy_Connector::creation_strategy (void) const +{ + return this->creation_strategy_; +} + +template ACE_Connect_Strategy * +ACE_Strategy_Connector::connect_strategy (void) const +{ + return this->connect_strategy_; +} + +template ACE_Concurrency_Strategy * +ACE_Strategy_Connector::concurrency_strategy (void) const +{ + return this->concurrency_strategy_; +} + +ACE_END_VERSIONED_NAMESPACE_DECL + +#endif /* ACE_CONNECTOR_C */ diff --git a/dep/ACE_wrappers/ace/Connector.h b/dep/ACE_wrappers/ace/Connector.h new file mode 100644 index 00000000000..b13fc56c131 --- /dev/null +++ b/dep/ACE_wrappers/ace/Connector.h @@ -0,0 +1,563 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Connector.h + * + * $Id: Connector.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Douglas C. Schmidt + */ +//============================================================================= + +#ifndef ACE_CONNECTOR_H +#define ACE_CONNECTOR_H + +#include /**/ "ace/pre.h" + +#include "ace/Service_Object.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/Strategies_T.h" +#include "ace/Synch_Options.h" +#include "ace/Unbounded_Set.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +/** + * @class ACE_Connector_Base + * + * @brief This base interface allows ACE_NonBlocking_Connect_Handler + * to only care about the SVC_HANDLER template parameter of the + * ACE_Connector. Otherwise, ACE_NonBlocking_Connect_Handler would + * have to be configured with all the template parameters that + * ACE_Connector is configured with. + */ +template +class ACE_Connector_Base +{ +public: + + virtual ~ACE_Connector_Base (void) {} + + /// Initialize the Svc_Handler. + virtual void initialize_svc_handler (ACE_HANDLE handle, + SVC_HANDLER *svc_handler) = 0; + + /// Return the handle set representing the non-blocking connects in + /// progress. + virtual ACE_Unbounded_Set &non_blocking_handles (void) = 0; +}; + +/** + * @class ACE_NonBlocking_Connect_Handler + * + * @brief Performs non-blocking connects on behalf of the Connector. + */ +template +class ACE_NonBlocking_Connect_Handler : public ACE_Event_Handler +{ +public: + + /// Constructor. + ACE_NonBlocking_Connect_Handler (ACE_Connector_Base &connector, + SVC_HANDLER *, + long timer_id); + + /// Close up and return underlying SVC_HANDLER through @c sh. + /** + * If the return value is true the close was performed succesfully, + * implying that this object was removed from the reactor and thereby + * (by means of reference counting decremented to 0) deleted. + * If the return value is false, the close was not successful. + * The @c sh does not have any connection to the return + * value. The argument will return a valid svc_handler object if a + * valid one exists within the object. Returning a valid svc_handler + * pointer also invalidates the svc_handler contained in this + * object. + */ + bool close (SVC_HANDLER *&sh); + + /// Get SVC_HANDLER. + SVC_HANDLER *svc_handler (void); + + /// Get handle. + ACE_HANDLE handle (void); + + /// Set handle. + void handle (ACE_HANDLE); + + /// Get timer id. + long timer_id (void); + + /// Set timer id. + void timer_id (long timer_id); + + /// Called by ACE_Reactor when asynchronous connections fail. + virtual int handle_input (ACE_HANDLE); + + /// Called by ACE_Reactor when asynchronous connections succeed. + virtual int handle_output (ACE_HANDLE); + + /// Called by ACE_Reactor when asynchronous connections suceeds (on + /// some platforms only). + virtual int handle_exception (ACE_HANDLE fd); + + /// This method is called if a connection times out before + /// completing. + virtual int handle_timeout (const ACE_Time_Value &tv, const void *arg); + + /// Should Reactor resume us if we have been suspended before the upcall? + virtual int resume_handler (void); + + /// Dump the state of an object. + void dump (void) const; + + /// Declare the dynamic allocation hooks. + ACE_ALLOC_HOOK_DECLARE; + +private: + + /// Connector base. + ACE_Connector_Base &connector_; + + /// Associated SVC_HANDLER. + SVC_HANDLER *svc_handler_; + + /// Associated timer id. + long timer_id_; +}; + +/** + * @class ACE_Connector + * + * @brief Generic factory for actively connecting clients and creating + * service handlers (SVC_HANDLERs). + * + * Implements the strategy for actively establishing connections with + * clients. An ACE_Connector is parameterized by concrete types that + * conform to the interfaces of PEER_CONNECTOR and SVC_HANDLER. The + * PEER_CONNECTOR is instantiated with a transport mechanism that + * actively establishes connections. The SVC_HANDLER is instantiated + * with a concrete type that performs the application-specific + * service. Both blocking and non-blocking connects are supported. + * Further, non-blocking connects support timeouts. + */ +template +class ACE_Connector : public ACE_Connector_Base, public ACE_Service_Object +{ +public: + + // Useful STL-style traits. + typedef typename SVC_HANDLER::addr_type addr_type; + typedef ACE_PEER_CONNECTOR connector_type; + typedef SVC_HANDLER handler_type; + typedef typename SVC_HANDLER::stream_type stream_type; + typedef typename ACE_PEER_CONNECTOR::PEER_ADDR peer_addr_type; + typedef ACE_PEER_CONNECTOR_ADDR ACE_PEER_ADDR_TYPEDEF; + + /** + * Initialize a connector. @a flags indicates how SVC_HANDLER's + * should be initialized prior to being activated. Right now, the + * only flag that is processed is ACE_NONBLOCK, which enabled + * non-blocking I/O on the SVC_HANDLER when it is opened. + */ + ACE_Connector (ACE_Reactor *r = ACE_Reactor::instance (), + int flags = 0); + + /** + * Initialize a connector. @a flags indicates how SVC_HANDLER's + * should be initialized prior to being activated. Right now, the + * only flag that is processed is ACE_NONBLOCK, which enabled + * non-blocking I/O on the SVC_HANDLER when it is opened. + */ + virtual int open (ACE_Reactor *r = ACE_Reactor::instance (), + int flags = 0); + + /// Shutdown a connector and release resources. + virtual ~ACE_Connector (void); + + // = Connection establishment methods. + + /** + * Initiate connection of @a svc_handler to peer at @a remote_addr + * using @a synch_options. If the caller wants to designate the + * selected @a local_addr they can (and can also insist that the + * @a local_addr be reused by passing a value @a reuse_addr == + * 1). @a flags and @a perms can be used to pass any flags that are + * needed to perform specific operations such as opening a file + * within connect with certain permissions. If the connection fails + * the hook on the will be called + * automatically to prevent resource leaks. + */ + virtual int connect (SVC_HANDLER *&svc_handler, + const ACE_PEER_CONNECTOR_ADDR &remote_addr, + const ACE_Synch_Options &synch_options = ACE_Synch_Options::defaults, + const ACE_PEER_CONNECTOR_ADDR &local_addr + = (peer_addr_type &) ACE_PEER_CONNECTOR_ADDR_ANY, + int reuse_addr = 0, + int flags = O_RDWR, + int perms = 0); + + /** + * This is a variation on the previous method. On cached + * connectors the @a svc_handler_hint variable can be used as a hint + * for future lookups. Since this variable is modified in the + * context of the internal cache its use is thread-safe. But the + * actual svc_handler for the current connection is returned in the + * second parameter @a svc_handler. If the connection fails the + * hook on the will be called automatically to + * prevent resource leaks. + */ + virtual int connect (SVC_HANDLER *&svc_handler_hint, + SVC_HANDLER *&svc_handler, + const ACE_PEER_CONNECTOR_ADDR &remote_addr, + const ACE_Synch_Options &synch_options = ACE_Synch_Options::defaults, + const ACE_PEER_CONNECTOR_ADDR &local_addr + = (peer_addr_type &) ACE_PEER_CONNECTOR_ADDR_ANY, + int reuse_addr = 0, + int flags = O_RDWR, + int perms = 0); + + /** + * Initiate connection of @a n @a svc_handlers to peers at + * @a remote_addrs using @a synch_options. Returns -1 if failure + * occurs and 0 otherwise. If @a failed_svc_handlers is non-NULL, a + * 1 is placed in the corresponding index of @a failed_svc_handlers + * for each that failed to connect, else a 0 is + * placed in that index. + */ + virtual int connect_n (size_t n, + SVC_HANDLER *svc_handlers[], + ACE_PEER_CONNECTOR_ADDR remote_addrs[], + ACE_TCHAR *failed_svc_handlers = 0, + const ACE_Synch_Options &synch_options = + ACE_Synch_Options::defaults); + + /** + * Cancel the @a svc_handler that was started asynchronously. Note that + * this is the only case when the Connector does not actively close + * the @a svc_handler. It is left up to the caller of to + * decide the fate of the @a svc_handler. + */ + virtual int cancel (SVC_HANDLER *svc_handler); + + /// Close down the Connector. All pending non-blocking connects are + /// canceled and the corresponding svc_handler is closed. + virtual int close (void); + + /// Return the underlying PEER_CONNECTOR object. + virtual ACE_PEER_CONNECTOR &connector (void) const; + + /// Initialize Svc_Handler. + virtual void initialize_svc_handler (ACE_HANDLE handle, + SVC_HANDLER *svc_handler); + + /// Set Reactor. + virtual void reactor (ACE_Reactor *reactor); + + /// Get Reactor. + virtual ACE_Reactor *reactor (void) const; + + /// Dump the state of an object. + void dump (void) const; + + /// Declare the dynamic allocation hooks. + ACE_ALLOC_HOOK_DECLARE; + +protected: + // = Helpful typedefs. + typedef ACE_NonBlocking_Connect_Handler NBCH; + + // = The following two methods define the Connector's strategies for + // creating, connecting, and activating SVC_HANDLER's, respectively. + + /** + * Bridge method for creating a SVC_HANDLER. The default is to + * create a new SVC_HANDLER only if @a sh == 0, else @a sh is + * unchanged. However, subclasses can override this policy to + * perform SVC_HANDLER creation in any way that they like (such as + * creating subclass instances of SVC_HANDLER, using a singleton, + * dynamically linking the handler, etc.). Returns -1 if failure, + * else 0. + */ + virtual int make_svc_handler (SVC_HANDLER *&sh); + + /** + * Bridge method for connecting the @a svc_handler to the + * @a remote_addr. The default behavior delegates to the + * . + */ + virtual int connect_svc_handler (SVC_HANDLER *&svc_handler, + const ACE_PEER_CONNECTOR_ADDR &remote_addr, + ACE_Time_Value *timeout, + const ACE_PEER_CONNECTOR_ADDR &local_addr, + int reuse_addr, + int flags, + int perms); + virtual int connect_svc_handler (SVC_HANDLER *&svc_handler, + SVC_HANDLER *&sh_copy, + const ACE_PEER_CONNECTOR_ADDR &remote_addr, + ACE_Time_Value *timeout, + const ACE_PEER_CONNECTOR_ADDR &local_addr, + int reuse_addr, + int flags, + int perms); + + /** + * Bridge method for activating a @a svc_handler with the appropriate + * concurrency strategy. The default behavior of this method is to + * activate the SVC_HANDLER by calling its method (which + * allows the SVC_HANDLER to define its own concurrency strategy). + * However, subclasses can override this strategy to do more + * sophisticated concurrency activations (such as creating the + * SVC_HANDLER as an "active object" via multi-threading or + * multi-processing). + */ + virtual int activate_svc_handler (SVC_HANDLER *svc_handler); + + /// Creates and registers ACE_NonBlocking_Connect_Handler. + int nonblocking_connect (SVC_HANDLER *, + const ACE_Synch_Options &); + + /// Implementation of the connect methods. + virtual int connect_i (SVC_HANDLER *&svc_handler, + SVC_HANDLER **sh_copy, + const ACE_PEER_CONNECTOR_ADDR &remote_addr, + const ACE_Synch_Options &synch_options, + const ACE_PEER_CONNECTOR_ADDR &local_addr, + int reuse_addr, + int flags, + int perms); + + /// Return the handle set representing the non-blocking connects in + /// progress. + ACE_Unbounded_Set &non_blocking_handles (void); + + // = Dynamic linking hooks. + /// Default version does no work and returns -1. Must be overloaded + /// by application developer to do anything meaningful. + virtual int init (int argc, ACE_TCHAR *argv[]); + + /// Calls handle_close() to shutdown the Connector gracefully. + virtual int fini (void); + + /// Default version returns address info in @a buf. + virtual int info (ACE_TCHAR **strp, size_t length) const; + + // = Service management hooks. + /// Default version does no work and returns -1. Must be overloaded + /// by application developer to do anything meaningful. + virtual int suspend (void); + + /// Default version does no work and returns -1. Must be overloaded + /// by application developer to do anything meaningful. + virtual int resume (void); + +private: + /// This is the peer connector factory. + ACE_PEER_CONNECTOR connector_; + + /** + * Flags that indicate how SVC_HANDLER's should be initialized + * prior to being activated. Right now, the only flag that is + * processed is ACE_NONBLOCK, which enabled non-blocking I/O on + * the SVC_HANDLER when it is opened. + */ + int flags_; + + /// Pointer to the Reactor. + ACE_Reactor *reactor_; + + /// Handle set representing the non-blocking connects in progress. + ACE_Unbounded_Set non_blocking_handles_; + +}; + +/** + * @class ACE_Strategy_Connector + * + * @brief Abstract factory for creating a service handler + * (SVC_HANDLER), connecting the SVC_HANDLER, and activating the + * SVC_HANDLER. + * + * Implements a flexible and extensible set of strategies for + * actively establishing connections with clients. There are + * three main strategies: (1) creating a SVC_HANDLER, (2) + * actively initiating a new connection from the client, + * and (3) activating the SVC_HANDLER with a + * particular concurrency mechanism after the connection is established. + */ +template +class ACE_Strategy_Connector + : public ACE_Connector +{ +public: + + // Useful STL-style traits. + typedef ACE_Creation_Strategy + creation_strategy_type; + typedef ACE_Connect_Strategy + connect_strategy_type; + typedef ACE_Concurrency_Strategy + concurrency_strategy_type; + typedef ACE_Connector + base_type; + + // = Define some useful (old style) traits. + typedef ACE_Creation_Strategy + CREATION_STRATEGY; + typedef ACE_Connect_Strategy + CONNECT_STRATEGY; + typedef ACE_Concurrency_Strategy + CONCURRENCY_STRATEGY; + typedef ACE_Connector + SUPER; + + /** + * Initialize a connector. @a flags indicates how 's + * should be initialized prior to being activated. Right now, the + * only flag that is processed is ACE_NONBLOCK, which enabled + * non-blocking I/O on the SVC_HANDLER when it is opened. + */ + ACE_Strategy_Connector (ACE_Reactor *r = ACE_Reactor::instance (), + ACE_Creation_Strategy * = 0, + ACE_Connect_Strategy * = 0, + ACE_Concurrency_Strategy * = 0, + int flags = 0); + + /** + * Initialize a connector. @a flags indicates how SVC_HANDLER's + * should be initialized prior to being activated. Right now, the + * only flag that is processed is ACE_NONBLOCK, which enabled + * non-blocking I/O on the SVC_HANDLER when it is opened. + * Default strategies would be created and used. + */ + virtual int open (ACE_Reactor *r, + int flags); + + /** + * Initialize a connector. @a flags indicates how SVC_HANDLER's + * should be initialized prior to being activated. Right now, the + * only flag that is processed is ACE_NONBLOCK, which enabled + * non-blocking I/O on the SVC_HANDLER when it is opened. + */ + virtual int open (ACE_Reactor *r = ACE_Reactor::instance (), + ACE_Creation_Strategy * = 0, + ACE_Connect_Strategy * = 0, + ACE_Concurrency_Strategy * = 0, + int flags = 0); + + /// Shutdown a connector and release resources. + virtual ~ACE_Strategy_Connector (void); + + /// Close down the Connector + virtual int close (void); + + // = Strategies accessors + virtual ACE_Creation_Strategy *creation_strategy (void) const; + virtual ACE_Connect_Strategy *connect_strategy (void) const; + virtual ACE_Concurrency_Strategy *concurrency_strategy (void) const; + +protected: + // = The following three methods define the 's strategies + // for creating, connecting, and activating SVC_HANDLER's, + // respectively. + + /** + * Bridge method for creating a SVC_HANDLER. The strategy for + * creating a SVC_HANDLER are configured into the Connector via + * it's . The default is to create a new + * SVC_HANDLER only if @a sh == 0, else @a sh is unchanged. + * However, subclasses can override this policy to perform + * SVC_HANDLER creation in any way that they like (such as + * creating subclass instances of SVC_HANDLER, using a singleton, + * dynamically linking the handler, etc.). Returns -1 if failure, + * else 0. + */ + virtual int make_svc_handler (SVC_HANDLER *&sh); + + /** + * Bridge method for connecting the new connection into the + * SVC_HANDLER. The default behavior delegates to the + * in the . + */ + virtual int connect_svc_handler (SVC_HANDLER *&sh, + const ACE_PEER_CONNECTOR_ADDR &remote_addr, + ACE_Time_Value *timeout, + const ACE_PEER_CONNECTOR_ADDR &local_addr, + int reuse_addr, + int flags, + int perms); + + /** + * Bridge method for connecting the new connection into the + * SVC_HANDLER. The default behavior delegates to the + * in the . + * @a sh_copy is used to obtain a copy of the @a sh pointer, but that + * can be kept in the stack; the motivation is a bit too long to + * include here, but basically we want to modify @a sh safely, using + * the internal locks in the Connect_Strategy, while saving a TSS + * copy in @a sh_copy, usually located in the stack. + */ + virtual int connect_svc_handler (SVC_HANDLER *&sh, + SVC_HANDLER *&sh_copy, + const ACE_PEER_CONNECTOR_ADDR &remote_addr, + ACE_Time_Value *timeout, + const ACE_PEER_CONNECTOR_ADDR &local_addr, + int reuse_addr, + int flags, + int perms); + + /** + * Bridge method for activating a SVC_HANDLER with the appropriate + * concurrency strategy. The default behavior of this method is to + * activate the SVC_HANDLER by calling its method (which + * allows the SVC_HANDLER to define its own concurrency strategy). + * However, subclasses can override this strategy to do more + * sophisticated concurrency activations (such as creating the + * SVC_HANDLER as an "active object" via multi-threading or + * multi-processing). + */ + virtual int activate_svc_handler (SVC_HANDLER *svc_handler); + + // = Strategy objects. + + /// Creation strategy for an Connector. + CREATION_STRATEGY *creation_strategy_; + + /// true if Connector created the creation strategy and thus should + /// delete it, else false. + bool delete_creation_strategy_; + + /// Connect strategy for a Connector. + CONNECT_STRATEGY *connect_strategy_; + + /// true if Connector created the connect strategy and thus should + /// delete it, else false. + bool delete_connect_strategy_; + + /// Concurrency strategy for an . + CONCURRENCY_STRATEGY *concurrency_strategy_; + + /// true if Connector created the concurrency strategy and thus should + /// delete it, else false. + bool delete_concurrency_strategy_; +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) +#include "ace/Connector.cpp" +#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ + +#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) +#pragma implementation ("Connector.cpp") +#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ + +#include /**/ "ace/post.h" + +#endif /* ACE_CONNECTOR_H */ diff --git a/dep/ACE_wrappers/ace/Containers.cpp b/dep/ACE_wrappers/ace/Containers.cpp new file mode 100644 index 00000000000..244a9ad4b1b --- /dev/null +++ b/dep/ACE_wrappers/ace/Containers.cpp @@ -0,0 +1,12 @@ +// $Id: Containers.cpp 80826 2008-03-04 14:51:23Z wotte $ + +#include "ace/Containers.h" + +ACE_RCSID (ace, + Containers, + "$Id: Containers.cpp 80826 2008-03-04 14:51:23Z wotte $") + +#if !defined (__ACE_INLINE__) +#include "ace/Containers.inl" +#endif /* __ACE_INLINE__ */ + diff --git a/dep/ACE_wrappers/ace/Containers.h b/dep/ACE_wrappers/ace/Containers.h new file mode 100644 index 00000000000..ecff8e368e4 --- /dev/null +++ b/dep/ACE_wrappers/ace/Containers.h @@ -0,0 +1,71 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Containers.h + * + * $Id: Containers.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Douglas C. Schmidt + */ +//============================================================================= + +#ifndef ACE_CONTAINERS_H +#define ACE_CONTAINERS_H + +#include /**/ "ace/pre.h" + +#include /**/ "ace/ACE_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +template class ACE_Double_Linked_List; +template class ACE_Double_Linked_List_Iterator_Base; +template class ACE_Double_Linked_List_Iterator; +template class ACE_Double_Linked_List_Reverse_Iterator; + +/** + * @class ACE_DLList_Node + * + * @brief Base implementation of element in a DL list. Needed for + * ACE_Double_Linked_List. + */ +class ACE_Export ACE_DLList_Node +{ +public: + friend class ACE_Double_Linked_List; + friend class ACE_Double_Linked_List_Iterator_Base; + friend class ACE_Double_Linked_List_Iterator; + friend class ACE_Double_Linked_List_Reverse_Iterator; + + ACE_DLList_Node (void *i, + ACE_DLList_Node *n = 0, + ACE_DLList_Node *p = 0); + + /// Declare the dynamic allocation hooks. + ACE_ALLOC_HOOK_DECLARE; + + void *item_; + + ACE_DLList_Node *next_; + ACE_DLList_Node *prev_; + +protected: + ACE_DLList_Node (void); +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +#include "ace/Containers.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/Containers_T.h" + +#include /**/ "ace/post.h" + +#endif /* ACE_CONTAINERS_H */ diff --git a/dep/ACE_wrappers/ace/Containers.inl b/dep/ACE_wrappers/ace/Containers.inl new file mode 100644 index 00000000000..8094672a8f6 --- /dev/null +++ b/dep/ACE_wrappers/ace/Containers.inl @@ -0,0 +1,25 @@ +// -*- C++ -*- +// +// $Id: Containers.inl 80826 2008-03-04 14:51:23Z wotte $ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_INLINE +ACE_DLList_Node::ACE_DLList_Node (void) + : item_ (0), + next_ (0), + prev_ (0) +{ +} + +ACE_INLINE +ACE_DLList_Node::ACE_DLList_Node (void *i, + ACE_DLList_Node *n, + ACE_DLList_Node *p) + : item_ (i), + next_ (n), + prev_ (p) +{ +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Containers_T.cpp b/dep/ACE_wrappers/ace/Containers_T.cpp new file mode 100644 index 00000000000..f4b6bd8a7f0 --- /dev/null +++ b/dep/ACE_wrappers/ace/Containers_T.cpp @@ -0,0 +1,1932 @@ +// $Id: Containers_T.cpp 82588 2008-08-11 13:37:41Z johnnyw $ + +#ifndef ACE_CONTAINERS_T_CPP +#define ACE_CONTAINERS_T_CPP + +#include "ace/Log_Msg.h" +#include "ace/Malloc_Base.h" +#include "ace/OS_Memory.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/Containers.h" + +#if !defined (__ACE_INLINE__) +#include "ace/Containers_T.inl" +#endif /* __ACE_INLINE__ */ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_ALLOC_HOOK_DEFINE(ACE_Bounded_Stack) + +template void +ACE_Bounded_Stack::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + ACE_TRACE ("ACE_Bounded_Stack::dump"); +#endif /* ACE_HAS_DUMP */ +} + +template +ACE_Bounded_Stack::ACE_Bounded_Stack (size_t size) + : size_ (size), + top_ (0) +{ + ACE_NEW (this->stack_, + T[size]); + ACE_TRACE ("ACE_Bounded_Stack::ACE_Bounded_Stack"); +} + +template +ACE_Bounded_Stack::ACE_Bounded_Stack (const ACE_Bounded_Stack &s) + : size_ (s.size_), + top_ (s.top_) +{ + ACE_NEW (this->stack_, + T[s.size_]); + + ACE_TRACE ("ACE_Bounded_Stack::ACE_Bounded_Stack"); + + for (size_t i = 0; i < this->top_; i++) + this->stack_[i] = s.stack_[i]; +} + +template void +ACE_Bounded_Stack::operator= (const ACE_Bounded_Stack &s) +{ + ACE_TRACE ("ACE_Bounded_Stack::operator="); + + if (&s != this) + { + if (this->size_ < s.size_) + { + delete [] this->stack_; + ACE_NEW (this->stack_, + T[s.size_]); + this->size_ = s.size_; + } + this->top_ = s.top_; + + for (size_t i = 0; i < this->top_; i++) + this->stack_[i] = s.stack_[i]; + } +} + +template +ACE_Bounded_Stack::~ACE_Bounded_Stack (void) +{ + ACE_TRACE ("ACE_Bounded_Stack::~ACE_Bounded_Stack"); + delete [] this->stack_; +} + +// ---------------------------------------- + +ACE_ALLOC_HOOK_DEFINE(ACE_Fixed_Stack) + +template void +ACE_Fixed_Stack::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + ACE_TRACE ("ACE_Fixed_Stack::dump"); +#endif /* ACE_HAS_DUMP */ +} + +template +ACE_Fixed_Stack::ACE_Fixed_Stack (void) + : size_ (ACE_SIZE), + top_ (0) +{ + ACE_TRACE ("ACE_Fixed_Stack::ACE_Fixed_Stack"); +} + +template +ACE_Fixed_Stack::ACE_Fixed_Stack (const ACE_Fixed_Stack &s) + : size_ (s.size_), + top_ (s.top_) +{ + ACE_TRACE ("ACE_Fixed_Stack::ACE_Fixed_Stack"); + for (size_t i = 0; i < this->top_; i++) + this->stack_[i] = s.stack_[i]; +} + +template void +ACE_Fixed_Stack::operator= (const ACE_Fixed_Stack &s) +{ + ACE_TRACE ("ACE_Fixed_Stack::operator="); + + if (&s != this) + { + this->top_ = s.top_; + + for (size_t i = 0; i < this->top_; i++) + this->stack_[i] = s.stack_[i]; + } +} + +template +ACE_Fixed_Stack::~ACE_Fixed_Stack (void) +{ + ACE_TRACE ("ACE_Fixed_Stack::~ACE_Fixed_Stack"); +} + +//---------------------------------------- + +ACE_ALLOC_HOOK_DEFINE(ACE_Unbounded_Stack) + +template void +ACE_Unbounded_Stack::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + // ACE_TRACE ("ACE_Unbounded_Stack::dump"); +#endif /* ACE_HAS_DUMP */ +} + +template +ACE_Unbounded_Stack::ACE_Unbounded_Stack (ACE_Allocator *alloc) + : head_ (0), + cur_size_ (0), + allocator_ (alloc) +{ + // ACE_TRACE ("ACE_Unbounded_Stack::ACE_Unbounded_Stack"); + if (this->allocator_ == 0) + this->allocator_ = ACE_Allocator::instance (); + + ACE_NEW_MALLOC (this->head_, + (ACE_Node *) this->allocator_->malloc (sizeof (ACE_Node)), + ACE_Node); + this->head_->next_ = this->head_; +} + +template void +ACE_Unbounded_Stack::delete_all_nodes (void) +{ + // ACE_TRACE ("ACE_Unbounded_Stack::delete_all_nodes"); + + while (this->is_empty () == 0) + { + ACE_Node *temp = this->head_->next_; + this->head_->next_ = temp->next_; + ACE_DES_FREE_TEMPLATE (temp, this->allocator_->free, + ACE_Node, ); + } + + this->cur_size_ = 0; + + ACE_ASSERT (this->head_ == this->head_->next_ + && this->is_empty ()); +} + +template void +ACE_Unbounded_Stack::copy_all_nodes (const ACE_Unbounded_Stack &s) +{ + // ACE_TRACE ("ACE_Unbounded_Stack::copy_all_nodes"); + + ACE_ASSERT (this->head_ == this->head_->next_); + + ACE_Node *temp = this->head_; + + for (ACE_Node *s_temp = s.head_->next_; + s_temp != s.head_; + s_temp = s_temp->next_) + { + ACE_Node *nptr = temp->next_; + ACE_NEW_MALLOC (temp->next_, + (ACE_Node *) this->allocator_->malloc (sizeof (ACE_Node)), + ACE_Node (s_temp->item_, nptr)); + temp = temp->next_; + } + this->cur_size_ = s.cur_size_; +} + +template +ACE_Unbounded_Stack::ACE_Unbounded_Stack (const ACE_Unbounded_Stack &s) + : head_ (0), + cur_size_ (0), + allocator_ (s.allocator_) +{ + if (this->allocator_ == 0) + this->allocator_ = ACE_Allocator::instance (); + + ACE_NEW_MALLOC (this->head_, + (ACE_Node *) this->allocator_->malloc (sizeof (ACE_Node)), + ACE_Node); + this->head_->next_ = this->head_; + + // ACE_TRACE ("ACE_Unbounded_Stack::ACE_Unbounded_Stack"); + this->copy_all_nodes (s); +} + +template void +ACE_Unbounded_Stack::operator= (const ACE_Unbounded_Stack &s) +{ + // ACE_TRACE ("ACE_Unbounded_Stack::operator="); + + if (this != &s) + { + this->delete_all_nodes (); + this->copy_all_nodes (s); + } +} + +template +ACE_Unbounded_Stack::~ACE_Unbounded_Stack (void) +{ + // ACE_TRACE ("ACE_Unbounded_Stack::~ACE_Unbounded_Stack"); + + this->delete_all_nodes (); + ACE_DES_FREE_TEMPLATE (head_, + this->allocator_->free, + ACE_Node, + ); +} + +template int +ACE_Unbounded_Stack::push (const T &new_item) +{ + // ACE_TRACE ("ACE_Unbounded_Stack::push"); + + ACE_Node *temp = 0; + + ACE_NEW_MALLOC_RETURN (temp, + static_cast *> (this->allocator_->malloc (sizeof (ACE_Node))), + ACE_Node (new_item, this->head_->next_), + -1); + this->head_->next_ = temp; + ++this->cur_size_; + return 0; +} + +template int +ACE_Unbounded_Stack::pop (T &item) +{ + // ACE_TRACE ("ACE_Unbounded_Stack::pop"); + + if (this->is_empty ()) + return -1; + else + { + ACE_Node *temp = this->head_->next_; + item = temp->item_; + this->head_->next_ = temp->next_; + + ACE_DES_FREE_TEMPLATE (temp, + this->allocator_->free, + ACE_Node, + ); + --this->cur_size_; + return 0; + } +} + +template int +ACE_Unbounded_Stack::find (const T &item) const +{ + // ACE_TRACE ("ACE_Unbounded_Stack::find"); + // Set into the dummy node. + this->head_->item_ = item; + + ACE_Node *temp = this->head_->next_; + + // Keep looping until we find the item. + while (!(temp->item_ == item)) + temp = temp->next_; + + // If we found the dummy node then it's not really there, otherwise, + // it is there. + return temp == this->head_ ? -1 : 0; +} + +template int +ACE_Unbounded_Stack::insert (const T &item) +{ + // ACE_TRACE ("ACE_Unbounded_Stack::insert"); + + if (this->find (item) == 0) + return 1; + else + return this->push (item); +} + +template int +ACE_Unbounded_Stack::remove (const T &item) +{ + // ACE_TRACE ("ACE_Unbounded_Stack::remove"); + + // Insert the item to be founded into the dummy node. + this->head_->item_ = item; + + ACE_Node *curr = this->head_; + + while (!(curr->next_->item_ == item)) + curr = curr->next_; + + if (curr->next_ == this->head_) + return -1; // Item was not found. + else + { + ACE_Node *temp = curr->next_; + // Skip over the node that we're deleting. + curr->next_ = temp->next_; + --this->cur_size_; + ACE_DES_FREE_TEMPLATE (temp, + this->allocator_->free, + ACE_Node, + ); + return 0; + } +} + +//-------------------------------------------------- +ACE_ALLOC_HOOK_DEFINE(ACE_Double_Linked_List_Iterator_Base) + +template +ACE_Double_Linked_List_Iterator_Base::ACE_Double_Linked_List_Iterator_Base (const ACE_Double_Linked_List &dll) + : current_ (0), dllist_ (&dll) +{ + // Do nothing +} + +template +ACE_Double_Linked_List_Iterator_Base::ACE_Double_Linked_List_Iterator_Base (const ACE_Double_Linked_List_Iterator_Base &iter) + : current_ (iter.current_), + dllist_ (iter.dllist_) +{ + // Do nothing +} + + +template T * +ACE_Double_Linked_List_Iterator_Base::next (void) const +{ + return this->not_done (); +} + +template int +ACE_Double_Linked_List_Iterator_Base::next (T *&ptr) const +{ + ptr = this->not_done (); + return ptr ? 1 : 0; +} + + +template int +ACE_Double_Linked_List_Iterator_Base::done (void) const +{ + return this->not_done () ? 0 : 1; +} + +template T & +ACE_Double_Linked_List_Iterator_Base::operator* (void) const +{ + return *(this->not_done ()); +} + +// @@ Is this a valid retasking? Make sure to check with Purify and +// whatnot that we're not leaking memory or doing any other screwing things. +template void +ACE_Double_Linked_List_Iterator_Base::reset (ACE_Double_Linked_List &dll) +{ + current_ = 0; + dllist_ = &dll; +} + + template int +ACE_Double_Linked_List_Iterator_Base::go_head (void) +{ + this->current_ = static_cast (dllist_->head_->next_); + return this->current_ ? 1 : 0; +} + +template int +ACE_Double_Linked_List_Iterator_Base::go_tail (void) +{ + this->current_ = static_cast (dllist_->head_->prev_); + return this->current_ ? 1 : 0; +} + +template T * +ACE_Double_Linked_List_Iterator_Base::not_done (void) const +{ + if (this->current_ != this->dllist_->head_) + return this->current_; + else + return 0; +} + +template T * +ACE_Double_Linked_List_Iterator_Base::do_advance (void) +{ + if (this->not_done ()) + { + this->current_ = static_cast (this->current_->next_); + return this->not_done (); + } + else + return 0; +} + +template T * +ACE_Double_Linked_List_Iterator_Base::do_retreat (void) +{ + if (this->not_done ()) + { + this->current_ = static_cast (this->current_->prev_); + return this->not_done (); + } + else + return 0; +} + +template void +ACE_Double_Linked_List_Iterator_Base::dump_i (void) const +{ + ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("current_ = %x"), this->current_)); + ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); +} + +//-------------------------------------------------- +ACE_ALLOC_HOOK_DEFINE(ACE_Double_Linked_List_Iterator) + +template +ACE_Double_Linked_List_Iterator::ACE_Double_Linked_List_Iterator (const ACE_Double_Linked_List &dll) + : ACE_Double_Linked_List_Iterator_Base (dll) +{ + this->current_ = static_cast (dll.head_->next_); + // Advance current_ out of the null area and onto the first item in + // the list +} + +template void +ACE_Double_Linked_List_Iterator::reset (ACE_Double_Linked_List &dll) +{ + this->ACE_Double_Linked_List_Iterator_Base ::reset (dll); + this->current_ = static_cast (dll.head_->next_); + // Advance current_ out of the null area and onto the first item in + // the list +} + +template int +ACE_Double_Linked_List_Iterator::first (void) +{ + return this->go_head (); +} + +template int +ACE_Double_Linked_List_Iterator::advance (void) +{ + return this->do_advance () ? 1 : 0; +} + +template T* +ACE_Double_Linked_List_Iterator::advance_and_remove (bool dont_remove) +{ + T* item = 0; + if (dont_remove) + this->do_advance (); + else + { + item = this->next (); + this->do_advance (); + // It seems dangerous to remove nodes in an iterator, but so it goes... + ACE_Double_Linked_List *dllist = + const_cast *> (this->dllist_); + dllist->remove (item); + } + return item; +} + +template void +ACE_Double_Linked_List_Iterator::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + this->dump_i (); +#endif /* ACE_HAS_DUMP */ +} + +// Prefix advance. + +template +ACE_Double_Linked_List_Iterator & +ACE_Double_Linked_List_Iterator::operator++ (void) +{ + this->do_advance (); + return *this; +} + + +// Postfix advance. + +template +ACE_Double_Linked_List_Iterator +ACE_Double_Linked_List_Iterator::operator++ (int) +{ + ACE_Double_Linked_List_Iterator retv (*this); + this->do_advance (); + return retv; +} + + +// Prefix reverse. + +template +ACE_Double_Linked_List_Iterator & +ACE_Double_Linked_List_Iterator::operator-- (void) +{ + this->do_retreat (); + return *this; +} + + +// Postfix reverse. + +template +ACE_Double_Linked_List_Iterator +ACE_Double_Linked_List_Iterator::operator-- (int) +{ + ACE_Double_Linked_List_Iterator retv (*this); + this->do_retreat (); + return retv; +} + + +//-------------------------------------------------- +ACE_ALLOC_HOOK_DEFINE(ACE_Double_Linked_List_Reverse_Iterator) + + template +ACE_Double_Linked_List_Reverse_Iterator::ACE_Double_Linked_List_Reverse_Iterator (ACE_Double_Linked_List &dll) + : ACE_Double_Linked_List_Iterator_Base (dll) +{ + this->current_ = static_cast (dll.head_->prev_); + // Advance current_ out of the null area and onto the last item in + // the list +} + +template void +ACE_Double_Linked_List_Reverse_Iterator::reset (ACE_Double_Linked_List &dll) +{ + this->ACE_Double_Linked_List_Iterator_Base ::reset (dll); + this->current_ = static_cast (dll.head_->prev_); + // Advance current_ out of the null area and onto the last item in + // the list +} + +template int +ACE_Double_Linked_List_Reverse_Iterator::first (void) +{ + return this->go_tail (); +} + +template int +ACE_Double_Linked_List_Reverse_Iterator::advance (void) +{ + return this->do_retreat () ? 1 : 0; +} + +template T* +ACE_Double_Linked_List_Reverse_Iterator::advance_and_remove (bool dont_remove) +{ + T* item = 0; + if (dont_remove) + { + this->do_retreat (); + } + else + { + item = this->next (); + this->do_retreat (); + // It seems dangerous to remove nodes in an iterator, but so it goes... + ACE_Double_Linked_List *dllist = + const_cast *> (this->dllist_); + dllist->remove (item); + } + return item; +} + +template void +ACE_Double_Linked_List_Reverse_Iterator::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + this->dump_i (); +#endif /* ACE_HAS_DUMP */ +} + +// Prefix advance. + +template +ACE_Double_Linked_List_Reverse_Iterator & +ACE_Double_Linked_List_Reverse_Iterator::operator++ (void) +{ + this->do_retreat (); + return *this; +} + + +// Postfix advance. + +template +ACE_Double_Linked_List_Reverse_Iterator +ACE_Double_Linked_List_Reverse_Iterator::operator++ (int) +{ + ACE_Double_Linked_List_Reverse_Iterator retv (*this); + this->do_retreat (); + return retv; +} + + +// Prefix reverse. + +template +ACE_Double_Linked_List_Reverse_Iterator & +ACE_Double_Linked_List_Reverse_Iterator::operator-- (void) +{ + this->do_advance (); + return *this; +} + + +// Postfix reverse. + +template +ACE_Double_Linked_List_Reverse_Iterator +ACE_Double_Linked_List_Reverse_Iterator::operator-- (int) +{ + ACE_Double_Linked_List_Reverse_Iterator retv (*this); + this->do_advance (); + return retv; +} + + +ACE_ALLOC_HOOK_DEFINE(ACE_Double_Linked_List) + + template +ACE_Double_Linked_List:: ACE_Double_Linked_List (ACE_Allocator *alloc) + : size_ (0), allocator_ (alloc) +{ + if (this->allocator_ == 0) + this->allocator_ = ACE_Allocator::instance (); + + ACE_NEW_MALLOC (this->head_, + (T *) this->allocator_->malloc (sizeof (T)), + T); + this->init_head (); +} + +template +ACE_Double_Linked_List::ACE_Double_Linked_List (const ACE_Double_Linked_List &cx) + : allocator_ (cx.allocator_) +{ + if (this->allocator_ == 0) + this->allocator_ = ACE_Allocator::instance (); + + ACE_NEW_MALLOC (this->head_, + (T *) this->allocator_->malloc (sizeof (T)), + T); + this->init_head (); + this->copy_nodes (cx); + this->size_ = cx.size_; +} + +template void +ACE_Double_Linked_List::operator= (const ACE_Double_Linked_List &cx) +{ + if (this != &cx) + { + this->delete_nodes (); + this->copy_nodes (cx); + } +} + +template +ACE_Double_Linked_List::~ACE_Double_Linked_List (void) +{ + this->delete_nodes (); + + ACE_DES_FREE (head_, + this->allocator_->free, + T); + + this->head_ = 0; +} + +template int +ACE_Double_Linked_List::is_empty (void) const +{ + return this->size () ? 0 : 1; +} + +template int +ACE_Double_Linked_List::is_full (void) const +{ + return 0; // We have no bound. +} + +template T * +ACE_Double_Linked_List::insert_tail (T *new_item) +{ + // Insert it before , i.e., at tail. + this->insert_element (new_item, 1); + return new_item; +} + +template T * +ACE_Double_Linked_List::insert_head (T *new_item) +{ + this->insert_element (new_item); // Insert it after , i.e., at head. + return new_item; +} + +template T * +ACE_Double_Linked_List::delete_head (void) +{ + if (this->is_empty ()) + return 0; + + T *temp = static_cast (this->head_->next_); + // Detach it from the list. + this->remove_element (temp); + return temp; +} + +template T * +ACE_Double_Linked_List::delete_tail (void) +{ + if (this->is_empty ()) + return 0; + + T *temp = static_cast (this->head_->prev_); + // Detach it from the list. + this->remove_element (temp); + return temp; +} + +template void +ACE_Double_Linked_List::reset (void) +{ + this->delete_nodes (); +} + +template int +ACE_Double_Linked_List::get (T *&item, size_t slot) +{ + ACE_Double_Linked_List_Iterator iter (*this); + + for (size_t i = 0; + i < slot && !iter.done (); + i++) + iter.advance (); + + item = iter.next (); + return item ? 0 : -1; +} + +template size_t +ACE_Double_Linked_List::size (void) const +{ + return this->size_; +} + +template void +ACE_Double_Linked_List::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + // Dump the state of an object. +#endif /* ACE_HAS_DUMP */ +} + +#if 0 +template T * +ACE_Double_Linked_List::find (const T &item) +{ + for (ACE_Double_Linked_List_Iterator iter (*this); + !iter.done (); + iter.advance ()) + { + T *temp = iter.next (); + + if (*temp == item) + return temp; + } + + return 0; +} + +template int +ACE_Double_Linked_List::remove (const T &item) +{ + T *temp = this->find (item); + + if (temp != 0) + return this->remove (temp); + else + return -1; +} +#endif /* 0 */ + +template int +ACE_Double_Linked_List::remove (T *n) +{ + return this->remove_element (n); +} + +template void +ACE_Double_Linked_List::delete_nodes (void) +{ + while (! this->is_empty ()) + { + T * temp = static_cast (this->head_->next_); + this->remove_element (temp); + ACE_DES_FREE (temp, + this->allocator_->free, + T); + } +} + +template void +ACE_Double_Linked_List::copy_nodes (const ACE_Double_Linked_List &c) +{ + for (ACE_Double_Linked_List_Iterator iter (c); + !iter.done (); + iter.advance ()) + { + T* temp = 0; + ACE_NEW_MALLOC (temp, + (T *)this->allocator_->malloc (sizeof (T)), + T (*iter.next ())); + this->insert_tail (temp); + } +} + +template void +ACE_Double_Linked_List::init_head (void) +{ + this->head_->next_ = this->head_; + this->head_->prev_ = this->head_; +} + +template int +ACE_Double_Linked_List::insert_element (T *new_item, + int before, + T *old_item) +{ + if (old_item == 0) + old_item = this->head_; + + if (before) + old_item = static_cast (old_item->prev_); + + new_item->next_ = old_item->next_; + new_item->next_->prev_ = new_item; + new_item->prev_ = old_item; + old_item->next_ = new_item; + ++this->size_; + return 0; // Well, what will cause errors here? +} + +template int +ACE_Double_Linked_List::remove_element (T *item) +{ + // Notice that you have to ensure that item is an element of this + // list. We can't do much checking here. + + if (item == this->head_ || item->next_ == 0 + || item->prev_ == 0 || this->size () == 0) // Can't remove head + return -1; + + item->prev_->next_ = item->next_; + item->next_->prev_ = item->prev_; + item->next_ = item->prev_ = 0; // reset pointers to prevent double removal. + --this->size_; + return 0; +} + +//-------------------------------------------------- +ACE_ALLOC_HOOK_DEFINE(ACE_Fixed_Set) + +template size_t +ACE_Fixed_Set::size (void) const +{ + ACE_TRACE ("ACE_Fixed_Set::size"); + return this->cur_size_; +} + +template void +ACE_Fixed_Set::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + ACE_TRACE ("ACE_Fixed_Set::dump"); +#endif /* ACE_HAS_DUMP */ +} + +template +ACE_Fixed_Set::~ACE_Fixed_Set (void) +{ + ACE_TRACE ("ACE_Fixed_Set::~ACE_Fixed_Set"); + this->cur_size_ = 0; +} + +template +ACE_Fixed_Set::ACE_Fixed_Set (const ACE_Fixed_Set &fs) + : cur_size_ (fs.cur_size_) +{ + ACE_TRACE ("ACE_Fixed_Set::ACE_Fixed_Set"); + + for (size_t i = 0, j = 0; i < fs.max_size_ && j < this->cur_size_; ++i) + if (fs.search_structure_[i].is_free_ == 0) + this->search_structure_[j++] = fs.search_structure_[i]; +} + +template void +ACE_Fixed_Set::operator= (const ACE_Fixed_Set &fs) +{ + ACE_TRACE ("ACE_Fixed_Set::operator="); + + if (this != &fs) + { + this->cur_size_ = fs.cur_size_; + + for (size_t i = 0, j = 0; i < fs.max_size_ && j < this->cur_size_; ++i) + if (fs.search_structure_[i].is_free_ == 0) + this->search_structure_[j++] = fs.search_structure_[i]; + } +} + +template +ACE_Fixed_Set::ACE_Fixed_Set (void) + : cur_size_ (0), + max_size_ (ACE_SIZE) +{ + ACE_TRACE ("ACE_Fixed_Set::ACE_Fixed_Set"); + for (size_t i = 0; i < this->max_size_; i++) + this->search_structure_[i].is_free_ = 1; +} + +template int +ACE_Fixed_Set::find (const T &item) const +{ + ACE_TRACE ("ACE_Fixed_Set::find"); + + for (size_t i = 0, j = 0; i < this->max_size_ && j < this->cur_size_; ++i) + if (this->search_structure_[i].is_free_ == 0) + { + if (this->search_structure_[i].item_ == item) + return 0; + ++j; + } + + return -1; +} + +template int +ACE_Fixed_Set::insert (const T &item) +{ + ACE_TRACE ("ACE_Fixed_Set::insert"); + ssize_t first_free = -1; // Keep track of first free slot. + size_t i; + + for (i = 0; + i < this->max_size_ && first_free == -1; + ++i) + + // First, make sure we don't allow duplicates. + + if (this->search_structure_[i].is_free_ == 0) + { + if (this->search_structure_[i].item_ == item) + return 1; + } + else + first_free = static_cast (i); + + // If we found a free spot let's reuse it. + + if (first_free > -1) + { + this->search_structure_[first_free].item_ = item; + this->search_structure_[first_free].is_free_ = 0; + this->cur_size_++; + return 0; + } + else /* No more room! */ + { + errno = ENOMEM; + return -1; + } +} + +template int +ACE_Fixed_Set::remove (const T &item) +{ + ACE_TRACE ("ACE_Fixed_Set::remove"); + + for (size_t i = 0, j = 0; + i < this->max_size_ && j < this->cur_size_; + ++i) + if (this->search_structure_[i].is_free_ == 0) + { + if (this->search_structure_[i].item_ == item) + { + // Mark this entry as being free. + this->search_structure_[i].is_free_ = 1; + + --this->cur_size_; + return 0; + } + else + ++j; + } + + return -1; +} + +//-------------------------------------------------- +ACE_ALLOC_HOOK_DEFINE(ACE_Fixed_Set_Iterator_Base) + +template void +ACE_Fixed_Set_Iterator_Base::dump_i (void) const +{ +#if defined (ACE_HAS_DUMP) + ACE_TRACE ("ACE_Fixed_Set_Iterator_Base::dump_i"); +#endif /* ACE_HAS_DUMP */ +} + +template +ACE_Fixed_Set_Iterator_Base::ACE_Fixed_Set_Iterator_Base (ACE_Fixed_Set &s) + : s_ (s), + next_ (-1), + iterated_items_ (0) +{ + ACE_TRACE ("ACE_Fixed_Set_Iterator_Base::ACE_Fixed_Set_Iterator_Base"); + this->advance (); +} + +template int +ACE_Fixed_Set_Iterator_Base::advance (void) +{ + ACE_TRACE ("ACE_Fixed_Set_Iterator_Base::advance"); + + if (this->iterated_items_ < this->s_.cur_size_) + { + for (++this->next_; + static_cast (this->next_) < this->s_.max_size_; + ++this->next_) + if (this->s_.search_structure_[this->next_].is_free_ == 0) + { + ++this->iterated_items_; + return 1; + } + } + else + ++this->next_; + + return 0; +} + +template int +ACE_Fixed_Set_Iterator_Base::first (void) +{ + ACE_TRACE ("ACE_Fixed_Set_Iterator_Base::first"); + + next_ = -1; + iterated_items_ = 0; + return this->advance (); +} + +template int +ACE_Fixed_Set_Iterator_Base::done (void) const +{ + ACE_TRACE ("ACE_Fixed_Set_Iterator_Base::done"); + + return ! (this->iterated_items_ < this->s_.cur_size_); +} + +template int +ACE_Fixed_Set_Iterator_Base::next_i (T *&item) +{ + ACE_TRACE ("ACE_Fixed_Set_Iterator_Base::next_i"); + + if (static_cast (this->next_) < this->s_.max_size_) + do + { + if (this->s_.search_structure_[this->next_].is_free_ == 0) + { + item = &this->s_.search_structure_[this->next_].item_; + this->advance (); + return 1; + } + } + while (this->advance () == 1); + + return 0; +} + +//-------------------------------------------------- +ACE_ALLOC_HOOK_DEFINE(ACE_Fixed_Set_Iterator) + +template void +ACE_Fixed_Set_Iterator::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + this->dump_i (); +#endif /* ACE_HAS_DUMP */ +} + +template +ACE_Fixed_Set_Iterator::ACE_Fixed_Set_Iterator (ACE_Fixed_Set &s) + : ACE_Fixed_Set_Iterator_Base (s) +{ + ACE_TRACE ("ACE_Fixed_Set_Iterator::ACE_Fixed_Set_Iterator"); +} + +template int +ACE_Fixed_Set_Iterator::next (T *&item) +{ + ACE_TRACE ("ACE_Fixed_Set_Iterator::next"); + return this->next_i (item); +} + +template int +ACE_Fixed_Set_Iterator::remove (T *&item) +{ + ACE_TRACE ("ACE_Fixed_Set_Iterator::remove"); + + if (this->s_.search_structure_[this->next_].is_free_ == 0) + { + item = &this->s_.search_structure_[this->next_].item_; + this->s_.remove (*item); + --(this->iterated_items_); + return 1; + } + + return 0; +} + +template T& +ACE_Fixed_Set_Iterator::operator* (void) +{ + T *retv = 0; + + if (this->s_.search_structure_[this->next_].is_free_ == 0) + retv = &this->s_.search_structure_[this->next_].item_; + + ACE_ASSERT (retv != 0); + + return *retv; +} + +//-------------------------------------------------- +ACE_ALLOC_HOOK_DEFINE(ACE_Fixed_Set_Const_Iterator) + +template void +ACE_Fixed_Set_Const_Iterator::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + this->dump_i (); +#endif /* ACE_HAS_DUMP */ +} + +template +ACE_Fixed_Set_Const_Iterator::ACE_Fixed_Set_Const_Iterator (const ACE_Fixed_Set &s) + : ACE_Fixed_Set_Iterator_Base (s) +{ + ACE_TRACE ("ACE_Fixed_Set_Const_Iterator::ACE_Fixed_Set_Const_Iterator"); +} + +template int +ACE_Fixed_Set_Const_Iterator::next (const T *&item) +{ + ACE_TRACE ("ACE_Fixed_Set_Const_Iterator::next"); + + return this->next_i (item); +} + +template const T& +ACE_Fixed_Set_Const_Iterator::operator* (void) const +{ + const T *retv = 0; + + if (this->s_.search_structure_[this->next_].is_free_ == 0) + retv = &this->s_.search_structure_[this->next_].item_; + + ACE_ASSERT (retv != 0); + + return *retv; +} + +//-------------------------------------------------- +ACE_ALLOC_HOOK_DEFINE(ACE_Bounded_Set) + +template void +ACE_Bounded_Set::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + ACE_TRACE ("ACE_Bounded_Set::dump"); +#endif /* ACE_HAS_DUMP */ +} + +template +ACE_Bounded_Set::~ACE_Bounded_Set (void) +{ + ACE_TRACE ("ACE_Bounded_Set::~ACE_Bounded_Set"); + delete [] this->search_structure_; +} + +template +ACE_Bounded_Set::ACE_Bounded_Set (void) + : cur_size_ (0), + max_size_ (static_cast (ACE_Bounded_Set::DEFAULT_SIZE)) +{ + ACE_TRACE ("ACE_Bounded_Set::ACE_Bounded_Set"); + + ACE_NEW (this->search_structure_, + typename ACE_Bounded_Set::Search_Structure[this->max_size_]); + + for (size_t i = 0; i < this->max_size_; ++i) + this->search_structure_[i].is_free_ = 1; +} + +template size_t +ACE_Bounded_Set::size (void) const +{ + ACE_TRACE ("ACE_Bounded_Set::size"); + return this->cur_size_; +} + +template +ACE_Bounded_Set::ACE_Bounded_Set (const ACE_Bounded_Set &bs) + : cur_size_ (bs.cur_size_), + max_size_ (bs.max_size_) +{ + ACE_TRACE ("ACE_Bounded_Set::ACE_Bounded_Set"); + + ACE_NEW (this->search_structure_, + typename ACE_Bounded_Set::Search_Structure[this->max_size_]); + + for (size_t i = 0; i < this->cur_size_; i++) + this->search_structure_[i] = bs.search_structure_[i]; +} + +template void +ACE_Bounded_Set::operator= (const ACE_Bounded_Set &bs) +{ + ACE_TRACE ("ACE_Bounded_Set::operator="); + + if (this != &bs) + { + if (this->max_size_ < bs.cur_size_) + { + delete [] this->search_structure_; + ACE_NEW (this->search_structure_, + typename ACE_Bounded_Set::Search_Structure[bs.cur_size_]); + this->max_size_ = bs.cur_size_; + } + + this->cur_size_ = bs.cur_size_; + + for (size_t i = 0; i < this->cur_size_; i++) + this->search_structure_[i] = bs.search_structure_[i]; + } +} + +template +ACE_Bounded_Set::ACE_Bounded_Set (size_t size) + : cur_size_ (0), + max_size_ (size) +{ + ACE_TRACE ("ACE_Bounded_Set::ACE_Bounded_Set"); + ACE_NEW (this->search_structure_, + typename ACE_Bounded_Set::Search_Structure[size]); + + for (size_t i = 0; i < this->max_size_; i++) + this->search_structure_[i].is_free_ = 1; +} + +template int +ACE_Bounded_Set::find (const T &item) const +{ + ACE_TRACE ("ACE_Bounded_Set::find"); + + for (size_t i = 0; i < this->cur_size_; i++) + if (this->search_structure_[i].item_ == item + && this->search_structure_[i].is_free_ == 0) + return 0; + + return -1; +} + +template int +ACE_Bounded_Set::insert (const T &item) +{ + ACE_TRACE ("ACE_Bounded_Set::insert"); + int first_free = -1; // Keep track of first free slot. + size_t i; + + for (i = 0; i < this->cur_size_; i++) + // First, make sure we don't allow duplicates. + + if (this->search_structure_[i].item_ == item + && this->search_structure_[i].is_free_ == 0) + return 1; + else if (this->search_structure_[i].is_free_ && first_free == -1) + first_free = static_cast (i); + + if (first_free > -1) // If we found a free spot let's reuse it. + { + this->search_structure_[first_free].item_ = item; + this->search_structure_[first_free].is_free_ = 0; + return 0; + } + else if (i < this->max_size_) // Insert at the end of the active portion. + { + this->search_structure_[i].item_ = item; + this->search_structure_[i].is_free_ = 0; + this->cur_size_++; + return 0; + } + else /* No more room! */ + { + errno = ENOMEM; + return -1; + } +} + +template int +ACE_Bounded_Set::remove (const T &item) +{ + ACE_TRACE ("ACE_Bounded_Set::remove"); + for (size_t i = 0; i < this->cur_size_; i++) + if (this->search_structure_[i].item_ == item) + { + // Mark this entry as being free. + this->search_structure_[i].is_free_ = 1; + + // If we just unbound the highest entry, then we need to + // figure out where the next highest active entry is. + if (i + 1 == this->cur_size_) + { + while (i > 0 && this->search_structure_[--i].is_free_) + continue; + + if (i == 0 && this->search_structure_[i].is_free_) + this->cur_size_ = 0; + else + this->cur_size_ = i + 1; + } + return 0; + } + + return -1; +} + +ACE_ALLOC_HOOK_DEFINE(ACE_Bounded_Set_Iterator) + + template void +ACE_Bounded_Set_Iterator::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + ACE_TRACE ("ACE_Bounded_Set_Iterator::dump"); +#endif /* ACE_HAS_DUMP */ +} + +template +ACE_Bounded_Set_Iterator::ACE_Bounded_Set_Iterator (ACE_Bounded_Set &s) + : s_ (s), + next_ (-1) +{ + ACE_TRACE ("ACE_Bounded_Set_Iterator::ACE_Bounded_Set_Iterator"); + this->advance (); +} + +template int +ACE_Bounded_Set_Iterator::advance (void) +{ + ACE_TRACE ("ACE_Bounded_Set_Iterator::advance"); + + for (++this->next_; + static_cast (this->next_) < this->s_.cur_size_ + && this->s_.search_structure_[this->next_].is_free_; + ++this->next_) + continue; + + return static_cast (this->next_) < this->s_.cur_size_; +} + +template int +ACE_Bounded_Set_Iterator::first (void) +{ + ACE_TRACE ("ACE_Bounded_Set_Iterator::first"); + + next_ = -1; + return this->advance (); +} + +template int +ACE_Bounded_Set_Iterator::done (void) const +{ + ACE_TRACE ("ACE_Bounded_Set_Iterator::done"); + + return static_cast (this->next_) >= + this->s_.cur_size_; +} + +template int +ACE_Bounded_Set_Iterator::next (T *&item) +{ + ACE_TRACE ("ACE_Bounded_Set_Iterator::next"); + if (static_cast (this->next_) < this->s_.cur_size_) + { + item = &this->s_.search_structure_[this->next_].item_; + return 1; + } + else + return 0; +} + +ACE_ALLOC_HOOK_DEFINE(ACE_DNode) + + template +ACE_DNode::ACE_DNode (const T &i, ACE_DNode *n, ACE_DNode *p) + : next_ (n), prev_ (p), item_ (i) +{ +} + +template +ACE_DNode::~ACE_DNode (void) +{ +} + +// **************************************************************** + +template void +ACE_Unbounded_Stack_Iterator::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + // ACE_TRACE ("ACE_Unbounded_Stack_Iterator::dump"); +#endif /* ACE_HAS_DUMP */ +} + +template +ACE_Unbounded_Stack_Iterator::ACE_Unbounded_Stack_Iterator (ACE_Unbounded_Stack &q) + : current_ (q.head_->next_), + stack_ (q) +{ + // ACE_TRACE ("ACE_Unbounded_Stack_Iterator::ACE_Unbounded_Stack_Iterator"); +} + +template int +ACE_Unbounded_Stack_Iterator::advance (void) +{ + // ACE_TRACE ("ACE_Unbounded_Stack_Iterator::advance"); + this->current_ = this->current_->next_; + return this->current_ != this->stack_.head_; +} + +template int +ACE_Unbounded_Stack_Iterator::first (void) +{ + // ACE_TRACE ("ACE_Unbounded_Stack_Iterator::first"); + this->current_ = this->stack_.head_->next_; + return this->current_ != this->stack_.head_; +} + +template int +ACE_Unbounded_Stack_Iterator::done (void) const +{ + ACE_TRACE ("ACE_Unbounded_Stack_Iterator::done"); + + return this->current_ == this->stack_.head_; +} + +template int +ACE_Unbounded_Stack_Iterator::next (T *&item) +{ + // ACE_TRACE ("ACE_Unbounded_Stack_Iterator::next"); + if (this->current_ == this->stack_.head_) + return 0; + else + { + item = &this->current_->item_; + return 1; + } +} + + +ACE_ALLOC_HOOK_DEFINE(ACE_Ordered_MultiSet) + + + template +ACE_Ordered_MultiSet::ACE_Ordered_MultiSet (ACE_Allocator *alloc) + : head_ (0) + , tail_ (0) + , cur_size_ (0) + , allocator_ (alloc) +{ + // ACE_TRACE ("ACE_Ordered_MultiSet::ACE_Ordered_MultiSet"); + + if (this->allocator_ == 0) + this->allocator_ = ACE_Allocator::instance (); +} + +template +ACE_Ordered_MultiSet::ACE_Ordered_MultiSet (const ACE_Ordered_MultiSet &us) + : head_ (0) + , tail_ (0) + , cur_size_ (0) + , allocator_ (us.allocator_) +{ + ACE_TRACE ("ACE_Ordered_MultiSet::ACE_Ordered_MultiSet"); + + if (this->allocator_ == 0) + this->allocator_ = ACE_Allocator::instance (); + + this->copy_nodes (us); +} + +template +ACE_Ordered_MultiSet::~ACE_Ordered_MultiSet (void) +{ + // ACE_TRACE ("ACE_Ordered_MultiSet::~ACE_Ordered_MultiSet"); + + this->delete_nodes (); +} + + +template void +ACE_Ordered_MultiSet::operator= (const ACE_Ordered_MultiSet &us) +{ + ACE_TRACE ("ACE_Ordered_MultiSet::operator="); + + if (this != &us) + { + this->delete_nodes (); + this->copy_nodes (us); + } +} + + +template int +ACE_Ordered_MultiSet::insert (const T &item) +{ + // ACE_TRACE ("ACE_Ordered_MultiSet::insert"); + + return this->insert_from (item, this->head_, 0); +} + +template int +ACE_Ordered_MultiSet::insert (const T &new_item, + ITERATOR &iter) +{ + // ACE_TRACE ("ACE_Ordered_MultiSet::insert using iterator"); + + return this->insert_from (new_item, iter.current_, &iter.current_); +} + +template int +ACE_Ordered_MultiSet::remove (const T &item) +{ + // ACE_TRACE ("ACE_Ordered_MultiSet::remove"); + + ACE_DNode *node = 0; + + int result = locate (item, 0, node); + + // if we found the node, remove from list and free it + if (node && (result == 0)) + { + if (node->prev_) + node->prev_->next_ = node->next_; + else + head_ = node->next_; + + if (node->next_) + node->next_->prev_ = node->prev_; + else + tail_ = node->prev_; + + --this->cur_size_; + + ACE_DES_FREE_TEMPLATE (node, + this->allocator_->free, + ACE_DNode, + ); + return 0; + } + + return -1; +} + +template int +ACE_Ordered_MultiSet::find (const T &item, + ITERATOR &iter) const +{ + // search an occurance of item, using iterator's current position as a hint + ACE_DNode *node = iter.current_; + int const result = locate (item, node, node); + + // if we found the node, update the iterator and indicate success + if (node && (result == 0)) + { + iter.current_ = node; + return 0; + } + + return -1; +} + + + +template void +ACE_Ordered_MultiSet::reset (void) +{ + ACE_TRACE ("reset"); + + this->delete_nodes (); +} + +template void +ACE_Ordered_MultiSet::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + // ACE_TRACE ("ACE_Ordered_MultiSet::dump"); + // + // ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); + // ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nhead_ = %u"), this->head_)); + // ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nhead_->next_ = %u"), this->head_->next_)); + // ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\ncur_size_ = %d\n"), this->cur_size_)); + // + // T *item = 0; + // size_t count = 1; + // + // for (ACE_Ordered_MultiSet_Iterator iter (*(ACE_Ordered_MultiSet *) this); + // iter.next (item) != 0; + // iter.advance ()) + // ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("count = %d\n"), count++)); + // + // ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); +#endif /* ACE_HAS_DUMP */ +} + +template int +ACE_Ordered_MultiSet::insert_from (const T &item, ACE_DNode *position, + ACE_DNode **new_position) +{ + // ACE_TRACE ("ACE_Ordered_MultiSet::insert_from"); + + // create a new node + ACE_DNode *temp = 0; + ACE_NEW_MALLOC_RETURN (temp, + static_cast*> (this->allocator_->malloc (sizeof (ACE_DNode))), + ACE_DNode (item), + -1); + // obtain approximate location of the node + int result = locate (item, position, position); + + // if there are nodes in the multiset + if (position) + { + switch (result) + { + // insert after the approximate position + case -1: + + // if there is a following node + if (position->next_) + { + // link up with the following node + position->next_->prev_ = temp; + temp->next_ = position->next_; + } + else + // appending to the end of the set + tail_ = temp; + + // link up with the preceeding node + temp->prev_ = position; + position->next_ = temp; + + break; + + // insert before the position + case 0: + case 1: + + // if there is a preceeding node + if (position->prev_) + { + // link up with the preceeding node + position->prev_->next_ = temp; + temp->prev_ = position->prev_; + } + else + // prepending to the start of the set + head_ = temp; + + // link up with the preceeding node + temp->next_ = position; + position->prev_ = temp; + + break; + + default: + return -1; + } + } + else + { + // point the head and tail to the new node. + this->head_ = temp; + this->tail_ = temp; + } + + ++this->cur_size_; + if (new_position) + *new_position = temp; + + return 0; +} + +template int +ACE_Ordered_MultiSet::locate (const T &item, ACE_DNode *start_position, + ACE_DNode *&new_position) const +{ + if (! start_position) + start_position = this->head_; + + // If starting before the item, move forward until at or just before + // item. + while (start_position && start_position->item_ < item && + start_position->next_) + start_position = start_position->next_; + + // If starting after the item, move back until at or just after item + while (start_position && item < start_position->item_ && + start_position->prev_) + start_position = start_position->prev_; + + // Save the (approximate) location in the passed pointer. + new_position = start_position; + + // Show the location is after (1), before (-1) , or at (0) the item + if (!new_position) + return 1; + else if (item < new_position->item_) + return 1; + else if (new_position->item_ < item) + return -1; + else + return 0; +} + +// Looks for first occurance of in the ordered set, using the +// passed starting position as a hint: if there is such an instance, +// it updates the new_position pointer to point to one such node and +// returns 0; if there is no such node, then if there is a node before +// where the item would have been, it updates the new_position pointer +// to point to this node and returns -1; if there is no such node, +// then if there is a node after where the item would have been, it +// updates the new_position pointer to point to this node (or 0 if +// there is no such node) and returns 1; + +template void +ACE_Ordered_MultiSet::copy_nodes (const ACE_Ordered_MultiSet &us) +{ + ACE_DNode *insertion_point = this->head_; + + for (ACE_DNode *curr = us.head_; + curr != 0; + curr = curr->next_) + this->insert_from (curr->item_, insertion_point, &insertion_point); +} + +template void +ACE_Ordered_MultiSet::delete_nodes (void) +{ + // iterate through list, deleting nodes + for (ACE_DNode *curr = this->head_; + curr != 0; + ) + { + ACE_DNode *temp = curr; + curr = curr->next_; + ACE_DES_FREE_TEMPLATE (temp, + this->allocator_->free, + ACE_DNode, + ); + } + + this->head_ = 0; + this->tail_ = 0; + this->cur_size_ = 0; +} + +ACE_ALLOC_HOOK_DEFINE(ACE_Ordered_MultiSet_Iterator) + +template +ACE_Ordered_MultiSet_Iterator::ACE_Ordered_MultiSet_Iterator (ACE_Ordered_MultiSet &s) + : current_ (s.head_), + set_ (s) +{ + // ACE_TRACE ("ACE_Ordered_MultiSet_Iterator::ACE_Ordered_MultiSet_Iterator"); +} + +template int +ACE_Ordered_MultiSet_Iterator::next (T *&item) const +{ + // ACE_TRACE ("ACE_Ordered_MultiSet_Iterator::next"); + if (this->current_) + { + item = &this->current_->item_; + return 1; + } + + return 0; +} + +template T& +ACE_Ordered_MultiSet_Iterator::operator* (void) +{ + //ACE_TRACE ("ACE_Ordered_MultiSet_Iterator::operator*"); + T *retv = 0; + + int const result = this->next (retv); + ACE_ASSERT (result != 0); + ACE_UNUSED_ARG (result); + + return *retv; +} + +ACE_ALLOC_HOOK_DEFINE (ACE_DLList_Node) + +template T * +ACE_DLList::insert_tail (T *new_item) +{ + ACE_DLList_Node *temp1 = 0; + ACE_NEW_MALLOC_RETURN (temp1, + static_cast (this->allocator_->malloc (sizeof (ACE_DLList_Node))), + ACE_DLList_Node (new_item), + 0); + ACE_DLList_Node *temp2 = ACE_DLList_Base::insert_tail (temp1); + return (T *) (temp2 ? temp2->item_ : 0); +} + +template T * +ACE_DLList::insert_head (T *new_item) +{ + ACE_DLList_Node *temp1 = 0; + ACE_NEW_MALLOC_RETURN (temp1, + (ACE_DLList_Node *) this->allocator_->malloc (sizeof (ACE_DLList_Node)), + ACE_DLList_Node (new_item), 0); + ACE_DLList_Node *temp2 = ACE_DLList_Base::insert_head (temp1); + return (T *) (temp2 ? temp2->item_ : 0); +} + +template T * +ACE_DLList::delete_head (void) +{ + ACE_DLList_Node *temp1 = ACE_DLList_Base::delete_head (); + T *temp2 = (T *) (temp1 ? temp1->item_ : 0); + ACE_DES_FREE (temp1, + this->allocator_->free, + ACE_DLList_Node); + + return temp2; +} + +template T * +ACE_DLList::delete_tail (void) +{ + ACE_DLList_Node *temp1 = ACE_DLList_Base::delete_tail (); + T *temp2 = (T *) (temp1 ? temp1->item_ : 0); + ACE_DES_FREE (temp1, + this->allocator_->free, + ACE_DLList_Node); + return temp2; +} + +// **************************************************************** + +// Compare this array with for equality. + +template bool +ACE_Array::operator== (const ACE_Array &s) const +{ + if (this == &s) + return true; + else if (this->size () != s.size ()) + return false; + + const size_t len = s.size (); + for (size_t slot = 0; slot < len; ++slot) + if ((*this)[slot] != s[slot]) + return false; + + return true; +} + +// **************************************************************** + +ACE_END_VERSIONED_NAMESPACE_DECL + +#endif /* ACE_CONTAINERS_T_CPP */ diff --git a/dep/ACE_wrappers/ace/Containers_T.h b/dep/ACE_wrappers/ace/Containers_T.h new file mode 100644 index 00000000000..7245b51b612 --- /dev/null +++ b/dep/ACE_wrappers/ace/Containers_T.h @@ -0,0 +1,2073 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Containers_T.h + * + * $Id: Containers_T.h 82588 2008-08-11 13:37:41Z johnnyw $ + * + * @author Douglas C. Schmidt + */ +//============================================================================= + +#ifndef ACE_CONTAINERS_T_H +#define ACE_CONTAINERS_T_H + +#include /**/ "ace/pre.h" + +#include /**/ "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +// Need by ACE_DLList_Node. +#include "ace/Containers.h" + +// Shared with "ace/Unbounded_Set.h" +#include "ace/Node.h" + +// Backwards compatibility, please include "ace/Array_Base.h" directly. +#include "ace/Array_Base.h" + +// Backwards compatibility, please include "ace/Unbounded_Set.h" directly. +#include "ace/Unbounded_Set.h" + +// Backwards compatibility, please include "ace/Unbounded_Queue.h" directly. +#include "ace/Unbounded_Queue.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +class ACE_Allocator; + + +/** + * @class ACE_Bounded_Stack + * + * @brief Implement a generic LIFO abstract data type. + * + * This implementation of a Stack uses a bounded array + * that is allocated dynamically. The Stack interface + * provides the standard constant time push, pop, and top + * operations. + * + * Requirements and Performance Characteristics + * - Internal Structure + * Dynamic array + * - Duplicates allowed? + * Yes + * - Random access allowed? + * No + * - Search speed + * N/A + * - Insert/replace speed + * N/A + * - Iterator still valid after change to container? + * N/A + * - Frees memory for removed elements? + * No + * - Items inserted by + * Value + * - Requirements for contained type + * -# Default constructor + * -# Copy constructor + * -# operator= + * + */ +template +class ACE_Bounded_Stack +{ +public: + // = Initialization, assignment, and termination methods. + + /// Initialize a new empty stack with the provided size.. + /** + * Initialize and allocate space for a new Bounded_Stack with the provided + * size. + */ + ACE_Bounded_Stack (size_t size); + + /// Initialize the stack to be a copy of the stack provided. + /** + * Initialize the stack to be an exact copy of the Bounded_Stack provided + * as a parameter. + */ + ACE_Bounded_Stack (const ACE_Bounded_Stack &s); + + /// Assignment operator + /** + * Perform a deep copy operation using the Bounded_Stack parameter. If the + * capacity of the lhs isn't sufficient for the rhs, then the underlying data + * structure will be reallocated to accomadate the larger number of elements. + */ + void operator= (const ACE_Bounded_Stack &s); + + /// Perform actions needed when stack goes out of scope. + /** + * Deallocate the memory used by the Bounded_Stack. + */ + ~ACE_Bounded_Stack (void); + + // = Classic Stack operations. + + ///Add an element to the top of the stack. + /** + * Place a new item on top of the stack. Returns -1 if the stack + * is already full, 0 if the stack is not already full, and -1 if + * failure occurs. + */ + int push (const T &new_item); + + ///Remove an item from the top of stack. + /** + * Remove and return the top stack item. Returns -1 if the stack is + * already empty, 0 if the stack is not already empty, and -1 if + * failure occurs. + */ + int pop (T &item); + + ///Examine the contents of the top of stack. + /** + * Return top stack item without removing it. Returns -1 if the + * stack is already empty, 0 if the stack is not already empty, and + * -1 if failure occurs. + */ + int top (T &item) const; + + // = Check boundary conditions. + + /// Returns 1 if the container is empty, otherwise returns 0. + /** + * Performs constant time check to determine if the stack is empty. + */ + int is_empty (void) const; + + /// Returns 1 if the container is full, otherwise returns 0. + /** + * Performs constant time check to determine if the stack is at capacity. + */ + int is_full (void) const; + + /// The number of items in the stack. + /** + * Return the number of items currently in the stack. + */ + size_t size (void) const; + + /// Dump the state of an object. + void dump (void) const; + + /// Declare the dynamic allocation hooks. + ACE_ALLOC_HOOK_DECLARE; + +private: + /// Size of the dynamically allocated data. + size_t size_; + + /// Keeps track of the current top of stack. + size_t top_; + + /// Holds the stack's contents. + T *stack_; +}; + +//---------------------------------------- + + +/** + * @class ACE_Fixed_Stack + * + * @brief Implement a generic LIFO abstract data type. + * + * This implementation of a Stack uses a fixed array + * with the size fixed at instantiation time. + * + * Requirements and Performance Characteristics + * - Internal Structure + * Fixed array + * - Duplicates allowed? + * Yes + * - Random access allowed? + * No + * - Search speed + * N/A + * - Insert/replace speed + * N/A + * - Iterator still valid after change to container? + * N/A + * - Frees memory for removed elements? + * No + * - Items inserted by + * Value + * - Requirements for contained type + * -# Default constructor + * -# Copy constructor + * -# operator= + * + */ +template +class ACE_Fixed_Stack +{ +public: + // = Initialization, assignment, and termination methods. + /// Initialize a new stack so that it is empty. + /** + * Initialize an empty stack. + */ + ACE_Fixed_Stack (void); + + /// The copy constructor (performs initialization). + /** + * Initialize the stack and copy the provided stack into the current stack. + */ + ACE_Fixed_Stack (const ACE_Fixed_Stack &s); + + /// Assignment operator (performs assignment). + /** + * Perform a deep copy of the provided stack. + */ + void operator= (const ACE_Fixed_Stack &s); + + /// Perform actions needed when stack goes out of scope. + /** + * Destroy the stack. + */ + ~ACE_Fixed_Stack (void); + + // = Classic Stack operations. + + ///Constant time placement of element on top of stack. + /** + * Place a new item on top of the stack. Returns -1 if the stack + * is already full, 0 if the stack is not already full, and -1 if + * failure occurs. + */ + int push (const T &new_item); + + ///Constant time removal of top of stack. + /** + * Remove and return the top stack item. Returns -1 if the stack is + * already empty, 0 if the stack is not already empty, and -1 if + * failure occurs. + */ + int pop (T &item); + + ///Constant time examination of top of stack. + /** + * Return top stack item without removing it. Returns -1 if the + * stack is already empty, 0 if the stack is not already empty, and + * -1 if failure occurs. + */ + int top (T &item) const; + + // = Check boundary conditions. + + /// Returns 1 if the container is empty, otherwise returns 0. + /** + * Performs constant time check to see if stack is empty. + */ + int is_empty (void) const; + + /// Returns 1 if the container is full, otherwise returns 0. + /** + * Performs constant time check to see if stack is full. + */ + int is_full (void) const; + + /// The number of items in the stack. + /** + * Constant time access to the current size of the stack. + */ + size_t size (void) const; + + /// Dump the state of an object. + void dump (void) const; + + /// Declare the dynamic allocation hooks. + ACE_ALLOC_HOOK_DECLARE; + +private: + /// Size of the allocated data. + size_t size_; + + /// Keeps track of the current top of stack. + size_t top_; + + /// Holds the stack's contents. + T stack_[ACE_SIZE]; +}; + +//---------------------------------------- + +template class ACE_Ordered_MultiSet; +template class ACE_Ordered_MultiSet_Iterator; + +/** + * @class ACE_DNode + * + * @brief Implementation element in a bilinked list. + */ +template +class ACE_DNode +{ + friend class ACE_Ordered_MultiSet; + friend class ACE_Ordered_MultiSet_Iterator; + +public: + + /// This isn't necessary, but it keeps some compilers happy. + ~ACE_DNode (void); + +private: + + // = Initialization methods + ACE_DNode (const T &i, ACE_DNode *n = 0, ACE_DNode *p = 0); + + /// Pointer to next element in the list of {ACE_DNode}s. + ACE_DNode *next_; + + /// Pointer to previous element in the list of {ACE_DNode}s. + ACE_DNode *prev_; + + /// Current value of the item in this node. + T item_; +}; + + + +/** + * @class ACE_Unbounded_Stack + * + * @brief Implement a generic LIFO abstract data type. + * + * This implementation of an unbounded Stack uses a linked list. + * If you use the {insert} or {remove} methods you should keep + * in mind that duplicate entries aren't allowed. In general, + * therefore, you should avoid the use of these methods since + * they aren't really part of the ADT stack. The stack is implemented + * as a doubly linked list. + * + * Requirements and Performance Characteristics + * - Internal Structure + * Double linked list + * - Duplicates allowed? + * No + * - Random access allowed? + * No + * - Search speed + * Linear + * - Insert/replace speed + * Linear + * - Iterator still valid after change to container? + * Yes + * - Frees memory for removed elements? + * Yes + * - Items inserted by + * Value + * - Requirements for contained type + * -# Default constructor + * -# Copy constructor + * -# operator= + * + */ +template +class ACE_Unbounded_Stack +{ +public: + friend class ACE_Unbounded_Stack_Iterator; + + // Trait definition. + typedef ACE_Unbounded_Stack_Iterator ITERATOR; + + // = Initialization, assignment, and termination methods. + /// Initialize a new stack so that it is empty. Use user defined + /// allocation strategy if specified. + /** + * Initialize an empty stack using the user specified allocation strategy + * if provided. + */ + ACE_Unbounded_Stack (ACE_Allocator *the_allocator = 0); + + /// The copy constructor (performs initialization). + /** + * Initialize this stack to be an exact copy of {s}. + */ + ACE_Unbounded_Stack (const ACE_Unbounded_Stack &s); + + /// Assignment operator (performs assignment). + /** + * Perform a deep copy of the rhs into the lhs. + */ + void operator= (const ACE_Unbounded_Stack &s); + + /// Perform actions needed when stack goes out of scope. + /** + * Destroy the underlying list for the stack. + */ + ~ACE_Unbounded_Stack (void); + + // = Classic Stack operations. + + + ///Push an element onto the top of stack. + /** + * Place a new item on top of the stack. Returns -1 if the stack + * is already full, 0 if the stack is not already full, and -1 if + * failure occurs. + */ + int push (const T &new_item); + + ///Pop the top element of the stack. + /** + * Remove and return the top stack item. Returns -1 if the stack is + * already empty, 0 if the stack is not already empty, and -1 if + * failure occurs. + */ + int pop (T &item); + + ///Examine the top of the stack. + /** + * Return top stack item without removing it. Returns -1 if the + * stack is already empty, 0 if the stack is not already empty, and + * -1 if failure occurs. + */ + int top (T &item) const; + + // = Check boundary conditions. + + /// Returns 1 if the container is empty, otherwise returns 0. + /** + * Constant time check to see if the stack is empty. + */ + int is_empty (void) const; + + /// Returns 1 if the container is full, otherwise returns 0. + /** + * Always resturns 0 since the stack is unbounded. + */ + int is_full (void) const; + + // = Auxiliary methods (not strictly part of the Stack ADT). + + ///Linear Insert of an item. + /** + * Insert {new_item} into the Stack at the head (but doesn't allow + * duplicates). Returns -1 if failures occur, 1 if item is already + * present (i.e., no duplicates are allowed), else 0. + */ + int insert (const T &new_item); + + /// Remove @a item from the Stack. Returns 0 if it removes the item, + /// -1 if it can't find the item, and -1 if a failure occurs. + /** + * Linear remove operation. + */ + int remove (const T &item); + + /// Finds if @a item occurs the set. Returns 0 if finds, else -1. + /** + * Linear find operation. + */ + int find (const T &item) const; + + /// The number of items in the stack. + /** + * Constant time access to the current stack size. + */ + size_t size (void) const; + + /// Dump the state of an object. + void dump (void) const; + + /// Declare the dynamic allocation hooks. + ACE_ALLOC_HOOK_DECLARE; + +private: + /// Delete all the nodes in the stack. + void delete_all_nodes (void); + + /// Copy all nodes from {s} to {this}. + void copy_all_nodes (const ACE_Unbounded_Stack &s); + + /// Head of the linked list of Nodes. + ACE_Node *head_; + + /// Current size of the stack. + size_t cur_size_; + + /// Allocation strategy of the stack. + ACE_Allocator *allocator_; +}; + +/** + * @class ACE_Unbounded_Stack_Iterator + * + * @brief Implement an iterator over an unbounded Stack. + */ +template +class ACE_Unbounded_Stack_Iterator +{ +public: + // = Initialization method. + /// Move to the first element in the {stack}. + ACE_Unbounded_Stack_Iterator (ACE_Unbounded_Stack &stack); + + // = Iteration methods. + + /// Pass back the @a next_item that hasn't been seen in the Stack. + /// Returns 0 when all items have been seen, else 1. + int next (T *&next_item); + + /// Move forward by one element in the Stack. Returns 0 when all the + /// items in the Stack have been seen, else 1. + int advance (void); + + /// Move to the first element in the Stack. Returns 0 if the + /// Stack is empty, else 1. + int first (void); + + /// Returns 1 when all items have been seen, else 0. + int done (void) const; + + /// Dump the state of an object. + void dump (void) const; + + /// Declare the dynamic allocation hooks. + ACE_ALLOC_HOOK_DECLARE; + +private: + /// Pointer to the current node in the iteration. + ACE_Node *current_; + + /// Pointer to the Stack we're iterating over. + ACE_Unbounded_Stack &stack_; +}; + +template +class ACE_Double_Linked_List; + +/** + * @class ACE_Double_Linked_List_Iterator_Base + * + * @brief Implements a common base class for iterators for a double + * linked list ADT + */ +template +class ACE_Double_Linked_List_Iterator_Base +{ +public: + // = Iteration methods. + + /// Passes back the {entry} under the iterator. Returns 0 if the + /// iteration has completed, otherwise 1 + int next (T *&) const; + + /** + * @deprecated Return the address of next (current) unvisited item in + * the list. 0 if there is no more element available. + */ + T *next (void) const; + + /// Returns 1 when all items have been seen, else 0. + int done (void) const; + + /// STL-like iterator dereference operator: returns a reference + /// to the node underneath the iterator. + T & operator* (void) const ; + + /** + * Retasks the iterator to iterate over a new + * Double_Linked_List. This allows clients to reuse an iterator + * without incurring the constructor overhead. If you do use this, + * be aware that if there are more than one reference to this + * iterator, the other "clients" may be very bothered when their + * iterator changes. @@ Here be dragons. Comments? + */ + void reset (ACE_Double_Linked_List &); + + /// Declare the dynamic allocation hooks. + ACE_ALLOC_HOOK_DECLARE; + +protected: + // = Initialization methods. + + /// Constructor + ACE_Double_Linked_List_Iterator_Base (const ACE_Double_Linked_List &); + + /// Copy constructor. + ACE_Double_Linked_List_Iterator_Base (const + ACE_Double_Linked_List_Iterator_Base + &iter); + + // = Iteration methods. + /** + * Move to the first element of the list. Returns 0 if the list is + * empty, else 1. + * @note the head of the ACE_DLList is actually a null entry, so the + * first element is actually the 2n'd entry + */ + int go_head (void); + + /// Move to the last element of the list. Returns 0 if the list is + /// empty, else 1. + int go_tail (void); + + /** + * Check if we reach the end of the list. Can also be used to get + * the *current* element in the list. Return the address of the + * current item if there are still elements left , 0 if we run out + * of element. + */ + T *not_done (void) const ; + + /// Advance to the next element in the list. Return the address of the + /// next element if there are more, 0 otherwise. + T *do_advance (void); + + /// Retreat to the previous element in the list. Return the address + /// of the previous element if there are more, 0 otherwise. + T *do_retreat (void); + + /// Dump the state of an object. + void dump_i (void) const; + + /// Remember where we are. + T *current_; + + const ACE_Double_Linked_List *dllist_; +}; + +/** + * @class ACE_Double_Linked_List_Iterator + * + * @brief Implements an iterator for a double linked list ADT + * + * Iterate thru the double-linked list. This class provides + * an interface that let users access the internal element + * addresses directly. Notice {class T} must declare + * ACE_Double_Linked_List<T>, + * ACE_Double_Linked_List_Iterator_Base <T> and + * ACE_Double_Linked_List_Iterator as friend classes and class T + * should also have data members T* next_ and T* prev_. + */ +template +class ACE_Double_Linked_List_Iterator : public ACE_Double_Linked_List_Iterator_Base +{ +public: + // = Initialization method. + ACE_Double_Linked_List_Iterator (const ACE_Double_Linked_List &); + + /** + * Retasks the iterator to iterate over a new + * Double_Linked_List. This allows clients to reuse an iterator + * without incurring the constructor overhead. If you do use this, + * be aware that if there are more than one reference to this + * iterator, the other "clients" may be very bothered when their + * iterator changes. + * @@ Here be dragons. Comments? + */ + void reset (ACE_Double_Linked_List &); + + /// Move to the first element in the list. Returns 0 if the + /// list is empty, else 1. + int first (void); + + /// Move forward by one element in the list. Returns 0 when all the + /// items in the list have been seen, else 1. + int advance (void); + + /** + * Advance the iterator while removing the original item from the + * list. Return a pointer points to the original (removed) item. + * If @a dont_remove equals false, this function behaves like {advance} + * but return 0 (NULL) instead. + */ + T* advance_and_remove (bool dont_remove); + + // = STL-style iteration methods + + /// Prefix advance. + ACE_Double_Linked_List_Iterator & operator++ (void); + + /// Postfix advance. + ACE_Double_Linked_List_Iterator operator++ (int); + + /// Prefix reverse. + ACE_Double_Linked_List_Iterator & operator-- (void); + + /// Postfix reverse. + ACE_Double_Linked_List_Iterator operator-- (int); + + /// Dump the state of an object. + void dump (void) const; + + /// Declare the dynamic allocation hooks. + ACE_ALLOC_HOOK_DECLARE; +}; + +/** + * @class ACE_Double_Linked_List_Reverse_Iterator + * + * @brief Implements a reverse iterator for a double linked list ADT + * + * Iterate backwards over the double-linked list. This class + * provide an interface that let users access the internal + * element addresses directly, which seems to break the + * encapsulation. Notice {class T} must declare + * ACE_Double_Linked_List<T>, + * ACE_Double_Linked_List_Iterator_Base <T> and + * ACE_Double_Linked_List_Iterator as friend classes and class T + * should also have data members T* next_ and T* prev_. + */ +template +class ACE_Double_Linked_List_Reverse_Iterator : public ACE_Double_Linked_List_Iterator_Base +{ +public: + // = Initialization method. + ACE_Double_Linked_List_Reverse_Iterator (ACE_Double_Linked_List &); + + /** + * Retasks the iterator to iterate over a new + * Double_Linked_List. This allows clients to reuse an iterator + * without incurring the constructor overhead. If you do use this, + * be aware that if there are more than one reference to this + * iterator, the other "clients" may be very bothered when their + * iterator changes. + * @@ Here be dragons. Comments? + */ + void reset (ACE_Double_Linked_List &); + + /// Move to the first element in the list. Returns 0 if the + /// list is empty, else 1. + int first (void); + + /// Move forward by one element in the list. Returns 0 when all the + /// items in the list have been seen, else 1. + int advance (void); + + /** + * Advance the iterator while removing the original item from the + * list. Return a pointer points to the original (removed) item. + * If @a dont_remove equals false, this function behaves like {advance} + * but return 0 (NULL) instead. + */ + T* advance_and_remove (bool dont_remove); + + // = STL-style iteration methods + + /// Prefix advance. + ACE_Double_Linked_List_Reverse_Iterator & operator++ (void); + + /// Postfix advance. + ACE_Double_Linked_List_Reverse_Iterator operator++ (int); + + /// Prefix reverse. + ACE_Double_Linked_List_Reverse_Iterator & operator-- (void); + + /// Postfix reverse. + ACE_Double_Linked_List_Reverse_Iterator operator-- (int); + + /// Dump the state of an object. + void dump (void) const; + + /// Declare the dynamic allocation hooks. + ACE_ALLOC_HOOK_DECLARE; +}; + + +/** + * @class ACE_Double_Linked_List + * + * @brief A double-linked list implementation. + * + * This implementation of an unbounded double-linked list uses a + * circular linked list with a dummy node. It is pretty much + * like the {ACE_Unbounded_Queue} except that it allows removing + * of a specific element from a specific location. + * Notice that this class is an implementation of a very simple + * data structure. This is *NOT* a container class. You can use the + * class to implement other contains classes but it is *NOT* a + * general purpose container class. + * The parameter class *MUST* have members T* prev and T* next + * and users of this class are responsible to follow the general + * rules of using double-linked lists to maintaining the list + * integrity. + * If you need a double linked container class, use the DLList + * class which is a container but delegates to the Double_Linked_List + * class. + * + * Requirements and Performance Characteristics + * - Internal Structure + * Double Linked List + * - Duplicates allowed? + * Yes + * - Random access allowed? + * No + * - Search speed + * N/A + * - Insert/replace speed + * Linear + * - Iterator still valid after change to container? + * Yes + * - Frees memory for removed elements? + * No + * - Items inserted by + * Value + * - Requirements for contained type + * -# Default constructor + * -# Copy constructor + * -# operator= + * + */ +template +class ACE_Double_Linked_List +{ +public: + friend class ACE_Double_Linked_List_Iterator_Base; + friend class ACE_Double_Linked_List_Iterator; + friend class ACE_Double_Linked_List_Reverse_Iterator; + + // Trait definition. + typedef ACE_Double_Linked_List_Iterator ITERATOR; + typedef ACE_Double_Linked_List_Reverse_Iterator REVERSE_ITERATOR; + + // = Initialization and termination methods. + /// construction. Use user specified allocation strategy + /// if specified. + /** + * Initialize an empy list using the allocation strategy specified by the user. + * If none is specified, then use default allocation strategy. + */ + ACE_Double_Linked_List (ACE_Allocator *the_allocator = 0); + + /// Copy constructor. + /** + * Create a double linked list that is a copy of the provided + * parameter. + */ + ACE_Double_Linked_List (const ACE_Double_Linked_List &); + + /// Assignment operator. + /** + * Perform a deep copy of the provided list by first deleting the nodes of the + * lhs and then copying the nodes of the rhs. + */ + void operator= (const ACE_Double_Linked_List &); + + /// Destructor. + /** + * Clean up the memory allocated for the nodes of the list. + */ + ~ACE_Double_Linked_List (void); + + // = Check boundary conditions. + + /// Returns 1 if the container is empty, 0 otherwise. + /** + * Performs constant time check to determine if the list is empty. + */ + int is_empty (void) const; + + /// The list is unbounded, so this always returns 0. + /** + * Since the list is unbounded, the method simply returns 0. + */ + int is_full (void) const; + + // = Classic queue operations. + + /// Adds @a new_item to the tail of the list. Returns the new item + /// that was inserted. + /** + * Provides constant time insertion at the end of the list structure. + */ + T *insert_tail (T *new_item); + + /// Adds @a new_item to the head of the list.Returns the new item that + /// was inserted. + /** + * Provides constant time insertion at the head of the list. + */ + T *insert_head (T *new_item); + + /// Removes the head of the list and returns a pointer to that item. + /** + * Removes and returns the first {item} in the list. Returns + * internal node's address on success, 0 if the queue was empty. + * This method will *not* free the internal node. + */ + T* delete_head (void); + + /// Removes the tail of the list and returns a pointer to that item. + /** + * Removes and returns the last {item} in the list. Returns + * internal nodes's address on success, 0 if the queue was + * empty. This method will *not* free the internal node. + */ + T *delete_tail (void); + + // = Additional utility methods. + + ///Empty the list. + /** + * Reset the {ACE_Double_Linked_List} to be empty. + * Notice that since no one is interested in the items within, + * This operation will delete all items. + */ + void reset (void); + + /// Get the {slot}th element in the set. Returns -1 if the element + /// isn't in the range {0..{size} - 1}, else 0. + /** + * Iterates through the list to the desired index and assigns the provides pointer + * with the address of the node occupying that index. + */ + int get (T *&item, size_t slot = 0); + + /// The number of items in the queue. + /** + * Constant time call to return the current size of the list. + */ + size_t size (void) const; + + /// Dump the state of an object. + void dump (void) const; + + /// Use DNode address directly. + /** + * Constant time removal of an item from the list using it's address. + */ + int remove (T *n); + + /// Declare the dynamic allocation hooks. + ACE_ALLOC_HOOK_DECLARE; + +protected: + /// Delete all the nodes in the list. + /** + * Removes and deallocates memory for all of the list nodes. + */ + void delete_nodes (void); + + /// Copy nodes from {rhs} into this list. + /** + * Copy the elements of the provided list by allocated new nodes and assigning + * them with the proper data. + */ + void copy_nodes (const ACE_Double_Linked_List &rhs); + + /// Setup header pointer. Called after we create the head node in ctor. + /** + * Initialize the head pointer so that the list has a dummy node. + */ + void init_head (void); + + ///Constant time insert a new item into the list structure. + /** + * Insert a @a new_item into the list. It will be added before + * or after @a old_item. Default is to insert the new item *after* + * {head_}. Return 0 if succeed, -1 if error occured. + */ + int insert_element (T *new_item, + int before = 0, + T *old_item = 0); + + ///Constant time delete an item from the list structure. + /** + * Remove @a item from the list. Return 0 if succeed, -1 otherwise. + * Notice that this function checks if item is {head_} and either its + * {next_} or {prev_} is NULL. The function resets item's {next_} and + * {prev_} to 0 to prevent clobbering the double-linked list if a user + * tries to remove the same node again. + */ + int remove_element (T *item); + + /// Head of the circular double-linked list. + T *head_; + + /// Size of this list. + size_t size_; + + /// Allocation Strategy of the queue. + ACE_Allocator *allocator_; +}; + + +template class ACE_DLList; +template class ACE_DLList_Iterator; +template class ACE_DLList_Reverse_Iterator; + +typedef ACE_Double_Linked_List ACE_DLList_Base; + +//typedef ACE_Double_Linked_List_Iterator +// ACE_DLList_Iterator_Base; +//typedef ACE_Double_Linked_List_Reverse_Iterator +// ACE_DLList_Reverse_Iterator_Base; +//@@ These two typedefs (inherited from James Hu's original design) +// have been removed because Sun CC 4.2 had problems with it. I guess +// having the DLList_Iterators inheriting from a class which is +// actually a typedef leads to problems. #define'ing rather than +// typedef'ing worked, but as per Carlos's reccomendation, I'm just +// replacing all references to the base classes with their actual +// type. Matt Braun (6/15/99) + +/** + * @class ACE_DLList + * + * @brief A double-linked list container class. + * + * ACE_DLList is a simple, unbounded container implemented using a + * double-linked list. It is critical to remember that ACE_DLList inherits + * from ACE_Double_Linked_List, wrapping each T pointer in a ACE_DLList_Node + * object which satisfies the next/prev pointer requirements imposed by + * ACE_Double_Linked_List. + * + * Each item inserted to an ACE_DLList is a pointer to a T object. The + * caller is responsible for lifetime of the T object. ACE_DLList takes no + * action on the T object; it is not copied on insertion and it is not + * deleted on removal from the ACE_DLList. + */ +template +class ACE_DLList : public ACE_DLList_Base +{ + friend class ACE_DLList_Node; + friend class ACE_Double_Linked_List_Iterator; + friend class ACE_DLList_Iterator; + friend class ACE_DLList_Reverse_Iterator; + +public: + + /// Delegates to ACE_Double_Linked_List. + void operator= (const ACE_DLList &l); + + /** + * @name Queue-like insert and delete methods + */ + //@{ + + /** + * Insert pointer for a new item at the tail of the list. + * + * @return Pointer to item inserted; 0 on error. + */ + T *insert_tail (T *new_item); + + /** + * Insert pointer for a new item at the head of the list. + * + * @return Pointer to item inserted; 0 on error. + */ + T *insert_head (T *new_item); + + /** + * Removes the item at the head of the list and returns its pointer. + * + * @return Pointer to previously inserted item; 0 if the list is empty, + * an error occurred, or the original pointer inserted was 0. + */ + T *delete_head (void); + + /** + * Removes the item at the tail of the list and returns its pointer. + * + * @return Pointer to previously inserted item; 0 if the list is empty, + * an error occurred, or the original pointer inserted was 0. + */ + T *delete_tail (void); + //@} + + /** + * Provide random access to any item in the list. + * + * @param item Receives a pointer to the T object pointer held at the + * specified position in the list. + * @param slot Position in the list to access. The first position is 0. + * + * @retval 0 Success; T pointer returned in item. + * @retval -1 Error, most likely slot is outside the range of the list. + */ + int get (T *&item, size_t slot = 0); + + /// Delegates to ACE_Double_Linked_List. + void dump (void) const; + + /// Delegates to ACE_Double_Linked_List. + int remove (ACE_DLList_Node *n); + + /** + * Constructor. + * + * @param the_allocator Allocator to use for allocating ACE_DLList_Node + * objects that wrap T objects for inclusion in the + * list. If 0, ACE_Allocator::instance() is used. + */ + ACE_DLList (ACE_Allocator *the_allocator = 0); + + /// Delegates to ACE_Double_Linked_List. + ACE_DLList (const ACE_DLList &l); + + /** + * Deletes all ACE_DLList_Node objects in the list starting from the head. + * No T objects referred to by the deleted ACE_DLList_Node objects are + * modified or freed. If you desire all of the T objects in the list to + * be deleted as well, code such as this should be used prior to destroying + * the ACE_DLList: + * @code + ACE_DLList list; + ... // insert dynamically allocated Items... + Item *p; + while ((p = list.delete_head()) != 0) + delete *p; + @endcode + */ + ~ACE_DLList (void); +}; + +/** + * @class ACE_DLList_Iterator + * + * @brief A double-linked list container class iterator. + * + * This implementation uses ACE_Double_Linked_List_Iterator to + * perform the logic behind this container class. It delegates + * all of its calls to ACE_Double_Linked_List_Iterator. + */ +template +class ACE_DLList_Iterator : public ACE_Double_Linked_List_Iterator +{ + + friend class ACE_DLList; + friend class ACE_DLList_Node; + +public: + + // = Initialization method. + ACE_DLList_Iterator (ACE_DLList &l); + + /** + * Retasks the iterator to iterate over a new + * Double_Linked_List. This allows clients to reuse an iterator + * without incurring the constructor overhead. If you do use this, + * be aware that if there are more than one reference to this + * iterator, the other "clients" may be very bothered when their + * iterator changes. + * @@ Here be dragons. Comments? + */ + void reset (ACE_DLList &l); + + // = Iteration methods. + /// Move forward by one element in the list. Returns 0 when all the + /// items in the list have been seen, else 1. + int advance (void); + + /// Pass back the {next_item} that hasn't been seen in the list. + /// Returns 0 when all items have been seen, else 1. + int next (T *&); + + /** + * @deprecated Delegates to ACE_Double_Linked_List_Iterator, except that + * whereas the Double_Linked_List version of next returns the node, this next + * returns the contents of the node + */ + T *next (void) const; + + /** + * Removes the current item (i.e., {next}) from the list. + * Note that DLList iterators do not support {advance_and_remove} + * directly (defined in its base class) and you will need to + * release the element returned by it. + */ + int remove (void); + + /// Delegates to ACE_Double_Linked_List_Iterator. + void dump (void) const; + +private: + ACE_DLList *list_; +}; + +/** + * @class ACE_DLList_Reverse_Iterator + * + * @brief A double-linked list container class iterator. + * + * This implementation uses ACE_Double_Linked_List_Iterator to + * perform the logic behind this container class. It delegates + * all of its calls to ACE_Double_Linked_List_Iterator. + */ +template +class ACE_DLList_Reverse_Iterator : public ACE_Double_Linked_List_Reverse_Iterator +{ + + friend class ACE_DLList; + friend class ACE_DLList_Node; + +public: + + // = Initialization method. + ACE_DLList_Reverse_Iterator (ACE_DLList &l); + + /** + * Retasks the iterator to iterate over a new + * Double_Linked_List. This allows clients to reuse an iterator + * without incurring the constructor overhead. If you do use this, + * be aware that if there are more than one reference to this + * iterator, the other "clients" may be very bothered when their + * iterator changes. + * @@ Here be dragons. Comments? + */ + void reset (ACE_DLList &l); + + // = Iteration methods. + /// Move forward by one element in the list. Returns 0 when all the + /// items in the list have been seen, else 1. + int advance (void); + + /// Pass back the {next_item} that hasn't been seen in the list. + /// Returns 0 when all items have been seen, else 1. + int next (T *&); + + /// @deprecated Delegates to ACE_Double_Linked_List_Iterator. + T *next (void) const; + + /// Removes the current item (i.e., {next}) from the list. + /// Note that DLList iterators do not support {advance_and_remove} + /// directly (defined in its base class) and you will need to + /// release the element returned by it. + int remove (void); + + /// Delegates to ACE_Double_Linked_List_Iterator. + void dump (void) const; + +private: + ACE_DLList *list_; +}; + +// Forward declaration. +template +class ACE_Fixed_Set; + +/** + * @class ACE_Fixed_Set_Iterator_Base + * + * @brief Implements a common base class for iterators for a unordered set. + */ +template +class ACE_Fixed_Set_Iterator_Base +{ +public: + // = Iteration methods. + + /// Pass back the {next_item} that hasn't been seen in the Set. + /// Returns 0 when all items have been seen, else 1. + int next (T *&next_item); + + /// Move forward by one element in the set. Returns 0 when all the + /// items in the set have been seen, else 1. + int advance (void); + + /// Move to the first element in the set. Returns 0 if the + /// set is empty, else 1. + int first (void); + + /// Returns 1 when all items have been seen, else 0. + int done (void) const; + + /// Declare the dynamic allocation hooks. + ACE_ALLOC_HOOK_DECLARE; + +protected: + // = Initialization method. + ACE_Fixed_Set_Iterator_Base (ACE_Fixed_Set &s); + + /// Set we are iterating over. + ACE_Fixed_Set &s_; + + /// How far we've advanced over the set. + ssize_t next_; + + /// The number of non free items that the iterator had pointed at. + size_t iterated_items_; + + /// Dump the state of an object. + void dump_i (void) const; + + /// Pass back the {next_item} that hasn't been seen in the Set. + /// Returns 0 when all items have been seen, else 1. + int next_i (T *&next_item); +}; + +/** + * @class ACE_Fixed_Set_Iterator + * + * @brief Iterates through an unordered set. + * + * This implementation of an unordered set uses a fixed array. + * Allows deletions while iteration is occurring. + */ +template +class ACE_Fixed_Set_Iterator : public ACE_Fixed_Set_Iterator_Base +{ +public: + // = Initialization method. + ACE_Fixed_Set_Iterator (ACE_Fixed_Set &s); + + // = Iteration methods. + + /// Pass back the {next_item} that hasn't been seen in the Set. + /// Returns 0 when all items have been seen, else 1. + int next (T *&next_item); + + /// Dump the state of an object. + void dump (void) const; + + /// Remove the item where the itearetor is located at. + /// Returns 1 if it removes a item, else 0. + /// Pass back the removed {item}. + int remove (T *&item); + + /// STL-like iterator dereference operator: returns a reference + /// to the node underneath the iterator. + T & operator* (void); + + /// Declare the dynamic allocation hooks. + ACE_ALLOC_HOOK_DECLARE; +}; + +/** + * @class ACE_Fixed_Set_Const_Iterator + * + * @brief Iterates through a const unordered set. + * + * This implementation of an unordered set uses a fixed array. + */ +template +class ACE_Fixed_Set_Const_Iterator : public ACE_Fixed_Set_Iterator_Base +{ +public: + // = Initialization method. + ACE_Fixed_Set_Const_Iterator (const ACE_Fixed_Set &s); + + // = Iteration methods. + + /// Pass back the {next_item} that hasn't been seen in the Set. + /// Returns 0 when all items have been seen, else 1. + int next (const T *&next_item); + + /// Dump the state of an object. + void dump (void) const; + + /// STL-like iterator dereference operator: returns a reference + /// to the node underneath the iterator. + const T & operator* (void) const ; + + /// Declare the dynamic allocation hooks. + ACE_ALLOC_HOOK_DECLARE; +}; + +/** + * @class ACE_Fixed_Set + * + * @brief Implement a simple unordered set of {T} with maximum {ACE_SIZE}. + * + * This implementation of an unordered set uses a fixed array. + * It does not allow duplicate members. The set provides linear insertion/deletion + * operations. + * + * Requirements and Performance Characteristics + * - Internal Structure + * Fixed array + * - Duplicates allowed? + * No + * - Random access allowed? + * No + * - Search speed + * Linear + * - Insert/replace speed + * Linear + * - Iterator still valid after change to container? + * Yes + * - Frees memory for removed elements? + * No + * - Items inserted by + * Value + * - Requirements for contained type + * -# Default constructor + * -# Copy constructor + * -# operator= + * -# operator== + * + */ +template +class ACE_Fixed_Set +{ +public: + friend class ACE_Fixed_Set_Iterator_Base; + friend class ACE_Fixed_Set_Iterator; + friend class ACE_Fixed_Set_Const_Iterator; + + // Trait definitions. + typedef ACE_Fixed_Set_Iterator ITERATOR; + typedef ACE_Fixed_Set_Const_Iterator CONST_ITERATOR; + + // = Initialization and termination methods. + /// Default Constructor. + /** + * Creates an empy set + */ + ACE_Fixed_Set (void); + + /// Copy constructor. + /** + * Initializes a set to be a copy of the set parameter. + */ + ACE_Fixed_Set (const ACE_Fixed_Set &); + + /// Assignment operator. + /** + * Deep copy of one set to another. + */ + void operator= (const ACE_Fixed_Set &); + + /// Destructor. + /** + * Destroys a set. + */ + ~ACE_Fixed_Set (void); + + // = Check boundary conditions. + + /// Returns 1 if the container is empty, otherwise returns 0. + /** + * Performs constant time check to determine if a set is empty. + */ + int is_empty (void) const; + + /// Returns 1 if the container is full, otherwise returns 0. + /** + * Performs a constant time check to see if the set is full. + */ + int is_full (void) const; + + // = Classic unordered set operations. + + ///Linear time insertion of an item unique to the set. + /** + * Insert @a new_item into the set (doesn't allow duplicates). + * Returns -1 if failures occur, 1 if item is already present, else + * 0. + */ + int insert (const T &new_item); + + ///Linear time removal operation of an item. + /** + * Remove first occurrence of {item} from the set. Returns 0 if + * it removes the item, -1 if it can't find the item, and -1 if a + * failure occurs. Removal doesn't reclaim memory for the @a item. + */ + int remove (const T &item); + + /// Finds if @a item occurs in the set. Returns 0 if finds, else -1. + /** + * Performs a linear find operation for the specified @a item. + */ + int find (const T &item) const; + + /// Size of the set. + /** + * Returns the current size of the set. + */ + size_t size (void) const; + + /// Dump the state of an object. + void dump (void) const; + + /// Declare the dynamic allocation hooks. + ACE_ALLOC_HOOK_DECLARE; + +private: + /// Holds the contents of the set. + struct + { + /// Item in the set. + T item_; + + /// Keeps track of whether this item is in use or not. + int is_free_; + } search_structure_[ACE_SIZE]; + + /// Current size of the set. + size_t cur_size_; + + /// Maximum size of the set. + size_t max_size_; +}; + +// Forward declaration. +template +class ACE_Bounded_Set; + +/** + * @class ACE_Bounded_Set_Iterator + * + * @brief Iterates through an unordered set. + * + * This implementation of an unordered set uses a Bounded array. + * Allows deletions while iteration is occurring. + */ +template +class ACE_Bounded_Set_Iterator +{ +public: + // = Initialization method. + ACE_Bounded_Set_Iterator (ACE_Bounded_Set &s); + + // = Iteration methods. + + /// Pass back the {next_item} that hasn't been seen in the Set. + /// Returns 0 when all items have been seen, else 1. + int next (T *&next_item); + + /// Move forward by one element in the set. Returns 0 when all the + /// items in the set have been seen, else 1. + int advance (void); + + /// Move to the first element in the set. Returns 0 if the + /// set is empty, else 1. + int first (void); + + /// Returns 1 when all items have been seen, else 0. + int done (void) const; + + /// Dump the state of an object. + void dump (void) const; + + /// Declare the dynamic allocation hooks. + ACE_ALLOC_HOOK_DECLARE; + +private: + /// Set we are iterating over. + ACE_Bounded_Set &s_; + + /// How far we've advanced over the set. + ssize_t next_; +}; + + +/** + * @class ACE_Bounded_Set + * + * @brief Implement a simple unordered set of {T} with maximum + * set at creation time. + * + * This implementation of an unordered set uses a Bounded array. + * This implementation does not allow duplicates. It provides + * linear insert/remove/find operations. Insertion/removal does not + * invalidate iterators, but caution should be taken to ensure + * expected behavior. Once initialized, the object has a maximum size + * which can only be increased by the assignment of another larger Bounded_Set. + * + * Requirements and Performance Characteristics + * - Internal Structure + * Bounded array which can grow via assignment + * - Duplicates allowed? + * No + * - Random access allowed? + * No + * - Search speed + * Linear + * - Insert/replace speed + * Linear + * - Iterator still valid after change to container? + * Yes + * - Frees memory for removed elements? + * No + * - Items inserted by + * Value + * - Requirements for contained type + * -# Default constructor + * -# Copy constructor + * -# operator= + * -# operator== + * + */ +template +class ACE_Bounded_Set +{ +public: + friend class ACE_Bounded_Set_Iterator; + + // Trait definition. + typedef ACE_Bounded_Set_Iterator ITERATOR; + + enum + { + DEFAULT_SIZE = 10 + }; + + // = Initialization and termination methods. + /// Construct a Bounded_Set using the default size. + /** + * The default constructor initializes the Bounded_Set to a maximum size + * specified by the DEFAULT_SIZE. + */ + ACE_Bounded_Set (void); + + /// Construct a Bounded_Set with the provided sizeB. + /** + * Initialize the Bounded_Set to have a maximum size equal to the size + * parameter specified. + */ + ACE_Bounded_Set (size_t size); + + /// Construct a Bounded_Set that is a copy of the provides Bounded_Set. + /** + * Initialize the Bounded_Set to be a copy of the Bounded_Set parameter. + */ + ACE_Bounded_Set (const ACE_Bounded_Set &); + + /// Assignment operator. + /** + * The assignment will make a deep copy of the Bounded_Set provided. If the + * rhs has more elements than the capacity of the lhs, then the lhs will be + * deleted and reallocated to accomadate the larger number of elements. + */ + void operator= (const ACE_Bounded_Set &); + + /// Destructor + /** + * Clean up the underlying dynamically allocated memory that is used by + * the Bounded_Set. + */ + ~ACE_Bounded_Set (void); + + // = Check boundary conditions. + + /// Returns 1 if the container is empty, otherwise returns 0. + /** + * A constant time check is performed to determine if the Bounded_Set is + * empty. + */ + int is_empty (void) const; + + /// Returns 1 if the container is full, otherwise returns 0. + /** + * Performs a constant time check to determine if the Bounded_Set is at + * capacity. + */ + int is_full (void) const; + + // = Classic unordered set operations. + + ///Inserts a new element unique to the set. + /** + * Insert @a new_item into the set (doesn't allow duplicates) in linear + * time. + * Returns -1 if failures occur, 1 if item is already present, else + * 0. + */ + int insert (const T &new_item); + + ///Finds the specified element and removes it from the set. + /** + * Remove first occurrence of @a item from the set. Returns 0 if it + * removes the item, -1 if it can't find the item, and -1 if a + * failure occurs. The linear remove operation does not reclaim the + * memory associated with the removed item. + */ + int remove (const T &item); + + /// Finds if @a item occurs in the set. Returns 0 if finds, else -1. + /** + * find preforms a linear search for {item} and returns 0 on successful + * find and -1 otherwise. + */ + int find (const T &item) const; + + /// Size of the set. + /** + * Returns a size_t representing the current size of the set. + */ + size_t size (void) const; + + /// Dump the state of an object. + void dump (void) const; + + /// Declare the dynamic allocation hooks. + ACE_ALLOC_HOOK_DECLARE; + +private: + struct Search_Structure + { + /// Item in the set. + T item_; + + /// Keeps track of whether this item is in use or not. + int is_free_; + }; + + /// Holds the contents of the set. + Search_Structure *search_structure_; + + /// Current size of the set. + size_t cur_size_; + + /// Maximum size of the set. + size_t max_size_; +}; + +/** + * @class ACE_Ordered_MultiSet_Iterator + * + * @brief Implement a bidirectional iterator over an ordered multiset. + * This class template requires that < operator semantics be + * defined for the parameterized type {T}, but does not impose + * any restriction on how that ordering operator is implemented. + */ +template +class ACE_Ordered_MultiSet_Iterator +{ +public: + friend class ACE_Ordered_MultiSet; + + // = Initialization method. + ACE_Ordered_MultiSet_Iterator (ACE_Ordered_MultiSet &s); + + // = Iteration methods. + + /// Pass back the {next_item} that hasn't been seen in the ordered multiset. + /// Returns 0 when all items have been seen, else 1. + int next (T *&next_item) const; + + /// Repositions the iterator at the first item in the ordered multiset + /// Returns 0 if the list is empty else 1. + int first (void); + + /// Repositions the iterator at the last item in the ordered multiset + /// Returns 0 if the list is empty else 1. + int last (void); + + /// Move forward by one element in the set. Returns 0 when all the + /// items in the set have been seen, else 1. + int advance (void); + + /// Move backward by one element in the set. Returns 0 when all the + /// items in the set have been seen, else 1. + int retreat (void); + + /// Returns 1 when all items have been seen, else 0. + int done (void) const; + + /// Dump the state of an object. + void dump (void) const; + + /// Returns a reference to the internal element {this} is pointing to. + T& operator* (void); + + /// Declare the dynamic allocation hooks. + ACE_ALLOC_HOOK_DECLARE; + +private: + + /// Pointer to the current node in the iteration. + ACE_DNode *current_; + + /// Pointer to the set we're iterating over. + ACE_Ordered_MultiSet &set_; +}; + + +/** + * @class ACE_Ordered_MultiSet + * + * @brief Implement a simple ordered multiset of {T} of unbounded size + * that allows duplicates. This class template requires that < + * operator semantics be defined for the parameterized type {T}, but + * does not impose any restriction on how that ordering operator is + * implemented. The set is implemented as a linked list. + * + * + * Requirements and Performance Characteristics + * - Internal Structure + * Double linked list + * - Duplicates allowed? + * Yes + * - Random access allowed? + * No + * - Search speed + * Linear + * - Insert/replace speed + * Linear + * - Iterator still valid after change to container? + * Yes + * - Frees memory for removed elements? + * Yes + * - Items inserted by + * Value + * - Requirements for contained type + * -# Default constructor + * -# Copy constructor + * -# operator= + * -# operator== + * -# operator< + * + * + */ +template +class ACE_Ordered_MultiSet +{ +public: + friend class ACE_Ordered_MultiSet_Iterator; + + // Trait definition. + typedef ACE_Ordered_MultiSet_Iterator ITERATOR; + + // = Initialization and termination methods. + /// Constructor. Use user specified allocation strategy + /// if specified. + /** + * Initialize the set using the allocation strategy specified. If none, use the + * default strategy. + */ + ACE_Ordered_MultiSet (ACE_Allocator *the_allocator = 0); + + /// Copy constructor. + /** + * Initialize the set to be a copy of the provided set. + */ + ACE_Ordered_MultiSet (const ACE_Ordered_MultiSet &); + + /// Destructor. + /** + * Delete the nodes of the set. + */ + ~ACE_Ordered_MultiSet (void); + + /// Assignment operator. + /** + * Delete the nodes in lhs, and copy the nodes from the rhs. + */ + void operator= (const ACE_Ordered_MultiSet &); + + // = Check boundary conditions. + + /// Returns 1 if the container is empty, otherwise returns 0. + /** + * Constant time check to determine if the set is empty. + */ + int is_empty (void) const; + + /// Size of the set. + /** + * Constant time check to determine the size of the set. + */ + size_t size (void) const; + + // = Classic unordered set operations. + + /// Insert @a new_item into the ordered multiset. + /// Returns -1 if failures occur, else 0. + /** + * Linear time, order preserving insert into the set beginning at the head. + */ + int insert (const T &new_item); + + ///Linear time insert beginning at the point specified by the provided iterator. + /** + * Insert @a new_item into the ordered multiset, starting its search at + * the node pointed to by the iterator, and if insertion was successful, + * updates the iterator to point to the newly inserted node. + * Returns -1 if failures occur, else 0. + */ + int insert (const T &new_item, ITERATOR &iter); + + /// Remove first occurrence of @a item from the set. Returns 0 if + /// it removes the item, -1 if it can't find the item. + /** + * Linear time search operation which removes the item from the set if found . + */ + int remove (const T &item); + + ///Linear find operation. + /** + * Finds first occurrence of @a item in the multiset, using the iterator's + * current position as a hint to improve performance. If find succeeds, + * it positions the iterator at that node and returns 0, or if it cannot + * locate the node, it leaves the iterator alone and just returns -1. + */ + int find (const T &item, ITERATOR &iter) const; + + /// Reset the ACE_Ordered_MultiSet to be empty. + /** + * Delete the nodes inside the set. + */ + void reset (void); + + /// Dump the state of an object. + void dump (void) const; + + /// Declare the dynamic allocation hooks. + ACE_ALLOC_HOOK_DECLARE; + +private: + + /** + * Insert @a item, starting its search at the position given, + * and if successful updates the passed pointer to point to + * the newly inserted item's node. + */ + int insert_from (const T &item, ACE_DNode *start_position, + ACE_DNode **new_position); + + /** + * Looks for first occurance of @a item in the ordered set, using the + * passed starting position as a hint: if there is such an instance, it + * updates the new_position pointer to point to this node and returns 0; + * if there is no such node, then if there is a node before where the + * item would have been, it updates the new_position pointer to point + * to this node and returns -1; if there is no such node, then if there + * is a node after where the item would have been, it updates the + * new_position pointer to point to this node (or 0 if there is no such + * node) and returns 1; + */ + int locate (const T &item, ACE_DNode *start_position, + ACE_DNode *&new_position) const; + + /// Delete all the nodes in the Set. + void delete_nodes (void); + + /// Copy nodes into this set. + void copy_nodes (const ACE_Ordered_MultiSet &); + + /// Head of the bilinked list of Nodes. + ACE_DNode *head_; + + /// Head of the bilinked list of Nodes. + ACE_DNode *tail_; + + /// Current size of the set. + size_t cur_size_; + + /// Allocation strategy of the set. + ACE_Allocator *allocator_; +}; + +// **************************************************************** + +/** + * @class ACE_Array + * + * @brief A dynamic array class. + * + * This class extends ACE_Array_Base, adding comparison operators. + * + * Requirements and Performance Characteristics + * - Internal Structure + * Dynamic array + * - Duplicates allowed? + * Yes + * - Random access allowed? + * Yes + * - Search speed + * N/A + * - Insert/replace speed + * O(1) + * - Iterator still valid after change to container? + * - In general, yes. + * - If array size is changed during iteration, no. + * - Frees memory for removed elements? + * No + * - Items inserted by + * Value + * - Requirements for contained type + * -# Default constructor + * -# Copy constructor + * -# operator= + * -# operator!= + * + * @sa ACE_Array_Base. This class inherits its operations and requirements. + */ +template +class ACE_Array : public ACE_Array_Base +{ +public: + // Define a "trait" + typedef T TYPE; + + typedef ACE_Array_Iterator ITERATOR; + + // = Exceptions. + + // = Initialization and termination methods. + + /// Dynamically create an uninitialized array. + /** + * Initialize an empty array of the specified size using the provided + * allocation strategy. + */ + ACE_Array (size_t size = 0, + ACE_Allocator* alloc = 0); + + /// Dynamically initialize the entire array to the {default_value}. + /** + * Initialize an array the given size placing the default_value in each index. + */ + ACE_Array (size_t size, + const T &default_value, + ACE_Allocator* alloc = 0); + + ///Copy constructor. + /** + * The copy constructor performs initialization by making an exact + * copy of the contents of parameter {s}, i.e., *this == s will + * return true. + */ + ACE_Array (const ACE_Array &s); + + ///Assignment operator + /** + * Assignment operator performs an assignment by making an exact + * copy of the contents of parameter {s}, i.e., *this == s will + * return true. Note that if the {max_size_} of {array_} is >= than + * {s.max_size_} we can copy it without reallocating. However, if + * {max_size_} is < {s.max_size_} we must delete the {array_}, + * reallocate a new {array_}, and then copy the contents of {s}. + */ + void operator= (const ACE_Array &s); + + // = Compare operators + + ///Equality comparison operator. + /** + * Compare this array with {s} for equality. Two arrays are equal + * if their {size}'s are equal and all the elements from 0 .. {size} + * are equal. + */ + bool operator== (const ACE_Array &s) const; + + ///Inequality comparison operator. + /** + * Compare this array with {s} for inequality such that {*this} != + * {s} is always the complement of the boolean return value of + * {*this} == {s}. + */ + bool operator!= (const ACE_Array &s) const; +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +#include "ace/Containers_T.inl" +#endif /* __ACE_INLINE__ */ + +#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) +#include "ace/Containers_T.cpp" +#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ + +#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) +#pragma implementation ("Containers_T.cpp") +#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ + +#include /**/ "ace/post.h" + +#endif /* ACE_CONTAINERS_T_H */ diff --git a/dep/ACE_wrappers/ace/Containers_T.inl b/dep/ACE_wrappers/ace/Containers_T.inl new file mode 100644 index 00000000000..912c9df8bb8 --- /dev/null +++ b/dep/ACE_wrappers/ace/Containers_T.inl @@ -0,0 +1,479 @@ +// -*- C++ -*- +// +// $Id: Containers_T.inl 80826 2008-03-04 14:51:23Z wotte $ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +template ACE_INLINE int +ACE_Bounded_Stack::is_empty (void) const +{ + ACE_TRACE ("ACE_Bounded_Stack::is_empty"); + return this->top_ == 0; +} + +template ACE_INLINE int +ACE_Bounded_Stack::is_full (void) const +{ + ACE_TRACE ("ACE_Bounded_Stack::is_full"); + return this->top_ >= this->size_; +} + +template ACE_INLINE int +ACE_Bounded_Stack::push (const T &new_item) +{ + ACE_TRACE ("ACE_Bounded_Stack::push"); + if (this->is_full () == 0) + { + this->stack_[this->top_++] = new_item; + return 0; + } + else + return -1; +} + +template ACE_INLINE int +ACE_Bounded_Stack::pop (T &item) +{ + ACE_TRACE ("ACE_Bounded_Stack::pop"); + if (this->is_empty () == 0) + { + item = this->stack_[--this->top_]; + return 0; + } + else + return -1; +} + +template ACE_INLINE int +ACE_Bounded_Stack::top (T &item) const +{ + ACE_TRACE ("ACE_Bounded_Stack::top"); + if (this->is_empty () == 0) + { + item = this->stack_[this->top_ - 1]; + return 0; + } + else + return -1; +} + +template ACE_INLINE size_t +ACE_Bounded_Stack::size (void) const +{ + return this->size_; +} + +//---------------------------------------- + +template ACE_INLINE int +ACE_Fixed_Stack::is_empty (void) const +{ + ACE_TRACE ("ACE_Fixed_Stack::is_empty"); + return this->top_ == 0; +} + +template ACE_INLINE int +ACE_Fixed_Stack::is_full (void) const +{ + ACE_TRACE ("ACE_Fixed_Stack::is_full"); + return this->top_ >= this->size_; +} + +template ACE_INLINE int +ACE_Fixed_Stack::push (const T &new_item) +{ + ACE_TRACE ("ACE_Fixed_Stack::push"); + if (this->is_full () == 0) + { + this->stack_[this->top_++] = new_item; + return 0; + } + else + return -1; +} + +template ACE_INLINE int +ACE_Fixed_Stack::pop (T &item) +{ + ACE_TRACE ("ACE_Fixed_Stack::pop"); + if (this->is_empty () == 0) + { + item = this->stack_[--this->top_]; + return 0; + } + else + return -1; +} + +template ACE_INLINE int +ACE_Fixed_Stack::top (T &item) const +{ + ACE_TRACE ("ACE_Fixed_Stack::top"); + if (this->is_empty () == 0) + { + item = this->stack_[this->top_ - 1]; + return 0; + } + else + return -1; +} + +template ACE_INLINE size_t +ACE_Fixed_Stack::size (void) const +{ + return this->size_; +} + +template ACE_INLINE int +ACE_Unbounded_Stack::is_empty (void) const +{ + // ACE_TRACE ("ACE_Unbounded_Stack::is_empty"); + return this->head_ == this->head_->next_; +} + +template ACE_INLINE int +ACE_Unbounded_Stack::top (T &item) const +{ + ACE_TRACE ("ACE_Unbounded_Stack::top"); + if (this->is_empty () == 0) + { + item = this->head_->next_->item_; + return 0; + } + else + return -1; +} + +template ACE_INLINE int +ACE_Unbounded_Stack::is_full (void) const +{ + ACE_TRACE ("ACE_Unbounded_Stack::is_full"); + return 0; // ??? +} + +template ACE_INLINE size_t +ACE_Unbounded_Stack::size (void) const +{ + return this->cur_size_; +} + +// --- + + +// --- + +template ACE_INLINE int +ACE_Fixed_Set::is_empty (void) const +{ + ACE_TRACE ("ACE_Fixed_Set::is_empty"); + return this->cur_size_ == 0; +} + +template ACE_INLINE int +ACE_Fixed_Set::is_full (void) const +{ + ACE_TRACE ("ACE_Fixed_Set::is_full"); + return this->cur_size_ == this->max_size_; +} + +// --- + +template ACE_INLINE int +ACE_Bounded_Set::is_empty (void) const +{ + ACE_TRACE ("ACE_Bounded_Set::is_empty"); + return this->cur_size_ == 0; +} + +template ACE_INLINE int +ACE_Bounded_Set::is_full (void) const +{ + ACE_TRACE ("ACE_Bounded_Set::is_full"); + return this->cur_size_ == this->max_size_; +} + +// -- + +template ACE_INLINE int +ACE_Ordered_MultiSet_Iterator::first (void) +{ + ACE_TRACE ("ACE_Ordered_MultiSet_Iterator::first"); + current_ = set_.head_; + + return (current_ ? 1 : 0); +} + +template ACE_INLINE int +ACE_Ordered_MultiSet_Iterator::last (void) +{ + ACE_TRACE ("ACE_Ordered_MultiSet_Iterator::last"); + current_ = set_.tail_; + + return (current_ ? 1 : 0); +} + +template ACE_INLINE int +ACE_Ordered_MultiSet_Iterator::advance (void) +{ + ACE_TRACE ("ACE_Ordered_MultiSet_Iterator::advance"); + + current_ = current_ ? current_->next_ : 0; + + return (current_ ? 1 : 0); +} + +template ACE_INLINE int +ACE_Ordered_MultiSet_Iterator::retreat (void) +{ + ACE_TRACE ("ACE_Ordered_MultiSet_Iterator::retreat"); + + current_ = current_ ? current_->prev_ : 0; + + return (current_ ? 1 : 0); +} + +template ACE_INLINE int +ACE_Ordered_MultiSet_Iterator::done (void) const +{ + ACE_TRACE ("ACE_Ordered_MultiSet_Iterator::done"); + + return (current_ ? 0 : 1); +} + +template ACE_INLINE void +ACE_Ordered_MultiSet_Iterator::dump (void) const +{ +#if defined (ACE_HAS_DUMP) +// ACE_TRACE ("ACE_Ordered_MultiSet_Iterator::dump"); +#endif /* ACE_HAS_DUMP */ +} + + + +// -- + +template ACE_INLINE int +ACE_Ordered_MultiSet::is_empty (void) const +{ + ACE_TRACE ("ACE_Ordered_MultiSet::is_empty"); + return this->cur_size_ > 0 ? 0 : 1; +} + +template ACE_INLINE size_t +ACE_Ordered_MultiSet::size (void) const +{ +// ACE_TRACE ("ACE_Ordered_MultiSet::size"); + return this->cur_size_; +} + +// **************************************************************** + +template ACE_INLINE +ACE_Array::ACE_Array (size_t size, + ACE_Allocator *alloc) + : ACE_Array_Base (size, alloc) +{ +} + +template ACE_INLINE +ACE_Array::ACE_Array (size_t size, + const T &default_value, + ACE_Allocator *alloc) + : ACE_Array_Base (size, default_value, alloc) +{ +} + +// The copy constructor (performs initialization). + +template ACE_INLINE +ACE_Array::ACE_Array (const ACE_Array &s) + : ACE_Array_Base (s) +{ +} + +// Assignment operator (performs assignment). + +template ACE_INLINE void +ACE_Array::operator= (const ACE_Array &s) +{ + // Check for "self-assignment". + + if (this != &s) + this->ACE_Array_Base::operator= (s); +} + +// Compare this array with for inequality. + +template ACE_INLINE bool +ACE_Array::operator!= (const ACE_Array &s) const +{ + return !(*this == s); +} + +// **************************************************************** + + +// **************************************************************** + +template ACE_INLINE void +ACE_DLList::operator= (const ACE_DLList &l) +{ + *(ACE_DLList_Base *) this = l; +} + +template ACE_INLINE int +ACE_DLList::get (T *&item, size_t index) +{ + ACE_DLList_Node *node; + int result = ACE_DLList_Base::get (node, index); + if (result != -1) + item = (T *) node->item_; + return result; +} + +template ACE_INLINE void +ACE_DLList::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + ACE_DLList_Base::dump (); +#endif /* ACE_HAS_DUMP */ +} + +template ACE_INLINE int +ACE_DLList::remove (ACE_DLList_Node *n) +{ + int result = ACE_DLList_Base::remove (n); + ACE_DES_FREE (n, + this->allocator_->free, + ACE_DLList_Node); + return result; +} + +template ACE_INLINE +ACE_DLList::ACE_DLList (ACE_Allocator *alloc) + : ACE_DLList_Base (alloc) +{ +} + +template ACE_INLINE +ACE_DLList::ACE_DLList (const ACE_DLList &l) + : ACE_DLList_Base ((ACE_DLList &) l) +{ +} + +template ACE_INLINE +ACE_DLList::~ACE_DLList (void) +{ + while (this->delete_head ()) ; +} + +template ACE_INLINE int +ACE_DLList_Iterator::remove (void) +{ + ACE_DLList_Node *temp = this->ACE_Double_Linked_List_Iterator ::next (); + this->ACE_Double_Linked_List_Iterator ::advance (); + return list_->remove (temp); +} + +template ACE_INLINE +ACE_DLList_Iterator::ACE_DLList_Iterator (ACE_DLList &l) + : ACE_Double_Linked_List_Iterator ((ACE_DLList_Base &)l), + list_ (&l) +{ +} + +template ACE_INLINE void +ACE_DLList_Iterator::reset (ACE_DLList &l) +{ + list_ = &l; + this->ACE_Double_Linked_List_Iterator ::reset ((ACE_DLList_Base &)l); +} + +template ACE_INLINE int +ACE_DLList_Iterator::next (T *&ptr) +{ + ACE_DLList_Node *temp = + ACE_Double_Linked_List_Iterator ::next (); + if (temp) + ptr = (T *) temp->item_; + return temp ? 1 : 0; +} + +template ACE_INLINE T * +ACE_DLList_Iterator::next (void) const +{ + ACE_DLList_Node *temp = ACE_Double_Linked_List_Iterator ::next (); + return (T *) (temp ? temp->item_ : 0); +} + +template ACE_INLINE int +ACE_DLList_Iterator::advance (void) +{ + return this->ACE_Double_Linked_List_Iterator ::advance (); +} + +template ACE_INLINE void +ACE_DLList_Iterator::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + ACE_Double_Linked_List_Iterator ::dump (); +#endif /* ACE_HAS_DUMP */ +} + + +template ACE_INLINE int +ACE_DLList_Reverse_Iterator::remove (void) +{ + ACE_DLList_Node *temp = ACE_Double_Linked_List_Reverse_Iterator ::next (); + this->ACE_Double_Linked_List_Reverse_Iterator ::advance (); + return list_->remove (temp); +} + +template ACE_INLINE +ACE_DLList_Reverse_Iterator::ACE_DLList_Reverse_Iterator (ACE_DLList &l) + : ACE_Double_Linked_List_Reverse_Iterator ((ACE_DLList_Base &)l), + list_ (&l) +{ +} + +template ACE_INLINE void +ACE_DLList_Reverse_Iterator::reset (ACE_DLList &l) +{ + list_ = &l; + this->ACE_Double_Linked_List_Reverse_Iterator ::reset ((ACE_DLList_Base &)l); +} + +template ACE_INLINE int +ACE_DLList_Reverse_Iterator::advance (void) +{ + return ACE_Double_Linked_List_Reverse_Iterator ::advance (); +} + +template ACE_INLINE int +ACE_DLList_Reverse_Iterator::next (T *&ptr) +{ + ACE_DLList_Node *temp = + ACE_Double_Linked_List_Reverse_Iterator ::next (); + if (temp == 0) + return 0; + ptr = (T *) temp->item_; + return 1; +} + +template ACE_INLINE T * +ACE_DLList_Reverse_Iterator::next (void) const +{ + ACE_DLList_Node *temp = ACE_Double_Linked_List_Reverse_Iterator ::next (); + return (T *) (temp ? temp->item_ : 0); +} + + +template ACE_INLINE void +ACE_DLList_Reverse_Iterator::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + ACE_Double_Linked_List_Reverse_Iterator ::dump (); +#endif /* ACE_HAS_DUMP */ +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Copy_Disabled.cpp b/dep/ACE_wrappers/ace/Copy_Disabled.cpp new file mode 100644 index 00000000000..6878311197d --- /dev/null +++ b/dep/ACE_wrappers/ace/Copy_Disabled.cpp @@ -0,0 +1,23 @@ +/** + * @file Copy_Disabled.cpp + * + * $Id: Copy_Disabled.cpp 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Carlos O'Ryan + */ + +#include "ace/Copy_Disabled.h" + + +ACE_RCSID (ace, + Copy_Disabled, + "$Id: Copy_Disabled.cpp 80826 2008-03-04 14:51:23Z wotte $") + + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_Copy_Disabled::ACE_Copy_Disabled (void) +{ +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Copy_Disabled.h b/dep/ACE_wrappers/ace/Copy_Disabled.h new file mode 100644 index 00000000000..f7b40e26422 --- /dev/null +++ b/dep/ACE_wrappers/ace/Copy_Disabled.h @@ -0,0 +1,65 @@ +// -*- C++ -*- + +//=========================================================================== +/** + * @file Copy_Disabled.h + * + * $Id: Copy_Disabled.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Carlos O'Ryan + */ +//=========================================================================== + +#ifndef ACE_COPY_DISABLED_H +#define ACE_COPY_DISABLED_H + +#include /**/ "ace/pre.h" + +#include /**/ "ace/ACE_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +/** + * @class ACE_Copy_Disabled + * + * @brief Helper class to disable copy construction and assignment + * + * Classes used to control OS and other resources are not "canonical", + * i.e. they have their copy constructor and assignment operators + * disabled. + * This is often done by making the copy constructor and assignment + * operators private, effectively disallowing copying by clients of + * the class (including derived classes). If the copy constructor and + * assingment operators are left unimplemented then the class itself + * cannot make any copies of its instances, because it would result in + * link errors. + * + * To use this class simply use private inheritance: + * + * class Foo : private ACE_Copy_Disabled + * { + * // code here + * }; + * + */ +class ACE_Export ACE_Copy_Disabled +{ +public: + + /// Default constructor + ACE_Copy_Disabled (void); + +private: + ACE_Copy_Disabled (const ACE_Copy_Disabled &); + ACE_Copy_Disabled &operator= (const ACE_Copy_Disabled &); +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#include /**/ "ace/post.h" + +#endif /* ACE_COPY_DISABLED_H */ diff --git a/dep/ACE_wrappers/ace/Countdown_Time.cpp b/dep/ACE_wrappers/ace/Countdown_Time.cpp new file mode 100644 index 00000000000..dbb2ca55ad1 --- /dev/null +++ b/dep/ACE_wrappers/ace/Countdown_Time.cpp @@ -0,0 +1,66 @@ +#include "ace/Countdown_Time.h" +#include "ace/OS_NS_sys_time.h" + +ACE_RCSID (ace, + Countdown_Time, + "$Id: Countdown_Time.cpp 80826 2008-03-04 14:51:23Z wotte $") + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_Countdown_Time::ACE_Countdown_Time (ACE_Time_Value *max_wait_time) + : max_wait_time_ (max_wait_time), + stopped_ (false) +{ + this->start (); +} + +ACE_Countdown_Time::~ACE_Countdown_Time (void) +{ + this->stop (); +} + +void +ACE_Countdown_Time::start (void) +{ + if (this->max_wait_time_ != 0) + { + this->start_time_ = ACE_OS::gettimeofday (); + this->stopped_ = false; + } +} + +bool +ACE_Countdown_Time::stopped (void) const +{ + return stopped_; +} + +void +ACE_Countdown_Time::stop (void) +{ + if (this->max_wait_time_ != 0 && this->stopped_ == false) + { + ACE_Time_Value elapsed_time = ACE_OS::gettimeofday () - this->start_time_; + + if (*this->max_wait_time_ > elapsed_time) + { + *this->max_wait_time_ -= elapsed_time; + } + else + { + // Used all of timeout. + *this->max_wait_time_ = ACE_Time_Value::zero; + // errno = ETIME; + } + this->stopped_ = true; + } +} + +void +ACE_Countdown_Time::update (void) +{ + this->stop (); + this->start (); +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Countdown_Time.h b/dep/ACE_wrappers/ace/Countdown_Time.h new file mode 100644 index 00000000000..c12cfb10874 --- /dev/null +++ b/dep/ACE_wrappers/ace/Countdown_Time.h @@ -0,0 +1,80 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Countdown_Time.h + * + * $Id: Countdown_Time.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Douglas C. Schmidt + */ +//============================================================================= + +#ifndef ACE_COUNTDOWN_TIME_H +#define ACE_COUNTDOWN_TIME_H + +#include /**/ "ace/pre.h" + +#include /**/ "ace/ACE_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/Time_Value.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +/** + * @class ACE_Countdown_Time + * + * @brief Keeps track of the amount of elapsed time. + * + * This class has a side-effect on the @c max_wait_time -- every + * time the stop() method is called the @c max_wait_time is + * updated. + */ +class ACE_Export ACE_Countdown_Time +{ +public: + /// Cache the @a max_wait_time and call @c start(). + ACE_Countdown_Time (ACE_Time_Value *max_wait_time); + + /// Destructor, makes sure the max_wait_time that got passed as pointer + /// to the constructor is updated with the time elapsed. + ~ACE_Countdown_Time (void); + + /// Cache the current time and enter a start state. + void start (void); + + /// Subtract the elapsed time from max_wait_time_ and enter a stopped + /// state. + void stop (void); + + /// Calls stop and then start. max_wait_time_ is modified by the + /// call to stop. + void update (void); + + /// Returns true if we've already been stopped, else false. + bool stopped (void) const; + +private: + /// Maximum time we were willing to wait. + ACE_Time_Value *max_wait_time_; + + /// Beginning of the start time. + ACE_Time_Value start_time_; + + /// Keeps track of whether we've already been stopped. + bool stopped_; + + // Prevent copying + ACE_Countdown_Time (const ACE_Countdown_Time &); + ACE_Countdown_Time &operator= (const ACE_Countdown_Time &); +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#include /**/ "ace/post.h" + +#endif /* ACE_COUNTDOWN_TIME_H */ diff --git a/dep/ACE_wrappers/ace/DEV.cpp b/dep/ACE_wrappers/ace/DEV.cpp new file mode 100644 index 00000000000..42178a68e6b --- /dev/null +++ b/dep/ACE_wrappers/ace/DEV.cpp @@ -0,0 +1,43 @@ +// $Id: DEV.cpp 80826 2008-03-04 14:51:23Z wotte $ + +#include "ace/DEV.h" + +#include "ace/OS_NS_unistd.h" + +#if !defined (__ACE_INLINE__) +#include "ace/DEV.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(ace, DEV, "$Id: DEV.cpp 80826 2008-03-04 14:51:23Z wotte $") + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_ALLOC_HOOK_DEFINE(ACE_DEV) + +void +ACE_DEV::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + ACE_TRACE ("ACE_DEV::dump"); +#endif /* ACE_HAS_DUMP */ +} + +// This is the do-nothing constructor. + +ACE_DEV::ACE_DEV (void) +{ + ACE_TRACE ("ACE_DEV::ACE_DEV"); +} + +// Close the device + +int +ACE_DEV::close (void) +{ + ACE_TRACE ("ACE_DEV::close"); + int result = ACE_OS::close (this->get_handle ()); + this->set_handle (ACE_INVALID_HANDLE); + return result; +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/DEV.h b/dep/ACE_wrappers/ace/DEV.h new file mode 100644 index 00000000000..86f8d5dc863 --- /dev/null +++ b/dep/ACE_wrappers/ace/DEV.h @@ -0,0 +1,78 @@ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file DEV.h + * + * $Id: DEV.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Gerhard Lenzer + */ +//============================================================================= + + +#ifndef ACE_DEV_H +#define ACE_DEV_H +#include /**/ "ace/pre.h" + +#include "ace/IO_SAP.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/DEV_Addr.h" + +// The following is necessary since many C++ compilers don't support +// typedef'd types inside of classes used as formal template +// arguments... ;-(. Luckily, using the C++ preprocessor I can hide +// most of this nastiness! + +#if defined (ACE_HAS_TEMPLATE_TYPEDEFS) +#define ACE_DEV_CONNECTOR ACE_DEV_Connector +#define ACE_DEV_STREAM ACE_DEV_IO +#else /* TEMPLATES are broken (must be a cfront-based compiler...) */ +#define ACE_DEV_CONNECTOR ACE_DEV_Connector, ACE_DEV_Addr +#define ACE_DEV_STREAM ACE_DEV_IO, ACE_DEV_Addr +#endif /* ACE_TEMPLATE_TYPEDEFS */ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +/** + * @class ACE_DEV + * + * @brief Defines the member functions for the base class of the + * ACE_DEV abstraction. + */ +class ACE_Export ACE_DEV : public ACE_IO_SAP +{ +public: + /// Close down the DEVICE + int close (void); + + /// Dump the state of an object. + void dump (void) const; + + /// Declare the dynamic allocation hooks. + ACE_ALLOC_HOOK_DECLARE; + + /** + * Disable signal @a signum + * This is here to prevent Win32 from + * disabling SPIPE using socket calls + */ + int disable (int signum) const ; + +protected: + /// Ensure that this class is an abstract base class + ACE_DEV (void); +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +#include "ace/DEV.inl" +#endif /* __ACE_INLINE__ */ + +#include /**/ "ace/post.h" +#endif /* ACE_DEV_H */ diff --git a/dep/ACE_wrappers/ace/DEV.inl b/dep/ACE_wrappers/ace/DEV.inl new file mode 100644 index 00000000000..4d97a73d8e8 --- /dev/null +++ b/dep/ACE_wrappers/ace/DEV.inl @@ -0,0 +1,18 @@ +// -*- C++ -*- +// +// $Id: DEV.inl 80826 2008-03-04 14:51:23Z wotte $ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_INLINE int +ACE_DEV::disable (int signum) const +{ +#if defined (ACE_WIN32) + ACE_UNUSED_ARG (signum) ; + return 0 ; +#else /* ACE_WIN32 */ + return ACE_IO_SAP::disable (signum) ; +#endif /* ACE_WIN32 */ +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/DEV_Addr.cpp b/dep/ACE_wrappers/ace/DEV_Addr.cpp new file mode 100644 index 00000000000..64bbb50873c --- /dev/null +++ b/dep/ACE_wrappers/ace/DEV_Addr.cpp @@ -0,0 +1,108 @@ +// $Id: DEV_Addr.cpp 80826 2008-03-04 14:51:23Z wotte $ + +#include "ace/DEV_Addr.h" +#if !defined (__ACE_INLINE__) +#include "ace/DEV_Addr.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/Log_Msg.h" +#include "ace/OS_NS_string.h" + +ACE_RCSID (ace, + DEV_Addr, + "$Id: DEV_Addr.cpp 80826 2008-03-04 14:51:23Z wotte $") + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_ALLOC_HOOK_DEFINE(ACE_DEV_Addr) + +// Transform the current address into string format. + +int +ACE_DEV_Addr::addr_to_string (ACE_TCHAR *s, size_t len) const +{ + ACE_TRACE ("ACE_DEV_Addr::addr_to_string"); + + ACE_OS::strsncpy (s, this->devname_, len); + return 0; +} + +// Return a pointer to the address. + +void * +ACE_DEV_Addr::get_addr (void) const +{ + ACE_TRACE ("ACE_DEV_Addr::get_addr"); + + return (void *) &this->devname_; +} + +void +ACE_DEV_Addr::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + ACE_TRACE ("ACE_DEV_Addr::dump"); + + ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("devname_ = %s"), this->devname_)); + ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); +#endif /* ACE_HAS_DUMP */ +} + +// Do nothing constructor. + +ACE_DEV_Addr::ACE_DEV_Addr (void) + : ACE_Addr (AF_DEV, sizeof this->devname_) +{ + ACE_TRACE ("ACE_DEV_Addr::ACE_DEV_Addr"); + + (void) ACE_OS::memset ((void *) &this->devname_, + 0, sizeof this->devname_); +} + +int +ACE_DEV_Addr::set (const ACE_DEV_Addr &sa) +{ + this->base_set (sa.get_type (), sa.get_size ()); + + if (sa.get_type () == AF_ANY) + (void) ACE_OS::memset ((void *) &this->devname_, + 0, + sizeof this->devname_); + else + (void) ACE_OS::strsncpy (this->devname_, + sa.devname_, + ACE_DEV_Addr::DEVNAME_LENGTH); + return 0; +} + +// Copy constructor. + +ACE_DEV_Addr::ACE_DEV_Addr (const ACE_DEV_Addr &sa) + : ACE_Addr (AF_DEV, sizeof this->devname_) +{ + ACE_TRACE ("ACE_DEV_Addr::ACE_DEV_Addr"); + + this->set (sa); +} + +ACE_DEV_Addr::ACE_DEV_Addr (const ACE_TCHAR *devname) + : ACE_Addr (AF_DEV, sizeof this->devname_) +{ + ACE_TRACE ("ACE_DEV_Addr::ACE_DEV_Addr"); + + this->set (devname); +} + +ACE_DEV_Addr & +ACE_DEV_Addr::operator= (const ACE_DEV_Addr &sa) +{ + ACE_TRACE ("ACE_DEV_Addr::operator="); + + if (this != &sa) + this->set (sa); + + return *this; +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/DEV_Addr.h b/dep/ACE_wrappers/ace/DEV_Addr.h new file mode 100644 index 00000000000..49ec5023a7c --- /dev/null +++ b/dep/ACE_wrappers/ace/DEV_Addr.h @@ -0,0 +1,90 @@ +// -*- C++ -*- + +//========================================================================== +/** + * @file DEV_Addr.h + * + * $Id: DEV_Addr.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Gerhard Lenzer and Douglas C. Schmidt + */ +//========================================================================== + +#ifndef ACE_DEV_ADDR_H +#define ACE_DEV_ADDR_H + +#include /**/ "ace/pre.h" + +#include "ace/Addr.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/os_include/os_dirent.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +/** + * @class ACE_DEV_Addr + * + * @brief Defines device address family address format. + */ +class ACE_Export ACE_DEV_Addr : public ACE_Addr +{ +public: + // = Initialization methods. + /// Default constructor. + ACE_DEV_Addr (void); + + /// Copy constructor. + ACE_DEV_Addr (const ACE_DEV_Addr &sa); + + /// Acts like a copy constructor. + int set (const ACE_DEV_Addr &sa); + + /// Create a ACE_DEV_Addr from a device name. + explicit ACE_DEV_Addr (const ACE_TCHAR *devname); + + /// Create a ACE_Addr from a ACE_DEV pathname. + void set (const ACE_TCHAR *devname); + + /// Assignment operator. + ACE_DEV_Addr &operator= (const ACE_DEV_Addr &); + + /// Return a pointer to the address. + virtual void *get_addr (void) const; + + /// Transform the current address into string format. + virtual int addr_to_string (ACE_TCHAR *addr, size_t) const; + + /// Compare two addresses for equality. + bool operator == (const ACE_DEV_Addr &SAP) const; + + /// Compare two addresses for inequality. + bool operator != (const ACE_DEV_Addr &SAP) const; + + /// Return the path name used for the rendezvous point. + const ACE_TCHAR *get_path_name (void) const; + + /// Dump the state of an object. + void dump (void) const; + + /// Declare the dynamic allocation hooks. + ACE_ALLOC_HOOK_DECLARE; + +private: + enum { DEVNAME_LENGTH = MAXPATHLEN + 1 }; + /// Name of the device. + ACE_TCHAR devname_[DEVNAME_LENGTH]; +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +#include "ace/DEV_Addr.inl" +#endif /* __ACE_INLINE__ */ + +#include /**/ "ace/post.h" + +#endif /* ACE_DEV_ADDR_H */ diff --git a/dep/ACE_wrappers/ace/DEV_Addr.inl b/dep/ACE_wrappers/ace/DEV_Addr.inl new file mode 100644 index 00000000000..5c1da68d7e7 --- /dev/null +++ b/dep/ACE_wrappers/ace/DEV_Addr.inl @@ -0,0 +1,51 @@ +// -*- C++ -*- +// +// $Id: DEV_Addr.inl 80826 2008-03-04 14:51:23Z wotte $ + +#include "ace/OS_NS_string.h" +#include "ace/Global_Macros.h" +#include "ace/os_include/sys/os_socket.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_INLINE void +ACE_DEV_Addr::set (const ACE_TCHAR *devname) +{ + ACE_TRACE ("ACE_DEV_Addr::set"); + + this->ACE_Addr::base_set + (AF_DEV, static_cast (ACE_OS::strlen (devname))); + ACE_OS::strsncpy (this->devname_, devname, ACE_DEV_Addr::DEVNAME_LENGTH); +} + +// Compare two addresses for equality. + +ACE_INLINE bool +ACE_DEV_Addr::operator == (const ACE_DEV_Addr &sap) const +{ + ACE_TRACE ("ACE_DEV_Addr::operator =="); + + return ACE_OS::strcmp (this->devname_, sap.devname_) == 0; +} + +// Compare two addresses for inequality. + +ACE_INLINE bool +ACE_DEV_Addr::operator != (const ACE_DEV_Addr &sap) const +{ + ACE_TRACE ("ACE_DEV_Addr::operator !="); + + return !((*this) == sap); // This is lazy, of course... ;-). +} + +// Return the path name used for the rendezvous point. + +ACE_INLINE const ACE_TCHAR * +ACE_DEV_Addr::get_path_name (void) const +{ + ACE_TRACE ("ACE_DEV_Addr::get_path_name"); + + return this->devname_; +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/DEV_Connector.cpp b/dep/ACE_wrappers/ace/DEV_Connector.cpp new file mode 100644 index 00000000000..bdc2530acd8 --- /dev/null +++ b/dep/ACE_wrappers/ace/DEV_Connector.cpp @@ -0,0 +1,53 @@ +// $Id: DEV_Connector.cpp 80826 2008-03-04 14:51:23Z wotte $ + +#include "ace/DEV_Connector.h" + +#include "ace/Handle_Ops.h" + +#if !defined (__ACE_INLINE__) +#include "ace/DEV_Connector.inl" +#endif /* __ACE_INLINE__ */ + + +ACE_RCSID (ace, + DEV_Connector, + "$Id: DEV_Connector.cpp 80826 2008-03-04 14:51:23Z wotte $") + + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_ALLOC_HOOK_DEFINE(ACE_DEV_Connector) + +void +ACE_DEV_Connector::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + ACE_TRACE ("ACE_DEV_Connector::dump"); +#endif /* ACE_HAS_DUMP */ +} + +ACE_DEV_Connector::ACE_DEV_Connector (void) +{ + ACE_TRACE ("ACE_DEV_Connector::ACE_DEV_Connector"); +} + +int +ACE_DEV_Connector::connect (ACE_DEV_IO &new_io, + const ACE_DEV_Addr &remote_sap, + ACE_Time_Value *timeout, + const ACE_Addr &, + int, + int flags, + int perms) +{ + ACE_TRACE ("ACE_DEV_Connector::connect"); + + ACE_HANDLE handle = ACE::handle_timed_open (timeout, + remote_sap.get_path_name (), + flags, perms); + new_io.set_handle (handle); + new_io.addr_ = remote_sap; // class copy. + return handle == ACE_INVALID_HANDLE ? -1 : 0; +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/DEV_Connector.h b/dep/ACE_wrappers/ace/DEV_Connector.h new file mode 100644 index 00000000000..32a7223f4c4 --- /dev/null +++ b/dep/ACE_wrappers/ace/DEV_Connector.h @@ -0,0 +1,110 @@ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file DEV_Connector.h + * + * $Id: DEV_Connector.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Gerhard Lenzer and Douglas C. Schmidt + */ +//============================================================================= + +#ifndef ACE_DEV_CONNECTOR_H +#define ACE_DEV_CONNECTOR_H +#include /**/ "ace/pre.h" + +#include "ace/DEV_IO.h" +#include "ace/Log_Msg.h" +#include "ace/os_include/os_fcntl.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +/** + * @class ACE_DEV_Connector + * + * @brief Defines an active connection factory for the ACE_DEV wrappers. + */ +class ACE_Export ACE_DEV_Connector +{ +public: + /// Default constructor. + ACE_DEV_Connector (void); + + /** + * Actively connect and produce a @a new_io if things go well. + * The @a remote_sap is the address that we are trying to connect + * with. The @a timeout is the amount of time to wait to connect. + * If it's 0 then we block indefinitely. If *timeout == {0, 0} then + * the connection is done using non-blocking mode. In this case, if + * the connection can't be made immediately the value of -1 is + * returned with @c errno == EWOULDBLOCK. If *timeout > {0, 0} then + * this is the maximum amount of time to wait before timing out. If the + * time expires before the connection is made @c errno == ETIME. The + * @a local_sap is the value of local address to bind to. If it's + * the default value of ACE_Addr::sap_any then the user is letting + * the OS do the binding. If @a reuse_addr == 1 then the + * is reused, even if it hasn't been cleanedup yet. + * The @a flags and @a perms arguments are passed down to the + * method. + */ + ACE_DEV_Connector (ACE_DEV_IO &new_io, + const ACE_DEV_Addr &remote_sap, + ACE_Time_Value *timeout = 0, + const ACE_Addr &local_sap = ACE_Addr::sap_any, + int reuse_addr = 0, + int flags = O_RDWR, + int perms = 0); + + /** + * Actively connect and produce a @a new_io if things go well. + * The @a remote_sap is the address that we are trying to connect + * with. The @a timeout is the amount of time to wait to connect. + * If it's 0 then we block indefinitely. If *timeout == {0, 0} then + * the connection is done using non-blocking mode. In this case, if + * the connection can't be made immediately the value of -1 is + * returned with @c errno == EWOULDBLOCK. If *timeout > {0, 0} then + * this is the maximum amount of time to wait before timing out. If the + * time expires before the connection is made @c errno == ETIME. The + * @a local_sap is the value of local address to bind to. If it's + * the default value of ACE_Addr::sap_any then the user is letting + * the OS do the binding. If @a reuse_addr == 1 then the + * is reused, even if it hasn't been cleanedup yet. + * The @a flags and @a perms arguments are passed down to the + * method. + */ + int connect (ACE_DEV_IO &new_io, + const ACE_DEV_Addr &remote_sap, + ACE_Time_Value *timeout = 0, + const ACE_Addr &local_sap = ACE_Addr::sap_any, + int reuse_addr = 0, + int flags = O_RDWR, + int perms = 0); + + /// Resets any event associations on this handle + int reset_new_handle (ACE_HANDLE handle); + + /// Dump the state of an object. + void dump (void) const; + + /// Declare the dynamic allocation hooks. + ACE_ALLOC_HOOK_DECLARE; + + // = Meta-type info + typedef ACE_DEV_Addr PEER_ADDR; + typedef ACE_DEV_IO PEER_STREAM; +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +#include "ace/DEV_Connector.inl" +#endif /* __ACE_INLINE__ */ + +#include /**/ "ace/post.h" +#endif /* ACE_DEV_CONNECTOR_H */ diff --git a/dep/ACE_wrappers/ace/DEV_Connector.inl b/dep/ACE_wrappers/ace/DEV_Connector.inl new file mode 100644 index 00000000000..924a4254791 --- /dev/null +++ b/dep/ACE_wrappers/ace/DEV_Connector.inl @@ -0,0 +1,34 @@ +// -*- C++ -*- +// +// $Id: DEV_Connector.inl 80826 2008-03-04 14:51:23Z wotte $ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +// Creates a Local ACE_DEV. + +ACE_INLINE +ACE_DEV_Connector::ACE_DEV_Connector (ACE_DEV_IO &new_io, + const ACE_DEV_Addr &remote_sap, + ACE_Time_Value *timeout, + const ACE_Addr &local_sap, + int reuse_addr, + int flags, + int perms) +{ + ACE_TRACE ("ACE_DEV_Connector::ACE_DEV_Connector"); + if (this->connect (new_io, remote_sap, timeout, local_sap, + reuse_addr, flags, perms) == ACE_IO_SAP::INVALID_HANDLE + && timeout != 0 && !(errno == EWOULDBLOCK || errno == ETIME)) + ACE_ERROR ((LM_ERROR, ACE_TEXT ("address %s, %p\n"), + remote_sap.get_path_name (), ACE_TEXT ("ACE_DEV_IO"))); +} + +ACE_INLINE int +ACE_DEV_Connector::reset_new_handle (ACE_HANDLE handle) +{ + ACE_UNUSED_ARG (handle); + // Nothing to do here since the handle is not a socket + return 0; +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/DEV_IO.cpp b/dep/ACE_wrappers/ace/DEV_IO.cpp new file mode 100644 index 00000000000..b9a8e1f46b9 --- /dev/null +++ b/dep/ACE_wrappers/ace/DEV_IO.cpp @@ -0,0 +1,131 @@ +// $Id: DEV_IO.cpp 80826 2008-03-04 14:51:23Z wotte $ + +#include "ace/DEV_IO.h" +#include "ace/Log_Msg.h" + +#if !defined (__ACE_INLINE__) +#include "ace/DEV_IO.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(ace, DEV_IO, "$Id: DEV_IO.cpp 80826 2008-03-04 14:51:23Z wotte $") + + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_ALLOC_HOOK_DEFINE(ACE_DEV_IO) + +// Return the local endpoint address. + +int +ACE_DEV_IO::get_local_addr (ACE_DEV_Addr &addr) const +{ + ACE_TRACE ("ACE_DEV_IO::get_local_addr"); + + addr = this->addr_; + return 0; +} + +// Return the address of the remotely connected peer (if there is +// one). + +int +ACE_DEV_IO::get_remote_addr (ACE_DEV_Addr &addr) const +{ + ACE_TRACE ("ACE_DEV_IO::get_remote_addr"); + addr = this->addr_; + return 0; +} + +void +ACE_DEV_IO::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + ACE_TRACE ("ACE_DEV_IO::dump"); + + ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); + this->addr_.dump (); + ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); +#endif /* ACE_HAS_DUMP */ +} + +// Simple-minded do nothing constructor. + +ACE_DEV_IO::ACE_DEV_IO (void) +{ + ACE_TRACE ("ACE_DEV_IO::ACE_DEV_IO"); +} + +// Send N char *ptrs and int lengths. Note that the char *'s precede +// the ints (basically, an varargs version of writev). The count N is +// the *total* number of trailing arguments, *not* a couple of the +// number of tuple pairs! + +ssize_t +ACE_DEV_IO::send (size_t n, ...) const +{ + ACE_TRACE ("ACE_DEV_IO::send"); + va_list argp; + int total_tuples = static_cast (n / 2); + iovec *iovp; +#if defined (ACE_HAS_ALLOCA) + iovp = (iovec *) alloca (total_tuples * sizeof (iovec)); +#else + ACE_NEW_RETURN (iovp, + iovec[total_tuples], + -1); +#endif /* !defined (ACE_HAS_ALLOCA) */ + + va_start (argp, n); + + for (int i = 0; i < total_tuples; i++) + { + iovp[i].iov_base = va_arg (argp, char *); + iovp[i].iov_len = va_arg (argp, int); + } + + ssize_t result = ACE_OS::writev (this->get_handle (), iovp, total_tuples); +#if !defined (ACE_HAS_ALLOCA) + delete [] iovp; +#endif /* !defined (ACE_HAS_ALLOCA) */ + va_end (argp); + return result; +} + +// This is basically an interface to ACE_OS::readv, that doesn't use the +// struct iovec explicitly. The ... can be passed as an arbitrary +// number of (char *ptr, int len) tuples. However, the count N is the +// *total* number of trailing arguments, *not* a couple of the number +// of tuple pairs! + +ssize_t +ACE_DEV_IO::recv (size_t n, ...) const +{ + ACE_TRACE ("ACE_DEV_IO::recv"); + va_list argp; + int total_tuples = static_cast (n / 2); + iovec *iovp; +#if defined (ACE_HAS_ALLOCA) + iovp = (iovec *) alloca (total_tuples * sizeof (iovec)); +#else + ACE_NEW_RETURN (iovp, + iovec[total_tuples], + -1); +#endif /* !defined (ACE_HAS_ALLOCA) */ + + va_start (argp, n); + + for (int i = 0; i < total_tuples; i++) + { + iovp[i].iov_base = va_arg (argp, char *); + iovp[i].iov_len = va_arg (argp, int); + } + + ssize_t result = ACE_OS::readv (this->get_handle (), iovp, total_tuples); +#if !defined (ACE_HAS_ALLOCA) + delete [] iovp; +#endif /* !defined (ACE_HAS_ALLOCA) */ + va_end (argp); + return result; +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/DEV_IO.h b/dep/ACE_wrappers/ace/DEV_IO.h new file mode 100644 index 00000000000..3b1c3deb334 --- /dev/null +++ b/dep/ACE_wrappers/ace/DEV_IO.h @@ -0,0 +1,185 @@ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file DEV_IO.h + * + * $Id: DEV_IO.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Gerhard Lenzer + * @author Douglas C. Schmidt + */ +//============================================================================= + +#ifndef ACE_DEV_IO_H +#define ACE_DEV_IO_H +#include /**/ "ace/pre.h" + +#include "ace/DEV.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#if defined (ACE_HAS_STREAM_PIPES) +# include "ace/OS_NS_stropts.h" +#endif /* ACE_HAS_STREAM_PIPES */ + +#include "ace/os_include/os_stdio.h" +#include "ace/os_include/sys/os_uio.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +class ACE_Time_Value; + +/** + * @class ACE_DEV_IO + * + * @brief Read/Write operations on Devices. + */ +class ACE_Export ACE_DEV_IO : public ACE_DEV +{ +public: + friend class ACE_DEV_Connector; + + /// Default constructor. + ACE_DEV_IO (void); + + // = Various send operations. + /// send upto @a n bytes in @a buf. + ssize_t send (const void *buf, size_t n) const; + + /// Recv upto @a n bytes in @a buf. + ssize_t recv (void *buf, size_t n) const; + + /// Send n bytes, keep trying until n are sent. + ssize_t send_n (const void *buf, + size_t n) const; + + /** + * @name I/O operations + * + * Notes on common parameters: + * + * @a buf is the buffer to write from or receive into. + * + * @a len is the number of bytes to transfer. + * + * The @a timeout parameter in the following methods indicates how + * long to blocking trying to transfer data. If @a timeout == 0, + * then the call behaves as a normal send/recv call, i.e., for + * blocking sockets, the call will block until action is possible; + * for non-blocking sockets, EWOULDBLOCK will be returned if no + * action is immediately possible. + * + * If @a timeout != 0, the call will wait until the relative time + * specified in *@a timeout elapses. + * + * The "_n()" I/O methods keep looping until all the data has been + * transferred. These methods also work for sockets in non-blocking + * mode i.e., they keep looping on EWOULDBLOCK. @a timeout is used + * to make sure we keep making progress, i.e., the same timeout + * value is used for every I/O operation in the loop and the timeout + * is not counted down. + * + * The return values for the "*_n()" methods match the return values + * from the non "_n()" methods and are specified as follows: + * + * - On complete transfer, the number of bytes transferred is returned. + * - On timeout, -1 is returned, errno == ETIME. + * - On error, -1 is returned, errno is set to appropriate error. + * - On EOF, 0 is returned, errno is irrelevant. + * + * On partial transfers, i.e., if any data is transferred before + * timeout/error/EOF, @a bytes_transferred will contain the number of + * bytes transferred. + */ + ssize_t recv_n (void *buf, + size_t n, + const ACE_Time_Value *timeout = 0, + size_t *bytes_transferred = 0) const; + +#if defined (ACE_HAS_STREAM_PIPES) + /// Recv bytes via STREAM pipes using "band" mode. + ssize_t recv (ACE_Str_Buf *cntl, + ACE_Str_Buf *data, + int *band, + int *flags) const; + + /// Send bytes via STREAM pipes using "band" mode. + ssize_t send (const ACE_Str_Buf *cntl, + const ACE_Str_Buf *data, + int band, + int flags) const; + + /// Recv @a cntl and @a data via STREAM pipes. + ssize_t recv (ACE_Str_Buf *cntl, + ACE_Str_Buf *data, + int *flags) const; + + /// Send @a cntl and @a data via STREAM pipes. + ssize_t send (const ACE_Str_Buf *cntl, + const ACE_Str_Buf *data, + int flags = 0) const; +#endif /* ACE_HAS_STREAM_PIPES */ + + /// Send iovecs via <::writev>. + ssize_t send (const iovec iov[], size_t n) const; + + /// Recv iovecs via <::readv>. + ssize_t recv (iovec iov[], size_t n) const; + + /** + * Send N char *ptrs and int lengths. Note that the char *'s + * precede the ints (basically, an varargs version of writev). The + * count N is the *total* number of trailing arguments, *not* a + * couple of the number of tuple pairs! + */ + ssize_t send (size_t n, ...) const; + + /** + * This is an interface to ::readv, that doesn't use the struct + * iovec explicitly. The ... can be passed as an arbitrary number + * of (char *ptr, int len) tuples. However, the count N is the + * *total* number of trailing arguments, *not* a couple of the + * number of tuple pairs! + */ + ssize_t recv (size_t n, ...) const; + + /// Send @a n bytes via Win32 WriteFile using overlapped I/O. + ssize_t send (const void *buf, size_t n, ACE_OVERLAPPED *overlapped) const; + + /// Recv @a n bytes via Win32 ReadFile using overlapped I/O. + ssize_t recv (void *buf, size_t n, ACE_OVERLAPPED *overlapped) const; + + /// Dump the state of an object. + void dump (void) const; + + // = The following two methods are no-ops to keep the + // ACE_Connector happy. + /// Return the local endpoint address. + int get_local_addr (ACE_DEV_Addr &) const; + + /// Return the address of the remotely connected peer (if there is + /// one). + int get_remote_addr (ACE_DEV_Addr &) const; + + /// Declare the dynamic allocation hooks. + ACE_ALLOC_HOOK_DECLARE; + + // = Meta-type info + typedef ACE_DEV_Addr PEER_ADDR; + +private: + /// Address of device we are connected to. + ACE_DEV_Addr addr_; +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +#include "ace/DEV_IO.inl" +#endif /* __ACE_INLINE__ */ + +#include /**/ "ace/post.h" +#endif /* ACE_DEV_IO_H */ diff --git a/dep/ACE_wrappers/ace/DEV_IO.inl b/dep/ACE_wrappers/ace/DEV_IO.inl new file mode 100644 index 00000000000..796d24e114a --- /dev/null +++ b/dep/ACE_wrappers/ace/DEV_IO.inl @@ -0,0 +1,126 @@ +// -*- C++ -*- +// +// $Id: DEV_IO.inl 80826 2008-03-04 14:51:23Z wotte $ + +#include "ace/OS_NS_sys_uio.h" +#include "ace/OS_NS_unistd.h" +#include "ace/OS_Memory.h" + +#include "ace/ACE.h" + +// Send exactly N bytes from BUF to this device. Keeping trying until +// this many bytes are sent. + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_INLINE ssize_t +ACE_DEV_IO::send_n (const void *buf, size_t n) const +{ + ACE_TRACE ("ACE_DEV_IO::send_n"); + return ACE::write_n (this->get_handle (), buf, n); +} + +// Receive exactly N bytes from this file into BUF. Keep trying until +// this many bytes are received. + +ACE_INLINE ssize_t +ACE_DEV_IO::recv_n (void *buf, + size_t n, + const ACE_Time_Value *timeout, + size_t *bytes_transferred) const +{ + ACE_TRACE ("ACE_DEV_IO::recv_n"); +#if defined (ACE_WIN32) + ACE_UNUSED_ARG (timeout); + + return ACE::read_n (this->get_handle (), + buf, + n, + bytes_transferred); +#else + return ACE::recv_n (this->get_handle (), + buf, + n, + timeout, + bytes_transferred); +#endif /*ACE_WIN32*/ +} + +ACE_INLINE ssize_t +ACE_DEV_IO::send (const void *buf, size_t n) const +{ + ACE_TRACE ("ACE_DEV_IO::send"); + return ACE_OS::write (this->get_handle (), (const char *) buf, n); +} + +ACE_INLINE ssize_t +ACE_DEV_IO::recv (void *buf, size_t n) const +{ + ACE_TRACE ("ACE_DEV_IO::recv"); + return ACE_OS::read (this->get_handle (), (char *) buf, n); +} + +ACE_INLINE ssize_t +ACE_DEV_IO::send (const iovec iov[], size_t n) const +{ + ACE_TRACE ("ACE_DEV_IO::send"); + return ACE_OS::writev (this->get_handle (), iov, static_cast (n)); +} + +ACE_INLINE ssize_t +ACE_DEV_IO::recv (iovec iov[], size_t n) const +{ + ACE_TRACE ("ACE_DEV_IO::recv"); + return ACE_OS::readv (this->get_handle (), iov, static_cast (n)); +} + +ACE_INLINE ssize_t +ACE_DEV_IO::send (const void *buf, size_t n, + ACE_OVERLAPPED *overlapped) const +{ + ACE_TRACE ("ACE_DEV_IO::send"); + return ACE_OS::write (this->get_handle (), + (const char *) buf, n, + overlapped); +} + +ACE_INLINE ssize_t +ACE_DEV_IO::recv (void *buf, size_t n, + ACE_OVERLAPPED *overlapped) const +{ + ACE_TRACE ("ACE_DEV_IO::recv"); + return ACE_OS::read (this->get_handle (), (char *) buf, n, + overlapped); +} + +#if defined (ACE_HAS_STREAM_PIPES) +ACE_INLINE ssize_t +ACE_DEV_IO::recv (ACE_Str_Buf *cntl, ACE_Str_Buf *data, int *band, int *flags) const +{ + ACE_TRACE ("ACE_DEV_IO::recv"); + return ACE_OS::getpmsg (this->get_handle (), (strbuf *) cntl, (strbuf *) data, band, flags); +} + +ACE_INLINE ssize_t +ACE_DEV_IO::send (const ACE_Str_Buf *cntl, const ACE_Str_Buf *data, int band, int flags) const +{ + ACE_TRACE ("ACE_DEV_IO::send"); + return ACE_OS::putpmsg (this->get_handle (), (strbuf *) cntl, (strbuf *) data, band, flags); +} + +ACE_INLINE ssize_t +ACE_DEV_IO::recv (ACE_Str_Buf *cntl, ACE_Str_Buf *data, int *flags) const +{ + ACE_TRACE ("ACE_DEV_IO::recv"); + return ACE_OS::getmsg (this->get_handle (), (strbuf *) cntl, (strbuf *) data, flags); +} + +ACE_INLINE ssize_t +ACE_DEV_IO::send (const ACE_Str_Buf *cntl, const ACE_Str_Buf *data, int flags) const +{ + ACE_TRACE ("ACE_DEV_IO::send"); + return ACE_OS::putmsg (this->get_handle (), (strbuf *) cntl, (strbuf *) data, flags); +} +#endif /* ACE_HAS_STREAM_PIPES */ + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/DLL.cpp b/dep/ACE_wrappers/ace/DLL.cpp new file mode 100644 index 00000000000..cad25110032 --- /dev/null +++ b/dep/ACE_wrappers/ace/DLL.cpp @@ -0,0 +1,267 @@ +// $Id: DLL.cpp 80826 2008-03-04 14:51:23Z wotte $ + +#include "ace/DLL.h" + +#include "ace/Log_Msg.h" +#include "ace/ACE.h" +#include "ace/DLL_Manager.h" +#include "ace/OS_NS_string.h" +#include "ace/OS_NS_dlfcn.h" +#include "ace/OS_NS_Thread.h" + +#include + +ACE_RCSID(ace, DLL, "$Id: DLL.cpp 80826 2008-03-04 14:51:23Z wotte $") + + ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +// Default constructor. Also, by default, the object will be closed +// before it is destroyed. + +ACE_DLL::ACE_DLL (bool close_handle_on_destruction) + : open_mode_ (0), + dll_name_ (0), + close_handle_on_destruction_ (close_handle_on_destruction), + dll_handle_ (0), + error_ (0) +{ + ACE_TRACE ("ACE_DLL::ACE_DLL (int)"); +} + +ACE_DLL::ACE_DLL (const ACE_DLL &rhs) + : open_mode_ (0), + dll_name_ (0), + close_handle_on_destruction_ (false), + dll_handle_ (0), + error_ (0) +{ + ACE_TRACE ("ACE_DLL::ACE_DLL (const ACE_DLL &)"); + + if (rhs.dll_name_ + // This will automatically up the refcount. + && this->open (rhs.dll_name_, + rhs.open_mode_, + rhs.close_handle_on_destruction_) != 0 + && ACE::debug ()) + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("ACE_DLL::copy_ctor: error: %s\n"), + this->error ())); +} + +// Assignment operator + +ACE_DLL & +ACE_DLL::operator= (const ACE_DLL &rhs) +{ + ACE_TRACE ("ACE_DLL::operator= (const ACE_DLL &)"); + + ACE_DLL tmp (rhs); + + std::swap (this->open_mode_, tmp.open_mode_); + std::swap (this->dll_name_, tmp.dll_name_); + std::swap (this->close_handle_on_destruction_, + tmp.close_handle_on_destruction_); + std::swap (this->dll_handle_, tmp.dll_handle_); + std::swap (this->error_, tmp.error_); + + return *this; +} + + +// If the library name and the opening mode are specified than on +// object creation the library is implicitly opened. + +ACE_DLL::ACE_DLL (const ACE_TCHAR *dll_name, + int open_mode, + bool close_handle_on_destruction) + : open_mode_ (open_mode), + dll_name_ (0), + close_handle_on_destruction_ (close_handle_on_destruction), + dll_handle_ (0), + error_ (0) +{ + ACE_TRACE ("ACE_DLL::ACE_DLL"); + + if (this->open (dll_name, this->open_mode_, close_handle_on_destruction) != 0 + && ACE::debug ()) + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("ACE_DLL::open: error calling open: %s\n"), + this->error ())); +} + +// The library is closed before the class gets destroyed depending on +// the close_handle_on_destruction value specified which is stored in +// close_handle_on_destruction_. + +ACE_DLL::~ACE_DLL (void) +{ + ACE_TRACE ("ACE_DLL::~ACE_DLL"); + + this->close (); + + // Normally delete()d in ACE_DLL::close(). However, that may not + // occur if full ACE_DLL initialization is interrupted due to errors + // (e.g. attempting to open a DSO/DLL that does not exist). Make + // sure this->dll_name_ is deallocated. + delete [] this->dll_name_; +} + +// This method opens the library based on the mode specified using the +// ACE_SHLIB_HANDLE which is obtained on making the ACE_OS::dlopen call. +// The default mode is: +// RTLD_LAZY Only references to data symbols are relocate when the +// object is first loaded. +// The other modes include: +// RTLD_NOW All necessary relocations are performed when the +// object is first loaded. +// RTLD_GLOBAL The object symbols are made available for the +// relocation processing of any other object. + +int +ACE_DLL::open (const ACE_TCHAR *dll_filename, + int open_mode, + bool close_handle_on_destruction) +{ + ACE_TRACE ("ACE_DLL::open"); + + return open_i (dll_filename, open_mode, close_handle_on_destruction); +} + +int +ACE_DLL::open_i (const ACE_TCHAR *dll_filename, + int open_mode, + bool close_handle_on_destruction, + ACE_SHLIB_HANDLE handle) +{ + ACE_TRACE ("ACE_DLL::open_i"); + + this->error_ = 0; + + if (!dll_filename) + { + if (ACE::debug ()) + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("ACE_DLL::open_i: dll_name is %s\n"), + this->dll_name_ == 0 ? ACE_TEXT ("(null)") + : this->dll_name_)); + return -1; + } + + if (this->dll_handle_) + { + // If we have a good handle and its the same name, just return. + if (ACE_OS::strcmp (this->dll_name_, dll_filename) == 0) + return 0; + else + this->close (); + } + + if (!this->dll_name_) + this->dll_name_ = ACE::strnew (dll_filename); + + this->open_mode_ = open_mode; + this->close_handle_on_destruction_ = close_handle_on_destruction; + + this->dll_handle_ = ACE_DLL_Manager::instance()->open_dll (this->dll_name_, + this->open_mode_, + handle); + + if (!this->dll_handle_) + this->error_ = 1; + + return this->error_ ? -1 : 0; +} + +// The symbol refernce of the name specified is obtained. + +void * +ACE_DLL::symbol (const ACE_TCHAR *sym_name, int ignore_errors) +{ + ACE_TRACE ("ACE_DLL::symbol"); + + this->error_ = 0; + + void *sym = 0; + if (this->dll_handle_) + sym = this->dll_handle_->symbol (sym_name, ignore_errors); + + if (!sym) + this->error_ = 1; + + return sym; +} + +// The library is closed using the ACE_SHLIB_HANDLE object, i.e., the +// shared object is now disassociated form the current process. + +int +ACE_DLL::close (void) +{ + ACE_TRACE ("ACE_DLL::close"); + + int retval = 0; + + if (this->dll_handle_ + && this->close_handle_on_destruction_ + && this->dll_name_ + && (retval = ACE_DLL_Manager::instance ()->close_dll (this->dll_name_)) != 0) + this->error_ = 1; + + // Even if close_dll() failed, go ahead and cleanup. + this->dll_handle_ = 0; + delete [] this->dll_name_; + this->dll_name_ = 0; + this->close_handle_on_destruction_ = false; + + return retval; +} + +// This method is used return the last error of a library operation. + +ACE_TCHAR * +ACE_DLL::error (void) const +{ + ACE_TRACE ("ACE_DLL::error"); + if (this->error_) + { + return ACE_OS::dlerror (); + } + + return 0; +} + +// Return the handle to the user either temporarily or forever, thus +// orphaning it. If 0 means the user wants the handle forever and if 1 +// means the user temporarily wants to take the handle. + +ACE_SHLIB_HANDLE +ACE_DLL::get_handle (int become_owner) const +{ + ACE_TRACE ("ACE_DLL::get_handle"); + + ACE_SHLIB_HANDLE handle = ACE_SHLIB_INVALID_HANDLE; + + if (this->dll_handle_) + handle = this->dll_handle_->get_handle (become_owner); + + return handle; +} + +// Set the handle for the DLL. By default, the object will be closed +// before it is destroyed. + +int +ACE_DLL::set_handle (ACE_SHLIB_HANDLE handle, + bool close_handle_on_destruction) +{ + ACE_TRACE ("ACE_DLL::set_handle"); + + // Create a unique name. Note that this name is only quaranteed + // to be unique for the life of this object. + ACE_TCHAR temp[ACE_UNIQUE_NAME_LEN]; + ACE_OS::unique_name (this, temp, ACE_UNIQUE_NAME_LEN); + + return this->open_i (temp, 1, close_handle_on_destruction, handle); +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/DLL.h b/dep/ACE_wrappers/ace/DLL.h new file mode 100644 index 00000000000..fa748e8d944 --- /dev/null +++ b/dep/ACE_wrappers/ace/DLL.h @@ -0,0 +1,196 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file DLL.h + * + * $Id: DLL.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Kirthika Parameswaran + */ +//============================================================================= + +#ifndef ACE_DLL_H +#define ACE_DLL_H +#include /**/ "ace/pre.h" + +#include /**/ "ace/ACE_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/Global_Macros.h" +#include "ace/os_include/os_dlfcn.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +class ACE_DLL_Handle; + +/** + * @class ACE_DLL + * + * @brief Provides an abstract interface for handling various DLL + * operations. + * + * This class is a wrapper over the various methods for utilizing + * a dynamically linked library (DLL), which is called a shared + * library on some platforms. Operations @c open(), @c close(), and + * @c symbol() have been implemented to help opening/closing and + * extracting symbol information from a DLL, respectively. + */ +class ACE_Export ACE_DLL +{ +public: + // = Initialization and termination methods. + + /** + * Default constructor. By default, the close() operation on the + * object will be invoked before it is destroyed. + * @param close_handle_on_destruction Indicates whether or not the + * close() method will be called to close an open DLL when this + * object is destroyed. By default, close() will be called. + * Set this parameter to 0 for situations where the DLL's lifetime + * is controlled in a scope other than that of this ACE_DLL object. + * For example, termination by ACE_DLL_Manager via ACE::fini(). + */ + explicit ACE_DLL (bool close_handle_on_destruction = true); + + /// Allow assignment + ACE_DLL& operator= (const ACE_DLL &rhs); + + + /** + * This constructor performs the actions of open() during construction. + * @param dll_name The name or path of the DLL to load. + * @param open_mode Flags to alter the actions taken when loading the DLL. + * The possible values are: + * @li @c RTLD_LAZY (this the default): loads identifier symbols but + * not the symbols for functions, which are loaded dynamically + * on-demand. + * @li @c RTLD_NOW: performs all necessary relocations when + * @a dll_name is first loaded + * @li RTLD_GLOBAL: makes symbols available for relocation + * processing of any other DLLs. + * @param close_handle_on_destruction Indicates whether or not the + * close() method will be called to close an open DLL when this + * object is destroyed. By default, close() will be called. + * Set this parameter to 0 for situations where the DLL's lifetime + * is controlled in a scope other than that of this ACE_DLL object. + * For example, termination by ACE_DLL_Manager via ACE::fini(). + */ + explicit ACE_DLL (const ACE_TCHAR *dll_name, + int open_mode = ACE_DEFAULT_SHLIB_MODE, + bool close_handle_on_destruction = true); + + /// Copy constructor. + ACE_DLL (const ACE_DLL &); + + /** + * This method opens and dynamically links a specified DLL. + * @param dll_name The filename or path of the DLL to load. + * If a filename is given to @c open(), the @c ACE::ldfind() is used + * to locate DLLs via the following algorithms: (1) DLL filename + * expansion: @c ACE::ldfind() determines the name of the DLL by + * adding the appropriate prefix and suffix, e.g., it adds the @c lib + * prefix and @c .so suffix for Solaris and the @c .dll suffix for + * Windows and (2) DLL search path: @c ACE::ldfind() will also search + * for the designated DLL using the platform's DLL search path + * environment variable, e.g., it searches for DLLs using @c + * LD_LIBRARY_PATH on many UNIX systems and @c PATH on Windows. + * @param open_mode Flags to alter the actions taken when loading the DLL. + * The possible values are: + * @li @c RTLD_LAZY (this the default): loads identifier symbols but + * not the symbols for functions, which are loaded dynamically + * on-demand. + * @li @c RTLD_NOW: performs all necessary relocations when + * @a dll_name is first loaded + * @li RTLD_GLOBAL: makes symbols available for relocation + * processing of any other DLLs. + * @param close_handle_on_destruction Indicates whether or not the + * close() method will be called to close an open DLL when this + * object is destroyed. By default, close() will be called. + * Set this parameter to 0 for situations where the DLL's lifetime + * is controlled in a scope other than that of this ACE_DLL object. + * For example, termination by ACE_DLL_Manager via ACE::fini(). + * @retval -1 On failure + * @retval 0 On success. + */ + int open (const ACE_TCHAR *dll_name, + int open_mode = ACE_DEFAULT_SHLIB_MODE, + bool close_handle_on_destruction = true); + + /// Call to close the DLL object. + int close (void); + + /** + * Called when the DLL object is destroyed -- invokes close() if the + * @a close_handle_on_destruction flag was set to non-zero in the + * constructor or open() method. + */ + ~ACE_DLL (void); + + /** + * Look up a named symbol in the DLL. DLL must be successfully opened + * before calling symbol(). + * @param symbol_name The symbol name to look up. + * @param ignore_errors If set to 1, allows you to probe a dll without + * generating error messages in the log. Handy for determining + * the capabilities of a library. + * @return Returns the value of @a symbol_name if it is a valid symbol + * in the DLL. Otherwise, returns 0. + */ + void *symbol (const ACE_TCHAR *symbol_name, int ignore_errors = 0); + + /// Returns a pointer to a string explaining that an error occured. You + /// will need to consult the error log for the actual error string + /// returned by the OS. + ACE_TCHAR *error (void) const; + + /** + * Return the handle to the caller. If @a become_owner is non-0 then + * caller assumes ownership of the handle and the ACE_DLL object + * won't call close() when it goes out of scope, even if + * is set. + */ + ACE_SHLIB_HANDLE get_handle (int become_owner = 0) const; + + /// Set the handle for the DLL object. By default, the close() + //operation on / the object will be invoked before it is destroyed. + int set_handle (ACE_SHLIB_HANDLE handle, + bool close_handle_on_destruction = true); + +private: + + int open_i (const ACE_TCHAR *dll_name, + int open_mode = ACE_DEFAULT_SHLIB_MODE, + bool close_handle_on_destruction = true, + ACE_SHLIB_HANDLE handle = 0); + + + //private: +public: + + /// Open mode. + int open_mode_; + + /// Keep track of the name of the loaded dll, so it can be used + /// to remove framework components, singletons that live in the dll, + /// prior to unloading the dll in the close() method. + ACE_TCHAR *dll_name_; + + /// This flag keeps track of whether we should close the handle + /// automatically when the object is destroyed. + bool close_handle_on_destruction_; + + ACE_DLL_Handle *dll_handle_; + + /// Flag to record if the last operation had an error. + bool error_; + +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#include /**/ "ace/post.h" +#endif /* ACE_DLL_H */ diff --git a/dep/ACE_wrappers/ace/DLL_Manager.cpp b/dep/ACE_wrappers/ace/DLL_Manager.cpp new file mode 100644 index 00000000000..90049a04220 --- /dev/null +++ b/dep/ACE_wrappers/ace/DLL_Manager.cpp @@ -0,0 +1,787 @@ +// $Id: DLL_Manager.cpp 80826 2008-03-04 14:51:23Z wotte $ + +#include "ace/DLL_Manager.h" + +#include "ace/Log_Msg.h" +#include "ace/ACE.h" +#include "ace/Framework_Component.h" + +#include "ace/Lib_Find.h" +#include "ace/Object_Manager.h" +#include "ace/SString.h" +#include "ace/Recursive_Thread_Mutex.h" +#include "ace/Guard_T.h" +#include "ace/OS_NS_dlfcn.h" +#include "ace/OS_NS_string.h" + +ACE_RCSID (ace, + DLL_Manager, + "DLL_Manager.cpp,v 4.23 2003/11/05 23:30:46 shuston Exp") + +/******************************************************************/ + + ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +sig_atomic_t ACE_DLL_Handle::open_called_ = 0; + +ACE_DLL_Handle::ACE_DLL_Handle (void) + : refcount_ (0), + dll_name_ (0), + handle_ (ACE_SHLIB_INVALID_HANDLE) +{ + ACE_TRACE ("ACE_DLL_Handle::ACE_DLL_Handle"); +} + +ACE_DLL_Handle::~ACE_DLL_Handle (void) +{ + ACE_TRACE ("ACE_DLL_Handle::~ACE_DLL_Handle"); + this->close (1); + delete[] this->dll_name_; +} + +const ACE_TCHAR * +ACE_DLL_Handle::dll_name (void) const +{ + ACE_TRACE ("ACE_DLL_Handle::dll_name"); + return this->dll_name_; +} + +int +ACE_DLL_Handle::open (const ACE_TCHAR *dll_name, + int open_mode, + ACE_SHLIB_HANDLE handle) +{ + ACE_TRACE ("ACE_DLL_Handle::open"); + ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, 0)); + + if (this->dll_name_) + { + // Once dll_name_ has been set, it can't be changed.. + if (ACE_OS::strcmp (this->dll_name_, dll_name) != 0) + { + if (ACE::debug ()) + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("(%P|%t) DLL_Handle::open: error, ") + ACE_TEXT ("tried to reopen %s with name %s\n"), + this->dll_name_, + dll_name)); + + return -1; + } + } + else + this->dll_name_ = ACE::strnew (dll_name); + + if (!this->open_called_) + this->open_called_ = 1; + + // If it hasn't been loaded yet, go ahead and do that now. + if (this->handle_ == ACE_SHLIB_INVALID_HANDLE) + { + if (handle) + this->handle_ = handle; + else + { + /* + ** Get the set of names to try loading. We need to do this to + ** properly support the ability for a user to specify a simple, + ** unadorned name (for example, "ACE") that will work across + ** platforms. We apply platform specifics to get a name that will + ** work (e.g. libACE, ACEd.dll, ACE.dll, etc.) We rely on the + ** underlying dlopen() implementation to "Do The Right Thing" in + ** terms of using relative paths, LD_LIBRARY_PATH, system security + ** rules, etc. except when ACE_MUST_HELP_DLOPEN_SEARCH_PATH is set. + ** If it is set, then ACE::ldfind() scans the configured path + ** looking for a match on the name and prefix/suffix applications. + ** NOTE: having ACE scan for a file and then pass a fully-qualified + ** pathname to dlopen() is a potential security hole; therefore, + ** do not use ACE_MUST_HELP_DLOPEN_SEARCH_PATH unless necessary + ** and only after considering the risks. + */ + ACE_Array dll_names; + dll_names.max_size (10); // Decent guess to avoid realloc later + +#if defined (ACE_MUST_HELP_DLOPEN_SEARCH_PATH) + // Find out where the library is + ACE_TCHAR dll_pathname[MAXPATHLEN + 1]; + + // Transform the pathname into the appropriate dynamic link library + // by searching the ACE_LD_SEARCH_PATH. + ACE::ldfind (dll_name, + dll_pathname, + (sizeof dll_pathname / sizeof (ACE_TCHAR))); + ACE_TString dll_str (dll_pathname); + dll_names.size (1); + dll_names.set (dll_str, 0); +#else + this->get_dll_names (dll_name, dll_names); +#endif + + ACE_Array_Iterator name_iter (dll_names); + ACE_TString *name = 0; + while (name_iter.next (name)) + { + // The ACE_SHLIB_HANDLE object is obtained. + this->handle_ = ACE_OS::dlopen (name->c_str (), + open_mode); + + if (ACE::debug ()) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("ACE (%P|%t) DLL_Handle::open ") + ACE_TEXT ("(\"%s\", 0x%x) -> %s: %s\n"), + name->c_str (), + open_mode, + ((this->handle_ != ACE_SHLIB_INVALID_HANDLE) + ? ACE_TEXT ("succeeded") + : ACE_TEXT ("failed")), + this->error()->c_str())); + } + + if (this->handle_ != ACE_SHLIB_INVALID_HANDLE) // Good one? + break; + + // If errno is ENOENT we just skip over this one, + // anything else - like an undefined symbol, for + // instance must be flagged here or the next error will + // mask it. + // @TODO: If we've found our DLL _and_ it's + // broken, should we continue at all? + if ((errno != 0) && (errno != ENOENT) && ACE::debug ()) + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("ACE (%P|%t) DLL_Handle::open ") + ACE_TEXT ("(\'%s\') failed, errno=") + ACE_TEXT ("%d: %s\n"), + name->c_str (), + errno, + this->error ()->c_str ())); + +#if defined (AIX) + // AIX often puts the shared library file (most often named + // shr.o) inside an archive library. If this is an archive + // library name, then try appending [shr.o] and retry. + if (ACE_TString::npos != name->strstr (ACE_TEXT (".a"))) + { + ACE_TCHAR aix_pathname[MAXPATHLEN + 1]; + ACE_OS::strncpy (aix_pathname, + name->c_str (), + name->length ()); + aix_pathname[name->length ()] = '\0'; + ACE_OS::strcat (aix_pathname, ACE_TEXT ("(shr.o)")); + open_mode |= RTLD_MEMBER; + + if (ACE::debug ()) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("ACE (%P|%t) DLL_Handle::open ") + ACE_TEXT ("(\"%s\", 0x%x) -> %s: %s\n"), + aix_pathname, + open_mode, + ACE_TEXT ((this->handle_ != ACE_SHLIB_INVALID_HANDLE) + ? "succeeded" + : "failed"), + this->error()->c_str())); + } + + this->handle_ = ACE_OS::dlopen (aix_pathname, open_mode); + if (this->handle_ != ACE_SHLIB_INVALID_HANDLE) + break; + + // If errno is ENOENT we just skip over this one, anything + // else - like an undefined symbol, for instance + // must be flagged here or the next error will mask it. + // + // @TODO: If we've found our DLL _and_ it's broken, + // should we continue at all? + if (ACE::debug () && (errno != 0) && (errno != ENOENT)) + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("ACE (%P|%t) DLL_Handle::open ") + ACE_TEXT ("(\'%s\') failed, errno=") + ACE_TEXT ("%d: %s\n"), + name->c_str (), + errno, + this->error ()->c_str ())); + + } +#endif /* AIX */ + + name_iter.advance (); + } + + if (this->handle_ == ACE_SHLIB_INVALID_HANDLE) + { + if (ACE::debug ()) + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("ACE (%P|%t) DLL_Handle::open (\"%s\"): ") + ACE_TEXT ("Invalid handle error: %s\n"), + this->dll_name_, + this->error ()->c_str ())); + + return -1; + } + } + } + + ++this->refcount_; + + if (ACE::debug ()) + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("ACE (%P|%t) DLL_Handle::open - %s (%d), refcount=%d\n"), + this->dll_name_, + this->handle_, + this->refcount_)); + return 0; +} + + +int +ACE_DLL_Handle::close (int unload) +{ + ACE_TRACE ("ACE_DLL_Handle::close"); + + int retval = 0; + ACE_SHLIB_HANDLE h = ACE_SHLIB_INVALID_HANDLE; + + // Only hold the lock until it comes time to dlclose() the DLL. Closing + // the DLL can cause further shutdowns as DLLs and their dependents are + // unloaded. + { + ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, 0)); + + // Since we don't actually unload the dll as soon as the refcount + // reaches zero, we need to make sure we don't decrement it below + // zero. + if (this->refcount_ > 0) + --this->refcount_; + else + this->refcount_ = 0; + + if (ACE::debug ()) + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("ACE (%P|%t) DLL_Handle::close - ") + ACE_TEXT ("%s (handle=%d, refcount=%d)\n"), + this->dll_name_, + this->handle_, + this->refcount_)); + + if (this->refcount_ == 0 && + this->handle_ != ACE_SHLIB_INVALID_HANDLE && + unload == 1) + { + if (ACE::debug ()) + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("ACE (%P|%t) DLL_Handle::close: ") + ACE_TEXT ("Unloading %s (handle=%d)\n"), + this->dll_name_, + this->handle_)); + + // First remove any associated Framework Components. + ACE_Framework_Repository *frPtr= ACE_Framework_Repository::instance (); + if (frPtr) + { + frPtr->remove_dll_components (this->dll_name_); + } + + h = this->handle_; + this->handle_ = ACE_SHLIB_INVALID_HANDLE; + } + } // Release lock_ here + + if (h != ACE_SHLIB_INVALID_HANDLE) + { + retval = ACE_OS::dlclose (h); + + if (retval != 0 && ACE::debug ()) + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("ACE (%P|%t) DLL_Handle::close - ") + ACE_TEXT ("Failed with: \"%s\".\n"), + this->error ()->c_str ())); + } + + return retval; +} + +sig_atomic_t +ACE_DLL_Handle::refcount (void) const +{ + return this->refcount_; +} + +void * +ACE_DLL_Handle::symbol (const ACE_TCHAR *sym_name, int ignore_errors) +{ + ACE_TRACE ("ACE_DLL_Handle::symbol"); + ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, 0)); + + ACE_Auto_Array_Ptr auto_name (ACE::ldname (sym_name)); + // handle_ can be invalid especially when ACE_DLL_Handle resigned ownership + // BTW. Handle lifecycle management is a little crazy in ACE + if (this->handle_ != ACE_SHLIB_INVALID_HANDLE) + { +#if defined (ACE_OPENVMS) + void *sym = ACE::ldsymbol (this->handle_, auto_name.get ()); +#else + void *sym = ACE_OS::dlsym (this->handle_, auto_name.get ()); +#endif + + // Linux says that the symbol could be null and that it isn't an + // error. So you should check the error message also, but since + // null symbols won't do us much good anyway, let's still report + // an error. + if (!sym && ignore_errors != 1) + { + if (ACE::debug ()) + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("ACE (%P|%t) DLL_Handle::symbol (\"%s\") ") + ACE_TEXT (" failed with \"%s\".\n"), + auto_name.get (), + this->error ()->c_str ())); + + return 0; + } + return sym; + } + return 0; +} + +ACE_SHLIB_HANDLE +ACE_DLL_Handle::get_handle (int become_owner) +{ + ACE_TRACE ("ACE_DLL_Handle::get_handle"); + ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, 0)); + + if (this->refcount_ == 0 && become_owner != 0) + { + if (ACE::debug ()) + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("ACE (%P|%t) DLL_Handle::get_handle: ") + ACE_TEXT ("cannot become owner, refcount == 0.\n"))); + + return ACE_SHLIB_INVALID_HANDLE; + } + + ACE_SHLIB_HANDLE handle = this->handle_; + + if (become_owner != 0) + { + if (--this->refcount_ == 0) + this->handle_ = ACE_SHLIB_INVALID_HANDLE; + } + + if (ACE::debug ()) + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("ACE (%P|%t) ACE_DLL_Handle::get_handle: ") + ACE_TEXT ("post call: handle %s, refcount %d\n"), + this->handle_ == ACE_SHLIB_INVALID_HANDLE ? + ACE_TEXT ("invalid") : ACE_TEXT ("valid"), + this->refcount_)); + + return handle; +} + +// This method is used return the last error of a library operation. + +auto_ptr +ACE_DLL_Handle::error (void) +{ + ACE_TRACE ("ACE_DLL_Handle::error"); + const ACE_TCHAR *error = ACE_OS::dlerror (); + auto_ptr str + (new ACE_TString (error ? error : ACE_TEXT ("no error"))); + return str; +} + +void +ACE_DLL_Handle::get_dll_names (const ACE_TCHAR *dll_name, + ACE_Array &try_names) +{ + // Build the array of DLL names to try on this platform by applying the + // proper prefixes and/or suffixes to the specified dll_name. + ACE_TString base (dll_name); + ACE_TString base_dir, base_file, base_suffix; + + // 1. Separate the dll_name into the dir part and the file part. We + // only decorate the file part to determine the names to try loading. + ACE_TString::size_type pos = base.rfind (ACE_DIRECTORY_SEPARATOR_CHAR); + if (pos != ACE_TString::npos) + { + base_dir = base.substr (0, pos + 1); + base_file = base.substr (pos + 1); + } + else + base_file = base; + + // 2. Locate the file suffix, if there is one. Move the '.' and the + // suffix to base_suffix. + if ((pos = base_file.rfind (ACE_TEXT ('.'))) != ACE_TString::npos) + { + base_suffix = base_file.substr (pos); + base_file = base_file.substr (0, pos); + } + + // 3. Build the combinations to try for this platform. + // Try these combinations: + // - name with decorator and platform's suffix appended (if not supplied) + // - name with platform's suffix appended (if not supplied) + // - name with platform's dll prefix (if it has one) and suffix + // - name with platform's dll prefix, decorator, and suffix. + // - name as originally given + // We first try to find the file using the decorator so that when a + // filename with and without decorator is used, we get the file with + // the same decorator as the ACE dll has and then as last resort + // the one without. For example with msvc, the debug build has a "d" + // decorator, but the release build has none and we really want to get + // the debug version of the library in a debug application instead + // of the release one. + // So we need room for 5 entries in try_names. + try_names.size (0); + if ((try_names.max_size () - try_names.size ()) < 5) + try_names.max_size (try_names.max_size () + 5); +#if defined (ACE_WIN32) && defined (ACE_LD_DECORATOR_STR) && !defined (ACE_DISABLE_DEBUG_DLL_CHECK) + ACE_TString decorator (ACE_LD_DECORATOR_STR); +#endif + ACE_TString suffix (ACE_DLL_SUFFIX); + ACE_TString prefix (ACE_DLL_PREFIX); + + for (size_t i = 0; i < 5 && try_names.size () < try_names.max_size (); ++i) + { + ACE_TString try_this; + size_t j = try_names.size (); + switch (i) + { + case 0: // Name + decorator + suffix + case 1: // Name + suffix + case 2: // Prefix + name + decorator + suffix + case 3: // Prefix + name + suffix + if ( + base_suffix.length () > 0 +#if !(defined(ACE_WIN32) && defined (ACE_LD_DECORATOR_STR) && !defined (ACE_DISABLE_DEBUG_DLL_CHECK)) + || (i == 1 || i == 3) // No decorator desired; skip +#endif + ) + break; + try_this = base_dir; + if (i > 1) + try_this += prefix; + try_this += base_file; + if (base_suffix.length () > 0) + try_this += base_suffix; + else + { +#if defined (ACE_WIN32) && defined (ACE_LD_DECORATOR_STR) && !defined (ACE_DISABLE_DEBUG_DLL_CHECK) + try_this += decorator; +#endif + try_this += suffix; + } + break; + case 4: + try_this = dll_name; + break; + } + + if (try_this.length ()) + { + try_names.size (j + 1); + try_names.set (try_this, j); + } + } + return; +} + +/******************************************************************/ + +// Pointer to the Singleton instance. +ACE_DLL_Manager *ACE_DLL_Manager::instance_ = 0; + + +ACE_DLL_Manager * +ACE_DLL_Manager::instance (int size) +{ + ACE_TRACE ("ACE_DLL_Manager::instance"); + + if (ACE_DLL_Manager::instance_ == 0) + { + // Perform Double-Checked Locking Optimization. + ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon, + *ACE_Static_Object_Lock::instance (), 0)); + if (ACE_DLL_Manager::instance_ == 0) + { + ACE_NEW_RETURN (ACE_DLL_Manager::instance_, + ACE_DLL_Manager (size), + 0); + } + } + + return ACE_DLL_Manager::instance_; +} + +void +ACE_DLL_Manager::close_singleton (void) +{ + ACE_TRACE ("ACE_DLL_Manager::close_singleton"); + + ACE_MT (ACE_GUARD (ACE_Recursive_Thread_Mutex, ace_mon, + *ACE_Static_Object_Lock::instance ())); + + delete ACE_DLL_Manager::instance_; + ACE_DLL_Manager::instance_ = 0; +} + +ACE_DLL_Manager::ACE_DLL_Manager (int size) + : handle_vector_ (0), + current_size_ (0), + total_size_ (0), + unload_policy_ (ACE_DLL_UNLOAD_POLICY_PER_DLL) +{ + ACE_TRACE ("ACE_DLL_Manager::ACE_DLL_Manager"); + + if (this->open (size) != 0 && ACE::debug ()) + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("ACE_DLL_Manager ctor failed to allocate ") + ACE_TEXT ("handle_vector_.\n"))); +} + +ACE_DLL_Manager::~ACE_DLL_Manager (void) +{ + ACE_TRACE ("ACE_DLL_Manager::~ACE_DLL_Manager"); + + if (this->close () != 0 && ACE::debug ()) + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("ACE_DLL_Manager dtor failed to close ") + ACE_TEXT ("properly.\n"))); +} + +ACE_DLL_Handle * +ACE_DLL_Manager::open_dll (const ACE_TCHAR *dll_name, + int open_mode, + ACE_SHLIB_HANDLE handle) +{ + ACE_TRACE ("ACE_DLL_Manager::open_dll"); + + ACE_DLL_Handle *temp_handle = 0; + ACE_DLL_Handle *dll_handle = 0; + { + ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, 0)); + dll_handle = this->find_dll (dll_name); + if (!dll_handle) + { + if (this->current_size_ < this->total_size_) + { + ACE_NEW_RETURN (temp_handle, + ACE_DLL_Handle, + 0); + + dll_handle = temp_handle; + } + } + } + + if (dll_handle) + { + if (dll_handle->open (dll_name, open_mode, handle) != 0) + { + // Error while opening dll. Free temp handle + if (ACE::debug ()) + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("ACE_DLL_Manager::open_dll: Could not ") + ACE_TEXT ("open dll %s.\n"), + dll_name)); + + delete temp_handle; + return 0; + } + + // Add the handle to the vector only if the dll is successfully + // opened. + if (temp_handle != 0) + { + ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, 0)); + this->handle_vector_[this->current_size_] = dll_handle; + ++this->current_size_; + } + } + + return dll_handle; +} + +int +ACE_DLL_Manager::close_dll (const ACE_TCHAR *dll_name) +{ + ACE_TRACE ("ACE_DLL_Manager::close_dll"); + ACE_DLL_Handle *handle = 0; + + { + ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, 0)); + handle = this->find_dll (dll_name); + } + + if (handle) + { + return this->unload_dll (handle, 0); + } + + return -1; +} + +u_long +ACE_DLL_Manager::unload_policy (void) const +{ + ACE_TRACE ("ACE_DLL_Manager::unload_policy"); + return this->unload_policy_; +} + +void +ACE_DLL_Manager::unload_policy (u_long unload_policy) +{ + ACE_TRACE ("ACE_DLL_Manager::unload_policy"); + ACE_MT (ACE_GUARD (ACE_Thread_Mutex, ace_mon, this->lock_)); + + u_long old_policy = this->unload_policy_; + this->unload_policy_ = unload_policy; + + // If going from LAZY to EAGER or from PER_DLL to PER_PROCESS|EAGER, + // call close(1) on all the ACE_DLL_Handle objects with refcount == 0 + // which will force those that are still loaded to be unloaded. + if (this->handle_vector_) + if (( ACE_BIT_ENABLED (old_policy, ACE_DLL_UNLOAD_POLICY_LAZY) && + ACE_BIT_DISABLED (this->unload_policy_, ACE_DLL_UNLOAD_POLICY_LAZY) ) || + ( ACE_BIT_DISABLED (this->unload_policy_, ACE_DLL_UNLOAD_POLICY_LAZY) && + ACE_BIT_ENABLED (old_policy, ACE_DLL_UNLOAD_POLICY_PER_DLL) && + ACE_BIT_DISABLED (this->unload_policy_, ACE_DLL_UNLOAD_POLICY_PER_DLL) )) + { + for (int i = this->current_size_ - 1; i >= 0; i--) + { + if (this->handle_vector_[i] && + this->handle_vector_[i]->refcount () == 0) + this->handle_vector_[i]->close (1); + } + } +} + +int +ACE_DLL_Manager::open (int size) +{ + ACE_TRACE ("ACE_DLL_Manager::open"); + + ACE_DLL_Handle **temp = 0; + + ACE_NEW_RETURN (temp, + ACE_DLL_Handle *[size], + -1); + + this->handle_vector_ = temp; + this->total_size_ = size; + return 0; +} + +int +ACE_DLL_Manager::close (void) +{ + ACE_TRACE ("ACE_DLL_Manager::close"); + + int force_close = 1; + + if (this->handle_vector_ != 0) + { + // Delete components in reverse order. + for (int i = this->current_size_ - 1; i >= 0; i--) + { + if (this->handle_vector_[i]) + { + ACE_DLL_Handle *s = + const_cast (this->handle_vector_[i]); + this->handle_vector_[i] = 0; + this->unload_dll (s, force_close); + delete s; + } + } + + delete [] this->handle_vector_; + this->handle_vector_ = 0; + this->current_size_ = 0; + } + return 0; +} + +ACE_DLL_Handle * +ACE_DLL_Manager::find_dll (const ACE_TCHAR *dll_name) const +{ + ACE_TRACE ("ACE_DLL_Manager::find_dll"); + + for (int i = 0; i < this->current_size_; i++) + if (this->handle_vector_[i] && + ACE_OS::strcmp (this->handle_vector_[i]->dll_name (), dll_name) == 0) + { + return this->handle_vector_[i]; + } + + return 0; +} + +int +ACE_DLL_Manager::unload_dll (ACE_DLL_Handle *dll_handle, int force_unload) +{ + ACE_TRACE ("ACE_DLL_Manager::unload_dll"); + + if (dll_handle) + { + int unload = force_unload; + if (unload == 0) + { + // apply strategy + if (ACE_BIT_DISABLED (this->unload_policy_, + ACE_DLL_UNLOAD_POLICY_PER_DLL)) + { + unload = ACE_BIT_DISABLED (this->unload_policy_, + ACE_DLL_UNLOAD_POLICY_LAZY); + } + else + { + // Declare the type of the symbol: + typedef int (*dll_unload_policy)(void); + + void * const unload_policy_ptr = + dll_handle->symbol (ACE_TEXT ("_get_dll_unload_policy"), 1); +#if defined (ACE_OPENVMS) && (!defined (__INITIAL_POINTER_SIZE) || (__INITIAL_POINTER_SIZE < 64)) + int const temp_p = + reinterpret_cast (unload_policy_ptr); +#else + intptr_t const temp_p = + reinterpret_cast (unload_policy_ptr); +#endif + + dll_unload_policy const the_policy = + reinterpret_cast (temp_p); + + if (the_policy != 0) + unload = ACE_BIT_DISABLED (the_policy (), + ACE_DLL_UNLOAD_POLICY_LAZY); + else + unload = ACE_BIT_DISABLED (this->unload_policy_, + ACE_DLL_UNLOAD_POLICY_LAZY); + } + } + + if (dll_handle->close (unload) != 0) + { + if (ACE::debug ()) + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("ACE_DLL_Manager::unload error.\n"))); + + return -1; + } + } + else + { + if (ACE::debug ()) + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("ACE_DLL_Manager::unload_dll called with ") + ACE_TEXT ("null pointer.\n"))); + + return -1; + } + + return 0; +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/DLL_Manager.h b/dep/ACE_wrappers/ace/DLL_Manager.h new file mode 100644 index 00000000000..63b9ee04a84 --- /dev/null +++ b/dep/ACE_wrappers/ace/DLL_Manager.h @@ -0,0 +1,269 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file DLL_Manager.h + * + * $Id: DLL_Manager.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Don Hinton + */ +//============================================================================= + +#ifndef ACE_DLL_MANAGER_H +#define ACE_DLL_MANAGER_H +#include /**/ "ace/pre.h" + +#include /**/ "ace/ACE_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/Auto_Ptr.h" +#include "ace/Containers_T.h" +#include "ace/SStringfwd.h" +#include "ace/os_include/os_dlfcn.h" + +#if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0) +# include "ace/Thread_Mutex.h" +#endif /* ACE_MT_SAFE */ + +#define ACE_DEFAULT_DLL_MANAGER_SIZE 1024 + + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +/** + * @class ACE_DLL_Handle + * + * @brief Provides an abstract interface for handling various DLL + * operations. + * + * This class is an wrapper over the various methods for utilizing a + * dynamically linked library (DLL), which is called a shared library + * on some platforms. It is refcounted and managed by + * ACE_DLL_Manager, so there will only be a single instance of this + * class for each dll loaded, no matter how many instances of ACE_DLL + * an application has open. Operations , , and + * have been implemented to help opening/closing and extracting symbol + * information from a DLL, respectively. + * + * Most of this class came from the original ACE_DLL class. ACE_DLL + * is now just an interface that passed all it's calls either directly + * or via ACE_DLL_Manager to this class for execution. + * + */ +class ACE_Export ACE_DLL_Handle +{ +public: + + /// Default construtor. + ACE_DLL_Handle (void); + + /// Destructor. + ~ACE_DLL_Handle (void); + + /// Returns the name of the shared library (without prefixes or suffixes). + const ACE_TCHAR *dll_name () const; + + /** + * This method opens and dynamically links @a dll_name. The default + * mode is , which loads identifier symbols but not the + * symbols for functions, which are loaded dynamically on-demand. + * Other supported modes include: , which performs all + * necessary relocations when @a dll_name is first loaded and + * , which makes symbols available for relocation + * processing of any other DLLs. Returns -1 on failure and 0 on + * success. + */ + int open (const ACE_TCHAR *dll_name, + int open_mode, + ACE_SHLIB_HANDLE handle); + + /// Call to close the DLL object. If unload = 0, it only decrements + /// the refcount, but if unload = 1, then it will actually unload + /// the library when the refcount == 0; + int close (int unload = 0); + + /// Return the current refcount. + sig_atomic_t refcount (void) const; + + /// If @a symbol_name is in the symbol table of the DLL a pointer to + /// the @a symbol_name is returned. Otherwise, returns 0. Set the + /// ignore_errors flag to supress logging errors if symbol_name isn't + /// found. This is nice if you just want to probe a dll to see what's + /// available, since missing functions in that case aren't really errors. + void *symbol (const ACE_TCHAR *symbol_name, int ignore_errors = 0); + + /** + * Return the handle to the caller. If @a become_owner is non-0 then + * caller assumes ownership of the handle so we decrement the retcount. + */ + ACE_SHLIB_HANDLE get_handle (int become_owner = 0); + +private: + + /// Returns a pointer to a string explaining why or + /// failed. This is used internal to print out the error to the log, + /// but since this object is shared, we can't store or return the error + /// to the caller. + auto_ptr error (void); + + // Builds array of DLL names to try to dlopen, based on platform + // and configured DLL prefixes/suffixes. + // Returns the array of names to try in try_names. + void get_dll_names (const ACE_TCHAR *dll_name, + ACE_Array &try_names); + + // Disallow copying and assignment since we don't handle them. + ACE_DLL_Handle (const ACE_DLL_Handle &); + void operator= (const ACE_DLL_Handle &); + +private: + + // Keep track of how many ACE_DLL objects have a reference to this + // dll. + sig_atomic_t refcount_; + + /// Name of the shared library. + ACE_TCHAR *dll_name_; + + /// Handle to the actual library loaded by the OS. + ACE_SHLIB_HANDLE handle_; + + /// Keeps track of whether or not open() has ever been called. This + /// helps get around problem on Linux, and perhaps other OS's, that + /// seg-fault if dlerror() is called before the ld library has been + /// initialized by a call to dlopen(). + static sig_atomic_t open_called_; + +#if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0) + /// Synchronization variable for the MT_SAFE Repository + ACE_Thread_Mutex lock_; +#endif /* ACE_MT_SAFE */ +}; + +class ACE_Framework_Repository; + +/** + * @class ACE_DLL_Manager + * + * @brief This class is a singleton and serves as a factory and + * repository for instances of ACE_DLL_Handle. + * + * This class is a singleton whose lifetime is managed by the + * ACE_Framework_Repository. Although it is normally meant to be + * used directly only by ACE_DLL, applications can call the unload_policy() + * methods in order get/set the the dll unload policy. Unload policies include + * per_process/per-dll and eager/lazy. Dlls can export set their own policy + * by using the ACE_DLL_UNLOAD_POLICY macro found in config-all.h. If a dll + * choses to set an unload policy, it will be used when the per-dll policy + * (the default) is in effect. If the per-dll policy is in effect and a dll + * has not chosen to set a policy, the current per-process policy will be + * used. + * + * The following policy macros are provided in config-all.h: + * + * ACE_DLL_UNLOAD_POLICY_PER_PROCESS - Per-process policy that unloads dlls + * eagerly. + * + * ACE_DLL_UNLOAD_POLICY_PER_DLL - Apply policy on a per-dll basis. If the + * dll doesn't use one of the macros below, the current per-process policy + * will be used. + * + * ACE_DLL_UNLOAD_POLICY_LAZY - Don't unload dll when refcount reaches + * zero, i.e., wait for either an explicit unload request or program exit. + * + * ACE_DLL_UNLOAD_POLICY_DEFAULT - Default policy allows dlls to control + * their own destinies, but will unload those that don't make a choice eagerly. + * + */ +class ACE_Export ACE_DLL_Manager +{ +public: + friend class ACE_Framework_Repository; + friend class ACE_Object_Manager; + + enum + { + DEFAULT_SIZE = ACE_DEFAULT_DLL_MANAGER_SIZE + }; + + /// Return a unique instance + static ACE_DLL_Manager *instance (int size = ACE_DLL_Manager::DEFAULT_SIZE); + + /// Factory for ACE_DLL_Handle objects. If one already exits, + /// its refcount is incremented. + ACE_DLL_Handle *open_dll (const ACE_TCHAR *dll_name, + int openmode, + ACE_SHLIB_HANDLE handle); + + /// Close the underlying dll. Decrements the refcount. + int close_dll (const ACE_TCHAR *dll_name); + + /// Returns the current per-process UNLOAD_POLICY. + u_long unload_policy (void) const; + + /// Set the per-process UNLOAD_POLICY. If the policy is changed from + /// LAZY to EAGER, then it will also unload any dlls with zero + /// refcounts. + void unload_policy (u_long unload_policy); + +protected: + + /// Default constructor. + ACE_DLL_Manager (int size = ACE_DLL_Manager::DEFAULT_SIZE); + + /// Destructor. + ~ACE_DLL_Manager (void); + + // Allocate handle_vector_. + int open (int size); + + // Close all open dlls and deallocate memory. + int close (void); + + // Find dll in handle_vector_. + ACE_DLL_Handle *find_dll (const ACE_TCHAR *dll_name) const; + + // Applies strategy for unloading dll. + int unload_dll (ACE_DLL_Handle *dll_handle, int force_unload = 0); + +private: + + /// Close the singleton instance. + static void close_singleton (void); + + // Disallow copying and assignment since we don't handle these. + ACE_DLL_Manager (const ACE_DLL_Manager &); + void operator= (const ACE_DLL_Manager &); + +private: + + /// Vector containing all loaded handle objects. + ACE_DLL_Handle **handle_vector_; + + /// Current number of handles. + int current_size_; + + /// Maximum number of handles. + int total_size_; + + /// Unload strategy. + u_long unload_policy_; + + /// Pointer to a process-wide ACE_DLL_Manager. + static ACE_DLL_Manager *instance_; + +#if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0) + /// Synchronization variable for the MT_SAFE Repository + ACE_Thread_Mutex lock_; +#endif /* ACE_MT_SAFE */ + +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#include /**/ "ace/post.h" +#endif /* ACE_DLL_MANAGER_H */ diff --git a/dep/ACE_wrappers/ace/Date_Time.cpp b/dep/ACE_wrappers/ace/Date_Time.cpp new file mode 100644 index 00000000000..eff0f273fe7 --- /dev/null +++ b/dep/ACE_wrappers/ace/Date_Time.cpp @@ -0,0 +1,10 @@ +// Date_Time.cpp +// $Id: Date_Time.cpp 80826 2008-03-04 14:51:23Z wotte $ + +#include "ace/Date_Time.h" + +#if !defined (__ACE_INLINE__) +#include "ace/Date_Time.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(ace, Date_Time, "$Id: Date_Time.cpp 80826 2008-03-04 14:51:23Z wotte $") diff --git a/dep/ACE_wrappers/ace/Date_Time.h b/dep/ACE_wrappers/ace/Date_Time.h new file mode 100644 index 00000000000..a15d435eeb8 --- /dev/null +++ b/dep/ACE_wrappers/ace/Date_Time.h @@ -0,0 +1,125 @@ +// -*- C++ -*- + +//========================================================================== +/** + * @file Date_Time.h + * + * $Id: Date_Time.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Tim Harrison (harrison@cs.wustl.edu) (and he's darn proud of this ;-)) + * + */ +//========================================================================== + +#ifndef ACE_DATE_TIME_H +#define ACE_DATE_TIME_H +#include /**/ "ace/pre.h" + +#include /**/ "ace/ACE_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +class ACE_Time_Value; + +/** + * @class ACE_Date_Time + * + * @brief System independent representation of date and time. + */ +class ACE_Export ACE_Date_Time +{ +public: + /// Constructor initializes current time/date info. + ACE_Date_Time (void); + + /// Constructor initializes with the given ACE_Time_Value + explicit ACE_Date_Time (const ACE_Time_Value& timevalue); + + /// Constructor with init values, no check for validy + /// Set/get portions of ACE_Date_Time, no check for validity. + ACE_Date_Time (long day, + long month = 0, + long year = 0, + long hour = 0, + long minute = 0, + long second = 0, + long microsec = 0, + long wday = 0); + + /// Update to the current time/date. + void update (void); + + /// Update to the given ACE_Time_Value + void update (const ACE_Time_Value& timevalue); + + /// Get day. + long day (void) const; + + /// Set day. + void day (long day); + + /// Get month. + long month (void) const; + + /// Set month. + void month (long month); + + /// Get year. + long year (void) const; + + /// Set year. + void year (long year); + + /// Get hour. + long hour (void) const; + + /// Set hour. + void hour (long hour); + + /// Get minute. + long minute (void) const; + + /// Set minute. + void minute (long minute); + + /// Get second. + long second (void) const; + + /// Set second. + void second (long second); + + /// Get microsec. + long microsec (void) const; + + /// Set microsec. + void microsec (long microsec); + + /// Get weekday. + long weekday (void) const; + + /// Set weekday. + void weekday (long wday); + +private: + long day_; + long month_; + long year_; + long hour_; + long minute_; + long second_; + long microsec_; + long wday_; +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +#include "ace/Date_Time.inl" +#endif /* __ACE_INLINE__ */ + +#include /**/ "ace/post.h" +#endif /* ACE_DATE_TIME_H */ diff --git a/dep/ACE_wrappers/ace/Date_Time.inl b/dep/ACE_wrappers/ace/Date_Time.inl new file mode 100644 index 00000000000..d34807d83a4 --- /dev/null +++ b/dep/ACE_wrappers/ace/Date_Time.inl @@ -0,0 +1,219 @@ +// -*- C++ -*- +// +// $Id: Date_Time.inl 80826 2008-03-04 14:51:23Z wotte $ + +#include "ace/Global_Macros.h" +#include "ace/Time_Value.h" +#include "ace/OS_NS_sys_time.h" +#include "ace/OS_NS_time.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_INLINE void +ACE_Date_Time::update (const ACE_Time_Value& timevalue) +{ +#if defined (ACE_HAS_WINCE) + // CE doesn't do localtime(). + FILETIME file_time = timevalue; + FILETIME local_file_time; + SYSTEMTIME sys_time; + ::FileTimeToLocalFileTime (&file_time, &local_file_time); + ::FileTimeToSystemTime (&local_file_time, &sys_time); + this->day_ = sys_time.wDay; + this->month_ = sys_time.wMonth; + this->year_ = sys_time.wYear; + this->hour_ = sys_time.wHour; + this->minute_ = sys_time.wMinute; + this->second_ = sys_time.wSecond; + this->microsec_ = sys_time.wMilliseconds * 1000; + this->wday_ = sys_time.wDayOfWeek; +#else + time_t time = timevalue.sec (); + struct tm tm_time; + ACE_OS::localtime_r (&time, &tm_time); + this->day_ = tm_time.tm_mday; + this->month_ = tm_time.tm_mon + 1; // localtime's months are 0-11 + this->year_ = tm_time.tm_year + 1900; // localtime reports years since 1900 + this->hour_ = tm_time.tm_hour; + this->minute_ = tm_time.tm_min; + this->second_ = tm_time.tm_sec; + this->microsec_ = timevalue.usec (); + this->wday_ = tm_time.tm_wday; +#endif /* ACE_HAS_WINCE */ +} + +ACE_INLINE void +ACE_Date_Time::update (void) +{ + ACE_TRACE ("ACE_Date_Time::update"); + + update(ACE_OS::gettimeofday ()); +} + +ACE_INLINE +ACE_Date_Time::ACE_Date_Time (void) +{ + ACE_TRACE ("ACE_Date_Time::ACE_Date_Time"); + this->update (); +} + +ACE_INLINE +ACE_Date_Time::ACE_Date_Time (const ACE_Time_Value& timevalue) +{ + ACE_TRACE ("ACE_Date_Time::ACE_Date_Time: timevalue"); + this->update (timevalue); +} + +// Constructor with init values, no check for validy +ACE_INLINE +ACE_Date_Time::ACE_Date_Time (long day, + long month, + long year, + long hour, + long minute, + long second, + long microsec, + long wday) + : day_ (day), + month_ (month), + year_ (year), + hour_ (hour), + minute_ (minute), + second_ (second), + microsec_ (microsec), + wday_ (wday) +{ + ACE_TRACE ("ACE_Date_Time::ACE_Date_Time"); +} + +// set/get portions of ACE_Date_Time, no check for validy + +// get day +ACE_INLINE long +ACE_Date_Time::day (void) const +{ + ACE_TRACE ("ACE_Date_Time::day"); + return day_; +} + +// set day +ACE_INLINE void +ACE_Date_Time::day (long day) +{ + ACE_TRACE ("ACE_Date_Time::day"); + day_ = day; +} + +// get month +ACE_INLINE long +ACE_Date_Time::month (void) const +{ + ACE_TRACE ("ACE_Date_Time::month"); + return month_; +} + +// set month +ACE_INLINE void +ACE_Date_Time::month (long month) +{ + ACE_TRACE ("ACE_Date_Time::month"); + month_ = month; +} + +// get year +ACE_INLINE long +ACE_Date_Time::year (void) const +{ + ACE_TRACE ("ACE_Date_Time::year"); + return year_; +} + +// set year +ACE_INLINE void +ACE_Date_Time::year (long year) +{ + ACE_TRACE ("ACE_Date_Time::year"); + year_ = year; +} + +// get hour +ACE_INLINE long +ACE_Date_Time::hour (void) const +{ + ACE_TRACE ("ACE_Date_Time::hour"); + return hour_; +} + +// set hour +ACE_INLINE void +ACE_Date_Time::hour (long hour) +{ + ACE_TRACE ("ACE_Date_Time::hour"); + hour_ = hour; +} + +// get minute +ACE_INLINE long +ACE_Date_Time::minute (void) const +{ + ACE_TRACE ("ACE_Date_Time::minute"); + return minute_; +} + +// set minute +ACE_INLINE void +ACE_Date_Time::minute (long minute) +{ + ACE_TRACE ("ACE_Date_Time::minute"); + minute_ = minute; +} + +// get second +ACE_INLINE long +ACE_Date_Time::second (void) const +{ + ACE_TRACE ("ACE_Date_Time::second"); + return second_; +} + +// set second +ACE_INLINE void +ACE_Date_Time::second (long second) +{ + ACE_TRACE ("ACE_Date_Time::second"); + second_ = second; +} + +// get microsec +ACE_INLINE long +ACE_Date_Time::microsec (void) const +{ + ACE_TRACE ("ACE_Date_Time::microsec"); + return microsec_; +} + +// set microsec +ACE_INLINE void +ACE_Date_Time::microsec (long microsec) +{ + ACE_TRACE ("ACE_Date_Time::microsec"); + microsec_ = microsec; +} + +// get wday +ACE_INLINE long +ACE_Date_Time::weekday (void) const +{ + ACE_TRACE ("ACE_Date_Time::weekday"); + return wday_; +} + +// set wday +ACE_INLINE void +ACE_Date_Time::weekday (long wday) +{ + ACE_TRACE ("ACE_Date_Time::weekday"); + wday_ = wday; +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Default_Constants.h b/dep/ACE_wrappers/ace/Default_Constants.h new file mode 100644 index 00000000000..13e99e9171b --- /dev/null +++ b/dep/ACE_wrappers/ace/Default_Constants.h @@ -0,0 +1,573 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Default_Constants.h + * + * $Id: Default_Constants.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Douglas C. Schmidt + * @author Jesper S. M|ller + * @author and a cast of thousands... + * + * This one is split from the famous OS.h + */ +//============================================================================= + +#ifndef ACE_DEFAULT_CONSTANTS_H +#define ACE_DEFAULT_CONSTANTS_H +#include /**/ "ace/pre.h" + +// Included just keep compilers that see #pragma dierctive first +// happy. +#include /**/ "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +// Define the default constants for ACE. Many of these are used for +// the ACE tests and applications. You can change these values by +// defining the macros in your config.h file. +# if !defined (ACE_DEFAULT_CLOSE_ALL_HANDLES) +# define ACE_DEFAULT_CLOSE_ALL_HANDLES true +# endif /* ACE_DEFAULT_CLOSE_ALL_HANDLES */ + +// The maximum length for a fully qualified Internet name. +# if !defined(ACE_MAX_FULLY_QUALIFIED_NAME_LEN) +# define ACE_MAX_FULLY_QUALIFIED_NAME_LEN 256 +# endif /* ACE_MAX_FULLY_QUALIFIED_NAME_LEN */ + +#if !defined (ACE_DEFAULT_PAGEFILE_POOL_BASE) +#define ACE_DEFAULT_PAGEFILE_POOL_BASE (void *) 0 +#endif /* ACE_DEFAULT_PAGEFILE_POOL_BASE */ + +#if !defined (ACE_DEFAULT_PAGEFILE_POOL_SIZE) +#define ACE_DEFAULT_PAGEFILE_POOL_SIZE (size_t) 0x01000000 +#endif /* ACE_DEFAULT_PAGEFILE_POOL_SIZE */ + +#if !defined (ACE_DEFAULT_PAGEFILE_POOL_CHUNK) +#define ACE_DEFAULT_PAGEFILE_POOL_CHUNK (size_t) 0x00010000 +#endif /* ACE_DEFAULT_PAGEFILE_POOL_CHUNK */ + +#if !defined (ACE_DEFAULT_PAGEFILE_POOL_NAME) +#define ACE_DEFAULT_PAGEFILE_POOL_NAME ACE_TEXT ("Default_ACE_Pagefile_Memory_Pool") +#endif /* ACE_DEFAULT_PAGEFILE_POOL_NAME */ + +#if !defined (ACE_DEFAULT_MESSAGE_BLOCK_PRIORITY) +#define ACE_DEFAULT_MESSAGE_BLOCK_PRIORITY 0 +#endif /* ACE_DEFAULT_MESSAGE_BLOCK_PRIORITY */ + +#if !defined (ACE_DEFAULT_SERVICE_REPOSITORY_SIZE) +#define ACE_DEFAULT_SERVICE_REPOSITORY_SIZE 1024 +#endif /* ACE_DEFAULT_SERVICE_REPOSITORY_SIZE */ + +#if !defined (ACE_REACTOR_NOTIFICATION_ARRAY_SIZE) +#define ACE_REACTOR_NOTIFICATION_ARRAY_SIZE 1024 +#endif /* ACE_REACTOR_NOTIFICATION_ARRAY_SIZE */ + +# if !defined (ACE_DEFAULT_TIMEOUT) +# define ACE_DEFAULT_TIMEOUT 5 +# endif /* ACE_DEFAULT_TIMEOUT */ + +# if !defined (ACE_DEFAULT_BACKLOG) +# define ACE_DEFAULT_BACKLOG 5 +# endif /* ACE_DEFAULT_BACKLOG */ + +# if !defined (ACE_DEFAULT_ASYNCH_BACKLOG) +# define ACE_DEFAULT_ASYNCH_BACKLOG 5 +# endif /* ACE_DEFAULT_ASYNCH_BACKLOG */ + +# if !defined (ACE_DEFAULT_THREADS) +# define ACE_DEFAULT_THREADS 1 +# endif /* ACE_DEFAULT_THREADS */ + +// The following 3 defines are used in the IP multicast and broadcast tests. +# if !defined (ACE_DEFAULT_BROADCAST_PORT) +# define ACE_DEFAULT_BROADCAST_PORT 20000 +# endif /* ACE_DEFAULT_BROADCAST_PORT */ + +# if !defined (ACE_DEFAULT_MULTICAST_PORT) +# define ACE_DEFAULT_MULTICAST_PORT 20001 +# endif /* ACE_DEFAULT_MULTICAST_PORT */ + +# if !defined (ACE_DEFAULT_MULTICAST_ADDR) +// This address MUST be within the range for host group addresses: +// 224.0.0.0 to 239.255.255.255. +# define ACE_DEFAULT_MULTICAST_ADDR "224.9.9.2" +# endif /* ACE_DEFAULT_MULTICAST_ADDR */ + +# if defined (ACE_HAS_IPV6) +# if !defined (ACE_DEFAULT_MULTICASTV6_ADDR) +// This address should be within the range for site-local addresses: +// ff05::0/16 . +# define ACE_DEFAULT_MULTICASTV6_ADDR "ff05:0::ff01:1" +# endif /* ACE_DEFAULT_MULTICASTV6_ADDR */ +# endif + +// Default port number for HTTP. +# if !defined (ACE_DEFAULT_HTTP_SERVER_PORT) +# define ACE_DEFAULT_HTTP_SERVER_PORT 80 +# endif /* ACE_DEFAULT_HTTP_SERVER_PORT */ + +// Used in many IPC_SAP tests +# if !defined (ACE_DEFAULT_SERVER_PORT) +# define ACE_DEFAULT_SERVER_PORT 20002 +# endif /* ACE_DEFAULT_SERVER_PORT */ + +# if !defined (ACE_DEFAULT_HTTP_PORT) +# define ACE_DEFAULT_HTTP_PORT 80 +# endif /* ACE_DEFAULT_HTTP_PORT */ + +# if !defined (ACE_DEFAULT_MAX_SOCKET_BUFSIZ) +# define ACE_DEFAULT_MAX_SOCKET_BUFSIZ 65536 +# endif /* ACE_DEFAULT_MAX_SOCKET_BUFSIZ */ + +# if !defined (ACE_DEFAULT_SERVER_PORT_STR) +# define ACE_DEFAULT_SERVER_PORT_STR ACE_TEXT("20002") +# endif /* ACE_DEFAULT_SERVER_PORT_STR */ + +// Used for the Service_Directory test +# if !defined (ACE_DEFAULT_SERVICE_PORT) +# define ACE_DEFAULT_SERVICE_PORT 20003 +# endif /* ACE_DEFAULT_SERVICE_PORT */ + +// Used for the ACE_Thread_Spawn test +# if !defined (ACE_DEFAULT_THR_PORT ) +# define ACE_DEFAULT_THR_PORT 20004 +# endif /* ACE_DEFAULT_THR_PORT */ + +// Used for tests +# if !defined (ACE_DEFAULT_LOCAL_PORT) +# define ACE_DEFAULT_LOCAL_PORT 20005 +# endif /* ACE_DEFAULT_LOCAL_PORT */ + +// Used for Connector tests +# if !defined (ACE_DEFAULT_LOCAL_PORT_STR) +# define ACE_DEFAULT_LOCAL_PORT_STR "20005" +# endif /* ACE_DEFAULT_LOCAL_PORT_STR */ + +// Used for the name server. +# if !defined (ACE_DEFAULT_NAME_SERVER_PORT) +# define ACE_DEFAULT_NAME_SERVER_PORT 20006 +# endif /* ACE_DEFAULT_NAME_SERVER_PORT */ + +# if !defined (ACE_DEFAULT_NAME_SERVER_PORT_STR) +# define ACE_DEFAULT_NAME_SERVER_PORT_STR "20006" +# endif /* ACE_DEFAULT_NAME_SERVER_PORT_STR */ + +// Used for the token server. +# if !defined (ACE_DEFAULT_TOKEN_SERVER_PORT) +# define ACE_DEFAULT_TOKEN_SERVER_PORT 20007 +# endif /* ACE_DEFAULT_TOKEN_SERVER_PORT */ + +# if !defined (ACE_DEFAULT_TOKEN_SERVER_PORT_STR) +# define ACE_DEFAULT_TOKEN_SERVER_PORT_STR "20007" +# endif /* ACE_DEFAULT_TOKEN_SERVER_PORT_STR */ + +// Used for the logging server. +# if !defined (ACE_DEFAULT_LOGGING_SERVER_PORT) +# define ACE_DEFAULT_LOGGING_SERVER_PORT 20008 +# endif /* ACE_DEFAULT_LOGGING_SERVER_PORT */ + +# if !defined (ACE_DEFAULT_LOGGING_SERVER_PORT_STR) +# define ACE_DEFAULT_LOGGING_SERVER_PORT_STR "20008" +# endif /* ACE_DEFAULT_LOGGING_SERVER_PORT_STR */ + +// Used for the logging server. +# if !defined (ACE_DEFAULT_THR_LOGGING_SERVER_PORT) +# define ACE_DEFAULT_THR_LOGGING_SERVER_PORT 20008 +# endif /* ACE_DEFAULT_THR_LOGGING_SERVER_PORT */ + +# if !defined (ACE_DEFAULT_THR_LOGGING_SERVER_PORT_STR) +# define ACE_DEFAULT_THR_LOGGING_SERVER_PORT_STR "20008" +# endif /* ACE_DEFAULT_THR_LOGGING_SERVER_PORT_STR */ + +// Used for the time server. +# if !defined (ACE_DEFAULT_TIME_SERVER_PORT) +# define ACE_DEFAULT_TIME_SERVER_PORT 20009 +# endif /* ACE_DEFAULT_TIME_SERVER_PORT */ + +# if !defined (ACE_DEFAULT_TIME_SERVER_PORT_STR) +# define ACE_DEFAULT_TIME_SERVER_PORT_STR "20009" +# endif /* ACE_DEFAULT_TIME_SERVER_PORT_STR */ + +# if !defined (ACE_DEFAULT_TIME_SERVER_STR) +# define ACE_DEFAULT_TIME_SERVER_STR "ACE_TS_TIME" +# endif /* ACE_DEFAULT_TIME_SERVER_STR */ + +// Used by the FIFO tests and the Client_Logging_Handler netsvc. +# if !defined (ACE_DEFAULT_RENDEZVOUS) +# if defined (ACE_HAS_STREAM_PIPES) +# define ACE_DEFAULT_RENDEZVOUS ACE_TEXT("/tmp/fifo.ace") +# else +# define ACE_DEFAULT_RENDEZVOUS ACE_TEXT("localhost:20010") +# endif /* ACE_HAS_STREAM_PIPES */ +# endif /* ACE_DEFAULT_RENDEZVOUS */ + +// Used for the UNIX syslog logging interface to ACE_Log_Msg. +# ifndef ACE_DEFAULT_SYSLOG_FACILITY +# define ACE_DEFAULT_SYSLOG_FACILITY LOG_USER +# endif /* ACE_DEFAULT_SYSLOG_FACILITY */ + +# if !defined (ACE_DEFAULT_LOGGER_KEY) + +# if defined (ACE_HAS_STREAM_PIPES) +# define ACE_DEFAULT_LOGGER_KEY ACE_TEXT ("/tmp/server_daemon") +# else +# define ACE_DEFAULT_LOGGER_KEY ACE_TEXT ("localhost:20012") +# endif /* ACE_HAS_STREAM_PIPES */ +# endif /* ACE_DEFAULT_LOGGER_KEY */ + +// The way to specify the local host for loopback IP. This is usually +// "localhost" but it may need changing on some platforms. +# if !defined (ACE_LOCALHOST) +# define ACE_LOCALHOST ACE_TEXT ("localhost") +# endif + +// This specification for an IPv6 localhost should work on all platforms +// supporting IPv6 +# if defined (ACE_HAS_IPV6) +# if !defined (ACE_IPV6_LOCALHOST) +# define ACE_IPV6_LOCALHOST ACE_TEXT ("::1") +# endif /* ACE_IPV6_LOCALHOST*/ +#endif /* ACE_HAS_IPV6 */ + +// This specification for an IPv6 ANY address should work on all platforms +// supporting IPv6 +# if defined (ACE_HAS_IPV6) +# if !defined (ACE_IPV6_ANY) +# define ACE_IPV6_ANY ACE_TEXT ("::") +# endif /* ACE_IPV6_ANY*/ +#endif /* ACE_HAS_IPV6 */ + +# if !defined (ACE_DEFAULT_SERVER_HOST) +# if defined (ACE_HAS_IPV6) +# define ACE_DEFAULT_SERVER_HOST ACE_IPV6_LOCALHOST +# else /*ACE_HAS_IPV6*/ +# define ACE_DEFAULT_SERVER_HOST ACE_LOCALHOST +# endif /*ACE_HAS_IPV6*/ +# endif /* ACE_DEFAULT_SERVER_HOST */ + +// Default shared memory key +# if !defined (ACE_DEFAULT_SHM_KEY) +# define ACE_DEFAULT_SHM_KEY 1234 +# endif /* ACE_DEFAULT_SHM_KEY */ + +// Default address for shared memory mapped files and SYSV shared memory +// (defaults to 64 M). +# if !defined (ACE_DEFAULT_BASE_ADDR) +# define ACE_DEFAULT_BASE_ADDR ((char *) (64 * 1024 * 1024)) +# endif /* ACE_DEFAULT_BASE_ADDR */ + +// Default segment size used by SYSV shared memory (128 K) +# if !defined (ACE_DEFAULT_SEGMENT_SIZE) +# define ACE_DEFAULT_SEGMENT_SIZE 1024 * 128 +# endif /* ACE_DEFAULT_SEGMENT_SIZE */ + +// Maximum number of SYSV shared memory segments +// (does anyone know how to figure out the right values?!) +# if !defined (ACE_DEFAULT_MAX_SEGMENTS) +# define ACE_DEFAULT_MAX_SEGMENTS 6 +# endif /* ACE_DEFAULT_MAX_SEGMENTS */ + +// Name of the map that's stored in shared memory. +# if !defined (ACE_NAME_SERVER_MAP) +# define ACE_NAME_SERVER_MAP "Name Server Map" +# endif /* ACE_NAME_SERVER_MAP */ + +// Default file permissions. +# if !defined (ACE_DEFAULT_FILE_PERMS) +# if defined (ACE_VXWORKS) +# define ACE_DEFAULT_FILE_PERMS (S_IRUSR | S_IWUSR| S_IRGRP| S_IROTH) +# else +# define ACE_DEFAULT_FILE_PERMS 0644 +# endif /* ACE_VXWORKS */ +# endif /* ACE_DEFAULT_FILE_PERMS */ + +// Default directory permissions. +# if !defined (ACE_DEFAULT_DIR_PERMS) +# define ACE_DEFAULT_DIR_PERMS 0755 +# endif /* ACE_DEFAULT_DIR_PERMS */ + +# if !defined (ACE_DEFAULT_TIMEPROBE_TABLE_SIZE) +# define ACE_DEFAULT_TIMEPROBE_TABLE_SIZE 8 * 1024 +# endif /* ACE_DEFAULT_TIMEPROBE_TABLE_SIZE */ + +// Default size of the ACE Map_Manager. +# if !defined (ACE_DEFAULT_MAP_SIZE) +# define ACE_DEFAULT_MAP_SIZE 1024 +# endif /* ACE_DEFAULT_MAP_SIZE */ + +// Defaults for ACE Timer Wheel +# if !defined (ACE_DEFAULT_TIMER_WHEEL_SIZE) +# define ACE_DEFAULT_TIMER_WHEEL_SIZE 1024 +# endif /* ACE_DEFAULT_TIMER_WHEEL_SIZE */ + +# if !defined (ACE_DEFAULT_TIMER_WHEEL_RESOLUTION) +# define ACE_DEFAULT_TIMER_WHEEL_RESOLUTION 100 +# endif /* ACE_DEFAULT_TIMER_WHEEL_RESOLUTION */ + +// Default size for ACE Timer Hash table +# if !defined (ACE_DEFAULT_TIMER_HASH_TABLE_SIZE) +# define ACE_DEFAULT_TIMER_HASH_TABLE_SIZE 1024 +# endif /* ACE_DEFAULT_TIMER_HASH_TABLE_SIZE */ + +// Defaults for the ACE Free List +# if !defined (ACE_DEFAULT_FREE_LIST_PREALLOC) +# define ACE_DEFAULT_FREE_LIST_PREALLOC 0 +# endif /* ACE_DEFAULT_FREE_LIST_PREALLOC */ + +# if !defined (ACE_DEFAULT_FREE_LIST_LWM) +# define ACE_DEFAULT_FREE_LIST_LWM 0 +# endif /* ACE_DEFAULT_FREE_LIST_LWM */ + +# if !defined (ACE_DEFAULT_FREE_LIST_HWM) +# define ACE_DEFAULT_FREE_LIST_HWM 25000 +# endif /* ACE_DEFAULT_FREE_LIST_HWM */ + +# if !defined (ACE_DEFAULT_FREE_LIST_INC) +# define ACE_DEFAULT_FREE_LIST_INC 100 +# endif /* ACE_DEFAULT_FREE_LIST_INC */ + +# if !defined (ACE_UNIQUE_NAME_LEN) +# define ACE_UNIQUE_NAME_LEN 100 +# endif /* ACE_UNIQUE_NAME_LEN */ + +# if !defined (ACE_MAX_DGRAM_SIZE) + // This is just a guess. 8k is the normal limit on + // most machines because that's what NFS expects. +# define ACE_MAX_DGRAM_SIZE 8192 +# endif /* ACE_MAX_DGRAM_SIZE */ + +# if !defined (ACE_DEFAULT_ARGV_BUFSIZ) +# define ACE_DEFAULT_ARGV_BUFSIZ 1024 * 4 +# endif /* ACE_DEFAULT_ARGV_BUFSIZ */ + +// A free list which create more elements when there aren't enough +// elements. +# define ACE_FREE_LIST_WITH_POOL 1 + +// A simple free list which doen't allocate/deallocate elements. +# define ACE_PURE_FREE_LIST 2 + +# if defined (ACE_WIN32) + +// This is necessary to work around bugs with Win32 non-blocking +// connects... +# if !defined (ACE_NON_BLOCKING_BUG_DELAY) +# define ACE_NON_BLOCKING_BUG_DELAY 35000 +# endif /* ACE_NON_BLOCKING_BUG_DELAY */ +# endif /*ACE_WIN32*/ + +// Max size of an ACE Log Record data buffer. This can be reset in +// the config.h file if you'd like to increase or decrease the size. +# if !defined (ACE_MAXLOGMSGLEN) +# define ACE_MAXLOGMSGLEN 4 * 1024 +# endif /* ACE_MAXLOGMSGLEN */ + +// Max size of an ACE Token. +# define ACE_MAXTOKENNAMELEN 40 + +// Max size of an ACE Token client ID. +# define ACE_MAXCLIENTIDLEN MAXHOSTNAMELEN + 20 + +/// Max udp packet size +#if !defined (ACE_MAX_UDP_PACKET_SIZE) +#define ACE_MAX_UDP_PACKET_SIZE 65536 +#endif + +/** + * @name Default values to control CDR classes memory allocation strategies + */ +//@{ + +/// Control the initial size of all CDR buffers, application +/// developers may want to optimize this value to fit their request +/// size +#if !defined (ACE_DEFAULT_CDR_BUFSIZE) +# define ACE_DEFAULT_CDR_BUFSIZE 512 +#endif /* ACE_DEFAULT_CDR_BUFSIZE */ + +#if (ACE_DEFAULT_CDR_BUFSIZE == 0) +# error: ACE_DEFAULT_CDR_BUFSIZE should be bigger then 0 +#endif + +/// Stop exponential growth of CDR buffers to avoid overallocation +#if !defined (ACE_DEFAULT_CDR_EXP_GROWTH_MAX) +# define ACE_DEFAULT_CDR_EXP_GROWTH_MAX 65536 +#endif /* ACE_DEFAULT_CDR_EXP_GROWTH_MAX */ + +/// Control CDR buffer growth after maximum exponential growth is +/// reached +#if !defined (ACE_DEFAULT_CDR_LINEAR_GROWTH_CHUNK) +# define ACE_DEFAULT_CDR_LINEAR_GROWTH_CHUNK 65536 +#endif /* ACE_DEFAULT_CDR_LINEAR_GROWTH_CHUNK */ +//@} + +/// Control the zero-copy optimizations for octet sequences +/** + * Large octet sequences can be sent without any copies by chaining + * them in the list of message blocks that represent a single CDR + * stream. However, if the octet sequence is too small the zero copy + * optimizations actually hurt performance. Octet sequences smaller + * than this value will be copied. + */ +#if !defined (ACE_DEFAULT_CDR_MEMCPY_TRADEOFF) +#define ACE_DEFAULT_CDR_MEMCPY_TRADEOFF 256 +#endif /* ACE_DEFAULT_CDR_MEMCPY_TRADEOFF */ + +#if defined (ACE_WIN32) + // Define the pathname separator characters for Win32 (ugh). +# define ACE_DIRECTORY_SEPARATOR_STR_A "\\" +# define ACE_DIRECTORY_SEPARATOR_CHAR_A '\\' +#else + // Define the pathname separator characters for UNIX. +# define ACE_DIRECTORY_SEPARATOR_STR_A "/" +# define ACE_DIRECTORY_SEPARATOR_CHAR_A '/' +#endif /* ACE_WIN32 */ + +// Define the Wide character and normal versions of some of the string macros +#if defined (ACE_HAS_WCHAR) +# define ACE_DIRECTORY_SEPARATOR_STR_W ACE_TEXT_WIDE(ACE_DIRECTORY_SEPARATOR_STR_A) +# define ACE_DIRECTORY_SEPARATOR_CHAR_W ACE_TEXT_WIDE(ACE_DIRECTORY_SEPARATOR_CHAR_A) +#endif /* ACE_HAS_WCHAR */ + +#define ACE_DIRECTORY_SEPARATOR_STR ACE_TEXT (ACE_DIRECTORY_SEPARATOR_STR_A) +#define ACE_DIRECTORY_SEPARATOR_CHAR ACE_TEXT (ACE_DIRECTORY_SEPARATOR_CHAR_A) + +#if !defined (ACE_DEFAULT_THREAD_PRIORITY) +# define ACE_DEFAULT_THREAD_PRIORITY (-0x7fffffffL - 1L) +#endif /* ACE_DEFAULT_THREAD_PRIORITY */ + +#if !defined (ACE_DEFAULT_THREAD_STACKSIZE) +# define ACE_DEFAULT_THREAD_STACKSIZE 0 +#endif /* ACE_DEFAULT_THREAD_STACKSIZE */ + +#if !defined (ACE_MAX_DEFAULT_PORT) +# define ACE_MAX_DEFAULT_PORT 65535 +#endif /* ACE_MAX_DEFAULT_PORT */ + +// Default number of ACE_Event_Handlers supported by +// ACE_Timer_Heap. +# if !defined (ACE_DEFAULT_TIMERS) +# define ACE_DEFAULT_TIMERS _POSIX_TIMER_MAX +# endif /* ACE_DEFAULT_TIMERS */ + +#if defined (ACE_WIN32) +# define ACE_PLATFORM_A "Win32" +# define ACE_PLATFORM_EXE_SUFFIX_A ".exe" +#elif defined (ACE_VXWORKS) +# define ACE_PLATFORM_A "VxWorks" +# if defined (__RTP__) +# define ACE_PLATFORM_EXE_SUFFIX_A ".vxe" +# else +# define ACE_PLATFORM_EXE_SUFFIX_A ".out" +# endif +#else /* !ACE_WIN32 && !ACE_VXWORKS */ +# define ACE_PLATFORM_A "UNIX" +# define ACE_PLATFORM_EXE_SUFFIX_A "" +#endif /* ACE_WIN32 */ + +// Define the Wide character and normal versions of some of the string macros +#if defined (ACE_HAS_WCHAR) +# define ACE_PLATFORM_W ACE_TEXT_WIDE(ACE_PLATFORM_A) +# define ACE_PLATFORM_EXE_SUFFIX_W ACE_TEXT_WIDE(ACE_PLATFORM_EXE_SUFFIX_A) +#endif /* ACE_HAS_WCHAR */ + +#define ACE_PLATFORM ACE_TEXT (ACE_PLATFORM_A) +#define ACE_PLATFORM_EXE_SUFFIX ACE_TEXT (ACE_PLATFORM_EXE_SUFFIX_A) + +#if defined (ACE_WIN32) +# define ACE_LD_SEARCH_PATH ACE_TEXT ("PATH") +# define ACE_LD_SEARCH_PATH_SEPARATOR_STR ACE_TEXT (";") +# define ACE_DLL_SUFFIX ACE_TEXT (".dll") +# if defined (__MINGW32__) +# define ACE_DLL_PREFIX ACE_TEXT ("lib") +# else /* __MINGW32__ */ +# define ACE_DLL_PREFIX ACE_TEXT ("") +# endif /* __MINGW32__ */ +#else /* !ACE_WIN32 */ +# if !defined (ACE_LD_SEARCH_PATH) +# define ACE_LD_SEARCH_PATH ACE_TEXT ("LD_LIBRARY_PATH") +# endif /* ACE_LD_SEARCH_PATH */ +# if !defined (ACE_LD_SEARCH_PATH_SEPARATOR_STR) +# define ACE_LD_SEARCH_PATH_SEPARATOR_STR ACE_TEXT (":") +# endif /* ACE_LD_SEARCH_PATH_SEPARATOR_STR */ +#endif /* ACE_WIN32 */ + +#if !defined (ACE_DLL_SUFFIX) +# define ACE_DLL_SUFFIX ACE_TEXT (".so") +#endif /* ACE_DLL_SUFFIX */ + +#if !defined (ACE_DLL_PREFIX) +# define ACE_DLL_PREFIX ACE_TEXT ("lib") +#endif /* ACE_DLL_PREFIX */ + +#if defined (ACE_WIN32) +// Used for dynamic linking +# if !defined (ACE_DEFAULT_SVC_CONF) +# if (ACE_USES_CLASSIC_SVC_CONF == 1) +# define ACE_DEFAULT_SVC_CONF ACE_TEXT (".\\svc.conf") +# else +# define ACE_DEFAULT_SVC_CONF ACE_TEXT (".\\svc.conf.xml") +# endif /* ACE_USES_CLASSIC_SVC_CONF ==1 */ +# endif /* ACE_DEFAULT_SVC_CONF */ +#endif /* ACE_WIN32 */ + + // Used for dynamic linking. +#if !defined (ACE_DEFAULT_SVC_CONF) +# if (ACE_USES_CLASSIC_SVC_CONF == 1) +# define ACE_DEFAULT_SVC_CONF ACE_TEXT ("./svc.conf") +# else +# define ACE_DEFAULT_SVC_CONF ACE_TEXT ("./svc.conf.xml") +# endif /* ACE_USES_CLASSIC_SVC_CONF ==1 */ +#endif /* ACE_DEFAULT_SVC_CONF */ + +#if !defined (ACE_LOGGER_KEY) +# define ACE_LOGGER_KEY ACE_TEXT ("/tmp/server_daemon") +#endif /* ACE_LOGGER_KEY */ + +// Theses defines are used by the ACE Name Server. +#if !defined (ACE_DEFAULT_LOCALNAME_A) +# define ACE_DEFAULT_LOCALNAME_A "localnames" +#endif /* ACE_DEFAULT_LOCALNAME_A */ +#if !defined (ACE_DEFAULT_GLOBALNAME_A) +# define ACE_DEFAULT_GLOBALNAME_A "globalnames" +#endif /* ACE_DEFAULT_GLOBALNAME_A */ + +// ACE_DEFAULT_NAMESPACE_DIR is for legacy mode apps. A better +// way of doing this is something like ACE_Lib_Find::get_temp_dir, since +// this directory may not exist +#if defined (ACE_LEGACY_MODE) +# if defined (ACE_WIN32) +# define ACE_DEFAULT_NAMESPACE_DIR_A "C:\\temp" +# else /* ACE_WIN32 */ +# define ACE_DEFAULT_NAMESPACE_DIR_A "/tmp" +# endif /* ACE_WIN32 */ +# if defined (ACE_HAS_WCHAR) +# define ACE_DEFAULT_NAMESPACE_DIR_W ACE_TEXT_WIDE(ACE_DEFAULT_NAMESPACE_DIR_A) +# endif /* ACE_HAS_WCHAR */ +# define ACE_DEFAULT_NAMESPACE_DIR ACE_TEXT(ACE_DEFAULT_NAMESPACE_DIR_A) +#endif /* ACE_LEGACY_MODE */ + +#if defined (ACE_HAS_WCHAR) +# define ACE_DEFAULT_LOCALNAME_W ACE_TEXT_WIDE(ACE_DEFAULT_LOCALNAME_A) +# define ACE_DEFAULT_GLOBALNAME_W ACE_TEXT_WIDE(ACE_DEFAULT_GLOBALNAME_A) +#endif /* ACE_HAS_WCHAR */ + +#define ACE_DEFAULT_LOCALNAME ACE_TEXT (ACE_DEFAULT_LOCALNAME_A) +#define ACE_DEFAULT_GLOBALNAME ACE_TEXT (ACE_DEFAULT_GLOBALNAME_A) + +# if defined (ACE_WIN32) + // The "null" device on Win32. +# define ACE_DEV_NULL "nul" +# define ACE_SYSCALL_FAILED 0xFFFFFFFF +# else /* !ACE_WIN32 */ + // The "null" device on UNIX. +# define ACE_DEV_NULL "/dev/null" +# define ACE_SYSCALL_FAILED -1 +# endif /* ACE_WIN32 */ + +#include /**/ "ace/post.h" +#endif /*ACE_DEFAULT_CONSTANTS_H*/ diff --git a/dep/ACE_wrappers/ace/Dev_Poll_Reactor.cpp b/dep/ACE_wrappers/ace/Dev_Poll_Reactor.cpp new file mode 100644 index 00000000000..60a71d29962 --- /dev/null +++ b/dep/ACE_wrappers/ace/Dev_Poll_Reactor.cpp @@ -0,0 +1,2516 @@ +// $Id: Dev_Poll_Reactor.cpp 81315 2008-04-10 07:14:15Z johnnyw $ + +#include "ace/OS_NS_errno.h" +#include "ace/Dev_Poll_Reactor.h" +#include "ace/Signal.h" +#include "ace/Sig_Handler.h" + +ACE_RCSID (ace, + Dev_Poll_Reactor, + "$Id: Dev_Poll_Reactor.cpp 81315 2008-04-10 07:14:15Z johnnyw $") + +#if defined (ACE_HAS_EVENT_POLL) || defined (ACE_HAS_DEV_POLL) + +# include "ace/OS_NS_unistd.h" +# include "ace/OS_NS_fcntl.h" +# include "ace/OS_NS_stropts.h" + +# if defined (ACE_HAS_EVENT_POLL) && defined (linux) +# include /**/ +# elif defined (ACE_HAS_DEV_POLL) +# if defined (linux) +# include /**/ +# elif defined (HPUX_VERS) && HPUX_VERS < 1123 +# include /**/ +# else +# include /**/ +# endif /* linux */ +# endif /* ACE_HAS_DEV_POLL */ + +#if !defined (__ACE_INLINE__) +# include "ace/Dev_Poll_Reactor.inl" +#endif /* __ACE_INLINE__ */ + + +#include "ace/Handle_Set.h" +#include "ace/Reactor.h" +#include "ace/Timer_Heap.h" +#include "ace/Timer_Queue.h" +#include "ace/ACE.h" +#include "ace/Reverse_Lock_T.h" +#include "ace/Recursive_Thread_Mutex.h" +#include "ace/Null_Mutex.h" +#include "ace/os_include/os_poll.h" +#include "ace/OS_NS_sys_mman.h" +#include "ace/Guard_T.h" +#include "ace/OS_NS_string.h" +#include "ace/OS_NS_sys_time.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_Dev_Poll_Reactor_Notify::ACE_Dev_Poll_Reactor_Notify (void) + : dp_reactor_ (0) + , notification_pipe_ () + , max_notify_iterations_ (-1) +#if defined (ACE_HAS_REACTOR_NOTIFICATION_QUEUE) + , notification_queue_ () +#endif /* ACE_HAS_REACTOR_NOTIFICATION_QUEUE */ +{ +} + +int +ACE_Dev_Poll_Reactor_Notify::open (ACE_Reactor_Impl *r, + ACE_Timer_Queue * /* timer_queue */, + int disable_notify_pipe) +{ + ACE_TRACE ("ACE_Dev_Poll_Reactor_Notify::open"); + + if (disable_notify_pipe == 0) + { + this->dp_reactor_ = dynamic_cast (r); + + if (this->dp_reactor_ == 0) + { + errno = EINVAL; + return -1; + } + + if (this->notification_pipe_.open () == -1) + return -1; + +#if defined (F_SETFD) + // close-on-exec + ACE_OS::fcntl (this->notification_pipe_.read_handle (), F_SETFD, 1); + ACE_OS::fcntl (this->notification_pipe_.write_handle (), F_SETFD, 1); +#endif /* F_SETFD */ + +#if defined (ACE_HAS_REACTOR_NOTIFICATION_QUEUE) + if (notification_queue_.open () == -1) + { + return -1; + } + + if (ACE::set_flags (this->notification_pipe_.write_handle (), + ACE_NONBLOCK) == -1) + return -1; +#endif /* ACE_HAS_REACTOR_NOTIFICATION_QUEUE */ + + // Set the read handle into non-blocking mode since we need to + // perform a "speculative" read when determining if there are + // notifications to dispatch. + if (ACE::set_flags (this->notification_pipe_.read_handle (), + ACE_NONBLOCK) == -1) + return -1; + } + + return 0; +} + +int +ACE_Dev_Poll_Reactor_Notify::close (void) +{ + ACE_TRACE ("ACE_Dev_Poll_Reactor_Notify::close"); + +#if defined (ACE_HAS_REACTOR_NOTIFICATION_QUEUE) + notification_queue_.reset (); +#endif /* ACE_HAS_REACTOR_NOTIFICATION_QUEUE */ + + return this->notification_pipe_.close (); +} + +int +ACE_Dev_Poll_Reactor_Notify::notify (ACE_Event_Handler *eh, + ACE_Reactor_Mask mask, + ACE_Time_Value *timeout) +{ + ACE_TRACE ("ACE_Dev_Poll_Reactor_Notify::notify"); + + // Just consider this method a "no-op" if there's no + // ACE_Dev_Poll_Reactor configured. + if (this->dp_reactor_ == 0) + return 0; + + ACE_Notification_Buffer buffer (eh, mask); + +#if defined (ACE_HAS_REACTOR_NOTIFICATION_QUEUE) + ACE_UNUSED_ARG (timeout); + ACE_Dev_Poll_Handler_Guard eh_guard (eh); + + int notification_required = + notification_queue_.push_new_notification (buffer); + + if (notification_required == -1) + return -1; // Also decrement eh's reference count + + // The notification has been queued, so it will be delivered at some + // point (and may have been already); release the refcnt guard. + eh_guard.release (); + + if (notification_required == 0) + return 0; + + // Now pop the pipe to force the callback for dispatching when ready. If + // the send fails due to a full pipe, don't fail - assume the already-sent + // pipe bytes will cause the entire notification queue to be processed. + ssize_t n = ACE::send (this->notification_pipe_.write_handle (), + (char *) &buffer, + 1, // Only need one byte to pop the pipe + &ACE_Time_Value::zero); + if (n == -1 && (errno != ETIME && errno != EAGAIN)) + return -1; + + return 0; +#else + + ACE_Dev_Poll_Handler_Guard eh_guard (eh); + + ssize_t n = ACE::send (this->notification_pipe_.write_handle (), + (char *) &buffer, + sizeof buffer, + timeout); + if (n == -1) + return -1; + + eh_guard.release (); + + return 0; +#endif /* ACE_HAS_REACTOR_NOTIFICATION_QUEUE */ +} + +int +ACE_Dev_Poll_Reactor_Notify::dispatch_notifications ( + int & /* number_of_active_handles */, + ACE_Handle_Set & /* rd_mask */) +{ + ACE_TRACE ("ACE_Dev_Poll_Reactor_Notify::dispatch_notifications"); + + // This method is unimplemented in the ACE_Dev_Poll_Reactor. + // Instead, the notification handler is invoked as part of the IO + // event set. Doing so alters the some documented semantics that + // state that the notifications are handled before IO events. + // Enforcing such semantics does not appear to be beneficial, and + // also serves to slow down event dispatching particularly with this + // ACE_Dev_Poll_Reactor. + + ACE_NOTSUP_RETURN (-1); +} + +int +ACE_Dev_Poll_Reactor_Notify::read_notify_pipe (ACE_HANDLE handle, + ACE_Notification_Buffer &buffer) +{ + ACE_TRACE ("ACE_Dev_Poll_Reactor_Notify::read_notify_pipe"); + + // This is a (non-blocking) "speculative" read, i.e., we attempt to + // read even if no event was polled on the read handle. A + // speculative read is necessary since notifications must be + // dispatched before IO events. We can avoid the speculative read + // by "walking" the array of pollfd structures returned from + // `/dev/poll' or `/dev/epoll' but that is potentially much more + // expensive than simply checking for an EWOULDBLOCK. + size_t to_read; + char *read_p; + bool have_one = false; + +#if defined (ACE_HAS_REACTOR_NOTIFICATION_QUEUE) + // For the queued case, we'll try to read one byte (since that's what + // the notify () tried to put in) but we don't need it - notifications can + // be queued even if the pipe fills, so there may be more notifications + // queued than there are bytes in the pipe. + char b; + read_p = &b; + to_read = 1; + + // Before reading the byte, pop a message from the queue and queue a + // new message unless the queue is now empty. The protocol is to + // keep a byte in the pipe as long as the queue is not empty. + bool more_messages_queued = false; + ACE_Notification_Buffer next; + + int result = notification_queue_.pop_next_notification (buffer, + more_messages_queued, + next); + + if (result == 0) + { + // remove the notification byte from the pipe, avoiding notification loop + ACE::recv (handle, read_p, to_read); + return 0; + } + + if (result == -1) + return -1; + + if (more_messages_queued) + (void) ACE::send (this->notification_pipe_.write_handle (), + (char *)&next, + 1 /* one byte is enough */, + &ACE_Time_Value::zero); +#else + to_read = sizeof buffer; + read_p = (char *)&buffer; +#endif /* ACE_HAS_REACTOR_NOTIFICATION_QUEUE */ + + ssize_t n = ACE::recv (handle, read_p, to_read); + + if (n > 0) + { + // Check to see if we've got a short read. + if (static_cast (n) != to_read) + { + size_t remainder = to_read - n; + + // If so, try to recover by reading the remainder. If this + // doesn't work we're in big trouble since the input stream + // won't be aligned correctly. I'm not sure quite what to + // do at this point. It's probably best just to return -1. + if (ACE::recv (handle, &read_p[n], remainder) <= 0) + return -1; + } + + return 1; + } + + // Return -1 if things have gone seriously wrong. + if (n <= 0 && (errno != EWOULDBLOCK && errno != EAGAIN)) + return -1; + + return have_one ? 1 : 0; +} + + +int +ACE_Dev_Poll_Reactor_Notify::handle_input (ACE_HANDLE handle) +{ + ACE_TRACE ("ACE_Dev_Poll_Reactor_Notify::handle_input"); + + // @@ We may end up dispatching this event handler twice: once when + // performing the speculative read on the notification pipe + // handle, and once more when dispatching the IO events. + + // Precondition: this->select_reactor_.token_.current_owner () == + // ACE_Thread::self (); + + int number_dispatched = 0; + int result = 0; + ACE_Notification_Buffer buffer; + + while ((result = this->read_notify_pipe (handle, buffer)) > 0) + { + // Dispatch the buffer + // NOTE: We count only if we made any dispatches ie. upcalls. + if (this->dispatch_notify (buffer) > 0) + ++number_dispatched; + + // Bail out if we've reached the . Note that + // by default is -1, so we'll loop until all + // the available notifications have been dispatched. + if (number_dispatched == this->max_notify_iterations_) + break; + } + + if (result == -1) + { + // Reassign number_dispatched to -1 if things have gone + // seriously wrong. + number_dispatched = -1; + } + + // Enqueue ourselves into the list of waiting threads. When we + // reacquire the token we'll be off and running again with ownership + // of the token. The postcondition of this call is that + // == . + //this->select_reactor_->renew (); + + return number_dispatched; +} + +ACE_HANDLE +ACE_Dev_Poll_Reactor_Notify::notify_handle (void) +{ + ACE_TRACE ("ACE_Dev_Poll_Reactor_Notify::notify_handle"); + + return this->notification_pipe_.read_handle (); +} + +int +ACE_Dev_Poll_Reactor_Notify::is_dispatchable (ACE_Notification_Buffer &) +{ + ACE_TRACE ("ACE_Dev_Poll_Reactor_Notify::is_dispatchable"); + + ACE_NOTSUP_RETURN (-1); +} + +int +ACE_Dev_Poll_Reactor_Notify::dispatch_notify (ACE_Notification_Buffer &buffer) +{ + ACE_TRACE ("ACE_Dev_Poll_Reactor_Notify::dispatch_notify"); + + // If eh == 0 then another thread is unblocking the + // ACE_Dev_Poll_Reactor to update the ACE_Dev_Poll_Reactor's + // internal structures. Otherwise, we need to dispatch the + // appropriate handle_* method on the ACE_Event_Handler + // pointer we've been passed. + if (buffer.eh_ != 0) + { + int result = 0; + + // Guard the handler's refcount. Recall that when the notify + // was queued, the refcount was incremented, so it need not be + // now. The guard insures that it is decremented properly. + ACE_Dev_Poll_Handler_Guard eh_guard (buffer.eh_, false); + + switch (buffer.mask_) + { + case ACE_Event_Handler::READ_MASK: + case ACE_Event_Handler::ACCEPT_MASK: + result = buffer.eh_->handle_input (ACE_INVALID_HANDLE); + break; + case ACE_Event_Handler::WRITE_MASK: + result = buffer.eh_->handle_output (ACE_INVALID_HANDLE); + break; + case ACE_Event_Handler::EXCEPT_MASK: + result = buffer.eh_->handle_exception (ACE_INVALID_HANDLE); + break; + default: + // Should we bail out if we get an invalid mask? + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("dispatch_notify invalid mask = %d\n"), + buffer.mask_)); + } + if (result == -1) + buffer.eh_->handle_close (ACE_INVALID_HANDLE, buffer.mask_); + } + + return 1; +} + +void +ACE_Dev_Poll_Reactor_Notify::max_notify_iterations (int iterations) +{ + ACE_TRACE ("ACE_Dev_Poll_Reactor_Notify::max_notify_iterations"); + + // Must always be > 0 or < 0 to optimize the loop exit condition. + if (iterations == 0) + iterations = 1; + + this->max_notify_iterations_ = iterations; +} + +int +ACE_Dev_Poll_Reactor_Notify::max_notify_iterations (void) +{ + ACE_TRACE ("ACE_Dev_Poll_Reactor_Notify::max_notify_iterations"); + + return this->max_notify_iterations_; +} + +int +ACE_Dev_Poll_Reactor_Notify::purge_pending_notifications ( + ACE_Event_Handler *eh, + ACE_Reactor_Mask mask) +{ + ACE_TRACE ("ACE_Dev_Poll_Reactor_Notify::purge_pending_notifications"); + +#if defined (ACE_HAS_REACTOR_NOTIFICATION_QUEUE) + + return notification_queue_.purge_pending_notifications (eh, mask); + +#else /* defined (ACE_HAS_REACTOR_NOTIFICATION_QUEUE) */ + ACE_UNUSED_ARG (eh); + ACE_UNUSED_ARG (mask); + ACE_NOTSUP_RETURN (-1); +#endif /* defined (ACE_HAS_REACTOR_NOTIFICATION_QUEUE) */ +} + +void +ACE_Dev_Poll_Reactor_Notify::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + ACE_TRACE ("ACE_Dev_Poll_Reactor_Notify::dump"); + + ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("dp_reactor_ = %@"), + this->dp_reactor_)); + this->notification_pipe_.dump (); + ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); +#endif /* ACE_HAS_DUMP */ +} + +// ----------------------------------------------------------------- + +ACE_Dev_Poll_Reactor_Handler_Repository:: +ACE_Dev_Poll_Reactor_Handler_Repository (void) + : max_size_ (0), + handlers_ (0) +{ + ACE_TRACE ("ACE_Dev_Poll_Reactor_Handler_Repository::ACE_Dev_Poll_Reactor_Handler_Repository"); +} + +int +ACE_Dev_Poll_Reactor_Handler_Repository::invalid_handle ( + ACE_HANDLE handle) const +{ + ACE_TRACE ("ACE_Dev_Poll_Reactor_Handler_Repository::invalid_handle"); + + if (handle < 0 || handle >= this->max_size_) + { + errno = EINVAL; + return 1; + } + else + return 0; +} + +int +ACE_Dev_Poll_Reactor_Handler_Repository::handle_in_range ( + ACE_HANDLE handle) const +{ + ACE_TRACE ("ACE_Dev_Poll_Reactor_Handler_Repository::handle_in_range"); + + if (handle >= 0 && handle < this->max_size_) + return 1; + else + { + errno = EINVAL; + return 0; + } +} + +int +ACE_Dev_Poll_Reactor_Handler_Repository::open (size_t size) +{ + ACE_TRACE ("ACE_Dev_Poll_Reactor_Handler_Repository::open"); + + this->max_size_ = size; + + // Try to allocate the memory. + ACE_NEW_RETURN (this->handlers_, + ACE_Dev_Poll_Event_Tuple[size], + -1); + + // Try to increase the number of handles if is greater than + // the current limit. + return ACE::set_handle_limit (size); +} + +int +ACE_Dev_Poll_Reactor_Handler_Repository::unbind_all (void) +{ + ACE_TRACE ("ACE_Dev_Poll_Reactor_Handler_Repository::unbind_all"); + + // Unbind all of the event handlers. + for (int handle = 0; + handle < this->max_size_; + ++handle) + this->unbind (handle); + + return 0; +} + +int +ACE_Dev_Poll_Reactor_Handler_Repository::close (void) +{ + ACE_TRACE ("ACE_Dev_Poll_Reactor_Handler_Repository::close"); + + if (this->handlers_ != 0) + { + this->unbind_all (); + + delete [] this->handlers_; + this->handlers_ = 0; + } + + return 0; +} + +ACE_Event_Handler * +ACE_Dev_Poll_Reactor_Handler_Repository::find (ACE_HANDLE handle, + size_t *index_p) +{ + ACE_TRACE ("ACE_Dev_Poll_Reactor_Handler_Repository::find"); + + ACE_Event_Handler *eh = 0; + + // Only bother to search for the if it's in range. + if (this->handle_in_range (handle)) + { + eh = this->handlers_[handle].event_handler; + if (eh != 0) + { + if (index_p != 0) + *index_p = handle; + } + else + errno = ENOENT; + } + + return eh; +} + +int +ACE_Dev_Poll_Reactor_Handler_Repository::bind ( + ACE_HANDLE handle, + ACE_Event_Handler *event_handler, + ACE_Reactor_Mask mask) +{ + ACE_TRACE ("ACE_Dev_Poll_Reactor_Handler_Repository::bind"); + + if (event_handler == 0) + return -1; + + if (handle == ACE_INVALID_HANDLE) + handle = event_handler->get_handle (); + + if (this->invalid_handle (handle)) + return -1; + + this->handlers_[handle].event_handler = event_handler; + this->handlers_[handle].mask = mask; + event_handler->add_reference (); + + return 0; +} + +int +ACE_Dev_Poll_Reactor_Handler_Repository::unbind (ACE_HANDLE handle, + bool decr_refcnt) +{ + ACE_TRACE ("ACE_Dev_Poll_Reactor_Handler_Repository::unbind"); + + if (this->find (handle) == 0) + return -1; + + if (decr_refcnt) + this->handlers_[handle].event_handler->remove_reference (); + this->handlers_[handle].event_handler = 0; + this->handlers_[handle].mask = ACE_Event_Handler::NULL_MASK; + this->handlers_[handle].suspended = 0; + + return 0; +} + +// ----------------------------------------------------------------- + +ACE_Dev_Poll_Reactor::ACE_Dev_Poll_Reactor (ACE_Sig_Handler *sh, + ACE_Timer_Queue *tq, + int disable_notify_pipe, + ACE_Reactor_Notify *notify, + int mask_signals, + int s_queue) + : initialized_ (false) + , poll_fd_ (ACE_INVALID_HANDLE) + , size_ (0) + // , ready_set_ () +#if defined (ACE_HAS_EVENT_POLL) + , events_ (0) + , start_pevents_ (0) + , end_pevents_ (0) +#else + , dp_fds_ (0) + , start_pfds_ (0) + , end_pfds_ (0) +#endif /* ACE_HAS_EVENT_POLL */ + , deactivated_ (0) + , token_ (*this, s_queue) + , lock_adapter_ (token_) + , timer_queue_ (0) + , delete_timer_queue_ (false) + , signal_handler_ (0) + , delete_signal_handler_ (false) + , notify_handler_ (0) + , delete_notify_handler_ (false) + , mask_signals_ (mask_signals) + , restart_ (0) +{ + ACE_TRACE ("ACE_Dev_Poll_Reactor::ACE_Dev_Poll_Reactor"); + + if (this->open (ACE::max_handles (), + 0, + sh, + tq, + disable_notify_pipe, + notify) == -1) + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("%p\n"), + ACE_TEXT ("ACE_Dev_Poll_Reactor::open ") + ACE_TEXT ("failed inside ") + ACE_TEXT ("ACE_Dev_Poll_Reactor::CTOR"))); +} + +ACE_Dev_Poll_Reactor::ACE_Dev_Poll_Reactor (size_t size, + int rs, + ACE_Sig_Handler *sh, + ACE_Timer_Queue *tq, + int disable_notify_pipe, + ACE_Reactor_Notify *notify, + int mask_signals, + int s_queue) + : initialized_ (false) + , poll_fd_ (ACE_INVALID_HANDLE) + , size_ (0) + // , ready_set_ () +#if defined (ACE_HAS_EVENT_POLL) + , events_ (0) + , start_pevents_ (0) + , end_pevents_ (0) +#else + , dp_fds_ (0) + , start_pfds_ (0) + , end_pfds_ (0) +#endif /* ACE_HAS_EVENT_POLL */ + , deactivated_ (0) + , token_ (*this, s_queue) + , lock_adapter_ (token_) + , timer_queue_ (0) + , delete_timer_queue_ (false) + , signal_handler_ (0) + , delete_signal_handler_ (false) + , notify_handler_ (0) + , delete_notify_handler_ (false) + , mask_signals_ (mask_signals) + , restart_ (0) +{ + if (this->open (size, + rs, + sh, + tq, + disable_notify_pipe, + notify) == -1) + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("%p\n"), + ACE_TEXT ("ACE_Dev_Poll_Reactor::open ") + ACE_TEXT ("failed inside ACE_Dev_Poll_Reactor::CTOR"))); +} + +ACE_Dev_Poll_Reactor::~ACE_Dev_Poll_Reactor (void) +{ + ACE_TRACE ("ACE_Dev_Poll_Reactor::~ACE_Dev_Poll_Reactor"); + + (void) this->close (); +} + +int +ACE_Dev_Poll_Reactor::open (size_t size, + int restart, + ACE_Sig_Handler *sh, + ACE_Timer_Queue *tq, + int disable_notify_pipe, + ACE_Reactor_Notify *notify) +{ + ACE_TRACE ("ACE_Dev_Poll_Reactor::open"); + + ACE_MT (ACE_GUARD_RETURN (ACE_Dev_Poll_Reactor_Token, mon, this->token_, -1)); + + // Can't initialize ourselves more than once. + if (this->initialized_) + return -1; + + this->restart_ = restart; + this->signal_handler_ = sh; + this->timer_queue_ = tq; + this->notify_handler_ = notify; + + int result = 0; + + // Allows the signal handler to be overridden. + if (this->signal_handler_ == 0) + { + ACE_NEW_RETURN (this->signal_handler_, + ACE_Sig_Handler, + -1); + + if (this->signal_handler_ == 0) + result = -1; + else + this->delete_signal_handler_ = true; + } + + // Allows the timer queue to be overridden. + if (result != -1 && this->timer_queue_ == 0) + { + ACE_NEW_RETURN (this->timer_queue_, + ACE_Timer_Heap, + -1); + + if (this->timer_queue_ == 0) + result = -1; + else + this->delete_timer_queue_ = true; + } + + // Allows the Notify_Handler to be overridden. + if (result != -1 && this->notify_handler_ == 0) + { + ACE_NEW_RETURN (this->notify_handler_, + ACE_Dev_Poll_Reactor_Notify, + -1); + + if (this->notify_handler_ == 0) + result = -1; + else + this->delete_notify_handler_ = true; + } + +#if defined (ACE_HAS_EVENT_POLL) + + // Allocating event table: + ACE_NEW_RETURN (this->events_, epoll_event[size], -1); + + // Initializing epoll: + this->poll_fd_ = ::epoll_create (size); + if (this->poll_fd_ == -1) + result = -1; + +#else + + // Allocate the array before opening the device to avoid a potential + // resource leak if allocation fails. + ACE_NEW_RETURN (this->dp_fds_, + pollfd[size], + -1); + + // Open the `/dev/poll' character device. + this->poll_fd_ = ACE_OS::open ("/dev/poll", O_RDWR); + if (this->poll_fd_ == ACE_INVALID_HANDLE) + result = -1; + +#endif /* ACE_HAS_EVENT_POLL */ + + if (result != -1 && this->handler_rep_.open (size) == -1) + result = -1; + + // Registration of the notification handler must be done after the + // /dev/poll device has been fully initialized. + else if (this->notify_handler_->open (this, + 0, + disable_notify_pipe) == -1 + || (disable_notify_pipe == 0 + && this->register_handler_i ( + this->notify_handler_->notify_handle (), + this->notify_handler_, + ACE_Event_Handler::READ_MASK) == -1)) + result = -1; + + this->size_ = size; + + if (result != -1) + // We're all set to go. + this->initialized_ = true; + else + // This will close down all the allocated resources properly. + (void) this->close (); + + return result; +} + +int +ACE_Dev_Poll_Reactor::current_info (ACE_HANDLE, size_t & /* size */) +{ + ACE_NOTSUP_RETURN (-1); +} + + +int +ACE_Dev_Poll_Reactor::set_sig_handler (ACE_Sig_Handler *signal_handler) +{ + if (this->delete_signal_handler_) + delete this->signal_handler_; + + this->signal_handler_ = signal_handler; + this->delete_signal_handler_ = false; + + return 0; +} + +int +ACE_Dev_Poll_Reactor::timer_queue (ACE_Timer_Queue *tq) +{ + if (this->delete_timer_queue_) + delete this->timer_queue_; + + this->timer_queue_ = tq; + this->delete_timer_queue_ = false; + + return 0; + +} + +ACE_Timer_Queue * +ACE_Dev_Poll_Reactor::timer_queue (void) const +{ + return this->timer_queue_; +} + +int +ACE_Dev_Poll_Reactor::close (void) +{ + ACE_TRACE ("ACE_Dev_Poll_Reactor::close"); + + ACE_MT (ACE_GUARD_RETURN (ACE_Dev_Poll_Reactor_Token, mon, this->token_, -1)); + + int result = 0; + + if (this->poll_fd_ != ACE_INVALID_HANDLE) + { + result = ACE_OS::close (this->poll_fd_); + } + +#if defined (ACE_HAS_EVENT_POLL) + + delete [] this->events_; + this->events_ = 0; + +#else + + delete [] this->dp_fds_; + this->dp_fds_ = 0; + +#endif /* ACE_HAS_EVENT_POLL */ + + if (this->delete_signal_handler_) + { + delete this->signal_handler_; + this->signal_handler_ = 0; + this->delete_signal_handler_ = false; + } + + (void) this->handler_rep_.close (); + + if (this->delete_timer_queue_) + { + delete this->timer_queue_; + this->timer_queue_ = 0; + this->delete_timer_queue_ = false; + } + + if (this->notify_handler_ != 0) + this->notify_handler_->close (); + + if (this->delete_notify_handler_) + { + delete this->notify_handler_; + this->notify_handler_ = 0; + this->delete_notify_handler_ = false; + } + + this->poll_fd_ = ACE_INVALID_HANDLE; + +#if defined (ACE_HAS_EVENT_POLL) + this->start_pevents_ = 0; + this->end_pevents_ = 0; +#else + this->start_pfds_ = 0; + this->end_pfds_ = 0; +#endif /* ACE_HAS_EVENT_POLL */ + + this->initialized_ = false; + + return result; +} + +int +ACE_Dev_Poll_Reactor::work_pending (const ACE_Time_Value & max_wait_time) +{ + ACE_TRACE ("ACE_Dev_Poll_Reactor::work_pending"); + + // Stash the current time + // + // The destructor of this object will automatically compute how much + // time elapsed since this method was called. + ACE_Time_Value mwt (max_wait_time); + ACE_MT (ACE_Countdown_Time countdown (&mwt)); + + Token_Guard guard (this->token_); + int const result = guard.acquire_quietly (&mwt); + + // If the guard is NOT the owner just return the retval + if (!guard.is_owner ()) + return result; + + // Update the countdown to reflect time waiting for the mutex. + ACE_MT (countdown.update ()); + + return this->work_pending_i (&mwt); +} + +int +ACE_Dev_Poll_Reactor::work_pending_i (ACE_Time_Value * max_wait_time) +{ + ACE_TRACE ("ACE_Dev_Poll_Reactor::work_pending_i"); + + if (this->deactivated_) + return 0; + +#if defined (ACE_HAS_EVENT_POLL) + if (this->start_pevents_ != this->end_pevents_) +#else + if (this->start_pfds_ != this->end_pfds_) +#endif /* ACE_HAS_EVENT_POLL */ + return 1; // We still have work_pending (). Do not poll for + // additional events. + + ACE_Time_Value timer_buf (0); + ACE_Time_Value *this_timeout = + this->timer_queue_->calculate_timeout (max_wait_time, &timer_buf); + + // Check if we have timers to fire. + int const timers_pending = + ((this_timeout != 0 && max_wait_time == 0) + || (this_timeout != 0 && max_wait_time != 0 + && *this_timeout != *max_wait_time) ? 1 : 0); + + long const timeout = + (this_timeout == 0 + ? -1 /* Infinity */ + : static_cast (this_timeout->msec ())); + +#if defined (ACE_HAS_EVENT_POLL) + + // Wait for events. + int const nfds = ::epoll_wait (this->poll_fd_, + this->events_, + this->size_, + static_cast (timeout)); + + if (nfds > 0) + { + this->start_pevents_ = this->events_; + this->end_pevents_ = this->start_pevents_ + nfds; + } + +#else + + struct dvpoll dvp; + + dvp.dp_fds = this->dp_fds_; + dvp.dp_nfds = this->size_; + dvp.dp_timeout = timeout; // Milliseconds + + // Poll for events + int const nfds = ACE_OS::ioctl (this->poll_fd_, DP_POLL, &dvp); + + // Retrieve the results from the pollfd array. + this->start_pfds_ = dvp.dp_fds; + + // If nfds == 0 then end_pfds_ == start_pfds_ meaning that there is + // no work pending. If nfds > 0 then there is work pending. + // Otherwise an error occurred. + if (nfds > -1) + this->end_pfds_ = this->start_pfds_ + nfds; +#endif /* ACE_HAS_EVENT_POLL */ + + // If timers are pending, override any timeout from the poll. + return (nfds == 0 && timers_pending != 0 ? 1 : nfds); +} + + +int +ACE_Dev_Poll_Reactor::handle_events (ACE_Time_Value *max_wait_time) +{ + ACE_TRACE ("ACE_Dev_Poll_Reactor::handle_events"); + + // Stash the current time + // + // The destructor of this object will automatically compute how much + // time elapsed since this method was called. + ACE_MT (ACE_Countdown_Time countdown (max_wait_time)); + + Token_Guard guard (this->token_); + int const result = guard.acquire_quietly (max_wait_time); + + // If the guard is NOT the owner just return the retval + if (!guard.is_owner ()) + return result; + + if (this->deactivated_) + return -1; + + // Update the countdown to reflect time waiting for the mutex. + ACE_MT (countdown.update ()); + + return this->handle_events_i (max_wait_time, guard); +} + +int +ACE_Dev_Poll_Reactor::handle_events_i (ACE_Time_Value *max_wait_time, + Token_Guard &guard) +{ + ACE_TRACE ("ACE_Dev_Poll_Reactor::handle_events_i"); + + int result = 0; + // int active_handle_count = 0; + + // Poll for events + // + // If the underlying ioctl () call was interrupted via the interrupt + // signal (i.e. returned -1 with errno == EINTR) then the loop will + // be restarted if so desired. + do + { + result = this->work_pending_i (max_wait_time); + if (result == -1) + ACE_ERROR ((LM_ERROR, "%t: %p\n", "work_pending_i")); + } + while (result == -1 && this->restart_ != 0 && errno == EINTR); + + if (result == 0 || (result == -1 && errno == ETIME)) + return 0; + else if (result == -1) + { + if (errno != EINTR) + return -1; + + // Bail out -- we got here since the poll was interrupted. + // If it was due to a signal registered through our ACE_Sig_Handler, + // then it was dispatched, so we count it in the number of events + // handled rather than cause an error return. + if (ACE_Sig_Handler::sig_pending () != 0) + { + ACE_Sig_Handler::sig_pending (0); + return 1; + } + return -1; + } + + // Dispatch an event. + return this->dispatch (guard); +} + +// Dispatch an event. On entry, the token is held by the caller. If an +// event is found to dispatch, the token is released before dispatching it. +int +ACE_Dev_Poll_Reactor::dispatch (Token_Guard &guard) +{ + ACE_TRACE ("ACE_Dev_Poll_Reactor::dispatch"); + + // Perform the Template Method for dispatching the first located event. + // We dispatch only one to effectively dispatch events concurrently. + // As soon as an event is located, the token is released, allowing the + // next waiter to begin getting an event while we dispatch one here. + int result = 0; + + // Handle timers early since they may have higher latency + // constraints than I/O handlers. Ideally, the order of + // dispatching should be a strategy... + if ((result = this->dispatch_timer_handler (guard)) != 0) + return result; + + // Check to see if there are no more I/O handles left to + // dispatch AFTER we've handled the timers. + + // Finally, dispatch the I/O handlers. + result = this->dispatch_io_event (guard); + + return result; +} + +int +ACE_Dev_Poll_Reactor::dispatch_timer_handler (Token_Guard &guard) +{ + if (this->timer_queue_->is_empty ()) + return 0; // Empty timer queue so cannot have any expired timers. + + // Get the current time + ACE_Time_Value cur_time (this->timer_queue_->gettimeofday () + + this->timer_queue_->timer_skew ()); + + // Look for a node in the timer queue whose timer <= the present + // time. + ACE_Timer_Node_Dispatch_Info info; + if (this->timer_queue_->dispatch_info (cur_time, info)) + { + const void *upcall_act = 0; + + // Preinvoke (handles refcount if needed, etc.) + this->timer_queue_->preinvoke (info, cur_time, upcall_act); + + // Release the token before expiration upcall. + guard.release_token (); + + // call the functor + this->timer_queue_->upcall (info, cur_time); + + // Postinvoke (undo refcount if needed, etc.) + this->timer_queue_->postinvoke (info, cur_time, upcall_act); + + // We have dispatched a timer + return 1; + } + + return 0; +} + +#if 0 +int +ACE_Dev_Poll_Reactor::dispatch_notification_handlers ( + ACE_Select_Reactor_Handle_Set &dispatch_set, + int &number_of_active_handles, + int &number_of_handlers_dispatched) +{ + // Check to see if the ACE_HANDLE associated with the + // Dev_Poll_Reactor's notify hook is enabled. If so, it means that + // one or more other threads are trying to update the + // ACE_Dev_Poll_Reactor's internal tables or the notify pipe is + // enabled. We'll handle all these threads and notifications, and + // then break out to continue the event loop. + + const int n = + this->notify_handler_->dispatch_notifications (number_of_active_handles, + dispatch_set.rd_mask_); + + if (n == -1) + return -1; + else + number_of_handlers_dispatched += n; + + return /* this->state_changed_ ? -1 : */ 0; +} +#endif /* 0 */ + +int +ACE_Dev_Poll_Reactor::dispatch_io_event (Token_Guard &guard) +{ + + // Define bits to check for while dispatching. +#if defined (ACE_HAS_EVENT_POLL) + const __uint32_t out_event = EPOLLOUT; + const __uint32_t exc_event = EPOLLPRI; + const __uint32_t in_event = EPOLLIN; + const __uint32_t err_event = EPOLLHUP | EPOLLERR; +#else + const short out_event = POLLOUT; + const short exc_event = POLLPRI; + const short in_event = POLLIN; + const short err_event = 0; // No known bits for this +#endif /* ACE_HAS_EVENT_POLL */ + + // Since the underlying event demultiplexing mechansim (`/dev/poll' + // or '/dev/epoll') is stateful, and since only one result buffer is + // used, all pending events (i.e. those retrieved from a previous + // poll) must be dispatched before any additional event can be + // polled. As such, the Dev_Poll_Reactor keeps track of the + // progress of events that have been dispatched. + + // Dispatch the events. + // + // Select the first available handle with event (s) pending. Check for + // event type in defined order of dispatch: output, exception, input. + // When an event is located, clear its bit in the dispatch set. If there + // are no more events for the handle, also increment the pfds pointer + // to move to the next handle ready. + // + // Notice that pfds only contains file descriptors that have + // received events. +#if defined (ACE_HAS_EVENT_POLL) + struct epoll_event *& pfds = this->start_pevents_; + if (pfds < this->end_pevents_) +#else + struct pollfd *& pfds = this->start_pfds_; + if (pfds < this->end_pfds_) +#endif /* ACE_HAS_EVENT_POLL */ + { +#if defined (ACE_HAS_EVENT_POLL) + const ACE_HANDLE handle = pfds->data.fd; + __uint32_t &revents = pfds->events; +#else + const ACE_HANDLE handle = pfds->fd; + short &revents = pfds->revents; +#endif /* ACE_HAS_EVENT_POLL */ + + // Figure out what to do first in order to make it easier to manage + // the bit twiddling and possible pfds increment before releasing + // the token for dispatch. + // Note that if there's an error (such as the handle was closed + // without being removed from the event set) the EPOLLHUP and/or + // EPOLLERR bits will be set in revents. + bool disp_out = false; + bool disp_exc = false; + bool disp_in = false; + if (ACE_BIT_ENABLED (revents, out_event)) + { + disp_out = true; + ACE_CLR_BITS (revents, out_event); + } + else if (ACE_BIT_ENABLED (revents, exc_event)) + { + disp_exc = true; + ACE_CLR_BITS (revents, exc_event); + } + else if (ACE_BIT_ENABLED (revents, in_event)) + { + disp_in = true; + ACE_CLR_BITS (revents, in_event); + } + else if (ACE_BIT_ENABLED (revents, err_event)) + { + this->remove_handler_i (handle, ACE_Event_Handler::ALL_EVENTS_MASK); + ++pfds; + return 1; + } + else + { + ACE_ERROR ((LM_ERROR, ACE_TEXT (" (%t) dispatch_io h %d unknown events 0x%x\n"), handle, revents)); + // ACE_ASSERT (0); + } + + // Increment the pointer to the next element before we + // release the token. Otherwise event handlers end up being + // dispatched multiple times for the same poll. + if (revents == 0) + ++pfds; + + /* When using sys_epoll, we can attach arbitrary user + data to the descriptor, so it can be delivered when + activity is detected. Perhaps we should store event + handler together with descriptor, instead of looking + it up in a repository ? Could it boost performance ? + */ + ACE_Event_Handler *eh = this->handler_rep_.find (handle); + + if (eh) + { + // Modify the reference count in an exception-safe way. + // Note that eh could be the notify handler. It's not strictly + // necessary to manage its refcount, but since we don't enable + // the counting policy, it won't do much. Management of the + // notified handlers themselves is done in the notify handler. + ACE_Dev_Poll_Handler_Guard eh_guard (eh); + + // Release the reactor token before upcall. + guard.release_token (); + + // Dispatch the detected event + if (disp_out) + { + const int status = + this->upcall (eh, &ACE_Event_Handler::handle_output, handle); + + if (status < 0) + // Note that the token is reacquired in remove_handler (). + this->remove_handler (handle, ACE_Event_Handler::WRITE_MASK); + return 1; + } + + if (disp_exc) + { + const int status = + this->upcall (eh, &ACE_Event_Handler::handle_exception, handle); + + if (status < 0) + // Note that the token is reacquired in remove_handler (). + this->remove_handler (handle, ACE_Event_Handler::EXCEPT_MASK); + return 1; + } + + if (disp_in) + { + const int status = + this->upcall (eh, &ACE_Event_Handler::handle_input, handle); + + if (status < 0) + // Note that the token is reacquired in remove_handler (). + this->remove_handler (handle, ACE_Event_Handler::READ_MASK); + return 1; + } + } // The reactor token is reacquired upon leaving this scope. + } + + return 0; +} + +int +ACE_Dev_Poll_Reactor::alertable_handle_events (ACE_Time_Value *max_wait_time) +{ + ACE_TRACE ("ACE_Dev_Poll_Reactor::alertable_handle_events"); + + return this->handle_events (max_wait_time); +} + +int +ACE_Dev_Poll_Reactor::handle_events (ACE_Time_Value &max_wait_time) +{ + ACE_TRACE ("ACE_Dev_Poll_Reactor::handle_events"); + + return this->handle_events (&max_wait_time); +} + +int +ACE_Dev_Poll_Reactor::alertable_handle_events (ACE_Time_Value &max_wait_time) +{ + ACE_TRACE ("ACE_Dev_Poll_Reactor::alertable_handle_events"); + + return this->handle_events (max_wait_time); +} + +int +ACE_Dev_Poll_Reactor::deactivated (void) +{ + return this->deactivated_; +} + +void +ACE_Dev_Poll_Reactor::deactivate (int do_stop) +{ + this->deactivated_ = do_stop; + this->wakeup_all_threads (); +} + +int +ACE_Dev_Poll_Reactor::register_handler (ACE_Event_Handler *handler, + ACE_Reactor_Mask mask) +{ + ACE_TRACE ("ACE_Dev_Poll_Reactor::register_handler"); + + ACE_MT (ACE_GUARD_RETURN (ACE_Dev_Poll_Reactor_Token, mon, this->token_, -1)); + + return this->register_handler_i (handler->get_handle (), + handler, + mask); +} + +int +ACE_Dev_Poll_Reactor::register_handler (ACE_HANDLE handle, + ACE_Event_Handler *event_handler, + ACE_Reactor_Mask mask) +{ + ACE_TRACE ("ACE_Dev_Poll_Reactor::register_handler"); + + ACE_MT (ACE_GUARD_RETURN (ACE_Dev_Poll_Reactor_Token, mon, this->token_, -1)); + + return this->register_handler_i (handle, + event_handler, + mask); +} + +int +ACE_Dev_Poll_Reactor::register_handler_i (ACE_HANDLE handle, + ACE_Event_Handler *event_handler, + ACE_Reactor_Mask mask) +{ + ACE_TRACE ("ACE_Dev_Poll_Reactor::register_handler_i"); + + if (handle == ACE_INVALID_HANDLE + || mask == ACE_Event_Handler::NULL_MASK) + { + errno = EINVAL; + return -1; + } + + if (this->handler_rep_.find (handle) == 0) + { + // Handler not present in the repository. Bind it. + if (this->handler_rep_.bind (handle, event_handler, mask) != 0) + return -1; + +#if defined (ACE_HAS_EVENT_POLL) + + struct epoll_event epev; + ACE_OS::memset (&epev, 0, sizeof (epev)); + static const int op = EPOLL_CTL_ADD; + + epev.events = this->reactor_mask_to_poll_event (mask); + epev.data.fd = handle; + + if (::epoll_ctl (this->poll_fd_, op, handle, &epev) == -1) + { + ACE_ERROR ((LM_ERROR, "%p\n", "epoll_ctl")); + (void) this->handler_rep_.unbind (handle); + return -1; + } + +#endif /* ACE_HAS_EVENT_POLL */ + } + else + { + // Handler is already present in the repository, so register it + // again, possibly for different event. Add new mask to the + // current one. + if (this->mask_ops_i (handle, mask, ACE_Reactor::ADD_MASK) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "mask_ops_i"), -1); + } + +#ifndef ACE_HAS_EVENT_POLL + + struct pollfd pfd; + + pfd.fd = handle; + pfd.events = this->reactor_mask_to_poll_event (mask); + pfd.revents = 0; + + // Add file descriptor to the "interest set." + if (ACE_OS::write (this->poll_fd_, &pfd, sizeof (pfd)) != sizeof (pfd)) + { + (void) this->handler_rep_.unbind (handle); + return -1; + } +#endif /*ACE_HAS_EVENT_POLL*/ + + // Note the fact that we've changed the state of the wait_set_, + // which is used by the dispatching loop to determine whether it can + // keep going or if it needs to reconsult select (). + // this->state_changed_ = 1; + + return 0; +} + +int +ACE_Dev_Poll_Reactor::register_handler ( + ACE_HANDLE /* event_handle */, + ACE_HANDLE /* io_handle */, + ACE_Event_Handler * /* event_handler */, + ACE_Reactor_Mask /* mask */) +{ + ACE_NOTSUP_RETURN (-1); +} + +int +ACE_Dev_Poll_Reactor::register_handler (const ACE_Handle_Set &handle_set, + ACE_Event_Handler *event_handler, + ACE_Reactor_Mask mask) +{ + ACE_TRACE ("ACE_Dev_Poll_Reactor::register_handler"); + + ACE_Handle_Set_Iterator handle_iter (handle_set); + + ACE_MT (ACE_GUARD_RETURN (ACE_Dev_Poll_Reactor_Token, mon, this->token_, -1)); + + // @@ It might be more efficient to construct a pollfd array and + // pass it to the write () call in register_handler_i () only once, + // instead of calling write () (a system call) once for each file + // descriptor. + + for (ACE_HANDLE h = handle_iter (); + h != ACE_INVALID_HANDLE; + h = handle_iter ()) + if (this->register_handler_i (h, event_handler, mask) == -1) + return -1; + + return 0; +} + +int +ACE_Dev_Poll_Reactor::register_handler (int signum, + ACE_Event_Handler *new_sh, + ACE_Sig_Action *new_disp, + ACE_Event_Handler **old_sh, + ACE_Sig_Action *old_disp) +{ + ACE_TRACE ("ACE_Dev_Poll_Reactor::register_handler"); + + return this->signal_handler_->register_handler (signum, + new_sh, + new_disp, + old_sh, + old_disp); +} + +int +ACE_Dev_Poll_Reactor::register_handler (const ACE_Sig_Set &sigset, + ACE_Event_Handler *new_sh, + ACE_Sig_Action *new_disp) +{ + ACE_TRACE ("ACE_Dev_Poll_Reactor::register_handler"); + + int result = 0; + +#if (ACE_NSIG > 0) + + for (int s = 1; s < ACE_NSIG; ++s) + if ((sigset.is_member (s) == 1) + && this->signal_handler_->register_handler (s, + new_sh, + new_disp) == -1) + result = -1; + +#else /* ACE_NSIG <= 0 */ + + ACE_UNUSED_ARG (sigset); + ACE_UNUSED_ARG (new_sh); + ACE_UNUSED_ARG (new_disp); + +#endif /* ACE_NSIG <= 0 */ + + return result; +} + +int +ACE_Dev_Poll_Reactor::remove_handler (ACE_Event_Handler *handler, + ACE_Reactor_Mask mask) +{ + ACE_TRACE ("ACE_Dev_Poll_Reactor::remove_handler"); + + ACE_MT (ACE_GUARD_RETURN (ACE_Dev_Poll_Reactor_Token, mon, this->token_, -1)); + + return this->remove_handler_i (handler->get_handle (), mask); +} + +int +ACE_Dev_Poll_Reactor::remove_handler (ACE_HANDLE handle, + ACE_Reactor_Mask mask) +{ + ACE_TRACE ("ACE_Dev_Poll_Reactor::remove_handler"); + + ACE_MT (ACE_GUARD_RETURN (ACE_Dev_Poll_Reactor_Token, mon, this->token_, -1)); + + return this->remove_handler_i (handle, mask); +} + +int +ACE_Dev_Poll_Reactor::remove_handler_i (ACE_HANDLE handle, + ACE_Reactor_Mask mask) +{ + ACE_TRACE ("ACE_Dev_Poll_Reactor::remove_handler_i"); + + ACE_Event_Handler *eh = this->handler_rep_.find (handle); + + if (eh == 0 || + this->mask_ops_i (handle, mask, ACE_Reactor::CLR_MASK) == -1) + return -1; + + // Check for ref counting now - handle_close () may delete eh. + bool const requires_reference_counting = + eh->reference_counting_policy ().value () == + ACE_Event_Handler::Reference_Counting_Policy::ENABLED; + + if (ACE_BIT_DISABLED (mask, ACE_Event_Handler::DONT_CALL)) + (void) eh->handle_close (handle, mask); + + // If there are no longer any outstanding events on the given handle + // then remove it from the handler repository. + if (this->handler_rep_.mask (handle) == ACE_Event_Handler::NULL_MASK) + this->handler_rep_.unbind (handle, requires_reference_counting); + + // Note the fact that we've changed the state of the wait_set, + // i.e. the "interest set," which is used by the dispatching loop to + // determine whether it can keep going or if it needs to reconsult + // /dev/poll or /dev/epoll. + // this->state_changed_ = 1; + + return 0; +} + +int +ACE_Dev_Poll_Reactor::remove_handler (const ACE_Handle_Set &handle_set, + ACE_Reactor_Mask mask) +{ + ACE_TRACE ("ACE_Dev_Poll_Reactor::remove_handler"); + + ACE_Handle_Set_Iterator handle_iter (handle_set); + + ACE_MT (ACE_GUARD_RETURN (ACE_Dev_Poll_Reactor_Token, mon, this->token_, -1)); + + // @@ It might be more efficient to construct a pollfd array and + // pass it to the write () call in register_handler_i () only once, + // instead of calling write () (a system call) once for each file + // descriptor. + + for (ACE_HANDLE h = handle_iter (); + h != ACE_INVALID_HANDLE; + h = handle_iter ()) + if (this->remove_handler_i (h, mask) == -1) + return -1; + + return 0; +} + +int +ACE_Dev_Poll_Reactor::remove_handler (int signum, + ACE_Sig_Action *new_disp, + ACE_Sig_Action *old_disp, + int sigkey) +{ + ACE_TRACE ("ACE_Dev_Poll_Reactor::remove_handler"); + + return this->signal_handler_->remove_handler (signum, + new_disp, + old_disp, + sigkey); +} + +int +ACE_Dev_Poll_Reactor::remove_handler (const ACE_Sig_Set &sigset) +{ + ACE_TRACE ("ACE_Dev_Poll_Reactor::remove_handler"); + + int result = 0; + +#if (ACE_NSIG > 0) + + for (int s = 1; s < ACE_NSIG; ++s) + if ((sigset.is_member (s) == 1) + && this->signal_handler_->remove_handler (s) == -1) + result = -1; + +#else /* ACE_NSIG <= 0 */ + + ACE_UNUSED_ARG (sigset); + +#endif /* ACE_NSIG <= 0 */ + + return result; +} + +int +ACE_Dev_Poll_Reactor::suspend_handler (ACE_Event_Handler *event_handler) +{ + ACE_TRACE ("ACE_Dev_Poll_Reactor::suspend_handler"); + + if (event_handler == 0) + { + errno = EINVAL; + return -1; + } + + ACE_HANDLE handle = event_handler->get_handle (); + + ACE_MT (ACE_GUARD_RETURN (ACE_Dev_Poll_Reactor_Token, mon, this->token_, -1)); + + return this->suspend_handler_i (handle); +} + +int +ACE_Dev_Poll_Reactor::suspend_handler (ACE_HANDLE handle) +{ + ACE_TRACE ("ACE_Dev_Poll_Reactor::suspend_handler"); + + ACE_MT (ACE_GUARD_RETURN (ACE_Dev_Poll_Reactor_Token, mon, this->token_, -1)); + + return this->suspend_handler_i (handle); +} + +int +ACE_Dev_Poll_Reactor::suspend_handler (const ACE_Handle_Set &handles) +{ + ACE_TRACE ("ACE_Dev_Poll_Reactor::suspend_handler"); + + ACE_Handle_Set_Iterator handle_iter (handles); + ACE_HANDLE h; + + ACE_MT (ACE_GUARD_RETURN (ACE_Dev_Poll_Reactor_Token, mon, this->token_, -1)); + + while ((h = handle_iter ()) != ACE_INVALID_HANDLE) + if (this->suspend_handler_i (h) == -1) + return -1; + + return 0; +} + +int +ACE_Dev_Poll_Reactor::suspend_handlers (void) +{ + ACE_TRACE ("ACE_Dev_Poll_Reactor::suspend_handlers"); + + ACE_MT (ACE_GUARD_RETURN (ACE_Dev_Poll_Reactor_Token, mon, this->token_, -1)); + + size_t const len = this->handler_rep_.size (); + + for (size_t i = 0; i < len; ++i) + if (this->handler_rep_.suspended (i) == 0 + && this->suspend_handler_i (i) != 0) + return -1; + + return 0; +} + +int +ACE_Dev_Poll_Reactor::suspend_handler_i (ACE_HANDLE handle) +{ + ACE_TRACE ("ACE_Dev_Poll_Reactor::suspend_handler_i"); + + if (this->handler_rep_.find (handle) == 0) + return -1; + + if (this->handler_rep_.suspended (handle)) + return 0; // Already suspended. @@ Should this be an error? + + // Remove the handle from the "interest set." + // + // Note that the associated event handler is still in the handler + // repository, but no events will be polled on the given handle thus + // no event will be dispatched to the event handler. + +#if defined (ACE_HAS_EVENT_POLL) + + struct epoll_event epev; + ACE_OS::memset (&epev, 0, sizeof (epev)); + static const int op = EPOLL_CTL_DEL; + + epev.events = 0; + epev.data.fd = handle; + + if (::epoll_ctl (this->poll_fd_, op, handle, &epev) == -1) + return -1; + +#else + + struct pollfd pfd[1]; + + pfd[0].fd = handle; + pfd[0].events = POLLREMOVE; + pfd[0].revents = 0; + + if (ACE_OS::write (this->poll_fd_, pfd, sizeof (pfd)) != sizeof (pfd)) + return -1; + +#endif /* ACE_HAS_EVENT_POLL */ + + this->handler_rep_.suspend (handle); + + return 0; +} + +int +ACE_Dev_Poll_Reactor::resume_handler (ACE_Event_Handler *event_handler) +{ + ACE_TRACE ("ACE_Dev_Poll_Reactor::resume_handler"); + + if (event_handler == 0) + { + errno = EINVAL; + return -1; + } + + ACE_HANDLE handle = event_handler->get_handle (); + + ACE_MT (ACE_GUARD_RETURN (ACE_Dev_Poll_Reactor_Token, mon, this->token_, -1)); + + return this->resume_handler_i (handle); +} + +int +ACE_Dev_Poll_Reactor::resume_handler (ACE_HANDLE handle) +{ + ACE_TRACE ("ACE_Dev_Poll_Reactor::resume_handler"); + + ACE_MT (ACE_GUARD_RETURN (ACE_Dev_Poll_Reactor_Token, mon, this->token_, -1)); + + return this->resume_handler_i (handle); +} + +int +ACE_Dev_Poll_Reactor::resume_handler (const ACE_Handle_Set &handles) +{ + ACE_TRACE ("ACE_Dev_Poll_Reactor::resume_handler"); + + ACE_Handle_Set_Iterator handle_iter (handles); + ACE_HANDLE h; + + ACE_MT (ACE_GUARD_RETURN (ACE_Dev_Poll_Reactor_Token, mon, this->token_, -1)); + + while ((h = handle_iter ()) != ACE_INVALID_HANDLE) + if (this->resume_handler_i (h) == -1) + return -1; + + return 0; +} + +int +ACE_Dev_Poll_Reactor::resume_handlers (void) +{ + ACE_TRACE ("ACE_Dev_Poll_Reactor::resume_handlers"); + + ACE_MT (ACE_GUARD_RETURN (ACE_Dev_Poll_Reactor_Token, mon, this->token_, -1)); + + size_t const len = this->handler_rep_.size (); + + for (size_t i = 0; i < len; ++i) + if (this->handler_rep_.suspended (i) + && this->resume_handler_i (i) != 0) + return -1; + + return 0; +} + +int +ACE_Dev_Poll_Reactor::resume_handler_i (ACE_HANDLE handle) +{ + ACE_TRACE ("ACE_Dev_Poll_Reactor::resume_handler_i"); + + if (this->handler_rep_.find (handle) == 0 + && this->handler_rep_.suspended (handle) == 0) + return -1; + + ACE_Reactor_Mask mask = this->handler_rep_.mask (handle); + + if (mask == ACE_Event_Handler::NULL_MASK) + return -1; + + // Place the handle back in to the "interest set." + // + // Events for the given handle will once again be polled. + +#if defined (ACE_HAS_EVENT_POLL) + + struct epoll_event epev; + ACE_OS::memset (&epev, 0, sizeof (epev)); + static const int op = EPOLL_CTL_ADD; + + epev.events = this->reactor_mask_to_poll_event (mask); + epev.data.fd = handle; + + if (::epoll_ctl (this->poll_fd_, op, handle, &epev) == -1) + return -1; + +#else + + struct pollfd pfd[1]; + + pfd[0].fd = handle; + pfd[0].events = this->reactor_mask_to_poll_event (mask); + pfd[0].revents = 0; + + if (ACE_OS::write (this->poll_fd_, pfd, sizeof (pfd)) != sizeof (pfd)) + return -1; + +#endif /* ACE_HAS_EVENT_POLL */ + + this->handler_rep_.resume (handle); + + return 0; +} + +int +ACE_Dev_Poll_Reactor::resumable_handler (void) +{ + // @@ Is this correct? + + return 0; +} + +int +ACE_Dev_Poll_Reactor::uses_event_associations (void) +{ + // Since the Dev_Poll_Reactor does not do any event associations, + // this method always return zero. + return 0; +} + +long +ACE_Dev_Poll_Reactor::schedule_timer (ACE_Event_Handler *event_handler, + const void *arg, + const ACE_Time_Value &delay, + const ACE_Time_Value &interval) +{ + ACE_TRACE ("ACE_Dev_Poll_Reactor::schedule_timer"); + + ACE_MT (ACE_GUARD_RETURN (ACE_Dev_Poll_Reactor_Token, mon, this->token_, -1)); + + if (0 != this->timer_queue_) + return this->timer_queue_->schedule + (event_handler, + arg, + this->timer_queue_->gettimeofday () + delay, + interval); + + errno = ESHUTDOWN; + return -1; +} + +int +ACE_Dev_Poll_Reactor::reset_timer_interval (long timer_id, + const ACE_Time_Value &interval) +{ + ACE_TRACE ("ACE_Dev_Poll_Reactor::reset_timer_interval"); + + ACE_MT (ACE_GUARD_RETURN (ACE_Dev_Poll_Reactor_Token, mon, this->token_, -1)); + + if (0 != this->timer_queue_) + return this->timer_queue_->reset_interval (timer_id, interval); + + errno = ESHUTDOWN; + return -1; +} + +int +ACE_Dev_Poll_Reactor::cancel_timer (ACE_Event_Handler *event_handler, + int dont_call_handle_close) +{ + ACE_TRACE ("ACE_Dev_Poll_Reactor::cancel_timer"); + + ACE_MT (ACE_GUARD_RETURN (ACE_Dev_Poll_Reactor_Token, mon, this->token_, -1)); + + return (this->timer_queue_ == 0 + ? 0 + : this->timer_queue_->cancel (event_handler, + dont_call_handle_close)); +} + +int +ACE_Dev_Poll_Reactor::cancel_timer (long timer_id, + const void **arg, + int dont_call_handle_close) +{ + ACE_TRACE ("ACE_Dev_Poll_Reactor::cancel_timer"); + + ACE_MT (ACE_GUARD_RETURN (ACE_Dev_Poll_Reactor_Token, mon, this->token_, -1)); + + return (this->timer_queue_ == 0 + ? 0 + : this->timer_queue_->cancel (timer_id, + arg, + dont_call_handle_close)); +} + +int +ACE_Dev_Poll_Reactor::schedule_wakeup (ACE_Event_Handler *eh, + ACE_Reactor_Mask mask) +{ + ACE_TRACE ("ACE_Dev_Poll_Reactor::schedule_wakeup"); + + return this->mask_ops (eh->get_handle (), mask, ACE_Reactor::ADD_MASK); +} + +int +ACE_Dev_Poll_Reactor::schedule_wakeup (ACE_HANDLE handle, + ACE_Reactor_Mask mask) +{ + ACE_TRACE ("ACE_Dev_Poll_Reactor::schedule_wakeup"); + + return this->mask_ops (handle, mask, ACE_Reactor::ADD_MASK); +} + +int +ACE_Dev_Poll_Reactor::cancel_wakeup (ACE_Event_Handler *eh, + ACE_Reactor_Mask mask) +{ + ACE_TRACE ("ACE_Dev_Poll_Reactor::cancel_wakeup"); + + return this->mask_ops (eh->get_handle (), mask, ACE_Reactor::CLR_MASK); +} + +int +ACE_Dev_Poll_Reactor::cancel_wakeup (ACE_HANDLE handle, + ACE_Reactor_Mask mask) +{ + ACE_TRACE ("ACE_Dev_Poll_Reactor::cancel_wakeup"); + + return this->mask_ops (handle, mask, ACE_Reactor::CLR_MASK); +} + +int +ACE_Dev_Poll_Reactor::notify (ACE_Event_Handler *eh, + ACE_Reactor_Mask mask, + ACE_Time_Value *timeout) +{ + ACE_TRACE ("ACE_Dev_Poll_Reactor::notify"); + + ssize_t n = 0; + + // Pass over both the Event_Handler *and* the mask to allow the + // caller to dictate which Event_Handler method the receiver + // invokes. Note that this call can timeout. + + n = this->notify_handler_->notify (eh, mask, timeout); + + return n == -1 ? -1 : 0; +} + +void +ACE_Dev_Poll_Reactor::max_notify_iterations (int iterations) +{ + ACE_TRACE ("ACE_Dev_Poll_Reactor::max_notify_iterations"); + + ACE_MT (ACE_GUARD (ACE_Dev_Poll_Reactor_Token, mon, this->token_)); + + this->notify_handler_->max_notify_iterations (iterations); +} + +int +ACE_Dev_Poll_Reactor::max_notify_iterations (void) +{ + ACE_TRACE ("ACE_Dev_Poll_Reactor::max_notify_iterations"); + + ACE_MT (ACE_GUARD_RETURN (ACE_Dev_Poll_Reactor_Token, mon, this->token_, -1)); + + return this->notify_handler_->max_notify_iterations (); +} + +int +ACE_Dev_Poll_Reactor::purge_pending_notifications (ACE_Event_Handler * eh, + ACE_Reactor_Mask mask) +{ + if (this->notify_handler_ == 0) + return 0; + + return this->notify_handler_->purge_pending_notifications (eh, mask); +} + +ACE_Event_Handler * +ACE_Dev_Poll_Reactor::find_handler (ACE_HANDLE handle) +{ + ACE_MT (ACE_READ_GUARD_RETURN (ACE_Dev_Poll_Reactor_Token, mon, this->token_, 0)); + + ACE_Event_Handler *event_handler = this->handler_rep_.find (handle); + if (event_handler) + event_handler->add_reference (); + return event_handler; +} + +int +ACE_Dev_Poll_Reactor::handler (ACE_HANDLE handle, + ACE_Reactor_Mask mask, + ACE_Event_Handler **event_handler) +{ + ACE_TRACE ("ACE_Dev_Poll_Reactor::handler"); + + ACE_MT (ACE_READ_GUARD_RETURN (ACE_Dev_Poll_Reactor_Token, mon, this->token_, -1)); + + ACE_Event_Handler *h = this->handler_rep_.find (handle); + + if (h != 0 + && ACE_BIT_CMP_MASK (this->handler_rep_.mask (handle), + mask, // Compare all bits in the mask + mask)) + { + if (event_handler != 0) + *event_handler = h; + + return 0; + } + + return -1; +} + +int +ACE_Dev_Poll_Reactor::handler (int signum, + ACE_Event_Handler **eh) +{ + ACE_TRACE ("ACE_Dev_Poll_Reactor::handler"); + + ACE_Event_Handler *handler = this->signal_handler_->handler (signum); + + if (handler == 0) + return -1; + else if (eh != 0) + *eh = handler; + + return 0; +} + +bool +ACE_Dev_Poll_Reactor::initialized (void) +{ + ACE_TRACE ("ACE_Dev_Poll_Reactor::initialized"); + + ACE_MT (ACE_GUARD_RETURN (ACE_Dev_Poll_Reactor_Token, mon, this->token_, false)); + + return this->initialized_; +} + +size_t +ACE_Dev_Poll_Reactor::size (void) const +{ + return this->size_; +} + +ACE_Lock & +ACE_Dev_Poll_Reactor::lock (void) +{ + ACE_TRACE ("ACE_Dev_Poll_Reactor::lock"); + + return this->lock_adapter_; +} + +void +ACE_Dev_Poll_Reactor::wakeup_all_threads (void) +{ + ACE_TRACE ("ACE_Dev_Poll_Reactor::wakeup_all_threads"); + + // Send a notification, but don't block if there's no one to receive + // it. + this->notify (0, + ACE_Event_Handler::NULL_MASK, + (ACE_Time_Value *) &ACE_Time_Value::zero); +} + +int +ACE_Dev_Poll_Reactor::owner (ACE_thread_t /* new_owner */, + ACE_thread_t * /* old_owner */) +{ + ACE_TRACE ("ACE_Dev_Poll_Reactor::owner"); + + // There is no need to set the owner of the event loop. Multiple + // threads may invoke the event loop simulataneously. + + return 0; +} + +int +ACE_Dev_Poll_Reactor::owner (ACE_thread_t * /* owner */) +{ + ACE_TRACE ("ACE_Dev_Poll_Reactor::owner"); + + // There is no need to set the owner of the event loop. Multiple + // threads may invoke the event loop simulataneously. + + return 0; +} + +int +ACE_Dev_Poll_Reactor::restart (void) +{ + ACE_TRACE ("ACE_Dev_Poll_Reactor::restart"); + + ACE_MT (ACE_GUARD_RETURN (ACE_Dev_Poll_Reactor_Token, mon, this->token_, -1)); + + return this->restart_; +} + +int +ACE_Dev_Poll_Reactor::restart (int r) +{ + ACE_TRACE ("ACE_Dev_Poll_Reactor::restart"); + + ACE_MT (ACE_GUARD_RETURN (ACE_Dev_Poll_Reactor_Token, mon, this->token_, -1)); + + int current_value = this->restart_; + this->restart_ = r; + return current_value; +} + +void +ACE_Dev_Poll_Reactor::requeue_position (int) +{ + ACE_TRACE ("ACE_Dev_Poll_Reactor::requeue_position"); +} + +int +ACE_Dev_Poll_Reactor::requeue_position (void) +{ + ACE_TRACE ("ACE_Dev_Poll_Reactor::requeue_position"); + + ACE_NOTSUP_RETURN (-1); +} + +int +ACE_Dev_Poll_Reactor::mask_ops (ACE_Event_Handler *event_handler, + ACE_Reactor_Mask mask, + int ops) +{ + ACE_TRACE ("ACE_Dev_Poll_Reactor::mask_ops"); + + ACE_MT (ACE_GUARD_RETURN (ACE_Dev_Poll_Reactor_Token, mon, this->token_, -1)); + + return this->mask_ops_i (event_handler->get_handle (), mask, ops); +} + +int +ACE_Dev_Poll_Reactor::mask_ops (ACE_HANDLE handle, + ACE_Reactor_Mask mask, + int ops) +{ + ACE_TRACE ("ACE_Dev_Poll_Reactor::mask_ops"); + + ACE_MT (ACE_GUARD_RETURN (ACE_Dev_Poll_Reactor_Token, mon, this->token_, -1)); + + return this->mask_ops_i (handle, mask, ops); +} + +int +ACE_Dev_Poll_Reactor::mask_ops_i (ACE_HANDLE handle, + ACE_Reactor_Mask mask, + int ops) +{ + ACE_TRACE ("ACE_Dev_Poll_Reactor::mask_ops_i"); + + if (this->handler_rep_.handle_in_range (handle) == 0) + return -1; + + // Block out all signals until method returns. + ACE_Sig_Guard sb; + + ACE_Reactor_Mask const old_mask = this->handler_rep_.mask (handle); + ACE_Reactor_Mask new_mask = old_mask; + + // Perform GET, CLR, SET, and ADD operations on the interest/wait + // set and the suspend set (if necessary). + // + // GET = 1, Retrieve current value + // SET = 2, Set value of bits to new mask (changes the entire mask) + // ADD = 3, Bitwise "or" the value into the mask (only changes + // enabled bits) + // CLR = 4 Bitwise "and" the negation of the value out of the mask + // (only changes enabled bits) + // + // Returns the original mask. + + switch (ops) + { + case ACE_Reactor::GET_MASK: + // The work for this operation is done in all cases at the + // begining of the function. + return old_mask; + + case ACE_Reactor::CLR_MASK: + ACE_CLR_BITS (new_mask, mask); + break; + + case ACE_Reactor::SET_MASK: + new_mask = mask; + break; + + case ACE_Reactor::ADD_MASK: + ACE_SET_BITS (new_mask, mask); + break; + + default: + return -1; + } + + /// Reset the mask for the given handle. + this->handler_rep_.mask (handle, new_mask); + + if (this->handler_rep_.suspended (handle) == 0) + { + // Only attempt to alter events for the handle from the + // "interest set" if it hasn't been suspended. + + short const events = this->reactor_mask_to_poll_event (new_mask); + +#if defined (sun) + // Apparently events cannot be updated on-the-fly on Solaris so + // remove the existing events, and then add the new ones. + struct pollfd pfd[2]; + + pfd[0].fd = handle; + pfd[0].events = POLLREMOVE; + pfd[0].revents = 0; + pfd[1].fd = (events == POLLREMOVE ? ACE_INVALID_HANDLE : handle); + pfd[1].events = events; + pfd[1].revents = 0; + + // Change the events associated with the given file descriptor. + if (ACE_OS::write (this->poll_fd_, + pfd, + sizeof (pfd)) != sizeof (pfd)) + return -1; +#elif defined (ACE_HAS_EVENT_POLL) + + struct epoll_event epev; + ACE_OS::memset (&epev, 0, sizeof (epev)); + int op; + + // ACE_Event_Handler::NULL_MASK ??? + if (new_mask == 0) + { + op = EPOLL_CTL_DEL; + epev.events = 0; + } + else + { + op = EPOLL_CTL_MOD; + epev.events = events; + } + + epev.data.fd = handle; + + if (::epoll_ctl (this->poll_fd_, op, handle, &epev) == -1) + { + // If a handle is closed, epoll removes it from the poll set + // automatically - we may not know about it yet. If that's the + // case, a mod operation will fail with ENOENT. Retry it as + // an add. + if (op == EPOLL_CTL_MOD && errno == ENOENT && + ::epoll_ctl (this->poll_fd_, EPOLL_CTL_ADD, handle, &epev) == -1) + return -1; + } + +#else + pollfd pfd[1]; + + pfd[0].fd = handle; + pfd[0].events = events; + pfd[0].revents = 0; + + // Change the events associated with the given file descriptor. + if (ACE_OS::write (this->poll_fd_, + pfd, + sizeof (pfd)) != sizeof (pfd)) + return -1; +#endif /*ACE_HAS_EVENT_POLL */ + } + + return old_mask; +} + +int +ACE_Dev_Poll_Reactor::ready_ops (ACE_Event_Handler * /* event_handler */, + ACE_Reactor_Mask /* mask */, + int /* ops */) +{ + ACE_TRACE ("ACE_Dev_Poll_Reactor::ready_ops"); + + // Since the Dev_Poll_Reactor uses the poll result buffer, the + // ready_set cannot be directly manipulated outside of the event + // loop. + ACE_NOTSUP_RETURN (-1); +} + +int +ACE_Dev_Poll_Reactor::ready_ops (ACE_HANDLE /* handle */, + ACE_Reactor_Mask /* mask */, + int /* ops */) +{ + ACE_TRACE ("ACE_Dev_Poll_Reactor::ready_ops"); + + // Since the Dev_Poll_Reactor uses the poll result buffer, the + // ready_set cannot be directly manipulated outside of the event + // loop. + ACE_NOTSUP_RETURN (-1); +} + +void +ACE_Dev_Poll_Reactor::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + ACE_TRACE ("ACE_Dev_Poll_Reactor::dump"); + + ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("restart_ = %d\n"), this->restart_)); + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("initialized_ = %d"), + this->initialized_)); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("poll_fd_ = %d"), this->poll_fd_)); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("size_ = %u"), this->size_)); + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("deactivated_ = %d"), + this->deactivated_)); + ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); +#endif /* ACE_HAS_DUMP */ +} + +short +ACE_Dev_Poll_Reactor::reactor_mask_to_poll_event (ACE_Reactor_Mask mask) +{ + ACE_TRACE ("ACE_Dev_Poll_Reactor::reactor_mask_to_poll_event"); + + if (mask == ACE_Event_Handler::NULL_MASK) + // No event. Remove from interest set. +#if defined (ACE_HAS_EVENT_POLL) + return EPOLL_CTL_DEL; +#else + return POLLREMOVE; +#endif /* ACE_HAS_EVENT_POLL */ + + short events = 0; + + // READ, ACCEPT, and CONNECT flag will place the handle in the + // read set. + if (ACE_BIT_ENABLED (mask, ACE_Event_Handler::READ_MASK) + || ACE_BIT_ENABLED (mask, ACE_Event_Handler::ACCEPT_MASK) + || ACE_BIT_ENABLED (mask, ACE_Event_Handler::CONNECT_MASK)) + { +#if defined (ACE_HAS_EVENT_POLL) + ACE_SET_BITS (events, EPOLLIN); +#else + ACE_SET_BITS (events, POLLIN); +#endif /*ACE_HAS_EVENT_POLL*/ + } + + // WRITE and CONNECT flag will place the handle in the write set. + if (ACE_BIT_ENABLED (mask, ACE_Event_Handler::WRITE_MASK) + || ACE_BIT_ENABLED (mask, ACE_Event_Handler::CONNECT_MASK)) + { +#if defined (ACE_HAS_EVENT_POLL) + ACE_SET_BITS (events, EPOLLOUT); +#else + ACE_SET_BITS (events, POLLOUT); +#endif /*ACE_HAS_EVENT_POLL*/ + } + + // EXCEPT flag will place the handle in the except set. + if (ACE_BIT_ENABLED (mask, ACE_Event_Handler::EXCEPT_MASK)) + { +#if defined (ACE_HAS_EVENT_POLL) + ACE_SET_BITS (events, EPOLLPRI); +#else + ACE_SET_BITS (events, POLLPRI); +#endif /*ACE_HAS_EVENT_POLL*/ + } + + return events; +} + +namespace { + void polite_sleep_hook (void *) { } +} + +int +ACE_Dev_Poll_Reactor::Token_Guard::acquire_quietly (ACE_Time_Value *max_wait) +{ + ACE_TRACE ("ACE_Dev_Poll_Reactor::Token_Guard::acquire_quietly"); + + // Acquire the token but don't ping any waiters; just queue up politely. + int result = 0; + if (max_wait) + { + ACE_Time_Value tv = ACE_OS::gettimeofday (); + tv += *max_wait; + + ACE_MT (result = this->token_.acquire_read (&polite_sleep_hook, + 0, + &tv)); + } + else + { + ACE_MT (result = this->token_.acquire_read (&polite_sleep_hook)); + } + + // Check for timeouts and errors. + if (result == -1) + { + if (errno == ETIME) + return 0; + else + { + ACE_ERROR ((LM_ERROR, "%t: %p\n", "token acquire_read")); + return -1; + } + } + + // We got the token and so let us mark ourselves as owner + this->owner_ = 1; + + return result; +} + +int +ACE_Dev_Poll_Reactor::Token_Guard::acquire (ACE_Time_Value *max_wait) +{ + ACE_TRACE ("ACE_Dev_Poll_Reactor::Token_Guard::acquire"); + + // Try to grab the token. If someone if already there, don't wake + // them up, just queue up in the thread pool. + int result = 0; + if (max_wait) + { + ACE_Time_Value tv = ACE_OS::gettimeofday (); + tv += *max_wait; + + ACE_MT (result = this->token_.acquire (0, 0, &tv)); + } + else + { + ACE_MT (result = this->token_.acquire ()); + } + + // Check for timeouts and errors. + if (result == -1) + { + if (errno == ETIME) + return 0; + else + return -1; + } + + // We got the token and so let us mark ourseleves as owner + this->owner_ = 1; + + return result; +} + +ACE_END_VERSIONED_NAMESPACE_DECL + +#endif /* ACE_HAS_EVENT_POLL || ACE_HAS_DEV_POLL */ diff --git a/dep/ACE_wrappers/ace/Dev_Poll_Reactor.h b/dep/ACE_wrappers/ace/Dev_Poll_Reactor.h new file mode 100644 index 00000000000..38d9c013a8b --- /dev/null +++ b/dep/ACE_wrappers/ace/Dev_Poll_Reactor.h @@ -0,0 +1,1252 @@ +// -*- C++ -*- + +// ========================================================================= +/** + * @file Dev_Poll_Reactor.h + * + * $Id: Dev_Poll_Reactor.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @c /dev/poll (or Linux @c sys_epoll) based Reactor implementation. + * + * @author Ossama Othman + */ +// ========================================================================= + + +#ifndef ACE_DEV_POLL_REACTOR_H +#define ACE_DEV_POLL_REACTOR_H + +#include /**/ "ace/pre.h" + +#include /**/ "ace/ACE_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#if defined (ACE_HAS_EVENT_POLL) && defined (ACE_HAS_DEV_POLL) +# error ACE_HAS_EVENT_POLL and ACE_HAS_DEV_POLL are mutually exclusive. +#endif /* ACE_HAS_EVENT_POLL && defined ACE_HAS_DEV_POLL */ + +#if defined (ACE_HAS_EVENT_POLL) || defined (ACE_HAS_DEV_POLL) + +#include "ace/Pipe.h" +#include "ace/Lock_Adapter_T.h" +#include "ace/Reactor_Impl.h" +#include "ace/Reactor_Token_T.h" +#include "ace/Token.h" + +#if defined (ACE_HAS_REACTOR_NOTIFICATION_QUEUE) +# include "ace/Notification_Queue.h" +#endif /* ACE_HAS_REACTOR_NOTIFICATION_QUEUE */ + +#if defined (ACE_HAS_DEV_POLL) +struct pollfd; +#elif defined (ACE_HAS_EVENT_POLL) +struct epoll_event; +#endif + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +// Forward declarations +class ACE_Sig_Handler; +class ACE_Dev_Poll_Reactor; + +/** + * @class ACE_Dev_Poll_Event_Tuple + * + * @brief Class that associates specific event mask with a given event + * handler. + * + * This class merely provides a means to associate an event mask + * with an event handler. Such an association is needed since it is + * not possible to retrieve the event mask from the "interest set" + * stored in the `/dev/poll' or `/dev/epoll' driver. Without this + * external association, it would not be possible keep track of the + * event mask for a given event handler when suspending it or resuming + * it. + * + * @note An ACE_Handle_Set is not used since the number of handles may + * exceed its capacity (ACE_DEFAULT_SELECT_REACTOR_SIZE). + */ +class ACE_Dev_Poll_Event_Tuple +{ +public: + + /// Constructor. + ACE_Dev_Poll_Event_Tuple (void); + +public: + + /// The event handler. + ACE_Event_Handler *event_handler; + + /// The event mask for the above event handler. + ACE_Reactor_Mask mask; + + /// Flag that states whether or not the event handler is suspended. + char suspended; +}; + +// --------------------------------------------------------------------- + +#if 0 +/** + * @class ACE_Dev_Poll_Ready_Set + * + * @brief Class that contains the list of "ready" file descriptors. + * + * This class points to an array of pollfd structures corresponding to + * "ready" file descriptors, such as those corresponding to event + * handlers that request an additional callback after being initially + * dispatched (i.e. return a value greater than zero). + * @par + * The idea is to store the "ready" set in an existing area of memory + * that already contains pollfd instances. Doing so is safe since the + * "ready" set is dispatched before polling for additional events, + * thus avoiding being potentially overwritten during the event poll. + * @par + * When the "ready" set is dispatched, all that needs to be done is to + * iterate over the contents of the array. There is no need to "walk" + * the array in search of ready file descriptors since the array by + * design only contains ready file descriptors. As such, this + * implementation of a ready set is much more efficient in the + * presence of a large number of file descriptors in terms of both + * time and space than the one used in the Select_Reactor, for + * example. + */ +class ACE_Dev_Poll_Ready_Set +{ +public: + + /// Constructor. + ACE_Dev_Poll_Ready_Set (void); + +public: + + /// The array containing the pollfd structures corresponding to the + /// "ready" file descriptors. + struct pollfd *pfds; + + /// The number of "ready" file descriptors in the above array. + int nfds; + +}; +#endif /* 0 */ + +// --------------------------------------------------------------------- + +/** + * @class ACE_Dev_Poll_Reactor_Notify + * + * @brief Event handler used for unblocking the ACE_Dev_Poll_Reactor + * from its event loop. + * + * This event handler is used internally by the ACE_Dev_Poll_Reactor + * as a means to allow a thread other then the one running the event + * loop to unblock the event loop. + */ +class ACE_Dev_Poll_Reactor_Notify : public ACE_Reactor_Notify +{ +public: + + /// Constructor + ACE_Dev_Poll_Reactor_Notify (void); + + /** + * @name Initialization and Termination Methods + * + * Methods called when initializing and terminating this event + * handler. + */ + virtual int open (ACE_Reactor_Impl *, + ACE_Timer_Queue *timer_queue = 0, + int disable_notify = 0); + virtual int close (void); + + /** + * Called by a thread when it wants to unblock the Reactor_Impl. + * This wakes up the Reactor_Impl if currently blocked. Pass over + * both the Event_Handler and the mask to allow the caller to + * dictate which Event_Handler method the Reactor_Impl will + * invoke. The ACE_Time_Value indicates how long to block + * trying to notify the Reactor_Impl. If timeout == 0, the + * caller will block until action is possible, else will wait until + * the relative time specified in *timeout elapses). + */ + virtual int notify (ACE_Event_Handler *eh = 0, + ACE_Reactor_Mask mask = ACE_Event_Handler::EXCEPT_MASK, + ACE_Time_Value *timeout = 0); + + /// Unimplemented method required by pure virtual method in abstract + /// base class. + /** + * This method's interface is not very compatibile with this + * Reactor's design. It's not clear why this method is pure virtual + * either. + */ + virtual int dispatch_notifications (int &number_of_active_handles, + ACE_Handle_Set &rd_mask); + + /// Returns the ACE_HANDLE of the notify pipe on which the reactor + /// is listening for notifications so that other threads can unblock + /// the Reactor_Impl. + virtual ACE_HANDLE notify_handle (void); + + /// Verify whether the buffer has dispatchable info or not. + virtual int is_dispatchable (ACE_Notification_Buffer &buffer); + + /// Handle one notify call represented in @a buffer. This could be + /// because of a thread trying to unblock the Reactor_Impl. + virtual int dispatch_notify (ACE_Notification_Buffer &buffer); + + /// Read one notify call on the handle into @a buffer. + /// This could be because of a thread trying to unblock the Reactor_Impl. + virtual int read_notify_pipe (ACE_HANDLE handle, + ACE_Notification_Buffer &buffer); + + /// Called back by the ACE_Dev_Poll_Reactor when a thread wants to + /// unblock us. + virtual int handle_input (ACE_HANDLE handle); + + /** + * Set the maximum number of times that the handle_input method + * will iterate and dispatch the ACE_Event_Handlers that are + * passed in via the notify queue before breaking out of the event + * loop. By default, this is set to -1, which means "iterate until + * the queue is empty." Setting this to a value like "1 or 2" will + * increase "fairness" (and thus prevent starvation) at the expense + * of slightly higher dispatching overhead. + */ + virtual void max_notify_iterations (int); + + /** + * Get the maximum number of times that the handle_input method + * will iterate and dispatch the ACE_Event_Handlers that are + * passed in via the notify queue before breaking out of its event + * loop. + */ + virtual int max_notify_iterations (void); + + /** + * Purge any notifications pending in this reactor for the specified + * ACE_Event_Handler object. Returns the number of notifications + * purged. Returns -1 on error. + */ + virtual int purge_pending_notifications ( + ACE_Event_Handler * = 0, + ACE_Reactor_Mask = ACE_Event_Handler::ALL_EVENTS_MASK); + + /// Dump the state of an object. + virtual void dump (void) const; + +protected: + + /** + * Keep a back pointer to the ACE_Dev_Poll_Reactor. If this value + * if NULL then the ACE_Dev_Poll_Reactor has been initialized with + * disable_notify_pipe. + */ + ACE_Dev_Poll_Reactor *dp_reactor_; + + /** + * Contains the ACE_HANDLE the ACE_Dev_Poll_Reactor is listening + * on, as well as the ACE_HANDLE that threads wanting the attention + * of the ACE_Dev_Poll_Reactor will write to. + */ + ACE_Pipe notification_pipe_; + + /** + * Keeps track of the maximum number of times that the + * ACE_Dev_Poll_Reactor_Notify::handle_input method will iterate and + * dispatch the ACE_Event_Handlers that are passed in via the + * notify pipe before breaking out of its recv loop. By default, + * this is set to -1, which means "iterate until the pipe is empty." + */ + int max_notify_iterations_; + +#if defined (ACE_HAS_REACTOR_NOTIFICATION_QUEUE) + /** + * @brief A user-space queue to store the notifications. + * + * The notification pipe has OS-specific size restrictions. That + * is, no more than a certain number of bytes may be stored in the + * pipe without blocking. This limit may be too small for certain + * applications. In this case, ACE can be configured to store all + * the events in user-space. The pipe is still needed to wake up + * the reactor thread, but only one event is sent through the pipe + * at a time. + */ + ACE_Notification_Queue notification_queue_; +#endif /* ACE_HAS_REACTOR_NOTIFICATION_QUEUE */ + +}; + +// --------------------------------------------------------------------- + +/** + * @class ACE_Dev_Poll_Reactor_Handler_Repository + * + * @internal + + * @brief Used to map ACE_HANDLEs onto the appropriate + * ACE_Event_Handler *. + * + * + * This class is simply a container that maps a handle to its + * corresponding event handler. It is not meant for use outside of + * the Dev_Poll_Reactor. + */ +class ACE_Dev_Poll_Reactor_Handler_Repository +{ +public: + + /// Constructor. + ACE_Dev_Poll_Reactor_Handler_Repository (void); + + /// Initialize a repository of the appropriate @a size. + int open (size_t size); + + /// Close down the repository. + int close (void); + + /** + * @name Repository Manipulation Operations + * + * Methods used to search and modify the handler repository. + */ + //@{ + + /** + * Return the @c ACE_Event_Handler associated with @c ACE_HANDLE. If + * @a index_p is non-zero, then return the index location of the + * handle, if found. + */ + ACE_Event_Handler *find (ACE_HANDLE handle, size_t *index_p = 0); + + /// Set the event mask for event handler associated with the given + /// handle. + void mask (ACE_HANDLE handle, ACE_Reactor_Mask mask); + + /// Retrieve the event mask for the event handler associated with + /// the given handle. + ACE_Reactor_Mask mask (ACE_HANDLE handle); + + /// Mark the event handler associated with the given handle as + /// "suspended." + void suspend (ACE_HANDLE handle); + + /// Mark the event handler associated with the given handle as + /// "resumed." + void resume (ACE_HANDLE handle); + + /// Is the event handler for the given handle suspended? + int suspended (ACE_HANDLE handle) const; + + /// Bind the ACE_Event_Handler to the @c ACE_HANDLE with the + /// appropriate ACE_Reactor_Mask settings. + int bind (ACE_HANDLE handle, + ACE_Event_Handler *handler, + ACE_Reactor_Mask mask); + + /// Remove the binding for @c ACE_HANDLE; optionally decrement the associated + /// handler's reference count. + int unbind (ACE_HANDLE handle, bool decr_refcnt = true); + + /// Remove all the (@c ACE_HANDLE, @c ACE_Event_Handler) tuples. + int unbind_all (void); + + /** + * @name Sanity Checking + * + * Methods used to prevent "out-of-range" errors when indexing the + * underlying handler array. + */ + //@{ + + // Check the @a handle to make sure it's a valid @c ACE_HANDLE that + // within the range of legal handles (i.e., greater than or equal to + // zero and less than @c max_size_). + int invalid_handle (ACE_HANDLE handle) const; + + // Check the handle to make sure it's a valid @c ACE_HANDLE that is + // within the range of currently registered handles (i.e., greater + // than or equal to zero and less than @c max_handlep1_). + int handle_in_range (ACE_HANDLE handle) const; + + //@} + + /// Returns the current table size. + size_t size (void) const; + + /// Dump the state of an object. + void dump (void) const; + + /// Declare the dynamic allocation hooks. + ACE_ALLOC_HOOK_DECLARE; + +private: + + /// Maximum number of handles. + int max_size_; + + /// The underlying array of event handlers. + /** + * The array of event handlers is directly indexed directly using + * an @c ACE_HANDLE value. This is Unix-specific. + */ + ACE_Dev_Poll_Event_Tuple *handlers_; + +}; + +// --------------------------------------------------------------------- + +/** + * @class ACE_Dev_Poll_Reactor + * + * @brief A `/dev/poll' or `/dev/epoll' based Reactor implemenatation. + * + * @attention The Linux epoll implementation works quite well and is + * fully supported; however, the /dev/poll implementation is @em experimental. + * + * The ACE_Dev_Poll_Reactor uses the `/dev/poll' or '/dev/epoll' + * character devices to demultiplex events on a given set of file + * descriptors. Unlike @c select(), `/dev/poll' and `/dev/epoll' have + * no hard-coded limit on the number of file descriptors that may be + * handled at any given time. As such, the ACE_Dev_Poll_Reactor can + * generally handle a much larger number of file descriptors than + * @c select() -based reactors. Furthermore, since `/dev/poll' and + * `/dev/epoll' both return a set of file descriptors that are active, + * there is no need to "walk" the set of file descriptors to determine + * which ones are active, such as what is done with the @c select() and + * @c poll() system calls. All returned file descriptors are active. + * This makes event dispatching very efficient. + * + * @note In general, this reactor may only be used to demultiplex + * events on sockets. Demultiplexing events on pipes, for + * example may not work. This is due to a limitation in the + * underlying `/dev/poll' device driver. + * + * @note It is only possible to achieve millisecond timeout + * resolutions with the @c ACE_Dev_Poll_Reactor. However, the + * timeout resolution for timers is independent of the reactors + * timeout resolution. As such, it may be possible to achieve + * sub-millisecond timeout resolutions for timers but that is + * entirely platform dependent. + */ + +#if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0) +typedef ACE_Token ACE_DEV_POLL_TOKEN; +#else +typedef ACE_Noop_Token ACE_DEV_POLL_TOKEN; +#endif /* ACE_MT_SAFE && ACE_MT_SAFE != 0 */ +typedef ACE_Reactor_Token_T ACE_Dev_Poll_Reactor_Token; + +class ACE_Export ACE_Dev_Poll_Reactor : public ACE_Reactor_Impl +{ +public: + + /// Initialize @c ACE_Dev_Poll_Reactor with the default size. + /** + * The default size for the @c ACE_Dev_Poll_Reactor is the maximum + * number of open file descriptors for the process. + */ + ACE_Dev_Poll_Reactor (ACE_Sig_Handler * = 0, + ACE_Timer_Queue * = 0, + int disable_notify_pipe = 0, + ACE_Reactor_Notify *notify = 0, + int mask_signals = 1, + int s_queue = ACE_DEV_POLL_TOKEN::FIFO); + + /// Initialize ACE_Dev_Poll_Reactor with size @a size. + /** + * @note On Unix platforms, the @a size parameter should be as large + * as the maximum number of file descriptors allowed for a + * given process. This is necessary since a file descriptor + * is used to directly index the array of event handlers + * maintained by the Reactor's handler repository. Direct + * indexing is used for efficiency reasons. If the size + * parameter is less than the process maximum, the process + * maximum will be decreased in order to prevent potential + * access violations. + */ + ACE_Dev_Poll_Reactor (size_t size, + int restart = 0, + ACE_Sig_Handler * = 0, + ACE_Timer_Queue * = 0, + int disable_notify_pipe = 0, + ACE_Reactor_Notify *notify = 0, + int mask_signals = 1, + int s_queue = ACE_DEV_POLL_TOKEN::FIFO); + + /// Close down and release all resources. + virtual ~ACE_Dev_Poll_Reactor (void); + + /// Initialization. + virtual int open (size_t size, + int restart = 0, + ACE_Sig_Handler * = 0, + ACE_Timer_Queue * = 0, + int disable_notify_pipe = 0, + ACE_Reactor_Notify * = 0); + + /** + * @param handle allows the reactor to check if the caller is + * valid. + * + * @return 0 if the size of the current message has been put in + * size. -1 if not. + */ + virtual int current_info (ACE_HANDLE handle, size_t & /* size */); + + /// Use a user specified signal handler instead. + virtual int set_sig_handler (ACE_Sig_Handler *signal_handler); + + /// Set a user-specified timer queue. + virtual int timer_queue (ACE_Timer_Queue *tq); + + /// Get the timer queue + /// @return The current @c ACE_Timer_Queue. + virtual ACE_Timer_Queue *timer_queue (void) const; + + /// Close down and release all resources. + virtual int close (void); + + // = Event loop drivers. + /** + * Returns non-zero if there are I/O events "ready" for dispatching, + * but does not actually dispatch the event handlers. By default, + * don't block while checking this, i.e., "poll". + * + * @note It is only possible to achieve millisecond timeout + * resolutions with the @c ACE_Dev_Poll_Reactor. + */ + virtual int work_pending ( + const ACE_Time_Value &max_wait_time = ACE_Time_Value::zero); + + /** + * This event loop driver blocks for up to @a max_wait_time before + * returning. It will return earlier if events occur. Note that + * @a max_wait_time can be 0, in which case this method blocks + * indefinitely until events occur. + * @par + * @a max_wait_time is decremented to reflect how much time this + * call took. For instance, if a time value of 3 seconds is passed + * to @c handle_events() and an event occurs after 2 seconds, + * @a max_wait_time will equal 1 second. This can be used if an + * application wishes to handle events for some fixed amount of + * time. + * @par + * The only difference between @c alertable_handle_events() and + * handle_events() is that in the alertable case, the event loop + * will return when the system queues an I/O completion routine or + * an Asynchronous Procedure Call. + * + * @return The total number of @c ACE_Event_Handlers that were + * dispatched, 0 if the @a max_wait_time elapsed without + * dispatching any handlers, or -1 if an error occurs. + + * @note It is only possible to achieve millisecond timeout + * resolutions with the @c ACE_Dev_Poll_Reactor. + */ + virtual int handle_events (ACE_Time_Value *max_wait_time = 0); + virtual int alertable_handle_events (ACE_Time_Value *max_wait_time = 0); + + /** + * This method is just like the one above, except the + * @a max_wait_time value is a reference and can therefore never be + * @c NULL. + * + * @note It is only possible to achieve millisecond timeout + * resolutions with the @c ACE_Dev_Poll_Reactor. + */ + virtual int handle_events (ACE_Time_Value &max_wait_time); + virtual int alertable_handle_events (ACE_Time_Value &max_wait_time); + + // = Event handling control. + + /** + * @return The status of Reactor. If this function returns 0, the + * reactor is actively handling events. If it returns + * non-zero, @c handle_events() and + * @c handle_alertable_events() return -1 immediately. + */ + virtual int deactivated (void); + + /** + * Control whether the Reactor will handle any more incoming events + * or not. If @a do_stop == 1, the Reactor will be disabled. By + * default, a reactor is in active state and can be + * deactivated/reactived as desired. + */ + virtual void deactivate (int do_stop); + + // = Register and remove Handlers. + + /// Register @a event_handler with @a mask. The I/O handle will + /// always come from get_handle on the event_handler. + virtual int register_handler (ACE_Event_Handler *event_handler, + ACE_Reactor_Mask mask); + + /// Register @a event_handler with @a mask. The I/O handle is + /// provided through the @a io_handle parameter. + virtual int register_handler (ACE_HANDLE io_handle, + ACE_Event_Handler *event_handler, + ACE_Reactor_Mask mask); + + /** + * Register an @a event_handler that will be notified when + * @a event_handle is signaled. @a mask specifies the network + * events that the @a event_handler is interested in. + */ + virtual int register_handler (ACE_HANDLE event_handle, + ACE_HANDLE io_handle, + ACE_Event_Handler *event_handler, + ACE_Reactor_Mask mask); + + /// Register @a event_handler> with all the @a handles> in the @c + /// Handle_Set. + virtual int register_handler (const ACE_Handle_Set &handles, + ACE_Event_Handler *event_handler, + ACE_Reactor_Mask mask); + + /** + * Register @a new_sh to handle the signal @a signum using the + * @a new_disp. Returns the @a old_sh that was previously + * registered (if any), along with the @a old_disp of the signal + * handler. + */ + virtual int register_handler (int signum, + ACE_Event_Handler *new_sh, + ACE_Sig_Action *new_disp = 0, + ACE_Event_Handler **old_sh = 0, + ACE_Sig_Action *old_disp = 0); + + /// Registers to handle a set of signals using the + /// . + virtual int register_handler (const ACE_Sig_Set &sigset, + ACE_Event_Handler *new_sh, + ACE_Sig_Action *new_disp = 0); + + /// Removes @a event_handler. + /** + * @note The I/O handle will be obtained using @c get_handle() + * method of @a event_handler . If @a mask == + * @c ACE_Event_Handler::DONT_CALL then the @c handle_close() + * method of the @a event_handler is not invoked. + */ + virtual int remove_handler (ACE_Event_Handler *event_handler, + ACE_Reactor_Mask mask); + + /** + * Removes @a handle. If @a mask == ACE_Event_Handler::DONT_CALL + * then the method of the associated + * is not invoked. + */ + virtual int remove_handler (ACE_HANDLE handle, + ACE_Reactor_Mask mask); + + /** + * Removes all handles in . If @a mask == + * ACE_Event_Handler::DONT_CALL then the method of + * the associated s is not invoked. + */ + virtual int remove_handler (const ACE_Handle_Set &handle_set, + ACE_Reactor_Mask mask); + + /** + * Remove the ACE_Event_Handler currently associated with @a signum. + * Install the new disposition (if given) and return the previous + * disposition (if desired by the caller). Returns 0 on success and + * -1 if @a signum is invalid. + */ + virtual int remove_handler (int signum, + ACE_Sig_Action *new_disp, + ACE_Sig_Action *old_disp = 0, + int sigkey = -1); + + /// Calls for every signal in . + virtual int remove_handler (const ACE_Sig_Set &sigset); + + // = Suspend and resume Handlers. + + /// Suspend event_handler temporarily. Use + /// ACE_Event_Handler::get_handle() to get the handle. + virtual int suspend_handler (ACE_Event_Handler *event_handler); + + /// Suspend handle temporarily. + virtual int suspend_handler (ACE_HANDLE handle); + + /// Suspend all handles in handle set temporarily. + virtual int suspend_handler (const ACE_Handle_Set &handles); + + /// Suspend all handles temporarily. + virtual int suspend_handlers (void); + + /// Resume event_handler. Use ACE_Event_Handler::get_handle() to + /// get the handle. + virtual int resume_handler (ACE_Event_Handler *event_handler); + + /// Resume handle. + virtual int resume_handler (ACE_HANDLE handle); + + /// Resume all handles in handle set. + virtual int resume_handler (const ACE_Handle_Set &handles); + + /// Resume all handles. + virtual int resume_handlers (void); + + /// Does the reactor allow the application to resume the handle on + /// its own, i.e., can it pass on the control of handle resumption to + /// the application. + virtual int resumable_handler (void); + + /// Return 1 if we any event associations were made by the reactor + /// for the handles that it waits on, 0 otherwise. + virtual int uses_event_associations (void); + + // = Timer management. + + /** + * Schedule an ACE_Event_Handler that will expire after an amount + * of time. The return value of this method, a timer_id value, + * uniquely identifies the event_handler in the ACE_Reactor's + * internal list of timers. + * This timer_id value can be used to cancel the timer + * with the cancel_timer() call. + * + * @see cancel_timer() + * @see reset_timer_interval() + * + * @param event_handler event handler to schedule on reactor + * @param arg argument passed to the handle_timeout() method of + * event_handler. + * @param delay time interval after which the timer will expire. + * @param interval time interval for which the timer will be + * automatically rescheduled. + * @return -1 on failure, a timer_id value on success + */ + virtual long schedule_timer (ACE_Event_Handler *event_handler, + const void *arg, + const ACE_Time_Value &delay, + const ACE_Time_Value &interval = ACE_Time_Value::zero); + + /** + * Resets the interval of the timer represented by @a timer_id to + * @a interval, which is specified in relative time to the current + * . If @a interval is equal to + * ACE_Time_Value::zero, the timer will become a non-rescheduling + * timer. Returns 0 if successful, -1 if not. + */ + virtual int reset_timer_interval (long timer_id, + const ACE_Time_Value &interval); + + /// Cancel all Event_Handlers that match the address of + /// @a event_handler. Returns number of handlers cancelled. + virtual int cancel_timer (ACE_Event_Handler *event_handler, + int dont_call_handle_close = 1); + + /** + * Cancel the single event handler that matches the @a timer_id value + * (which was returned from the schedule method). If @a arg is + * non-NULL then it will be set to point to the ``magic cookie'' + * argument passed in when the event handler was registered. This + * makes it possible to free up the memory and avoid memory leaks. + * Returns 1 if cancellation succeeded and 0 if the @a timer_id + * wasn't found. + */ + virtual int cancel_timer (long timer_id, + const void **arg = 0, + int dont_call_handle_close = 1); + + // = High-level event handler scheduling operations + + /// Add @a masks_to_be_added to the @a event_handler's entry. + /// @a event_handler must already have been registered. + virtual int schedule_wakeup (ACE_Event_Handler *event_handler, + ACE_Reactor_Mask masks_to_be_added); + + /// Add @a masks_to_be_added to the @a handle's entry. + /// associated with @a handle must already have been registered. + virtual int schedule_wakeup (ACE_HANDLE handle, + ACE_Reactor_Mask masks_to_be_added); + + /// Clear @a masks_to_be_cleared from the @a event_handler's entry. + virtual int cancel_wakeup (ACE_Event_Handler *event_handler, + ACE_Reactor_Mask masks_to_be_cleared); + + /// Clear @a masks_to_be_cleared from the @a handle's entry. + virtual int cancel_wakeup (ACE_HANDLE handle, + ACE_Reactor_Mask masks_to_be_cleared); + + // = Notification methods. + + /** + * Notify @a event_handler of @a mask event. The ACE_Time_Value + * indicates how long to blocking trying to notify. If @a timeout == + * 0, the caller will block until action is possible, else will wait + * until the relative time specified in @a timeout elapses). + */ + virtual int notify (ACE_Event_Handler *event_handler = 0, + ACE_Reactor_Mask mask = ACE_Event_Handler::EXCEPT_MASK, + ACE_Time_Value * = 0); + + /** + * Set the maximum number of times that ACE_Reactor_Impl will + * iterate and dispatch the that are passed in + * via the notify queue before breaking out of its + * loop. By default, this is set to + * -1, which means "iterate until the queue is empty." Setting this + * to a value like "1 or 2" will increase "fairness" (and thus + * prevent starvation) at the expense of slightly higher dispatching + * overhead. + */ + virtual void max_notify_iterations (int); + + /** + * Get the maximum number of times that the ACE_Reactor_Impl will + * iterate and dispatch the that are passed in + * via the notify queue before breaking out of its + * loop. + */ + virtual int max_notify_iterations (void); + + /** + * Purge any notifications pending in this reactor for the specified + * ACE_Event_Handler object. Returns the number of notifications + * purged. Returns -1 on error. + */ + virtual int purge_pending_notifications (ACE_Event_Handler * = 0, + ACE_Reactor_Mask = ACE_Event_Handler::ALL_EVENTS_MASK); + + /** + * Return the Event_Handler associated with @a handle. Return 0 if + * @a handle is not registered. + */ + virtual ACE_Event_Handler *find_handler (ACE_HANDLE handle); + + /** + * Check to see if @a handle is associated with a valid Event_Handler + * bound to @a mask. Return the @a event_handler associated with this + * @c handler if @a event_handler != 0. + */ + virtual int handler (ACE_HANDLE handle, + ACE_Reactor_Mask mask, + ACE_Event_Handler **event_handler = 0); + + /** + * Check to see if @a signum is associated with a valid Event_Handler + * bound to a signal. Return the @a event_handler associated with + * this @c handler if @a event_handler != 0. + */ + virtual int handler (int signum, + ACE_Event_Handler ** = 0); + + /// Returns true if Reactor has been successfully initialized, else + /// false. + virtual bool initialized (void); + + /// Returns the current size of the Reactor's internal descriptor + /// table. + virtual size_t size (void) const; + + /// Returns a reference to the Reactor's internal lock. + virtual ACE_Lock &lock (void); + + /// Wake up all threads waiting in the event loop. + virtual void wakeup_all_threads (void); + + /// Transfers ownership of Reactor_Impl to the new_owner. + /** + * @note There is no need to set the owner of the event loop for the + * ACE_Dev_Poll_Reactor. Multiple threads may invoke the + * event loop simulataneously. As such, this method is a + * no-op. + */ + virtual int owner (ACE_thread_t new_owner, ACE_thread_t *old_owner = 0); + + /// Return the ID of the "owner" thread. + /** + * @note There is no need to set the owner of the event loop for the + * ACE_Dev_Poll_Reactor. Multiple threads may invoke the + * event loop simulataneously. As such, this method is a + * no-op. + */ + virtual int owner (ACE_thread_t *owner); + + /// Get the existing restart value. + virtual int restart (void); + + /// Set a new value for restart and return the original value. + /** + * @param r If zero, then the event loop will not be automatically + * restarted if the underlying poll is interrupted via the + * INTR (interrupt) signal. + * + * @return Returns the previous "restart" value. + */ + virtual int restart (int r); + + /// Set position of the owner thread. + /** + * @note This is currently a no-op. + */ + virtual void requeue_position (int); + + /// Get position of the owner thread. + /** + * @note This is currently a no-op. + */ + virtual int requeue_position (void); + + /** + * @name Low-level wait_set mask manipulation methods + * + * Low-level methods to manipulate the event/reactor mask associated + * with a handle and event handler when polling for events. + * @par + * The "interest set," i.e. the wait set, can be directly + * manipulated with these methods. + */ + //@{ + + /// GET/SET/ADD/CLR the dispatch mask "bit" bound with the + /// event_handler and mask. + /** + * @return Old mask on success, -1 on error. + */ + virtual int mask_ops (ACE_Event_Handler *event_handler, + ACE_Reactor_Mask mask, + int ops); + + /// GET/SET/ADD/CLR the dispatch MASK "bit" bound with the handle + /// and mask. + /** + * @return Old mask on success, -1 on error. + */ + virtual int mask_ops (ACE_HANDLE handle, + ACE_Reactor_Mask mask, + int ops); + + //@} + + /** + * @name Low-level ready_set mask manipulation methods + * + * These methods are unimplemented. + */ + //@{ + + /// GET/SET/ADD/CLR the ready "bit" bound with the event_handler + /// and mask. + virtual int ready_ops (ACE_Event_Handler *event_handler, + ACE_Reactor_Mask mask, + int ops); + + /// GET/SET/ADD/CLR the ready "bit" bound with the handle and mask. + virtual int ready_ops (ACE_HANDLE handle, + ACE_Reactor_Mask, + int ops); + + //@} + + /// Dump the state of an object. + virtual void dump (void) const; + + /// Declare the dynamic allocation hooks. + ACE_ALLOC_HOOK_DECLARE; + +protected: + + class Token_Guard; + + /// Non-locking version of wait_pending(). + /** + * Returns non-zero if there are I/O events "ready" for dispatching, + * but does not actually dispatch the event handlers. By default, + * don't block while checking this, i.e., "poll". + * + * @note It is only possible to achieve millisecond timeout + * resolutions with the ACE_Dev_Poll_Reactor. + */ + int work_pending_i (ACE_Time_Value *max_wait_time); + + /// Poll for events and return the number of event handlers that + /// were dispatched. + /** + * This is a helper method called by all handle_events() methods. + */ + int handle_events_i (ACE_Time_Value *max_wait_time, Token_Guard &guard); + + /// Perform the upcall with the given event handler method. + int upcall (ACE_Event_Handler *event_handler, + int (ACE_Event_Handler::*callback)(ACE_HANDLE), + ACE_HANDLE handle); + + /** + * Dispatch ACE_Event_Handlers for time events, I/O events, and + * signal events. Returns the total number of ACE_Event_Handlers + * that were dispatched or -1 if something goes wrong. + */ + int dispatch (Token_Guard &guard); + + /// Dispatch a single timer, if ready. + /// Returns: 0 if no timers ready (token still held), + /// 1 if a timer was expired (token released), + /// -1 on error (token still held). + int dispatch_timer_handler (Token_Guard &guard); + + /// Dispatch an IO event to the corresponding event handler. Returns + /// Returns: 0 if no events ready (token still held), + /// 1 if an event was expired (token released), + /// -1 on error (token still held). + int dispatch_io_event (Token_Guard &guard); + + /// Register the given event handler with the reactor. + int register_handler_i (ACE_HANDLE handle, + ACE_Event_Handler *eh, + ACE_Reactor_Mask mask); + + /// Remove the event handler associated with the given handle and + /// event mask from the "interest set." + int remove_handler_i (ACE_HANDLE handle, ACE_Reactor_Mask mask); + + /// Temporarily remove the given handle from the "interest set." + int suspend_handler_i (ACE_HANDLE handle); + + /// Place the given handle that was temporarily removed from the + /// "interest set," i.e that was suspended, back in to the interest + /// set. The given handle will once again be polled for events. + int resume_handler_i (ACE_HANDLE handle); + + /// GET/SET/ADD/CLR the dispatch MASK "bit" bound with the handle + /// and mask. This internal helper method acquires no lock. + /** + * @return Old mask on success, -1 on error. + */ + int mask_ops_i (ACE_HANDLE handle, + ACE_Reactor_Mask mask, + int ops); + + /// Convert a reactor mask to its corresponding poll() event mask. + short reactor_mask_to_poll_event (ACE_Reactor_Mask mask); + +protected: + + /// Has the reactor been initialized. + bool initialized_; + + /// The file descriptor associated with the open `/dev/poll' or + /// `/dev/epoll' device. + /** + * All interactions with the `/dev/poll' or `/dev/epoll' device are + * done through this file descriptor. + */ + ACE_HANDLE poll_fd_; + + /// The maximum number of file descriptors over which demultiplexing + /// will occur. + size_t size_; + + /// Track HANDLES we are interested in for various events that must + /// be dispatched *without* polling. + /// ACE_Dev_Poll_Ready_Set ready_set_; + +#if defined (ACE_HAS_EVENT_POLL) + /// Table of event structures to be filled by epoll_wait: + struct epoll_event *events_; + + /// Pointer to the next epoll_event array element that contains the next + /// event to be dispatched. + struct epoll_event *start_pevents_; + + /// The last element in the event array plus one. + /** + * The loop that dispatches IO events stops when this->start_pevents_ == + * this->end_pevents_. + */ + struct epoll_event *end_pevents_; + +#else + /// The pollfd array that `/dev/poll' will feed its results to. + struct pollfd *dp_fds_; + + + /// Pointer to the next pollfd array element that contains the next + /// event to be dispatched. + struct pollfd *start_pfds_; + + /// The last element in the pollfd array plus one. + /** + * The loop that dispatches IO events stops when this->start_pfds == + * this->end_pfds_. + */ + struct pollfd *end_pfds_; +#endif /* ACE_HAS_EVENT_POLL */ + + /// This flag is used to keep track of whether we are actively handling + /// events or not. + sig_atomic_t deactivated_; + + /// Lock used for synchronization of reactor state. + ACE_Dev_Poll_Reactor_Token token_; + + /// Adapter used to return internal lock to outside world. + ACE_Lock_Adapter lock_adapter_; + + /// The repository that contains all registered event handlers. + ACE_Dev_Poll_Reactor_Handler_Repository handler_rep_; + + /// Defined as a pointer to allow overriding by derived classes... + ACE_Timer_Queue *timer_queue_; + + /// Keeps track of whether we should delete the timer queue (if we + /// didn't create it, then we don't delete it). + bool delete_timer_queue_; + + /// Handle signals without requiring global/static variables. + ACE_Sig_Handler *signal_handler_; + + /// Keeps track of whether we should delete the signal handler (if we + /// didn't create it, then we don't delete it). + bool delete_signal_handler_; + + /// Callback object that unblocks the if it's + /// sleeping. + ACE_Reactor_Notify *notify_handler_; + + /// Keeps track of whether we need to delete the notify handler (if + /// we didn't create it, then we don't delete it). + bool delete_notify_handler_; + + /// Flag that determines if signals are masked during event + /// dispatching. + /** + * If 0 then the Reactor will not mask the signals during the event + * dispatching. This is useful for applications that do not + * register any signal handlers and want to reduce the overhead + * introduce by the kernel level locks required to change the mask. + */ + int mask_signals_; + + /// Restart the handle_events event loop method automatically when + /// polling function in use (ioctl() in this case) is interrupted + /// via an EINTR signal. + int restart_; + +protected: + + /** + * @class Token_Guard + * + * @brief A helper class that helps grabbing, releasing and waiting + * on tokens for a thread that needs access to the reactor's token. + */ + class ACE_Export Token_Guard + { + public: + + /// Constructor that will grab the token for us + Token_Guard (ACE_Dev_Poll_Reactor_Token &token); + + /// Destructor. This will release the token if it hasn't been + /// released till this point + ~Token_Guard (void); + + /// Release the token .. + void release_token (void); + + /// Returns whether the thread that created this object owns the + /// token or not. + int is_owner (void); + + /// A helper method that acquires the token 1) at a low priority, and + /// 2) wait quietly for the token, not waking another thread. This + /// is appropriate for cases where a thread wants to wait for and + /// dispatch an event, not causing an existing waiter to relinquish the + /// token, and also queueing up behind other threads waiting to modify + /// event records. + int acquire_quietly (ACE_Time_Value *max_wait = 0); + + /// A helper method that acquires the token at a high priority, and + /// does wake the current token holder. + int acquire (ACE_Time_Value *max_wait = 0); + + private: + + Token_Guard (void); + + private: + + /// The Reactor token. + ACE_Dev_Poll_Reactor_Token &token_; + + /// Flag that indicate whether the thread that created this object + /// owns the token or not. A value of 0 indicates that this class + /// hasn't got the token (and hence the thread) and a value of 1 + /// vice-versa. + int owner_; + + }; + +}; + + +/** + * @class ACE_Dev_Poll_Handler_Guard + * + * @brief Class used to make event handler reference count + * manipulation exception-safe. + * + * This class makes the reference count manipulation that occurs + * during an upcall exception-safe. Prior to dispatching the event + * handler, the reference count is increased. Once the upcall for the + * given event handler is complete, its reference count will be decreased. + */ +class ACE_Dev_Poll_Handler_Guard +{ +public: + + /// Constructor + /** + * The constructor checks to see if @a eh is a reference-counted handler and + * remember that for later. If @a eh is reference counted, its reference + * count is incremented unless @a do_incr is false. + * @a do_incr should be false if the reference count was incremented + * independently of this guard, for example, on a notify handler since + * the reference count is incremented when the notify is queued. + */ + ACE_Dev_Poll_Handler_Guard (ACE_Event_Handler *eh, bool do_incr = true); + + /// Destructor + /** + * The destructor decrements the reference count on the event + * handler corresponding to the given handle. + */ + ~ACE_Dev_Poll_Handler_Guard (void); + + /// Release the event handler from this guard; when the destructor is + /// called, the handler's reference count will not be decremented. + void release (void); + +private: + + /// The event handler being managed. + ACE_Event_Handler *eh_; + + /// true if eh_ is a reference-counted handler. + bool refcounted_; + +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +# include "ace/Dev_Poll_Reactor.inl" +#endif /* __ACE_INLINE__ */ + +#endif /* ACE_HAS_EVENT_POLL || ACE_HAS_DEV_POLL */ + +#include /**/ "ace/post.h" + +#endif /* ACE_DEV_POLL_REACTOR_H */ diff --git a/dep/ACE_wrappers/ace/Dev_Poll_Reactor.inl b/dep/ACE_wrappers/ace/Dev_Poll_Reactor.inl new file mode 100644 index 00000000000..96e71f2dea5 --- /dev/null +++ b/dep/ACE_wrappers/ace/Dev_Poll_Reactor.inl @@ -0,0 +1,228 @@ +// -*- C++ -*- +// +// $Id: Dev_Poll_Reactor.inl 80826 2008-03-04 14:51:23Z wotte $ + +#include "ace/Log_Msg.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_INLINE +ACE_Dev_Poll_Event_Tuple::ACE_Dev_Poll_Event_Tuple (void) + : event_handler (0), + mask (ACE_Event_Handler::NULL_MASK), + suspended (0) +{ +} + +// --------------------------------------------------------------------- + +#if 0 +ACE_INLINE +ACE_Dev_Poll_Ready_Set::ACE_Dev_Poll_Ready_Set (void) + : pfds (0), + nfds (0) +{ +} +#endif /* 0 */ + +// --------------------------------------------------------------------- + +ACE_INLINE void +ACE_Dev_Poll_Reactor_Handler_Repository::mask (ACE_HANDLE handle, + ACE_Reactor_Mask mask) +{ + ACE_TRACE ("ACE_Dev_Poll_Reactor_Handler_Repository::mask"); + + // Only bother to search for the handle if it's in range. + if (this->handle_in_range (handle)) + this->handlers_[handle].mask = mask; +} + +ACE_INLINE ACE_Reactor_Mask +ACE_Dev_Poll_Reactor_Handler_Repository::mask (ACE_HANDLE handle) +{ + ACE_TRACE ("ACE_Dev_Poll_Reactor_Handler_Repository::mask"); + + ACE_Reactor_Mask mask = ACE_Event_Handler::NULL_MASK; + + // Only bother to search for the handle if it's in range. + if (this->handle_in_range (handle)) + mask = this->handlers_[handle].mask; + + if (mask == ACE_Event_Handler::NULL_MASK) + errno = ENOENT; + + return mask; +} + +ACE_INLINE void +ACE_Dev_Poll_Reactor_Handler_Repository::suspend (ACE_HANDLE handle) +{ + ACE_TRACE ("ACE_Dev_Poll_Reactor_Handler_Repository::suspend"); + + // Only bother to search for the handle if it's in range. + if (this->handle_in_range (handle)) + this->handlers_[handle].suspended = 1; +} + +ACE_INLINE void +ACE_Dev_Poll_Reactor_Handler_Repository::resume (ACE_HANDLE handle) +{ + ACE_TRACE ("ACE_Dev_Poll_Reactor_Handler_Repository::resume"); + + // Only bother to search for the handle if it's in range. + if (this->handle_in_range (handle)) + this->handlers_[handle].suspended = 0; +} + +ACE_INLINE int +ACE_Dev_Poll_Reactor_Handler_Repository::suspended (ACE_HANDLE handle) const +{ + ACE_TRACE ("ACE_Dev_Poll_Reactor_Handler_Repository::suspended"); + + if (this->handle_in_range (handle)) + return this->handlers_[handle].suspended; + + return -1; +} + +ACE_INLINE size_t +ACE_Dev_Poll_Reactor_Handler_Repository::size (void) const +{ + ACE_TRACE ("ACE_Dev_Poll_Reactor_Handler_Repository::size"); + + return this->max_size_; +} + +// ----------------------------------------------------------------- + +ACE_INLINE +ACE_Dev_Poll_Handler_Guard::ACE_Dev_Poll_Handler_Guard + (ACE_Event_Handler *eh, + bool do_incr) + : eh_ (eh), + refcounted_ (false) +{ + if (eh == 0) + return; + + this->refcounted_ = + eh->reference_counting_policy ().value () == + ACE_Event_Handler::Reference_Counting_Policy::ENABLED; + + if (do_incr && this->refcounted_) + eh->add_reference (); + + /** + * The below comments were here when I replaced the old refcount + * scheme was replaced. They may still need addressing. -Steve Huston + */ + + /** + * @todo Suspend the handler so that other threads will not cause + * an event that is already in an upcall from being dispatched + * again. + * + * @note The naive approach would be to simply call + * suspend_handler_i() on the reactor. However, that would + * cause a system call (write()) to occur. Obviously this + * can potentially have an adverse affect on performance. + * Ideally, the handler would only be marked as "suspended" in + * the handler repository. If an event arrives for a + * suspended handler that event can be "queued" in a + * "handle readiness queue." "Queued" is quoted since a real + * queue need not be used since duplicate events can be + * coalesced, thus avoiding unbounded queue growth. Event + * coalescing is already done by Linux's event poll driver + * (/dev/epoll) so Solaris' poll driver (/dev/poll) is the + * main concern here. The largest the queue can be is the + * same size as the number of handlers stored in the handler + * repository. + */ +} + +ACE_INLINE +ACE_Dev_Poll_Handler_Guard::~ACE_Dev_Poll_Handler_Guard (void) +{ + if (this->refcounted_ && this->eh_ != 0) + this->eh_->remove_reference (); + + /** + * The below comments were here when I replaced the old refcount + * scheme was replaced. They may still need addressing. -Steve Huston + */ + /** + * @todo Resume the handler so that other threads will be allowed to + * dispatch the handler. + */ +} + +ACE_INLINE void +ACE_Dev_Poll_Handler_Guard::release (void) +{ + this->eh_ = 0; +} + +// --------------------------------------------------------------------- + +ACE_INLINE int +ACE_Dev_Poll_Reactor::upcall (ACE_Event_Handler *event_handler, + int (ACE_Event_Handler::*callback)(ACE_HANDLE), + ACE_HANDLE handle) +{ + // If the handler returns positive value (requesting a reactor + // callback) just call back as many times as the handler requests + // it. Other threads are off handling other things. + int status = 0; + + do + { + status = (event_handler->*callback) (handle); + } + while (status > 0); + + return status; +} + + +/************************************************************************/ +// Methods for ACE_Dev_Poll_Reactor::Token_Guard +/************************************************************************/ + +ACE_INLINE +ACE_Dev_Poll_Reactor::Token_Guard::Token_Guard (ACE_Dev_Poll_Reactor_Token &token) + + : token_ (token), + owner_ (0) +{ +} + +ACE_INLINE +ACE_Dev_Poll_Reactor::Token_Guard::~Token_Guard (void) +{ + if (this->owner_ == 1) + { + ACE_MT (this->token_.release ()); + this->owner_ = 0; + } +} + +ACE_INLINE void +ACE_Dev_Poll_Reactor::Token_Guard::release_token (void) +{ + if (this->owner_) + { + ACE_MT (this->token_.release ()); + + // We are not the owner anymore.. + this->owner_ = 0; + } +} + +ACE_INLINE int +ACE_Dev_Poll_Reactor::Token_Guard::is_owner (void) +{ + return this->owner_; +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Dirent.cpp b/dep/ACE_wrappers/ace/Dirent.cpp new file mode 100644 index 00000000000..df1290e1e53 --- /dev/null +++ b/dep/ACE_wrappers/ace/Dirent.cpp @@ -0,0 +1,7 @@ +// $Id: Dirent.cpp 80826 2008-03-04 14:51:23Z wotte $ + +#include "ace/Dirent.h" + +#if !defined (__ACE_INLINE__) +#include "ace/Dirent.inl" +#endif /* __ACE_INLINE__ */ diff --git a/dep/ACE_wrappers/ace/Dirent.h b/dep/ACE_wrappers/ace/Dirent.h new file mode 100644 index 00000000000..2dd5d0a19fb --- /dev/null +++ b/dep/ACE_wrappers/ace/Dirent.h @@ -0,0 +1,122 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Dirent.h + * + * $Id: Dirent.h 80826 2008-03-04 14:51:23Z wotte $ + * + * Define a portable C++ interface to ACE_OS_Dirent directory-entry + * manipulation. + * + * @author Douglas C. Schmidt + */ +//============================================================================= + +#ifndef ACE_DIRENT_H +#define ACE_DIRENT_H +#include /**/ "ace/pre.h" + +#include /**/ "ace/ACE_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/OS_NS_dirent.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +/** + * @class ACE_Dirent + * + * @brief Define a portable C++ directory-entry iterator based on the POSIX API. + */ +class ACE_Export ACE_Dirent +{ +public: + // = Initialization and termination methods. + /// Default constructor. + ACE_Dirent (void); + + /// Constructor calls + explicit ACE_Dirent (const ACE_TCHAR *dirname); + + /// Opens the directory named by filename and associates a directory + /// stream with it. + int open (const ACE_TCHAR *filename); + + /// Destructor calls . + ~ACE_Dirent (void); + + /// Closes the directory stream and frees the structure. + void close (void); + + // = Iterator methods. + /** + * Returns a pointer to a structure representing the directory entry + * at the current position in the directory stream to which dirp + * refers, and positions the directory stream at the next entry, + * except on read-only filesystems. It returns a NULL pointer upon + * reaching the end of the directory stream, or upon detecting an + * invalid location in the directory. shall not return + * directory entries containing empty names. It is unspecified + * whether entries are returned for dot or dot-dot. The pointer + * returned by points to data that may be overwritten by + * another call to on the same directory stream. This + * data shall not be overwritten by another call to on a + * different directory stream. may buffer several + * directory entries per actual read operation; marks for + * update the st_atime field of the directory each time the + * directory is actually read. + */ + ACE_DIRENT *read (void); + + /** + * Has the equivalent functionality as except that an + * @a entry and @a result buffer must be supplied by the caller to + * store the result. + */ + int read (struct ACE_DIRENT *entry, + struct ACE_DIRENT **result); + + // = Manipulators. + /// Returns the current location associated with the directory + /// stream. + long tell (void); + + /** + * Sets the position of the next operation on the + * directory stream. The new position reverts to the position + * associated with the directory stream at the time the + * operation that provides loc was performed. Values returned by + * are good only for the lifetime of the pointer from + * which they are derived. If the directory is closed and then + * reopened, the value may be invalidated due to + * undetected directory compaction. It is safe to use a previous + * value immediately after a call to and before + * any calls to readdir. + */ + void seek (long loc); + + /** + * Resets the position of the directory stream to the beginning of + * the directory. It also causes the directory stream to refer to + * the current state of the corresponding directory, as a call to + * would. + */ + void rewind (void); + +private: + /// Pointer to the directory stream. + ACE_DIR *dirp_; +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +#include "ace/Dirent.inl" +#endif /* __ACE_INLINE__ */ + +#include /**/ "ace/post.h" +#endif /* ACE_DIRENT_H */ diff --git a/dep/ACE_wrappers/ace/Dirent.inl b/dep/ACE_wrappers/ace/Dirent.inl new file mode 100644 index 00000000000..01ce3a96c4b --- /dev/null +++ b/dep/ACE_wrappers/ace/Dirent.inl @@ -0,0 +1,99 @@ +// -*- C++ -*- +// +// $Id: Dirent.inl 80826 2008-03-04 14:51:23Z wotte $ + +#include "ace/Log_Msg.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_INLINE int +ACE_Dirent::open (const ACE_TCHAR *dirname) +{ + // If the directory stream is already open, close it to prevent + // possible resource leaks. + + if (this->dirp_ != 0) + { + ACE_OS::closedir (this->dirp_); + this->dirp_ = 0; + } + + this->dirp_ = ACE_OS::opendir (dirname); + + if (this->dirp_ == 0) + return -1; + else + return 0; +} + +ACE_INLINE +ACE_Dirent::ACE_Dirent (void) + : dirp_ (0) +{ +} + +ACE_INLINE +ACE_Dirent::ACE_Dirent (const ACE_TCHAR *dirname) + : dirp_ (0) +{ + if (this->open (dirname) == -1) + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("%p\n"), + ACE_TEXT ("ACE_Dirent::ACE_Dirent"))); +} + +ACE_INLINE +ACE_Dirent::~ACE_Dirent (void) +{ + if (this->dirp_ != 0) + ACE_OS::closedir (this->dirp_); +} + +ACE_INLINE ACE_DIRENT * +ACE_Dirent::read (void) +{ + return this->dirp_ ? ACE_OS::readdir (this->dirp_) : 0; +} + +ACE_INLINE int +ACE_Dirent::read (struct ACE_DIRENT *entry, + struct ACE_DIRENT **result) +{ + return this->dirp_ + ? ACE_OS::readdir_r (this->dirp_, entry, result) + : 0; +} + +ACE_INLINE void +ACE_Dirent::close (void) +{ + if (this->dirp_ != 0) + { + ACE_OS::closedir (this->dirp_); + + // Prevent double closure + this->dirp_ = 0; + } +} + +ACE_INLINE void +ACE_Dirent::rewind (void) +{ + if (this->dirp_) + ACE_OS::rewinddir (this->dirp_); +} + +ACE_INLINE void +ACE_Dirent::seek (long loc) +{ + if (this->dirp_) + ACE_OS::seekdir (this->dirp_, loc); +} + +ACE_INLINE long +ACE_Dirent::tell (void) +{ + return this->dirp_ ? ACE_OS::telldir (this->dirp_) : 0; +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Dirent_Selector.cpp b/dep/ACE_wrappers/ace/Dirent_Selector.cpp new file mode 100644 index 00000000000..8fcb5775b29 --- /dev/null +++ b/dep/ACE_wrappers/ace/Dirent_Selector.cpp @@ -0,0 +1,59 @@ +// $Id: Dirent_Selector.cpp 80826 2008-03-04 14:51:23Z wotte $ + +#include "ace/Dirent_Selector.h" + +#if !defined (__ACE_INLINE__) +#include "ace/Dirent_Selector.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/OS_NS_dirent.h" +#include "ace/OS_NS_stdlib.h" + +ACE_RCSID (ace, + Dirent_Selector, + "$Id: Dirent_Selector.cpp 80826 2008-03-04 14:51:23Z wotte $") + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +// Construction/Destruction + +ACE_Dirent_Selector::ACE_Dirent_Selector (void) + : namelist_ (0), + n_ (0) +{ +} + +ACE_Dirent_Selector::~ACE_Dirent_Selector (void) +{ + // Free up any allocated resources. + this->close(); +} + +int +ACE_Dirent_Selector::open (const ACE_TCHAR *dir, + ACE_SCANDIR_SELECTOR sel, + ACE_SCANDIR_COMPARATOR cmp) +{ + n_ = ACE_OS::scandir (dir, &this->namelist_, sel, cmp); + return n_; +} + +int +ACE_Dirent_Selector::close (void) +{ + for (--n_; n_ >= 0; --n_) + { +#if defined (ACE_LACKS_STRUCT_DIR) + // Only the lacking-struct-dir emulation allocates this. Native + // scandir includes d_name in the dirent struct itself. + ACE_OS::free (this->namelist_[n_]->d_name); +#endif + ACE_OS::free (this->namelist_[n_]); + } + + ACE_OS::free (this->namelist_); + this->namelist_ = 0; + return 0; +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Dirent_Selector.h b/dep/ACE_wrappers/ace/Dirent_Selector.h new file mode 100644 index 00000000000..20673c473a9 --- /dev/null +++ b/dep/ACE_wrappers/ace/Dirent_Selector.h @@ -0,0 +1,75 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Dirent_Selector.h + * + * $Id: Dirent_Selector.h 80826 2008-03-04 14:51:23Z wotte $ + * + * Define a portable C++ interface to the method. + * + * @author Rich Newman + */ +//============================================================================= + +#ifndef ACE_DIRENT_SELECTOR_H +#define ACE_DIRENT_SELECTOR_H +#include /**/ "ace/pre.h" + +#include /**/ "ace/ACE_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +#pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/OS_NS_dirent.h" /* Need ACE_SCANDIR_SELECTOR, COMPARATOR */ +#include "ace/os_include/os_dirent.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +/** + * @class ACE_Dirent_Selector + * + * @brief Define a portable C++ directory-entry iterator based on the + * POSIX scandir API. + */ +class ACE_Export ACE_Dirent_Selector +{ +public: + /// Constructor + ACE_Dirent_Selector (void); + + /// Destructor. + virtual ~ACE_Dirent_Selector (void); + + /// Return the length of the list of matching directory entries. + int length (void) const; + + /// Return the entry at @a index. + ACE_DIRENT *operator[] (const int index) const; + + /// Free up resources. + int close (void); + + /// Open the directory @a dir and populate the current list of names with + /// directory entries that match the @a selector and @a comparator. + int open (const ACE_TCHAR *dir, + ACE_SCANDIR_SELECTOR selector = 0, + ACE_SCANDIR_COMPARATOR comparator = 0); + +protected: + /// Ptr to the namelist array. + ACE_DIRENT **namelist_; + + /// Number of entries in the array. + int n_; +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +#include "ace/Dirent_Selector.inl" +#endif /* __ACE_INLINE__ */ + +#include /**/ "ace/post.h" +#endif /* ACE_DIRENT_SELECTOR_H */ diff --git a/dep/ACE_wrappers/ace/Dirent_Selector.inl b/dep/ACE_wrappers/ace/Dirent_Selector.inl new file mode 100644 index 00000000000..15f804704bf --- /dev/null +++ b/dep/ACE_wrappers/ace/Dirent_Selector.inl @@ -0,0 +1,19 @@ +// -*- C++ -*- +// +// $Id: Dirent_Selector.inl 80826 2008-03-04 14:51:23Z wotte $ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_INLINE int +ACE_Dirent_Selector::length (void) const +{ + return n_; +} + +ACE_INLINE ACE_DIRENT * +ACE_Dirent_Selector::operator[] (const int n) const +{ + return this->namelist_[n]; +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Dump.cpp b/dep/ACE_wrappers/ace/Dump.cpp new file mode 100644 index 00000000000..6e5c2d0c3ea --- /dev/null +++ b/dep/ACE_wrappers/ace/Dump.cpp @@ -0,0 +1,141 @@ +// $Id: Dump.cpp 80826 2008-03-04 14:51:23Z wotte $ + +#include "ace/Dump.h" +#include "ace/Guard_T.h" +#include "ace/Thread_Mutex.h" +#include "ace/Object_Manager.h" +#include "ace/Log_Msg.h" + +ACE_RCSID(ace, Dump, "$Id: Dump.cpp 80826 2008-03-04 14:51:23Z wotte $") + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +// Implementations (very simple for now...) + +ACE_Dumpable::~ACE_Dumpable (void) +{ + ACE_TRACE ("ACE_Dumpable::~ACE_Dumpable"); +} + +ACE_Dumpable::ACE_Dumpable (const void *this_ptr) + : this_ (this_ptr) +{ + ACE_TRACE ("ACE_Dumpable::ACE_Dumpable"); +} + +ACE_Dumpable_Ptr::ACE_Dumpable_Ptr (const ACE_Dumpable *dumper) + : dumper_ (dumper) +{ + ACE_TRACE ("ACE_Dumpable_Ptr::ACE_Dumpable_Ptr"); +} + +const ACE_Dumpable * +ACE_Dumpable_Ptr::operator->() const +{ + ACE_TRACE ("ACE_Dumpable_Ptr::operator->"); + return this->dumper_; +} + +void +ACE_Dumpable_Ptr::operator= (const ACE_Dumpable *dumper) const +{ + ACE_TRACE ("ACE_Dumpable_Ptr::operator="); + if (this->dumper_ != dumper) + { + delete const_cast (this->dumper_); + (const_cast (this))->dumper_ = dumper; + } +} + +ACE_ODB::ACE_ODB (void) + // Let the Tuple default constructor initialize object_table_ + : current_size_ (0) +{ + ACE_TRACE ("ACE_ODB::ACE_ODB"); +} + +ACE_ODB * +ACE_ODB::instance (void) +{ + ACE_TRACE ("ACE_ODB::instance"); + + if (ACE_ODB::instance_ == 0) + { + ACE_MT (ACE_Thread_Mutex *lock = + ACE_Managed_Object::get_preallocated_object + (ACE_Object_Manager::ACE_DUMP_LOCK); + ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, *lock, 0)); + + if (ACE_ODB::instance_ == 0) + ACE_NEW_RETURN (ACE_ODB::instance_, + ACE_ODB, + 0); + } + + return ACE_ODB::instance_; +} + +void +ACE_ODB::dump_objects (void) +{ + ACE_TRACE ("ACE_ODB::dump_objects"); + for (int i = 0; i < this->current_size_; i++) + { + if (this->object_table_[i].this_ != 0) + // Dump the state of the object. + this->object_table_[i].dumper_->dump (); + } +} + +// This method registers a new . It detects +// duplicates and simply overwrites them. + +void +ACE_ODB::register_object (const ACE_Dumpable *dumper) +{ + ACE_TRACE ("ACE_ODB::register_object"); + int i; + int slot = 0; + + for (i = 0; i < this->current_size_; i++) + { + if (this->object_table_[i].this_ == 0) + slot = i; + else if (this->object_table_[i].this_ == dumper->this_) + { + slot = i; + break; + } + } + + if (i == this->current_size_) + { + slot = this->current_size_++; + ACE_ASSERT (this->current_size_ < ACE_ODB::MAX_TABLE_SIZE); + } + this->object_table_[slot].this_ = dumper->this_; + this->object_table_[slot].dumper_ = dumper; +} + +void +ACE_ODB::remove_object (const void *this_ptr) +{ + ACE_TRACE ("ACE_ODB::remove_object"); + int i; + + for (i = 0; i < this->current_size_; i++) + { + if (this->object_table_[i].this_ == this_ptr) + break; + } + + if (i < this->current_size_) + { + this->object_table_[i].this_ = 0; + this->object_table_[i].dumper_ = 0; + } +} + +ACE_ODB *ACE_ODB::instance_ = 0; + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Dump.h b/dep/ACE_wrappers/ace/Dump.h new file mode 100644 index 00000000000..4ccd64adb95 --- /dev/null +++ b/dep/ACE_wrappers/ace/Dump.h @@ -0,0 +1,172 @@ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file Dump.h + * + * $Id: Dump.h 80826 2008-03-04 14:51:23Z wotte $ + * + * + * A prototype mechanism that allow all ACE objects to be registered + * with a central in-memory "database" that can dump the state of all + * live ACE objects (e.g., from within a debugger). + * + * The macros which allow easy registration and removal of objects to be + * dumped (ACE_REGISTER_OBJECT and ACE_REMOVE_OBJECT) are turned into + * no-ops by compiling with the ACE_NDEBUG macro defined. This allows + * usage to be removed in "release mode" builds without changing code. + * + * There are several interesting aspects to this design: + * + * 1. It uses the External Polymorphism pattern to avoid having to + * derive all ACE classes from a common base class that has virtual + * methods (this is crucial to avoid unnecessary overhead). In + * addition, there is no additional space added to ACE objects + * (this is crucial to maintain binary layout compatibility). + * + * 2. This mechanism can be conditionally compiled in order to + * completely disable this feature entirely. Moreover, by + * using macros there are relatively few changes to ACE code. + * + * 3. This mechanism copes with single-inheritance hierarchies of + * dumpable classes. In such cases we typically want only one + * dump, corresponding to the most derived instance. Thanks to + * Christian Millour (chris@etca.fr) for illustrating how to do + * this. Note, however, that this scheme doesn't generalize to + * work with multiple-inheritance or virtual base classes. + * + * Future work includes: + * + * 1. Using a dynamic object table rather than a static table + * + * 2. Adding support to allow particular classes of objects to + * be selectively dumped. + * + * + * @author Doug Schmidt + */ +//============================================================================= + + +#ifndef ACE_DUMP_H +#define ACE_DUMP_H +#include /**/ "ace/pre.h" + +#include /**/ "ace/ACE_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +/** + * @class ACE_Dumpable + * + * @brief Base class that defines a uniform interface for all object + * dumping. + */ +class ACE_Export ACE_Dumpable +{ +public: + friend class ACE_ODB; + friend class ACE_Dumpable_Ptr; + + /// Constructor. + ACE_Dumpable (const void *); + + /// This pure virtual method must be filled in by a subclass. + virtual void dump (void) const = 0; + +protected: + virtual ~ACE_Dumpable (void); + +private: + /// Pointer to the object that is being stored. + const void *this_; +}; + +/** + * @class ACE_Dumpable_Ptr + * + * @brief A smart pointer stored in the in-memory object database + * ACE_ODB. The pointee (if any) is deleted when reassigned. + */ +class ACE_Export ACE_Dumpable_Ptr +{ +public: + ACE_Dumpable_Ptr (const ACE_Dumpable *dumper = 0); + const ACE_Dumpable *operator->() const; + void operator= (const ACE_Dumpable *dumper) const; + +private: + /// "Real" pointer to the underlying abstract base class + /// pointer that does the real work. + const ACE_Dumpable *dumper_; +}; + +/** + * @class ACE_ODB + * + * @brief This is the object database (ODB) that keeps track of all + * live ACE objects. + */ +class ACE_Export ACE_ODB +{ +public: + /// @todo This is clearly inadequate and should be dynamic... + enum {MAX_TABLE_SIZE = 100000}; + + /// Iterates through the entire set of registered objects and + /// dumps their state. + void dump_objects (void); + + /// Add the tuple to the list of registered ACE objects. + void register_object (const ACE_Dumpable *dumper); + + /// Use to locate and remove the associated from the + /// list of registered ACE objects. + void remove_object (const void *this_); + + /// Interface to the Singleton instance of the object database. + static ACE_ODB *instance (void); + +private: + ACE_ODB (void); // Ensure we have a Singleton... + + struct Tuple + { + /// Pointer to the object that is registered. + const void *this_; + + /// Smart pointer to the ACE_Dumpable object associated with this_. + /// This uses an ACE_Dumpable_Ptr, instead of a bare pointer, to + /// cope with hierarchies of dumpable classes. In such cases we + /// typically want only one dump, corresponding to the most derived + /// instance. To achieve this, the handle registered for the + /// subobject corresponding to the base class is destroyed (hence + /// on destruction of the subobject its handle won't exist anymore + /// and we'll have to check for that). + const ACE_Dumpable_Ptr dumper_; + + Tuple (void) : dumper_(0) {} + }; + + /// Singleton instance of this class. + static ACE_ODB *instance_; + + /// The current implementation is very simple-minded and will be + /// changed to be dynamic. + Tuple object_table_[ACE_ODB::MAX_TABLE_SIZE]; + + /// Current size of . + int current_size_; +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +// Include the templates classes at this point. +#include "ace/Dump_T.h" + +#include /**/ "ace/post.h" +#endif /* ACE_DUMP_H */ diff --git a/dep/ACE_wrappers/ace/Dump_T.cpp b/dep/ACE_wrappers/ace/Dump_T.cpp new file mode 100644 index 00000000000..da2b62a6fa3 --- /dev/null +++ b/dep/ACE_wrappers/ace/Dump_T.cpp @@ -0,0 +1,48 @@ +// Dump_T.cpp +// +// $Id: Dump_T.cpp 80826 2008-03-04 14:51:23Z wotte $ + +#ifndef ACE_DUMP_T_CPP +#define ACE_DUMP_T_CPP + +#include "ace/Dump_T.h" +#include "ace/Global_Macros.h" +#include "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +template +ACE_Dumpable_Adapter::~ACE_Dumpable_Adapter (void) +{ + ACE_TRACE ("ACE_Dumpable_Adapter::~ACE_Dumpable_Adapter"); +} + +template +ACE_Dumpable_Adapter::ACE_Dumpable_Adapter (const Concrete *t) + : ACE_Dumpable ((const void *) t), this_ (t) +{ + ACE_TRACE ("ACE_Dumpable_Adapter::ACE_Dumpable_Adapter"); +} + +template Concrete * +ACE_Dumpable_Adapter::operator->() const +{ + return (Concrete *) this->this_; +} + +template void +ACE_Dumpable_Adapter::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + ACE_TRACE ("ACE_Dumpable_Adapter::dump"); + this->this_->dump (); +#endif /* ACE_HAS_DUMP */ +} + +ACE_END_VERSIONED_NAMESPACE_DECL + +#endif /* ACE_DUMP_T_CPP */ diff --git a/dep/ACE_wrappers/ace/Dump_T.h b/dep/ACE_wrappers/ace/Dump_T.h new file mode 100644 index 00000000000..92b57addce6 --- /dev/null +++ b/dep/ACE_wrappers/ace/Dump_T.h @@ -0,0 +1,82 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Dump_T.h + * + * $Id: Dump_T.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Doug Schmidt + */ +//============================================================================= + + +#ifndef ACE_DUMP_T_H +#define ACE_DUMP_T_H +#include /**/ "ace/pre.h" + +#include "ace/Dump.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +/** + * @class ACE_Dumpable_Adapter + * + * @brief This class inherits the interface of the abstract ACE_Dumpable + * class and is instantiated with the implementation of the + * concrete component class . + * + * This design is similar to the Adapter and Decorator patterns + * from the ``Gang of Four'' book. Note that + * need not inherit from a common class since ACE_Dumpable + * provides the uniform virtual interface! + */ +template +class ACE_Dumpable_Adapter : public ACE_Dumpable +{ +public: + // = Initialization and termination methods. + ACE_Dumpable_Adapter (const Concrete *t); + ~ACE_Dumpable_Adapter (void); + + /// Concrete dump method (simply delegates to the method of + /// ). + virtual void dump (void) const; + + /// Delegate to methods in the Concrete class. + Concrete *operator->() const; + +private: + /// Pointer to @c this of . + const Concrete *this_; +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +// Some useful macros for conditionally compiling this feature... +#if defined (ACE_NDEBUG) +#define ACE_REGISTER_OBJECT(CLASS) +#define ACE_REMOVE_OBJECT +#else +#define ACE_REGISTER_OBJECT(CLASS) \ + ACE_ODB::instance ()->register_object \ + (new ACE_Dumpable_Adapter (this)); +#define ACE_REMOVE_OBJECT \ + ACE_ODB::instance ()->remove_object \ + ((void *) this); +#endif /* ACE_NDEBUG */ + +#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) +#include "ace/Dump_T.cpp" +#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ + +#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) +#pragma implementation ("Dump_T.cpp") +#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ + +#include /**/ "ace/post.h" +#endif /* ACE_DUMP_T_H */ diff --git a/dep/ACE_wrappers/ace/Dynamic.cpp b/dep/ACE_wrappers/ace/Dynamic.cpp new file mode 100644 index 00000000000..4eaedad0cfe --- /dev/null +++ b/dep/ACE_wrappers/ace/Dynamic.cpp @@ -0,0 +1,34 @@ +// $Id: Dynamic.cpp 80826 2008-03-04 14:51:23Z wotte $ + +#include "ace/Dynamic.h" +#include "ace/Singleton.h" +#include "ace/TSS_T.h" +#include "ace/Synch_Traits.h" +#include "ace/Null_Mutex.h" + +#if !defined (__ACE_INLINE__) +#include "ace/Dynamic.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(ace, Dynamic, "$Id: Dynamic.cpp 80826 2008-03-04 14:51:23Z wotte $") + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_Dynamic::ACE_Dynamic (void) + : is_dynamic_ (false) +{ + ACE_TRACE ("ACE_Dynamic::ACE_Dynamic"); +} + +/* static */ ACE_Dynamic * +ACE_Dynamic::instance (void) +{ + return ACE_TSS_Singleton::instance (); +} + +#if defined (ACE_HAS_EXPLICIT_STATIC_TEMPLATE_MEMBER_INSTANTIATION) +template ACE_TSS_Singleton * + ACE_TSS_Singleton::singleton_; +#endif /* ACE_HAS_EXPLICIT_STATIC_TEMPLATE_MEMBER_INSTANTIATION */ + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Dynamic.h b/dep/ACE_wrappers/ace/Dynamic.h new file mode 100644 index 00000000000..70dfcd8d90a --- /dev/null +++ b/dep/ACE_wrappers/ace/Dynamic.h @@ -0,0 +1,75 @@ +// -*- C++ -*- + +//========================================================================== +/** + * @file Dynamic.h + * + * $Id: Dynamic.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Doug Schmidt + * @author Irfan Pyarali. + */ +//========================================================================== + +#ifndef ACE_DYNAMIC_H +#define ACE_DYNAMIC_H +#include /**/ "ace/pre.h" + +#include /**/ "ace/ACE_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +/** + * @class ACE_Dynamic + * + * @brief Checks to see if an object was dynamically allocated. + * + * This class holds the pointer in a thread-safe manner between + * the call to operator new and the call to the constructor. + */ +class ACE_Export ACE_Dynamic +{ +public: + // = Initialization and termination method. + /// Constructor. + ACE_Dynamic (void); + + /// Destructor. + ~ACE_Dynamic (void); + + /** + * Sets a flag that indicates that the object was dynamically + * created. This method is usually called in operator new and then + * checked and reset in the constructor. + */ + void set (void); + + /// @c true if we were allocated dynamically, else @c false. + bool is_dynamic (void); + + /// Resets state flag. + void reset (void); + + static ACE_Dynamic *instance (void); + +private: + /** + * Flag that indicates that the object was dynamically created. This + * method is usually called in operator new and then checked and + * reset in the constructor. + */ + bool is_dynamic_; +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +#include "ace/Dynamic.inl" +#endif /* __ACE_INLINE__ */ + +#include /**/ "ace/post.h" +#endif /* ACE_DYNAMIC_H */ diff --git a/dep/ACE_wrappers/ace/Dynamic.inl b/dep/ACE_wrappers/ace/Dynamic.inl new file mode 100644 index 00000000000..1e8e968f898 --- /dev/null +++ b/dep/ACE_wrappers/ace/Dynamic.inl @@ -0,0 +1,34 @@ +// -*- C++ -*- +// +// $Id: Dynamic.inl 80826 2008-03-04 14:51:23Z wotte $ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_INLINE +ACE_Dynamic::~ACE_Dynamic (void) +{ + // ACE_TRACE ("ACE_Dynamic::~ACE_Dynamic"); +} + +ACE_INLINE void +ACE_Dynamic::set (void) +{ + // ACE_TRACE ("ACE_Dynamic::set"); + this->is_dynamic_ = true; +} + +ACE_INLINE bool +ACE_Dynamic::is_dynamic (void) +{ + // ACE_TRACE ("ACE_Dynamic::is_dynamic"); + return this->is_dynamic_; +} + +ACE_INLINE void +ACE_Dynamic::reset (void) +{ + // ACE_TRACE ("ACE_Dynamic::reset"); + this->is_dynamic_ = false; +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Dynamic_Message_Strategy.cpp b/dep/ACE_wrappers/ace/Dynamic_Message_Strategy.cpp new file mode 100644 index 00000000000..9211f3313a6 --- /dev/null +++ b/dep/ACE_wrappers/ace/Dynamic_Message_Strategy.cpp @@ -0,0 +1,205 @@ +#include "ace/Dynamic_Message_Strategy.h" + +#if !defined (__ACE_INLINE__) +#include "ace/Dynamic_Message_Strategy.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/Guard_T.h" +#include "ace/Log_Msg.h" +#include "ace/Malloc_Base.h" +#include "ace/OS_NS_string.h" + +ACE_RCSID (ace, + Dynamic_Message_Strategy, + "$Id: Dynamic_Message_Strategy.cpp 80826 2008-03-04 14:51:23Z wotte $") + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +// ctor + +ACE_Dynamic_Message_Strategy::ACE_Dynamic_Message_Strategy (unsigned long static_bit_field_mask, + unsigned long static_bit_field_shift, + unsigned long dynamic_priority_max, + unsigned long dynamic_priority_offset) + : static_bit_field_mask_ (static_bit_field_mask), + static_bit_field_shift_ (static_bit_field_shift), + dynamic_priority_max_ (dynamic_priority_max), + dynamic_priority_offset_ (dynamic_priority_offset), + max_late_ (0, dynamic_priority_offset - 1), + min_pending_ (0, dynamic_priority_offset), + pending_shift_ (0, dynamic_priority_max) +{ +} + +// dtor + +ACE_Dynamic_Message_Strategy::~ACE_Dynamic_Message_Strategy (void) +{ +} + +ACE_Dynamic_Message_Strategy::Priority_Status +ACE_Dynamic_Message_Strategy::priority_status (ACE_Message_Block & mb, + const ACE_Time_Value & tv) +{ + // default the message to have pending priority status + Priority_Status status = ACE_Dynamic_Message_Strategy::PENDING; + + // start with the passed absolute time as the message's priority, then + // call the polymorphic hook method to (at least partially) convert + // the absolute time and message attributes into the message's priority + ACE_Time_Value priority (tv); + convert_priority (priority, mb); + + // if the priority is negative, the message is pending + if (priority < ACE_Time_Value::zero) + { + // priority for pending messages must be shifted + // upward above the late priority range + priority += pending_shift_; + if (priority < min_pending_) + priority = min_pending_; + } + // otherwise, if the priority is greater than the maximum late + // priority value that can be represented, it is beyond late + else if (priority > max_late_) + { + // all messages that are beyond late are assigned lowest priority (zero) + mb.msg_priority (0); + return ACE_Dynamic_Message_Strategy::BEYOND_LATE; + } + // otherwise, the message is late, but its priority is correct + else + status = ACE_Dynamic_Message_Strategy::LATE; + + // use (fast) bitwise operators to isolate and replace + // the dynamic portion of the message's priority + mb.msg_priority((mb.msg_priority() & static_bit_field_mask_) | + ((priority.usec () + + ACE_ONE_SECOND_IN_USECS * (suseconds_t)(priority.sec())) << + static_bit_field_shift_)); + + // returns the priority status of the message + return status; +} + + +// Dump the state of the strategy. + +void +ACE_Dynamic_Message_Strategy::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + ACE_TRACE ("ACE_Dynamic_Message_Strategy::dump"); + + ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); + + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("static_bit_field_mask_ = %u\n") + ACE_TEXT ("static_bit_field_shift_ = %u\n") + ACE_TEXT ("dynamic_priority_max_ = %u\n") + ACE_TEXT ("dynamic_priority_offset_ = %u\n") + ACE_TEXT ("max_late_ = [%d sec, %d usec]\n") + ACE_TEXT ("min_pending_ = [%d sec, %d usec]\n") + ACE_TEXT ("pending_shift_ = [%d sec, %d usec]\n"), + this->static_bit_field_mask_, + this->static_bit_field_shift_, + this->dynamic_priority_max_, + this->dynamic_priority_offset_, + this->max_late_.sec (), + this->max_late_.usec (), + this->min_pending_.sec (), + this->min_pending_.usec (), + this->pending_shift_.sec (), + this->pending_shift_.usec ())); + + ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); +#endif /* ACE_HAS_DUMP */ +} + +ACE_Deadline_Message_Strategy::ACE_Deadline_Message_Strategy (unsigned long static_bit_field_mask, + unsigned long static_bit_field_shift, + unsigned long dynamic_priority_max, + unsigned long dynamic_priority_offset) + : ACE_Dynamic_Message_Strategy (static_bit_field_mask, + static_bit_field_shift, + dynamic_priority_max, + dynamic_priority_offset) +{ +} + +ACE_Deadline_Message_Strategy::~ACE_Deadline_Message_Strategy (void) +{ +} + +void +ACE_Deadline_Message_Strategy::convert_priority (ACE_Time_Value & priority, + const ACE_Message_Block & mb) +{ + // Convert absolute time passed in tv to negative time + // to deadline of mb with respect to that absolute time. + priority -= mb.msg_deadline_time (); +} + // dynamic priority conversion function based on time to deadline + +void +ACE_Deadline_Message_Strategy::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + ACE_TRACE ("ACE_Deadline_Message_Strategy::dump"); + + ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); + + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("ACE_Dynamic_Message_Strategy base class: \n"))); + this->ACE_Dynamic_Message_Strategy::dump (); + + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nderived class: ACE_Deadline_Message_Strategy\n"))); + + ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); +#endif /* ACE_HAS_DUMP */ +} + +ACE_Laxity_Message_Strategy::ACE_Laxity_Message_Strategy (unsigned long static_bit_field_mask, + unsigned long static_bit_field_shift, + unsigned long dynamic_priority_max, + unsigned long dynamic_priority_offset) + : ACE_Dynamic_Message_Strategy (static_bit_field_mask, + static_bit_field_shift, + dynamic_priority_max, + dynamic_priority_offset) +{ +} + +ACE_Laxity_Message_Strategy::~ACE_Laxity_Message_Strategy (void) +{ +} + +void +ACE_Laxity_Message_Strategy::convert_priority (ACE_Time_Value & priority, + const ACE_Message_Block & mb) +{ + // Convert absolute time passed in tv to negative + // laxity of mb with respect to that absolute time. + priority += mb.msg_execution_time (); + priority -= mb.msg_deadline_time (); +} + // dynamic priority conversion function based on laxity + +void +ACE_Laxity_Message_Strategy::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + ACE_TRACE ("ACE_Laxity_Message_Strategy::dump"); + + ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); + + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("ACE_Dynamic_Message_Strategy base class: \n"))); + this->ACE_Dynamic_Message_Strategy::dump (); + + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nderived class: ACE_Laxity_Message_Strategy\n"))); + + ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); +#endif /* ACE_HAS_DUMP */ +} + // Dump the state of the strategy. + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Dynamic_Message_Strategy.h b/dep/ACE_wrappers/ace/Dynamic_Message_Strategy.h new file mode 100644 index 00000000000..090ad3a8f82 --- /dev/null +++ b/dep/ACE_wrappers/ace/Dynamic_Message_Strategy.h @@ -0,0 +1,217 @@ +// -*- C++ -*- + +//========================================================================== +/** + * @file Dynamic_Message_Strategy.h + * + * $Id: Dynamic_Message_Strategy.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Douglas C. Schmidt + */ +//========================================================================== + +#ifndef ACE_DYNAMIC_MESSAGE_STRATEGY_H +#define ACE_DYNAMIC_MESSAGE_STRATEGY_H + +#include /**/ "ace/pre.h" + +#include "ace/config-lite.h" +#include /**/ "ace/ACE_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/Message_Block.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +/** + * @class ACE_Dynamic_Message_Strategy + * + * @brief An abstract base class which provides dynamic priority + * evaluation methods for use by the ACE_Dynamic_Message_Queue + * class or any other class which needs to manage the priorities + * of a collection of ACE_Message_Blocks dynamically. + * + * Methods for deadline and laxity based priority evaluation are + * provided. These methods assume a specific partitioning of + * the message priority number into a higher order dynamic bit + * field and a lower order static priority bit field. The + * default partitioning assumes an unsigned dynamic message + * priority field of 22 bits and an unsigned static message + * priority field of 10 bits. This corresponds to the initial + * values of the static class members. To provide a different + * partitioning, assign a different set of values to the static + * class memebers before using the static member functions. + */ +class ACE_Export ACE_Dynamic_Message_Strategy +{ +public: + + // = Message priority status + + // Values are defined as bit flags so that status combinations may + // be specified easily. + + enum Priority_Status + { + /// Message can still make its deadline + PENDING = 0x01, + /// Message cannot make its deadline + LATE = 0x02, + /// Message is so late its priority is undefined + BEYOND_LATE = 0x04, + /// Mask to match any priority status + ANY_STATUS = 0x07 + }; + + /// Constructor. + ACE_Dynamic_Message_Strategy (unsigned long static_bit_field_mask, + unsigned long static_bit_field_shift, + unsigned long dynamic_priority_max, + unsigned long dynamic_priority_offset); + + /// Virtual destructor. + virtual ~ACE_Dynamic_Message_Strategy (void); + + /// Updates the message's priority and returns its priority status. + Priority_Status priority_status (ACE_Message_Block &mb, + const ACE_Time_Value &tv); + + /// Get static bit field mask. + unsigned long static_bit_field_mask (void) const; + + /// Set static bit field mask. + void static_bit_field_mask (unsigned long); + + /// Get left shift value to make room for static bit field. + unsigned long static_bit_field_shift (void) const; + + /// Set left shift value to make room for static bit field. + void static_bit_field_shift (unsigned long); + + /// Get maximum supported priority value. + unsigned long dynamic_priority_max (void) const; + + /// Set maximum supported priority value. + void dynamic_priority_max (unsigned long); + + /// Get offset to boundary between signed range and unsigned range. + unsigned long dynamic_priority_offset (void) const; + + /// Set offset to boundary between signed range and unsigned range. + void dynamic_priority_offset (unsigned long); + + /// Dump the state of the strategy. + virtual void dump (void) const; + +protected: + /// Hook method for dynamic priority conversion. + virtual void convert_priority (ACE_Time_Value &priority, + const ACE_Message_Block &mb) = 0; + + /// This is a bit mask with all ones in the static bit field. + unsigned long static_bit_field_mask_; + + /** + * This is a left shift value to make room for static bit field: + * this value should be the logarithm base 2 of + * (static_bit_field_mask_ + 1). + */ + unsigned long static_bit_field_shift_; + + /// Maximum supported priority value. + unsigned long dynamic_priority_max_; + + /// Offset to boundary between signed range and unsigned range. + unsigned long dynamic_priority_offset_; + + /// Maximum late time value that can be represented. + ACE_Time_Value max_late_; + + /// Minimum pending time value that can be represented. + ACE_Time_Value min_pending_; + + /// Time value by which to shift pending priority. + ACE_Time_Value pending_shift_; +}; + +/** + * @class ACE_Deadline_Message_Strategy + * + * @brief Deadline based message priority strategy. + * + * Assigns dynamic message priority according to time to deadline. The + * message priority is divided into high and low order bit fields. The + * high order bit field is used for dynamic message priority, which is + * updated whenever the convert_priority() method is called. The + * low order bit field is used for static message priority and is left + * unchanged. The partitioning of the priority value into high and low + * order bit fields is done according to the arguments passed to the + * strategy object's constructor. + */ +class ACE_Export ACE_Deadline_Message_Strategy : public ACE_Dynamic_Message_Strategy +{ +public: + /// Ctor, with all arguments defaulted. + ACE_Deadline_Message_Strategy (unsigned long static_bit_field_mask = 0x3FFUL, // 2^(10) - 1 + unsigned long static_bit_field_shift = 10, // 10 low order bits + unsigned long dynamic_priority_max = 0x3FFFFFUL, // 2^(22)-1 + unsigned long dynamic_priority_offset = 0x200000UL); // 2^(22-1) + + /// Virtual dtor. + virtual ~ACE_Deadline_Message_Strategy (void); + + /// Dynamic priority conversion function based on time to deadline. + virtual void convert_priority (ACE_Time_Value &priority, + const ACE_Message_Block &mb); + + /// Dump the state of the strategy. + virtual void dump (void) const; +}; + +/** + * @class ACE_Laxity_Message_Strategy + * + * @brief Laxity based message priority strategy. + * + * Assigns dynamic message priority according to laxity (time to + * deadline minus worst case execution time). The message priority is + * divided into high and low order bit fields. The high order + * bit field is used for dynamic message priority, which is + * updated whenever the convert_priority() method is called. The + * low order bit field is used for static message priority and is left + * unchanged. The partitioning of the priority value into high and low + * order bit fields is done according to the arguments passed to the + * strategy object's constructor. + */ +class ACE_Export ACE_Laxity_Message_Strategy : public ACE_Dynamic_Message_Strategy +{ +public: + /// Ctor, with all arguments defaulted. + ACE_Laxity_Message_Strategy (unsigned long static_bit_field_mask = 0x3FFUL, // 2^(10) - 1 + unsigned long static_bit_field_shift = 10, // 10 low order bits + unsigned long dynamic_priority_max = 0x3FFFFFUL, // 2^(22)-1 + unsigned long dynamic_priority_offset = 0x200000UL); // 2^(22-1) + + /// virtual dtor. + virtual ~ACE_Laxity_Message_Strategy (void); + + /// Dynamic priority conversion function based on laxity. + virtual void convert_priority (ACE_Time_Value &priority, + const ACE_Message_Block &mb); + + /// Dump the state of the strategy. + virtual void dump (void) const; +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +#include "ace/Dynamic_Message_Strategy.inl" +#endif /* __ACE_INLINE__ */ + +#include /**/ "ace/post.h" + +#endif /* ACE_DYNAMIC_MESSAGE_STRATEGY_H */ diff --git a/dep/ACE_wrappers/ace/Dynamic_Message_Strategy.inl b/dep/ACE_wrappers/ace/Dynamic_Message_Strategy.inl new file mode 100644 index 00000000000..9742a07fd88 --- /dev/null +++ b/dep/ACE_wrappers/ace/Dynamic_Message_Strategy.inl @@ -0,0 +1,75 @@ +// -*- C++ -*- +// +// $Id: Dynamic_Message_Strategy.inl 80826 2008-03-04 14:51:23Z wotte $ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_INLINE unsigned long +ACE_Dynamic_Message_Strategy::static_bit_field_mask (void) const +{ + return static_bit_field_mask_; +} + // get static bit field mask + +ACE_INLINE void +ACE_Dynamic_Message_Strategy::static_bit_field_mask (unsigned long ul) +{ + static_bit_field_mask_ = ul; +} + // set static bit field mask + +ACE_INLINE unsigned long +ACE_Dynamic_Message_Strategy::static_bit_field_shift (void) const +{ + return static_bit_field_shift_; +} + // get left shift value to make room for static bit field + +ACE_INLINE void +ACE_Dynamic_Message_Strategy::static_bit_field_shift (unsigned long ul) +{ + static_bit_field_shift_ = ul; +} + // set left shift value to make room for static bit field + +ACE_INLINE unsigned long +ACE_Dynamic_Message_Strategy::dynamic_priority_max (void) const +{ + return dynamic_priority_max_; +} + // get maximum supported priority value + +ACE_INLINE void +ACE_Dynamic_Message_Strategy::dynamic_priority_max (unsigned long ul) +{ + // pending_shift_ depends on dynamic_priority_max_: for performance + // reasons, the value in pending_shift_ is (re)calculated only when + // dynamic_priority_max_ is initialized or changes, and is stored + // as a class member rather than being a derived value. + dynamic_priority_max_ = ul; + pending_shift_ = ACE_Time_Value (0, ul); +} + // set maximum supported priority value + +ACE_INLINE unsigned long +ACE_Dynamic_Message_Strategy::dynamic_priority_offset (void) const +{ + return dynamic_priority_offset_; +} + // get offset for boundary between signed range and unsigned range + +ACE_INLINE void +ACE_Dynamic_Message_Strategy::dynamic_priority_offset (unsigned long ul) +{ + // max_late_ and min_pending_ depend on dynamic_priority_offset_: + // for performance reasons, the values in max_late_ and min_pending_ + // are (re)calculated only when dynamic_priority_offset_ is + // initialized or changes, and are stored as a class member rather + // than being derived each time one of their values is needed. + dynamic_priority_offset_ = ul; + max_late_ = ACE_Time_Value (0, ul - 1); + min_pending_ = ACE_Time_Value (0, ul); +} + // set offset for boundary between signed range and unsigned range + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Dynamic_Service.cpp b/dep/ACE_wrappers/ace/Dynamic_Service.cpp new file mode 100644 index 00000000000..28d6e4526f2 --- /dev/null +++ b/dep/ACE_wrappers/ace/Dynamic_Service.cpp @@ -0,0 +1,63 @@ +// $Id: Dynamic_Service.cpp 80826 2008-03-04 14:51:23Z wotte $ + +#ifndef ACE_DYNAMIC_SERVICE_CPP +#define ACE_DYNAMIC_SERVICE_CPP + +#include "ace/Dynamic_Service.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/Service_Object.h" + +#if !defined (__ACE_INLINE__) +#include "ace/Dynamic_Service.inl" +#endif /* __ACE_INLINE__ */ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + + +template TYPE * +ACE_Dynamic_Service::instance (const ACE_TCHAR *name) +{ + ACE_Service_Object * svc_obj = + static_cast + (ACE_Dynamic_Service_Base::instance (name,false)); + return dynamic_cast (svc_obj); +} + +template TYPE * +ACE_Dynamic_Service::instance (const ACE_TCHAR *name, + bool no_global) +{ + ACE_Service_Object * svc_obj = + static_cast + (ACE_Dynamic_Service_Base::instance (name, no_global)); + return dynamic_cast (svc_obj); +} + +template TYPE * +ACE_Dynamic_Service::instance (const ACE_Service_Gestalt* conf, + const ACE_TCHAR *name) +{ + ACE_Service_Object * svc_obj = + static_cast + (ACE_Dynamic_Service_Base::instance (conf, name, false)); + return dynamic_cast (svc_obj); +} + +template TYPE * +ACE_Dynamic_Service::instance (const ACE_Service_Gestalt* conf, + const ACE_TCHAR *name, + bool no_global) +{ + ACE_Service_Object * svc_obj = + static_cast + (ACE_Dynamic_Service_Base::instance (conf, name, no_global)); + return dynamic_cast (svc_obj); +} + +ACE_END_VERSIONED_NAMESPACE_DECL + +#endif /* ACE_DYNAMIC_SERVICE_CPP */ diff --git a/dep/ACE_wrappers/ace/Dynamic_Service.h b/dep/ACE_wrappers/ace/Dynamic_Service.h new file mode 100644 index 00000000000..b90095c766d --- /dev/null +++ b/dep/ACE_wrappers/ace/Dynamic_Service.h @@ -0,0 +1,89 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Dynamic_Service.h + * + * $Id: Dynamic_Service.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Prashant Jain + * @author Douglas C. Schmidt + */ +//============================================================================= + +#ifndef ACE_DYNAMIC_SERVICE_H +#define ACE_DYNAMIC_SERVICE_H + +#include /**/ "ace/pre.h" + +#include /**/ "ace/config-all.h" +#include "ace/Global_Macros.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/Dynamic_Service_Base.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +class ACE_Service_Object; + +/** + * @class ACE_Dynamic_Service + * + * @brief Provides a general interface to retrieve arbitrary objects + * from the ACE service repository. + * + * Uses "name" for lookup in the ACE service repository. Obtains + * the object and returns it as the appropriate type. + */ +template +class ACE_Dynamic_Service : public ACE_Dynamic_Service_Base +{ +public: + /// Return instance using @a name to search the Service_Repository. + static TYPE* instance (const ACE_TCHAR *name); + static TYPE* instance (const ACE_TCHAR *name, bool no_global); + + static TYPE* instance (const ACE_Service_Gestalt* repo, + const ACE_TCHAR *name); + static TYPE* instance (const ACE_Service_Gestalt* repo, + const ACE_TCHAR *name, bool no_global); + +#if defined (ACE_USES_WCHAR) + + /// Return instance using @a name to search the Service_Repository. + static TYPE* instance (const ACE_ANTI_TCHAR *name); + + static TYPE* instance (const ACE_ANTI_TCHAR *name, bool no_global); + + static TYPE* instance (const ACE_Service_Gestalt* repo, + const ACE_ANTI_TCHAR *name); + static TYPE* instance (const ACE_Service_Gestalt* repo, + const ACE_ANTI_TCHAR *name, bool no_global); +#endif // ACE_USES_WCHAR + +private: + ACE_UNIMPLEMENTED_FUNC (ACE_Dynamic_Service ()) + ACE_UNIMPLEMENTED_FUNC (ACE_Dynamic_Service (const ACE_Dynamic_Service&)) + ACE_UNIMPLEMENTED_FUNC (ACE_Dynamic_Service& operator= (const ACE_Dynamic_Service&)) +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +#include "ace/Dynamic_Service.inl" +#endif /* __ACE_INLINE__ */ + +#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) +# include "ace/Dynamic_Service.cpp" +#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ + +#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) +# pragma implementation ("Dynamic_Service.cpp") +#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ + +#include /**/ "ace/post.h" + +#endif /* ACE_DYNAMIC_SERVICE_H */ diff --git a/dep/ACE_wrappers/ace/Dynamic_Service.inl b/dep/ACE_wrappers/ace/Dynamic_Service.inl new file mode 100644 index 00000000000..31324bf535b --- /dev/null +++ b/dep/ACE_wrappers/ace/Dynamic_Service.inl @@ -0,0 +1,39 @@ +// -*- C++ -*- +// +// $Id: Dynamic_Service.inl 81318 2008-04-10 10:12:05Z johnnyw $ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +#if defined (ACE_USES_WCHAR) + +template ACE_INLINE TYPE * +ACE_Dynamic_Service::instance (const ACE_ANTI_TCHAR *name) +{ + return instance (ACE_TEXT_CHAR_TO_TCHAR (name),false); +} + +template ACE_INLINE TYPE * +ACE_Dynamic_Service::instance (const ACE_ANTI_TCHAR *name, + bool no_global) +{ + return instance (ACE_TEXT_CHAR_TO_TCHAR (name),no_global); +} + +template ACE_INLINE TYPE * +ACE_Dynamic_Service::instance (const ACE_Service_Gestalt* repo, + const ACE_ANTI_TCHAR *name) +{ + return instance (repo, ACE_TEXT_CHAR_TO_TCHAR (name),false); +} + +template ACE_INLINE TYPE * +ACE_Dynamic_Service::instance (const ACE_Service_Gestalt* repo, + const ACE_ANTI_TCHAR *name, + bool no_global) +{ + return instance (repo, ACE_TEXT_CHAR_TO_TCHAR (name),no_global); +} + +#endif // ACE_USES_WCHAR + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Dynamic_Service_Base.cpp b/dep/ACE_wrappers/ace/Dynamic_Service_Base.cpp new file mode 100644 index 00000000000..91eec162ce0 --- /dev/null +++ b/dep/ACE_wrappers/ace/Dynamic_Service_Base.cpp @@ -0,0 +1,101 @@ +#include "ace/Dynamic_Service_Base.h" +#include "ace/ACE.h" +#include "ace/Service_Config.h" +#include "ace/Service_Repository.h" +#include "ace/Service_Types.h" +#include "ace/Log_Msg.h" + + +ACE_RCSID (ace, + Dynamic_Service_Base, + "$Id: Dynamic_Service_Base.cpp 80826 2008-03-04 14:51:23Z wotte $") + + ACE_BEGIN_VERSIONED_NAMESPACE_DECL + + +void +ACE_Dynamic_Service_Base::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + ACE_TRACE ("ACE_Dynamic_Service_Base::dump"); + + ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\n"))); + ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); +#endif /* ACE_HAS_DUMP */ +} + +// Get the instance using for the current global +// service configuration repository. + +void * +ACE_Dynamic_Service_Base::instance (const ACE_TCHAR *name, bool no_global) +{ + ACE_TRACE ("ACE_Dynamic_Service_Base::instance"); + return instance (ACE_Service_Config::current (), name, no_global); +} + +// Find a service registration + +const ACE_Service_Type * +ACE_Dynamic_Service_Base::find_i (const ACE_Service_Gestalt* &repo, + const ACE_TCHAR *name, + bool no_global) +{ + ACE_TRACE ("ACE_Dynamic_Service_Base::find_i"); + const ACE_Service_Type *svc_rec = 0; + + ACE_Service_Gestalt* global = ACE_Service_Config::global (); + + for ( ; (repo->find (name, &svc_rec) == -1) && !no_global; repo = global) + { + // Check the static repo, too if different + if (repo == global) + break; + } + + return svc_rec; +} + + +// Get the instance using for specific configuration repository. +void * +ACE_Dynamic_Service_Base::instance (const ACE_Service_Gestalt* repo, + const ACE_TCHAR *name, + bool no_global) +{ + ACE_TRACE ("ACE_Dynamic_Service_Base::instance"); + + void *obj = 0; + const ACE_Service_Type_Impl *type = 0; + + const ACE_Service_Gestalt* repo_found = repo; + const ACE_Service_Type *svc_rec = find_i (repo_found, name, no_global); + if (svc_rec != 0) + { + type = svc_rec->type (); + if (type != 0) + obj = type->object (); + } + + if (ACE::debug ()) + { + ACE_Guard log_guard (*ACE_Log_Msg::instance ()); + + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("ACE (%P|%t) DSB::instance, repo=%@, name=%s") + ACE_TEXT (" type=%@ => %@"), + repo->repo_, name, type, obj)); + + if (repo->repo_ != repo_found->repo_) + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT (" [in repo=%@]\n"), + repo_found->repo_)); + else + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\n"))); + } + + return obj; +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Dynamic_Service_Base.h b/dep/ACE_wrappers/ace/Dynamic_Service_Base.h new file mode 100644 index 00000000000..095e883a8fe --- /dev/null +++ b/dep/ACE_wrappers/ace/Dynamic_Service_Base.h @@ -0,0 +1,74 @@ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file Dynamic_Service_Base.h + * + * $Id: Dynamic_Service_Base.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Prashant Jain + * @author Douglas C. Schmidt + */ +//============================================================================= + +#ifndef ACE_DYNAMIC_SERVICE_BASE_H +#define ACE_DYNAMIC_SERVICE_BASE_H + +#include /**/ "ace/pre.h" + +#include /**/ "ace/ACE_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +class ACE_Service_Gestalt; +class ACE_Service_Type; + +/** + * @class ACE_Dynamic_Service_Base + * + * @brief Base class for all ACE_Dynamic_Service instantiations. + * + * Factors out common code shared by all ACE_Dynamic_Service + * instantiations, this avoid code bloat. + */ +class ACE_Export ACE_Dynamic_Service_Base +{ + +public: + /// Dump the current static of the object + void dump (void) const; + +protected: + /// Perform the default repo search, but optionally skip searching the global + /// repo. + static void* instance (const ACE_TCHAR *name, bool no_global = false); + + static void* instance (const ACE_Service_Gestalt* repo, + const ACE_TCHAR *name, + bool no_global = false); + + /// No need to create, or assign instances of this class + ACE_Dynamic_Service_Base (void); + ~ACE_Dynamic_Service_Base (void); + const ACE_Dynamic_Service_Base& operator= (const ACE_Dynamic_Service_Base&); + +private: + /// Implement the service search policy, i.e. "look for the service first + /// locally and then globally" + static const ACE_Service_Type *find_i (const ACE_Service_Gestalt* &repo, + const ACE_TCHAR *name, + bool no_global); + + /// The dependency declaration class needs access to the service search + /// policy, implemented by find_i() + friend class ACE_Dynamic_Service_Dependency; +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#include /**/ "ace/post.h" +#endif /* ACE_DYNAMIC_SERVICE_BASE_H */ diff --git a/dep/ACE_wrappers/ace/Dynamic_Service_Dependency.cpp b/dep/ACE_wrappers/ace/Dynamic_Service_Dependency.cpp new file mode 100644 index 00000000000..df7cd0f5d48 --- /dev/null +++ b/dep/ACE_wrappers/ace/Dynamic_Service_Dependency.cpp @@ -0,0 +1,51 @@ +#include "ace/ACE.h" +#include "ace/DLL_Manager.h" +#include "ace/Dynamic_Service_Dependency.h" +#include "ace/Service_Config.h" +#include "ace/Log_Msg.h" + +ACE_RCSID (ace, + Dynamic_Service_Dependency, + "$Id: Dynamic_Service_Dependency.cpp 80826 2008-03-04 14:51:23Z wotte $") + + + ACE_BEGIN_VERSIONED_NAMESPACE_DECL + + +ACE_Dynamic_Service_Dependency::ACE_Dynamic_Service_Dependency (const ACE_TCHAR *principal) +{ + this->init (ACE_Service_Config::current (), principal); +} + +ACE_Dynamic_Service_Dependency::ACE_Dynamic_Service_Dependency (const ACE_Service_Gestalt *cfg, + const ACE_TCHAR *principal) +{ + this->init (cfg, principal); +} + + +ACE_Dynamic_Service_Dependency::~ACE_Dynamic_Service_Dependency (void) +{ + if (ACE::debug ()) + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("(%P|%t) DSD, this=%@ - destroying\n"), + this)); +} + +void +ACE_Dynamic_Service_Dependency::init (const ACE_Service_Gestalt *cfg, + const ACE_TCHAR *principal) +{ + const ACE_Service_Type* st = + ACE_Dynamic_Service_Base::find_i (cfg, principal,false); + if (ACE::debug ()) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("(%P|%t) DSD, this=%@ - creating dependency on "), this)); + st->dump (); + } + this->tracker_ = st->dll (); +} + + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Dynamic_Service_Dependency.h b/dep/ACE_wrappers/ace/Dynamic_Service_Dependency.h new file mode 100644 index 00000000000..0f187d0037a --- /dev/null +++ b/dep/ACE_wrappers/ace/Dynamic_Service_Dependency.h @@ -0,0 +1,70 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Dynamic_Service_Dependency.h + * + * $Id: Dynamic_Service_Dependency.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Iliyan Jeliazkov + */ +//============================================================================= + +#ifndef ACE_DYNAMIC_SERVICE_DEPENDENCY_H +#define ACE_DYNAMIC_SERVICE_DEPENDENCY_H + +#include /**/ "ace/pre.h" + + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/Dynamic_Service_Base.h" +#include "ace/Service_Object.h" +#include "ace/DLL.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +/** + * @class ACE_Dynamic_Service_Dependency + * + * @brief Provides a way to declare dependency on specific service, + * thus helping to avoid order of initialization issues with instances + * of an objects whose implementation code resides in dynamically loaded + * services. + * + * It is disastrous to have dynamically loadable services create and give away + * ownership of objects and then ending up being unloaded before all those + * instances have been deleted. Normally the code for such objects classes + * resides within the TEXT segment of the DLL, which implements the service. + * If a service gets removed, its DLL may be unmapped from memory and then + * any attempt to invoke a method on the said objects will cause SEGV. + * + * Such instances must contain a member of ACE_Dynamic_Service_Dependency + * initialized with the service they depend on. + * ACE_Dynamic_Service_Dependency's constructor and destructor are + * "magical" - they work by maintaining the underlying dynamic service's + * DLL reference count. + */ +class ACE_Export ACE_Dynamic_Service_Dependency +{ +public: + ACE_Dynamic_Service_Dependency (const ACE_Service_Gestalt *cfg, + const ACE_TCHAR *principal); + ACE_Dynamic_Service_Dependency (const ACE_TCHAR *principal); + ~ACE_Dynamic_Service_Dependency (void); + +private: + void init (const ACE_Service_Gestalt *cfg, const ACE_TCHAR *principal); + +private: + ACE_DLL tracker_; +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + + +#include /**/ "ace/post.h" + +#endif /* ACE_DYNAMIC_SERVICE_DEPENDENCY_H */ diff --git a/dep/ACE_wrappers/ace/Encoding_Converter.cpp b/dep/ACE_wrappers/ace/Encoding_Converter.cpp new file mode 100644 index 00000000000..b5fd2b35402 --- /dev/null +++ b/dep/ACE_wrappers/ace/Encoding_Converter.cpp @@ -0,0 +1,12 @@ +// $Id: Encoding_Converter.cpp 80826 2008-03-04 14:51:23Z wotte $ +#include "ace/Encoding_Converter.h" + +#if defined (ACE_USES_WCHAR) +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_Encoding_Converter::~ACE_Encoding_Converter (void) +{ +} + +ACE_END_VERSIONED_NAMESPACE_DECL +#endif /* ACE_USES_WCHAR */ diff --git a/dep/ACE_wrappers/ace/Encoding_Converter.h b/dep/ACE_wrappers/ace/Encoding_Converter.h new file mode 100644 index 00000000000..34d22fa29a1 --- /dev/null +++ b/dep/ACE_wrappers/ace/Encoding_Converter.h @@ -0,0 +1,70 @@ +// -*- C++ -*- + +//========================================================================= +/** + * @file Encoding_Converter.h + * + * $Id: Encoding_Converter.h 80826 2008-03-04 14:51:23Z wotte $ + * + * This class is the base class for all encoding converters that convert + * to and from UTF-8. + * + * @author Chad Elliott + */ +//========================================================================= + +#ifndef ACE_ENCODING_CONVERTER_H +#define ACE_ENCODING_CONVERTER_H + +#include /**/ "ace/pre.h" + +#include "ace/Basic_Types.h" + +#if defined (ACE_USES_WCHAR) +#include /**/ "ace/ACE_export.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +/** The base class for all ACE UTF Encoding Converters. + * This class provides a generic interface that is used to implement + * various UTF encoding conversion classes. + */ +class ACE_Export ACE_Encoding_Converter +{ +public: + /// This enum describes the various states that can be returned + /// from the to_utf8() and from_utf8() methods which depends on + /// both the source buffer and the size of the target buffer. + enum Result {CONVERSION_OK, + SOURCE_EXHAUSTED, + TARGET_EXHAUSTED, + SOURCE_ILLEGAL + }; + + /// This destructor is here (and virtual) because we have virtual + /// functions. + virtual ~ACE_Encoding_Converter (void); + + /// Convert the source (which can be in any encoding) to UTF-8 and + /// store it in the provided target buffer. + virtual Result to_utf8 (const void* source, + size_t source_size, + ACE_Byte* target, + size_t target_size, + bool strict = true) = 0; + + /// Convert the UTF-8 source into an alternate encoding and store it + /// in the provided target buffer. + virtual Result from_utf8 (const ACE_Byte* source, + size_t source_size, + void* target, + size_t target_size, + bool strict = true) = 0; +}; + +ACE_END_VERSIONED_NAMESPACE_DECL +#endif /* ACE_USES_WCHAR */ + +#include /**/ "ace/post.h" + +#endif /* ACE_ENCODING_CONVERTER_H */ diff --git a/dep/ACE_wrappers/ace/Encoding_Converter_Factory.cpp b/dep/ACE_wrappers/ace/Encoding_Converter_Factory.cpp new file mode 100644 index 00000000000..f603ae3e893 --- /dev/null +++ b/dep/ACE_wrappers/ace/Encoding_Converter_Factory.cpp @@ -0,0 +1,74 @@ +// $Id: Encoding_Converter_Factory.cpp 80826 2008-03-04 14:51:23Z wotte $ +#include "ace/Encoding_Converter_Factory.h" + +#if defined (ACE_USES_WCHAR) +#include "ace/UTF32_Encoding_Converter.h" +#include "ace/UTF16_Encoding_Converter.h" +#include "ace/UTF8_Encoding_Converter.h" +#include "ace/OS_Memory.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_Encoding_Converter* +ACE_Encoding_Converter_Factory::create ( + const ACE_Byte* source, + size_t source_size, + ACE_Encoding_Converter_Factory::Encoding_Hint hint) +{ +#if defined (ACE_BIG_ENDIAN) + bool const convert_for_bigendian = true; +#else + bool const convert_for_bigendian = false; +#endif /* ACE_BIG_ENDIAN */ + ACE_Encoding_Converter* converter = 0; + + switch (hint) + { + case ACE_UTF_32BE: + ACE_NEW_RETURN (converter, + ACE_UTF32_Encoding_Converter (!convert_for_bigendian), + 0); + break; + case ACE_UTF_32LE: + ACE_NEW_RETURN (converter, + ACE_UTF32_Encoding_Converter (convert_for_bigendian), + 0); + break; + case ACE_UTF_16BE: + ACE_NEW_RETURN (converter, + ACE_UTF16_Encoding_Converter (!convert_for_bigendian), + 0); + break; + case ACE_UTF_16LE: + ACE_NEW_RETURN (converter, + ACE_UTF16_Encoding_Converter (convert_for_bigendian), + 0); + break; + case ACE_UTF_8: + ACE_NEW_RETURN (converter, + ACE_UTF8_Encoding_Converter, + 0); + break; + default: + // First check for ASCII since much of ASCII text will appear to + // convert from UTF-16 to UTF-8. + converter = ACE_UTF8_Encoding_Converter::encoded (source, source_size); + if (converter != 0) + return converter; + + // Check for UTF-32 + converter = ACE_UTF32_Encoding_Converter::encoded (source, source_size); + if (converter != 0) + return converter; + + // Check for UTF-16 + converter = ACE_UTF16_Encoding_Converter::encoded (source, source_size); + if (converter != 0) + return converter; + } + + return converter; +} + +ACE_END_VERSIONED_NAMESPACE_DECL +#endif /* ACE_USES_WCHAR */ diff --git a/dep/ACE_wrappers/ace/Encoding_Converter_Factory.h b/dep/ACE_wrappers/ace/Encoding_Converter_Factory.h new file mode 100644 index 00000000000..1441c690bef --- /dev/null +++ b/dep/ACE_wrappers/ace/Encoding_Converter_Factory.h @@ -0,0 +1,54 @@ +// -*- C++ -*- + +//========================================================================= +/** + * @file Encoding_Converter_Factory.h + * + * $Id: Encoding_Converter_Factory.h 80826 2008-03-04 14:51:23Z wotte $ + * + * This class can be used to create encoding converters of various types. + * + * @author Chad Elliott + */ +//========================================================================= + +#ifndef ACE_ENCODING_CONVERTER_FACTORY_H +#define ACE_ENCODING_CONVERTER_FACTORY_H + +#include /**/ "ace/pre.h" + +#include "ace/Basic_Types.h" + +#if defined (ACE_USES_WCHAR) +#include /**/ "ace/ACE_export.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +class ACE_Encoding_Converter; + +/** Create an encoding converter based on the source or hint. + * This class allows users to avoid knowing any concrete converter types. + */ +class ACE_Export ACE_Encoding_Converter_Factory +{ +public: + /// This enum is used to tell what type of converter to create. + enum Encoding_Hint { ACE_UTF_32BE, ACE_UTF_32LE, + ACE_UTF_16BE, ACE_UTF_16LE, + ACE_UTF_8, ACE_NONE + }; + + /// Create an encoding converter based on the source. If a hint is + /// given, it just creates the specified type of converter without looking + /// at the source. + static ACE_Encoding_Converter* create (const ACE_Byte* source, + size_t source_size, + Encoding_Hint hint = ACE_NONE); +}; + +ACE_END_VERSIONED_NAMESPACE_DECL +#endif /* ACE_USES_WCHAR */ + +#include /**/ "ace/post.h" + +#endif /* ACE_ENCODING_CONVERTER_FACTORY_H */ diff --git a/dep/ACE_wrappers/ace/Env_Value_T.cpp b/dep/ACE_wrappers/ace/Env_Value_T.cpp new file mode 100644 index 00000000000..1997bbea484 --- /dev/null +++ b/dep/ACE_wrappers/ace/Env_Value_T.cpp @@ -0,0 +1,12 @@ +// $Id: Env_Value_T.cpp 80826 2008-03-04 14:51:23Z wotte $ + +#ifndef ACE_ENV_VALUE_T_CPP +#define ACE_ENV_VALUE_T_CPP + +#include "ace/Env_Value_T.h" + +#if ! defined (__ACE_INLINE__) +#include "ace/Env_Value_T.inl" +#endif /* __ACE_INLINE__ */ + +#endif /* ACE_ENV_VALUE_T_CPP */ diff --git a/dep/ACE_wrappers/ace/Env_Value_T.h b/dep/ACE_wrappers/ace/Env_Value_T.h new file mode 100644 index 00000000000..df2178a0f11 --- /dev/null +++ b/dep/ACE_wrappers/ace/Env_Value_T.h @@ -0,0 +1,166 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Env_Value_T.h + * + * $Id: Env_Value_T.h 80826 2008-03-04 14:51:23Z wotte $ + * + * Template to encapsulate getting a value from an environment variable + * and using a supplied default value if not in the environment. + * + * + * @author Chris Cleeland (derived from work by Carlos O'Ryan) + */ +//============================================================================= + +#ifndef ACE_ENV_VALUE_T_H +#define ACE_ENV_VALUE_T_H + +#include /**/ "ace/pre.h" + +#include /**/ "ace/config-all.h" +#include "ace/Global_Macros.h" +#include "ace/OS_NS_stdlib.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +/** + * @class ACE_Env_Value + * + * @brief Environment Variable Value + * + * Reads a variable from the user environment, providing a default + * value. + */ +template +class ACE_Env_Value +{ +public: + /** + * Default constructor which isn't bound to a specific environment + * variable name or a default value. Before being useful it must + * 'd. + */ + ACE_Env_Value (void); + + /// Constructor that calls . + ACE_Env_Value (const ACE_TCHAR *varname, + const T &vardefault); + + /// Destroy the value. + ~ACE_Env_Value (void); + + /// Returns the value as type T. + operator T (void); + + /// The constructor, read @a varname from the environment, using + /// @a defval as its value if it is not defined. + void open (const ACE_TCHAR *varname, const T &defval); + + /// Returns the name of the variable being tracked. + const ACE_TCHAR *varname (void) const; + +private: + /// Disallow copying and assignment. + ACE_UNIMPLEMENTED_FUNC (ACE_Env_Value(const ACE_Env_Value &)) + ACE_UNIMPLEMENTED_FUNC (ACE_Env_Value operator=(const ACE_Env_Value &)) + + void fetch_value (void); + + const ACE_TCHAR *varname_; + T value_; +}; + +/// Function to convert a string @a s into type @c T. +template void ACE_Convert (const ACE_TCHAR *s, T &t); + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +#include "ace/Env_Value_T.inl" +#endif /* __ACE_INLINE__ */ + +#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) +#include "ace/Env_Value_T.cpp" +#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +template <> inline void +ACE_Convert (const ACE_TCHAR *s, ACE_TCHAR *&v) +{ + v = (ACE_TCHAR *) s; +} + +template <> inline void +ACE_Convert (const ACE_TCHAR *s, const ACE_TCHAR *&v) +{ + v = (const ACE_TCHAR *) s; +} + +template <> inline void +ACE_Convert (const ACE_TCHAR *s, short &si) +{ + si = static_cast (ACE_OS::strtol (s, 0, 10)); +} + +template <> inline void +ACE_Convert (const ACE_TCHAR *s, u_short &us) +{ + us = static_cast (ACE_OS::strtol (s, 0, 10)); +} + +template <> inline void +ACE_Convert (const ACE_TCHAR *s, u_int &i) +{ + i = static_cast (ACE_OS::strtol (s, 0, 10)); +} + +template <> inline void +ACE_Convert (const ACE_TCHAR *s, long &l) +{ + l = ACE_OS::strtol (s, 0, 10); +} + +template <> inline void +ACE_Convert (const ACE_TCHAR *s, int &i) +{ + i = static_cast (ACE_OS::strtol (s, 0, 10)); +} + +template <> inline void +ACE_Convert (const ACE_TCHAR *s, u_long &ul) +{ + ul = ACE_OS::strtoul (s, 0, 10); +} + +template <> inline void +ACE_Convert (const ACE_TCHAR *s, double &d) +{ + d = ACE_OS::strtod (s, 0); +} + +// Default calls a CTOR on type T of the form 'T::T(const char*)', but +// users can feel free to create their own specialized conversion +// functions if necessary, as shown above. Note that for 'char*' the +// default is used because a simple cast will be performed and no +// conversion will be necessary. +template inline void +ACE_Convert (const ACE_TCHAR *s, T &t) +{ + t = T (s); +} + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) +#pragma implementation ("Env_Value_T.cpp") +#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ + +#include /**/ "ace/post.h" +#endif /* ACE_ENV_VALUE_T_H */ diff --git a/dep/ACE_wrappers/ace/Env_Value_T.inl b/dep/ACE_wrappers/ace/Env_Value_T.inl new file mode 100644 index 00000000000..d9af1b03164 --- /dev/null +++ b/dep/ACE_wrappers/ace/Env_Value_T.inl @@ -0,0 +1,60 @@ +// $Id: Env_Value_T.inl 80826 2008-03-04 14:51:23Z wotte $ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +template ACE_INLINE +ACE_Env_Value::operator T (void) +{ + return value_; +} + +template ACE_INLINE +ACE_Env_Value::ACE_Env_Value (void) + : varname_ (0) +{ +} + +template ACE_INLINE +ACE_Env_Value::ACE_Env_Value (const ACE_TCHAR *varname, + const T &defval) + : varname_ (varname), + value_(defval) +{ + this->fetch_value (); +} + +template ACE_INLINE void +ACE_Env_Value::open (const ACE_TCHAR *varname, + const T &defval) +{ + this->varname_ = varname; + this->value_ = defval; + this->fetch_value (); +} + +template ACE_INLINE void +ACE_Env_Value::fetch_value (void) +{ +#if defined (ACE_WIN32) + const ACE_TCHAR *env = ACE_OS::getenv (this->varname_); + if (env != 0) + ACE_Convert (env, value_); +#else + char *nenv = ACE_OS::getenv (ACE_TEXT_ALWAYS_CHAR (this->varname_)); + if (nenv != 0) + ACE_Convert (ACE_TEXT_CHAR_TO_TCHAR (nenv), this->value_); +#endif +} + +template ACE_INLINE const ACE_TCHAR* +ACE_Env_Value::varname (void) const +{ + return this->varname_; +} + +template ACE_INLINE +ACE_Env_Value::~ACE_Env_Value (void) +{ +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Event.cpp b/dep/ACE_wrappers/ace/Event.cpp new file mode 100644 index 00000000000..ea5f86d99d1 --- /dev/null +++ b/dep/ACE_wrappers/ace/Event.cpp @@ -0,0 +1,93 @@ +// $Id: Event.cpp 80826 2008-03-04 14:51:23Z wotte $ + +#include "ace/Event.h" + +#if !defined (__ACE_INLINE__) +#include "ace/Event.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/Log_Msg.h" + +ACE_RCSID(ace, Event, "$Id: Event.cpp 80826 2008-03-04 14:51:23Z wotte $") + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_Event::ACE_Event (int manual_reset, + int initial_state, + int type, + const ACE_TCHAR *name, + void *arg, + LPSECURITY_ATTRIBUTES sa) + : removed_ (false) +{ + if (ACE_OS::event_init (&this->handle_, + manual_reset, + initial_state, + type, + name, + arg, + sa) != 0) + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("%p\n"), + ACE_TEXT ("ACE_Event::ACE_Event"))); +} + +ACE_Event::~ACE_Event (void) +{ + this->remove (); +} + +int +ACE_Event::remove (void) +{ + int result = 0; + if (!this->removed_) + { + this->removed_ = true; + result = ACE_OS::event_destroy (&this->handle_); + } + return result; +} + +int +ACE_Event::wait (void) +{ + return ACE_OS::event_wait (&this->handle_); +} + +int +ACE_Event::wait (const ACE_Time_Value *abstime, int use_absolute_time) +{ + return ACE_OS::event_timedwait (&this->handle_, + const_cast (abstime), + use_absolute_time); +} + +int +ACE_Event::signal (void) +{ + return ACE_OS::event_signal (&this->handle_); +} + +int +ACE_Event::pulse (void) +{ + return ACE_OS::event_pulse (&this->handle_); +} + +int +ACE_Event::reset (void) +{ + return ACE_OS::event_reset (&this->handle_); +} + +void +ACE_Event::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); + ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); +#endif /* ACE_HAS_DUMP */ +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Event.h b/dep/ACE_wrappers/ace/Event.h new file mode 100644 index 00000000000..887b504d8f9 --- /dev/null +++ b/dep/ACE_wrappers/ace/Event.h @@ -0,0 +1,143 @@ +// -*- C++ -*- + +//========================================================================== +/** + * @file Event.h + * + * $Id: Event.h 80826 2008-03-04 14:51:23Z wotte $ + * + * Moved from Synch.h. + * + * @author Douglas C. Schmidt + */ +//========================================================================== + +#ifndef ACE_EVENT_H +#define ACE_EVENT_H +#include /**/ "ace/pre.h" + +#include /**/ "ace/ACE_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/OS_NS_Thread.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +/** + * @class ACE_Event + * + * @brief A wrapper around the Win32 event locking mechanism. + * + * Portable implementation of an Event mechanism, which is native to + * Win32, but must be emulated on UNIX. All platforms support + * process-scope locking support. However, only Win32 platforms + * support global naming and system-scope locking support. + */ +class ACE_Export ACE_Event +{ +public: + /// Constructor that creates event. + ACE_Event (int manual_reset = 0, + int initial_state = 0, + int type = USYNC_THREAD, + const ACE_TCHAR *name = 0, + void *arg = 0, + LPSECURITY_ATTRIBUTES sa = 0); + + /// Implicitly destroy the event variable. + ~ACE_Event (void); + + /** + * Explicitly destroy the event variable. Note that only one thread + * should call this method since it doesn't protect against race + * conditions. + */ + int remove (void); + + /// Underlying handle to event. + ACE_event_t handle (void) const; + + /** + * Set the underlying handle to event. Note that this method assumes + * ownership of the and will close it down in . If + * you want the to stay open when is called make + * sure to call on the before closing it. You are + * responsible for the closing the existing before + * overwriting it. + */ + void handle (ACE_event_t new_handle); + + /** + * if MANUAL reset + * sleep till the event becomes signaled + * event remains signaled after wait() completes. + * else AUTO reset + * sleep till the event becomes signaled + * event resets wait() completes. + */ + int wait (void); + + /// Same as wait() above, but this one can be timed + /// @a abstime is absolute time-of-day if if @a use_absolute_time + /// is non-0, else it is relative time. + int wait (const ACE_Time_Value *abstime, + int use_absolute_time = 1); + + /** + * if MANUAL reset + * wake up all waiting threads + * set to signaled state + * else AUTO reset + * if no thread is waiting, set to signaled state + * if thread(s) are waiting, wake up one waiting thread and + * reset event + */ + int signal (void); + + /** + * if MANUAL reset + * wakeup all waiting threads and + * reset event + * else AUTO reset + * wakeup one waiting thread (if present) and + * reset event + */ + int pulse (void); + + /// Set to nonsignaled state. + int reset (void); + + /// Dump the state of an object. + void dump (void) const; + + /// Declare the dynamic allocation hooks + ACE_ALLOC_HOOK_DECLARE; + +protected: + /// The underlying handle. + ACE_event_t handle_; + + /// Keeps track of whether has been called yet to avoid + /// multiple calls, e.g., explicitly and implicitly in the + /// destructor. This flag isn't protected by a lock, so make sure + /// that you don't have multiple threads simultaneously calling + /// on the same object, which is a bad idea anyway... + bool removed_; + +private: + // = Prevent copying. + ACE_Event (const ACE_Event& event); + const ACE_Event &operator= (const ACE_Event &rhs); +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +#include "ace/Event.inl" +#endif /* __ACE_INLINE__ */ + +#include /**/ "ace/post.h" +#endif /* ACE_EVENT_H */ diff --git a/dep/ACE_wrappers/ace/Event.inl b/dep/ACE_wrappers/ace/Event.inl new file mode 100644 index 00000000000..ae0805c95f0 --- /dev/null +++ b/dep/ACE_wrappers/ace/Event.inl @@ -0,0 +1,18 @@ +// -*- C++ -*- +// $Id: Event.inl 80826 2008-03-04 14:51:23Z wotte $ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_INLINE ACE_event_t +ACE_Event::handle (void) const +{ + return this->handle_; +} + +ACE_INLINE void +ACE_Event::handle (ACE_event_t new_handle) +{ + this->handle_ = new_handle; +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Event_Handler.cpp b/dep/ACE_wrappers/ace/Event_Handler.cpp new file mode 100644 index 00000000000..9e0a10e6ac7 --- /dev/null +++ b/dep/ACE_wrappers/ace/Event_Handler.cpp @@ -0,0 +1,396 @@ +// Event_Handler.cpp +// $Id: Event_Handler.cpp 80826 2008-03-04 14:51:23Z wotte $ + +#include "ace/Event_Handler.h" +#include "ace/OS_Errno.h" +#include "ace/Reactor.h" +#include "ace/Thread_Manager.h" +/* Need to see if ACE_HAS_BUILTIN_ATOMIC_OP defined */ +#include "ace/Atomic_Op.h" + +#if !defined (__ACE_INLINE__) +#include "ace/Event_Handler.inl" +#endif /* __ACE_INLINE__ */ + +#include + +ACE_RCSID(ace, Event_Handler, "$Id: Event_Handler.cpp 80826 2008-03-04 14:51:23Z wotte $") + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +// Implement conceptually abstract virtual functions in the base class +// so derived classes don't have to implement unused ones. + +ACE_Event_Handler::ACE_Event_Handler (ACE_Reactor *r, + int p) + : reference_count_ (1), + priority_ (p), + reactor_ (r), + reference_counting_policy_ (Reference_Counting_Policy::DISABLED) +{ + // ACE_TRACE ("ACE_Event_Handler::ACE_Event_Handler"); +} + +ACE_Event_Handler::~ACE_Event_Handler (void) +{ + // ACE_TRACE ("ACE_Event_Handler::~ACE_Event_Handler"); +} + +// Gets the file descriptor associated with this I/O device. + +ACE_HANDLE +ACE_Event_Handler::get_handle (void) const +{ + ACE_TRACE ("ACE_Event_Handler::get_handle"); + return ACE_INVALID_HANDLE; +} + +// Sets the file descriptor associated with this I/O device. + +void +ACE_Event_Handler::set_handle (ACE_HANDLE) +{ + ACE_TRACE ("ACE_Event_Handler::set_handle"); +} + +// Gets the priority of this handler. + +int +ACE_Event_Handler::priority (void) const +{ + ACE_TRACE ("ACE_Event_Handler::priority"); + return this->priority_; +} + +// Sets the priority + +void +ACE_Event_Handler::priority (int priority) +{ + ACE_TRACE ("ACE_Event_Handler::priority"); + this->priority_ = priority; +} + +// Called when the object is about to be removed from the Dispatcher +// tables. + +int +ACE_Event_Handler::handle_close (ACE_HANDLE, ACE_Reactor_Mask) +{ + ACE_TRACE ("ACE_Event_Handler::handle_close"); + return -1; +} + +// Called when input becomes available on fd. + +int +ACE_Event_Handler::handle_input (ACE_HANDLE) +{ + ACE_TRACE ("ACE_Event_Handler::handle_input"); + return -1; +} + +// Called when output is possible on fd. + +int +ACE_Event_Handler::handle_output (ACE_HANDLE) +{ + ACE_TRACE ("ACE_Event_Handler::handle_output"); + return -1; +} + +// Called when urgent data is available on fd. + +int +ACE_Event_Handler::handle_exception (ACE_HANDLE) +{ + ACE_TRACE ("ACE_Event_Handler::handle_exception"); + return -1; +} + +// Called when timer expires, TV stores the current time. + +int +ACE_Event_Handler::handle_timeout (const ACE_Time_Value &, const void *) +{ + ACE_TRACE ("ACE_Event_Handler::handle_timeout"); + return -1; +} + +// Called when a monitored Process exits + +int +ACE_Event_Handler::handle_exit (ACE_Process *) +{ + ACE_TRACE ("ACE_Event_Handler::handle_exit"); + return -1; +} + +// Called when a registered signal occurs. + +int +ACE_Event_Handler::handle_signal (int, siginfo_t *, ucontext_t *) +{ + ACE_TRACE ("ACE_Event_Handler::handle_signal"); + return -1; +} + +int +ACE_Event_Handler::resume_handler (void) +{ + ACE_TRACE ("ACE_Event_Handler::resume_handler"); + + // Return a default value and allow the reactor to take care of + // resuming the handler + return ACE_Event_Handler::ACE_REACTOR_RESUMES_HANDLER; +} + + +int +ACE_Event_Handler::handle_qos (ACE_HANDLE) +{ + ACE_TRACE ("ACE_Event_Handler::handle_qos"); + return -1; +} + +int +ACE_Event_Handler::handle_group_qos (ACE_HANDLE) +{ + ACE_TRACE ("ACE_Event_Handler::handle_group_qos"); + return -1; +} + +void +ACE_Event_Handler::reactor (ACE_Reactor *reactor) +{ + ACE_TRACE ("ACE_Event_Handler::reactor"); + this->reactor_ = reactor; +} + +ACE_Reactor * +ACE_Event_Handler::reactor (void) const +{ + ACE_TRACE ("ACE_Event_Handler::reactor"); + return this->reactor_; +} + +ACE_Reactor_Timer_Interface * +ACE_Event_Handler::reactor_timer_interface (void) const +{ + ACE_TRACE ("ACE_Event_Handler::reactor_timer_interface"); + return this->reactor_; +} + +ACE_Event_Handler::Reference_Count +ACE_Event_Handler::add_reference (void) +{ + bool const reference_counting_required = + this->reference_counting_policy ().value () == + ACE_Event_Handler::Reference_Counting_Policy::ENABLED; + + if (reference_counting_required) + return ++this->reference_count_; + else + return 1; +} + +ACE_Event_Handler::Reference_Count +ACE_Event_Handler::remove_reference (void) +{ + bool const reference_counting_required = + this->reference_counting_policy ().value () == + ACE_Event_Handler::Reference_Counting_Policy::ENABLED; + + if (reference_counting_required) + { + Reference_Count result = + --this->reference_count_; + + if (result == 0) + delete this; + + return result; + } + else + { + return 1; + } +} + +ACE_Event_Handler::Policy::~Policy (void) +{ +} + +ACE_Event_Handler::Reference_Counting_Policy::Reference_Counting_Policy (Reference_Counting_Policy::Value value) + : value_ (value) +{ +} + +ACE_Event_Handler::Reference_Counting_Policy::Value +ACE_Event_Handler::Reference_Counting_Policy::value (void) const +{ + return this->value_; +} + +void +ACE_Event_Handler::Reference_Counting_Policy::value (ACE_Event_Handler::Reference_Counting_Policy::Value value) +{ + this->value_ = value; +} + +ACE_Event_Handler::Reference_Counting_Policy & +ACE_Event_Handler::reference_counting_policy (void) +{ + return this->reference_counting_policy_; +} + +//#if !defined (ACE_HAS_WINCE) + +ACE_THR_FUNC_RETURN +ACE_Event_Handler::read_adapter (void *args) +{ + ACE_Event_Handler *this_ptr = static_cast (args); + ACE_Reactor *r = this_ptr->reactor (); + + while (this_ptr->handle_input (ACE_STDIN) != -1) + continue; + + this_ptr->handle_close (ACE_STDIN, ACE_Event_Handler::READ_MASK); + // It's possible for handle_close() to "delete this" so we need to + // cache the reactor pointer and use it here. + r->notify (); + + return 0; +} + +int +ACE_Event_Handler::register_stdin_handler (ACE_Event_Handler *eh, + ACE_Reactor *reactor, + ACE_Thread_Manager *thr_mgr, + int flags) +{ +#if defined (ACE_WIN32) + ACE_UNUSED_ARG (reactor); + + eh->reactor (reactor); + return thr_mgr->spawn (&read_adapter, static_cast (eh), flags); +#else + // Keep compilers happy. + ACE_UNUSED_ARG (flags); + ACE_UNUSED_ARG (thr_mgr); + return reactor->register_handler (ACE_STDIN, + eh, + ACE_Event_Handler::READ_MASK); +#endif /* ACE_WIN32 */ +} + +int +ACE_Event_Handler::remove_stdin_handler (ACE_Reactor *reactor, + ACE_Thread_Manager * /* thr_mgr */) +{ +#if defined (ACE_WIN32) + ACE_UNUSED_ARG (reactor); + + // What should we do here? + ACE_NOTSUP_RETURN (-1); +#else + return reactor->remove_handler (ACE_STDIN, + ACE_Event_Handler::READ_MASK); +#endif /* ACE_WIN32 */ +} + +//#endif /* ACE_HAS_WINCE */ + +// --------------------------------------------------------------------- + +ACE_Event_Handler_var::ACE_Event_Handler_var (void) + : ptr_ (0) +{ +} + +ACE_Event_Handler_var::ACE_Event_Handler_var (ACE_Event_Handler *p) + : ptr_ (p) +{ +} + +ACE_Event_Handler_var::ACE_Event_Handler_var (const ACE_Event_Handler_var &b) + : ptr_ (b.ptr_) +{ + if (this->ptr_ != 0) + { + this->ptr_->add_reference (); + } +} + +ACE_Event_Handler_var::~ACE_Event_Handler_var (void) +{ + if (this->ptr_ != 0) + { + ACE_Errno_Guard eguard (errno); + this->ptr_->remove_reference (); + } +} + +ACE_Event_Handler_var & +ACE_Event_Handler_var::operator= (ACE_Event_Handler *p) +{ + if (this->ptr_ != p) + { + ACE_Event_Handler_var tmp (p); + std::swap (this->ptr_, tmp.ptr_); + } + + return *this; +} + +ACE_Event_Handler_var & +ACE_Event_Handler_var::operator= (const ACE_Event_Handler_var &b) +{ + ACE_Event_Handler_var tmp (b); + std::swap (this->ptr_, tmp.ptr_); + + return *this; +} + +ACE_Event_Handler * +ACE_Event_Handler_var::operator->() const +{ + return this->ptr_; +} + +ACE_Event_Handler * +ACE_Event_Handler_var::handler (void) const +{ + return this->ptr_; +} + +ACE_Event_Handler * +ACE_Event_Handler_var::release (void) +{ + ACE_Event_Handler * const old = this->ptr_; + this->ptr_ = 0; + return old; +} + +void +ACE_Event_Handler_var::reset (ACE_Event_Handler *p) +{ + *this = p; +} + +// --------------------------------------------------------------------- + +ACE_Notification_Buffer::ACE_Notification_Buffer (void) +{ + ACE_TRACE ("ACE_Notification_Buffer::ACE_Notification_Buffer"); +} + +ACE_Notification_Buffer::ACE_Notification_Buffer (ACE_Event_Handler *eh, + ACE_Reactor_Mask mask) + : eh_ (eh), + mask_ (mask) +{ + ACE_TRACE ("ACE_Notification_Buffer::ACE_Notification_Buffer"); +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Event_Handler.h b/dep/ACE_wrappers/ace/Event_Handler.h new file mode 100644 index 00000000000..28a762892ad --- /dev/null +++ b/dep/ACE_wrappers/ace/Event_Handler.h @@ -0,0 +1,388 @@ +/* -*- C++ -*- */ + +//========================================================================== +/** + * @file Event_Handler.h + * + * $Id: Event_Handler.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Douglas C. Schmidt + */ +//========================================================================== + +#ifndef ACE_EVENT_HANDLER_H +#define ACE_EVENT_HANDLER_H +#include /**/ "ace/pre.h" + +#include /**/ "ace/ACE_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/os_include/os_signal.h" +#include "ace/Atomic_Op.h" +#include "ace/Synch_Traits.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +// Forward declaration. +class ACE_Message_Block; +class ACE_Reactor; +class ACE_Reactor_Timer_Interface; +class ACE_Thread_Manager; +class ACE_Process; + +typedef unsigned long ACE_Reactor_Mask; + +/** + * @class ACE_Event_Handler + * + * @brief Provides an abstract interface for handling various types of + * I/O, timer, and signal events. + * + * Subclasses read/write input/output on an I/O descriptor, + * handle an exception raised on an I/O descriptor, handle a + * timer's expiration, or handle a signal. + */ +class ACE_Export ACE_Event_Handler +{ +public: + enum + { + LO_PRIORITY = 0, + HI_PRIORITY = 10, + NULL_MASK = 0, +#if defined (ACE_USE_POLL) + READ_MASK = POLLIN, + WRITE_MASK = POLLOUT, + EXCEPT_MASK = POLLPRI, +#else /* USE SELECT */ + READ_MASK = (1 << 0), + WRITE_MASK = (1 << 1), + EXCEPT_MASK = (1 << 2), +#endif /* ACE_USE_POLL */ + ACCEPT_MASK = (1 << 3), + CONNECT_MASK = (1 << 4), + TIMER_MASK = (1 << 5), + QOS_MASK = (1 << 6), + GROUP_QOS_MASK = (1 << 7), + SIGNAL_MASK = (1 << 8), + ALL_EVENTS_MASK = READ_MASK | + WRITE_MASK | + EXCEPT_MASK | + ACCEPT_MASK | + CONNECT_MASK | + TIMER_MASK | + QOS_MASK | + GROUP_QOS_MASK | + SIGNAL_MASK, + RWE_MASK = READ_MASK | + WRITE_MASK | + EXCEPT_MASK, + DONT_CALL = (1 << 9) + }; + + /// Destructor is virtual to enable proper cleanup. + virtual ~ACE_Event_Handler (void); + + /// Get the I/O handle. + virtual ACE_HANDLE get_handle (void) const; + + /// Set the I/O handle. + virtual void set_handle (ACE_HANDLE); + + // = Get/set priority + + // Priorities run from MIN_PRIORITY (which is the "lowest priority") + // to MAX_PRIORITY (which is the "highest priority"). + /// Get the priority of the Event_Handler. + virtual int priority (void) const; + + /// Set the priority of the Event_Handler. + virtual void priority (int priority); + + /// Called when input events occur (e.g., connection or data). + virtual int handle_input (ACE_HANDLE fd = ACE_INVALID_HANDLE); + + /// Called when output events are possible (e.g., when flow control + /// abates or non-blocking connection completes). + virtual int handle_output (ACE_HANDLE fd = ACE_INVALID_HANDLE); + + /// Called when an exceptional events occur (e.g., SIGURG). + virtual int handle_exception (ACE_HANDLE fd = ACE_INVALID_HANDLE); + + /** + * Called when timer expires. @a current_time represents the current + * time that the was selected for timeout + * dispatching and @a act is the asynchronous completion token that + * was passed in when was invoked. + */ + virtual int handle_timeout (const ACE_Time_Value ¤t_time, + const void *act = 0); + + /// Called when a process exits. + virtual int handle_exit (ACE_Process *); + + /// Called when a method returns -1 or when the + /// method is called on an ACE_Reactor. The + /// @a close_mask indicates which event has triggered the + /// method callback on a particular @a handle. + virtual int handle_close (ACE_HANDLE handle, + ACE_Reactor_Mask close_mask); + + /// Called when object is signaled by OS (either via UNIX signals or + /// when a Win32 object becomes signaled). + virtual int handle_signal (int signum, siginfo_t * = 0, ucontext_t * = 0); + + enum + { + /// The handler is not resumed at all. Could lead to deadlock.. + ACE_EVENT_HANDLER_NOT_RESUMED = -1, + /// The reactor takes responsibility of resuming the handler and + /// is the default + ACE_REACTOR_RESUMES_HANDLER = 0, + /// The application takes responsibility of resuming the handler + ACE_APPLICATION_RESUMES_HANDLER + }; + /** + * Called to figure out whether the handler needs to resumed by the + * reactor or the application can take care of it. The default + * value of 0 would be returned which would allow the reactor to + * take care of resumption of the handler. The application can + * return a value more than zero and decide to resume the handler + * themseleves. + * + * @note This method is only useful for the ACE_TP_Reactor. Sad + * that we have to have this method in a class that is supposed to + * be used across different components in ACE. + */ + virtual int resume_handler (void); + + virtual int handle_qos (ACE_HANDLE = ACE_INVALID_HANDLE); + virtual int handle_group_qos (ACE_HANDLE = ACE_INVALID_HANDLE); + + // = Accessors to set/get the various event demultiplexors. + /// Set the event demultiplexors. + virtual void reactor (ACE_Reactor *reactor); + + /// Get the event demultiplexors. + virtual ACE_Reactor *reactor (void) const; + + /// Get only the reactor's timer related interface. + virtual ACE_Reactor_Timer_Interface *reactor_timer_interface (void) const; + + /** + * Used to read from non-socket ACE_HANDLEs in our own thread to + * work around Win32 limitations that don't allow us to 'able on + * Win32. + */ + static int register_stdin_handler (ACE_Event_Handler *eh, + ACE_Reactor *reactor, + ACE_Thread_Manager *thr_mgr, + int flags = THR_DETACHED); + + /// Performs the inverse of the method. + static int remove_stdin_handler (ACE_Reactor *reactor, + ACE_Thread_Manager *thr_mgr); + + /// Reference count type. + typedef long Reference_Count; + + /// Increment reference count on the handler. + /** + * This method is called when the handler is registered with the + * Reactor and when the Reactor makes an upcall on the handler. + * Reference count is 1 when the handler is created. + * + * @return Current reference count. + */ + virtual Reference_Count add_reference (void); + + /// Decrement reference count on the handler. + /** + * This method is called when the handler is removed from the + * Reactor and when an upcall made on the handler by the Reactor + * completes. Handler is deleted when the reference count reaches + * 0. + * + * @return Current reference count. + */ + virtual Reference_Count remove_reference (void); + + /** + * @class Policy + * + * @brief Base class for all handler policies. + */ + class ACE_Export Policy + { + + public: + + /// Virtual destructor. + virtual ~Policy (void); + }; + + /** + * @class Reference_Counting_Policy + * + * @brief This policy dictates the reference counting requirements + * for the handler. + * + * This policy allows applications to configure whether it wants the + * Reactor to call add_reference() and remove_reference() during + * registrations, removals, and upcalls. + * + * Default: DISABLED. + */ + class ACE_Export Reference_Counting_Policy : public Policy + { + /// This policy can only be created by the handler. + friend class ACE_Event_Handler; + + public: + + enum Value + { + /// Perform reference counting. + ENABLED, + /// Don't perform reference counting. + DISABLED + }; + + /// Current Reference_Counting_Policy. + Value value (void) const; + + /// Update Reference_Counting_Policy. + void value (Value value); + + private: + + /// Private constructor. + Reference_Counting_Policy (Value value); + + /// The value of the policy. + Value value_; + }; + + /// Current Reference_Counting_Policy. + Reference_Counting_Policy &reference_counting_policy (void); + +protected: + /// Force ACE_Event_Handler to be an abstract base class. + ACE_Event_Handler (ACE_Reactor * = 0, + int priority = ACE_Event_Handler::LO_PRIORITY); + + /// Typedef for implementation of reference counting. + typedef ACE_Atomic_Op Atomic_Reference_Count; + + /// Reference count. + Atomic_Reference_Count reference_count_; + +private: + + /// Priority of this Event_Handler. + int priority_; + + /// Pointer to the various event demultiplexors. + ACE_Reactor *reactor_; + + /// Reference counting requirements. + Reference_Counting_Policy reference_counting_policy_; +}; + +/** + * @class ACE_Event_Handler_var + * + * @brief Auto pointer like class for Event Handlers. + * + * Used to manage lifecycle of handlers. This class calls + * ACE_Event_Handler::remove_reference() in its destructor. + */ +class ACE_Export ACE_Event_Handler_var +{ + +public: + + /// Default constructor. + ACE_Event_Handler_var (void); + + /// Construct with a handler. + ACE_Event_Handler_var (ACE_Event_Handler *p); + + /// Copy constructor. + ACE_Event_Handler_var (const ACE_Event_Handler_var &b); + + /// Destructor. + ~ACE_Event_Handler_var (void); + + /// Assignment to a handler. + ACE_Event_Handler_var &operator= (ACE_Event_Handler *p); + + /// Assignment to a ACE_Event_Handler_var. + ACE_Event_Handler_var &operator= (const ACE_Event_Handler_var &b); + + /// Overloaded "->". + ACE_Event_Handler *operator-> () const; + + /// Access the handler. + ACE_Event_Handler *handler (void) const; + + /// Release the handler. + ACE_Event_Handler *release (void); + + /// Reset the handler. + void reset (ACE_Event_Handler *p = 0); + +private: + + /// Handler. + ACE_Event_Handler *ptr_; +}; + +/** + * @class ACE_Notification_Buffer + * + * @brief Simple wrapper for passing s and + * ACE_Reactor_Masks between threads. + */ +class ACE_Export ACE_Notification_Buffer +{ +public: + ACE_Notification_Buffer (void); + + ACE_Notification_Buffer (ACE_Event_Handler *eh, + ACE_Reactor_Mask mask); + + /// Default dtor. + ~ACE_Notification_Buffer (void); + + /// Pointer to the Event_Handler that will be dispatched + /// by the main event loop. + ACE_Event_Handler *eh_; + + /// Mask that indicates which method to call. + ACE_Reactor_Mask mask_; +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +#include "ace/Event_Handler.inl" +#endif /* __ACE_INLINE__ */ + +#include /**/ "ace/post.h" +#endif /* ACE_EVENT_HANDLER_H */ diff --git a/dep/ACE_wrappers/ace/Event_Handler.inl b/dep/ACE_wrappers/ace/Event_Handler.inl new file mode 100644 index 00000000000..d97c45466ae --- /dev/null +++ b/dep/ACE_wrappers/ace/Event_Handler.inl @@ -0,0 +1,12 @@ +// -*- C++ -*- +// +// $Id: Event_Handler.inl 80826 2008-03-04 14:51:23Z wotte $ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_INLINE +ACE_Notification_Buffer::~ACE_Notification_Buffer (void) +{ +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Event_Handler_T.cpp b/dep/ACE_wrappers/ace/Event_Handler_T.cpp new file mode 100644 index 00000000000..45d9d4e2767 --- /dev/null +++ b/dep/ACE_wrappers/ace/Event_Handler_T.cpp @@ -0,0 +1,125 @@ +// Event_Handler_T.cpp +// +// $Id: Event_Handler_T.cpp 80826 2008-03-04 14:51:23Z wotte $ + +#ifndef ACE_EVENT_HANDLER_T_CPP +#define ACE_EVENT_HANDLER_T_CPP + +#include "ace/Event_Handler_T.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#if defined (ACE_HAS_TEMPLATE_TYPEDEFS) + +#if !defined (__ACE_INLINE__) +#include "ace/Event_Handler_T.inl" +#endif /* __ACE_INLINE__ */ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_ALLOC_HOOK_DEFINE(ACE_Event_Handler_T) + +template void +ACE_Event_Handler_T::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + ACE_TRACE ("ACE_Event_Handler_T::dump"); +#endif /* ACE_HAS_DUMP */ +} + +template +ACE_Event_Handler_T::~ACE_Event_Handler_T (void) +{ + ACE_TRACE ("ACE_Event_Handler_T::~ACE_Event_Handler_T"); + if (this->delete_handler_) + delete this->op_handler_; +} + +template +ACE_Event_Handler_T::ACE_Event_Handler_T (T *op_handler, int delete_handler, + GET_HANDLE get_handle, + IO_HANDLER input_h, + CL_HANDLER close_h, + SIG_HANDLER sig_h, + TO_HANDLER timeout_h, + IO_HANDLER output_h, + SET_HANDLE set_handle, + IO_HANDLER except_h) + : op_handler_ (op_handler), + input_handler_ (input_h), + output_handler_ (output_h), + except_handler_ (except_h), + to_handler_ (timeout_h), + cl_handler_ (close_h), + sig_handler_ (sig_h), + delete_handler_ (delete_handler), + set_handle_ (set_handle), + get_handle_ (get_handle) +{ + ACE_TRACE ("ACE_Event_Handler_T::ACE_Event_Handler_T"); +} + +template ACE_HANDLE +ACE_Event_Handler_T::get_handle (void) const +{ + ACE_TRACE ("ACE_Event_Handler_T::get_handle"); + return this->get_handle_ == 0 ? ACE_INVALID_HANDLE : (this->op_handler_->*get_handle_) (); +} + +template void +ACE_Event_Handler_T::set_handle (ACE_HANDLE h) +{ + ACE_TRACE ("ACE_Event_Handler_T::set_handle"); + if (this->set_handle_ != 0) + (this->op_handler_->*set_handle_) (h); +} + +template int +ACE_Event_Handler_T::handle_input (ACE_HANDLE fd) +{ + ACE_TRACE ("ACE_Event_Handler_T::handle_input"); + return this->input_handler_ == 0 ? 0 : (this->op_handler_->*input_handler_) (fd); +} + +template int +ACE_Event_Handler_T::handle_output (ACE_HANDLE fd) +{ + ACE_TRACE ("ACE_Event_Handler_T::handle_output"); + return this->output_handler_ == 0 ? 0 : (this->op_handler_->*output_handler_) (fd); +} + +template int +ACE_Event_Handler_T::handle_exception (ACE_HANDLE fd) +{ + ACE_TRACE ("ACE_Event_Handler_T::handle_exception"); + return this->except_handler_ == 0 ? 0 : (this->op_handler_->*except_handler_) (fd); +} + +template int +ACE_Event_Handler_T::handle_timeout (const ACE_Time_Value &tv, const void *arg) +{ + ACE_TRACE ("ACE_Event_Handler_T::handle_timeout"); + return this->to_handler_ == 0 ? 0 : (this->op_handler_->*to_handler_) (tv, arg); +} + +template int +ACE_Event_Handler_T::handle_close (ACE_HANDLE fd, ACE_Reactor_Mask close_mask) +{ + ACE_TRACE ("ACE_Event_Handler_T::handle_close"); + return this->cl_handler_ == 0 ? 0 : (this->op_handler_->*cl_handler_) (fd, close_mask); +} + +template int +ACE_Event_Handler_T::handle_signal (int signum, siginfo_t *s, ucontext_t *u) +{ + ACE_TRACE ("ACE_Event_Handler_T::handle_signal"); + return this->sig_handler_ == 0 ? 0 : (this->op_handler_->*sig_handler_) (signum, s, u); +} + +ACE_END_VERSIONED_NAMESPACE_DECL + +#endif /* ACE_HAS_TEMPLATE_TYPEDEFS */ + +#endif /* ACE_EVENT_HANDLER_T_CPP */ diff --git a/dep/ACE_wrappers/ace/Event_Handler_T.h b/dep/ACE_wrappers/ace/Event_Handler_T.h new file mode 100644 index 00000000000..7f81b347482 --- /dev/null +++ b/dep/ACE_wrappers/ace/Event_Handler_T.h @@ -0,0 +1,191 @@ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file Event_Handler_T.h + * + * $Id: Event_Handler_T.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Douglas C. Schmidt + */ +//============================================================================= + +#ifndef ACE_EVENT_HANDLER_T_H +#define ACE_EVENT_HANDLER_T_H +#include /**/ "ace/pre.h" + +#include "ace/Event_Handler.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#if defined (ACE_HAS_TEMPLATE_TYPEDEFS) + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +/** + * @class ACE_Event_Handler_T + * + * @brief Enable a class that doesn't inherit from the + * ACE_Event_Handler to be incorporated into the ACE_Reactor + * framework. Thanks to Greg Lavender (g.lavender@isode.com) + * for sharing this idea. + * + * It is sometimes the case that an application has a hierarchy + * of operation dispatcher classes that have their own + * inheritance hierarchy but also would like to integrate with + * the ACE_Reactor. Rather than adopt a "mixin" approach, it is + * often cleaner to define a template as a subclass of + * ACE_Event_Handler and paramterize it with an operation + * dispatcher type. + * When constructing an instantiation of the ACE_Event_Handler_T + * object, a set of pointers to member functions must be + * provided so that when one of the handle_* methods is called + * by the ACE_Reactor, the appropriate method is called on the + * underlying operations object. This is done since in some + * cases it is useful to map any event that happens to the same + * method on an object. + * The ACE_Event_Handler_T template is instantiated by an + * operations object and registered with the ACE_Reactor, and it + * then calls the appropriate op_handler. So, it's basically + * just another level of indirection in event dispatching. The + * coupling betweent the ultimate handler of the event and the + * ACE_Event_Handler class is relaxed a bit by have this + * intermediate object of type around. The + * client object can then dynamically change the bindings for + * the various handlers so that during the life of one of the + * operation objects, it can change how it wants events to be + * handled. It just instantiates a new instance of the template + * with different bindings and reregisters this new object with + * the ACE_Reactor. + */ +template +class ACE_Event_Handler_T : public ACE_Event_Handler +{ +public: + // = Typedefs to simplify pointer-to-member-function registration. + + // Get/set the underlying handle. + typedef ACE_HANDLE (T::*GET_HANDLE) (void) const; + typedef void (T::*SET_HANDLE) (ACE_HANDLE); + + /// Handle I/O events. + typedef int (T::*IO_HANDLER) (ACE_HANDLE); + + /// Handle timeout events. + typedef int (T::*TO_HANDLER) (const ACE_Time_Value &, const void *); + + /// Handle close events. + typedef int (T::*CL_HANDLER) (ACE_HANDLE, ACE_Reactor_Mask); + + /// = Initialization and termination methods. + typedef int (T::*SIG_HANDLER) (int, siginfo_t*, ucontext_t*); + + /// Initialize the op_handler. + ACE_Event_Handler_T (T *op_handler, + int delete_handler, + GET_HANDLE get_handle = 0, + IO_HANDLER input = 0, + CL_HANDLER close = 0, + SIG_HANDLER sig = 0, + TO_HANDLER timeout = 0, + IO_HANDLER output = 0, + SET_HANDLE set_handle = 0, + IO_HANDLER except = 0); + + /// Close down and delete the + ~ACE_Event_Handler_T (void); + + // = Override all the ACE_Event_Handler methods. + + // These methods all delegate down to the operations handler. + virtual ACE_HANDLE get_handle (void) const; + virtual void set_handle (ACE_HANDLE); + virtual int handle_input (ACE_HANDLE fd = ACE_INVALID_HANDLE); + virtual int handle_output (ACE_HANDLE fd = ACE_INVALID_HANDLE); + virtual int handle_exception (ACE_HANDLE fd = ACE_INVALID_HANDLE); + virtual int handle_timeout (const ACE_Time_Value &tv, const void *arg = 0); + virtual int handle_close (ACE_HANDLE fd, ACE_Reactor_Mask close_mask); + virtual int handle_signal (int signum, siginfo_t * = 0, ucontext_t * = 0); + + // = Get/set the operations handler. + T *op_handler (void); + void op_handler (T *); + + // = Get/set the target pointer-to-method used for dispatching. + + GET_HANDLE handle_get (void); + void handle_get (GET_HANDLE); + + SET_HANDLE handle_set (void); + void handle_set (SET_HANDLE); + + IO_HANDLER input_handler (void); + void input_handler (IO_HANDLER); + + IO_HANDLER output_handler (void); + void output_handler (IO_HANDLER); + + IO_HANDLER except_handler (void); + void except_handler (IO_HANDLER); + + TO_HANDLER to_handler (void); + void to_handler (TO_HANDLER); + + CL_HANDLER cl_handler (void); + void cl_handler (CL_HANDLER); + + SIG_HANDLER sig_handler (void); + void sig_handler (SIG_HANDLER); + + /// Dump the state of an object. + void dump (void) const; + + /// Declare the dynamic allocation hooks. + ACE_ALLOC_HOOK_DECLARE; + +protected: + /// Pointer to the object that handles all the delegated operations. + T *op_handler_; + + // = Handle input, output, and exception events. + IO_HANDLER input_handler_; + IO_HANDLER output_handler_; + IO_HANDLER except_handler_; + + /// Handle timeout events. + TO_HANDLER to_handler_; + + /// Handle close events. + CL_HANDLER cl_handler_; + + /// Handle signal events. + SIG_HANDLER sig_handler_; + + /// Keeps track of whether we need to delete the handler in the + /// destructor. + int delete_handler_; + + // = Get/set underlying handle. + SET_HANDLE set_handle_; + GET_HANDLE get_handle_; +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +#include "ace/Event_Handler_T.inl" +#endif /* __ACE_INLINE__ */ + +#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) +#include "ace/Event_Handler_T.cpp" +#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ + +#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) +#pragma implementation ("Event_Handler_T.cpp") +#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ + +#endif /* ACE_HAS_TEMPLATE_TYPEDEFS */ +#include /**/ "ace/post.h" +#endif /* ACE_EVENT_HANDLER_H */ diff --git a/dep/ACE_wrappers/ace/Event_Handler_T.inl b/dep/ACE_wrappers/ace/Event_Handler_T.inl new file mode 100644 index 00000000000..40db43e8e23 --- /dev/null +++ b/dep/ACE_wrappers/ace/Event_Handler_T.inl @@ -0,0 +1,135 @@ +// -*- C++ -*- +// +// $Id: Event_Handler_T.inl 80826 2008-03-04 14:51:23Z wotte $ + +#include "ace/Global_Macros.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +template ACE_INLINE void +ACE_Event_Handler_T::op_handler (T *op) +{ + ACE_TRACE ("ACE_Event_Handler_T::op_handler"); + this->op_handler_ = op; +} + +template ACE_INLINE T * +ACE_Event_Handler_T::op_handler (void) +{ + ACE_TRACE ("ACE_Event_Handler_T::op_handler"); + return this->op_handler_; +} + +template ACE_INLINE typename ACE_Event_Handler_T::GET_HANDLE +ACE_Event_Handler_T::handle_get (void) +{ + ACE_TRACE ("ACE_Event_Handler_T::handle_get"); + return this->get_handle_; +} + +template ACE_INLINE void +ACE_Event_Handler_T::handle_get (typename ACE_Event_Handler_T::GET_HANDLE h) +{ + ACE_TRACE ("ACE_Event_Handler_T::handle_get"); + this->get_handle_ = h; +} + +template ACE_INLINE typename ACE_Event_Handler_T::SET_HANDLE +ACE_Event_Handler_T::handle_set (void) +{ + ACE_TRACE ("ACE_Event_Handler_T::handle_set"); + return this->set_handle_; +} + +template ACE_INLINE void +ACE_Event_Handler_T::handle_set (typename ACE_Event_Handler_T::SET_HANDLE h) +{ + ACE_TRACE ("ACE_Event_Handler_T::handle_set"); + this->set_handle_ = h; +} + +template ACE_INLINE typename ACE_Event_Handler_T::IO_HANDLER +ACE_Event_Handler_T::input_handler (void) +{ + ACE_TRACE ("ACE_Event_Handler_T::input_handler"); + return this->input_handler_; +} + +template ACE_INLINE void +ACE_Event_Handler_T::input_handler (typename ACE_Event_Handler_T::IO_HANDLER h) +{ + ACE_TRACE ("ACE_Event_Handler_T::input_handler"); + this->input_handler_ = h; +} + +template ACE_INLINE typename ACE_Event_Handler_T::IO_HANDLER +ACE_Event_Handler_T::output_handler (void) +{ + ACE_TRACE ("ACE_Event_Handler_T::output_handler"); + return this->output_handler_; +} + +template ACE_INLINE void +ACE_Event_Handler_T::output_handler (typename ACE_Event_Handler_T::IO_HANDLER h) +{ + ACE_TRACE ("ACE_Event_Handler_T::output_handler"); + this->output_handler_ = h; +} + +template ACE_INLINE typename ACE_Event_Handler_T::IO_HANDLER +ACE_Event_Handler_T::except_handler (void) +{ + ACE_TRACE ("ACE_Event_Handler_T::except_handler"); + return this->except_handler_; +} + +template ACE_INLINE void +ACE_Event_Handler_T::except_handler (typename ACE_Event_Handler_T::IO_HANDLER h) +{ + ACE_TRACE ("ACE_Event_Handler_T::except_handler"); + this->except_handler_ = h; +} + +template ACE_INLINE typename ACE_Event_Handler_T::TO_HANDLER +ACE_Event_Handler_T::to_handler (void) +{ + ACE_TRACE ("ACE_Event_Handler_T::to_handler"); + return this->to_handler_; +} + +template ACE_INLINE void +ACE_Event_Handler_T::to_handler (typename ACE_Event_Handler_T::TO_HANDLER h) +{ + ACE_TRACE ("ACE_Event_Handler_T::to_handler"); + this->to_handler_ = h; +} + +template ACE_INLINE typename ACE_Event_Handler_T::CL_HANDLER +ACE_Event_Handler_T::cl_handler (void) +{ + ACE_TRACE ("ACE_Event_Handler_T::cl_handler"); + return this->cl_handler_; +} + +template ACE_INLINE void +ACE_Event_Handler_T::cl_handler (typename ACE_Event_Handler_T::CL_HANDLER h) +{ + ACE_TRACE ("ACE_Event_Handler_T::cl_handler"); + this->cl_handler_ = h; +} + +template ACE_INLINE typename ACE_Event_Handler_T::SIG_HANDLER +ACE_Event_Handler_T::sig_handler (void) +{ + ACE_TRACE ("ACE_Event_Handler_T::sig_handler"); + return this->sig_handler_; +} + +template ACE_INLINE void +ACE_Event_Handler_T::sig_handler (typename ACE_Event_Handler_T::SIG_HANDLER h) +{ + ACE_TRACE ("ACE_Event_Handler_T::sig_handler"); + this->sig_handler_ = h; +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Exception_Macros.h b/dep/ACE_wrappers/ace/Exception_Macros.h new file mode 100644 index 00000000000..bb74b1a2129 --- /dev/null +++ b/dep/ACE_wrappers/ace/Exception_Macros.h @@ -0,0 +1,55 @@ +// -*- C++ -*- + +// ============================================================================ +/** + * @file Exception_Macros.h + * + * $Id: Exception_Macros.h 80826 2008-03-04 14:51:23Z wotte $ + * + * Writing code that is portable between platforms with or without + * native C++ exceptions is hard. The following macros offer some + * help on this task. + * + * @author Nanbor Wang + * @author Aniruddha Gokhale + * @author Carlos O'Ryan + * @author Krishnakumar B , et al. + */ +// ============================================================================ + +// Macros for handling exceptions. + +#ifndef ACE_EXCEPTION_MACROS_H +#define ACE_EXCEPTION_MACROS_H + +#include /**/ "ace/pre.h" + +#include /**/ "ace/config-all.h" + +# if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +# endif /* ACE_LACKS_PRAGMA_ONCE */ + +// By default, if the compiler supports native exception handling, assume +// CORBA also support native exception handling. But it can be disabled by +// defining ACE_CORBA_HAS_EXCEPTIONS=0. If the compiler does not support +// exceptions handling, make sure native exception handling is disabled. +#if defined (ACE_HAS_EXCEPTIONS) +# if defined (ACE_CORBA_HAS_EXCEPTIONS) +# if (ACE_CORBA_HAS_EXCEPTIONS == 0) +# undef ACE_USES_NATIVE_EXCEPTIONS +# else /* ACE_CORBA_HAS_EXCEPTIONS != 0 */ +# define ACE_USES_NATIVE_EXCEPTIONS +# endif /* ACE_CORBA_HAS_EXCEPTIONS == 0 */ +# else +# define ACE_USES_NATIVE_EXCEPTIONS +# define ACE_CORBA_HAS_EXCEPTIONS +# endif /* ACE_CORBA_HAS_EXCEPTIONS */ +#else /* ! ACE_HAS_EXCEPTIONS */ +# undef ACE_CORBA_HAS_EXCEPTIONS +# undef ACE_USES_NATIVE_EXCEPTIONS +#endif /* ACE_HAS_EXCEPTIONS */ + +#include /**/ "ace/post.h" + +#endif /* ACE_EXCEPTION_MACROS_H */ diff --git a/dep/ACE_wrappers/ace/FIFO.cpp b/dep/ACE_wrappers/ace/FIFO.cpp new file mode 100644 index 00000000000..e3970015c43 --- /dev/null +++ b/dep/ACE_wrappers/ace/FIFO.cpp @@ -0,0 +1,78 @@ +// $Id: FIFO.cpp 80826 2008-03-04 14:51:23Z wotte $ + +#include "ace/FIFO.h" + +#if !defined (__ACE_INLINE__) +#include "ace/FIFO.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/Log_Msg.h" +#include "ace/OS_NS_string.h" +#include "ace/OS_NS_errno.h" +#include "ace/OS_NS_sys_stat.h" +#include "ace/OS_NS_fcntl.h" + +ACE_RCSID(ace, FIFO, "$Id: FIFO.cpp 80826 2008-03-04 14:51:23Z wotte $") + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_ALLOC_HOOK_DEFINE(ACE_FIFO) + +void +ACE_FIFO::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + ACE_TRACE ("ACE_FIFO::dump"); + + ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("rendezvous_ = %s"), this->rendezvous_)); + ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); +#endif /* ACE_HAS_DUMP */ +} + +int +ACE_FIFO::open (const ACE_TCHAR *r, int flags, mode_t perms, + LPSECURITY_ATTRIBUTES sa) +{ + ACE_TRACE ("ACE_FIFO::open"); + ACE_OS::strsncpy (this->rendezvous_, r, MAXPATHLEN); + + if ((flags & O_CREAT) != 0 + && ACE_OS::mkfifo (this->rendezvous_, perms) == -1 + && !(errno == EEXIST)) + return -1; + + this->set_handle (ACE_OS::open (this->rendezvous_, flags, 0, sa)); + return this->get_handle () == ACE_INVALID_HANDLE ? -1 : 0; +} + +ACE_FIFO::ACE_FIFO (const ACE_TCHAR *fifo_name, + int flags, + mode_t perms, + LPSECURITY_ATTRIBUTES sa) +{ + ACE_TRACE ("ACE_FIFO::ACE_FIFO"); + if (this->open (fifo_name, flags, perms, sa) == -1) + ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("ACE_FIFO"))); +} + +ACE_FIFO::ACE_FIFO (void) +{ +// ACE_TRACE ("ACE_FIFO::ACE_FIFO"); +} + +int +ACE_FIFO::close (void) +{ + ACE_TRACE ("ACE_FIFO::close"); + int result = 0; + + if (this->get_handle () != ACE_INVALID_HANDLE) + { + result = ACE_OS::close (this->get_handle ()); + this->set_handle (ACE_INVALID_HANDLE); + } + return result; +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/FIFO.h b/dep/ACE_wrappers/ace/FIFO.h new file mode 100644 index 00000000000..2d590563a99 --- /dev/null +++ b/dep/ACE_wrappers/ace/FIFO.h @@ -0,0 +1,85 @@ +// -*- C++ -*- + +//========================================================================== +/** + * @file FIFO.h + * + * $Id: FIFO.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Doug Schmidt + */ +//========================================================================== + + +#ifndef ACE_FIFO_H +#define ACE_FIFO_H +#include /**/ "ace/pre.h" + +#include /**/ "ace/ACE_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/IPC_SAP.h" +#include "ace/os_include/os_limits.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +/** + * @class ACE_FIFO + * + * @brief Abstract base class for UNIX FIFOs + * + * UNIX FIFOs are also known Named Pipes, which are totally + * unrelated to Win32 Named Pipes. If you want to use a local + * IPC mechanism that will be portable to both UNIX and Win32, + * take a look at the classes. + */ +class ACE_Export ACE_FIFO : public ACE_IPC_SAP +{ +public: + /// Open up the named pipe on the in accordance with the + /// flags. + int open (const ACE_TCHAR *rendezvous, int flags, mode_t perms, + LPSECURITY_ATTRIBUTES sa = 0); + + /// Close down the ACE_FIFO without removing the rendezvous point. + int close (void); + + /// Close down the ACE_FIFO and remove the rendezvous point from the + /// file system. + int remove (void); + + /// Return the local address of this endpoint. + int get_local_addr (const ACE_TCHAR *&rendezvous) const; + + /// Dump the state of an object. + void dump (void) const; + + /// Declare the dynamic allocation hooks. + ACE_ALLOC_HOOK_DECLARE; + +protected: + // = Make these protected to ensure that the class is "abstract." + /// Default constructor. + ACE_FIFO (void); + + /// Open up the named pipe on the in accordance with the + /// flags. + ACE_FIFO (const ACE_TCHAR *rendezvous, int flags, mode_t perms, + LPSECURITY_ATTRIBUTES sa = 0); + +private: + /// Rendezvous point in the file system. + ACE_TCHAR rendezvous_[MAXPATHLEN + 1]; +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +#include "ace/FIFO.inl" +#endif /* __ACE_INLINE__ */ + +#include /**/ "ace/post.h" +#endif /* ACE_FIFO_H */ diff --git a/dep/ACE_wrappers/ace/FIFO.inl b/dep/ACE_wrappers/ace/FIFO.inl new file mode 100644 index 00000000000..05cc030a917 --- /dev/null +++ b/dep/ACE_wrappers/ace/FIFO.inl @@ -0,0 +1,25 @@ +// -*- C++ -*- +// +// $Id: FIFO.inl 80826 2008-03-04 14:51:23Z wotte $ + +#include "ace/OS_NS_unistd.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_INLINE int +ACE_FIFO::get_local_addr (const ACE_TCHAR *&r) const +{ + ACE_TRACE ("ACE_FIFO::get_local_addr"); + r = this->rendezvous_; + return 0; +} + +ACE_INLINE int +ACE_FIFO::remove (void) +{ + ACE_TRACE ("ACE_FIFO::remove"); + int const result = this->close (); + return ACE_OS::unlink (this->rendezvous_) == -1 || result == -1 ? -1 : 0; +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/FIFO_Recv.cpp b/dep/ACE_wrappers/ace/FIFO_Recv.cpp new file mode 100644 index 00000000000..254e30f21d1 --- /dev/null +++ b/dep/ACE_wrappers/ace/FIFO_Recv.cpp @@ -0,0 +1,88 @@ +// $Id: FIFO_Recv.cpp 80826 2008-03-04 14:51:23Z wotte $ + +#include "ace/FIFO_Recv.h" +#include "ace/Log_Msg.h" +#include "ace/OS_NS_fcntl.h" + +#if !defined (__ACE_INLINE__) +#include "ace/FIFO_Recv.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(ace, FIFO_Recv, "$Id: FIFO_Recv.cpp 80826 2008-03-04 14:51:23Z wotte $") + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_ALLOC_HOOK_DEFINE(ACE_FIFO_Recv) + +void +ACE_FIFO_Recv::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + ACE_TRACE ("ACE_FIFO_Recv::dump"); + ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); + ACE_FIFO::dump (); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("aux_handle_ = %d"), this->aux_handle_)); + ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); +#endif /* ACE_HAS_DUMP */ +} + +int +ACE_FIFO_Recv::close (void) +{ + ACE_TRACE ("ACE_FIFO_Recv::close"); + int result = ACE_FIFO::close (); + + if (this->aux_handle_ != ACE_INVALID_HANDLE) + return ACE_OS::close (this->aux_handle_); + else + return result; +} + +// Note that persistent means "open fifo for writing, as well as +// reading." This ensures that the fifo never gets EOF, even if there +// aren't any writers at the moment! + +int +ACE_FIFO_Recv::open (const ACE_TCHAR *fifo_name, + int flags, + mode_t perms, + int persistent, + LPSECURITY_ATTRIBUTES sa) +{ + ACE_TRACE ("ACE_FIFO_Recv::open"); + + if (ACE_FIFO::open (fifo_name, ACE_NONBLOCK | flags, perms, sa) == -1) + return -1; + else if (this->disable (ACE_NONBLOCK) == -1) + return -1; + else if (persistent + && (this->aux_handle_ = ACE_OS::open (fifo_name, O_WRONLY, 0, sa)) == ACE_INVALID_HANDLE) + return -1; + else + return this->get_handle () == ACE_INVALID_HANDLE ? -1 : 0; +} + +ACE_FIFO_Recv::ACE_FIFO_Recv (void) + : aux_handle_ (ACE_INVALID_HANDLE) +{ + ACE_TRACE ("ACE_FIFO_Recv::ACE_FIFO_Recv"); +} + +ACE_FIFO_Recv::ACE_FIFO_Recv (const ACE_TCHAR *fifo_name, + int flags, + mode_t perms, + int persistent, + LPSECURITY_ATTRIBUTES sa) + : aux_handle_ (ACE_INVALID_HANDLE) +{ + ACE_TRACE ("ACE_FIFO_Recv::ACE_FIFO_Recv"); + + if (this->ACE_FIFO_Recv::open (fifo_name, + flags, + perms, + persistent, + sa) == -1) + ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("ACE_FIFO_Recv"))); +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/FIFO_Recv.h b/dep/ACE_wrappers/ace/FIFO_Recv.h new file mode 100644 index 00000000000..c19d102c82a --- /dev/null +++ b/dep/ACE_wrappers/ace/FIFO_Recv.h @@ -0,0 +1,85 @@ +// -*- C++ -*- + +//========================================================================== +/** + * @file FIFO_Recv.h + * + * $Id: FIFO_Recv.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Doug Schmidt + */ +//========================================================================== + + +#ifndef ACE_FIFO_RECV_H +#define ACE_FIFO_RECV_H + +#include /**/ "ace/pre.h" + +#include "ace/FIFO.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/os_include/os_fcntl.h" +#include "ace/Default_Constants.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +/** + * @class ACE_FIFO_Recv + * + * @brief Receiver side of the bytestream C++ wrapper for UNIX + * FIFOs. + */ +class ACE_Export ACE_FIFO_Recv : public ACE_FIFO +{ +public: + // = Initialization methods. + /// Default constructor. + ACE_FIFO_Recv (void); + + /// Open up a bytestream named pipe for reading. + ACE_FIFO_Recv (const ACE_TCHAR *rendezvous, + int flags = O_CREAT | O_RDONLY, + mode_t perms = ACE_DEFAULT_FILE_PERMS, + int persistent = 1, + LPSECURITY_ATTRIBUTES sa = 0); + + /// Open up a bytestream named pipe for reading. + int open (const ACE_TCHAR *rendezvous, + int flags = O_CREAT | O_RDONLY, + mode_t perms = ACE_DEFAULT_FILE_PERMS, + int persistent = 1, + LPSECURITY_ATTRIBUTES sa = 0); + + /// Close down the named pipe. + int close (void); + + /// Recv @a buf of up to @a len bytes. + ssize_t recv (void *buf, size_t len); + + /// Recv @a buf of exactly @a len bytes (block until done). + ssize_t recv_n (void *buf, size_t len); + + /// Dump the state of an object. + void dump (void) const; + + /// Declare the dynamic allocation hooks. + ACE_ALLOC_HOOK_DECLARE; + +private: + /// Auxiliary handle that is used to implement persistent FIFOs. + ACE_HANDLE aux_handle_; +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +#include "ace/FIFO_Recv.inl" +#endif /* __ACE_INLINE__ */ + +#include /**/ "ace/post.h" + +#endif /* ACE_FIFO_RECV_H */ diff --git a/dep/ACE_wrappers/ace/FIFO_Recv.inl b/dep/ACE_wrappers/ace/FIFO_Recv.inl new file mode 100644 index 00000000000..d4c3fee4326 --- /dev/null +++ b/dep/ACE_wrappers/ace/FIFO_Recv.inl @@ -0,0 +1,24 @@ +// -*- C++ -*- +// +// $Id: FIFO_Recv.inl 80826 2008-03-04 14:51:23Z wotte $ + +#include "ace/ACE.h" +#include "ace/OS_NS_unistd.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_INLINE ssize_t +ACE_FIFO_Recv::recv (void *buf, size_t len) +{ + ACE_TRACE ("ACE_FIFO_Recv::recv"); + return ACE_OS::read (this->get_handle (), (char *) buf, len); +} + +ACE_INLINE ssize_t +ACE_FIFO_Recv::recv_n (void *buf, size_t n) +{ + ACE_TRACE ("ACE_FIFO_Recv::recv_n"); + return ACE::recv_n (this->get_handle (), buf, n); +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/FIFO_Recv_Msg.cpp b/dep/ACE_wrappers/ace/FIFO_Recv_Msg.cpp new file mode 100644 index 00000000000..f389d03d276 --- /dev/null +++ b/dep/ACE_wrappers/ace/FIFO_Recv_Msg.cpp @@ -0,0 +1,67 @@ +// $Id: FIFO_Recv_Msg.cpp 80826 2008-03-04 14:51:23Z wotte $ + +#include "ace/FIFO_Recv_Msg.h" + +#include "ace/Log_Msg.h" + +#if !defined (__ACE_INLINE__) +#include "ace/FIFO_Recv_Msg.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(ace, FIFO_Recv_Msg, "$Id: FIFO_Recv_Msg.cpp 80826 2008-03-04 14:51:23Z wotte $") + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_ALLOC_HOOK_DEFINE(ACE_FIFO_Recv_Msg) + +void +ACE_FIFO_Recv_Msg::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + ACE_TRACE ("ACE_FIFO_Recv_Msg::dump"); + ACE_FIFO_Recv::dump (); +#endif /* ACE_HAS_DUMP */ +} + +// Note that persistent means "open FIFO for writing, as well as +// reading." This ensures that the FIFO never gets EOF, even if there +// aren't any writers at the moment! + +int +ACE_FIFO_Recv_Msg::open (const ACE_TCHAR *fifo_name, + int flags, + mode_t perms, + int persistent, + LPSECURITY_ATTRIBUTES sa) +{ + ACE_TRACE ("ACE_FIFO_Recv_Msg::open"); + + return ACE_FIFO_Recv::open (fifo_name, + flags, + perms, + persistent, + sa); +} + +ACE_FIFO_Recv_Msg::ACE_FIFO_Recv_Msg (void) +{ + ACE_TRACE ("ACE_FIFO_Recv_Msg::ACE_FIFO_Recv_Msg"); +} + +ACE_FIFO_Recv_Msg::ACE_FIFO_Recv_Msg (const ACE_TCHAR *fifo_name, + int flags, + mode_t perms, + int persistent, + LPSECURITY_ATTRIBUTES sa) +{ + ACE_TRACE ("ACE_FIFO_Recv_Msg::ACE_FIFO_Recv_Msg"); + + if (this->ACE_FIFO_Recv_Msg::open (fifo_name, + flags, + perms, + persistent, + sa) == -1) + ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("ACE_FIFO_Recv_Msg"))); +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/FIFO_Recv_Msg.h b/dep/ACE_wrappers/ace/FIFO_Recv_Msg.h new file mode 100644 index 00000000000..80b7bdda91c --- /dev/null +++ b/dep/ACE_wrappers/ace/FIFO_Recv_Msg.h @@ -0,0 +1,138 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file FIFO_Recv_Msg.h + * + * $Id: FIFO_Recv_Msg.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Doug Schmidt + */ +//============================================================================= + + +#ifndef ACE_FIFO_RECV_MSG_H +#define ACE_FIFO_RECV_MSG_H +#include /**/ "ace/pre.h" + +#include "ace/FIFO_Recv.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +// Forward decls +class ACE_Str_Buf; + +/** + * @class ACE_FIFO_Recv_Msg + * + * @brief Receiver side for the record oriented C++ wrapper for UNIX FIFOs. + * + * This method works slightly differently on platforms with the + * @c ACE_HAS_STREAM_PIPES configuration setting than those without. + * With ACE_HAS_STREAM_PIPES, the @c getmsg() system function is used + * and it preserves message boundaries internally. Without + * @c ACE_HAS_STREAM_PIPES, the message boundaries are emulated by + * this class and ACE_FIFO_Send_Msg cooperating. The sending class + * first writes an integer number of bytes in the message, then the + * message. ACE_FIFO_Recv_Msg reads the count, then the data. + * The operational differences occur primarily when a message is larger + * than what a caller of this class requests. See recv() for details. + */ +class ACE_Export ACE_FIFO_Recv_Msg : public ACE_FIFO_Recv +{ +public: + // = Initialization methods. + /// Default constructor. + ACE_FIFO_Recv_Msg (void); + + /// Open up a record-oriented named pipe for reading. + ACE_FIFO_Recv_Msg (const ACE_TCHAR *rendezvous, + int flags = O_CREAT | O_RDONLY, + mode_t perms = ACE_DEFAULT_FILE_PERMS, + int persistent = 1, + LPSECURITY_ATTRIBUTES sa = 0); + + /// Open up a record-oriented named pipe for reading. + int open (const ACE_TCHAR *rendezvous, + int flags = O_CREAT | O_RDONLY, + mode_t perms = ACE_DEFAULT_FILE_PERMS, + int persistent = 1, + LPSECURITY_ATTRIBUTES sa = 0); + + /// Receive a message based on attributes in an ACE_Str_Buf. + /** + * @param msg Reference to an ACE_Str_Buf whose @c buf member points + * to the memory to receive the data and @c maxlen member + * contains the maximum number of bytes to receive. + * On return after successfully reading data, the + * @c len member contains the number of bytes received and + * placed in the buffer pointed to by @c msg.buf. + * + * @retval -1 Error; consult @c errno for specific error number. + * @return If the @c ACE_HAS_STREAM_PIPES configuration setting is + * defined, the return value is the number of bytes received + * in the message and will be the same as @c buf.len. + * The return value from the @c getmsg() system function + * is discarded. + * If @c ACE_HAS_STREAM_PIPES is not defined, the number + * of bytes in the message read from the FIFO is returned. + * If the message is larger than the maximum length + * requested in @c msg.maxlen, the return value reflects + * the entire message length, and the @c msg.len member + * reflects how many bytes were actually placed in the + * caller's buffer. Any part of the message longer than + * @c msg.maxlen is discarded. + */ + ssize_t recv (ACE_Str_Buf &msg); + + /// Receive a message based on buffer pointer and maximum size. + /** + * @param buf Pointer to the memory to receive the data. + * @param len The maximum number of bytes to receive. + * + * @retval -1 Error; consult @c errno for specific error number. + * @return The number of bytes received in the message. For messages + * that are larger than the requested maximum size, the + * behavior is different depending on the @c ACE_HAS_STREAM_PIPES + * configuration setting. With @c ACE_HAS_STREAM_PIPES, + * the return value will be the same as @arg len (this is + * also possible if the message is exactly the same length + * as @arg len, and the two cases are indistinguishable). + * Without @c ACE_HAS_STREAM_PIPES, the return value is + * the total length of the message, including bytes in + * excess of @arg len. The excess bytes are discarded. + */ + ssize_t recv (void *buf, size_t len); + +#if defined (ACE_HAS_STREAM_PIPES) + /// Recv and message via Stream pipes. + ssize_t recv (ACE_Str_Buf *data, + ACE_Str_Buf *cntl, + int *flags); + + /// Recv and message via Stream pipes in "band" mode. + ssize_t recv (int *band, + ACE_Str_Buf *data, + ACE_Str_Buf *cntl, + int *flags); +#endif /* ACE_HAS_STREAM_PIPES */ + + /// Dump the state of an object. + void dump (void) const; + + /// Declare the dynamic allocation hooks. + ACE_ALLOC_HOOK_DECLARE; +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +#include "ace/FIFO_Recv_Msg.inl" +#endif /* __ACE_INLINE__ */ + +#include /**/ "ace/post.h" +#endif /* ACE_FIFO_RECV_MSG_H */ diff --git a/dep/ACE_wrappers/ace/FIFO_Recv_Msg.inl b/dep/ACE_wrappers/ace/FIFO_Recv_Msg.inl new file mode 100644 index 00000000000..0a0b0673d38 --- /dev/null +++ b/dep/ACE_wrappers/ace/FIFO_Recv_Msg.inl @@ -0,0 +1,137 @@ +// -*- C++ -*- +// +// $Id: FIFO_Recv_Msg.inl 82559 2008-08-07 20:23:07Z parsons $ + +#include "ace/Min_Max.h" +#include "ace/OS_NS_stropts.h" +#include "ace/Truncate.h" + +#if !defined (ACE_HAS_STREAM_PIPES) +#include "ace/OS_NS_unistd.h" +#endif + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_INLINE ssize_t +ACE_FIFO_Recv_Msg::recv (ACE_Str_Buf &recv_msg) +{ + ACE_TRACE ("ACE_FIFO_Recv_Msg::recv"); +#if defined (ACE_HAS_STREAM_PIPES) + int i = 0; + if (ACE_OS::getmsg (this->get_handle (), + (strbuf *) 0, + (strbuf *) &recv_msg, + &i) == -1) + { + return -1; + } + else + { + return recv_msg.len; + } +#else /* Do the ol' 2-read trick... */ + if (ACE_OS::read (this->get_handle (), + (char *) &recv_msg.len, + sizeof recv_msg.len) != sizeof recv_msg.len) + { + return -1; + } + else + { + size_t remaining = static_cast (recv_msg.len); + size_t requested = static_cast (recv_msg.maxlen); + ssize_t recv_len = ACE_OS::read (this->get_handle (), + (char *) recv_msg.buf, + ACE_MIN (remaining, requested)); + + if (recv_len == -1) + { + return -1; + } + + // Tell caller what's really in the buffer. + recv_msg.len = static_cast (recv_len); + + // If there are more bytes remaining in the message, read them and + // throw them away. Leaving them in the FIFO would make it difficult + // to find the start of the next message in the fifo. + // Since the ACE_HAS_STREAM_PIPES version of this method doesn't + // return getmsg()'s indication of "data remaining", don't worry about + // saving the indication here either to read the remainder later. + size_t total_msg_size = remaining; + remaining -= recv_len; + + while (remaining > 0) + { + const size_t throw_away = 1024; + char dev_null[throw_away]; + recv_len = ACE_OS::read (this->get_handle (), + dev_null, + ACE_MIN (remaining, throw_away)); + + if (recv_len == -1) + { + break; + } + + remaining -= recv_len; + } + + return ACE_Utils::truncate_cast (total_msg_size); + } +#endif /* ACE_HAS_STREAM_PIPES */ +} + +ACE_INLINE ssize_t +ACE_FIFO_Recv_Msg::recv (void *buf, size_t max_len) +{ + ACE_TRACE ("ACE_FIFO_Recv_Msg::recv"); + ACE_Str_Buf recv_msg ((char *) buf, 0, static_cast (max_len)); + + return this->recv (recv_msg); +} + +#if defined (ACE_HAS_STREAM_PIPES) +ACE_INLINE ssize_t +ACE_FIFO_Recv_Msg::recv (ACE_Str_Buf *data, + ACE_Str_Buf *cntl, + int *flags) +{ + ACE_TRACE ("ACE_FIFO_Recv_Msg::recv"); + if (ACE_OS::getmsg (this->get_handle (), + (strbuf *) cntl, + (strbuf *) data, + flags) == -1) + { + return -1; + } + else + { + return (cntl == 0 ? 0 : cntl->len) + (data == 0 ? 0 : data->len); + } +} + +ACE_INLINE ssize_t +ACE_FIFO_Recv_Msg::recv (int *band, + ACE_Str_Buf *data, + ACE_Str_Buf *cntl, + int *flags) +{ + ACE_TRACE ("ACE_FIFO_Recv_Msg::recv"); + + if (ACE_OS::getpmsg (this->get_handle (), + (strbuf *) cntl, + (strbuf *) data, + band, + flags) == -1) + { + return -1; + } + else + { + return (cntl == 0 ? 0 : cntl->len) + (data == 0 ? 0 : data->len); + } +} +#endif /* ACE_HAS_STREAM_PIPES */ + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/FIFO_Send.cpp b/dep/ACE_wrappers/ace/FIFO_Send.cpp new file mode 100644 index 00000000000..720e63c5425 --- /dev/null +++ b/dep/ACE_wrappers/ace/FIFO_Send.cpp @@ -0,0 +1,58 @@ +// $Id: FIFO_Send.cpp 80826 2008-03-04 14:51:23Z wotte $ + +#include "ace/FIFO_Send.h" +#include "ace/Log_Msg.h" + +#if !defined (__ACE_INLINE__) +#include "ace/FIFO_Send.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(ace, FIFO_Send, "$Id: FIFO_Send.cpp 80826 2008-03-04 14:51:23Z wotte $") + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_ALLOC_HOOK_DEFINE(ACE_FIFO_Send) + +void +ACE_FIFO_Send::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + ACE_TRACE ("ACE_FIFO_Send::dump"); + ACE_FIFO::dump (); +#endif /* ACE_HAS_DUMP */ +} + +ACE_FIFO_Send::ACE_FIFO_Send (void) +{ +// ACE_TRACE ("ACE_FIFO_Send::ACE_FIFO_Send"); +} + +int +ACE_FIFO_Send::open (const ACE_TCHAR *rendezvous_name, + int flags, + mode_t perms, + LPSECURITY_ATTRIBUTES sa) +{ + ACE_TRACE ("ACE_FIFO_Send::open"); + return ACE_FIFO::open (rendezvous_name, + flags | O_WRONLY, + perms, + sa); +} + +ACE_FIFO_Send::ACE_FIFO_Send (const ACE_TCHAR *fifo_name, + int flags, + mode_t perms, + LPSECURITY_ATTRIBUTES sa) +{ + ACE_TRACE ("ACE_FIFO_Send::ACE_FIFO_Send"); + if (this->ACE_FIFO_Send::open (fifo_name, + flags, + perms, + sa) == -1) + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("%p\n"), + ACE_TEXT ("ACE_FIFO_Send::ACE_FIFO_Send"))); +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/FIFO_Send.h b/dep/ACE_wrappers/ace/FIFO_Send.h new file mode 100644 index 00000000000..cc0fc282f83 --- /dev/null +++ b/dep/ACE_wrappers/ace/FIFO_Send.h @@ -0,0 +1,75 @@ +// -*- C++ -*- + +//========================================================================== +/** + * @file FIFO_Send.h + * + * $Id: FIFO_Send.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Doug Schmidt + */ +//========================================================================== + + +#ifndef ACE_FIFO_SEND_H +#define ACE_FIFO_SEND_H + +#include /**/ "ace/pre.h" + +#include "ace/FIFO.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/os_include/os_fcntl.h" +#include "ace/Default_Constants.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +/** + * @class ACE_FIFO_Send + * + * @brief Sender side for the bytestream C++ wrapper for UNIX FIFOs + */ +class ACE_Export ACE_FIFO_Send : public ACE_FIFO +{ +public: + // = Initialization methods. + /// Default constructor. + ACE_FIFO_Send (void); + + /// Open up a bytestream named pipe for writing. + ACE_FIFO_Send (const ACE_TCHAR *rendezvous, + int flags = O_WRONLY, + mode_t perms = ACE_DEFAULT_FILE_PERMS, + LPSECURITY_ATTRIBUTES sa = 0); + + /// Open up a bytestream named pipe for writing. + int open (const ACE_TCHAR *rendezvous, + int flags = O_WRONLY, + mode_t perms = ACE_DEFAULT_FILE_PERMS, + LPSECURITY_ATTRIBUTES sa = 0); + + /// Send @a buf of up to @a len bytes. + ssize_t send (const void *buf, size_t len); + + /// Send @a buf of exactly @a len bytes (block until done). + ssize_t send_n (const void *buf, size_t len); + + /// Dump the state of an object. + void dump (void) const; + + /// Declare the dynamic allocation hooks. + ACE_ALLOC_HOOK_DECLARE; +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +#include "ace/FIFO_Send.inl" +#endif /* __ACE_INLINE__ */ + +#include /**/ "ace/post.h" + +#endif /* ACE_FIFO_SEND_H */ diff --git a/dep/ACE_wrappers/ace/FIFO_Send.inl b/dep/ACE_wrappers/ace/FIFO_Send.inl new file mode 100644 index 00000000000..a01facd61f0 --- /dev/null +++ b/dep/ACE_wrappers/ace/FIFO_Send.inl @@ -0,0 +1,24 @@ +// -*- C++ -*- +// +// $Id: FIFO_Send.inl 80826 2008-03-04 14:51:23Z wotte $ + +#include "ace/ACE.h" +#include "ace/OS_NS_unistd.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_INLINE ssize_t +ACE_FIFO_Send::send (const void *buf, size_t len) +{ + ACE_TRACE ("ACE_FIFO_Send::send"); + return ACE_OS::write (this->get_handle (), (const char *) buf, len); +} + +ACE_INLINE ssize_t +ACE_FIFO_Send::send_n (const void *buf, size_t n) +{ + ACE_TRACE ("ACE_FIFO_Send::send_n"); + return ACE::send_n (this->get_handle (), buf, n); +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/FIFO_Send_Msg.cpp b/dep/ACE_wrappers/ace/FIFO_Send_Msg.cpp new file mode 100644 index 00000000000..b3bbae00aed --- /dev/null +++ b/dep/ACE_wrappers/ace/FIFO_Send_Msg.cpp @@ -0,0 +1,80 @@ +// $Id: FIFO_Send_Msg.cpp 80826 2008-03-04 14:51:23Z wotte $ + +#include "ace/FIFO_Send_Msg.h" + +#include "ace/Log_Msg.h" +#include "ace/OS_NS_sys_uio.h" + +#if !defined (__ACE_INLINE__) +#include "ace/FIFO_Send_Msg.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(ace, FIFO_Send_Msg, "$Id: FIFO_Send_Msg.cpp 80826 2008-03-04 14:51:23Z wotte $") + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_ALLOC_HOOK_DEFINE(ACE_FIFO_Send_Msg) + +void +ACE_FIFO_Send_Msg::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + ACE_TRACE ("ACE_FIFO_Send_Msg::dump"); + ACE_FIFO_Send::dump (); +#endif /* ACE_HAS_DUMP */ +} + +ssize_t +ACE_FIFO_Send_Msg::send (const ACE_Str_Buf &send_msg) +{ + // ACE_TRACE ("ACE_FIFO_Send_Msg::send"); +#if defined (ACE_HAS_STREAM_PIPES) + if (ACE_OS::putmsg (this->get_handle (), + (strbuf *) 0, + (strbuf *) &send_msg, + 0) == -1) + return -1; + else + return send_msg.len; +#else + iovec iov[2]; + + iov[0].iov_base = (char *) &send_msg.len; + iov[0].iov_len = sizeof send_msg.len; + + iov[1].iov_base = (char *) send_msg.buf; + iov[1].iov_len = static_cast (send_msg.len); + + ssize_t sent = ACE_OS::writev (this->get_handle (), iov, 2); + if (sent > 0) + sent -= iov[0].iov_len; // Don't count the length we added. + return sent; +#endif /* ACE_HAS_STREAM_PIPES */ +} + +ACE_FIFO_Send_Msg::ACE_FIFO_Send_Msg (void) +{ +// ACE_TRACE ("ACE_FIFO_Send_Msg::ACE_FIFO_Send_Msg"); +} + +int +ACE_FIFO_Send_Msg::open (const ACE_TCHAR *fifo_name, + int flags, + mode_t perms, + LPSECURITY_ATTRIBUTES sa) +{ + ACE_TRACE ("ACE_FIFO_Send_Msg::open"); + return ACE_FIFO_Send::open (fifo_name, flags | O_WRONLY, perms, sa); +} + +ACE_FIFO_Send_Msg::ACE_FIFO_Send_Msg (const ACE_TCHAR *fifo_name, + int flags, + mode_t perms, + LPSECURITY_ATTRIBUTES sa) +{ + ACE_TRACE ("ACE_FIFO_Send_Msg::ACE_FIFO_Send_Msg"); + if (this->ACE_FIFO_Send_Msg::open (fifo_name, flags, perms, sa) == -1) + ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("ACE_FIFO_Send_Msg"))); +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/FIFO_Send_Msg.h b/dep/ACE_wrappers/ace/FIFO_Send_Msg.h new file mode 100644 index 00000000000..504d8972187 --- /dev/null +++ b/dep/ACE_wrappers/ace/FIFO_Send_Msg.h @@ -0,0 +1,91 @@ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file FIFO_Send_Msg.h + * + * $Id: FIFO_Send_Msg.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Doug Schmidt + */ +//============================================================================= + + +#ifndef ACE_FIFO_SEND_MSG_H +#define ACE_FIFO_SEND_MSG_H +#include /**/ "ace/pre.h" + +#include "ace/FIFO_Send.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#if defined (ACE_HAS_STREAM_PIPES) +# include "ace/OS_NS_stropts.h" +#endif /* ACE_HAS_STREAM_PIPES */ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +// Forward Decls +class ACE_Str_Buf; + +/** + * @class ACE_FIFO_Send_Msg + * + * @brief Sender side for the Record oriented C++ wrapper for UNIX + * FIFOs. + */ +class ACE_Export ACE_FIFO_Send_Msg : public ACE_FIFO_Send +{ +public: + // = Initialization methods. + /// Default constructor. + ACE_FIFO_Send_Msg (void); + + /// Open up a record-oriented named pipe for writing. + ACE_FIFO_Send_Msg (const ACE_TCHAR *rendezvous, + int flags = O_WRONLY, + mode_t perms = ACE_DEFAULT_FILE_PERMS, + LPSECURITY_ATTRIBUTES sa = 0); + + /// Open up a record-oriented named pipe for writing. + int open (const ACE_TCHAR *rendezvous, + int flags = O_WRONLY, + mode_t perms = ACE_DEFAULT_FILE_PERMS, + LPSECURITY_ATTRIBUTES sa = 0); + + /// Send @a buf of up to @a len bytes. + ssize_t send (const ACE_Str_Buf &msg); + + /// Send @a buf of exactly @a len bytes (block until done). + ssize_t send (const void *buf, size_t len); + +#if defined (ACE_HAS_STREAM_PIPES) + /// Send and message via Stream pipes. + ssize_t send (const ACE_Str_Buf *data, + const ACE_Str_Buf *cntl = 0, + int flags = 0); + + /// Send and message via Stream pipes in "band" mode. + ssize_t send (int band, + const ACE_Str_Buf *data, + const ACE_Str_Buf *cntl = 0, + int flags = MSG_BAND); +#endif /* ACE_HAS_STREAM_PIPES */ + + /// Dump the state of an object. + void dump (void) const; + + /// Declare the dynamic allocation hooks. + ACE_ALLOC_HOOK_DECLARE; +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +#include "ace/FIFO_Send_Msg.inl" +#endif /* __ACE_INLINE__ */ + +#include /**/ "ace/post.h" +#endif /* ACE_FIFO_SEND_MSG_H */ diff --git a/dep/ACE_wrappers/ace/FIFO_Send_Msg.inl b/dep/ACE_wrappers/ace/FIFO_Send_Msg.inl new file mode 100644 index 00000000000..0a34e64e370 --- /dev/null +++ b/dep/ACE_wrappers/ace/FIFO_Send_Msg.inl @@ -0,0 +1,53 @@ +// -*- C++ -*- +// +// $Id: FIFO_Send_Msg.inl 80826 2008-03-04 14:51:23Z wotte $ + +#include "ace/OS_NS_stropts.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_INLINE ssize_t +ACE_FIFO_Send_Msg::send (const void *buf, size_t len) +{ + ACE_TRACE ("ACE_FIFO_Send_Msg::send"); + ACE_Str_Buf send_msg ((char *) buf, static_cast (len)); + + return this->send (send_msg); +} + +#if defined (ACE_HAS_STREAM_PIPES) +ACE_INLINE ssize_t +ACE_FIFO_Send_Msg::send (const ACE_Str_Buf *data, + const ACE_Str_Buf *cntl, + int flags) +{ + ACE_TRACE ("ACE_FIFO_Send_Msg::send"); + if (ACE_OS::putmsg (this->get_handle (), + (strbuf *) cntl, + (strbuf *) data, + flags) == -1) + return-1; + else + return (cntl == 0 ? 0 : cntl->len) + (data == 0 ? 0 : data->len); +} + +ACE_INLINE ssize_t +ACE_FIFO_Send_Msg::send (int band, + const ACE_Str_Buf *data, + const ACE_Str_Buf *cntl, + int flags) +{ + ACE_TRACE ("ACE_FIFO_Send_Msg::send"); + + if (ACE_OS::putpmsg (this->get_handle (), + (strbuf *) cntl, + (strbuf *) data, + band, + flags) == -1) + return -1; + else + return (cntl == 0 ? 0 : cntl->len) + (data == 0 ? 0 : data->len); +} +#endif /* ACE_HAS_STREAM_PIPES */ + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/FILE.cpp b/dep/ACE_wrappers/ace/FILE.cpp new file mode 100644 index 00000000000..8fe88d1b09c --- /dev/null +++ b/dep/ACE_wrappers/ace/FILE.cpp @@ -0,0 +1,147 @@ +// $Id: FILE.cpp 80826 2008-03-04 14:51:23Z wotte $ + +/* Defines the member functions for the base class of the ACE_IO_SAP + ACE_FILE abstraction. */ + +#include "ace/FILE.h" + +#include "ace/OS_NS_unistd.h" +#include "ace/OS_NS_sys_stat.h" + +#if !defined (__ACE_INLINE__) +#include "ace/FILE.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(ace, FILE, "$Id: FILE.cpp 80826 2008-03-04 14:51:23Z wotte $") + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_ALLOC_HOOK_DEFINE(ACE_FILE) + +void +ACE_FILE::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + ACE_TRACE ("ACE_FILE::dump"); + ACE_IO_SAP::dump (); +#endif /* ACE_HAS_DUMP */ +} + +// This is the do-nothing constructor. + +ACE_FILE::ACE_FILE (void) +{ + ACE_TRACE ("ACE_FILE::ACE_FILE"); +} + +// Close the file + +int +ACE_FILE::close (void) +{ + ACE_TRACE ("ACE_FILE::close"); + int result = 0; + + if (this->get_handle () != ACE_INVALID_HANDLE) + { + result = ACE_OS::close (this->get_handle ()); + this->set_handle (ACE_INVALID_HANDLE); + } + return result; +} + +int +ACE_FILE::get_info (ACE_FILE_Info *finfo) +{ + ACE_TRACE ("ACE_FILE::get_info"); + ACE_stat filestatus; + + int const result = ACE_OS::fstat (this->get_handle (), &filestatus); + + if (result == 0) + { + finfo->mode_ = filestatus.st_mode; + finfo->nlink_ = filestatus.st_nlink; + finfo->size_ = filestatus.st_size; + } + + return result; +} + +int +ACE_FILE::get_info (ACE_FILE_Info &finfo) +{ + ACE_TRACE ("ACE_FILE::get_info"); + + return this->get_info (&finfo); +} + +int +ACE_FILE::truncate (ACE_OFF_T length) +{ + ACE_TRACE ("ACE_FILE::truncate"); + return ACE_OS::ftruncate (this->get_handle (), length); +} + +ACE_OFF_T +ACE_FILE::seek (ACE_OFF_T offset, int startpos) +{ + return ACE_OS::lseek (this->get_handle (), offset, startpos); +} + +ACE_OFF_T +ACE_FILE::tell (void) +{ + ACE_TRACE ("ACE_FILE::tell"); + return ACE_OS::lseek (this->get_handle (), 0, SEEK_CUR); +} + +// Return the local endpoint address. + +int +ACE_FILE::get_local_addr (ACE_Addr &addr) const +{ + ACE_TRACE ("ACE_FILE::get_local_addr"); + + // Perform the downcast since had better be an + // . + ACE_FILE_Addr *file_addr = + dynamic_cast (&addr); + + if (file_addr == 0) + return -1; + else + { + *file_addr = this->addr_; + return 0; + } +} + +// Return the same result as . + +int +ACE_FILE::get_remote_addr (ACE_Addr &addr) const +{ + ACE_TRACE ("ACE_FILE::get_remote_addr"); + + return this->get_local_addr (addr); +} + +int +ACE_FILE::remove (void) +{ + ACE_TRACE ("ACE_FILE::remove"); + + this->close (); + return ACE_OS::unlink (this->addr_.get_path_name ()); +} + +int +ACE_FILE::unlink (void) +{ + ACE_TRACE ("ACE_FILE::unlink"); + + return ACE_OS::unlink (this->addr_.get_path_name ()); +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/FILE.h b/dep/ACE_wrappers/ace/FILE.h new file mode 100644 index 00000000000..407a03379e5 --- /dev/null +++ b/dep/ACE_wrappers/ace/FILE.h @@ -0,0 +1,139 @@ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file FILE.h + * + * $Id: FILE.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Gerhard Lenzer + */ +//============================================================================= + +#ifndef ACE_FILE_H +#define ACE_FILE_H +#include /**/ "ace/pre.h" + +#include "ace/IO_SAP.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/FILE_Addr.h" + +// The following is necessary since many C++ compilers don't support +// typedef'd types inside of classes used as formal template +// arguments... ;-(. Luckily, using the C++ preprocessor I can hide +// most of this nastiness! + +#if defined (ACE_HAS_TEMPLATE_TYPEDEFS) +#define ACE_FILE_CONNECTOR ACE_FILE_Connector +#define ACE_FILE_STREAM ACE_FILE_IO +#else /* TEMPLATES are broken (must be a cfront-based compiler...) */ +#define ACE_FILE_CONNECTOR ACE_FILE_Connector, ACE_FILE_Addr +#define ACE_FILE_STREAM ACE_FILE_IO, ACE_FILE_Addr +#endif /* ACE_TEMPLATE_TYPEDEFS */ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +/** + * @class ACE_FILE_Info + * + * @brief Abstracts basic OS FILE information. + */ +class ACE_Export ACE_FILE_Info +{ +public: + /// Mode of file + mode_t mode_; + + /// No of links + nlink_t nlink_; + + /// Size of file + ACE_OFF_T size_; +}; + +/** + * @class ACE_FILE + * + * @brief Defines the core methods of the ACE_FILE abstraction. + */ +class ACE_Export ACE_FILE : public ACE_IO_SAP +{ +public: + /// Close the ACE_FILE handle without removing the ACE_FILE from + /// the file system. + int close (void); + + /// Close and remove the ACE_FILE from the file system. + int remove (void); + + /// Remove the ACE_FILE from the file system without closing the + /// ACE_FILE handle. + int unlink (void); + + /// Get information on this ACE_FILE. + int get_info (ACE_FILE_Info *finfo); + + /// Get information on this ACE_FILE. + int get_info (ACE_FILE_Info &finfo); + + /// Set filesize to length byte. + int truncate (ACE_OFF_T length); + + /** + * Sets the file pointer as follows: + * o If is , the pointer is set to @a offset + * bytes. + * + * o If is , the pointer is set to its + * current location plus @a offset. + * + * o If is , the pointer is set to the size + * of the file plus offset. + */ + ACE_OFF_T seek (ACE_OFF_T offset, + int whence = SEEK_CUR); + + /// Return an offset for the file handle. + ACE_OFF_T tell (void); + + /** + * Disable signal @a signum + * This is here to prevent Win32 from + * disabling SPIPE using socket calls + */ + int disable (int signum) const ; + + /// Return the local endpoint address in the referenced ACE_Addr. + /// Returns 0 if successful, else -1. + int get_local_addr (ACE_Addr &) const; + + /// Return the same thing as get_local_addr(). + int get_remote_addr (ACE_Addr &) const; + + /// Dump the state of an object. + void dump (void) const; + + /// Declare the dynamic allocation hooks. + ACE_ALLOC_HOOK_DECLARE; + +protected: + /// Ensure that this class is only created by the + /// ACE_FILE_Connector. + ACE_FILE (void); + + /// File we are "connected" with... + ACE_FILE_Addr addr_; +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +#include "ace/FILE.inl" +#endif /* __ACE_INLINE__ */ + +#include /**/ "ace/post.h" +#endif /* ACE_FILE_H */ diff --git a/dep/ACE_wrappers/ace/FILE.inl b/dep/ACE_wrappers/ace/FILE.inl new file mode 100644 index 00000000000..288374afc58 --- /dev/null +++ b/dep/ACE_wrappers/ace/FILE.inl @@ -0,0 +1,18 @@ +// -*- C++ -*- +// +// $Id: FILE.inl 80826 2008-03-04 14:51:23Z wotte $ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_INLINE int +ACE_FILE::disable (int signum) const +{ +#if defined (ACE_WIN32) + ACE_UNUSED_ARG (signum) ; + return 0 ; +#else /* ACE_WIN32 */ + return ACE_IO_SAP::disable (signum) ; +#endif /* ACE_WIN32 */ +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/FILE_Addr.cpp b/dep/ACE_wrappers/ace/FILE_Addr.cpp new file mode 100644 index 00000000000..6d8fbeb775b --- /dev/null +++ b/dep/ACE_wrappers/ace/FILE_Addr.cpp @@ -0,0 +1,124 @@ +// $Id: FILE_Addr.cpp 80826 2008-03-04 14:51:23Z wotte $ + +#include "ace/FILE_Addr.h" +#include "ace/Lib_Find.h" +#include "ace/Log_Msg.h" +#include "ace/OS_NS_stdlib.h" +#include "ace/OS_NS_string.h" +#include "ace/os_include/sys/os_socket.h" + +#if !defined (__ACE_INLINE__) +#include "ace/FILE_Addr.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(ace, FILE_Addr, "$Id: FILE_Addr.cpp 80826 2008-03-04 14:51:23Z wotte $") + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_ALLOC_HOOK_DEFINE(ACE_FILE_Addr) + +ACE_FILE_Addr::ACE_FILE_Addr (void) + : ACE_Addr (AF_FILE, sizeof this->filename_ / sizeof (ACE_TCHAR)) +{ + this->filename_[0] = '\0'; +} + +int +ACE_FILE_Addr::set (const ACE_FILE_Addr &sa) +{ + if (sa.get_type () == AF_ANY) + { +#if defined (ACE_DEFAULT_TEMP_FILE) + // Create a temporary file. + ACE_OS::strcpy (this->filename_, + ACE_DEFAULT_TEMP_FILE); +#else /* ACE_DEFAULT_TEMP_FILE */ + if (ACE::get_temp_dir (this->filename_, MAXPATHLEN - 15) == -1) + // -15 for ace-file-XXXXXX + { + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("Temporary path too long, ") + ACE_TEXT ("defaulting to current directory\n"))); + this->filename_[0] = 0; + } + + // Add the filename to the end + ACE_OS::strcat (this->filename_, ACE_TEXT ("ace-fileXXXXXX")); + +#endif /* ACE_DEFAULT_TEMP_FILE */ + + if (ACE_OS::mktemp (this->filename_) == 0) + return -1; + this->base_set (AF_FILE, + static_cast (ACE_OS::strlen (this->filename_) + 1)); + } + else + { + (void)ACE_OS::strsncpy (this->filename_, sa.filename_, sa.get_size ()); + + this->base_set (sa.get_type (), sa.get_size ()); + } + return 0; +} + +// Copy constructor. + +ACE_FILE_Addr::ACE_FILE_Addr (const ACE_FILE_Addr &sa) + : ACE_Addr (AF_FILE, sizeof this->filename_) +{ + this->set (sa); +} + +int +ACE_FILE_Addr::set (const ACE_TCHAR *filename) +{ + this->ACE_Addr::base_set (AF_FILE, + static_cast (ACE_OS::strlen (filename) + 1)); + (void) ACE_OS::strsncpy (this->filename_, + filename, + sizeof this->filename_ / sizeof (ACE_TCHAR)); + return 0; +} + +ACE_FILE_Addr & +ACE_FILE_Addr::operator= (const ACE_FILE_Addr &sa) +{ + if (this != &sa) + this->set (sa); + return *this; +} + +// Create a ACE_Addr from a ACE_FILE pathname. + +ACE_FILE_Addr::ACE_FILE_Addr (const ACE_TCHAR *filename) +{ + this->set (filename); +} + +int +ACE_FILE_Addr::addr_to_string (ACE_TCHAR *s, size_t len) const +{ + ACE_OS::strsncpy (s, this->filename_, len); + return 0; +} + +// Return the address. + +void * +ACE_FILE_Addr::get_addr (void) const +{ + return (void *)&this->filename_; +} + +void +ACE_FILE_Addr::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + ACE_TRACE ("ACE_FILE_Addr::dump"); + + ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("filename_ = %s"), this->filename_)); + ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); +#endif /* ACE_HAS_DUMP */ +} +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/FILE_Addr.h b/dep/ACE_wrappers/ace/FILE_Addr.h new file mode 100644 index 00000000000..432275b9665 --- /dev/null +++ b/dep/ACE_wrappers/ace/FILE_Addr.h @@ -0,0 +1,89 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file FILE_Addr.h + * + * $Id: FILE_Addr.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Douglas C. Schmidt + */ +//============================================================================= + +#ifndef ACE_FILE_ADDR_H +#define ACE_FILE_ADDR_H +#include /**/ "ace/pre.h" + +#include "ace/Addr.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/Flag_Manip.h" +#include "ace/os_include/os_dirent.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +/** + * @class ACE_FILE_Addr + * + * @brief Defines the FILE address family address format. + */ +class ACE_Export ACE_FILE_Addr : public ACE_Addr +{ +public: + // = Initialization methods. + /// Default constructor. + ACE_FILE_Addr (void); + + /// Copy constructor. + ACE_FILE_Addr (const ACE_FILE_Addr &sa); + + /// Acts like a copy constructor. If @a sa == ACE_Addr::sap_any then + /// create a temporary filename using ACE_OS::mktemp. + int set (const ACE_FILE_Addr &sa); + + /// Create a ACE_FILE_Addr from a pathname. + explicit ACE_FILE_Addr (const ACE_TCHAR *filename); + + /// Create a ACE_FILE_Addr from a pathname. + int set (const ACE_TCHAR *filename); + + /// Assignment operator. + ACE_FILE_Addr &operator= (const ACE_FILE_Addr &); + + /// Return a pointer to the address. + virtual void *get_addr (void) const; + + /// Transform the current address into string format. + virtual int addr_to_string (ACE_TCHAR *addr, size_t) const; + + /// Compare two addresses for equality. + bool operator == (const ACE_FILE_Addr &SAP) const; + + /// Compare two addresses for inequality. + bool operator != (const ACE_FILE_Addr &SAP) const; + + /// Return the path name used for the rendezvous point. + const ACE_TCHAR *get_path_name (void) const; + + /// Dump the state of an object. + void dump (void) const; + + /// Declare the dynamic allocation hooks. + ACE_ALLOC_HOOK_DECLARE; + +private: + /// Name of the file. + ACE_TCHAR filename_[MAXPATHLEN + 1]; +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +#include "ace/FILE_Addr.inl" +#endif /* __ACE_INLINE__ */ + +#include /**/ "ace/post.h" +#endif /* ACE_FILE_ADDR_H */ diff --git a/dep/ACE_wrappers/ace/FILE_Addr.inl b/dep/ACE_wrappers/ace/FILE_Addr.inl new file mode 100644 index 00000000000..0ae7d31d278 --- /dev/null +++ b/dep/ACE_wrappers/ace/FILE_Addr.inl @@ -0,0 +1,34 @@ +// -*- C++ -*- +// +// $Id: FILE_Addr.inl 80826 2008-03-04 14:51:23Z wotte $ + + +#include "ace/SString.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +// Compare two addresses for equality. + +ACE_INLINE bool +ACE_FILE_Addr::operator == (const ACE_FILE_Addr &sap) const +{ + return ACE_OS::strcmp (this->filename_, sap.filename_) == 0; +} + +// Compare two addresses for inequality. + +ACE_INLINE bool +ACE_FILE_Addr::operator != (const ACE_FILE_Addr &sap) const +{ + return !((*this) == sap); // This is lazy, of course... ;-) +} + +// Return the path name used for the rendezvous point. + +ACE_INLINE const ACE_TCHAR * +ACE_FILE_Addr::get_path_name (void) const +{ + return this->filename_; +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/FILE_Connector.cpp b/dep/ACE_wrappers/ace/FILE_Connector.cpp new file mode 100644 index 00000000000..b59b1e8913d --- /dev/null +++ b/dep/ACE_wrappers/ace/FILE_Connector.cpp @@ -0,0 +1,84 @@ +// $Id: FILE_Connector.cpp 80826 2008-03-04 14:51:23Z wotte $ + +#include "ace/FILE_Connector.h" +#include "ace/Handle_Ops.h" +#include "ace/OS_NS_stdlib.h" + +#if !defined (__ACE_INLINE__) +#include "ace/FILE_Connector.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(ace, FILE_Connector, "$Id: FILE_Connector.cpp 80826 2008-03-04 14:51:23Z wotte $") + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_ALLOC_HOOK_DEFINE(ACE_FILE_Connector) + +void +ACE_FILE_Connector::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + ACE_TRACE ("ACE_FILE_Connector::dump"); + + ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\n"))); + ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); +#endif /* ACE_HAS_DUMP */ +} + +ACE_FILE_Connector::ACE_FILE_Connector (void) +{ + ACE_TRACE ("ACE_FILE_Connector::ACE_FILE_Connector"); +} + +int +ACE_FILE_Connector::connect (ACE_FILE_IO &new_io, + const ACE_FILE_Addr &remote_sap, + ACE_Time_Value *timeout, + const ACE_Addr &, + int, + int flags, + int perms) +{ + ACE_TRACE ("ACE_FILE_Connector::connect"); + ACE_ASSERT (new_io.get_handle () == ACE_INVALID_HANDLE); + + ACE_HANDLE handle = ACE_INVALID_HANDLE; + + // Check to see if caller has requested that we create the filename. + if (reinterpret_cast ( + const_cast (remote_sap)) == ACE_Addr::sap_any) + { + // Create a new temporary file. + // Use ACE_OS::mkstemp() if it is available since it avoids a + // race condition, and subsequently a security hole due to that + // race condition (specifically, a denial-of-service attack). + // + // However, using mkstemp() prevents us from doing a timed open + // since it opens the file for us. Better to avoid the race + // condition. + char filename[] = "ace-file-XXXXXX"; + + handle = ACE_OS::mkstemp (filename); // mkstemp() replaces "XXXXXX" + + if (handle == ACE_INVALID_HANDLE + || new_io.addr_.set (ACE_TEXT_CHAR_TO_TCHAR (filename)) != 0) + return -1; + + new_io.set_handle (handle); + + return 0; + } + else + new_io.addr_ = remote_sap; // class copy. + + handle = ACE::handle_timed_open (timeout, + new_io.addr_.get_path_name (), + flags, + perms); + + new_io.set_handle (handle); + return handle == ACE_INVALID_HANDLE ? -1 : 0; +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/FILE_Connector.h b/dep/ACE_wrappers/ace/FILE_Connector.h new file mode 100644 index 00000000000..c6d3963736c --- /dev/null +++ b/dep/ACE_wrappers/ace/FILE_Connector.h @@ -0,0 +1,113 @@ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file FILE_Connector.h + * + * $Id: FILE_Connector.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Doug Schmidt + */ +//============================================================================= + +#ifndef ACE_FILE_CONNECTOR_H +#define ACE_FILE_CONNECTOR_H +#include /**/ "ace/pre.h" + +#include "ace/FILE_IO.h" +#include "ace/Log_Msg.h" +#include "ace/os_include/os_fcntl.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +/** + * @class ACE_FILE_Connector + * + * @brief Defines an active connection factory for the ACE_FILE wrappers. + * + * Note that the O_APPEND flag is only partly supported on Win32. If + * you specify O_APPEND, then the file pointer will be positioned at + * the end of the file initially during open, but it is not + * re-positioned at the end prior to each write, as specified by + * POSIX. This is generally good enough for typical situations, but + * it is ``not quite right'' in its semantics. + */ +class ACE_Export ACE_FILE_Connector +{ +public: + // = Initialization methods. + /// Default constructor. + ACE_FILE_Connector (void); + + /** + * Actively ``connect'' and produce a @a new_io ACE_FILE_IO object + * if things go well. The @a remote_sap is the file that we are + * trying to create/open. If it's the default value of + * ACE_Addr::sap_any then the user is letting the OS create the + * filename (via ). The @a timeout is the amount of + * time to wait to create/open the file. If it's 0 then we block + * indefinitely. If *timeout == {0, 0} then the file is created + * using non-blocking mode. If *timeout > {0, 0} then this is the + * maximum amount of time to wait before timing out. The + * @a local_sap and @a reuse_addr parameters are ignored. The @a flags + * and @a perms arguments are passed down to the + * method. + */ + ACE_FILE_Connector (ACE_FILE_IO &new_io, + const ACE_FILE_Addr &remote_sap, + ACE_Time_Value *timeout = 0, + const ACE_Addr &local_sap = ACE_Addr::sap_any, + int reuse_addr = 0, + int flags = O_RDWR | O_CREAT, + int perms = ACE_DEFAULT_FILE_PERMS); + + /** + * Actively ``connect'' and produce a @a new_io object + * if things go well. The @a remote_sap is the file that we are + * trying to create/open. If it's the default value of + * ACE_Addr::sap_any then the user is letting the OS create the + * filename (via ). The @a timeout is the amount of + * time to wait to create/open the file. If it's 0 then we block + * indefinitely. If *timeout == {0, 0} then the file is created + * using non-blocking mode. In this case, if the create/open can't + * be done immediately the value of -1 is returned with . If *timeout > {0, 0} then this is the maximum amount of + * time to wait before timing out. If the time expires before the + * connection is made @c errno == ETIME. The @a local_sap and + * @a reuse_addr parameters are ignored. The @a flags and @a perms + * arguments are passed down to the method. + */ + int connect (ACE_FILE_IO &new_io, + const ACE_FILE_Addr &remote_sap, + ACE_Time_Value *timeout = 0, + const ACE_Addr &local_sap = ACE_Addr::sap_any, + int reuse_addr = 0, + int flags = O_RDWR | O_CREAT, + int perms = ACE_DEFAULT_FILE_PERMS); + + /// Resets any event associations on this handle + int reset_new_handle (ACE_HANDLE handle); + + /// Dump the state of an object. + void dump (void) const; + + /// Declare the dynamic allocation hooks. + ACE_ALLOC_HOOK_DECLARE; + + // = Meta-type "trait" information. + typedef ACE_FILE_Addr PEER_ADDR; + typedef ACE_FILE_IO PEER_STREAM; +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +#include "ace/FILE_Connector.inl" +#endif /* __ACE_INLINE__ */ + +#include /**/ "ace/post.h" +#endif /* ACE_FILE_CONNECTOR_H */ diff --git a/dep/ACE_wrappers/ace/FILE_Connector.inl b/dep/ACE_wrappers/ace/FILE_Connector.inl new file mode 100644 index 00000000000..deab94e0061 --- /dev/null +++ b/dep/ACE_wrappers/ace/FILE_Connector.inl @@ -0,0 +1,36 @@ +// -*- C++ -*- +// +// $Id: FILE_Connector.inl 80826 2008-03-04 14:51:23Z wotte $ + +// Creates a Local ACE_FILE. + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_INLINE +ACE_FILE_Connector::ACE_FILE_Connector (ACE_FILE_IO &new_io, + const ACE_FILE_Addr &remote_sap, + ACE_Time_Value *timeout, + const ACE_Addr &local_sap, + int reuse_addr, + int flags, + int perms) +{ + ACE_TRACE ("ACE_FILE_Connector::ACE_FILE_Connector"); + if (this->connect (new_io, remote_sap, timeout, local_sap, + reuse_addr, flags, perms) == ACE_IO_SAP::INVALID_HANDLE + && timeout != 0 && !(errno == EWOULDBLOCK || errno == ETIME)) + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("address %s, %p\n"), + remote_sap.get_path_name (), + ACE_TEXT ("ACE_FILE_IO"))); +} + +ACE_INLINE int +ACE_FILE_Connector::reset_new_handle (ACE_HANDLE handle) +{ + ACE_UNUSED_ARG (handle); + // Nothing to do here since the handle is not a socket + return 0; +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/FILE_IO.cpp b/dep/ACE_wrappers/ace/FILE_IO.cpp new file mode 100644 index 00000000000..d6bf084dfae --- /dev/null +++ b/dep/ACE_wrappers/ace/FILE_IO.cpp @@ -0,0 +1,145 @@ +// $Id: FILE_IO.cpp 82559 2008-08-07 20:23:07Z parsons $ + +#include "ace/FILE_IO.h" + +#include "ace/Log_Msg.h" +#include "ace/OS_NS_sys_stat.h" +#include "ace/OS_Memory.h" +#include "ace/Truncate.h" + +#if !defined (__ACE_INLINE__) +#include "ace/FILE_IO.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(ace, FILE_IO, "$Id: FILE_IO.cpp 82559 2008-08-07 20:23:07Z parsons $") + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_ALLOC_HOOK_DEFINE(ACE_FILE_IO) + +void +ACE_FILE_IO::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + ACE_TRACE ("ACE_FILE_IO::dump"); + + ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); + this->addr_.dump (); + ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); +#endif /* ACE_HAS_DUMP */ +} + +// Simple-minded do nothing constructor. + +ACE_FILE_IO::ACE_FILE_IO (void) +{ + ACE_TRACE ("ACE_FILE_IO::ACE_FILE_IO"); +} + +// Send N char *ptrs and int lengths. Note that the char *'s precede +// the ints (basically, an varargs version of writev). The count N is +// the *total* number of trailing arguments, *not* a couple of the +// number of tuple pairs! + +ssize_t +ACE_FILE_IO::send (size_t n, ...) const +{ + ACE_TRACE ("ACE_FILE_IO::send"); + va_list argp; + int total_tuples = ACE_Utils::truncate_cast (n / 2); + iovec *iovp = 0; +#if defined (ACE_HAS_ALLOCA) + iovp = (iovec *) alloca (total_tuples * sizeof (iovec)); +#else + ACE_NEW_RETURN (iovp, + iovec[total_tuples], + -1); +#endif /* !defined (ACE_HAS_ALLOCA) */ + + va_start (argp, n); + + for (int i = 0; i < total_tuples; i++) + { + iovp[i].iov_base = va_arg (argp, char *); + iovp[i].iov_len = va_arg (argp, int); + } + + ssize_t result = ACE_OS::writev (this->get_handle (), + iovp, + total_tuples); +#if !defined (ACE_HAS_ALLOCA) + delete [] iovp; +#endif /* !defined (ACE_HAS_ALLOCA) */ + va_end (argp); + return result; +} + +// This is basically an interface to ACE_OS::readv, that doesn't use +// the struct iovec explicitly. The ... can be passed as an arbitrary +// number of (char *ptr, int len) tuples. However, the count N is the +// *total* number of trailing arguments, *not* a couple of the number +// of tuple pairs! + +ssize_t +ACE_FILE_IO::recv (size_t n, ...) const +{ + ACE_TRACE ("ACE_FILE_IO::recv"); + va_list argp; + int total_tuples = ACE_Utils::truncate_cast (n / 2); + iovec *iovp = 0; +#if defined (ACE_HAS_ALLOCA) + iovp = (iovec *) alloca (total_tuples * sizeof (iovec)); +#else + ACE_NEW_RETURN (iovp, + iovec[total_tuples], + -1); +#endif /* !defined (ACE_HAS_ALLOCA) */ + + va_start (argp, n); + + for (int i = 0; i < total_tuples; i++) + { + iovp[i].iov_base = va_arg (argp, char *); + iovp[i].iov_len = va_arg (argp, int); + } + + ssize_t const result = ACE_OS::readv (this->get_handle (), + iovp, + total_tuples); +#if !defined (ACE_HAS_ALLOCA) + delete [] iovp; +#endif /* !defined (ACE_HAS_ALLOCA) */ + va_end (argp); + return result; +} + +// Allows a client to read from a file without having to provide a +// buffer to read. This method determines how much data is in the +// file, allocates a buffer of this size, reads in the data, and +// returns the number of bytes read. + +ssize_t +ACE_FILE_IO::recvv (iovec *io_vec) +{ + ACE_TRACE ("ACE_FILE_IO::recvv"); + + io_vec->iov_base = 0; + size_t const length = + static_cast (ACE_OS::filesize (this->get_handle ())); + + if (length > 0) + { + ACE_NEW_RETURN (io_vec->iov_base, + char[length], + -1); + io_vec->iov_len = this->recv_n (io_vec->iov_base, + length); + return io_vec->iov_len; + } + else + { + return ACE_Utils::truncate_cast (length); + } +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/FILE_IO.h b/dep/ACE_wrappers/ace/FILE_IO.h new file mode 100644 index 00000000000..951069e3652 --- /dev/null +++ b/dep/ACE_wrappers/ace/FILE_IO.h @@ -0,0 +1,170 @@ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file FILE_IO.h + * + * $Id: FILE_IO.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Douglas C. Schmidt + */ +//============================================================================= + +#ifndef ACE_FILE_IO_H +#define ACE_FILE_IO_H +#include /**/ "ace/pre.h" + +#include "ace/FILE.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/FILE_Addr.h" + +// Used in the FILE_IO.h file... +#include "ace/os_include/os_stdio.h" +#include "ace/os_include/sys/os_uio.h" + +#if defined (ACE_HAS_STREAM_PIPES) +# include "ace/OS_NS_stropts.h" +#endif /* ACE_HAS_STREAM_PIPES */ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +// Forward decl. +class ACE_Message_Block; +class ACE_Time_Value; + +/** + * @class ACE_FILE_IO + * + * @brief Read/Write operations on Files + */ +class ACE_Export ACE_FILE_IO : public ACE_FILE +{ +public: + friend class ACE_FILE_Connector; + + // = Initialization method. + /// Default constructor. + ACE_FILE_IO (void); + + /// send upto @a n bytes in @a buf. + ssize_t send (const void *buf, size_t n) const; + + /// Recv upto @a n bytes in @a buf. + ssize_t recv (void *buf, size_t n) const; + + /// Send n bytes, keep trying until n are sent. + ssize_t send_n (const void *buf, size_t n) const; + + /// Send all the @a message_blocks chained through their and + /// pointers. This call uses the underlying OS gather-write + /// operation to reduce the domain-crossing penalty. + ssize_t send_n (const ACE_Message_Block *message_block, + const ACE_Time_Value *timeout = 0, + size_t *bytes_transferred = 0); + + /// Recv n bytes, keep trying until n are received. + ssize_t recv_n (void *buf, size_t n) const; + +#if defined (ACE_HAS_STREAM_PIPES) + /// Send bytes via STREAM pipes. + ssize_t send (const ACE_Str_Buf *cntl, + const ACE_Str_Buf *data, + int flags = 0) const; + + /// Recv bytes via STREAM pipes. + ssize_t recv (ACE_Str_Buf *cntl, + ACE_Str_Buf *data, + int *flags) const; + + /// Send bytes via STREAM pipes using "band" mode. + ssize_t send (const ACE_Str_Buf *cntl, + const ACE_Str_Buf *data, + int band, + int flags) const; + + /// Recv bytes via STREAM pipes using "band" mode. + ssize_t recv (ACE_Str_Buf *cntl, + ACE_Str_Buf *data, + int *band, + int *flags) const; + +#endif /* ACE_HAS_STREAM_PIPES */ + + /// Send iovecs via <::writev>. + ssize_t send (const iovec iov[], int n) const; + + /// Recv iovecs via <::readv>. + ssize_t recv (iovec iov[], int n) const; + + /** + * Send N char *ptrs and int lengths. Note that the char *'s + * precede the ints (basically, an varargs version of writev). The + * count N is the *total* number of trailing arguments, *not* a + * couple of the number of tuple pairs! + */ + ssize_t send (size_t n, ...) const; + + /** + * This is an interface to ::readv, that doesn't use the struct + * iovec explicitly. The ... can be passed as an arbitrary number + * of (char *ptr, int len) tuples. However, the count N is the + * *total* number of trailing arguments, *not* a couple of the + * number of tuple pairs! + */ + ssize_t recv (size_t n, ...) const; + + /// Send @a n bytes via Win32 WriteFile using overlapped I/O. + ssize_t send (const void *buf, + size_t n, + ACE_OVERLAPPED *overlapped) const; + + /// Recv @a n bytes via Win32 ReadFile using overlapped I/O. + ssize_t recv (void *buf, + size_t n, + ACE_OVERLAPPED *overlapped) const; + + /// Send an @c iovec of size @a n to the file. + ssize_t sendv (const iovec iov[], + int n) const; + + /** + * Allows a client to read from a file without having to provide a + * buffer to read. This method determines how much data is in the + * file, allocates a buffer of this size, reads in the data, and + * returns the number of bytes read. The caller is responsible for + * deleting the member in the field of using + * delete [] io_vec->iov_base. + */ + ssize_t recvv (iovec *io_vec); + + /// Send an of size @a n to the file. Will block until all + /// bytes are sent or an error occurs. + ssize_t sendv_n (const iovec iov[], + int n) const; + + /// Receive an of size @a n to the file. + ssize_t recvv_n (iovec iov[], + int n) const; + + /// Dump the state of an object. + void dump (void) const; + + /// Declare the dynamic allocation hooks. + ACE_ALLOC_HOOK_DECLARE; + + // = Meta-type info + typedef ACE_FILE_Addr PEER_ADDR; +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +#include "ace/FILE_IO.inl" +#endif /* __ACE_INLINE__ */ + +#include /**/ "ace/post.h" +#endif /* ACE_FILE_IO_H */ diff --git a/dep/ACE_wrappers/ace/FILE_IO.inl b/dep/ACE_wrappers/ace/FILE_IO.inl new file mode 100644 index 00000000000..d2e4f756c2c --- /dev/null +++ b/dep/ACE_wrappers/ace/FILE_IO.inl @@ -0,0 +1,152 @@ +// -*- C++ -*- +// +// $Id: FILE_IO.inl 80826 2008-03-04 14:51:23Z wotte $ + +#include "ace/ACE.h" +#include "ace/OS_NS_sys_uio.h" +#include "ace/OS_NS_unistd.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_INLINE ssize_t +ACE_FILE_IO::sendv_n (const iovec iov[], int n) const +{ + ACE_TRACE ("ACE_FILE_IO::sendv_n"); + return ACE::writev_n (this->get_handle (), + iov, + n); +} + +ACE_INLINE ssize_t +ACE_FILE_IO::send_n (const ACE_Message_Block *message_block, + const ACE_Time_Value *timeout, + size_t *bytes_transferred) +{ + ACE_TRACE ("ACE_FILE_IO::send_n"); + ACE_UNUSED_ARG (timeout); + return ACE::write_n (this->get_handle (), + message_block, + bytes_transferred); +} + +// Recv an n byte message from the file. + +ACE_INLINE ssize_t +ACE_FILE_IO::recvv_n (iovec iov[], int n) const +{ + ACE_TRACE ("ACE_FILE_IO::recvv_n"); + // @@ Carlos, can you please update this to call the + // new ACE::recvv_n() method that you write? + return ACE_OS::readv (this->get_handle (), + iov, + n); +} + +// Send an of size to the file. + +ACE_INLINE ssize_t +ACE_FILE_IO::sendv (const iovec iov[], int n) const +{ + ACE_TRACE ("ACE_FILE_IO::sendv"); + return ACE_OS::writev (this->get_handle (), iov, n); +} + +// Send exactly N bytes from BUF to this file. Keeping trying until +// this many bytes are sent. + +ACE_INLINE ssize_t +ACE_FILE_IO::send_n (const void *buf, size_t n) const +{ + ACE_TRACE ("ACE_FILE_IO::send_n"); + return ACE::write_n (this->get_handle (), buf, n); +} + +// Receive exactly N bytes from this file into BUF. Keep trying until +// this many bytes are received. + +ACE_INLINE ssize_t +ACE_FILE_IO::recv_n (void *buf, size_t n) const +{ + ACE_TRACE ("ACE_FILE_IO::recv_n"); + return ACE::read_n (this->get_handle (), buf, n); +} + +ACE_INLINE ssize_t +ACE_FILE_IO::send (const void *buf, size_t n) const +{ + ACE_TRACE ("ACE_FILE_IO::send"); + return ACE_OS::write (this->get_handle (), buf, n); +} + +ACE_INLINE ssize_t +ACE_FILE_IO::recv (void *buf, size_t n) const +{ + ACE_TRACE ("ACE_FILE_IO::recv"); + return ACE_OS::read (this->get_handle (), buf, n); +} + +ACE_INLINE ssize_t +ACE_FILE_IO::send (const iovec iov[], int n) const +{ + ACE_TRACE ("ACE_FILE_IO::send"); + return ACE_OS::writev (this->get_handle (), iov, n); +} + +ACE_INLINE ssize_t +ACE_FILE_IO::recv (iovec iov[], int n) const +{ + ACE_TRACE ("ACE_FILE_IO::recv"); + return ACE_OS::readv (this->get_handle (), iov, n); +} + +#if defined (ACE_HAS_STREAM_PIPES) +ACE_INLINE ssize_t +ACE_FILE_IO::recv (ACE_Str_Buf *cntl, ACE_Str_Buf *data, int *band, int *flags) const +{ + ACE_TRACE ("ACE_FILE_IO::recv"); + return ACE_OS::getpmsg (this->get_handle (), (strbuf *) cntl, (strbuf *) data, band, flags); +} + +ACE_INLINE ssize_t +ACE_FILE_IO::send (const ACE_Str_Buf *cntl, const ACE_Str_Buf *data, int band, int flags) const +{ + ACE_TRACE ("ACE_FILE_IO::send"); + return ACE_OS::putpmsg (this->get_handle (), (strbuf *) cntl, (strbuf *) data, band, flags); +} + +ACE_INLINE ssize_t +ACE_FILE_IO::recv (ACE_Str_Buf *cntl, ACE_Str_Buf *data, int *flags) const +{ + ACE_TRACE ("ACE_FILE_IO::recv"); + return ACE_OS::getmsg (this->get_handle (), (strbuf *) cntl, (strbuf *) data, flags); +} + +ACE_INLINE ssize_t +ACE_FILE_IO::send (const ACE_Str_Buf *cntl, const ACE_Str_Buf *data, int flags) const +{ + ACE_TRACE ("ACE_FILE_IO::send"); + return ACE_OS::putmsg (this->get_handle (), (strbuf *) cntl, (strbuf *) data, flags); +} + +ACE_INLINE ssize_t +ACE_FILE_IO::send (const void *buf, size_t n, + ACE_OVERLAPPED *overlapped) const +{ + ACE_TRACE ("ACE_FILE_IO::send"); + return ACE_OS::write (this->get_handle (), + buf, n, + overlapped); +} + +ACE_INLINE ssize_t +ACE_FILE_IO::recv (void *buf, size_t n, + ACE_OVERLAPPED *overlapped) const +{ + ACE_TRACE ("ACE_FILE_IO::recv"); + return ACE_OS::read (this->get_handle (), buf, n, + overlapped); +} + +#endif /* ACE_HAS_STREAM_PIPES */ + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/File_Lock.cpp b/dep/ACE_wrappers/ace/File_Lock.cpp new file mode 100644 index 00000000000..eeba6f61430 --- /dev/null +++ b/dep/ACE_wrappers/ace/File_Lock.cpp @@ -0,0 +1,72 @@ +// $Id: File_Lock.cpp 80826 2008-03-04 14:51:23Z wotte $ + +#include "ace/File_Lock.h" +#include "ace/Log_Msg.h" + +#if !defined (__ACE_INLINE__) +#include "ace/File_Lock.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(ace, File_Lock, "$Id: File_Lock.cpp 80826 2008-03-04 14:51:23Z wotte $") + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_ALLOC_HOOK_DEFINE(ACE_File_Lock) + +void +ACE_File_Lock::dump (void) const +{ +#if defined (ACE_HAS_DUMP) +// ACE_TRACE ("ACE_File_Lock::dump"); + + ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); + this->lock_.dump (); + ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); +#endif /* ACE_HAS_DUMP */ +} + +ACE_File_Lock::ACE_File_Lock (ACE_HANDLE h, + int unlink_in_destructor) + : removed_ (0), + unlink_in_destructor_ (unlink_in_destructor) +{ +// ACE_TRACE ("ACE_File_Lock::ACE_File_Lock"); + if (ACE_OS::flock_init (&this->lock_) == -1) + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("%p\n"), + ACE_TEXT ("ACE_File_Lock::ACE_File_Lock"))); + this->set_handle (h); +} + +ACE_File_Lock::ACE_File_Lock (const ACE_TCHAR *name, + int flags, + mode_t perms, + int unlink_in_destructor) + : unlink_in_destructor_ (unlink_in_destructor) +{ +// ACE_TRACE ("ACE_File_Lock::ACE_File_Lock"); + + if (this->open (name, flags, perms) == -1) + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("%p %s\n"), + ACE_TEXT ("ACE_File_Lock::ACE_File_Lock"), + name)); +} + +int +ACE_File_Lock::open (const ACE_TCHAR *name, + int flags, + mode_t perms) +{ +// ACE_TRACE ("ACE_File_Lock::open"); + this->removed_ = 0; + return ACE_OS::flock_init (&this->lock_, flags, name, perms); +} + +ACE_File_Lock::~ACE_File_Lock (void) +{ +// ACE_TRACE ("ACE_File_Lock::~ACE_File_Lock"); + this->remove (this->unlink_in_destructor_); +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/File_Lock.h b/dep/ACE_wrappers/ace/File_Lock.h new file mode 100644 index 00000000000..12f8ed64f38 --- /dev/null +++ b/dep/ACE_wrappers/ace/File_Lock.h @@ -0,0 +1,170 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file File_Lock.h + * + * $Id: File_Lock.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Douglas C. Schmidt + */ +//============================================================================= + +#ifndef ACE_FILE_LOCK_H +#define ACE_FILE_LOCK_H +#include /**/ "ace/pre.h" + +#include /**/ "ace/ACE_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/OS_NS_stdio.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +/** + * @class ACE_File_Lock + * + * @brief A wrapper around the UNIX file locking mechanism. + * + * Allows us to "adapt" the UNIX file locking mechanisms to work + * with all of our Guard stuff... + */ +class ACE_Export ACE_File_Lock +{ +public: + /** + * Set the of the File_Lock to @a handle. Note that this + * constructor assumes ownership of the @a handle and will close it + * down in . If you want the @a handle to stay open when + * is called make sure to call on the @a handle. + * If you don't want the file unlinked in the destructor pass a + * zero value for . + */ + ACE_File_Lock (ACE_HANDLE handle = ACE_INVALID_HANDLE, + int unlink_in_destructor = 1); + + /// Open the @a filename with @a flags and @a mode and set the result + /// to . If you don't want the file unlinked in the + /// destructor pass a zero value for . + ACE_File_Lock (const ACE_TCHAR *filename, + int flags, + mode_t mode = 0, + int unlink_in_destructor = 1); + + /// Open the @a filename with @a flags and @a mode and set the result to + /// . + int open (const ACE_TCHAR *filename, + int flags, + mode_t mode = 0); + + /// Remove a File lock by releasing it and closing down the . + ~ACE_File_Lock (void); + + /// Remove a File lock by releasing it and closing down the + /// . If is non-0 then we unlink the file. + int remove (int unlink_file = 1); + + /** + * Note, for interface uniformity with other synchronization + * wrappers we include the method. This is implemented as + * a write-lock to be on the safe-side... + */ + int acquire (short whence = 0, ACE_OFF_T start = 0, ACE_OFF_T len = 1); + + /** + * Note, for interface uniformity with other synchronization + * wrappers we include the method. This is implemented + * as a write-lock to be on the safe-side... Returns -1 on failure. + * If we "failed" because someone else already had the lock, @c errno + * is set to @c EBUSY. + */ + int tryacquire (short whence = 0, ACE_OFF_T start = 0, ACE_OFF_T len = 1); + + /// Unlock a readers/writer lock. + int release (short whence = 0, ACE_OFF_T start = 0, ACE_OFF_T len = 1); + + /// Acquire a write lock, but block if any readers or a + /// writer hold the lock. + int acquire_write (short whence = 0, ACE_OFF_T start = 0, ACE_OFF_T len = 1); + + /** + * Conditionally acquire a write lock (i.e., won't block). Returns + * -1 on failure. If we "failed" because someone else already had + * the lock, @c errno is set to @c EBUSY. + */ + int tryacquire_write (short whence = 0, ACE_OFF_T start = 0, ACE_OFF_T len = 1); + + /** + * Conditionally upgrade to a write lock (i.e., won't block). Returns + * -1 on failure. If we "failed" because someone else already had + * the lock, @c errno is set to @c EBUSY. + */ + int tryacquire_write_upgrade (short whence = 0, + ACE_OFF_T start = 0, + ACE_OFF_T len = 1); + + /** + * Acquire a read lock, but block if a writer hold the lock. + * Returns -1 on failure. If we "failed" because someone else + * already had the lock, @c errno is set to @c EBUSY. + */ + int acquire_read (short whence = 0, ACE_OFF_T start = 0, ACE_OFF_T len = 1); + + /** + * Conditionally acquire a read lock (i.e., won't block). Returns + * -1 on failure. If we "failed" because someone else already had + * the lock, @c errno is set to @c EBUSY. + */ + int tryacquire_read (short whence = 0, ACE_OFF_T start = 0, ACE_OFF_T len = 1); + + /// Get underlying ACE_HANDLE for the file. + ACE_HANDLE get_handle (void) const; + + /** + * Set underlying ACE_HANDLE. Note that this method assumes + * ownership of the and will close it down in . If + * you want the to stay open when is called make + * sure to call on the before closing it. You are + * responsible for the closing the existing before + * overwriting it. + */ + void set_handle (ACE_HANDLE); + + /// Dump state of the object. + void dump (void) const; + + /// Declare the dynamic allocation hooks. + ACE_ALLOC_HOOK_DECLARE; + +protected: + /// Locking structure for OS record locks. + ACE_OS::ace_flock_t lock_; + + /// Keeps track of whether has been called yet to avoid + /// multiple calls, e.g., explicitly and implicitly in the + /// destructor. This flag isn't protected by a lock, so make sure + /// that you don't have multiple threads simultaneously calling + /// on the same object, which is a bad idea anyway... + int removed_; + + /// Keeps track of whether to unlink the underlying file in the + /// destructor. + int unlink_in_destructor_; + +private: + // = Prevent assignment and initialization. + void operator= (const ACE_File_Lock &); + ACE_File_Lock (const ACE_File_Lock &); +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +#include "ace/File_Lock.inl" +#endif /* __ACE_INLINE__ */ + +#include /**/ "ace/post.h" +#endif /* ACE_FILE_LOCK_H */ diff --git a/dep/ACE_wrappers/ace/File_Lock.inl b/dep/ACE_wrappers/ace/File_Lock.inl new file mode 100644 index 00000000000..20b00039222 --- /dev/null +++ b/dep/ACE_wrappers/ace/File_Lock.inl @@ -0,0 +1,96 @@ +// -*- C++ -*- +// +// $Id: File_Lock.inl 80826 2008-03-04 14:51:23Z wotte $ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_INLINE int +ACE_File_Lock::acquire_read (short whence, ACE_OFF_T start, ACE_OFF_T len) +{ +// ACE_TRACE ("ACE_File_Lock::acquire_read"); + return ACE_OS::flock_rdlock (&this->lock_, whence, start, len); +} + +ACE_INLINE int +ACE_File_Lock::tryacquire_read (short whence, ACE_OFF_T start, ACE_OFF_T len) +{ +// ACE_TRACE ("ACE_File_Lock::tryacquire_read"); + return ACE_OS::flock_tryrdlock (&this->lock_, whence, start, len); +} + +ACE_INLINE int +ACE_File_Lock::tryacquire_write (short whence, ACE_OFF_T start, ACE_OFF_T len) +{ +// ACE_TRACE ("ACE_File_Lock::tryacquire_write"); + return ACE_OS::flock_trywrlock (&this->lock_, whence, start, len); +} + +ACE_INLINE int +ACE_File_Lock::tryacquire_write_upgrade (short whence, + ACE_OFF_T start, + ACE_OFF_T len) +{ +// ACE_TRACE ("ACE_File_Lock::tryacquire_write_upgrade"); + return ACE_OS::flock_trywrlock (&this->lock_, whence, start, len); +} + +ACE_INLINE int +ACE_File_Lock::tryacquire (short whence, ACE_OFF_T start, ACE_OFF_T len) +{ +// ACE_TRACE ("ACE_File_Lock::tryacquire"); + return this->tryacquire_write (whence, start, len); +} + +ACE_INLINE int +ACE_File_Lock::acquire_write (short whence, ACE_OFF_T start, ACE_OFF_T len) +{ +// ACE_TRACE ("ACE_File_Lock::acquire_write"); + return ACE_OS::flock_wrlock (&this->lock_, whence, start, len); +} + +ACE_INLINE int +ACE_File_Lock::acquire (short whence, ACE_OFF_T start, ACE_OFF_T len) +{ +// ACE_TRACE ("ACE_File_Lock::acquire"); + return this->acquire_write (whence, start, len); +} + +ACE_INLINE int +ACE_File_Lock::release (short whence, ACE_OFF_T start, ACE_OFF_T len) +{ +// ACE_TRACE ("ACE_File_Lock::release"); + return ACE_OS::flock_unlock (&this->lock_, whence, start, len); +} + +ACE_INLINE int +ACE_File_Lock::remove (int unlink_file) +{ +// ACE_TRACE ("ACE_File_Lock::remove"); + + int result = 0; + + if (this->removed_ == 0) + { + this->removed_ = 1; + result = ACE_OS::flock_destroy (&this->lock_, + unlink_file); + } + return result; +} + +ACE_INLINE ACE_HANDLE +ACE_File_Lock::get_handle (void) const +{ +// ACE_TRACE ("ACE_File_Lock::get_handle"); + return this->lock_.handle_; +} + +ACE_INLINE void +ACE_File_Lock::set_handle (ACE_HANDLE h) +{ +// ACE_TRACE ("ACE_File_Lock::set_handle"); + this->lock_.handle_ = h; + this->removed_ = 0; +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Filecache.cpp b/dep/ACE_wrappers/ace/Filecache.cpp new file mode 100644 index 00000000000..3a7e3da0a4c --- /dev/null +++ b/dep/ACE_wrappers/ace/Filecache.cpp @@ -0,0 +1,754 @@ +// $Id: Filecache.cpp 80826 2008-03-04 14:51:23Z wotte $ + +#include "ace/Filecache.h" +#include "ace/Object_Manager.h" +#include "ace/Log_Msg.h" +#include "ace/ACE.h" +#include "ace/Guard_T.h" +#include "ace/OS_NS_string.h" +#include "ace/OS_NS_time.h" +#include "ace/OS_NS_unistd.h" +#include "ace/OS_NS_fcntl.h" +#include "ace/Truncate.h" + +ACE_RCSID (ace, + Filecache, + "$Id: Filecache.cpp 80826 2008-03-04 14:51:23Z wotte $") + +#if defined (ACE_WIN32) +// Specifies no sharing flags. +#define R_MASK ACE_DEFAULT_OPEN_PERMS +#define W_MASK 0 +#else +#define R_MASK S_IRUSR|S_IRGRP|S_IROTH +#define W_MASK S_IRUSR|S_IRGRP|S_IROTH|S_IWUSR|S_IWGRP|S_IWOTH +#endif /* ACE_WIN32 */ + +#if defined (ACE_WIN32) +// See if you can get rid of some of these. +#define READ_FLAGS (FILE_FLAG_SEQUENTIAL_SCAN | \ + FILE_FLAG_OVERLAPPED | \ + O_RDONLY) +// static const int RCOPY_FLAGS = (FILE_FLAG_SEQUENTIAL_SCAN | +// O_RDONLY); +#define WRITE_FLAGS (FILE_FLAG_SEQUENTIAL_SCAN | \ + FILE_FLAG_OVERLAPPED | \ + O_RDWR | O_CREAT | O_TRUNC) +// static const int WCOPY_FLAGS = (FILE_FLAG_SEQUENTIAL_SCAN | +// O_RDWR | O_CREAT | O_TRUNC); +#else +#define READ_FLAGS O_RDONLY +// static const int RCOPY_FLAGS = O_RDONLY; +#define WRITE_FLAGS (O_RDWR | O_CREAT | O_TRUNC) +// static const int WCOPY_FLAGS = O_RDWR | O_CREAT | O_TRUNC; +#endif /* ACE_WIN32 */ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +// static data members +ACE_Filecache *ACE_Filecache::cvf_ = 0; + +void +ACE_Filecache_Handle::init (void) +{ + this->file_ = 0; + this->handle_ = ACE_INVALID_HANDLE; +} + +ACE_Filecache_Handle::ACE_Filecache_Handle (void) + : file_ (0), handle_ (0), mapit_ (0) +{ + this->init (); +} + +ACE_Filecache_Handle::ACE_Filecache_Handle (const ACE_TCHAR *filename, + ACE_Filecache_Flag mapit) + : file_ (0), handle_ (0), mapit_ (mapit) +{ + this->init (); + // Fetch the file from the Virtual_Filesystem let the + // Virtual_Filesystem do the work of cache coherency. + + // Filecache will also do the acquire, since it holds the lock at + // that time. + this->file_ = ACE_Filecache::instance ()->fetch (filename, mapit); +} + +ACE_Filecache_Handle::ACE_Filecache_Handle (const ACE_TCHAR *filename, + int size, + ACE_Filecache_Flag mapit) + : file_ (0), handle_ (0), mapit_ (mapit) +{ + this->init (); + + if (size == 0) + ACE_Filecache::instance ()->remove (filename); + else + { + // Since this is being opened for a write, simply create a new + // ACE_Filecache_Object now, and let the destructor add it into CVF + // later + + // Filecache will also do the acquire, since it holds the lock at + // that time. + this->file_ = ACE_Filecache::instance ()->create (filename, size); + } +} + +ACE_Filecache_Handle::~ACE_Filecache_Handle (void) +{ + if (this->handle_ != ACE_INVALID_HANDLE) + // this was dup ()'d + ACE_OS::close (this->handle_); + + ACE_Filecache::instance ()->finish (this->file_); +} + +void * +ACE_Filecache_Handle::address (void) const +{ + return this->file_ == 0 ? 0 : this->file_->address (); +} + +ACE_HANDLE +ACE_Filecache_Handle::handle (void) const +{ + if (this->handle_ == ACE_INVALID_HANDLE && this->file_ != 0) + { + ACE_Filecache_Handle *mutable_this = + const_cast (this); + mutable_this->handle_ = ACE_OS::dup (this->file_->handle ()); + } + return this->handle_; +} + +int +ACE_Filecache_Handle::error (void) const +{ + if (this->file_ == 0) + return -1; + else + return this->file_->error (); +} + +ACE_OFF_T +ACE_Filecache_Handle::size (void) const +{ + if (this->file_ == 0) + return -1; + else + return this->file_->size (); +} + +// ------------------ +// ACE_Filecache_Hash +// ------------------ + +#define ACE_Filecache_Hash \ + ACE_Hash_Map_Manager_Ex, ACE_Equal_To, ACE_Null_Mutex> +#define ACE_Filecache_Hash_Entry \ + ACE_Hash_Map_Entry + +template <> +ACE_Filecache_Hash_Entry::ACE_Hash_Map_Entry ( + const ACE_TCHAR *const &ext_id, + ACE_Filecache_Object *const &int_id, + ACE_Filecache_Hash_Entry *next, + ACE_Filecache_Hash_Entry *prev) + : ext_id_ (ext_id + ? ACE_OS::strdup (ext_id) + : ACE_OS::strdup (ACE_TEXT (""))), + int_id_ (int_id), + next_ (next), + prev_ (prev) +{ +} + +template <> +ACE_Filecache_Hash_Entry::ACE_Hash_Map_Entry (ACE_Filecache_Hash_Entry *next, + ACE_Filecache_Hash_Entry *prev) + : ext_id_ (0), + next_ (next), + prev_ (prev) +{ +} + +template <> +ACE_Filecache_Hash_Entry::~ACE_Hash_Map_Entry (void) +{ + ACE_OS::free ((void *) ext_id_); +} + +// We need these template specializations since KEY is defined as a +// ACE_TCHAR*, which doesn't have a hash() or equal() method defined on it. + +template <> +unsigned long +ACE_Filecache_Hash::hash (const ACE_TCHAR *const &ext_id) +{ + return ACE::hash_pjw (ext_id); +} + +template <> +int +ACE_Filecache_Hash::equal (const ACE_TCHAR *const &id1, + const ACE_TCHAR *const &id2) +{ + return ACE_OS::strcmp (id1, id2) == 0; +} + +#undef ACE_Filecache_Hash +#undef ACE_Filecache_Hash_Entry + + +// ------------- +// ACE_Filecache +// ------------- + +ACE_Filecache * +ACE_Filecache::instance (void) +{ + // Double check locking pattern. + if (ACE_Filecache::cvf_ == 0) + { + ACE_SYNCH_RW_MUTEX &lock = + *ACE_Managed_Object::get_preallocated_object + (ACE_Object_Manager::ACE_FILECACHE_LOCK); + ACE_GUARD_RETURN (ACE_SYNCH_RW_MUTEX, ace_mon, lock, 0); + + // @@ James, please check each of the ACE_NEW_RETURN calls to + // make sure that it is safe to return if allocation fails. + if (ACE_Filecache::cvf_ == 0) + ACE_NEW_RETURN (ACE_Filecache::cvf_, + ACE_Filecache, + 0); + } + + return ACE_Filecache::cvf_; +} + +ACE_Filecache::ACE_Filecache (void) + : size_ (ACE_DEFAULT_VIRTUAL_FILESYSTEM_TABLE_SIZE), + hash_ (size_) +{ +} + +ACE_Filecache::~ACE_Filecache (void) +{ +} + +ACE_Filecache_Object * +ACE_Filecache::insert_i (const ACE_TCHAR *filename, + ACE_SYNCH_RW_MUTEX &filelock, + int mapit) +{ + ACE_Filecache_Object *handle = 0; + + if (this->hash_.find (filename, handle) == -1) + { + ACE_NEW_RETURN (handle, + ACE_Filecache_Object (filename, filelock, 0, mapit), + 0); + + // ACE_DEBUG ((LM_DEBUG, ACE_TEXT (" (%t) CVF: creating %s\n"), filename)); + + if (this->hash_.bind (filename, handle) == -1) + { + delete handle; + handle = 0; + } + } + else + handle = 0; + + return handle; +} + +ACE_Filecache_Object * +ACE_Filecache::remove_i (const ACE_TCHAR *filename) +{ + ACE_Filecache_Object *handle = 0; + + // Disassociate file from the cache. + if (this->hash_.unbind (filename, handle) == 0) + { + handle->stale_ = 1; + + // Try a lock. If it succeeds, we can delete it now. + // Otherwise, it will clean itself up later. + if (handle->lock_.tryacquire_write () == 0) + { + delete handle; + handle = 0; + } + } + else + handle = 0; + + return handle; +} + +ACE_Filecache_Object * +ACE_Filecache::update_i (const ACE_TCHAR *filename, + ACE_SYNCH_RW_MUTEX &filelock, + int mapit) +{ + ACE_Filecache_Object *handle = 0; + + handle = this->remove_i (filename); + handle = this->insert_i (filename, filelock, mapit); + + return handle; +} + +int +ACE_Filecache::find (const ACE_TCHAR *filename) +{ + return this->hash_.find (filename); +} + + +ACE_Filecache_Object * +ACE_Filecache::remove (const ACE_TCHAR *filename) +{ + ACE_Filecache_Object *handle = 0; + + ACE_OFF_T loc = ACE::hash_pjw (filename) % this->size_; + ACE_SYNCH_RW_MUTEX &hashlock = this->hash_lock_[loc]; + // ACE_SYNCH_RW_MUTEX &filelock = this->file_lock_[loc]; + + if (this->hash_.find (filename, handle) != -1) + { + ACE_WRITE_GUARD_RETURN (ACE_SYNCH_RW_MUTEX, + ace_mon, + hashlock, + 0); + + return this->remove_i (filename); + } + + return 0; +} + + +ACE_Filecache_Object * +ACE_Filecache::fetch (const ACE_TCHAR *filename, int mapit) +{ + ACE_Filecache_Object *handle = 0; + + ACE_OFF_T loc = ACE::hash_pjw (filename) % this->size_; + ACE_SYNCH_RW_MUTEX &hashlock = this->hash_lock_[loc]; + ACE_SYNCH_RW_MUTEX &filelock = this->file_lock_[loc]; + + filelock.acquire_read (); + + if (this->hash_.find (filename, handle) == -1) + { + ACE_WRITE_GUARD_RETURN (ACE_SYNCH_RW_MUTEX, + ace_mon, + hashlock, + 0); + + // Second check in the method call + handle = this->insert_i (filename, filelock, mapit); + + if (handle == 0) + filelock.release (); + } + else + { + if (handle->update ()) + { + { + // Double check locking pattern + ACE_WRITE_GUARD_RETURN (ACE_SYNCH_RW_MUTEX, + ace_mon, + hashlock, + 0); + + // Second check in the method call + handle = this->update_i (filename, filelock, mapit); + + if (handle == 0) + filelock.release (); + } + } + // ACE_DEBUG ((LM_DEBUG, ACE_TEXT (" (%t) CVF: found %s\n"), filename)); + } + + return handle; +} + +ACE_Filecache_Object * +ACE_Filecache::create (const ACE_TCHAR *filename, int size) +{ + ACE_Filecache_Object *handle = 0; + + ACE_OFF_T loc = ACE::hash_pjw (filename) % this->size_; + ACE_SYNCH_RW_MUTEX &filelock = this->file_lock_[loc]; + + ACE_NEW_RETURN (handle, + ACE_Filecache_Object (filename, size, filelock), + 0); + handle->acquire (); + + return handle; +} + +ACE_Filecache_Object * +ACE_Filecache::finish (ACE_Filecache_Object *&file) +{ + if (file == 0) + return file; + + ACE_OFF_T loc = ACE::hash_pjw (file->filename_) % this->size_; + ACE_SYNCH_RW_MUTEX &hashlock = this->hash_lock_[loc]; + + if (file != 0) + switch (file->action_) + { + case ACE_Filecache_Object::ACE_WRITING: + { + ACE_WRITE_GUARD_RETURN (ACE_SYNCH_RW_MUTEX, + ace_mon, + hashlock, + 0); + + file->release (); + + this->remove_i (file->filename_); +#if 0 + int result = this->hash_.bind (file->filename (), file); + + if (result == 0) + file->acquire (); +#else + // Last one using a stale file is resposible for deleting it. + if (file->stale_) + { + // Try a lock. If it succeds, we can delete it now. + // Otherwise, it will clean itself up later. + if (file->lock_.tryacquire_write () == 0) + { + delete file; + file = 0; + } + } +#endif + } + + break; + default: + file->release (); + + // Last one using a stale file is resposible for deleting it. + if (file->stale_) + { + // Try a lock. If it succeds, we can delete it now. + // Otherwise, it will clean itself up later. + if (file->lock_.tryacquire_write () == 0) + { + delete file; + file = 0; + } + } + + break; + } + + return file; +} + +void +ACE_Filecache_Object::init (void) +{ + this->filename_[0] = '\0'; + this->handle_ = ACE_INVALID_HANDLE; + this->error_ = ACE_SUCCESS; + this->tempname_ = 0; + this->size_ = 0; + + ACE_OS::memset (&(this->stat_), 0, sizeof (this->stat_)); +} + +ACE_Filecache_Object::ACE_Filecache_Object (void) + : tempname_ (0), + mmap_ (), + handle_ (0), + // stat_ (), + size_ (0), + action_ (0), + error_ (0), + stale_ (0), + // sa_ (), + junklock_ (), + lock_ (junklock_) +{ + this->init (); +} + +ACE_Filecache_Object::ACE_Filecache_Object (const ACE_TCHAR *filename, + ACE_SYNCH_RW_MUTEX &lock, + LPSECURITY_ATTRIBUTES sa, + int mapit) + : tempname_ (0), + mmap_ (), + handle_ (0), + // stat_ (), + size_ (0), + action_ (0), + error_ (0), + stale_ (0), + sa_ (sa), + junklock_ (), + lock_ (lock) +{ + this->init (); + + // ASSERT strlen(filename) < sizeof (this->filename_) + ACE_OS::strcpy (this->filename_, filename); + this->action_ = ACE_Filecache_Object::ACE_READING; + // place ourselves into the READING state + + // Can we access the file? + if (ACE_OS::access (this->filename_, R_OK) == -1) + { + this->error_i (ACE_Filecache_Object::ACE_ACCESS_FAILED); + return; + } + + // Can we stat the file? + if (ACE_OS::stat (this->filename_, &this->stat_) == -1) + { + this->error_i (ACE_Filecache_Object::ACE_STAT_FAILED); + return; + } + + this->size_ = ACE_Utils::truncate_cast (this->stat_.st_size); + this->tempname_ = this->filename_; + + // Can we open the file? + this->handle_ = ACE_OS::open (this->tempname_, + READ_FLAGS, R_MASK, this->sa_); + if (this->handle_ == ACE_INVALID_HANDLE) + { + this->error_i (ACE_Filecache_Object::ACE_OPEN_FAILED, + ACE_TEXT ("ACE_Filecache_Object::ctor: open")); + return; + } + + if (mapit) + { + // Can we map the file? + if (this->mmap_.map (this->handle_, static_cast (-1), + PROT_READ, ACE_MAP_PRIVATE, 0, 0, this->sa_) != 0) + { + this->error_i (ACE_Filecache_Object::ACE_MEMMAP_FAILED, + ACE_TEXT ("ACE_Filecache_Object::ctor: map")); + ACE_OS::close (this->handle_); + this->handle_ = ACE_INVALID_HANDLE; + return; + } + } + + // Ok, finished! + this->action_ = ACE_Filecache_Object::ACE_READING; +} + +ACE_Filecache_Object::ACE_Filecache_Object (const ACE_TCHAR *filename, + ACE_OFF_T size, + ACE_SYNCH_RW_MUTEX &lock, + LPSECURITY_ATTRIBUTES sa) + : stale_ (0), + sa_ (sa), + lock_ (lock) +{ + this->init (); + + this->size_ = size; + ACE_OS::strcpy (this->filename_, filename); + this->action_ = ACE_Filecache_Object::ACE_WRITING; + + // Can we access the file? + if (ACE_OS::access (this->filename_, R_OK|W_OK) == -1 + // Does it exist? + && ACE_OS::access (this->filename_, F_OK) != -1) + { + // File exists, but we cannot access it. + this->error_i (ACE_Filecache_Object::ACE_ACCESS_FAILED); + return; + } + + this->tempname_ = this->filename_; + + // Can we open the file? + this->handle_ = ACE_OS::open (this->tempname_, WRITE_FLAGS, W_MASK, this->sa_); + if (this->handle_ == ACE_INVALID_HANDLE) + { + this->error_i (ACE_Filecache_Object::ACE_OPEN_FAILED, + ACE_TEXT ("ACE_Filecache_Object::acquire: open")); + return; + } + + // Can we write? + if (ACE_OS::pwrite (this->handle_, "", 1, this->size_ - 1) != 1) + { + this->error_i (ACE_Filecache_Object::ACE_WRITE_FAILED, + ACE_TEXT ("ACE_Filecache_Object::acquire: write")); + ACE_OS::close (this->handle_); + return; + } + + // Can we map? + if (this->mmap_.map (this->handle_, this->size_, PROT_RDWR, MAP_SHARED, + 0, 0, this->sa_) != 0) + { + this->error_i (ACE_Filecache_Object::ACE_MEMMAP_FAILED, + ACE_TEXT ("ACE_Filecache_Object::acquire: map")); + ACE_OS::close (this->handle_); + } + + // Ok, done! +} + +ACE_Filecache_Object::~ACE_Filecache_Object (void) +{ + if (this->error_ == ACE_SUCCESS) + { + this->mmap_.unmap (); + ACE_OS::close (this->handle_); + this->handle_ = ACE_INVALID_HANDLE; + } + + this->lock_.release (); +} + +int +ACE_Filecache_Object::acquire (void) +{ + return this->lock_.tryacquire_read (); +} + +int +ACE_Filecache_Object::release (void) +{ + if (this->action_ == ACE_WRITING) + { + // We are safe since only one thread has a writable Filecache_Object + +#if 0 + ACE_HANDLE original = ACE_OS::open (this->filename_, WRITE_FLAGS, W_MASK, + this->sa_); + if (original == ACE_INVALID_HANDLE) + this->error_ = ACE_Filecache_Object::ACE_OPEN_FAILED; + else if (ACE_OS::write (original, this->mmap_.addr (), + this->size_) == -1) + { + this->error_ = ACE_Filecache_Object::ACE_WRITE_FAILED; + ACE_OS::close (original); + ACE_OS::unlink (this->filename_); + } + else if (ACE_OS::stat (this->filename_, &this->stat_) == -1) + this->error_ = ACE_Filecache_Object::ACE_STAT_FAILED; +#endif + + this->mmap_.unmap (); + ACE_OS::close (this->handle_); + this->handle_ = ACE_INVALID_HANDLE; + +#if 0 + // Leave the file in an acquirable state. + this->handle_ = ACE_OS::open (this->tempname_, READ_FLAGS, R_MASK); + if (this->handle_ == ACE_INVALID_HANDLE) + { + this->error_i (ACE_Filecache_Object::ACE_OPEN_FAILED, + "ACE_Filecache_Object::acquire: open"); + } + else if (this->mmap_.map (this->handle_, -1, + PROT_READ, + ACE_MAP_PRIVATE, + 0, + 0, + this->sa_) != 0) + { + this->error_i (ACE_Filecache_Object::ACE_MEMMAP_FAILED, + "ACE_Filecache_Object::acquire: map"); + ACE_OS::close (this->handle_); + this->handle_ = ACE_INVALID_HANDLE; + } + + this->action_ = ACE_Filecache_Object::ACE_READING; +#endif + } + + return this->lock_.release (); +} + +int +ACE_Filecache_Object::error (void) const +{ + // The existence of the object means a read lock is being held. + return this->error_; +} + +int +ACE_Filecache_Object::error_i (int error_value, const ACE_TCHAR *s) +{ + s = s; + ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p.\n"), s)); + this->error_ = error_value; + return error_value; +} + +const ACE_TCHAR * +ACE_Filecache_Object::filename (void) const +{ + // The existence of the object means a read lock is being held. + return this->filename_; +} + +ACE_OFF_T +ACE_Filecache_Object::size (void) const +{ + // The existence of the object means a read lock is being held. + return this->size_; +} + +ACE_HANDLE +ACE_Filecache_Object::handle (void) const +{ + // The existence of the object means a read lock is being held. + return this->handle_; +} + +void * +ACE_Filecache_Object::address (void) const +{ + // The existence of the object means a read lock is being held. + return this->mmap_.addr (); +} + +int +ACE_Filecache_Object::update (void) const +{ + // The existence of the object means a read lock is being held. + int result; + ACE_stat statbuf; + + if (ACE_OS::stat (this->filename_, &statbuf) == -1) + result = 1; + else + // non-portable code may follow +#if defined (ACE_HAS_WINCE) + // Yup, non-portable... there's probably a way to safely implement + // difftime() on WinCE, but for now, this will have to do. It flags + // every file as having changed since cached. + result = 1; +#else + result = ACE_OS::difftime (this->stat_.st_mtime, statbuf.st_mtime) < 0; +#endif /* ACE_HAS_WINCE */ + + return result; +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Filecache.h b/dep/ACE_wrappers/ace/Filecache.h new file mode 100644 index 00000000000..60b8a90f620 --- /dev/null +++ b/dep/ACE_wrappers/ace/Filecache.h @@ -0,0 +1,353 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Filecache.h + * + * $Id: Filecache.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author James Hu + */ +//============================================================================= + + +#ifndef ACE_FILECACHE_H +#define ACE_FILECACHE_H + +#include /**/ "ace/pre.h" + +#include "ace/Mem_Map.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/Hash_Map_Manager_T.h" +#include "ace/Null_Mutex.h" +#include "ace/Synch_Traits.h" +#include "ace/RW_Thread_Mutex.h" +#include "ace/OS_NS_sys_stat.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +enum ACE_Filecache_Flag +{ + ACE_NOMAP = 0, + ACE_MAPIT = 1 +}; + +class ACE_Filecache_Object; + +/** + * @class ACE_Filecache_Handle + * + * @brief Abstraction over a real file. This is meant to be the entry + * point into the Cached Virtual Filesystem. + * + * This is a cached filesystem implementation based loosely on the + * implementation of JAWS_File. The interfaces will be nearly the + * same. The under-the-hood implementation should hopefully be a + * much faster thing. + * These will be given their own implementations later. For now, we + * borrow the implementation provided by JAWS. + * On creation, the cache is checked, and reference count is + * incremented. On destruction, reference count is decremented. If + * the reference count is 0, the file is removed from the cache. + * E.g. 1, + * { + * ACE_Filecache_Handle foo("foo.html"); + * this->peer ().send (foo.address (), foo.size ()); + * } + * E.g. 2, + * { + * ACE_Filecache_Handle foo("foo.html"); + * io->transmitfile (foo.handle (), this->peer ().handle ()); + * } + * E.g. 3, + * { + * ACE_Filecache_Handle foo("foo.html", content_length); + * this->peer ().recv (foo.address (), content_length); + * } + * TODO: + */ +class ACE_Export ACE_Filecache_Handle +{ + // (1) Get rid of the useless copying of files when reading. + // Although it does make sure the file you send isn't being changed, + // it doesn't make sure the file is in a sensible state before + // sending it. + // + // Alternative: if the file get's trashed while it is being shipped, + // let the client request the file again. The cache should have an + // updated copy by that point. + // + // (2) Use hashing for locating files. This means I need a hastable + // implementation with buckets. + // + // (3) Only lock when absolutely necessary. JAWS_Virtual_Filesystem was + // rather conservative, but for some reason it still ran into problems. + // Since this design should be simpler, problems should be easier to spot. + // +public: + + /// Query cache for file, and acquire it. Assumes the file is being + /// opened for reading. + ACE_Filecache_Handle (const ACE_TCHAR *filename, + ACE_Filecache_Flag mapit = ACE_MAPIT); + + /** + * Create new entry, and acquire it. Presence of SIZE assumes the + * file is being opened for writing. If SIZE is zero, assumes the + * file is to be removed from the cache. + */ + ACE_Filecache_Handle (const ACE_TCHAR *filename, + int size, + ACE_Filecache_Flag mapit = ACE_MAPIT); + + /// Closes any open handles, release acquired file. + ~ACE_Filecache_Handle (void); + + /// Base address of memory mapped file. + void *address (void) const; + + /// A handle (e.g., UNIX file descriptor, or NT file handle). + ACE_HANDLE handle (void) const; + + /// Any associated error in handle creation and acquisition. + int error (void) const; + + /// The size of the file. + ACE_OFF_T size (void) const; + +protected: + /// Default do nothing constructor. Prevent it from being called. + ACE_Filecache_Handle (void); + + /// Common initializations for constructors. + void init (void); + +public: + /// These come from ACE_Filecache_Object, which is an internal class. + enum + { + ACE_SUCCESS = 0, + ACE_ACCESS_FAILED, + ACE_OPEN_FAILED, + ACE_COPY_FAILED, + ACE_STAT_FAILED, + ACE_MEMMAP_FAILED, + ACE_WRITE_FAILED + }; + +private: + /// A reference to the low level instance. + ACE_Filecache_Object *file_; + + /// A 'd version of the one from . + ACE_HANDLE handle_; + + int mapit_; +}; + +typedef ACE_Hash_Map_Manager_Ex, ACE_Equal_To, ACE_Null_Mutex> + ACE_Filecache_Hash; + +typedef ACE_Hash_Map_Entry ACE_Filecache_Hash_Entry; + +/** + * @class ACE_Filecache + * + * @brief A hash table holding the information about entry point into + * the Cached Virtual Filesystem. On insertion, the reference + * count is incremented. On destruction, reference count is + * decremented. + */ +class ACE_Export ACE_Filecache +{ +public: + /// Singleton pattern. + static ACE_Filecache *instance (void); + + ~ACE_Filecache (void); + + /// Returns 0 if the file associated with ``filename'' is in the cache, + /// or -1 if not. + int find (const ACE_TCHAR *filename); + + /// Return the file associated with ``filename'' if it is in the cache, + /// or create if not. + ACE_Filecache_Object *fetch (const ACE_TCHAR *filename, int mapit = 1); + + /// Remove the file associated with ``filename'' from the cache. + ACE_Filecache_Object *remove (const ACE_TCHAR *filename); + + /// Create a new Filecache_Object, returns it. + ACE_Filecache_Object *create (const ACE_TCHAR *filename, int size); + + /// Release an acquired Filecache_Object, returns it again or NULL if it + /// was deleted. + ACE_Filecache_Object *finish (ACE_Filecache_Object *&new_file); + +protected: + ACE_Filecache_Object *insert_i (const ACE_TCHAR *filename, + ACE_SYNCH_RW_MUTEX &filelock, + int mapit); + ACE_Filecache_Object *remove_i (const ACE_TCHAR *filename); + ACE_Filecache_Object *update_i (const ACE_TCHAR *filename, + ACE_SYNCH_RW_MUTEX &filelock, + int mapit); + +public: + + enum + { + /// For this stupid implementation, use an array. Someday, use a + /// balanced search tree, or real hash table. + ACE_DEFAULT_VIRTUAL_FILESYSTEM_TABLE_SIZE = 512, + + /// This determines the highwater mark in megabytes for the cache. + /// This will be ignored for now. + ACE_DEFAULT_VIRTUAL_FILESYSTEM_CACHE_SIZE = 20 + }; + +protected: + /// Prevent it from being called. + ACE_Filecache (void); + +private: + ACE_OFF_T size_; + + /// The hash table + ACE_Filecache_Hash hash_; + + /// The reference to the instance + static ACE_Filecache *cvf_; + + // = Synchronization variables. + ACE_SYNCH_RW_MUTEX hash_lock_[ACE_DEFAULT_VIRTUAL_FILESYSTEM_TABLE_SIZE]; + ACE_SYNCH_RW_MUTEX file_lock_[ACE_DEFAULT_VIRTUAL_FILESYSTEM_TABLE_SIZE]; +}; + +/** + * @class ACE_Filecache_Object + * + * @brief Abstraction over a real file. This is what the Virtual + * Filesystem contains. This class is not intended for general + * consumption. Please consult a physician before attempting to + * use this class. + */ +class ACE_Export ACE_Filecache_Object +{ +public: + friend class ACE_Filecache; + + /// Creates a file for reading. + ACE_Filecache_Object (const ACE_TCHAR *filename, + ACE_SYNCH_RW_MUTEX &lock, + LPSECURITY_ATTRIBUTES sa = 0, + int mapit = 1); + + /// Creates a file for writing. + ACE_Filecache_Object (const ACE_TCHAR *filename, + ACE_OFF_T size, + ACE_SYNCH_RW_MUTEX &lock, + LPSECURITY_ATTRIBUTES sa = 0); + + /// Only if reference count is zero should this be called. + ~ACE_Filecache_Object (void); + + /// Increment the reference_count_. + int acquire (void); + + /// Decrement the reference_count_. + int release (void); + + // = error_ accessors + int error (void) const; + int error (int error_value, + const ACE_TCHAR *s = ACE_TEXT ("ACE_Filecache_Object")); + + /// filename_ accessor + const ACE_TCHAR *filename (void) const; + + /// handle_ accessor. + ACE_HANDLE handle (void) const; + + /// Base memory address for memory mapped file. + void *address (void) const; + + /// size_ accessor. + ACE_OFF_T size (void) const; + + /// True if file on disk is newer than cached file. + int update (void) const; + +protected: + /// Prevent from being called. + ACE_Filecache_Object (void); + + /// Common initialization code, + void init (void); + +private: + /// Internal error logging method, no locking. + int error_i (int error_value, + const ACE_TCHAR *s = ACE_TEXT ("ACE_Filecache_Object")); + +public: + + enum Creation_States + { + ACE_READING = 1, + ACE_WRITING = 2 + }; + + enum Error_Conditions + { + ACE_SUCCESS = 0, + ACE_ACCESS_FAILED, + ACE_OPEN_FAILED, + ACE_COPY_FAILED, + ACE_STAT_FAILED, + ACE_MEMMAP_FAILED, + ACE_WRITE_FAILED + }; + +private: + /// The temporary file name and the real file name. The real file is + /// copied into the temporary file for safety reasons. + ACE_TCHAR *tempname_; + ACE_TCHAR filename_[MAXPATHLEN + 1]; + + /// Holds the memory mapped version of the temporary file. + ACE_Mem_Map mmap_; + + /// The descriptor to the temporary file. + ACE_HANDLE handle_; + + /// Used to compare against the real file to test if an update is needed. + ACE_stat stat_; + ACE_OFF_T size_; + + /// Status indicators. + int action_; + int error_; + + /// If set to 1, means the object is flagged for removal. + int stale_; + + /// Security attribute object. + LPSECURITY_ATTRIBUTES sa_; + + /// The default initializer + ACE_SYNCH_RW_MUTEX junklock_; + + /// Provides a bookkeeping mechanism for users of this object. + ACE_SYNCH_RW_MUTEX &lock_; +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#include /**/ "ace/post.h" + +#endif /* ACE_FILECACHE_H */ diff --git a/dep/ACE_wrappers/ace/Flag_Manip.cpp b/dep/ACE_wrappers/ace/Flag_Manip.cpp new file mode 100644 index 00000000000..f9ac4083fa0 --- /dev/null +++ b/dep/ACE_wrappers/ace/Flag_Manip.cpp @@ -0,0 +1,95 @@ +// $Id: Flag_Manip.cpp 80826 2008-03-04 14:51:23Z wotte $ + +#include "ace/Flag_Manip.h" + +#if defined (ACE_LACKS_FCNTL) +# include "ace/OS_NS_stropts.h" +# include "ace/OS_NS_errno.h" +#endif /* ACE_LACKS_FCNTL */ + +#if !defined (__ACE_INLINE__) +#include "ace/Flag_Manip.inl" +#endif /* __ACE_INLINE__ */ + +#if defined (CYGWIN32) +# include "ace/os_include/os_termios.h" +#endif /* CYGWIN32 */ + +ACE_RCSID (ace, + Flag_Manip, + "$Id: Flag_Manip.cpp 80826 2008-03-04 14:51:23Z wotte $") + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +// Flags are file status flags to turn on. + +int +ACE::set_flags (ACE_HANDLE handle, int flags) +{ + ACE_TRACE ("ACE::set_flags"); +#if defined (ACE_LACKS_FCNTL) + switch (flags) + { + case ACE_NONBLOCK: + // nonblocking argument (1) + // blocking: (0) + { + int nonblock = 1; + return ACE_OS::ioctl (handle, FIONBIO, &nonblock); + } + default: + ACE_NOTSUP_RETURN (-1); + } +#else + int val = ACE_OS::fcntl (handle, F_GETFL, 0); + + if (val == -1) + return -1; + + // Turn on flags. + ACE_SET_BITS (val, flags); + + if (ACE_OS::fcntl (handle, F_SETFL, val) == -1) + return -1; + else + return 0; +#endif /* ACE_LACKS_FCNTL */ +} + +// Flags are the file status flags to turn off. + +int +ACE::clr_flags (ACE_HANDLE handle, int flags) +{ + ACE_TRACE ("ACE::clr_flags"); + +#if defined (ACE_LACKS_FCNTL) + switch (flags) + { + case ACE_NONBLOCK: + // nonblocking argument (1) + // blocking: (0) + { + int nonblock = 0; + return ACE_OS::ioctl (handle, FIONBIO, &nonblock); + } + default: + ACE_NOTSUP_RETURN (-1); + } +#else + int val = ACE_OS::fcntl (handle, F_GETFL, 0); + + if (val == -1) + return -1; + + // Turn flags off. + ACE_CLR_BITS (val, flags); + + if (ACE_OS::fcntl (handle, F_SETFL, val) == -1) + return -1; + else + return 0; +#endif /* ACE_LACKS_FCNTL */ +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Flag_Manip.h b/dep/ACE_wrappers/ace/Flag_Manip.h new file mode 100644 index 00000000000..0457dcb4d95 --- /dev/null +++ b/dep/ACE_wrappers/ace/Flag_Manip.h @@ -0,0 +1,58 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Flag_Manip.h + * + * $Id: Flag_Manip.h 80826 2008-03-04 14:51:23Z wotte $ + * + * This class includes the functions used for the Flag Manipulation. + * + * @author Priyanka Gontla + */ +//============================================================================= + +#ifndef ACE_FLAG_MANIP_H +#define ACE_FLAG_MANIP_H + +#include /**/ "ace/pre.h" + +#include /**/ "ace/ACE_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/Global_Macros.h" +#include "ace/os_include/os_fcntl.h" /* For values passed to these methods */ + +#if defined (ACE_EXPORT_MACRO) +# undef ACE_EXPORT_MACRO +#endif +#define ACE_EXPORT_MACRO ACE_Export + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +namespace ACE +{ + // = Set/get/clear various flags related to I/O HANDLE. + /// Set flags associated with @a handle. + extern ACE_Export int set_flags (ACE_HANDLE handle, + int flags); + + /// Clear flags associated with @a handle. + extern ACE_Export int clr_flags (ACE_HANDLE handle, + int flags); + + /// Return the current setting of flags associated with @a handle. + ACE_NAMESPACE_INLINE_FUNCTION int get_flags (ACE_HANDLE handle); +} + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +#include "ace/Flag_Manip.inl" +#endif /* __ACE_INLINE__ */ + +#include /**/ "ace/post.h" +#endif /* ACE_FLAG_MANIP_H */ diff --git a/dep/ACE_wrappers/ace/Flag_Manip.inl b/dep/ACE_wrappers/ace/Flag_Manip.inl new file mode 100644 index 00000000000..229a4ee596c --- /dev/null +++ b/dep/ACE_wrappers/ace/Flag_Manip.inl @@ -0,0 +1,26 @@ +// -*- C++ -*- +// +// $Id: Flag_Manip.inl 80826 2008-03-04 14:51:23Z wotte $ + +#include "ace/OS_NS_fcntl.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +// Return flags currently associated with handle. +ACE_INLINE int +ACE::get_flags (ACE_HANDLE handle) +{ + ACE_TRACE ("ACE::get_flags"); + +#if defined (ACE_LACKS_FCNTL) + // ACE_OS::fcntl is not supported. It + // would be better to store ACE's notion of the flags + // associated with the handle, but this works for now. + ACE_UNUSED_ARG (handle); + return 0; +#else + return ACE_OS::fcntl (handle, F_GETFL, 0); +#endif /* ACE_LACKS_FCNTL */ +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Framework_Component.cpp b/dep/ACE_wrappers/ace/Framework_Component.cpp new file mode 100644 index 00000000000..48d3043594b --- /dev/null +++ b/dep/ACE_wrappers/ace/Framework_Component.cpp @@ -0,0 +1,279 @@ +// Framework_Component.cpp +// $Id: Framework_Component.cpp 82238 2008-07-02 12:05:46Z sma $ + +#include "ace/Framework_Component.h" + +#if !defined (__ACE_INLINE__) +#include "ace/Framework_Component.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/Object_Manager.h" +#include "ace/Log_Msg.h" +#include "ace/DLL_Manager.h" +#include "ace/Recursive_Thread_Mutex.h" +#include "ace/OS_NS_string.h" + +ACE_RCSID(ace, Framework_Component, "$Id: Framework_Component.cpp 82238 2008-07-02 12:05:46Z sma $") + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_Framework_Component::~ACE_Framework_Component (void) +{ + ACE_TRACE ("ACE_Framework_Component::~ACE_Framework_Component"); + + ACE::strdelete (const_cast (this->dll_name_)); + ACE::strdelete (const_cast (this->name_)); +} + +/***************************************************************/ + +ACE_ALLOC_HOOK_DEFINE(ACE_Framework_Repository) + +sig_atomic_t ACE_Framework_Repository::shutting_down_ = 0; + +// Pointer to the Singleton instance. +ACE_Framework_Repository *ACE_Framework_Repository::repository_ = 0; + +ACE_Framework_Repository::~ACE_Framework_Repository (void) +{ + ACE_TRACE ("ACE_Framework_Repository::~ACE_Framework_Repository"); + this->close (); +} + +int +ACE_Framework_Repository::open (int size) +{ + ACE_TRACE ("ACE_Framework_Repository::open"); + + ACE_Framework_Component **temp = 0; + + ACE_NEW_RETURN (temp, + ACE_Framework_Component *[size], + -1); + + this->component_vector_ = temp; + this->total_size_ = size; + return 0; +} + +int +ACE_Framework_Repository::close (void) +{ + ACE_TRACE ("ACE_Framework_Repository::close"); + ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1)); + + this->shutting_down_ = 1; + + if (this->component_vector_ != 0) + { + // Delete components in reverse order. + for (int i = this->current_size_ - 1; i >= 0; i--) + if (this->component_vector_[i]) + { + ACE_Framework_Component *s = + const_cast ( + this->component_vector_[i]); + + this->component_vector_[i] = 0; + delete s; + } + + delete [] this->component_vector_; + this->component_vector_ = 0; + this->current_size_ = 0; + } + + ACE_DLL_Manager::close_singleton (); + return 0; +} + +ACE_Framework_Repository * +ACE_Framework_Repository::instance (int size) +{ + ACE_TRACE ("ACE_Framework_Repository::instance"); + + if (ACE_Framework_Repository::repository_ == 0) + { + // Perform Double-Checked Locking Optimization. + ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon, + *ACE_Static_Object_Lock::instance (), 0)); + if (ACE_Framework_Repository::repository_ == 0) + { + if (ACE_Object_Manager::starting_up () || + !ACE_Object_Manager::shutting_down ()) + { + ACE_NEW_RETURN (ACE_Framework_Repository::repository_, + ACE_Framework_Repository (size), + 0); + } + } + } + + return ACE_Framework_Repository::repository_; +} + +void +ACE_Framework_Repository::close_singleton (void) +{ + ACE_TRACE ("ACE_Framework_Repository::close_singleton"); + + ACE_MT (ACE_GUARD (ACE_Recursive_Thread_Mutex, ace_mon, + *ACE_Static_Object_Lock::instance ())); + + delete ACE_Framework_Repository::repository_; + ACE_Framework_Repository::repository_ = 0; +} + +int +ACE_Framework_Repository::register_component (ACE_Framework_Component *fc) +{ + ACE_TRACE ("ACE_Framework_Repository::register_component"); + ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1)); + int i; + + // Check to see if it's already registered + for (i = 0; i < this->current_size_; i++) + if (this->component_vector_[i] && + fc->this_ == this->component_vector_[i]->this_) + { + ACE_ERROR_RETURN ((LM_ERROR, + "AFR::register_component: error, compenent already registered\n"), + -1); + } + + if (i < this->total_size_) + { + this->component_vector_[i] = fc; + this->current_size_++; + return 0; + } + + return -1; +} + +int +ACE_Framework_Repository::remove_component (const ACE_TCHAR *name) +{ + ACE_TRACE ("ACE_Framework_Repository::remove_component"); + ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1)); + int i; + + for (i = 0; i < this->current_size_; i++) + if (this->component_vector_[i] && + ACE_OS::strcmp (this->component_vector_[i]->name_, name) == 0) + { + delete this->component_vector_[i]; + this->component_vector_[i] = 0; + this->compact (); + return 0; + } + + return -1; +} + +int +ACE_Framework_Repository::remove_dll_components (const ACE_TCHAR *dll_name) +{ + ACE_TRACE ("ACE_Framework_Repository::remove_dll_components"); + + if (this->shutting_down_) + return this->remove_dll_components_i (dll_name); + ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1)); + + return this->remove_dll_components_i (dll_name); +} + +int +ACE_Framework_Repository::remove_dll_components_i (const ACE_TCHAR *dll_name) +{ + ACE_TRACE ("ACE_Framework_Repository::remove_dll_components_i"); + + int i; + int retval = -1; + + for (i = 0; i < this->current_size_; i++) + if (this->component_vector_[i] && + ACE_OS::strcmp (this->component_vector_[i]->dll_name_, dll_name) == 0) + { + if (ACE::debug ()) + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("AFR::remove_dll_components_i (%s) ") + ACE_TEXT ("component \"%s\"\n"), + dll_name, this->component_vector_[i]->name_)); + delete this->component_vector_[i]; + this->component_vector_[i] = 0; + ++retval; + } + + this->compact (); + + return retval == -1 ? -1 : 0; +} + +void +ACE_Framework_Repository::compact (void) +{ + ACE_TRACE ("ACE_Framework_Repository::compact"); + + int i; + int start_hole; + int end_hole; + + do + { + start_hole = this->current_size_; + end_hole = this->current_size_; + + // Find hole + for (i = 0; i < this->current_size_; ++i) + { + if (this->component_vector_[i] == 0) + { + if (start_hole == this->current_size_) + { + start_hole = i; + end_hole = i; + } + else + end_hole = i; + } + else if (end_hole != this->current_size_) + break; + } + + if (start_hole != this->current_size_) + { + // move the contents and reset current_size_ + while (end_hole + 1 < this->current_size_) + { + this->component_vector_[start_hole++] = + this->component_vector_[++end_hole]; + } + // Since start_hole is now one past the last + // active slot. + this->current_size_ = start_hole; + } + + } while (start_hole != this->current_size_); +} + +void +ACE_Framework_Repository::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + ACE_TRACE ("ACE_Framework_Repository::dump"); +#endif /* ACE_HAS_DUMP */ +} + +ACE_Framework_Repository::ACE_Framework_Repository (int size) + : current_size_ (0) +{ + ACE_TRACE ("ACE_Framework_Repository::ACE_Framework_Repository"); + + if (this->open (size) == -1) + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("%p\n"), + ACE_TEXT ("ACE_Framework_Repository"))); +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Framework_Component.h b/dep/ACE_wrappers/ace/Framework_Component.h new file mode 100644 index 00000000000..941960bf047 --- /dev/null +++ b/dep/ACE_wrappers/ace/Framework_Component.h @@ -0,0 +1,210 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Framework_Component.h + * + * $Id: Framework_Component.h 80826 2008-03-04 14:51:23Z wotte $ + * + * A prototype mechanism that allows framework components, singletons + * such as ACE_Reactor, ACE_Proactor, etc, to be registered with a + * central repository managed by the ACE_Object_Manager or + * ACE_Service_Config that will handle destruction. + * + * This technique obviates changing ACE_Object_Manager and + * ACE_Service_Config everytime a new framework is added. Which also + * means that unused framework components don't need to linked into + * the final application which is important for applications with + * stringent footprint requirements. + * + * Framework components need only provide a static method, + * close_singleton() and add the ACE_REGISTER_FRAMEWORK_COMPONENT macro + * call to their instance() methods in order to participate. Components + * that don't have a close_singleton() method can also participate via + * template specialization of ACE_Framework_Component_T. + * + * This design uses the External Polymorphism pattern to avoid having + * to derive all framework components from a common base class that + * has virtual methods (this is crucial to avoid unnecessary overhead), + * and is based on the dump debugging implementation found in + * . + * + * @author Don Hinton . + */ +//============================================================================= + +#ifndef ACE_FRAMEWORK_COMPONENT_H +#define ACE_FRAMEWORK_COMPONENT_H +#include /**/ "ace/pre.h" + +#include /**/ "ace/ACE_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/os_include/os_signal.h" +#include "ace/Thread_Mutex.h" + +#define ACE_DEFAULT_FRAMEWORK_REPOSITORY_SIZE 1024 + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +/** + * @class ACE_Framework_Component + * + * @brief Base class that defines a uniform interface for all managed + * framework components. + */ +class ACE_Export ACE_Framework_Component +{ +public: + friend class ACE_Framework_Repository; + + /// Constructor. + ACE_Framework_Component (void *_this, + const ACE_TCHAR *dll_name = 0, + const ACE_TCHAR *name = 0); + + /// Close the contained singleton. + virtual void close_singleton (void) = 0; + +protected: + /// Destructor. + virtual ~ACE_Framework_Component (void); + +private: + // No copy possible + ACE_Framework_Component (const ACE_Framework_Component &); + void operator= (const ACE_Framework_Component &); + +private: + /// Pointer to the actual component. + const void *this_; + + /// Library associated with this component + const ACE_TCHAR *dll_name_; + + /// Component name + const ACE_TCHAR *name_; +}; + +/** + * @class ACE_Framework_Repository + * + * @brief Contains all framework components used by an application. + * + * This class contains a vector of ACE_Framework_Component *'s. On + * destruction, framework components are destroyed in the reverse order + * that they were added originally. + */ +class ACE_Export ACE_Framework_Repository +{ +public: + // This is just to silence a compiler warning about no public ctors + friend class ACE_Framework_Component; + + enum + { + DEFAULT_SIZE = ACE_DEFAULT_FRAMEWORK_REPOSITORY_SIZE + }; + + /// Close down the repository and free up dynamically allocated + /// resources. + ~ACE_Framework_Repository (void); + + /// Initialize the repository. + int open (int size = DEFAULT_SIZE); + + /// Close down the repository and free up dynamically allocated + /// resources, also called by dtor. + int close (void); + + /// Get pointer to a process-wide ACE_Framework_Repository. + static ACE_Framework_Repository *instance + (int size = ACE_Framework_Repository::DEFAULT_SIZE); + + /// Delete the dynamically allocated Singleton. + static void close_singleton (void); + + // = Search structure operations (all acquire locks as necessary). + + /// Insert a new component. Returns -1 when the repository is full + /// and 0 on success. + int register_component (ACE_Framework_Component *fc); + + /// Remove a component. Returns -1 on error or if component not found + /// and 0 on success. + int remove_component (const ACE_TCHAR *name); + + /// Remove all components associated with a particular dll. + int remove_dll_components (const ACE_TCHAR *dll_name); + + /// Return the current size of the repository. + int current_size (void) const; + + /// Return the total size of the repository. + int total_size (void) const; + + /// Dump the state of an object. + void dump (void) const; + + /// Declare the dynamic allocation hooks. + ACE_ALLOC_HOOK_DECLARE; + +protected: + + /// Initialize the repository. + ACE_Framework_Repository (int size = ACE_Framework_Repository::DEFAULT_SIZE); + +private: + + /// Actually removes the dll components, must be called with locks held. + int remove_dll_components_i (const ACE_TCHAR *dll_name); + + /// Compact component_vector_ after components have been removed__maintains + /// order. + void compact (void); + + /// Disallow copying and assignment. + ACE_Framework_Repository (const ACE_Framework_Repository &); + ACE_Framework_Repository &operator= (const ACE_Framework_Repository &); + +private: + + /// Contains all the framework components. + ACE_Framework_Component **component_vector_; + + /// Current number of components. + int current_size_; + + /// Maximum number of components. + int total_size_; + + /// Pointer to a process-wide ACE_Framework_Repository. + static ACE_Framework_Repository *repository_; + + /// Flag set when repository is the process of shutting down. This + /// is necessary to keep from self-deadlocking since some of + /// the components might make calls back to the repository to + /// unload their components, e.g., ACE_DLL_Manager. + static sig_atomic_t shutting_down_; + +#if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0) + /// Synchronization variable for the MT_SAFE Repository + ACE_Thread_Mutex lock_; +#endif /* ACE_MT_SAFE */ + +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +#include "ace/Framework_Component.inl" +#endif /* __ACE_INLINE__ */ + +// Include the templates classes at this point. +#include "ace/Framework_Component_T.h" + +#include /**/ "ace/post.h" +#endif /* ACE_FRAMEWORK_COMPONENT_H */ diff --git a/dep/ACE_wrappers/ace/Framework_Component.inl b/dep/ACE_wrappers/ace/Framework_Component.inl new file mode 100644 index 00000000000..1fb2de38b85 --- /dev/null +++ b/dep/ACE_wrappers/ace/Framework_Component.inl @@ -0,0 +1,39 @@ +// -*- C++ -*- +// +// $Id: Framework_Component.inl 80826 2008-03-04 14:51:23Z wotte $ + +#include "ace/ACE.h" +#include "ace/Guard_T.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_INLINE +ACE_Framework_Component::ACE_Framework_Component (void *_this, + const ACE_TCHAR *dll_name, + const ACE_TCHAR *name) + : this_ (_this), + dll_name_ (ACE::strnew (dll_name ? dll_name : ACE_TEXT (""))), + name_ (ACE::strnew (name ? name : ACE_TEXT (""))) +{ + ACE_TRACE ("ACE_Framework_Component::ctor"); +} + +/***************************************************************/ + +ACE_INLINE int +ACE_Framework_Repository::current_size (void) const +{ + ACE_TRACE ("ACE_Framework_Repository::current_size"); + ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, (ACE_Thread_Mutex &) this->lock_, -1)); + return this->current_size_; +} + +ACE_INLINE int +ACE_Framework_Repository::total_size (void) const +{ + ACE_TRACE ("ACE_Framework_Repository::total_size"); + ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, (ACE_Thread_Mutex &) this->lock_, -1)); + return this->total_size_; +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Framework_Component_T.cpp b/dep/ACE_wrappers/ace/Framework_Component_T.cpp new file mode 100644 index 00000000000..6f0be7b5e2a --- /dev/null +++ b/dep/ACE_wrappers/ace/Framework_Component_T.cpp @@ -0,0 +1,33 @@ +// $Id: Framework_Component_T.cpp 80826 2008-03-04 14:51:23Z wotte $ + +#ifndef ACE_FRAMEWORK_COMPONENT_T_CPP +#define ACE_FRAMEWORK_COMPONENT_T_CPP + +#include "ace/Framework_Component_T.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +template +ACE_Framework_Component_T::ACE_Framework_Component_T (Concrete *concrete) + : ACE_Framework_Component ((void *) concrete, concrete->dll_name (), concrete->name ()) +{ + ACE_TRACE ("ACE_Framework_Component_T::ctor"); +} + +template +ACE_Framework_Component_T::~ACE_Framework_Component_T (void) +{ + ACE_TRACE ("ACE_Framework_Component_T::~ACE_Framework_Component_T"); + Concrete::close_singleton (); +} + +template void +ACE_Framework_Component_T::close_singleton (void) +{ + ACE_TRACE ("ACE_Framework_Component_T::close_singleton"); + Concrete::close_singleton (); +} + +ACE_END_VERSIONED_NAMESPACE_DECL + +#endif /* ACE_FRAMEWORK_COMPONENT_T_CPP */ diff --git a/dep/ACE_wrappers/ace/Framework_Component_T.h b/dep/ACE_wrappers/ace/Framework_Component_T.h new file mode 100644 index 00000000000..2dcef43e384 --- /dev/null +++ b/dep/ACE_wrappers/ace/Framework_Component_T.h @@ -0,0 +1,71 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Framework_Component_T.h + * + * $Id: Framework_Component_T.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Don Hinton + */ +//============================================================================= + +#ifndef ACE_FRAMEWORK_COMPONENT_T_H +#define ACE_FRAMEWORK_COMPONENT_T_H +#include /**/ "ace/pre.h" +#include "ace/Framework_Component.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +/** + * @class ACE_Framework_Component_T + * + * @brief This class inherits the interface of the abstract + * ACE_Framework_Component class and is instantiated with the + * implementation of the concrete component class @c class Concrete. + * + * This design is similar to the Adapter and Decorator patterns + * from the ``Gang of Four'' book. Note that @c class Concrete + * need not inherit from a common class since ACE_Framework_Component + * provides the uniform virtual interface! (implementation based on + * ACE_Dumpable_Adapter in . + */ +template +class ACE_Framework_Component_T : public ACE_Framework_Component +{ +public: + // = Initialization and termination methods. + + /// Constructor. + ACE_Framework_Component_T (Concrete *concrete); + + /// Destructor. + ~ACE_Framework_Component_T (void); + + /// Close the contained singleton. + void close_singleton (void); +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +// This macro should be called in the instance() method +// of the Concrete class that will be managed. Along +// with the appropriate template instantiation. +#define ACE_REGISTER_FRAMEWORK_COMPONENT(CLASS, INSTANCE) \ + ACE_Framework_Repository::instance ()->register_component \ + (new ACE_Framework_Component_T (INSTANCE)); + +#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) +#include "ace/Framework_Component_T.cpp" +#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ + +#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) +#pragma implementation ("Framework_Component_T.cpp") +#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ + +#include /**/ "ace/post.h" +#endif /* ACE_FRAMEWORK_COMPONENT_T_H */ diff --git a/dep/ACE_wrappers/ace/Free_List.cpp b/dep/ACE_wrappers/ace/Free_List.cpp new file mode 100644 index 00000000000..4da723f4898 --- /dev/null +++ b/dep/ACE_wrappers/ace/Free_List.cpp @@ -0,0 +1,163 @@ +// $Id: Free_List.cpp 81107 2008-03-27 11:12:42Z johnnyw $ + +#ifndef ACE_FREE_LIST_CPP +#define ACE_FREE_LIST_CPP + +#include "ace/Free_List.h" +#include "ace/Guard_T.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +template +ACE_Free_List::~ACE_Free_List (void) +{ +} + +// Default constructor that takes in a preallocation number +// (), a low and high water mark ( and ) and an +// increment value () + +template +ACE_Locked_Free_List::ACE_Locked_Free_List (int mode, + size_t prealloc, + size_t lwm, + size_t hwm, + size_t inc) + : mode_ (mode), + free_list_ (0), + lwm_ (lwm), + hwm_ (hwm), + inc_ (inc), + size_ (0) +{ + this->alloc (prealloc); +} + +// Destructor - removes all the elements from the free_list + +template +ACE_Locked_Free_List::~ACE_Locked_Free_List (void) +{ + if (this->mode_ != ACE_PURE_FREE_LIST) + while (this->free_list_ != 0) + { + T *temp = this->free_list_; + this->free_list_ = this->free_list_->get_next (); + delete temp; + } +} + +// Inserts an element onto the free list (if we are allowed to manage +// elements withing and it pasts the high water mark, delete the +// element) + +template void +ACE_Locked_Free_List::add (T *element) +{ + ACE_MT (ACE_GUARD (ACE_LOCK, ace_mon, this->mutex_)); + + // Check to see that we not at the high water mark. + if (this->mode_ == ACE_PURE_FREE_LIST + || this->size_ < this->hwm_) + { + element->set_next (this->free_list_); + this->free_list_ = element; + this->size_++; + } + else + delete element; +} + +// Takes a element off the freelist and returns it. It creates +// new elements if we are allowed to do it and the size is at the low +// water mark. + +template T * +ACE_Locked_Free_List::remove (void) +{ + ACE_MT (ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->mutex_, 0)); + + // If we are at the low water mark, add some nodes + if (this->mode_ != ACE_PURE_FREE_LIST && this->size_ <= this->lwm_) + this->alloc (this->inc_); + + // Remove a node + T *temp = this->free_list_; + + if (temp != 0) + { + this->free_list_ = this->free_list_->get_next (); + this->size_--; + } + + return temp; +} + + +// Returns the current size of the free list + +template size_t +ACE_Locked_Free_List::size (void) +{ + return this->size_; +} + +// Resizes the free list to + +template void +ACE_Locked_Free_List::resize (size_t newsize) +{ + ACE_MT (ACE_GUARD (ACE_LOCK, ace_mon, this->mutex_)); + + // Check if we are allowed to resize + if (this->mode_ != ACE_PURE_FREE_LIST) + { + // Check to see if we grow or shrink + if (newsize < this->size_) + { + this->dealloc (this->size_ - newsize); + } + else + { + this->alloc (newsize - this->size_); + } + } +} + +// Allocates extra nodes for the freelist + +template void +ACE_Locked_Free_List::alloc (size_t n) +{ + for (; n > 0; n--) + { + T *temp = 0; + ACE_NEW (temp, T); + temp->set_next (this->free_list_); + this->free_list_ = temp; + this->size_++; + } +} + +// Removes and frees nodes from the freelist. + +template void +ACE_Locked_Free_List::dealloc (size_t n) +{ + for (; this->free_list_ != 0 && n > 0; + n--) + { + T *temp = this->free_list_; + this->free_list_ = this->free_list_->get_next (); + delete temp; + this->size_--; + } +} + +ACE_END_VERSIONED_NAMESPACE_DECL + +#endif /* ACE_FREE_LIST_CPP */ diff --git a/dep/ACE_wrappers/ace/Free_List.h b/dep/ACE_wrappers/ace/Free_List.h new file mode 100644 index 00000000000..3d429dcafcb --- /dev/null +++ b/dep/ACE_wrappers/ace/Free_List.h @@ -0,0 +1,150 @@ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file Free_List.h + * + * $Id: Free_List.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Darrell Brunsch (brunsch@cs.wustl.edu) + */ +//============================================================================= + +#ifndef ACE_FREE_LIST_H +#define ACE_FREE_LIST_H +#include /**/ "ace/pre.h" + +#include /**/ "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/Global_Macros.h" +#include "ace/Default_Constants.h" +#include "ace/os_include/os_stddef.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +/** + * @class ACE_Free_List + * + * @brief Implements a free list. + * + * This class maintains a free list of nodes of type T. + */ +template +class ACE_Free_List +{ +public: + /// Destructor - removes all the elements from the free_list. + virtual ~ACE_Free_List (void); + + /// Inserts an element onto the free list (if it isn't past the high + /// water mark). + virtual void add (T *element) = 0; + + /// Takes a element off the freelist and returns it. It creates + /// new elements if the size is at or below the low water mark. + virtual T *remove (void) = 0; + + /// Returns the current size of the free list. + virtual size_t size (void) = 0; + + /// Resizes the free list to @a newsize. + virtual void resize (size_t newsize) = 0; +}; + +/** + * @class ACE_Locked_Free_List + * + * @brief Implements a free list. + * + * This class maintains a free list of nodes of type T. It + * depends on the type T having a and + * method. It maintains a mutex so the freelist can be used in + * a multithreaded program . + */ +template +class ACE_Locked_Free_List : public ACE_Free_List +{ +public: + // = Initialization and termination. + /** + * Constructor takes a @a mode (i.e., ACE_FREE_LIST_WITH_POOL or + * ACE_PURE_FREE_LIST), a count of the number of nodes to + * , a low and high water mark ( and ) that + * indicate when to allocate more nodes, an increment value () + * that indicates how many nodes to allocate when the list must + * grow. + */ + ACE_Locked_Free_List (int mode = ACE_FREE_LIST_WITH_POOL, + size_t prealloc = ACE_DEFAULT_FREE_LIST_PREALLOC, + size_t lwm = ACE_DEFAULT_FREE_LIST_LWM, + size_t hwm = ACE_DEFAULT_FREE_LIST_HWM, + size_t inc = ACE_DEFAULT_FREE_LIST_INC); + + /// Destructor - removes all the elements from the free_list. + virtual ~ACE_Locked_Free_List (void); + + /// Inserts an element onto the free list (if it isn't past the high + /// water mark). + virtual void add (T *element); + + /// Takes a element off the freelist and returns it. It creates + /// new elements if the size is at or below the low water mark. + virtual T *remove (void); + + /// Returns the current size of the free list. + virtual size_t size (void); + + /// Resizes the free list to @a newsize. + virtual void resize (size_t newsize); + +protected: + /// Allocates @a n extra nodes for the freelist. + virtual void alloc (size_t n); + + /// Removes and frees @a n nodes from the freelist. + virtual void dealloc (size_t n); + + /// Free list operation mode, either ACE_FREE_LIST_WITH_POOL or + /// ACE_PURE_FREE_LIST. + int mode_; + + /// Pointer to the first node in the freelist. + T *free_list_; + + /// Low water mark. + size_t lwm_; + + /// High water mark. + size_t hwm_; + + /// Increment value. + size_t inc_; + + /// Keeps track of the size of the list. + size_t size_; + + /// Synchronization variable for ACE_Timer_Queue. + ACE_LOCK mutex_; + +private: + // = Don't allow these operations for now. + ACE_UNIMPLEMENTED_FUNC (ACE_Locked_Free_List (const ACE_Locked_Free_List &)) + ACE_UNIMPLEMENTED_FUNC (void operator= (const ACE_Locked_Free_List &)) +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) +#include "ace/Free_List.cpp" +#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ + +#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) +#pragma implementation ("Free_List.cpp") +#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ + +#include /**/ "ace/post.h" +#endif /* ACE_FREE_LIST_H */ diff --git a/dep/ACE_wrappers/ace/Functor.cpp b/dep/ACE_wrappers/ace/Functor.cpp new file mode 100644 index 00000000000..429aaac9f22 --- /dev/null +++ b/dep/ACE_wrappers/ace/Functor.cpp @@ -0,0 +1,43 @@ + +//============================================================================= +/** + * @file Functor.cpp + * + * $Id: Functor.cpp 80826 2008-03-04 14:51:23Z wotte $ + * + * Non-inlinable method definitions for non-templatized classes + * and template specializations implementing the GOF Command Pattern, + * and STL-style functors. + * + * + * @author Chris Gill + * + * Based on Command Pattern implementations originally done by + * + * Carlos O'Ryan + * Douglas C. Schmidt + * Sergio Flores-Gaitan + * + * and on STL-style functor implementations originally done by + * + * Irfan Pyarali + */ +//============================================================================= + + +#include "ace/Functor_T.h" +#include "ace/Functor.h" + +#if !defined (__ACE_INLINE__) +#include "ace/Functor.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(ace, Functor, "$Id: Functor.cpp 80826 2008-03-04 14:51:23Z wotte $") + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_Command_Base::~ACE_Command_Base (void) +{ +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Functor.h b/dep/ACE_wrappers/ace/Functor.h new file mode 100644 index 00000000000..8504cf0764b --- /dev/null +++ b/dep/ACE_wrappers/ace/Functor.h @@ -0,0 +1,593 @@ +// -*- C++ -*- + +//========================================================================== +/** + * @file Functor.h + * + * $Id: Functor.h 80826 2008-03-04 14:51:23Z wotte $ + * + * Non-templatized classes and class template specializations for + * implementing function objects that are used in various places + * in ACE. There are currently two major categories of function + * objects in ACE: GoF Command Pattern objects, and STL-style + * functors for comparison of container elements. The command objects + * are invoked via an execute () method, while the STL-style functors are + * invoked via an operator() () method. + * Non-templatized classes for implementing the GoF Command Pattern, + * also known as functors or function objects. + * + * + * @author Chris Gill + * @author Based on Command Pattern implementations originally done by + * @author Carlos O'Ryan + * @author Douglas C. Schmidt + * @author Sergio Flores-Gaitan + * @author and on STL-style functor implementations originally done by + * @author Irfan Pyarali + */ +//========================================================================== + + +#ifndef ACE_FUNCTOR_H +#define ACE_FUNCTOR_H +#include /**/ "ace/pre.h" + +#include /**/ "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include /**/ "ace/ACE_export.h" +#include "ace/Basic_Types.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +////////////////////////////////////////////////////////////// +// GOF Command Pattern Classes and Template Specializations // +////////////////////////////////////////////////////////////// + +/** + * @class ACE_Command_Base + * + * @brief Defines an abstract class that allows us to invoke commands + * without knowing anything about the implementation. + * + * This class declares an interface to execute a command + * independent of the effect of the command, or the objects used + * to implement it. + */ +class ACE_Export ACE_Command_Base +{ +public: + // = Initialization and termination methods. + /// Default constructor. + ACE_Command_Base (void); + + /// Virtual destructor. + virtual ~ACE_Command_Base (void); + + /** + * Invokes the method encapsulated by the command, passing along the + * passed argument (if any). Users of classes derived from this + * class must ensure that the resulting invocation can tolerate a + * null void pointer being passed, or otherwise ensure that this + * will never occur. + */ + virtual int execute (void *arg = 0) = 0; +}; + +//////////////////////////////////////////////////////////// +// STL-style Functor Classes and Template Specializations // +//////////////////////////////////////////////////////////// + +// Forward declaration since we are going to specialize that template +// here. The template itself requires this file so every user of the +// template should also see the specialization. +template class ACE_Hash; +template class ACE_Equal_To; +template class ACE_Less_Than; + +/** + * @class ACE_Hash + * + * @brief Function object for hashing a char + */ +template<> +class ACE_Export ACE_Hash +{ +public: + /// Simply returns t + unsigned long operator () (char t) const; +}; + +/** + * @class ACE_Hash + * + * @brief Function object for hashing a signed char + */ +template<> +class ACE_Export ACE_Hash +{ +public: + /// Simply returns t + unsigned long operator () (signed char t) const; +}; + +/** + * @class ACE_Hash + * + * @brief Function object for hashing an unsigned char + */ +template<> +class ACE_Export ACE_Hash +{ +public: + /// Simply returns t + unsigned long operator () (unsigned char t) const; +}; + +#if 0 +// @@ ADD HASHES FOR ACE TYPES + +/** + * @class ACE_Hash + * + * @brief Function object for hashing a 16-bit signed number + */ +template<> +class ACE_Export ACE_Hash +{ +public: + /// Simply returns t + unsigned long operator () (ACE_INT16 t) const; +}; + +/** + * @class ACE_Hash + * + * @brief Function object for hashing a 16-bit unsigned number + */ +template<> +class ACE_Export ACE_Hash +{ +public: + /// Simply returns t + unsigned long operator () (ACE_UINT16 t) const; +}; + +/** + * @class ACE_Hash + * + * @brief Function object for hashing a 32-bit signed number + */ +template<> +class ACE_Export ACE_Hash +{ +public: + /// Simply returns t + unsigned long operator () (ACE_INT32 t) const; +}; + +/** + * @class ACE_Hash + * + * @brief Function object for hashing a 32-bit unsigned number + */ +template<> +class ACE_Export ACE_Hash +{ +public: + /// Simply returns t + unsigned long operator () (ACE_UINT32 t) const; +}; + +/** + * @class ACE_Hash + * + * @brief Function object for hashing a 64-bit unsigned number + */ +template<> +class ACE_Export ACE_Hash +{ +public: + /// Simply returns t + unsigned long operator () (ACE_UINT64 t) const; +}; + +// @@ DONE ADDING HASHES FOR ACE TYPES +#endif + +/** + * @class ACE_Hash + * + * @brief Function object for hashing a short number + */ +template<> +class ACE_Export ACE_Hash +{ +public: + /// Simply returns t + unsigned long operator () (short t) const; +}; + +/** + * @class ACE_Hash + * + * @brief Function object for hashing an unsigned short number + */ +template<> +class ACE_Export ACE_Hash +{ +public: + /// Simply returns t + unsigned long operator () (unsigned short t) const; +}; + +/** + * @class ACE_Hash + * + * @brief Function object for hashing an int number + */ +template<> +class ACE_Export ACE_Hash +{ +public: + /// Simply returns t + unsigned long operator () (int t) const; +}; + +/** + * @class ACE_Hash + * + * @brief Function object for hashing an unsigned int number + */ +template<> +class ACE_Export ACE_Hash +{ +public: + /// Simply returns t + unsigned long operator () (unsigned int t) const; +}; + +/** + * @class ACE_Hash + * + * @brief Function object for hashing a long number + */ +template<> +class ACE_Export ACE_Hash +{ +public: + /// Simply returns t + unsigned long operator () (long t) const; +}; + +/** + * @class ACE_Hash + * + * @brief Function object for hashing an unsigned long number + */ +template<> +class ACE_Export ACE_Hash +{ +public: + /// Simply returns t + unsigned long operator () (unsigned long t) const; +}; + +#if !defined (ACE_LACKS_LONGLONG_T) && (ACE_SIZEOF_LONG < 8) +/** + * @class ACE_Hash + * + * @brief Function object for hashing a signed 64-bit number + */ +template<> +class ACE_Export ACE_Hash +{ +public: + /// Simply returns t + unsigned long operator () (ACE_INT64 t) const; +}; +#endif /* !ACE_LACKS_LONGLONG_T && ACE_SIZEOF_LONG < 8 */ + +// We can do this even if ACE_LACKS_UNSIGNEDLONGLONG_T because there's an +// emulation for it in ACE_U_LongLong. +#if (ACE_SIZEOF_LONG < 8) +/** + * @class ACE_Hash + * + * @brief Function object for hashing an unsigned 64-bit number + */ +template<> +class ACE_Export ACE_Hash +{ +public: + /// Simply returns t + unsigned long operator () (const ACE_UINT64 &t) const; +}; +#endif /* ACE_SIZEOF_LONG < 8 */ + +/** + * @class ACE_Hash + * + * @brief Function object for hashing a const string + */ +template<> +class ACE_Export ACE_Hash +{ +public: + /// Calls ACE::hash_pjw + unsigned long operator () (const char *t) const; +}; + +/** + * @class ACE_Hash + * + * @brief Function object for hashing a string + */ +template<> +class ACE_Export ACE_Hash +{ +public: + /// Calls ACE::hash_pjw + unsigned long operator () (const char *t) const; +}; + +/** + * @class ACE_Hash + * + * @brief Function object for hashing a void * + */ +template<> +class ACE_Export ACE_Hash +{ +public: + unsigned long operator () (const void *) const; +}; + +/** + * @class ACE_Equal_To + * + * @brief Function object for determining whether two const strings are equal. + */ +template<> +class ACE_Export ACE_Equal_To +{ +public: + /// Simply calls ACE_OS::strcmp + int operator () (const char *lhs, + const char *rhs) const; +}; + +/** + * @class ACE_Equal_To + * + * @brief Function object for determining whether two non-const + * strings are equal. + */ +template<> +class ACE_Export ACE_Equal_To +{ +public: + /// Simply calls ACE_OS::strcmp + int operator () (const char *lhs, + const char *rhs) const; +}; + +/** + * @class ACE_Equal_To + * + * @brief Function object for determining whether two unsigned + * 16 bit ints are equal. + */ +template<> +class ACE_Export ACE_Equal_To +{ +public: + /// Simply calls built-in operators + int operator () (const ACE_UINT16 lhs, + const ACE_UINT16 rhs) const; +}; + +/** + * @class ACE_Equal_To + * + * @brief Function object for determining whether two + * 16 bit ints are equal. + */ +template<> +class ACE_Export ACE_Equal_To +{ +public: + /// Simply calls built-in operators + int operator () (const ACE_INT16 lhs, + const ACE_INT16 rhs) const; +}; + +/** + * @class ACE_Equal_To + * + * @brief Function object for determining whether two unsigned + * 32 bit ints are equal. + */ +template<> +class ACE_Export ACE_Equal_To +{ +public: + /// Simply calls built-in operators + int operator () (const ACE_UINT32 lhs, + const ACE_UINT32 rhs) const; +}; + +/** + * @class ACE_Equal_To + * + * @brief Function object for determining whether two + * 32 bit ints are equal. + */ +template<> +class ACE_Export ACE_Equal_To +{ +public: + /// Simply calls built-in operators + int operator () (const ACE_INT32 lhs, + const ACE_INT32 rhs) const; +}; + +/** + * @class ACE_Equal_To + * + * @brief Function object for determining whether two unsigned + * 64 bit ints are equal. + */ +template<> +class ACE_Export ACE_Equal_To +{ +public: + /// Simply calls built-in operators + int operator () (const ACE_UINT64 lhs, + const ACE_UINT64 rhs) const; +}; + +/** + * @class ACE_Less_Than + * + * @brief Function object for determining whether the first const string + * is less than the second const string. + */ +template<> +class ACE_Export ACE_Less_Than +{ +public: + /// Simply calls ACE_OS::strcmp + int operator () (const char *lhs, + const char *rhs) const; +}; + +/** + * @class ACE_Less_Than + * + * @brief Function object for determining whether the first string + * is less than the second string. + */ +template<> +class ACE_Export ACE_Less_Than +{ +public: + /// Simply calls ACE_OS::strcmp + int operator () (const char *lhs, + const char *rhs) const; +}; + +#if defined (ACE_HAS_WCHAR) + +# if ! defined (ACE_LACKS_NATIVE_WCHAR_T) +/** + * @class ACE_Hash + * + * @brief Function object for hashing a wchar_t + */ +template<> +class ACE_Export ACE_Hash +{ +public: + /// Simply returns t + unsigned long operator () (wchar_t t) const; +}; +# endif /* ACE_LACKS_NATIVE_WCHAR_T */ +/** + * @class ACE_Hash + * + * @brief Function object for hashing a const string + */ +template<> +class ACE_Export ACE_Hash +{ +public: + /// Calls ACE::hash_pjw + unsigned long operator () (const wchar_t *t) const; +}; + +/** + * @class ACE_Hash + * + * @brief Function object for hashing a string + */ +template<> +class ACE_Export ACE_Hash +{ +public: + /// Calls ACE::hash_pjw + unsigned long operator () (const wchar_t *t) const; +}; + +/** + * @class ACE_Equal_To + * + * @brief Function object for determining whether two const strings are equal. + */ +template<> +class ACE_Export ACE_Equal_To +{ +public: + /// Simply calls ACE_OS::strcmp + int operator () (const wchar_t *lhs, + const wchar_t *rhs) const; +}; + +/** + * @class ACE_Equal_To + * + * @brief Function object for determining whether two non-const + * strings are equal. + */ +template<> +class ACE_Export ACE_Equal_To +{ +public: + /// Simply calls ACE_OS::strcmp + int operator () (const wchar_t *lhs, + const wchar_t *rhs) const; +}; + +/** + * @class ACE_Less_Than + * + * @brief Function object for determining whether the first const string + * is less than the second const string. + */ +template<> +class ACE_Export ACE_Less_Than +{ +public: + /// Simply calls ACE_OS::strcmp + int operator () (const wchar_t *lhs, + const wchar_t *rhs) const; +}; + +/** + * @class ACE_Less_Than + * + * @brief Function object for determining whether the first string + * is less than the second string. + */ +template<> +class ACE_Export ACE_Less_Than +{ +public: + /// Simply calls ACE_OS::strcmp + int operator () (const wchar_t *lhs, + const wchar_t *rhs) const; +}; + +#endif // ACE_HAS_WCHAR + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +#include "ace/Functor.inl" +#endif /* __ACE_INLINE__ */ + +#include /**/ "ace/post.h" +#endif /* ACE_FUNCTOR_H */ diff --git a/dep/ACE_wrappers/ace/Functor.inl b/dep/ACE_wrappers/ace/Functor.inl new file mode 100644 index 00000000000..30e539459a8 --- /dev/null +++ b/dep/ACE_wrappers/ace/Functor.inl @@ -0,0 +1,284 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Functor.inl + * + * $Id: Functor.inl 80826 2008-03-04 14:51:23Z wotte $ + * + * Inlinable method definitions for non-templatized classes + * and template specializations implementing the GOF Command Pattern, + * and STL-style functors. + * + * + * @author Chris Gill + * + * Based on Command Pattern implementations originally done by + * + * Carlos O'Ryan + * Douglas C. Schmidt + * Sergio Flores-Gaitan + * + * and on STL-style functor implementations originally done by + * Irfan Pyarali + */ +//============================================================================= + + +#include "ace/ACE.h" +#include "ace/OS_NS_string.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +////////////////////////////////////////////////////////////// +// GOF Command Pattern Classes and Template Specializations // +////////////////////////////////////////////////////////////// + +// Default constructor. + +ACE_INLINE +ACE_Command_Base::ACE_Command_Base (void) +{ +} + +//////////////////////////////////////////////////////////// +// STL-style Functor Classes and Template Specializations // +//////////////////////////////////////////////////////////// + +ACE_INLINE unsigned long +ACE_Hash::operator () (char t) const +{ + return t; +} + +#if defined (ACE_HAS_WCHAR) && ! defined (ACE_LACKS_NATIVE_WCHAR_T) +ACE_INLINE unsigned long +ACE_Hash::operator () (wchar_t t) const +{ + return t; +} +#endif /* ACE_HAS_WCHAR && ! ACE_LACKS_NATIVE_WCHAR_T */ + +ACE_INLINE unsigned long +ACE_Hash::operator () (signed char t) const +{ + return t; +} + +ACE_INLINE unsigned long +ACE_Hash::operator () (unsigned char t) const +{ + return t; +} + +#if 0 +ACE_INLINE unsigned long +ACE_Hash::operator () (ACE_INT16 t) const +{ + return t; +} + +ACE_INLINE unsigned long +ACE_Hash::operator () (ACE_UINT16 t) const +{ + return t; +} + +ACE_INLINE unsigned long +ACE_Hash::operator () (ACE_INT32 t) const +{ + return static_cast (t); +} + +ACE_INLINE unsigned long +ACE_Hash::operator () (ACE_UINT32 t) const +{ + return t; +} + +ACE_INLINE unsigned long +ACE_Hash::operator () (ACE_UINT64 t) const +{ +#if (ACE_SIZEOF_LONG == 4) + return ACE_U64_TO_U32 (t); +#else + return static_cast (t); +#endif /* ACE_SIZEOF_LONG */ +} +#endif + +ACE_INLINE unsigned long +ACE_Hash::operator () (short t) const +{ + return static_cast (t); +} + +ACE_INLINE unsigned long +ACE_Hash::operator () (unsigned short t) const +{ + return static_cast (t); +} + +ACE_INLINE unsigned long +ACE_Hash::operator () (int t) const +{ + return static_cast (t); +} + +ACE_INLINE unsigned long +ACE_Hash::operator () (unsigned int t) const +{ + return static_cast (t); +} + +ACE_INLINE unsigned long +ACE_Hash::operator () (long t) const +{ + return static_cast (t); +} + +ACE_INLINE unsigned long +ACE_Hash::operator () (unsigned long t) const +{ + return t; +} + +// This #if needs to match the one in Functor.h +#if !defined (ACE_LACKS_LONGLONG_T) && (ACE_SIZEOF_LONG < 8) +ACE_INLINE unsigned long +ACE_Hash::operator () (ACE_INT64 t) const +{ + return static_cast (t); +} +#endif /* !ACE_LACKS_LONGLONG_T && ACE_SIZEOF_LONG < 8 */ + +#if (ACE_SIZEOF_LONG < 8) +ACE_INLINE unsigned long +ACE_Hash::operator () (const ACE_UINT64 &t) const +{ +#if (ACE_SIZEOF_LONG == 4) + return ACE_U64_TO_U32 (t); +#else + return static_cast (t); +#endif /* ACE_SIZEOF_LONG */ +} +#endif /* !ACE_LACKS_UNSIGNEDLONGLONG_T */ + +ACE_INLINE unsigned long +ACE_Hash::operator () (const char *t) const +{ + return ACE::hash_pjw (t); +} + +ACE_INLINE unsigned long +ACE_Hash::operator () (const char *t) const +{ + return ACE::hash_pjw (t); +} + +ACE_INLINE unsigned long +ACE_Hash::operator () (const void *t) const +{ + return static_cast (reinterpret_cast (t)); +} + +/***********************************************************************/ +ACE_INLINE int +ACE_Equal_To::operator () (const char *lhs, const char *rhs) const +{ + return !ACE_OS::strcmp (lhs, rhs); +} + +ACE_INLINE int +ACE_Equal_To::operator () (const char *lhs, const char *rhs) const +{ + return !ACE_OS::strcmp (lhs, rhs); +} + +ACE_INLINE int +ACE_Equal_To::operator () (const ACE_UINT16 lhs, const ACE_UINT16 rhs) const +{ + return (lhs == rhs); +} + +ACE_INLINE int +ACE_Equal_To::operator () (const ACE_INT16 lhs, const ACE_INT16 rhs) const +{ + return (lhs == rhs); +} + +ACE_INLINE int +ACE_Equal_To::operator () (const ACE_UINT32 lhs, const ACE_UINT32 rhs) const +{ + return (lhs == rhs); +} + +ACE_INLINE int +ACE_Equal_To::operator () (const ACE_INT32 lhs, const ACE_INT32 rhs) const +{ + return (lhs == rhs); +} + +ACE_INLINE int +ACE_Equal_To::operator () (const ACE_UINT64 lhs, const ACE_UINT64 rhs) const +{ + return (lhs == rhs); +} + +/****************************************************************************/ +ACE_INLINE int +ACE_Less_Than::operator () (const char *lhs, const char *rhs) const +{ + return (ACE_OS::strcmp (lhs, rhs) < 0) ? 1 : 0; +} + +ACE_INLINE int +ACE_Less_Than::operator () (const char *lhs, const char *rhs) const +{ + return (ACE_OS::strcmp (lhs, rhs) < 0) ? 1 : 0; +} + + +#if defined (ACE_HAS_WCHAR) + +ACE_INLINE unsigned long +ACE_Hash::operator () (const wchar_t *t) const +{ + return ACE::hash_pjw (t); +} + +ACE_INLINE unsigned long +ACE_Hash::operator () (const wchar_t *t) const +{ + return ACE::hash_pjw (t); +} + +ACE_INLINE int +ACE_Equal_To::operator () (const wchar_t *lhs, + const wchar_t *rhs) const +{ + return !ACE_OS::strcmp (lhs, rhs); +} + +ACE_INLINE int +ACE_Equal_To::operator () (const wchar_t *lhs, + const wchar_t *rhs) const +{ + return !ACE_OS::strcmp (lhs, rhs); +} + +ACE_INLINE int +ACE_Less_Than::operator () (const wchar_t *lhs, const wchar_t *rhs) const +{ + return (ACE_OS::strcmp (lhs, rhs) < 0) ? 1 : 0; +} + +ACE_INLINE int +ACE_Less_Than::operator () (const wchar_t *lhs, const wchar_t *rhs) const +{ + return (ACE_OS::strcmp (lhs, rhs) < 0) ? 1 : 0; +} + +#endif // ACE_HAS_WCHAR + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Functor_String.cpp b/dep/ACE_wrappers/ace/Functor_String.cpp new file mode 100644 index 00000000000..c113f5cdf6f --- /dev/null +++ b/dep/ACE_wrappers/ace/Functor_String.cpp @@ -0,0 +1,7 @@ +#include "ace/Functor_String.h" + +#if !defined (__ACE_INLINE__) +#include "ace/Functor_String.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(ace, Functor, "$Id: Functor_String.cpp 80826 2008-03-04 14:51:23Z wotte $") diff --git a/dep/ACE_wrappers/ace/Functor_String.h b/dep/ACE_wrappers/ace/Functor_String.h new file mode 100644 index 00000000000..6070fcf1bea --- /dev/null +++ b/dep/ACE_wrappers/ace/Functor_String.h @@ -0,0 +1,141 @@ +// -*- C++ -*- + +//========================================================================== +/** + * @file Functor_String.h + * + * $Id: Functor_String.h 80826 2008-03-04 14:51:23Z wotte $ + * + * Class template specializations for ACE_*String types implementing + * function objects that are used in various places in ATC. They + * could be placed in Functor.h. But we don't want to couple string + * types to the rest of ACE+TAO. Hence they are placed in a seperate + * file. + */ +//========================================================================== +#ifndef ACE_FUNCTOR_STRING_H +#define ACE_FUNCTOR_STRING_H +#include /**/ "ace/pre.h" + +#include /**/ "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include /**/ "ace/ACE_export.h" +#include "ace/SStringfwd.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +//////////////////////////////////////////////////////////// +// STL-style Functor Classes and Template Specializations // +//////////////////////////////////////////////////////////// + +// Forward declaration since we are going to specialize that template +// here. The template itself requires this file so every user of the +// template should also see the specialization. +template class ACE_Hash; +template class ACE_Equal_To; +template class ACE_Less_Than; + +/** + * @class ACE_Equal_To + * + * @brief Function object for determining whether two ACE_CStrings are + * equal. + */ +template<> +class ACE_Export ACE_Equal_To +{ +public: + int operator () (const ACE_CString &lhs, + const ACE_CString &rhs) const; +}; + + +/** + * @class ACE_Hash + * + * @brief Function object for hashing a ACE_CString + */ +template<> +class ACE_Export ACE_Hash +{ +public: + /// Calls ACE::hash_pjw + unsigned long operator () (const ACE_CString &lhs) const; +}; + + +/** + * @class ACE_Less_Than + * + * @brief Function object for determining whether the first const string + * is less than the second const string. + */ +template<> +class ACE_Export ACE_Less_Than +{ +public: + /// Simply calls ACE_OS::strcmp + int operator () (const ACE_CString &lhs, + const ACE_CString &rhs) const; +}; + + +#if defined (ACE_USES_WCHAR) + +/** + * @class ACE_Equal_To + * + * @brief Function object for determining whether two ACE_CStrings are + * equal. + */ +template<> +class ACE_Export ACE_Equal_To +{ +public: + int operator () (const ACE_WString &lhs, + const ACE_WString &rhs) const; +}; + + +/** + * @class ACE_Hash + * + * @brief Function object for hashing a ACE_WString + */ +template<> +class ACE_Export ACE_Hash +{ +public: + /// Calls ACE::hash_pjw + unsigned long operator () (const ACE_WString &lhs) const; +}; + +/** + * @class ACE_Less_Than + * + * @brief Function object for determining whether the first const string + * is less than the second const string. + */ +template<> +class ACE_Export ACE_Less_Than +{ +public: + /// Simply calls ACE_OS::strcmp + int operator () (const ACE_WString &lhs, + const ACE_WString &rhs) const; +}; + +#endif /*ACE_USES_WCHAR*/ + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +#include "ace/Functor_String.inl" +#endif /* __ACE_INLINE__ */ + +#include /**/ "ace/post.h" +#endif /*ACE_FUNCTOR_STRING_H*/ diff --git a/dep/ACE_wrappers/ace/Functor_String.inl b/dep/ACE_wrappers/ace/Functor_String.inl new file mode 100644 index 00000000000..bdac96386f8 --- /dev/null +++ b/dep/ACE_wrappers/ace/Functor_String.inl @@ -0,0 +1,56 @@ +// -*- C++ -*- +// +// $Id: Functor_String.inl 80826 2008-03-04 14:51:23Z wotte $ + +#include "ace/ACE.h" +#include "ace/String_Base.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_INLINE unsigned long +ACE_Hash::operator () (const ACE_CString &t) const +{ + return t.hash (); +} + + +ACE_INLINE int +ACE_Equal_To::operator () (const ACE_CString &lhs, + const ACE_CString &rhs) const +{ + return lhs == rhs; +} + +ACE_INLINE int +ACE_Less_Than::operator () (const ACE_CString &lhs, + const ACE_CString &rhs) const +{ + return (lhs < rhs); +} + + +#if defined (ACE_USES_WCHAR) +ACE_INLINE unsigned long +ACE_Hash::operator () (const ACE_WString &t) const +{ + return t.hash (); +} + + +ACE_INLINE int +ACE_Equal_To::operator () (const ACE_WString &lhs, + const ACE_WString &rhs) const +{ + return lhs == rhs; +} + +ACE_INLINE int +ACE_Less_Than::operator () (const ACE_WString &lhs, + const ACE_WString &rhs) const +{ + return (lhs < rhs); +} + +#endif /*ACE_USES_WCHAR*/ + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Functor_T.cpp b/dep/ACE_wrappers/ace/Functor_T.cpp new file mode 100644 index 00000000000..213b501aac1 --- /dev/null +++ b/dep/ACE_wrappers/ace/Functor_T.cpp @@ -0,0 +1,49 @@ +// $Id: Functor_T.cpp 80826 2008-03-04 14:51:23Z wotte $ + +#ifndef ACE_FUNCTOR_T_CPP +#define ACE_FUNCTOR_T_CPP + +#include "ace/Functor_T.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#if !defined (__ACE_INLINE__) +#include "ace/Functor_T.inl" +#endif /* __ACE_INLINE__ */ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_ALLOC_HOOK_DEFINE(ACE_Command_Callback) + +/////////////////////////////////// +// GOF Command Pattern Templates // +/////////////////////////////////// + +// Constructor. + +template +ACE_Command_Callback::ACE_Command_Callback (RECEIVER &recvr, + ACTION action) + : receiver_ (recvr), + action_ (action) +{ +} + +template +ACE_Command_Callback::~ACE_Command_Callback (void) +{ +} + +// Invokes an operation. + +template int +ACE_Command_Callback::execute (void *arg) +{ + return (receiver_.*action_) (arg); +} + +ACE_END_VERSIONED_NAMESPACE_DECL + +#endif /* ACE_FUNCTOR_T_CPP */ diff --git a/dep/ACE_wrappers/ace/Functor_T.h b/dep/ACE_wrappers/ace/Functor_T.h new file mode 100644 index 00000000000..f055c3c885e --- /dev/null +++ b/dep/ACE_wrappers/ace/Functor_T.h @@ -0,0 +1,158 @@ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file Functor_T.h + * + * $Id: Functor_T.h 80826 2008-03-04 14:51:23Z wotte $ + * + * Templatized classes for implementing function objects that are + * used in various places in ACE. There are currently two major + * categories of function objects in ACE: GOF Command Pattern + * objects, and STL-style functors for comparison of container + * elements. The command objects are invoked via an + * method, while the STL-style functors are invoked via an + * method. + * + * + * @author Chris Gill + * @author Based on Command Pattern implementations originally done by + * @author Carlos O'Ryan + * @author Douglas C. Schmidt + * @author Sergio Flores-Gaitan + * @author and on STL-style functor implementations originally done by + * @author Irfan Pyarali + */ +//============================================================================= + + +#ifndef ACE_FUNCTOR_T_H +#define ACE_FUNCTOR_T_H +#include /**/ "ace/pre.h" + +#include "ace/Functor.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/Functor_String.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +/////////////////////////////////// +// GOF Command Pattern Templates // +/////////////////////////////////// + +/** + * @class ACE_Command_Callback + * + * @brief Defines a class template that allows us to invoke a GOF + * command style callback to an object without knowing anything + * about the object except its type. + * + * This class declares an interface to execute operations, + * binding a RECEIVER object with an ACTION. The RECEIVER knows + * how to implement the operation. A class can invoke operations + * without knowing anything about it, or how it was implemented. + */ +template +class ACE_Command_Callback : public ACE_Command_Base +{ +public: + /// Constructor: sets the of the Command to recvr, and the + /// of the Command to . + ACE_Command_Callback (RECEIVER &recvr, ACTION action); + + /// Virtual destructor. + virtual ~ACE_Command_Callback (void); + + /// Invokes the method from the object . + virtual int execute (void *arg = 0); + +private: + /// Object where the method resides. + RECEIVER &receiver_; + + /// Method that is going to be invoked. + ACTION action_; +}; + +///////////////////////////////// +// STL-style Functor Templates // +///////////////////////////////// + +/** + * @class ACE_Hash + * + * @brief Function object for hashing + */ +template +class ACE_Hash +{ +public: + /// Simply calls t.hash () + unsigned long operator () (const TYPE &t) const; +}; + +/** + * @class ACE_Pointer_Hash + * + * @brief Function object for hashing pointers + */ +template +class ACE_Pointer_Hash +{ +public: + /// Simply returns t. + unsigned long operator () (TYPE t) const; +}; + +/** + * @class ACE_Equal_To + * + * @brief Function object for comparing two objects of + * the given type for equality. + */ +template +class ACE_Equal_To +{ +public: + /// Simply calls operator== + bool operator () (const TYPE &lhs, + const TYPE &rhs) const; +}; + +/** + * @class ACE_Less_Than + * + * @brief Function object for determining whether the first object of + * the given type is less than the second object of the same + * type. + */ +template +class ACE_Less_Than +{ +public: + /// Simply calls operator< + bool operator () (const TYPE &lhs, + const TYPE &rhs) const; +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +#include "ace/Functor_T.inl" +#endif /* __ACE_INLINE__ */ + + +#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) +#include "ace/Functor_T.cpp" +#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ + +#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) +#pragma implementation ("Functor_T.cpp") +#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ + +#include /**/ "ace/post.h" +#endif /* ACE_FUNCTOR_T_H */ diff --git a/dep/ACE_wrappers/ace/Functor_T.inl b/dep/ACE_wrappers/ace/Functor_T.inl new file mode 100644 index 00000000000..35cfed5b798 --- /dev/null +++ b/dep/ACE_wrappers/ace/Functor_T.inl @@ -0,0 +1,42 @@ +// -*- C++ -*- +// +// $Id: Functor_T.inl 80826 2008-03-04 14:51:23Z wotte $ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +template ACE_INLINE unsigned long +ACE_Hash::operator () (const TYPE &t) const +{ + return t.hash (); +} + +template ACE_INLINE unsigned long +ACE_Pointer_Hash::operator () (TYPE t) const +{ +#if defined (ACE_WIN64) + // The cast below is legit... we only want a hash, and need not convert + // the hash back to a pointer. +# pragma warning(push) +# pragma warning(disable : 4311) /* Truncate pointer to unsigned long */ +#endif /* ACE_WIN64 */ + return reinterpret_cast (t); +#if defined (ACE_WIN64) +# pragma warning(pop) +#endif /* ACE_WIN64 */ +} + +template ACE_INLINE bool +ACE_Equal_To::operator () (const TYPE &lhs, + const TYPE &rhs) const +{ + return lhs == rhs; +} + +template ACE_INLINE bool +ACE_Less_Than::operator () (const TYPE &lhs, + const TYPE &rhs) const +{ + return lhs < rhs; +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Future.cpp b/dep/ACE_wrappers/ace/Future.cpp new file mode 100644 index 00000000000..e3693bd29b6 --- /dev/null +++ b/dep/ACE_wrappers/ace/Future.cpp @@ -0,0 +1,436 @@ + // $Id: Future.cpp 80826 2008-03-04 14:51:23Z wotte $ + +#ifndef ACE_FUTURE_CPP +#define ACE_FUTURE_CPP + +#include "ace/Future.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +ACE_RCSID (ace, Future, "$Id: Future.cpp 80826 2008-03-04 14:51:23Z wotte $") + +#if defined (ACE_HAS_THREADS) + +# include "ace/Guard_T.h" +# include "ace/Recursive_Thread_Mutex.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +template +ACE_Future_Holder::ACE_Future_Holder (void) +{ +} + +template +ACE_Future_Holder::ACE_Future_Holder (const ACE_Future &item) + : item_ (item) +{ +} + +template +ACE_Future_Holder::~ACE_Future_Holder (void) +{ +} + +template +ACE_Future_Observer::ACE_Future_Observer (void) +{ +} + +template +ACE_Future_Observer::~ACE_Future_Observer (void) +{ +} + +// Dump the state of an object. + +template void +ACE_Future_Rep::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); + ACE_DEBUG ((LM_DEBUG, + "ref_count_ = %d\n", + (int) this->ref_count_)); + ACE_DEBUG ((LM_INFO,"value_: \n")); + if (this->value_) + ACE_DEBUG ((LM_DEBUG, ACE_TEXT (" (NON-NULL)\n"))); + else + //FUZZ: disable check_for_NULL + ACE_DEBUG ((LM_DEBUG, ACE_TEXT (" (NULL)\n"))); + //FUZZ: enable check_for_NULL + + ACE_DEBUG ((LM_INFO,"value_ready_: \n")); + this->value_ready_.dump (); + ACE_DEBUG ((LM_INFO,"value_ready_mutex_: \n")); + this->value_ready_mutex_.dump (); + ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); +#endif /* ACE_HAS_DUMP */ +} + +template ACE_Future_Rep * +ACE_Future_Rep::internal_create (void) +{ + ACE_Future_Rep *temp = 0; + ACE_NEW_RETURN (temp, + ACE_Future_Rep (), + 0); + return temp; +} + +template ACE_Future_Rep * +ACE_Future_Rep::create (void) +{ + // Yes set ref count to zero. + ACE_Future_Rep *temp = internal_create (); +#if defined (ACE_NEW_THROWS_EXCEPTIONS) + if (temp == 0) + ACE_throw_bad_alloc; +#else + ACE_ASSERT (temp != 0); +#endif /* ACE_NEW_THROWS_EXCEPTIONS */ + return temp; + } + + +template ACE_Future_Rep * +ACE_Future_Rep::attach (ACE_Future_Rep*& rep) +{ + ACE_ASSERT (rep != 0); + // Use value_ready_mutex_ for both condition and ref count management + ACE_MT (ACE_Guard r_mon (rep->value_ready_mutex_)); + ++rep->ref_count_; + return rep; +} + +template void +ACE_Future_Rep::detach (ACE_Future_Rep*& rep) +{ + ACE_ASSERT (rep != 0); + // Use value_ready_mutex_ for both condition and ref count management + ACE_MT (ACE_GUARD (ACE_Recursive_Thread_Mutex, r_mon, rep->value_ready_mutex_)); + + if (rep->ref_count_-- == 0) + { + ACE_MT (r_mon.release ()); + // We do not need the lock when deleting the representation. + // There should be no side effects from deleting rep and we don + // not want to release a deleted mutex. + delete rep; + } +} + +template void +ACE_Future_Rep::assign (ACE_Future_Rep*& rep, ACE_Future_Rep* new_rep) +{ + ACE_ASSERT (rep != 0); + ACE_ASSERT (new_rep != 0); + // Use value_ready_mutex_ for both condition and ref count management + ACE_MT (ACE_GUARD (ACE_Recursive_Thread_Mutex, r_mon, rep->value_ready_mutex_)); + + ACE_Future_Rep* old = rep; + rep = new_rep; + + // detached old last for exception safety + if (old->ref_count_-- == 0) + { + ACE_MT (r_mon.release ()); + // We do not need the lock when deleting the representation. + // There should be no side effects from deleting rep and we don + // not want to release a deleted mutex. + delete old; + } +} + +template +ACE_Future_Rep::ACE_Future_Rep (void) + : value_ (0), + ref_count_ (0), + value_ready_ (value_ready_mutex_) +{ +} + +template +ACE_Future_Rep::~ACE_Future_Rep (void) +{ + delete this->value_; +} + +template int +ACE_Future_Rep::ready (void) const +{ + return this->value_ != 0; +} + +template int +ACE_Future_Rep::set (const T &r, + ACE_Future &caller) +{ + // If the value is already produced, ignore it... + if (this->value_ == 0) + { + ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, + ace_mon, + this->value_ready_mutex_, + -1)); + // Otherwise, create a new result value. Note the use of the + // Double-checked locking pattern to avoid multiple allocations. + + if (this->value_ == 0) // Still no value, so proceed + { + ACE_NEW_RETURN (this->value_, + T (r), + -1); + + // Remove and notify all subscribed observers. + typename OBSERVER_COLLECTION::iterator iterator = + this->observer_collection_.begin (); + + typename OBSERVER_COLLECTION::iterator end = + this->observer_collection_.end (); + + while (iterator != end) + { + OBSERVER *observer = *iterator++; + observer->update (caller); + } + + // Signal all the waiting threads. + return this->value_ready_.broadcast (); + } + // Destructor releases the lock. + } + return 0; +} + +template int +ACE_Future_Rep::get (T &value, + ACE_Time_Value *tv) const +{ + // If the value is already produced, return it. + if (this->value_ == 0) + { + ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon, + this->value_ready_mutex_, + -1)); + // If the value is not yet defined we must block until the + // producer writes to it. + + while (this->value_ == 0) + // Perform a timed wait. + if (this->value_ready_.wait (tv) == -1) + return -1; + + // Destructor releases the lock. + } + + value = *this->value_; + return 0; +} + +template int +ACE_Future_Rep::attach (ACE_Future_Observer *observer, + ACE_Future &caller) +{ + ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon, this->value_ready_mutex_, -1)); + + // Otherwise, create a new result value. Note the use of the + // Double-checked locking pattern to avoid corrupting the list. + + int result = 1; + + // If the value is already produced, then notify observer + if (this->value_ == 0) + result = this->observer_collection_.insert (observer); + else + observer->update (caller); + + return result; +} + +template int +ACE_Future_Rep::detach (ACE_Future_Observer *observer) +{ + ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon, this->value_ready_mutex_, -1)); + + // Remove all occurrences of the specified observer from this + // objects hash map. + return this->observer_collection_.remove (observer); +} + +template +ACE_Future_Rep::operator T () +{ + // If the value is already produced, return it. + if (this->value_ == 0) + { + // Constructor of ace_mon acquires the mutex. + ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon, this->value_ready_mutex_, 0)); + + // If the value is not yet defined we must block until the + // producer writes to it. + + // Wait ``forever.'' + + while (this->value_ == 0) + if (this->value_ready_.wait () == -1) + // What to do in this case since we've got to indicate + // failure somehow? Exceptions would be nice, but they're + // not portable... + return 0; + + // Destructor releases the mutex + } + + return *this->value_; +} + +template +ACE_Future::ACE_Future (void) + : future_rep_ (FUTURE_REP::create ()) +{ +} + +template +ACE_Future::ACE_Future (const ACE_Future &r) + : future_rep_ (FUTURE_REP::attach (((ACE_Future &) r).future_rep_)) +{ +} + +template +ACE_Future::ACE_Future (const T &r) + : future_rep_ (FUTURE_REP::create ()) +{ + this->future_rep_->set (r, *this); +} + +template +ACE_Future::~ACE_Future (void) +{ + FUTURE_REP::detach (future_rep_); +} + +template bool +ACE_Future::operator== (const ACE_Future &r) const +{ + return r.future_rep_ == this->future_rep_; +} + +template bool +ACE_Future::operator!= (const ACE_Future &r) const +{ + return r.future_rep_ != this->future_rep_; +} + +template int +ACE_Future::cancel (const T &r) +{ + this->cancel (); + return this->future_rep_->set (r, + *this); +} + +template int +ACE_Future::cancel (void) +{ + // If this ACE_Future is already attached to a ACE_Future_Rep, + // detach it (maybe delete the ACE_Future_Rep). + FUTURE_REP::assign (this->future_rep_, + FUTURE_REP::create ()); + return 0; +} + +template int +ACE_Future::set (const T &r) +{ + // Give the pointer to the result to the ACE_Future_Rep. + return this->future_rep_->set (r, + *this); +} + +template int +ACE_Future::ready (void) const +{ + // We're ready if the ACE_Future_rep is ready... + return this->future_rep_->ready (); +} + +template int +ACE_Future::get (T &value, + ACE_Time_Value *tv) const +{ + // We return the ACE_Future_rep. + return this->future_rep_->get (value, tv); +} + +template int +ACE_Future::attach (ACE_Future_Observer *observer) +{ + return this->future_rep_->attach (observer, *this); +} + +template int +ACE_Future::detach (ACE_Future_Observer *observer) +{ + return this->future_rep_->detach (observer); +} + +template +ACE_Future::operator T () +{ + // note that this will fail (and COREDUMP!) + // if future_rep_ == 0 ! + // + // but... + // this is impossible unless somebody is so stupid to + // try something like this: + // + // Future futT; + // T t; + // t = futT; + + // perform type conversion on Future_Rep. + return *future_rep_; +} + +template void +ACE_Future::operator = (const ACE_Future &rhs) +{ + // assignment: + // + // bind to the same as . + + // This will work if &r == this, by first increasing the ref count + ACE_Future &r = (ACE_Future &) rhs; + FUTURE_REP::assign (this->future_rep_, + FUTURE_REP::attach (r.future_rep_)); +} + +template void +ACE_Future::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + ACE_DEBUG ((LM_DEBUG, + ACE_BEGIN_DUMP, this)); + + if (this->future_rep_) + this->future_rep_->dump (); + + ACE_DEBUG ((LM_DEBUG, + ACE_END_DUMP)); +#endif /* ACE_HAS_DUMP */ +} + +template ACE_Future_Rep * +ACE_Future::get_rep () +{ + return this->future_rep_; +} + +ACE_END_VERSIONED_NAMESPACE_DECL + +#endif /* ACE_HAS_THREADS */ + +#endif /* ACE_FUTURE_CPP */ diff --git a/dep/ACE_wrappers/ace/Future.h b/dep/ACE_wrappers/ace/Future.h new file mode 100644 index 00000000000..e30159eaf96 --- /dev/null +++ b/dep/ACE_wrappers/ace/Future.h @@ -0,0 +1,387 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Future.h + * + * $Id: Future.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Andres Kruse + * @author Douglas C. Schmidt + * @author Per Andersson and + * @author John Tucker + */ +//============================================================================= + +#ifndef ACE_FUTURE_H +#define ACE_FUTURE_H + +#include /**/ "ace/pre.h" + +#include "ace/Unbounded_Set.h" +#include "ace/Strategies_T.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#if defined (ACE_HAS_THREADS) + +#include "ace/Recursive_Thread_Mutex.h" +#include "ace/Condition_Recursive_Thread_Mutex.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +// Forward decl. +template class ACE_Future_Holder; +template class ACE_Future_Observer; +template class ACE_Future_Rep; +template class ACE_Future; + +/** + * @class ACE_Future_Holder + * + * @brief Implementation of object that holds an ACE_Future. + */ +template +class ACE_Future_Holder +{ +public: + ACE_Future_Holder (const ACE_Future &future); + ~ACE_Future_Holder (void); + + /// Declare the dynamic allocation hooks. + ACE_ALLOC_HOOK_DECLARE; + + ACE_Future item_; + +protected: + ACE_Future_Holder (void); +}; + +/** + * @class ACE_Future_Observer + * + * @brief ACE_Future_Observer + * + * An ACE_Future_Observer object implements an object that is + * subscribed with an ACE_Future object so that it may be notified + * when the value of the ACE_Future object is written to by a writer + * thread. It uses the Observer pattern. + */ +template +class ACE_Future_Observer +{ +public: + /// Destructor + virtual ~ACE_Future_Observer (void); + + /// Called by the ACE_Future in which we are subscribed to when + /// its value is written to. + virtual void update (const ACE_Future &future) = 0; + + /// Declare the dynamic allocation hooks. + ACE_ALLOC_HOOK_DECLARE; +protected: + + /// Constructor + ACE_Future_Observer (void); +}; + +/** + * @class ACE_Future_Rep + * + * @internal + * + * @brief ACE_Future_Rep + * + * An ACE_Future_Rep object encapsules a pointer to an object + * of class T which is the result of an asynchronous method + * invocation. It is pointed to by ACE_Future object[s] and + * only accessible through them. + */ +template +class ACE_Future_Rep +{ +private: + friend class ACE_Future; + + /** + * Set the result value. The specified represents the + * future that invoked this method, which is used to notify + * the list of future observers. Returns 0 for success, -1 on error. + * This function only has an effect the first time it is called for + * the object. Subsequent calls return 0 (success) but have no effect. + */ + int set (const T &r, + ACE_Future &caller); + + /// Wait up to @a tv time to get the @a value. Note that @a tv must be + /// specified in absolute time rather than relative time. + int get (T &value, + ACE_Time_Value *tv) const; + + /** + * Attaches the specified observer to a subject (i.e., the ACE_Future_Rep). + * The update method of the specified subject will be invoked with a copy of + * the written-to ACE_Future as input when the result gets set. + * + * Returns 0 if the observer is successfully attached, 1 if the + * observer is already attached, and -1 if failures occur. + */ + int attach (ACE_Future_Observer *observer, + ACE_Future &caller); + + /** + * Detaches the specified observer from a subject (i.e., the ACE_Future_Rep). + * The update method of the specified subject will not be invoked when the + * ACE_Future_Reps result gets set. Returns 1 if the specified observer was + * actually attached to the subject prior to this call and 0 if was not. + * + * Returns 0 if the observer was successfully detached, and -1 if the + * observer was not attached in the first place. + */ + int detach (ACE_Future_Observer *observer); + + /** + * Type conversion. will block forever until the result is + * available. Note that this method is going away in a subsequent + * release since it doesn't distinguish between failure results and + * success results (exceptions should be used, but they aren't + * portable...). The method should be used instead since it + * separates the error value from the result, and also permits + * timeouts. + */ + operator T (); + + /// Dump the state of an object. + void dump (void) const; + + /// Declare the dynamic allocation hooks. + ACE_ALLOC_HOOK_DECLARE; + + // = Encapsulate reference count and object lifetime of instances. + + // These methods must go after the others to work around a bug with + // Borland's C++ Builder... + + /// Allocate a new ACE_Future_Rep instance, returning NULL if it + /// cannot be created. + static ACE_Future_Rep *internal_create (void); + + /// Create a ACE_Future_Rep and initialize the reference count. + static ACE_Future_Rep *create (void); + + /** + * Increase the reference count and return argument. Uses the + * attribute "value_ready_mutex_" to synchronize reference count + * updating. + * + * Precondition (rep != 0). + */ + static ACE_Future_Rep *attach (ACE_Future_Rep *&rep); + + /** + * Decreases the reference count and deletes rep if there are no + * more references to rep. + * + * Precondition (rep != 0) + */ + static void detach (ACE_Future_Rep *&rep); + + /** + * Decreases the rep's reference count and deletes rep if there + * are no more references to rep. Then assigns new_rep to rep. + * + * Precondition (rep != 0 && new_rep != 0) + */ + static void assign (ACE_Future_Rep *&rep, ACE_Future_Rep *new_rep); + + /// Is result available? + int ready (void) const; + + /// Pointer to the result. + T *value_; + + /// Reference count. + int ref_count_; + + typedef ACE_Future_Observer OBSERVER; + + typedef ACE_Unbounded_Set OBSERVER_COLLECTION; + + /// Keep a list of ACE_Future_Observers unread by client's reader thread. + OBSERVER_COLLECTION observer_collection_; + + // = Condition variable and mutex that protect the . + mutable ACE_Recursive_Thread_Mutex value_ready_mutex_; + mutable ACE_Condition_Recursive_Thread_Mutex value_ready_; + +private: + + ACE_Future_Rep (void); + +protected: + + ~ACE_Future_Rep (void); + +}; + +/** + * @class ACE_Future + * + * @brief This class implements a ``single write, multiple read'' + * pattern that can be used to return results from asynchronous + * method invocations. + */ +template +class ACE_Future +{ +public: + // = Initialization and termination methods. + /// Constructor. + ACE_Future (void); + + /// Copy constructor binds @a this and @a r to the same + /// ACE_Future_Rep. An ACE_Future_Rep is created if necessary. + ACE_Future (const ACE_Future &r); + + /// Constructor that initialises an ACE_Future to point to the + /// result @a r immediately. + ACE_Future (const T &r); + + /// Destructor. + ~ACE_Future (void); + + /// Assignment operator that binds @a this and @a r to the same + /// ACE_Future_Rep. An ACE_Future_Rep is created if necessary. + void operator = (const ACE_Future &r); + + /// Cancel an ACE_Future and assign the value @a r. It is used if a + /// client does not want to wait for the value to be produced. + int cancel (const T &r); + + /** + * Cancel an ACE_Future. Put the future into its initial + * state. Returns 0 on succes and -1 on failure. It is now possible + * to reuse the ACE_Future. But remember, the ACE_Future + * is now bound to a new ACE_Future_Rep. + */ + int cancel (void); + + /** + * Equality operator that returns @c true if both ACE_Future objects + * point to the same ACE_Future_Rep object. + * + * @note It also returns @c true if both objects have just been + * instantiated and not used yet. + */ + bool operator == (const ACE_Future &r) const; + + /// Inequality operator, which is the opposite of equality. + bool operator != (const ACE_Future &r) const; + + /** + * Make the result available. Is used by the server thread to give + * the result to all waiting clients. Returns 0 for success, -1 on failure. + * This function only has an effect the first time it is called for + * the object (actually, the first time the underlying ACE_Future_Rep has a + * value assigned to it). Subsequent calls return 0 (success) but have no + * effect. + */ + int set (const T &r); + + /** + * Wait to get the object's value. + * + * @param value Receives the value of this ACE_Future when it is set. + * @param tv Pointer to an ACE_Time_Value containing the absolute + * time to wait until for the value to be set. If @a tv + * is 0, the call waits indefinitely for the value to be + * set, unless an error occurs. + * + * @retval 0 Success; @a value contains the value of the ACE_Future. + * @retval -1 Error; check ACE_OS::last_error() for an error code. + */ + int get (T &value, + ACE_Time_Value *tv = 0) const; + + /** + * @deprecated Note that this method is going away in a subsequent + * release since it doesn't distinguish between failure + * results and success results (exceptions should be + * used, but they aren't portable...). + * Type conversion, which obtains the result of the asynchronous + * method invocation. Will block forever. The get() method should be + * used instead since it separates the error value from the result, + * and also permits timeouts. + */ + operator T (); + + /// Check if the result is available. + int ready (void) const; + + /** + * Attaches the specified observer to a subject (this ACE_Future). + * The update method of the specified subject will be invoked with a copy of + * the associated ACE_Future as input when the result gets set. If the + * result is already set when this method gets invoked, then the update + * method of the specified subject will be invoked immediately. + * + * @param observer The observer to attach to the subject. + * + * @retval 0 Success. + * @retval 1 The observer was already attached. + * @retval -1 Error; check ACE_OS::last_error() for an error code. + */ + int attach (ACE_Future_Observer *observer); + + /** + * Detaches the specified observer from a subject (this ACE_Future). + * The update method of the specified subject will not be invoked when the + * ACE_Future_Rep result gets set. + * + * @param observer The observer to attach to the subject. + * + * @retval 0 The observer was successfully detached. + * @retval -1 Error, including the observer not attached prior + * to calling this method. + */ + int detach (ACE_Future_Observer *observer); + + /// Dump the state of an object. + void dump (void) const; + + /** + * Get the underlying ACE_Future_Rep pointer. Note that this method should + * rarely, if ever, be used and that modifying the underlying + * ACE_Future_Rep should be done with extreme caution. + */ + ACE_Future_Rep *get_rep (void); + + /// Declare the dynamic allocation hooks. + ACE_ALLOC_HOOK_DECLARE; + +private: + + // the ACE_Future_Rep + /// Protect operations on the . + typedef ACE_Future_Rep FUTURE_REP; + FUTURE_REP *future_rep_; +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) +#include "ace/Future.cpp" +#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ + +#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) +#pragma implementation ("Future.cpp") +#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ + +#endif /* ACE_HAS_THREADS */ + +#include /**/ "ace/post.h" + +#endif /* ACE_FUTURE_H */ diff --git a/dep/ACE_wrappers/ace/Future_Set.cpp b/dep/ACE_wrappers/ace/Future_Set.cpp new file mode 100644 index 00000000000..fceca83dd5a --- /dev/null +++ b/dep/ACE_wrappers/ace/Future_Set.cpp @@ -0,0 +1,136 @@ +// $Id: Future_Set.cpp 80826 2008-03-04 14:51:23Z wotte $ + +#ifndef ACE_FUTURE_SET_CPP +#define ACE_FUTURE_SET_CPP + +#include "ace/Future_Set.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +#pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#if defined (ACE_HAS_THREADS) + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +template +ACE_Future_Set::ACE_Future_Set (ACE_Message_Queue *new_queue) + : delete_queue_ (false) +{ + if (new_queue) + this->future_notification_queue_ = new_queue; + else + { + ACE_NEW (this->future_notification_queue_, + ACE_Message_Queue); + this->delete_queue_ = true; + } +} + +template +ACE_Future_Set::~ACE_Future_Set (void) +{ + // Detach ourselves from all remaining futures, if any, in our map. + typename FUTURE_HASH_MAP::iterator iterator = + this->future_map_.begin (); + + typename FUTURE_HASH_MAP::iterator end = + this->future_map_.end (); + + for (; + iterator != end; + ++iterator) + { + FUTURE_HOLDER *future_holder = (*iterator).int_id_; + future_holder->item_.detach (this); + delete future_holder; + } + + if (this->delete_queue_) + delete this->future_notification_queue_; +} + +template int +ACE_Future_Set::is_empty () const +{ + return (((ACE_Future_Set*)this)->future_map_.current_size () == 0 ); +} + +template int +ACE_Future_Set::insert (ACE_Future &future) +{ + FUTURE_HOLDER *future_holder; + ACE_NEW_RETURN (future_holder, + FUTURE_HOLDER (future), + -1); + + FUTURE_REP *future_rep = future.get_rep (); + int result = this->future_map_.bind (future_rep, + future_holder); + + // If a new map entry was created, then attach to the future, + // otherwise we were already attached to the future or some error + // occurred so just delete the future holder. + if ( result == 0 ) + // Attach ourself to the ACE_Futures list of observer + future.attach (this); + else + delete future_holder; + + return result; +} + +template void +ACE_Future_Set::update (const ACE_Future &future) +{ + ACE_Message_Block *mb; + FUTURE &local_future = const_cast &> (future); + + ACE_NEW (mb, + ACE_Message_Block ((char *) local_future.get_rep (), 0)); + + // Enqueue in priority order. + this->future_notification_queue_->enqueue (mb, 0); +} + +template int +ACE_Future_Set::next_readable (ACE_Future &future, + ACE_Time_Value *tv) +{ + if (this->is_empty ()) + return 0; + + ACE_Message_Block *mb = 0; + FUTURE_REP *future_rep = 0; + + // Wait for a "readable future" signal from the message queue. + if (this->future_notification_queue_->dequeue_head (mb, + tv) != -1) + { + // Extract future rep from the message block. + future_rep = reinterpret_cast (mb->base ()); + + // Delete the message block. + mb->release (); + } + else + return 0; + + // Remove the hash map entry with the specified future rep from our map. + FUTURE_HOLDER *future_holder; + if (this->future_map_.find (future_rep, + future_holder) != -1) + { + future = future_holder->item_; + this->future_map_.unbind (future_rep); + delete future_holder; + return 1; + } + + return 0; +} + +ACE_END_VERSIONED_NAMESPACE_DECL + +#endif /* ACE_HAS_THREADS */ +#endif /* ACE_FUTURE_SET_CPP */ diff --git a/dep/ACE_wrappers/ace/Future_Set.h b/dep/ACE_wrappers/ace/Future_Set.h new file mode 100644 index 00000000000..a954d299746 --- /dev/null +++ b/dep/ACE_wrappers/ace/Future_Set.h @@ -0,0 +1,146 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Future_Set.h + * + * $Id: Future_Set.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author John Tucker + */ +//============================================================================= + +#ifndef ACE_FUTURE_SET_H +#define ACE_FUTURE_SET_H +#include /**/ "ace/pre.h" + +#include "ace/Thread.h" +#include "ace/Message_Queue.h" +#include "ace/Future.h" +#include "ace/Hash_Map_Manager_T.h" +#include "ace/Null_Mutex.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +#pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#if defined (ACE_HAS_THREADS) + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +/** + * @class ACE_Future_Set + * + * @brief This class implements a mechanism which allows the values of + * a collection of ACE_Future objects to be accessed by reader threads + * as they become available. The caller(s) provide the ACE_Future_Set + * (i.e. the observer...) with the collection of ACE_Future objects + * (i.e. the subjects...) that are to be observed using the + * the ACE_Future_Set::insert() method. The caller(s) may then iterate + * over the collection in the order in which they become readable using + * the ACE_Future_Set::next_readable() method. + */ +template +class ACE_Future_Set : public ACE_Future_Observer +{ +public: + // = Initialization and termination methods. + + /// Constructor. + ACE_Future_Set (ACE_Message_Queue *future_notification_queue_ = 0); + + /// Destructor. + ~ACE_Future_Set (void); + + /** + * Return 1 if their are no ACE_Future objects left on its queue and + * 0 otherwise. + * + * When an ACE_Future_Set has no ACE_Future>subjects to observe it is + * empty. The ACE_Future_Set is in the empty state when either the caller(s) + * have retrieved every readable ACE_Future subject assigned the + * ACE_Future_Set via the ACE_Future_Set::next_readable() method, + * or when the ACE_Future_Set has not been assigned any subjects. + */ + int is_empty (void) const; + + /** + * Enqueus the given ACE_Future into this objects queue when it is + * readable. + * + * Returns 0 if the future is successfully inserted, 1 if the + * future is already inserted, and -1 if failures occur. + */ + int insert (ACE_Future &future); + + /** + * Wait up to @a tv time to get the @a value. Note that @a tv must be + * specified in absolute time rather than relative time.); get the + * next ACE_Future that is readable. If @a tv = 0, the will block + * forever. + * + * If a readable future becomes available, then the input + * ACE_Future object param will be assigned with it and 1 will + * be returned. If the ACE_Future_Set is empty (i.e. see definition + * of ACE_Future_Set::is_empty()), then 0 is returned. + * + * When a readable ACE_Future object is retrieved via the + * ACE_Future_Set::next_readable() method, the ACE_Future_Set will + * remove that ACE_Future object from its list of subjects. + */ + int next_readable (ACE_Future &result, + ACE_Time_Value *tv = 0); + + /// Called by the ACE_Future subject in which we are subscribed to + /// when its value is written to. + virtual void update (const ACE_Future &future); + + /// Declare the dynamic allocation hooks. + ACE_ALLOC_HOOK_DECLARE; + +private: + // = Disallow these operations. + ACE_UNIMPLEMENTED_FUNC (void operator= (const ACE_Future_Set &)) + ACE_UNIMPLEMENTED_FUNC (ACE_Future_Set (const ACE_Future_Set &)) + + typedef ACE_Future FUTURE; + + typedef ACE_Future_Rep FUTURE_REP; + + typedef ACE_Future_Holder FUTURE_HOLDER; + + typedef ACE_Pointer_Hash FUTURE_REP_HASH; + + typedef ACE_Equal_To FUTURE_REP_COMPARE; + + typedef ACE_Hash_Map_Manager_Ex FUTURE_HASH_MAP; + + /// Map of , subjects, which have not been written to by + /// client's writer thread. + FUTURE_HASH_MAP future_map_; + + /// Message queue for notifying the reader thread of which + /// have been written to by client's writer thread. + ACE_Message_Queue *future_notification_queue_; + + /// Keeps track of whether we need to delete the message queue. + bool delete_queue_; +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) +#include "ace/Future_Set.cpp" +#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ + +#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) +#pragma implementation ("Future_Set.cpp") +#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ + +#endif /* ACE_HAS_THREADS */ +#include /**/ "ace/post.h" +#endif /* ACE_FUTURE_SET_H */ diff --git a/dep/ACE_wrappers/ace/GNUmakefile b/dep/ACE_wrappers/ace/GNUmakefile new file mode 100644 index 00000000000..138ff5e47b3 --- /dev/null +++ b/dep/ACE_wrappers/ace/GNUmakefile @@ -0,0 +1,83 @@ +# -*- makefile -*- +#---------------------------------------------------------------------------- +# GNU ACE Workspace +# +# $Id: GNUACEWorkspaceCreator.pm 80826 2008-03-04 14:51:23Z wotte $ +# +# This file was generated by MPC. Any changes made directly to +# this file will be lost the next time it is generated. +# +# MPC Command: +# /export/anduriltmp/bczar/DOC_ROOT/stage-10168/ACE_wrappers/bin/mwc.pl -type gnuace -exclude "TAO/TAO_*.mwc,TAO/CIAO/CIAO_*.mwc" -recurse -hierarchy -relative ACE_ROOT=/export/anduriltmp/bczar/DOC_ROOT/stage-10168/ACE_wrappers -relative TAO_ROOT=/export/anduriltmp/bczar/DOC_ROOT/stage-10168/ACE_wrappers/TAO -relative CIAO_ROOT=/export/anduriltmp/bczar/DOC_ROOT/stage-10168/ACE_wrappers/TAO/CIAO +# +#---------------------------------------------------------------------------- + +MAKEFILE = GNUmakefile + +ifeq ($(findstring k,$(MAKEFLAGS)),k) + KEEP_GOING = - +endif + +include $(ACE_ROOT)/include/makeinclude/macros.GNU + +all: ACE ACE_FlReactor ACE_Qt3Reactor ACE_TkReactor ACE_XtReactor ACE_ETCL ACE_ETCL_Parser Monitor_Control-target SSL-target + +REMAINING_TARGETS := $(subst all, , $(TARGETS_NESTED:.nested=)) $(CUSTOM_TARGETS) + +$(REMAINING_TARGETS): + @$(MAKE) -f GNUmakefile.ACE $(@) + @$(MAKE) -f GNUmakefile.ACE_FlReactor $(@) + @$(MAKE) -f GNUmakefile.ACE_Qt3Reactor $(@) + @$(MAKE) -f GNUmakefile.ACE_TkReactor $(@) + @$(MAKE) -f GNUmakefile.ACE_XtReactor $(@) + @cd ETCL && $(MAKE) -f GNUmakefile.ACE_ETCL $(@) + @cd ETCL && $(MAKE) -f GNUmakefile.ACE_ETCL_Parser $(@) + @cd Monitor_Control && $(MAKE) -f GNUmakefile.Monitor_Control $(@) + @cd SSL && $(MAKE) -f GNUmakefile.SSL $(@) + +.PHONY: ACE +ACE: + @$(MAKE) -f GNUmakefile.ACE all + +.PHONY: ACE_FlReactor +ACE_FlReactor: ACE + @$(MAKE) -f GNUmakefile.ACE_FlReactor all + +.PHONY: ACE_Qt3Reactor +ACE_Qt3Reactor: ACE + @$(MAKE) -f GNUmakefile.ACE_Qt3Reactor all + +.PHONY: ACE_TkReactor +ACE_TkReactor: ACE + @$(MAKE) -f GNUmakefile.ACE_TkReactor all + +.PHONY: ACE_XtReactor +ACE_XtReactor: ACE + @$(MAKE) -f GNUmakefile.ACE_XtReactor all + +.PHONY: ACE_ETCL +ACE_ETCL: ACE + @cd ETCL && $(MAKE) -f GNUmakefile.ACE_ETCL all + +.PHONY: ACE_ETCL_Parser +ACE_ETCL_Parser: ACE ACE_ETCL + @cd ETCL && $(MAKE) -f GNUmakefile.ACE_ETCL_Parser all + +.PHONY: Monitor_Control-target +Monitor_Control-target: ACE ACE_ETCL ACE_ETCL_Parser + @cd Monitor_Control && $(MAKE) -f GNUmakefile.Monitor_Control all + +.PHONY: SSL-target +SSL-target: ACE + @cd SSL && $(MAKE) -f GNUmakefile.SSL all + +project_name_list: + @echo ACE_ETCL + @echo ACE_ETCL_Parser + @echo ACE + @echo ACE_FlReactor + @echo ACE_Qt3Reactor + @echo ACE_TkReactor + @echo ACE_XtReactor + @echo Monitor_Control-target + @echo SSL-target diff --git a/dep/ACE_wrappers/ace/GNUmakefile.ACE b/dep/ACE_wrappers/ace/GNUmakefile.ACE new file mode 100644 index 00000000000..b559137bed1 --- /dev/null +++ b/dep/ACE_wrappers/ace/GNUmakefile.ACE @@ -0,0 +1,485 @@ +# -*- Makefile -*- +#---------------------------------------------------------------------------- +# GNU Makefile +# +# @file GNUmakefile.ACE +# +# $Id: gnu.mpd 82648 2008-08-21 06:55:54Z johnnyw $ +# +# This file was automatically generated by MPC. Any changes made directly to +# this file will be lost the next time it is generated. +# +#---------------------------------------------------------------------------- +MAKEFILE = GNUmakefile.ACE +DEPENDENCY_FILE = .depend.ACE + +## LIB may be set to empty later on in this file +LIB_UNCHECKED = libACE.a +LIB = $(LIB_UNCHECKED) +LIB_NAME = libACE + +## SHLIB may be set to empty later on in this file +SHLIB_UNCHECKED = libACE.$(SOEXT) +SHLIB = $(SHLIB_UNCHECKED) + +FILES = \ + Local_Name_Space.cpp \ + Name_Proxy.cpp \ + Name_Request_Reply.cpp \ + Name_Space.cpp \ + Naming_Context.cpp \ + Registry_Name_Space.cpp \ + Remote_Name_Space.cpp \ + NT_Service.cpp \ + Codecs.cpp \ + Local_Tokens.cpp \ + Remote_Tokens.cpp \ + Token_Collection.cpp \ + Token_Invariants.cpp \ + Token_Manager.cpp \ + Token_Request_Reply.cpp \ + DLL.cpp \ + Dynamic_Service_Base.cpp \ + Dynamic_Service_Dependency.cpp \ + Parse_Node.cpp \ + Service_Config.cpp \ + Service_Gestalt.cpp \ + Service_Manager.cpp \ + Service_Object.cpp \ + Service_Repository.cpp \ + Service_Types.cpp \ + Shared_Object.cpp \ + Svc_Conf_Lexer.cpp \ + Svc_Conf_y.cpp \ + Encoding_Converter.cpp \ + Encoding_Converter_Factory.cpp \ + UTF8_Encoding_Converter.cpp \ + UTF16_Encoding_Converter.cpp \ + UTF32_Encoding_Converter.cpp \ + XML_Svc_Conf.cpp \ + UUID.cpp \ + Filecache.cpp \ + ACE.cpp \ + ACE_crc_ccitt.cpp \ + ACE_crc32.cpp \ + ace_wchar.cpp \ + Activation_Queue.cpp \ + Active_Map_Manager.cpp \ + Addr.cpp \ + Argv_Type_Converter.cpp \ + Assert.cpp \ + Asynch_IO.cpp \ + Asynch_IO_Impl.cpp \ + Asynch_Pseudo_Task.cpp \ + ATM_Acceptor.cpp \ + ATM_Addr.cpp \ + ATM_Connector.cpp \ + ATM_Params.cpp \ + ATM_QoS.cpp \ + ATM_Stream.cpp \ + Atomic_Op.cpp \ + Atomic_Op_Sparc.c \ + Auto_Event.cpp \ + Barrier.cpp \ + Base_Thread_Adapter.cpp \ + Based_Pointer_Repository.cpp \ + Basic_Stats.cpp \ + Basic_Types.cpp \ + Capabilities.cpp \ + CDR_Base.cpp \ + CDR_Stream.cpp \ + CDR_Size.cpp \ + Cleanup.cpp \ + Codeset_IBM1047.cpp \ + Codeset_Registry.cpp \ + Codeset_Registry_db.cpp \ + Condition_Recursive_Thread_Mutex.cpp \ + Condition_Thread_Mutex.cpp \ + Configuration.cpp \ + Configuration_Import_Export.cpp \ + Connection_Recycling_Strategy.cpp \ + Containers.cpp \ + Copy_Disabled.cpp \ + Countdown_Time.cpp \ + Date_Time.cpp \ + DEV.cpp \ + DEV_Addr.cpp \ + DEV_Connector.cpp \ + DEV_IO.cpp \ + DLL_Manager.cpp \ + Dev_Poll_Reactor.cpp \ + Dirent.cpp \ + Dirent_Selector.cpp \ + Dump.cpp \ + Dynamic.cpp \ + Dynamic_Message_Strategy.cpp \ + Event.cpp \ + Event_Handler.cpp \ + FIFO.cpp \ + FIFO_Recv.cpp \ + FIFO_Recv_Msg.cpp \ + FIFO_Send.cpp \ + FIFO_Send_Msg.cpp \ + FILE.cpp \ + FILE_Addr.cpp \ + FILE_Connector.cpp \ + FILE_IO.cpp \ + File_Lock.cpp \ + Flag_Manip.cpp \ + Framework_Component.cpp \ + Functor.cpp \ + Functor_String.cpp \ + Get_Opt.cpp \ + gethrtime.cpp \ + Handle_Ops.cpp \ + Handle_Set.cpp \ + Hashable.cpp \ + High_Res_Timer.cpp \ + ICMP_Socket.cpp \ + INET_Addr.cpp \ + Init_ACE.cpp \ + IO_SAP.cpp \ + IO_Cntl_Msg.cpp \ + IOStream.cpp \ + IPC_SAP.cpp \ + Lib_Find.cpp \ + Local_Memory_Pool.cpp \ + Lock.cpp \ + Log_Msg.cpp \ + Log_Msg_Backend.cpp \ + Log_Msg_Callback.cpp \ + Log_Msg_IPC.cpp \ + Log_Msg_NT_Event_Log.cpp \ + Log_Msg_UNIX_Syslog.cpp \ + Log_Record.cpp \ + Logging_Strategy.cpp \ + LSOCK.cpp \ + LSOCK_Acceptor.cpp \ + LSOCK_CODgram.cpp \ + LSOCK_Connector.cpp \ + LSOCK_Dgram.cpp \ + LSOCK_Stream.cpp \ + Malloc.cpp \ + Malloc_Allocator.cpp \ + Manual_Event.cpp \ + MEM_Acceptor.cpp \ + MEM_Addr.cpp \ + MEM_Connector.cpp \ + MEM_IO.cpp \ + Mem_Map.cpp \ + MEM_SAP.cpp \ + MEM_Stream.cpp \ + Message_Block.cpp \ + Message_Queue.cpp \ + Message_Queue_NT.cpp \ + Message_Queue_Vx.cpp \ + Method_Request.cpp \ + MMAP_Memory_Pool.cpp \ + Msg_WFMO_Reactor.cpp \ + Monitor_Admin.cpp \ + Monitor_Admin_Manager.cpp \ + Monitor_Base.cpp \ + Monitor_Point_Registry.cpp \ + Monitor_Size.cpp \ + Monitor_Control_Types.cpp \ + Monitor_Control_Action.cpp \ + Multihomed_INET_Addr.cpp \ + Mutex.cpp \ + Netlink_Addr.cpp \ + Notification_Strategy.cpp \ + Notification_Queue.cpp \ + Obchunk.cpp \ + Object_Manager.cpp \ + Object_Manager_Base.cpp \ + OS_Errno.cpp \ + OS_Log_Msg_Attributes.cpp \ + OS_main.cpp \ + OS_NS_arpa_inet.cpp \ + OS_NS_ctype.cpp \ + OS_NS_dirent.cpp \ + OS_NS_dlfcn.cpp \ + OS_NS_errno.cpp \ + OS_NS_fcntl.cpp \ + OS_NS_math.cpp \ + OS_NS_netdb.cpp \ + OS_NS_poll.cpp \ + OS_NS_pwd.cpp \ + OS_NS_regex.cpp \ + OS_NS_signal.cpp \ + OS_NS_stdio.cpp \ + OS_NS_stdlib.cpp \ + OS_NS_string.cpp \ + OS_NS_strings.cpp \ + OS_NS_stropts.cpp \ + OS_NS_sys_mman.cpp \ + OS_NS_sys_msg.cpp \ + OS_NS_sys_resource.cpp \ + OS_NS_sys_select.cpp \ + OS_NS_sys_sendfile.cpp \ + OS_NS_sys_shm.cpp \ + OS_NS_sys_socket.cpp \ + OS_NS_sys_stat.cpp \ + OS_NS_sys_time.cpp \ + OS_NS_sys_uio.cpp \ + OS_NS_sys_utsname.cpp \ + OS_NS_sys_wait.cpp \ + OS_NS_Thread.cpp \ + OS_NS_time.cpp \ + OS_NS_unistd.cpp \ + OS_NS_wchar.cpp \ + OS_QoS.cpp \ + OS_Thread_Adapter.cpp \ + OS_TLI.cpp \ + Pagefile_Memory_Pool.cpp \ + PI_Malloc.cpp \ + Ping_Socket.cpp \ + Pipe.cpp \ + POSIX_Asynch_IO.cpp \ + POSIX_CB_Proactor.cpp \ + POSIX_Proactor.cpp \ + Priority_Reactor.cpp \ + Proactor.cpp \ + Proactor_Impl.cpp \ + Process.cpp \ + Process_Manager.cpp \ + Process_Mutex.cpp \ + Process_Semaphore.cpp \ + Profile_Timer.cpp \ + Reactor.cpp \ + Reactor_Impl.cpp \ + Reactor_Notification_Strategy.cpp \ + Reactor_Timer_Interface.cpp \ + Read_Buffer.cpp \ + Recursive_Thread_Mutex.cpp \ + Recyclable.cpp \ + Registry.cpp \ + Rtems_init.c \ + RW_Mutex.cpp \ + RW_Process_Mutex.cpp \ + RW_Thread_Mutex.cpp \ + Sample_History.cpp \ + Sbrk_Memory_Pool.cpp \ + Sched_Params.cpp \ + Select_Reactor_Base.cpp \ + Semaphore.cpp \ + Shared_Memory.cpp \ + Shared_Memory_MM.cpp \ + Shared_Memory_Pool.cpp \ + Shared_Memory_SV.cpp \ + Sig_Adapter.cpp \ + Sig_Handler.cpp \ + Signal.cpp \ + SOCK.cpp \ + SOCK_Acceptor.cpp \ + SOCK_CODgram.cpp \ + Sock_Connect.cpp \ + SOCK_Connector.cpp \ + SOCK_Dgram.cpp \ + SOCK_Dgram_Bcast.cpp \ + SOCK_Dgram_Mcast.cpp \ + SOCK_IO.cpp \ + SOCK_Netlink.cpp \ + SOCK_SEQPACK_Acceptor.cpp \ + SOCK_SEQPACK_Association.cpp \ + SOCK_SEQPACK_Connector.cpp \ + SOCK_Stream.cpp \ + SPIPE.cpp \ + SPIPE_Acceptor.cpp \ + SPIPE_Addr.cpp \ + SPIPE_Connector.cpp \ + SPIPE_Stream.cpp \ + SString.cpp \ + Stack_Trace.cpp \ + Stats.cpp \ + String_Base_Const.cpp \ + SUN_Proactor.cpp \ + SV_Message.cpp \ + SV_Message_Queue.cpp \ + SV_Semaphore_Complex.cpp \ + SV_Semaphore_Simple.cpp \ + SV_Shared_Memory.cpp \ + Synch_Options.cpp \ + System_Time.cpp \ + Task.cpp \ + Thread.cpp \ + Thread_Adapter.cpp \ + Thread_Control.cpp \ + Thread_Exit.cpp \ + Thread_Hook.cpp \ + Thread_Manager.cpp \ + Thread_Mutex.cpp \ + Thread_Semaphore.cpp \ + Throughput_Stats.cpp \ + Time_Value.cpp \ + Timeprobe.cpp \ + TLI.cpp \ + TLI_Acceptor.cpp \ + TLI_Connector.cpp \ + TLI_Stream.cpp \ + Token.cpp \ + TP_Reactor.cpp \ + Trace.cpp \ + TSS_Adapter.cpp \ + TTY_IO.cpp \ + UNIX_Addr.cpp \ + UPIPE_Acceptor.cpp \ + UPIPE_Connector.cpp \ + UPIPE_Stream.cpp \ + WFMO_Reactor.cpp \ + WIN32_Asynch_IO.cpp \ + WIN32_Proactor.cpp \ + XTI_ATM_Mcast.cpp + +#---------------------------------------------------------------------------- +# Include macros and targets +#---------------------------------------------------------------------------- +ACE_SHLIBS = + +PRJ_TYPE = library + +INSLIB ?= ../lib +ifeq ($(INSLIB),.) + ifeq ($(PWD),) + PWD=$(shell pwd) + endif + INSLIB = $(PWD) +endif +OUTPUT_DIRECTORY = $(INSLIB) + +include $(ACE_ROOT)/include/makeinclude/wrapper_macros.GNU + +ifneq (,$(RC)) +RESOURCES += \ + ace.rc + +RCFLAGS = \ + --include-dir=.. +endif + +# To build multiple targets in the same directory on AIX, it works +# best to have a template directory per project. +# The compiler/linker isn't too smart about instantiating templates... +ifdef TEMPINCDIR +TEMPINCDIR := $(TEMPINCDIR)/ACE +all: $(TEMPINCDIR) +endif + +ifneq ($(OUTPUT_DIRECTORY),) +all: $(OUTPUT_DIRECTORY) +$(OUTPUT_DIRECTORY): + -@$(MKDIR) "$(OUTPUT_DIRECTORY)" +endif + +LIBCHECK = 1 +ifneq ($(ace_for_tao),1) +ifneq ($(LIBCHECK), 1) + LIB = + SHLIB = + all: lib_warning +endif +else + LIB = + SHLIB = + all: avoid_warning +endif + +ifneq ($(ace_for_tao),1) +else + LIB = + SHLIB = + all: avoid_warning +endif +LSRC = $(FILES) + +include $(ACE_ROOT)/include/makeinclude/macros.GNU +include $(ACE_ROOT)/include/makeinclude/rules.common.GNU +include $(ACE_ROOT)/include/makeinclude/rules.nonested.GNU +include $(ACE_ROOT)/include/makeinclude/rules.lib.GNU +include $(ACE_ROOT)/include/makeinclude/rules.local.GNU +ifeq ($(VXWORKSLINK),1) +include $(TGT_DIR)/h/make/rules.$(PRJ_TYPE) +endif + +ifeq ($(VXWORKSLINK),1) +LDLIBPATH = -L. -L../lib +else +LDFLAGS += -L. -L../lib +endif +CPPFLAGS += -I.. +ifeq ($(shared_libs),1) + ifneq ($(SHLIB),) + CPPFLAGS += -DACE_BUILD_DLL + endif +endif +ifeq ($(static_libs),1) + CPPFLAGS += -DACE_AS_STATIC_LIBS +endif + +#---------------------------------------------------------------------------- +# Local targets +#---------------------------------------------------------------------------- +Svc_Conf_y.cpp: Svc_Conf.y +ifeq ($(notdir $(YACC)), bison) + $(YACC) -l -d Svc_Conf.y + sed -e 's/fprintf/ACE_OS::fprintf/g' \ + -e 's/\t/ /g' \ + -e 's/yy/ace_yy/g' \ + -e 's/->ace_yyerrno/->yyerrno/g' \ + -e 's/->ace_yylineno/->yylineno/g' \ + -e 's/ NULL/ 0/g' \ + -e 's/ace_yyerror[ ]*([ ]*"/ace_yyerror (ACE_SVC_CONF_PARAM->yyerrno, ACE_SVC_CONF_PARAM->yylineno, "/g' \ + -e 's/ace_yyerror[ ]*([ ]*ace_yymsg/ace_yyerror (ACE_SVC_CONF_PARAM->yyerrno, ACE_SVC_CONF_PARAM->yylineno, ace_yymsg/g' \ + -e 's/ace_yyerror[ ]*([ ]*YY_/ace_yyerror (ACE_SVC_CONF_PARAM->yyerrno, ACE_SVC_CONF_PARAM->yylineno, YY_/g' \ + -e 's@#include @@' \ + -e 's/Svc_Conf\.tab\.c/Svc_Conf_y.cpp/g' $@ + $(RM) -f Svc_Conf.tab.c Svc_Conf_y.cpp.orig +else + @echo 'ERROR: You must use bison 1.35 or higher to process this file' + @/bin/false +endif + +Svc_Conf_Token_Table.h: Svc_Conf.y Svc_Conf_y.cpp +ifeq ($(notdir $(YACC)), bison) + mv Svc_Conf.tab.h Svc_Conf_Token_Table.h +else + @echo 'ERROR: You must use bison 1.35 or higher to process this file' + @/bin/false +endif + +lib_warning: + @echo ACE will not be built due to the following missing library: + @echo $(LIBCHECK) + +avoid_warning: + @echo ACE will not be built due to one of the following enabled make macros: + @echo ace_for_tao + +## Some OS's have /bin/test others only have /usr/bin/test +ifeq ($(wildcard /bin/test), /bin/test) + TEST_EXE = /bin/test +else +ifeq ($(wildcard /usr/bin/test), /usr/bin/test) + TEST_EXE = /usr/bin/test +endif +endif + +ifneq ($(GENERATED_DIRTY),) +.PRECIOUS: $(GENERATED_DIRTY) +## If the generated files are anything but source files, we need to +## ensure that those files are generated before we attempt to build anything +## else. +ifeq ($(OBJS_DEPEND_ON_GENERATED),1) +$(VDIR)$(ACE_PCH_FILE) $(addprefix $(VDIR), $(OBJS)): $(GENERATED_DIRTY) +$(VSHDIR)$(ACE_PCH_FILE) $(VSHOBJS): $(GENERATED_DIRTY) +endif +endif + + +realclean: clean +ifneq ($(GENERATED_DIRTY),) + -$(RM) -r $(GENERATED_DIRTY) +endif + +__prebuild__: + @-: + diff --git a/dep/ACE_wrappers/ace/GNUmakefile.ACE_FlReactor b/dep/ACE_wrappers/ace/GNUmakefile.ACE_FlReactor new file mode 100644 index 00000000000..2a9d9908c34 --- /dev/null +++ b/dep/ACE_wrappers/ace/GNUmakefile.ACE_FlReactor @@ -0,0 +1,189 @@ +# -*- Makefile -*- +#---------------------------------------------------------------------------- +# GNU Makefile +# +# @file GNUmakefile.ACE_FlReactor +# +# $Id: gnu.mpd 82648 2008-08-21 06:55:54Z johnnyw $ +# +# This file was automatically generated by MPC. Any changes made directly to +# this file will be lost the next time it is generated. +# +#---------------------------------------------------------------------------- +MAKEFILE = GNUmakefile.ACE_FlReactor +DEPENDENCY_FILE = .depend.ACE_FlReactor + +## LIB may be set to empty later on in this file +LIB_UNCHECKED = libACE_FlReactor.a +LIB = $(LIB_UNCHECKED) +LIB_NAME = libACE_FlReactor + +## SHLIB may be set to empty later on in this file +SHLIB_UNCHECKED = libACE_FlReactor.$(SOEXT) +SHLIB = $(SHLIB_UNCHECKED) + +FILES = \ + FlReactor/FlReactor.cpp + +VPATH = .:FlReactor + +#---------------------------------------------------------------------------- +# Include macros and targets +#---------------------------------------------------------------------------- +ACE_SHLIBS = -lACE + +PRJ_TYPE = library + +INSLIB ?= ../lib +ifeq ($(INSLIB),.) + ifeq ($(PWD),) + PWD=$(shell pwd) + endif + INSLIB = $(PWD) +endif +OUTPUT_DIRECTORY = $(INSLIB) + +include $(ACE_ROOT)/include/makeinclude/wrapper_macros.GNU + +# To build multiple targets in the same directory on AIX, it works +# best to have a template directory per project. +# The compiler/linker isn't too smart about instantiating templates... +ifdef TEMPINCDIR +TEMPINCDIR := $(TEMPINCDIR)/ACE_FlReactor +all: $(TEMPINCDIR) +endif + +ifneq ($(OUTPUT_DIRECTORY),) +all: $(OUTPUT_DIRECTORY) +$(OUTPUT_DIRECTORY): + -@$(MKDIR) "$(OUTPUT_DIRECTORY)" +endif + +# turn off libcheck if doing a dry run +ifeq ($(findstring n, $(MAKEFLAGS)),n) + LIBCHECK = 1 +else + # turn off libcheck if keep going was passed too + ifeq ($(findstring k, $(MAKEFLAGS)),k) + LIBCHECK = 1 + else + LIBCHECK ?= $(filter-out $(foreach lib,ACE,$(findstring $(lib),$(foreach libpath,. ../lib /usr/lib /usr/lib64 $(INSLIB),$(wildcard $(libpath)/lib$(lib).* $(libpath)/$(lib).lib)))),ACE) + ifeq ($(LIBCHECK),) + LIBCHECK = 1 + endif + endif +endif +ifeq ($(x11),1) +ifeq ($(gl),1) +ifeq ($(fl),1) +ifneq ($(LIBCHECK), 1) + LIB = + SHLIB = + all: lib_warning +endif +else + LIB = + SHLIB = + all: require_warning +endif +else + LIB = + SHLIB = + all: require_warning +endif +else + LIB = + SHLIB = + all: require_warning +endif + +ifeq ($(x11),1) +ifeq ($(gl),1) +ifeq ($(fl),1) +else + LIB = + SHLIB = + all: require_warning +endif +else + LIB = + SHLIB = + all: require_warning +endif +else + LIB = + SHLIB = + all: require_warning +endif +LSRC = $(FILES) + +include $(ACE_ROOT)/include/makeinclude/macros.GNU +include $(ACE_ROOT)/include/makeinclude/rules.common.GNU +include $(ACE_ROOT)/include/makeinclude/rules.nonested.GNU +include $(ACE_ROOT)/include/makeinclude/rules.lib.GNU +include $(ACE_ROOT)/include/makeinclude/rules.local.GNU +ifeq ($(VXWORKSLINK),1) +include $(TGT_DIR)/h/make/rules.$(PRJ_TYPE) +endif + +ifeq ($(VXWORKSLINK),1) +LDLIBPATH = -L. -L../lib +else +LDFLAGS += -L. -L../lib +endif +CPPFLAGS += -I.. +ifeq ($(shared_libs),1) + ifneq ($(SHLIB),) + CPPFLAGS += -DACE_FLREACTOR_BUILD_DLL + endif +endif +ifeq ($(static_libs),1) + CPPFLAGS += -DACE_AS_STATIC_LIBS +endif + +#---------------------------------------------------------------------------- +# Local targets +#---------------------------------------------------------------------------- +CPPFLAGS += $(PLATFORM_FL_CPPFLAGS) +CPPFLAGS += $(PLATFORM_GL_CPPFLAGS) $(PLATFORM_X11_CPPFLAGS) +LIBS += $(PLATFORM_FL_LIBS) $(PLATFORM_GL_LIBS) $(PLATFORM_X11_LIBS) +LDFLAGS += $(PLATFORM_FL_LDFLAGS) $(PLATFORM_GL_LDFLAGS) +LDFLAGS += $(PLATFORM_GL_LDFLAGS) + +lib_warning: + @echo ACE_FlReactor will not be built due to the following missing library: + @echo $(LIBCHECK) + +require_warning: + @echo ACE_FlReactor will not be built due to one of the following disabled make macros: + @echo x11 gl fl + +## Some OS's have /bin/test others only have /usr/bin/test +ifeq ($(wildcard /bin/test), /bin/test) + TEST_EXE = /bin/test +else +ifeq ($(wildcard /usr/bin/test), /usr/bin/test) + TEST_EXE = /usr/bin/test +endif +endif + +ifneq ($(GENERATED_DIRTY),) +.PRECIOUS: $(GENERATED_DIRTY) +## If the generated files are anything but source files, we need to +## ensure that those files are generated before we attempt to build anything +## else. +ifeq ($(OBJS_DEPEND_ON_GENERATED),1) +$(VDIR)$(ACE_PCH_FILE) $(addprefix $(VDIR), $(OBJS)): $(GENERATED_DIRTY) +$(VSHDIR)$(ACE_PCH_FILE) $(VSHOBJS): $(GENERATED_DIRTY) +endif +endif + + +realclean: clean +ifneq ($(GENERATED_DIRTY),) + -$(RM) -r $(GENERATED_DIRTY) +endif + +__prebuild__: + @-: + diff --git a/dep/ACE_wrappers/ace/GNUmakefile.ACE_Qt3Reactor b/dep/ACE_wrappers/ace/GNUmakefile.ACE_Qt3Reactor new file mode 100644 index 00000000000..ea7f38d17d3 --- /dev/null +++ b/dep/ACE_wrappers/ace/GNUmakefile.ACE_Qt3Reactor @@ -0,0 +1,169 @@ +# -*- Makefile -*- +#---------------------------------------------------------------------------- +# GNU Makefile +# +# @file GNUmakefile.ACE_Qt3Reactor +# +# $Id: gnu.mpd 82648 2008-08-21 06:55:54Z johnnyw $ +# +# This file was automatically generated by MPC. Any changes made directly to +# this file will be lost the next time it is generated. +# +#---------------------------------------------------------------------------- +MAKEFILE = GNUmakefile.ACE_Qt3Reactor +DEPENDENCY_FILE = .depend.ACE_Qt3Reactor + +## LIB may be set to empty later on in this file +LIB_UNCHECKED = libACE_QtReactor.a +LIB = $(LIB_UNCHECKED) +LIB_NAME = libACE_QtReactor + +## SHLIB may be set to empty later on in this file +SHLIB_UNCHECKED = libACE_QtReactor.$(SOEXT) +SHLIB = $(SHLIB_UNCHECKED) + +FILES = \ + QtReactor/QtReactor_moc.cpp \ + QtReactor/QtReactor.cpp + +VPATH = .:QtReactor + +#---------------------------------------------------------------------------- +# Include macros and targets +#---------------------------------------------------------------------------- +ACE_SHLIBS = -lACE -lqt-mt$(QT_VERSION) + +PRJ_TYPE = library + +INSLIB ?= ../lib +ifeq ($(INSLIB),.) + ifeq ($(PWD),) + PWD=$(shell pwd) + endif + INSLIB = $(PWD) +endif +OUTPUT_DIRECTORY = $(INSLIB) + +include $(ACE_ROOT)/include/makeinclude/wrapper_macros.GNU + +# To build multiple targets in the same directory on AIX, it works +# best to have a template directory per project. +# The compiler/linker isn't too smart about instantiating templates... +ifdef TEMPINCDIR +TEMPINCDIR := $(TEMPINCDIR)/ACE_Qt3Reactor +all: $(TEMPINCDIR) +endif + +ifneq ($(OUTPUT_DIRECTORY),) +all: $(OUTPUT_DIRECTORY) +$(OUTPUT_DIRECTORY): + -@$(MKDIR) "$(OUTPUT_DIRECTORY)" +endif + +# turn off libcheck if doing a dry run +ifeq ($(findstring n, $(MAKEFLAGS)),n) + LIBCHECK = 1 +else + # turn off libcheck if keep going was passed too + ifeq ($(findstring k, $(MAKEFLAGS)),k) + LIBCHECK = 1 + else + LIBCHECK ?= $(filter-out $(foreach lib,ACE,$(findstring $(lib),$(foreach libpath,. ../lib $(QTDIR)/lib /usr/lib /usr/lib64 $(INSLIB),$(wildcard $(libpath)/lib$(lib).* $(libpath)/$(lib).lib)))),ACE) + ifeq ($(LIBCHECK),) + LIBCHECK = 1 + endif + endif +endif +ifeq ($(qt),1) +ifneq ($(LIBCHECK), 1) + LIB = + SHLIB = + all: lib_warning +endif +else + LIB = + SHLIB = + all: require_warning +endif + +ifeq ($(qt),1) +else + LIB = + SHLIB = + all: require_warning +endif +LSRC = $(FILES) + +include $(ACE_ROOT)/include/makeinclude/macros.GNU +include $(ACE_ROOT)/include/makeinclude/rules.common.GNU +include $(ACE_ROOT)/include/makeinclude/rules.nonested.GNU +include $(ACE_ROOT)/include/makeinclude/rules.lib.GNU +include $(ACE_ROOT)/include/makeinclude/rules.local.GNU +ifeq ($(VXWORKSLINK),1) +include $(TGT_DIR)/h/make/rules.$(PRJ_TYPE) +endif + +ifeq ($(VXWORKSLINK),1) +LDLIBPATH = -L. -L../lib -L$(QTDIR)/lib +else +LDFLAGS += -L. -L../lib -L$(QTDIR)/lib +endif +CPPFLAGS += -I.. -I$(QTDIR)/include +CPPFLAGS += -DQT_THREAD_SUPPORT +ifeq ($(shared_libs),1) + ifneq ($(SHLIB),) + CPPFLAGS += -DACE_QTREACTOR_BUILD_DLL + endif +endif +ifeq ($(static_libs),1) + CPPFLAGS += -DACE_AS_STATIC_LIBS +endif + +#---------------------------------------------------------------------------- +# Local targets +#---------------------------------------------------------------------------- +CPPFLAGS += $(PLATFORM_QT_CPPFLAGS) +LIBS += $(PLATFORM_QT_LIBS) +LDFLAGS += $(PLATFORM_QT_LDFLAGS) + +lib_warning: + @echo ACE_Qt3Reactor will not be built due to the following missing library: + @echo $(LIBCHECK) + +require_warning: + @echo ACE_Qt3Reactor will not be built due to one of the following disabled make macros: + @echo qt + +## Some OS's have /bin/test others only have /usr/bin/test +ifeq ($(wildcard /bin/test), /bin/test) + TEST_EXE = /bin/test +else +ifeq ($(wildcard /usr/bin/test), /usr/bin/test) + TEST_EXE = /usr/bin/test +endif +endif + +GENERATED_DIRTY += QtReactor/QtReactor_moc.cpp +QtReactor/QtReactor_moc.cpp: QtReactor/QtReactor.h + $(QTDIR)/bin/moc QtReactor/QtReactor.h -o $@ + +ifneq ($(GENERATED_DIRTY),) +.PRECIOUS: $(GENERATED_DIRTY) +## If the generated files are anything but source files, we need to +## ensure that those files are generated before we attempt to build anything +## else. +ifeq ($(OBJS_DEPEND_ON_GENERATED),1) +$(VDIR)$(ACE_PCH_FILE) $(addprefix $(VDIR), $(OBJS)): $(GENERATED_DIRTY) +$(VSHDIR)$(ACE_PCH_FILE) $(VSHOBJS): $(GENERATED_DIRTY) +endif +endif + + +realclean: clean +ifneq ($(GENERATED_DIRTY),) + -$(RM) -r $(GENERATED_DIRTY) +endif + +__prebuild__: + @-: + diff --git a/dep/ACE_wrappers/ace/GNUmakefile.ACE_TkReactor b/dep/ACE_wrappers/ace/GNUmakefile.ACE_TkReactor new file mode 100644 index 00000000000..efd388ced9f --- /dev/null +++ b/dep/ACE_wrappers/ace/GNUmakefile.ACE_TkReactor @@ -0,0 +1,163 @@ +# -*- Makefile -*- +#---------------------------------------------------------------------------- +# GNU Makefile +# +# @file GNUmakefile.ACE_TkReactor +# +# $Id: gnu.mpd 82648 2008-08-21 06:55:54Z johnnyw $ +# +# This file was automatically generated by MPC. Any changes made directly to +# this file will be lost the next time it is generated. +# +#---------------------------------------------------------------------------- +MAKEFILE = GNUmakefile.ACE_TkReactor +DEPENDENCY_FILE = .depend.ACE_TkReactor + +## LIB may be set to empty later on in this file +LIB_UNCHECKED = libACE_TkReactor.a +LIB = $(LIB_UNCHECKED) +LIB_NAME = libACE_TkReactor + +## SHLIB may be set to empty later on in this file +SHLIB_UNCHECKED = libACE_TkReactor.$(SOEXT) +SHLIB = $(SHLIB_UNCHECKED) + +FILES = \ + TkReactor/TkReactor.cpp + +VPATH = .:TkReactor + +#---------------------------------------------------------------------------- +# Include macros and targets +#---------------------------------------------------------------------------- +ACE_SHLIBS = -lACE + +PRJ_TYPE = library + +INSLIB ?= ../lib +ifeq ($(INSLIB),.) + ifeq ($(PWD),) + PWD=$(shell pwd) + endif + INSLIB = $(PWD) +endif +OUTPUT_DIRECTORY = $(INSLIB) + +include $(ACE_ROOT)/include/makeinclude/wrapper_macros.GNU + +# To build multiple targets in the same directory on AIX, it works +# best to have a template directory per project. +# The compiler/linker isn't too smart about instantiating templates... +ifdef TEMPINCDIR +TEMPINCDIR := $(TEMPINCDIR)/ACE_TkReactor +all: $(TEMPINCDIR) +endif + +ifneq ($(OUTPUT_DIRECTORY),) +all: $(OUTPUT_DIRECTORY) +$(OUTPUT_DIRECTORY): + -@$(MKDIR) "$(OUTPUT_DIRECTORY)" +endif + +# turn off libcheck if doing a dry run +ifeq ($(findstring n, $(MAKEFLAGS)),n) + LIBCHECK = 1 +else + # turn off libcheck if keep going was passed too + ifeq ($(findstring k, $(MAKEFLAGS)),k) + LIBCHECK = 1 + else + LIBCHECK ?= $(filter-out $(foreach lib,ACE,$(findstring $(lib),$(foreach libpath,. ../lib /usr/lib /usr/lib64 $(INSLIB),$(wildcard $(libpath)/lib$(lib).* $(libpath)/$(lib).lib)))),ACE) + ifeq ($(LIBCHECK),) + LIBCHECK = 1 + endif + endif +endif +ifeq ($(tk),1) +ifneq ($(LIBCHECK), 1) + LIB = + SHLIB = + all: lib_warning +endif +else + LIB = + SHLIB = + all: require_warning +endif + +ifeq ($(tk),1) +else + LIB = + SHLIB = + all: require_warning +endif +LSRC = $(FILES) + +include $(ACE_ROOT)/include/makeinclude/macros.GNU +include $(ACE_ROOT)/include/makeinclude/rules.common.GNU +include $(ACE_ROOT)/include/makeinclude/rules.nonested.GNU +include $(ACE_ROOT)/include/makeinclude/rules.lib.GNU +include $(ACE_ROOT)/include/makeinclude/rules.local.GNU +ifeq ($(VXWORKSLINK),1) +include $(TGT_DIR)/h/make/rules.$(PRJ_TYPE) +endif + +ifeq ($(VXWORKSLINK),1) +LDLIBPATH = -L. -L../lib +else +LDFLAGS += -L. -L../lib +endif +CPPFLAGS += -I.. +ifeq ($(shared_libs),1) + ifneq ($(SHLIB),) + CPPFLAGS += -DACE_TKREACTOR_BUILD_DLL + endif +endif +ifeq ($(static_libs),1) + CPPFLAGS += -DACE_AS_STATIC_LIBS +endif + +#---------------------------------------------------------------------------- +# Local targets +#---------------------------------------------------------------------------- +CPPFLAGS += $(PLATFORM_TCL_CPPFLAGS) $(PLATFORM_TK_CPPFLAGS) +LIBS += $(PLATFORM_TCL_LIBS) $(PLATFORM_TK_LIBS) +LDFLAGS += $(PLATFORM_TCL_LDFLAGS) $(PLATFORM_TK_LDFLAGS) + +lib_warning: + @echo ACE_TkReactor will not be built due to the following missing library: + @echo $(LIBCHECK) + +require_warning: + @echo ACE_TkReactor will not be built due to one of the following disabled make macros: + @echo tk + +## Some OS's have /bin/test others only have /usr/bin/test +ifeq ($(wildcard /bin/test), /bin/test) + TEST_EXE = /bin/test +else +ifeq ($(wildcard /usr/bin/test), /usr/bin/test) + TEST_EXE = /usr/bin/test +endif +endif + +ifneq ($(GENERATED_DIRTY),) +.PRECIOUS: $(GENERATED_DIRTY) +## If the generated files are anything but source files, we need to +## ensure that those files are generated before we attempt to build anything +## else. +ifeq ($(OBJS_DEPEND_ON_GENERATED),1) +$(VDIR)$(ACE_PCH_FILE) $(addprefix $(VDIR), $(OBJS)): $(GENERATED_DIRTY) +$(VSHDIR)$(ACE_PCH_FILE) $(VSHOBJS): $(GENERATED_DIRTY) +endif +endif + + +realclean: clean +ifneq ($(GENERATED_DIRTY),) + -$(RM) -r $(GENERATED_DIRTY) +endif + +__prebuild__: + @-: + diff --git a/dep/ACE_wrappers/ace/GNUmakefile.ACE_XtReactor b/dep/ACE_wrappers/ace/GNUmakefile.ACE_XtReactor new file mode 100644 index 00000000000..823e7f439d2 --- /dev/null +++ b/dep/ACE_wrappers/ace/GNUmakefile.ACE_XtReactor @@ -0,0 +1,175 @@ +# -*- Makefile -*- +#---------------------------------------------------------------------------- +# GNU Makefile +# +# @file GNUmakefile.ACE_XtReactor +# +# $Id: gnu.mpd 82648 2008-08-21 06:55:54Z johnnyw $ +# +# This file was automatically generated by MPC. Any changes made directly to +# this file will be lost the next time it is generated. +# +#---------------------------------------------------------------------------- +MAKEFILE = GNUmakefile.ACE_XtReactor +DEPENDENCY_FILE = .depend.ACE_XtReactor + +## LIB may be set to empty later on in this file +LIB_UNCHECKED = libACE_XtReactor.a +LIB = $(LIB_UNCHECKED) +LIB_NAME = libACE_XtReactor + +## SHLIB may be set to empty later on in this file +SHLIB_UNCHECKED = libACE_XtReactor.$(SOEXT) +SHLIB = $(SHLIB_UNCHECKED) + +FILES = \ + XtReactor/XtReactor.cpp + +VPATH = .:XtReactor + +#---------------------------------------------------------------------------- +# Include macros and targets +#---------------------------------------------------------------------------- +ACE_SHLIBS = -lACE + +PRJ_TYPE = library + +INSLIB ?= ../lib +ifeq ($(INSLIB),.) + ifeq ($(PWD),) + PWD=$(shell pwd) + endif + INSLIB = $(PWD) +endif +OUTPUT_DIRECTORY = $(INSLIB) + +include $(ACE_ROOT)/include/makeinclude/wrapper_macros.GNU + +# To build multiple targets in the same directory on AIX, it works +# best to have a template directory per project. +# The compiler/linker isn't too smart about instantiating templates... +ifdef TEMPINCDIR +TEMPINCDIR := $(TEMPINCDIR)/ACE_XtReactor +all: $(TEMPINCDIR) +endif + +ifneq ($(OUTPUT_DIRECTORY),) +all: $(OUTPUT_DIRECTORY) +$(OUTPUT_DIRECTORY): + -@$(MKDIR) "$(OUTPUT_DIRECTORY)" +endif + +# turn off libcheck if doing a dry run +ifeq ($(findstring n, $(MAKEFLAGS)),n) + LIBCHECK = 1 +else + # turn off libcheck if keep going was passed too + ifeq ($(findstring k, $(MAKEFLAGS)),k) + LIBCHECK = 1 + else + LIBCHECK ?= $(filter-out $(foreach lib,ACE,$(findstring $(lib),$(foreach libpath,. ../lib /usr/lib /usr/lib64 $(INSLIB),$(wildcard $(libpath)/lib$(lib).* $(libpath)/$(lib).lib)))),ACE) + ifeq ($(LIBCHECK),) + LIBCHECK = 1 + endif + endif +endif +ifeq ($(x11),1) +ifeq ($(xt),1) +ifneq ($(LIBCHECK), 1) + LIB = + SHLIB = + all: lib_warning +endif +else + LIB = + SHLIB = + all: require_warning +endif +else + LIB = + SHLIB = + all: require_warning +endif + +ifeq ($(x11),1) +ifeq ($(xt),1) +else + LIB = + SHLIB = + all: require_warning +endif +else + LIB = + SHLIB = + all: require_warning +endif +LSRC = $(FILES) + +include $(ACE_ROOT)/include/makeinclude/macros.GNU +include $(ACE_ROOT)/include/makeinclude/rules.common.GNU +include $(ACE_ROOT)/include/makeinclude/rules.nonested.GNU +include $(ACE_ROOT)/include/makeinclude/rules.lib.GNU +include $(ACE_ROOT)/include/makeinclude/rules.local.GNU +ifeq ($(VXWORKSLINK),1) +include $(TGT_DIR)/h/make/rules.$(PRJ_TYPE) +endif + +ifeq ($(VXWORKSLINK),1) +LDLIBPATH = -L. -L../lib +else +LDFLAGS += -L. -L../lib +endif +CPPFLAGS += -I.. +ifeq ($(shared_libs),1) + ifneq ($(SHLIB),) + CPPFLAGS += -DACE_XTREACTOR_BUILD_DLL + endif +endif +ifeq ($(static_libs),1) + CPPFLAGS += -DACE_AS_STATIC_LIBS +endif + +#---------------------------------------------------------------------------- +# Local targets +#---------------------------------------------------------------------------- +CPPFLAGS += $(PLATFORM_XT_CPPFLAGS) $(PLATFORM_X11_CPPFLAGS) +LIBS += $(PLATFORM_XT_LIBS) $(PLATFORM_X11_LIBS) +LDFLAGS += $(PLATFORM_XT_LDFLAGS) $(PLATFORM_X11_LDFLAGS) + +lib_warning: + @echo ACE_XtReactor will not be built due to the following missing library: + @echo $(LIBCHECK) + +require_warning: + @echo ACE_XtReactor will not be built due to one of the following disabled make macros: + @echo x11 xt + +## Some OS's have /bin/test others only have /usr/bin/test +ifeq ($(wildcard /bin/test), /bin/test) + TEST_EXE = /bin/test +else +ifeq ($(wildcard /usr/bin/test), /usr/bin/test) + TEST_EXE = /usr/bin/test +endif +endif + +ifneq ($(GENERATED_DIRTY),) +.PRECIOUS: $(GENERATED_DIRTY) +## If the generated files are anything but source files, we need to +## ensure that those files are generated before we attempt to build anything +## else. +ifeq ($(OBJS_DEPEND_ON_GENERATED),1) +$(VDIR)$(ACE_PCH_FILE) $(addprefix $(VDIR), $(OBJS)): $(GENERATED_DIRTY) +$(VSHDIR)$(ACE_PCH_FILE) $(VSHOBJS): $(GENERATED_DIRTY) +endif +endif + + +realclean: clean +ifneq ($(GENERATED_DIRTY),) + -$(RM) -r $(GENERATED_DIRTY) +endif + +__prebuild__: + @-: + diff --git a/dep/ACE_wrappers/ace/Get_Opt.cpp b/dep/ACE_wrappers/ace/Get_Opt.cpp new file mode 100644 index 00000000000..915ff8a87a9 --- /dev/null +++ b/dep/ACE_wrappers/ace/Get_Opt.cpp @@ -0,0 +1,734 @@ +// $Id: Get_Opt.cpp 81840 2008-06-05 13:46:45Z sma $ + +#include "ace/Get_Opt.h" + +#if !defined (__ACE_INLINE__) +#include "ace/Get_Opt.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/ACE.h" +#include "ace/Log_Msg.h" +#include "ace/SString.h" +#include "ace/OS_Memory.h" +#include "ace/OS_NS_string.h" +#include "ace/OS_NS_ctype.h" +#include "ace/OS_NS_stdlib.h" + +ACE_RCSID (ace, + Get_Opt, + "$Id: Get_Opt.cpp 81840 2008-06-05 13:46:45Z sma $") + +/* + * Copyright (c) 1987, 1993, 1994 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/*- + * Copyright (c) 2000 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Dieter Baron and Thomas Klausner. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the NetBSD + * Foundation, Inc. and its contributors. + * 4. Neither the name of The NetBSD Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_ALLOC_HOOK_DEFINE(ACE_Get_Opt) + +#ifdef ACE_USES_WCHAR +void ACE_Get_Opt::ACE_Get_Opt_Init (const ACE_TCHAR *optstring) +#else +ACE_Get_Opt::ACE_Get_Opt (int argc, + ACE_TCHAR **argv, + const ACE_TCHAR *optstring, + int skip, + int report_errors, + int ordering, + int long_only) + : argc_ (argc), + argv_ (argv), + optind (skip), + opterr (report_errors), + optarg (0), + optstring_ (0), + long_only_ (long_only), + has_colon_ (0), + last_option_ (0), + nextchar_ (0), + optopt_ (0), + ordering_ (ordering), + nonopt_start_ (optind), + nonopt_end_ (optind), + long_option_ (0) +#endif +{ + ACE_TRACE ("ACE_Get_Opt::ACE_Get_Opt"); + + ACE_NEW (this->optstring_, ACE_TString (optstring)); + ACE_NEW (this->last_option_, ACE_TString (ACE_TEXT (""))); + + // First check to see if POSIXLY_CORRECT was set. + // Win32 is the only platform capable of wide-char env var. +#if defined (ACE_WIN32) + const ACE_TCHAR *env_check = ACE_TEXT ("POSIXLY_CORRECT"); +#else + const char *env_check = "POSIXLY_CORRECT"; +#endif + if (ACE_OS::getenv (env_check) != 0) + this->ordering_ = REQUIRE_ORDER; + + // Now, check to see if any or the following were passed at + // the begining of optstring: '+' same as POSIXLY_CORRECT; + // '-' turns off POSIXLY_CORRECT; or ':' which signifies we + // should return ':' if a parameter is missing for an option. + // We use a loop here, since a combination of "{+|-}:" in any + // order should be legal. + int done = 0; + int offset = 0; + while (!done) + { + switch (optstring[offset++]) + { + case '+': + this->ordering_ = REQUIRE_ORDER; + break; + case '-': + this->ordering_ = RETURN_IN_ORDER; + break; + case ':': + this->has_colon_ = 1; + break; + default: + // Quit as soon as we see something else... + done = 1; + break; + } + } +} + +ACE_Get_Opt::~ACE_Get_Opt (void) +{ + ACE_TRACE ("ACE_Get_Opt::~ACE_Get_Opt"); + + size_t i = 0; + size_t size = this->long_opts_.size (); + ACE_Get_Opt_Long_Option *option = 0; + for (i = 0; i < size; ++i) + { + int retval = this->long_opts_.get (option, i); + if (retval != 0) + { + // Should never happen. + retval = 0; + continue; + } + if (option) + { + delete option; + option = 0; + } + } + delete this->optstring_; + delete this->last_option_; +} + +int +ACE_Get_Opt::nextchar_i (void) +{ + ACE_TRACE ("ACE_Get_Opt::nextchar_i"); + + if (this->ordering_ == PERMUTE_ARGS) + if (this->permute () == EOF) + return EOF; + + // Update scanning pointer. + if (this->optind >= this->argc_) + { + // We're done... + this->nextchar_ = 0; + return EOF; + } + else if (*(this->nextchar_ = this->argv_[this->optind]) != '-' + || this->nextchar_[1] == '\0') + { + // We didn't get an option. + + if (this->ordering_ == REQUIRE_ORDER + || this->ordering_ == PERMUTE_ARGS) + // If we permuted or require the options to be in order, we're done. + return EOF; + + // It must be RETURN_IN_ORDER... + this->optarg = this->argv_[this->optind++]; + this->nextchar_ = 0; + return 1; + } + else if (this->nextchar_[1] != 0 + && *++this->nextchar_ == '-' + && this->nextchar_[1] == 0) + { + // Found "--" so we're done... + ++this->optind; + this->nextchar_ = 0; + return EOF; + } + + // If it's a long option, and we allow long options advance nextchar_. + if (*this->nextchar_ == '-' && this->long_opts_.size () != 0) + this->nextchar_++; + + return 0; +} + +int +ACE_Get_Opt::long_option_i (void) +{ + ACE_TRACE ("ACE_Get_Opt::long_option_i"); + + ACE_Get_Opt_Long_Option *p; + ACE_TCHAR *s = this->nextchar_; + int hits = 0; + int exact = 0; + ACE_Get_Opt_Long_Option *pfound = 0; + int indfound = 0; + + // Advance to the end of the long option name so we can use + // it to get the length for a string compare. + while (*s && *s != '=') + s++; + + size_t len = s - this->nextchar_; + // set last_option_ to nextchar_, up to the '='. + this->last_option (ACE_TString (this->nextchar_, len)); + + size_t size = this->long_opts_.size (); + u_int option_index = 0; + for (option_index = 0; option_index < size ; option_index++) + { + p = this->long_opts_[option_index]; + ACE_ASSERT (p); + + if (!ACE_OS::strncmp (p->name_, this->nextchar_, len)) + { + // Got at least a partial match. + pfound = p; + indfound = option_index; + hits += 1; + if (len == ACE_OS::strlen(p->name_)) + { + // And in fact, it's an exact match, so let's use it. + exact = 1; + break; + } + } + } + + if ((hits > 1) && !exact) + { + // Great, we found a match, but unfortunately we found more than + // one and it wasn't exact. + if (this->opterr) + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("%s: option `%s' is ambiguous\n"), + this->argv_[0], this->argv_[this->optind])); + this->nextchar_ = 0; + this->optind++; + return '?'; + } + + if (pfound != 0) + { + // Okay, we found a good one (either a single hit or an exact match). + option_index = indfound; + this->optind++; + if (*s) + { + // s must point to '=' which means there's an argument (well + // close enough). + if (pfound->has_arg_ != NO_ARG) + // Good, we want an argument and here it is. + this->optarg = ++s; + else + { + // Whoops, we've got what looks like an argument, but we + // don't want one. + if (this->opterr) + ACE_ERROR + ((LM_ERROR, + ACE_TEXT ("%s: long option `--%s' doesn't allow ") + ACE_TEXT ("an argument\n"), + this->argv_[0], pfound->name_)); + // The spec doesn't cover this, so we keep going and the program + // doesn't know we ignored an argument if opt_err is off!!! + } + } + else if (pfound->has_arg_ == ARG_REQUIRED) + { + // s didn't help us, but we need an argument. Note that + // optional arguments for long options must use the "=" syntax, + // so we won't get here in that case. + if (this->optind < this->argc_) + // We still have some elements left, so use the next one. + this->optarg = this->argv_[this->optind++]; + else + { + // All out of elements, so we have to punt... + if (this->opterr) + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("%s: long option '--%s' requires ") + ACE_TEXT ("an argument\n"), + this->argv_[0], pfound->name_)); + this->nextchar_ = 0; + this->optopt_ = pfound->val_; // Remember matching short equiv + return this->has_colon_ ? ':' : '?'; + } + } + this->nextchar_ = 0; + this->long_option_ = pfound; + // Since val_ has to be either a valid short option or 0, this works + // great. If the user really wants to know if a long option was passed. + this->optopt_ = pfound->val_; + return pfound->val_; + } + if (!this->long_only_ || this->argv_[this->optind][1] == '-' + || this->optstring_->find (*this->nextchar_) == ACE_TString::npos) + { + // Okay, we couldn't find a long option. If it isn't long_only (which + // means try the long first, and if not found try the short) or a long + // signature was passed, e.g. "--", or it's not a short (not sure when + // this could happen) it's an error. + if (this->opterr) + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("%s: illegal long option '--%s'\n"), + this->argv_[0], this->nextchar_)); + this->nextchar_ = 0; + this->optind++; + return '?'; + } + return this->short_option_i (); +} + +int +ACE_Get_Opt::short_option_i (void) +{ + ACE_TRACE ("ACE_Get_Opt::short_option_i"); + + /* Look at and handle the next option-character. */ + ACE_TCHAR opt = *this->nextchar_++; + // Set last_option_ to opt + this->last_option (opt); + + ACE_TCHAR *oli = 0; + oli = + const_cast (ACE_OS::strchr (this->optstring_->c_str (), opt)); + + /* Increment `optind' when we start to process its last character. */ + if (*this->nextchar_ == '\0') + ++this->optind; + + if (oli == 0 || opt == ':') + { + if (this->opterr) + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("%s: illegal short option -- %c\n"), + this->argv_[0], opt)); + return '?'; + } + if (opt == 'W' && oli[1] == ';') + { + if (this->nextchar_[0] == 0) + this->nextchar_ = this->argv_[this->optind]; + return long_option_i (); + } + this->optopt_ = oli[0]; // Remember the option that matched + if (oli[1] == ':') + { + if (oli[2] == ':') + { + // Takes an optional argument, and since short option args must + // must follow directly in the same argument, a NULL nextchar_ + // means we didn't get one. + if (*this->nextchar_ != '\0') + { + this->optarg = this->nextchar_; + this->optind++; + } + else + this->optarg = 0; + this->nextchar_ = 0; + } + else + { + // Takes a required argument. + if (*this->nextchar_ != '\0') + { + // Found argument in same argv-element. + this->optarg = this->nextchar_; + this->optind++; + } + else if (this->optind == this->argc_) + { + // Ran out of arguments before finding required argument. + if (this->opterr) + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("%s: short option requires ") + ACE_TEXT ("an argument -- %c\n"), + this->argv_[0], opt)); + opt = this->has_colon_ ? ':' : '?'; + } + else + // Use the next argv-element as the argument. + this->optarg = this->argv_[this->optind++]; + this->nextchar_ = 0; + } + } + return opt; +} + +int +ACE_Get_Opt::operator () (void) +{ + ACE_TRACE ("ACE_Get_Opt_Long::operator"); + + // First of all, make sure we reinitialize any pointers.. + this->optarg = 0; + this->long_option_ = 0; + + if (this->argv_ == 0) + { + // It can happen, e.g., on VxWorks. + this->optind = 0; + return -1; + } + + // We check this because we can string short options together if the + // preceding one doesn't take an argument. + if (this->nextchar_ == 0 || *this->nextchar_ == '\0') + { + int retval = this->nextchar_i (); + if (retval != 0) + return retval; + } + + if (((this->argv_[this->optind][0] == '-') + && (this->argv_[this->optind][1] == '-')) || this->long_only_) + return this->long_option_i (); + + return this->short_option_i (); +} + +int +ACE_Get_Opt::long_option (const ACE_TCHAR *name, + OPTION_ARG_MODE has_arg) +{ + ACE_TRACE ("ACE_Get_Opt::long_option (const ACE_TCHAR *name, OPTION_ARG_MODE has_arg)"); + return this->long_option (name, 0, has_arg); +} + +int +ACE_Get_Opt::long_option (const ACE_TCHAR *name, + int short_option, + OPTION_ARG_MODE has_arg) +{ + ACE_TRACE ("ACE_Get_Opt::long_option (const ACE_TCHAR *name, int short_option, OPTION_ARG_MODE has_arg)"); + + // We only allow valid alpha-numeric characters as short options. + // If short_options is not a valid alpha-numeric, we can still return it + // when the long option is found, but won't allow the caller to pass it on + // the command line (how could they?). The special case is 0, but since + // we always return it, we let the caller worry about that. + if (ACE_OS::ace_isalnum (short_option) != 0) + { + // If the short_option already exists, make sure it matches, otherwise + // add it. + ACE_TCHAR *s = 0; + if ((s = const_cast ( + ACE_OS::strchr (this->optstring_->c_str (), + short_option))) != 0) + { + // Short option exists, so verify the argument options + if (s[1] == ':') + { + if (s[2] == ':') + { + if (has_arg != ARG_OPTIONAL) + { + if (this->opterr) + ACE_ERROR + ((LM_ERROR, + ACE_TEXT ("Existing short option '%c' takes ") + ACE_TEXT ("optional argument; adding %s ") + ACE_TEXT ("requires ARG_OPTIONAL\n"), + short_option, name)); + return -1; + } + } + else + if (has_arg != ARG_REQUIRED) + { + if (this->opterr) + ACE_ERROR + ((LM_ERROR, + ACE_TEXT ("Existing short option '%c' requires ") + ACE_TEXT ("an argument; adding %s ") + ACE_TEXT ("requires ARG_REQUIRED\n"), + short_option, name)); + return -1; + } + } + else if (has_arg != NO_ARG) + { + if (this->opterr) + ACE_ERROR + ((LM_ERROR, + ACE_TEXT ("Existing short option '%c' does not ") + ACE_TEXT ("accept an argument; adding %s ") + ACE_TEXT ("requires NO_ARG\n"), + short_option, name)); + return -1; + } + } + else + { + // Didn't find short option, so add it... + *this->optstring_ += (ACE_TCHAR) short_option; + if (has_arg == ARG_REQUIRED) + *this->optstring_ += ACE_TEXT (":"); + else if (has_arg == ARG_OPTIONAL) + *this->optstring_ += ACE_TEXT ("::"); + } + } + + ACE_Get_Opt_Long_Option *option = + new ACE_Get_Opt_Long_Option (name, has_arg, short_option); + + if (!option) + return -1; + + // Add to array + size_t size = this->long_opts_.size (); + if (this->long_opts_.size (size + 1) != 0 + || this->long_opts_.set (option, size) != 0) + { + delete option; + ACE_ERROR_RETURN + ((LM_ERROR, ACE_TEXT ("Could not add long option to array.\n")), + -1); + } + return 0; +} + +const ACE_TCHAR* +ACE_Get_Opt::long_option (void) const +{ + ACE_TRACE ("ACE_Get_Opt::long_option (void)"); + if (this->long_option_) + return this->long_option_->name_; + return 0; +} + +const ACE_TCHAR* +ACE_Get_Opt::last_option (void) const +{ + return this->last_option_->c_str (); +} + +void +ACE_Get_Opt::last_option (const ACE_TString &last_option) +{ + *this->last_option_ = last_option; +} + +void +ACE_Get_Opt::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + ACE_TRACE ("ACE_Get_Opt::dump"); + + ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\n") + ACE_TEXT ("opstring_ = %s\n") + ACE_TEXT ("long_only_ = %d\n") + ACE_TEXT ("has_colon_ = %d\n") + ACE_TEXT ("last_option_ = %s\n") + ACE_TEXT ("nextchar_ = %s\n") + ACE_TEXT ("optopt_ = %c\n") + ACE_TEXT ("ordering_ = %d\n"), + this->optstring_->c_str (), + this->long_only_, + this->has_colon_, + this->last_option_->c_str (), + this->nextchar_, + this->optopt_, + this->ordering_)); + + // now loop through the + size_t size = this->long_opts_.size (); + for (u_int i = 0; i < size ; ++i) + { + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\n") + ACE_TEXT ("long_option name_ = %s\n") + ACE_TEXT ("has_arg_ = %d\n") + ACE_TEXT ("val_ = %d\n"), + this->long_opts_[i]->name_, + this->long_opts_[i]->has_arg_, + this->long_opts_[i]->val_)); + } + ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); +#endif /* ACE_HAS_DUMP */ +} + +void +ACE_Get_Opt::permute_args (void) +{ + ACE_TRACE ("ACE_Get_Opt::permute_args"); + + u_long cyclelen, i, j, ncycle, nnonopts, nopts; + u_long opt_end = this->optind; + int cstart, pos = 0; + ACE_TCHAR *swap = 0; + + nnonopts = this->nonopt_end_ - this->nonopt_start_; + nopts = opt_end - this->nonopt_end_; + ncycle = ACE::gcd (nnonopts, nopts); + cyclelen = (opt_end - this->nonopt_start_) / ncycle; + + this->optind = this->optind - nnonopts; + + for (i = 0; i < ncycle; i++) + { + cstart = this->nonopt_end_ + i; + pos = cstart; + for (j = 0; j < cyclelen; j++) + { + if (pos >= this->nonopt_end_) + pos -= nnonopts; + else + pos += nopts; + swap = this->argv_[pos]; + + ((ACE_TCHAR **)this->argv_)[pos] = argv_[cstart]; + + ((ACE_TCHAR **)this->argv_)[cstart] = swap; + } + } +} + +int +ACE_Get_Opt::permute (void) +{ + ACE_TRACE ("ACE_Get_Opt::permute"); + + if (this->nonopt_start_ != this->nonopt_end_ + && this->nonopt_start_ != this->optind) + this->permute_args (); + + this->nonopt_start_ = this->optind; + + // Skip over args untill we find the next option. + while (this->optind < this->argc_ + && (this->argv_[this->optind][0] != '-' + || this->argv_[this->optind][1] == '\0')) + this->optind++; + + // Got an option, so mark this as the end of the non options. + this->nonopt_end_ = this->optind; + + if (this->optind != this->argc_ + && ACE_OS::strcmp (this->argv_[this->optind], + ACE_TEXT ("--")) == 0) + { + // We found the marker for the end of the options. + ++this->optind; + + if (this->nonopt_start_ != this->nonopt_end_ + && this->nonopt_end_ != this->optind) + this->permute_args (); + } + + if (this->optind == this->argc_) + { + if (this->nonopt_start_ != this->nonopt_end_) + this->optind = this->nonopt_start_; + return EOF; + } + return 0; +} + +const ACE_TCHAR * +ACE_Get_Opt::optstring (void) const +{ + return this->optstring_->c_str (); +} + +ACE_Get_Opt::ACE_Get_Opt_Long_Option::ACE_Get_Opt_Long_Option ( + const ACE_TCHAR *name, + int has_arg, + int val) + : name_ (ACE::strnew (name)), + has_arg_ (has_arg), + val_ (val) +{} + +ACE_Get_Opt::ACE_Get_Opt_Long_Option::~ACE_Get_Opt_Long_Option (void) +{ + delete [] this->name_; +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Get_Opt.h b/dep/ACE_wrappers/ace/Get_Opt.h new file mode 100644 index 00000000000..3b4a420d91c --- /dev/null +++ b/dep/ACE_wrappers/ace/Get_Opt.h @@ -0,0 +1,494 @@ +// -*- C++ -*- + +//========================================================================== +/** + * @file Get_Opt.h + * + * $Id: Get_Opt.h 81840 2008-06-05 13:46:45Z sma $ + * + * @author Douglas C. Schmidt + * @author Don Hinton (added long option support) + */ +//========================================================================== + +#ifndef ACE_GET_OPT_H +#define ACE_GET_OPT_H +#include /**/ "ace/pre.h" + +#include "ace/SStringfwd.h" +#include "ace/Containers.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#undef optind +#undef optarg +#undef opterr + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +/* + * These definitions are for backward compatibility with previous versions. + * of ACE_Get_Opt. + */ + +/** + * @class ACE_Get_Opt + * + * @brief Iterator for parsing command-line arguments. + * + * This is a C++ wrapper for getopt(3c) and getopt_long(3c). + */ + +class ACE_Export ACE_Get_Opt +{ +public: + /// Mutually exclusive ordering values. + enum + { + /** + * REQUIRE_ORDER means that processing stops and @c EOF is + * returned as soon as a non-option argument is found. @c opt_ind() + * will return the index of the next @a argv element so the program + * can continue processing the rest of the @a argv elements. + */ + REQUIRE_ORDER = 1, + + /** + * PERMUTE_ARGS means the @a argv elements are reordered dynamically + * (permuted) so that all options appear first. When the elements are + * permuted, the order of the options and the following arguments are + * maintained. When the last option has been processed, @c EOF is + * returned and @c opt_ind() returns the index into the next non-option + * element. + */ + PERMUTE_ARGS = 2, + + /** + * RETURN_IN_ORDER means each @a argv element is processed in the + * order is it seen. If the element is not recognized as an option, '1' + * is returned and @c opt_arg() refers to the @a argv element found. + */ + RETURN_IN_ORDER = 3 + }; + + /// Mutually exclusive option argument mode used by long options. + enum OPTION_ARG_MODE + { + /// Doesn't take an argument. + NO_ARG = 0, + + /// Requires an argument, same as passing ":" after a short option + /// character in @a optstring. + ARG_REQUIRED = 1, + + /// Argument is optional, same as passing "::" after a short + /// option character in @a optstring. + ARG_OPTIONAL = 2 + }; + + /** + * Constructor initializes the command line to be parsed. All information + * for parsing must be supplied to this constructor. + * + * @param argc The number of @a argv elements to parse. + * @param argv Command line tokens, such as would be passed + * to @c main(). + * @param optstring Nul-terminated string containing the legitimate + * short option characters. A single colon ":" + * following an option character means the option + * requires an argument. A double colon "::" following + * an option character means the argument is optional. + * The argument is taken from the rest of the current + * @a argv element, or from the following @a argv + * element (only valid for required arguments; + * optional arguments must always reside in the same + * @a argv element). The argument value, if any is + * returned by the @c opt_arg() method. + * @a optstring can be extended by adding long options + * with corresponding short options via the + * @c long_option() method. If the short option + * already appears in @a optstring, the argument + * characteristics must match, otherwise it is added. + * See @c long_option() for more information. + * If 'W', followed by a semi-colon ';' appears in + * @a optstring, then any time a 'W' appears on the + * command line, the following argument is treated as + * a long option. For example, if the command line + * contains "program -W foo", "foo" is treated as a + * long option, that is, as if "program --foo" had + * been passed. + * The following characters can appear in @a optstring + * before any option characters, with the described + * effect: + * - '+' changes the @a ordering to @a REQUIRE_ORDER. + * - '-' changes the @a ordering to @a RETURN_IN_ORDER. + * - ':' changes the return value from @c operator() + * and get_opt() from '?' to ':' when an option + * requires an argument but none is specified. + * + * @param skip_args Optional (default 1). The specified number of + * initial elements in @a argv are skipped before + * parsing begins. Thus, the default prevents + * @a argv[0] (usually the command name) from being + * parsed. @a argc includes all @a argv elements, + * including any skipped elements. + * @param report_errors Optional, if non-zero then parsing errors cause + * an error message to be displayed from the + * @c operator() method before it returns. The + * error message is suppressed if this argument is 0. + * This setting also controls whether or not an error + * message is displayed in @c long_option() encounters + * an error. + * @param ordering Optional (default is @c PERMUTE_ARGS); determines + * how the @a argv elements are processed. This argument + * is overridden by two factors: + * -# The @c POSIXLY_CORRECT environment variable. If + * this environment variable is set, the ordering + * is changed to @c REQUIRE_ORDER. + * -# Leading characters in @a optstring (see above). + * Any leading ordering characters override both + * the @a ordering argument and any effect of the + * @c POSIXLY_CORRECT environment variable. + * @param long_only Optional. If non-zero, then long options can be + * specified using a single '-' on the command line. + * If the token is not a long option, it is processed + * as usual, that is, as a short option or set of + * short options. + * + * Multiple short options can be combined as long as only the last + * one can takes an argument. For example, if @a optstring is defined as + * @c "abc:" or @c "abc::" then the command line @e "program -abcxxx" short + * options @e a, @e b, and @e c are found with @e "xxx" as the argument for + * @e c. + * However, if the command line is specified as @e "program -acb" only + * options @e a and @e c are found with @e "b" as the argument for @e c. + * Also, for options with optional arguments, that is, those followed by + * "::", the argument must be in the same @a argv element, so "program -abc + * xxx" will only find "xxx" as the argument for @e c if @a optstring is + * specified as @c "abc:" not @c "abc::". + */ +#ifndef ACE_USES_WCHAR + ACE_Get_Opt (int argc, + ACE_TCHAR **argv, + const ACE_TCHAR *optstring = ACE_TEXT (""), + int skip_args = 1, + int report_errors = 0, + int ordering = PERMUTE_ARGS, + int long_only = 0); + +#else +private: + void ACE_Get_Opt_Init (const ACE_TCHAR *optstring); +public: + ACE_INLINE ACE_Get_Opt (int argc, + ACE_TCHAR **argv, + const ACE_TCHAR *optstring = ACE_TEXT (""), + int skip_args = 1, + int report_errors = 0, + int ordering = PERMUTE_ARGS, + int long_only = 0); + ACE_INLINE ACE_Get_Opt (int argc, + ACE_TCHAR **argv, + const char *optstring, + int skip_args = 1, + int report_errors = 0, + int ordering = PERMUTE_ARGS, + int long_only = 0); +#endif + /// Default dtor. + ~ACE_Get_Opt (void); + + /** + * Scan elements of @a argv (whose length is @a argc) for short option + * characters given in @a optstring or long options (with no short + * option equivalents). + * + * If an element of @a argv starts with '-', and is not exactly "-" + * or "--", then it is a short option element. The characters of this + * element (aside from the initial '-') are option characters. If + * it starts with "--" followed by other characters it is treated as + * a long option. If @c operator() is called repeatedly, it returns + * each of the option characters from each of the option elements. + * + * @return The parsed option character. The following characters have + * special significance. + * @retval 0 A long option was found + * @retval '\?' Either an unknown option character was found, or the + * option is known but requires an argument, none was + * specified, and @a optstring did not contain a leading + * colon. + * @retval ':' A known option character was found but it requires an + * argument and none was supplied, and the first character + * of @a optstring was a colon. @c opt_opt() indicates + * which option was specified. + * @retval '1' @c RETURN_IN_ORDER was specified and a non-option argument + * was found. + * @retval EOF No more option characters were found. @c opt_ind() will + * return the index in @a argv of the first @a argv element + * that is not an option. If @c PERMUTE_ARGS was + * specified, the @a argv elements have been permuted so that + * those that are not options now come last. + * + * @note The standards are unclear with respect to the conditions under + * which '?' and ':' are returned, so we scan the initial characters of + * @a optstring up unto the first short option character for '+', '-', + * and ':' in order to determine ordering and missing argument behavior. + */ + int operator () (void); + + /** + * For communication from @c operator() to the caller. When + * @c operator() finds an option that takes an argument, the argument + * value is returned from this method, otherwise it returns 0. + */ + ACE_TCHAR *opt_arg (void) const; + + /** + * Returns the most recently matched option character. Especially + * useful when operator() returns ':' for an unspecified argument + * that's required, since this allows the caller to learn what option + * was specified without its required argument. + */ + int opt_opt (void); + + /** + * Index in @a argv of the next element to be scanned. This is used + * for communication to and from the caller and for communication + * between successive calls to @c operator(). On entry to + * @c operator(), zero means this is the first call; initialize. + * + * When @c operator() returns @c EOF, this is the index of the first of + * the non-option elements that the caller should itself scan. + * + * Otherwise, @c opt_ind() communicates from one call to the next how + * much of @a argv has been scanned so far. + */ + int &opt_ind (void); + + /// Adds a long option with no corresponding short option. + /** + * If the @a name option is seen, @c operator() returns 0. + * + * @param name The long option to add. + * @param has_arg Defines the argument requirements for + * the new option. + * + * @retval 0 Success + * @retval -1 The long option can not be added. + */ + int long_option (const ACE_TCHAR *name, + OPTION_ARG_MODE has_arg = NO_ARG); + + /// Adds a long option with a corresponding short option. + /** + * @param name The long option to add. + * @param short_option A character, the short option that corresponds + * to @a name. + * @param has_arg Defines the argument requirements for + * the new option. If the short option has already + * been supplied in the @a optstring, @a has_arg + * must match or an error is returned; otherwise, the + * new short option is added to the @a optstring. + * + * @retval 0 Success + * @retval -1 The long option can not be added. + */ + int long_option (const ACE_TCHAR *name, + int short_option, + OPTION_ARG_MODE has_arg = NO_ARG); + + /// Returns the name of the long option found on the last call to + /// @c operator() or 0 if none was found. + const ACE_TCHAR *long_option (void) const; + + /// The number of arguments in the internal @c argv_. + int argc (void) const; + + /// Accessor for the internal @c argv_ pointer. + ACE_TCHAR **argv (void) const; + + /// Accessor for the @c last_option that was processed. This allows + /// applications to know if the found option was a short or long + /// option, and is especially useful in cases where it was invalid + /// and the caller wants to print out the invalid value. + const ACE_TCHAR *last_option (void) const; + + /// Dump the state of an object. + void dump (void) const; + + /// Return the @a optstring. This is handy to verify that calls to + /// long_option added short options as expected. + const ACE_TCHAR *optstring (void) const; + +public: + /* + * The following five data members should be private, but that + * would break backwards compatibility. However, we recommend not + * writing code that uses these fields directly. + */ + + /// Holds the @a argc count. + /** + * @deprecated This is public for backwards compatibility only. + * It will be made private in a release of ACE past 5.3. Do not + * write code that relies on this member being public; use the + * @c argc() accessor method instead. + */ + int argc_; + + /// Holds the @a argv pointer. + /** + * @deprecated This is public for backwards compatibility only. + * It will be made private in a release of ACE past 5.3. Do not + * write code that relies on this member being public; use the + * @c argv() accessor method instead. + */ + ACE_TCHAR **argv_; + + /// Index in @c argv_ of the next element to be scanned. + /** + * @deprecated This is public for backwards compatibility only. + * It will be made private in a release of ACE past 5.3. Do not + * write code that relies on this member being public; use the + * @c opt_ind() accessor method instead. + */ + int optind; + + /// Callers store zero here to inhibit the error message for + /// unrecognized options. + /** + * @deprecated This is public for backwards compatibility only. + * It will be made private in a release of ACE past 5.3. Do not + * write code that relies on this member being public; use the + * @a report_errors argument to this class's constructor instead. + */ + int opterr; + + /// Points to the option argument when one is found on last call to + /// @c operator(). + /** + * @deprecated This is public for backwards compatibility only. + * It will be made private in a release of ACE past 5.3. Do not + * write code that relies on this member being public; use the + * @c opt_arg() accessor method instead. + */ + ACE_TCHAR *optarg; + +private: + /** + * @class ACE_Get_Opt_Long_Option This class is for internal use + * in the ACE_Get_Opt class, and is inaccessible to users. + */ + class ACE_Get_Opt_Long_Option + { + public: + /// ctor + ACE_Get_Opt_Long_Option (const ACE_TCHAR *name, + int has_arg, + int val = 0); + + /// Dtor. + ~ACE_Get_Opt_Long_Option (void); + + bool operator < (const ACE_Get_Opt_Long_Option &rhs); + + /// Long option name. + const ACE_TCHAR *name_; + + /// Contains value for . + int has_arg_; + + /// Contains a valid short option character or zero if it doesn't + /// have a corresponding short option. It can also contain a + /// non-printable value that cannot be passed to but + /// will be returned by . This is handy for + /// simplifying long option handling, see tests/Get_Opt_Test.cpp + /// for an example of this technique. + int val_; + }; + + /// Updates nextchar_. + int nextchar_i (void); + + /// Handles long options. + int long_option_i (void); + + /// Handles short options. + int short_option_i (void); + + /// If permuting args, this functions manages the nonopt_start_ and + /// nonopt_end_ indexes and makes calls to permute to actually + /// reorder the -elements. + void permute_args (void); + + /// Handles reordering -elements. + int permute (void); + + /// Set last_option. + void last_option (const ACE_TString &s); + + // Disallow copying and assignment. + ACE_Get_Opt (const ACE_Get_Opt &); + ACE_Get_Opt &operator= (const ACE_Get_Opt &); + +private: + + /// Holds the option string. + ACE_TString *optstring_; + + /// Treat all options as long options. + int long_only_; + + /// Keeps track of whether or not a colon was passed in . + /// This is used to determine the return value when required + /// arguments are missing. + int has_colon_; + + /// This is the last option, short or long, that was processed. This + /// is handy to have in cases where the option passed was invalid. + ACE_TString *last_option_; + + /** + * The next char to be scanned in the option-element in which the + * last option character we returned was found. This allows us to + * pick up the scan where we left off * + * If this is zero, or a null string, it means resume the scan + * by advancing to the next -element. + */ + ACE_TCHAR *nextchar_; + + /// Most recently matched short option character. + int optopt_; + + /// Keeps track of ordering mode (default ). + int ordering_; + + /// Index of the first non-option -element found (only valid + /// when permuting). + int nonopt_start_; + + /// Index of the -element following the last non-option element + /// (only valid when permuting). + int nonopt_end_; + + /// Points to the long_option found on last call to . + ACE_Get_Opt_Long_Option *long_option_; + + /// Array of long options. + ACE_Array long_opts_; + + /// Declare the dynamic allocation hooks. + ACE_ALLOC_HOOK_DECLARE; + +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +#include "ace/Get_Opt.inl" +#endif /* __ACE_INLINE__ */ + +#include /**/ "ace/post.h" +#endif /* ACE_GET_OPT_H */ diff --git a/dep/ACE_wrappers/ace/Get_Opt.inl b/dep/ACE_wrappers/ace/Get_Opt.inl new file mode 100644 index 00000000000..e307fb5e400 --- /dev/null +++ b/dep/ACE_wrappers/ace/Get_Opt.inl @@ -0,0 +1,97 @@ +// -*- C++ -*- +// +// $Id: Get_Opt.inl 81840 2008-06-05 13:46:45Z sma $ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_INLINE bool +ACE_Get_Opt::ACE_Get_Opt_Long_Option::operator < (const ACE_Get_Opt_Long_Option &rhs) +{ + return this->name_ < rhs.name_; +} + +ACE_INLINE int +ACE_Get_Opt::argc (void) const +{ + return this->argc_; +} + +ACE_INLINE ACE_TCHAR ** +ACE_Get_Opt::argv (void) const +{ + return this->argv_; +} + +ACE_INLINE ACE_TCHAR* +ACE_Get_Opt::opt_arg (void) const +{ + return this->optarg; +} + +ACE_INLINE int +ACE_Get_Opt::opt_opt (void) +{ + return this->optopt_; +} + +ACE_INLINE int & +ACE_Get_Opt::opt_ind (void) +{ + return this->optind; +} + +#ifdef ACE_USES_WCHAR +ACE_INLINE ACE_Get_Opt::ACE_Get_Opt (int argc, + ACE_TCHAR **argv, + const ACE_TCHAR *optstring, + int skip_args, + int report_errors, + int ordering, + int long_only) + : argc_ (argc), + argv_ (argv), + optind (skip_args), + opterr (report_errors), + optarg (0), + optstring_ (0), + long_only_ (long_only), + has_colon_ (0), + last_option_ (0), + nextchar_ (0), + optopt_ (0), + ordering_ (ordering), + nonopt_start_ (optind), + nonopt_end_ (optind), + long_option_ (0) +{ + ACE_Get_Opt_Init (optstring); +} + +ACE_INLINE ACE_Get_Opt::ACE_Get_Opt (int argc, + ACE_TCHAR **argv, + const char *optstring, + int skip_args, + int report_errors, + int ordering, + int long_only) + : argc_ (argc), + argv_ (argv), + optind (skip_args), + opterr (report_errors), + optarg (0), + optstring_ (), + long_only_ (long_only), + has_colon_ (0), + last_option_ (0), + nextchar_ (0), + optopt_ (0), + ordering_ (ordering), + nonopt_start_ (optind), + nonopt_end_ (optind), + long_option_ (0) +{ + ACE_Get_Opt_Init (ACE_TEXT_CHAR_TO_TCHAR (optstring)); +} +#endif + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Global_Macros.h b/dep/ACE_wrappers/ace/Global_Macros.h new file mode 100644 index 00000000000..d1bf6420b05 --- /dev/null +++ b/dep/ACE_wrappers/ace/Global_Macros.h @@ -0,0 +1,1121 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Global_Macros.h + * + * $Id: Global_Macros.h 82442 2008-07-28 13:11:29Z johnnyw $ + * + * @author Douglas C. Schmidt + * @author Jesper S. M|ller + * @author and a cast of thousands... + * + * This one is split from the famous OS.h + */ +//============================================================================= + +#ifndef ACE_GLOBAL_MACROS_H +#define ACE_GLOBAL_MACROS_H + +#include /**/ "ace/pre.h" + +// Included just keep compilers that see #pragma dierctive first +// happy. +#include /**/ "ace/ACE_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/config-lite.h" +#include "ace/Assert.h" // For ACE_ASSERT + +// Start Global Macros +# define ACE_BEGIN_DUMP ACE_TEXT ("\n====\n(%P|%t|%x)\n") +# define ACE_END_DUMP ACE_TEXT ("====\n") + +# if defined (ACE_NDEBUG) +# define ACE_DB(X) +# else +# define ACE_DB(X) X +# endif /* ACE_NDEBUG */ + +// ACE_NO_HEAP_CHECK macro can be used to suppress false report of +// memory leaks. It turns off the built-in heap checking until the +// block is left. The old state will then be restored Only used for +// Win32 (in the moment). +# if defined (ACE_WIN32) + +# if defined (_DEBUG) && !defined (ACE_HAS_WINCE) && !defined (__BORLANDC__) +# include /**/ + +// Open versioned namespace, if enabled by the user. +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +class ACE_Export ACE_No_Heap_Check +{ +public: + ACE_No_Heap_Check (void) + : old_state (_CrtSetDbgFlag (_CRTDBG_REPORT_FLAG)) + { _CrtSetDbgFlag (old_state & ~_CRTDBG_ALLOC_MEM_DF);} + ~ACE_No_Heap_Check (void) { _CrtSetDbgFlag (old_state);} +private: + int old_state; +}; + +// Close versioned namespace, if enabled by the user. +ACE_END_VERSIONED_NAMESPACE_DECL + +# define ACE_NO_HEAP_CHECK ACE_No_Heap_Check ____no_heap; +# else /* !_DEBUG */ +# define ACE_NO_HEAP_CHECK +# endif /* _DEBUG */ +# else /* !ACE_WIN32 */ +# define ACE_NO_HEAP_CHECK +# endif /* ACE_WIN32 */ + +// Turn a number into a string. +# define ACE_ITOA(X) #X + +// Create a string of a server address with a "host:port" format. +# define ACE_SERVER_ADDRESS(H,P) H ACE_TEXT(":") P + +// A couple useful inline functions for checking whether bits are +// enabled or disabled. + +// Efficiently returns the least power of two >= X... +# define ACE_POW(X) (((X) == 0)?1:(X-=1,X|=X>>1,X|=X>>2,X|=X>>4,X|=X>>8,X|=X>>16,(++X))) +# define ACE_EVEN(NUM) (((NUM) & 1) == 0) +# define ACE_ODD(NUM) (((NUM) & 1) == 1) +# define ACE_BIT_ENABLED(WORD, BIT) (((WORD) & (BIT)) != 0) +# define ACE_BIT_DISABLED(WORD, BIT) (((WORD) & (BIT)) == 0) +# define ACE_BIT_CMP_MASK(WORD, BIT, MASK) (((WORD) & (BIT)) == MASK) +# define ACE_SET_BITS(WORD, BITS) (WORD |= (BITS)) +# define ACE_CLR_BITS(WORD, BITS) (WORD &= ~(BITS)) + +# if !defined (ACE_ENDLESS_LOOP) +# define ACE_ENDLESS_LOOP +# endif /* ! ACE_ENDLESS_LOOP */ + +# if defined (ACE_NEEDS_FUNC_DEFINITIONS) + // It just evaporated ;-) Not pleasant. +# define ACE_UNIMPLEMENTED_FUNC(f) +# else +# define ACE_UNIMPLEMENTED_FUNC(f) f; +# endif /* ACE_NEEDS_FUNC_DEFINITIONS */ + +#if !defined (ACE_LACKS_DEPRECATED_MACROS) + // Easy way to designate that a class is used as a pseudo-namespace. + // Insures that g++ "friendship" anamolies are properly handled. + # define ACE_CLASS_IS_NAMESPACE(CLASSNAME) \ + private: \ + CLASSNAME (void); \ + CLASSNAME (const CLASSNAME&); \ + friend class ace_dewarn_gplusplus +#endif /* ACE_LACKS_DEPRECATED_MACROS */ + +// ---------------------------------------------------------------- + +//FUZZ: disable check_for_exception_sepc +#if !defined (ACE_LACKS_DEPRECATED_MACROS) + #if defined (ACE_HAS_NO_THROW_SPEC) + # define ACE_THROW_SPEC(X) + #else + # if defined (ACE_HAS_EXCEPTIONS) + # if defined (ACE_WIN32) && defined (_MSC_VER) && \ + (_MSC_VER >= 1400) && (_MSC_VER <= 1500) + # define ACE_THROW_SPEC(X) throw(...) + # else + # define ACE_THROW_SPEC(X) throw X + # endif /* ACE_WIN32 && VC8 */ + # else /* ! ACE_HAS_EXCEPTIONS */ + # define ACE_THROW_SPEC(X) + # endif /* ! ACE_HAS_EXCEPTIONS */ + #endif /*ACE_HAS_NO_THROW_SPEC*/ +#endif /* ACE_LACKS_DEPRECATED_MACROS */ +//FUZZ: enable check_for_exception_sepc + +// ---------------------------------------------------------------- + +#if !defined (ACE_LACKS_DEPRECATED_MACROS) + /** + * This macro is deprecated + */ + #define ACE_NESTED_CLASS(TYPE, NAME) TYPE::NAME +#endif /* ACE_LACKS_DEPRECATED_MACROS */ + +#if !defined (ACE_LACKS_DEPRECATED_MACROS) + /** + * @name CORBA namespace macros. + * + * CORBA namespace macros. + * + * @deprecated These macros were formerly used by TAO but are now + * deprecated, and only remain to retain some backward + * compatibility. They will be removed in a future ACE + * release. + */ + //@{ + #define ACE_CORBA_1(NAME) CORBA::NAME + #define ACE_CORBA_2(TYPE, NAME) CORBA::TYPE::NAME + #define ACE_CORBA_3(TYPE, NAME) CORBA::TYPE::NAME + //@} +#endif /* ACE_LACKS_DEPRECATED_MACROS */ + +// ---------------------------------------------------------------- + +// Convenient macro for testing for deadlock, as well as for detecting +// when mutexes fail. +#define ACE_GUARD_ACTION(MUTEX, OBJ, LOCK, ACTION, REACTION) \ + ACE_Guard< MUTEX > OBJ (LOCK); \ + if (OBJ.locked () != 0) { ACTION; } \ + else { REACTION; } +#define ACE_GUARD_REACTION(MUTEX, OBJ, LOCK, REACTION) \ + ACE_GUARD_ACTION(MUTEX, OBJ, LOCK, ;, REACTION) +#define ACE_GUARD(MUTEX, OBJ, LOCK) \ + ACE_GUARD_REACTION(MUTEX, OBJ, LOCK, return) +#define ACE_GUARD_RETURN(MUTEX, OBJ, LOCK, RETURN) \ + ACE_GUARD_REACTION(MUTEX, OBJ, LOCK, return RETURN) +# define ACE_WRITE_GUARD(MUTEX,OBJ,LOCK) \ + ACE_Write_Guard< MUTEX > OBJ (LOCK); \ + if (OBJ.locked () == 0) return; +# define ACE_WRITE_GUARD_RETURN(MUTEX,OBJ,LOCK,RETURN) \ + ACE_Write_Guard< MUTEX > OBJ (LOCK); \ + if (OBJ.locked () == 0) return RETURN; +# define ACE_READ_GUARD(MUTEX,OBJ,LOCK) \ + ACE_Read_Guard< MUTEX > OBJ (LOCK); \ + if (OBJ.locked () == 0) return; +# define ACE_READ_GUARD_RETURN(MUTEX,OBJ,LOCK,RETURN) \ + ACE_Read_Guard< MUTEX > OBJ (LOCK); \ + if (OBJ.locked () == 0) return RETURN; + +// ---------------------------------------------------------------- + +# define ACE_DES_NOFREE(POINTER,CLASS) \ + do { \ + if (POINTER) \ + { \ + (POINTER)->~CLASS (); \ + } \ + } \ + while (0) + +# define ACE_DES_ARRAY_NOFREE(POINTER,SIZE,CLASS) \ + do { \ + if (POINTER) \ + { \ + for (size_t i = 0; \ + i < SIZE; \ + ++i) \ + { \ + (&(POINTER)[i])->~CLASS (); \ + } \ + } \ + } \ + while (0) + +# define ACE_DES_FREE(POINTER,DEALLOCATOR,CLASS) \ + do { \ + if (POINTER) \ + { \ + (POINTER)->~CLASS (); \ + DEALLOCATOR (POINTER); \ + } \ + } \ + while (0) + +# define ACE_DES_ARRAY_FREE(POINTER,SIZE,DEALLOCATOR,CLASS) \ + do { \ + if (POINTER) \ + { \ + for (size_t i = 0; \ + i < SIZE; \ + ++i) \ + { \ + (&(POINTER)[i])->~CLASS (); \ + } \ + DEALLOCATOR (POINTER); \ + } \ + } \ + while (0) + +# if defined (ACE_HAS_WORKING_EXPLICIT_TEMPLATE_DESTRUCTOR) +# define ACE_DES_NOFREE_TEMPLATE(POINTER,T_CLASS,T_PARAMETER) \ + do { \ + if (POINTER) \ + { \ + (POINTER)->~T_CLASS (); \ + } \ + } \ + while (0) +# define ACE_DES_ARRAY_NOFREE_TEMPLATE(POINTER,SIZE,T_CLASS,T_PARAMETER) \ + do { \ + if (POINTER) \ + { \ + for (size_t i = 0; \ + i < SIZE; \ + ++i) \ + { \ + (&(POINTER)[i])->~T_CLASS (); \ + } \ + } \ + } \ + while (0) + +#if defined (ACE_EXPLICIT_TEMPLATE_DESTRUCTOR_TAKES_ARGS) +# define ACE_DES_FREE_TEMPLATE(POINTER,DEALLOCATOR,T_CLASS,T_PARAMETER) \ + do { \ + if (POINTER) \ + { \ + (POINTER)->~T_CLASS T_PARAMETER (); \ + DEALLOCATOR (POINTER); \ + } \ + } \ + while (0) +#else +# define ACE_DES_FREE_TEMPLATE(POINTER,DEALLOCATOR,T_CLASS,T_PARAMETER) \ + do { \ + if (POINTER) \ + { \ + (POINTER)->~T_CLASS (); \ + DEALLOCATOR (POINTER); \ + } \ + } \ + while (0) +#endif /* defined(ACE_EXPLICIT_TEMPLATE_DESTRUCTOR_TAKES_ARGS) */ +# define ACE_DES_ARRAY_FREE_TEMPLATE(POINTER,SIZE,DEALLOCATOR,T_CLASS,T_PARAMETER) \ + do { \ + if (POINTER) \ + { \ + for (size_t i = 0; \ + i < SIZE; \ + ++i) \ + { \ + (&(POINTER)[i])->~T_CLASS (); \ + } \ + DEALLOCATOR (POINTER); \ + } \ + } \ + while (0) +#if defined(ACE_EXPLICIT_TEMPLATE_DESTRUCTOR_TAKES_ARGS) +# define ACE_DES_FREE_TEMPLATE2(POINTER,DEALLOCATOR,T_CLASS,T_PARAM1,T_PARAM2) \ + do { \ + if (POINTER) \ + { \ + (POINTER)->~T_CLASS (); \ + DEALLOCATOR (POINTER); \ + } \ + } \ + while (0) +#else +# define ACE_DES_FREE_TEMPLATE2(POINTER,DEALLOCATOR,T_CLASS,T_PARAM1,T_PARAM2) \ + do { \ + if (POINTER) \ + { \ + (POINTER)->~T_CLASS (); \ + DEALLOCATOR (POINTER); \ + } \ + } \ + while (0) +#endif /* defined(ACE_EXPLICIT_TEMPLATE_DESTRUCTOR_TAKES_ARGS) */ +#if defined(ACE_EXPLICIT_TEMPLATE_DESTRUCTOR_TAKES_ARGS) +# define ACE_DES_FREE_TEMPLATE3(POINTER,DEALLOCATOR,T_CLASS,T_PARAM1,T_PARAM2,T_PARAM3) \ + do { \ + if (POINTER) \ + { \ + (POINTER)->~T_CLASS (); \ + DEALLOCATOR (POINTER); \ + } \ + } \ + while (0) +#else +# define ACE_DES_FREE_TEMPLATE3(POINTER,DEALLOCATOR,T_CLASS,T_PARAM1,T_PARAM2,T_PARAM3) \ + do { \ + if (POINTER) \ + { \ + (POINTER)->~T_CLASS (); \ + DEALLOCATOR (POINTER); \ + } \ + } \ + while (0) +#endif /* defined(ACE_EXPLICIT_TEMPLATE_DESTRUCTOR_TAKES_ARGS) */ +#if defined(ACE_EXPLICIT_TEMPLATE_DESTRUCTOR_TAKES_ARGS) +# define ACE_DES_FREE_TEMPLATE4(POINTER,DEALLOCATOR,T_CLASS,T_PARAM1,T_PARAM2,T_PARAM3, T_PARAM4) \ + do { \ + if (POINTER) \ + { \ + (POINTER)->~T_CLASS (); \ + DEALLOCATOR (POINTER); \ + } \ + } \ + while (0) +#else +# define ACE_DES_FREE_TEMPLATE4(POINTER,DEALLOCATOR,T_CLASS,T_PARAM1,T_PARAM2,T_PARAM3, T_PARAM4) \ + do { \ + if (POINTER) \ + { \ + (POINTER)->~T_CLASS (); \ + DEALLOCATOR (POINTER); \ + } \ + } \ + while (0) +#endif /* defined(ACE_EXPLICIT_TEMPLATE_DESTRUCTOR_TAKES_ARGS) */ +# define ACE_DES_ARRAY_FREE_TEMPLATE2(POINTER,SIZE,DEALLOCATOR,T_CLASS,T_PARAM1,T_PARAM2) \ + do { \ + if (POINTER) \ + { \ + for (size_t i = 0; \ + i < SIZE; \ + ++i) \ + { \ + (&(POINTER)[i])->~T_CLASS (); \ + } \ + DEALLOCATOR (POINTER); \ + } \ + } \ + while (0) +# else /* ! ACE_HAS_WORKING_EXPLICIT_TEMPLATE_DESTRUCTOR */ +# define ACE_DES_NOFREE_TEMPLATE(POINTER,T_CLASS,T_PARAMETER) \ + do { \ + if (POINTER) \ + { \ + (POINTER)->T_CLASS T_PARAMETER::~T_CLASS (); \ + } \ + } \ + while (0) +# define ACE_DES_ARRAY_NOFREE_TEMPLATE(POINTER,SIZE,T_CLASS,T_PARAMETER) \ + do { \ + if (POINTER) \ + { \ + for (size_t i = 0; \ + i < SIZE; \ + ++i) \ + { \ + (POINTER)[i].T_CLASS T_PARAMETER::~T_CLASS (); \ + } \ + } \ + } \ + while (0) +# define ACE_DES_FREE_TEMPLATE(POINTER,DEALLOCATOR,T_CLASS,T_PARAMETER) \ + do { \ + if (POINTER) \ + { \ + POINTER->T_CLASS T_PARAMETER::~T_CLASS (); \ + DEALLOCATOR (POINTER); \ + } \ + } \ + while (0) +# define ACE_DES_ARRAY_FREE_TEMPLATE(POINTER,SIZE,DEALLOCATOR,T_CLASS,T_PARAMETER) \ + do { \ + if (POINTER) \ + { \ + for (size_t i = 0; \ + i < SIZE; \ + ++i) \ + { \ + POINTER[i].T_CLASS T_PARAMETER::~T_CLASS (); \ + } \ + DEALLOCATOR (POINTER); \ + } \ + } \ + while (0) +# define ACE_DES_FREE_TEMPLATE2(POINTER,DEALLOCATOR,T_CLASS,T_PARAM1,T_PARAM2) \ + do { \ + if (POINTER) \ + { \ + POINTER->T_CLASS ::~T_CLASS (); \ + DEALLOCATOR (POINTER); \ + } \ + } \ + while (0) +# define ACE_DES_FREE_TEMPLATE3(POINTER,DEALLOCATOR,T_CLASS,T_PARAM1,T_PARAM2,T_PARAM3) \ + do { \ + if (POINTER) \ + { \ + POINTER->T_CLASS ::~T_CLASS (); \ + DEALLOCATOR (POINTER); \ + } \ + } \ + while (0) +# define ACE_DES_FREE_TEMPLATE4(POINTER,DEALLOCATOR,T_CLASS,T_PARAM1,T_PARAM2,T_PARAM3,T_PARAM4) \ + do { \ + if (POINTER) \ + { \ + POINTER->T_CLASS ::~T_CLASS (); \ + DEALLOCATOR (POINTER); \ + } \ + } \ + while (0) +# define ACE_DES_ARRAY_FREE_TEMPLATE2(POINTER,SIZE,DEALLOCATOR,T_CLASS,T_PARAM1,T_PARAM2) \ + do { \ + if (POINTER) \ + { \ + for (size_t i = 0; \ + i < SIZE; \ + ++i) \ + { \ + POINTER[i].T_CLASS ::~T_CLASS (); \ + } \ + DEALLOCATOR (POINTER); \ + } \ + } \ + while (0) +# endif /* defined ! ACE_HAS_WORKING_EXPLICIT_TEMPLATE_DESTRUCTOR */ + + +/*******************************************************************/ + +/// Service Objects, i.e., objects dynamically loaded via the service +/// configurator, must provide a destructor function with the +/// following prototype to perform object cleanup. +typedef void (*ACE_Service_Object_Exterminator)(void *); + +/** @name Service Configurator macros + * + * The following macros are used to define helper objects used in + * ACE's Service Configurator framework, which is described in + * Chapter 5 of C++NPv2 . This + * framework implements the Component Configurator pattern, which is + * described in Chapter 2 of POSA2 . + * The intent of this pattern is to allow developers to dynamically + * load and configure services into a system. With a little help from + * this macros statically linked services can also be dynamically + * configured. + * + * More details about this component are available in the documentation + * of the ACE_Service_Configurator class and also + * ACE_Dynamic_Service. + * + * Notice that in all the macros the SERVICE_CLASS parameter must be + * the name of a class derived from ACE_Service_Object. + */ +//@{ +/// Declare a the data structure required to register a statically +/// linked service into the service configurator. +/** + * The macro should be used in the header file where the service is + * declared, its only argument is usually the name of the class that + * implements the service. + * + * @param SERVICE_CLASS The name of the class implementing the + * service. + */ +# define ACE_STATIC_SVC_DECLARE(SERVICE_CLASS) \ +extern ACE_Static_Svc_Descriptor ace_svc_desc_##SERVICE_CLASS ; + +/// As ACE_STATIC_SVC_DECLARE, but using an export macro for NT +/// compilers. +/** + * NT compilers require the use of explicit directives to export and + * import symbols from a DLL. If you need to define a service in a + * dynamic library you should use this version instead. + * Normally ACE uses a macro to inject the correct export/import + * directives on NT. Naturally it also the macro expands to a blank + * on platforms that do not require such directives. + * The first argument (EXPORT_NAME) is the prefix for this export + * macro, the full name is formed by appending _Export. + * ACE provides tools to generate header files that define the macro + * correctly on all platforms, please see + * $ACE_ROOT/bin/generate_export_file.pl + * + * @param EXPORT_NAME The export macro name prefix. + * @param SERVICE_CLASS The name of the class implementing the service. + */ +#define ACE_STATIC_SVC_DECLARE_EXPORT(EXPORT_NAME,SERVICE_CLASS) \ +extern EXPORT_NAME##_Export ACE_Static_Svc_Descriptor ace_svc_desc_##SERVICE_CLASS; + +/// Define the data structure used to register a statically linked +/// service into the Service Configurator. +/** + * The service configurator requires several arguments to build and + * control an statically linked service, including its name, the + * factory function used to construct the service, and some flags. + * All those parameters are configured in a single structure, an + * instance of this structure is statically initialized using the + * following macro. + * + * @param SERVICE_CLASS The name of the class that implements the + * service, must be derived (directly or indirectly) from + * ACE_Service_Object. + * @param NAME The name for this service, this name is used by the + * service configurator to match configuration options provided in + * the svc.conf file. + * @param TYPE The type of object. Objects can be streams or service + * objects. Please read the ACE_Service_Configurator and ASX + * documentation for more details. + * @param FN The name of the factory function, usually the + * ACE_SVC_NAME macro can be used to generate the name. The + * factory function is often defined using ACE_FACTORY_DECLARE and + * ACE_FACTORY_DEFINE. + * @param FLAGS Flags to control the ownership and lifecycle of the + * object. Please read the ACE_Service_Configurator documentation + * for more details. + * @param ACTIVE If not zero then a thread will be dedicate to the + * service. Please read the ACE_Service_Configurator documentation + * for more details. + */ +# define ACE_STATIC_SVC_DEFINE(SERVICE_CLASS, NAME, TYPE, FN, FLAGS, ACTIVE) \ +ACE_Static_Svc_Descriptor ace_svc_desc_##SERVICE_CLASS = { NAME, TYPE, FN, FLAGS, ACTIVE }; + +/// Automatically register a service with the service configurator +/** + * In some applications the services must be automatically registered + * with the service configurator, before main() starts. + * The ACE_STATIC_SVC_REQUIRE macro defines a class whose constructor + * register the service, it also defines a static instance of that + * class to ensure that the service is registered before main. + * + * On platforms that lack adequate support for static C++ objects the + * macro ACE_STATIC_SVC_REGISTER can be used to explicitly register + * the service. + * + * @todo One class per-Service_Object seems wasteful. It should be + * possible to define a single class and re-use it for all the + * service objects, just by passing the Service_Descriptor as an + * argument to the constructor. + */ +#if defined(ACE_LACKS_STATIC_CONSTRUCTORS) +# define ACE_STATIC_SVC_REQUIRE(SERVICE_CLASS)\ +class ACE_Static_Svc_##SERVICE_CLASS {\ +public:\ + ACE_Static_Svc_##SERVICE_CLASS() { \ + ACE_Service_Config::insert (\ + &ace_svc_desc_##SERVICE_CLASS); \ + } \ +}; +#define ACE_STATIC_SVC_REGISTER(SERVICE_CLASS)\ +ACE_Static_Svc_##SERVICE_CLASS ace_static_svc_##SERVICE_CLASS + +#else /* !ACE_LACKS_STATIC_CONSTRUCTORS */ + +# define ACE_STATIC_SVC_REQUIRE(SERVICE_CLASS)\ +class ACE_Static_Svc_##SERVICE_CLASS {\ +public:\ + ACE_Static_Svc_##SERVICE_CLASS() { \ + ACE_Service_Config::insert (\ + &ace_svc_desc_##SERVICE_CLASS); \ + } \ +};\ +static ACE_Static_Svc_##SERVICE_CLASS ace_static_svc_##SERVICE_CLASS; +#define ACE_STATIC_SVC_REGISTER(SERVICE_CLASS) do {} while (0) + +#endif /* !ACE_LACKS_STATIC_CONSTRUCTORS */ + +// Preprocessor symbols will not be expanded if they are +// concatenated. Force the preprocessor to expand them during the +// argument prescan by calling a macro that itself calls another that +// performs the actual concatenation. +#define ACE_PREPROC_CONCATENATE_IMPL(A,B) A ## B +#define ACE_PREPROC_CONCATENATE(A,B) ACE_PREPROC_CONCATENATE_IMPL(A,B) + +#if defined (ACE_HAS_VERSIONED_NAMESPACE) && ACE_HAS_VERSIONED_NAMESPACE == 1 +// Preprocessor symbols will not be expanded if they are +// concatenated. Force the preprocessor to expand them during the +// argument prescan by calling a macro that itself calls another that +// performs the actual concatenation. +# define ACE_MAKE_SVC_CONFIG_FUNCTION_NAME(PREFIX,VERSIONED_NAMESPACE,SERVICE_CLASS) PREFIX ## _ ## VERSIONED_NAMESPACE ## _ ## SERVICE_CLASS +#else +# define ACE_MAKE_SVC_CONFIG_FUNCTION_NAME(PREFIX,VERSIONED_NAMESPACE,SERVICE_CLASS) PREFIX ## _ ## SERVICE_CLASS +#endif /* ACE_HAS_VERSIONED_NAMESPACE == 1 */ + +#define ACE_MAKE_SVC_CONFIG_FACTORY_NAME(VERSIONED_NAMESPACE,SERVICE_CLASS) ACE_MAKE_SVC_CONFIG_FUNCTION_NAME(_make,VERSIONED_NAMESPACE,SERVICE_CLASS) +#define ACE_MAKE_SVC_CONFIG_GOBBLER_NAME(VERSIONED_NAMESPACE,SERVICE_CLASS) ACE_MAKE_SVC_CONFIG_FUNCTION_NAME(_gobble,VERSIONED_NAMESPACE,SERVICE_CLASS) + + +/// Declare the factory method used to create dynamically loadable +/// services. +/** + * Once the service implementation is dynamically loaded the Service + * Configurator uses a factory method to create the object. + * This macro declares such a factory function with the proper + * interface and export macros. + * Normally used in the header file that declares the service + * implementation. + * + * @param CLS must match the prefix of the export macro used for this + * service. + * @param SERVICE_CLASS must match the name of the class that + * implements the service. + * + */ +# define ACE_FACTORY_DECLARE(CLS,SERVICE_CLASS) \ +extern "C" CLS##_Export ACE_VERSIONED_NAMESPACE_NAME::ACE_Service_Object * \ +ACE_MAKE_SVC_CONFIG_FACTORY_NAME(ACE_VERSIONED_NAMESPACE_NAME,SERVICE_CLASS) (ACE_Service_Object_Exterminator *); + +/// Define the factory method (and destructor) for a dynamically +/// loadable service. +/** + * Use with arguments matching ACE_FACTORY_DECLARE. + * Normally used in the .cpp file that defines the service + * implementation. + * + * This macro defines both the factory method and the function used to + * cleanup the service object. + * + * If this macro is used to define a factory function that need not be + * exported (for example, in a static service situation), CLS can be + * specified as ACE_Local_Service. + */ +# define ACE_Local_Service_Export + +#if defined (ACE_OPENVMS) +# define ACE_PREPROC_STRINGIFY(A) #A +# define ACE_MAKE_SVC_REGISTRAR_ARG(A) ACE_PREPROC_STRINGIFY(A), (void*)&A +# define ACE_FACTORY_DEFINE(CLS,SERVICE_CLASS) \ +void ACE_MAKE_SVC_CONFIG_GOBBLER_NAME(ACE_VERSIONED_NAMESPACE_NAME,SERVICE_CLASS) (void *p) { \ + ACE_VERSIONED_NAMESPACE_NAME::ACE_Service_Object * _p = \ + static_cast< ACE_VERSIONED_NAMESPACE_NAME::ACE_Service_Object *> (p); \ + ACE_ASSERT (_p != 0); \ + delete _p; } \ +extern "C" CLS##_Export ACE_VERSIONED_NAMESPACE_NAME::ACE_Service_Object *\ +ACE_MAKE_SVC_CONFIG_FACTORY_NAME(ACE_VERSIONED_NAMESPACE_NAME,SERVICE_CLASS) (ACE_Service_Object_Exterminator *gobbler) \ +{ \ + ACE_TRACE (#SERVICE_CLASS); \ + if (gobbler != 0) \ + *gobbler = (ACE_Service_Object_Exterminator) ACE_MAKE_SVC_CONFIG_GOBBLER_NAME(ACE_VERSIONED_NAMESPACE_NAME,SERVICE_CLASS); \ + return new SERVICE_CLASS; \ +} \ +ACE_Dynamic_Svc_Registrar ace_svc_reg_##SERVICE_CLASS \ + (ACE_MAKE_SVC_REGISTRAR_ARG(ACE_MAKE_SVC_CONFIG_FACTORY_NAME(ACE_VERSIONED_NAMESPACE_NAME,SERVICE_CLASS))); +#else +# define ACE_FACTORY_DEFINE(CLS,SERVICE_CLASS) \ +void ACE_MAKE_SVC_CONFIG_GOBBLER_NAME(ACE_VERSIONED_NAMESPACE_NAME,SERVICE_CLASS) (void *p) { \ + ACE_VERSIONED_NAMESPACE_NAME::ACE_Service_Object * _p = \ + static_cast< ACE_VERSIONED_NAMESPACE_NAME::ACE_Service_Object *> (p); \ + ACE_ASSERT (_p != 0); \ + delete _p; } \ +extern "C" CLS##_Export ACE_VERSIONED_NAMESPACE_NAME::ACE_Service_Object *\ +ACE_MAKE_SVC_CONFIG_FACTORY_NAME(ACE_VERSIONED_NAMESPACE_NAME,SERVICE_CLASS) (ACE_Service_Object_Exterminator *gobbler) \ +{ \ + ACE_TRACE (#SERVICE_CLASS); \ + if (gobbler != 0) \ + *gobbler = (ACE_Service_Object_Exterminator) ACE_MAKE_SVC_CONFIG_GOBBLER_NAME(ACE_VERSIONED_NAMESPACE_NAME,SERVICE_CLASS); \ + return new SERVICE_CLASS; \ +} +#endif + +/** + * For service classes scoped within namespaces, use this macro in + * place of ACE_FACTORY_DEFINE. The third argument in this case is + * the fully scoped name of the class as it is to be + * instantiated. For example, given: + * namespace ACE + * { + * namespace Foo + * { + * class Bar : public ACE_Service_Object + * {}; + * }; + * }; + * + * ACE_FACTORY_DECLARE(ACE,ACE_Foo_Bar) + * + * you would then use: + * + * ACE_FACTORY_NAMESPACE_DEFINE(ACE,ACE_Foo_Bar,ACE::Foo::Bar) + * + * Note that in this example, the ACE_FACTORY_DECLARE is done outside + * the namespace scope. Then, the SERVICE_CLASS name is the same as + * the fully scoped class name, but with '::' replaced with '_'. Doing + * this will ensure unique generated signatures for the various C + * style functions. + */ +#if defined (ACE_OPENVMS) +# define ACE_PREPROC_STRINGIFY(A) #A +# define ACE_MAKE_SVC_REGISTRAR_ARG(A) ACE_PREPROC_STRINGIFY(A), (void*)&A +# define ACE_FACTORY_NAMESPACE_DEFINE(CLS,SERVICE_CLASS,NAMESPACE_CLASS) \ +void ACE_MAKE_SVC_CONFIG_GOBBLER_NAME(ACE_VERSIONED_NAMESPACE_NAME,SERVICE_CLASS) (void *p) { \ + ACE_VERSIONED_NAMESPACE_NAME::ACE_Service_Object * _p = \ + static_cast< ACE_VERSIONED_NAMESPACE_NAME::ACE_Service_Object *> (p); \ + ACE_ASSERT (_p != 0); \ + delete _p; } \ +extern "C" CLS##_Export ACE_VERSIONED_NAMESPACE_NAME::ACE_Service_Object *\ +ACE_MAKE_SVC_CONFIG_FACTORY_NAME(ACE_VERSIONED_NAMESPACE_NAME,SERVICE_CLASS) (ACE_Service_Object_Exterminator *gobbler) \ +{ \ + ACE_TRACE (#SERVICE_CLASS); \ + if (gobbler != 0) \ + *gobbler = (ACE_Service_Object_Exterminator) ACE_MAKE_SVC_CONFIG_GOBBLER_NAME(ACE_VERSIONED_NAMESPACE_NAME,SERVICE_CLASS); \ + return new NAMESPACE_CLASS; \ +} \ +ACE_Dynamic_Svc_Registrar ace_svc_reg_##SERVICE_CLASS \ + (ACE_MAKE_SVC_REGISTRAR_ARG(ACE_MAKE_SVC_CONFIG_FACTORY_NAME(ACE_VERSIONED_NAMESPACE_NAME,SERVICE_CLASS))); +#else +# define ACE_FACTORY_NAMESPACE_DEFINE(CLS,SERVICE_CLASS,NAMESPACE_CLASS) \ +void ACE_MAKE_SVC_CONFIG_GOBBLER_NAME(ACE_VERSIONED_NAMESPACE_NAME,SERVICE_CLASS) (void *p) { \ + ACE_VERSIONED_NAMESPACE_NAME::ACE_Service_Object * _p = \ + static_cast< ACE_VERSIONED_NAMESPACE_NAME::ACE_Service_Object *> (p); \ + ACE_ASSERT (_p != 0); \ + delete _p; } \ +extern "C" CLS##_Export ACE_VERSIONED_NAMESPACE_NAME::ACE_Service_Object *\ +ACE_MAKE_SVC_CONFIG_FACTORY_NAME(ACE_VERSIONED_NAMESPACE_NAME,SERVICE_CLASS) (ACE_Service_Object_Exterminator *gobbler) \ +{ \ + ACE_TRACE (#SERVICE_CLASS); \ + if (gobbler != 0) \ + *gobbler = (ACE_Service_Object_Exterminator) ACE_MAKE_SVC_CONFIG_GOBBLER_NAME(ACE_VERSIONED_NAMESPACE_NAME,SERVICE_CLASS); \ + return new NAMESPACE_CLASS; \ +} +#endif + +/// The canonical name for a service factory method +# define ACE_SVC_NAME(SERVICE_CLASS) ACE_MAKE_SVC_CONFIG_FACTORY_NAME(ACE_VERSIONED_NAMESPACE_NAME,SERVICE_CLASS) + +/// The canonical way to invoke (i.e. construct) a service factory +/// method. +#define ACE_SVC_INVOKE(SERVICE_CLASS) ACE_SVC_NAME(SERVICE_CLASS) (0) + +//@} + +/** @name Helper macros for services defined in the netsvcs library. + * + * The ACE services defined in netsvcs use this helper macros for + * simplicity. + * + */ +//@{ +# define ACE_SVC_FACTORY_DECLARE(X) ACE_FACTORY_DECLARE (ACE_Svc, X) +# define ACE_SVC_FACTORY_DEFINE(X) ACE_FACTORY_DEFINE (ACE_Svc, X) +//@} + +#if defined (ACE_WIN32) +// These are used in SPIPE_Acceptor/Connector, but are ignored at runtime. +# if defined (ACE_HAS_WINCE) +# if !defined (PIPE_TYPE_MESSAGE) +# define PIPE_TYPE_MESSAGE 0 +# endif +# if !defined (PIPE_READMODE_MESSAGE) +# define PIPE_READMODE_MESSAGE 0 +# endif +# if !defined (PIPE_WAIT) +# define PIPE_WAIT 0 +# endif +# endif /* ACE_HAS_WINCE */ +#else /* !ACE_WIN32 */ +// Add some typedefs and macros to enhance Win32 conformance... +# if !defined (LPSECURITY_ATTRIBUTES) +# define LPSECURITY_ATTRIBUTES int +# endif /* !defined LPSECURITY_ATTRIBUTES */ +# if !defined (GENERIC_READ) +# define GENERIC_READ 0 +# endif /* !defined GENERIC_READ */ +# if !defined (FILE_SHARE_READ) +# define FILE_SHARE_READ 0 +# endif /* !defined FILE_SHARE_READ */ +# if !defined (OPEN_EXISTING) +# define OPEN_EXISTING 0 +# endif /* !defined OPEN_EXISTING */ +# if !defined (FILE_ATTRIBUTE_NORMAL) +# define FILE_ATTRIBUTE_NORMAL 0 +# endif /* !defined FILE_ATTRIBUTE_NORMAL */ +# if !defined (MAXIMUM_WAIT_OBJECTS) +# define MAXIMUM_WAIT_OBJECTS 0 +# endif /* !defined MAXIMUM_WAIT_OBJECTS */ +# if !defined (FILE_FLAG_OVERLAPPED) +# define FILE_FLAG_OVERLAPPED 0 +# endif /* !defined FILE_FLAG_OVERLAPPED */ +# if !defined (FILE_FLAG_SEQUENTIAL_SCAN) +# define FILE_FLAG_SEQUENTIAL_SCAN 0 +# endif /* FILE_FLAG_SEQUENTIAL_SCAN */ +# if !defined(FILE_FLAG_WRITE_THROUGH) +# define FILE_FLAG_WRITE_THROUGH 0 +# endif /* !defined FILE_FLAG_WRITE_THROUGH */ +# if !defined(PIPE_WAIT) +# define PIPE_WAIT 0 +# endif /* !defined PIPE_WAIT */ +# if !defined(PIPE_NOWAIT) +# define PIPE_NOWAIT 0 +# endif /* !defined PIPE_WAIT */ +# if !defined(PIPE_READMODE_BYTE) +# define PIPE_READMODE_BYTE 0 +# endif /* !defined PIPE_READMODE_BYTE */ +# if !defined(PIPE_READMODE_MESSAGE) +# define PIPE_READMODE_MESSAGE 0 +# endif /* !defined PIPE_READMODE_MESSAGE */ +# if !defined(PIPE_TYPE_BYTE) +# define PIPE_TYPE_BYTE 0 +# endif /* !defined PIPE_TYPE_BYTE */ +# if !defined(PIPE_TYPE_MESSAGE) +# define PIPE_TYPE_MESSAGE 0 +# endif /* !defined PIPE_TYPE_MESSAGE */ +#endif /* ACE_WIN32 */ + + +// Some useful abstrations for expressions involving +// ACE_Allocator.malloc (). The difference between ACE_NEW_MALLOC* +// with ACE_ALLOCATOR* is that they call constructors also. + +#include "ace/OS_Errno.h" /* Need errno and ENOMEM */ + +# define ACE_ALLOCATOR_RETURN(POINTER,ALLOCATOR,RET_VAL) \ + do { POINTER = ALLOCATOR; \ + if (POINTER == 0) { errno = ENOMEM; return RET_VAL; } \ + } while (0) +# define ACE_ALLOCATOR(POINTER,ALLOCATOR) \ + do { POINTER = ALLOCATOR; \ + if (POINTER == 0) { errno = ENOMEM; return; } \ + } while (0) +# define ACE_ALLOCATOR_NORETURN(POINTER,ALLOCATOR) \ + do { POINTER = ALLOCATOR; \ + if (POINTER == 0) { errno = ENOMEM; } \ + } while (0) + +# define ACE_NEW_MALLOC_RETURN(POINTER,ALLOCATOR,CONSTRUCTOR,RET_VAL) \ + do { POINTER = ALLOCATOR; \ + if (POINTER == 0) { errno = ENOMEM; return RET_VAL;} \ + else { (void) new (POINTER) CONSTRUCTOR; } \ + } while (0) +# define ACE_NEW_MALLOC(POINTER,ALLOCATOR,CONSTRUCTOR) \ + do { POINTER = ALLOCATOR; \ + if (POINTER == 0) { errno = ENOMEM; return;} \ + else { (void) new (POINTER) CONSTRUCTOR; } \ + } while (0) +# define ACE_NEW_MALLOC_NORETURN(POINTER,ALLOCATOR,CONSTRUCTOR) \ + do { POINTER = ALLOCATOR; \ + if (POINTER == 0) { errno = ENOMEM;} \ + else { (void) new (POINTER) CONSTRUCTOR; } \ + } while (0) + +/* ACE_Metrics */ +#if defined ACE_LACKS_ARRAY_PLACEMENT_NEW +# define ACE_NEW_MALLOC_ARRAY_RETURN(POINTER,ALLOCATOR,CONSTRUCTOR,COUNT,RET_VAL) \ + do { POINTER = ALLOCATOR; \ + if (POINTER == 0) { errno = ENOMEM; return RET_VAL;} \ + else { for (u_int i = 0; i < COUNT; ++i) \ + {(void) new (POINTER) CONSTRUCTOR; ++POINTER;} \ + POINTER -= COUNT;} \ + } while (0) +# define ACE_NEW_MALLOC_ARRAY(POINTER,ALLOCATOR,CONSTRUCTOR,COUNT) \ + do { POINTER = ALLOCATOR; \ + if (POINTER == 0) { errno = ENOMEM; return;} \ + else { for (u_int i = 0; i < COUNT; ++i) \ + {(void) new (POINTER) CONSTRUCTOR; ++POINTER;} \ + POINTER -= COUNT;} \ + } while (0) +#else /* ! defined ACE_LACKS_ARRAY_PLACEMENT_NEW */ +# define ACE_NEW_MALLOC_ARRAY_RETURN(POINTER,ALLOCATOR,CONSTRUCTOR,COUNT,RET_VAL) \ + do { POINTER = ALLOCATOR; \ + if (POINTER == 0) { errno = ENOMEM; return RET_VAL;} \ + else { (void) new (POINTER) CONSTRUCTOR [COUNT]; } \ + } while (0) +# define ACE_NEW_MALLOC_ARRAY(POINTER,ALLOCATOR,CONSTRUCTOR,COUNT) \ + do { POINTER = ALLOCATOR; \ + if (POINTER == 0) { errno = ENOMEM; return;} \ + else { (void) new (POINTER) CONSTRUCTOR [COUNT]; } \ + } while (0) +#endif /* defined ACE_LACKS_ARRAY_PLACEMENT_NEW */ + +// This is being placed here temporarily to help stablelize the builds, but will +// be moved out along with the above macros as part of the subsetting. dhinton +#if !defined (ACE_LACKS_NEW_H) +# if defined (ACE_USES_STD_NAMESPACE_FOR_STDCPP_LIB) +# include /**/ +# else +# include /**/ +# endif /* ACE_USES_STD_NAMESPACE_FOR_STDCPP_LIB */ +#endif /* ! ACE_LACKS_NEW_H */ + +# define ACE_NOOP(x) + +#if defined (ACE_WIN32) && defined (ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS) +# define ACE_SEH_TRY __try +# define ACE_SEH_EXCEPT(X) __except(X) +# define ACE_SEH_FINALLY __finally +#else /* !ACE_WIN32 */ +# define ACE_SEH_TRY if (1) +# define ACE_SEH_EXCEPT(X) while (0) +# define ACE_SEH_FINALLY if (1) +#endif /* ACE_WIN32 */ + +// These should probably be put into a seperate header. + +// The following is necessary since many C++ compilers don't support +// typedef'd types inside of classes used as formal template +// arguments... ;-(. Luckily, using the C++ preprocessor I can hide +// most of this nastiness! + +# if defined (ACE_HAS_TEMPLATE_TYPEDEFS) + +// Handle ACE_Message_Queue. +# define ACE_SYNCH_DECL class _ACE_SYNCH +# define ACE_SYNCH_USE _ACE_SYNCH +# define ACE_SYNCH_MUTEX_T typename _ACE_SYNCH::MUTEX +# define ACE_SYNCH_CONDITION_T typename _ACE_SYNCH::CONDITION +# define ACE_SYNCH_SEMAPHORE_T typename _ACE_SYNCH::SEMAPHORE + +// Handle ACE_Malloc* +# define ACE_MEM_POOL_1 class _ACE_MEM_POOL +# define ACE_MEM_POOL_2 _ACE_MEM_POOL +# define ACE_MEM_POOL _ACE_MEM_POOL +# define ACE_MEM_POOL_OPTIONS typename _ACE_MEM_POOL::OPTIONS + +// Handle ACE_Svc_Handler +# define ACE_PEER_STREAM_1 class _ACE_PEER_STREAM +# define ACE_PEER_STREAM_2 _ACE_PEER_STREAM +# define ACE_PEER_STREAM _ACE_PEER_STREAM +# define ACE_PEER_STREAM_ADDR typename _ACE_PEER_STREAM::PEER_ADDR + +// Handle ACE_Acceptor +# define ACE_PEER_ACCEPTOR_1 class _ACE_PEER_ACCEPTOR +# define ACE_PEER_ACCEPTOR_2 _ACE_PEER_ACCEPTOR +# define ACE_PEER_ACCEPTOR _ACE_PEER_ACCEPTOR +# define ACE_PEER_ACCEPTOR_ADDR typename _ACE_PEER_ACCEPTOR::PEER_ADDR + +// Handle ACE_Connector +# define ACE_PEER_CONNECTOR_1 class _ACE_PEER_CONNECTOR +# define ACE_PEER_CONNECTOR_2 _ACE_PEER_CONNECTOR +# define ACE_PEER_CONNECTOR _ACE_PEER_CONNECTOR +# define ACE_PEER_CONNECTOR_ADDR typename ACE_PEER_CONNECTOR::PEER_ADDR +# define ACE_PEER_CONNECTOR_ADDR_ANY ACE_PEER_ADDR_TYPEDEF::sap_any + +// Handle ACE_SOCK_* +# define ACE_SOCK_ACCEPTOR ACE_SOCK_Acceptor +# define ACE_SOCK_CONNECTOR ACE_SOCK_Connector +# define ACE_SOCK_STREAM ACE_SOCK_Stream +# define ACE_SOCK_DGRAM ACE_SOCK_Dgram +# define ACE_SOCK_DGRAM_BCAST ACE_SOCK_Dgram_Bcast +# define ACE_SOCK_DGRAM_MCAST ACE_SOCK_Dgram_Mcast + +// Handle ACE_SOCK_SEQPACK_* +# define ACE_SOCK_SEQPACK_ACCEPTOR ACE_SOCK_SEQPACK_Acceptor +# define ACE_SOCK_SEQPACK_CONNECTOR ACE_SOCK_SEQPACK_Connector +# define ACE_SOCK_SEQPACK_ASSOCIATION ACE_SOCK_SEQPACK_Association + +// Handle ACE_MEM_* +# define ACE_MEM_ACCEPTOR ACE_MEM_Acceptor +# define ACE_MEM_CONNECTOR ACE_MEM_Connector +# define ACE_MEM_STREAM ACE_MEM_Stream + +// Handle ACE_LSOCK_* +# define ACE_LSOCK_ACCEPTOR ACE_LSOCK_Acceptor +# define ACE_LSOCK_CONNECTOR ACE_LSOCK_Connector +# define ACE_LSOCK_STREAM ACE_LSOCK_Stream + +// Handle ACE_TLI_* +# define ACE_TLI_ACCEPTOR ACE_TLI_Acceptor +# define ACE_TLI_CONNECTOR ACE_TLI_Connector +# define ACE_TLI_STREAM ACE_TLI_Stream + +// Handle ACE_SPIPE_* +# define ACE_SPIPE_ACCEPTOR ACE_SPIPE_Acceptor +# define ACE_SPIPE_CONNECTOR ACE_SPIPE_Connector +# define ACE_SPIPE_STREAM ACE_SPIPE_Stream + +// Handle ACE_UPIPE_* +# define ACE_UPIPE_ACCEPTOR ACE_UPIPE_Acceptor +# define ACE_UPIPE_CONNECTOR ACE_UPIPE_Connector +# define ACE_UPIPE_STREAM ACE_UPIPE_Stream + +// Handle ACE_FILE_* +# define ACE_FILE_CONNECTOR ACE_FILE_Connector +# define ACE_FILE_STREAM ACE_FILE_IO + +// Handle ACE_*_Memory_Pool. +# define ACE_MMAP_MEMORY_POOL ACE_MMAP_Memory_Pool +# define ACE_LITE_MMAP_MEMORY_POOL ACE_Lite_MMAP_Memory_Pool +# define ACE_SBRK_MEMORY_POOL ACE_Sbrk_Memory_Pool +# define ACE_SHARED_MEMORY_POOL ACE_Shared_Memory_Pool +# define ACE_LOCAL_MEMORY_POOL ACE_Local_Memory_Pool +# define ACE_PAGEFILE_MEMORY_POOL ACE_Pagefile_Memory_Pool + +# else /* TEMPLATES are broken in some form or another (i.e., most C++ compilers) */ + +// Handle ACE_Message_Queue. +# if defined (ACE_HAS_OPTIMIZED_MESSAGE_QUEUE) +# define ACE_SYNCH_DECL class _ACE_SYNCH_MUTEX_T, class _ACE_SYNCH_CONDITION_T, class _ACE_SYNCH_SEMAPHORE_T +# define ACE_SYNCH_USE _ACE_SYNCH_MUTEX_T, _ACE_SYNCH_CONDITION_T, _ACE_SYNCH_SEMAPHORE_T +# else +# define ACE_SYNCH_DECL class _ACE_SYNCH_MUTEX_T, class _ACE_SYNCH_CONDITION_T +# define ACE_SYNCH_USE _ACE_SYNCH_MUTEX_T, _ACE_SYNCH_CONDITION_T +# endif /* ACE_HAS_OPTIMIZED_MESSAGE_QUEUE */ +# define ACE_SYNCH_MUTEX_T _ACE_SYNCH_MUTEX_T +# define ACE_SYNCH_CONDITION_T _ACE_SYNCH_CONDITION_T +# define ACE_SYNCH_SEMAPHORE_T _ACE_SYNCH_SEMAPHORE_T + +// Handle ACE_Malloc* +# define ACE_MEM_POOL_1 class _ACE_MEM_POOL, class _ACE_MEM_POOL_OPTIONS +# define ACE_MEM_POOL_2 _ACE_MEM_POOL, _ACE_MEM_POOL_OPTIONS +# define ACE_MEM_POOL _ACE_MEM_POOL +# define ACE_MEM_POOL_OPTIONS _ACE_MEM_POOL_OPTIONS + +// Handle ACE_Svc_Handler +# define ACE_PEER_STREAM_1 class _ACE_PEER_STREAM, class _ACE_PEER_ADDR +# define ACE_PEER_STREAM_2 _ACE_PEER_STREAM, _ACE_PEER_ADDR +# define ACE_PEER_STREAM _ACE_PEER_STREAM +# define ACE_PEER_STREAM_ADDR _ACE_PEER_ADDR + +// Handle ACE_Acceptor +# define ACE_PEER_ACCEPTOR_1 class _ACE_PEER_ACCEPTOR, class _ACE_PEER_ADDR +# define ACE_PEER_ACCEPTOR_2 _ACE_PEER_ACCEPTOR, _ACE_PEER_ADDR +# define ACE_PEER_ACCEPTOR _ACE_PEER_ACCEPTOR +# define ACE_PEER_ACCEPTOR_ADDR _ACE_PEER_ADDR + +// Handle ACE_Connector +# define ACE_PEER_CONNECTOR_1 class _ACE_PEER_CONNECTOR, class _ACE_PEER_ADDR +# define ACE_PEER_CONNECTOR_2 _ACE_PEER_CONNECTOR, _ACE_PEER_ADDR +# define ACE_PEER_CONNECTOR _ACE_PEER_CONNECTOR +# define ACE_PEER_CONNECTOR_ADDR _ACE_PEER_ADDR +# define ACE_PEER_CONNECTOR_ADDR_ANY ACE_PEER_CONNECTOR_ADDR::sap_any + +// Handle ACE_SOCK_* +# define ACE_SOCK_ACCEPTOR ACE_SOCK_Acceptor, ACE_INET_Addr +# define ACE_SOCK_CONNECTOR ACE_SOCK_Connector, ACE_INET_Addr +# define ACE_SOCK_STREAM ACE_SOCK_Stream, ACE_INET_Addr +# define ACE_SOCK_DGRAM ACE_SOCK_Dgram, ACE_INET_Addr +# define ACE_SOCK_DGRAM_BCAST ACE_SOCK_Dgram_Bcast, ACE_INET_Addr +# define ACE_SOCK_DGRAM_MCAST ACE_SOCK_Dgram_Mcast, ACE_INET_Addr + +// Handle ACE_SOCK_SEQPACK_* +# define ACE_SOCK_SEQPACK_ACCEPTOR ACE_SOCK_SEQPACK_Acceptor, ACE_Multihomed_INET_Addr +# define ACE_SOCK_SEQPACK_CONNECTOR ACE_SOCK_SEQPACK_Connector, ACE_Multihomed_INET_Addr +# define ACE_SOCK_SEQPACK_ASSOCIATION ACE_SOCK_SEQPACK_Association, ACE_Multihomed_INET_Addr + +// Handle ACE_MEM_* +# define ACE_MEM_ACCEPTOR ACE_MEM_Acceptor, ACE_MEM_Addr +# define ACE_MEM_CONNECTOR ACE_MEM_Connector, ACE_INET_Addr +# define ACE_MEM_STREAM ACE_MEM_Stream, ACE_INET_Addr + +// Handle ACE_LSOCK_* +# define ACE_LSOCK_ACCEPTOR ACE_LSOCK_Acceptor, ACE_UNIX_Addr +# define ACE_LSOCK_CONNECTOR ACE_LSOCK_Connector, ACE_UNIX_Addr +# define ACE_LSOCK_STREAM ACE_LSOCK_Stream, ACE_UNIX_Addr + +// Handle ACE_TLI_* +# define ACE_TLI_ACCEPTOR ACE_TLI_Acceptor, ACE_INET_Addr +# define ACE_TLI_CONNECTOR ACE_TLI_Connector, ACE_INET_Addr +# define ACE_TLI_STREAM ACE_TLI_Stream, ACE_INET_Addr + +// Handle ACE_SPIPE_* +# define ACE_SPIPE_ACCEPTOR ACE_SPIPE_Acceptor, ACE_SPIPE_Addr +# define ACE_SPIPE_CONNECTOR ACE_SPIPE_Connector, ACE_SPIPE_Addr +# define ACE_SPIPE_STREAM ACE_SPIPE_Stream, ACE_SPIPE_Addr + +// Handle ACE_UPIPE_* +# define ACE_UPIPE_ACCEPTOR ACE_UPIPE_Acceptor, ACE_SPIPE_Addr +# define ACE_UPIPE_CONNECTOR ACE_UPIPE_Connector, ACE_SPIPE_Addr +# define ACE_UPIPE_STREAM ACE_UPIPE_Stream, ACE_SPIPE_Addr + +// Handle ACE_FILE_* +# define ACE_FILE_CONNECTOR ACE_FILE_Connector, ACE_FILE_Addr +# define ACE_FILE_STREAM ACE_FILE_IO, ACE_FILE_Addr + +// Handle ACE_*_Memory_Pool. +# define ACE_MMAP_MEMORY_POOL ACE_MMAP_Memory_Pool, ACE_MMAP_Memory_Pool_Options +# define ACE_LITE_MMAP_MEMORY_POOL ACE_Lite_MMAP_Memory_Pool, ACE_MMAP_Memory_Pool_Options +# define ACE_SBRK_MEMORY_POOL ACE_Sbrk_Memory_Pool, ACE_Sbrk_Memory_Pool_Options +# define ACE_SHARED_MEMORY_POOL ACE_Shared_Memory_Pool, ACE_Shared_Memory_Pool_Options +# define ACE_LOCAL_MEMORY_POOL ACE_Local_Memory_Pool, ACE_Local_Memory_Pool_Options +# define ACE_PAGEFILE_MEMORY_POOL ACE_Pagefile_Memory_Pool, ACE_Pagefile_Memory_Pool_Options +# endif /* ACE_HAS_TEMPLATE_TYPEDEFS */ + +// Work around compilers that don't like in-class static integral +// constants. Constants in this case are meant to be compile-time +// constants so that they may be used as template arguments, for +// example. BOOST provides a similar macro. +#ifndef ACE_LACKS_STATIC_IN_CLASS_CONSTANTS +# define ACE_STATIC_CONSTANT(TYPE, ASSIGNMENT) static TYPE const ASSIGNMENT +#else +# define ACE_STATIC_CONSTANT(TYPE, ASSIGNMENT) enum { ASSIGNMENT } +#endif /* !ACE_LACKS_STATIC_IN_CLASS_CONSTANTS */ + +#include /**/ "ace/post.h" + +#endif /*ACE_GLOBAL_MACROS_H*/ diff --git a/dep/ACE_wrappers/ace/Guard_T.cpp b/dep/ACE_wrappers/ace/Guard_T.cpp new file mode 100644 index 00000000000..a21fc2e2fc7 --- /dev/null +++ b/dep/ACE_wrappers/ace/Guard_T.cpp @@ -0,0 +1,61 @@ +// $Id: Guard_T.cpp 80826 2008-03-04 14:51:23Z wotte $ + +#ifndef ACE_GUARD_T_CPP +#define ACE_GUARD_T_CPP + +#include "ace/Guard_T.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#if !defined (__ACE_INLINE__) +#include "ace/Guard_T.inl" +#endif /* __ACE_INLINE__ */ + +#if defined (ACE_HAS_DUMP) +# include "ace/Log_Msg.h" +#endif /* ACE_HAS_DUMP */ + +// **************************************************************** + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +// ACE_ALLOC_HOOK_DEFINE(ACE_Guard) + +template void +ACE_Guard::dump (void) const +{ +#if defined (ACE_HAS_DUMP) +// ACE_TRACE ("ACE_Guard::dump"); + + ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("mutex_ = %x\n"), this->lock_)); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("owner_ = %d\n"), this->owner_)); + ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); +#endif /* ACE_HAS_DUMP */ +} + +// ACE_ALLOC_HOOK_DEFINE(ACE_Write_Guard) + +template void +ACE_Write_Guard::dump (void) const +{ +#if defined (ACE_HAS_DUMP) +// ACE_TRACE ("ACE_Write_Guard::dump"); + ACE_Guard::dump (); +#endif /* ACE_HAS_DUMP */ +} + +// ACE_ALLOC_HOOK_DEFINE(ACE_Read_Guard) + +template void +ACE_Read_Guard::dump (void) const +{ +// ACE_TRACE ("ACE_Read_Guard::dump"); + ACE_Guard::dump (); +} + +ACE_END_VERSIONED_NAMESPACE_DECL + +#endif /* ACE_GUARD_T_CPP */ diff --git a/dep/ACE_wrappers/ace/Guard_T.h b/dep/ACE_wrappers/ace/Guard_T.h new file mode 100644 index 00000000000..46d555505af --- /dev/null +++ b/dep/ACE_wrappers/ace/Guard_T.h @@ -0,0 +1,365 @@ +// -*- C++ -*- + +//========================================================================== +/** + * @file Guard_T.h + * + * $Id: Guard_T.h 82508 2008-08-05 13:52:48Z johnnyw $ + * + * Moved from Synch.h. + * + * @author Douglas C. Schmidt + */ +//========================================================================== + +#ifndef ACE_GUARD_T_H +#define ACE_GUARD_T_H +#include /**/ "ace/pre.h" + +#include "ace/Lock.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/Global_Macros.h" +#include "ace/OS_NS_Thread.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +/** + * @class ACE_Guard + * + * @brief This data structure is meant to be used within a method or + * function... It performs automatic aquisition and release of + * a parameterized synchronization object . + * + * The class given as an actual parameter must provide at + * the very least the , , , and + * methods. + */ +template +class ACE_Guard +{ +public: + + // = Initialization and termination methods. + ACE_Guard (ACE_LOCK &l); + + /// Implicitly and automatically acquire (or try to acquire) the + /// lock. If @a block is non-0 then the , else + /// it. + ACE_Guard (ACE_LOCK &l, bool block); + + /// Initialise the guard without implicitly acquiring the lock. The + /// parameter indicates whether the guard should release + /// the lock implicitly on destruction. The parameter is + /// ignored and is used here to disambiguate with the preceding + /// constructor. + ACE_Guard (ACE_LOCK &l, bool block, int become_owner); + + /// Implicitly release the lock. + ~ACE_Guard (void); + + // = Lock accessors. + + /// Explicitly acquire the lock. + int acquire (void); + + /// Conditionally acquire the lock (i.e., won't block). + int tryacquire (void); + + /// Explicitly release the lock, but only if it is held! + int release (void); + + /// Relinquish ownership of the lock so that it is not released + /// implicitly in the destructor. + void disown (void); + + // = Utility methods. + /// 1 if locked, 0 if couldn't acquire the lock + /// (errno will contain the reason for this). + int locked (void) const; + + /// Explicitly remove the lock. + int remove (void); + + /// Dump the state of an object. + void dump (void) const; + + // ACE_ALLOC_HOOK_DECLARE; + // Declare the dynamic allocation hooks. + +protected: + + /// Helper, meant for subclass only. + ACE_Guard (ACE_LOCK *lock): lock_ (lock), owner_ (0) {} + + /// Pointer to the ACE_LOCK we're guarding. + ACE_LOCK *lock_; + + /// Keeps track of whether we acquired the lock or failed. + int owner_; + +private: + // = Prevent assignment and initialization. + ACE_UNIMPLEMENTED_FUNC (void operator= (const ACE_Guard &)) + ACE_UNIMPLEMENTED_FUNC (ACE_Guard (const ACE_Guard &)) +}; + +/** + * @class ACE_Write_Guard + * + * @brief This class is similar to class ACE_Guard, though it + * acquires/releases a write lock automatically (naturally, the + * it is instantiated with must support the appropriate + * API). + */ +template +class ACE_Write_Guard : public ACE_Guard +{ +public: + // = Initialization method. + + /// Implicitly and automatically acquire a write lock. + ACE_Write_Guard (ACE_LOCK &m); + + /// Implicitly and automatically acquire (or try to acquire) a write + /// lock. + ACE_Write_Guard (ACE_LOCK &m, bool block); + + // = Lock accessors. + + /// Explicitly acquire the write lock. + int acquire_write (void); + + /// Explicitly acquire the write lock. + int acquire (void); + + /// Conditionally acquire the write lock (i.e., won't block). + int tryacquire_write (void); + + /// Conditionally acquire the write lock (i.e., won't block). + int tryacquire (void); + + // = Utility methods. + + /// Dump the state of an object. + void dump (void) const; + + // ACE_ALLOC_HOOK_DECLARE; + // Declare the dynamic allocation hooks. +}; + +/** + * @class ACE_Read_Guard + * + * @brief This class is similar to class ACE_Guard, though it + * acquires/releases a read lock automatically (naturally, the + * it is instantiated with must support the appropriate + * API). + */ +template +class ACE_Read_Guard : public ACE_Guard +{ +public: + // = Initialization methods. + + /// Implicitly and automatically acquire a read lock. + ACE_Read_Guard (ACE_LOCK& m); + + /// Implicitly and automatically acquire (or try to acquire) a read + /// lock. + ACE_Read_Guard (ACE_LOCK &m, bool block); + + // = Lock accessors. + + /// Explicitly acquire the read lock. + int acquire_read (void); + + /// Explicitly acquire the read lock. + int acquire (void); + + /// Conditionally acquire the read lock (i.e., won't block). + int tryacquire_read (void); + + /// Conditionally acquire the read lock (i.e., won't block). + int tryacquire (void); + + // = Utility methods. + + /// Dump the state of an object. + void dump (void) const; + + // ACE_ALLOC_HOOK_DECLARE; + // Declare the dynamic allocation hooks. +}; + +#if !(defined (ACE_HAS_THREADS) && (defined (ACE_HAS_THREAD_SPECIFIC_STORAGE) || defined (ACE_HAS_TSS_EMULATION))) + +#define ACE_TSS_Guard ACE_Guard +#define ACE_TSS_Write_GUARD ACE_Write_Guard +#define ACE_TSS_Read_GUARD ACE_Read_Guard + +#else + /* ACE platform supports some form of threading and + thread-specific storage. */ + +/** + * @class ACE_TSS_Guard + * + * @brief This data structure is meant to be used within a method or + * function... It performs automatic aquisition and release of + * a synchronization object. Moreover, it ensures that the lock + * is released even if a thread exits via ! + */ +template +class ACE_TSS_Guard +{ +public: + // = Initialization and termination methods. + + /// Implicitly and automatically acquire the thread-specific lock. + ACE_TSS_Guard (ACE_LOCK &lock, bool block = true); + + /// Implicitly release the thread-specific lock. + ~ACE_TSS_Guard (void); + + // = Lock accessors. + + /// Explicitly acquire the thread-specific lock. + int acquire (void); + + /// Conditionally acquire the thread-specific lock (i.e., won't + /// block). + int tryacquire (void); + + /// Explicitly release the thread-specific lock. + int release (void); + + // = Utility methods. + /// Explicitly release the thread-specific lock. + int remove (void); + + /// Dump the state of an object. + void dump (void) const; + + // ACE_ALLOC_HOOK_DECLARE; + // Declare the dynamic allocation hooks. + +protected: + /// Helper, meant for subclass only. + ACE_TSS_Guard (void); + + /// Initialize the key. + void init_key (void); + + /// Called when thread exits to clean up the lock. + static void cleanup (void *ptr); + + /// Thread-specific key... + ACE_thread_key_t key_; + +private: + // = Prevent assignment and initialization. + ACE_UNIMPLEMENTED_FUNC (void operator= (const ACE_TSS_Guard &)) + ACE_UNIMPLEMENTED_FUNC (ACE_TSS_Guard (const ACE_TSS_Guard &)) +}; + +/** + * @class ACE_TSS_Write_Guard + * + * @brief This class is similar to class ACE_TSS_Guard, though it + * acquires/releases a write-lock automatically (naturally, the + * ACE_LOCK it is instantiated with must support the appropriate + * API). + */ +template +class ACE_TSS_Write_Guard : public ACE_TSS_Guard +{ +public: + // = Initialization method. + + /// Implicitly and automatically acquire the thread-specific write lock. + ACE_TSS_Write_Guard (ACE_LOCK &lock, bool block = true); + + // = Lock accessors. + + /// Explicitly acquire the thread-specific write lock. + int acquire_write (void); + + /// Explicitly acquire the thread-specific write lock. + int acquire (void); + + /// Conditionally acquire the thread-specific write lock (i.e., won't block). + int tryacquire_write (void); + + /// Conditionally acquire the thread-specific write lock (i.e., won't block). + int tryacquire (void); + + // = Utility methods. + + /// Dump the state of an object. + void dump (void) const; + + // ACE_ALLOC_HOOK_DECLARE; + // Declare the dynamic allocation hooks. +}; + +/** + * @class ACE_TSS_Read_Guard + * + * @brief This class is similar to class , though it + * acquires/releases a read lock automatically (naturally, the + * it is instantiated with must support the + * appropriate API). + */ +template +class ACE_TSS_Read_Guard : public ACE_TSS_Guard +{ +public: + // = Initialization method. + /// Implicitly and automatically acquire the thread-specific read lock. + ACE_TSS_Read_Guard (ACE_LOCK &lock, bool block = true); + + // = Lock accessors. + /// Explicitly acquire the thread-specific read lock. + int acquire_read (void); + + /// Explicitly acquire the thread-specific read lock. + int acquire (void); + + /// Conditionally acquire the thread-specific read lock (i.e., won't + /// block). + int tryacquire_read (void); + + /// Conditionally acquire the thread-specific read lock (i.e., won't + /// block). + int tryacquire (void); + + // = Utility methods. + /// Dump the state of an object. + void dump (void) const; + + // ACE_ALLOC_HOOK_DECLARE; + // Declare the dynamic allocation hooks. +}; + +#endif /* !(defined (ACE_HAS_THREADS) && (defined (ACE_HAS_THREAD_SPECIFIC_STORAGE) || defined (ACE_HAS_TSS_EMULATION))) */ + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +#include "ace/Guard_T.inl" +#endif /* __ACE_INLINE__ */ + +#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) +#include "ace/Guard_T.cpp" +#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ + +#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) +#pragma implementation ("Guard_T.cpp") +#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ + +#include /**/ "ace/post.h" +#endif /* ACE_GUARD_T_H */ diff --git a/dep/ACE_wrappers/ace/Guard_T.inl b/dep/ACE_wrappers/ace/Guard_T.inl new file mode 100644 index 00000000000..5fb22b3bac7 --- /dev/null +++ b/dep/ACE_wrappers/ace/Guard_T.inl @@ -0,0 +1,170 @@ +// -*- C++ -*- +// +// $Id: Guard_T.inl 82508 2008-08-05 13:52:48Z johnnyw $ + +#include "ace/RW_Thread_Mutex.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +template ACE_INLINE int +ACE_Guard::acquire (void) +{ + return this->owner_ = this->lock_->acquire (); +} + +template ACE_INLINE int +ACE_Guard::tryacquire (void) +{ + return this->owner_ = this->lock_->tryacquire (); +} + +template ACE_INLINE int +ACE_Guard::release (void) +{ + if (this->owner_ == -1) + return -1; + else + { + this->owner_ = -1; + return this->lock_->release (); + } +} + +template ACE_INLINE +ACE_Guard::ACE_Guard (ACE_LOCK &l) + : lock_ (&l), + owner_ (0) +{ + this->acquire (); +} + +template ACE_INLINE +ACE_Guard::ACE_Guard (ACE_LOCK &l, bool block) + : lock_ (&l), + owner_ (0) +{ + if (block) + this->acquire (); + else + this->tryacquire (); +} + +template ACE_INLINE +ACE_Guard::ACE_Guard (ACE_LOCK &l, bool /* block */, int become_owner) + : lock_ (&l), + owner_ (become_owner == 0 ? -1 : 0) +{ +} + +// Implicitly and automatically acquire (or try to acquire) the +// lock. + +template ACE_INLINE +ACE_Guard::~ACE_Guard (void) +{ + this->release (); +} + +template ACE_INLINE int +ACE_Guard::locked (void) const +{ + return this->owner_ != -1; +} + +template ACE_INLINE int +ACE_Guard::remove (void) +{ + return this->lock_->remove (); +} + +template ACE_INLINE void +ACE_Guard::disown (void) +{ + this->owner_ = -1; +} + +template ACE_INLINE +ACE_Write_Guard::ACE_Write_Guard (ACE_LOCK &m) + : ACE_Guard (&m) +{ + this->acquire_write (); +} + +template ACE_INLINE int +ACE_Write_Guard::acquire_write (void) +{ + return this->owner_ = this->lock_->acquire_write (); +} + +template ACE_INLINE int +ACE_Write_Guard::acquire (void) +{ + return this->owner_ = this->lock_->acquire_write (); +} + +template ACE_INLINE int +ACE_Write_Guard::tryacquire_write (void) +{ + return this->owner_ = this->lock_->tryacquire_write (); +} + +template ACE_INLINE int +ACE_Write_Guard::tryacquire (void) +{ + return this->owner_ = this->lock_->tryacquire_write (); +} + +template ACE_INLINE +ACE_Write_Guard::ACE_Write_Guard (ACE_LOCK &m, + bool block) + : ACE_Guard (&m) +{ + if (block) + this->acquire_write (); + else + this->tryacquire_write (); +} + +template ACE_INLINE int +ACE_Read_Guard::acquire_read (void) +{ + return this->owner_ = this->lock_->acquire_read (); +} + +template ACE_INLINE int +ACE_Read_Guard::acquire (void) +{ + return this->owner_ = this->lock_->acquire_read (); +} + +template ACE_INLINE int +ACE_Read_Guard::tryacquire_read (void) +{ + return this->owner_ = this->lock_->tryacquire_read (); +} + +template ACE_INLINE int +ACE_Read_Guard::tryacquire (void) +{ + return this->owner_ = this->lock_->tryacquire_read (); +} + +template ACE_INLINE +ACE_Read_Guard::ACE_Read_Guard (ACE_LOCK &m) + : ACE_Guard (&m) +{ + this->acquire_read (); +} + +template ACE_INLINE +ACE_Read_Guard::ACE_Read_Guard (ACE_LOCK &m, + bool block) + : ACE_Guard (&m) +{ + if (block) + this->acquire_read (); + else + this->tryacquire_read (); +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Handle_Gobbler.h b/dep/ACE_wrappers/ace/Handle_Gobbler.h new file mode 100644 index 00000000000..9d6890a03fc --- /dev/null +++ b/dep/ACE_wrappers/ace/Handle_Gobbler.h @@ -0,0 +1,68 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Handle_Gobbler.h + * + * $Id: Handle_Gobbler.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Kirthika Parameswaran + * @author Irfan Pyarali + */ +//============================================================================= + + +#ifndef ACE_HANDLE_GOBBLER_H +#define ACE_HANDLE_GOBBLER_H +#include /**/ "ace/pre.h" + +#include "ace/Handle_Set.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +/** + * @class ACE_Handle_Gobbler + * + * @brief This class gobbles up handles. + * + * This is useful when we need to control the number of handles + * available for a process. This class is mostly used for + * testing purposes. + */ +class ACE_Handle_Gobbler +{ +public: + + /// Destructor. Cleans up any remaining handles. + inline ~ACE_Handle_Gobbler (void); + + /** + * Handles are opened continously until the process runs out of + * them, and then handles are closed + * (freed) thereby making them usable in the future. + */ + inline int consume_handles (size_t n_handles_to_keep_available); + + /// Free up @a n_handles. + inline int free_handles (size_t n_handles); + + /// All remaining handles are closed. + inline void close_remaining_handles (void); + +private: + typedef ACE_Handle_Set HANDLE_SET; + + /// The container which holds the open descriptors. + HANDLE_SET handle_set_; +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#include "ace/Handle_Gobbler.inl" + +#include /**/ "ace/post.h" +#endif /* ACE_HANDLE_GOBBLER_H */ diff --git a/dep/ACE_wrappers/ace/Handle_Gobbler.inl b/dep/ACE_wrappers/ace/Handle_Gobbler.inl new file mode 100644 index 00000000000..4b81218e6de --- /dev/null +++ b/dep/ACE_wrappers/ace/Handle_Gobbler.inl @@ -0,0 +1,78 @@ +// -*- C++ -*- +// +// $Id: Handle_Gobbler.inl 80826 2008-03-04 14:51:23Z wotte $ + +// Since this is only included in Handle_Gobbler.h, these should be +// inline, not ACE_INLINE. +// FUZZ: disable check_for_inline + +#include "ace/OS_NS_unistd.h" +#include "ace/OS_NS_fcntl.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +inline void +ACE_Handle_Gobbler::close_remaining_handles (void) +{ + ACE_Handle_Set_Iterator iter (this->handle_set_); + for (ACE_HANDLE h = iter (); h != ACE_INVALID_HANDLE; h = iter ()) + ACE_OS::close (h); +} + +inline +ACE_Handle_Gobbler::~ACE_Handle_Gobbler (void) +{ + this->close_remaining_handles (); +} + +inline int +ACE_Handle_Gobbler::free_handles (size_t n_handles) +{ + ACE_Handle_Set_Iterator iter (this->handle_set_); + for (ACE_HANDLE h = iter (); + h != ACE_INVALID_HANDLE && n_handles > 0; + --n_handles, h = iter ()) + ACE_OS::close (h); + + return 0; +} + +inline int +ACE_Handle_Gobbler::consume_handles (size_t n_handles_to_keep_available) +{ + int result = 0; + +#if defined(ACE_WIN32) + // On Win32, this style of gobbling doesn't seem to work. + ACE_UNUSED_ARG(n_handles_to_keep_available); + +#else + + while (1) + { + ACE_HANDLE handle = ACE_OS::open (ACE_DEV_NULL, O_WRONLY); + + if (handle == ACE_INVALID_HANDLE) + { + if (ACE::out_of_handles (errno)) + { + result = this->free_handles (n_handles_to_keep_available); + break; + } + else + { + result = -1; + break; + } + } + if (handle >= FD_SETSIZE) + break; + this->handle_set_.set_bit (handle); + } + +#endif /* ACE_WIN32 */ + + return result; +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Handle_Ops.cpp b/dep/ACE_wrappers/ace/Handle_Ops.cpp new file mode 100644 index 00000000000..0ec856cf1c9 --- /dev/null +++ b/dep/ACE_wrappers/ace/Handle_Ops.cpp @@ -0,0 +1,48 @@ +// $Id: Handle_Ops.cpp 80826 2008-03-04 14:51:23Z wotte $ + +#include "ace/Handle_Ops.h" + +#include "ace/OS_NS_errno.h" +#include "ace/OS_NS_fcntl.h" +#include "ace/Time_Value.h" + +ACE_RCSID (ace, + Handle_Ops, + "$Id: Handle_Ops.cpp 80826 2008-03-04 14:51:23Z wotte $") + + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_HANDLE +ACE::handle_timed_open (ACE_Time_Value *timeout, + const ACE_TCHAR *name, + int flags, + int perms, + LPSECURITY_ATTRIBUTES sa) +{ + ACE_TRACE ("ACE::handle_timed_open"); + + if (timeout != 0) + { +#if !defined (ACE_WIN32) + // On Win32, ACE_NONBLOCK gets recognized as O_WRONLY so we + // don't use it there + flags |= ACE_NONBLOCK; +#endif /* ACE_WIN32 */ + + // Open the named pipe or file using non-blocking mode... + ACE_HANDLE const handle = ACE_OS::open (name, flags, perms, sa); + + if (handle == ACE_INVALID_HANDLE + && (errno == EWOULDBLOCK + && (timeout->sec () > 0 || timeout->usec () > 0))) + // This expression checks if we were polling. + errno = ETIMEDOUT; + + return handle; + } + else + return ACE_OS::open (name, flags, perms, sa); +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Handle_Ops.h b/dep/ACE_wrappers/ace/Handle_Ops.h new file mode 100644 index 00000000000..c615380f8dd --- /dev/null +++ b/dep/ACE_wrappers/ace/Handle_Ops.h @@ -0,0 +1,50 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Handle_Ops.h + * + * $Id: Handle_Ops.h 80826 2008-03-04 14:51:23Z wotte $ + * + * Handle operations. + */ +//============================================================================= + +#ifndef ACE_HANDLE_OPS_H +#define ACE_HANDLE_OPS_H + +#include /**/ "ace/pre.h" + +#include /**/ "ace/ACE_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/Global_Macros.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +class ACE_Time_Value; + +// = Operations on HANDLEs. +namespace ACE +{ + /** + * Wait up to @a timeout amount of time to actively open a device. + * This method doesn't perform the @c connect, it just does the + * timed wait. + */ + extern ACE_Export ACE_HANDLE handle_timed_open ( + ACE_Time_Value *timeout, + const ACE_TCHAR *name, + int flags, + int perms, + LPSECURITY_ATTRIBUTES sa = 0); +} + +ACE_END_VERSIONED_NAMESPACE_DECL + +#include /**/ "ace/post.h" + +#endif /* ACE_HANDLE_OPS_H */ diff --git a/dep/ACE_wrappers/ace/Handle_Set.cpp b/dep/ACE_wrappers/ace/Handle_Set.cpp new file mode 100644 index 00000000000..8eb5186cc21 --- /dev/null +++ b/dep/ACE_wrappers/ace/Handle_Set.cpp @@ -0,0 +1,570 @@ +// Handle_Set.cpp +// $Id: Handle_Set.cpp 80826 2008-03-04 14:51:23Z wotte $ + +#include "ace/Handle_Set.h" + +#if !defined (__ACE_INLINE__) +#include "ace/Handle_Set.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/OS_NS_string.h" + +ACE_RCSID(ace, Handle_Set, "$Id: Handle_Set.cpp 80826 2008-03-04 14:51:23Z wotte $") + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_ALLOC_HOOK_DEFINE(ACE_Handle_Set) + + // ACE_MSB_MASK is only used here. + // This needs to go here to avoid overflow problems on some compilers. +#if defined (ACE_WIN32) + // Does ACE_WIN32 have an fd_mask? +# define ACE_MSB_MASK (~(1 << (NFDBITS - 1))) +#else /* ! ACE_WIN32 */ +# define ACE_MSB_MASK (~((fd_mask) 1 << (NFDBITS - 1))) +#endif /* ! ACE_WIN32 */ + +#if defined (__BORLANDC__) && !defined (ACE_WIN32) +// The Borland C++ compiler on Linux also doesn't have fds_bits, but has __fds_bits. +#define fds_bits __fds_bits +#endif + +#if defined (linux) && __GLIBC__ > 1 && __GLIBC_MINOR__ >= 1 && !defined (_XOPEN_SOURCE) + // XPG4.2 requires the fds_bits member name, so it is not enabled by + // default on Linux/glibc-2.1.x systems. Instead use "__fds_bits." + // Ugly, but "what are you going to do?" 8-) +#define fds_bits __fds_bits +#endif /* linux && __GLIBC__ > 1 && __GLIBC_MINOR__ >= 1 && !_XOPEN_SOURCE */ + +void +ACE_Handle_Set::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + ACE_TRACE ("ACE_Handle_Set::dump"); + + ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); + + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nsize_ = %d"), this->size_)); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nmax_handle_ = %d"), this->max_handle_)); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\n[ "))); + +#if defined (ACE_WIN32) + for (size_t i = 0; i < (size_t) this->mask_.fd_count + 1; i++) + ACE_DEBUG ((LM_DEBUG, ACE_TEXT (" %x "), this->mask_.fd_array[i])); +#else /* !ACE_WIN32 */ + for (ACE_HANDLE i = 0; i < this->max_handle_ + 1; i++) + if (this->is_set (i)) + ACE_DEBUG ((LM_DEBUG, ACE_TEXT (" %d "), i)); +#endif /* ACE_WIN32 */ + + ACE_DEBUG ((LM_DEBUG, ACE_TEXT (" ]\n"))); + ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); +#endif /* ACE_HAS_DUMP */ +} + +// Table that maps bytes to counts of the enabled bits in each value +// from 0 to 255, +// +// nbits_[0] == 0 +// +// because there are no bits enabled for the value 0. +// +// nbits_[5] == 2 +// +// because there are 2 bits enabled in the value 5, i.e., it's +// 101 in binary. + +const char ACE_Handle_Set::nbits_[256] = +{ + 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4, + 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, + 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, + 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, + 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, + 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, + 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, + 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, + 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, + 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, + 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, + 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, + 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, + 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, + 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, + 4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8}; + +// Constructor, initializes the bitmask to all 0s. + +ACE_Handle_Set::ACE_Handle_Set (void) +{ + ACE_TRACE ("ACE_Handle_Set::ACE_Handle_Set"); + this->reset (); +} + +ACE_Handle_Set::ACE_Handle_Set (const fd_set &fd_mask) +{ + ACE_TRACE ("ACE_Handle_Set::ACE_Handle_Set"); + this->reset (); + ACE_OS::memcpy ((void *) &this->mask_, + (void *) &fd_mask, + sizeof this->mask_); +#if !defined (ACE_WIN32) + this->sync (ACE_Handle_Set::MAXSIZE); +#if defined (ACE_HAS_BIG_FD_SET) + this->min_handle_ = 0; +#endif /* ACE_HAS_BIG_FD_SET */ +#endif /* !ACE_WIN32 */ +} + +// Counts the number of bits enabled in N. Uses a table lookup to +// speed up the count. + +int +ACE_Handle_Set::count_bits (u_long n) +{ + + ACE_TRACE ("ACE_Handle_Set::count_bits"); +#if defined (ACE_HAS_HANDLE_SET_OPTIMIZED_FOR_SELECT) + register int rval = 0; + + // Count the number of enabled bits in . This algorithm is very + // fast, i.e., O(enabled bits in n). + + for (register u_long m = n; + m != 0; + m &= m - 1) + rval++; + + return rval; +#else + return (ACE_Handle_Set::nbits_[n & 0xff] + + ACE_Handle_Set::nbits_[(n >> 8) & 0xff] + + ACE_Handle_Set::nbits_[(n >> 16) & 0xff] + + ACE_Handle_Set::nbits_[(n >> 24) & 0xff]); +#endif /* ACE_HAS_HANDLE_SET_OPTIMIZED_FOR_SELECT */ +} + +#if defined (ACE_HAS_BIG_FD_SET) +// Find the bit position counting from right to left worst case +// (1<<31) is 8. + +int +ACE_Handle_Set::bitpos (u_long bit) +{ + register int l = 0; + register u_long n = bit - 1; + + // This is a fast count method when have the most significative bit. + + while (n >> 8) + { + n >>= 8; + l += 8; + } + + // Is greater than 15? + if (n & 16) + { + n >>= 4; + l += 4; + } + + // Count number remaining bits. + while (n != 0) + { + n &= n - 1; + l++; + } + return l; +} +#endif /* ACE_HAS_BIG_FD_SET */ + +// Synchronize the underlying FD_SET with the MAX_FD and the SIZE. + +#if defined (ACE_USE_SHIFT_FOR_EFFICIENCY) +// These don't work because shifting right 3 bits is not the same as +// dividing by 3, e.g., dividing by 8 requires shifting right 3 bits. +// In order to do the shift, we need to calculate the number of bits +// at some point. +#define ACE_DIV_BY_WORDSIZE(x) ((x) >> ((int) ACE_Handle_Set::WORDSIZE)) +#define ACE_MULT_BY_WORDSIZE(x) ((x) << ((int) ACE_Handle_Set::WORDSIZE)) +#else +#define ACE_DIV_BY_WORDSIZE(x) ((x) / ((int) ACE_Handle_Set::WORDSIZE)) +#define ACE_MULT_BY_WORDSIZE(x) ((x) * ((int) ACE_Handle_Set::WORDSIZE)) +#endif /* ACE_USE_SHIFT_FOR_EFFICIENCY */ + +void +ACE_Handle_Set::sync (ACE_HANDLE max) +{ + ACE_TRACE ("ACE_Handle_Set::sync"); +#if !defined (ACE_WIN32) + fd_mask *maskp = (fd_mask *)(this->mask_.fds_bits); + this->size_ = 0; + + for (int i = ACE_DIV_BY_WORDSIZE (max - 1); + i >= 0; + i--) + this->size_ += ACE_Handle_Set::count_bits (maskp[i]); + + this->set_max (max); +#else + ACE_UNUSED_ARG (max); +#endif /* !ACE_WIN32 */ +} + +// Resets the MAX_FD after a clear of the original MAX_FD. + +void +ACE_Handle_Set::set_max (ACE_HANDLE current_max) +{ + ACE_TRACE ("ACE_Handle_Set::set_max"); +#if !defined(ACE_WIN32) + fd_mask * maskp = (fd_mask *)(this->mask_.fds_bits); + + if (this->size_ == 0) + this->max_handle_ = ACE_INVALID_HANDLE; + else + { + int i; + + for (i = ACE_DIV_BY_WORDSIZE (current_max - 1); + maskp[i] == 0; + i--) + continue; +#if defined (ACE_TANDEM_NSK_BIT_ORDER) + // bits are in reverse order, MSB (sign bit) = bit 0. + this->max_handle_ = ACE_MULT_BY_WORDSIZE (i); + for (fd_mask val = maskp[i]; + (val & ACE_MSB_MASK) != 0; + val = (val << 1)) + ++this->max_handle_; +#elif 1 /* !defined(ACE_HAS_BIG_FD_SET) */ + this->max_handle_ = ACE_MULT_BY_WORDSIZE (i); + for (fd_mask val = maskp[i]; + (val & ~1) != 0; // This obscure code is needed since "bit 0" is in location 1... + val = (val >> 1) & ACE_MSB_MASK) + ++this->max_handle_; +#else + register u_long val = this->mask_.fds_bits[i]; + this->max_handle_ = ACE_MULT_BY_WORDSIZE (i) + + ACE_Handle_Set::bitpos(val & ~(val - 1)); +#endif /* 1 */ + } + + // Do some sanity checking... + if (this->max_handle_ >= ACE_Handle_Set::MAXSIZE) + this->max_handle_ = ACE_Handle_Set::MAXSIZE - 1; +#else + ACE_UNUSED_ARG (current_max); +#endif /* !ACE_WIN32 */ +} + +ACE_ALLOC_HOOK_DEFINE(ACE_Handle_Set_Iterator) + +void +ACE_Handle_Set_Iterator::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + ACE_TRACE ("ACE_Handle_Set_Iterator::dump"); + + ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); +#if defined(ACE_WIN32) || !defined(ACE_HAS_BIG_FD_SET) + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nhandle_index_ = %d"), this->handle_index_)); +#elif defined(ACE_HAS_BIG_FD_SET) + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nword_max_ = %d"), this->word_max_)); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nword_val_ = %d"), this->word_val_)); +#endif + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nword_num_ = %d"), this->word_num_)); + ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); +#endif /* ACE_HAS_DUMP */ +} + +ACE_HANDLE +ACE_Handle_Set_Iterator::operator () (void) +{ + ACE_TRACE ("ACE_Handle_Set_Iterator::operator"); +#if defined (ACE_WIN32) + if (this->handle_index_ < this->handles_.mask_.fd_count) + // Return the handle and advance the iterator. + return (ACE_HANDLE) this->handles_.mask_.fd_array[this->handle_index_++]; + else + return ACE_INVALID_HANDLE; + +#elif !defined (ACE_HAS_BIG_FD_SET) /* !ACE_WIN32 */ + // No sense searching further than the max_handle_ + 1; + ACE_HANDLE maxhandlep1 = this->handles_.max_handle_ + 1; + + // HP-UX 11 plays some games with the fd_mask type - fd_mask is + // defined as an int_32t, but the fds_bits is an array of longs. + // This makes plainly indexing through the array by hand tricky, + // since the FD_* macros treat the array as int32_t. So the bits + // are in the right place for int32_t, even though the array is + // long. This, they say, is to preserve the same in-memory layout + // for 32-bit and 64-bit processes. So, we play the same game as + // the FD_* macros to get the bits right. On all other systems, + // this amounts to practically a NOP, since this is what would have + // been done anyway, without all this type jazz. + fd_mask * maskp = (fd_mask *)(this->handles_.mask_.fds_bits); + + if (this->handle_index_ >= maxhandlep1) + // We've seen all the handles we're interested in seeing for this + // iterator. + return ACE_INVALID_HANDLE; + else + { + ACE_HANDLE result = this->handle_index_; + + // Increment the iterator and advance to the next bit in this + // word. + this->handle_index_++; +#if defined (ACE_TANDEM_NSK_BIT_ORDER) + // bits are in reverse order, MSB (sign bit) = bit 0. + this->word_val_ = (this->word_val_ << 1); +# else + this->word_val_ = (this->word_val_ >> 1) & ACE_MSB_MASK; +# endif /* ACE_TANDEM_NSK_BIT_ORDER */ + + // If we've examined all the bits in this word, we'll go onto + // the next word. + + if (this->word_val_ == 0) + { + // Start the handle_index_ at the beginning of the next word + // and then loop until we've found the first non-zero bit or + // we run past the of the bitset. + + for (this->handle_index_ = ACE_MULT_BY_WORDSIZE(++this->word_num_); + this->handle_index_ < maxhandlep1 + && maskp[this->word_num_] == 0; + this->word_num_++) + this->handle_index_ += ACE_Handle_Set::WORDSIZE; + + // If the bit index becomes >= the maxhandlep1 that means + // there weren't any more bits set that we want to consider. + // Therefore, we'll just store the maxhandlep1, which will + // cause to return + // immediately next time it's called. + if (this->handle_index_ >= maxhandlep1) + { + this->handle_index_ = maxhandlep1; + return result; + } + else + // Load the bits of the next word. + this->word_val_ = maskp[this->word_num_]; + } + + // Loop until we get to have its least significant + // bit enabled, keeping track of which this + // represents (this information is used by subsequent calls to + // ). + +#if defined (ACE_TANDEM_NSK_BIT_ORDER) + // bits are in reverse order, MSB (sign bit) = bit 0. + for (; + this->word_val_ > 0; + this->word_val_ = (this->word_val_ << 1)) + this->handle_index_++; +# else + for (; + ACE_BIT_DISABLED (this->word_val_, 1); + this->handle_index_++) + this->word_val_ = (this->word_val_ >> 1) & ACE_MSB_MASK; +# endif /* ACE_TANDEM_NSK_BIT_ORDER */ + + return result; + } +#else /* !ACE_HAS_BIG_FD_SET */ + // Find the first word in fds_bits with bit on + register u_long lsb = this->word_val_; + + if (lsb == 0) + { + do + { + // We have exceeded the word count in Handle_Set? + if (++this->word_num_ >= this->word_max_) + return ACE_INVALID_HANDLE; + + lsb = this->handles_.mask_.fds_bits[this->word_num_]; + } + while (lsb == 0); + + // Set index to word boundary. + this->handle_index_ = ACE_MULT_BY_WORDSIZE (this->word_num_); + + // Put new word_val. + this->word_val_ = lsb; + + // Find the least significative bit. + lsb &= ~(lsb - 1); + + // Remove least significative bit. + this->word_val_ ^= lsb; + + // Save to calculate bit distance. + this->oldlsb_ = lsb; + + // Move index to least significative bit. + while (lsb >>= 1) + this->handle_index_++; + } + else + { + // Find the least significative bit. + lsb &= ~(lsb - 1); + + // Remove least significative bit. + this->word_val_ ^= lsb; + + register u_long n = lsb - this->oldlsb_; + + // Move index to bit distance between new lsb and old lsb. + do + { + this->handle_index_++; + n &= n >> 1; + } + while (n != 0); + + this->oldlsb_ = lsb; + } + + return this->handle_index_; +#endif /* ACE_WIN32 */ +} + +ACE_Handle_Set_Iterator::ACE_Handle_Set_Iterator (const ACE_Handle_Set &hs) + : handles_ (hs), +#if !defined (ACE_HAS_BIG_FD_SET) || defined (ACE_WIN32) + handle_index_ (0), + word_num_ (-1) +#elif defined (ACE_HAS_BIG_FD_SET) + oldlsb_ (0), + word_max_ (hs.max_handle_ == ACE_INVALID_HANDLE + ? 0 + : ((ACE_DIV_BY_WORDSIZE (hs.max_handle_)) + 1)) +#endif /* ACE_HAS_BIG_FD_SET */ +{ + ACE_TRACE ("ACE_Handle_Set_Iterator::ACE_Handle_Set_Iterator"); +#if !defined (ACE_WIN32) && !defined (ACE_HAS_BIG_FD_SET) + // No sense searching further than the max_handle_ + 1; + ACE_HANDLE maxhandlep1 = + this->handles_.max_handle_ + 1; + + fd_mask *maskp = + (fd_mask *)(this->handles_.mask_.fds_bits); + + // Loop until we've found the first non-zero bit or we run past the + // of the bitset. + while (this->handle_index_ < maxhandlep1 + && maskp[++this->word_num_] == 0) + this->handle_index_ += ACE_Handle_Set::WORDSIZE; + + // If the bit index becomes >= the maxhandlep1 that means there + // weren't any bits set. Therefore, we'll just store the + // maxhandlep1, which will cause to return + // immediately. + if (this->handle_index_ >= maxhandlep1) + this->handle_index_ = maxhandlep1; + else + // Loop until we get to have its least significant bit + // enabled, keeping track of which this represents + // (this information is used by ). +#if defined (ACE_TANDEM_NSK_BIT_ORDER) + // bits are in reverse order, MSB (sign bit) = bit 0. + for (this->word_val_ = maskp[this->word_num_]; + this->word_val_ > 0; + this->word_val_ = (this->word_val_ << 1)) + this->handle_index_++; +# else + for (this->word_val_ = maskp[this->word_num_]; + ACE_BIT_DISABLED (this->word_val_, 1) + && this->handle_index_ < maxhandlep1; + this->handle_index_++) + this->word_val_ = (this->word_val_ >> 1) & ACE_MSB_MASK; +# endif /* ACE_TANDEM_NSK_BIT_ORDER */ +#elif !defined (ACE_WIN32) && defined (ACE_HAS_BIG_FD_SET) + if (this->word_max_==0) + { + this->word_num_ = -1; + this->word_val_ = 0; + } + else + { + this->word_num_ = + ACE_DIV_BY_WORDSIZE (this->handles_.min_handle_) - 1; + this->word_val_ = 0; + } +#endif /* !ACE_WIN32 && !ACE_HAS_BIG_FD_SET */ +} + + +void +ACE_Handle_Set_Iterator::reset_state (void) +{ + ACE_TRACE ("ACE_Handle_Set_Iterator::reset_state"); + +#if !defined (ACE_HAS_BIG_FD_SET) || defined (ACE_WIN32) + this->handle_index_ = 0; + this->word_num_ = -1; +#elif defined (ACE_HAS_BIG_FD_SET) + this->oldlsb_ = 0; + this->word_max_ = + this->handles_.max_handle_ == ACE_INVALID_HANDLE ? 0 + : ((ACE_DIV_BY_WORDSIZE (this->handles_.max_handle_)) + 1); +#endif /* ACE_HAS_BIG_FD_SET */ + +#if !defined (ACE_WIN32) && !defined (ACE_HAS_BIG_FD_SET) + // No sense searching further than the max_handle_ + 1; + ACE_HANDLE maxhandlep1 = + this->handles_.max_handle_ + 1; + + fd_mask *maskp = + (fd_mask *)(this->handles_.mask_.fds_bits); + + // Loop until we've found the first non-zero bit or we run past the + // of the bitset. + while (this->handle_index_ < maxhandlep1 + && maskp[++this->word_num_] == 0) + this->handle_index_ += ACE_Handle_Set::WORDSIZE; + + // If the bit index becomes >= the maxhandlep1 that means there + // weren't any bits set. Therefore, we'll just store the + // maxhandlep1, which will cause to return + // immediately. + if (this->handle_index_ >= maxhandlep1) + this->handle_index_ = maxhandlep1; + else + // Loop until we get to have its least significant bit + // enabled, keeping track of which this represents + // (this information is used by ). +#if defined (ACE_TANDEM_NSK_BIT_ORDER) + // bits are in reverse order, MSB (sign bit) = bit 0. + for (this->word_val_ = maskp[this->word_num_]; + this->word_val_ > 0; + this->word_val_ = (this->word_val_ << 1)) + this->handle_index_++; +# else + for (this->word_val_ = maskp[this->word_num_]; + ACE_BIT_DISABLED (this->word_val_, 1) + && this->handle_index_ < maxhandlep1; + this->handle_index_++) + this->word_val_ = (this->word_val_ >> 1) & ACE_MSB_MASK; +# endif /* ACE_TANDEM_NSK_BIT_ORDER */ +#elif !defined (ACE_WIN32) && defined (ACE_HAS_BIG_FD_SET) + if (this->word_max_==0) + { + this->word_num_ = -1; + this->word_val_ = 0; + } + else + { + this->word_num_ = + ACE_DIV_BY_WORDSIZE (this->handles_.min_handle_) - 1; + this->word_val_ = 0; + } +#endif /* !ACE_WIN32 && !ACE_HAS_BIG_FD_SET */ +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Handle_Set.h b/dep/ACE_wrappers/ace/Handle_Set.h new file mode 100644 index 00000000000..a2967222175 --- /dev/null +++ b/dep/ACE_wrappers/ace/Handle_Set.h @@ -0,0 +1,240 @@ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file Handle_Set.h + * + * $Id: Handle_Set.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Douglas C. Schmidt + */ +//============================================================================= + +#ifndef ACE_HANDLE_SET_H +#define ACE_HANDLE_SET_H +#include /**/ "ace/pre.h" + +#include /**/ "ace/ACE_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/os_include/sys/os_select.h" +#include "ace/os_include/os_limits.h" + +#if defined (__QNX__) + typedef long fd_mask; +#endif /* __QNX__ */ + +// Default size of the ACE Reactor. +#if defined (FD_SETSIZE) + int const ACE_FD_SETSIZE = FD_SETSIZE; +#else /* !FD_SETSIZE */ +# define ACE_FD_SETSIZE FD_SETSIZE +#endif /* ACE_FD_SETSIZE */ + +#if !defined (ACE_DEFAULT_SELECT_REACTOR_SIZE) +# define ACE_DEFAULT_SELECT_REACTOR_SIZE ACE_FD_SETSIZE +#endif /* ACE_DEFAULT_SELECT_REACTOR_SIZE */ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +/** + * @class ACE_Handle_Set + * + * @brief C++ wrapper facade for the socket @c fd_set abstraction. + * + * This abstraction is a very efficient wrapper facade over + * @c fd_set. In particular, no range checking is performed, so + * it's important not to set or clear bits that are outside the + * @c ACE_DEFAULT_SELECT_REACTOR_SIZE. + */ +class ACE_Export ACE_Handle_Set +{ +public: + friend class ACE_Handle_Set_Iterator; + + // = Initialization and termination. + + enum + { + MAXSIZE = ACE_DEFAULT_SELECT_REACTOR_SIZE + }; + + // = Initialization methods. + /// Constructor, initializes the bitmask to all 0s. + ACE_Handle_Set (void); + + /** + * Constructor, initializes the handle set from a given mask. + */ + ACE_Handle_Set (const fd_set &mask); + + // = Methods for manipulating bitsets. + /// Initialize the bitmask to all 0s and reset the associated fields. + void reset (void); + + /** + * Checks whether @a handle is enabled. No range checking is + * performed so @a handle must be less than + * @c ACE_DEFAULT_SELECT_REACTOR_SIZE. + */ + int is_set (ACE_HANDLE handle) const; + + /// Enables the @a handle. No range checking is performed so @a handle + /// must be less than @c ACE_DEFAULT_SELECT_REACTOR_SIZE. + void set_bit (ACE_HANDLE handle); + + /// Disables the @a handle. No range checking is performed so + /// @a handle must be less than @c ACE_DEFAULT_SELECT_REACTOR_SIZE. + void clr_bit (ACE_HANDLE handle); + + /// Returns a count of the number of enabled bits. + int num_set (void) const; + + /// Returns the number of the large bit. + ACE_HANDLE max_set (void) const; + + /** + * Rescan the underlying @c fd_set up to handle @a max to find the new + * (highest bit set) and (how many bits set) values. + * This is useful for evaluating the changes after the handle set has + * been manipulated in some way other than member functions; for example, + * after + ACE_Select_Reactor_Handle_Set dispatch_set_; + + /// Tracks handles that are waited for by . + ACE_Select_Reactor_Handle_Set ready_set_; + + /// Defined as a pointer to allow overriding by derived classes... + ACE_Timer_Queue *timer_queue_; + + /// Handle signals without requiring global/static variables. + ACE_Sig_Handler *signal_handler_; + + /// Callback object that unblocks the ACE_Select_Reactor if it's + /// sleeping. + ACE_Reactor_Notify *notify_handler_; + + /// Keeps track of whether we should delete the timer queue (if we + /// didn't create it, then we don't delete it). + bool delete_timer_queue_; + + /// Keeps track of whether we should delete the signal handler (if we + /// didn't create it, then we don't delete it). + bool delete_signal_handler_; + + /// Keeps track of whether we need to delete the notify handler (if + /// we didn't create it, then we don't delete it). + bool delete_notify_handler_; + + /// True if we've been initialized yet... + bool initialized_; + + /// Restart the event-loop method automatically when + /// . + + if (number_of_active_handles == 0) + { + do + { + if (this->timer_queue_ == 0) + return 0; + + this_timeout = + this->timer_queue_->calculate_timeout (max_wait_time, + &timer_buf); +#ifdef ACE_WIN32 + // This arg is ignored on Windows and causes pointer + // truncation warnings on 64-bit compiles. + int const width = 0; +#else + int const width = this->handler_rep_.max_handlep1 (); +#endif /* ACE_WIN32 */ + + dispatch_set.rd_mask_ = this->wait_set_.rd_mask_; + dispatch_set.wr_mask_ = this->wait_set_.wr_mask_; + dispatch_set.ex_mask_ = this->wait_set_.ex_mask_; + number_of_active_handles = ACE_OS::select (width, + dispatch_set.rd_mask_, + dispatch_set.wr_mask_, + dispatch_set.ex_mask_, + this_timeout); + } + while (number_of_active_handles == -1 && this->handle_error () > 0); + + if (number_of_active_handles > 0) + { +#if !defined (ACE_WIN32) + // Resynchronize the fd_sets so their "max" is set properly. + dispatch_set.rd_mask_.sync (this->handler_rep_.max_handlep1 ()); + dispatch_set.wr_mask_.sync (this->handler_rep_.max_handlep1 ()); + dispatch_set.ex_mask_.sync (this->handler_rep_.max_handlep1 ()); +#endif /* ACE_WIN32 */ + } + else if (number_of_active_handles == -1) + { + // Normally, select() will reset the bits in dispatch_set + // so that only those filed descriptors that are ready will + // have bits set. However, when an error occurs, the bit + // set remains as it was when the select call was first made. + // Thus, we now have a dispatch_set that has every file + // descriptor that was originally waited for, which is not + // correct. We must clear all the bit sets because we + // have no idea if any of the file descriptors is ready. + // + // NOTE: We dont have a test case to reproduce this + // problem. But pleae dont ignore this and remove it off. + dispatch_set.rd_mask_.reset (); + dispatch_set.wr_mask_.reset (); + dispatch_set.ex_mask_.reset (); + } + } + + // Return the number of events to dispatch. + return number_of_active_handles; +} + +template int +ACE_Select_Reactor_T::dispatch_timer_handlers + (int &number_of_handlers_dispatched) +{ + number_of_handlers_dispatched += this->timer_queue_->expire (); + + return 0; +} + +template int +ACE_Select_Reactor_T::dispatch_notification_handlers + (ACE_Select_Reactor_Handle_Set &dispatch_set, + int &number_of_active_handles, + int &number_of_handlers_dispatched) +{ + // Check to see if the ACE_HANDLE associated with the + // Select_Reactor's notify hook is enabled. If so, it means that + // one or more other threads are trying to update the + // ACE_Select_Reactor_T's internal tables or the notify pipe is + // enabled. We'll handle all these threads and notifications, and + // then break out to continue the event loop. + int const n = + this->notify_handler_->dispatch_notifications (number_of_active_handles, + dispatch_set.rd_mask_); + + if (n == -1) + return -1; + else + { + number_of_handlers_dispatched += n; + number_of_active_handles -= n; + } + + // Same as dispatch_timer_handlers + // No need to do anything with the state changed. That is because + // unbind already handles the case where someone unregister some + // kind of handle and unbind it. (::unbind calls the function + // state_changed () to reflect ant change with that) + // return this->state_changed_ ? -1 : 0; + return 0; +} + +template int +ACE_Select_Reactor_T::dispatch_io_set + (int number_of_active_handles, + int &number_of_handlers_dispatched, + int mask, + ACE_Handle_Set &dispatch_mask, + ACE_Handle_Set &ready_mask, + ACE_EH_PTMF callback) +{ + ACE_TRACE ("ACE_Select_Reactor_T::dispatch_io_set"); + ACE_HANDLE handle; + + ACE_Handle_Set_Iterator handle_iter (dispatch_mask); + + while ((handle = handle_iter ()) != ACE_INVALID_HANDLE && + number_of_handlers_dispatched < number_of_active_handles) + { + ++number_of_handlers_dispatched; + + this->notify_handle (handle, + mask, + ready_mask, + this->handler_rep_.find (handle), + callback); + + // clear the bit from that dispatch mask, + // so when we need to restart the iteration (rebuilding the iterator...) + // we will not dispatch the already dispatched handlers + this->clear_dispatch_mask (handle, mask); + + if (this->state_changed_) + { + + handle_iter.reset_state (); + this->state_changed_ = false; + } + } + + return 0; +} + +template int +ACE_Select_Reactor_T::dispatch_io_handlers + (ACE_Select_Reactor_Handle_Set &dispatch_set, + int &number_of_active_handles, + int &number_of_handlers_dispatched) +{ + ACE_TRACE ("ACE_Select_Reactor_T::dispatch_io_handlers"); + + // Handle output events (this code needs to come first to handle the + // obscure case of piggy-backed data coming along with the final + // handshake message of a nonblocking connection). + + if (this->dispatch_io_set (number_of_active_handles, + number_of_handlers_dispatched, + ACE_Event_Handler::WRITE_MASK, + dispatch_set.wr_mask_, + this->ready_set_.wr_mask_, + &ACE_Event_Handler::handle_output) == -1) + { + number_of_active_handles -= number_of_handlers_dispatched; + return -1; + } + + // ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("ACE_Select_Reactor_T::dispatch - EXCEPT\n"))); + if (this->dispatch_io_set (number_of_active_handles, + number_of_handlers_dispatched, + ACE_Event_Handler::EXCEPT_MASK, + dispatch_set.ex_mask_, + this->ready_set_.ex_mask_, + &ACE_Event_Handler::handle_exception) == -1) + { + number_of_active_handles -= number_of_handlers_dispatched; + return -1; + } + + // ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("ACE_Select_Reactor_T::dispatch - READ\n"))); + if (this->dispatch_io_set (number_of_active_handles, + number_of_handlers_dispatched, + ACE_Event_Handler::READ_MASK, + dispatch_set.rd_mask_, + this->ready_set_.rd_mask_, + &ACE_Event_Handler::handle_input) == -1) + { + number_of_active_handles -= number_of_handlers_dispatched; + return -1; + } + + number_of_active_handles -= number_of_handlers_dispatched; + return 0; +} + +template int +ACE_Select_Reactor_T::dispatch + (int active_handle_count, + ACE_Select_Reactor_Handle_Set &dispatch_set) +{ + ACE_TRACE ("ACE_Select_Reactor_T::dispatch"); + + int io_handlers_dispatched = 0; + int other_handlers_dispatched = 0; + int signal_occurred = 0; + // The following do/while loop keeps dispatching as long as there + // are still active handles. Note that the only way we should ever + // iterate more than once through this loop is if signals occur + // while we're dispatching other handlers. + + do + { + // We expect that the loop will decrease the number of active + // handles in each iteration. If it does not, then something is + // inconsistent in the state of the Reactor and we should avoid + // the loop. Please read the comments on bug 2540 for more + // details. + int initial_handle_count = active_handle_count; + + // Note that we keep track of changes to our state. If any of + // the dispatch_*() methods below return -1 it means that the + // state has changed as the result of an + // being dispatched. This means that we + // need to bail out and rerun the select() loop since our + // existing notion of handles in may no longer be + // correct. + // + // In the beginning, our state starts out unchanged. After + // every iteration (i.e., due to signals), our state starts out + // unchanged again. + + this->state_changed_ = false; + + // Perform the Template Method for dispatching all the handlers. + + // First check for interrupts. + if (active_handle_count == -1) + { + // Bail out -- we got here since /. Pass over both the *and* the + * @a mask to allow the caller to dictate which + * method the will invoke. The ACE_Time_Value + * indicates how long to blocking trying to notify the + * . If @a timeout == 0, the caller will block until + * action is possible, else will wait until the relative time + * specified in *@a timeout elapses). + */ + virtual int notify (ACE_Event_Handler * = 0, + ACE_Reactor_Mask = ACE_Event_Handler::EXCEPT_MASK, + ACE_Time_Value * = 0); + + /** + * Set the maximum number of times that the + * method will iterate and + * dispatch the that are passed in via the + * notify pipe before breaking out of its loop. By default, + * this is set to -1, which means "iterate until the pipe is empty." + * Setting this to a value like "1 or 2" will increase "fairness" + * (and thus prevent starvation) at the expense of slightly higher + * dispatching overhead. + */ + virtual void max_notify_iterations (int); + + /** + * Get the maximum number of times that the + * method will iterate and + * dispatch the that are passed in via the + * notify pipe before breaking out of its loop. + */ + virtual int max_notify_iterations (void); + + /// Get the existing restart value. + virtual int restart (void); + + /// Set a new value for restart and return the original value. + virtual int restart (int r); + + /// Set position that the main ACE_Select_Reactor thread is requeued in the + /// list of waiters during a callback. + virtual void requeue_position (int); + + /// Get position that the main ACE_Select_Reactor thread is requeued in the + /// list of waiters during a callback. + virtual int requeue_position (void); + + // = Low-level wait_set mask manipulation methods. + /// GET/SET/ADD/CLR the dispatch mask "bit" bound with the and + /// @a mask. + virtual int mask_ops (ACE_Event_Handler *eh, + ACE_Reactor_Mask mask, + int ops); + + /// GET/SET/ADD/CLR the dispatch MASK "bit" bound with the + /// and @a mask. + virtual int mask_ops (ACE_HANDLE handle, + ACE_Reactor_Mask mask, + int ops); + + // = Low-level ready_set mask manipulation methods. + /// GET/SET/ADD/CLR the ready "bit" bound with the and @a mask. + virtual int ready_ops (ACE_Event_Handler *eh, + ACE_Reactor_Mask mask, + int ops); + + /// GET/SET/ADD/CLR the ready "bit" bound with the and @a mask. + virtual int ready_ops (ACE_HANDLE handle, + ACE_Reactor_Mask, + int ops); + + /// Wake up all threads in waiting in the event loop + virtual void wakeup_all_threads (void); + + // = Only the owner thread can perform a . + + /// Set the new owner of the thread and return the old owner. + virtual int owner (ACE_thread_t n_id, ACE_thread_t *o_id = 0); + + /// Return the current owner of the thread. + virtual int owner (ACE_thread_t *); + + // = Miscellaneous Handler operations. + + /** + * Return the Event_Handler associated with . Return 0 if + * is not registered. + */ + virtual ACE_Event_Handler *find_handler (ACE_HANDLE handle); + + /** + * Check to see if is associated with a valid Event_Handler + * bound to @a mask. Return the @a eh associated with this @a handler + * if != 0. + */ + virtual int handler (ACE_HANDLE handle, + ACE_Reactor_Mask mask, + ACE_Event_Handler **eh = 0); + + /** + * Check to see if @a signum is associated with a valid Event_Handler + * bound to a signal. Return the associated with this + * handler if != 0. + */ + virtual int handler (int signum, + ACE_Event_Handler ** = 0); + + /// Returns true if we've been successfully initialized, else false. + virtual bool initialized (void); + + /// Returns the current size of the Reactor's internal descriptor + /// table. + virtual size_t size (void) const; + + /** + * Returns a reference to the ACE_Reactor_Token that is + * used to serialize the internal processing logic. + * This can be useful for situations where you need to avoid + * deadlock efficiently when ACE_Event_Handlers are used in + * multiple threads. + */ + virtual ACE_Lock &lock (void); + + /// Dump the state of an object. + virtual void dump (void) const; + + /// Declare the dynamic allocation hooks. + ACE_ALLOC_HOOK_DECLARE; + +protected: + // = Internal methods that do the actual work. + + // All of these methods assume that the token + // lock is held by the public methods that call down to them. + + /// Do the work of actually binding the and with the + /// @a mask. + virtual int register_handler_i (ACE_HANDLE handle, + ACE_Event_Handler *eh, + ACE_Reactor_Mask mask); + + /// Register a set of . + virtual int register_handler_i (const ACE_Handle_Set &handles, + ACE_Event_Handler *handler, + ACE_Reactor_Mask mask); + + /// Do the work of actually unbinding the and with the + /// @a mask. + virtual int remove_handler_i (ACE_HANDLE handle, + ACE_Reactor_Mask); + + /// Remove a set of . + virtual int remove_handler_i (const ACE_Handle_Set &handles, + ACE_Reactor_Mask); + + /// Suspend the associated with + virtual int suspend_i (ACE_HANDLE handle); + + /// Check to see if the associated with is + /// suspended. Returns 0 if not, 1 if so. + virtual int is_suspended_i (ACE_HANDLE handle); + + /// Resume the associated with + virtual int resume_i (ACE_HANDLE handle); + + /// Implement the public handler method. + virtual ACE_Event_Handler *find_handler_i (ACE_HANDLE handle); + + /// Implement the public handler method. + virtual int handler_i (ACE_HANDLE handle, + ACE_Reactor_Mask, + ACE_Event_Handler ** = 0); + + /// Implement the public handler method. + virtual int handler_i (int signum, ACE_Event_Handler ** = 0); + + /** + * Check if there are any HANDLEs enabled in the , and + * if so, update the and return the number ready. If + * there aren't any HANDLEs enabled return 0. + */ + virtual int any_ready (ACE_Select_Reactor_Handle_Set &handle_set); + + /// Implement the method, assuming that the Sig_Guard is + /// beign held + virtual int any_ready_i (ACE_Select_Reactor_Handle_Set &handle_set); + + /// Take corrective action when errors occur. + virtual int handle_error (void); + + /// Make sure the handles are all valid. + virtual int check_handles (void); + + /// Wait for events to occur. + virtual int wait_for_multiple_events (ACE_Select_Reactor_Handle_Set &, + ACE_Time_Value *); + + // = Dispatching methods. + + /** + * Template Method that dispatches ACE_Event_Handlers for time + * events, I/O events, and signal events. Returns the total number + * of ACE_Event_Handlers that were dispatched or -1 if something + * goes wrong. + */ + virtual int dispatch (int nfound, + ACE_Select_Reactor_Handle_Set &); + + /** + * Dispatch all timer handlers that have expired. Returns -1 if the + * state of the has changed, else 0. + * is set to the number of timer handlers + * dispatched. + */ + virtual int dispatch_timer_handlers (int &number_dispatched); + + /** + * Dispatch any notification handlers. Returns -1 if the state of + * the has changed, else returns number of handlers + * notified. + */ + virtual int dispatch_notification_handlers (ACE_Select_Reactor_Handle_Set &dispatch_set, + int &number_of_active_handles, + int &number_of_handlers_dispatched); + + /** + * Dispatch all the input/output/except handlers that are enabled in + * the . Updates and + * according to the behavior of the + * number Returns -1 if the state of the has changed, + * else 0. + */ + virtual int dispatch_io_handlers (ACE_Select_Reactor_Handle_Set &dispatch_set, + int &number_of_active_handles, + int &number_of_handlers_dispatched); + + /** + * Factors the dispatching of an io handle set (each WRITE, EXCEPT + * or READ set of handles). It updates the + * and invokes this->notify_handle + * for all the handles in using the @a mask, + * and parameters. Must return -1 if + * this->state_changed otherwise it must return 0. + */ + virtual int dispatch_io_set (int number_of_active_handles, + int &number_of_handlers_dispatched, + int mask, + ACE_Handle_Set& dispatch_mask, + ACE_Handle_Set& ready_mask, + ACE_EH_PTMF callback); + + /// Notify the appropriate in the context of the + /// associated with that a particular event has occurred. + virtual void notify_handle (ACE_HANDLE handle, + ACE_Reactor_Mask mask, + ACE_Handle_Set &, + ACE_Event_Handler *eh, + ACE_EH_PTMF callback); + + /// Enqueue ourselves into the list of waiting threads at the + /// appropriate point specified by . + virtual void renew (void); + + /// Synchronization token for the MT_SAFE ACE_Select_Reactor. + ACE_SELECT_REACTOR_TOKEN token_; + + /// Adapter used to return internal lock to outside world. + ACE_Lock_Adapter lock_adapter_; + + /// Release the token lock when a Win32 structured exception occurs. + int release_token (void); + + /// Stops the VC++ compiler from bitching about exceptions and destructors + int handle_events_i (ACE_Time_Value *max_wait_time = 0); + + /// This flag is used to keep track of whether we are actively handling + /// events or not. + sig_atomic_t deactivated_; + +private: + /// Deny access since member-wise won't work... + ACE_UNIMPLEMENTED_FUNC (ACE_Select_Reactor_T (const ACE_Select_Reactor_T &)) + ACE_UNIMPLEMENTED_FUNC (ACE_Select_Reactor_T &operator= (const ACE_Select_Reactor_T &) ) +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +#include "ace/Select_Reactor_T.inl" +#endif /* __ACE_INLINE__ */ + +#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) +#include "ace/Select_Reactor_T.cpp" +#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ + +#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) +#pragma implementation ("Select_Reactor_T.cpp") +#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ + +#include /**/ "ace/post.h" +#endif /* ACE_SELECT_REACTOR_T_H */ diff --git a/dep/ACE_wrappers/ace/Select_Reactor_T.inl b/dep/ACE_wrappers/ace/Select_Reactor_T.inl new file mode 100644 index 00000000000..05405a5b17b --- /dev/null +++ b/dep/ACE_wrappers/ace/Select_Reactor_T.inl @@ -0,0 +1,236 @@ +// -*- C++ -*- +// +// $Id: Select_Reactor_T.inl 80826 2008-03-04 14:51:23Z wotte $ + +#include "ace/Reactor.h" +#include "ace/Signal.h" +#include "ace/Sig_Handler.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +template +ACE_INLINE int +ACE_Select_Reactor_T::resume_handler (ACE_Event_Handler *h) +{ + ACE_TRACE ("ACE_Select_Reactor_T::resume_handler"); + return this->resume_handler (h->get_handle ()); +} + +template +ACE_INLINE int +ACE_Select_Reactor_T::resume_handler (const ACE_Handle_Set &handles) +{ + ACE_TRACE ("ACE_Select_Reactor_T::resume_handler"); + ACE_Handle_Set_Iterator handle_iter (handles); + ACE_HANDLE h; + + ACE_MT (ACE_GUARD_RETURN (ACE_SELECT_REACTOR_TOKEN, ace_mon, this->token_, -1)); + + while ((h = handle_iter ()) != ACE_INVALID_HANDLE) + if (this->resume_i (h) == -1) + return -1; + + return 0; +} + +template +ACE_INLINE int +ACE_Select_Reactor_T::suspend_handler (ACE_Event_Handler *h) +{ + ACE_TRACE ("ACE_Select_Reactor_T::suspend_handler"); + return this->suspend_handler (h->get_handle ()); +} + +template +ACE_INLINE int +ACE_Select_Reactor_T::suspend_handler (const ACE_Handle_Set &handles) +{ + ACE_TRACE ("ACE_Select_Reactor_T::suspend_handler"); + ACE_Handle_Set_Iterator handle_iter (handles); + ACE_HANDLE h; + + ACE_MT (ACE_GUARD_RETURN (ACE_SELECT_REACTOR_TOKEN, ace_mon, this->token_, -1)); + + while ((h = handle_iter ()) != ACE_INVALID_HANDLE) + if (this->suspend_i (h) == -1) + return -1; + + return 0; +} + +template +ACE_INLINE int +ACE_Select_Reactor_T::register_handler (int signum, + ACE_Event_Handler *new_sh, + ACE_Sig_Action *new_disp, + ACE_Event_Handler **old_sh, + ACE_Sig_Action *old_disp) +{ + ACE_TRACE ("ACE_Select_Reactor_T::register_handler"); + return this->signal_handler_->register_handler (signum, + new_sh, new_disp, + old_sh, old_disp); +} + +#if defined (ACE_WIN32) + +template +ACE_INLINE int +ACE_Select_Reactor_T::register_handler (ACE_Event_Handler *, + ACE_HANDLE ) +{ + // Don't have an implementation for this yet... + ACE_NOTSUP_RETURN (-1); +} + +#endif /* ACE_WIN32 */ + +template +ACE_INLINE int +ACE_Select_Reactor_T::register_handler (ACE_HANDLE , + ACE_HANDLE , + ACE_Event_Handler *, + ACE_Reactor_Mask ) +{ + // Don't have an implementation for this yet... + ACE_NOTSUP_RETURN (-1); +} + +template +ACE_INLINE int +ACE_Select_Reactor_T::handler (int signum, ACE_Event_Handler **handler) +{ + ACE_TRACE ("ACE_Select_Reactor_T::handler"); + return this->handler_i (signum, handler); +} + +template +ACE_INLINE int +ACE_Select_Reactor_T::remove_handler (int signum, + ACE_Sig_Action *new_disp, + ACE_Sig_Action *old_disp, + int sigkey) +{ + ACE_TRACE ("ACE_Select_Reactor_T::remove_handler"); + return this->signal_handler_->remove_handler (signum, new_disp, old_disp, sigkey); +} + +template +ACE_INLINE int +ACE_Select_Reactor_T::uses_event_associations (void) +{ + // Since the Select_Reactor does not do any event associations, this + // function always return 0. + return 0; +} + +// = The remaining methods in this file must be called with locks +// held. + +// Performs operations on the "ready" bits. + +template ACE_INLINE int +ACE_Select_Reactor_T::ready_ops (ACE_Event_Handler *handler, + ACE_Reactor_Mask mask, + int ops) +{ + ACE_TRACE ("ACE_Select_Reactor_T::ready_ops"); + return this->ready_ops (handler->get_handle (), mask, ops); +} + +// Performs operations on the "dispatch" masks. + +template ACE_INLINE int +ACE_Select_Reactor_T::mask_ops (ACE_Event_Handler *handler, + ACE_Reactor_Mask mask, + int ops) +{ + ACE_TRACE ("ACE_Select_Reactor_T::mask_ops"); + return this->mask_ops (handler->get_handle (), mask, ops); +} + +template ACE_INLINE int +ACE_Select_Reactor_T::schedule_wakeup (ACE_Event_Handler *eh, + ACE_Reactor_Mask mask) +{ + ACE_TRACE ("ACE_Select_Reactor_T::schedule_wakeup"); + return this->mask_ops (eh->get_handle (), mask, ACE_Reactor::ADD_MASK); +} + +template ACE_INLINE int +ACE_Select_Reactor_T::cancel_wakeup (ACE_Event_Handler *eh, + ACE_Reactor_Mask mask) +{ + ACE_TRACE ("ACE_Select_Reactor_T::cancel_wakeup"); + return this->mask_ops (eh->get_handle (), mask, ACE_Reactor::CLR_MASK); +} + +template ACE_INLINE int +ACE_Select_Reactor_T::schedule_wakeup (ACE_HANDLE handle, + ACE_Reactor_Mask mask) +{ + ACE_TRACE ("ACE_Select_Reactor_T::schedule_wakeup"); + return this->mask_ops (handle, mask, ACE_Reactor::ADD_MASK); +} + +template ACE_INLINE int +ACE_Select_Reactor_T::cancel_wakeup (ACE_HANDLE handle, + ACE_Reactor_Mask mask) +{ + ACE_TRACE ("ACE_Select_Reactor_T::cancel_wakeup"); + return this->mask_ops (handle, mask, ACE_Reactor::CLR_MASK); +} + +template ACE_INLINE ACE_Lock & +ACE_Select_Reactor_T::lock (void) +{ + ACE_TRACE ("ACE_Select_Reactor_T::lock"); + return this->lock_adapter_; +} + +template ACE_INLINE void +ACE_Select_Reactor_T::wakeup_all_threads (void) +{ + // Send a notification, but don't block if there's no one to receive + // it. + this->notify (0, ACE_Event_Handler::NULL_MASK, (ACE_Time_Value *) &ACE_Time_Value::zero); +} + +template ACE_INLINE int +ACE_Select_Reactor_T::alertable_handle_events (ACE_Time_Value *max_wait_time) +{ + return this->handle_events (max_wait_time); +} + +template ACE_INLINE int +ACE_Select_Reactor_T::alertable_handle_events (ACE_Time_Value &max_wait_time) +{ + return this->handle_events (max_wait_time); +} + +template ACE_INLINE int +ACE_Select_Reactor_T::deactivated (void) +{ + return this->deactivated_; +} + +template ACE_INLINE void +ACE_Select_Reactor_T::deactivate (int do_stop) +{ + { + ACE_MT (ACE_GUARD (ACE_SELECT_REACTOR_TOKEN, + ace_mon, + this->token_)); + this->deactivated_ = do_stop; + } + + this->wakeup_all_threads (); +} + +template ACE_INLINE size_t +ACE_Select_Reactor_T::size (void) const +{ + return this->handler_rep_.size (); +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Semaphore.cpp b/dep/ACE_wrappers/ace/Semaphore.cpp new file mode 100644 index 00000000000..b3d6c6638ff --- /dev/null +++ b/dep/ACE_wrappers/ace/Semaphore.cpp @@ -0,0 +1,62 @@ +// $Id: Semaphore.cpp 80826 2008-03-04 14:51:23Z wotte $ + +#include "ace/Semaphore.h" + +#if !defined (__ACE_INLINE__) +#include "ace/Semaphore.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/Log_Msg.h" +#include "ace/ACE.h" + +ACE_RCSID (ace, + Semaphore, + "$Id: Semaphore.cpp 80826 2008-03-04 14:51:23Z wotte $") + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_ALLOC_HOOK_DEFINE(ACE_Semaphore) + +void +ACE_Semaphore::dump (void) const +{ +// ACE_TRACE ("ACE_Semaphore::dump"); + + ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\n"))); + ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); +} + +ACE_Semaphore::ACE_Semaphore (unsigned int count, + int type, + const ACE_TCHAR *name, + void *arg, + int max) + : removed_ (false) +{ +// ACE_TRACE ("ACE_Semaphore::ACE_Semaphore"); +#if defined(ACE_LACKS_UNNAMED_SEMAPHORE) +// if the user does not provide a name, we generate a unique name here + ACE_TCHAR iname[ACE_UNIQUE_NAME_LEN]; + if (name == 0) + ACE::unique_name (this, iname, ACE_UNIQUE_NAME_LEN); + if (ACE_OS::sema_init (&this->semaphore_, count, type, + name ? name : iname, + arg, max) != 0) +#else + if (ACE_OS::sema_init (&this->semaphore_, count, type, + name, arg, max) != 0) +#endif + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("%p\n"), + ACE_TEXT ("ACE_Semaphore::ACE_Semaphore"))); +} + +ACE_Semaphore::~ACE_Semaphore (void) +{ +// ACE_TRACE ("ACE_Semaphore::~ACE_Semaphore"); + + this->remove (); +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Semaphore.h b/dep/ACE_wrappers/ace/Semaphore.h new file mode 100644 index 00000000000..7c4936abfd3 --- /dev/null +++ b/dep/ACE_wrappers/ace/Semaphore.h @@ -0,0 +1,183 @@ +// -*- C++ -*- + +//========================================================================== +/** + * @file Semaphore.h + * + * $Id: Semaphore.h 81014 2008-03-19 11:41:31Z johnnyw $ + * + * Moved from Synch.h. + * + * @author Douglas C. Schmidt + */ +//========================================================================== + +#ifndef ACE_SEMAPHORE_H +#define ACE_SEMAPHORE_H +#include /**/ "ace/pre.h" + +#include /**/ "ace/ACE_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/OS_NS_Thread.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +class ACE_Time_Value; + +/** + * @class ACE_Semaphore + * + * @brief Wrapper for Dijkstra style general semaphores. + */ +class ACE_Export ACE_Semaphore +{ +public: + // = Initialization and termination. + /// Initialize the semaphore, with initial value of "count". + ACE_Semaphore (unsigned int count = 1, // By default make this unlocked. + int type = USYNC_THREAD, + const ACE_TCHAR *name = 0, + void * = 0, + int max = 0x7fffffff); + + /// Implicitly destroy the semaphore. + ~ACE_Semaphore (void); + + /** + * Explicitly destroy the semaphore. Note that only one thread + * should call this method since it doesn't protect against race + * conditions. + */ + int remove (void); + + /// Block the thread until the semaphore count becomes + /// greater than 0, then decrement it. + int acquire (void); + + /** + * Block the thread until the semaphore count becomes greater than 0 + * (at which point it is decremented) or until @a tv times out (in + * which case -1 is returned and @c errno == @c ETIME). Note that @a tv + * is assumed to be in "absolute" rather than "relative" time. The + * value of @a tv is updated upon return to show the actual + * (absolute) acquisition time. + * + * @note Solaris threads do not support timed semaphores. + * Therefore, if you're running on Solaris you might want to + * consider using the ACE POSIX pthreads implementation instead, + * which can be enabled by compiling ACE with + * -DACE_HAS_PTHREADS, rather than -DACE_HAS_STHREADS or + * -DACE_HAS_POSIX_SEM. + */ + int acquire (ACE_Time_Value &tv); + + /** + * If @a tv == 0 then call directly. Otherwise, Block + * the thread until the semaphore count becomes greater than 0 + * (at which point it is decremented) or until @a tv times out (in + * which case -1 is returned and @c errno == @c ETIME). Note that + * <*tv> is assumed to be in "absolute" rather than "relative" time. + * The value of <*tv> is updated upon return to show the actual + * (absolute) acquisition time. + * + * @note Solaris threads do not support timed semaphores. + * Therefore, if you're running on Solaris you might want to + * consider using the ACE POSIX pthreads implementation instead, + * which can be enabled by compiling ACE with + * -DACE_HAS_PTHREADS, rather than -DACE_HAS_STHREADS or + * -DACE_HAS_POSIX_SEM. */ + int acquire (ACE_Time_Value *tv); + + /** + * Conditionally decrement the semaphore if count is greater than 0 + * (i.e., won't block). Returns -1 on failure. If we "failed" + * because someone else already had the lock, @c errno is set to + * @c EBUSY. + */ + int tryacquire (void); + + /// Increment the semaphore by 1, potentially unblocking a waiting + /// thread. + int release (void); + + /// Increment the semaphore by @a release_count, potentially + /// unblocking waiting threads. + int release (unsigned int release_count); + + /** + * Acquire semaphore ownership. This calls and is only + * here to make the ACE_Semaphore interface consistent with the + * other synchronization APIs. + */ + int acquire_read (void); + + /** + * Acquire semaphore ownership. This calls and is only + * here to make the ACE_Semaphore interface consistent with the + * other synchronization APIs. + */ + int acquire_write (void); + + /** + * Conditionally acquire semaphore (i.e., won't block). This calls + * and is only here to make the ACE_Semaphore + * interface consistent with the other synchronization APIs. + * Returns -1 on failure. If we "failed" because someone else + * already had the lock, @c errno is set to @c EBUSY. + */ + int tryacquire_read (void); + + /** + * Conditionally acquire semaphore (i.e., won't block). This calls + * and is only here to make the ACE_Semaphore + * interface consistent with the other synchronization APIs. + * Returns -1 on failure. If we "failed" because someone else + * already had the lock, @c errno is set to @c EBUSY. + */ + int tryacquire_write (void); + + /** + * This is only here to make the ACE_Semaphore + * interface consistent with the other synchronization APIs. + * Assumes the caller has already acquired the semaphore using one of + * the above calls, and returns 0 (success) always. + */ + int tryacquire_write_upgrade (void); + + /// Dump the state of an object. + void dump (void) const; + + /// Declare the dynamic allocation hooks. + ACE_ALLOC_HOOK_DECLARE; + + /// Return the underlying lock. + const ACE_sema_t &lock (void) const; + +protected: + ACE_sema_t semaphore_; + + /// Keeps track of whether remove() has been called yet to avoid + /// multiple remove() calls, e.g., explicitly and implicitly in the + /// destructor. This flag isn't protected by a lock, so make sure + /// that you don't have multiple threads simultaneously calling + /// remove () on the same object, which is a bad idea anyway... + bool removed_; + +private: + // = Prevent assignment and initialization. + void operator= (const ACE_Semaphore &); + ACE_Semaphore (const ACE_Semaphore &); +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +#include "ace/Semaphore.inl" +#endif /* __ACE_INLINE__ */ + +#include /**/ "ace/post.h" +#endif /* ACE_SEMAPHORE_H */ diff --git a/dep/ACE_wrappers/ace/Semaphore.inl b/dep/ACE_wrappers/ace/Semaphore.inl new file mode 100644 index 00000000000..e0162dc247b --- /dev/null +++ b/dep/ACE_wrappers/ace/Semaphore.inl @@ -0,0 +1,119 @@ +// -*- C++ -*- +// +// $Id: Semaphore.inl 80826 2008-03-04 14:51:23Z wotte $ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_INLINE const ACE_sema_t & +ACE_Semaphore::lock (void) const +{ +// ACE_TRACE ("ACE_Semaphore::lock"); + return this->semaphore_; +} + +ACE_INLINE int +ACE_Semaphore::remove (void) +{ +// ACE_TRACE ("ACE_Semaphore::remove"); + int result = 0; + if (!this->removed_) + { + this->removed_ = true; + result = ACE_OS::sema_destroy (&this->semaphore_); + } + return result; +} + +ACE_INLINE int +ACE_Semaphore::acquire (void) +{ +// ACE_TRACE ("ACE_Semaphore::acquire"); + return ACE_OS::sema_wait (&this->semaphore_); +} + +ACE_INLINE int +ACE_Semaphore::acquire (ACE_Time_Value &tv) +{ +// ACE_TRACE ("ACE_Semaphore::acquire"); + return ACE_OS::sema_wait (&this->semaphore_, tv); +} + +ACE_INLINE int +ACE_Semaphore::acquire (ACE_Time_Value *tv) +{ +// ACE_TRACE ("ACE_Semaphore::acquire"); + return ACE_OS::sema_wait (&this->semaphore_, tv); +} + +ACE_INLINE int +ACE_Semaphore::tryacquire (void) +{ +// ACE_TRACE ("ACE_Semaphore::tryacquire"); + return ACE_OS::sema_trywait (&this->semaphore_); +} + +ACE_INLINE int +ACE_Semaphore::release (void) +{ +// ACE_TRACE ("ACE_Semaphore::release"); + return ACE_OS::sema_post (&this->semaphore_); +} + +ACE_INLINE int +ACE_Semaphore::release (unsigned int release_count) +{ +// ACE_TRACE ("ACE_Semaphore::release"); + return ACE_OS::sema_post (&this->semaphore_, release_count); +} + +// Acquire semaphore ownership. This calls and is only +// here to make the interface consistent with the +// other synchronization APIs. + +ACE_INLINE int +ACE_Semaphore::acquire_read (void) +{ + return this->acquire (); +} + +// Acquire semaphore ownership. This calls and is only +// here to make the interface consistent with the +// other synchronization APIs. + +ACE_INLINE int +ACE_Semaphore::acquire_write (void) +{ + return this->acquire (); +} + +// Conditionally acquire semaphore (i.e., won't block). This calls +// and is only here to make the +// interface consistent with the other synchronization APIs. + +ACE_INLINE int +ACE_Semaphore::tryacquire_read (void) +{ + return this->tryacquire (); +} + +// Conditionally acquire semaphore (i.e., won't block). This calls +// and is only here to make the +// interface consistent with the other synchronization APIs. + +ACE_INLINE int +ACE_Semaphore::tryacquire_write (void) +{ + return this->tryacquire (); +} + +// This is only here to make the interface consistent +// with the other synchronization APIs. Assumes the caller has +// already acquired the semaphore using one of the above calls, and +// returns 0 (success) always. +ACE_INLINE int +ACE_Semaphore::tryacquire_write_upgrade (void) +{ + return 0; +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Service_Config.cpp b/dep/ACE_wrappers/ace/Service_Config.cpp new file mode 100644 index 00000000000..f0f352cedcb --- /dev/null +++ b/dep/ACE_wrappers/ace/Service_Config.cpp @@ -0,0 +1,619 @@ +// $Id: Service_Config.cpp 81756 2008-05-22 09:47:33Z johnnyw $ + +#include "ace/Service_Config.h" + +#if !defined (__ACE_INLINE__) +#include "ace/Service_Config.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/Service_Types.h" +#include "ace/Reactor.h" +#include "ace/Singleton.h" +#include "ace/Service_Repository.h" + +#ifndef ACE_LACKS_UNIX_SIGNALS +# include "ace/Sig_Adapter.h" +#endif /* !ACE_LACKS_UNIX_SIGNALS */ + +#include "ace/OS_NS_time.h" +#include "ace/OS_NS_stdio.h" +#include "ace/OS_NS_unistd.h" +#include "ace/Thread.h" +#include "ace/Get_Opt.h" +#include "ace/ARGV.h" +#include "ace/Log_Msg.h" +#include "ace/ACE.h" + +ACE_RCSID (ace, + Service_Config, + "$Id: Service_Config.cpp 81756 2008-05-22 09:47:33Z johnnyw $") + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_Threading_Helper::~ACE_Threading_Helper () +{ + ACE_OS::thr_key_detach (this->key_, 0); + ACE_OS::thr_keyfree (this->key_); +} + +ACE_Threading_Helper::ACE_Threading_Helper () + : key_ (ACE_OS::NULL_key) +{ +# if defined (ACE_HAS_TSS_EMULATION) + ACE_Object_Manager::init_tss (); +# endif + + if (ACE_Thread::keycreate (&key_, 0, 0) == -1) + { + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("(%P|%t) Failed to create thread key: %p\n"), + "")); + } +} + +void +ACE_Threading_Helper::set (void* p) +{ + if (ACE_Thread::setspecific (key_, p) == -1) + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("(%P|%t) Service Config failed to set thread key value: %p\n"), + "")); +} + +void* +ACE_Threading_Helper::get (void) +{ + void* temp = 0; + if (ACE_Thread::getspecific (key_, &temp) == -1) + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("(%P|%t) Service Config failed to get thread key value: %p\n"), + ""), + 0); + return temp; +} + +ACE_Threading_Helper::~ACE_Threading_Helper () +{ +} + +ACE_Threading_Helper::ACE_Threading_Helper () +{ +} + +void +ACE_Threading_Helper::set (void*) +{ +} + +void* +ACE_Threading_Helper::get (void) +{ + return ACE_Service_Config::singleton()->instance_.get (); +} + +/** + * @c ACE_Service_Config is supposed to be a Singleton. This is the + * only Configuration Gestalt available for access from static + * initializers at proces start-up time. Using Unmanaged Singleton + * is safer because (a) the Object Manager may not yet be fully initialized + * in the context of a static initializer that uses SC, and (b) because we + * know that upon process exit the SC will still be automaticaly and explicitly + * closed by @c ACE_Object_Manager::fini(). + */ +typedef ACE_Unmanaged_Singleton ACE_SERVICE_CONFIG_SINGLETON; + + +/// ctor +ACE_Service_Config_Guard::ACE_Service_Config_Guard (ACE_Service_Gestalt * psg) + : saved_ (ACE_Service_Config::current ()) +{ + if (ACE::debug ()) + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("ACE (%P|%t) SCG:") + ACE_TEXT (" - config=%@ repo=%@ superceded by repo=%@\n"), + this, + this->saved_.get (), + this->saved_->repo_, + psg->repo_)); + + // Modify the TSS if the repo has changed + ACE_Service_Config::current (psg); +} + +ACE_Service_Config_Guard::~ACE_Service_Config_Guard (void) +{ + ACE_Service_Gestalt* s = this->saved_.get (); + ACE_ASSERT (s != 0); + + ACE_Service_Config::current (s); + + if (ACE::debug ()) + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("ACE (%P|%t) SCG:") + ACE_TEXT (" - new repo=%@\n"), + this, + this->saved_->repo_)); +} + + +ACE_ALLOC_HOOK_DEFINE (ACE_Service_Config) + +// Set the signal handler to point to the handle_signal() function. +ACE_Sig_Adapter *ACE_Service_Config::signal_handler_ = 0; + +// Trigger a reconfiguration. +sig_atomic_t ACE_Service_Config::reconfig_occurred_ = 0; + +// = Set by command-line options. + +/// Pathname of file to write process id. +ACE_TCHAR *ACE_Service_Config::pid_file_name_ = 0; + +/// Shall we become a daemon process? +bool ACE_Service_Config::be_a_daemon_ = false; + +/// Number of the signal used to trigger reconfiguration. +int ACE_Service_Config::signum_ = SIGHUP; + +void +ACE_Service_Config::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + ACE_TRACE ("ACE_Service_Config::dump"); +#endif /* ACE_HAS_DUMP */ +} + +int +ACE_Service_Config::parse_args_i (int argc, ACE_TCHAR *argv[]) +{ + ACE_TRACE ("ACE_Service_Config::parse_args_i"); + + // Using PERMUTE_ARGS (default) in order to have all + // unrecognized options and their value arguments moved + // to the end of the argument vector. We'll pick them up + // after processing our options and pass them on to the + // base class for further parsing. + //FUZZ: disable check_for_lack_ACE_OS + ACE_Get_Opt getopt (argc, + argv, + ACE_TEXT ("bs:p:"), + 1 , // Start at argv[1]. + 0, // Do not report errors + ACE_Get_Opt::RETURN_IN_ORDER); + //FUZZ: enable check_for_lack_ACE_OS + + // Keep a list of all unknown arguments, begin with the + // executable's name + ACE_ARGV superargv; + superargv.add (argv[0]); + + //FUZZ: disable check_for_lack_ACE_OS + for (int c; (c = getopt ()) != -1; ) + //FUZZ: enable check_for_lack_ACE_OS + switch (c) + { + case 'p': + ACE_Service_Config::pid_file_name_ = getopt.opt_arg (); + break; + case 'b': + ACE_Service_Config::be_a_daemon_ = true; + break; + case 's': + { + // There's no point in dealing with this on NT since it + // doesn't really support signals very well... +#if !defined (ACE_LACKS_UNIX_SIGNALS) + ACE_Service_Config::signum_ = + ACE_OS::atoi (getopt.opt_arg ()); + + if (ACE_Reactor::instance ()->register_handler + (ACE_Service_Config::signum_, + ACE_Service_Config::signal_handler_) == -1) + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("cannot obtain signal handler\n")), + -1); +#endif /* ACE_LACKS_UNIX_SIGNALS */ + break; + } + default: + superargv.add (argv[getopt.opt_ind () - 1], true); + } + + // Collect any argumets that were left + for (int c = getopt.opt_ind (); c < argc; ++c) + superargv.add (argv[c-1], true); + + bool ignore_default_svc_conf_file = false; + return instance_->parse_args_i (superargv.argc (), + superargv.argv (), + ignore_default_svc_conf_file); + +} /* parse_args_i () */ + + +int +ACE_Service_Config::open_i (const ACE_TCHAR program_name[], + const ACE_TCHAR *logger_key, + bool , + bool , + bool ) +{ + ACE_TRACE ("ACE_Service_Config::open_i"); + ACE_MT (ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->lock_, -1)); + + ACE_Log_Msg *log_msg = ACE_LOG_MSG; + + if (ACE::debug ()) + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("ACE (%P|%t) SC::open_i - this=%@, opened=%d\n"), + this, this->is_opened_)); + + // Guard against reentrant processing. + if (this->is_opened_) + return 0; + + this->is_opened_ = true; + + // Check for things we need to do on a per-process basis and which + // may not be safe, or wise to do an a per instance basis + + // Become a daemon before doing anything else. + if (ACE_Service_Config::be_a_daemon_) + ACE::daemonize (); + + // Write process id to file. + if (this->pid_file_name_ != 0) + { + FILE* pidf = ACE_OS::fopen (this->pid_file_name_, + ACE_TEXT("w")); + + if (pidf != 0) + { + ACE_OS::fprintf (pidf, + "%ld\n", + static_cast (ACE_OS::getpid())); + ACE_OS::fclose (pidf); + } + } + + u_long flags = log_msg->flags (); + + // Only use STDERR if the caller hasn't already set the flags. + if (flags == 0) + flags = (u_long) ACE_Log_Msg::STDERR; + + const ACE_TCHAR *key = logger_key; + + if (key == 0 || ACE_OS::strcmp (key, ACE_DEFAULT_LOGGER_KEY) == 0) + // Only use the static if the caller doesn't + // override it in the parameter list or if the key supplied is + // equal to the default static logger key. + key = ACE_Service_Config::current()->logger_key_; + else + ACE_SET_BITS (flags, ACE_Log_Msg::LOGGER); + + if (log_msg->open (program_name, + flags, + key) == -1) + return -1; + + if (ACE::debug ()) + ACE_DEBUG ((LM_STARTUP, + ACE_TEXT ("starting up daemon %n\n"))); + + // Initialize the Service Repository (this will still work if + // user forgets to define an object of type ACE_Service_Config). + ACE_Service_Repository::instance (ACE_Service_Gestalt::MAX_SERVICES); + + // Initialize the ACE_Reactor (the ACE_Reactor should be the + // same size as the ACE_Service_Repository). + ACE_Reactor::instance (); + + // There's no point in dealing with this on NT since it doesn't + // really support signals very well... +#if !defined (ACE_LACKS_UNIX_SIGNALS) + // Only attempt to register a signal handler for positive + // signal numbers. + if (ACE_Service_Config::signum_ > 0) + { + ACE_Sig_Set ss; + ss.sig_add (ACE_Service_Config::signum_); + if ((ACE_Reactor::instance () != 0) && + (ACE_Reactor::instance ()->register_handler + (ss, ACE_Service_Config::signal_handler_) == -1)) + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("can't register signal handler\n"))); + } +#endif /* ACE_LACKS_UNIX_SIGNALS */ + + return 0; +} + +/// Return the global configuration instance. Always returns the same +/// instance +ACE_Service_Config * +ACE_Service_Config::singleton (void) +{ + return ACE_SERVICE_CONFIG_SINGLETON::instance (); +} + +int +ACE_Service_Config::insert (ACE_Static_Svc_Descriptor* stsd) +{ + return ACE_Service_Config::instance ()->insert (stsd); +} + + +// Totally remove from the daemon by removing it from the +// ACE_Reactor, and unlinking it if necessary. +int +ACE_Service_Config::remove (const ACE_TCHAR svc_name[]) +{ + ACE_TRACE ("ACE_Service_Config::remove"); + return ACE_Service_Repository::instance ()->remove (svc_name); +} + +// Suspend . Note that this will not unlink the service +// from the daemon if it was dynamically linked, it will mark it as +// being suspended in the Service Repository and call the +// member function on the appropriate . A service +// can be resumed later on by calling the method... + +int +ACE_Service_Config::suspend (const ACE_TCHAR svc_name[]) +{ + ACE_TRACE ("ACE_Service_Config::suspend"); + return ACE_Service_Repository::instance ()->suspend (svc_name); +} + +// Resume a SVC_NAME that was previously suspended or has not yet +// been resumed (e.g., a static service). + +int +ACE_Service_Config::resume (const ACE_TCHAR svc_name[]) +{ + ACE_TRACE ("ACE_Service_Config::resume"); + return ACE_Service_Repository::instance ()->resume (svc_name); +} + + +ACE_Service_Config::ACE_Service_Config (bool ignore_static_svcs, + size_t size, + int signum) +{ + ACE_TRACE ("ACE_Service_Config::ACE_Service_Config"); + + // TODO: Need to find a more customizable way of instantiating the + // gestalt but perhaps we should leave this out untill such + // customizations are identified. + ACE_Service_Gestalt* tmp = 0; + ACE_NEW_NORETURN (tmp, + ACE_Service_Gestalt (size, false, ignore_static_svcs)); + + this->is_opened_ = false; + this->instance_ = tmp; + this->threadkey_.set (tmp); + + ACE_Service_Config::signum_ = signum; +} + +ACE_Service_Config::ACE_Service_Config (const ACE_TCHAR program_name[], + const ACE_TCHAR *logger_key) +{ + ACE_TRACE ("ACE_Service_Config::ACE_Service_Config"); + + // TODO: Need to find a more customizable way of instantiating the + // gestalt but perhaps we should leave this out untill such + // customizations are identified. + ACE_Service_Gestalt* tmp = 0; + ACE_NEW_NORETURN (tmp, + ACE_Service_Gestalt (ACE_Service_Repository::DEFAULT_SIZE, false)); + + this->is_opened_ = false; + this->instance_ = tmp; + this->threadkey_.set (tmp); + + if (this->open (program_name, + logger_key) == -1 && errno != ENOENT) + { + // Only print out an error if it wasn't the svc.conf file that was + // missing. + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("(%P|%t) SC failed to open: %p\n"), + program_name)); + } +} + +/// Return the "global" configuration instance, for the current +/// thread. This may be the same as instance(), but on some occasions, +/// it may be a different one. For example, ACE_Service_Config_Guard +/// provides a way of temporarily replacing the "current" +/// configuration instance in the context of a thread. +ACE_Service_Gestalt* +ACE_Service_Config::current (void) +{ + void* temp = ACE_Service_Config::singleton()->threadkey_.get (); + if (temp == 0) { + + // The most likely reason is that the current thread was spawned + // by some native primitive, like pthreads or Windows API - not + // from ACE. This is perfectly legal for callers who are not, or + // do not need to be ACE-aware. Such callers must have no + // expectation that the pluggable, multi-context configuration + // support will work - they would always get the global context, + // because at this point there is no information what the "parent" + // thread's configuration context was. + + temp = global(); + singleton()->threadkey_.set (temp); + } + + return static_cast (temp); +} + +/// A mutator to set the "current" (TSS) gestalt instance. +void +ACE_Service_Config::current (ACE_Service_Gestalt* newcurrent) +{ + ACE_Service_Config::singleton()->threadkey_.set (newcurrent); +} + + + +#if (ACE_USES_CLASSIC_SVC_CONF == 0) +ACE_Service_Type * +ACE_Service_Config::create_service_type (const ACE_TCHAR *n, + ACE_Service_Type_Impl *o, + ACE_DLL &dll, + int active) +{ + ACE_Service_Type *sp = 0; + ACE_NEW_RETURN (sp, + ACE_Service_Type (n, o, dll, active), + 0); + return sp; +} +#endif /* ACE_USES_CLASSIC_SVC_CONF == 0 */ + +ACE_Service_Type_Impl * +ACE_Service_Config::create_service_type_impl (const ACE_TCHAR *name, + int type, + void *symbol, + u_int flags, + ACE_Service_Object_Exterminator gobbler) +{ + ACE_Service_Type_Impl *stp = 0; + + // Note, the only place we need to put a case statement. This is + // also the place where we'd put the RTTI tests, if the compiler + // actually supported them! + + switch (type) + { + case ACE_Service_Type::SERVICE_OBJECT: + ACE_NEW_RETURN (stp, + ACE_Service_Object_Type ((ACE_Service_Object *) symbol, + name, flags, + gobbler), + 0); + break; + case ACE_Service_Type::MODULE: + ACE_NEW_RETURN (stp, + ACE_Module_Type (symbol, name, flags), + 0); + break; + case ACE_Service_Type::STREAM: + ACE_NEW_RETURN (stp, + ACE_Stream_Type (symbol, name, flags), + 0); + break; + default: + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("unknown case\n"))); + break; + } + return stp; + +} + + +// Signal handling API to trigger dynamic reconfiguration. +void +ACE_Service_Config::handle_signal (int sig, + siginfo_t *, + ucontext_t *) +{ +#if defined (ACE_NDEBUG) + ACE_UNUSED_ARG (sig); +#else /* ! ACE_NDEBUG */ + ACE_ASSERT (ACE_Service_Config::signum_ == sig); +#endif /* ! ACE_NDEBUG */ + + ACE_Service_Config::reconfig_occurred_ = 1; +} + +// Trigger reconfiguration to re-read configuration files. +void +ACE_Service_Config::reconfigure (void) +{ + ACE_TRACE ("ACE_Service_Config::reconfigure"); + + ACE_Service_Config::reconfig_occurred_ = 0; + + if (ACE::debug ()) + { +#if !defined (ACE_NLOGGING) + time_t t = ACE_OS::time (0); +#endif /* ! ACE_NLOGGING */ + if (ACE::debug ()) + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("beginning reconfiguration at %s"), + ACE_OS::ctime (&t))); + } + if (ACE_Service_Config::process_directives () == -1) + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("%p\n"), + ACE_TEXT ("process_directives"))); +} + +// Tidy up and perform last rites on a terminating ACE_Service_Config. +int +ACE_Service_Config::close (void) +{ + ACE_Service_Config::singleton ()->instance_->close (); + + // Delete the service repository. All the objects inside the + // service repository should already have been finalized. + ACE_Service_Repository::close_singleton (); + + // Do away with the singleton ACE_Service_Config (calls dtor) + ACE_SERVICE_CONFIG_SINGLETON::close (); + + return 0; +} + + +int +ACE_Service_Config::fini_svcs (void) +{ + ACE_TRACE ("ACE_Service_Config::fini_svcs"); + + // Clear the LM_DEBUG bit from log messages if appropriate + if (ACE::debug ()) + ACE_Log_Msg::disable_debug_messages (); + + int result = 0; + if (ACE_Service_Repository::instance () != 0) + result = ACE_Service_Repository::instance ()->fini (); + + if (ACE::debug ()) + ACE_Log_Msg::enable_debug_messages (); + + return result; +} + +/// Perform user-specified close activities and remove dynamic memory. +ACE_Service_Config::~ACE_Service_Config (void) +{ + ACE_TRACE ("ACE_Service_Config::~ACE_Service_Config"); +} + +// ************************************************************ + +/* static */ +int +ACE_Service_Config::reconfig_occurred (void) +{ + ACE_TRACE ("ACE_Service_Config::reconfig_occurred"); + return ACE_Service_Config::reconfig_occurred_ != 0; +} + +void +ACE_Service_Config::reconfig_occurred (int config_occurred) +{ + ACE_TRACE ("ACE_Service_Config::reconfig_occurred"); + ACE_Service_Config::reconfig_occurred_ = config_occurred; +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Service_Config.h b/dep/ACE_wrappers/ace/Service_Config.h new file mode 100644 index 00000000000..61d9fd4d087 --- /dev/null +++ b/dep/ACE_wrappers/ace/Service_Config.h @@ -0,0 +1,684 @@ +// -*- C++ -*- + +//==================================================================== +/** + * @file Service_Config.h + * + * $Id: Service_Config.h 81673 2008-05-09 19:09:43Z iliyan $ + * + * @author Douglas C. Schmidt + */ +//==================================================================== + +#ifndef ACE_SERVICE_CONFIG_H +#define ACE_SERVICE_CONFIG_H + +#include /**/ "ace/pre.h" + +#include /**/ "ace/config-all.h" +#include "ace/Default_Constants.h" +#include "ace/Intrusive_Auto_Ptr.h" +#include "ace/Service_Gestalt.h" +#include "ace/Synch_Traits.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/OS_NS_signal.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +// Forward decl. +class ACE_Service_Object; +class ACE_Service_Type; +class ACE_Service_Type_Impl; +class ACE_Service_Repository; +class ACE_Sig_Adapter; +class ACE_Allocator; +class ACE_Reactor; +class ACE_Thread_Manager; +class ACE_DLL; + +#if (ACE_USES_CLASSIC_SVC_CONF == 1) +#define ACE_STATIC_SERVICE_DIRECTIVE(ident, parameters) \ + ACE_TEXT ("static ") \ + ACE_TEXT (ident) \ + ACE_TEXT (" \"") \ + ACE_TEXT (parameters) \ + ACE_TEXT ("\"") +#define ACE_DYNAMIC_SERVICE_DIRECTIVE(ident, libpathname, objectclass, parameters) \ + ACE_TEXT ("dynamic ") \ + ACE_TEXT (ident) \ + ACE_TEXT (" Service_Object * ") \ + ACE_TEXT (libpathname) \ + ACE_TEXT (":") \ + ACE_TEXT (objectclass) \ + ACE_TEXT ("() \"") \ + ACE_TEXT (parameters) \ + ACE_TEXT ("\"") +#define ACE_REMOVE_SERVICE_DIRECTIVE(ident) \ + ACE_TEXT ("remove ") \ + ACE_TEXT (ident) +class ACE_Svc_Conf_Param; +#else +#define ACE_STATIC_SERVICE_DIRECTIVE(ident, parameters) \ + ACE_TEXT ("") +#define ACE_DYNAMIC_SERVICE_DIRECTIVE(ident, libpathname, objectclass, parameters) \ + ACE_TEXT ("") \ + ACE_TEXT ("") +#define ACE_REMOVE_SERVICE_DIRECTIVE(ident) \ + ACE_TEXT ("") +class ACE_XML_Svc_Conf; +#endif /* ACE_USES_CLASSIC_SVC_CONF == 1 */ + +ACE_END_VERSIONED_NAMESPACE_DECL + +extern "C" +{ + typedef ACE_Service_Object *(*ACE_SERVICE_ALLOCATOR) (ACE_Service_Object_Exterminator *); +} + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +/** + * @class ACE_Static_Svc_Descriptor + * + * @brief Holds the information necessary to describe a statically linked + * Svc. + */ +class ACE_Static_Svc_Descriptor +{ +public: + /// Name of the service. + const ACE_TCHAR *name_; + + /// Type of service. + int type_; + + /// Factory function that allocates the service. + ACE_SERVICE_ALLOCATOR alloc_; + + /// Bitmask flags indicating how the framework should delete memory. + u_int flags_; + + /// Flag indicating whether the service starts out active. + int active_; + + /// Dump the state of an object. + void dump (void) const; + + /// Declare the dynamic allocation hooks. + ACE_ALLOC_HOOK_DECLARE; + +public: + /// Compare two service descriptors for equality. + bool operator== (ACE_Static_Svc_Descriptor &) const; + + /// Compare two service descriptors for inequality. + bool operator!= (ACE_Static_Svc_Descriptor &) const; +}; + + +/** + * @class ACE_Threading_Helper + * + * @brief Encapsulates responsibility for allocating, destroying and + * manipulating the value, associated with a thread-specific + * key. Relates to the ability of the created thread to inherit the + * parent thread's gestalt. Designed to be used as an instance member + * of @c ACE_Service_Config. + * + * Partial specialization over ACE_SYNCH_MUTEX is used to implement + * specific behavior in both multi- and single-threaded builds. + */ +template +class ACE_Threading_Helper +{ +}; + +/* + * Specialization for a multi threaded program + */ +template<> +class ACE_Export ACE_Threading_Helper +{ +public: + ACE_Threading_Helper (); + ~ACE_Threading_Helper (); + + void set (void*); + void* get (void); + +private: + /// Key for the thread-specific data, which is a simple pointer to + /// the thread's (currently-) global configuration context. + ACE_thread_key_t key_; +}; + +/* + * Specialization for a single threaded program + */ +template<> +class ACE_Export ACE_Threading_Helper +{ +public: + ACE_Threading_Helper (); + ~ACE_Threading_Helper (); + + void set (void*); + void* get (void); +}; + +#define ACE_Component_Config ACE_Service_Config + +/** + * @class ACE_Service_Config + * + * @brief Supplies common server operations for dynamic and static + * configuration of service. + * + * The ACE_Service_Config uses the Monostate pattern. Therefore, + * you can only have one of these instantiated per-process. It + * represents the process-wide collection of services, which is + * typicaly shared among all other configurable entities. The only + * ACE_Service_Config instance is registered with and owned by the + * ACE_Object_Manager. + * + * By contrast, the ACE_Service_Gestalt represents the collection + * of services, pertaining to a configurable entity. Typicaly, a + * "configurable entity" is an instance, which owns an instance of + * ACE_Service_Gestalt in order to ensure full controll over the + * services it needs. + * + * Another facet of ACE_Service_Config is that for a given thread, + * it provides access to its current, process-global + * ACE_Service_Gestalt instance through its curent() method. + * + * @note The signal_handler_ static member is allocated by the + * ACE_Object_Manager. The ACE_Service_Config constructor + * uses signal_handler_. Therefore, if the program has any + * static ACE_Service_Config objects, there might be + * initialization order problems. They can be minimized, but + * not eliminated, by _not_ #defining + * ACE_HAS_NONSTATIC_OBJECT_MANAGER. + */ +class ACE_Export ACE_Service_Config +{ + + /// The Instance, or the global (default) configuration context. + /// The monostate would forward the calls to that instance. The TSS + /// will point here + ACE_Intrusive_Auto_Ptr instance_; + + /// A helper instance to manage thread-specific key creation. + /// Dependent on the syncronization mutex ACE uses, the corresponding + /// partial template instantiation will perform the right services + /// that have to do with managing thread-specific storage. Note that, + /// for single-threaded builds they would do (next to) nothing. + ACE_Threading_Helper threadkey_; + +public: + + // = Initialization and termination methods. + + /** + * Initialize the Service Repository. Note that initialising @a + * signum to a negative number will prevent a signal handler being + * registered when the repository is opened. + */ + ACE_Service_Config (bool ignore_static_svcs = true, + size_t size = ACE_DEFAULT_SERVICE_REPOSITORY_SIZE, + int signum = SIGHUP); + + /** + * Performs an open without parsing command-line arguments. The + * @a logger_key indicates where to write the logging output, which + * is typically either a STREAM pipe or a socket address. + */ + ACE_Service_Config (const ACE_TCHAR program_name[], + const ACE_TCHAR *logger_key = ACE_DEFAULT_LOGGER_KEY); + + /// Perform user-specified close activities and remove dynamic + /// memory. + virtual ~ACE_Service_Config (void); + +private: + + /** + * Performs an open without parsing command-line arguments. + * Implements whats different in the opening sequence + * for this class, as opposed to the base class. + * + * The @a logger_key indicates where to write the logging output, which + * is typically either a STREAM pipe or a socket address. If + * @a ignore_default_svc_conf_file is non-0 then the "svc.conf" file + * will be ignored. If @a ignore_debug_flag is non-0 then the + * application is responsible for setting the + * @c ACE_Log_Msg::priority_mask() appropriately. Returns number of + * errors that occurred on failure and 0 otherwise. + */ + virtual int open_i (const ACE_TCHAR program_name[], + const ACE_TCHAR *logger_key, + bool ignore_static_svcs, + bool ignore_default_svc_conf_file, + bool ignore_debug_flag); + + /** + * Implements whats different in the command line parameter processing + * for this class, as opposed to the base class. + */ + virtual int parse_args_i (int argc, ACE_TCHAR *argv[]); + + /// = Static interfaces + + public: + /** + * Returns the process-wide global singleton instance. It would + * have been created and will be managed by the Object Manager. + */ + static ACE_Service_Config* singleton (void); + + /** + * Mutator for the currently active configuration context instance + * (gestalt). Intended for use by helper classes like @see + * ACE_Service_Config_Guard. Stack-based instances can be used to + * temporarily change which gestalt is seen as global by static + * initializers (especially those in DLLs loaded at run-time). + */ + static void current (ACE_Service_Gestalt*); + + /** + * Accessor for the "current" service gestalt + */ + static ACE_Service_Gestalt* current (void); + + /** + * This is what the static service initializators are hard-wired to + * use, so in order to avoid interface changes this method merely + * forwards to @c ACE_Service_Config::current. This enables us to + * enforce which Service Gestalt is used for services registering + * through static initializers. Especially important for DLL-based + * dynamic services, which can contain their own static services and + * static initializers. + * + * @deprecated Use current() instead. + */ + static ACE_Service_Gestalt* instance (void); + + /** + * Returns a process-wide global singleton instance in contrast with + * current (), which may return a different instance at different + * times, dependent on the context. Modifying this method's return + * value is strongly discouraged as it will circumvent the mechanism + * for dynamically loading services. If you must, use with extreme + * caution! + */ + static ACE_Service_Gestalt* global (void); + + /** + * Performs an open without parsing command-line arguments. The + * @a logger_key indicates where to write the logging output, which + * is typically either a STREAM pipe or a socket address. If + * @a ignore_static_svcs is true then static services are not loaded, + * otherwise, they are loaded. If @a ignore_default_svc_conf_file is + * non-0 then the configuration file will be ignored. + * Returns zero upon success, -1 if the file is not found or cannot + * be opened (errno is set accordingly), otherwise returns the + * number of errors encountered loading the services in the + * specified svc.conf configuration file. If @a ignore_debug_flag is + * non-0 then the application is responsible for setting the + * @c ACE_Log_Msg::priority_mask appropriately. + */ + static int open (const ACE_TCHAR program_name[], + const ACE_TCHAR *logger_key = ACE_DEFAULT_LOGGER_KEY, + bool ignore_static_svcs = true, + bool ignore_default_svc_conf_file = false, + bool ignore_debug_flag = false); + + /** + * This is the primary entry point into the ACE_Service_Config (the + * constructor just handles simple initializations). It parses + * arguments passed in from @a argc and @a argv parameters. The + * arguments that are valid in a call to this method include: + * + * - '-b' Option to indicate that we should be a daemon. Note that when + * this option is used, the process will be daemonized before the + * service configuration file(s) are read. During daemonization, + * (on POSIX systems) the current directory will be changed to "/" + * so the caller should either fully specify the file names, or + * execute a @c chroot() to the appropriate directory. + * @sa ACE::daemonize(). + * - '-d' Turn on debugging mode + * - '-f' Specifies a configuration file name other than the default + * svc.conf. Can be specified multiple times to use multiple files. + * - '-k' Specifies the rendezvous point to use for the ACE distributed + * logger. + * - '-y' Explicitly enables the use of static services. This flag + * overrides the @a ignore_static_svcs parameter value. + * - '-n' Explicitly disables the use of static services. This flag + * overrides the @a ignore_static_svcs parameter value. + * - '-p' Specifies a pathname which is used to store the process id. + * - '-s' Specifies a signal number other than SIGHUP to trigger reprocessing + * of the configuration file(s). Ignored for platforms that do not + * have POSIX signals, such as Windows. + * - '-S' Specifies a service directive string. Enclose the string in quotes + * and escape any embedded quotes with a backslash. This option + * specifies service directives without the need for a configuration + * file. + * + * @param argc The number of commandline arguments. + * @param argv The array with commandline arguments + * @param logger_key Indicates where to write the logging output, + * which is typically either a STREAM pipe or a + * socket address. + * @param ignore_static_svcs If true then static services are not loaded, + * otherwise, they are loaded. + * @param ignore_default_svc_conf_file If non-0 then the @c svc.conf + * configuration file will be ignored. + * @param ignore_debug_flag If true then the application is responsible + * for setting the @c ACE_Log_Msg::priority_mask + * appropriately. + * + * @retval -1 The configuration file is not found or cannot + * be opened (errno is set accordingly). + * @retval 0 Success. + * @retval >0 The number of errors encountered while processing + * the service configuration file(s). + */ + static int open (int argc, + ACE_TCHAR *argv[], + const ACE_TCHAR *logger_key = ACE_DEFAULT_LOGGER_KEY, + bool ignore_static_svcs = true, + bool ignore_default_svc_conf_file = false, + bool ignore_debug_flag = false); + + /// Tidy up and perform last rites when ACE_Service_Config is shut + /// down. This method calls close_svcs(). Returns 0. + static int close (void); + + /// Perform user-specified close hooks and possibly delete all of the + /// configured services in the . + static int fini_svcs (void); + + /// True if reconfiguration occurred. + static int reconfig_occurred (void); + + /// Indicate that reconfiguration occurred. + static void reconfig_occurred (int); + + /// Perform the reconfiguration process. + static void reconfigure (void); + + // = The following methods are static in order to enforce Singleton + // semantics for the Reactor, Service_Repository, Thread_Manager, + // and Acceptor/Connector Strategy factory. Other portions of the + // system may need to access them at some point or another... + + // = This is not strictly needed, anymore since the service configurator + // has been refactored to allow multiple service configuration + // instances (called gestalts). The interfaces, however were retained in for + // the sake of maintaining source-code compatibility. + + + // = Accessors and mutators for process-wide Singletons. + + /// Returns a pointer to the list of statically linked services. + /// + /// @deprecated - Same as instance(), but still useful in legacy code, + /// (notably, one that can not be easily modified) which uses the following + /// idiom for registering static services: + /// + /// ACE_Service_Config::static_svcs ()->insert (...); + static ACE_Service_Gestalt* static_svcs (void); + + /// Insert a static service descriptor for processing on open_i(). The + /// corresponding ACE_STATIC_SVC_* macros were chaged to use this method + /// instead of obtaining a ptr to a container. See the note on static_svcs(). + /// Added to prevent exposing the internal storage representation of the + /// services repository and provide a better way of debugging service + /// loading and registration problems. + static int insert (ACE_Static_Svc_Descriptor *svc); + + // = Utility methods. + /// Dynamically link the shared object file and retrieve a pointer to + /// the designated shared object in this file. + static int initialize (const ACE_Service_Type *, + const ACE_TCHAR *parameters); + + /// Initialize and activate a statically @a svc_name service. + static int initialize (const ACE_TCHAR *svc_name, + const ACE_TCHAR *parameters); + + /// Resume a @a svc_name that was previously suspended or has not yet + /// been resumed (e.g., a static service). + static int resume (const ACE_TCHAR svc_name[]); + + /** + * Suspend @a svc_name. Note that this will not unlink the service + * from the daemon if it was dynamically linked, it will mark it as + * being suspended in the Service Repository and call the + * member function on the appropriate ACE_Service_Object. A + * service can be resumed later on by calling the member + * function... + */ + static int suspend (const ACE_TCHAR svc_name[]); + + /// Totally remove @a svc_name from the daemon by removing it + /// from the ACE_Reactor, and unlinking it if necessary. + static int remove (const ACE_TCHAR svc_name[]); + +#if defined (ACE_HAS_WINCE) && defined (ACE_USES_WCHAR) + // We must provide these function to bridge the Svc_Conf parser + // with ACE. + static int initialize (const ACE_Service_Type *, ACE_ANTI_TCHAR []); + static int initialize (const char svc_name[], ACE_ANTI_TCHAR parameters[]); + static int resume (const ACE_ANTI_TCHAR svc_name[]); + static int suspend (const ACE_ANTI_TCHAR svc_name[]); + static int remove (const ACE_ANTI_TCHAR svc_name[]); +#endif /* ACE_HAS_WINCE */ + + /// Dump the state of an object. + void dump (void) const; + + /// Set the signal_handler;for internal use by ACE_Object_Manager only. + static ACE_INLINE void signal_handler (ACE_Sig_Adapter *); + + /// Declare the dynamic allocation hooks. + ACE_ALLOC_HOOK_DECLARE; + + /// Process a file containing a list of service configuration + /// directives. + static int process_file (const ACE_TCHAR file[]); + + /// Process one service configuration @a directive, which is passed as + /// a string. Returns the number of errors that occurred. + static int process_directive (const ACE_TCHAR directive[]); + + /** + * Process one static service definition. Load a new static service + * into the ACE_Service_Repository. + * + * @param ssd Service descriptor, see the document of + * ACE_Static_Svc_Descriptor for more details. + * + * @param force_replace If set the new service descriptor replaces + * any previous instance in the ACE_Service_Repository. + * + * @return Returns -1 if the service cannot be 'loaded'. + */ + static int process_directive (const ACE_Static_Svc_Descriptor &ssd, + bool force_replace = false); + + /** + * Process (or re-process) service configuration requests that are + * provided in the svc.conf file(s). Returns the number of errors + * that occurred. + */ + static int process_directives (void); + + /// Handles signals to trigger reconfigurations. + static void handle_signal (int sig, siginfo_t *, ucontext_t *); + + /** + * Handle the command-line options intended for the + * ACE_Service_Config. Note that @c argv[0] is assumed to be the + * program name. + * The arguments that are valid in a call to this method are + * - '-b' Option to indicate that we should be a daemon + * - '-d' Turn on debugging mode + * - '-f' Option to read in the list of svc.conf file names + * - '-k' Option to read a wide string where in the logger output can + * be written + * - '-y' Turn on the flag for a repository of statically + * linked services + * - '-n' Need not have a repository of statically linked services + * - '-S' Option to read in the list of services on the command-line + * Please observe the difference between options '-f' that looks + * for a list of files and here a list of services. + */ + static int parse_args (int, ACE_TCHAR *argv[]); + +#if (ACE_USES_CLASSIC_SVC_CONF == 0) + static ACE_Service_Type *create_service_type (const ACE_TCHAR *n, + ACE_Service_Type_Impl *o, + ACE_DLL &dll, + int active); +#endif /* ACE_USES_CLASSIC_SVC_CONF == 0 */ + + static ACE_Service_Type_Impl * + create_service_type_impl (const ACE_TCHAR *name, + int type, + void *symbol, + u_int flags, + ACE_Service_Object_Exterminator gobbler); + + /// @deprecated + /// Process service configuration requests that were provided on the + /// command-line. Returns the number of errors that occurred. + static int process_commandline_directives (void); + + /// Become a daemon. + static int start_daemon (void); + + // @deprecated + // Add the default statically-linked services to the + // ACE_Service_Repository. + static int load_static_svcs (void); + +protected: + +#if (ACE_USES_CLASSIC_SVC_CONF == 1) + /// @deprecated + /// This is the implementation function that process_directives() + /// and process_directive() both call. Returns the number of errors + /// that occurred. + static int process_directives_i (ACE_Svc_Conf_Param *param); +#endif /* ACE_USES_CLASSIC_SVC_CONF == 1 */ + + + // = Process-wide state. + +private: + + /// Have we called ACE_Service_Config::open() yet? + bool is_opened_; + +#if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0) + /// Synchronization variable for open, etc. + mutable ACE_SYNCH_MUTEX lock_; +#endif /* ACE_MT_SAFE */ + + /// True if reconfiguration occurred. + static sig_atomic_t reconfig_occurred_; + + // = Set by command-line options. + /// Shall we become a daemon process? + static bool be_a_daemon_; + + /// Pathname of file to write process id. + static ACE_TCHAR *pid_file_name_; + + /// Number of the signal used to trigger reconfiguration. + static int signum_; + + /// Handles the reconfiguration signals. + static ACE_Sig_Adapter *signal_handler_; + + /// Pointer to the Singleton (ACE_Cleanup) Gestalt instance. + /// There is thread-specific global instance pointer, which is used to + /// temporarily change which Gestalt instance is used for static service + /// registrations. + /// + /// A specific use case is a thread, which loads a _dynamic_ service from + /// a DLL. If the said DLL also contains additional _static_ services, + /// those *must* be registered with the same configuration repository as + /// the dynamic service. Otherwise, the DLL's static services would be + /// registered with the global Gestalt and may outlive the DLL that + /// contains their code and perhaps the memory in which they are in. + /// This is a problem because if the DLL gets unloaded (as it will, if + /// it was loaded in an instance of Gestalt), the DLL's memory will be + /// deallocated, but the global service repository will still "think" + /// it must finalize the (DLL's) static services - with disastrous + /// consequences, occurring in the post-main code (at_exit()). + + /// This class needs the intimate access to be able to swap the + /// current TSS pointer for the global Gestalt. + friend class ACE_Service_Config_Guard; + + /// The helper needs intimate access (when building with no threads) + friend class ACE_Threading_Helper ; + friend class ACE_Threading_Helper ; +}; + +/** + * @class ACE_Service_Config_Guard + * + * @brief A guard class, designed to be instantiated on the stack. + * + * Instantiating it with a specific configuration ensures any references to + * ACE_Service_Config::instance(), even when occuring in static constructors, + * will allways access the designated configuration instance. + * This comes very handy when a dynamic service also registers any static + * services of its own and their static factories. + */ +class ACE_Export ACE_Service_Config_Guard +{ +public: + ACE_Service_Config_Guard (ACE_Service_Gestalt* psg); + ~ACE_Service_Config_Guard (void); + +private: + // Private AND not implemented to disable copying + ACE_Service_Config_Guard(const ACE_Service_Config_Guard&); + ACE_Service_Config_Guard& operator= (const ACE_Service_Config_Guard&); + +private: + ACE_Intrusive_Auto_Ptr saved_; +}; + + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +#include "ace/Service_Config.inl" +#endif /* __ACE_INLINE__ */ + +#include /**/ "ace/post.h" + +#endif /* ACE_SERVICE_CONFIG_H */ diff --git a/dep/ACE_wrappers/ace/Service_Config.inl b/dep/ACE_wrappers/ace/Service_Config.inl new file mode 100644 index 00000000000..a03e7124eb1 --- /dev/null +++ b/dep/ACE_wrappers/ace/Service_Config.inl @@ -0,0 +1,204 @@ +// -*- C++ -*- +// +// $Id: Service_Config.inl 81673 2008-05-09 19:09:43Z iliyan $ + +#include "ace/OS_NS_string.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +// This is the primary entry point into the ACE_Service_Config (the +// constructor just handles simple initializations). +ACE_INLINE int +ACE_Service_Config::open (const ACE_TCHAR program_name[], + const ACE_TCHAR *logger_key, + bool ignore_static_svcs, + bool ignore_default_svc_conf, + bool ignore_debug_flag) +{ + ACE_TRACE ("ACE_Service_Config::open"); + if (singleton()->open_i (program_name, + logger_key, + ignore_static_svcs, + ignore_default_svc_conf, + ignore_debug_flag) == -1) + return -1; + + return current()->open (program_name, + logger_key, + ignore_static_svcs, + ignore_default_svc_conf, + ignore_debug_flag); +} + + +ACE_INLINE int +ACE_Service_Config::open (int argc, + ACE_TCHAR *argv[], + const ACE_TCHAR *logger_key, + bool ignore_static_svcs, + bool ignore_default_svc_conf, + bool ignore_debug_flag) +{ + ACE_TRACE ("ACE_Service_Config::open"); + if (singleton()->open_i (argv[0], + logger_key, + ignore_static_svcs, + ignore_default_svc_conf, + ignore_debug_flag) == -1) + return -1; + + return current()->open (argc, + argv, + logger_key, + ignore_static_svcs, + ignore_default_svc_conf, + ignore_debug_flag); +} + +// Handle the command-line options intended for the +// ACE_Service_Config. +ACE_INLINE int +ACE_Service_Config::parse_args (int argc, ACE_TCHAR *argv[]) +{ + return ACE_Service_Config::current ()->parse_args (argc, argv); +} + +/// Return the global configuration instance. Allways returns the same +/// instance +ACE_INLINE ACE_Service_Gestalt * +ACE_Service_Config::global (void) +{ + return ACE_Service_Config::singleton()->instance_.get (); +} + +/// Return the configuration instance, considered "global" in the +/// current thread. This may be the same as instance(), but on some +/// occasions, it may be a different one. For example, +/// ACE_Service_Config_Guard provides a way of temporarily replacing +/// the "current" configuration instance in the context of a thread. +ACE_INLINE ACE_Service_Gestalt * +ACE_Service_Config::instance (void) +{ + return ACE_Service_Config::current (); +} + +// This method has changed to return the gestalt instead of the +// container, underlying the service repository and defined +// ACE_Service_Gestalt::insert (ACE_Static_Svc_Descriptor*). This way +// the existing source code can keep using +// ACE_Service_Config::static_svcs(), however now it is not necessary +// to expose the repository storage *and* it is much easier to debug +// service registration problems. + +ACE_INLINE ACE_Service_Gestalt* +ACE_Service_Config::static_svcs (void) +{ + return ACE_Service_Config::current (); +} + +/// Compare two service descriptors for equality. +ACE_INLINE bool +ACE_Static_Svc_Descriptor::operator== (ACE_Static_Svc_Descriptor &d) const +{ + return ACE_OS::strcmp (name_, d.name_) == 0; +} + +/// Compare two service descriptors for inequality. +ACE_INLINE bool +ACE_Static_Svc_Descriptor::operator!= (ACE_Static_Svc_Descriptor &d) const +{ + return !(*this == d); +} + +ACE_INLINE void +ACE_Service_Config::signal_handler (ACE_Sig_Adapter *signal_handler) +{ + signal_handler_ = signal_handler; +} + +/// Initialize and activate a statically linked service. +ACE_INLINE int +ACE_Service_Config::initialize (const ACE_TCHAR *svc_name, + const ACE_TCHAR *parameters) +{ + ACE_TRACE ("ACE_Service_Config::initialize"); + return ACE_Service_Config::current ()->initialize (svc_name, + parameters); +} + +/// Dynamically link the shared object file and retrieve a pointer to +/// the designated shared object in this file. +ACE_INLINE int +ACE_Service_Config::initialize (const ACE_Service_Type *sr, + const ACE_TCHAR *parameters) +{ + ACE_TRACE ("ACE_Service_Config::initialize"); + return ACE_Service_Config::current ()->initialize (sr, parameters); +} + +/// Process a file containing a list of service configuration +/// directives. +ACE_INLINE int ACE_Service_Config::process_file (const ACE_TCHAR file[]) +{ + return ACE_Service_Config::current ()->process_file (file); +} + +/// +ACE_INLINE int +ACE_Service_Config::process_directive (const ACE_TCHAR directive[]) +{ + return ACE_Service_Config::current ()->process_directive (directive); +} + +/// Process service configuration requests as indicated in the queue of +/// svc.conf files. +ACE_INLINE int +ACE_Service_Config::process_directives (void) +{ + return ACE_Service_Config::current ()->process_directives (false); +} + +ACE_INLINE int +ACE_Service_Config::process_directive (const ACE_Static_Svc_Descriptor &ssd, + bool force_replace) +{ + return ACE_Service_Config::current ()->process_directive (ssd, force_replace); +} + + +#if defined (ACE_HAS_WINCE) && defined (ACE_USES_WCHAR) +// We must provide these function to bridge Svc_Conf parser with ACE. + +ACE_INLINE int +ACE_Service_Config::initialize (const ACE_Service_Type *sp, ACE_ANTI_TCHAR parameters[]) +{ + return ACE_Service_Config::initialize (sp, ACE_TEXT_ANTI_TO_TCHAR (parameters)); +} + +ACE_INLINE int +ACE_Service_Config::initialize (const ACE_ANTI_TCHAR svc_name[], ACE_ANTI_TCHAR parameters[]) +{ + return ACE_Service_Config::initialize (ACE_TEXT_ANTI_TO_TCHAR (svc_name), + ACE_TEXT_ANTI_TO_TCHAR (parameters)); +} + +ACE_INLINE int +ACE_Service_Config::resume (const ACE_ANTI_TCHAR svc_name[]) +{ + return ACE_Service_Config::resume (ACE_TEXT_ANTI_TO_TCHAR (svc_name)); +} + +ACE_INLINE int +ACE_Service_Config::suspend (const ACE_ANTI_TCHAR svc_name[]) +{ + return ACE_Service_Config::suspend (ACE_TEXT_ANTI_TO_TCHAR (svc_name)); +} + +ACE_INLINE int +ACE_Service_Config::remove (const ACE_ANTI_TCHAR svc_name[]) +{ + return ACE_Service_Config::remove (ACE_TEXT_ANTI_TO_TCHAR (svc_name)); +} +#endif /* ACE_HAS_WINCE && !ACE_USES_WCHAR */ + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Service_Gestalt.cpp b/dep/ACE_wrappers/ace/Service_Gestalt.cpp new file mode 100644 index 00000000000..6ceeb15260f --- /dev/null +++ b/dep/ACE_wrappers/ace/Service_Gestalt.cpp @@ -0,0 +1,1296 @@ +// $Id: Service_Gestalt.cpp 81673 2008-05-09 19:09:43Z iliyan $ + +#include "ace/Svc_Conf.h" +#include "ace/Get_Opt.h" +#include "ace/ARGV.h" +#include "ace/Malloc.h" +#include "ace/Service_Manager.h" +#include "ace/Service_Types.h" +#include "ace/Containers.h" +#include "ace/Auto_Ptr.h" +#include "ace/Reactor.h" +#include "ace/Thread_Manager.h" +#include "ace/DLL.h" +#include "ace/XML_Svc_Conf.h" +#include "ace/SString.h" + +#ifndef ACE_LACKS_UNIX_SIGNALS +# include "ace/Signal.h" +#endif /* !ACE_LACKS_UNIX_SIGNALS */ + +#include "ace/OS_NS_stdio.h" +#include "ace/OS_NS_string.h" +#include "ace/OS_NS_time.h" +#include "ace/OS_NS_unistd.h" +#include "ace/OS_NS_sys_stat.h" + +#include "ace/TSS_T.h" +#include "ace/Service_Gestalt.h" + +#include "ace/Svc_Conf_Param.h" + +ACE_RCSID (ace, + Service_Gestalt, + "$Id: Service_Gestalt.cpp 81673 2008-05-09 19:09:43Z iliyan $") + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_Service_Type_Dynamic_Guard::ACE_Service_Type_Dynamic_Guard + (ACE_Service_Repository &r, const ACE_TCHAR *name) + : repo_ (r) + // Relocation starts where the next service will be inserted (if any) + , repo_begin_ (r.current_size ()) + , name_ (name) +# if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0) + // On this thread (for the duration of the initialize() method), + // we're about to do two things that require locking: (1) fiddle + // with the repository and (2) load a DLL and hence lock the + // DLL_Manager. + // + // Now if we don't lock the repo here, it is possible that two + // threads may deadlock on initialization because they can acquire + // locks (1) and (2) in different order, for instance: + // + // T1: loads a DLL (2) and registers a service (1); + // + // T2: may be relocating a service (1), which could lead to a + // (re)opening or uping the ref count on a DLL (2); + // + // To prevent this, we lock the repo here, using the repo_monitor_ + // member guard. + , repo_monitor_ (r.lock_) +#endif +{ + if (ACE::debug ()) + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("ACE (%P|%t) STDG::, repo=%@") + ACE_TEXT(", name=%s - begining at [%d]\n"), + &this->repo_, + this->name_, + this->repo_begin_)); + + ACE_ASSERT (this->name_ != 0); // No name? +} + + +/// Destructor + +ACE_Service_Type_Dynamic_Guard::~ACE_Service_Type_Dynamic_Guard (void) +{ + const ACE_Service_Type *tmp = 0; + + // Lookup without ignoring suspended services. Making sure + // not to ignore any inactive services, since those may be forward + // declarations + size_t slot = 0; + int const ret = this->repo_.find_i (this->name_, slot, &tmp, false); + + // We inserted it (as inactive), so we expect to find it, right? + if ((ret < 0 && ret != -2) || tmp == 0) + { + if (ACE::debug ()) + ACE_ERROR ((LM_WARNING, + ACE_TEXT ("ACE (%P|%t) STDG:: - Failed (%d) to find %s -> %@\n"), + ret, this->name_, tmp)); + return; + } + + if (tmp->type () != 0) + { + // Something has registered a proper (non-forward-decl) service with + // the same name as our dummy. + + if (ACE::debug ()) + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("ACE (%P|%t) STDG::, repo=%@ [%d], ") + ACE_TEXT ("name=%s - updating dependents [%d - %d)\n"), + &this->repo_, + slot, + this->name_, + this->repo_begin_, + this->repo_.current_size ())); + + // Relocate any services inserted since we were created. + // Any (static, i.e. DLL = 0) services registered in + // the context of this guard aren't really static because + // their code belongs in the DLL's code segment + this->repo_.relocate_i (this->repo_begin_, this->repo_.current_size (), tmp->dll()); + + if (ACE::debug ()) + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("ACE (%P|%t) STDG::, repo=%@ [%d], ") + ACE_TEXT ("name=%s - loaded (type=%@, impl=%@, object=%@, active=%d)\n"), + &this->repo_, + slot, + this->name_, + tmp, + tmp->type (), + tmp->type ()->object (), + tmp->active ())); + } +} + + + +// ---------------------------------------- + +ACE_Service_Gestalt::Processed_Static_Svc:: +Processed_Static_Svc (const ACE_Static_Svc_Descriptor *assd) + :name_(0), + assd_(assd) +{ + ACE_NEW_NORETURN (name_, ACE_TCHAR[ACE_OS::strlen(assd->name_)+1]); + ACE_OS::strcpy(name_,assd->name_); +} + +ACE_Service_Gestalt::Processed_Static_Svc::~Processed_Static_Svc (void) +{ + delete [] name_; +} + +void +ACE_Service_Gestalt::intrusive_add_ref (ACE_Service_Gestalt* g) +{ + if (g != 0) + { + ++g->refcnt_; + ACE_ASSERT (g->refcnt_ > 0); + } +} + +void +ACE_Service_Gestalt::intrusive_remove_ref (ACE_Service_Gestalt* g) +{ + if (g != 0) + { + long tmp = --g->refcnt_; + if (tmp <= 0) delete g; + ACE_ASSERT (tmp >= 0); + } +} + + +ACE_Service_Gestalt::~ACE_Service_Gestalt (void) +{ + + if (this->svc_repo_is_owned_) + delete this->repo_; + + this->repo_ =0; + + delete this->static_svcs_; + this->static_svcs_ = 0; + + // Delete the dynamically allocated static_svcs instance. +#ifndef ACE_NLOGGING + if (ACE::debug ()) + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("ACE (%P|%t) SG::~SG - this=%@, pss = %@\n"), + this, this->processed_static_svcs_)); +#endif + + if (this->processed_static_svcs_ && + !this->processed_static_svcs_->is_empty()) + { + Processed_Static_Svc **pss = 0; + for (ACE_PROCESSED_STATIC_SVCS_ITERATOR iter (*this->processed_static_svcs_); + iter.next (pss) != 0; + iter.advance ()) + { + delete *pss; + } + } + + delete this->processed_static_svcs_; + this->processed_static_svcs_ = 0; + + delete this->svc_conf_file_queue_; + this->svc_conf_file_queue_ = 0; +} + +ACE_Service_Gestalt::ACE_Service_Gestalt (size_t size, + bool svc_repo_is_owned, + bool no_static_svcs) + : svc_repo_is_owned_ (svc_repo_is_owned) + , svc_repo_size_ (size) + , is_opened_ (0) + , logger_key_ (ACE_DEFAULT_LOGGER_KEY) + , no_static_svcs_ (no_static_svcs) + , svc_queue_ (0) + , svc_conf_file_queue_ (0) + , repo_ (0) + , static_svcs_ (0) + , processed_static_svcs_ (0) + , refcnt_ (0) +{ + (void)this->init_i (); + +#ifndef ACE_NLOGGING + if (ACE::debug ()) + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("ACE (%P|%t) SG::ctor - this = %@, pss = %@\n"), + this, this->processed_static_svcs_)); +#endif +} + +/// Performs the common initialization tasks for a new or previously +/// closed instance. Must not be virtual, as it is also called from +/// the constructor. +int +ACE_Service_Gestalt::init_i (void) +{ + // Only initialize the repo_ if (a) we are being constructed, or; + // (b) we're being open()-ed, perhaps after previously having been + // close()-ed. In both cases: repo_ == 0 and we need a repository. + if (this->repo_ == 0) + { + if (this->svc_repo_is_owned_) + { + ACE_NEW_RETURN (this->repo_, + ACE_Service_Repository (this->svc_repo_size_), + -1); + } + else + { + this->repo_ = + ACE_Service_Repository::instance (this->svc_repo_size_); + } + } + + if (init_svc_conf_file_queue () == -1) + return -1; + + if ( svc_conf_file_queue_->is_empty ()) + { + // Check if the default file exists before attempting to queue it + // for processing + FILE *fp = ACE_OS::fopen (ACE_DEFAULT_SVC_CONF, + ACE_TEXT ("r")); + bool skip_static_svcs = (fp == 0); + if (fp != 0) + ACE_OS::fclose (fp); + + if (!skip_static_svcs) { + // Load the default "svc.conf" entry here if there weren't + // overriding -f arguments in . + if (svc_conf_file_queue_->enqueue_tail + (ACE_TString (ACE_DEFAULT_SVC_CONF)) == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("%p\n"), + ACE_TEXT ("enqueuing ") + ACE_DEFAULT_SVC_CONF + ACE_TEXT(" file")), + -1); + } + } + } + + return 0; +} + + +// Add the default statically-linked services to the Service +// Repository. + +int +ACE_Service_Gestalt::load_static_svcs (void) +{ + ACE_TRACE ("ACE_Service_Gestalt::load_static_svcs"); + + if (this->static_svcs_ == 0) + return 0; // Nothing to do + + ACE_Static_Svc_Descriptor **ssdp = 0; + for (ACE_STATIC_SVCS_ITERATOR iter (*this->static_svcs_); + iter.next (ssdp) != 0; + iter.advance ()) + { + ACE_Static_Svc_Descriptor *ssd = *ssdp; + + if (this->process_directive (*ssd, 1) == -1) + return -1; + } + return 0; + +} /* load_static_svcs () */ + + + +/// Find a static service descriptor by name + +int +ACE_Service_Gestalt::find_static_svc_descriptor (const ACE_TCHAR* name, + ACE_Static_Svc_Descriptor **ssd) const +{ + ACE_TRACE ("ACE_Service_Gestalt::find_static_svc_descriptor"); + + if (this->static_svcs_ == 0) + return -1; + + ACE_Static_Svc_Descriptor **ssdp = 0; + for (ACE_STATIC_SVCS_ITERATOR iter ( *this->static_svcs_); + iter.next (ssdp) != 0; + iter.advance ()) + { + if (ACE_OS::strcmp ((*ssdp)->name_, name) == 0) + { + if (ssd != 0) + *ssd = *ssdp; + + return 0; + } + } + + return -1; +} + +/// @brief + +const ACE_Static_Svc_Descriptor* +ACE_Service_Gestalt::find_processed_static_svc (const ACE_TCHAR* name) +{ + if (this->processed_static_svcs_ == 0 || name == 0) + return 0; + + Processed_Static_Svc **pss = 0; + for (ACE_PROCESSED_STATIC_SVCS_ITERATOR iter (*this->processed_static_svcs_); + iter.next (pss) != 0; + iter.advance ()) + { + if (ACE_OS::strcmp ((*pss)->name_, name) == 0) + return (*pss)->assd_; + } + return 0; +} + + + +/// @brief Captures a list of the direcives processed (explicitely) for this +/// Gestalt so that services can be replicated in other repositories +/// upon their first initialization. +/// +/// This is part of the mechanism ensuring distinct local instances +/// for static service objects, loaded in another repository. + +void +ACE_Service_Gestalt::add_processed_static_svc + (const ACE_Static_Svc_Descriptor *assd) +{ + + /// When process_directive(Static_Svc_Descriptor&) is called, it + /// associates a service object with the Gestalt and makes the + /// resource (a Service Object) local to the repository. This is but + /// the first step in using such SO. The next is the + /// "initialization" step. It is typicaly done through a "static" + /// service configuration directive. + /// + /// In contrast a "dynamic" directive, when processed through the + /// overloaded process_directives(string) both creates the SO + /// locally and initializes it, where the statics directive must + /// first locate the SO and then calls the init() method. This means + /// that durig the "static" initialization there's no specific + /// information about the hosting repository and the gestalt must + /// employ some lookup strategy to find it elsewhere. + + if (this->processed_static_svcs_ == 0) + ACE_NEW (this->processed_static_svcs_, + ACE_PROCESSED_STATIC_SVCS); + + Processed_Static_Svc **pss = 0; + for (ACE_PROCESSED_STATIC_SVCS_ITERATOR iter (*this->processed_static_svcs_); + iter.next (pss) != 0; + iter.advance ()) + { + if (ACE_OS::strcmp ((*pss)->name_, assd->name_) == 0) + { + (*pss)->assd_ = assd; + return; + } + } + Processed_Static_Svc *tmp = 0; + ACE_NEW (tmp,Processed_Static_Svc(assd)); + this->processed_static_svcs_->insert(tmp); + + if (ACE::debug ()) + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("ACE (%P|%t) SG::add_processed_static_svc, ") + ACE_TEXT ("repo=%@ - %s\n"), + this->repo_, + assd->name_)); +} + + +/// Queues a static service object descriptor which, during open() +/// will be given to process_directive() to create the Service +/// Object. Normally, only called from static initializers, prior to +/// calling open() but loading a service from a DLL can cause it too. + +int +ACE_Service_Gestalt::insert (ACE_Static_Svc_Descriptor *stsd) +{ + if (this->static_svcs_ == 0) + ACE_NEW_RETURN (this->static_svcs_, + ACE_STATIC_SVCS, + -1); + + return this->static_svcs_->insert (stsd); +} + + +ACE_ALLOC_HOOK_DEFINE (ACE_Service_Gestalt) + + +void +ACE_Service_Gestalt::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + ACE_TRACE ("ACE_Service_Gestalt::dump"); +#endif /* ACE_HAS_DUMP */ +} + + + +/// + +int +ACE_Service_Gestalt::initialize (const ACE_TCHAR *svc_name, + const ACE_TCHAR *parameters) +{ + ACE_TRACE ("ACE_Service_Gestalt_Base::initialize (repo)"); + ACE_ARGV args (parameters); + +#ifndef ACE_NLOGGING + if (ACE::debug ()) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("ACE (%P|%t) SG::initialize - () repo=%@, ") + ACE_TEXT ("looking up static ") + ACE_TEXT ("service \'%s\' to initialize\n"), + this->repo_, + svc_name)); + } +#endif + + const ACE_Service_Type *srp = 0; + for (int i = 0; this->find (svc_name, &srp) == -1 && i < 2; i++) + // if (this->repo_->find (svc_name, &srp) == -1) + { + const ACE_Static_Svc_Descriptor *assd = + ACE_Service_Config::global()->find_processed_static_svc(svc_name); + if (assd != 0) + { + this->process_directive_i(*assd, 0); + } + else + { + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("ACE (%P|%t) ERROR: SG::initialize - service \'%s\'") + ACE_TEXT (" was not located.\n"), + svc_name), + -1); + } + } + if (srp == 0) + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("ACE (%P|%t) ERROR: SG::initialize - service \'%s\'") + ACE_TEXT (" was not located.\n"), + svc_name), + -1); + + /// If initialization fails ... + if (srp->type ()->init (args.argc (), + args.argv ()) == -1) + { + // ... report and remove this entry. + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("ACE (%P|%t) ERROR: SG::initialize - static init of \'%s\'") + ACE_TEXT (" failed (%p)\n"), + svc_name, ACE_TEXT ("error"))); + this->repo_->remove (svc_name); + return -1; + } + + // If everything is ok, activate it + const_cast(srp)->active (1); + return 0; +} + + +#if (ACE_USES_CLASSIC_SVC_CONF == 1) +int +ACE_Service_Gestalt::initialize (const ACE_Service_Type_Factory *stf, + const ACE_TCHAR *parameters) +{ + ACE_TRACE ("ACE_Service_Gestalt::initialize"); + +#ifndef ACE_NLOGGING + if (ACE::debug ()) + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("ACE (%P|%t) SG::initialize - repo=%@, name=%s") + ACE_TEXT (" - looking up in the repo\n"), + this->repo_, + stf->name ())); +#endif + + ACE_Service_Type *srp = 0; + int const retv = this->repo_->find (stf->name (), + (const ACE_Service_Type **) &srp); + + // If there is an active service already, remove it first + // before it can be re-installed. + if (retv >= 0) + { +#ifndef ACE_NLOGGING + if (ACE::debug ()) + ACE_DEBUG ((LM_WARNING, + ACE_TEXT ("ACE (%P|%t) SG::initialize - repo=%@,") + ACE_TEXT (" name=%s - removing a pre-existing namesake.\n"), + this->repo_, + stf->name ())); +#endif + this->repo_->remove (stf->name ()); + } + + // If there is an inactive service by that name it may have been + // either inactivated, or just a forward declaration for a service, + // that is in the process of being initialized. If it is the latter, + // then we have detected an attempt to initialize the same dynamic + // service while still processing previous attempt. This can lock up + // the process, because the ACE_DLL_Manager::open () is not + // re-entrant - it uses a Singleton lock to serialize concurent + // invocations. This use case must be handled here, because if the + // DLL_Manager was re-entrant we would have entered an infinite + // recursion here. + if (retv == -2 && srp->type () == 0) + ACE_ERROR_RETURN ((LM_WARNING, + ACE_TEXT ("ACE (%P|%t) SG::initialize - repo=%@,") + ACE_TEXT (" name=%s - forward-declared; ") + ACE_TEXT (" recursive initialization requests are") + ACE_TEXT (" ignored.\n"), + this->repo_, + stf->name ()), + -1); + + // Reserve a spot for the dynamic service by inserting an incomplete + // service declaration, i.e. one that can not produce a service + // object if asked (a forward declaration). This declaration + // ensures maintaining the proper partial ordering of the services + // with respect to their finalization. For example, dependent static + // services must be registered *after* the dynamic service that + // loads them, so that their finalization is complete *before* + // finalizing the dynamic service. + ACE_Service_Type_Dynamic_Guard dummy (*this->repo_, + stf->name ()); + + // make_service_type() is doing the dynamic loading and also runs + // any static initializers + ACE_Auto_Ptr tmp (stf->make_service_type (this)); + + if (tmp.get () != 0 && + this->initialize_i (tmp.get (), parameters) == 0) + { + // All good. Tthe ACE_Service_Type instance is now owned by the + // repository and we should make sure it is not destroyed upon + // exit from this method. + tmp.release (); + return 0; + } + + return -1; +} +#endif /* (ACE_USES_CLASSIC_SVC_CONF == 1) */ + + +// Dynamically link the shared object file and retrieve a pointer to +// the designated shared object in this file. +// @note This is obsolete (and error-prone) in the presense of dynamic +// services with their own static services. This method will allow those +// static services to register *before* the dynamic service that owns them. +// Upon finalization of the static services the process may crash, because +// the dynamic service's DLL may have been already released, together with +// the memory in which the static services reside. +// It may not crash, for instance, when the first static service to register +// is the same as the dynamic service being loaded. You should be so lucky! .. + +int +ACE_Service_Gestalt::initialize (const ACE_Service_Type *sr, + const ACE_TCHAR *parameters) +{ + ACE_TRACE ("ACE_Service_Gestalt::initialize"); + + if (ACE::debug ()) + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("ACE (%P|%t) SG::initialize - repo=%@, name=%s") + ACE_TEXT (" - looking up in the repo\n"), + this->repo_, + sr->name ())); + + ACE_Service_Type *srp = 0; + if (this->repo_->find (sr->name (), + (const ACE_Service_Type **) &srp) >= 0) + { +#ifndef ACE_NLOGGING + ACE_DEBUG ((LM_WARNING, + ACE_TEXT ("ACE (%P|%t) SG::initialize - repo=%@, name=%s") + ACE_TEXT (" - removing a pre-existing namesake.\n"), + this->repo_, + sr->name ())); +#endif + this->repo_->remove (sr->name ()); + } + + return this->initialize_i (sr, parameters); + +} + +// Dynamically link the shared object file and retrieve a pointer to +// the designated shared object in this file. +int +ACE_Service_Gestalt::initialize_i (const ACE_Service_Type *sr, + const ACE_TCHAR *parameters) +{ + ACE_TRACE ("ACE_Service_Gestalt::initialize_i"); + ACE_ARGV args (parameters); + if (sr->type ()->init (args.argc (), + args.argv ()) == -1) + { + // We just get ps to avoid having remove() delete it. + ACE_Service_Type *ps = 0; + this->repo_->remove (sr->name (), &ps); + +#ifndef ACE_NLOGGING + // Not using LM_ERROR here to avoid confusing the test harness + if (ACE::debug ()) + ACE_ERROR_RETURN ((LM_WARNING, + ACE_TEXT ("ACE (%P|%t) SG::initialize_i -") + ACE_TEXT (" repo=%@, name=%s - remove failed: %m\n"), + this->repo_, + sr->name ()), + -1); +#endif + return -1; + } + + if (this->repo_->insert (sr) == -1) + { +#ifndef ACE_NLOGGING + // Not using LM_ERROR here to avoid confusing the test harness + if (ACE::debug ()) + ACE_ERROR_RETURN ((LM_WARNING, + ACE_TEXT ("ACE (%P|%t) SG::initialize_i -") + ACE_TEXT (" repo=%@, name=%s - insert failed: %m\n"), + this->repo_, + sr->name ()), + -1); +#endif + return -1; + } + + return 0; +} + +// Totally remove from the daemon by removing it from the +// ACE_Reactor, and unlinking it if necessary. + +int +ACE_Service_Gestalt::remove (const ACE_TCHAR svc_name[]) +{ + ACE_TRACE ("ACE_Service_Gestalt::remove"); + if (this->repo_ == 0) + return -1; + + return this->repo_->remove (svc_name); +} + +// Suspend . Note that this will not unlink the service +// from the daemon if it was dynamically linked, it will mark it as +// being suspended in the Service Repository and call the +// member function on the appropriate . A service +// can be resumed later on by calling the method... + +int +ACE_Service_Gestalt::suspend (const ACE_TCHAR svc_name[]) +{ + ACE_TRACE ("ACE_Service_Gestalt::suspend"); + if (this->repo_ == 0) + return -1; + + return this->repo_->suspend (svc_name); +} + +// Resume a SVC_NAME that was previously suspended or has not yet +// been resumed (e.g., a static service). + +int +ACE_Service_Gestalt::resume (const ACE_TCHAR svc_name[]) +{ + ACE_TRACE ("ACE_Service_Gestalt::resume"); + if (this->repo_ == 0) + return -1; + + return this->repo_->resume (svc_name); +} + + +int +ACE_Service_Gestalt::process_directive (const ACE_Static_Svc_Descriptor &ssd, + bool force_replace) +{ + int const result = process_directive_i (ssd, force_replace); + if (result == 0) + { + this->add_processed_static_svc(&ssd); + } + return result; +} + +int +ACE_Service_Gestalt::process_directive_i (const ACE_Static_Svc_Descriptor &ssd, + bool force_replace) +{ + if (this->repo_ == 0) + return -1; + + if (!force_replace) + { + if (this->repo_->find (ssd.name_, 0, 0) >= 0) + { + // The service is already there, just return + return 0; + } + } + + + ACE_Service_Object_Exterminator gobbler; + void *sym = (ssd.alloc_)(&gobbler); + + ACE_Service_Type_Impl *stp = + ACE_Service_Config::create_service_type_impl (ssd.name_, + ssd.type_, + sym, + ssd.flags_, + gobbler); + if (stp == 0) + return 0; + + ACE_Service_Type *service_type = 0; + + // This is just a temporary to force the compiler to use the right + // constructor in ACE_Service_Type. Note that, in cases where we are + // called from a static initializer which is part of a DLL, there is + // not enough information about the actuall DLL in this context. + ACE_DLL tmp_dll; + + ACE_NEW_RETURN (service_type, + ACE_Service_Type (ssd.name_, + stp, + tmp_dll, + ssd.active_), + -1); + +#ifndef ACE_NLOGGING + if (ACE::debug ()) + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("ACE (%P|%t) SG::process_directive_i, ") + ACE_TEXT ("repo=%@ - %s, dll=%s, force=%d\n"), + this->repo_, + ssd.name_, + (tmp_dll.dll_name_ == 0) ? ACE_TEXT ("") : tmp_dll.dll_name_, + force_replace)); +#endif + + return this->repo_->insert (service_type); +} + +#if (ACE_USES_CLASSIC_SVC_CONF == 1) + +int +ACE_Service_Gestalt::process_directives_i (ACE_Svc_Conf_Param *param) +{ +#ifndef ACE_NLOGGING + if (ACE::debug ()) + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("ACE (%P|%t) SG::process_directives_i, ") + ACE_TEXT ("repo=%@ - %s\n"), + this->repo_, + (param->type == ACE_Svc_Conf_Param::SVC_CONF_FILE) + ? ACE_TEXT ("") + : param->source.directive)); +#endif + + // AC 970827 Skip the heap check because yacc allocates a buffer + // here which will be reported as a memory leak for some reason. + ACE_NO_HEAP_CHECK + + // Were we called in the context of the current instance? + ACE_ASSERT (this == param->config); + + // Temporarily (for the duration of this call) make sure that *any* + // static service registrations will happen with this instance. Such + // registrations are possible as a side-effect of dynamically + // loading a DLL, which has other static services registered. Thus + // this instance will own both the DLL and those static services, + // which implies that their finalization will be performed in the + // correct order, i.e. prior to finalizing the DLL + ACE_Service_Config_Guard guard (this); + + ::ace_yyparse (param); + + // This is a hack, better errors should be provided... + if (param->yyerrno > 0) + { + // Always set the last error if ace_yyparse() fails. + // Other code may use errno to determine the type + // of problem that occurred from processing directives. + ACE_OS::last_error (EINVAL); + return param->yyerrno; + } + else + return 0; +} + +#else + +ACE_XML_Svc_Conf * +ACE_Service_Gestalt::get_xml_svc_conf (ACE_DLL &xmldll) +{ + if (xmldll.open (ACE_TEXT ("ACEXML_XML_Svc_Conf_Parser")) == -1) + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("ACE (%P|%t) Failure to open ACEXML_XML_Svc_Conf_Parser: %p\n"), + "ACE_Service_Config::get_xml_svc_conf"), + 0); + + void * foo = + xmldll.symbol (ACE_TEXT ("_ACEXML_create_XML_Svc_Conf_Object")); + + ACE_XML_Svc_Conf::Factory factory = + reinterpret_cast (foo); + if (factory == 0) + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("ACE (%P|%t) Unable to resolve factory: %p\n"), + xmldll.error ()), + 0); + + return factory (); +} +#endif /* ACE_USES_CLASSIC_SVC_CONF == 1 */ + +int +ACE_Service_Gestalt::process_file (const ACE_TCHAR file[]) +{ + ACE_TRACE ("ACE_Service_Gestalt::process_file"); + + // To avoid recursive processing of the same file and the same repository + // we maintain an implicit stack of dummy "services" named after the file + // being processed. Anytime we have to open a new file, we then can check + // to see if it is not already being processed by searching for a dummy + // service with a matching name. + if (this->repo_->find (file, 0, 0) >=0) + { + ACE_DEBUG ((LM_WARNING, + ACE_TEXT ("ACE (%P|%t) Configuration file %s is currently") + ACE_TEXT (" being processed. Ignoring recursive process_file().\n"), + file)); + return 0; + } + + // Register a dummy service as a forward decl, using the file name as name. + // The entry will be automaticaly removed once the thread exits this block. + ACE_Service_Type_Dynamic_Guard recursion_guard (*this->repo_, + file); + + /* + * @TODO: Test with ACE_USES_CLASSIC_SVC_CONF turned off! + */ +#if (ACE_USES_CLASSIC_SVC_CONF == 1) + int result = 0; + + FILE *fp = ACE_OS::fopen (file, + ACE_TEXT ("r")); + + if (fp == 0) + { + // Invalid svc.conf file. We'll report it here and break out of + // the method. + if (ACE::debug ()) + ACE_DEBUG ((LM_ERROR, + ACE_TEXT ("ACE (%P|%t): %p\n"), + file)); + + // Use stat to find out if the file exists. I didn't use access() + // because stat is better supported on most non-unix platforms. + ACE_stat exists; + if (ACE_OS::stat (file, &exists) == 0) + // If it exists, but we couldn't open it for reading then we + // must not have permission to read it. + errno = EPERM; + else + errno = ENOENT; + result = -1; + } + else + { + ACE_Svc_Conf_Param f (this, fp); + + // Keep track of the number of errors. + result = this->process_directives_i (&f); + + (void) ACE_OS::fclose (fp); + } + return result; +#else + ACE_DLL dll; + + auto_ptr + xml_svc_conf (this->get_xml_svc_conf (dll)); + + if (xml_svc_conf.get () == 0) + return -1; + + return xml_svc_conf->parse_file (file); +#endif /* ACE_USES_CLASSIC_SVC_CONF == 1 */ +} + +int +ACE_Service_Gestalt::process_directive (const ACE_TCHAR directive[]) +{ + ACE_TRACE ("ACE_Service_Gestalt::process_directive"); + +#ifndef ACE_NLOGGING + if (ACE::debug ()) + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("ACE (%P|%t) SG::process_directive, repo=%@ - %s\n"), + this->repo_, + directive)); +#endif + +#if (ACE_USES_CLASSIC_SVC_CONF == 1) + ACE_UNUSED_ARG (directive); + + ACE_Svc_Conf_Param d (this, directive); + + return this->process_directives_i (&d); +#else + ACE_DLL dll; + + auto_ptr + xml_svc_conf (this->get_xml_svc_conf (dll)); + + if (xml_svc_conf.get () == 0) + return -1; + + // Temporarily (for the duration of this call) make sure that *any* static + // service registrations will happen with this instance. Such registrations + // are possible as a side-effect of dynamically loading a DLL, which has + // other static services registered. Thus this instance will own both the + // DLL and those static services, which implies that their finalization + // will be performed in the correct order, i.e. prior to finalizing the DLL + ACE_Service_Config_Guard guard (this); + + return xml_svc_conf->parse_string (directive); +#endif /* ACE_USES_CLASSIC_SVC_CONF == 1 */ + +} /* process_directive () */ + + +int +ACE_Service_Gestalt::init_svc_conf_file_queue (void) +{ + if (this->svc_conf_file_queue_ == 0) + { + ACE_SVC_QUEUE *tmp = 0; + ACE_NEW_RETURN (tmp, + ACE_SVC_QUEUE, + -1); + this->svc_conf_file_queue_ = tmp; + } + +#ifndef ACE_NLOGGING + if (ACE::debug ()) + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("ACE (%P|%t) SG::init_svc_conf_file_queue ") + ACE_TEXT ("- this=%@, repo=%@\n"), + this, this->repo_)); +#endif + + return 0; + +} /* init_svc_conf_file_queue () */ + + +int +ACE_Service_Gestalt::open_i (const ACE_TCHAR /*program_name*/[], + const ACE_TCHAR* /*logger_key*/, + bool ignore_static_svcs, + bool ignore_default_svc_conf_file, + bool ignore_debug_flag) +{ + ACE_TRACE ("ACE_Service_Gestalt::open_i"); + int result = 0; + ACE_Log_Msg *log_msg = ACE_LOG_MSG; + + no_static_svcs_ = ignore_static_svcs; + + // Record the current log setting upon entering this thread. + u_long old_process_mask = log_msg->priority_mask + (ACE_Log_Msg::PROCESS); + + u_long old_thread_mask = log_msg->priority_mask + (ACE_Log_Msg::THREAD); + +#ifndef ACE_NLOGGING + if (ACE::debug ()) + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("ACE (%P|%t) SG::open_i - this=%@, ") + ACE_TEXT ("opened=%d, loadstatics=%d\n"), + this, this->is_opened_, this->no_static_svcs_)); +#endif + + // Guard against reentrant processing. For example, + // if the singleton gestalt (ubergestalt) was already open, + // do not open it again... + if (this->is_opened_++ != 0) + return 0; + + if (this->init_i () != 0) + return -1; + + if (!ignore_debug_flag) + { + // If -d was included as a startup parameter, the user wants debug + // information printed during service initialization. + if (ACE::debug ()) + ACE_Log_Msg::enable_debug_messages (); + else + // The user has requested no debugging info. + ACE_Log_Msg::disable_debug_messages (); + } + + // See if we need to load the static services. + if (this->no_static_svcs_ == 0 + && this->load_static_svcs () == -1) + result = -1; + else + { + if (this->process_commandline_directives () == -1) + result = -1; + else + result = this->process_directives (ignore_default_svc_conf_file); + } + + + // Reset debugging back to the way it was when we came into + // into . + { + // Make sure to save/restore errno properly. + ACE_Errno_Guard error (errno); + + if (!ignore_debug_flag) + { + log_msg->priority_mask (old_process_mask, ACE_Log_Msg::PROCESS); + log_msg->priority_mask (old_thread_mask, ACE_Log_Msg::THREAD); + } + } + + return result; +} /* open_i () */ + + +int +ACE_Service_Gestalt::is_opened (void) +{ + return this->is_opened_; +} + +int +ACE_Service_Gestalt::process_commandline_directives (void) +{ + int result = 0; + if (this->svc_queue_ != 0) + { + ACE_TString *sptr = 0; + for (ACE_SVC_QUEUE_ITERATOR iter (*this->svc_queue_); + iter.next (sptr) != 0; + iter.advance ()) + { + // Process just a single directive. + if (this->process_directive ((sptr->fast_rep ())) != 0) + { + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("ACE (%P|%t) %p\n"), + ACE_TEXT ("process_directive"))); + result = -1; + } + } + + delete this->svc_queue_; + this->svc_queue_ = 0; + } + + return result; + +} /* process_commandline_directives () */ + + +int +ACE_Service_Gestalt::parse_args (int argc, ACE_TCHAR *argv[]) +{ + ACE_TRACE ("ACE_Service_Gestalt::parse_args"); + bool unused_ignore_default_svc_conf = true; + return parse_args_i (argc, argv, unused_ignore_default_svc_conf); +} + +int +ACE_Service_Gestalt::parse_args_i (int argc, + ACE_TCHAR *argv[], + bool &ignore_default_svc_conf_file) +{ + ACE_TRACE ("ACE_Service_Gestalt::parse_args_i"); + //FUZZ: disable check_for_lack_ACE_OS + ACE_Get_Opt getopt (argc, + argv, + ACE_TEXT ("df:k:nyS:"), + 1); // Start at argv[1]. + //FUZZ: enable check_for_lack_ACE_OS + + if (this->init_svc_conf_file_queue () == -1) + return -1; + + //FUZZ: disable check_for_lack_ACE_OS + for (int c; (argc != 0) && ((c = getopt ()) != -1); ) + //FUZZ: enable check_for_lack_ACE_OS + switch (c) + { + case 'd': + ACE::debug (1); + break; + case 'f': + if (this->svc_conf_file_queue_->enqueue_tail (ACE_TString (getopt.opt_arg ())) == -1) + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("%p\n"), + ACE_TEXT ("enqueue_tail")), + -1); + ignore_default_svc_conf_file = true; + break; + case 'k': + /* + * @TODO: Is this always a static storage? Shouldn't we copy + * & gain ownership of the value? + */ + this->logger_key_ = getopt.opt_arg (); + break; + case 'n': + this->no_static_svcs_ = 1; + break; + case 'y': + this->no_static_svcs_ = 0; + break; + case 'S': + if (this->svc_queue_ == 0) + { + ACE_NEW_RETURN (this->svc_queue_, + ACE_SVC_QUEUE, + -1); + } + + if (this->svc_queue_->enqueue_tail (ACE_TString (getopt.opt_arg ())) == -1) + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("%p\n"), + ACE_TEXT ("enqueue_tail")), + -1); + break; + default: + if (ACE::debug ()) + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("ACE (%P|%t) %c is not a ACE_Service_Config option\n"), + c)); + } + + return 0; +} /* parse_args_i () */ + + + +// Process service configuration directives from the files queued for +// processing +int +ACE_Service_Gestalt::process_directives (bool ignore_default_svc_conf_file) +{ + ACE_TRACE ("ACE_Service_Gestalt::process_directives"); + + if (this->svc_conf_file_queue_ == 0 + || this->svc_conf_file_queue_->is_empty ()) + return 0; + + ACE_TString *sptr = 0; + ACE_TString default_svc_conf (ACE_DEFAULT_SVC_CONF); + + // Iterate through all the svc.conf files. + for (ACE_SVC_QUEUE_ITERATOR iter (*this->svc_conf_file_queue_); + iter.next (sptr) != 0; + iter.advance ()) + { + if (*sptr == default_svc_conf && ignore_default_svc_conf_file) + continue; + + int result = this->process_file (sptr->fast_rep ()); + if (result < 0) + return result; + } + + return 0; + +} /* process_directives () */ + +// Tidy up and perform last rites on a terminating ACE_Service_Gestalt. +int +ACE_Service_Gestalt::close (void) +{ + ACE_TRACE ("ACE_Service_Gestalt::close"); + + if (!this->is_opened_ || --this->is_opened_ != 0) + return 0; + + // Delete the list fo svc.conf files + delete this->svc_conf_file_queue_; + this->svc_conf_file_queue_ = 0; + + if (this->processed_static_svcs_ && + !this->processed_static_svcs_->is_empty()) + { + Processed_Static_Svc **pss = 0; + for (ACE_PROCESSED_STATIC_SVCS_ITERATOR iter (*this->processed_static_svcs_); + iter.next (pss) != 0; + iter.advance ()) + { + delete *pss; + } + } + delete this->processed_static_svcs_; + this->processed_static_svcs_ = 0; + +#ifndef ACE_NLOGGING + if (ACE::debug ()) + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("ACE (%P|%t) SG::close - complete this=%@, repo=%@, owned=%d\n"), + this, this->repo_, this->svc_repo_is_owned_)); +#endif + + if (this->svc_repo_is_owned_) + delete this->repo_; + + this->repo_ = 0; + + return 0; +} /* close () */ + + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if !defined (__ACE_INLINE__) +#include "ace/Service_Gestalt.inl" +#endif /* __ACE_INLINE__ */ + +// Allocate a Service Manager. +ACE_FACTORY_DEFINE (ACE, ACE_Service_Manager) diff --git a/dep/ACE_wrappers/ace/Service_Gestalt.h b/dep/ACE_wrappers/ace/Service_Gestalt.h new file mode 100644 index 00000000000..51d3b9b2730 --- /dev/null +++ b/dep/ACE_wrappers/ace/Service_Gestalt.h @@ -0,0 +1,510 @@ +// -*- C++ -*- + +//==================================================================== +/** + * @file Service_Gestalt.h + * + * $Id: Service_Gestalt.h 81624 2008-05-06 17:14:57Z wotte $ + * + * @author Iliyan Jeliazkov + */ +//==================================================================== + +#ifndef ACE_SERVICE_GESTALT_H +#define ACE_SERVICE_GESTALT_H + +#include /**/ "ace/pre.h" + +#include /**/ "ace/config-all.h" +#include "ace/Default_Constants.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/Auto_Ptr.h" +#include "ace/SString.h" +#include "ace/Unbounded_Queue.h" +#include "ace/Unbounded_Set.h" +#include "ace/Service_Repository.h" +#include "ace/Singleton.h" +#include "ace/OS_NS_signal.h" +#include "ace/Synch_Traits.h" +#include "ace/Atomic_Op.h" +#include "ace/Guard_T.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +#if (ACE_USES_CLASSIC_SVC_CONF == 1) +class ACE_Service_Type_Factory; +class ACE_Location_Node; +#else +class ACE_XML_Svc_Conf; +class ACE_DLL; +#endif /* ACE_USES_CLASSIC_SVC_CONF == 1 */ + +class ACE_Static_Svc_Descriptor; +class ACE_Svc_Conf_Param; + +/** + * @class ACE_Service_Gestalt + * + * @brief Supplies common server operations for dynamic and static + * configuration of services. + * + * The Gestalt embodies the concept of configuration context. On one + * hand, it is a flat namespace, where names correspond to a Service + * Object instance. A Gestalt owns the Service Repository instance, + * which in turn owns the Service Object instances. + * + * Another aspect of a Gestalt is its responsibility for + * record-keeping and accounting for the meta-data, necessary for + * locating, removing or instantiating a service. + * + * A repository underlies an instance of a gestalt and its lifetime + * may or may not be bounded by the lifetime of the gestalt, that owns + * it. This feature is important for the derived classes and the + * Service Config in particular. + * + */ +class ACE_Export ACE_Service_Gestalt +{ +private: + /// + /// Not implemented to enforce no copying + // + ACE_UNIMPLEMENTED_FUNC (ACE_Service_Gestalt(const ACE_Service_Gestalt&)) + ACE_UNIMPLEMENTED_FUNC (ACE_Service_Gestalt& operator=(const ACE_Service_Gestalt&)) + +public: + enum + { + MAX_SERVICES = ACE_DEFAULT_SERVICE_REPOSITORY_SIZE + }; + + /// Constructor either associates the instance with the process-wide + /// singleton instance of ACE_Service_Repository, or creates and + /// manages its own instance of the specified size. + ACE_Service_Gestalt (size_t size = 1024, + bool svc_repo_is_owned = true, + bool no_static_svcs = true); + + /// Perform user-specified close activities and remove dynamic + /// memory. + ~ACE_Service_Gestalt (void); + + /// Dump the state of an object. + void dump (void) const; + + /** + * Performs an open without parsing command-line arguments. The + * @a logger_key indicates where to write the logging output, which + * is typically either a STREAM pipe or a socket address. If + * @a ignore_static_svcs is true then static services are not loaded, + * otherwise, they are loaded. If @a ignore_default_svc_conf_file is + * true then the configuration file will be ignored. + * Returns zero upon success, -1 if the file is not found or cannot + * be opened (errno is set accordingly), otherwise returns the + * number of errors encountered loading the services in the + * specified svc.conf configuration file. If @a ignore_debug_flag is + * true then the application is responsible for setting the + * appropriately. + */ + int open (const ACE_TCHAR program_name[], + const ACE_TCHAR *logger_key = ACE_DEFAULT_LOGGER_KEY, + bool ignore_static_svcs = true, + bool ignore_default_svc_conf_file = false, + bool ignore_debug_flag = false); + + /** + * This is the primary entry point into the ACE_Service_Config (the + * constructor just handles simple initializations). It parses + * arguments passed in from @a argc and @a argv parameters. The + * arguments that are valid in a call to this method include: + * + * - '-b' Option to indicate that we should be a daemon. Note that when + * this option is used, the process will be daemonized before the + * service configuration file(s) are read. During daemonization, + * (on POSIX systems) the current directory will be changed to "/" + * so the caller should either fully specify the file names, or + * execute a @c chroot() to the appropriate directory. + * @sa ACE::daemonize(). + * - '-d' Turn on debugging mode + * - '-f' Specifies a configuration file name other than the default + * svc.conf. Can be specified multiple times to use multiple files. + * - '-k' Specifies the rendezvous point to use for the ACE distributed + * logger. + * - '-y' Explicitly enables the use of static services. This flag + * overrides the @a ignore_static_svcs parameter value. + * - '-n' Explicitly disables the use of static services. This flag + * overrides the @a ignore_static_svcs parameter value. + * - '-p' Specifies a pathname which is used to store the process id. + * - '-s' Specifies a signal number other than SIGHUP to trigger reprocessing + * of the configuration file(s). Ignored for platforms that do not + * have POSIX signals, such as Windows. + * - '-S' Specifies a service directive string. Enclose the string in quotes + * and escape any embedded quotes with a backslash. This option + * specifies service directives without the need for a configuration + * file. + * + * @param argc The number of commandline arguments. + * @param argv The array with commandline arguments + * @param logger_key Indicates where to write the logging output, + * which is typically either a STREAM pipe or a + * socket address. + * @param ignore_static_svcs If true then static services are not loaded, + * otherwise, they are loaded. + * @param ignore_default_svc_conf_file If false then the @c svc.conf + * configuration file will be ignored. + * @param ignore_debug_flag If false then the application is responsible + * for setting the @c ACE_Log_Msg::priority_mask + * appropriately. + * + * @retval -1 The configuration file is not found or cannot + * be opened (errno is set accordingly). + * @retval 0 Success. + * @retval >0 The number of errors encountered while processing + * the service configuration file(s). + */ + int open (int argc, + ACE_TCHAR *argv[], + const ACE_TCHAR *logger_key = ACE_DEFAULT_LOGGER_KEY, + bool ignore_static_svcs = true, + bool ignore_default_svc_conf_file = false, + bool ignore_debug_flag = false); + + /// Has it been opened? Returns the difference between the times + /// open and close have been called on this instance + int is_opened (void); + + /// Declare the dynamic allocation hooks. + ACE_ALLOC_HOOK_DECLARE; + + /// Process one service configuration @a directive, which is passed as + /// a string. Returns the number of errors that occurred. + int process_directive (const ACE_TCHAR directive[]); + + /// Process one static service definition. + /** + * Load a new static service. + * + * @param ssd Service descriptor, see the document of + * ACE_Static_Svc_Descriptor for more details. + * + * @param force_replace If set the new service descriptor replaces + * any previous instance in the repository. + * + * @return Returns -1 if the service cannot be 'loaded'. + */ + int process_directive (const ACE_Static_Svc_Descriptor &ssd, + bool force_replace = false); + + /// Process a file containing a list of service configuration + /// directives. + int process_file (const ACE_TCHAR file[]); + + /** + * Locate an entry with @a name in the table. If @a ignore_suspended + * is set then only consider services marked as resumed. If the + * caller wants the located entry, pass back a pointer to the + * located entry via @a srp. If @a name is not found, -1 is returned. + * If @a name is found, but it is suspended and the caller wants to + * ignore suspended services a -2 is returned. + */ + int find (const ACE_TCHAR name[], + const ACE_Service_Type **srp = 0, + bool ignore_suspended = true) const; + + /** + * Handle the command-line options intended for the + * ACE_Service_Gestalt. Note that is assumed to be the + * program name. + * + * The arguments that are valid in a call to this method are + * - '-d' Turn on debugging mode + * - '-f' Option to read in the list of svc.conf file names + * - '-k' Option to read a wide string where in the logger output can + * be written + * - '-y' Turn on the flag for a repository of statically + * linked services + * - '-n' Need not have a repository of statically linked services + * - '-S' Option to read in the list of services on the command-line + * Please observe the difference between options '-f' that looks + * for a list of files and here a list of services. + */ + int parse_args (int, ACE_TCHAR *argv[]); + + /** + * Process (or re-process) service configuration requests that are + * provided in the svc.conf file(s). Returns the number of errors + * that occurred. + */ + int process_directives (bool ignore_default_svc_conf_file); + + /// Tidy up and perform last rites when ACE_Service_Config is shut + /// down. This method calls . Returns 0. + int close (void); + + + // Registers a service descriptor for a static service object + int insert (ACE_Static_Svc_Descriptor *stsd); + + // = Utility methods. + +#if (ACE_USES_CLASSIC_SVC_CONF == 1) + /// Dynamically link the shared object file and retrieve a pointer to + /// the designated shared object in this file. Also account for the + /// possiblity to have static services registered when loading the DLL, by + /// ensuring that the dynamic sevice is registered before any of its + /// subordibnate static services. Thus avoiding any finalization order + /// problems. + int initialize (const ACE_Service_Type_Factory *, + const ACE_TCHAR *parameters); +#endif /* (ACE_USES_CLASSIC_SVC_CONF == 1) */ + + /// Dynamically link the shared object file and retrieve a pointer to + /// the designated shared object in this file. + /// @deprecated + /// @note This is error-prone in the presense of dynamic services, + /// which in turn initialize their own static services. This method + /// will allow those static services to register *before* the dynamic + /// service that owns them. Upon finalization of the static services + /// the process will typically crash, because the dynamic service's + /// DLL may have been already released, together with the memory in + /// which the static services reside. It may not crash, for + /// instance, when the first static service to register is the same + /// as the dynamic service being loaded. You should be so lucky! + int initialize (const ACE_Service_Type *, + const ACE_TCHAR *parameters); + + /// Initialize and activate a statically @a svc_name service. + int initialize (const ACE_TCHAR *svc_name, + const ACE_TCHAR *parameters); + + /// Resume a @a svc_name that was previously suspended or has not yet + /// been resumed (e.g., a static service). + int resume (const ACE_TCHAR svc_name[]); + + /** + * Suspend @a svc_name. Note that this will not unlink the service + * from the daemon if it was dynamically linked, it will mark it as + * being suspended in the Service Repository and call the + * member function on the appropriate ACE_Service_Object. A + * service can be resumed later on by calling the member + * function... + */ + int suspend (const ACE_TCHAR svc_name[]); + + /// Totally remove @a svc_name from the daemon by removing it + /// from the ACE_Reactor, and unlinking it if necessary. + int remove (const ACE_TCHAR svc_name[]); + + /** + * Using the supplied name, finds and (if needed) returns a pointer to a + * static service descriptor. Returns 0 for success and -1 for failure + */ + int find_static_svc_descriptor (const ACE_TCHAR* name, + ACE_Static_Svc_Descriptor **ssd = 0) const; + + struct Processed_Static_Svc + { + Processed_Static_Svc (const ACE_Static_Svc_Descriptor *); + ~Processed_Static_Svc (void); + ACE_TCHAR * name_; + const ACE_Static_Svc_Descriptor *assd_; + }; + + /// Get the current ACE_Service_Repository held by this object. + ACE_Service_Repository* current_service_repository (void); + +protected: + + int parse_args_i (int, ACE_TCHAR *argv[], + bool& ignore_default_svc_conf_file); + + /** + * Performs an open without parsing command-line arguments. The + * @a logger_key indicates where to write the logging output, which + * is typically either a STREAM pipe or a socket address. If + * @a ignore_default_svc_conf_file is non-0 then the "svc.conf" file + * will be ignored. If @a ignore_debug_flag is non-0 then the + * application is responsible for setting the + * @c ACE_Log_Msg::priority_mask() appropriately. Returns number of + * errors that occurred on failure and 0 otherwise. + */ + int open_i (const ACE_TCHAR program_name[], + const ACE_TCHAR *logger_key = ACE_DEFAULT_LOGGER_KEY, + bool ignore_static_svcs = true, + bool ignore_default_svc_conf_file = false, + bool ignore_debug_flag = false); + + /// Initialize the if necessary. + int init_svc_conf_file_queue (void); + + /// Add the default statically-linked services to the + /// ACE_Service_Repository. + int load_static_svcs (void); + + /// Process service configuration requests that were provided on the + /// command-line. Returns the number of errors that occurred. + int process_commandline_directives (void); + + /// Process a static directive without also inserting its descriptor + /// the global table. This avoids multiple additions when processing + /// directives in non-global gestalts. + int process_directive_i (const ACE_Static_Svc_Descriptor &ssd, + bool force_replace = false); + +#if (ACE_USES_CLASSIC_SVC_CONF == 1) + /// This is the implementation function that process_directives() + /// and process_directive() both call. Returns the number of errors + /// that occurred. + int process_directives_i (ACE_Svc_Conf_Param *param); +#else + /// Helper function to dynamically link in the XML Service Configurator + /// parser. + ACE_XML_Svc_Conf* get_xml_svc_conf (ACE_DLL &d); +#endif /* ACE_USES_CLASSIC_SVC_CONF == 1 */ + + /// Dynamically link the shared object file and retrieve a pointer to + /// the designated shared object in this file. + int initialize_i (const ACE_Service_Type *sr, const ACE_TCHAR *parameters); + + const ACE_Static_Svc_Descriptor* find_processed_static_svc (const ACE_TCHAR*); + void add_processed_static_svc (const ACE_Static_Svc_Descriptor *); + + /// Performs the common initialization tasks for a new or previously + /// closed instance. Must not be virtual, as it is called from the + /// constructor. + int init_i (void); + +protected: + + // Maintain a queue of services to be configured from the + // command-line. + typedef ACE_Unbounded_Queue ACE_SVC_QUEUE; + typedef ACE_Unbounded_Queue_Iterator ACE_SVC_QUEUE_ITERATOR; + + // Maintain a set of the statically linked service descriptors. + typedef ACE_Unbounded_Set + ACE_STATIC_SVCS; + + typedef ACE_Unbounded_Set_Iterator + ACE_STATIC_SVCS_ITERATOR; + + typedef ACE_Unbounded_Set + ACE_PROCESSED_STATIC_SVCS; + + typedef ACE_Unbounded_Set_Iterator + ACE_PROCESSED_STATIC_SVCS_ITERATOR; + + friend class ACE_Dynamic_Service_Base; + friend class ACE_Service_Object; + friend class ACE_Service_Config; + friend class ACE_Service_Config_Guard; + +protected: + + /// Do we own the service repository instance, or have only been + /// given a ptr to the singleton? + bool svc_repo_is_owned_; + + /// Repository size is necessary, so that we can close (which may + /// destroy the repository instance), and then re-open again. + size_t svc_repo_size_; + + /// Keep track of the number of times the instance has been + /// initialized (opened). "If so, we can't allow to be called since + /// it's not reentrant" is the original motivation, but that does not seem + /// to be the case anymore. This variable is incremented by the + /// method and decremented by the + /// method. + int is_opened_; + + /// Indicates where to write the logging output. This is typically + /// either a STREAM pipe or a socket + const ACE_TCHAR *logger_key_; + + /// Should we avoid loading the static services? + bool no_static_svcs_; + + /// Queue of services specified on the command-line. + ACE_SVC_QUEUE* svc_queue_; + + /** Queue of svc.conf files specified on the command-line. + * @@ This should probably be made to handle unicode filenames... + */ + ACE_SVC_QUEUE* svc_conf_file_queue_; + + /// The service repository to hold the services. + ACE_Service_Repository* repo_; + + /// Repository of statically linked services. + ACE_STATIC_SVCS* static_svcs_; + + /// Repository of statically linked services for which process + /// directive was called, but the service is not already a member of + /// the static_svcs_ list. + ACE_PROCESSED_STATIC_SVCS* processed_static_svcs_; + + /// Support for intrusive reference counting + ACE_Atomic_Op refcnt_; + + public: + static void intrusive_add_ref (ACE_Service_Gestalt*); + static void intrusive_remove_ref (ACE_Service_Gestalt*); + +}; /* class ACE_Service_Gestalt */ + + +/** + * @class ACE_Service_Type_Dynamic_Guard + * + * @brief A forward service declaration guard. + * + * Helps to resolve an issue with hybrid services, i.e. dynamic + * services, accompanied by static services in the same DLL. Only + * automatic instances of this class are supposed to exist. Those are + * created during (dynamic) service initialization and serve to: + * + * (a) Ensure the service we are loading is ordered last in the + * repository, following any other services it may cause to register, + * as part of its own registration. This is a common case when + * loading dynamic services from DLLs - there are often static + * initializers, which register static services. + * + * (b) The SDG instance destructor detects if the dynamic service + * initialized successfully and "fixes-up" all the newly registered + * static services to hold a reference to the DLL, from which they + * have originated. + */ +class ACE_Export ACE_Service_Type_Dynamic_Guard +{ +public: + ACE_Service_Type_Dynamic_Guard (ACE_Service_Repository &r, + ACE_TCHAR const *name); + + ~ACE_Service_Type_Dynamic_Guard (void); + +private: + ACE_Service_Repository & repo_; + size_t repo_begin_; + ACE_TCHAR const * const name_; + + +# if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0) + ACE_Guard< ACE_Recursive_Thread_Mutex > repo_monitor_; +#endif +}; + + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +#include "ace/Service_Gestalt.inl" +#endif /* __ACE_INLINE__ */ + + +#include /**/ "ace/post.h" + +#endif /* ACE_SERVICE_GESTALT_H */ diff --git a/dep/ACE_wrappers/ace/Service_Gestalt.inl b/dep/ACE_wrappers/ace/Service_Gestalt.inl new file mode 100644 index 00000000000..d7de81361ec --- /dev/null +++ b/dep/ACE_wrappers/ace/Service_Gestalt.inl @@ -0,0 +1,76 @@ +// -*- C++ -*- +// +// $Id: Service_Gestalt.inl 81388 2008-04-23 14:02:05Z johnnyw $ + + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + + +// This is the primary entry point into the ACE_Service_Config (the +// constructor just handles simple initializations). + +ACE_INLINE int +ACE_Service_Gestalt::open (const ACE_TCHAR program_name[], + const ACE_TCHAR *logger_key, + bool ignore_static_svcs, + bool ignore_default_svc_conf, + bool ignore_debug_flag) +{ + ACE_TRACE ("ACE_Service_Gestalt::open"); + this->no_static_svcs_ = ignore_static_svcs; + + return this->open_i (program_name, + logger_key, + ignore_static_svcs, + ignore_default_svc_conf, + ignore_debug_flag); +} + +ACE_INLINE int +ACE_Service_Gestalt::open (int argc, + ACE_TCHAR *argv[], + const ACE_TCHAR *logger_key, + bool ignore_static_svcs, + bool ignore_default_svc_conf, + bool ignore_debug_flag) +{ + ACE_TRACE ("ACE_Service_Gestalt::open"); + + this->no_static_svcs_ = ignore_static_svcs; + + if (this->parse_args_i (argc, + argv, + ignore_default_svc_conf) == -1) + return -1; + + return this->open_i (argv == 0 ? 0 : argv[0], + logger_key, + ignore_static_svcs, + ignore_default_svc_conf, + ignore_debug_flag); +} + +/// Searches for a service object declaration in the local repo, only + +ACE_INLINE int +ACE_Service_Gestalt::find (const ACE_TCHAR name[], + const ACE_Service_Type **srp, + bool ignore_suspended) const +{ + // Closing the gestalt will have disassociated it from the + // repository. If the repository used to be owned by the gestalt, it + // will also have been destroyed - so just check for repo_ before + // doing anything with it. + if (this->repo_ != 0) + return this->repo_->find (name, srp, ignore_suspended); + + return 0; +} + +ACE_INLINE ACE_Service_Repository* +ACE_Service_Gestalt::current_service_repository (void) +{ + return this->repo_; +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Service_Manager.cpp b/dep/ACE_wrappers/ace/Service_Manager.cpp new file mode 100644 index 00000000000..54ceb67f636 --- /dev/null +++ b/dep/ACE_wrappers/ace/Service_Manager.cpp @@ -0,0 +1,437 @@ +// $Id: Service_Manager.cpp 82513 2008-08-05 18:52:53Z parsons $ + +#include "ace/Service_Manager.h" + +#include "ace/Get_Opt.h" +#include "ace/Log_Msg.h" +#include "ace/Service_Repository.h" +#include "ace/Service_Config.h" +#include "ace/Service_Types.h" +#include "ace/Reactor.h" +#include "ace/WFMO_Reactor.h" +#include "ace/OS_NS_stdio.h" +#include "ace/OS_NS_string.h" + +ACE_RCSID (ace, + Service_Manager, + "$Id: Service_Manager.cpp 82513 2008-08-05 18:52:53Z parsons $") + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_ALLOC_HOOK_DEFINE (ACE_Service_Manager) + +void +ACE_Service_Manager::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + ACE_TRACE ("ACE_Service_Manager::dump"); +#endif /* ACE_HAS_DUMP */ +} + +// Static variables. + +u_short ACE_Service_Manager::DEFAULT_PORT_ = 10000; + +ACE_Service_Manager::ACE_Service_Manager (void) + : debug_ (false), + signum_ (SIGHUP) +{ + ACE_TRACE ("ACE_Service_Manager::ACE_Service_Manager"); +} + +ACE_Service_Manager::~ACE_Service_Manager (void) +{ + ACE_TRACE ("ACE_Service_Manager::~ACE_Service_Manager"); +} + +int +ACE_Service_Manager::suspend (void) +{ + ACE_TRACE ("ACE_Service_Manager::suspend"); + return ACE_Reactor::instance ()->suspend_handler (this); +} + +int +ACE_Service_Manager::resume (void) +{ + ACE_TRACE ("ACE_Service_Manager::resume"); + return ACE_Reactor::instance ()->resume_handler (this); +} + +int +ACE_Service_Manager::open (const ACE_INET_Addr &sia) +{ + ACE_TRACE ("ACE_Service_Manager::open"); + + // Reuse the listening address, even if it's already in use! + if (this->acceptor_.open (sia, 1) == -1) + { + return -1; + } + + return 0; +} + +int +ACE_Service_Manager::info (ACE_TCHAR **strp, size_t length) const +{ + ACE_TRACE ("ACE_Service_Manager::info"); + ACE_INET_Addr sa; + ACE_TCHAR buf[BUFSIZ]; + + if (this->acceptor_.get_local_addr (sa) == -1) + { + return -1; + } + + ACE_OS::sprintf (buf, + ACE_TEXT ("%d/%s %s"), + sa.get_port_number (), + ACE_TEXT ("tcp"), + ACE_TEXT ("# lists all services in the daemon\n")); + + if (*strp == 0 && (*strp = ACE_OS::strdup (buf)) == 0) + { + return -1; + } + else + { + ACE_OS::strsncpy (*strp, buf, length); + } + + return static_cast (ACE_OS::strlen (buf)); +} + +int +ACE_Service_Manager::init (int argc, ACE_TCHAR *argv[]) +{ + ACE_TRACE ("ACE_Service_Manager::init"); + ACE_INET_Addr local_addr (ACE_Service_Manager::DEFAULT_PORT_); + + //FUZZ: disable check_for_lack_ACE_OS + ACE_Get_Opt getopt (argc, argv, ACE_TEXT ("dp:s:"), 0); // Start at argv[0] + + for (int c; (c = getopt ()) != -1; ) + //FUZZ: enable check_for_lack_ACE_OS + switch (c) + { + case 'd': + this->debug_ = true; + break; + case 'p': + local_addr.set ((u_short) ACE_OS::atoi (getopt.opt_arg ())); + break; + case 's': + this->signum_ = ACE_OS::atoi (getopt.opt_arg ()); + break; + default: + break; + } + + if (this->get_handle () == ACE_INVALID_HANDLE && + this->open (local_addr) == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("%p\n"), + ACE_TEXT ("open")), -1); + } + else if (ACE_Reactor::instance ()->register_handler + (this, + ACE_Event_Handler::ACCEPT_MASK) == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("registering service with ACE_Reactor\n")), + -1); + } + + return 0; +} + +int +ACE_Service_Manager::handle_close (ACE_HANDLE, ACE_Reactor_Mask) +{ + ACE_TRACE ("ACE_Service_Manager::handle_close"); + return this->acceptor_.close (); +} + +int +ACE_Service_Manager::fini (void) +{ + ACE_TRACE ("ACE_Service_Manager::fini"); + + int retv = 0; + + if (this->get_handle () != ACE_INVALID_HANDLE) + { + retv = + ACE_Reactor::instance ()->remove_handler ( + this, + ACE_Event_Handler::ACCEPT_MASK | ACE_Event_Handler::DONT_CALL); + + this->handle_close (ACE_INVALID_HANDLE, + ACE_Event_Handler::NULL_MASK); + } + + return retv; +} + +ACE_HANDLE +ACE_Service_Manager::get_handle (void) const +{ + ACE_TRACE ("ACE_Service_Manager::get_handle"); + return this->acceptor_.get_handle (); +} + +int +ACE_Service_Manager::handle_signal (int, siginfo_t *, ucontext_t *) +{ + return 0; +} + +// Determine all the services offered by this daemon and return the +// information back to the client. + +int +ACE_Service_Manager::list_services (void) +{ + ACE_TRACE ("ACE_Service_Manager::list_services"); + ACE_Service_Repository_Iterator sri (*ACE_Service_Repository::instance (), 0); + + for (const ACE_Service_Type *sr; + sri.next (sr) != 0; + sri.advance ()) + { + ssize_t len = static_cast (ACE_OS::strlen (sr->name ())) + 11; + ACE_TCHAR buf[BUFSIZ]; + ACE_TCHAR *p = buf + len; + + ACE_OS::strcpy (buf, sr->name ()); + ACE_OS::strcat (buf, (sr->active ()) ? + ACE_TEXT (" (active) ") : + ACE_TEXT (" (paused) ")); + + p[-1] = ' '; + p[0] = '\0'; + + len += sr->type ()->info (&p, sizeof buf - len); + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("len = %d, info = %s%s"), + len, + buf, + buf[len - 1] == '\n' ? ACE_TEXT ("") : ACE_TEXT ("\n"))); + } + + if (len > 0) + { + ssize_t n = this->client_stream_.send_n (buf, len); + + if (n <= 0 && errno != EPIPE) + { + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("%p\n"), + ACE_TEXT ("send_n"))); + } + } + } + + return 0; +} + +// Trigger a reconfiguration of the Service Configurator via its +// svc.conf file. + +int +ACE_Service_Manager::reconfigure_services (void) +{ + ACE_TRACE ("ACE_Service_Manager::reconfigure_services"); + +#if 0 +// Send ourselves a signal! ACE_OS::kill (ACE_OS::getpid (), +// this->signum_); +#endif /* 0 */ + + // Flag the main event loop that a reconfiguration should occur. + // The next trip through the should + // pick this up and cause a reconfiguration. Note that we can't + // trigger the reconfiguration automatically since that might "pull + // the rug" out from underneath the existing services in a + // problematic way. + ACE_Service_Config::reconfig_occurred ((sig_atomic_t) 1); + return static_cast (this->client_stream_.send_n ("done\n", + sizeof ("done\n"))); +} + +// isolate the request-processing code +void +ACE_Service_Manager::process_request (ACE_TCHAR *request) +{ + ACE_TRACE("ACE_Service_Manager::process_request"); + ACE_TCHAR *p; + + // Kill trailing newlines. + for (p = request; + (*p != '\0') && (*p != '\r') && (*p != '\n'); + p++) + { + continue; + } + + *p = '\0'; + + if (ACE_OS::strcmp (request, ACE_TEXT ("help")) == 0) + { + // Return a list of the configured services. + this->list_services (); + } + else if (ACE_OS::strcmp (request, ACE_TEXT ("reconfigure") )== 0) + { + // Trigger a reconfiguration by re-reading the local file. + this->reconfigure_services (); + } + else + { + // Just process a single request passed in via the socket + // remotely. + ACE_Service_Config_Guard guard (ACE_Service_Config::global ()); + ACE_Service_Config::process_directive (request); + } + + // Additional management services may be handled here... +} + +// Accept new connection from client and carry out the service they +// request. + +int +ACE_Service_Manager::handle_input (ACE_HANDLE) +{ + ACE_TRACE ("ACE_Service_Manager::handle_input"); + + // Try to find out if the implementation of the reactor that we are + // using requires us to reset the event association for the newly + // created handle. This is because the newly created handle will + // inherit the properties of the listen handle, including its event + // associations. + int reset_new_handle = + ACE_Reactor::instance ()->uses_event_associations (); + + if (this->acceptor_.accept (this->client_stream_, // stream + 0, // remote address + 0, // timeout + 1, // restart + reset_new_handle // reset new handler + ) == -1) + { + return -1; + } + + if (this->debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("client_stream fd = %d\n"), + this->client_stream_.get_handle ())); + ACE_INET_Addr sa; + + if (this->client_stream_.get_remote_addr (sa) == -1) + { + return -1; + } + + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("accepted from host %C at port %d\n"), + sa.get_host_name (), + sa.get_port_number ())); + } + + ACE_TCHAR request[BUFSIZ]; + ACE_TCHAR* offset = request; + ssize_t remaining = sizeof (request); + + // Read service request from client. + + ssize_t result; + + // Keep looping until we actually get the request. Note that Win32 + // sets the socket into non-blocking mode, so we may need to loop if + // the system is heavily loaded. Read bytes into the buffer until a + // '\n' or '\r' is found in the buffer, otherwise the buffer + // contains an incomplete string. + + int error; + + do + { + result = client_stream_.recv (offset, remaining); + error = errno; + + if (result == 0 && error != EWOULDBLOCK) + { + remaining = 0; + } + + if (result >= 0) + { + if ((remaining -= result) <= 0) + { + ACE_DEBUG ((LM_ERROR, + ACE_TEXT ("Request buffer overflow.\n"))); + result = 0; + break; + } + + offset += result; + *offset = 0; + + if (ACE_OS::strchr (request, '\r') != 0 + || ACE_OS::strchr (request, '\n') != 0) + { + remaining = 0; + } + } + } + while ((result == -1 && error == EWOULDBLOCK) || remaining > 0); + + switch (result) + { + case -1: + if (this->debug_) + { + ACE_DEBUG ((LM_ERROR, + ACE_TEXT ("%p\n"), + ACE_TEXT ("recv"))); + } + + break; + case 0: + return 0; + /* NOTREACHED */ + default: + { + ACE_Event_Handler *old_signal_handler = 0; + ACE_Reactor::instance ()->register_handler (SIGPIPE, + this, + 0, + &old_signal_handler); + + this->process_request (request); + + // Restore existing SIGPIPE handler + ACE_Reactor::instance ()->register_handler (SIGPIPE, + old_signal_handler); + } + } + + if (this->client_stream_.close () == -1 && this->debug_) + { + ACE_DEBUG ((LM_ERROR, + ACE_TEXT ("%p\n"), + ACE_TEXT ("close"))); + } + + return 0; +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Service_Manager.h b/dep/ACE_wrappers/ace/Service_Manager.h new file mode 100644 index 00000000000..13ce60405ff --- /dev/null +++ b/dep/ACE_wrappers/ace/Service_Manager.h @@ -0,0 +1,120 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Service_Manager.h + * + * $Id: Service_Manager.h 81388 2008-04-23 14:02:05Z johnnyw $ + * + * @author Douglas C. Schmidt + */ +//============================================================================= + +#ifndef ACE_SERVICE_MANAGER_H +#define ACE_SERVICE_MANAGER_H +#include /**/ "ace/pre.h" + +#include "ace/SOCK_Stream.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/SOCK_Acceptor.h" +#include "ace/INET_Addr.h" +#include "ace/Service_Object.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +/** + * @class ACE_Service_Manager + * + * @brief Provide a standard ACE service for managing all the services + * configured in an ACE_Service_Repository. + * + * This implementation is simple and just handles each client + * request one at a time. There are currently 3 types of requests: + * - List services: If the string "help" is sent, return a list of all + * the services supported by the Service Configurator. + * - Reconfigure: If the string "reconfigure" is sent trigger a + * reconfiguration, which will re-read the local file. + * - Process directive: If neither "help" nor "reconfigure" is sent, + * simply treat the incoming string as a process directive and pass + * it along to . This allows + * remote configuration via command-line instructions like + * % echo suspend My_Remote_Service | telnet hostname 3911 + * + * Each request is associated with a new connection, which is closed + * when the request is processed. In addition, you must be using the + * singleton in order to trigger + * reconfigurations. + */ +class ACE_Export ACE_Service_Manager : public ACE_Service_Object +{ +public: + // = Initialization and termination hooks. + /// Constructor. + ACE_Service_Manager (void); + + /// Destructor. + virtual ~ACE_Service_Manager (void); + +protected: + // = Perform the various meta-services. + + /// Trigger a reconfiguration of the Service Configurator by + /// re-reading its local file. + virtual int reconfigure_services (void); + + /// Determine all the services offered by this daemon and return the + /// information back to the client. + virtual int list_services (void); + + // = Dynamic linking hooks. + virtual int init (int argc, ACE_TCHAR *argv[]); + virtual int info (ACE_TCHAR **info_string, size_t length) const; + virtual int fini (void); + + // = Scheduling hooks. + virtual int suspend (void); + virtual int resume (void); + + /// Dump the state of an object. + void dump (void) const; + + /// Declare the dynamic allocation hooks. + ACE_ALLOC_HOOK_DECLARE; + +protected: + int open (const ACE_INET_Addr &sia); + + // = Demultiplexing hooks. + virtual ACE_HANDLE get_handle (void) const; + virtual int handle_input (ACE_HANDLE fd); + virtual int handle_close (ACE_HANDLE fd, ACE_Reactor_Mask); + virtual int handle_signal (int signum, siginfo_t *, ucontext_t *); + + /// Handle one request. + virtual void process_request (ACE_TCHAR *request); + + /// Connection to the client (we only support one client connection + /// at a time). + ACE_SOCK_Stream client_stream_; + + /// Acceptor instance. + ACE_SOCK_Acceptor acceptor_; + + /// Keep track whether we debug or not. + bool debug_; + + /// The signal used to trigger reconfiguration. + int signum_; + + /// Default port for the Acceptor to listen on. + static u_short DEFAULT_PORT_; +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#include /**/ "ace/post.h" +#endif /* _SERVICE_MANAGER_H */ diff --git a/dep/ACE_wrappers/ace/Service_Object.cpp b/dep/ACE_wrappers/ace/Service_Object.cpp new file mode 100644 index 00000000000..33e27eb35c5 --- /dev/null +++ b/dep/ACE_wrappers/ace/Service_Object.cpp @@ -0,0 +1,180 @@ +// $Id: Service_Object.cpp 81826 2008-06-02 15:29:53Z schmidt $ + +#include "ace/config-all.h" + +#include "ace/Service_Object.h" + +#if !defined (__ACE_INLINE__) +#include "ace/Service_Object.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/OS_NS_stdio.h" +#include "ace/Service_Types.h" +#include "ace/DLL.h" +#include "ace/ACE.h" +#include "ace/Log_Msg.h" +#if defined (ACE_OPENVMS) +# include "ace/Lib_Find.h" +#endif + +ACE_RCSID (ace, + Service_Object, + "$Id: Service_Object.cpp 81826 2008-06-02 15:29:53Z schmidt $") + + ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_ALLOC_HOOK_DEFINE(ACE_Service_Object) + ACE_ALLOC_HOOK_DEFINE(ACE_Service_Type) + + void +ACE_Service_Type::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + ACE_TRACE ("ACE_Service_Type::dump"); +#endif /* ACE_HAS_DUMP */ + + + // Using printf, since the log facility may not have been + // initialized yet. Using a "//" prefix, in case the executable + // happens to be a code generator and the output gets embedded in + // the generated C++ code. + ACE_OS::fprintf(stderr, + "// [ST] dump, this=%p, name=%s, type=%p, so=%p, active=%d\n", + this, + this->name_, + this->type_, + (this->type_ != 0) ? this->type_->object () : 0, + this->active_); + +} + +ACE_Service_Type::ACE_Service_Type (const ACE_TCHAR *n, + ACE_Service_Type_Impl *t, + const ACE_DLL &dll, + bool active) + : name_ (0), + type_ (t), + dll_ (dll), + active_ (active), + fini_already_called_ (false) +{ + ACE_TRACE ("ACE_Service_Type::ACE_Service_Type"); + this->name (n); +} + +ACE_Service_Type::ACE_Service_Type (const ACE_TCHAR *n, + ACE_Service_Type_Impl *t, + ACE_SHLIB_HANDLE handle, + bool active) + : name_ (0), + type_ (t), + active_ (active), + fini_already_called_ (false) +{ + ACE_TRACE ("ACE_Service_Type::ACE_Service_Type"); + this->dll_.set_handle (handle); + this->name (n); +} + +ACE_Service_Type::~ACE_Service_Type (void) +{ + ACE_TRACE ("ACE_Service_Type::~ACE_Service_Type"); + this->fini (); + + delete [] const_cast (this->name_); +} + +int +ACE_Service_Type::fini (void) +{ + if (ACE::debug ()) + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("ACE (%P|%t) ST::fini - destroying name=%s, dll=%s\n"), + this->name_, + this->dll_.dll_name_)); + + if (this->fini_already_called_) + return 0; + + this->fini_already_called_ = true; + + if (this->type_ == 0) + { + // Returning 1 currently only makes sense for dummy instances, used + // to "reserve" a spot (kind of like forward-declarations) for a + // dynamic service. This is necessary to help enforce the correct + // finalization order, when such service also has any (dependent) + // static services + + return 1; // No implementation was found. + } + + int ret = this->type_->fini (); + + // Ensure that closing the DLL is done after type_->fini() as it may + // require access to the code for the service object destructor, + // which resides in the DLL + + return (ret | this->dll_.close ()); +} + +int +ACE_Service_Type::suspend (void) const +{ + ACE_TRACE ("ACE_Service_Type::suspend"); + (const_cast (this))->active_ = false; + return this->type_->suspend (); +} + +int +ACE_Service_Type::resume (void) const +{ + ACE_TRACE ("ACE_Service_Type::resume"); + (const_cast (this))->active_ = true; + return this->type_->resume (); +} + +ACE_Service_Object::ACE_Service_Object (ACE_Reactor *r) + : ACE_Event_Handler (r) +{ + ACE_TRACE ("ACE_Service_Object::ACE_Service_Object"); +} + +ACE_Service_Object::~ACE_Service_Object (void) +{ + ACE_TRACE ("ACE_Service_Object::~ACE_Service_Object"); +} + +int +ACE_Service_Object::suspend (void) +{ + ACE_TRACE ("ACE_Service_Object::suspend"); + return 0; +} + +int +ACE_Service_Object::resume (void) +{ + ACE_TRACE ("ACE_Service_Object::resume"); + return 0; +} + +void +ACE_Service_Type::name (const ACE_TCHAR *n) +{ + ACE_TRACE ("ACE_Service_Type::name"); + + delete [] const_cast (this->name_); + this->name_ = ACE::strnew (n); +} + +#if defined (ACE_OPENVMS) +ACE_Dynamic_Svc_Registrar::ACE_Dynamic_Svc_Registrar (const ACE_TCHAR* alloc_name, + void* svc_allocator) +{ + // register service allocator function by full name in ACE singleton registry + ACE::ldregister (alloc_name, svc_allocator); +} +#endif + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Service_Object.h b/dep/ACE_wrappers/ace/Service_Object.h new file mode 100644 index 00000000000..d64cebba6c4 --- /dev/null +++ b/dep/ACE_wrappers/ace/Service_Object.h @@ -0,0 +1,207 @@ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file Service_Object.h + * + * $Id: Service_Object.h 81388 2008-04-23 14:02:05Z johnnyw $ + * + * @author Douglas C. Schmidt + */ +//============================================================================= + +#ifndef ACE_SERVICE_OBJECT_H +#define ACE_SERVICE_OBJECT_H +#include /**/ "ace/pre.h" + +#include "ace/Shared_Object.h" +#include "ace/Svc_Conf_Tokens.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/Event_Handler.h" +#include "ace/DLL.h" + +#include "ace/Service_Gestalt.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +#define ACE_Component ACE_Service_Object + +/** + * @class ACE_Service_Object + * + * @brief Provide the abstract base class common to all service + * implementations. + * + * Classes that inherit from ACE_Service_Objects are capable + * of being registered with the ACE_Reactor (due to the + * ACE_Event_Handler, as well as being dynamically linked by + * the ACE_Service_Config (due to the ACE_Shared_Object). + */ +class ACE_Export ACE_Service_Object + : public ACE_Event_Handler, + public ACE_Shared_Object +{ +public: + // = Initialization and termination methods. + /// Constructor. + ACE_Service_Object (ACE_Reactor * = 0); + + /// Destructor. + virtual ~ACE_Service_Object (void); + + /// Temporarily disable a service without removing it completely. + virtual int suspend (void); + + /// Re-enable a previously suspended service. + virtual int resume (void); +}; + +// Forward decl. +class ACE_Service_Type_Impl; + +/** + * @class ACE_Service_Type + * + * @brief Keeps track of information related to the various + * ACE_Service_Type_Impl subclasses. + * + * This class acts as the interface of the "Bridge" pattern. + */ +class ACE_Export ACE_Service_Type +{ +public: + enum + { + /// Delete the payload object. + DELETE_OBJ = 1, + + /// Delete the enclosing object. + DELETE_THIS = 2 + }; + + enum + { + SERVICE_OBJECT = ACE_SVC_OBJ_T, + MODULE = ACE_MODULE_T, + STREAM = ACE_STREAM_T, + INVALID_TYPE = -1 + }; + + // = Initialization and termination methods. + ACE_Service_Type (const ACE_TCHAR *n, + ACE_Service_Type_Impl *o, + const ACE_DLL &dll, + bool active); + ACE_Service_Type (const ACE_TCHAR *n, + ACE_Service_Type_Impl *o, + ACE_SHLIB_HANDLE handle, + bool active); + ~ACE_Service_Type (void); + + const ACE_TCHAR *name (void) const; + void name (const ACE_TCHAR *); + + const ACE_Service_Type_Impl *type (void) const; + void type (const ACE_Service_Type_Impl *, bool active = true); + + /// Is this just a stub for the real thing? + bool is_forward_declaration (void) const; + + int suspend (void) const; + int resume (void) const; + bool active (void) const; + void active (bool turnon); + + /// Calls on + int fini (void); + + /// Check if the service has been fini'ed. + bool fini_called (void) const; + + /// Dump the state of an object. + void dump (void) const; + + /// Get to the DLL's implentation + const ACE_DLL & dll (void) const; + + /// Sets the DLL + void dll (const ACE_DLL&); + + /// Declare the dynamic allocation hooks. + ACE_ALLOC_HOOK_DECLARE; + +private: + /// Humanly readible name of svc. + const ACE_TCHAR *name_; + + /// Pointer to C++ object that implements the svc. + const ACE_Service_Type_Impl *type_; + + /// ACE_DLL representing the shared object file (non-zero if + /// dynamically linked). + mutable ACE_DLL dll_; + + /// true if svc is currently active, otherwise false. + bool active_; + + /// true if on has already been called, otherwise false. + bool fini_already_called_; +}; + +/** + * @class ACE_Service_Object_Ptr + * + * @brief This is a smart pointer that holds onto the associated + * ACE_Service_Object * until the current scope is left, at + * which point the object's hook is called and the + * service_object_ gets deleted. + * + * This class is similar to the Standard C++ Library class + * . It is used in conjunction with statically linked + * , as shown in the + * ./netsvcs/server/main.cpp example. + */ +class ACE_Export ACE_Service_Object_Ptr +{ +public: + // = Initialization and termination methods. + /// Acquire ownership of the @a so. + ACE_Service_Object_Ptr (ACE_Service_Object *so); + + /// Release the held ACE_Service_Object by calling its hook. + ~ACE_Service_Object_Ptr (void); + + /// Smart pointer to access the underlying ACE_Service_Object. + ACE_Service_Object *operator-> (); + +private: + /// Holds the service object until we're done. + ACE_Service_Object *service_object_; +}; + +#if defined (ACE_OPENVMS) +/** + * @class ACE_Dynamic_Svc_Registrar + * + * @brief Used to register Service allocator function by its full name. + */ +class ACE_Dynamic_Svc_Registrar +{ +public: + ACE_Dynamic_Svc_Registrar (const ACE_TCHAR* alloc_name, + void* svc_allocator); +}; +#endif + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +#include "ace/Service_Object.inl" +#endif /* __ACE_INLINE__ */ + +#include /**/ "ace/post.h" +#endif /* ACE_SERVICE_OBJECT_H */ diff --git a/dep/ACE_wrappers/ace/Service_Object.inl b/dep/ACE_wrappers/ace/Service_Object.inl new file mode 100644 index 00000000000..6283f3e9981 --- /dev/null +++ b/dep/ACE_wrappers/ace/Service_Object.inl @@ -0,0 +1,79 @@ +// -*- C++ -*- +// $Id: Service_Object.inl 81388 2008-04-23 14:02:05Z johnnyw $ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_INLINE ACE_Service_Object_Ptr::ACE_Service_Object_Ptr (ACE_Service_Object *so) + : service_object_ (so) +{ +} + +ACE_INLINE ACE_Service_Object_Ptr::~ACE_Service_Object_Ptr (void) +{ + this->service_object_->fini (); + delete this->service_object_; +} + +ACE_INLINE ACE_Service_Object * +ACE_Service_Object_Ptr::operator-> () +{ + return this->service_object_; +} + +ACE_INLINE const ACE_TCHAR * +ACE_Service_Type::name (void) const +{ + ACE_TRACE ("ACE_Service_Type::name"); + return this->name_; +} + +ACE_INLINE const ACE_Service_Type_Impl * +ACE_Service_Type::type (void) const +{ + ACE_TRACE ("ACE_Service_Type::type"); + return this->type_; +} + +ACE_INLINE void +ACE_Service_Type::type (const ACE_Service_Type_Impl *o, bool enabled) +{ + ACE_TRACE ("ACE_Service_Type::type"); + this->type_ = o; + ((ACE_Service_Type *) this)->active_ = enabled; +} + +ACE_INLINE bool +ACE_Service_Type::active (void) const +{ + ACE_TRACE ("ACE_Service_Type::active"); + return this->active_; +} + +ACE_INLINE void +ACE_Service_Type::active (bool turnon) +{ + ACE_TRACE ("ACE_Service_Type::active"); + this->active_ = turnon; +} + +ACE_INLINE bool +ACE_Service_Type::fini_called (void) const +{ + ACE_TRACE ("ACE_Service_Type::fini_called"); + return this->fini_already_called_; +} + +ACE_INLINE const ACE_DLL & ACE_Service_Type::dll () const +{ + ACE_TRACE ("ACE_Service_Type::dll"); + return this->dll_; +} + +ACE_INLINE void ACE_Service_Type::dll (const ACE_DLL &adll) +{ + ACE_TRACE ("ACE_Service_Type::dll"); + this->dll_ = adll; +} + +ACE_END_VERSIONED_NAMESPACE_DECL + diff --git a/dep/ACE_wrappers/ace/Service_Repository.cpp b/dep/ACE_wrappers/ace/Service_Repository.cpp new file mode 100644 index 00000000000..18fafe05be7 --- /dev/null +++ b/dep/ACE_wrappers/ace/Service_Repository.cpp @@ -0,0 +1,637 @@ +// $Id: Service_Repository.cpp 81388 2008-04-23 14:02:05Z johnnyw $ + +#include "ace/Service_Repository.h" + +#if !defined (__ACE_INLINE__) +#include "ace/Service_Repository.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/Service_Types.h" +#include "ace/Object_Manager.h" +#include "ace/Log_Msg.h" +#include "ace/ACE.h" +#include "ace/OS_NS_unistd.h" +#include "ace/OS_NS_errno.h" +#include "ace/OS_NS_string.h" + +ACE_RCSID (ace, + Service_Repository, + "$Id: Service_Repository.cpp 81388 2008-04-23 14:02:05Z johnnyw $") + + ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_ALLOC_HOOK_DEFINE(ACE_Service_Repository) + +// Process-wide Service Repository. +ACE_Service_Repository *ACE_Service_Repository::svc_rep_ = 0; + +// Controls whether the Service_Repository is deleted when we shut +// down (we can only delete it safely if we created it)! +bool ACE_Service_Repository::delete_svc_rep_ = false; + +void +ACE_Service_Repository::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + ACE_TRACE ("ACE_Service_Repository::dump"); +#endif /* ACE_HAS_DUMP */ +} + +ACE_Service_Repository::ACE_Service_Repository (void) + : service_vector_ (0), + current_size_ (0), + total_size_ (0) +{ + ACE_TRACE ("ACE_Service_Repository::ACE_Service_Repository"); +} + +ACE_Service_Repository * +ACE_Service_Repository::instance (size_t size /* = ACE_Service_Repository::DEFAULT_SIZE */) +{ + ACE_TRACE ("ACE_Service_Repository::instance"); + + if (ACE_Service_Repository::svc_rep_ == 0) + { + // Perform Double-Checked Locking Optimization. + ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon, + *ACE_Static_Object_Lock::instance (), 0)); + if (ACE_Service_Repository::svc_rep_ == 0) + { + if (ACE_Object_Manager::starting_up () || + !ACE_Object_Manager::shutting_down ()) + { + ACE_NEW_RETURN (ACE_Service_Repository::svc_rep_, + ACE_Service_Repository (size), + 0); + ACE_Service_Repository::delete_svc_rep_ = true; + } + } + } + + return ACE_Service_Repository::svc_rep_; +} + +ACE_Service_Repository * +ACE_Service_Repository::instance (ACE_Service_Repository *s) +{ + ACE_TRACE ("ACE_Service_Repository::instance"); + ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon, + *ACE_Static_Object_Lock::instance (), 0)); + + ACE_Service_Repository *t = ACE_Service_Repository::svc_rep_; + // We can't safely delete it since we don't know who created it! + ACE_Service_Repository::delete_svc_rep_ = false; + + ACE_Service_Repository::svc_rep_ = s; + return t; +} + +void +ACE_Service_Repository::close_singleton (void) +{ + ACE_TRACE ("ACE_Service_Repository::close_singleton"); + + ACE_MT (ACE_GUARD (ACE_Recursive_Thread_Mutex, ace_mon, + *ACE_Static_Object_Lock::instance ())); + + if (ACE_Service_Repository::delete_svc_rep_) + { + delete ACE_Service_Repository::svc_rep_; + ACE_Service_Repository::svc_rep_ = 0; + ACE_Service_Repository::delete_svc_rep_ = false; + } +} + +// Initialize the Repository to a clean slate. + +int +ACE_Service_Repository::open (size_t size) +{ + ACE_TRACE ("ACE_Service_Repository::open"); + + ACE_Service_Type **temp = 0; + + ACE_NEW_RETURN (temp, + ACE_Service_Type *[size], + -1); + + this->service_vector_ = const_cast (temp); + this->total_size_ = size; + return 0; +} + +ACE_Service_Repository::ACE_Service_Repository (size_t size) + : current_size_ (0) +{ + ACE_TRACE ("ACE_Service_Repository::ACE_Service_Repository"); + + if (this->open (size) == -1) + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("%p\n"), + ACE_TEXT ("ACE_Service_Repository"))); +} + +// Finalize (call and possibly delete) all the services. + +int +ACE_Service_Repository::fini (void) +{ + ACE_TRACE ("ACE_Service_Repository::fini"); + ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon, this->lock_, -1)); + + if (this->service_vector_ == 0) + return 0; + + int retval = 0; + + // Do not be tempted to use the prefix decrement operator. Use + // postfix decrement operator since the index is unsigned and may + // wrap around the 0 + for (size_t i = this->current_size_; i-- != 0; ) + { + // the services in reverse order. + ACE_Service_Type *s = + const_cast (this->service_vector_[i]); + +#ifndef ACE_NLOGGING + if (ACE::debug ()) + { + if (s != 0) + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("ACE (%P|%t) SR::fini, repo=%@ [%d] (%d), ") + ACE_TEXT ("name=%s, type=%@, object=%@, active=%d\n"), + this, + i, + this->total_size_, + s->name(), + s->type (), + (s->type () != 0) ? s->type ()->object () : 0, + s->active ())); + else + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("ACE (%P|%t) SR::fini, repo=%@ [%d] (%d) -> 0\n"), + this, + i, + this->total_size_)); + } +#endif + + // Collect any errors. + if (s != 0) + retval += s->fini (); + } + + return (retval == 0) ? 0 : -1; +} + +// Close down all the services. + +int +ACE_Service_Repository::close (void) +{ + ACE_TRACE ("ACE_Service_Repository::close"); + ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon, this->lock_, -1)); + + if (this->service_vector_ == 0) + return 0; + +#ifndef ACE_NLOGGING + if(ACE::debug ()) + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("(%P|%t) SR::close - repo=%@, size=%d\n"), + this, + this->current_size_)); +#endif + + // Do not use the prefix decrement operator since the index is + // unsigned and may wrap around the 0. + for (size_t i = this->current_size_; i-- != 0; ) + { + // Delete services in reverse order. + ACE_Service_Type *s = + const_cast (this->service_vector_[i]); + +#ifndef ACE_NLOGGING + if(ACE::debug ()) + { + if (s == 0) + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("(%P|%t) SR::close - repo=%@ [%d] -> 0\n"), + this, + i)); + else + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("(%P|%t) SR::close - repo=%@ [%d], name=%s, object=%@\n"), + this, + i, + s->name (), + s)); + } +#endif + --this->current_size_; + delete s; + } + + delete [] this->service_vector_; + this->service_vector_ = 0; + this->current_size_ = 0; + + return 0; +} + +ACE_Service_Repository::~ACE_Service_Repository (void) +{ + ACE_TRACE ("ACE_Service_Repository::~ACE_Service_Repository"); +#ifndef ACE_NLOGGING + if(ACE::debug ()) + ACE_DEBUG ((LM_DEBUG, "(%P|%t) SR::, this=%@\n", this)); +#endif + this->close (); +} + +// Locate an entry with in the table. If is +// set then only consider services marked as resumed. If the caller +// wants the located entry, pass back a pointer to the located entry +// via . If is not found -1 is returned. If is +// found, but it is suspended and the caller wants to ignore suspended +// services a -2 is returned. Must be called with locks held. + +int +ACE_Service_Repository::find_i (const ACE_TCHAR name[], + size_t &slot, + const ACE_Service_Type **srp, + bool ignore_suspended) const +{ + ACE_TRACE ("ACE_Service_Repository::find_i"); + size_t i; + + for (i = 0; i < this->current_size_; i++) + { + if (this->service_vector_[i] != 0 // skip any empty slots + && ACE_OS::strcmp (name, + this->service_vector_[i]->name ()) == 0) + break; + } + + if (i < this->current_size_) + { + slot = i; + if (this->service_vector_[i]->fini_called ()) + { + if (srp != 0) + *srp = 0; + return -1; + } + + if (srp != 0) + *srp = this->service_vector_[i]; + + if (ignore_suspended + && this->service_vector_[i]->active () == 0) + return -2; + + return 0; + } + + return -1; +} + + +/// @brief Relocate (a static) service to another DLL. +/// +/// Works by having the service type keep a reference to a specific +/// DLL. No locking, caller makes sure calling it is safe. You can +/// forcefully relocate any DLLs in the given range, not only the +/// static ones - but that will cause Very Bad Things (tm) to happen. + +int +ACE_Service_Repository::relocate_i (size_t begin, + size_t end, + const ACE_DLL& adll) +{ + ACE_SHLIB_HANDLE new_handle = adll.get_handle (0); + + for (size_t i = begin; i < end; i++) + { + ACE_Service_Type *type = + const_cast (this->service_vector_[i]); + + ACE_SHLIB_HANDLE old_handle = (type == 0) ? ACE_SHLIB_INVALID_HANDLE + : type->dll ().get_handle (0); + +#ifndef ACE_NLOGGING + if (ACE::debug ()) + { + if (type == 0) + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("ACE (%P|%t) SR::relocate_i - repo=%@ [%d] (size=%d)") + ACE_TEXT (": skipping empty slot\n"), + this, + i, + this->total_size_)); + else + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("ACE (%P|%t) SR::relocate_i - repo=%@ [%d] (size=%d)") + ACE_TEXT (": trying name=%s, handle: %d -> %d\n"), + this, + i, + this->total_size_, + type->name (), + old_handle, + new_handle)); + } +#endif + + if (type != 0 // skip any gaps + && old_handle == ACE_SHLIB_INVALID_HANDLE + && new_handle != old_handle) + { +#ifndef ACE_NLOGGING + if (ACE::debug ()) + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("ACE (%P|%t) SR::relocate_i - repo=%@ [%d] (size=%d)") + ACE_TEXT (": relocating name=%s, handle: %d -> %d\n"), + this, + i, + this->total_size_, + type->name (), + old_handle, + new_handle)); +#endif + type->dll (adll); // ups the refcount on adll + } + } + + return 0; +} + +int +ACE_Service_Repository::find (const ACE_TCHAR name[], + const ACE_Service_Type **srp, + bool ignore_suspended) const +{ + ACE_TRACE ("ACE_Service_Repository::find"); + ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon, this->lock_, -1)); + size_t ignore_location = 0; + return this->find_i (name, ignore_location, srp, ignore_suspended); +} + + +// Insert the ACE_Service_Type SR into the repository. Note that +// services may be inserted either resumed or suspended. Using same +// name as in an existing service causes the delete () to be called +// for the old one, i.e. make sure @code sr is allocated on the heap! +int +ACE_Service_Repository::insert (const ACE_Service_Type *sr) +{ + ACE_TRACE ("ACE_Service_Repository::insert"); + + size_t i = 0; + int return_value = -1; + ACE_Service_Type const *s = 0; + + // Establish scope for locking while manipulating the service + // storage + { + // @TODO: Do we need a recursive mutex here? + ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, + ace_mon, + this->lock_, + -1)); + + return_value = find_i (sr->name (), i, &s, false); + + // Adding an entry. + if (s != 0) + { + this->service_vector_[i] = sr; + } + else + { + // New services are always added where current_size_ points, + // because if any DLL relocation needs to happen, it will be + // performed on services with indexes between some old + // current_size_ and the new current_size_ value. See + // ACE_Service_Type_Dynamic_Guard ctor and dtor for details. + + if (i < this->current_size_) + i = this->current_size_; + + if (i < this->total_size_) + { + this->service_vector_[i] = sr; + this->current_size_++; + return_value = 0; + } + else + { + return_value = -1; // no space left + } + + // Since there may be "holes" left by removed services one + // could consider wrapping current_size_ modulo + // total_size_. This is going to impact + // ACE_Service_Type_Dynamic_Guard, too and is tricky. Perhaps + // a new directive, like "reload" would be better as it can + // combine the removal and insertion in an atomic step and + // avoid creating too many "holes". + } + } +#ifndef ACE_NLOGGING + if (ACE::debug ()) + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("ACE (%P|%t) SR::insert - repo=%@ [%d] (%d),") + ACE_TEXT (" name=%s (%s) (type=%@, object=%@, active=%d)\n"), + this, + i, + this->total_size_, + sr->name(), + (return_value == 0 ? ((s==0) ? "new" : "replacing") : "failed"), + sr->type (), + (sr->type () != 0) ? sr->type ()->object () : 0, + sr->active ())); +#endif + + // If necessary, delete but outside the lock. (s may be 0, but + // that's okay, too) + delete s; + + if (return_value == -1) + ACE_OS::last_error (ENOSPC); + + return return_value; +} + +// Resume a service that was previously suspended. +int +ACE_Service_Repository::resume (const ACE_TCHAR name[], + const ACE_Service_Type **srp) +{ + ACE_TRACE ("ACE_Service_Repository::resume"); + ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon, this->lock_, -1)); + + size_t i = 0; + if (-1 == this->find_i (name, i, srp, 0)) + return -1; + + return this->service_vector_[i]->resume (); +} + +// Suspend a service so that it will not be considered active under +// most circumstances by other portions of the ACE_Service_Repository. + +int +ACE_Service_Repository::suspend (const ACE_TCHAR name[], + const ACE_Service_Type **srp) +{ + ACE_TRACE ("ACE_Service_Repository::suspend"); + ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon, this->lock_, -1)); + size_t i = 0; + if (-1 == this->find_i (name, i, srp, 0)) + return -1; + + return this->service_vector_[i]->suspend (); +} + + +/** + * @brief Completely remove a entry from the Repository and + * dynamically unlink it if it was originally dynamically linked. + */ + +int +ACE_Service_Repository::remove (const ACE_TCHAR name[], ACE_Service_Type **ps) +{ + ACE_TRACE ("ACE_Service_Repository::remove"); + ACE_Service_Type *s = 0; + { + ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon, this->lock_, -1)); + + // Not found!? + if (this->remove_i (name, &s) == -1) + return -1; + } + + if (ps != 0) + *ps = s; + else + delete s; + return 0; +} + +/** + * @brief Completely remove a entry from the Repository and + * dynamically unlink it if it was originally dynamically linked. + * + * Return a ptr to the entry in @code ps. There is no locking so make + * sure you hold the repo lock when calling. + * + * Since the order of services in the Respository matters, we can't + * simply overwrite the entry being deleted with the last and + * decrement the by 1. A good example of why the order + * matters is a dynamic service, in whose DLL there is at least one + * static service. In order to prevent SEGV during finalization, those + * static services must be finalized _before_the dynamic service that + * owns them. Otherwice the TEXT segment, containing the code for the + * static service's desructor may be unloaded with the DLL. + * + * Neither can we "pack" the array because this may happen inside the + * scope of a Service_Dynamic_Guard, which caches an index where + * loading of a DLL started in order to relocate dependent services. + */ +int +ACE_Service_Repository::remove_i (const ACE_TCHAR name[], ACE_Service_Type **ps) +{ + size_t i = 0; + if (-1 == this->find_i (name, i, 0, false)) + return -1; // Not found + + // We may need the old ptr - to be delete outside the lock! + *ps = const_cast (this->service_vector_[i]); + +#ifndef ACE_NLOGGING + if (ACE::debug ()) + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("ACE (%P|%t) SR::remove_i - repo=%@ [%d] (%d),") + ACE_TEXT (" name=%s (removed) (type=%@, active=%d)\n"), + this, + i, + this->total_size_, + name, + *ps, + (*ps)->active ())); +#endif + + this->service_vector_[i] = 0; // simply leave a gap + return 0; +} + +ACE_ALLOC_HOOK_DEFINE(ACE_Service_Repository_Iterator) + +void +ACE_Service_Repository_Iterator::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + ACE_TRACE ("ACE_Service_Repository_Iterator::dump"); +#endif /* ACE_HAS_DUMP */ +} + + +// Initializes the iterator and skips over any suspended entries at +// the beginning of the table, if necessary. Note, you must not +// perform destructive operations on elements during this iteration... + +ACE_Service_Repository_Iterator::ACE_Service_Repository_Iterator + (ACE_Service_Repository &sr, int ignr_suspended) + : svc_rep_ (sr), + next_ (0), + ignore_suspended_ (ignr_suspended) +{ + while (!(done() || valid())) + this->next_++; +} + +// Obtains a pointer to the next valid service in the table. If there +// are no more entries, returns 0, else 1. + +int +ACE_Service_Repository_Iterator::next (const ACE_Service_Type *&sr) +{ + ACE_TRACE ("ACE_Service_Repository_Iterator::next"); + + if (done ()) + return 0; + + sr = this->svc_rep_.service_vector_[this->next_]; + return 1; +} + +// Advance the iterator by the proper amount. If we are ignoring +// suspended entries and the current entry is suspended, then we must +// skip over this entry. Otherwise, we must advance the NEXT index to +// reference the next valid service entry. + +int +ACE_Service_Repository_Iterator::advance (void) +{ + ACE_TRACE ("ACE_Service_Repository_Iterator::advance"); + + if (done()) return 0; + + do this->next_++; while (!(done () || valid ())); + + return !done(); +} + +bool +ACE_Service_Repository_Iterator::valid (void) const +{ + ACE_TRACE ("ACE_Service_Repository_Iterator::valid"); + if (!this->ignore_suspended_) + return (this->svc_rep_.service_vector_[this->next_] != 0); // skip over gaps + + return (this->svc_rep_.service_vector_[this->next_] != 0 + && this->svc_rep_.service_vector_[this->next_]->active ()); +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Service_Repository.h b/dep/ACE_wrappers/ace/Service_Repository.h new file mode 100644 index 00000000000..30c11ce6ce9 --- /dev/null +++ b/dep/ACE_wrappers/ace/Service_Repository.h @@ -0,0 +1,280 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Service_Repository.h + * + * $Id: Service_Repository.h 81388 2008-04-23 14:02:05Z johnnyw $ + * + * @author Douglas C. Schmidt + */ +//============================================================================= + +#ifndef ACE_SERVICE_REPOSITORY_H +#define ACE_SERVICE_REPOSITORY_H + +#include /**/ "ace/pre.h" + +#include /**/ "ace/ACE_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/Default_Constants.h" +#include "ace/Recursive_Thread_Mutex.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +class ACE_Service_Type; +class ACE_DLL; + +#define ACE_Component_Repository ACE_Service_Repository +/** + * @class ACE_Service_Repository + * + * @brief Contains all the services offered by a Service + * Configurator-based application. + * + * This class contains a vector of *'s and + * allows an administrative entity to centrally manage and + * control the behavior of application services. Note that if + * services are removed from the middle of the repository the + * order won't necessarily be maintained since the + * method performs compaction. However, the common case is not + * to remove services, so typically they are deleted in the + * reverse order that they were added originally. + */ +class ACE_Export ACE_Service_Repository +{ +public: + friend class ACE_Service_Repository_Iterator; + + enum + { + DEFAULT_SIZE = ACE_DEFAULT_SERVICE_REPOSITORY_SIZE + }; + + // = Initialization and termination methods. + /// Initialize the repository. + ACE_Service_Repository (void); + + /// Initialize the repository. + ACE_Service_Repository (size_t size); + + /// Initialize the repository. + int open (size_t size = DEFAULT_SIZE); + + /// Close down the repository and free up dynamically allocated + /// resources. + ~ACE_Service_Repository (void); + + /// Close down the repository and free up dynamically allocated + /// resources. + int close (void); + + /// Finalize all the services by calling and deleting + /// dynamically allocated services. + int fini (void); + + /// Get pointer to a process-wide ACE_Service_Repository. + static ACE_Service_Repository * instance + (size_t size = ACE_Service_Repository::DEFAULT_SIZE); + + /// Set pointer to a process-wide ACE_Service_Repository and return + /// existing pointer. + static ACE_Service_Repository *instance (ACE_Service_Repository *); + + /// Delete the dynamically allocated Singleton. + static void close_singleton (void); + + // = Search structure operations (all acquire locks as necessary). + + /// Insert a new service record. Returns -1 when the service repository + /// is full and 0 on success. + int insert (const ACE_Service_Type *); + + /** + * Locate a named entry in the service table, optionally ignoring + * suspended entries. + * + * @param service_name The name of the service to search for. + * @param srp Optional; if not 0, it is a pointer to a location + * to receive the ACE_Service_Type pointer for the + * located service. Meaningless if this method + * returns -1. + * @param ignore_suspended If true, the search ignores suspended services. + * + * @retval 0 Named service was located. + * @retval -1 Named service was not found. + * @retval -2 Named service was found, but is suspended and + * @a ignore_suspended is true. + */ + int find (const ACE_TCHAR name[], + const ACE_Service_Type **srp = 0, + bool ignore_suspended = true) const; + + /// Remove an existing service record. If @a sr == 0, the service record + /// is deleted before control is returned to the caller. If @a sr != 0, + /// the service's record is removed from the repository, but not deleted; + /// *sr receives the service record pointer and the caller is responsible + /// for properly disposing of it. + int remove (const ACE_TCHAR[], ACE_Service_Type **sr = 0); + + // = Liveness control + /// Resume a service record. + int resume (const ACE_TCHAR[], const ACE_Service_Type ** = 0); + + /// Suspend a service record. + int suspend (const ACE_TCHAR[], const ACE_Service_Type ** = 0); + + /// Return the current size of the repository. + size_t current_size (void) const; + + /// Return the total size of the repository. + size_t total_size (void) const; + + /// Dump the state of an object. + void dump (void) const; + + /// Declare the dynamic allocation hooks. + ACE_ALLOC_HOOK_DECLARE; + +private: + + friend class ACE_Service_Type_Dynamic_Guard; + + /// Remove an existing service record. It requires @a sr != 0, which + /// receives the service record pointer and the caller is + /// responsible for properly disposing of it. + int remove_i (const ACE_TCHAR[], ACE_Service_Type **sr); + + /** + * Locate a named entry in the service table, optionally ignoring + * suspended entries. + * + * @param service_name The name of the service to search for. + * @param slot Receives the position index of the service if it + * is found. Contents are meaningless if this method + * returns -1. + * @param srp Optional; if not 0, it is a pointer to a location + * to receive the ACE_Service_Type pointer for the + * located service. Meaningless if this method + * returns -1. + * @param ignore_suspended If true, the search ignores suspended services. + * + * @retval 0 Named service was located; index in the table is set in + * @a slot. + * @retval -1 Named service was not found. + * @retval -2 Named service was found, but is suspended and + * @a ignore_suspended is true. + */ + int find_i (const ACE_TCHAR service_name[], + size_t &slot, + const ACE_Service_Type **srp = 0, + bool ignore_suspended = true) const; + + /// @brief Relocate (static) services to another DLL. + /// + /// If any have been registered in the context of a "forward + /// declaration" guard, those really aren't static services. Their + /// code is in the DLL's code segment, or in one of the dependent + /// DLLs. Therefore, such services need to be associated with the + /// proper DLL in order to prevent failures upon finalization. The + /// method locks the repo. + /// + /// Works by having the service type keep a reference to a specific + /// DLL. No locking, caller makes sure calling it is safe. You can + /// forcefully relocate any DLLs in the given range, not only the + /// static ones - but that will cause Very Bad Things (tm) to happen. + + int relocate_i (size_t begin, + size_t end, + const ACE_DLL &adll); + + /// Contains all the configured services. + const ACE_Service_Type **service_vector_; + + /// Current number of services. + size_t current_size_; + + /// Maximum number of services. + size_t total_size_; + + /// Pointer to a process-wide ACE_Service_Repository. + static ACE_Service_Repository *svc_rep_; + + /// Must delete the if true. + static bool delete_svc_rep_; + +#if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0) + /// Synchronization variable for the MT_SAFE Repository + mutable ACE_Recursive_Thread_Mutex lock_; +#endif /* ACE_MT_SAFE */ +}; + +/** + * @class ACE_Service_Repository_Iterator + * + * @brief Iterate through the ACE_Service_Repository. + * + * Make sure not to delete entries as the iteration is going on + * since this class is not designed as a robust iterator. + */ +class ACE_Export ACE_Service_Repository_Iterator +{ +public: + // = Initialization and termination methods. + /// Constructor initializes the iterator. + ACE_Service_Repository_Iterator (ACE_Service_Repository &sr, + int ignored_suspended = 1); + + /// Destructor. + ~ACE_Service_Repository_Iterator (void); + + +public: + // = Iteration methods. + + /// Pass back the that hasn't been seen in the repository. + /// Returns 0 when all items have been seen, else 1. + int next (const ACE_Service_Type *&next_item); + + /// Returns 1 when all items have been seen, else 0. + int done (void) const; + + /// Move forward by one element in the repository. Returns 0 when all the + /// items in the set have been seen, else 1. + int advance (void); + + /// Dump the state of an object. + void dump (void) const; + + /// Declare the dynamic allocation hooks. + ACE_ALLOC_HOOK_DECLARE; + +private: + bool valid (void) const; + +private: + ACE_Service_Repository_Iterator (const ACE_Service_Repository_Iterator&); + + /// Reference to the Service Repository we are iterating over. + ACE_Service_Repository &svc_rep_; + + /// Next index location that we haven't yet seen. + size_t next_; + + /// Are we ignoring suspended services? + bool ignore_suspended_; +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +#include "ace/Service_Repository.inl" +#endif /* __ACE_INLINE__ */ + +#include /**/ "ace/post.h" + +#endif /* _SERVICE_REPOSITORY_H */ diff --git a/dep/ACE_wrappers/ace/Service_Repository.inl b/dep/ACE_wrappers/ace/Service_Repository.inl new file mode 100644 index 00000000000..621c837ef53 --- /dev/null +++ b/dep/ACE_wrappers/ace/Service_Repository.inl @@ -0,0 +1,51 @@ +// -*- C++ -*- +// +// $Id: Service_Repository.inl 80826 2008-03-04 14:51:23Z wotte $ + +// Returns a count of the number of currently valid entries (counting +// both resumed and suspended entries). + +#if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0) +#include "ace/Guard_T.h" +#include "ace/Thread_Mutex.h" +#endif /* ACE_MT_SAFE */ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_INLINE size_t +ACE_Service_Repository::current_size (void) const +{ + ACE_TRACE ("ACE_Service_Repository::current_size"); + ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, + ace_mon, + (ACE_Recursive_Thread_Mutex &) this->lock_, 0)); + return this->current_size_; +} + +// Returns a count of the total number of possible entries in the +// table. + +ACE_INLINE size_t +ACE_Service_Repository::total_size (void) const +{ + ACE_TRACE ("ACE_Service_Repository::total_size"); + ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, + ace_mon, + (ACE_Recursive_Thread_Mutex &) this->lock_, 0)); + return this->total_size_; +} + +ACE_INLINE int +ACE_Service_Repository_Iterator::done (void) const +{ + ACE_TRACE ("ACE_Service_Repository_Iterator::done"); + + return this->next_ >= this->svc_rep_.current_size_; +} + +ACE_INLINE +ACE_Service_Repository_Iterator::~ACE_Service_Repository_Iterator (void) +{ +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Service_Templates.h b/dep/ACE_wrappers/ace/Service_Templates.h new file mode 100644 index 00000000000..d05d0d611d2 --- /dev/null +++ b/dep/ACE_wrappers/ace/Service_Templates.h @@ -0,0 +1,29 @@ + +//============================================================================= +/** + * @file Service_Templates.h + * + * $Id: Service_Templates.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Priyanka Gontla + */ +//============================================================================= + + +#ifndef ACE_SERVICE_TEMPLATES_H +#define ACE_SERVICE_TEMPLATES_H +#include /**/ "ace/pre.h" + +#include "ace/Svc_Conf.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/Auto_Ptr.h" +#include "ace/Thread_Manager.h" +#include "ace/Stream_Modules.h" +#include "ace/Stream.h" + +#include /**/ "ace/post.h" +#endif /* ACE_SERVICE_TEMPLATES_H */ diff --git a/dep/ACE_wrappers/ace/Service_Types.cpp b/dep/ACE_wrappers/ace/Service_Types.cpp new file mode 100644 index 00000000000..46c671beb0a --- /dev/null +++ b/dep/ACE_wrappers/ace/Service_Types.cpp @@ -0,0 +1,453 @@ +// $Id: Service_Types.cpp 81826 2008-06-02 15:29:53Z schmidt $ + +#include "ace/Service_Types.h" + +#if !defined (__ACE_INLINE__) +#include "ace/Service_Types.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/Stream_Modules.h" +#include "ace/Stream.h" +#include "ace/OS_NS_stdio.h" +#include "ace/OS_NS_string.h" + + +ACE_RCSID (ace, + Service_Types, + "$Id: Service_Types.cpp 81826 2008-06-02 15:29:53Z schmidt $") + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +typedef ACE_Stream MT_Stream; +typedef ACE_Module MT_Module; +typedef ACE_Task MT_Task; + +ACE_ALLOC_HOOK_DEFINE(ACE_Service_Type_Impl) + +void +ACE_Service_Type_Impl::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + ACE_TRACE ("ACE_Service_Type_Impl::dump"); +#endif /* ACE_HAS_DUMP */ +} + +ACE_Service_Type_Impl::ACE_Service_Type_Impl (void *so, + const ACE_TCHAR *s_name, + u_int f, + ACE_Service_Object_Exterminator gobbler) + : name_ (0), + obj_ (so), + gobbler_ (gobbler), + flags_ (f) +{ + ACE_TRACE ("ACE_Service_Type_Impl::ACE_Service_Type_Impl"); + this->name (s_name); +} + +ACE_Service_Type_Impl::~ACE_Service_Type_Impl (void) +{ + ACE_TRACE ("ACE_Service_Type_Impl::~ACE_Service_Type_Impl"); + + // It's ok to call this, even though we may have already deleted it + // in the fini() method since it would then be NULL. + delete [] const_cast (this->name_); +} + +int +ACE_Service_Type_Impl::fini (void) const +{ + ACE_TRACE ("ACE_Service_Type_Impl::fini"); + + delete [] const_cast (this->name_); + (const_cast (this))->name_ = 0; + + if (ACE_BIT_ENABLED (this->flags_, + ACE_Service_Type::DELETE_OBJ)) + { + if (gobbler_ != 0) + gobbler_ (this->object ()); + else + // Cast to remove const-ness. + operator delete ((void *) this->object ()); + } + + if (ACE_BIT_ENABLED (this->flags_, + ACE_Service_Type::DELETE_THIS)) + delete const_cast (this); + + return 0; +} + +ACE_Service_Object_Type::ACE_Service_Object_Type (void *so, + const ACE_TCHAR *s_name, + u_int f, + ACE_Service_Object_Exterminator gobbler) + : ACE_Service_Type_Impl (so, s_name, f, gobbler) + , initialized_ (-1) +{ + ACE_TRACE ("ACE_Service_Object_Type::ACE_Service_Object_Type"); +} + +int +ACE_Service_Object_Type::init (int argc, ACE_TCHAR *argv[]) const +{ + ACE_TRACE ("ACE_Service_Object_Type::init"); + + void * const obj = this->object (); + + ACE_Service_Object * const so = + static_cast (obj); + + if (so == 0) + return -1; + + this->initialized_ = so->init (argc, argv); + + return this->initialized_; +} + +int +ACE_Service_Object_Type::fini (void) const +{ + ACE_TRACE ("ACE_Service_Object_Type::fini"); + + void * const obj = this->object (); + + ACE_Service_Object * const so = + static_cast (obj); + + // Call fini() if an only if, the object was successfuly + // initialized, i.e. init() returned 0. This is necessary to + // maintain the ctor/dtor-like semantics for init/fini. + if (so != 0 && this->initialized_ == 0) + so->fini (); + + return ACE_Service_Type_Impl::fini (); +} + +ACE_Service_Object_Type::~ACE_Service_Object_Type (void) +{ + ACE_TRACE ("ACE_Service_Object_Type::~ACE_Service_Object_Type"); +} + +int +ACE_Service_Object_Type::suspend (void) const +{ + ACE_TRACE ("ACE_Service_Object_Type::suspend"); + return static_cast (this->object ())->suspend (); +} + +int +ACE_Service_Object_Type::resume (void) const +{ + ACE_TRACE ("ACE_Service_Object_Type::resume"); + return static_cast (this->object ())->resume (); +} + +int +ACE_Service_Object_Type::info (ACE_TCHAR **str, size_t len) const +{ + ACE_TRACE ("ACE_Service_Object_Type::info"); + return static_cast (this->object ())->info (str, len); +} + +ACE_ALLOC_HOOK_DEFINE(ACE_Module_Type) + +void +ACE_Module_Type::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + ACE_TRACE ("ACE_Module_Type::dump"); +#endif /* ACE_HAS_DUMP */ +} + +ACE_Module_Type::ACE_Module_Type (void *m, + const ACE_TCHAR *m_name, + u_int f) + : ACE_Service_Type_Impl (m, m_name, f) +{ + ACE_TRACE ("ACE_Module_Type::ACE_Module_Type"); +} + +ACE_Module_Type::~ACE_Module_Type (void) +{ + ACE_TRACE ("ACE_Module_Type::~ACE_Module_Type"); +} + +int +ACE_Module_Type::init (int argc, ACE_TCHAR *argv[]) const +{ + ACE_TRACE ("ACE_Module_Type::init"); + void *obj = this->object (); + MT_Module *mod = (MT_Module *) obj; + MT_Task *reader = mod->reader (); + MT_Task *writer = mod->writer (); + + if (reader->init (argc, argv) == -1 + || writer->init (argc, argv) == -1) + return -1; + else + return 0; +} + +int +ACE_Module_Type::suspend (void) const +{ + ACE_TRACE ("ACE_Module_Type::suspend"); + void *obj = this->object (); + MT_Module *mod = (MT_Module *) obj; + MT_Task *reader = mod->reader (); + MT_Task *writer = mod->writer (); + + if (reader->suspend () == -1 + || writer->suspend () == -1) + return -1; + else + return 0; +} + +int +ACE_Module_Type::resume (void) const +{ + ACE_TRACE ("ACE_Module_Type::resume"); + void *obj = this->object (); + MT_Module *mod = (MT_Module *) obj; + MT_Task *reader = mod->reader (); + MT_Task *writer = mod->writer (); + + if (reader->resume () == -1 + || writer->resume () == -1) + return -1; + else + return 0; +} + +// Note, these operations are somewhat too familiar with the +// implementation of ACE_Module and ACE_Module::close... + +int +ACE_Module_Type::fini (void) const +{ + ACE_TRACE ("ACE_Module_Type::fini"); + + void *obj = this->object (); + MT_Module *mod = (MT_Module *) obj; + MT_Task *reader = mod->reader (); + MT_Task *writer = mod->writer (); + + if (reader != 0) + reader->fini (); + + if (writer != 0) + writer->fini (); + + // Close the module and delete the memory. + mod->close (MT_Module::M_DELETE); + return ACE_Service_Type_Impl::fini (); +} + +int +ACE_Module_Type::info (ACE_TCHAR **str, size_t len) const +{ + ACE_TRACE ("ACE_Module_Type::info"); + ACE_TCHAR buf[BUFSIZ]; + + ACE_OS::sprintf (buf, + ACE_TEXT ("%s\t %s"), + this->name (), + ACE_TEXT ("# ACE_Module\n")); + + if (*str == 0 && (*str = ACE_OS::strdup (buf)) == 0) + return -1; + else + ACE_OS::strsncpy (*str, buf, len); + return static_cast (ACE_OS::strlen (buf)); +} + +void +ACE_Module_Type::link (ACE_Module_Type *n) +{ + ACE_TRACE ("ACE_Module_Type::link"); + this->link_ = n; +} + +ACE_Module_Type * +ACE_Module_Type::link (void) const +{ + ACE_TRACE ("ACE_Module_Type::link"); + return this->link_; +} + +ACE_ALLOC_HOOK_DEFINE(ACE_Stream_Type) + +void +ACE_Stream_Type::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + ACE_TRACE ("ACE_Stream_Type::dump"); +#endif /* ACE_HAS_DUMP */ +} + +int +ACE_Stream_Type::init (int, ACE_TCHAR *[]) const +{ + ACE_TRACE ("ACE_Stream_Type::init"); + return 0; +} + +int +ACE_Stream_Type::suspend (void) const +{ + ACE_TRACE ("ACE_Stream_Type::suspend"); + + for (ACE_Module_Type *m = this->head_; + m != 0; + m = m->link ()) + m->suspend (); + + return 0; +} + +int +ACE_Stream_Type::resume (void) const +{ + ACE_TRACE ("ACE_Stream_Type::resume"); + + for (ACE_Module_Type *m = this->head_; + m != 0; + m = m->link ()) + m->resume (); + + return 0; +} + +ACE_Stream_Type::ACE_Stream_Type (void *s, + const ACE_TCHAR *s_name, + u_int f) + : ACE_Service_Type_Impl (s, s_name, f), + head_ (0) +{ + ACE_TRACE ("ACE_Stream_Type::ACE_Stream_Type"); +} + +ACE_Stream_Type::~ACE_Stream_Type (void) +{ + ACE_TRACE ("ACE_Stream_Type::~ACE_Stream_Type"); +} + +int +ACE_Stream_Type::info (ACE_TCHAR **str, size_t len) const +{ + ACE_TRACE ("ACE_Stream_Type::info"); + ACE_TCHAR buf[BUFSIZ]; + + ACE_OS::sprintf (buf, + ACE_TEXT ("%s\t %s"), + this->name (), + ACE_TEXT ("# STREAM\n")); + + if (*str == 0 && (*str = ACE_OS::strdup (buf)) == 0) + return -1; + else + ACE_OS::strsncpy (*str, buf, len); + return static_cast (ACE_OS::strlen (buf)); +} + +int +ACE_Stream_Type::fini (void) const +{ + ACE_TRACE ("ACE_Stream_Type::fini"); + void *obj = this->object (); + MT_Stream *str = (MT_Stream *) obj; + + for (ACE_Module_Type *m = this->head_; m != 0; ) + { + ACE_Module_Type *t = m->link (); + + // Final arg is an indication to *not* delete the Module. + str->remove (m->name (), + MT_Module::M_DELETE_NONE); + + // Finalize the Module (this may delete it, but we don't really + // care since we don't access it again). + m->fini (); + m = t; + } + str->close (); + + return ACE_Service_Type_Impl::fini (); +} + +// Locate and remove from the ACE_Stream. + +int +ACE_Stream_Type::remove (ACE_Module_Type *mod) +{ + ACE_TRACE ("ACE_Stream_Type::remove"); + + ACE_Module_Type *prev = 0; + void *obj = this->object (); + MT_Stream *str = (MT_Stream *) obj; + int result = 0; + + for (ACE_Module_Type *m = this->head_; m != 0; ) + { + // We need to do this first so we don't bomb out if we delete m! + ACE_Module_Type *link = m->link (); + + if (m == mod) + { + if (prev == 0) + this->head_ = link; + else + prev->link (link); + + // Final arg is an indication to *not* delete the Module. + if (str->remove (m->name (), + MT_Module::M_DELETE_NONE) == -1) + result = -1; + + // This call may end up deleting m, which is ok since we + // don't access it again! + m->fini (); + } + else + prev = m; + + m = link; + } + + return result; +} + +int +ACE_Stream_Type::push (ACE_Module_Type *new_module) +{ + ACE_TRACE ("ACE_Stream_Type::push"); + void *obj = this->object (); + MT_Stream *str = (MT_Stream *) obj; + + new_module->link (this->head_); + this->head_ = new_module; + obj = new_module->object (); + return str->push ((MT_Module *) obj); +} + +ACE_Module_Type * +ACE_Stream_Type::find (const ACE_TCHAR *mod_name) const +{ + ACE_TRACE ("ACE_Stream_Type::find"); + + for (ACE_Module_Type *m = this->head_; + m != 0; + m = m->link ()) + if (ACE_OS::strcmp (m->name (), mod_name) == 0) + return m; + + return 0; +} + +// @@@ Eliminated ommented out explicit template instantiation code + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Service_Types.h b/dep/ACE_wrappers/ace/Service_Types.h new file mode 100644 index 00000000000..b9450d2c5a1 --- /dev/null +++ b/dep/ACE_wrappers/ace/Service_Types.h @@ -0,0 +1,206 @@ +// -*- C++ -*- + +//========================================================================== +/** + * @file Service_Types.h + * + * $Id: Service_Types.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Douglas C. Schmidt + */ +//========================================================================== + +#ifndef ACE_SERVICE_TYPE_H +#define ACE_SERVICE_TYPE_H + +#include /**/ "ace/pre.h" + +#include "ace/Service_Object.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +/** + * @class ACE_Service_Type_Impl + * + * @brief The abstract base class of the hierarchy that defines the + * contents of the ACE_Service_Repository. The subclasses of + * this class allow the configuration of ACE_Service_Objects, + * ACE_Modules, and ACE_Streams. + * + * This class provides the root of the implementation hierarchy + * of the "Bridge" pattern. It maintains a pointer to the + * appropriate type of service implementation, i.e., + * ACE_Service_Object, ACE_Module, or ACE_Stream. + */ +class ACE_Export ACE_Service_Type_Impl +{ +public: + // = Initialization and termination methods. + ACE_Service_Type_Impl (void *object, + const ACE_TCHAR *s_name, + u_int flags = 0, + ACE_Service_Object_Exterminator gobbler = 0); + virtual ~ACE_Service_Type_Impl (void); + + // = Pure virtual interface (must be defined by the subclass). + virtual int suspend (void) const = 0; + virtual int resume (void) const = 0; + virtual int init (int argc, ACE_TCHAR *argv[]) const = 0; + virtual int fini (void) const; + virtual int info (ACE_TCHAR **str, size_t len) const = 0; + + /// The pointer to the service. + void *object (void) const; + + /// Get the name of the service. + const ACE_TCHAR *name (void) const; + + /// Set the name of the service. + void name (const ACE_TCHAR *); + + /// Dump the state of an object. + void dump (void) const; + + /// Declare the dynamic allocation hooks. + ACE_ALLOC_HOOK_DECLARE; + +protected: + /// Name of the service. + const ACE_TCHAR *name_; + + /// Pointer to object that implements the service. This actually + /// points to an ACE_Service_Object, ACE_Module, or ACE_Stream. + void *obj_; + + /// Destroy function to deallocate obj_. + ACE_Service_Object_Exterminator gobbler_; + + /// Flags that control serivce behavior (particularly deletion). + u_int flags_; +}; + +/** + * @class ACE_Service_Object_Type + * + * @brief Define the methods for handling the configuration of + * ACE_Service_Objects. + */ +class ACE_Export ACE_Service_Object_Type : public ACE_Service_Type_Impl +{ +public: + // = Initialization method. + ACE_Service_Object_Type (void *so, + const ACE_TCHAR *name, + u_int flags = 0, + ACE_Service_Object_Exterminator gobbler = 0); + + ~ACE_Service_Object_Type (void); + + // = Implement the hooks for . + virtual int suspend (void) const; + virtual int resume (void) const; + virtual int init (int argc, ACE_TCHAR *argv[]) const; + virtual int fini (void) const; + virtual int info (ACE_TCHAR **str, size_t len) const; + +private: + /// Holds the initialization status (result of object->init()) + mutable int initialized_; +}; + +/** + * @class ACE_Module_Type + * + * @brief Define the methods for handling the configuration of + * ACE_Modules. + */ +class ACE_Export ACE_Module_Type : public ACE_Service_Type_Impl +{ +public: + // = Initialization method. + ACE_Module_Type (void *m, // Really an ACE_Module *. + const ACE_TCHAR *identifier, + u_int flags = 0); + + ~ACE_Module_Type (void); + + // = Implement the hooks for . + virtual int suspend (void) const; + virtual int resume (void) const; + virtual int init (int argc, ACE_TCHAR *argv[]) const; + virtual int fini (void) const; + virtual int info (ACE_TCHAR **str, size_t len) const; + + /// Get the link pointer. + ACE_Module_Type *link (void) const; + + /// Set the link pointer. + void link (ACE_Module_Type *); + + /// Dump the state of an object. + void dump (void) const; + + /// Declare the dynamic allocation hooks. + ACE_ALLOC_HOOK_DECLARE; + +private: + /// Pointer to the next ACE_Module_Type in an ACE_Stream_Type. + ACE_Module_Type *link_; +}; + +/** + * @class ACE_Stream_Type + * + * @brief Define the methods for handling the configuration of + * ACE_Streams. + */ +class ACE_Export ACE_Stream_Type : public ACE_Service_Type_Impl +{ +public: + // = Initialization method. + ACE_Stream_Type (void *s, // Really an ACE_Stream *. + const ACE_TCHAR *identifier, + u_int flags = 0); + + ~ACE_Stream_Type (void); + + // = Implement the hooks for . + virtual int suspend (void) const; + virtual int resume (void) const; + virtual int init (int argc, ACE_TCHAR *argv[]) const; + virtual int fini (void) const; + virtual int info (ACE_TCHAR **str, size_t len) const; + + /// Add a new ACE_Module to the top of the ACE_Stream. + int push (ACE_Module_Type *new_module); + + /// Search for @a module and remove it from the ACE_Stream. + int remove (ACE_Module_Type *module); + + /// Locate the ACE_Module with @a mod_name. + ACE_Module_Type *find (const ACE_TCHAR *mod_name) const; + + /// Dump the state of an object. + void dump (void) const; + + /// Declare the dynamic allocation hooks. + ACE_ALLOC_HOOK_DECLARE; + +private: + /// Pointer to the head of the ACE_Module list. + ACE_Module_Type *head_; +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +#include "ace/Service_Types.inl" +#endif /* __ACE_INLINE__ */ + +#include /**/ "ace/post.h" + +#endif /* _SERVICE_TYPE_H */ diff --git a/dep/ACE_wrappers/ace/Service_Types.inl b/dep/ACE_wrappers/ace/Service_Types.inl new file mode 100644 index 00000000000..f7f93591562 --- /dev/null +++ b/dep/ACE_wrappers/ace/Service_Types.inl @@ -0,0 +1,32 @@ +// -*- C++ -*- +// +// $Id: Service_Types.inl 80826 2008-03-04 14:51:23Z wotte $ + +#include "ace/ACE.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_INLINE void * +ACE_Service_Type_Impl::object (void) const +{ + ACE_TRACE ("ACE_Service_Type_Impl::object"); + return this->obj_; +} + +ACE_INLINE const ACE_TCHAR * +ACE_Service_Type_Impl::name (void) const +{ + ACE_TRACE ("ACE_Service_Type_Impl::name"); + return this->name_; +} + +ACE_INLINE void +ACE_Service_Type_Impl::name (const ACE_TCHAR *n) +{ + ACE_TRACE ("ACE_Service_Type_Impl::name"); + + ACE::strdelete (const_cast (this->name_)); + this->name_ = ACE::strnew (n); +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Shared_Memory.cpp b/dep/ACE_wrappers/ace/Shared_Memory.cpp new file mode 100644 index 00000000000..ccb1f26c401 --- /dev/null +++ b/dep/ACE_wrappers/ace/Shared_Memory.cpp @@ -0,0 +1,13 @@ +// $Id: Shared_Memory.cpp 80826 2008-03-04 14:51:23Z wotte $ + +#include "ace/Shared_Memory.h" + +ACE_RCSID(ace, Shared_Memory, "$Id: Shared_Memory.cpp 80826 2008-03-04 14:51:23Z wotte $") + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_Shared_Memory::~ACE_Shared_Memory (void) +{ +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Shared_Memory.h b/dep/ACE_wrappers/ace/Shared_Memory.h new file mode 100644 index 00000000000..6dbd17ff492 --- /dev/null +++ b/dep/ACE_wrappers/ace/Shared_Memory.h @@ -0,0 +1,58 @@ +// -*- C++ -*- + +//========================================================================== +/** + * @file Shared_Memory.h + * + * $Id: Shared_Memory.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Doug Schmidt + */ +//========================================================================== + + +#ifndef ACE_SHARED_MEMORY_H +#define ACE_SHARED_MEMORY_H + +#include /**/ "ace/pre.h" + +#include /**/ "ace/ACE_export.h" + +#include "ace/os_include/os_stddef.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +/** + * @class ACE_Shared_Memory + * + * @brief This base class adapts both System V shared memory and "BSD" + * mmap to a common API. + * + * This is a very simple-minded wrapper, i.e., it really is only + * useful for allocating large contiguous chunks of shared + * memory. For a much more sophisticated version, please check + * out the class. + */ +class ACE_Export ACE_Shared_Memory +{ +public: + virtual ~ACE_Shared_Memory (void); + + // = Note that all the following methods are pure virtual. + virtual int close (void) = 0; + virtual int remove (void) = 0; + virtual void *malloc (size_t = 0) = 0; + virtual int free (void *p) = 0; + virtual size_t get_segment_size (void) const = 0; + virtual ACE_HANDLE get_id (void) const = 0; +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#include /**/ "ace/post.h" + +#endif /* ACE_SHARED_MEMORY_H */ diff --git a/dep/ACE_wrappers/ace/Shared_Memory_MM.cpp b/dep/ACE_wrappers/ace/Shared_Memory_MM.cpp new file mode 100644 index 00000000000..d6d1ed90cce --- /dev/null +++ b/dep/ACE_wrappers/ace/Shared_Memory_MM.cpp @@ -0,0 +1,111 @@ +// $Id: Shared_Memory_MM.cpp 80826 2008-03-04 14:51:23Z wotte $ + +#include "ace/Shared_Memory_MM.h" + +#if !defined (__ACE_INLINE__) +#include "ace/Shared_Memory_MM.inl" +#endif /* __ACE_INLINE__ */ + + +ACE_RCSID (ace, + Shared_Memory_MM, + "$Id: Shared_Memory_MM.cpp 80826 2008-03-04 14:51:23Z wotte $") + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_ALLOC_HOOK_DEFINE(ACE_Shared_Memory_MM) + +void +ACE_Shared_Memory_MM::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + ACE_TRACE ("ACE_Shared_Memory_MM::dump"); +#endif /* ACE_HAS_DUMP */ +} + +// Creates a shared memory segment of SIZE bytes. + +ACE_Shared_Memory_MM::ACE_Shared_Memory_MM (ACE_HANDLE handle, + size_t length, + int prot, + int share, + char *addr, + ACE_OFF_T pos) + : shared_memory_ (handle, length, prot, share, addr, pos) +{ + ACE_TRACE ("ACE_Shared_Memory_MM::ACE_Shared_Memory_MM"); +} + +ACE_Shared_Memory_MM::ACE_Shared_Memory_MM (const ACE_TCHAR *file_name, + size_t len, + int flags, + int mode, + int prot, + int share, + char *addr, + ACE_OFF_T pos) + : shared_memory_ (file_name, len, flags, mode, + prot, share, addr, pos) +{ + ACE_TRACE ("ACE_Shared_Memory_MM::ACE_Shared_Memory_MM"); +} + +// The "do-nothing" constructor. + +ACE_Shared_Memory_MM::ACE_Shared_Memory_MM (void) +{ + ACE_TRACE ("ACE_Shared_Memory_MM::ACE_Shared_Memory_MM"); +} + +// The overall size of the segment. + +size_t +ACE_Shared_Memory_MM::get_segment_size (void) const +{ + ACE_TRACE ("ACE_Shared_Memory_MM::get_segment_size"); + // This cast is legit since the original length in open() is an int. + return this->shared_memory_.size (); +} + +// Unmaps the shared memory segment. + +int +ACE_Shared_Memory_MM::remove (void) +{ + ACE_TRACE ("ACE_Shared_Memory_MM::remove"); + return shared_memory_.remove (); +} + +// Closes (unmaps) the shared memory segment. + +int +ACE_Shared_Memory_MM::close (void) +{ + ACE_TRACE ("ACE_Shared_Memory_MM::close"); + return shared_memory_.unmap (); +} + +void * +ACE_Shared_Memory_MM::malloc (size_t) +{ + ACE_TRACE ("ACE_Shared_Memory_MM::malloc"); + void *addr = 0; + + return this->shared_memory_ (addr) == -1 ? 0 : addr; +} + +ACE_HANDLE +ACE_Shared_Memory_MM::get_id (void) const +{ + ACE_TRACE ("ACE_Shared_Memory_MM::get_id"); + return this->shared_memory_.handle (); +} + +int +ACE_Shared_Memory_MM::free (void *p) +{ + ACE_TRACE ("ACE_Shared_Memory_MM::free"); + return p != 0; +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Shared_Memory_MM.h b/dep/ACE_wrappers/ace/Shared_Memory_MM.h new file mode 100644 index 00000000000..e02b21249ac --- /dev/null +++ b/dep/ACE_wrappers/ace/Shared_Memory_MM.h @@ -0,0 +1,120 @@ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file Shared_Memory_MM.h + * + * $Id: Shared_Memory_MM.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Douglas C. Schmidt + */ +//============================================================================= + + +#ifndef ACE_SHARED_MALLOC_MM_H +#define ACE_SHARED_MALLOC_MM_H +#include /**/ "ace/pre.h" + +#include "ace/Shared_Memory.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/Mem_Map.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +/** + * @class ACE_Shared_Memory_MM + * + * @brief Shared memory wrapper based on MMAP. + * + * This class provides a very simple-minded shared memory manager. We + * strongly recommend that you do NOT use this class. Instead, please + * use @c ACE_Malloc, which has much more powerful capabilities. + */ +class ACE_Export ACE_Shared_Memory_MM : public ACE_Shared_Memory +{ +public: + // = Initialization and termination methods. + /// Default constructor. + ACE_Shared_Memory_MM (void); + + /// Constructor. + ACE_Shared_Memory_MM (ACE_HANDLE handle, + size_t length = static_cast (-1), + int prot = PROT_RDWR, + int share = ACE_MAP_PRIVATE, + char *addr = 0, + ACE_OFF_T pos = 0); + + /// Constructor. + ACE_Shared_Memory_MM (const ACE_TCHAR *file_name, + size_t length = static_cast (-1), + int flags = O_RDWR | O_CREAT, + int mode = ACE_DEFAULT_FILE_PERMS, + int prot = PROT_RDWR, + int share = ACE_MAP_SHARED, + char *addr = 0, ACE_OFF_T pos = 0); + + /// Open method. + int open (ACE_HANDLE handle, + size_t length = static_cast (-1), + int prot = PROT_RDWR, + int share = ACE_MAP_PRIVATE, + char *addr = 0, + ACE_OFF_T pos = 0); + + /// Open method. + int open (const ACE_TCHAR *file_name, + size_t length = static_cast (-1), + int flags = O_RDWR | O_CREAT, + int mode = ACE_DEFAULT_FILE_PERMS, + int prot = PROT_RDWR, + int share = ACE_MAP_SHARED, + char *addr = 0, + ACE_OFF_T pos = 0); + + /// Return the name of file that is mapped (if any). + const ACE_TCHAR *filename (void) const; + + /// Close down the shared memory segment. + virtual int close (void); + + /// Remove the shared memory segment and the underlying file. + virtual int remove (void); + + // = Allocation and deallocation methods. + /// Create a new chuck of memory containing @a size bytes. + virtual void *malloc (size_t size = 0); + + /// Free a chuck of memory allocated by + /// . + virtual int free (void *p); + + /// Return the size of the shared memory segment. + virtual size_t get_segment_size (void) const; + + /// Return the ID of the shared memory segment (i.e., an ACE_HANDLE). + virtual ACE_HANDLE get_id (void) const; + + /// Dump the state of an object. + void dump (void) const; + + /// Declare the dynamic allocation hooks. + ACE_ALLOC_HOOK_DECLARE; + +private: + /// This version is implemented with memory-mapped files. + ACE_Mem_Map shared_memory_; +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +#include "ace/Shared_Memory_MM.inl" +#endif /* __ACE_INLINE__ */ + +#include /**/ "ace/post.h" +#endif /* ACE_SHARED_MALLOC_MM_H */ diff --git a/dep/ACE_wrappers/ace/Shared_Memory_MM.inl b/dep/ACE_wrappers/ace/Shared_Memory_MM.inl new file mode 100644 index 00000000000..6e1f4b76616 --- /dev/null +++ b/dep/ACE_wrappers/ace/Shared_Memory_MM.inl @@ -0,0 +1,42 @@ +// -*- C++ -*- +// +// $Id: Shared_Memory_MM.inl 80826 2008-03-04 14:51:23Z wotte $ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +// Return the name of file that is mapped (if any). + +ACE_INLINE const ACE_TCHAR * +ACE_Shared_Memory_MM::filename (void) const +{ + return this->shared_memory_.filename (); +} + +ACE_INLINE int +ACE_Shared_Memory_MM::open (ACE_HANDLE handle, + size_t length, + int prot, + int share, + char *addr, + ACE_OFF_T pos) +{ + ACE_TRACE ("ACE_Shared_Memory_MM::open"); + return shared_memory_.map (handle, length, prot, share, addr, pos); +} + +ACE_INLINE int +ACE_Shared_Memory_MM::open (const ACE_TCHAR *file_name, + size_t len, + int flags, + int mode, + int prot, + int share, + char *addr, + ACE_OFF_T pos) +{ + ACE_TRACE ("ACE_Shared_Memory_MM::open"); + return shared_memory_.map (file_name, len, flags, mode, + prot, share, addr, pos); +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Shared_Memory_Pool.cpp b/dep/ACE_wrappers/ace/Shared_Memory_Pool.cpp new file mode 100644 index 00000000000..b61febc3171 --- /dev/null +++ b/dep/ACE_wrappers/ace/Shared_Memory_Pool.cpp @@ -0,0 +1,461 @@ +// $Id: Shared_Memory_Pool.cpp 80826 2008-03-04 14:51:23Z wotte $ + +// Shared_Memory_Pool.cpp +#include "ace/Shared_Memory_Pool.h" +#include "ace/OS_NS_sys_shm.h" +#include "ace/Log_Msg.h" + +ACE_RCSID(ace, Shared_Memory_Pool, "$Id: Shared_Memory_Pool.cpp 80826 2008-03-04 14:51:23Z wotte $") + +#if !defined (ACE_LACKS_SYSV_SHMEM) + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_ALLOC_HOOK_DEFINE(ACE_Shared_Memory_Pool) + +ACE_Shared_Memory_Pool_Options::ACE_Shared_Memory_Pool_Options ( + const char *base_addr, + size_t max_segments, + size_t file_perms, + ACE_OFF_T minimum_bytes, + size_t segment_size) + : base_addr_ (base_addr), + max_segments_ (max_segments), + minimum_bytes_ (minimum_bytes), + file_perms_ (file_perms), + segment_size_ (segment_size) +{ + ACE_TRACE ("ACE_Shared_Memory_Pool_Options::ACE_Shared_Memory_Pool_Options"); +} + +void +ACE_Shared_Memory_Pool::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + ACE_TRACE ("ACE_Shared_Memory_Pool::dump"); +#endif /* ACE_HAS_DUMP */ +} + +int +ACE_Shared_Memory_Pool::in_use (ACE_OFF_T &offset, + size_t &counter) +{ + offset = 0; + SHM_TABLE *st = reinterpret_cast (this->base_addr_); + shmid_ds buf; + + for (counter = 0; + counter < this->max_segments_ && st[counter].used_ == 1; + counter++) + { + if (ACE_OS::shmctl (st[counter].shmid_, IPC_STAT, &buf) == -1) + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("(%P|%t) %p\n"), + ACE_TEXT ("shmctl")), + -1); + offset += buf.shm_segsz; + // ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%P|%t) segment size = %d, offset = %d\n"), buf.shm_segsz, offset)); + } + + return 0; +} + +int +ACE_Shared_Memory_Pool::find_seg (const void* const searchPtr, + ACE_OFF_T &offset, + size_t &counter) +{ + offset = 0; + SHM_TABLE *st = reinterpret_cast (this->base_addr_); + shmid_ds buf; + + for (counter = 0; + counter < this->max_segments_ + && st[counter].used_ == 1; + counter++) + { + if (ACE_OS::shmctl (st[counter].shmid_, IPC_STAT, &buf) == -1) + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("(%P|%t) %p\n"), + ACE_TEXT ("shmctl")), + -1); + offset += buf.shm_segsz; + + // If segment 'counter' starts at a location greater than the + // place we are searching for. We then decrement the offset to + // the start of counter-1. (flabar@vais.net) + if (((ptrdiff_t) offset + (ptrdiff_t) (this->base_addr_)) > (ptrdiff_t) searchPtr) + { + --counter; + offset -= buf.shm_segsz; + return 0; + } + // ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%P|%t) segment size = %d, offset = %d\n"), buf.shm_segsz, offset)); + } + + return 0; +} + +int +ACE_Shared_Memory_Pool::commit_backing_store_name (size_t rounded_bytes, + ACE_OFF_T &offset) +{ + ACE_TRACE ("ACE_Shared_Memory_Pool::commit_backing_store_name"); + + size_t counter; + SHM_TABLE *st = reinterpret_cast (this->base_addr_); + + if (this->in_use (offset, counter) == -1) + return -1; + + if (counter == this->max_segments_) + ACE_ERROR_RETURN ((LM_ERROR, + "exceeded max number of segments = %d, base = %u, offset = %u\n", + counter, + this->base_addr_, + offset), + -1); + else + { + int shmid = ACE_OS::shmget (st[counter].key_, + rounded_bytes, + this->file_perms_ | IPC_CREAT | IPC_EXCL); + if (shmid == -1) + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("(%P|%t) %p\n"), + ACE_TEXT ("shmget")), + -1); + st[counter].shmid_ = shmid; + st[counter].used_ = 1; + + void *address = (void *) (((char *) this->base_addr_) + offset); + void *shmem = ACE_OS::shmat (st[counter].shmid_, + (char *) address, + 0); + + if (shmem != address) + ACE_ERROR_RETURN ((LM_ERROR, + "(%P|%t) %p, shmem = %u, address = %u\n", + "shmat", + shmem, + address), + -1); + } + return 0; +} + +// Handle SIGSEGV and SIGBUS signals to remap shared memory properly. + +int +ACE_Shared_Memory_Pool::handle_signal (int , siginfo_t *siginfo, ucontext_t *) +{ + ACE_TRACE ("ACE_Shared_Memory_Pool::handle_signal"); + // ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("signal %S occurred\n"), signum)); + + // While FreeBSD 5.X has a siginfo_t struct with a si_addr field, + // it does not define SEGV_MAPERR. +#if defined (ACE_HAS_SIGINFO_T) && !defined (ACE_LACKS_SI_ADDR) && \ + (defined (SEGV_MAPERR) || defined (SEGV_MEMERR)) + ACE_OFF_T offset; + // Make sure that the pointer causing the problem is within the + // range of the backing store. + + if (siginfo != 0) + { + // ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%P|%t) si_signo = %d, si_code = %d, addr = %u\n"), siginfo->si_signo, siginfo->si_code, siginfo->si_addr)); + size_t counter; + if (this->in_use (offset, counter) == -1) + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("(%P|%t) %p\n"), + ACE_TEXT ("in_use"))); +#if !defined(_UNICOS) + else if (!(siginfo->si_code == SEGV_MAPERR + && siginfo->si_addr < (((char *) this->base_addr_) + offset) + && siginfo->si_addr >= ((char *) this->base_addr_))) + ACE_ERROR_RETURN ((LM_ERROR, + "(%P|%t) address %u out of range\n", + siginfo->si_addr), + -1); +#else /* ! _UNICOS */ + else if (!(siginfo->si_code == SEGV_MEMERR + && siginfo->si_addr < (((unsigned long) this->base_addr_) + offset) + && siginfo->si_addr >= ((unsigned long) this->base_addr_))) + ACE_ERROR_RETURN ((LM_ERROR, + "(%P|%t) address %u out of range\n", + siginfo->si_addr), + -1); +#endif /* ! _UNICOS */ + } + + // The above if case will check to see that the address is in the + // proper range. Therefore there is a segment out there that the + // pointer wants to point into. Find the segment that someone else + // has used and attach to it (flabar@vais.net) + + size_t counter; // ret value to get shmid from the st table. + +#if !defined(_UNICOS) + if (this->find_seg (siginfo->si_addr, offset, counter) == -1) +#else /* ! _UNICOS */ + if (this->find_seg ((const void *)siginfo->si_addr, offset, counter) == -1) +#endif /* ! _UNICOS */ + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("(%P|%t) %p\n"), + ACE_TEXT ("in_use")), + -1); + + void *address = (void *) (((char *) this->base_addr_) + offset); + SHM_TABLE *st = reinterpret_cast (this->base_addr_); + + void *shmem = ACE_OS::shmat (st[counter].shmid_, (char *) address, 0); + + if (shmem != address) + ACE_ERROR_RETURN ((LM_ERROR, + "(%P|%t) %p, shmem = %u, address = %u\n", + "shmat", + shmem, + address), + -1); + + // NOTE: this won't work if we dont have SIGINFO_T or SI_ADDR +#else + ACE_UNUSED_ARG (siginfo); +#endif /* ACE_HAS_SIGINFO_T && !defined (ACE_LACKS_SI_ADDR) */ + + return 0; +} + +ACE_Shared_Memory_Pool::ACE_Shared_Memory_Pool ( + const ACE_TCHAR *backing_store_name, + const OPTIONS *options) + : base_addr_ (0), + file_perms_ (ACE_DEFAULT_FILE_PERMS), + max_segments_ (ACE_DEFAULT_MAX_SEGMENTS), + minimum_bytes_ (0), + segment_size_ (ACE_DEFAULT_SEGMENT_SIZE) +{ + ACE_TRACE ("ACE_Shared_Memory_Pool::ACE_Shared_Memory_Pool"); + + // Only change the defaults if != 0. + if (options) + { + this->base_addr_ = + reinterpret_cast (const_cast (options->base_addr_)); + this->max_segments_ = options->max_segments_; + this->file_perms_ = options->file_perms_; + this->minimum_bytes_ = options->minimum_bytes_; + this->segment_size_ = options->segment_size_; + } + + if (backing_store_name) + { + // Convert the string into a number that is used as the segment + // key. + + int segment_key; + int result = ::sscanf (ACE_TEXT_ALWAYS_CHAR (backing_store_name), + "%d", + &segment_key); + + if (result == 0 || result == EOF) + // The conversion to a number failed so hash with crc32 + // ACE::crc32 is also used in . + this->base_shm_key_ = + (key_t) ACE::crc32 (ACE_TEXT_ALWAYS_CHAR (backing_store_name)); + else + this->base_shm_key_ = segment_key; + + if (this->base_shm_key_ == IPC_PRIVATE) + // Make sure that the segment can be shared between unrelated + // processes. + this->base_shm_key_ = ACE_DEFAULT_SHM_KEY; + } + else + this->base_shm_key_ = ACE_DEFAULT_SHM_KEY; + + if (this->signal_handler_.register_handler (SIGSEGV, this) == -1) + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("%p\n"), + ACE_TEXT ("ACE_Sig_Handler::register_handler"))); +} + +ACE_Shared_Memory_Pool::~ACE_Shared_Memory_Pool (void) +{ +} + +// Ask system for more shared memory. + +void * +ACE_Shared_Memory_Pool::acquire (size_t nbytes, + size_t &rounded_bytes) +{ + ACE_TRACE ("ACE_Shared_Memory_Pool::acquire"); + + rounded_bytes = this->round_up (nbytes); + + // ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%P|%t) acquiring more chunks, nbytes = %d, rounded_bytes = %d\n"), nbytes, rounded_bytes)); + + ACE_OFF_T offset; + + if (this->commit_backing_store_name (rounded_bytes, offset) == -1) + return 0; + + // ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%P|%t) acquired more chunks, nbytes = %d, rounded_bytes = %d\n"), nbytes, rounded_bytes)); + return ((char *) this->base_addr_) + offset; +} + +// Ask system for initial chunk of shared memory. + +void * +ACE_Shared_Memory_Pool::init_acquire (size_t nbytes, + size_t &rounded_bytes, + int &first_time) +{ + ACE_TRACE ("ACE_Shared_Memory_Pool::init_acquire"); + + ACE_OFF_T shm_table_offset = ACE::round_to_pagesize (sizeof (SHM_TABLE)); + rounded_bytes = this->round_up (nbytes > (size_t) this->minimum_bytes_ + ? nbytes + : (size_t) this->minimum_bytes_); + + // Acquire the semaphore to serialize initialization and prevent + // race conditions. + + int shmid = ACE_OS::shmget (this->base_shm_key_, + rounded_bytes + shm_table_offset, + this->file_perms_ | IPC_CREAT | IPC_EXCL); + if (shmid == -1) + { + if (errno != EEXIST) + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("(%P|%t) %p\n"), + ACE_TEXT ("shmget")), + 0); + first_time = 0; + + shmid = ACE_OS::shmget (this->base_shm_key_, 0, 0); + + if (shmid == -1) + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("(%P|%t) %p\n"), + ACE_TEXT ("shmget")), + 0); + + // This implementation doesn't care if we don't get the key we + // want... + this->base_addr_ = + ACE_OS::shmat (shmid, + reinterpret_cast (this->base_addr_), + 0); + if (this->base_addr_ == reinterpret_cast (-1)) + ACE_ERROR_RETURN ((LM_ERROR, + "(%P|%t) %p, base_addr = %u\n", + "shmat", + this->base_addr_), + 0); + } + else + { + first_time = 1; + + // This implementation doesn't care if we don't get the key we + // want... + this->base_addr_ = + ACE_OS::shmat (shmid, + reinterpret_cast (this->base_addr_), + 0); + if (this->base_addr_ == reinterpret_cast (-1)) + ACE_ERROR_RETURN ((LM_ERROR, + "(%P|%t) %p, base_addr = %u\n", + "shmat", + this->base_addr_), 0); + + SHM_TABLE *st = reinterpret_cast (this->base_addr_); + st[0].key_ = this->base_shm_key_; + st[0].shmid_ = shmid; + + st[0].used_ = 1; + + for (size_t counter = 1; // Skip over the first entry... + counter < this->max_segments_; + counter++) + { + st[counter].key_ = this->base_shm_key_ + counter; + st[counter].shmid_ = 0; + st[counter].used_ = 0; + } + } + + return (void *) (((char *) this->base_addr_) + shm_table_offset); +} + +// Instruct the memory pool to release all of its resources. + +int +ACE_Shared_Memory_Pool::release (int) +{ + ACE_TRACE ("ACE_Shared_Memory_Pool::release"); + + int result = 0; + SHM_TABLE *st = reinterpret_cast (this->base_addr_); + + for (size_t counter = 0; + counter < this->max_segments_ && st[counter].used_ == 1; + counter++) + if (ACE_OS::shmctl (st[counter].shmid_, IPC_RMID, 0) == -1) + result = -1; + + return result; +} + +int +ACE_Shared_Memory_Pool::sync (ssize_t, int) +{ + ACE_TRACE ("ACE_Shared_Memory_Pool::sync"); + return 0; +} + +int +ACE_Shared_Memory_Pool::sync (void *, size_t, int) +{ + ACE_TRACE ("ACE_Shared_Memory_Pool::sync"); + return 0; +} + +int +ACE_Shared_Memory_Pool::protect (ssize_t, int) +{ + ACE_TRACE ("ACE_Shared_Memory_Pool::protect"); + return 0; +} + +int +ACE_Shared_Memory_Pool::protect (void *, size_t, int) +{ + ACE_TRACE ("ACE_Shared_Memory_Pool::protect"); + return 0; +} + +void * +ACE_Shared_Memory_Pool::base_addr (void) const +{ + ACE_TRACE ("ACE_Shared_Memory_Pool::base_addr"); + return this->base_addr_; +} + +// Implement the algorithm for rounding up the request to an +// appropriate chunksize. + +size_t +ACE_Shared_Memory_Pool::round_up (size_t nbytes) +{ + ACE_TRACE ("ACE_Shared_Memory_Pool::round_up"); + if (nbytes < this->segment_size_) + nbytes = this->segment_size_; + + return ACE::round_to_pagesize (nbytes); +} + +ACE_END_VERSIONED_NAMESPACE_DECL + +#endif /* !ACE_LACKS_SYSV_SHMEM */ diff --git a/dep/ACE_wrappers/ace/Shared_Memory_Pool.h b/dep/ACE_wrappers/ace/Shared_Memory_Pool.h new file mode 100644 index 00000000000..79cb970e712 --- /dev/null +++ b/dep/ACE_wrappers/ace/Shared_Memory_Pool.h @@ -0,0 +1,210 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Shared_Memory_Pool.h + * + * $Id: Shared_Memory_Pool.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Dougls C. Schmidt + * @author Prashant Jain + */ +//============================================================================= + +#ifndef ACE_SHARED_MEMORY_POOL_H +#define ACE_SHARED_MEMORY_POOL_H + +#include /**/ "ace/pre.h" + +#include /**/ "ace/ACE_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#if !defined (ACE_LACKS_SYSV_SHMEM) + +#include "ace/ACE.h" +#include "ace/Event_Handler.h" +#include "ace/Sig_Handler.h" +#include "ace/os_include/sys/os_mman.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +/** + * @class ACE_Shared_Memory_Pool_Options + * + * @brief Helper class for Shared Memory Pool constructor options. + * + * This should be a nested class, but that breaks too many + * compilers. + */ +class ACE_Export ACE_Shared_Memory_Pool_Options +{ +public: + /// Initialization method. + ACE_Shared_Memory_Pool_Options ( + const char *base_addr = ACE_DEFAULT_BASE_ADDR, + size_t max_segments = ACE_DEFAULT_MAX_SEGMENTS, + size_t file_perms = ACE_DEFAULT_FILE_PERMS, + ACE_OFF_T minimum_bytes = 0, + size_t segment_size = ACE_DEFAULT_SEGMENT_SIZE); + + /// Base address of the memory-mapped backing store. + const char *base_addr_; + + /// Number of shared memory segments to allocate. + size_t max_segments_; + + /// What the minimum bytes of the initial segment should be. + ACE_OFF_T minimum_bytes_; + + /// File permissions to use when creating/opening a segment. + size_t file_perms_; + + /// Shared memory segment size. + size_t segment_size_; +}; + +/** + * @class ACE_Shared_Memory_Pool + * + * @brief Make a memory pool that is based on System V shared memory + * (shmget(2) etc.). This implementation allows memory to be + * shared between processes. If your platform doesn't support + * System V shared memory (e.g., Win32 and many RTOS platforms + * do not) then you should use ACE_MMAP_Memory_Pool instead of this + * class. In fact, you should probably use ACE_MMAP_Memory_Pool on + * platforms that *do* support System V shared memory since it + * provides more powerful features, such as persistent backing store + * and greatly scalability. + */ +class ACE_Export ACE_Shared_Memory_Pool : public ACE_Event_Handler +{ +public: + typedef ACE_Shared_Memory_Pool_Options OPTIONS; + + /// Initialize the pool. + ACE_Shared_Memory_Pool (const ACE_TCHAR *backing_store_name = 0, + const OPTIONS *options = 0); + + virtual ~ACE_Shared_Memory_Pool (void); + + /// Ask system for initial chunk of local memory. + virtual void *init_acquire (size_t nbytes, + size_t &rounded_bytes, + int &first_time); + + /** + * Acquire at least @a nbytes from the memory pool. @a rounded_byes is + * the actual number of bytes allocated. Also acquires an internal + * semaphore that ensures proper serialization of Memory_Pool + * initialization across processes. + */ + virtual void *acquire (size_t nbytes, + size_t &rounded_bytes); + + /// Instruct the memory pool to release all of its resources. + virtual int release (int destroy = 1); + + /// Sync the memory region to the backing store starting at + /// @c this->base_addr_. + virtual int sync (ssize_t len = -1, int flags = MS_SYNC); + + /// Sync the memory region to the backing store starting at @a addr. + virtual int sync (void *addr, size_t len, int flags = MS_SYNC); + + /** + * Change the protection of the pages of the mapped region to @a prot + * starting at @c this->base_addr_ up to @a len bytes. If @a len == -1 + * then change protection of all pages in the mapped region. + */ + virtual int protect (ssize_t len = -1, int prot = PROT_RDWR); + + /// Change the protection of the pages of the mapped region to @a prot + /// starting at @a addr up to @a len bytes. + virtual int protect (void *addr, size_t len, int prot = PROT_RDWR); + + /// Return the base address of this memory pool, 0 if base_addr + /// never changes. + virtual void *base_addr (void) const; + + /// Dump the state of an object. + virtual void dump (void) const; + + /// Declare the dynamic allocation hooks. + ACE_ALLOC_HOOK_DECLARE; + +protected: + /// Implement the algorithm for rounding up the request to an + /// appropriate chunksize. + virtual size_t round_up (size_t nbytes); + + /** + * Commits a new shared memory segment if necessary after an + * or a signal. @a offset is set to the new offset into + * the backing store. + */ + virtual int commit_backing_store_name (size_t rounded_bytes, + ACE_OFF_T &offset); + + /// Keeps track of all the segments being used. + struct SHM_TABLE + { + /// Shared memory segment key. + key_t key_; + + /// Shared memory segment internal id. + int shmid_; + + /// Is the segment currently used.; + int used_; + }; + + /** + * Base address of the shared memory segment. If this has the value + * of 0 then the OS is free to select any address, otherwise this + * value is what the OS must try to use to map the shared memory + * segment. + */ + void *base_addr_; + + /// File permissions to use when creating/opening a segment. + size_t file_perms_; + + /// Number of shared memory segments in the table. + size_t max_segments_; + + /// What the minimim bytes of the initial segment should be. + ACE_OFF_T minimum_bytes_; + + /// Shared memory segment size. + size_t segment_size_; + + /// Base shared memory key for the segment. + key_t base_shm_key_; + + /// Find the segment that contains the @a searchPtr + virtual int find_seg (const void *const searchPtr, + ACE_OFF_T &offset, + size_t &counter); + + /// Determine how much memory is currently in use. + virtual int in_use (ACE_OFF_T &offset, + size_t &counter); + + /// Handles SIGSEGV. + ACE_Sig_Handler signal_handler_; + + /// Handle SIGSEGV and SIGBUS signals to remap shared memory + /// properly. + virtual int handle_signal (int signum, siginfo_t *, ucontext_t *); +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#endif /* !ACE_LACKS_SYSV_SHMEM */ + +#include /**/ "ace/post.h" + +#endif /* ACE_SHARED_MEMORY_POOL_H */ diff --git a/dep/ACE_wrappers/ace/Shared_Memory_SV.cpp b/dep/ACE_wrappers/ace/Shared_Memory_SV.cpp new file mode 100644 index 00000000000..fe26688b098 --- /dev/null +++ b/dep/ACE_wrappers/ace/Shared_Memory_SV.cpp @@ -0,0 +1,88 @@ +// $Id: Shared_Memory_SV.cpp 80826 2008-03-04 14:51:23Z wotte $ + +#include "ace/Shared_Memory_SV.h" + +#if !defined (__ACE_INLINE__) +#include "ace/Shared_Memory_SV.inl" +#endif /* __ACE_INLINE__ */ + + +ACE_RCSID (ace, + Shared_Memory_SV, + "$Id: Shared_Memory_SV.cpp 80826 2008-03-04 14:51:23Z wotte $") + + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_ALLOC_HOOK_DEFINE(ACE_Shared_Memory_SV) + +void +ACE_Shared_Memory_SV::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + ACE_TRACE ("ACE_Shared_Memory_SV::dump"); +#endif /* ACE_HAS_DUMP */ +} + +ACE_Shared_Memory_SV::ACE_Shared_Memory_SV (key_t id, + size_t length, + int create, + int perms, + void *addr, + int flags) + : shared_memory_ (id, length, create, perms, addr, flags) +{ + ACE_TRACE ("ACE_Shared_Memory_SV::ACE_Shared_Memory_SV"); +} + +// The overall size of the segment. + +size_t +ACE_Shared_Memory_SV::get_segment_size (void) const +{ + ACE_TRACE ("ACE_Shared_Memory_SV::get_segment_size"); + // This cast is ok since the 'open' method for this class allows only + // an 'int' size. Therefore, this case should not lose information. + return this->shared_memory_.get_segment_size (); +} + +// Removes the shared memory segment. + +int +ACE_Shared_Memory_SV::remove (void) +{ + ACE_TRACE ("ACE_Shared_Memory_SV::remove"); + return shared_memory_.remove (); +} + +// Closes (detaches) the shared memory segment. + +int +ACE_Shared_Memory_SV::close (void) +{ + ACE_TRACE ("ACE_Shared_Memory_SV::close"); + return shared_memory_.detach (); +} + +void * +ACE_Shared_Memory_SV::malloc (size_t) +{ + ACE_TRACE ("ACE_Shared_Memory_SV::malloc"); + return this->shared_memory_.get_segment_ptr (); +} + +ACE_HANDLE +ACE_Shared_Memory_SV::get_id (void) const +{ + ACE_TRACE ("ACE_Shared_Memory_SV::get_id"); + return this->shared_memory_.get_id (); +} + +int +ACE_Shared_Memory_SV::free (void *p) +{ + ACE_TRACE ("ACE_Shared_Memory_SV::free"); + return p != 0; +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Shared_Memory_SV.h b/dep/ACE_wrappers/ace/Shared_Memory_SV.h new file mode 100644 index 00000000000..7ae62a3323f --- /dev/null +++ b/dep/ACE_wrappers/ace/Shared_Memory_SV.h @@ -0,0 +1,101 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Shared_Memory_SV.h + * + * $Id: Shared_Memory_SV.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Douglas C. Schmidt + */ +//============================================================================= + + +#ifndef ACE_SHARED_MALLOC_SV_H +#define ACE_SHARED_MALLOC_SV_H +#include /**/ "ace/pre.h" + +#include "ace/Shared_Memory.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/SV_Shared_Memory.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +/** + * @class ACE_Shared_Memory_SV + * + * @brief Shared memory wrapper based on System V shared memory. + * + * This class provides a very simple-minded shared memory manager. We + * strongly recommend that you do NOT use this class. Instead, please + * use @c ACE_Malloc, which has much more powerful capabilities. + */ +class ACE_Export ACE_Shared_Memory_SV : public ACE_Shared_Memory +{ +public: + enum + { + ACE_CREATE = IPC_CREAT, + ACE_OPEN = 0 + }; + + // = Initialization and termination methods. + ACE_Shared_Memory_SV (void); + ACE_Shared_Memory_SV (key_t id, + size_t length, + int create = ACE_Shared_Memory_SV::ACE_OPEN, + int perms = ACE_DEFAULT_FILE_PERMS, + void *addr = 0, + int flags = 0); + + int open (key_t id, + size_t length, + int create = ACE_Shared_Memory_SV::ACE_OPEN, + int perms = ACE_DEFAULT_FILE_PERMS, + void *addr = 0, + int flags = 0); + + /// Close down the shared memory segment. + virtual int close (void); + + /// Remove the underlying shared memory segment. + virtual int remove (void); + + // = Allocation and deallocation methods. + /// Create a new chuck of memory containing @a size bytes. + virtual void *malloc (size_t = 0); + + /// Free a chuck of memory allocated by . + virtual int free (void *p); + + /// Return the size of the shared memory segment. + virtual size_t get_segment_size (void) const; + + /// Return the ID of the shared memory segment (i.e., a System V + /// shared memory internal id). + virtual ACE_HANDLE get_id (void) const; + + /// Dump the state of an object. + void dump (void) const; + + /// Declare the dynamic allocation hooks. + ACE_ALLOC_HOOK_DECLARE; + +private: + /// This version is implemented with System V shared memory + /// segments. + ACE_SV_Shared_Memory shared_memory_; +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +#include "ace/Shared_Memory_SV.inl" +#endif /* __ACE_INLINE__ */ + +#include /**/ "ace/post.h" +#endif /* ACE_SHARED_MALLOC_SV_H */ diff --git a/dep/ACE_wrappers/ace/Shared_Memory_SV.inl b/dep/ACE_wrappers/ace/Shared_Memory_SV.inl new file mode 100644 index 00000000000..1a586701cc3 --- /dev/null +++ b/dep/ACE_wrappers/ace/Shared_Memory_SV.inl @@ -0,0 +1,30 @@ +// -*- C++ -*- +// +// $Id: Shared_Memory_SV.inl 80826 2008-03-04 14:51:23Z wotte $ + +#include "ace/Global_Macros.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_INLINE int +ACE_Shared_Memory_SV::open (key_t id, + size_t length, + int create, + int perms, + void *addr, + int flags) +{ + ACE_TRACE ("ACE_Shared_Memory_SV::open"); + return shared_memory_.open_and_attach (id, length, create, + perms, addr, flags); +} + +// The "do-nothing" constructor. + +ACE_INLINE +ACE_Shared_Memory_SV::ACE_Shared_Memory_SV (void) +{ + ACE_TRACE ("ACE_Shared_Memory_SV::ACE_Shared_Memory_SV"); +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Shared_Object.cpp b/dep/ACE_wrappers/ace/Shared_Object.cpp new file mode 100644 index 00000000000..76c27df1cb1 --- /dev/null +++ b/dep/ACE_wrappers/ace/Shared_Object.cpp @@ -0,0 +1,54 @@ +// $Id: Shared_Object.cpp 80826 2008-03-04 14:51:23Z wotte $ + +#include "ace/Shared_Object.h" +#include "ace/Global_Macros.h" +#include "ace/config-all.h" + +/* Provide the abstract base class used to access dynamic linking + facilities */ + +#if !defined (__ACE_INLINE__) +#include "ace/Shared_Object.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID (ace, + Shared_Object, + "$Id: Shared_Object.cpp 80826 2008-03-04 14:51:23Z wotte $") + + ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +// Initializes object when dynamic linking occurs. + +int +ACE_Shared_Object::init (int, ACE_TCHAR *[]) +{ + ACE_TRACE ("ACE_Shared_Object::init"); + return 0; +} + +// Terminates object when dynamic unlinking occurs. + +int +ACE_Shared_Object::fini (void) +{ + ACE_TRACE ("ACE_Shared_Object::fini"); + return 0; +} + +// Returns information on active object. + +int +ACE_Shared_Object::info (ACE_TCHAR **, size_t) const +{ + ACE_TRACE ("ACE_Shared_Object::info"); + return 0; +} + +// Need to give a default implementation. + +ACE_Shared_Object::~ACE_Shared_Object (void) +{ + ACE_TRACE ("ACE_Shared_Object::~ACE_Shared_Object"); +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Shared_Object.h b/dep/ACE_wrappers/ace/Shared_Object.h new file mode 100644 index 00000000000..fedf051ba6f --- /dev/null +++ b/dep/ACE_wrappers/ace/Shared_Object.h @@ -0,0 +1,62 @@ +// -*- C++ -*- + +//========================================================================== +/** + * @file Shared_Object.h + * + * $Id: Shared_Object.h 81348 2008-04-14 09:00:32Z johnnyw $ + * + * @author Douglas C. Schmidt + */ +//========================================================================== + +#ifndef ACE_SHARED_OBJECT_H +#define ACE_SHARED_OBJECT_H + +#include /**/ "ace/pre.h" + +#include /**/ "ace/ACE_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/os_include/sys/os_types.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +/** + * @class ACE_Shared_Object + * + * @brief Provide the abstract base class used to access dynamic + * linking facilities. + */ +class ACE_Export ACE_Shared_Object +{ +public: + /// Constructor + ACE_Shared_Object (void); + + /// Destructor + virtual ~ACE_Shared_Object (void); + + /// Initializes object when dynamic linking occurs. + virtual int init (int argc, ACE_TCHAR *argv[]); + + /// Terminates object when dynamic unlinking occurs. + virtual int fini (void); + + /// Returns information on a service object. + virtual int info (ACE_TCHAR **info_string, size_t length = 0) const; + +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +#include "ace/Shared_Object.inl" +#endif /* __ACE_INLINE__ */ + +#include /**/ "ace/post.h" + +#endif /* ACE_SHARED_OBJECT_H */ diff --git a/dep/ACE_wrappers/ace/Shared_Object.inl b/dep/ACE_wrappers/ace/Shared_Object.inl new file mode 100644 index 00000000000..4f5f0020604 --- /dev/null +++ b/dep/ACE_wrappers/ace/Shared_Object.inl @@ -0,0 +1,12 @@ +// -*- C++ -*- +// +// $Id: Shared_Object.inl 80826 2008-03-04 14:51:23Z wotte $ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_INLINE +ACE_Shared_Object::ACE_Shared_Object (void) +{ +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Sig_Adapter.cpp b/dep/ACE_wrappers/ace/Sig_Adapter.cpp new file mode 100644 index 00000000000..d1af40f12d5 --- /dev/null +++ b/dep/ACE_wrappers/ace/Sig_Adapter.cpp @@ -0,0 +1,80 @@ +// $Id: Sig_Adapter.cpp 80826 2008-03-04 14:51:23Z wotte $ + +#include "ace/Sig_Adapter.h" + +ACE_RCSID(ace, Sig_Adapter, "$Id: Sig_Adapter.cpp 80826 2008-03-04 14:51:23Z wotte $") + + +ACE_Sig_Adapter::ACE_Sig_Adapter (ACE_Sig_Action &sa, int sigkey) + : sigkey_ (sigkey), + type_ (SIG_ACTION), + sa_ (sa) +{ + // ACE_TRACE ("ACE_Sig_Adapter::ACE_Sig_Adapter"); +} + +ACE_Sig_Adapter::ACE_Sig_Adapter (ACE_Event_Handler *eh, + int sigkey) + : sigkey_ (sigkey), + type_ (ACE_HANDLER), + eh_ (eh) +{ + // ACE_TRACE ("ACE_Sig_Adapter::ACE_Sig_Adapter"); +} + +ACE_Sig_Adapter::ACE_Sig_Adapter (ACE_Sig_Handler_Ex sig_func, + int sigkey) + : sigkey_ (sigkey), + type_ (C_FUNCTION), + sig_func_ (sig_func) +{ + // ACE_TRACE ("ACE_Sig_Adapter::ACE_Sig_Adapter"); +} + +ACE_Sig_Adapter::~ACE_Sig_Adapter () +{ +} + +int +ACE_Sig_Adapter::sigkey (void) +{ + ACE_TRACE ("ACE_Sig_Adapter::sigkey"); + return this->sigkey_; +} + +int +ACE_Sig_Adapter::handle_signal (int signum, + siginfo_t *siginfo, + ucontext_t *ucontext) +{ + ACE_TRACE ("ACE_Sig_Adapter::handle_signal"); + + switch (this->type_) + { + case SIG_ACTION: + { + // We have to dispatch a handler that was registered by a + // third-party library. + + ACE_Sig_Action old_disp; + + // Make sure this handler executes in the context it was + // expecting... + this->sa_.register_action (signum, &old_disp); + + ACE_Sig_Handler_Ex sig_func = ACE_Sig_Handler_Ex (this->sa_.handler ()); + + (*sig_func) (signum, siginfo, ucontext); + // Restore the original disposition. + old_disp.register_action (signum); + break; + } + case ACE_HANDLER: + this->eh_->handle_signal (signum, siginfo, ucontext); + break; + case C_FUNCTION: + (*this->sig_func_) (signum, siginfo, ucontext); + break; + } + return 0; +} diff --git a/dep/ACE_wrappers/ace/Sig_Adapter.h b/dep/ACE_wrappers/ace/Sig_Adapter.h new file mode 100644 index 00000000000..cbd6b399867 --- /dev/null +++ b/dep/ACE_wrappers/ace/Sig_Adapter.h @@ -0,0 +1,81 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Sig_Adapter.h + * + * $Id: Sig_Adapter.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Douglas C. Schmidt + */ +//============================================================================= + +#ifndef ACE_SIG_ADAPTER_H +#define ACE_SIG_ADAPTER_H + +#include /**/ "ace/pre.h" + +#include /**/ "ace/ACE_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/Event_Handler.h" +#include "ace/Signal.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +/** + * @class ACE_Sig_Adapter + * + * @brief Provide an adapter that transforms various types of signal + * handlers into the scheme used by the ACE_Reactor. + */ +class ACE_Export ACE_Sig_Adapter : public ACE_Event_Handler +{ +public: + ACE_Sig_Adapter (ACE_Sig_Action &, int sigkey); + ACE_Sig_Adapter (ACE_Event_Handler *, int sigkey); + ACE_Sig_Adapter (ACE_Sig_Handler_Ex, int sigkey = 0); + ~ACE_Sig_Adapter (void); + + /// Returns this signal key that's used to remove this from the + /// ACE_Reactor's internal table. + int sigkey (void); + + /// Called by the to dispatch the signal handler. + virtual int handle_signal (int, siginfo_t *, ucontext_t *); + +private: + /// Key for this signal handler (used to remove it). + int sigkey_; + + /// Is this an external handler or an ACE handler? + enum + { + /// We're just wrapping an ACE_Event_Handler. + ACE_HANDLER, + /// An ACE_Sig_Action. + SIG_ACTION, + /// A normal C function. + C_FUNCTION + } type_; + + // = This should be a union, but C++ won't allow that because the + // has a constructor. + /// This is an external handler (ugh). + ACE_Sig_Action sa_; + + /// This is an ACE hander. + ACE_Event_Handler *eh_; + + /// This is a normal C function. + ACE_Sig_Handler_Ex sig_func_; +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#include /**/ "ace/post.h" + +#endif /* ACE_SIG_ADAPTER_H */ diff --git a/dep/ACE_wrappers/ace/Sig_Handler.cpp b/dep/ACE_wrappers/ace/Sig_Handler.cpp new file mode 100644 index 00000000000..33bbb638bb4 --- /dev/null +++ b/dep/ACE_wrappers/ace/Sig_Handler.cpp @@ -0,0 +1,614 @@ +// $Id: Sig_Handler.cpp 81388 2008-04-23 14:02:05Z johnnyw $ + +#include "ace/Sig_Handler.h" +#include "ace/Sig_Adapter.h" +#include "ace/Signal.h" +#include "ace/Recursive_Thread_Mutex.h" +#include "ace/Managed_Object.h" +#include "ace/Containers.h" +#include "ace/Guard_T.h" + +#if !defined (__ACE_INLINE__) +#include "ace/Sig_Handler.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(ace, Sig_Handler, "$Id: Sig_Handler.cpp 81388 2008-04-23 14:02:05Z johnnyw $") + +#if defined (ACE_HAS_SIG_C_FUNC) + +extern "C" void +ace_sig_handler_dispatch (int signum, siginfo_t *info, ucontext_t *context) +{ + ACE_TRACE ("ace_sig_handler_dispatch"); + ACE_Sig_Handler::dispatch (signum, info, context); +} + +#define ace_signal_handler_dispatcher ACE_SignalHandler(ace_sig_handler_dispatch) + +extern "C" void +ace_sig_handlers_dispatch (int signum, siginfo_t *info, ucontext_t *context) +{ + ACE_TRACE ("ace_sig_handlers_dispatch"); + ACE_Sig_Handlers::dispatch (signum, info, context); +} + +#define ace_signal_handlers_dispatcher ACE_SignalHandler(ace_sig_handlers_dispatch) + +#else +#define ace_signal_handler_dispatcher ACE_SignalHandler(ACE_Sig_Handler::dispatch) + +#define ace_signal_handlers_dispatcher ACE_SignalHandler(ACE_Sig_Handlers::dispatch) +#endif /* ACE_HAS_SIG_C_FUNC */ + + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +// Array of Event_Handlers that will handle the signals. +ACE_Event_Handler *ACE_Sig_Handler::signal_handlers_[ACE_NSIG]; + +// Remembers if a signal has occurred. +sig_atomic_t ACE_Sig_Handler::sig_pending_ = 0; + + +ACE_ALLOC_HOOK_DEFINE(ACE_Sig_Handler) + +ACE_Sig_Handler::~ACE_Sig_Handler (void) +{ +} + +void +ACE_Sig_Handler::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + ACE_TRACE ("ACE_Sig_Handler::dump"); +#endif /* ACE_HAS_DUMP */ +} + +int +ACE_Sig_Handler::sig_pending (void) +{ + ACE_TRACE ("ACE_Sig_Handler::sig_pending"); + ACE_MT (ACE_Recursive_Thread_Mutex *lock = + ACE_Managed_Object::get_preallocated_object + (ACE_Object_Manager::ACE_SIG_HANDLER_LOCK); + ACE_Guard m (*lock)); + return ACE_Sig_Handler::sig_pending_ != 0; +} + +void +ACE_Sig_Handler::sig_pending (int pending) +{ + ACE_TRACE ("ACE_Sig_Handler::sig_pending"); + + ACE_MT (ACE_Recursive_Thread_Mutex *lock = + ACE_Managed_Object::get_preallocated_object + (ACE_Object_Manager::ACE_SIG_HANDLER_LOCK); + ACE_Guard m (*lock)); + ACE_Sig_Handler::sig_pending_ = pending; +} + +ACE_Event_Handler * +ACE_Sig_Handler::handler (int signum) +{ + ACE_TRACE ("ACE_Sig_Handler::handler"); + ACE_MT (ACE_Recursive_Thread_Mutex *lock = + ACE_Managed_Object::get_preallocated_object + (ACE_Object_Manager::ACE_SIG_HANDLER_LOCK); + ACE_Guard m (*lock)); + + if (ACE_Sig_Handler::in_range (signum)) + return ACE_Sig_Handler::signal_handlers_[signum]; + else + return 0; +} + +ACE_Event_Handler * +ACE_Sig_Handler::handler_i (int signum, + ACE_Event_Handler *new_sh) +{ + ACE_TRACE ("ACE_Sig_Handler::handler_i"); + + if (ACE_Sig_Handler::in_range (signum)) + { + ACE_Event_Handler *sh = ACE_Sig_Handler::signal_handlers_[signum]; + + ACE_Sig_Handler::signal_handlers_[signum] = new_sh; + return sh; + } + else + return 0; +} + +ACE_Event_Handler * +ACE_Sig_Handler::handler (int signum, + ACE_Event_Handler *new_sh) +{ + ACE_TRACE ("ACE_Sig_Handler::handler"); + ACE_MT (ACE_Recursive_Thread_Mutex *lock = + ACE_Managed_Object::get_preallocated_object + (ACE_Object_Manager::ACE_SIG_HANDLER_LOCK); + ACE_Guard m (*lock)); + + return ACE_Sig_Handler::handler_i (signum, new_sh); +} + +// Register an ACE_Event_Handler along with the corresponding SIGNUM. +// This method does NOT acquire any locks, so it can be called from a +// signal handler. + +int +ACE_Sig_Handler::register_handler_i (int signum, + ACE_Event_Handler *new_sh, + ACE_Sig_Action *new_disp, + ACE_Event_Handler **old_sh, + ACE_Sig_Action *old_disp) +{ + ACE_TRACE ("ACE_Sig_Handler::register_handler_i"); + + if (ACE_Sig_Handler::in_range (signum)) + { + ACE_Sig_Action sa; // Define a "null" action. + ACE_Event_Handler *sh = ACE_Sig_Handler::handler_i (signum, + new_sh); + + // Return a pointer to the old if the user + // asks for this. + if (old_sh != 0) + *old_sh = sh; + + // Make sure that points to a valid location if the + // user doesn't care... + if (new_disp == 0) + new_disp = &sa; + + new_disp->handler (ace_signal_handler_dispatcher); +#if !defined (ACE_HAS_LYNXOS_SIGNALS) + new_disp->flags (new_disp->flags () | SA_SIGINFO); +#endif /* ACE_HAS_LYNXOS_SIGNALS */ + return new_disp->register_action (signum, old_disp); + } + else + return -1; +} + +// Register an ACE_Event_Handler along with the corresponding SIGNUM. +// This method acquires a lock, so it can't be called from a signal +// handler, e.g., . + +int +ACE_Sig_Handler::register_handler (int signum, + ACE_Event_Handler *new_sh, + ACE_Sig_Action *new_disp, + ACE_Event_Handler **old_sh, + ACE_Sig_Action *old_disp) +{ + ACE_TRACE ("ACE_Sig_Handler::register_handler"); + ACE_MT (ACE_Recursive_Thread_Mutex *lock = + ACE_Managed_Object::get_preallocated_object + (ACE_Object_Manager::ACE_SIG_HANDLER_LOCK); + ACE_Guard m (*lock)); + + return ACE_Sig_Handler::register_handler_i (signum, + new_sh, + new_disp, + old_sh, + old_disp); +} + +// Remove an ACE_Event_Handler. + +int +ACE_Sig_Handler::remove_handler (int signum, + ACE_Sig_Action *new_disp, + ACE_Sig_Action *old_disp, + int) +{ + ACE_TRACE ("ACE_Sig_Handler::remove_handler"); + ACE_MT (ACE_Recursive_Thread_Mutex *lock = + ACE_Managed_Object::get_preallocated_object + (ACE_Object_Manager::ACE_SIG_HANDLER_LOCK); + ACE_Guard m (*lock)); + + if (ACE_Sig_Handler::in_range (signum)) + { + ACE_Sig_Action sa (SIG_DFL, (sigset_t *) 0); // Define the default disposition. + + if (new_disp == 0) + new_disp = &sa; + + ACE_Sig_Handler::signal_handlers_[signum] = 0; + + // Register either the new disposition or restore the default. + return new_disp->register_action (signum, old_disp); + } + + return -1; +} + +// Master dispatcher function that gets called by a signal handler and +// dispatches one handler... + +void +ACE_Sig_Handler::dispatch (int signum, + siginfo_t *siginfo, + ucontext_t *ucontext) +{ + ACE_TRACE ("ACE_Sig_Handler::dispatch"); + + // Save/restore errno. + ACE_Errno_Guard error (errno); + + // We can't use the call here because that acquires + // the lock, which is non-portable... + ACE_Sig_Handler::sig_pending_ = 1; + + // Darn well better be in range since the OS dispatched this... + ACE_ASSERT (ACE_Sig_Handler::in_range (signum)); + + ACE_Event_Handler *eh = ACE_Sig_Handler::signal_handlers_[signum]; + + if (eh != 0) + { + if (eh->handle_signal (signum, siginfo, ucontext) == -1) + { + // Define the default disposition. + ACE_Sig_Action sa ((ACE_SignalHandler) SIG_DFL, (sigset_t *) 0); + + ACE_Sig_Handler::signal_handlers_[signum] = 0; + + // Remove the current disposition by registering the default + // disposition. + sa.register_action (signum); + + // Allow the event handler to close down if necessary. + eh->handle_close (ACE_INVALID_HANDLE, + ACE_Event_Handler::SIGNAL_MASK); + } +#if defined (ACE_WIN32) + else + // Win32 is weird in the sense that it resets the signal + // disposition to SIG_DFL after a signal handler is + // dispatched. Therefore, to workaround this "feature" we + // must re-register the with + // explicitly. + ACE_Sig_Handler::register_handler_i (signum, + eh); +#endif /* ACE_WIN32*/ + } +} + +// ---------------------------------------- +// The following classes are local to this file. + +// There are bugs with HP/UX's C++ compiler that prevents this stuff +// from compiling... +#define ACE_MAX_SIGNAL_HANDLERS ((size_t) 20) + +// Keeps track of the id that uniquely identifies each registered +// signal handler. This id can be used to cancel a timer via the +// method. +int ACE_Sig_Handlers::sigkey_ = 0; + +// If this is true then a 3rd party library has registered a +// handler... +bool ACE_Sig_Handlers::third_party_sig_handler_ = false; + +// Make life easier by defining typedefs... +typedef ACE_Fixed_Set ACE_SIG_HANDLERS_SET; +typedef ACE_Fixed_Set_Iterator ACE_SIG_HANDLERS_ITERATOR; + +class ACE_Sig_Handlers_Set +{ +public: + static ACE_SIG_HANDLERS_SET *instance (int signum); + +private: + static ACE_SIG_HANDLERS_SET *sig_handlers_[ACE_NSIG]; +}; + +/* static */ +ACE_SIG_HANDLERS_SET *ACE_Sig_Handlers_Set::sig_handlers_[ACE_NSIG]; + +/* static */ +ACE_SIG_HANDLERS_SET * +ACE_Sig_Handlers_Set::instance (int signum) +{ + if (signum <= 0 || signum >= ACE_NSIG) + return 0; // This will cause problems... + else if (ACE_Sig_Handlers_Set::sig_handlers_[signum] == 0) + ACE_NEW_RETURN (ACE_Sig_Handlers_Set::sig_handlers_[signum], + ACE_SIG_HANDLERS_SET, + 0); + return ACE_Sig_Handlers_Set::sig_handlers_[signum]; +} + +ACE_ALLOC_HOOK_DEFINE(ACE_Sig_Handlers) + +void +ACE_Sig_Handlers::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + ACE_TRACE ("ACE_Sig_Handlers::dump"); +#endif /* ACE_HAS_DUMP */ +} + +// This is the method that does all the dirty work... The basic +// structure of this method was devised by Detlef Becker. + +int +ACE_Sig_Handlers::register_handler (int signum, + ACE_Event_Handler *new_sh, + ACE_Sig_Action *new_disp, + ACE_Event_Handler **, + ACE_Sig_Action *old_disp) +{ + ACE_TRACE ("ACE_Sig_Handlers::register_handler"); + ACE_MT (ACE_Recursive_Thread_Mutex *lock = + ACE_Managed_Object::get_preallocated_object + (ACE_Object_Manager::ACE_SIG_HANDLER_LOCK); + ACE_Guard m (*lock)); + + if (ACE_Sig_Handler::in_range (signum)) + { + ACE_Sig_Adapter *ace_sig_adapter = 0; // Our signal handler. + ACE_Sig_Adapter *extern_sh = 0; // An external signal handler. + ACE_Sig_Action sa; + + // Get current signal disposition. + sa.retrieve_action (signum); + + // Check whether we are already in control of the signal + // handling disposition... + + if (!(sa.handler () == ace_signal_handlers_dispatcher + || sa.handler () == ACE_SignalHandler (SIG_IGN) + || sa.handler () == ACE_SignalHandler (SIG_DFL))) + { + // Drat, a 3rd party library has already installed a signal ;-( + + // Upto here we never disabled RESTART_MODE. Thus, + // RESTART_MODE can only be changed by 3rd party libraries. + + if (ACE_BIT_DISABLED (sa.flags (), SA_RESTART) + && ACE_Sig_Handlers::third_party_sig_handler_) + // Toggling is disallowed since we might break 3rd party + // code. + return -1; + + // Note that we've seen a 3rd party handler... + ACE_Sig_Handlers::third_party_sig_handler_ = true; + + // Create a new 3rd party disposition, remembering its + // preferred signal blocking etc...; + ACE_NEW_RETURN (extern_sh, + ACE_Sig_Adapter (sa, + ++ACE_Sig_Handlers::sigkey_), + -1); + // Add the external signal handler to the set of handlers + // for this signal. + if (ACE_Sig_Handlers_Set::instance (signum)->insert (extern_sh) == -1) + { + delete extern_sh; + return -1; + } + } + // Add our new handler at this point. + ACE_NEW_RETURN (ace_sig_adapter, + ACE_Sig_Adapter (new_sh, + ++ACE_Sig_Handlers::sigkey_), + -1); + // Add the ACE signal handler to the set of handlers for this + // signal (make sure it goes before the external one if there is + // one of these). + if (ACE_Sig_Handlers_Set::instance (signum)->insert (ace_sig_adapter) == -1) + { + // We couldn't reinstall our handler, so let's pretend like + // none of this happened... + if (extern_sh) + { + ACE_Sig_Handlers_Set::instance (signum)->remove (extern_sh); + delete extern_sh; + } + delete ace_sig_adapter; + return -1; + } + // If ACE_Sig_Handlers::dispatch() was set we're done. + else if (sa.handler () == ace_signal_handlers_dispatcher) + return ace_sig_adapter->sigkey (); + + // Otherwise, we need to register our handler function so that + // all signals will be dispatched through ACE. + else + { + // Make sure that new_disp points to a valid location if the + // user doesn't care... + if (new_disp == 0) + new_disp = &sa; + + new_disp->handler (ace_signal_handlers_dispatcher); + + // Default is to restart signal handlers. + new_disp->flags (new_disp->flags () | SA_RESTART); + new_disp->flags (new_disp->flags () | SA_SIGINFO); + + // Finally install (possibly reinstall) the ACE signal + // handler disposition with the SA_RESTART mode enabled. + if (new_disp->register_action (signum, old_disp) == -1) + { + // Yikes, lots of roll back at this point... + ACE_Sig_Handlers_Set::instance (signum)->remove (ace_sig_adapter); + delete ace_sig_adapter; + + if (extern_sh) + { + ACE_Sig_Handlers_Set::instance (signum)->remove (extern_sh); + delete extern_sh; + } + return -1; + } + else // Return the signal key so that programs can cancel this + // handler if they want! + return ace_sig_adapter->sigkey (); + } + } + + return -1; +} + +// Remove the ACE_Event_Handler currently associated with . +// Install the new disposition (if given) and return the previous +// disposition (if desired by the caller). Returns 0 on success and +// -1 if is invalid. + +int +ACE_Sig_Handlers::remove_handler (int signum, + ACE_Sig_Action *new_disp, + ACE_Sig_Action *old_disp, + int sigkey) +{ + ACE_TRACE ("ACE_Sig_Handlers::remove_handler"); + ACE_MT (ACE_Recursive_Thread_Mutex *lock = + ACE_Managed_Object::get_preallocated_object + (ACE_Object_Manager::ACE_SIG_HANDLER_LOCK); + ACE_Guard m (*lock)); + + if (ACE_Sig_Handler::in_range (signum)) + { + ACE_SIG_HANDLERS_SET *handler_set = + ACE_Sig_Handlers_Set::instance (signum); + + ACE_SIG_HANDLERS_ITERATOR handler_iterator (*handler_set); + + // Iterate through the set of handlers for this signal. + + for (ACE_Event_Handler **eh; + handler_iterator.next (eh) != 0; + handler_iterator.advance ()) + { + // Type-safe downcast would be nice here... + ACE_Sig_Adapter *sh = (ACE_Sig_Adapter *) *eh; + + // Remove the handler if (1) its key matches the key we've + // been told to remove or (2) if we've been told to remove + // *all* handlers (i.e., == -1). + + if (sh->sigkey () == sigkey || sigkey == -1) + { + handler_set->remove (*eh); + delete *eh; + } + } + + if (handler_set->size () == 0) + { + // If there are no more handlers left for a signal then + // register the new disposition or restore the default + // disposition. + + ACE_Sig_Action sa (SIG_DFL, (sigset_t *) 0); + + if (new_disp == 0) + new_disp = &sa; + + return new_disp->register_action (signum, old_disp); + } + return 0; + } + else + return -1; +} + +// Master dispatcher function that gets called by a signal handler and +// dispatches *all* the handlers... + +void +ACE_Sig_Handlers::dispatch (int signum, + siginfo_t *siginfo, + ucontext_t *ucontext) +{ + ACE_TRACE ("ACE_Sig_Handlers::dispatch"); + // The following is #ifdef'd out because it's entirely non-portable + // to acquire a mutex in a signal handler... +#if 0 + ACE_MT (ACE_Recursive_Thread_Mutex *lock = + ACE_Managed_Object::get_preallocated_object + (ACE_Object_Manager::ACE_SIG_HANDLER_LOCK); + ACE_TSS_Guard m (*lock)); +#endif /* 0 */ + + // Save/restore errno. + ACE_Errno_Guard error (errno); + + ACE_Sig_Handler::sig_pending_ = 1; + + // Darn well better be in range since the OS dispatched this... + ACE_ASSERT (ACE_Sig_Handler::in_range (signum)); + + ACE_SIG_HANDLERS_SET *handler_set = + ACE_Sig_Handlers_Set::instance (signum); + + ACE_SIG_HANDLERS_ITERATOR handler_iterator (*handler_set); + + for (ACE_Event_Handler **eh = 0; + handler_iterator.next (eh) != 0; + handler_iterator.advance ()) + { + if ((*eh)->handle_signal (signum, siginfo, ucontext) == -1) + { + handler_set->remove (*eh); + delete *eh; + } + } +} + +// Return the first item in the list of handlers. Note that this will +// trivially provide the same behavior as the ACE_Sig_Handler +// version if there is only 1 handler registered! + +ACE_Event_Handler * +ACE_Sig_Handlers::handler (int signum) +{ + ACE_TRACE ("ACE_Sig_Handlers::handler"); + ACE_SIG_HANDLERS_SET *handler_set = + ACE_Sig_Handlers_Set::instance (signum); + ACE_SIG_HANDLERS_ITERATOR handler_iterator (*handler_set); + ACE_Event_Handler **eh = 0; + handler_iterator.next (eh); + return *eh; +} + +// The following is a strange bit of logic that tries to give the same +// semantics as what happens in ACE_Sig_Handler when we replace the +// current signal handler with a new one. Note that if there is only +// one signal handler the behavior will be identical. If there is +// more than one handler then things get weird... + +ACE_Event_Handler * +ACE_Sig_Handlers::handler (int signum, ACE_Event_Handler *new_sh) +{ + ACE_TRACE ("ACE_Sig_Handlers::handler"); + ACE_SIG_HANDLERS_SET *handler_set = + ACE_Sig_Handlers_Set::instance (signum); + ACE_SIG_HANDLERS_ITERATOR handler_iterator (*handler_set); + ACE_Event_Handler **eh = 0; + + // Find the first handler... + handler_iterator.next (eh); + + // ... then remove it from the set ... + handler_set->remove (*eh); + + // ... and then insert the new signal handler into the beginning of + // the set (note, this is a bit too tied up in the implementation of + // ACE_Unbounded_Set...). + ACE_Sig_Adapter *temp = 0; + + ACE_NEW_RETURN (temp, + ACE_Sig_Adapter (new_sh, + ++ACE_Sig_Handlers::sigkey_), + 0); + handler_set->insert (temp); + return *eh; +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Sig_Handler.h b/dep/ACE_wrappers/ace/Sig_Handler.h new file mode 100644 index 00000000000..53d30d4f058 --- /dev/null +++ b/dep/ACE_wrappers/ace/Sig_Handler.h @@ -0,0 +1,237 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Sig_Handler.h + * + * $Id: Sig_Handler.h 81388 2008-04-23 14:02:05Z johnnyw $ + * + * @author Douglas C. Schmidt + */ +//============================================================================= + +#ifndef ACE_SIGNAL_HANDLER_H +#define ACE_SIGNAL_HANDLER_H +#include /**/ "ace/pre.h" + +#include /**/ "ace/ACE_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/Event_Handler.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +class ACE_Sig_Action; + +/** + * @class ACE_Sig_Handler + * + * @brief This is the main dispatcher of signals for ACE. It improves + * the existing UNIX signal handling mechanism by allowing C++ + * objects to handle signals in a way that avoids the use of + * global/static variables and functions. + * + * Using this class a program can register an ACE_Event_Handler + * with the ACE_Sig_Handler in order to handle a designated + * @a signum. When a signal occurs that corresponds to this + * @a signum, the @c handle_signal method of the registered + * ACE_Event_Handler is invoked automatically. + */ +class ACE_Export ACE_Sig_Handler +{ +public: + /// Default constructor. + ACE_Sig_Handler (void); + + /// Destructor + virtual ~ACE_Sig_Handler (void); + + // = Registration and removal methods. + /** + * Add a new ACE_Event_Handler and a new sigaction associated with + * @a signum. Passes back the existing ACE_Event_Handler and its + * sigaction if pointers are non-zero. Returns -1 on failure and >= + * 0 on success. + */ + virtual int register_handler (int signum, + ACE_Event_Handler *new_sh, + ACE_Sig_Action *new_disp = 0, + ACE_Event_Handler **old_sh = 0, + ACE_Sig_Action *old_disp = 0); + + /** + * Remove the ACE_Event_Handler currently associated with + * @a signum. @a sigkey is ignored in this implementation since there + * is only one instance of a signal handler. Install the new + * disposition (if given) and return the previous disposition (if + * desired by the caller). Returns 0 on success and -1 if @a signum + * is invalid. + */ + virtual int remove_handler (int signum, + ACE_Sig_Action *new_disp = 0, + ACE_Sig_Action *old_disp = 0, + int sigkey = -1); + + // Set/get signal status. + /// True if there is a pending signal. + static int sig_pending (void); + + /// Reset the value of so that no signal is pending. + static void sig_pending (int); + + // = Set/get the handler associated with a particular signal. + + /// Return the ACE_Sig_Handler associated with @a signum. + virtual ACE_Event_Handler *handler (int signum); + + /// Set a new ACE_Event_Handler that is associated with @a signum. + /// Return the existing handler. + virtual ACE_Event_Handler *handler (int signum, ACE_Event_Handler *); + + /** + * Callback routine registered with sigaction(2) that dispatches the + * method of the appropriate pre-registered + * ACE_Event_Handler. + */ + static void dispatch (int, siginfo_t *, + ucontext_t *); + + /// Dump the state of an object. + void dump (void) const; + + /// Declare the dynamic allocation hooks. + ACE_ALLOC_HOOK_DECLARE; + +protected: + // = These methods and data members are shared by derived classes. + + /** + * Set a new ACE_Event_Handler that is associated with @a signum. + * Return the existing handler. Does not acquire any locks so that + * it can be called from a signal handler, such as . + */ + static ACE_Event_Handler *handler_i (int signum, + ACE_Event_Handler *); + + /** + * This implementation method is called by and + * @c dispatch. It doesn't do any locking so that it can be called + * within a signal handler, such as @c dispatch. It adds a new + * ACE_Event_Handler and a new sigaction associated with @a signum. + * Passes back the existing ACE_Event_Handler and its sigaction if + * pointers are non-zero. Returns -1 on failure and >= 0 on + * success. + */ + static int register_handler_i (int signum, + ACE_Event_Handler *new_sh, + ACE_Sig_Action *new_disp = 0, + ACE_Event_Handler **old_sh = 0, + ACE_Sig_Action *old_disp = 0); + + /// Check whether the SIGNUM is within the legal range of signals. + static int in_range (int signum); + + /// Keeps track of whether a signal is pending. + static sig_atomic_t sig_pending_; + +private: + /// Array used to store one user-defined Event_Handler for every + /// signal. + static ACE_Event_Handler *signal_handlers_[ACE_NSIG]; +}; + +/** + * @class ACE_Sig_Handlers + * + * @brief This is an alternative signal handling dispatcher for ACE. It + * allows a list of signal handlers to be registered for each + * signal. It also makes SA_RESTART the default mode. + * + * Using this class a program can register one or more + * ACE_Event_Handler with the ACE_Sig_Handler in order to + * handle a designated @a signum. When a signal occurs that + * corresponds to this @a signum, the methods of + * all the registered ACE_Event_Handlers are invoked + * automatically. + */ +class ACE_Export ACE_Sig_Handlers : public ACE_Sig_Handler +{ +public: + // = Registration and removal methods. + /** + * Add a new ACE_Event_Handler and a new sigaction associated with + * @a signum. Passes back the existing ACE_Event_Handler and its + * sigaction if pointers are non-zero. Returns -1 on failure and + * a that is >= 0 on success. + */ + virtual int register_handler (int signum, + ACE_Event_Handler *new_sh, + ACE_Sig_Action *new_disp = 0, + ACE_Event_Handler **old_sh = 0, + ACE_Sig_Action *old_disp = 0); + + /** + * Remove an ACE_Event_Handler currently associated with @a signum. + * We remove the handler if (1) its sigkey> matches the @a sigkey + * passed as a parameter or (2) if we've been told to remove all the + * handlers, i.e., == -1. If a new disposition is given it + * is installed and the previous disposition is returned (if desired + * by the caller). Returns 0 on success and -1 if @a signum is + * invalid. + */ + virtual int remove_handler (int signum, + ACE_Sig_Action *new_disp = 0, + ACE_Sig_Action *old_disp = 0, + int sigkey = -1); + + // = Set/get the handler associated with a particular signal. + + /// Return the head of the list of s associated with + /// SIGNUM. + virtual ACE_Event_Handler *handler (int signum); + + /** + * Set a new ACE_Event_Handler that is associated with SIGNUM at + * the head of the list of signals. Return the existing handler + * that was at the head. + */ + virtual ACE_Event_Handler *handler (int signum, + ACE_Event_Handler *); + + /** + * Callback routine registered with sigaction(2) that dispatches the + * method of all the pre-registered + * ACE_Event_Handlers for @a signum + */ + static void dispatch (int signum, siginfo_t *, ucontext_t *); + + /// Dump the state of an object. + void dump (void) const; + + /// Declare the dynamic allocation hooks. + ACE_ALLOC_HOOK_DECLARE; + +private: + /** + * Keeps track of the id that uniquely identifies each registered + * signal handler. This id can be used to cancel a timer via the + * method. + */ + static int sigkey_; + + /// If this is true then a 3rd party library has registered a + /// handler... + static bool third_party_sig_handler_; +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +#include "ace/Sig_Handler.inl" +#endif /* __ACE_INLINE__ */ + +#include /**/ "ace/post.h" +#endif /* ACE_SIG_HANDLER_H */ diff --git a/dep/ACE_wrappers/ace/Sig_Handler.inl b/dep/ACE_wrappers/ace/Sig_Handler.inl new file mode 100644 index 00000000000..de02c09ab16 --- /dev/null +++ b/dep/ACE_wrappers/ace/Sig_Handler.inl @@ -0,0 +1,15 @@ +// -*- C++ -*- +// +// $Id: Sig_Handler.inl 80826 2008-03-04 14:51:23Z wotte $ + +ACE_INLINE +ACE_Sig_Handler::ACE_Sig_Handler (void) +{ +} + +ACE_INLINE int +ACE_Sig_Handler::in_range (int signum) +{ + ACE_TRACE ("ACE_Sig_Handler::in_range"); + return signum > 0 && signum < ACE_NSIG; +} diff --git a/dep/ACE_wrappers/ace/Signal.cpp b/dep/ACE_wrappers/ace/Signal.cpp new file mode 100644 index 00000000000..5f17455502b --- /dev/null +++ b/dep/ACE_wrappers/ace/Signal.cpp @@ -0,0 +1,221 @@ +// $Id: Signal.cpp 80826 2008-03-04 14:51:23Z wotte $ + +#include "ace/Signal.h" +// #include "ace/Log_Msg.h" + +#if !defined (__ACE_INLINE__) +#include "ace/Signal.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(ace, Signal, "$Id: Signal.cpp 80826 2008-03-04 14:51:23Z wotte $") + + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_ALLOC_HOOK_DEFINE(ACE_Sig_Action) + +void +ACE_Sig_Action::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + ACE_TRACE ("ACE_Sig_Action::dump"); +#endif /* ACE_HAS_DUMP */ +} + +ACE_ALLOC_HOOK_DEFINE(ACE_Sig_Set) + +ACE_Sig_Set::~ACE_Sig_Set (void) +{ + ACE_TRACE ("ACE_Sig_Set::~ACE_Sig_Set"); + ACE_OS::sigemptyset (&this->sigset_); +} + +ACE_Sig_Action::~ACE_Sig_Action (void) +{ + ACE_TRACE ("ACE_Sig_Action::~ACE_Sig_Action"); +} + +// Restore the signal mask. + +ACE_Sig_Guard::~ACE_Sig_Guard (void) +{ + //ACE_TRACE ("ACE_Sig_Guard::~ACE_Sig_Guard"); + if (!this->condition_) + return; + +#if !defined (ACE_LACKS_UNIX_SIGNALS) +#if defined (ACE_LACKS_PTHREAD_THR_SIGSETMASK) + ACE_OS::sigprocmask (SIG_SETMASK, + (sigset_t *) this->omask_, + 0); +#else + ACE_OS::thr_sigsetmask (SIG_SETMASK, + (sigset_t *) this->omask_, + 0); +#endif /* ACE_LACKS_PTHREAD_THR_SIGSETMASK */ +#endif /* !ACE_LACKS_UNIX_SIGNALS */ +} + +void +ACE_Sig_Set::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + ACE_TRACE ("ACE_Sig_Set::dump"); +#endif /* ACE_HAS_DUMP */ +} + +ACE_ALLOC_HOOK_DEFINE(ACE_Sig_Guard) + +void +ACE_Sig_Guard::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + ACE_TRACE ("ACE_Sig_Guard::dump"); +#endif /* ACE_HAS_DUMP */ +} + +ACE_Sig_Action::ACE_Sig_Action (void) +{ + // ACE_TRACE ("ACE_Sig_Action::ACE_Sig_Action"); + this->sa_.sa_flags = 0; + + // Since Service_Config::signal_handler_ is static and has an + // ACE_Sig_Action instance, Win32 will get errno set unless this is + // commented out. +#if !defined (ACE_WIN32) + ACE_OS::sigemptyset (&this->sa_.sa_mask); +#endif /* ACE_WIN32 */ + this->sa_.sa_handler = 0; +} + +ACE_Sig_Action::ACE_Sig_Action (ACE_SignalHandler sig_handler, + sigset_t *sig_mask, + int sig_flags) +{ + // ACE_TRACE ("ACE_Sig_Action::ACE_Sig_Action"); + this->sa_.sa_flags = sig_flags; + + if (sig_mask == 0) + ACE_OS::sigemptyset (&this->sa_.sa_mask); + else + this->sa_.sa_mask = *sig_mask; // Structure assignment... + +#if !defined(ACE_HAS_TANDEM_SIGNALS) + this->sa_.sa_handler = ACE_SignalHandlerV (sig_handler); +#else + this->sa_.sa_handler = (void (*)()) ACE_SignalHandlerV (sig_handler); +#endif /* !ACE_HAS_TANDEM_SIGNALS */ +} + +ACE_Sig_Action::ACE_Sig_Action (ACE_SignalHandler sig_handler, + const ACE_Sig_Set &sig_mask, + int sig_flags) +{ + // ACE_TRACE ("ACE_Sig_Action::ACE_Sig_Action"); + this->sa_.sa_flags = sig_flags; + + // Structure assignment... + this->sa_.sa_mask = sig_mask.sigset (); + +#if !defined(ACE_HAS_TANDEM_SIGNALS) + this->sa_.sa_handler = ACE_SignalHandlerV (sig_handler); +#else + this->sa_.sa_handler = (void (*)()) ACE_SignalHandlerV (sig_handler); +#endif /* !ACE_HAS_TANDEM_SIGNALS */ +} + +ACE_Sig_Action::ACE_Sig_Action (ACE_SignalHandler sig_handler, + int signum, + sigset_t *sig_mask, + int sig_flags) +{ + // ACE_TRACE ("ACE_Sig_Action::ACE_Sig_Action"); + this->sa_.sa_flags = sig_flags; + + if (sig_mask == 0) + ACE_OS::sigemptyset (&this->sa_.sa_mask); + else + this->sa_.sa_mask = *sig_mask; // Structure assignment... + +#if !defined(ACE_HAS_TANDEM_SIGNALS) + this->sa_.sa_handler = ACE_SignalHandlerV (sig_handler); +#else + this->sa_.sa_handler = (void (*)()) ACE_SignalHandlerV (sig_handler); +#endif /* !ACE_HAS_TANDEM_SIGNALS */ + ACE_OS::sigaction (signum, &this->sa_, 0); +} + +ACE_Sig_Action::ACE_Sig_Action (ACE_SignalHandler sig_handler, + int signum, + const ACE_Sig_Set &sig_mask, + int sig_flags) +{ + // ACE_TRACE ("ACE_Sig_Action::ACE_Sig_Action"); + this->sa_.sa_flags = sig_flags; + + // Structure assignment... + this->sa_.sa_mask = sig_mask.sigset (); + +#if !defined(ACE_HAS_TANDEM_SIGNALS) + this->sa_.sa_handler = ACE_SignalHandlerV (sig_handler); +#else + this->sa_.sa_handler = (void (*)()) ACE_SignalHandlerV (sig_handler); +#endif /* !ACE_HAS_TANDEM_SIGNALS */ + ACE_OS::sigaction (signum, &this->sa_, 0); +} + +ACE_Sig_Action::ACE_Sig_Action (const ACE_Sig_Set &signals, + ACE_SignalHandler sig_handler, + const ACE_Sig_Set &sig_mask, + int sig_flags) +{ + // ACE_TRACE ("ACE_Sig_Action::ACE_Sig_Action"); + this->sa_.sa_flags = sig_flags; + + // Structure assignment... + this->sa_.sa_mask = sig_mask.sigset (); + +#if !defined(ACE_HAS_TANDEM_SIGNALS) + this->sa_.sa_handler = ACE_SignalHandlerV (sig_handler); +#else + this->sa_.sa_handler = (void (*)()) ACE_SignalHandlerV (sig_handler); +#endif /* !ACE_HAS_TANDEM_SIGNALS */ + +#if (ACE_NSIG > 0) + for (int s = 1; s < ACE_NSIG; s++) + if ((signals.is_member (s)) == 1) + ACE_OS::sigaction (s, &this->sa_, 0); +#else /* ACE_NSIG <= 0 */ + ACE_UNUSED_ARG (signals); +#endif /* ACE_NSIG <= 0 */ +} + +ACE_Sig_Action::ACE_Sig_Action (const ACE_Sig_Set &signals, + ACE_SignalHandler sig_handler, + sigset_t *sig_mask, + int sig_flags) +{ + // ACE_TRACE ("ACE_Sig_Action::ACE_Sig_Action"); + this->sa_.sa_flags = sig_flags; + + if (sig_mask == 0) + ACE_OS::sigemptyset (&this->sa_.sa_mask); + else + this->sa_.sa_mask = *sig_mask; // Structure assignment... + +#if !defined(ACE_HAS_TANDEM_SIGNALS) + this->sa_.sa_handler = ACE_SignalHandlerV (sig_handler); +#else + this->sa_.sa_handler = (void (*)()) ACE_SignalHandlerV (sig_handler); +#endif /* !ACE_HAS_TANDEM_SIGNALS */ + +#if (ACE_NSIG > 0) + for (int s = 1; s < ACE_NSIG; s++) + if ((signals.is_member (s)) == 1) + ACE_OS::sigaction (s, &this->sa_, 0); +#else /* ACE_NSIG <= 0 */ + ACE_UNUSED_ARG (signals); +#endif /* ACE_NSIG <= 0 */ +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Signal.h b/dep/ACE_wrappers/ace/Signal.h new file mode 100644 index 00000000000..736d62e5c08 --- /dev/null +++ b/dep/ACE_wrappers/ace/Signal.h @@ -0,0 +1,267 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Signal.h + * + * $Id: Signal.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Douglas C. Schmidt + */ +//============================================================================= + +#ifndef ACE_SIGNAL_H +#define ACE_SIGNAL_H +#include /**/ "ace/pre.h" + +#include "ace/config-lite.h" + +#if defined (ACE_DONT_INCLUDE_ACE_SIGNAL_H) +# error ace/Signal.h was #included instead of signal.h by ace/OS_NS_signal.h: fix!!!! +#endif /* ACE_DONT_INCLUDE_ACE_SIGNAL_H */ + +#include /**/ "ace/ACE_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/OS_NS_signal.h" + +// Type of the extended signal handler. +typedef void (*ACE_Sig_Handler_Ex) (int, siginfo_t *siginfo, ucontext_t *ucontext); + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +/** + * @class ACE_Sig_Set + * + * @brief Provide a C++ wrapper for the C sigset_t interface. + * + * Handle signals via a more elegant C++ interface (e.g., + * doesn't require the use of global variables or global + * functions in an application). + */ +class ACE_Export ACE_Sig_Set +{ +public: + // = Initialization and termination methods. + /// Initialize with @a sigset. If @a sigset == 0 then fill + /// the set. + ACE_Sig_Set (sigset_t *sigset); + + /// Initialize with @a sigset. If @a sigset == 0 then fill + /// the set. + ACE_Sig_Set (ACE_Sig_Set *sigset); + + /// If @a fill == 0 then initialize the to be empty, else + /// full. + ACE_Sig_Set (int fill = 0); + + ~ACE_Sig_Set (void); + + /// Create a set that excludes all signals defined by the system. + int empty_set (void); + + /// Create a set that includes all signals defined by the system. + int fill_set (void); + + /// Adds the individual signal specified by @a signo to the set. + int sig_add (int signo); + + /// Deletes the individual signal specified by @a signo from the set. + int sig_del (int signo); + + /// Checks whether the signal specified by @a signo is in the set. + int is_member (int signo) const; + + /// Returns a pointer to the underlying @c sigset_t. + operator sigset_t *(); + + /// Returns a copy of the underlying @c sigset_t. + sigset_t sigset (void) const; + + /// Dump the state of an object. + void dump (void) const; + + /// Declare the dynamic allocation hooks. + ACE_ALLOC_HOOK_DECLARE; + +private: + /// Set of signals. + sigset_t sigset_; +}; + +/** + * @class ACE_Sig_Action + * + * @brief C++ wrapper facade for the @c sigaction struct. + */ +class ACE_Export ACE_Sig_Action +{ +public: + // = Initialization methods. + /// Default constructor. Initializes everything to 0. + ACE_Sig_Action (void); + + /// Assigns the various fields of a @c sigaction struct but doesn't + /// register for signal handling via the @c sigaction function. + ACE_Sig_Action (ACE_SignalHandler handler, + sigset_t *sigmask = 0, + int flags = 0); + + /// Assigns the various fields of a @c sigaction struct but doesn't + /// register for signal handling via the @c sigaction function. + ACE_Sig_Action (ACE_SignalHandler handler, + const ACE_Sig_Set &sigmask, + int flags = 0); + + /** + * Assigns the various fields of a @c sigaction struct and registers + * the @a handler to process signal @a signum via the @c sigaction + * function. + */ + ACE_Sig_Action (ACE_SignalHandler handler, + int signum, + sigset_t *sigmask = 0, + int flags = 0); + + /** + * Assigns the various fields of a @c sigaction struct and registers + * the @a handler to process signal @a signum via the @c sigaction + * function. + */ + ACE_Sig_Action (ACE_SignalHandler handler, + int signum, + const ACE_Sig_Set &sigmask, + int flags = 0); + + + // @@ The next two methods have a parameter as "signalss". Please do + // not change the argument name as "signals". This causes the + // following problem as reported by + // . + + // In the file Signal.h two of the functions have and argument name + // of signals. signals is a Qt macro (to do with their meta object + // stuff. + // We could as well have it as "signal", but I am nost sure whether + // that would cause a problem with something else - Bala + + /** + * Assigns the various fields of a @c sigaction struct and registers + * the @a handler to process all @a signalss via the @c sigaction + * function. + */ + ACE_Sig_Action (const ACE_Sig_Set &signalss, + ACE_SignalHandler handler, + const ACE_Sig_Set &sigmask, + int flags = 0); + + /** + * Assigns the various fields of a @c sigaction struct and registers + * the @a handler to process all @a signalss via the @c sigaction + * function. + */ + ACE_Sig_Action (const ACE_Sig_Set &signalss, + ACE_SignalHandler handler, + sigset_t *sigmask = 0, + int flags = 0); + + /// Copy constructor. + ACE_Sig_Action (const ACE_Sig_Action &s); + + /// Default dtor. + ~ACE_Sig_Action (void); + + // = Signal action management. + /// Register @c this as the current disposition and store old + /// disposition into @a oaction if it is non-NULL. + int register_action (int signum, + ACE_Sig_Action *oaction = 0); + + /// Assign the value of @a oaction to @c this and make it become the + /// new signal disposition. + int restore_action (int signum, + ACE_Sig_Action &oaction); + + /// Retrieve the current disposition into @c this. + int retrieve_action (int signum); + + /// Set current signal action. + void set (struct sigaction *); + + /// Get current signal action. + struct sigaction *get (void); + operator struct sigaction *(); + + /// Set current signal flags. + void flags (int); + + /// Get current signal flags. + int flags (void); + + /// Set current signal mask. + void mask (sigset_t *); + void mask (ACE_Sig_Set &); + + /// Get current signal mask. + sigset_t *mask (void); + + /// Set current signal handler (pointer to function). + void handler (ACE_SignalHandler); + + /// Get current signal handler (pointer to function). + ACE_SignalHandler handler (void); + + /// Dump the state of an object. + void dump (void) const; + + /// Declare the dynamic allocation hooks. + ACE_ALLOC_HOOK_DECLARE; + +private: + /// Controls signal behavior. + struct sigaction sa_; +}; + +/** + * @class ACE_Sig_Guard + * + * @brief Hold signals in MASK for duration of a C++ statement block. + * Note that a "0" for mask causes all signals to be held. + */ +class ACE_Export ACE_Sig_Guard +{ +public: + // = Initialization and termination methods. + /// This is kind of conditional Guard, needed when guard should be + /// activated only when a spcific condition met. When condition == + /// true (default), Guard is activated + ACE_Sig_Guard (ACE_Sig_Set *mask = 0, bool condition = true); + + /// Restore blocked signals. + ~ACE_Sig_Guard (void); + + /// Dump the state of an object. + void dump (void) const; + + /// Declare the dynamic allocation hooks. + ACE_ALLOC_HOOK_DECLARE; + +private: + /// Original signal mask. + ACE_Sig_Set omask_; + + /// Guard Condition + bool condition_; +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +#include "ace/Signal.inl" +#endif /* __ACE_INLINE__ */ + +#include /**/ "ace/post.h" +#endif /* ACE_SIGNAL_HANDLER_H */ diff --git a/dep/ACE_wrappers/ace/Signal.inl b/dep/ACE_wrappers/ace/Signal.inl new file mode 100644 index 00000000000..858c33c26fb --- /dev/null +++ b/dep/ACE_wrappers/ace/Signal.inl @@ -0,0 +1,265 @@ +// -*- C++ -*- +// +// $Id: Signal.inl 80826 2008-03-04 14:51:23Z wotte $ + +#include "ace/OS_NS_signal.h" +#include "ace/config-all.h" +#include "ace/Trace.h" +#include "ace/Object_Manager_Base.h" +#include "ace/OS_NS_Thread.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_INLINE +ACE_Sig_Set::ACE_Sig_Set (sigset_t *ss) + // : sigset_ () +{ + ACE_TRACE ("ACE_Sig_Set::ACE_Sig_Set"); + + if (ss == 0) + ACE_OS::sigfillset (&this->sigset_); + else + // Structure assignment. + this->sigset_ = *ss; +} + +ACE_INLINE +ACE_Sig_Set::ACE_Sig_Set (int fill) + // : sigset_ () +{ + ACE_TRACE ("ACE_Sig_Set::ACE_Sig_Set"); + + if (fill) + ACE_OS::sigfillset (&this->sigset_); + else + ACE_OS::sigemptyset (&this->sigset_); +} + +ACE_INLINE +ACE_Sig_Set::ACE_Sig_Set (ACE_Sig_Set *ss) + // : sigset_ () +{ + ACE_TRACE ("ACE_Sig_Set::ACE_Sig_Set"); + + if (ss == 0) + ACE_OS::sigfillset (&this->sigset_); + else + this->sigset_ = ss->sigset_; +} + +ACE_INLINE int +ACE_Sig_Set::empty_set (void) +{ + ACE_TRACE ("ACE_Sig_Set::empty_set"); + return ACE_OS::sigemptyset (&this->sigset_); +} + +ACE_INLINE int +ACE_Sig_Set::fill_set (void) +{ + ACE_TRACE ("ACE_Sig_Set::fill_set"); + return ACE_OS::sigfillset (&this->sigset_); +} + +ACE_INLINE int +ACE_Sig_Set::sig_add (int signo) +{ + ACE_TRACE ("ACE_Sig_Set::sig_add"); + return ACE_OS::sigaddset (&this->sigset_, signo); +} + +ACE_INLINE int +ACE_Sig_Set::sig_del (int signo) +{ + ACE_TRACE ("ACE_Sig_Set::sig_del"); + return ACE_OS::sigdelset (&this->sigset_, signo); +} + +ACE_INLINE int +ACE_Sig_Set::is_member (int signo) const +{ + ACE_TRACE ("ACE_Sig_Set::is_member"); + return ACE_OS::sigismember (const_cast (&this->sigset_), signo); +} + +ACE_INLINE +ACE_Sig_Set::operator sigset_t *(void) +{ + ACE_TRACE ("ACE_Sig_Set::operator sigset_t *"); + return &this->sigset_; +} + +ACE_INLINE sigset_t +ACE_Sig_Set::sigset (void) const +{ + ACE_TRACE ("ACE_Sig_Set::sigset"); + return this->sigset_; +} + +ACE_INLINE int +ACE_Sig_Action::flags (void) +{ + ACE_TRACE ("ACE_Sig_Action::flags"); + return this->sa_.sa_flags; +} + +ACE_INLINE void +ACE_Sig_Action::flags (int flags) +{ + ACE_TRACE ("ACE_Sig_Action::flags"); + this->sa_.sa_flags = flags; +} + +ACE_INLINE sigset_t * +ACE_Sig_Action::mask (void) +{ + ACE_TRACE ("ACE_Sig_Action::mask"); + return &this->sa_.sa_mask; +} + +ACE_INLINE void +ACE_Sig_Action::mask (sigset_t *ss) +{ + ACE_TRACE ("ACE_Sig_Action::mask"); + if (ss != 0) + this->sa_.sa_mask = *ss; // Structure assignment +} + +ACE_INLINE void +ACE_Sig_Action::mask (ACE_Sig_Set &ss) +{ + ACE_TRACE ("ACE_Sig_Action::mask"); + this->sa_.sa_mask = ss.sigset (); // Structure assignment +} + +ACE_INLINE ACE_SignalHandler +ACE_Sig_Action::handler (void) +{ + ACE_TRACE ("ACE_Sig_Action::handler"); + return ACE_SignalHandler (this->sa_.sa_handler); +} + +ACE_INLINE void +ACE_Sig_Action::handler (ACE_SignalHandler handler) +{ + ACE_TRACE ("ACE_Sig_Action::handler"); +#if !defined(ACE_HAS_TANDEM_SIGNALS) + this->sa_.sa_handler = ACE_SignalHandlerV (handler); +#else + this->sa_.sa_handler = (void (*)()) ACE_SignalHandlerV (handler); +#endif /* !ACE_HAS_TANDEM_SIGNALS */ +} + +#if 0 +ACE_INLINE ACE_SignalHandler +ACE_Sig_Action::sigaction (void) +{ + ACE_TRACE ("ACE_Sig_Action::sigaction"); + return ACE_SignalHandler (this->sa_.sa_sigaction); +} + +ACE_INLINE void +ACE_Sig_Action::sigaction (ACE_SignalHandler handler) +{ + ACE_TRACE ("ACE_Sig_Action::sigaction"); + this->sa_.sa_sigaction = (void (*)()) ACE_SignalHandlerV (handler); +} +#endif /* 0 */ + +ACE_INLINE void +ACE_Sig_Action::set (struct sigaction *sa) +{ + ACE_TRACE ("ACE_Sig_Action::set"); + this->sa_ = *sa; // Structure assignment. +} + +ACE_INLINE struct sigaction * +ACE_Sig_Action::get (void) +{ + ACE_TRACE ("ACE_Sig_Action::get"); + return &this->sa_; +} + +ACE_INLINE +ACE_Sig_Action::operator struct sigaction * () +{ + ACE_TRACE ("ACE_Sig_Action::operator struct sigaction *"); + return &this->sa_; +} + +ACE_INLINE +ACE_Sig_Action::ACE_Sig_Action (const ACE_Sig_Action &s) + // : sa_ () +{ + ACE_TRACE ("ACE_Sig_Action::ACE_Sig_Action"); + *this = s; // structure copy. +} + +ACE_INLINE int +ACE_Sig_Action::register_action (int signum, ACE_Sig_Action *oaction) +{ + ACE_TRACE ("ACE_Sig_Action::register_action"); + struct sigaction *sa = oaction == 0 ? 0 : oaction->get (); + + return ACE_OS::sigaction (signum, &this->sa_, sa); +} + +ACE_INLINE int +ACE_Sig_Action::retrieve_action (int signum) +{ + ACE_TRACE ("ACE_Sig_Action::retrieve_action"); + return ACE_OS::sigaction (signum, 0, &this->sa_); +} + +ACE_INLINE int +ACE_Sig_Action::restore_action (int signum, ACE_Sig_Action &oaction) +{ + ACE_TRACE ("ACE_Sig_Action::restore_action"); + this->sa_ = *oaction.get (); // Structure assignment + return ACE_OS::sigaction (signum, &this->sa_, 0); +} + +// Block out the signal MASK until the destructor is called. + +ACE_INLINE +ACE_Sig_Guard::ACE_Sig_Guard (ACE_Sig_Set *mask, + bool condition) + : omask_ () + , condition_ (condition) +{ + //ACE_TRACE ("ACE_Sig_Guard::ACE_Sig_Guard"); + if (!this->condition_) + return; + +#if defined (ACE_LACKS_UNIX_SIGNALS) + ACE_UNUSED_ARG (mask); +#else + // If MASK is 0 then block all signals! + if (mask == 0) + { +# if defined (ACE_LACKS_PTHREAD_THR_SIGSETMASK) + ACE_OS::sigprocmask (SIG_BLOCK, + ACE_OS_Object_Manager::default_mask (), + (sigset_t *) this->omask_); +# else + ACE_OS::thr_sigsetmask (SIG_BLOCK, + ACE_OS_Object_Manager::default_mask (), + (sigset_t *) this->omask_); +# endif /* ACE_LACKS_PTHREAD_THR_SIGSETMASK */ + } + else +# if defined (ACE_LACKS_PTHREAD_THR_SIGSETMASK) + ACE_OS::sigprocmask (SIG_BLOCK, + (sigset_t *) *mask, + (sigset_t *) + this->omask_); +# else + ACE_OS::thr_sigsetmask (SIG_BLOCK, + (sigset_t *) *mask, + (sigset_t *) + this->omask_); +# endif /* ACE_LACKS_PTHREAD_THR_SIGSETMASK */ +#endif /* ACE_LACKS_UNIX_SIGNALS */ +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Singleton.cpp b/dep/ACE_wrappers/ace/Singleton.cpp new file mode 100644 index 00000000000..41c9cc194e0 --- /dev/null +++ b/dep/ACE_wrappers/ace/Singleton.cpp @@ -0,0 +1,534 @@ +// $Id: Singleton.cpp 80826 2008-03-04 14:51:23Z wotte $ + +#ifndef ACE_SINGLETON_CPP +#define ACE_SINGLETON_CPP + +#include "ace/Singleton.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#if !defined (__ACE_INLINE__) +#include "ace/Singleton.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/Object_Manager.h" +#include "ace/Log_Msg.h" +#include "ace/Framework_Component.h" +#include "ace/Guard_T.h" + +ACE_RCSID (ace, + Singleton, + "$Id: Singleton.cpp 80826 2008-03-04 14:51:23Z wotte $") + + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +template void +ACE_Singleton::dump (void) +{ +#if defined (ACE_HAS_DUMP) + ACE_TRACE ("ACE_Singleton::dump"); + +#if !defined (ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES) + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("instance_ = %x"), + ACE_Singleton::instance_i ())); + ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); +#endif /* ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES */ +#endif /* ACE_HAS_DUMP */ +} + +template ACE_Singleton *& +ACE_Singleton::instance_i (void) +{ +#if defined (ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES) + // Pointer to the Singleton instance. This works around a bug with + // G++ and it's (mis-)handling of templates and statics... + static ACE_Singleton *singleton_ = 0; + + return singleton_; +#else + return ACE_Singleton::singleton_; +#endif /* ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES */ +} + +template TYPE * +ACE_Singleton::instance (void) +{ + ACE_TRACE ("ACE_Singleton::instance"); + + ACE_Singleton *&singleton = + ACE_Singleton::instance_i (); + + // Perform the Double-Check pattern... + if (singleton == 0) + { + if (ACE_Object_Manager::starting_up () || + ACE_Object_Manager::shutting_down ()) + { + // The program is still starting up, and therefore assumed + // to be single threaded. There's no need to double-check. + // Or, the ACE_Object_Manager instance has been destroyed, + // so the preallocated lock is not available. Either way, + // don't register for destruction with the + // ACE_Object_Manager: we'll have to leak this instance. + + ACE_NEW_RETURN (singleton, (ACE_Singleton), 0); + } + else + { +#if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0) + // Obtain a lock from the ACE_Object_Manager. The pointer + // is static, so we only obtain one per ACE_Singleton + // instantiation. + static ACE_LOCK *lock = 0; + if (ACE_Object_Manager::get_singleton_lock (lock) != 0) + // Failed to acquire the lock! + return 0; + + ACE_GUARD_RETURN (ACE_LOCK, ace_mon, *lock, 0); + + if (singleton == 0) + { +#endif /* ACE_MT_SAFE */ + ACE_NEW_RETURN (singleton, (ACE_Singleton), 0); + + // Register for destruction with ACE_Object_Manager. + ACE_Object_Manager::at_exit (singleton); +#if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0) + } +#endif /* ACE_MT_SAFE */ + } + } + + return &singleton->instance_; +} + +template void +ACE_Singleton::cleanup (void *) +{ + delete this; + ACE_Singleton::instance_i () = 0; +} + +#if !defined (ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES) +// Pointer to the Singleton instance. +template ACE_Singleton * +ACE_Singleton::singleton_ = 0; + +template ACE_Unmanaged_Singleton * +ACE_Unmanaged_Singleton::singleton_ = 0; +#endif /* !defined (ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES) */ + +template void +ACE_Unmanaged_Singleton::dump (void) +{ +#if defined (ACE_HAS_DUMP) + ACE_TRACE ("ACE_Unmanaged_Singleton::dump"); + +#if !defined (ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES) + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("instance_ = %x"), + ACE_Unmanaged_Singleton::instance_i ())); + ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); +#endif /* ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES */ +#endif /* ACE_HAS_DUMP */ +} + +template +ACE_Unmanaged_Singleton *& +ACE_Unmanaged_Singleton::instance_i (void) +{ +#if defined (ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES) + // Pointer to the Singleton instance. This works around a bug with + // G++ and it's (mis-)handling of templates and statics... + static ACE_Unmanaged_Singleton *singleton_ = 0; + + return singleton_; +#else + return ACE_Unmanaged_Singleton::singleton_; +#endif /* ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES */ +} + +template TYPE * +ACE_Unmanaged_Singleton::instance (void) +{ + ACE_TRACE ("ACE_Unmanaged_Singleton::instance"); + + ACE_Unmanaged_Singleton *&singleton = + ACE_Unmanaged_Singleton::instance_i (); + + // Perform the Double-Check pattern... + if (singleton == 0) + { + if (ACE_Object_Manager::starting_up () || + ACE_Object_Manager::shutting_down ()) + { + // The program is still starting up, and therefore assumed + // to be single threaded. There's no need to double-check. + // Or, the ACE_Object_Manager instance has been destroyed, + // so the preallocated lock is not available. Either way, + // don't register for destruction with the + // ACE_Object_Manager: we'll have to leak this instance. + + ACE_NEW_RETURN (singleton, (ACE_Unmanaged_Singleton), + 0); + } + else + { +#if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0) + // Obtain a lock from the ACE_Object_Manager. The pointer + // is static, so we only obtain one per + // ACE_Unmanaged_Singleton instantiation. + static ACE_LOCK *lock = 0; + if (ACE_Object_Manager::get_singleton_lock (lock) != 0) + // Failed to acquire the lock! + return 0; + + ACE_GUARD_RETURN (ACE_LOCK, ace_mon, *lock, 0); +#endif /* ACE_MT_SAFE */ + + if (singleton == 0) + ACE_NEW_RETURN (singleton, + (ACE_Unmanaged_Singleton), + 0); + } + } + + return &singleton->instance_; +} + +template void +ACE_Unmanaged_Singleton::close (void) +{ + ACE_Unmanaged_Singleton *&singleton = + ACE_Unmanaged_Singleton::instance_i (); + + if (singleton) + { + singleton->cleanup (); + ACE_Unmanaged_Singleton::instance_i () = 0; + } +} + +template void +ACE_TSS_Singleton::dump (void) +{ +#if defined (ACE_HAS_DUMP) + ACE_TRACE ("ACE_TSS_Singleton::dump"); + +#if !defined (ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES) + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("instance_ = %x"), + ACE_TSS_Singleton::instance_i ())); + ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); +#endif /* ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES */ +#endif /* ACE_HAS_DUMP */ +} + +template ACE_TSS_Singleton *& +ACE_TSS_Singleton::instance_i (void) +{ +#if defined (ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES) + // Pointer to the Singleton instance. This works around a bug with + // G++ and it's (mis-)handling of templates and statics... + static ACE_TSS_Singleton *singleton_ = 0; + + return singleton_; +#else + return ACE_TSS_Singleton::singleton_; +#endif /* ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES */ +} + +template TYPE * +ACE_TSS_Singleton::instance (void) +{ + ACE_TRACE ("ACE_TSS_Singleton::instance"); + + ACE_TSS_Singleton *&singleton = + ACE_TSS_Singleton::instance_i (); + + // Perform the Double-Check pattern... + if (singleton == 0) + { + if (ACE_Object_Manager::starting_up () || + ACE_Object_Manager::shutting_down ()) + { + // The program is still starting up, and therefore assumed + // to be single threaded. There's no need to double-check. + // Or, the ACE_Object_Manager instance has been destroyed, + // so the preallocated lock is not available. Either way, + // don't register for destruction with the + // ACE_Object_Manager: we'll have to leak this instance. + + ACE_NEW_RETURN (singleton, (ACE_TSS_Singleton), 0); + } + else + { +#if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0) + + // Obtain a lock from the ACE_Object_Manager. The pointer + // is static, so we only obtain one per ACE_Singleton instantiation. + static ACE_LOCK *lock = 0; + if (ACE_Object_Manager::get_singleton_lock (lock) != 0) + // Failed to acquire the lock! + return 0; + + ACE_GUARD_RETURN (ACE_LOCK, ace_mon, *lock, 0); + + if (singleton == 0) + { +#endif /* ACE_MT_SAFE */ + ACE_NEW_RETURN (singleton, (ACE_TSS_Singleton), + 0); + + // Register for destruction with ACE_Object_Manager. + ACE_Object_Manager::at_exit (singleton); +#if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0) + } +#endif /* ACE_MT_SAFE */ + } + } + + return ACE_TSS_GET (&singleton->instance_, TYPE); +} + +template void +ACE_TSS_Singleton::cleanup (void *) +{ + delete this; + ACE_TSS_Singleton::instance_i () = 0; +} + +template void +ACE_Unmanaged_TSS_Singleton::dump (void) +{ +#if defined (ACE_HAS_DUMP) + ACE_TRACE ("ACE_Unmanaged_TSS_Singleton::dump"); + +#if !defined (ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES) + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("instance_ = %x"), + ACE_Unmanaged_TSS_Singleton::instance_i ())); + ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); +#endif /* ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES */ +#endif /* ACE_HAS_DUMP */ +} + +template +ACE_Unmanaged_TSS_Singleton *& +ACE_Unmanaged_TSS_Singleton::instance_i (void) +{ +#if defined (ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES) + // Pointer to the Singleton instance. This works around a bug with + // G++ and it's (mis-)handling of templates and statics... + static ACE_Unmanaged_TSS_Singleton *singleton_ = 0; + + return singleton_; +#else + return ACE_Unmanaged_TSS_Singleton::singleton_; +#endif /* ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES */ +} + +template TYPE * +ACE_Unmanaged_TSS_Singleton::instance (void) +{ + ACE_TRACE ("ACE_Unmanaged_TSS_Singleton::instance"); + + ACE_Unmanaged_TSS_Singleton *&singleton = + ACE_Unmanaged_TSS_Singleton::instance_i (); + + // Perform the Double-Check pattern... + if (singleton == 0) + { + if (ACE_Object_Manager::starting_up () || + ACE_Object_Manager::shutting_down ()) + { + // The program is still starting up, and therefore assumed + // to be single threaded. There's no need to double-check. + // Or, the ACE_Object_Manager instance has been destroyed, + // so the preallocated lock is not available. Either way, + // don't register for destruction with the + // ACE_Object_Manager: we'll have to leak this instance. + + ACE_NEW_RETURN (singleton, + (ACE_Unmanaged_TSS_Singleton), + 0); + } + else + { +#if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0) + // Obtain a lock from the ACE_Object_Manager. The pointer + // is static, so we only obtain one per + // ACE_Unmanaged_Singleton instantiation. + static ACE_LOCK *lock = 0; + if (ACE_Object_Manager::get_singleton_lock (lock) != 0) + // Failed to acquire the lock! + return 0; + + ACE_GUARD_RETURN (ACE_LOCK, ace_mon, *lock, 0); +#endif /* ACE_MT_SAFE */ + + if (singleton == 0) + ACE_NEW_RETURN (singleton, + (ACE_Unmanaged_TSS_Singleton), + 0); + } + } + + return ACE_TSS_GET (&singleton->instance_, TYPE); +} + +template void +ACE_Unmanaged_TSS_Singleton::close (void) +{ + ACE_Unmanaged_TSS_Singleton *&singleton = + ACE_Unmanaged_TSS_Singleton::instance_i (); + + if (singleton) + singleton->cleanup (); +} + +#if !defined (ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES) +// Pointer to the Singleton instance. +template ACE_TSS_Singleton * +ACE_TSS_Singleton::singleton_ = 0; + +template +ACE_Unmanaged_TSS_Singleton * +ACE_Unmanaged_TSS_Singleton::singleton_ = 0; +#endif /* !defined (ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES) */ + +/*************************************************************************/ + +#if !defined (ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES) +// Pointer to the Singleton instance. +template ACE_DLL_Singleton_T * +ACE_DLL_Singleton_T::singleton_ = 0; +#endif /* !defined (ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES) */ + +template void +ACE_DLL_Singleton_T::dump (void) +{ +#if defined (ACE_HAS_DUMP) + ACE_TRACE ("ACE_DLL_Singleton_T::dump"); + +#if !defined (ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES) + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("instance_ = %x"), + ACE_DLL_Singleton_T::instance_i ())); + ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); +#endif /* ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES */ +#endif /* ACE_HAS_DUMP */ +} + +template +ACE_DLL_Singleton_T *& +ACE_DLL_Singleton_T::instance_i (void) +{ + ACE_TRACE ("ACE_DLL_Singleton_T::instance_i"); + +#if defined (ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES) + // Pointer to the Singleton instance. This works around a bug with + // G++ and it's (mis-)handling of templates and statics... + static ACE_DLL_Singleton_T *singleton_ = 0; + + return singleton_; +#else + return ACE_DLL_Singleton_T::singleton_; +#endif /* ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES */ +} + +template TYPE * +ACE_DLL_Singleton_T::instance (void) +{ + ACE_TRACE ("ACE_DLL_Singleton_T::instance"); + + ACE_DLL_Singleton_T *&singleton = + ACE_DLL_Singleton_T::instance_i (); + + // Perform the Double-Check pattern... + if (singleton == 0) + { + if (ACE_Object_Manager::starting_up () || + ACE_Object_Manager::shutting_down ()) + { + // The program is still starting up, and therefore assumed + // to be single threaded. There's no need to double-check. + // Or, the ACE_Object_Manager instance has been destroyed, + // so the preallocated lock is not available. Either way, + // don't register for destruction with the + // ACE_Object_Manager: we'll have to leak this instance. + + ACE_NEW_RETURN (singleton, (ACE_DLL_Singleton_T), + 0); + } + else + { +#if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0) + // Obtain a lock from the ACE_Object_Manager. The pointer + // is static, so we only obtain one per + // ACE_Unmanaged_Singleton instantiation. + static ACE_LOCK *lock = 0; + if (ACE_Object_Manager::get_singleton_lock (lock) != 0) + // Failed to acquire the lock! + return 0; + + ACE_GUARD_RETURN (ACE_LOCK, ace_mon, *lock, 0); +#endif /* ACE_MT_SAFE */ + + if (singleton == 0) + ACE_NEW_RETURN (singleton, + (ACE_DLL_Singleton_T), + 0); + } + //ACE_REGISTER_FRAMEWORK_COMPONENT(ACE_DLL_Singleton, singleton); + ACE_Framework_Repository::instance ()->register_component + (new ACE_Framework_Component_T > (singleton)); + } + + return &singleton->instance_; +} + +template void +ACE_DLL_Singleton_T::close (void) +{ + ACE_TRACE ("ACE_DLL_Singleton_T::close"); + + ACE_DLL_Singleton_T *&singleton = + ACE_DLL_Singleton_T::instance_i (); + + delete singleton; + singleton = 0; +} + +template void +ACE_DLL_Singleton_T::close_singleton (void) +{ + ACE_TRACE ("ACE_DLL_Singleton_T::close_singleton"); + ACE_DLL_Singleton_T::close (); +} + +template const ACE_TCHAR * +ACE_DLL_Singleton_T::dll_name (void) +{ + return this->instance ()->dll_name (); +} + +template const ACE_TCHAR * +ACE_DLL_Singleton_T::name (void) +{ + return this->instance ()->name (); +} + + +/**********************************************************************/ + +template const ACE_TCHAR* +ACE_DLL_Singleton_Adapter_T::dll_name (void) +{ + // @todo make this a constant somewhere (or it there already is one + // then use it. + return ACE_TEXT("ACE"); +} + +ACE_END_VERSIONED_NAMESPACE_DECL + +#endif /* ACE_SINGLETON_CPP */ diff --git a/dep/ACE_wrappers/ace/Singleton.h b/dep/ACE_wrappers/ace/Singleton.h new file mode 100644 index 00000000000..e9c8498ff8a --- /dev/null +++ b/dep/ACE_wrappers/ace/Singleton.h @@ -0,0 +1,327 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Singleton.h + * + * $Id: Singleton.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @brief + * + * @author Tim Harrison + * @author Douglas C. Schmidt + * @author Chris Lahey + * @author Rich Christy + * @author David Levine + */ +//============================================================================= + +#ifndef ACE_SINGLETON_H +#define ACE_SINGLETON_H +#include /**/ "ace/pre.h" + +#include /**/ "ace/config-all.h" +#include "ace/TSS_T.h" +#include "ace/Cleanup.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +/** + * @class ACE_Singleton + * + * @brief A Singleton Adapter uses the Adapter pattern to turn ordinary + * classes into Singletons optimized with the Double-Checked + * Locking optimization pattern. + * + * This implementation is a slight variation on the GoF + * Singleton pattern. In particular, a single + * > instance is allocated here, + * not a instance. The reason for this is to allow + * registration with the ACE_Object_Manager, so that the + * Singleton can be cleaned up when the process exits. For this + * scheme to work, a (static) cleanup() function must be + * provided. ACE_Singleton provides one so that TYPE doesn't + * need to. + * If you want to make sure that only the singleton instance of + * is created, and that users cannot create their own + * instances of , do the following to class : + * (a) Make the constructor of private (or protected) + * (b) Make Singleton a friend of + * Here is an example: + * @verbatim + * class foo + * { + * friend class ACE_Singleton; + * private: + * foo () { cout << "foo constructed" << endl; } + * ~foo () { cout << "foo destroyed" << endl; } + * }; + * typedef ACE_Singleton FOO; + * @endverbatim + * + * @note The best types to use for ACE_LOCK are + * ACE_Recursive_Thread_Mutex and ACE_Null_Mutex. + * ACE_Recursive_Thread_Mutex should be used in multi-threaded + * programs in which it is possible for more than one thread to + * access the > instance. + * ACE_Null_Mutex can be used otherwise. The reason that these + * types of locks are best has to do with their allocation by + * the ACE_Object_Manager. Single ACE_Recursive_Thread_Mutex + * and ACE_Null_Mutex instances are used for all ACE_Singleton + * instantiations. However, other types of locks are allocated + * per ACE_Singleton instantiation. + */ +template +class ACE_Singleton : public ACE_Cleanup +{ +public: + /// Global access point to the Singleton. + static TYPE *instance (void); + + /// Cleanup method, used by to destroy the + /// ACE_Singleton. + virtual void cleanup (void *param = 0); + + /// Dump the state of the object. + static void dump (void); + +protected: + /// Default constructor. + ACE_Singleton (void); + + /// Contained instance. + TYPE instance_; + +#if !defined (ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES) + /// Pointer to the Singleton (ACE_Cleanup) instance. + static ACE_Singleton *singleton_; +#endif /* ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES */ + + /// Get pointer to the Singleton instance. + static ACE_Singleton *&instance_i (void); +}; + +/** + * @class ACE_Unmanaged_Singleton + * + * @brief Same as ACE_Singleton, except does _not_ register with + * ACE_Object_Manager for destruction. + * + * This version of ACE_Singleton can be used if, for example, + * its DLL will be unloaded before the ACE_Object_Manager + * destroys the instance. Unlike with ACE_Singleton, the + * application is responsible for explicitly destroying the + * instance after it is no longer needed (if it wants to avoid + * memory leaks, at least). The close() static member function + * must be used to explicitly destroy the Singleton. + * Usage is the same as for ACE_Singleton, but note that if you + * you declare a friend, the friend class must still be an + * *ACE_Singleton*, not an ACE_Unmanaged_Singleton. + */ +template +class ACE_Unmanaged_Singleton : public ACE_Singleton +{ +public: + /// Global access point to the Singleton. + static TYPE *instance (void); + + /// Explicitly delete the Singleton instance. + static void close (void); + + /// Dump the state of the object. + static void dump (void); + +protected: + /// Default constructor. + ACE_Unmanaged_Singleton (void); + +#if !defined (ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES) + /// Pointer to the Singleton (ACE_Cleanup) instance. + static ACE_Unmanaged_Singleton *singleton_; +#endif /* ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES */ + + /// Get pointer to the Singleton instance. + static ACE_Unmanaged_Singleton *&instance_i (void); +}; + +/** + * @class ACE_TSS_Singleton + * + * @brief This class uses the Adapter pattern to turn ordinary classes + * into Thread-specific Singletons optimized with the + * Double-Checked Locking optimization pattern. + * + * This implementation is another variation on the GoF Singleton + * pattern. In this case, a single > instance is allocated here, not a instance. + * Each call to the static method returns a Singleton + * whose pointer resides in thread-specific storage. As with + * ACE_Singleton, we use the ACE_Object_Manager so that the + * Singleton can be cleaned up when the process exits. For this + * scheme to work, a (static) cleanup() function must be + * provided. ACE_Singleton provides one so that TYPE doesn't + * need to. + */ +template +class ACE_TSS_Singleton : public ACE_Cleanup +{ +public: + /// Global access point to the singleton. + static TYPE *instance (void); + + /// Cleanup method, used by to destroy the + /// singleton. + virtual void cleanup (void *param = 0); + + /// Dump the state of the object. + static void dump (void); + +protected: + /// Default constructor. + ACE_TSS_Singleton (void); + + /// Contained instance. + ACE_TSS_TYPE (TYPE) instance_; + + ACE_UNIMPLEMENTED_FUNC (void operator= (const ACE_TSS_Singleton &)) + ACE_UNIMPLEMENTED_FUNC (ACE_TSS_Singleton (const ACE_TSS_Singleton &)) + +#if !defined (ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES) + /// Pointer to the Singleton (ACE_Cleanup) instance. + static ACE_TSS_Singleton *singleton_; +#endif /* ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES */ + + /// Get pointer to the TSS Singleton instance. + static ACE_TSS_Singleton *&instance_i (void); +}; + +/** + * @class ACE_Unmanaged_TSS_Singleton + * + * @brief Same as ACE_TSS_Singleton, except does _not_ register with + * ACE_Object_Manager for destruction. + * + * This version of ACE_TSS_Singleton can be used if, for example, its DLL will + * be unloaded before the ACE_Object_Manager destroys the instance. Unlike with + * ACE_Singleton, the application is responsible for explicitly destroying the + * instance after it is no longer needed (if it wants to avoid memory leaks, + * at least). The close() static member function must be used to explicitly + * destroy the Singleton. + */ +template +class ACE_Unmanaged_TSS_Singleton : public ACE_TSS_Singleton +{ +public: + /// Global access point to the singleton. + static TYPE *instance (void); + + /// Explicitly delete the singleton instance. + static void close (void); + + /// Dump the state of the object. + static void dump (void); + +protected: + /// Default constructor. + ACE_Unmanaged_TSS_Singleton (void); + +#if !defined (ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES) + /// Pointer to the Singleton (ACE_Cleanup) instance. + static ACE_Unmanaged_TSS_Singleton *singleton_; +#endif /* ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES */ + + /// Get pointer to the Singleton instance. + static ACE_Unmanaged_TSS_Singleton *&instance_i (void); +}; + +/** + * @class ACE_DLL_Singleton_T + * + * @brief Same as ACE_Singleton, except that it registers for + * destruction with the ACE_Framework_Repository instead of + * with the ACE_Object_Manager directly. + * + * This version of ACE_Singleton should be used for singletons + * that live in a dll loaded either directly by ACE_DLL or indirectly + * by the ACE Service Configuration framework. Whenever ACE_DLL is ready + * to actually unload the dll, ACE_DLL_Singleton based dlls associated + * with that dll will be destroyed first. In fact, any singleton can + * safely use ACE_DLL_Singleton, even those that don't live in dlls. In + * that case, the singleton will be destroyed at normal program shutdown. + * + * The only additional requirement is that the contained class + * export name() and dll_name() methods. See ACE_DLL_Singleton_Adapter_T + * below for a convenient example of how to satisfy this + * requirement for the dll_name(). + * + * Usage is the same as for ACE_Singleton, but note that if you + * you declare a friend, the friend class must still be an + * *ACE_Singleton*, not an ACE_Unmanaged_Singleton. + */ +template +class ACE_DLL_Singleton_T +{ +public: + //void cleanup (void *param = 0); + + /// Global access point to the Singleton. + static TYPE *instance (void); + + /// Explicitly delete the Singleton instance. + static void close (void); + + static void close_singleton (void); + + /// Dump the state of the object. + static void dump (void); + + const ACE_TCHAR *dll_name (void); + + const ACE_TCHAR *name (void); + +protected: + /// Default constructor. + ACE_DLL_Singleton_T (void); + + /// Destructor. + ~ACE_DLL_Singleton_T (void); + + /// Contained instance. + TYPE instance_; + +#if !defined (ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES) + /// Pointer to the Singleton instance. + static ACE_DLL_Singleton_T *singleton_; +#endif /* ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES */ + + /// Get pointer to the singleton instance. + static ACE_DLL_Singleton_T *&instance_i (void); +}; + +template +class ACE_DLL_Singleton_Adapter_T : public TYPE +{ +public: + const ACE_TCHAR *dll_name (void); +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +#include "ace/Singleton.inl" +#endif /* __ACE_INLINE__ */ + +#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) +#include "ace/Singleton.cpp" +#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ + +#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) +#pragma implementation ("Singleton.cpp") +#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ + +#include /**/ "ace/post.h" +#endif /* ACE_SINGLETON_H */ diff --git a/dep/ACE_wrappers/ace/Singleton.inl b/dep/ACE_wrappers/ace/Singleton.inl new file mode 100644 index 00000000000..107a8b78c6d --- /dev/null +++ b/dep/ACE_wrappers/ace/Singleton.inl @@ -0,0 +1,42 @@ +// -*- C++ -*- +// +// $Id: Singleton.inl 80826 2008-03-04 14:51:23Z wotte $ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +// Default constructors. +// +// Note: don't explicitly initialize "instance_", because TYPE may not +// have a default constructor. Let the compiler figure it out . . . + +template ACE_INLINE +ACE_Singleton::ACE_Singleton (void) +{ +} + +template ACE_INLINE +ACE_Unmanaged_Singleton::ACE_Unmanaged_Singleton (void) +{ +} + +template ACE_INLINE +ACE_TSS_Singleton::ACE_TSS_Singleton (void) +{ +} + +template ACE_INLINE +ACE_Unmanaged_TSS_Singleton::ACE_Unmanaged_TSS_Singleton (void) +{ +} + +template ACE_INLINE +ACE_DLL_Singleton_T::ACE_DLL_Singleton_T (void) +{ +} + +template +ACE_DLL_Singleton_T::~ACE_DLL_Singleton_T (void) +{ +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Sock_Connect.cpp b/dep/ACE_wrappers/ace/Sock_Connect.cpp new file mode 100644 index 00000000000..99815ce797c --- /dev/null +++ b/dep/ACE_wrappers/ace/Sock_Connect.cpp @@ -0,0 +1,1603 @@ +// $Id: Sock_Connect.cpp 82276 2008-07-09 17:35:49Z jtc $ + +#include "ace/Sock_Connect.h" +#include "ace/INET_Addr.h" +#include "ace/Log_Msg.h" +#include "ace/Handle_Set.h" +#include "ace/Auto_Ptr.h" +#include "ace/SString.h" +#include "ace/OS_Memory.h" +#include "ace/OS_NS_stdio.h" +#include "ace/ACE.h" + +#if defined (sparc) +# include "ace/OS_NS_fcntl.h" +#endif // sparc + +#include "ace/OS_NS_stdlib.h" +#include "ace/OS_NS_string.h" +#include "ace/OS_NS_sys_socket.h" +#include "ace/OS_NS_netdb.h" +#include "ace/OS_NS_unistd.h" +#include "ace/os_include/net/os_if.h" + +#if defined (ACE_HAS_IPV6) +# include "ace/Guard_T.h" +# include "ace/Recursive_Thread_Mutex.h" +# if defined (_AIX) +# include /**/ +# endif /* _AIX */ +#endif /* ACE_HAS_IPV6 */ + +# if defined (ACE_HAS_GETIFADDRS) +# if defined (ACE_VXWORKS) +# include /**/ +# else +# include /**/ +# endif /*ACE_VXWORKS */ +# endif /* ACE_HAS_GETIFADDRS */ + +#if defined (ACE_VXWORKS) && (ACE_VXWORKS < 0x600) +#include /**/ +#include /**/ +#if defined (ACE_HAS_IPV6) +#include /**/ +extern "C" { + extern struct in_ifaddr* in_ifaddr; + extern LIST_HEAD(in_ifaddrhashhead, in_ifaddr) *in_ifaddrhashtbl; +} +#endif /* ACE_HAS_IPV6 */ +#include "ace/OS_NS_stdio.h" +#endif /* ACE_VXWORKS < 0x600 */ + +#if defined (ACE_VXWORKS) && ((ACE_VXWORKS == 0x630) || (ACE_VXWORKS == 0x640)) && defined (__RTP__) && defined (ACE_HAS_IPV6) +const struct in6_addr in6addr_any = IN6ADDR_ANY_INIT; +const struct in6_addr in6addr_nodelocal_allnodes = IN6ADDR_NODELOCAL_ALLNODES_INIT; +const struct in6_addr in6addr_linklocal_allnodes = IN6ADDR_LINKLOCAL_ALLNODES_INIT; +const struct in6_addr in6addr_linklocal_allrouters = IN6ADDR_LINKLOCAL_ALLROUTERS_INIT; +#endif /* ACE_VXWORKS == 0x630 && __RTP__ && ACE_HAS_IPV6 */ + +#if defined (ACE_HAS_WINCE) +#include /**/ +// The following code is suggested by microsoft as a workaround to the fact +// that on Windows CE, these constants are exported as function addresses +// rather than simply values. +# include /**/ +const struct in6_addr in6addr_any = IN6ADDR_ANY_INIT; +const struct in6_addr in6addr_loopback = IN6ADDR_LOOPBACK_INIT; +#endif // ACE_HAS_WINCE + +#if defined (ACE_WIN32) && defined (ACE_HAS_PHARLAP) +# include "ace/OS_NS_stdio.h" +#endif + +#if defined (ACE_HAS_IPV6) + +// These defines support a generic usage based on +// the various SIGCF*IF ioctl implementations + +# if defined (SIOCGLIFCONF) +# define SIOCGIFCONF_CMD SIOCGLIFCONF +# if defined (__hpux) +# define IFREQ if_laddrreq +# define IFCONF if_laddrconf +# define IFC_REQ iflc_req +# define IFC_LEN iflc_len +# define IFC_BUF iflc_buf +# define IFR_ADDR iflr_addr +# define IFR_NAME iflr_name +# define IFR_FLAGS iflr_flags +# undef SETFAMILY +# define SA_FAMILY sa_family +# else +# define IFREQ lifreq +# define IFCONF lifconf +# define IFC_REQ lifc_req +# define IFC_LEN lifc_len +# define IFC_BUF lifc_buf +# define IFR_ADDR lifr_addr +# define IFR_NAME lifr_name +# define IFR_FLAGS lifr_flags +# define SETFAMILY +# define IFC_FAMILY lifc_family +# define IFC_FLAGS lifc_flags +# define SA_FAMILY ss_family +# endif +# else +# define SIOCGIFCONF_CMD SIOCGIFCONF +# define IFREQ ifreq +# define IFCONF ifconf +# define IFC_REQ ifc_req +# define IFC_LEN ifc_len +# define IFC_BUF ifc_buf +# define IFR_ADDR ifr_addr +# define IFR_NAME ifr_name +# define IFR_FLAGS ifr_flags +# undef SETFAMILY +# define SA_FAMILY sa_family +# endif /* SIOCGLIFCONF */ + +# if defined (ACE_HAS_THREADS) +# include "ace/Object_Manager.h" +# endif /* ACE_HAS_THREADS */ + +namespace +{ + // private: + // Used internally so not exported. + + // Does this box have ipv4 turned on? + int ace_ipv4_enabled = -1; + + // Does this box have ipv6 turned on? + int ace_ipv6_enabled = -1; + +} +#else /* ACE_HAS_IPV6 */ +# define SIOCGIFCONF_CMD SIOCGIFCONF +# define IFREQ ifreq +# define IFCONF ifconf +# define IFC_REQ ifc_req +# define IFC_LEN ifc_len +# define IFC_BUF ifc_buf +# define IFR_ADDR ifr_addr +# define IFR_NAME ifr_name +# define IFR_FLAGS ifr_flags +# undef SETFAMILY +# define SA_FAMILY sa_family +#endif /* ACE_HAS_IPV6 */ + +// This is a hack to work around a problem with Visual Age C++ 5 and 6 on AIX. +// Without this, the compiler auto-instantiates the ACE_Auto_Array_Ptr for +// ifreq (contained in this module) but only adds the #include for +// and not the one for which is also needed. Although we +// don't need the template defined here, it makes the compiler pull in +// and the build runs clean. +#if defined (AIX) && defined (__IBMCPP__) && (__IBMCPP__ >= 500) && (__IBMCPP__ < 700) +static ACE_Auto_Array_Ptr force_compiler_to_include_socket_h; +#endif /* AIX && __IBMCPP__ >= 500 */ + + +ACE_RCSID (ace, + Sock_Connect, + "$Id: Sock_Connect.cpp 82276 2008-07-09 17:35:49Z jtc $") + + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +// Bind socket to an unused port. + +int +ACE::bind_port (ACE_HANDLE handle, ACE_UINT32 ip_addr, int address_family) +{ + ACE_TRACE ("ACE::bind_port"); + + ACE_INET_Addr addr; + +#if defined (ACE_HAS_IPV6) + if (address_family != PF_INET6) + // What do we do if it is PF_"INET6? Since it's 4 bytes, it must be an + // IPV4 address. Is there a difference? Why is this test done? dhinton +#else /* ACE_HAS_IPV6 */ + ACE_UNUSED_ARG (address_family); +#endif /* !ACE_HAS_IPV6 */ + addr = ACE_INET_Addr ((u_short)0, ip_addr); +#if defined (ACE_HAS_IPV6) + else if (ip_addr != INADDR_ANY) + // address_family == PF_INET6 and a non default IP address means to bind + // to the IPv4-mapped IPv6 address + addr.set ((u_short)0, ip_addr, 1, 1); +#endif /* ACE_HAS_IPV6 */ + + // The OS kernel should select a free port for us. + return ACE_OS::bind (handle, + (sockaddr*)addr.get_addr(), + addr.get_size()); +} + +int +ACE::get_bcast_addr (ACE_UINT32 &bcast_addr, + const ACE_TCHAR *host_name, + ACE_UINT32 host_addr, + ACE_HANDLE handle) +{ + ACE_TRACE ("ACE::get_bcast_addr"); + +#if defined (ACE_LACKS_GET_BCAST_ADDR) + ACE_UNUSED_ARG (bcast_addr); + ACE_UNUSED_ARG (host_name); + ACE_UNUSED_ARG (host_addr); + ACE_UNUSED_ARG (handle); + ACE_NOTSUP_RETURN (-1); +#elif !defined(ACE_WIN32) && !defined(__INTERIX) + ACE_HANDLE s = handle; + + if (s == ACE_INVALID_HANDLE) + s = ACE_OS::socket (AF_INET, SOCK_STREAM, 0); + + if (s == ACE_INVALID_HANDLE) + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("%p\n"), + ACE_TEXT ("ACE_OS::socket")), + -1); + + struct ifconf ifc; + char buf[BUFSIZ]; + + ifc.ifc_len = sizeof buf; + ifc.ifc_buf = buf; + + // Get interface structure and initialize the addresses using UNIX + // techniques + if (ACE_OS::ioctl (s, SIOCGIFCONF_CMD, (char *) &ifc) == -1) + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("%p\n"), + ACE_TEXT ("ACE::get_bcast_addr:") + ACE_TEXT ("ioctl (get interface configuration)")), + -1); + + struct ifreq *ifr = ifc.ifc_req; + + struct sockaddr_in ip_addr; + + // Get host ip address if necessary. + if (host_name) + { + hostent *hp = ACE_OS::gethostbyname (ACE_TEXT_ALWAYS_CHAR (host_name)); + + if (hp == 0) + return -1; + else +#if !defined(_UNICOS) + ACE_OS::memcpy ((char *) &ip_addr.sin_addr.s_addr, + (char *) hp->h_addr, + hp->h_length); +#else /* _UNICOS */ + { + ACE_UINT64 haddr; // a place to put the address + char * haddrp = (char *) &haddr; // convert to char pointer + ACE_OS::memcpy(haddrp,(char *) hp->h_addr,hp->h_length); + ip_addr.sin_addr.s_addr = haddr; + } +#endif /* ! _UNICOS */ + } + else + { + ACE_OS::memset ((void *) &ip_addr, 0, sizeof ip_addr); +#if !defined(_UNICOS) + ACE_OS::memcpy ((void *) &ip_addr.sin_addr, + (void*) &host_addr, + sizeof ip_addr.sin_addr); +#else /* _UNICOS */ + ip_addr.sin_addr.s_addr = host_addr; // just copy to the bitfield +#endif /* ! _UNICOS */ + } + +#if !defined(AIX) && !defined (__QNX__) && !defined (__FreeBSD__) && !defined(__NetBSD__) + for (int n = ifc.ifc_len / sizeof (struct ifreq) ; n > 0; + n--, ifr++) +#else + // see mk_broadcast@SOCK_Dgram_Bcast.cpp + for (int nbytes = ifc.ifc_len; nbytes >= (int) sizeof (struct ifreq) && + ((ifr->ifr_addr.sa_len > sizeof (struct sockaddr)) ? + (nbytes >= (int) sizeof (ifr->ifr_name) + ifr->ifr_addr.sa_len) : 1); + ((ifr->ifr_addr.sa_len > sizeof (struct sockaddr)) ? + (nbytes -= sizeof (ifr->ifr_name) + ifr->ifr_addr.sa_len, + ifr = (struct ifreq *) + ((caddr_t) &ifr->ifr_addr + ifr->ifr_addr.sa_len)) : + (nbytes -= sizeof (struct ifreq), ifr++))) +#endif /* !defined(AIX) && !defined (__QNX__) && !defined (__FreeBSD__) && !defined(__NetBSD__) */ + { + struct sockaddr_in if_addr; + + // Compare host ip address with interface ip address. + ACE_OS::memcpy (&if_addr, + &ifr->ifr_addr, + sizeof if_addr); + + if (ip_addr.sin_addr.s_addr != if_addr.sin_addr.s_addr) + continue; + + if (ifr->ifr_addr.sa_family != AF_INET) + { + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("%p\n"), + ACE_TEXT ("ACE::get_bcast_addr:") + ACE_TEXT ("Not AF_INET"))); + continue; + } + + struct ifreq flags = *ifr; + struct ifreq if_req = *ifr; + + if (ACE_OS::ioctl (s, SIOCGIFFLAGS, (char *) &flags) == -1) + { + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("%p\n"), + ACE_TEXT ("ACE::get_bcast_addr:") + ACE_TEXT (" ioctl (get interface flags)"))); + continue; + } + + if (ACE_BIT_DISABLED (flags.ifr_flags, IFF_UP)) + { + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("%p\n"), + ACE_TEXT ("ACE::get_bcast_addr:") + ACE_TEXT ("Network interface is not up"))); + continue; + } + + if (ACE_BIT_ENABLED (flags.ifr_flags, IFF_LOOPBACK)) + continue; + + if (ACE_BIT_ENABLED (flags.ifr_flags, IFF_BROADCAST)) + { + if (ACE_OS::ioctl (s, + SIOCGIFBRDADDR, + (char *) &if_req) == -1) + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("%p\n"), + ACE_TEXT ("ACE::get_bcast_addr:") + ACE_TEXT ("ioctl (get broadaddr)"))); + else + { + ACE_OS::memcpy (&ip_addr, + &if_req.ifr_broadaddr, + sizeof if_req.ifr_broadaddr); + + ACE_OS::memcpy ((void *) &host_addr, + (void *) &ip_addr.sin_addr, + sizeof host_addr); + + if (handle == ACE_INVALID_HANDLE) + ACE_OS::close (s); + + bcast_addr = host_addr; + return 0; + } + } + else + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("%p\n"), + ACE_TEXT ("ACE::get_bcast_addr:") + ACE_TEXT ("Broadcast is not enable for this interface."))); + + if (handle == ACE_INVALID_HANDLE) + ACE_OS::close (s); + + bcast_addr = host_addr; + return 0; + } + + return 0; +#else + ACE_UNUSED_ARG (handle); + ACE_UNUSED_ARG (host_addr); + ACE_UNUSED_ARG (host_name); + bcast_addr = (ACE_UINT32 (INADDR_BROADCAST)); + return 0; +#endif /* !ACE_WIN32 && !__INTERIX */ +} + +int +ACE::get_fqdn (ACE_INET_Addr const & addr, + char hostname[], + size_t len) +{ + int h_error; // Not the same as errno! + hostent hentry; + ACE_HOSTENT_DATA buf; + + char * ip_addr = 0; + int ip_addr_size = 0; + if (addr.get_type () == AF_INET) + { + sockaddr_in * const sock_addr = + reinterpret_cast (addr.get_addr ()); + ip_addr_size = sizeof sock_addr->sin_addr; + ip_addr = (char*) &sock_addr->sin_addr; + } +#ifdef ACE_HAS_IPV6 + else + { + sockaddr_in6 * sock_addr = + reinterpret_cast (addr.get_addr ()); + + ip_addr_size = sizeof sock_addr->sin6_addr; + ip_addr = (char*) &sock_addr->sin6_addr; + } +#endif /* ACE_HAS_IPV6 */ + + // get the host entry for the address in question + hostent * const hp = ACE_OS::gethostbyaddr_r (ip_addr, + ip_addr_size, + addr.get_type (), + &hentry, + buf, + &h_error); + + // if it's not found in the host file or the DNS datase, there is nothing + // much we can do. embed the IP address + if (hp == 0 || hp->h_name == 0) + return -1; + + if (ACE::debug()) + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("(%P|%t) - ACE::get_fqdn, ") + ACE_TEXT ("canonical host name is %s\n"), + ACE_TEXT_CHAR_TO_TCHAR (hp->h_name))); + + // check if the canonical name is the FQDN + if (!ACE_OS::strchr(hp->h_name, '.')) + { + // list of address + char** p; + // list of aliases + char** q; + + // for every address and for every alias within the address, check and + // see if we can locate a FQDN + for (p = hp->h_addr_list; *p != 0; ++p) + { + for (q = hp->h_aliases; *q != 0; ++q) + { + if (ACE_OS::strchr(*q, '.')) + { + // we got an FQDN from an alias. use this + if (ACE_OS::strlen (*q) >= len) + // the hostname is too huge to fit into a + // buffer of size MAXHOSTNAMELEN + // should we check other aliases as well + // before bailing out prematurely? + // for right now, let's do it. this (short name) + // is atleast better than embedding the IP + // address in the profile + continue; + + if (ACE::debug ()) + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("(%P|%t) - ACE::get_fqdn, ") + ACE_TEXT ("found fqdn within alias as %s\n"), + ACE_TEXT_CHAR_TO_TCHAR(*q))); + ACE_OS::strcpy (hostname, *q); + + return 0; + } + } + } + } + + // The canonical name may be an FQDN when we reach here. + // Alternatively, the canonical name (a non FQDN) may be the best + // we can do. + if (ACE_OS::strlen (hp->h_name) >= len) + { + // The hostname is too large to fit into a buffer of size + // MAXHOSTNAMELEN. + return -2; + } + else + { + ACE_OS::strcpy (hostname, hp->h_name); + } + + return 0; +} + +#if defined (ACE_WIN32) + +static int +get_ip_interfaces_win32 (size_t &count, + ACE_INET_Addr *&addrs) +{ +# if defined (ACE_HAS_WINCE) + // moved the ACE_HAS_WINCE impl ahaid of ACE_HAS_WINSOCK2 because + // WINCE in fact has winsock2, but doesn't properly support the + // WSAIoctl for obtaining IPv6 address info. + PIP_ADAPTER_ADDRESSES AdapterAddresses = 0; + ULONG OutBufferLength = 0; + ULONG RetVal = 0; + unsigned char *octet_buffer = 0; + + RetVal = + GetAdaptersAddresses(AF_UNSPEC, + 0, + 0, + AdapterAddresses, + &OutBufferLength); + + if (RetVal != ERROR_BUFFER_OVERFLOW) + { + return -1; + } + + ACE_NEW_RETURN (octet_buffer, unsigned char[OutBufferLength],-1); + AdapterAddresses = (IP_ADAPTER_ADDRESSES *)octet_buffer; + + RetVal = + GetAdaptersAddresses(AF_UNSPEC, + 0, + 0, + AdapterAddresses, + &OutBufferLength); + + if (RetVal != NO_ERROR) + { + delete [] octet_buffer; + return -1; + } + + // If successful, output some information from the data we received + PIP_ADAPTER_ADDRESSES AdapterList = AdapterAddresses; + while (AdapterList) + { + if (AdapterList->OperStatus == IfOperStatusUp) + { + if (AdapterList->IfIndex != 0) + ++count; + if (AdapterList->Ipv6IfIndex != 0) + ++count; + } + AdapterList = AdapterList->Next; + } + + AdapterList = AdapterAddresses; + + ACE_NEW_RETURN (addrs, ACE_INET_Addr[count],-1); + count = 0; + for (AdapterList = AdapterAddresses; + AdapterList != 0; + AdapterList = AdapterList->Next) + { + if (AdapterList->OperStatus != IfOperStatusUp) + continue; + + IP_ADAPTER_UNICAST_ADDRESS *uni = 0; + if (AdapterList->IfIndex != 0) + for (uni = AdapterList->FirstUnicastAddress; + uni != 0; + uni = uni->Next) + { + SOCKET_ADDRESS *sa_addr = &uni->Address; + if (sa_addr->lpSockaddr->sa_family == AF_INET) + { + sockaddr_in *sin = (sockaddr_in*)sa_addr->lpSockaddr; + addrs[count].set(sin,sa_addr->iSockaddrLength); + ++count; + break; + } + } + if (AdapterList->Ipv6IfIndex != 0) + { + for (uni = AdapterList->FirstUnicastAddress; + uni != 0; + uni = uni->Next) + { + SOCKET_ADDRESS *sa_addr = &uni->Address; + if (sa_addr->lpSockaddr->sa_family == AF_INET6) + { + sockaddr_in *sin = (sockaddr_in*)sa_addr->lpSockaddr; + addrs[count].set(sin,sa_addr->iSockaddrLength); + ++count; + break; + } + } + } + } + + delete [] octet_buffer; + return 0; + +# elif defined (ACE_HAS_PHARLAP) + // PharLap ETS has its own kernel routines to rummage through the device + // configs and extract the interface info, but only for Pharlap RT. +# if !defined (ACE_HAS_PHARLAP_RT) + ACE_NOTSUP_RETURN (-1); +# endif /* ACE_HAS_PHARLAP_RT */ + + // Locate all of the IP devices in the system, saving a DEVHANDLE + // for each. Then allocate the ACE_INET_Addrs needed and fetch all + // the IP addresses. To locate the devices, try the available + // device name roots and increment the device number until the + // kernel says there are no more of that type. + const size_t ACE_MAX_ETS_DEVICES = 64; // Arbitrary, but should be enough. + DEVHANDLE ip_dev[ACE_MAX_ETS_DEVICES]; + EK_TCPIPCFG *devp; + size_t i, j; + ACE_TCHAR dev_name[16]; + + count = 0; + for (i = 0; count < ACE_MAX_ETS_DEVICES; i++, ++count) + { + // Ethernet. + ACE_OS::sprintf (dev_name, + "ether%d", + i); + ip_dev[count] = EtsTCPGetDeviceHandle (dev_name); + if (ip_dev[count] == 0) + break; + } + for (i = 0; count < ACE_MAX_ETS_DEVICES; i++, ++count) + { + // SLIP. + ACE_OS::sprintf (dev_name, + "sl%d", + i); + ip_dev[count] = EtsTCPGetDeviceHandle (dev_name); + if (ip_dev[count] == 0) + break; + } + for (i = 0; count < ACE_MAX_ETS_DEVICES; i++, ++count) + { + // PPP. + ACE_OS::sprintf (dev_name, + "ppp%d", + i); + ip_dev[count] = EtsTCPGetDeviceHandle (dev_name); + if (ip_dev[count] == 0) + break; + } + + if (count > 0) + ACE_NEW_RETURN (addrs, + ACE_INET_Addr[count], + -1); + else + addrs = 0; + + for (i = 0, j = 0; i < count; i++) + { + devp = EtsTCPGetDeviceCfg (ip_dev[i]); + if (devp != 0) + { + addrs[j].set (0, + devp->nwIPAddress, + 0); // Already in net order. + ++j; + } + // There's no call to close the DEVHANDLE. + } + + count = j; + if (count == 0 && addrs != 0) + { + delete [] addrs; + addrs = 0; + } + + return 0; + + +# else + // All non-CE, non-Pharlap Windows. Must support Winsock2. + + int i, n_interfaces, status; + + INTERFACE_INFO info[64]; + SOCKET sock; + + // Get an (overlapped) DGRAM socket to test with + sock = socket (AF_INET, SOCK_DGRAM, 0); + if (sock == INVALID_SOCKET) + return -1; + + DWORD bytes; + status = WSAIoctl(sock, + SIO_GET_INTERFACE_LIST, + 0, + 0, + info, + sizeof(info), + &bytes, + 0, + 0); + closesocket (sock); + if (status == SOCKET_ERROR) + return -1; + + n_interfaces = bytes / sizeof(INTERFACE_INFO); + + // SIO_GET_INTERFACE_LIST does not work for IPv6 + // Instead recent versions of Winsock2 add the new opcode + // SIO_ADDRESS_LIST_QUERY. + // If this is not available forget about IPv6 local interfaces:-/ + int n_v6_interfaces = 0; + +# if defined (ACE_HAS_IPV6) && defined (SIO_ADDRESS_LIST_QUERY) + + LPSOCKET_ADDRESS_LIST v6info; + char *buffer; + DWORD buflen = sizeof (SOCKET_ADDRESS_LIST) + (63 * sizeof (SOCKET_ADDRESS)); + ACE_NEW_RETURN (buffer, + char[buflen], + -1); + v6info = reinterpret_cast (buffer); + + // Get an (overlapped) DGRAM socket to test with. + // If it fails only return IPv4 interfaces. + sock = socket (AF_INET6, SOCK_DGRAM, IPPROTO_UDP); + if (sock != INVALID_SOCKET) + { + status = WSAIoctl(sock, + SIO_ADDRESS_LIST_QUERY, + 0, + 0, + v6info, + buflen, + &bytes, + 0, + 0); + closesocket (sock); + if (status != SOCKET_ERROR) + n_v6_interfaces = v6info->iAddressCount; + } +# endif /* ACE_HAS_IPV6 */ + + ACE_NEW_RETURN (addrs, + ACE_INET_Addr[n_interfaces + n_v6_interfaces], + -1); + + // Now go through the list and transfer the good ones to the list of + // because they're down or don't have an IP address. + for (count = 0, i = 0; i < n_interfaces; ++i) + { + LPINTERFACE_INFO lpii; + struct sockaddr_in *addrp = 0; + + lpii = &info[i]; + if (!(lpii->iiFlags & IFF_UP)) + continue; + + // We assume IPv4 addresses here + addrp = reinterpret_cast (&lpii->iiAddress.AddressIn); + if (addrp->sin_addr.s_addr == INADDR_ANY) + continue; + + // Set the address for the caller. + addrs[count].set(addrp, sizeof(sockaddr_in)); + ++count; + } + +# if defined (ACE_HAS_IPV6) && defined (SIO_ADDRESS_LIST_QUERY) + // Now go through the list and transfer the good ones to the list of + // because they're down or don't have an IP address. + for (i = 0; i < n_v6_interfaces; i++) + { + struct sockaddr_in6 *addr6p; + + if (v6info->Address[i].lpSockaddr->sa_family != AF_INET6) + continue; + + addr6p = reinterpret_cast (v6info->Address[i].lpSockaddr); + if (IN6_IS_ADDR_UNSPECIFIED(&addr6p->sin6_addr)) // IN6ADDR_ANY? + continue; + + // Set the address for the caller. + addrs[count].set(reinterpret_cast (addr6p), sizeof(sockaddr_in6)); + ++count; + } + + delete [] buffer; // Clean up +# endif /* ACE_HAS_IPV6 */ + + if (count == 0) + { + delete [] addrs; + addrs = 0; + } + + return 0; + +# endif /* ACE_HAS_WINCE */ +} +#elif defined (ACE_HAS_GETIFADDRS) +static int +get_ip_interfaces_getifaddrs (size_t &count, + ACE_INET_Addr *&addrs) +{ + // Take advantage of the BSD getifaddrs function that simplifies + // access to connected interfaces. + struct ifaddrs *ifap = 0; + struct ifaddrs *p_if = 0; + + if (::getifaddrs (&ifap) != 0) + return -1; + + // Count number of interfaces. + size_t num_ifs = 0; + for (p_if = ifap; p_if != 0; p_if = p_if->ifa_next) + ++num_ifs; + + // Now create and initialize output array. + ACE_NEW_RETURN (addrs, + ACE_INET_Addr[num_ifs], + -1); // caller must free + + // Pull the address out of each INET interface. Not every interface + // is for IP, so be careful to count properly. When setting the + // INET_Addr, note that the 3rd arg (0) says to leave the byte order + // (already in net byte order from the interface structure) as is. + count = 0; + + for (p_if = ifap; + p_if != 0; + p_if = p_if->ifa_next) + { + if (p_if->ifa_addr && + p_if->ifa_addr->sa_family == AF_INET) + { + struct sockaddr_in *addr = + reinterpret_cast (p_if->ifa_addr); + + // Sometimes the kernel returns 0.0.0.0 as the interface + // address, skip those... + if (addr->sin_addr.s_addr != INADDR_ANY) + { + addrs[count].set ((u_short) 0, + addr->sin_addr.s_addr, + 0); + ++count; + } + } +# if defined (ACE_HAS_IPV6) + else if (p_if->ifa_addr && + p_if->ifa_addr->sa_family == AF_INET6) + { + struct sockaddr_in6 *addr = + reinterpret_cast (p_if->ifa_addr); + + // Skip the ANY address + if (!IN6_IS_ADDR_UNSPECIFIED(&addr->sin6_addr)) + { + addrs[count].set(reinterpret_cast (addr), + sizeof(sockaddr_in6)); + ++count; + } + } +# endif /* ACE_HAS_IPV6 */ + } + + ::freeifaddrs (ifap); + + return 0; +} +#elif defined (__hpux) +static int +get_ip_interfaces_hpux (size_t &count, + ACE_INET_Addr *&addrs) +{ + size_t num_ifs = 0; + size_t num_ifs_found = 0; + + // Call specific routine as necessary. + ACE_HANDLE handle = ACE_OS::socket (PF_INET, SOCK_DGRAM, 0); + ACE_HANDLE handle_ipv6 = ACE_INVALID_HANDLE; + + if (handle == ACE_INVALID_HANDLE) + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("%p\n"), + ACE_TEXT ("ACE::get_ip_interfaces:open")), + -1); + + int result = 0; + int tmp_how_many = 0; + + result = ACE_OS::ioctl (handle, + SIOCGIFNUM, + (caddr_t) &tmp_how_many); + if (result != -1) + num_ifs = (size_t)tmp_how_many; + +# if defined (ACE_HAS_IPV6) + tmp_how_many = 0; + handle_ipv6 = ACE_OS::socket (PF_INET6, SOCK_DGRAM, 0); + result = ACE_OS::ioctl (handle_ipv6, + SIOCGLIFNUM, + (caddr_t) &tmp_how_many); + if (result != -1) + num_ifs += (size_t)tmp_how_many; +# endif + + if (num_ifs == 0) + { + ACE_OS::close (handle); + ACE_OS::close (handle_ipv6); + return -1; + } + + // ioctl likes to have an extra IFREQ structure to mark the end of + // what it returned, so increase the num_ifs by one. + ++num_ifs; + + //HPUX requires two passes, First for IPv4, then for IPv6 + + struct ifreq *ifs = 0; + ACE_NEW_RETURN (ifs, + struct ifreq[num_ifs], + -1); + ACE_OS::memset (ifs, 0, num_ifs * sizeof (struct ifreq)); + + ACE_Auto_Array_Ptr p_ifs (ifs); + + if (p_ifs.get() == 0) + { + ACE_OS::close (handle); + ACE_OS::close (handle_ipv6); + errno = ENOMEM; + return -1; + } + + struct ifconf ifcfg; + ACE_OS::memset (&ifcfg, 0, sizeof (struct ifconf)); + + ifcfg.ifc_req = p_ifs.get (); + ifcfg.ifc_len = num_ifs * sizeof (struct ifreq); + + if (ACE_OS::ioctl (handle, + SIOCGIFCONF, + (char *) &ifcfg) == -1) + { + ACE_OS::close (handle); + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("%p\n"), + ACE_TEXT ("ACE::get_ip_interfaces:") + ACE_TEXT ("ioctl - SIOCGIFCONF failed")), + -1); + } + + ACE_OS::close (handle); + + // Now create and initialize output array. + + ACE_NEW_RETURN (addrs, + ACE_INET_Addr[num_ifs], + -1); // caller must free + + struct ifreq *pcur = p_ifs.get (); + num_ifs_found = ifcfg.ifc_len / sizeof (struct ifreq); // get the number of returned ifs + + for (size_t i = 0; + i < num_ifs_found; + i++) + { + struct sockaddr_in *addr = + reinterpret_cast (&pcur->ifr_addr); + if (addr->sin_addr.s_addr != 0) + { + addrs[count].set ((u_short) 0, + addr->sin_addr.s_addr, + 0); + ++count; + } + ++pcur; + } + +# if defined (ACE_HAS_IPV6) + + if (handle_ipv6 != ACE_INVALID_HANDLE) + { + struct if_laddrreq *lifs = 0; + ACE_NEW_RETURN (lifs, + struct if_laddrreq[num_ifs], + -1); + ACE_OS::memset (lifs, 0, num_ifs * sizeof (struct if_laddrreq)); + + ACE_Auto_Array_Ptr p_lifs (lifs); + + if (p_lifs.get() == 0) + { + ACE_OS::close (handle); + ACE_OS::close (handle_ipv6); + errno = ENOMEM; + return -1; + } + + struct if_laddrconf lifcfg; + ACE_OS::memset (&lifcfg, 0, sizeof (struct if_laddrconf)); + + lifcfg.iflc_req = p_lifs.get (); + lifcfg.iflc_len = num_ifs * sizeof (struct if_laddrreq); + + if (ACE_OS::ioctl (handle_ipv6, + SIOCGLIFCONF, + (char *) &lifcfg) == -1) + { + ACE_OS::close (handle); + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("%p\n"), + ACE_TEXT ("ACE::get_ip_interfaces:") + ACE_TEXT ("ioctl - SIOCGLIFCONF failed")), + -1); + } + + ACE_OS::close (handle_ipv6); + + struct if_laddrreq *plcur = p_lifs.get (); + num_ifs_found = lifcfg.iflc_len / sizeof (struct if_laddrreq); + + for (size_t i = 0; + i < num_ifs_found; + i++) + { + struct sockaddr_in *addr = + reinterpret_cast (&plcur->iflr_addr); + if (!IN6_IS_ADDR_UNSPECIFIED(&reinterpret_cast(addr)->sin6_addr)) + { + addrs[count].set(addr, sizeof(struct sockaddr_in6)); + ++count; + } + ++plcur; + } + } +# endif /* ACE_HAS_IPV6 */ + return 0; +} +#elif defined (_AIX) +static int +get_ip_interfaces_aix (size_t &count, + ACE_INET_Addr *&addrs) +{ + ACE_HANDLE handle = ACE::get_handle(); + size_t num_ifs = 0; + struct ifconf ifc; + + if (handle == ACE_INVALID_HANDLE) + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("%p\n"), + ACE_TEXT ("ACE::get_ip_interfaces_aix:")), + -1); + + if (ACE_OS::ioctl (handle, + SIOCGSIZIFCONF, + (caddr_t)&ifc.ifc_len) == -1) + { + ACE_OS::close (handle); + ACE_ERROR_RETURN((LM_ERROR, + ACE_TEXT ("%p\n"), + ACE_TEXT ("get ifconf size")), + -1); + } + + ACE_NEW_RETURN (ifc.ifc_buf,char [ifc.ifc_len], -1); + + ACE_Auto_Array_Ptr safe_buf (ifc.ifc_buf); + ACE_OS::memset (safe_buf.get(), 0, ifc.ifc_len); + + if (ACE_OS::ioctl(handle, SIOCGIFCONF, (caddr_t)&ifc) == -1) + { + ACE_OS::close (handle); + ACE_ERROR_RETURN((LM_ERROR, + ACE_TEXT ("%p\n"), + ACE_TEXT ("get ifconf")), + -1); + } + + ACE_OS::close (handle); + + char *buf_start = safe_buf.get(); + char *buf_end = buf_start + ifc.ifc_len; + + num_ifs = 0; + for (char *ptr = buf_start; ptr < buf_end; ) + { + struct ifreq *req = reinterpret_cast(ptr); + ptr += IFNAMSIZ; + ptr += req->ifr_addr.sa_len; + if (req->ifr_addr.sa_family == AF_INET +# if defined (ACE_HAS_IPV6) + || req->ifr_addr.sa_family == AF_INET6 +# endif + ) + ++num_ifs; + } + ACE_NEW_RETURN (addrs,ACE_INET_Addr[num_ifs], -1); + + for (char * ptr = buf_start; ptr < buf_end; ) + { + struct ifreq *req = reinterpret_cast(ptr); + // skip the interface name + ptr += IFNAMSIZ; + if (req->ifr_addr.sa_family == AF_INET +# if defined (ACE_HAS_IPV6) + || req->ifr_addr.sa_family == AF_INET6 +# endif + ) + { + sockaddr_in *addr = (sockaddr_in*)&req->ifr_addr; + addrs[count++].set(addr, addr->sin_len); + } + ptr += req->ifr_addr.sa_len; + } + + return 0; +} + +#elif defined (ACE_VXWORKS) && (ACE_VXWORKS < 0x600) && !defined (ACE_HAS_VXWORKS551_MEDUSA) +int +get_ip_interfaces_vxworks_lt600 (size_t &count, + ACE_INET_Addr *&addrs) +{ + count = 0; + // Loop through each address structure + +# if defined (ACE_HAS_IPV6) && defined (TAILQ_ENTRY) +# define ia_next ia_link.tqe_next +# endif /* TAILQ_ENTRY */ + + for (struct in_ifaddr* ia = in_ifaddr; ia != 0; ia = ia->ia_next) + { + ++count; + } + + // Now create and initialize output array. + ACE_NEW_RETURN (addrs, + ACE_INET_Addr[count], + -1); // caller must free + count = 0; + for (struct in_ifaddr* ia = in_ifaddr; ia != 0; ia = ia->ia_next) + { + struct ifnet* ifp = ia->ia_ifa.ifa_ifp; + if (ifp != 0) + { + // Get the current interface name + char interface[64]; + ACE_OS::sprintf(interface, "%s%d", ifp->if_name, ifp->if_unit); + + // Get the address for the current interface + char address [INET_ADDR_LEN]; + STATUS status = ifAddrGet(interface, address); + + if (status == OK) + { + // Concatenate a ':' at the end. This is because in + // ACE_INET_Addr::string_to_addr, the ip_address is + // obtained using ':' as the delimiter. Since, using + // ifAddrGet(), we just get the IP address, I am adding + // a ":" to get with the general case. + ACE_OS::strcat (address, ":"); + addrs[count].set (address); + } + else + { + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("ACE::get_ip_interface failed\n") + ACE_TEXT ("Couldnt get the IP Address\n")), + -1); + } + ++count; + } + } + return 0; +} +#endif // ACE_WIN32 || ACE_HAS_GETIFADDRS || __hpux || _AIX || ACE_VXWORKS < 0x600 + + +// return an array of all configured IP interfaces on this host, count +// rc = 0 on success (count == number of interfaces else -1 caller is +// responsible for calling delete [] on parray + +int +ACE::get_ip_interfaces (size_t &count, + ACE_INET_Addr *&addrs) +{ + ACE_TRACE ("ACE::get_ip_interfaces"); + + count = 0; + addrs = 0; + +#if defined (ACE_WIN32) + return get_ip_interfaces_win32 (count, addrs); +#elif defined (ACE_HAS_GETIFADDRS) + return get_ip_interfaces_getifaddrs (count, addrs); +#elif defined (__hpux) + return get_ip_interfaces_hpux (count, addrs); +#elif defined (_AIX) + return get_ip_interfaces_aix (count, addrs); +#elif defined (ACE_VXWORKS) && (ACE_VXWORKS < 0x600) && !defined (ACE_HAS_VXWORKS551_MEDUSA) + return get_ip_interfaces_vxworks_lt600 (count, addrs); +#elif (defined (__unix) || defined (__unix__) || defined (__Lynx__) || defined (ACE_OPENVMS) || (defined (ACE_VXWORKS) && (ACE_VXWORKS == 0x650)) || defined (ACE_HAS_RTEMS)) && !defined (ACE_LACKS_NETWORKING) + // COMMON (SVR4 and BSD) UNIX CODE + + // Call specific routine as necessary. + ACE_HANDLE handle = ACE::get_handle(); + + if (handle == ACE_INVALID_HANDLE) + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("%p\n"), + ACE_TEXT ("ACE::get_ip_interfaces:open")), + -1); + + size_t num_ifs, num_ifs_found; + + if (ACE::count_interfaces (handle, num_ifs)) + { + ACE_OS::close (handle); + return -1; + } + + // ioctl likes to have an extra ifreq structure to mark the end of + // what it returned, so increase the num_ifs by one. + ++num_ifs; + + struct IFREQ *ifs = 0; + ACE_NEW_RETURN (ifs, + struct IFREQ[num_ifs], + -1); + ACE_OS::memset (ifs, 0, num_ifs * sizeof (struct IFREQ)); + + ACE_Auto_Array_Ptr p_ifs (ifs); + + if (p_ifs.get() == 0) + { + ACE_OS::close (handle); + errno = ENOMEM; + return -1; + } + + struct IFCONF ifcfg; + ACE_OS::memset (&ifcfg, 0, sizeof (struct IFCONF)); + +# ifdef SETFAMILY + ifcfg.IFC_FAMILY = AF_UNSPEC; // request all families be returned + ifcfg.IFC_FLAGS = 0; +# endif + + ifcfg.IFC_REQ = p_ifs.get (); + ifcfg.IFC_LEN = num_ifs * sizeof (struct IFREQ); + + if (ACE_OS::ioctl (handle, + SIOCGIFCONF_CMD, + (caddr_t) &ifcfg) == -1) + { + ACE_OS::close (handle); + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("%p\n"), + ACE_TEXT ("ACE::get_ip_interfaces:") + ACE_TEXT ("ioctl - SIOCGIFCONF failed")), + -1); + } + + ACE_OS::close (handle); + + // Now create and initialize output array. + + ACE_NEW_RETURN (addrs, + ACE_INET_Addr[num_ifs], + -1); // caller must free + + struct IFREQ *pcur = p_ifs.get (); + num_ifs_found = ifcfg.IFC_LEN / sizeof (struct IFREQ); // get the number of returned ifs + + // Pull the address out of each INET interface. Not every interface + // is for IP, so be careful to count properly. When setting the + // INET_Addr, note that the 3rd arg (0) says to leave the byte order + // (already in net byte order from the interface structure) as is. + count = 0; + + for (size_t i = 0; + i < num_ifs_found; + i++) + { + if (pcur->IFR_ADDR.SA_FAMILY == AF_INET +# if defined (ACE_HAS_IPV6) + || pcur->IFR_ADDR.SA_FAMILY == AF_INET6 +# endif + ) + + { +# if !defined(_UNICOS) + struct sockaddr_in *addr = + reinterpret_cast (&pcur->IFR_ADDR); + + // Sometimes the kernel returns 0.0.0.0 as an IPv4 interface + // address; skip those... + if (addr->sin_addr.s_addr != 0 +# if defined (ACE_HAS_IPV6) + || (addr->sin_family == AF_INET6 && + !IN6_IS_ADDR_UNSPECIFIED(&reinterpret_cast(addr)->sin6_addr)) +# endif + ) + { + int addrlen = static_cast (sizeof (struct sockaddr_in)); +# if defined (ACE_HAS_IPV6) + if (addr->sin_family == AF_INET6) + addrlen = static_cast (sizeof (struct sockaddr_in6)); +# endif + addrs[count].set (addr, addrlen); + ++count; + } +# else /* ! _UNICOS */ + // need to explicitly copy on the Cray, since the bitfields kinda + // screw things up here + struct sockaddr_in inAddr; + + inAddr.sin_len = pcur->IFR_ADDR.sa_len; + inAddr.sin_family = pcur->IFR_ADDR.sa_family; + memcpy((void *)&(inAddr.sin_addr), + (const void *)&(pcur->IFR_ADDR.sa_data[8]), + sizeof(struct in_addr)); + + if (inAddr.sin_addr.s_addr != 0) + { + addrs[count].set(&inAddr, sizeof(struct sockaddr_in)); + ++count; + } +# endif /* ! _UNICOS */ + } + +#if !defined (__QNX__) && !defined (__FreeBSD__) && !defined(__NetBSD__) && !defined (ACE_HAS_RTEMS) + ++pcur; +#else + if (pcur->ifr_addr.sa_len <= sizeof (struct sockaddr)) + { + ++pcur; + } + else + { + pcur = (struct ifreq *) + (pcur->ifr_addr.sa_len + (caddr_t) &pcur->ifr_addr); + } +#endif /* !defined (__QNX__) && !defined (__FreeBSD__) && !defined(__NetBSD__) */ + } + +# if defined (ACE_HAS_IPV6) + // Retrieve IPv6 local interfaces by scanning /proc/net/if_inet6 if + // it exists. If we cannot open it then ignore possible IPv6 + // interfaces, we did our best;-) + FILE* fp; + char addr_p[8][5]; + char s_ipaddr[64]; + int scopeid; + struct addrinfo hints, *res0; + int error; + + ACE_OS::memset (&hints, 0, sizeof (hints)); + hints.ai_flags = AI_NUMERICHOST; + hints.ai_family = AF_INET6; + + if ((fp = ACE_OS::fopen (ACE_TEXT ("/proc/net/if_inet6"), ACE_TEXT ("r"))) != 0) + { + while (fscanf (fp, + "%4s%4s%4s%4s%4s%4s%4s%4s %02x %*02x %*02x %*02x %*8s\n", + addr_p[0], addr_p[1], addr_p[2], addr_p[3], + addr_p[4], addr_p[5], addr_p[6], addr_p[7], &scopeid) != EOF) + { + // Format the address intoa proper IPv6 decimal address specification and + // resolve the resulting text using getaddrinfo(). + + const char* ip_fmt = "%s:%s:%s:%s:%s:%s:%s:%s%%%d"; + ACE_OS::sprintf (s_ipaddr, + ip_fmt, + addr_p[0], addr_p[1], addr_p[2], addr_p[3], + addr_p[4], addr_p[5], addr_p[6], addr_p[7], scopeid); + + error = getaddrinfo (s_ipaddr, 0, &hints, &res0); + if (error) + continue; + + if (res0->ai_family == AF_INET6 && + !IN6_IS_ADDR_UNSPECIFIED (&reinterpret_cast (res0->ai_addr)->sin6_addr)) + { + addrs[count].set(reinterpret_cast (res0->ai_addr), res0->ai_addrlen); + ++count; + } + freeaddrinfo (res0); + + } + ACE_OS::fclose (fp); + } +# endif /* ACE_HAS_IPV6 */ + + return 0; +#else + ACE_UNUSED_ARG (count); + ACE_UNUSED_ARG (addrs); + ACE_NOTSUP_RETURN (-1); // no implementation +#endif /* ACE_WIN32 */ +} + +// Helper routine for get_ip_interfaces, differs by UNIX platform so +// put into own subroutine. perform some ioctls to retrieve ifconf +// list of ifreq structs. + +int +ACE::count_interfaces (ACE_HANDLE handle, + size_t &how_many) +{ +#if defined (ACE_WIN32) || defined (ACE_HAS_GETIFADDRS) || defined (__hpux) || defined (_AIX) || (defined (ACE_VXWORKS) && (ACE_VXWORKS < 0x600)) + // none of these platforms make use of count_interfaces + ACE_UNUSED_ARG (handle); + ACE_UNUSED_ARG (how_many); + ACE_NOTSUP_RETURN (-1); // no implementation + +#elif defined (SIOCGIFNUM) +# if defined (SIOCGLIFNUM) + int cmd = SIOCGLIFNUM; + struct lifnum if_num = {AF_UNSPEC,0,0}; +# else + int cmd = SIOCGIFNUM; + int if_num = 0; +# endif /* SIOCGLIFNUM */ + if (ACE_OS::ioctl (handle, cmd, (caddr_t)&if_num) == -1) + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("%p\n"), + ACE_TEXT ("ACE::count_interfaces:") + ACE_TEXT ("ioctl - SIOCGLIFNUM failed")), + -1); +# if defined (SIOCGLIFNUM) + how_many = if_num.lifn_count; +# else + how_many = if_num; +# endif /* SIOCGLIFNUM */ +return 0; + +#elif (defined (__unix) || defined (__unix__) || defined (__Lynx__) || defined (ACE_OPENVMS) || defined (ACE_HAS_RTEMS)) && !defined (ACE_LACKS_NETWORKING) + // Note: DEC CXX doesn't define "unix". BSD compatible OS: HP UX, + // AIX, SunOS 4.x perform some ioctls to retrieve ifconf list of + // ifreq structs no SIOCGIFNUM on SunOS 4.x, so use guess and scan + // algorithm + + // Probably hard to put this many ifs in a unix box.. + const int MAX_IF = 50; + + // HACK - set to an unreasonable number + int num_ifs = MAX_IF; + + struct ifconf ifcfg; + size_t ifreq_size = num_ifs * sizeof (struct ifreq); + struct ifreq *p_ifs = + (struct ifreq *) ACE_OS::malloc (ifreq_size); + + if (!p_ifs) + { + errno = ENOMEM; + return -1; + } + + ACE_OS::memset (p_ifs, 0, ifreq_size); + ACE_OS::memset (&ifcfg, 0, sizeof (struct ifconf)); + + ifcfg.ifc_req = p_ifs; + ifcfg.ifc_len = ifreq_size; + + if (ACE_OS::ioctl (handle, + SIOCGIFCONF_CMD, + (caddr_t) &ifcfg) == -1) + { + ACE_OS::free (ifcfg.ifc_req); + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("%p\n"), + ACE_TEXT ("ACE::count_interfaces:") + ACE_TEXT ("ioctl - SIOCGIFCONF failed")), + -1); + } + + int if_count = 0, i; + + // get if address out of ifreq buffers. ioctl puts a blank-named + // interface to mark the end of the returned interfaces. + for (i = 0; + i < num_ifs; + i++) + { + /* In OpenBSD, the length of the list is returned. */ + ifcfg.ifc_len -= sizeof (struct ifreq); + if (ifcfg.ifc_len < 0) + break; + + ++if_count; +#if !defined (__QNX__) && !defined (__FreeBSD__) && !defined(__NetBSD__) && !defined (ACE_HAS_RTEMS) + ++p_ifs; +#else + if (p_ifs->ifr_addr.sa_len <= sizeof (struct sockaddr)) + { + ++p_ifs; + } + else + { + p_ifs = (struct ifreq *) + (p_ifs->ifr_addr.sa_len + (caddr_t) &p_ifs->ifr_addr); + } +#endif /* !defined (__QNX__) && !defined (__FreeBSD__) && !defined(__NetBSD__) */ + } + + ACE_OS::free (ifcfg.ifc_req); + +# if defined (ACE_HAS_IPV6) + FILE* fp = 0; + + if ((fp = ACE_OS::fopen (ACE_TEXT ("/proc/net/if_inet6"), ACE_TEXT ("r"))) != 0) + { + // Scan the lines according to the expected format but don't really read any input + while (fscanf (fp, "%*32s %*02x %*02x %*02x %*02x %*8s\n") != EOF) + { + ++if_count; + } + ACE_OS::fclose (fp); + } +# endif /* ACE_HAS_IPV6 */ + + how_many = if_count; + return 0; +#else + ACE_UNUSED_ARG (handle); + ACE_UNUSED_ARG (how_many); + ACE_NOTSUP_RETURN (-1); // no implementation +#endif /* sparc && SIOCGIFNUM */ +} + +// Routine to return a handle from which ioctl() requests can be made. + +ACE_HANDLE +ACE::get_handle (void) +{ + // Solaris 2.x + ACE_HANDLE handle = ACE_INVALID_HANDLE; +#if defined (sparc) + handle = ACE_OS::open ("/dev/udp", O_RDONLY); +#elif defined (__unix) || defined (__unix__) || defined (__Lynx__) || defined (_AIX) || defined (__hpux) || (defined (ACE_VXWORKS) && (ACE_VXWORKS >= 0x600)) || defined (ACE_OPENVMS) || defined (ACE_HAS_RTEMS) + // Note: DEC CXX doesn't define "unix" BSD compatible OS: HP UX, + // AIX, SunOS 4.x + + handle = ACE_OS::socket (PF_INET, SOCK_DGRAM, 0); +#endif /* sparc */ + return handle; +} + + +#if defined (ACE_HAS_IPV6) +static int +ip_check (int &ipvn_enabled, int pf) +{ + // We only get to this point if ipvn_enabled was -1 in the caller. + // Perform Double-Checked Locking Optimization. + ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon, + *ACE_Static_Object_Lock::instance (), 0)); + + if (ipvn_enabled == -1) + { + // Determine if the kernel has IPv6 support by attempting to + // create a PF_INET socket and see if it fails. + ACE_HANDLE const s = ACE_OS::socket (pf, SOCK_DGRAM, 0); + if (s == ACE_INVALID_HANDLE) + { + ipvn_enabled = 0; + } + else + { + ipvn_enabled = 1; + ACE_OS::closesocket (s); + } + } + return ipvn_enabled; +} +#endif /* ACE_HAS_IPV6 */ + +bool +ACE::ipv4_enabled (void) +{ +#if defined (ACE_HAS_IPV6) + return static_cast (ace_ipv4_enabled == -1 ? + ::ip_check (ace_ipv4_enabled, PF_INET) : + ace_ipv4_enabled); +#else + // Assume it's always enabled since ACE requires some version of + // TCP/IP to exist. + return true; +#endif /* ACE_HAS_IPV6*/ +} + +int +ACE::ipv6_enabled (void) +{ +#if defined (ACE_HAS_IPV6) + return ace_ipv6_enabled == -1 ? + ::ip_check (ace_ipv6_enabled, PF_INET6) : + ace_ipv6_enabled; +#else /* ACE_HAS_IPV6 */ + return 0; +#endif /* !ACE_HAS_IPV6 */ +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Sock_Connect.h b/dep/ACE_wrappers/ace/Sock_Connect.h new file mode 100644 index 00000000000..d6a72c718b8 --- /dev/null +++ b/dep/ACE_wrappers/ace/Sock_Connect.h @@ -0,0 +1,107 @@ +// -*- C++ -*- + +//========================================================================== +/** + * @file Sock_Connect.h + * + * $Id: Sock_Connect.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Priyanka Gontla + * @author Based on code that existed formerly in ACE.h. + */ +//========================================================================== + +#ifndef ACE_SOCK_CONNECT_H +#define ACE_SOCK_CONNECT_H + +#include /**/ "ace/pre.h" + +#include /**/ "ace/ACE_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/Basic_Types.h" +#include "ace/os_include/netinet/os_in.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +// Forward Declarations +class ACE_INET_Addr; + +namespace ACE +{ + // = Socket connection establishment calls. + + /// Bind a new unused port to @a handle. + extern ACE_Export int bind_port (ACE_HANDLE handle, + ACE_UINT32 ip_addr = INADDR_ANY, + int address_family = AF_UNSPEC); + + /** + * Get our broadcast address based on our @a host_addr. If + * @a hostname is non-0 we'll use it to determine our IP address. If + * @a handle is not ACE_INVALID_HANDLE then we'll use this to + * determine our broadcast address, otherwise we'll have to create a + * socket internally (and free it). Returns -1 on failure and 0 on + * success. + */ + extern ACE_Export int get_bcast_addr ( + ACE_UINT32 &bcast_addr, + const ACE_TCHAR *hostname = 0, + ACE_UINT32 host_addr = 0, + ACE_HANDLE handle = ACE_INVALID_HANDLE); + + /// Get fully qualified host/domain name. + extern ACE_Export int get_fqdn (ACE_INET_Addr const & addr, + char hostname[], + size_t len); + + /** + * Return count and array of all configured IP interfaces on this + * host, rc = 0 on success (count == number of interfaces else -1). + * Caller is responsible for calling delete [] on @a addr_array. + */ + extern ACE_Export int get_ip_interfaces (size_t &count, + ACE_INET_Addr *&addr_array); + + /** + * Helper routine for get_ip_interfaces, differs by UNIX platform so + * put into own subroutine. perform some ioctls to retrieve ifconf + * list of ifreq structs. + */ + extern ACE_Export int count_interfaces (ACE_HANDLE handle, + size_t &how_many); + + /// Routine to return a handle from which @c ioctl requests can be + /// made. Caller must close the handle. + extern ACE_Export ACE_HANDLE get_handle (void); + + /// Returns @c true if IPv4 is enabled on the current host; @c false + /// if not. + /** + * This is an execution-time check. If ACE has not been compiled + * with @c ACE_HAS_IPV6, it always returns @c true. This function + * tries to create a @c PF_INET socket, returning @c true if it + * succeeds, and @c false if it fails. Caches the result so it only + gets checked once. + */ + extern ACE_Export bool ipv4_enabled (void); + + /** + * Returns 1 if IPv6 is enabled on the current host; 0 if not. + * This is an execution-time check. If ACE has not been compiled + * with ACE_HAS_IPV6, it always returns 0. If ACE_HAS_IPV6 is + * enabled, this function tries to create a PF_INET6 socket, + * returning 1 if it succeeds, and 0 if it fails. Caches the result + * so it only gets checked once. + */ + extern ACE_Export int ipv6_enabled (void); +} + +ACE_END_VERSIONED_NAMESPACE_DECL + +#include /**/ "ace/post.h" + +#endif /* ACE_SOCK_CONNECT_H */ diff --git a/dep/ACE_wrappers/ace/Stack_Trace.cpp b/dep/ACE_wrappers/ace/Stack_Trace.cpp new file mode 100644 index 00000000000..082cca8a88a --- /dev/null +++ b/dep/ACE_wrappers/ace/Stack_Trace.cpp @@ -0,0 +1,696 @@ +//============================================================================= +/** + * @file Stack_Trace.cpp + * + * $Id: Stack_Trace.cpp 82575 2008-08-08 20:36:10Z mitza $ + * + * @brief Encapsulate string representation of stack trace. + * + * Portions of the platform-specific code have been based on + * code found in various places on the internet e.g., google groups, + * VxWorks FAQ, etc., and adapted for use here. + */ +//============================================================================= + +#include "ace/Stack_Trace.h" +#include "ace/Min_Max.h" +#include "ace/OS_NS_string.h" +#include "ace/OS_NS_stdio.h" + +ACE_RCSID (ace, Stack_Trace, "$Id: Stack_Trace.cpp 82575 2008-08-08 20:36:10Z mitza $") + +/* + This is ugly, simply because it's very platform-specific. +*/ + +const char ACE_Stack_Trace::UNSUPPORTED[] = ""; +const char ACE_Stack_Trace::UNABLE_TO_GET_TRACE[] = ""; + +ACE_Stack_Trace::ACE_Stack_Trace (ssize_t starting_frame_offset, size_t num_frames) + : buflen_(0) +{ + // cannot initialize arrays, so we must assign. + this->buf_[0] = '\0'; + this->generate_trace (starting_frame_offset, num_frames); +} + +const char* +ACE_Stack_Trace::c_str () const +{ + return &this->buf_[0]; +} + +static inline size_t +determine_starting_frame (ssize_t initial_frame, ssize_t offset) +{ + return ACE_MAX( initial_frame + offset, static_cast(0)); +} + +#if (defined(__GLIBC__) || defined(ACE_HAS_EXECINFO_H)) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3)) +// This is the code for glibc +# include + +void +ACE_Stack_Trace::generate_trace (ssize_t starting_frame_offset, size_t num_frames) +{ + const size_t MAX_FRAMES = 128; + const ssize_t INITIAL_FRAME = 3; + + void* stack[MAX_FRAMES]; + size_t stack_size = 0; + char** stack_syms; + + if (num_frames == 0) + num_frames = MAX_FRAMES; + + size_t starting_frame = + determine_starting_frame (INITIAL_FRAME, starting_frame_offset); + + stack_size = ::backtrace (&stack[0], sizeof(stack)/sizeof(stack[0])); + if (stack_size != 0) + { + stack_syms = ::backtrace_symbols (stack, stack_size); + + for (size_t i = starting_frame; + i < stack_size && num_frames > 0; + i++, num_frames--) + { + // this could be more efficient by remembering where we left off in buf_ + char *symp = &stack_syms[i][0]; + while (this->buflen_ < SYMBUFSIZ && *symp != '\0') + { + this->buf_[this->buflen_++] = *symp++; + } + this->buf_[this->buflen_++] = '\n'; // put a newline at the end + } + this->buf_[this->buflen_+1] = '\0'; // zero terminate the string + + ::free (stack_syms); + } + else + { + ACE_OS::strcpy (&this->buf_[0], UNABLE_TO_GET_TRACE); + } +} +#elif defined(VXWORKS) && !defined(__RTP__) +# include +# include // hopefully this is enough to get all the necessary #defines. + +struct ACE_Stack_Trace_stackstate +{ + ACE_Stack_Trace_stackstate (char* b, size_t& bl, size_t nf, size_t sf) + : buf(b), buflen(bl), num_frames(nf), starting_frame(sf) + { } + + char* buf; + size_t& buflen; + size_t num_frames; + size_t starting_frame; +}; + +//@TODO: Replace with a TSS-based pointer to avoid problems in multithreaded environs, +// or use a mutex to serialize access to this. +static ACE_Stack_Trace_stackstate* ACE_Stack_Trace_stateptr = 0; + +static void +ACE_Stack_Trace_Add_Frame_To_Buf (INSTR *caller, + unsigned int func, + unsigned int nargs, + unsigned int *args) +{ + if (ACE_Stack_Trace_stateptr == 0) + return; + + ACE_Stack_Trace_stackstate *stackstate = ACE_Stack_Trace_stateptr; + + // Decrement the num_frames and starting_frame elements, + // then see if we're ready to start or ready to finish. + --stackstate->num_frames; + --stackstate->starting_frame; + + if (stackstate->num_frames == 0 || stackstate->starting_frame > 0) + return; + + // These are references so that the structure gets updated + // in the code below. + char*& buf = stackstate->buf; + unsigned int& len = stackstate->buflen; + + // At some point try using symFindByValue() to lookup func (and caller?) + // to print out symbols rather than simply addresses. + + // VxWorks can pass -1 for "nargs" if there was an error + if (nargs == static_cast (-1)) nargs = 0; + + len += ACE_OS::sprintf (&buf[len], "%#10x: %#10x (", (int)caller, func); + for (unsigned int i = 0; i < nargs; ++i) + { + if (i != 0) + len += ACE_OS::sprintf (&buf[len], ", "); + len += ACE_OS::sprintf(&buf [len], "%#x", args [i]); + } + + len += ACE_OS::sprintf(&buf[len], ")\n"); +} + +void +ACE_Stack_Trace::generate_trace (ssize_t starting_frame_offset, + size_t num_frames) +{ + const size_t MAX_FRAMES = 128; + const ssize_t INITIAL_FRAME = 3; + + if (num_frames == 0) + num_frames = MAX_FRAMES; + + size_t starting_frame = + determine_starting_frame (INITIAL_FRAME, starting_frame_offset); + + ACE_Stack_Trace_stackstate state (&this->buf_[0], this->buflen_, + num_frames, starting_frame); + + REG_SET regs; + + taskRegsGet ((int)taskIdSelf(), ®s); + // Maybe we should take a lock here to guard stateptr? + ACE_Stack_Trace_stateptr = &state; + trcStack (®s, (FUNCPTR)ACE_Stack_Trace_Add_Frame_To_Buf, taskIdSelf ()); +} + + +#elif defined(VXWORKS) && defined(__RTP__) +# include +# include +# include + +// See memEdrLib.c in VxWorks RTP sources for an example of stack tracing. + +static STATUS ace_vx_rtp_pc_validate (INSTR *pc, TRC_OS_CTX *pOsCtx) +{ + return ALIGNED (pc, sizeof (INSTR)) ? OK : ERROR; +} + +void +ACE_Stack_Trace::generate_trace (ssize_t starting_frame_offset, + size_t num_frames) +{ + const size_t MAX_FRAMES = 128; + const ssize_t INITIAL_FRAME = 2; + + if (num_frames == 0) num_frames = MAX_FRAMES; + size_t starting_frame = + determine_starting_frame (INITIAL_FRAME, starting_frame_offset); + + jmp_buf regs; + setjmp (regs); + + TASK_DESC desc; + if (taskInfoGet (taskIdSelf (), &desc) == ERROR) return; + + TRC_OS_CTX osCtx; + osCtx.stackBase = desc.td_pStackBase; + osCtx.stackEnd = desc.td_pStackEnd; + osCtx.pcValidateRtn = reinterpret_cast (ace_vx_rtp_pc_validate); + + char *fp = _WRS_FRAMEP_FROM_JMP_BUF (regs); + INSTR *pc = _WRS_RET_PC_FROM_JMP_BUF (regs); + + for (size_t depth = 0; depth < num_frames + starting_frame; ++depth) + { + char *prevFp; + INSTR *prevPc; + INSTR *prevFn; + + if (trcLibFuncs.lvlInfoGet (fp, pc, &osCtx, &prevFp, &prevPc, &prevFn) + == ERROR) + { + ACE_OS::strcpy (this->buf_, UNABLE_TO_GET_TRACE); + return; + } + + if(prevPc == 0 || prevFp == 0) break; + + if (depth >= starting_frame) + { + //Hopefully a future version of VxWorks will have a system call + //for an RTP to query its own symbols, but this is not possible now. + //An enhancement request has been filed under WIND00123307. + const char *fnName = "(no symbols)"; + + static const int N_ARGS = 12; + int buf[N_ARGS]; + int *pArgs = 0; + int numArgs = + trcLibFuncs.lvlArgsGet (prevPc, prevFn, prevFp, + buf, N_ARGS, &pArgs); + + // VxWorks can return -1 for "numArgs" if there was an error + if (numArgs == -1) numArgs = 0; + + size_t len = ACE_OS::strlen (this->buf_); + size_t space = SYMBUFSIZ - len - 1; + char *cursor = this->buf_ + len; + size_t written = ACE_OS::snprintf (cursor, space, "%x %s", + prevFn, fnName); + cursor += written; + space -= written; + + if (space < 1) return; //no point in logging when we're out of buffer + for (int arg = 0; numArgs != -1 && pArgs && arg < numArgs; ++arg) + { + if (arg == 0) *cursor++ = '(', --space; + written = ACE_OS::snprintf (cursor, space, + (arg < numArgs - 1) ? "%x, " : "%x", + pArgs[arg]); + cursor += written; + space -= written; + if (space && arg == numArgs - 1) *cursor++ = ')', --space; + } + if (space) *cursor++ = '\n', --space; + *cursor++ = 0; //we saved space for the null terminator + } + + fp = prevFp; + pc = prevPc; + } +} + +#elif defined(sun) +/* + * walks up call stack, printing library:routine+offset for each routine + */ + +# include +# include +# include +# include +# include +# define ACE_STACK_TRACE_BIAS 0 + +# if defined(sparc) || defined(__sparc) +# define ACE_STACK_TRACE_FLUSHWIN() asm("ta 3"); +# define ACE_STACK_TRACE_FRAME_PTR_INDEX 1 +# define ACE_STACK_TRACE_SKIP_FRAMES 0 +# if defined(__sparcv9) +# undef ACE_STACK_TRACE_BIAS +# define ACE_STACK_TRACE_BIAS 2047 +# endif +# endif + +# if defined(i386) || defined(__i386) +# define ACE_STACK_TRACE_FLUSHWIN() +# define ACE_STACK_TRACE_FRAME_PTR_INDEX 3 +# define ACE_STACK_TRACE_SKIP_FRAMES 0 +# endif + +# if defined(__amd64) || defined(__x86_64) +# define ACE_STACK_TRACE_FLUSHWIN() +# define ACE_STACK_TRACE_FRAME_PTR_INDEX 5 +# define ACE_STACK_TRACE_SKIP_FRAMES 0 +# endif + +# if defined(ppc) || defined(__ppc) +# define ACE_STACK_TRACE_FLUSHWIN() +# define ACE_STACK_TRACE_FRAME_PTR_INDEX 0 +# define ACE_STACK_TRACE_SKIP_FRAMES 2 +# endif + +static frame* +cs_frame_adjust(frame* sp) +{ + unsigned char* sp_byte = (unsigned char*)sp; + sp_byte += ACE_STACK_TRACE_BIAS; + return (frame*) sp_byte; +} + +/* + this function walks up call stack, calling user-supplied + function once for each stack frame, passing the pc and the user-supplied + usrarg as the argument. + */ + +static int +cs_operate(int (*func)(void *, void *), void * usrarg, + size_t starting_frame, size_t num_frames_arg) +{ + ACE_STACK_TRACE_FLUSHWIN(); + + jmp_buf env; + setjmp(env); + frame* sp = cs_frame_adjust((frame*) env[ACE_STACK_TRACE_FRAME_PTR_INDEX]); + + // make a copy of num_frames_arg to eliminate the following warning on some + // solaris platforms: + // Stack_Trace.cpp:318: warning: argument `size_t num_frames' might be clobbered by `longjmp' or `vfork' + size_t num_frames = num_frames_arg; + + // I would like to use ACE_MAX below rather than ?:, but + // I get linker relocation errors such as the following when + // I use it: + // ld: fatal: relocation error: file: .shobj/Stack_Trace.o section: + // .rela.debug_line symbol: : relocation against a discarded symbol, + // symbol is part of discarded section: + // .text%const __type_0&ace_max(const __type_0&,const __type_0&) + // + const size_t starting_skip = starting_frame - 1; +#if ACE_STACK_TRACE_SKIP_FRAMES == 0 + size_t skip_frames = starting_skip; +#else + size_t skip_frames = + ACE_STACK_TRACE_SKIP_FRAMES > starting_skip ? + ACE_STACK_TRACE_SKIP_FRAMES : starting_skip; +#endif /* ACE_STACK_TRACE_SKIP_FRAMES == 0 */ + size_t i; + for (i = 0; i < skip_frames && sp; ++i) + { + sp = cs_frame_adjust((frame*) sp->fr_savfp); + } + + i = 0; + + while ( sp + && sp->fr_savpc + && ++i + && --num_frames + && (*func)((void*)sp->fr_savpc, usrarg)) + { + sp = cs_frame_adjust((frame*) sp->fr_savfp); + } + + return(i); +} + +static int +add_frame_to_buf (void* pc, void* usrarg) +{ + char* buf = (char*)usrarg; + Dl_info info; + const char* func = "??"; + const char* lib = "??"; + + if(dladdr(pc, & info) != 0) + { + lib = (const char *) info.dli_fname; + func = (const char *) info.dli_sname; + } + + (void) ACE_OS::snprintf(buf, + ACE_Stack_Trace::SYMBUFSIZ, + "%s%s:%s+0x%x\n", + buf, + lib, + func, + //@@ Should the arithmetic on the following + //line be done with two void* ptrs? The result + //would be ptrdiff_t, and what is the correct + //sprintf() conversion character for that? + (size_t)pc - (size_t)info.dli_saddr); + + return(1); +} + +void +ACE_Stack_Trace::generate_trace (ssize_t starting_frame_offset, + size_t num_frames) +{ + const size_t MAX_FRAMES = 128; + const ssize_t INITIAL_FRAME = 3; + + if (num_frames == 0) + num_frames = MAX_FRAMES; + + size_t starting_frame = + determine_starting_frame (INITIAL_FRAME, starting_frame_offset); + + cs_operate (&add_frame_to_buf, &this->buf_[0], starting_frame, num_frames); +} + +#elif defined(ACE_WIN64) && (_WIN32_WINNT <= _WIN32_WINNT_WIN2K) +# if defined(_MSC_VER) +# define STRING2(X) #X +# define STRING(X) STRING2(X) +# pragma message (__FILE__ "(" STRING(__LINE__) ") : warning: stack traces"\ + " can't be generated on 64-bit Windows when _WIN32_WINNT is less than "\ + "0x501.") +# undef STRING +# undef STRING2 +# endif /*_MSC_VER*/ +void +ACE_Stack_Trace::generate_trace (ssize_t, size_t) +{ + ACE_OS::strcpy (&this->buf_[0], ""); +} + +#elif defined(ACE_WIN32) && !defined(ACE_HAS_WINCE) && !defined (__MINGW32__) \ + && !defined(__BORLANDC__) +# include +# include + +# define MAXTEXT 5000 +# define SYMSIZE 100 + +//@TODO: Test with WCHAR +//@TODO: Need a common CriticalSection since dbghelp is not thread-safe + +typedef struct _dbghelp_functions +{ + HMODULE hMod; //our handle to dbghelp.dll + + //these already have typedefs in DbgHelp.h + DWORD64 (WINAPI *SymGetModuleBase64) (HANDLE hProc, DWORD64 dwAddr); + PVOID (WINAPI *SymFunctionTableAccess64) (HANDLE hProc, DWORD64 AddrBase); + + typedef BOOL (WINAPI *SymFromAddr_t) + (HANDLE hProc, DWORD64 Addr, PDWORD64 Disp, PSYMBOL_INFO Symbol); + SymFromAddr_t SymFromAddr; + + typedef BOOL (WINAPI *SymGetLineFromAddr64_t) (HANDLE hProc, DWORD64 dwAddr, + PDWORD pdwDisplacement, + PIMAGEHLP_LINE64 Line); + SymGetLineFromAddr64_t SymGetLineFromAddr64; + + typedef DWORD (WINAPI *SymSetOptions_t) (DWORD SymOptions); + SymSetOptions_t SymSetOptions; + + typedef DWORD (WINAPI *SymGetOptions_t) (); + SymGetOptions_t SymGetOptions; + + typedef BOOL (WINAPI *SymInitialize_t) (HANDLE hProc, PCTSTR UserSearchPath, + BOOL invasive); + SymInitialize_t SymInitialize; + + typedef BOOL + (WINAPI *StackWalk64_t) (DWORD MachineType, HANDLE hPRoc, HANDLE hThr, + LPSTACKFRAME64 StackFrame, PVOID ContextRecord, + PREAD_PROCESS_MEMORY_ROUTINE64 RMRoutine, + PFUNCTION_TABLE_ACCESS_ROUTINE64 FTARoutine, + PGET_MODULE_BASE_ROUTINE64 GMBRoutine, + PTRANSLATE_ADDRESS_ROUTINE64 TranslateAddress); + StackWalk64_t StackWalk64; + + typedef BOOL (WINAPI *SymCleanup_t) (HANDLE hProc); + SymCleanup_t SymCleanup; +} dbghelp_functions; + + +# pragma warning (push) +# pragma warning (disable:4706) +static bool load_dbghelp_library_if_needed (dbghelp_functions *pDbg) +{ + //@TODO: See codeproject's StackWalker.cpp for the list of locations to + //search so we get the "enhanced" dbghelp if the user has it but it is not + //first on the path. + if (!(pDbg->hMod = ACE_TEXT_LoadLibrary (ACE_TEXT ("Dbghelp")))) + return false; + + //@TODO: Cache this so we don't have to re-link every time. When to unload? + +# define LINK(TYPE, NAME) (pDbg->NAME = \ + (TYPE) GetProcAddress (pDbg->hMod, #NAME)) +# define LINK_T(NAME) LINK (dbghelp_functions::NAME##_t, NAME) + return LINK (PGET_MODULE_BASE_ROUTINE64, SymGetModuleBase64) + && LINK (PFUNCTION_TABLE_ACCESS_ROUTINE64, SymFunctionTableAccess64) + && LINK_T (SymFromAddr) && LINK_T (SymGetLineFromAddr64) + && LINK_T (SymSetOptions)&& LINK_T (SymGetOptions) + && LINK_T (SymInitialize) && LINK_T (StackWalk64) && LINK_T (SymCleanup); +# undef LINK +# undef LINK_T +} +# pragma warning (pop) + + +struct frame_state { + STACKFRAME64 sf; + PSYMBOL_INFO pSym; + dbghelp_functions *pDbg; +}; + +static int +add_frame_to_buf (struct frame_state const *fs, void *usrarg) +{ + if (fs == 0 || usrarg == 0) + return -1; + + char *buf = static_cast (usrarg); + + DWORD64 disp; + DWORD64 dwModBase = fs->pDbg->SymGetModuleBase64 (GetCurrentProcess (), + fs->sf.AddrPC.Offset); + if (fs->pDbg->SymFromAddr (GetCurrentProcess (), + fs->sf.AddrPC.Offset, &disp, fs->pSym)) + { + IMAGEHLP_LINE64 line = {sizeof (IMAGEHLP_LINE64)}; + DWORD lineDisp; + if (fs->pDbg->SymGetLineFromAddr64 (GetCurrentProcess (), + fs->sf.AddrPC.Offset, + &lineDisp, &line)) + { + (void) ACE_OS::snprintf (buf, ACE_Stack_Trace::SYMBUFSIZ, + "%s%s() %s: %d + 0x%x\n", + buf, fs->pSym->Name, line.FileName, + line.LineNumber, lineDisp); + } + else + { + (void) ACE_OS::snprintf (buf, ACE_Stack_Trace::SYMBUFSIZ, + "%s%s()+0x%x [0x%x]\n", + buf, fs->pSym->Name, disp, + fs->sf.AddrPC.Offset - dwModBase); + } + } + else + { + (void) ACE_OS::snprintf (buf, ACE_Stack_Trace::SYMBUFSIZ, + "%s[0x%x]\n", + buf, fs->sf.AddrPC.Offset - dwModBase); + } + return 0; +} + +static void emptyStack () { } + +static int +cs_operate(int (*func)(struct frame_state const *, void *), void *usrarg, + size_t starting_frame, size_t num_frames) +{ + dbghelp_functions dbg; + if (!load_dbghelp_library_if_needed (&dbg)) + { + ACE_OS::strcpy (static_cast (usrarg), + ""); + if (dbg.hMod) FreeLibrary (dbg.hMod); + return 1; + } + + frame_state fs; + ZeroMemory (&fs.sf, sizeof (fs.sf)); + fs.pDbg = &dbg; + emptyStack (); //Not sure what this should do, Chad? + + CONTEXT c; + ZeroMemory (&c, sizeof (CONTEXT)); + c.ContextFlags = CONTEXT_FULL; + +# if defined (_M_IX86) + DWORD machine = IMAGE_FILE_MACHINE_I386; + __asm { + call x + x: pop eax + mov c.Eip, eax + mov c.Ebp, ebp + mov c.Esp, esp + } + fs.sf.AddrPC.Offset = c.Eip; + fs.sf.AddrStack.Offset = c.Esp; + fs.sf.AddrFrame.Offset = c.Ebp; + fs.sf.AddrPC.Mode = AddrModeFlat; + fs.sf.AddrStack.Mode = AddrModeFlat; + fs.sf.AddrFrame.Mode = AddrModeFlat; +# elif defined (_M_X64) + DWORD machine = IMAGE_FILE_MACHINE_AMD64; + RtlCaptureContext (&c); + fs.sf.AddrPC.Offset = c.Rip; + fs.sf.AddrFrame.Offset = c.Rsp; //should be Rbp or Rdi instead? + fs.sf.AddrStack.Offset = c.Rsp; + fs.sf.AddrPC.Mode = AddrModeFlat; + fs.sf.AddrFrame.Mode = AddrModeFlat; + fs.sf.AddrStack.Mode = AddrModeFlat; +# elif defined (_M_IA64) + DWORD machine = IMAGE_FILE_MACHINE_IA64; + RtlCaptureContext (&c); + fs.sf.AddrPC.Offset = c.StIIP; + fs.sf.AddrFrame.Offset = c.RsBSP; + fs.sf.AddrBStore.Offset = c.RsBSP; + fs.sf.AddrStack.Offset = c.IntSp; + fs.sf.AddrPC.Mode = AddrModeFlat; + fs.sf.AddrFrame.Mode = AddrModeFlat; + fs.sf.AddrBStore.Mode = AddrModeFlat; + fs.sf.AddrStack.Mode = AddrModeFlat; +# endif + + fs.pSym = (PSYMBOL_INFO) GlobalAlloc (GMEM_FIXED, + sizeof (SYMBOL_INFO) + + sizeof (ACE_TCHAR) * (SYMSIZE - 1)); + fs.pSym->SizeOfStruct = sizeof (SYMBOL_INFO); + fs.pSym->MaxNameLen = SYMSIZE * sizeof (ACE_TCHAR); + dbg.SymSetOptions (SYMOPT_DEFERRED_LOADS | SYMOPT_LOAD_LINES + | SYMOPT_FAIL_CRITICAL_ERRORS | dbg.SymGetOptions ()); + dbg.SymInitialize (GetCurrentProcess (), 0, true); + //What does the "true" parameter mean when tracing the current process? + + for (size_t current_frame = 0; current_frame < num_frames + starting_frame; + ++current_frame) + { + BOOL ok = dbg.StackWalk64 (machine, + GetCurrentProcess (), + GetCurrentThread (), + &fs.sf, &c, 0, + dbg.SymFunctionTableAccess64, + dbg.SymGetModuleBase64, 0); + if (!ok || fs.sf.AddrFrame.Offset == 0) + break; + + if (current_frame < starting_frame) + continue; + + func (&fs, usrarg); + } + + dbg.SymCleanup (GetCurrentProcess ()); + GlobalFree (fs.pSym); + FreeLibrary (dbg.hMod); + + return 0; +} + +void +ACE_Stack_Trace::generate_trace (ssize_t starting_frame_offset, + size_t num_frames) +{ + const size_t MAX_FRAMES = 128; + const ssize_t INITIAL_FRAME = 3; + + if (num_frames == 0) + num_frames = MAX_FRAMES; + + size_t starting_frame = + determine_starting_frame (INITIAL_FRAME, starting_frame_offset); + + cs_operate (&add_frame_to_buf, &this->buf_[0], starting_frame, num_frames); +} + +#else // Unsupported platform +void +ACE_Stack_Trace::generate_trace (ssize_t, size_t) +{ +// Call determine_starting_frame() on HP aCC build to resolve declared +// method never referenced warning. +#if defined (__HP_aCC) + size_t starting_frame = determine_starting_frame (0, 0); +#endif + + ACE_OS::strcpy (&this->buf_[0], UNSUPPORTED); +} +#endif + diff --git a/dep/ACE_wrappers/ace/Stack_Trace.h b/dep/ACE_wrappers/ace/Stack_Trace.h new file mode 100644 index 00000000000..56cf8a09208 --- /dev/null +++ b/dep/ACE_wrappers/ace/Stack_Trace.h @@ -0,0 +1,107 @@ +// -*- C++ -*- +//============================================================================= +/** + * @file Stack_Trace.h + * + * $Id: Stack_Trace.h 81926 2008-06-12 14:43:09Z mitza $ + * + * @author Chris Cleeland (cleeland.ociweb.com) + */ +//============================================================================= + +#ifndef ACE_STACK_TRACE_H +#define ACE_STACK_TRACE_H + +#include /**/ "ace/pre.h" + +#include "ace/ACE_export.h" +#include "ace/Basic_Types.h" + +# if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +# endif /* ACE_LACKS_PRAGMA_ONCE */ + +# ifndef ACE_STACK_TRACE_SYMBUFSIZ +# define ACE_STACK_TRACE_SYMBUFSIZ 4096 +# endif + +/** + * @class ACE_Stack_Trace + * + * @brief Encapsulate a string representation of a stack trace on supported platforms. + * Stack traces for code built with optimize=1 (or "Release" configs on Visual + * Studio) may be misleading (missng frames) due to inlining performed by the + * compiler, which is indepenent of the inline=0 / inline=1 build option and + * the __ACE_INLINE__ / ACE_NO_INLINE macros. + * + * A new conversion character, the question mark, was added to ACE_Log_Msg for stack + * trace logging. The %? conversion character was added as a convenience so that users + * need not instantiate an ACE_Stack_Trace instance solely for the purpose of printing + * it in an ACE logging message. The following are functionally equivalent: + * + * \code + * ACE_DEBUG((LM_DEBUG, "%?")); + * + * ACE_Stack_Trace st; + * ACE_DEBUG ((LM_DEBUG, "%s", st.c_str() )); + * \endcode + * + * These usage examples were shown in $ACE_ROOT/tests/Stack_Trace_Test.cpp. + * + * @note The stack trace functionality was currently supported on platforms: + * - Any platform using glibc as its runtime library, or where ACE_HAS_EXECINFO_H is defined + * (this covers Linux and Mac) and gcc version >= 3.3. + * - VxWorks, both kernel and RTP + * - Solaris + * - Windows 32 and 64 bit (Visual C++, excluding WinCE/mobile) + * + * @note Since stack trace buffer size has limitation(@c ACE_STACK_TRACE_SYMBUFSIZ), you will not + * get a complete stack trace if @c ACE_STACK_TRACE_SYMBUFSIZ value is less than actual stack + * trace data length. To get a complete stack trace, you need set @c ACE_STACK_TRACE_SYMBUFSIZ + * with a larger value that is enough for the stack trace data in your @c config.h file + * and rebuild ACE. + * + * @note Using ACE logging mechanism (%?) to log the stack trace also has ACE_MAXLOGMSGLEN size limitation. + * To get a complete stack trace, you could use different output method. Following is an example. + * + * \code + * ACE_Stack_Trace st; + * ACE_OS::printf("at [%s]\n", st.c_str()); + * \endcode + */ +class ACE_Export ACE_Stack_Trace +{ +public: + /** + * @brief Grab a snapshot of the current stack trace and hold it for later use. + * + * @param starting_frame_offset offset into the array of frames to start printing; 0 is the + * platform-specific offset for the first frame, positive numbers give less frames, negative give + * more frames + * @param num_frames the number of stack frames to include (0 indicates platform-specific maximum) + * + */ + explicit ACE_Stack_Trace (ssize_t starting_frame_offset = 0, size_t num_frames = 0); + + /** + * @brief Return buffer as a C-style string. + * @return C-style string with string representation of stack trace. + * @note Lifecycle of string follows lifecycle of ACE_Stack_Trace instance. + */ + const char* c_str() const; + + static const size_t SYMBUFSIZ = ACE_STACK_TRACE_SYMBUFSIZ; + +private: + char buf_[SYMBUFSIZ]; + size_t buflen_; + + static const char UNSUPPORTED[]; + static const char UNABLE_TO_GET_TRACE[]; + + void generate_trace (ssize_t starting_frame_offset, size_t num_frames); +}; + +#include /**/ "ace/post.h" +#endif /* ACE_STACK_TRACE_H */ + diff --git a/dep/ACE_wrappers/ace/Static_Object_Lock.h b/dep/ACE_wrappers/ace/Static_Object_Lock.h new file mode 100644 index 00000000000..ad780258ee1 --- /dev/null +++ b/dep/ACE_wrappers/ace/Static_Object_Lock.h @@ -0,0 +1,78 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Static_Object_Lock.h + * + * $Id: Static_Object_Lock.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author David L. Levine + * @author Matthias Kerkhoff + * @author Per Andersson + */ +//============================================================================= + +#ifndef ACE_STATIC_OBJECT_LOCK_H +#define ACE_STATIC_OBJECT_LOCK_H +#include /**/ "ace/pre.h" + +#include /**/ "ace/ACE_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#if defined (ACE_HAS_THREADS) + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +class ACE_Recursive_Thread_Mutex; + +/** + * @class ACE_Static_Object_Lock + * + * @brief Provide an interface to access a global lock. + * + * This class is used to serialize the creation of static + * singleton objects. It really isn't needed any more, because + * anyone can access ACE_STATIC_OBJECT_LOCK directly. But, it + * is retained for backward compatibility. + */ +class ACE_Export ACE_Static_Object_Lock +{ +public: + /// Static lock access point. + static ACE_Recursive_Thread_Mutex *instance (void); + + /// For use only by ACE_Object_Manager to clean up lock if it + /// what dynamically allocated. + static void cleanup_lock (void); +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#endif /* ACE_HAS_THREADS */ + +// hack to get around errors while compiling using split-cpp +#if defined (ACE_HAS_THREADS) + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +# if defined (ACE_IS_SPLITTING) +typedef ACE_Cleanup_Adapter ACE_Static_Object_Lock_Type; + +# if defined (__GNUC__) +// With g++, suppress the warning that this is unused. +static ACE_Static_Object_Lock_Type *ACE_Static_Object_Lock_lock __attribute__ ((unused)) = 0; +# else +static ACE_Static_Object_Lock_Type *ACE_Static_Object_Lock_lock = 0; +# endif /* __GNUC__ */ + +# endif /* ACE_IS_SPLITTING */ + +ACE_END_VERSIONED_NAMESPACE_DECL + +#endif /* ACE_HAS_THREADS */ + +#include /**/ "ace/post.h" +#endif /* ACE_STATIC_OBJECT_LOCK_H */ diff --git a/dep/ACE_wrappers/ace/Stats.cpp b/dep/ACE_wrappers/ace/Stats.cpp new file mode 100644 index 00000000000..bb6dcf0a6a8 --- /dev/null +++ b/dep/ACE_wrappers/ace/Stats.cpp @@ -0,0 +1,426 @@ +// $Id: Stats.cpp 80826 2008-03-04 14:51:23Z wotte $ + +#include "ace/Stats.h" + +#if !defined (__ACE_INLINE__) +# include "ace/Stats.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/OS_NS_stdio.h" +#include "ace/OS_NS_string.h" + +ACE_RCSID(ace, Stats, "$Id: Stats.cpp 80826 2008-03-04 14:51:23Z wotte $") + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_UINT32 +ACE_Stats_Value::fractional_field (void) const +{ + if (precision () == 0) + { + return 1; + } + else + { + ACE_UINT32 field = 10; + for (u_int i = 0; i < precision () - 1; ++i) + { + field *= 10; + } + + return field; + } +} + +int +ACE_Stats::sample (const ACE_INT32 value) +{ + if (samples_.enqueue_tail (value) == 0) + { + ++number_of_samples_; + if (number_of_samples_ == 0) + { + // That's a lot of samples :-) + overflow_ = EFAULT; + return -1; + } + + if (value < min_) + min_ = value; + + if (value > max_) + max_ = value; + + return 0; + } + else + { + // Probably failed due to running out of memory when trying to + // enqueue the new value. + overflow_ = errno; + return -1; + } +} + +void +ACE_Stats::mean (ACE_Stats_Value &m, + const ACE_UINT32 scale_factor) +{ + if (number_of_samples_ > 0) + { +#if defined ACE_LACKS_LONGLONG_T + // If ACE_LACKS_LONGLONG_T, then ACE_UINT64 is a user-defined class. + // To prevent having to construct a static of that class, declare it + // on the stack, and construct it, in each function that needs it. + const ACE_U_LongLong ACE_STATS_INTERNAL_OFFSET (0, 8); +#else /* ! ACE_LACKS_LONGLONG_T */ + const ACE_UINT64 ACE_STATS_INTERNAL_OFFSET = + ACE_UINT64_LITERAL (0x100000000); +#endif /* ! ACE_LACKS_LONGLONG_T */ + + ACE_UINT64 sum = ACE_STATS_INTERNAL_OFFSET; + ACE_Unbounded_Queue_Iterator i (samples_); + while (! i.done ()) + { + ACE_INT32 *sample; + if (i.next (sample)) + { + sum += *sample; + i.advance (); + } + } + + // sum_ was initialized with ACE_STATS_INTERNAL_OFFSET, so + // subtract that off here. + quotient (sum - ACE_STATS_INTERNAL_OFFSET, + number_of_samples_ * scale_factor, + m); + } + else + { + m.whole (0); + m.fractional (0); + } +} + +int +ACE_Stats::std_dev (ACE_Stats_Value &std_dev, + const ACE_UINT32 scale_factor) +{ + if (number_of_samples_ <= 1) + { + std_dev.whole (0); + std_dev.fractional (0); + } + else + { + const ACE_UINT32 field = std_dev.fractional_field (); + + // The sample standard deviation is: + // + // sqrt (sum (sample_i - mean)^2 / (number_of_samples_ - 1)) + + ACE_UINT64 mean_scaled; + // Calculate the mean, scaled, so that we don't lose its + // precision. + ACE_Stats_Value avg (std_dev.precision ()); + mean (avg, 1u); + avg.scaled_value (mean_scaled); + + // Calculate the summation term, of squared differences from the + // mean. + ACE_UINT64 sum_of_squares = 0; + ACE_Unbounded_Queue_Iterator i (samples_); + while (! i.done ()) + { + ACE_INT32 *sample; + if (i.next (sample)) + { + const ACE_UINT64 original_sum_of_squares = sum_of_squares; + + // Scale up by field width so that we don't lose the + // precision of the mean. Carefully . . . + const ACE_UINT64 product (*sample * field); + + ACE_UINT64 difference; + // NOTE: please do not reformat this code! It // + // works with the Diab compiler the way it is! // + if (product >= mean_scaled) // + { // + difference = product - mean_scaled; // + } // + else // + { // + difference = mean_scaled - product; // + } // + // NOTE: please do not reformat this code! It // + // works with the Diab compiler the way it is! // + + // Square using 64-bit arithmetic. + sum_of_squares += difference * ACE_U64_TO_U32 (difference); + i.advance (); + + if (sum_of_squares < original_sum_of_squares) + { + overflow_ = ENOSPC; + return -1; + } + } + } + + // Divide the summation by (number_of_samples_ - 1), to get the + // variance. In addition, scale the variance down to undo the + // mean scaling above. Otherwise, it can get too big. + ACE_Stats_Value variance (std_dev.precision ()); + quotient (sum_of_squares, + (number_of_samples_ - 1) * field * field, + variance); + + // Take the square root of the variance to get the standard + // deviation. First, scale up . . . + ACE_UINT64 scaled_variance; + variance.scaled_value (scaled_variance); + + // And scale up, once more, because we'll be taking the square + // root. + scaled_variance *= field; + ACE_Stats_Value unscaled_standard_deviation (std_dev.precision ()); + square_root (scaled_variance, + unscaled_standard_deviation); + + // Unscale. + quotient (unscaled_standard_deviation, + scale_factor * field, + std_dev); + } + + return 0; +} + + +void +ACE_Stats::reset (void) +{ + overflow_ = 0u; + number_of_samples_ = 0u; + min_ = 0x7FFFFFFF; + max_ = -0x8000 * 0x10000; + samples_.reset (); +} + +int +ACE_Stats::print_summary (const u_int precision, + const ACE_UINT32 scale_factor, + FILE *file) const +{ + ACE_TCHAR mean_string [128]; + ACE_TCHAR std_dev_string [128]; + ACE_TCHAR min_string [128]; + ACE_TCHAR max_string [128]; + int success = 0; + + for (int tmp_precision = precision; + ! overflow_ && ! success && tmp_precision >= 0; + --tmp_precision) + { + // Build a format string, in case the C library doesn't support %*u. + ACE_TCHAR format[32]; + if (tmp_precision == 0) + ACE_OS::sprintf (format, ACE_TEXT ("%%%d"), tmp_precision); + else + ACE_OS::sprintf (format, ACE_TEXT ("%%d.%%0%du"), tmp_precision); + + ACE_Stats_Value u (tmp_precision); + ((ACE_Stats *) this)->mean (u, scale_factor); + ACE_OS::sprintf (mean_string, format, u.whole (), u.fractional ()); + + ACE_Stats_Value sd (tmp_precision); + if (((ACE_Stats *) this)->std_dev (sd, scale_factor)) + { + success = 0; + continue; + } + else + { + success = 1; + } + ACE_OS::sprintf (std_dev_string, format, sd.whole (), sd.fractional ()); + + ACE_Stats_Value minimum (tmp_precision), maximum (tmp_precision); + if (min_ != 0) + { + const ACE_UINT64 m (min_); + quotient (m, scale_factor, minimum); + } + if (max_ != 0) + { + const ACE_UINT64 m (max_); + quotient (m, scale_factor, maximum); + } + ACE_OS::sprintf (min_string, format, + minimum.whole (), minimum.fractional ()); + ACE_OS::sprintf (max_string, format, + maximum.whole (), maximum.fractional ()); + } + + if (success == 1) + { + ACE_OS::fprintf (file, ACE_TEXT ("samples: %u (%s - %s); mean: ") + ACE_TEXT ("%s; std dev: %s\n"), + samples (), min_string, max_string, + mean_string, std_dev_string); + return 0; + } + else + { +#if !defined (ACE_HAS_WINCE) + ACE_OS::fprintf (file, + ACE_TEXT ("ACE_Stats::print_summary: OVERFLOW: %s\n"), + ACE_OS::strerror (overflow_)); +#else + // WinCE doesn't have strerror ;( + ACE_OS::fprintf (file, + ACE_TEXT ("ACE_Stats::print_summary: OVERFLOW\n")); +#endif /* ACE_HAS_WINCE */ + return -1; + } +} + +void +ACE_Stats::quotient (const ACE_UINT64 dividend, + const ACE_UINT32 divisor, + ACE_Stats_Value "ient) +{ + // The whole part of the division comes from simple integer division. + quotient.whole (static_cast (divisor == 0 + ? 0 : dividend / divisor)); + + if (quotient.precision () > 0 || divisor == 0) + { + const ACE_UINT32 field = quotient.fractional_field (); + + // Fractional = (dividend % divisor) * 10^precision / divisor + + // It would be nice to add round-up term: + // Fractional = (dividend % divisor) * 10^precision / divisor + + // 10^precision/2 / 10^precision + // = ((dividend % divisor) * 10^precision + divisor) / + // divisor + quotient.fractional (static_cast ( + dividend % divisor * field / divisor)); + } + else + { + // No fractional portion is requested, so don't bother + // calculating it. + quotient.fractional (0); + } +} + +void +ACE_Stats::quotient (const ACE_Stats_Value ÷nd, + const ACE_UINT32 divisor, + ACE_Stats_Value "ient) +{ + // The whole part of the division comes from simple integer division. + quotient.whole (divisor == 0 ? 0 : dividend.whole () / divisor); + + if (quotient.precision () > 0 || divisor == 0) + { + const ACE_UINT32 field = quotient.fractional_field (); + + // Fractional = (dividend % divisor) * 10^precision / divisor. + quotient.fractional (dividend.whole () % divisor * field / divisor + + dividend.fractional () / divisor); + } + else + { + // No fractional portion is requested, so don't bother + // calculating it. + quotient.fractional (0); + } +} + +void +ACE_Stats::square_root (const ACE_UINT64 n, + ACE_Stats_Value &square_root) +{ + ACE_UINT32 floor = 0; + ACE_UINT32 ceiling = 0xFFFFFFFFu; + ACE_UINT32 mid = 0; + u_int i; + + // The maximum number of iterations is log_2 (2^64) == 64. + for (i = 0; i < 64; ++i) + { + mid = (ceiling - floor) / 2 + floor; + if (floor == mid) + // Can't divide the interval any further. + break; + else + { + // Multiply carefully to avoid overflow. + ACE_UINT64 mid_squared = mid; mid_squared *= mid; + if (mid_squared == n) + break; + else if (mid_squared < n) + floor = mid; + else + ceiling = mid; + } + } + + square_root.whole (mid); + ACE_UINT64 mid_squared = mid; mid_squared *= mid; + + if (square_root.precision () && mid_squared < n) + { + // (mid * 10^precision + fractional)^2 == + // n^2 * 10^(precision * 2) + + const ACE_UINT32 field = square_root.fractional_field (); + + floor = 0; + ceiling = field; + mid = 0; + + // Do the 64-bit arithmetic carefully to avoid overflow. + ACE_UINT64 target = n; + target *= field; + target *= field; + + ACE_UINT64 difference = 0; + + for (i = 0; i < square_root.precision (); ++i) + { + mid = (ceiling - floor) / 2 + floor; + + ACE_UINT64 current = square_root.whole () * field + mid; + current *= square_root.whole () * field + mid; + + if (floor == mid) + { + difference = target - current; + break; + } + else if (current <= target) + floor = mid; + else + ceiling = mid; + } + + // Check to see if the fractional part should be one greater. + ACE_UINT64 next = square_root.whole () * field + mid + 1; + next *= square_root.whole () * field + mid + 1; + + square_root.fractional (next - target < difference ? mid + 1 : mid); + } + else + { + // No fractional portion is requested, so don't bother + // calculating it. + square_root.fractional (0); + } +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Stats.h b/dep/ACE_wrappers/ace/Stats.h new file mode 100644 index 00000000000..2590ec95c10 --- /dev/null +++ b/dep/ACE_wrappers/ace/Stats.h @@ -0,0 +1,222 @@ +// -*- C++ -*- + +//========================================================================== +/** + * @file Stats.h + * + * $Id: Stats.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author David L. Levine + */ +//========================================================================== + + +#ifndef ACE_STATS_H +#define ACE_STATS_H + +#include /**/ "ace/pre.h" + +#include /**/ "ace/ACE_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/Unbounded_Queue.h" +#include "ace/Log_Msg.h" +#include "ace/Basic_Stats.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +/** + * @class ACE_Stats_Value + * + * @brief Helper class for ACE_Stats. + * + * Container struct for 64-bit signed quantity and its + * precision. It would be nicer to use a fixed-point class, but + * this is sufficient. Users typically don't need to use this + * class directly; see ACE_Stats below. + */ +class ACE_Export ACE_Stats_Value +{ +public: + /** + * Constructor, which requires precision in terms of number of + * decimal digits. The more variation in the data, and the greater + * the data values, the smaller the precision must be to avoid + * overflow in the standard deviation calculation. 3 might be a + * good value, or maybe 4. 5 will probably be too large for + * non-trivial data sets. + */ + ACE_Stats_Value (const u_int precision); + + /// Accessor for precision. + u_int precision (void) const; + + /// Set the whole_ field. + void whole (const ACE_UINT32); + + /// Accessor for the whole_ field. + ACE_UINT32 whole (void) const; + + /// Set the fractional_ field. + void fractional (const ACE_UINT32); + + /// Accessor for the fractional_ field. + ACE_UINT32 fractional (void) const; + + /// Calculates the maximum value of the fractional portion, given its + /// precision. + ACE_UINT32 fractional_field (void) const; + + /** + * Access the value as an _unsigned_ 64 bit quantity. It scales the + * value up by {precision} decimal digits, so that no precision will + * be lost. It assumes that {whole_} is >= 0. + */ + void scaled_value (ACE_UINT64 &) const; + + /// Print to stdout. + void dump (void) const; + +private: + + ACE_Stats_Value (void) {} + +private: + /// The integer portion of the value. + ACE_UINT32 whole_; + + /// The fractional portion of the value. + ACE_UINT32 fractional_; + + /** + * The number of decimal digits of precision represented by + * {fractional_}. Not declared const, so the only way to change it + * is via the assignment operator. + */ + u_int precision_; + +}; + +/** + * @class ACE_Stats + * + * @brief Provides simple statistical analysis. + * + * Simple statistical analysis package. Prominent features are: + * -# It does not use any floating point arithmetic. + * -# It handles positive and/or negative sample values. The + * sample value type is ACE_INT32. + * -# It uses 64 bit unsigned, but not 64 bit signed, quantities + * internally. + * -# It checks for overflow of internal state. + * -# It has no static variables of other than built-in types. + * + * Example usage: + * + * @verbatim + * ACE_Stats stats; + * for (u_int i = 0; i < n; ++i) + * { + * const ACE_UINT32 sample = ...; + * stats.sample (sample); + * } + * stats.print_summary (3); + * @endverbatim + */ +class ACE_Export ACE_Stats +{ +public: + /// Default constructor. + ACE_Stats (void); + + /// Provide a new sample. Returns 0 on success, -1 if it fails due + /// to running out of memory, or to rolling over of the sample count. + int sample (const ACE_INT32 value); + + /// Access the number of samples provided so far. + ACE_UINT32 samples (void) const; + + /// Value of the minimum sample provided so far. + ACE_INT32 min_value (void) const; + + /// Value of the maximum sample provided so far. + ACE_INT32 max_value (void) const; + + /** + * Access the mean of all samples provided so far. The fractional + * part is to the specified number of digits. E.g., 3 fractional + * digits specifies that the fractional part is in thousandths. + */ + void mean (ACE_Stats_Value &mean, + const ACE_UINT32 scale_factor = 1); + + /// Access the standard deviation, whole and fractional parts. See + /// description of {mean} method for argument descriptions. + int std_dev (ACE_Stats_Value &std_dev, + const ACE_UINT32 scale_factor = 1); + + /** + * Print summary statistics. If scale_factor is not 1, then the + * results are divided by it, i.e., each of the samples is scaled + * down by it. If internal overflow is reached with the specified + * scale factor, it successively tries to reduce it. Returns -1 if + * there is overflow even with a 0 scale factor. + */ + int print_summary (const u_int precision, + const ACE_UINT32 scale_factor = 1, + FILE * = stdout) const; + + /// Initialize internal state. + void reset (void); + + /// Utility division function, for ACE_UINT64 dividend. + static void quotient (const ACE_UINT64 dividend, + const ACE_UINT32 divisor, + ACE_Stats_Value "ient); + + /// Utility division function, for ACE_Stats_Value dividend. + static void quotient (const ACE_Stats_Value ÷nd, + const ACE_UINT32 divisor, + ACE_Stats_Value "ient); + + /** + * Sqrt function, which uses an oversimplified version of Newton's + * method. It's not fast, but it doesn't require floating point + * support. + */ + static void square_root (const ACE_UINT64 n, + ACE_Stats_Value &square_root); + + /// Print summary statistics to stdout. + void dump (void) const; + +protected: + /// Internal indication of whether there has been overflow. Contains + /// the errno corresponding to the cause of overflow. + u_int overflow_; + + /// Number of samples. + ACE_UINT32 number_of_samples_; + + /// Minimum sample value. + ACE_INT32 min_; + + /// Maximum sample value. + ACE_INT32 max_; + + /// The samples. + ACE_Unbounded_Queue samples_; +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +# include "ace/Stats.inl" +#endif /* __ACE_INLINE__ */ + +#include /**/ "ace/post.h" + +#endif /* ! ACE_STATS_H */ diff --git a/dep/ACE_wrappers/ace/Stats.inl b/dep/ACE_wrappers/ace/Stats.inl new file mode 100644 index 00000000000..4c76838c207 --- /dev/null +++ b/dep/ACE_wrappers/ace/Stats.inl @@ -0,0 +1,104 @@ +// -*- C++ -*- +// +// $Id: Stats.inl 80826 2008-03-04 14:51:23Z wotte $ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_INLINE +ACE_Stats_Value::ACE_Stats_Value (const u_int precision) + : whole_ (0), + fractional_ (0), + precision_ (precision) +{ +} + +ACE_INLINE +u_int +ACE_Stats_Value::precision (void) const +{ + return precision_; +} + +ACE_INLINE +void +ACE_Stats_Value::whole (const ACE_UINT32 value) +{ + whole_ = value; +} + +ACE_INLINE +ACE_UINT32 +ACE_Stats_Value::whole (void) const +{ + return whole_; +} + +ACE_INLINE +void +ACE_Stats_Value::fractional (const ACE_UINT32 value) +{ + fractional_ = value; +} + +ACE_INLINE +ACE_UINT32 +ACE_Stats_Value::fractional (void) const +{ + return fractional_; +} + +ACE_INLINE +void +ACE_Stats_Value::scaled_value (ACE_UINT64 &sv) const +{ + sv = whole () * fractional_field () + fractional (); +} + +ACE_INLINE +void +ACE_Stats_Value::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("precision: %u digits; whole: %u, fractional: %u\n"), + precision_, whole_, fractional_)); +#endif /* ACE_HAS_DUMP */ +} + +ACE_INLINE +ACE_Stats::ACE_Stats (void) +{ + reset (); +} + +ACE_INLINE +ACE_UINT32 +ACE_Stats::samples (void) const +{ + return number_of_samples_; +} + +ACE_INLINE +ACE_INT32 +ACE_Stats::min_value (void) const +{ + return min_; +} + +ACE_INLINE +ACE_INT32 +ACE_Stats::max_value (void) const +{ + return max_; +} + +ACE_INLINE +void +ACE_Stats::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + print_summary (3u); +#endif /* ACE_HAS_DUMP */ +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Strategies.h b/dep/ACE_wrappers/ace/Strategies.h new file mode 100644 index 00000000000..484ffa9a510 --- /dev/null +++ b/dep/ACE_wrappers/ace/Strategies.h @@ -0,0 +1,33 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Strategies.h + * + * $Id: Strategies.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Douglas C. Schmidt + */ +//============================================================================= + +#ifndef ACE_STRATEGIES_H +#define ACE_STRATEGIES_H +#include /**/ "ace/pre.h" + +#include /**/ "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +/// Place holder for backward compatibility.. +#include "ace/Connection_Recycling_Strategy.h" +#include "ace/Hashable.h" +#include "ace/Notification_Strategy.h" +#include "ace/Reactor_Notification_Strategy.h" +#include "ace/Recyclable.h" +#include "ace/Refcountable.h" + + +#include /**/ "ace/post.h" +#endif /*ACE_STRATEGIES_H*/ diff --git a/dep/ACE_wrappers/ace/Strategies_T.cpp b/dep/ACE_wrappers/ace/Strategies_T.cpp new file mode 100644 index 00000000000..cd2935aadf3 --- /dev/null +++ b/dep/ACE_wrappers/ace/Strategies_T.cpp @@ -0,0 +1,1502 @@ +// $Id: Strategies_T.cpp 82294 2008-07-12 13:03:37Z johnnyw $ + +#ifndef ACE_STRATEGIES_T_CPP +#define ACE_STRATEGIES_T_CPP + +#include "ace/Strategies_T.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/Service_Repository.h" +#include "ace/Service_Types.h" +#include "ace/Thread_Manager.h" +#include "ace/WFMO_Reactor.h" +#include "ace/ACE.h" +#include "ace/OS_NS_dlfcn.h" +#include "ace/OS_NS_string.h" +#include "ace/OS_Errno.h" +#include "ace/Svc_Handler.h" +#if defined (ACE_OPENVMS) +# include "ace/Lib_Find.h" +#endif + +#if !defined (__ACE_INLINE__) +#include "ace/Strategies_T.inl" +#endif /* __ACE_INLINE__ */ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +template +ACE_Recycling_Strategy::~ACE_Recycling_Strategy (void) +{ +} + +template int +ACE_Recycling_Strategy::assign_recycler (SVC_HANDLER *svc_handler, + ACE_Connection_Recycling_Strategy *recycler, + const void *recycling_act) +{ + svc_handler->recycler (recycler, recycling_act); + return 0; +} + +template int +ACE_Recycling_Strategy::prepare_for_recycling (SVC_HANDLER *svc_handler) +{ + return svc_handler->recycle (); +} + +template +ACE_Singleton_Strategy::~ACE_Singleton_Strategy (void) +{ + ACE_TRACE ("ACE_Singleton_Strategy::~ACE_Singleton_Strategy"); + if (this->delete_svc_handler_) + delete this->svc_handler_; +} + +// Create a Singleton SVC_HANDLER by always returning the same +// SVC_HANDLER. + +template int +ACE_Singleton_Strategy::make_svc_handler (SVC_HANDLER *&sh) +{ + ACE_TRACE ("ACE_Singleton_Strategy::make_svc_handler"); + sh = this->svc_handler_; + return 0; +} + +template int +ACE_Singleton_Strategy::open (SVC_HANDLER *sh, + ACE_Thread_Manager *) +{ + ACE_TRACE ("ACE_Singleton_Strategy::open"); + + if (this->delete_svc_handler_) + delete this->svc_handler_; + + // If is NULL then create a new . + if (sh == 0) + { + ACE_NEW_RETURN (this->svc_handler_, + SVC_HANDLER, + -1); + this->delete_svc_handler_ = true; + } + else + { + this->svc_handler_ = sh; + this->delete_svc_handler_ = false; + } + + return 0; +} + +template int +ACE_DLL_Strategy::open (const ACE_TCHAR dll_name[], + const ACE_TCHAR factory_function[], + const ACE_TCHAR svc_name[], + ACE_Service_Repository *svc_rep, + ACE_Thread_Manager *thr_mgr) +{ + ACE_TRACE ("ACE_DLL_Strategy::open"); + this->inherited::open (thr_mgr); + ACE_OS::strcpy (this->dll_name_, dll_name); + ACE_OS::strcpy (this->factory_function_, factory_function); + ACE_OS::strcpy (this->svc_name_, svc_name); + this->svc_rep_ = svc_rep; + return 0; +} + +// Create a SVC_HANDLER by dynamically linking it from a DLL. + +template int +ACE_DLL_Strategy::make_svc_handler (SVC_HANDLER *&sh) +{ + ACE_TRACE ("ACE_DLL_Strategy::make_svc_handler"); + + // Open the shared library. + ACE_SHLIB_HANDLE handle = ACE_OS::dlopen (this->dll_name_); + + // Extract the factory function. +#if defined (ACE_OPENVMS) + SVC_HANDLER *(*factory)(void) = + (SVC_HANDLER *(*)(void)) ACE::ldsymbol (handle, + this->factory_function_); +#else + SVC_HANDLER *(*factory)(void) = + (SVC_HANDLER *(*)(void)) ACE_OS::dlsym (handle, + this->factory_function_); +#endif + + // Call the factory function to obtain the new SVC_Handler (should + // use RTTI here when it becomes available...) + SVC_HANDLER *svc_handler = 0; + + ACE_ALLOCATOR_RETURN (svc_handler, (*factory)(), -1); + + if (svc_handler != 0) + { + // Create an ACE_Service_Type containing the SVC_Handler and + // insert into this->svc_rep_; + + ACE_Service_Type_Impl *stp = 0; + ACE_NEW_RETURN (stp, + ACE_Service_Object_Type (svc_handler, + this->svc_name_), + -1); + + ACE_Service_Type *srp = 0; + + ACE_NEW_RETURN (srp, + ACE_Service_Type (this->svc_name_, + stp, + handle, + 1), + -1); + if (srp == 0) + { + delete stp; + errno = ENOMEM; + return -1; + } + + if (this->svc_rep_->insert (srp) == -1) + return -1; + // @@ Somehow, we need to deal with this->thr_mgr_... + } + + sh = svc_handler; + return 0; +} + +// Default behavior is to activate the SVC_HANDLER by calling it's +// open() method, which allows the SVC_HANDLER to determine its own +// concurrency strategy. + +template int +ACE_Concurrency_Strategy::activate_svc_handler (SVC_HANDLER *svc_handler, + void *arg) +{ + ACE_TRACE ("ACE_Concurrency_Strategy::activate_svc_handler"); + + int result = 0; + + // See if we should enable non-blocking I/O on the 's + // peer. + if (ACE_BIT_ENABLED (this->flags_, ACE_NONBLOCK) != 0) + { + if (svc_handler->peer ().enable (ACE_NONBLOCK) == -1) + result = -1; + } + // Otherwise, make sure it's disabled by default. + else if (svc_handler->peer ().disable (ACE_NONBLOCK) == -1) + result = -1; + + if (result == 0 && svc_handler->open (arg) == -1) + result = -1; + + if (result == -1) + // The connection was already made; so this close is a "normal" close + // operation. + svc_handler->close (NORMAL_CLOSE_OPERATION); + + return result; +} + +template int +ACE_Reactive_Strategy::open (ACE_Reactor *reactor, + ACE_Reactor_Mask mask, + int flags) +{ + ACE_TRACE ("ACE_Reactive_Strategy::open"); + this->reactor_ = reactor; + this->mask_ = mask; + this->flags_ = flags; + + // Must have a + if (this->reactor_ == 0) + return -1; + else + return 0; +} + +template int +ACE_Reactive_Strategy::activate_svc_handler (SVC_HANDLER *svc_handler, + void *arg) +{ + ACE_TRACE ("ACE_Reactive_Strategy::activate_svc_handler"); + + int result = 0; + + if (this->reactor_ == 0) + result = -1; + + // Register with the Reactor with the appropriate . + else if (this->reactor_->register_handler (svc_handler, this->mask_) == -1) + result = -1; + + // If the implementation of the reactor uses event associations + else if (this->reactor_->uses_event_associations ()) + { + // If we don't have non-block on, it won't work with + // WFMO_Reactor + // This maybe too harsh + // if (!ACE_BIT_ENABLED (this->flags_, ACE_NONBLOCK)) + // goto failure; + if (svc_handler->open (arg) != -1) + return 0; + else + result = -1; + } + else + // Call up to our parent to do the SVC_HANDLER initialization. + return this->inherited::activate_svc_handler (svc_handler, arg); + + if (result == -1) + // The connection was already made; so this close is a "normal" close + // operation. + svc_handler->close (NORMAL_CLOSE_OPERATION); + + return result; +} + +template int +ACE_Thread_Strategy::open (ACE_Thread_Manager *thr_mgr, + long thr_flags, + int n_threads, + int flags) +{ + ACE_TRACE ("ACE_Thread_Strategy::open"); + this->thr_mgr_ = thr_mgr; + this->n_threads_ = n_threads; + this->thr_flags_ = thr_flags; + this->flags_ = flags; + + // Must have a thread manager! + if (this->thr_mgr_ == 0) + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("error: must have a non-NULL thread manager\n")), + -1); + else + return 0; +} + +template int +ACE_Thread_Strategy::activate_svc_handler (SVC_HANDLER *svc_handler, + void *arg) +{ + ACE_TRACE ("ACE_Thread_Strategy::activate_svc_handler"); + // Call up to our parent to do the SVC_HANDLER initialization. + if (this->inherited::activate_svc_handler (svc_handler, + arg) == -1) + return -1; + else + // Turn the into an active object (if it isn't + // already one as a result of the first activation...) + return svc_handler->activate (this->thr_flags_, + this->n_threads_); +} + +template int +ACE_Accept_Strategy::open + (const ACE_PEER_ACCEPTOR_ADDR &local_addr, int reuse_addr) +{ + this->reuse_addr_ = reuse_addr; + this->peer_acceptor_addr_ = local_addr; + if (this->peer_acceptor_.open (local_addr, reuse_addr) == -1) + return -1; + + // Set the peer acceptor's handle into non-blocking mode. This is a + // safe-guard against the race condition that can otherwise occur + // between the time when was interrupted. + if (ACE_Sig_Handler::sig_pending () != 0) + { + ACE_Sig_Handler::sig_pending (0); + + // This piece of code comes from the old TP_Reactor. We did not + // handle signals at all then. If we happen to handle signals + // in the TP_Reactor, we should then start worryiung about this + // - Bala 21-Aug- 01 +if 0 + // Not sure if this should be done in the TP_Reactor + // case... leave it out for now. -Steve Huston 22-Aug-00 + + // If any HANDLES in the are activated as a + // result of signals they should be dispatched since + // they may be time critical... + active_handle_count = this->any_ready (dispatch_set); +else + // active_handle_count = 0; +endif + + // Record the fact that the Reactor has dispatched a + // handle_signal() method. We need this to return the + // appropriate count. + return 1; + } + + return -1; +} +#endif // #if 0 + + +int +ACE_TP_Reactor::handle_timer_events (int & /*event_count*/, + ACE_TP_Token_Guard &guard) +{ + if (this->timer_queue_ == 0 || this->timer_queue_->is_empty()) + { // Empty timer queue so cannot have any expired timers. + return 0; + } + + // Get the current time + ACE_Time_Value cur_time (this->timer_queue_->gettimeofday () + + this->timer_queue_->timer_skew ()); + + // Look for a node in the timer queue whose timer <= the present + // time. + ACE_Timer_Node_Dispatch_Info info; + + if (this->timer_queue_->dispatch_info (cur_time, info)) + { + const void *upcall_act = 0; + + // Preinvoke. + this->timer_queue_->preinvoke (info, cur_time, upcall_act); + + // Release the token before dispatching notifies... + guard.release_token (); + + // call the functor + this->timer_queue_->upcall (info, cur_time); + + // Postinvoke + this->timer_queue_->postinvoke (info, cur_time, upcall_act); + + // We have dispatched a timer + return 1; + } + + return 0; +} + +int +ACE_TP_Reactor::handle_notify_events (int & /*event_count*/, + ACE_TP_Token_Guard &guard) +{ + // Get the handle on which notify calls could have occured + ACE_HANDLE notify_handle = this->get_notify_handle (); + + int result = 0; + + // The notify was not in the list returned by + // wait_for_multiple_events (). + if (notify_handle == ACE_INVALID_HANDLE) + return result; + + // Now just do a read on the pipe.. + ACE_Notification_Buffer buffer; + + // Clear the handle of the read_mask of our + this->ready_set_.rd_mask_.clr_bit (notify_handle); + + // Keep reading notifies till we empty it or till we have a + // dispatchable buffer + while (this->notify_handler_->read_notify_pipe (notify_handle, buffer) > 0) + { + // Just figure out whether we can read any buffer that has + // dispatchable info. If not we have just been unblocked by + // another thread trying to update the reactor. If we get any + // buffer that needs dispatching we will dispatch that after + // releasing the lock + if (this->notify_handler_->is_dispatchable (buffer) > 0) + { + // Release the token before dispatching notifies... + guard.release_token (); + + // Dispatch the upcall for the notify + this->notify_handler_->dispatch_notify (buffer); + + // We had a successful dispatch. + result = 1; + + // break out of the while loop + break; + } + } + + // If we did some work, then we just return 1 which will allow us + // to get out of here. If we return 0, then we will be asked to do + // some work ie. dispacth socket events + return result; +} + +int +ACE_TP_Reactor::handle_socket_events (int &event_count, + ACE_TP_Token_Guard &guard) +{ + + // We got the lock, lets handle some I/O events. + ACE_EH_Dispatch_Info dispatch_info; + + this->get_socket_event_info (dispatch_info); + + // If there is any event handler that is ready to be dispatched, the + // dispatch information is recorded in dispatch_info. + if (!dispatch_info.dispatch ()) + { + // Check for removed handlers. + if (dispatch_info.event_handler_ == 0) + { + this->handler_rep_.unbind(dispatch_info.handle_, + dispatch_info.mask_); + } + + + return 0; + } + + // Suspend the handler so that other threads don't start dispatching + // it, if we can't suspend then return directly + // + // NOTE: This check was performed in older versions of the + // TP_Reactor. Looks like it is a waste.. + if (dispatch_info.event_handler_ != this->notify_handler_) + if (this->suspend_i (dispatch_info.handle_) == -1) + return 0; + + // Call add_reference() if needed. + if (dispatch_info.reference_counting_required_) + dispatch_info.event_handler_->add_reference (); + + // Release the lock. Others threads can start waiting. + guard.release_token (); + + int result = 0; + + // If there was an event handler ready, dispatch it. + // Decrement the event left + --event_count; + + // Dispatched an event + if (this->dispatch_socket_event (dispatch_info) == 0) + ++result; + + return result; +} + +int +ACE_TP_Reactor::get_event_for_dispatching (ACE_Time_Value *max_wait_time) +{ + // If the reactor handler state has changed, clear any remembered + // ready bits and re-scan from the master wait_set. + if (this->state_changed_) + { + this->ready_set_.rd_mask_.reset (); + this->ready_set_.wr_mask_.reset (); + this->ready_set_.ex_mask_.reset (); + + this->state_changed_ = false; + } + else + { + // This is a hack... somewhere, under certain conditions (which + // I don't understand...) the mask will have all of its bits clear, + // yet have a size_ > 0. This is an attempt to remedy the affect, + // without knowing why it happens. + + this->ready_set_.rd_mask_.sync (this->ready_set_.rd_mask_.max_set ()); + this->ready_set_.wr_mask_.sync (this->ready_set_.wr_mask_.max_set ()); + this->ready_set_.ex_mask_.sync (this->ready_set_.ex_mask_.max_set ()); + } + + return this->wait_for_multiple_events (this->ready_set_, max_wait_time); +} + +int +ACE_TP_Reactor::get_socket_event_info (ACE_EH_Dispatch_Info &event) +{ + // Check for dispatch in write, except, read. Only catch one, but if + // one is caught, be sure to clear the handle from each mask in case + // there is more than one mask set for it. This would cause problems + // if the handler is suspended for dispatching, but its set bit in + // another part of ready_set_ kept it from being dispatched. + int found_io = 0; + ACE_HANDLE handle; + + // @@todo: We can do quite a bit of code reduction here. Let me get + // it to work before I do this. + { + ACE_Handle_Set_Iterator handle_iter (this->ready_set_.wr_mask_); + + while (!found_io && (handle = handle_iter ()) != ACE_INVALID_HANDLE) + { + if (this->is_suspended_i (handle)) + continue; + + // Remember this info + event.set (handle, + this->handler_rep_.find (handle), + ACE_Event_Handler::WRITE_MASK, + &ACE_Event_Handler::handle_output); + + this->clear_handle_read_set (handle); + found_io = 1; + } + } + + if (!found_io) + { + ACE_Handle_Set_Iterator handle_iter (this->ready_set_.ex_mask_); + + while (!found_io && (handle = handle_iter ()) != ACE_INVALID_HANDLE) + { + if (this->is_suspended_i (handle)) + continue; + + // Remember this info + event.set (handle, + this->handler_rep_.find (handle), + ACE_Event_Handler::EXCEPT_MASK, + &ACE_Event_Handler::handle_exception); + + this->clear_handle_read_set (handle); + + found_io = 1; + } + } + + if (!found_io) + { + ACE_Handle_Set_Iterator handle_iter (this->ready_set_.rd_mask_); + + while (!found_io && (handle = handle_iter ()) != ACE_INVALID_HANDLE) + { + if (this->is_suspended_i (handle)) + continue; + + // Remember this info + event.set (handle, + this->handler_rep_.find (handle), + ACE_Event_Handler::READ_MASK, + &ACE_Event_Handler::handle_input); + + this->clear_handle_read_set (handle); + found_io = 1; + } + } + + return found_io; +} + +// Dispatches a single event handler +int +ACE_TP_Reactor::dispatch_socket_event (ACE_EH_Dispatch_Info &dispatch_info) +{ + ACE_TRACE ("ACE_TP_Reactor::dispatch_socket_event"); + + ACE_Event_Handler * const event_handler = dispatch_info.event_handler_; + ACE_EH_PTMF const callback = dispatch_info.callback_; + + // Check for removed handlers. + if (event_handler == 0) + return -1; + + // Upcall. If the handler returns positive value (requesting a + // reactor callback) don't set the ready-bit because it will be + // ignored if the reactor state has changed. Just call back + // as many times as the handler requests it. Other threads are off + // handling other things. + int status = 1; + while (status > 0) + status = (event_handler->*callback) (dispatch_info.handle_); + + // Post process socket event + return this->post_process_socket_event (dispatch_info, status); +} + +int +ACE_TP_Reactor::post_process_socket_event (ACE_EH_Dispatch_Info &dispatch_info, + int status) +{ + int result = 0; + + // First check if we really have to post process something, if not, then + // we don't acquire the token which saves us a lot of time. + if (status < 0 || + (dispatch_info.event_handler_ != this->notify_handler_ && + dispatch_info.resume_flag_ == + ACE_Event_Handler::ACE_REACTOR_RESUMES_HANDLER)) + { + // Get the reactor token and with this token acquired remove first the + // handler and resume it at the same time. This must be atomic, see also + // bugzilla 2395. When this is not atomic it can be that we resume the + // handle after it is reused by the OS. + ACE_TP_Token_Guard guard (this->token_); + + result = guard.acquire_token (); + + // If the guard is NOT the owner just return the retval + if (!guard.is_owner ()) + return result; + + // A different event handler may have been registered during the + // upcall if the handle was closed and then reopened, for + // example. Make sure we're removing and/or resuming the event + // handler used during the upcall. + ACE_Event_Handler const * const eh = + this->handler_rep_.find (dispatch_info.handle_); + + // Only remove or resume the event handler used during the + // upcall. + if (eh == dispatch_info.event_handler_) + { + if (status < 0) + { + result = + this->remove_handler_i (dispatch_info.handle_, + dispatch_info.mask_); + } + + // Resume handler if required. + if (dispatch_info.event_handler_ != this->notify_handler_ && + dispatch_info.resume_flag_ == + ACE_Event_Handler::ACE_REACTOR_RESUMES_HANDLER) + this->resume_i (dispatch_info.handle_); + } + } + + // Call remove_reference() if needed. + if (dispatch_info.reference_counting_required_) + dispatch_info.event_handler_->remove_reference (); + + return result; +} + +int +ACE_TP_Reactor::resumable_handler (void) +{ + return 1; +} + +int +ACE_TP_Reactor::handle_events (ACE_Time_Value &max_wait_time) +{ + return this->handle_events (&max_wait_time); +} + +void +ACE_TP_Reactor::notify_handle (ACE_HANDLE, + ACE_Reactor_Mask, + ACE_Handle_Set &, + ACE_Event_Handler *eh, + ACE_EH_PTMF) +{ + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("ACE_TP_Reactor::notify_handle: ") + ACE_TEXT ("Wrong version of notify_handle() got called \n"))); + + ACE_ASSERT (eh == 0); + ACE_UNUSED_ARG (eh); +} + +ACE_HANDLE +ACE_TP_Reactor::get_notify_handle (void) +{ + // Call the notify handler to get a handle on which we would have a + // notify waiting + ACE_HANDLE const read_handle = + this->notify_handler_->notify_handle (); + + // Check whether the rd_mask has been set on that handle. If so + // return the handle. + if (read_handle != ACE_INVALID_HANDLE && + this->ready_set_.rd_mask_.is_set (read_handle)) + { + return read_handle; + } + + // None found.. + return ACE_INVALID_HANDLE; +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/TP_Reactor.h b/dep/ACE_wrappers/ace/TP_Reactor.h new file mode 100644 index 00000000000..a5994017e3d --- /dev/null +++ b/dep/ACE_wrappers/ace/TP_Reactor.h @@ -0,0 +1,320 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file TP_Reactor.h + * + * $Id: TP_Reactor.h 82393 2008-07-23 10:52:34Z johnnyw $ + * + * The ACE_TP_Reactor (aka, Thread Pool Reactor) uses the + * Leader/Followers pattern to demultiplex events among a pool of + * threads. When using a thread pool reactor, an application + * pre-spawns a fixed number of threads. When these threads + * invoke the ACE_TP_Reactor's handle_events() method, one thread + * will become the leader and wait for an event. The other + * follower threads will queue up waiting for their turn to become + * the leader. When an event occurs, the leader will pick a + * follower to become the leader and go on to handle the event. + * The consequence of using ACE_TP_Reactor is the amortization of + * the costs used to create threads. The context switching cost + * will also reduce. Moreover, the total resources used by + * threads are bounded because there are a fixed number of threads. + * + * @author Irfan Pyarali + * @author Nanbor Wang + */ +//============================================================================= + + +#ifndef ACE_TP_REACTOR_H +#define ACE_TP_REACTOR_H + +#include /**/ "ace/pre.h" + +#include "ace/Select_Reactor.h" +#include "ace/Timer_Queue.h" /* Simple forward decl won't work... */ + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +/** + * @class ACE_EH_Dispatch_Info + * + * @brief This structure contains information of the activated event + * handler. + */ +class ACE_EH_Dispatch_Info +{ +public: + ACE_EH_Dispatch_Info (void); + + void set (ACE_HANDLE handle, + ACE_Event_Handler *event_handler, + ACE_Reactor_Mask mask, + ACE_EH_PTMF callback); + + bool dispatch (void) const; + + ACE_HANDLE handle_; + ACE_Event_Handler *event_handler_; + ACE_Reactor_Mask mask_; + ACE_EH_PTMF callback_; + int resume_flag_; + bool reference_counting_required_; + +private: + bool dispatch_; + + // Disallow copying and assignment. + ACE_EH_Dispatch_Info (const ACE_EH_Dispatch_Info &); + ACE_EH_Dispatch_Info &operator= (const ACE_EH_Dispatch_Info &); +}; + + +/** + * @class ACE_TP_Token_Guard + * + * @brief A helper class that helps grabbing, releasing and waiting + * on tokens for a thread that tries calling handle_events (). + * + * In short, this class will be owned by one thread by creating on the + * stack. This class gives the status of the ownership of the token + * and manages the ownership + */ + +class ACE_TP_Token_Guard +{ +public: + + /// Constructor that will grab the token for us + ACE_TP_Token_Guard (ACE_Select_Reactor_Token &token); + + /// Destructor. This will release the token if it hasnt been + /// released till this point + ~ACE_TP_Token_Guard (void); + + /// Release the token .. + void release_token (void); + + /// Returns whether the thread that created this object ownes the + /// token or not. + bool is_owner (void); + + /// A helper method that grabs the token for us, after which the + /// thread that owns that can do some actual work. + int acquire_read_token (ACE_Time_Value *max_wait_time = 0); + + /** + * A helper method that grabs the token for us, after which the + * thread that owns that can do some actual work. This differs from + * acquire_read_token() as it uses acquire () to get the token instead of + * acquire_read () + */ + int acquire_token (ACE_Time_Value *max_wait_time = 0); + +private: + + // Disallow default construction. + ACE_TP_Token_Guard (void); + + // Disallow copying and assignment. + ACE_TP_Token_Guard (const ACE_TP_Token_Guard &); + ACE_TP_Token_Guard &operator= (const ACE_TP_Token_Guard &); + +private: + + /// The Select Reactor token. + ACE_Select_Reactor_Token &token_; + + /// Flag that indicate whether the thread that created this object + /// owns the token or not. A value of false indicates that this class + /// hasnt got the token (and hence the thread) and a value of true + /// vice-versa. + bool owner_; + +}; + +/** + * @class ACE_TP_Reactor + * + * @brief Specialization of ACE_Select_Reactor to support thread-pool + * based event dispatching. + * + * One of the shortcomings of the ACE_Select_Reactor is that it + * does not support a thread pool-based event dispatching model, + * similar to the one in ACE_WFMO_Reactor. In ACE_Select_Reactor, only + * thread can call handle_events() at any given time. ACE_TP_Reactor + * removes this short-coming. + * + * ACE_TP_Reactor is a specialization of ACE_Select_Reactor to support + * thread pool-based event dispatching. This reactor takes advantage + * of the fact that events reported by @c select() are persistent if not + * acted upon immediately. It works by remembering the event handler + * which was just activated, suspending it for further I/O activities, + * releasing the internal lock (so that another thread can start waiting + * in the event loop) and then dispatching the event's handler outside the + * scope of the reactor lock. After the event handler has been dispatched + * the event handler is resumed for further I/O activity. + * + * This reactor implementation is best suited for situations when the + * callbacks to event handlers can take arbitrarily long and/or a number + * of threads are available to run the event loop. Note that I/O-processing + * callback code in event handlers (e.g. handle_input()) does not have to + * be modified or made thread-safe for this reactor. This is because + * before an I/O event is dispatched to an event handler, the handler is + * suspended; it is resumed by the reactor after the upcall completes. + * Therefore, multiple I/O events will not be made to one event handler + * multiple threads simultaneously. This suspend/resume protection does not + * apply to either timers scheduled with the reactor or to notifications + * requested via the reactor. When using timers and/or notifications you + * must provide proper protection for your class in the context of multiple + * threads. + */ +class ACE_Export ACE_TP_Reactor : public ACE_Select_Reactor +{ +public: + + /// Initialize ACE_TP_Reactor with the default size. + ACE_TP_Reactor (ACE_Sig_Handler * = 0, + ACE_Timer_Queue * = 0, + bool mask_signals = true, + int s_queue = ACE_Select_Reactor_Token::FIFO); + + /** + * Initialize the ACE_TP_Reactor to manage + * @a max_number_of_handles. If @a restart is non-0 then the + * ACE_Reactor's @c handle_events() method will be restarted + * automatically when @c EINTR occurs. If @a sh or + * @a tq are non-0 they are used as the signal handler and + * timer queue, respectively. + */ + ACE_TP_Reactor (size_t max_number_of_handles, + int restart = 0, + ACE_Sig_Handler *sh = 0, + ACE_Timer_Queue *tq = 0, + bool mask_signals = true, + int s_queue = ACE_Select_Reactor_Token::FIFO); + + /** + * This event loop driver that blocks for @a max_wait_time before + * returning. It will return earlier if timer events, I/O events, + * or signal events occur. Note that @a max_wait_time can be 0, in + * which case this method blocks indefinitely until events occur. + * + * @a max_wait_time is decremented to reflect how much time this call + * took. For instance, if a time value of 3 seconds is passed to + * handle_events and an event occurs after 2 seconds, + * @a max_wait_time will equal 1 second. This can be used if an + * application wishes to handle events for some fixed amount of + * time. + * + * @return The total number of events that were dispatched; 0 if the + * @a max_wait_time elapsed without dispatching any handlers, or -1 + * if an error occurs (check @c errno for more information). + */ + virtual int handle_events (ACE_Time_Value *max_wait_time = 0); + + virtual int handle_events (ACE_Time_Value &max_wait_time); + + /// Does the reactor allow the application to resume the handle on + /// its own ie. can it pass on the control of handle resumption to + /// the application. The TP reactor has can allow applications to + /// resume handles. So return a positive value. + virtual int resumable_handler (void); + + /// Called from handle events + static void no_op_sleep_hook (void *); + + /// The ACE_TP_Reactor implementation does not have a single owner thread. + /// Attempts to set the owner explicitly are ignored. The reported owner + /// thread is the current Leader in the pattern. + virtual int owner (ACE_thread_t n_id, ACE_thread_t *o_id = 0); + + /// Return the thread ID of the current Leader. + virtual int owner (ACE_thread_t *t_id); + + /// Declare the dynamic allocation hooks. + ACE_ALLOC_HOOK_DECLARE; + +protected: + // = Internal methods that do the actual work. + + /// Template method from the base class. + virtual void clear_dispatch_mask (ACE_HANDLE handle, + ACE_Reactor_Mask mask); + + /// Dispatch just 1 signal, timer, notification handlers + int dispatch_i (ACE_Time_Value *max_wait_time, + ACE_TP_Token_Guard &guard); + + /// Get the event that needs dispatching. It could be either a + /// signal, timer, notification handlers or return possibly 1 I/O + /// handler for dispatching. In the most common use case, this would + /// return 1 I/O handler for dispatching + int get_event_for_dispatching (ACE_Time_Value *max_wait_time); + +#if 0 + // @Ciju + // signal handling isn't in a production state yet. + // Commenting it out for now. + + /// Method to handle signals + /// @note It is just busted at this point in time. + int handle_signals (int &event_count, + ACE_TP_Token_Guard &g); +#endif // #if 0 + + /// Handle timer events + int handle_timer_events (int &event_count, + ACE_TP_Token_Guard &g); + + /// Handle notify events + int handle_notify_events (int &event_count, + ACE_TP_Token_Guard &g); + + /// handle socket events + int handle_socket_events (int &event_count, + ACE_TP_Token_Guard &g); + + /// This method shouldn't get called. + virtual void notify_handle (ACE_HANDLE handle, + ACE_Reactor_Mask mask, + ACE_Handle_Set &, + ACE_Event_Handler *eh, + ACE_EH_PTMF callback); +private: + + /// Get the handle of the notify pipe from the ready set if there is + /// an event in the notify pipe. + ACE_HANDLE get_notify_handle (void); + + /// Get socket event dispatch information. + int get_socket_event_info (ACE_EH_Dispatch_Info &info); + + /// Notify the appropriate in the context of the + /// associated with that a particular event has occurred. + int dispatch_socket_event (ACE_EH_Dispatch_Info &dispatch_info); + + /// Clear the @a handle from the read_set + void clear_handle_read_set (ACE_HANDLE handle); + + int post_process_socket_event (ACE_EH_Dispatch_Info &dispatch_info,int status); + +private: + /// Deny access since member-wise won't work... + ACE_TP_Reactor (const ACE_TP_Reactor &); + ACE_TP_Reactor &operator = (const ACE_TP_Reactor &); +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +#include "ace/TP_Reactor.inl" +#endif /* __ACE_INLINE__ */ + +#include /**/ "ace/post.h" + +#endif /* ACE_TP_REACTOR_H */ diff --git a/dep/ACE_wrappers/ace/TP_Reactor.inl b/dep/ACE_wrappers/ace/TP_Reactor.inl new file mode 100644 index 00000000000..2b14a8c9b96 --- /dev/null +++ b/dep/ACE_wrappers/ace/TP_Reactor.inl @@ -0,0 +1,119 @@ +// -*- C++ -*- +// +// $Id: TP_Reactor.inl 80826 2008-03-04 14:51:23Z wotte $ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +/************************************************************************/ +// Methods for ACE_EH_Dispatch_Info +/************************************************************************/ + +ACE_INLINE +ACE_EH_Dispatch_Info::ACE_EH_Dispatch_Info (void) : + handle_ (ACE_INVALID_HANDLE), + event_handler_ (0), + mask_ (ACE_Event_Handler::NULL_MASK), + callback_ (0), + resume_flag_ (ACE_Event_Handler::ACE_REACTOR_RESUMES_HANDLER), + reference_counting_required_ (false), + dispatch_ (false) +{ +} + +ACE_INLINE void +ACE_EH_Dispatch_Info::set (ACE_HANDLE handle, + ACE_Event_Handler *event_handler, + ACE_Reactor_Mask mask, + ACE_EH_PTMF callback) +{ + this->dispatch_ = true; + + this->handle_ = handle; + this->event_handler_ = event_handler; + this->mask_ = mask; + this->callback_ = callback; + if (event_handler_) + { + this->resume_flag_ = event_handler->resume_handler (); + this->reference_counting_required_ = + (event_handler_->reference_counting_policy ().value () == + ACE_Event_Handler::Reference_Counting_Policy::ENABLED); + } + else + this->dispatch_ = false; +} + +ACE_INLINE bool +ACE_EH_Dispatch_Info::dispatch (void) const +{ + return this->dispatch_; +} + +/************************************************************************/ +// Methods for ACE_TP_Token_Guard +/************************************************************************/ + +ACE_INLINE +ACE_TP_Token_Guard::ACE_TP_Token_Guard (ACE_Select_Reactor_Token &token) + + : token_ (token), + owner_ (false) +{ +} + +ACE_INLINE +ACE_TP_Token_Guard::~ACE_TP_Token_Guard (void) +{ + if (this->owner_) + { + ACE_MT (this->token_.release ()); + this->owner_ = false; + } +} + +ACE_INLINE void +ACE_TP_Token_Guard::release_token (void) +{ + if (this->owner_) + { + ACE_MT (this->token_.release ()); + + // We are not the owner anymore.. + this->owner_ = false; + } +} + +ACE_INLINE bool +ACE_TP_Token_Guard::is_owner (void) +{ + return this->owner_; +} + + +/************************************************************************/ +// Methods for ACE_TP_Reactor +/************************************************************************/ + +ACE_INLINE void +ACE_TP_Reactor::no_op_sleep_hook (void *) +{ +} + +ACE_INLINE void +ACE_TP_Reactor::clear_handle_read_set (ACE_HANDLE handle) +{ + this->ready_set_.wr_mask_.clr_bit (handle); + this->ready_set_.ex_mask_.clr_bit (handle); + this->ready_set_.rd_mask_.clr_bit (handle); +} + +ACE_INLINE void +ACE_TP_Reactor::clear_dispatch_mask (ACE_HANDLE , + ACE_Reactor_Mask ) +{ + this->ready_set_.rd_mask_.reset (); + this->ready_set_.wr_mask_.reset (); + this->ready_set_.ex_mask_.reset (); +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/TSS_Adapter.cpp b/dep/ACE_wrappers/ace/TSS_Adapter.cpp new file mode 100644 index 00000000000..da6218dddb8 --- /dev/null +++ b/dep/ACE_wrappers/ace/TSS_Adapter.cpp @@ -0,0 +1,45 @@ +/** + * @file TSS_Adapter.cpp + * + * $Id: TSS_Adapter.cpp 80826 2008-03-04 14:51:23Z wotte $ + * + * Originally in Synch.cpp + * + * @author Douglas C. Schmidt + */ + +#include "ace/TSS_Adapter.h" + +ACE_RCSID(ace, TSS_Adapter, "$Id: TSS_Adapter.cpp 80826 2008-03-04 14:51:23Z wotte $") + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_TSS_Adapter::ACE_TSS_Adapter (void *object, ACE_THR_DEST f) + : ts_obj_ (object), + func_ (f) +{ + // ACE_TRACE ("ACE_TSS_Adapter::ACE_TSS_Adapter"); +} + +void +ACE_TSS_Adapter::cleanup (void) +{ + // ACE_TRACE ("ACE_TSS_Adapter::cleanup"); + (*this->func_)(this->ts_obj_); // call cleanup routine for ts_obj_ +} + +ACE_END_VERSIONED_NAMESPACE_DECL + +extern "C" void +ACE_TSS_C_cleanup (void *object) +{ + // ACE_TRACE ("ACE_TSS_C_cleanup"); + if (object != 0) + { + ACE_TSS_Adapter * const tss_adapter = (ACE_TSS_Adapter *) object; + // Perform cleanup on the real TS object. + tss_adapter->cleanup (); + // Delete the adapter object. + delete tss_adapter; + } +} diff --git a/dep/ACE_wrappers/ace/TSS_Adapter.h b/dep/ACE_wrappers/ace/TSS_Adapter.h new file mode 100644 index 00000000000..b8ff85e3210 --- /dev/null +++ b/dep/ACE_wrappers/ace/TSS_Adapter.h @@ -0,0 +1,61 @@ +// -*- C++ -*- + +//========================================================================== +/** + * @file TSS_Adapter.h + * + * $Id: TSS_Adapter.h 80826 2008-03-04 14:51:23Z wotte $ + * + * Originally in Synch.h + * + * @author Douglas C. Schmidt + */ +//========================================================================== + +#ifndef ACE_TSS_ADAPTER_H +#define ACE_TSS_ADAPTER_H +#include /**/ "ace/pre.h" + +#include /**/ "ace/ACE_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +/** + * @class ACE_TSS_Adapter + * + * @brief This class encapsulates a TSS object and its associated + * C++ destructor function. It is used by the ACE_TSS... + * methods (in Synch_T.cpp) in order to allow an extern + * "C" cleanup routine to be used. Needed by the "frigging" + * MVS C++ compiler. + * + * Objects of this class are stored in thread specific + * storage. ts_obj_ points to the "real" object and + * func_ is a pointer to the C++ cleanup function for ts_obj_. + */ +class ACE_Export ACE_TSS_Adapter +{ +public: + /// Initialize the adapter. + ACE_TSS_Adapter (void *object, ACE_THR_DEST f); + + /// Perform the cleanup operation. + void cleanup (void); + +//private: + + /// The real TS object. + void * const ts_obj_; + + /// The real cleanup routine for ts_obj; + ACE_THR_DEST func_; +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#include /**/ "ace/post.h" +#endif /* ACE_TSS_ADAPTER_H */ diff --git a/dep/ACE_wrappers/ace/TSS_T.cpp b/dep/ACE_wrappers/ace/TSS_T.cpp new file mode 100644 index 00000000000..7ef74538aac --- /dev/null +++ b/dep/ACE_wrappers/ace/TSS_T.cpp @@ -0,0 +1,725 @@ +// $Id: TSS_T.cpp 82508 2008-08-05 13:52:48Z johnnyw $ + +#ifndef ACE_TSS_T_CPP +#define ACE_TSS_T_CPP + +#include "ace/TSS_T.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#if !defined (__ACE_INLINE__) +#include "ace/TSS_T.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/Thread.h" +#include "ace/Log_Msg.h" +#include "ace/Guard_T.h" +#include "ace/OS_NS_stdio.h" + +#if defined (ACE_HAS_THR_C_DEST) +# include "ace/TSS_Adapter.h" +#endif /* ACE_HAS_THR_C_DEST */ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_ALLOC_HOOK_DEFINE(ACE_TSS) + +template +ACE_TSS::~ACE_TSS (void) +{ +#if defined (ACE_HAS_THREADS) && (defined (ACE_HAS_THREAD_SPECIFIC_STORAGE) || defined (ACE_HAS_TSS_EMULATION)) + if (this->once_) + { + ACE_OS::thr_key_detach (this->key_, this); + ACE_OS::thr_keyfree (this->key_); + } +#else // defined (ACE_HAS_THREADS) && (defined (ACE_HAS_THREAD_SPECIFIC_STORAGE) || defined (ACE_HAS_TSS_EMULATION)) + // We own it, we need to delete it. + delete type_; +#endif // defined (ACE_HAS_THREADS) && (defined (ACE_HAS_THREAD_SPECIFIC_STORAGE) || defined (ACE_HAS_TSS_EMULATION)) +} + +template TYPE * +ACE_TSS::operator-> () const +{ + return this->ts_get (); +} + +template +ACE_TSS::operator TYPE *(void) const +{ + return this->ts_get (); +} + +template TYPE * +ACE_TSS::make_TSS_TYPE (void) const +{ + TYPE *temp = 0; + ACE_NEW_RETURN (temp, + TYPE, + 0); + return temp; +} + +template void +ACE_TSS::dump (void) const +{ +#if defined (ACE_HAS_DUMP) +// ACE_TRACE ("ACE_TSS::dump"); +#if defined (ACE_HAS_THREADS) && (defined (ACE_HAS_THREAD_SPECIFIC_STORAGE) || defined (ACE_HAS_TSS_EMULATION)) + ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); + this->keylock_.dump (); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("key_ = %d\n"), this->key_)); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nonce_ = %d"), this->once_)); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\n"))); + ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); +#endif /* defined (ACE_HAS_THREADS) && (defined (ACE_HAS_THREAD_SPECIFIC_STORAGE) || defined (ACE_HAS_TSS_EMULATION)) */ +#endif /* ACE_HAS_DUMP */ +} + +#if defined (ACE_HAS_THREADS) && (defined (ACE_HAS_THREAD_SPECIFIC_STORAGE) || defined (ACE_HAS_TSS_EMULATION)) +#if defined (ACE_HAS_THR_C_DEST) +extern "C" void ACE_TSS_C_cleanup (void *); // defined in Synch.cpp +#endif /* ACE_HAS_THR_C_DEST */ + +template void +ACE_TSS::cleanup (void *ptr) +{ + // Cast this to the concrete TYPE * so the destructor gets called. + delete (TYPE *) ptr; +} + +template int +ACE_TSS::ts_init (void) +{ + // Ensure that we are serialized! + ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->keylock_, 0); + + // Use the Double-Check pattern to make sure we only create the key + // once! + if (!this->once_) + { + if (ACE_Thread::keycreate (&this->key_, +#if defined (ACE_HAS_THR_C_DEST) + &ACE_TSS_C_cleanup, +#else + &ACE_TSS::cleanup, +#endif /* ACE_HAS_THR_C_DEST */ + (void *) this) != 0) + return -1; // Major problems, this should *never* happen! + else + { + // This *must* come last to avoid race conditions! + this->once_ = true; + return 0; + } + } + + return 0; +} + +template +ACE_TSS::ACE_TSS (TYPE *ts_obj) + : once_ (false), + key_ (ACE_OS::NULL_key) +{ + // If caller has passed us a non-NULL TYPE *, then we'll just use + // this to initialize the thread-specific value. Thus, subsequent + // calls to operator->() will return this value. This is useful + // since it enables us to assign objects to thread-specific data + // that have arbitrarily complex constructors! + + if (ts_obj != 0) + { + if (this->ts_init () == -1) + { + // Save/restore errno. + ACE_Errno_Guard error (errno); + // What should we do if this call fails?! +#if defined (ACE_HAS_WINCE) + ::MessageBox (0, + ACE_TEXT ("ACE_Thread::keycreate() failed!"), + ACE_TEXT ("ACE_TSS::ACE_TSS"), + MB_OK); +#else + ACE_OS::fprintf (stderr, + "ACE_Thread::keycreate() failed!"); +#endif /* ACE_HAS_WINCE */ + return; + } + +#if defined (ACE_HAS_THR_C_DEST) + // Encapsulate a ts_obj and it's destructor in an + // ACE_TSS_Adapter. + ACE_TSS_Adapter *tss_adapter = 0; + ACE_NEW (tss_adapter, + ACE_TSS_Adapter ((void *) ts_obj, + ACE_TSS::cleanup)); + + // Put the adapter in thread specific storage + if (ACE_Thread::setspecific (this->key_, + (void *) tss_adapter) != 0) + { + delete tss_adapter; + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("%p\n"), + ACE_TEXT ("ACE_Thread::setspecific() failed!"))); + } +#else + if (ACE_Thread::setspecific (this->key_, + (void *) ts_obj) != 0) + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("%p\n"), + ACE_TEXT ("ACE_Thread::setspecific() failed!"))); +#endif /* ACE_HAS_THR_C_DEST */ + } +} + +template TYPE * +ACE_TSS::ts_get (void) const +{ + if (!this->once_) + { + // Create and initialize thread-specific ts_obj. + if (const_cast< ACE_TSS < TYPE > * >(this)->ts_init () == -1) + // Seriously wrong.. + return 0; + } + + TYPE *ts_obj = 0; + +#if defined (ACE_HAS_THR_C_DEST) + ACE_TSS_Adapter *tss_adapter = 0; + + // Get the adapter from thread-specific storage + void *temp = tss_adapter; // Need this temp to keep G++ from complaining. + if (ACE_Thread::getspecific (this->key_, &temp) == -1) + return 0; // This should not happen! + tss_adapter = static_cast (temp); + + // Check to see if this is the first time in for this thread. + if (tss_adapter == 0) +#else + // Get the ts_obj from thread-specific storage. Note that no locks + // are required here... + void *temp = ts_obj; // Need this temp to keep G++ from complaining. + if (ACE_Thread::getspecific (this->key_, &temp) == -1) + return 0; // This should not happen! + ts_obj = static_cast (temp); + + // Check to see if this is the first time in for this thread. + if (ts_obj == 0) +#endif /* ACE_HAS_THR_C_DEST */ + { + // Allocate memory off the heap and store it in a pointer in + // thread-specific storage (on the stack...). + + ts_obj = this->make_TSS_TYPE (); + + if (ts_obj == 0) + return 0; + +#if defined (ACE_HAS_THR_C_DEST) + // Encapsulate a ts_obj and it's destructor in an + // ACE_TSS_Adapter. + ACE_NEW_RETURN (tss_adapter, + ACE_TSS_Adapter (ts_obj, + ACE_TSS::cleanup), 0); + + // Put the adapter in thread specific storage + if (ACE_Thread::setspecific (this->key_, + (void *) tss_adapter) != 0) + { + delete tss_adapter; + delete ts_obj; + return 0; // Major problems, this should *never* happen! + } +#else + // Store the dynamically allocated pointer in thread-specific + // storage. + if (ACE_Thread::setspecific (this->key_, + (void *) ts_obj) != 0) + { + delete ts_obj; + return 0; // Major problems, this should *never* happen! + } +#endif /* ACE_HAS_THR_C_DEST */ + } + +#if defined (ACE_HAS_THR_C_DEST) + // Return the underlying ts object. + return static_cast (tss_adapter->ts_obj_); +#else + return ts_obj; +#endif /* ACE_HAS_THR_C_DEST */ +} + +// Get the thread-specific object for the key associated with this +// object. Returns 0 if the ts_obj has never been initialized, +// otherwise returns a pointer to the ts_obj. + +template TYPE * +ACE_TSS::ts_object (void) const +{ + if (!this->once_) // Return 0 if we've never been initialized. + return 0; + + TYPE *ts_obj = 0; + +#if defined (ACE_HAS_THR_C_DEST) + ACE_TSS_Adapter *tss_adapter = 0; + + // Get the tss adapter from thread-specific storage + void *temp = tss_adapter; // Need this temp to keep G++ from complaining. + if (ACE_Thread::getspecific (this->key_, &temp) == -1) + { + return 0; // This should not happen! + } + else + { + tss_adapter = static_cast (temp); + { + if (tss_adapter != 0) + // Extract the real TS object. + ts_obj = static_cast (tss_adapter->ts_obj_); + } + } +#else + void *temp = ts_obj; // Need this temp to keep G++ from complaining. + if (ACE_Thread::getspecific (this->key_, &temp) == -1) + return 0; // This should not happen! + ts_obj = static_cast (temp); +#endif /* ACE_HAS_THR_C_DEST */ + + return ts_obj; +} + +template TYPE * +ACE_TSS::ts_object (TYPE *new_ts_obj) +{ + // Note, we shouldn't hold the keylock at this point because + // does it for us and we'll end up with deadlock + // otherwise... + if (!this->once_) + { + // Create and initialize thread-specific ts_obj. + if (this->ts_init () == -1) + return 0; + } + + TYPE *ts_obj = 0; + +#if defined (ACE_HAS_THR_C_DEST) + ACE_TSS_Adapter *tss_adapter = 0; + + void *temp = tss_adapter; // Need this temp to keep G++ from complaining. + if (ACE_Thread::getspecific (this->key_, &temp) == -1) + return 0; // This should not happen! + tss_adapter = static_cast (temp); + + if (tss_adapter != 0) + { + ts_obj = static_cast (tss_adapter->ts_obj_); + delete tss_adapter; // don't need this anymore + } + + ACE_NEW_RETURN (tss_adapter, + ACE_TSS_Adapter ((void *) new_ts_obj, + ACE_TSS::cleanup), + 0); + + if (ACE_Thread::setspecific (this->key_, + (void *) tss_adapter) == -1) + { + delete tss_adapter; + return ts_obj; // This should not happen! + } +#else + void *temp = ts_obj; // Need this temp to keep G++ from complaining. + if (ACE_Thread::getspecific (this->key_, &temp) == -1) + return 0; // This should not happen! + ts_obj = static_cast (temp); + if (ACE_Thread::setspecific (this->key_, (void *) new_ts_obj) == -1) + return ts_obj; // This should not happen! +#endif /* ACE_HAS_THR_C_DEST */ + + return ts_obj; +} + +ACE_ALLOC_HOOK_DEFINE(ACE_TSS_Guard) + +template void +ACE_TSS_Guard::dump (void) const +{ +#if defined (ACE_HAS_DUMP) +// ACE_TRACE ("ACE_TSS_Guard::dump"); + + ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("key_ = %d"), this->key_)); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\n"))); + ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); +#endif /* ACE_HAS_DUMP */ +} + +template void +ACE_TSS_Guard::init_key (void) +{ +// ACE_TRACE ("ACE_TSS_Guard::init_key"); + + this->key_ = ACE_OS::NULL_key; + ACE_Thread::keycreate (&this->key_, +#if defined (ACE_HAS_THR_C_DEST) + &ACE_TSS_C_cleanup, +#else + &ACE_TSS_Guard::cleanup, +#endif /* ACE_HAS_THR_C_DEST */ + (void *) this); +} + +template +ACE_TSS_Guard::ACE_TSS_Guard (void) +{ +// ACE_TRACE ("ACE_TSS_Guard::ACE_TSS_Guard"); + this->init_key (); +} + +template int +ACE_TSS_Guard::release (void) +{ +// ACE_TRACE ("ACE_TSS_Guard::release"); + + ACE_Guard *guard = 0; + +#if defined (ACE_HAS_THR_C_DEST) + ACE_TSS_Adapter *tss_adapter = 0; + void *temp = tss_adapter; // Need this temp to keep G++ from complaining. + ACE_Thread::getspecific (this->key_, &temp); + tss_adapter = static_cast (temp); + guard = static_cast *> (tss_adapter->ts_obj_); +#else + void *temp = guard; // Need this temp to keep G++ from complaining. + ACE_Thread::getspecific (this->key_, &temp); + guard = static_cast *> (temp); +#endif /* ACE_HAS_THR_C_DEST */ + + return guard->release (); +} + +template int +ACE_TSS_Guard::remove (void) +{ +// ACE_TRACE ("ACE_TSS_Guard::remove"); + + ACE_Guard *guard = 0; + +#if defined (ACE_HAS_THR_C_DEST) + ACE_TSS_Adapter *tss_adapter = 0; + void *temp = tss_adapter; // Need this temp to keep G++ from complaining. + ACE_Thread::getspecific (this->key_, &temp); + tss_adapter = static_cast (temp); + guard = static_cast *> (tss_adapter->ts_obj_); +#else + void *temp = guard; // Need this temp to keep G++ from complaining. + ACE_Thread::getspecific (this->key_, &temp); + guard = static_cast *> (temp); +#endif /* ACE_HAS_THR_C_DEST */ + + return guard->remove (); +} + +template +ACE_TSS_Guard::~ACE_TSS_Guard (void) +{ +// ACE_TRACE ("ACE_TSS_Guard::~ACE_TSS_Guard"); + + ACE_Guard *guard = 0; + +#if defined (ACE_HAS_THR_C_DEST) + ACE_TSS_Adapter *tss_adapter = 0; + void *temp = tss_adapter; // Need this temp to keep G++ from complaining. + ACE_Thread::getspecific (this->key_, &temp); + tss_adapter = static_cast (temp); + guard = static_cast *> (tss_adapter->ts_obj_); +#else + void *temp = guard; // Need this temp to keep G++ from complaining. + ACE_Thread::getspecific (this->key_, &temp); + guard = static_cast *> (temp); +#endif /* ACE_HAS_THR_C_DEST */ + + // Make sure that this pointer is NULL when we shut down... + ACE_Thread::setspecific (this->key_, 0); + ACE_Thread::keyfree (this->key_); + // Destructor releases lock. + delete guard; +} + +template void +ACE_TSS_Guard::cleanup (void *ptr) +{ +// ACE_TRACE ("ACE_TSS_Guard::cleanup"); + + // Destructor releases lock. + delete (ACE_Guard *) ptr; +} + +template +ACE_TSS_Guard::ACE_TSS_Guard (ACE_LOCK &lock, bool block) +{ +// ACE_TRACE ("ACE_TSS_Guard::ACE_TSS_Guard"); + + this->init_key (); + ACE_Guard *guard = 0; + ACE_NEW (guard, + ACE_Guard (lock, + block)); + +#if defined (ACE_HAS_THR_C_DEST) + ACE_TSS_Adapter *tss_adapter = 0; + ACE_NEW (tss_adapter, + ACE_TSS_Adapter ((void *) guard, + ACE_TSS_Guard::cleanup)); + ACE_Thread::setspecific (this->key_, + (void *) tss_adapter); +#else + ACE_Thread::setspecific (this->key_, + (void *) guard); +#endif /* ACE_HAS_THR_C_DEST */ +} + +template int +ACE_TSS_Guard::acquire (void) +{ +// ACE_TRACE ("ACE_TSS_Guard::acquire"); + + ACE_Guard *guard = 0; + +#if defined (ACE_HAS_THR_C_DEST) + ACE_TSS_Adapter *tss_adapter = 0; + void *temp = tss_adapter; // Need this temp to keep G++ from complaining. + ACE_Thread::getspecific (this->key_, &temp); + tss_adapter = static_cast (temp); + guard = static_cast *> (tss_adapter->ts_obj_); +#else + void *temp = guard; // Need this temp to keep G++ from complaining. + ACE_Thread::getspecific (this->key_, &temp); + guard = static_cast *> (temp); +#endif /* ACE_HAS_THR_C_DEST */ + + return guard->acquire (); +} + +template int +ACE_TSS_Guard::tryacquire (void) +{ +// ACE_TRACE ("ACE_TSS_Guard::tryacquire"); + + ACE_Guard *guard = 0; + +#if defined (ACE_HAS_THR_C_DEST) + ACE_TSS_Adapter *tss_adapter = 0; + void *temp = tss_adapter; // Need this temp to keep G++ from complaining. + ACE_Thread::getspecific (this->key_, &temp); + tss_adapter = static_cast (temp); + guard = static_cast *> (tss_adapter->ts_obj_); +#else + void *temp = guard; // Need this temp to keep G++ from complaining. + ACE_Thread::getspecific (this->key_, &temp); + guard = static_cast *> (temp); +#endif /* ACE_HAS_THR_C_DEST */ + + return guard->tryacquire (); +} + +template +ACE_TSS_Write_Guard::ACE_TSS_Write_Guard (ACE_LOCK &lock, + bool block) +{ +// ACE_TRACE ("ACE_TSS_Write_Guard::ACE_TSS_Write_Guard"); + + this->init_key (); + ACE_Guard *guard = 0; + ACE_NEW (guard, + ACE_Write_Guard (lock, + block)); + +#if defined (ACE_HAS_THR_C_DEST) + ACE_TSS_Adapter *tss_adapter = 0; + ACE_NEW (tss_adapter, + ACE_TSS_Adapter ((void *) guard, + ACE_TSS_Guard::cleanup)); + ACE_Thread::setspecific (this->key_, + (void *) tss_adapter); +#else + ACE_Thread::setspecific (this->key_, + (void *) guard); +#endif /* ACE_HAS_THR_C_DEST */ +} + +template int +ACE_TSS_Write_Guard::acquire (void) +{ +// ACE_TRACE ("ACE_TSS_Write_Guard::acquire"); + + ACE_Write_Guard *guard = 0; + +#if defined (ACE_HAS_THR_C_DEST) + ACE_TSS_Adapter *tss_adapter = 0; + void *temp = tss_adapter; // Need this temp to keep G++ from complaining. + ACE_Thread::getspecific (this->key_, &temp); + tss_adapter = static_cast (temp); + guard = static_cast *> (tss_adapter->ts_obj_); +#else + void *temp = guard; // Need this temp to keep G++ from complaining. + ACE_Thread::getspecific (this->key_, &temp); + guard = static_cast *> (temp); +#endif /* ACE_HAS_THR_C_DEST */ + + return guard->acquire_write (); +} + +template int +ACE_TSS_Write_Guard::tryacquire (void) +{ +// ACE_TRACE ("ACE_TSS_Write_Guard::tryacquire"); + + ACE_Write_Guard *guard = 0; + +#if defined (ACE_HAS_THR_C_DEST) + ACE_TSS_Adapter *tss_adapter = 0; + void *temp = tss_adapter; // Need this temp to keep G++ from complaining. + ACE_Thread::getspecific (this->key_, &temp); + tss_adapter = static_cast (temp); + guard = static_cast *> (tss_adapter->ts_obj_); +#else + void *temp = guard; // Need this temp to keep G++ from complaining. + ACE_Thread::getspecific (this->key_, &temp); + guard = static_cast *> (temp); +#endif /* ACE_HAS_THR_C_DEST */ + + return guard->tryacquire_write (); +} + +template int +ACE_TSS_Write_Guard::acquire_write (void) +{ +// ACE_TRACE ("ACE_TSS_Write_Guard::acquire_write"); + + return this->acquire (); +} + +template int +ACE_TSS_Write_Guard::tryacquire_write (void) +{ +// ACE_TRACE ("ACE_TSS_Write_Guard::tryacquire_write"); + + return this->tryacquire (); +} + +template void +ACE_TSS_Write_Guard::dump (void) const +{ +#if defined (ACE_HAS_DUMP) +// ACE_TRACE ("ACE_TSS_Write_Guard::dump"); + ACE_TSS_Guard::dump (); +#endif /* ACE_HAS_DUMP */ +} + +template +ACE_TSS_Read_Guard::ACE_TSS_Read_Guard (ACE_LOCK &lock, bool block) +{ +// ACE_TRACE ("ACE_TSS_Read_Guard::ACE_TSS_Read_Guard"); + + this->init_key (); + ACE_Guard *guard = 0; + ACE_NEW (guard, + ACE_Read_Guard (lock, + block)); +#if defined (ACE_HAS_THR_C_DEST) + ACE_TSS_Adapter *tss_adapter; + ACE_NEW (tss_adapter, + ACE_TSS_Adapter ((void *)guard, + ACE_TSS_Guard::cleanup)); + ACE_Thread::setspecific (this->key_, + (void *) tss_adapter); +#else + ACE_Thread::setspecific (this->key_, + (void *) guard); +#endif /* ACE_HAS_THR_C_DEST */ +} + +template int +ACE_TSS_Read_Guard::acquire (void) +{ +// ACE_TRACE ("ACE_TSS_Read_Guard::acquire"); + + ACE_Read_Guard *guard = 0; + +#if defined (ACE_HAS_THR_C_DEST) + ACE_TSS_Adapter *tss_adapter = 0; + void *temp = tss_adapter; // Need this temp to keep G++ from complaining. + ACE_Thread::getspecific (this->key_, &temp); + tss_adapter = static_cast (temp); + guard = static_cast *> (tss_adapter->ts_obj_); +#else + void *temp = guard; // Need this temp to keep G++ from complaining. + ACE_Thread::getspecific (this->key_, &temp); + guard = static_cast *> (temp); +#endif /* ACE_HAS_THR_C_DEST */ + + return guard->acquire_read (); +} + +template int +ACE_TSS_Read_Guard::tryacquire (void) +{ +// ACE_TRACE ("ACE_TSS_Read_Guard::tryacquire"); + + ACE_Read_Guard *guard = 0; + +#if defined (ACE_HAS_THR_C_DEST) + ACE_TSS_Adapter *tss_adapter = 0; + void *temp = tss_adapter; // Need this temp to keep G++ from complaining. + ACE_Thread::getspecific (this->key_, &temp); + tss_adapter = static_cast (temp); + guard = static_cast *> (tss_adapter->ts_obj_); +#else + void *temp = guard; // Need this temp to keep G++ from complaining. + ACE_Thread::getspecific (this->key_, &temp); + guard = static_cast *> (temp); +#endif /* ACE_HAS_THR_C_DEST */ + + return guard->tryacquire_read (); +} + +template int +ACE_TSS_Read_Guard::acquire_read (void) +{ +// ACE_TRACE ("ACE_TSS_Read_Guard::acquire_read"); + + return this->acquire (); +} + +template int +ACE_TSS_Read_Guard::tryacquire_read (void) +{ +// ACE_TRACE ("ACE_TSS_Read_Guard::tryacquire_read"); + + return this->tryacquire (); +} + +template void +ACE_TSS_Read_Guard::dump (void) const +{ +#if defined (ACE_HAS_DUMP) +// ACE_TRACE ("ACE_TSS_Read_Guard::dump"); + ACE_TSS_Guard::dump (); +#endif /* ACE_HAS_DUMP */ +} + +#endif /* defined (ACE_HAS_THREADS) && (defined (ACE_HAS_THREAD_SPECIFIC_STORAGE) || defined (ACE_HAS_TSS_EMULATION)) */ + +ACE_END_VERSIONED_NAMESPACE_DECL + +#endif /* ACE_TSS_T_CPP */ diff --git a/dep/ACE_wrappers/ace/TSS_T.h b/dep/ACE_wrappers/ace/TSS_T.h new file mode 100644 index 00000000000..f9ffaa92f35 --- /dev/null +++ b/dep/ACE_wrappers/ace/TSS_T.h @@ -0,0 +1,253 @@ +// -*- C++ -*- + +//========================================================================== +/** + * @file TSS_T.h + * + * $Id: TSS_T.h 80826 2008-03-04 14:51:23Z wotte $ + * + * Moved from Synch.h. + * + * @author Douglas C. Schmidt + */ +//========================================================================== + +#ifndef ACE_TSS_T_H +#define ACE_TSS_T_H +#include /**/ "ace/pre.h" + +#include "ace/Lock.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +// This should probably go somewhere else, but it's only used here and +// in Thread_Manager. +// Note there is no ACE_TSS_SET because one would typicaly do +// 'ACE_TSS_GET()->xyz_ = value', so the macro would have been too +// complicated. +# if defined (ACE_HAS_THREADS) && (defined (ACE_HAS_THREAD_SPECIFIC_STORAGE) || defined (ACE_HAS_TSS_EMULATION)) +# define ACE_TSS_TYPE(T) ACE_TSS< T > +# define ACE_TSS_GET(I, T) ((I)->operator T * ()) +# else +# define ACE_TSS_TYPE(T) T +# define ACE_TSS_GET(I, T) (I) +# endif /* ACE_HAS_THREADS && (ACE_HAS_THREAD_SPECIFIC_STORAGE || ACE_HAS_TSS_EMULATION) */ + +#include "ace/Thread_Mutex.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +/** + * @class ACE_TSS + * + * @brief Allows objects that are "physically" in thread specific + * storage (i.e., private to a thread) to be accessed as though + * they were "logically" global to a program. + * + * This class helps to maintain a separate copy of an object for each thread + * that needs access to it. All threads access a single instance of ACE_TSS + * to obtain a pointer to a thread-specific copy of a TYPE object. Using + * a pointer to TYPE in TSS instead of TYPE itself is useful because, + * in addition to avoiding copies on what may be a complex class, it allows + * assignment of objects to thread-specific data that have arbitrarily + * complex constructors. + * + * When the ACE_TSS object is destroyed, all threads's instances of the + * data are deleted. + * + * Modern compilers have no problem using a built-in type for @c TYPE. + * However, if you must use an older compiler that won't work with a built-in + * type, the ACE_TSS_Type_Adapter class template, below, can be used for + * adapting built-in types to work with ACE_TSS. + * + * @note Beware when creating static instances of this type + * (as with any other, btw). The unpredictable order of initialization + * across different platforms may cause a situation where one uses + * the instance before it is fully initialized. That's why typically + * instances of this type are dynamicaly allocated. On the stack it is + * typically allocated inside the ACE_Thread::svc() method which + * limits its lifetime appropriately. + * + */ +template +class ACE_TSS +{ +public: + /** + * Default constructor. Can also initialize this ACE_TSS instance, + * readying it for use by the calling thread as well as all other + * threads in the process. If the constructor does not initialize this + * object, the first access to it will perform the initialization, which + * could possibly (under odd error conditions) fail. + * + * @param ts_obj If non-zero, this object is initialized for use by + * all threads and @a ts_obj is used to set the + * thread-specific value for the calling thread. Other + * threads use the ts_object (TYPE *) method to set + * a specific value. + */ + ACE_TSS (TYPE *ts_obj = 0); + + /// Deregister this object from thread-specific storage administration. + /// Will cause all threads' copies of TYPE to be destroyed. + virtual ~ACE_TSS (void); + + /** + * Set the thread-specific object for the calling thread. + * If this object has not been initialized yet, this method performs the + * initialization. + * + * @param new_ts_obj The new value for the calling thread's copy of + * this object. + * + * @return The previous value of the calling thread's copy of this + * object; 0 if there was no previous value. This method also + * returns 0 on errors. To tell the difference between an error + * and a returned 0 pointer, it's recommended that one set errno + * to 0 prior to calling ts_object() and check for a new errno + * value if ts_object() returns 0. + */ + TYPE *ts_object (TYPE *new_ts_obj); + + /** @name Accessors + * + * All accessors return a pointer to the calling thread's copy of the + * TYPE data. The pointer may be 0 on error conditions or if the calling + * thread's copy of the data has not yet been set. See specific method + * descriptions for complete details. + */ + //@{ + /** + * Get the thread-specific object for this object. + * + * @return 0 if the object has never been initialized, otherwise returns + * the calling thread's copy of the data. The returned pointer + * may be 0 under odd error conditions; check errno for further + * information. + */ + TYPE *ts_object (void) const; + + /** + * Use a "smart pointer" to get the thread-specific data associated + * with this object. + * If this ACE_TSS object hasn't been initialized, this method + * will initialize it as a side-affect. If the calling thread has not + * set a value, a default-constructed instance of TYPE is allocated and it + * becomes the thread's instance. + * + * @return The calling thread's copy of the data. The returned pointer + * may be 0 under odd error conditions; check errno for further + * information. + */ + TYPE *operator-> () const; + + /** + * Obtain a pointer to the calling thread's TYPE object. + * If this ACE_TSS object hasn't been initialized, this method + * will initialize it as a side-affect. If the calling thread has not + * set a value, a default-constructed instance of TYPE is allocated and it + * becomes the thread's instance. + * + * @return The calling thread's copy of the data. The returned pointer + * may be 0 under odd error conditions; check errno for further + * information. + */ + operator TYPE *(void) const; + + //@} + + /// Hook for construction parameters. + virtual TYPE *make_TSS_TYPE (void) const; + + // = Utility methods. + + /// Dump the state of an object. + void dump (void) const; + + // ACE_ALLOC_HOOK_DECLARE; + // Declare the dynamic allocation hooks. + +protected: + /// Actually implements the code that retrieves the object from + /// thread-specific storage. + TYPE *ts_get (void) const; + + /// Factors out common code for initializing TSS. This must NOT be + /// called with the lock held... + int ts_init (void); + +#if !(defined (ACE_HAS_THREADS) && (defined (ACE_HAS_THREAD_SPECIFIC_STORAGE) || defined (ACE_HAS_TSS_EMULATION))) + /// This implementation only works for non-threading systems... + TYPE *type_; +#else + /// Avoid race conditions during initialization. + ACE_Thread_Mutex keylock_; + + /// "First time in" flag. + volatile bool once_; + + /// Key for the thread-specific error data. + ACE_thread_key_t key_; + + /// "Destructor" that deletes internal TYPE * when thread exits. + static void cleanup (void *ptr); +#endif /* defined (ACE_HAS_THREADS) && (defined (ACE_HAS_THREAD_SPECIFIC_STORAGE) || defined (ACE_HAS_TSS_EMULATION)) */ + // = Disallow copying... + ACE_UNIMPLEMENTED_FUNC (void operator= (const ACE_TSS &)) + ACE_UNIMPLEMENTED_FUNC (ACE_TSS (const ACE_TSS &)) +}; + +/** + * @class ACE_TSS_Type_Adapter + * + * @brief Adapter that allows built-in types to be used with ACE_TSS. + * + * Wraps a value of a built-in type, providing conversions to + * and from the type. Example use with ACE_TSS: + * ACE_TSS > i; + * *i = 37; + * ACE_OS::fprintf (stderr, "%d\n", *i); + * Unfortunately, though, some compilers have trouble with the + * implicit type conversions. This seems to work better: + * ACE_TSS > i; + * i->operator int & () = 37; + * ACE_OS::fprintf (stderr, "%d\n", i->operator int ()); + */ +template +class ACE_TSS_Type_Adapter +{ +public: + /// Constructor. Inlined here so that it should _always_ be inlined. + ACE_TSS_Type_Adapter (const TYPE value = 0): value_ (value) {} + + /// TYPE conversion. Inlined here so that it should _always_ be + /// inlined. + operator TYPE () const { return value_; }; + + /// TYPE & conversion. Inlined here so that it should _always_ be + /// inlined. + operator TYPE &() { return value_; }; + +private: + /// The wrapped value. + TYPE value_; +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +#include "ace/TSS_T.inl" +#endif /* __ACE_INLINE__ */ + +#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) +#include "ace/TSS_T.cpp" +#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ + +#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) +#pragma implementation ("TSS_T.cpp") +#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ + +#include /**/ "ace/post.h" +#endif /* ACE_TSS_T_H */ diff --git a/dep/ACE_wrappers/ace/TSS_T.inl b/dep/ACE_wrappers/ace/TSS_T.inl new file mode 100644 index 00000000000..9959a2edd94 --- /dev/null +++ b/dep/ACE_wrappers/ace/TSS_T.inl @@ -0,0 +1,42 @@ +// -*- C++ -*- +// +// $Id: TSS_T.inl 80826 2008-03-04 14:51:23Z wotte $ + +#if !(defined (ACE_HAS_THREADS) && (defined (ACE_HAS_THREAD_SPECIFIC_STORAGE) || defined (ACE_HAS_TSS_EMULATION))) + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +template ACE_INLINE +ACE_TSS::ACE_TSS (TYPE *type) + : type_ (type) +{ +} + +template ACE_INLINE int +ACE_TSS::ts_init (void) +{ + return 0; +} + +template ACE_INLINE TYPE * +ACE_TSS::ts_object (void) const +{ + return this->type_; +} + +template ACE_INLINE TYPE * +ACE_TSS::ts_object (TYPE *type) +{ + this->type_ = type; + return this->type_; +} + +template ACE_INLINE TYPE * +ACE_TSS::ts_get (void) const +{ + return this->type_; +} + +ACE_END_VERSIONED_NAMESPACE_DECL + +#endif /* ! (defined (ACE_HAS_THREADS) && (defined (ACE_HAS_THREAD_SPECIFIC_STORAGE) || defined (ACE_HAS_TSS_EMULATION))) */ diff --git a/dep/ACE_wrappers/ace/TTY_IO.cpp b/dep/ACE_wrappers/ace/TTY_IO.cpp new file mode 100644 index 00000000000..9918ec0dceb --- /dev/null +++ b/dep/ACE_wrappers/ace/TTY_IO.cpp @@ -0,0 +1,582 @@ +// $Id: TTY_IO.cpp 82271 2008-07-09 09:23:03Z olli $ + +#include "ace/TTY_IO.h" +#include "ace/OS_NS_errno.h" +#include "ace/OS_NS_string.h" +#include "ace/OS_NS_strings.h" + +#if defined (ACE_HAS_TERMIOS) +# include "ace/os_include/os_termios.h" +#elif defined (ACE_HAS_TERMIO) +# include +#endif + +ACE_RCSID (ace, + TTY_IO, + "$Id: TTY_IO.cpp 82271 2008-07-09 09:23:03Z olli $") + +namespace +{ + const char ACE_TTY_IO_NONE[] = "none"; +#if defined (ACE_HAS_TERMIOS) || defined (ACE_HAS_TERMIO) || defined (ACE_WIN32) + const char ACE_TTY_IO_ODD[] = "odd"; + const char ACE_TTY_IO_EVEN[] = "even"; +#endif +#if defined (ACE_WIN32) + const char ACE_TTY_IO_MARK[] = "mark"; + const char ACE_TTY_IO_SPACE[] = "space"; +#endif /* ACE_WIN32 */ +} + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_TTY_IO::Serial_Params::Serial_Params (void) +{ + baudrate = 9600; + xonlim = 0; + xofflim = 0; + readmincharacters = 0; + readtimeoutmsec = 10000; + paritymode = ACE_TTY_IO_NONE; + ctsenb = false; + rtsenb = 0; + xinenb = false; + xoutenb = false; + modem = false; + rcvenb = true; + dsrenb = false; + dtrdisable = false; + databits = 8; + stopbits = 1; +} + +// Interface for reading/writing serial device parameters + +int ACE_TTY_IO::control (Control_Mode cmd, Serial_Params *arg) const +{ +#if defined (ACE_HAS_TERMIOS) || defined (ACE_HAS_TERMIO) + +#if defined (ACE_HAS_TERMIOS) + struct termios devpar; + speed_t newbaudrate = 0; + if (tcgetattr (get_handle () , &devpar) == -1) +#elif defined (TCGETS) + struct termios devpar; + unsigned int newbaudrate = 0; + if (this->ACE_IO_SAP::control (TCGETS, static_cast(&devpar)) == -1) +#elif defined (TCGETA) + struct termio devpar; + unsigned int newbaudrate = 0; + if (this->ACE_IO_SAP::control (TCGETA, static_cast(&devpar)) == -1) +#else + errno = ENOSYS; +#endif /* ACE_HAS_TERMIOS */ + return -1; + + switch (cmd) + { + case SETPARAMS: + switch (arg->baudrate) + { +#if defined (B0) + case 0: newbaudrate = B0; break; +#endif /* B0 */ +#if defined (B50) + case 50: newbaudrate = B50; break; +#endif /* B50 */ +#if defined (B75) + case 75: newbaudrate = B75; break; +#endif /* B75 */ +#if defined (B110) + case 110: newbaudrate = B110; break; +#endif /* B110 */ +#if defined (B134) + case 134: newbaudrate = B134; break; +#endif /* B134 */ +#if defined (B150) + case 150: newbaudrate = B150; break; +#endif /* B150 */ +#if defined (B200) + case 200: newbaudrate = B200; break; +#endif /* B200 */ +#if defined (B300) + case 300: newbaudrate = B300; break; +#endif /* B300 */ +#if defined (B600) + case 600: newbaudrate = B600; break; +#endif /* B600 */ +#if defined (B1200) + case 1200: newbaudrate = B1200; break; +#endif /* B1200 */ +#if defined (B1800) + case 1800: newbaudrate = B1800; break; +#endif /* B1800 */ +#if defined (B2400) + case 2400: newbaudrate = B2400; break; +#endif /* B2400 */ +#if defined (B4800) + case 4800: newbaudrate = B4800; break; +#endif /* B4800 */ +#if defined (B9600) + case 9600: newbaudrate = B9600; break; +#endif /* B9600 */ +#if defined (B19200) + case 19200: newbaudrate = B19200; break; +#endif /* B19200 */ +#if defined (B38400) + case 38400: newbaudrate = B38400; break; +#endif /* B38400 */ +#if defined (B56000) + case 56000: newbaudrate = B56000; break; +#endif /* B56000 */ +#if defined (B57600) + case 57600: newbaudrate = B57600; break; +#endif /* B57600 */ +#if defined (B76800) + case 76800: newbaudrate = B76800; break; +#endif /* B76800 */ +#if defined (B115200) + case 115200: newbaudrate = B115200; break; +#endif /* B115200 */ +#if defined (B128000) + case 128000: newbaudrate = B128000; break; +#endif /* B128000 */ +#if defined (B153600) + case 153600: newbaudrate = B153600; break; +#endif /* B153600 */ +#if defined (B230400) + case 230400: newbaudrate = B230400; break; +#endif /* B230400 */ +#if defined (B307200) + case 307200: newbaudrate = B307200; break; +#endif /* B307200 */ +#if defined (B256000) + case 256000: newbaudrate = B256000; break; +#endif /* B256000 */ +#if defined (B460800) + case 460800: newbaudrate = B460800; break; +#endif /* B460800 */ +#if defined (B500000) + case 500000: newbaudrate = B500000; break; +#endif /* B500000 */ +#if defined (B576000) + case 576000: newbaudrate = B576000; break; +#endif /* B576000 */ +#if defined (B921600) + case 921600: newbaudrate = B921600; break; +#endif /* B921600 */ +#if defined (B1000000) + case 1000000: newbaudrate = B1000000; break; +#endif /* B1000000 */ +#if defined (B1152000) + case 1152000: newbaudrate = B1152000; break; +#endif /* B1152000 */ +#if defined (B1500000) + case 1500000: newbaudrate = B1500000; break; +#endif /* B1500000 */ +#if defined (B2000000) + case 2000000: newbaudrate = B2000000; break; +#endif /* B2000000 */ +#if defined (B2500000) + case 2500000: newbaudrate = B2500000; break; +#endif /* B2500000 */ +#if defined (B3000000) + case 3000000: newbaudrate = B3000000; break; +#endif /* B3000000 */ +#if defined (B3500000) + case 3500000: newbaudrate = B3500000; break; +#endif /* B3500000 */ +#if defined (B4000000) + case 4000000: newbaudrate = B4000000; break; +#endif /* B4000000 */ + default: + return -1; + } + +#if defined (ACE_HAS_TERMIOS) + // Can you really have different input and output baud rates?! + if (cfsetospeed (&devpar, newbaudrate) == -1) + return -1; + if (cfsetispeed (&devpar, newbaudrate) == -1) + return -1; +#else + devpar.c_cflag &= ~CBAUD; +# if defined (CBAUDEX) + devpar.c_cflag &= ~CBAUDEX; +# endif /* CBAUDEX */ + devpar.c_cflag |= newbaudrate; +#endif /* ACE_HAS_TERMIOS */ + + devpar.c_cflag &= ~CSIZE; + switch (arg->databits) + { + case 5: + devpar.c_cflag |= CS5; + break; + case 6: + devpar.c_cflag |= CS6; + break; + case 7: + devpar.c_cflag |= CS7; + break; + case 8: + devpar.c_cflag |= CS8; + break; + default: + return -1; + } + + switch (arg->stopbits) + { + case 1: + devpar.c_cflag &= ~CSTOPB; + break; + case 2: + devpar.c_cflag |= CSTOPB; + break; + default: + return -1; + } + + if (arg->paritymode) + { + if (ACE_OS::strcasecmp (arg->paritymode, ACE_TTY_IO_ODD) == 0) + { + devpar.c_cflag |= PARENB; + devpar.c_cflag |= PARODD; + } + else if (ACE_OS::strcasecmp (arg->paritymode, ACE_TTY_IO_EVEN) == 0) + { + devpar.c_cflag |= PARENB; + devpar.c_cflag &= ~PARODD; + } + else if (ACE_OS::strcasecmp (arg->paritymode, ACE_TTY_IO_NONE) == 0) + devpar.c_cflag &= ~PARENB; + else + return -1; + } + else + { + devpar.c_cflag &= ~PARENB; + } + +#if defined (CNEW_RTSCTS) + if ((arg->ctsenb) || (arg->rtsenb)) // Enable RTS/CTS protocol + devpar.c_cflag |= CNEW_RTSCTS; + else + devpar.c_cflag &= ~CNEW_RTSCTS; +#elif defined (CRTSCTS) + if ((arg->ctsenb) || (arg->rtsenb)) // Enable RTS/CTS protocol + devpar.c_cflag |= CRTSCTS; + else + devpar.c_cflag &= ~CRTSCTS; +#endif /* NEW_RTSCTS || CRTSCTS */ + +#if defined (CREAD) + // Enable/disable receiver + if (arg->rcvenb) + devpar.c_cflag |= CREAD; + else + devpar.c_cflag &= ~CREAD; +#endif /* CREAD */ + +#if defined (HUPCL) + // Cause DTR to drop after port close. + devpar.c_cflag |= HUPCL; +#endif /* HUPCL */ + +#if defined (CLOCAL) + // If device is not a modem set to local device. + if (arg->modem) + devpar.c_cflag &= ~CLOCAL; + else + devpar.c_cflag |= CLOCAL; +#endif /* CLOCAL */ + + devpar.c_iflag = IGNPAR | INPCK; + if (arg->databits < 8) + devpar.c_iflag |= ISTRIP; + +#if defined (IGNBRK) + // If device is not a modem set to ignore break points + if(arg->modem) + devpar.c_iflag &= ~IGNBRK; + else + devpar.c_iflag |= IGNBRK; +#endif /* IGNBRK */ + +#if defined (IXOFF) + // Enable/disable software flow control on input + if (arg->xinenb) + devpar.c_iflag |= IXOFF; + else + devpar.c_iflag &= ~IXOFF; +#endif /* IXOFF */ + +#if defined (IXON) + // Enable/disable software flow control on output + if (arg->xoutenb) + devpar.c_iflag |= IXON; + else + devpar.c_iflag &= ~IXON; +#endif /* IXON */ + +#if defined (ICANON) + // Enable noncanonical input processing mode + devpar.c_lflag &= ~ICANON; +#endif /* ICANON */ + +#if defined (ECHO) + // Disable echoing of input characters + devpar.c_lflag &= ~ECHO; +#endif /* ECHO */ + +#if defined (ECHOE) + // Disable echoing erase chareacter as BS-SP-BS + devpar.c_lflag &= ~ECHOE; +#endif /* ECHOE */ + +#if defined (ISIG) + // Disable SIGINTR, SIGSUSP, SIGDSUSP and SIGQUIT signals + devpar.c_lflag &= ~ISIG; +#endif /* ISIG */ + +#if defined (OPOST) + // Disable post-processing of output data + devpar.c_oflag &= ~OPOST; +#endif /* OPOST */ + + if (arg->readtimeoutmsec < 0) + { + // Settings for infinite timeout. + devpar.c_cc[VTIME] = 0; + // In case of infinite timeout [VMIN] must be at least 1. + if (arg->readmincharacters > UCHAR_MAX) + devpar.c_cc[VMIN] = UCHAR_MAX; + else if (arg->readmincharacters < 1) + devpar.c_cc[VMIN] = 1; + else + devpar.c_cc[VMIN] = static_cast(arg->readmincharacters); + } + else + { + devpar.c_cc[VTIME] = static_cast(arg->readtimeoutmsec / 100); + + if (arg->readmincharacters > UCHAR_MAX) + devpar.c_cc[VMIN] = UCHAR_MAX; + else if (arg->readmincharacters < 1) + devpar.c_cc[VMIN] = 0; + else + devpar.c_cc[VMIN] = static_cast(arg->readmincharacters); + } + +#if defined (TIOCMGET) + int status; + this->ACE_IO_SAP::control (TIOCMGET, &status); + + if (arg->dtrdisable) + status &= ~TIOCM_DTR; + else + status |= TIOCM_DTR; + + this->ACE_IO_SAP::control (TIOCMSET, &status); +#endif /* definded (TIOCMGET) */ + +#if defined (ACE_HAS_TERMIOS) + return tcsetattr (get_handle (), TCSANOW, &devpar); +#elif defined (TCSETS) + return this->ACE_IO_SAP::control (TCSETS, static_cast(&devpar)); +#elif defined (TCSETA) + return this->ACE_IO_SAP::control (TCSETA, static_cast(&devpar)); +#else + errno = ENOSYS; + return -1; +#endif /* ACE_HAS_TERMIOS */ + + case GETPARAMS: + return -1; // Not yet implemented. + default: + return -1; // Wrong cmd. + } +#elif defined (ACE_WIN32) + switch (cmd) + { + case SETPARAMS: + DCB dcb; + dcb.DCBlength = sizeof dcb; + if (!::GetCommState (this->get_handle (), &dcb)) + { + ACE_OS::set_errno_to_last_error (); + return -1; + } + + dcb.BaudRate = arg->baudrate; + + switch (arg->databits) + { + case 4: + case 5: + case 6: + case 7: + case 8: + dcb.ByteSize = arg->databits; + break; + default: + return -1; + } + + switch (arg->stopbits) + { + case 1: + dcb.StopBits = ONESTOPBIT; + break; + case 2: + dcb.StopBits = TWOSTOPBITS; + break; + default: + return -1; + } + + if (arg->paritymode) + { + dcb.fParity = TRUE; + if (ACE_OS::strcasecmp (arg->paritymode, ACE_TTY_IO_ODD) == 0) + dcb.Parity = ODDPARITY; + else if (ACE_OS::strcasecmp (arg->paritymode, ACE_TTY_IO_EVEN) == 0) + dcb.Parity = EVENPARITY; + else if (ACE_OS::strcasecmp (arg->paritymode, ACE_TTY_IO_NONE) == 0) + dcb.Parity = NOPARITY; + else if (ACE_OS::strcasecmp (arg->paritymode, ACE_TTY_IO_MARK) == 0) + dcb.Parity = MARKPARITY; + else if (ACE_OS::strcasecmp (arg->paritymode, ACE_TTY_IO_SPACE) == 0) + dcb.Parity = SPACEPARITY; + else + return -1; + } + else + { + dcb.fParity = FALSE; + dcb.Parity = NOPARITY; + } + + // Enable/disable RTS protocol. + switch (arg->rtsenb) + { + case 1: + dcb.fRtsControl = RTS_CONTROL_ENABLE; + break; + case 2: + dcb.fRtsControl = RTS_CONTROL_HANDSHAKE; + break; + case 3: + dcb.fRtsControl = RTS_CONTROL_TOGGLE; + break; + default: + dcb.fRtsControl = RTS_CONTROL_DISABLE; + } + + // Enable/disable CTS protocol. + if (arg->ctsenb) + dcb.fOutxCtsFlow = TRUE; + else + dcb.fOutxCtsFlow = FALSE; + + // Enable/disable DSR protocol. + if (arg->dsrenb) + dcb.fOutxDsrFlow = TRUE; + else + dcb.fOutxDsrFlow = FALSE; + + // Disable/enable DTR protocol + if (arg->dtrdisable) + dcb.fDtrControl = DTR_CONTROL_DISABLE; + else + dcb.fDtrControl = DTR_CONTROL_ENABLE; + + // Enable/disable software flow control on input + if (arg->xinenb) + dcb.fInX = TRUE; + else + dcb.fInX = FALSE; + + // Enable/disable software flow control on output + if (arg->xoutenb) + dcb.fOutX = TRUE; + else + dcb.fOutX = FALSE; + + // Always set limits unless set to negative to use default. + if (arg->xonlim >= 0) + dcb.XonLim = static_cast(arg->xonlim); + if (arg->xofflim >= 0) + dcb.XoffLim = static_cast(arg->xofflim); + + dcb.fAbortOnError = FALSE; + dcb.fErrorChar = FALSE; + dcb.fNull = FALSE; + dcb.fBinary = TRUE; + + if (!::SetCommState (this->get_handle (), &dcb)) + { + ACE_OS::set_errno_to_last_error (); + return -1; + } + + COMMTIMEOUTS timeouts; + if (!::GetCommTimeouts (this->get_handle(), &timeouts)) + { + ACE_OS::set_errno_to_last_error (); + return -1; + } + + if (arg->readtimeoutmsec < 0) + { + // Settings for infinite timeout. + timeouts.ReadIntervalTimeout = 0; + timeouts.ReadTotalTimeoutMultiplier = 0; + timeouts.ReadTotalTimeoutConstant = 0; + } + else if (arg->readtimeoutmsec == 0) + { + // Return immediately if no data in the input buffer. + timeouts.ReadIntervalTimeout = MAXDWORD; + timeouts.ReadTotalTimeoutMultiplier = 0; + timeouts.ReadTotalTimeoutConstant = 0; + } + else + { + // Wait for specified timeout for char to arrive before returning. + timeouts.ReadIntervalTimeout = MAXDWORD; + timeouts.ReadTotalTimeoutMultiplier = MAXDWORD; + timeouts.ReadTotalTimeoutConstant = arg->readtimeoutmsec; + } + + if (!::SetCommTimeouts (this->get_handle (), &timeouts)) + { + ACE_OS::set_errno_to_last_error (); + return -1; + } + + return 0; + + case GETPARAMS: + ACE_NOTSUP_RETURN (-1); // Not yet implemented. + default: + return -1; // Wrong cmd. + + } // arg switch +#else + ACE_UNUSED_ARG (cmd); + ACE_UNUSED_ARG (arg); + ACE_NOTSUP_RETURN (-1); +#endif /* ACE_HAS_TERMIOS || ACE_HAS_TERMIO */ +} + +#if defined (ACE_NEEDS_DEV_IO_CONVERSION) +ACE_TTY_IO::operator ACE_DEV_IO &() +{ + return static_cast(*this); +} +#endif /* ACE_NEEDS_DEV_IO_CONVERSION */ + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/TTY_IO.h b/dep/ACE_wrappers/ace/TTY_IO.h new file mode 100644 index 00000000000..1029966e56c --- /dev/null +++ b/dep/ACE_wrappers/ace/TTY_IO.h @@ -0,0 +1,113 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file TTY_IO.h + * + * $Id: TTY_IO.h 82271 2008-07-09 09:23:03Z olli $ + * + * @author Douglas C. Schmidt + */ +//============================================================================= + +#ifndef ACE_TTY_IO_H +#define ACE_TTY_IO_H + +#include "ace/DEV_IO.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +/** + * @class ACE_TTY_IO + * + * @brief Class definitions for platform specific TTY features. + * + * This class represents an example interface for a specific + * device (a serial line). It extends the capability of the + * underlying DEV_IO class by adding a control method that takes + * a special structure (Serial_Params) as argument to allow a + * comfortable user interface (away from that annoying termios + * structure, which is very specific to UNIX). + */ +class ACE_Export ACE_TTY_IO : public ACE_DEV_IO +{ +public: + enum Control_Mode + { + SETPARAMS, ///< Set control parameters. + GETPARAMS ///< Get control parameters. + }; + + struct ACE_Export Serial_Params + { + Serial_Params (void); + + /** Specifies the baudrate at which the communnication port operates. */ + int baudrate; + /** Specifies the minimum number of bytes in input buffer before XON char + is sent. Negative value indicates that default value should + be used (Win32). */ + int xonlim; + /** Specifies the maximum number of bytes in input buffer before XOFF char + is sent. Negative value indicates that default value should + be used (Win32). */ + int xofflim; + /** Specifies the minimum number of characters for non-canonical + read (POSIX). */ + unsigned int readmincharacters; + /** Specifies the time to wait before returning from read. Negative value + means infinite timeout. */ + int readtimeoutmsec; + /** Specifies the parity mode. POSIX supports "none", "even" and + "odd" parity. Additionally Win32 supports "mark" and "space" + parity modes. */ + const char *paritymode; + /** Enable & set CTS mode. Note that RTS & CTS are enabled/disabled + together on some systems (RTS/CTS is enabled if either + ctsenb or rtsenb is set). */ + bool ctsenb; + /** Enable & set RTS mode. Note that RTS & CTS are enabled/disabled + together on some systems (RTS/CTS is enabled if either + ctsenb or rtsenb is set). + - 0 = Disable RTS. + - 1 = Enable RTS. + - 2 = Enable RTS flow-control handshaking (Win32). + - 3 = Specifies that RTS line will be high if bytes are available + for transmission. After transmission RTS will be low (Win32). */ + unsigned char rtsenb; + /** Enable/disable software flow control on input. */ + bool xinenb; + /** Enable/disable software flow control on output. */ + bool xoutenb; + /** Specifies if device is a modem (POSIX). If not set modem status + lines are ignored. */ + bool modem; + /** Enable/disable receiver (POSIX). */ + bool rcvenb; + /** Controls whether DSR is disabled or enabled (Win32). */ + bool dsrenb; + /** Controls whether DTR is disabled or enabled. */ + bool dtrdisable; + /** Data bits. Valid values 5, 6, 7 and 8 data bits. + Additionally Win32 supports 4 data bits. */ + unsigned char databits; + /** Stop bits. Valid values are 1 and 2. */ + unsigned char stopbits; + }; + + /** Interface for reading/writing serial device parameters. */ + int control (Control_Mode cmd, Serial_Params *arg) const; + +#if defined (ACE_NEEDS_DEV_IO_CONVERSION) + /** This is necessary to pass ACE_TTY_IO as parameter to DEV_Connector. */ + operator ACE_DEV_IO &(); +#endif /* ACE_NEEDS_DEV_IO_CONVERSION */ +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#endif /* ACE_TTY_IO_H */ diff --git a/dep/ACE_wrappers/ace/Task.cpp b/dep/ACE_wrappers/ace/Task.cpp new file mode 100644 index 00000000000..b3d8aad7a86 --- /dev/null +++ b/dep/ACE_wrappers/ace/Task.cpp @@ -0,0 +1,299 @@ +// $Id: Task.cpp 80826 2008-03-04 14:51:23Z wotte $ + +#include "ace/Task.h" +#include "ace/Module.h" + +#if !defined (__ACE_INLINE__) +#include "ace/Task.inl" +#endif /* __ACE_INLINE__ */ + + +ACE_RCSID (ace, + Task, + "$Id: Task.cpp 80826 2008-03-04 14:51:23Z wotte $") + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_Task_Base::ACE_Task_Base (ACE_Thread_Manager *thr_man) + : thr_count_ (0), + thr_mgr_ (thr_man), + flags_ (0), + grp_id_ (-1) +#if !(defined (ACE_MVS) || defined(__TANDEM)) + ,last_thread_id_ (0) +#endif /* !defined (ACE_MVS) */ +{ +#if (defined (ACE_MVS) || defined(__TANDEM)) + ACE_OS::memset( &this->last_thread_id_, '\0', sizeof( this->last_thread_id_ )); +#endif /* defined (ACE_MVS) */ +} + +ACE_Task_Base::~ACE_Task_Base (void) +{ +} + +// Default ACE_Task service routine + +int +ACE_Task_Base::svc (void) +{ + ACE_TRACE ("ACE_Task_Base::svc"); + return 0; +} + +// Default ACE_Task open routine + +int +ACE_Task_Base::open (void *) +{ + ACE_TRACE ("ACE_Task_Base::open"); + return 0; +} + +// Default ACE_Task close routine + +int +ACE_Task_Base::close (u_long) +{ + ACE_TRACE ("ACE_Task_Base::close"); + return 0; +} + +// Forward the call to close() so that existing applications don't +// break. + +int +ACE_Task_Base::module_closed (void) +{ + return this->close (1); +} + +// Default ACE_Task put routine. + +int +ACE_Task_Base::put (ACE_Message_Block *, ACE_Time_Value *) +{ + ACE_TRACE ("ACE_Task_Base::put"); + return 0; +} + +// Wait for all threads running in a task to exit. + +int +ACE_Task_Base::wait (void) +{ + ACE_TRACE ("ACE_Task_Base::wait"); + + // If we don't have a thread manager, we probably were never + // activated. + if (this->thr_mgr () != 0) + return this->thr_mgr ()->wait_task (this); + else + return 0; +} + +// Suspend a task. +int +ACE_Task_Base::suspend (void) +{ + ACE_TRACE ("ACE_Task_Base::suspend"); + ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1)); + if (this->thr_count_ > 0) + return this->thr_mgr_->suspend_task (this); + + return 0; +} + +// Resume a suspended task. +int +ACE_Task_Base::resume (void) +{ + ACE_TRACE ("ACE_Task_Base::resume"); + ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1)); + if (this->thr_count_ > 0) + return this->thr_mgr_->resume_task (this); + + return 0; +} + +int +ACE_Task_Base::activate (long flags, + int n_threads, + int force_active, + long priority, + int grp_id, + ACE_Task_Base *task, + ACE_hthread_t thread_handles[], + void *stack[], + size_t stack_size[], + ACE_thread_t thread_ids[], + const char* thr_name[]) +{ + ACE_TRACE ("ACE_Task_Base::activate"); + +#if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0) + ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1); + + // If the task passed in is zero, we will use + if (task == 0) + task = this; + + if (this->thr_count_ > 0 && force_active == 0) + return 1; // Already active. + else + { + if (this->thr_count_ > 0 && this->grp_id_ != -1) + // If we're joining an existing group of threads then make + // sure to use its group id. + grp_id = this->grp_id_; + this->thr_count_ += n_threads; + } + + // Use the ACE_Thread_Manager singleton if we're running as an + // active object and the caller didn't supply us with a + // Thread_Manager. + if (this->thr_mgr_ == 0) +# if defined (ACE_THREAD_MANAGER_LACKS_STATICS) + this->thr_mgr_ = ACE_THREAD_MANAGER_SINGLETON::instance (); +# else /* ! ACE_THREAD_MANAGER_LACKS_STATICS */ + this->thr_mgr_ = ACE_Thread_Manager::instance (); +# endif /* ACE_THREAD_MANAGER_LACKS_STATICS */ + + int grp_spawned = -1; + if (thread_ids == 0) + // Thread Ids were not specified + grp_spawned = + this->thr_mgr_->spawn_n (n_threads, + &ACE_Task_Base::svc_run, + (void *) this, + flags, + priority, + grp_id, + task, + thread_handles, + stack, + stack_size, + thr_name); + else + // thread names were specified + grp_spawned = + this->thr_mgr_->spawn_n (thread_ids, + n_threads, + &ACE_Task_Base::svc_run, + (void *) this, + flags, + priority, + grp_id, + stack, + stack_size, + thread_handles, + task, + thr_name); + if (grp_spawned == -1) + { + // If spawn_n fails, restore original thread count. + this->thr_count_ -= n_threads; + return -1; + } + + if (this->grp_id_ == -1) + this->grp_id_ = grp_spawned; + +#if defined (ACE_MVS) || defined(__TANDEM) + ACE_OS::memcpy( &this->last_thread_id_, '\0', sizeof(this->last_thread_id_)); +#else + this->last_thread_id_ = 0; // Reset to prevent inadvertant match on ID +#endif /* defined (ACE_MVS) */ + + return 0; + +#else + { + // Keep the compiler from complaining. + ACE_UNUSED_ARG (flags); + ACE_UNUSED_ARG (n_threads); + ACE_UNUSED_ARG (force_active); + ACE_UNUSED_ARG (priority); + ACE_UNUSED_ARG (grp_id); + ACE_UNUSED_ARG (task); + ACE_UNUSED_ARG (thread_handles); + ACE_UNUSED_ARG (stack); + ACE_UNUSED_ARG (stack_size); + ACE_UNUSED_ARG (thread_ids); + ACE_UNUSED_ARG (thr_name); + ACE_NOTSUP_RETURN (-1); + } +#endif /* ACE_MT_SAFE */ +} + +void +ACE_Task_Base::cleanup (void *object, void *) +{ + ACE_Task_Base *t = (ACE_Task_Base *) object; + + // The thread count must be decremented first in case the + // hook does something crazy like "delete this". + { + ACE_MT (ACE_GUARD (ACE_Thread_Mutex, ace_mon, t->lock_)); + t->thr_count_--; + if (0 == t->thr_count_) + t->last_thread_id_ = ACE_Thread::self (); + } + + // @@ Is it possible to pass in the exit status somehow? + t->close (); + // t is undefined here. close() could have deleted it. +} + + +#if defined (ACE_HAS_SIG_C_FUNC) +extern "C" void +ACE_Task_Base_cleanup (void *object, void *) +{ + ACE_Task_Base::cleanup (object, 0); +} +#endif /* ACE_HAS_SIG_C_FUNC */ + +ACE_THR_FUNC_RETURN +ACE_Task_Base::svc_run (void *args) +{ + ACE_TRACE ("ACE_Task_Base::svc_run"); + + ACE_Task_Base *t = (ACE_Task_Base *) args; + + // Register ourself with our 's thread exit hook + // mechanism so that our close() hook will be sure to get invoked + // when this thread exits. + +#if defined ACE_HAS_SIG_C_FUNC + t->thr_mgr ()->at_exit (t, ACE_Task_Base_cleanup, 0); +#else + t->thr_mgr ()->at_exit (t, ACE_Task_Base::cleanup, 0); +#endif /* ACE_HAS_SIG_C_FUNC */ + + // Call the Task's svc() hook method. + int const svc_status = t->svc (); + ACE_THR_FUNC_RETURN status; +#if defined (ACE_HAS_INTEGRAL_TYPE_THR_FUNC_RETURN) + // Reinterpret case between integral types is not mentioned in the C++ spec + status = static_cast (svc_status); +#else + status = reinterpret_cast (svc_status); +#endif /* ACE_HAS_INTEGRAL_TYPE_THR_FUNC_RETURN */ + +// If we changed this zero change the other if in OS.cpp Thread_Adapter::invoke +#if 1 + // Call the close> hook. + ACE_Thread_Manager *thr_mgr_ptr = t->thr_mgr (); + + // This calls the Task->close () hook. + t->cleanup (t, 0); + + // This prevents a second invocation of the cleanup code + // (called later by . + thr_mgr_ptr->at_exit (t, 0, 0); +#endif + return status; +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Task.h b/dep/ACE_wrappers/ace/Task.h new file mode 100644 index 00000000000..f2ac03ca9e9 --- /dev/null +++ b/dep/ACE_wrappers/ace/Task.h @@ -0,0 +1,307 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Task.h + * + * $Id: Task.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Douglas C. Schmidt + */ +//============================================================================= + +#ifndef ACE_TASK_H +#define ACE_TASK_H +#include /**/ "ace/pre.h" + +#include "ace/Service_Object.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/Thread_Manager.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +/** + * @class ACE_Task_Flags + * + * @brief These flags are used within the ACE_Task. + * + * These flags should be hidden within ACE_Task. Unfortunately, the + * HP/UX C++ compiler can't grok this... Fortunately, there's no + * code defined here, so we don't have to worry about multiple + * definitions. + */ +namespace ACE_Task_Flags +{ + enum + { + /// Identifies a Task as being the "reader" in a Module. + ACE_READER = 01, + /// Just flush data messages in the queue. + ACE_FLUSHDATA = 02, + /// Flush all messages in the Queue. + ACE_FLUSHALL = 04, + /// Flush read queue + ACE_FLUSHR = 010, + /// Flush write queue + ACE_FLUSHW = 020, + /// Flush both queues + ACE_FLUSHRW = 030 + }; +} + +/** + * @class ACE_Task_Base + * + * @brief Direct base class for the ACE_Task template. + * + * This class factors out the non-template code in order to + * reduce template bloat, as well as to make it possible for the + * ACE_Thread_Manager to store ACE_Task_Base *'s + * polymorphically. + */ +class ACE_Export ACE_Task_Base : public ACE_Service_Object +{ +public: + // = Initialization and termination methods. + /// Constructor. + ACE_Task_Base (ACE_Thread_Manager * = 0); + + /// Destructor. + virtual ~ACE_Task_Base (void); + + // = Initialization and termination hooks. + + // These methods should be overridden by subclasses if you'd like to + // provide -specific initialization and termination behavior. + + /// Hook called to initialize a task and prepare it for execution. + /// @a args can be used to pass arbitrary information into . + virtual int open (void *args = 0); + + /** + * Hook called from ACE_Thread_Exit when during thread exit and from + * the default implementation of . In general, this + * method shouldn't be called directly by an application, + * particularly if the is running as an Active Object. + * Instead, a special message should be passed into the via + * the method defined below, and the method should + * interpret this as a flag to shut down the . + */ + virtual int close (u_long flags = 0); + + /** + * Hook called during . The default + * implementation calls forwards the call to close(1). Please + * notice the changed value of the default argument of . + * This allows tasks to differ between the call has been originated + * from or from . Be aware that + * close(0) will be also called when a thread associated with the + * ACE_Task instance exits. + */ + virtual int module_closed (void); + + // = Immediate and deferred processing methods, respectively. + + // These methods should be overridden by subclasses if you'd like to + // provide -specific message processing behavior. + + /// A hook method that can be used to pass a message to a + /// task, where it can be processed immediately or queued for subsequent + /// processing in the hook method. + virtual int put (ACE_Message_Block *, ACE_Time_Value * = 0); + + /// Run by a daemon thread to handle deferred processing. + virtual int svc (void); + + // = Active object activation method. + /** + * Turn the task into an active object, i.e., having @a n_threads of + * control, all running at the @a priority level (see below) with the + * same @a grp_id, all of which invoke . Returns -1 if + * failure occurs, returns 1 if Task is already an active object and + * @a force_active is false (i.e., do *not* create a new thread in + * this case), and returns 0 if Task was not already an active + * object and a thread is created successfully or thread is an + * active object and @a force_active is true. Note that if + * @a force_active is true and there are already threads spawned in + * this , the @a grp_id parameter is ignored and the @a grp_id + * of any newly activated thread(s) will inherit the existing + * @a grp_id of the existing thread(s) in the . + * + * The <{flags}> are a bitwise-OR of the following: + * = BEGIN + * THR_CANCEL_DISABLE, THR_CANCEL_ENABLE, THR_CANCEL_DEFERRED, + * THR_CANCEL_ASYNCHRONOUS, THR_BOUND, THR_NEW_LWP, THR_DETACHED, + * THR_SUSPENDED, THR_DAEMON, THR_JOINABLE, THR_SCHED_FIFO, + * THR_SCHED_RR, THR_SCHED_DEFAULT, THR_EXPLICIT_SCHED, + * THR_SCOPE_SYSTEM, THR_SCOPE_PROCESS + * = END + * If THR_SCHED_INHERIT is not desirable, applications should + * specifically pass in THR_EXPLICIT_SCHED. + * + * + * By default, or if <{priority}> is set to + * ACE_DEFAULT_THREAD_PRIORITY, an "appropriate" priority value for + * the given scheduling policy (specified in <{flags}>, e.g., + * ) is used. This value is calculated + * dynamically, and is the median value between the minimum and + * maximum priority values for the given policy. If an explicit + * value is given, it is used. Note that actual priority values are + * EXTREMEMLY implementation-dependent, and are probably best + * avoided. + * + * If @a thread_handles != 0 it is assumed to be an array of @a n + * thread_handles that will be assigned the values of the thread + * handles being spawned. Returns -1 on failure (@c errno will + * explain...), otherwise returns the group id of the threads. + * + * Assigning @a task allows you to associate the newly spawned + * threads with an instance of ACE_Task_Base. If @a task == 0, then + * the new threads are associated automatically with @c this + * ACE_Task_Base. Setting the @a task argument to value other than + * @c this makes the thread manipulating methods, such as wait(), + * suspend(), resume(), useless. Threads spawned with user + * specified @a task value must therefore be manipulated thru + * ACE_Thread_Manager directly. + * + * If @a stack != 0 it is assumed to be an array of @a n pointers to + * the base of the stacks to use for the threads being spawned. + * Likewise, if @a stack_size != 0 it is assumed to be an array of + * @a n values indicating how big each of the corresponding @a stacks + * are. + * + * + */ + virtual int activate (long flags = THR_NEW_LWP | THR_JOINABLE | THR_INHERIT_SCHED, + int n_threads = 1, + int force_active = 0, + long priority = ACE_DEFAULT_THREAD_PRIORITY, + int grp_id = -1, + ACE_Task_Base *task = 0, + ACE_hthread_t thread_handles[] = 0, + void *stack[] = 0, + size_t stack_size[] = 0, + ACE_thread_t thread_ids[] = 0, + const char* thr_name[] = 0); + + /** + * Block until there are no more threads running in this task. + * This method will not wait for either detached or daemon threads; + * the threads must have been spawned with the @c THR_JOINABLE flag. + * Upon successful completion, the threads have been joined, so further + * attempts to join with any of the waited-for threads will fail. + * + * @retval 0 Success. + * @retval -1 Failure (consult errno for further information). + */ + virtual int wait (void); + + // = Suspend/resume a Task. + + // Note that these methods are not portable and should be avoided + // since they are inherently error-prone to use. They are only here + // for (the rare) applications that know how to use them correctly. + /// Suspend a task. + virtual int suspend (void); + /// Resume a suspended task. + virtual int resume (void); + + /// Get the current group id. + int grp_id (void) const; + + /// Set the current group id. + void grp_id (int); + + /// Get the thread manager associated with this Task. + ACE_Thread_Manager *thr_mgr (void) const; + + /// Set the thread manager associated with this Task. + void thr_mgr (ACE_Thread_Manager *); + + /// True if queue is a reader, else false. + int is_reader (void) const; + + /// True if queue is a writer, else false. + int is_writer (void) const; + + /** + * Returns the number of threads currently running within a task. + * If we're a passive object this value is 0, else it's greater than + * 0. + */ + size_t thr_count (void) const; + + /** + * Returns the thread ID of the thread whose exit caused this object's + * thread count to be decremented to 0. + * + * When a thread spawned in the context of this object (using activate()) + * returns from its svc() method ACE calls the close() hook. Before it does + * so, it decrements the number of active threads. If the number of threads + * is decremented to 0, the thread ID of the current thread is stored for + * access by this method. If the returned thread ID matches the calling + * thread's ID, the calling thread knows that there are no other threads + * still active in the ACE_Task. + * + * @retval ACE_thread_t of the last thread to close. 0 if the last thread + * is not yet known; for example, if no threads are active, or if + * multiple threads are active. + */ + ACE_thread_t last_thread (void) const; + + /// Routine that runs the service routine as a daemon thread. + static ACE_THR_FUNC_RETURN svc_run (void *); + + /// Cleanup hook that is called when a thread exits to gracefully + /// shutdown an ACE_Task. + static void cleanup (void *object, void *params); + +protected: + /** + * Count of the number of threads running within the task. If this + * value is greater than 0 then we're an active object and the value + * of is the number of active threads at this instant. + * If the value == 0, then we're a passive object. + */ + size_t thr_count_; + + /// Multi-threading manager. + ACE_Thread_Manager *thr_mgr_; + + /// ACE_Task flags. + u_long flags_; + + /// This maintains the group id of the Task. + int grp_id_; + +#if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0) + /// Protect the state of a Task during concurrent operations, but + /// only if we're configured as MT safe... + ACE_Thread_Mutex lock_; +#endif /* ACE_MT_SAFE */ + + /// Holds the thread ID of the last thread to exit svc() in this object. + ACE_thread_t last_thread_id_; + +private: + + // = Disallow these operations. + ACE_Task_Base &operator= (const ACE_Task_Base &); + ACE_Task_Base (const ACE_Task_Base &); +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +#include "ace/Task.inl" +#endif /* __ACE_INLINE__ */ + +// Include the ACE_Task templates classes at this point. +#include "ace/Task_T.h" + +#include /**/ "ace/post.h" +#endif /* ACE_TASK_H */ diff --git a/dep/ACE_wrappers/ace/Task.inl b/dep/ACE_wrappers/ace/Task.inl new file mode 100644 index 00000000000..9f70371e5f5 --- /dev/null +++ b/dep/ACE_wrappers/ace/Task.inl @@ -0,0 +1,77 @@ +// -*- C++ -*- +// +// $Id: Task.inl 80826 2008-03-04 14:51:23Z wotte $ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +// Get the current group id. +ACE_INLINE int +ACE_Task_Base::grp_id (void) const +{ + ACE_TRACE ("ACE_Task_Base::grp_id"); + ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, const_cast (this->lock_), -1)); + return this->grp_id_; +} + +// Set the current group id. + +ACE_INLINE void +ACE_Task_Base::grp_id (int identifier) +{ + ACE_TRACE ("ACE_Task_Base::grp_id"); + ACE_MT (ACE_GUARD (ACE_Thread_Mutex, ace_mon, this->lock_)); + + // Cache the group id in the task and then set it in the + // Thread_Manager, if there is one. + this->grp_id_ = identifier; + if (this->thr_mgr ()) + this->thr_mgr ()->set_grp (this, identifier); +} + +ACE_INLINE ACE_Thread_Manager * +ACE_Task_Base::thr_mgr (void) const +{ + ACE_TRACE ("ACE_Task_Base::thr_mgr"); + return this->thr_mgr_; +} + +ACE_INLINE void +ACE_Task_Base::thr_mgr (ACE_Thread_Manager *thr_mgr) +{ + ACE_TRACE ("ACE_Task_Base::thr_mgr"); + this->thr_mgr_ = thr_mgr; +} + +ACE_INLINE int +ACE_Task_Base::is_reader (void) const +{ + ACE_TRACE ("ACE_Task_Base::is_reader"); + return (ACE_BIT_ENABLED (this->flags_, ACE_Task_Flags::ACE_READER)); +} + +ACE_INLINE int +ACE_Task_Base::is_writer (void) const +{ + ACE_TRACE ("ACE_Task_Base::is_writer"); + return (ACE_BIT_DISABLED (this->flags_, ACE_Task_Flags::ACE_READER)); +} + +// Return the count of the current number of threads. +ACE_INLINE size_t +ACE_Task_Base::thr_count (void) const +{ + ACE_TRACE ("ACE_Task_Base::thr_count"); + ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, const_cast (this->lock_), 0)); + + return this->thr_count_; +} + +// Return the thread ID of the last thread to exit svc(). +ACE_INLINE ACE_thread_t +ACE_Task_Base::last_thread (void) const +{ + ACE_TRACE ("ACE_Task_Base::last_thread"); + return this->last_thread_id_; +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Task_Ex_T.cpp b/dep/ACE_wrappers/ace/Task_Ex_T.cpp new file mode 100644 index 00000000000..de97e5ba6b4 --- /dev/null +++ b/dep/ACE_wrappers/ace/Task_Ex_T.cpp @@ -0,0 +1,114 @@ +// $Id: Task_Ex_T.cpp 80826 2008-03-04 14:51:23Z wotte $ + +#ifndef ACE_TASK_EX_T_CPP +#define ACE_TASK_EX_T_CPP + +#include "ace/Task_Ex_T.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/Module.h" +#include "ace/Null_Condition.h" + +#if !defined (__ACE_INLINE__) +#include "ace/Task_Ex_T.inl" +#endif /* __ACE_INLINE__ */ + + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +template void +ACE_Task_Ex::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + ACE_TRACE ("ACE_Task_Ex::dump"); + ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nthr_mgr_ = %x"), this->thr_mgr_)); + this->msg_queue_->dump (); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("delete_msg_queue_ = %d\n"), this->delete_msg_queue_)); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nflags = %x"), this->flags_)); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nmod_ = %x"), this->mod_)); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nnext_ = %x"), this->next_)); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\ngrp_id_ = %d"), this->grp_id_)); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nthr_count_ = %d"), this->thr_count_)); +#if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0) + this->lock_.dump (); +#endif /* ACE_MT_SAFE */ + + ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); +#endif /* ACE_HAS_DUMP */ +} + +// If the user doesn't supply a ACE_Message_Queue_Ex pointer then we'll +// allocate one dynamically. Otherwise, we'll use the one they give. + +template +ACE_Task_Ex::ACE_Task_Ex (ACE_Thread_Manager *thr_man, + ACE_Message_Queue_Ex *mq) + : ACE_Task_Base (thr_man), + msg_queue_ (0), + delete_msg_queue_ (false), + mod_ (0), + next_ (0) +{ + ACE_TRACE ("ACE_Task_Ex::ACE_Task_Ex"); + + if (mq == 0) + { + ACE_NEW (mq, + (ACE_Message_Queue_Ex)); + this->delete_msg_queue_ = true; + } + + this->msg_queue_ = mq; +} + +template +ACE_Task_Ex::~ACE_Task_Ex (void) +{ + ACE_TRACE ("ACE_Task_Ex::~ACE_Task_Ex"); + if (this->delete_msg_queue_) + delete this->msg_queue_; + + // These assignments aren't strickly necessary but they help guard + // against odd race conditions... + this->delete_msg_queue_ = false; +} + +template ACE_Task * +ACE_Task_Ex::sibling (void) +{ + ACE_TRACE ("ACE_Task_Ex::sibling"); + /// @todo FIXME Need to impl ACE_Moudle to support ACE_Task as well. + /// Now always return 0 for sibling + return 0; +/* + if (this->mod_ == 0) + return 0; + else + return this->mod_->sibling (this); +*/ +} + +template const ACE_TCHAR * +ACE_Task_Ex::name (void) const +{ + ACE_TRACE ("ACE_Task_Ex::name"); + if (this->mod_ == 0) + return 0; + else + return this->mod_->name (); +} + +template ACE_Module * +ACE_Task_Ex::module (void) const +{ + ACE_TRACE ("ACE_Task_Ex::module"); + return this->mod_; +} + +ACE_END_VERSIONED_NAMESPACE_DECL + +#endif /* ACE_TASK_EX_T_CPP */ diff --git a/dep/ACE_wrappers/ace/Task_Ex_T.h b/dep/ACE_wrappers/ace/Task_Ex_T.h new file mode 100644 index 00000000000..00233d4e7d9 --- /dev/null +++ b/dep/ACE_wrappers/ace/Task_Ex_T.h @@ -0,0 +1,205 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Task_Ex_T.h + * + * $Id: Task_Ex_T.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Kobi Cohen-Arazi + */ +//============================================================================= + +#ifndef ACE_TASK_EX_T_H +#define ACE_TASK_EX_T_H +#include /**/ "ace/pre.h" + +#include "ace/Service_Object.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/Synch_Traits.h" +#include "ace/Task.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +// Forward decls... +template class ACE_Module; + +/** + * @class ACE_Task_Ex + * + * @brief Primary interface for application message processing, as well + * as input and output message queueing. + * + * Unlike ACE_Task, these class doesn't have the ability to be a part of + * a Stream chain. I.e. You cannot (yet) chain modules based on ACE_Task_Ex. + * + * @todo: We can merge ACE_Task and ACE_Task_Ex to be one class. + * something like that: + * template + * class ACE_Task : public ACE_Task_Base + * { + * // use here the code from ACE_Task_Ex using ACE_Message_Queue_Ex + * }; + * + * Now specialized version of ACE_Task with ACE_Message_Block as its + * ACE_MESSAGE_TYPE... + * + * template + * class ACE_Task : public ACE_Task_Base + * { + * // put here the good old ACE_Task code + * }; + * + * When User (and legacy code) write ACE_Task, specialized ACE_Task + * code is in action. + */ +template +class ACE_Task_Ex : public ACE_Task_Base +{ +public: + friend class ACE_Module; + friend class ACE_Module_Type; + typedef ACE_Message_Queue_Ex MESSAGE_QUEUE_EX; + + // = Initialization/termination methods. + /** + * Initialize a Task, supplying a thread manager and a message + * queue. If the user doesn't supply a ACE_Message_Queue pointer + * then we'll allocate one dynamically. Otherwise, we'll use the + * one passed as a parameter. + */ + ACE_Task_Ex (ACE_Thread_Manager *thr_mgr = 0, + MESSAGE_QUEUE_EX *mq = 0); + + /// Destructor. + virtual ~ACE_Task_Ex (void); + + /// Gets the message queue associated with this task. + MESSAGE_QUEUE_EX *msg_queue (void); + + /// Sets the message queue associated with this task. + void msg_queue (MESSAGE_QUEUE_EX *); + +public: // Should be protected: + // = Message queue manipulation methods. + + // = Enqueue and dequeue methods. + + // For the following five method if @a timeout == 0, the caller will + // block until action is possible, else will wait until the + // <{absolute}> time specified in *@a timeout elapses). These calls + // will return, however, when queue is closed, deactivated, when a + // signal occurs, or if the time specified in timeout elapses, (in + // which case errno = EWOULDBLOCK). + + /// Insert message into the message queue. Note that @a timeout uses + /// <{absolute}> time rather than <{relative}> time. + int putq (ACE_MESSAGE_TYPE *, ACE_Time_Value *timeout = 0); + + /** + * Extract the first message from the queue (blocking). Note that + * @a timeout uses <{absolute}> time rather than <{relative}> time. + * Returns number of items in queue if the call succeeds or -1 otherwise. + */ + int getq (ACE_MESSAGE_TYPE *&mb, ACE_Time_Value *timeout = 0); + + /// Return a message to the queue. Note that @a timeout uses + /// <{absolute}> time rather than <{relative}> time. + int ungetq (ACE_MESSAGE_TYPE *, ACE_Time_Value *timeout = 0); + + /** + * Turn the message around and send it back down the Stream. Note + * that @a timeout uses <{absolute}> time rather than <{relative}> + * time. + */ + int reply (ACE_MESSAGE_TYPE *, ACE_Time_Value *timeout = 0); + + /** + * Transfer message to the adjacent ACE_Task_Ex in a ACE_Stream. Note + * that @a timeout uses <{absolute}> time rather than <{relative}> + * time. + */ + int put_next (ACE_MESSAGE_TYPE *msg, ACE_Time_Value *timeout = 0); + + /** + * Tests whether we can enqueue a message without blocking. + * @deprecated This method is deprecated and will go away in the future. + */ + int can_put (ACE_MESSAGE_TYPE *); + + // = ACE_Task utility routines to identify names et al. + /// Return the name of the enclosing Module if there's one associated + /// with the Task, else returns 0. + const ACE_TCHAR *name (void) const; + + // = Pointers to next ACE_Task_Base (if ACE is part of an ACE_Stream). + /// Get next Task pointer. + ACE_Task *next (void); + + /// Set next Task pointer. + void next (ACE_Task *); + + /// Alwasy return 0. @todo FIXME + ACE_Task *sibling (void); + + /// Return the Task's Module if there is one, else returns 0. + ACE_Module *module (void) const; + + /** + * Flush the task's queue, i.e., free all of the enqueued + * message blocks and releases any threads blocked on the queue. + * Note that if this conflicts with the C++ iostream + * function, just rewrite the iostream function as ::. + */ + int flush (u_long flag = ACE_Task_Flags::ACE_FLUSHALL); + + // = Special routines corresponding to certain message types. + + /// Manipulate watermarks. + void water_marks (ACE_IO_Cntl_Msg::ACE_IO_Cntl_Cmds, size_t); + + /// Queue of messages on the ACE_Task.. + MESSAGE_QUEUE_EX *msg_queue_; + + /// true if should delete Message_Queue, false otherwise. + bool delete_msg_queue_; + + /// Back-pointer to the enclosing module. + ACE_Module *mod_; + + /// Pointer to adjacent ACE_Task. + ACE_Task *next_; + + /// Dump the state of an object. + void dump (void) const; + + /// Declare the dynamic allocation hooks. + ACE_ALLOC_HOOK_DECLARE; + +private: + + // = Disallow these operations. + ACE_UNIMPLEMENTED_FUNC (void operator= (const ACE_Task_Ex &)) + ACE_UNIMPLEMENTED_FUNC (ACE_Task_Ex (const ACE_Task_Ex &)) +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +#include "ace/Task_Ex_T.inl" +#endif /* __ACE_INLINE__ */ + +#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) +#include "ace/Task_Ex_T.cpp" +#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ + +#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) +#pragma implementation ("Task_Ex_T.cpp") +#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ + +#include /**/ "ace/post.h" +#endif /* ACE_TASK_EX_H */ diff --git a/dep/ACE_wrappers/ace/Task_Ex_T.inl b/dep/ACE_wrappers/ace/Task_Ex_T.inl new file mode 100644 index 00000000000..dd90bcd499a --- /dev/null +++ b/dep/ACE_wrappers/ace/Task_Ex_T.inl @@ -0,0 +1,109 @@ +// -*- C++ -*- +// +// $Id: Task_Ex_T.inl 80826 2008-03-04 14:51:23Z wotte $ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +template ACE_INLINE void +ACE_Task_Ex::water_marks (ACE_IO_Cntl_Msg::ACE_IO_Cntl_Cmds cmd, + size_t wm_size) +{ + ACE_TRACE ("ACE_Task_Ex::water_marks"); + if (cmd == ACE_IO_Cntl_Msg::SET_LWM) + this->msg_queue_->low_water_mark (wm_size); + else /* cmd == ACE_IO_Cntl_Msg::SET_HWM */ + this->msg_queue_->high_water_mark (wm_size); +} + +template ACE_INLINE int +ACE_Task_Ex::getq (ACE_MESSAGE_TYPE *&mb, ACE_Time_Value *tv) +{ + ACE_TRACE ("ACE_Task_Ex::getq"); + return this->msg_queue_->dequeue_head (mb, tv); +} + +template ACE_INLINE int +ACE_Task_Ex::can_put (ACE_MESSAGE_TYPE *) +{ + ACE_TRACE ("ACE_Task_Ex::can_put"); + ACE_NOTSUP_RETURN (-1); +} + +template ACE_INLINE int +ACE_Task_Ex::putq (ACE_MESSAGE_TYPE *mb, ACE_Time_Value *tv) +{ + ACE_TRACE ("ACE_Task_Ex::putq"); + return this->msg_queue_->enqueue_tail (mb, tv); +} + +template ACE_INLINE int +ACE_Task_Ex::ungetq (ACE_MESSAGE_TYPE *mb, ACE_Time_Value *tv) +{ + ACE_TRACE ("ACE_Task_Ex::ungetq"); + return this->msg_queue_->enqueue_head (mb, tv); +} + +template ACE_INLINE int +ACE_Task_Ex::flush (u_long flag) +{ + ACE_TRACE ("ACE_Task_Ex::flush"); + if (ACE_BIT_ENABLED (flag, ACE_Task_Flags::ACE_FLUSHALL)) + return this->msg_queue_ != 0 && this->msg_queue_->close (); + else + return -1; // Note, need to be more careful about what we free... +} + +template ACE_INLINE void +ACE_Task_Ex::msg_queue (ACE_Message_Queue_Ex *mq) +{ + ACE_TRACE ("ACE_Task_Ex::msg_queue"); + if (this->delete_msg_queue_) + { + delete this->msg_queue_; + this->delete_msg_queue_ = false; + } + this->msg_queue_ = mq; +} + +template ACE_Message_Queue_Ex * +ACE_Task_Ex::msg_queue (void) +{ + ACE_TRACE ("ACE_Task_Ex::msg_queue"); + return this->msg_queue_; +} + +template ACE_INLINE int +ACE_Task_Ex::reply (ACE_MESSAGE_TYPE *mb, ACE_Time_Value *tv) +{ + ACE_TRACE ("ACE_Task_Ex::reply"); + ACE_UNUSED_ARG (mb); + ACE_UNUSED_ARG (tv); + return -1 ; // this->sibling ()->put_next (mb, tv); +} + +template ACE_INLINE ACE_Task * +ACE_Task_Ex::next (void) +{ + ACE_TRACE ("ACE_Task_Ex::next"); + return this->next_; +} + +template ACE_INLINE void +ACE_Task_Ex::next (ACE_Task *q) +{ + ACE_TRACE ("ACE_Task_Ex::next"); + this->next_ = q; +} + +// Transfer msg to the next ACE_Task_Ex. + +template ACE_INLINE int +ACE_Task_Ex::put_next ( + ACE_MESSAGE_TYPE * /* msg */, + ACE_Time_Value * /* tv */) +{ + ACE_TRACE ("ACE_Task_Ex::put_next"); + return -1; // this->next_ == 0 ? -1 : this->next_->put (msg, tv); +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Task_T.cpp b/dep/ACE_wrappers/ace/Task_T.cpp new file mode 100644 index 00000000000..08b36f82f08 --- /dev/null +++ b/dep/ACE_wrappers/ace/Task_T.cpp @@ -0,0 +1,108 @@ +// $Id: Task_T.cpp 80826 2008-03-04 14:51:23Z wotte $ + +#ifndef ACE_TASK_T_CPP +#define ACE_TASK_T_CPP + +#include "ace/Task_T.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/Module.h" +#include "ace/Null_Condition.h" + +#if !defined (__ACE_INLINE__) +#include "ace/Task_T.inl" +#endif /* __ACE_INLINE__ */ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +template void +ACE_Task::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + ACE_TRACE ("ACE_Task::dump"); + ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nthr_mgr_ = %x"), this->thr_mgr_)); + this->msg_queue_->dump (); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("delete_msg_queue_ = %d\n"), this->delete_msg_queue_)); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nflags = %x"), this->flags_)); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nmod_ = %x"), this->mod_)); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nnext_ = %x"), this->next_)); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\ngrp_id_ = %d"), this->grp_id_)); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nthr_count_ = %d"), this->thr_count_)); +#if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0) + this->lock_.dump (); +#endif /* ACE_MT_SAFE */ + + ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); +#endif /* ACE_HAS_DUMP */ +} + +// If the user doesn't supply a ACE_Message_Queue pointer then we'll +// allocate one dynamically. Otherwise, we'll use the one they give. + +template +ACE_Task::ACE_Task (ACE_Thread_Manager *thr_man, + ACE_Message_Queue *mq) + : ACE_Task_Base (thr_man), + msg_queue_ (0), + delete_msg_queue_ (false), + mod_ (0), + next_ (0) +{ + ACE_TRACE ("ACE_Task::ACE_Task"); + + if (mq == 0) + { + ACE_NEW (mq, + ACE_Message_Queue); + this->delete_msg_queue_ = true; + } + + this->msg_queue_ = mq; +} + +template +ACE_Task::~ACE_Task (void) +{ + ACE_TRACE ("ACE_Task::~ACE_Task"); + if (this->delete_msg_queue_) + delete this->msg_queue_; + + // These assignments aren't strickly necessary but they help guard + // against odd race conditions... + this->delete_msg_queue_ = false; +} + +template ACE_Task * +ACE_Task::sibling (void) +{ + ACE_TRACE ("ACE_Task::sibling"); + if (this->mod_ == 0) + return 0; + else + return this->mod_->sibling (this); +} + +template const ACE_TCHAR * +ACE_Task::name (void) const +{ + ACE_TRACE ("ACE_Task::name"); + if (this->mod_ == 0) + return 0; + else + return this->mod_->name (); +} + +template ACE_Module * +ACE_Task::module (void) const +{ + ACE_TRACE ("ACE_Task::module"); + return this->mod_; +} + +ACE_END_VERSIONED_NAMESPACE_DECL + +#endif /* ACE_TASK_T_CPP */ diff --git a/dep/ACE_wrappers/ace/Task_T.h b/dep/ACE_wrappers/ace/Task_T.h new file mode 100644 index 00000000000..b945bf37551 --- /dev/null +++ b/dep/ACE_wrappers/ace/Task_T.h @@ -0,0 +1,198 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Task_T.h + * + * $Id: Task_T.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Douglas C. Schmidt + */ +//============================================================================= + +#ifndef ACE_TASK_T_H +#define ACE_TASK_T_H +#include /**/ "ace/pre.h" + +#include "ace/Message_Queue.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/Synch_Traits.h" +#include "ace/Task.h" +#include "ace/IO_Cntl_Msg.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +// Forward decls... +template class ACE_Module; + +/** + * @class ACE_Task + * + * @brief Primary interface for application message processing, as well + * as input and output message queueing. + * + * This class serves as the basis for passive and active objects + * in ACE. + */ +template +class ACE_Task : public ACE_Task_Base +{ +public: + friend class ACE_Module; + friend class ACE_Module_Type; + + // = Initialization/termination methods. + /** + * Initialize a Task, supplying a thread manager and a message + * queue. If the user doesn't supply a ACE_Message_Queue pointer + * then we'll allocate one dynamically. Otherwise, we'll use the + * one passed as a parameter. + */ + ACE_Task (ACE_Thread_Manager *thr_mgr = 0, + ACE_Message_Queue *mq = 0); + + /// Destructor. + virtual ~ACE_Task (void); + + /// Gets the message queue associated with this task. + ACE_Message_Queue *msg_queue (void); + + /// Sets the message queue associated with this task. + void msg_queue (ACE_Message_Queue *); + +public: // Should be protected: + // = Message queue manipulation methods. + + // = Enqueue and dequeue methods. + + // For the following five method if @a timeout == 0, the caller will + // block until action is possible, else will wait until the + // <{absolute}> time specified in *@a timeout elapses). These calls + // will return, however, when queue is closed, deactivated, when a + // signal occurs, or if the time specified in timeout elapses, (in + // which case errno = EWOULDBLOCK). + + /// Insert message into the message queue. Note that @a timeout uses + /// <{absolute}> time rather than <{relative}> time. + int putq (ACE_Message_Block *, ACE_Time_Value *timeout = 0); + + /** + * Extract the first message from the queue (blocking). Note that + * @a timeout uses <{absolute}> time rather than <{relative}> time. + * Returns number of items in queue if the call succeeds or -1 otherwise. + */ + int getq (ACE_Message_Block *&mb, ACE_Time_Value *timeout = 0); + + /// Return a message to the queue. Note that @a timeout uses + /// <{absolute}> time rather than <{relative}> time. + int ungetq (ACE_Message_Block *, ACE_Time_Value *timeout = 0); + + /** + * Turn the message around, sending it in the opposite direction in + * the stream. To do this, the message is put onto the task next in + * the stream after this task's sibling. + * + * @param ACE_Message_Block Pointer to the block that is used in the reply. + * @param timeout The absolute time at which the put operation used to + * send the message block to the next module in the stream + * will time out. If 0, this call blocks until it can be + * completed. + */ + int reply (ACE_Message_Block *, ACE_Time_Value *timeout = 0); + + /** + * Transfer message to the adjacent ACE_Task in a ACE_Stream. Note + * that @a timeout uses <{absolute}> time rather than <{relative}> + * time. + */ + int put_next (ACE_Message_Block *msg, ACE_Time_Value *timeout = 0); + + /** + * Tests whether we can enqueue a message without blocking. + * + * @deprecated This method is deprecated and will go away in the future. + */ + int can_put (ACE_Message_Block *); + + // = ACE_Task utility routines to identify names et al. + /// Return the name of the enclosing Module if there's one associated + /// with the Task, else returns 0. + const ACE_TCHAR *name (void) const; + + // = Pointers to next ACE_Task_Base (if ACE is part of an ACE_Stream). + /// Get next Task pointer. + ACE_Task *next (void); + + /// Set next Task pointer. + void next (ACE_Task *); + + /// Return the Task's sibling if there's one associated with the + /// Task's Module, else returns 0. + ACE_Task *sibling (void); + + /// Return the Task's Module if there is one, else returns 0. + ACE_Module *module (void) const; + + /** + * Flush the task's queue, i.e., free all of the enqueued + * message blocks and unblocks any threads waiting on the queue. + * Note that if this conflicts with the C++ iostream + * function, just rewrite the iostream function as ::. + */ + int flush (u_long flag = ACE_Task_Flags::ACE_FLUSHALL); + + // = Special routines corresponding to certain message types. + + /// Manipulate watermarks. + void water_marks (ACE_IO_Cntl_Msg::ACE_IO_Cntl_Cmds, size_t); + + /// Queue of messages on the ACE_Task.. + ACE_Message_Queue *msg_queue_; + + /// true if should delete Message_Queue, false otherwise. + bool delete_msg_queue_; + + /// Back-pointer to the enclosing module. + ACE_Module *mod_; + + /// Pointer to adjacent ACE_Task. + ACE_Task *next_; + + /// Dump the state of an object. + void dump (void) const; + + /// Declare the dynamic allocation hooks. + ACE_ALLOC_HOOK_DECLARE; + +private: + + // = Disallow these operations. + ACE_UNIMPLEMENTED_FUNC (void operator= (const ACE_Task &)) + ACE_UNIMPLEMENTED_FUNC (ACE_Task (const ACE_Task &)) +}; + +#if defined ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION_EXPORT +template class ACE_Export ACE_Task; +template class ACE_Export ACE_Task; +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION_EXPORT */ + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +#include "ace/Task_T.inl" +#endif /* __ACE_INLINE__ */ + +#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) +#include "ace/Task_T.cpp" +#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ + +#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) +#pragma implementation ("Task_T.cpp") +#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ + +#include /**/ "ace/post.h" +#endif /* ACE_TASK_T_H */ diff --git a/dep/ACE_wrappers/ace/Task_T.inl b/dep/ACE_wrappers/ace/Task_T.inl new file mode 100644 index 00000000000..a441ca9d0b3 --- /dev/null +++ b/dep/ACE_wrappers/ace/Task_T.inl @@ -0,0 +1,105 @@ +// -*- C++ -*- +// +// $Id: Task_T.inl 80826 2008-03-04 14:51:23Z wotte $ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +template ACE_INLINE void +ACE_Task::water_marks (ACE_IO_Cntl_Msg::ACE_IO_Cntl_Cmds cmd, + size_t wm_size) +{ + ACE_TRACE ("ACE_Task::water_marks"); + if (cmd == ACE_IO_Cntl_Msg::SET_LWM) + this->msg_queue_->low_water_mark (wm_size); + else /* cmd == ACE_IO_Cntl_Msg::SET_HWM */ + this->msg_queue_->high_water_mark (wm_size); +} + +template ACE_INLINE int +ACE_Task::getq (ACE_Message_Block *&mb, ACE_Time_Value *tv) +{ + ACE_TRACE ("ACE_Task::getq"); + return this->msg_queue_->dequeue_head (mb, tv); +} + +template ACE_INLINE int +ACE_Task::can_put (ACE_Message_Block *) +{ + ACE_TRACE ("ACE_Task::can_put"); + ACE_NOTSUP_RETURN (-1); +} + +template ACE_INLINE int +ACE_Task::putq (ACE_Message_Block *mb, ACE_Time_Value *tv) +{ + ACE_TRACE ("ACE_Task::putq"); + return this->msg_queue_->enqueue_tail (mb, tv); +} + +template ACE_INLINE int +ACE_Task::ungetq (ACE_Message_Block *mb, ACE_Time_Value *tv) +{ + ACE_TRACE ("ACE_Task::ungetq"); + return this->msg_queue_->enqueue_head (mb, tv); +} + +template ACE_INLINE int +ACE_Task::flush (u_long flag) +{ + ACE_TRACE ("ACE_Task::flush"); + if (ACE_BIT_ENABLED (flag, ACE_Task_Flags::ACE_FLUSHALL)) + return this->msg_queue_ != 0 && this->msg_queue_->close (); + else + return -1; // Note, need to be more careful about what we free... +} + +template ACE_INLINE void +ACE_Task::msg_queue (ACE_Message_Queue *mq) +{ + ACE_TRACE ("ACE_Task::msg_queue"); + if (this->delete_msg_queue_) + { + delete this->msg_queue_; + this->delete_msg_queue_ = false; + } + this->msg_queue_ = mq; +} + +template ACE_Message_Queue * +ACE_Task::msg_queue (void) +{ + ACE_TRACE ("ACE_Task::msg_queue"); + return this->msg_queue_; +} + +template ACE_INLINE int +ACE_Task::reply (ACE_Message_Block *mb, ACE_Time_Value *tv) +{ + ACE_TRACE ("ACE_Task::reply"); + return this->sibling ()->put_next (mb, tv); +} + +template ACE_INLINE ACE_Task * +ACE_Task::next (void) +{ + ACE_TRACE ("ACE_Task::next"); + return this->next_; +} + +template ACE_INLINE void +ACE_Task::next (ACE_Task *q) +{ + ACE_TRACE ("ACE_Task::next"); + this->next_ = q; +} + +// Transfer msg to the next ACE_Task. + +template ACE_INLINE int +ACE_Task::put_next (ACE_Message_Block *msg, ACE_Time_Value *tv) +{ + ACE_TRACE ("ACE_Task::put_next"); + return this->next_ == 0 ? -1 : this->next_->put (msg, tv); +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Test_and_Set.cpp b/dep/ACE_wrappers/ace/Test_and_Set.cpp new file mode 100644 index 00000000000..15fbfe084f5 --- /dev/null +++ b/dep/ACE_wrappers/ace/Test_and_Set.cpp @@ -0,0 +1,51 @@ +// $Id: Test_and_Set.cpp 80826 2008-03-04 14:51:23Z wotte $ + +#ifndef ACE_TEST_AND_SET_CPP +#define ACE_TEST_AND_SET_CPP + +#include "ace/Test_and_Set.h" +#include "ace/Guard_T.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +template +ACE_Test_and_Set::ACE_Test_and_Set (TYPE initial_value) + : is_set_ (initial_value) +{ +} + +// Returns true if we are done, else false. +template TYPE +ACE_Test_and_Set::is_set (void) const +{ + ACE_GUARD_RETURN (ACE_LOCK, ace_mon, (ACE_LOCK &) this->lock_, this->is_set_); + return this->is_set_; +} + +// Sets the status. +template TYPE +ACE_Test_and_Set::set (TYPE status) +{ + ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, this->is_set_); + TYPE o_status = this->is_set_; + this->is_set_ = status; + return o_status; +} + +template int +ACE_Test_and_Set::handle_signal (int, siginfo_t *, ucontext_t *) +{ + // By setting this to 1, we are "signaling" to anyone calling + // or or that the "test and set" object is in the + // "signaled" state, i.e., it's "available" to be set back to 0. + this->set (1); + return 0; +} + +ACE_END_VERSIONED_NAMESPACE_DECL + +#endif /* ACE_TEST_AND_SET_CPP */ diff --git a/dep/ACE_wrappers/ace/Test_and_Set.h b/dep/ACE_wrappers/ace/Test_and_Set.h new file mode 100644 index 00000000000..062de0bc804 --- /dev/null +++ b/dep/ACE_wrappers/ace/Test_and_Set.h @@ -0,0 +1,75 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Test_and_Set.h + * + * $Id: Test_and_Set.h 80826 2008-03-04 14:51:23Z wotte $ + */ +//============================================================================= + + +#ifndef ACE_TEST_AND_SET_H +#define ACE_TEST_AND_SET_H + +#include /**/ "ace/pre.h" +#include "ace/Event_Handler.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +/** + * @class ACE_Test_and_Set + * + * @brief Implements the classic ``test and set'' operation. + * + * + * This class keeps track of the status of , which can + * be set based on various events (such as receipt of a + * signal). This class is derived from ACE_Event_Handler so + * that it can be "signaled" by a Reactor when a signal occurs. + * We assume that is a data type that can be assigned the + * value 0 or 1. + */ +template +class ACE_Test_and_Set : public ACE_Event_Handler +{ +public: + ACE_Test_and_Set (TYPE initial_value = 0); + + /// Returns true if we are set, else false. + TYPE is_set (void) const; + + /// Sets the status, returning the original value of + /// . + TYPE set (TYPE); + + /// Called when object is signaled by OS (either via UNIX signals or + /// when a Win32 object becomes signaled). + virtual int handle_signal (int signum, + siginfo_t * = 0, + ucontext_t * = 0); + +private: + /// Keeps track of our state. + TYPE is_set_; + + /// Protect the state from race conditions. + ACE_LOCK lock_; +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) +#include "ace/Test_and_Set.cpp" +#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ + +#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) +#pragma implementation ("Test_and_Set.cpp") +#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ + +#include /**/ "ace/post.h" +#endif /* ACE_TEST_AND_SET_H */ diff --git a/dep/ACE_wrappers/ace/Thread.cpp b/dep/ACE_wrappers/ace/Thread.cpp new file mode 100644 index 00000000000..43d9a25baf8 --- /dev/null +++ b/dep/ACE_wrappers/ace/Thread.cpp @@ -0,0 +1,99 @@ +// $Id: Thread.cpp 80826 2008-03-04 14:51:23Z wotte $ + +#include "ace/Thread.h" + +ACE_RCSID(ace, + Thread, + "$Id: Thread.cpp 80826 2008-03-04 14:51:23Z wotte $") + +#if !defined (__ACE_INLINE__) +#include "ace/Thread.inl" +#endif /* !defined (__ACE_INLINE__) */ + +#if defined (ACE_HAS_THREADS) + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +size_t +ACE_Thread::spawn_n (size_t n, + ACE_THR_FUNC func, + void *arg, + long flags, + long priority, + void *stack[], + size_t stack_size[], + ACE_Thread_Adapter *thread_adapter, + const char* thr_name[]) +{ + ACE_TRACE ("ACE_Thread::spawn_n"); + ACE_thread_t t_id; + size_t i; + + for (i = 0; i < n; i++) + // Bail out if error occurs. + if (ACE_OS::thr_create (func, + arg, + flags, + &t_id, + 0, + priority, + stack == 0 ? 0 : stack[i], + stack_size == 0 ? ACE_DEFAULT_THREAD_STACKSIZE : stack_size[i], + thread_adapter, + thr_name == 0 ? 0 : &thr_name[i]) != 0) + break; + + return i; +} + +size_t +ACE_Thread::spawn_n (ACE_thread_t thread_ids[], + size_t n, + ACE_THR_FUNC func, + void *arg, + long flags, + long priority, + void *stack[], + size_t stack_size[], + ACE_hthread_t thread_handles[], + ACE_Thread_Adapter *thread_adapter, + const char* thr_name[]) +{ + ACE_TRACE ("ACE_Thread::spawn_n"); + size_t i = 0; + + for (i = 0; i < n; i++) + { + ACE_thread_t t_id; + ACE_hthread_t t_handle; + + int const result = + ACE_OS::thr_create (func, + arg, + flags, + &t_id, + &t_handle, + priority, + stack == 0 ? 0 : stack[i], + stack_size == 0 ? ACE_DEFAULT_THREAD_STACKSIZE : stack_size[i], + thread_adapter, + thr_name == 0 ? 0 : &thr_name[i]); + + if (result == 0) + { + if (thread_ids != 0) + thread_ids[i] = t_id; + if (thread_handles != 0) + thread_handles[i] = t_handle; + } + else + // Bail out if error occurs. + break; + } + + return i; +} + +ACE_END_VERSIONED_NAMESPACE_DECL + +#endif /* ACE_HAS_THREADS */ diff --git a/dep/ACE_wrappers/ace/Thread.h b/dep/ACE_wrappers/ace/Thread.h new file mode 100644 index 00000000000..4d44858fa5b --- /dev/null +++ b/dep/ACE_wrappers/ace/Thread.h @@ -0,0 +1,282 @@ +// -*- C++ -*- + +//========================================================================== +/** + * @file Thread.h + * + * $Id: Thread.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Douglas Schmidt + */ +//========================================================================== + +#ifndef ACE_THREAD_H +#define ACE_THREAD_H + +#include /**/ "ace/pre.h" + +#include /**/ "ace/ACE_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/OS_NS_Thread.h" +#include "ace/Thread_Adapter.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +struct cancel_state +{ + /// e.g., PTHREAD_CANCEL_ENABLE, PTHREAD_CANCEL_DISABLE, + /// PTHREAD_CANCELED. + int cancelstate; + + /// e.g., PTHREAD_CANCEL_DEFERRED and PTHREAD_CANCEL_ASYNCHRONOUS. + int canceltype; +}; + +/** + * @class ACE_Thread + * + * @brief Provides a wrapper for threads. + * + * This class provides a common interface that is mapped onto + * POSIX Pthreads, Solaris threads, Win32 threads, VxWorks + * threads, or pSoS threads. Note, however, that it is + * generally a better idea to use the ACE_Thread_Manager + * programming API rather than the API since the + * thread manager is more powerful. + */ +class ACE_Export ACE_Thread +{ +public: + /** + * Creates a new thread having @a flags attributes and running @a func + * with (if is non-0 then @a func and + * are ignored and are obtained from ). + * and are set to the thread's ID and handle (?), + * respectively. The thread runs at @a priority priority (see + * below). + * + * The @a flags are a bitwise-OR of the following: + * = BEGIN + * THR_CANCEL_DISABLE, THR_CANCEL_ENABLE, THR_CANCEL_DEFERRED, + * THR_CANCEL_ASYNCHRONOUS, THR_BOUND, THR_NEW_LWP, THR_DETACHED, + * THR_SUSPENDED, THR_DAEMON, THR_JOINABLE, THR_SCHED_FIFO, + * THR_SCHED_RR, THR_SCHED_DEFAULT, THR_EXPLICIT_SCHED, + * THR_SCOPE_SYSTEM, THR_SCOPE_PROCESS + * = END + * + * By default, or if @a priority is set to + * ACE_DEFAULT_THREAD_PRIORITY, an "appropriate" priority value for + * the given scheduling policy (specified in , e.g., + * ) is used. This value is calculated + * dynamically, and is the median value between the minimum and + * maximum priority values for the given policy. If an explicit + * value is given, it is used. Note that actual priority values are + * EXTREMEMLY implementation-dependent, and are probably best + * avoided. + * + * Note that is always deleted when + * is called, so it must be allocated with global operator new. + */ + static int spawn (ACE_THR_FUNC func, + void *arg = 0, + long flags = THR_NEW_LWP | THR_JOINABLE, + ACE_thread_t *t_id = 0, + ACE_hthread_t *t_handle = 0, + long priority = ACE_DEFAULT_THREAD_PRIORITY, + void *stack = 0, + size_t stack_size = ACE_DEFAULT_THREAD_STACKSIZE, + ACE_Thread_Adapter *thread_adapter = 0, + const char** thr_name = 0); + + /** + * Spawn N new threads, which execute @a func with argument @a arg (if + * @a thread_adapter is non-0 then @a func and @a args are ignored and + * are obtained from @a thread_adapter). If @a stack != 0 it is + * assumed to be an array of @a n pointers to the base of the stacks + * to use for the threads being spawned. Likewise, if @a stack_size + * != 0 it is assumed to be an array of @a n values indicating how + * big each of the corresponding @a stacks are. Returns the number + * of threads actually spawned (if this doesn't equal the number + * requested then something has gone wrong and @c errno will + * explain...). + * + * @see spawn() + */ + static size_t spawn_n (size_t n, + ACE_THR_FUNC func, + void *arg = 0, + long flags = THR_NEW_LWP | THR_JOINABLE, + long priority = ACE_DEFAULT_THREAD_PRIORITY, + void *stack[] = 0, + size_t stack_size[] = 0, + ACE_Thread_Adapter *thread_adapter = 0, + const char* thr_name[] = 0); + + /** + * Spawn @a n new threads, which execute @a func with argument @a arg + * (if @a thread_adapter is non-0 then @a func and @a args are ignored + * and are obtained from @a thread_adapter). The thread_ids of + * successfully spawned threads will be placed into the + * buffer (which must be the same size as @a n). If @a stack != 0 it + * is assumed to be an array of @a n pointers to the base of the + * stacks to use for the threads being spawned. If @a stack_size != + * 0 it is assumed to be an array of @a n values indicating how big + * each of the corresponding @a stacks are. If @a thread_handles != 0 + * it is assumed to be an array of @a n thread_handles that will be + * assigned the values of the thread handles being spawned. Returns + * the number of threads actually spawned (if this doesn't equal the + * number requested then something has gone wrong and @c errno will + * explain...). + * + * @see spawn() + */ + static size_t spawn_n (ACE_thread_t thread_ids[], + size_t n, + ACE_THR_FUNC func, + void *arg, + long flags, + long priority = ACE_DEFAULT_THREAD_PRIORITY, + void *stack[] = 0, + size_t stack_size[] = 0, + ACE_hthread_t thread_handles[] = 0, + ACE_Thread_Adapter *thread_adapter = 0, + const char* thr_name[] = 0); + + /** + * Wait for one or more threads to exit and reap their exit status. + * thr_join() returns successfully when the target thread terminates. + * + * @param thread_id is the ACE_thread_t ID of the thread to wait for. + * If @a thread_id is 0, join() waits for any + * undetached thread in the process to terminate + * on platforms that support this capability + * (for example, Solaris). + * @param departed points to a location that is set to the ID of the + * terminated thread if join() returns successfully. + * If @a departed is 0, it is ignored. + * @param status Points to the location that receives the joined + * thread's exit value. If @a status is 0, it is ignored. + * + * @retval 0 for success + * @retval -1 (with errno set) for failure. + */ + static int join (ACE_thread_t thread_id, + ACE_thread_t *departed, + ACE_THR_FUNC_RETURN *status); + + /// Wait for one thread to exit and reap its exit status. + static int join (ACE_hthread_t, + ACE_THR_FUNC_RETURN * = 0); + + /// Continue the execution of a previously suspended thread. + static int resume (ACE_hthread_t); + + /// Suspend the execution of a particular thread. + static int suspend (ACE_hthread_t); + + /// Get the priority of a particular thread. + static int getprio (ACE_hthread_t ht_id, int &priority); + + /// Get the priority and policy of a particular thread. + static int getprio (ACE_hthread_t ht_id, int &priority, int &policy); + + /// Set the priority of a particular thread. + static int setprio (ACE_hthread_t ht_id, int priority, int policy = -1); + + /// Send a signal to the thread. + static int kill (ACE_thread_t, int signum); + + /// Yield the thread to another. + static void yield (void); + + /** + * Return the unique kernel handle of the thread. Note that on + * Win32 this is actually a pseudohandle, which cannot be shared + * with other processes or waited on by threads. To locate the real + * handle, please use the ACE_Thread_Manager::thr_self() method. + */ + static void self (ACE_hthread_t &t_handle); + + /// Return the unique ID of the thread. + static ACE_thread_t self (void); + + /// Exit the current thread and return "status". + /// Should _not_ be called by main thread. + static void exit (ACE_THR_FUNC_RETURN status = 0); + + /// Get the LWP concurrency level of the process. + static int getconcurrency (void); + + /// Set the LWP concurrency level of the process. + static int setconcurrency (int new_level); + + /// Change and/or examine calling thread's signal mask. + static int sigsetmask (int how, + const sigset_t *sigset, + sigset_t *osigset = 0); + + /** + * Allocates a @a keyp that is used to identify data that is specific + * to each thread in the process. The key is global to all threads + * in the process. + */ + static int keycreate (ACE_thread_key_t *keyp, +#if defined (ACE_HAS_THR_C_DEST) + ACE_THR_C_DEST destructor, +#else + ACE_THR_DEST destructor, +#endif /* ACE_HAS_THR_C_DEST */ + void * = 0); + + /// Free up the key so that other threads can reuse it. + static int keyfree (ACE_thread_key_t key); + + /// Bind value to the thread-specific data key, @a key, for the calling + /// thread. + static int setspecific (ACE_thread_key_t key, + void *value); + + /// Stores the current value bound to @a key for the calling thread + /// into the location pointed to by @a valuep. + static int getspecific (ACE_thread_key_t key, + void **valuep); + + /// Disable thread cancellation. + static int disablecancel (struct cancel_state *old_state); + + /// Enable thread cancellation. + static int enablecancel (struct cancel_state *old_state, + int flag); + + /// Set the cancellation state. + static int setcancelstate (struct cancel_state &new_state, + struct cancel_state *old_state); + + /** + * Cancel a thread. + * @note This method is only portable on platforms, such as POSIX pthreads, + * that support thread cancellation. + */ + static int cancel (ACE_thread_t t_id); + + /// Test the cancel. + static void testcancel (void); + +private: + /// Ensure that we don't get instantiated. + ACE_Thread (void); +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +#include "ace/Thread.inl" +#endif /* __ACE_INLINE__ */ + +#include /**/ "ace/post.h" + +#endif /* ACE_THREAD_H */ diff --git a/dep/ACE_wrappers/ace/Thread.inl b/dep/ACE_wrappers/ace/Thread.inl new file mode 100644 index 00000000000..87e47e13580 --- /dev/null +++ b/dep/ACE_wrappers/ace/Thread.inl @@ -0,0 +1,286 @@ +// -*- C++ -*- +// +// $Id: Thread.inl 80826 2008-03-04 14:51:23Z wotte $ + +#include "ace/OS_NS_string.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +// Allocates a that is used to identify data that is specific +// to each thread in the process. The key is global to all threads in +// the process. + +ACE_INLINE int +ACE_Thread::keycreate (ACE_thread_key_t *keyp, +#if defined (ACE_HAS_THR_C_DEST) + ACE_THR_C_DEST destructor, +#else + ACE_THR_DEST destructor, +#endif /* ACE_HAS_THR_C_DEST */ + void *inst) +{ + // ACE_TRACE ("ACE_Thread::keycreate"); + return ACE_OS::thr_keycreate (keyp, destructor, inst); +} + +// Free up the key so that other threads can reuse it. + +ACE_INLINE int +ACE_Thread::keyfree (ACE_thread_key_t key) +{ + ACE_TRACE ("ACE_Thread::keyfree"); + return ACE_OS::thr_keyfree (key); +} + +// Bind value to the thread-specific data key, , for the calling +// thread. + +ACE_INLINE int +ACE_Thread::setspecific (ACE_thread_key_t key, void *value) +{ + // ACE_TRACE ("ACE_Thread::setspecific"); + return ACE_OS::thr_setspecific (key, value); +} + +// Stores the current value bound to for the calling thread +// into the location pointed to by . + +ACE_INLINE int +ACE_Thread::getspecific (ACE_thread_key_t key, void **valuep) +{ + // ACE_TRACE ("ACE_Thread::getspecific"); + return ACE_OS::thr_getspecific (key, valuep); +} + +ACE_INLINE ACE_thread_t +ACE_Thread::self (void) +{ +// ACE_TRACE ("ACE_Thread::self"); + return ACE_OS::thr_self (); +} + +ACE_INLINE void +ACE_Thread::exit (ACE_THR_FUNC_RETURN status) +{ + ACE_TRACE ("ACE_Thread::exit"); + ACE_OS::thr_exit (status); +} + +ACE_INLINE void +ACE_Thread::yield (void) +{ + ACE_TRACE ("ACE_Thread::yield"); + ACE_OS::thr_yield (); +} + +ACE_INLINE int +ACE_Thread::spawn (ACE_THR_FUNC func, + void *arg, + long flags, + ACE_thread_t *t_id, + ACE_hthread_t *t_handle, + long priority, + void *thr_stack, + size_t thr_stack_size, + ACE_Thread_Adapter *thread_adapter, + const char** thr_name) +{ + ACE_TRACE ("ACE_Thread::spawn"); + + return ACE_OS::thr_create (func, + arg, + flags, + t_id, + t_handle, + priority, + thr_stack, + thr_stack_size, + thread_adapter, + thr_name); +} + +ACE_INLINE int +ACE_Thread::resume (ACE_hthread_t t_id) +{ + ACE_TRACE ("ACE_Thread::resume"); + return ACE_OS::thr_continue (t_id); +} + +ACE_INLINE int +ACE_Thread::suspend (ACE_hthread_t t_id) +{ + ACE_TRACE ("ACE_Thread::suspend"); + return ACE_OS::thr_suspend (t_id); +} + +ACE_INLINE int +ACE_Thread::kill (ACE_thread_t t_id, int signum) +{ + ACE_TRACE ("ACE_Thread::kill"); + return ACE_OS::thr_kill (t_id, signum); +} + +ACE_INLINE int +ACE_Thread::join (ACE_thread_t wait_for, + ACE_thread_t *departed, + ACE_THR_FUNC_RETURN *status) +{ + ACE_TRACE ("ACE_Thread::join"); + return ACE_OS::thr_join (wait_for, departed, status); +} + +ACE_INLINE int +ACE_Thread::join (ACE_hthread_t wait_for, + ACE_THR_FUNC_RETURN *status) +{ + ACE_TRACE ("ACE_Thread::join"); + return ACE_OS::thr_join (wait_for, status); +} + +ACE_INLINE int +ACE_Thread::getconcurrency (void) +{ + ACE_TRACE ("ACE_Thread::getconcurrency"); + return ACE_OS::thr_getconcurrency (); +} + +ACE_INLINE int +ACE_Thread::setconcurrency (int new_level) +{ + ACE_TRACE ("ACE_Thread::setconcurrency"); + return ACE_OS::thr_setconcurrency (new_level); +} + +ACE_INLINE int +ACE_Thread::sigsetmask (int how, + const sigset_t *sigset, + sigset_t *osigset) +{ + ACE_TRACE ("ACE_Thread::sigsetmask"); + return ACE_OS::thr_sigsetmask (how, sigset, osigset); +} + +ACE_INLINE int +ACE_Thread::disablecancel (struct cancel_state *old_state) +{ + ACE_TRACE ("ACE_Thread::disablecancel"); + int old_cstate = 0; + int result = ACE_OS::thr_setcancelstate (THR_CANCEL_DISABLE, + &old_cstate); + if (result == 0 && old_state != 0) + { + ACE_OS::memset (old_state, + 0, + sizeof (old_state)); + old_state->cancelstate = old_cstate; + } + + return result; +} + +ACE_INLINE int +ACE_Thread::enablecancel (struct cancel_state *old_state, + int flag) +{ + ACE_TRACE ("ACE_Thread::enablecancel"); + int old_cstate = 0; + int old_ctype = 0; + int result; + + result = ACE_OS::thr_setcancelstate (THR_CANCEL_ENABLE, + &old_cstate); + if (result != 0) + return result; + + result = ACE_OS::thr_setcanceltype (flag, + &old_ctype); + if (result != 0) + return result; + + if (old_state != 0) + { + old_state->cancelstate = old_cstate; + old_state->canceltype = old_ctype; + } + + return 0; +} + +ACE_INLINE int +ACE_Thread::setcancelstate (struct cancel_state &new_state, + struct cancel_state *old_state) +{ + ACE_TRACE ("ACE_Thread::setcancelstate"); + int old_cstate = 0; + int old_ctype = 0; + + if (new_state.cancelstate != 0 + && ACE_OS::thr_setcancelstate (new_state.cancelstate, + &old_cstate) != 0) + return -1; + + if (new_state.canceltype != 0 + && ACE_OS::thr_setcanceltype (new_state.canceltype, + &old_ctype) != 0) + { + int o_cstate; + + ACE_OS::thr_setcancelstate (old_cstate, + &o_cstate); + return -1; + } + + if (old_state != 0) + { + old_state->cancelstate = old_cstate; + old_state->canceltype = old_ctype; + } + + return 0; +} + +ACE_INLINE int +ACE_Thread::cancel (ACE_thread_t t_id) +{ + ACE_TRACE ("ACE_Thread::cancel"); + + return ACE_OS::thr_cancel (t_id); +} + +ACE_INLINE void +ACE_Thread::testcancel (void) +{ + ACE_TRACE ("ACE_Thread::testcancel"); + + ACE_OS::thr_testcancel (); +} + +ACE_INLINE void +ACE_Thread::self (ACE_hthread_t &t_id) +{ +// ACE_TRACE ("ACE_Thread::self"); + ACE_OS::thr_self (t_id); +} + +ACE_INLINE int +ACE_Thread::getprio (ACE_hthread_t ht_id, int &priority) +{ + ACE_TRACE ("ACE_Thread::getprio"); + return ACE_OS::thr_getprio (ht_id, priority); +} + +ACE_INLINE int +ACE_Thread::getprio (ACE_hthread_t ht_id, int &priority, int &policy) +{ + ACE_TRACE ("ACE_Thread::getprio"); + return ACE_OS::thr_getprio (ht_id, priority, policy); +} + +ACE_INLINE int +ACE_Thread::setprio (ACE_hthread_t ht_id, int priority, int policy) +{ + ACE_TRACE ("ACE_Thread::setprio"); + return ACE_OS::thr_setprio (ht_id, priority, policy); +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Thread_Adapter.cpp b/dep/ACE_wrappers/ace/Thread_Adapter.cpp new file mode 100644 index 00000000000..9dbad0580b8 --- /dev/null +++ b/dep/ACE_wrappers/ace/Thread_Adapter.cpp @@ -0,0 +1,228 @@ +// $Id: Thread_Adapter.cpp 81239 2008-04-04 22:28:48Z iliyan $ + +#include "ace/Thread_Adapter.h" +#include "ace/Thread_Manager.h" +#include "ace/Thread_Exit.h" +#include "ace/Thread_Hook.h" +#include "ace/Object_Manager_Base.h" +#include "ace/Service_Config.h" + +ACE_RCSID (ace, + Thread_Adapter, + "$Id: Thread_Adapter.cpp 81239 2008-04-04 22:28:48Z iliyan $") + +#if !defined (ACE_HAS_INLINED_OSCALLS) +# include "ace/Thread_Adapter.inl" +#endif /* ACE_HAS_INLINED_OSCALLS */ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_Thread_Adapter::ACE_Thread_Adapter (ACE_THR_FUNC user_func, + void *arg, + ACE_THR_C_FUNC entry_point, + ACE_Thread_Manager *tm, + ACE_Thread_Descriptor *td +#if defined (ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS) + , ACE_SEH_EXCEPT_HANDLER selector, + ACE_SEH_EXCEPT_HANDLER handler +#endif /* ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS */ + ) + : ACE_Base_Thread_Adapter ( + user_func + , arg + , entry_point + , td +#if defined (ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS) + , selector + , handler +#endif /* ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS */ + ) + , thr_mgr_ (tm) +{ + ACE_OS_TRACE ("ACE_Thread_Adapter::ACE_Thread_Adapter"); +} + +ACE_Thread_Adapter::~ACE_Thread_Adapter (void) +{ +} + +ACE_THR_FUNC_RETURN +ACE_Thread_Adapter::invoke (void) +{ + // Inherit the logging features if the parent thread has an + // ACE_Log_Msg instance in thread-specific storage. + this->inherit_log_msg (); + + ACE_Service_Config::current (ACE_Service_Config::global()); + +#if !defined(ACE_USE_THREAD_MANAGER_ADAPTER) + // NOTE: this preprocessor directive should match the one in above + // ACE_Thread_Exit::instance (). With the Xavier Pthreads package, + // the exit_hook in TSS causes a seg fault. So, this works around + // that by creating exit_hook on the stack. +# if defined (ACE_HAS_THREAD_SPECIFIC_STORAGE) || defined (ACE_HAS_TSS_EMULATION) + // Obtain our thread-specific exit hook and make sure that it knows + // how to clean us up! Note that we never use this pointer directly + // (it's stored in thread-specific storage), so it's ok to + // dereference it here and only store it as a reference. + + // Except if it is null, then the thr_mgr() method crashes. + // -jxh + + ACE_Thread_Exit *exit_hook_instance = ACE_Thread_Exit::instance (); + ACE_Thread_Exit_Maybe exit_hook_maybe (exit_hook_instance == 0); + ACE_Thread_Exit *exit_hook_ptr = exit_hook_instance + ? exit_hook_instance + : exit_hook_maybe.instance (); + ACE_Thread_Exit &exit_hook = *exit_hook_ptr; + + if (this->thr_mgr () != 0) + { + // Keep track of the that's associated with this + // . + exit_hook.thr_mgr (this->thr_mgr ()); + } +# else + // Without TSS, create an instance. When this + // function returns, its destructor will be called because the + // object goes out of scope. The drawback with this appraoch is + // that the destructor _won't_ get called if is called. + // So, threads shouldn't exit that way. Instead, they should return + // from . + ACE_Thread_Exit exit_hook; + exit_hook.thr_mgr (this->thr_mgr ()); +# endif /* ACE_HAS_THREAD_SPECIFIC_STORAGE || ACE_HAS_TSS_EMULATION */ + +#endif /* ! ACE_USE_THREAD_MANAGER_ADAPTER */ + + return this->invoke_i (); +} + +ACE_THR_FUNC_RETURN +ACE_Thread_Adapter::invoke_i (void) +{ + // Extract the arguments. + ACE_THR_FUNC func = reinterpret_cast (this->user_func_); + void *arg = this->arg_; + +#if defined (ACE_WIN32) && defined (ACE_HAS_MFC) && (ACE_HAS_MFC != 0) + ACE_OS_Thread_Descriptor *thr_desc = this->thr_desc_; +#endif /* ACE_WIN32 && ACE_HAS_MFC && (ACE_HAS_MFC != 0) */ + + // Delete ourselves since we don't need anymore. Make sure + // not to access anywhere below this point. + delete this; + +#if defined (ACE_NEEDS_LWP_PRIO_SET) + // On SunOS, the LWP priority needs to be set in order to get + // preemption when running in the RT class. This is the ACE way to + // do that . . . + ACE_hthread_t thr_handle; + ACE_OS::thr_self (thr_handle); + int prio; + + // thr_getprio () on the current thread should never fail. + ACE_OS::thr_getprio (thr_handle, prio); + + // ACE_OS::thr_setprio () has the special logic to set the LWP priority, + // if running in the RT class. + ACE_OS::thr_setprio (prio); + +#endif /* ACE_NEEDS_LWP_PRIO_SET */ + + ACE_THR_FUNC_RETURN status = 0; + + ACE_SEH_TRY + { + ACE_SEH_TRY + { + ACE_Thread_Hook *hook = + ACE_OS_Object_Manager::thread_hook (); + + if (hook) + // Invoke the start hook to give the user a chance to + // perform some initialization processing before the + // is invoked. + status = hook->start (func, arg); + else + // Call thread entry point. + status = (*func) (arg); + } + +#if defined (ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS) + ACE_SEH_EXCEPT (ACE_OS_Object_Manager::seh_except_selector ()( + (void *) GetExceptionInformation ())) + { + ACE_OS_Object_Manager::seh_except_handler ()(0); + } +#endif /* ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS */ + } + + ACE_SEH_FINALLY + { + // If we changed this to 1, change the respective if in + // Task::svc_run to 0. +#if 0 + // Call the close> hook. + if (func == reinterpret_cast ( + ACE_Task_Base::svc_run)) + { + ACE_Task_Base *task_ptr = (ACE_Task_Base *) arg; + ACE_Thread_Manager *thr_mgr_ptr = task_ptr->thr_mgr (); + + // This calls the Task->close () hook. + task_ptr->cleanup (task_ptr, 0); + + // This prevents a second invocation of the cleanup code + // (called later by . + thr_mgr_ptr->at_exit (task_ptr, 0, 0); + } +#endif /* 0 */ + +#if defined (ACE_WIN32) || defined (ACE_HAS_TSS_EMULATION) +# if defined (ACE_WIN32) && defined (ACE_HAS_MFC) && (ACE_HAS_MFC != 0) + int using_afx = -1; + if (thr_desc) + using_afx = ACE_BIT_ENABLED (thr_desc->flags (), THR_USE_AFX); +# endif /* ACE_WIN32 && ACE_HAS_MFC && (ACE_HAS_MFC != 0) */ + // Call TSS destructors. + ACE_OS::cleanup_tss (0 /* not main thread */); + +# if defined (ACE_WIN32) + // Exit the thread. Allow CWinThread-destructor to be invoked + // from AfxEndThread. _endthreadex will be called from + // AfxEndThread so don't exit the thread now if we are running + // an MFC thread. +# if defined (ACE_HAS_MFC) && (ACE_HAS_MFC != 0) + if (using_afx != -1) + { + if (using_afx) + ::AfxEndThread ((DWORD) status); + else + ACE_ENDTHREADEX (status); + } + else + { + // Not spawned by ACE_Thread_Manager, use the old buggy + // version. You should seriously consider using + // ACE_Thread_Manager to spawn threads. The following code + // is know to cause some problem. + CWinThread *pThread = ::AfxGetThread (); + + if (!pThread || pThread->m_nThreadID != ACE_OS::thr_self ()) + ACE_ENDTHREADEX (status); + else + ::AfxEndThread ((DWORD)status); + } +# else + + ACE_ENDTHREADEX (status); +# endif /* ACE_HAS_MFC && ACE_HAS_MFS != 0*/ +# endif /* ACE_WIN32 */ +#endif /* ACE_WIN32 || ACE_HAS_TSS_EMULATION */ + } + + return status; +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Thread_Adapter.h b/dep/ACE_wrappers/ace/Thread_Adapter.h new file mode 100644 index 00000000000..8f1f259eff3 --- /dev/null +++ b/dep/ACE_wrappers/ace/Thread_Adapter.h @@ -0,0 +1,100 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Thread_Adapter.h + * + * $Id: Thread_Adapter.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Carlos O'Ryan + */ +//============================================================================= + +#ifndef ACE_THREAD_ADAPTER_H +#define ACE_THREAD_ADAPTER_H +#include /**/ "ace/pre.h" + +#include /**/ "ace/ACE_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/Base_Thread_Adapter.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +// Forward decl. +class ACE_Thread_Manager; +class ACE_Thread_Descriptor; + +/** + * @class ACE_Thread_Adapter + * + * @brief Converts a C++ function into a function that + * can be called from a thread creation routine + * (e.g., pthread_create() or _beginthreadex()) that expects an + * extern "C" entry point. This class also makes it possible to + * transparently provide hooks to register a thread with an + * ACE_Thread_Manager. + * + * This class is used in ACE_OS::thr_create(). In general, the + * thread that creates an object of this class is different from + * the thread that calls @c invoke() on this object. Therefore, + * the @c invoke() method is responsible for deleting itself. + */ +class ACE_Export ACE_Thread_Adapter : public ACE_Base_Thread_Adapter +{ +public: + /// Constructor. + ACE_Thread_Adapter (ACE_THR_FUNC user_func, + void *arg, + ACE_THR_C_FUNC entry_point = (ACE_THR_C_FUNC) ACE_THREAD_ADAPTER_NAME, + ACE_Thread_Manager *thr_mgr = 0, + ACE_Thread_Descriptor *td = 0 +# if defined (ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS) + , ACE_SEH_EXCEPT_HANDLER selector = 0, + ACE_SEH_EXCEPT_HANDLER handler = 0 +# endif /* ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS */ + ); + + /** + * Execute the with the . This function deletes + * @c this, thereby rendering the object useless after the call + * returns. + */ + virtual ACE_THR_FUNC_RETURN invoke (void); + + /// Accessor for the optional ACE_Thread_Manager. + ACE_Thread_Manager *thr_mgr (void); + +protected: + + /// Ensure that this object must be allocated on the heap. + ~ACE_Thread_Adapter (void); + +private: + + /// Called by invoke, mainly here to separate the SEH stuff because + /// SEH on Win32 doesn't compile with local vars with destructors. + virtual ACE_THR_FUNC_RETURN invoke_i (void); + +private: + + /// Optional thread manager. + ACE_Thread_Manager *thr_mgr_; + +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +# if defined (ACE_HAS_INLINED_OSCALLS) +# if defined (ACE_INLINE) +# undef ACE_INLINE +# endif /* ACE_INLINE */ +# define ACE_INLINE inline +# include "ace/Thread_Adapter.inl" +# endif /* ACE_HAS_INLINED_OSCALLS */ + +#include /**/ "ace/post.h" +#endif /* ACE_THREAD_ADAPTER_H */ diff --git a/dep/ACE_wrappers/ace/Thread_Adapter.inl b/dep/ACE_wrappers/ace/Thread_Adapter.inl new file mode 100644 index 00000000000..6def13be5ab --- /dev/null +++ b/dep/ACE_wrappers/ace/Thread_Adapter.inl @@ -0,0 +1,13 @@ +// -*- C++ -*- +// +// $Id: Thread_Adapter.inl 80826 2008-03-04 14:51:23Z wotte $ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_INLINE ACE_Thread_Manager * +ACE_Thread_Adapter::thr_mgr (void) +{ + return this->thr_mgr_; +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Thread_Control.cpp b/dep/ACE_wrappers/ace/Thread_Control.cpp new file mode 100644 index 00000000000..51d0f4c18eb --- /dev/null +++ b/dep/ACE_wrappers/ace/Thread_Control.cpp @@ -0,0 +1,96 @@ +// $Id: Thread_Control.cpp 80826 2008-03-04 14:51:23Z wotte $ + +// +#include "ace/config-all.h" +#if defined (ACE_LEGACY_MODE) +// This silly include breaks a cycle when compiling in backwards +// compatibility mode +# include "ace/Thread_Exit.h" +#endif /* ACE_LEGACY_MODE */ +// + +#include "ace/Thread_Control.h" +#include "ace/Thread_Manager.h" + +ACE_RCSID(ace, Thread_Control, "$Id: Thread_Control.cpp 80826 2008-03-04 14:51:23Z wotte $") + +#if !defined (ACE_HAS_INLINED_OSCALLS) +# include "ace/Thread_Control.inl" +#endif /* ACE_HAS_INLINED_OSCALLS */ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +void +ACE_Thread_Control::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + ACE_OS_TRACE ("ACE_Thread_Control::dump"); +#endif /* ACE_HAS_DUMP */ +} + +int +ACE_Thread_Control::insert (ACE_Thread_Manager *tm, int insert) +{ + ACE_OS_TRACE ("ACE_Thread_Control::insert"); + + ACE_hthread_t t_id; + ACE_OS::thr_self (t_id); + this->tm_ = tm; + + if (insert) + return this->tm_->insert_thr (ACE_OS::thr_self (), t_id); + else + return 0; +} + +// Initialize the thread controller. + +ACE_Thread_Control::ACE_Thread_Control (ACE_Thread_Manager *t, + int insert) + : tm_ (t), + status_ (0) +{ + ACE_OS_TRACE ("ACE_Thread_Control::ACE_Thread_Control"); + + if (this->tm_ != 0 && insert) + { + ACE_hthread_t t_id; + ACE_OS::thr_self (t_id); + this->tm_->insert_thr (ACE_OS::thr_self (), t_id); + } +} + +// Automatically kill thread on exit. + +ACE_Thread_Control::~ACE_Thread_Control (void) +{ + ACE_OS_TRACE ("ACE_Thread_Control::~ACE_Thread_Control"); + +#if defined (ACE_HAS_RECURSIVE_THR_EXIT_SEMANTICS) || defined (ACE_HAS_TSS_EMULATION) || defined (ACE_WIN32) + this->exit (this->status_, 0); +#else + this->exit (this->status_, 1); +#endif /* ACE_HAS_RECURSIVE_THR_EXIT_SEMANTICS */ +} + +// Exit from thread (but clean up first). + +ACE_THR_FUNC_RETURN +ACE_Thread_Control::exit (ACE_THR_FUNC_RETURN exit_status, int do_thr_exit) +{ + ACE_OS_TRACE ("ACE_Thread_Control::exit"); + + if (this->tm_ != 0) + return this->tm_->exit (exit_status, do_thr_exit); + else + { +#if !defined (ACE_HAS_TSS_EMULATION) + // With ACE_HAS_TSS_EMULATION, we let ACE_Thread_Adapter::invoke () + // exit the thread after cleaning up TSS. + ACE_OS::thr_exit (exit_status); +#endif /* ! ACE_HAS_TSS_EMULATION */ + return 0; + } +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Thread_Control.h b/dep/ACE_wrappers/ace/Thread_Control.h new file mode 100644 index 00000000000..3eb5185c84c --- /dev/null +++ b/dep/ACE_wrappers/ace/Thread_Control.h @@ -0,0 +1,102 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Thread_Control.h + * + * $Id: Thread_Control.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Carlos O'Ryan + */ +//============================================================================= + + +#ifndef ACE_THREAD_CONTROL_H +#define ACE_THREAD_CONTROL_H +#include /**/ "ace/pre.h" + +#include /**/ "ace/ACE_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +class ACE_Thread_Manager; + +/** + * @class ACE_Thread_Control + * + * @brief Used to keep track of a thread's activities within its entry + * point function. + * + * A ACE_Thread_Manager uses this class to ensure that threads + * it spawns automatically register and unregister themselves + * with it. + * This class can be stored in thread-specific storage using the + * ACE_TSS wrapper. When a thread exits the + * function deletes this object, thereby + * ensuring that it gets removed from its associated + * ACE_Thread_Manager. + */ +class ACE_Export ACE_Thread_Control +{ +public: + /// Initialize the thread control object. If @a insert != 0, then + /// register the thread with the Thread_Manager. + ACE_Thread_Control (ACE_Thread_Manager *tm = 0, + int insert = 0); + + /// Remove the thread from its associated and exit + /// the thread if is enabled. + ~ACE_Thread_Control (void); + + /// Remove this thread from its associated ACE_Thread_Manager and exit + /// the thread if @a do_thr_exit is enabled. + ACE_THR_FUNC_RETURN exit (ACE_THR_FUNC_RETURN status, + int do_thr_exit); + + /// Store the and use it to register ourselves for + /// correct shutdown. + int insert (ACE_Thread_Manager *tm, int insert = 0); + + /// Returns the current . + ACE_Thread_Manager *thr_mgr (void); + + /// Atomically set a new and return the old + /// . + ACE_Thread_Manager *thr_mgr (ACE_Thread_Manager *); + + /// Set the exit status (and return existing status). + ACE_THR_FUNC_RETURN status (ACE_THR_FUNC_RETURN status); + + /// Get the current exit status. + ACE_THR_FUNC_RETURN status (void); + + /// Dump the state of an object. + void dump (void) const; + + /// Declare the dynamic allocation hooks. + ACE_ALLOC_HOOK_DECLARE; + +private: + /// Pointer to the thread manager for this block of code. + ACE_Thread_Manager *tm_; + + /// Keeps track of the exit status for the thread. + ACE_THR_FUNC_RETURN status_; +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +# if defined (ACE_HAS_INLINED_OSCALLS) +# if defined (ACE_INLINE) +# undef ACE_INLINE +# endif /* ACE_INLINE */ +# define ACE_INLINE inline +# include "ace/Thread_Control.inl" +# endif /* ACE_HAS_INLINED_OSCALLS */ + +#include /**/ "ace/post.h" +#endif /* ACE_THREAD_CONTROL_H */ diff --git a/dep/ACE_wrappers/ace/Thread_Control.inl b/dep/ACE_wrappers/ace/Thread_Control.inl new file mode 100644 index 00000000000..6ebd3ac2c56 --- /dev/null +++ b/dep/ACE_wrappers/ace/Thread_Control.inl @@ -0,0 +1,46 @@ +// -*- C++ -*- +// +// $Id: Thread_Control.inl 80826 2008-03-04 14:51:23Z wotte $ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +// Set the exit status. + +ACE_INLINE ACE_THR_FUNC_RETURN +ACE_Thread_Control::status (ACE_THR_FUNC_RETURN s) +{ + ACE_OS_TRACE ("ACE_Thread_Control::status"); + return this->status_ = s; +} + +// Get the exit status. + +ACE_INLINE ACE_THR_FUNC_RETURN +ACE_Thread_Control::status (void) +{ + ACE_OS_TRACE ("ACE_Thread_Control::status"); + return this->status_; +} + +// Returns the current . + +ACE_INLINE ACE_Thread_Manager * +ACE_Thread_Control::thr_mgr (void) +{ + ACE_OS_TRACE ("ACE_Thread_Control::thr_mgr"); + return this->tm_; +} + +// Atomically set a new and return the old +// . + +ACE_INLINE ACE_Thread_Manager * +ACE_Thread_Control::thr_mgr (ACE_Thread_Manager *tm) +{ + ACE_OS_TRACE ("ACE_Thread_Control::thr_mgr"); + ACE_Thread_Manager *o_tm = this->tm_; + this->tm_ = tm; + return o_tm; +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Thread_Exit.cpp b/dep/ACE_wrappers/ace/Thread_Exit.cpp new file mode 100644 index 00000000000..cc6a8620cbe --- /dev/null +++ b/dep/ACE_wrappers/ace/Thread_Exit.cpp @@ -0,0 +1,123 @@ +// $Id: Thread_Exit.cpp 80826 2008-03-04 14:51:23Z wotte $ + +#include "ace/Thread_Exit.h" +#include "ace/Managed_Object.h" +#include "ace/Thread_Manager.h" +#include "ace/Guard_T.h" + +ACE_RCSID(ace, Thread_Exit, "$Id: Thread_Exit.cpp 80826 2008-03-04 14:51:23Z wotte $") + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +bool ACE_Thread_Exit::is_constructed_ = false; + +void +ACE_Thread_Exit::cleanup (void *instance) +{ + ACE_OS_TRACE ("ACE_Thread_Exit::cleanup"); + + delete (ACE_TSS_TYPE (ACE_Thread_Exit) *) instance; + + // Set the thr_exit_ static to null to keep things from crashing if + // ACE::fini() is enabled here. + ACE_Thread_Manager::thr_exit_ = 0; + + ACE_Thread_Exit::is_constructed_ = false; + // All TSS objects have been destroyed. Reset this flag so + // ACE_Thread_Exit singleton can be created again. +} + +// NOTE: this preprocessor directive should match the one in +// ACE_Task_Base::svc_run () below. This prevents the two statics +// from being defined. + +ACE_Thread_Exit * +ACE_Thread_Exit::instance (void) +{ +#if defined (ACE_HAS_THREAD_SPECIFIC_STORAGE) || defined (ACE_HAS_TSS_EMULATION) + ACE_OS_TRACE ("ACE_Thread_Exit::instance"); + + // Determines if we were dynamically allocated. + static ACE_TSS_TYPE (ACE_Thread_Exit) * volatile instance_; + + // Implement the Double Check pattern. + + if (!ACE_Thread_Exit::is_constructed_) + { + ACE_MT (ACE_Thread_Mutex *lock = + ACE_Managed_Object::get_preallocated_object + (ACE_Object_Manager::ACE_THREAD_EXIT_LOCK); + ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, *lock, 0)); + + if (!ACE_Thread_Exit::is_constructed_) + { + ACE_NEW_RETURN (instance_, + ACE_TSS_TYPE (ACE_Thread_Exit), + 0); + + ACE_Thread_Exit::is_constructed_ = true; + + ACE_Thread_Manager::set_thr_exit (instance_); + } + } + + return ACE_TSS_GET (instance_, ACE_Thread_Exit); +#else + return 0; +#endif /* ACE_HAS_THREAD_SPECIFIC_STORAGE || ACE_HAS_TSS_EMULATION */ +} + +// Grab hold of the Task * so that we can close() it in the +// destructor. + +ACE_Thread_Exit::ACE_Thread_Exit (void) +{ + ACE_OS_TRACE ("ACE_Thread_Exit::ACE_Thread_Exit"); +} + +// Set the this pointer... + +void +ACE_Thread_Exit::thr_mgr (ACE_Thread_Manager *tm) +{ + ACE_OS_TRACE ("ACE_Thread_Exit::thr_mgr"); + + if (tm != 0) + this->thread_control_.insert (tm, 0); +} + +// When this object is destroyed the Task is automatically closed +// down! + +ACE_Thread_Exit::~ACE_Thread_Exit (void) +{ + ACE_OS_TRACE ("ACE_Thread_Exit::~ACE_Thread_Exit"); +} + +ACE_Thread_Exit_Maybe::ACE_Thread_Exit_Maybe (int flag) + : instance_ (0) +{ + if (flag) + { + ACE_NEW (instance_, ACE_Thread_Exit); + } +} + +ACE_Thread_Exit_Maybe::~ACE_Thread_Exit_Maybe (void) +{ + delete this->instance_; +} + +ACE_Thread_Exit * +ACE_Thread_Exit_Maybe::operator -> (void) const +{ + return this->instance_; +} + +ACE_Thread_Exit * +ACE_Thread_Exit_Maybe::instance (void) const +{ + return this->instance_; +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Thread_Exit.h b/dep/ACE_wrappers/ace/Thread_Exit.h new file mode 100644 index 00000000000..5b614e2e807 --- /dev/null +++ b/dep/ACE_wrappers/ace/Thread_Exit.h @@ -0,0 +1,111 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Thread_Exit.h + * + * $Id: Thread_Exit.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Carlos O'Ryan + */ +//============================================================================= + + +#ifndef ACE_THREAD_EXIT_H +#define ACE_THREAD_EXIT_H +#include /**/ "ace/pre.h" + +#include /**/ "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/Thread_Control.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +/** + * @class ACE_Thread_Exit + * + * @brief Keep exit information for a Thread in thread specific storage. + * so that the thread-specific exit hooks will get called no + * matter how the thread exits (e.g., via , C++ + * or Win32 exception, "falling off the end" of the thread entry + * point function, etc.). + * + * This clever little helper class is stored in thread-specific + * storage using the wrapper. When a thread exits the + * function deletes this object, thereby + * closing it down gracefully. + */ +class ACE_Export ACE_Thread_Exit +{ +public: + /// Capture the Thread that will be cleaned up automatically. + ACE_Thread_Exit (void); + + /// Set the ACE_Thread_Manager. + void thr_mgr (ACE_Thread_Manager *tm); + + /// Destructor calls the thread-specific exit hooks when a thread + /// exits. + ~ACE_Thread_Exit (void); + + /// Singleton access point. + static ACE_Thread_Exit *instance (void); + + /// Cleanup method, used by the ACE_Object_Manager to destroy the + /// singleton. + static void cleanup (void *instance); + +private: + /// Automatically add/remove the thread from the + /// ACE_Thread_Manager. + ACE_Thread_Control thread_control_; + + /** + * Used to detect whether we should create a new instance (or not) + * within the instance method -- we don't trust the instance_ ptr + * because the destructor may have run (if ACE::fini() was called). + * See bug #526. + * We don't follow the singleton pattern due to dependency issues. + */ + static bool is_constructed_; +}; + +/** + * @class ACE_Thread_Exit_Maybe + * + * @brief A version of ACE_Thread_Exit that is created dynamically + * under the hood if the flag is set to TRUE. + * + * Allows the appearance of a "smart pointer", but is not + * always created. + */ +class ACE_Export ACE_Thread_Exit_Maybe +{ +public: + /// Don't create an ACE_Thread_Exit instance by default. + ACE_Thread_Exit_Maybe (int flag = 0); + + /// Destroys the underlying ACE_Thread_Exit instance if it exists. + ~ACE_Thread_Exit_Maybe (void); + + /// Delegates to underlying instance. + ACE_Thread_Exit * operator -> (void) const; + + /// Returns the underlying instance. + ACE_Thread_Exit * instance (void) const; + +private: + + /// Holds the underlying instance. + ACE_Thread_Exit *instance_; + +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#include /**/ "ace/post.h" +#endif /* ACE_THREAD_EXIT_H */ diff --git a/dep/ACE_wrappers/ace/Thread_Hook.cpp b/dep/ACE_wrappers/ace/Thread_Hook.cpp new file mode 100644 index 00000000000..79d937f9ff5 --- /dev/null +++ b/dep/ACE_wrappers/ace/Thread_Hook.cpp @@ -0,0 +1,33 @@ +// $Id: Thread_Hook.cpp 80826 2008-03-04 14:51:23Z wotte $ + +#include "ace/Thread_Hook.h" +#include "ace/Object_Manager_Base.h" + +ACE_RCSID(ace, Thread_Hook, "$Id: Thread_Hook.cpp 80826 2008-03-04 14:51:23Z wotte $") + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_Thread_Hook::~ACE_Thread_Hook () +{ +} + +ACE_THR_FUNC_RETURN +ACE_Thread_Hook::start (ACE_THR_FUNC func, + void *arg) +{ + return (func) (arg); +} + +ACE_Thread_Hook * +ACE_Thread_Hook::thread_hook (ACE_Thread_Hook *hook) +{ + return ACE_OS_Object_Manager::thread_hook (hook); +} + +ACE_Thread_Hook * +ACE_Thread_Hook::thread_hook (void) +{ + return ACE_OS_Object_Manager::thread_hook (); +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Thread_Hook.h b/dep/ACE_wrappers/ace/Thread_Hook.h new file mode 100644 index 00000000000..7bc3bcce492 --- /dev/null +++ b/dep/ACE_wrappers/ace/Thread_Hook.h @@ -0,0 +1,65 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Thread_Hook.h + * + * $Id: Thread_Hook.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Carlos O'Ryan + */ +//============================================================================= + + +#ifndef ACE_THREAD_HOOK_H +#define ACE_THREAD_HOOK_H +#include /**/ "ace/pre.h" + +#include /**/ "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include /**/ "ace/ACE_export.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +/** + * @class ACE_Thread_Hook + * + * @brief This class makes it possible to provide user-defined "start" + * hooks that are called before the thread entry point function + * is invoked. + */ +class ACE_Export ACE_Thread_Hook +{ + +public: + + /// Destructor. + virtual ~ACE_Thread_Hook (void); + + /** + * This method can be overridden in a subclass to customize this + * pre-function call "hook" invocation that can perform + * initialization processing before the thread entry point @a func + * method is called back. The @a func and @a arg passed into the + * start hook are the same as those passed by the application that + * spawned the thread. + */ + virtual ACE_THR_FUNC_RETURN start (ACE_THR_FUNC func, + void *arg); + + /// sets the system wide thread hook, returns the previous thread + /// hook or 0 if none is set. + static ACE_Thread_Hook *thread_hook (ACE_Thread_Hook *hook); + + /// Returns the current system thread hook. + static ACE_Thread_Hook *thread_hook (void); +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#include /**/ "ace/post.h" +#endif /* ACE_THREAD_HOOK_H */ diff --git a/dep/ACE_wrappers/ace/Thread_Manager.cpp b/dep/ACE_wrappers/ace/Thread_Manager.cpp new file mode 100644 index 00000000000..1cb7126b4d6 --- /dev/null +++ b/dep/ACE_wrappers/ace/Thread_Manager.cpp @@ -0,0 +1,2221 @@ +// $Id: Thread_Manager.cpp 82600 2008-08-12 08:04:24Z johnnyw $ + +#include "ace/TSS_T.h" +#include "ace/Thread_Manager.h" +#include "ace/Dynamic.h" +#include "ace/Object_Manager.h" +#include "ace/Singleton.h" +#include "ace/Auto_Ptr.h" +#include "ace/Guard_T.h" +#include "ace/Time_Value.h" +#include "ace/OS_NS_sys_time.h" +#include "ace/Truncate.h" + +#if !defined (__ACE_INLINE__) +#include "ace/Thread_Manager.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID (ace, + Thread_Manager, + "$Id: Thread_Manager.cpp 82600 2008-08-12 08:04:24Z johnnyw $") + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_At_Thread_Exit::~ACE_At_Thread_Exit (void) +{ + this->do_apply (); +} + +ACE_At_Thread_Exit_Func::~ACE_At_Thread_Exit_Func (void) +{ + this->do_apply (); +} + +void +ACE_At_Thread_Exit_Func::apply (void) +{ + this->func_ (this->object_, this->param_); +} + +ACE_ALLOC_HOOK_DEFINE(ACE_Thread_Control) +ACE_ALLOC_HOOK_DEFINE(ACE_Thread_Manager) + +#if ! defined (ACE_THREAD_MANAGER_LACKS_STATICS) +// Process-wide Thread Manager. +ACE_Thread_Manager *ACE_Thread_Manager::thr_mgr_ = 0; + +// Controls whether the Thread_Manager is deleted when we shut down +// (we can only delete it safely if we created it!) +bool ACE_Thread_Manager::delete_thr_mgr_ = false; +#endif /* ! defined (ACE_THREAD_MANAGER_LACKS_STATICS) */ + +ACE_TSS_TYPE (ACE_Thread_Exit) *ACE_Thread_Manager::thr_exit_ = 0; + +int +ACE_Thread_Manager::set_thr_exit (ACE_TSS_TYPE (ACE_Thread_Exit) *ptr) +{ + if (ACE_Thread_Manager::thr_exit_ == 0) + ACE_Thread_Manager::thr_exit_ = ptr; + else + return -1; + return 0; +} + +void +ACE_Thread_Manager::dump (void) +{ +#if defined (ACE_HAS_DUMP) + ACE_TRACE ("ACE_Thread_Manager::dump"); + // Cast away const-ness of this in order to use its non-const lock_. + ACE_MT (ACE_GUARD (ACE_Thread_Mutex, ace_mon, + ((ACE_Thread_Manager *) this)->lock_)); + + ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); + + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\ngrp_id_ = %d"), this->grp_id_)); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\ncurrent_count_ = %d"), this->thr_list_.size ())); + + for (ACE_Double_Linked_List_Iterator iter (this->thr_list_); + !iter.done (); + iter.advance ()) + { + iter.next ()->dump (); + } + + ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); +#endif /* ACE_HAS_DUMP */ +} + +ACE_Thread_Descriptor::~ACE_Thread_Descriptor (void) +{ + delete this->sync_; +} + +void +ACE_Thread_Descriptor::at_pop (int apply) +{ + ACE_TRACE ("ACE_Thread_Descriptor::at_pop"); + // Get first at from at_exit_list + ACE_At_Thread_Exit* at = this->at_exit_list_; + // Remove at from at_exit list + this->at_exit_list_ = at->next_; + // Apply if required + if (apply) + { + at->apply (); + // Do the apply method + at->was_applied (true); + // Mark at has been applied to avoid double apply from + // at destructor + } + // If at is not owner delete at. + if (!at->is_owner ()) + delete at; +} + +void +ACE_Thread_Descriptor::at_push (ACE_At_Thread_Exit* cleanup, bool is_owner) +{ + ACE_TRACE ("ACE_Thread_Descriptor::at_push"); + cleanup->is_owner (is_owner); + cleanup->td_ = this; + cleanup->next_ = at_exit_list_; + at_exit_list_ = cleanup; +} + +int +ACE_Thread_Descriptor::at_exit (ACE_At_Thread_Exit& cleanup) +{ + ACE_TRACE ("ACE_Thread_Descriptor::at_exit"); + at_push (&cleanup, 1); + return 0; +} + +int +ACE_Thread_Descriptor::at_exit (ACE_At_Thread_Exit* cleanup) +{ + ACE_TRACE ("ACE_Thread_Descriptor::at_exit"); + if (cleanup==0) + return -1; + else + { + this->at_push (cleanup); + return 0; + } +} + +void +ACE_Thread_Descriptor::do_at_exit () +{ + ACE_TRACE ("ACE_Thread_Descriptor::do_at_exit"); + while (at_exit_list_!=0) + this->at_pop (); +} + +void +ACE_Thread_Descriptor::terminate () +{ + ACE_TRACE ("ACE_Thread_Descriptor::terminate"); + + if (!terminated_) + { + ACE_Log_Msg* log_msg = this->log_msg_; + terminated_ = true; + // Run at_exit hooks + this->do_at_exit (); + // We must remove Thread_Descriptor from Thread_Manager list + if (this->tm_ != 0) + { + int close_handle = 0; + +#if !defined (ACE_HAS_VXTHREADS) + // Threads created with THR_DAEMON shouldn't exist here, but + // just to be safe, let's put it here. + + if (ACE_BIT_DISABLED (this->thr_state_, ACE_Thread_Manager::ACE_THR_JOINING)) + { + if (ACE_BIT_DISABLED (this->flags_, THR_DETACHED | THR_DAEMON) + || ACE_BIT_ENABLED (this->flags_, THR_JOINABLE)) + { + // Mark thread as terminated. + ACE_SET_BITS (this->thr_state_, ACE_Thread_Manager::ACE_THR_TERMINATED); + tm_->register_as_terminated (this); + // Must copy the information here because td will be + // "freed" below. + } +#if defined (ACE_WIN32) + else + { + close_handle = 1; + } +#endif /* ACE_WIN32 */ + } +#endif /* !ACE_HAS_VXTHREADS */ + + // Remove thread descriptor from the table. + if (this->tm_ != 0) + tm_->remove_thr (this, close_handle); + } + + // Check if we need delete ACE_Log_Msg instance + // If ACE_TSS_cleanup was not executed first log_msg == 0 + if (log_msg == 0) + { + // Only inform to ACE_TSS_cleanup that it must delete the log instance + // setting ACE_LOG_MSG thr_desc to 0. + ACE_LOG_MSG->thr_desc (0); + } + else + { + // Thread_Descriptor is the owner of the Log_Msg instance!! + // deleted. + this->log_msg_ = 0; + delete log_msg; + } + } +} + +int +ACE_Thread_Descriptor::at_exit (void *object, + ACE_CLEANUP_FUNC cleanup_hook, + void *param) +{ + ACE_TRACE ("ACE_Thread_Descriptor::at_exit"); + // To keep compatibility, when cleanup_hook is null really is a at_pop + // without apply. + if (cleanup_hook == 0) + { + if (this->at_exit_list_!= 0) + this->at_pop(0); + } + else + { + ACE_At_Thread_Exit* cleanup = 0; + ACE_NEW_RETURN (cleanup, + ACE_At_Thread_Exit_Func (object, + cleanup_hook, + param), + -1); + this->at_push (cleanup); + } + return 0; +} + +void +ACE_Thread_Descriptor::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + ACE_TRACE ("ACE_Thread_Descriptor::dump"); + ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); + + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nthr_id_ = %d"), this->thr_id_)); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nthr_handle_ = %d"), this->thr_handle_)); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\ngrp_id_ = %d"), this->grp_id_)); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nthr_state_ = %d"), this->thr_state_)); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\ncleanup_info_.cleanup_hook_ = %x"), this->cleanup_info_.cleanup_hook_)); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nflags_ = %x\n"), this->flags_)); + + ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); +#endif /* ACE_HAS_DUMP */ +} + +ACE_Thread_Descriptor::ACE_Thread_Descriptor (void) + : log_msg_ (0), + at_exit_list_ (0), + terminated_ (false) +{ + ACE_TRACE ("ACE_Thread_Descriptor::ACE_Thread_Descriptor"); + ACE_NEW (this->sync_, + ACE_DEFAULT_THREAD_MANAGER_LOCK); +} + +void +ACE_Thread_Descriptor::acquire_release (void) +{ + // Just try to acquire the lock then release it. +#if defined (ACE_THREAD_MANAGER_USES_SAFE_SPAWN) + if (ACE_BIT_DISABLED (this->thr_state_, ACE_Thread_Manager::ACE_THR_SPAWNED)) +#endif /* ACE_THREAD_MANAGER_USES_SAFE_SPAWN */ + { + this->sync_->acquire (); + // Acquire the lock before removing from the thread table. If + // this thread is in the table already, it should simply acquire the + // lock easily. + + // Once we get the lock, we must have registered. + ACE_ASSERT (ACE_BIT_ENABLED (this->thr_state_, ACE_Thread_Manager::ACE_THR_SPAWNED)); + + this->sync_->release (); + // Release the lock before putting it back to freelist. + } +} + +void +ACE_Thread_Descriptor::acquire (void) +{ + // Just try to acquire the lock then release it. +#if defined (ACE_THREAD_MANAGER_USES_SAFE_SPAWN) + if (ACE_BIT_DISABLED (this->thr_state_, ACE_Thread_Manager::ACE_THR_SPAWNED)) +#endif /* ACE_THREAD_MANAGER_USES_SAFE_SPAWN */ + { + this->sync_->acquire (); + } +} + +void +ACE_Thread_Descriptor::release (void) +{ + // Just try to acquire the lock then release it. +#if defined (ACE_THREAD_MANAGER_USES_SAFE_SPAWN) + if (ACE_BIT_DISABLED (this->thr_state_, ACE_Thread_Manager::ACE_THR_SPAWNED)) +#endif /* ACE_THREAD_MANAGER_USES_SAFE_SPAWN */ + { + this->sync_->release (); + // Release the lock before putting it back to freelist. + } +} + +// The following macro simplifies subsequence code. +#define ACE_FIND(OP,INDEX) \ + ACE_Thread_Descriptor *INDEX = OP; \ + +ACE_Thread_Descriptor * +ACE_Thread_Manager::thread_descriptor (ACE_thread_t thr_id) +{ + ACE_TRACE ("ACE_Thread_Manager::thread_descriptor"); + ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, 0)); + + ACE_FIND (this->find_thread (thr_id), ptr); + return ptr; +} + +ACE_Thread_Descriptor * +ACE_Thread_Manager::hthread_descriptor (ACE_hthread_t thr_handle) +{ + ACE_TRACE ("ACE_Thread_Manager::hthread_descriptor"); + ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, 0)); + + ACE_FIND (this->find_hthread (thr_handle), ptr); + return ptr; +} + +// Return the thread descriptor (indexed by ACE_hthread_t). + +int +ACE_Thread_Manager::thr_self (ACE_hthread_t &self) +{ + ACE_TRACE ("ACE_Thread_Manager::thr_self"); + + ACE_Thread_Descriptor *desc = + this->thread_desc_self (); + + if (desc == 0) + return -1; + else + desc->self (self); + + return 0; +} + +// Initialize the synchronization variables. + +ACE_Thread_Manager::ACE_Thread_Manager (size_t prealloc, + size_t lwm, + size_t inc, + size_t hwm) + : grp_id_ (1), + automatic_wait_ (1) +#if defined (ACE_HAS_THREADS) + , zero_cond_ (lock_) +#endif /* ACE_HAS_THREADS */ + , thread_desc_freelist_ (ACE_FREE_LIST_WITH_POOL, + prealloc, lwm, hwm, inc) +{ + ACE_TRACE ("ACE_Thread_Manager::ACE_Thread_Manager"); +} + +#if ! defined (ACE_THREAD_MANAGER_LACKS_STATICS) +ACE_Thread_Manager * +ACE_Thread_Manager::instance (void) +{ + ACE_TRACE ("ACE_Thread_Manager::instance"); + + if (ACE_Thread_Manager::thr_mgr_ == 0) + { + // Perform Double-Checked Locking Optimization. + ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon, + *ACE_Static_Object_Lock::instance (), 0)); + + if (ACE_Thread_Manager::thr_mgr_ == 0) + { + ACE_NEW_RETURN (ACE_Thread_Manager::thr_mgr_, + ACE_Thread_Manager, + 0); + ACE_Thread_Manager::delete_thr_mgr_ = true; + } + } + + return ACE_Thread_Manager::thr_mgr_; +} + +ACE_Thread_Manager * +ACE_Thread_Manager::instance (ACE_Thread_Manager *tm) +{ + ACE_TRACE ("ACE_Thread_Manager::instance"); + ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon, + *ACE_Static_Object_Lock::instance (), 0)); + + ACE_Thread_Manager *t = ACE_Thread_Manager::thr_mgr_; + // We can't safely delete it since we don't know who created it! + ACE_Thread_Manager::delete_thr_mgr_ = false; + + ACE_Thread_Manager::thr_mgr_ = tm; + return t; +} + +void +ACE_Thread_Manager::close_singleton (void) +{ + ACE_TRACE ("ACE_Thread_Manager::close_singleton"); + + ACE_MT (ACE_GUARD (ACE_Recursive_Thread_Mutex, ace_mon, + *ACE_Static_Object_Lock::instance ())); + + if (ACE_Thread_Manager::delete_thr_mgr_) + { + // First, we clean up the thread descriptor list. + ACE_Thread_Manager::thr_mgr_->close (); + delete ACE_Thread_Manager::thr_mgr_; + ACE_Thread_Manager::thr_mgr_ = 0; + ACE_Thread_Manager::delete_thr_mgr_ = false; + } + + ACE_Thread_Exit::cleanup (ACE_Thread_Manager::thr_exit_); +} +#endif /* ! defined (ACE_THREAD_MANAGER_LACKS_STATICS) */ + +// Close up and release all resources. + +int +ACE_Thread_Manager::close () +{ + ACE_TRACE ("ACE_Thread_Manager::close"); + + // Clean up the thread descriptor list. + if (this->automatic_wait_) + this->wait (0, 1); + else + { + ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1)); + + this->remove_thr_all (); + } + + return 0; +} + +ACE_Thread_Manager::~ACE_Thread_Manager (void) +{ + ACE_TRACE ("ACE_Thread_Manager::~ACE_Thread_Manager"); + this->close (); +} + + +// Run the entry point for thread spawned under the control of the +// . This must be an extern "C" to make certain +// compilers happy... +// +// The interaction with and +// works like this, with +// ACE_HAS_THREAD_SPECIFIC_STORAGE or ACE_HAS_TSS_EMULATION: +// +// o Every thread in the is run with +// . +// +// o retrieves the singleton +// instance from . +// The singleton gets created in thread-specific storage +// in the first call to that function. The key point is that the +// instance is in thread-specific storage. +// +// o A thread can exit by various means, such as , C++ +// or Win32 exception, "falling off the end" of the thread entry +// point function, etc. +// +// o If you follow this so far, now it gets really fun . . . +// When the thread-specific storage (for the thread that +// is being destroyed) is cleaned up, the OS threads package (or +// the ACE emulation of thread-specific storage) will destroy any +// objects that are in thread-specific storage. It has a list of +// them, and just walks down the list and destroys each one. +// +// o That's where the ACE_Thread_Exit destructor gets called. + +#if defined(ACE_USE_THREAD_MANAGER_ADAPTER) +extern "C" void * +ace_thread_manager_adapter (void *args) +{ +#if defined (ACE_HAS_TSS_EMULATION) + // As early as we can in the execution of the new thread, allocate + // its local TS storage. Allocate it on the stack, to save dynamic + // allocation/dealloction. + void *ts_storage[ACE_TSS_Emulation::ACE_TSS_THREAD_KEYS_MAX]; + ACE_TSS_Emulation::tss_open (ts_storage); +#endif /* ACE_HAS_TSS_EMULATION */ + + ACE_Thread_Adapter *thread_args = reinterpret_cast (args); + + // NOTE: this preprocessor directive should match the one in above + // ACE_Thread_Exit::instance (). With the Xavier Pthreads package, + // the exit_hook in TSS causes a seg fault. So, this works around + // that by creating exit_hook on the stack. +#if defined (ACE_HAS_THREAD_SPECIFIC_STORAGE) || defined (ACE_HAS_TSS_EMULATION) + // Obtain our thread-specific exit hook and make sure that it knows + // how to clean us up! Note that we never use this pointer directly + // (it's stored in thread-specific storage), so it's ok to + // dereference it here and only store it as a reference. + ACE_Thread_Exit &exit_hook = *ACE_Thread_Exit::instance (); +#else + // Without TSS, create an instance. When this + // function returns, its destructor will be called because the + // object goes out of scope. The drawback with this appraoch is + // that the destructor _won't_ get called if is called. + // So, threads shouldn't exit that way. Instead, they should return + // from . + ACE_Thread_Exit exit_hook; +#endif /* ACE_HAS_THREAD_SPECIFIC_STORAGE || ACE_HAS_TSS_EMULATION */ + + // Keep track of the that's associated with this + // . + exit_hook.thr_mgr (thread_args->thr_mgr ()); + + // Invoke the user-supplied function with the args. + void *status = thread_args->invoke (); + + delete static_cast (thread_args); + return status; +} +#endif + +// Call the appropriate OS routine to spawn a thread. Should *not* be +// called with the lock_ held... + +int +ACE_Thread_Manager::spawn_i (ACE_THR_FUNC func, + void *args, + long flags, + ACE_thread_t *t_id, + ACE_hthread_t *t_handle, + long priority, + int grp_id, + void *stack, + size_t stack_size, + ACE_Task_Base *task, + const char** thr_name) +{ + // First, threads created by Thread Manager should not be daemon threads. + // Using assertion is probably a bit too strong. However, it helps + // finding this kind of error as early as possible. Perhaps we can replace + // assertion by returning error. + ACE_ASSERT (ACE_BIT_DISABLED (flags, THR_DAEMON)); + + // Create a new thread running . *Must* be called with the + // held... + // Get a "new" Thread Descriptor from the freelist. + auto_ptr new_thr_desc (this->thread_desc_freelist_.remove ()); + + // Reset thread descriptor status + new_thr_desc->reset (this); + + ACE_Thread_Adapter *thread_args = 0; +# if defined (ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS) + ACE_NEW_RETURN (thread_args, + ACE_Thread_Adapter (func, + args, + (ACE_THR_C_FUNC) ACE_THREAD_ADAPTER_NAME, + this, + new_thr_desc.get (), + ACE_OS_Object_Manager::seh_except_selector(), + ACE_OS_Object_Manager::seh_except_handler()), + -1); +# else + ACE_NEW_RETURN (thread_args, + ACE_Thread_Adapter (func, + args, + (ACE_THR_C_FUNC) ACE_THREAD_ADAPTER_NAME, + this, + new_thr_desc.get ()), + -1); +# endif /* ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS */ + auto_ptr auto_thread_args (static_cast (thread_args)); + + ACE_TRACE ("ACE_Thread_Manager::spawn_i"); + ACE_hthread_t thr_handle; + + ACE_thread_t thr_id; + if (t_id == 0) + t_id = &thr_id; + + // Acquire the lock to block the spawned thread from + // removing this Thread Descriptor before it gets put into our + // thread table. + new_thr_desc->sync_->acquire (); + + int const result = ACE_Thread::spawn (func, + args, + flags, + t_id, + &thr_handle, + priority, + stack, + stack_size, + thread_args, + thr_name); + + if (result != 0) + { + // _Don't_ clobber errno here! result is either 0 or -1, and + // ACE_OS::thr_create () already set errno! D. Levine 28 Mar 1997 + // errno = result; + ACE_Errno_Guard guard (errno); // Lock release may smash errno + new_thr_desc->sync_->release (); + return -1; + } + auto_thread_args.release (); + +#if defined (ACE_HAS_WTHREADS) + // Have to duplicate handle if client asks for it. + // @@ How are thread handles implemented on AIX? Do they + // also need to be duplicated? + if (t_handle != 0) +# if defined (ACE_HAS_WINCE) + *t_handle = thr_handle; +# else /* ! ACE_HAS_WINCE */ + (void) ::DuplicateHandle (::GetCurrentProcess (), + thr_handle, + ::GetCurrentProcess (), + t_handle, + 0, + TRUE, + DUPLICATE_SAME_ACCESS); +# endif /* ! ACE_HAS_WINCE */ +#else /* ! ACE_HAS_WTHREADS */ + if (t_handle != 0) + *t_handle = thr_handle; +#endif /* ! ACE_HAS_WTHREADS */ + + // append_thr also put the into Thread_Manager's + // double-linked list. Only after this point, can we manipulate + // double-linked list from a spawned thread's context. + return this->append_thr (*t_id, + thr_handle, + ACE_THR_SPAWNED, + grp_id, + task, + flags, + new_thr_desc.release ()); +} + +int +ACE_Thread_Manager::spawn (ACE_THR_FUNC func, + void *args, + long flags, + ACE_thread_t *t_id, + ACE_hthread_t *t_handle, + long priority, + int grp_id, + void *stack, + size_t stack_size, + const char** thr_name) +{ + ACE_TRACE ("ACE_Thread_Manager::spawn"); + + ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1)); + + if (grp_id == -1) + grp_id = this->grp_id_++; // Increment the group id. + + if (priority != ACE_DEFAULT_THREAD_PRIORITY) + ACE_CLR_BITS (flags, THR_INHERIT_SCHED); + + if (this->spawn_i (func, + args, + flags, + t_id, + t_handle, + priority, + grp_id, + stack, + stack_size, + 0, + thr_name) == -1) + return -1; + + return grp_id; +} + +// Create N new threads running FUNC. + +int +ACE_Thread_Manager::spawn_n (size_t n, + ACE_THR_FUNC func, + void *args, + long flags, + long priority, + int grp_id, + ACE_Task_Base *task, + ACE_hthread_t thread_handles[], + void *stack[], + size_t stack_size[], + const char* thr_name[]) +{ + ACE_TRACE ("ACE_Thread_Manager::spawn_n"); + ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1)); + + if (grp_id == -1) + grp_id = this->grp_id_++; // Increment the group id. + + for (size_t i = 0; i < n; i++) + { + // @@ What should happen if this fails?! e.g., should we try to + // cancel the other threads that we've already spawned or what? + if (this->spawn_i (func, + args, + flags, + 0, + thread_handles == 0 ? 0 : &thread_handles[i], + priority, + grp_id, + stack == 0 ? 0 : stack[i], + stack_size == 0 ? ACE_DEFAULT_THREAD_STACKSIZE : stack_size[i], + task, + thr_name == 0 ? 0 : &thr_name [i]) == -1) + return -1; + } + + return grp_id; +} + +// Create N new threads running FUNC. + +int +ACE_Thread_Manager::spawn_n (ACE_thread_t thread_ids[], + size_t n, + ACE_THR_FUNC func, + void *args, + long flags, + long priority, + int grp_id, + void *stack[], + size_t stack_size[], + ACE_hthread_t thread_handles[], + ACE_Task_Base *task, + const char* thr_name[]) +{ + ACE_TRACE ("ACE_Thread_Manager::spawn_n"); + ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1)); + + if (grp_id == -1) + grp_id = this->grp_id_++; // Increment the group id. + + for (size_t i = 0; i < n; i++) + { + // @@ What should happen if this fails?! e.g., should we try to + // cancel the other threads that we've already spawned or what? + if (this->spawn_i (func, + args, + flags, + thread_ids == 0 ? 0 : &thread_ids[i], + thread_handles == 0 ? 0 : &thread_handles[i], + priority, + grp_id, + stack == 0 ? 0 : stack[i], + stack_size == 0 ? ACE_DEFAULT_THREAD_STACKSIZE : stack_size[i], + task, + thr_name == 0 ? 0 : &thr_name [i]) == -1) + return -1; + } + + return grp_id; +} + +// Append a thread into the pool (does not check for duplicates). +// Must be called with locks held. + +int +ACE_Thread_Manager::append_thr (ACE_thread_t t_id, + ACE_hthread_t t_handle, + ACE_UINT32 thr_state, + int grp_id, + ACE_Task_Base *task, + long flags, + ACE_Thread_Descriptor *td) +{ + ACE_TRACE ("ACE_Thread_Manager::append_thr"); + ACE_Thread_Descriptor *thr_desc = 0; + + if (td == 0) + { + ACE_NEW_RETURN (thr_desc, + ACE_Thread_Descriptor, + -1); + thr_desc->tm_ = this; + // Setup the Thread_Manager. + } + else + thr_desc = td; + + thr_desc->thr_id_ = t_id; + thr_desc->thr_handle_ = t_handle; + thr_desc->grp_id_ = grp_id; + thr_desc->task_ = task; + thr_desc->flags_ = flags; + + this->thr_list_.insert_head (thr_desc); + ACE_SET_BITS (thr_desc->thr_state_, thr_state); + thr_desc->sync_->release (); + + return 0; +} + +// Return the thread descriptor (indexed by ACE_hthread_t). + +ACE_Thread_Descriptor * +ACE_Thread_Manager::find_hthread (ACE_hthread_t h_id) +{ + for (ACE_Double_Linked_List_Iterator iter (this->thr_list_); + !iter.done (); + iter.advance ()) + { + if (ACE_OS::thr_cmp (iter.next ()->thr_handle_, h_id)) + { + return iter.next (); + } + } + + return 0; +} + +// Locate the index in the table associated with . Must be +// called with the lock held. + +ACE_Thread_Descriptor * +ACE_Thread_Manager::find_thread (ACE_thread_t t_id) +{ + ACE_TRACE ("ACE_Thread_Manager::find_thread"); + + for (ACE_Double_Linked_List_Iterator iter (this->thr_list_); + !iter.done (); + iter.advance ()) + { + if (ACE_OS::thr_equal (iter.next ()->thr_id_, t_id)) + { + return iter.next (); + } + } + return 0; +} + +// Insert a thread into the pool (checks for duplicates and doesn't +// allow them to be inserted twice). + +int +ACE_Thread_Manager::insert_thr (ACE_thread_t t_id, + ACE_hthread_t t_handle, + int grp_id, + long flags) +{ + ACE_TRACE ("ACE_Thread_Manager::insert_thr"); + ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1)); + + // Check for duplicates and bail out if we're already registered... + if (this->find_thread (t_id) != 0 ) + return -1; + + if (grp_id == -1) + grp_id = this->grp_id_++; + + if (this->append_thr (t_id, + t_handle, + ACE_THR_SPAWNED, + grp_id, + 0, + flags) == -1) + return -1; + + return grp_id; +} + +// Run the registered hooks when the thread exits. + +void +ACE_Thread_Manager::run_thread_exit_hooks (int i) +{ +#if 0 // currently unused! + ACE_TRACE ("ACE_Thread_Manager::run_thread_exit_hooks"); + + // @@ Currently, we have just one hook. This should clearly be + // generalized to support an arbitrary number of hooks. + + ACE_Thread_Descriptor *td = this->thread_desc_self (); + if (td != 0 && td->cleanup_info.cleanup_hook_ != 0) + { + (*td->cleanup_info_.cleanup_hook_) + (td->cleanup_info_.object_, + td->cleanup_info_.param_); + + td->cleanup_info_.cleanup_hook_ = 0; + } + ACE_UNUSED_ARG (i); +#else + ACE_UNUSED_ARG (i); +#endif /* 0 */ +} + +// Remove a thread from the pool. Must be called with locks held. + +void +ACE_Thread_Manager::remove_thr (ACE_Thread_Descriptor *td, + int close_handler) +{ + ACE_TRACE ("ACE_Thread_Manager::remove_thr"); + + td->tm_ = 0; + this->thr_list_.remove (td); + +#if defined (ACE_WIN32) + if (close_handler != 0) + ::CloseHandle (td->thr_handle_); +#else + ACE_UNUSED_ARG (close_handler); +#endif /* ACE_WIN32 */ + + this->thread_desc_freelist_.add (td); + +#if defined (ACE_HAS_THREADS) + // Tell all waiters when there are no more threads left in the pool. + if (this->thr_list_.size () == 0) + this->zero_cond_.broadcast (); +#endif /* ACE_HAS_THREADS */ +} + +// Repeatedly call remove_thr on all table entries until there +// is no thread left. Must be called with lock held. +void +ACE_Thread_Manager::remove_thr_all (void) +{ + ACE_Thread_Descriptor *td = 0; + + while ((td = this->thr_list_.delete_head ()) != 0) + { + this->remove_thr (td, 1); + } +} + +// ------------------------------------------------------------------ +// Factor out some common behavior to simplify the following methods. +#define ACE_THR_OP(OP,STATE) \ + int result = OP (td->thr_handle_); \ + if (result == -1) { \ + if (errno != ENOTSUP) \ + this->thr_to_be_removed_.enqueue_tail (td); \ + return -1; \ + } \ + else { \ + ACE_SET_BITS (td->thr_state_, STATE); \ + return 0; \ + } + +int +ACE_Thread_Manager::join_thr (ACE_Thread_Descriptor *td, int) +{ + ACE_TRACE ("ACE_Thread_Manager::join_thr"); + int const result = ACE_Thread::join (td->thr_handle_); + if (result != 0) + { + // Since the thread are being joined, we should + // let it remove itself from the list. + + // this->remove_thr (td); + errno = result; + return -1; + } + + return 0; +} + +int +ACE_Thread_Manager::suspend_thr (ACE_Thread_Descriptor *td, int) +{ + ACE_TRACE ("ACE_Thread_Manager::suspend_thr"); + + int const result = ACE_Thread::suspend (td->thr_handle_); + if (result == -1) { + if (errno != ENOTSUP) + this->thr_to_be_removed_.enqueue_tail (td); + return -1; + } + else { + ACE_SET_BITS (td->thr_state_, ACE_THR_SUSPENDED); + return 0; + } +} + +int +ACE_Thread_Manager::resume_thr (ACE_Thread_Descriptor *td, int) +{ + ACE_TRACE ("ACE_Thread_Manager::resume_thr"); + + int const result = ACE_Thread::resume (td->thr_handle_); + if (result == -1) { + if (errno != ENOTSUP) + this->thr_to_be_removed_.enqueue_tail (td); + return -1; + } + else { + ACE_CLR_BITS (td->thr_state_, ACE_THR_SUSPENDED); + return 0; + } +} + +int +ACE_Thread_Manager::cancel_thr (ACE_Thread_Descriptor *td, int async_cancel) +{ + ACE_TRACE ("ACE_Thread_Manager::cancel_thr"); + // Must set the state first and then try to cancel the thread. + ACE_SET_BITS (td->thr_state_, ACE_THR_CANCELLED); + + if (async_cancel != 0) + // Note that this call only does something relevant if the OS + // platform supports asynchronous thread cancellation. Otherwise, + // it's a no-op. + return ACE_Thread::cancel (td->thr_id_); + + return 0; +} + +int +ACE_Thread_Manager::kill_thr (ACE_Thread_Descriptor *td, int signum) +{ + ACE_TRACE ("ACE_Thread_Manager::kill_thr"); + + ACE_thread_t tid = td->thr_id_; + + int const result = ACE_Thread::kill (tid, signum); + + if (result != 0) + { + // Only remove a thread from us when there is a "real" error. + if (errno != ENOTSUP) + this->thr_to_be_removed_.enqueue_tail (td); + + return -1; + } + + return 0; +} + +// ------------------------------------------------------------------ +// Factor out some common behavior to simplify the following methods. +#define ACE_EXECUTE_OP(OP, ARG) \ + ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1)); \ + ACE_ASSERT (this->thr_to_be_removed_.is_empty ()); \ + ACE_FIND (this->find_thread (t_id), ptr); \ + if (ptr == 0) \ + { \ + errno = ENOENT; \ + return -1; \ + } \ + int result = OP (ptr, ARG); \ + ACE_Errno_Guard error (errno); \ + while (! this->thr_to_be_removed_.is_empty ()) { \ + ACE_Thread_Descriptor * td = 0; \ + this->thr_to_be_removed_.dequeue_head (td); \ + this->remove_thr (td, 1); \ + } \ + return result + +// Suspend a single thread. + +int +ACE_Thread_Manager::suspend (ACE_thread_t t_id) +{ + ACE_TRACE ("ACE_Thread_Manager::suspend"); + ACE_EXECUTE_OP (this->suspend_thr, 0); +} + +// Resume a single thread. + +int +ACE_Thread_Manager::resume (ACE_thread_t t_id) +{ + ACE_TRACE ("ACE_Thread_Manager::resume"); + ACE_EXECUTE_OP (this->resume_thr, 0); +} + +// Cancel a single thread. + +int +ACE_Thread_Manager::cancel (ACE_thread_t t_id, int async_cancel) +{ + ACE_TRACE ("ACE_Thread_Manager::cancel"); + ACE_EXECUTE_OP (this->cancel_thr, async_cancel); +} + +// Send a signal to a single thread. + +int +ACE_Thread_Manager::kill (ACE_thread_t t_id, int signum) +{ + ACE_TRACE ("ACE_Thread_Manager::kill"); + ACE_EXECUTE_OP (this->kill_thr, signum); +} + +int +ACE_Thread_Manager::check_state (ACE_UINT32 state, + ACE_thread_t id, + int enable) +{ + ACE_TRACE ("ACE_Thread_Manager::check_state"); + ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1)); + + ACE_UINT32 thr_state; + + int self_check = ACE_OS::thr_equal (id, ACE_OS::thr_self ()); + + // If we're checking the state of our thread, try to get the cached + // value out of TSS to avoid lookup. + if (self_check) + { + ACE_Thread_Descriptor *desc = ACE_LOG_MSG->thr_desc (); + if (desc == 0) + return 0; // Always return false. + thr_state = desc->thr_state_; + } + else + { + // Not calling from self, have to look it up from the list. + ACE_FIND (this->find_thread (id), ptr); + if (ptr == 0) + return 0; + thr_state = ptr->thr_state_; + } + if (enable) + return ACE_BIT_ENABLED (thr_state, state); + + return ACE_BIT_DISABLED (thr_state, state); +} + +// Test if a single thread has terminated. + +int +ACE_Thread_Manager::testterminate (ACE_thread_t t_id) +{ + ACE_TRACE ("ACE_Thread_Manager::testterminate"); + return this->check_state (ACE_THR_TERMINATED, t_id); +} + +// Test if a single thread is suspended. + +int +ACE_Thread_Manager::testsuspend (ACE_thread_t t_id) +{ + ACE_TRACE ("ACE_Thread_Manager::testsuspend"); + return this->check_state (ACE_THR_SUSPENDED, t_id); +} + +// Test if a single thread is active (i.e., resumed). + +int +ACE_Thread_Manager::testresume (ACE_thread_t t_id) +{ + ACE_TRACE ("ACE_Thread_Manager::testresume"); + return this->check_state (ACE_THR_SUSPENDED, t_id, 0); +} + +// Test if a single thread is cancelled. + +int +ACE_Thread_Manager::testcancel (ACE_thread_t t_id) +{ + ACE_TRACE ("ACE_Thread_Manager::testcancel"); + return this->check_state (ACE_THR_CANCELLED, t_id); +} + +// Thread information query functions. + +int +ACE_Thread_Manager::hthread_within (ACE_hthread_t handle) +{ + ACE_TRACE ("ACE_Thread_Manager::hthread_within"); + ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_monx, this->lock_, -1)); + + for (ACE_Double_Linked_List_Iterator iter (this->thr_list_); + !iter.done (); + iter.advance ()) + { + if (ACE_OS::thr_cmp(iter.next ()->thr_handle_, handle)) + { + return 1; + } + } + + return 0; +} + +int +ACE_Thread_Manager::thread_within (ACE_thread_t tid) +{ + ACE_TRACE ("ACE_Thread_Manager::thread_within"); + ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_monx, this->lock_, -1)); + + for (ACE_Double_Linked_List_Iterator iter (this->thr_list_); + !iter.done (); + iter.advance ()) + { + if (ACE_OS::thr_equal (iter.next ()->thr_id_, tid)) + { + return 1; + } + } + + return 0; +} + +// Get group ids for a particular thread id. + +int +ACE_Thread_Manager::get_grp (ACE_thread_t t_id, int &grp_id) +{ + ACE_TRACE ("ACE_Thread_Manager::get_grp"); + ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1)); + + ACE_FIND (this->find_thread (t_id), ptr); + + if (ptr) + grp_id = ptr->grp_id_; + else + return -1; + return 0; +} + +// Set group ids for a particular thread id. + +int +ACE_Thread_Manager::set_grp (ACE_thread_t t_id, int grp_id) +{ + ACE_TRACE ("ACE_Thread_Manager::set_grp"); + ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1)); + + ACE_FIND (this->find_thread (t_id), ptr); + if (ptr) + ptr->grp_id_ = grp_id; + else + return -1; + return 0; +} + +// Suspend a group of threads. + +int +ACE_Thread_Manager::apply_grp (int grp_id, + ACE_THR_MEMBER_FUNC func, + int arg) +{ + ACE_TRACE ("ACE_Thread_Manager::apply_grp"); + ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_monx, this->lock_, -1)); + ACE_ASSERT (this->thr_to_be_removed_.is_empty ()); + + int result = 0; + + for (ACE_Double_Linked_List_Iterator iter (this->thr_list_); + !iter.done (); + iter.advance ()) + { + if (iter.next ()->grp_id_ == grp_id) + { + if ((this->*func) (iter.next (), arg) == -1) + { + result = -1; + } + } + } + + // Must remove threads after we have traversed the thr_list_ to + // prevent clobber thr_list_'s integrity. + + if (! this->thr_to_be_removed_.is_empty ()) + { + // Save/restore errno. + ACE_Errno_Guard error (errno); + + for (ACE_Thread_Descriptor *td; + this->thr_to_be_removed_.dequeue_head (td) != -1; + ) + this->remove_thr (td, 1); + } + + return result; +} + +int +ACE_Thread_Manager::suspend_grp (int grp_id) +{ + ACE_TRACE ("ACE_Thread_Manager::suspend_grp"); + return this->apply_grp (grp_id, + ACE_THR_MEMBER_FUNC (&ACE_Thread_Manager::suspend_thr)); +} + +// Resume a group of threads. + +int +ACE_Thread_Manager::resume_grp (int grp_id) +{ + ACE_TRACE ("ACE_Thread_Manager::resume_grp"); + return this->apply_grp (grp_id, + ACE_THR_MEMBER_FUNC (&ACE_Thread_Manager::resume_thr)); +} + +// Kill a group of threads. + +int +ACE_Thread_Manager::kill_grp (int grp_id, int signum) +{ + ACE_TRACE ("ACE_Thread_Manager::kill_grp"); + return this->apply_grp (grp_id, + ACE_THR_MEMBER_FUNC (&ACE_Thread_Manager::kill_thr), signum); +} + +// Cancel a group of threads. + +int +ACE_Thread_Manager::cancel_grp (int grp_id, int async_cancel) +{ + ACE_TRACE ("ACE_Thread_Manager::cancel_grp"); + return this->apply_grp (grp_id, + ACE_THR_MEMBER_FUNC (&ACE_Thread_Manager::cancel_thr), + async_cancel); +} + +int +ACE_Thread_Manager::apply_all (ACE_THR_MEMBER_FUNC func, int arg) +{ + ACE_TRACE ("ACE_Thread_Manager::apply_all"); + ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1)); + ACE_ASSERT (this->thr_to_be_removed_.is_empty ()); + + int result = 0; + + for (ACE_Double_Linked_List_Iterator iter (this->thr_list_); + !iter.done (); + iter.advance ()) + { + if ((this->*func)(iter.next (), arg) == -1) + { + result = -1; + } + } + + // Must remove threads after we have traversed the thr_list_ to + // prevent clobber thr_list_'s integrity. + + if (! this->thr_to_be_removed_.is_empty ()) + { + // Save/restore errno. + ACE_Errno_Guard error (errno); + + for (ACE_Thread_Descriptor *td; + this->thr_to_be_removed_.dequeue_head (td) != -1; + ) + this->remove_thr (td, 1); + } + + return result; +} + +// Resume all threads that are suspended. + +int +ACE_Thread_Manager::resume_all (void) +{ + ACE_TRACE ("ACE_Thread_Manager::resume_all"); + return this->apply_all (ACE_THR_MEMBER_FUNC (&ACE_Thread_Manager::resume_thr)); +} + +int +ACE_Thread_Manager::suspend_all (void) +{ + ACE_TRACE ("ACE_Thread_Manager::suspend_all"); + return this->apply_all (ACE_THR_MEMBER_FUNC (&ACE_Thread_Manager::suspend_thr)); +} + +int +ACE_Thread_Manager::kill_all (int sig) +{ + ACE_TRACE ("ACE_Thread_Manager::kill_all"); + return this->apply_all (&ACE_Thread_Manager::kill_thr, sig); +} + +int +ACE_Thread_Manager::cancel_all (int async_cancel) +{ + ACE_TRACE ("ACE_Thread_Manager::cancel_all"); + return this->apply_all (ACE_THR_MEMBER_FUNC (&ACE_Thread_Manager::cancel_thr), + async_cancel); +} + +int +ACE_Thread_Manager::join (ACE_thread_t tid, ACE_THR_FUNC_RETURN *status) +{ + ACE_TRACE ("ACE_Thread_Manager::join"); + + bool found = false; + ACE_Thread_Descriptor tdb; + + { + ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1)); + +#if !defined (ACE_HAS_VXTHREADS) + for (ACE_Double_Linked_List_Iterator biter (this->terminated_thr_list_); + !biter.done (); + biter.advance ()) + { + if (ACE_OS::thr_equal (biter.next ()->thr_id_, tid)) + { + ACE_Thread_Descriptor_Base *tdb = biter.advance_and_remove (false); + if (ACE_Thread::join (tdb->thr_handle_, status) == -1) + { + return -1; + } + delete tdb; + + // return immediately if we've found the thread we want to join. + return 0; + } + } +#endif /* !ACE_HAS_VXTHREADS */ + + for (ACE_Double_Linked_List_Iterator iter (this->thr_list_); + !iter.done (); + iter.advance ()) + { + // If threads are created as THR_DETACHED or THR_DAEMON, we + // can't help much. + if (ACE_OS::thr_equal (iter.next ()->thr_id_,tid) && + (ACE_BIT_DISABLED (iter.next ()->flags_, THR_DETACHED | THR_DAEMON) + || ACE_BIT_ENABLED (iter.next ()->flags_, THR_JOINABLE))) + { + tdb = *iter.next (); + ACE_SET_BITS (iter.next ()->thr_state_, ACE_THR_JOINING); + found = 1; + break; + } + } + + if (!found) + return -1; + // Didn't find the thread we want or the thread is not joinable. + } + + if (ACE_Thread::join (tdb.thr_handle_, status) == -1) + return -1; + + return 0; +} + +// Wait for group of threads + +int +ACE_Thread_Manager::wait_grp (int grp_id) +{ + ACE_TRACE ("ACE_Thread_Manager::wait_grp"); + + int copy_count = 0; + ACE_Thread_Descriptor_Base *copy_table = 0; + + // We have to make sure that while we wait for these threads to + // exit, we do not have the lock. Therefore we make a copy of all + // interesting entries and let go of the lock. + { + ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1)); + +#if !defined (ACE_HAS_VXTHREADS) + ACE_NEW_RETURN (copy_table, + ACE_Thread_Descriptor_Base [this->thr_list_.size () + + this->terminated_thr_list_.size ()], + -1); +#else + ACE_NEW_RETURN (copy_table, + ACE_Thread_Descriptor_Base [this->thr_list_.size ()], + -1); +#endif /* !ACE_HAS_VXTHREADS */ + + for (ACE_Double_Linked_List_Iterator iter (this->thr_list_); + !iter.done (); + iter.advance ()) + { + // If threads are created as THR_DETACHED or THR_DAEMON, we + // can't help much. + if (iter.next ()->grp_id_ == grp_id && + (ACE_BIT_DISABLED (iter.next ()->flags_, THR_DETACHED | THR_DAEMON) + || ACE_BIT_ENABLED (iter.next ()->flags_, THR_JOINABLE))) + { + ACE_SET_BITS (iter.next ()->thr_state_, ACE_THR_JOINING); + copy_table[copy_count++] = *iter.next (); + } + } + +#if !defined (ACE_HAS_VXTHREADS) + for (ACE_Double_Linked_List_Iterator biter (this->terminated_thr_list_); + !biter.done (); + biter.advance ()) + { + // If threads are created as THR_DETACHED or THR_DAEMON, we + // can't help much. + if (biter.next ()->grp_id_ == grp_id) + { + ACE_Thread_Descriptor_Base *tdb = biter.advance_and_remove (false); + copy_table[copy_count++] = *tdb; + delete tdb; + } + } +#endif /* !ACE_HAS_VXTHREADS */ + } + + // Now actually join() with all the threads in this group. + int result = 0; + + for (int i = 0; + i < copy_count && result != -1; + i++) + { + if (ACE_Thread::join (copy_table[i].thr_handle_) == -1) + result = -1; + } + + delete [] copy_table; + + return result; +} + +// Must be called when thread goes out of scope to clean up its table +// slot. + +ACE_THR_FUNC_RETURN +ACE_Thread_Manager::exit (ACE_THR_FUNC_RETURN status, bool do_thread_exit) +{ + ACE_TRACE ("ACE_Thread_Manager::exit"); +#if defined (ACE_WIN32) + // Remove detached thread handle. + + if (do_thread_exit) + { +#if 0 + // @@ This callback is now taken care of by TSS_Cleanup. Do we + // need it anymore? + + // On Win32, if we really wants to exit from a thread, we must + // first clean up the thread specific storage. By doing so, + // ACE_Thread_Manager::exit will be called again with + // do_thr_exit = 0 and cleaning up the ACE_Cleanup_Info (but not + // exiting the thread.) After the following call returns, we + // are safe to exit this thread. + delete ACE_Thread_Exit::instance (); +#endif /* 0 */ + ACE_Thread::exit (status); + } +#endif /* ACE_WIN32 */ + + // Just hold onto the guard while finding this thread's id and + { + ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, 0)); + + // Find the thread id, but don't use the cache. It might have been + // deleted already. + ACE_thread_t const id = ACE_OS::thr_self (); + ACE_Thread_Descriptor* td = this->find_thread (id); + if (td != 0) + { + // @@ We call Thread_Descriptor terminate this realize the cleanup + // process itself. + td->terminate(); + } + } + + if (do_thread_exit) + { + ACE_Thread::exit (status); + // On reasonable systems should not return. + // However, due to horrible semantics with Win32 thread-specific + // storage this call can return (don't ask...). + } + + return 0; +} + +// Wait for all the threads to exit. + +int +ACE_Thread_Manager::wait (const ACE_Time_Value *timeout, + bool abandon_detached_threads, + bool use_absolute_time) +{ + ACE_TRACE ("ACE_Thread_Manager::wait"); + + ACE_Time_Value local_timeout; + // Check to see if we're using absolute time or not. + if (use_absolute_time == false && timeout != 0) + { + local_timeout = *timeout; + local_timeout += ACE_OS::gettimeofday (); + timeout = &local_timeout; + } + +#if !defined (ACE_HAS_VXTHREADS) + ACE_Double_Linked_List term_thr_list_copy; +#endif /* ACE_HAS_VXTHREADS */ + +#if defined (ACE_HAS_THREADS) + { + // Just hold onto the guard while waiting. + ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1)); + + if (ACE_Object_Manager::shutting_down () != 1) + { + // Program is not shutting down. Perform a normal wait on threads. + if (abandon_detached_threads != 0) + { + ACE_ASSERT (this->thr_to_be_removed_.is_empty ()); + for (ACE_Double_Linked_List_Iterator + iter (this->thr_list_); + !iter.done (); + iter.advance ()) + { + if (ACE_BIT_ENABLED (iter.next ()->flags_, + THR_DETACHED | THR_DAEMON) + && ACE_BIT_DISABLED (iter.next ()->flags_, THR_JOINABLE)) + { + this->thr_to_be_removed_.enqueue_tail (iter.next ()); + ACE_SET_BITS (iter.next ()->thr_state_, ACE_THR_JOINING); + } + } + + if (! this->thr_to_be_removed_.is_empty ()) + { + ACE_Thread_Descriptor *td = 0; + while (this->thr_to_be_removed_.dequeue_head (td) != -1) + this->remove_thr (td, 1); + } + } + + while (this->thr_list_.size () > 0) + if (this->zero_cond_.wait (timeout) == -1) + return -1; + } + else + // Program is shutting down, no chance to wait on threads. + // Therefore, we'll just remove threads from the list. + this->remove_thr_all (); + +#if !defined (ACE_HAS_VXTHREADS) + ACE_Thread_Descriptor_Base* item = 0; + while ((item = this->terminated_thr_list_.delete_head ()) != 0) + { + term_thr_list_copy.insert_tail (item); + } +#endif /* ACE_HAS_VXTHREADS */ + // Release the guard, giving other threads a chance to run. + } + +#if !defined (ACE_HAS_VXTHREADS) + // @@ VxWorks doesn't support thr_join (yet.) We are working + // on our implementation. Chorus'es thr_join seems broken. + ACE_Thread_Descriptor_Base *item = 0; + + while ((item = term_thr_list_copy.delete_head ()) != 0) + { + if (ACE_BIT_DISABLED (item->flags_, THR_DETACHED | THR_DAEMON) + || ACE_BIT_ENABLED (item->flags_, THR_JOINABLE)) + // Detached handles shouldn't reached here. + (void) ACE_Thread::join (item->thr_handle_); + + delete item; + } + +#endif /* !ACE_HAS_VXTHREADS */ +#else + ACE_UNUSED_ARG (timeout); + ACE_UNUSED_ARG (abandon_detached_threads); +#endif /* ACE_HAS_THREADS */ + + return 0; +} + +int +ACE_Thread_Manager::apply_task (ACE_Task_Base *task, + ACE_THR_MEMBER_FUNC func, + int arg) +{ + ACE_TRACE ("ACE_Thread_Manager::apply_task"); + ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1)); + ACE_ASSERT (this->thr_to_be_removed_.is_empty ()); + + int result = 0; + + for (ACE_Double_Linked_List_Iterator iter (this->thr_list_); + !iter.done (); + iter.advance ()) + if (iter.next ()->task_ == task + && (this->*func) (iter.next (), arg) == -1) + result = -1; + + // Must remove threads after we have traversed the thr_list_ to + // prevent clobber thr_list_'s integrity. + + if (! this->thr_to_be_removed_.is_empty ()) + { + // Save/restore errno. + ACE_Errno_Guard error (errno); + + for (ACE_Thread_Descriptor *td; + this->thr_to_be_removed_.dequeue_head (td) != -1; + ) + this->remove_thr (td, 1); + } + + return result; +} + +// Wait for all threads to exit a task. + +int +ACE_Thread_Manager::wait_task (ACE_Task_Base *task) +{ + int copy_count = 0; + ACE_Thread_Descriptor_Base *copy_table = 0; + + // We have to make sure that while we wait for these threads to + // exit, we do not have the lock. Therefore we make a copy of all + // interesting entries and let go of the lock. + { + ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1)); + +#if !defined (ACE_HAS_VXTHREADS) + ACE_NEW_RETURN (copy_table, + ACE_Thread_Descriptor_Base [this->thr_list_.size () + + this->terminated_thr_list_.size ()], + -1); +#else + ACE_NEW_RETURN (copy_table, + ACE_Thread_Descriptor_Base [this->thr_list_.size ()], + -1); +#endif /* !ACE_HAS_VXTHREADS */ + + for (ACE_Double_Linked_List_Iterator iter (this->thr_list_); + !iter.done (); + iter.advance ()) + { + // If threads are created as THR_DETACHED or THR_DAEMON, we + // can't wait on them here. + if (iter.next ()->task_ == task && + (ACE_BIT_DISABLED (iter.next ()->flags_, + THR_DETACHED | THR_DAEMON) + || ACE_BIT_ENABLED (iter.next ()->flags_, + THR_JOINABLE))) + { + ACE_SET_BITS (iter.next ()->thr_state_, + ACE_THR_JOINING); + copy_table[copy_count++] = *iter.next (); + } + } + +#if !defined (ACE_HAS_VXTHREADS) + for (ACE_Double_Linked_List_Iterator titer (this->terminated_thr_list_); + !titer.done (); + titer.advance ()) + { + // If threads are created as THR_DETACHED or THR_DAEMON, we can't help much here. + if (titer.next ()->task_ == task) + { + ACE_Thread_Descriptor_Base *tdb = titer.advance_and_remove (false); + copy_table[copy_count++] = *tdb; + delete tdb; + } + } +#endif /* !ACE_HAS_VXTHREADS */ + } + + // Now to do the actual work + int result = 0; + + for (int i = 0; + i < copy_count && result != -1; + i++) + { + if (ACE_Thread::join (copy_table[i].thr_handle_) == -1) + result = -1; + } + + delete [] copy_table; + + return result; +} + +// Suspend a task + +int +ACE_Thread_Manager::suspend_task (ACE_Task_Base *task) +{ + ACE_TRACE ("ACE_Thread_Manager::suspend_task"); + return this->apply_task (task, + ACE_THR_MEMBER_FUNC (&ACE_Thread_Manager::suspend_thr)); +} + +// Resume a task. +int +ACE_Thread_Manager::resume_task (ACE_Task_Base *task) +{ + ACE_TRACE ("ACE_Thread_Manager::resume_task"); + return this->apply_task (task, + ACE_THR_MEMBER_FUNC (&ACE_Thread_Manager::resume_thr)); +} + +// Kill a task. + +int +ACE_Thread_Manager::kill_task (ACE_Task_Base *task, int /* signum */) +{ + ACE_TRACE ("ACE_Thread_Manager::kill_task"); + return this->apply_task (task, + ACE_THR_MEMBER_FUNC (&ACE_Thread_Manager::kill_thr)); +} + +// Cancel a task. +int +ACE_Thread_Manager::cancel_task (ACE_Task_Base *task, + int async_cancel) +{ + ACE_TRACE ("ACE_Thread_Manager::cancel_task"); + return this->apply_task (task, + ACE_THR_MEMBER_FUNC (&ACE_Thread_Manager::cancel_thr), + async_cancel); +} + +// Locate the index in the table associated with from the +// beginning of the table up to an index. Must be called with the +// lock held. + +ACE_Thread_Descriptor * +ACE_Thread_Manager::find_task (ACE_Task_Base *task, size_t slot) +{ + ACE_TRACE ("ACE_Thread_Manager::find_task"); + + size_t i = 0; + + for (ACE_Double_Linked_List_Iterator iter (this->thr_list_); + !iter.done (); + iter.advance ()) + { + if (i >= slot) + break; + + if (task == iter.next ()->task_) + return iter.next (); + + ++i; + } + + return 0; +} + +// Returns the number of ACE_Task in a group. + +int +ACE_Thread_Manager::num_tasks_in_group (int grp_id) +{ + ACE_TRACE ("ACE_Thread_Manager::num_tasks_in_group"); + ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1)); + + int tasks_count = 0; + size_t i = 0; + + for (ACE_Double_Linked_List_Iterator iter (this->thr_list_); + !iter.done (); + iter.advance ()) + { + if (iter.next ()->grp_id_ == grp_id + && this->find_task (iter.next ()->task_, i) == 0 + && iter.next ()->task_ != 0) + { + ++tasks_count; + } + + ++i; + } + return tasks_count; +} + +// Returns the number of threads in an ACE_Task. + +int +ACE_Thread_Manager::num_threads_in_task (ACE_Task_Base *task) +{ + ACE_TRACE ("ACE_Thread_Manager::num_threads_in_task"); + ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1)); + + int threads_count = 0; + + for (ACE_Double_Linked_List_Iterator iter (this->thr_list_); + !iter.done (); + iter.advance ()) + { + if (iter.next ()->task_ == task) + { + ++threads_count; + } + } + + return threads_count; +} + +// Returns in task_list a list of ACE_Tasks registered with ACE_Thread_Manager. + +ssize_t +ACE_Thread_Manager::task_all_list (ACE_Task_Base *task_list[], + size_t n) +{ + ACE_TRACE ("ACE_Thread_Manager::task_all_list"); + ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1)); + + size_t task_list_count = 0; + + for (ACE_Double_Linked_List_Iterator iter (this->thr_list_); + !iter.done (); + iter.advance ()) + { + if (task_list_count >= n) + { + break; + } + + ACE_Task_Base *task_p = iter.next ()->task_; + + if (0 != task_p) + { + // This thread has a task pointer; see if it's already in the + // list. Don't add duplicates. + size_t i = 0; + + for (; i < task_list_count; ++i) + { + if (task_list[i] == task_p) + { + break; + } + } + + if (i == task_list_count) // No match - add this one + { + task_list[task_list_count++] = task_p; + } + } + } + + return ACE_Utils::truncate_cast (task_list_count); +} + +// Returns in thread_list a list of all thread ids + +ssize_t +ACE_Thread_Manager::thread_all_list (ACE_thread_t thread_list[], + size_t n) +{ + ACE_TRACE ("ACE_Thread_Manager::thread_all_list"); + ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1)); + + size_t thread_count = 0; + + for (ACE_Double_Linked_List_Iterator iter (this->thr_list_); + !iter.done (); + iter.advance ()) + { + if (thread_count >= n) + { + break; + } + + thread_list[thread_count] = iter.next ()->thr_id_; + ++thread_count; + } + + return ACE_Utils::truncate_cast (thread_count); +} + + +int +ACE_Thread_Manager::thr_state (ACE_thread_t id, + ACE_UINT32& state) +{ + ACE_TRACE ("ACE_Thread_Manager::thr_state"); + ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1)); + + int const self_check = ACE_OS::thr_equal (id, ACE_OS::thr_self ()); + + // If we're checking the state of our thread, try to get the cached + // value out of TSS to avoid lookup. + if (self_check) + { + ACE_Thread_Descriptor *desc = ACE_LOG_MSG->thr_desc (); + + if (desc == 0) + { + return 0; // Always return false. + } + + state = desc->thr_state_; + } + else + { + // Not calling from self, have to look it up from the list. + ACE_FIND (this->find_thread (id), ptr); + + if (ptr == 0) + { + return 0; + } + + state = ptr->thr_state_; + } + + return 1; +} + +// Returns in task_list a list of ACE_Tasks in a group. + +ssize_t +ACE_Thread_Manager::task_list (int grp_id, + ACE_Task_Base *task_list[], + size_t n) +{ + ACE_TRACE ("ACE_Thread_Manager::task_list"); + ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1)); + + ACE_Task_Base **task_list_iterator = task_list; + size_t task_list_count = 0; + size_t i = 0; + + for (ACE_Double_Linked_List_Iterator iter (this->thr_list_); + !iter.done (); + iter.advance ()) + { + if (task_list_count >= n) + { + break; + } + + if (iter.next ()->grp_id_ == grp_id + && this->find_task (iter.next ()->task_, i) == 0) + { + task_list_iterator[task_list_count] = iter.next ()->task_; + ++task_list_count; + } + + ++i; + } + + return ACE_Utils::truncate_cast (task_list_count); +} + +// Returns in thread_list a list of thread ids in an ACE_Task. + +ssize_t +ACE_Thread_Manager::thread_list (ACE_Task_Base *task, + ACE_thread_t thread_list[], + size_t n) +{ + ACE_TRACE ("ACE_Thread_Manager::thread_list"); + ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1)); + + size_t thread_count = 0; + + for (ACE_Double_Linked_List_Iterator iter (this->thr_list_); + !iter.done (); + iter.advance ()) + { + if (thread_count >= n) + { + break; + } + + if (iter.next ()->task_ == task) + { + thread_list[thread_count] = iter.next ()->thr_id_; + ++thread_count; + } + } + + return ACE_Utils::truncate_cast (thread_count); +} + +// Returns in thread_list a list of thread handles in an ACE_Task. + +ssize_t +ACE_Thread_Manager::hthread_list (ACE_Task_Base *task, + ACE_hthread_t hthread_list[], + size_t n) +{ + ACE_TRACE ("ACE_Thread_Manager::hthread_list"); + ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1)); + + size_t hthread_count = 0; + + for (ACE_Double_Linked_List_Iterator iter (this->thr_list_); + !iter.done (); + iter.advance ()) + { + if (hthread_count >= n) + { + break; + } + + if (iter.next ()->task_ == task) + { + hthread_list[hthread_count] = iter.next ()->thr_handle_; + ++hthread_count; + } + } + + return ACE_Utils::truncate_cast (hthread_count); +} + +ssize_t +ACE_Thread_Manager::thread_grp_list (int grp_id, + ACE_thread_t thread_list[], + size_t n) +{ + ACE_TRACE ("ACE_Thread_Manager::thread_grp_list"); + ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1)); + + size_t thread_count = 0; + + for (ACE_Double_Linked_List_Iterator iter (this->thr_list_); + !iter.done (); + iter.advance ()) + { + if (thread_count >= n) + { + break; + } + + if (iter.next ()->grp_id_ == grp_id) + { + thread_list[thread_count] = iter.next ()->thr_id_; + thread_count++; + } + } + + return ACE_Utils::truncate_cast (thread_count); +} + +// Returns in thread_list a list of thread handles in an ACE_Task. + +ssize_t +ACE_Thread_Manager::hthread_grp_list (int grp_id, + ACE_hthread_t hthread_list[], + size_t n) +{ + ACE_TRACE ("ACE_Thread_Manager::hthread_grp_list"); + ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1)); + + size_t hthread_count = 0; + + for (ACE_Double_Linked_List_Iterator iter (this->thr_list_); + !iter.done (); + iter.advance ()) + { + if (hthread_count >= n) + { + break; + } + + if (iter.next ()->grp_id_ == grp_id) + { + hthread_list[hthread_count] = iter.next ()->thr_handle_; + hthread_count++; + } + } + + return ACE_Utils::truncate_cast (hthread_count); +} + +int +ACE_Thread_Manager::set_grp (ACE_Task_Base *task, int grp_id) +{ + ACE_TRACE ("ACE_Thread_Manager::set_grp"); + ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1)); + + for (ACE_Double_Linked_List_Iterator iter (this->thr_list_); + !iter.done (); + iter.advance ()) + { + if (iter.next ()->task_ == task) + { + iter.next ()->grp_id_ = grp_id; + } + } + + return 0; +} + +int +ACE_Thread_Manager::get_grp (ACE_Task_Base *task, int &grp_id) +{ + ACE_TRACE ("ACE_Thread_Manager::get_grp"); + ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1)); + + ACE_FIND (this->find_task (task), ptr); + grp_id = ptr->grp_id_; + return 0; +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Thread_Manager.h b/dep/ACE_wrappers/ace/Thread_Manager.h new file mode 100644 index 00000000000..2703aae405a --- /dev/null +++ b/dep/ACE_wrappers/ace/Thread_Manager.h @@ -0,0 +1,1264 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Thread_Manager.h + * + * $Id: Thread_Manager.h 82588 2008-08-11 13:37:41Z johnnyw $ + * + * @author Douglas C. Schmidt + */ +//============================================================================= + +#ifndef ACE_THREAD_MANAGER_H +#define ACE_THREAD_MANAGER_H +#include /**/ "ace/pre.h" + +#include "ace/Thread.h" +#include "ace/Thread_Adapter.h" +#include "ace/Thread_Exit.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/Condition_Thread_Mutex.h" +#include "ace/Unbounded_Queue.h" +#include "ace/Containers.h" +#include "ace/Free_List.h" +#include "ace/Singleton.h" +#include "ace/Log_Msg.h" +#include "ace/Synch_Traits.h" +#include "ace/Basic_Types.h" + +// The following macros control how a Thread Manager manages a pool of +// Thread_Descriptor. Currently, the default behavior is not to +// preallocate any thread descriptor and never (well, almost never) +// free up any thread descriptor until the Thread Manager gets +// destructed. Which means, once your system is stable, you rarely +// need to pay the price of memory allocation. On a deterministic +// system, which means, the number of threads spawned can be +// determined before hand, you can either redefine the memory pool +// size macros to suit your need or constructed the Thread_Manager +// accordingly. That way, you don't pay the price of memory +// allocation when the system is really doing its job. OTOH, on +// system with resources constraint, you may want to lower the size of +// ACE_DEFAULT_THREAD_MANAGER_HWM to avoid unused memory hanging +// around. + +#if !defined (ACE_DEFAULT_THREAD_MANAGER_PREALLOC) +# define ACE_DEFAULT_THREAD_MANAGER_PREALLOC 0 +#endif /* ACE_DEFAULT_THREAD_MANAGER_PREALLOC */ + +#if !defined (ACE_DEFAULT_THREAD_MANAGER_LWM) +# define ACE_DEFAULT_THREAD_MANAGER_LWM 1 +#endif /* ACE_DEFAULT_THREAD_MANAGER_LWM */ + +#if !defined (ACE_DEFAULT_THREAD_MANAGER_INC) +# define ACE_DEFAULT_THREAD_MANAGER_INC 1 +#endif /* ACE_DEFAULT_THREAD_MANAGER_INC */ + +#if !defined (ACE_DEFAULT_THREAD_MANAGER_HWM) +# define ACE_DEFAULT_THREAD_MANAGER_HWM ACE_DEFAULT_FREE_LIST_HWM +// this is a big number +#endif /* ACE_DEFAULT_THREAD_MANAGER_HWM */ + +// This is the synchronization mechanism used to prevent a thread +// descriptor gets removed from the Thread_Manager before it gets +// stash into it. If you want to disable this feature (and risk of +// corrupting the freelist,) you define the lock as ACE_Null_Mutex. +// Usually, if you can be sure that your threads will run for an +// extended period of time, you can safely disable the lock. + +#if !defined (ACE_DEFAULT_THREAD_MANAGER_LOCK) +# define ACE_DEFAULT_THREAD_MANAGER_LOCK ACE_SYNCH_MUTEX +#endif /* ACE_DEFAULT_THREAD_MANAGER_LOCK */ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +// Forward declarations. +class ACE_Task_Base; +class ACE_Thread_Manager; +class ACE_Thread_Descriptor; + +/** + * @class ACE_At_Thread_Exit + * + * @brief Contains a method to be applied when a thread is terminated. + */ +class ACE_Export ACE_At_Thread_Exit +{ + friend class ACE_Thread_Descriptor; + friend class ACE_Thread_Manager; +public: + /// Default constructor + ACE_At_Thread_Exit (void); + + /// The destructor + virtual ~ACE_At_Thread_Exit (void); + + /// At_Thread_Exit has the ownership? + bool is_owner (void) const; + + /// Set the ownership of the At_Thread_Exit. + bool is_owner (bool owner); + + /// This At_Thread_Exit was applied? + bool was_applied (void) const; + + /// Set applied state of At_Thread_Exit. + bool was_applied (bool applied); + +protected: + /// The next At_Thread_Exit hook in the list. + ACE_At_Thread_Exit *next_; + + /// Do the apply if necessary + void do_apply (void); + + /// The apply method. + virtual void apply (void) = 0; + + /// The Thread_Descriptor where this at is registered. + ACE_Thread_Descriptor* td_; + + /// The at was applied? + bool was_applied_; + + /// The at has the ownership of this? + bool is_owner_; +}; + +class ACE_Export ACE_At_Thread_Exit_Func : public ACE_At_Thread_Exit +{ +public: + /// Constructor + ACE_At_Thread_Exit_Func (void *object, + ACE_CLEANUP_FUNC func, + void *param = 0); + + virtual ~ACE_At_Thread_Exit_Func (void); + +protected: + /// The object to be cleanup + void *object_; + + /// The cleanup func + ACE_CLEANUP_FUNC func_; + + /// A param if required + void *param_; + + /// The apply method + void apply (void); +}; + +/** + * @class ACE_Thread_Descriptor_Base + * + * @brief Basic information for thread descriptors. These information + * gets extracted out because we need it after a thread is + * terminated. + * + * @internal + */ +class ACE_Export ACE_Thread_Descriptor_Base : public ACE_OS_Thread_Descriptor +{ + + friend class ACE_Thread_Manager; + friend class ACE_Double_Linked_List; + friend class ACE_Double_Linked_List_Iterator_Base; + friend class ACE_Double_Linked_List_Iterator; + friend class ACE_Double_Linked_List; + friend class ACE_Double_Linked_List_Iterator_Base; + friend class ACE_Double_Linked_List_Iterator; +public: + ACE_Thread_Descriptor_Base (void); + ~ACE_Thread_Descriptor_Base (void); + + // = We need the following operators to make Borland happy. + + /// Equality operator. + bool operator== (const ACE_Thread_Descriptor_Base &rhs) const; + + /// Inequality operator. + bool operator!= (const ACE_Thread_Descriptor_Base &rhs) const; + + /// Group ID. + int grp_id (void) const; + + /// Current state of the thread. + ACE_UINT32 state (void) const; + + /// Return the pointer to an ACE_Task_Base or NULL if there's no + /// ACE_Task_Base associated with this thread.; + ACE_Task_Base *task (void) const; + +protected: + /// Reset this base thread descriptor. + void reset (void); + + /// Unique thread ID. + ACE_thread_t thr_id_; + + /// Unique handle to thread (used by Win32 and AIX). + ACE_hthread_t thr_handle_; + + /// Group ID. + int grp_id_; + + /// Current state of the thread. + ACE_UINT32 thr_state_; + + /// Pointer to an ACE_Task_Base or NULL if there's no + /// ACE_Task_Base. + ACE_Task_Base *task_; + + /// We need these pointers to maintain the double-linked list in a + /// thread managers. + ACE_Thread_Descriptor_Base *next_; + ACE_Thread_Descriptor_Base *prev_; +}; + +/** + * @class ACE_Thread_Descriptor + * + * @brief Information for controlling threads that run under the control + * of the . + */ +class ACE_Export ACE_Thread_Descriptor : public ACE_Thread_Descriptor_Base +{ + friend class ACE_At_Thread_Exit; + friend class ACE_Thread_Manager; + friend class ACE_Double_Linked_List; + friend class ACE_Double_Linked_List_Iterator; +public: + // = Initialization method. + ACE_Thread_Descriptor (void); + + // = Accessor methods. + /// Unique thread id. + ACE_thread_t self (void) const; + + /// Unique handle to thread (used by Win32 and AIX). + void self (ACE_hthread_t &); + + /// Dump the state of an object. + void dump (void) const; + + /** + * This cleanup function must be called only for ACE_TSS_cleanup. + * The ACE_TSS_cleanup delegate Log_Msg instance destruction when + * Log_Msg cleanup is called before terminate. + */ + void log_msg_cleanup(ACE_Log_Msg* log_msg); + + /** + * Register an At_Thread_Exit hook and the ownership is acquire by + * Thread_Descriptor, this is the usual case when the AT is dynamically + * allocated. + */ + int at_exit (ACE_At_Thread_Exit* cleanup); + + /// Register an At_Thread_Exit hook and the ownership is retained for the + /// caller. Normally used when the at_exit hook is created in stack. + int at_exit (ACE_At_Thread_Exit& cleanup); + + /** + * Register an object (or array) for cleanup at thread termination. + * "cleanup_hook" points to a (global, or static member) function + * that is called for the object or array when it to be destroyed. + * It may perform any necessary cleanup specific for that object or + * its class. "param" is passed as the second parameter to the + * "cleanup_hook" function; the first parameter is the object (or + * array) to be destroyed. Returns 0 on success, non-zero on + * failure: -1 if virtual memory is exhausted or 1 if the object (or + * arrayt) had already been registered. + */ + int at_exit (void *object, + ACE_CLEANUP_FUNC cleanup_hook, + void *param); + + /// Do nothing destructor to keep some compilers happy + ~ACE_Thread_Descriptor (void); + + /** + * Do nothing but to acquire the thread descriptor's lock and + * release. This will first check if the thread is registered or + * not. If it is already registered, there's no need to reacquire + * the lock again. This is used mainly to get newly spawned thread + * in synch with thread manager and prevent it from accessing its + * thread descriptor before it gets fully built. This function is + * only called from ACE_Log_Msg::thr_desc. + */ + void acquire_release (void); + void acquire (void); + void release (void); + + /** + * Set/get the @c next_ pointer. These are required by the + * ACE_Free_List. + */ + void set_next (ACE_Thread_Descriptor *td); + ACE_Thread_Descriptor *get_next (void) const; + +private: + /// Reset this thread descriptor. + void reset (ACE_Thread_Manager *tm); + + /// Pop an At_Thread_Exit from at thread termination list, apply the at + /// if apply is true. + void at_pop (int apply = 1); + + /// Push an At_Thread_Exit to at thread termination list and set the + /// ownership of at. + void at_push (ACE_At_Thread_Exit* cleanup, + bool is_owner = false); + + /// Run the AT_Thread_Exit hooks. + void do_at_exit (void); + + /// Terminate realize the cleanup process to thread termination + void terminate (void); + + /// Thread_Descriptor is the ownership of ACE_Log_Msg if log_msg_!=0 + /// This can occur because ACE_TSS_cleanup was executed before terminate. + ACE_Log_Msg *log_msg_; + + /// The AT_Thread_Exit list + ACE_At_Thread_Exit *at_exit_list_; + + /** + * Stores the cleanup info for a thread. + * @note This should be generalized to be a stack of ACE_Cleanup_Info's. + */ + ACE_Cleanup_Info cleanup_info_; + + /// Pointer to an ACE_Thread_Manager or NULL if there's no + /// ACE_Thread_Manager> + ACE_Thread_Manager* tm_; + + /// Registration lock to prevent premature removal of thread descriptor. + ACE_DEFAULT_THREAD_MANAGER_LOCK *sync_; + + /// Keep track of termination status. + bool terminated_; +}; + +// Forward declaration. +class ACE_Thread_Control; + +// This typedef should be (and used to be) inside the +// ACE_Thread_Manager declaration. But, it caused compilation +// problems on g++/VxWorks/i960 with -g. Note that +// ACE_Thread_Manager::THR_FUNC is only used internally in +// ACE_Thread_Manager, so it's not useful for anyone else. +// It also caused problems on IRIX5 with g++. +#if defined (__GNUG__) +typedef int (ACE_Thread_Manager::*ACE_THR_MEMBER_FUNC)(ACE_Thread_Descriptor *, int); +#endif /* __GNUG__ */ + +/** + * @class ACE_Thread_Manager + * + * @brief Manages a pool of threads. + * + * This class allows operations on groups of threads atomically. + * The default behavior of thread manager is to wait on + * all threads under it's management when it gets destructed. + * Therefore, remember to remove a thread from thread manager if + * you don't want it to wait for the thread. There are also + * functions to disable this default wait-on-exit behavior. + * However, if your program depends on turning this off to run + * correctly, you are probably doing something wrong. Rule of + * thumb, use ACE_Thread to manage your daemon threads. + * Notice that if there're threads which live beyond the scope of + * main(), you are sure to have resource leaks in your program. + * Remember to wait on threads before exiting your main program if that + * could happen in your programs. + */ +class ACE_Export ACE_Thread_Manager +{ +public: + friend class ACE_Thread_Control; + + // Allow ACE_THread_Exit to register the global TSS instance object. + friend class ACE_Thread_Exit; + friend class ACE_Thread_Descriptor; + +#if !defined (__GNUG__) + typedef int (ACE_Thread_Manager::*ACE_THR_MEMBER_FUNC)(ACE_Thread_Descriptor *, int); +#endif /* !__GNUG__ */ + + /// These are the various states a thread managed by the + /// ACE_Thread_Manager can be in. + enum + { + /// Uninitialized. + ACE_THR_IDLE = 0x00000000, + + /// Created but not yet running. + ACE_THR_SPAWNED = 0x00000001, + + /// Thread is active (naturally, we don't know if it's actually + /// *running* because we aren't the scheduler...). + ACE_THR_RUNNING = 0x00000002, + + /// Thread is suspended. + ACE_THR_SUSPENDED = 0x00000004, + + /// Thread has been cancelled (which is an indiction that it needs to + /// terminate...). + ACE_THR_CANCELLED = 0x00000008, + + /// Thread has shutdown, but the slot in the thread manager hasn't + /// been reclaimed yet. + ACE_THR_TERMINATED = 0x00000010, + + /// Join operation has been invoked on the thread by thread manager. + ACE_THR_JOINING = 0x10000000 + }; + + /** + * @brief Initialization and termination methods. + * + * Internally, ACE_Thread_Manager keeps a freelist for caching + * resources it uses to keep track of managed threads (not the + * threads themselves.) @a prealloc, @a lwm, @a inc, @hwm + * determine the initial size, the low water mark, increment step, + * and high water mark of the freelist. + * + * @sa ACE_Free_List + */ + ACE_Thread_Manager (size_t preaolloc = ACE_DEFAULT_THREAD_MANAGER_PREALLOC, + size_t lwm = ACE_DEFAULT_THREAD_MANAGER_LWM, + size_t inc = ACE_DEFAULT_THREAD_MANAGER_INC, + size_t hwm = ACE_DEFAULT_THREAD_MANAGER_HWM); + ~ACE_Thread_Manager (void); + +#if ! defined (ACE_THREAD_MANAGER_LACKS_STATICS) + /// Get pointer to a process-wide ACE_Thread_Manager. + static ACE_Thread_Manager *instance (void); + + /// Set pointer to a process-wide ACE_Thread_Manager and return + /// existing pointer. + static ACE_Thread_Manager *instance (ACE_Thread_Manager *); + + /// Delete the dynamically allocated Singleton + static void close_singleton (void); +#endif /* ! defined (ACE_THREAD_MANAGER_LACKS_STATICS) */ + + /// No-op. Currently unused. + int open (size_t size = 0); + + /** + * Release all resources. + * By default, this method will wait until all threads exit. + * However, when called from close_singleton(), most global resources + * are destroyed and thus, close() does not try to wait; it simply cleans + * up internal thread records (the thread descriptor list). + */ + int close (void); + + /** + * Create a new thread, which executes @a func with argument @a arg. + * + * @param func The function that is called in the spawned thread. + * + * @param arg The value passed to each spawned thread's @a func. + * + * @param flags Flags to control attributes of the spawned threads. + * @sa ACE_OS::thr_create() for descriptions of the + * possible flags values and their interactions. + * + * @param t_id Pointer to a location to receive the spawned thread's + * ID. If 0, the ID is not returned. + * + * @param t_handle Pointer to a location to receive the spawned thread's + * thread handle. If 0, the handle is not returned. + * + * @param priority The priority at which the thread is spawned. + * + * @param grp_id The thread group that the spawned thread is + * added to. If -1 is specified, a new thread group is + * created for the spawned thread. + * + * @param stack Pointers to the base of a pre-allocated stack space + * for the thread's stack. If 0, the platform allocates + * stack space for the thread. If a stack is specified, + * it is recommended that @a stack_size also be supplied + * to specify the size of the stack. + * Not all platforms support pre-allocated stacks. If + * @a stack is specified for a platform which does not + * allow pre-allocated stack space this parameter is + * ignored. + * + * @param stack_size Indicate how large the thread's stack should be, in + * bytes. If a pre-allocated stack pointer is passed in + * @a stack, @a stack_size indicates the size of that + * stack area. If no pre-allocated stack is passed, + * the stack size specified is passed to the + * operating system to request that it allocate a stack + * of the specified size. + * + * @param thr_name Pointer to a name to assign to the spawned thread. + * This is only meaningful for platforms that have a + * capacity to name threads (e.g., VxWorks and some + * varieties of Pthreads). This argument is ignored if + * specified as 0 and on platforms that do not have the + * capability to name threads. + * + * @retval -1 on failure; @c errno contains an error value. + * @retval The group id of the spawned thread. + */ + int spawn (ACE_THR_FUNC func, + void *arg = 0, + long flags = THR_NEW_LWP | THR_JOINABLE | THR_INHERIT_SCHED, + ACE_thread_t *t_id = 0, + ACE_hthread_t *t_handle = 0, + long priority = ACE_DEFAULT_THREAD_PRIORITY, + int grp_id = -1, + void *stack = 0, + size_t stack_size = ACE_DEFAULT_THREAD_STACKSIZE, + const char** thr_name = 0); + + /** + * Spawn a specified number of threads, all of which execute @a func + * with argument @a arg. + * + * @param n The number of threads to spawn. + * + * @param func The function that is called in the spawned thread. + * + * @param arg The value passed to each spawned thread's @a func. + * + * @param flags Flags to control attributes of the spawned threads. + * @sa ACE_OS::thr_create() for descriptions of the + * possible flags values and their interactions. + * + * @param priority The priority at which the threads are spawned. + * + * @param grp_id The thread group that the spawned threads are + * added to. If -1 is specified, a new thread group is + * created for the spawned threads. + * + * @param task The ACE_Task that the spawned threads are associated + * with. If 0, the threads are not associated with an + * ACE_Task. This argument is usually assigned by the + * ACE_Task_Base::activate() method to associate the + * spawned threads with the spawning ACE_Task object. + * + * @param thread_handles An array of @a n entries which will receive + * the thread handles of the spawned threads. + * + * @param stack An array of @a n pointers to pre-allocated stack space + * for each thread's stack. If specified as 0, the + * platform allocates stack space for each thread. If + * a stack is specified, it is recommended that a + * @a stack_size element also be supplied that specifies + * the size of the stack. + * Not all platforms support pre-allocated stacks. If + * @a stack is specified for a platform which does not + * allow pre-allocated stack space this parameter is + * ignored. + * + * @param stack_size An array of @a n values which indicate how large + * each thread's stack should be, in bytes. + * If pre-allocated stacks are passed in @a stacks, these + * sizes are for those stacks. If no pre-allocated stacks + * are passed, the stack sizes are specified to the + * operating system to request that it allocate stacks + * of the specified sizes. If an array entry is 0, the + * platform defaults are used for the corresponding thread. + * If a 0 array pointer is specified, platform defaults + * are used for all thread stack sizes. + * + * @param thr_name An array of names to assign to the spawned threads. + * This is only meaningful for platforms that have a + * capacity to name threads (e.g., VxWorks and some + * varieties of Pthreads). This argument is ignored if + * specified as 0 and on platforms that do not have the + * capability to name threads. + * + * ACE_Thread_Manager can manipulate threads in groups based on + * @a grp_id or @a task using functions such as kill_grp() or + * cancel_task(). + * + * @retval -1 on failure; @c errno contains an error value. + * @retval The group id of the threads. + */ + int spawn_n (size_t n, + ACE_THR_FUNC func, + void *arg = 0, + long flags = THR_NEW_LWP | THR_JOINABLE | THR_INHERIT_SCHED, + long priority = ACE_DEFAULT_THREAD_PRIORITY, + int grp_id = -1, + ACE_Task_Base *task = 0, + ACE_hthread_t thread_handles[] = 0, + void *stack[] = 0, + size_t stack_size[] = 0, + const char* thr_name[] = 0); + + /** + * Spawn a specified number of threads, all of which execute @a func + * with argument @a arg. + * + * @param thread_ids An array to receive the thread IDs of successfully + * spawned buffer. If 0, the thread IDs are not returned. + * If specified, the array must be at least @a n entries. + * + * @param n The number of threads to spawn. + * + * @param func The function that is called in the spawned thread. + * + * @param arg The value passed to each spawned thread's @a func. + * + * @param flags Flags to control attributes of the spawned threads. + * @sa ACE_OS::thr_create() for descriptions of the + * possible flags values and their interactions. + * + * @param priority The priority at which the threads are spawned. + * + * @param grp_id The thread group that the spawned threads are + * added to. If -1 is specified, a new thread group is + * created for the spawned threads. + * + * @param stack An array of @a n pointers to pre-allocated stack space + * for each thread's stack. If specified as 0, the + * platform allocates stack space for each thread. If + * a stack is specified, it is recommended that a + * @a stack_size element also be supplied that specifies + * the size of the stack. + * Not all platforms support pre-allocated stacks. If + * @a stack is specified for a platform which does not + * allow pre-allocated stack space this parameter is + * ignored. + * + * @param stack_size An array of @a n values which indicate how large + * each thread's stack should be, in bytes. + * If pre-allocated stacks are passed in @a stacks, these + * sizes are for those stacks. If no pre-allocated stacks + * are passed, the stack sizes are specified to the + * operating system to request that it allocate stacks + * of the specified sizes. If an array entry is 0, the + * platform defaults are used for the corresponding thread. + * If a 0 array pointer is specified, platform defaults + * are used for all thread stack sizes. + * + * @param thread_handles An array of @a n entries which will receive + * the thread handles of the spawned threads. + * + * @param task The ACE_Task that the spawned threads are associated + * with. If 0, the threads are not associated with an + * ACE_Task. This argument is usually assigned by the + * ACE_Task_Base::activate() method to associate the + * spawned threads with the spawning ACE_Task object. + * + * @param thr_name An array of names to assign to the spawned threads. + * This is only meaningful for platforms that have a + * capacity to name threads (e.g., VxWorks and some + * varieties of Pthreads). This argument is ignored if + * specified as 0 and on platforms that do not have the + * capability to name threads. + * + * ACE_Thread_Manager can manipulate threads in groups based on + * @a grp_id or @a task using functions such as kill_grp() or + * cancel_task(). + * + * @retval -1 on failure; @c errno contains an error value. + * @retval The group id of the threads. + + */ + int spawn_n (ACE_thread_t thread_ids[], + size_t n, + ACE_THR_FUNC func, + void *arg, + long flags, + long priority = ACE_DEFAULT_THREAD_PRIORITY, + int grp_id = -1, + void *stack[] = 0, + size_t stack_size[] = 0, + ACE_hthread_t thread_handles[] = 0, + ACE_Task_Base *task = 0, + const char* thr_name[] = 0); + + /** + * Called to clean up when a thread exits. + * + * @param do_thread_exit If non-0 then ACE_Thread::exit is called to + * exit the thread + * @param status If ACE_Thread_Exit is called, this is passed as + * the exit value of the thread. + * Should _not_ be called by main thread. + */ + ACE_THR_FUNC_RETURN exit (ACE_THR_FUNC_RETURN status = 0, + bool do_thread_exit = true); + + /** + * Block until there are no more threads running in this thread + * manager or @c timeout expires. + * + * @param timeout is treated as "absolute" time by default, but this + * can be changed to "relative" time by setting the @c + * use_absolute_time to false. + * @param abandon_detached_threads If true, @c wait() will first + * check thru its thread list for + * threads with THR_DETACHED or + * THR_DAEMON flags set and remove + * these threads. Notice that + * unlike other @c wait_*() methods, + * by default, @c wait() does wait on + * all thread spawned by this + * thread manager no matter the detached + * flags are set or not unless it is + * called with @c + * abandon_detached_threads flag set. + * @param use_absolute_time If true then treat @c timeout as + * absolute time, else relative time. + * @return 0 on success * and -1 on failure. + * + * @note If this function is called while the @c + * ACE_Object_Manager is shutting down (as a result of program + * rundown via @c ACE::fini()), it will not wait for any threads to + * complete. If you must wait for threads spawned by this thread + * manager to complete and you are in a ACE rundown situation (such + * as your object is being destroyed by the @c ACE_Object_Manager) + * you can use @c wait_grp() instead. + */ + int wait (const ACE_Time_Value *timeout = 0, + bool abandon_detached_threads = false, + bool use_absolute_time = true); + + /// Join a thread specified by @a tid. Do not wait on a detached thread. + int join (ACE_thread_t tid, ACE_THR_FUNC_RETURN *status = 0); + + /** + * Block until there are no more threads running in a group. + * Returns 0 on success and -1 on failure. Notice that wait_grp + * will not wait on detached threads. + */ + int wait_grp (int grp_id); + + /** + * Return the "real" handle to the calling thread, caching it if + * necessary in TSS to speed up subsequent lookups. This is + * necessary since on some platforms (e.g., Windows) we can't get this + * handle via direct method calls. Notice that you should *not* + * close the handle passed back from this method. It is used + * internally by Thread Manager. On the other hand, you *have to* + * use this internal thread handle when working on Thread_Manager. + * Return -1 if fail. + */ + int thr_self (ACE_hthread_t &); + + /** + * Return the unique ID of the calling thread. + * Same as calling ACE_Thread::self(). + */ + ACE_thread_t thr_self (void); + + /** + * Returns a pointer to the current ACE_Task_Base we're executing + * in if this thread is indeed running in an ACE_Task_Base, else + * return 0. + */ + ACE_Task_Base *task (void); + + /** + * @name Suspend and resume methods + * + * Suspend/resume is not supported on all platforms. For example, Pthreads + * does not support these functions. + */ + //@{ + + /// Suspend all threads + int suspend_all (void); + + /// Suspend a single thread. + int suspend (ACE_thread_t); + + /// Suspend a group of threads. + int suspend_grp (int grp_id); + + /** + * True if @a t_id is inactive (i.e., suspended), else false. Always + * return false if @a t_id is not managed by the Thread_Manager. + */ + int testsuspend (ACE_thread_t t_id); + + /// Resume all stopped threads + int resume_all (void); + + /// Resume a single thread. + int resume (ACE_thread_t); + + /// Resume a group of threads. + int resume_grp (int grp_id); + + /** + * True if @a t_id is active (i.e., resumed), else false. Always + * return false if @a t_id is not managed by the Thread_Manager. + */ + int testresume (ACE_thread_t t_id); + + //@} + + // = Send signals to one or more threads without blocking. + /** + * Send @a signum to all stopped threads. Not supported on platforms + * that do not have advanced signal support, such as Win32. + */ + int kill_all (int signum); + /** + * Send the @a signum to a single thread. Not supported on platforms + * that do not have advanced signal support, such as Win32. + */ + int kill (ACE_thread_t, int signum); + /** + * Send @a signum to a group of threads, not supported on platforms + * that do not have advanced signal support, such as Win32. + */ + int kill_grp (int grp_id, int signum); + + // = Cancel methods, which provides a cooperative thread-termination mechanism (will not block). + /** + * Cancel's all the threads. + */ + int cancel_all (int async_cancel = 0); + + /** + * Cancel a single thread. + */ + int cancel (ACE_thread_t, int async_cancel = 0); + + /** + * Cancel a group of threads. + */ + int cancel_grp (int grp_id, int async_cancel = 0); + + /** + * True if @a t_id is cancelled, else false. Always return false if + * @a t_id is not managed by the Thread_Manager. + */ + int testcancel (ACE_thread_t t_id); + + /** + * True if @a t_id has terminated (i.e., is no longer running), + * but the slot in the thread manager hasn't been reclaimed yet, + * else false. Always return false if @a t_id is not managed by the + * Thread_Manager. + */ + int testterminate (ACE_thread_t t_id); + + /// Set group ids for a particular thread id. + int set_grp (ACE_thread_t, + int grp_id); + + /// Get group ids for a particular thread id. + int get_grp (ACE_thread_t, + int &grp_id); + + /** + * @name Task-related operations + */ + //@{ + /** + * Block until there are no more threads running in a specified task. + * This method will not wait for either detached or daemon threads; + * the threads must have been spawned with the @c THR_JOINABLE flag. + * Upon successful completion, the threads have been joined, so further + * attempts to join with any of the waited-for threads will fail. + * + * @param task The ACE_Task_Base object whose threads are to waited for. + * + * @retval 0 Success. + * @retval -1 Failure (consult errno for further information). + */ + int wait_task (ACE_Task_Base *task); + + /** + * Suspend all threads in an ACE_Task. + */ + int suspend_task (ACE_Task_Base *task); + + /** + * Resume all threads in an ACE_Task. + */ + int resume_task (ACE_Task_Base *task); + + /** + * Send a signal @a signum to all threads in an ACE_Task. + */ + int kill_task (ACE_Task_Base *task, int signum); + + /** + * Cancel all threads in an ACE_Task. If is non-0, + * then asynchronously cancel these threads if the OS platform + * supports cancellation. Otherwise, perform a "cooperative" + * cancellation. + */ + int cancel_task (ACE_Task_Base *task, int async_cancel = 0); + + //@} + + // = Collect thread handles in the thread manager. Notice that + // the collected information is just a snapshot. + /// Check if the thread is managed by the thread manager. Return true if + /// the thread is found, false otherwise. + int hthread_within (ACE_hthread_t handle); + int thread_within (ACE_thread_t tid); + + /// Returns the number of ACE_Task_Base in a group. + int num_tasks_in_group (int grp_id); + + /// Returns the number of threads in an ACE_Task_Base. + int num_threads_in_task (ACE_Task_Base *task); + + /** + * Returns a list of ACE_Task_Base pointers corresponding to the tasks + * that have active threads in a specified thread group. + * + * @param grp_id The thread group ID to obtain task pointers for. + * + * @param task_list is a pointer to an array to receive the list of pointers. + * The caller is responsible for supplying an array with at + * least @arg n entries. + * + * @param n The maximum number of ACE_Task_Base pointers to write + * in @arg task_list. + * + * @retval If successful, the number of pointers returned, which will be + * no greater than @arg n. Returns -1 on error. + * + * @note This method has no way to indicate if there are more than + * @arg n ACE_Task_Base pointers available. Therefore, it may be + * wise to guess a larger value of @arg n than one thinks in cases + * where the exact number of tasks is not known. + * + * @sa num_tasks_in_group(), task_all_list() + */ + ssize_t task_list (int grp_id, + ACE_Task_Base *task_list[], + size_t n); + + /** + * Returns in @a thread_list a list of up to @a n thread ids in an + * ACE_Task_Base. The caller must allocate the memory for + * @a thread_list. In case of an error, -1 is returned. If no + * requested values are found, 0 is returned, otherwise correct + * number of retrieved values are returned. + */ + ssize_t thread_list (ACE_Task_Base *task, + ACE_thread_t thread_list[], + size_t n); + + /** + * Returns in @a hthread_list a list of up to @a n thread handles in + * an ACE_Task_Base. The caller must allocate memory for + * @a hthread_list. In case of an error, -1 is returned. If no + * requested values are found, 0 is returned, otherwise correct + * number of retrieved values are returned. + */ + ssize_t hthread_list (ACE_Task_Base *task, + ACE_hthread_t hthread_list[], + size_t n); + + /** + * Returns in @a thread_list a list of up to @a n thread ids in a + * group @a grp_id. The caller must allocate the memory for + * @a thread_list. In case of an error, -1 is returned. If no + * requested values are found, 0 is returned, otherwise correct + * number of retrieved values are returned. + */ + ssize_t thread_grp_list (int grp_id, + ACE_thread_t thread_list[], + size_t n); + + /** + * Returns in @a hthread_list a list of up to @a n thread handles in + * a group @a grp_id. The caller must allocate memory for + * @a hthread_list. + */ + ssize_t hthread_grp_list (int grp_id, + ACE_hthread_t hthread_list[], + size_t n); + + /** + * Returns a list of ACE_Task_Base pointers corresponding to the tasks + * that have active threads managed by this instance. + * + * @param task_list is a pointer to an array to receive the list of pointers. + * The caller is responsible for supplying an array with at + * least @arg n entries. + * + * @param n The maximum number of ACE_Task_Base pointers to write + * in @arg task_list. + * + * @retval If successful, the number of pointers returned, which will be + * no greater than @arg n. Returns -1 on error. + * + * @note This method has no way to indicate if there are more than + * @arg n ACE_Task_Base pointers available. Therefore, it may be + * wise to guess a larger value of @arg n than one thinks in cases + * where the exact number of tasks is not known. + * + * @sa count_threads() + */ + ssize_t task_all_list (ACE_Task_Base *task_list[], + size_t n); + + /** + * Returns in @a thread_list a list of up to @a n thread ids. The + * caller must allocate the memory for @a thread_list. In case of an + * error, -1 is returned. If no requested values are found, 0 is + * returned, otherwise correct number of retrieved values are + * returned. + */ + ssize_t thread_all_list (ACE_thread_t thread_list[], + size_t n); + + /// Set group ids for a particular task. + int set_grp (ACE_Task_Base *task, int grp_id); + + /// Get group ids for a particular task. + int get_grp (ACE_Task_Base *task, int &grp_id); + + /// Return a count of the current number of threads active in the + /// . + size_t count_threads (void) const; + + /// Get the state of the thread. Returns false if the thread is not + /// managed by this thread manager. + int thr_state (ACE_thread_t id, ACE_UINT32& state); + + /** + * Register an At_Thread_Exit hook and the ownership is acquire by + * Thread_Descriptor, this is the usual case when the AT is dynamically + * allocated. + */ + int at_exit (ACE_At_Thread_Exit* cleanup); + + /// Register an At_Thread_Exit hook and the ownership is retained for the + /// caller. Normally used when the at_exit hook is created in stack. + int at_exit (ACE_At_Thread_Exit& cleanup); + + /** + * + ***** + * @deprecated This function is deprecated. Please use the previous two + * at_exit method. Notice that you should avoid mixing this method + * with the previous two at_exit methods. + ***** + * + * Register an object (or array) for cleanup at + * thread termination. "cleanup_hook" points to a (global, or + * static member) function that is called for the object or array + * when it to be destroyed. It may perform any necessary cleanup + * specific for that object or its class. "param" is passed as the + * second parameter to the "cleanup_hook" function; the first + * parameter is the object (or array) to be destroyed. + * "cleanup_hook", for example, may delete the object (or array). + * If == 0, the will _NOT_ get cleanup at + * thread exit. You can use this to cancel the previously added + * at_exit. + */ + int at_exit (void *object, + ACE_CLEANUP_FUNC cleanup_hook, + void *param); + + /// Access function to determine whether the Thread_Manager will + /// wait for its thread to exit or not when being closing down. + void wait_on_exit (int dowait); + int wait_on_exit (void); + + /// Dump the state of an object. + void dump (void); + + /// Declare the dynamic allocation hooks. + ACE_ALLOC_HOOK_DECLARE; + +protected: + // = Accessors for ACE_Thread_Descriptors. + /** + * Get a pointer to the calling thread's own thread_descriptor. + * This must be called from a spawn thread. This function will + * fetch the info from TSS. + */ + ACE_Thread_Descriptor *thread_desc_self (void); + + /// Return a pointer to the thread's Thread_Descriptor, + /// 0 if fail. + ACE_Thread_Descriptor *thread_descriptor (ACE_thread_t); + + /// Return a pointer to the thread's Thread_Descriptor, + /// 0 if fail. + ACE_Thread_Descriptor *hthread_descriptor (ACE_hthread_t); + + /// Create a new thread (must be called with locks held). + int spawn_i (ACE_THR_FUNC func, + void *arg, + long flags, + ACE_thread_t * = 0, + ACE_hthread_t *t_handle = 0, + long priority = ACE_DEFAULT_THREAD_PRIORITY, + int grp_id = -1, + void *stack = 0, + size_t stack_size = 0, + ACE_Task_Base *task = 0, + const char** thr_name = 0); + + /// Run the registered hooks when the thread exits. + void run_thread_exit_hooks (int i); + + /// Locate the index of the table slot occupied by . Returns + /// -1 if is not in the table doesn't contain . + ACE_Thread_Descriptor *find_thread (ACE_thread_t t_id); + + /// Locate the index of the table slot occupied by . Returns + /// -1 if is not in the table doesn't contain . + ACE_Thread_Descriptor *find_hthread (ACE_hthread_t h_id); + + /** + * Locate the thread descriptor address of the list occupied by + * @a task. Returns 0 if @a task is not in the table doesn't contain + * @a task. + */ + ACE_Thread_Descriptor *find_task (ACE_Task_Base *task, + size_t slot = 0); + + /// Insert a thread in the table (checks for duplicates). + int insert_thr (ACE_thread_t t_id, + ACE_hthread_t, + int grp_id = -1, + long flags = 0); + + /// Append a thread in the table (adds at the end, growing the table + /// if necessary). + int append_thr (ACE_thread_t t_id, ACE_hthread_t, + ACE_UINT32, + int grp_id, + ACE_Task_Base *task = 0, + long flags = 0, + ACE_Thread_Descriptor *td = 0); + + /// Remove thread from the table. + void remove_thr (ACE_Thread_Descriptor *td, + int close_handler); + + /// Remove all threads from the table. + void remove_thr_all (void); + + // = The following four methods implement a simple scheme for + // operating on a collection of threads atomically. + + /** + * Efficiently check whether @a thread is in a particular @a state. + * This call updates the TSS cache if possible to speed up + * subsequent searches. + */ + int check_state (ACE_UINT32 state, + ACE_thread_t thread, + int enable = 1); + + /// Apply @a func to all members of the table that match the @a task + int apply_task (ACE_Task_Base *task, + ACE_THR_MEMBER_FUNC func, + int = 0); + + /// Apply @a func to all members of the table that match the @a grp_id. + int apply_grp (int grp_id, + ACE_THR_MEMBER_FUNC func, + int arg = 0); + + /// Apply @a func to all members of the table. + int apply_all (ACE_THR_MEMBER_FUNC, + int = 0); + + /// Join the thread described in @a td. + int join_thr (ACE_Thread_Descriptor *td, + int = 0); + + /// Resume the thread described in @a td. + int resume_thr (ACE_Thread_Descriptor *td, + int = 0); + + /// Suspend the thread described in @a td. + int suspend_thr (ACE_Thread_Descriptor *td, + int = 0); + + /// Send signal @a signum to the thread described in @a td. + int kill_thr (ACE_Thread_Descriptor *td, + int signum); + + /// Set the cancellation flag for the thread described in @a td. + int cancel_thr (ACE_Thread_Descriptor *td, + int async_cancel = 0); + + /// Register a thread as terminated and put it into the . + int register_as_terminated (ACE_Thread_Descriptor *td); + + /// Setting the static ACE_TSS_TYPE (ACE_Thread_Exit) *thr_exit_ pointer. + static int set_thr_exit (ACE_TSS_TYPE (ACE_Thread_Exit) *ptr); + + /** + * Keeping a list of thread descriptors within the thread manager. + * Double-linked list enables us to cache the entries in TSS + * and adding/removing thread descriptor entries without + * affecting other thread's descriptor entries. + */ + ACE_Double_Linked_List thr_list_; + +#if !defined (ACE_HAS_VXTHREADS) + /// Collect terminated but not yet joined thread entries. + ACE_Double_Linked_List terminated_thr_list_; +#endif /* !ACE_HAS_VXTHREADS */ + + /// Collect pointers to thread descriptors of threads to be removed later. + ACE_Unbounded_Queue thr_to_be_removed_; + + /// Keeps track of the next group id to assign. + int grp_id_; + + /// Set if we want the Thread_Manager to wait on all threads before + /// being closed, reset otherwise. + int automatic_wait_; + + // = ACE_Thread_Mutex and condition variable for synchronizing termination. +#if defined (ACE_HAS_THREADS) + /// Serialize access to the . + ACE_Thread_Mutex lock_; + + /// Keep track of when there are no more threads. + ACE_Condition_Thread_Mutex zero_cond_; +#endif /* ACE_HAS_THREADS */ + + ACE_Locked_Free_List thread_desc_freelist_; + +private: +#if ! defined (ACE_THREAD_MANAGER_LACKS_STATICS) + /// Pointer to a process-wide ACE_Thread_Manager. + static ACE_Thread_Manager *thr_mgr_; + + /// Must delete the thr_mgr_ if true. + static bool delete_thr_mgr_; + + /// Global ACE_TSS (ACE_Thread_Exit) object ptr. + static ACE_TSS_TYPE (ACE_Thread_Exit) *thr_exit_; +#endif /* ! defined (ACE_THREAD_MANAGER_LACKS_STATICS) */ +}; + +#if defined (ACE_THREAD_MANAGER_LACKS_STATICS) +#define ACE_THREAD_MANAGER_SINGLETON_DEFINE \ + ACE_Singleton; +typedef ACE_Singleton ACE_THREAD_MANAGER_SINGLETON; +#endif /* defined (ACE_THREAD_MANAGER_LACKS_STATICS) */ + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +#include "ace/Thread_Manager.inl" +#endif /* __ACE_INLINE__ */ + +#include /**/ "ace/post.h" +#endif /* ACE_THREAD_MANAGER_H */ diff --git a/dep/ACE_wrappers/ace/Thread_Manager.inl b/dep/ACE_wrappers/ace/Thread_Manager.inl new file mode 100644 index 00000000000..6be65a664fa --- /dev/null +++ b/dep/ACE_wrappers/ace/Thread_Manager.inl @@ -0,0 +1,307 @@ +// -*- C++ -*- +// +// $Id: Thread_Manager.inl 82588 2008-08-11 13:37:41Z johnnyw $ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_INLINE +ACE_At_Thread_Exit::ACE_At_Thread_Exit (void) + : next_ (0), + td_ (0), + was_applied_ (false), + is_owner_ (true) +{ +} + +ACE_INLINE bool +ACE_At_Thread_Exit::was_applied() const +{ + return was_applied_; +} + +ACE_INLINE bool +ACE_At_Thread_Exit::was_applied (bool applied) +{ + was_applied_ = applied; + if (was_applied_) + td_ = 0; + return was_applied_; +} + +ACE_INLINE bool +ACE_At_Thread_Exit::is_owner() const +{ + return is_owner_; +} + +ACE_INLINE bool +ACE_At_Thread_Exit::is_owner (bool owner) +{ + is_owner_ = owner; + return is_owner_; +} + +ACE_INLINE void +ACE_At_Thread_Exit::do_apply (void) +{ + if (!this->was_applied_ && this->is_owner_) + td_->at_pop(); +} + +ACE_INLINE +ACE_At_Thread_Exit_Func::ACE_At_Thread_Exit_Func (void *object, + ACE_CLEANUP_FUNC func, + void *param) + : object_(object), + func_(func), + param_(param) +{ +} + +ACE_INLINE +ACE_Thread_Descriptor_Base::ACE_Thread_Descriptor_Base (void) + : ACE_OS_Thread_Descriptor (), + thr_id_ (ACE_OS::NULL_thread), + thr_handle_ (ACE_OS::NULL_hthread), + grp_id_ (0), + thr_state_ (ACE_Thread_Manager::ACE_THR_IDLE), + task_ (0), + next_ (0), + prev_ (0) +{ +} + +ACE_INLINE +ACE_Thread_Descriptor_Base::~ACE_Thread_Descriptor_Base (void) +{ +} + +ACE_INLINE bool +ACE_Thread_Descriptor_Base::operator== ( + const ACE_Thread_Descriptor_Base &rhs) const +{ + return + ACE_OS::thr_cmp (this->thr_handle_, rhs.thr_handle_) + && ACE_OS::thr_equal (this->thr_id_, rhs.thr_id_); +} + +ACE_INLINE bool +ACE_Thread_Descriptor_Base::operator!=(const ACE_Thread_Descriptor_Base &rhs) const +{ + return !(*this == rhs); +} + +ACE_INLINE ACE_Task_Base * +ACE_Thread_Descriptor_Base::task (void) const +{ + ACE_TRACE ("ACE_Thread_Descriptor_Base::task"); + return this->task_; +} + +// Group ID. + +ACE_INLINE int +ACE_Thread_Descriptor_Base::grp_id (void) const +{ + ACE_TRACE ("ACE_Thread_Descriptor_Base::grp_id"); + return grp_id_; +} + +// Current state of the thread. +ACE_INLINE ACE_UINT32 +ACE_Thread_Descriptor_Base::state (void) const +{ + ACE_TRACE ("ACE_Thread_Descriptor_Base::state"); + return thr_state_; +} + +// Reset this base descriptor. +ACE_INLINE void +ACE_Thread_Descriptor_Base::reset (void) +{ + ACE_TRACE ("ACE_Thread_Descriptor_Base::reset"); + this->thr_id_ = ACE_OS::NULL_thread; + this->thr_handle_ = ACE_OS::NULL_hthread; + this->grp_id_ = 0; + this->thr_state_ = ACE_Thread_Manager::ACE_THR_IDLE; + this->task_ = 0; + this->flags_ = 0; +} + +// Unique thread id. +ACE_INLINE ACE_thread_t +ACE_Thread_Descriptor::self (void) const +{ + ACE_TRACE ("ACE_Thread_Descriptor::self"); + return this->thr_id_; +} + +// Unique kernel-level thread handle. + +ACE_INLINE void +ACE_Thread_Descriptor::self (ACE_hthread_t &handle) +{ + ACE_TRACE ("ACE_Thread_Descriptor::self"); + handle = this->thr_handle_; +} + +ACE_INLINE void +ACE_Thread_Descriptor::log_msg_cleanup (ACE_Log_Msg* log_msg) + +{ + log_msg_ = log_msg; +} + +// Set the pointer +ACE_INLINE void +ACE_Thread_Descriptor::set_next (ACE_Thread_Descriptor *td) +{ + ACE_TRACE ("ACE_Thread_Descriptor::set_next"); + this->next_ = td; +} + +// Get the pointer +ACE_INLINE ACE_Thread_Descriptor * +ACE_Thread_Descriptor::get_next (void) const +{ + ACE_TRACE ("ACE_Thread_Descriptor::get_next"); + return static_cast (this->next_); +} + +// Reset this thread descriptor +ACE_INLINE void +ACE_Thread_Descriptor::reset (ACE_Thread_Manager *tm) +{ + ACE_TRACE ("ACE_Thread_Descriptor::reset"); + this->ACE_Thread_Descriptor_Base::reset (); + this->at_exit_list_ = 0; + // Start the at_exit hook list. + this->tm_ = tm; + // Setup the Thread_Manager. + this->log_msg_ = 0; + this->terminated_ = false; +} + +ACE_INLINE ACE_Thread_Descriptor * +ACE_Thread_Manager::thread_desc_self (void) +{ + // This method must be called with lock held. + + // Try to get it from cache. + ACE_Thread_Descriptor *desc = ACE_LOG_MSG->thr_desc (); + +#if 1 + // ACE_ASSERT (desc != 0); + // Thread descriptor should always get cached. +#else + if (desc == 0) + { + ACE_thread_t id = ACE_OS::thr_self (); + + desc = this->find_thread (id); + + // Thread descriptor adapter might not have been put into the + // list yet. + if (desc != 0) + // Update the TSS cache. + ACE_LOG_MSG->thr_desc (desc); + } +#endif + return desc; +} + +// Return the unique ID of the thread. + +ACE_INLINE ACE_thread_t +ACE_Thread_Manager::thr_self (void) +{ + ACE_TRACE ("ACE_Thread_Manager::thr_self"); + return ACE_Thread::self (); +} + +ACE_INLINE ACE_Task_Base * +ACE_Thread_Manager::task (void) +{ + ACE_TRACE ("ACE_Thread_Manager::task"); + + ACE_Thread_Descriptor *td = this->thread_desc_self () ; + + if (td == 0) + return 0; + else + return td->task (); +} + +ACE_INLINE int +ACE_Thread_Manager::open (size_t) +{ + // Currently no-op. + return 0; +} + +ACE_INLINE int +ACE_Thread_Manager::at_exit (ACE_At_Thread_Exit* at) +{ + ACE_Thread_Descriptor *td = this->thread_desc_self (); + if (td == 0) + return -1; + else + return td->at_exit (at); +} + +ACE_INLINE int +ACE_Thread_Manager::at_exit (ACE_At_Thread_Exit& at) +{ + ACE_Thread_Descriptor *td = this->thread_desc_self (); + if (td == 0) + return -1; + else + return td->at_exit (at); +} + +ACE_INLINE int +ACE_Thread_Manager::at_exit (void *object, + ACE_CLEANUP_FUNC cleanup_hook, + void *param) +{ + ACE_Thread_Descriptor *td = this->thread_desc_self (); + if (td == 0) + return -1; + else + return td->at_exit (object, + cleanup_hook, + param); +} + +ACE_INLINE void +ACE_Thread_Manager::wait_on_exit (int do_wait) +{ + this->automatic_wait_ = do_wait; +} + +ACE_INLINE int +ACE_Thread_Manager::wait_on_exit (void) +{ + return this->automatic_wait_; +} + +ACE_INLINE int +ACE_Thread_Manager::register_as_terminated (ACE_Thread_Descriptor *td) +{ +#if defined (ACE_HAS_VXTHREADS) + ACE_UNUSED_ARG (td); +#else /* ! ACE_HAS_VXTHREADS */ + ACE_Thread_Descriptor_Base *tdb = 0; + ACE_NEW_RETURN (tdb, ACE_Thread_Descriptor_Base (*td), -1); + this->terminated_thr_list_.insert_tail (tdb); +#endif /* !ACE_HAS_VXTHREADS */ + return 0; +} + +ACE_INLINE size_t +ACE_Thread_Manager::count_threads (void) const +{ + return this->thr_list_.size (); +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Thread_Mutex.cpp b/dep/ACE_wrappers/ace/Thread_Mutex.cpp new file mode 100644 index 00000000000..4ebdc412e6f --- /dev/null +++ b/dep/ACE_wrappers/ace/Thread_Mutex.cpp @@ -0,0 +1,62 @@ +/** + * @file Thread_Mutex.cpp + * + * $Id: Thread_Mutex.cpp 80826 2008-03-04 14:51:23Z wotte $ + * + * Originally in Synch.cpp + * + * @author Douglas C. Schmidt + */ + +#include "ace/Thread_Mutex.h" + +#if defined (ACE_HAS_THREADS) + +#if !defined (__ACE_INLINE__) +#include "ace/Thread_Mutex.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/Log_Msg.h" +#include "ace/Malloc_T.h" + +ACE_RCSID(ace, Thread_Mutex, "$Id: Thread_Mutex.cpp 80826 2008-03-04 14:51:23Z wotte $") + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_ALLOC_HOOK_DEFINE(ACE_Thread_Mutex) + +void +ACE_Thread_Mutex::dump (void) const +{ +#if defined (ACE_HAS_DUMP) +// ACE_TRACE ("ACE_Thread_Mutex::dump"); + + ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\n"))); + ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); +#endif /* ACE_HAS_DUMP */ +} + +ACE_Thread_Mutex::~ACE_Thread_Mutex (void) +{ +// ACE_TRACE ("ACE_Thread_Mutex::~ACE_Thread_Mutex"); + this->remove (); +} + +ACE_Thread_Mutex::ACE_Thread_Mutex (const ACE_TCHAR *name, ACE_mutexattr_t *arg) + : removed_ (false) +{ +// ACE_TRACE ("ACE_Thread_Mutex::ACE_Thread_Mutex"); + + if (ACE_OS::thread_mutex_init (&this->lock_, + 0, + name, + arg) != 0) + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("%p\n"), + ACE_TEXT ("ACE_Thread_Mutex::ACE_Thread_Mutex"))); +} + +ACE_END_VERSIONED_NAMESPACE_DECL + +#endif /* ACE_HAS_THREADS */ diff --git a/dep/ACE_wrappers/ace/Thread_Mutex.h b/dep/ACE_wrappers/ace/Thread_Mutex.h new file mode 100644 index 00000000000..471434eb49b --- /dev/null +++ b/dep/ACE_wrappers/ace/Thread_Mutex.h @@ -0,0 +1,175 @@ +// -*- C++ -*- + +//========================================================================== +/** + * @file Thread_Mutex.h + * + * $Id: Thread_Mutex.h 80826 2008-03-04 14:51:23Z wotte $ + * + * Moved from Synch.h. + * + * @author Douglas C. Schmidt + */ +//========================================================================== + +#ifndef ACE_THREAD_MUTEX_H +#define ACE_THREAD_MUTEX_H +#include /**/ "ace/pre.h" + +#include /**/ "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#if !defined (ACE_HAS_THREADS) +# include "ace/Null_Mutex.h" +#else /* ACE_HAS_THREADS */ +// ACE platform supports some form of threading. + +#include /**/ "ace/ACE_export.h" +#include "ace/OS_NS_Thread.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +/** + * @class ACE_Thread_Mutex + * + * @brief ACE_Thread_Mutex wrapper (only valid for threads in the same + * process). + * + * This implementation is optimized for locking threads that are + * in the same process. It maps to s on NT + * and with set to on UNIX. + * ACE_Thread_Mutex is recursive on some platforms (like + * Win32). However, on most platforms (like Solaris) it is not + * recursive. To be totally safe and portable, developers + * should use ACE_Recursive_Thread_Mutex when they need a + * recursive mutex. + */ +class ACE_Export ACE_Thread_Mutex +{ + friend class ACE_Condition_Thread_Mutex; +public: + /// Constructor. + ACE_Thread_Mutex (const ACE_TCHAR *name = 0, + ACE_mutexattr_t *attributes = 0); + + /// Implicitly destroy the mutex. + ~ACE_Thread_Mutex (void); + + /** + * Explicitly destroy the mutex. Note that only one thread should + * call this method since it doesn't protect against race + * conditions. + */ + int remove (void); + + /// Acquire lock ownership (wait on queue if necessary). + int acquire (void); + + /** + * Block the thread until we acquire the mutex or until @a tv times + * out, in which case -1 is returned with @c errno == @c ETIME. Note + * that @a tv is assumed to be in "absolute" rather than "relative" + * time. The value of @a tv is updated upon return to show the + * actual (absolute) acquisition time. + */ + int acquire (ACE_Time_Value &tv); + + /** + * If @a tv == 0 the call directly. Otherwise, Block the + * thread until we acquire the mutex or until @a tv times out, in + * which case -1 is returned with @c errno == @c ETIME. Note that + * @a tv is assumed to be in "absolute" rather than "relative" time. + * The value of @a tv is updated upon return to show the actual + * (absolute) acquisition time. + */ + int acquire (ACE_Time_Value *tv); + + /** + * Conditionally acquire lock (i.e., don't wait on queue). Returns + * -1 on failure. If we "failed" because someone else already had + * the lock, @c errno is set to @c EBUSY. + */ + int tryacquire (void); + + /// Release lock and unblock a thread at head of queue. + int release (void); + + /** + * Acquire mutex ownership. This calls acquire() and is only here + * to make the ACE_Thread_Mutex interface consistent with the + * other synchronization APIs. + */ + int acquire_read (void); + + /** + * Acquire mutex ownership. This calls acquire() and is only here + * to make the ACE_Thread_Mutex interface consistent with the + * other synchronization APIs. + */ + int acquire_write (void); + + /** + * Conditionally acquire mutex (i.e., won't block). This calls + * tryacquire() and is only here to make the ACE_Thread_Mutex + * interface consistent with the other synchronization APIs. + * Returns -1 on failure. If we "failed" because someone else + * already had the lock, @c errno is set to @c EBUSY. + */ + int tryacquire_read (void); + + /** + * Conditionally acquire mutex (i.e., won't block). This calls + * tryacquire() and is only here to make the ACE_Thread_Mutex + * interface consistent with the other synchronization APIs. + * Returns -1 on failure. If we "failed" because someone else + * already had the lock, @c errno is set to @c EBUSY. + */ + int tryacquire_write (void); + + /** + * This is only here to make the ACE_Thread_Mutex + * interface consistent with the other synchronization APIs. + * Assumes the caller has already acquired the mutex using one of + * the above calls, and returns 0 (success) always. + */ + int tryacquire_write_upgrade (void); + + /// Return the underlying mutex. + const ACE_thread_mutex_t &lock (void) const; + + /// Dump the state of an object. + void dump (void) const; + + /// Declare the dynamic allocation hooks. + ACE_ALLOC_HOOK_DECLARE; + + // protected: + /// Mutex type that supports single-process locking efficiently. + ACE_thread_mutex_t lock_; + + /// Keeps track of whether remove() has been called yet to avoid + /// multiple calls, e.g., explicitly and implicitly in the + /// destructor. This flag isn't protected by a lock, so make sure + /// that you don't have multiple threads simultaneously calling + /// on the same object, which is a bad idea anyway... + bool removed_; + +private: + // = Prevent assignment and initialization. + void operator= (const ACE_Thread_Mutex &); + ACE_Thread_Mutex (const ACE_Thread_Mutex &); +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +#include "ace/Thread_Mutex.inl" +#endif /* __ACE_INLINE__ */ + +#endif /* !ACE_HAS_THREADS */ + +#include /**/ "ace/post.h" +#endif /* ACE_THREAD_MUTEX_H */ diff --git a/dep/ACE_wrappers/ace/Thread_Mutex.inl b/dep/ACE_wrappers/ace/Thread_Mutex.inl new file mode 100644 index 00000000000..ff744684c2b --- /dev/null +++ b/dep/ACE_wrappers/ace/Thread_Mutex.inl @@ -0,0 +1,97 @@ +// -*- C++ -*- +// +// $Id: Thread_Mutex.inl 80826 2008-03-04 14:51:23Z wotte $ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_INLINE const ACE_thread_mutex_t & +ACE_Thread_Mutex::lock (void) const +{ +// ACE_TRACE ("ACE_Thread_Mutex::lock"); + return this->lock_; +} + +ACE_INLINE int +ACE_Thread_Mutex::acquire_read (void) +{ +// ACE_TRACE ("ACE_Thread_Mutex::acquire_read"); + return ACE_OS::thread_mutex_lock (&this->lock_); +} + +ACE_INLINE int +ACE_Thread_Mutex::acquire_write (void) +{ +// ACE_TRACE ("ACE_Thread_Mutex::acquire_write"); + return ACE_OS::thread_mutex_lock (&this->lock_); +} + +ACE_INLINE int +ACE_Thread_Mutex::tryacquire_read (void) +{ +// ACE_TRACE ("ACE_Thread_Mutex::tryacquire_read"); + return ACE_OS::thread_mutex_trylock (&this->lock_); +} + +ACE_INLINE int +ACE_Thread_Mutex::tryacquire_write (void) +{ +// ACE_TRACE ("ACE_Thread_Mutex::tryacquire_write"); + return ACE_OS::thread_mutex_trylock (&this->lock_); +} + +ACE_INLINE int +ACE_Thread_Mutex::tryacquire_write_upgrade (void) +{ +// ACE_TRACE ("ACE_Thread_Mutex::tryacquire_write_upgrade"); + return 0; +} + +ACE_INLINE int +ACE_Thread_Mutex::acquire (void) +{ +// ACE_TRACE ("ACE_Thread_Mutex::acquire"); + return ACE_OS::thread_mutex_lock (&this->lock_); +} + +ACE_INLINE int +ACE_Thread_Mutex::acquire (ACE_Time_Value &tv) +{ + // ACE_TRACE ("ACE_Thread_Mutex::acquire"); + return ACE_OS::thread_mutex_lock (&this->lock_, tv); +} + +ACE_INLINE int +ACE_Thread_Mutex::acquire (ACE_Time_Value *tv) +{ + // ACE_TRACE ("ACE_Thread_Mutex::acquire"); + return ACE_OS::thread_mutex_lock (&this->lock_, tv); +} + +ACE_INLINE int +ACE_Thread_Mutex::tryacquire (void) +{ +// ACE_TRACE ("ACE_Thread_Mutex::tryacquire"); + return ACE_OS::thread_mutex_trylock (&this->lock_); +} + +ACE_INLINE int +ACE_Thread_Mutex::release (void) +{ +// ACE_TRACE ("ACE_Thread_Mutex::release"); + return ACE_OS::thread_mutex_unlock (&this->lock_); +} + +ACE_INLINE int +ACE_Thread_Mutex::remove (void) +{ +// ACE_TRACE ("ACE_Thread_Mutex::remove"); + int result = 0; + if (this->removed_ == false) + { + this->removed_ = true; + result = ACE_OS::thread_mutex_destroy (&this->lock_); + } + return result; +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Thread_Semaphore.cpp b/dep/ACE_wrappers/ace/Thread_Semaphore.cpp new file mode 100644 index 00000000000..39b28931db5 --- /dev/null +++ b/dep/ACE_wrappers/ace/Thread_Semaphore.cpp @@ -0,0 +1,62 @@ +/** + * @file Thread_Semaphore.cpp + * + * $Id: Thread_Semaphore.cpp 80826 2008-03-04 14:51:23Z wotte $ + * + * Originally in Synch.cpp + * + * @author Douglas C. Schmidt + */ + +#include "ace/Thread_Semaphore.h" + +#if defined (ACE_HAS_THREADS) + +#if !defined (__ACE_INLINE__) +#include "ace/Thread_Semaphore.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/ACE.h" + +ACE_RCSID(ace, Thread_Semaphore, "$Id: Thread_Semaphore.cpp 80826 2008-03-04 14:51:23Z wotte $") + + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +void +ACE_Thread_Semaphore::dump (void) const +{ +#if defined (ACE_HAS_DUMP) +// ACE_TRACE ("ACE_Thread_Semaphore::dump"); + + ACE_Semaphore::dump (); +#endif /* ACE_HAS_DUMP */ +} + +ACE_Thread_Semaphore::ACE_Thread_Semaphore (unsigned int count, + const ACE_TCHAR *name, + void *arg, + int max) + : ACE_Semaphore (count, USYNC_THREAD, name, arg, max) +{ +// ACE_TRACE ("ACE_Thread_Semaphore::ACE_Thread_Semaphore"); +} + +/*****************************************************************************/ + +ACE_Thread_Semaphore * +ACE_Malloc_Lock_Adapter_T::operator () (const ACE_TCHAR *name) +{ + ACE_Thread_Semaphore *p = 0; + if (name == 0) + ACE_NEW_RETURN (p, ACE_Thread_Semaphore (1, name), 0); + else + ACE_NEW_RETURN (p, ACE_Thread_Semaphore (1, ACE::basename (name, + ACE_DIRECTORY_SEPARATOR_CHAR)), + 0); + return p; +} + +ACE_END_VERSIONED_NAMESPACE_DECL + +#endif /* ACE_HAS_THREADS */ diff --git a/dep/ACE_wrappers/ace/Thread_Semaphore.h b/dep/ACE_wrappers/ace/Thread_Semaphore.h new file mode 100644 index 00000000000..b35ef334cb4 --- /dev/null +++ b/dep/ACE_wrappers/ace/Thread_Semaphore.h @@ -0,0 +1,89 @@ +// -*- C++ -*- + +//========================================================================== +/** + * @file Thread_Semaphore.h + * + * $Id: Thread_Semaphore.h 80826 2008-03-04 14:51:23Z wotte $ + * + * Moved from Synch.h. + * + * @author Douglas C. Schmidt + */ +//========================================================================== + +#ifndef ACE_THREAD_SEMAPHORE_H +#define ACE_THREAD_SEMAPHORE_H +#include /**/ "ace/pre.h" + +#include /**/ "ace/ACE_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#if !defined (ACE_HAS_THREADS) +# include "ace/Null_Semaphore.h" +#else /* ACE_HAS_THREADS */ +// ACE platform supports some form of threading. + +#include "ace/Semaphore.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +/** + * @class ACE_Thread_Semaphore + * + * @brief Wrapper for Dijkstra style general semaphores that work + * only within one process. + */ +class ACE_Export ACE_Thread_Semaphore : public ACE_Semaphore +{ +public: + /// Initialize the semaphore, with an initial value of @a count, + /// maximum value of @a max, and unlocked by default. + ACE_Thread_Semaphore (unsigned int count = 1, // By default make this unlocked. + const ACE_TCHAR *name = 0, + void * = 0, + int max = 0x7FFFFFFF); + + /// Default dtor. + ~ACE_Thread_Semaphore (void); + + /// Dump the state of an object. + void dump (void) const; + + /// Declare the dynamic allocation hooks. + ACE_ALLOC_HOOK_DECLARE; +}; + +/*****************************************************************************/ + +template class ACE_Malloc_Lock_Adapter_T; + +/** + * @class ACE_Malloc_Lock_Adapter_T + * + * @brief Template specialization of ACE_Malloc_Lock_Adapter_T for + * ACE_Thread_Semaphore. + * + * This is needed since the ctor for ACE_Thread_Semaphore doesn't match + * the standard form used by other lock strategy classes. + */ +template<> +class ACE_Export ACE_Malloc_Lock_Adapter_T +{ +public: + ACE_Thread_Semaphore * operator () (const ACE_TCHAR *name); +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +#include "ace/Thread_Semaphore.inl" +#endif /* __ACE_INLINE__ */ + +#endif /* !ACE_HAS_THREADS */ + +#include /**/ "ace/post.h" +#endif /* ACE_THREAD_SEMAPHORE_H */ diff --git a/dep/ACE_wrappers/ace/Thread_Semaphore.inl b/dep/ACE_wrappers/ace/Thread_Semaphore.inl new file mode 100644 index 00000000000..b64ec3c08f5 --- /dev/null +++ b/dep/ACE_wrappers/ace/Thread_Semaphore.inl @@ -0,0 +1,12 @@ +// -*- C++ -*- +// +// $Id: Thread_Semaphore.inl 80826 2008-03-04 14:51:23Z wotte $ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_INLINE +ACE_Thread_Semaphore::~ACE_Thread_Semaphore (void) +{ +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Throughput_Stats.cpp b/dep/ACE_wrappers/ace/Throughput_Stats.cpp new file mode 100644 index 00000000000..6e667299729 --- /dev/null +++ b/dep/ACE_wrappers/ace/Throughput_Stats.cpp @@ -0,0 +1,202 @@ +// $Id: Throughput_Stats.cpp 80826 2008-03-04 14:51:23Z wotte $ + +#include "ace/Throughput_Stats.h" + +#include "ace/OS_NS_stdio.h" +#include "ace/OS_NS_string.h" +#include "ace/High_Res_Timer.h" +#include "ace/Log_Msg.h" + +ACE_RCSID(ace, Throughput_Stats, "$Id: Throughput_Stats.cpp 80826 2008-03-04 14:51:23Z wotte $") + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_Throughput_Stats::ACE_Throughput_Stats (void) + : ACE_Basic_Stats () + , throughput_last_ (0) +#if 0 + // @@TODO: This is what I really wanted to compute, but it just + // does not work. + , throughput_sum_x_ (0) + , throughput_sum_x2_ (0) + , throughput_sum_y_ (0) + , throughput_sum_y2_ (0) + , throughput_sum_xy_ (0) +#endif /* 0 */ +{ +} + +void +ACE_Throughput_Stats::sample (ACE_UINT64 throughput, + ACE_UINT64 latency) +{ + this->ACE_Basic_Stats::sample (latency); + + if (this->samples_count () == 1u) + { + + this->throughput_last_ = throughput; +#if 0 + // @@TODO: This is what I really wanted to compute, but it just + // does not work. + this->throughput_sum_y_ = this->samples_count_; + this->throughput_sum_y2_ = this->samples_count_ * this->samples_count_; + this->throughput_sum_x_ = throughput; + this->throughput_sum_x2_ = throughput * throughput; + this->throughput_sum_xy_ = throughput * this->samples_count_; + + ACE_OS::printf ("%f %qu\n", throughput / 400000000.0, this->samples_count_); +#endif /* 0 */ + } + else + { + this->throughput_last_ = throughput; + +#if 0 + // @@TODO: This is what I really wanted to compute, but it just + // does not work. + this->throughput_sum_y_ += this->samples_count_; + this->throughput_sum_y2_ += this->samples_count_ * this->samples_count_; + this->throughput_sum_x_ += throughput; + this->throughput_sum_x2_ += throughput * throughput; + this->throughput_sum_xy_ += throughput * this->samples_count_; + + ACE_OS::printf ("%f %qu\n", throughput / 400000000.0, this->samples_count_); +#endif /* 0 */ + } +} + +void +ACE_Throughput_Stats::accumulate (const ACE_Throughput_Stats &rhs) +{ + if (rhs.samples_count () == 0u) + return; + + this->ACE_Basic_Stats::accumulate (rhs); + + if (this->samples_count () == 0u) + { + this->throughput_last_ = rhs.throughput_last_; +#if 0 + // @@TODO: This is what I really wanted to compute, but it just + // does not work. + this->throughput_sum_x_ = rhs.throughput_sum_x_; + this->throughput_sum_x2_ = rhs.throughput_sum_x2_; + this->throughput_sum_y_ = rhs.throughput_sum_y_; + this->throughput_sum_y2_ = rhs.throughput_sum_y2_; + this->throughput_sum_xy_ = rhs.throughput_sum_xy_; +#endif /* 0 */ + + return; + } + + + if (this->throughput_last_ < rhs.throughput_last_) + this->throughput_last_ = rhs.throughput_last_; + +#if 0 + // @@TODO: This is what I really wanted to compute, but it just + // does not work. + this->throughput_sum_x_ += rhs.throughput_sum_x_; + this->throughput_sum_x2_ += rhs.throughput_sum_x2_; + this->throughput_sum_y_ += rhs.throughput_sum_y_; + this->throughput_sum_y2_ += rhs.throughput_sum_y2_; + this->throughput_sum_xy_ += rhs.throughput_sum_xy_; +#endif /* 0 */ +} + +void +ACE_Throughput_Stats::dump_results (const ACE_TCHAR* msg, + ACE_UINT32 sf) +{ + if (this->samples_count () == 0u) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("%s : no data collected\n"), msg)); + return; + } + + this->ACE_Basic_Stats::dump_results (msg, sf); + + ACE_Throughput_Stats::dump_throughput (msg, sf, + this->throughput_last_, + this->samples_count ()); + +#if 0 + // @@TODO: This is what I really wanted to generate, but it just + // doesn't work. + double t_sum_x = + ACE_CU64_TO_CU32 (this->throughput_sum_x_);// / sf); + //t_sum_x /= 1000000.0; + double t_sum_y = + ACE_CU64_TO_CU32 (this->throughput_sum_y_); + double t_sum_x2 = + ACE_CU64_TO_CU32 (this->throughput_sum_x2_);// / (sf*sf)); + //t_sum_x2 /= 1000000.0; + //t_sum_x2 /= 1000000.0; + double t_sum_y2 = + ACE_CU64_TO_CU32 (this->throughput_sum_y2_); + double t_sum_xy = + ACE_CU64_TO_CU32 (this->throughput_sum_xy_);// / sf); + //t_sum_xy /= 1000000.0; + double t_avgx = t_sum_x / this->samples_count (); + double t_avgy = t_sum_y / this->samples_count (); + + double t_a = + (this->samples_count () * t_sum_xy - t_sum_x * t_sum_y) + / (this->samples_count () * t_sum_x2 - t_sum_x * t_sum_x); + double t_b = (t_avgy - t_a * t_avgx); + + t_a *= 1000000.0; + + double d_r = + (t_sum_xy - t_avgx * t_sum_y - t_avgy * t_sum_x + + this->samples_count () * t_avgx * t_avgy); + double n_r = + (t_sum_x2 + - this->samples_count () * t_avgx * t_avgx) + * (t_sum_y2 + - this->samples_count () * t_avgy * t_avgy); + double t_r = d_r * d_r / n_r; + + // ACE_DEBUG ((LM_DEBUG, + // "%s throughput: %.2f/%.2f/%.2f/%.6f/%.2f (avg/a/b/r/elapsed)\n", + // msg, t_avg, t_a, t_b, t_r, seconds)); + // ACE_DEBUG ((LM_DEBUG, + // "%s data: %.2f/%.2f/%.2f/%.6f/%.2f (x/x2/y/y2/xy)\n", + // msg, t_sum_x, t_sum_x2, t_sum_y, t_sum_y2, t_sum_xy)); +#endif +} + +void +ACE_Throughput_Stats::dump_throughput (const ACE_TCHAR *msg, + ACE_UINT32 sf, + ACE_UINT64 elapsed_time, + ACE_UINT32 samples_count) +{ +#ifndef ACE_NLOGGING + double seconds = +# if defined ACE_LACKS_LONGLONG_T + elapsed_time / sf; +#elif defined (ACE_LACKS_UNSIGNEDLONGLONG_T) + static_cast (ACE_UINT64_DBLCAST_ADAPTER ( + ACE_U_LongLong(elapsed_time / sf))); +# else /* ! ACE_LACKS_LONGLONG_T */ + static_cast (ACE_UINT64_DBLCAST_ADAPTER (elapsed_time / sf)); +# endif /* ! ACE_LACKS_LONGLONG_T */ + seconds /= ACE_HR_SCALE_CONVERSION; + + const double t_avg = samples_count / seconds; + + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("%s throughput: %.2f (events/second)\n"), + msg, t_avg)); +#else + ACE_UNUSED_ARG (msg); + ACE_UNUSED_ARG (sf); + ACE_UNUSED_ARG (elapsed_time); + ACE_UNUSED_ARG (samples_count); +#endif /* ACE_NLOGGING */ +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Throughput_Stats.h b/dep/ACE_wrappers/ace/Throughput_Stats.h new file mode 100644 index 00000000000..c306c856c5e --- /dev/null +++ b/dep/ACE_wrappers/ace/Throughput_Stats.h @@ -0,0 +1,86 @@ +// -*- C++ -*- + +//========================================================================== +/** + * @file Throughput_Stats.h + * + * $Id: Throughput_Stats.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author David L. Levine + */ +//========================================================================== + + +#ifndef ACE_THROUGHPUT_STATS_H +#define ACE_THROUGHPUT_STATS_H + +#include /**/ "ace/pre.h" + +#include /**/ "ace/ACE_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/Basic_Stats.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +/// A simple class to make throughput and latency analysis. +/** + * + * Keep the relevant information to perform throughput and latency + * analysis, including: + * -# Minimum, Average and Maximum latency + * -# Jitter for the latency + * -# Linear regression for throughput + * -# Accumulate results from several samples to obtain aggregated + * results, across several threads or experiments. + * + * @todo The idea behind this class was to use linear regression to + * determine if the throughput was linear or exhibited jitter. + * Unfortunately it never worked quite right, so only average + * throughput is computed. + */ +class ACE_Export ACE_Throughput_Stats : public ACE_Basic_Stats +{ +public: + /// Constructor + ACE_Throughput_Stats (void); + + /// Store one sample + void sample (ACE_UINT64 throughput, ACE_UINT64 latency); + + /// Update the values to reflect the stats in @a throughput + void accumulate (const ACE_Throughput_Stats &throughput); + + /// Print down the stats + void dump_results (const ACE_TCHAR* msg, ACE_UINT32 scale_factor); + + /// Dump the average throughput stats. + static void dump_throughput (const ACE_TCHAR *msg, + ACE_UINT32 scale_factor, + ACE_UINT64 elapsed_time, + ACE_UINT32 samples_count); +private: + /// The last throughput measurement. + ACE_UINT64 throughput_last_; + +#if 0 + /// These are the fields that we should keep to perform linear + /// regression + //@{ + ///@} + ACE_UINT64 throughput_sum_x_; + ACE_UINT64 throughput_sum_x2_; + ACE_UINT64 throughput_sum_y_; + ACE_UINT64 throughput_sum_y2_; + ACE_UINT64 throughput_sum_xy_; +#endif /* 0 */ +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#include /**/ "ace/post.h" + +#endif /* ! ACE_THROUGHPUT_STATS_H */ diff --git a/dep/ACE_wrappers/ace/Time_Value.cpp b/dep/ACE_wrappers/ace/Time_Value.cpp new file mode 100644 index 00000000000..8ecfbe7d3b4 --- /dev/null +++ b/dep/ACE_wrappers/ace/Time_Value.cpp @@ -0,0 +1,264 @@ +#include "ace/Time_Value.h" + +ACE_RCSID (ace, + Time_Value, + "$Id: Time_Value.cpp 80826 2008-03-04 14:51:23Z wotte $") + + +#if !defined (__ACE_INLINE__) +#include "ace/Time_Value.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/Numeric_Limits.h" +#include "ace/If_Then_Else.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +// Static constant representing `zero-time'. +// Note: this object requires static construction. +const ACE_Time_Value ACE_Time_Value::zero; + +// Constant for maximum time representable. Note that this time +// is not intended for use with select () or other calls that may +// have *their own* implementation-specific maximum time representations. +// Its primary use is in time computations such as those used by the +// dynamic subpriority strategies in the ACE_Dynamic_Message_Queue class. +// Note: this object requires static construction. +const ACE_Time_Value ACE_Time_Value::max_time ( + ACE_Numeric_Limits::max (), + ACE_ONE_SECOND_IN_USECS - 1); + +ACE_ALLOC_HOOK_DEFINE (ACE_Time_Value) + +// Increment microseconds (the only reason this is here is to allow +// the use of ACE_Atomic_Op with ACE_Time_Value). + +ACE_Time_Value +ACE_Time_Value::operator ++ (int) +{ + // ACE_OS_TRACE ("ACE_Time_Value::operator ++ (int)"); + ACE_Time_Value tv (*this); + ++*this; + return tv; +} + +ACE_Time_Value & +ACE_Time_Value::operator ++ (void) +{ + // ACE_OS_TRACE ("ACE_Time_Value::operator ++ (void)"); + this->usec (this->usec () + 1); + this->normalize (); + return *this; +} + +// Decrement microseconds (the only reason this is here is / to allow +// the use of ACE_Atomic_Op with ACE_Time_Value). + +ACE_Time_Value +ACE_Time_Value::operator -- (int) +{ + // ACE_OS_TRACE ("ACE_Time_Value::operator -- (int)"); + ACE_Time_Value tv (*this); + --*this; + return tv; +} + +ACE_Time_Value & +ACE_Time_Value::operator -- (void) +{ + // ACE_OS_TRACE ("ACE_Time_Value::operator -- (void)"); + this->usec (this->usec () - 1); + this->normalize (); + return *this; +} + +#if defined (ACE_WIN32) +// Static constant to remove time skew between FILETIME and POSIX +// time. POSIX and Win32 use different epochs (Jan. 1, 1970 v.s. +// Jan. 1, 1601). The following constant defines the difference +// in 100ns ticks. +// +// In the beginning (Jan. 1, 1601), there was no time and no computer. +// And Bill said: "Let there be time," and there was time.... +# if defined (ACE_LACKS_LONGLONG_T) +const ACE_U_LongLong ACE_Time_Value::FILETIME_to_timval_skew = +ACE_U_LongLong (0xd53e8000, 0x19db1de); +# else +const DWORDLONG ACE_Time_Value::FILETIME_to_timval_skew = +ACE_INT64_LITERAL (0x19db1ded53e8000); +# endif + +// Initializes the ACE_Time_Value object from a Win32 FILETIME + +ACE_Time_Value::ACE_Time_Value (const FILETIME &file_time) +{ + // // ACE_OS_TRACE ("ACE_Time_Value::ACE_Time_Value"); + this->set (file_time); +} + +void ACE_Time_Value::set (const FILETIME &file_time) +{ + // Initializes the ACE_Time_Value object from a Win32 FILETIME +#if defined (ACE_LACKS_LONGLONG_T) + ACE_U_LongLong LL_100ns(file_time.dwLowDateTime, file_time.dwHighDateTime); + LL_100ns -= ACE_Time_Value::FILETIME_to_timval_skew; + // Convert 100ns units to seconds; + this->tv_.tv_sec = (long) (LL_100ns / ((double) (10000 * 1000))); + // Convert remainder to microseconds; + this->tv_.tv_usec = (suseconds_t)((LL_100ns % ((ACE_UINT32)(10000 * 1000))) / 10); +#else + // Don't use a struct initializer, gcc don't like it. + ULARGE_INTEGER _100ns; + _100ns.LowPart = file_time.dwLowDateTime; + _100ns.HighPart = file_time.dwHighDateTime; + + _100ns.QuadPart -= ACE_Time_Value::FILETIME_to_timval_skew; + + // Convert 100ns units to seconds; + this->tv_.tv_sec = (long) (_100ns.QuadPart / (10000 * 1000)); + // Convert remainder to microseconds; + this->tv_.tv_usec = (suseconds_t) ((_100ns.QuadPart % (10000 * 1000)) / 10); +#endif // ACE_LACKS_LONGLONG_T + this->normalize (); +} + +// Returns the value of the object as a Win32 FILETIME. + +ACE_Time_Value::operator FILETIME () const +{ + FILETIME file_time; + // ACE_OS_TRACE ("ACE_Time_Value::operator FILETIME"); + +#if defined (ACE_LACKS_LONGLONG_T) + ACE_U_LongLong LL_sec(this->tv_.tv_sec); + ACE_U_LongLong LL_usec(this->tv_.tv_usec); + ACE_U_LongLong LL_100ns = LL_sec * (ACE_UINT32)(10000 * 1000) + + LL_usec * (ACE_UINT32)10 + + ACE_Time_Value::FILETIME_to_timval_skew; + file_time.dwLowDateTime = LL_100ns.lo(); + file_time.dwHighDateTime = LL_100ns.hi(); +#else + ULARGE_INTEGER _100ns; + _100ns.QuadPart = (((DWORDLONG) this->tv_.tv_sec * (10000 * 1000) + + this->tv_.tv_usec * 10) + + ACE_Time_Value::FILETIME_to_timval_skew); + + file_time.dwLowDateTime = _100ns.LowPart; + file_time.dwHighDateTime = _100ns.HighPart; +#endif //ACE_LACKS_LONGLONG_T + + return file_time; +} + +#endif /* ACE_WIN32 */ + +void +ACE_Time_Value::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + // ACE_OS_TRACE ("ACE_Time_Value::dump"); +#if 0 + ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\ntv_sec_ = %d"), this->tv_.tv_sec)); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\ntv_usec_ = %d\n"), this->tv_.tv_usec)); + ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); +#endif /* 0 */ +#endif /* ACE_HAS_DUMP */ +} + +void +ACE_Time_Value::normalize (void) +{ + // // ACE_OS_TRACE ("ACE_Time_Value::normalize"); + // From Hans Rohnert... + + if (this->tv_.tv_usec >= ACE_ONE_SECOND_IN_USECS) + { + /*! \todo This loop needs some optimization. + */ + do + { + ++this->tv_.tv_sec; + this->tv_.tv_usec -= ACE_ONE_SECOND_IN_USECS; + } + while (this->tv_.tv_usec >= ACE_ONE_SECOND_IN_USECS); + } + else if (this->tv_.tv_usec <= -ACE_ONE_SECOND_IN_USECS) + { + /*! \todo This loop needs some optimization. + */ + do + { + --this->tv_.tv_sec; + this->tv_.tv_usec += ACE_ONE_SECOND_IN_USECS; + } + while (this->tv_.tv_usec <= -ACE_ONE_SECOND_IN_USECS); + } + + if (this->tv_.tv_sec >= 1 && this->tv_.tv_usec < 0) + { + --this->tv_.tv_sec; + this->tv_.tv_usec += ACE_ONE_SECOND_IN_USECS; + } +// tv_sec in qnxnto is unsigned +#if !defined ( __QNXNTO__) + else if (this->tv_.tv_sec < 0 && this->tv_.tv_usec > 0) + { + ++this->tv_.tv_sec; + this->tv_.tv_usec -= ACE_ONE_SECOND_IN_USECS; + } +#endif /* __QNXNTO__ */ +} + + +ACE_Time_Value & +ACE_Time_Value::operator *= (double d) +{ + // The floating type to be used in the computations. It should be + // large enough to hold a time_t. We actually want a floating type + // with enough digits in its mantissa to hold a time_t without + // losing precision. For example, if FLT_RADIX is 2 and + // LDBL_MANT_DIG is 64, a long double has a 64 bit wide mantissa, + // which would be sufficient to hold a 64 bit time_t value without + // losing precision. + // + // For now we'll simply go with long double if it is larger than + // time_t. We're hosed if long double isn't large enough. + typedef ACE::If_Then_Else<(sizeof (double) > sizeof (time_t)), + double, + long double>::result_type float_type; + + float_type time_total = + (this->sec () + + static_cast (this->usec ()) / ACE_ONE_SECOND_IN_USECS) * d; + + // shall we saturate the result? + static const float_type max_int = + ACE_Numeric_Limits::max () + 0.999999; + static const float_type min_int = + ACE_Numeric_Limits::min () - 0.999999; + + if (time_total > max_int) + time_total = max_int; + if (time_total < min_int) + time_total = min_int; + + const time_t time_sec = static_cast (time_total); + + time_total -= time_sec; + time_total *= ACE_ONE_SECOND_IN_USECS; + + suseconds_t time_usec = static_cast (time_total); + + // round up the result to save the last usec + if (time_usec > 0 && (time_total - time_usec) >= 0.5) + ++time_usec; + else if (time_usec < 0 && (time_total - time_usec) <= -0.5) + --time_usec; + + this->set (time_sec, time_usec); + + return *this; +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Time_Value.h b/dep/ACE_wrappers/ace/Time_Value.h new file mode 100644 index 00000000000..b00410e2b33 --- /dev/null +++ b/dep/ACE_wrappers/ace/Time_Value.h @@ -0,0 +1,380 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Time_Value.h + * + * $Id: Time_Value.h 81914 2008-06-11 13:56:11Z sma $ + * + * @author Douglas C. Schmidt + */ +//============================================================================= + +#ifndef ACE_TIME_VALUE_H +#define ACE_TIME_VALUE_H + +#include /**/ "ace/pre.h" + +#include /**/ "ace/ACE_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +# include "ace/os_include/os_time.h" + +// Define some helpful constants. +// Not type-safe, and signed. For backward compatibility. +#define ACE_ONE_SECOND_IN_MSECS 1000L +suseconds_t const ACE_ONE_SECOND_IN_USECS = 1000000; +#define ACE_ONE_SECOND_IN_NSECS 1000000000L + +// needed for ACE_UINT64 +#include "ace/Basic_Types.h" + +// This forward declaration is needed by the set() and FILETIME() functions +#if defined (ACE_LACKS_LONGLONG_T) +ACE_BEGIN_VERSIONED_NAMESPACE_DECL +class ACE_Export ACE_U_LongLong; +ACE_END_VERSIONED_NAMESPACE_DECL +#endif /* ACE_LACKS_LONGLONG_T */ + +// ------------------------------------------------------------------- + +/** + * @class ACE_Time_Value + * + * @brief Operations on "timeval" structures, which express time in + * seconds (secs) and microseconds (usecs). + * + * This class centralizes all the time related processing in + * ACE. These time values are typically used in conjunction with OS + * mechanisms like or other calls that may have + * *their own* implementation-specific maximum time representations. + * Its primary use is in time computations such as those used by the + * dynamic subpriority strategies in the ACE_Dynamic_Message_Queue + * class. + */ + static const ACE_Time_Value max_time; + + // = Initialization methods. + + /// Default Constructor. + ACE_Time_Value (void); + + /// Constructor. + explicit ACE_Time_Value (time_t sec, suseconds_t usec = 0); + + // = Methods for converting to/from various time formats. + + /// Construct the ACE_Time_Value from a timeval. + explicit ACE_Time_Value (const struct timeval &t); + + /// Construct the ACE_Time_Value object from a timespec_t. + explicit ACE_Time_Value (const timespec_t &t); + +# if defined (ACE_WIN32) + /// Construct the ACE_Time_Value object from a Win32 FILETIME + explicit ACE_Time_Value (const FILETIME &ft); +# endif /* ACE_WIN32 */ + + /// Initializes the ACE_Time_Value from seconds and useconds. + void set (time_t sec, suseconds_t usec); + + /// Initializes the ACE_Time_Value from a double, which is assumed to be + /// in second format, with any remainder treated as microseconds. + void set (double d); + + /// Initializes the ACE_Time_Value from a timeval. + void set (const timeval &t); + + /// Initializes the ACE_Time_Value object from a timespec_t. + void set (const timespec_t &t); + +# if defined (ACE_WIN32) + /// Initializes the ACE_Time_Value object from a Win32 FILETIME. + void set (const FILETIME &ft); +# endif /* ACE_WIN32 */ + + /// Converts from ACE_Time_Value format into milliseconds format. + /** + * @return Sum of second field (in milliseconds) and microsecond field + * (in milliseconds). Note that this method can overflow if + * the second and microsecond field values are large, so use + * the msec (ACE_UINT64 &ms) method instead. + * + * @note The semantics of this method differs from the sec() and + * usec() methods. There is no analogous "millisecond" + * component in an ACE_Time_Value. + */ + unsigned long msec (void) const; + + /// Converts from ACE_Time_Value format into milliseconds format. + /** + * @return Sum of second field (in milliseconds) and microsecond field + * (in milliseconds) and return them via the @param ms parameter. + * + * @note The semantics of this method differs from the sec() and + * usec() methods. There is no analogous "millisecond" + * component in an ACE_Time_Value. + */ + void msec (ACE_UINT64 &ms) const; + + /// Converts from ACE_Time_Value format into milliseconds format. + /** + * @return Sum of second field (in milliseconds) and microsecond field + * (in milliseconds) and return them via the @param ms parameter. + * + * @note The semantics of this method differs from the sec() and + * usec() methods. There is no analogous "millisecond" + * component in an ACE_Time_Value. + */ + void msec (ACE_UINT64 &ms) /* const */; + + /// Converts from milli-seconds format into ACE_Time_Value format. + /** + * @note The semantics of this method differs from the sec() and + * usec() methods. There is no analogous "millisecond" + * component in an ACE_Time_Value. + */ + void msec (long); + + /// Converts from milli-seconds format into ACE_Time_Value format. + /** + * @note The semantics of this method differs from the sec() and + * usec() methods. There is no analogous "millisecond" + * component in an ACE_Time_Value. + */ + void msec (int); // converted to long then calls above. + + /// Returns the value of the object as a timespec_t. + operator timespec_t () const; + + /// Returns the value of the object as a timeval. + operator timeval () const; + + /// Returns a pointer to the object as a timeval. + operator const timeval *() const; + +# if defined (ACE_WIN32) + /// Returns the value of the object as a Win32 FILETIME. + operator FILETIME () const; +# endif /* ACE_WIN32 */ + + // = The following are accessor/mutator methods. + + /// Get seconds. + /** + * @return The second field/component of this ACE_Time_Value. + * + * @note The semantics of this method differs from the msec() + * method. + */ + time_t sec (void) const; + + /// Set seconds. + void sec (time_t sec); + + /// Get microseconds. + /** + * @return The microsecond field/component of this ACE_Time_Value. + * + * @note The semantics of this method differs from the msec() + * method. + */ + suseconds_t usec (void) const; + + /// Set microseconds. + void usec (suseconds_t usec); + + /** + * @return Sum of second field (in microseconds) and microsecond field + * and return them via the @param usec parameter. + */ + void to_usec (ACE_UINT64 &usec) const; + + // = The following arithmetic methods operate on ACE_Time_Value's. + + /// Add @a tv to this. + ACE_Time_Value &operator += (const ACE_Time_Value &tv); + + /// Add @a tv to this. + ACE_Time_Value &operator += (time_t tv); + + /// Assign @ tv to this + ACE_Time_Value &operator = (const ACE_Time_Value &tv); + + /// Assign @ tv to this + ACE_Time_Value &operator = (time_t tv); + + /// Subtract @a tv to this. + ACE_Time_Value &operator -= (const ACE_Time_Value &tv); + + /// Substract @a tv to this. + ACE_Time_Value &operator -= (time_t tv); + + /** + \brief Multiply the time value by the @a d factor. + \note The result of the operator is valid for results from range + < (ACE_INT32_MIN, -999999), (ACE_INT32_MAX, 999999) >. Result + outside this range are saturated to a limit. + */ + ACE_Time_Value &operator *= (double d); + + /// Increment microseconds as postfix. + /** + * @note The only reason this is here is to allow the use of ACE_Atomic_Op + * with ACE_Time_Value. + */ + ACE_Time_Value operator++ (int); + + /// Increment microseconds as prefix. + /** + * @note The only reason this is here is to allow the use of ACE_Atomic_Op + * with ACE_Time_Value. + */ + ACE_Time_Value &operator++ (void); + + /// Decrement microseconds as postfix. + /** + * @note The only reason this is here is to allow the use of ACE_Atomic_Op + * with ACE_Time_Value. + */ + ACE_Time_Value operator-- (int); + + /// Decrement microseconds as prefix. + /** + * @note The only reason this is here is to allow the use of ACE_Atomic_Op + * with ACE_Time_Value. + */ + ACE_Time_Value &operator-- (void); + + /// Adds two ACE_Time_Value objects together, returns the sum. + friend ACE_Export ACE_Time_Value operator + (const ACE_Time_Value &tv1, + const ACE_Time_Value &tv2); + + /// Subtracts two ACE_Time_Value objects, returns the difference. + friend ACE_Export ACE_Time_Value operator - (const ACE_Time_Value &tv1, + const ACE_Time_Value &tv2); + + /// True if @a tv1 < @a tv2. + friend ACE_Export bool operator < (const ACE_Time_Value &tv1, + const ACE_Time_Value &tv2); + + /// True if @a tv1 > @a tv2. + friend ACE_Export bool operator > (const ACE_Time_Value &tv1, + const ACE_Time_Value &tv2); + + /// True if @a tv1 <= @a tv2. + friend ACE_Export bool operator <= (const ACE_Time_Value &tv1, + const ACE_Time_Value &tv2); + + /// True if @a tv1 >= @a tv2. + friend ACE_Export bool operator >= (const ACE_Time_Value &tv1, + const ACE_Time_Value &tv2); + + /// True if @a tv1 == @a tv2. + friend ACE_Export bool operator == (const ACE_Time_Value &tv1, + const ACE_Time_Value &tv2); + + /// True if @a tv1 != @a tv2. + friend ACE_Export bool operator != (const ACE_Time_Value &tv1, + const ACE_Time_Value &tv2); + + //@{ + /// Multiplies the time value by @a d + friend ACE_Export ACE_Time_Value operator * (double d, + const ACE_Time_Value &tv); + + friend ACE_Export ACE_Time_Value operator * (const ACE_Time_Value &tv, + double d); + //@} + + /// Dump is a no-op. + /** + * The dump() method is a no-op. It's here for backwards compatibility + * only, but does not dump anything. Invoking logging methods here + * violates layering restrictions in ACE because this class is part + * of the OS layer and @c ACE_Log_Msg is at a higher level. + */ + void dump (void) const; + +# if defined (ACE_WIN32) + /// Const time difference between FILETIME and POSIX time. +# if defined (ACE_LACKS_LONGLONG_T) + static const ACE_U_LongLong FILETIME_to_timval_skew; +# else + static const DWORDLONG FILETIME_to_timval_skew; +# endif // ACE_LACKS_LONGLONG_T +# endif /* ACE_WIN32 */ + +private: + /// Put the timevalue into a canonical form. + void normalize (void); + + /// Store the values as a timeval. +#if defined (ACE_HAS_TIME_T_LONG_MISMATCH) + // Windows' timeval is non-conformant, so swap in a struct that conforms + // to the proper data types to represent the entire time range that this + // class's API can accept. + // Also, since this class can supply a pointer to a timeval that things + // like select() expect, we need the OS-defined one as well. To make this + // available, use a real timeval called ext_tv_ and set it up when needed. + // Since this is most often for relative times that don't approach 32 bits + // in size, reducing a time_t to fit should be no problem. + struct { + time_t tv_sec; + suseconds_t tv_usec; + } tv_; + timeval ext_tv_; +#else + timeval tv_; +#endif /* ACE_HAS_TIME_T_LONG_MISMATCH */ +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +#include "ace/Time_Value.inl" +#endif /* __ACE_INLINE__ */ + +#if defined (ACE_WIN32) && defined (_WIN32_WCE) +} +#endif + +#if defined (__MINGW32__) +ACE_BEGIN_VERSIONED_NAMESPACE_DECL +// The MingW linker has problems with the exported statics +// zero and max_time with these two statics the linker will be able to +// resolve the static exported symbols. +static const ACE_Time_Value& __zero_time = ACE_Time_Value::zero; +static const ACE_Time_Value& __max_time = ACE_Time_Value::max_time; +ACE_END_VERSIONED_NAMESPACE_DECL +#endif /* __MINGW32__ */ + +#include /**/ "ace/post.h" + +#endif /* ACE_TIME_VALUE_H */ diff --git a/dep/ACE_wrappers/ace/Time_Value.inl b/dep/ACE_wrappers/ace/Time_Value.inl new file mode 100644 index 00000000000..27433389323 --- /dev/null +++ b/dep/ACE_wrappers/ace/Time_Value.inl @@ -0,0 +1,422 @@ +// -*- C++ -*- +// +// $Id: Time_Value.inl 82610 2008-08-12 19:46:36Z parsons $ + +#include "ace/Truncate.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +#if defined (ACE_WIN32) && defined (_WIN32_WCE) +// Something is a bit brain-damaged here and I'm not sure what... this code +// compiled before the OS reorg for ACE 5.4. Since then it hasn't - eVC +// complains that the operators that return ACE_Time_Value are C-linkage +// functions that can't return a C++ class. The only way I've found to +// defeat this is to wrap the whole class in extern "C++". +// - Steve Huston, 23-Aug-2004 +extern "C++" { +#endif + +// Returns the value of the object as a timeval. + +ACE_INLINE +ACE_Time_Value::operator timeval () const +{ + // ACE_OS_TRACE ("ACE_Time_Value::operator timeval"); +#if defined (ACE_HAS_TIME_T_LONG_MISMATCH) + // Recall that on some Windows we substitute another type for timeval in tv_ + ACE_Time_Value *me = const_cast (this); + me->ext_tv_.tv_sec = ACE_Utils::truncate_cast (this->tv_.tv_sec); + me->ext_tv_.tv_usec = ACE_Utils::truncate_cast (this->tv_.tv_usec); + return this->ext_tv_; +#else + return this->tv_; +#endif /* ACE_HAS_TIME_T_LONG_MISMATCH */ +} + +ACE_INLINE void +ACE_Time_Value::set (const timeval &tv) +{ + // ACE_OS_TRACE ("ACE_Time_Value::set"); + this->tv_.tv_sec = tv.tv_sec; + this->tv_.tv_usec = tv.tv_usec; + + this->normalize (); +} + +ACE_INLINE +ACE_Time_Value::ACE_Time_Value (const struct timeval &tv) +{ + // ACE_OS_TRACE ("ACE_Time_Value::ACE_Time_Value"); + this->set (tv); +} + +ACE_INLINE +ACE_Time_Value::operator const timeval * () const +{ + // ACE_OS_TRACE ("ACE_Time_Value::operator const timeval *"); +#if defined (ACE_HAS_TIME_T_LONG_MISMATCH) + // Recall that on some Windows we substitute another type for timeval in tv_ + ACE_Time_Value *me = const_cast (this); + me->ext_tv_.tv_sec = ACE_Utils::truncate_cast (this->tv_.tv_sec); + me->ext_tv_.tv_usec = ACE_Utils::truncate_cast (this->tv_.tv_usec); + return (const timeval *) &this->ext_tv_; +#else + return (const timeval *) &this->tv_; +#endif /* ACE_HAS_TIME_T_LONG_MISMATCH */ +} + +ACE_INLINE void +ACE_Time_Value::set (time_t sec, suseconds_t usec) +{ + // ACE_OS_TRACE ("ACE_Time_Value::set"); + this->tv_.tv_sec = sec; + this->tv_.tv_usec = usec; +#if __GNUC__ + if (__builtin_constant_p(sec) && + __builtin_constant_p(usec) && + (sec >= 0 && usec >= 0 && usec < ACE_ONE_SECOND_IN_USECS)) + return; +#endif + this->normalize (); +} + +ACE_INLINE void +ACE_Time_Value::set (double d) +{ + // ACE_OS_TRACE ("ACE_Time_Value::set"); + long l = (long) d; + this->tv_.tv_sec = l; + this->tv_.tv_usec = (suseconds_t) ((d - (double) l) * ACE_ONE_SECOND_IN_USECS + .5); + this->normalize (); +} + +// Initializes a timespec_t. Note that this approach loses precision +// since it converts the nano-seconds into micro-seconds. But then +// again, do any real systems have nano-second timer precision?! + +ACE_INLINE void +ACE_Time_Value::set (const timespec_t &tv) +{ + // ACE_OS_TRACE ("ACE_Time_Value::set"); + + this->set (tv.tv_sec, + tv.tv_nsec / 1000); // Convert nanoseconds into microseconds. +} + +ACE_INLINE +ACE_Time_Value::ACE_Time_Value (void) + // : tv_ () +{ + // ACE_OS_TRACE ("ACE_Time_Value::ACE_Time_Value"); + this->set (0, 0); +} + +ACE_INLINE +ACE_Time_Value::ACE_Time_Value (time_t sec, suseconds_t usec) +{ + // ACE_OS_TRACE ("ACE_Time_Value::ACE_Time_Value"); + this->set (sec, usec); +} + +// Returns number of seconds. + +ACE_INLINE time_t +ACE_Time_Value::sec (void) const +{ + // ACE_OS_TRACE ("ACE_Time_Value::sec"); + return this->tv_.tv_sec; +} + +// Sets the number of seconds. + +ACE_INLINE void +ACE_Time_Value::sec (time_t sec) +{ + // ACE_OS_TRACE ("ACE_Time_Value::sec"); + this->tv_.tv_sec = ACE_Utils::truncate_cast (sec); +} + +// Converts from Time_Value format into milli-seconds format. + +ACE_INLINE unsigned long +ACE_Time_Value::msec (void) const +{ + // ACE_OS_TRACE ("ACE_Time_Value::msec"); + + // Note - we're truncating a value here, which can lose data. This is + // called out in the user documentation for this with a recommendation to + // use msec(ACE_UINT64&) instead, so just go ahead and truncate. + time_t secs = this->tv_.tv_sec * 1000 + this->tv_.tv_usec / 1000; + return ACE_Utils::truncate_cast (secs); +} + +ACE_INLINE void +ACE_Time_Value::msec (ACE_UINT64 &ms) const +{ + // ACE_OS_TRACE ("ACE_Time_Value::msec"); + ms = ACE_Utils::truncate_cast (this->tv_.tv_sec); + ms *= 1000; + ms += (this->tv_.tv_usec / 1000); +} + +ACE_INLINE void +ACE_Time_Value::msec (ACE_UINT64 &ms) /*const*/ +{ + // ACE_OS_TRACE ("ACE_Time_Value::msec"); + const ACE_Time_Value *tv = this; + tv->msec (ms); +} + +// Converts from milli-seconds format into Time_Value format. + +ACE_INLINE void +ACE_Time_Value::msec (long milliseconds) +{ + // ACE_OS_TRACE ("ACE_Time_Value::msec"); + // Convert millisecond units to seconds; + long secs = milliseconds / 1000; + this->tv_.tv_sec = secs; + // Convert remainder to microseconds; + this->tv_.tv_usec = (milliseconds - (secs * 1000)) * 1000; +} + +// Converts from milli-seconds format into Time_Value format. + +ACE_INLINE void +ACE_Time_Value::msec (int milliseconds) +{ + ACE_Time_Value::msec (static_cast (milliseconds)); +} + +// Returns number of micro-seconds. + +ACE_INLINE suseconds_t +ACE_Time_Value::usec (void) const +{ + // ACE_OS_TRACE ("ACE_Time_Value::usec"); + return this->tv_.tv_usec; +} + +// Sets the number of micro-seconds. + +ACE_INLINE void +ACE_Time_Value::usec (suseconds_t usec) +{ + // ACE_OS_TRACE ("ACE_Time_Value::usec"); + this->tv_.tv_usec = usec; +} + +ACE_INLINE void +ACE_Time_Value::to_usec (ACE_UINT64 & usec) const +{ + // ACE_OS_TRACE ("ACE_Time_Value::to_usec"); + +#if defined (ACE_LACKS_UNSIGNEDLONGLONG_T) + usec = ACE_U_LongLong (static_cast (this->tv_.tv_sec)); +#elif defined (ACE_LACKS_LONGLONG_T) + // No native 64-bit type, meaning time_t is most likely 32 bits. + usec = ACE_U_LongLong (this->tv_.tv_sec); +#else + usec = static_cast (this->tv_.tv_sec); +#endif /* ACE_LACKS_LONG_LONG_T */ + usec *= 1000000; + usec += this->tv_.tv_usec; +} + +ACE_INLINE ACE_Time_Value +operator * (double d, const ACE_Time_Value &tv) +{ + return ACE_Time_Value (tv) *= d; +} + +ACE_INLINE ACE_Time_Value +operator * (const ACE_Time_Value &tv, double d) +{ + return ACE_Time_Value (tv) *= d; +} + +// True if tv1 > tv2. + +ACE_INLINE bool +operator > (const ACE_Time_Value &tv1, + const ACE_Time_Value &tv2) +{ + // ACE_OS_TRACE ("operator >"); + if (tv1.sec () > tv2.sec ()) + return 1; + else if (tv1.sec () == tv2.sec () + && tv1.usec () > tv2.usec ()) + return 1; + else + return 0; +} + +// True if tv1 >= tv2. + +ACE_INLINE bool +operator >= (const ACE_Time_Value &tv1, + const ACE_Time_Value &tv2) +{ + // ACE_OS_TRACE ("operator >="); + if (tv1.sec () > tv2.sec ()) + return 1; + else if (tv1.sec () == tv2.sec () + && tv1.usec () >= tv2.usec ()) + return 1; + else + return 0; +} + +// Returns the value of the object as a timespec_t. + +ACE_INLINE +ACE_Time_Value::operator timespec_t () const +{ + // ACE_OS_TRACE ("ACE_Time_Value::operator timespec_t"); + timespec_t tv; + tv.tv_sec = this->sec (); + // Convert microseconds into nanoseconds. + tv.tv_nsec = this->tv_.tv_usec * 1000; + return tv; +} + +// Initializes the ACE_Time_Value object from a timespec_t. + +ACE_INLINE +ACE_Time_Value::ACE_Time_Value (const timespec_t &tv) + // : tv_ () +{ + // ACE_OS_TRACE ("ACE_Time_Value::ACE_Time_Value"); + this->set (tv); +} + +// True if tv1 < tv2. + +ACE_INLINE bool +operator < (const ACE_Time_Value &tv1, + const ACE_Time_Value &tv2) +{ + // ACE_OS_TRACE ("operator <"); + return tv2 > tv1; +} + +// True if tv1 >= tv2. + +ACE_INLINE bool +operator <= (const ACE_Time_Value &tv1, + const ACE_Time_Value &tv2) +{ + // ACE_OS_TRACE ("operator <="); + return tv2 >= tv1; +} + +// True if tv1 == tv2. + +ACE_INLINE bool +operator == (const ACE_Time_Value &tv1, + const ACE_Time_Value &tv2) +{ + // ACE_OS_TRACE ("operator =="); + return tv1.sec () == tv2.sec () + && tv1.usec () == tv2.usec (); +} + +// True if tv1 != tv2. + +ACE_INLINE bool +operator != (const ACE_Time_Value &tv1, + const ACE_Time_Value &tv2) +{ + // ACE_OS_TRACE ("operator !="); + return !(tv1 == tv2); +} + +// Add TV to this. + +ACE_INLINE ACE_Time_Value & +ACE_Time_Value::operator+= (const ACE_Time_Value &tv) +{ + // ACE_OS_TRACE ("ACE_Time_Value::operator+="); + this->sec (this->sec () + tv.sec ()); + this->usec (this->usec () + tv.usec ()); + this->normalize (); + return *this; +} + +ACE_INLINE ACE_Time_Value & +ACE_Time_Value::operator+= (time_t tv) +{ + // ACE_OS_TRACE ("ACE_Time_Value::operator+="); + this->sec (this->sec () + tv); + return *this; +} + +ACE_INLINE ACE_Time_Value & +ACE_Time_Value::operator= (const ACE_Time_Value &tv) +{ + // ACE_OS_TRACE ("ACE_Time_Value::operator="); + this->sec (tv.sec ()); + this->usec (tv.usec ()); + return *this; +} + +ACE_INLINE ACE_Time_Value & +ACE_Time_Value::operator= (time_t tv) +{ + // ACE_OS_TRACE ("ACE_Time_Value::operator="); + this->sec (tv); + this->usec (0); + return *this; +} + +// Subtract TV to this. + +ACE_INLINE ACE_Time_Value & +ACE_Time_Value::operator-= (const ACE_Time_Value &tv) +{ + // ACE_OS_TRACE ("ACE_Time_Value::operator-="); + this->sec (this->sec () - tv.sec ()); + this->usec (this->usec () - tv.usec ()); + this->normalize (); + return *this; +} + +ACE_INLINE ACE_Time_Value & +ACE_Time_Value::operator-= (time_t tv) +{ + // ACE_OS_TRACE ("ACE_Time_Value::operator-="); + this->sec (this->sec () - tv); + return *this; +} + +// Adds two ACE_Time_Value objects together, returns the sum. + +ACE_INLINE ACE_Time_Value +operator + (const ACE_Time_Value &tv1, + const ACE_Time_Value &tv2) +{ + // ACE_OS_TRACE ("operator +"); + ACE_Time_Value sum (tv1); + sum += tv2; + + return sum; +} + +// Subtracts two ACE_Time_Value objects, returns the difference. + +ACE_INLINE ACE_Time_Value +operator - (const ACE_Time_Value &tv1, + const ACE_Time_Value &tv2) +{ + // ACE_OS_TRACE ("operator -"); + ACE_Time_Value delta (tv1); + delta -= tv2; + + return delta; +} + +#if defined (ACE_WIN32) && defined (_WIN32_WCE) +} +#endif + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Timeprobe.cpp b/dep/ACE_wrappers/ace/Timeprobe.cpp new file mode 100644 index 00000000000..1fe8459ed8d --- /dev/null +++ b/dep/ACE_wrappers/ace/Timeprobe.cpp @@ -0,0 +1,15 @@ +// $Id: Timeprobe.cpp 80826 2008-03-04 14:51:23Z wotte $ + +#include "ace/config-all.h" + +ACE_RCSID(ace, Timeprobe, "$Id: Timeprobe.cpp 80826 2008-03-04 14:51:23Z wotte $") + +#if defined (ACE_COMPILE_TIMEPROBES) + +#include "ace/Timeprobe.h" + +#if !defined (__ACE_INLINE__) +#include "ace/Timeprobe.inl" +#endif /* __ACE_INLINE__ */ + +#endif /* ACE_COMPILE_TIMEPROBES */ diff --git a/dep/ACE_wrappers/ace/Timeprobe.h b/dep/ACE_wrappers/ace/Timeprobe.h new file mode 100644 index 00000000000..ac2abe38d0e --- /dev/null +++ b/dep/ACE_wrappers/ace/Timeprobe.h @@ -0,0 +1,201 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Timeprobe.h + * + * $Id: Timeprobe.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Irfan Pyarali + * + * If users want to use time probes, the ACE_COMPILE_TIMEPROBES + * flag must be defined when compiling ACE. This can be achieved + * by doing one of the following: + * + * . Use make probe = 1, if you are using the make utility. + * + * . Define ACE_COMPILE_TIMEPROBES in config.h + * + * . Define ACE_COMPILE_TIMEPROBES in the VC project file. + * + * . Other regular methods will also work. + * + * It is not necessary to define ACE_COMPILE_TIMEPROBES when using + * time probes, you simply need ACE_ENABLE_TIMEPROBES. You can use + * the ACE_TIMEPROBE_* macros to program the time probes, and use + * the ACE_ENABLE_TIMEPROBE to enable the time probes. If you + * define ACE_ENABLE_TIMEPROBE in your code, but forget to compile + * ACE with ACE_COMPILE_TIMEPROBES, you will end up with linker + * errors. + * + * Remember that ACE_COMPILE_TIMEPROBES means that the ACE library + * will contain code for time probes. This is only useful when + * compiling ACE. ACE_ENABLE_TIMEPROBES means that the + * ACE_TIMEPROBE_* macros should spring to life. + */ +//============================================================================= + +#ifndef ACE_TIMEPROBE_H +#define ACE_TIMEPROBE_H +#include /**/ "ace/pre.h" + +#include "ace/config-lite.h" +#include /**/ "ace/ACE_export.h" +#include "ace/Malloc_Allocator.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +/* Enable ACE Timeprobes */ +#if defined (ACE_ENABLE_TIMEPROBES) + #if !defined (ACE_COMPILE_TIMEPROBES) + #define ACE_COMPILE_TIMEPROBES + #endif /* ACE_COMPILE_TIMEPROBES */ +#endif /* ACE_ENABLE_TIMEPROBES */ + +#if defined (ACE_COMPILE_TIMEPROBES) + +#include "ace/OS_NS_time.h" +#include "ace/OS_NS_Thread.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +/** + * @class ACE_Event_Descriptions + * + * @brief Event Descriptions. + */ +class ACE_Export ACE_Event_Descriptions +{ +public: + /// Event descriptions + const char **descriptions_; + + /// Minimum id of this description set + u_long minimum_id_; + + /// Comparison + bool operator== (const ACE_Event_Descriptions &rhs) const; +}; + +/** + * @class ACE_timeprobe_t + * + * @brief Time probe record. + */ +class ACE_Export ACE_timeprobe_t +{ +public: + /// Events are record as strings or numbers. + union event + { + u_long event_number_; + const char *event_description_; + }; + + /// Type of event. + enum event_type + { + NUMBER, + STRING + }; + + /// Event. + event event_; + + /// Type of event. + event_type event_type_; + + /// Timestamp. + ACE_hrtime_t time_; + + /// Id of thread posting the time probe. + ACE_thread_t thread_; +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +#include "ace/Timeprobe.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/Synch_Traits.h" +#include "ace/Null_Mutex.h" +#include "ace/Singleton.h" +#include "ace/Timeprobe_T.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +// If ACE_MT_TIMEPROBES is defined, use a Thread_Mutex to lock the +// internal state of ACE_Timerprobe. This allows multiple threads to +// use the same ACE_Timerprobe. +# if defined (ACE_MT_TIMEPROBES) +typedef ACE_SYNCH_MUTEX ACE_TIMEPROBE_MUTEX; +# else /* ACE_MT_TIMEPROBES */ +typedef ACE_SYNCH_NULL_MUTEX ACE_TIMEPROBE_MUTEX; +# endif /* ACE_MT_TIMEPROBES */ + +typedef ACE_New_Allocator ACE_TIMEPROBE_ALLOCATOR; + +typedef ACE_Timeprobe_Ex + ACE_TIMEPROBE_WITH_LOCKING; + +// If ACE_TSS_TIMEPROBES is defined, store the ACE_Timeprobe singleton +// in thread specific storage. This allows multiple threads to use +// their own instance of ACE_Timerprobe, without interfering with each +// other. + +# if defined (ACE_TSS_TIMEPROBES) +# define ACE_TIMEPROBE_SINGLETON_TYPE ACE_TSS_Singleton +# define ACE_TIMEPROBE_SINGLETON_LOCK_TYPE ACE_SYNCH_NULL_MUTEX +# else /* ACE_TSS_TIMEPROBES */ +# define ACE_TIMEPROBE_SINGLETON_TYPE ACE_Singleton +# define ACE_TIMEPROBE_SINGLETON_LOCK_TYPE ACE_SYNCH_MUTEX +# endif /* ACE_TSS_TIMEPROBES */ + +ACE_SINGLETON_DECLARE (ACE_TIMEPROBE_SINGLETON_TYPE, \ + ACE_TIMEPROBE_WITH_LOCKING, \ + ACE_TIMEPROBE_SINGLETON_LOCK_TYPE) + +typedef ACE_TIMEPROBE_SINGLETON_TYPE + ACE_TIMEPROBE_SINGLETON; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#endif /* ACE_COMPILE_TIMEPROBES */ + +// If ACE_ENABLE_TIMEPROBES is defined, the macros below will +// work. Otherwise, they just vanish. Using this macro, you can +// control which files/libraries are probed. +#if defined (ACE_ENABLE_TIMEPROBES) && defined (ACE_COMPILE_TIMEPROBES) + +# define ACE_TIMEPROBE_RESET ACE_TIMEPROBE_SINGLETON::instance ()->reset () + +# define ACE_TIMEPROBE(id) ACE_TIMEPROBE_SINGLETON::instance ()->timeprobe (id) + +# define ACE_TIMEPROBE_PRINT ACE_TIMEPROBE_SINGLETON::instance ()->print_times () + +# define ACE_TIMEPROBE_PRINT_ABSOLUTE ACE_TIMEPROBE_SINGLETON::instance ()->print_absolute_times () + +# define ACE_TIMEPROBE_EVENT_DESCRIPTIONS(descriptions, minimum_id) \ +static int ace_timeprobe_##descriptions##_return = \ + ACE_TIMEPROBE_SINGLETON::instance ()->event_descriptions \ + (descriptions, minimum_id) + +# define ACE_FUNCTION_TIMEPROBE(X) \ + ACE_Function_Timeprobe function_timeprobe \ + (*ACE_TIMEPROBE_SINGLETON::instance (), X) + +#else /* ACE_ENABLE_TIMEPROBES && ACE_COMPILE_TIMEPROBES */ + +# define ACE_TIMEPROBE_RESET +# define ACE_TIMEPROBE(id) +# define ACE_TIMEPROBE_PRINT +# define ACE_TIMEPROBE_PRINT_ABSOLUTE +# define ACE_TIMEPROBE_EVENT_DESCRIPTIONS(descriptions, minimum_id) +# define ACE_FUNCTION_TIMEPROBE(X) + +#endif /* ACE_ENABLE_TIMEPROBES && ACE_COMPILE_TIMEPROBES */ +#include /**/ "ace/post.h" +#endif /* ACE_TIMEPROBE_H */ diff --git a/dep/ACE_wrappers/ace/Timeprobe.inl b/dep/ACE_wrappers/ace/Timeprobe.inl new file mode 100644 index 00000000000..aa7a9240648 --- /dev/null +++ b/dep/ACE_wrappers/ace/Timeprobe.inl @@ -0,0 +1,14 @@ +// -*- C++ -*- +// +// $Id: Timeprobe.inl 80826 2008-03-04 14:51:23Z wotte $ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_INLINE bool +ACE_Event_Descriptions::operator== (const ACE_Event_Descriptions &rhs) const +{ + return this->minimum_id_ == rhs.minimum_id_ && + this->descriptions_ == rhs.descriptions_; +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Timeprobe_T.cpp b/dep/ACE_wrappers/ace/Timeprobe_T.cpp new file mode 100644 index 00000000000..d23b7b8b869 --- /dev/null +++ b/dep/ACE_wrappers/ace/Timeprobe_T.cpp @@ -0,0 +1,427 @@ +// $Id: Timeprobe_T.cpp 80826 2008-03-04 14:51:23Z wotte $ + +#ifndef ACE_TIMEPROBE_T_CPP +#define ACE_TIMEPROBE_T_CPP + +#include "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#if defined (ACE_COMPILE_TIMEPROBES) + +#include "ace/Timeprobe.h" +#include "ace/High_Res_Timer.h" +#include "ace/OS_NS_string.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +template +ACE_Timeprobe_Ex::ACE_Timeprobe_Ex (u_long size) + : timeprobes_ (0), + lock_ (), + max_size_ (size), + current_size_ (0), + report_buffer_full_ (0), + allocator_ (0) +{ + ACE_timeprobe_t *temp; + //FUZZ: disable check_for_lack_ACE_OS + ACE_NEW_MALLOC_ARRAY (temp, + (ACE_timeprobe_t *) this->allocator ()-> + malloc (this->max_size_*sizeof(ACE_timeprobe_t)), + ACE_timeprobe_t, + this->max_size_); + //FUZZ: enable check_for_lack_ACE_OS + this->timeprobes_ = temp; + +} + +template +ACE_Timeprobe_Ex:: +ACE_Timeprobe_Ex (ALLOCATOR *allocator, + u_long size) + : timeprobes_ (0), + lock_ (), + max_size_ (size), + current_size_ (0), + report_buffer_full_ (0), + allocator_ (allocator) +{ + ACE_timeprobe_t *temp = 0; + //FUZZ: disable check_for_lack_ACE_OS + ACE_NEW_MALLOC_ARRAY (temp, + (ACE_timeprobe_t *) this->allocator ()-> + malloc (this->max_size_*sizeof(ACE_timeprobe_t)), + ACE_timeprobe_t, + this->max_size_); + //FUZZ: enable check_for_lack_ACE_OS + this->timeprobes_ = temp; + +} + +template +ACE_Timeprobe_Ex::ACE_Timeprobe_Ex (const ACE_Timeprobe_Ex &) +{ + // + // Stupid MSVC is forcing me to define this; please don't use it. + // + + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("ACE_NOTSUP: %N, line %l\n"))); + errno = ENOTSUP; +} + +template +ACE_Timeprobe_Ex::~ACE_Timeprobe_Ex (void) +{ + ACE_DES_ARRAY_FREE ((ACE_timeprobe_t *) (this->timeprobes_), + this->max_size_, + this->allocator ()->free, + ACE_timeprobe_t); +} + +template void +ACE_Timeprobe_Ex::timeprobe (u_long event) +{ + ACE_GUARD (ACE_LOCK, ace_mon, this->lock_); + + this->timeprobes_[this->current_size_].event_.event_number_ = event; + this->timeprobes_[this->current_size_].event_type_ = ACE_timeprobe_t::NUMBER; + this->timeprobes_[this->current_size_].time_ = ACE_OS::gethrtime (); + this->timeprobes_[this->current_size_].thread_ = ACE_OS::thr_self (); + + ++this->current_size_; + +#if !defined (ACE_TIMEPROBE_ASSERTS_FIXED_SIZE) + // wrap around to the beginning on overflow + if (this->current_size_ >= this->max_size_) + { + this->current_size_ = 0; + this->report_buffer_full_ = 1; + } +#endif /* ACE_TIMEPROBE_ASSERTS_FIXED_SIZE */ + + ACE_ASSERT (this->current_size_ < this->max_size_); +} + +template void +ACE_Timeprobe_Ex::timeprobe (const char *event) +{ + ACE_GUARD (ACE_LOCK, ace_mon, this->lock_); + + this->timeprobes_[this->current_size_].event_.event_description_ = event; + this->timeprobes_[this->current_size_].event_type_ = ACE_timeprobe_t::STRING; + this->timeprobes_[this->current_size_].time_ = ACE_OS::gethrtime (); + this->timeprobes_[this->current_size_].thread_ = ACE_OS::thr_self (); + + ++this->current_size_; + +#if !defined (ACE_TIMEPROBE_ASSERTS_FIXED_SIZE) + // wrap around to the beginning on overflow + if (this->current_size_ >= this->max_size_) + { + this->current_size_ = 0; + this->report_buffer_full_ = 1; + } +#endif /* ACE_TIMEPROBE_ASSERTS_FIXED_SIZE */ + + ACE_ASSERT (this->current_size_ < this->max_size_); +} + +template void +ACE_Timeprobe_Ex::reset (void) +{ + ACE_GUARD (ACE_LOCK, ace_mon, this->lock_); + + this->current_size_ = 0; + this->report_buffer_full_ = 0; +} + +template void +ACE_Timeprobe_Ex::increase_size (u_long size) +{ + ACE_GUARD (ACE_LOCK, ace_mon, this->lock_); + + if (size > this->max_size_) + { + ACE_timeprobe_t *temp = 0; + //FUZZ: disable check_for_lack_ACE_OS + ACE_NEW_MALLOC_ARRAY (temp, + (ACE_timeprobe_t *) this->allocator ()-> + malloc (this->max_size_ + * sizeof (ACE_timeprobe_t)), + ACE_timeprobe_t, + size); + //FUZZ: enable check_for_lack_ACE_OS + + if (this->max_size_ > 0) + { + ACE_OS::memcpy (temp, + this->timeprobes_, + this->max_size_ * sizeof (ACE_timeprobe_t)); + + // Iterates over the array explicitly calling the destructor for + // each probe instance, then deallocates the memory + + ACE_DES_ARRAY_FREE ((ACE_timeprobe_t *)(this->timeprobes_), + this->max_size_, + this->allocator ()->free, + ACE_timeprobe_t); + } + this->timeprobes_ = temp; + this->max_size_ = size; + } +} + +template ACE_Unbounded_Set & +ACE_Timeprobe_Ex::event_descriptions (void) +{ + return this->event_descriptions_; +} + +template ACE_Unbounded_Set & +ACE_Timeprobe_Ex::sorted_event_descriptions (void) +{ + return this->sorted_event_descriptions_; +} + +template ACE_timeprobe_t * +ACE_Timeprobe_Ex::timeprobes (void) +{ + return this->timeprobes_; +} + +template ACE_LOCK & +ACE_Timeprobe_Ex::lock (void) +{ + return this->lock_; +} + +template u_long +ACE_Timeprobe_Ex::max_size (void) +{ + return this->max_size_; +} + +template u_long +ACE_Timeprobe_Ex::current_size (void) +{ + return this->current_size_; +} + +template int +ACE_Timeprobe_Ex::event_descriptions (const char **descriptions, + u_long minimum_id) +{ + ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, -1); + + ACE_Event_Descriptions events; + events.descriptions_ = descriptions; + events.minimum_id_ = minimum_id; + + this->event_descriptions_.insert (events); + + return 0; +} + +template void +ACE_Timeprobe_Ex::print_times (void) +{ + ACE_GUARD (ACE_LOCK, ace_mon, this->lock_); + + // Sort the event descriptions + this->sort_event_descriptions_i (); + + u_long size = this->report_buffer_full_ ? this->max_size_ + : this->current_size_; + + ACE_DEBUG ((LM_DEBUG, + "\nACE_Timeprobe_Ex; %u timestamps were recorded:\n", + size)); + + if (size == 0) + return; + + ACE_DEBUG ((LM_DEBUG, + "\n%-50.50s %8.8s %13.13s\n\n", + "Event", + "thread", + "usec")); + + double gsf = ACE_High_Res_Timer::global_scale_factor (); + u_long i, j; + + // First element + i = this->report_buffer_full_ ? this->current_size_ : 0; + + ACE_DEBUG ((LM_DEBUG, + "%-50.50s %8.8x %13.13s\n", + this->find_description_i (i), + this->timeprobes_[i].thread_, + "START")); + + if (size == 1) + return; + + bool has_timestamp_inversion = false; + + j = i; + i = (i + 1) % this->max_size_; + + do + { + // When reusing the same ACE_Timeprobe from multiple threads + // with Linux on Intel SMP, it sometimes happens that the + // recorded times go backward in time if they are recorded from + // different threads (see bugzilla #2342). To obtain the + // correct signed difference between consecutive recorded times, + // one has to cast the time difference to an intermediate signed + // integral type of the same size as ACE_hrtime_t. + + double time_difference = + (ACE_INT64) (this->timeprobes_[i].time_ - this->timeprobes_[j].time_); + + if (time_difference < 0) + has_timestamp_inversion = true; + + // Convert to microseconds. + time_difference /= gsf; + + ACE_DEBUG ((LM_DEBUG, + "%-50.50s %8.8x %14.3f\n", + this->find_description_i (i), + this->timeprobes_[i].thread_, + time_difference)); + + j = i; + i = (i + 1) % this->max_size_; + } + while (i != this->current_size_); + + static bool inversion_warning_printed = false; + if (!inversion_warning_printed && has_timestamp_inversion) + { + inversion_warning_printed = true; + ACE_DEBUG ((LM_DEBUG, + "\nWARNING: The timestamps recorded by gethrtime() on" + " this platform are\n" + "not monotonic across different threads.\n")); + } +} + +template void +ACE_Timeprobe_Ex::print_absolute_times (void) +{ + ACE_GUARD (ACE_LOCK, ace_mon, this->lock_); + + // Sort the event descriptions + this->sort_event_descriptions_i (); + + u_long size = this->report_buffer_full_ ? this->max_size_ + : this->current_size_; + + ACE_DEBUG ((LM_DEBUG, + "\nACE_Timeprobe_Ex; %u timestamps were recorded:\n", + size)); + + if (size == 0) + return; + + ACE_DEBUG ((LM_DEBUG, + "\n%-50.50s %8.8s %13.13s\n\n", + "Event", + "thread", + "stamp")); + + u_long i = this->report_buffer_full_ ? this->current_size_ : 0; + + ACE_Time_Value tv; // to convert ACE_hrtime_t + do + { + ACE_High_Res_Timer::hrtime_to_tv (tv, this->timeprobes_ [i].time_); + + ACE_DEBUG ((LM_DEBUG, + "%-50.50s %8.8x %12.12u\n", + this->find_description_i (i), + this->timeprobes_ [i].thread_, + tv.sec () * 1000000 + + tv.usec ())); + + // Modulus increment: loops around at the end. + i = (i + 1) % this->max_size_; + } + while (i != this->current_size_); +} + +template const char * +ACE_Timeprobe_Ex::find_description_i (u_long i) +{ + if (this->timeprobes_[i].event_type_ == ACE_timeprobe_t::STRING) + return this->timeprobes_[i].event_.event_description_; + else + { + EVENT_DESCRIPTIONS::iterator iterator = this->sorted_event_descriptions_.begin (); + for (u_long j = 0; + j < this->sorted_event_descriptions_.size () - 1; + iterator++, j++) + { + EVENT_DESCRIPTIONS::iterator next_event_descriptions = iterator; + ++next_event_descriptions; + + if (this->timeprobes_[i].event_.event_number_ < (*next_event_descriptions).minimum_id_) + break; + } + return (*iterator).descriptions_[this->timeprobes_[i].event_.event_number_ - (*iterator).minimum_id_]; + } +} + +template void +ACE_Timeprobe_Ex::sort_event_descriptions_i (void) +{ + size_t total_elements = this->event_descriptions_.size (); + + for (size_t i = 0; + i < total_elements; + i++) + { + EVENT_DESCRIPTIONS::iterator iterator = this->event_descriptions_.begin (); + ACE_Event_Descriptions min_entry = *iterator; + + for (; + iterator != this->event_descriptions_.end (); + iterator++) + if ((*iterator).minimum_id_ < min_entry.minimum_id_) + min_entry = *iterator; + + this->sorted_event_descriptions_.insert (min_entry); + this->event_descriptions_.remove (min_entry); + } +} + +template ALLOCATOR * +ACE_Timeprobe_Ex::allocator (void) +{ + return allocator_ ? allocator_ : ACE_Singleton::instance (); +} + +template +ACE_Function_Timeprobe::ACE_Function_Timeprobe (Timeprobe &timeprobe, + u_long event) + : timeprobe_ (timeprobe), + event_ (event) +{ + this->timeprobe_.timeprobe (this->event_); +} + +template +ACE_Function_Timeprobe::~ACE_Function_Timeprobe (void) +{ + this->timeprobe_.timeprobe (this->event_ + 1); +} + +ACE_END_VERSIONED_NAMESPACE_DECL + +#endif /* ACE_COMPILE_TIMEPROBES */ +#endif /* ACE_TIMEPROBE_T_CPP */ diff --git a/dep/ACE_wrappers/ace/Timeprobe_T.h b/dep/ACE_wrappers/ace/Timeprobe_T.h new file mode 100644 index 00000000000..54e5ff4c185 --- /dev/null +++ b/dep/ACE_wrappers/ace/Timeprobe_T.h @@ -0,0 +1,220 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Timeprobe_T.h + * + * $Id: Timeprobe_T.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Irfan Pyarali + */ +//============================================================================= + + +#ifndef ACE_TIMEPROBE_T_H +#define ACE_TIMEPROBE_T_H +#include /**/ "ace/pre.h" + +#include /**/ "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#if defined (ACE_COMPILE_TIMEPROBES) + +#include "ace/Unbounded_Set.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +/** + * @class ACE_Timeprobe_Ex + * + * @brief This class is used to instrument code. This is accomplished + * by inserting time probes at different location in the code. + * ACE_Timeprobe then measures the time difference between two + * time probes. + * + * This class provides a lightweight implementation for + * measuring the time required to execute code between two time + * probes. When a time probe executes, it records the time, the + * id of the calling thread, and an event description. The + * event description can either be an unsigned long or a string + * (char *). If string are used, care must be taken cause only + * pointer copies are done and the string data is *not* copied. + * The recorded time probes can then be printed by calling + * . If you have used unsigned longs as event + * descriptions in any of your time probes, you must have + * provided an event description table that maps the unsigned + * longs to readable strings. This map is a simple array of + * strings, and the event number is used as the index into the + * array when looking for the event description. If you have + * only used strings for the event description, this map is not + * necessary. + * Multiple maps can also be used to chunk up the time probes. + * Each one can be added by calling . + * Different tables are used internally by consulting the + * minimum_id for each table. It is up to the user to make sure + * that multiple tables do not share the same event id range. + */ +template +class ACE_Timeprobe_Ex +{ +public: + + /// Self + typedef ACE_Timeprobe_Ex + SELF; + + /** + * ACE_Timeprobe + */ + typedef ACE_Timeprobe_Ex ACE_Timeprobe; + + + /// We can hold multiple event description tables. + typedef ACE_Unbounded_Set + EVENT_DESCRIPTIONS; + + /// Create Timeprobes with @a size slots + ACE_Timeprobe_Ex (u_long size = ACE_DEFAULT_TIMEPROBE_TABLE_SIZE); + + /// Create Timeprobes with @a size slots + ACE_Timeprobe_Ex (ALLOCATOR *allocator, + u_long size = ACE_DEFAULT_TIMEPROBE_TABLE_SIZE); + /// Destructor. + ~ACE_Timeprobe_Ex (void); + + /// Record a time. @a event is used to describe this time probe. + void timeprobe (u_long event); + + /// Record a time. @a id is used to describe this time probe. + void timeprobe (const char *id); + + /// Record event descriptions. + int event_descriptions (const char **descriptions, + u_long minimum_id); + + /// Print the time probes. + void print_times (void); + + /// Print the time probes. + void print_absolute_times (void); + + /// Reset the slots. All old time probes will be lost. + void reset (void); + + void increase_size (u_long size); + + /// Not implemented (stupid MSVC won't let it be protected). + ACE_Timeprobe_Ex (const ACE_Timeprobe_Ex &); + + // = (Somewhat private) Accessors + + /// Event Descriptions + ACE_Unbounded_Set &event_descriptions (void); + + /// Sorted Event Descriptions. + ACE_Unbounded_Set &sorted_event_descriptions (void); + + /// Find description of event @a i + const char *find_description_i (u_long i); + + /// Sort event descriptions + void sort_event_descriptions_i (void); + + /// Time probe slots + ACE_timeprobe_t *timeprobes (void); + + /// Synchronization variable. + ACE_LOCK &lock (void); + + /// Max size of timestamp table + u_long max_size (void); + + /// Current size of timestamp table + u_long current_size (void); + +protected: + + /// Obtain an allocator pointer. If there is no allocator stored in + /// the instance, the singleton allocator in the current process is used. + ALLOCATOR * allocator (void); + + /// Event Descriptions + EVENT_DESCRIPTIONS event_descriptions_; + + /// Sorted Event Descriptions. + EVENT_DESCRIPTIONS sorted_event_descriptions_; + + /// Time probe slots + ACE_timeprobe_t *timeprobes_; + + /// Synchronization variable. + ACE_LOCK lock_; + + /// Max size of timestamp table + u_long max_size_; + + /// Current size of timestamp table + u_long current_size_; + + /// Flag indicating the report buffer has filled up, and is now + /// acting as a ring-buffer using modulus arithmetic: this saves the + /// max_size_ most recent time stamps and loses earlier ones until + /// drained. + u_short report_buffer_full_; + +private: + ALLOCATOR * allocator_; +}; + +// template +// class ACE_Timeprobe : public ACE_Timeprobe_Ex +// { +// public: +// // Initialize a ACE_Timeprobe with default size +// ACE_Timeprobe (ACE_Allocator *allocator = ACE_Allocator::instance()); + +// /// Create Timeprobes with @a size slots +// ACE_Timeprobe (ACE_Allocator *allocator = ACE_Allocator::instance(), +// u_long size = ACE_DEFAULT_TIMEPROBE_TABLE_SIZE); +// }; + +/** + * @class ACE_Function_Timeprobe + * + * @brief Auto pointer like time probes. It will record on + * construction and on destruction. + */ +template +class ACE_Function_Timeprobe +{ +public: + /// Constructor. + ACE_Function_Timeprobe (Timeprobe &timeprobe, u_long event); + + /// Destructor. + ~ACE_Function_Timeprobe (void); + +protected: + /// Reference to timeprobe. + Timeprobe &timeprobe_; + + /// Event. + u_long event_; +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) +#include "ace/Timeprobe_T.cpp" +#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ + +#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) +#pragma implementation ("Timeprobe_T.cpp") +#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ + +#endif /* ACE_COMPILE_TIMEPROBES */ +#include /**/ "ace/post.h" +#endif /* ACE_TIMEPROBE_T_H */ diff --git a/dep/ACE_wrappers/ace/Timer_Hash.h b/dep/ACE_wrappers/ace/Timer_Hash.h new file mode 100644 index 00000000000..b381419da44 --- /dev/null +++ b/dep/ACE_wrappers/ace/Timer_Hash.h @@ -0,0 +1,75 @@ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file Timer_Hash.h + * + * $Id: Timer_Hash.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Darrell Brunsch + */ +//============================================================================= + + +#ifndef ACE_TIMER_HASH_H +#define ACE_TIMER_HASH_H +#include /**/ "ace/pre.h" + +#include "ace/Timer_Hash_T.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/Timer_Heap_T.h" +#include "ace/Timer_List_T.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +// The following typedef are here for ease of use + +typedef ACE_Timer_Hash_Upcall , + ACE_SYNCH_RECURSIVE_MUTEX> + ACE_Hash_Upcall; + +typedef ACE_Timer_List_T + ACE_Hash_Timer_List; + +typedef ACE_Timer_Heap_T + ACE_Hash_Timer_Heap; + + +typedef ACE_Timer_Hash_T, + ACE_SYNCH_RECURSIVE_MUTEX, + ACE_Hash_Timer_List> + + ACE_Timer_Hash; + +typedef ACE_Timer_Hash_Iterator_T, + ACE_SYNCH_RECURSIVE_MUTEX, + ACE_Hash_Timer_List> + ACE_Timer_Hash_Iterator; + +typedef ACE_Timer_Hash_T, + ACE_SYNCH_RECURSIVE_MUTEX, + ACE_Hash_Timer_Heap> + ACE_Timer_Hash_Heap; + +typedef ACE_Timer_Hash_Iterator_T, + ACE_SYNCH_RECURSIVE_MUTEX, + ACE_Hash_Timer_Heap> + ACE_Timer_Hash_Heap_Iterator; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#include /**/ "ace/post.h" +#endif /* ACE_TIMER_HASH_H */ diff --git a/dep/ACE_wrappers/ace/Timer_Hash_T.cpp b/dep/ACE_wrappers/ace/Timer_Hash_T.cpp new file mode 100644 index 00000000000..057668063aa --- /dev/null +++ b/dep/ACE_wrappers/ace/Timer_Hash_T.cpp @@ -0,0 +1,873 @@ +// $Id: Timer_Hash_T.cpp 80826 2008-03-04 14:51:23Z wotte $ + +#ifndef ACE_TIMER_HASH_T_CPP +#define ACE_TIMER_HASH_T_CPP + +#include "ace/Timer_Hash_T.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/OS_NS_sys_time.h" +#include "ace/Guard_T.h" +#include "ace/Log_Msg.h" + +ACE_RCSID(ace, + Timer_Hash_T, + "$Id: Timer_Hash_T.cpp 80826 2008-03-04 14:51:23Z wotte $") + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +template +class Hash_Token +{ +public: + // This constructor is required by ACE_Locked_Free_List::alloc. + Hash_Token (void) + {} + + Hash_Token *get_next (void) + { + return this->next_; + } + + void set_next (Hash_Token *next) + { + this->next_ = next; + } + + void set (const void *act, + size_t pos, + long orig_id, + const TYPE &type) + { + this->act_ = act; + this->pos_ = pos; + this->orig_id_ = orig_id; + this->type_ = type; + this->next_ = 0; + } + + const void *act_; + size_t pos_; + long orig_id_; + TYPE type_; + /// Pointer to next token. + Hash_Token *next_; +}; + +// Default constructor + +template +ACE_Timer_Hash_Upcall::ACE_Timer_Hash_Upcall (void) + : timer_hash_ (0) +{ + // Nothing +} + +// Constructor that specifies a Timer_Hash to call up to + +template +ACE_Timer_Hash_Upcall::ACE_Timer_Hash_Upcall ( + ACE_Timer_Queue_T *timer_hash) + : timer_hash_ (timer_hash) +{ + // Nothing +} + +template int +ACE_Timer_Hash_Upcall::registration ( + TIMER_QUEUE &, + ACE_Event_Handler *, + const void *) +{ + // Registration will be handled by the upcall functor of the timer + // hash. + return 0; +} + +template int +ACE_Timer_Hash_Upcall::preinvoke (TIMER_QUEUE &, + ACE_Event_Handler *, + const void *, + int, + const ACE_Time_Value &, + const void *&) +{ + // This method should never be invoked since we don't invoke + // expire() on the buckets. + ACE_ASSERT (0); + return 0; +} + +template int +ACE_Timer_Hash_Upcall::postinvoke ( + TIMER_QUEUE &, + ACE_Event_Handler *, + const void *, + int, + const ACE_Time_Value &, + const void *) +{ + // This method should never be invoked since we don't invoke + // expire() on the buckets. + ACE_ASSERT (0); + return 0; +} + +// Calls up to timer_hash's upcall functor +template int +ACE_Timer_Hash_Upcall::timeout ( + TIMER_QUEUE &, + ACE_Event_Handler *, + const void *, + int, + const ACE_Time_Value &) +{ + // This method should never be invoked since we don't invoke + // expire() on the buckets. + ACE_ASSERT (0); + return 0; +} + +template int +ACE_Timer_Hash_Upcall::cancel_type ( + TIMER_QUEUE &, + ACE_Event_Handler *, + int, + int &) +{ + // Cancellation will be handled by the upcall functor of the timer + // hash. + return 0; +} + +template int +ACE_Timer_Hash_Upcall::cancel_timer ( + TIMER_QUEUE &, + ACE_Event_Handler *, + int, + int) +{ + // Cancellation will be handled by the upcall functor of the timer + // hash. + return 0; +} + +template int +ACE_Timer_Hash_Upcall::deletion ( + TIMER_QUEUE &, + ACE_Event_Handler *event_handler, + const void *arg) +{ + // Call up to the upcall functor of the timer hash since the timer + // hash does not invoke deletion() on its upcall functor directly. + Hash_Token *h = + reinterpret_cast *> (const_cast (arg)); + + int result = + this->timer_hash_->upcall_functor (). + deletion (*this->timer_hash_, + event_handler, + h->act_); + + return result; +} + +template +ACE_Timer_Hash_Iterator_T::ACE_Timer_Hash_Iterator_T (ACE_Timer_Hash_T &hash) + : timer_hash_ (hash) +{ + this->first (); + // Nothing +} + +// Positions the iterator at the first node in the timing hash table + +template void +ACE_Timer_Hash_Iterator_T::first (void) +{ + for (this->position_ = 0; + this->position_ < this->timer_hash_.table_size_; + ++this->position_) + { + // Check for an empty entry + if (!this->timer_hash_.table_[this->position_]->is_empty ()) + { + this->iter_ = &this->timer_hash_.table_[this->position_]->iter (); + this->iter_->first (); + return; + } + } + + // Didn't find any + this->iter_ = 0; +} + +// Positions the iterator at the next node in the bucket or goes to the next +// bucket + +template void +ACE_Timer_Hash_Iterator_T::next (void) +{ + if (this->isdone ()) + return; + + // If there is no more in the current bucket, go to the next + if (this->iter_->isdone ()) + { + for (++this->position_; + this->position_ < this->timer_hash_.table_size_; + ++this->position_) + { + // Check for an empty entry + if (!this->timer_hash_.table_[this->position_]->is_empty ()) + { + this->iter_ = &this->timer_hash_.table_[this->position_]->iter (); + this->iter_->first (); + return; + } + } + + // Didn't find any. + this->iter_ = 0; + } + else + this->iter_->next (); +} + +// Returns true when we are at the end (when bucket_item_ == 0) + +template bool +ACE_Timer_Hash_Iterator_T::isdone (void) const +{ + return this->iter_ == 0; +} + +// Returns the node at the current position in the sequence + +template +ACE_Timer_Node_T * +ACE_Timer_Hash_Iterator_T::item (void) +{ + if (this->isdone ()) + return 0; + + return this->iter_->item (); +} + +template +ACE_Timer_Queue_Iterator_T & +ACE_Timer_Hash_T::iter (void) +{ + this->iterator_->first (); + return *this->iterator_; +} + +// Create an empty queue. + +template +ACE_Timer_Hash_T::ACE_Timer_Hash_T ( + size_t table_size, + FUNCTOR *upcall_functor, + ACE_Free_List > *freelist) + : ACE_Timer_Queue_T (upcall_functor, freelist), + size_ (0), + table_size_ (table_size), + table_functor_ (this), + earliest_position_ (0) +#if defined (ACE_WIN64) + , pointer_base_ (0) +#endif /* ACE_WIN64 */ + , token_list_ () +{ + ACE_TRACE ("ACE_Timer_Hash_T::ACE_Timer_Hash_T"); + + ACE_NEW (table_, + BUCKET *[table_size]); + + this->gettimeofday (ACE_OS::gettimeofday); + + for (size_t i = 0; + i < table_size; + ++i) + { + ACE_NEW (this->table_[i], + BUCKET (&this->table_functor_, + this->free_list_)); + this->table_[i]->gettimeofday (ACE_OS::gettimeofday); + } + + ACE_NEW (iterator_, + HASH_ITERATOR (*this)); +} + + +template +ACE_Timer_Hash_T::ACE_Timer_Hash_T ( + FUNCTOR *upcall_functor, + ACE_Free_List > *freelist) + : ACE_Timer_Queue_T (upcall_functor, freelist), + size_ (0), + table_size_ (ACE_DEFAULT_TIMER_HASH_TABLE_SIZE), + table_functor_ (this), + earliest_position_ (0) +#if defined (ACE_WIN64) + , pointer_base_ (0) +#endif /* ACE_WIN64 */ + , token_list_ () +{ + ACE_TRACE ("ACE_Timer_Hash_T::ACE_Timer_Hash_T"); + + ACE_NEW (table_, + BUCKET *[ACE_DEFAULT_TIMER_HASH_TABLE_SIZE]); + + + this->gettimeofday (ACE_OS::gettimeofday); + + for (size_t i = 0; + i < this->table_size_; + ++i) + { + ACE_NEW (this->table_[i], + BUCKET (&this->table_functor_, + this->free_list_)); + this->table_[i]->gettimeofday (ACE_OS::gettimeofday); + } + + ACE_NEW (iterator_, + HASH_ITERATOR (*this)); +} + +// Remove all remaining items in the Queue. + +template +ACE_Timer_Hash_T::~ACE_Timer_Hash_T (void) +{ + ACE_TRACE ("ACE_Timer_Hash_T::~ACE_Timer_Hash_T"); + ACE_MT (ACE_GUARD (ACE_LOCK, ace_mon, this->mutex_)); + + delete iterator_; + + for (size_t i = 0; + i < this->table_size_; + ++i) + delete this->table_[i]; + + delete [] this->table_; +} + +// Checks if queue is empty. + +template bool +ACE_Timer_Hash_T::is_empty (void) const +{ + ACE_TRACE ("ACE_Timer_Hash_T::is_empty"); + return this->table_[this->earliest_position_]->is_empty (); +} + +// Returns earliest time in a non-empty bucket + +template +const ACE_Time_Value & +ACE_Timer_Hash_T::earliest_time (void) const +{ + ACE_TRACE ("ACE_Timer_Hash_T::earliest_time"); + return this->table_[this->earliest_position_]->earliest_time (); +} + +template void +ACE_Timer_Hash_T::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + ACE_TRACE ("ACE_Timer_Hash_T::dump"); + ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\ntable_size_ = %d"), this->table_size_)); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nearliest_position_ = %d"), this->earliest_position_)); + + for (size_t i = 0; i < this->table_size_; ++i) + if (!this->table_[i]->is_empty ()) + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nBucket %d contains nodes"), i)); + + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\n"))); + ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); +#endif /* ACE_HAS_DUMP */ +} + +// Reschedule a periodic timer. This function must be called with the +// mutex lock held. + +template +void +ACE_Timer_Hash_T::reschedule ( + ACE_Timer_Node_T *expired) +{ + ACE_TRACE ("ACE_Timer_Hash_T::reschedule"); + + Hash_Token *h = + reinterpret_cast *> ( + const_cast (expired->get_act ())); + + // Don't use ACE_Utils::truncate_cast<> here. A straight + // static_cast<> will provide more unique results when the number + // of seconds is greater than std::numeric_limits::max(). + size_t const secs_hash_input = + static_cast (expired->get_timer_value ().sec ()); + h->pos_ = secs_hash_input % this->table_size_; + + h->orig_id_ = + this->table_[h->pos_]->schedule (expired->get_type (), + h, + expired->get_timer_value (), + expired->get_interval ()); + ACE_ASSERT (h->orig_id_ != -1); + +#if 0 + ACE_DEBUG ((LM_DEBUG, "Hash::reschedule() resets %d in slot %d where it's id is %d and token is %x\n", + expired->get_timer_value ().msec (), + h->pos_, + h->orig_id_, + h)); +#endif + + // Since schedule() above will allocate a new node + // then here schedule for deletion. Don't call + // this->free_node() because that will invalidate + // and that's what user have as timer_id. + ACE_Timer_Queue_T::free_node (expired); + + if (this->table_[this->earliest_position_]->is_empty () + || this->table_[h->pos_]->earliest_time () + < this->table_[this->earliest_position_]->earliest_time ()) + this->earliest_position_ = h->pos_; +} + +// Insert a new handler that expires at time future_time; if interval +// is > 0, the handler will be reinvoked periodically. + +template +long +ACE_Timer_Hash_T::schedule_i ( + const TYPE &type, + const void *act, + const ACE_Time_Value &future_time, + const ACE_Time_Value &interval) +{ + ACE_TRACE ("ACE_Timer_Hash_T::schedule_i"); + + // Don't use ACE_Utils::truncate_cast<> here. A straight + // static_cast<> will provide more unique results when the number + // of seconds is greater than std::numeric_limits::max(). + size_t const secs_hash_input = static_cast (future_time.sec ()); + size_t const position = secs_hash_input % this->table_size_; + + // Don't create Hash_Token directly. Instead we get one from Free_List + // and then set it properly. + Hash_Token *h = this->token_list_.remove (); + h->set (act, position, 0, type); + + h->orig_id_ = + this->table_[position]->schedule (type, + h, + future_time, + interval); + ACE_ASSERT (h->orig_id_ != -1); + +#if 0 + ACE_DEBUG ((LM_DEBUG, "Hash::schedule() placing %d in slot %d where it's id is %d and token is %x\n", + future_time.msec (), + position, + h->orig_id_, + h)); +#endif + + if (this->table_[this->earliest_position_]->is_empty () + || this->table_[position]->earliest_time () + < this->table_[this->earliest_position_]->earliest_time ()) + this->earliest_position_ = position; + + ++this->size_; + +#if defined (ACE_WIN64) + // This is a Win64 hack, necessary because of the original (bad) decision + // to use a pointer as the timer ID. This class doesn't follow the usual + // timer expiration rules (see comments in header file) and is probably + // not used much. The dynamic allocation of Hash_Tokens without + // recording them anywhere is a large problem for Win64 since the + // size of a pointer is 64 bits, but a long is 32. Since this class + // is not much used, I'm hacking this, at least for now. If it becomes + // an issue, I'll look at it again then. + intptr_t hi = reinterpret_cast (h); + if (this->pointer_base_ == 0) + this->pointer_base_ = hi & 0xffffffff00000000; + return static_cast (hi & 0xffffffff); +#else + return reinterpret_cast (h); +#endif +} + +// Locate and update the inteval on the timer_id + +template +int +ACE_Timer_Hash_T::reset_interval ( + long timer_id, + const ACE_Time_Value & interval) +{ + ACE_TRACE ("ACE_Timer_Hash_T::reset_interval"); + + // Make sure we are getting a valid , not an error + // returned by . + if (timer_id == -1) + return -1; + +#if defined (ACE_WIN64) + unsigned long const timer_offset = + static_cast (timer_id); + + ACE_MT (ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->mutex_, -1)); + + Hash_Token * const h = + reinterpret_cast *> (this->pointer_base_ + timer_offset); +#else + Hash_Token * const h = + reinterpret_cast *> (timer_id); + + // Grab the lock before accessing the table. We don't need to do so + // before this point since no members are accessed until now. + ACE_MT (ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->mutex_, -1)); +#endif /* ACE_WIN64 */ + + return this->table_[h->pos_]->reset_interval (h->orig_id_, + interval); +} + +// Locate and remove the single with a value of +// @a timer_id from the correct table timer queue. + +template +int +ACE_Timer_Hash_T::cancel (long timer_id, + const void **act, + int dont_call) +{ + ACE_TRACE ("ACE_Timer_Hash_T::cancel"); + + // Make sure we are getting a valid , not an error + // returned by . + if (timer_id == -1) + return 0; + +#if defined (ACE_WIN64) + unsigned long const timer_offset = + static_cast (timer_id); + + ACE_MT (ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->mutex_, -1)); + + Hash_Token * const h = + reinterpret_cast *> (this->pointer_base_ + timer_offset); +#else + Hash_Token * const h = + reinterpret_cast *> (timer_id); + + // Grab the lock before accessing the table. We don't need to do so + // before this point since no members are accessed until now. + ACE_MT (ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->mutex_, -1)); +#endif /* ACE_WIN64 */ + + int const result = this->table_[h->pos_]->cancel (h->orig_id_, + 0, + dont_call); + + if (result == 1) + { + // Call the close hooks. + int cookie = 0; + + // cancel_type() called once per . + this->upcall_functor ().cancel_type (*this, + h->type_, + dont_call, + cookie); + + // cancel_timer() called once per . + this->upcall_functor ().cancel_timer (*this, + h->type_, + dont_call, + cookie); + + if (h->pos_ == this->earliest_position_) + this->find_new_earliest (); + + if (act != 0) + *act = h->act_; + + // We could destruct Hash_Token explicitly but we better + // schedule it for destruction. In this case next + // token_list_.remove () will use it. + this->token_list_.add (h); + + --this->size_; + } + + return result; +} + +// Locate and remove all values of from the timer queue. + +template +int +ACE_Timer_Hash_T::cancel (const TYPE &type, + int dont_call) +{ + ACE_TRACE ("ACE_Timer_Hash_T::cancel"); + + size_t i; // loop variable. + + Hash_Token **timer_ids = 0; + size_t pos = 0; + + ACE_MT (ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->mutex_, -1)); + + ACE_NEW_RETURN (timer_ids, + Hash_Token *[this->size_], + -1); + + for (i = 0; + i < this->table_size_; + ++i) + { + ACE_Timer_Queue_Iterator_T, + ACE_Null_Mutex> &iter = + this->table_[i]->iter (); + + for (iter.first (); + !iter.isdone (); + iter.next ()) + if (iter.item ()->get_type () == type) + timer_ids[pos++] = + reinterpret_cast *> ( + const_cast (iter.item ()->get_act ())); + } + + if (pos > this->size_) + return -1; + + for (i = 0; i < pos; ++i) + { + int const result = + this->table_[timer_ids[i]->pos_]->cancel (timer_ids[i]->orig_id_, + 0, + dont_call); + ACE_ASSERT (result == 1); + ACE_UNUSED_ARG (result); + + // We could destruct Hash_Token explicitly but we better + // schedule it for destruction. + this->token_list_.add (timer_ids[i]); + + --this->size_; + } + + delete [] timer_ids; + + this->find_new_earliest (); + + // Call the close hooks. + int cookie = 0; + + // cancel_type() called once per . + this->upcall_functor ().cancel_type (*this, + type, + dont_call, + cookie); + + for (i = 0; + i < pos; + ++i) + { + // cancel_timer() called once per . + this->upcall_functor ().cancel_timer (*this, + type, + dont_call, + cookie); + } + + return static_cast (pos); +} + +// Removes the earliest node and finds the new earliest position + +template ACE_Timer_Node_T * +ACE_Timer_Hash_T::remove_first (void) +{ + if (this->is_empty ()) + return 0; + + ACE_Timer_Node_T *temp = + this->table_[this->earliest_position_]->remove_first (); + + this->find_new_earliest (); + + --this->size_; + + return temp; +} + +// Finds a new earliest position + +template void +ACE_Timer_Hash_T::find_new_earliest (void) +{ + for (size_t i = 0; i < this->table_size_; ++i) + if (!this->table_[i]->is_empty ()) + if (this->table_[this->earliest_position_]->is_empty () + || this->earliest_time () == ACE_Time_Value::zero + || this->table_[i]->earliest_time () <= this->earliest_time ()) + this->earliest_position_ = i; +} + +// Returns the earliest node without removing it + +template ACE_Timer_Node_T * +ACE_Timer_Hash_T::get_first (void) +{ + ACE_TRACE ("ACE_Timer_Hash_T::get_first"); + + if (this->is_empty ()) + return 0; + + return this->table_[this->earliest_position_]->get_first (); +} + +template void +ACE_Timer_Hash_T::free_node (ACE_Timer_Node_T *node) +{ + ACE_Timer_Queue_T::free_node (node); + + Hash_Token *h = + reinterpret_cast *> (const_cast (node->get_act ())); + this->token_list_.add (h); +} + +template int +ACE_Timer_Hash_T::dispatch_info_i (const ACE_Time_Value &cur_time, + ACE_Timer_Node_Dispatch_Info_T &info) +{ + int const result = + ACE_Timer_Queue_T::dispatch_info_i (cur_time, + info); + + if (result == 1) + { + Hash_Token *h = + reinterpret_cast *> (const_cast (info.act_)); + + info.act_ = h->act_; + } + + return result; +} + +// Dummy version of expire to get rid of warnings in Sun CC 4.2 + +template int +ACE_Timer_Hash_T::expire () +{ + return ACE_Timer_Queue_T::expire(); +} + +// Specialized expire for Timer Hash + +template int +ACE_Timer_Hash_T::expire (const ACE_Time_Value &cur_time) +{ + ACE_TRACE ("ACE_Timer_Hash_T::expire"); + + int number_of_timers_expired = 0; + + ACE_Timer_Node_T *expired = 0; + + ACE_MT (ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->mutex_, -1)); + + // Go through the table and expire anything that can be expired + + for (size_t i = 0; + i < this->table_size_; + ++i) + { + while (!this->table_[i]->is_empty () + && this->table_[i]->earliest_time () <= cur_time) + { + expired = this->table_[i]->remove_first (); + const void *act = expired->get_act (); + bool reclaim = true; + + Hash_Token *h = + reinterpret_cast *> (const_cast (act)); + + ACE_ASSERT (h->pos_ == i); + +#if 0 + ACE_DEBUG ((LM_DEBUG, "Hash::expire() expiring %d in slot %d where it's id is %d and token is %x\n", + expired->get_timer_value ().msec (), + h->pos_, + h->orig_id_, + h)); +#endif + + // Check if this is an interval timer. + if (expired->get_interval () > ACE_Time_Value::zero) + { + // Make sure that we skip past values that have already + // "expired". + do + expired->set_timer_value (expired->get_timer_value () + + expired->get_interval ()); + while (expired->get_timer_value () <= cur_time); + + // Since this is an interval timer, we need to + // reschedule it. + this->reschedule (expired); + reclaim = false; + } + else + { + this->free_node (expired); + } + + ACE_Timer_Node_Dispatch_Info_T info; + + // Get the dispatch info + expired->get_dispatch_info (info); + + info.act_ = h->act_; + + const void *upcall_act = 0; + + this->preinvoke (info, cur_time, upcall_act); + + this->upcall (info, cur_time); + + this->postinvoke (info, cur_time, upcall_act); + + if (reclaim) + { + --this->size_; + } + + ++number_of_timers_expired; + } + } + + if (number_of_timers_expired > 0) + this->find_new_earliest (); + + return number_of_timers_expired; +} + +ACE_END_VERSIONED_NAMESPACE_DECL + +#endif /* ACE_TIMER_HASH_T_CPP */ diff --git a/dep/ACE_wrappers/ace/Timer_Hash_T.h b/dep/ACE_wrappers/ace/Timer_Hash_T.h new file mode 100644 index 00000000000..b04e7cfbcf3 --- /dev/null +++ b/dep/ACE_wrappers/ace/Timer_Hash_T.h @@ -0,0 +1,342 @@ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file Timer_Hash_T.h + * + * $Id: Timer_Hash_T.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Darrell Brunsch + */ +//============================================================================= + +#ifndef ACE_TIMER_HASH_T_H +#define ACE_TIMER_HASH_T_H +#include /**/ "ace/pre.h" + +#include "ace/Timer_Queue_T.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/Free_List.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +// Forward declaration. +template +class ACE_Timer_Hash_T; +template +class Hash_Token; + +/** + * @class ACE_Timer_Hash_Upcall + * + * @brief Functor for Timer_Hash + * + * This class calls up to the Timer Hash's functor from the + * timer queues in the hash table + */ +template +class ACE_Timer_Hash_Upcall +{ +public: + typedef ACE_Timer_Queue_T, + ACE_Null_Mutex> + TIMER_QUEUE; + + /// Default constructor (creates an invalid object, but needs to be here + /// so timer queues using this functor can be constructed) + ACE_Timer_Hash_Upcall (void); + + /// Constructor that specifies a Timer_Hash to call up to + ACE_Timer_Hash_Upcall (ACE_Timer_Queue_T *timer_hash); + + /// This method is called when a timer is registered. + int registration (TIMER_QUEUE &timer_queue, + ACE_Event_Handler *handler, + const void *arg); + + /// This method is called before the timer expires. + int preinvoke (TIMER_QUEUE &timer_queue, + ACE_Event_Handler *handler, + const void *arg, + int recurring_timer, + const ACE_Time_Value &cur_time, + const void *&upcall_act); + + /// This method is called when the timer expires. + int timeout (TIMER_QUEUE &timer_queue, + ACE_Event_Handler *handler, + const void *arg, + int recurring_timer, + const ACE_Time_Value &cur_time); + + /// This method is called after the timer expires. + int postinvoke (TIMER_QUEUE &timer_queue, + ACE_Event_Handler *handler, + const void *arg, + int recurring_timer, + const ACE_Time_Value &cur_time, + const void *upcall_act); + + /// This method is called when a handler is cancelled + int cancel_type (TIMER_QUEUE &timer_queue, + ACE_Event_Handler *handler, + int dont_call, + int &requires_reference_counting); + + /// This method is called when a timer is cancelled + int cancel_timer (TIMER_QUEUE &timer_queue, + ACE_Event_Handler *handler, + int dont_call, + int requires_reference_counting); + + /// This method is called when the timer queue is destroyed and + /// the timer is still contained in it + int deletion (TIMER_QUEUE &timer_queue, + ACE_Event_Handler *handler, + const void *arg); + +private: + /// Timer Queue to do the calling up to + ACE_Timer_Queue_T *timer_hash_; + + // = Don't allow these operations for now. + ACE_UNIMPLEMENTED_FUNC (ACE_Timer_Hash_Upcall (const ACE_Timer_Hash_Upcall &)) + ACE_UNIMPLEMENTED_FUNC (void operator= (const ACE_Timer_Hash_Upcall &)) +}; + +/** + * @class ACE_Timer_Hash_Iterator_T + * + * @brief Iterates over an ACE_Timer_Hash_T. + * + * This is a generic iterator that can be used to visit every + * node of a timer queue. Be aware that it doesn't transverse + * in the order of timeout values. + */ +template +class ACE_Timer_Hash_Iterator_T : public ACE_Timer_Queue_Iterator_T +{ +public: + /// Constructor. + ACE_Timer_Hash_Iterator_T (ACE_Timer_Hash_T &); + + /// Positions the iterator at the earliest node in the Timer Queue + virtual void first (void); + + /// Positions the iterator at the next node in the Timer Queue + virtual void next (void); + + /// Returns true when there are no more nodes in the sequence + virtual bool isdone (void) const; + + /// Returns the node at the current position in the sequence + virtual ACE_Timer_Node_T *item (void); + +protected: + /// Pointer to the ACE_Timer_Hash that we are iterating over. + ACE_Timer_Hash_T &timer_hash_; + + /// Current position in 's table + size_t position_; + + /// Current iterator used on 's bucket + ACE_Timer_Queue_Iterator_T, ACE_Null_Mutex> *iter_; +}; + +/** + * @class ACE_Timer_Hash_T + * + * @brief Provides a hash table of BUCKETs as an implementation for + * a timer queue. + * + * This implementation uses a hash table of BUCKETs. The hash + * is based on the time_value of the event. Unlike other Timer + * Queues, ACE_Timer_Hash does not expire events in order. + */ +template +class ACE_Timer_Hash_T : public ACE_Timer_Queue_T +{ +public: + /// Type of iterator + typedef ACE_Timer_Hash_Iterator_T + HASH_ITERATOR; + + /// Iterator is a friend + friend class ACE_Timer_Hash_Iterator_T; + + /// Type inherited from + typedef ACE_Timer_Queue_T INHERITED; + + // = Initialization and termination methods. + /** + * Default constructor. @a table_size determines the size of the + * hash table. @a upcall_functor is the instance of the FUNCTOR + * to be used by the buckets. If @a upcall_functor is 0, a default + * FUNCTOR will be created. + */ + ACE_Timer_Hash_T (size_t table_size, + FUNCTOR *upcall_functor = 0, + ACE_Free_List > *freelist = 0); + + /** + * Default constructor. @a upcall_functor is the instance of the + * FUNCTOR to be used by the queue. If @a upcall_functor is 0, Timer + * Hash will create a default FUNCTOR. @a freelist the freelist of + * timer nodes. If 0, then a default freelist will be created. The default + * size will be ACE_DEFAULT_TIMERS and there will be no preallocation. + */ + ACE_Timer_Hash_T (FUNCTOR *upcall_functor = 0, ACE_Free_List > *freelist = 0); + + /// Destructor + virtual ~ACE_Timer_Hash_T (void); + + /// True if queue is empty, else false. + virtual bool is_empty (void) const; + + /// Returns the time of the earlier node in the . + /// Must be called on a non-empty queue. + virtual const ACE_Time_Value &earliest_time (void) const; + + /** + * Resets the interval of the timer represented by @a timer_id to + * @a interval, which is specified in relative time to the current + * . If @a interval is equal to + * ACE_Time_Value::zero, the timer will become a non-rescheduling + * timer. Returns 0 if successful, -1 if not. + */ + virtual int reset_interval (long timer_id, + const ACE_Time_Value &interval); + + /** + * Cancel all timer associated with @a type. If is 0 + * then the will be invoked. Returns number of timers + * cancelled. If any valid timer is not cancelled before destruction + * of this instance of ACE_Timer_Hash_T then user will get a memory + * leak. + */ + virtual int cancel (const TYPE &type, + int dont_call_handle_close = 1); + + /** + * Cancel the single timer that matches the @a timer_id value (which + * was returned from the method). If act is non-NULL + * then it will be set to point to the ``magic cookie'' argument + * passed in when the timer was registered. This makes it possible + * to free up the memory and avoid memory leaks. If is + * 0 then the will be invoked. Returns 1 if cancellation + * succeeded and 0 if the @a timer_id wasn't found. If any valid + * timer is not cancelled before destruction of this instance of + * ACE_Timer_Hash_T then user will get a memory leak. + */ + virtual int cancel (long timer_id, + const void **act = 0, + int dont_call_handle_close = 1); + + /** + * Run the for all timers whose values are <= + * . Also accounts for . Returns + * the number of timers canceled. + */ + virtual int expire (void); + + /** + * Run the for all timers whose values are <= @a current_time. + * This does not account for . Returns the number of + * timers canceled. + */ + virtual int expire (const ACE_Time_Value ¤t_time); + + /// Returns a pointer to this ACE_Timer_Queue's iterator. + virtual ACE_Timer_Queue_Iterator_T &iter (void); + + /// Removes the earliest node from the queue and returns it + virtual ACE_Timer_Node_T *remove_first (void); + + /// Dump the state of an object. + virtual void dump (void) const; + + /// Reads the earliest node from the queue and returns it. + virtual ACE_Timer_Node_T *get_first (void); + +protected: + /// Factory method that frees a previously allocated node. + virtual void free_node (ACE_Timer_Node_T *); + +private: + + /** + * Schedule @a type that will expire at @a future_time, + * which is specified in absolute time. If it expires then @a act is + * passed in as the value to the . If @a interval is != to + * ACE_Time_Value::zero then it is used to reschedule the @a type + * automatically, using relative time to the current . + * This method returns a that is a pointer to a token + * which stores information about the event. This can be + * used to cancel the timer before it expires. Returns -1 on + * failure. + */ + virtual long schedule_i (const TYPE &type, + const void *act, + const ACE_Time_Value &future_time, + const ACE_Time_Value &interval); + + /// Non-locking version of dispatch_info () + virtual int dispatch_info_i (const ACE_Time_Value ¤t_time, + ACE_Timer_Node_Dispatch_Info_T &info); + + /// Reschedule an "interval" ACE_Timer_Node. + virtual void reschedule (ACE_Timer_Node_T *); + + /// Finds the earliest node + void find_new_earliest (void); + + /// Keeps track of the size of the queue + size_t size_; + + /// Table of BUCKETS + BUCKET **table_; + + /// Keeps track of the size of table_ + size_t table_size_; + + /// Functor used for the table's timer queues + ACE_Timer_Hash_Upcall table_functor_; + + /// Index to the position with the earliest entry + size_t earliest_position_; + + /// Iterator used to expire timers. + HASH_ITERATOR *iterator_; + +#if defined (ACE_WIN64) + // Part of a hack... see comments in schedule(). + // This is, essentially, the upper 32 bits of a 64-bit pointer on Win64. + ptrdiff_t pointer_base_; +#endif + + /// Hash_Token is usually allocated in schedule but its + /// deallocation is problematic and token_list_ helps with this. + ACE_Locked_Free_List, ACE_Null_Mutex> token_list_; + + // = Don't allow these operations for now. + ACE_UNIMPLEMENTED_FUNC (ACE_Timer_Hash_T (const ACE_Timer_Hash_T &)) + ACE_UNIMPLEMENTED_FUNC (void operator= (const ACE_Timer_Hash_T &)) +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) +#include "ace/Timer_Hash_T.cpp" +#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ + +#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) +#pragma implementation ("Timer_Hash_T.cpp") +#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ + +#include /**/ "ace/post.h" +#endif /* ACE_TIMER_HASH_T_H */ diff --git a/dep/ACE_wrappers/ace/Timer_Heap.h b/dep/ACE_wrappers/ace/Timer_Heap.h new file mode 100644 index 00000000000..7dec5ec22b4 --- /dev/null +++ b/dep/ACE_wrappers/ace/Timer_Heap.h @@ -0,0 +1,41 @@ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file Timer_Heap.h + * + * $Id: Timer_Heap.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Douglas C. Schmidt + */ +//============================================================================= + +#ifndef ACE_TIMER_HEAP_H +#define ACE_TIMER_HEAP_H +#include /**/ "ace/pre.h" + +#include "ace/Timer_Heap_T.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +// The following typedefs are here for ease of use and backward +// compatibility. + +typedef ACE_Timer_Heap_T, + ACE_SYNCH_RECURSIVE_MUTEX> + ACE_Timer_Heap; + +typedef ACE_Timer_Heap_Iterator_T, + ACE_SYNCH_RECURSIVE_MUTEX> + ACE_Timer_Heap_Iterator; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#include /**/ "ace/post.h" +#endif /* ACE_TIMER_HEAP_H */ diff --git a/dep/ACE_wrappers/ace/Timer_Heap_T.cpp b/dep/ACE_wrappers/ace/Timer_Heap_T.cpp new file mode 100644 index 00000000000..03893dac9a3 --- /dev/null +++ b/dep/ACE_wrappers/ace/Timer_Heap_T.cpp @@ -0,0 +1,889 @@ +// $Id: Timer_Heap_T.cpp 80826 2008-03-04 14:51:23Z wotte $ + +#ifndef ACE_TIMER_HEAP_T_CPP +#define ACE_TIMER_HEAP_T_CPP + +#include "ace/Timer_Heap_T.h" +#include "ace/Log_Msg.h" +#include "ace/Guard_T.h" +#include "ace/OS_NS_errno.h" +#include "ace/OS_NS_string.h" +#include "ace/Numeric_Limits.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +/* +** The ACE_Timer_Heap::max_size_ and array loops, checks, etc. are all size_t. +** The timer IDs are long, and since they are indices into the heap, we need +** to be sure that the timer heap size can fit in a long. Hence, when size +** is (re)set, limit it to the maximum long value. We use the C++ standard +** limits if available. +*/ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +// Define some simple inlined functions to clarify the code. +inline size_t +ACE_HEAP_PARENT (size_t X) +{ + return (X == 0 ? 0 : ((X - 1) / 2)); +} + +inline size_t +ACE_HEAP_LCHILD (size_t X) +{ + return X + X + 1; +} + +// Constructor that takes in an to iterate over. + +template +ACE_Timer_Heap_Iterator_T::ACE_Timer_Heap_Iterator_T ( + ACE_Timer_Heap_T &heap) + : timer_heap_ (heap) +{ + ACE_TRACE ("ACE_Timer_Heap_Iterator_T::ACE_Timer_Heap_Iterator"); + this->first (); +} + +template +ACE_Timer_Heap_Iterator_T::~ACE_Timer_Heap_Iterator_T (void) +{ +} + +// Positions the iterator at the first node in the heap array + +template +void +ACE_Timer_Heap_Iterator_T::first (void) +{ + this->position_ = 0; +} + +// Positions the iterator at the next node in the heap array + +template +void +ACE_Timer_Heap_Iterator_T::next (void) +{ + if (this->position_ != this->timer_heap_.cur_size_) + ++this->position_; +} + +// Returns true the is at the end of the heap array + +template bool +ACE_Timer_Heap_Iterator_T::isdone (void) const +{ + return this->position_ == this->timer_heap_.cur_size_; +} + +// Returns the node at the current position in the heap or 0 if at the end + +template ACE_Timer_Node_T * +ACE_Timer_Heap_Iterator_T::item (void) +{ + if (this->position_ != this->timer_heap_.cur_size_) + return this->timer_heap_.heap_[this->position_]; + return 0; +} + +// Constructor +// Note that timer_ids_curr_ and timer_ids_min_free_ both start at 0. +// Since timer IDs are assigned by first incrementing the timer_ids_curr_ +// value, the first ID assigned will be 1 (just as in the previous design). +// When it's time to wrap, the next ID given out will be 0. +template +ACE_Timer_Heap_T::ACE_Timer_Heap_T ( + size_t size, + bool preallocated, + FUNCTOR *upcall_functor, + ACE_Free_List > *freelist) + : ACE_Timer_Queue_T (upcall_functor, freelist), + max_size_ (size), + cur_size_ (0), + cur_limbo_ (0), + timer_ids_curr_ (0), + timer_ids_min_free_ (0), + preallocated_nodes_ (0), + preallocated_nodes_freelist_ (0) +{ + ACE_TRACE ("ACE_Timer_Heap_T::ACE_Timer_Heap_T"); + + // Possibly reduce size to fit in a long. + if (size > static_cast (ACE_Numeric_Limits::max ())) + { + size = static_cast (ACE_Numeric_Limits::max ()); + this->max_size_ = size; + } + + // Create the heap array. + ACE_NEW (this->heap_, + ACE_Timer_Node_T *[size]); + + // Create the parallel + ACE_NEW (this->timer_ids_, + ssize_t[size]); + + // Initialize the "freelist," which uses negative values to + // distinguish freelist elements from "pointers" into the + // array. + for (size_t i = 0; i < size; ++i) + this->timer_ids_[i] = -1; + + if (preallocated) + { + ACE_NEW (this->preallocated_nodes_, + ACE_Timer_Node_T[size]); + + // Add allocated array to set of such arrays for deletion on + // cleanup. + this->preallocated_node_set_.insert (this->preallocated_nodes_); + + // Form the freelist by linking the next_ pointers together. + for (size_t j = 1; j < size; ++j) + this->preallocated_nodes_[j - 1].set_next (&this->preallocated_nodes_[j]); + + // NULL-terminate the freelist. + this->preallocated_nodes_[size - 1].set_next (0); + + // Assign the freelist pointer to the front of the list. + this->preallocated_nodes_freelist_ = + &this->preallocated_nodes_[0]; + } + + ACE_NEW (iterator_, + HEAP_ITERATOR (*this)); +} + +// Note that timer_ids_curr_ and timer_ids_min_free_ both start at 0. +// Since timer IDs are assigned by first incrementing the timer_ids_curr_ +// value, the first ID assigned will be 1 (just as in the previous design). +// When it's time to wrap, the next ID given out will be 0. +template +ACE_Timer_Heap_T::ACE_Timer_Heap_T ( + FUNCTOR *upcall_functor, + ACE_Free_List > *freelist) + : ACE_Timer_Queue_T (upcall_functor, freelist), + max_size_ (ACE_DEFAULT_TIMERS), + cur_size_ (0), + cur_limbo_ (0), + timer_ids_curr_ (0), + timer_ids_min_free_ (0), + preallocated_nodes_ (0), + preallocated_nodes_freelist_ (0) +{ + ACE_TRACE ("ACE_Timer_Heap_T::ACE_Timer_Heap_T"); + + // Possibly reduce size to fit in a long. + if (this->max_size_ > static_cast (ACE_Numeric_Limits::max ())) + this->max_size_ = static_cast (ACE_Numeric_Limits::max ()); + + // Create the heap array. + ACE_NEW (this->heap_, + ACE_Timer_Node_T *[this->max_size_]); + + // Create the parallel array. + ACE_NEW (this->timer_ids_, + ssize_t[this->max_size_]); + + // Initialize the "freelist," which uses negative values to + // distinguish freelist elements from "pointers" into the + // array. + for (size_t i = 0; i < this->max_size_; ++i) + this->timer_ids_[i] = -1; + + ACE_NEW (iterator_, + HEAP_ITERATOR (*this)); +} + +template +ACE_Timer_Heap_T::~ACE_Timer_Heap_T (void) +{ + ACE_TRACE ("ACE_Timer_Heap_T::~ACE_Timer_Heap_T"); + + delete iterator_; + + size_t current_size = + this->cur_size_; + + // Clean up all the nodes still in the queue + for (size_t i = 0; i < current_size; ++i) + { + // Grab the event_handler and act, then delete the node before calling + // back to the handler. Prevents a handler from trying to cancel_timer() + // inside handle_close(), ripping the current timer node out from + // under us. + TYPE eh = this->heap_[i]->get_type (); + const void *act = this->heap_[i]->get_act (); + this->free_node (this->heap_[i]); + this->upcall_functor ().deletion (*this, eh, act); + } + + delete [] this->heap_; + delete [] this->timer_ids_; + + // clean up any preallocated timer nodes + if (preallocated_nodes_ != 0) + { + ACE_Unbounded_Set_Iterator *> + set_iterator (this->preallocated_node_set_); + + for (ACE_Timer_Node_T **entry = 0; + set_iterator.next (entry) !=0; + set_iterator.advance ()) + delete [] *entry; + } +} + +template +long +ACE_Timer_Heap_T::pop_freelist (void) +{ + ACE_TRACE ("ACE_Timer_Heap_T::pop_freelist"); + + // Scan for a free timer ID. Note that since this function is called + // _after_ the check for a full timer heap, we are guaranteed to find + // a free ID, even if we need to wrap around and start reusing freed IDs. + // On entry, the curr_ index is at the previous ID given out; start + // up where we left off last time. + // NOTE - a timer_ids_ slot with -2 is out of the heap, but not freed. + // It must be either freed (free_node) or rescheduled (reschedule). + ++this->timer_ids_curr_; + while (this->timer_ids_curr_ < this->max_size_ && + (this->timer_ids_[this->timer_ids_curr_] >= 0 || + this->timer_ids_[this->timer_ids_curr_] == -2 )) + ++this->timer_ids_curr_; + if (this->timer_ids_curr_ == this->max_size_) + { + ACE_ASSERT (this->timer_ids_min_free_ < this->max_size_); + this->timer_ids_curr_ = this->timer_ids_min_free_; + // We restarted the free search at min. Since min won't be + // free anymore, and curr_ will just keep marching up the list + // on each successive need for an ID, reset min_free_ to the + // size of the list until an ID is freed that curr_ has already + // gone past (see push_freelist). + this->timer_ids_min_free_ = this->max_size_; + } + + return static_cast (this->timer_ids_curr_); +} + +template +void +ACE_Timer_Heap_T::push_freelist (long old_id) +{ + ACE_TRACE ("ACE_Timer_Heap_T::push_freelist"); + + // Since this ID has already been checked by one of the public + // functions, it's safe to cast it here. + size_t oldid = static_cast (old_id); + + // The freelist values in the are negative, so set the + // freed entry back to 'free'. If this is the new lowest value free + // timer ID that curr_ won't see on it's normal march through the list, + // remember it. + ACE_ASSERT (this->timer_ids_[oldid] >= 0 || this->timer_ids_[oldid] == -2); + if (this->timer_ids_[oldid] == -2) + --this->cur_limbo_; + else + --this->cur_size_; + this->timer_ids_[oldid] = -1; + if (oldid < this->timer_ids_min_free_ && oldid <= this->timer_ids_curr_) + this->timer_ids_min_free_ = oldid; + return; +} + +template +long +ACE_Timer_Heap_T::timer_id (void) +{ + ACE_TRACE ("ACE_Timer_Heap_T::timer_id"); + + // Return the next item off the freelist and use it as the timer id. + return this->pop_freelist (); +} + +// Checks if queue is empty. + +template +bool +ACE_Timer_Heap_T::is_empty (void) const +{ + ACE_TRACE ("ACE_Timer_Heap_T::is_empty"); + return this->cur_size_ == 0; +} + +template +ACE_Timer_Queue_Iterator_T & +ACE_Timer_Heap_T::iter (void) +{ + this->iterator_->first (); + return *this->iterator_; +} + +// Returns earliest time in a non-empty queue. + +template const ACE_Time_Value & +ACE_Timer_Heap_T::earliest_time (void) const +{ + ACE_TRACE ("ACE_Timer_Heap_T::earliest_time"); + return this->heap_[0]->get_timer_value (); +} + +template +void +ACE_Timer_Heap_T::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + ACE_TRACE ("ACE_Timer_Heap_T::dump"); + ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); + + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nmax_size_ = %d"), this->max_size_)); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\ncur_size_ = %d"), this->cur_size_)); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\ncur_limbo_= %d"), this->cur_limbo_)); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nids_curr_ = %d"), + this->timer_ids_curr_)); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nmin_free_ = %d"), + this->timer_ids_min_free_)); + + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nheap_ = \n"))); + + for (size_t i = 0; i < this->cur_size_; ++i) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("%d\n"), + i)); + this->heap_[i]->dump (); + } + + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\ntimer_ids_ = \n"))); + + for (size_t j = 0; j < this->max_size_; ++j) + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("%d\t%d\n"), + j, + this->timer_ids_[j])); + + ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); +#endif /* ACE_HAS_DUMP */ +} + +template +void +ACE_Timer_Heap_T::copy ( + size_t slot, + ACE_Timer_Node_T *moved_node) +{ + // Insert into its new location in the heap. + this->heap_[slot] = moved_node; + + ACE_ASSERT (moved_node->get_timer_id () >= 0 + && moved_node->get_timer_id () < (int) this->max_size_); + + // Update the corresponding slot in the parallel array. + this->timer_ids_[moved_node->get_timer_id ()] = static_cast (slot); +} + +// Remove the slot'th timer node from the heap, but do not reclaim its +// timer ID or change the size of this timer heap object. The caller of +// this function must call either free_node (to reclaim the timer ID +// and the timer node memory, as well as decrement the size of the queue) +// or reschedule (to reinsert the node in the heap at a new time). +template +ACE_Timer_Node_T * +ACE_Timer_Heap_T::remove (size_t slot) +{ + ACE_Timer_Node_T *removed_node = + this->heap_[slot]; + + // NOTE - the cur_size_ is being decremented since the queue has one + // less active timer in it. However, this ACE_Timer_Node is not being + // freed, and there is still a place for it in timer_ids_ (the timer ID + // is not being relinquished). The node can still be rescheduled, or + // it can be freed via free_node. + --this->cur_size_; + + // Only try to reheapify if we're not deleting the last entry. + + if (slot < this->cur_size_) + { + ACE_Timer_Node_T *moved_node = + this->heap_[this->cur_size_]; + + // Move the end node to the location being removed and update + // the corresponding slot in the parallel array. + this->copy (slot, moved_node); + + // If the time_value_> is great than or equal its + // parent it needs be moved down the heap. + size_t parent = ACE_HEAP_PARENT (slot); + + if (moved_node->get_timer_value () + >= this->heap_[parent]->get_timer_value ()) + this->reheap_down (moved_node, + slot, + ACE_HEAP_LCHILD (slot)); + else + this->reheap_up (moved_node, + slot, + parent); + } + + this->timer_ids_[removed_node->get_timer_id ()] = -2; + ++this->cur_limbo_; + return removed_node; +} + +template void +ACE_Timer_Heap_T::reheap_down ( + ACE_Timer_Node_T *moved_node, + size_t slot, + size_t child) +{ + // Restore the heap property after a deletion. + + while (child < this->cur_size_) + { + // Choose the smaller of the two children. + if (child + 1 < this->cur_size_ + && this->heap_[child + 1]->get_timer_value () + < this->heap_[child]->get_timer_value ()) + child++; + + // Perform a if the child has a larger timeout value than + // the . + if (this->heap_[child]->get_timer_value () + < moved_node->get_timer_value ()) + { + this->copy (slot, + this->heap_[child]); + slot = child; + child = ACE_HEAP_LCHILD (child); + } + else + // We've found our location in the heap. + break; + } + + this->copy (slot, moved_node); +} + +template +void +ACE_Timer_Heap_T::reheap_up ( + ACE_Timer_Node_T *moved_node, + size_t slot, + size_t parent) +{ + // Restore the heap property after an insertion. + + while (slot > 0) + { + // If the parent node is greater than the we need + // to copy it down. + if (moved_node->get_timer_value () + < this->heap_[parent]->get_timer_value ()) + { + this->copy (slot, this->heap_[parent]); + slot = parent; + parent = ACE_HEAP_PARENT (slot); + } + else + break; + } + + // Insert the new node into its proper resting place in the heap and + // update the corresponding slot in the parallel array. + this->copy (slot, + moved_node); +} + +template +void +ACE_Timer_Heap_T::insert ( + ACE_Timer_Node_T *new_node) +{ + if (this->cur_size_ + this->cur_limbo_ + 2 >= this->max_size_) + this->grow_heap (); + + this->reheap_up (new_node, + this->cur_size_, + ACE_HEAP_PARENT (this->cur_size_)); + this->cur_size_++; +} + +template +void +ACE_Timer_Heap_T::grow_heap (void) +{ + // All the containers will double in size from max_size_. + size_t new_size = this->max_size_ * 2; + +#if 0 + // Yikes - there's no way to flag a failure of going out of range of + // a 'long' - this is a problem that should be addressed at some point. + if (new_size > ACE_Numeric_Limits::max ()) + new_size = ACE_Numeric_Limits::max (); + + if (new_size <= this->max_size_) // We are already at the limit + { + errno = ENOMEM; + return -1; + } +#endif /* 0 */ + + // First grow the heap itself. + + ACE_Timer_Node_T **new_heap = 0; + + ACE_NEW (new_heap, + ACE_Timer_Node_T *[new_size]); + + ACE_OS::memcpy (new_heap, + this->heap_, + this->max_size_ * sizeof *new_heap); + delete [] this->heap_; + this->heap_ = new_heap; + + // Grow the array of timer ids. + + ssize_t *new_timer_ids = 0; + + ACE_NEW (new_timer_ids, + ssize_t[new_size]); + + ACE_OS::memcpy (new_timer_ids, + this->timer_ids_, + this->max_size_ * sizeof (ssize_t)); + + delete [] timer_ids_; + this->timer_ids_ = new_timer_ids; + + // And add the new elements to the end of the "freelist". + for (size_t i = this->max_size_; i < new_size; ++i) + this->timer_ids_[i] = -(static_cast (i) + 1); + + // Grow the preallocation array (if using preallocation) + if (this->preallocated_nodes_ != 0) + { + // Create a new array with max_size elements to link in to + // existing list. + ACE_NEW (this->preallocated_nodes_, + ACE_Timer_Node_T[this->max_size_]); + + // Add it to the set for later deletion + this->preallocated_node_set_.insert (this->preallocated_nodes_); + + // Link new nodes together (as for original list). + for (size_t k = 1; k < this->max_size_; ++k) + this->preallocated_nodes_[k - 1].set_next (&this->preallocated_nodes_[k]); + + // NULL-terminate the new list. + this->preallocated_nodes_[this->max_size_ - 1].set_next (0); + + // Link new array to the end of the existling list. + if (this->preallocated_nodes_freelist_ == 0) + this->preallocated_nodes_freelist_ = + &preallocated_nodes_[0]; + else + { + ACE_Timer_Node_T *previous = + this->preallocated_nodes_freelist_; + + for (ACE_Timer_Node_T *current = this->preallocated_nodes_freelist_->get_next (); + current != 0; + current = current->get_next ()) + previous = current; + + previous->set_next (&this->preallocated_nodes_[0]); + } + } + + this->max_size_ = new_size; + // Force rescan of list from beginning for a free slot (I think...) + // This fixed Bugzilla #2447. + this->timer_ids_min_free_ = this->max_size_; +} + +// Reschedule a periodic timer. This function must be called with the +// mutex lock held. + +template +void +ACE_Timer_Heap_T::reschedule ( + ACE_Timer_Node_T *expired) +{ + ACE_TRACE ("ACE_Timer_Heap_T::reschedule"); + + // If we are rescheduling, then the most recent call was to + // remove_first (). That called remove () to remove the node from the + // heap, but did not free the timer ID. The ACE_Timer_Node still has + // its assigned ID - just needs to be inserted at the new proper + // place, and the heap restored properly. + if (this->timer_ids_[expired->get_timer_id ()] == -2) + --this->cur_limbo_; + this->insert (expired); +} + +template +ACE_Timer_Node_T * +ACE_Timer_Heap_T::alloc_node (void) +{ + ACE_Timer_Node_T *temp = 0; + + // Only allocate a node if we are *not* using the preallocated heap. + if (this->preallocated_nodes_ == 0) + ACE_NEW_RETURN (temp, + ACE_Timer_Node_T, + 0); + else + { + // check to see if the heap needs to grow + if (this->preallocated_nodes_freelist_ == 0) + this->grow_heap (); + + temp = this->preallocated_nodes_freelist_; + + // Remove the first element from the freelist. + this->preallocated_nodes_freelist_ = + this->preallocated_nodes_freelist_->get_next (); + } + return temp; +} + +template +void +ACE_Timer_Heap_T::free_node ( + ACE_Timer_Node_T *node) +{ + // Return this timer id to the freelist. + this->push_freelist (node->get_timer_id ()); + + // Only free up a node if we are *not* using the preallocated heap. + if (this->preallocated_nodes_ == 0) + delete node; + else + { + node->set_next (this->preallocated_nodes_freelist_); + this->preallocated_nodes_freelist_ = node; + } +} + +// Insert a new timer that expires at time future_time; if interval is +// > 0, the handler will be reinvoked periodically. + +template +long +ACE_Timer_Heap_T::schedule_i ( + const TYPE &type, + const void *act, + const ACE_Time_Value &future_time, + const ACE_Time_Value &interval) +{ + ACE_TRACE ("ACE_Timer_Heap_T::schedule_i"); + + if ((this->cur_size_ + this->cur_limbo_) < this->max_size_) + { + // Obtain the next unique sequence number. + long timer_id = this->timer_id (); + + // Obtain the memory to the new node. + ACE_Timer_Node_T *temp = 0; + + ACE_ALLOCATOR_RETURN (temp, + this->alloc_node (), + -1); + temp->set (type, + act, + future_time, + interval, + 0, + timer_id); + + this->insert (temp); + return timer_id; + } + else + return -1; +} + +// Locate and remove the single timer with a value of @a timer_id from +// the timer queue. + +template +int +ACE_Timer_Heap_T::cancel (long timer_id, + const void **act, + int dont_call) +{ + ACE_TRACE ("ACE_Timer_Heap_T::cancel"); + ACE_MT (ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->mutex_, -1)); + + // Locate the ACE_Timer_Node that corresponds to the timer_id. + + // Check to see if the timer_id is out of range + if (timer_id < 0 + || (size_t) timer_id > this->max_size_) + return 0; + + ssize_t timer_node_slot = this->timer_ids_[timer_id]; + + // Check to see if timer_id is still valid. + if (timer_node_slot < 0) + return 0; + + if (timer_id != this->heap_[timer_node_slot]->get_timer_id ()) + { + ACE_ASSERT (timer_id == this->heap_[timer_node_slot]->get_timer_id ()); + return 0; + } + else + { + ACE_Timer_Node_T *temp = + this->remove (timer_node_slot); + + // Call the close hooks. + int cookie = 0; + + // cancel_type() called once per . + this->upcall_functor ().cancel_type (*this, + temp->get_type (), + dont_call, + cookie); + + // cancel_timer() called once per . + this->upcall_functor ().cancel_timer (*this, + temp->get_type (), + dont_call, + cookie); + + if (act != 0) + *act = temp->get_act (); + + this->free_node (temp); + return 1; + } +} + +// Locate and update the inteval on the timer_id + +template +int +ACE_Timer_Heap_T::reset_interval (long timer_id, + const ACE_Time_Value &interval) +{ + ACE_TRACE ("ACE_Timer_Heap_T::reset_interval"); + ACE_MT (ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->mutex_, -1)); + + // Locate the ACE_Timer_Node that corresponds to the timer_id. + + // Check to see if the timer_id is out of range + if (timer_id < 0 + || (size_t) timer_id > this->max_size_) + return -1; + + ssize_t timer_node_slot = this->timer_ids_[timer_id]; + + // Check to see if timer_id is still valid. + if (timer_node_slot < 0) + return -1; + + if (timer_id != this->heap_[timer_node_slot]->get_timer_id ()) + { + ACE_ASSERT (timer_id == this->heap_[timer_node_slot]->get_timer_id ()); + return -1; + } + else + { + // Reset the timer interval + this->heap_[timer_node_slot]->set_interval (interval); + return 0; + } +} + +// Locate and remove all values of @a type from the timer queue. + +template +int +ACE_Timer_Heap_T::cancel (const TYPE &type, + int dont_call) +{ + ACE_TRACE ("ACE_Timer_Heap_T::cancel"); + + ACE_MT (ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->mutex_, -1)); + + int number_of_cancellations = 0; + + // Try to locate the ACE_Timer_Node that matches the timer_id. + + for (size_t i = 0; i < this->cur_size_; ) + { + if (this->heap_[i]->get_type () == type) + { + ACE_Timer_Node_T *temp = this->remove (i); + + ++number_of_cancellations; + + this->free_node (temp); + + // We reset to zero so that we don't miss checking any nodes + // if a reheapify occurs when a node is removed. There + // may be a better fix than this, however. + i = 0; + } + else + ++i; + } + + // Call the close hooks. + int cookie = 0; + + // cancel_type() called once per . + this->upcall_functor ().cancel_type (*this, + type, + dont_call, + cookie); + + for (int j = 0; + j < number_of_cancellations; + ++j) + { + // cancel_timer() called once per . + this->upcall_functor ().cancel_timer (*this, + type, + dont_call, + cookie); + } + + return number_of_cancellations; +} + +// Returns the earliest node or returns 0 if the heap is empty. + +template +ACE_Timer_Node_T * +ACE_Timer_Heap_T::remove_first (void) +{ + ACE_TRACE ("ACE_Timer_Heap_T::remove_first"); + + if (this->cur_size_ == 0) + return 0; + + return this->remove (0); +} + +template +ACE_Timer_Node_T * +ACE_Timer_Heap_T::get_first (void) +{ + ACE_TRACE ("ACE_Timer_Heap_T::get_first"); + + return this->cur_size_ == 0 ? 0 : this->heap_[0]; +} + +ACE_END_VERSIONED_NAMESPACE_DECL + +#endif /* ACE_TIMER_HEAP_T_CPP */ diff --git a/dep/ACE_wrappers/ace/Timer_Heap_T.h b/dep/ACE_wrappers/ace/Timer_Heap_T.h new file mode 100644 index 00000000000..ac21a487f38 --- /dev/null +++ b/dep/ACE_wrappers/ace/Timer_Heap_T.h @@ -0,0 +1,338 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Timer_Heap_T.h + * + * $Id: Timer_Heap_T.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Douglas C. Schmidt + */ +//============================================================================= + +#ifndef ACE_TIMER_HEAP_T_H +#define ACE_TIMER_HEAP_T_H +#include /**/ "ace/pre.h" + +#include "ace/Timer_Queue_T.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/Free_List.h" +#include "ace/Unbounded_Set.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +// Forward declaration +template +class ACE_Timer_Heap_T; + +/** + * @class ACE_Timer_Heap_Iterator_T + * + * @brief Iterates over an ACE_Timer_Heap_T. + * + * This is a generic iterator that can be used to visit every + * node of a timer queue. Be aware that it doesn't transverse + * in the order of timeout values. + */ +template +class ACE_Timer_Heap_Iterator_T : public ACE_Timer_Queue_Iterator_T +{ +public: + /// Constructor. + ACE_Timer_Heap_Iterator_T (ACE_Timer_Heap_T &); + + /// Destructor. + ~ACE_Timer_Heap_Iterator_T (void); + + /// Positions the iterator at the earliest node in the Timer Queue + virtual void first (void); + + /// Positions the iterator at the next node in the Timer Queue + virtual void next (void); + + /// Returns true when there are no more nodes in the sequence + virtual bool isdone (void) const; + + /// Returns the node at the current position in the sequence + virtual ACE_Timer_Node_T *item (void); + +protected: + /// Pointer to the ACE_Timer_Heap that we are iterating over. + ACE_Timer_Heap_T &timer_heap_; + + /// Position in the array where the iterator is at + size_t position_; +}; + +/** + * @class ACE_Timer_Heap_T + * + * @brief Provides a very fast and predictable timer implementation. + * + * This implementation uses a heap-based callout queue of + * absolute times. Therefore, in the average and worst case, + * scheduling, canceling, and expiring timers is O(log N) (where + * N is the total number of timers). In addition, we can also + * preallocate as many @c ACE_Timer_Node objects as there are slots + * in the heap. This allows us to completely remove the need for + * dynamic memory allocation, which is important for real-time + * systems. + */ +template +class ACE_Timer_Heap_T : public ACE_Timer_Queue_T +{ +public: + typedef ACE_Timer_Heap_Iterator_T HEAP_ITERATOR; + friend class ACE_Timer_Heap_Iterator_T; + + typedef ACE_Timer_Queue_T INHERITED; + + // = Initialization and termination methods. + /** + * The Constructor creates a heap with specified number of elements. + * This can also take in a upcall functor and freelist (if 0, then + * defaults will be created). + * + * @param size The maximum number of timers that can be + * inserted into the new object. + * @param preallocated Default false, true then all the memory + * for the @c ACE_Timer_Node objects will be pre-allocated. This saves + * time and is more predictable (though it requires more space). + * Otherwise, timer nodes are allocated as needed. + * @param freelist is the freelist of timer nodes. + * @param upcall_functor If 0 Timer Heap will create a default FUNCTOR. + */ + ACE_Timer_Heap_T (size_t size, + bool preallocated = false, + FUNCTOR *upcall_functor = 0, + ACE_Free_List > *freelist = 0); + + /** + * Default constructor. @c upcall_functor is the instance of the + * FUNCTOR to be used by the queue. If @c upcall_functor is 0, Timer + * Heap will create a default FUNCTOR. @c freelist is the freelist of + * timer nodes. If 0, then a default freelist will be created. The default + * size will be ACE_DEFAULT_TIMERS and there will be no preallocation. + */ + ACE_Timer_Heap_T (FUNCTOR *upcall_functor = 0, + ACE_Free_List > *freelist = 0); + + /// Destructor. + virtual ~ACE_Timer_Heap_T (void); + + /// True if heap is empty, else false. + virtual bool is_empty (void) const; + + /// Returns the time of the earliest node in the Timer_Queue. + /// Must be called on a non-empty queue. + virtual const ACE_Time_Value &earliest_time (void) const; + + /** + * Resets the interval of the timer represented by @a timer_id to + * @a interval, which is specified in relative time to the current + * . If @a interval is equal to + * ACE_Time_Value::zero, the timer will become a non-rescheduling + * timer. Returns 0 if successful, -1 if not. + */ + virtual int reset_interval (long timer_id, + const ACE_Time_Value &interval); + + /** + * Cancel all timers associated with @a type. If @a dont_call_handle_close + * is 0then the will be invoked. Returns number of timers + * cancelled. + */ + virtual int cancel (const TYPE &type, + int dont_call_handle_close = 1); + + /** + * Cancel the single timer that matches the @a timer_id value (which + * was returned from the method). If act is non-NULL + * then it will be set to point to the ``magic cookie'' argument + * passed in when the timer was registered. This makes it possible + * to free up the memory and avoid memory leaks. If @a dont_call_handle_close + * is 0 then the will be invoked. Returns 1 if cancellation + * succeeded and 0 if the @a timer_id wasn't found. + */ + virtual int cancel (long timer_id, + const void **act = 0, + int dont_call_handle_close = 1); + + /// Returns a pointer to this ACE_Timer_Queue's iterator. + virtual ACE_Timer_Queue_Iterator_T &iter (void); + + /** + * Removes the earliest node from the queue and returns it. Note that + * the timer is removed from the heap, but is not freed, and its ID + * is not reclaimed. The caller is responsible for calling either + * @c reschedule() or @c free_node() after this function returns. Thus, + * this function is for support of @c ACE_Timer_Queue::expire and + * should not be used unadvisedly in other conditions. + */ + ACE_Timer_Node_T *remove_first (void); + + /// Dump the state of an object. + virtual void dump (void) const; + + /// Reads the earliest node from the queue and returns it. + virtual ACE_Timer_Node_T *get_first (void); + +protected: + + /** + * Schedule a timer that may optionally auto-reset. + * Schedule @a type that will expire at @a future_time, + * which is specified in absolute time. If it expires then @a act is + * passed in as the value to the . If @a interval is != to + * ACE_Time_Value::zero then it is used to reschedule the @a type + * automatically, using relative time to the current . + * This method returns a that uniquely identifies the the + * @a type entry in an internal list. This can be used to + * cancel the timer before it expires. The cancellation ensures + * that are unique up to values of greater than 2 + * billion timers. As long as timers don't stay around longer than + * this there should be no problems with accidentally deleting the + * wrong timer. Returns -1 on failure (which is guaranteed never to + * be a valid ). + */ + virtual long schedule_i (const TYPE &type, + const void *act, + const ACE_Time_Value &future_time, + const ACE_Time_Value &interval); + + /// Reschedule an "interval" ACE_Timer_Node. + virtual void reschedule (ACE_Timer_Node_T *); + + /// Factory method that allocates a new node (uses operator new if + /// we're *not* preallocating, otherwise uses an internal freelist). + virtual ACE_Timer_Node_T *alloc_node (void); + + /** + * Factory method that frees a previously allocated node (uses + * operator delete if we're *not* preallocating, otherwise uses an + * internal freelist). + */ + virtual void free_node (ACE_Timer_Node_T *); + +private: + /// Remove and return the @a sloth ACE_Timer_Node and restore the + /// heap property. + ACE_Timer_Node_T *remove (size_t slot); + + /// Insert @a new_node into the heap and restore the heap property. + void insert (ACE_Timer_Node_T *new_node); + + /** + * Doubles the size of the heap and the corresponding timer_ids array. + * If preallocation is used, will also double the size of the + * preallocated array of ACE_Timer_Nodes. + */ + void grow_heap (void); + + /// Restore the heap property, starting at @a slot. + void reheap_up (ACE_Timer_Node_T *new_node, + size_t slot, + size_t parent); + + /// Restore the heap property, starting at @a slot. + void reheap_down (ACE_Timer_Node_T *moved_node, + size_t slot, + size_t child); + + /// Copy @a moved_node into the @a slot slot of and move + /// @a slot into the corresponding slot in the array. + void copy (size_t slot, ACE_Timer_Node_T *moved_node); + + /** + * Returns a timer id that uniquely identifies this timer. This id + * can be used to cancel a timer via the method. The + * timer id returned from this method will never == -1 to avoid + * conflicts with other failure return values. + */ + long timer_id (void); + + /// Pops and returns a new timer id from the freelist. + long pop_freelist (void); + + /// Pushes @a old_id onto the freelist. + void push_freelist (long old_id); + + /// Maximum size of the heap. + size_t max_size_; + + /// Current size of the heap. + size_t cur_size_; + + /// Number of heap entries in transition (removed from the queue, but + /// not freed) and may be rescheduled or freed. + size_t cur_limbo_; + + /// Iterator used to expire timers. + HEAP_ITERATOR *iterator_; + + /** + * Current contents of the Heap, which is organized as a "heap" of + * ACE_Timer_Node *'s. In this context, a heap is a "partially + * ordered, almost complete" binary tree, which is stored in an + * array. + */ + ACE_Timer_Node_T **heap_; + + /** + * An array of "pointers" that allows each ACE_Timer_Node in the + * to be located in O(1) time. Basically, + * contains the slot in the array where an ACE_Timer_Node + * * with timer id \ resides. Thus, the timer id passed back from + * is really a slot into the array. The + * array serves two purposes: negative values are + * indications of free timer IDs, whereas positive values are + * "pointers" into the array for assigned timer IDs. + */ + ssize_t *timer_ids_; + + /// "Pointer" to the element in the array that was + /// last given out as a timer ID. + size_t timer_ids_curr_; + + /// Index representing the lowest timer ID that has been freed. When + /// the timer_ids_next_ value wraps around, it starts back at this + /// point. + size_t timer_ids_min_free_; + + /** + * If this is non-0, then we preallocate number of + * ACE_Timer_Node objects in order to reduce dynamic allocation + * costs. In auto-growing implementation, this points to the + * last array of nodes allocated. + */ + ACE_Timer_Node_T *preallocated_nodes_; + + /// This points to the head of the freelist, + /// which is organized as a stack. + ACE_Timer_Node_T *preallocated_nodes_freelist_; + + /// Set of pointers to the arrays of preallocated timer nodes. + /// Used to delete the allocated memory when required. + ACE_Unbounded_Set *> preallocated_node_set_; + + // = Don't allow these operations for now. + ACE_UNIMPLEMENTED_FUNC (ACE_Timer_Heap_T (const ACE_Timer_Heap_T &)) + ACE_UNIMPLEMENTED_FUNC (void operator= (const ACE_Timer_Heap_T &)) +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) +#include "ace/Timer_Heap_T.cpp" +#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ + +#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) +#pragma implementation ("Timer_Heap_T.cpp") +#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ + +#include /**/ "ace/post.h" +#endif /* ACE_TIMER_HEAP_T_H */ diff --git a/dep/ACE_wrappers/ace/Timer_List.h b/dep/ACE_wrappers/ace/Timer_List.h new file mode 100644 index 00000000000..f2d9cc2a458 --- /dev/null +++ b/dep/ACE_wrappers/ace/Timer_List.h @@ -0,0 +1,42 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Timer_List.h + * + * $Id: Timer_List.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Doug Schmidt + */ +//============================================================================= + + +#ifndef ACE_TIMER_LIST_H +#define ACE_TIMER_LIST_H +#include /**/ "ace/pre.h" + +#include "ace/Timer_List_T.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +// The following typedefs are here for ease of use and backward +// compatibility. + +typedef ACE_Timer_List_T, + ACE_SYNCH_RECURSIVE_MUTEX> + ACE_Timer_List; + +typedef ACE_Timer_List_Iterator_T, + ACE_SYNCH_RECURSIVE_MUTEX> + ACE_Timer_List_Iterator; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#include /**/ "ace/post.h" +#endif /* ACE_TIMER_LIST_H */ diff --git a/dep/ACE_wrappers/ace/Timer_List_T.cpp b/dep/ACE_wrappers/ace/Timer_List_T.cpp new file mode 100644 index 00000000000..c3b837bb289 --- /dev/null +++ b/dep/ACE_wrappers/ace/Timer_List_T.cpp @@ -0,0 +1,418 @@ +// $Id: Timer_List_T.cpp 80826 2008-03-04 14:51:23Z wotte $ + +#ifndef ACE_TIMER_LIST_T_C +#define ACE_TIMER_LIST_T_C + +#include "ace/Timer_List_T.h" +#include "ace/Guard_T.h" +#include "ace/Log_Msg.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +ACE_RCSID(ace, Timer_List_T, "$Id: Timer_List_T.cpp 80826 2008-03-04 14:51:23Z wotte $") + +// Default Constructor + +template +ACE_Timer_List_Iterator_T::ACE_Timer_List_Iterator_T (List& lst) + : list_ (lst) +{ + this->first(); +} + +template +ACE_Timer_List_Iterator_T::~ACE_Timer_List_Iterator_T (void) +{ +} + +// Positions the iterator at the node right after the dummy node + +template void +ACE_Timer_List_Iterator_T::first (void) +{ + this->current_node_ = this->list_.get_first(); +} + +// Positions the iterator at the next node in the Timer Queue + +template void +ACE_Timer_List_Iterator_T::next (void) +{ + // Make sure that if we are at the end, we don't wrap around + if (! this->isdone()) + this->current_node_ = this->current_node_->get_next (); + if (this->current_node_ == this->list_.head_) + this->current_node_ = 0; +} + +// Returns true when we are at + +template bool +ACE_Timer_List_Iterator_T::isdone (void) const +{ + return this->current_node_ == 0; +} + +// Returns the node at or 0 if we are at the end + +template ACE_Timer_Node_T * +ACE_Timer_List_Iterator_T::item (void) +{ + if (! this->isdone()) + return this->current_node_; + return 0; +} + +/////////////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////////////// + +// Return our instance of the iterator + +template ACE_Timer_Queue_Iterator_T & +ACE_Timer_List_T::iter (void) +{ + this->iterator_->first (); + return *this->iterator_; +} + +// Create an empty list. + +template +ACE_Timer_List_T::ACE_Timer_List_T (FUNCTOR* uf, FreeList* fl) + : Base(uf, fl) + , head_ (new ACE_Timer_Node_T) + , id_counter_ (0) +{ + ACE_TRACE ("ACE_Timer_List_T::ACE_Timer_List_T"); + + this->head_->set_next (this->head_); + this->head_->set_prev (this->head_); + + ACE_NEW (iterator_, Iterator(*this)); +} + + +// Checks if list is empty. + +template bool +ACE_Timer_List_T::is_empty (void) const +{ + ACE_TRACE ("ACE_Timer_List_T::is_empty"); + return this->get_first_i() == 0; +} + + +// Returns earliest time in a non-empty list. + +template const ACE_Time_Value & +ACE_Timer_List_T::earliest_time (void) const +{ + ACE_TRACE ("ACE_Timer_List_T::earliest_time"); + ACE_Timer_Node_T* first = this->get_first_i(); + if (first != 0) + return first->get_timer_value (); + return ACE_Time_Value::zero; +} + + +// Remove all remaining items in the list. + +template +ACE_Timer_List_T::~ACE_Timer_List_T (void) +{ + ACE_TRACE ("ACE_Timer_List_T::~ACE_Timer_List_T"); + ACE_MT (ACE_GUARD (ACE_LOCK, ace_mon, this->mutex_)); + + delete iterator_; + + if (!this->is_empty()) + { + for (ACE_Timer_Node_T* n = this->get_first(); + n != this->head_; + ) + { + this->upcall_functor ().deletion (*this, + n->get_type(), + n->get_act()); + + ACE_Timer_Node_T *next = + n->get_next (); + + this->free_node (n); + + n = next; + } + } + + // delete the dummy node + delete this->head_; +} + +template void +ACE_Timer_List_T::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + ACE_TRACE ("ACE_Timer_List_T::dump"); + ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); + + int count = 0; + + ACE_Timer_Node_T* n = this->get_first_i(); + if (n != 0) { + for (; n != this->head_; n = n->get_next()) { + ++count; + } + } + + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nsize_ = %d"), count)); + ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); +#endif /* ACE_HAS_DUMP */ +} + + +// Reschedule a periodic timer. This function must be called with the +// lock held. + +template void +ACE_Timer_List_T::reschedule (ACE_Timer_Node_T* n) +{ + ACE_TRACE ("ACE_Timer_List_T::reschedule"); + this->schedule_i(n, n->get_timer_value()); +} + + +// Insert a new handler that expires at time future_time; if interval +// is > 0, the handler will be reinvoked periodically. + +template long +ACE_Timer_List_T::schedule_i (const TYPE &type, + const void *act, + const ACE_Time_Value &future_time, + const ACE_Time_Value &interval) +{ + ACE_TRACE ("ACE_Timer_List_T::schedule_i"); + + ACE_Timer_Node_T* n = this->alloc_node(); + + if (n != 0) + { + long id = this->id_counter_++; + + if (id != -1) { + n->set (type, act, future_time, interval, 0, 0, id); + this->schedule_i (n, future_time); + } + return id; + } + + // Failure return + errno = ENOMEM; + return -1; +} + +/// The shared scheduling functionality between schedule() and reschedule() +template void +ACE_Timer_List_T::schedule_i (ACE_Timer_Node_T* n, + const ACE_Time_Value& expire) +{ + if (this->is_empty()) { + n->set_prev(this->head_); + n->set_next(this->head_); + this->head_->set_prev(n); + this->head_->set_next(n); + return; + } + + // We always want to search backwards from the tail of the list, because + // this minimizes the search in the extreme case when lots of timers are + // scheduled for exactly the same time, and it also assumes that most of + // the timers will be scheduled later than existing timers. + ACE_Timer_Node_T* p = this->head_->get_prev(); + while (p != this->head_ && p->get_timer_value() > expire) + p = p->get_prev(); + + // insert after + n->set_prev(p); + n->set_next(p->get_next()); + p->get_next()->set_prev(n); + p->set_next(n); +} + +template +ACE_Timer_Node_T* +ACE_Timer_List_T::find_node (long timer_id) const +{ + ACE_Timer_Node_T* n = this->get_first_i(); + if (n == 0) + return 0; + + for (; n != this->head_; n = n->get_next()) { + if (n->get_timer_id() == timer_id) { + return n; + } + } + return 0; +} + +// Locate and update the inteval on the timer_id +template int +ACE_Timer_List_T::reset_interval (long timer_id, + const ACE_Time_Value &interval) +{ + ACE_TRACE ("ACE_Timer_List_T::reset_interval"); + ACE_MT (ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->mutex_, -1)); + ACE_Timer_Node_T* n = this->find_node(timer_id); + if (n != 0) { + n->set_interval(interval); // The interval will take effect the next time this node is expired. + return 0; + } + return -1; +} + +// Locate and remove the single with a value of +// @a timer_id from the timer queue. +template int +ACE_Timer_List_T::cancel (long timer_id, + const void **act, + int skip_close) +{ + ACE_TRACE ("ACE_Timer_List_T::cancel"); + ACE_MT (ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->mutex_, -1)); + ACE_Timer_Node_T* n = this->find_node(timer_id); + if (n != 0) + { + if (act != 0) + *act = n->get_act (); + + // Call the close hooks. + int cookie = 0; + + // cancel_type() called once per . + this->upcall_functor ().cancel_type (*this, + n->get_type (), + skip_close, + cookie); + + // cancel_timer() called once per . + this->upcall_functor ().cancel_timer (*this, + n->get_type (), + skip_close, + cookie); + + this->cancel_i (n); + + return 1; + } + + return 0; +} + +// Locate and remove all values of from the timer queue. +template int +ACE_Timer_List_T::cancel (const TYPE &type, int skip_close) +{ + ACE_TRACE ("ACE_Timer_List_T::cancel"); + + int num_canceled = 0; // Note : Technically this can overflow. + + int cookie = 0; + + ACE_MT (ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->mutex_, -1)); + + if (!this->is_empty ()) + { + for (ACE_Timer_Node_T* n = this->get_first(); + n != this->head_; + ) + { + if (n->get_type() == type) // Note: Typically Type is an ACE_Event_Handler* + { + ++num_canceled; + + ACE_Timer_Node_T* tmp = n; + n = n->get_next(); + + this->cancel_i (tmp); + } + else + { + n = n->get_next(); + } + } + } + + // Call the close hooks. + + // cancel_type() called once per . + this->upcall_functor ().cancel_type (*this, + type, + skip_close, + cookie); + + for (int i = 0; + i < num_canceled; + ++i) + { + // cancel_timer() called once per . + this->upcall_functor ().cancel_timer (*this, + type, + skip_close, + cookie); + } + + return num_canceled; +} + +template void +ACE_Timer_List_T::unlink (ACE_Timer_Node_T* n) +{ + n->get_prev()->set_next(n->get_next()); + n->get_next()->set_prev(n->get_prev()); + n->set_prev(0); + n->set_next(0); +} + +/// Shared subset of the two cancel() methods. +template void +ACE_Timer_List_T::cancel_i (ACE_Timer_Node_T* n) +{ + this->unlink (n); + this->free_node (n); +} + +// Reads the first node on the list and returns it. +template ACE_Timer_Node_T * +ACE_Timer_List_T::get_first (void) +{ + ACE_TRACE ("ACE_Timer_List_T::get_first"); + return this->get_first_i(); +} + +template ACE_Timer_Node_T * +ACE_Timer_List_T::get_first_i (void) const +{ + ACE_TRACE ("ACE_Timer_List_T::get_first_i"); + ACE_Timer_Node_T* first = this->head_->get_next(); + if (first != this->head_) // Note : is_empty() uses get_first() + return first; + return 0; +} + + +// Removes the first node on the list and returns it. + +template ACE_Timer_Node_T * +ACE_Timer_List_T::remove_first (void) +{ + ACE_TRACE ("ACE_Timer_List_T::remove_first"); + ACE_Timer_Node_T* first = this->get_first(); + if (first != 0) { + this->unlink(first); + return first; + } + return 0; +} + +#endif /* ACE_TIMER_LIST_T_C */ diff --git a/dep/ACE_wrappers/ace/Timer_List_T.h b/dep/ACE_wrappers/ace/Timer_List_T.h new file mode 100644 index 00000000000..cabd47aeaf0 --- /dev/null +++ b/dep/ACE_wrappers/ace/Timer_List_T.h @@ -0,0 +1,226 @@ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file Timer_List_T.h + * + * $Id: Timer_List_T.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Douglas C. Schmidt + */ +//============================================================================= + +#ifndef ACE_TIMER_LIST_T_H +#define ACE_TIMER_LIST_T_H +#include /**/ "ace/pre.h" + +#include "ace/Timer_Queue_T.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +// Forward declaration. +template +class ACE_Timer_List_T; + +/** + * @class ACE_Timer_List_Iterator_T + * + * @brief Iterates over an ACE_Timer_List. + * + * This is a generic iterator that can be used to visit every + * node of a timer queue. + */ +template +class ACE_Timer_List_Iterator_T +: public ACE_Timer_Queue_Iterator_T +{ +public: + typedef ACE_Timer_List_T List; + /// Constructor. + ACE_Timer_List_Iterator_T (List& lst); + + /// Destructor. + virtual ~ACE_Timer_List_Iterator_T (void); + + /// Positions the iterator at the earliest node in the Timer Queue + virtual void first (void); + + /// Positions the iterator at the next node in the Timer Queue + virtual void next (void); + + /// Returns true when there are no more nodes in the sequence + virtual bool isdone (void) const; + + /// Returns the node at the current position in the sequence + virtual ACE_Timer_Node_T *item (void); + +protected: + /// Pointer to the ACE_Timer_List that we are iterating over. + List& list_; + + /// Current position in the ACE_Timer_List + ACE_Timer_Node_T* current_node_; +}; + +/** + * @class ACE_Timer_List_T + * + * @brief Provides a simple implementation of timers. + * + * This implementation uses a linked list of absolute times. + * Therefore, in the average case, scheduling and canceling + * timers is O(N) (where N is the total number of timers) and + * expiring timers is O(K) (where K is the total number of timers + * that are < the current time of day). + * More clever implementations could use a delta-list, a heap, + * or timing wheels, etc. For instance, ACE_Timer_Heap + * is a subclass of ACE_Timer_List that implements a + * heap-based callout queue. For most applications, the + * ACE_Timer_Heap will perform substantially faster than the + * ACE_Timer_List. + */ +template +class ACE_Timer_List_T : public ACE_Timer_Queue_T +{ +public: + /// Type of iterator + typedef ACE_Timer_List_Iterator_T Iterator; + + /// Iterator is a friend + friend class ACE_Timer_List_Iterator_T; + + typedef ACE_Timer_Node_T Node; + /// Type inherited from + typedef ACE_Timer_Queue_T Base; + typedef ACE_Free_List FreeList; + + // = Initialization and termination methods. + /** + * Default constructor. @a upcall_functor is the instance of the + * FUNCTOR to be used by the list. If @a upcall_functor is 0, a + * default FUNCTOR will be created. @a freelist is the freelist of + * timer nodes. If 0, then a default freelist will be created. + */ + ACE_Timer_List_T (FUNCTOR* upcall_functor = 0, FreeList* freelist = 0); + + /// Destructor + virtual ~ACE_Timer_List_T (void); + + /// True if queue is empty, else false. + virtual bool is_empty (void) const; + + /// Returns the time of the earlier node in the ACE_Timer_List. + /// Must be called on a non-empty queue. + virtual const ACE_Time_Value& earliest_time (void) const; + + /** + * Resets the interval of the timer represented by @a timer_id to + * @a interval, which is specified in relative time to the current + * . If @a interval is equal to + * ACE_Time_Value::zero, the timer will become a non-rescheduling + * timer. Returns 0 if successful, -1 if not. + */ + virtual int reset_interval (long timer_id, + const ACE_Time_Value& interval); + + /** + * Cancel all timers associated with @a type. If dont_call_handle_close is 0 + * then the @a functor will be invoked. Returns the number of timers + * cancelled. + */ + virtual int cancel (const TYPE& type, + int dont_call_handle_close = 1); + + /** + * Cancel the single timer that matches the @a timer_id value (which + * was returned from the method). If act is non-NULL + * then it will be set to point to the ``magic cookie'' argument + * passed in when the timer was registered. This makes it possible + * to free up the memory and avoid memory leaks. If is + * 0 then the will be invoked. Returns 1 if cancellation + * succeeded and 0 if the @a timer_id wasn't found. + */ + virtual int cancel (long timer_id, + const void** act = 0, + int dont_call_handle_close = 1); + + /// Returns a pointer to this ACE_Timer_Queue's iterator. + virtual ACE_Timer_Queue_Iterator_T& iter (void); + + /// Removes the earliest node from the queue and returns it + virtual ACE_Timer_Node_T* remove_first (void); + + /// Dump the state of an object. + virtual void dump (void) const; + + /// Reschedule an "interval" ACE_Timer_Node_T. This should be private + /// but for now it needs to be public for + virtual void reschedule (ACE_Timer_Node_T *); + + /// Reads the earliest node from the queue and returns it. + virtual ACE_Timer_Node_T* get_first (void); + +private: + + /** + * Schedule @a type that will expire at @a future_time, which is + * specified in absolute time. If it expires then @a act is passed + * in as the value to the . If @a interval is != to + * ACE_Time_Value::zero then it is used to reschedule the @a type + * automatically, using relative time to the current . + * This method returns a that uniquely identifies the the + * @a type entry in an internal list. This can be used to + * cancel the timer before it expires. The cancellation ensures + * that are unique up to values of greater than 2 + * billion timers. As long as timers don't stay around longer than + * this there should be no problems with accidentally deleting the + * wrong timer. Returns -1 on failure (which is guaranteed never to + * be a valid ). + */ + virtual long schedule_i (const TYPE& type, + const void* act, + const ACE_Time_Value& future_time, + const ACE_Time_Value& interval); + + void schedule_i(ACE_Timer_Node_T* n, const ACE_Time_Value& exp); + + ACE_Timer_Node_T* find_node(long timer_id) const; + + void cancel_i (ACE_Timer_Node_T* n); + + void unlink (ACE_Timer_Node_T* n); + + ACE_Timer_Node_T* get_first_i(void) const; + +private: + + /// Pointer to linked list of . + ACE_Timer_Node_T* head_; + + /// Iterator used to expire timers. + Iterator* iterator_; + + /** + * Keeps track of the timer id that uniquely identifies each timer. + * This id can be used to cancel a timer via the + * method. + */ + long id_counter_; + + // = Don't allow these operations for now. + ACE_UNIMPLEMENTED_FUNC (ACE_Timer_List_T (const ACE_Timer_List_T &)) + ACE_UNIMPLEMENTED_FUNC (void operator= (const ACE_Timer_List_T &)) +}; + +#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) +#include "ace/Timer_List_T.cpp" +#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ + +#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) +#pragma implementation ("Timer_List_T.cpp") +#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ + +#include /**/ "ace/post.h" +#endif /* ACE_TIMER_LIST_T_H */ diff --git a/dep/ACE_wrappers/ace/Timer_Queue.h b/dep/ACE_wrappers/ace/Timer_Queue.h new file mode 100644 index 00000000000..4644aa1b43d --- /dev/null +++ b/dep/ACE_wrappers/ace/Timer_Queue.h @@ -0,0 +1,52 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Timer_Queue.h + * + * $Id: Timer_Queue.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Douglas C. Schmidt + * @author Irfan Pyarali + */ +//============================================================================= + +#ifndef ACE_TIMER_QUEUE_H +#define ACE_TIMER_QUEUE_H + +#include /**/ "ace/pre.h" + +#include "ace/Synch_Traits.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/Timer_Queuefwd.h" +#include "ace/Timer_Queue_T.h" +#if defined (ACE_HAS_THREADS) +# include "ace/Recursive_Thread_Mutex.h" +#else +# include "ace/Null_Mutex.h" +#endif /* ACE_HAS_THREADS */ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +// The following typedef are here for ease of use and backward +// compatibility. +typedef ACE_Timer_Node_Dispatch_Info_T + ACE_Timer_Node_Dispatch_Info; + +typedef ACE_Timer_Node_T + ACE_Timer_Node; + +typedef ACE_Timer_Queue_Iterator_T, + ACE_SYNCH_RECURSIVE_MUTEX> + ACE_Timer_Queue_Iterator; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#include /**/ "ace/post.h" + +#endif /* ACE_TIMER_QUEUE_H */ diff --git a/dep/ACE_wrappers/ace/Timer_Queue_Adapters.cpp b/dep/ACE_wrappers/ace/Timer_Queue_Adapters.cpp new file mode 100644 index 00000000000..f6519ae9efc --- /dev/null +++ b/dep/ACE_wrappers/ace/Timer_Queue_Adapters.cpp @@ -0,0 +1,361 @@ +// $Id: Timer_Queue_Adapters.cpp 80826 2008-03-04 14:51:23Z wotte $ + +#ifndef ACE_TIMER_QUEUE_ADAPTERS_CPP +#define ACE_TIMER_QUEUE_ADAPTERS_CPP + +#include "ace/Timer_Queue_Adapters.h" + +#if defined (ACE_HAS_DEFERRED_TIMER_COMMANDS) +#include "ace/Functor.h" +#endif /* ACE_HAS_DEFERRED_TIMER_COMMANDS */ + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +# if !defined (__ACE_INLINE__) +# include "ace/Timer_Queue_Adapters.inl" +# endif /* __ACE_INLINE__ */ + +#include "ace/Signal.h" +#include "ace/OS_NS_unistd.h" +#include "ace/OS_NS_sys_time.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +template TQ & +ACE_Async_Timer_Queue_Adapter::timer_queue (void) +{ + return this->timer_queue_; +} + +template int +ACE_Async_Timer_Queue_Adapter::cancel (long timer_id, + const void **act) +{ + // Block designated signals. + ACE_Sig_Guard sg (&this->mask_); + ACE_UNUSED_ARG (sg); + + return this->timer_queue_.cancel (timer_id, act); +} + +template int +ACE_Async_Timer_Queue_Adapter::expire (void) +{ + // Block designated signals. + ACE_Sig_Guard sg (&this->mask_); + ACE_UNUSED_ARG (sg); + + return this->timer_queue_.expire (); +} + +template int +ACE_Async_Timer_Queue_Adapter::schedule_ualarm (void) +{ + ACE_Time_Value tv = this->timer_queue_.earliest_time () + - this->timer_queue_.gettimeofday (); + + // Beware of negative times and zero times (which cause problems for + // ). + if (tv < ACE_Time_Value::zero) + tv = ACE_Time_Value (0, 1); + + // @@ This code should be clever enough to avoid updating the + // if we haven't actually changed the earliest time. + // Schedule a new timer. + ACE_OS::ualarm (tv); + return 0; +} + +template long +ACE_Async_Timer_Queue_Adapter::schedule (ACE_Event_Handler *eh, + const void *act, + const ACE_Time_Value &future_time, + const ACE_Time_Value &interval) +{ + ACE_UNUSED_ARG (act); + ACE_UNUSED_ARG (interval); + + // Block designated signals. + ACE_Sig_Guard sg (&this->mask_); + ACE_UNUSED_ARG (sg); + + // @@ We still need to implement interval timers... + long tid = this->timer_queue_.schedule (eh, act, future_time); + + if (tid == -1) + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("%p\n"), + ACE_TEXT ("schedule_timer")), + -1); + + if (this->schedule_ualarm () == -1) + return 0; + + return tid; +} + +template +ACE_Async_Timer_Queue_Adapter::ACE_Async_Timer_Queue_Adapter (ACE_Sig_Set *mask) + // If == 0, block *all* signals when the SIGARLM handler is + // running, else just block those in the mask. + : mask_ (mask) +{ + // The following code is necessary to selectively "block" certain + // signals when SIGALRM is running. Also, we always restart system + // calls that are interrupted by the signals. + + ACE_Sig_Action sa ((ACE_SignalHandler) 0, + this->mask_, + SA_RESTART); + + if (this->sig_handler_.register_handler (SIGALRM, this, &sa) == -1) + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("%p\n"), + ACE_TEXT ("register_handler"))); +} + +// This is the signal handler function for the asynchronous timer +// list. It gets invoked asynchronously when the SIGALRM signal +// occurs. + +template int +ACE_Async_Timer_Queue_Adapter::handle_signal (int signum, + siginfo_t *, + ucontext_t *) +{ + switch (signum) + { + case SIGALRM: + { + // Expire the pending timers. + + // @@ We need to figure out how to implement interval + // timers... + this->timer_queue_.expire (); + + // Only schedule a new timer if there is one in the list. + + // @@ This code should also become smarter to avoid + // unnecessary calls to ualarm(). + if (this->timer_queue_.is_empty () == 0) + return this->schedule_ualarm (); + else + return 0; + /* NOTREACHED */ + } + default: + ACE_ERROR_RETURN ((LM_ERROR, + "unexpected signal %S\n", + signum), + -1); + /* NOTREACHED */ + } +} + +template +ACE_Thread_Timer_Queue_Adapter::ACE_Thread_Timer_Queue_Adapter (ACE_Thread_Manager *tm, + TQ* timer_queue) + : ACE_Task_Base (tm), + timer_queue_(timer_queue), + delete_timer_queue_(false), + condition_ (mutex_), + active_ (true), // Assume that we start in active mode. + thr_id_ (ACE_OS::NULL_thread) +{ + if (timer_queue_ == 0) + { + ACE_NEW (this->timer_queue_, + TQ); + this->delete_timer_queue_ = true; + } +} + +template +ACE_Thread_Timer_Queue_Adapter::~ACE_Thread_Timer_Queue_Adapter (void) +{ + if (this->delete_timer_queue_) + { + delete this->timer_queue_; + this->timer_queue_ = 0; + this->delete_timer_queue_ = false; + } +} + +template ACE_SYNCH_RECURSIVE_MUTEX & +ACE_Thread_Timer_Queue_Adapter::mutex (void) +{ + return this->mutex_; +} + +template long +ACE_Thread_Timer_Queue_Adapter::schedule + (ACE_Event_Handler* handler, + const void *act, + const ACE_Time_Value &future_time, + const ACE_Time_Value &interval) +{ + ACE_GUARD_RETURN (ACE_SYNCH_RECURSIVE_MUTEX, guard, this->mutex_, -1); + + long result = this->timer_queue_->schedule (handler, act, future_time, interval); + this->condition_.signal (); + return result; +} + +template int +ACE_Thread_Timer_Queue_Adapter::cancel (long timer_id, + const void **act) +{ + ACE_GUARD_RETURN (ACE_SYNCH_RECURSIVE_MUTEX, guard, this->mutex_, -1); + + int result = this->timer_queue_->cancel (timer_id, act); + condition_.signal (); + return result; +} + +template void +ACE_Thread_Timer_Queue_Adapter::deactivate (void) +{ + ACE_GUARD (ACE_SYNCH_RECURSIVE_MUTEX, guard, this->mutex_); + + this->active_ = false; + this->condition_.signal (); +} + +template int +ACE_Thread_Timer_Queue_Adapter::svc (void) +{ + ACE_GUARD_RETURN (ACE_SYNCH_RECURSIVE_MUTEX, guard, this->mutex_, -1); + + this->thr_id_ = ACE_Thread::self (); + + // Thread cancellation point, if ACE supports it. + // + // Note: This call generates a warning under Solaris because the header + // file /usr/include/pthread.h redefines the routine argument. This + // is a bug in the Solaris header files and has nothing to do with + // ACE. +# if !defined (ACE_LACKS_PTHREAD_CANCEL) + ACE_PTHREAD_CLEANUP_PUSH (&this->condition_.mutex ().get_nesting_mutex ()); +# endif /* ACE_LACKS_PTHREAD_CANCEL */ + + while (this->active_) + { +# if defined (ACE_HAS_DEFERRED_TIMER_COMMANDS) + // Temporarily suspend ownership of the timer queue mutex in + // order to dispatch deferred execution commands. These + // commands are to be treated as executing in a context + // "external" to the timer queue adapter, and thus must compete + // separately for this lock. + mutex_.release (); + this->dispatch_commands (); + + // Re-acquire ownership of the timer queue mutex in order to + // restore the "internal" timer queue adapter context + mutex_.acquire (); +# endif /* ACE_HAS_DEFERRED_TIMER_COMMANDS */ + + // If the queue is empty, sleep until there is a change on it. + if (this->timer_queue_->is_empty ()) + this->condition_.wait (); + else + { + // Compute the remaining time, being careful not to sleep + // for "negative" amounts of time. + ACE_Time_Value const tv_curr = this->timer_queue_->gettimeofday (); + ACE_Time_Value const tv_earl = this->timer_queue_->earliest_time (); + + if (tv_earl > tv_curr) + { + // The earliest time on the Timer_Queue is in future, so + // use ACE_OS::gettimeofday() to convert the tv to the + // absolute time. + ACE_Time_Value const tv = ACE_OS::gettimeofday () + (tv_earl - tv_curr); + // ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("waiting until %u.%3.3u secs\n"), + // tv.sec(), tv.msec())); + this->condition_.wait (&tv); + } + } + + // Expire timers anyway, at worst this is a no-op. + this->timer_queue_->expire (); + } + + // Thread cancellation point, if ACE supports it. +# if !defined (ACE_LACKS_PTHREAD_CANCEL) + ACE_PTHREAD_CLEANUP_POP (0); +# endif /* ACE_LACKS_PTHREAD_CANCEL */ + + return 0; +} + +template int +ACE_Thread_Timer_Queue_Adapter::activate (long flags, + int , + int , + long priority, + int grp_id, + ACE_Task_Base *task, + ACE_hthread_t [], + void *stack[], + size_t stack_size[], + ACE_thread_t thread_ids[], + const char* thr_name[]) +{ + // Make sure to set this flag in case we were deactivated earlier. + this->active_ = true; + + // Make sure that we only allow a single thread to be spawned for + // our adapter. Otherwise, too many weird things can happen. + return ACE_Task_Base::activate (flags, 1, 0, priority, grp_id, task, 0, + stack, stack_size, thread_ids, thr_name); +} + +# if defined (ACE_HAS_DEFERRED_TIMER_COMMANDS) + +// Enqueues a command object for execution just before waiting on the next +// timer event. This allows deferred execution of commands that cannot +// be performed in the timer event handler context, such as registering +// or cancelling timers on platforms where the timer queue mutex is not +// recursive. + +template int +ACE_Thread_Timer_Queue_Adapter::enqueue_command (ACE_Command_Base *cmd, + COMMAND_ENQUEUE_POSITION pos) +{ + // Serialize access to the command queue. + ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, guard, this->command_mutex_, -1); + + if (pos == ACE_Thread_Timer_Queue_Adapter::TAIL) + return command_queue_.enqueue_tail (cmd); + else + return command_queue_.enqueue_head (cmd); +} + +// Dispatches all command objects enqueued in the most recent event +// handler context. + +template int +ACE_Thread_Timer_Queue_Adapter::dispatch_commands (void) +{ + // Serialize access to the command queue. + ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, guard, this->command_mutex_, -1); + + // loop through the enqueued commands + ACE_Command_Base *cmd = 0; + while (command_queue_.dequeue_head (cmd) == 0) + if (cmd) + { + cmd->execute (); + delete cmd; + } + + return 0; +} + +# endif /* ACE_HAS_DEFERRED_TIMER_COMMANDS */ + +ACE_END_VERSIONED_NAMESPACE_DECL + +#endif /* ACE_TIMER_QUEUE_ADAPTERS_CPP */ diff --git a/dep/ACE_wrappers/ace/Timer_Queue_Adapters.h b/dep/ACE_wrappers/ace/Timer_Queue_Adapters.h new file mode 100644 index 00000000000..e6ef944eab2 --- /dev/null +++ b/dep/ACE_wrappers/ace/Timer_Queue_Adapters.h @@ -0,0 +1,261 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Timer_Queue_Adapters.h + * + * $Id: Timer_Queue_Adapters.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Douglas C. Schmidt and + * Carlos O'Ryan + */ +//============================================================================= + +#ifndef ACE_TIMER_QUEUE_ADAPTERS_H +#define ACE_TIMER_QUEUE_ADAPTERS_H +#include /**/ "ace/pre.h" + +#include "ace/Task.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/Signal.h" +#include "ace/Sig_Handler.h" +#include "ace/Condition_Recursive_Thread_Mutex.h" + +#if defined (ACE_HAS_DEFERRED_TIMER_COMMANDS) +# include "ace/Unbounded_Queue.h" +ACE_BEGIN_VERSIONED_NAMESPACE_DECL +class ACE_Command_Base; +ACE_END_VERSIONED_NAMESPACE_DECL +#endif /* ACE_HAS_DEFERRED_TIMER_COMMANDS */ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +class ACE_Sig_Set; + +/** + * @class ACE_Async_Timer_Queue_Adapter + * + * @brief Adapts an ACE timer queue to be driven asynchronously using signals. + * + * This implementation uses the ACE_OS::ualarm call, to generate + * the SIGARLM signal that is caught by this class. + * + * @note This adapter only works on platforms that support ualarm(). + * POSIX platforms generally do; Windows and some others do not. + * + * @todo This adapter does not automatically reschedule repeating timers. + */ +template +class ACE_Async_Timer_Queue_Adapter : public ACE_Event_Handler +{ +public: + typedef TQ TIMER_QUEUE; + + /// Constructor + /** + * Register the SIGALRM handler. If @a mask == 0 then block all + * signals when @c SIGALRM is run. Otherwise, just block the signals + * indicated in @a mask. + */ + ACE_Async_Timer_Queue_Adapter (ACE_Sig_Set *mask = 0); + + /// Schedule the timer according to the semantics of the + /// ACE_Timer_List. + /** + * This timer gets dispatched via a signal, rather than by a user + * calling expire(). Note that interval timers are not implemented + * yet. + */ + long schedule (ACE_Event_Handler *type, + const void *act, + const ACE_Time_Value &future_time, + const ACE_Time_Value &interval = ACE_Time_Value::zero); + + /// Cancel the @a timer_id and pass back the @a act if an address is + /// passed in. + int cancel (long timer_id, const void **act = 0); + + /// Dispatch all timers with expiry time at or before the current time. + /// Returns the number of timers expired. + int expire (void); + + /// Return a reference to the underlying timer queue. + TQ &timer_queue (void); + +private: + /// Perform the logic to compute the new ualarm(2) setting. + virtual int schedule_ualarm (void); + + /// Called back by @c SIGALRM handler. + virtual int handle_signal (int signum, siginfo_t *, ucontext_t *); + + /// Handler for the @c SIGALRM signal, so that we can access our state + /// without requiring any global variables. + ACE_Sig_Handler sig_handler_; + + /// Implementation of the timer queue (e.g., ACE_Timer_List, + /// ACE_Timer_Heap, etc.). + TQ timer_queue_; + + /// Mask of signals to be blocked when we're servicing @c SIGALRM. + ACE_Sig_Set mask_; +}; + +/** + * @class ACE_Thread_Timer_Queue_Adapter + * + * @brief Adapts an ACE timer queue using a separate thread for dispatching. + * + * This implementation uses a separate thread to dispatch the timers. + * The base queue need not be thread safe; this class takes all the + * necessary locks. + * + * @note This is a case where template parameters will be useful, but + * (IMHO) the effort and portability problems discourage their + * use. + * + */ +template +class ACE_Thread_Timer_Queue_Adapter : public ACE_Task_Base +{ +public: + /// Trait for the underlying queue type. + typedef TQ TIMER_QUEUE; + +# if defined (ACE_HAS_DEFERRED_TIMER_COMMANDS) + + /// Typedef for the position at which to enqueue a deferred + /// execution command. + enum COMMAND_ENQUEUE_POSITION {HEAD, TAIL}; + +# endif /* ACE_HAS_DEFERRED_TIMER_COMMANDS */ + + /// Creates the timer queue. Activation of the task is the user's + /// responsibility. Optionally a pointer to a timer queue can be passed, + /// when no pointer is passed, a TQ is dynamically created + ACE_Thread_Timer_Queue_Adapter (ACE_Thread_Manager * = ACE_Thread_Manager::instance (), + TQ* timer_queue = 0); + + /// Destructor. + virtual ~ACE_Thread_Timer_Queue_Adapter (void); + + /// Schedule the timer according to the semantics of the ; wakes + /// up the dispatching thread. + long schedule (ACE_Event_Handler *handler, + const void *act, + const ACE_Time_Value &future_time, + const ACE_Time_Value &interval = ACE_Time_Value::zero); + + /// Cancel the @a timer_id and return the @a act parameter if an + /// address is passed in. Also wakes up the dispatching thread. + int cancel (long timer_id, const void **act = 0); + + /// Runs the dispatching thread. + virtual int svc (void); + + /// Inform the dispatching thread that it should terminate. + virtual void deactivate (void); + + /// Access the locking mechanism, useful for iteration. + ACE_SYNCH_RECURSIVE_MUTEX &mutex (void); + + /// Set a user-specified timer queue. + int timer_queue (TQ *tq); + + /// Return the current . + TQ *timer_queue (void) const; + + /// Return the thread id of our active object. + ACE_thread_t thr_id (void) const; + + /** + * We override the default activate() method so that we can ensure + * that only a single thread is ever spawned. Otherwise, too many + * weird things can happen... + */ + virtual int activate (long flags = THR_NEW_LWP | THR_JOINABLE, + int n_threads = 1, + int force_active = 0, + long priority = ACE_DEFAULT_THREAD_PRIORITY, + int grp_id = -1, + ACE_Task_Base *task = 0, + ACE_hthread_t thread_handles[] = 0, + void *stack[] = 0, + size_t stack_size[] = 0, + ACE_thread_t thread_ids[] = 0, + const char* thr_name[] = 0); + +# if defined (ACE_HAS_DEFERRED_TIMER_COMMANDS) + + /** + * Enqueues a command object for execution just before waiting on the next + * timer event. This allows deferred execution of commands that cannot + * be performed in the timer event handler context, such as registering + * or cancelling timers on platforms where the timer queue mutex is not + * recursive. + */ + int enqueue_command (ACE_Command_Base *command_, + COMMAND_ENQUEUE_POSITION pos = TAIL); + +# endif /* ACE_HAS_DEFERRED_TIMER_COMMANDS */ + +private: + +# if defined (ACE_HAS_DEFERRED_TIMER_COMMANDS) + /// Dispatches all command objects enqueued in the most + /// recent event handler context. + int dispatch_commands (void); + + /// Queue of commands for deferred execution. + ACE_Unbounded_Queue command_queue_; + + /// The mutual exclusion mechanism for the command queue. + ACE_SYNCH_MUTEX command_mutex_; +# endif /* ACE_HAS_DEFERRED_TIMER_COMMANDS */ + + /// The underlying Timer_Queue. + TQ* timer_queue_; + + /// Keeps track of whether we should delete the timer queue (if we + /// didn't create it, then we don't delete it). + bool delete_timer_queue_; + + /// The mutual exclusion mechanism that is required to use the + /// . + ACE_SYNCH_RECURSIVE_MUTEX mutex_; + + /** + * The dispatching thread sleeps on this condition while waiting to + * dispatch the next timer; it is used to wake it up if there is a + * change on the timer queue. + */ + ACE_SYNCH_RECURSIVE_CONDITION condition_; + + /// When deactivate is called this variable turns to false and the + /// dispatching thread is signalled, to terminate its main loop. + bool active_; + + /// Thread id of our active object task. + ACE_thread_t thr_id_; +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +# include "ace/Timer_Queue_Adapters.inl" +#endif /* __ACE_INLINE__ */ + +#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) +# include "ace/Timer_Queue_Adapters.cpp" +#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ + +#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) +# pragma implementation ("Timer_Queue_Adapters.cpp") +#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ + +#include /**/ "ace/post.h" +#endif /* ACE_TIMER_QUEUE_ADAPTERS_H */ diff --git a/dep/ACE_wrappers/ace/Timer_Queue_Adapters.inl b/dep/ACE_wrappers/ace/Timer_Queue_Adapters.inl new file mode 100644 index 00000000000..77011eacf8b --- /dev/null +++ b/dep/ACE_wrappers/ace/Timer_Queue_Adapters.inl @@ -0,0 +1,29 @@ +// -*- C++ -*- +// +// $Id: Timer_Queue_Adapters.inl 80826 2008-03-04 14:51:23Z wotte $ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +template ACE_INLINE TQ * +ACE_Thread_Timer_Queue_Adapter::timer_queue (void) const +{ + return this->timer_queue_; +} + +template ACE_INLINE int +ACE_Thread_Timer_Queue_Adapter::timer_queue (TQ *tq) +{ + if (this->delete_timer_queue_) + delete this->timer_queue_; + this->timer_queue_ = tq; + this->delete_timer_queue_ = false; + return 0; +} + +template ACE_INLINE ACE_thread_t +ACE_Thread_Timer_Queue_Adapter::thr_id (void) const +{ + return this->thr_id_; +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Timer_Queue_T.cpp b/dep/ACE_wrappers/ace/Timer_Queue_T.cpp new file mode 100644 index 00000000000..58fbf9ad3dc --- /dev/null +++ b/dep/ACE_wrappers/ace/Timer_Queue_T.cpp @@ -0,0 +1,481 @@ +// $Id: Timer_Queue_T.cpp 80826 2008-03-04 14:51:23Z wotte $ + +#ifndef ACE_TIMER_QUEUE_T_CPP +#define ACE_TIMER_QUEUE_T_CPP + +#include "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +/* + * Hook to specialize to add includes + */ +//@@ REACTOR_SPL_INCLUDE_FORWARD_DECL_ADD_HOOK + +#include "ace/Timer_Queue_T.h" +#include "ace/Guard_T.h" +#include "ace/Log_Msg.h" +#include "ace/Reactor_Timer_Interface.h" +#include "ace/Null_Mutex.h" +#include "ace/OS_NS_sys_time.h" + +#if !defined (__ACE_INLINE__) +#include "ace/Timer_Queue_T.inl" +#endif /* __ACE_INLINE__ */ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +// This fudge factor can be overriden for timers that need it, such as on +// Solaris, by defining the ACE_TIMER_SKEW symbol in the appropriate config +// header. +#if !defined (ACE_TIMER_SKEW) +# define ACE_TIMER_SKEW 0 +#endif /* ACE_TIMER_SKEW */ + +template void +ACE_Timer_Node_T::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + ACE_TRACE ("ACE_Timer_Node_T::dump"); + ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nact_ = %x"), this->act_)); + this->timer_value_.dump (); + this->interval_.dump (); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nprev_ = %x"), this->prev_)); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nnext_ = %x"), this->next_)); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\ntimer_id_ = %d\n"), this->timer_id_)); + ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); +#endif /* ACE_HAS_DUMP */ +} + +template +ACE_Timer_Node_T::ACE_Timer_Node_T (void) +{ + ACE_TRACE ("ACE_Timer_Node_T::ACE_Timer_Node_T"); +} + +template +ACE_Timer_Node_T::~ACE_Timer_Node_T (void) +{ + ACE_TRACE ("ACE_Timer_Node_T::~ACE_Timer_Node_T"); +} + +template +ACE_Timer_Queue_Iterator_T::ACE_Timer_Queue_Iterator_T (void) +{ +} + +template +ACE_Timer_Queue_Iterator_T::~ACE_Timer_Queue_Iterator_T (void) +{ +} + +template ACE_Time_Value * +ACE_Timer_Queue_T::calculate_timeout (ACE_Time_Value *max_wait_time) +{ + ACE_TRACE ("ACE_Timer_Queue_T::calculate_timeout"); + ACE_MT (ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->mutex_, max_wait_time)); + + if (this->is_empty ()) + // Nothing on the Timer_Queue, so use whatever the caller gave us. + return max_wait_time; + else + { + ACE_Time_Value const cur_time = this->gettimeofday (); + + if (this->earliest_time () > cur_time) + { + // The earliest item on the Timer_Queue is still in the + // future. Therefore, use the smaller of (1) caller's wait + // time or (2) the delta time between now and the earliest + // time on the Timer_Queue. + + this->timeout_ = this->earliest_time () - cur_time; + if (max_wait_time == 0 || *max_wait_time > timeout_) + return &this->timeout_; + else + return max_wait_time; + } + else + { + // The earliest item on the Timer_Queue is now in the past. + // Therefore, we've got to "poll" the Reactor, i.e., it must + // just check the descriptors and then dispatch timers, etc. + this->timeout_ = ACE_Time_Value::zero; + return &this->timeout_; + } + } +} + +template ACE_Time_Value * +ACE_Timer_Queue_T::calculate_timeout (ACE_Time_Value *max_wait_time, + ACE_Time_Value *the_timeout) +{ + ACE_TRACE ("ACE_Timer_Queue_T::calculate_timeout"); + + if (the_timeout == 0) + return 0; + + if (this->is_empty ()) + { + // Nothing on the Timer_Queue, so use whatever the caller gave us. + if (max_wait_time) + *the_timeout = *max_wait_time; + else + return 0; + } + else + { + ACE_Time_Value cur_time = this->gettimeofday (); + + if (this->earliest_time () > cur_time) + { + // The earliest item on the Timer_Queue is still in the + // future. Therefore, use the smaller of (1) caller's wait + // time or (2) the delta time between now and the earliest + // time on the Timer_Queue. + + *the_timeout = this->earliest_time () - cur_time; + if (!(max_wait_time == 0 || *max_wait_time > *the_timeout)) + *the_timeout = *max_wait_time; + } + else + { + // The earliest item on the Timer_Queue is now in the past. + // Therefore, we've got to "poll" the Reactor, i.e., it must + // just check the descriptors and then dispatch timers, etc. + *the_timeout = ACE_Time_Value::zero; + } + } + return the_timeout; +} + +template void +ACE_Timer_Queue_T::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + ACE_TRACE ("ACE_Timer_Queue_T::dump"); + ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); + this->timeout_.dump (); + this->timer_skew_.dump (); + ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); +#endif /* ACE_HAS_DUMP */ +} + +template +ACE_Timer_Queue_T::ACE_Timer_Queue_T (FUNCTOR *upcall_functor, + ACE_Free_List > *freelist) + : gettimeofday_ (ACE_OS::gettimeofday), + delete_upcall_functor_ (upcall_functor == 0), + delete_free_list_ (freelist == 0), + timer_skew_ (0, ACE_TIMER_SKEW) +{ + ACE_TRACE ("ACE_Timer_Queue_T::ACE_Timer_Queue_T"); + + if (!freelist) + ACE_NEW (free_list_, + (ACE_Locked_Free_List,ACE_Null_Mutex>)); + else + free_list_ = freelist; + + if (!upcall_functor) + ACE_NEW (upcall_functor_, + FUNCTOR); + else + upcall_functor_ = upcall_functor; +} + +template +ACE_Timer_Queue_T::~ACE_Timer_Queue_T (void) +{ + ACE_TRACE ("ACE_Timer_Queue_T::~ACE_Timer_Queue_T"); + + // Cleanup the functor and free_list on the way out + if (this->delete_upcall_functor_) + delete this->upcall_functor_; + + if (this->delete_free_list_) + delete this->free_list_; +} + +template ACE_Timer_Node_T * +ACE_Timer_Queue_T::alloc_node (void) +{ + return this->free_list_->remove (); +} + +template void +ACE_Timer_Queue_T::free_node (ACE_Timer_Node_T *node) +{ + this->free_list_->add (node); +} + +template ACE_LOCK & +ACE_Timer_Queue_T::mutex (void) +{ + return this->mutex_; +} + +template long +ACE_Timer_Queue_T::schedule (const TYPE &type, + const void *act, + const ACE_Time_Value &future_time, + const ACE_Time_Value &interval) +{ + ACE_MT (ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->mutex_, -1)); + + // Schedule the timer. + long const result = + this->schedule_i (type, + act, + future_time, + interval); + + // Return on failure. + if (result == -1) + return result; + + // Inform upcall functor of successful registration. + this->upcall_functor ().registration (*this, + type, + act); + + // Return result; + return result; +} + +// Run the method for all Timers whose values are <= +// . +template int +ACE_Timer_Queue_T::expire (const ACE_Time_Value &cur_time) +{ + ACE_TRACE ("ACE_Timer_Queue_T::expire"); + ACE_MT (ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->mutex_, -1)); + + // Keep looping while there are timers remaining and the earliest + // timer is <= the passed in to the method. + + if (this->is_empty ()) + return 0; + + int number_of_timers_expired = 0; + int result = 0; + + ACE_Timer_Node_Dispatch_Info_T info; + + while ((result = this->dispatch_info_i (cur_time, info)) != 0) + { + const void *upcall_act = 0; + + this->preinvoke (info, cur_time, upcall_act); + + this->upcall (info, cur_time); + + this->postinvoke (info, cur_time, upcall_act); + + ++number_of_timers_expired; + + } + + ACE_UNUSED_ARG (result); + return number_of_timers_expired; +} + +template int +ACE_Timer_Queue_T::dispatch_info_i (const ACE_Time_Value &cur_time, + ACE_Timer_Node_Dispatch_Info_T &info) +{ + ACE_TRACE ("ACE_Timer_Queue_T::dispatch_info_i"); + + if (this->is_empty ()) + return 0; + + ACE_Timer_Node_T *expired = 0; + + if (this->earliest_time () <= cur_time) + { + expired = this->remove_first (); + + // Get the dispatch info + expired->get_dispatch_info (info); + + // Check if this is an interval timer. + if (expired->get_interval () > ACE_Time_Value::zero) + { + // Make sure that we skip past values that have already + // "expired". + do + expired->set_timer_value (expired->get_timer_value () + + expired->get_interval ()); + while (expired->get_timer_value () <= cur_time); + + // Since this is an interval timer, we need to reschedule + // it. + this->reschedule (expired); + } + else + { + // Call the factory method to free up the node. + this->free_node (expired); + } + + return 1; + } + + return 0; +} + +template void +ACE_Timer_Queue_T::return_node (ACE_Timer_Node_T *node) +{ + ACE_MT (ACE_GUARD (ACE_LOCK, ace_mon, this->mutex_)); + this->free_node (node); +} + + +template +ACE_Event_Handler_Handle_Timeout_Upcall::ACE_Event_Handler_Handle_Timeout_Upcall (void) +{ +} + +template +ACE_Event_Handler_Handle_Timeout_Upcall::~ACE_Event_Handler_Handle_Timeout_Upcall (void) +{ +} + +template int +ACE_Event_Handler_Handle_Timeout_Upcall::registration (TIMER_QUEUE &, + ACE_Event_Handler *event_handler, + const void *) +{ + event_handler->add_reference (); + return 0; +} + +template int +ACE_Event_Handler_Handle_Timeout_Upcall::preinvoke (TIMER_QUEUE & /* timer_queue */, + ACE_Event_Handler *event_handler, + const void * /* timer_act */, + int /* recurring_timer */, + const ACE_Time_Value & /* cur_time */, + const void *&upcall_act) +{ + bool const requires_reference_counting = + event_handler->reference_counting_policy ().value () == + ACE_Event_Handler::Reference_Counting_Policy::ENABLED; + + if (requires_reference_counting) + { + event_handler->add_reference (); + + upcall_act = &this->requires_reference_counting_; + } + + return 0; +} + +template int +ACE_Event_Handler_Handle_Timeout_Upcall::postinvoke (TIMER_QUEUE & /* timer_queue */, + ACE_Event_Handler *event_handler, + const void * /* timer_act */, + int /* recurring_timer */, + const ACE_Time_Value & /* cur_time */, + const void *upcall_act) +{ + if (upcall_act == &this->requires_reference_counting_) + { + event_handler->remove_reference (); + } + + return 0; +} + +template int +ACE_Event_Handler_Handle_Timeout_Upcall::timeout (TIMER_QUEUE &timer_queue, + ACE_Event_Handler *event_handler, + const void *act, + int recurring_timer, + const ACE_Time_Value &cur_time) +{ + int requires_reference_counting = 0; + + if (!recurring_timer) + { + requires_reference_counting = + event_handler->reference_counting_policy ().value () == + ACE_Event_Handler::Reference_Counting_Policy::ENABLED; + } + + // Upcall to the s handle_timeout method. + if (event_handler->handle_timeout (cur_time, act) == -1) + { + if (event_handler->reactor_timer_interface ()) + event_handler->reactor_timer_interface ()->cancel_timer (event_handler, 0); + else + timer_queue.cancel (event_handler, 0); // 0 means "call handle_close()". + } + + if (!recurring_timer && + requires_reference_counting) + { + event_handler->remove_reference (); + } + + return 0; +} + +template int +ACE_Event_Handler_Handle_Timeout_Upcall::cancel_type (TIMER_QUEUE &, + ACE_Event_Handler *event_handler, + int dont_call, + int &requires_reference_counting) +{ + requires_reference_counting = + event_handler->reference_counting_policy ().value () == + ACE_Event_Handler::Reference_Counting_Policy::ENABLED; + + // Upcall to the s handle_close method + if (dont_call == 0) + event_handler->handle_close (ACE_INVALID_HANDLE, + ACE_Event_Handler::TIMER_MASK); + + return 0; +} + +template int +ACE_Event_Handler_Handle_Timeout_Upcall::cancel_timer (TIMER_QUEUE &, + ACE_Event_Handler *event_handler, + int, + int requires_reference_counting) +{ + if (requires_reference_counting) + event_handler->remove_reference (); + + return 0; +} + +template int +ACE_Event_Handler_Handle_Timeout_Upcall::deletion (TIMER_QUEUE &timer_queue, + ACE_Event_Handler *event_handler, + const void *) +{ + int requires_reference_counting = 0; + + this->cancel_type (timer_queue, + event_handler, + 0, + requires_reference_counting); + + this->cancel_timer (timer_queue, + event_handler, + 0, + requires_reference_counting); + + return 0; +} + +ACE_END_VERSIONED_NAMESPACE_DECL + +#endif /* ACE_TIMER_QUEUE_T_CPP */ diff --git a/dep/ACE_wrappers/ace/Timer_Queue_T.h b/dep/ACE_wrappers/ace/Timer_Queue_T.h new file mode 100644 index 00000000000..591109c177e --- /dev/null +++ b/dep/ACE_wrappers/ace/Timer_Queue_T.h @@ -0,0 +1,562 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Timer_Queue_T.h + * + * $Id: Timer_Queue_T.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Doug Schmidt + * @author Irfan Pyarali and + * @author Darrell Brunsch + */ +//============================================================================= + +#ifndef ACE_TIMER_QUEUE_T_H +#define ACE_TIMER_QUEUE_T_H +#include /**/ "ace/pre.h" + +#include "ace/Free_List.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/Event_Handler.h" +#include "ace/Time_Value.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +/** + * @class ACE_Timer_Node_Dispatch_Info_T + * + * @brief Maintains generated dispatch information for Timer nodes. + * + */ +template +class ACE_Timer_Node_Dispatch_Info_T +{ +public: + /// The type of object held in the queue + TYPE type_; + + /// Asynchronous completion token associated with the timer. + const void *act_; + + /// Flag to check if the timer is recurring. + int recurring_timer_; +}; + +/** + * @class ACE_Timer_Node_T + * + * @brief Maintains the state associated with a Timer entry. + */ +template +class ACE_Timer_Node_T +{ +public: + /// Default constructor + ACE_Timer_Node_T (void); + + /// Destructor + ~ACE_Timer_Node_T (void); + + /// Useful typedef .. + typedef ACE_Timer_Node_Dispatch_Info_T DISPATCH_INFO; + + /// Singly linked list + void set (const TYPE &type, + const void *a, + const ACE_Time_Value &t, + const ACE_Time_Value &i, + ACE_Timer_Node_T *n, + long timer_id); + + /// Doubly linked list version + void set (const TYPE &type, + const void *a, + const ACE_Time_Value &t, + const ACE_Time_Value &i, + ACE_Timer_Node_T *p, + ACE_Timer_Node_T *n, + long timer_id); + + // = Accessors + + /// Get the type. + TYPE &get_type (void); + + /// Set the type. + void set_type (TYPE &type); + + /// Get the asynchronous completion token. + const void *get_act (void); + + /// Set the asynchronous completion token. + void set_act (void *act); + + /// Get the timer value. + const ACE_Time_Value &get_timer_value (void) const; + + /// Set the timer value. + void set_timer_value (const ACE_Time_Value &timer_value); + + /// Get the timer interval. + const ACE_Time_Value &get_interval (void) const; + + /// Set the timer interval. + void set_interval (const ACE_Time_Value &interval); + + /// Get the previous pointer. + ACE_Timer_Node_T *get_prev (void); + + /// Set the previous pointer. + void set_prev (ACE_Timer_Node_T *prev); + + /// Get the next pointer. + ACE_Timer_Node_T *get_next (void); + + /// Set the next pointer. + void set_next (ACE_Timer_Node_T *next); + + /// Get the timer_id. + long get_timer_id (void) const; + + /// Set the timer_id. + void set_timer_id (long timer_id); + + /// Get the dispatch info. The dispatch information is got + /// through . This form helps us in preventing allocation and + /// deleting data along the criticl path. + /// @@TODO: We may want to have a copying version too, so that our + /// interface will be complete.. + void get_dispatch_info (ACE_Timer_Node_Dispatch_Info_T &info); + + /// Dump the state of an TYPE. + void dump (void) const; + +private: + /// Type of object stored in the Queue + TYPE type_; + + /// Asynchronous completion token associated with the timer. + const void *act_; + + /// Time until the timer expires. + ACE_Time_Value timer_value_; + + /// If this is a periodic timer this holds the time until the next + /// timeout. + ACE_Time_Value interval_; + + /// Pointer to previous timer. + ACE_Timer_Node_T *prev_; + + /// Pointer to next timer. + ACE_Timer_Node_T *next_; + + /// Id of this timer (used to cancel timers before they expire). + long timer_id_; +}; + +/** + * @class ACE_Timer_Queue_Iterator_T + * + * @brief Generic interface for iterating over a subclass of + * ACE_Timer_Queue. + * + * This is a generic iterator that can be used to visit every + * node of a timer queue. Be aware that it isn't guaranteed + * that the transversal will be in order of timeout values. + */ +template +class ACE_Timer_Queue_Iterator_T +{ +public: + // = Initialization and termination methods. + /// Constructor. + ACE_Timer_Queue_Iterator_T (void); + + /// Destructor. + virtual ~ACE_Timer_Queue_Iterator_T (void); + + /// Positions the iterator at the earliest node in the Timer Queue + virtual void first (void) = 0; + + /// Positions the iterator at the next node in the Timer Queue + virtual void next (void) = 0; + + /// Returns true when there are no more nodes in the sequence + virtual bool isdone (void) const = 0; + + /// Returns the node at the current position in the sequence + virtual ACE_Timer_Node_T *item (void) = 0; +}; + +/** + * @class ACE_Timer_Queue_T + * + * @brief Provides an interface to timers. + * + * This is an abstract base class that provides hook for + * implementing specialized policies such as ACE_Timer_List + * and ACE_Timer_Heap. + */ +template +class ACE_Timer_Queue_T +{ +public: + /// Type of Iterator. + typedef ACE_Timer_Queue_Iterator_T ITERATOR; + + // = Initialization and termination methods. + /** + * Default constructor. @a upcall_functor is the instance of the + * FUNCTOR to be used by the queue. If @a upcall_functor is 0, Timer + * Queue will create a default FUNCTOR. @a freelist the freelist of + * timer nodes. If 0, then a default freelist will be created. + */ + ACE_Timer_Queue_T (FUNCTOR *upcall_functor = 0, + ACE_Free_List > *freelist = 0); + + /// Destructor - make virtual for proper destruction of inherited + /// classes. + virtual ~ACE_Timer_Queue_T (void); + + /// True if queue is empty, else false. + virtual bool is_empty (void) const = 0; + + /// Returns the time of the earlier node in the Timer_Queue. Must + /// be called on a non-empty queue. + virtual const ACE_Time_Value &earliest_time (void) const = 0; + + /** + * Schedule @a type that will expire at @a future_time, which is + * specified in absolute time. If it expires then @a act is passed + * in as the value to the . If @a interval is != to + * ACE_Time_Value::zero then it is used to reschedule the @a type + * automatically, using relative time to the current . + * This method returns a that uniquely identifies the the + * @a type entry in an internal list. This can be used to + * cancel the timer before it expires. The cancellation ensures + * that are unique up to values of greater than 2 + * billion timers. As long as timers don't stay around longer than + * this there should be no problems with accidentally deleting the + * wrong timer. Returns -1 on failure (which is guaranteed never to + * be a valid ). + */ + virtual long schedule (const TYPE &type, + const void *act, + const ACE_Time_Value &future_time, + const ACE_Time_Value &interval = ACE_Time_Value::zero); + + /** + * Resets the interval of the timer represented by @a timer_id to + * @a interval, which is specified in relative time to the current + * . If @a interval is equal to + * ACE_Time_Value::zero, the timer will become a non-rescheduling + * timer. Returns 0 if successful, -1 if not. + */ + virtual int reset_interval (long timer_id, + const ACE_Time_Value &interval) = 0; + + /** + * Cancel all timer associated with @a type. If + * @a dont_call_handle_close is 0 then the will be invoked, + * which typically invokes the hook. Returns number + * of timers cancelled. + */ + virtual int cancel (const TYPE &type, + int dont_call_handle_close = 1) = 0; + + /** + * Cancel the single timer that matches the @a timer_id value (which + * was returned from the method). If act is non-NULL + * then it will be set to point to the ``magic cookie'' argument + * passed in when the timer was registered. This makes it possible + * to free up the memory and avoid memory leaks. If + * @a dont_call_handle_close is 0 then the will be invoked, + * which typically calls the hook. Returns 1 if + * cancellation succeeded and 0 if the @a timer_id wasn't found. + */ + virtual int cancel (long timer_id, + const void **act = 0, + int dont_call_handle_close = 1) = 0; + + /** + * Run the for all timers whose values are <= @a current_time. + * This does not account for . Returns the number of + * timers canceled. + */ + virtual int expire (const ACE_Time_Value ¤t_time); + + /** + * Get the dispatch information for a timer whose value is <= @a current_time. + * This does not account for . Returns 1 if + * there is a node whose value <= @a current_time else returns a 0. + * + */ + virtual int dispatch_info (const ACE_Time_Value ¤t_time, + ACE_Timer_Node_Dispatch_Info_T &info); + + /** + * Run the for all timers whose values are <= + * . Also accounts for . + * + * Depending on the resolution of the underlying OS the system calls + * like select()/poll() might return at time different than that is + * specified in the timeout. Suppose the OS guarantees a resolution of t ms. + * The timeline will look like + * + * A B + * | | + * V V + * |-------------|-------------|-------------|-------------| + * t t t t t + * + * + * If you specify a timeout value of A, then the timeout will not occur + * at A but at the next interval of the timer, which is later than + * that is expected. Similarly, if your timeout value is equal to B, + * then the timeout will occur at interval after B. Now depending upon the + * resolution of your timeouts and the accuracy of the timeouts + * needed for your application, you should set the value of + * . In the above case, if you want the timeout A to fire + * no later than A, then you should specify your to be + * A % t. + * + * The timeout value should be specified via the macro ACE_TIMER_SKEW + * in your config.h file. The default value is zero. + * + * Things get interesting if the t before the timeout value B is zero + * i.e your timeout is less than the interval. In that case, you are + * almost sure of not getting the desired timeout behaviour. Maybe you + * should look for a better OS :-) + * + * Returns the number of timers canceled. + */ + + /* virtual */ int expire (void); + + /** + * Returns the current time of day. This method allows different + * implementations of the timer queue to use special high resolution + * timers. + */ + /* virtual */ ACE_Time_Value gettimeofday (void); + + /// Allows applications to control how the timer queue gets the time + /// of day. + void gettimeofday (ACE_Time_Value (*gettimeofday)(void)); + + /// Determine the next event to timeout. Returns @a max if there are + /// no pending timers or if all pending timers are longer than max. + /// This method acquires a lock internally since it modifies internal state. + virtual ACE_Time_Value *calculate_timeout (ACE_Time_Value *max); + + /** + * Determine the next event to timeout. Returns @a max if there are + * no pending timers or if all pending timers are longer than max. + * should be a pointer to storage for the timeout value, + * and this value is also returned. This method does not acquire a + * lock internally since it doesn't modify internal state. If you + * need to call this method when the queue is being modified + * concurrently, however, you should make sure to acquire the + * externally before making the call. + */ + virtual ACE_Time_Value *calculate_timeout (ACE_Time_Value *max, + ACE_Time_Value *the_timeout); + + /// Set the timer skew for the Timer_Queue. + void timer_skew (const ACE_Time_Value &skew); + + /// Get the timer skew for the Timer_Queue. + const ACE_Time_Value &timer_skew (void) const; + + /// Synchronization variable used by the queue + ACE_LOCK &mutex (void); + + /// Accessor to the upcall functor + FUNCTOR &upcall_functor (void); + + /// Returns a pointer to this ACE_Timer_Queue's iterator. + virtual ITERATOR &iter (void) = 0; + + /// Removes the earliest node from the queue and returns it + virtual ACE_Timer_Node_T *remove_first (void) = 0; + + /// Dump the state of a object. + virtual void dump (void) const; + + /// Reads the earliest node from the queue and returns it. + virtual ACE_Timer_Node_T *get_first (void) = 0; + + /// Method used to return a timer node to the queue's ownership + /// after it is returned by a method like . + virtual void return_node (ACE_Timer_Node_T *); + + /// This method will call the preinvoke() on . + void preinvoke (ACE_Timer_Node_Dispatch_Info_T &info, + const ACE_Time_Value &cur_time, + const void *&upcall_act); + + /// This method will call the timeout() on . + void upcall (ACE_Timer_Node_Dispatch_Info_T &info, + const ACE_Time_Value &cur_time); + + /// This method will call the postinvoke() on . + void postinvoke (ACE_Timer_Node_Dispatch_Info_T &info, + const ACE_Time_Value &cur_time, + const void *upcall_act); + +protected: + + /// Schedule a timer. + virtual long schedule_i (const TYPE &type, + const void *act, + const ACE_Time_Value &future_time, + const ACE_Time_Value &interval) = 0; + + /// Reschedule an "interval" ACE_Timer_Node. + virtual void reschedule (ACE_Timer_Node_T *) = 0; + + /// Factory method that allocates a new node. + virtual ACE_Timer_Node_T *alloc_node (void); + + /// Factory method that frees a previously allocated node. + virtual void free_node (ACE_Timer_Node_T *); + + /// Non-locking version of dispatch_info () + virtual int dispatch_info_i (const ACE_Time_Value ¤t_time, + ACE_Timer_Node_Dispatch_Info_T &info); + + /// Synchronization variable for ACE_Timer_Queue. + /// @note The right name would be lock_, but HP/C++ will choke on that! + ACE_LOCK mutex_; + + /// Class that implements a free list + ACE_Free_List > *free_list_; + + /// Pointer to function that returns the current time of day. + ACE_Time_Value (*gettimeofday_)(void); + + /// Upcall functor + FUNCTOR *upcall_functor_; + + /// To delete or not to delete is the question? + bool const delete_upcall_functor_; + + /// Flag to delete only if the class created the + bool const delete_free_list_; + +private: + + /// Returned by . + ACE_Time_Value timeout_; + + /// Adjusts for timer skew in various clocks. + ACE_Time_Value timer_skew_; + + // = Don't allow these operations for now. + ACE_UNIMPLEMENTED_FUNC (ACE_Timer_Queue_T (const ACE_Timer_Queue_T &)) + ACE_UNIMPLEMENTED_FUNC (void operator= (const ACE_Timer_Queue_T &)) +}; + +/** + * @class ACE_Event_Handler_Handle_Timeout_Upcall + * + * @brief Functor for Timer_Queues. + * + * This class implements the functor required by the Timer + * Queue to call on ACE_Event_Handlers. + */ +template +class ACE_Event_Handler_Handle_Timeout_Upcall +{ +public: + typedef ACE_Timer_Queue_T, + ACE_LOCK> + TIMER_QUEUE; + + // = Initialization and termination methods. + /// Constructor. + ACE_Event_Handler_Handle_Timeout_Upcall (void); + + /// Destructor. + ~ACE_Event_Handler_Handle_Timeout_Upcall (void); + + /// This method is called when a timer is registered. + int registration (TIMER_QUEUE &timer_queue, + ACE_Event_Handler *handler, + const void *arg); + + /// This method is called before the timer expires. + int preinvoke (TIMER_QUEUE &timer_queue, + ACE_Event_Handler *handler, + const void *arg, + int recurring_timer, + const ACE_Time_Value &cur_time, + const void *&upcall_act); + + /// This method is called when the timer expires. + int timeout (TIMER_QUEUE &timer_queue, + ACE_Event_Handler *handler, + const void *arg, + int recurring_timer, + const ACE_Time_Value &cur_time); + + /// This method is called after the timer expires. + int postinvoke (TIMER_QUEUE &timer_queue, + ACE_Event_Handler *handler, + const void *arg, + int recurring_timer, + const ACE_Time_Value &cur_time, + const void *upcall_act); + + /// This method is called when a handler is cancelled + int cancel_type (TIMER_QUEUE &timer_queue, + ACE_Event_Handler *handler, + int dont_call, + int &requires_reference_counting); + + /// This method is called when a timer is cancelled + int cancel_timer (TIMER_QUEUE &timer_queue, + ACE_Event_Handler *handler, + int dont_call, + int requires_reference_counting); + + /// This method is called when the timer queue is destroyed and + /// the timer is still contained in it + int deletion (TIMER_QUEUE &timer_queue, + ACE_Event_Handler *handler, + const void *arg); + +private: + + /// Flag indicating that reference counting is required for this + /// event handler upcall. + int requires_reference_counting_; + + // = Don't allow these operations for now. + ACE_UNIMPLEMENTED_FUNC (ACE_Event_Handler_Handle_Timeout_Upcall (const ACE_Event_Handler_Handle_Timeout_Upcall &)) + ACE_UNIMPLEMENTED_FUNC (void operator= (const ACE_Event_Handler_Handle_Timeout_Upcall &)) +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +#include "ace/Timer_Queue_T.inl" +#endif /* __ACE_INLINE__ */ + +#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) +#include "ace/Timer_Queue_T.cpp" +#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ + +#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) +#pragma implementation ("Timer_Queue_T.cpp") +#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ + +#include /**/ "ace/post.h" +#endif /* ACE_TIMER_QUEUE_T_H */ diff --git a/dep/ACE_wrappers/ace/Timer_Queue_T.inl b/dep/ACE_wrappers/ace/Timer_Queue_T.inl new file mode 100644 index 00000000000..7606a2e1f62 --- /dev/null +++ b/dep/ACE_wrappers/ace/Timer_Queue_T.inl @@ -0,0 +1,222 @@ +// -*- C++ -*- +// +// $Id: Timer_Queue_T.inl 80826 2008-03-04 14:51:23Z wotte $ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +template ACE_INLINE void +ACE_Timer_Node_T::set (const TYPE &type, + const void *a, + const ACE_Time_Value &t, + const ACE_Time_Value &i, + ACE_Timer_Node_T *n, + long timer_id) +{ + this->type_ = type; + this->act_ = a; + this->timer_value_ = t; + this->interval_ = i; + this->next_ = n; + this->timer_id_ = timer_id; +} + +template ACE_INLINE void +ACE_Timer_Node_T::set (const TYPE &type, + const void *a, + const ACE_Time_Value &t, + const ACE_Time_Value &i, + ACE_Timer_Node_T *p, + ACE_Timer_Node_T *n, + long timer_id) +{ + this->type_ = type; + this->act_ = a; + this->timer_value_ = t; + this->interval_ = i; + this->prev_ = p; + this->next_ = n; + this->timer_id_ = timer_id; +} + +template ACE_INLINE TYPE & +ACE_Timer_Node_T::get_type (void) +{ + return this->type_; +} + +template ACE_INLINE void +ACE_Timer_Node_T::set_type (TYPE &type) +{ + this->type_ = type; +} + +template ACE_INLINE const void * +ACE_Timer_Node_T::get_act (void) +{ + return this->act_; +} + +template ACE_INLINE void +ACE_Timer_Node_T::set_act (void *act) +{ + this->act_ = act; +} + +template ACE_INLINE const ACE_Time_Value & +ACE_Timer_Node_T::get_timer_value (void) const +{ + return this->timer_value_; +} + +template ACE_INLINE void +ACE_Timer_Node_T::set_timer_value (const ACE_Time_Value &timer_value) +{ + this->timer_value_ = timer_value; +} + +template ACE_INLINE const ACE_Time_Value & +ACE_Timer_Node_T::get_interval (void) const +{ + return this->interval_; +} + +template ACE_INLINE void +ACE_Timer_Node_T::set_interval (const ACE_Time_Value &interval) +{ + this->interval_ = interval; +} + +template ACE_INLINE ACE_Timer_Node_T * +ACE_Timer_Node_T::get_prev (void) +{ + return this->prev_; +} + +template ACE_INLINE void +ACE_Timer_Node_T::set_prev (ACE_Timer_Node_T *prev) +{ + this->prev_ = prev; +} + +template ACE_INLINE ACE_Timer_Node_T * +ACE_Timer_Node_T::get_next (void) +{ + return this->next_; +} + +template ACE_INLINE void +ACE_Timer_Node_T::set_next (ACE_Timer_Node_T *next) +{ + this->next_ = next; +} + +template ACE_INLINE long +ACE_Timer_Node_T::get_timer_id (void) const +{ + return this->timer_id_; +} + +template ACE_INLINE void +ACE_Timer_Node_T::set_timer_id (long timer_id) +{ + this->timer_id_ = timer_id; +} + +template ACE_INLINE void +ACE_Timer_Node_T::get_dispatch_info (ACE_Timer_Node_Dispatch_Info_T &info) +{ + // Yes, do a copy + info.type_ = this->type_; + info.act_ = this->act_; + info.recurring_timer_ = + this->interval_ > ACE_Time_Value::zero; +} + +template ACE_INLINE void +ACE_Timer_Queue_T::timer_skew (const ACE_Time_Value &skew) +{ + timer_skew_ = skew; +} + +template ACE_INLINE const ACE_Time_Value & +ACE_Timer_Queue_T::timer_skew (void) const +{ + return timer_skew_; +} + +template ACE_INLINE int +ACE_Timer_Queue_T::expire (void) +{ + if (!this->is_empty ()) + return this->expire (this->gettimeofday () + timer_skew_); + else + return 0; +} + +template int +ACE_Timer_Queue_T::dispatch_info (const ACE_Time_Value &cur_time, + ACE_Timer_Node_Dispatch_Info_T &info) +{ + ACE_TRACE ("ACE_Timer_Queue_T::dispatch_info"); + ACE_MT (ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->mutex_, 0)); + + return this->dispatch_info_i (cur_time, info); +} + +template ACE_INLINE void +ACE_Timer_Queue_T::upcall (ACE_Timer_Node_Dispatch_Info_T &info, + const ACE_Time_Value &cur_time) +{ + this->upcall_functor ().timeout (*this, + info.type_, + info.act_, + info.recurring_timer_, + cur_time); +} + +template ACE_INLINE void +ACE_Timer_Queue_T::preinvoke (ACE_Timer_Node_Dispatch_Info_T &info, + const ACE_Time_Value &cur_time, + const void *&upcall_act) +{ + this->upcall_functor ().preinvoke (*this, + info.type_, + info.act_, + info.recurring_timer_, + cur_time, + upcall_act); +} + +template ACE_INLINE void +ACE_Timer_Queue_T::postinvoke (ACE_Timer_Node_Dispatch_Info_T &info, + const ACE_Time_Value &cur_time, + const void *upcall_act) +{ + this->upcall_functor ().postinvoke (*this, + info.type_, + info.act_, + info.recurring_timer_, + cur_time, + upcall_act); +} + +template ACE_INLINE ACE_Time_Value +ACE_Timer_Queue_T::gettimeofday (void) +{ + // Invoke gettimeofday via pointer to function. + return this->gettimeofday_ (); +} + +template ACE_INLINE void +ACE_Timer_Queue_T::gettimeofday (ACE_Time_Value (*gettimeofday)(void)) +{ + this->gettimeofday_ = gettimeofday; +} + +template ACE_INLINE FUNCTOR & +ACE_Timer_Queue_T::upcall_functor (void) +{ + return *this->upcall_functor_; +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Timer_Queuefwd.h b/dep/ACE_wrappers/ace/Timer_Queuefwd.h new file mode 100644 index 00000000000..662f29c0411 --- /dev/null +++ b/dep/ACE_wrappers/ace/Timer_Queuefwd.h @@ -0,0 +1,38 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Timer_Queuefwd.h + * + * $Id: Timer_Queuefwd.h 80826 2008-03-04 14:51:23Z wotte $ + * + * Forward declarations and typedefs of ACE_Timer_Queue class. + * + * @author Ossama Othman + */ +//============================================================================= + +#ifndef ACE_TIMER_QUEUE_FWD_H +#define ACE_TIMER_QUEUE_FWD_H + +#include /**/ "ace/pre.h" + +#include "ace/Synch_Traits.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +template class ACE_Timer_Queue_T; +template class ACE_Event_Handler_Handle_Timeout_Upcall; + +class ACE_Event_Handler; + +typedef ACE_Timer_Queue_T, + ACE_SYNCH_RECURSIVE_MUTEX> + ACE_Timer_Queue; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#include /**/ "ace/post.h" + +#endif /* ACE_TIMER_QUEUE_FWD_H */ diff --git a/dep/ACE_wrappers/ace/Timer_Wheel.h b/dep/ACE_wrappers/ace/Timer_Wheel.h new file mode 100644 index 00000000000..21ba8776102 --- /dev/null +++ b/dep/ACE_wrappers/ace/Timer_Wheel.h @@ -0,0 +1,42 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Timer_Wheel.h + * + * $Id: Timer_Wheel.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Darrell Brunsch (brunsch@cs.wustl.edu) + */ +//============================================================================= + + +#ifndef ACE_TIMER_WHEEL_H +#define ACE_TIMER_WHEEL_H +#include /**/ "ace/pre.h" + +#include "ace/Timer_Wheel_T.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +// The following typedefs are here for ease of use and backward +// compatibility. + +typedef ACE_Timer_Wheel_T, + ACE_SYNCH_RECURSIVE_MUTEX> + ACE_Timer_Wheel; + +typedef ACE_Timer_Wheel_Iterator_T, + ACE_SYNCH_RECURSIVE_MUTEX> + ACE_Timer_Wheel_Iterator; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#include /**/ "ace/post.h" +#endif /* ACE_TIMER_WHEEL_H */ diff --git a/dep/ACE_wrappers/ace/Timer_Wheel_T.cpp b/dep/ACE_wrappers/ace/Timer_Wheel_T.cpp new file mode 100644 index 00000000000..f62ca7523f2 --- /dev/null +++ b/dep/ACE_wrappers/ace/Timer_Wheel_T.cpp @@ -0,0 +1,967 @@ +// $Id: Timer_Wheel_T.cpp 80826 2008-03-04 14:51:23Z wotte $ + +#ifndef ACE_TIMER_WHEEL_T_CPP +#define ACE_TIMER_WHEEL_T_CPP + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/OS_NS_sys_time.h" +#include "ace/Guard_T.h" +#include "ace/Timer_Wheel_T.h" +#include "ace/Log_Msg.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +// Design/implementation notes for ACE_Timer_Wheel_T. +// +// Each timer queue entry is represented by a ACE_Timer_Node. +// The timing wheel is divided into a number of "spokes"; there are +// spoke_count_ spokes in the wheel. Each timer is hashed into one of the +// spokes. Entries within each spoke are linked in a double-linked list +// in order of increasing expiration. The first ACE_Timer_Node in each +// spoke is a "dummy node" that marks the end of the list of ACE_Timer_Nodes +// in that spoke. +// +// The timer ID for a scheduled timer is formed by its spoke position in +// the wheel, and the number of timers that have been inserted in that spoke +// since the queue was initialized. N bits of the long timer_id are used +// to determine the spoke, and M bits are used as a counter. +// Each time a Node is inserted into a spoke, it's counter +// is incremented. The count is kept in the timer ID field +// of the dummy root Node. In the event of overflow of the counter, the spoke +// must be searched for each new id to make sure it's not already in use. To +// prevent having to do an exhaustive search each time, we keep extra data +// in the dummy root Node. +/** +* Default Constructor that sets defaults for spoke_count_ and resolution_ +* and doesn't do any preallocation. +* +* @param upcall_functor A pointer to a functor to use instead of the default +* @param freelist A pointer to a freelist to use instead of the default +*/ +template +ACE_Timer_Wheel_T::ACE_Timer_Wheel_T +(FUNCTOR* upcall_functor + , FreeList* freelist + ) +: Base (upcall_functor, freelist) +, spokes_(0) +, spoke_count_(0) // calculated in open_i +, spoke_bits_(0) +, res_bits_ (0) +, earliest_spoke_ (0) +, iterator_(0) +, timer_count_(0) +{ + ACE_TRACE ("ACE_Timer_Wheel_T::ACE_Timer_Wheel_T"); + this->open_i (0, + ACE_DEFAULT_TIMER_WHEEL_SIZE, + ACE_DEFAULT_TIMER_WHEEL_RESOLUTION); +} + +/** +* Constructor that sets up the timing wheel and also may preallocate +* some nodes on the free list +* +* @param spoke_count The number of lists in the timer wheel +* @param resolution The time resolution in milliseconds used by the hashing function +* @param prealloc The number of entries to prealloc in the free_list +* @param upcall_functor A pointer to a functor to use instead of the default +* @param freelist A pointer to a freelist to use instead of the default +*/ +template +ACE_Timer_Wheel_T::ACE_Timer_Wheel_T + (u_int spoke_count, + u_int resolution, + size_t prealloc, + FUNCTOR* upcall_functor, + FreeList* freelist) +: Base (upcall_functor, freelist) +, spokes_ (0) +, spoke_count_ (0) // calculated in open_i +, spoke_bits_ (0) +, res_bits_ (0) +, earliest_spoke_ (0) +, iterator_ (0) +, timer_count_ (0) +{ + ACE_TRACE ("ACE_Timer_Wheel_T::ACE_Timer_Wheel_T"); + this->open_i (prealloc, spoke_count, resolution); +} + +template int +ACE_Timer_Wheel_T::power2bits (int n, + int min_bits, + int max_bits) +{ + int max = (1 << max_bits) - 1; + if (n > max) + return max_bits; + + // count the bits in n. + int i = 0; + int tmp = n; + do + { + tmp >>= 1; + ++i; + } + while (tmp != 0); + + if (i <= min_bits) + return min_bits; + + // Which is nearest? + int a = (1 << i) - n; + int b = (1 << (i - 1)) - n; + if (b < 0) + b = -b; + if (b < a) + return i - 1; + return i; +} + +/** +* Initialize the queue. Uses the established members for all needed +* information. +*/ +template void +ACE_Timer_Wheel_T::open_i + (size_t prealloc, u_int spokes, u_int res) +{ + ACE_TRACE ("ACE_Timer_Wheel_T::open_i"); + + this->gettimeofday (ACE_OS::gettimeofday); + + // Rather than waste bits in our timer id, we might as well round up + // the spoke count to the next power of two - 1 . (i.e 1,3,7,15,...127,etc.) + const int MIN_SPOKE_BITS = 3; // Allow between 8 and 4096 spokes + const int MAX_SPOKE_BITS = 12; + const int MAX_RES_BITS = 20; // 20 is plenty, even on 64 bit platforms. + + this->spoke_bits_ = power2bits (spokes, MIN_SPOKE_BITS, MAX_SPOKE_BITS); + this->res_bits_ = power2bits (res, 1, MAX_RES_BITS); + + this->spoke_count_ = 1 << this->spoke_bits_; + + this->free_list_->resize (prealloc + this->spoke_count_); + + this->wheel_time_.msec (1 << (this->res_bits_ + this->spoke_bits_)); + + ACE_NEW (this->spokes_, ACE_Timer_Node_T* [this->spoke_count_]); + + // Create the root nodes. These will be treated specially + for (u_int i = 0; i < this->spoke_count_; ++i) + { + ACE_Timer_Node_T* root = this->alloc_node (); + root->set (0, 0, ACE_Time_Value::zero, ACE_Time_Value::zero, root, root, 0); + this->spokes_[i] = root; + } + + ACE_NEW (iterator_, Iterator (*this)); +} + +/// Destructor just cleans up its memory +template +ACE_Timer_Wheel_T::~ACE_Timer_Wheel_T (void) +{ + ACE_TRACE ("ACE_Timer_Wheel_T::~ACE_Timer_Wheel_T"); + + delete iterator_; + + for (u_int i = 0; i < this->spoke_count_; ++i) + { + // Free all the nodes starting at the root + ACE_Timer_Node_T* root = this->spokes_[i]; + for (ACE_Timer_Node_T* n = root->get_next (); n != root;) + { + ACE_Timer_Node_T* next = n->get_next (); + this->upcall_functor ().deletion (*this, + n->get_type (), + n->get_act ()); + this->free_node (n); + n = next; + } + delete root; + } + delete[] this->spokes_; +} + +/// Searches for a node by timer_id within one spoke. +template +ACE_Timer_Node_T* +ACE_Timer_Wheel_T::find_spoke_node + (u_int spoke, long timer_id) const +{ + ACE_Timer_Node_T* root = this->spokes_[spoke]; + for (ACE_Timer_Node_T* n = root->get_next (); + n != root; + n = n->get_next ()) + { + if (n->get_timer_id () == timer_id) + return n; + } + return 0; +} + +/// Searches all spokes for a node matching the specified timer_id +/// Uses the spoke encoded in the timer_id as a starting place. +template +ACE_Timer_Node_T* +ACE_Timer_Wheel_T::find_node (long timer_id) const +{ + if (timer_id == -1) + return 0; + + // Search the spoke where timer_id was originally scheduled + u_int spoke_mask = this->spoke_count_ - 1; + u_int start = timer_id & spoke_mask; + ACE_Timer_Node_T* n = this->find_spoke_node (start, timer_id); + if (n != 0) + return n; + + //ACE_ERROR((LM_ERROR, "Node not found in original spoke.\n")); + + // Search the rest of the spokes + for (u_int i = 0; i < this->spoke_count_; ++i) + { + if (i != start) + { // already searched this one + n = this->find_spoke_node (i, timer_id); + if (n != 0) + return n; + } + } + + //ACE_ERROR((LM_ERROR, "Node not found.\n")); + return 0; +} + +/** +* Check to see if the wheel is empty +* +* @return True if empty +*/ +template bool +ACE_Timer_Wheel_T::is_empty (void) const +{ + ACE_TRACE ("ACE_Timer_Wheel_T::is_empty"); + return timer_count_ == 0; +} + + +/** +* @return First (earliest) node in the wheel_'s earliest_spoke_ list +*/ +template const ACE_Time_Value & +ACE_Timer_Wheel_T::earliest_time (void) const +{ + ACE_TRACE ("ACE_Timer_Wheel_T::earliest_time"); + ACE_Timer_Node_T* n = this->get_first_i (); + if (n != 0) + return n->get_timer_value (); + return ACE_Time_Value::zero; +} + +/// Uses a simple hash to find which spoke to use based on when the +/// timer is due to expire. Hopefully the 64bit int operations avoid +/// any overflow problems. +template u_int +ACE_Timer_Wheel_T::calculate_spoke + (const ACE_Time_Value& t) const +{ + return static_cast ((t.msec () >> this->res_bits_) & (this->spoke_count_ - 1)); +} + +/// Generates a unique timer_id for the given spoke. It should be pretty +/// fast until the point where the counter overflows. At that time you +/// have to do exhaustive searches within the spoke to ensure that a particular +/// timer id is not already in use. Some optimizations are in place so +/// that this hopefully doesn't have to happen often. +template long +ACE_Timer_Wheel_T::generate_timer_id (u_int spoke) +{ + + int cnt_bits = sizeof (long) * 8 - this->spoke_bits_; + long max_cnt = ((long)1 << cnt_bits) - 1; + if (spoke == this->spoke_count_) + --max_cnt; // Because -1 is used as a special invalid timer_id. + + ACE_Timer_Node_T* root = this->spokes_[spoke]; + + if (root == root->get_next ()) + root->set_act(0); + + // We use this field to keep track of the next counter value that + // may be in use. Of course it may have expired, so we just use + // this field so that we know when we don't have to check for duplicates +#if defined (ACE_WIN64) + // The cast below is legit... we know that long is shorter than a + // pointer, but are only using it as a 'long' storage area. +# pragma warning(push) +# pragma warning(disable : 4311) +#endif /* ACE_WIN64 */ + long next_cnt = reinterpret_cast (root->get_act ()); +#if defined (ACE_WIN64) +# pragma warning(pop) +#endif /* ACE_WIN64 */ + + // This field is used as a counter instead of a timer_id. + long cnt = root->get_timer_id (); + + if (cnt >= max_cnt && root == root->get_next ()) + { + // Special case when we overflow on an empty spoke. We can just + // wrap the count around without searching for duplicates. We only + // want to do this when the counter overflows, so that we return + // unique timer_id values as often as possible. + root->set_timer_id (1); + return spoke; + } + else if (cnt >= max_cnt) + { // overflow + cnt = 0; // try again starting at zero + } + else if (next_cnt == 0 || cnt < next_cnt) + { + root->set_timer_id (cnt + 1); + return (cnt << this->spoke_bits_) | spoke; + } + + //ACE_ERROR((LM_ERROR, "Timer id overflow. We have to search now.\n")); + + // We've run out of consecutive id numbers so now we have to search + // for a unique id. + // We'll try increasing numbers until we find one that is not in use, + // and we'll record the next highest number so that we can avoid this + // search as often as possible. + for (; cnt < max_cnt - 1; ++cnt) + { + long id = (cnt << this->spoke_bits_) | spoke; + ACE_Timer_Node_T* n = this->find_spoke_node (spoke, id); + if (n == 0) + { + root->set_timer_id (cnt + 1); + // Now we need to find the next highest cnt in use + next_cnt = 0; + for (; n != root; n = n->get_next ()) + { + long tmp = n->get_timer_id () >> this->spoke_bits_; + if (tmp > cnt && (tmp < next_cnt || next_cnt == 0)) + next_cnt = tmp; + } +#if defined (ACE_WIN64) + // The cast below is legit... we know we're storing a long in + // a pointer, but are only using it as a 'long' storage area. +# pragma warning(push) +# pragma warning(disable : 4312) +#endif /* ACE_WIN64 */ + root->set_act (reinterpret_cast (next_cnt)); +#if defined (ACE_WIN64) +# pragma warning(pop) +#endif /* ACE_WIN64 */ + return id; + } + } + + return -1; // We did our best, but the spoke is full. +} + +/** +* Creates a ACE_Timer_Node_T based on the input parameters. Then inserts +* the node into the wheel using reschedule (). Then returns a timer_id. +* +* @param type The data of the timer node +* @param act Asynchronous Completion Token (AKA magic cookie) +* @param future_time The time the timer is scheduled for (absolute time) +* @param interval If not ACE_Time_Value::zero, then this is a periodic +* timer and interval is the time period +* +* @return Unique identifier (can be used to cancel the timer). +* -1 on failure. +*/ +template long +ACE_Timer_Wheel_T::schedule_i (const TYPE& type, + const void* act, + const ACE_Time_Value& future_time, + const ACE_Time_Value& interval) +{ + ACE_TRACE ("ACE_Timer_Wheel_T::schedule_i"); + + ACE_Timer_Node_T* n = this->alloc_node (); + + if (n != 0) + { + u_int spoke = calculate_spoke (future_time); + long id = generate_timer_id (spoke); + + //ACE_ERROR((LM_ERROR, "Scheduling %x spoke:%d id:%d\n", (long) n, spoke, id)); + + if (id != -1) + { + n->set (type, act, future_time, interval, 0, 0, id); + this->schedule_i (n, spoke, future_time); + } + return id; + } + + // Failure return + errno = ENOMEM; + return -1; +} + +/** +* Takes an ACE_Timer_Node and inserts it into the correct position in +* the correct list. Also makes sure to update the earliest time. +* +* @param n The timer node to reschedule +*/ +template void +ACE_Timer_Wheel_T::reschedule (ACE_Timer_Node_T* n) +{ + ACE_TRACE ("ACE_Timer_Wheel_T::reschedule"); + const ACE_Time_Value& expire = n->get_timer_value (); + u_int spoke = calculate_spoke (expire); + this->schedule_i (n, spoke, expire); +} + +/// The shared scheduling functionality between schedule() and reschedule() +template void +ACE_Timer_Wheel_T::schedule_i + (ACE_Timer_Node_T* n, + u_int spoke, + const ACE_Time_Value& expire) +{ + // See if we need to update the earliest time + if (this->is_empty() || expire < this->earliest_time ()) + this->earliest_spoke_ = spoke; + + ACE_Timer_Node_T* root = this->spokes_[spoke]; + ACE_Timer_Node_T* last = root->get_prev (); + + ++timer_count_; + + // If the spoke is empty + if (last == root) { + n->set_prev (root); + n->set_next (root); + root->set_prev (n); + root->set_next (n); + return; + } + + // We always want to search backwards from the tail of the list, because + // this minimizes the search in the extreme case when lots of timers are + // scheduled for exactly the same time + ACE_Timer_Node_T* p = root->get_prev (); + while (p != root && p->get_timer_value () > expire) + p = p->get_prev (); + + // insert after + n->set_prev (p); + n->set_next (p->get_next ()); + p->get_next ()->set_prev (n); + p->set_next (n); +} + + +/** +* Find the timer node by using the id as a pointer. Then use set_interval() +* on the node to update the interval. +* +* @param timer_id The timer identifier +* @param interval The new interval +* +* @return 0 if successful, -1 if no. +*/ +template int +ACE_Timer_Wheel_T::reset_interval (long timer_id, + const ACE_Time_Value &interval + ) +{ + ACE_TRACE ("ACE_Timer_Wheel_T::reset_interval"); + ACE_MT (ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->mutex_, -1)); + ACE_Timer_Node_T* n = this->find_node (timer_id); + if (n != 0) + { + // The interval will take effect the next time this node is expired. + n->set_interval (interval); + return 0; + } + return -1; +} + + +/** +* Goes through every list in the wheel and whenever we find one with the +* correct type value, we remove it and continue. At the end make sure +* we reset the earliest time value in case the earliest timers were +* removed. +* +* @param type The value to search for. +* @param skip_close If this non-zero, the cancellation method of the +* functor will not be called for each cancelled timer. +* +* @return Number of timers cancelled +*/ +template int +ACE_Timer_Wheel_T::cancel (const TYPE& type, int skip_close) +{ + ACE_TRACE ("ACE_Timer_Wheel_T::cancel"); + + int num_canceled = 0; // Note : Technically this can overflow. + int cookie = 0; + + ACE_MT (ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->mutex_, -1)); + + if (!this->is_empty ()) + { + ACE_Timer_Node_T* first = this->get_first (); + ACE_Time_Value last = first->get_timer_value (); + int recalc = 0; + + for (u_int i = 0; i < this->spoke_count_; ++i) + { + ACE_Timer_Node_T* root = this->spokes_[i]; + for (ACE_Timer_Node_T* n = root->get_next (); n != root; ) + { + if (n->get_type () == type) + { + ++num_canceled; + if (n == first) + recalc = 1; + + ACE_Timer_Node_T* tmp = n; + n = n->get_next (); + + this->cancel_i (tmp); + } + else + { + n = n->get_next (); + } + } + } + + if (recalc) + this->recalc_earliest (last); + } + + // Call the close hooks. + + // cancel_type() called once per . + this->upcall_functor ().cancel_type (*this, + type, + skip_close, + cookie); + + for (int i = 0; + i < num_canceled; + ++i) + { + // cancel_timer() called once per . + this->upcall_functor ().cancel_timer (*this, + type, + skip_close, + cookie); + } + + return num_canceled; +} + + +/** +* Cancels the single timer that is specified by the timer_id. In this +* case the timer_id is actually a pointer to the node, so we cast it +* to the node. This can be dangerous if the timer_id is made up +* (or deleted twice) so we do a little sanity check. Finally we update +* the earliest time in case the earliest timer was removed. +* +* @param timer_id Timer Identifier +* @param act Asychronous Completion Token (AKA magic cookie): +* If this is non-zero, stores the magic cookie of +* the cancelled timer here. +* @param skip_close If this non-zero, the cancellation method of the +* functor will not be called. +* +* @return 1 for sucess and 0 if the timer_id wasn't found (or was +* found to be invalid) +*/ +template int +ACE_Timer_Wheel_T::cancel (long timer_id, + const void **act, + int skip_close) +{ + ACE_TRACE ("ACE_Timer_Wheel_T::cancel"); + ACE_MT (ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->mutex_, -1)); + ACE_Timer_Node_T* n = this->find_node (timer_id); + if (n != 0) + { + ACE_Time_Value last = n->get_timer_value (); + + int recalc = (this->get_first_i () == n); + + // Call the close hooks. + int cookie = 0; + + // cancel_type() called once per . + this->upcall_functor ().cancel_type (*this, + n->get_type (), + skip_close, + cookie); + + // cancel_timer() called once per . + this->upcall_functor ().cancel_timer (*this, + n->get_type (), + skip_close, + cookie); + if (act != 0) + *act = n->get_act (); + + this->cancel_i (n); + + if (recalc) + this->recalc_earliest (last); + + return 1; + } + return 0; +} + +/// Shared subset of the two cancel() methods. +template void +ACE_Timer_Wheel_T::cancel_i (ACE_Timer_Node_T* n) +{ + this->unlink (n); + this->free_node (n); +} + +/// There are a few places where we have to figure out which timer +/// will expire next. This method makes the assumption that spokes +/// are always sorted, and that timers are always in the correct spoke +/// determined from their expiration time. +/// The last time is always passed in, even though you can often calculate +/// it as get_first()->get_timer_value(). +template void +ACE_Timer_Wheel_T::recalc_earliest + (const ACE_Time_Value& last) +{ + // This is possible because we use a count for is_empty() + if (this->is_empty ()) + return; + + ACE_Time_Value et = ACE_Time_Value::zero; + u_int es = 0; + u_int spoke = this->earliest_spoke_; + + // We will have to go around the wheel at most one time. + for (u_int i = 0; i < this->spoke_count_; ++i) + { + ACE_Timer_Node_T* root = this->spokes_[spoke]; + ACE_Timer_Node_T* n = root->get_next (); + if (n != root) + { + ACE_Time_Value t = n->get_timer_value (); + if (t < last + this->wheel_time_) + { + this->earliest_spoke_ = spoke; + return; + } + else if (et == ACE_Time_Value::zero || t < et) + { + et = t; + es = spoke; + } + } + if (++spoke >= this->spoke_count_) + spoke = 0; + } + + this->earliest_spoke_ = es; + //ACE_ERROR((LM_ERROR, "We had to search the whole wheel.\n")); +} + +/** +* Dumps out the size of the wheel, the resolution, and the contents +* of the wheel. +*/ +template void +ACE_Timer_Wheel_T::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + ACE_TRACE ("ACE_Timer_Wheel_T::dump"); + ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); + + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("\nspoke_count_ = %d"), this->spoke_count_)); + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("\nresolution_ = %d"), 1 << this->res_bits_)); + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("\nwheel_ = \n"))); + + for (u_int i = 0; i < this->spoke_count_; ++i) + { + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("%d\n"), i)); + ACE_Timer_Node_T* root = this->spokes_[i]; + for (ACE_Timer_Node_T* n = root->get_next (); + n != root; + n = n->get_next ()) + { + n->dump (); + } + } + + ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); +#endif /* ACE_HAS_DUMP */ +} + + +/** +* Removes the earliest node and then find the new +* +* @return The earliest timer node. +*/ +template ACE_Timer_Node_T * +ACE_Timer_Wheel_T::remove_first (void) +{ + ACE_TRACE ("ACE_Timer_Wheel_T::remove_first"); + return remove_first_expired (ACE_Time_Value::max_time); +} + +template void +ACE_Timer_Wheel_T::unlink (ACE_Timer_Node_T* n) +{ + ACE_TRACE ("ACE_Timer_Wheel_T::unlink"); + --timer_count_; + n->get_prev ()->set_next (n->get_next ()); + n->get_next ()->set_prev (n->get_prev ()); + n->set_prev (0); + n->set_next (0); +} + +template ACE_Timer_Node_T * +ACE_Timer_Wheel_T::remove_first_expired (const ACE_Time_Value& now) +{ + ACE_Timer_Node_T* n = this->get_first (); + if (n != 0 && n->get_timer_value() <= now) + { + this->unlink (n); + this->recalc_earliest (n->get_timer_value ()); + return n; + } + return 0; +} + +/** +* Returns the earliest node without removing it +* +* @return The earliest timer node. +*/ +template +ACE_Timer_Node_T* +ACE_Timer_Wheel_T::get_first (void) +{ + ACE_TRACE ("ACE_Timer_Wheel_T::get_first"); + return this->get_first_i (); +} + +template +ACE_Timer_Node_T* +ACE_Timer_Wheel_T::get_first_i (void) const +{ + ACE_Timer_Node_T* root = this->spokes_[this->earliest_spoke_]; + ACE_Timer_Node_T* first = root->get_next (); + if (first != root) + return first; + return 0; +} + + +/** +* @return The iterator +*/ +template +ACE_Timer_Queue_Iterator_T& +ACE_Timer_Wheel_T::iter (void) +{ + this->iterator_->first (); + return *this->iterator_; +} + +/** +* Dummy version of expire to get rid of warnings in Sun CC 4.2 +* Just call the expire of the base class. +*/ +template int +ACE_Timer_Wheel_T::expire () +{ + return ACE_Timer_Queue_T::expire (); +} + +/** +* This is a specialized version of expire that is more suited for the +* internal data representation. +* +* @param cur_time The time to expire timers up to. +* +* @return Number of timers expired +*/ +template int +ACE_Timer_Wheel_T::expire (const ACE_Time_Value& cur_time) +{ + ACE_TRACE ("ACE_Timer_Wheel_T::expire"); + + int expcount = 0; + + ACE_MT (ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->mutex_, -1)); + + ACE_Timer_Node_T* n = this->remove_first_expired (cur_time); + + while (n != 0) + { + ++expcount; + + //ACE_ERROR((LM_ERROR, "Expiring %x\n", (long) n)); + + ACE_Timer_Node_Dispatch_Info_T info; + + // Get the dispatch info + n->get_dispatch_info (info); + + if (n->get_interval () > ACE_Time_Value::zero) + { + // Make sure that we skip past values that have already + // "expired". + do + n->set_timer_value (n->get_timer_value () + + n->get_interval ()); + while (n->get_timer_value () <= cur_time); + + this->reschedule (n); + } + else + { + this->free_node (n); + } + + const void *upcall_act = 0; + + this->preinvoke (info, cur_time, upcall_act); + + this->upcall (info, cur_time); + + this->postinvoke (info, cur_time, upcall_act); + + n = this->remove_first_expired (cur_time); + } + + return expcount; +} + +/////////////////////////////////////////////////////////////////////////// +// ACE_Timer_Wheel_Iterator_T + +/** +* Just initializes the iterator with a ACE_Timer_Wheel_T and then calls +* first() to initialize the rest of itself. +* +* @param wheel A reference for a timer queue to iterate over +*/ +template +ACE_Timer_Wheel_Iterator_T::ACE_Timer_Wheel_Iterator_T +(Wheel& wheel) +: timer_wheel_ (wheel) +{ + this->first(); +} + + +/** +* Destructor, at this level does nothing. +*/ +template +ACE_Timer_Wheel_Iterator_T::~ACE_Timer_Wheel_Iterator_T (void) +{ +} + + +/** +* Positions the iterator at the first position in the timing wheel +* that contains something. spoke_ will be set to the spoke position of +* this entry and current_node_ will point to the first entry in that spoke. +* +* If the wheel is empty, spoke_ will be equal timer_wheel_.spoke_count_ and +* current_node_ would be 0. +*/ +template void +ACE_Timer_Wheel_Iterator_T::first (void) +{ + this->goto_next(0); +} + + +/** +* Positions the iterator at the next node. +*/ +template void +ACE_Timer_Wheel_Iterator_T::next (void) +{ + if (this->isdone()) + return; + + ACE_Timer_Node_T* n = this->current_node_->get_next (); + ACE_Timer_Node_T* root = this->timer_wheel_.spokes_[this->spoke_]; + if (n == root) + this->goto_next (this->spoke_ + 1); + else + this->current_node_ = n; +} + +/// Helper class for common functionality of next() and first() +template void +ACE_Timer_Wheel_Iterator_T::goto_next (u_int start_spoke) +{ + // Find the first non-empty entry. + u_int sc = this->timer_wheel_.spoke_count_; + for (u_int i = start_spoke; i < sc; ++i) + { + ACE_Timer_Node_T* root = this->timer_wheel_.spokes_[i]; + ACE_Timer_Node_T* n = root->get_next (); + if (n != root) + { + this->spoke_ = i; + this->current_node_ = n; + return; + } + } + // empty + this->spoke_ = sc; + this->current_node_ = 0; +} + +/** +* @return True when we there aren't any more items (when current_node_ == 0) +*/ +template bool +ACE_Timer_Wheel_Iterator_T::isdone (void) const +{ + return this->current_node_ == 0; +} + +/** +* @return The node at the current spokeition in the sequence or 0 if the wheel +* is empty +*/ +template ACE_Timer_Node_T * +ACE_Timer_Wheel_Iterator_T::item (void) +{ + return this->current_node_; +} + +ACE_END_VERSIONED_NAMESPACE_DECL + +#endif /* ACE_TIMER_WHEEL_T_CPP */ diff --git a/dep/ACE_wrappers/ace/Timer_Wheel_T.h b/dep/ACE_wrappers/ace/Timer_Wheel_T.h new file mode 100644 index 00000000000..44fffed13e6 --- /dev/null +++ b/dep/ACE_wrappers/ace/Timer_Wheel_T.h @@ -0,0 +1,226 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Timer_Wheel_T.h + * + * $Id: Timer_Wheel_T.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Darrell Brunsch + */ +//============================================================================= + +#ifndef ACE_TIMER_WHEEL_T_H +#define ACE_TIMER_WHEEL_T_H +#include /**/ "ace/pre.h" + +#include "ace/Timer_Queue_T.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +// Forward declaration +template +class ACE_Timer_Wheel_T; + +/** + * @class ACE_Timer_Wheel_Iterator_T + * + * @brief Iterates over an ACE_Timer_Wheel. + * + * This is a generic iterator that can be used to visit every + * node of a timer queue. Be aware that it doesn't traverse + * in the order of timeout values. + */ +template +class ACE_Timer_Wheel_Iterator_T + : public ACE_Timer_Queue_Iterator_T +{ +public: + typedef ACE_Timer_Wheel_T Wheel; + typedef ACE_Timer_Node_T Node; + + /// Constructor + ACE_Timer_Wheel_Iterator_T (Wheel &); + + /// Destructor + ~ACE_Timer_Wheel_Iterator_T (void); + + /// Positions the iterator at the earliest node in the Timer Queue + virtual void first (void); + + /// Positions the iterator at the next node in the Timer Queue + virtual void next (void); + + /// Returns true when there are no more nodes in the sequence + virtual bool isdone (void) const; + + /// Returns the node at the current position in the sequence + virtual ACE_Timer_Node_T* item (void); + +protected: + /// Pointer to the ACE_Timer_List that we are iterating over. + Wheel& timer_wheel_; + + /// Current position in the timing wheel + u_int spoke_; + + /// Pointer to the position in the the th list + ACE_Timer_Node_T* current_node_; +private: + void goto_next(u_int start_spoke); +}; + +/** + * @class ACE_Timer_Wheel_T + * + * @brief Provides a Timing Wheel version of ACE_Timer_Queue. + * + * This implementation uses a hash table of ordered doubly- + * linked lists of absolute times. The enhancements over the + * @c ACE_Timer_List include adding a free list and the ability + * to preallocate nodes. Timer Wheel is based on the timing + * wheel implementation used in Adam M. Costello and + * George Varghese's paper "Redesigning the BSD Callout and + * Timer Facilities" + * (http://dworkin.wustl.edu/~varghese/PAPERS/newbsd.ps.Z) + */ +template +class ACE_Timer_Wheel_T : public ACE_Timer_Queue_T +{ +public: + /// Type of iterator + typedef ACE_Timer_Wheel_Iterator_T Iterator; + /// Iterator is a friend + friend class ACE_Timer_Wheel_Iterator_T; + typedef ACE_Timer_Node_T Node; + /// Type inherited from + typedef ACE_Timer_Queue_T Base; + typedef ACE_Free_List FreeList; + + /// Default constructor + ACE_Timer_Wheel_T (FUNCTOR* upcall_functor = 0, FreeList* freelist = 0); + + /// Constructor with opportunities to set the wheelsize and resolution + ACE_Timer_Wheel_T (u_int spoke_count, + u_int resolution, + size_t prealloc = 0, + FUNCTOR* upcall_functor = 0, + FreeList* freelist = 0); + + /// Destructor + virtual ~ACE_Timer_Wheel_T (void); + + /// True if queue is empty, else false. + virtual bool is_empty (void) const; + + /// Returns the time of the earlier node in the ACE_Timer_Wheel. + /// Must be called on a non-empty queue. + virtual const ACE_Time_Value& earliest_time (void) const; + + /// Changes the interval of a timer (and can make it periodic or non + /// periodic by setting it to ACE_Time_Value::zero or not). + virtual int reset_interval (long timer_id, + const ACE_Time_Value& interval); + + /// Cancel all timer associated with @a type. If is 0 + /// then the will be invoked. Returns number of timers + /// cancelled. + virtual int cancel (const TYPE& type, + int dont_call_handle_close = 1); + + // Cancel a timer, storing the magic cookie in act (if nonzero). + // Calls the functor if dont_call_handle_close is 0 and returns 1 + // on success + virtual int cancel (long timer_id, + const void** act = 0, + int dont_call_handle_close = 1); + + /// Run the for all timers whose values are <= + /// . Also accounts for . Returns + /// the number of timers canceled. + virtual int expire (void); + + // Run the for all timers whose values are <= @a current_time. + // This does not account for . Returns the number of + // timers canceled. + int expire (const ACE_Time_Value& current_time); + + /// Returns a pointer to this 's iterator. + virtual ACE_Timer_Queue_Iterator_T& iter (void); + + /// Removes the earliest node from the queue and returns it + virtual ACE_Timer_Node_T* remove_first (void); + + /// Dump the state of an object. + virtual void dump (void) const; + + /// Reads the earliest node from the queue and returns it. + virtual ACE_Timer_Node_T* get_first (void); + +protected: + + /// Schedules a timer. + virtual long schedule_i (const TYPE& type, + const void* act, + const ACE_Time_Value& future_time, + const ACE_Time_Value& interval); + +private: + // The following are documented in the .cpp file. + ACE_Timer_Node_T* get_first_i (void) const; + ACE_Timer_Node_T* remove_first_expired (const ACE_Time_Value& now); + void open_i (size_t prealloc, u_int spokes, u_int res); + virtual void reschedule (ACE_Timer_Node_T *); + ACE_Timer_Node_T* find_spoke_node(u_int spoke, long timer_id) const; + ACE_Timer_Node_T* find_node(long timer_id) const; + u_int calculate_spoke(const ACE_Time_Value& expire) const; + long generate_timer_id(u_int spoke); + void schedule_i (ACE_Timer_Node_T* n, u_int spoke, const ACE_Time_Value& expire); + void cancel_i (ACE_Timer_Node_T* n); + void unlink (ACE_Timer_Node_T* n); + void recalc_earliest(const ACE_Time_Value& last); + +private: + int power2bits (int n, int min_bits, int max_bits); + + /// Timing Wheel. + ACE_Timer_Node_T** spokes_; + /// Size of the timing wheel. + u_int spoke_count_; + /// Number of timer_id bits used for the spoke + int spoke_bits_; + /// Maximum number of timers per spoke + u_int max_per_spoke_; + /// Resolution (in microsoconds) of the timing wheel. + int res_bits_; + /// Index of the list with the earliest time + u_int earliest_spoke_; + /// Iterator used to expire timers. + Iterator* iterator_; + /// The total amount of time in one iteration of the wheel. (resolution * spoke_count) + ACE_Time_Value wheel_time_; + /// The total number of timers currently scheduled. + u_int timer_count_; + + // = Don't allow these operations for now, don't split into multiple lines + // breaks sun compilers + ACE_UNIMPLEMENTED_FUNC (ACE_Timer_Wheel_T (const ACE_Timer_Wheel_T &)) + ACE_UNIMPLEMENTED_FUNC (void operator= (const ACE_Timer_Wheel_T &)) +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) +#include "ace/Timer_Wheel_T.cpp" +#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ + +#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) +#pragma implementation ("Timer_Wheel_T.cpp") +#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ + +#include /**/ "ace/post.h" +#endif /* ACE_TIMER_WHEEL_T_H */ diff --git a/dep/ACE_wrappers/ace/Token.cpp b/dep/ACE_wrappers/ace/Token.cpp new file mode 100644 index 00000000000..ca2aea12fe0 --- /dev/null +++ b/dep/ACE_wrappers/ace/Token.cpp @@ -0,0 +1,545 @@ +// $Id: Token.cpp 80826 2008-03-04 14:51:23Z wotte $ + +#include "ace/Token.h" + +#if !defined (__ACE_INLINE__) +# include "ace/Token.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(ace, Token, "$Id: Token.cpp 80826 2008-03-04 14:51:23Z wotte $") + +#if defined (ACE_HAS_THREADS) + +#include "ace/Thread.h" +#include "ace/Log_Msg.h" + +#if defined (ACE_TOKEN_DEBUGGING) +// FUZZ: disable check_for_streams_include +#include "ace/streams.h" +#endif /* ACE_TOKEN_DEBUGGING */ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_ALLOC_HOOK_DEFINE(ACE_Token) + +void +ACE_Token::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + ACE_TRACE ("ACE_Token::dump"); + + ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); + + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nthread = %d"), ACE_Thread::self ())); + // @@ Is there a portable way to do this? + // ACE_DEBUG ((LM_DEBUG, "\nowner_ = %d", (long) this->owner_)); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nowner_ addr = %x"), &this->owner_)); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nwaiters_ = %d"), this->waiters_)); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nin_use_ = %d"), this->in_use_)); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nnesting level = %d"), this->nesting_level_)); + ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); +#endif /* ACE_HAS_DUMP */ +} + +ACE_Token::ACE_Token_Queue_Entry::ACE_Token_Queue_Entry (ACE_Thread_Mutex &m, + ACE_thread_t t_id) + : next_ (0), + thread_id_ (t_id), +#if defined (ACE_TOKEN_USES_SEMAPHORE) + cv_ (0), +#else + cv_ (m), +#endif /* ACE_TOKEN_USES_SEMAPHORE */ + runable_ (0) +{ +#if defined (ACE_TOKEN_USES_SEMAPHORE) + ACE_UNUSED_ARG (m); +#endif /* ACE_TOKEN_USES_SEMAPHORE */ + + ACE_TRACE ("ACE_Token::ACE_Token_Queue_Entry::ACE_Token_Queue_Entry"); +} + +ACE_Token::ACE_Token_Queue_Entry::ACE_Token_Queue_Entry (ACE_Thread_Mutex &m, + ACE_thread_t t_id, + ACE_Condition_Attributes &attributes) + : next_ (0), + thread_id_ (t_id), +#if defined (ACE_TOKEN_USES_SEMAPHORE) + cv_ (0), +#else + cv_ (m, attributes), +#endif /* ACE_TOKEN_USES_SEMAPHORE */ + runable_ (0) +{ +#if defined (ACE_TOKEN_USES_SEMAPHORE) + ACE_UNUSED_ARG (m); + ACE_UNUSED_ARG (attributes); +#endif /* ACE_TOKEN_USES_SEMAPHORE */ + + ACE_TRACE ("ACE_Token::ACE_Token_Queue_Entry::ACE_Token_Queue_Entry"); +} + +ACE_Token::ACE_Token_Queue::ACE_Token_Queue (void) + : head_ (0), + tail_ (0) +{ + ACE_TRACE ("ACE_Token::ACE_Token_Queue::ACE_Token_Queue"); +} + +// +// Remove an entry from the list. Must be called with locks held. +// +void +ACE_Token::ACE_Token_Queue::remove_entry (ACE_Token::ACE_Token_Queue_Entry *entry) +{ + ACE_TRACE ("ACE_Token::ACE_Token_Queue::remove_entry"); + ACE_Token_Queue_Entry *curr = 0; + ACE_Token_Queue_Entry *prev = 0; + + if (this->head_ == 0) + return; + + for (curr = this->head_; + curr != 0 && curr != entry; + curr = curr->next_) + prev = curr; + + if (curr == 0) + // Didn't find the entry... + return; + else if (prev == 0) + // Delete at the head. + this->head_ = this->head_->next_; + else + // Delete in the middle. + prev->next_ = curr->next_; + + // We need to update the tail of the list if we've deleted the last + // entry. + if (curr->next_ == 0) + this->tail_ = prev; +} + +// +// Add an entry into the list. Must be called with locks held. +// +void +ACE_Token::ACE_Token_Queue::insert_entry (ACE_Token::ACE_Token_Queue_Entry &entry, + int requeue_position) +{ + if (this->head_ == 0) + { + // No other threads - just add me + this->head_ = &entry; + this->tail_ = &entry; + } + else if (requeue_position == -1) + { + // Insert at the end of the queue. + this->tail_->next_ = &entry; + this->tail_ = &entry; + } + else if (requeue_position == 0) + { + // Insert at head of queue. + entry.next_ = this->head_; + this->head_ = &entry; + } + else + // Insert in the middle of the queue somewhere. + { + // Determine where our thread should go in the queue of waiters. + + ACE_Token::ACE_Token_Queue_Entry *insert_after = this->head_; + while (requeue_position-- && insert_after->next_ != 0) + insert_after = insert_after->next_; + + entry.next_ = insert_after->next_; + + if (entry.next_ == 0) + this->tail_ = &entry; + + insert_after->next_ = &entry; + } +} + +ACE_Token::ACE_Token (const ACE_TCHAR *name, void *any) + : lock_ (name, (ACE_mutexattr_t *) any), + owner_ (ACE_OS::NULL_thread), + in_use_ (0), + waiters_ (0), + nesting_level_ (0), + attributes_ (USYNC_THREAD), + queueing_strategy_ (FIFO) +{ +// ACE_TRACE ("ACE_Token::ACE_Token"); +} + +ACE_Token::~ACE_Token (void) +{ + ACE_TRACE ("ACE_Token::~ACE_Token"); +} + +int +ACE_Token::shared_acquire (void (*sleep_hook_func)(void *), + void *arg, + ACE_Time_Value *timeout, + ACE_Token_Op_Type op_type) +{ + ACE_TRACE ("ACE_Token::shared_acquire"); + ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1); + +#if defined (ACE_TOKEN_DEBUGGING) + this->dump (); +#endif /* ACE_TOKEN_DEBUGGING */ + + ACE_thread_t const thr_id = ACE_Thread::self (); + + // Nobody holds the token. + if (!this->in_use_) + { + // Its mine! + this->in_use_ = op_type; + this->owner_ = thr_id; + return 0; + } + + // + // Someone already holds the token. + // + + // Check if it is us. + if (ACE_OS::thr_equal (thr_id, this->owner_)) + { + ++this->nesting_level_; + return 0; + } + + // Do a quick check for "polling" behavior. + if (timeout != 0 && timeout->sec () == 0 && timeout->usec () == 0) + { + errno = ETIME; + return -1; + } + + // + // We've got to sleep until we get the token. + // + + // Which queue we should end up in... + ACE_Token_Queue *queue = (op_type == ACE_Token::READ_TOKEN + ? &this->readers_ + : &this->writers_); + + // Allocate queue entry on stack. This works since we don't exit + // this method's activation record until we've got the token. + ACE_Token::ACE_Token_Queue_Entry my_entry (this->lock_, + thr_id, + this->attributes_); + queue->insert_entry (my_entry, this->queueing_strategy_); + ++this->waiters_; + + // Execute appropriate callback. (@@ should these + // methods return a success/failure status, and if so, what should + // we do with it?) + int ret = 0; + if (sleep_hook_func) + { + (*sleep_hook_func) (arg); + ++ret; + } + else + { + // Execute virtual method. + this->sleep_hook (); + ++ret; + } + + bool timed_out = false; + bool error = false; + + // Sleep until we've got the token (ignore signals). + do + { + int const result = my_entry.wait (timeout, this->lock_); + + if (result == -1) + { + // Note, this should obey whatever thread-specific interrupt + // policy is currently in place... + if (errno == EINTR) + continue; + +#if defined (ACE_TOKEN_DEBUGGING) + cerr << '(' << ACE_Thread::self () << ')' + << " acquire: " + << (errno == ETIME ? "timed out" : "error occurred") + << endl; +#endif /* ACE_TOKEN_DEBUGGING */ + + // We come here if a timeout occurs or some serious + // ACE_Condition object error. + if (errno == ETIME) + timed_out = true; + else + error = true; + + // Stop the loop. + break; + } + } + while (!ACE_OS::thr_equal (thr_id, this->owner_)); + + // Do this always and irrespective of the result of wait(). + --this->waiters_; + queue->remove_entry (&my_entry); + +#if defined (ACE_TOKEN_DEBUGGING) + ACE_DEBUG ((LM_DEBUG, "(%t) ACE_Token::shared_acquire (UNBLOCKED)\n")); +#endif /* ACE_TOKEN_DEBUGGING */ + + // If timeout occured + if (timed_out) + { + // This thread was still selected to own the token. + if (my_entry.runable_) + { + // Wakeup next waiter since this thread timed out. + this->wakeup_next_waiter (); + } + + // Return error. + return -1; + } + else if (error) + { + // Return error. + return -1; + } + + // If this is a normal wakeup, this thread should be runnable. + ACE_ASSERT (my_entry.runable_); + + return ret; +} + +// By default this is a no-op. + +/* virtual */ +void +ACE_Token::sleep_hook (void) +{ + ACE_TRACE ("ACE_Token::sleep_hook"); +} + +int +ACE_Token::acquire (ACE_Time_Value *timeout) +{ + ACE_TRACE ("ACE_Token::acquire"); + return this->shared_acquire (0, 0, timeout, ACE_Token::WRITE_TOKEN); +} + +// Acquire the token, sleeping until it is obtained or until +// expires. + +int +ACE_Token::acquire (void (*sleep_hook_func)(void *), + void *arg, + ACE_Time_Value *timeout) +{ + ACE_TRACE ("ACE_Token::acquire"); + return this->shared_acquire (sleep_hook_func, arg, timeout, ACE_Token::WRITE_TOKEN); +} + +// Try to renew the token. + +int +ACE_Token::renew (int requeue_position, + ACE_Time_Value *timeout) +{ + ACE_TRACE ("ACE_Token::renew"); + ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1); + +#if defined (ACE_TOKEN_DEBUGGING) + this->dump (); +#endif /* ACE_TOKEN_DEBUGGING */ + // ACE_ASSERT (ACE_OS::thr_equal (ACE_Thread::self (), this->owner_)); + + // Check to see if there are any waiters worth giving up the lock + // for. + + // If no writers and either we are a writer or there are no readers. + if (this->writers_.head_ == 0 && + (this->in_use_ == ACE_Token::WRITE_TOKEN || + this->readers_.head_ == 0)) + // Immediate return. + return 0; + + // We've got to sleep until we get the token again. + + // Determine which queue should this thread go to. + ACE_Token::ACE_Token_Queue *this_threads_queue = + this->in_use_ == ACE_Token::READ_TOKEN ? + &this->readers_ : &this->writers_; + + ACE_Token::ACE_Token_Queue_Entry my_entry (this->lock_, + this->owner_); + + this_threads_queue->insert_entry (my_entry, + // if requeue_position == 0 then we want to go next, + // otherwise use the queueing strategy, which might also + // happen to be 0. + requeue_position == 0 ? 0 : this->queueing_strategy_); + ++this->waiters_; + + // Remember nesting level... + int const save_nesting_level_ = this->nesting_level_; + + // Reset state for new owner. + this->nesting_level_ = 0; + + // Wakeup waiter. + this->wakeup_next_waiter (); + + bool timed_out = false; + bool error = false; + + // Sleep until we've got the token (ignore signals). + do + { + int const result = my_entry.wait (timeout, this->lock_); + + if (result == -1) + { + // Note, this should obey whatever thread-specific interrupt + // policy is currently in place... + if (errno == EINTR) + continue; + +#if defined (ACE_TOKEN_DEBUGGING) + cerr << '(' << ACE_Thread::self () << ')' + << " renew: " + << (errno == ETIME ? "timed out" : "error occurred") + << endl; +#endif /* ACE_TOKEN_DEBUGGING */ + + // We come here if a timeout occurs or some serious + // ACE_Condition object error. + if (errno == ETIME) + timed_out = true; + else + error = true; + + // Stop the loop. + break; + } + } + while (!ACE_OS::thr_equal (my_entry.thread_id_, this->owner_)); + + // Do this always and irrespective of the result of wait(). + --this->waiters_; + this_threads_queue->remove_entry (&my_entry); + +#if defined (ACE_TOKEN_DEBUGGING) + ACE_DEBUG ((LM_DEBUG, "(%t) ACE_Token::renew (UNBLOCKED)\n")); +#endif /* ACE_TOKEN_DEBUGGING */ + + // If timeout occured + if (timed_out) + { + // This thread was still selected to own the token. + if (my_entry.runable_) + { + // Wakeup next waiter since this thread timed out. + this->wakeup_next_waiter (); + } + + // Return error. + return -1; + } + else if (error) + { + // Return error. + return -1; + } + + // If this is a normal wakeup, this thread should be runnable. + ACE_ASSERT (my_entry.runable_); + + // Reinstate nesting level. + this->nesting_level_ = save_nesting_level_; + + return 0; +} + +// Release the current holder of the token (which had +// better be the caller's thread!). + +int +ACE_Token::release (void) +{ + ACE_TRACE ("ACE_Token::release"); + ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1); + +#if defined (ACE_TOKEN_DEBUGGING) + this->dump (); +#endif /* ACE_TOKEN_DEBUGGING */ + + // Nested release... + if (this->nesting_level_ > 0) + --this->nesting_level_; + else + { + // + // Regular release... + // + + // Wakeup waiter. + this->wakeup_next_waiter (); + } + + return 0; +} + +void +ACE_Token::wakeup_next_waiter (void) +{ + ACE_TRACE ("ACE_Token::wakeup_next_waiter"); + + // Reset state for new owner. + this->owner_ = ACE_OS::NULL_thread; + this->in_use_ = 0; + + // Any waiters... + if (this->writers_.head_ == 0 && + this->readers_.head_ == 0) + { + // No more waiters... + return; + } + + // Wakeup next waiter. + ACE_Token_Queue *queue = 0; + + // Writer threads get priority to run first. + if (this->writers_.head_ != 0) + { + this->in_use_ = ACE_Token::WRITE_TOKEN; + queue = &this->writers_; + } + else + { + this->in_use_ = ACE_Token::READ_TOKEN; + queue = &this->readers_; + } + + // Wake up waiter and make it runable. + queue->head_->runable_ = 1; + queue->head_->signal (); + + this->owner_ = queue->head_->thread_id_; +} + +ACE_END_VERSIONED_NAMESPACE_DECL + +#endif /* ACE_HAS_THREADS */ diff --git a/dep/ACE_wrappers/ace/Token.h b/dep/ACE_wrappers/ace/Token.h new file mode 100644 index 00000000000..f46726aa66c --- /dev/null +++ b/dep/ACE_wrappers/ace/Token.h @@ -0,0 +1,376 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Token.h + * + * $Id: Token.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Original author + * @author Karl-Heinz Dorn (kdorn@erlh.siemens.de) + * @author Ported to ACE by + * @author Douglas C. Schmidt (schmidt@cs.wustl.edu) + */ +//============================================================================= + +#ifndef ACE_TOKEN_H +#define ACE_TOKEN_H +#include /**/ "ace/pre.h" + +#include /**/ "ace/ACE_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/Null_Mutex.h" + +#if defined (ACE_HAS_THREADS) + +#include "ace/Thread_Mutex.h" + +#if (defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)) || defined (ACE_HAS_VXTHREADS) +// If platforms support semaphores with timed wait, then we use semaphores instead of c.v. +# define ACE_TOKEN_USES_SEMAPHORE +#endif /* (ACE_WIN32 && !ACE_HAS_WINCE) || VXWORKS */ + +#if defined (ACE_TOKEN_USES_SEMAPHORE) +# include "ace/Semaphore.h" +#endif /* ACE_TOKEN_USES_SEMAPHORE */ + +#include "ace/Condition_Thread_Mutex.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +class ACE_Time_Value; + +/** + * @class ACE_Token + * + * @brief Class that acquires, renews, and releases a synchronization + * token that is serviced in strict FIFO/LIFO ordering and that also + * supports (1) recursion and (2) readers/writer semantics. + * + * This class is a more general-purpose synchronization mechanism + * than many native OS mutexes. For example, it implements + * "recursive mutex" semantics, where a thread that owns the token + * can reacquire it without deadlocking. If the same thread calls + * multiple times, however, it must call an + * equal number of times before the token is actually released. + * Threads that are blocked awaiting the token are serviced in + * strict FIFO/LIFO order as other threads release the token (Solaris + * and Pthread mutexes don't strictly enforce an acquisition + * order). There are two lists within the class. Write + * acquires always have higher priority over read acquires. Which + * means, if you use both write/read operations, care must be + * taken to avoid starvation on the readers. Notice that the + * read/write acquire operations do not have the usual semantic of + * reader/writer locks. Only one reader can acquire the token at + * a time (which is different from the usual reader/writer locks + * where several readers can acquire a lock at the same time as + * long as there is no writer waiting for the lock). We choose + * the names to (1) borrow the semantic to give writers higher + * priority and (2) support a common interface for all locking + * classes in ACE. + */ +class ACE_Export ACE_Token +{ +public: + + /** + * Available queueing strategies. + */ + enum QUEUEING_STRATEGY + { + /// FIFO, First In, First Out. + FIFO = -1, + /// LIFO, Last In, First Out + LIFO = 0 + }; + + // = Initialization and termination. + + /// Constructor + ACE_Token (const ACE_TCHAR *name = 0, void * = 0); + + /// Destructor + virtual ~ACE_Token (void); + + // = Strategies + + /// Retrieve the current queueing strategy. + int queueing_strategy (void); + + /// Set the queueing strategy. + void queueing_strategy (int queueing_strategy); + + // = Synchronization operations. + + /** + * Acquire the token, sleeping until it is obtained or until the + * expiration of @a timeout, which is treated as "absolute" time. If + * some other thread currently holds the token then is + * called before our thread goes to sleep. This can be + * used by the requesting thread to unblock a token-holder that is + * sleeping, e.g., by means of writing to a pipe (the ACE + * ACE_Reactor uses this functionality). Return values: 0 if + * acquires without calling 1 if is + * called. 2 if the token is signaled. -1 if failure or timeout + * occurs (if timeout occurs errno == ETIME) If @a timeout == + * <&ACE_Time_Value::zero> then acquire has polling semantics (and + * does *not* call ). + */ + int acquire (void (*sleep_hook)(void *), + void *arg = 0, + ACE_Time_Value *timeout = 0); + + /** + * This behaves just like the previous method, except that + * it invokes the virtual function called that can be + * overridden by a subclass of ACE_Token. + */ + int acquire (ACE_Time_Value *timeout = 0); + + /** + * This should be overridden by a subclass to define the appropriate + * behavior before goes to sleep. By default, this is a + * no-op... + */ + virtual void sleep_hook (void); + + /** + * An optimized method that efficiently reacquires the token if no + * other threads are waiting. This is useful for situations where + * you don't want to degrade the quality of service if there are + * other threads waiting to get the token. If == + * -1 and there are other threads waiting to obtain the token we are + * queued according to the queueing strategy. If + * > -1 then it indicates how many entries to skip over before + * inserting our thread into the list of waiters (e.g., + * == 0 means "insert at front of the queue"). + * Renew has the rather odd semantics such that if there are other + * waiting threads it will give up the token even if the + * nesting_level_ > 1. I'm not sure if this is really the right + * thing to do (since it makes it possible for shared data to be + * changed unexpectedly) so use with caution... This method + * maintians the original token priority. As in , the + * @a timeout value is an absolute time. + */ + int renew (int requeue_position = 0, + ACE_Time_Value *timeout = 0); + + /// Become interface-compliant with other lock mechanisms (implements + /// a non-blocking ). + int tryacquire (void); + + /// Shuts down the ACE_Token instance. + int remove (void); + + /// Relinquish the token. If there are any waiters then the next one + /// in line gets it. + int release (void); + + /// Behaves like acquire() but at a lower priority. It should probably + /// be called acquire_yield() since the semantics aren't really + /// what's commonly expected for readers/writer locks. See the class + /// documentation above for more details. + int acquire_read (void); + + /// Behaves like acquire() but at a lower priority. It should probably + /// be called acquire_yield() since the semantics aren't really + /// what's commonly expected for readers/writer locks. See the class + /// documentation above for more details. + int acquire_read (void (*sleep_hook)(void *), + void *arg = 0, + ACE_Time_Value *timeout = 0); + + /// Calls acquire(). + int acquire_write (void); + + /// Calls acquire(). + int acquire_write (void (*sleep_hook)(void *), + void *arg = 0, + ACE_Time_Value *timeout = 0); + + /// Lower priority try_acquire(). + int tryacquire_read (void); + + /// Just calls . + int tryacquire_write (void); + + /// Assumes the caller has acquired the token and returns 0. + int tryacquire_write_upgrade (void); + + // = Accessor methods. + + /// Return the number of threads that are currently waiting to get + /// the token. + int waiters (void); + + /// Return the id of the current thread that owns the token. + ACE_thread_t current_owner (void); + + /// Dump the state of an object. + void dump (void) const; + + /// Declare the dynamic allocation hooks. + ACE_ALLOC_HOOK_DECLARE; + + /// The following structure implements a LIFO/FIFO queue of waiter threads + /// that are asleep waiting to obtain the token. + struct ACE_Token_Queue_Entry + { + /// Constructor + ACE_Token_Queue_Entry (ACE_Thread_Mutex &m, + ACE_thread_t t_id); + + /// Constructor using a pre-allocated attributes + ACE_Token_Queue_Entry (ACE_Thread_Mutex &m, + ACE_thread_t t_id, + ACE_Condition_Attributes &attributes); + + /// Entry blocks on the token. + int wait (ACE_Time_Value *timeout, ACE_Thread_Mutex &lock); + + /// Notify (unblock) the entry. + int signal (void); + + /// Pointer to next waiter. + ACE_Token_Queue_Entry *next_; + + /// ACE_Thread id of this waiter. + ACE_thread_t thread_id_; + +#if defined (ACE_TOKEN_USES_SEMAPHORE) + /// ACE_Semaphore object used to wake up waiter when it can run again. + ACE_Semaphore cv_; +#else + /// ACE_Condition object used to wake up waiter when it can run again. + ACE_Condition_Thread_Mutex cv_; +#endif /* ACE_TOKEN_USES_SEMAPHORE */ + + /// Ok to run. + int runable_; + }; + +private: + enum ACE_Token_Op_Type + { + READ_TOKEN = 1, + WRITE_TOKEN + }; + + struct ACE_Token_Queue + { + /// Constructor + ACE_Token_Queue (void); + + /// Remove a waiter from the queue. + void remove_entry (ACE_Token_Queue_Entry *); + + /// Insert a waiter into the queue. + void insert_entry (ACE_Token_Queue_Entry &entry, + int requeue_position = -1); + + /// Head of the list of waiting threads. + ACE_Token_Queue_Entry *head_; + + /// Tail of the list of waiting threads. + ACE_Token_Queue_Entry *tail_; + }; + + /// Implements the and methods above. + int shared_acquire (void (*sleep_hook_func)(void *), + void *arg, + ACE_Time_Value *timeout, + ACE_Token_Op_Type op_type); + + /// Wake next in line for ownership. + void wakeup_next_waiter (void); + + /// A queue of writer threads. + ACE_Token_Queue writers_; + + /// A queue of reader threads. + ACE_Token_Queue readers_; + + /// ACE_Thread_Mutex used to lock internal data structures. + ACE_Thread_Mutex lock_; + + /// Current owner of the token. + ACE_thread_t owner_; + + /// Some thread (i.e., ) is using the token. We need this + /// extra variable to deal with POSIX pthreads madness... + int in_use_; + + /// Number of waiters. + int waiters_; + + /// Current nesting level. + int nesting_level_; + + /// The attributes for the condition variables, optimizes lock time. + ACE_Condition_Attributes attributes_; + + /// Queueing strategy, LIFO/FIFO. + int queueing_strategy_; +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#else + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +class ACE_Export ACE_Token +{ +public: + int queueing_strategy (void) { ACE_NOTSUP_RETURN (-1); } + void queueing_strategy (int /*queueing_strategy*/) { } + int acquire (ACE_Time_Value * = 0) { ACE_NOTSUP_RETURN (-1); } + int tryacquire (void) { ACE_NOTSUP_RETURN (-1); } + int remove (void) { ACE_NOTSUP_RETURN (-1); } + int release (void) { ACE_NOTSUP_RETURN (-1); } +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#endif /* ACE_HAS_THREADS */ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +class ACE_Export ACE_Noop_Token : public ACE_Null_Mutex +{ +public: + /// Queueing strategy + enum QUEUEING_STRATEGY + { + FIFO = -1, + LIFO = 0 + }; + + /// Get queueing strategy. + int queueing_strategy (void); + + /// Set queueing strategy. + void queueing_strategy (int queueing_strategy); + + int renew (int = 0, ACE_Time_Value * =0); + + /// Dump the state of an object. + void dump (void) const; + + /// Declare the dynamic allocation hooks. + ACE_ALLOC_HOOK_DECLARE; +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +#include "ace/Token.inl" +#endif /* __ACE_INLINE__ */ + + +#include /**/ "ace/post.h" +#endif /* ACE_TOKEN_H */ diff --git a/dep/ACE_wrappers/ace/Token.inl b/dep/ACE_wrappers/ace/Token.inl new file mode 100644 index 00000000000..f09a0e6f3de --- /dev/null +++ b/dep/ACE_wrappers/ace/Token.inl @@ -0,0 +1,176 @@ +// -*- C++ -*- +// +// $Id: Token.inl 80826 2008-03-04 14:51:23Z wotte $ + +#include "ace/config-macros.h" + +#if defined (ACE_HAS_THREADS) + +#include "ace/Guard_T.h" +#include "ace/Time_Value.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_INLINE int +ACE_Token::queueing_strategy (void) +{ + return this->queueing_strategy_; +} + +ACE_INLINE void +ACE_Token::queueing_strategy (int queueing_strategy) +{ + this->queueing_strategy_ = queueing_strategy == -1 ? -1 : 0; +} + +ACE_INLINE int +ACE_Token::remove (void) +{ + ACE_TRACE ("ACE_Token::remove"); + // Don't have an implementation for this yet... + ACE_NOTSUP_RETURN (-1); +} + +ACE_INLINE int +ACE_Token::tryacquire (void) +{ + ACE_TRACE ("ACE_Token::tryacquire"); + return this->shared_acquire + (0, 0, (ACE_Time_Value *) &ACE_Time_Value::zero, ACE_Token::WRITE_TOKEN); +} + +ACE_INLINE int +ACE_Token::waiters (void) +{ + ACE_TRACE ("ACE_Token::waiters"); + ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1); + + int const ret = this->waiters_; + return ret; +} + +ACE_INLINE ACE_thread_t +ACE_Token::current_owner (void) +{ + ACE_TRACE ("ACE_Token::current_owner"); + ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, this->owner_); + + return this->owner_; +} + +ACE_INLINE int +ACE_Token::acquire_read (void) +{ + ACE_TRACE ("ACE_Token::acquire_read"); + return this->shared_acquire + (0, 0, 0, ACE_Token::READ_TOKEN); +} + +ACE_INLINE int +ACE_Token::acquire_write (void) +{ + ACE_TRACE ("ACE_Token::acquire_write"); + return this->shared_acquire + (0, 0, 0, ACE_Token::WRITE_TOKEN); +} + +ACE_INLINE int +ACE_Token::tryacquire_read (void) +{ + ACE_TRACE ("ACE_Token::tryacquire_read"); + return this->shared_acquire + (0, 0, (ACE_Time_Value *) &ACE_Time_Value::zero, ACE_Token::READ_TOKEN); +} + +ACE_INLINE int +ACE_Token::acquire_read (void (*sleep_hook_func)(void *), + void *arg, + ACE_Time_Value *timeout) +{ + ACE_TRACE ("ACE_Token::acquire_read"); + return this->shared_acquire (sleep_hook_func, arg, timeout, ACE_Token::READ_TOKEN); +} + +ACE_INLINE int +ACE_Token::tryacquire_write (void) +{ + ACE_TRACE ("ACE_Token::tryacquire_write"); + return this->shared_acquire + (0, 0, (ACE_Time_Value *) &ACE_Time_Value::zero, ACE_Token::WRITE_TOKEN); +} + +ACE_INLINE int +ACE_Token::tryacquire_write_upgrade (void) +{ + ACE_TRACE ("ACE_Token::tryacquire_write_upgrade"); + return 0; +} + +ACE_INLINE int +ACE_Token::acquire_write (void (*sleep_hook_func)(void *), + void *arg, + ACE_Time_Value *timeout) +{ + ACE_TRACE ("ACE_Token::acquire_write"); + return this->shared_acquire (sleep_hook_func, arg, timeout, ACE_Token::WRITE_TOKEN); +} + +ACE_INLINE int +ACE_Token::ACE_Token_Queue_Entry::wait (ACE_Time_Value *timeout, ACE_Thread_Mutex &lock) +{ +#if defined (ACE_TOKEN_USES_SEMAPHORE) + lock.release (); + int const retv = (timeout == 0 ? + this->cv_.acquire () : + this->cv_.acquire (*timeout)); + lock.acquire (); + return retv; +#else + ACE_UNUSED_ARG (lock); + return this->cv_.wait (timeout); +#endif /* ACE_TOKEN_USES_SEMAPHORE */ +} + +ACE_INLINE int +ACE_Token::ACE_Token_Queue_Entry::signal (void) +{ + return +#if defined (ACE_TOKEN_USES_SEMAPHORE) + this->cv_.release (); +#else + this->cv_.signal (); +#endif /* ACE_TOKEN_USES_SEMAPHORE */ +} + +ACE_END_VERSIONED_NAMESPACE_DECL + +#endif /* ACE_HAS_THREADS */ + +/*****************************************************************************/ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_INLINE int +ACE_Noop_Token::queueing_strategy (void) +{ + return -1; +} + +ACE_INLINE void +ACE_Noop_Token::queueing_strategy (int /* queueing_strategy */) +{ +} + +ACE_INLINE int +ACE_Noop_Token::renew (int, ACE_Time_Value *) +{ + return 0; +} + +ACE_INLINE void +ACE_Noop_Token::dump (void) const +{ +} + +ACE_END_VERSIONED_NAMESPACE_DECL + diff --git a/dep/ACE_wrappers/ace/Token_Collection.cpp b/dep/ACE_wrappers/ace/Token_Collection.cpp new file mode 100644 index 00000000000..23a5813c958 --- /dev/null +++ b/dep/ACE_wrappers/ace/Token_Collection.cpp @@ -0,0 +1,294 @@ +#include "ace/Token_Collection.h" + +#if defined (ACE_HAS_TOKENS_LIBRARY) + +#if !defined (__ACE_INLINE__) +#include "ace/Token_Collection.inl" +#endif /* __ACE_INLINE__ */ + + +ACE_RCSID (ace, + Token_Collection, + "$Id: Token_Collection.cpp 80826 2008-03-04 14:51:23Z wotte $") + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_Token_Collection::ACE_Token_Collection (bool debug, + const ACE_TCHAR *name) +: debug_ (debug) +{ + ACE_TRACE ("ACE_Token_Collection::ACE_Token_Collection"); + + if (name == 0) + name = ACE_TEXT ("no name"); + + ACE_OS::strsncpy (this->name_, + const_cast (name), + ACE_MAXTOKENNAMELEN); +} + +int +ACE_Token_Collection::insert (ACE_Token_Proxy &new_token) +{ + ACE_TRACE ("ACE_Token_Collection::insert"); + + TOKEN_NAME name (new_token.name ()); + + // Check if the new_proxy is already in the list. + if (collection_.find (name) == 1) + // One already exists, so fail. + return -1; + + // Clone the new token. + ACE_Token_Proxy *temp = new_token.clone (); + + if (collection_.bind (name, temp) == -1) + ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("bind failed\n")), -1); + return 0; +} + +int +ACE_Token_Collection::extract (const ACE_TCHAR *token_name, ACE_Token_Proxy *&proxy) +{ + ACE_TRACE ("ACE_Token_Collection::extract"); + TOKEN_NAME name (token_name); + return collection_.unbind (token_name, proxy); +} + +ACE_Token_Proxy * +ACE_Token_Collection::is_member (const ACE_TCHAR *token_name) +{ + ACE_TRACE ("ACE_Token_Collection::is_member"); + TOKEN_NAME name (token_name); + ACE_Token_Proxy *temp; + // Get the token from the collection. + return collection_.find (name, temp) == -1 ? 0 : temp; +} + +int +ACE_Token_Collection::is_member (const ACE_Token_Proxy &token) +{ + ACE_TRACE ("ACE_Token_Collection::is_member"); + TOKEN_NAME token_name (token.name ()); + return collection_.find (token_name) == 0; +} + +int +ACE_Token_Collection::acquire (int notify, + void (*sleep_hook)(void *), + ACE_Synch_Options &options) +{ + ACE_TRACE ("ACE_Token_Collection::acquire"); + + COLLECTION::ITERATOR iterator (collection_); + + for (COLLECTION::ENTRY *temp = 0; + iterator.next (temp) != 0; + iterator.advance ()) + { + if (debug_) + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("collection acquiring %s\n"), + temp->int_id_->name ())); + if (temp->int_id_->acquire (notify, + sleep_hook, + options) == -1) + { + // Save/restore errno. + ACE_Errno_Guard error (errno); + this->release (); + ACE_RETURN (-1); + } + } + + return 0; +} + +int +ACE_Token_Collection::acquire (const ACE_TCHAR *token_name, + int notify, + void (*sleep_hook)(void *), + ACE_Synch_Options &options) +{ + ACE_TRACE ("ACE_Token_Collection::acquire"); + TOKEN_NAME name (token_name); + ACE_Token_Proxy *temp; + // Get the token from the collection. + int result = collection_.find (name, temp); + // did we find it? + if (result == -1) + return result; + // perform the operation + return temp->acquire (notify, sleep_hook, options); +} + + +int +ACE_Token_Collection::tryacquire (const ACE_TCHAR *token_name, + void (*sleep_hook)(void *)) +{ + ACE_TRACE ("ACE_Token_Collection::tryacquire"); + TOKEN_NAME name (token_name); + ACE_Token_Proxy *temp; + // Get the token from the collection. + int result = collection_.find (name, temp); + // did we find it? + if (result == -1) + return result; + + // perform the operation + return temp->tryacquire (sleep_hook); +} + +int +ACE_Token_Collection::tryacquire (void (*sleep_hook)(void *)) +{ + ACE_TRACE ("ACE_Token_Collection::tryacquire"); + + COLLECTION::ITERATOR iterator (collection_); + + for (COLLECTION::ENTRY *temp = 0; + iterator.next (temp) != 0; + iterator.advance ()) + { + if (debug_) + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("collection acquiring %s\n"), + temp->int_id_->name ())); + // We will fail if _any_ token is not free. + if (temp->int_id_->tryacquire (sleep_hook) == -1) + return -1; + } + + return 0; +} + +int +ACE_Token_Collection::renew (int requeue_position, + ACE_Synch_Options &options) +{ + ACE_TRACE ("ACE_Token_Collection::renew"); + + COLLECTION::ITERATOR iterator (collection_); + + for (COLLECTION::ENTRY *temp = 0; + iterator.next (temp) != 0; + iterator.advance ()) + { + if (debug_) + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("collection renewing %s\n"), + temp->int_id_->name ())); + if (temp->int_id_->renew (requeue_position, options) == -1) + return -1; + } + + return 0; +} + +int +ACE_Token_Collection::renew (const ACE_TCHAR *token_name, + int requeue_position, + ACE_Synch_Options &options) +{ + ACE_TRACE ("ACE_Token_Collection::renew"); + TOKEN_NAME name (token_name); + ACE_Token_Proxy *temp; + + // Get the token from the collection. + int result = collection_.find (name, temp); + + // Did we find it? + if (result == -1) + ACE_ERROR_RETURN ((LM_DEBUG, ACE_TEXT ("%p %s\n"), + ACE_TEXT ("not in collection "), + token_name), -1); + // perform the operation + return temp->renew (requeue_position, options); +} + +int +ACE_Token_Collection::release (ACE_Synch_Options &) + +{ + ACE_TRACE ("ACE_Token_Collection::release"); + COLLECTION::ITERATOR iterator (collection_); + + for (COLLECTION::ENTRY *temp = 0; + iterator.next (temp) != 0; + iterator.advance ()) + { + if (debug_) + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("collection releasing %s\n"), + temp->int_id_->name ())); + temp->int_id_->release (); + } + + return 0; +} + +int +ACE_Token_Collection::release (const ACE_TCHAR *token_name, + ACE_Synch_Options &options) +{ + ACE_TRACE ("ACE_Token_Collection::release"); + TOKEN_NAME name (token_name); + ACE_Token_Proxy *temp; + // get the token from the collection + int result = collection_.find (name, temp); + // did we find it? + if (result != 0) + return result; + // perform the operation + return temp->release (options); +} + +ACE_Token_Collection::~ACE_Token_Collection (void) +{ + ACE_TRACE ("ACE_Token_Collection::~ACE_Token_Collection"); + COLLECTION::ITERATOR iterator (collection_); + + for (COLLECTION::ENTRY *temp = 0; + iterator.next (temp) != 0; + iterator.advance ()) + { + delete temp->int_id_; + // The ext_id_'s delete themselves when the array of + // COLLECTION::ENTRYs goes away. + } +} + + +// This method doesn't mean anything for a collection. +ACE_Token_Proxy * +ACE_Token_Collection::clone (void) const +{ + ACE_TRACE ("ACE_Token_Collection::clone"); + return (ACE_Token_Proxy *) 0; +} + +// This method doesn't mean anything for a collection. +ACE_Tokens * +ACE_Token_Collection::create_token (const ACE_TCHAR *) +{ + ACE_TRACE ("ACE_Token_Collection::create_token"); + return (ACE_Tokens *) 0; +} + +void +ACE_Token_Collection::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + ACE_TRACE ("ACE_Token_Collection::dump"); + ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("ACE_Token_Collection::dump:\n") + ACE_TEXT (" debug_ = %d\n"), debug_)); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("collection_\n"))); + collection_.dump (); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("base:\n"))); + ACE_Token_Proxy::dump (); + ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); +#endif /* ACE_HAS_DUMP */ +} + +ACE_END_VERSIONED_NAMESPACE_DECL + +#endif /* ACE_HAS_TOKENS_LIBRARY */ diff --git a/dep/ACE_wrappers/ace/Token_Collection.h b/dep/ACE_wrappers/ace/Token_Collection.h new file mode 100644 index 00000000000..16a9bb412b0 --- /dev/null +++ b/dep/ACE_wrappers/ace/Token_Collection.h @@ -0,0 +1,243 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Token_Collection.h + * + * $Id: Token_Collection.h 80826 2008-03-04 14:51:23Z wotte $ + * + * The ACE_Token class offers methods for acquiring, renewing, + * and releasing a synchronization token on a per-token basis. The + * ACE_Token_Collection offers an interface for performing + * operations on groups of tokens as a whole, or on a single token + * within the collection. + * + * The atomic group operations are not yet implemented. + * + * + * @author Douglas C. Schmidt (schmidt@cs.wustl.edu) + * @author Tim Harrison (harrison@cs.wustl.edu) + */ +//============================================================================= + +#ifndef ACE_TOKEN_COLLECTION_H +#define ACE_TOKEN_COLLECTION_H +#include /**/ "ace/pre.h" + +#include "ace/Map_Manager.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#if defined (ACE_HAS_TOKENS_LIBRARY) + +#include "ace/Local_Tokens.h" +#include "ace/Null_Mutex.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +/** + * @class ACE_Token_Collection + * + * @brief Allows atomic token group operations AND + * provides a ACE_Token manager interface. + * + * There are two types of operations offered by + * ACE_Token_Collection. The first is atomic operations on + * collections of Token_Proxies. In this respect, the + * ACE_Token_Collection can be thought of as a single token + * consisting of multiple Token_Proxies. The second role of the + * ACE_Token_Collection is as a ACE_Token manager. + * ACE_Token_Collection allows individual operations on single + * members of a collection of Token_Proxies. This provides a + * single access point for operations on multiple tokens. + * + * @bug Although ACE_Token_Collection inherits from ACE_Token_Proxy, it + * can not be including in a collection. This is because + * returns zero for now. + * + */ +class ACE_Export ACE_Token_Collection : public ACE_Token_Proxy +{ +public: + /** + * @a debug print out verbose debugging messages. @a name will give a + * name to the collection. Collections don't really need names, but + * are sometimes useful for debugging. + */ + ACE_Token_Collection (bool debug = false, + const ACE_TCHAR *name = 0); + +// Collection Management operations + + /** + * Insert a Token into the collection. All ACE_Token type + * operations performed on the collection will also be performed on + * the new_proxy until it is removed. Note that no operations + * performed prior to the insertion will be performed. Returns: 0 + * on success, -1 on failure with @c errno == problem. If a token + * proxy already exists in the collection with the same name, the + * insertion will fail. Also, is copied. Note that during + * the copy, client_id's are *not* inherited. The client ID of the + * thread using the collection will be used. Client ID's can be + * changed explicity on each proxy using is_member. + */ + int insert (ACE_Token_Proxy &token); + + /** + * Removes the ACE_Token matching the given token_name from the + * collection. On success, extract returns 0. On failure + * (token_name was not in the collection,) extract returns -1. On + * success, the state of the token found is copied into proxy. + * The returned ACE_Token_Proxy* must be deleted by the user. + */ + int extract (const ACE_TCHAR *token_name, ACE_Token_Proxy *&proxy); + + /// Returns the proxy if true. 0 otherwise. + ACE_Token_Proxy *is_member (const ACE_TCHAR *token_name); + + /** + * Is the specified token in the collection? + * 1, yes. + * 0, no. + */ + int is_member (const ACE_Token_Proxy &token); + +// = Collective operation semantics. + +// For acquire, renew, and release, there are two interfaces. Once +// interface allows an operation on a single token in the +// collection. The collective interfaces perform atomic operations +// on the entire collection. For instance, a collective acquire +// will perform an acquire for each and every token in the +// collection or the operation will fail. Currently, these +// operations are performed with no ordering heuristics. That is, +// the Collection steps through the tokens in the order they were +// inserted. For each one it performs the operation (acquire, +// renew, or release). + + /** + * Acquire "atomically" all resources in the collection. This is + * only successfull if all tokens in the collection could be + * acquired. options contains the blocking semantics, timeout + * value, etc. Returns: 0 on success, -1 on failure with @c errno == + * problem. If and error or deadlock occurs for one of the tokens, + * all the tokens will be released and the method will return -1. + * Note that returning on detection of deadlock prevents livelock + * between competing collections. If a collection returns after + * detecting deadlock, it is the application's responsibility to not + * to blindly loop on the collection::acquire operation. In other + * words, once the collection reports deadlock, it is out of our + * hands. + */ + virtual int acquire (int notify = 0, + void (*sleep_hook)(void *) = 0, + ACE_Synch_Options &options = + ACE_Synch_Options::defaults); + + /// Acquire the token corresponding to @a token_name. The other + /// parameters are passed to ::acquire. + virtual int acquire (const ACE_TCHAR *token_name, + int notify = 0, + void (*sleep_hook)(void *) = 0, + ACE_Synch_Options &options = + ACE_Synch_Options::defaults); + + /// Try to acquire all tokens in collection. + virtual int tryacquire (void (*sleep_hook)(void *) = 0); + + /// Try to acquire @a token_name. + virtual int tryacquire (const ACE_TCHAR *token_name, + void (*sleep_hook)(void *) = 0); + + /** + * Renews "atomically" all resources in the collection. This is + * only successfull if all tokens in the collection could be + * renewed. options contains the blocking semantics, timeout + * value, etc. Returns: 0 on success, -1 on failure with @c errno == + * problem. + */ + virtual int renew (int requeue_position = 0, + ACE_Synch_Options &options = + ACE_Synch_Options::defaults); + + + /// Renew the token corresponding to @a token_name. The other + /// parameters are passed to ::renew. + virtual int renew (const ACE_TCHAR *token_name, + int requeue_position = 0, + ACE_Synch_Options &options = + ACE_Synch_Options::defaults); + + /** + * Releases "atomically" all resources in the collection. This is + * only successfull if all tokens in the collection could be + * released. options contains the blocking semantics, timeout + * value, etc. Returns: 0 on success, -1 on failure with @c errno == + * problem. + */ + virtual int release (ACE_Synch_Options &options = + ACE_Synch_Options::defaults); + + + /// Release the token corresponding to . The other + /// parameters are passed to ::release. + virtual int release (const ACE_TCHAR *token_name, + ACE_Synch_Options &options = + ACE_Synch_Options::defaults); + + ~ACE_Token_Collection (void); + + /// Dump the state of the class. + void dump (void) const; + + /// Return the name of the collection. Not very functionally + /// important, but sometimes a useful debugging tool. + virtual const ACE_TCHAR *name (void) const; + +protected: + + typedef ACE_Token_Name TOKEN_NAME; + + /// COLLECTION maintains a mapping from token names to ACE_Tokens* + typedef ACE_Map_Manager + COLLECTION; + + /// Allows iterations through collection_ + /** + * @deprecated Deprecated typedef. Use COLLECTION::ITERATOR trait instead. + */ + typedef COLLECTION::ITERATOR COLLECTION_ITERATOR; + + /// Allows iterations through collection_ + /** + * @deprecated Deprecated typedef. Use COLLECTION::ENTRY trait instead. + */ + typedef COLLECTION::ENTRY COLLECTION_ENTRY; + + /// COLLECTION maintains a mapping from token names to ACE_Tokens*. + COLLECTION collection_; + + /// Whether to print out debug messages or not. + bool debug_; + + /// Name of the collection. + ACE_TCHAR name_[ACE_MAXTOKENNAMELEN]; + + // = I'm not sure what these mean, but they have to be defined since they're + // pure virtual in ACE_Token_Proxy. + virtual ACE_Token_Proxy *clone (void) const; + virtual ACE_Tokens *create_token (const ACE_TCHAR *name); +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +#include "ace/Token_Collection.inl" +#endif /* __ACE_INLINE__ */ + +#endif /* ACE_HAS_TOKENS_LIBRARY */ + +#include /**/ "ace/post.h" +#endif /* ACE_TOKEN_COLLECTION_H */ diff --git a/dep/ACE_wrappers/ace/Token_Collection.inl b/dep/ACE_wrappers/ace/Token_Collection.inl new file mode 100644 index 00000000000..73f1e95d76e --- /dev/null +++ b/dep/ACE_wrappers/ace/Token_Collection.inl @@ -0,0 +1,17 @@ +// -*- C++ -*- +// +// $Id: Token_Collection.inl 80826 2008-03-04 14:51:23Z wotte $ + +#if defined (ACE_HAS_TOKENS_LIBRARY) + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_INLINE const ACE_TCHAR * +ACE_Token_Collection::name (void) const +{ + return name_; +} + +ACE_END_VERSIONED_NAMESPACE_DECL + +#endif /* ACE_HAS_TOKENS_LIBRARY */ diff --git a/dep/ACE_wrappers/ace/Token_Invariants.cpp b/dep/ACE_wrappers/ace/Token_Invariants.cpp new file mode 100644 index 00000000000..6c5d1bd5298 --- /dev/null +++ b/dep/ACE_wrappers/ace/Token_Invariants.cpp @@ -0,0 +1,355 @@ +#include "ace/Token_Invariants.h" + +#if defined (ACE_HAS_TOKENS_LIBRARY) + +#include "ace/Object_Manager.h" + +ACE_RCSID (ace, + Token_Invariants, + "$Id: Token_Invariants.cpp 80826 2008-03-04 14:51:23Z wotte $") + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_Token_Invariant_Manager *ACE_Token_Invariant_Manager::instance_ = 0; + +ACE_Token_Invariant_Manager * +ACE_Token_Invariant_Manager::instance (void) +{ + ACE_TRACE ("ACE_Token_Invariant_Manager::instance"); + + // Perform the Double-Check pattern... + if (instance_ == 0) + { + ACE_MT (ACE_TOKEN_CONST::MUTEX *lock = + ACE_Managed_Object::get_preallocated_object + (ACE_Object_Manager::ACE_TOKEN_INVARIANTS_CREATION_LOCK); + ACE_GUARD_RETURN (ACE_TOKEN_CONST::MUTEX, ace_mon, *lock, 0)); + + if (instance_ == 0) + { + ACE_NEW_RETURN (instance_, + ACE_Token_Invariant_Manager, + 0); + // Register for destruction with ACE_Object_Manager. + ACE_Object_Manager::at_exit (instance_); + } + } + + return instance_; +} + +ACE_Token_Invariant_Manager::ACE_Token_Invariant_Manager (void) +{ + ACE_TRACE ("ACE_Token_Invariant_Manager::ACE_Token_Invariant_Manager"); +} + +int +ACE_Token_Invariant_Manager::mutex_acquired (const ACE_TCHAR *token_name) +{ + ACE_TRACE ("ACE_Token_Invariant_Manager::mutex_acquired"); + + ACE_GUARD_RETURN (ACE_TOKEN_CONST::MUTEX, ace_mon, this->lock_, -1); + + ACE_Mutex_Invariants *inv = 0; + if (this->get_mutex (token_name, inv) == -1) + return -1; + + return inv->acquired (); +} + +int +ACE_Token_Invariant_Manager::acquired (const ACE_Token_Proxy *proxy) +{ + ACE_TRACE ("ACE_Token_Invariant_Manager::acquired"); + + // Reach into the proxy to find the token type. + if (proxy->token_->type () == ACE_Tokens::MUTEX) + return this->mutex_acquired (proxy->name ()); + else // ACE_Tokens::RWLOCK. + { + if (proxy->type () == ACE_RW_Token::READER) + return this->reader_acquired (proxy->name ()); + else // ACE_RW_Token::WRITER. + return this->writer_acquired (proxy->name ()); + } +} + +void +ACE_Token_Invariant_Manager::releasing (const ACE_Token_Proxy *proxy) +{ + ACE_TRACE ("ACE_Token_Invariant_Manager::releasing"); + + // Reach into the proxy to find the token type. + if (proxy->token_->type () == ACE_Tokens::MUTEX) + this->mutex_releasing (proxy->name ()); + else // ACE_Tokens::RWLOCK. + this->rwlock_releasing (proxy->name ()); +} + +void +ACE_Token_Invariant_Manager::mutex_releasing (const ACE_TCHAR *token_name) +{ + ACE_TRACE ("ACE_Token_Invariant_Manager::mutex_releasing"); + ACE_GUARD (ACE_TOKEN_CONST::MUTEX, ace_mon, this->lock_); + + ACE_Mutex_Invariants *inv = 0; + if (this->get_mutex (token_name, inv) == 0) + inv->releasing (); +} + +int +ACE_Token_Invariant_Manager::reader_acquired (const ACE_TCHAR *token_name) +{ + ACE_TRACE ("ACE_Token_Invariant_Manager::reader_acquired"); + ACE_GUARD_RETURN (ACE_TOKEN_CONST::MUTEX, ace_mon, this->lock_, -1); + + ACE_RWLock_Invariants *inv = 0; + if (this->get_rwlock (token_name, inv) == -1) + return -1; + + return inv->reader_acquired (); +} + +int +ACE_Token_Invariant_Manager::writer_acquired (const ACE_TCHAR *token_name) +{ + ACE_TRACE ("ACE_Token_Invariant_Manager::writer_acquired"); + + ACE_GUARD_RETURN (ACE_TOKEN_CONST::MUTEX, ace_mon, this->lock_, -1); + + ACE_RWLock_Invariants *inv = 0; + if (this->get_rwlock (token_name, inv) == -1) + return -1; + + return inv->writer_acquired (); +} + +void +ACE_Token_Invariant_Manager::rwlock_releasing (const ACE_TCHAR *token_name) +{ + ACE_TRACE ("ACE_Token_Invariant_Manager::rwlock_releasing"); + + ACE_GUARD (ACE_TOKEN_CONST::MUTEX, ace_mon, this->lock_); + + ACE_RWLock_Invariants *inv = 0; + if (this->get_rwlock (token_name, inv) == 0) + inv->releasing (); +} + +void +ACE_Token_Invariant_Manager::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + ACE_TRACE ("ACE_Token_Invariant_Manager::dump"); + ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("mutex_collection_:\n"))); + mutex_collection_.dump (); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("rwlock_collection_:\n"))); + rwlock_collection_.dump (); + ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); +#endif /* ACE_HAS_DUMP */ +} + + +int +ACE_Token_Invariant_Manager::get_mutex (const ACE_TCHAR *token_name, + ACE_Mutex_Invariants *&inv) +{ + ACE_TRACE ("ACE_Token_Invariant_Manager::get_mutex"); + TOKEN_NAME name (token_name); + if (mutex_collection_.find (name, inv) == -1) + // We did not find one in the collection. + { + ACE_Mutex_Invariants *new_invariant; + + ACE_NEW_RETURN (new_invariant, + ACE_Mutex_Invariants, + -1); + if (mutex_collection_.bind (name, new_invariant) == -1) + { + delete new_invariant; + return -1; + } + + if (mutex_collection_.find (name, inv) == -1) + // We did not find one in the collection. + return -1; + } + + return 0; +} + +int +ACE_Token_Invariant_Manager::get_rwlock (const ACE_TCHAR *token_name, + ACE_RWLock_Invariants *&inv) +{ + ACE_TRACE ("ACE_Token_Invariant_Manager::get_rwlock"); + TOKEN_NAME name (token_name); + if (rwlock_collection_.find (name, inv) == -1) + // We did not find one in the collection. + { + ACE_RWLock_Invariants *new_invariant; + + ACE_NEW_RETURN (new_invariant, + ACE_RWLock_Invariants, + -1); + if (rwlock_collection_.bind (name, new_invariant) == -1) + return -1; + + if (rwlock_collection_.find (name, inv) == -1) + // We did not find one in the collection. + return -1; + } + + return 0; +} + + +ACE_Token_Invariant_Manager::~ACE_Token_Invariant_Manager (void) +{ + ACE_TRACE ("ACE_Token_Invariant_Manager::~ACE_Token_Invariant_Manager"); + + MUTEX_COLLECTION::ITERATOR iterator (mutex_collection_); + + for (MUTEX_COLLECTION::ENTRY *temp = 0; + iterator.next (temp) != 0; + iterator.advance ()) + delete temp->int_id_; + + RWLOCK_COLLECTION::ITERATOR iterator2 (rwlock_collection_); + + for (RWLOCK_COLLECTION::ENTRY *temp2 = 0; + iterator2.next (temp2) != 0; + iterator2.advance ()) + delete temp2->int_id_; +} + +// ************************************************** +// ************************************************** +// ************************************************** + +ACE_Mutex_Invariants::ACE_Mutex_Invariants (void) +: owners_ (0) +{ +} + +int +ACE_Mutex_Invariants::acquired (void) +{ + if (++owners_ > 1) + { + owners_ = 42; + return 0; + } + else + return 1; +} + +void +ACE_Mutex_Invariants::releasing (void) +{ + if (owners_ == 1) + --owners_; +} + +ACE_Mutex_Invariants::ACE_Mutex_Invariants (const ACE_Mutex_Invariants &rhs) +: owners_ (rhs.owners_) +{ +} + +void +ACE_Mutex_Invariants::operator= (const ACE_Mutex_Invariants &rhs) +{ + owners_ = rhs.owners_; +} + +void +ACE_Mutex_Invariants::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + ACE_TRACE ("ACE_Mutex_Invariants::dump"); + ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("owners_ = %d\n"), owners_)); + ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); +#endif /* ACE_HAS_DUMP */ +} + +// ************************************************** +// ************************************************** +// ************************************************** + +ACE_RWLock_Invariants::ACE_RWLock_Invariants (void) +: writers_ (0), + readers_ (0) +{ +} + +int +ACE_RWLock_Invariants::writer_acquired (void) +{ + if (readers_ > 0) + { + writers_ = readers_ = 42; + return 0; + } + else if (++writers_ > 1) + { + writers_ = readers_ = 42; + return 0; + } + else + return 1; +} + +int +ACE_RWLock_Invariants::reader_acquired (void) +{ + if (writers_ > 0) + { + writers_ = readers_ = 42; + return 0; + } + else + { + ++readers_; + return 1; + } +} + +void +ACE_RWLock_Invariants::releasing (void) +{ + if (writers_ == 1) + writers_ = 0; + else if (readers_ > 0) + --readers_; +} + +ACE_RWLock_Invariants::ACE_RWLock_Invariants (const ACE_RWLock_Invariants &rhs) +: writers_ (rhs.writers_), + readers_ (rhs.readers_) +{ +} + +void +ACE_RWLock_Invariants::operator= (const ACE_RWLock_Invariants &rhs) +{ + writers_ = rhs.writers_; + readers_ = rhs.readers_; +} + +void +ACE_RWLock_Invariants::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + ACE_TRACE ("ACE_RWLock_Invariants::dump"); + ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("writers_ = %d readers_ = %d\n"), + writers_, readers_)); + ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); +#endif /* ACE_HAS_DUMP */ +} + +ACE_END_VERSIONED_NAMESPACE_DECL + +#endif /* ACE_HAS_TOKENS_LIBRARY */ diff --git a/dep/ACE_wrappers/ace/Token_Invariants.h b/dep/ACE_wrappers/ace/Token_Invariants.h new file mode 100644 index 00000000000..5cec394763d --- /dev/null +++ b/dep/ACE_wrappers/ace/Token_Invariants.h @@ -0,0 +1,245 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Token_Invariants.h + * + * $Id: Token_Invariants.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Tim Harrison (harrison@cs.wustl.edu) + * + * Allows applications to test that invariants are always + * satisfied. Can test mutexes and readers/writer locks. Does + * not test recursive acquisition. + * + * + */ +//============================================================================= + +#ifndef ACE_TOKEN_INVARIANTS_H +#define ACE_TOKEN_INVARIANTS_H +#include /**/ "ace/pre.h" + +#include /**/ "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#if defined (ACE_HAS_TOKENS_LIBRARY) + +#include "ace/Map_Manager.h" +#include "ace/Local_Tokens.h" +#include "ace/Null_Mutex.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +/** + * @class ACE_Mutex_Invariants + * + * @brief Mutex Invariants + * = INVARIANTS + * 1. Only one owner at a time. + */ +class ACE_Export ACE_Mutex_Invariants +{ +public: + /// Default construction. + ACE_Mutex_Invariants (void); + + /// Returns 1 on success, 0 when an invariant has been violated and + /// -1 on error. + int acquired (void); + + /// Updates internal database. + void releasing (void); + + // = Map_Manager operations. + + /// Copy construction. + ACE_Mutex_Invariants (const ACE_Mutex_Invariants &rhs); + + /// Copy. + void operator= (const ACE_Mutex_Invariants &rhs); + + /// Dump the state of the class. + void dump (void) const; + +private: + /// Number of owners. This had better be 0 >= owners_ <= 1; + int owners_; +}; + +/** + * @class ACE_RWLock_Invariants + * + * @brief RWLock Invariants + * + * Preserve the following invariants: + * -# Only one writer at a time. + * -# If there is an owning writer, there are no owning readers. + */ +class ACE_Export ACE_RWLock_Invariants +{ +public: + /// Default construction. + ACE_RWLock_Invariants (void); + + /// Returns 1 on success, 0 when an invariant has been violated and + /// -1 on error. + int writer_acquired (void); + + /// Returns 1 on success, 0 when an invariant has been violated and + /// -1 on error. + int reader_acquired (void); + + /// Updates internal database. + void releasing (void); + + // = Map_Manager operations. + + /// Copy construction. + ACE_RWLock_Invariants (const ACE_RWLock_Invariants &rhs); + + /// Copy. + void operator= (const ACE_RWLock_Invariants &rhs); + + /// Dump the state of the class. + void dump (void) const; + +private: + /// Number of owning writers. + int writers_; + + /// Number of owning readers. + int readers_; +}; + +/** + * @class ACE_Token_Invariant_Manager + * + * @brief Token Invariants + * + * The Token Invariant Manager allows applications to test that + * invariants are always satisfied. Currently, Token_Invariants + * can test mutexes and readers/writer locks. Does not test + * recursive acquisition. + * Note that this class does not ever clean its database. Until + * destroyed, it's size will forever increase. + */ +class ACE_Export ACE_Token_Invariant_Manager : public ACE_Cleanup +{ +public: + + /// Singleton access point. + static ACE_Token_Invariant_Manager *instance (void); + + // = Polymorphic methods. Just pass in the proxy and the method + // figures out the type of the token. + + /// Returns 1 on success, 0 when an invariant has been violated and + /// -1 on error. + int acquired (const ACE_Token_Proxy *proxy); + + /// Updates internal database. + void releasing (const ACE_Token_Proxy *proxy); + + // = Explicit methods. These to not require actual proxies in order + // to test a scenario. + + /// Returns 1 on success, 0 when an invariant has been violated and + /// -1 on error. + int mutex_acquired (const ACE_TCHAR *token_name); + + /// Updates internal database. + void mutex_releasing (const ACE_TCHAR *token_name); + + /// Returns 1 on success, 0 when an invariant has been violated and + /// -1 on error. + int reader_acquired (const ACE_TCHAR *token_name); + + /// Returns 1 on success, 0 when an invariant has been violated and + /// -1 on error. + int writer_acquired (const ACE_TCHAR *token_name); + + /// Updates internal database. + void rwlock_releasing (const ACE_TCHAR *token_name); + + /// Dump the state of the class. + void dump (void) const; + + // = The following two method should be in the protected part of the + // class. Bugs with certain compilers preclude this. + /// Prevent non-singleton construction. + ACE_Token_Invariant_Manager (void); + + /// Destruction. + virtual ~ACE_Token_Invariant_Manager (void); + +protected: + /// Return or create. + int get_mutex (const ACE_TCHAR *token_name, + ACE_Mutex_Invariants *&inv); + + /// Return or create. + int get_rwlock (const ACE_TCHAR *token_name, + ACE_RWLock_Invariants *&inv); + + /// ACE_Mutex_Token used to lock internal data structures. + ACE_TOKEN_CONST::MUTEX lock_; + + /// This may be changed to a template type. + typedef ACE_Token_Name TOKEN_NAME; + + /// COLLECTION maintains a mapping from token names to mutexes. + typedef ACE_Map_Manager + MUTEX_COLLECTION; + + /// Allows iterations through collection. + /** + * @deprecated Deprecated typedef. Use MUTEX_COLLECTION::ITERATOR trait + * instead. + */ + typedef MUTEX_COLLECTION::ITERATOR MUTEX_COLLECTION_ITERATOR; + + /// Allows iterations through collection. + /** + * @deprecated Deprecated typedef. Use MUTEX_COLLECTION::ENTRY trait + * instead. + */ + typedef MUTEX_COLLECTION::ENTRY MUTEX_COLLECTION_ENTRY; + + /// MUTEX_COLLECTION maintains a mapping from token names to mutexes. + MUTEX_COLLECTION mutex_collection_; + + /// COLLECTION maintains a mapping from token names to mutexes. + typedef ACE_Map_Manager + RWLOCK_COLLECTION; + + /// Allows iterations through collection. + /** + * @deprecated Deprecated typedef. Use RWLOCK_COLLECTION::ITERATOR trait + * instead. + */ + typedef RWLOCK_COLLECTION::ITERATOR RWLOCK_COLLECTION_ITERATOR; + + /// Allows iterations through collection. + /** + * @deprecated Deprecated typedef. Use RWLOCK_COLLECTION::ENTRY trait + * instead. + */ + typedef RWLOCK_COLLECTION::ENTRY RWLOCK_COLLECTION_ENTRY; + + /// MUTEX_COLLECTION maintains a mapping from token names to mutexes. + RWLOCK_COLLECTION rwlock_collection_; + + /// Singleton pointer. + static ACE_Token_Invariant_Manager *instance_; +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#endif /* ACE_HAS_TOKENS_LIBRARY */ + +#include /**/ "ace/post.h" +#endif /* ACE_TOKEN_INVARIANTS_H */ diff --git a/dep/ACE_wrappers/ace/Token_Manager.cpp b/dep/ACE_wrappers/ace/Token_Manager.cpp new file mode 100644 index 00000000000..22b6e9f9e16 --- /dev/null +++ b/dep/ACE_wrappers/ace/Token_Manager.cpp @@ -0,0 +1,273 @@ +#include "ace/Token_Manager.h" + +#if defined (ACE_HAS_TOKENS_LIBRARY) + +#include "ace/Object_Manager.h" + +#if !defined (__ACE_INLINE__) +#include "ace/Token_Manager.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID (ace, + Token_Manager, + "$Id: Token_Manager.cpp 80826 2008-03-04 14:51:23Z wotte $") + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +// singleton token manager +ACE_Token_Manager *ACE_Token_Manager::token_manager_ = 0; + +ACE_Token_Manager::ACE_Token_Manager () +{ + ACE_TRACE ("ACE_Token_Manager::ACE_Token_Manager"); +} + +ACE_Token_Manager::~ACE_Token_Manager () +{ + ACE_TRACE ("ACE_Token_Manager::~ACE_Token_Manager"); + + COLLECTION::ITERATOR iterator (collection_); + + for (COLLECTION::ENTRY *temp = 0; + iterator.next (temp) != 0; + iterator.advance ()) + { + // @ should I be doing an unbind here? + delete temp->int_id_; + // The ext_id_'s delete themselves when the array of + // COLLECTION::ENTRYs goes away. + } +} + +ACE_Token_Manager * +ACE_Token_Manager::instance (void) +{ + ACE_TRACE ("ACE_Token_Manager::instance"); + + // This first check is to avoid acquiring the mutex in the common + // case. Double-Check pattern rules. + if (token_manager_ == 0) + { +#if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0) + ACE_TOKEN_CONST::MUTEX *lock = + ACE_Managed_Object::get_preallocated_object + (ACE_Object_Manager::ACE_TOKEN_MANAGER_CREATION_LOCK); + ACE_GUARD_RETURN (ACE_TOKEN_CONST::MUTEX, ace_mon, *lock, 0); +#endif /* ACE_MT_SAFE */ + + if (token_manager_ == 0) + { + ACE_NEW_RETURN (token_manager_, + ACE_Token_Manager, + 0); + // Register for destruction with ACE_Object_Manager. + ACE_Object_Manager::at_exit (token_manager_); + } + } + + return token_manager_; +} + +void +ACE_Token_Manager::get_token (ACE_Token_Proxy *proxy, + const ACE_TCHAR *token_name) +{ + ACE_TRACE ("ACE_Token_Manager::get_token"); + // Hmm. I think this makes sense. We perform our own locking here + // (see safe_acquire.) We have to make sure that only one thread + // uses the collection at a time. + + ACE_GUARD (ACE_TOKEN_CONST::MUTEX, ace_mon, this->lock_); + + TOKEN_NAME name (token_name); + + if (collection_.find (name, proxy->token_) == -1) + // We did not find one in the collection. + { + // Make one. + proxy->token_ = proxy->create_token (token_name); + + // Put it in the collection. + if (collection_.bind (name, proxy->token_) == -1) + { + delete proxy->token_; + proxy->token_ = 0; + } + } + + if (proxy->token_ != 0) + proxy->token_->inc_reference (); + + // We may be returning proxy->token_ == 0 if new failed, caller must + // check. +} + +// 0. check_deadlock (TOKEN) +// 1. if TOKEN->visited (), return 0. +// 2. mark TOKEN visited. +// 3. get ALL_OWNERS +// 4. if CLIENT in ALL_OWNERS, return *DEADLOCK*. +// 5. for each OWNER in ALL_OWNERS, +// 6. if OWNER is not waiting for a NEW_TOKEN, continue. +// 7. else, if check_deadlock (NEW_TOKEN) == 1, return *DEADLOCK* +// 8. return 0. + +int +ACE_Token_Manager::check_deadlock (ACE_Token_Proxy *proxy) +{ + ACE_TRACE ("ACE_Token_Manager::check_deadlock"); + + // Start the recursive deadlock detection algorithm. + int result = this->check_deadlock (proxy->token_, proxy); + + // Whether or not we detect deadlock, we have to unmark all tokens + // for the next time. + COLLECTION::ITERATOR iterator (collection_); + for (COLLECTION::ENTRY *temp = 0; + iterator.next (temp) != 0; + iterator.advance ()) + temp->int_id_->visit (0); + + return result; +} + +int +ACE_Token_Manager::check_deadlock (ACE_Tokens *token, ACE_Token_Proxy *proxy) +{ + ACE_TRACE ("ACE_Token_Manager::check_deadlock"); + + if (token->visited ()) + return 0; + + token->visit (1); + + ACE_Tokens::OWNER_STACK owners; + + int is_owner = token->owners (owners, proxy->client_id ()); + + switch (is_owner) + { + case -1: + // Error. + return -1; + case 1: + // The caller is an owner, so we have a deadlock situation. + if (debug_) + { + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%t) Deadlock detected.\n"))); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("%s owns %s and is waiting for %s.\n"), + proxy->client_id (), + token->name (), + proxy->token_->name ())); + } + + return 1; + case 0: + default: + // Recurse on each owner. + while (!owners.is_empty ()) + { + ACE_TPQ_Entry *e; + owners.pop (e); + // If the owner is waiting on another token, recurse. + ACE_Tokens *twf = this->token_waiting_for (e->client_id ()); + if ((twf != 0) && + (this->check_deadlock (twf, proxy) == 1)) + { + if (debug_) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("%s owns %s and is waiting for %s.\n"), + e->client_id (), + token->name (), + twf->name ())); + } + return 1; + } + // else, check the next owner. + } + + // We've checked all the owners and found no deadlock. + return 0; + } +} + + +ACE_Tokens * +ACE_Token_Manager::token_waiting_for (const ACE_TCHAR *client_id) +{ + COLLECTION::ITERATOR iterator (collection_); + for (COLLECTION::ENTRY *temp = 0; + iterator.next (temp) != 0; + iterator.advance ()) + { + if (temp->int_id_->is_waiting_for (client_id)) + return temp->int_id_; + } + + // nothing was found, return NULL. + return 0; +} + +// Notify the token manager that a token is has been released. If +// as a result, there is no owner of the token, the token is +// deleted. +void +ACE_Token_Manager::release_token (ACE_Tokens *&token) +{ + ACE_TRACE ("ACE_Token_Manager::release_token"); + // again, let's perform our own locking here. + + ACE_GUARD (ACE_TOKEN_CONST::MUTEX, ace_mon, this->lock_); + + if (token->dec_reference () == 0) + { + // No one has the token, so we can delete it and remove it from + // our collection. First, let's get it from the collection. + TOKEN_NAME token_name (token->name ()); + + ACE_Tokens *temp; + + if (collection_.unbind (token_name, temp) == -1) + // we did not find one in the collection + { + errno = ENOENT; + ACE_ERROR ((LM_ERROR, ACE_TEXT ("Token Manager could not release %s:%d\n"), + token->name (), token->type ())); + // @@ bad + } + else + // we found it + { + // sanity pointer comparison. The token referenced by the + // proxy better be the one we found in the list. + ACE_ASSERT (token == temp); + delete token; // or delete temp + // we set their token to zero. if the calling proxy is + // still going to be used, it had better check it's token + // value before calling a method on it! + token = 0; + } + } + // else + // someone is still interested in the token, so keep it around. +} + +void +ACE_Token_Manager::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + ACE_TRACE ("ACE_Token_Manager::dump"); + ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("ACE_Token_Manager::dump:\n"))); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("lock_\n"))); + lock_.dump (); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("collection_\n"))); + collection_.dump (); + ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); +#endif /* ACE_HAS_DUMP */ +} + +ACE_END_VERSIONED_NAMESPACE_DECL + +#endif /* ACE_HAS_TOKENS_LIBRARY */ diff --git a/dep/ACE_wrappers/ace/Token_Manager.h b/dep/ACE_wrappers/ace/Token_Manager.h new file mode 100644 index 00000000000..9882e28ef67 --- /dev/null +++ b/dep/ACE_wrappers/ace/Token_Manager.h @@ -0,0 +1,150 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Token_Manager.h + * + * $Id: Token_Manager.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Tim Harrison (harrison@cs.wustl.edu) + */ +//============================================================================= + +#ifndef ACE_TOKEN_MANAGER_H +#define ACE_TOKEN_MANAGER_H +#include /**/ "ace/pre.h" + +#include /**/ "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/Local_Tokens.h" + +#if defined (ACE_HAS_TOKENS_LIBRARY) + +#include "ace/Null_Mutex.h" +#include "ace/Map_Manager.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +class ACE_Local_Mutex; +class ACE_Mutex_Token; + +/** + * @class ACE_Token_Manager + * + * @brief Manages all tokens in a process space. + * + * Factory: Proxies use the token manager to obtain token + * references. This allows multiple proxies to reference the same + * logical token. + * Deadlock detection: Tokens use the manager to check for + * deadlock situations during acquires. + */ +class ACE_Export ACE_Token_Manager : public ACE_Cleanup +{ + + // To add a new type of token (e.g. semaphore), do the following + // steps: 1. Create a new derivation of ACE_Token. This class + // defines the semantics of the new Token. 2. Create a + // derivation of ACE_Token_Manager. You will only need to + // redefine make_mutex. +public: + ACE_Token_Manager (void); + virtual ~ACE_Token_Manager (void); + + /// Get the pointer to token manager singleton. + static ACE_Token_Manager *instance (void); + + /// Set the pointer to token manager singleton. + void instance (ACE_Token_Manager *); + + /** + * The Token manager uses ACE_Token_Proxy::token_id_ to look for + * an existing token. If none is found, the Token Manager calls + * ACE_Token_Proxy::create_token to create a new one. When + * finished, sets ACE_Token_Proxy::token_. @a token_name uniquely + * id's the token name. + */ + void get_token (ACE_Token_Proxy *, const ACE_TCHAR *token_name); + + /** + * Check whether acquire will cause deadlock or not. + * returns 1 if the acquire will _not_ cause deadlock. + * returns 0 if the acquire _will_ cause deadlock. + * This method ignores recursive acquisition. That is, it will not + * report deadlock if the client holding the token requests the + * token again. Thus, it assumes recursive mutexes. + */ + int check_deadlock (ACE_Token_Proxy *proxy); + int check_deadlock (ACE_Tokens *token, ACE_Token_Proxy *proxy); + + /// Notify the token manager that a token has been released. If as a + /// result, there is no owner of the token, the token is deleted. + void release_token (ACE_Tokens *&token); + + /** + * This is to allow Tokens to perform atomic transactions. The + * typical usage is to acquire this mutex, check for a safe_acquire, + * perform some queueing (if need be) and then release the lock. + * This is necessary since safe_acquire is implemented in terms of + * the Token queues. + */ + ACE_TOKEN_CONST::MUTEX &mutex (void); + + /// Dump the state of the class. + void dump (void) const; + + /// Turn debug mode on/off. + void debug (bool d); + +private: + /// Whether to print debug messages or not. + bool debug_; + + /// pointer to singleton token manager. + static ACE_Token_Manager *token_manager_; + + /// Return the token that the given client_id is waiting for, if any + ACE_Tokens *token_waiting_for (const ACE_TCHAR *client_id); + + /// ACE_Mutex_Token used to lock internal data structures. + ACE_TOKEN_CONST::MUTEX lock_; + + /// This may be changed to a template type. + typedef ACE_Token_Name TOKEN_NAME; + + /// COLLECTION maintains a mapping from token names to ACE_Tokens* + typedef ACE_Map_Manager + COLLECTION; + + /// Allows iterations through collection_ + /** + * @deprecated Deprecated typedef. Use COLLECTION::ITERATOR trait + * instead. + */ + typedef COLLECTION::ITERATOR COLLECTION_ITERATOR; + + /// Allows iterations through collection_ + /** + * @deprecated Deprecated typedef. Use COLLECTION::ENTRY trait + * instead. + */ + typedef COLLECTION::ENTRY COLLECTION_ENTRY; + + /// COLLECTION maintains a mapping from token names to ACE_Tokens*. + COLLECTION collection_; +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +#include "ace/Token_Manager.inl" +#endif /* __ACE_INLINE__ */ + +#endif /* ACE_HAS_TOKENS_LIBRARY */ + +#include /**/ "ace/post.h" +#endif /* ACE_TOKEN_MANAGER_H */ diff --git a/dep/ACE_wrappers/ace/Token_Manager.inl b/dep/ACE_wrappers/ace/Token_Manager.inl new file mode 100644 index 00000000000..a44778c89b2 --- /dev/null +++ b/dep/ACE_wrappers/ace/Token_Manager.inl @@ -0,0 +1,25 @@ +// -*- C++ -*- +// +// $Id: Token_Manager.inl 80826 2008-03-04 14:51:23Z wotte $ + +#if defined (ACE_HAS_TOKENS_LIBRARY) + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_INLINE ACE_TOKEN_CONST::MUTEX & +ACE_Token_Manager::mutex (void) +{ + ACE_TRACE ("ACE_Token_Manager::mutex"); + return lock_; +} + +ACE_INLINE void +ACE_Token_Manager::debug (bool d) +{ + ACE_TRACE ("ACE_Token_Manager::debug"); + debug_ = d; +} + +ACE_END_VERSIONED_NAMESPACE_DECL + +#endif /* ACE_HAS_TOKENS_LIBRARY */ diff --git a/dep/ACE_wrappers/ace/Token_Request_Reply.cpp b/dep/ACE_wrappers/ace/Token_Request_Reply.cpp new file mode 100644 index 00000000000..598afe01388 --- /dev/null +++ b/dep/ACE_wrappers/ace/Token_Request_Reply.cpp @@ -0,0 +1,186 @@ +// $Id: Token_Request_Reply.cpp 80826 2008-03-04 14:51:23Z wotte $ + +#include "ace/Token_Request_Reply.h" + +#if defined (ACE_HAS_TOKENS_LIBRARY) + +#if !defined (__ACE_INLINE__) +#include "ace/Token_Request_Reply.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(ace, Token_Request_Reply, "$Id: Token_Request_Reply.cpp 80826 2008-03-04 14:51:23Z wotte $") + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +// Default "do nothing" constructor. + +ACE_Token_Request::ACE_Token_Request (void) + : token_name_ (0), + client_id_ (0) +{ +} + +// Create a ACE_Token_Request message. + +ACE_Token_Request::ACE_Token_Request (int token_type, + int proxy_type, + ACE_UINT32 operation_type, + const ACE_TCHAR token_name[], + const ACE_TCHAR client_id[], + const ACE_Synch_Options &options) +{ + this->token_type (token_type); + this->proxy_type (proxy_type); + this->operation_type (operation_type); + this->requeue_position (0); // to avoid Purify UMR + this->notify (0); // to avoid Purify UMR + transfer_.arg_ = 0; // to avoid Purify UMR + ACE_OS::memset (transfer_.data_, 0, sizeof transfer_.data_); // to avoid Purify UMR + this->token_name (token_name, client_id); + this->options (options); +} + +// Encode the transfer buffer into network byte order +// so that it can be sent to the server. + +int +ACE_Token_Request::encode (void *&buf) +{ + buf = (void *) &this->transfer_; + return this->length (); +} + +// Decode the transfer buffer into host byte byte order +// so that it can be used by the server. + +int +ACE_Token_Request::decode (void) +{ + this->token_name_ = this->transfer_.data_; + + options_.set (transfer_.use_timeout_ == 1 ? ACE_Synch_Options::USE_TIMEOUT : 0, + ACE_Time_Value (transfer_.sec_, transfer_.usec_), + (void *) transfer_.arg_); + + // Decode the variable-sized portion. + size_t token_len = ACE_OS::strlen (this->token_name_); + + // Check to make sure this->tokenName_ isn't too long! + if (token_len >= ACE_MAXTOKENNAMELEN) + { + errno = ENAMETOOLONG; + return -1; + } + else // Skip this->tokenName_ + '\0' + ':'. + this->client_id_ = + &this->token_name_[(token_len + 2) * sizeof (ACE_TCHAR)]; + + // Fixed size header + // token_name_ plus '\0' + // ':' + // client_id_ plus '\0' + size_t data_size = ACE_TOKEN_REQUEST_HEADER_SIZE + + ACE_OS::strlen (this->token_name_) + 1 + + ACE_OS::strlen (this->client_id_) + 1 + + 1; + + // Make sure the message was correctly received and framed. + return this->length () == data_size ? 0 : -1; +} + +// Print out the current values of the ACE_Token_Request. + +void +ACE_Token_Request::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("*******\nlength = %d\ntoken name = %s\nclient id = %s\n"), + this->length (), this->token_name (), this->client_id ())); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("type = "))); + + if (this->token_type () == ACE_Tokens::MUTEX) + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("MUTEX\n"))); + else // == ACE_Tokens::RWLOCK + { + if (this->proxy_type () == ACE_RW_Token::READER) + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("RLOCK\n"))); + else // == WRITER + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("WLOCK\n"))); + } + + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("operation = "))); + switch (this->operation_type ()) + { + case ACE_Token_Request::ACQUIRE: + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("ACQUIRE\n"))); + break; + case ACE_Token_Request::RELEASE: + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("RELEASE\n"))); + break; + case ACE_Token_Request::RENEW: + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("RENEW\n"))); + break; + default: + ACE_DEBUG ((LM_DEBUG, ACE_TEXT (" = %d\n"), this->operation_type ())); + break; + } + + if (this->options ()[ACE_Synch_Options::USE_TIMEOUT] == 0) + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("blocking forever\n"))); + else + { + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("waiting for %d secs and %d usecs\n"), + this->options ().timeout ().sec (), this->options ().timeout ().usec ())); + } + ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); +#endif /* ACE_HAS_DUMP */ +} + +// ************************************************************ +// ************************************************************ +// ************************************************************ + +// Create a ACE_Token_Reply message. + +ACE_Token_Reply::ACE_Token_Reply (void) // Type of reply. +{ + this->arg (0); + this->errnum (0); + this->length (sizeof (Transfer)); +} + +// Encode the transfer buffer into network byte order +// so that it can be sent to the client. + +int +ACE_Token_Reply::encode (void *&buf) +{ + buf = (void *) &this->transfer_; + return this->length (); +} + +// Decode the transfer buffer into host byte order +// so that it can be used by the client. + +int +ACE_Token_Reply::decode (void) +{ + return 0; +} + +// Print out current values of the ACE_Token_Reply object. + +void +ACE_Token_Reply::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("*******\nlength = %d\nerrnum = %d"), + this->length (), this->errnum ())); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("arg = %d"), this->arg ())); +#endif /* ACE_HAS_DUMP */ +} + +ACE_END_VERSIONED_NAMESPACE_DECL + +#endif /* ACE_HAS_TOKENS_LIBRARY */ diff --git a/dep/ACE_wrappers/ace/Token_Request_Reply.h b/dep/ACE_wrappers/ace/Token_Request_Reply.h new file mode 100644 index 00000000000..01a7cfd3e82 --- /dev/null +++ b/dep/ACE_wrappers/ace/Token_Request_Reply.h @@ -0,0 +1,270 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Token_Request_Reply.h + * + * $Id: Token_Request_Reply.h 80826 2008-03-04 14:51:23Z wotte $ + * + * Define the format used to exchange messages between the + * ACE_Token Server and its clients. + * + * + * @author Douglas C. Schmidt (schmidt@cs.wustl.edu) + * @author Tim Harrison (harrison@cs.wustl.edu) + */ +//============================================================================= + + +#ifndef ACE_TOKEN_REQUEST_REPLY_H +#define ACE_TOKEN_REQUEST_REPLY_H +#include /**/ "ace/pre.h" + +#include "ace/Local_Tokens.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#if defined (ACE_HAS_TOKENS_LIBRARY) + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +/// Specifies the size of the fixed length portion of +/// the Transfer structure in ACE_Token_Request +#define ACE_TOKEN_REQUEST_HEADER_SIZE 40 + +/** + * @class ACE_Token_Request + * + * @brief Message format for delivering requests to the ACE_Token Server. + * + * This class is implemented to minimize data copying. + * In particular, all marshaling is done in situ... + */ +class ACE_Export ACE_Token_Request +{ +public: + /// Operation types. + enum OPERATION + { + /// Acquire the token. + ACQUIRE, + /// Release the token. + RELEASE, + /// Renew the token. + RENEW, + /// Remove the token. + REMOVE, + // Try to acquire the token. + TRY_ACQUIRE + }; + + /// Default constructor. + ACE_Token_Request (void); + + /** + * @param token_type MUTEX, RWLOCK + * @param proxy_type MUTEX, RLOCK, WLOCK (acquires mean different things) + * @param operation method + * @param token_name + * @param client_id + * @param options We check USE_TIMEOUT and use the arg. + */ + ACE_Token_Request (int token_type, + int proxy_type, + ACE_UINT32 operation, + const ACE_TCHAR token_name[], + const ACE_TCHAR client_id[], + const ACE_Synch_Options &options); + + /// Get the length of the encoded/decoded message. + ACE_UINT32 length (void) const; + + /// Set the length of the encoded/decoded message. + void length (ACE_UINT32); + + /// Get the type of proxy + int proxy_type (void) const; + + /// Set the type of proxy + void proxy_type (int proxy_type); + + /// Get the type of token + int token_type (void) const; + + /// Set the type of token + void token_type (int token_type); + + /// Get the type of the operation. + ACE_UINT32 operation_type (void) const; + + /// Set the type of the operation. + void operation_type (ACE_UINT32); + + /// Get the requeue position. These should be used when renew + /// is the operation type. + ACE_UINT32 requeue_position (void) const; + + /// Set the requeue position. These should be used when renew + /// is the operation type. + void requeue_position (ACE_UINT32); + + /// Get notify. These should be used when acquire is the operation type. + ACE_UINT32 notify (void) const; + + /// Set notify. These should be used when acquire is the operation type. + void notify (ACE_UINT32); + + /// Get the timeout. + ACE_Synch_Options &options (void) const; + + /// Set the timeout. + void options (const ACE_Synch_Options &options); + + // = Set/get the name of the token and the client id. The set + // method is combined to make it easier on us. We're copying the + // names as a contiguous buffer. + ACE_TCHAR *token_name (void) const; + ACE_TCHAR *client_id (void) const; + void token_name (const ACE_TCHAR *token_name, const ACE_TCHAR *client_id); + + /// Encode the message before transmission. + int encode (void *&); + + /// Decode message after reception. This must be called to set the + /// internal options. + int decode (void); + + /// Print out the values of the message for debugging purposes. + void dump (void) const; + +private: + // = The 5 fields in the struct are transmitted to the server. + // The remaining 2 fields are not tranferred -- they are used only on + // the server-side to simplify lookups. + + struct Transfer + { + /// Length of entire request. + ACE_UINT32 length_; + + /// Type of the request (i.e., MUTEX, RLOCK, WLOCK... + ACE_UINT32 token_type_; + + /// Type of the request (i.e., MUTEX, RLOCK, WLOCK... + ACE_UINT32 proxy_type_; + + /// Type of the request (i.e., , , , and ). + ACE_UINT32 operation_type_; + + /// this only makes sense when operation type is renew + ACE_UINT32 requeue_position_; + + /// this only makes sense when operation type is renew + ACE_UINT32 notify_; + + // = ACE_Synch_Options stuff + + /// Indicates if we should block forever. If 1, then + /// and indicates how long we should wait. If 0, + /// then we block forever. + ACE_UINT32 use_timeout_; + + /// Max seconds willing to wait for token if not blocking forever. + ACE_UINT32 sec_; + + /// Max micro seconds to wait for token if not blocking forever. + ACE_UINT32 usec_; + + /// value returned in ; + ACE_UINT32 arg_; + + /// The data portion contains the including a 0 terminator, + /// a ':', then the including a 0 terminator + ACE_TCHAR data_[ACE_MAXTOKENNAMELEN + ACE_MAXCLIENTIDLEN + 3]; + } transfer_; + + /// Pointer to the beginning of the token name in this->data_. + ACE_TCHAR *token_name_; + + /// Pointer to the beginning of the client id in this->data_; + ACE_TCHAR *client_id_; + + /// Holds arg, sec, usec, etc. + ACE_Synch_Options options_; +}; + +/** + * @class ACE_Token_Reply + * + * @brief Message format for delivering replies from the ACE_Token Server. + * + * This class is implemented to minimize data copying. + * In particular, all marshaling is done in situ... + */ +class ACE_Export ACE_Token_Reply +{ +public: + /// Default constructor. + ACE_Token_Reply (void); + + /// Get the length of the encoded/decoded message. + ACE_UINT32 length (void) const; + + /// Set the length of the encoded/decoded message. + void length (ACE_UINT32); + + /// Get the errno of a reply. + ACE_UINT32 errnum (void) const; + + /// Set the errno of a reply. + void errnum (ACE_UINT32); + + /// Get the arg of a reply. + ACE_UINT32 arg (void) const; + + /// Set the arg of a reply. + void arg (ACE_UINT32); + + /// Encode the message before transfer. + int encode (void *&); + + /// Decode a message after reception. + int decode (void); + + /// Print out the values of the message for debugging purposes. + void dump (void) const; + +private: + // = The 2 fields in the struct are transmitted to the server. + + struct Transfer + { + /// Length of entire reply. + ACE_UINT32 length_; + + /// Indicates why error occurred if type_> == . + /// Typical reasons include: + /// @c EWOULDBLOCK (if client requested a non-blocking check for the token). + /// @c ETIME (if the client timed out after waiting for the token). + /// (if the token lock was removed out from underneath a waiter). + /// (attempt to renew a token that isn't owned by the client). + ACE_UINT32 errno_; + + /// magic cookie + ACE_UINT32 arg_; + + } transfer_; +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +#include "ace/Token_Request_Reply.inl" +#endif /* __ACE_INLINE__ */ + +#endif /* ACE_HAS_TOKENS_LIBRARY */ + +#include /**/ "ace/post.h" +#endif /* ACE_TOKEN_REQUEST_REPLY_H */ diff --git a/dep/ACE_wrappers/ace/Token_Request_Reply.inl b/dep/ACE_wrappers/ace/Token_Request_Reply.inl new file mode 100644 index 00000000000..4291bfa6089 --- /dev/null +++ b/dep/ACE_wrappers/ace/Token_Request_Reply.inl @@ -0,0 +1,205 @@ +// -*- C++ -*- +// +// $Id: Token_Request_Reply.inl 80826 2008-03-04 14:51:23Z wotte $ + +#if defined (ACE_HAS_TOKENS_LIBRARY) + +#include "ace/Truncate.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +// = Set/get the length of the encoded/decoded message. + +ACE_INLINE ACE_UINT32 +ACE_Token_Request::length (void) const +{ + return ntohl (this->transfer_.length_); +} + +ACE_INLINE void +ACE_Token_Request::length (ACE_UINT32 l) +{ + this->transfer_.length_ = htonl (l); +} + +// = Set/get the type of the message. +ACE_INLINE int +ACE_Token_Request::token_type (void) const +{ + return (int) ntohl (this->transfer_.token_type_); +} + +ACE_INLINE void +ACE_Token_Request::token_type (int t) +{ + this->transfer_.token_type_ = htonl ((ACE_UINT32) t); +} + +// = Set/get the type of the message. +ACE_INLINE int +ACE_Token_Request::proxy_type (void) const +{ + return (int) ntohl (this->transfer_.proxy_type_); +} + +ACE_INLINE void +ACE_Token_Request::proxy_type (int t) +{ + this->transfer_.proxy_type_ = htonl ((ACE_UINT32) t); +} + +// = Set/get the type of the message. +ACE_INLINE ACE_UINT32 +ACE_Token_Request::operation_type (void) const +{ + return ntohl (this->transfer_.operation_type_); +} + +ACE_INLINE void +ACE_Token_Request::operation_type (ACE_UINT32 t) +{ + this->transfer_.operation_type_ = htonl (t); +} + +// = Set/get the requeue position +ACE_INLINE ACE_UINT32 +ACE_Token_Request::requeue_position (void) const +{ + return ntohl (this->transfer_.requeue_position_); +} + +ACE_INLINE void +ACE_Token_Request::requeue_position (ACE_UINT32 rq) +{ + this->transfer_.requeue_position_ = htonl (rq); +} + +// = Set/get the requeue position +ACE_INLINE ACE_UINT32 +ACE_Token_Request::notify (void) const +{ + return ntohl (this->transfer_.notify_); +} + +ACE_INLINE void +ACE_Token_Request::notify (ACE_UINT32 rq) +{ + this->transfer_.notify_ = htonl (rq); +} + +// = Set/get the blocking semantics. +ACE_INLINE ACE_Synch_Options & +ACE_Token_Request::options (void) const +{ + return (ACE_Synch_Options &) options_; +} + +ACE_INLINE void +ACE_Token_Request::options (const ACE_Synch_Options &opt) +{ + // fight the friggin const from hell + ACE_Synch_Options *options = (ACE_Synch_Options *) &opt; + + transfer_.use_timeout_ = options->operator[](ACE_Synch_Options::USE_TIMEOUT); + if (transfer_.use_timeout_ == 1) + { + transfer_.usec_ = options->timeout ().usec (); + if (options->timeout ().sec () > (time_t) ACE_UINT32_MAX) + transfer_.sec_ = ACE_UINT32_MAX; + else + transfer_.sec_ = static_cast (options->timeout ().sec ()); + } + else + { + transfer_.usec_ = 0; + transfer_.sec_ = 0; + } +} + +// = Set/get the name of the token. +ACE_INLINE ACE_TCHAR * +ACE_Token_Request::token_name (void) const +{ + return token_name_; +} + +ACE_INLINE void +ACE_Token_Request::token_name (const ACE_TCHAR *token_name, + const ACE_TCHAR *client_id) +{ + size_t token_name_length = ACE_OS::strlen (token_name) + 1; // Add 1 for '\0'. + size_t client_id_length = ACE_OS::strlen (client_id) + 1; // Add 1 for '\0'. + + // Set up pointers and copy token_name and client_id into request. + token_name_ = this->transfer_.data_; + client_id_ = &this->token_name_[token_name_length + 1]; // Add 1 for ':'; + client_id_[-1] = ACE_TEXT (':'); // Insert the ':' before this->clientId_. + + (void) ACE_OS::memcpy (this->token_name_, + token_name, + token_name_length * sizeof (ACE_TCHAR)); + (void) ACE_OS::memcpy (this->client_id_, + client_id, + client_id_length * sizeof (ACE_TCHAR)); + + // Fixed length header size + size_t len = ACE_TOKEN_REQUEST_HEADER_SIZE; + + // ... then add in the amount of the variable-sized portion. + len += token_name_length + client_id_length + 1; + this->length (ACE_Utils::truncate_cast (len)); +} + +// = Set/get the id of the client. +ACE_INLINE ACE_TCHAR * +ACE_Token_Request::client_id (void) const +{ + return this->client_id_; +} + +// ************************************************************ +// ************************************************************ +// ************************************************************ + +// = Set/get the length of the encoded/decoded message. +ACE_INLINE ACE_UINT32 +ACE_Token_Reply::length (void) const +{ + return ntohl (this->transfer_.length_); +} + +ACE_INLINE void +ACE_Token_Reply::length (ACE_UINT32 l) +{ + this->transfer_.length_ = htonl (l); +} + +// = Set/get the errno of a failed reply. +ACE_INLINE ACE_UINT32 +ACE_Token_Reply::errnum (void) const +{ + return ntohl (this->transfer_.errno_); +} + +ACE_INLINE void +ACE_Token_Reply::errnum (ACE_UINT32 e) +{ + this->transfer_.errno_ = htonl (e); +} + +// = Set/get the length of the encoded/decoded message. +ACE_INLINE ACE_UINT32 +ACE_Token_Reply::arg (void) const +{ + return ntohl (this->transfer_.arg_); +} + +ACE_INLINE void +ACE_Token_Reply::arg (ACE_UINT32 arg) +{ + this->transfer_.arg_ = htonl (arg); +} + +ACE_END_VERSIONED_NAMESPACE_DECL + +#endif /* ACE_HAS_TOKENS_LIBRARY */ diff --git a/dep/ACE_wrappers/ace/Trace.cpp b/dep/ACE_wrappers/ace/Trace.cpp new file mode 100644 index 00000000000..12ccf135ebd --- /dev/null +++ b/dep/ACE_wrappers/ace/Trace.cpp @@ -0,0 +1,137 @@ +// $Id: Trace.cpp 80826 2008-03-04 14:51:23Z wotte $ + + +#include "ace/Trace.h" + +ACE_RCSID (ace, + Trace, + "$Id: Trace.cpp 80826 2008-03-04 14:51:23Z wotte $") + +// Turn off tracing for the duration of this file. +#if defined (ACE_NTRACE) +#undef ACE_NTRACE +#endif /* ACE_NTRACE */ +#define ACE_NTRACE 1 + +#include "ace/Log_Msg.h" +#include "ace/Object_Manager_Base.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +// = Static initialization. + +// Keeps track of how far to indent per trace call. +int ACE_Trace::nesting_indent_ = ACE_Trace::DEFAULT_INDENT; + +// Is tracing enabled? +int ACE_Trace::enable_tracing_ = ACE_Trace::DEFAULT_TRACING; + +ACE_ALLOC_HOOK_DEFINE(ACE_Trace) + +void +ACE_Trace::dump (void) const +{ +#if defined (ACE_HAS_DUMP) +#endif /* ACE_HAS_DUMP */ +} + +// Determine whether or not tracing is enabled + +int +ACE_Trace::is_tracing (void) +{ + return ACE_Trace::enable_tracing_; +} + +// Enable the tracing facility. + +void +ACE_Trace::start_tracing (void) +{ + ACE_Trace::enable_tracing_ = 1; +} + +// Disable the tracing facility. + +void +ACE_Trace::stop_tracing (void) +{ + ACE_Trace::enable_tracing_ = 0; +} + +// Change the nesting indentation level. + +void +ACE_Trace::set_nesting_indent (int indent) +{ + ACE_Trace::nesting_indent_ = indent; +} + +// Get the nesting indentation level. + +int +ACE_Trace::get_nesting_indent (void) +{ + return ACE_Trace::nesting_indent_; +} + +// Perform the first part of the trace, which prints out the string N, +// the LINE, and the ACE_FILE as the function is entered. + +ACE_Trace::ACE_Trace (const ACE_TCHAR *n, + int line, + const ACE_TCHAR *file) +{ +#if defined (ACE_NLOGGING) + ACE_UNUSED_ARG (line); + ACE_UNUSED_ARG (file); +#endif /* ACE_NLOGGING */ + + this->name_ = n; + + // If ACE has not yet been initialized, don't try to trace... there's + // too much stuff not yet initialized. + if (ACE_Trace::enable_tracing_ && !ACE_OS_Object_Manager::starting_up ()) + { + ACE_Log_Msg *lm = ACE_LOG_MSG; + if (lm->tracing_enabled () + && lm->trace_active () == 0) + { + lm->trace_active (1); + ACE_DEBUG ((LM_TRACE, + ACE_TEXT ("%*s(%t) calling %s in file `%s' on line %d\n"), + ACE_Trace::nesting_indent_ * lm->inc (), + ACE_TEXT (""), + this->name_, + file, + line)); + lm->trace_active (0); + } + } +} + +// Perform the second part of the trace, which prints out the NAME as +// the function is exited. + +ACE_Trace::~ACE_Trace (void) +{ + // If ACE has not yet been initialized, don't try to trace... there's + // too much stuff not yet initialized. + if (ACE_Trace::enable_tracing_ && !ACE_OS_Object_Manager::starting_up ()) + { + ACE_Log_Msg *lm = ACE_LOG_MSG; + if (lm->tracing_enabled () + && lm->trace_active () == 0) + { + lm->trace_active (1); + ACE_DEBUG ((LM_TRACE, + ACE_TEXT ("%*s(%t) leaving %s\n"), + ACE_Trace::nesting_indent_ * lm->dec (), + ACE_TEXT (""), + this->name_)); + lm->trace_active (0); + } + } +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Trace.h b/dep/ACE_wrappers/ace/Trace.h new file mode 100644 index 00000000000..f11d634ee17 --- /dev/null +++ b/dep/ACE_wrappers/ace/Trace.h @@ -0,0 +1,96 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Trace.h + * + * $Id: Trace.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Douglas C. Schmidt + */ +//============================================================================= + +#ifndef ACE_TRACE_H +#define ACE_TRACE_H + +#include /**/ "ace/pre.h" + +#include /**/ "ace/ACE_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +/** + * @class ACE_Trace + * + * @brief A C++ trace facility that keeps track of which methods are + * entered and exited. + * + * This class uses C++ constructors and destructors to automate + * the ACE_Trace nesting. In addition, thread-specific storage + * is used to enable multiple threads to work correctly. + */ +class ACE_Export ACE_Trace +{ +public: + // = Initialization and termination methods. + + /// Perform the first part of the trace, which prints out the string + /// N, the LINE, and the ACE_FILE as the function is entered. + ACE_Trace (const ACE_TCHAR *n, + int line = 0, + const ACE_TCHAR *file = ACE_TEXT ("")); + + /// Perform the second part of the trace, which prints out the NAME + /// as the function is exited. + ~ACE_Trace (void); + + // = Control the tracing level. + /// Determine if tracing is enabled (return == 1) or not (== 0) + static int is_tracing(void); + + /// Enable the tracing facility. + static void start_tracing (void); + + /// Disable the tracing facility. + static void stop_tracing (void); + + /// Change the nesting indentation level. + static void set_nesting_indent (int indent); + + /// Get the nesting indentation level. + static int get_nesting_indent (void); + + /// Dump the state of an object. + void dump (void) const; + +private: + // Keeps track of how deeply the call stack is nested (this is + // maintained in thread-specific storage to ensure correctness in + // multiple threads of control. + + /// Name of the method we are in. + const ACE_TCHAR *name_; + + /// Keeps track of how far to indent per trace call. + static int nesting_indent_; + + /// Is tracing enabled? + static int enable_tracing_; + + /// Default values. + enum + { + DEFAULT_INDENT = 3, + DEFAULT_TRACING = 1 + }; +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#include /**/ "ace/post.h" + +#endif /* ACE_TRACE_H */ diff --git a/dep/ACE_wrappers/ace/Truncate.h b/dep/ACE_wrappers/ace/Truncate.h new file mode 100644 index 00000000000..5b9a0e1187a --- /dev/null +++ b/dep/ACE_wrappers/ace/Truncate.h @@ -0,0 +1,1055 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Truncate.h + * + * $Id: Truncate.h 82623 2008-08-13 14:41:09Z johnnyw $ + * + * @author Steve Huston + * @author Ossama Othman + * @author Russell Mora + */ +//============================================================================= + +#ifndef ACE_TRUNCATE_H +#define ACE_TRUNCATE_H + +#include /**/ "ace/pre.h" + +#include "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/Global_Macros.h" +#include "ace/If_Then_Else.h" +#include "ace/Numeric_Limits.h" + +#if defined (ACE_LACKS_LONGLONG_T) \ + || defined (__BORLANDC__) && __BORLANDC__ < 0x590 +# include "ace/Basic_Types.h" +#endif /* ACE_LACKS_LONGLONG_T || __BORLANDC__ < 0x590 */ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +namespace ACE_Utils +{ + +#if !defined (__BORLANDC__) || __BORLANDC__ >= 0x590 + + template struct Sign_Check; + + // Specialize the unsigned signed cases. + template<> struct Sign_Check { ACE_STATIC_CONSTANT (bool, is_signed = 0); }; + template<> struct Sign_Check { ACE_STATIC_CONSTANT (bool, is_signed = 0); }; + template<> struct Sign_Check { ACE_STATIC_CONSTANT (bool, is_signed = 0); }; + template<> struct Sign_Check { ACE_STATIC_CONSTANT (bool, is_signed = 0); }; +#if !(defined(ACE_LACKS_LONGLONG_T) || defined(ACE_LACKS_UNSIGNEDLONGLONG_T)) +# ifdef __GNUC__ + // Silence g++ "-pedantic" warnings regarding use of "long long" + // type. + __extension__ +# endif /* __GNUC__ */ + template<> struct Sign_Check { ACE_STATIC_CONSTANT (bool, is_signed = 0); }; +#else + template<> struct Sign_Check { ACE_STATIC_CONSTANT (bool, is_signed = 0); }; +#endif /* !ACE_LACKS_LONGLONG_T */ + + // Specialize the signed cases. + template<> struct Sign_Check { ACE_STATIC_CONSTANT (bool, is_signed = 1); }; + template<> struct Sign_Check { ACE_STATIC_CONSTANT (bool, is_signed = 1); }; + template<> struct Sign_Check { ACE_STATIC_CONSTANT (bool, is_signed = 1); }; + template<> struct Sign_Check { ACE_STATIC_CONSTANT (bool, is_signed = 1); }; +#ifndef ACE_LACKS_LONGLONG_T +# ifdef __GNUC__ + // Silence g++ "-pedantic" warnings regarding use of "long long" + // type. + __extension__ +# endif /* __GNUC__ */ + template<> struct Sign_Check { ACE_STATIC_CONSTANT (bool, is_signed = 1); }; +#endif /* !ACE_LACKS_LONGLONG_T */ + + // ----------------------------------------------------- + + /** + * @struct To_Unsigned + * + * @brief Retrieve unsigned counterpart to given type or value. + * + * Retrieve unsigned counterpart to given type or value. + */ + template struct To_Unsigned; + + template<> + struct To_Unsigned + { + typedef unsigned char unsigned_type; + + unsigned_type operator() (unsigned_type x) { return x; } + }; + + template<> + struct To_Unsigned + { + typedef unsigned short unsigned_type; + + unsigned_type operator() (unsigned_type x) { return x; } + }; + + template<> + struct To_Unsigned + { + typedef unsigned int unsigned_type; + + unsigned_type operator() (unsigned_type x) { return x; } + }; + + template<> + struct To_Unsigned + { + typedef unsigned long unsigned_type; + + unsigned_type operator() (unsigned_type x) { return x; } + }; + +#if !(defined(ACE_LACKS_LONGLONG_T) || defined(ACE_LACKS_UNSIGNEDLONGLONG_T)) +# ifdef __GNUC__ + // Silence g++ "-pedantic" warnings regarding use of "long long" + // type. + __extension__ +# endif /* __GNUC__ */ + template<> + struct To_Unsigned + { + typedef unsigned long long unsigned_type; + + unsigned_type operator() (unsigned_type x) { return x; } + }; +#else + template<> + struct To_Unsigned + { + typedef ACE_U_LongLong unsigned_type; + + unsigned_type operator() (unsigned_type x) { return x; } + }; +#endif /* !ACE_LACKS_LONGLONG_T */ + + // ---------------- + + template<> + struct To_Unsigned + { + typedef signed char signed_type; + typedef unsigned char unsigned_type; + + unsigned_type operator() (signed_type x) + { + return static_cast (x); + } + }; + + template<> + struct To_Unsigned + { + typedef signed short signed_type; + typedef unsigned short unsigned_type; + + unsigned_type operator() (signed_type x) + { + return static_cast (x); + } + }; + + template<> + struct To_Unsigned + { + typedef signed int signed_type; + typedef unsigned int unsigned_type; + + unsigned_type operator() (signed_type x) + { + return static_cast (x); + } + }; + + template<> + struct To_Unsigned + { + typedef signed long signed_type; + typedef unsigned long unsigned_type; + + unsigned_type operator() (signed_type x) + { + return static_cast (x); + } + }; + +#if !(defined(ACE_LACKS_LONGLONG_T) || defined(ACE_LACKS_UNSIGNEDLONGLONG_T)) +# ifdef __GNUC__ + // Silence g++ "-pedantic" warnings regarding use of "long long" + // type. + __extension__ +# endif /* __GNUC__ */ + template<> + struct To_Unsigned + { + typedef signed long long signed_type; + typedef unsigned long long unsigned_type; + + unsigned_type operator() (signed_type x) + { + return static_cast (x); + } + }; +#endif /* !ACE_LACKS_LONGLONG_T */ + + // ----------------------------------------------------- + + /** + * @struct Safe_Comparator + * + * @brief Conservative comparison of types that may not be safely + * promoted and/or converted to each other. + * + * The comparison operations provided by this structure perform + * negative value checking when necessary to prevent wrap-around + * when explicitly casting to an unsigned type. + * + * @internal This structure is not meant for general use. + */ + template struct Safe_Comparator; + + // LEFT: signed, RIGHT: unsigned + template + struct Safe_Comparator + { + static bool greater_than (LEFT lhs, RIGHT rhs) + { + // Prevent wrap-around when casting to unsigned. + if (lhs < 0) + return false; // since rhs is always positive + else + { + // Implicit promotion of unsigned LEFT and RIGHT types here. + return To_Unsigned() (lhs) > rhs; + } + } + }; + + // LEFT: unsigned, RIGHT: signed + template + struct Safe_Comparator + { + static bool greater_than (LEFT lhs, RIGHT rhs) + { + // Prevent wrap-around when casting to unsigned. + if (rhs < 0) + return true; // since lhs is always positive + else + { + // Implicit promotion of unsigned LEFT and RIGHT types here. + return lhs > To_Unsigned() (rhs); + } + } + }; + + // LEFT: unsigned, RIGHT: unsigned + template + struct Safe_Comparator + { + static bool greater_than (LEFT lhs, RIGHT rhs) + { + // Implicit promotion of unsigned LEFT and RIGHT types here. + return lhs > rhs; + } + }; + + // LEFT: signed, RIGHT: signed + template + struct Safe_Comparator + { + static bool greater_than (LEFT lhs, RIGHT rhs) + { + // Implicit promotion of signed LEFT and RIGHT types here. + return lhs > rhs; + } + }; + + // ----------------------------------------------------- + + /** + * @struct Fast_Comparator + * + * @brief Quick comparison of types that can be safely promoted + * and/or converted to each other. + * + * The comparison operations provided by this structure perform no + * negative value checking, meaning it is not applicable to all + * types. Check the value of the @c USABLE enumerator to determine + * if it applies to the types in question. + * + * @internal This structure is not meant for general use. + */ + template + struct Fast_Comparator + { + ACE_STATIC_CONSTANT ( + bool, + USE_LEFT = ((sizeof (LEFT) > sizeof (RIGHT) + && (Sign_Check::is_signed == 1 + || Sign_Check::is_signed == 0)) + + // The following is basically the case where LEFT + // and RIGHT are the same integral type. + || (sizeof (LEFT) == sizeof (RIGHT) + // Can't portably do + // Sign_Check::is_signed == + // Sign_Check::is_signed, + // i.e. comparison of anonymous enumerations, + // without triggering a compiler diagnostic + // so expand the comparison. + && ((Sign_Check::is_signed == 1 + && Sign_Check::is_signed == 1) + || (Sign_Check::is_signed == 0 + && Sign_Check::is_signed == 0))))); + + ACE_STATIC_CONSTANT ( + bool, + USE_RIGHT = (sizeof (RIGHT) > sizeof (LEFT) + && (Sign_Check::is_signed == 1 + || Sign_Check::is_signed == 0))); + + ACE_STATIC_CONSTANT (bool, USABLE = (USE_LEFT || USE_RIGHT)); + + typedef typename ACE::If_Then_Else< + USE_LEFT, + LEFT, + typename ACE::If_Then_Else< + USE_RIGHT, + RIGHT, + void>::result_type>::result_type promote_type; + + static bool greater_than (LEFT lhs, RIGHT rhs) + { + // The explicit cast is assumed to change the type of rhs without + // changing its value. + return + (static_cast (lhs) > static_cast (rhs)); + } + + }; + + // ----------------------------------------------------- + + /** + * @struct Comparator + * + * @brief Structure that provides optimal comparison operation for + * given types. + * + * The comparison operations provided by this structure are chosen + * at compile time based on the signs and sizes of types being + * compared. + * @par + * Comparisons of values with the same sign or those with types that + * can be promoted safely are done quickly, without any range + * checking. + * @par + * Comparisons of values of different types that cannot be safely + * promoted incur an additional check for a negative value to allow + * the compiler to perform the appropriate implicit unsigned type + * promotion. + * + * @note In general, the operations found in this structure should + * not be used to work around compiler diagnostics regarding + * comparison of signed and unsigned types. Verify that your + * types are correct before relying on those operations. + * + * @internal This structure is not meant for general use. + */ + template + struct Comparator + { + typedef typename ACE::If_Then_Else< + Fast_Comparator::USABLE, + Fast_Comparator, + Safe_Comparator::is_signed, + Sign_Check::is_signed> >::result_type comp_type; + }; + + // ----------------------------------------------------- + + /** + * @struct Truncator + * + * @brief Truncate value of type @c FROM to value of type @c TO. + * + * Truncate a value of type @c FROM to value of type @c TO, if the + * value is larger than the maximum of value of type @c TO. + */ + template + struct Truncator + { + ACE_STATIC_CONSTANT ( + bool, + // max FROM always greater than max TO + MAX_FROM_GT_MAX_TO = (sizeof(FROM) > sizeof (TO) + || (sizeof(FROM) == sizeof (TO) + && Sign_Check::is_signed == 0))); + + typedef typename ACE::If_Then_Else< + MAX_FROM_GT_MAX_TO, + FROM, + TO>::result_type comp_to_type; + + // Take advantage of knowledge that we're casting a positive value + // to a type large enough to hold it so that we can bypass + // negative value checks at compile-time. Otherwise fallback on + // the safer comparison. + typedef typename ACE::If_Then_Else< + MAX_FROM_GT_MAX_TO, + Fast_Comparator, + typename Comparator::comp_type>::result_type comparator; + + /// Truncate a value of type @c FROM to value of type @c TO, if + /// the value is larger than the maximum of value of type @c TO. + TO operator() (FROM val) + { + return + (comparator::greater_than (val, ACE_Numeric_Limits::max ()) + ? ACE_Numeric_Limits::max () + : static_cast (val)); + } + + }; + + // Partial specialization for the case where the types are the same. + // No truncation is necessary. + template + struct Truncator + { + T operator() (T val) + { + return val; + } + }; + + +#if defined (ACE_LACKS_LONGLONG_T) || defined (ACE_LACKS_UNSIGNEDLONGLONG_T) + // Partial specialization for the case where we're casting from + // ACE_U_LongLong to a smaller integer. We assume that we're always + // truncating from ACE_U_LongLong to a smaller type. The partial + // specialization above handles the case where both the FROM and TO + // types are ACE_U_LongLong. + template + struct Truncator + { + TO operator() (ACE_U_LongLong const & val) + { + // If val less than or equal to ACE_Numeric_Limits::max(), + // val.lo() must be less than or equal to + // ACE_Numeric_Limits::max (), as well. + return + (val > ACE_Numeric_Limits::max () + ? ACE_Numeric_Limits::max () + : static_cast (val.lo ())); + } + }; +#endif /* ACE_LACKS_LONGLONG_T || ACE_LACKS_UNSIGNEDLONGLONG_T */ + + // ----------------------------------------------------- + /** + * @struct Noop_Truncator + * + * @brief No-op truncation. + * + * This structure/functor performs no truncation since it assumes + * that @c sizeof(FROM) @c < @c sizeof(TO), meaning that + * @c numeric_limits::max() @c < @c numeric_limits::max(). + */ + template + struct Noop_Truncator + { + TO operator() (FROM val) + { + return static_cast (val); + } + }; + // ----------------------------------------------------- + + /** + * @class truncate_cast + * + * @brief Helper function to truncate an integral value to the + * maximum value of the given type. + * + * Very useful since ACE methods return @c int very often and + * the value's source is often a different-size integral + * type, such as @c size_t. This function hides the + * truncation logic and resolves compiler diagnostics. + * + * @internal Internal use only. + */ + template + inline TO truncate_cast (FROM val) + { + // If the size of FROM is less than the size of TO, "val" will + // never be greater than the maximum "TO" value, so there is no + // need to attempt to truncate. + typedef typename ACE::If_Then_Else< + (sizeof (FROM) < sizeof (TO)), + Noop_Truncator, + Truncator >::result_type truncator; + + return truncator() (val); + } + +#else + + // Borland can't handle the template meta-programming above so + // provide explicit specializations for a few types. More will be + // added if necessary. + + /** + * @deprecated Borland ACE_Utils::Truncator<> specializations should + * be removed. + */ + + template struct Truncator; + + //---------------------------------------------------------- + // sizeof(FROM) > sizeof(TO) + //---------------------------------------------------------- + + template<> + struct Truncator + { + ACE_INT8 operator() (ACE_INT32 val) + { + return + (val > ACE_Numeric_Limits::max () + ? ACE_Numeric_Limits::max () + : static_cast (val)); + } + }; + + template<> + struct Truncator + { + ACE_UINT8 operator() (ACE_UINT32 val) + { + return + (val > static_cast (ACE_Numeric_Limits::max ()) + ? ACE_Numeric_Limits::max () + : static_cast (val)); + } + }; + + template<> + struct Truncator + { + ACE_UINT8 operator() (ACE_INT32 val) + { + return + (val > static_cast (ACE_Numeric_Limits::max ()) + ? ACE_Numeric_Limits::max () + : static_cast (val)); + } + }; + + template<> + struct Truncator + { + ACE_INT8 operator() (ACE_UINT32 val) + { + return + (val > static_cast (ACE_Numeric_Limits::max ()) + ? ACE_Numeric_Limits::max () + : static_cast (val)); + } + }; + +#if defined (ACE_SIZEOF_LONG) && ACE_SIZEOF_LONG < 8 + template<> + struct Truncator + { + signed long operator() (ACE_INT64 val) + { + return + (val > ACE_Numeric_Limits::max () + ? ACE_Numeric_Limits::max () + : static_cast (val)); + } + }; + + template<> + struct Truncator + { + unsigned long operator() (ACE_INT64 val) + { + return + (val > static_cast (ACE_Numeric_Limits::max ()) + ? ACE_Numeric_Limits::max () + : static_cast (val)); + } + }; + + template<> + struct Truncator + { + unsigned long operator() (ACE_UINT64 val) + { + return + (val > static_cast (ACE_Numeric_Limits::max ()) + ? ACE_Numeric_Limits::max () + : static_cast (val)); + } + }; + + template<> + struct Truncator + { + signed long operator() (ACE_UINT64 val) + { + return + (val > static_cast (ACE_Numeric_Limits::max ()) + ? ACE_Numeric_Limits::max () + : static_cast (val)); + } + }; + + template<> + struct Truncator + { + signed long operator() (const ACE_UINT64 val) + { + return + (val > static_cast (ACE_Numeric_Limits::max ()) + ? ACE_Numeric_Limits::max () + : static_cast (val)); + } + }; + +#endif /* ACE_SIZEOF_LONG < 8 */ + +#if defined (ACE_SIZEOF_INT) && ACE_SIZEOF_INT < 8 + template<> + struct Truncator + { + ACE_INT32 operator() (ACE_INT64 val) + { + return + (val > ACE_Numeric_Limits::max () + ? ACE_Numeric_Limits::max () + : static_cast (val)); + } + }; + + template<> + struct Truncator + { + ACE_UINT32 operator() (ACE_INT64 val) + { + return + (val > static_cast (ACE_Numeric_Limits::max ()) + ? ACE_Numeric_Limits::max () + : static_cast (val)); + } + }; + + template<> + struct Truncator + { + ACE_UINT32 operator() (ACE_UINT64 val) + { + return + (val > static_cast (ACE_Numeric_Limits::max ()) + ? ACE_Numeric_Limits::max () + : static_cast (val)); + } + }; + + template<> + struct Truncator + { + signed int operator() (ACE_UINT64 val) + { + return + (val > static_cast (ACE_Numeric_Limits::max ()) + ? ACE_Numeric_Limits::max () + : static_cast (val)); + } + }; + +#endif /* ACE_SIZEOF_INT < 8 */ + + //---------------------------------------------------------- + // sizeof(FROM) == sizeof(TO) + //---------------------------------------------------------- + + template<> + struct Truncator + { + char operator() (unsigned int val) + { + return static_cast (val); + } + }; + + template<> + struct Truncator + { + wchar_t operator() (unsigned int val) + { + return static_cast (val); + } + }; + + template<> + struct Truncator + { + unsigned int operator() (signed int val) + { + return static_cast (val); + } + }; + + template<> + struct Truncator + { + signed int operator() (unsigned int val) + { + return + (val > static_cast (ACE_Numeric_Limits::max ()) + ? ACE_Numeric_Limits::max () + : static_cast (val)); + } + }; + + template<> + struct Truncator + { + signed int operator() (const unsigned int val) + { + return + (val > static_cast (ACE_Numeric_Limits::max ()) + ? ACE_Numeric_Limits::max () + : static_cast (val)); + } + }; + + template<> + struct Truncator + { + unsigned long operator() (signed long val) + { + return static_cast (val); + } + }; + + template<> + struct Truncator + { + signed long operator() (unsigned long val) + { + return + (val > static_cast (ACE_Numeric_Limits::max ()) + ? ACE_Numeric_Limits::max () + : static_cast (val)); + } + }; + +#if defined (ACE_SIZEOF_INT) && defined (ACE_SIZEOF_LONG) \ + && ACE_SIZEOF_INT == ACE_SIZEOF_LONG + + template<> + struct Truncator + { + unsigned long operator() (signed int val) + { + return static_cast (val); + } + }; + + template<> + struct Truncator + { + signed long operator() (signed int val) + { + return static_cast (val); + } + }; + + template<> + struct Truncator + { + signed int operator() (unsigned long val) + { + return + (val > static_cast (ACE_Numeric_Limits::max ()) + ? ACE_Numeric_Limits::max () + : static_cast (val)); + } + }; + + template<> + struct Truncator + { + signed int operator() (signed long val) + { + return static_cast (val); +// This code causes asserts and compiler crashes with BCB6 Static and +// BCB2007 Static +// return +// (val > static_cast (ACE_Numeric_Limits::max ()) +// ? ACE_Numeric_Limits::max () +// : static_cast (val)); + } + }; + + template<> + struct Truncator + { + unsigned int operator() (signed long val) + { + return static_cast (val); + } + }; + + template<> + struct Truncator + { + unsigned int operator() (const signed long val) + { + return static_cast (val); + } + }; + + + template<> + struct Truncator + { + signed long operator() (unsigned int val) + { + return + (val > static_cast (ACE_Numeric_Limits::max ()) + ? ACE_Numeric_Limits::max () + : static_cast (val)); + } + }; + +#endif /* ACE_SIZEOF_INT == ACE_SIZEOF_LONG */ + + template<> + struct Truncator + { + ACE_UINT64 operator() (ACE_INT64 val) + { + return static_cast (val); + } + }; + + template<> + struct Truncator + { + ACE_INT64 operator() (ACE_UINT64 val) + { + return + (val > static_cast (ACE_Numeric_Limits::max ()) + ? ACE_Numeric_Limits::max () + : static_cast (val)); + } + }; + + //---------------------------------------------------------- + // sizeof(FROM) < sizeof(TO) + //---------------------------------------------------------- + + template<> + struct Truncator + { + ACE_INT32 operator() (ACE_INT8 val) + { + return static_cast (val); + } + }; + + template<> + struct Truncator + { + ACE_UINT32 operator() (ACE_UINT8 val) + { + return static_cast (val); + } + }; + + template<> + struct Truncator + { + ACE_INT32 operator() (ACE_UINT8 val) + { + return static_cast (val); + } + }; + + template<> + struct Truncator + { + ACE_UINT32 operator() (ACE_INT8 val) + { + return static_cast (val); + } + }; + +#if defined (ACE_SIZEOF_LONG) && ACE_SIZEOF_LONG < 8 + template<> + struct Truncator + { + ACE_INT64 operator() (signed long val) + { + return static_cast (val); + } + }; + + template<> + struct Truncator + { + ACE_UINT64 operator() (signed long val) + { + return static_cast (val); + } + }; + + template<> + struct Truncator + { + ACE_UINT64 operator() (const signed long val) + { + return + (val > static_cast (ACE_Numeric_Limits::max ()) + ? ACE_Numeric_Limits::max () + : static_cast (val)); + } + }; + + template<> + struct Truncator + { + ACE_UINT64 operator() (unsigned long val) + { + return static_cast (val); + } + }; + + template<> + struct Truncator + { + ACE_INT64 operator() (unsigned long val) + { + return static_cast (val); + } + }; +#endif /* ACE_SIZEOF_LONG < 8 */ + +#if defined (ACE_SIZEOF_INT) && ACE_SIZEOF_INT < 8 + template<> + struct Truncator + { + ACE_INT64 operator() (signed int val) + { + return static_cast (val); + } + }; + + template<> + struct Truncator + { + ACE_UINT64 operator() (signed int val) + { + return static_cast (val); + } + }; + + template<> + struct Truncator + { + ACE_UINT64 operator() (unsigned int val) + { + return static_cast (val); + } + }; + + template<> + struct Truncator + { + ACE_INT64 operator() (unsigned int val) + { + return static_cast (val); + } + }; +#endif /* ACE_SIZEOF_INT < 8 */ + + template<> + struct Truncator + { + unsigned long operator() (size_t val) + { + return + (val > static_cast (ACE_Numeric_Limits::max ()) + ? ACE_Numeric_Limits::max () + : static_cast (val)); + } + }; + + // Partial specialization for the case where the types are the same. + // No truncation is necessary. + template + struct Truncator + { + T operator() (T val) + { + return val; + } + }; + + // Partial specialization for the case where the types are the same, + // but the from type is const. No truncation is necessary. + // + // This is only necessary to workaround a problem with the BCB6 + // compiler. + template + struct Truncator + { + T operator() (T val) + { + return val; + } + }; + + // ------------------------------------- + + template + inline TO truncate_cast (FROM val) + { + typedef Truncator truncator; + + return truncator() (val); + } + +#endif /* !__BORLANDC__ || __BORLANDC__ >= 0x590 */ + +} // namespace ACE_Utils + +ACE_END_VERSIONED_NAMESPACE_DECL + +#include /**/ "ace/post.h" + +#endif /* ACE_TRUNCATE_H*/ diff --git a/dep/ACE_wrappers/ace/Typed_SV_Message.cpp b/dep/ACE_wrappers/ace/Typed_SV_Message.cpp new file mode 100644 index 00000000000..6be3d4c682a --- /dev/null +++ b/dep/ACE_wrappers/ace/Typed_SV_Message.cpp @@ -0,0 +1,30 @@ +// $Id: Typed_SV_Message.cpp 80826 2008-03-04 14:51:23Z wotte $ + +#ifndef ACE_TYPED_SV_MESSAGE_CPP +#define ACE_TYPED_SV_MESSAGE_CPP + +#include "ace/Typed_SV_Message.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#if !defined (__ACE_INLINE__) +#include "ace/Typed_SV_Message.inl" +#endif /* __ACE_INLINE__ */ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_ALLOC_HOOK_DEFINE(ACE_Typed_SV_Message) + +template void +ACE_Typed_SV_Message::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + ACE_TRACE ("ACE_Typed_SV_Message::dump"); +#endif /* ACE_HAS_DUMP */ +} + +ACE_END_VERSIONED_NAMESPACE_DECL + +#endif /* ACE_TYPED_SV_MESSAGE_CPP */ diff --git a/dep/ACE_wrappers/ace/Typed_SV_Message.h b/dep/ACE_wrappers/ace/Typed_SV_Message.h new file mode 100644 index 00000000000..b43258e01a3 --- /dev/null +++ b/dep/ACE_wrappers/ace/Typed_SV_Message.h @@ -0,0 +1,107 @@ +// -*- C++ -*- + +//========================================================================== +/** + * @file Typed_SV_Message.h + * + * $Id: Typed_SV_Message.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Doug Schmidt + */ +//========================================================================== + + +#ifndef ACE_TYPED_SV_MESSAGE_H +#define ACE_TYPED_SV_MESSAGE_H + +#include /**/ "ace/pre.h" + +#include /**/ "ace/ACE_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +/** + * @class ACE_Typed_SV_Message + * + * @brief Defines the header file for the C++ wrapper for System V + * message queues. + */ +template +class ACE_Typed_SV_Message +{ +public: + // = Initialization and termination methods. + ACE_Typed_SV_Message (long type = 0, + int length = sizeof (T), + int max_size = sizeof (T)); + ACE_Typed_SV_Message (const T &data, + long type = 0, + int length = sizeof (T), + int max_size = sizeof (T)); + ~ACE_Typed_SV_Message (void); + + /// Get the type of the message. + long type (void) const; + + /// Set the type of the message. + void type (long type); + + /// Get the length of the message. + int length (void) const; + + /// Set the length of the message. + void length (int l); + + /// Get the maximum size of the message. + int max_size (void) const; + + /// Set the maximum size of the message. + void max_size (int m); + + /// Get a pointer to the data in the message. + T &data (void); + + /// Set a pointer to the data in the message. + void data (const T &data); + + /// Dump the state of an object. + void dump (void) const; + + /// Declare the dynamic allocation hooks. + ACE_ALLOC_HOOK_DECLARE; + +private: + /// Type of message. + long type_; + + /// Length of this message. + int length_; + + /// Maximum length of any message. + int max_; + + /// Data stored in a message. + T data_; +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +#include "ace/Typed_SV_Message.inl" +#endif /* __ACE_INLINE__ */ + +#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) +#include "ace/Typed_SV_Message.cpp" +#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ + +#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) +#pragma implementation ("Typed_SV_Message.cpp") +#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ + +#include /**/ "ace/post.h" + +#endif /* ACE_TYPED_SV_MESSAGE_H */ diff --git a/dep/ACE_wrappers/ace/Typed_SV_Message.inl b/dep/ACE_wrappers/ace/Typed_SV_Message.inl new file mode 100644 index 00000000000..6d8ea702321 --- /dev/null +++ b/dep/ACE_wrappers/ace/Typed_SV_Message.inl @@ -0,0 +1,96 @@ +// -*- C++ -*- +// +// $Id: Typed_SV_Message.inl 80826 2008-03-04 14:51:23Z wotte $ + +#include "ace/config-all.h" +#include "ace/Global_Macros.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +template ACE_INLINE +ACE_Typed_SV_Message::ACE_Typed_SV_Message (long t, + int l, + int m) + : type_ (t) +{ + ACE_TRACE ("ACE_Typed_SV_Message::ACE_Typed_SV_Message"); + this->length (l); + this->max_size (m); +} + +template ACE_INLINE +ACE_Typed_SV_Message::ACE_Typed_SV_Message (const T &d, + long t, + int l, + int m) + : type_ (t), + data_ (d) +{ + ACE_TRACE ("ACE_Typed_SV_Message::ACE_Typed_SV_Message"); + this->length (l); + this->max_size (m); +} + +template ACE_INLINE +ACE_Typed_SV_Message::~ACE_Typed_SV_Message (void) +{ + ACE_TRACE ("ACE_Typed_SV_Message::~ACE_Typed_SV_Message"); +} + +template ACE_INLINE long +ACE_Typed_SV_Message::type (void) const +{ + ACE_TRACE ("ACE_Typed_SV_Message::type"); + return this->type_; +} + +template ACE_INLINE void +ACE_Typed_SV_Message::type (long t) +{ + ACE_TRACE ("ACE_Typed_SV_Message::type"); + this->type_ = t; +} + +template ACE_INLINE int +ACE_Typed_SV_Message::length (void) const +{ + ACE_TRACE ("ACE_Typed_SV_Message::length"); + return this->length_; +} + +template ACE_INLINE void +ACE_Typed_SV_Message::length (int len) +{ + ACE_TRACE ("ACE_Typed_SV_Message::length"); + this->length_ = len + (sizeof *this - (sizeof this->type_ + sizeof this->data_)); +} + +template ACE_INLINE int +ACE_Typed_SV_Message::max_size (void) const +{ + ACE_TRACE ("ACE_Typed_SV_Message::max_size"); + return this->max_; +} + +template ACE_INLINE void +ACE_Typed_SV_Message::max_size (int m) +{ + ACE_TRACE ("ACE_Typed_SV_Message::max_size"); + this->max_ = m + (sizeof *this - (sizeof this->type_ + sizeof this->data_)); +} + +template T & +ACE_Typed_SV_Message::data (void) +{ + ACE_TRACE ("ACE_Typed_SV_Message::data"); + return this->data_; +} + +template void +ACE_Typed_SV_Message::data (const T &d) +{ + ACE_TRACE ("ACE_Typed_SV_Message::data"); + this->data_ = d; +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Typed_SV_Message_Queue.cpp b/dep/ACE_wrappers/ace/Typed_SV_Message_Queue.cpp new file mode 100644 index 00000000000..0adb589e62b --- /dev/null +++ b/dep/ACE_wrappers/ace/Typed_SV_Message_Queue.cpp @@ -0,0 +1,56 @@ +// $Id: Typed_SV_Message_Queue.cpp 80826 2008-03-04 14:51:23Z wotte $ + +#ifndef ACE_TYPED_SV_MESSAGE_QUEUE_CPP +#define ACE_TYPED_SV_MESSAGE_QUEUE_CPP + +#include "ace/Typed_SV_Message.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/Typed_SV_Message_Queue.h" +#include "ace/Log_Msg.h" + +#if !defined (__ACE_INLINE__) +#include "ace/Typed_SV_Message_Queue.inl" +#endif /* __ACE_INLINE__ */ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_ALLOC_HOOK_DEFINE(ACE_Typed_SV_Message_Queue) + +template void +ACE_Typed_SV_Message_Queue::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + ACE_TRACE ("ACE_Typed_SV_Message_Queue::dump"); +#endif /* ACE_HAS_DUMP */ +} + +template +ACE_Typed_SV_Message_Queue::ACE_Typed_SV_Message_Queue (void) +{ + ACE_TRACE ("ACE_Typed_SV_Message_Queue::ACE_Typed_SV_Message_Queue"); +} + +template +ACE_Typed_SV_Message_Queue::ACE_Typed_SV_Message_Queue (key_t external_id, + int create, + int perms) +{ + ACE_TRACE ("ACE_Typed_SV_Message_Queue::ACE_Typed_SV_Message_Queue"); + if (this->open (external_id, create, perms) == -1) + ACE_ERROR ((LM_ERROR, + "ACE_Typed_SV_Message_Queue::ACE_Typed_SV_Message_Queue")); +} + +template +ACE_Typed_SV_Message_Queue::~ACE_Typed_SV_Message_Queue (void) +{ + ACE_TRACE ("ACE_Typed_SV_Message_Queue::~ACE_Typed_SV_Message_Queue"); +} + +ACE_END_VERSIONED_NAMESPACE_DECL + +#endif /* ACE_TYPED_SV_MESSAGE_QUEUE_CPP */ diff --git a/dep/ACE_wrappers/ace/Typed_SV_Message_Queue.h b/dep/ACE_wrappers/ace/Typed_SV_Message_Queue.h new file mode 100644 index 00000000000..12c0e50921b --- /dev/null +++ b/dep/ACE_wrappers/ace/Typed_SV_Message_Queue.h @@ -0,0 +1,92 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Typed_SV_Message_Queue.h + * + * $Id: Typed_SV_Message_Queue.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Douglas C. Schmidt + */ +//============================================================================= + +#ifndef ACE_TYPED_MESSAGE_QUEUE_H +#define ACE_TYPED_MESSAGE_QUEUE_H +#include /**/ "ace/pre.h" + +#include "ace/SV_Message_Queue.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/Typed_SV_Message.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +/** + * @class ACE_Typed_SV_Message_Queue + * + * @brief Defines the header file for the C++ wrapper facade for typed message queues. + */ +template +class ACE_Typed_SV_Message_Queue +{ +public: + enum + { + ACE_CREATE = IPC_CREAT, + ACE_OPEN = 0, + ACE_NOWAIT = IPC_NOWAIT + }; + + // = Initialization and termination operations. + ACE_Typed_SV_Message_Queue (void); + ACE_Typed_SV_Message_Queue (key_t external_id, + int create = ACE_OPEN, + int perms = ACE_DEFAULT_FILE_PERMS); + int open (key_t external_id, + int create = ACE_OPEN, + int perms = ACE_DEFAULT_FILE_PERMS); + int close (void); + int remove (void); + ~ACE_Typed_SV_Message_Queue (void); + + /// Send method. + int send (const ACE_Typed_SV_Message &mb, int mflags = 0); + + /// Recv method. + int recv (ACE_Typed_SV_Message &mb, int mflags = 0); + + /// Return the id of the underlying ACE_SV_Message_Queue. + int get_id (void) const; + + /// Control the underlying message queue. + int control (int option, void *arg = 0); + + /// Dump the state of an object. + void dump (void) const; + + /// Declare the dynamic allocation hooks. + ACE_ALLOC_HOOK_DECLARE; + +private: + ACE_SV_Message_Queue message_queue_; +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +#include "ace/Typed_SV_Message_Queue.inl" +#endif /* __ACE_INLINE__ */ + +#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) +#include "ace/Typed_SV_Message_Queue.cpp" +#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ + +#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) +#pragma implementation ("Typed_SV_Message_Queue.cpp") +#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ + +#include /**/ "ace/post.h" +#endif /* ACE_TYPED_MESSAGE_QUEUE_H */ diff --git a/dep/ACE_wrappers/ace/Typed_SV_Message_Queue.inl b/dep/ACE_wrappers/ace/Typed_SV_Message_Queue.inl new file mode 100644 index 00000000000..90539936e62 --- /dev/null +++ b/dep/ACE_wrappers/ace/Typed_SV_Message_Queue.inl @@ -0,0 +1,80 @@ +// -*- C++ -*- +// +// $Id: Typed_SV_Message_Queue.inl 80826 2008-03-04 14:51:23Z wotte $ + +#include "ace/SV_Message_Queue.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +template ACE_INLINE int +ACE_Typed_SV_Message_Queue::open (key_t external_id, + int create, + int perms) +{ + ACE_TRACE ("ACE_Typed_SV_Message_Queue::open"); + return this->message_queue_.open (external_id, create, perms); +} + +// What does it mean to close a message queue?! + +template ACE_INLINE int +ACE_Typed_SV_Message_Queue::close (void) +{ + ACE_TRACE ("ACE_Typed_SV_Message_Queue::close"); + return 1; +} + +template ACE_INLINE int +ACE_Typed_SV_Message_Queue::recv (ACE_Typed_SV_Message &mb, + int mflags) +{ + ACE_TRACE ("ACE_Typed_SV_Message_Queue::recv"); + + int length = + this->message_queue_.recv (reinterpret_cast (mb), + mb.max_size (), + mb.type (), + mflags); + if (length != -1) + mb.length (length); + + return length; +} + +template ACE_INLINE int +ACE_Typed_SV_Message_Queue::send (const ACE_Typed_SV_Message &mb, + int mflags) +{ + ACE_TRACE ("ACE_Typed_SV_Message_Queue::send"); + return + this->message_queue_.send ( + reinterpret_cast ( + const_cast &> (mb)), + mb.length (), + mflags); +} + +template ACE_INLINE int +ACE_Typed_SV_Message_Queue::remove (void) +{ + ACE_TRACE ("ACE_Typed_SV_Message_Queue::remove"); + + return this->message_queue_.remove (); +} + +template ACE_INLINE int +ACE_Typed_SV_Message_Queue::control (int option, + void *arg) +{ + ACE_TRACE ("ACE_Typed_SV_Message_Queue::control"); + + return this->message_queue_.control (option, arg); +} + +template ACE_INLINE int +ACE_Typed_SV_Message_Queue::get_id (void) const +{ + return this->message_queue_.get_id (); +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/UNIX_Addr.cpp b/dep/ACE_wrappers/ace/UNIX_Addr.cpp new file mode 100644 index 00000000000..013af8a33ec --- /dev/null +++ b/dep/ACE_wrappers/ace/UNIX_Addr.cpp @@ -0,0 +1,151 @@ +// $Id: UNIX_Addr.cpp 80826 2008-03-04 14:51:23Z wotte $ + +#include "ace/UNIX_Addr.h" + +ACE_RCSID(ace, UNIX_Addr, "$Id: UNIX_Addr.cpp 80826 2008-03-04 14:51:23Z wotte $") + +#if !defined (ACE_LACKS_UNIX_DOMAIN_SOCKETS) + +#if !defined (__ACE_INLINE__) +#include "ace/UNIX_Addr.inl" +#endif /* __ACE_INLINE__ */ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_ALLOC_HOOK_DEFINE(ACE_UNIX_Addr) + +// Set a pointer to the address. +void +ACE_UNIX_Addr::set_addr (void *addr, int len) +{ + ACE_TRACE ("ACE_UNIX_Addr::set_addr"); + + this->ACE_Addr::base_set (AF_UNIX, len); + ACE_OS::memcpy ((void *) &this->unix_addr_, + (void *) addr, + len); +} + +// Return a pointer to the underlying address. + +void * +ACE_UNIX_Addr::get_addr (void) const +{ + return (void *) &this->unix_addr_; +} + +// Transform the string into the current addressing format. + +int +ACE_UNIX_Addr::string_to_addr (const char addr[]) +{ + ACE_OS::strsncpy (this->unix_addr_.sun_path, addr, + sizeof this->unix_addr_.sun_path); + return 0; +} + +// Transform the current address into string format. + +int +ACE_UNIX_Addr::addr_to_string (ACE_TCHAR s[], size_t len) const +{ + ACE_OS::strsncpy (s, + ACE_TEXT_CHAR_TO_TCHAR (this->unix_addr_.sun_path), + len); + return 0; +} + +u_long +ACE_UNIX_Addr::hash (void) const +{ + return ACE::hash_pjw (this->unix_addr_.sun_path); +} + +void +ACE_UNIX_Addr::dump (void) const +{ +#if defined (ACE_HAS_DUMP) +#endif /* ACE_HAS_DUMP */ +} + +// Do nothing constructor. + +ACE_UNIX_Addr::ACE_UNIX_Addr (void) + : ACE_Addr (AF_UNIX, sizeof this->unix_addr_) +{ + (void) ACE_OS::memset ((void *) &this->unix_addr_, + 0, + sizeof this->unix_addr_); + + this->unix_addr_.sun_family = AF_UNIX; +} + +int +ACE_UNIX_Addr::set (const ACE_UNIX_Addr &sa) +{ + if (sa.get_type () == AF_ANY) + (void) ACE_OS::memset ((void *) &this->unix_addr_, + 0, + sizeof this->unix_addr_); + else + ACE_OS::strcpy (this->unix_addr_.sun_path, + sa.unix_addr_.sun_path); + + this->unix_addr_.sun_family = AF_UNIX; + this->base_set (sa.get_type (), sa.get_size ()); + + return 0; +} + +// Copy constructor. + +ACE_UNIX_Addr::ACE_UNIX_Addr (const ACE_UNIX_Addr &sa) + : ACE_Addr (AF_UNIX, sa.get_size ()) +{ + this->set (sa); +} + +int +ACE_UNIX_Addr::set (const sockaddr_un *un, int len) +{ + (void) ACE_OS::memset ((void *) &this->unix_addr_, 0, + sizeof this->unix_addr_); + this->unix_addr_.sun_family = AF_UNIX; + ACE_OS::strcpy (this->unix_addr_.sun_path, un->sun_path); + this->base_set (AF_UNIX, len); + return 0; +} + +ACE_UNIX_Addr::ACE_UNIX_Addr (const sockaddr_un *un, int len) +{ + this->set (un, len); +} + +int +ACE_UNIX_Addr::set (const char rendezvous_point[]) +{ + (void) ACE_OS::memset ((void *) &this->unix_addr_, + 0, + sizeof this->unix_addr_); + this->unix_addr_.sun_family = AF_UNIX; + (void) ACE_OS::strsncpy (this->unix_addr_.sun_path, + rendezvous_point, + sizeof this->unix_addr_.sun_path); + + this->ACE_Addr::base_set (AF_UNIX, + sizeof this->unix_addr_ - + sizeof (this->unix_addr_.sun_path) + + ACE_OS::strlen (this->unix_addr_.sun_path)); + return 0; +} + +// Create a ACE_Addr from a UNIX pathname. + +ACE_UNIX_Addr::ACE_UNIX_Addr (const char rendezvous_point[]) +{ + this->set (rendezvous_point); +} + +ACE_END_VERSIONED_NAMESPACE_DECL + +#endif /* ACE_LACKS_UNIX_DOMAIN_SOCKETS */ diff --git a/dep/ACE_wrappers/ace/UNIX_Addr.h b/dep/ACE_wrappers/ace/UNIX_Addr.h new file mode 100644 index 00000000000..887529fe152 --- /dev/null +++ b/dep/ACE_wrappers/ace/UNIX_Addr.h @@ -0,0 +1,117 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file UNIX_Addr.h + * + * $Id: UNIX_Addr.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Doug Schmidt + */ +//============================================================================= + + +#ifndef ACE_UNIX_ADDR_H +#define ACE_UNIX_ADDR_H + +#include /**/ "ace/pre.h" + +#include /**/ "ace/ACE_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#if !defined (ACE_LACKS_UNIX_DOMAIN_SOCKETS) + +#include "ace/Addr.h" +#include "ace/Log_Msg.h" +#include "ace/ACE.h" +#include "ace/os_include/sys/os_un.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +/** + * @class ACE_UNIX_Addr + * + * @brief Defines the ``UNIX domain address family'' address format. + */ +class ACE_Export ACE_UNIX_Addr : public ACE_Addr +{ +public: + // = Initialization methods. + /// Default constructor. + ACE_UNIX_Addr (void); + + /// Copy constructor. + ACE_UNIX_Addr (const ACE_UNIX_Addr &sa); + + /// Creates an ACE_UNIX_Addr from a string. + ACE_UNIX_Addr (const char rendezvous_point[]); + + /// Creates an ACE_INET_Addr from a sockaddr_un structure. + ACE_UNIX_Addr (const sockaddr_un *, int len); + + /// Creates an ACE_UNIX_Addr from another ACE_UNIX_Addr. + int set (const ACE_UNIX_Addr &sa); + + /// Creates an ACE_UNIX_Addr from a string. + int set (const char rendezvous_point[]); + + /// Creates an ACE_UNIX_Addr from a sockaddr_un structure. + int set (const sockaddr_un *, int len); + + /// Return a pointer to the underlying network address. + virtual void *get_addr (void) const; + + /// Set a pointer to the underlying network address. + virtual void set_addr (void *addr, int len); + + /// Transform the current address into string format. + virtual int addr_to_string (ACE_TCHAR addr[], size_t) const; + + /// Transform the string into the current addressing format. + virtual int string_to_addr (const char addr[]); + +#if defined (ACE_HAS_WCHAR) + /// Creates an ACE_UNIX_Addr from a string. + ACE_UNIX_Addr (const wchar_t rendezvous_point[]); + + /// Creates an ACE_UNIX_Addr from a string. + int set (const wchar_t rendezvous_point[]); +#endif /* ACE_HAS_WCHAR */ + + /// Compare two addresses for equality. + bool operator == (const ACE_UNIX_Addr &SAP) const; + + /// Compare two addresses for inequality. + bool operator != (const ACE_UNIX_Addr &SAP) const; + + /// Return the path name of the underlying rendezvous point. + const char *get_path_name (void) const; + + /// Computes and returns hash value. + virtual u_long hash (void) const; + + /// Dump the state of an object. + void dump (void) const; + + /// Declare the dynamic allocation hooks. + ACE_ALLOC_HOOK_DECLARE; + +private: + /// Underlying socket address. + sockaddr_un unix_addr_; +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +#include "ace/UNIX_Addr.inl" +#endif /* __ACE_INLINE__ */ + +#endif /* ACE_LACKS_UNIX_DOMAIN_SOCKETS */ + +#include /**/ "ace/post.h" + +#endif /* ACE_UNIX_ADDR_H */ diff --git a/dep/ACE_wrappers/ace/UNIX_Addr.inl b/dep/ACE_wrappers/ace/UNIX_Addr.inl new file mode 100644 index 00000000000..5e801b56fea --- /dev/null +++ b/dep/ACE_wrappers/ace/UNIX_Addr.inl @@ -0,0 +1,57 @@ +// -*- C++ -*- +// +// $Id: UNIX_Addr.inl 80826 2008-03-04 14:51:23Z wotte $ + + +#include "ace/OS_NS_string.h" + + +#if !defined (ACE_LACKS_UNIX_DOMAIN_SOCKETS) + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +#if defined (ACE_HAS_WCHAR) +/// Creates an ACE_UNIX_Addr from a string. +ACE_INLINE +ACE_UNIX_Addr::ACE_UNIX_Addr (const wchar_t rendezvous_point[]) +{ + this->set (ACE_Wide_To_Ascii (rendezvous_point).char_rep ()); +} + +/// Creates an ACE_UNIX_Addr from a string. +ACE_INLINE int +ACE_UNIX_Addr::set (const wchar_t rendezvous_point[]) +{ + return this->set (ACE_Wide_To_Ascii (rendezvous_point).char_rep ()); +} +#endif /* ACE_HAS_WCHAR */ + +// Compare two addresses for equality. + +ACE_INLINE bool +ACE_UNIX_Addr::operator == (const ACE_UNIX_Addr &sap) const +{ + return ACE_OS::strncmp (this->unix_addr_.sun_path, + sap.unix_addr_.sun_path, + sizeof this->unix_addr_.sun_path) == 0; +} + +// Compare two addresses for inequality. + +ACE_INLINE bool +ACE_UNIX_Addr::operator != (const ACE_UNIX_Addr &sap) const +{ + return !((*this) == sap); // This is lazy, of course... ;-) +} + +// Return the path name used for the rendezvous point. + +ACE_INLINE const char * +ACE_UNIX_Addr::get_path_name (void) const +{ + return this->unix_addr_.sun_path; +} + +ACE_END_VERSIONED_NAMESPACE_DECL + +#endif /* ACE_LACKS_UNIX_DOMAIN_SOCKETS */ diff --git a/dep/ACE_wrappers/ace/UPIPE_Acceptor.cpp b/dep/ACE_wrappers/ace/UPIPE_Acceptor.cpp new file mode 100644 index 00000000000..0b8954d5d0c --- /dev/null +++ b/dep/ACE_wrappers/ace/UPIPE_Acceptor.cpp @@ -0,0 +1,129 @@ +// $Id: UPIPE_Acceptor.cpp 80826 2008-03-04 14:51:23Z wotte $ + +#include "ace/UPIPE_Acceptor.h" + +ACE_RCSID(ace, UPIPE_Acceptor, "$Id: UPIPE_Acceptor.cpp 80826 2008-03-04 14:51:23Z wotte $") + +#if defined (ACE_HAS_THREADS) + +#include "ace/OS_NS_unistd.h" + +#if !defined (__ACE_INLINE__) +#include "ace/UPIPE_Acceptor.inl" +#endif /* __ACE_INLINE__ */ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_ALLOC_HOOK_DEFINE(ACE_UPIPE_Acceptor) + +void +ACE_UPIPE_Acceptor::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + ACE_TRACE ("ACE_UPIPE_Acceptor::dump"); +#endif /* ACE_HAS_DUMP */ +} + +/* Do nothing routine for constructor. */ + +ACE_UPIPE_Acceptor::ACE_UPIPE_Acceptor (void) + : mb_ (sizeof (ACE_UPIPE_Stream *)) +{ + ACE_TRACE ("ACE_UPIPE_Acceptor::ACE_UPIPE_Acceptor"); +} + +ACE_UPIPE_Acceptor::~ACE_UPIPE_Acceptor (void) +{ + ACE_TRACE ("ACE_UPIPE_Acceptor::~ACE_UPIPE_Acceptor"); +} + +// General purpose routine for performing server ACE_UPIPE. + +int +ACE_UPIPE_Acceptor::open (const ACE_UPIPE_Addr &local_addr, + int reuse_addr) +{ + ACE_TRACE ("ACE_UPIPE_Acceptor::open"); + return this->ACE_SPIPE_Acceptor::open (local_addr, reuse_addr); +} + +int +ACE_UPIPE_Acceptor::close (void) +{ + ACE_TRACE ("ACE_UPIPE_Acceptor::close"); + return this->ACE_SPIPE_Acceptor::close (); +} + +// General purpose routine for accepting new connections. + +ACE_UPIPE_Acceptor::ACE_UPIPE_Acceptor (const ACE_UPIPE_Addr &local_addr, + int reuse_addr) + : mb_ (sizeof (ACE_UPIPE_Stream *)) +{ + ACE_TRACE ("ACE_UPIPE_Acceptor::ACE_UPIPE_Acceptor"); + + if (this->open (local_addr, reuse_addr) == -1) + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("%p\n"), + ACE_TEXT ("ACE_UPIPE_Acceptor"))); +} + +int +ACE_UPIPE_Acceptor::accept (ACE_UPIPE_Stream &new_stream, + ACE_UPIPE_Addr *remote_addr, + ACE_Time_Value *timeout, + int restart, + int reset_new_handle) +{ + ACE_TRACE ("ACE_UPIPE_Acceptor::accept"); + ACE_UNUSED_ARG (reset_new_handle); + + ACE_SPIPE_Stream new_io; + + if (this->ACE_SPIPE_Acceptor::accept (new_io, remote_addr, + timeout, restart) == -1) + return -1; + else + { + ACE_UPIPE_Stream *remote_stream = 0; + + ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, new_stream.lock_, -1)); + + new_stream.set_handle (new_io.get_handle ()); + new_stream.reference_count_++; + + // Transfer address ownership. + new_io.get_local_addr (new_stream.local_addr_); + new_io.get_remote_addr (new_stream.remote_addr_); + + // Now that we got the handle, we'll read the address of the + // connector-side ACE_UPIPE_Stream out of the pipe and link that + // ACE_UPIPE_Stream to our ACE_UPIPE_Stream. + + if (ACE_OS::read (new_stream.get_handle (), + (char *) &remote_stream, + sizeof remote_stream) == -1) + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("ACE_UPIPE_Acceptor: %p\n"), + ACE_TEXT ("read stream address failed"))); + else if (new_stream.stream_.link (remote_stream->stream_) == -1) + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("ACE_UPIPE_Acceptor: %p\n"), + ACE_TEXT ("link streams failed"))); + // Send a message over the new streampipe to confirm acceptance. + else if (new_stream.send (&mb_, 0) == -1) + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("ACE_UPIPE_Acceptor: %p\n"), + ACE_TEXT ("linked stream.put failed"))); + + // Close down the new_stream at this point in order to conserve + // handles. Note that we don't need the SPIPE connection + // anymore since we're now linked via the . + new_stream.ACE_SPIPE::close (); + return 0; + } +} + +ACE_END_VERSIONED_NAMESPACE_DECL + +#endif /* ACE_HAS_THREADS */ diff --git a/dep/ACE_wrappers/ace/UPIPE_Acceptor.h b/dep/ACE_wrappers/ace/UPIPE_Acceptor.h new file mode 100644 index 00000000000..0fd33226ed3 --- /dev/null +++ b/dep/ACE_wrappers/ace/UPIPE_Acceptor.h @@ -0,0 +1,99 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file UPIPE_Acceptor.h + * + * $Id: UPIPE_Acceptor.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Gerhard Lenzer + * @author Douglas C. Schmidt + */ +//============================================================================= + + +#ifndef ACE_UPIPE_ACCEPTOR_H +#define ACE_UPIPE_ACCEPTOR_H +#include /**/ "ace/pre.h" + +#include "ace/UPIPE_Stream.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#if defined (ACE_HAS_THREADS) + +#include "ace/SPIPE_Acceptor.h" +#include "ace/Thread_Manager.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +/** + * @class ACE_UPIPE_Acceptor + * + * @brief Defines the format and interface for the listener side of the + * ACE_UPIPE_Stream. + */ +class ACE_Export ACE_UPIPE_Acceptor : public ACE_SPIPE_Acceptor +{ +public: + // = Initialization and termination. + /// Default constructor. + ACE_UPIPE_Acceptor (void); + + /// Initialize passive endpoint. + ACE_UPIPE_Acceptor (const ACE_UPIPE_Addr &local_sap, + int reuse_addr = 0); + + /// Initialize passive endpoint. + int open (const ACE_UPIPE_Addr &local_sap, + int reuse_addr = 0); + + /// Close down and release resources. + ~ACE_UPIPE_Acceptor (void); + + /// Close down and release resources. + int close (void); + + /// Close down and release resources and remove the underlying SPIPE + /// rendezvous point. + int remove (void); + + // = Passive connection acceptance method. + /** + * Accept a new data transfer connection. A @a timeout of 0 means + * block forever, a @a timeout of {0, 0} means poll. @a restart == 1 + * means "restart if interrupted." + */ + int accept (ACE_UPIPE_Stream &server_stream, + ACE_UPIPE_Addr *remote_addr = 0, + ACE_Time_Value *timeout = 0, + int restart = 1, + int reset_new_handle = 0); + + /// Dump the state of an object. + void dump (void) const; + + /// Declare the dynamic allocation hooks. + ACE_ALLOC_HOOK_DECLARE; + +private: + /// Manage threads. + ACE_Thread_Manager tm; + + /// To confirm connection establishment. + ACE_Message_Block mb_; +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +#include "ace/UPIPE_Acceptor.inl" +#endif /* __ACE_INLINE__ */ + +#endif /* ACE_HAS_THREADS */ + +#include /**/ "ace/post.h" + +#endif /* ACE_UPIPE_ACCEPTOR_H */ diff --git a/dep/ACE_wrappers/ace/UPIPE_Acceptor.inl b/dep/ACE_wrappers/ace/UPIPE_Acceptor.inl new file mode 100644 index 00000000000..9432ad7bb88 --- /dev/null +++ b/dep/ACE_wrappers/ace/UPIPE_Acceptor.inl @@ -0,0 +1,14 @@ +// -*- C++ -*- +// +// $Id: UPIPE_Acceptor.inl 80826 2008-03-04 14:51:23Z wotte $ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_INLINE int +ACE_UPIPE_Acceptor::remove (void) +{ + ACE_TRACE ("ACE_UPIPE_Acceptor::remove"); + return this->ACE_SPIPE_Acceptor::remove (); +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/UPIPE_Addr.h b/dep/ACE_wrappers/ace/UPIPE_Addr.h new file mode 100644 index 00000000000..aaf33b683fa --- /dev/null +++ b/dep/ACE_wrappers/ace/UPIPE_Addr.h @@ -0,0 +1,33 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file UPIPE_Addr.h + * + * $Id: UPIPE_Addr.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Doug Schmidt + */ +//============================================================================= + + +#ifndef ACE_UPIPE_ADDR_H +#define ACE_UPIPE_ADDR_H + +#include /**/ "ace/pre.h" + +#include "ace/SPIPE_Addr.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +typedef ACE_SPIPE_Addr ACE_UPIPE_Addr; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#include /**/ "ace/post.h" + +#endif /* ACE_UPIPE_ADDR_H */ diff --git a/dep/ACE_wrappers/ace/UPIPE_Connector.cpp b/dep/ACE_wrappers/ace/UPIPE_Connector.cpp new file mode 100644 index 00000000000..9b9bfcd3878 --- /dev/null +++ b/dep/ACE_wrappers/ace/UPIPE_Connector.cpp @@ -0,0 +1,101 @@ +// $Id: UPIPE_Connector.cpp 80826 2008-03-04 14:51:23Z wotte $ + +#include "ace/UPIPE_Connector.h" + +ACE_RCSID(ace, UPIPE_Connector, "$Id: UPIPE_Connector.cpp 80826 2008-03-04 14:51:23Z wotte $") + +#if defined (ACE_HAS_THREADS) + +#include "ace/Handle_Ops.h" +#include "ace/OS_NS_unistd.h" +#include "ace/OS_NS_stropts.h" + +#if !defined (__ACE_INLINE__) +#include "ace/UPIPE_Connector.inl" +#endif /* __ACE_INLINE__ */ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_ALLOC_HOOK_DEFINE(ACE_UPIPE_Connector) + +void +ACE_UPIPE_Connector::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + ACE_TRACE ("ACE_UPIPE_Connector::dump"); +#endif /* ACE_HAS_DUMP */ +} + +ACE_UPIPE_Connector::ACE_UPIPE_Connector (void) +{ + ACE_TRACE ("ACE_UPIPE_Connector::ACE_UPIPE_Connector"); +} + +int +ACE_UPIPE_Connector::connect (ACE_UPIPE_Stream &new_stream, + const ACE_UPIPE_Addr &addr, + ACE_Time_Value *timeout, + const ACE_Addr & /* local_sap */, + int /* reuse_addr */, + int flags, + int perms) +{ + ACE_TRACE ("ACE_UPIPE_Connector::connect"); + ACE_ASSERT (new_stream.get_handle () == ACE_INVALID_HANDLE); + + ACE_HANDLE handle = ACE::handle_timed_open (timeout, + addr.get_path_name (), + flags, perms); + + if (handle == ACE_INVALID_HANDLE) + return -1; +#if !defined (ACE_WIN32) + else if (ACE_OS::isastream (handle) != 1) + return -1; +#endif + else // We're connected! + { + ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, new_stream.lock_, -1)); + + ACE_UPIPE_Stream *ustream = &new_stream; + + new_stream.set_handle (handle); + new_stream.remote_addr_ = addr; // class copy. + new_stream.reference_count_++; + + // Now send the address of our ACE_UPIPE_Stream over this pipe + // to our corresponding ACE_UPIPE_Acceptor, so he may link the + // two streams. + ssize_t result = ACE_OS::write (handle, + (const char *) &ustream, + sizeof ustream); + if (result == -1) + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("ACE_UPIPE_Connector %p\n"), + ACE_TEXT ("write to pipe failed"))); + + // Wait for confirmation of stream linking. + ACE_Message_Block *mb_p = 0; + + // Our part is done, wait for server to confirm connection. + result = new_stream.recv (mb_p, 0); + + // Do *not* coalesce the following two checks for result == -1. + // They perform different checks and cannot be merged. + if (result == -1) + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("ACE_UPIPE_Connector %p\n"), + ACE_TEXT ("no confirmation from server"))); + else + // Close down the new_stream at this point in order to + // conserve handles. Note that we don't need the SPIPE + // connection anymore since we're linked via the Message_Queue + // now. + new_stream.ACE_SPIPE::close (); + return static_cast (result); + } +} + +ACE_END_VERSIONED_NAMESPACE_DECL + +#endif /* ACE_HAS_THREADS */ diff --git a/dep/ACE_wrappers/ace/UPIPE_Connector.h b/dep/ACE_wrappers/ace/UPIPE_Connector.h new file mode 100644 index 00000000000..ea4fc2ec762 --- /dev/null +++ b/dep/ACE_wrappers/ace/UPIPE_Connector.h @@ -0,0 +1,115 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file UPIPE_Connector.h + * + * $Id: UPIPE_Connector.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Gerhard Lenzer and Douglas C. Schmidt + */ +//============================================================================= + + +#ifndef ACE_UPIPE_CONNECTOR_H +#define ACE_UPIPE_CONNECTOR_H +#include /**/ "ace/pre.h" + +#include "ace/UPIPE_Stream.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#if defined (ACE_HAS_THREADS) + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +/** + * @class ACE_UPIPE_Connector + * + * @brief Defines an active connection factory for the + * ACE_UPIPE_STREAM wrappers. + */ +class ACE_Export ACE_UPIPE_Connector +{ +public: + // = Initialization methods. + /// Default constructor. + ACE_UPIPE_Connector (void); + + /** + * Actively connect and produce a @a new_stream if things go well. + * The @a addr is the address that we are trying to connect + * with. The @a timeout is the amount of time to wait to connect. + * If it's 0 then we block indefinitely. If *timeout == {0, 0} then + * the connection is done using non-blocking mode. In this case, if + * the connection can't be made immediately the value of -1 is + * returned with @c errno == EWOULDBLOCK. If *timeout > {0, 0} then + * this is the maximum amount of time to wait before timing out. If the + * time expires before the connection is made @c errno == ETIME. The + * @a local_sap is the value of local address to bind to. If it's + * the default value of ACE_Addr::sap_any then the user is letting + * the OS do the binding. If @a reuse_addr == 1 then the + * @a local_addr is reused, even if it hasn't been cleanedup yet. + * The @a flags and @a perms arguments are passed down to the open() + * method. + */ + ACE_UPIPE_Connector (ACE_UPIPE_Stream &new_stream, + const ACE_UPIPE_Addr &addr, + ACE_Time_Value *timeout = 0, + const ACE_Addr &local_sap = ACE_Addr::sap_any, + int reuse_addr = 0, + int flags = O_RDWR, + int perms = 0); + + /** + * Actively connect and produce a @a new_stream if things go well. + * The @a addr is the address that we are trying to connect + * with. The @a timeout is the amount of time to wait to connect. + * If it's 0 then we block indefinitely. If *timeout == {0, 0} then + * the connection is done using non-blocking mode. In this case, if + * the connection can't be made immediately the value of -1 is + * returned with @c errno == EWOULDBLOCK. If *timeout > {0, 0} then + * this is the maximum amount of time to wait before timing out. If the + * time expires before the connection is made @c errno == ETIME. The + * @a local_sap is the value of local address to bind to. If it's + * the default value of ACE_Addr::sap_any then the user is letting + * the OS do the binding. If @a reuse_addr == 1 then the + * @a local_addr is reused, even if it hasn't been cleanedup yet. + * The @a flags and @a perms arguments are passed down to the open() + * method. + */ + int connect (ACE_UPIPE_Stream &new_stream, + const ACE_UPIPE_Addr &addr, + ACE_Time_Value *timeout = 0, + const ACE_Addr &local_sap = ACE_Addr::sap_any, + int reuse_addr = 0, + int flags = O_RDWR, + int perms = 0); + + /// Resets any event associations on this handle + int reset_new_handle (ACE_HANDLE handle); + + // = Meta-type info + typedef ACE_UPIPE_Addr PEER_ADDR; + typedef ACE_UPIPE_Stream PEER_STREAM; + + /// Dump the state of an object. + void dump (void) const; + + /// Declare the dynamic allocation hooks. + ACE_ALLOC_HOOK_DECLARE; +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +#include "ace/UPIPE_Connector.inl" +#endif /* __ACE_INLINE__ */ + +#endif /* ACE_HAS_THREADS */ + +#include /**/ "ace/post.h" + +#endif /* ACE_UPIPE_CONNECTOR_H */ diff --git a/dep/ACE_wrappers/ace/UPIPE_Connector.inl b/dep/ACE_wrappers/ace/UPIPE_Connector.inl new file mode 100644 index 00000000000..fa43dbea326 --- /dev/null +++ b/dep/ACE_wrappers/ace/UPIPE_Connector.inl @@ -0,0 +1,34 @@ +// -*- C++ -*- +// +// $Id: UPIPE_Connector.inl 80826 2008-03-04 14:51:23Z wotte $ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +// Creates a Local ACE_UPIPE. +ACE_INLINE +ACE_UPIPE_Connector::ACE_UPIPE_Connector (ACE_UPIPE_Stream &new_stream, + const ACE_UPIPE_Addr &addr, + ACE_Time_Value *timeout, + const ACE_Addr &local_sap, + int reuse_addr, + int flags, + int perms) +{ + ACE_TRACE ("ACE_UPIPE_Connector::ACE_UPIPE_Connector"); + if (this->connect (new_stream, addr, timeout, local_sap, + reuse_addr, flags, perms) == -1 + && timeout != 0 && !(errno == EWOULDBLOCK || errno == ETIME)) + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("address %s, %p\n"), + addr.get_path_name (), + ACE_TEXT ("ACE_UPIPE_Connector"))); +} + +ACE_INLINE int +ACE_UPIPE_Connector::reset_new_handle (ACE_HANDLE /* handle */) +{ + // Nothing to do here since the handle is not a socket + return 0; +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/UPIPE_Stream.cpp b/dep/ACE_wrappers/ace/UPIPE_Stream.cpp new file mode 100644 index 00000000000..d07722a482e --- /dev/null +++ b/dep/ACE_wrappers/ace/UPIPE_Stream.cpp @@ -0,0 +1,234 @@ +// $Id: UPIPE_Stream.cpp 82559 2008-08-07 20:23:07Z parsons $ + +#include "ace/UPIPE_Stream.h" + +ACE_RCSID(ace, UPIPE_Stream, "$Id: UPIPE_Stream.cpp 82559 2008-08-07 20:23:07Z parsons $") + +#if defined (ACE_HAS_THREADS) + +#include "ace/OS_NS_string.h" + +#if !defined (__ACE_INLINE__) +#include "ace/UPIPE_Stream.inl" +#endif /* __ACE_INLINE__ */ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_ALLOC_HOOK_DEFINE(ACE_UPIPE_Stream) + +ACE_UPIPE_Stream::ACE_UPIPE_Stream (void) + : mb_last_ (0), + reference_count_ (0) +{ + ACE_TRACE ("ACE_UPIPE_Stream::ACE_UPIPE_STREAM"); +} + +ACE_UPIPE_Stream::~ACE_UPIPE_Stream (void) +{ + if (this->mb_last_ != 0) + { + this->mb_last_->release (); + this->mb_last_ = 0; + } +} + +int +ACE_UPIPE_Stream::control (int cmd, + void * val) const +{ + ACE_TRACE ("ACE_UPIPE_Stream::control"); + + return ((ACE_UPIPE_Stream *) this)->stream_.control + ((ACE_IO_Cntl_Msg::ACE_IO_Cntl_Cmds) cmd, val); +} + +void +ACE_UPIPE_Stream::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + ACE_TRACE ("ACE_UPIPE_Stream::dump"); +#endif /* ACE_HAS_DUMP */ +} + +int +ACE_UPIPE_Stream::close (void) +{ + ACE_TRACE ("ACE_UPIPE_Stream::close"); + ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1)); + + this->reference_count_--; + + if (this->reference_count_ == 0) + { + // Since the UPIPE should have been closed earlier we won't bother + // checking to see if closing it now fails. + + if (this->ACE_SPIPE::get_handle () != ACE_INVALID_HANDLE) + this->ACE_SPIPE::close (); + + // Close down the ACE_stream. + return this->stream_.close (); + } + return 0; +} + +int +ACE_UPIPE_Stream::get_remote_addr (ACE_UPIPE_Addr &remote_sap) const +{ + ACE_TRACE ("ACE_UPIPE_Stream::get_remote_addr"); + remote_sap = this->remote_addr_; + return 0; +} + +int +ACE_UPIPE_Stream::send (ACE_Message_Block *mb_p, + ACE_Time_Value *timeout) +{ + ACE_TRACE ("ACE_UPIPE_Stream::send_msg"); + return this->stream_.put (mb_p, timeout) == -1 ? -1 : 0; +} + +int ACE_UPIPE_Stream::recv (ACE_Message_Block *& mb_p, + ACE_Time_Value *timeout) +{ + return this->stream_.get (mb_p, timeout) == -1 ? -1 : 0; +} + +// Send a buffer. + +ssize_t +ACE_UPIPE_Stream::send (const char *buffer, + size_t n, + ACE_Time_Value *timeout) +{ + ACE_TRACE ("ACE_UPIPE_Stream::send"); + + ACE_Message_Block *mb_p; + ACE_NEW_RETURN (mb_p, + ACE_Message_Block (n), + -1); + mb_p->copy (buffer, n); + return + this->stream_.put (mb_p, timeout) == -1 + ? -1 + : static_cast (n); +} + +// Receive a buffer. + +ssize_t +ACE_UPIPE_Stream::recv (char *buffer, + size_t n, + ACE_Time_Value *timeout) +{ + ACE_TRACE ("ACE_UPIPE_Stream::recv"); + // Index in buffer. + size_t bytes_read = 0; + + while (bytes_read < n) + if (this->mb_last_ != 0) + { + // We have remaining data in our last read Message_Buffer. + size_t this_len = this->mb_last_->length (); + if (this_len < n) + { + // The remaining data is not enough. + + ACE_OS::memcpy ((void *) &buffer[bytes_read], + this->mb_last_->rd_ptr (), + this_len); + bytes_read += this_len; + this->mb_last_ = this->mb_last_->release (); // mb_last_ now 0 + return static_cast (bytes_read); + } + else + { + // The remaining data is at least enough. If there's + // more, we'll get it the next time through. + ACE_OS::memcpy (&buffer[bytes_read], + this->mb_last_->rd_ptr (), + n); + bytes_read += n; + + // Advance rd_ptr. + this->mb_last_->rd_ptr (n); + + if (this->mb_last_->length () == 0) + // Now the Message_Buffer is empty. + this->mb_last_ = this->mb_last_->release (); + } + } + else + { + // We have to get a new Message_Buffer from our stream. + int result = this->stream_.get (this->mb_last_, timeout); + + if (result == -1) + { + if (errno == EWOULDBLOCK && bytes_read > 0) + // Return the number of bytes read before we timed out. + return static_cast (bytes_read); + else + return -1; + } + } + + return static_cast (bytes_read); +} + +ssize_t +ACE_UPIPE_Stream::send_n (const char *buf, + size_t n, + ACE_Time_Value *timeout) +{ + ACE_TRACE ("ACE_UPIPE_Stream::send_n"); + + size_t bytes_written; + ssize_t len = 0; + + for (bytes_written = 0; bytes_written < n; bytes_written += len) + { + len = this->send (buf + bytes_written, + n - bytes_written, + timeout); + + if (len == -1) + { + return -1; + } + } + + return static_cast (bytes_written); +} + +ssize_t +ACE_UPIPE_Stream::recv_n (char *buf, + size_t n, + ACE_Time_Value *timeout) +{ + ACE_TRACE ("ACE_UPIPE_Stream::recv_n"); + size_t bytes_read; + ssize_t len = 0; + + for (bytes_read = 0; bytes_read < n; bytes_read += len) + { + len = this->recv (buf + bytes_read, + n - bytes_read, + timeout); + + if (len == -1) + { + return -1; + } + else if (len == 0) + { + break; + } + } + + return static_cast< ssize_t> (bytes_read); +} + +ACE_END_VERSIONED_NAMESPACE_DECL + +#endif /* ACE_HAS_THREADS */ diff --git a/dep/ACE_wrappers/ace/UPIPE_Stream.h b/dep/ACE_wrappers/ace/UPIPE_Stream.h new file mode 100644 index 00000000000..b10aef11591 --- /dev/null +++ b/dep/ACE_wrappers/ace/UPIPE_Stream.h @@ -0,0 +1,140 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file UPIPE_Stream.h + * + * $Id: UPIPE_Stream.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Gerhard Lenzer + * @author Douglas C. Schmidt + */ +//============================================================================= + + +#ifndef ACE_UPIPE_STREAM_H +#define ACE_UPIPE_STREAM_H +#include /**/ "ace/pre.h" + +#include "ace/Stream.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#if defined (ACE_HAS_THREADS) + +#include "ace/SPIPE.h" +#include "ace/Message_Queue.h" +#include "ace/UPIPE_Addr.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +/** + * @class ACE_UPIPE_Stream + * + * @brief Defines the method that transfer data on a UPIPE. + */ +class ACE_Export ACE_UPIPE_Stream : public ACE_SPIPE +{ +public: + friend class ACE_UPIPE_Acceptor; + friend class ACE_UPIPE_Connector; + + typedef ACE_Stream MT_Stream; + + // = Initialization and Termination. + + ACE_UPIPE_Stream (void); + + virtual ~ACE_UPIPE_Stream (void); + + /// Shut down the UPIPE and release resources. + int close (void); + + /// Return the underlying I/O handle. + ACE_HANDLE get_handle (void) const; + + // = Send/recv ACE Message_Blocks. + /// Send a message through the message queue. Returns -1 on error, + /// else 0. + int send (ACE_Message_Block *mb_p, + ACE_Time_Value *timeout = 0); + + /// Recv a message from the message queue. Returns -1 on error, else + /// 0. + int recv (ACE_Message_Block *&mb_p, + ACE_Time_Value *timeout = 0); + + // = Send/recv char buffers. + /// Send a buffer of @a n bytes through the message queue. Returns -1 + /// on error, else number of bytes sent. + ssize_t send (const char *buffer, + size_t n, + ACE_Time_Value *timeout = 0); + + /// Recv a buffer of upto @a n bytes from the message queue. Returns + /// -1 on error, else number of bytes read. + ssize_t recv (char *buffer, + size_t n, + ACE_Time_Value *timeout = 0); + + /// Send a buffer of exactly @a n bytes to the message queue. Returns + /// -1 on error, else number of bytes written (which should == n). + ssize_t send_n (const char *buffer, + size_t n, + ACE_Time_Value *timeout = 0); + + /// Recv a buffer of exactly @a n bytes from the message queue. + /// Returns -1 on error, else the number of bytes read. + ssize_t recv_n (char *buffer, + size_t n, + ACE_Time_Value *timeout = 0); + + /// Perform control operations on the UPIPE_Stream. + int control (int cmd, void *val) const; + + /// Return the remote address we are connected to. + int get_remote_addr (ACE_UPIPE_Addr &remote_sap) const; + + /// Dump the state of an object. + void dump (void) const; + + /// Declare the dynamic allocation hooks. + ACE_ALLOC_HOOK_DECLARE; + + // = Meta-type info + typedef ACE_UPIPE_Addr PEER_ADDR; + +private: + /// To hold the last ACE_Message_Block read out of the stream. Thus + /// allowing subsequent reads from one ACE_Message_Block + ACE_Message_Block *mb_last_; + + /// Address of who we are connected to. + ACE_UPIPE_Addr remote_addr_; + + /// Stream component used by the @c UPIPE_Acceptor and + /// @c UPIPE_Connector to link together two UPIPE_Streams. + MT_Stream stream_; + + /// Keep track of whether the sender and receiver have both shutdown. + int reference_count_; + +#if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0) + /// Ensure that we are thread-safe. + ACE_Thread_Mutex lock_; +#endif /* ACE_MT_SAFE */ +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +#include "ace/UPIPE_Stream.inl" +#endif /* __ACE_INLINE__ */ + +#endif /* ACE_HAS_THREADS */ + +#include /**/ "ace/post.h" + +#endif /*ACE_UPIPE_STREAM_H */ diff --git a/dep/ACE_wrappers/ace/UPIPE_Stream.inl b/dep/ACE_wrappers/ace/UPIPE_Stream.inl new file mode 100644 index 00000000000..7a0d73c3179 --- /dev/null +++ b/dep/ACE_wrappers/ace/UPIPE_Stream.inl @@ -0,0 +1,14 @@ +// -*- C++ -*- +// +// $Id: UPIPE_Stream.inl 80826 2008-03-04 14:51:23Z wotte $ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_INLINE ACE_HANDLE +ACE_UPIPE_Stream::get_handle (void) const +{ + ACE_TRACE ("ACE_UPIPE_Stream::get_handle"); + return this->ACE_SPIPE::get_handle (); +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/UTF16_Encoding_Converter.cpp b/dep/ACE_wrappers/ace/UTF16_Encoding_Converter.cpp new file mode 100644 index 00000000000..0a51cf9fbb5 --- /dev/null +++ b/dep/ACE_wrappers/ace/UTF16_Encoding_Converter.cpp @@ -0,0 +1,364 @@ +// $Id: UTF16_Encoding_Converter.cpp 80826 2008-03-04 14:51:23Z wotte $ + +// ====================================================================== +// +// The actual conversion methods are covered by the copyright information +// below. It is not the actual code provided by Unicode, Inc. but is an +// ACE-ified and only slightly modified version. +// Chad Elliott 4/28/2005 +// +// Copyright 2001-2004 Unicode, Inc. +// +// Limitations on Rights to Redistribute This Code +// +// Unicode, Inc. hereby grants the right to freely use the information +// supplied in this file in the creation of products supporting the +// Unicode Standard, and to make copies of this file in any form +// for internal or external distribution as long as this notice +// remains attached. +// +// ====================================================================== + +#include "ace/UTF16_Encoding_Converter.h" + +#if defined (ACE_USES_WCHAR) +#include "ace/OS_NS_stdio.h" +#include "ace/OS_Memory.h" +#include "ace/Min_Max.h" + +#if !defined (__ACE_INLINE__) +#include "ace/UTF16_Encoding_Converter.inl" +#endif /* __ACE_INLINE__ */ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +static const ACE_UINT32 halfShift = 10; +static const ACE_UINT32 halfBase = 0x00010000; +static const ACE_UINT32 halfMask = 0x000003FF; + +static const ACE_UINT32 UNI_SUR_HIGH_START = 0x0000D800; +static const ACE_UINT32 UNI_SUR_HIGH_END = 0x0000DBFF; +static const ACE_UINT32 UNI_SUR_LOW_START = 0x0000DC00; +static const ACE_UINT32 UNI_SUR_LOW_END = 0x0000DFFF; +static const ACE_UINT32 UNI_REPLACEMENT_CHAR = 0x0000FFFD; +static const ACE_UINT32 UNI_MAX_BMP = 0x0000FFFF; +static const ACE_UINT32 UNI_MAX_UTF16 = 0x0010FFFF; + +// Once the bits are split out into bytes of UTF-8, this is a mask OR-ed +// into the first byte, depending on how many bytes follow. There are +// as many entries in this table as there are UTF-8 sequence types. +// (I.e., one byte sequence, two byte... etc.). Remember that sequencs +// for *legal* UTF-8 will be 4 or fewer bytes total. +static const ACE_Byte firstByteMark[7] = { 0x00, 0x00, 0xC0, + 0xE0, 0xF0, 0xF8, 0xFC }; + +// Index into the table below with the first byte of a UTF-8 sequence to +// get the number of trailing bytes that are supposed to follow it. +// Note that *legal* UTF-8 values can't have 4 or 5-bytes. The table is +// left as-is for anyone who may want to do such conversion, which was +// allowed in earlier algorithms. +static const ACE_Byte trailingBytesForUTF8[256] = { + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, + 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, 3,3,3,3,3,3,3,3,4,4,4,4,5,5,5,5 +}; + +// Magic values subtracted from a buffer value during UTF8 conversion. +// This table contains as many values as there might be trailing bytes +// in a UTF-8 sequence. +static const ACE_UINT32 offsetsFromUTF8[6] = { 0x00000000, 0x00003080, + 0x000E2080, 0x03C82080, + 0xFA082080, 0x82082080 }; + + +ACE_UTF16_Encoding_Converter::ACE_UTF16_Encoding_Converter (bool swap) + : swap_ (swap) +{ +} + +ACE_UTF16_Encoding_Converter::~ACE_UTF16_Encoding_Converter (void) +{ +} + +ACE_UTF16_Encoding_Converter::Result +ACE_UTF16_Encoding_Converter::to_utf8 (const void* source, + size_t source_size, + ACE_Byte* target, + size_t target_size, + bool strict) +{ + static const ACE_UINT32 byteMask = 0xBF; + static const ACE_UINT32 byteMark = 0x80; + Result result = CONVERSION_OK; + + ACE_Byte* targetEnd = target + target_size; + const ACE_UINT16* sourceStart = static_cast (source); + const ACE_UINT16* sourceEnd = sourceStart + + (source_size / sizeof (ACE_UINT16)); + + while (sourceStart < sourceEnd) + { + ACE_UINT16 nw = *sourceStart++; + ACE_UINT32 ch = (this->swap_ ? ACE_SWAP_WORD (nw) : nw); + + // If we have a surrogate pair, convert to ACE_UINT32 first. + if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_HIGH_END) + { + // If the 16 bits following the high surrogate are in the + // sourceStart buffer... + if (sourceStart < sourceEnd) + { + ACE_UINT32 ch2 = (this->swap_ ? ACE_SWAP_WORD (*sourceStart) : + *sourceStart); + // If it's a low surrogate, convert to ACE_UINT32. + if (ch2 >= UNI_SUR_LOW_START && ch2 <= UNI_SUR_LOW_END) + { + ch = ((ch - UNI_SUR_HIGH_START) << halfShift) + + (ch2 - UNI_SUR_LOW_START) + halfBase; + ++sourceStart; + } + else if (strict) + { + // it's an unpaired high surrogate + result = SOURCE_ILLEGAL; + break; + } + } + else + { + // We don't have the 16 bits following the high surrogate. + result = SOURCE_EXHAUSTED; + break; + } + } + else if (strict) + { + // UTF-16 surrogate values are illegal in UTF-32 + if (ch >= UNI_SUR_LOW_START && ch <= UNI_SUR_LOW_END) + { + result = SOURCE_ILLEGAL; + break; + } + } + + // Figure out how many bytes the result will require + unsigned short bytesToWrite = 0; + if (ch < 0x80) + bytesToWrite = 1; + else if (ch < 0x800) + bytesToWrite = 2; + else if (ch < 0x10000) + bytesToWrite = 3; + else if (ch < 0x110000) + bytesToWrite = 4; + else + { + bytesToWrite = 3; + ch = UNI_REPLACEMENT_CHAR; + } + + target += bytesToWrite; + if (target > targetEnd) + { + result = TARGET_EXHAUSTED; + break; + } + + // NOTE: Everything falls through for efficiency purposes. + switch (bytesToWrite) + { + case 4: + *--target = (ACE_Byte)((ch | byteMark) & byteMask); + ch >>= 6; + case 3: + *--target = (ACE_Byte)((ch | byteMark) & byteMask); + ch >>= 6; + case 2: + *--target = (ACE_Byte)((ch | byteMark) & byteMask); + ch >>= 6; + case 1: + *--target = (ACE_Byte)(ch | firstByteMark[bytesToWrite]); + } + target += bytesToWrite; + } + + return result; +} + +ACE_UTF16_Encoding_Converter::Result +ACE_UTF16_Encoding_Converter::from_utf8 (const ACE_Byte* source, + size_t source_size, + void* target, + size_t target_size, + bool strict) +{ + Result result = CONVERSION_OK; + const ACE_Byte* sourceEnd = source + source_size; + ACE_UINT16* targetStart = static_cast (target); + ACE_UINT16* targetEnd = targetStart + target_size; + + while (source < sourceEnd) + { + ACE_UINT32 ch = 0; + unsigned short extraBytesToRead = trailingBytesForUTF8[*source]; + if (source + extraBytesToRead >= sourceEnd) + { + result = SOURCE_EXHAUSTED; + break; + } + + // Do this check whether lenient or strict + if (!this->is_legal_utf8 (source, extraBytesToRead + 1)) + { + result = SOURCE_ILLEGAL; + break; + } + + // The cases all fall through. See "Note A" below. + switch (extraBytesToRead) + { + case 5: // remember, illegal UTF-8 + ch += *source++; + ch <<= 6; + case 4: // remember, illegal UTF-8 + ch += *source++; + ch <<= 6; + case 3: + ch += *source++; + ch <<= 6; + case 2: + ch += *source++; + ch <<= 6; + case 1: + ch += *source++; + ch <<= 6; + case 0: + ch += *source++; + } + ch -= offsetsFromUTF8[extraBytesToRead]; + + if (targetStart >= targetEnd) + { + result = TARGET_EXHAUSTED; + break; + } + + if (ch <= UNI_MAX_BMP) // Target is a character <= 0xFFFF + { + // UTF-16 surrogate values are illegal in UTF-32 + if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_LOW_END) + { + if (strict) + { + result = SOURCE_ILLEGAL; + break; + } + else + { + *targetStart++ = UNI_REPLACEMENT_CHAR; + } + } + else + { + *targetStart++ = (ACE_UINT16)ch; + } + } + else if (ch > UNI_MAX_UTF16) + { + if (strict) + { + result = SOURCE_ILLEGAL; + break; + } + else + { + *targetStart++ = UNI_REPLACEMENT_CHAR; + } + } + else + { + // targetStart is a character in range 0xFFFF - 0x10FFFF. + if (targetStart + 1 >= targetEnd) + { + result = TARGET_EXHAUSTED; + break; + } + ch -= halfBase; + *targetStart++ = (ACE_UINT16)((ch >> halfShift) + UNI_SUR_HIGH_START); + *targetStart++ = (ACE_UINT16)((ch & halfMask) + UNI_SUR_LOW_START); + } + } + + return result; +} + +ACE_UTF16_Encoding_Converter* +ACE_UTF16_Encoding_Converter::encoded (const ACE_Byte* source, + size_t source_size) +{ + static const size_t begin = 16; + static const size_t converted = begin * 4; + + ACE_Byte target[converted]; + ACE_UTF16_Encoding_Converter* converter; + ACE_NEW_RETURN (converter, + ACE_UTF16_Encoding_Converter (false), + 0); + if (converter->to_utf8 (source, + ACE_MIN (begin, source_size), + target, + converted) == CONVERSION_OK) + { + return converter; + } + else + { + delete converter; + } + + return 0; +} + +ACE_UINT32 +ACE_UTF16_Encoding_Converter::get_UNI_SUR_HIGH_START (void) +{ + return UNI_SUR_HIGH_START; +} + +ACE_UINT32 +ACE_UTF16_Encoding_Converter::get_UNI_SUR_LOW_END (void) +{ + return UNI_SUR_LOW_END; +} + +ACE_UINT32 +ACE_UTF16_Encoding_Converter::get_UNI_REPLACEMENT_CHAR (void) +{ + return UNI_REPLACEMENT_CHAR; +} + +const ACE_Byte* +ACE_UTF16_Encoding_Converter::get_first_byte_mark (void) +{ + return firstByteMark; +} + +const ACE_Byte* +ACE_UTF16_Encoding_Converter::get_trailing_bytes_for_utf8 (void) +{ + return trailingBytesForUTF8; +} + +const ACE_UINT32* +ACE_UTF16_Encoding_Converter::get_offsets_from_utf8 (void) +{ + return offsetsFromUTF8; +} + +ACE_END_VERSIONED_NAMESPACE_DECL +#endif /* ACE_USES_WCHAR */ diff --git a/dep/ACE_wrappers/ace/UTF16_Encoding_Converter.h b/dep/ACE_wrappers/ace/UTF16_Encoding_Converter.h new file mode 100644 index 00000000000..9bdcb21a07f --- /dev/null +++ b/dep/ACE_wrappers/ace/UTF16_Encoding_Converter.h @@ -0,0 +1,86 @@ +// -*- C++ -*- + +//========================================================================= +/** + * @file UTF16_Encoding_Converter.h + * + * $Id: UTF16_Encoding_Converter.h 80826 2008-03-04 14:51:23Z wotte $ + * + * This class contains declarations for methods that convert between + * UTF-16 (both BE and LE) and UTF-8 + * + * @author Chad Elliott + */ +//========================================================================= + +#ifndef ACE_UTF16_ENCODING_CONVERTER_H +#define ACE_UTF16_ENCODING_CONVERTER_H + +#include /**/ "ace/pre.h" + +#include "ace/Encoding_Converter.h" + +#if defined (ACE_USES_WCHAR) +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +/** Convert from UTF-16 to UTF-8 and from UTF-8 to UTF-16. + * This class implements the ACE_Encoding_Converter interface. + */ +class ACE_UTF16_Encoding_Converter: public ACE_Encoding_Converter +{ +public: + /// The swap parameter determines whether we need to swap byte order on + /// the stream as each word is pulled off when converting to UTF-8. + ACE_UTF16_Encoding_Converter (bool swap = false); + + /// This is a do nothing destructor. + virtual ~ACE_UTF16_Encoding_Converter (void); + + /// Convert the source from UTF-16 to UTF-8 and store it in the + /// provided target buffer. + virtual Result to_utf8 (const void* source, + size_t source_size, + ACE_Byte* target, + size_t target_size, + bool strict = true); + + /// Convert the UTF-8 source into a UTF-16 encoding and store it + /// in the provided target buffer. + virtual Result from_utf8 (const ACE_Byte* source, + size_t source_size, + void* target, + size_t target_size, + bool strict = true); + + /// This factory helper method determines if the source stream is UTF-16 + /// encoded. If it is, allocate an ACE_UTF16_Encoding_Converter and + /// return it. The caller then owns the allocated object. + static ACE_UTF16_Encoding_Converter* encoded (const ACE_Byte* source, + size_t source_size); + +protected: + /// Determines if the source buffer is legal UTF-8 + bool is_legal_utf8 (const ACE_Byte* source, + size_t length) const; + + static ACE_UINT32 get_UNI_SUR_HIGH_START (void); + static ACE_UINT32 get_UNI_SUR_LOW_END (void); + static ACE_UINT32 get_UNI_REPLACEMENT_CHAR (void); + static const ACE_Byte* get_first_byte_mark (void); + static const ACE_Byte* get_trailing_bytes_for_utf8 (void); + static const ACE_UINT32* get_offsets_from_utf8 (void); + + bool swap_; +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +#include "ace/UTF16_Encoding_Converter.inl" +#endif /* __ACE_INLINE__ */ + +#endif /* ACE_USES_WCHAR */ + +#include /**/ "ace/post.h" + +#endif /* ACE_UTF16_ENCODING_CONVERTER_H */ diff --git a/dep/ACE_wrappers/ace/UTF16_Encoding_Converter.inl b/dep/ACE_wrappers/ace/UTF16_Encoding_Converter.inl new file mode 100644 index 00000000000..e5292757889 --- /dev/null +++ b/dep/ACE_wrappers/ace/UTF16_Encoding_Converter.inl @@ -0,0 +1,76 @@ +/* -*- C++ -*- */ +// $Id: UTF16_Encoding_Converter.inl 80826 2008-03-04 14:51:23Z wotte $ + +// ====================================================================== +// +// The actual conversion methods are covered by the copyright information +// below. +// Chad Elliott 4/28/2005 +// +// Copyright 2001-2004 Unicode, Inc. +// +// Limitations on Rights to Redistribute This Code +// +// Unicode, Inc. hereby grants the right to freely use the information +// supplied in this file in the creation of products supporting the +// Unicode Standard, and to make copies of this file in any form +// for internal or external distribution as long as this notice +// remains attached. +// +// ====================================================================== + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_INLINE bool +ACE_UTF16_Encoding_Converter::is_legal_utf8 (const ACE_Byte* source, + size_t length) const +{ + ACE_Byte a; + const ACE_Byte* srcptr = source + length; + + switch (length) + { + default: + return false; + + // Everything else falls through when "true"... + case 4: if ((a = (*--srcptr)) < 0x80 || a > 0xBF) return false; + case 3: if ((a = (*--srcptr)) < 0x80 || a > 0xBF) return false; + case 2: if ((a = (*--srcptr)) > 0xBF) return false; + + switch (*source) + { + // no fall-through in this inner switch + case 0xE0: + if (a < 0xA0) + return false; + break; + case 0xED: + if (a > 0x9F) + return false; + break; + case 0xF0: + if (a < 0x90) + return false; + break; + case 0xF4: + if (a > 0x8F) + return false; + break; + default: + if (a < 0x80) + return false; + } + + case 1: + if (*source >= 0x80 && *source < 0xC2) + return false; + } + + if (*source > 0xF4) + return false; + + return true; +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/UTF32_Encoding_Converter.cpp b/dep/ACE_wrappers/ace/UTF32_Encoding_Converter.cpp new file mode 100644 index 00000000000..459bf2530b0 --- /dev/null +++ b/dep/ACE_wrappers/ace/UTF32_Encoding_Converter.cpp @@ -0,0 +1,254 @@ +// $Id: UTF32_Encoding_Converter.cpp 80826 2008-03-04 14:51:23Z wotte $ + +// ====================================================================== +// +// The actual conversion methods are covered by the copyright information +// below. It is not the actual code provided by Unicode, Inc. but is an +// ACE-ified and only slightly modified version. +// +// Chad Elliott 4/28/2005 +// +// Copyright 2001-2004 Unicode, Inc. +// +// Limitations on Rights to Redistribute This Code +// +// Unicode, Inc. hereby grants the right to freely use the information +// supplied in this file in the creation of products supporting the +// Unicode Standard, and to make copies of this file in any form +// for internal or external distribution as long as this notice +// remains attached. +// +// ====================================================================== + +#include "ace/UTF32_Encoding_Converter.h" + +#if defined (ACE_USES_WCHAR) +#include "ace/OS_NS_stdio.h" +#include "ace/OS_Memory.h" +#include "ace/Min_Max.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +static const ACE_UINT32 UNI_MAX_LEGAL_UTF32 = 0x0010FFFF; + +ACE_UTF32_Encoding_Converter::ACE_UTF32_Encoding_Converter (bool swap) + : ACE_UTF16_Encoding_Converter (swap) +{ +} + +ACE_UTF32_Encoding_Converter::~ACE_UTF32_Encoding_Converter (void) +{ +} + +ACE_UTF32_Encoding_Converter::Result +ACE_UTF32_Encoding_Converter::to_utf8 (const void* source, + size_t source_size, + ACE_Byte* target, + size_t target_size, + bool strict) +{ + static const ACE_UINT32 byteMask = 0xBF; + static const ACE_UINT32 byteMark = 0x80; + static const ACE_UINT32 UNI_SUR_HIGH_START = get_UNI_SUR_HIGH_START (); + static const ACE_UINT32 UNI_SUR_LOW_END = get_UNI_SUR_LOW_END (); + static const ACE_Byte* firstByteMark = get_first_byte_mark (); + + Result result = CONVERSION_OK; + ACE_Byte* targetEnd = target + target_size; + const ACE_UINT32* sourceStart = static_cast (source); + const ACE_UINT32* sourceEnd = sourceStart + (source_size / sizeof (ACE_UINT32)); + + while (sourceStart < sourceEnd) + { + ACE_UINT32 nw = *sourceStart++; + ACE_UINT32 ch = (this->swap_ ? ACE_SWAP_LONG (nw) : nw); + unsigned short bytesToWrite = 0; + + if (strict) + { + // UTF-16 surrogate values are illegal in UTF-32 + if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_LOW_END) + { + result = SOURCE_ILLEGAL; + break; + } + } + + // Figure out how many bytes the result will require. Turn any + // illegally large ACE_UINT32 things (> Plane 17) into replacement + // chars. + if (ch < 0x80) + { + bytesToWrite = 1; + } + else if (ch < 0x800) + { + bytesToWrite = 2; + } + else if (ch < 0x10000) + { + bytesToWrite = 3; + } + else if (ch <= UNI_MAX_LEGAL_UTF32) + { + bytesToWrite = 4; + } + else + { + result = SOURCE_ILLEGAL; + break; + } + + target += bytesToWrite; + if (target > targetEnd) + { + result = TARGET_EXHAUSTED; + break; + } + + // NOTE: everything falls through. + switch (bytesToWrite) + { + case 4: + *--target = (ACE_Byte)((ch | byteMark) & byteMask); + ch >>= 6; + case 3: + *--target = (ACE_Byte)((ch | byteMark) & byteMask); + ch >>= 6; + case 2: + *--target = (ACE_Byte)((ch | byteMark) & byteMask); + ch >>= 6; + case 1: + *--target = (ACE_Byte) (ch | firstByteMark[bytesToWrite]); + } + target += bytesToWrite; + } + + return result; +} + +ACE_UTF32_Encoding_Converter::Result +ACE_UTF32_Encoding_Converter::from_utf8 (const ACE_Byte* source, + size_t source_size, + void* target, + size_t target_size, + bool strict) +{ + static const ACE_UINT32 UNI_SUR_HIGH_START = get_UNI_SUR_HIGH_START (); + static const ACE_UINT32 UNI_SUR_LOW_END = get_UNI_SUR_LOW_END (); + static const ACE_UINT32 UNI_REPLACEMENT_CHAR = get_UNI_REPLACEMENT_CHAR (); + static const ACE_Byte* trailingBytesForUTF8 = get_trailing_bytes_for_utf8 (); + static const ACE_UINT32* offsetsFromUTF8 = get_offsets_from_utf8 (); + + Result result = CONVERSION_OK; + const ACE_Byte* sourceEnd = source + source_size; + ACE_UINT32* targetStart = static_cast (target); + ACE_UINT32* targetEnd = targetStart + target_size; + + while (source < sourceEnd) + { + ACE_UINT32 ch = 0; + unsigned short extraBytesToRead = trailingBytesForUTF8[*source]; + if (source + extraBytesToRead >= sourceEnd) + { + result = SOURCE_EXHAUSTED; + break; + } + + // Do this check whether lenient or strict + if (!this->is_legal_utf8 (source, extraBytesToRead + 1)) + { + result = SOURCE_ILLEGAL; + break; + } + + // The cases all fall through. See "Note A" below. + switch (extraBytesToRead) + { + case 5: + ch += *source++; + ch <<= 6; + case 4: + ch += *source++; + ch <<= 6; + case 3: + ch += *source++; + ch <<= 6; + case 2: + ch += *source++; + ch <<= 6; + case 1: + ch += *source++; + ch <<= 6; + case 0: + ch += *source++; + } + ch -= offsetsFromUTF8[extraBytesToRead]; + + if (targetStart >= targetEnd) + { + result = TARGET_EXHAUSTED; + break; + } + + if (ch <= UNI_MAX_LEGAL_UTF32) + { + // UTF-16 surrogate values are illegal in UTF-32, and anything + // over Plane 17 (> 0x10FFFF) is illegal. + if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_LOW_END) + { + if (strict) + { + result = SOURCE_ILLEGAL; + break; + } + else + { + *targetStart++ = UNI_REPLACEMENT_CHAR; + } + } + else + { + *targetStart++ = ch; + } + } + else + { + result = SOURCE_ILLEGAL; + break; + } + } + + return result; +} + +ACE_UTF32_Encoding_Converter* +ACE_UTF32_Encoding_Converter::encoded (const ACE_Byte* source, + size_t source_size) +{ + static const size_t begin = 16; + static const size_t converted = begin * 4; + + ACE_Byte target[converted]; + ACE_UTF32_Encoding_Converter* converter = 0; + ACE_NEW_RETURN (converter, + ACE_UTF32_Encoding_Converter (false), + 0); + + if (converter->to_utf8 (source, + ACE_MIN (begin, source_size), + target, + converted) == CONVERSION_OK) + { + return converter; + } + else + { + delete converter; + } + + return 0; +} + +ACE_END_VERSIONED_NAMESPACE_DECL +#endif /* ACE_USES_WCHAR */ diff --git a/dep/ACE_wrappers/ace/UTF32_Encoding_Converter.h b/dep/ACE_wrappers/ace/UTF32_Encoding_Converter.h new file mode 100644 index 00000000000..214edeeeed8 --- /dev/null +++ b/dep/ACE_wrappers/ace/UTF32_Encoding_Converter.h @@ -0,0 +1,67 @@ +// -*- C++ -*- + +//========================================================================= +/** + * @file UTF32_Encoding_Converter.h + * + * $Id: UTF32_Encoding_Converter.h 80826 2008-03-04 14:51:23Z wotte $ + * + * This class contains declarations for methods that convert between + * UTF-32 (both BE and LE) and UTF-8 + * + * @author Chad Elliott + */ +//========================================================================= + +#ifndef ACE_UTF32_ENCODING_CONVERTER_H +#define ACE_UTF32_ENCODING_CONVERTER_H + +#include /**/ "ace/pre.h" + +#include "ace/UTF16_Encoding_Converter.h" + +#if defined (ACE_USES_WCHAR) +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +/** Convert from UTF-32 to UTF-8 and from UTF-8 to UTF-32. + * This class implements the ACE_Encoding_Converter interface. + */ +class ACE_UTF32_Encoding_Converter: public ACE_UTF16_Encoding_Converter +{ +public: + /// This class has some similarities to the UTF16 converter, so + /// we just construct our base class and pass the swap parameter. + ACE_UTF32_Encoding_Converter (bool swap = false); + + /// This is a do nothing destructor. + virtual ~ACE_UTF32_Encoding_Converter (void); + + /// Convert the source from UTF-32 to UTF-8 and store it in the + /// provided target buffer. + virtual Result to_utf8 (const void* source, + size_t source_size, + ACE_Byte* target, + size_t target_size, + bool strict = true); + + /// Convert the UTF-8 source into a UTF-32 encoding and store it + /// in the provided target buffer. + virtual Result from_utf8 (const ACE_Byte* source, + size_t source_size, + void* target, + size_t target_size, + bool strict = true); + + /// This factory helper method determines if the source stream is UTF-32 + /// encoded. If it is, allocate an ACE_UTF32_Encoding_Converter and + /// return it. The caller then owns the allocated object. + static ACE_UTF32_Encoding_Converter* encoded (const ACE_Byte* source, + size_t source_size); +}; + +ACE_END_VERSIONED_NAMESPACE_DECL +#endif /* ACE_USES_WCHAR */ + +#include /**/ "ace/post.h" + +#endif /* ACE_UTF32_ENCODING_CONVERTER_H */ diff --git a/dep/ACE_wrappers/ace/UTF8_Encoding_Converter.cpp b/dep/ACE_wrappers/ace/UTF8_Encoding_Converter.cpp new file mode 100644 index 00000000000..cd6c409d0f8 --- /dev/null +++ b/dep/ACE_wrappers/ace/UTF8_Encoding_Converter.cpp @@ -0,0 +1,92 @@ +// $Id: UTF8_Encoding_Converter.cpp 80826 2008-03-04 14:51:23Z wotte $ + +#include "ace/UTF8_Encoding_Converter.h" + +#if defined (ACE_USES_WCHAR) +#include "ace/UTF16_Encoding_Converter.h" +#include "ace/UTF32_Encoding_Converter.h" +#include "ace/OS_NS_string.h" +#include "ace/OS_Memory.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_UTF8_Encoding_Converter::ACE_UTF8_Encoding_Converter (void) + : native_ (0) +{ + // Choose a converter for the ASCII or UTF-8 string to a wide character + // string which we will use in from_utf8. We have to make an + // assumption here about the encoding based on the size of ACE_TCHAR. + switch (sizeof (ACE_TCHAR)) + { + case 4: + ACE_NEW(this->native_, ACE_UTF32_Encoding_Converter); + break; + case 2: + ACE_NEW(this->native_, ACE_UTF16_Encoding_Converter); + break; + } +} + +ACE_UTF8_Encoding_Converter::~ACE_UTF8_Encoding_Converter (void) +{ + delete native_; +} + +ACE_UTF8_Encoding_Converter::Result +ACE_UTF8_Encoding_Converter::to_utf8 (const void* source, + size_t source_size, + ACE_Byte* target, + size_t target_size, + bool /*strict*/) +{ + if (target_size >= source_size) + { + ACE_OS::memcpy (target, source, source_size); + return CONVERSION_OK; + } + + return TARGET_EXHAUSTED; +} + +ACE_UTF8_Encoding_Converter::Result +ACE_UTF8_Encoding_Converter::from_utf8 (const ACE_Byte* source, + size_t source_size, + void* target, + size_t target_size, + bool strict) +{ + if (this->native_ != 0) + { + return this->native_->from_utf8(source, source_size, + target, target_size, strict); + } + + ACE_TCHAR* targetStart = static_cast (target); + ACE_OS::strncpy (targetStart, + ACE_TEXT_CHAR_TO_TCHAR ( + reinterpret_cast (source)), + source_size); + targetStart[source_size] = 0; + return CONVERSION_OK; +} + +ACE_UTF8_Encoding_Converter* +ACE_UTF8_Encoding_Converter::encoded (const ACE_Byte* source, + size_t source_size) +{ + for(size_t i = 0; i < source_size; i++) + { + if (source[i] < 0x01 || source[i] > 0x7f) + return 0; + } + + // All characters are "valid" ASCII + ACE_UTF8_Encoding_Converter* converter = 0; + ACE_NEW_RETURN (converter, + ACE_UTF8_Encoding_Converter, + 0); + return converter; +} + +ACE_END_VERSIONED_NAMESPACE_DECL +#endif /* ACE_USES_WCHAR */ diff --git a/dep/ACE_wrappers/ace/UTF8_Encoding_Converter.h b/dep/ACE_wrappers/ace/UTF8_Encoding_Converter.h new file mode 100644 index 00000000000..2cb6ed4e452 --- /dev/null +++ b/dep/ACE_wrappers/ace/UTF8_Encoding_Converter.h @@ -0,0 +1,72 @@ +// -*- C++ -*- + +//========================================================================= +/** + * @file UTF8_Encoding_Converter.h + * + * $Id: UTF8_Encoding_Converter.h 80826 2008-03-04 14:51:23Z wotte $ + * + * This class contains declarations for methods that convert between + * UTF-8 and the native ACE_TCHAR representation. + * + * @author Chad Elliott + */ +//========================================================================= + +#ifndef ACE_UTF8_ENCODING_CONVERTER_H +#define ACE_UTF8_ENCODING_CONVERTER_H + +#include /**/ "ace/pre.h" + +#include "ace/Encoding_Converter.h" + +#if defined (ACE_USES_WCHAR) +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +/** Convert from UTF-16 or UTF-32 to UTF-8. + * This class implements the ACE_Encoding_Converter interface. + */ +class ACE_UTF8_Encoding_Converter: public ACE_Encoding_Converter +{ +public: + /// Allocate the converter to be used by the from_utf8() method based + /// on the size of the native wide character. + ACE_UTF8_Encoding_Converter (void); + + /// De-allocate the native converter. + virtual ~ACE_UTF8_Encoding_Converter (void); + + /// Since the source *must be* UTF-8, there is no conversion required. + /// This method just copies the source to the target given that there + /// is enough space. + virtual Result to_utf8 (const void* source, + size_t source_size, + ACE_Byte* target, + size_t target_size, + bool strict = true); + + /// Utilize the native converter to convert the UTF-8 source into an + /// alternate encoding and store it in the provided target buffer. + virtual Result from_utf8 (const ACE_Byte* source, + size_t source_size, + void* target, + size_t target_size, + bool strict = true); + + + /// This factory helper method determines if the source stream is UTF-8 + /// encoded. If it is, allocate an ACE_UTF8_Encoding_Converter and + /// return it. The caller then owns the allocated object. + static ACE_UTF8_Encoding_Converter* encoded (const ACE_Byte* source, + size_t source_size); + +private: + ACE_Encoding_Converter* native_; +}; + +ACE_END_VERSIONED_NAMESPACE_DECL +#endif /* ACE_USES_WCHAR */ + +#include /**/ "ace/post.h" + +#endif /* ACE_UTF8_ENCODING_CONVERTER_H */ diff --git a/dep/ACE_wrappers/ace/UUID.cpp b/dep/ACE_wrappers/ace/UUID.cpp new file mode 100644 index 00000000000..4ce2bcd0a4b --- /dev/null +++ b/dep/ACE_wrappers/ace/UUID.cpp @@ -0,0 +1,554 @@ +//$Id: UUID.cpp 81541 2008-04-30 13:56:12Z shuston $ + +#include "ace/UUID.h" +#include "ace/Guard_T.h" + +#if !defined (__ACE_INLINE__) +#include "ace/UUID.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/Log_Msg.h" +#include "ace/OS_NS_stdio.h" +#include "ace/OS_NS_string.h" +#include "ace/OS_NS_sys_time.h" +#include "ace/OS_NS_netdb.h" +#include "ace/OS_NS_unistd.h" +#include "ace/ACE.h" + +ACE_RCSID (ace, + UUID, + "$Id: UUID.cpp 81541 2008-04-30 13:56:12Z shuston $") + + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +namespace ACE_Utils +{ + UUID_Node::UUID_Node (void) + { + for (int i = 0; i < UUID_Node::NODE_ID_SIZE; ++i) + node_ID_[i] = 0; + } + + UUID_Node::Node_ID& + UUID_Node::node_ID (void) + { + return node_ID_; + } + + void + UUID_Node::node_ID (Node_ID& node_ID) + { + for (int i = 0; i < UUID_Node::NODE_ID_SIZE; ++i) + node_ID_[i] = node_ID[i]; + } + + UUID UUID::NIL_UUID; + + /// Construct a nil UUID. Such a UUID has every one of it's data + /// elements set to zero. + UUID::UUID (void) + : time_low_ (0), + time_mid_ (0), + time_hi_and_version_ (0), + clock_seq_hi_and_reserved_ (0), + clock_seq_low_ (0), + node_ (0), + node_release_ (true), + as_string_ (0) + { + ACE_NEW (node_, + UUID_Node); + } + + /// Construct a UUID from a string representation of an UUID. + UUID::UUID (const ACE_CString& uuid_string) + : time_low_ (0), + time_mid_ (0), + time_hi_and_version_ (0), + clock_seq_hi_and_reserved_ (0), + clock_seq_low_ (0), + node_ (0), + node_release_ (true), + as_string_ (0) + { + ACE_NEW (node_, + UUID_Node); + + this->from_string_i (uuid_string); + } + + UUID::UUID (const UUID &right) + : time_low_ (right.time_low_), + time_mid_ (right.time_mid_), + time_hi_and_version_ (right.time_hi_and_version_), + clock_seq_hi_and_reserved_ (right.clock_seq_hi_and_reserved_), + clock_seq_low_ (right.clock_seq_low_), + as_string_ (0) + { + ACE_NEW (node_, + UUID_Node (*right.node_)); + } + + UUID::~UUID (void) + { + if (node_release_) + delete node_; + + if (as_string_ != 0) + delete as_string_; + } + + const ACE_CString* + UUID::to_string (void) + { + /// Only compute the string representation once. + if (as_string_ == 0) + { + // Get a buffer exactly the correct size. Use the nil UUID as a + // gauge. Don't forget the trailing nul. + size_t UUID_STRING_LENGTH = 36 + thr_id_.length () + pid_.length (); + char *buf = 0; + + if ((thr_id_.length () != 0) && (pid_.length () != 0)) + { + UUID_STRING_LENGTH += 2; //for '-' + ACE_NEW_RETURN (buf, + char[UUID_STRING_LENGTH + 1], + 0); + + ACE_OS::sprintf (buf, + "%8.8x-%4.4x-%4.4x-%2.2x%2.2x-%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x-%s-%s", + this->time_low_, + this->time_mid_, + this->time_hi_and_version_, + this->clock_seq_hi_and_reserved_, + this->clock_seq_low_, + (this->node_->node_ID ()) [0], + (this->node_->node_ID ()) [1], + (this->node_->node_ID ()) [2], + (this->node_->node_ID ()) [3], + (this->node_->node_ID ()) [4], + (this->node_->node_ID ()) [5], + thr_id_.c_str (), + pid_.c_str () + ); + } + else + { + ACE_NEW_RETURN (buf, + char[UUID_STRING_LENGTH + 1], + 0); + + ACE_OS::sprintf (buf, + "%8.8x-%4.4x-%4.4x-%2.2x%2.2x-%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x", + this->time_low_, + this->time_mid_, + this->time_hi_and_version_, + this->clock_seq_hi_and_reserved_, + this->clock_seq_low_, + (this->node_->node_ID ()) [0], + (this->node_->node_ID ()) [1], + (this->node_->node_ID ()) [2], + (this->node_->node_ID ()) [3], + (this->node_->node_ID ()) [4], + (this->node_->node_ID ()) [5] + ); + } + + // We allocated 'buf' above dynamically, so we shouldn't use + // ACE_NEW_RETURN here to avoid a possible memory leak. + ACE_NEW_NORETURN (this->as_string_, + ACE_CString (buf, UUID_STRING_LENGTH)); + + // we first free the dynamically allocated 'buf'. + delete [] buf; + + // then we test that ACE_NEW succeded for 'as_string_' + // if not, we return 0 (NULL) to indicate failure. + if (this->as_string_ == 0 ) + return 0; + } + + return as_string_; + } + + void + UUID::from_string_i (const ACE_CString& uuid_string) + { + if (uuid_string.length () < NIL_UUID.to_string ()->length ()) + { + ACE_ERROR ((LM_ERROR, + "%N ACE_UUID::from_string_i - " + "IllegalArgument (incorrect string length)\n")); + return; + } + + /// Special case for the nil UUID. + if (uuid_string == *NIL_UUID.to_string ()) + { + bool copy_constructor_not_supported = false; + ACE_ASSERT (copy_constructor_not_supported); + //*this = NIL_UUID; + ACE_UNUSED_ARG (copy_constructor_not_supported); + return; + } + + unsigned int time_low; + unsigned int time_mid; + unsigned int time_hi_and_version; + unsigned int clock_seq_hi_and_reserved; + unsigned int clock_seq_low; + unsigned int node [UUID_Node::NODE_ID_SIZE]; + char thr_pid_buf [BUFSIZ]; + + if (uuid_string.length () == NIL_UUID.to_string ()->length ()) + { + // This might seem quite strange this being in ACE, but it + // seems to be a bit difficult to write a facade for ::sscanf + // because some compilers dont support vsscanf, including + // MSVC. It appears that most platforms support sscanf though + // so we need to use it directly. + const int nScanned = +#if defined (ACE_HAS_TR24731_2005_CRT) + sscanf_s ( +#else + ::sscanf ( +#endif /* ACE_HAS_TR24731_2005_CRT */ + uuid_string.c_str (), + "%8x-%4x-%4x-%2x%2x-%2x%2x%2x%2x%2x%2x", + &time_low, + &time_mid, + &time_hi_and_version, + &clock_seq_hi_and_reserved, + &clock_seq_low, + &node[0], + &node[1], + &node[2], + &node[3], + &node[4], + &node[5] + ); + + if (nScanned != 11) + { + ACE_DEBUG ((LM_DEBUG, + "UUID::from_string_i - " + "IllegalArgument (invalid string representation)\n")); + return; + } + } + else + { + const int nScanned = +#if defined (ACE_HAS_TR24731_2005_CRT) + sscanf_s (uuid_string.c_str (), + "%8x-%4x-%4x-%2x%2x-%2x%2x%2x%2x%2x%2x-%s", + &time_low, + &time_mid, + &time_hi_and_version, + &clock_seq_hi_and_reserved, + &clock_seq_low, + &node[0], + &node[1], + &node[2], + &node[3], + &node[4], + &node[5], + thr_pid_buf, + BUFSIZ + ); +#else + ::sscanf (uuid_string.c_str (), + "%8x-%4x-%4x-%2x%2x-%2x%2x%2x%2x%2x%2x-%s", + &time_low, + &time_mid, + &time_hi_and_version, + &clock_seq_hi_and_reserved, + &clock_seq_low, + &node[0], + &node[1], + &node[2], + &node[3], + &node[4], + &node[5], + thr_pid_buf + ); +#endif /* ACE_HAS_TR24731_2005_CRT */ + + if (nScanned != 12) + { + ACE_DEBUG ((LM_DEBUG, + "ACE_UUID::from_string_i - " + "IllegalArgument (invalid string representation)\n")); + return; + } + } + + this->time_low_ = static_cast (time_low); + this->time_mid_ = static_cast (time_mid); + this->time_hi_and_version_ = static_cast (time_hi_and_version); + this->clock_seq_hi_and_reserved_ = static_cast (clock_seq_hi_and_reserved); + this->clock_seq_low_ = static_cast (clock_seq_low); + + UUID_Node::Node_ID node_id; + for (int i = 0; i < UUID_Node::NODE_ID_SIZE; ++i) + node_id [i] = static_cast (node[i]); + + this->node_->node_ID (node_id); + + // Support varient 10- only + if ((this->clock_seq_hi_and_reserved_ & 0xc0) != 0x80 && (this->clock_seq_hi_and_reserved_ & 0xc0) != 0xc0) + { + ACE_DEBUG ((LM_DEBUG, + "ACE_UUID::from_string_i - " + "IllegalArgument (unsupported variant)\n")); + return; + } + + /// Support versions 1, 3, and 4 only + ACE_UINT16 V1 = this->time_hi_and_version_; + + if ((V1 & 0xF000) != 0x1000 && + (V1 & 0xF000) != 0x3000 && + (V1 & 0xF000) != 0x4000) + { + ACE_DEBUG ((LM_DEBUG, + "ACE_UUID::from_string_i - " + "IllegalArgument (unsupported version)\n")); + return; + } + + if ((this->clock_seq_hi_and_reserved_ & 0xc0) == 0xc0) + { + if (uuid_string.length () == NIL_UUID.to_string ()->length ()) + { + ACE_DEBUG ((LM_DEBUG, + "ACE_UUID::from_string_i - " + "IllegalArgument (Missing Thread and Process Id)\n")); + return; + } + ACE_CString thr_pid_str (thr_pid_buf); + ssize_t pos = static_cast (thr_pid_str.find ('-')); + if (pos == -1) + ACE_DEBUG ((LM_DEBUG, + "ACE_UUID::from_string_i - " + "IllegalArgument (Thread and Process Id format incorrect)\n")); + + this->thr_id_ = thr_pid_str.substr (0, pos); + this->pid_ = thr_pid_str.substr (pos+1, thr_pid_str.length ()-pos-1); + } + } + + UUID_Generator::UUID_Generator () + : time_last_ (0), + destroy_lock_ (true) + { + ACE_NEW (lock_, + ACE_SYNCH_MUTEX); + } + + UUID_Generator::~UUID_Generator () + { + if (destroy_lock_) + delete lock_; + } + + void + UUID_Generator::init (void) + { + ACE_OS::macaddr_node_t macaddress; + int result = ACE_OS::getmacaddress (&macaddress); + + UUID_Node::Node_ID node_id; + if (result != -1) + { +// ACE_DEBUG ((LM_DEBUG, +// "%02X-%02X-%02X-%02X-%02X-%02X\n", +// macaddress.node [0], +// macaddress.node [1], +// macaddress.node [2], +// macaddress.node [3], +// macaddress.node [4], +// macaddress.node [5])); + + ACE_OS::memcpy (&node_id, + macaddress.node, + sizeof (node_id)); + } + else + { + node_id [0] = static_cast (ACE_OS::rand ()); + node_id [1] = static_cast (ACE_OS::rand ()); + node_id [2] = static_cast (ACE_OS::rand ()); + node_id [3] = static_cast (ACE_OS::rand ()); + node_id [4] = static_cast (ACE_OS::rand ()); + node_id [5] = static_cast (ACE_OS::rand ()); + } + + this->get_timestamp (time_last_); + + { + ACE_GUARD (ACE_SYNCH_MUTEX, ace_mon, *lock_); + uuid_state_.timestamp = time_last_; + uuid_state_.node.node_ID (node_id); + } + } + + void + UUID_Generator::generate_UUID (UUID& uuid,ACE_UINT16 version, + u_char variant) + { + UUID_Time timestamp; + ACE_UINT16 clock_sequence; + + this->get_timestamp_and_clocksequence (timestamp, + clock_sequence); + + // Construct a Version 1 UUID with the information in the arguements. + uuid.time_low (static_cast (timestamp & 0xFFFFFFFF)); + uuid.time_mid (static_cast ((timestamp >> 32) & 0xFFFF)); + + ACE_UINT16 tHAV = static_cast ((timestamp >> 48) & 0xFFFF); + tHAV |= (version << 12); + uuid.time_hi_and_version (tHAV); + + u_char cseqHAV; + uuid.clock_seq_low (static_cast (clock_sequence & 0xFF)); + cseqHAV = static_cast ((clock_sequence & 0x3f00) >> 8); + uuid_state_.timestamp = timestamp; + + cseqHAV |= variant; + uuid.clock_seq_hi_and_reserved (cseqHAV); + uuid.node (& (uuid_state_.node)); + + if (variant == 0xc0) + { + ACE_Thread_ID thread_id; + char buf [BUFSIZ]; + thread_id.to_string (buf); + uuid.thr_id (buf); + + ACE_OS::sprintf (buf, + "%d", + static_cast (ACE_OS::getpid ())); + uuid.pid (buf); + } + } + + UUID* + UUID_Generator::generate_UUID (ACE_UINT16 version, u_char variant) + { + UUID* uuid; + ACE_NEW_RETURN (uuid, + UUID, + 0); + + this->generate_UUID (*uuid, version, variant); + return uuid; + } + + /// Obtain a new timestamp. If UUID's are being generated too quickly + /// the clock sequence will be incremented + void + UUID_Generator::get_timestamp (UUID_Time& timestamp) + { + ACE_GUARD (ACE_SYNCH_MUTEX, mon, *lock_); + + this->get_systemtime (timestamp); + + // Account for the clock being set back. Increment the clock / + // sequence. + if (timestamp <= time_last_) + { + uuid_state_.clock_sequence = static_cast + ((uuid_state_.clock_sequence + 1) & ACE_UUID_CLOCK_SEQ_MASK); + } + // If the system time ticked since the last UUID was + // generated. Set / the clock sequence back. + else if (timestamp > time_last_) + { + uuid_state_.clock_sequence = 0; + } + + time_last_ = timestamp; + } + + void + UUID_Generator::get_timestamp_and_clocksequence (UUID_Time& timestamp, + ACE_UINT16& clock_sequence) + { + ACE_GUARD (ACE_SYNCH_MUTEX, mon, *lock_); + + this->get_systemtime (timestamp); + + // Account for the clock being set back. Increment the clock / + // sequence. + if (timestamp <= time_last_) + uuid_state_.clock_sequence = static_cast ((uuid_state_.clock_sequence + 1) & ACE_UUID_CLOCK_SEQ_MASK); + + // If the system time ticked since the last UUID was + // generated. Set / the clock sequence back. + else if (timestamp > time_last_) + uuid_state_.clock_sequence = 0; + + time_last_ = timestamp; + clock_sequence = uuid_state_.clock_sequence; + } + + /** + * ACE_Time_Value is in POSIX time, seconds since Jan 1, 1970. UUIDs use + * time in 100ns ticks since 15 October 1582. The difference is: + * 15 Oct 1582 - 1 Jan 1600: 17 days in Oct, 30 in Nov, 31 in Dec + + * 17 years and 4 leap days (1584, 88, 92 and 96) + * 1 Jan 1600 - 1 Jan 1900: 3 centuries + 73 leap days ( 25 in 17th cent. + * and 24 each in 18th and 19th centuries) + * 1 Jan 1900 - 1 Jan 1970: 70 years + 17 leap days. + * This adds up, in days: (17+30+31+365*17+4)+ (365*300+73)+ (365*70+17) or + * 122192928000000000U (0x1B21DD213814000) 100 ns ticks. + */ + void + UUID_Generator::get_systemtime (UUID_Time & timestamp) + { + const UUID_Time timeOffset = +#if defined (ACE_LACKS_UNSIGNEDLONGLONG_T) + ACE_U_LongLong (ACE_INT64_LITERAL (0x1B21DD213814000)); +#elif defined (ACE_LACKS_LONGLONG_T) + ACE_U_LongLong (0x13814000u, 0x1B21DD2u); +#else + ACE_UINT64_LITERAL (0x1B21DD213814000); +#endif /* ACE_LACKS_UNSIGNEDLONGLONG_T */ + + /// Get the time of day, convert to 100ns ticks then add the offset. + ACE_Time_Value now = ACE_OS::gettimeofday (); + ACE_UINT64 time; + now.to_usec (time); + time = time * 10; + timestamp = time + timeOffset; +} + + ACE_SYNCH_MUTEX* + UUID_Generator::lock (void) + { + return this->lock_; + } + + void + UUID_Generator::lock (ACE_SYNCH_MUTEX* lock, + bool release_lock) + { + if (this->destroy_lock_) + delete this->lock_; + + this->lock_ = lock; + this->destroy_lock_ = release_lock; + } + +} + +#if defined (ACE_HAS_EXPLICIT_STATIC_TEMPLATE_MEMBER_INSTANTIATION) +template ACE_Singleton * + ACE_Singleton::singleton_; +#endif /* ACE_HAS_EXPLICIT_STATIC_TEMPLATE_MEMBER_INSTANTIATION */ + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/UUID.h b/dep/ACE_wrappers/ace/UUID.h new file mode 100644 index 00000000000..4f3c39d0812 --- /dev/null +++ b/dep/ACE_wrappers/ace/UUID.h @@ -0,0 +1,239 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file UUID.h + * + * $Id: UUID.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Andrew T. Finnel + * @author Yamuna Krishnmaurthy + */ +//============================================================================= + +#ifndef ACE_UUID_H +#define ACE_UUID_H +#include /**/ "ace/pre.h" + +#include /**/ "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/SString.h" +#include "ace/Singleton.h" +#include "ace/Synch_Traits.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +namespace ACE_Utils +{ + /// Class to hold a MAC address + class ACE_Export UUID_Node + { + public: + + /// Constructor + UUID_Node (void); + + enum {NODE_ID_SIZE = 6}; + typedef u_char Node_ID[NODE_ID_SIZE]; + + Node_ID &node_ID (void); + void node_ID (Node_ID&); + + ///// Equality Operations + bool operator == (const UUID_Node& right) const; + bool operator != (const UUID_Node& right) const; + + ///// Relational Operations + //bool operator < (const UUID_Node& right) const; + + private: + Node_ID node_ID_; + }; + + /** + * @class ACE_UUID + * + * ACE_UUID represents a Universally Unique IDentifier (UUID) as + * described in (the expired) INTERNET-DRAFT specification entitled + * UUIDs and GUIDs. All instances of UUID are of the time-based + * variety. That is, the version number part of the timeHiAndVersion + * field is 1. + * + * The default constructor creates a nil UUID. + * + * UUIDs have value semantics. In addition, they may be compared for + * ordering and equality. + * + * Additionally in this implementation provisions have been made to include + * process and thread ids to make the UUIDs more unique. The variant 0xc0 + * has been added to facilitate this. + */ + class ACE_Export UUID + { + public: + + /// Constructor + UUID (void); + + /// Constructs a UUID from a string representation. + UUID (const ACE_CString& uuidString); + + UUID (const UUID &right); + + // Destructor + ~UUID (void); + + ACE_UINT32 time_low (void) const; + void time_low (ACE_UINT32); + + ACE_UINT16 time_mid (void) const; + void time_mid (ACE_UINT16); + + ACE_UINT16 time_hi_and_version (void) const; + void time_hi_and_version (ACE_UINT16); + + u_char clock_seq_hi_and_reserved (void) const; + void clock_seq_hi_and_reserved (u_char); + + u_char clock_seq_low (void) const; + void clock_seq_low (u_char); + + UUID_Node* node (void) const; + void node (UUID_Node*); + + ACE_CString* thr_id (void); + void thr_id (char*); + + ACE_CString* pid (void); + void pid (char*); + + /// Returns a string representation of the UUID + const ACE_CString* to_string (void); + + /// Set the value using a string + void from_string (const ACE_CString& uuid_string); + + static UUID NIL_UUID; + + /// Equality Operations + bool operator== (const UUID &right) const; + bool operator!= (const UUID &right) const; + + /// Relational Operations + //bool operator< (const UUID &right) const; + //bool operator> (const UUID &right) const; + //bool operator<= (const UUID &right) const; + //bool operator>= (const UUID &right) const; + + private: + void from_string_i (const ACE_CString& uuid_string); + + UUID& operator= (const UUID&); + + /// Data Members for Class Attributes + ACE_UINT32 time_low_; + ACE_UINT16 time_mid_; + ACE_UINT16 time_hi_and_version_; + u_char clock_seq_hi_and_reserved_; + u_char clock_seq_low_; + UUID_Node* node_; + bool node_release_; + ACE_CString thr_id_; + ACE_CString pid_; + + /// The string representation of the UUID. This is created and + /// updated only on demand. + ACE_CString *as_string_; + }; + + /** + * @class ACE_UUID_Generator + * + * Singleton class that generates UUIDs. + * + */ + class ACE_Export UUID_Generator + { + public: + + enum {ACE_UUID_CLOCK_SEQ_MASK = 0x3FFF}; + + UUID_Generator(); + ~UUID_Generator(); + + void init (void); + + /// Format timestamp, clockseq, and nodeID into an UUID of the + /// specified version and variant. For generating UUID's with + /// thread and process ids use variant=0xc0 + void generate_UUID (UUID&, ACE_UINT16 version=0x0001, u_char variant=0x80); + + /// Format timestamp, clockseq, and nodeID into a VI UUID. For + /// generating UUID's with thread and process ids use variant=0xc0 + UUID* generate_UUID (ACE_UINT16 version=0x0001, u_char variant=0x80); + + /// Type to represent UTC as a count of 100 nanosecond intervals + /// since 00:00:00.00, 15 October 1582. + typedef ACE_UINT64 UUID_Time; + + /// The locking strategy prevents multiple generators from accessing + /// the UUID_state at the same time. Get the locking strategy. + ACE_SYNCH_MUTEX* lock (void); + + /// Set a new locking strategy and return the old one. + void lock (ACE_SYNCH_MUTEX* lock, + bool release_lock); + + private: + + /// The system time when that last uuid was generated. + UUID_Time time_last_; + + /// Type to contain the UUID generator persistent state. This will + /// be kept in memory mapped shared memory + struct UUID_State + { + UUID_Time timestamp; + UUID_Node node; + ACE_UINT16 clock_sequence; + }; + + /// Obtain a UUID timestamp. Compensate for the fact that the time + /// obtained from getSystem time has a resolution less than 100ns. + void get_timestamp (UUID_Time& timestamp); + + /// Obtain a UUID timestamp and clock sequence. Compensate for the + /// fact that the time obtained from getSystem time has a + /// resolution less than 100ns. + void get_timestamp_and_clocksequence (UUID_Time& timestamp, + ACE_UINT16& clockSequence); + + /// Obtain the system time in UTC as a count of 100 nanosecond intervals + /// since 00:00:00.00, 15 October 1582 (the date of Gregorian reform to + /// the Christian calendar). + void get_systemtime( UUID_Time& timeNow); + + /// The UUID generator persistent state. + UUID_State uuid_state_; + + ACE_SYNCH_MUTEX* lock_; + bool destroy_lock_; + }; + + typedef ACE_Singleton UUID_GENERATOR; + +} + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +#include "ace/UUID.inl" +#endif /* __ACE_INLINE__ */ + +#include /**/ "ace/post.h" +#endif // ACE_UUID_H + diff --git a/dep/ACE_wrappers/ace/UUID.inl b/dep/ACE_wrappers/ace/UUID.inl new file mode 100644 index 00000000000..a60fb6ce17f --- /dev/null +++ b/dep/ACE_wrappers/ace/UUID.inl @@ -0,0 +1,200 @@ +// -*- C++ -*- +// +//$Id: UUID.inl 80826 2008-03-04 14:51:23Z wotte $ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +namespace ACE_Utils +{ + + /// Data Members for Class Attributes + ACE_INLINE ACE_UINT32 + UUID::time_low (void) const + { + return this->time_low_; + } + + ACE_INLINE void + UUID::time_low (ACE_UINT32 timelow) + { + this->time_low_ = timelow; + } + + ACE_INLINE ACE_UINT16 + UUID::time_mid (void) const + { + return this->time_mid_; + } + + ACE_INLINE void + UUID::time_mid (ACE_UINT16 time_mid) + { + this->time_mid_ = time_mid; + } + + ACE_INLINE ACE_UINT16 + UUID::time_hi_and_version (void) const + { + return this->time_hi_and_version_; + } + + ACE_INLINE void + UUID::time_hi_and_version (ACE_UINT16 time_hi_and_version) + { + this->time_hi_and_version_ = time_hi_and_version; + } + + ACE_INLINE u_char + UUID::clock_seq_hi_and_reserved (void) const + { + return this->clock_seq_hi_and_reserved_; + } + + ACE_INLINE void + UUID::clock_seq_hi_and_reserved (u_char clock_seq_hi_and_reserved) + { + this->clock_seq_hi_and_reserved_ = clock_seq_hi_and_reserved; + } + + ACE_INLINE u_char + UUID::clock_seq_low (void) const + { + return this->clock_seq_low_; + } + + ACE_INLINE void + UUID::clock_seq_low (u_char clock_seq_low) + { + this->clock_seq_low_ = clock_seq_low; + } + + ACE_INLINE UUID_Node* + UUID::node (void) const + { + return this->node_; + } + + ACE_INLINE void + UUID::node (UUID_Node* node) + { + if (node_release_) + delete node_; + + this->node_ = node; + node_release_ = false; + } + + ACE_INLINE ACE_CString* + UUID::thr_id (void) + { + return &this->thr_id_; + } + + ACE_INLINE void + UUID::thr_id (char* thr_id) + { + this->thr_id_ = thr_id; + } + + ACE_INLINE ACE_CString* + UUID::pid (void) + { + return &this->pid_; + } + + ACE_INLINE void + UUID::pid (char* pid) + { + this->pid_ = pid; + } + + ACE_INLINE void + UUID::from_string (const ACE_CString& uuidString) + { + this->from_string_i (uuidString); + } + + ACE_INLINE bool + UUID::operator == (const UUID &right) const + { + if ((this->time_low_ != right.time_low ()) || + (this->time_mid_ != right.time_mid ()) || + (this->time_hi_and_version_ != right.time_hi_and_version ()) || + (this->clock_seq_hi_and_reserved_ != right.clock_seq_hi_and_reserved ()) || + (this->clock_seq_low_ != right.clock_seq_low ()) || + (*this->node_ != *right.node ())) + return false; + + return true; + } + + ACE_INLINE bool + UUID::operator != (const UUID &right) const + { + return !(*this == right); + } + +// ACE_INLINE bool +//UUID::operator < (const UUID &rt) const +// { +// UUID right (rt); +// if ((timeLow_ < right.timeLow ()) || +// (timeMid_ < right.timeMid ()) || +// (timeHiAndVersion_ < right.timeHiAndVersion ()) || +// (clockSeqHiAndReserved_ < right.clockSeqHiAndReserved ()) || +// (clockSeqLow_ < right.clockSeqLow ()) || +// (node_ < right.node ())) +// { +// return true; +// } +// +// return false; +// } +// +// ACE_INLINE bool +// UUID::operator > (const UUID &right) const +// { +// return right < *this; +// } +// +// ACE_INLINE bool +// UUID::operator <= (const UUID &right) const +// { +// return !(*this > right); +// } +// +// ACE_INLINE bool +// UUID::operator >= (const UUID &right) const +// { +// return !(*this < right); +// } +// + ACE_INLINE bool + UUID_Node::operator == (const UUID_Node& rt) const + { + for (size_t i = 0; i < NODE_ID_SIZE; ++i) + if (node_ID_ [i] != rt.node_ID_ [i]) + return false; + + return true; + } + + ACE_INLINE bool + UUID_Node::operator != (const UUID_Node& right) const + { + return !(*this == right); + } + +// ACE_INLINE bool +// UUID_node::operator < (const UUID_node& rt) const +// { +// UUID_node right = rt; +// for (size_t i = 0; i < NODE_ID_SIZE; ++i) +// if (nodeID_ [i] < right.nodeID ()[i]) +// return true; +// +// return false; +// } +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Unbounded_Queue.cpp b/dep/ACE_wrappers/ace/Unbounded_Queue.cpp new file mode 100644 index 00000000000..aaaddc6a98d --- /dev/null +++ b/dep/ACE_wrappers/ace/Unbounded_Queue.cpp @@ -0,0 +1,434 @@ +// $Id: Unbounded_Queue.cpp 80826 2008-03-04 14:51:23Z wotte $ + +#ifndef ACE_UNBOUNDED_QUEUE_CPP +#define ACE_UNBOUNDED_QUEUE_CPP + +#include "ace/Unbounded_Queue.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#if !defined (__ACE_INLINE__) +#include "ace/Unbounded_Queue.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/Malloc_Base.h" +#include "ace/Log_Msg.h" +#include "ace/os_include/os_errno.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_ALLOC_HOOK_DEFINE(ACE_Unbounded_Queue) + +template +ACE_Unbounded_Queue::ACE_Unbounded_Queue (ACE_Allocator *alloc) + : head_ (0), + cur_size_ (0), + allocator_ (alloc) +{ + // ACE_TRACE ("ACE_Unbounded_Queue::ACE_Unbounded_Queue (void)"); + + if (this->allocator_ == 0) + this->allocator_ = ACE_Allocator::instance (); + + ACE_NEW_MALLOC (this->head_, + (ACE_Node *) this->allocator_->malloc (sizeof (ACE_Node)), + ACE_Node); + // Make the list circular by pointing it back to itself. + this->head_->next_ = this->head_; +} + +template +ACE_Unbounded_Queue::ACE_Unbounded_Queue (const ACE_Unbounded_Queue &us) + : head_ (0), + cur_size_ (0), + allocator_ (us.allocator_) +{ + // ACE_TRACE ("ACE_Unbounded_Queue::ACE_Unbounded_Queue"); + + if (this->allocator_ == 0) + this->allocator_ = ACE_Allocator::instance (); + + ACE_NEW_MALLOC (this->head_, + (ACE_Node *) this->allocator_->malloc (sizeof (ACE_Node)), + ACE_Node); + this->head_->next_ = this->head_; + this->copy_nodes (us); +} + +template void +ACE_Unbounded_Queue::operator= (const ACE_Unbounded_Queue &us) +{ + // ACE_TRACE ("ACE_Unbounded_Queue::operator="); + + if (this != &us) + { + this->delete_nodes (); + this->copy_nodes (us); + } +} + +template ACE_Unbounded_Queue_Iterator +ACE_Unbounded_Queue::begin (void) +{ + // ACE_TRACE ("ACE_Unbounded_Queue::begin"); + return ACE_Unbounded_Queue_Iterator (*this); +} + +template ACE_Unbounded_Queue_Iterator +ACE_Unbounded_Queue::end (void) +{ + // ACE_TRACE ("ACE_Unbounded_Queue::end"); + return ACE_Unbounded_Queue_Iterator (*this, 1); +} + +template void +ACE_Unbounded_Queue::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + // ACE_TRACE ("ACE_Unbounded_Queue::dump"); + + ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nhead_ = %u"), this->head_)); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nhead_->next_ = %u"), this->head_->next_)); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\ncur_size_ = %d\n"), this->cur_size_)); + + T *item = 0; +#if !defined (ACE_NLOGGING) + size_t count = 1; +#endif /* ! ACE_NLOGGING */ + + for (ACE_Unbounded_Queue_Iterator iter (*(ACE_Unbounded_Queue *) this); + iter.next (item) != 0; + iter.advance ()) + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("count = %d\n"), count++)); + + ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); +#endif /* ACE_HAS_DUMP */ +} + +template void +ACE_Unbounded_Queue::copy_nodes (const ACE_Unbounded_Queue &us) +{ + for (ACE_Node *curr = us.head_->next_; + curr != us.head_; + curr = curr->next_) + if (this->enqueue_tail (curr->item_) == -1) + // @@ What's the right thing to do here? + this->delete_nodes (); +} + +template void +ACE_Unbounded_Queue::delete_nodes (void) +{ + for (ACE_Node *curr = this->head_->next_; + // Keep looking until we've hit the dummy node. + curr != this->head_; + ) + { + ACE_Node *temp = curr; + curr = curr->next_; + + ACE_DES_FREE_TEMPLATE (temp, + this->allocator_->free, + ACE_Node, + ); + --this->cur_size_; + // @@ Doesnt make sense to have this check since + // this will always be true. + // ACE_ASSERT (this->cur_size_ >= 0); + } + + // Reset the list to be a circular list with just a dummy node. + this->head_->next_ = this->head_; +} + +template +ACE_Unbounded_Queue::~ACE_Unbounded_Queue (void) +{ + // ACE_TRACE ("ACE_Unbounded_Queue::~ACE_Unbounded_Queue (void)"); + + this->delete_nodes (); + ACE_DES_FREE_TEMPLATE (head_, + this->allocator_->free, + ACE_Node, + ); + this->head_ = 0; +} + +template int +ACE_Unbounded_Queue::enqueue_head (const T &new_item) +{ + // ACE_TRACE ("ACE_Unbounded_Queue::enqueue_head"); + + ACE_Node *temp = 0; + + // Create a new node that points to the original head. + ACE_NEW_MALLOC_RETURN (temp, + static_cast *> (this->allocator_->malloc (sizeof (ACE_Node))), + ACE_Node (new_item, this->head_->next_), + -1); + // Link this pointer into the front of the list. Note that the + // "real" head of the queue is next_>, whereas is + // just a pointer to the dummy node. + this->head_->next_ = temp; + + ++this->cur_size_; + return 0; +} + +template int +ACE_Unbounded_Queue::enqueue_tail (const T &new_item) +{ + // ACE_TRACE ("ACE_Unbounded_Queue::enqueue_tail"); + + // Insert into the old dummy node location. Note that this + // isn't actually the "head" item in the queue, it's a dummy node at + // the "tail" of the queue... + this->head_->item_ = new_item; + + ACE_Node *temp = 0; + + // Create a new dummy node. + ACE_NEW_MALLOC_RETURN (temp, + static_cast *> (this->allocator_->malloc (sizeof (ACE_Node))), + ACE_Node (this->head_->next_), + -1); + // Link this dummy pointer into the list. + this->head_->next_ = temp; + + // Point the head to the new dummy node. + this->head_ = temp; + + ++this->cur_size_; + return 0; +} + +template int +ACE_Unbounded_Queue::dequeue_head (T &item) +{ + // ACE_TRACE ("ACE_Unbounded_Queue::dequeue_head"); + + // Check for empty queue. + if (this->is_empty ()) + return -1; + + ACE_Node *temp = this->head_->next_; + + item = temp->item_; + this->head_->next_ = temp->next_; + ACE_DES_FREE_TEMPLATE (temp, + this->allocator_->free, + ACE_Node, + ); + --this->cur_size_; + return 0; +} + +template void +ACE_Unbounded_Queue::reset (void) +{ + ACE_TRACE ("reset"); + + this->delete_nodes (); +} + +template int +ACE_Unbounded_Queue::get (T *&item, size_t slot) const +{ + // ACE_TRACE ("ACE_Unbounded_Queue::get"); + + ACE_Node *curr = this->head_->next_; + + size_t i; + + for (i = 0; i < this->cur_size_; i++) + { + if (i == slot) + break; + + curr = curr->next_; + } + + if (i < this->cur_size_) + { + item = &curr->item_; + return 0; + } + else + return -1; +} + +template int +ACE_Unbounded_Queue::set (const T &item, + size_t slot) +{ + // ACE_TRACE ("ACE_Unbounded_Queue::set"); + + ACE_Node *curr = this->head_->next_; + + size_t i; + + for (i = 0; + i < slot && i < this->cur_size_; + ++i) + curr = curr->next_; + + if (i < this->cur_size_) + { + // We're in range, so everything's cool. + curr->item_ = item; + return 0; + } + else + { + // We need to expand the list. + + // A common case will be increasing the set size by 1. + // Therefore, we'll optimize for this case. + if (i == slot) + { + // Try to expand the size of the set by 1. + if (this->enqueue_tail (item) == -1) + return -1; + else + return 0; + } + else + { + T const dummy = T (); + + // We need to expand the list by multiple (dummy) items. + for (; i < slot; ++i) + { + // This head points to the existing dummy node, which is + // about to be overwritten when we add the new dummy + // node. + curr = this->head_; + + // Try to expand the size of the set by 1, but don't + // store anything in the dummy node (yet). + if (this->enqueue_tail (dummy) == -1) + return -1; + } + + curr->item_ = item; + return 0; + } + } +} + +// **************************************************************** + +template void +ACE_Unbounded_Queue_Const_Iterator::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + // ACE_TRACE ("ACE_Unbounded_Queue_Const_Iterator::dump"); +#endif /* ACE_HAS_DUMP */ +} + +template +ACE_Unbounded_Queue_Const_Iterator::ACE_Unbounded_Queue_Const_Iterator (const ACE_Unbounded_Queue &q, int end) + : current_ (end == 0 ? q.head_->next_ : q.head_ ), + queue_ (q) +{ + // ACE_TRACE ("ACE_Unbounded_Queue_Const_Iterator::ACE_Unbounded_Queue_Const_Iterator"); +} + +template int +ACE_Unbounded_Queue_Const_Iterator::advance (void) +{ + // ACE_TRACE ("ACE_Unbounded_Queue_Const_Iterator::advance"); + this->current_ = this->current_->next_; + return this->current_ != this->queue_.head_; +} + +template int +ACE_Unbounded_Queue_Const_Iterator::first (void) +{ + // ACE_TRACE ("ACE_Unbounded_Queue_Const_Iterator::first"); + this->current_ = this->queue_.head_->next_; + return this->current_ != this->queue_.head_; +} + +template int +ACE_Unbounded_Queue_Const_Iterator::done (void) const +{ + ACE_TRACE ("ACE_Unbounded_Queue_Const_Iterator::done"); + + return this->current_ == this->queue_.head_; +} + +template int +ACE_Unbounded_Queue_Const_Iterator::next (T *&item) +{ + // ACE_TRACE ("ACE_Unbounded_Queue_Const_Iterator::next"); + if (this->current_ == this->queue_.head_) + return 0; + else + { + item = &this->current_->item_; + return 1; + } +} + +// **************************************************************** + +template void +ACE_Unbounded_Queue_Iterator::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + // ACE_TRACE ("ACE_Unbounded_Queue_Iterator::dump"); +#endif /* ACE_HAS_DUMP */ +} + +template +ACE_Unbounded_Queue_Iterator::ACE_Unbounded_Queue_Iterator (ACE_Unbounded_Queue &q, int end) + : current_ (end == 0 ? q.head_->next_ : q.head_ ), + queue_ (q) +{ + // ACE_TRACE ("ACE_Unbounded_Queue_Iterator::ACE_Unbounded_Queue_Iterator"); +} + +template int +ACE_Unbounded_Queue_Iterator::advance (void) +{ + // ACE_TRACE ("ACE_Unbounded_Queue_Iterator::advance"); + this->current_ = this->current_->next_; + return this->current_ != this->queue_.head_; +} + +template int +ACE_Unbounded_Queue_Iterator::first (void) +{ + // ACE_TRACE ("ACE_Unbounded_Queue_Iterator::first"); + this->current_ = this->queue_.head_->next_; + return this->current_ != this->queue_.head_; +} + +template int +ACE_Unbounded_Queue_Iterator::done (void) const +{ + ACE_TRACE ("ACE_Unbounded_Queue_Iterator::done"); + + return this->current_ == this->queue_.head_; +} + +template int +ACE_Unbounded_Queue_Iterator::next (T *&item) +{ + // ACE_TRACE ("ACE_Unbounded_Queue_Iterator::next"); + if (this->current_ == this->queue_.head_) + return 0; + else + { + item = &this->current_->item_; + return 1; + } +} + +ACE_END_VERSIONED_NAMESPACE_DECL + +#endif /* ACE_UNBOUNDED_QUEUE_CPP */ diff --git a/dep/ACE_wrappers/ace/Unbounded_Queue.h b/dep/ACE_wrappers/ace/Unbounded_Queue.h new file mode 100644 index 00000000000..b6e1c4eea76 --- /dev/null +++ b/dep/ACE_wrappers/ace/Unbounded_Queue.h @@ -0,0 +1,297 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Unbounded_Queue.h + * + * $Id: Unbounded_Queue.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Douglas C. Schmidt + */ +//============================================================================= + +#ifndef ACE_UNBOUNDED_QUEUE_H +#define ACE_UNBOUNDED_QUEUE_H +#include /**/ "ace/pre.h" + +#include "ace/Node.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/os_include/os_stddef.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +class ACE_Allocator; + +template +class ACE_Unbounded_Queue; + +/** + * @class ACE_Unbounded_Queue_Iterator + * + * @brief Implement an iterator over an unbounded queue. + */ +template +class ACE_Unbounded_Queue_Iterator +{ +public: + // = Initialization method. + ACE_Unbounded_Queue_Iterator (ACE_Unbounded_Queue &q, int end = 0); + + // = Iteration methods. + + /// Pass back the @a next_item that hasn't been seen in the queue. + /// Returns 0 when all items have been seen, else 1. + int next (T *&next_item); + + /// Move forward by one element in the set. Returns 0 when all the + /// items in the queue have been seen, else 1. + int advance (void); + + /// Move to the first element in the queue. Returns 0 if the + /// queue is empty, else 1. + int first (void); + + /// Returns 1 when all items have been seen, else 0. + int done (void) const; + + /// Dump the state of an object. + void dump (void) const; + + /// Declare the dynamic allocation hooks. + ACE_ALLOC_HOOK_DECLARE; + +private: + /// Pointer to the current node in the iteration. + ACE_Node *current_; + + /// Pointer to the queue we're iterating over. + ACE_Unbounded_Queue &queue_; +}; + +/** + * @class ACE_Unbounded_Queue_Const_Iterator + * + * @brief Implement an iterator over an const unbounded queue. + */ +template +class ACE_Unbounded_Queue_Const_Iterator +{ +public: + // = Initialization method. + ACE_Unbounded_Queue_Const_Iterator (const ACE_Unbounded_Queue &q, int end = 0); + + // = Iteration methods. + + /// Pass back the @a next_item that hasn't been seen in the queue. + /// Returns 0 when all items have been seen, else 1. + int next (T *&next_item); + + /// Move forward by one element in the set. Returns 0 when all the + /// items in the queue have been seen, else 1. + int advance (void); + + /// Move to the first element in the queue. Returns 0 if the + /// queue is empty, else 1. + int first (void); + + /// Returns 1 when all items have been seen, else 0. + int done (void) const; + + /// Dump the state of an object. + void dump (void) const; + + /// Declare the dynamic allocation hooks. + ACE_ALLOC_HOOK_DECLARE; + +private: + /// Pointer to the current node in the iteration. + ACE_Node *current_; + + /// Pointer to the queue we're iterating over. + const ACE_Unbounded_Queue &queue_; +}; + +/** + * @class ACE_Unbounded_Queue + * + * @brief A Queue of "infinite" length. + * + * This implementation of an unbounded queue uses a circular + * linked list with a dummy node. + * + * Requirements and Performance Characteristics + * - Internal Structure + * Circular linked list + * - Duplicates allowed? + * Yes + * - Random access allowed? + * No + * - Search speed + * N/A + * - Insert/replace speed + * N/A + * - Iterator still valid after change to container? + * Yes + * - Frees memory for removed elements? + * Yes + * - Items inserted by + * Value + * - Requirements for contained type + * -# Default constructor + * -# Copy constructor + * -# operator= + * + */ +template +class ACE_Unbounded_Queue +{ +public: + friend class ACE_Unbounded_Queue_Iterator; + friend class ACE_Unbounded_Queue_Const_Iterator; + + // Trait definition. + typedef ACE_Unbounded_Queue_Iterator ITERATOR; + typedef ACE_Unbounded_Queue_Const_Iterator CONST_ITERATOR; + + // = Initialization and termination methods. + /// Construction. Use user specified allocation strategy + /// if specified. + /** + * Initialize an empty queue using the strategy provided. + */ + ACE_Unbounded_Queue (ACE_Allocator *alloc = 0); + + /// Copy constructor. + /** + * Initialize the queue to be a copy of the provided queue. + */ + ACE_Unbounded_Queue (const ACE_Unbounded_Queue &); + + /// Assignment operator. + /** + * Perform a deep copy of rhs. + */ + void operator= (const ACE_Unbounded_Queue &); + + /// Destructor. + /** + * Clean up the memory for the queue. + */ + ~ACE_Unbounded_Queue (void); + + // = Check boundary conditions. + + /// Returns 1 if the container is empty, otherwise returns 0. + /** + * Constant time check to see if the queue is empty. + */ + int is_empty (void) const; + + /// Returns 0. + /** + * The queue cannot be full, so it always returns 0. + */ + int is_full (void) const; + + // = Classic queue operations. + + /// Adds @a new_item to the tail of the queue. Returns 0 on success, + /// -1 on failure. + /** + * Insert an item at the end of the queue. + */ + int enqueue_tail (const T &new_item); + + /// Adds @a new_item to the head of the queue. Returns 0 on success, + /// -1 on failure. + /** + * Insert an item at the head of the queue. + */ + int enqueue_head (const T &new_item); + + /// Removes and returns the first @a item on the queue. Returns 0 on + /// success, -1 if the queue was empty. + /** + * Remove an item from the head of the queue. + */ + int dequeue_head (T &item); + + // = Additional utility methods. + + /// Reset the ACE_Unbounded_Queue to be empty and release all its + /// dynamically allocated resources. + /** + * Delete the queue nodes. + */ + void reset (void); + + /// Get the @a slot th element in the set. Returns -1 if the element + /// isn't in the range {0..#cur_size_ - 1}, else 0. + /** + * Find the item in the queue between 0 and the provided index of the + * queue. + */ + int get (T *&item, size_t slot = 0) const; + + /// Set the @a slot th element of the queue to @a item. + /** + * Set the @a slot th element in the set. Will pad out the set with + * empty nodes if @a slot is beyond the range {0..#cur_size_ - 1}. + * Returns -1 on failure, 0 if @a slot isn't initially in range, and + * 0 otherwise. + */ + int set (const T &item, size_t slot); + + /// The number of items in the queue. + /** + * Return the size of the queue. + */ + size_t size (void) const; + + /// Dump the state of an object. + void dump (void) const; + + // = STL-styled unidirectional iterator factory. + ACE_Unbounded_Queue_Iterator begin (void); + ACE_Unbounded_Queue_Iterator end (void); + + /// Declare the dynamic allocation hooks. + ACE_ALLOC_HOOK_DECLARE; + +protected: + /// Delete all the nodes in the queue. + void delete_nodes (void); + + /// Copy nodes into this queue. + void copy_nodes (const ACE_Unbounded_Queue &); + + /// Pointer to the dummy node in the circular linked Queue. + ACE_Node *head_; + + /// Current size of the queue. + size_t cur_size_; + + /// Allocation Strategy of the queue. + ACE_Allocator *allocator_; +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +#include "ace/Unbounded_Queue.inl" +#endif /* __ACE_INLINE__ */ + +#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) +#include "ace/Unbounded_Queue.cpp" +#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ + +#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) +#pragma implementation ("Unbounded_Queue.cpp") +#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ + +#include /**/ "ace/post.h" +#endif /* ACE_UNBOUNDED_QUEUE_H */ diff --git a/dep/ACE_wrappers/ace/Unbounded_Queue.inl b/dep/ACE_wrappers/ace/Unbounded_Queue.inl new file mode 100644 index 00000000000..0758412b984 --- /dev/null +++ b/dep/ACE_wrappers/ace/Unbounded_Queue.inl @@ -0,0 +1,27 @@ +// -*- C++ -*- +// +// $Id: Unbounded_Queue.inl 80826 2008-03-04 14:51:23Z wotte $ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +template ACE_INLINE size_t +ACE_Unbounded_Queue::size (void) const +{ + return this->cur_size_; +} + +template ACE_INLINE int +ACE_Unbounded_Queue::is_empty (void) const +{ + // ACE_TRACE ("ACE_Unbounded_Queue::is_empty"); + return this->head_ == this->head_->next_; +} + +template ACE_INLINE int +ACE_Unbounded_Queue::is_full (void) const +{ + // ACE_TRACE ("ACE_Unbounded_Queue::is_full"); + return 0; // We should implement a "node of last resort for this..." +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Unbounded_Set.cpp b/dep/ACE_wrappers/ace/Unbounded_Set.cpp new file mode 100644 index 00000000000..c54e3fcfa2f --- /dev/null +++ b/dep/ACE_wrappers/ace/Unbounded_Set.cpp @@ -0,0 +1,18 @@ +// $Id: Unbounded_Set.cpp 81624 2008-05-06 17:14:57Z wotte $ + +#ifndef ACE_UNBOUNDED_SET_CPP +#define ACE_UNBOUNDED_SET_CPP + +#include "ace/Unbounded_Set.h" +#include "ace/Malloc_Base.h" +#include "ace/Log_Msg.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#if !defined (__ACE_INLINE__) +#include "ace/Unbounded_Set.inl" +#endif /* __ACE_INLINE__ */ + +#endif /* ACE_UNBOUNDED_SET_CPP */ diff --git a/dep/ACE_wrappers/ace/Unbounded_Set.h b/dep/ACE_wrappers/ace/Unbounded_Set.h new file mode 100644 index 00000000000..a75eac18fc3 --- /dev/null +++ b/dep/ACE_wrappers/ace/Unbounded_Set.h @@ -0,0 +1,103 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Unbounded_Set.h + * + * $Id: Unbounded_Set.h 81642 2008-05-07 19:30:35Z shuston $ + * + * @author Douglas C. Schmidt + */ +//============================================================================= + +#ifndef ACE_UNBOUNDED_SET_H +#define ACE_UNBOUNDED_SET_H +#include /**/ "ace/pre.h" + +#include "ace/Unbounded_Set_Ex.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +class ACE_Allocator; + +/** + * @struct ACE_Unbounded_Set_Default_Comparator + * @brief Simple comparator that evaluates equality using == operator. + */ +template +struct ACE_Unbounded_Set_Default_Comparator +{ + bool operator() (const T&lhs, const T&rhs) const; +}; + +template +class ACE_Unbounded_Set; + +/** + * @class ACE_Unbounded_Set_Iterator + * @brief Compatibility wrapper for ACE_Unbounded_Set_Ex_Iterator. + */ +template +class ACE_Unbounded_Set_Iterator : public + ACE_Unbounded_Set_Ex_Iterator > +{ +public: + typedef ACE_Unbounded_Set_Ex_Iterator > base_type; + + // = Initialization method. + ACE_Unbounded_Set_Iterator (ACE_Unbounded_Set &s, bool end = false); + + ACE_Unbounded_Set_Iterator (const base_type &s); +}; + +/** + * @class ACE_Unbounded_Set_Const_Iterator + * @brief Compatibility wrapper for ACE_Unbounded_Set_Ex_Const_Iterator. + */ +template +class ACE_Unbounded_Set_Const_Iterator : public + ACE_Unbounded_Set_Ex_Const_Iterator > +{ +public: + + typedef ACE_Unbounded_Set_Ex_Const_Iterator > base_type; + + // = Initialization method. + ACE_Unbounded_Set_Const_Iterator (const ACE_Unbounded_Set &s, + bool end = false); + + ACE_Unbounded_Set_Const_Iterator (const base_type &s); +}; + +/** + * @class ACE_Unbounded_Set + * @brief Compatibility wrapper for ACE_Unbounded_Set_Ex. + */ +template +class ACE_Unbounded_Set : public + ACE_Unbounded_Set_Ex > +{ +public: + ACE_Unbounded_Set (ACE_Allocator *alloc = 0); +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +#include "ace/Unbounded_Set.inl" +#endif /* __ACE_INLINE__ */ + +#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) +#include "ace/Unbounded_Set.cpp" +#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ + +#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) +#pragma implementation ("Unbounded_Set.cpp") +#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ + +#include /**/ "ace/post.h" +#endif /* ACE_UNBOUNDED_SET_H */ diff --git a/dep/ACE_wrappers/ace/Unbounded_Set.inl b/dep/ACE_wrappers/ace/Unbounded_Set.inl new file mode 100644 index 00000000000..365b025c0be --- /dev/null +++ b/dep/ACE_wrappers/ace/Unbounded_Set.inl @@ -0,0 +1,49 @@ +// -*- C++ -*- +// +// $Id: Unbounded_Set.inl 81642 2008-05-07 19:30:35Z shuston $ + +#include "ace/Global_Macros.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +template ACE_INLINE bool +ACE_Unbounded_Set_Default_Comparator::operator () (const T &lhs, const T &rhs) const +{ + return lhs == rhs; +} + +template +ACE_Unbounded_Set_Iterator::ACE_Unbounded_Set_Iterator (ACE_Unbounded_Set &s, + bool end) + : base_type (s, end) +{ +} + +template +ACE_Unbounded_Set_Iterator::ACE_Unbounded_Set_Iterator (const base_type & s) + : base_type (s) +{ +} + +template +ACE_Unbounded_Set_Const_Iterator:: +ACE_Unbounded_Set_Const_Iterator (const ACE_Unbounded_Set &s, + bool end) + : base_type (s, end) +{ +} + +template +ACE_Unbounded_Set_Const_Iterator::ACE_Unbounded_Set_Const_Iterator (const base_type & s) + : base_type (s) +{ +} + +template +ACE_Unbounded_Set::ACE_Unbounded_Set (ACE_Allocator *alloc) + : ACE_Unbounded_Set_Ex > (alloc) +{ +} + + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Unbounded_Set_Ex.cpp b/dep/ACE_wrappers/ace/Unbounded_Set_Ex.cpp new file mode 100644 index 00000000000..c5cd9e27b21 --- /dev/null +++ b/dep/ACE_wrappers/ace/Unbounded_Set_Ex.cpp @@ -0,0 +1,499 @@ +// $Id: Unbounded_Set_Ex.cpp 81702 2008-05-15 10:18:07Z johnnyw $ + +#ifndef ACE_UNBOUNDED_SET_EX_CPP +#define ACE_UNBOUNDED_SET_EX_CPP + +#include "ace/Unbounded_Set.h" +#include "ace/Malloc_Base.h" +#include "ace/Log_Msg.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#if !defined (__ACE_INLINE__) +#include "ace/Unbounded_Set_Ex.inl" +#endif /* __ACE_INLINE__ */ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_ALLOC_HOOK_DEFINE(ACE_Unbounded_Set_Ex) + +template size_t +ACE_Unbounded_Set_Ex::size (void) const +{ + // ACE_TRACE ("ACE_Unbounded_Set_Ex::size"); + return this->cur_size_; +} + +template int +ACE_Unbounded_Set_Ex::insert_tail (const T &item) +{ + // ACE_TRACE ("ACE_Unbounded_Set_Ex::insert_tail"); + NODE *temp = 0; + + // Insert into the old dummy node location. + this->head_->item_ = item; + + // Create a new dummy node. + ACE_NEW_MALLOC_RETURN (temp, + static_cast (this->allocator_->malloc (sizeof (NODE))), + NODE (this->head_->next_), + -1); + // Link this pointer into the list. + this->head_->next_ = temp; + + // Point the head to the new dummy node. + this->head_ = temp; + + ++this->cur_size_; + return 0; +} + +template void +ACE_Unbounded_Set_Ex::reset (void) +{ + ACE_TRACE ("reset"); + + this->delete_nodes (); +} + +template void +ACE_Unbounded_Set_Ex::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + ACE_TRACE ("ACE_Unbounded_Set_Ex::dump"); + + ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nhead_ = %u"), this->head_)); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nhead_->next_ = %u"), this->head_->next_)); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\ncur_size_ = %d\n"), this->cur_size_)); + + T *item = 0; +#if !defined (ACE_NLOGGING) + size_t count = 1; +#endif /* ! ACE_NLOGGING */ + + const_iterator const the_end = this->end (); + for (const_iterator i (this->begin ()); + i != end; + ++i) + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("count = %u\n"), count++)); + + ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); +#endif /* ACE_HAS_DUMP */ +} + +template void +ACE_Unbounded_Set_Ex::copy_nodes (const ACE_Unbounded_Set_Ex &us) +{ + for (NODE *curr = us.head_->next_; + curr != us.head_; + curr = curr->next_) + this->insert_tail (curr->item_); +} + +template void +ACE_Unbounded_Set_Ex::delete_nodes (void) +{ + NODE *curr = this->head_->next_; + + // Keep looking until we've hit the dummy node. + + while (curr != this->head_) + { + NODE *temp = curr; + curr = curr->next_; + ACE_DES_FREE_TEMPLATE2 (temp, + this->allocator_->free, + ACE_Node, + T, C); + --this->cur_size_; + } + + // Reset the list to be a circular list with just a dummy node. + this->head_->next_ = this->head_; +} + +template +ACE_Unbounded_Set_Ex::~ACE_Unbounded_Set_Ex (void) +{ + // ACE_TRACE ("ACE_Unbounded_Set_Ex::~ACE_Unbounded_Set_Ex"); + + this->delete_nodes (); + + // Delete the dummy node. + ACE_DES_FREE_TEMPLATE2 (head_, + this->allocator_->free, + ACE_Node, + T, C); + this->head_ = 0; +} + +template +ACE_Unbounded_Set_Ex::ACE_Unbounded_Set_Ex (ACE_Allocator *alloc) + : head_ (0), + cur_size_ (0), + allocator_ (alloc) +{ + // ACE_TRACE ("ACE_Unbounded_Set_Ex::ACE_Unbounded_Set_Ex"); + + if (this->allocator_ == 0) + this->allocator_ = ACE_Allocator::instance (); + + ACE_NEW_MALLOC (this->head_, + (NODE*) this->allocator_->malloc (sizeof (NODE)), + NODE); + // Make the list circular by pointing it back to itself. + this->head_->next_ = this->head_; +} + +template +ACE_Unbounded_Set_Ex::ACE_Unbounded_Set_Ex (const C &comp, + ACE_Allocator *alloc) + : head_ (0), + cur_size_ (0), + allocator_ (alloc), + comp_ (comp) +{ + // ACE_TRACE ("ACE_Unbounded_Set_Ex::ACE_Unbounded_Set_Ex"); + + if (this->allocator_ == 0) + this->allocator_ = ACE_Allocator::instance (); + + ACE_NEW_MALLOC (this->head_, + (NODE*) this->allocator_->malloc (sizeof (NODE)), + NODE); + // Make the list circular by pointing it back to itself. + this->head_->next_ = this->head_; +} + +template +ACE_Unbounded_Set_Ex::ACE_Unbounded_Set_Ex (const ACE_Unbounded_Set_Ex &us) + : head_ (0), + cur_size_ (0), + allocator_ (us.allocator_), + comp_ (us.comp_) +{ + ACE_TRACE ("ACE_Unbounded_Set_Ex::ACE_Unbounded_Set_Ex"); + + if (this->allocator_ == 0) + this->allocator_ = ACE_Allocator::instance (); + + ACE_NEW_MALLOC (this->head_, + (NODE*) this->allocator_->malloc (sizeof (NODE)), + NODE); + this->head_->next_ = this->head_; + this->copy_nodes (us); +} + +template ACE_Unbounded_Set_Ex & +ACE_Unbounded_Set_Ex::operator= (const ACE_Unbounded_Set_Ex &us) +{ + ACE_TRACE ("ACE_Unbounded_Set_Ex::operator="); + + if (this != &us) + { + this->delete_nodes (); + this->copy_nodes (us); + } + + return *this; +} + +template int +ACE_Unbounded_Set_Ex::find (const T &item) const +{ + // ACE_TRACE ("ACE_Unbounded_Set_Ex::find"); + const_iterator const the_end = this->end (); + for (const_iterator i = this->begin (); i != the_end; ++i) + if (this->comp_(*i, item)) + return 0; + + return -1; +} + +template int +ACE_Unbounded_Set_Ex::insert (const T &item) +{ + // ACE_TRACE ("ACE_Unbounded_Set_Ex::insert"); + if (this->find (item) == 0) + return 1; + else + return this->insert_tail (item); +} + +template int +ACE_Unbounded_Set_Ex::remove (const T &item) +{ + // ACE_TRACE ("ACE_Unbounded_Set_Ex::remove"); + + // Insert the item to be founded into the dummy node. + this->head_->item_ = item; + + NODE *curr = this->head_; + + while (!(this->comp_ (curr->next_->item_, item))) + curr = curr->next_; + + if (curr->next_ == this->head_) + return -1; // Item was not found. + else + { + NODE *temp = curr->next_; + // Skip over the node that we're deleting. + curr->next_ = temp->next_; + --this->cur_size_; + ACE_DES_FREE_TEMPLATE2 (temp, + this->allocator_->free, + ACE_Node, + T, C); + return 0; + } +} + +template typename ACE_Unbounded_Set_Ex::iterator +ACE_Unbounded_Set_Ex::begin (void) +{ + // ACE_TRACE ("ACE_Unbounded_Set_Ex::begin"); + return iterator (*this); +} + +template typename ACE_Unbounded_Set_Ex::iterator +ACE_Unbounded_Set_Ex::end (void) +{ + // ACE_TRACE ("ACE_Unbounded_Set_Ex::end"); + return iterator (*this, 1); +} + +template typename ACE_Unbounded_Set_Ex::const_iterator +ACE_Unbounded_Set_Ex::begin (void) const +{ + // ACE_TRACE ("ACE_Unbounded_Set_Ex::begin"); + return const_iterator (*this); +} + +template typename ACE_Unbounded_Set_Ex::const_iterator +ACE_Unbounded_Set_Ex::end (void) const +{ + // ACE_TRACE ("ACE_Unbounded_Set_Ex::end"); + return const_iterator (*this, 1); +} + +ACE_ALLOC_HOOK_DEFINE(ACE_Unbounded_Set_Ex_Iterator) + +template void +ACE_Unbounded_Set_Ex_Iterator::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + // ACE_TRACE ("ACE_Unbounded_Set_Ex_Iterator::dump"); +#endif /* ACE_HAS_DUMP */ +} + +template +ACE_Unbounded_Set_Ex_Iterator::ACE_Unbounded_Set_Ex_Iterator ( + ACE_Unbounded_Set_Ex &s, + bool end) + : current_ (!end ? s.head_->next_ : s.head_ ), + set_ (&s) +{ + // ACE_TRACE ("ACE_Unbounded_Set_Ex_Iterator::ACE_Unbounded_Set_Ex_Iterator"); +} + +template int +ACE_Unbounded_Set_Ex_Iterator::advance (void) +{ + // ACE_TRACE ("ACE_Unbounded_Set_Ex_Iterator::advance"); + this->current_ = this->current_->next_; + return this->current_ != this->set_->head_; +} + +template int +ACE_Unbounded_Set_Ex_Iterator::first (void) +{ + // ACE_TRACE ("ACE_Unbounded_Set_Ex_Iterator::first"); + this->current_ = this->set_->head_->next_; + return this->current_ != this->set_->head_; +} + +template int +ACE_Unbounded_Set_Ex_Iterator::done (void) const +{ + ACE_TRACE ("ACE_Unbounded_Set_Ex_Iterator::done"); + + return this->current_ == this->set_->head_; +} + +template int +ACE_Unbounded_Set_Ex_Iterator::next (T *&item) +{ + // ACE_TRACE ("ACE_Unbounded_Set_Ex_Iterator::next"); + if (this->current_ == this->set_->head_) + return 0; + else + { + item = &this->current_->item_; + return 1; + } +} + +template ACE_Unbounded_Set_Ex_Iterator +ACE_Unbounded_Set_Ex_Iterator::operator++ (int) +{ + //ACE_TRACE ("ACE_Unbounded_Set_Ex_Iterator::operator++ (int)"); + ACE_Unbounded_Set_Ex_Iterator retv (*this); + + // postfix operator + + this->advance (); + return retv; +} + +template ACE_Unbounded_Set_Ex_Iterator& +ACE_Unbounded_Set_Ex_Iterator::operator++ (void) +{ + // ACE_TRACE ("ACE_Unbounded_Set_Ex_Iterator::operator++ (void)"); + + // prefix operator + + this->advance (); + return *this; +} + +template T& +ACE_Unbounded_Set_Ex_Iterator::operator* (void) +{ + //ACE_TRACE ("ACE_Unbounded_Set_Ex_Iterator::operator*"); + T *retv = 0; + + int result = this->next (retv); + ACE_ASSERT (result != 0); + ACE_UNUSED_ARG (result); + + return *retv; +} + +template bool +ACE_Unbounded_Set_Ex_Iterator::operator== (const ACE_Unbounded_Set_Ex_Iterator &rhs) const +{ + //ACE_TRACE ("ACE_Unbounded_Set_Ex_Iterator::operator=="); + return (this->set_ == rhs.set_ && this->current_ == rhs.current_); +} + +template bool +ACE_Unbounded_Set_Ex_Iterator::operator!= (const ACE_Unbounded_Set_Ex_Iterator &rhs) const +{ + //ACE_TRACE ("ACE_Unbounded_Set_Ex_Iterator::operator!="); + return (this->set_ != rhs.set_ || this->current_ != rhs.current_); +} + +ACE_ALLOC_HOOK_DEFINE(ACE_Unbounded_Set_Ex_Const_Iterator) + +template void +ACE_Unbounded_Set_Ex_Const_Iterator::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + // ACE_TRACE ("ACE_Unbounded_Set_Ex_Const_Iterator::dump"); +#endif /* ACE_HAS_DUMP */ +} + +template +ACE_Unbounded_Set_Ex_Const_Iterator::ACE_Unbounded_Set_Ex_Const_Iterator ( + const ACE_Unbounded_Set_Ex &s, + bool end) + : current_ (!end ? s.head_->next_ : s.head_ ), + set_ (&s) +{ + // ACE_TRACE ("ACE_Unbounded_Set_Ex_Const_Iterator::ACE_Unbounded_Set_Ex_Const_Iterator"); +} + +template int +ACE_Unbounded_Set_Ex_Const_Iterator::advance (void) +{ + // ACE_TRACE ("ACE_Unbounded_Set_Ex_Const_Iterator::advance"); + this->current_ = this->current_->next_; + return this->current_ != this->set_->head_; +} + +template int +ACE_Unbounded_Set_Ex_Const_Iterator::first (void) +{ + // ACE_TRACE ("ACE_Unbounded_Set_Ex_Const_Iterator::first"); + this->current_ = this->set_->head_->next_; + return this->current_ != this->set_->head_; +} + +template int +ACE_Unbounded_Set_Ex_Const_Iterator::done (void) const +{ + ACE_TRACE ("ACE_Unbounded_Set_Ex_Const_Iterator::done"); + + return this->current_ == this->set_->head_; +} + +template int +ACE_Unbounded_Set_Ex_Const_Iterator::next (T *&item) +{ + // ACE_TRACE ("ACE_Unbounded_Set_Ex_Const_Iterator::next"); + if (this->current_ == this->set_->head_) + return 0; + else + { + item = &this->current_->item_; + return 1; + } +} + +template ACE_Unbounded_Set_Ex_Const_Iterator +ACE_Unbounded_Set_Ex_Const_Iterator::operator++ (int) +{ + //ACE_TRACE ("ACE_Unbounded_Set_Ex_Const_Iterator::operator++ (int)"); + ACE_Unbounded_Set_Ex_Const_Iterator retv (*this); + + // postfix operator + + this->advance (); + return retv; +} + +template ACE_Unbounded_Set_Ex_Const_Iterator& +ACE_Unbounded_Set_Ex_Const_Iterator::operator++ (void) +{ + // ACE_TRACE ("ACE_Unbounded_Set_Ex_Const_Iterator::operator++ (void)"); + + // prefix operator + + this->advance (); + return *this; +} + +template T& +ACE_Unbounded_Set_Ex_Const_Iterator::operator* (void) +{ + //ACE_TRACE ("ACE_Unbounded_Set_Ex_Const_Iterator::operator*"); + T *retv = 0; + + int const result = this->next (retv); + ACE_ASSERT (result != 0); + ACE_UNUSED_ARG (result); + + return *retv; +} + +template bool +ACE_Unbounded_Set_Ex_Const_Iterator::operator== (const ACE_Unbounded_Set_Ex_Const_Iterator &rhs) const +{ + //ACE_TRACE ("ACE_Unbounded_Set_Ex_Const_Iterator::operator=="); + return (this->set_ == rhs.set_ && this->current_ == rhs.current_); +} + +template bool +ACE_Unbounded_Set_Ex_Const_Iterator::operator!= (const ACE_Unbounded_Set_Ex_Const_Iterator &rhs) const +{ + //ACE_TRACE ("ACE_Unbounded_Set_Ex_Const_Iterator::operator!="); + return (this->set_ != rhs.set_ || this->current_ != rhs.current_); +} + +ACE_END_VERSIONED_NAMESPACE_DECL + +#endif /* ACE_UNBOUNDED_SET_EX_CPP */ diff --git a/dep/ACE_wrappers/ace/Unbounded_Set_Ex.h b/dep/ACE_wrappers/ace/Unbounded_Set_Ex.h new file mode 100644 index 00000000000..262ef6043a1 --- /dev/null +++ b/dep/ACE_wrappers/ace/Unbounded_Set_Ex.h @@ -0,0 +1,347 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Unbounded_Set_Ex.h + * + * $Id: Unbounded_Set_Ex.h 81624 2008-05-06 17:14:57Z wotte $ + * + * @author Douglas C. Schmidt + */ +//============================================================================= + +#ifndef ACE_UNBOUNDED_SET_EX_H +#define ACE_UNBOUNDED_SET_EX_H +#include /**/ "ace/pre.h" + +#include "ace/Node.h" +#include "ace/os_include/os_stddef.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +class ACE_Allocator; + +template +class ACE_Unbounded_Set_Ex_Iterator; + +template +class ACE_Unbounded_Set_Ex_Const_Iterator; + +template +class ACE_Unbounded_Set_Ex; + +/** + * @class ACE_Unbounded_Set_Ex_Iterator + * + * @brief Implement an iterator over an unbounded set. + */ +template +class ACE_Unbounded_Set_Ex_Iterator +{ +public: + // = Initialization method. + ACE_Unbounded_Set_Ex_Iterator (ACE_Unbounded_Set_Ex &s, bool end = false); + + // = Iteration methods. + + /// Pass back the that hasn't been seen in the Set. + /// Returns 0 when all items have been seen, else 1. + int next (T *&next_item); + + /// Move forward by one element in the set. Returns 0 when all the + /// items in the set have been seen, else 1. + int advance (void); + + /// Move to the first element in the set. Returns 0 if the + /// set is empty, else 1. + int first (void); + + /// Returns 1 when all items have been seen, else 0. + int done (void) const; + + /// Dump the state of an object. + void dump (void) const; + + // = STL styled iteration, compare, and reference functions. + + /// Postfix advance. + ACE_Unbounded_Set_Ex_Iterator operator++ (int); + + /// Prefix advance. + ACE_Unbounded_Set_Ex_Iterator& operator++ (void); + + /// Returns a reference to the internal element @c this is pointing to. + T& operator* (void); + + /// Check if two iterators point to the same position + bool operator== (const ACE_Unbounded_Set_Ex_Iterator &) const; + bool operator!= (const ACE_Unbounded_Set_Ex_Iterator &) const; + + /// Declare the dynamic allocation hooks. + ACE_ALLOC_HOOK_DECLARE; + +private: + + /// Pointer to the current node in the iteration. + ACE_Node *current_; + + /// Pointer to the set we're iterating over. + ACE_Unbounded_Set_Ex *set_; +}; + +/** + * @class ACE_Unbounded_Set_Ex_Const_Iterator + * + * @brief Implement an const iterator over an unbounded set. + */ +template +class ACE_Unbounded_Set_Ex_Const_Iterator +{ +public: + // = Initialization method. + ACE_Unbounded_Set_Ex_Const_Iterator (const ACE_Unbounded_Set_Ex &s, + bool end = false); + + // = Iteration methods. + + /// Pass back the @a next_item that hasn't been seen in the Set. + /// @return Returns 0 when all items have been seen, else 1. + int next (T *&next_item); + + /// Move forward by one element in the set. Returns 0 when all the + /// items in the set have been seen, else 1. + int advance (void); + + /// Move to the first element in the set. Returns 0 if the + /// set is empty, else 1. + int first (void); + + /// Returns 1 when all items have been seen, else 0. + int done (void) const; + + /// Dump the state of an object. + void dump (void) const; + + // = STL styled iteration, compare, and reference functions. + + /// Postfix advance. + ACE_Unbounded_Set_Ex_Const_Iterator operator++ (int); + + /// Prefix advance. + ACE_Unbounded_Set_Ex_Const_Iterator& operator++ (void); + + /// Returns a reference to the internal element @c this is pointing to. + T& operator* (void); + + /// Check if two iterators point to the same position + bool operator== (const ACE_Unbounded_Set_Ex_Const_Iterator &) const; + bool operator!= (const ACE_Unbounded_Set_Ex_Const_Iterator &) const; + + /// Declare the dynamic allocation hooks. + ACE_ALLOC_HOOK_DECLARE; + +private: + + /// Pointer to the current node in the iteration. + ACE_Node *current_; + + /// Pointer to the set we're iterating over. + const ACE_Unbounded_Set_Ex *set_; +}; + +/** + * @class ACE_Unbounded_Set_Ex + * + * @brief Implement a simple unordered set of of unbounded size. + * + * This implementation of an unordered set uses a circular + * linked list with a dummy node. This implementation does not + * allow duplicates, but it maintains FIFO ordering of insertions. + * + * This implementation may also be parameterized with a comparator + * functor, which must implement bool operator () (const T&, const T&) const, + * returning true if the given items are equivalent. The default comparator + * is sufficient for objects reliably compared with operator==. + * + * Requirements and Performance Characteristics + * - Internal Structure + * Circular linked list + * - Duplicates allowed? + * No + * - Random access allowed? + * No + * - Search speed + * Linear + * - Insert/replace speed + * Linear + * - Iterator still valid after change to container? + * Yes + * - Frees memory for removed elements? + * Yes + * - Items inserted by + * Value + * - Requirements for contained type + * -# Default constructor + * -# Copy constructor + * -# operator= + * -# operator== const + * + */ +template +class ACE_Unbounded_Set_Ex +{ +public: + friend class ACE_Unbounded_Set_Ex_Iterator; + friend class ACE_Unbounded_Set_Ex_Const_Iterator; + + // Trait definition. + typedef ACE_Unbounded_Set_Ex_Iterator ITERATOR; + typedef ACE_Unbounded_Set_Ex_Iterator iterator; + typedef ACE_Unbounded_Set_Ex_Const_Iterator CONST_ITERATOR; + typedef ACE_Unbounded_Set_Ex_Const_Iterator const_iterator; + typedef C COMP; + typedef ACE_Node NODE; + + // = Initialization and termination methods. + /// Constructor. Use user specified allocation strategy + /// if specified. + /** + * Initialize an empty set using the allocation strategy of the user if + * provided. + */ + ACE_Unbounded_Set_Ex (ACE_Allocator *alloc = 0); + + /** + * Initialize an empty set using the allocation strategy of the user if + * provided, and a given comparator functor. + */ + ACE_Unbounded_Set_Ex (const C &comparator, ACE_Allocator *alloc = 0); + + /// Copy constructor. + /** + * Initialize this set to be an exact copy of the set provided. + */ + ACE_Unbounded_Set_Ex (const ACE_Unbounded_Set_Ex &); + + /// Assignment operator. + /** + * Perform a deep copy of the rhs into the lhs. + */ + ACE_Unbounded_Set_Ex & operator= (const ACE_Unbounded_Set_Ex &); + + /// Destructor. + /** + * Destroy the nodes of the set. + */ + ~ACE_Unbounded_Set_Ex (void); + + // = Check boundary conditions. + + /// Returns @c true if the container is empty, otherwise returns @c false. + /** + * Constant time is_empty check. + */ + bool is_empty (void) const; + + /// Returns @c false. + /** + * Always returns @c false since the set can never fill up. + */ + bool is_full (void) const; + + // = Classic unordered set operations. + + /// Linear insertion of an item. + /** + * Insert @a new_item into the set (doesn't allow duplicates). + * Returns -1 if failures occur, 1 if item is already present, else + * 0. + */ + int insert (const T &new_item); + + /// Insert @a item at the tail of the set (doesn't check for + /// duplicates). + /** + * Constant time insert at the end of the set. + */ + int insert_tail (const T &item); + + /// Linear remove operation. + /** + * Remove first occurrence of @a item from the set. Returns 0 if + * it removes the item, -1 if it can't find the item, and -1 if a + * failure occurs. + */ + int remove (const T &item); + + /// Finds if @a item occurs in the set. Returns 0 if find succeeds, + /// else -1. + /** + * Performs a linear find operation. + */ + int find (const T &item) const; + + /// Size of the set. + /** + * Access the size of the set. + */ + size_t size (void) const; + + /// Dump the state of an object. + void dump (void) const; + + /// Reset the ACE_Unbounded_Set_Ex to be empty. + /** + * Delete the nodes of the set. + */ + void reset (void); + + // = STL-styled unidirectional iterator factory. + iterator begin (void); + iterator end (void); + const_iterator begin (void) const; + const_iterator end (void) const; + + /// Declare the dynamic allocation hooks. + ACE_ALLOC_HOOK_DECLARE; + +private: + /// Delete all the nodes in the Set. + void delete_nodes (void); + + /// Copy nodes into this set. + void copy_nodes (const ACE_Unbounded_Set_Ex &); + + /// Head of the linked list of Nodes. + NODE *head_; + + /// Current size of the set. + size_t cur_size_; + + /// Allocation strategy of the set. + ACE_Allocator *allocator_; + + /// Comparator to be used + COMP comp_; +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +#include "ace/Unbounded_Set_Ex.inl" +#endif /* __ACE_INLINE__ */ + +#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) +#include "ace/Unbounded_Set_Ex.cpp" +#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ + +#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) +#pragma implementation ("Unbounded_Set_Ex.cpp") +#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ + +#include /**/ "ace/post.h" +#endif /* ACE_UNBOUNDED_SET_H */ diff --git a/dep/ACE_wrappers/ace/Unbounded_Set_Ex.inl b/dep/ACE_wrappers/ace/Unbounded_Set_Ex.inl new file mode 100644 index 00000000000..356a1f58f1d --- /dev/null +++ b/dep/ACE_wrappers/ace/Unbounded_Set_Ex.inl @@ -0,0 +1,23 @@ +// -*- C++ -*- +// +// $Id: Unbounded_Set_Ex.inl 81624 2008-05-06 17:14:57Z wotte $ + +#include "ace/Global_Macros.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +template ACE_INLINE bool +ACE_Unbounded_Set_Ex::is_empty (void) const +{ + ACE_TRACE ("ACE_Unbounded_Set_Ex::is_empty"); + return this->head_ == this->head_->next_; +} + +template ACE_INLINE bool +ACE_Unbounded_Set_Ex::is_full (void) const +{ + ACE_TRACE ("ACE_Unbounded_Set_Ex::is_full"); + return 0; // We should implement a "node of last resort for this..." +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/Value_Ptr.h b/dep/ACE_wrappers/ace/Value_Ptr.h new file mode 100644 index 00000000000..c9272a90cff --- /dev/null +++ b/dep/ACE_wrappers/ace/Value_Ptr.h @@ -0,0 +1,167 @@ +// -*- C++ -*- + +//========================================================================== +/** + * @file Value_Ptr.h + * + * $Id: Value_Ptr.h 80826 2008-03-04 14:51:23Z wotte $ + * + * Value_Ptr implementation based on code in Herb Sutter's book "More + * Exceptional C++". + * + * @author Ossama Othman + */ +//========================================================================== + +#ifndef ACE_VALUE_PTR_H +#define ACE_VALUE_PTR_H + +#include "ace/config-lite.h" + +#include + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +namespace ACE +{ + /** + * @struct VP_traits + * + * @brief @c Value_Ptr traits template structure. + * + * The @c Value_Ptr template class delegates some operations to this + * template traits structure. + * + * Specialize this trait template if cloning through copy + * construction is not sufficient. For example, to avoid slicing + * when copying an object through a base class pointer, one can + * implement a virtual "clone" method that can be used to + * polymorphically invoke the appropriate cloning operation(s). + * That virtual method would then be invoked by the @c VP_traits\<\> + * specialization. + */ + template + struct VP_traits + { + /// Copy the given object. + static T * clone (T const * p) { return new T (*p); } + }; + + /** + * @class Value_Ptr + * + * @brief Smart pointer implementation designed for use as a class + * member. + * + * Using a @c std::auto_ptr\<\> as a class member is sometimes + * problematic since ownership of memory is transferred when copying + * such members. This @c Value_Ptr class is explicitly designed to + * avoid such problems by performing copies of the underlying object + * rather than transfer ownership. This, for example, allows it to + * be readily used as a member in classes placed inside STL + * containers. + * + * @see Item 31 in "More Exceptional C++" by Herb Sutter. + */ + template + class Value_Ptr + { + public: + + /// Constructor. + explicit Value_Ptr (T * p = 0) : p_ (p) { } + + /// Destructor. + ~Value_Ptr (void) { delete this->p_; } + + /// Deference operator. + T & operator* (void) const { return *this->p_; } + + /// Pointer operator. + T * operator-> (void) const { return this->p_; } + + /// Non-throwing swap operation used to make assignment strongly + /// exception-safe. + /** + * @note As implemented, the swap operation may not work correctly + * for @c auto_ptr\<\>s, but why would one use an @c + * auto_ptr\<\> as the template argument for this particular + * template class!? + */ + void swap (Value_Ptr & other) { std::swap (this->p_, other.p_); } + + /// Copy constructor. + Value_Ptr (Value_Ptr const & other) + : p_ (create_from (other.p_)) { } + + /// Assignment operator. + Value_Ptr & operator= (Value_Ptr const & other) + { + // Strongly exception-safe. + Value_Ptr temp (other); + this->swap (temp); + return *this; + } + +#ifndef ACE_LACKS_MEMBER_TEMPLATES + + // Compiler can't handle member templates so we lose converting + // copy operations. + + /// Converting copy constructor. + template + Value_Ptr (Value_Ptr const & other) + : p_ (create_from (other.p_)) { } + + /// Converting assignment operator. + template + Value_Ptr & operator= (Value_Ptr const & other) + { + // Strongly exception-safe. + Value_Ptr temp (other); + this->swap (temp); + return *this; + } + +#endif /* !ACE_LACKS_MEMBER_TEMPLATES */ + + private: + +#ifndef ACE_LACKS_MEMBER_TEMPLATES + + /// Copying method invoked when copy constructing. + template + T * create_from (U const * p) const + { + return p ? VP_traits::clone (p) : 0; + } + +#else + + // Compiler can't handle member templates so we lose converting + // copy operations. + + /// Copying method invoked when copy constructing. + T * create_from (T const * p) const + { + return p ? VP_traits::clone (p) : 0; + } + +#endif /* !ACE_LACKS_MEMBER_TEMPLATES */ + + private: + +#ifndef ACE_LACKS_MEMBER_TEMPLATES + template friend class Value_Ptr; +#endif /* !ACE_LACKS_MEMBER_TEMPLATES */ + + /// Object owned by this @c Value_Ptr. + T * p_; + + }; + +} + +ACE_END_VERSIONED_NAMESPACE_DECL + +#endif /* ACE_VALUE_PTR_H */ diff --git a/dep/ACE_wrappers/ace/Vector_T.cpp b/dep/ACE_wrappers/ace/Vector_T.cpp new file mode 100644 index 00000000000..006e6db1b4a --- /dev/null +++ b/dep/ACE_wrappers/ace/Vector_T.cpp @@ -0,0 +1,154 @@ +// $Id: Vector_T.cpp 80826 2008-03-04 14:51:23Z wotte $ + +#ifndef ACE_VECTOR_T_CPP +#define ACE_VECTOR_T_CPP + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/Vector_T.h" + +#if !defined (__ACE_INLINE__) +#include "ace/Vector_T.inl" +#endif /* __ACE_INLINE__ */ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_ALLOC_HOOK_DEFINE(ACE_Vector) + +template +void ACE_Vector::resize (const size_t new_size, + const T& t) +{ + ACE_Array::size (new_size); + if (new_size > length_) + for (size_t i = length_; i < new_size; ++i) + (*this)[i]=t; + + curr_max_size_ = this->max_size (); + length_ = new_size; +} + +template +void ACE_Vector::push_back (const T& elem) +{ + if (length_ == curr_max_size_) + { + ACE_Array::size (curr_max_size_ * 2); + curr_max_size_ = this->max_size (); + } + else + ACE_Array::size (length_ + 1); + + ++length_; + (*this)[length_-1] = elem; +} + +template +void ACE_Vector::dump (void) const +{ +#if defined (ACE_HAS_DUMP) +#if 0 + // Can't do this unless the vector is an object with a dump + // function. + for (size_t i = 0; i < this->size (); ++i) + (*this)[i].dump (); +#endif /* 0 */ +#endif /* ACE_HAS_DUMP */ +} + +// Compare this vector with for equality. +template bool +ACE_Vector::operator== (const ACE_Vector &s) const +{ + if (this == &s) + return true; + else if (this->size () != s.size ()) + return false; + + const size_t len = s.size (); + for (size_t slot = 0; slot < len; ++slot) + if ((*this)[slot] != s[slot]) + return false; + + return true; +} + +#if 0 +template +int compare(const ACE_Vector& v1, + const ACE_Vector& v2, + const size_t from_ndx, + const size_t to_ndx) +{ + size_t last1 = v1.size () - 1; + size_t last2 = v2.size () - 1; + if (last1 < from_ndx || last1 < to_ndx) + return false; + if (last2 < from_ndx || last2 < to_ndx) + return false; + if (last1 != last2) + return false; + + // cout<<"compare() <================="<"< +int partial_compare(const ACE_Vector& v1, + const ACE_Vector& v2, + const size_t from_ndx, + const size_t to_ndx) +{ + size_t last1 = v1.size () - 1; + size_t last2 = v2.size () - 1; + + if (last1 < from_ndx || last1 < to_ndx) + return false; + if (last2 < from_ndx || last2 < to_ndx) + return false; + + // cout<<"partial_compare() <================="<"< int +ACE_Vector_Iterator::next (T *&item) +{ + // ACE_TRACE ("ACE_Vector_Iterator::next"); + + if (this->done ()) + { + item = 0; + return 0; + } + else + { + item = &vector_[current_]; + return 1; + } +} + +ACE_END_VERSIONED_NAMESPACE_DECL + +#endif /* ACE_VECTOR_T_CPP */ diff --git a/dep/ACE_wrappers/ace/Vector_T.h b/dep/ACE_wrappers/ace/Vector_T.h new file mode 100644 index 00000000000..2df3aa61d00 --- /dev/null +++ b/dep/ACE_wrappers/ace/Vector_T.h @@ -0,0 +1,316 @@ +// -*- C++ -*- + +//========================================================================== +/** + * @file Vector_T.h + * + * $Id: Vector_T.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Craig L. Ching + * @author Gonzalo Diethelm + */ +//========================================================================== + +#ifndef ACE_VECTOR_T_H +#define ACE_VECTOR_T_H + +#include /**/ "ace/pre.h" + +#include "ace/Array.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +/* + * Default size for an ACE_Vector. + */ +static const size_t ACE_VECTOR_DEFAULT_SIZE = 32; + +// Forward declaration. +template class ACE_Vector_Iterator; + +/** + * @class ACE_Vector + * + * @brief Defines an STL-like vector container. + * + * This is an STL-like template vector container, a wrapper around + * ACE_Array. It provides at least the basic std::vector look and + * feel: push_back(), clear(), resize(), capacity(). This template + * class uses the copy semantic paradigm, though it is okay to use + * reference counted smart pointers (see ACE_Ptr<T>) with this + * template class. + * + * Requirements and Performance Characteristics + * - Internal Structure + * ACE_Array + * - Duplicates allowed? + * Yes + * - Random access allowed? + * No + * - Search speed + * N/A + * - Insert/replace speed + * Linear + * - Iterator still valid after change to container? + * Yes + * - Frees memory for removed elements? + * No + * - Items inserted by + * Value + * - Requirements for contained type + * -# Default constructor + * -# Copy constructor + * -# operator= + */ +template +class ACE_Vector : public ACE_Array +{ +public: + /** + * A short name for iterator for ACE_Vector. + */ + typedef ACE_Vector_Iterator Iterator; + + + /** + * General constructor. + * + * @param init_size Initial size of the vector with the default + * value of DEFAULT_SIZE + * @param alloc Pointer to an ACE allocator. If it is NULL then the + * default ACE allocator is used + */ + ACE_Vector (const size_t init_size = DEFAULT_SIZE, + ACE_Allocator* alloc = 0); + + /** + * Destructor. + */ + ~ACE_Vector (); + + /** + * Returns the current vector capacity, that is, the currently + * allocated buffer size. + * + * @return Current buffer size of the vector + */ + size_t capacity (void) const; + + /** + * Returns the vector's dynamic size / actual current size of the + * vector. Do not confuse it with ACE_Array::size(), which returns + * the array's capacity. Unfortunately, ACE is not very consistent + * with the function names. + * + * @return Dynamic size / actual current size of the vector. + */ + size_t size (void) const; + + /** + * Clears out the vector. It does not reallocate the vector's + * buffer, it is just sets the vector's dynamic size to 0. + */ + void clear (void); + + /** + * Resizes the vector to the new capacity. If the vector's current + * capacity is smaller than the size to be specified, then the + * buffer gets reallocated. If the new capacity is less than the + * current capacity of the vector, the buffer size stays the same. + * + * @param new_size New capacity of the vector + * @param t A filler value (of the class T) for initializing the + * elements of the vector with. By default, if this + * parameter is not specified, the default value of the + * class T will be used (for more detail, see the + * initialization clause for this parameter). + */ + void resize (const size_t new_size, + const T& t); + + /** + * Appends a new element to the vector ("push back"). If the + * dynamic size of the vector is equal to the capacity of the vector + * (vector is at capacity), the vector automatically doubles its + * capacity. + * + * @param elem A reference to the new element to be appended. By + * default, this parameters gets initialized with the + * default value of the class T. + */ + void push_back (const T& elem); + + /** + * Deletes the last element from the vector ("pop back"). What this + * function really does is decrement the dynamic size of the + * vector. The vector's buffer does not get reallocated for + * performance. + */ + void pop_back (void); + + /** + * This function dumps the content of the vector. TO BE MOVED out + * of this class. It needs to be implemented as a global template + * function that accepts a const ACE_Vector<T>, in order to + * make instances of this class compile on Linux, AIX. G++ and xlC + * have template instantiation algoriths, which are different from + * the one in Visual C++. The algorithms try to instantiate ALL + * methods declared in the template class, regardless of whether the + * functions are used or not. That is, all of the classes, that are + * used as elements in ACE_Vector's, have to have the dump() methods + * defined in them (seems to be overkill). + * + * This function calls T::dump() for each element of the vector. + */ + void dump (void) const; + + // = Compare operators + + ///Equality comparison operator. + /** + * Compare this vector with @arg s for equality. Two vectors are equal + * if their sizes are equal and all the elements are equal. + */ + bool operator== (const ACE_Vector &s) const; + + ///Inequality comparison operator. + /** + * Compare this vector with @arg s for inequality such that @c *this != + * @arg s is always the complement of the boolean return value of + * @c *this == @arg s. + */ + bool operator!= (const ACE_Vector &s) const; + + void swap (ACE_Vector &rhs); + +protected: + + /** + * Dynamic size (length) of the vector. + */ + size_t length_; + + /** + * Current capacity (buffer size) of the vector. + */ + size_t curr_max_size_; + + friend class ACE_Vector_Iterator; +}; + +#if 0 +/* + * Not sure about including these functions, if for no other reason, + * because they polute the global namespace! + */ + +/** + * Compare two vectors in the range of [from_ndx..to_ndx]. This + * template function requires class T to have the bool operator!=() + * declared in the class. It is safe to define vectors of scalar data + * types, like int, double, etc., including class ACE_TString. + * + * @param v1 The first vector (out of the two) to be compared. + * @param v2 The Second vector (out of the two) to be compared. + * @param from_ndx Compare vector v1 and v2, starting with the + * "from_ndx" index . + * @param to_ndx Compare vector v1 and v2, from "from_ndx" to + * "to_ndx". + * @return Returns true if v1==v2 in the specified index range, + * returns false otherwise. Also, returns false in case if + * v1's size is not equal to v2's size. + */ +template +int compare (const ACE_Vector& v1, + const ACE_Vector& v2, + const size_t from_ndx, + const size_t to_ndx); + +/** + * Does a partial comparison of two vectors in the range of + * [from_ndx..to_ndx]. The only difference between this function and + * the template compare<T> function is that this function does + * not require v1 and v2 to be of equal size. + * + * @param v1 The first vector (out of the two) to be compared. + * @param v2 The Second vector (out of the two) to be compared. + * @param from_ndx Compare vector v1 and v2, starting with the + * "from_ndx" index . + * @param to_ndx Compare vector v1 and v2, from "from_ndx" to + * "to_ndx". + * @return Returns true if vector v1 and v2 are equal in the specified + * index range. + */ + +template +int partial_compare (const ACE_Vector& v1, + const ACE_Vector& v2, + const size_t from_ndx, + const size_t to_ndx); +#endif /* 0 */ +// **************************************************************** + +/** + * @class ACE_Vector_Iterator + * + * @brief Implement an iterator over an ACE_Vector. + * + * This iterator is safe in the face of vector element deletions. + * But it is NOT safe if the vector is resized via the assignment + * operator during iteration. That would be very odd, and dangerous. + */ +template +class ACE_Vector_Iterator +{ +public: + // = Initialization method. + ACE_Vector_Iterator (ACE_Vector &); + + // = Iteration methods. + + /// Pass back the that hasn't been seen in the vector. + /// Returns 0 when all items have been seen, else 1. + int next (T *&next_item); + + /// Move forward by one element in the vector. Returns 0 when all the + /// items in the vector have been seen, else 1. + int advance (void); + + /// Returns 1 when all items have been seen, else 0. + int done (void) const; + + /// Dump the state of an object. + void dump (void) const; + + /// Declare the dynamic allocation hooks. + ACE_ALLOC_HOOK_DECLARE; + +private: + /// Pointer to the current item in the iteration. + size_t current_; + + /// Reference to the vector we're iterating over. + ACE_Vector &vector_; +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +#include "ace/Vector_T.inl" +#endif /* __ACE_INLINE__ */ + +#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) +#include "ace/Vector_T.cpp" +#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ + +#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) +#pragma implementation ("Vector_T.cpp") +#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ + +#include /**/ "ace/post.h" + +#endif /* ACE_VECTOR_T_H */ diff --git a/dep/ACE_wrappers/ace/Vector_T.inl b/dep/ACE_wrappers/ace/Vector_T.inl new file mode 100644 index 00000000000..4b773109a84 --- /dev/null +++ b/dep/ACE_wrappers/ace/Vector_T.inl @@ -0,0 +1,107 @@ +// -*- C++ -*- +// +// $Id: Vector_T.inl 81478 2008-04-28 13:22:26Z schmidt $ + +#include + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +template ACE_INLINE +ACE_Vector::ACE_Vector (const size_t init_size, + ACE_Allocator* alloc) + : ACE_Array (init_size == 0 ? DEFAULT_SIZE : init_size, alloc), + length_ (0) +{ + this->curr_max_size_ = this->max_size (); +} + +template ACE_INLINE +ACE_Vector::~ACE_Vector () +{ +} + +template ACE_INLINE +size_t ACE_Vector::capacity (void) const +{ + return curr_max_size_; +} + +template ACE_INLINE +size_t ACE_Vector::size (void) const +{ + return length_; +} + +template ACE_INLINE +void ACE_Vector::clear (void) +{ + length_ = 0; +} + +template ACE_INLINE +void ACE_Vector::pop_back (void) +{ + if (length_ > 0) + { + --length_; + ACE_Array::size (length_); + } +} + +// Compare this vector with for inequality. + +template ACE_INLINE bool +ACE_Vector::operator!= (const ACE_Vector &s) const +{ + return !(*this == s); +} + +template ACE_INLINE void +ACE_Vector::swap (ACE_Vector &rhs) +{ + ACE_Array::swap (rhs); + std::swap (this->length_, rhs.length_); + std::swap (this->curr_max_size_, rhs.curr_max_size_); +} + +// **************************************************************** + +template ACE_INLINE void +ACE_Vector_Iterator::dump (void) const +{ + // ACE_TRACE ("ACE_Vector_Iterator::dump"); +} + +template ACE_INLINE +ACE_Vector_Iterator::ACE_Vector_Iterator (ACE_Vector &v) + : current_ (0), + vector_ (v) +{ + // ACE_TRACE ("ACE_Vector_Iterator::ACE_Vector_Iterator"); +} + +template ACE_INLINE int +ACE_Vector_Iterator::advance (void) +{ + // ACE_TRACE ("ACE_Vector_Iterator::advance"); + + if (this->current_ < vector_.size ()) + { + ++this->current_; + return 1; + } + else + // Already finished iterating. + return 0; +} + +template ACE_INLINE int +ACE_Vector_Iterator::done (void) const +{ + ACE_TRACE ("ACE_Vector_Iterator::done"); + + return this->current_ >= vector_.size (); +} + +ACE_END_VERSIONED_NAMESPACE_DECL + diff --git a/dep/ACE_wrappers/ace/Version.h b/dep/ACE_wrappers/ace/Version.h new file mode 100644 index 00000000000..0c8c9d7dbb0 --- /dev/null +++ b/dep/ACE_wrappers/ace/Version.h @@ -0,0 +1,9 @@ + +// -*- C++ -*- +// $Id: Version.h 82705 2008-09-15 11:08:20Z sma $ +// This is file was automatically generated by \$ACE_ROOT/bin/make_release. + +#define ACE_MAJOR_VERSION 5 +#define ACE_MINOR_VERSION 6 +#define ACE_BETA_VERSION 6 +#define ACE_VERSION "5.6.6" diff --git a/dep/ACE_wrappers/ace/Versioned_Namespace.h b/dep/ACE_wrappers/ace/Versioned_Namespace.h new file mode 100644 index 00000000000..542254876ff --- /dev/null +++ b/dep/ACE_wrappers/ace/Versioned_Namespace.h @@ -0,0 +1,51 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Versioned_Namespace.h + * + * $Id$ + * + * Versioned namespace support. + * + * Useful for preventing conflicts when using a third party library. + * + * @author Ossama Othman + */ +//============================================================================= + +#ifndef ACE_VERSIONED_NAMESPACE_H +#define ACE_VERSIONED_NAMESPACE_H + +#ifndef ACE_CONFIG_MACROS_H +# error This header is only meant to be included by or after "ace/config-lite.h". +#endif /* !ACE_CONFIG_LITE_H */ + + +#if defined (ACE_HAS_VERSIONED_NAMESPACE) && ACE_HAS_VERSIONED_NAMESPACE == 1 + +# ifndef ACE_VERSIONED_NAMESPACE_NAME +//# include "ace/Version.h" + +// Preprocessor symbols will not be expanded if they are +// concatenated. Force the preprocessor to expand them during the +// argument prescan by calling a macro that itself calls another that +// performs the actual concatenation. +# define ACE_MAKE_VERSIONED_NAMESPACE_NAME_IMPL(MAJOR,MINOR,BETA) ACE_ ## MAJOR ## _ ## MINOR ## _ ## BETA +# define ACE_MAKE_VERSIONED_NAMESPACE_NAME(MAJOR,MINOR,BETA) ACE_MAKE_VERSIONED_NAMESPACE_NAME_IMPL(MAJOR,MINOR,BETA) +# define ACE_VERSIONED_NAMESPACE_NAME ACE_MAKE_VERSIONED_NAMESPACE_NAME(ACE_MAJOR_VERSION,ACE_MINOR_VERSION,ACE_BETA_VERSION) +# endif /* !ACE_VERSIONED_NAMESPACE_NAME */ + +# define ACE_BEGIN_VERSIONED_NAMESPACE_DECL namespace ACE_VERSIONED_NAMESPACE_NAME { +# define ACE_END_VERSIONED_NAMESPACE_DECL } \ + using namespace ACE_VERSIONED_NAMESPACE_NAME; + +#else + +# define ACE_VERSIONED_NAMESPACE_NAME +# define ACE_BEGIN_VERSIONED_NAMESPACE_DECL +# define ACE_END_VERSIONED_NAMESPACE_DECL + +#endif /* ACE_HAS_VERSIONED_NAMESPACE */ + +#endif /* !ACE_VERSIONED_NAMESPACE_H */ diff --git a/dep/ACE_wrappers/ace/WFMO_Reactor.cpp b/dep/ACE_wrappers/ace/WFMO_Reactor.cpp new file mode 100644 index 00000000000..7195749adcc --- /dev/null +++ b/dep/ACE_wrappers/ace/WFMO_Reactor.cpp @@ -0,0 +1,2748 @@ +// $Id: WFMO_Reactor.cpp 81138 2008-03-28 09:18:15Z johnnyw $ + +#include "ace/WFMO_Reactor.h" + +#if defined (ACE_WIN32) + +#include "ace/Handle_Set.h" +#include "ace/Timer_Heap.h" +#include "ace/Thread.h" +#include "ace/OS_NS_errno.h" +#include "ace/Null_Condition.h" + +#if !defined (__ACE_INLINE__) +#include "ace/WFMO_Reactor.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(ace, WFMO_Reactor, "$Id: WFMO_Reactor.cpp 81138 2008-03-28 09:18:15Z johnnyw $") + +#include "ace/Auto_Ptr.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_WFMO_Reactor_Handler_Repository::ACE_WFMO_Reactor_Handler_Repository (ACE_WFMO_Reactor &wfmo_reactor) + : wfmo_reactor_ (wfmo_reactor) +{ +} + +int +ACE_WFMO_Reactor_Handler_Repository::open (size_t size) +{ + if (size > MAXIMUM_WAIT_OBJECTS) + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("%d exceeds MAXIMUM_WAIT_OBJECTS (%d)\n"), + size, + MAXIMUM_WAIT_OBJECTS), + -1); + + // Dynamic allocation + ACE_NEW_RETURN (this->current_handles_, + ACE_HANDLE[size], + -1); + ACE_NEW_RETURN (this->current_info_, + Current_Info[size], + -1); + ACE_NEW_RETURN (this->current_suspended_info_, + Suspended_Info[size], + -1); + ACE_NEW_RETURN (this->to_be_added_info_, + To_Be_Added_Info[size], + -1); + + // Initialization + this->max_size_ = size; + this->max_handlep1_ = 0; + this->suspended_handles_ = 0; + this->handles_to_be_added_ = 0; + this->handles_to_be_deleted_ = 0; + this->handles_to_be_suspended_ = 0; + this->handles_to_be_resumed_ = 0; + + for (size_t i = 0; i < size; ++i) + this->current_handles_[i] = ACE_INVALID_HANDLE; + + return 0; +} + +ACE_WFMO_Reactor_Handler_Repository::~ACE_WFMO_Reactor_Handler_Repository (void) +{ + // Free up dynamically allocated space + delete [] this->current_handles_; + delete [] this->current_info_; + delete [] this->current_suspended_info_; + delete [] this->to_be_added_info_; +} + +ACE_Reactor_Mask +ACE_WFMO_Reactor_Handler_Repository::bit_ops (long &existing_masks, + ACE_Reactor_Mask change_masks, + int operation) +{ + // Find the old reactor masks. This automatically does the work of + // the GET_MASK operation. + + ACE_Reactor_Mask old_masks = ACE_Event_Handler::NULL_MASK; + + if (ACE_BIT_ENABLED (existing_masks, FD_READ) + || ACE_BIT_ENABLED (existing_masks, FD_CLOSE)) + ACE_SET_BITS (old_masks, ACE_Event_Handler::READ_MASK); + + if (ACE_BIT_ENABLED (existing_masks, FD_WRITE)) + ACE_SET_BITS (old_masks, ACE_Event_Handler::WRITE_MASK); + + if (ACE_BIT_ENABLED (existing_masks, FD_OOB)) + ACE_SET_BITS (old_masks, ACE_Event_Handler::EXCEPT_MASK); + + if (ACE_BIT_ENABLED (existing_masks, FD_ACCEPT)) + ACE_SET_BITS (old_masks, ACE_Event_Handler::ACCEPT_MASK); + + if (ACE_BIT_ENABLED (existing_masks, FD_CONNECT)) + ACE_SET_BITS (old_masks, ACE_Event_Handler::CONNECT_MASK); + + if (ACE_BIT_ENABLED (existing_masks, FD_QOS)) + ACE_SET_BITS (old_masks, ACE_Event_Handler::QOS_MASK); + + if (ACE_BIT_ENABLED (existing_masks, FD_GROUP_QOS)) + ACE_SET_BITS (old_masks, ACE_Event_Handler::GROUP_QOS_MASK); + + switch (operation) + { + case ACE_Reactor::CLR_MASK: + // For the CLR_MASK operation, clear only the specific masks. + + if (ACE_BIT_ENABLED (change_masks, ACE_Event_Handler::READ_MASK)) + { + ACE_CLR_BITS (existing_masks, FD_READ); + ACE_CLR_BITS (existing_masks, FD_CLOSE); + } + + if (ACE_BIT_ENABLED (change_masks, ACE_Event_Handler::WRITE_MASK)) + ACE_CLR_BITS (existing_masks, FD_WRITE); + + if (ACE_BIT_ENABLED (change_masks, ACE_Event_Handler::EXCEPT_MASK)) + ACE_CLR_BITS (existing_masks, FD_OOB); + + if (ACE_BIT_ENABLED (change_masks, ACE_Event_Handler::ACCEPT_MASK)) + ACE_CLR_BITS (existing_masks, FD_ACCEPT); + + if (ACE_BIT_ENABLED (change_masks, ACE_Event_Handler::CONNECT_MASK)) + ACE_CLR_BITS (existing_masks, FD_CONNECT); + + if (ACE_BIT_ENABLED (change_masks, ACE_Event_Handler::QOS_MASK)) + ACE_CLR_BITS (existing_masks, FD_QOS); + + if (ACE_BIT_ENABLED (change_masks, ACE_Event_Handler::GROUP_QOS_MASK)) + ACE_CLR_BITS (existing_masks, FD_GROUP_QOS); + + break; + + case ACE_Reactor::SET_MASK: + // If the operation is a set, first reset any existing masks + + existing_masks = 0; + /* FALLTHRU */ + + case ACE_Reactor::ADD_MASK: + // For the ADD_MASK and the SET_MASK operation, add only the + // specific masks. + + if (ACE_BIT_ENABLED (change_masks, ACE_Event_Handler::READ_MASK)) + { + ACE_SET_BITS (existing_masks, FD_READ); + ACE_SET_BITS (existing_masks, FD_CLOSE); + } + + if (ACE_BIT_ENABLED (change_masks, ACE_Event_Handler::WRITE_MASK)) + ACE_SET_BITS (existing_masks, FD_WRITE); + + if (ACE_BIT_ENABLED (change_masks, ACE_Event_Handler::EXCEPT_MASK)) + ACE_SET_BITS (existing_masks, FD_OOB); + + if (ACE_BIT_ENABLED (change_masks, ACE_Event_Handler::ACCEPT_MASK)) + ACE_SET_BITS (existing_masks, FD_ACCEPT); + + if (ACE_BIT_ENABLED (change_masks, ACE_Event_Handler::CONNECT_MASK)) + ACE_SET_BITS (existing_masks, FD_CONNECT); + + if (ACE_BIT_ENABLED (change_masks, ACE_Event_Handler::QOS_MASK)) + ACE_SET_BITS (existing_masks, FD_QOS); + + if (ACE_BIT_ENABLED (change_masks, ACE_Event_Handler::GROUP_QOS_MASK)) + ACE_SET_BITS (existing_masks, FD_GROUP_QOS); + + break; + + case ACE_Reactor::GET_MASK: + + // The work for this operation is done in all cases at the + // begining of the function. + + ACE_UNUSED_ARG (change_masks); + + break; + } + + return old_masks; +} + +int +ACE_WFMO_Reactor_Handler_Repository::unbind_i (ACE_HANDLE handle, + ACE_Reactor_Mask mask, + bool &changes_required) +{ + int error = 0; + + // Remember this value; only if it changes do we need to wakeup + // the other threads + size_t const original_handle_count = this->handles_to_be_deleted_; + size_t i; + + // Go through all the handles looking for . Even if we find + // it, we continue through the rest of the list since could + // appear multiple times. All handles are checked. + + // First check the current entries + for (i = 0; i < this->max_handlep1_ && error == 0; ++i) + // Since the handle can either be the event or the I/O handle, + // we have to check both + if ((this->current_handles_[i] == handle + || this->current_info_[i].io_handle_ == handle) + && // Make sure that it is not already marked for deleted + !this->current_info_[i].delete_entry_) + { + if (this->remove_handler_i (i, mask) == -1) + error = 1; + } + + // Then check the suspended entries + for (i = 0; i < this->suspended_handles_ && error == 0; ++i) + // Since the handle can either be the event or the I/O handle, we + // have to check both + if ((this->current_suspended_info_[i].io_handle_ == handle + || this->current_suspended_info_[i].event_handle_ == handle) + && + // Make sure that it is not already marked for deleted + !this->current_suspended_info_[i].delete_entry_) + { + if (this->remove_suspended_handler_i (i, mask) == -1) + error = 1; + } + + // Then check the to_be_added entries + for (i = 0; i < this->handles_to_be_added_ && error == 0; ++i) + // Since the handle can either be the event or the I/O handle, + // we have to check both + if ((this->to_be_added_info_[i].io_handle_ == handle + || this->to_be_added_info_[i].event_handle_ == handle) + && + // Make sure that it is not already marked for deleted + !this->to_be_added_info_[i].delete_entry_) + { + if (this->remove_to_be_added_handler_i (i, mask) == -1) + error = 1; + } + + // Only if the number of handlers to be deleted changes do we need + // to wakeup the other threads + if (original_handle_count < this->handles_to_be_deleted_) + changes_required = true; + + return error ? -1 : 0; +} + +int +ACE_WFMO_Reactor_Handler_Repository::remove_handler_i (size_t slot, + ACE_Reactor_Mask to_be_removed_masks) +{ + // I/O entries + if (this->current_info_[slot].io_entry_) + { + // See if there are other events that the is + // interested in + this->bit_ops (this->current_info_[slot].network_events_, + to_be_removed_masks, + ACE_Reactor::CLR_MASK); + + // Disassociate/Reassociate the event from/with the I/O handle. + // This will depend on the value of remaining set of network + // events that the is interested in. I don't + // think we can do anything about errors here, so I will not + // check this. + ::WSAEventSelect ((SOCKET) this->current_info_[slot].io_handle_, + this->current_handles_[slot], + this->current_info_[slot].network_events_); + } + // Normal event entries. + else if (ACE_BIT_ENABLED (to_be_removed_masks, ACE_Event_Handler::DONT_CALL)) + // Preserve DONT_CALL + to_be_removed_masks = ACE_Event_Handler::DONT_CALL; + else + // Make sure that the is the NULL_MASK + to_be_removed_masks = ACE_Event_Handler::NULL_MASK; + + // If this event was marked for suspension, undo the suspension flag + // and reduce the to be suspended count. + if (this->current_info_[slot].suspend_entry_) + { + // Undo suspension + this->current_info_[slot].suspend_entry_ = false; + // Decrement the handle count + --this->handles_to_be_suspended_; + } + + // If there are no more events that the is + // interested in, or this is a non-I/O entry, schedule the + // for removal + if (this->current_info_[slot].network_events_ == 0) + { + // Mark to be deleted + this->current_info_[slot].delete_entry_ = true; + // Remember the mask + this->current_info_[slot].close_masks_ = to_be_removed_masks; + // Increment the handle count + ++this->handles_to_be_deleted_; + } + + // Since it is not a complete removal, we'll call handle_close + // for all the masks that were removed. This does not change + // the internal state of the reactor. + // + // Note: this condition only applies to I/O entries + else if (ACE_BIT_ENABLED (to_be_removed_masks, ACE_Event_Handler::DONT_CALL) == 0) + { + ACE_HANDLE handle = this->current_info_[slot].io_handle_; + this->current_info_[slot].event_handler_->handle_close (handle, + to_be_removed_masks); + } + + return 0; +} + +int +ACE_WFMO_Reactor_Handler_Repository::remove_suspended_handler_i (size_t slot, + ACE_Reactor_Mask to_be_removed_masks) +{ + // I/O entries + if (this->current_suspended_info_[slot].io_entry_) + { + // See if there are other events that the is + // interested in + this->bit_ops (this->current_suspended_info_[slot].network_events_, + to_be_removed_masks, + ACE_Reactor::CLR_MASK); + + // Disassociate/Reassociate the event from/with the I/O handle. + // This will depend on the value of remaining set of network + // events that the is interested in. I don't + // think we can do anything about errors here, so I will not + // check this. + ::WSAEventSelect ((SOCKET) this->current_suspended_info_[slot].io_handle_, + this->current_suspended_info_[slot].event_handle_, + this->current_suspended_info_[slot].network_events_); + } + // Normal event entries. + else if (ACE_BIT_ENABLED (to_be_removed_masks, ACE_Event_Handler::DONT_CALL)) + // Preserve DONT_CALL + to_be_removed_masks = ACE_Event_Handler::DONT_CALL; + else + // Make sure that the is the NULL_MASK + to_be_removed_masks = ACE_Event_Handler::NULL_MASK; + + // If this event was marked for resumption, undo the resumption flag + // and reduce the to be resumed count. + if (this->current_suspended_info_[slot].resume_entry_) + { + // Undo resumption + this->current_suspended_info_[slot].resume_entry_ = false; + // Decrement the handle count + --this->handles_to_be_resumed_; + } + + // If there are no more events that the is + // interested in, or this is a non-I/O entry, schedule the + // for removal + if (this->current_suspended_info_[slot].network_events_ == 0) + { + // Mark to be deleted + this->current_suspended_info_[slot].delete_entry_ = true; + // Remember the mask + this->current_suspended_info_[slot].close_masks_ = to_be_removed_masks; + // Increment the handle count + ++this->handles_to_be_deleted_; + } + // Since it is not a complete removal, we'll call handle_close for + // all the masks that were removed. This does not change the + // internal state of the reactor. + // + // Note: this condition only applies to I/O entries + else if (ACE_BIT_ENABLED (to_be_removed_masks, ACE_Event_Handler::DONT_CALL) == 0) + { + ACE_HANDLE handle = this->current_suspended_info_[slot].io_handle_; + this->current_suspended_info_[slot].event_handler_->handle_close (handle, + to_be_removed_masks); + } + + return 0; +} + +int +ACE_WFMO_Reactor_Handler_Repository::remove_to_be_added_handler_i (size_t slot, + ACE_Reactor_Mask to_be_removed_masks) +{ + // I/O entries + if (this->to_be_added_info_[slot].io_entry_) + { + // See if there are other events that the is + // interested in + this->bit_ops (this->to_be_added_info_[slot].network_events_, + to_be_removed_masks, + ACE_Reactor::CLR_MASK); + + // Disassociate/Reassociate the event from/with the I/O handle. + // This will depend on the value of remaining set of network + // events that the is interested in. I don't + // think we can do anything about errors here, so I will not + // check this. + ::WSAEventSelect ((SOCKET) this->to_be_added_info_[slot].io_handle_, + this->to_be_added_info_[slot].event_handle_, + this->to_be_added_info_[slot].network_events_); + } + // Normal event entries. + else if (ACE_BIT_ENABLED (to_be_removed_masks, ACE_Event_Handler::DONT_CALL)) + // Preserve DONT_CALL + to_be_removed_masks = ACE_Event_Handler::DONT_CALL; + else + // Make sure that the is the NULL_MASK + to_be_removed_masks = ACE_Event_Handler::NULL_MASK; + + // If this event was marked for suspension, undo the suspension flag + // and reduce the to be suspended count. + if (this->to_be_added_info_[slot].suspend_entry_) + { + // Undo suspension + this->to_be_added_info_[slot].suspend_entry_ = false; + // Decrement the handle count + --this->handles_to_be_suspended_; + } + + // If there are no more events that the is + // interested in, or this is a non-I/O entry, schedule the + // for removal + if (this->to_be_added_info_[slot].network_events_ == 0) + { + // Mark to be deleted + this->to_be_added_info_[slot].delete_entry_ = true; + // Remember the mask + this->to_be_added_info_[slot].close_masks_ = to_be_removed_masks; + // Increment the handle count + ++this->handles_to_be_deleted_; + } + // Since it is not a complete removal, we'll call handle_close + // for all the masks that were removed. This does not change + // the internal state of the reactor. + // + // Note: this condition only applies to I/O entries + else if (ACE_BIT_ENABLED (to_be_removed_masks, ACE_Event_Handler::DONT_CALL) == 0) + { + ACE_HANDLE handle = this->to_be_added_info_[slot].io_handle_; + this->to_be_added_info_[slot].event_handler_->handle_close (handle, + to_be_removed_masks); + } + + return 0; +} + +int +ACE_WFMO_Reactor_Handler_Repository::suspend_handler_i (ACE_HANDLE handle, + bool &changes_required) +{ + size_t i = 0; + + // Go through all the handles looking for . Even if we find + // it, we continue through the rest of the list since could + // appear multiple times. All handles are checked. + + // Check the current entries first. + for (i = 0; i < this->max_handlep1_; ++i) + // Since the handle can either be the event or the I/O handle, + // we have to check both + if ((this->current_handles_[i] == handle || + this->current_info_[i].io_handle_ == handle) && + // Make sure that it is not already marked for suspension + !this->current_info_[i].suspend_entry_) + { + // Mark to be suspended + this->current_info_[i].suspend_entry_ = true; + // Increment the handle count + ++this->handles_to_be_suspended_; + // Changes will be required + changes_required = true; + } + + // Then check the suspended entries. + for (i = 0; i < this->suspended_handles_; ++i) + // Since the handle can either be the event or the I/O handle, + // we have to check both + if ((this->current_suspended_info_[i].event_handle_ == handle || + this->current_suspended_info_[i].io_handle_ == handle) && + // Make sure that the resumption is not already undone + this->current_suspended_info_[i].resume_entry_) + { + // Undo resumption + this->current_suspended_info_[i].resume_entry_ = false; + // Decrement the handle count + --this->handles_to_be_resumed_; + // Changes will be required + changes_required = true; + } + + // Then check the to_be_added entries. + for (i = 0; i < this->handles_to_be_added_; ++i) + // Since the handle can either be the event or the I/O handle, + // we have to check both + if ((this->to_be_added_info_[i].io_handle_ == handle || + this->to_be_added_info_[i].event_handle_ == handle) && + // Make sure that it is not already marked for suspension + !this->to_be_added_info_[i].suspend_entry_) + { + // Mark to be suspended + this->to_be_added_info_[i].suspend_entry_ = true; + // Increment the handle count + ++this->handles_to_be_suspended_; + // Changes will be required + changes_required = true; + } + + return 0; +} + +int +ACE_WFMO_Reactor_Handler_Repository::resume_handler_i (ACE_HANDLE handle, + bool &changes_required) +{ + size_t i = 0; + + // Go through all the handles looking for . Even if we find + // it, we continue through the rest of the list since could + // appear multiple times. All handles are checked. + + // Check the current entries first. + for (i = 0; i < this->max_handlep1_; ++i) + // Since the handle can either be the event or the I/O handle, + // we have to check both + if ((this->current_handles_[i] == handle || + this->current_info_[i].io_handle_ == handle) && + // Make sure that the suspension is not already undone + this->current_info_[i].suspend_entry_) + { + // Undo suspension + this->current_info_[i].suspend_entry_ = false; + // Decrement the handle count + --this->handles_to_be_suspended_; + // Changes will be required + changes_required = true; + } + + // Then check the suspended entries. + for (i = 0; i < this->suspended_handles_; ++i) + // Since the handle can either be the event or the I/O handle, + // we have to check both + if ((this->current_suspended_info_[i].event_handle_ == handle || + this->current_suspended_info_[i].io_handle_ == handle) && + // Make sure that it is not already marked for resumption + !this->current_suspended_info_[i].resume_entry_) + { + // Mark to be resumed + this->current_suspended_info_[i].resume_entry_ = true; + // Increment the handle count + ++this->handles_to_be_resumed_; + // Changes will be required + changes_required = true; + } + + // Then check the to_be_added entries. + for (i = 0; i < this->handles_to_be_added_; ++i) + // Since the handle can either be the event or the I/O handle, + // we have to check both + if ((this->to_be_added_info_[i].io_handle_ == handle || + this->to_be_added_info_[i].event_handle_ == handle) && + // Make sure that the suspension is not already undone + this->to_be_added_info_[i].suspend_entry_) + { + // Undo suspension + this->to_be_added_info_[i].suspend_entry_ = false; + // Decrement the handle count + --this->handles_to_be_suspended_; + // Changes will be required + changes_required = true; + } + + return 0; +} + +void +ACE_WFMO_Reactor_Handler_Repository::unbind_all (void) +{ + { + ACE_GUARD (ACE_Process_Mutex, ace_mon, this->wfmo_reactor_.lock_); + + bool dummy; + size_t i; + + // Remove all the current handlers + for (i = 0; i < this->max_handlep1_; ++i) + this->unbind_i (this->current_handles_[i], + ACE_Event_Handler::ALL_EVENTS_MASK, + dummy); + + // Remove all the suspended handlers + for (i = 0; i < this->suspended_handles_; ++i) + this->unbind_i (this->current_suspended_info_[i].event_handle_, + ACE_Event_Handler::ALL_EVENTS_MASK, + dummy); + + // Remove all the to_be_added handlers + for (i = 0; i < this->handles_to_be_added_; ++i) + this->unbind_i (this->to_be_added_info_[i].event_handle_, + ACE_Event_Handler::ALL_EVENTS_MASK, + dummy); + } + + // The guard is released here + + // Wake up all threads in WaitForMultipleObjects so that they can + // reconsult the handle set + this->wfmo_reactor_.wakeup_all_threads (); +} + +int +ACE_WFMO_Reactor_Handler_Repository::bind_i (bool io_entry, + ACE_Event_Handler *event_handler, + long network_events, + ACE_HANDLE io_handle, + ACE_HANDLE event_handle, + bool delete_event) +{ + if (event_handler == 0) + return -1; + + // Make sure that the is valid + if (event_handle == ACE_INVALID_HANDLE) + event_handle = event_handler->get_handle (); + if (this->invalid_handle (event_handle)) + return -1; + + size_t current_size = this->max_handlep1_ + + this->handles_to_be_added_ - + this->handles_to_be_deleted_ + + this->suspended_handles_; + + // Make sure that there's room in the table and that total pending + // additions should not exceed what the array + // can hold. + if (current_size < this->max_size_ && + this->handles_to_be_added_ < this->max_size_) + { + // Cache this set into the , till we come + // around to actually adding this to the + this->to_be_added_info_[this->handles_to_be_added_].set (event_handle, + io_entry, + event_handler, + io_handle, + network_events, + delete_event); + + ++this->handles_to_be_added_; + + event_handler->add_reference (); + + // Wake up all threads in WaitForMultipleObjects so that they can + // reconsult the handle set + this->wfmo_reactor_.wakeup_all_threads (); + } + else + { + errno = EMFILE; // File descriptor table is full (better than nothing) + return -1; + } + + return 0; +} + +int +ACE_WFMO_Reactor_Handler_Repository::make_changes_in_current_infos (void) +{ + // Go through the entire valid array and check for all handles that + // have been schedule for deletion + if (this->handles_to_be_deleted_ > 0 || this->handles_to_be_suspended_ > 0) + { + size_t i = 0; + while (i < this->max_handlep1_) + { + // This stuff is necessary here, since we should not make + // the upcall until all the internal data structures have + // been updated. This is to protect against upcalls that + // try to deregister again. + ACE_HANDLE handle = ACE_INVALID_HANDLE; + ACE_Reactor_Mask masks = ACE_Event_Handler::NULL_MASK; + ACE_Event_Handler *event_handler = 0; + + // See if this entry is scheduled for deletion + if (this->current_info_[i].delete_entry_) + { + // Calling the method here will ensure that we + // will only call it once per deregistering . + // This is essential in the case when the will + // do something like delete itself and we have multiple + // threads in WFMO_Reactor. + // + // Make sure that the DONT_CALL mask is not set + masks = this->current_info_[i].close_masks_; + if (ACE_BIT_ENABLED (masks, ACE_Event_Handler::DONT_CALL) == 0) + { + // Grab the correct handle depending on the type entry + if (this->current_info_[i].io_entry_) + handle = this->current_info_[i].io_handle_; + else + handle = this->current_handles_[i]; + + // Event handler + event_handler = this->current_info_[i].event_handler_; + } + + // If created the event, we need to clean it up + if (this->current_info_[i].delete_event_) + ACE_OS::event_destroy (&this->current_handles_[i]); + + // Reduce count by one + --this->handles_to_be_deleted_; + } + + // See if this entry is scheduled for suspension + else if (this->current_info_[i].suspend_entry_) + { + this->current_suspended_info_ [this->suspended_handles_].set (this->current_handles_[i], + this->current_info_[i]); + // Increase number of suspended handles + ++this->suspended_handles_; + + // Reduce count by one + --this->handles_to_be_suspended_; + } + + // See if this entry is scheduled for deletion or suspension + // If so we need to clean up + if (this->current_info_[i].delete_entry_ || + this->current_info_[i].suspend_entry_ ) + { + size_t last_valid_slot = this->max_handlep1_ - 1; + // If this is the last handle in the set, no need to swap + // places. Simply remove it. + if (i < last_valid_slot) + // Swap this handle with the last valid handle + { + // Struct copy + this->current_info_[i] = + this->current_info_[last_valid_slot]; + this->current_handles_[i] = + this->current_handles_[last_valid_slot]; + } + // Reset the info in this slot + this->current_info_[last_valid_slot].reset (); + this->current_handles_[last_valid_slot] = ACE_INVALID_HANDLE; + --this->max_handlep1_; + } + else + { + // This current entry is not up for deletion or + // suspension. Proceed to the next entry in the current + // handles. + ++i; + } + + // Now that all internal structures have been updated, make + // the upcall. + if (event_handler != 0) + { + bool const requires_reference_counting = + event_handler->reference_counting_policy ().value () == + ACE_Event_Handler::Reference_Counting_Policy::ENABLED; + + event_handler->handle_close (handle, masks); + + if (requires_reference_counting) + { + event_handler->remove_reference (); + } + } + } + } + + return 0; +} + +int +ACE_WFMO_Reactor_Handler_Repository::make_changes_in_suspension_infos (void) +{ + // Go through the array + if (this->handles_to_be_deleted_ > 0 || this->handles_to_be_resumed_ > 0) + { + size_t i = 0; + while (i < this->suspended_handles_) + { + // This stuff is necessary here, since we should not make + // the upcall until all the internal data structures have + // been updated. This is to protect against upcalls that + // try to deregister again. + ACE_HANDLE handle = ACE_INVALID_HANDLE; + ACE_Reactor_Mask masks = ACE_Event_Handler::NULL_MASK; + ACE_Event_Handler *event_handler = 0; + + // See if this entry is scheduled for deletion + if (this->current_suspended_info_[i].delete_entry_) + { + // Calling the method here will ensure that we + // will only call it once per deregistering . + // This is essential in the case when the will + // do something like delete itself and we have multiple + // threads in WFMO_Reactor. + // + // Make sure that the DONT_CALL mask is not set + masks = this->current_suspended_info_[i].close_masks_; + if (ACE_BIT_ENABLED (masks, ACE_Event_Handler::DONT_CALL) == 0) + { + // Grab the correct handle depending on the type entry + if (this->current_suspended_info_[i].io_entry_) + handle = this->current_suspended_info_[i].io_handle_; + else + handle = this->current_suspended_info_[i].event_handle_; + + // Upcall + event_handler = this->current_suspended_info_[i].event_handler_; + } + + // If created the event, we need to clean it up + if (this->current_suspended_info_[i].delete_event_) + ACE_OS::event_destroy (&this->current_suspended_info_[i].event_handle_); + + // Reduce count by one + --this->handles_to_be_deleted_; + } + + else if (this->current_suspended_info_[i].resume_entry_) + { + // Add to the end of the current handles set + this->current_handles_[this->max_handlep1_] = this->current_suspended_info_[i].event_handle_; + // Struct copy + this->current_info_[this->max_handlep1_].set (this->current_suspended_info_[i]); + ++this->max_handlep1_; + + // Reduce count by one + --this->handles_to_be_resumed_; + } + + // If an entry needs to be removed, either because it + // was deleted or resumed, remove it now before doing + // the upcall. + if (this->current_suspended_info_[i].resume_entry_ || + this->current_suspended_info_[i].delete_entry_) + { + size_t last_valid_slot = this->suspended_handles_ - 1; + // Net effect is that we're removing an entry and + // compressing the list from the end. So, if removing + // an entry from the middle, copy the last valid one to the + // removed slot. Reset the end and decrement the number + // of suspended handles. + if (i < last_valid_slot) + // Struct copy + this->current_suspended_info_[i] = + this->current_suspended_info_[last_valid_slot]; + this->current_suspended_info_[last_valid_slot].reset (); + --this->suspended_handles_; + } + else + { + // This current entry is not up for deletion or + // resumption. Proceed to the next entry in the + // suspended handles. + ++i; + } + + // Now that all internal structures have been updated, make + // the upcall. + if (event_handler != 0) + { + int requires_reference_counting = + event_handler->reference_counting_policy ().value () == + ACE_Event_Handler::Reference_Counting_Policy::ENABLED; + + event_handler->handle_close (handle, masks); + + if (requires_reference_counting) + { + event_handler->remove_reference (); + } + } + } + } + + return 0; +} + +int +ACE_WFMO_Reactor_Handler_Repository::make_changes_in_to_be_added_infos (void) +{ + // Go through the arrays + for (size_t i = 0; i < this->handles_to_be_added_; ++i) + { + // This stuff is necessary here, since we should not make + // the upcall until all the internal data structures have + // been updated. This is to protect against upcalls that + // try to deregister again. + ACE_HANDLE handle = ACE_INVALID_HANDLE; + ACE_Reactor_Mask masks = ACE_Event_Handler::NULL_MASK; + ACE_Event_Handler *event_handler = 0; + + // See if this entry is scheduled for deletion + if (this->to_be_added_info_[i].delete_entry_) + { + // Calling the method here will ensure that we + // will only call it once per deregistering . + // This is essential in the case when the will + // do something like delete itself and we have multiple + // threads in WFMO_Reactor. + // + // Make sure that the DONT_CALL mask is not set + masks = this->to_be_added_info_[i].close_masks_; + if (ACE_BIT_ENABLED (masks, ACE_Event_Handler::DONT_CALL) == 0) + { + // Grab the correct handle depending on the type entry + if (this->to_be_added_info_[i].io_entry_) + handle = this->to_be_added_info_[i].io_handle_; + else + handle = this->to_be_added_info_[i].event_handle_; + + // Upcall + event_handler = this->to_be_added_info_[i].event_handler_; + } + + // If created the event, we need to clean it up + if (this->to_be_added_info_[i].delete_event_) + ACE_OS::event_destroy (&this->to_be_added_info_[i].event_handle_); + + // Reduce count by one + --this->handles_to_be_deleted_; + } + + // See if this entry is scheduled for suspension + else if (this->to_be_added_info_[i].suspend_entry_) + { + this->current_suspended_info_ [this->suspended_handles_].set (this->to_be_added_info_[i].event_handle_, + this->to_be_added_info_[i]); + // Increase number of suspended handles + ++this->suspended_handles_; + + // Reduce count by one + --this->handles_to_be_suspended_; + } + + // If neither of the two flags are on, add to current + else + { + // Add to the end of the current handles set + this->current_handles_[this->max_handlep1_] = this->to_be_added_info_[i].event_handle_; + // Struct copy + this->current_info_[this->max_handlep1_].set (this->to_be_added_info_[i]); + ++this->max_handlep1_; + } + + // Reset the + this->to_be_added_info_[i].reset (); + + // Now that all internal structures have been updated, make the + // upcall. + if (event_handler != 0) + { + int requires_reference_counting = + event_handler->reference_counting_policy ().value () == + ACE_Event_Handler::Reference_Counting_Policy::ENABLED; + + event_handler->handle_close (handle, masks); + + if (requires_reference_counting) + { + event_handler->remove_reference (); + } + } + } + + // Since all to be added handles have been taken care of, reset the + // counter + this->handles_to_be_added_ = 0; + + return 0; +} + +void +ACE_WFMO_Reactor_Handler_Repository::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + size_t i = 0; + + ACE_TRACE ("ACE_WFMO_Reactor_Handler_Repository::dump"); + + ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); + + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("Max size = %d\n"), + this->max_size_)); + + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("Current info table\n\n"))); + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("\tSize = %d\n"), + this->max_handlep1_)); + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("\tHandles to be suspended = %d\n"), + this->handles_to_be_suspended_)); + + for (i = 0; i < this->max_handlep1_; ++i) + this->current_info_[i].dump (this->current_handles_[i]); + + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("\n"))); + + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("To-be-added info table\n\n"))); + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("\tSize = %d\n"), + this->handles_to_be_added_)); + + for (i = 0; i < this->handles_to_be_added_; ++i) + this->to_be_added_info_[i].dump (); + + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("\n"))); + + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("Suspended info table\n\n"))); + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("\tSize = %d\n"), + this->suspended_handles_)); + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("\tHandles to be resumed = %d\n"), + this->handles_to_be_resumed_)); + + for (i = 0; i < this->suspended_handles_; ++i) + this->current_suspended_info_[i].dump (); + + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("\n"))); + + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("Total handles to be deleted = %d\n"), + this->handles_to_be_deleted_)); + + ACE_DEBUG ((LM_DEBUG, + ACE_END_DUMP)); +#endif /* ACE_HAS_DUMP */ +} + +/************************************************************/ + +int +ACE_WFMO_Reactor::work_pending (const ACE_Time_Value &) +{ + ACE_NOTSUP_RETURN (-1); +} + +#if defined (ACE_WIN32_VC8) +# pragma warning (push) +# pragma warning (disable:4355) /* Use of 'this' in initializer list */ +# endif +ACE_WFMO_Reactor::ACE_WFMO_Reactor (ACE_Sig_Handler *sh, + ACE_Timer_Queue *tq, + ACE_Reactor_Notify *notify) + : signal_handler_ (0), + delete_signal_handler_ (false), + timer_queue_ (0), + delete_timer_queue_ (false), + delete_handler_rep_ (false), + notify_handler_ (0), + delete_notify_handler_ (false), + lock_adapter_ (lock_), + handler_rep_ (*this), + // this event is initially signaled + ok_to_wait_ (1), + // this event is initially unsignaled + wakeup_all_threads_ (0), + // this event is initially unsignaled + waiting_to_change_state_ (0), + active_threads_ (0), + owner_ (ACE_Thread::self ()), + new_owner_ (0), + change_state_thread_ (0), + open_for_business_ (false), + deactivated_ (0) +{ + if (this->open (ACE_WFMO_Reactor::DEFAULT_SIZE, 0, sh, tq, 0, notify) == -1) + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("%p\n"), + ACE_TEXT ("WFMO_Reactor"))); +} + +ACE_WFMO_Reactor::ACE_WFMO_Reactor (size_t size, + int unused, + ACE_Sig_Handler *sh, + ACE_Timer_Queue *tq, + ACE_Reactor_Notify *notify) + : signal_handler_ (0), + delete_signal_handler_ (false), + timer_queue_ (0), + delete_timer_queue_ (false), + delete_handler_rep_ (false), + notify_handler_ (0), + delete_notify_handler_ (false), + lock_adapter_ (lock_), + handler_rep_ (*this), + // this event is initially signaled + ok_to_wait_ (1), + // this event is initially unsignaled + wakeup_all_threads_ (0), + // this event is initially unsignaled + waiting_to_change_state_ (0), + active_threads_ (0), + owner_ (ACE_Thread::self ()), + new_owner_ (0), + change_state_thread_ (0), + open_for_business_ (false), + deactivated_ (0) +{ + ACE_UNUSED_ARG (unused); + + if (this->open (size, 0, sh, tq, 0, notify) == -1) + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("%p\n"), + ACE_TEXT ("WFMO_Reactor"))); +} +#if defined (ACE_WIN32_VC8) +# pragma warning (pop) +#endif + +int +ACE_WFMO_Reactor::current_info (ACE_HANDLE, size_t &) +{ + return -1; +} + +int +ACE_WFMO_Reactor::open (size_t size, + int unused, + ACE_Sig_Handler *sh, + ACE_Timer_Queue *tq, + int disable_notify_pipe, + ACE_Reactor_Notify *notify) +{ + ACE_UNUSED_ARG (unused); + ACE_UNUSED_ARG (disable_notify_pipe); + + // This GUARD is necessary since we are updating shared state. + ACE_GUARD_RETURN (ACE_Process_Mutex, ace_mon, this->lock_, -1); + + // If we are already open, return -1 + if (this->open_for_business_) + return -1; + + // Timer Queue + if (this->delete_timer_queue_) + delete this->timer_queue_; + + if (tq == 0) + { + ACE_NEW_RETURN (this->timer_queue_, + ACE_Timer_Heap, + -1); + this->delete_timer_queue_ = true; + } + else + { + this->timer_queue_ = tq; + this->delete_timer_queue_ = false; + } + + // Signal Handler + if (this->delete_signal_handler_) + delete this->signal_handler_; + + if (sh == 0) + { + ACE_NEW_RETURN (this->signal_handler_, + ACE_Sig_Handler, + -1); + this->delete_signal_handler_ = true; + } + else + { + this->signal_handler_ = sh; + this->delete_signal_handler_ = false; + } + + // Setup the atomic wait array (used later in ) + this->atomic_wait_array_[0] = this->lock_.lock ().proc_mutex_; + this->atomic_wait_array_[1] = this->ok_to_wait_.handle (); + + // Prevent memory leaks when the ACE_WFMO_Reactor is reopened. + if (this->delete_handler_rep_) + { + if (this->handler_rep_.changes_required ()) + { + // Make necessary changes to the handler repository + this->handler_rep_.make_changes (); + // Turn off since all necessary changes + // have completed + this->wakeup_all_threads_.reset (); + } + + this->handler_rep_.~ACE_WFMO_Reactor_Handler_Repository (); + } + + // Open the handle repository. Two additional handles for internal + // purposes + if (this->handler_rep_.open (size + 2) == -1) + ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), + ACE_TEXT ("opening handler repository")), + -1); + else + this->delete_handler_rep_ = true; + + if (this->notify_handler_ != 0 && this->delete_notify_handler_) + delete this->notify_handler_; + + this->notify_handler_ = notify; + + if (this->notify_handler_ == 0) + { + ACE_NEW_RETURN (this->notify_handler_, + ACE_WFMO_Reactor_Notify, + -1); + + if (this->notify_handler_ == 0) + return -1; + else + this->delete_notify_handler_ = true; + } + + /* NOTE */ + // The order of the following two registrations is very important + + // Open the notification handler + if (this->notify_handler_->open (this, this->timer_queue_) == -1) + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("%p\n"), + ACE_TEXT ("opening notify handler ")), + -1); + + // Register for event + if (this->register_handler (&this->wakeup_all_threads_handler_, + this->wakeup_all_threads_.handle ()) == -1) + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("%p\n"), + ACE_TEXT ("registering thread wakeup handler")), + -1); + + // Since we have added two handles into the handler repository, + // update the + if (this->handler_rep_.changes_required ()) + { + // Make necessary changes to the handler repository + this->handler_rep_.make_changes (); + // Turn off since all necessary changes + // have completed + this->wakeup_all_threads_.reset (); + } + + // We are open for business + this->open_for_business_ = true; + + return 0; +} + +int +ACE_WFMO_Reactor::set_sig_handler (ACE_Sig_Handler *signal_handler) +{ + if (this->signal_handler_ != 0 && this->delete_signal_handler_) + delete this->signal_handler_; + this->signal_handler_ = signal_handler; + this->delete_signal_handler_ = false; + return 0; +} + +ACE_Timer_Queue * +ACE_WFMO_Reactor::timer_queue (void) const +{ + return this->timer_queue_; +} + +int +ACE_WFMO_Reactor::timer_queue (ACE_Timer_Queue *tq) +{ + if (this->timer_queue_ != 0 && this->delete_timer_queue_) + delete this->timer_queue_; + this->timer_queue_ = tq; + this->delete_timer_queue_ = false; + return 0; +} + +int +ACE_WFMO_Reactor::close (void) +{ + // This GUARD is necessary since we are updating shared state. + ACE_GUARD_RETURN (ACE_Process_Mutex, ace_mon, this->lock_, -1); + + // If we are already closed, return error + if (!this->open_for_business_) + return -1; + + // We are now closed + this->open_for_business_ = false; + // This will unregister all handles + this->handler_rep_.close (); + + return 0; +} + +ACE_WFMO_Reactor::~ACE_WFMO_Reactor (void) +{ + // Assumption: No threads are left in the Reactor when this method + // is called (i.e., active_threads_ == 0) + + // Close down + this->close (); + + // Make necessary changes to the handler repository that we caused + // by . + this->handler_rep_.make_changes (); + + if (this->delete_timer_queue_) + { + delete this->timer_queue_; + this->timer_queue_ = 0; + this->delete_timer_queue_ = false; + } + + if (this->delete_signal_handler_) + { + delete this->signal_handler_; + this->signal_handler_ = 0; + this->delete_signal_handler_ = false; + } + + if (this->delete_notify_handler_) + { + delete this->notify_handler_; + this->notify_handler_ = 0; + this->delete_notify_handler_ = false; + } +} + +int +ACE_WFMO_Reactor::register_handler_i (ACE_HANDLE event_handle, + ACE_HANDLE io_handle, + ACE_Event_Handler *event_handler, + ACE_Reactor_Mask new_masks) +{ + // If this is a Winsock 1 system, the underlying event assignment will + // not work, so don't try. Winsock 1 must use ACE_Select_Reactor for + // reacting to socket activity. + +#if !defined (ACE_HAS_WINSOCK2) || (ACE_HAS_WINSOCK2 == 0) + + ACE_UNUSED_ARG (event_handle); + ACE_UNUSED_ARG (io_handle); + ACE_UNUSED_ARG (event_handler); + ACE_UNUSED_ARG (new_masks); + ACE_NOTSUP_RETURN (-1); + +#else + + // Make sure that the is valid + if (io_handle == ACE_INVALID_HANDLE) + io_handle = event_handler->get_handle (); + + if (this->handler_rep_.invalid_handle (io_handle)) + { + errno = ERROR_INVALID_HANDLE; + return -1; + } + + long new_network_events = 0; + bool delete_event = false; + auto_ptr event; + + // Look up the repository to see if the is already + // there. + ACE_Reactor_Mask old_masks; + int found = this->handler_rep_.modify_network_events_i (io_handle, + new_masks, + old_masks, + new_network_events, + event_handle, + delete_event, + ACE_Reactor::ADD_MASK); + + // Check to see if the user passed us a valid event; If not then we + // need to create one + if (event_handle == ACE_INVALID_HANDLE) + { + // Note: don't change this since some C++ compilers have + // s that don't work properly... + auto_ptr tmp (new ACE_Auto_Event); + event = tmp; + event_handle = event->handle (); + delete_event = true; + } + + int result = ::WSAEventSelect ((SOCKET) io_handle, + event_handle, + new_network_events); + // If we had found the there is nothing more to do + if (found) + return result; + else if (result != SOCKET_ERROR && + this->handler_rep_.bind_i (1, + event_handler, + new_network_events, + io_handle, + event_handle, + delete_event) != -1) + { + // The was not found in the repository, add to + // the repository. + if (delete_event) + { + // Clear out the handle in the ACE_Auto_Event so that when + // it is destroyed, the handle isn't closed out from under + // the reactor. After setting it, running down the event + // (via auto_ptr<> event, above) at function return will + // cause an error because it'll try to close an invalid handle. + // To avoid that smashing the errno value, save the errno + // here, explicitly remove the event so the dtor won't do it + // again, then restore errno. + ACE_Errno_Guard guard (errno); + event->handle (ACE_INVALID_HANDLE); + event->remove (); + } + return 0; + } + else + return -1; + +#endif /* ACE_HAS_WINSOCK2 || ACE_HAS_WINSOCK2 == 0 */ + +} + +int +ACE_WFMO_Reactor::mask_ops_i (ACE_HANDLE io_handle, + ACE_Reactor_Mask new_masks, + int operation) +{ + // Make sure that the is valid + if (this->handler_rep_.invalid_handle (io_handle)) + return -1; + + long new_network_events = 0; + bool delete_event = false; + ACE_HANDLE event_handle = ACE_INVALID_HANDLE; + + // Look up the repository to see if the is already + // there. + ACE_Reactor_Mask old_masks; + int found = this->handler_rep_.modify_network_events_i (io_handle, + new_masks, + old_masks, + new_network_events, + event_handle, + delete_event, + operation); + if (found) + { + int result = ::WSAEventSelect ((SOCKET) io_handle, + event_handle, + new_network_events); + if (result == 0) + return old_masks; + else + return result; + } + else + return -1; +} + + + +int +ACE_WFMO_Reactor_Handler_Repository::modify_network_events_i (ACE_HANDLE io_handle, + ACE_Reactor_Mask new_masks, + ACE_Reactor_Mask &old_masks, + long &new_network_events, + ACE_HANDLE &event_handle, + bool &delete_event, + int operation) +{ + long *modified_network_events = &new_network_events; + int found = 0; + size_t i; + + // First go through the current entries + // + // Look for all entries in the current handles for matching handle + // (except those that have been scheduled for deletion) + for (i = 0; i < this->max_handlep1_ && !found; ++i) + if (io_handle == this->current_info_[i].io_handle_ && + !this->current_info_[i].delete_entry_) + { + found = 1; + modified_network_events = &this->current_info_[i].network_events_; + delete_event = this->current_info_[i].delete_event_; + event_handle = this->current_handles_[i]; + } + + // Then pass through the suspended handles + // + // Look for all entries in the suspended handles for matching handle + // (except those that have been scheduled for deletion) + for (i = 0; i < this->suspended_handles_ && !found; ++i) + if (io_handle == this->current_suspended_info_[i].io_handle_ && + !this->current_suspended_info_[i].delete_entry_) + { + found = 1; + modified_network_events = &this->current_suspended_info_[i].network_events_; + delete_event = this->current_suspended_info_[i].delete_event_; + event_handle = this->current_suspended_info_[i].event_handle_; + } + + // Then check the to_be_added handles + // + // Look for all entries in the to_be_added handles for matching + // handle (except those that have been scheduled for deletion) + for (i = 0; i < this->handles_to_be_added_ && !found; ++i) + if (io_handle == this->to_be_added_info_[i].io_handle_ && + !this->to_be_added_info_[i].delete_entry_) + { + found = 1; + modified_network_events = &this->to_be_added_info_[i].network_events_; + delete_event = this->to_be_added_info_[i].delete_event_; + event_handle = this->to_be_added_info_[i].event_handle_; + } + + old_masks = this->bit_ops (*modified_network_events, + new_masks, + operation); + + new_network_events = *modified_network_events; + + return found; +} + +ACE_Event_Handler * +ACE_WFMO_Reactor_Handler_Repository::find_handler (ACE_HANDLE handle) +{ + long existing_masks_ignored = 0; + return this->handler (handle, existing_masks_ignored); +} + +ACE_Event_Handler * +ACE_WFMO_Reactor_Handler_Repository::handler (ACE_HANDLE handle, + long &existing_masks) +{ + int found = 0; + size_t i = 0; + ACE_Event_Handler *event_handler = 0; + existing_masks = 0; + + // Look for the handle first + + // First go through the current entries + // + // Look for all entries in the current handles for matching handle + // (except those that have been scheduled for deletion) + for (i = 0; i < this->max_handlep1_ && !found; ++i) + if ((handle == this->current_info_[i].io_handle_ || + handle == this->current_handles_[i]) && + !this->current_info_[i].delete_entry_) + { + found = 1; + event_handler = this->current_info_[i].event_handler_; + existing_masks = this->current_info_[i].network_events_; + } + + // Then pass through the suspended handles + // + // Look for all entries in the suspended handles for matching handle + // (except those that have been scheduled for deletion) + for (i = 0; i < this->suspended_handles_ && !found; ++i) + if ((handle == this->current_suspended_info_[i].io_handle_ || + handle == this->current_suspended_info_[i].event_handle_) && + !this->current_suspended_info_[i].delete_entry_) + { + found = 1; + event_handler = this->current_suspended_info_[i].event_handler_; + existing_masks = this->current_suspended_info_[i].network_events_; + } + + // Then check the to_be_added handles + // + // Look for all entries in the to_be_added handles for matching + // handle (except those that have been scheduled for deletion) + for (i = 0; i < this->handles_to_be_added_ && !found; ++i) + if ((handle == this->to_be_added_info_[i].io_handle_ || + handle == this->to_be_added_info_[i].event_handle_) && + !this->to_be_added_info_[i].delete_entry_) + { + found = 1; + event_handler = this->to_be_added_info_[i].event_handler_; + existing_masks = this->to_be_added_info_[i].network_events_; + } + + if (event_handler) + event_handler->add_reference (); + + return event_handler; +} + +int +ACE_WFMO_Reactor_Handler_Repository::handler (ACE_HANDLE handle, + ACE_Reactor_Mask user_masks, + ACE_Event_Handler **user_event_handler) +{ + long existing_masks = 0; + int found = 0; + + ACE_Event_Handler_var safe_event_handler = + this->handler (handle, + existing_masks); + + if (safe_event_handler.handler ()) + found = 1; + + if (!found) + return -1; + + // Otherwise, make sure that the masks that the user is looking for + // are on. + if (found && + ACE_BIT_ENABLED (user_masks, ACE_Event_Handler::READ_MASK)) + if (!ACE_BIT_ENABLED (existing_masks, FD_READ) && + !ACE_BIT_ENABLED (existing_masks, FD_CLOSE)) + found = 0; + + if (found && + ACE_BIT_ENABLED (user_masks, ACE_Event_Handler::WRITE_MASK)) + if (!ACE_BIT_ENABLED (existing_masks, FD_WRITE)) + found = 0; + + if (found && + ACE_BIT_ENABLED (user_masks, ACE_Event_Handler::EXCEPT_MASK)) + if (!ACE_BIT_ENABLED (existing_masks, FD_OOB)) + found = 0; + + if (found && + ACE_BIT_ENABLED (user_masks, ACE_Event_Handler::ACCEPT_MASK)) + if (!ACE_BIT_ENABLED (existing_masks, FD_ACCEPT)) + found = 0; + + if (found && + ACE_BIT_ENABLED (user_masks, ACE_Event_Handler::CONNECT_MASK)) + if (!ACE_BIT_ENABLED (existing_masks, FD_CONNECT)) + found = 0; + + if (found && + ACE_BIT_ENABLED (user_masks, ACE_Event_Handler::QOS_MASK)) + if (!ACE_BIT_ENABLED (existing_masks, FD_QOS)) + found = 0; + + if (found && + ACE_BIT_ENABLED (user_masks, ACE_Event_Handler::GROUP_QOS_MASK)) + if (!ACE_BIT_ENABLED (existing_masks, FD_GROUP_QOS)) + found = 0; + + if (found && + user_event_handler) + *user_event_handler = safe_event_handler.release (); + + if (found) + return 0; + else + return -1; +} + +// Waits for and dispatches all events. Returns -1 on error, 0 if +// max_wait_time expired, or the number of events that were dispatched. +int +ACE_WFMO_Reactor::event_handling (ACE_Time_Value *max_wait_time, + int alertable) +{ + ACE_TRACE ("ACE_WFMO_Reactor::event_handling"); + + // Make sure we are not closed + if (!this->open_for_business_ || this->deactivated_) + return -1; + + // Stash the current time -- the destructor of this object will + // automatically compute how much time elapsed since this method was + // called. + ACE_Countdown_Time countdown (max_wait_time); + + int result; + do + { + // Check to see if it is ok to enter ::WaitForMultipleObjects + // This will acquire lock_> on success On failure, the + // lock will not be acquired + result = this->ok_to_wait (max_wait_time, alertable); + if (result != 1) + return result; + + // Increment the number of active threads + ++this->active_threads_; + + // Release the + this->lock_.release (); + + // Update the countdown to reflect time waiting to play with the + // mut and event. + countdown.update (); + + // Calculate timeout + int timeout = this->calculate_timeout (max_wait_time); + + // Wait for event to happen + DWORD wait_status = this->wait_for_multiple_events (timeout, + alertable); + + // Upcall + result = this->safe_dispatch (wait_status); + if (0 == result) + { + // wait_for_multiple_events timed out without dispatching + // anything. Because of rounding and conversion errors and + // such, it could be that the wait loop timed out, but + // the timer queue said it wasn't quite ready to expire a + // timer. In this case, max_wait_time won't have quite been + // reduced to 0, and we need to go around again. If max_wait_time + // is all the way to 0, just return, as the entire time the + // caller wanted to wait has been used up. + countdown.update (); // Reflect time waiting for events + if (0 == max_wait_time || max_wait_time->usec () == 0) + break; + } + } + while (result == 0); + + return result; +} + +int +ACE_WFMO_Reactor::ok_to_wait (ACE_Time_Value *max_wait_time, + int alertable) +{ + // Calculate the max time we should spend here + // + // Note: There is really no need to involve the here + // because even if a timeout in the does expire we + // will not be able to dispatch it + + // We need to wait for both the and event. + // If not on WinCE, use WaitForMultipleObjects() to wait for both atomically. + // On WinCE, the waitAll arg to WFMO must be false, so wait for the + // ok_to_wait_ event first (since that's likely to take the longest) then + // grab the lock and recheck the ok_to_wait_ event. When we can get them + // both, or there's an error/timeout, return. +#if defined (ACE_HAS_WINCE) + ACE_Time_Value timeout = ACE_OS::gettimeofday (); + if (max_wait_time != 0) + timeout += *max_wait_time; + while (1) + { + int status; + if (max_wait_time == 0) + status = this->ok_to_wait_.wait (); + else + status = this->ok_to_wait_.wait (&timeout); + if (status == -1) + return -1; + // The event is signaled, so it's ok to wait; grab the lock and + // recheck the event. If something has changed, restart the wait. + if (max_wait_time == 0) + status = this->lock_.acquire (); + else + status = this->lock_.acquire (timeout); + if (status == -1) + return -1; + + // Have the lock_, now re-check the event. If it's not signaled, + // another thread changed something so go back and wait again. + ACE_Time_Value poll_it = ACE_OS::gettimeofday (); + if (this->ok_to_wait_.wait (&poll_it) == 0) + break; + this->lock_.release (); + } + return 1; + +#else + int timeout = max_wait_time == 0 ? INFINITE : max_wait_time->msec (); + DWORD result = 0; + while (1) + { +# if defined (ACE_HAS_PHARLAP) + // PharLap doesn't implement WaitForMultipleObjectsEx, and doesn't + // do async I/O, so it's not needed in this case anyway. + result = ::WaitForMultipleObjects (sizeof this->atomic_wait_array_ / sizeof (ACE_HANDLE), + this->atomic_wait_array_, + TRUE, + timeout); + + if (result != WAIT_IO_COMPLETION) + break; + +# else + result = ::WaitForMultipleObjectsEx (sizeof this->atomic_wait_array_ / sizeof (ACE_HANDLE), + this->atomic_wait_array_, + TRUE, + timeout, + alertable); + + if (result != WAIT_IO_COMPLETION) + break; + +# endif /* ACE_HAS_PHARLAP */ + } + + switch (result) + { + case WAIT_TIMEOUT: + errno = ETIME; + return 0; + case WAIT_FAILED: + case WAIT_ABANDONED_0: + ACE_OS::set_errno_to_last_error (); + return -1; + default: + break; + } + + // It is ok to enter ::WaitForMultipleObjects + return 1; +#endif /* ACE_HAS_WINCE */ +} + +DWORD +ACE_WFMO_Reactor::wait_for_multiple_events (int timeout, + int alertable) +{ + // Wait for any of handles_ to be active, or until timeout expires. + // If is enabled allow asynchronous completion of + // ReadFile and WriteFile operations. + +#if defined (ACE_HAS_PHARLAP) || defined (ACE_HAS_WINCE) + // PharLap doesn't do async I/O and doesn't implement + // WaitForMultipleObjectsEx, so use WaitForMultipleObjects. + ACE_UNUSED_ARG (alertable); + return ::WaitForMultipleObjects (this->handler_rep_.max_handlep1 (), + this->handler_rep_.handles (), + FALSE, + timeout); +#else + return ::WaitForMultipleObjectsEx (this->handler_rep_.max_handlep1 (), + this->handler_rep_.handles (), + FALSE, + timeout, + alertable); +#endif /* ACE_HAS_PHARLAP */ +} + +DWORD +ACE_WFMO_Reactor::poll_remaining_handles (DWORD slot) +{ + return ::WaitForMultipleObjects (this->handler_rep_.max_handlep1 () - slot, + this->handler_rep_.handles () + slot, + FALSE, + 0); +} + +int +ACE_WFMO_Reactor::calculate_timeout (ACE_Time_Value *max_wait_time) +{ + ACE_Time_Value *time = 0; + if (this->owner_ == ACE_Thread::self ()) + time = this->timer_queue_->calculate_timeout (max_wait_time); + else + time = max_wait_time; + + if (time == 0) + return INFINITE; + else + return time->msec (); +} + + +int +ACE_WFMO_Reactor::expire_timers (void) +{ + // If "owner" thread + if (ACE_Thread::self () == this->owner_) + // expire all pending timers. + return this->timer_queue_->expire (); + + else + // Nothing to expire + return 0; +} + +int +ACE_WFMO_Reactor::dispatch (DWORD wait_status) +{ + int handlers_dispatched = 0; + + // Expire timers + handlers_dispatched += this->expire_timers (); + + switch (wait_status) + { + case WAIT_FAILED: // Failure. + ACE_OS::set_errno_to_last_error (); + return -1; + + case WAIT_TIMEOUT: // Timeout. + errno = ETIME; + return handlers_dispatched; + +#ifndef ACE_HAS_WINCE + case WAIT_IO_COMPLETION: // APC. + return handlers_dispatched; +#endif // ACE_HAS_WINCE + + default: // Dispatch. + // We'll let dispatch worry about abandoned mutes. + handlers_dispatched += this->dispatch_handles (wait_status); + return handlers_dispatched; + } +} + +// Dispatches any active handles from to +// , polling through our handle set looking +// for active handles. +int +ACE_WFMO_Reactor::dispatch_handles (DWORD wait_status) +{ + // dispatch_slot is the absolute slot. Only += is used to + // increment it. + DWORD dispatch_slot = 0; + + // Cache this value, this is the absolute value. + DWORD max_handlep1 = this->handler_rep_.max_handlep1 (); + + // nCount starts off at , this is a transient count of + // handles last waited on. + DWORD nCount = max_handlep1; + + for (int number_of_handlers_dispatched = 1; + ; + ++number_of_handlers_dispatched) + { + const bool ok = ( +#if ! defined(__BORLANDC__) \ + && !defined (ghs) \ + && !defined (__MINGW32__) \ + && !(defined (_MSC_VER) && _MSC_VER >= 1300) + // wait_status is unsigned in Borland, Green Hills, + // mingw32 and MSVC++ >= 7.1. + // This >= is always true, with a warning. + wait_status >= WAIT_OBJECT_0 && +#endif + wait_status <= (WAIT_OBJECT_0 + nCount)); + + if (ok) + dispatch_slot += wait_status - WAIT_OBJECT_0; + else + // Otherwise, a handle was abandoned. + dispatch_slot += wait_status - WAIT_ABANDONED_0; + + // Dispatch handler + if (this->dispatch_handler (dispatch_slot, max_handlep1) == -1) + return -1; + + // Increment slot + ++dispatch_slot; + + // We're done. + if (dispatch_slot >= max_handlep1) + return number_of_handlers_dispatched; + + // Readjust nCount + nCount = max_handlep1 - dispatch_slot; + + // Check the remaining handles + wait_status = this->poll_remaining_handles (dispatch_slot); + switch (wait_status) + { + case WAIT_FAILED: // Failure. + ACE_OS::set_errno_to_last_error (); + /* FALLTHRU */ + case WAIT_TIMEOUT: + // There are no more handles ready, we can return. + return number_of_handlers_dispatched; + } + } +} + +int +ACE_WFMO_Reactor::dispatch_handler (DWORD slot, + DWORD max_handlep1) +{ + // Check if there are window messages that need to be dispatched + if (slot == max_handlep1) + return this->dispatch_window_messages (); + + // Dispatch the handler if it has not been scheduled for deletion. + // Note that this is a very week test if there are multiple threads + // dispatching this slot as no locks are held here. Generally, you + // do not want to do something like deleting the this pointer in + // handle_close() if you have registered multiple times and there is + // more than one thread in WFMO_Reactor->handle_events(). + else if (!this->handler_rep_.scheduled_for_deletion (slot)) + { + ACE_HANDLE event_handle = *(this->handler_rep_.handles () + slot); + + if (this->handler_rep_.current_info ()[slot].io_entry_) + return this->complex_dispatch_handler (slot, + event_handle); + else + return this->simple_dispatch_handler (slot, + event_handle); + } + else + // The handle was scheduled for deletion, so we will skip it. + return 0; +} + +int +ACE_WFMO_Reactor::simple_dispatch_handler (DWORD slot, + ACE_HANDLE event_handle) +{ + // This dispatch is used for non-I/O entires + + // Assign the ``signaled'' HANDLE so that callers can get it. + // siginfo_t is an ACE - specific fabrication. Constructor exists. + siginfo_t sig (event_handle); + + ACE_Event_Handler *event_handler = + this->handler_rep_.current_info ()[slot].event_handler_; + + int requires_reference_counting = + event_handler->reference_counting_policy ().value () == + ACE_Event_Handler::Reference_Counting_Policy::ENABLED; + + if (requires_reference_counting) + { + event_handler->add_reference (); + } + + // Upcall + if (event_handler->handle_signal (0, &sig) == -1) + this->handler_rep_.unbind (event_handle, + ACE_Event_Handler::NULL_MASK); + + // Call remove_reference() if needed. + if (requires_reference_counting) + { + event_handler->remove_reference (); + } + + return 0; +} + +int +ACE_WFMO_Reactor::complex_dispatch_handler (DWORD slot, + ACE_HANDLE event_handle) +{ + // This dispatch is used for I/O entires. + + ACE_WFMO_Reactor_Handler_Repository::Current_Info ¤t_info = + this->handler_rep_.current_info ()[slot]; + + WSANETWORKEVENTS events; + ACE_Reactor_Mask problems = ACE_Event_Handler::NULL_MASK; + if (::WSAEnumNetworkEvents ((SOCKET) current_info.io_handle_, + event_handle, + &events) == SOCKET_ERROR) + problems = ACE_Event_Handler::ALL_EVENTS_MASK; + else + { + // Prepare for upcalls. Clear the bits from representing + // events the handler is not interested in. If there are any left, + // do the upcall(s). upcall will replace events.lNetworkEvents + // with bits representing any functions that requested a repeat + // callback before checking handles again. In this case, continue + // to call back unless the handler is unregistered as a result of + // one of the upcalls. The way this is written, the upcalls will + // keep being done even if one or more upcalls reported problems. + // In practice this may turn out not so good, but let's see. If any + // problems, please notify Steve Huston + // before or after you change this code. + events.lNetworkEvents &= current_info.network_events_; + while (events.lNetworkEvents != 0) + { + ACE_Event_Handler *event_handler = + current_info.event_handler_; + + int reference_counting_required = + event_handler->reference_counting_policy ().value () == + ACE_Event_Handler::Reference_Counting_Policy::ENABLED; + + // Call add_reference() if needed. + if (reference_counting_required) + { + event_handler->add_reference (); + } + + // Upcall + problems |= this->upcall (current_info.event_handler_, + current_info.io_handle_, + events); + + // Call remove_reference() if needed. + if (reference_counting_required) + { + event_handler->remove_reference (); + } + + if (this->handler_rep_.scheduled_for_deletion (slot)) + break; + } + } + + if (problems != ACE_Event_Handler::NULL_MASK + && !this->handler_rep_.scheduled_for_deletion (slot) ) + this->handler_rep_.unbind (event_handle, problems); + + return 0; +} + +ACE_Reactor_Mask +ACE_WFMO_Reactor::upcall (ACE_Event_Handler *event_handler, + ACE_HANDLE io_handle, + WSANETWORKEVENTS &events) +{ + // This method figures out what exactly has happened to the socket + // and then calls appropriate methods. + ACE_Reactor_Mask problems = ACE_Event_Handler::NULL_MASK; + + // Go through the events and do the indicated upcalls. If the handler + // doesn't want to be called back, clear the bit for that event. + // At the end, set the bits back to to request a repeat call. + + long actual_events = events.lNetworkEvents; + int action; + + if (ACE_BIT_ENABLED (actual_events, FD_WRITE)) + { + action = event_handler->handle_output (io_handle); + if (action <= 0) + { + ACE_CLR_BITS (actual_events, FD_WRITE); + if (action == -1) + ACE_SET_BITS (problems, ACE_Event_Handler::WRITE_MASK); + } + } + + if (ACE_BIT_ENABLED (actual_events, FD_CONNECT)) + { + if (events.iErrorCode[FD_CONNECT_BIT] == 0) + { + // Successful connect + action = event_handler->handle_output (io_handle); + if (action <= 0) + { + ACE_CLR_BITS (actual_events, FD_CONNECT); + if (action == -1) + ACE_SET_BITS (problems, + ACE_Event_Handler::CONNECT_MASK); + } + } + // Unsuccessful connect + else + { + action = event_handler->handle_input (io_handle); + if (action <= 0) + { + ACE_CLR_BITS (actual_events, FD_CONNECT); + if (action == -1) + ACE_SET_BITS (problems, + ACE_Event_Handler::CONNECT_MASK); + } + } + } + + if (ACE_BIT_ENABLED (actual_events, FD_OOB)) + { + action = event_handler->handle_exception (io_handle); + if (action <= 0) + { + ACE_CLR_BITS (actual_events, FD_OOB); + if (action == -1) + ACE_SET_BITS (problems, ACE_Event_Handler::EXCEPT_MASK); + } + } + + if (ACE_BIT_ENABLED (actual_events, FD_READ)) + { + action = event_handler->handle_input (io_handle); + if (action <= 0) + { + ACE_CLR_BITS (actual_events, FD_READ); + if (action == -1) + ACE_SET_BITS (problems, ACE_Event_Handler::READ_MASK); + } + } + + if (ACE_BIT_ENABLED (actual_events, FD_CLOSE) + && ACE_BIT_DISABLED (problems, ACE_Event_Handler::READ_MASK)) + { + action = event_handler->handle_input (io_handle); + if (action <= 0) + { + ACE_CLR_BITS (actual_events, FD_CLOSE); + if (action == -1) + ACE_SET_BITS (problems, ACE_Event_Handler::READ_MASK); + } + } + + if (ACE_BIT_ENABLED (actual_events, FD_ACCEPT)) + { + action = event_handler->handle_input (io_handle); + if (action <= 0) + { + ACE_CLR_BITS (actual_events, FD_ACCEPT); + if (action == -1) + ACE_SET_BITS (problems, ACE_Event_Handler::ACCEPT_MASK); + } + } + + if (ACE_BIT_ENABLED (actual_events, FD_QOS)) + { + action = event_handler->handle_qos (io_handle); + if (action <= 0) + { + ACE_CLR_BITS (actual_events, FD_QOS); + if (action == -1) + ACE_SET_BITS (problems, ACE_Event_Handler::QOS_MASK); + } + } + + if (ACE_BIT_ENABLED (actual_events, FD_GROUP_QOS)) + { + action = event_handler->handle_group_qos (io_handle); + if (action <= 0) + { + ACE_CLR_BITS (actual_events, FD_GROUP_QOS); + if (action == -1) + ACE_SET_BITS (problems, ACE_Event_Handler::GROUP_QOS_MASK); + } + } + + events.lNetworkEvents = actual_events; + return problems; +} + + +int +ACE_WFMO_Reactor::update_state (void) +{ + // This GUARD is necessary since we are updating shared state. + ACE_GUARD_RETURN (ACE_Process_Mutex, monitor, this->lock_, -1); + + // Decrement active threads + --this->active_threads_; + + // Check if the state of the handler repository has changed or new + // owner has to be set + if (this->handler_rep_.changes_required () || this->new_owner ()) + { + if (this->change_state_thread_ == 0) + // Try to become the thread which will be responsible for the + // changes + { + this->change_state_thread_ = ACE_Thread::self (); + // Make sure no new threads are allowed to enter + this->ok_to_wait_.reset (); + + if (this->active_threads_ > 0) + // Check for other active threads + { + // Wake up all other threads + this->wakeup_all_threads_.signal (); + // Release + monitor.release (); + // Go to sleep waiting for all other threads to get done + this->waiting_to_change_state_.wait (); + // Re-acquire again + monitor.acquire (); + } + + // Note that make_changes() calls into user code which can + // request other changes. So keep looping until all + // requested changes are completed. + while (this->handler_rep_.changes_required ()) + // Make necessary changes to the handler repository + this->handler_rep_.make_changes (); + if (this->new_owner ()) + // Update the owner + this->change_owner (); + // Turn off + this->wakeup_all_threads_.reset (); + // Let everyone know that it is ok to go ahead + this->ok_to_wait_.signal (); + // Reset this flag + this->change_state_thread_ = 0; + } + else if (this->active_threads_ == 0) + // This thread did not get a chance to become the change + // thread. If it is the last one out, it will wakeup the + // change thread + this->waiting_to_change_state_.signal (); + } + // This is if we were woken up explicitily by the user and there are + // no state changes required. + else if (this->active_threads_ == 0) + // Turn off + this->wakeup_all_threads_.reset (); + + return 0; +} + +void +ACE_WFMO_Reactor::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + ACE_TRACE ("ACE_WFMO_Reactor::dump"); + + ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); + + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("Count of currently active threads = %d\n"), + this->active_threads_)); + + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("ID of owner thread = %d\n"), + this->owner_)); + + this->handler_rep_.dump (); + this->signal_handler_->dump (); + this->timer_queue_->dump (); + + ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); +#endif /* ACE_HAS_DUMP */ +} + +int +ACE_WFMO_Reactor_Notify::dispatch_notifications (int & /*number_of_active_handles*/, + ACE_Handle_Set & /*rd_mask*/) +{ + return -1; +} + +int +ACE_WFMO_Reactor_Notify::is_dispatchable (ACE_Notification_Buffer & /*buffer*/) +{ + return 0; +} + +ACE_HANDLE +ACE_WFMO_Reactor_Notify::notify_handle (void) +{ + return ACE_INVALID_HANDLE; +} + +int +ACE_WFMO_Reactor_Notify::read_notify_pipe (ACE_HANDLE , + ACE_Notification_Buffer &) +{ + return 0; +} + +int +ACE_WFMO_Reactor_Notify::dispatch_notify (ACE_Notification_Buffer &) +{ + return 0; +} + +int +ACE_WFMO_Reactor_Notify::close (void) +{ + return -1; +} + +ACE_WFMO_Reactor_Notify::ACE_WFMO_Reactor_Notify (size_t max_notifies) + : timer_queue_ (0), + message_queue_ (max_notifies * sizeof (ACE_Notification_Buffer), + max_notifies * sizeof (ACE_Notification_Buffer)), + max_notify_iterations_ (-1) +{ +} + +int +ACE_WFMO_Reactor_Notify::open (ACE_Reactor_Impl *wfmo_reactor, + ACE_Timer_Queue *timer_queue, + int ignore_notify) +{ + ACE_UNUSED_ARG (ignore_notify); + timer_queue_ = timer_queue; + return wfmo_reactor->register_handler (this); +} + +ACE_HANDLE +ACE_WFMO_Reactor_Notify::get_handle (void) const +{ + return this->wakeup_one_thread_.handle (); +} + +// Handle all pending notifications. + +int +ACE_WFMO_Reactor_Notify::handle_signal (int signum, + siginfo_t *siginfo, + ucontext_t *) +{ + ACE_UNUSED_ARG (signum); + + // Just check for sanity... + if (siginfo->si_handle_ != this->wakeup_one_thread_.handle ()) + return -1; + + // This will get called when wakeup_one_thread_> event + // is signaled. + // ACE_DEBUG ((LM_DEBUG, + // ACE_TEXT ("(%t) waking up to handle internal notifications\n"))); + + for (int i = 1; ; ++i) + { + ACE_Message_Block *mb = 0; + // Copy ACE_Time_Value::zero since dequeue_head will modify it. + ACE_Time_Value zero_timeout (ACE_Time_Value::zero); + if (this->message_queue_.dequeue_head (mb, &zero_timeout) == -1) + { + if (errno == EWOULDBLOCK) + // We've reached the end of the processing, return + // normally. + return 0; + else + return -1; // Something weird happened... + } + else + { + ACE_Notification_Buffer *buffer = + reinterpret_cast (mb->base ()); + + // If eh == 0 then we've got major problems! Otherwise, we + // need to dispatch the appropriate handle_* method on the + // ACE_Event_Handler pointer we've been passed. + + if (buffer->eh_ != 0) + { + ACE_Event_Handler *event_handler = + buffer->eh_; + + bool const requires_reference_counting = + event_handler->reference_counting_policy ().value () == + ACE_Event_Handler::Reference_Counting_Policy::ENABLED; + + int result = 0; + + switch (buffer->mask_) + { + case ACE_Event_Handler::READ_MASK: + case ACE_Event_Handler::ACCEPT_MASK: + result = event_handler->handle_input (ACE_INVALID_HANDLE); + break; + case ACE_Event_Handler::WRITE_MASK: + result = event_handler->handle_output (ACE_INVALID_HANDLE); + break; + case ACE_Event_Handler::EXCEPT_MASK: + result = event_handler->handle_exception (ACE_INVALID_HANDLE); + break; + case ACE_Event_Handler::QOS_MASK: + result = event_handler->handle_qos (ACE_INVALID_HANDLE); + break; + case ACE_Event_Handler::GROUP_QOS_MASK: + result = event_handler->handle_group_qos (ACE_INVALID_HANDLE); + break; + default: + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("invalid mask = %d\n"), + buffer->mask_)); + break; + } + + if (result == -1) + event_handler->handle_close (ACE_INVALID_HANDLE, + ACE_Event_Handler::EXCEPT_MASK); + + if (requires_reference_counting) + { + event_handler->remove_reference (); + } + } + + // Make sure to delete the memory regardless of success or + // failure! + mb->release (); + + // Bail out if we've reached the . + // Note that by default is -1, so + // we'll loop until we're done. + if (i == this->max_notify_iterations_) + { + // If there are still notification in the queue, we need + // to wake up again + if (!this->message_queue_.is_empty ()) + this->wakeup_one_thread_.signal (); + + // Break the loop as we have reached max_notify_iterations_ + return 0; + } + } + } +} + +// Notify the WFMO_Reactor, potentially enqueueing the +// for subsequent processing in the WFMO_Reactor +// thread of control. + +int +ACE_WFMO_Reactor_Notify::notify (ACE_Event_Handler *event_handler, + ACE_Reactor_Mask mask, + ACE_Time_Value *timeout) +{ + if (event_handler != 0) + { + ACE_Message_Block *mb = 0; + ACE_NEW_RETURN (mb, + ACE_Message_Block (sizeof (ACE_Notification_Buffer)), + -1); + + ACE_Notification_Buffer *buffer = + (ACE_Notification_Buffer *) mb->base (); + buffer->eh_ = event_handler; + buffer->mask_ = mask; + + // Convert from relative time to absolute time by adding the + // current time of day. This is what + // expects. + if (timeout != 0) + *timeout += timer_queue_->gettimeofday (); + + if (this->message_queue_.enqueue_tail + (mb, timeout) == -1) + { + mb->release (); + return -1; + } + + event_handler->add_reference (); + } + + return this->wakeup_one_thread_.signal (); +} + +void +ACE_WFMO_Reactor_Notify::max_notify_iterations (int iterations) +{ + ACE_TRACE ("ACE_WFMO_Reactor_Notify::max_notify_iterations"); + // Must always be > 0 or < 0 to optimize the loop exit condition. + if (iterations == 0) + iterations = 1; + + this->max_notify_iterations_ = iterations; +} + +int +ACE_WFMO_Reactor_Notify::max_notify_iterations (void) +{ + ACE_TRACE ("ACE_WFMO_Reactor_Notify::max_notify_iterations"); + return this->max_notify_iterations_; +} + +int +ACE_WFMO_Reactor_Notify::purge_pending_notifications (ACE_Event_Handler *eh, + ACE_Reactor_Mask mask) +{ + ACE_TRACE ("ACE_WFMO_Reactor_Notify::purge_pending_notifications"); + + // Go over message queue and take out all the matching event + // handlers. If eh == 0, purge all. Note that reactor notifies (no + // handler specified) are never purged, as this may lose a needed + // notify the reactor queued for itself. + + if (this->message_queue_.is_empty ()) + return 0; + + // Guard against new and/or delivered notifications while purging. + // WARNING!!! The use of the notification queue's lock object for + // this guard makes use of the knowledge that on Win32, the mutex + // protecting the queue is really a CriticalSection, which is + // recursive. This is how we can get away with locking it down here + // and still calling member functions on the queue object. + ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, monitor, this->message_queue_.lock(), -1); + + // first, copy all to our own local queue. Since we've locked everyone out + // of here, there's no need to use any synchronization on this queue. + ACE_Message_Queue local_queue; + + size_t queue_size = this->message_queue_.message_count (); + int number_purged = 0; + + size_t index; + + for (index = 0; index < queue_size; ++index) + { + ACE_Message_Block *mb = 0; + if (-1 == this->message_queue_.dequeue_head (mb)) + return -1; // This shouldn't happen... + + ACE_Notification_Buffer *buffer = + reinterpret_cast (mb->base ()); + + // If this is not a Reactor notify (it is for a particular handler), + // and it matches the specified handler (or purging all), + // and applying the mask would totally eliminate the notification, then + // release it and count the number purged. + if ((0 != buffer->eh_) && + (0 == eh || eh == buffer->eh_) && + ACE_BIT_DISABLED (buffer->mask_, ~mask)) // the existing notification mask + // is left with nothing when + // applying the mask + { + ACE_Event_Handler *event_handler = buffer->eh_; + + event_handler->remove_reference (); + + mb->release (); + ++number_purged; + } + else + { + // To preserve it, move it to the local_queue. But first, if + // this is not a Reactor notify (it is for a + // particularhandler), and it matches the specified handler + // (or purging all), then apply the mask + if ((0 != buffer->eh_) && + (0 == eh || eh == buffer->eh_)) + ACE_CLR_BITS(buffer->mask_, mask); + if (-1 == local_queue.enqueue_head (mb)) + return -1; + } + } + + if (this->message_queue_.message_count ()) + { // Should be empty! + ACE_ASSERT (0); + return -1; + } + + // Now copy back from the local queue to the class queue, taking + // care to preserve the original order... + queue_size = local_queue.message_count (); + for (index = 0; index < queue_size; ++index) + { + ACE_Message_Block *mb = 0; + if (-1 == local_queue.dequeue_head (mb)) + { + ACE_ASSERT (0); + return -1; + } + + if (-1 == this->message_queue_.enqueue_head (mb)) + { + ACE_ASSERT (0); + return -1; + } + } + + return number_purged; +} + +void +ACE_WFMO_Reactor_Notify::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + ACE_TRACE ("ACE_WFMO_Reactor_Notify::dump"); + ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); + this->timer_queue_->dump (); + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("Max. iteration: %d\n"), + this->max_notify_iterations_)); + ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); +#endif /* ACE_HAS_DUMP */ +} + +void +ACE_WFMO_Reactor::max_notify_iterations (int iterations) +{ + ACE_TRACE ("ACE_WFMO_Reactor::max_notify_iterations"); + ACE_GUARD (ACE_Process_Mutex, monitor, this->lock_); + + // Must always be > 0 or < 0 to optimize the loop exit condition. + this->notify_handler_->max_notify_iterations (iterations); +} + +int +ACE_WFMO_Reactor::max_notify_iterations (void) +{ + ACE_TRACE ("ACE_WFMO_Reactor::max_notify_iterations"); + ACE_GUARD_RETURN (ACE_Process_Mutex, monitor, this->lock_, -1); + + return this->notify_handler_->max_notify_iterations (); +} + +int +ACE_WFMO_Reactor::purge_pending_notifications (ACE_Event_Handler *eh, + ACE_Reactor_Mask mask) +{ + ACE_TRACE ("ACE_WFMO_Reactor::purge_pending_notifications"); + if (this->notify_handler_ == 0) + return 0; + else + return this->notify_handler_->purge_pending_notifications (eh, mask); +} + +int +ACE_WFMO_Reactor::resumable_handler (void) +{ + ACE_TRACE ("ACE_WFMO_Reactor::resumable_handler"); + return 0; +} + + +// No-op WinSOCK2 methods to help WFMO_Reactor compile +#if !defined (ACE_HAS_WINSOCK2) || (ACE_HAS_WINSOCK2 == 0) +int +WSAEventSelect (SOCKET /* s */, + WSAEVENT /* hEventObject */, + long /* lNetworkEvents */) +{ + return -1; +} + +int +WSAEnumNetworkEvents (SOCKET /* s */, + WSAEVENT /* hEventObject */, + LPWSANETWORKEVENTS /* lpNetworkEvents */) +{ + return -1; +} +#endif /* !defined ACE_HAS_WINSOCK2 */ + +ACE_END_VERSIONED_NAMESPACE_DECL + +#endif /* ACE_WIN32 */ diff --git a/dep/ACE_wrappers/ace/WFMO_Reactor.h b/dep/ACE_wrappers/ace/WFMO_Reactor.h new file mode 100644 index 00000000000..1bbf207eca1 --- /dev/null +++ b/dep/ACE_wrappers/ace/WFMO_Reactor.h @@ -0,0 +1,1368 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file WFMO_Reactor.h + * + * $Id: WFMO_Reactor.h 81138 2008-03-28 09:18:15Z johnnyw $ + * + * @author Irfan Pyarali + * @author Tim Harrison + * @author Doug Schmidt + */ +//============================================================================= + +#ifndef ACE_WFMO_REACTOR_H +#define ACE_WFMO_REACTOR_H +#include /**/ "ace/pre.h" + +#include /**/ "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#if defined (ACE_WIN32) + +#include "ace/Signal.h" +#include "ace/Timer_Queue.h" +#include "ace/Event_Handler.h" +#include "ace/Auto_Event.h" +#include "ace/Manual_Event.h" +#include "ace/Condition_Thread_Mutex.h" +#include "ace/Lock_Adapter_T.h" +#include "ace/Reactor_Impl.h" +#include "ace/Message_Queue.h" +#include "ace/Process_Mutex.h" + +// If we don't have WinSOCK2, we need these defined +#if !defined (ACE_HAS_WINSOCK2) || (ACE_HAS_WINSOCK2 == 0) +/* + * WinSock 2 extension -- bit values and indices for FD_XXX network events + */ +#define FD_READ_BIT 0 +#define FD_WRITE_BIT 1 +#define FD_OOB_BIT 2 +#define FD_ACCEPT_BIT 3 +#define FD_CONNECT_BIT 4 +#define FD_CLOSE_BIT 5 +#define FD_QOS_BIT 6 +#define FD_GROUP_QOS_BIT 7 + +#define FD_QOS (1 << FD_QOS_BIT) +#define FD_GROUP_QOS (1 << FD_GROUP_QOS_BIT) + +#define FD_MAX_EVENTS 8 +#define FD_ALL_EVENTS ((1 << FD_MAX_EVENTS) - 1) + +#define WSAEVENT HANDLE + +typedef struct _WSANETWORKEVENTS +{ + long lNetworkEvents; + int iErrorCode[FD_MAX_EVENTS]; +} WSANETWORKEVENTS, FAR * LPWSANETWORKEVENTS; + +int WSAEventSelect (SOCKET s, + WSAEVENT hEventObject, + long lNetworkEvents); + +int WSAEnumNetworkEvents (SOCKET s, + WSAEVENT hEventObject, + LPWSANETWORKEVENTS lpNetworkEvents); + +#endif /* !defined ACE_HAS_WINSOCK2 */ + +class ACE_WFMO_Reactor_Test; // Must be out of versioned namespace. + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +// Forward decl. +class ACE_WFMO_Reactor; +class ACE_Handle_Set; + +/** + * @class ACE_Wakeup_All_Threads_Handler + * + * @brief This is a helper class whose sole purpose is to handle events + * on wakeup_all_threads_> + */ +class ACE_Export ACE_Wakeup_All_Threads_Handler : public ACE_Event_Handler +{ +public: + /// Called when the wakeup_all_threads_> + virtual int handle_signal (int signum, siginfo_t * = 0, ucontext_t * = 0); +}; + +/** + * @class ACE_WFMO_Reactor_Handler_Repository + * + * @internal This class is for internal ACE use only. + * + * @brief Used to map ACE_HANDLEs onto the appropriate + * ACE_Event_Handler * and other information. + */ +class ACE_Export ACE_WFMO_Reactor_Handler_Repository +{ +public: + friend class ACE_WFMO_Reactor; + friend class ACE_WFMO_Reactor_Test; + + /** + * @class Common_Info + * + * @brief This struct contains the necessary information for every + * entry. The reason the event is not in this + * structure is because we need to pass an event array into + * WaitForMultipleObjects and therefore keeping the events + * seperate makes sense. + */ + class Common_Info + { + public: + /// This indicates whether this entry is for I/O or for a regular + /// event + bool io_entry_; + + /// The assosiated + ACE_Event_Handler *event_handler_; + + /// The I/O handle related to the . This entry is + /// only valid if the flag is true. + ACE_HANDLE io_handle_; + + /** + * This is the set of events that the is + * interested in. This entry is only valid if the flag + * is true. + */ + long network_events_; + + /** + * This flag indicates that created the event on + * behalf of the user. Therefore we need to clean this up when the + * removes itself from . This entry + * is only valid if the flag is true. + */ + bool delete_event_; + + /// This is set when the entry needed to be deleted. + bool delete_entry_; + + /** + * These are the masks related to for the + * . This is only valid when is + * set. + */ + ACE_Reactor_Mask close_masks_; + + /// Constructor used for initializing the structure + Common_Info (void); + + /// Reset the state of the structure + void reset (void); + + /// Set the structure to these new values + void set (bool io_entry, + ACE_Event_Handler *event_handler, + ACE_HANDLE io_handle, + long network_events, + bool delete_event, + bool delete_entry, + ACE_Reactor_Mask close_masks); + + /// Set the structure to these new values + void set (Common_Info &common_info); + + /// Dump the state of an object. + void dump (void) const; + }; + + /** + * @class Current_Info + * + * @brief This structure inherits from the common structure to add + * information for current entries. + */ + class Current_Info : public Common_Info + { + public: + /// This is set when the entry needed to be suspended. + bool suspend_entry_; + + /// Default constructor + Current_Info (void); + + /// Reset the state of the structure + void reset (void); + + /// Set the structure to these new values + void set (bool io_entry, + ACE_Event_Handler *event_handler, + ACE_HANDLE io_handle, + long network_events, + bool delete_event, + bool delete_entry = false, + ACE_Reactor_Mask close_masks = ACE_Event_Handler::NULL_MASK, + bool suspend_entry = false); + + /// Set the structure to these new values + void set (Common_Info &common_info, + bool suspend_entry = false); + + /// Dump the state of an object. + void dump (ACE_HANDLE event_handle) const; + }; + + /** + * @class To_Be_Added_Info + * + * @brief This structure inherits from the common structure to add + * information for entries. + */ + class To_Be_Added_Info : public Common_Info + { + public: + /// Handle for the event + ACE_HANDLE event_handle_; + + /// This is set when the entry needed to be suspended. + bool suspend_entry_; + + /// Default constructor + To_Be_Added_Info (void); + + /// Reset the state of the structure + void reset (void); + + /// Set the structure to these new values + void set (ACE_HANDLE event_handle, + bool io_entry, + ACE_Event_Handler *event_handler, + ACE_HANDLE io_handle, + long network_events, + bool delete_event, + bool delete_entry = false, + ACE_Reactor_Mask close_masks = ACE_Event_Handler::NULL_MASK, + bool suspend_entry = false); + + /// Set the structure to these new values + void set (ACE_HANDLE event_handle, + Common_Info &common_info, + bool suspend_entry = false); + + /// Dump the state of an object. + void dump (void) const; + }; + + /** + * @class Suspended_Info + * + * @brief This structure inherits from the common structure to add + * information for suspended entries. + */ + class Suspended_Info : public Common_Info + { + public: + /// Handle for the event + ACE_HANDLE event_handle_; + + /// This is set when the entry needed to be resumed. + bool resume_entry_; + + /// Constructor used for initializing the structure + Suspended_Info (void); + + /// Reset the state of the structure + void reset (void); + + /// Set the structure to these new values + void set (ACE_HANDLE event_handle, + bool io_entry, + ACE_Event_Handler *event_handler, + ACE_HANDLE io_handle, + long network_events, + bool delete_event, + bool delete_entry = false, + ACE_Reactor_Mask close_masks = 0, + bool resume_entry = false); + + /// Set the structure to these new values + void set (ACE_HANDLE event_handle, + Common_Info &common_info, + bool resume_entry = false); + + /// Dump the state of an object. + void dump (void) const; + }; + + /// Constructor. + ACE_WFMO_Reactor_Handler_Repository (ACE_WFMO_Reactor &wfmo_reactor); + + /// Destructor. + virtual ~ACE_WFMO_Reactor_Handler_Repository (void); + + /// Initialize the repository of the approriate @a size. + int open (size_t size); + + /// Close down the handler repository. + int close (void); + + // = Search structure operations. + + /// Bind the to the ACE_HANDLE. This is for + /// the simple event entry. + int bind (ACE_HANDLE, ACE_Event_Handler *); + + /// Insert I/O entry into the system. This method + /// assumes that the lock are head *before* this method is invoked. + int bind_i (bool io_entry, + ACE_Event_Handler *event_handler, + long network_events, + ACE_HANDLE io_handle, + ACE_HANDLE event_handle, + bool delete_event); + + /// Remove the binding of ACE_HANDLE in accordance with the @a mask. + int unbind (ACE_HANDLE, + ACE_Reactor_Mask mask); + + /// Non-lock-grabbing version of + int unbind_i (ACE_HANDLE, + ACE_Reactor_Mask mask, + bool &changes_required); + + /// Remove all bindings of tuples. + void unbind_all (void); + + // = Sanity checking. + + // Check the to make sure it's a valid ACE_HANDLE + int invalid_handle (ACE_HANDLE handle) const; + + // = Accessors. + /// Maximum ACE_HANDLE value, plus 1. + DWORD max_handlep1 (void) const; + + /// Pointer to the beginning of the current array of ACE_HANDLE + /// *'s. + ACE_HANDLE *handles (void) const; + + /// Pointer to the beginning of the current array of + /// ACE_Event_Handler *'s. + Current_Info *current_info (void) const; + + /// Check if changes to the handle set are required. + virtual bool changes_required (void); + + /// Make changes to the handle set + virtual int make_changes (void); + + /// Check to see if @a slot has been scheduled for deletion + int scheduled_for_deletion (size_t slot) const; + + /** + * This method is used to calculate the network mask after a mask_op + * request to . Note that because the + * may already be in the handler repository, we may have to find the + * old event and the old network events + */ + int modify_network_events_i (ACE_HANDLE io_handle, + ACE_Reactor_Mask new_masks, + ACE_Reactor_Mask &old_masks, + long &new_network_events, + ACE_HANDLE &event_handle, + bool &delete_event, + int operation); + + /// This method is used to change the network mask left (if any) + /// after a remove request to + ACE_Reactor_Mask bit_ops (long &existing_masks, + ACE_Reactor_Mask to_be_removed_masks, + int operation); + + /// Temporarily suspend entry + int suspend_handler_i (ACE_HANDLE handle, + bool &changes_required); + + /// Resume suspended entry + int resume_handler_i (ACE_HANDLE handle, + bool &changes_required); + + /// Deletions and suspensions in current_info_ + int make_changes_in_current_infos (void); + + /// Deletions and resumptions in current_suspended_info_ + int make_changes_in_suspension_infos (void); + + /// Deletions in to_be_added_info_, or transfers to current_info_ or + /// current_suspended_info_ from to_be_added_info_ + int make_changes_in_to_be_added_infos (void); + + /// Removes the ACE_Event_Handler at @a slot from the table. + int remove_handler_i (size_t slot, + ACE_Reactor_Mask mask); + + /// Removes the ACE_Event_Handler at @a slot from the table. + int remove_suspended_handler_i (size_t slot, + ACE_Reactor_Mask mask); + + /// Removes the ACE_Event_Handler at @a slot from the table. + int remove_to_be_added_handler_i (size_t slot, + ACE_Reactor_Mask to_be_removed_masks); + + /** + * Return the Event_Handler associated with . Return 0 if + * is not registered. + */ + ACE_Event_Handler *find_handler (ACE_HANDLE handle); + + /** + * Check to see if is associated with a valid Event_Handler + * bound to @a mask. Return the associated with this + * @a handler if != 0. + */ + int handler (ACE_HANDLE handle, + ACE_Reactor_Mask mask, + ACE_Event_Handler **event_handler = 0); + + /** + * Check to see if is associated with a valid + * Event_Handler. Return Event_Handler and associated masks. + */ + ACE_Event_Handler *handler (ACE_HANDLE handle, + long &existing_masks); + + /// Dump the state of an object. + void dump (void) const; + +protected: + /// Reference to our . + ACE_WFMO_Reactor &wfmo_reactor_; + + /// Maximum number of handles. + size_t max_size_; + + /** + * Array of passed to . This + * is not part of the structure as the handle array needs to be + * passed directly to . + */ + ACE_HANDLE *current_handles_; + + /// Array of current entries in the table + Current_Info *current_info_; + + /// A count of the number of active handles. + DWORD max_handlep1_; + + /// Information for entries to be added + To_Be_Added_Info *to_be_added_info_; + + /// Number of records to be added + size_t handles_to_be_added_; + + /// Currently suspended handles + Suspended_Info *current_suspended_info_; + + /// Number of currently suspended handles + size_t suspended_handles_; + + /// Number of records to be suspended + size_t handles_to_be_suspended_; + + /// Number of records to be resumed + size_t handles_to_be_resumed_; + + /// Number of records to be deleted + size_t handles_to_be_deleted_; + +}; + +/** + * @class ACE_WFMO_Reactor_Notify + * + * @brief Unblock the from its event loop, passing + * it an optional ACE_Event_Handler to dispatch. + * + * This implementation is necessary for cases where the + * is run in a multi-threaded program. In + * this case, we need to be able to unblock + * when updates occur other than in the + * main thread. To do this, we signal an + * auto-reset event the is listening on. If + * an ACE_Event_Handler and ACE_Reactor_Mask is passed to + * , the appropriate method is dispatched. + */ +class ACE_Export ACE_WFMO_Reactor_Notify : public ACE_Reactor_Notify +{ +public: + /// Constructor + ACE_WFMO_Reactor_Notify (size_t max_notifies = 1024); + + /// Initialization. is stored to call . + virtual int open (ACE_Reactor_Impl *wfmo_reactor, + ACE_Timer_Queue *timer_queue, + int disable_notify = 0); + + /// No-op. + virtual int close (void); + + /** + * Special trick to unblock when updates + * occur. All we do is enqueue and @a mask onto the + * ACE_Message_Queue and wakeup the by signaling + * its handle. The ACE_Time_Value indicates how long + * to blocking trying to notify the . If @a timeout == + * 0, the caller will block until action is possible, else will wait + * until the relative time specified in @a timeout elapses). + */ + virtual int notify (ACE_Event_Handler *event_handler = 0, + ACE_Reactor_Mask mask = ACE_Event_Handler::EXCEPT_MASK, + ACE_Time_Value *timeout = 0); + + /// No-op. + virtual int dispatch_notifications (int &number_of_active_handles, + ACE_Handle_Set &rd_mask); + + /// Returns a handle to the . + virtual ACE_HANDLE get_handle (void) const; + + /// Returns the ACE_HANDLE of the notify pipe on which the reactor + /// is listening for notifications so that other threads can unblock + /// the + virtual ACE_HANDLE notify_handle (void); + + /// Handle one of the notify call on the . This could be + /// because of a thread trying to unblock the + virtual int dispatch_notify (ACE_Notification_Buffer &buffer); + + /// Verify whether the buffer has dispatchable info or not. + virtual int is_dispatchable (ACE_Notification_Buffer &buffer); + + /// Read one of the notify call on the into the + /// . This could be because of a thread trying to unblock + /// the + virtual int read_notify_pipe (ACE_HANDLE handle, + ACE_Notification_Buffer &buffer); + + /** + * Set the maximum number of times that the + * method will iterate and + * dispatch the that are passed in via the + * notify queue before breaking out of its + * loop. By default, this is set to + * -1, which means "iterate until the queue is empty." Setting this + * to a value like "1 or 2" will increase "fairness" (and thus + * prevent starvation) at the expense of slightly higher dispatching + * overhead. + */ + void max_notify_iterations (int); + + /** + * Get the maximum number of times that the + * method will iterate and + * dispatch the that are passed in via the + * notify queue before breaking out of its + * loop. + */ + int max_notify_iterations (void); + + /** + * Purge any notifications pending in this reactor for the specified + * ACE_Event_Handler object. If == 0, all notifications for all + * handlers are removed (but not any notifications posted just to wake up + * the reactor itself). Returns the number of notifications purged. + * Returns -1 on error. + */ + virtual int purge_pending_notifications (ACE_Event_Handler *, + ACE_Reactor_Mask = ACE_Event_Handler::ALL_EVENTS_MASK); + + /// Dump the state of an object. + virtual void dump (void) const; + +private: + /// Pointer to the wfmo_reactor's timer queue. + ACE_Timer_Queue *timer_queue_; + + /** + * Called when the notification event waited on by + * is signaled. This dequeues all pending + * and dispatches them. + */ + virtual int handle_signal (int signum, siginfo_t * = 0, ucontext_t * = 0); + + /// An auto event is used so that we can it to wakeup one + /// thread up (e.g., when the method is called). + ACE_Auto_Event wakeup_one_thread_; + + /// Message queue that keeps track of pending . + /// This queue must be thread-safe because it can be called by + /// multiple threads of control. + ACE_Message_Queue message_queue_; + + /** + * Keeps track of the maximum number of times that the + * method will iterate and + * dispatch the that are passed in via the + * notify queue before breaking out of its + * loop. By default, this is set to + * -1, which means "iterate until the queue is empty." + */ + int max_notify_iterations_; +}; + +/** + * @class ACE_WFMO_Reactor + * + * @brief An object oriented event demultiplexor and event handler. + * ACE_WFMO_Reactor is a Windows-only implementation of the ACE_Reactor + * interface that uses the WaitForMultipleObjects() event demultiplexer. + * + * Like the other ACE Reactors, ACE_WFMO_Reactor can schedule timers. + * It also reacts to signalable handles, such as events (see the documentation + * for WaitForMultipleObjects() for a complete list of signalable handle + * types). Therefore, I/O handles are not directly usable for registering + * for input, output, and exception notification. The exception to this + * is ACE_SOCK-based handles, which can be registered for input, output, and + * exception notification just as with other platforms. See Chapter 4 in + * C++NPv2 for complete details. + * + * Note that changes to the state of ACE_WFMO_Reactor are not + * instantaneous. Most changes (registration, removal, + * suspension, and resumption of handles, and changes in + * ownership) are made when the ACE_WFMO_Reactor reaches a stable + * state. Users should be careful, especially when removing + * handlers. This is because the ACE_WFMO_Reactor will call + * handle_close() on the handler when it is finally removed and + * not when remove_handler() is called. If the registered handler's pointer + * is not valid when ACE_WFMO_Reactor calls ACE_Event_Handler::handle_close(), + * use the DONT_CALL flag with remove_handler(). Preferably, use dynamically + * allocated event handlers and call "delete this" inside the handle_close() + * hook method. + * + * Note that although multiple threads can concurrently run the + * ACE_WFMO_Reactor event loop, the concept of the reactor "owner" is still + * important. Only the owner thread can expire timers and wait on the + * notifications handle. Thus, be careful to properly set the owner thread + * when spawning threads to run the event loop while you are using timers + * or notifications. + */ +class ACE_Export ACE_WFMO_Reactor : public ACE_Reactor_Impl +{ +public: + friend class ACE_WFMO_Reactor_Handler_Repository; + friend class ACE_WFMO_Reactor_Test; + + enum + { + /// Default size of the WFMO_Reactor's handle table. + /** + * Two slots will be added to the @a size parameter in the + * constructor and open methods which will store handles used for + * internal management purposes. + */ + DEFAULT_SIZE = MAXIMUM_WAIT_OBJECTS - 2 + }; + + // = Initialization and termination methods. + + /// Initialize ACE_WFMO_Reactor with the default size. + ACE_WFMO_Reactor (ACE_Sig_Handler * = 0, + ACE_Timer_Queue * = 0, + ACE_Reactor_Notify * = 0); + + /** + * Initialize ACE_WFMO_Reactor with the specified size. + * + * @param size The maximum number of handles the reactor can + * register. The value should not exceed + * ACE_WFMO_Reactor::DEFAULT_SIZE. Two slots will be + * added to the @a size parameter which will store handles + * used for internal management purposes. + */ + ACE_WFMO_Reactor (size_t size, + int unused = 0, + ACE_Sig_Handler * = 0, + ACE_Timer_Queue * = 0, + ACE_Reactor_Notify * = 0); + + /** + * Initialize ACE_WFMO_Reactor with the specified size. + * + * @param size The maximum number of handles the reactor can + * register. The value should not exceed + * ACE_WFMO_Reactor::DEFAULT_SIZE. Two slots will be + * added to the @a size parameter which will store handles + * used for internal management purposes. + */ + virtual int open (size_t size = ACE_WFMO_Reactor::DEFAULT_SIZE, + int restart = 0, + ACE_Sig_Handler * = 0, + ACE_Timer_Queue * = 0, + int disable_notify_pipe = 0, + ACE_Reactor_Notify * = 0); + + /// Returns -1 (not used in this implementation); + virtual int current_info (ACE_HANDLE, size_t & /* size */); + + /// Use a user specified signal handler instead. + virtual int set_sig_handler (ACE_Sig_Handler *signal_handler); + + /// Set a user-specified timer queue. + virtual int timer_queue (ACE_Timer_Queue *tq); + + /// Return the current ACE_Timer_Queue. + virtual ACE_Timer_Queue *timer_queue (void) const; + + /// Close down the ACE_WFMO_Reactor and release all of its resources. + virtual int close (void); + + /// Close down the ACE_WFMO_Reactor and release all of its resources. + virtual ~ACE_WFMO_Reactor (void); + + // = Event loop drivers. + + /** + * This method is not currently implemented. We recommend that you + * use handle_events (ACE_Time_Value::zero) to get basically the + * same effect, i.e., it won't block the caller if there are no events. + */ + virtual int work_pending (const ACE_Time_Value &max_wait_time = ACE_Time_Value::zero); + + /** + * This event loop driver blocks for up to @a max_wait_time before + * returning. It will return earlier if timer events, I/O events, + * or signal events occur. Note that @a max_wait_time can be 0, in + * which case this method blocks indefinitely until events occur. + * + * @a max_wait_time is decremented to reflect how much time this call + * took. For instance, if a time value of 3 seconds is passed to + * handle_events and an event occurs after 2 seconds, + * @a max_wait_time will equal 1 second. This can be used if an + * application wishes to handle events for some fixed amount of + * time. + * + * is used as the demultiplexing call + * + * Returns the total number of I/O and timer ACE_Event_Handlers + * that were dispatched, 0 if the @a max_wait_time elapsed without + * dispatching any handlers, or -1 if an error occurs. + * + * The only difference between and + * is that in the alertable case, TRUE is passed to + * for the option. + */ + virtual int handle_events (ACE_Time_Value *max_wait_time = 0); + virtual int alertable_handle_events (ACE_Time_Value *max_wait_time = 0); + + /** + * This method is just like the one above, except the + * @a max_wait_time value is a reference and can therefore never be + * NULL. + * + * The only difference between and + * is that in the alertable case, TRUE is passed to + * for the option. + */ + virtual int handle_events (ACE_Time_Value &max_wait_time); + virtual int alertable_handle_events (ACE_Time_Value &max_wait_time); + + + // = Event handling control. + + /** + * Return the status of Reactor. If this function returns 0, the reactor is + * actively handling events. If it returns non-zero, and + * return -1 immediately. + */ + virtual int deactivated (void); + + /** + * Control whether the Reactor will handle any more incoming events or not. + * If == 1, the Reactor will be disabled. By default, a reactor + * is in active state and can be deactivated/reactived as wish. + */ + virtual void deactivate (int do_stop); + + // = Register and remove Handlers. + + /** + * Register an ACE_Event_Handler . Since no Event + * Mask is passed through this interface, it is assumed that the + * being passed in is an event handle and when the event + * becomes signaled, will call handle_signal on + * . If == the + * will call the method of + * to extract the underlying event handle. + */ + virtual int register_handler (ACE_Event_Handler *event_handler, + ACE_HANDLE event_handle = ACE_INVALID_HANDLE); + + /** + * Register an ACE_Event_Handler . @a mask specifies + * the network events that the is interested in. If + * == the will + * call the method of to extract the + * underlying I/O handle. If the == + * , WFMO_Reactor will create an event for + * associating it with the I/O handle. When the is + * signalled, the appropriate callback will be invoked on + * the + */ + virtual int register_handler (ACE_HANDLE event_handle, + ACE_HANDLE io_handle, + ACE_Event_Handler *event_handler, + ACE_Reactor_Mask mask); + + /** + * This is a simple version of the above method + * where the I/O handle is passed in and the event handle will + * always be created by + */ + virtual int register_handler (ACE_HANDLE io_handle, + ACE_Event_Handler *event_handler, + ACE_Reactor_Mask mask); + + /** + * This is a simple version of the above method + * where the I/O handle will always come from on the + * and the event handle will always be created by + * + */ + virtual int register_handler (ACE_Event_Handler *event_handler, + ACE_Reactor_Mask mask); + + /// Register with all the in the + /// . + virtual int register_handler (const ACE_Handle_Set &handles, + ACE_Event_Handler *event_handler, + ACE_Reactor_Mask mask); + + /** + * Register to handle the signal @a signum using the + * . Returns the that was previously registered + * (if any), along with the of the signal handler. + */ + virtual int register_handler (int signum, + ACE_Event_Handler *new_sh, + ACE_Sig_Action *new_disp = 0, + ACE_Event_Handler **old_sh = 0, + ACE_Sig_Action *old_disp = 0); + + /// Registers to handle a set of signals using the + /// . + virtual int register_handler (const ACE_Sig_Set &sigset, + ACE_Event_Handler *new_sh, + ACE_Sig_Action *new_disp = 0); + + /** + * Removes from the . Note that + * the will call the method of + * to extract the underlying handle. If @a mask == + * ACE_Event_Handler::DONT_CALL then the method of + * the is not invoked. Note that the can + * either be the or the + */ + virtual int remove_handler (ACE_Event_Handler *event_handler, + ACE_Reactor_Mask mask); + + /** + * Removes from the . If @a mask == + * ACE_Event_Handler::DONT_CALL then the method of + * the is not invoked. Note that the can + * either be the or the + * + * For the case of I/O entries, this removes the @a mask binding of + * whose handle is from . If + * there are no more bindings for this then it is + * removed from the WFMO_Reactor. For simple event entries, mask is + * mostly ignored and the is always removed from + * + */ + virtual int remove_handler (ACE_HANDLE handle, + ACE_Reactor_Mask mask); + + /** + * Removes all the @a mask bindings for handles in the + * bind of . If there are no more bindings for any + * of these handles then they are removed from WFMO_Reactor. + */ + virtual int remove_handler (const ACE_Handle_Set &handle_set, + ACE_Reactor_Mask); + + /** + * Remove the ACE_Event_Handler currently associated with @a signum. + * is ignored in this implementation since there is only + * one instance of a signal handler. Install the new disposition + * (if given) and return the previous disposition (if desired by the + * caller). Returns 0 on success and -1 if @a signum is invalid. + */ + virtual int remove_handler (int signum, + ACE_Sig_Action *new_disp, + ACE_Sig_Action *old_disp = 0, + int sigkey = -1); + + /// Calls for every signal in . + virtual int remove_handler (const ACE_Sig_Set &sigset); + + // = Suspend and resume Handlers. + + /// Suspend temporarily. Use + /// to get the handle. + virtual int suspend_handler (ACE_Event_Handler *event_handler); + + /// Suspend temporarily. + virtual int suspend_handler (ACE_HANDLE handle); + + /// Suspend all in handle set temporarily. + virtual int suspend_handler (const ACE_Handle_Set &handles); + + /// Suspend all temporarily. + virtual int suspend_handlers (void); + + /// Resume . Use to + /// get the handle. + virtual int resume_handler (ACE_Event_Handler *event_handler); + + /// Resume . + virtual int resume_handler (ACE_HANDLE handle); + + /// Resume all in handle set. + virtual int resume_handler (const ACE_Handle_Set &handles); + + /// Resume all . + virtual int resume_handlers (void); + + /// Does the reactor allow the application to resume the handle on + /// its own ie. can it pass on the control of handle resumption to + /// the application. A positive value indicates that the handlers + /// are application resumable. A value of 0 indicates otherwise. + virtual int resumable_handler (void); + + /** + * Return 1 if we any event associations were made by the reactor + * for the handles that it waits on, 0 otherwise. Since the + * WFMO_Reactor does use event associations, this function always + * return 1. + */ + virtual int uses_event_associations (void); + + // Timer management. + + /** + * Schedule an ACE_Event_Handler that will expire after an amount + * of time. The return value of this method, a timer_id value, + * uniquely identifies the event_handler in the ACE_Reactor's + * internal list of timers. + * This timer_id value can be used to cancel the timer + * with the cancel_timer() call. + * + * @see cancel_timer() + * @see reset_timer_interval() + * + * @param event_handler event handler to schedule on reactor + * @param arg argument passed to the handle_timeout() method of event_handler + * @param delay time interval after which the timer will expire + * @param interval time interval after which the timer will be automatically rescheduled + * @return -1 on failure, a timer_id value on success + */ + virtual long schedule_timer (ACE_Event_Handler *event_handler, + const void *arg, + const ACE_Time_Value &delay, + const ACE_Time_Value &interval = ACE_Time_Value::zero); + + /** + * Resets the interval of the timer represented by @a timer_id to + * @a interval, which is specified in relative time to the current + * . If @a interval is equal to + * ACE_Time_Value::zero, the timer will become a non-rescheduling + * timer. Returns 0 if successful, -1 if not. + */ + virtual int reset_timer_interval (long timer_id, + const ACE_Time_Value &interval); + + /// Cancel all Event_Handlers that match the address of + /// . Returns number of handler's cancelled. + virtual int cancel_timer (ACE_Event_Handler *event_handler, + int dont_call_handle_close = 1); + + /** + * Cancel the single Event_Handler that matches the @a timer_id value + * (which was returned from the schedule method). If arg is + * non-NULL then it will be set to point to the ``magic cookie'' + * argument passed in when the Event_Handler was registered. This + * makes it possible to free up the memory and avoid memory leaks. + * Returns 1 if cancellation succeeded and 0 if the @a timer_id + * wasn't found. + */ + virtual int cancel_timer (long timer_id, + const void **arg = 0, + int dont_call_handle_close = 1); + + // = High-level Event_Handler scheduling operations + + /** + * Add @a masks_to_be_added to the 's entry in + * WFMO_Reactor. must already have been registered + * with WFMO_Reactor. + */ + virtual int schedule_wakeup (ACE_Event_Handler *event_handler, + ACE_Reactor_Mask masks_to_be_added); + + /** + * Add @a masks_to_be_added to the @a handle's entry in WFMO_Reactor. + * The Event_Handler associated with must already have been + * registered with WFMO_Reactor. + */ + virtual int schedule_wakeup (ACE_HANDLE handle, + ACE_Reactor_Mask masks_to_be_added); + + /** + * Remove to the 's entry in + * WFMO_Reactor. The Event_Handler associated with must + * already have been registered with WFMO_Reactor. + */ + virtual int cancel_wakeup (ACE_Event_Handler *event_handler, + ACE_Reactor_Mask masks_to_be_deleted); + + /** + * Remove to the 's entry in + * WFMO_Reactor. The Event_Handler associated with must + * already have been registered with WFMO_Reactor. + */ + virtual int cancel_wakeup (ACE_HANDLE handle, + ACE_Reactor_Mask masks_to_be_deleted); + + // = Notification methods. + + /** + * Wakeup one thread if it is currently blocked + * in . The ACE_Time_Value indicates how + * long to blocking trying to notify the . If + * @a timeout == 0, the caller will block until action is possible, + * else will wait until the relative time specified in @a timeout + * elapses). + */ + virtual int notify (ACE_Event_Handler * = 0, + ACE_Reactor_Mask = ACE_Event_Handler::EXCEPT_MASK, + ACE_Time_Value * = 0); + + /** + * Set the maximum number of times that the + * method will iterate and + * dispatch the that are passed in via the + * notify queue before breaking out of its + * loop. By default, this is set to + * -1, which means "iterate until the queue is empty." Setting this + * to a value like "1 or 2" will increase "fairness" (and thus + * prevent starvation) at the expense of slightly higher dispatching + * overhead. + */ + virtual void max_notify_iterations (int); + + /** + * Get the maximum number of times that the + * method will iterate and + * dispatch the that are passed in via the + * notify queue before breaking out of its + * loop. + */ + virtual int max_notify_iterations (void); + + /** + * Purge any notifications pending in this reactor for the specified + * ACE_Event_Handler object. Returns the number of notifications + * purged. Returns -1 on error. + */ + virtual int purge_pending_notifications (ACE_Event_Handler * = 0, + ACE_Reactor_Mask = ACE_Event_Handler::ALL_EVENTS_MASK); + + // = Assorted helper methods. + + /** + * Return the Event_Handler associated with . Return 0 if + * is not registered. + */ + ACE_Event_Handler *find_handler (ACE_HANDLE handle); + + /** + * Check to see if is associated with a valid Event_Handler + * bound to @a mask. Return the associated with this + * @a handler if != 0. + */ + virtual int handler (ACE_HANDLE handle, + ACE_Reactor_Mask mask, + ACE_Event_Handler **event_handler = 0); + + /** + * Check to see if @a signum is associated with a valid Event_Handler + * bound to a signal. Return the associated with + * this @a handler if != 0. + */ + virtual int handler (int signum, + ACE_Event_Handler ** = 0); + + /// Returns true if WFMO_Reactor has been successfully initialized, else + /// false. + virtual bool initialized (void); + + /// Returns the current size of the WFMO_Reactor's internal + /// descriptor table. + virtual size_t size (void) const; + + /// Returns a reference to the WFMO_Reactor's internal lock. + virtual ACE_Lock &lock (void); + + /// Wake up all threads in WaitForMultipleObjects so that they can + /// reconsult the handle set + virtual void wakeup_all_threads (void); + + /** + * Transfers ownership of the WFMO_Reactor to the . The + * transfer will not complete until all threads are ready (just like + * the handle set). + */ + virtual int owner (ACE_thread_t new_owner, ACE_thread_t *old_owner = 0); + + /// Return the ID of the "owner" thread. + virtual int owner (ACE_thread_t *owner); + + /// Get the existing restart value. + virtual int restart (void); + + /// Set a new value for restart and return the original value. + virtual int restart (int r); + + /// Not implemented + virtual void requeue_position (int); + + /// Not implemented + virtual int requeue_position (void); + + // = Low-level wait_set mask manipulation methods. + + /** + * Modify @a masks of the 's entry in WFMO_Reactor + * depending upon . must already have + * been registered with WFMO_Reactor. + */ + virtual int mask_ops (ACE_Event_Handler *event_handler, + ACE_Reactor_Mask masks, + int operation); + + /** + * Modify @a masks of the 's entry in WFMO_Reactor depending + * upon . must already have been registered + * with WFMO_Reactor. + */ + virtual int mask_ops (ACE_HANDLE handle, + ACE_Reactor_Mask masks, + int ops); + + // = Low-level ready_set mask manipulation methods. + + /// Not implemented + virtual int ready_ops (ACE_Event_Handler *event_handler, + ACE_Reactor_Mask mask, + int ops); + + /// Not implemented + virtual int ready_ops (ACE_HANDLE handle, + ACE_Reactor_Mask, + int ops); + + /// Declare the dynamic allocation hooks. + ACE_ALLOC_HOOK_DECLARE; + + /// Dump the state of an object. + virtual void dump (void) const; + +protected: + /// Registration workhorse + virtual int register_handler_i (ACE_HANDLE event_handle, + ACE_HANDLE io_handle, + ACE_Event_Handler *event_handler, + ACE_Reactor_Mask mask); + + /// Event handling workhorse + virtual int event_handling (ACE_Time_Value *max_wait_time = 0, + int alertable = 0); + + /// Bit masking workhorse + virtual int mask_ops_i (ACE_HANDLE io_handle, + ACE_Reactor_Mask masks, + int operation); + + /// Return the ID of the "owner" thread. Does not do any locking. + virtual ACE_thread_t owner_i (void); + + /// Wait up to @a max_wait_time until it's ok to enter + /// WaitForMultipleObjects. Returns 1 (and holding lock_) if ok to wait; + /// -1 (and not holding lock_) if not. + virtual int ok_to_wait (ACE_Time_Value *max_wait_time, + int alertable); + + /// Wait for timer and I/O events to occur. + virtual DWORD wait_for_multiple_events (int timeout, + int alertable); + + /// Check for activity on remaining handles. + virtual DWORD poll_remaining_handles (DWORD slot); + + /// Expire timers. Only the owner thread does useful stuff in this + /// function. + virtual int expire_timers (void); + + /// Dispatches the timers and I/O handlers. + virtual int dispatch (DWORD wait_status); + + /// Protect against structured exceptions caused by user code when + /// dispatching handles + virtual int safe_dispatch (DWORD wait_status); + + /** + * Dispatches any active handles from handles_[@a slot] to + * handles_[active_handles_] using to poll + * through our handle set looking for active handles. + */ + virtual int dispatch_handles (DWORD slot); + + /// Dispatches a single handler. Returns 0 on success, -1 if the + /// handler was removed. + virtual int dispatch_handler (DWORD slot, + DWORD max_handlep1); + + /// Dispatches a single handler. Returns 0 on success, -1 if the + /// handler was removed. + virtual int simple_dispatch_handler (DWORD slot, + ACE_HANDLE event_handle); + + /// Dispatches a single handler. Returns 0 on success, -1 if the + /// handler was removed. + virtual int complex_dispatch_handler (DWORD slot, + ACE_HANDLE event_handle); + + /// Dispatches window messages. Noop for WFMO_Reactor. + virtual int dispatch_window_messages (void); + + virtual ACE_Reactor_Mask upcall (ACE_Event_Handler *event_handler, + ACE_HANDLE io_handle, + WSANETWORKEVENTS &events); + + /// Used to caluculate the next timeout + virtual int calculate_timeout (ACE_Time_Value *time); + + /// Update the state of the handler repository + virtual int update_state (void); + + /// Check to see if we have a new owner + virtual int new_owner (void); + + /// Set owner to new owner + virtual int change_owner (void); + + /// Handle signals without requiring global/static variables. + ACE_Sig_Handler *signal_handler_; + + /// Keeps track of whether we should delete the signal handler (if we + /// didn't create it, then we don't delete it). + bool delete_signal_handler_; + + /// Defined as a pointer to allow overriding by derived classes... + ACE_Timer_Queue *timer_queue_; + + /// Keeps track of whether we should delete the timer queue (if we + /// didn't create it, then we don't delete it). + bool delete_timer_queue_; + + /// Keeps track of whether we should delete the handler repository + bool delete_handler_rep_; + + /// Used when is called. + ACE_Reactor_Notify *notify_handler_; + + /// Keeps track of whether we should delete the notify handler. + bool delete_notify_handler_; + + /** + * Synchronization for the ACE_WFMO_Reactor. + * + * A Process Mutex is used here because of two reasons: + * (a) The implementation of ACE_Thread_Mutex uses CriticalSections + * CriticalSections are not waitable using ::WaitForMultipleObjects + * (b) This is really not a process mutex because it is not + * named. No other process can use this mutex. + */ + ACE_Process_Mutex lock_; + + /// Adapter used to return internal lock to outside world. + ACE_Lock_Adapter lock_adapter_; + + /// Table that maps to 's. + ACE_WFMO_Reactor_Handler_Repository handler_rep_; + + /// A manual event used to block threads from proceeding into + /// WaitForMultipleObjects + ACE_Manual_Event ok_to_wait_; + + /** + * A manual event is used so that we can wake everyone up (e.g., + * when are bounded and unbound from the + * handler repository). + */ + ACE_Manual_Event wakeup_all_threads_; + + /// Used when is signaled + ACE_Wakeup_All_Threads_Handler wakeup_all_threads_handler_; + + /// The changing thread waits on this event, till all threads are not + /// active anymore + ACE_Auto_Event waiting_to_change_state_; + + /// Count of currently active threads + size_t active_threads_; + + /** + * The thread which is "owner" of the WFMO_Reactor. The owner + * concept is used because we don't want multiple threads to try to + * expire timers. Therefore the "owner" thread is the only one + * allowed to expire timers. Also, the owner thread is the only + * thread which waits on the notify handle. Note that the ownership + * can be transferred. + */ + ACE_thread_t owner_; + + /// The owner to be of the WFMO_Reactor + ACE_thread_t new_owner_; + + /// This is the thread which is responsible for the changing the + /// state of the handle set + ACE_thread_t change_state_thread_; + + /// This is an array of ACE_HANDLEs which keep track of the + /// and handles + ACE_HANDLE atomic_wait_array_ [2]; + + /// This flag is used to keep track of whether we are already closed. + bool open_for_business_; + + /// This flag is used to keep track of whether we are actively handling + /// events or not. + sig_atomic_t deactivated_; + +private: + /// Deny access since member-wise won't work... + ACE_WFMO_Reactor (const ACE_WFMO_Reactor &); + ACE_WFMO_Reactor &operator = (const ACE_WFMO_Reactor &); +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +#include "ace/WFMO_Reactor.inl" +#endif /* __ACE_INLINE__ */ + +#endif /* ACE_WIN32 */ +#include /**/ "ace/post.h" +#endif /* ACE_WFMO_REACTOR_H */ diff --git a/dep/ACE_wrappers/ace/WFMO_Reactor.inl b/dep/ACE_wrappers/ace/WFMO_Reactor.inl new file mode 100644 index 00000000000..a155019d841 --- /dev/null +++ b/dep/ACE_wrappers/ace/WFMO_Reactor.inl @@ -0,0 +1,1200 @@ +// -*- C++ -*- +// +// $Id: WFMO_Reactor.inl 81138 2008-03-28 09:18:15Z johnnyw $ + +#include "ace/Handle_Set.h" +#include "ace/Reactor.h" +#include "ace/Thread.h" +#include "ace/Sig_Handler.h" +#include "ace/OS_NS_errno.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +/************************************************************/ + +ACE_INLINE int +ACE_Wakeup_All_Threads_Handler::handle_signal (int /* signum */, + siginfo_t * /* siginfo */, + ucontext_t *) +{ + // This will get called when wakeup_all_threads_> event + // is signaled. There is nothing to be done here. + // ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%t) waking up to get updated handle set info\n"))); + return 0; +} + +#if defined (ACE_WIN32) + +/************************************************************/ + +ACE_INLINE +ACE_WFMO_Reactor_Handler_Repository::Common_Info::Common_Info (void) + : io_entry_ (false), + event_handler_ (0), + io_handle_ (ACE_INVALID_HANDLE), + network_events_ (0), + delete_event_ (false), + delete_entry_ (false), + close_masks_ (ACE_Event_Handler::NULL_MASK) +{ +} + +ACE_INLINE void +ACE_WFMO_Reactor_Handler_Repository::Common_Info::reset (void) +{ + this->event_handler_ = 0; + this->io_entry_ = false; + this->io_handle_ = ACE_INVALID_HANDLE; + this->network_events_ = 0; + this->delete_event_ = false; + this->delete_entry_ = false; + this->close_masks_ = ACE_Event_Handler::NULL_MASK; +} + +ACE_INLINE void +ACE_WFMO_Reactor_Handler_Repository::Common_Info::set (bool io_entry, + ACE_Event_Handler *event_handler, + ACE_HANDLE io_handle, + long network_events, + bool delete_event, + bool delete_entry, + ACE_Reactor_Mask close_masks) +{ + this->event_handler_ = event_handler; + this->io_entry_ = io_entry; + this->io_handle_ = io_handle; + this->network_events_ = network_events; + this->delete_event_ = delete_event; + this->delete_entry_ = delete_entry; + this->close_masks_ = close_masks; +} + +ACE_INLINE void +ACE_WFMO_Reactor_Handler_Repository::Common_Info::set (Common_Info &common_info) +{ + *this = common_info; +} + +ACE_INLINE void +ACE_WFMO_Reactor_Handler_Repository::Common_Info::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + ACE_TRACE ("ACE_WFMO_Reactor_Handler_Repository::Common_Info::dump"); + + ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); + + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("I/O Entry = %d\n"), + this->io_entry_)); + + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("Event Handler = %d\n"), + this->event_handler_)); + + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("I/O Handle = %d\n"), + this->io_handle_)); + + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("Network Events = %d\n"), + this->network_events_)); + + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("Delete Event = %d\n"), + this->delete_event_)); + + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("Delete Entry = %d\n"), + this->delete_entry_)); + + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("Close Masks = %d\n"), + this->close_masks_)); + + ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); +#endif /* ACE_HAS_DUMP */ +} + +/************************************************************/ + +ACE_INLINE +ACE_WFMO_Reactor_Handler_Repository::Current_Info::Current_Info (void) + : suspend_entry_ (false) +{ +} + +ACE_INLINE void +ACE_WFMO_Reactor_Handler_Repository::Current_Info::set (bool io_entry, + ACE_Event_Handler *event_handler, + ACE_HANDLE io_handle, + long network_events, + bool delete_event, + bool delete_entry, + ACE_Reactor_Mask close_masks, + bool suspend_entry) +{ + this->suspend_entry_ = suspend_entry; + Common_Info::set (io_entry, + event_handler, + io_handle, + network_events, + delete_event, + delete_entry, + close_masks); +} + +ACE_INLINE void +ACE_WFMO_Reactor_Handler_Repository::Current_Info::set (Common_Info &common_info, + bool suspend_entry) +{ + this->suspend_entry_ = suspend_entry; + Common_Info::set (common_info); +} + +ACE_INLINE void +ACE_WFMO_Reactor_Handler_Repository::Current_Info::reset (void) +{ + this->suspend_entry_ = false; + Common_Info::reset (); +} + +ACE_INLINE void +ACE_WFMO_Reactor_Handler_Repository::Current_Info::dump (ACE_HANDLE event_handle) const +{ +#if defined (ACE_HAS_DUMP) + ACE_TRACE ("ACE_WFMO_Reactor_Handler_Repository::Current_Info::dump"); + + ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); + + Common_Info::dump (); + + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("Event Handle = %d\n"), + event_handle)); + + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("Suspend Entry = %d\n"), + this->suspend_entry_)); + + ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); +#else /* !ACE_HAS_DUMP */ + ACE_UNUSED_ARG (event_handle); +#endif /* ACE_HAS_DUMP */ +} + +/************************************************************/ + +ACE_INLINE +ACE_WFMO_Reactor_Handler_Repository::To_Be_Added_Info::To_Be_Added_Info (void) + : event_handle_ (ACE_INVALID_HANDLE), + suspend_entry_ (false) +{ +} + +ACE_INLINE void +ACE_WFMO_Reactor_Handler_Repository::To_Be_Added_Info::set (ACE_HANDLE event_handle, + bool io_entry, + ACE_Event_Handler *event_handler, + ACE_HANDLE io_handle, + long network_events, + bool delete_event, + bool delete_entry, + ACE_Reactor_Mask close_masks, + bool suspend_entry) +{ + this->event_handle_ = event_handle; + this->suspend_entry_ = suspend_entry; + Common_Info::set (io_entry, + event_handler, + io_handle, + network_events, + delete_event, + delete_entry, + close_masks); +} + +ACE_INLINE void +ACE_WFMO_Reactor_Handler_Repository::To_Be_Added_Info::set (ACE_HANDLE event_handle, + Common_Info &common_info, + bool suspend_entry) +{ + this->event_handle_ = event_handle; + this->suspend_entry_ = suspend_entry; + Common_Info::set (common_info); +} + +ACE_INLINE void +ACE_WFMO_Reactor_Handler_Repository::To_Be_Added_Info::reset (void) +{ + this->event_handle_ = ACE_INVALID_HANDLE; + this->suspend_entry_ = false; + Common_Info::reset (); +} + +ACE_INLINE void +ACE_WFMO_Reactor_Handler_Repository::To_Be_Added_Info::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + ACE_TRACE ("ACE_WFMO_Reactor_Handler_Repository::To_Be_Added_Info::dump"); + + ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); + + Common_Info::dump (); + + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("Event Handle = %d\n"), + this->event_handle_)); + + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("Suspend Entry = %d\n"), + this->suspend_entry_)); + + ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); +#endif /* ACE_HAS_DUMP */ +} + +/************************************************************/ + +ACE_INLINE +ACE_WFMO_Reactor_Handler_Repository::Suspended_Info::Suspended_Info (void) + : event_handle_ (ACE_INVALID_HANDLE), + resume_entry_ (false) +{ +} + +ACE_INLINE void +ACE_WFMO_Reactor_Handler_Repository::Suspended_Info::reset (void) +{ + this->event_handle_ = ACE_INVALID_HANDLE; + this->resume_entry_ = false; + Common_Info::reset (); +} + +ACE_INLINE void +ACE_WFMO_Reactor_Handler_Repository::Suspended_Info::set (ACE_HANDLE event_handle, + bool io_entry, + ACE_Event_Handler *event_handler, + ACE_HANDLE io_handle, + long network_events, + bool delete_event, + bool delete_entry, + ACE_Reactor_Mask close_masks, + bool resume_entry) +{ + this->event_handle_ = event_handle; + this->resume_entry_ = resume_entry; + Common_Info::set (io_entry, + event_handler, + io_handle, + network_events, + delete_event, + delete_entry, + close_masks); +} + +ACE_INLINE void +ACE_WFMO_Reactor_Handler_Repository::Suspended_Info::set (ACE_HANDLE event_handle, + Common_Info &common_info, + bool resume_entry) +{ + this->event_handle_ = event_handle; + this->resume_entry_ = resume_entry; + Common_Info::set (common_info); +} + +ACE_INLINE void +ACE_WFMO_Reactor_Handler_Repository::Suspended_Info::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + ACE_TRACE ("ACE_WFMO_Reactor_Handler_Repository::Suspended_Info::dump"); + + ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); + + Common_Info::dump (); + + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("Event Handle = %d\n"), + this->event_handle_)); + + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("Resume Entry = %d\n"), + this->resume_entry_)); + + ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); +#endif /* ACE_HAS_DUMP */ +} + +/************************************************************/ + +ACE_INLINE int +ACE_WFMO_Reactor_Handler_Repository::close (void) +{ + // Let all the handlers know that the is closing down + this->unbind_all (); + + return 0; +} + +ACE_INLINE ACE_HANDLE * +ACE_WFMO_Reactor_Handler_Repository::handles (void) const +{ + // This code is probably too subtle to be useful in the long run... + // The basic idea is that all threads wait on all user handles plus + // the handle. The owner thread additional + // waits on the handle. This is to ensure that only the + // thread get to expire timers and handle event on the + // notify pipe. + if (ACE_Thread::self () == this->wfmo_reactor_.owner_i ()) + return this->current_handles_; + else + return this->current_handles_ + 1; +} + +ACE_INLINE ACE_WFMO_Reactor_Handler_Repository::Current_Info * +ACE_WFMO_Reactor_Handler_Repository::current_info (void) const +{ + if (ACE_Thread::self () == this->wfmo_reactor_.owner_i ()) + return this->current_info_; + else + return this->current_info_ + 1; +} + +ACE_INLINE DWORD +ACE_WFMO_Reactor_Handler_Repository::max_handlep1 (void) const +{ + if (ACE_Thread::self () == this->wfmo_reactor_.owner_i ()) + return this->max_handlep1_; + else + return this->max_handlep1_ - 1; +} + +ACE_INLINE int +ACE_WFMO_Reactor_Handler_Repository::scheduled_for_deletion (size_t slot) const +{ + if (ACE_Thread::self () == this->wfmo_reactor_.owner_i ()) + return this->current_info_[slot].delete_entry_ == true; + else + return this->current_info_[slot + 1].delete_entry_ == true; +} + +ACE_INLINE int +ACE_WFMO_Reactor_Handler_Repository::invalid_handle (ACE_HANDLE handle) const +{ + ACE_TRACE ("ACE_WFMO_Reactor_Handler_Repository::invalid_handle"); + // It's too expensive to perform more exhaustive validity checks on + // Win32 due to the way that they implement SOCKET HANDLEs. + if (handle == ACE_INVALID_HANDLE) + { + errno = EINVAL; + return 1; + } + else + return 0; +} + +ACE_INLINE bool +ACE_WFMO_Reactor_Handler_Repository::changes_required (void) +{ + // Check if handles have be scheduled for additions or removal + return this->handles_to_be_added_ > 0 + || this->handles_to_be_deleted_ > 0 + || this->handles_to_be_suspended_ > 0 + || this->handles_to_be_resumed_ > 0; +} + +ACE_INLINE int +ACE_WFMO_Reactor_Handler_Repository::make_changes (void) +{ + // This method must ONLY be called by the + // change_state_thread_>. We therefore assume that + // there will be no contention for this method and hence no guards + // are neccessary. + + // Deletions and suspensions in current_info_ + this->make_changes_in_current_infos (); + + // Deletions and resumptions in current_suspended_info_ + this->make_changes_in_suspension_infos (); + + // Deletions in to_be_added_info_, or transfers to current_info_ or + // current_suspended_info_ from to_be_added_info_ + this->make_changes_in_to_be_added_infos (); + + return 0; +} + +ACE_INLINE int +ACE_WFMO_Reactor_Handler_Repository::unbind (ACE_HANDLE handle, + ACE_Reactor_Mask mask) +{ + if (this->invalid_handle (handle)) + return -1; + + ACE_GUARD_RETURN (ACE_Process_Mutex, ace_mon, this->wfmo_reactor_.lock_, -1); + + bool changes_required = false; + int const result = this->unbind_i (handle, + mask, + changes_required); + + if (changes_required) + // Wake up all threads in WaitForMultipleObjects so that they can + // reconsult the handle set + this->wfmo_reactor_.wakeup_all_threads (); + + return result; +} + +ACE_INLINE int +ACE_WFMO_Reactor::reset_timer_interval + (long timer_id, + const ACE_Time_Value &interval) +{ + ACE_TRACE ("ACE_WFMO_Reactor::reset_timer_interval"); + + if (0 != this->timer_queue_) + { + long result = this->timer_queue_->reset_interval + (timer_id, + interval); + + // Wakeup the owner thread so that it gets the latest timer values + this->notify (); + + return result; + } + + errno = ESHUTDOWN; + return -1; +} + +ACE_INLINE long +ACE_WFMO_Reactor::schedule_timer (ACE_Event_Handler *handler, + const void *arg, + const ACE_Time_Value &delay_time, + const ACE_Time_Value &interval) +{ + ACE_TRACE ("ACE_WFMO_Reactor::schedule_timer"); + + if (0 != this->timer_queue_) + { + long result = this->timer_queue_->schedule + (handler, + arg, + timer_queue_->gettimeofday () + delay_time, + interval); + + // Wakeup the owner thread so that it gets the latest timer values + this->notify (); + + return result; + } + + errno = ESHUTDOWN; + return -1; +} + +ACE_INLINE int +ACE_WFMO_Reactor::cancel_timer (ACE_Event_Handler *handler, + int dont_call_handle_close) +{ + ACE_TRACE ("ACE_WFMO_Reactor::cancel_timer"); + if (0 != this->timer_queue_) + return this->timer_queue_->cancel (handler, dont_call_handle_close); + return 0; +} + +ACE_INLINE int +ACE_WFMO_Reactor::cancel_timer (long timer_id, + const void **arg, + int dont_call_handle_close) +{ + ACE_TRACE ("ACE_WFMO_Reactor::cancel_timer"); + if (0 != this->timer_queue_) + return this->timer_queue_->cancel (timer_id, arg, dont_call_handle_close); + return 0; +} + +ACE_INLINE int +ACE_WFMO_Reactor::register_handler (ACE_Event_Handler *event_handler, + ACE_HANDLE event_handle) +{ + // This GUARD is necessary since we are updating shared state. + ACE_GUARD_RETURN (ACE_Process_Mutex, ace_mon, this->lock_, -1); + + return this->handler_rep_.bind_i (0, + event_handler, + 0, + ACE_INVALID_HANDLE, + event_handle, + 0); +} + +ACE_INLINE int +ACE_WFMO_Reactor::register_handler (ACE_Event_Handler *event_handler, + ACE_Reactor_Mask mask) +{ + // This GUARD is necessary since we are updating shared state. + ACE_GUARD_RETURN (ACE_Process_Mutex, ace_mon, this->lock_, -1); + + return this->register_handler_i (ACE_INVALID_HANDLE, + ACE_INVALID_HANDLE, + event_handler, + mask); +} + +ACE_INLINE int +ACE_WFMO_Reactor::register_handler (ACE_HANDLE io_handle, + ACE_Event_Handler *event_handler, + ACE_Reactor_Mask mask) +{ + // This GUARD is necessary since we are updating shared state. + ACE_GUARD_RETURN (ACE_Process_Mutex, ace_mon, this->lock_, -1); + + return this->register_handler_i (ACE_INVALID_HANDLE, + io_handle, + event_handler, + mask); +} + +ACE_INLINE int +ACE_WFMO_Reactor::register_handler (ACE_HANDLE event_handle, + ACE_HANDLE io_handle, + ACE_Event_Handler *event_handler, + ACE_Reactor_Mask mask) +{ + // This GUARD is necessary since we are updating shared state. + ACE_GUARD_RETURN (ACE_Process_Mutex, ace_mon, this->lock_, -1); + + return this->register_handler_i (event_handle, + io_handle, + event_handler, + mask); +} + +ACE_INLINE int +ACE_WFMO_Reactor::register_handler (const ACE_Handle_Set &handles, + ACE_Event_Handler *handler, + ACE_Reactor_Mask mask) +{ + // This GUARD is necessary since we are updating shared state. + ACE_GUARD_RETURN (ACE_Process_Mutex, ace_mon, this->lock_, -1); + + ACE_Handle_Set_Iterator handle_iter (handles); + ACE_HANDLE h; + + while ((h = handle_iter ()) != ACE_INVALID_HANDLE) + if (this->register_handler_i (h, + ACE_INVALID_HANDLE, + handler, + mask) == -1) + return -1; + + return 0; +} + +ACE_INLINE int +ACE_WFMO_Reactor::schedule_wakeup (ACE_HANDLE io_handle, + ACE_Reactor_Mask masks_to_be_added) +{ + // This GUARD is necessary since we are updating shared state. + ACE_GUARD_RETURN (ACE_Process_Mutex, ace_mon, this->lock_, -1); + + return this->mask_ops_i (io_handle, + masks_to_be_added, + ACE_Reactor::ADD_MASK); +} + +ACE_INLINE int +ACE_WFMO_Reactor::schedule_wakeup (ACE_Event_Handler *event_handler, + ACE_Reactor_Mask masks_to_be_added) +{ + // This GUARD is necessary since we are updating shared state. + ACE_GUARD_RETURN (ACE_Process_Mutex, ace_mon, this->lock_, -1); + + return this->mask_ops_i (event_handler->get_handle (), + masks_to_be_added, + ACE_Reactor::ADD_MASK); +} + +ACE_INLINE int +ACE_WFMO_Reactor::cancel_wakeup (ACE_HANDLE io_handle, + ACE_Reactor_Mask masks_to_be_removed) +{ + // This GUARD is necessary since we are updating shared state. + ACE_GUARD_RETURN (ACE_Process_Mutex, ace_mon, this->lock_, -1); + + return this->mask_ops_i (io_handle, + masks_to_be_removed, + ACE_Reactor::CLR_MASK); +} + +ACE_INLINE int +ACE_WFMO_Reactor::cancel_wakeup (ACE_Event_Handler *event_handler, + ACE_Reactor_Mask masks_to_be_removed) +{ + // This GUARD is necessary since we are updating shared state. + ACE_GUARD_RETURN (ACE_Process_Mutex, ace_mon, this->lock_, -1); + + return this->mask_ops_i (event_handler->get_handle (), + masks_to_be_removed, + ACE_Reactor::CLR_MASK); +} + +ACE_INLINE int +ACE_WFMO_Reactor::remove_handler (ACE_Event_Handler *event_handler, + ACE_Reactor_Mask mask) +{ + return this->handler_rep_.unbind (event_handler->get_handle (), + mask); +} + +ACE_INLINE int +ACE_WFMO_Reactor::remove_handler (ACE_HANDLE handle, + ACE_Reactor_Mask mask) +{ + return this->handler_rep_.unbind (handle, + mask); +} + +ACE_INLINE int +ACE_WFMO_Reactor::remove_handler (const ACE_Handle_Set &handles, + ACE_Reactor_Mask mask) +{ + ACE_Handle_Set_Iterator handle_iter (handles); + ACE_HANDLE h; + bool changes_required = false; + + ACE_GUARD_RETURN (ACE_Process_Mutex, ace_mon, this->lock_, -1); + + while ((h = handle_iter ()) != ACE_INVALID_HANDLE) + if (this->handler_rep_.unbind_i (h, + mask, + changes_required) == -1) + return -1; + + // Wake up all threads in WaitForMultipleObjects so that they can + // reconsult the handle set + this->wakeup_all_threads (); + + return 0; +} + +ACE_INLINE int +ACE_WFMO_Reactor::suspend_handler (ACE_HANDLE handle) +{ + ACE_GUARD_RETURN (ACE_Process_Mutex, ace_mon, this->lock_, -1); + + bool changes_required = false; + int const result = + this->handler_rep_.suspend_handler_i (handle, + changes_required); + + if (changes_required) + // Wake up all threads in WaitForMultipleObjects so that they can + // reconsult the handle set + this->wakeup_all_threads (); + + return result; +} + +ACE_INLINE int +ACE_WFMO_Reactor::suspend_handler (ACE_Event_Handler *event_handler) +{ + return this->suspend_handler (event_handler->get_handle ()); +} + +ACE_INLINE int +ACE_WFMO_Reactor::suspend_handler (const ACE_Handle_Set &handles) +{ + ACE_Handle_Set_Iterator handle_iter (handles); + ACE_HANDLE h; + bool changes_required = false; + + ACE_GUARD_RETURN (ACE_Process_Mutex, ace_mon, this->lock_, -1); + + while ((h = handle_iter ()) != ACE_INVALID_HANDLE) + if (this->handler_rep_.suspend_handler_i (h, + changes_required) == -1) + return -1; + + // Wake up all threads in WaitForMultipleObjects so that they can + // reconsult the handle set + this->wakeup_all_threads (); + + return 0; +} + +ACE_INLINE int +ACE_WFMO_Reactor::suspend_handlers (void) +{ + bool error = false; + int result = 0; + ACE_GUARD_RETURN (ACE_Process_Mutex, ace_mon, this->lock_, -1); + + // First suspend all current handles + bool changes_required = false; + + for (size_t i = 0; + i < this->handler_rep_.max_handlep1_ && !error; + i++) + { + result = + this->handler_rep_.suspend_handler_i (this->handler_rep_.current_handles_[i], + changes_required); + if (result == -1) + error = true; + } + + // Then suspend all to_be_added_handles + for (size_t i = 0; + i < this->handler_rep_.handles_to_be_added_ && !error; + i++) + { + if (this->handler_rep_.to_be_added_info_[i].io_entry_) + { + result = + this->handler_rep_.suspend_handler_i (this->handler_rep_.to_be_added_info_[i].io_handle_, + changes_required); + } + else + { + result = + this->handler_rep_.suspend_handler_i (this->handler_rep_.to_be_added_info_[i].event_handle_, + changes_required); + } + if (result == -1) + error = true; + } + + // Wake up all threads in WaitForMultipleObjects so that they can + // reconsult the handle set + this->wakeup_all_threads (); + + return error ? -1 : 0; +} + +ACE_INLINE int +ACE_WFMO_Reactor::resume_handler (ACE_HANDLE handle) +{ + ACE_GUARD_RETURN (ACE_Process_Mutex, ace_mon, this->lock_, -1); + + bool changes_required = false; + int result = + this->handler_rep_.resume_handler_i (handle, changes_required); + + if (changes_required) + // Wake up all threads in WaitForMultipleObjects so that they can + // reconsult the handle set + this->wakeup_all_threads (); + + return result; +} + +ACE_INLINE int +ACE_WFMO_Reactor::resume_handler (ACE_Event_Handler *event_handler) +{ + return this->resume_handler (event_handler->get_handle ()); +} + +ACE_INLINE int +ACE_WFMO_Reactor::resume_handler (const ACE_Handle_Set &handles) +{ + ACE_Handle_Set_Iterator handle_iter (handles); + ACE_HANDLE h; + bool changes_required = false; + + ACE_GUARD_RETURN (ACE_Process_Mutex, ace_mon, this->lock_, -1); + + while ((h = handle_iter ()) != ACE_INVALID_HANDLE) + if (this->handler_rep_.resume_handler_i (h, + changes_required) == -1) + return -1; + + // Wake up all threads in WaitForMultipleObjects so that they can + // reconsult the handle set + this->wakeup_all_threads (); + + return 0; +} + +ACE_INLINE int +ACE_WFMO_Reactor::resume_handlers (void) +{ + bool error = false; + int result = 0; + ACE_GUARD_RETURN (ACE_Process_Mutex, ace_mon, this->lock_, -1); + + bool changes_required = false; + for (size_t i = 0; + i < this->handler_rep_.suspended_handles_ && !error; + i++) + { + result = + this->handler_rep_.resume_handler_i (this->handler_rep_.current_suspended_info_[i].event_handle_, + changes_required); + if (result == -1) + error = true; + } + + // Then resume all to_be_added_handles + for (size_t i = 0; + i < this->handler_rep_.handles_to_be_added_ && !error; + i++) + { + if (this->handler_rep_.to_be_added_info_[i].io_entry_) + { + result = + this->handler_rep_.resume_handler_i (this->handler_rep_.to_be_added_info_[i].io_handle_, + changes_required); + } + else + { + result = + this->handler_rep_.resume_handler_i (this->handler_rep_.to_be_added_info_[i].event_handle_, + changes_required); + } + if (result == -1) + error = true; + } + + // Wake up all threads in WaitForMultipleObjects so that they can + // reconsult the handle set + this->wakeup_all_threads (); + + return error ? -1 : 0; +} + +ACE_INLINE int +ACE_WFMO_Reactor::uses_event_associations (void) +{ + // Since the WFMO_Reactor does use event associations, this function + // always return 1. + return 1; +} + +ACE_INLINE int +ACE_WFMO_Reactor::handle_events (ACE_Time_Value &how_long) +{ + return this->event_handling (&how_long, FALSE); +} + +ACE_INLINE int +ACE_WFMO_Reactor::alertable_handle_events (ACE_Time_Value &how_long) +{ + return this->event_handling (&how_long, TRUE); +} + +ACE_INLINE int +ACE_WFMO_Reactor::handle_events (ACE_Time_Value *how_long) +{ + return this->event_handling (how_long, FALSE); +} + +ACE_INLINE int +ACE_WFMO_Reactor::alertable_handle_events (ACE_Time_Value *how_long) +{ + return this->event_handling (how_long, TRUE); +} + +ACE_INLINE int +ACE_WFMO_Reactor::deactivated (void) +{ + return this->deactivated_; +} + +ACE_INLINE void +ACE_WFMO_Reactor::deactivate (int do_stop) +{ + this->deactivated_ = do_stop; + this->wakeup_all_threads (); +} + +ACE_INLINE int +ACE_WFMO_Reactor::owner (ACE_thread_t *t) +{ + ACE_GUARD_RETURN (ACE_Process_Mutex, ace_mon, this->lock_, -1); + *t = this->owner_i (); + return 0; +} + +ACE_INLINE ACE_thread_t +ACE_WFMO_Reactor::owner_i (void) +{ + return this->owner_; +} + +ACE_INLINE int +ACE_WFMO_Reactor::owner (ACE_thread_t new_owner, ACE_thread_t *old_owner) +{ + ACE_GUARD_RETURN (ACE_Process_Mutex, monitor, this->lock_, -1); + this->new_owner_ = new_owner; + + if (old_owner != 0) + *old_owner = this->owner_i (); + + // Wake up all threads in WaitForMultipleObjects so that they can + // reconsult the new owner responsibilities + this->wakeup_all_threads (); + + return 0; +} + +ACE_INLINE int +ACE_WFMO_Reactor::new_owner (void) +{ + return this->new_owner_ != ACE_thread_t (0); +} + +ACE_INLINE int +ACE_WFMO_Reactor::change_owner (void) +{ + this->owner_ = this->new_owner_; + this->new_owner_ = ACE_thread_t (0); + return 0; +} + +ACE_INLINE int +ACE_WFMO_Reactor::safe_dispatch (DWORD wait_status) +{ + int result = -1; + ACE_SEH_TRY + { + result = this->dispatch (wait_status); + } + ACE_SEH_FINALLY + { + this->update_state (); + } + + return result; +} + +ACE_INLINE int +ACE_WFMO_Reactor::dispatch_window_messages (void) +{ + return 0; +} + +ACE_INLINE void +ACE_WFMO_Reactor::wakeup_all_threads (void) +{ + this->wakeup_all_threads_.signal (); +} + +ACE_INLINE int +ACE_WFMO_Reactor::notify (ACE_Event_Handler *event_handler, + ACE_Reactor_Mask mask, + ACE_Time_Value *timeout) +{ + return this->notify_handler_->notify (event_handler, mask, timeout); +} + +ACE_INLINE int +ACE_WFMO_Reactor::register_handler (int signum, + ACE_Event_Handler *new_sh, + ACE_Sig_Action *new_disp, + ACE_Event_Handler **old_sh, + ACE_Sig_Action *old_disp) +{ + return this->signal_handler_->register_handler (signum, + new_sh, new_disp, + old_sh, old_disp); +} + +ACE_INLINE int +ACE_WFMO_Reactor::register_handler (const ACE_Sig_Set &sigset, + ACE_Event_Handler *new_sh, + ACE_Sig_Action *new_disp) +{ + int result = 0; + +#if (ACE_NSIG > 0) + for (int s = 1; s < ACE_NSIG; s++) + if (sigset.is_member (s) + && this->signal_handler_->register_handler (s, + new_sh, + new_disp) == -1) + result = -1; +#else + ACE_UNUSED_ARG (sigset); + ACE_UNUSED_ARG (new_sh); + ACE_UNUSED_ARG (new_disp); +#endif /* ACE_NSIG */ + + return result; +} + +ACE_INLINE int +ACE_WFMO_Reactor::remove_handler (int signum, + ACE_Sig_Action *new_disp, + ACE_Sig_Action *old_disp, + int sigkey) +{ + return this->signal_handler_->remove_handler (signum, + new_disp, + old_disp, + sigkey); +} + +ACE_INLINE int +ACE_WFMO_Reactor::remove_handler (const ACE_Sig_Set &sigset) +{ + int result = 0; + +#if (ACE_NSIG > 0) + for (int s = 1; s < ACE_NSIG; s++) + if (sigset.is_member (s) + && this->signal_handler_->remove_handler (s) == -1) + result = -1; +#else + ACE_UNUSED_ARG (sigset); +#endif /* ACE_NSIG */ + + return result; +} + +ACE_INLINE int +ACE_WFMO_Reactor::handler (int signum, ACE_Event_Handler **eh) +{ + ACE_Event_Handler *handler = + this->signal_handler_->handler (signum); + + if (handler == 0) + return -1; + else if (eh != 0) + *eh = handler; + return 0; +} + +ACE_INLINE int +ACE_WFMO_Reactor::mask_ops (ACE_Event_Handler *event_handler, + ACE_Reactor_Mask mask, + int operation) +{ + ACE_GUARD_RETURN (ACE_Process_Mutex, monitor, this->lock_, -1); + + return this->mask_ops_i (event_handler->get_handle (), + mask, + operation); +} + +ACE_INLINE int +ACE_WFMO_Reactor::mask_ops (ACE_HANDLE io_handle, + ACE_Reactor_Mask mask, + int operation) +{ + ACE_GUARD_RETURN (ACE_Process_Mutex, monitor, this->lock_, -1); + + return this->mask_ops_i (io_handle, + mask, + operation); +} + +ACE_INLINE void +ACE_WFMO_Reactor::requeue_position (int) +{ + // Not implemented +} + +ACE_INLINE int +ACE_WFMO_Reactor::requeue_position (void) +{ + // Don't have an implementation for this yet... + ACE_NOTSUP_RETURN (-1); +} + +ACE_INLINE int +ACE_WFMO_Reactor::restart (void) +{ + return 0; +} + +ACE_INLINE int +ACE_WFMO_Reactor::restart (int) +{ + return 0; +} + +ACE_INLINE int +ACE_WFMO_Reactor::ready_ops (ACE_Event_Handler *event_handler, + ACE_Reactor_Mask mask, + int ops) +{ + // Don't have an implementation for this yet... + ACE_UNUSED_ARG (event_handler); + ACE_UNUSED_ARG (mask); + ACE_UNUSED_ARG (ops); + ACE_NOTSUP_RETURN (-1); +} + +ACE_INLINE int +ACE_WFMO_Reactor::ready_ops (ACE_HANDLE handle, + ACE_Reactor_Mask, + int ops) +{ + // Don't have an implementation for this yet... + ACE_UNUSED_ARG (handle); + ACE_UNUSED_ARG (ops); + ACE_NOTSUP_RETURN (-1); +} + +ACE_INLINE ACE_Event_Handler * +ACE_WFMO_Reactor::find_handler (ACE_HANDLE handle) +{ + ACE_GUARD_RETURN (ACE_Process_Mutex, ace_mon, this->lock_, 0); + + return this->handler_rep_.find_handler (handle); +} + +ACE_INLINE int +ACE_WFMO_Reactor::handler (ACE_HANDLE handle, + ACE_Reactor_Mask mask, + ACE_Event_Handler **event_handler) +{ + ACE_GUARD_RETURN (ACE_Process_Mutex, ace_mon, this->lock_, -1); + + return this->handler_rep_.handler (handle, + mask, + event_handler); +} + +ACE_INLINE bool +ACE_WFMO_Reactor::initialized (void) +{ + return this->open_for_business_; +} + +ACE_INLINE ACE_Lock & +ACE_WFMO_Reactor::lock (void) +{ + return this->lock_adapter_; +} + +ACE_INLINE size_t +ACE_WFMO_Reactor::size (void) const +{ + // Size of repository minus the 2 used for internal purposes + return this->handler_rep_.max_size_ - 2; +} +#else +ACE_INLINE bool +ACE_WFMO_Reactor_Handler_Repository::changes_required (void) +{ + return false; +} + +ACE_INLINE int +ACE_WFMO_Reactor_Handler_Repository::make_changes (void) +{ + return 0; +} + +ACE_INLINE +ACE_WFMO_Reactor_Handler_Repository::~ACE_WFMO_Reactor_Handler_Repository (void) +{ +} + +#endif /* ACE_WIN32 */ + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/WIN32_Asynch_IO.cpp b/dep/ACE_wrappers/ace/WIN32_Asynch_IO.cpp new file mode 100644 index 00000000000..6f201acccbd --- /dev/null +++ b/dep/ACE_wrappers/ace/WIN32_Asynch_IO.cpp @@ -0,0 +1,3778 @@ +// $Id: WIN32_Asynch_IO.cpp 82444 2008-07-28 13:33:07Z johnnyw $ + +#include "ace/WIN32_Asynch_IO.h" + +ACE_RCSID (ace, + Win32_Asynch_IO, + "$Id: WIN32_Asynch_IO.cpp 82444 2008-07-28 13:33:07Z johnnyw $") + +#if defined (ACE_HAS_WIN32_OVERLAPPED_IO) && \ + (defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 == 1)) + +#include "ace/WIN32_Proactor.h" +#include "ace/Proactor.h" +#include "ace/Message_Block.h" +#include "ace/Service_Config.h" +#include "ace/INET_Addr.h" +#include "ace/Task_T.h" +#include "ace/OS_NS_errno.h" +#include "ace/OS_NS_unistd.h" +#include "ace/OS_NS_sys_socket.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +size_t +ACE_WIN32_Asynch_Result::bytes_transferred (void) const +{ + return this->bytes_transferred_; +} + +const void * +ACE_WIN32_Asynch_Result::act (void) const +{ + return this->act_; +} + +int +ACE_WIN32_Asynch_Result::success (void) const +{ + return this->success_; +} + +const void * +ACE_WIN32_Asynch_Result::completion_key (void) const +{ + return this->completion_key_; +} + +u_long +ACE_WIN32_Asynch_Result::error (void) const +{ + return this->error_; +} + +ACE_HANDLE +ACE_WIN32_Asynch_Result::event (void) const +{ + return this->hEvent; +} + +u_long +ACE_WIN32_Asynch_Result::offset (void) const +{ + return this->Offset; +} + +u_long +ACE_WIN32_Asynch_Result::offset_high (void) const +{ + return this->OffsetHigh; +} + +int +ACE_WIN32_Asynch_Result::priority (void) const +{ + ACE_NOTSUP_RETURN (0); +} + +int +ACE_WIN32_Asynch_Result::signal_number (void) const +{ + ACE_NOTSUP_RETURN (0); +} + +int +ACE_WIN32_Asynch_Result::post_completion (ACE_Proactor_Impl *proactor) +{ + // Get to the platform specific implementation. + ACE_WIN32_Proactor *win32_proactor = dynamic_cast (proactor); + + if (win32_proactor == 0) + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("Dynamic cast to WIN32 Proactor failed\n")), + -1); + + // Post myself. + return win32_proactor->post_completion (this); +} + +void +ACE_WIN32_Asynch_Result::set_bytes_transferred (size_t nbytes) +{ + this->bytes_transferred_ = nbytes; +} + +void +ACE_WIN32_Asynch_Result::set_error (u_long errcode) +{ + this->error_ = errcode; +} + +ACE_WIN32_Asynch_Result::~ACE_WIN32_Asynch_Result (void) +{ +} + +ACE_WIN32_Asynch_Result::ACE_WIN32_Asynch_Result + (const ACE_Handler::Proxy_Ptr &handler_proxy, + const void* act, + ACE_HANDLE event, + u_long offset, + u_long offset_high, + int priority, + int signal_number) + : ACE_Asynch_Result_Impl (), + OVERLAPPED (), + handler_proxy_ (handler_proxy), + act_ (act), + bytes_transferred_ (0), + success_ (0), + completion_key_ (0), + error_ (0) +{ + // Set the ACE_OVERLAPPED structure + this->Internal = 0; + this->InternalHigh = 0; + this->Offset = offset; + this->OffsetHigh = offset_high; + this->hEvent = event; + + ACE_UNUSED_ARG (priority); + ACE_UNUSED_ARG (signal_number); +} + +int +ACE_WIN32_Asynch_Operation::open (const ACE_Handler::Proxy_Ptr &handler_proxy, + ACE_HANDLE handle, + const void *completion_key, + ACE_Proactor *proactor) +{ + this->proactor_ = proactor; + this->handler_proxy_ = handler_proxy; + this->handle_ = handle; + + // Grab the handle from the if is invalid + if (this->handle_ == ACE_INVALID_HANDLE) + { + ACE_Handler *handler = handler_proxy.get ()->handler (); + if (handler != 0) + this->handle_ = handler->handle (); + } + if (this->handle_ == ACE_INVALID_HANDLE) + return -1; + + if (this->proactor_!= 0) + // update implementation. + this->win32_proactor_ = + dynamic_cast (this->proactor_->implementation ()); + + // Register with the . + return this->win32_proactor_->register_handle (this->handle_, + completion_key); +} + +int +ACE_WIN32_Asynch_Operation::cancel (void) +{ +#if defined (ACE_HAS_WIN32_OVERLAPPED_IO) + // All I/O operations that are canceled will complete with the error + // ERROR_OPERATION_ABORTED. All completion notifications for the I/O + // operations will occur normally. + + // @@ This API returns 0 on failure. So, I am returning -1 in that + // case. Is that right? (Alex). + int const result = (int) ::CancelIo (this->handle_); + + if (result == 0) + // Couldn't cancel the operations. + return 2; + + // result is non-zero. All the operations are cancelled then. + return 0; + +#else /* !ACE_HAS_WIN32_OVERLAPPED_IO */ + ACE_NOTSUP_RETURN (-1); +#endif /* ACE_HAS_AIO_CALLS */ +} + +ACE_Proactor * +ACE_WIN32_Asynch_Operation::proactor (void) const +{ + return this->proactor_; +} + +ACE_WIN32_Asynch_Operation::ACE_WIN32_Asynch_Operation (ACE_WIN32_Proactor *win32_proactor) + : ACE_Asynch_Operation_Impl (), + win32_proactor_ (win32_proactor), + proactor_ (0), + handle_ (ACE_INVALID_HANDLE) +{ +} + +ACE_WIN32_Asynch_Operation::~ACE_WIN32_Asynch_Operation (void) +{ +} + +// ************************************************************ + +size_t +ACE_WIN32_Asynch_Read_Stream_Result::bytes_to_read (void) const +{ + return this->bytes_to_read_; +} + +ACE_Message_Block & +ACE_WIN32_Asynch_Read_Stream_Result::message_block (void) const +{ + return this->message_block_; +} + +ACE_HANDLE +ACE_WIN32_Asynch_Read_Stream_Result::handle (void) const +{ + return this->handle_; +} + +ACE_WIN32_Asynch_Read_Stream_Result::ACE_WIN32_Asynch_Read_Stream_Result ( + const ACE_Handler::Proxy_Ptr &handler_proxy, + ACE_HANDLE handle, + ACE_Message_Block &message_block, + size_t bytes_to_read, + const void* act, + ACE_HANDLE event, + int priority, + int signal_number, + int scatter_enabled) + : ACE_Asynch_Result_Impl (), + ACE_Asynch_Read_Stream_Result_Impl (), + ACE_WIN32_Asynch_Result (handler_proxy, + act, + event, + 0, + 0, + priority, + signal_number), + bytes_to_read_ (bytes_to_read), + message_block_ (message_block), + handle_ (handle), + scatter_enabled_ (scatter_enabled) +{ +} + +void +ACE_WIN32_Asynch_Read_Stream_Result::complete (size_t bytes_transferred, + int success, + const void *completion_key, + u_long error) +{ + // Copy the data which was returned by GetQueuedCompletionStatus + this->bytes_transferred_ = bytes_transferred; + this->success_ = success; + this->completion_key_ = completion_key; + this->error_ = error; + + // Appropriately move the pointers in the message block. + if (!this->scatter_enabled ()) + this->message_block_.wr_ptr (bytes_transferred); + else + { + for (ACE_Message_Block* mb = &this->message_block_; + (mb != 0) && (bytes_transferred > 0); + mb = mb->cont ()) + { + size_t len_part = mb->space (); + + if (len_part > bytes_transferred) + len_part = bytes_transferred; + + mb->wr_ptr (len_part); + + bytes_transferred -= len_part; + } + } + + // Create the interface result class. + ACE_Asynch_Read_Stream::Result result (this); + + // Call the application handler. + ACE_Handler *handler = this->handler_proxy_.get ()->handler (); + if (handler != 0) + handler->handle_read_stream (result); +} + +ACE_WIN32_Asynch_Read_Stream_Result::~ACE_WIN32_Asynch_Read_Stream_Result (void) +{ +} + +// Base class operations. These operations are here to kill dominance +// warnings. These methods call the base class methods. + +size_t +ACE_WIN32_Asynch_Read_Stream_Result::bytes_transferred (void) const +{ + return ACE_WIN32_Asynch_Result::bytes_transferred (); +} + +const void * +ACE_WIN32_Asynch_Read_Stream_Result::act (void) const +{ + return ACE_WIN32_Asynch_Result::act (); +} + +int +ACE_WIN32_Asynch_Read_Stream_Result::success (void) const +{ + return ACE_WIN32_Asynch_Result::success (); +} + +const void * +ACE_WIN32_Asynch_Read_Stream_Result::completion_key (void) const +{ + return ACE_WIN32_Asynch_Result::completion_key (); +} + +u_long +ACE_WIN32_Asynch_Read_Stream_Result::error (void) const +{ + return ACE_WIN32_Asynch_Result::error (); +} + +ACE_HANDLE +ACE_WIN32_Asynch_Read_Stream_Result::event (void) const +{ + return ACE_WIN32_Asynch_Result::event (); +} + +u_long +ACE_WIN32_Asynch_Read_Stream_Result::offset (void) const +{ + return ACE_WIN32_Asynch_Result::offset (); +} + +u_long +ACE_WIN32_Asynch_Read_Stream_Result::offset_high (void) const +{ + return ACE_WIN32_Asynch_Result::offset_high (); +} + +int +ACE_WIN32_Asynch_Read_Stream_Result::priority (void) const +{ + return ACE_WIN32_Asynch_Result::priority (); +} + +int +ACE_WIN32_Asynch_Read_Stream_Result::signal_number (void) const +{ + return ACE_WIN32_Asynch_Result::signal_number (); +} + +int +ACE_WIN32_Asynch_Read_Stream_Result::post_completion (ACE_Proactor_Impl *proactor) +{ + return ACE_WIN32_Asynch_Result::post_completion (proactor); +} + +int +ACE_WIN32_Asynch_Read_Stream_Result::scatter_enabled (void) const +{ + return this->scatter_enabled_; +} + +ACE_WIN32_Asynch_Read_Stream::ACE_WIN32_Asynch_Read_Stream (ACE_WIN32_Proactor *win32_proactor) + : ACE_Asynch_Operation_Impl (), + ACE_Asynch_Read_Stream_Impl (), + ACE_WIN32_Asynch_Operation (win32_proactor) +{ +} + +int +ACE_WIN32_Asynch_Read_Stream::read (ACE_Message_Block &message_block, + size_t bytes_to_read, + const void *act, + int priority, + int signal_number) +{ + size_t space = message_block.space (); + if (bytes_to_read > space) + bytes_to_read = space; + + if (bytes_to_read == 0) + { + errno = ENOSPC; + return -1; + } + + // Create the Asynch_Result. + ACE_WIN32_Asynch_Read_Stream_Result *result = 0; + ACE_NEW_RETURN (result, + ACE_WIN32_Asynch_Read_Stream_Result (this->handler_proxy_, + this->handle_, + message_block, + bytes_to_read, + act, + this->win32_proactor_->get_handle (), + priority, + signal_number), + -1); + + // Shared read + int const return_val = this->shared_read (result); + + // Upon errors + if (return_val == -1) + delete result; + + return return_val; +} + +int +ACE_WIN32_Asynch_Read_Stream::readv (ACE_Message_Block &message_block, + size_t bytes_to_read, + const void *act, + int priority, + int signal_number) +{ +#if (defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)) + iovec iov[ACE_IOV_MAX]; + int iovcnt = 0; + + // We should not read more than user requested, + // but it is allowed to read less + + for (const ACE_Message_Block* msg = &message_block; + msg != 0 && bytes_to_read > 0 && iovcnt < ACE_IOV_MAX; + msg = msg->cont () , ++iovcnt ) + { + size_t msg_space = msg->space (); + + // OS should correctly process zero length buffers + // if ( msg_space == 0 ) + // ACE_ERROR_RETURN ((LM_ERROR, + // ACE_TEXT ("ACE_WIN32_Asynch_Read_Stream::readv:") + // ACE_TEXT ("No space in the message block\n")), + // -1); + + if (msg_space > bytes_to_read) + msg_space = bytes_to_read; + bytes_to_read -= msg_space; + + // Make as many iovec as needed to fit all of msg_space. + size_t wr_ptr_offset = 0; + + while (msg_space > 0 && iovcnt < ACE_IOV_MAX) + { + u_long this_chunk_length; + if (msg_space > ULONG_MAX) + this_chunk_length = ULONG_MAX; + else + this_chunk_length = static_cast (msg_space); + // Collect the data in the iovec. + iov[iovcnt].iov_base = msg->wr_ptr () + wr_ptr_offset; + iov[iovcnt].iov_len = this_chunk_length; + msg_space -= this_chunk_length; + wr_ptr_offset += this_chunk_length; + + // Increment iovec counter if there's more to do. + if (msg_space > 0) + ++iovcnt; + } + if (msg_space > 0) // Ran out of iovecs before msg_space exhausted + { + errno = ERANGE; + return -1; + } + } + + // Re-calculate number bytes to read + bytes_to_read = 0; + + for (int i = 0; i < iovcnt ; ++i) + bytes_to_read += iov[i].iov_len; + + if (bytes_to_read == 0) + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("ACE_WIN32_Asynch_Read_Stream::readv:") + ACE_TEXT ("Attempt to read 0 bytes\n")), + -1); + + // Create the Asynch_Result. + ACE_WIN32_Asynch_Read_Stream_Result *result = 0; + ACE_NEW_RETURN (result, + ACE_WIN32_Asynch_Read_Stream_Result (this->handler_proxy_, + this->handle_, + message_block, + bytes_to_read, + act, + this->win32_proactor_->get_handle (), + priority, + signal_number, + 1), // scatter read enabled + -1); + + // do the scatter recv + + result->set_error (0); // Clear error before starting IO. + + DWORD bytes_recvd = 0; + u_long flags = 0; + + int initiate_result = ::WSARecv (reinterpret_cast (result->handle ()), + reinterpret_cast (iov), + iovcnt, + &bytes_recvd, + &flags, + result, + 0); + + if (0 == initiate_result) + // Immediate success: the OVERLAPPED will still get queued. + return 1; + + ACE_ASSERT (initiate_result == SOCKET_ERROR); + + // If initiate failed, check for a bad error. + ACE_OS::set_errno_to_last_error (); + switch (errno) + { + case ERROR_IO_PENDING: + // The IO will complete proactively: the OVERLAPPED will still + // get queued. + initiate_result = 0; + break; + + default: + // Something else went wrong: the OVERLAPPED will not get + // queued. + + if (ACE::debug ()) + { + ACE_DEBUG ((LM_ERROR, + ACE_TEXT ("%p\n"), + ACE_TEXT ("WSARecv"))); + } + + delete result; + initiate_result = -1; + break; + } + + return initiate_result; +#else + ACE_UNUSED_ARG (message_block); + ACE_UNUSED_ARG (bytes_to_read); + ACE_UNUSED_ARG (act); + ACE_UNUSED_ARG (priority); + ACE_UNUSED_ARG (signal_number); + ACE_NOTSUP_RETURN (-1); +#endif /* ACE_HAS_WINSOCK2 && ACE_HAS_WINSOCK2 != 0 */ +} + +ACE_WIN32_Asynch_Read_Stream::~ACE_WIN32_Asynch_Read_Stream (void) +{ +} + +int +ACE_WIN32_Asynch_Read_Stream::shared_read (ACE_WIN32_Asynch_Read_Stream_Result *result) +{ + // ReadFile API limits us to DWORD range. + if (result->bytes_to_read () > MAXDWORD) + { + errno = ERANGE; + return -1; + } + DWORD bytes_to_read = static_cast (result->bytes_to_read ()); + u_long bytes_read; + + result->set_error (0); // Clear error before starting IO. + + // Initiate the read + int initiate_result = ::ReadFile (result->handle (), + result->message_block ().wr_ptr (), + bytes_to_read, + &bytes_read, + result); + if (initiate_result == 1) + // Immediate success: the OVERLAPPED will still get queued. + return 0; + + // If initiate failed, check for a bad error. + ACE_OS::set_errno_to_last_error (); + switch (errno) + { + case ERROR_IO_PENDING: + /* FALLTHRU */ + case ERROR_MORE_DATA: + // The IO will complete proactively: the OVERLAPPED will still + // get queued. + return 0; + + default: + // Something else went wrong: the OVERLAPPED will not get + // queued. + + if (ACE::debug ()) + { + ACE_DEBUG ((LM_ERROR, + ACE_TEXT ("%p\n"), + ACE_TEXT ("ReadFile"))); + } + + return -1; + } +} + +// Methods belong to ACE_WIN32_Asynch_Operation base class. These +// methods are defined here to avoid VC++ warnings. They route the +// call to the ACE_WIN32_Asynch_Operation base class. + +int +ACE_WIN32_Asynch_Read_Stream::open (const ACE_Handler::Proxy_Ptr &handler_proxy, + ACE_HANDLE handle, + const void *completion_key, + ACE_Proactor *proactor) +{ + return ACE_WIN32_Asynch_Operation::open (handler_proxy, + handle, + completion_key, + proactor); +} + +int +ACE_WIN32_Asynch_Read_Stream::cancel (void) +{ + return ACE_WIN32_Asynch_Operation::cancel (); +} + +ACE_Proactor * +ACE_WIN32_Asynch_Read_Stream::proactor (void) const +{ + return ACE_WIN32_Asynch_Operation::proactor (); +} + +size_t +ACE_WIN32_Asynch_Write_Stream_Result::bytes_to_write (void) const +{ + return this->bytes_to_write_; +} + +ACE_Message_Block & +ACE_WIN32_Asynch_Write_Stream_Result::message_block (void) const +{ + return this->message_block_; +} + +ACE_HANDLE +ACE_WIN32_Asynch_Write_Stream_Result::handle (void) const +{ + return this->handle_; +} + +ACE_WIN32_Asynch_Write_Stream_Result::ACE_WIN32_Asynch_Write_Stream_Result ( + const ACE_Handler::Proxy_Ptr &handler_proxy, + ACE_HANDLE handle, + ACE_Message_Block &message_block, + size_t bytes_to_write, + const void* act, + ACE_HANDLE event, + int priority, + int signal_number, + int gather_enabled) + : ACE_Asynch_Result_Impl (), + ACE_Asynch_Write_Stream_Result_Impl (), + ACE_WIN32_Asynch_Result + (handler_proxy, act, event, 0, 0, priority, signal_number), + bytes_to_write_ (bytes_to_write), + message_block_ (message_block), + handle_ (handle), + gather_enabled_ (gather_enabled) +{ +} + +void +ACE_WIN32_Asynch_Write_Stream_Result::complete (size_t bytes_transferred, + int success, + const void *completion_key, + u_long error) +{ + // Copy the data which was returned by . + this->bytes_transferred_ = bytes_transferred; + this->success_ = success; + this->completion_key_ = completion_key; + this->error_ = error; + + // Appropriately move the pointers in the message block. + if (!this->gather_enabled ()) + this->message_block_.rd_ptr (bytes_transferred); + else + { + for (ACE_Message_Block* mb = &this->message_block_; + (mb != 0) && (bytes_transferred > 0); + mb = mb->cont ()) + { + size_t len_part = mb->length (); + + if ( len_part > bytes_transferred) + len_part = bytes_transferred; + + mb->rd_ptr (len_part); + + bytes_transferred -= len_part; + } + } + + // Create the interface result class. + ACE_Asynch_Write_Stream::Result result (this); + + // Call the application handler. + ACE_Handler *handler = this->handler_proxy_.get ()->handler (); + if (handler != 0) + handler->handle_write_stream (result); +} + +ACE_WIN32_Asynch_Write_Stream_Result::~ACE_WIN32_Asynch_Write_Stream_Result (void) +{ +} + +// Base class operations. These operations are here to kill dominance +// warnings. These methods call the base class methods. + +size_t +ACE_WIN32_Asynch_Write_Stream_Result::bytes_transferred (void) const +{ + return ACE_WIN32_Asynch_Result::bytes_transferred (); +} + +const void * +ACE_WIN32_Asynch_Write_Stream_Result::act (void) const +{ + return ACE_WIN32_Asynch_Result::act (); +} + +int +ACE_WIN32_Asynch_Write_Stream_Result::success (void) const +{ + return ACE_WIN32_Asynch_Result::success (); +} + +const void * +ACE_WIN32_Asynch_Write_Stream_Result::completion_key (void) const +{ + return ACE_WIN32_Asynch_Result::completion_key (); +} + +u_long +ACE_WIN32_Asynch_Write_Stream_Result::error (void) const +{ + return ACE_WIN32_Asynch_Result::error (); +} + +ACE_HANDLE +ACE_WIN32_Asynch_Write_Stream_Result::event (void) const +{ + return ACE_WIN32_Asynch_Result::event (); +} + +u_long +ACE_WIN32_Asynch_Write_Stream_Result::offset (void) const +{ + return ACE_WIN32_Asynch_Result::offset (); +} + +u_long +ACE_WIN32_Asynch_Write_Stream_Result::offset_high (void) const +{ + return ACE_WIN32_Asynch_Result::offset_high (); +} + +int +ACE_WIN32_Asynch_Write_Stream_Result::priority (void) const +{ + return ACE_WIN32_Asynch_Result::priority (); +} + +int +ACE_WIN32_Asynch_Write_Stream_Result::signal_number (void) const +{ + return ACE_WIN32_Asynch_Result::signal_number (); +} + +int +ACE_WIN32_Asynch_Write_Stream_Result::post_completion (ACE_Proactor_Impl *proactor) +{ + return ACE_WIN32_Asynch_Result::post_completion (proactor); +} + +int +ACE_WIN32_Asynch_Write_Stream_Result::gather_enabled (void) const +{ + return this->gather_enabled_; +} + +ACE_WIN32_Asynch_Write_Stream::ACE_WIN32_Asynch_Write_Stream (ACE_WIN32_Proactor *win32_proactor) + : ACE_Asynch_Operation_Impl (), + ACE_Asynch_Write_Stream_Impl (), + ACE_WIN32_Asynch_Operation (win32_proactor) +{ +} + +int +ACE_WIN32_Asynch_Write_Stream::write (ACE_Message_Block &message_block, + size_t bytes_to_write, + const void *act, + int priority, + int signal_number) +{ + size_t len = message_block.length(); + + if (bytes_to_write > len) + bytes_to_write = len ; + + if (bytes_to_write == 0) + ACE_ERROR_RETURN + ((LM_ERROR, + ACE_TEXT ("ACE_WIN32_Asynch_Write_Stream::write:") + ACE_TEXT ("Attempt to write 0 bytes\n")), + -1); + + ACE_WIN32_Asynch_Write_Stream_Result *result = 0; + ACE_NEW_RETURN (result, + ACE_WIN32_Asynch_Write_Stream_Result (this->handler_proxy_, + this->handle_, + message_block, + bytes_to_write, + act, + this->win32_proactor_->get_handle (), + priority, + signal_number), + -1); + + // Shared write + int return_val = this->shared_write (result); + + // Upon errors + if (return_val == -1) + delete result; + + return return_val; +} + +int +ACE_WIN32_Asynch_Write_Stream::writev (ACE_Message_Block &message_block, + size_t bytes_to_write, + const void *act, + int priority, + int signal_number) +{ +#if (defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)) + iovec iov[ACE_IOV_MAX]; + int iovcnt = 0; + + // We should not write more than user requested, + // but it is allowed to write less + + for (const ACE_Message_Block* msg = &message_block; + msg != 0 && bytes_to_write > 0 && iovcnt < ACE_IOV_MAX; + msg = msg->cont ()) + { + size_t msg_len = msg->length (); + + // Skip 0-length blocks. + if (msg_len == 0) + continue; + if (msg_len > bytes_to_write) + msg_len = bytes_to_write; + bytes_to_write -= msg_len; + + // Make as many iovec as needed to fit all of msg_len. + size_t rd_ptr_offset = 0; + + while (msg_len > 0 && iovcnt < ACE_IOV_MAX) + { + u_long this_chunk_length; + if (msg_len > ULONG_MAX) + this_chunk_length = ULONG_MAX; + else + this_chunk_length = static_cast (msg_len); + // Collect the data in the iovec. + iov[iovcnt].iov_base = msg->rd_ptr () + rd_ptr_offset; + iov[iovcnt].iov_len = this_chunk_length; + msg_len -= this_chunk_length; + rd_ptr_offset += this_chunk_length; + + // Increment iovec counter if there's more to do. + if (msg_len > 0) + iovcnt++; + } + if (msg_len > 0) // Ran out of iovecs before msg_space exhausted + { + errno = ERANGE; + return -1; + } + ++iovcnt; + } + + // Re-calculate number bytes to write + bytes_to_write = 0; + + for ( int i=0; i < iovcnt ; ++i ) + bytes_to_write += iov[i].iov_len; + + if ( bytes_to_write == 0 ) + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("ACE_WIN32_Asynch_Write_Stream::writev:") + ACE_TEXT ("Attempt to write 0 bytes\n")), + -1); + + + ACE_WIN32_Asynch_Write_Stream_Result *result = 0; + ACE_NEW_RETURN (result, + ACE_WIN32_Asynch_Write_Stream_Result (this->handler_proxy_, + this->handle_, + message_block, + bytes_to_write, + act, + this->win32_proactor_->get_handle (), + priority, + signal_number, + 1), // gather write enabled + -1); + + // do the gather send + + u_long bytes_sent = 0; + + int initiate_result = ::WSASend (reinterpret_cast (result->handle ()), + reinterpret_cast (iov), + iovcnt, + &bytes_sent, + 0, // flags + result, + 0); + + if (0 == initiate_result) + // Immediate success: the OVERLAPPED will still get queued. + return 1; + + ACE_ASSERT (initiate_result == SOCKET_ERROR); + + // If initiate failed, check for a bad error. + ACE_OS::set_errno_to_last_error (); + switch (errno) + { + case ERROR_IO_PENDING: + // The IO will complete proactively: the OVERLAPPED will still + // get queued. + initiate_result = 0; + break; + + default: + // Something else went wrong: the OVERLAPPED will not get + // queued. + + if (ACE::debug ()) + { + ACE_DEBUG ((LM_ERROR, + ACE_TEXT ("%p\n"), + ACE_TEXT ("WSASend"))); + } + + delete result; + initiate_result = -1; + break; + } + + return initiate_result; +#else + ACE_UNUSED_ARG (message_block); + ACE_UNUSED_ARG (bytes_to_write); + ACE_UNUSED_ARG (act); + ACE_UNUSED_ARG (priority); + ACE_UNUSED_ARG (signal_number); + ACE_NOTSUP_RETURN (-1); +#endif /* ACE_HAS_WINSOCK2 && ACE_HAS_WINSOCK2 != 0 */ +} + +ACE_WIN32_Asynch_Write_Stream::~ACE_WIN32_Asynch_Write_Stream (void) +{ +} + +int +ACE_WIN32_Asynch_Write_Stream::shared_write (ACE_WIN32_Asynch_Write_Stream_Result *result) +{ + u_long bytes_written; + if (result->bytes_to_write () > MAXDWORD) + { + errno = ERANGE; + return -1; + } + DWORD bytes_to_write = static_cast (result->bytes_to_write ()); + + result->set_error (0); // Clear error before starting IO. + + // Initiate the write; Winsock 2 is required for the higher-performing + // WSASend() function. For Winsock 1, fall back to the slower WriteFile(). + int initiate_result = 0; +#if (defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)) + WSABUF iov; + iov.buf = result->message_block ().rd_ptr (); + iov.len = bytes_to_write; + initiate_result = ::WSASend (reinterpret_cast (result->handle ()), + &iov, + 1, + &bytes_written, + 0, // flags + result, + 0); + if (initiate_result == 0) + // Immediate success: the OVERLAPPED will still get queued. + return 0; +#else + initiate_result = ::WriteFile (result->handle (), + result->message_block ().rd_ptr (), + bytes_to_write, + &bytes_written, + result); + if (initiate_result == 1) + // Immediate success: the OVERLAPPED will still get queued. + return 0; +#endif /* ACE_HAS_WINSOCK2 */ + + // If initiate failed, check for a bad error. + ACE_OS::set_errno_to_last_error (); + switch (errno) + { + case ERROR_IO_PENDING: + // The IO will complete proactively: the OVERLAPPED will still + // get queued. + return 0; + + default: + // Something else went wrong: the OVERLAPPED will not get + // queued. + + if (ACE::debug ()) + ACE_DEBUG ((LM_ERROR, + ACE_TEXT ("%p\n"), + ACE_TEXT ("Initiating write"))); + return -1; + } +} + +// Methods belong to ACE_WIN32_Asynch_Operation base class. These +// methods are defined here to avoid VC++ warnings. They route the +// call to the ACE_WIN32_Asynch_Operation base class. + +int +ACE_WIN32_Asynch_Write_Stream::open (const ACE_Handler::Proxy_Ptr &handler_proxy, + ACE_HANDLE handle, + const void *completion_key, + ACE_Proactor *proactor) +{ + return ACE_WIN32_Asynch_Operation::open (handler_proxy, + handle, + completion_key, + proactor); +} + +int +ACE_WIN32_Asynch_Write_Stream::cancel (void) +{ + return ACE_WIN32_Asynch_Operation::cancel (); +} + +ACE_Proactor * +ACE_WIN32_Asynch_Write_Stream::proactor (void) const +{ + return ACE_WIN32_Asynch_Operation::proactor (); +} + +ACE_WIN32_Asynch_Read_File_Result::ACE_WIN32_Asynch_Read_File_Result ( + const ACE_Handler::Proxy_Ptr &handler_proxy, + ACE_HANDLE handle, + ACE_Message_Block &message_block, + size_t bytes_to_read, + const void* act, + u_long offset, + u_long offset_high, + ACE_HANDLE event, + int priority, + int signal_number, + int scatter_enabled) + : ACE_Asynch_Result_Impl (), + ACE_Asynch_Read_Stream_Result_Impl (), + ACE_Asynch_Read_File_Result_Impl (), + ACE_WIN32_Asynch_Read_Stream_Result (handler_proxy, + handle, + message_block, + bytes_to_read, + act, + event, + priority, + signal_number, + scatter_enabled) +{ + this->Offset = offset; + this->OffsetHigh = offset_high; +} + +void +ACE_WIN32_Asynch_Read_File_Result::complete (size_t bytes_transferred, + int success, + const void *completion_key, + u_long error) +{ + // Copy the data which was returned by GetQueuedCompletionStatus. + this->bytes_transferred_ = bytes_transferred; + this->success_ = success; + this->completion_key_ = completion_key; + this->error_ = error; + + // Appropriately move the pointers in the message block. + if (!this->scatter_enabled ()) + this->message_block_.wr_ptr (bytes_transferred); + else + { + static const size_t page_size = ACE_OS::getpagesize(); + + for (ACE_Message_Block* mb = &this->message_block_; + (mb != 0) && (bytes_transferred > 0); + mb = mb->cont ()) + { + // mb->space () is ought to be >= page_size. + // this is verified in the readv method + // ACE_ASSERT (mb->space () >= page_size); + + size_t len_part = page_size ; + + if ( len_part > bytes_transferred) + len_part = bytes_transferred; + + mb->wr_ptr (len_part); + + bytes_transferred -= len_part; + } + } + + // Create the interface result class. + ACE_Asynch_Read_File::Result result (this); + + // Call the application handler. + ACE_Handler *handler = this->handler_proxy_.get ()->handler (); + if (handler != 0) + handler->handle_read_file (result); +} + +ACE_WIN32_Asynch_Read_File_Result::~ACE_WIN32_Asynch_Read_File_Result (void) +{ +} + +// Base class operations. These operations are here to kill dominance +// warnings. These methods call the base class methods. + +size_t +ACE_WIN32_Asynch_Read_File_Result::bytes_transferred (void) const +{ + return ACE_WIN32_Asynch_Result::bytes_transferred (); +} + +const void * +ACE_WIN32_Asynch_Read_File_Result::act (void) const +{ + return ACE_WIN32_Asynch_Result::act (); +} + +int +ACE_WIN32_Asynch_Read_File_Result::success (void) const +{ + return ACE_WIN32_Asynch_Result::success (); +} + +const void * +ACE_WIN32_Asynch_Read_File_Result::completion_key (void) const +{ + return ACE_WIN32_Asynch_Result::completion_key (); +} + +u_long +ACE_WIN32_Asynch_Read_File_Result::error (void) const +{ + return ACE_WIN32_Asynch_Result::error (); +} + +ACE_HANDLE +ACE_WIN32_Asynch_Read_File_Result::event (void) const +{ + return ACE_WIN32_Asynch_Result::event (); +} + +u_long +ACE_WIN32_Asynch_Read_File_Result::offset (void) const +{ + return ACE_WIN32_Asynch_Result::offset (); +} + +u_long +ACE_WIN32_Asynch_Read_File_Result::offset_high (void) const +{ + return ACE_WIN32_Asynch_Result::offset_high (); +} + +int +ACE_WIN32_Asynch_Read_File_Result::priority (void) const +{ + return ACE_WIN32_Asynch_Result::priority (); +} + +int +ACE_WIN32_Asynch_Read_File_Result::signal_number (void) const +{ + return ACE_WIN32_Asynch_Result::signal_number (); +} + +// The following methods belong to +// ACE_WIN32_Asynch_Read_Stream_Result. They are here to avoid VC++ +// warnings. These methods route their call to the +// ACE_WIN32_Asynch_Read_Stream_Result base class. + +size_t +ACE_WIN32_Asynch_Read_File_Result::bytes_to_read (void) const +{ + return ACE_WIN32_Asynch_Read_Stream_Result::bytes_to_read (); +} + +ACE_Message_Block & +ACE_WIN32_Asynch_Read_File_Result::message_block (void) const +{ + return ACE_WIN32_Asynch_Read_Stream_Result::message_block (); +} + +ACE_HANDLE +ACE_WIN32_Asynch_Read_File_Result::handle (void) const +{ + return ACE_WIN32_Asynch_Read_Stream_Result::handle (); +} + +int +ACE_WIN32_Asynch_Read_File_Result::post_completion (ACE_Proactor_Impl *proactor) +{ + return ACE_WIN32_Asynch_Result::post_completion (proactor); +} + +// ************************************************************ + +ACE_WIN32_Asynch_Read_File::ACE_WIN32_Asynch_Read_File (ACE_WIN32_Proactor *win32_proactor) + : ACE_Asynch_Operation_Impl (), + ACE_Asynch_Read_Stream_Impl (), + ACE_Asynch_Read_File_Impl (), + ACE_WIN32_Asynch_Read_Stream (win32_proactor) +{ +} + +int +ACE_WIN32_Asynch_Read_File::read (ACE_Message_Block &message_block, + size_t bytes_to_read, + u_long offset, + u_long offset_high, + const void *act, + int priority, + int signal_number) +{ + size_t space = message_block.space (); + if ( bytes_to_read > space ) + bytes_to_read = space; + + if ( bytes_to_read == 0 ) + ACE_ERROR_RETURN + ((LM_ERROR, + ACE_TEXT ("ACE_WIN32_Asynch_Read_File::read:") + ACE_TEXT ("Attempt to read 0 bytes or no space in the message block\n")), + -1); + + + ACE_WIN32_Asynch_Read_File_Result *result = 0; + ACE_NEW_RETURN (result, + ACE_WIN32_Asynch_Read_File_Result (this->handler_proxy_, + this->handle_, + message_block, + bytes_to_read, + act, + offset, + offset_high, + this->win32_proactor_->get_handle (), + priority, + signal_number), + -1); + + // Shared read + int return_val = this->shared_read (result); + + // Upon errors + if (return_val == -1) + delete result; + + return return_val; +} + +int +ACE_WIN32_Asynch_Read_File::readv (ACE_Message_Block &message_block, + size_t bytes_to_read, + u_long offset, + u_long offset_high, + const void *act, + int priority, + int signal_number) +{ +#if defined (ACE_HAS_WIN32_OVERLAPPED_IO) + static const size_t page_size = ACE_OS::getpagesize(); + + FILE_SEGMENT_ELEMENT buffer_pointers[ACE_IOV_MAX + 1]; + int buffer_pointers_count = 0; + + // Each buffer must be at least the size of a system memory page + // and must be aligned on a system memory page size boundary + + // We should not read more than user requested, + // but it is allowed to read less + + size_t total_space = 0; + + for (const ACE_Message_Block* msg = &message_block; + msg != 0 && buffer_pointers_count < ACE_IOV_MAX && total_space < bytes_to_read; + msg = msg->cont(), ++buffer_pointers_count ) + { + size_t msg_space = msg->space (); + + if (msg_space < page_size) + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("ACE_WIN32_Asynch_Read_File::readv:") + ACE_TEXT ("Invalid message block size\n")), + -1); + + buffer_pointers[buffer_pointers_count].Buffer = msg->wr_ptr (); + total_space += page_size; + } + + // not read more than buffers space + if (bytes_to_read > total_space) + bytes_to_read = total_space; + + // ReadFileScatter API limits us to DWORD range. + if (bytes_to_read > MAXDWORD) + { + errno = ERANGE; + return -1; + } + DWORD dword_bytes_to_read = static_cast (bytes_to_read); + + // last one should be completely 0 + buffer_pointers[buffer_pointers_count].Buffer = 0; + + ACE_WIN32_Asynch_Read_File_Result *result = 0; + ACE_NEW_RETURN (result, + ACE_WIN32_Asynch_Read_File_Result (this->handler_proxy_, + this->handle_, + message_block, + bytes_to_read, + act, + offset, + offset_high, + this->win32_proactor_->get_handle (), + priority, + signal_number, + 1), // scatter read enabled + -1); + + // do the scatter read + result->set_error (0); // Clear error before starting IO. + + int initiate_result = ::ReadFileScatter (result->handle (), + buffer_pointers, + dword_bytes_to_read, + 0, // reserved, must be NULL + result); + + if (0 != initiate_result) + // Immediate success: the OVERLAPPED will still get queued. + return 1; + + // If initiate failed, check for a bad error. + ACE_OS::set_errno_to_last_error (); + switch (errno) + { + case ERROR_IO_PENDING: + // The IO will complete proactively: the OVERLAPPED will still + // get queued. + initiate_result = 0; + break; + + default: + // Something else went wrong: the OVERLAPPED will not get + // queued. + + if (ACE::debug ()) + { + ACE_DEBUG ((LM_ERROR, + ACE_TEXT ("%p\n"), + ACE_TEXT ("ReadFileScatter"))); + } + + delete result; + initiate_result = -1; + break; + } + + return initiate_result; +#else + ACE_NOTSUP_RETURN (-1); +#endif /* ACE_WIN32_OVERLAPPED_IO */ +} + + +ACE_WIN32_Asynch_Read_File::~ACE_WIN32_Asynch_Read_File (void) +{ +} + +int +ACE_WIN32_Asynch_Read_File::read (ACE_Message_Block &message_block, + size_t bytes_to_read, + const void *act, + int priority, + int signal_number) +{ + return ACE_WIN32_Asynch_Read_Stream::read (message_block, + bytes_to_read, + act, + priority, + signal_number); +} + +int +ACE_WIN32_Asynch_Read_File::readv (ACE_Message_Block &message_block, + size_t bytes_to_read, + const void *act, + int priority, + int signal_number) +{ + return ACE_WIN32_Asynch_Read_Stream::readv (message_block, + bytes_to_read, + act, + priority, + signal_number); +} + +// Methods belong to ACE_WIN32_Asynch_Operation base class. These +// methods are defined here to avoid VC++ warnings. They route the +// call to the ACE_WIN32_Asynch_Operation base class. + +int +ACE_WIN32_Asynch_Read_File::open (const ACE_Handler::Proxy_Ptr &handler_proxy, + ACE_HANDLE handle, + const void *completion_key, + ACE_Proactor *proactor) +{ + return ACE_WIN32_Asynch_Operation::open (handler_proxy, + handle, + completion_key, + proactor); +} + +int +ACE_WIN32_Asynch_Read_File::cancel (void) +{ + return ACE_WIN32_Asynch_Operation::cancel (); +} + +ACE_Proactor * +ACE_WIN32_Asynch_Read_File::proactor (void) const +{ + return ACE_WIN32_Asynch_Operation::proactor (); +} + +ACE_WIN32_Asynch_Write_File_Result::ACE_WIN32_Asynch_Write_File_Result ( + const ACE_Handler::Proxy_Ptr &handler_proxy, + ACE_HANDLE handle, + ACE_Message_Block &message_block, + size_t bytes_to_write, + const void* act, + u_long offset, + u_long offset_high, + ACE_HANDLE event, + int priority, + int signal_number, + int gather_enabled) + : ACE_Asynch_Result_Impl (), + ACE_Asynch_Write_Stream_Result_Impl (), + ACE_Asynch_Write_File_Result_Impl (), + ACE_WIN32_Asynch_Write_Stream_Result (handler_proxy, + handle, + message_block, + bytes_to_write, + act, + event, + priority, + signal_number, + gather_enabled) +{ + this->Offset = offset; + this->OffsetHigh = offset_high; +} + +void +ACE_WIN32_Asynch_Write_File_Result::complete (size_t bytes_transferred, + int success, + const void *completion_key, + u_long error) +{ + // Copy the data which was returned by GetQueuedCompletionStatus + this->bytes_transferred_ = bytes_transferred; + this->success_ = success; + this->completion_key_ = completion_key; + this->error_ = error; + + // Appropriately move the pointers in the message block. + if (!this->gather_enabled ()) + this->message_block_.rd_ptr (bytes_transferred); + else + { + static const size_t page_size = ACE_OS::getpagesize(); + + for (ACE_Message_Block* mb = &this->message_block_; + (mb != 0) && (bytes_transferred > 0); + mb = mb->cont ()) + { + // mb->length () is ought to be >= page_size. + // this is verified in the writev method + // ACE_ASSERT (mb->length () >= page_size); + + size_t len_part = page_size; + + if ( len_part > bytes_transferred) + len_part = bytes_transferred; + + mb->rd_ptr (len_part); + + bytes_transferred -= len_part; + } + + } + + // Create the interface result class. + ACE_Asynch_Write_File::Result result (this); + + // Call the application handler. + ACE_Handler *handler = this->handler_proxy_.get ()->handler (); + if (handler != 0) + handler->handle_write_file (result); +} + +ACE_WIN32_Asynch_Write_File_Result::~ACE_WIN32_Asynch_Write_File_Result (void) +{ +} + +// Base class operations. These operations are here to kill dominance +// warnings. These methods call the base class methods. + +size_t +ACE_WIN32_Asynch_Write_File_Result::bytes_transferred (void) const +{ + return ACE_WIN32_Asynch_Result::bytes_transferred (); +} + +const void * +ACE_WIN32_Asynch_Write_File_Result::act (void) const +{ + return ACE_WIN32_Asynch_Result::act (); +} + +int +ACE_WIN32_Asynch_Write_File_Result::success (void) const +{ + return ACE_WIN32_Asynch_Result::success (); +} + +const void * +ACE_WIN32_Asynch_Write_File_Result::completion_key (void) const +{ + return ACE_WIN32_Asynch_Result::completion_key (); +} + +u_long +ACE_WIN32_Asynch_Write_File_Result::error (void) const +{ + return ACE_WIN32_Asynch_Result::error (); +} + +ACE_HANDLE +ACE_WIN32_Asynch_Write_File_Result::event (void) const +{ + return ACE_WIN32_Asynch_Result::event (); +} + +u_long +ACE_WIN32_Asynch_Write_File_Result::offset (void) const +{ + return ACE_WIN32_Asynch_Result::offset (); +} + +u_long +ACE_WIN32_Asynch_Write_File_Result::offset_high (void) const +{ + return ACE_WIN32_Asynch_Result::offset_high (); +} + +int +ACE_WIN32_Asynch_Write_File_Result::priority (void) const +{ + return ACE_WIN32_Asynch_Result::priority (); +} + +int +ACE_WIN32_Asynch_Write_File_Result::signal_number (void) const +{ + return ACE_WIN32_Asynch_Result::signal_number (); +} + +// The following methods belong to +// ACE_WIN32_Asynch_Write_Stream_Result. They are here to avoid VC++ +// warnings. These methods route their call to the +// ACE_WIN32_Asynch_Write_Stream_Result base class. + +size_t +ACE_WIN32_Asynch_Write_File_Result::bytes_to_write (void) const +{ + return ACE_WIN32_Asynch_Write_Stream_Result::bytes_to_write (); +} + +ACE_Message_Block & +ACE_WIN32_Asynch_Write_File_Result::message_block (void) const +{ + return ACE_WIN32_Asynch_Write_Stream_Result::message_block (); +} + +ACE_HANDLE +ACE_WIN32_Asynch_Write_File_Result::handle (void) const +{ + return ACE_WIN32_Asynch_Write_Stream_Result::handle (); +} + +int +ACE_WIN32_Asynch_Write_File_Result::post_completion (ACE_Proactor_Impl *proactor) +{ + return ACE_WIN32_Asynch_Result::post_completion (proactor); +} + +ACE_WIN32_Asynch_Write_File::ACE_WIN32_Asynch_Write_File (ACE_WIN32_Proactor *win32_proactor) + : ACE_Asynch_Operation_Impl (), + ACE_Asynch_Write_Stream_Impl (), + ACE_Asynch_Write_File_Impl (), + ACE_WIN32_Asynch_Write_Stream (win32_proactor) +{ +} + +int +ACE_WIN32_Asynch_Write_File::write (ACE_Message_Block &message_block, + size_t bytes_to_write, + u_long offset, + u_long offset_high, + const void *act, + int priority, + int signal_number) +{ + size_t len = message_block.length (); + if ( bytes_to_write > len ) + bytes_to_write = len; + + if ( bytes_to_write == 0 ) + ACE_ERROR_RETURN + ((LM_ERROR, + ACE_TEXT ("ACE_WIN32_Asynch_Write_File::write:") + ACE_TEXT ("Attempt to read 0 bytes\n")), + -1); + + ACE_WIN32_Asynch_Write_File_Result *result = 0; + ACE_NEW_RETURN (result, + ACE_WIN32_Asynch_Write_File_Result (this->handler_proxy_, + this->handle_, + message_block, + bytes_to_write, + act, + offset, + offset_high, + this->win32_proactor_->get_handle (), + priority, + signal_number), + -1); + + // Shared write + int return_val = this->shared_write (result); + + // Upon errors + if (return_val == -1) + delete result; + + return return_val; +} + +int +ACE_WIN32_Asynch_Write_File::writev (ACE_Message_Block &message_block, + size_t bytes_to_write, + u_long offset, + u_long offset_high, + const void *act, + int priority, + int signal_number) +{ +#if defined (ACE_HAS_WIN32_OVERLAPPED_IO) + static const size_t page_size = ACE_OS::getpagesize(); + + FILE_SEGMENT_ELEMENT buffer_pointers[ACE_IOV_MAX + 1]; + int buffer_pointers_count = 0; + + // Each buffer must be at least the size of a system memory page + // and must be aligned on a system memory page size boundary + + // We should not read more than user requested, + // but it is allowed to read less + + size_t total_len = 0; + + for (const ACE_Message_Block* msg = &message_block; + msg != 0 && buffer_pointers_count < ACE_IOV_MAX && total_len < bytes_to_write; + msg = msg->cont (), ++buffer_pointers_count ) + { + size_t msg_len = msg->length (); + + // Don't allow writing less than page_size, unless + // the size of the message block is big enough (so we don't write from + // memory which does not belong to the message block), and the message + // block is the last in the chain. + if (msg_len < page_size && + (msg->size () - (msg->rd_ptr () - msg->base ()) < page_size || // message block too small + bytes_to_write - total_len > page_size ))// NOT last chunk + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("ACE_WIN32_Asynch_Write_File::writev:") + ACE_TEXT ("Invalid message block length\n")), + -1); + + buffer_pointers[buffer_pointers_count].Buffer = msg->rd_ptr (); + total_len += page_size; + } + + // not write more than we have in buffers + if (bytes_to_write > total_len) + bytes_to_write = total_len; + // WriteFileGather API limits us to DWORD range. + if (bytes_to_write > MAXDWORD) + { + errno = ERANGE; + return -1; + } + DWORD dword_bytes_to_write = static_cast (bytes_to_write); + + // last one should be completely 0 + buffer_pointers[buffer_pointers_count].Buffer = 0; + + ACE_WIN32_Asynch_Write_File_Result *result = 0; + ACE_NEW_RETURN (result, + ACE_WIN32_Asynch_Write_File_Result (this->handler_proxy_, + this->handle_, + message_block, + bytes_to_write, + act, + offset, + offset_high, + this->win32_proactor_->get_handle (), + priority, + signal_number, + 1), // gather write enabled + -1); + + result->set_error(0); + + // do the gather write + int initiate_result = ::WriteFileGather (result->handle (), + buffer_pointers, + dword_bytes_to_write, + 0, // reserved, must be NULL + result); + + if (0 != initiate_result) + // Immediate success: the OVERLAPPED will still get queued. + return 1; + + // If initiate failed, check for a bad error. + ACE_OS::set_errno_to_last_error (); + switch (errno) + { + case ERROR_IO_PENDING: + // The IO will complete proactively: the OVERLAPPED will still + // get queued. + initiate_result = 0; + break; + + default: + // Something else went wrong: the OVERLAPPED will not get + // queued. + + if (ACE::debug ()) + { + ACE_DEBUG ((LM_ERROR, + ACE_TEXT ("%p\n"), + ACE_TEXT ("WriteFileGather"))); + } + + delete result; + initiate_result = -1; + break; + } + + return initiate_result; +#else + + ACE_NOTSUP_RETURN (-1); + +#endif /* ACE_HAS_WIN32_OVERLAPPED_IO */ +} + + +ACE_WIN32_Asynch_Write_File::~ACE_WIN32_Asynch_Write_File (void) +{ +} + +int +ACE_WIN32_Asynch_Write_File::write (ACE_Message_Block &message_block, + size_t bytes_to_write, + const void *act, + int priority, + int signal_number) +{ + return ACE_WIN32_Asynch_Write_Stream::write (message_block, + bytes_to_write, + act, + priority, + signal_number); +} + +int +ACE_WIN32_Asynch_Write_File::writev (ACE_Message_Block &message_block, + size_t bytes_to_write, + const void *act, + int priority, + int signal_number) +{ + return ACE_WIN32_Asynch_Write_Stream::writev (message_block, + bytes_to_write, + act, + priority, + signal_number); +} + +// Methods belong to ACE_WIN32_Asynch_Operation base class. These +// methods are defined here to avoid VC++ warnings. They route the +// call to the ACE_WIN32_Asynch_Operation base class. + +int +ACE_WIN32_Asynch_Write_File::open (const ACE_Handler::Proxy_Ptr &handler_proxy, + ACE_HANDLE handle, + const void *completion_key, + ACE_Proactor *proactor) +{ + return ACE_WIN32_Asynch_Operation::open (handler_proxy, + handle, + completion_key, + proactor); +} + +int +ACE_WIN32_Asynch_Write_File::cancel (void) +{ + return ACE_WIN32_Asynch_Operation::cancel (); +} + +ACE_Proactor * +ACE_WIN32_Asynch_Write_File::proactor (void) const +{ + return ACE_WIN32_Asynch_Operation::proactor (); +} + +size_t +ACE_WIN32_Asynch_Accept_Result::bytes_to_read (void) const +{ + return this->bytes_to_read_; +} + +ACE_Message_Block & +ACE_WIN32_Asynch_Accept_Result::message_block (void) const +{ + return this->message_block_; +} + +ACE_HANDLE +ACE_WIN32_Asynch_Accept_Result::listen_handle (void) const +{ + return this->listen_handle_; +} + +ACE_HANDLE +ACE_WIN32_Asynch_Accept_Result::accept_handle (void) const +{ + return this->accept_handle_; +} + +ACE_WIN32_Asynch_Accept_Result::ACE_WIN32_Asynch_Accept_Result ( + const ACE_Handler::Proxy_Ptr &handler_proxy, + ACE_HANDLE listen_handle, + ACE_HANDLE accept_handle, + ACE_Message_Block &message_block, + size_t bytes_to_read, + const void* act, + ACE_HANDLE event, + int priority, + int signal_number) + : ACE_Asynch_Result_Impl (), + ACE_Asynch_Accept_Result_Impl (), + ACE_WIN32_Asynch_Result (handler_proxy, + act, + event, + 0, + 0, + priority, + signal_number), + bytes_to_read_ (bytes_to_read), + message_block_ (message_block), + listen_handle_ (listen_handle), + accept_handle_ (accept_handle) +{ +} + +void +ACE_WIN32_Asynch_Accept_Result::complete (size_t bytes_transferred, + int success, + const void *completion_key, + u_long error) +{ + // Copy the data which was returned by GetQueuedCompletionStatus + this->bytes_transferred_ = bytes_transferred; + this->success_ = success; + this->completion_key_ = completion_key; + this->error_ = error; + + // Appropriately move the pointers in the message block. + this->message_block_.wr_ptr (bytes_transferred); + + if (!success && this->accept_handle_ != ACE_INVALID_HANDLE) + { + ACE_OS::closesocket (this->accept_handle_); + this->accept_handle_ = ACE_INVALID_HANDLE; + } + + // Create the interface result class. + ACE_Asynch_Accept::Result result (this); + + // Call the application handler. + ACE_Handler *handler = this->handler_proxy_.get ()->handler (); + if (handler != 0) + handler->handle_accept (result); +} + +ACE_WIN32_Asynch_Accept_Result::~ACE_WIN32_Asynch_Accept_Result (void) +{ +} + +// Base class operations. These operations are here to kill dominance +// warnings. These methods call the base class methods. + +size_t +ACE_WIN32_Asynch_Accept_Result::bytes_transferred (void) const +{ + return ACE_WIN32_Asynch_Result::bytes_transferred (); +} + +const void * +ACE_WIN32_Asynch_Accept_Result::act (void) const +{ + return ACE_WIN32_Asynch_Result::act (); +} + +int +ACE_WIN32_Asynch_Accept_Result::success (void) const +{ + return ACE_WIN32_Asynch_Result::success (); +} + +const void * +ACE_WIN32_Asynch_Accept_Result::completion_key (void) const +{ + return ACE_WIN32_Asynch_Result::completion_key (); +} + +u_long +ACE_WIN32_Asynch_Accept_Result::error (void) const +{ + return ACE_WIN32_Asynch_Result::error (); +} + +ACE_HANDLE +ACE_WIN32_Asynch_Accept_Result::event (void) const +{ + return ACE_WIN32_Asynch_Result::event (); +} + +u_long +ACE_WIN32_Asynch_Accept_Result::offset (void) const +{ + return ACE_WIN32_Asynch_Result::offset (); +} + +u_long +ACE_WIN32_Asynch_Accept_Result::offset_high (void) const +{ + return ACE_WIN32_Asynch_Result::offset_high (); +} + +int +ACE_WIN32_Asynch_Accept_Result::priority (void) const +{ + return ACE_WIN32_Asynch_Result::priority (); +} + +int +ACE_WIN32_Asynch_Accept_Result::signal_number (void) const +{ + return ACE_WIN32_Asynch_Result::signal_number (); +} + +int +ACE_WIN32_Asynch_Accept_Result::post_completion (ACE_Proactor_Impl *proactor) +{ + return ACE_WIN32_Asynch_Result::post_completion (proactor); +} + +ACE_WIN32_Asynch_Accept::ACE_WIN32_Asynch_Accept (ACE_WIN32_Proactor *win32_proactor) + : ACE_Asynch_Operation_Impl (), + ACE_Asynch_Accept_Impl (), + ACE_WIN32_Asynch_Operation (win32_proactor) +{ +} + +int +ACE_WIN32_Asynch_Accept::accept (ACE_Message_Block &message_block, + size_t bytes_to_read, + ACE_HANDLE accept_handle, + const void *act, + int priority, + int signal_number, + int addr_family) +{ +#if defined (ACE_HAS_WIN32_OVERLAPPED_IO) || (defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)) + // Sanity check: make sure that enough space has been allocated by + // the caller. + size_t address_size = +#if defined (ACE_HAS_IPV6) + addr_family == AF_INET ? sizeof (sockaddr_in) : sizeof (sockaddr_in6); +#else + sizeof (sockaddr_in); +#endif /* ACE_HAS_IPV6 */ + address_size += 16; // AcceptEx requires address size + 16 (minimum) + size_t available_space = message_block.space (); + size_t space_needed = bytes_to_read + 2 * address_size; + if (available_space < space_needed) + ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("Buffer too small\n")), -1); + + // WIN Specific. + + // AcceptEx API limits us to DWORD range. + if (bytes_to_read > MAXDWORD) + { + errno = ERANGE; + return -1; + } + DWORD dword_bytes_to_read = static_cast (bytes_to_read); + + int close_accept_handle = 0; + // If the is invalid, we will create a new socket. + if (accept_handle == ACE_INVALID_HANDLE) + { + accept_handle = ACE_OS::socket (addr_family, + SOCK_STREAM, + 0); + if (accept_handle == ACE_INVALID_HANDLE) + { + if (ACE::debug ()) + { + ACE_DEBUG ((LM_ERROR, + ACE_TEXT ("%p\n"), + ACE_TEXT ("ACE_OS::socket"))); + } + return -1; + } + else + // Remember to close the socket down if failures occur. + close_accept_handle = 1; + } + + // Common code for both WIN and POSIX. + ACE_WIN32_Asynch_Accept_Result *result = 0; + ACE_NEW_RETURN (result, + ACE_WIN32_Asynch_Accept_Result (this->handler_proxy_, + this->handle_, + accept_handle, + message_block, + bytes_to_read, + act, + this->win32_proactor_->get_handle (), + priority, + signal_number), + -1); + + u_long bytes_read; + + // Initiate the accept. + int initiate_result = ::AcceptEx ((SOCKET) result->listen_handle (), + (SOCKET) result->accept_handle (), + result->message_block ().wr_ptr (), + dword_bytes_to_read, + static_cast (address_size), + static_cast (address_size), + &bytes_read, + result); + if (initiate_result == 1) + // Immediate success: the OVERLAPPED will still get queued. + return 1; + + // If initiate failed, check for a bad error. + ACE_OS::set_errno_to_last_error (); + switch (errno) + { + case ERROR_IO_PENDING: + // The IO will complete proactively: the OVERLAPPED will still + // get queued. + return 0; + + default: + // Something else went wrong: the OVERLAPPED will not get + // queued. + + if (close_accept_handle == 1) + // Close the newly created socket + ACE_OS::closesocket (accept_handle); + + // Cleanup dynamically allocated Asynch_Result. + delete result; + + if (ACE::debug ()) + { + ACE_DEBUG ((LM_ERROR, + ACE_TEXT ("%p\n"), + ACE_TEXT ("AcceptEx"))); + } + return -1; + } +#else + ACE_UNUSED_ARG (message_block); + ACE_UNUSED_ARG (bytes_to_read); + ACE_UNUSED_ARG (accept_handle); + ACE_UNUSED_ARG (act); + ACE_UNUSED_ARG (priority); + ACE_UNUSED_ARG (signal_number); + ACE_UNUSED_ARG (addr_family); + ACE_NOTSUP_RETURN (-1); +#endif /* defined (ACE_HAS_WIN32_OVERLAPPED_IO) || (defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)) */ +} + +ACE_WIN32_Asynch_Accept::~ACE_WIN32_Asynch_Accept (void) +{ +} + +// Methods belong to ACE_WIN32_Asynch_Operation base class. These +// methods are defined here to avoid VC++ warnings. They route the +// call to the ACE_WIN32_Asynch_Operation base class. + +int +ACE_WIN32_Asynch_Accept::open (const ACE_Handler::Proxy_Ptr &handler_proxy, + ACE_HANDLE handle, + const void *completion_key, + ACE_Proactor *proactor) +{ + return ACE_WIN32_Asynch_Operation::open (handler_proxy, + handle, + completion_key, + proactor); +} + +int +ACE_WIN32_Asynch_Accept::cancel (void) +{ + return ACE_WIN32_Asynch_Operation::cancel (); +} + +ACE_Proactor * +ACE_WIN32_Asynch_Accept::proactor (void) const +{ + return ACE_WIN32_Asynch_Operation::proactor (); +} + +// ********************************************************************* + +ACE_HANDLE +ACE_WIN32_Asynch_Connect_Result::connect_handle (void) const +{ + return this->connect_handle_; +} + +void ACE_WIN32_Asynch_Connect_Result::connect_handle ( ACE_HANDLE handle ) +{ + this->connect_handle_ = handle; +} + + +ACE_WIN32_Asynch_Connect_Result::ACE_WIN32_Asynch_Connect_Result + (const ACE_Handler::Proxy_Ptr &handler_proxy, + ACE_HANDLE connect_handle, + const void* act, + ACE_HANDLE event, + int priority, + int signal_number) + : ACE_Asynch_Result_Impl (), + ACE_Asynch_Connect_Result_Impl (), + ACE_WIN32_Asynch_Result + (handler_proxy, act, event, 0, 0, priority, signal_number), + connect_handle_ (connect_handle) +{ + ; +} + +void +ACE_WIN32_Asynch_Connect_Result::complete (size_t bytes_transferred, + int success, + const void *completion_key, + u_long error) +{ + // Copy the data. + this->bytes_transferred_ = bytes_transferred; + this->success_ = success; + this->completion_key_ = completion_key; + this->error_ = error; + + // Create the interface result class. + ACE_Asynch_Connect::Result result (this); + + // Call the application handler. + ACE_Handler *handler = this->handler_proxy_.get ()->handler (); + if (handler != 0) + handler->handle_connect (result); +} + +ACE_WIN32_Asynch_Connect_Result::~ACE_WIN32_Asynch_Connect_Result (void) +{ +} + +// Base class operations. These operations are here to kill dominance +// warnings. These methods call the base class methods. + +size_t +ACE_WIN32_Asynch_Connect_Result::bytes_transferred (void) const +{ + return ACE_WIN32_Asynch_Result::bytes_transferred (); +} + +const void * +ACE_WIN32_Asynch_Connect_Result::act (void) const +{ + return ACE_WIN32_Asynch_Result::act (); +} + +int +ACE_WIN32_Asynch_Connect_Result::success (void) const +{ + return ACE_WIN32_Asynch_Result::success (); +} + +const void * +ACE_WIN32_Asynch_Connect_Result::completion_key (void) const +{ + return ACE_WIN32_Asynch_Result::completion_key (); +} + +u_long +ACE_WIN32_Asynch_Connect_Result::error (void) const +{ + return ACE_WIN32_Asynch_Result::error (); +} + +ACE_HANDLE +ACE_WIN32_Asynch_Connect_Result::event (void) const +{ + return ACE_WIN32_Asynch_Result::event (); +} + +u_long +ACE_WIN32_Asynch_Connect_Result::offset (void) const +{ + return ACE_WIN32_Asynch_Result::offset (); +} + +u_long +ACE_WIN32_Asynch_Connect_Result::offset_high (void) const +{ + return ACE_WIN32_Asynch_Result::offset_high (); +} + +int +ACE_WIN32_Asynch_Connect_Result::priority (void) const +{ + return ACE_WIN32_Asynch_Result::priority (); +} + +int +ACE_WIN32_Asynch_Connect_Result::signal_number (void) const +{ + return ACE_WIN32_Asynch_Result::signal_number (); +} + +int +ACE_WIN32_Asynch_Connect_Result::post_completion (ACE_Proactor_Impl *proactor) +{ + return ACE_WIN32_Asynch_Result::post_completion (proactor); +} + +// ********************************************************************* + +ACE_WIN32_Asynch_Connect::ACE_WIN32_Asynch_Connect (ACE_WIN32_Proactor * win32_proactor) + : ACE_Asynch_Operation_Impl (), + ACE_Asynch_Connect_Impl (), + ACE_WIN32_Asynch_Operation (win32_proactor), + flg_open_ (false) +{ +} + +ACE_WIN32_Asynch_Connect::~ACE_WIN32_Asynch_Connect (void) +{ + this->close (); + this->reactor (0); // to avoid purge_pending_notifications +} + +ACE_Proactor * +ACE_WIN32_Asynch_Connect::proactor (void) const +{ + return ACE_WIN32_Asynch_Operation::proactor (); +} + +ACE_HANDLE +ACE_WIN32_Asynch_Connect::get_handle (void) const +{ + + ACE_ASSERT (0); + return ACE_INVALID_HANDLE; +} + +void +ACE_WIN32_Asynch_Connect::set_handle (ACE_HANDLE) +{ + ACE_ASSERT (0) ; +} + +int +ACE_WIN32_Asynch_Connect::open (const ACE_Handler::Proxy_Ptr &handler_proxy, + ACE_HANDLE, + const void *completion_key, + ACE_Proactor *proactor) +{ + ACE_TRACE ("ACE_WIN32_Asynch_Connect::open"); + + // if we are already opened, + // we could not create a new handler without closing the previous + if (this->flg_open_) + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("%N:%l:ACE_WIN32_Asynch_Connect::open:") + ACE_TEXT ("connector already open \n")), + -1); + + //int result = + ACE_WIN32_Asynch_Operation::open (handler_proxy, + ACE_INVALID_HANDLE, + completion_key, + proactor); + + // Ignore result as we pass ACE_INVALID_HANDLE + //if (result == -1) + // return result; + + this->flg_open_ = true; + + return 0; +} + +int +ACE_WIN32_Asynch_Connect::connect (ACE_HANDLE connect_handle, + const ACE_Addr & remote_sap, + const ACE_Addr & local_sap, + int reuse_addr, + const void *act, + int priority, + int signal_number) +{ + ACE_TRACE ("ACE_WIN32_Asynch_Connect::connect"); + + if (!this->flg_open_) + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("%N:%l:ACE_WIN32_Asynch_Connect::connect") + ACE_TEXT ("connector was not opened before\n")), + -1); + + // Common code for both WIN and WIN32. + // Create future Asynch_Connect_Result + ACE_WIN32_Asynch_Connect_Result *result = 0; + ACE_NEW_RETURN (result, + ACE_WIN32_Asynch_Connect_Result (this->handler_proxy_, + connect_handle, + act, + this->win32_proactor_->get_handle (), + priority, + signal_number), + -1); + + int rc = connect_i (result, + remote_sap, + local_sap, + reuse_addr); + + // update handle + connect_handle = result->connect_handle (); + + if (rc != 0) + return post_result (result, true); + + // Enqueue result we will wait for completion + { + ACE_MT (ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->lock_, -1)); + + if (this->result_map_.bind (connect_handle, result) == -1) + { + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("ACE_WIN32_Asynch_Connect::connect: %p\n"), + ACE_TEXT ("bind"))); + result->set_error (EFAULT); + return post_result (result, true); + } + } + + ACE_Asynch_Pseudo_Task & task = + this->win32_proactor_->get_asynch_pseudo_task (); + + if (-1 == task.register_io_handler (connect_handle, + this, + ACE_Event_Handler::CONNECT_MASK, + 0)) // not to suspend after register + { + result = 0; + { + ACE_MT (ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->lock_, -1)); + this->result_map_.unbind (connect_handle, result); + } + if (result != 0) + { + result->set_error (EFAULT); + this->post_result (result, true); + } + } + + return 0; +} + +int ACE_WIN32_Asynch_Connect::post_result (ACE_WIN32_Asynch_Connect_Result * result, + bool post_enable) +{ + ACE_HANDLE handle = result->connect_handle (); + if (this->flg_open_ && post_enable) + { + // NOTE: result is invalid after post_completion(). It's either deleted + // or will be shortly via the proactor dispatch, regardless of success + // or fail of the call. + if (this->win32_proactor_ ->post_completion (result) == 0) + return 0; + + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("Error:(%P | %t):%p\n"), + ACE_TEXT ("ACE_WIN32_Asynch_Connect::post_result: ") + ACE_TEXT (" failed"))); + } + else + { + // There was no call to post_completion() so manually delete result. + delete result; + } + + if (handle != ACE_INVALID_HANDLE) + ACE_OS::closesocket (handle); + + return -1; +} + +// connect_i +// return code : +// -1 errors before attempt to connect +// 0 connect started +// 1 connect finished ( may be unsuccessfully) + +int +ACE_WIN32_Asynch_Connect::connect_i (ACE_WIN32_Asynch_Connect_Result *result, + const ACE_Addr & remote_sap, + const ACE_Addr & local_sap, + int reuse_addr) +{ + result->set_bytes_transferred (0); + + ACE_HANDLE handle = result->connect_handle (); + if (handle == ACE_INVALID_HANDLE) + { + int protocol_family = remote_sap.get_type (); + handle = ACE_OS::socket (protocol_family, + SOCK_STREAM, + 0); + + // save it + result->connect_handle (handle); + if (handle == ACE_INVALID_HANDLE) + { + result->set_error (errno); + ACE_ERROR_RETURN + ((LM_ERROR, + ACE_TEXT ("ACE_WIN32_Asynch_Connect::connect_i: %p\n"), + ACE_TEXT ("socket")), + -1); + } + + // Reuse the address + int one = 1; + if (protocol_family != PF_UNIX && + reuse_addr != 0 && + ACE_OS::setsockopt (handle, + SOL_SOCKET, + SO_REUSEADDR, + (const char*) &one, + sizeof one) == -1) + { + result->set_error (errno); + ACE_ERROR_RETURN + ((LM_ERROR, + ACE_TEXT ("ACE_WIN32_Asynch_Connect::connect_i: %p\n"), + ACE_TEXT ("setsockopt")), + -1); + } + } + + if (local_sap != ACE_Addr::sap_any) + { + sockaddr * laddr = reinterpret_cast (local_sap.get_addr ()); + int size = local_sap.get_size (); + if (ACE_OS::bind (handle, laddr, size) == -1) + { + result->set_error (errno); + ACE_ERROR_RETURN + ((LM_ERROR, + ACE_TEXT ("ACE_WIN32_Asynch_Connect::connect_i: %p\n"), + ACE_TEXT ("bind")), + -1); + } + } + + // set non blocking mode + if (ACE::set_flags (handle, ACE_NONBLOCK) != 0) + { + result->set_error (errno); + ACE_ERROR_RETURN + ((LM_ERROR, + ACE_TEXT ("ACE_WIN32_Asynch_Connect::connect_i: %p\n"), + ACE_TEXT ("set_flags")), + -1); + } + + for (;;) + { + int rc = ACE_OS::connect + (handle, + reinterpret_cast (remote_sap.get_addr ()), + remote_sap.get_size ()); + + if (rc < 0) // failure + { + if (errno == EWOULDBLOCK || errno == EINPROGRESS) + return 0; // connect started + + if (errno == EINTR) + continue; + + result->set_error (errno); + } + return 1 ; // connect finished + } +} + + +// cancel_uncompleted +// It performs cancellation of all pending requests +// +// Parameter flg_notify can be +// 0 - don't send notifications about canceled accepts +// !0 - notify user about canceled accepts +// according WIN32 standards we should receive notifications +// on canceled AIO requests +// +// Return value : number of cancelled requests +// + +int +ACE_WIN32_Asynch_Connect::cancel_uncompleted (bool flg_notify, + ACE_Handle_Set &set) +{ + ACE_TRACE ("ACE_WIN32_Asynch_Connect::cancel_uncompleted"); + + int retval = 0; + + MAP_MANAGER::ITERATOR iter (result_map_); + MAP_MANAGER::ENTRY * me = 0; + + set.reset (); + + for (; iter.next (me) != 0; retval++, iter.advance ()) + { + ACE_HANDLE handle = me->ext_id_; + ACE_WIN32_Asynch_Connect_Result* result = me->int_id_ ; + + set.set_bit (handle); + + result->set_bytes_transferred (0); + result->set_error (ERROR_OPERATION_ABORTED); + this->post_result (result, flg_notify); + } + + result_map_.unbind_all (); + + return retval; +} + +int +ACE_WIN32_Asynch_Connect::cancel (void) +{ + ACE_TRACE ("ACE_WIN32_Asynch_Connect::cancel"); + + int rc = -1 ; // ERRORS + + ACE_Handle_Set set; + int num_cancelled = 0; + { + ACE_MT (ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->lock_, -1)); + + num_cancelled = cancel_uncompleted (flg_open_, set); + } + if (num_cancelled == 0) + rc = 1; // AIO_ALLDONE + else if (num_cancelled > 0) + rc = 0; // AIO_CANCELED + + if (!this->flg_open_) + return rc; + + ACE_Asynch_Pseudo_Task & task = + this->win32_proactor_->get_asynch_pseudo_task (); + + task.remove_io_handler (set); + return rc; +} + +int +ACE_WIN32_Asynch_Connect::close (void) +{ + ACE_TRACE ("ACE_WIN32_Asynch_Connect::close"); + + ACE_Handle_Set set; + int num_cancelled = 0; + { + ACE_MT (ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->lock_, -1)); + + num_cancelled = cancel_uncompleted (flg_open_, set); + } + if (num_cancelled == 0 || this->flg_open_ == 0) + { + this->flg_open_ = false; + return 0; + } + + ACE_Asynch_Pseudo_Task & task = + this->win32_proactor_->get_asynch_pseudo_task (); + + task.remove_io_handler (set); + return 0; +} + +int +ACE_WIN32_Asynch_Connect::handle_exception (ACE_HANDLE fd) +{ + ACE_TRACE ("ACE_WIN32_Asynch_Connect::handle_exception"); + return handle_output (fd); +} + +int +ACE_WIN32_Asynch_Connect::handle_input (ACE_HANDLE fd) +{ + ACE_TRACE ("ACE_WIN32_Asynch_Connect::handle_input"); + return handle_output (fd); +} + +int +ACE_WIN32_Asynch_Connect::handle_output (ACE_HANDLE fd) +{ + ACE_TRACE ("ACE_WIN32_Asynch_Connect::handle_output"); + + ACE_WIN32_Asynch_Connect_Result* result = 0; + + { + ACE_MT (ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->lock_, 0)); + if (this->result_map_.unbind (fd, result) != 0) // not found + return -1; + } + + int sockerror = 0 ; + int lsockerror = sizeof sockerror; + + ACE_OS::getsockopt (fd, + SOL_SOCKET, + SO_ERROR, + (char*) & sockerror, + & lsockerror); + + // This previously just did a "return -1" and let handle_close() clean + // things up. However, this entire object may be gone as a result of + // the application's completion handler, so don't count on 'this' being + // legitimate on return from post_result(). + // remove_io_handler() contains flag DONT_CALL + this->win32_proactor_->get_asynch_pseudo_task().remove_io_handler (fd); + + result->set_bytes_transferred (0); + result->set_error (sockerror); + this->post_result (result, this->flg_open_); + return 0; +} + + +int +ACE_WIN32_Asynch_Connect::handle_close (ACE_HANDLE fd, ACE_Reactor_Mask) +{ + ACE_TRACE ("ACE_WIN32_Asynch_Connect::handle_close"); + + ACE_Asynch_Pseudo_Task & task = + this->win32_proactor_->get_asynch_pseudo_task (); + task.remove_io_handler (fd); + + ACE_WIN32_Asynch_Connect_Result* result = 0; + + { + ACE_MT (ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->lock_, 0)); + if (this->result_map_.unbind (fd, result) != 0) // not found + return -1; + } + + result->set_bytes_transferred (0); + result->set_error (ERROR_OPERATION_ABORTED); + this->post_result (result, this->flg_open_); + + return 0; +} + +// ********************************************************************* + +ACE_HANDLE +ACE_WIN32_Asynch_Transmit_File_Result::socket (void) const +{ + return this->socket_; +} + +ACE_HANDLE +ACE_WIN32_Asynch_Transmit_File_Result::file (void) const +{ + return this->file_; +} + +ACE_Asynch_Transmit_File::Header_And_Trailer * +ACE_WIN32_Asynch_Transmit_File_Result::header_and_trailer (void) const +{ + return this->header_and_trailer_; +} + +size_t +ACE_WIN32_Asynch_Transmit_File_Result::bytes_to_write (void) const +{ + return this->bytes_to_write_; +} + +size_t +ACE_WIN32_Asynch_Transmit_File_Result::bytes_per_send (void) const +{ + return this->bytes_per_send_; +} + +u_long +ACE_WIN32_Asynch_Transmit_File_Result::flags (void) const +{ + return this->flags_; +} + +ACE_WIN32_Asynch_Transmit_File_Result::ACE_WIN32_Asynch_Transmit_File_Result ( + const ACE_Handler::Proxy_Ptr &handler_proxy, + ACE_HANDLE socket, + ACE_HANDLE file, + ACE_Asynch_Transmit_File::Header_And_Trailer *header_and_trailer, + size_t bytes_to_write, + u_long offset, + u_long offset_high, + size_t bytes_per_send, + u_long flags, + const void *act, + ACE_HANDLE event, + int priority, + int signal_number) + : ACE_Asynch_Result_Impl (), + ACE_Asynch_Transmit_File_Result_Impl (), + ACE_WIN32_Asynch_Result (handler_proxy, + act, + event, + offset, + offset_high, + priority, + signal_number), + socket_ (socket), + file_ (file), + header_and_trailer_ (header_and_trailer), + bytes_to_write_ (bytes_to_write), + bytes_per_send_ (bytes_per_send), + flags_ (flags) +{ +} + +void +ACE_WIN32_Asynch_Transmit_File_Result::complete (size_t bytes_transferred, + int success, + const void *completion_key, + u_long error) +{ + // Copy the data which was returned by GetQueuedCompletionStatus + this->bytes_transferred_ = bytes_transferred; + this->success_ = success; + this->completion_key_ = completion_key; + this->error_ = error; + + // We will not do this because (a) the header and trailer blocks may + // be the same message_blocks and (b) in cases of failures we have + // no idea how much of what (header, data, trailer) was sent. + /* + if (this->success_ && this->header_and_trailer_ != 0) + { + ACE_Message_Block *header = this->header_and_trailer_->header (); + if (header != 0) + header->rd_ptr (this->header_and_trailer_->header_bytes ()); + + ACE_Message_Block *trailer = this->header_and_trailer_->trailer (); + if (trailer != 0) + trailer->rd_ptr (this->header_and_trailer_->trailer_bytes ()); + } + */ + + // Create the interface result class. + ACE_Asynch_Transmit_File::Result result (this); + + // Call the application handler. + ACE_Handler *handler = this->handler_proxy_.get ()->handler (); + if (handler != 0) + handler->handle_transmit_file (result); +} + +ACE_WIN32_Asynch_Transmit_File_Result::~ACE_WIN32_Asynch_Transmit_File_Result (void) +{ +} + +// Base class operations. These operations are here to kill dominance +// warnings. These methods call the base class methods. + +size_t +ACE_WIN32_Asynch_Transmit_File_Result::bytes_transferred (void) const +{ + return ACE_WIN32_Asynch_Result::bytes_transferred (); +} + +const void * +ACE_WIN32_Asynch_Transmit_File_Result::act (void) const +{ + return ACE_WIN32_Asynch_Result::act (); +} + +int +ACE_WIN32_Asynch_Transmit_File_Result::success (void) const +{ + return ACE_WIN32_Asynch_Result::success (); +} + +const void * +ACE_WIN32_Asynch_Transmit_File_Result::completion_key (void) const +{ + return ACE_WIN32_Asynch_Result::completion_key (); +} + +u_long +ACE_WIN32_Asynch_Transmit_File_Result::error (void) const +{ + return ACE_WIN32_Asynch_Result::error (); +} + +ACE_HANDLE +ACE_WIN32_Asynch_Transmit_File_Result::event (void) const +{ + return ACE_WIN32_Asynch_Result::event (); +} + +u_long +ACE_WIN32_Asynch_Transmit_File_Result::offset (void) const +{ + return ACE_WIN32_Asynch_Result::offset (); +} + +u_long +ACE_WIN32_Asynch_Transmit_File_Result::offset_high (void) const +{ + return ACE_WIN32_Asynch_Result::offset_high (); +} + +int +ACE_WIN32_Asynch_Transmit_File_Result::priority (void) const +{ + return ACE_WIN32_Asynch_Result::priority (); +} + +int +ACE_WIN32_Asynch_Transmit_File_Result::signal_number (void) const +{ + return ACE_WIN32_Asynch_Result::signal_number (); +} + +int +ACE_WIN32_Asynch_Transmit_File_Result::post_completion (ACE_Proactor_Impl *proactor) +{ + return ACE_WIN32_Asynch_Result::post_completion (proactor); +} + +ACE_WIN32_Asynch_Transmit_File::ACE_WIN32_Asynch_Transmit_File (ACE_WIN32_Proactor *win32_proactor) + : ACE_Asynch_Operation_Impl (), + ACE_Asynch_Transmit_File_Impl (), + ACE_WIN32_Asynch_Operation (win32_proactor) +{ +} + +int +ACE_WIN32_Asynch_Transmit_File::transmit_file (ACE_HANDLE file, + ACE_Asynch_Transmit_File::Header_And_Trailer *header_and_trailer, + size_t bytes_to_write, + u_long offset, + u_long offset_high, + size_t bytes_per_send, + u_long flags, + const void *act, + int priority, + int signal_number) +{ +#if defined (ACE_HAS_WIN32_OVERLAPPED_IO) || (defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)) + + // TransmitFile API limits us to DWORD range. + if (bytes_to_write > MAXDWORD || bytes_per_send > MAXDWORD) + { + errno = ERANGE; + return -1; + } + DWORD dword_bytes_to_write = static_cast (bytes_to_write); + DWORD dword_bytes_per_send = static_cast (bytes_per_send); + + ACE_WIN32_Asynch_Transmit_File_Result *result = 0; + ACE_NEW_RETURN (result, + ACE_WIN32_Asynch_Transmit_File_Result (this->handler_proxy_, + this->handle_, + file, + header_and_trailer, + bytes_to_write, + offset, + offset_high, + bytes_per_send, + flags, + act, + this->win32_proactor_->get_handle (), + priority, + signal_number), + -1); + + ACE_LPTRANSMIT_FILE_BUFFERS transmit_buffers = 0; + if (result->header_and_trailer () != 0) + transmit_buffers = result->header_and_trailer ()->transmit_buffers (); + + // Initiate the transmit file + int initiate_result = ::TransmitFile ((SOCKET) result->socket (), + result->file (), + dword_bytes_to_write, + dword_bytes_per_send, + result, + transmit_buffers, + result->flags ()); + if (initiate_result == 1) + // Immediate success: the OVERLAPPED will still get queued. + return 1; + + // If initiate failed, check for a bad error. + ACE_OS::set_errno_to_last_error (); + switch (errno) + { + case ERROR_IO_PENDING: + // The IO will complete proactively: the OVERLAPPED will still + // get queued. + return 0; + + default: + // Something else went wrong: the OVERLAPPED will not get + // queued. + + // Cleanup dynamically allocated Asynch_Result + delete result; + + if (ACE::debug ()) + { + ACE_DEBUG ((LM_ERROR, + ACE_TEXT ("%p\n"), + ACE_TEXT ("TransmitFile"))); + } + return -1; + } +#else + ACE_UNUSED_ARG (file); + ACE_UNUSED_ARG (header_and_trailer); + ACE_UNUSED_ARG (bytes_to_write); + ACE_UNUSED_ARG (offset); + ACE_UNUSED_ARG (offset_high); + ACE_UNUSED_ARG (bytes_per_send); + ACE_UNUSED_ARG (flags); + ACE_UNUSED_ARG (act); + ACE_UNUSED_ARG (priority); + ACE_UNUSED_ARG (signal_number); + ACE_NOTSUP_RETURN (-1); +#endif /* ACE_HAS_WIN32_OVERLAPPED_IO || ACE_HAS_WINSOCK2 */ +} + +ACE_WIN32_Asynch_Transmit_File::~ACE_WIN32_Asynch_Transmit_File (void) +{ +} + +// Methods belong to ACE_WIN32_Asynch_Operation base class. These +// methods are defined here to avoid VC++ warnings. They route the +// call to the ACE_WIN32_Asynch_Operation base class. + +int +ACE_WIN32_Asynch_Transmit_File::open (const ACE_Handler::Proxy_Ptr &handler_proxy, + ACE_HANDLE handle, + const void *completion_key, + ACE_Proactor *proactor) +{ + return ACE_WIN32_Asynch_Operation::open (handler_proxy, + handle, + completion_key, + proactor); +} + +int +ACE_WIN32_Asynch_Transmit_File::cancel (void) +{ + return ACE_WIN32_Asynch_Operation::cancel (); +} + +ACE_Proactor * +ACE_WIN32_Asynch_Transmit_File::proactor (void) const +{ + return ACE_WIN32_Asynch_Operation::proactor (); +} + +size_t +ACE_WIN32_Asynch_Read_Dgram_Result::bytes_to_read (void) const +{ + return this->bytes_to_read_; +} + +ACE_Message_Block* +ACE_WIN32_Asynch_Read_Dgram_Result::message_block (void) const +{ + return this->message_block_; +} + + +int +ACE_WIN32_Asynch_Read_Dgram_Result::remote_address (ACE_Addr& addr) const +{ + int retVal = -1; // failure + + // make sure the addresses are of the same type + if (addr.get_type () == this->remote_address_->get_type ()) + { // copy the remote_address_ into addr + addr.set_addr (this->remote_address_->get_addr (), + this->remote_address_->get_size ()); + retVal = 0; // success + } + + return retVal; +} + +sockaddr * +ACE_WIN32_Asynch_Read_Dgram_Result::saddr () const +{ + return (sockaddr *) this->remote_address_->get_addr (); +} + + +int +ACE_WIN32_Asynch_Read_Dgram_Result::flags (void) const +{ + return this->flags_; +} + +ACE_HANDLE +ACE_WIN32_Asynch_Read_Dgram_Result::handle (void) const +{ + return this->handle_; +} + +size_t +ACE_WIN32_Asynch_Read_Dgram_Result::bytes_transferred (void) const +{ + return ACE_WIN32_Asynch_Result::bytes_transferred (); +} + +const void * +ACE_WIN32_Asynch_Read_Dgram_Result::act (void) const +{ + return ACE_WIN32_Asynch_Result::act (); +} + +int +ACE_WIN32_Asynch_Read_Dgram_Result::success (void) const +{ + return ACE_WIN32_Asynch_Result::success (); +} + +const void * +ACE_WIN32_Asynch_Read_Dgram_Result::completion_key (void) const +{ + return ACE_WIN32_Asynch_Result::completion_key (); +} + +u_long +ACE_WIN32_Asynch_Read_Dgram_Result::error (void) const +{ + return ACE_WIN32_Asynch_Result::error (); +} + +ACE_HANDLE +ACE_WIN32_Asynch_Read_Dgram_Result::event (void) const +{ + return ACE_WIN32_Asynch_Result::event (); +} + +u_long +ACE_WIN32_Asynch_Read_Dgram_Result::offset (void) const +{ + return ACE_WIN32_Asynch_Result::offset (); +} + +u_long +ACE_WIN32_Asynch_Read_Dgram_Result::offset_high (void) const +{ + return ACE_WIN32_Asynch_Result::offset_high (); +} + +int +ACE_WIN32_Asynch_Read_Dgram_Result::priority (void) const +{ + return ACE_WIN32_Asynch_Result::priority (); +} + +int +ACE_WIN32_Asynch_Read_Dgram_Result::signal_number (void) const +{ + return ACE_WIN32_Asynch_Result::signal_number (); +} + +int +ACE_WIN32_Asynch_Read_Dgram_Result::post_completion (ACE_Proactor_Impl *proactor) +{ + return ACE_WIN32_Asynch_Result::post_completion (proactor); +} + +ACE_WIN32_Asynch_Read_Dgram_Result::ACE_WIN32_Asynch_Read_Dgram_Result ( + const ACE_Handler::Proxy_Ptr &handler_proxy, + ACE_HANDLE handle, + ACE_Message_Block *message_block, + size_t bytes_to_read, + int flags, + int protocol_family, + const void* act, + ACE_HANDLE event, + int priority, + int signal_number) + : ACE_Asynch_Result_Impl (), + ACE_Asynch_Read_Dgram_Result_Impl(), + ACE_WIN32_Asynch_Result (handler_proxy, act, event, 0, 0, priority, signal_number), + bytes_to_read_ (bytes_to_read), + message_block_ (message_block), + remote_address_ (0), + addr_len_ (0), + flags_ (flags), + handle_ (handle) +{ + ACE_ASSERT (protocol_family == PF_INET); // only supporting INET addresses + + ACE_NEW (remote_address_, ACE_INET_Addr); + addr_len_ = remote_address_->get_size (); + + ACE_UNUSED_ARG (protocol_family); +} + +void +ACE_WIN32_Asynch_Read_Dgram_Result::complete (size_t bytes_transferred, + int success, + const void *completion_key, + u_long error) +{ + // Copy the data which was returned by GetQueuedCompletionStatus + this->bytes_transferred_ = bytes_transferred; + this->success_ = success; + this->completion_key_ = completion_key; + this->error_ = error; + + // Appropriately move the pointers in the message block. + for (ACE_Message_Block* mb = this->message_block_; + (mb != 0) && (bytes_transferred > 0); + mb = mb->cont ()) + { + size_t len_part = mb->space (); + + if ( len_part > bytes_transferred) + len_part = bytes_transferred; + + mb->wr_ptr (len_part); + + bytes_transferred -= len_part; + } + + // Adjust the address length + this->remote_address_->set_size (this->addr_len_); + + // Create the interface result class. + ACE_Asynch_Read_Dgram::Result result (this); + + // Call the application handler. + ACE_Handler *handler = this->handler_proxy_.get ()->handler (); + if (handler != 0) + handler->handle_read_dgram (result); +} + +ACE_WIN32_Asynch_Read_Dgram_Result::~ACE_WIN32_Asynch_Read_Dgram_Result (void) +{ + delete this->remote_address_; +} + +//*************************************************************************** + +ACE_WIN32_Asynch_Read_Dgram::~ACE_WIN32_Asynch_Read_Dgram (void) +{ +} + +ssize_t +ACE_WIN32_Asynch_Read_Dgram::recv (ACE_Message_Block *message_block, + size_t & number_of_bytes_recvd, + int flags, + int protocol_family, + const void *act, + int priority, + int signal_number) +{ + number_of_bytes_recvd = 0; + + size_t bytes_to_read = 0; + + iovec iov[ACE_IOV_MAX]; + int iovcnt = 0; + + for (const ACE_Message_Block* msg = message_block; + msg != 0 && iovcnt < ACE_IOV_MAX; + msg = msg->cont () , ++iovcnt ) + { + size_t msg_space = msg->space (); + + // OS should correctly process zero length buffers + // if ( msg_space == 0 ) + // ACE_ERROR_RETURN ((LM_ERROR, + // ACE_TEXT ("ACE_WIN32_Asynch_Read_Dgram::recv:") + // ACE_TEXT ("No space in the message block\n")), + // -1); + + bytes_to_read += msg_space; + + // Make as many iovec as needed to fit all of msg_len. + size_t wr_ptr_offset = 0; + + while (msg_space > 0 && iovcnt < ACE_IOV_MAX) + { + u_long this_chunk_length; + if (msg_space > ULONG_MAX) + this_chunk_length = ULONG_MAX; + else + this_chunk_length = static_cast (msg_space); + // Collect the data in the iovec. + iov[iovcnt].iov_base = msg->wr_ptr () + wr_ptr_offset; + iov[iovcnt].iov_len = this_chunk_length; + msg_space -= this_chunk_length; + wr_ptr_offset += this_chunk_length; + + // Increment iovec counter if there's more to do. + if (msg_space > 0) + iovcnt++; + } + if (msg_space > 0) // Ran out of iovecs before msg_space exhausted + { + errno = ERANGE; + return -1; + } + } + + if (bytes_to_read == 0) + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("ACE_WIN32_Asynch_Read_Dgram::recv:") + ACE_TEXT ("Attempt to read 0 bytes\n")), + -1); + + // Create the Asynch_Result. + ACE_WIN32_Asynch_Read_Dgram_Result *result = 0; + ACE_NEW_RETURN (result, + ACE_WIN32_Asynch_Read_Dgram_Result (this->handler_proxy_, + this->handle_, + message_block, + bytes_to_read, + flags, + protocol_family, + act, + this->win32_proactor_->get_handle (), + priority, + signal_number), + -1); + + // do the scatter/gather recv + ssize_t initiate_result = ACE_OS::recvfrom (result->handle (), + iov, + iovcnt, + number_of_bytes_recvd, + result->flags_, + result->saddr (), + &(result->addr_len_), + result, + 0); + if (initiate_result == SOCKET_ERROR) + { + // If initiate failed, check for a bad error. + ACE_OS::set_errno_to_last_error (); + switch (errno) + { + case ERROR_IO_PENDING: + // The IO will complete proactively: the OVERLAPPED will still + // get queued. + initiate_result = 0; + break; + + default: + // Something else went wrong: the OVERLAPPED will not get + // queued. + + if (ACE::debug ()) + { + ACE_DEBUG ((LM_ERROR, + ACE_TEXT ("%p\n"), + ACE_TEXT ("WSARecvFrom"))); + } + + delete result; + initiate_result = -1; + break; + } + + } + else + { + // Immediate success: the OVERLAPPED will still get queued. + // number_of_bytes_recvd contains the number of bytes recvd + // addr contains the peer address + // flags was updated + + // number_of_bytes_recvd = bytes_recvd; + initiate_result = 1; + } + + return initiate_result; +} + +int +ACE_WIN32_Asynch_Read_Dgram::open (const ACE_Handler::Proxy_Ptr &handler_proxy, + ACE_HANDLE handle, + const void *completion_key, + ACE_Proactor *proactor) +{ + return ACE_WIN32_Asynch_Operation::open (handler_proxy, + handle, + completion_key, + proactor); +} + +int +ACE_WIN32_Asynch_Read_Dgram::cancel (void) +{ + return ACE_WIN32_Asynch_Operation::cancel (); +} + +ACE_Proactor * +ACE_WIN32_Asynch_Read_Dgram::proactor (void) const +{ + return ACE_WIN32_Asynch_Operation::proactor (); +} + +ACE_WIN32_Asynch_Read_Dgram::ACE_WIN32_Asynch_Read_Dgram (ACE_WIN32_Proactor *win32_proactor) + : ACE_Asynch_Operation_Impl (), + ACE_Asynch_Read_Dgram_Impl (), + ACE_WIN32_Asynch_Operation (win32_proactor) +{ +} + +//*********************************************** + +size_t +ACE_WIN32_Asynch_Write_Dgram_Result::bytes_to_write (void) const +{ + return this->bytes_to_write_; +} + +ACE_Message_Block* +ACE_WIN32_Asynch_Write_Dgram_Result::message_block () const +{ + return this->message_block_; +} + +int +ACE_WIN32_Asynch_Write_Dgram_Result::flags (void) const +{ + return this->flags_; +} + +ACE_HANDLE +ACE_WIN32_Asynch_Write_Dgram_Result::handle (void) const +{ + return this->handle_; +} + +size_t +ACE_WIN32_Asynch_Write_Dgram_Result::bytes_transferred (void) const +{ + return ACE_WIN32_Asynch_Result::bytes_transferred (); +} + +const void * +ACE_WIN32_Asynch_Write_Dgram_Result::act (void) const +{ + return ACE_WIN32_Asynch_Result::act (); +} + +int +ACE_WIN32_Asynch_Write_Dgram_Result::success (void) const +{ + return ACE_WIN32_Asynch_Result::success (); +} + +const void * +ACE_WIN32_Asynch_Write_Dgram_Result::completion_key (void) const +{ + return ACE_WIN32_Asynch_Result::completion_key (); +} + +u_long +ACE_WIN32_Asynch_Write_Dgram_Result::error (void) const +{ + return ACE_WIN32_Asynch_Result::error (); +} + +ACE_HANDLE +ACE_WIN32_Asynch_Write_Dgram_Result::event (void) const +{ + return ACE_WIN32_Asynch_Result::event (); +} + +u_long +ACE_WIN32_Asynch_Write_Dgram_Result::offset (void) const +{ + return ACE_WIN32_Asynch_Result::offset (); +} + +u_long +ACE_WIN32_Asynch_Write_Dgram_Result::offset_high (void) const +{ + return ACE_WIN32_Asynch_Result::offset_high (); +} + +int +ACE_WIN32_Asynch_Write_Dgram_Result::priority (void) const +{ + return ACE_WIN32_Asynch_Result::priority (); +} + +int +ACE_WIN32_Asynch_Write_Dgram_Result::signal_number (void) const +{ + return ACE_WIN32_Asynch_Result::signal_number (); +} + +int +ACE_WIN32_Asynch_Write_Dgram_Result::post_completion (ACE_Proactor_Impl *proactor) +{ + return ACE_WIN32_Asynch_Result::post_completion (proactor); +} + +ACE_WIN32_Asynch_Write_Dgram_Result::ACE_WIN32_Asynch_Write_Dgram_Result ( + const ACE_Handler::Proxy_Ptr &handler_proxy, + ACE_HANDLE handle, + ACE_Message_Block *message_block, + size_t bytes_to_write, + int flags, + const void* act, + ACE_HANDLE event, + int priority, + int signal_number) + : ACE_Asynch_Result_Impl (), + ACE_Asynch_Write_Dgram_Result_Impl(), + ACE_WIN32_Asynch_Result (handler_proxy, + act, + event, + 0, + 0, + priority, + signal_number), + bytes_to_write_ (bytes_to_write), + message_block_ (message_block), + flags_ (flags), + handle_ (handle) +{ +} + +void +ACE_WIN32_Asynch_Write_Dgram_Result::complete (size_t bytes_transferred, + int success, + const void *completion_key, + u_long error) +{ + // Copy the data which was returned by GetQueuedCompletionStatus + this->bytes_transferred_ = bytes_transferred; + this->success_ = success; + this->completion_key_ = completion_key; + this->error_ = error; + + // Appropriately move the pointers in the message block. + for (ACE_Message_Block* mb = this->message_block_; + (mb != 0) && (bytes_transferred > 0); + mb = mb->cont ()) + { + size_t len_part = mb->length (); + + if ( len_part > bytes_transferred) + len_part = bytes_transferred; + + mb->rd_ptr (len_part); + + bytes_transferred -= len_part; + } + + // Create the interface result class. + ACE_Asynch_Write_Dgram::Result result (this); + + // Call the application handler. + ACE_Handler *handler = this->handler_proxy_.get ()->handler (); + if (handler != 0) + handler->handle_write_dgram (result); +} + +ACE_WIN32_Asynch_Write_Dgram_Result::~ACE_WIN32_Asynch_Write_Dgram_Result (void) +{ +} + + +//*********************************************** + +ACE_WIN32_Asynch_Write_Dgram::~ACE_WIN32_Asynch_Write_Dgram (void) +{ +} + +ssize_t +ACE_WIN32_Asynch_Write_Dgram::send (ACE_Message_Block *message_block, + size_t &number_of_bytes_sent, + int flags, + const ACE_Addr &addr, + const void *act, + int priority, + int signal_number) +{ + number_of_bytes_sent = 0; + + size_t bytes_to_write = 0; + + iovec iov[ACE_IOV_MAX]; + int iovcnt = 0; + + for (const ACE_Message_Block* msg = message_block; + msg != 0 && iovcnt < ACE_IOV_MAX; + msg = msg->cont () , ++iovcnt ) + { + size_t msg_len = msg->length (); + + bytes_to_write += msg_len; + + // Make as many iovec as needed to fit all of msg_len. + size_t rd_ptr_offset = 0; + + do + { + if (msg_len >= 0 && iovcnt < ACE_IOV_MAX) + { + u_long this_chunk_length; + if (msg_len > ULONG_MAX) + this_chunk_length = ULONG_MAX; + else + this_chunk_length = static_cast (msg_len); + + // Collect the data in the iovec. + iov[iovcnt].iov_base = msg->rd_ptr () + rd_ptr_offset; + iov[iovcnt].iov_len = this_chunk_length; + msg_len -= this_chunk_length; + rd_ptr_offset += this_chunk_length; + + // Increment iovec counter if there's more to do. + if (msg_len > 0) + iovcnt++; + } + } + while (msg_len > 0 && iovcnt < ACE_IOV_MAX); + + if (msg_len > 0) // Ran out of iovecs before msg_space exhausted + { + errno = ERANGE; + return -1; + } + } + + // Create the Asynch_Result. + ACE_WIN32_Asynch_Write_Dgram_Result *result = 0; + ACE_NEW_RETURN (result, + ACE_WIN32_Asynch_Write_Dgram_Result (this->handler_proxy_, + this->handle_, + message_block, + bytes_to_write, + flags, + act, + this->win32_proactor_->get_handle (), + priority, + signal_number), + -1); + + // do the scatter/gather send + + ssize_t initiate_result = ACE_OS::sendto (result->handle (), + iov, + iovcnt, + number_of_bytes_sent, + result->flags_, + (sockaddr *) addr.get_addr (), + addr.get_size(), + result, + 0); + + + if (initiate_result == SOCKET_ERROR) + { + // If initiate failed, check for a bad error. + ACE_OS::set_errno_to_last_error (); + switch (errno) + { + case ERROR_IO_PENDING: + // The IO will complete proactively: the OVERLAPPED will still + // get queued. + initiate_result = 0; + break; + + default: + // Something else went wrong: the OVERLAPPED will not get + // queued. + + if (ACE::debug ()) + { + ACE_DEBUG ((LM_ERROR, + ACE_TEXT ("%p\n"), + ACE_TEXT ("WSASendTo"))); + } + + delete result; + initiate_result = -1; + break; + } + + } + else + { + // Immediate success: the OVERLAPPED will still get queued. + // number_of_bytes_recvd contains the number of bytes recvd + // addr contains the peer address + // flags was updated + + // number_of_bytes_sent = bytes_sent; + initiate_result = 1; + } + + return initiate_result; +} + +int +ACE_WIN32_Asynch_Write_Dgram::open (const ACE_Handler::Proxy_Ptr &handler_proxy, + ACE_HANDLE handle, + const void *completion_key, + ACE_Proactor *proactor) +{ + return ACE_WIN32_Asynch_Operation::open (handler_proxy, + handle, + completion_key, + proactor); +} + +int +ACE_WIN32_Asynch_Write_Dgram::cancel (void) +{ + return ACE_WIN32_Asynch_Operation::cancel (); +} + +ACE_Proactor * +ACE_WIN32_Asynch_Write_Dgram::proactor (void) const +{ + return ACE_WIN32_Asynch_Operation::proactor (); +} + +ACE_WIN32_Asynch_Write_Dgram::ACE_WIN32_Asynch_Write_Dgram (ACE_WIN32_Proactor *win32_proactor) + : ACE_Asynch_Operation_Impl (), + ACE_Asynch_Write_Dgram_Impl (), + ACE_WIN32_Asynch_Operation (win32_proactor) +{ +} + +ACE_END_VERSIONED_NAMESPACE_DECL + +#endif /* ACE_HAS_WIN32_OVERLAPPED_IO && ACE_HAS_WINSOCK2 */ diff --git a/dep/ACE_wrappers/ace/WIN32_Asynch_IO.h b/dep/ACE_wrappers/ace/WIN32_Asynch_IO.h new file mode 100644 index 00000000000..34af77dabb2 --- /dev/null +++ b/dep/ACE_wrappers/ace/WIN32_Asynch_IO.h @@ -0,0 +1,1937 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file WIN32_Asynch_IO.h + * + * $Id: WIN32_Asynch_IO.h 80826 2008-03-04 14:51:23Z wotte $ + * + * + * These classes only works on Win32 platforms. + * + * The implementation of ACE_Asynch_Transmit_File, + * ACE_Asynch_Accept, and ACE_Asynch_Connect are only supported if + * ACE_HAS_WINSOCK2 is defined or you are on WinNT 4.0 or higher. + * + * + * @author Irfan Pyarali + * @author Tim Harrison + * @author Alexander Babu Arulanthu + * @author Roger Tragin + * @author Alexander Libman + */ +//============================================================================= + +#ifndef ACE_WIN32_ASYNCH_IO_H +#define ACE_WIN32_ASYNCH_IO_H +#include /**/ "ace/pre.h" + +#include /**/ "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +#pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#if defined (ACE_HAS_WIN32_OVERLAPPED_IO) && \ + (defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 == 1)) + +#include "ace/Asynch_IO_Impl.h" +#include "ace/Addr.h" +#include "ace/Event_Handler.h" +#include "ace/Handle_Set.h" +#include "ace/Map_Manager.h" +#include "ace/Null_Mutex.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +// Forward declaration +class ACE_WIN32_Proactor; + +/** + * @class ACE_WIN32_Asynch_Result + * + * @brief An abstract class which adds information to the OVERLAPPED + * structure to make it more useful. + * + * An abstract base class from which you can obtain some basic + * information like the number of bytes transferred, the ACT + * associated with the asynchronous operation, indication of + * success or failure, etc. Subclasses may want to store more + * information that is particular to the asynchronous operation + * it represents. + */ +class ACE_Export ACE_WIN32_Asynch_Result : public virtual ACE_Asynch_Result_Impl, + public OVERLAPPED +{ + /// Factory class has special permissions. + friend class ACE_WIN32_Asynch_Accept; + + /// Proactor class has special permission. + friend class ACE_WIN32_Proactor; + +public: + /// Number of bytes transferred by the operation. + size_t bytes_transferred (void) const; + + /// ACT associated with the operation. + const void *act (void) const; + + /// Did the operation succeed? + int success (void) const; + + /** + * This returns the ACT associated with the handle when it was + * registered with the I/O completion port. This ACT is not the + * same as the ACT associated with the asynchronous operation. + */ + const void *completion_key (void) const; + + /// Error value if the operation fail. + u_long error (void) const; + + /// Event associated with the OVERLAPPED structure. + ACE_HANDLE event (void) const; + + /// This really make sense only when doing file I/O. + u_long offset (void) const; + + /// Offset_high associated with the OVERLAPPED structure. + u_long offset_high (void) const; + + /// The priority of the asynchronous operation. Currently, this is + /// not supported on Win32. + int priority (void) const; + + /// Returns 0. + int signal_number (void) const; + + /// Post @c this to the Proactor's completion port. + int post_completion (ACE_Proactor_Impl *proactor); + + /// Destructor. + virtual ~ACE_WIN32_Asynch_Result (void); + + /// Simulate error value to use in the post_completion () + void set_error (u_long errcode); + + /// Simulate value to use in the post_completion () + void set_bytes_transferred (size_t nbytes); + +protected: + /// Constructor. + ACE_WIN32_Asynch_Result (const ACE_Handler::Proxy_Ptr &handler_proxy, + const void* act, + ACE_HANDLE event, + u_long offset, + u_long offset_high, + int priority, + int signal_number = 0); + + /// Proxy for the ACE_Handler that will be called back. + ACE_Handler::Proxy_Ptr handler_proxy_; + + /// ACT for this operation. + const void *act_; + + /// Bytes transferred by this operation. + size_t bytes_transferred_; + + /// Success indicator. + int success_; + + /// ACT associated with handle. + const void *completion_key_; + + /// Error if operation failed. + u_long error_; +}; + +/** + * @class ACE_WIN32_Asynch_Operation + * + * @brief This class abstracts out the common things needed for + * implementing Asynch_Operation for WIN32 platform. + * + */ +class ACE_Export ACE_WIN32_Asynch_Operation : public virtual ACE_Asynch_Operation_Impl +{ +public: + /** + * Initializes the factory with information which will be used with + * each asynchronous call. If ( == ACE_INVALID_HANDLE), + * will be called on the @a handler to get the + * correct handle. + */ + int open (const ACE_Handler::Proxy_Ptr &handler_proxy, + ACE_HANDLE handle, + const void *completion_key, + ACE_Proactor *proactor); + + /** + * This cancels all pending accepts operations that were issued by + * the calling thread. The function does not cancel asynchronous + * operations issued by other threads. + */ + int cancel (void); + + // = Access methods. + + /// Return the underlying proactor. + ACE_Proactor* proactor (void) const; + +protected: + /// Constructor. + ACE_WIN32_Asynch_Operation (ACE_WIN32_Proactor *win32_proactor); + + /// Destructor. + virtual ~ACE_WIN32_Asynch_Operation (void); + + /// Win32 Proactor. + ACE_WIN32_Proactor *win32_proactor_; + + /// Proactor that this asynch IO is registered with. + ACE_Proactor *proactor_; + + /// Handler that will receive the callback. + ACE_Handler::Proxy_Ptr handler_proxy_; + + /// I/O handle used for reading. + ACE_HANDLE handle_; +}; + +/** + * @class ACE_WIN32_Asynch_Read_Stream_Result + * + * @brief This class provides concrete implementation for + * ACE_Asynch_Read_Stream::Result class. + */ +class ACE_Export ACE_WIN32_Asynch_Read_Stream_Result : public virtual ACE_Asynch_Read_Stream_Result_Impl, + public ACE_WIN32_Asynch_Result +{ + /// Factory class will have special permissions. + friend class ACE_WIN32_Asynch_Read_Stream; + + /// Proactor class has special permission. + friend class ACE_WIN32_Proactor; + +public: + /// The number of bytes which were requested at the start of the + /// asynchronous read. + size_t bytes_to_read (void) const; + + /// Message block which contains the read data. + ACE_Message_Block &message_block (void) const; + + /// I/O handle used for reading. + ACE_HANDLE handle (void) const; + + // Base class operations. These operations are here to kill + // dominance warnings. These methods call the base class methods. + + /// Number of bytes transferred by the operation. + size_t bytes_transferred (void) const; + + /// ACT associated with the operation. + const void *act (void) const; + + /// Did the operation succeed? + int success (void) const; + + /** + * This returns the ACT associated with the handle when it was + * registered with the I/O completion port. This ACT is not the + * same as the ACT associated with the asynchronous operation. + */ + const void *completion_key (void) const; + + /// Error value if the operation fail. + u_long error (void) const; + + /// Event associated with the OVERLAPPED structure. + ACE_HANDLE event (void) const; + + /// This really make sense only when doing file I/O. + u_long offset (void) const; + + /// Offset_high associated with the OVERLAPPED structure. + u_long offset_high (void) const; + + /// The priority of the asynchronous operation. Currently, this is + /// not supported on Win32. + int priority (void) const; + + /// No-op. Returns 0. + int signal_number (void) const; + + /// Post @c this to the Proactor's completion port. + int post_completion (ACE_Proactor_Impl *proactor); + + /// Accessor for the scatter read flag + int scatter_enabled (void) const; + +protected: + /// Constructor is protected since creation is limited to + /// ACE_Asynch_Read_Stream factory. + ACE_WIN32_Asynch_Read_Stream_Result (const ACE_Handler::Proxy_Ptr &handler_proxy, + ACE_HANDLE handle, + ACE_Message_Block &message_block, + size_t bytes_to_read, + const void* act, + ACE_HANDLE event, + int priority, + int signal_number = 0, + int scatter_enabled = 0); + + /// Proactor will call this method when the read completes. + virtual void complete (size_t bytes_transferred, + int success, + const void *completion_key, + u_long error); + + /// Destructor. + virtual ~ACE_WIN32_Asynch_Read_Stream_Result (void); + + /// Bytes requested when the asynchronous read was initiated. + size_t bytes_to_read_; + + /// Message block for reading the data into. + ACE_Message_Block &message_block_; + + /// I/O handle used for reading. + ACE_HANDLE handle_; + + /// Flag for scatter read + int scatter_enabled_; +}; + +/** + * @class ACE_WIN32_Asynch_Read_Stream + * + * @brief This class is a factory for starting off asynchronous reads + * on a stream. + * + * Once is called, multiple asynchronous s can + * started using this class. An ACE_Asynch_Read_Stream::Result + * will be passed back to the @a handler when the asynchronous + * reads completes through the + * callback. + */ +class ACE_Export ACE_WIN32_Asynch_Read_Stream : public virtual ACE_Asynch_Read_Stream_Impl, + public ACE_WIN32_Asynch_Operation +{ + +public: + /// Constructor. + ACE_WIN32_Asynch_Read_Stream (ACE_WIN32_Proactor *win32_proactor); + + /// This starts off an asynchronous read. Upto @a bytes_to_read will + /// be read and stored in the @a message_block. + int read (ACE_Message_Block &message_block, + size_t bytes_to_read, + const void *act, + int priority, + int signal_number = 0); + + /** + * Same as above but with scatter support, through chaining of composite + * message blocks using the continuation field. + */ + int readv (ACE_Message_Block &message_block, + size_t bytes_to_read, + const void *act, + int priority, + int signal_number = 0); + + /// Destructor. + virtual ~ACE_WIN32_Asynch_Read_Stream (void); + + // Methods belong to ACE_WIN32_Asynch_Operation base class. These + // methods are defined here to avoid VC++ warnings. They route the + // call to the ACE_WIN32_Asynch_Operation base class. + + /** + * Initializes the factory with information which will be used with + * each asynchronous call. If ( == ACE_INVALID_HANDLE), + * will be called on the @a handler to get the + * correct handle. + */ + int open (const ACE_Handler::Proxy_Ptr &handler_proxy, + ACE_HANDLE handle, + const void *completion_key, + ACE_Proactor *proactor); + + /** + * This cancels all pending accepts operations that were issued by + * the calling thread. The function does not cancel asynchronous + * operations issued by other threads. + */ + int cancel (void); + + /// Return the underlying proactor. + ACE_Proactor* proactor (void) const; + +protected: + /// This is the method which does the real work and is there so that + /// the ACE_Asynch_Read_File class can use it too. + int shared_read (ACE_WIN32_Asynch_Read_Stream_Result *result); +}; + +/** + * @class ACE_WIN32_Asynch_Write_Stream_Result + * + * @brief This class provides concrete implementation for + * ACE_Asynch_Write_Stream::Result class. + */ +class ACE_Export ACE_WIN32_Asynch_Write_Stream_Result : public virtual ACE_Asynch_Write_Stream_Result_Impl, + public ACE_WIN32_Asynch_Result +{ + /// Factory class willl have special permissions. + friend class ACE_WIN32_Asynch_Write_Stream; + + /// Proactor class has special permission. + friend class ACE_WIN32_Proactor; + +public: + /// The number of bytes which were requested at the start of the + /// asynchronous write. + size_t bytes_to_write (void) const; + + /// Message block that contains the data to be written. + ACE_Message_Block &message_block (void) const; + + /// I/O handle used for writing. + ACE_HANDLE handle (void) const; + + // = Base class operations. These operations are here to kill some + // warnings. These methods call the base class methods. + + /// Number of bytes transferred by the operation. + size_t bytes_transferred (void) const; + + /// ACT associated with the operation. + const void *act (void) const; + + /// Did the operation succeed? + int success (void) const; + + /** + * This returns the ACT associated with the handle when it was + * registered with the I/O completion port. This ACT is not the + * same as the ACT associated with the asynchronous operation. + */ + const void *completion_key (void) const; + + /// Error value if the operation fail. + u_long error (void) const; + + /// Event associated with the OVERLAPPED structure. + ACE_HANDLE event (void) const; + + /// This really make sense only when doing file I/O. + u_long offset (void) const; + + /// Offset_high associated with the OVERLAPPED structure. + u_long offset_high (void) const; + + /// The priority of the asynchronous operation. Currently, this is + /// not supported on Win32. + int priority (void) const; + + /// No-op. Returns 0. + int signal_number (void) const; + + /// Post @c this to the Proactor's completion port. + int post_completion (ACE_Proactor_Impl *proactor); + + /// Accessor for the gather write flag + int gather_enabled (void) const; + +protected: + /// Constructor is protected since creation is limited to + /// ACE_Asynch_Write_Stream factory. + ACE_WIN32_Asynch_Write_Stream_Result (const ACE_Handler::Proxy_Ptr &handler_proxy, + ACE_HANDLE handle, + ACE_Message_Block &message_block, + size_t bytes_to_write, + const void* act, + ACE_HANDLE event, + int priority, + int signal_number = 0, + int gather_enabled = 0); + + /// ACE_Proactor will call this method when the write completes. + virtual void complete (size_t bytes_transferred, + int success, + const void *completion_key, + u_long error); + + /// Destructor. + virtual ~ACE_WIN32_Asynch_Write_Stream_Result (void); + + /// The number of bytes which were requested at the start of the + /// asynchronous write. + size_t bytes_to_write_; + + /// Message block that contains the data to be written. + ACE_Message_Block &message_block_; + + /// I/O handle used for writing. + ACE_HANDLE handle_; + + /// Flag for gather write + int gather_enabled_; +}; + +/** + * @class ACE_WIN32_Asynch_Write_Stream + * + * @brief This class is a factory for starting off asynchronous writes + * on a stream. + * + * + * Once is called, multiple asynchronous s can + * started using this class. A ACE_Asynch_Write_Stream::Result + * will be passed back to the @a handler when the asynchronous + * write completes through the + * callback. + */ +class ACE_Export ACE_WIN32_Asynch_Write_Stream : public virtual ACE_Asynch_Write_Stream_Impl, + public ACE_WIN32_Asynch_Operation +{ +public: + /// Constructor. + ACE_WIN32_Asynch_Write_Stream (ACE_WIN32_Proactor *win32_proactor); + + /// This starts off an asynchronous write. Upto @a bytes_to_write + /// will be written from the @a message_block. + int write (ACE_Message_Block &message_block, + size_t bytes_to_write, + const void *act, + int priority, + int signal_number = 0); + + /** + * Same as above but with gather support, through chaining of composite + * message blocks using the continuation field. + */ + int writev (ACE_Message_Block &message_block, + size_t bytes_to_write, + const void *act, + int priority, + int signal_number = 0); + + /// Destructor. + virtual ~ACE_WIN32_Asynch_Write_Stream (void); + + // = Methods belonging to base class. + + // These methods are defined here to avoid VC++ warnings. They route + // the call to the base class. + + /** + * Initializes the factory with information which will be used with + * each asynchronous call. If ( == ACE_INVALID_HANDLE), + * will be called on the @a handler to get the + * correct handle. + */ + int open (const ACE_Handler::Proxy_Ptr &handler_proxy, + ACE_HANDLE handle, + const void *completion_key, + ACE_Proactor *proactor); + + /** + * This cancels all pending accepts operations that were issued by + * the calling thread. The function does not cancel asynchronous + * operations issued by other threads. + */ + int cancel (void); + + /// Return the underlying proactor. + ACE_Proactor* proactor (void) const; + +protected: + /// This is the method which does the real work and is there so that + /// the ACE_Asynch_Write_File class can use it too. + int shared_write (ACE_WIN32_Asynch_Write_Stream_Result *result); +}; + +/** + * @class ACE_WIN32_Asynch_Read_File_Result + * + * @brief This class provides concrete implementation for + * ACE_Asynch_Read_File::Result class. + */ +class ACE_Export ACE_WIN32_Asynch_Read_File_Result : public virtual ACE_Asynch_Read_File_Result_Impl, + public ACE_WIN32_Asynch_Read_Stream_Result +{ + /// Factory class will have special permissions. + friend class ACE_WIN32_Asynch_Read_File; + + /// Proactor class has special permission. + friend class ACE_WIN32_Proactor; + +public: + // = These methods belong to ACE_WIN32_Asynch_Result class base + // class. These operations are here to kill some warnings. These + // methods call the base class methods. + + /// Number of bytes transferred by the operation. + size_t bytes_transferred (void) const; + + /// ACT associated with the operation. + const void *act (void) const; + + /// Did the operation succeed? + int success (void) const; + + /** + * This returns the ACT associated with the handle when it was + * registered with the I/O completion port. This ACT is not the + * same as the ACT associated with the asynchronous operation. + */ + const void *completion_key (void) const; + + /// Error value if the operation fail. + u_long error (void) const; + + /// Event associated with the OVERLAPPED structure. + ACE_HANDLE event (void) const; + + /// This really make sense only when doing file I/O. + u_long offset (void) const; + + /// Offset_high associated with the OVERLAPPED structure. + u_long offset_high (void) const; + + /// The priority of the asynchronous operation. Currently, this is + /// not supported on Win32. + int priority (void) const; + + /// No-op. Returns 0. + int signal_number (void) const; + + // The following methods belong to + // ACE_WIN32_Asynch_Read_Stream_Result. They are here to avoid VC++ + // dominance warnings. These methods route their call to the + // ACE_WIN32_Asynch_Read_Stream_Result base class. + + /// The number of bytes which were requested at the start of the + /// asynchronous read. + size_t bytes_to_read (void) const; + + /// Message block which contains the read data. + ACE_Message_Block &message_block (void) const; + + /// I/O handle used for reading. + ACE_HANDLE handle (void) const; + + /// Post @c this to the Proactor's completion port. + int post_completion (ACE_Proactor_Impl *proactor); + +protected: + /// Constructor is protected since creation is limited to + /// ACE_Asynch_Read_File factory. + ACE_WIN32_Asynch_Read_File_Result (const ACE_Handler::Proxy_Ptr &handler_proxy, + ACE_HANDLE handle, + ACE_Message_Block &message_block, + size_t bytes_to_read, + const void* act, + u_long offset, + u_long offset_high, + ACE_HANDLE event, + int priority, + int signal_number = 0, + int scatter_enabled = 0); + + /// ACE_Proactor will call this method when the read completes. + virtual void complete (size_t bytes_transferred, + int success, + const void *completion_key, + u_long error); + + /// Destructor. + virtual ~ACE_WIN32_Asynch_Read_File_Result (void); +}; + +/** + * @class ACE_WIN32_Asynch_Read_File + * + * @brief This class is a factory for starting off asynchronous reads + * on a file. + * + * Once is called, multiple asynchronous s can + * started using this class. A ACE_Asynch_Read_File::Result + * will be passed back to the @a handler when the asynchronous + * reads completes through the + * callback. + * + * This class differs slightly from ACE_Asynch_Read_Stream as it + * allows the user to specify an offset for the read. + */ +class ACE_Export ACE_WIN32_Asynch_Read_File : public virtual ACE_Asynch_Read_File_Impl, + public ACE_WIN32_Asynch_Read_Stream +{ + +public: + /// Constructor. + ACE_WIN32_Asynch_Read_File (ACE_WIN32_Proactor *win32_proactor); + + /** + * This starts off an asynchronous read. Upto @a bytes_to_read will + * be read and stored in the @a message_block. The read will start + * at @a offset from the beginning of the file. + */ + int read (ACE_Message_Block &message_block, + size_t bytes_to_read, + u_long offset, + u_long offset_high, + const void *act, + int priority, + int signal_number = 0); + + /** + * Same as above but with scatter support, through chaining of + * composite message blocks using the continuation field. + * @note Each data block payload must be at least the size of a + * system memory page and must be aligned on a system memory page + * size boundary + */ + int readv (ACE_Message_Block &message_block, + size_t bytes_to_read, + u_long offset, + u_long offset_high, + const void *act, + int priority, + int signal_number = 0); + + + /// Destructor. + virtual ~ACE_WIN32_Asynch_Read_File (void); + + // = Methods belong to ACE_WIN32_Asynch_Operation base class. These + // methods are defined here to avoid VC++ warnings. They route the + // call to the ACE_WIN32_Asynch_Operation base class. + + /** + * Initializes the factory with information which will be used with + * each asynchronous call. If ( == ACE_INVALID_HANDLE), + * will be called on the @a handler to get the + * correct handle. + */ + int open (const ACE_Handler::Proxy_Ptr &handler_proxy, + ACE_HANDLE handle, + const void *completion_key, + ACE_Proactor *proactor); + + /** + * This cancels all pending accepts operations that were issued by + * the calling thread. The function does not cancel asynchronous + * operations issued by other threads. + */ + int cancel (void); + + /// Return the underlying proactor. + ACE_Proactor* proactor (void) const; + +private: + /** + * This method belongs to ACE_WIN32_Asynch_Read_Stream. It is here + * to avoid the compiler warnings. We forward this call to the + * ACE_WIN32_Asynch_Read_Stream class. + */ + int read (ACE_Message_Block &message_block, + size_t bytes_to_read, + const void *act, + int priority, + int signal_number = 0); + + /** + * Same as above but with scatter support, through chaining of composite + * message blocks using the continuation field. + */ + int readv (ACE_Message_Block &message_block, + size_t bytes_to_read, + const void *act, + int priority, + int signal_number = 0); +}; + +/** + * @class ACE_WIN32_Asynch_Write_File_Result + * + * @brief This class provides implementation for + * ACE_Asynch_Write_File_Result for WIN32 platforms. + * + * This class has all the information necessary for the + * @a handler to uniquiely identify the completion of the + * asynchronous write. + * + * This class differs slightly from + * ACE_Asynch_Write_Stream::Result as it calls back + * on the @a handler instead + * of . No additional state + * is required by this class as ACE_Asynch_Result can store + * the @a offset. + */ +class ACE_Export ACE_WIN32_Asynch_Write_File_Result : public virtual ACE_Asynch_Write_File_Result_Impl, + public ACE_WIN32_Asynch_Write_Stream_Result +{ + /// Factory class will have special permission. + friend class ACE_WIN32_Asynch_Write_File; + + /// Proactor class has special permission. + friend class ACE_WIN32_Proactor; + +public: + // = Base class operations. These operations are here to kill some + // warnings. These methods call the base class methods. + + /// Number of bytes transferred by the operation. + size_t bytes_transferred (void) const; + + /// ACT associated with the operation. + const void *act (void) const; + + /// Did the operation succeed? + int success (void) const; + + /** + * This returns the ACT associated with the handle when it was + * registered with the I/O completion port. This ACT is not the + * same as the ACT associated with the asynchronous operation. + */ + const void *completion_key (void) const; + + /// Error value if the operation fail. + u_long error (void) const; + + /// Event associated with the OVERLAPPED structure. + ACE_HANDLE event (void) const; + + /// This really make sense only when doing file I/O. + u_long offset (void) const; + + /// Offset_high associated with the OVERLAPPED structure. + u_long offset_high (void) const; + + /// The priority of the asynchronous operation. Currently, this is + /// not supported on Win32. + int priority (void) const; + + /// No-op. Returns 0. + int signal_number (void) const; + + // The following methods belong to + // ACE_WIN32_Asynch_Read_Stream_Result. They are here to avoid VC++ + // warnings. These methods route their call to the + // ACE_WIN32_Asynch_Read_Stream_Result base class. + + /// The number of bytes which were requested at the start of the + /// asynchronous write. + size_t bytes_to_write (void) const; + + /// Message block that contains the data to be written. + ACE_Message_Block &message_block (void) const; + + /// I/O handle used for writing. + ACE_HANDLE handle (void) const; + + /// Post @c this to the Proactor's completion port. + int post_completion (ACE_Proactor_Impl *proactor); + +protected: + /// Constructor is protected since creation is limited to + /// ACE_Asynch_Write_File factory. + ACE_WIN32_Asynch_Write_File_Result (const ACE_Handler::Proxy_Ptr &handler_proxy, + ACE_HANDLE handle, + ACE_Message_Block &message_block, + size_t bytes_to_write, + const void* act, + u_long offset, + u_long offset_high, + ACE_HANDLE event, + int priority, + int signal_number = 0, + int gather_enabled = 0); + + /// ACE_Proactor will call this method when the write completes. + virtual void complete (size_t bytes_transferred, + int success, + const void *completion_key, + u_long error); + + /// Destructor. + virtual ~ACE_WIN32_Asynch_Write_File_Result (void); +}; + +/** + * @class ACE_WIN32_Asynch_Write_File + * + * @brief This class is a factory for starting off asynchronous writes + * on a file. + * + * Once is called, multiple asynchronous s can be + * started using this class. A ACE_Asynch_Write_File::Result + * will be passed back to the @a handler when the asynchronous + * writes completes through the + * callback. + */ +class ACE_Export ACE_WIN32_Asynch_Write_File : public virtual ACE_Asynch_Write_File_Impl, + public ACE_WIN32_Asynch_Write_Stream +{ +public: + /// Constructor. + ACE_WIN32_Asynch_Write_File (ACE_WIN32_Proactor *win32_proactor); + + /** + * This starts off an asynchronous write. Upto @a bytes_to_write + * will be write and stored in the @a message_block. The write will + * start at @a offset from the beginning of the file. + */ + int write (ACE_Message_Block &message_block, + size_t bytes_to_write, + u_long offset, + u_long offset_high, + const void *act, + int priority, + int signal_number = 0); + + /** + * Same as above but with gather support, through chaining of + * composite message blocks using the continuation field. + * @note Each data block payload must be at least the size of a + * system memory page and must be aligned on a system memory page + * size boundary + */ + int writev (ACE_Message_Block &message_block, + size_t bytes_to_write, + u_long offset, + u_long offset_high, + const void *act, + int priority, + int signal_number = 0); + + /// Destrcutor. + virtual ~ACE_WIN32_Asynch_Write_File (void); + + // = Methods belong to ACE_WIN32_Asynch_Operation base class. These + // methods are defined here to avoid VC++ warnings. They route the + // call to the ACE_WIN32_Asynch_Operation base class. + + /** + * Initializes the factory with information which will be used with + * each asynchronous call. If ( == ACE_INVALID_HANDLE), + * will be called on the @a handler to get the + * correct handle. + */ + int open (const ACE_Handler::Proxy_Ptr &handler_proxy, + ACE_HANDLE handle, + const void *completion_key, + ACE_Proactor *proactor); + + /** + * This cancels all pending accepts operations that were issued by + * the calling thread. The function does not cancel asynchronous + * operations issued by other threads. + */ + int cancel (void); + + /// Return the underlying proactor. + ACE_Proactor* proactor (void) const; + +private: + /** + * This method belongs to ACE_WIN32_Asynch_Write_Stream. It is here + * to avoid compiler warnings. This method is forwarded to the + * ACE_WIN32_Asynch_Write_Stream class. + */ + int write (ACE_Message_Block &message_block, + size_t bytes_to_write, + const void *act, + int priority, + int signal_number = 0); + + /** + * Same as above but with gather support, through chaining of composite + * message blocks using the continuation field. + */ + int writev (ACE_Message_Block &message_block, + size_t bytes_to_write, + const void *act, + int priority, + int signal_number = 0); +}; + +/** + * @class ACE_WIN32_Asynch_Accept_Result + * + * @brief This class implements ACE_Asynch_Accept::Result for WIN32 + * platform. + * + * This class has all the information necessary for the + * @a handler to uniquiely identify the completion of the + * asynchronous accept. + */ +class ACE_Export ACE_WIN32_Asynch_Accept_Result : public virtual ACE_Asynch_Accept_Result_Impl, + public ACE_WIN32_Asynch_Result +{ + /// Factory will have special permission. + friend class ACE_WIN32_Asynch_Accept; + + /// Proactor class has special permission. + friend class ACE_WIN32_Proactor; + +public: + /// The number of bytes which were requested at the start of the + /// asynchronous accept. + size_t bytes_to_read (void) const; + + /// Message block which contains the read data. + ACE_Message_Block &message_block (void) const; + + /// I/O handle used for accepting new connections. + ACE_HANDLE listen_handle (void) const; + + /// I/O handle for the new connection. + ACE_HANDLE accept_handle (void) const; + + // = Base class operations. These operations are here to kill some + // warnings. These methods call the base class methods. + + /// Number of bytes transferred by the operation. + size_t bytes_transferred (void) const; + + /// ACT associated with the operation. + const void *act (void) const; + + /// Did the operation succeed? + int success (void) const; + + /** + * This returns the ACT associated with the handle when it was + * registered with the I/O completion port. This ACT is not the + * same as the ACT associated with the asynchronous operation. + */ + const void *completion_key (void) const; + + /// Error value if the operation fail. + u_long error (void) const; + + /// Event associated with the OVERLAPPED structure. + ACE_HANDLE event (void) const; + + /// This really make sense only when doing file I/O. + u_long offset (void) const; + + /// Offset_high associated with the OVERLAPPED structure. + u_long offset_high (void) const; + + /// The priority of the asynchronous operation. Currently, this is + /// not supported on Win32. + int priority (void) const; + + /// No-op. Returns 0. + int signal_number (void) const; + + /// Post @c this to the Proactor's completion port. + int post_completion (ACE_Proactor_Impl *proactor); + +protected: + /// Constructor is protected since creation is limited to + /// ACE_Asynch_Accept factory. + ACE_WIN32_Asynch_Accept_Result (const ACE_Handler::Proxy_Ptr &handler_proxy, + ACE_HANDLE listen_handle, + ACE_HANDLE accept_handle, + ACE_Message_Block &message_block, + size_t bytes_to_read, + const void* act, + ACE_HANDLE event, + int priority, + int signal_number = 0); + + /// ACE_Proactor will call this method when the accept completes. + virtual void complete (size_t bytes_transferred, + int success, + const void *completion_key, + u_long error); + + /// Destructor. + virtual ~ACE_WIN32_Asynch_Accept_Result (void); + + /// Bytes requested when the asynchronous read was initiated. + size_t bytes_to_read_; + + /// Message block for reading the data into. + ACE_Message_Block &message_block_; + + /// I/O handle used for accepting new connections. + ACE_HANDLE listen_handle_; + + /// I/O handle for the new connection. + ACE_HANDLE accept_handle_; +}; + +/** + * @class ACE_WIN32_Asynch_Accept + * + * @brief This class is a factory for starting off asynchronous accepts + * on a listen handle. + * + * Once is called, multiple asynchronous s can + * started using this class. A ACE_Asynch_Accept::Result will + * be passed back to the @a handler when the asynchronous accept + * completes through the + * callback. + */ +class ACE_Export ACE_WIN32_Asynch_Accept : public virtual ACE_Asynch_Accept_Impl, + public ACE_WIN32_Asynch_Operation +{ +public: + /// Constructor. + ACE_WIN32_Asynch_Accept (ACE_WIN32_Proactor *win32_proactor); + + /** + * This starts off an asynchronous accept. The asynchronous accept + * call also allows any initial data to be returned to the + * @a handler. Upto @a bytes_to_read will be read and stored in the + * @a message_block. The will be used for the + * call. If ( == INVALID_HANDLE), a new + * handle will be created. + * + * @a message_block must be specified. This is because the address of + * the new connection is placed at the end of this buffer. + */ + int accept (ACE_Message_Block &message_block, + size_t bytes_to_read, + ACE_HANDLE accept_handle, + const void *act, + int priority, + int signal_number = 0, + int addr_family = AF_INET); + + /// Destructor. + ~ACE_WIN32_Asynch_Accept (void); + + // Methods belong to ACE_WIN32_Asynch_Operation base class. These + // methods are defined here to avoid VC++ warnings. They route the + // call to the ACE_WIN32_Asynch_Operation base class. + + /** + * Initializes the factory with information which will be used with + * each asynchronous call. If ( == ACE_INVALID_HANDLE), + * will be called on the @a handler to get the + * correct handle. + */ + int open (const ACE_Handler::Proxy_Ptr &handler_proxy, + ACE_HANDLE handle, + const void *completion_key, + ACE_Proactor *proactor); + + /** + * This cancels all pending accepts operations that were issued by + * the calling thread. The function does not cancel asynchronous + * operations issued by other threads. + */ + int cancel (void); + + /// Return the underlying proactor. + ACE_Proactor* proactor (void) const; +}; + +/** + * @class ACE_WIN32_Asynch_Connect_Result + * + * @brief This is that class which will be passed back to the + * completion handler when the asynchronous connect completes. + * + * This class has all the information necessary for the + * completion handler to uniquiely identify the completion of the + * asynchronous connect. + */ +class ACE_Export ACE_WIN32_Asynch_Connect_Result : public virtual ACE_Asynch_Connect_Result_Impl, + public ACE_WIN32_Asynch_Result +{ + /// Factory classes will have special permissions. + friend class ACE_WIN32_Asynch_Connect; + + /// The Proactor constructs the Result class for faking results. + friend class ACE_WIN32_Proactor; + +public: + + /// I/O handle for the connection. + ACE_HANDLE connect_handle (void) const; + + // = Base class operations. These operations are here to kill some + // warnings. These methods call the base class methods. + + /// Number of bytes transferred by the operation. + size_t bytes_transferred (void) const; + + /// ACT associated with the operation. + const void *act (void) const; + + /// Did the operation succeed? + int success (void) const; + + /** + * Returns the ACT associated with the handle when it was + * registered with the I/O completion port. This ACT is not the + * same as the ACT associated with the asynchronous operation. + */ + const void *completion_key (void) const; + + /// Error value if the operation fail. + u_long error (void) const; + + /// Event associated with the OVERLAPPED structure. + ACE_HANDLE event (void) const; + + /// This really make sense only when doing file I/O. + u_long offset (void) const; + + /// Offset_high associated with the OVERLAPPED structure. + u_long offset_high (void) const; + + /// The priority of the asynchronous operation. Currently, this is + /// not supported on Win32. + int priority (void) const; + + /// No-op. Returns 0. + int signal_number (void) const; + + /// Post this object to the Proactor's completion port. + int post_completion (ACE_Proactor_Impl *proactor); + +protected: + /// Constructor is protected since creation is limited to + /// ACE_Asynch_Connect factory. + ACE_WIN32_Asynch_Connect_Result (const ACE_Handler::Proxy_Ptr &handler_proxy, + ACE_HANDLE connect_handle, + const void* act, + ACE_HANDLE event, + int priority, + int signal_number); + + /// ACE_Proactor will call this method when the accept completes. + virtual void complete (size_t bytes_transferred, + int success, + const void *completion_key, + u_long error); + + /// Destructor. + virtual ~ACE_WIN32_Asynch_Connect_Result (void); + + /// Set the I/O handle for the new connection. + void connect_handle (ACE_HANDLE handle); + + ACE_HANDLE connect_handle_; +}; + + +/** + * @class ACE_WIN32_Asynch_Connect + */ +class ACE_Export ACE_WIN32_Asynch_Connect : + public virtual ACE_Asynch_Connect_Impl, + public ACE_WIN32_Asynch_Operation, + public ACE_Event_Handler +{ +public: + + /// Constructor. + ACE_WIN32_Asynch_Connect (ACE_WIN32_Proactor * win32_proactor); + + /// Destructor. + virtual ~ACE_WIN32_Asynch_Connect (void); + + /** + * This open belongs to ACE_WIN32_Asynch_Operation. We forward + * this call to that method. We have put this here to avoid the + * compiler warnings. + */ + int open (const ACE_Handler::Proxy_Ptr &handler_proxy, + ACE_HANDLE handle, + const void *completion_key, + ACE_Proactor *proactor = 0); + + /** + * Start an asynchronous connect. + * + * @param connect_handle Handle to use for the connect. If the value + * ACE_INVALID_HANDLE, a new handle will be created. + * + * @retval 0 Success + * @retval -1 Error + */ + int connect (ACE_HANDLE connect_handle, + const ACE_Addr &remote_sap, + const ACE_Addr &local_sap, + int reuse_addr, + const void *act, + int priority, + int signal_number = 0); + + /** + * Cancel all pending pseudo-asynchronus requests + * Behavior as usual AIO request + */ + int cancel (void); + + /** + * Close performs cancellation of all pending requests + * and close the connect handle + */ + int close (void); + + /// Virtual from ACE_Event_Handler + ACE_HANDLE get_handle (void) const; + + /// Virtual from ACE_Event_Handler + void set_handle (ACE_HANDLE handle); + + /// Virtual from ACE_Event_Handler + int handle_input ( ACE_HANDLE handle); + int handle_output ( ACE_HANDLE handle); + int handle_exception ( ACE_HANDLE handle); + + /// Virtual from ACE_Event_Handler + int handle_close (ACE_HANDLE handle, ACE_Reactor_Mask close_mask) ; + + // = Methods belong to ACE_WIN32_Asynch_Operation base class. These + // methods are defined here to avoid dominace warnings. They route + // the call to the ACE_WIN32_Asynch_Operation base class. + /// Return the underlying proactor. + ACE_Proactor* proactor (void) const; + +private: + int connect_i (ACE_WIN32_Asynch_Connect_Result *result, + const ACE_Addr &remote_sap, + const ACE_Addr &local_sap, + int reuse_addr); + + int post_result (ACE_WIN32_Asynch_Connect_Result *result, bool flg_post); + + /// Cancel uncompleted connect operations. + /** + * @param flg_notify Indicates whether or not to send notification about + * canceled connect operations. If false, don't send + * notifications. If true, notify user about canceled + * connects. + * According WIN32 standards we should receive + * notifications on canceled AIO requests. + * + * @param set Receives the set of I/O handles on which asynchronous + * connect requests were canceled as a result of this + * method. The contents of @a set are completely + * replaced. + */ + int cancel_uncompleted (bool flg_notify, ACE_Handle_Set &set); + + /// true - Connect is registered in ACE_Asynch_Pseudo_Task + /// false - Accept is deregisted in ACE_Asynch_Pseudo_Task + bool flg_open_ ; + + typedef ACE_Map_Manager + MAP_MANAGER; + + /// Map of Result pointers that correspond to all the 's + /// pending. + MAP_MANAGER result_map_; + + /// The lock to protect the result map which is shared. The queue + /// is updated by main thread in the register function call and + /// through the auxillary thread in the asynch pseudo task. + ACE_SYNCH_MUTEX lock_; +}; + +/** + * @class ACE_WIN32_Asynch_Transmit_File_Result + * + * + * @brief This class implements ACE_Asynch_Transmit_File::Result for + * WIN32 platforms. + * + * This class has all the information necessary for the + * @a handler to uniquiely identify the completion of the + * asynchronous transmit file. + */ +class ACE_Export ACE_WIN32_Asynch_Transmit_File_Result : public virtual ACE_Asynch_Transmit_File_Result_Impl, + public ACE_WIN32_Asynch_Result +{ + /// Factory class will have special permission. + friend class ACE_WIN32_Asynch_Transmit_File; + + /// Proactor class has special permission. + friend class ACE_WIN32_Proactor; + +public: + /// Socket used for transmitting the file. + ACE_HANDLE socket (void) const; + + /// File from which the data is read. + ACE_HANDLE file (void) const; + + /// Header and trailer data associated with this transmit file. + ACE_Asynch_Transmit_File::Header_And_Trailer *header_and_trailer (void) const; + + /// The number of bytes which were requested at the start of the + /// asynchronous transmit file. + size_t bytes_to_write (void) const; + + /// Number of bytes per send requested at the start of the transmit + /// file. + size_t bytes_per_send (void) const; + + /// Flags which were passed into transmit file. + u_long flags (void) const; + + // Base class operations. These operations are here to kill some + // warnings. These methods call the base class methods. + + /// Number of bytes transferred by the operation. + size_t bytes_transferred (void) const; + + /// ACT associated with the operation. + const void *act (void) const; + + /// Did the operation succeed? + int success (void) const; + + /** + * This returns the ACT associated with the handle when it was + * registered with the I/O completion port. This ACT is not the + * same as the ACT associated with the asynchronous operation. + */ + const void *completion_key (void) const; + + /// Error value if the operation fail. + u_long error (void) const; + + /// Event associated with the OVERLAPPED structure. + ACE_HANDLE event (void) const; + + /// This really make sense only when doing file I/O. + u_long offset (void) const; + + /// Offset_high associated with the OVERLAPPED structure. + u_long offset_high (void) const; + + /// The priority of the asynchronous operation. Currently, this is + /// not supported on Win32. + int priority (void) const; + + /// No-op. Returns 0. + int signal_number (void) const; + + /// Post @c this to the Proactor's completion port. + int post_completion (ACE_Proactor_Impl *proactor); + +protected: + /// Constructor is protected since creation is limited to + /// ACE_Asynch_Transmit_File factory. + ACE_WIN32_Asynch_Transmit_File_Result (const ACE_Handler::Proxy_Ptr &handler_proxy, + ACE_HANDLE socket, + ACE_HANDLE file, + ACE_Asynch_Transmit_File::Header_And_Trailer *header_and_trailer, + size_t bytes_to_write, + u_long offset, + u_long offset_high, + size_t bytes_per_send, + u_long flags, + const void *act, + ACE_HANDLE event, + int priority, + int signal_number = 0); + + /// Proactor will call this method when the write completes. + virtual void complete (size_t bytes_transferred, + int success, + const void *completion_key, + u_long error); + + /// Destructor. + virtual ~ACE_WIN32_Asynch_Transmit_File_Result (void); + + /// Network I/O handle. + ACE_HANDLE socket_; + + /// File I/O handle. + ACE_HANDLE file_; + + /// Header and trailer data associated with this transmit file. + ACE_Asynch_Transmit_File::Header_And_Trailer *header_and_trailer_; + + /// The number of bytes which were requested at the start of the + /// asynchronous transmit file. + size_t bytes_to_write_; + + /// Number of bytes per send requested at the start of the transmit + /// file. + size_t bytes_per_send_; + + /// Flags which were passed into transmit file. + u_long flags_; +}; + +/** + * @class ACE_WIN32_Asynch_Transmit_File + * + * @brief This class is a factory for starting off asynchronous + * transmit files on a stream. + * + * Once is called, multiple asynchronous s + * can started using this class. A + * ACE_Asynch_Transmit_File::Result will be passed back to the + * @a handler when the asynchronous transmit file completes + * through the callback. + * + * The transmit_file function transmits file data over a + * connected network connection. The function uses the operating + * system's cache manager to retrieve the file data. This + * function provides high-performance file data transfer over + * network connections. This function would be of great use in + * a Web Server, Image Server, etc. + */ +class ACE_Export ACE_WIN32_Asynch_Transmit_File : public virtual ACE_Asynch_Transmit_File_Impl, + public ACE_WIN32_Asynch_Operation +{ +public: + /// Constructor. + ACE_WIN32_Asynch_Transmit_File (ACE_WIN32_Proactor *win32_proactor); + + /** + * This starts off an asynchronous transmit file. The is a + * handle to an open file. is a pointer to a + * data structure that contains pointers to data to send before and + * after the file data is sent. Set this parameter to 0 if you only + * want to transmit the file data. Upto @a bytes_to_write will be + * written to the . If you want to send the entire file, + * let @a bytes_to_write = 0. @a bytes_per_send is the size of each + * block of data sent per send operation. Please read the Win32 + * documentation on what the flags should be. + */ + int transmit_file (ACE_HANDLE file, + ACE_Asynch_Transmit_File::Header_And_Trailer *header_and_trailer, + size_t bytes_to_write, + u_long offset, + u_long offset_high, + size_t bytes_per_send, + u_long flags, + const void *act, + int priority, + int signal_number = 0); + + /// Destructor. + ~ACE_WIN32_Asynch_Transmit_File (void); + + // Methods belong to ACE_WIN32_Asynch_Operation base class. These + // methods are defined here to avoid VC++ warnings. They route the + // call to the ACE_WIN32_Asynch_Operation base class. + + /** + * Initializes the factory with information which will be used with + * each asynchronous call. If ( == ACE_INVALID_HANDLE), + * will be called on the @a handler to get the + * correct handle. + */ + int open (const ACE_Handler::Proxy_Ptr &handler_proxy, + ACE_HANDLE handle, + const void *completion_key, + ACE_Proactor *proactor); + + /** + * This cancels all pending accepts operations that were issued by + * the calling thread. The function does not cancel asynchronous + * operations issued by other threads. + */ + int cancel (void); + + /// Return the underlying proactor. + ACE_Proactor* proactor (void) const; +}; + +/** + * @class ACE_WIN32_Asynch_Read_Dgram_Result + * + * @brief This class provides concrete implementation for + * ACE_Asynch_Read_Dgram::Result class. + */ +class ACE_Export ACE_WIN32_Asynch_Read_Dgram_Result : public virtual ACE_Asynch_Read_Dgram_Result_Impl, + public ACE_WIN32_Asynch_Result +{ + /// Factory class will have special permissions. + friend class ACE_WIN32_Asynch_Read_Dgram; + + /// Proactor class has special permission. + friend class ACE_WIN32_Proactor; + +public: + /// The number of bytes which were requested at the start of the + /// asynchronous read. + size_t bytes_to_read (void) const; + + /// Message block which contains the read data + ACE_Message_Block *message_block (void) const; + + /// The address of where the packet came from + int remote_address (ACE_Addr& addr) const; + + sockaddr *saddr () const; + + /// The flags used in the read + int flags (void) const; + + /// I/O handle used for reading. + ACE_HANDLE handle (void) const; + + // Base class operations. These operations are here to kill + // dominance warnings. These methods call the base class methods. + + /// Number of bytes transferred by the operation. + size_t bytes_transferred (void) const; + + /// ACT associated with the operation. + const void *act (void) const; + + /// Did the operation succeed? + int success (void) const; + + /** + * This returns the ACT associated with the handle when it was + * registered with the I/O completion port. This ACT is not the + * same as the ACT associated with the asynchronous operation. + */ + const void *completion_key (void) const; + + /// Error value if the operation fail. + u_long error (void) const; + + /// Event associated with the OVERLAPPED structure. + ACE_HANDLE event (void) const; + + /// This really make sense only when doing file I/O. + u_long offset (void) const; + + /// Offset_high associated with the OVERLAPPED structure. + u_long offset_high (void) const; + + /// The priority of the asynchronous operation. Currently, this is + /// not supported on Win32. + int priority (void) const; + + /// No-op. Returns 0. + int signal_number (void) const; + + /// Post @c this to the Proactor's completion port. + int post_completion (ACE_Proactor_Impl *proactor); + +protected: + /// Constructor is protected since creation is limited to + /// ACE_Asynch_Read_Dgram factory. + ACE_WIN32_Asynch_Read_Dgram_Result (const ACE_Handler::Proxy_Ptr &handler_proxy, + ACE_HANDLE handle, + ACE_Message_Block *message_block, + size_t bytes_to_read, + int flags, + int protocol_family, + const void* act, + ACE_HANDLE event, + int priority, + int signal_number = 0); + + /// Proactor will call this method when the read completes. + virtual void complete (size_t bytes_transferred, + int success, + const void *completion_key, + u_long error); + + /// Destructor. + virtual ~ACE_WIN32_Asynch_Read_Dgram_Result (void); + + /// Bytes requested when the asynchronous read was initiated. + size_t bytes_to_read_; + + /// Message block for reading the data into. + ACE_Message_Block *message_block_; + + /// The address of where the packet came from + ACE_Addr *remote_address_; + + int addr_len_; + + /// The flags used in the read + int flags_; + + /// I/O handle used for reading. + ACE_HANDLE handle_; +}; + +/** + * @class ACE_WIN32_Asynch_Read_Dgram + * + * @brief This class is a factory for starting off asynchronous reads + * on a UDP socket. + * + * Once is called, multiple asynchronous s can be + * started using this class. An ACE_Asynch_Read_Dgram::Result + * will be passed back to the @a handler when the asynchronous + * reads completes through the + * callback. + * + */ +class ACE_Export ACE_WIN32_Asynch_Read_Dgram : public virtual ACE_Asynch_Read_Dgram_Impl, + public ACE_WIN32_Asynch_Operation +{ +public: + /// Constructor. + ACE_WIN32_Asynch_Read_Dgram (ACE_WIN32_Proactor *win32_proactor); + + /// Destructor. + virtual ~ACE_WIN32_Asynch_Read_Dgram (void); + + /** This starts off an asynchronous read. Upto + * total_size()> will be read and stored in the + * @a message_block. @a message_block's will be updated to reflect + * the added bytes if the read operation is successfully completed. + * Return code of 1 means immediate success and + * will contain number of bytes read. The + * method will still be called. Return code of 0 means the IO will + * complete proactively. Return code of -1 means there was an error, use + * errno to get the error code. + * + * Scatter/gather is supported on WIN32 by using the cont()> + * method. Up to ACE_IOV_MAX @a message_block's are supported. Upto + * size()> bytes will be read into each for + * a total of total_size()> bytes. All @a message_block's + * 's will be updated to reflect the added bytes for each + * @a message_block + */ + virtual ssize_t recv (ACE_Message_Block *message_block, + size_t &number_of_bytes_recvd, + int flags, + int protocol_family, + const void *act, + int priority, + int signal_number); + + // Methods belong to ACE_WIN32_Asynch_Operation base class. These + // methods are defined here to avoid VC++ warnings. They route the + // call to the ACE_WIN32_Asynch_Operation base class. + + /** + * Initializes the factory with information which will be used with + * each asynchronous call. If ( == ACE_INVALID_HANDLE), + * will be called on the @a handler to get the + * correct handle. + */ + int open (const ACE_Handler::Proxy_Ptr &handler_proxy, + ACE_HANDLE handle, + const void *completion_key, + ACE_Proactor *proactor); + + /** + * This cancels all pending accepts operations that were issued by + * the calling thread. The function does not cancel asynchronous + * operations issued by other threads. + */ + int cancel (void); + + /// Return the underlying proactor. + ACE_Proactor* proactor (void) const; + +protected: + /// Do-nothing constructor. + ACE_WIN32_Asynch_Read_Dgram (void); +}; + +/** + * @class ACE_WIN32_Asynch_Write_Dgram_Result + * + * @brief This class provides concrete implementation for + * ACE_Asynch_Write_Dgram::Result class. + */ +class ACE_Export ACE_WIN32_Asynch_Write_Dgram_Result : public virtual ACE_Asynch_Write_Dgram_Result_Impl, + public ACE_WIN32_Asynch_Result +{ + /// Factory class willl have special permissions. + friend class ACE_WIN32_Asynch_Write_Dgram; + + /// Proactor class has special permission. + friend class ACE_WIN32_Proactor; + +public: + /// The number of bytes which were requested at the start of the + /// asynchronous write. + size_t bytes_to_write (void) const; + + /// Message block which contains the sent data + ACE_Message_Block *message_block (void) const; + + /// The flags using in the write + int flags (void) const; + + /// I/O handle used for writing. + ACE_HANDLE handle (void) const; + + // = Base class operations. These operations are here to kill some + // warnings. These methods call the base class methods. + + /// Number of bytes transferred by the operation. + size_t bytes_transferred (void) const; + + /// ACT associated with the operation. + const void *act (void) const; + + /// Did the operation succeed? + int success (void) const; + + /** + * This returns the ACT associated with the handle when it was + * registered with the I/O completion port. This ACT is not the + * same as the ACT associated with the asynchronous operation. + */ + const void *completion_key (void) const; + + /// Error value if the operation fail. + u_long error (void) const; + + /// Event associated with the OVERLAPPED structure. + ACE_HANDLE event (void) const; + + /// This really make sense only when doing file I/O. + u_long offset (void) const; + + /// Offset_high associated with the OVERLAPPED structure. + u_long offset_high (void) const; + + /// The priority of the asynchronous operation. Currently, this is + /// not supported on Win32. + int priority (void) const; + + /// No-op. Returns 0. + int signal_number (void) const; + + /// Post @c this to the Proactor's completion port. + int post_completion (ACE_Proactor_Impl *proactor); + +protected: + /// Constructor is protected since creation is limited to + /// ACE_Asynch_Write_Stream factory. + ACE_WIN32_Asynch_Write_Dgram_Result (const ACE_Handler::Proxy_Ptr &handler_proxy, + ACE_HANDLE handle, + ACE_Message_Block *message_block, + size_t bytes_to_write, + int flags, + const void* act, + ACE_HANDLE event, + int priority, + int signal_number = 0); + + /// ACE_Proactor will call this method when the write completes. + virtual void complete (size_t bytes_transferred, + int success, + const void *completion_key, + u_long error); + + /// Destructor. + virtual ~ACE_WIN32_Asynch_Write_Dgram_Result (void); + + /// The number of bytes which were requested at the start of the + /// asynchronous write. + size_t bytes_to_write_; + + /// Message block used for the send. + ACE_Message_Block *message_block_; + + /// The flags using in the write + int flags_; + + /// I/O handle used for writing. + ACE_HANDLE handle_; +}; + +/** + * @class ACE_WIN32_Asynch_Write_Dgram + * + * @brief This class is a factory for starting off asynchronous writes + * on a UDP socket. + * + * + * Once is called, multiple asynchronous s can + * started using this class. A ACE_Asynch_Write_Stream::Result + * will be passed back to the @a handler when the asynchronous + * write completes through the + * callback. + */ +class ACE_Export ACE_WIN32_Asynch_Write_Dgram : public virtual ACE_Asynch_Write_Dgram_Impl, + public ACE_WIN32_Asynch_Operation +{ +public: + /// Constructor. + ACE_WIN32_Asynch_Write_Dgram (ACE_WIN32_Proactor *win32_proactor); + + /// Destructor. + virtual ~ACE_WIN32_Asynch_Write_Dgram (void); + + /** This starts off an asynchronous send. Upto + * total_length()> will be sent. @a message_block's + * will be updated to reflect the sent bytes if the send operation + * is successfully completed. + * Return code of 1 means immediate success and + * is updated to number of bytes sent. The + * method will still be called. Return code of 0 means the IO will + * complete proactively. Return code of -1 means there was an error, use + * errno to get the error code. + * + * Scatter/gather is supported on WIN32 by using the cont()> + * method. Up to ACE_IOV_MAX @a message_block's are supported. Upto + * length()> bytes will be sent from each + * for a total of total_length()> bytes. All + * @a message_block's 's will be updated to reflect the bytes sent + * from each @a message_block. + */ + virtual ssize_t send (ACE_Message_Block *message_block, + size_t &number_of_bytes_sent, + int flags, + const ACE_Addr &addr, + const void *act, + int priority, + int signal_number); + + // = Methods belonging to base class. + + // These methods are defined here to avoid VC++ warnings. They route + // the call to the base class. + + /** + * Initializes the factory with information which will be used with + * each asynchronous call. If ( == ACE_INVALID_HANDLE), + * will be called on the @a handler to get the + * correct handle. + */ + int open (const ACE_Handler::Proxy_Ptr &handler_proxy, + ACE_HANDLE handle, + const void *completion_key, + ACE_Proactor *proactor); + + /** + * This cancels all pending accepts operations that were issued by + * the calling thread. The function does not cancel asynchronous + * operations issued by other threads. + */ + int cancel (void); + + /// Return the underlying proactor. + ACE_Proactor* proactor (void) const; + +protected: + /// Do-nothing constructor. + ACE_WIN32_Asynch_Write_Dgram (void); +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#endif /* ACE_HAS_WIN32_OVERLAPPED_IO && ACE_HAS_WINSOCK2 */ +#include /**/ "ace/post.h" +#endif /* ACE_WIN32_ASYNCH_IO_H */ diff --git a/dep/ACE_wrappers/ace/WIN32_Proactor.cpp b/dep/ACE_wrappers/ace/WIN32_Proactor.cpp new file mode 100644 index 00000000000..a559838976f --- /dev/null +++ b/dep/ACE_wrappers/ace/WIN32_Proactor.cpp @@ -0,0 +1,804 @@ +// $Id: WIN32_Proactor.cpp 80826 2008-03-04 14:51:23Z wotte $ + +// ACE_RCSID(ace, Proactor, "$Id: WIN32_Proactor.cpp 80826 2008-03-04 14:51:23Z wotte $") + +#include "ace/WIN32_Proactor.h" + +#if defined (ACE_WIN32) && defined (ACE_HAS_WIN32_OVERLAPPED_IO) +// WIN implemenatation of the Proactor. + +#include "ace/Log_Msg.h" +#include "ace/Object_Manager.h" +#include "ace/OS_NS_errno.h" +#include "ace/OS_NS_unistd.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +/** + * @class ACE_WIN32_Wakeup_Completion + * + * This is result object is used by the of the + * ACE_Proactor interface to wake up all the threads blocking + * for completions. + */ +class ACE_WIN32_Wakeup_Completion : public ACE_WIN32_Asynch_Result +{ + +public: + /// Constructor. + ACE_WIN32_Wakeup_Completion (ACE_Handler::Proxy_Ptr &handler_proxy, + const void *act = 0, + ACE_HANDLE event = ACE_INVALID_HANDLE, + int priority = 0, + int signal_number = ACE_SIGRTMIN); + + /// Destructor. + virtual ~ACE_WIN32_Wakeup_Completion (void); + + /// This method calls the 's method. + virtual void complete (size_t bytes_transferred = 0, + int success = 1, + const void *completion_key = 0, + u_long error = 0); +}; + +ACE_WIN32_Proactor::ACE_WIN32_Proactor (size_t number_of_threads, + bool used_with_reactor_event_loop) + : completion_port_ (0), + // This *MUST* be 0, *NOT* ACE_INVALID_HANDLE !!! + number_of_threads_ (static_cast (number_of_threads)), + used_with_reactor_event_loop_ (used_with_reactor_event_loop) +{ + // Create the completion port. + this->completion_port_ = ::CreateIoCompletionPort (INVALID_HANDLE_VALUE, + 0, + 0, + this->number_of_threads_); + if (this->completion_port_ == 0) + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("%p\n"), + ACE_TEXT ("CreateIoCompletionPort"))); + + this->get_asynch_pseudo_task ().start (); +} + +ACE_WIN32_Proactor::~ACE_WIN32_Proactor (void) +{ + this->get_asynch_pseudo_task ().stop (); + + this->close (); +} + +ACE_Asynch_Pseudo_Task & +ACE_WIN32_Proactor::get_asynch_pseudo_task () +{ + return this->pseudo_task_; +} + +int +ACE_WIN32_Proactor::close (void) +{ + // Close the completion port + if (this->completion_port_ != 0) + { + // To avoid memory leaks we should delete all results from queue. + + for (;;) + { + ACE_OVERLAPPED *overlapped = 0; + u_long bytes_transferred = 0; + ULONG_PTR completion_key = 0; + + // Get the next asynchronous operation that completes + BOOL res = ::GetQueuedCompletionStatus + (this->completion_port_, + &bytes_transferred, + &completion_key, + &overlapped, + 0); // poll + + if (overlapped == 0 || res == FALSE) + break; + + ACE_WIN32_Asynch_Result *asynch_result = + (ACE_WIN32_Asynch_Result *) overlapped; + + delete asynch_result; + } + + int result = ACE_OS::close (this->completion_port_); + this->completion_port_ = 0; + return result; + } + + return 0; +} + +int +ACE_WIN32_Proactor::register_handle (ACE_HANDLE handle, + const void *completion_key) +{ + ULONG_PTR comp_key (reinterpret_cast (completion_key)); + + // No locking is needed here as no state changes. + ACE_HANDLE cp = ::CreateIoCompletionPort (handle, + this->completion_port_, + comp_key, + this->number_of_threads_); + if (cp == 0) + { + ACE_OS::set_errno_to_last_error (); + // If errno == ERROR_INVALID_PARAMETER, then this handle was + // already registered. + if (errno != ERROR_INVALID_PARAMETER) + { + if (ACE::debug ()) + { + ACE_DEBUG ((LM_ERROR, + ACE_TEXT ("%p\n"), + ACE_TEXT ("CreateIoCompletionPort"))); + } + return -1; + } + } + return 0; +} + +ACE_Asynch_Read_Stream_Impl * +ACE_WIN32_Proactor::create_asynch_read_stream (void) +{ + ACE_Asynch_Read_Stream_Impl *implementation = 0; + ACE_NEW_RETURN (implementation, + ACE_WIN32_Asynch_Read_Stream (this), + 0); + return implementation; +} + +ACE_Asynch_Write_Stream_Impl * +ACE_WIN32_Proactor::create_asynch_write_stream (void) +{ + ACE_Asynch_Write_Stream_Impl *implementation = 0; + ACE_NEW_RETURN (implementation, + ACE_WIN32_Asynch_Write_Stream (this), + 0); + return implementation; +} + +ACE_Asynch_Read_Dgram_Impl * +ACE_WIN32_Proactor::create_asynch_read_dgram (void) +{ + ACE_Asynch_Read_Dgram_Impl *implementation = 0; + ACE_NEW_RETURN (implementation, + ACE_WIN32_Asynch_Read_Dgram (this), + 0); + return implementation; +} + +ACE_Asynch_Write_Dgram_Impl * +ACE_WIN32_Proactor::create_asynch_write_dgram (void) +{ + ACE_Asynch_Write_Dgram_Impl *implementation = 0; + ACE_NEW_RETURN (implementation, + ACE_WIN32_Asynch_Write_Dgram (this), + 0); + return implementation; +} + +ACE_Asynch_Read_File_Impl * +ACE_WIN32_Proactor::create_asynch_read_file (void) +{ + ACE_Asynch_Read_File_Impl *implementation = 0; + ACE_NEW_RETURN (implementation, + ACE_WIN32_Asynch_Read_File (this), + 0); + return implementation; +} + +ACE_Asynch_Write_File_Impl * +ACE_WIN32_Proactor::create_asynch_write_file (void) +{ + ACE_Asynch_Write_File_Impl *implementation = 0; + ACE_NEW_RETURN (implementation, + ACE_WIN32_Asynch_Write_File (this), + 0); + return implementation; +} + +ACE_Asynch_Accept_Impl * +ACE_WIN32_Proactor::create_asynch_accept (void) +{ + ACE_Asynch_Accept_Impl *implementation = 0; + ACE_NEW_RETURN (implementation, + ACE_WIN32_Asynch_Accept (this), + 0); + return implementation; +} + +ACE_Asynch_Connect_Impl * +ACE_WIN32_Proactor::create_asynch_connect (void) +{ + ACE_Asynch_Connect_Impl *implementation = 0; + ACE_NEW_RETURN (implementation, + ACE_WIN32_Asynch_Connect (this), + 0); + return implementation; +} + +ACE_Asynch_Transmit_File_Impl * +ACE_WIN32_Proactor::create_asynch_transmit_file (void) +{ + ACE_Asynch_Transmit_File_Impl *implementation = 0; + ACE_NEW_RETURN (implementation, + ACE_WIN32_Asynch_Transmit_File (this), + 0); + return implementation; +} + +ACE_Asynch_Read_Stream_Result_Impl * +ACE_WIN32_Proactor::create_asynch_read_stream_result + (const ACE_Handler::Proxy_Ptr &handler_proxy, + ACE_HANDLE handle, + ACE_Message_Block &message_block, + size_t bytes_to_read, + const void* act, + ACE_HANDLE event, + int priority, + int signal_number) +{ + ACE_Asynch_Read_Stream_Result_Impl *implementation = 0; + ACE_NEW_RETURN (implementation, + ACE_WIN32_Asynch_Read_Stream_Result (handler_proxy, + handle, + message_block, + bytes_to_read, + act, + event, + priority, + signal_number), + 0); + return implementation; +} + +ACE_Asynch_Write_Stream_Result_Impl * +ACE_WIN32_Proactor::create_asynch_write_stream_result + (const ACE_Handler::Proxy_Ptr &handler_proxy, + ACE_HANDLE handle, + ACE_Message_Block &message_block, + size_t bytes_to_write, + const void* act, + ACE_HANDLE event, + int priority, + int signal_number) +{ + ACE_Asynch_Write_Stream_Result_Impl *implementation = 0; + ACE_NEW_RETURN (implementation, + ACE_WIN32_Asynch_Write_Stream_Result (handler_proxy, + handle, + message_block, + bytes_to_write, + act, + event, + priority, + signal_number), + 0); + return implementation; +} + +ACE_Asynch_Read_File_Result_Impl * +ACE_WIN32_Proactor::create_asynch_read_file_result + (const ACE_Handler::Proxy_Ptr &handler_proxy, + ACE_HANDLE handle, + ACE_Message_Block &message_block, + size_t bytes_to_read, + const void* act, + u_long offset, + u_long offset_high, + ACE_HANDLE event, + int priority, + int signal_number) +{ + ACE_Asynch_Read_File_Result_Impl *implementation = 0; + ACE_NEW_RETURN (implementation, + ACE_WIN32_Asynch_Read_File_Result (handler_proxy, + handle, + message_block, + bytes_to_read, + act, + offset, + offset_high, + event, + priority, + signal_number), + 0); + return implementation; +} + +ACE_Asynch_Write_File_Result_Impl * +ACE_WIN32_Proactor::create_asynch_write_file_result + (const ACE_Handler::Proxy_Ptr &handler_proxy, + ACE_HANDLE handle, + ACE_Message_Block &message_block, + size_t bytes_to_write, + const void* act, + u_long offset, + u_long offset_high, + ACE_HANDLE event, + int priority, + int signal_number) +{ + ACE_Asynch_Write_File_Result_Impl *implementation = 0; + ACE_NEW_RETURN (implementation, + ACE_WIN32_Asynch_Write_File_Result (handler_proxy, + handle, + message_block, + bytes_to_write, + act, + offset, + offset_high, + event, + priority, + signal_number), + 0); + return implementation; +} + +ACE_Asynch_Read_Dgram_Result_Impl * +ACE_WIN32_Proactor::create_asynch_read_dgram_result + (const ACE_Handler::Proxy_Ptr &handler_proxy, + ACE_HANDLE handle, + ACE_Message_Block *message_block, + size_t bytes_to_read, + int flags, + int protocol_family, + const void* act, + ACE_HANDLE event, + int priority, + int signal_number) +{ + ACE_Asynch_Read_Dgram_Result_Impl *implementation = 0; + ACE_NEW_RETURN (implementation, + ACE_WIN32_Asynch_Read_Dgram_Result (handler_proxy, + handle, + message_block, + bytes_to_read, + flags, + protocol_family, + act, + event, + priority, + signal_number), + 0); + return implementation; +} + +ACE_Asynch_Write_Dgram_Result_Impl * +ACE_WIN32_Proactor::create_asynch_write_dgram_result + (const ACE_Handler::Proxy_Ptr &handler_proxy, + ACE_HANDLE handle, + ACE_Message_Block *message_block, + size_t bytes_to_read, + int flags, + const void* act, + ACE_HANDLE event, + int priority, + int signal_number) +{ + ACE_Asynch_Write_Dgram_Result_Impl *implementation = 0; + ACE_NEW_RETURN (implementation, + ACE_WIN32_Asynch_Write_Dgram_Result(handler_proxy, + handle, + message_block, + bytes_to_read, + flags, + act, + event, + priority, + signal_number), + 0); + return implementation; +} + +ACE_Asynch_Accept_Result_Impl * +ACE_WIN32_Proactor::create_asynch_accept_result + (const ACE_Handler::Proxy_Ptr &handler_proxy, + ACE_HANDLE listen_handle, + ACE_HANDLE accept_handle, + ACE_Message_Block &message_block, + size_t bytes_to_read, + const void* act, + ACE_HANDLE event, + int priority, + int signal_number) +{ + ACE_Asynch_Accept_Result_Impl *implementation = 0; + ACE_NEW_RETURN (implementation, + ACE_WIN32_Asynch_Accept_Result (handler_proxy, + listen_handle, + accept_handle, + message_block, + bytes_to_read, + act, + event, + priority, + signal_number), + 0); + return implementation; +} + +ACE_Asynch_Connect_Result_Impl * +ACE_WIN32_Proactor::create_asynch_connect_result + (const ACE_Handler::Proxy_Ptr &handler_proxy, + ACE_HANDLE connect_handle, + const void *act, + ACE_HANDLE event, + int priority, + int signal_number) +{ + ACE_Asynch_Connect_Result_Impl *implementation = 0; + ACE_NEW_RETURN (implementation, + ACE_WIN32_Asynch_Connect_Result (handler_proxy, + connect_handle, + act, + event, + priority, + signal_number), + 0); + return implementation; +} + +ACE_Asynch_Transmit_File_Result_Impl * +ACE_WIN32_Proactor::create_asynch_transmit_file_result + (const ACE_Handler::Proxy_Ptr &handler_proxy, + ACE_HANDLE socket, + ACE_HANDLE file, + ACE_Asynch_Transmit_File::Header_And_Trailer *header_and_trailer, + size_t bytes_to_write, + u_long offset, + u_long offset_high, + size_t bytes_per_send, + u_long flags, + const void *act, + ACE_HANDLE event, + int priority, + int signal_number) +{ + ACE_Asynch_Transmit_File_Result_Impl *implementation = 0; + ACE_NEW_RETURN (implementation, + ACE_WIN32_Asynch_Transmit_File_Result (handler_proxy, + socket, + file, + header_and_trailer, + bytes_to_write, + offset, + offset_high, + bytes_per_send, + flags, + act, + event, + priority, + signal_number), + 0); + return implementation; +} + +ACE_Asynch_Result_Impl * +ACE_WIN32_Proactor::create_asynch_timer (const ACE_Handler::Proxy_Ptr &handler_proxy, + const void *act, + const ACE_Time_Value &tv, + ACE_HANDLE event, + int priority, + int signal_number) +{ + ACE_Asynch_Result_Impl *implementation = 0; + ACE_NEW_RETURN (implementation, + ACE_WIN32_Asynch_Timer (handler_proxy, + act, + tv, + event, + priority, + signal_number), + 0); + return implementation; +} + +int +ACE_WIN32_Proactor::handle_signal (int, siginfo_t *, ucontext_t *) +{ + // Perform a non-blocking "poll" for all the I/O events that have + // completed in the I/O completion queue. + + int result = 0; + + for (ACE_Time_Value timeout (0, 0); + ; + ) + { + result = this->handle_events (timeout); + + if (result != 1) + break; + } + + // If our handle_events failed, we'll report a failure to the + // Reactor. + return result == -1 ? -1 : 0; +} + +int +ACE_WIN32_Proactor::handle_close (ACE_HANDLE handle, + ACE_Reactor_Mask close_mask) +{ + ACE_UNUSED_ARG (close_mask); + ACE_UNUSED_ARG (handle); + + return this->close (); +} + +ACE_HANDLE +ACE_WIN32_Proactor::get_handle (void) const +{ + if (this->used_with_reactor_event_loop_) + return this->event_.handle (); + else + return 0; +} + +int +ACE_WIN32_Proactor::handle_events (ACE_Time_Value &wait_time) +{ + // Decrement with the amount of time spent in the method + ACE_Countdown_Time countdown (&wait_time); + return this->handle_events (wait_time.msec ()); +} + +int +ACE_WIN32_Proactor::handle_events (void) +{ + return this->handle_events (ACE_INFINITE); +} + +int +ACE_WIN32_Proactor::handle_events (unsigned long milli_seconds) +{ + ACE_OVERLAPPED *overlapped = 0; + u_long bytes_transferred = 0; + ULONG_PTR completion_key = 0; + + // Get the next asynchronous operation that completes + BOOL result = ::GetQueuedCompletionStatus (this->completion_port_, + &bytes_transferred, + &completion_key, + &overlapped, + milli_seconds); + if (result == FALSE && overlapped == 0) + { + ACE_OS::set_errno_to_last_error (); + + switch (errno) + { + case WAIT_TIMEOUT: + errno = ETIME; + return 0; + + case ERROR_SUCCESS: + // Calling GetQueuedCompletionStatus with timeout value 0 + // returns FALSE with extended errno "ERROR_SUCCESS" errno = + // ETIME; ?? I don't know if this has to be done !! + return 0; + + default: + if (ACE::debug ()) + ACE_DEBUG ((LM_ERROR, + ACE_TEXT ("%p\n"), + ACE_TEXT ("GetQueuedCompletionStatus"))); + return -1; + } + } + else if (overlapped != 0) + { + // Narrow the result. + ACE_WIN32_Asynch_Result *asynch_result = (ACE_WIN32_Asynch_Result *) overlapped; + + // If errors happen, grab the error. + if (result == FALSE) + ACE_OS::set_errno_to_last_error (); + else + errno = 0; + + u_long result_err = asynch_result->error (); + + // if "result_err" is 0 than + // It is normal OS/WIN32 AIO completion. + // We have cleared asynch_result->error_ + // during shared_read/shared_write. + // The real error code is already stored in "errno", + // so copy "errno" value to the "result_err" + // and pass this "result_err" code + // to the application_specific_code () + // else + // "result_err" non zero + // it means we have "post_completed" result + // so pass this "result_err" code + // to the application_specific_code () + + if (result_err == 0) + result_err = errno ; + + this->application_specific_code (asynch_result, + static_cast (bytes_transferred), + (void *) completion_key, + result_err); + } + return 1; +} + +void +ACE_WIN32_Proactor::application_specific_code (ACE_WIN32_Asynch_Result *asynch_result, + size_t bytes_transferred, + const void *completion_key, + u_long error) +{ + ACE_SEH_TRY + { + // Call completion hook + asynch_result->complete (bytes_transferred, + error ? 0 : 1, + (void *) completion_key, + error); + } + ACE_SEH_FINALLY + { + // This is crucial to prevent memory leaks + delete asynch_result; + } +} + +int +ACE_WIN32_Proactor::post_completion (ACE_WIN32_Asynch_Result *result) +{ + // Grab the event associated with the Proactor + HANDLE handle = this->get_handle (); + + // pass + // bytes_transferred + // completion_key + // to the ::PostQueuedCompletionStatus() + // error will be extracted later in handle_events() + + DWORD bytes_transferred = 0; + const void * completion_key = 0 ; + + if (result != 0) + { + // This cast is ok since the original API calls restricted the transfer + // counts to DWORD range. + bytes_transferred = static_cast (result->bytes_transferred ()); + completion_key = result->completion_key(); + } + + ULONG_PTR comp_key (reinterpret_cast (completion_key)); + + // Post a completion + if (::PostQueuedCompletionStatus (this->completion_port_, // completion port + bytes_transferred, // xfer count + comp_key, // completion key + result // overlapped + ) == FALSE) + { + delete result; + + if (ACE::debug ()) + { + ACE_DEBUG ((LM_ERROR, + ACE_TEXT ("%p\n"), + ACE_TEXT ("PostQueuedCompletionStatus failed"))); + } + return -1; + } + + // If Proactor event is valid, signal it + if (handle != ACE_INVALID_HANDLE + && handle != 0) + ACE_OS::event_signal (&handle); + + return 0; +} + +int +ACE_WIN32_Proactor::post_wakeup_completions (int how_many) +{ + ACE_WIN32_Wakeup_Completion *wakeup_completion = 0; + + for (ssize_t ci = 0; ci < how_many; ci++) + { + ACE_NEW_RETURN + (wakeup_completion, + ACE_WIN32_Wakeup_Completion (this->wakeup_handler_.proxy ()), + -1); + + if (wakeup_completion->post_completion (this) == -1) + return -1; + } + + return 0; +} + +int +ACE_WIN32_Proactor::wake_up_dispatch_threads (void) +{ + return 0; +} + +int +ACE_WIN32_Proactor::close_dispatch_threads (int) +{ + return 0; +} + +size_t +ACE_WIN32_Proactor::number_of_threads (void) const +{ + return static_cast (this->number_of_threads_); +} + +void +ACE_WIN32_Proactor::number_of_threads (size_t threads) +{ + this->number_of_threads_ = static_cast (threads); +} + +ACE_WIN32_Asynch_Timer::ACE_WIN32_Asynch_Timer + (const ACE_Handler::Proxy_Ptr &handler_proxy, + const void *act, + const ACE_Time_Value &tv, + ACE_HANDLE event, + int priority, + int signal_number) + : ACE_Asynch_Result_Impl (), + ACE_WIN32_Asynch_Result (handler_proxy, act, event, 0, 0, priority, + signal_number), + time_ (tv) +{ +} + +void +ACE_WIN32_Asynch_Timer::complete (size_t, + int, + const void *, + u_long) +{ + ACE_Handler *handler = this->handler_proxy_.get ()->handler (); + if (handler != 0) + handler->handle_time_out (this->time_, this->act ()); +} + +ACE_WIN32_Wakeup_Completion::ACE_WIN32_Wakeup_Completion + (ACE_Handler::Proxy_Ptr &handler_proxy, + const void *act, + ACE_HANDLE event, + int priority, + int signal_number) + : ACE_Asynch_Result_Impl (), + ACE_WIN32_Asynch_Result + (handler_proxy, act, event, 0, 0, priority, signal_number) +{ +} + +ACE_WIN32_Wakeup_Completion::~ACE_WIN32_Wakeup_Completion (void) +{ +} + +void +ACE_WIN32_Wakeup_Completion::complete (size_t /* bytes_transferred */, + int /* success */, + const void * /* completion_key */, + u_long /* error */) +{ + ACE_Handler *handler = this->handler_proxy_.get ()->handler (); + if (handler != 0) + handler->handle_wakeup (); +} + +ACE_END_VERSIONED_NAMESPACE_DECL + +#endif /* ACE_WIN32 */ diff --git a/dep/ACE_wrappers/ace/WIN32_Proactor.h b/dep/ACE_wrappers/ace/WIN32_Proactor.h new file mode 100644 index 00000000000..4fb686d7a7e --- /dev/null +++ b/dep/ACE_wrappers/ace/WIN32_Proactor.h @@ -0,0 +1,325 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file WIN32_Proactor.h + * + * $Id: WIN32_Proactor.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Irfan Pyarali (irfan@cs.wustl.edu) + * @author Tim Harrison (harrison@cs.wustl.edu) + * @author Alexander Babu Arulanthu + * @author Roger Tragin + * @author Alexander Libman + */ +//============================================================================= + +#ifndef ACE_WIN32_PROACTOR_H +#define ACE_WIN32_PROACTOR_H +#include /**/ "ace/pre.h" + +#include /**/ "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +#pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#if defined (ACE_WIN32) && defined (ACE_HAS_WIN32_OVERLAPPED_IO) +// WIN32 implementation of the Proactor. + +#include "ace/WIN32_Asynch_IO.h" +#include "ace/Event_Handler.h" + +#include "ace/Proactor_Impl.h" +#include "ace/Asynch_Pseudo_Task.h" +#include "ace/Auto_Event.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +// Forward declarations. +class ACE_WIN32_Asynch_Result; +class ACE_WIN32_Proactor_Timer_Handler; + +/** + * @class ACE_WIN32_Proactor + * + * @brief A manager for asynchronous event demultiplexing on Win32. + * + * See the Proactor pattern description at + * http://www.cs.wustl.edu/~schmidt/PDF/proactor.pdf for more + * details. + */ +class ACE_Export ACE_WIN32_Proactor : public ACE_Proactor_Impl +{ + friend class ACE_WIN32_Asynch_Connect; + +public: + /// A do nothing constructor. + ACE_WIN32_Proactor (size_t number_of_threads = 0, + bool used_with_reactor_event_loop = false); + + /// Virtual destruction. + virtual ~ACE_WIN32_Proactor (void); + + /// Close the IO completion port. + virtual int close (void); + + /// This method adds the @a handle to the I/O completion port. This + /// function is a no-op function for Unix systems. + virtual int register_handle (ACE_HANDLE handle, + const void *completion_key); + + /** + * Dispatch a single set of events. If @a wait_time elapses before + * any events occur, return 0. Return 1 on success i.e., when a + * completion is dispatched, non-zero (-1) on errors and errno is + * set accordingly. + */ + virtual int handle_events (ACE_Time_Value &wait_time); + + /** + * Block indefinitely until at least one event is dispatched. + * Dispatch a single set of events. Return 1 on success i.e., when a + * completion is dispatched, non-zero (-1) on errors and errno is + * set accordingly. + */ + virtual int handle_events (void); + + /** + * Post a result to the completion port of the Proactor. If errors + * occur, the result will be deleted by this method. If successful, + * the result will be deleted by the Proactor when the result is + * removed from the completion port. Therefore, the result should + * have been dynamically allocated and should be orphaned by the + * user once this method is called. + */ + virtual int post_completion (ACE_WIN32_Asynch_Result *result); + + /// Add wakeup dispatch threads (reinit). + int wake_up_dispatch_threads (void); + + /// Close all dispatch threads. + int close_dispatch_threads (int wait); + + /// Get number of thread used as a parameter to @c CreateIoCompletionPort. + size_t number_of_threads (void) const; + + /// Set number of thread used as a parameter to @c CreateIoCompletionPort. + void number_of_threads (size_t threads); + + /// Get the event handle. + virtual ACE_HANDLE get_handle (void) const; + + virtual ACE_Asynch_Read_Stream_Impl *create_asynch_read_stream (void); + virtual ACE_Asynch_Write_Stream_Impl *create_asynch_write_stream (void); + virtual ACE_Asynch_Read_File_Impl *create_asynch_read_file (void); + virtual ACE_Asynch_Write_File_Impl *create_asynch_write_file (void); + virtual ACE_Asynch_Read_Dgram_Impl *create_asynch_read_dgram (void); + virtual ACE_Asynch_Write_Dgram_Impl *create_asynch_write_dgram (void); + virtual ACE_Asynch_Accept_Impl *create_asynch_accept (void); + virtual ACE_Asynch_Connect_Impl *create_asynch_connect (void); + virtual ACE_Asynch_Transmit_File_Impl *create_asynch_transmit_file (void); + + // Methods used to create Asynch_IO_Result objects. We create the right + // objects here in these methods. + + virtual ACE_Asynch_Read_Stream_Result_Impl *create_asynch_read_stream_result (const ACE_Handler::Proxy_Ptr &handler_proxy, + ACE_HANDLE handle, + ACE_Message_Block &message_block, + size_t bytes_to_read, + const void* act, + ACE_HANDLE event, + int priority, + int signal_number = 0); + + virtual ACE_Asynch_Write_Stream_Result_Impl *create_asynch_write_stream_result (const ACE_Handler::Proxy_Ptr &handler_proxy, + ACE_HANDLE handle, + ACE_Message_Block &message_block, + size_t bytes_to_write, + const void* act, + ACE_HANDLE event, + int priority, + int signal_number = 0); + + virtual ACE_Asynch_Read_File_Result_Impl *create_asynch_read_file_result (const ACE_Handler::Proxy_Ptr &handler_proxy, + ACE_HANDLE handle, + ACE_Message_Block &message_block, + size_t bytes_to_read, + const void* act, + u_long offset, + u_long offset_high, + ACE_HANDLE event, + int priority, + int signal_number = 0); + + virtual ACE_Asynch_Write_File_Result_Impl *create_asynch_write_file_result (const ACE_Handler::Proxy_Ptr &handler_proxy, + ACE_HANDLE handle, + ACE_Message_Block &message_block, + size_t bytes_to_write, + const void* act, + u_long offset, + u_long offset_high, + ACE_HANDLE event, + int priority, + int signal_number = 0); + + /// Create the correct implementation class for ACE_Asynch_Read_Dgram::Result. + virtual ACE_Asynch_Read_Dgram_Result_Impl *create_asynch_read_dgram_result (const ACE_Handler::Proxy_Ptr &handler_proxy, + ACE_HANDLE handle, + ACE_Message_Block *message_block, + size_t bytes_to_read, + int flags, + int protocol_family, + const void* act, + ACE_HANDLE event, + int priority, + int signal_number = 0); + + /// Create the correct implementation class for ACE_Asynch_Write_Dgram::Result. + virtual ACE_Asynch_Write_Dgram_Result_Impl *create_asynch_write_dgram_result (const ACE_Handler::Proxy_Ptr &handler_proxy, + ACE_HANDLE handle, + ACE_Message_Block *message_block, + size_t bytes_to_write, + int flags, + const void* act, + ACE_HANDLE event, + int priority, + int signal_number = 0); + + virtual ACE_Asynch_Accept_Result_Impl *create_asynch_accept_result (const ACE_Handler::Proxy_Ptr &handler_proxy, + ACE_HANDLE listen_handle, + ACE_HANDLE accept_handle, + ACE_Message_Block &message_block, + size_t bytes_to_read, + const void* act, + ACE_HANDLE event, + int priority, + int signal_number = 0); + + virtual ACE_Asynch_Connect_Result_Impl *create_asynch_connect_result (const ACE_Handler::Proxy_Ptr &handler_proxy, + ACE_HANDLE connect_handle, + const void *act, + ACE_HANDLE event, + int priority, + int signal_number = 0); + + + virtual ACE_Asynch_Transmit_File_Result_Impl *create_asynch_transmit_file_result (const ACE_Handler::Proxy_Ptr &handler_proxy, + ACE_HANDLE socket, + ACE_HANDLE file, + ACE_Asynch_Transmit_File::Header_And_Trailer *header_and_trailer, + size_t bytes_to_write, + u_long offset, + u_long offset_high, + size_t bytes_per_send, + u_long flags, + const void *act, + ACE_HANDLE event, + int priority, + int signal_number = 0); + + /// Create a timer result object which can be used with the Timer + /// mechanism of the Proactor. + virtual ACE_Asynch_Result_Impl *create_asynch_timer (const ACE_Handler::Proxy_Ptr &handler_proxy, + const void *act, + const ACE_Time_Value &tv, + ACE_HANDLE event, + int priority, + int signal_number = 0); + +protected: + /// Task to process pseudo-asynchronous operations + ACE_Asynch_Pseudo_Task & get_asynch_pseudo_task (void); + + /// Called when object is signaled by OS (either via UNIX signals or + /// when a Win32 object becomes signaled). + virtual int handle_signal (int signum, siginfo_t * = 0, ucontext_t * = 0); + + /// Called when object is removed from the ACE_Reactor. + virtual int handle_close (ACE_HANDLE handle, + ACE_Reactor_Mask close_mask); + + /** + * Dispatch a single set of events. If @a milli_seconds elapses + * before any events occur, return 0. Return 1 if a completion is + * dispatched. Return -1 on errors. + */ + virtual int handle_events (unsigned long milli_seconds); + + /// Protect against structured exceptions caused by user code when + /// dispatching handles. + void application_specific_code (ACE_WIN32_Asynch_Result *asynch_result, + size_t bytes_transferred, + const void *completion_key, + u_long error); + + /** + * Post @a how_many completions to the completion port so that all + * threads can wake up. This is used in conjunction with the + * run_event_loop(). + */ + virtual int post_wakeup_completions (int how_many); + + /// Handle for the completion port. Unix doesnt have completion + /// ports. + ACE_HANDLE completion_port_; + + /// This number is passed to the @c CreateIOCompletionPort system + /// call. + DWORD number_of_threads_; + + /// This event is used in conjunction with Reactor when we try to + /// integrate the event loops of Reactor and the Proactor. + ACE_Auto_Event event_; + + /// Flag that indicates whether we are used in conjunction with + /// Reactor. + bool const used_with_reactor_event_loop_; + + /// Handler to handle the wakeups. This works in conjunction with the + /// ACE_Proactor::run_event_loop(). + ACE_Handler wakeup_handler_; + + /// Pseudo-task for asynch connect ( NT/2000) + /// In future should removed in XP with ConnectEx support + ACE_Asynch_Pseudo_Task pseudo_task_; +}; + +/** + * @class ACE_WIN32_Asynch_Timer + * + * @brief This class is posted to the completion port when a timer + * expires. When the complete method of this object is + * called, the @a handler's handle_timeout method will be + * called. + */ +class ACE_WIN32_Asynch_Timer : public ACE_WIN32_Asynch_Result +{ + /// The factory method for this class is with the POSIX_Proactor + /// class. + friend class ACE_WIN32_Proactor; + +protected: + /// Constructor. + ACE_WIN32_Asynch_Timer (const ACE_Handler::Proxy_Ptr &handler_proxy, + const void *act, + const ACE_Time_Value &tv, + ACE_HANDLE event = ACE_INVALID_HANDLE, + int priority = 0, + int signal_number = 0); + + /// This method calls the @a handler's handle_timeout method. + virtual void complete (size_t bytes_transferred, + int success, + const void *completion_key, + u_long error = 0); + + /// Time value requested by caller + ACE_Time_Value time_; +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#endif /* ACE_WIN32 */ +#include /**/ "ace/post.h" +#endif /* ACE_PROACTOR_H */ diff --git a/dep/ACE_wrappers/ace/XML_Svc_Conf.cpp b/dep/ACE_wrappers/ace/XML_Svc_Conf.cpp new file mode 100644 index 00000000000..23dddad8469 --- /dev/null +++ b/dep/ACE_wrappers/ace/XML_Svc_Conf.cpp @@ -0,0 +1,15 @@ +// $Id: XML_Svc_Conf.cpp 80826 2008-03-04 14:51:23Z wotte $ + +#include "ace/XML_Svc_Conf.h" + +#if (ACE_USES_CLASSIC_SVC_CONF == 0) + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_XML_Svc_Conf::~ACE_XML_Svc_Conf (void) +{ +} + +ACE_END_VERSIONED_NAMESPACE_DECL + +#endif /* ACE_USES_CLASSIC_SVC_CONF == 0 */ diff --git a/dep/ACE_wrappers/ace/XML_Svc_Conf.h b/dep/ACE_wrappers/ace/XML_Svc_Conf.h new file mode 100644 index 00000000000..883151e05d2 --- /dev/null +++ b/dep/ACE_wrappers/ace/XML_Svc_Conf.h @@ -0,0 +1,65 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file XML_Svc_Conf.h + * + * $Id: XML_Svc_Conf.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Nanbor Wang + */ +//============================================================================= + + +#ifndef ACE_XML_SVC_CONF_H +#define ACE_XML_SVC_CONF_H + +#include /**/ "ace/pre.h" + +#include /**/ "ace/ACE_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#if (ACE_USES_CLASSIC_SVC_CONF==0) + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +/** + * @class ACE_XML_Svc_Conf + * + * @brief This abstract class defines the common operations + * ACE_Service_Config expects when using the XML Service Config Parser. + * + * When implementing a concret XML_Svc_Conf class, be sure to overload + * the new/delete function so the dynamically created concret XML_Svc_Conf + * instance can be deleted from the original heap in the DLL/SO. The + * concret XML_Svc_Conf implementation will be put into a DLL/SO that + * ACE applications can link to dynamically using the ACE_DLL class. + * This DLL should include an operation as follow: + * + * extern "C" ACE_XML_Svc_Conf_Parser * _ACEXML_create_XML_Svc_Conf_Object (void); + * + * + */ + +class ACE_Export ACE_XML_Svc_Conf +{ +public: + typedef ACE_XML_Svc_Conf *(*Factory)(void); + + virtual ~ACE_XML_Svc_Conf (void) = 0; + + virtual int parse_file (const ACE_TCHAR file[]) = 0; + + virtual int parse_string (const ACE_TCHAR str[]) = 0; +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#endif /* ACE_USES_CLASSIC_SVC_CONF == 0 */ + +#include /**/ "ace/post.h" + +#endif /* ACE_XML_SVC_CONF_H */ diff --git a/dep/ACE_wrappers/ace/XTI_ATM_Mcast.cpp b/dep/ACE_wrappers/ace/XTI_ATM_Mcast.cpp new file mode 100644 index 00000000000..503e3fea0e2 --- /dev/null +++ b/dep/ACE_wrappers/ace/XTI_ATM_Mcast.cpp @@ -0,0 +1,70 @@ +// $Id: XTI_ATM_Mcast.cpp 80826 2008-03-04 14:51:23Z wotte $ + +#include "ace/XTI_ATM_Mcast.h" + +ACE_RCSID(ace, XTI_ATM_Mcast, "$Id: XTI_ATM_Mcast.cpp 80826 2008-03-04 14:51:23Z wotte $") + +#if defined (ACE_HAS_XTI_ATM) + +#if !defined (__ACE_INLINE__) +#include "ace/XTI_ATM_Mcast.inl" +#endif /* __ACE_INLINE__ */ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_ALLOC_HOOK_DEFINE(ACE_XTI_ATM_Mcast) + +void +ACE_XTI_ATM_Mcast::dump (void) const +{ +#if defined (ACE_HAS_DUMP) + ACE_TRACE ("ACE_XTI_ATM_Mcast::dump"); +#endif /* ACE_HAS_DUMP */ +} + +ACE_XTI_ATM_Mcast::ACE_XTI_ATM_Mcast (void) +{ + ACE_TRACE ("ACE_XTI_ATM_Mcast::ACE_XTI_ATM_Mcast"); +} + +// Add a leaf to the current connection (i.e., multicast). + +int +ACE_XTI_ATM_Mcast::add_leaf (ACE_TLI_Stream ¤t_stream, + const ACE_Addr &remote_sap, + ACE_INT32 leaf_id, + ACE_Time_Value *timeout) +{ + ACE_TRACE ("ACE_XTI_ATM_Mcast::add_leaf"); + + struct netbuf call_req; + memset(&call_req, 0, sizeof(call_req)); + call_req.len = remote_sap.get_size (); + call_req.buf = (char *)remote_sap.get_addr (); + + if (::t_addleaf(current_stream.get_handle(), + leaf_id, + &call_req) < 0) + { + // Check for asynchronous event + if (t_errno == TLOOK) + { + int const event = ACE_OS::t_look(current_stream.get_handle()); + if (event != TNODATA && event != T_DATA) + return -1; + else + // If this doesn't work for asynchronous calls we need to call + // the XTI/ATM t_rcvleafchange() function to check for t_addleaf + // completion. + return complete (current_stream, 0, timeout); + } + else + return -1; + } + + return 0; +} + +ACE_END_VERSIONED_NAMESPACE_DECL + +#endif /* ACE_HAS_XTI_ATM */ diff --git a/dep/ACE_wrappers/ace/XTI_ATM_Mcast.h b/dep/ACE_wrappers/ace/XTI_ATM_Mcast.h new file mode 100644 index 00000000000..bfdfa92c957 --- /dev/null +++ b/dep/ACE_wrappers/ace/XTI_ATM_Mcast.h @@ -0,0 +1,137 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file XTI_ATM_Mcast.h + * + * $Id: XTI_ATM_Mcast.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Joe Hoffert + */ +//============================================================================= + + +#ifndef ACE_XTI_ATM_MCAST_H +#define ACE_XTI_ATM_MCAST_H +#include /**/ "ace/pre.h" + +#include /**/ "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +#pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#if defined (ACE_HAS_XTI_ATM) + +#include "ace/TLI_Connector.h" +#include "ace/ATM_Addr.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +/** + * @class ACE_XTI_ATM_Mcast + * + * @brief Defines an active connection factory for the ACE_TLI C++ + * wrappers to support XTI/ATM multicast. + */ +class ACE_Export ACE_XTI_ATM_Mcast : public ACE_TLI_Connector +{ +public: + // = Initialization methods. + /// Default constructor. + ACE_XTI_ATM_Mcast (void); + + /** + * Actively connect and produce a @a new_stream if things go well. + * The @a remote_sap is the address that we are trying to connect + * with. The @a timeout is the amount of time to wait to connect. + * If it's 0 then we block indefinitely. If *timeout == {0, 0} then + * the connection is done using non-blocking mode. In this case, if + * the connection can't be made immediately the value of -1 is + * returned with @c errno == EWOULDBLOCK. If *timeout > {0, 0} then + * this is the amount of time to wait before timing out. If the + * time expires before the connection is made @c errno == ETIME. The + * @a local_sap is the value of local address to bind to. If it's + * the default value of ACE_Addr::sap_any then the user is letting + * the OS do the binding. If @a reuse_addr == 1 then the + * is reused, even if it hasn't been cleanedup yet. + */ + ACE_XTI_ATM_Mcast (ACE_TLI_Stream &new_stream, + const ACE_Addr &remote_sap, + ACE_Time_Value *timeout = 0, + const ACE_Addr &local_sap = ACE_Addr::sap_any, + int reuse_addr = 0, + int flags = O_RDWR, + int perms = 0, + const char device[] = ACE_XTI_ATM_DEVICE, + struct t_info *info = 0, + int rw_flag = 1, + struct netbuf *udata = 0, + struct netbuf *opt = 0); + + /** + * Actively connect and produce a @a new_stream if things go well. + * The @a remote_sap is the address that we are trying to connect + * with. The @a timeout is the amount of time to wait to connect. + * If it's 0 then we block indefinitely. If *timeout == {0, 0} then + * the connection is done using non-blocking mode. In this case, if + * the connection can't be made immediately the value of -1 is + * returned with @c errno == EWOULDBLOCK. If *timeout > {0, 0} then + * this is the amount of time to wait before timing out. If the + * time expires before the connection is made @c errno == ETIME. The + * @a local_sap is the value of local address to bind to. If it's + * the default value of ACE_Addr::sap_any then the user is letting + * the OS do the binding. If @a reuse_addr == 1 then the + * is reused, even if it hasn't been cleanedup yet. + */ + int connect (ACE_TLI_Stream &new_stream, + const ACE_Addr &remote_sap, + ACE_Time_Value *timeout = 0, + const ACE_Addr &local_sap = ACE_Addr::sap_any, + int reuse_addr = 0, + int flags = O_RDWR, + int perms = 0, + const char device[] = ACE_XTI_ATM_DEVICE, + struct t_info *info = 0, + int rw_flag = 1, + struct netbuf *udata = 0, + struct netbuf *opt = 0); + + /** + * Actively add a leaf to the currently connected stream (i.e., + * multicast). The @a remote_sap is the address of the leaf that we + * are trying to add. The @a timeout is the amount of time to wait to + * connect. If it's 0 then we block indefinitely. If *timeout == + * {0, 0} then the connection is done using non-blocking mode. In + * this case, if the connection can't be made immediately the value + * of -1 is returned with @c errno == EWOULDBLOCK. If *timeout > + * {0, 0} then this is the amount of time to wait before timing out. + * If the time expires before the connection is made @c errno == ETIME. + */ + int add_leaf (ACE_TLI_Stream ¤t_stream, + const ACE_Addr &remote_sap, + ACE_INT32 leaf_id, + ACE_Time_Value *timeout = 0); + + // = Meta-type info + typedef ACE_ATM_Addr PEER_ADDR; + typedef ACE_TLI_Stream PEER_STREAM; + + /// Dump the state of an object. + void dump (void) const; + + /// Declare the dynamic allocation hooks. + ACE_ALLOC_HOOK_DECLARE; +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +#include "ace/XTI_ATM_Mcast.inl" +#endif /* __ACE_INLINE__ */ + +#endif /* ACE_HAS_XTI_ATM */ + +#include /**/ "ace/post.h" + +#endif /* ACE_XTI_ATM_MCAST_H */ diff --git a/dep/ACE_wrappers/ace/XTI_ATM_Mcast.inl b/dep/ACE_wrappers/ace/XTI_ATM_Mcast.inl new file mode 100644 index 00000000000..b182bb41b20 --- /dev/null +++ b/dep/ACE_wrappers/ace/XTI_ATM_Mcast.inl @@ -0,0 +1,65 @@ +// -*- C++ -*- +// +// $Id: XTI_ATM_Mcast.inl 80826 2008-03-04 14:51:23Z wotte $ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_INLINE +ACE_XTI_ATM_Mcast::ACE_XTI_ATM_Mcast (ACE_TLI_Stream &new_stream, + const ACE_Addr &remote_sap, + ACE_Time_Value *timeout, + const ACE_Addr &local_sap, + int reuse_addr, + int flags, + int perms, + const char device[], + struct t_info *info, + int rw_flag, + struct netbuf *udata, + struct netbuf *opt) +{ + ACE_TRACE ("ACE_XTI_ATM_Mcast::ACE_XTI_ATM_Mcast"); + if (this->connect (new_stream, remote_sap, timeout, local_sap, reuse_addr, + flags, perms, device, + info, rw_flag, + udata, opt) == ACE_INVALID_HANDLE + && timeout != 0 && !(errno == EWOULDBLOCK || errno == ETIME)) + ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("ACE_TLI_Stream::ACE_TLI_Stream"))); +} + +// Connect the to the , waiting up to +// amount of time if necessary. This is simple a pass- +// through function to ACE_TLI_Connector::connect(). It is over- +// ridden to change the default device from TCP to XTI/ATM. + +ACE_INLINE +int +ACE_XTI_ATM_Mcast::connect (ACE_TLI_Stream &new_stream, + const ACE_Addr &remote_sap, + ACE_Time_Value *timeout, + const ACE_Addr &local_sap, + int reuse_addr, + int flags, + int perms, + const char device[], + struct t_info *info, + int rw_flag, + struct netbuf *udata, + struct netbuf *opt) +{ + ACE_TRACE ("ACE_XTI_ATM_Mcast::connect"); + return ACE_TLI_Connector::connect(new_stream, + remote_sap, + timeout, + local_sap, + reuse_addr, + flags, + perms, + device, + info, + rw_flag, + udata, + opt); +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/ace.rc b/dep/ACE_wrappers/ace/ace.rc new file mode 100644 index 00000000000..54792491900 --- /dev/null +++ b/dep/ACE_wrappers/ace/ace.rc @@ -0,0 +1,38 @@ +#include "Version.h" + +1 VERSIONINFO + FILEVERSION ACE_MAJOR_VERSION,ACE_MINOR_VERSION,ACE_BETA_VERSION,0 + PRODUCTVERSION ACE_MAJOR_VERSION,ACE_MINOR_VERSION,ACE_BETA_VERSION,0 + FILEFLAGSMASK 0x3fL + FILEFLAGS 0x0L + FILEOS 0x4L + FILETYPE 0x1L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904B0" + BEGIN + VALUE "FileDescription", "ACE\0" + VALUE "FileVersion", ACE_VERSION "\0" + VALUE "InternalName", "ACEDLL\0" + VALUE "LegalCopyright", "\0" + VALUE "LegalTrademarks", "\0" + VALUE "OriginalFilename", "ACE.DLL\0" + VALUE "ProductName", "ACE\0" + VALUE "ProductVersion", ACE_VERSION "\0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END +END + +/* + * The following resource is used by the ACE logger to write messages + * to the NT event log. If you are statically linking to the ACE + * library, and you wish to use the NT event log, you should copy this + * message table to your application's resource script. + */ +1 MESSAGETABLE ace_message_table.bin diff --git a/dep/ACE_wrappers/ace/ace_ce_dll.cfg b/dep/ACE_wrappers/ace/ace_ce_dll.cfg new file mode 100644 index 00000000000..80c479b3205 --- /dev/null +++ b/dep/ACE_wrappers/ace/ace_ce_dll.cfg @@ -0,0 +1 @@ +WCE_CFG=WCE200; \ No newline at end of file diff --git a/dep/ACE_wrappers/ace/ace_message_table.bin b/dep/ACE_wrappers/ace/ace_message_table.bin new file mode 100644 index 0000000000000000000000000000000000000000..6ac08e5dc692359adc1156f251c77ed9420d8e72 GIT binary patch literal 28 VcmZQ%KmY+ClLv@Z4SBghq5uTP0E++s literal 0 HcmV?d00001 diff --git a/dep/ACE_wrappers/ace/ace_wchar.cpp b/dep/ACE_wrappers/ace/ace_wchar.cpp new file mode 100644 index 00000000000..bec8255447d --- /dev/null +++ b/dep/ACE_wrappers/ace/ace_wchar.cpp @@ -0,0 +1,17 @@ +// -*- C++ -*- +// +// $Id: ace_wchar.cpp 80826 2008-03-04 14:51:23Z wotte $ + +#include "ace/config-macros.h" +#include "ace/ace_wchar.h" + +ACE_RCSID(ace, ace_wchar, "$Id: ace_wchar.cpp 80826 2008-03-04 14:51:23Z wotte $") + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +#if defined(ACE_HAS_ICONV) +iconv_t ACE_Wide_To_Ascii::ACE_Wide_To_Ascii_iconv_env = 0; +iconv_t ACE_Ascii_To_Wide::ACE_Ascii_To_Wide_iconv_env = 0; +#endif + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/dep/ACE_wrappers/ace/ace_wchar.h b/dep/ACE_wrappers/ace/ace_wchar.h new file mode 100644 index 00000000000..f556e0f9cf8 --- /dev/null +++ b/dep/ACE_wrappers/ace/ace_wchar.h @@ -0,0 +1,385 @@ +//* -*- C++ -*- */ + +//============================================================================= +/** + * @file ace_wchar.h + * + * $Id: ace_wchar.h 82441 2008-07-28 13:04:13Z johnnyw $ + * + * @author Darrell Brunsch + */ +//============================================================================= + +#ifndef ACE_WCHAR_H +#define ACE_WCHAR_H + +#include "ace/config-macros.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +// These macros have been deprecated and should be replaced by their +// ACE_TEXT_* equivalents. These macros are just hacks and may not +// completely provide the old functionality. +#if defined (ACE_LEGACY_MODE) +// Convert the old unicode indicators +# if defined (ACE_HAS_MOSTLY_UNICODE_APIS) +# define ACE_USES_WCHAR +# endif /* ACE_HAS_MOSTLY_UNICODE_APIS */ +# if defined (ACE_HAS_UNICODE) +# define ACE_HAS_WCHAR +# endif /* ACE_HAS_UNICODE */ + +// These are defined to get older stuff to compile +// FUZZ: disable check_for_tchar +# define ASYS_TCHAR ACE_TCHAR +# define ASYS_TEXT ACE_TEXT +# define ASYS_ONLY_MULTIBYTE_STRING ACE_TEXT_ALWAYS_CHAR +# define ASYS_MULTIBYTE_STRING ACE_TEXT_CHAR_TO_TCHAR +# define ASYS_WIDE_STRING ACE_TEXT_CHAR_TO_TCHAR +# define ACE_WIDE_STRING ACE_TEXT_CHAR_TO_TCHAR + +# if defined (ACE_USES_WCHAR) +# define ASYS_ONLY_WIDE_STRING(STRING) STRING +# else /* ACE_USES_WCHAR */ +# define ASYS_ONLY_WIDE_STRING(STRING) \ + ACE_Ascii_To_Wide (STRING).wchar_rep () +# endif /* ACE_USES_WCHAR */ + +# define ACE_TEXT_STRING ACE_TString + +#endif /* ACE_LEGACY_MODE */ + +#if defined (ACE_HAS_XPG4_MULTIBYTE_CHAR) +# if !defined (ACE_HAS_WCHAR) +# define ACE_HAS_WCHAR +# endif +# include /**/ +#endif /* ACE_HAS_XPG4_MULTIBYTE_CHAR */ + +#if defined (ACE_HAS_WCHAR) +# if defined (ACE_VXWORKS) +# include /**/ /* For wchar_t */ +# include /**/ /* For mbstowcs, etc. */ +# include /**/ /* For strlen */ +# if !defined (__RTP__) +# define wint_t unsigned int /* VxWorks has wchar_t but not wint_t */ +# else +# include /**/ +# include /**/ +# endif +# elif defined (ACE_OPENVMS) +# include /**/ +# include /**/ +# elif defined (ACE_HAS_STANDARD_CPP_LIBRARY) && \ + (ACE_HAS_STANDARD_CPP_LIBRARY != 0) +# include /**/ +# include /**/ +# elif defined (ACE_HAS_WINCE) +# include /**/ +# else +# include /**/ +# endif /* ACE_HAS_STANDARD_CPP_LIBRARY */ +#endif /* ACE_HAS_WCHAR */ + +#if defined (ACE_HAS_ICONV) +# include /**/ +# if !defined (ACE_MAX_ICONV_BUFFER) +# define ACE_MAX_ICONV_BUFFER 16*1024 +# endif +#endif /* ACE_HAS_ICONV */ + +#if defined (ACE_USES_STD_NAMESPACE_FOR_STDC_LIB) && \ + (ACE_USES_STD_NAMESPACE_FOR_STDC_LIB != 0) +using std::size_t; +#endif /* ACE_USES_STD_NAMESPACE_FOR_STDC_LIB */ + +// This makes the somewhat dubious assumption that if a platform lacks +// a native wchar_t type, then it will typedef it as unsigned short. +#if defined (ACE_HAS_WCHAR) && !defined (ACE_LACKS_NATIVE_WCHAR_T) +# if !defined (ACE_WSTRING_HAS_USHORT_SUPPORT) +# define ACE_WSTRING_HAS_USHORT_SUPPORT +# endif /* ACE_WSTRING_HAS_USHORT_SUPPORT */ +#endif /* ACE_HAS_WCHAR && !ACE_LACKS_NATIVE_WCHAR_T */ + +// Set the default behaviour for ACE_TEXT_WIDE to use the L-prefix +#if !defined (ACE_USES_L_PREFIX) +# define ACE_USES_L_PREFIX 1 +#endif /* ACE_USES_L_PREFIX */ + +// Define the unicode/wchar related macros correctly + +# if !defined (ACE_TEXT_WIDE) +# if (ACE_USES_L_PREFIX == 1) +# define ACE_TEXT_WIDE_I(STRING) L##STRING +# else /* ACE_USES_L_PREFIX */ +# define ACE_TEXT_WIDE_I(STRING) STRING +# endif /* ACE_USES_L_PREFIX */ +# define ACE_TEXT_WIDE(STRING) ACE_TEXT_WIDE_I (STRING) +# endif /* ACE_TEXT_WIDE */ + +#if defined (ACE_USES_WCHAR) +typedef wchar_t ACE_TCHAR; +typedef char ACE_ANTI_TCHAR; +# define ACE_TEXT(STRING) ACE_TEXT_WIDE (STRING) +# if !defined (ACE_LACKS_DEPRECATED_MACROS) +# define ACE_LIB_TEXT(STRING) ACE_TEXT_WIDE (STRING) +# endif +# define ACE_TEXT_ALWAYS_CHAR(STRING) ACE_Wide_To_Ascii (STRING).char_rep () +# define ACE_TEXT_ALWAYS_WCHAR(STRING) STRING +# define ACE_TEXT_CHAR_TO_TCHAR(STRING) ACE_Ascii_To_Wide (STRING).wchar_rep () +# define ACE_TEXT_WCHAR_TO_TCHAR(STRING) STRING +# define ACE_TEXT_ANTI_TO_TCHAR(STRING) ACE_Ascii_To_Wide (STRING).wchar_rep () +#else /* ACE_USES_WCHAR */ +typedef char ACE_TCHAR; +typedef wchar_t ACE_ANTI_TCHAR; +# define ACE_TEXT(STRING) STRING +# if !defined (ACE_LACKS_DEPRECATED_MACROS) +# define ACE_LIB_TEXT(STRING) STRING +# endif +# define ACE_TEXT_ALWAYS_CHAR(STRING) STRING +# define ACE_TEXT_ALWAYS_WCHAR(STRING) ACE_Ascii_To_Wide (STRING).wchar_rep () +# define ACE_TEXT_CHAR_TO_TCHAR(STRING) STRING +# define ACE_TEXT_WCHAR_TO_TCHAR(STRING) ACE_Wide_To_Ascii (STRING).char_rep () +# define ACE_TEXT_ANTI_TO_TCHAR(STRING) ACE_Wide_To_Ascii (STRING).char_rep () +#endif /* ACE_USES_WCHAR */ + +// The OS_String module defines some wide-char functions that are not +// universally available. In particular, they're not part of the +// XPG4 Worldwide Portability Interface wide-character string handling +// functions. So, if ACE_HAS_XPG4_MULTIBYTE_CHAR is defined, note that +// these functions are missing. +#if defined (ACE_HAS_XPG4_MULTIBYTE_CHAR) + +# if !defined (ACE_LACKS_ITOW) +# define ACE_LACKS_ITOW +# endif + +# if !defined (ACE_LACKS_WCSICMP) +# define ACE_LACKS_WCSICMP +# endif + +# if !defined (ACE_LACKS_WCSNICMP) +# define ACE_LACKS_WCSNICMP +# endif + +# if !defined (ACE_LACKS_WCSDUP) +# define ACE_LACKS_WCSDUP +# endif + +#endif /* ACE_HAS_XPG4_MULTIBYTE_CHAR */ + +#if defined ACE_HAS_WCHAR + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +/** + * @class ACE_Wide_To_Ascii + * + * @brief A lightweight wchar* to char* string conversion class. + * + * The purpose of this class is to perform conversion from + * wchar* to char* strings. It is not intended for general + * purpose use. + */ +class ACE_Wide_To_Ascii +{ +public: + /// Ctor must take a wchar string. + ACE_Wide_To_Ascii (const wchar_t *s); + + /// Dtor will free up the memory. + ~ACE_Wide_To_Ascii (void); + + /// Return the internal char* representation. + char *char_rep (void); + + /// Converts an wchar_t string to ascii and returns a new string. + static char *convert (const wchar_t *wstr); + +private: + /// Internal pointer to the converted string. + char *s_; + +#if defined (ACE_HAS_ICONV) + static iconv_t ACE_Wide_To_Ascii_iconv_env; +#endif /* ACE_HAS_ICONV */ + + /// Disallow these operation. + ACE_Wide_To_Ascii (void); + ACE_Wide_To_Ascii (ACE_Wide_To_Ascii &); + ACE_Wide_To_Ascii& operator= (ACE_Wide_To_Ascii &); +}; + +/** + * @class ACE_Ascii_To_Wide + * + * @brief A lightweight char* to wchar* string conversion class. + * + * The purpose of this class is to perform conversion from + * char* to wchar* strings. It is not intended for general + * purpose use. + */ +class ACE_Ascii_To_Wide +{ +public: + /// Ctor must take a wchar string. + ACE_Ascii_To_Wide (const char *s); + + /// Dtor will free up the memory. + ~ACE_Ascii_To_Wide (void); + + /// Return the internal wchar* representation. + wchar_t *wchar_rep (void); + + /// Converts an char string to unicode/wide and returns a new string. + static wchar_t *convert (const char *str); + +private: + /// Internal pointer to the converted string. + wchar_t *s_; + +#if defined (ACE_HAS_ICONV) + static iconv_t ACE_Ascii_To_Wide_iconv_env; +#endif /* ACE_HAS_ICONV */ + + /// Disallow these operation. + ACE_Ascii_To_Wide (void); + ACE_Ascii_To_Wide (ACE_Ascii_To_Wide &); + ACE_Ascii_To_Wide operator= (ACE_Ascii_To_Wide &); +}; + +#if defined (ACE_LEGACY_MODE) +typedef ACE_Ascii_To_Wide ACE_OS_CString; +typedef ACE_Wide_To_Ascii ACE_OS_WString; +#endif /* ACE_LEGACY_MODE */ + +ACE_END_VERSIONED_NAMESPACE_DECL + +#endif /* ACE_HAS_WCHAR */ + +#if defined (ACE_WIN32) +#if defined (ACE_USES_WCHAR) +#define ACE_LPSTR LPWSTR +#define ACE_TEXT_SERVICE_TABLE_ENTRY SERVICE_TABLE_ENTRYW +#define ACE_TEXT_STARTUPINFO STARTUPINFOW +#define ACE_TEXT_WIN32_FIND_DATA WIN32_FIND_DATAW +#define ACE_TEXT_OSVERSIONINFO OSVERSIONINFOW +#define ACE_TEXT_EXPLICIT_ACCESS EXPLICIT_ACCESS_W + +#define ACE_TEXT_CreateEvent ::CreateEventW +#define ACE_TEXT_CreateFile ::CreateFileW +#define ACE_TEXT_CreateFileMapping ::CreateFileMappingW +#define ACE_TEXT_CreateMutex ::CreateMutexW +#define ACE_TEXT_CreateProcess ::CreateProcessW +#define ACE_TEXT_CreateSemaphore ::CreateSemaphoreW +#define ACE_TEXT_CreateService ::CreateServiceW +#define ACE_TEXT_ExpandEnvironmentStrings ::ExpandEnvironmentStringsW +#define ACE_TEXT_FindFirstChangeNotification ::FindFirstChangeNotificationW +#define ACE_TEXT_FindFirstFile ::FindFirstFileW +#define ACE_TEXT_FindNextFile ::FindNextFileW +#define ACE_TEXT_FormatMessage ::FormatMessageW +#define ACE_TEXT_FreeEnvironmentStrings ::FreeEnvironmentStringsW +#define ACE_TEXT_GetComputerName ::GetComputerNameW +#define ACE_TEXT_GetEnvironmentStrings ::GetEnvironmentStringsW +#define ACE_TEXT_GetFileAttributes ::GetFileAttributesW +#define ACE_TEXT_GetModuleFileName ::GetModuleFileNameW +#define ACE_TEXT_GetTempPath ::GetTempPathW +#define ACE_TEXT_GetUserName ::GetUserNameW +#define ACE_TEXT_GetUserNameEx ::GetUserNameExW +#define ACE_TEXT_GetVersionEx ::GetVersionExW +#define ACE_TEXT_LoadLibrary ::LoadLibraryW +#define ACE_TEXT_MoveFileEx ::MoveFileExW +#define ACE_TEXT_WaitNamedPipe ::WaitNamedPipeW +#define ACE_TEXT_OpenFileMapping ::OpenFileMappingW +#define ACE_TEXT_OpenSCManager ::OpenSCManagerW +#define ACE_TEXT_OpenService ::OpenServiceW +#define ACE_TEXT_OutputDebugString ::OutputDebugStringW +#define ACE_TEXT_RegisterEventSource ::RegisterEventSourceW +#define ACE_TEXT_RegisterServiceCtrlHandler ::RegisterServiceCtrlHandlerW +#define ACE_TEXT_RegConnectRegistry ::RegConnectRegistryW +#define ACE_TEXT_RegCreateKeyEx ::RegCreateKeyExW +#define ACE_TEXT_RegDeleteKey ::RegDeleteKeyW +#define ACE_TEXT_RegDeleteValue ::RegDeleteValueW +#define ACE_TEXT_RegEnumKeyEx ::RegEnumKeyExW +#define ACE_TEXT_RegEnumValue ::RegEnumValueW +#define ACE_TEXT_RegCreateKey ::RegCreateKeyW +#define ACE_TEXT_RegOpenKey ::RegOpenKeyW +#define ACE_TEXT_RegOpenKeyEx ::RegOpenKeyExW +#define ACE_TEXT_RegQueryValueEx ::RegQueryValueExW +#define ACE_TEXT_RegSetValueEx ::RegSetValueExW +#define ACE_TEXT_ReportEvent ::ReportEventW +#define ACE_TEXT_SearchPath ::SearchPathW +#define ACE_TEXT_StartService ::StartServiceW +#define ACE_TEXT_StartServiceCtrlDispatcher ::StartServiceCtrlDispatcherW +#define ACE_TEXT_SetFileSecurity ::SetFileSecurityW +#define ACE_TEXT_SetEntriesInAcl ::SetEntriesInAclW +#define ACE_TEXT_PdhExpandCounterPath ::PdhExpandCounterPathW +#define ACE_TEXT_PdhOpenQuery ::PdhOpenQueryW +#define ACE_TEXT_PdhAddCounter ::PdhAddCounterW + +#else /* ACE_USES_WCHAR */ +#define ACE_LPSTR LPSTR +#define ACE_TEXT_SERVICE_TABLE_ENTRY SERVICE_TABLE_ENTRYA +#define ACE_TEXT_STARTUPINFO STARTUPINFOA +#define ACE_TEXT_WIN32_FIND_DATA WIN32_FIND_DATAA +#define ACE_TEXT_OSVERSIONINFO OSVERSIONINFOA +#define ACE_TEXT_EXPLICIT_ACCESS EXPLICIT_ACCESS_A + +#define ACE_TEXT_CreateEvent ::CreateEventA +#define ACE_TEXT_CreateFile ::CreateFileA +#define ACE_TEXT_CreateFileMapping ::CreateFileMappingA +#define ACE_TEXT_CreateMutex ::CreateMutexA +#define ACE_TEXT_CreateProcess ::CreateProcessA +#define ACE_TEXT_CreateSemaphore ::CreateSemaphoreA +#define ACE_TEXT_CreateService ::CreateServiceA +#define ACE_TEXT_ExpandEnvironmentStrings ::ExpandEnvironmentStringsA +#define ACE_TEXT_FindFirstChangeNotification ::FindFirstChangeNotificationA +#define ACE_TEXT_FindFirstFile ::FindFirstFileA +#define ACE_TEXT_FindNextFile ::FindNextFileA +#define ACE_TEXT_FormatMessage ::FormatMessageA +#define ACE_TEXT_FreeEnvironmentStrings ::FreeEnvironmentStringsA +#define ACE_TEXT_GetComputerName ::GetComputerNameA +#define ACE_TEXT_GetEnvironmentStrings ::GetEnvironmentStringsA +#define ACE_TEXT_GetFileAttributes ::GetFileAttributesA +#define ACE_TEXT_GetModuleFileName ::GetModuleFileNameA +#define ACE_TEXT_GetTempPath ::GetTempPathA +#define ACE_TEXT_GetUserName ::GetUserNameA +#define ACE_TEXT_GetUserNameEx ::GetUserNameExA +#define ACE_TEXT_GetVersionEx ::GetVersionExA +#define ACE_TEXT_LoadLibrary ::LoadLibraryA +#define ACE_TEXT_MoveFileEx ::MoveFileExA +#define ACE_TEXT_WaitNamedPipe ::WaitNamedPipeA +#define ACE_TEXT_OpenFileMapping ::OpenFileMappingA +#define ACE_TEXT_OpenSCManager ::OpenSCManagerA +#define ACE_TEXT_OpenService ::OpenServiceA +#define ACE_TEXT_OutputDebugString ::OutputDebugStringA +#define ACE_TEXT_RegisterEventSource ::RegisterEventSourceA +#define ACE_TEXT_RegisterServiceCtrlHandler ::RegisterServiceCtrlHandlerA +#define ACE_TEXT_RegConnectRegistry ::RegConnectRegistryA +#define ACE_TEXT_RegCreateKeyEx ::RegCreateKeyExA +#define ACE_TEXT_RegDeleteKey ::RegDeleteKeyA +#define ACE_TEXT_RegDeleteValue ::RegDeleteValueA +#define ACE_TEXT_RegEnumKeyEx ::RegEnumKeyExA +#define ACE_TEXT_RegEnumValue ::RegEnumValueA +#define ACE_TEXT_RegCreateKey ::RegCreateKeyA +#define ACE_TEXT_RegOpenKey ::RegOpenKeyA +#define ACE_TEXT_RegOpenKeyEx ::RegOpenKeyExA +#define ACE_TEXT_RegQueryValueEx ::RegQueryValueExA +#define ACE_TEXT_RegSetValueEx ::RegSetValueExA +#define ACE_TEXT_ReportEvent ::ReportEventA +#define ACE_TEXT_SearchPath ::SearchPathA +#define ACE_TEXT_StartService ::StartServiceA +#define ACE_TEXT_StartServiceCtrlDispatcher ::StartServiceCtrlDispatcherA +#define ACE_TEXT_SetFileSecurity ::SetFileSecurityA +#define ACE_TEXT_SetEntriesInAcl ::SetEntriesInAclA +#define ACE_TEXT_PdhExpandCounterPath ::PdhExpandCounterPathA +#define ACE_TEXT_PdhOpenQuery ::PdhOpenQueryA +#define ACE_TEXT_PdhAddCounter ::PdhAddCounterA +#endif /* ACE_USES_WCHAR */ +#endif /* ACE_WIN32 */ + +#include "ace/ace_wchar.inl" + +#endif /* ACE_WCHAR_H */ diff --git a/dep/ACE_wrappers/ace/ace_wchar.inl b/dep/ACE_wrappers/ace/ace_wchar.inl new file mode 100644 index 00000000000..744b44f5e73 --- /dev/null +++ b/dep/ACE_wrappers/ace/ace_wchar.inl @@ -0,0 +1,183 @@ +// -*- C++ -*- +// +// $Id: ace_wchar.inl 80826 2008-03-04 14:51:23Z wotte $ + +// These are always inlined +// FUZZ: disable check_for_inline + +#if defined (ACE_HAS_WCHAR) + +#if !defined (ACE_WIN32) +# include /**/ // Need to see strlen() +#endif /* ACE_WIN32 */ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +inline +ACE_Wide_To_Ascii::~ACE_Wide_To_Ascii (void) +{ + delete [] this->s_; +} + +inline char * +ACE_Wide_To_Ascii::char_rep (void) +{ + return this->s_; +} + +inline char * +ACE_Wide_To_Ascii::convert (const wchar_t *wstr) +{ + // Short circuit null pointer case + if (wstr == 0) + return 0; + +# if defined (ACE_WIN32) + UINT const cp = GetACP (); // Codepage + int const len = ::WideCharToMultiByte (cp, + 0, + wstr, + -1, + 0, + 0, + 0, + 0); +# elif defined (ACE_LACKS_WCSLEN) + const wchar_t * wtemp = wstr; + while ((*wtemp) != 0) // Hopefully the string is null terminated! + ++wtemp; + + int const len = wtemp - wstr + 1; +# else /* ACE_WIN32 */ + size_t const len = ::wcslen (wstr) + 1; +# endif /* ACE_WIN32 */ + +#if !defined (ACE_HAS_ICONV) + char *str = new char[len]; +#endif + +# if defined (ACE_WIN32) + ::WideCharToMultiByte (cp, 0, wstr, -1, str, len, 0, 0); +# elif defined (ACE_VXWORKS) + ::wcstombs (str, wstr, len); +# elif defined (ACE_HAS_ICONV) + wchar_t * wstri = const_cast (wstr); + size_t lensi = ACE_MAX_ICONV_BUFFER; + size_t lenwi = len * sizeof(wchar_t); + char buf[ACE_MAX_ICONV_BUFFER]; + char *stri = buf; + + size_t hr = iconv (ACE_Wide_To_Ascii_iconv_env, (char**)&wstri, &lenwi, &stri, &lensi); + if ((hr==size_t(-1))||(lensi==ACE_MAX_ICONV_BUFFER)) + { + char *str=new char[len]; + for (size_t i = 0; i < len; i++) + { + wchar_t *t = const_cast (wstr); + str[i] = static_cast (*(t + i)); + } + + return str; + } + char *str = new char[ACE_MAX_ICONV_BUFFER-lensi]; + ::memcpy(str, buf, ACE_MAX_ICONV_BUFFER-lensi); +# else /* ACE_HAS_ICONV */ + for (size_t i = 0; i < len; ++i) + { + wchar_t *t = const_cast (wstr); + str[i] = static_cast (*(t + i)); + } +# endif /* ACE_WIN32 */ + return str; +} + +inline +ACE_Wide_To_Ascii::ACE_Wide_To_Ascii (const wchar_t *s) +{ +#if defined(ACE_HAS_ICONV) + if (ACE_Wide_To_Ascii_iconv_env == 0) + { + ACE_Wide_To_Ascii_iconv_env = iconv_open("", "WCHAR_T"); + } +#endif + s_ = ACE_Wide_To_Ascii::convert (s); +} + +inline +ACE_Ascii_To_Wide::~ACE_Ascii_To_Wide (void) +{ + delete [] this->s_; +} + +inline wchar_t * +ACE_Ascii_To_Wide::wchar_rep (void) +{ + return this->s_; +} + +inline wchar_t * +ACE_Ascii_To_Wide::convert (const char *str) +{ + // Short circuit null pointer case + if (str == 0) + return 0; + +# if defined (ACE_WIN32) + UINT const cp = GetACP (); // Codepage + int const len = ::MultiByteToWideChar (cp, 0, str, -1, 0, 0); +# else /* ACE_WIN32 */ + size_t const len = strlen (str) + 1; +# endif /* ACE_WIN32 */ + +#if !defined (ACE_HAS_ICONV) + wchar_t *wstr = new wchar_t[len]; +#endif + +# if defined (ACE_WIN32) + ::MultiByteToWideChar (cp, 0, str, -1, wstr, len); +# elif defined (ACE_VXWORKS) + ::mbstowcs (wstr, str, len); +# elif defined (ACE_HAS_ICONV) /* ACE_VXWORKS */ + char *stri = const_cast(str); + size_t lensi = len; + size_t lenwi = ACE_MAX_ICONV_BUFFER; + wchar_t buf[ACE_MAX_ICONV_BUFFER/sizeof(wchar_t)]; + wchar_t *wstri=buf; + + size_t hr=iconv(ACE_Ascii_To_Wide_iconv_env, &stri, &lensi, (char**)&wstri, &lenwi); + if((hr==size_t(-1))||(lenwi==ACE_MAX_ICONV_BUFFER)){ + wchar_t *wstr=new wchar_t[len*sizeof(wchar_t)]; + for (size_t i = 0; i < len; i++){ + char *t = const_cast (str); + wstr[i] = static_cast (*((unsigned char*)t + i)); + } + + return wstr; + } + wchar_t *wstr=new wchar_t[(ACE_MAX_ICONV_BUFFER-lenwi)/sizeof(wchar_t)]; + ::memcpy(wstr,buf,ACE_MAX_ICONV_BUFFER-lenwi); +# else /* ACE_HAS_ICONV */ + for (size_t i = 0; i < len; ++i) + { + char *t = const_cast (str); + wstr[i] = static_cast (*((unsigned char*)(t + i))); + } +# endif /* ACE_WIN32 */ + return wstr; +} + +inline +ACE_Ascii_To_Wide::ACE_Ascii_To_Wide (const char *s) +{ +#if defined(ACE_HAS_ICONV) + if (ACE_Ascii_To_Wide_iconv_env == 0) + { + ACE_Ascii_To_Wide_iconv_env = iconv_open("WCHAR_T", ""); + } +#endif + s_ = ACE_Ascii_To_Wide::convert (s); +} + +ACE_END_VERSIONED_NAMESPACE_DECL + +#endif /* ACE_HAS_WCHAR */ diff --git a/dep/ACE_wrappers/ace/checked_iterator.h b/dep/ACE_wrappers/ace/checked_iterator.h new file mode 100644 index 00000000000..7792fbb9ec6 --- /dev/null +++ b/dep/ACE_wrappers/ace/checked_iterator.h @@ -0,0 +1,58 @@ +// -*- C++ -*- + +#ifndef ACE_CHECKED_ITERATOR_H +#define ACE_CHECKED_ITERATOR_H + +/** + * @file checked_iterator.h + * + * @brief Checked iterator factory function. + * + * Some compilers (e.g. MSVC++ >= 8) issue security related + * diagnostics if algorithms such as std::copy() are used in an unsafe + * way. Normally this isn't an issue if STL container iterators are + * used in conjuction with the standard algorithms. However, in cases + * where application-specific iterators are use with standard + * algorithms that could potentially overrun a buffer, extra care must + * be taken to prevent such an overrun. If supported, checked + * iterators can be used to address the potential destination buffer + * overrun. + * + * This header provides function templates that generate the + * appropriate checked iterator. In cases where checked iterators are + * not supported, the pointer passed to the function is returned + * instead. + * + * $Id: checked_iterator.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @internal The functions and types in this header are meant for + * internal use. They may change at any point between + * releases. + * + * @author Ossama Othman + */ + +# if defined (_MSC_VER) && (_MSC_FULL_VER >= 140050000) +// Checked iterators are currently only supported in MSVC++ 8 or better. +# include +# endif /* _MSC_VER >= 1400 */ + +# if defined (_MSC_VER) && (_MSC_FULL_VER >= 140050000) +template +stdext::checked_array_iterator +ACE_make_checked_array_iterator (PTR buf, size_t len) +{ + return stdext::checked_array_iterator (buf, len); +} +# else +template +PTR +ACE_make_checked_array_iterator (PTR buf, size_t /* len */) +{ + // Checked iterators are unsupported. Just return the pointer to + // the buffer itself. + return buf; +} +# endif /* _MSC_VER >= 1400 */ + +#endif /* ACE_CHECKED_ITERATOR_H */ diff --git a/dep/ACE_wrappers/ace/codecs.mpb b/dep/ACE_wrappers/ace/codecs.mpb new file mode 100644 index 00000000000..03ecfef7616 --- /dev/null +++ b/dep/ACE_wrappers/ace/codecs.mpb @@ -0,0 +1,8 @@ +// -*- MPC -*- +// $Id: codecs.mpb 80826 2008-03-04 14:51:23Z wotte $ + +feature(ace_codecs) { + Source_Files(ACE_COMPONENTS) { + Codecs.cpp + } +} diff --git a/dep/ACE_wrappers/ace/config-WinCE.h b/dep/ACE_wrappers/ace/config-WinCE.h new file mode 100644 index 00000000000..f3b65a44c10 --- /dev/null +++ b/dep/ACE_wrappers/ace/config-WinCE.h @@ -0,0 +1,240 @@ +// $Id: config-WinCE.h 81693 2008-05-14 12:35:01Z johnnyw $ + +// Note: For WinCE build, simply use: #include "ace/config-win32.h" +// It is same as config.h for Windows NT/2k so that you can +// share same files and directories for both WinCE and NT/2k +// builds, unless you add additional definition(s) for each +// specific build or change the output directory. + +#ifndef ACE_CONFIG_WINCE_H +#define ACE_CONFIG_WINCE_H + +#include /**/ "ace/pre.h" + +#ifndef ACE_CONFIG_WIN32_H +# error Use config-win32.h in config.h instead of this header +#endif // ACE_CONFIG_WIN32_H + +#if !defined (UNDER_CE) +# error Define UNDER_CE to version (i.e. 300 = 3.0) +#endif // UNDER_CE + +#if (UNDER_CE < 300) +# error ACE requires Windows CE 3.0 and later. +#endif // UNDER_CE + +#if (UNDER_CE < 400) +// CE 3 doesn't have Winsock 2, but CE 4 does. +# if !defined (ACE_HAS_WINSOCK2) +# define ACE_HAS_WINSOCK2 0 +# endif +# define ACE_LACKS_ASSERT_H +# define ACE_LACKS_SEARCH_H +# define ACE_LACKS_WCHAR_H +# define ACE_LACKS_WCTYPE_H +# define ACE_LACKS_STDDEF_H +# define ACE_LACKS_PTRDIFF_T +#endif /* UNDER_CE < 400 */ + +#if !defined (ACE_HAS_WINCE) +# define ACE_HAS_WINCE 1 +#endif + +#if defined (_MSC_VER) && (_MSC_VER < 1400) +// WinCE prior to Visual Studio 2005 integration doesn't have most of +// the standard C library time functions. It also doesn't define struct tm. +// SYSTEMTIME has pretty much the same info though, so we can map it when +// needed. Define struct tm here and use it when needed. This is taken +// from the standard C library. +# define ACE_LACKS_STRUCT_TM +#endif + +// We need these libraries to build: +#pragma comment(lib,"corelibc.lib") +#pragma comment(linker, "/nodefaultlib:oldnames.lib") + +// Only DLL version is supported on CE. +//#if defined (ACE_HAS_DLL) +//# undef ACE_HAS_DLL +//#endif // ACE_HAS_DLL +//#define ACE_HAS_DLL 1 + +// Need to define LD search path explicitly on CE because +// CE doesn't have environment variables and we can't get +// the information using getenv. +#define ACE_DEFAULT_LD_SEARCH_PATH ACE_TEXT (".\\;\\windows") + +#define ACE_LACKS_FCNTL_H +#define ACE_LACKS_SYS_TYPES_H +#define ACE_LACKS_GETCWD +#define ACE_LACKS_ASCTIME +#define ACE_LACKS_ASCTIME_R +#define ACE_LACKS_GMTIME +#define ACE_LACKS_GMTIME_R +#define ACE_LACKS_LOCALTIME +#define ACE_LACKS_PERROR +#define ACE_LACKS_STRFTIME +#define ACE_LACKS_WIN32_SETFILEPOINTEREX +#define ACE_LACKS_WIN32_SERVICES +#define ACE_LACKS_WIN32_SECURITY_DESCRIPTORS +#define ACE_LACKS_GETPROCESSTIMES +#define ACE_LACKS_PDH_H +#define ACE_LACKS_PDHMSG_H + +#define ACE_HAS_POSITION_INDEPENDENT_POINTERS 1 + +#define ACE_LACKS_MSG_WFMO +#define ACE_LACKS_UMASK + +// WinCE only supports the UNICODE API +#if !defined (ACE_USES_WCHAR) +# define ACE_USES_WCHAR +#endif /* ACE_USES_WCHAR */ + +#define ACE_USES_WINCE_SEMA_SIMULATION + +#define ACE_HAS_NONSTATIC_OBJECT_MANAGER 1 + +// FILE stuff isn't always defined in CE +#if (_MSC_VER < 1400) && !defined (_FILE_DEFINED) + typedef void FILE; +# define _FILE_DEFINED +#endif /* _MSC_VER < 1400 && !_FILE_DEFINED */ + +// This was defined in previous versions of CE, but not 2.11 +#define EXCEPTION_ACCESS_VIOLATION STATUS_ACCESS_VIOLATION + +#define ACE_MAIN WINAPI WinMain + +// SH3 cross-compiler can't handle inline functions correctly +// (along with other bugs.) +#if defined (SH3) +# define ACE_LACKS_INLINE_FUNCTIONS +#endif // SH3 && _DEBUG + +#ifndef ACE_DEFAULT_SERVER_HOST +# define ACE_DEFAULT_SERVER_HOST ACE_TEXT("localhost") +#endif // ACE_DEFAULT_SERVER_HOST + +// @@ Need to remap every function that uses any of these flags to +// Win32 API. These are for ANSI styled function and are not +// available on WinCE. + +#define _O_RDONLY 0x0000 // open for reading only +#define _O_WRONLY 0x0001 // open for writing only +#define _O_RDWR 0x0002 // open for reading and writing +#define _O_APPEND 0x0008 // writes done at eof + +#define _O_CREAT 0x0100 // create and open file +#define _O_TRUNC 0x0200 // open and truncate +#define _O_EXCL 0x0400 // open only if file doesn't already exist + +// O_TEXT files have sequences translated to on read()'s, +// and sequences translated to on write()'s +#define _O_TEXT 0x4000 // file mode is text (translated) +#define _O_BINARY 0x8000 // file mode is binary (untranslated) + +// macro to translate the C 2.0 name used to force binary mode for files +//#define _O_RAW _O_BINARY + +// Open handle inherit bit +//#define _O_NOINHERIT 0x0080 // child process doesn't inherit file + +// Temporary file bit - file is deleted when last handle is closed +#define _O_TEMPORARY 0x0040 // temporary file bit + +// temporary access hint +//#define _O_SHORT_LIVED 0x1000 // temporary storage file, try not to flush + +// sequential/random access hints +//#define _O_SEQUENTIAL 0x0020 // file access is primarily sequential +//#define _O_RANDOM 0x0010 // file access is primarily random + + +// Non-ANSI names +#define O_RDONLY _O_RDONLY +#define O_WRONLY _O_WRONLY +#define O_RDWR _O_RDWR +#define O_APPEND _O_APPEND +#define O_CREAT _O_CREAT +#define O_TRUNC _O_TRUNC +#define O_EXCL _O_EXCL +#define O_TEXT _O_TEXT +#define O_BINARY _O_BINARY +#define O_TEMPORARY _O_TEMPORARY +//#define O_RAW _O_BINARY +//#define O_NOINHERIT _O_NOINHERIT +//#define O_SEQUENTIAL _O_SEQUENTIAL +//#define O_RANDOM _O_RANDOM + + +// @@ NSIG value. This is definitely not correct. +#define NSIG 23 + + +// @@ For some reason, WinCE forgot to define this. +// Need to find out what it is. (Used in MapViewOfFile ().) +#define FILE_MAP_COPY 0 + + +#define ACE_LACKS_STRCASECMP // WinCE doesn't support _stricmp +#define ACE_LACKS_GETSERVBYNAME +#define ACE_LACKS_ACCESS +#define ACE_LACKS_FILELOCKS +#define ACE_LACKS_EXEC +#define ACE_LACKS_MKTEMP +#define ACE_LACKS_STRRCHR +#define ACE_LACKS_BSEARCH +#define ACE_LACKS_SOCKET_BUFSIZ +#define ACE_LACKS_ISATTY +#define ACE_LACKS_STRERROR +#define ACE_LACKS_SYSTEM +#define ACE_LACKS_SIGACTION +#define ACE_LACKS_PIPE + +//#define ACE_LACKS_CUSERID +//#define ACE_LACKS_CHDIR +#define ACE_LACKS_ENV +#define ACE_LACKS_HOSTNAME +#define ACE_LACKS_REALPATH +#define ACE_LACKS_READLINK +#define ACE_LACKS_SWAB +#define ACE_LACKS_TEMPNAM +#define ACE_LACKS_GETPROTOBYNUMBER +#define ACE_LACKS_GETPROTOBYNAME + +#if defined (_WIN32_WCE_EMULATION) +// @@ For some reason, qsort isn't defined correctly (_stdcall vs _cdecl) +// under emulation. So for right now, exclude it. +# define ACE_LACKS_QSORT +#endif // _WIN32_WCE_EMULATION + +#if !defined (BUFSIZ) +# define BUFSIZ 1024 +#endif + +typedef void (__cdecl * __sighandler_t)(int); // keep Signal compilation happy +typedef long off_t; + +#define ACE_LACKS_MALLOC_H // We do have malloc.h, but don't use it. + +#define ACE_HAS_WINCE_BROKEN_ERRNO + +#define ACE_HAS_STRDUP_EMULATION + +// WinCE can't do fixed addresses for memory-mapped files. +#if defined (ACE_DEFAULT_BASE_ADDR) +# undef ACE_DEFAULT_BASE_ADDR +#endif +#define ACE_DEFAULT_BASE_ADDR 0 + +#define ACE_HAS_TSS_EMULATION + +// This is still true up thru VC8... +#define ACE_LACKS_ERRNO_H +#define ACE_LACKS_SIGNAL_H +#define ACE_LACKS_SYS_STAT_H + +#include /**/ "ace/post.h" + +#endif // ACE_CONFIG_WINCE_H diff --git a/dep/ACE_wrappers/ace/config-aix-5.x.h b/dep/ACE_wrappers/ace/config-aix-5.x.h new file mode 100644 index 00000000000..30507a05fea --- /dev/null +++ b/dep/ACE_wrappers/ace/config-aix-5.x.h @@ -0,0 +1,333 @@ +// $Id: config-aix-5.x.h 80826 2008-03-04 14:51:23Z wotte $ +// +// Config file for AIX 5.1 and higher. + +#ifndef ACE_CONFIG_AIX_5_X_H +#define ACE_CONFIG_AIX_5_X_H + +// This define is needed for building with Visual Age C++ 5 in incremental +// mode. In the batch mode build, platform_aix_ibm.GNU sets it. The incremental +// mode compiler won't be supported after ACE 5.3, so this will also go away +// in that timeframe, so don't worry about future AIX versions. +#if !defined (ACE_AIX_VERS) +# define ACE_AIX_VERS 501 +#endif + +// AIX 5.1 has AIO, but it doesn't have the same API as other POSIX +// systems, and the semantics of operations are a bit different. Will take +// some real work to get this going. +// AIX 5.2, however, has the POSIX API implemented. However, the libc functions +// to implement it aren't exported by default. You need to use smit to enable +// them. So, leave AIO disabled unless the user explicitly enables it. +// config-aix-4.x.h will set ACE_HAS_AIO_CALLS if config-posix.h senses the +// feature-test macros, so set up _ACE_DISABLE_AIO_CALLS_ if the user didn't +// set it. Then check for it after including config-aix-4.x.h and remove +// ACE_HAS_AIO_CALLS if so. +#if !defined (ACE_HAS_AIO_CALLS) +# define _ACE_DISABLE_AIO_CALLS_ +#endif + +// Both IBM and g++ compilers set _THREAD_SAFE if compiler is asked to compile +// threaded code (xlC_r, as opposed to xlC; and g++ -pthread) +#if !defined (ACE_MT_SAFE) || (ACE_MT_SAFE != 0) +# if defined (ACE_HAS_THREADS) +# undef ACE_HAS_THREADS +# endif +# if defined (_THREAD_SAFE) +# define ACE_HAS_THREADS 1 +// # else +// # define ACE_HAS_THREADS 0 +# endif /* _THREAD_SAFE */ +#endif /* !ACE_MT_SAFE || (ACE_MT_SAFE != 0) */ + +#if defined (__xlC__) || defined (__IBMCPP__) + // AIX xlC, IBM C/C++, and Visual Age C++ compilers + //******************************************************************** + // + +// Compiler does this with a builtin - it's not in libc. +// Although ACE does have alloca() on this compiler/platform combination, it is +// disabled by default since it can be dangerous. Uncomment the following line +// if you ACE to use it. +//# define ACE_HAS_ALLOCA + +// Compiler supports the ssize_t typedef. +# define ACE_HAS_SSIZE_T + + // Keep an eye on this as the compiler and standards converge... +# define ACE_LACKS_LINEBUFFERED_STREAMBUF +# define ACE_LACKS_PRAGMA_ONCE + + // C Set++ 3.1, IBM C/C++ 3.6, and Visual Age C++ 5 batch (__xlC__) +# if defined (__xlC__) +# if (__xlC__ < 0x0500) +# define ACE_LACKS_PLACEMENT_OPERATOR_DELETE +# endif /* __xlC__ < 0x0500 */ +# endif + + // These are for Visual Age C++ only +# if defined (__IBMCPP__) && (__IBMCPP__ >= 600) +# define ACE_EXPLICIT_TEMPLATE_DESTRUCTOR_TAKES_ARGS + // When using -qtempinc, we don't need to see template implementation + // source (though we do need a pragma to find the correct source file). + // However, without -qtempinc (either -qnotempinc or -qtemplateregistry) + // we do need to see the source. +# if defined (__TEMPINC__) +# if !defined ACE_TEMPLATES_REQUIRE_PRAGMA +# define ACE_TEMPLATES_REQUIRE_PRAGMA +# endif +# else +# if !defined (ACE_TEMPLATES_REQUIRE_SOURCE) +# define ACE_TEMPLATES_REQUIRE_SOURCE +# endif +# endif /* __TEMPINC__ */ + +# undef WIFEXITED +# undef WEXITSTATUS +# define ACE_HAS_STANDARD_CPP_LIBRARY 1 +# define ACE_USES_STD_NAMESPACE_FOR_STDCPP_LIB 1 + +# if (__IBMCPP__ >= 600) /* Visual Age 6 and XL C/C++ 7 and up */ +# define ACE_HAS_TEMPLATE_TYPEDEFS +# define ACE_HAS_CUSTOM_EXPORT_MACROS +# define ACE_Proper_Export_Flag +# define ACE_Proper_Import_Flag +# define ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) extern template class SINGLETON_TYPE < CLASS, LOCK >; +# endif /* __IBMCPP__ >= 600 */ +# endif /* __IBMCPP__ */ + +#elif defined (__GNUG__) + // config-g++-common.h undef's ACE_HAS_STRING_CLASS with -frepo, so + // this must appear before its #include. +# define ACE_HAS_STRING_CLASS + +# include "ace/config-g++-common.h" + // Denotes that GNU has cstring.h as standard, to redefine memchr(). +# define ACE_HAS_GNU_CSTRING_H +# define ACE_HAS_SSIZE_T + +# if (__GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ == 0)) +// We have to explicitly instantiate static template members prior to g++ 4.1 +# define ACE_HAS_EXPLICIT_STATIC_TEMPLATE_MEMBER_INSTANTIATION +#endif /* g++ prior to 4.1 */ + +# if !defined (ACE_MT_SAFE) || ACE_MT_SAFE != 0 + // ACE_MT_SAFE is #defined below, for all compilers. +# if !defined (_REENTRANT) +# define _REENTRANT +# endif /* _REENTRANT */ +# endif /* !ACE_MT_SAFE */ + +#else /* ! __xlC__ && ! __GNUG__ */ +# ifdef __cplusplus /* Let it slide for C compilers. */ +# error unsupported compiler in ace/config-aix-5.x.h +# endif /* __cplusplus */ +#endif /* ! __xlC__ && ! __GNUG__ */ + +// Compiling for AIX. +#ifndef AIX +# define AIX +#endif /* AIX */ + +// Pick up all the detectable settings. +#include "ace/config-posix.h" + +// Regardless of what config-posix.h may indicate, AIX 5.3 is the first +// to support sem_timedwait(). Prior to that, use the emulation. +#if defined (ACE_HAS_POSIX_SEM_TIMEOUT) && \ + (defined (ACE_AIX_VERS) && (ACE_AIX_VERS < 503)) +# undef ACE_HAS_POSIX_SEM_TIMEOUT +#endif /* ACE_HAS_POSIX_SEM_TIMEOUT && ACE_AIX_VERS < 503 */ + +#if defined (ACE_DLL_SUFFIX) +# undef ACE_DLL_SUFFIX +#endif +#define ACE_DLL_SUFFIX ".so" + +#define ACE_DEFAULT_BASE_ADDR ((char *) 0x80000000) + +#define ACE_HAS_2_PARAM_ASCTIME_R_AND_CTIME_R + +#define ACE_HAS_SOCKLEN_T +#define ACE_HAS_4_4BSD_SENDMSG_RECVMSG + +// AIX has AIO, but the functions don't match those of other AIO-enabled +// platforms. If this is to work, it'll require some significant work, +// maybe moving the OS-abstraction stuff to an OS_AIO or some such thing. +//# define ACE_HAS_AIO_CALLS + +#define ACE_HAS_AIX_HI_RES_TIMER + +// Compiler/platform has correctly prototyped header files. +#define ACE_HAS_CPLUSPLUS_HEADERS + +// Prototypes for both signal() and struct sigaction are consistent. +#define ACE_HAS_CONSISTENT_SIGNAL_PROTOTYPES + +// OS has readdir and friends. +#define ACE_HAS_DIRENT + +// OS supports the getrusage() system call +#define ACE_HAS_GETRUSAGE + +#define ACE_HAS_GPERF + +#define ACE_HAS_H_ERRNO + +#define ACE_LACKS_STDINT_H +#define ACE_LACKS_SYS_SYSCTL_H + +#define ACE_HAS_HANDLE_SET_OPTIMIZED_FOR_SELECT +#define ACE_HAS_NONCONST_SELECT_TIMEVAL +#define ACE_HAS_IP_MULTICAST + +// Lacks perfect filtering, must bind group address. +#if !defined ACE_LACKS_PERFECT_MULTICAST_FILTERING +# define ACE_LACKS_PERFECT_MULTICAST_FILTERING 1 +#endif /* ACE_LACKS_PERFECT_MULTICAST_FILTERING */ + +#define ACE_HAS_MSG + +// Compiler/platform supports poll(). +#define ACE_HAS_POLL + +// Platform supports POSIX O_NONBLOCK semantics. +#define ACE_HAS_POSIX_NONBLOCK + +#define ACE_HAS_POSIX_TIME +// ... but needs to include another header for it on 4.2+ +# define ACE_HAS_BROKEN_POSIX_TIME +// ... and needs another typedef +#define ACE_LACKS_TIMESPEC_T +#define ACE_HAS_SELECT_H + +#define ACE_HAS_REENTRANT_FUNCTIONS + +// Compiler/platform defines the sig_atomic_t typedef +#define ACE_HAS_SIG_ATOMIC_T +#define ACE_HAS_SIGINFO_T +#define ACE_LACKS_SIGINFO_H +#define ACE_HAS_P_READ_WRITE + +#define ACE_HAS_SIGWAIT +#define ACE_HAS_SOCKADDR_IN_SIN_LEN +#define ACE_HAS_STRBUF_T + +// Compiler supports stropts.h +#define ACE_HAS_STREAMS +// #define ACE_HAS_STREAM_PIPES + +// Compiler/platform supports strerror (). +#define ACE_HAS_STRERROR + +// AIX bzero() +#define ACE_HAS_STRINGS + +#define ACE_HAS_STRUCT_NETDB_DATA + +// Dynamic linking is in good shape on newer OS/patch levels. If you have +// trouble with the dynamic linking parts of ACE, and can't patch your OS +// up to latest levels, comment this out. +#define ACE_HAS_SVR4_DYNAMIC_LINKING +// This is tightly related to dynamic linking... +#define ACE_HAS_AUTOMATIC_INIT_FINI + +#define ACE_HAS_SVR4_GETTIMEOFDAY + +#define ACE_HAS_SYSV_IPC +#define ACE_HAS_TIMOD_H +#define ACE_HAS_XTI +#define ACE_HAS_BROKEN_T_ERROR +#define ACE_TLI_TCP_DEVICE "/dev/xti/tcp" + +#define ACE_HAS_UALARM + +#define ACE_HAS_UCONTEXT_T + +#define ACE_HAS_UTIME + +// Platform has XPG4 wide character type and functions. However, the size +// of wchar_t changes for 32- vs. 64-bit builds (unsigned short vs. unsigned +// int, respectively). +#define ACE_HAS_XPG4_MULTIBYTE_CHAR +#ifdef __64BIT__ +# define ACE_SIZEOF_WCHAR 4 +#else +# define ACE_SIZEOF_WCHAR 2 +#endif /* __64BIT__ */ + +#define ACE_LACKS_NETINET_TCP_H + +// AIX uses LIBPATH to search for libraries +#define ACE_LD_SEARCH_PATH "LIBPATH" + +// Defines the page size of the system. +#define ACE_PAGE_SIZE 4096 + +//************************************************************** +// +// Threads related definitions. +// +// The threads on AIX are generally POSIX P1003.1c (ACE_HAS_PTHREADS). +// However, there is also a kernel thread ID (tid_t) that is used in +// ACE_Log_Msg (printing the thread ID). The tid_t is not the same as +// pthread_t, and can't derive one from the other - thread_self() gets +// the tid_t (kernel thread ID) if called from a thread. +// Thanks very much to Chris Lahey for straightening this out. + +#if defined (ACE_HAS_THREADS) +# if !defined (ACE_MT_SAFE) +# define ACE_MT_SAFE 1 +# endif + +# define ACE_HAS_PTHREADS +# define ACE_HAS_PTHREADS_UNIX98_EXT +# define ACE_HAS_PTHREAD_CONTINUE_NP +# define ACE_HAS_PTHREAD_SUSPEND_NP +# define ACE_HAS_RECURSIVE_MUTEXES +# define ACE_HAS_RECURSIVE_THR_EXIT_SEMANTICS +# define ACE_HAS_SIGTHREADMASK +# define ACE_HAS_THREAD_SPECIFIC_STORAGE + +# define ACE_LACKS_THREAD_PROCESS_SCOPING +#else +# undef ACE_HAS_THREADS +#endif /* ACE_HAS_THREADS != 0 */ + +#define ACE_MALLOC_ALIGN 8 + +#if (defined _XOPEN_SOURCE && (_XOPEN_SOURCE - 0) >= 500) && !defined(_UNIX95) +# define ACE_HAS_3_PARAM_WCSTOK +#endif /* (_XOPEN_SOURCE -0) >= 500 && !_UNIX95 */ + +#if defined (_ACE_DISABLE_AIO_CALLS_) +# if defined (ACE_HAS_AIO_CALLS) +# undef ACE_HAS_AIO_CALLS +# endif +# undef _ACE_DISABLE_AIO_CALLS_ +#endif + +// AIX's /usr/include/unistd.h sets _POSIX_SEMAPHORE to indicate the system +// supplies such a facility, but the headers don't enable it unless +// _XOPEN_SOURCE >= 500. So disable semaphores here if _XOPEN_SOURCE isn't +// up to snuff. +#if defined (ACE_HAS_POSIX_SEM) && \ + (!defined (_XOPEN_SOURCE) || (_XOPEN_SOURCE-0 < 500)) +# undef ACE_HAS_POSIX_SEM +#endif + +// I think this is correct, but needs to be verified... -Steve Huston +#define ACE_HAS_SIGTIMEDWAIT + +// AIX 5.1 has netinet/tcp.h +#undef ACE_LACKS_NETINET_TCP_H + +#define ACE_HAS_3_PARAM_READDIR_R +#define ACE_HAS_POSIX_GETPWNAM_R +#define ACE_HAS_SCANDIR +#define ACE_SCANDIR_CMP_USES_VOIDPTR +#define ACE_SCANDIR_SEL_LACKS_CONST +#define ACE_HAS_SIGSUSPEND +#define ACE_HAS_TIMEZONE /* Call tzset() to set timezone */ + +#endif /* ACE_CONFIG_AIX_5_X_H */ diff --git a/dep/ACE_wrappers/ace/config-all.h b/dep/ACE_wrappers/ace/config-all.h new file mode 100644 index 00000000000..2a57a7ee3f3 --- /dev/null +++ b/dep/ACE_wrappers/ace/config-all.h @@ -0,0 +1,89 @@ +// -*- C++ -*- + +//========================================================================== +/** + * @file config-all.h + * + * $Id: config-all.h 81661 2008-05-09 12:05:34Z johnnyw $ + * + * @author (Originally in OS.h)Doug Schmidt + * @author Jesper S. M|ller + * @author and a cast of thousands... + */ +//========================================================================== + +#ifndef ACE_CONFIG_ALL_H +#define ACE_CONFIG_ALL_H + +#include /**/ "ace/pre.h" + +#include "ace/config-lite.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +// This is used to indicate that a platform doesn't support a +// particular feature. +#if defined ACE_HAS_VERBOSE_NOTSUP + // Print a console message with the file and line number of the + // unsupported function. +# include "ace/OS_NS_stdio.h" +# define ACE_NOTSUP_RETURN(FAILVALUE) do { errno = ENOTSUP; ACE_OS::fprintf (stderr, ACE_TEXT ("ACE_NOTSUP: %s, line %d\n"), __FILE__, __LINE__); return FAILVALUE; } while (0) +# define ACE_NOTSUP do { errno = ENOTSUP; ACE_OS::fprintf (stderr, ACE_TEXT ("ACE_NOTSUP: %s, line %d\n"), __FILE__, __LINE__); return; } while (0) +#else /* ! ACE_HAS_VERBOSE_NOTSUP */ +# define ACE_NOTSUP_RETURN(FAILVALUE) do { errno = ENOTSUP ; return FAILVALUE; } while (0) +# define ACE_NOTSUP do { errno = ENOTSUP; return; } while (0) +#endif /* ! ACE_HAS_VERBOSE_NOTSUP */ + +// ---------------------------------------------------------------- + +# define ACE_TRACE_IMPL(X) ACE_Trace ____ (ACE_TEXT (X), __LINE__, ACE_TEXT (__FILE__)) + +// By default tracing is turned off. +#if !defined (ACE_NTRACE) +# define ACE_NTRACE 1 +#endif /* ACE_NTRACE */ + +#if (ACE_NTRACE == 1) +# define ACE_TRACE(X) +#else +# if !defined (ACE_HAS_TRACE) +# define ACE_HAS_TRACE +# endif /* ACE_HAS_TRACE */ +# define ACE_TRACE(X) ACE_TRACE_IMPL(X) +# include "ace/Trace.h" +#endif /* ACE_NTRACE */ + +// By default we perform no tracing on the OS layer, otherwise the +// coupling between the OS layer and Log_Msg is too tight. But the +// application can override the default if they wish to. +#if !defined (ACE_OS_NTRACE) +# define ACE_OS_NTRACE 1 +#endif /* ACE_OS_NTRACE */ + +#if (ACE_OS_NTRACE == 1) +# define ACE_OS_TRACE(X) +#else +# if !defined (ACE_HAS_TRACE) +# define ACE_HAS_TRACE +# endif /* ACE_HAS_TRACE */ +# define ACE_OS_TRACE(X) ACE_TRACE_IMPL(X) +# include "ace/Trace.h" +#endif /* ACE_OS_NTRACE */ + +#if !defined (ACE_HAS_MONITOR_FRAMEWORK) +# define ACE_HAS_MONITOR_FRAMEWORK 1 +#endif + +#if !defined (ACE_HAS_MONITOR_POINTS) +# define ACE_HAS_MONITOR_POINTS 0 +#endif + +// These includes are here to avoid circular dependencies. +// Keep this at the bottom of the file. It contains the main macros. +#include "ace/OS_main.h" + +#include /**/ "ace/post.h" + +#endif /* ACE_CONFIG_ALL_H */ diff --git a/dep/ACE_wrappers/ace/config-borland-common.h b/dep/ACE_wrappers/ace/config-borland-common.h new file mode 100644 index 00000000000..c57ddb07f36 --- /dev/null +++ b/dep/ACE_wrappers/ace/config-borland-common.h @@ -0,0 +1,66 @@ +// -*- C++ -*- +//$Id: config-borland-common.h 82294 2008-07-12 13:03:37Z johnnyw $ + +// The following configuration file contains defines for Borland compilers. + +#ifndef ACE_CONFIG_BORLAND_COMMON_H +#define ACE_CONFIG_BORLAND_COMMON_H +#include /**/ "ace/pre.h" + +#define ACE_HAS_CUSTOM_EXPORT_MACROS +#define ACE_Proper_Export_Flag __declspec (dllexport) +#define ACE_Proper_Import_Flag __declspec (dllimport) +#define ACE_EXPORT_SINGLETON_DECLARATION(T) template class __declspec (dllexport) T +#define ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) template class __declspec (dllexport) SINGLETON_TYPE; +#define ACE_IMPORT_SINGLETON_DECLARATION(T) template class __declspec (dllimport) T +#define ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) template class __declspec (dllimport) SINGLETON_TYPE ; + +// In later versions of C++Builder we will prefer inline functions by +// default. The debug configuration of ACE is built with functions +// out-of-line, so when linking your application against a debug ACE +// build, you can choose to use the out-of-line functions by adding +// ACE_NO_INLINE=1 to your project settings. +# if !defined (__ACE_INLINE__) +# define __ACE_INLINE__ 1 +# endif /* __ACE_INLINE__ */ + +# define ACE_CC_NAME ACE_TEXT ("Borland C++ Builder") +# define ACE_CC_MAJOR_VERSION (__BORLANDC__ / 0x100) +# define ACE_CC_MINOR_VERSION (__BORLANDC__ % 0x100) +# define ACE_CC_BETA_VERSION (0) + +# ifndef ACE_USING_MCPP_PREPROCESSOR +# define ACE_CC_PREPROCESSOR_ARGS "-q -P- -o%s" +# endif + +# define ACE_EXPORT_NESTED_CLASSES 1 +# define ACE_HAS_CPLUSPLUS_HEADERS 1 +# define ACE_HAS_EXCEPTIONS +# define ACE_HAS_GNU_CSTRING_H 1 +# define ACE_HAS_NONCONST_SELECT_TIMEVAL +# define ACE_HAS_SIG_ATOMIC_T +# define ACE_HAS_STANDARD_CPP_LIBRARY 1 +# define ACE_HAS_STDCPP_STL_INCLUDES 1 +# define ACE_HAS_STRERROR +# define ACE_HAS_STRING_CLASS 1 +# define ACE_HAS_TEMPLATE_TYPEDEFS 1 +# define ACE_HAS_USER_MODE_MASKS 1 +# define ACE_LACKS_ACE_IOSTREAM 1 +# define ACE_LACKS_LINEBUFFERED_STREAMBUF 1 +# define ACE_LACKS_STRPTIME 1 +# if (__BORLANDC__ < 0x590) +# define ACE_LACKS_PLACEMENT_OPERATOR_DELETE 1 +# endif +# define ACE_LACKS_PRAGMA_ONCE 1 +# define ACE_HAS_NEW_NOTHROW +# define ACE_TEMPLATES_REQUIRE_SOURCE 1 +# define ACE_SIZEOF_LONG_DOUBLE 10 +# define ACE_UINT64_FORMAT_SPECIFIER ACE_TEXT ("%Lu") +# define ACE_INT64_FORMAT_SPECIFIER ACE_TEXT ("%Ld") +# define ACE_USES_STD_NAMESPACE_FOR_STDCPP_LIB 1 +# define ACE_USES_STD_NAMESPACE_FOR_STDC_LIB 0 +# define ACE_ENDTHREADEX(STATUS) ::_endthreadex ((DWORD) STATUS) +# define ACE_LACKS_SWAB + +#include /**/ "ace/post.h" +#endif /* ACE_CONFIG_BORLAND_COMMON_H */ diff --git a/dep/ACE_wrappers/ace/config-cray.h b/dep/ACE_wrappers/ace/config-cray.h new file mode 100644 index 00000000000..28038b15b88 --- /dev/null +++ b/dep/ACE_wrappers/ace/config-cray.h @@ -0,0 +1,213 @@ +/* -*- C++ -*- */ +// $Id: config-cray.h 81935 2008-06-12 22:01:53Z jtc $ + +#ifndef ACE_CONFIG_CRAY_H +#define ACE_CONFIG_CRAY_H +#include /**/ "ace/pre.h" + +/* + The following predefined macros are used within ACE ifdefs. + These are defined when using the Cray compilers. _CRAYMPP + is defined, for example, if you are running on a Cray T3E + massively parallel machine. Moreover, in the case of the T3E, + _CRAYT3E will be defined. This is used to determine the + ACE_SIZEOF defines for primitive types. + + _UNICOS is defined as either the major version of UNICOS being run, + e.g. 9 or 10 on the vector machines (e.g. C90, T90, J90, YMP, ...) + or the major+minor+level UNICOS/mk version, e.g. 2.0.3 => 203, + being run on an MPP machine. + + Summary: + + _CRAYMPP (defined only if running on MPP machine, e.g. T3E, UNICOS/mk) + _CRAYT3E (defined specifically if compiling on a Cray T3E) + _UNICOS (defined if running UNICOS or UNICOS/mk) + + Tested on UNICOS 10.0.0.5, UNICOS/mk 2.0.4.57 + Compiles on UNICOS 9.0.2.8, but some tests deadlock + + Contributed by Doug Anderson +*/ + +#if defined (_UNICOS) && !defined (MAXPATHLEN) +#define MAXPATHLEN 1023 +#endif /* _UNICOS */ + +#define ACE_DEFAULT_CLOSE_ALL_HANDLES 0 + +// Defines the page size of the system. +#define ACE_PAGE_SIZE 4096 + +#define ACE_HAS_CPLUSPLUS_HEADERS + +#define ACE_HAS_SSIZE_T + +#define ACE_HAS_SYSV_IPC + +#define ACE_MT_SAFE 1 + +#define ACE_HAS_THREADS + +#define ACE_HAS_PTHREADS + +#define ACE_HAS_THREAD_SPECIFIC_STORAGE + +#define ACE_HAS_PTHREAD_MUTEXATTR_SETKIND_NP + +#define ACE_HAS_2_PARAM_ASCTIME_R_AND_CTIME_R + +#define ACE_HAS_POSIX_TIME + +#define ACE_HAS_TIMEZONE_GETTIMEOFDAY + +#define ACE_HAS_POSIX_NONBLOCK + +// Platform has POSIX terminal interface. +#define ACE_HAS_TERMIOS + +#define ACE_HAS_DIRENT + +#define ACE_HAS_HANDLE_SET_OPTIMIZED_FOR_SELECT + +#define ACE_HAS_IP_MULTICAST + +#define ACE_HAS_SOCKADDR_IN_SIN_LEN + +#define ACE_HAS_NONCONST_SELECT_TIMEVAL + +#define ACE_HAS_NONCONST_READLINK + +#define ACE_HAS_CHARPTR_SOCKOPT + +#define ACE_HAS_NONCONST_GETBY + +// has man pages, but links with missing symbols and I can't find lib yet +/* #define ACE_HAS_REGEX */ + +#define ACE_HAS_SIG_MACROS + +#define ACE_HAS_CONSISTENT_SIGNAL_PROTOTYPES + +#if _UNICOS > 9 +# define ACE_HAS_SIGWAIT +#endif + +#define ACE_HAS_SIG_ATOMIC_T + +#define ACE_HAS_SIGISMEMBER_BUG + +#define ACE_HAS_MSG + +#define ACE_HAS_STRERROR + +#define ACE_HAS_GPERF + +// Special modifications that apply to UNICOS/mk +#if defined(_CRAYMPP) + +# define ACE_HAS_SIGINFO_T +# define ACE_HAS_UCONTEXT_T + +#endif + +// The Cray T90 supposedly supports SYSV SHMEM, but I was unable to get it +// working. Of course, all other Cray PVP and MPP systems do NOT support it, +// so it's probably good to just define like this for consistency +#define ACE_LACKS_SYSV_SHMEM +#define ACE_LACKS_MMAP +#define ACE_LACKS_CONST_TIMESPEC_PTR +#define ACE_LACKS_SYSCALL +#define ACE_LACKS_STRRECVFD +#define ACE_LACKS_MADVISE +#define ACE_LACKS_NETDB_REENTRANT_FUNCTIONS +#define ACE_LACKS_LINEBUFFERED_STREAMBUF +#define ACE_LACKS_PTHREAD_CLEANUP +#define ACE_LACKS_CONDATTR_PSHARED +#define ACE_LACKS_THREAD_PROCESS_SCOPING + +#if !defined(_CRAYMPP) + +#define ACE_LACKS_PTHREAD_CANCEL +#define ACE_LACKS_PTHREAD_KILL + +#endif + +#define ACE_LACKS_MUTEXATTR_PSHARED +#define ACE_LACKS_RWLOCK_T +#define ACE_LACKS_PRI_T +#define ACE_LACKS_GETPGID +#define ACE_LACKS_SETPGID +#define ACE_LACKS_SETREGID +#define ACE_LACKS_SETREUID +#define ACE_LACKS_MPROTECT +#define ACE_LACKS_MSYNC +#define ACE_LACKS_READV +#define ACE_LACKS_RLIMIT + +// we probably want to fake not having this, since Cray memory mgmt is different +#define ACE_LACKS_SBRK + +#define ACE_LACKS_SETSCHED + +#define ACE_LACKS_SIGINFO_H + +#define ACE_LACKS_TIMESPEC_T + +#define ACE_LACKS_WRITEV + +// Cray vector machines are "word" oriented, and modern ones are hard 64-bit. +// "char" is somewhat of a special case. Most problems arise when code thinks +// it can address 32-bit quantities and the like. MPP crays are typically +// byte oriented, e.g. T3E uses Alpha processors, so we don't need as much +// special treatment. + +#ifndef _CRAYMPP + +# define ACE_SIZEOF_CHAR 1 +# define ACE_SIZEOF_SHORT 8 +# define ACE_SIZEOF_INT 8 +# define ACE_SIZEOF_LONG 8 +# define ACE_SIZEOF_LONG_LONG 8 +# define ACE_SIZEOF_FLOAT 8 +# define ACE_SIZEOF_DOUBLE 8 +# define ACE_SIZEOF_LONG_DOUBLE 16 +# define ACE_SIZEOF_VOID_P 8 + +#elif defined(_CRAYT3E) + +# define ACE_SIZEOF_CHAR 1 +# define ACE_SIZEOF_SHORT 4 +# define ACE_SIZEOF_INT 8 +# define ACE_SIZEOF_LONG 8 +# define ACE_SIZEOF_LONG_LONG 8 +# define ACE_SIZEOF_FLOAT 4 +# define ACE_SIZEOF_DOUBLE 8 +# define ACE_SIZEOF_LONG_DOUBLE 8 +# define ACE_SIZEOF_VOID_P 8 + +#endif + +// Ones to check out at some point + +/* #define ACE_HAS_SYS_SIGLIST */ + +// C++ Compiler stuff to verify +/* #define ACE_NEW_THROWS_EXCEPTIONS */ +/* #define ACE_HAS_TEMPLATE_TYPEDEFS */ + +// thread issues to check out +/* #define ACE_LACKS_TIMEDWAIT_PROTOTYPES */ + +// Cray does seem to support it, in -lnsl and has tiuser.h header +/* #define ACE_HAS_TLI */ +/* #define ACE_HAS_TIUSER_H */ +/* #define ACE_HAS_TLI_PROTOTYPES */ +/* #define ACE_LACKS_T_ERRNO */ + +/* #define ACE_LACKS_NAMED_POSIX_SEM */ + +/* #define ACE_HAS_SYS_ERRLIST */ + +#include /**/ "ace/post.h" +#endif /* ACE_CONFIG_CRAY_H */ diff --git a/dep/ACE_wrappers/ace/config-cxx-common.h b/dep/ACE_wrappers/ace/config-cxx-common.h new file mode 100644 index 00000000000..024c25fd27e --- /dev/null +++ b/dep/ACE_wrappers/ace/config-cxx-common.h @@ -0,0 +1,86 @@ +// -*- C++ -*- +// +// $Id: config-cxx-common.h 81935 2008-06-12 22:01:53Z jtc $ + +#ifndef ACE_CXX_COMMON_H +#define ACE_CXX_COMMON_H +#include /**/ "ace/pre.h" + +#if !defined (ACE_CONFIG_INCLUDE_CXX_COMMON) +# error ace/config-cxx-common.h: ACE configuration error! Do not #include this file directly! +#endif + +#if defined (__DECCXX) +# if !defined (linux) +# define ACE_HAS_STRING_CLASS +# if (__DECCXX_VER >= 60090010) +# define ACE_HAS_STDCPP_STL_INCLUDES +# endif /* __DECCXX_VER < 60090010 */ +# endif /* ! linux */ + +# define DEC_CXX +# define ACE_HAS_WORKING_EXPLICIT_TEMPLATE_DESTRUCTOR +# define ACE_LACKS_LINEBUFFERED_STREAMBUF +# define ACE_LACKS_SIGNED_CHAR +# define ACE_HAS_CPLUSPLUS_HEADERS +# define ACE_TEMPLATES_REQUIRE_SOURCE +# if (__DECCXX_VER >= 60090010) + // DEC CXX 6.0 supports exceptions, etc., by default. Exceptions + // are enabled by platform_osf1_4.x.GNU/wrapper_macros.GNU. +# if defined (ACE_HAS_EXCEPTIONS) +# define ACE_NEW_THROWS_EXCEPTIONS +# endif /* ACE_HAS_EXCEPTIONS */ +# define ACE_HAS_STANDARD_CPP_LIBRARY 1 +# define ACE_HAS_TEMPLATE_TYPEDEFS + +# define ACE_ENDLESS_LOOP \ + unsigned int ace_endless_loop____ = 0; if (ace_endless_loop____) break; + +# if defined (__USE_STD_IOSTREAM) +# define ACE_LACKS_CHAR_RIGHT_SHIFTS +# define ACE_LACKS_IOSTREAM_FX +# define ACE_LACKS_UNBUFFERED_STREAMBUF +# define ACE_USES_STD_NAMESPACE_FOR_STDCPP_LIB 1 +# else /* ! __USE_STD_IOSTREAM */ +# define ACE_USES_OLD_IOSTREAMS +# endif /* ! __USE_STD_IOSTREAM */ + +// 9: nested comment not allowed. (/usr/include/pdsc.h!) (nestcomment) +// 177: variable was declared but never referenced (declbutnotref) +// 193: zero used for undefined preprocessing identifier (undpreid) +// 236: controlling expression is constant (boolexprconst) +// 401: base_class_with_nonvirtual_dtor (basclsnondto) +// 1016: expected type is incompatible with declared type of int (incint) +// 1136: conversion to smaller size integer could lose data (intconlosbit) + +# pragma message disable basclsnondto +# pragma message disable boolexprconst +# pragma message disable undpreid +# pragma message disable notusetmpfunprm +# pragma message disable bltinclnk + +# if (__DECCXX_VER >= 60190029) + // 6.1-029 and later support msg 1136. Disable it because it + // causes warnings from ACE and/or TAO. +# pragma message disable intconlosbit +# endif /* __DECCXX_VER >= 60190029 */ + +# if (__DECCXX_VER == 60190027) + // Seems that this version of cxx doesn't have reset +# define ACE_AUTO_PTR_LACKS_RESET +# endif /* __DECCXX_VER == 60190027 */ + +# if defined (DIGITAL_UNIX) && DIGITAL_UNIX >= 0x40D + // variable "PTHREAD_THIS_CATCH_NP" was declared but never referenced +# pragma message disable declbutnotref +# endif /* DIGITAL_UNIX >= 4.0f */ + +# else /* __DECCXX_VER < 60090010 */ +# define ACE_LACKS_PRAGMA_ONCE +# endif /* __DECCXX_VER < 60090010 */ +#else /* ! __DECCXX */ +# error ace/config-cxx-common.h can only be used with Compaq CXX! +#endif /* ! __DECCXX */ + +#include /**/ "ace/post.h" +#endif /* ACE_CXX_COMMON_H */ diff --git a/dep/ACE_wrappers/ace/config-cygwin32.h b/dep/ACE_wrappers/ace/config-cygwin32.h new file mode 100644 index 00000000000..3dde027988e --- /dev/null +++ b/dep/ACE_wrappers/ace/config-cygwin32.h @@ -0,0 +1,206 @@ +/* -*- C++ -*- */ +// $Id: config-cygwin32.h 81809 2008-05-30 13:40:21Z vzykov $ + +// The following configuration file is designed to work for CygWin +// platforms using GNU C++. + +#ifndef ACE_CONFIG_CYGWIN32_H +#define ACE_CONFIG_CYGWIN32_H + +#include /**/ "ace/pre.h" + +#if !defined (ACE_MT_SAFE) +#define ACE_MT_SAFE 1 +#endif + +#define CYGWIN32 + +// We trust this file will get included before +#if !defined(FD_SETSIZE) +# define FD_SETSIZE 1024 +#endif + +#if !defined (ACE_IOV_MAX) +# define ACE_IOV_MAX 64 +#endif /* ACE_IOV_MAX */ + +// Define custom export macros for export/import of symbols from/of dll's +#define ACE_HAS_CUSTOM_EXPORT_MACROS +#define ACE_Proper_Export_Flag __declspec (dllexport) +#define ACE_Proper_Import_Flag __declspec (dllimport) +#define ACE_EXPORT_SINGLETON_DECLARATION(T) template class __declspec (dllexport) T +#define ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) template class __declspec (dllexport) SINGLETON_TYPE; +#define ACE_IMPORT_SINGLETON_DECLARATION(T) extern template class T +#define ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) extern template class SINGLETON_TYPE ; + +#define ACE_HAS_SELECT_H + +#define ACE_LACKS_PRAGMA_ONCE + +#if ! defined (__ACE_INLINE__) +# define __ACE_INLINE__ +#endif /* ! __ACE_INLINE__ */ + +#include /**/ + +// Needed to differentiate between libc 5 and libc 6 (aka glibc). +// It's there on all libc 5 systems I checked. +#include /**/ + +// config-g++-common.h undef's ACE_HAS_STRING_CLASS with -frepo, so +// this must appear before its #include. +#define ACE_HAS_STRING_CLASS + +#if defined (__GNUG__) +# include "ace/config-g++-common.h" +#else +# ifdef __cplusplus /* Let it slide for C compilers. */ +# error unsupported compiler in ace/config-cygwin32.h +# endif /* __cplusplus */ +#endif /* __GNUG__ */ + +#define ACE_HAS_VOIDPTR_SOCKOPT 1 +#define ACE_HAS_UALARM 1 +#define ACE_HAS_SYS_ERRLIST 1 +#define ACE_HAS_STRNLEN 1 +#define ACE_HAS_POSIX_GETPWNAM_R 1 +#define ACE_HAS_POSIX_NONBLOCK 1 +#define ACE_HAS_POSIX_TIME +#define ACE_HAS_CLOCK_GETTIME 1 +#define ACE_HAS_TIMEZONE_GETTIMEOFDAY +#define ACE_HAS_MSG +#define ACE_DEFAULT_BASE_ADDR ((char *) 0x8000000) +#define ACE_HAS_NONCONST_SELECT_TIMEVAL +#define ACE_HAS_SVR4_DYNAMIC_LINKING +//#define ACE_HAS_SYSV_IPC +#define ACE_HAS_VOIDPTR_MMAP +#define ACE_HAS_CPLUSPLUS_HEADERS +#define ACE_HAS_POLL +#define ACE_HAS_POSITION_INDEPENDENT_POINTERS 1 +#define ACE_HAS_SOCKADDR_MSG_NAME 1 +#define ACE_LACKS_PRI_T 1 +#define ACE_HAS_3_PARAM_READDIR_R + +// Compiler/platform supports alloca(). +// Although ACE does have alloca() on this compiler/platform combination, it is +// disabled by default since it can be dangerous. Uncomment the following line +// if you want ACE to use it. +//#define ACE_HAS_ALLOCA + +// Compiler/platform has the getrusage() system call. +#define ACE_HAS_GETRUSAGE + +#define ACE_HAS_CONSISTENT_SIGNAL_PROTOTYPES + +// Optimize ACE_Handle_Set for select(). +#define ACE_HAS_HANDLE_SET_OPTIMIZED_FOR_SELECT + +#define ACE_HAS_IP_MULTICAST + +#define ACE_HAS_BIG_FD_SET + +// Platform has POSIX terminal interface. +#define ACE_HAS_TERMIOS + +#define ACE_DEFAULT_MAX_SOCKET_BUFSIZ 65535 + +#define ACE_DEFAULT_SELECT_REACTOR_SIZE 256 + +#define ACE_HAS_GETPAGESIZE + +#define ACE_HAS_VOIDPTR_GETTIMEOFDAY + +// Compiler/platform supports strerror (). +#define ACE_HAS_STRERROR + +// Compiler supports the ssize_t typedef. +#define ACE_HAS_SSIZE_T + +#define ACE_HAS_SOCKLEN_T 1 + +#define ACE_HAS_GPERF + +#define ACE_HAS_DIRENT +#define ACE_HAS_4_4BSD_SENDMSG_RECVMSG + +#define ACE_LACKS_MKFIFO +#define ACE_LACKS_SIGINFO_H +#define ACE_LACKS_UCONTEXT_H +#define ACE_LACKS_STROPTS_H +#define ACE_LACKS_FGETWC 1 +#define ACE_LACKS_NAMED_POSIX_SEM +#define ACE_LACKS_STRRECVFD +#define ACE_LACKS_MADVISE +#define ACE_LACKS_GETPGID_PROTOTYPE +#define ACE_LACKS_GETHOSTENT +#define ACE_LACKS_ITOW 1 +#define ACE_LACKS_LINEBUFFERED_STREAMBUF 1 +#define ACE_LACKS_NETDB_REENTRANT_FUNCTIONS 1 +#define ACE_LACKS_RLIMIT +#define ACE_LACKS_RWLOCK_T 1 +#define ACE_LACKS_SUSECONDS_T +#define ACE_LACKS_SYS_SYSCTL_H + +#define ACE_LACKS_FGETWS 1 +#define ACE_LACKS_FPUTWS 1 + +#define ACE_LACKS_WCSTOULL 1 + +#define ACE_HAS_AUTOMATIC_INIT_FINI + +#define ACE_HAS_SIGWAIT +#define ACE_HAS_SIGINFO_T +#define ACE_HAS_SIGACTION_CONSTP2 +#define ACE_HAS_SIGSUSPEND +#define ACE_HAS_SIG_C_FUNC 1 +#define ACE_HAS_SIG_ATOMIC_T + +#define ACE_HAS_POSIX_SEM + +#define ACE_HAS_P_READ_WRITE + +#define ACE_HAS_2_PARAM_ASCTIME_R_AND_CTIME_R + +// Cygwin DLL suffix is .dll +#define ACE_DLL_SUFFIX ACE_TEXT (".dll") + +// Cygwin runs on Windows, so we have to get the environment variable PATH and +// not LD_LIBRARY_PATH which is the default in ACE +#define ACE_LD_SEARCH_PATH ACE_TEXT ("PATH") + +#if ACE_MT_SAFE +// Yes, we do have threads. +# define ACE_HAS_THREADS +// And they're even POSIX pthreads (LinuxThreads implementation) +# define ACE_HAS_PTHREADS + +# define ACE_HAS_RECURSIVE_THR_EXIT_SEMANTICS + +// Compiler/platform has thread-specific storage +# define ACE_HAS_THREAD_SPECIFIC_STORAGE + +# define ACE_HAS_PTHREADS_UNIX98_EXT +# define ACE_HAS_PTHREAD_CONTINUE 1 +# define ACE_HAS_PTHREAD_SUSPEND 1 + +# define ACE_LACKS_PTHREAD_ATTR_SETSTACKADDR +// Cygwin (see pthread.h): Not supported or implemented. +# define ACE_LACKS_SETSCHED +# define ACE_LACKS_SETDETACH +# define ACE_LACKS_PTHREAD_CANCEL +# define ACE_LACKS_THREAD_PROCESS_SCOPING +# define ACE_LACKS_MUTEXATTR_PSHARED +# define ACE_LACKS_RWLOCKATTR_PSHARED +# define ACE_LACKS_PTHREAD_THR_SIGSETMASK 1 +# define ACE_LACKS_PTHREAD_YIELD 1 +# define ACE_LACKS_PTHREAD_ATTR_SETSTACK + +// In the 1.5.9 release of Cygwin the pthread_kill gives an access violation +// so for the time being we say Cygwin doesn't support pthread_kill. +# define ACE_LACKS_PTHREAD_KILL + +#endif /* ACE_MT_SAFE */ + +#include /**/ "ace/post.h" + +#endif /* ACE_CONFIG_CYGWIN32_H */ diff --git a/dep/ACE_wrappers/ace/config-doxygen.h b/dep/ACE_wrappers/ace/config-doxygen.h new file mode 100644 index 00000000000..2bc89c982fa --- /dev/null +++ b/dep/ACE_wrappers/ace/config-doxygen.h @@ -0,0 +1,120 @@ +// -*- C++ -*- + +/** + * This is a configuration file to define all the macros that Doxygen + * needs + * + * @file config-doxygen.h + * + * $Id: config-doxygen.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Carlos O'Ryan + * @author Darrell Brunsch + * + */ +#ifndef ACE_CONFIG_DOXYGEN_H +#define ACE_CONFIG_DOXYGEN_H + +/// Make sure that we always turn inlining on. +#define __ACE_INLINE__ + +/// Make the wchar_t interfaces available. +#define ACE_HAS_WCHAR + +/// Make all the emulation versions of string operations visible +// #define ACE_LACKS_WCSTOK +#define ACE_LACKS_ITOW +#define ACE_LACKS_STRCASECMP +#define ACE_LACKS_STRRCHR +#define ACE_LACKS_WCSCAT +#define ACE_LACKS_WCSCHR +#define ACE_LACKS_WCSCMP +#define ACE_LACKS_WCSCPY +#define ACE_LACKS_WCSICMP +#define ACE_LACKS_WCSLEN +#define ACE_LACKS_WCSNCAT +#define ACE_LACKS_WCSNCMP +#define ACE_LACKS_WCSNCPY +#define ACE_LACKS_WCSNICMP +#define ACE_LACKS_WCSPBRK +#define ACE_LACKS_WCSRCHR +#define ACE_LACKS_WCSCSPN +#define ACE_LACKS_WCSSPN +#define ACE_LACKS_WCSSTR + +/// Support for threads enables several important classes +#define ACE_HAS_THREADS + +/// Support for Win32 enables the WFMO_Reactor and several Async I/O +/// classes +#define ACE_WIN32 + +/// Enable support for POSIX Asynchronous I/O calls +#define ACE_HAS_AIO_CALLS + +/// Enable support for TLI interfaces +#define ACE_HAS_TLI + +/// Enable support for the SSL wrappers +#define ACE_HAS_SSL 1 + +/// Enable exceptions +#define ACE_HAS_EXCEPTIONS + +/// Enable timeprobes +#define ACE_COMPILE_TIMEPROBES + +/// Enable unicode to generate ACE_Registry_Name_Space +#define UNICODE + +/// These defines make sure that Svc_Conf_y.cpp and Svc_Conf_l.cpp are correctly +/// parsed +#define __cplusplus +#define ACE_YY_USE_PROTOS + +/// TAO features that should be documented too +#define TAO_HAS_RT_CORBA 1 +#define TAO_HAS_MINIMUM_CORBA 0 +#define TAO_HAS_AMI 1 +#define TAO_HAS_INTERCEPTORS 1 +#define TAO_HAS_SCIOP 1 +#define TAO_HAS_COIOP 1 +#define TAO_HAS_TRANSPORT_CURRENT 1 + +/// Generate token library documentation +#define ACE_HAS_TOKENS_LIBRARY + +/// Generate ACE ATM classes documentation +#define ACE_HAS_ATM + +/// Generate ACE XTI ATM class documentation +#define ACE_HAS_XTI_ATM + +/// Generate ACE_Dev_Poll_Reactor documentation +#define ACE_HAS_DEV_POLL + +/// Generate ACE_Event_Handler_T documentation +#define ACE_HAS_TEMPLATE_TYPEDEFS + +/// Generate ACE_Log_Msg_NT_Event_Log documentation +#define ACE_HAS_LOG_MSG_NT_EVENT_LOG + +/// Generate icmp documentation +#define ACE_HAS_ICMP_SUPPORT 1 + +/// Don't expand ACE_RCSID macro +#define ACE_USE_RCSID 0 + +/// Parse some ACE_SSL classes that depend on recent versions of +/// OpenSSL. +#define OPENSSL_VERSION_NUMBER 0x00905820L + +/// Enable IPv6 +#define ACE_HAS_IPV6 + +/// Enable netlink socket support +#define ACE_HAS_NETLINK + +#define ACE_HAS_IP_MULTICAST + +#endif /* ACE_CONFIG_DOXYGEN_H */ diff --git a/dep/ACE_wrappers/ace/config-freebsd.h b/dep/ACE_wrappers/ace/config-freebsd.h new file mode 100644 index 00000000000..3461bec8d81 --- /dev/null +++ b/dep/ACE_wrappers/ace/config-freebsd.h @@ -0,0 +1,284 @@ +/* -*- C++ -*- */ +// $Id: config-freebsd.h 80826 2008-03-04 14:51:23Z wotte $ + +// The following configuration file is designed to work for FreeBSD + +#ifndef ACE_CONFIG_H +#define ACE_CONFIG_H +#include /**/ "ace/pre.h" + +#if !defined (ACE_MT_SAFE) +# define ACE_MT_SAFE 1 +#endif + +#if ACE_MT_SAFE + // Yes, we do have threads. +# define ACE_HAS_THREADS 1 +#else + // Set to 0 since that's what config-posix.h checks for. +# define ACE_HAS_THREADS 0 +#endif /* ACE_MT_SAFE */ + +#include "ace/config-posix.h" + +#include +// Make sure we source in the OS version. + +#if ! defined (__ACE_INLINE__) +#define __ACE_INLINE__ +#endif /* ! __ACE_INLINE__ */ + +#if (__FreeBSD_version < 220000) +#if defined (ACE_HAS_THREADS) +#error Threads are not supported. +#endif /* ACE_HAS_THREADS */ +#endif /* __FreeBSD_version < 220000 */ + +#if defined (__GNUG__) +# include "ace/config-g++-common.h" +#endif /* __GNUG__ */ + +#if defined (ACE_HAS_PENTIUM) +# undef ACE_HAS_PENTIUM +#endif /* ACE_HAS_PENTIUM */ + +// Platform specific directives +// gcc defines __FreeBSD__ automatically for us. +#ifdef ACE_HAS_THREADS +#if !defined (_THREAD_SAFE) +#define _THREAD_SAFE +#endif /* _THREAD_SAFE */ +#endif + +#define ACE_HAS_GPERF + +#if (__FreeBSD_version < 420000) +#define ACE_LACKS_GETPGID +#define ACE_LACKS_SETPGID +#define ACE_LACKS_SETREGID +#define ACE_LACKS_SETREUID +#define ACE_LACKS_PTHREAD_CANCEL +#endif /* __FreeBSD_version < 420000 */ + +#define ACE_HAS_ALT_CUSERID +#define ACE_HAS_RECURSIVE_THR_EXIT_SEMANTICS +#define ACE_HAS_SIG_MACROS +// Optimize ACE_Handle_Set for select(). +#define ACE_HAS_HANDLE_SET_OPTIMIZED_FOR_SELECT +#define ACE_HAS_NONCONST_SELECT_TIMEVAL +#define ACE_HAS_CHARPTR_DL + +#if (__FreeBSD_version < 400000) +#define ACE_LACKS_SIGSET +#define ACE_LACKS_RWLOCK_T +#define ACE_LACKS_READDIR_R +#define ACE_LACKS_SETSCHED +#define ACE_LACKS_PTHREAD_THR_SIGSETMASK +#define ACE_LACKS_UCONTEXT_H +#define ACE_LACKS_RAND_REENTRANT_FUNCTIONS +#endif + +#define ACE_NEEDS_SCHED_H + +#if (__FreeBSD_version < 400000) +enum schedparam_policy { + SCHED_RR, + SCHED_IO, + SCHED_FIFO, + SCHED_OTHER +}; +#endif + +// Use of is deprecated. +#define ACE_LACKS_MALLOC_H + + +// This won't be necessary after it is fixed in the system include headers. +extern "C" { char * cuserid (char *s); } + +// Platform supports POSIX timers via struct timespec. +#define ACE_HAS_POSIX_TIME +#define ACE_HAS_UALARM + +// Platform defines struct timespec but not timespec_t +#define ACE_LACKS_TIMESPEC_T + +#if (__FreeBSD_version < 501000) +#define ACE_LACKS_STDINT_H +#endif + +#define ACE_HAS_SYSCTL +#define ACE_LACKS_STRRECVFD + +#define ACE_HAS_SOCKADDR_IN_SIN_LEN +#define ACE_HAS_SOCKADDR_IN6_SIN6_LEN + +// Platform supports System V IPC (most versions of UNIX, but not Win32) +#define ACE_HAS_SYSV_IPC + +// Compiler/platform contains the file. +#define ACE_HAS_SYS_SYSCALL_H + +#if (__FreeBSD_version >= 220000) +#define ACE_HAS_VASPRINTF +#endif + +#if (__FreeBSD_version >= 300000) +#define ACE_HAS_SIGINFO_T +#endif /* __FreeBSD_version >= 300000 */ + +#if (__FreeBSD_version >= 320000) +#define ACE_HAS_REENTRANT_FUNCTIONS +#define ACE_LACKS_NETDB_REENTRANT_FUNCTIONS +#define ACE_HAS_2_PARAM_ASCTIME_R_AND_CTIME_R +#endif /* __FreeBSD_version >= 320000 */ + +#if (__FreeBSD_version >= 440000) +#define ACE_HAS_GETPROGNAME +#define ACE_HAS_SETPROGNAME +#endif + +#if (__FreeBSD_version < 501000) +#define ACE_LACKS_PWD_REENTRANT_FUNCTIONS +#endif + +#define ACE_HAS_CONSISTENT_SIGNAL_PROTOTYPES +#define ACE_LACKS_SIGINFO_H +#define ACE_LACKS_LOG2 +#define ACE_LACKS_SI_ADDR + +// Compiler/platform supports SVR4 signal typedef +#define ACE_HAS_SVR4_SIGNAL_T + +// Compiler/platform supports alloca(). +// Although ACE does have alloca() on this compiler/platform combination, it is +// disabled by default since it can be dangerous. Uncomment the following line +// if you ACE to use it. +//#define ACE_HAS_ALLOCA + +// Compiler/platform supports SVR4 dynamic linking semantics.. +#define ACE_HAS_SVR4_DYNAMIC_LINKING + +// Compiler/platform correctly calls init()/fini() for shared libraries. +#define ACE_HAS_AUTOMATIC_INIT_FINI + +// Explicit dynamic linking permits "lazy" symbol resolution +#define ACE_HAS_RTLD_LAZY_V + +// platform supports POSIX O_NONBLOCK semantics +#define ACE_HAS_POSIX_NONBLOCK + +// platform supports IP multicast +#define ACE_HAS_IP_MULTICAST + +// Lacks perfect filtering, must bind group address. +#if !defined ACE_LACKS_PERFECT_MULTICAST_FILTERING +# define ACE_LACKS_PERFECT_MULTICAST_FILTERING 1 +#endif /* ACE_LACKS_PERFECT_MULTICAST_FILTERING */ + +// Compiler/platform has +//#define ACE_HAS_ALLOCA_H + +// Compiler/platform has the getrusage() system call. +#define ACE_HAS_GETRUSAGE + +// Compiler/platform defines the sig_atomic_t typedef. +#define ACE_HAS_SIG_ATOMIC_T + +// Compiler/platform supports sys_siglist array. +// *** This refers to (_sys_siglist) instead of (sys_siglist) +// #define ACE_HAS_SYS_SIGLIST + +// Compiler/platform defines a union semun for SysV shared memory. +#define ACE_HAS_SEMUN + +// Compiler supports the ssize_t typedef. +#define ACE_HAS_SSIZE_T + +// Compiler/platform supports strerror (). +#define ACE_HAS_STRERROR + +// Compiler/platform provides the sockio.h file. +#define ACE_HAS_SYS_SOCKIO_H + +// Defines the page size of the system. +#define ACE_PAGE_SIZE 4096 + +// Platform provides header. +#define ACE_HAS_SYS_FILIO_H + +// Platform/compiler supports timezone * as second parameter to gettimeofday(). +#define ACE_HAS_TIMEZONE_GETTIMEOFDAY + +#define ACE_HAS_MSG +#define ACE_HAS_4_4BSD_SENDMSG_RECVMSG + +#if (__FreeBSD_version < 500100) +# define ACE_HAS_NONCONST_MSGSND +#endif + +// Thread specific settings +// Yes, we do have threads. +#ifdef ACE_HAS_THREADS +#if !defined (ACE_MT_SAFE) +# define ACE_MT_SAFE 1 +#endif /* ! ACE_MT_SAFE */ +#endif /* ACE_HAS_THREADS */ + +#define ACE_LACKS_THREAD_PROCESS_SCOPING +#define ACE_LACKS_CONDATTR_PSHARED +#define ACE_LACKS_MUTEXATTR_PSHARED +#define ACE_HAS_THREAD_SPECIFIC_STORAGE +#define ACE_HAS_DIRENT + +#define ACE_HAS_SIGWAIT + +// Platform has POSIX terminal interface. +#define ACE_HAS_TERMIOS + +#if (__FreeBSD_version > 400000) +#define ACE_HAS_UCONTEXT_T +#define ACE_HAS_SOCKLEN_T +#define ACE_HAS_GETIFADDRS +#define ACE_HAS_PTHREADS_UNIX98_EXT +#endif + +// Note, on FreeBSD 5, POSIX aio is now an optional kernel module which +// must be loaded. +// Read the aio(4) man page for what to do, otherwise any aio_* call +// will coredump. + +// By default use Proactor which does not use POSIX Real-time Signals. +#ifdef ACE_HAS_AIO_CALLS +# ifndef ACE_POSIX_AIOCB_PROACTOR +# define ACE_POSIX_AIOCB_PROACTOR +# endif /* ACE_POSIX_AIOCB_PROACTOR */ +#endif /* ACE_HAS_AIO_CALLS */ + +#define ACE_LACKS_STROPTS_H + +// Needed when ACE_HAS_WCHAR is defined. +#define ACE_LACKS_WCSNICMP +#define ACE_LACKS_WCSICMP +#define ACE_LACKS_WCSDUP +#define ACE_LACKS_ITOW +#define ACE_HAS_3_PARAM_WCSTOK +#define ACE_HAS_3_PARAM_READDIR_R + +#if (__FreeBSD_version >= 501000) +# define ACE_HAS_PTHREAD_SETSTACK +#endif + +#if (__FreeBSD_version < 700007) +# define ACE_HAS_SIGVAL_SIGVAL_INT +# define ACE_HAS_BROKEN_SIGEVENT_STRUCT +#endif + +#if (__FreeBSD_version >= 700028) +# define ACE_HAS_SCTP +# define ACE_HAS_LKSCTP +#endif + +#include /**/ "ace/post.h" + +#endif /* ACE_CONFIG_H */ diff --git a/dep/ACE_wrappers/ace/config-g++-common.h b/dep/ACE_wrappers/ace/config-g++-common.h new file mode 100644 index 00000000000..8ac8eb9748f --- /dev/null +++ b/dep/ACE_wrappers/ace/config-g++-common.h @@ -0,0 +1,136 @@ +// -*- C++ -*- +// +// $Id: config-g++-common.h 82495 2008-08-04 07:23:01Z johnnyw $ + +// This configuration file is designed to be included by another, +// specific configuration file. It provides config information common +// to all g++ platforms, including egcs. + +#ifndef ACE_GNUG_COMMON_H +#define ACE_GNUG_COMMON_H +#include /**/ "ace/pre.h" + +#define ACE_HAS_CPLUSPLUS_HEADERS +#define ACE_HAS_STDCPP_STL_INCLUDES +#define ACE_HAS_TEMPLATE_TYPEDEFS +#define ACE_HAS_STANDARD_CPP_LIBRARY 1 +#define ACE_HAS_WORKING_EXPLICIT_TEMPLATE_DESTRUCTOR +#define ACE_USES_STD_NAMESPACE_FOR_STDCPP_LIB 1 +#define ACE_TEMPLATES_REQUIRE_SOURCE + +#if ( __GNUC__ == 2 && __GNUC_MINOR__ < 97 ) + // gcc 2.97 and lower use old iostreams +# define ACE_USES_OLD_IOSTREAMS +#endif /* __GNUC__ >= 2.97 */ + +#if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) +# define ACE_EXPLICIT_TEMPLATE_DESTRUCTOR_TAKES_ARGS +#endif /* __GNUC__ >= 3.4 */ + +#if (__GNUC__ < 3) +# define ACE_LACKS_MEMBER_TEMPLATES +#endif /* __GNUC__ < 3 */ + +// __EXCEPTIONS is defined with -fexceptions, the egcs default. It +// is not defined with -fno-exceptions, the ACE default for g++. +// ACE_HAS_EXCEPTIONS is defined in +// include/makeinclude/wrapper_macros.GNU, so this really isn't +// necessary. Just in case . . . +#if defined (__EXCEPTIONS) && !defined (ACE_HAS_EXCEPTIONS) +# define ACE_HAS_EXCEPTIONS +#endif /* __EXCEPTIONS && ! ACE_HAS_EXCEPTIONS */ + +#if defined (ACE_HAS_EXCEPTIONS) +# define ACE_NEW_THROWS_EXCEPTIONS +# if (__GNUC__ >= 4 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3)) +// Versions of g++ prior to 3.3 had a buggy operator // new(nothrow)[](). +# define ACE_HAS_NEW_NOTHROW +# endif /* __GNUC__ >= 3.3 */ +#endif /* ACE_HAS_EXCEPTIONS */ + +#if (defined (i386) || defined (__i386__)) && !defined (ACE_SIZEOF_LONG_DOUBLE) +# define ACE_SIZEOF_LONG_DOUBLE 12 +#endif /* i386 */ + +#if !defined (__MINGW32__) && (defined (i386) || defined (__i386__)) + // If running an Intel, assume that it's a Pentium so that + // ACE_OS::gethrtime () can use the RDTSC instruction. If running a + // 486 or lower, be sure to comment this out. (If not running an + // Intel CPU, this #define will not be seen because of the i386 + // protection, so it can be ignored.) +# define ACE_HAS_PENTIUM +#endif /* i386 */ + +#if (defined (ACE_HAS_PENTIUM) || defined (__amd64__) || defined (__x86_64__)) +# define ACE_HAS_INTEL_ASSEMBLY +#endif + +// GNU g++ >= 4.x implements "#pragma once". +#if (__GNUC__ < 4) && !defined (ACE_LACKS_PRAGMA_ONCE) +// We define it with a -D with make depend. +# define ACE_LACKS_PRAGMA_ONCE +#endif /* ! ACE_LACKS_PRAGMA_ONCE */ + +// Take advantage of G++ (>= 4.x) visibility attributes to generate +// improved shared library binaries. +#if (__GNUC__ >= 4) && !defined (__MINGW32__) + +# if defined (ACE_HAS_CUSTOM_EXPORT_MACROS) && ACE_HAS_CUSTOM_EXPORT_MACROS == 0 +# undef ACE_HAS_CUSTOM_EXPORT_MACROS +# if defined (ACE_GCC_HAS_TEMPLATE_INSTANTIATION_VISIBILITY_ATTRS) +# undef ACE_GCC_HAS_TEMPLATE_INSTANTIATION_VISIBILITY_ATTRS +# endif /* ACE_GCC_HAS_TEMPLATE_INSTANTIATION_VISIBILITY_ATTRS */ +# define ACE_GCC_HAS_TEMPLATE_INSTANTIATION_VISIBILITY_ATTRS 0 +# else +# ifndef ACE_HAS_CUSTOM_EXPORT_MACROS +# define ACE_HAS_CUSTOM_EXPORT_MACROS +# endif /* !ACE_HAS_CUSTOM_EXPORT_MACROS */ +# define ACE_Proper_Export_Flag __attribute__ ((visibility("default"))) +# define ACE_Proper_Import_Flag __attribute__ ((visibility("default"))) + +# if (__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 2)) +// Sadly, G++ 4.x silently ignores visibility attributes on +// template instantiations, which breaks singletons. +// As a workaround, we use the GCC visibility pragmas. +// And to make them fit in a macro, we use C99's _Pragma() +// http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17470 +// This has been fixed in GCC 4.1.1 with FC6 but not with SuSE 10.2 +// that gets shipped with GCC 4.1.2 so we assume that with GCC 4.2 +// this will be fixed on the head. With FC6 just set this define yourself +# ifndef ACE_GCC_HAS_TEMPLATE_INSTANTIATION_VISIBILITY_ATTRS +# define ACE_GCC_HAS_TEMPLATE_INSTANTIATION_VISIBILITY_ATTRS 1 +# endif +# endif + +# if defined (ACE_GCC_HAS_TEMPLATE_INSTANTIATION_VISIBILITY_ATTRS) && ACE_GCC_HAS_TEMPLATE_INSTANTIATION_VISIBILITY_ATTRS == 1 +# define ACE_EXPORT_SINGLETON_DECLARATION(T) template class ACE_Proper_Export_Flag T +# define ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) template class ACE_Proper_Export_Flag SINGLETON_TYPE ; +# else /* ACE_GCC_HAS_TEMPLATE_INSTANTIATION_VISIBILITY_ATTRS */ +# define ACE_EXPORT_SINGLETON_DECLARATION(T) \ + _Pragma ("GCC visibility push(default)") \ + template class T \ + _Pragma ("GCC visibility pop") +# define ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) \ + _Pragma ("GCC visibility push(default)") \ + template class SINGLETON_TYPE; \ + _Pragma ("GCC visibility pop") +# endif /* ACE_GCC_HAS_TEMPLATE_INSTANTIATION_VISIBILITY_ATTRS */ + +// Note that the "__extension__" is needed to prevent g++ from issuing +// an error when using its "-pedantic" command line flag. +# define ACE_IMPORT_SINGLETON_DECLARATION(T) __extension__ extern template class T +# define ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) __extension__ extern template class SINGLETON_TYPE; + +# endif /* ACE_HAS_CUSTOM_EXPORT_MACROS == 0 */ +#endif /* __GNU__ >= 4 */ + +#if defined (ACE_HAS_GNU_REPO) + // -frepo causes unresolved symbols of basic_string left- and + // right-shift operators with ACE_HAS_STRING_CLASS. +# if defined (ACE_HAS_STRING_CLASS) +# undef ACE_HAS_STRING_CLASS +# endif /* ACE_HAS_STRING_CLASS */ +#endif /* ! ACE_HAS_GNU_REPO */ + +#include /**/ "ace/post.h" +#endif /* ACE_GNUG_COMMON_H */ diff --git a/dep/ACE_wrappers/ace/config-ghs-common.h b/dep/ACE_wrappers/ace/config-ghs-common.h new file mode 100644 index 00000000000..ffa554c047e --- /dev/null +++ b/dep/ACE_wrappers/ace/config-ghs-common.h @@ -0,0 +1,43 @@ +/* -*- C++ -*- */ +// $Id: config-ghs-common.h 80826 2008-03-04 14:51:23Z wotte $ + +// This configuration file is designed to be included by another, +// specific configuration file. It provides config information common +// to all Green Hills platforms. + +#ifndef ACE_GHS_COMMON_H +#define ACE_GHS_COMMON_H +#include /**/ "ace/pre.h" + +#if !defined (ACE_CONFIG_INCLUDE_GHS_COMMON) +# error ace/config-ghs-common.h: ACE configuration error! Do not #include this file directly! +#endif + +#if defined (ghs) + +# if defined (sun) + // Need nonstatic Object_Manager on Solaris to prevent seg fault + // on startup. +# define ACE_HAS_NONSTATIC_OBJECT_MANAGER +# endif /* sun */ + +# if defined (__STANDARD_CXX) + // Green Hills 1.8.9, but not 1.8.8. +# define ACE_HAS_STANDARD_CPP_LIBRARY 1 +# define ACE_LACKS_AUTO_PTR +# define ACE_LACKS_CHAR_RIGHT_SHIFTS +# define ACE_LACKS_UNBUFFERED_STREAMBUF +# else +# define ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA +# endif /* __STANDARD_CXX */ + +# define ACE_LACKS_LINEBUFFERED_STREAMBUF +# define ACE_LACKS_LONGLONG_T +# define ACE_LACKS_SIGNED_CHAR + +#else /* ! ghs */ +# error ace/config-ghs-common.h can only be used with Green Hills compilers! +#endif /* ! ghs */ + +#include /**/ "ace/post.h" +#endif /* ACE_GHS_COMMON_H */ diff --git a/dep/ACE_wrappers/ace/config-hpux-11.00.h b/dep/ACE_wrappers/ace/config-hpux-11.00.h new file mode 100644 index 00000000000..3af693e3eb3 --- /dev/null +++ b/dep/ACE_wrappers/ace/config-hpux-11.00.h @@ -0,0 +1,449 @@ +/* -*- C++ -*- */ +// $Id: config-hpux-11.00.h 81992 2008-06-16 19:09:50Z wotte $ + +// The following configuration file is designed to work for HP +// platforms running HP-UX 11.00 using aC++ or gcc (2.95 and up). + +#ifndef ACE_CONFIG_H +#define ACE_CONFIG_H +#include /**/ "ace/pre.h" + +#define ACE_LACKS_STDINT_H +#define ACE_LACKS_SYS_SELECT_H + +#if defined (__GNUG__) + +// config-g++-common.h undef's ACE_HAS_STRING_CLASS with -frepo, so +// this must appear before its #include. +# define ACE_HAS_STRING_CLASS + +# include "ace/config-g++-common.h" + +#else + +// aC++... + +// Precompiler needs extra flags to ignore "invalid #pragma directive" +# ifndef ACE_USING_MCPP_PREPROCESSOR +# define ACE_CC_PREPROCESSOR_ARGS "-E +W 67" +# endif +// Compiler supports C++ exception handling. It's on by default. If the +// +noeh compiler option is used to disable exceptions, the compiler defines +// __HPACC_NOEH. +# if !defined (__HPACC_NOEH) +# define ACE_HAS_EXCEPTIONS 1 +# endif + +// If the -AA compile option is used, the compiler defines _HP_NAMESPACE_STD. +// The -AA option enables the 2.0 standard C++ library. If not used, then +// we have the old, 1.2.1 C++ library. +# if defined (_HP_NAMESPACE_STD) +# if defined (ACE_HAS_STANDARD_CPP_LIBRARY) +# undef ACE_HAS_STANDARD_CPP_LIBRARY +# endif +# define ACE_HAS_STANDARD_CPP_LIBRARY 1 +# if defined (ACE_USES_STD_NAMESPACE_FOR_STDCPP_LIB) +# undef ACE_USES_STD_NAMESPACE_FOR_STDCPP_LIB +# endif +# if defined (RWSTD_NO_NAMESPACE) + namespace std {} using namespace std; +# else +# define ACE_USES_STD_NAMESPACE_FOR_STDCPP_LIB 1 +# endif /* RWSTD_NO_NAMESPACE */ +# else +# define ACE_USES_OLD_IOSTREAMS + // There's no support in ACE's use of numeric_limits for those that + // aren't in std:: +# define ACE_LACKS_NUMERIC_LIMITS +# endif /* _HP_NAMESPACE_STD */ + +// Compiler implements templates that support typedefs inside of classes +// used as formal arguments to a template class. +# define ACE_HAS_TEMPLATE_TYPEDEFS + +# define ACE_HAS_WORKING_EXPLICIT_TEMPLATE_DESTRUCTOR + +// Platform lacks streambuf "linebuffered ()". +# define ACE_LACKS_LINEBUFFERED_STREAMBUF 1 + +// Lack of (and broken) support for placement operator delete is a known +// bug by HP, up until aC++ A.03.55.02. +# if (__HP_aCC < 35502) +# define ACE_LACKS_PLACEMENT_OPERATOR_DELETE +# endif /* __HP_aCC < 35502 */ + +// Compiler's 'new' throws exceptions on failure, regardless of whether or +// not exception handling is enabled in the compiler options. Fortunately, +// new(nothrow_t) is offered. +# define ACE_NEW_THROWS_EXCEPTIONS +# define ACE_HAS_NEW_NOTHROW +# define ACE_HAS_NEW_NO_H 1 + +// Compiler's template mechanism must see source code (i.e., .C files). +# define ACE_TEMPLATES_REQUIRE_SOURCE + +// Compiler doesn't handle 'signed char' correctly (used in ace/IOStream.h) +# define ACE_LACKS_SIGNED_CHAR + +#endif /* __GNUG__, HP */ + +//********************************************************************* +// +// From here down is the compiler-INdependent OS settings. +// +//********************************************************************* + +// Compiling for HPUX. +#if !defined (HPUX) +#define HPUX +#endif /* HPUX */ +#define HPUX_11 + +#ifndef _HPUX_SOURCE +#define _HPUX_SOURCE +#endif + +#include /**/ + +// HP-UX is a POSIX-compliant system - see what's available. +#include "ace/config-posix.h" + +// config-posix.h sets up ACE_HAS_AIO_CALLS if the headers define the +// proper things. In HP-UX 11's case, the AIOCB Proactor works the best +// overall. If the user hasn't overridden it, select AIOCB. +#if defined (ACE_HAS_AIO_CALLS) +# if !defined (ACE_POSIX_AIOCB_PROACTOR) && !defined (ACE_POSIX_SIG_PROACTOR) +# define ACE_POSIX_AIOCB_PROACTOR +# endif /* !ACE_HAS_POSIX_AIOCB_PROACTOR && !ACE_POSIX_SIG_PROACTOR */ +#endif /* ACE_HAS_AIO_CALLS */ + +//////////////////////////////////////////////////////////////////////////// +// +// General OS information - see README for more details on what they mean +// +/////////////////////////////////////////////////////////////////////////// + +// HP/UX needs to have these addresses in a special range. +// If this is on a 64-bit model, the default is to use 64-bit addressing. +// It can also be set so that the mapped region is shareable with 32-bit +// programs. To enable the 32/64 sharing, comment out the first definition +// of ACE_DEFAULT_BASE_ADDR and uncomment the two lines after it. +#if defined (__LP64__) +# define ACE_DEFAULT_BASE_ADDR ((char *) 0x0000001100000000) +//# define ACE_DEFAULT_BASE_ADDR ((char *) 0x80000000) +//# define ACE_OS_EXTRA_MMAP_FLAGS MAP_ADDR32 + +# define ACE_DEFAULT_BASE_ADDRL (0x0000001100000000) +//# define ACE_DEFAULT_BASE_ADDRL (0x80000000) +#else +# define ACE_DEFAULT_BASE_ADDR ((char *) 0x80000000) +#endif /* __LP64__ */ + +// Preprocessor needs some help with data types +#if defined (__LP64__) +# define ACE_SIZEOF_LONG 8 +#else +# define ACE_SIZEOF_LONG 4 +#endif + +// Platform can do async I/O (aio_*) (set up in config-posix.h) +// ... but seems to require this in order to keep from hanging. Needs some +// investigation, maybe with HP. John Mulhern determined this value +// empirically. YMMV. If it does vary, set it up in your own config.h which +// then includes the ACE-supplied config. +#if !defined (ACE_INFINITE) +# define ACE_INFINITE 10000000 +#endif + +/* Compiler/platform correctly calls init()/fini() for shared libraries. */ +#define ACE_HAS_AUTOMATIC_INIT_FINI 1 + +// Manually tweak the malloc control block paddings to properly align +// things. +#define ACE_MALLOC_PADDING 16 +#define ACE_MALLOC_ALIGN 8 +#define ACE_PI_CONTROL_BLOCK_ALIGN_LONGS 3 + +// Compiler/platform contains the file. +#define ACE_HAS_SYS_SYSCALL_H + +#define ACE_HAS_SYS_PSTAT_H + +// But doesn't have a prototype for syscall() +#define ACE_LACKS_SYSCALL + +// Platform supports POSIX.1b clock_gettime () +#define ACE_HAS_CLOCK_GETTIME +#define ACE_HAS_CLOCK_SETTIME + +// Prototypes for both signal() and struct sigaction are consistent. +#define ACE_HAS_CONSISTENT_SIGNAL_PROTOTYPES + +// Compiler/platform has correctly prototyped header files. +#define ACE_HAS_CPLUSPLUS_HEADERS + +// Compiler/platform has Dirent iterator functions. +#define ACE_HAS_DIRENT + +#define ACE_HAS_VSWPRINTF + +// Platform supports getpagesize() call +#define ACE_HAS_GETPAGESIZE +// But we define this just to be safe +#define ACE_PAGE_SIZE 4096 + +// Can run gperf on this platform (needed for TAO) +# define ACE_HAS_GPERF + +// Optimize ACE_Handle_Set for select(). +# define ACE_HAS_HANDLE_SET_OPTIMIZED_FOR_SELECT + +// Platform supports IP multicast +#define ACE_HAS_IP_MULTICAST +// At least for 11iv2, lacks perfect filtering. +#if (HPUX_VERS >= 1123) && !defined (ACE_LACKS_PERFECT_MULTICAST_FILTERING) +# define ACE_LACKS_PERFECT_MULTICAST_FILTERING 1 +#endif + +/* Platform defines MAP_FAILED as a long constant. */ +#define ACE_HAS_LONG_MAP_FAILED 1 + +// Platform supports recvmsg and sendmsg. +#define ACE_HAS_MSG + +// Platform's select() has non-const timeval argument +#define ACE_HAS_NONCONST_SELECT_TIMEVAL + +// Compiler/platform supports poll(). +#define ACE_HAS_POLL + +/* Platform supports "position-independent" features provided by + ACE_Based_Pointer<>. */ +#define ACE_HAS_POSITION_INDEPENDENT_POINTERS 1 + +/* Platform supports POSIX getpwnam_r() function */ +#define ACE_HAS_POSIX_GETPWNAM_R 1 + +// Platform supports POSIX O_NONBLOCK semantics. +#define ACE_HAS_POSIX_NONBLOCK + +// Platform supports the POSIX struct timespec type +#define ACE_HAS_POSIX_TIME + +/* Platform has pread() and pwrite() support. */ +#define ACE_HAS_P_READ_WRITE 1 + +/* Platform will recurse infinitely on thread exits from TSS cleanup routines + (e.g., AIX) */ +#define ACE_HAS_RECURSIVE_THR_EXIT_SEMANTICS 1 + +// Platform supports reentrant functions (all the POSIX *_r functions). +#define ACE_HAS_REENTRANT_FUNCTIONS +// ctime_r and asctime_r conform to POSIX.1c (2 param version) +#define ACE_HAS_2_PARAM_ASCTIME_R_AND_CTIME_R + +// Platform offers scandir(), and requires no adjustments for its API. +#define ACE_HAS_SCANDIR + +// HP-UX 11 has reentrant netdb functions. The catch is that the old +// functions (gethostbyname, etc.) are thread-safe and the _r versions are +// not used and will be removed at some point. So, define things so +// the _r versions are not used. This will slow things down a bit due to +// the extra mutex lock in the ACE_NETDBCALL_RETURN macro, and will be fixed +// in the future (problem ID P64). +#define ACE_LACKS_NETDB_REENTRANT_FUNCTIONS + +/* Platform lacks pri_t (e.g., Tandem NonStop UNIX). */ +#define ACE_LACKS_PRI_T 1 + +// Platform has shm_open +#define ACE_HAS_SHM_OPEN + +// Compiler/platform defines the sig_atomic_t typedef +#define ACE_HAS_SIG_ATOMIC_T + +/* Compiler requires extern "C" functions for signals. */ +#define ACE_HAS_SIG_C_FUNC 1 + +// Platform's sigaction() function takes const sigaction* as 2nd parameter. +#define ACE_HAS_SIGACTION_CONSTP2 + +#define ACE_HAS_SSIZE_T + +// Platform supports SVR4 extended signals +#define ACE_HAS_SIGINFO_T + +/* Define to 1 if platform has sigsuspend(). */ +#define ACE_HAS_SIGSUSPEND 1 + +// Platform doesn't detect a signal out of range unless it's way out of range. +#define ACE_HAS_SIGISMEMBER_BUG + +/* Platform provides socklen_t type, such as Linux with glibc2. */ +#define ACE_HAS_SOCKLEN_T 1 + +#define ACE_HAS_XPG4_MULTIBYTE_CHAR + +/* Platform/compiler supports _sys_errlist symbol */ +#define ACE_HAS_SYS_ERRLIST 1 + +#define ACE_HAS_UALARM + +// Platform supports ucontext_t (which is used in the extended signal API). +#define ACE_HAS_UCONTEXT_T + +// Compiler/platform supports strerror (). +#define ACE_HAS_STRERROR + +// Platform/compiler supports void * as second parameter to gettimeofday(). +#define ACE_HAS_VOIDPTR_GETTIMEOFDAY + +/* Platform requires void * for mmap(). */ +#define ACE_HAS_VOIDPTR_MMAP 1 + +/* OS/compiler uses void * arg 4 setsockopt() rather than const char * */ +#define ACE_HAS_VOIDPTR_SOCKOPT 1 + +// Platform supports SVR4 dynamic linking semantics. +// When used, this requires -ldl on the ACE library link line. +#define ACE_HAS_SVR4_DYNAMIC_LINKING + +// Platform supports the getrusage() system call. +#define ACE_HAS_GETRUSAGE + +/* Define to 1 if platform has the declaration of getrusage(). */ +#define ACE_HAS_GETRUSAGE_PROTOTYPE 1 + +// Platform has the sigwait function in a header file +#define ACE_HAS_SIGWAIT +#define ACE_HAS_SIGTIMEDWAIT + +// Platform supports System V IPC (most versions of UNIX, but not Win32) +#define ACE_HAS_SYSV_IPC + +// accept() is thread-safe +#define ACE_HAS_THREAD_SAFE_ACCEPT + +// Platform lacks a typedef for timespec_t, but has struct timespec +#define ACE_LACKS_TIMESPEC_T + +// dlopen() takes a char* instead of const char* +#define ACE_HAS_CHARPTR_DL + +// lacks setegid and seteuid +#define ACE_LACKS_SETEGID +#define ACE_LACKS_SETEUID + +#define ACE_LACKS_SUSECONDS_T +#define ACE_LACKS_SYS_SYSCTL_H + +// @@ TODO: It looks like HP-UX provides strtoull and wcstoull +// but some more work is needed to plug them in correctly. +#define ACE_LACKS_STRTOULL +#define ACE_LACKS_WCSTOULL + +// Shared library name/path components +#if defined (__ia64) +# define ACE_DLL_SUFFIX ACE_TEXT (".so") +#else +# define ACE_DLL_SUFFIX ACE_TEXT (".sl") +#endif /* __ia64 */ +#if defined (__LP64__) +# define ACE_LD_SEARCH_PATH ACE_TEXT ("LD_LIBRARY_PATH") +#else +# define ACE_LD_SEARCH_PATH ACE_TEXT ("SHLIB_PATH") +#endif /* __LP64__ */ + +#if defined (_INCLUDE__STDC_A1_SOURCE) +# define ACE_HAS_3_PARAM_WCSTOK +#endif + +#define ACE_HAS_3_PARAM_READDIR_R + + +////////////////////////////////////////////////////////////////////////// +// +// STREAMS information +// +////////////////////////////////////////////////////////////////////////// + +// Platform supports STREAMS +#define ACE_HAS_STREAMS +// Compiler/platform supports struct strbuf. +#define ACE_HAS_STRBUF_T +// But the putmsg signature doesn't have it as const... +// Well, it really does, but it depends on preprocessor defines. +#define ACE_LACKS_CONST_STRBUF_PTR +/* Platform supports TLI timod STREAMS module */ +#define ACE_HAS_TIMOD_H 1 + +// Platform supports STREAM pipes +// This is possible, but not by default - need to rebuild the kernel to +// get them enabled - see pipe(2) and "STREAMS/UX for the HP 9000" +// #define ACE_HAS_STREAM_PIPES + +///////////////////////////////////////////////////////////////////////// +// +// TLI/XTI information +// +//////////////////////////////////////////////////////////////////////// + +// Platform supports XTI (includes TLI). +#define ACE_HAS_XTI +// HP-UX 11 conforms to the XPG4 spec, which ACE calls broken for the +// errmsg not being const... +#define ACE_HAS_BROKEN_T_ERROR +// The definitions of TCP_NODELAY and TCP_MAXSEG conflict between +// sys/xti.h and netinet/tcp.h. +#define ACE_HAS_CONFLICTING_XTI_MACROS +/* Platform provides header */ +#define ACE_HAS_SYS_XTI_H 1 + +///////////////////////////////////////////////////////////////////////// +// +// Threads information. +// +// Use of threads is controlled by the 'threads' argument to make. See +// include/makeinclude/platform_hpux_aCC.GNU for details. If it's not set, +// the default is to enable it, since kernel threads are always available +// on HP-UX 11, as opposed to 10.x where it was optional software. +// +//////////////////////////////////////////////////////////////////////// + +#if defined (ACE_HAS_THREADS) +# if (ACE_HAS_THREADS == 0) +# undef ACE_HAS_THREADS +# endif /* ACE_HAS_THREADS == 0 */ +#else +# define ACE_HAS_THREADS +#endif /* ACE_HAS_THREADS */ + +#if defined (ACE_HAS_THREADS) + +# if !defined (ACE_MT_SAFE) +# define ACE_MT_SAFE 1 +# endif + +// HP-UX doesn't define _POSIX_THREADS since it doesn't implement all +// features (lacks thread priority inheritance and protection), so +// config-posix.h doesn't get this one... +# define ACE_HAS_PTHREADS +# define ACE_HAS_PTHREADS_UNIX98_EXT +# define ACE_HAS_PTHREAD_CONTINUE +# define ACE_HAS_PTHREAD_RESUME_NP +# define ACE_HAS_PTHREAD_SUSPEND +# define ACE_HAS_RECURSIVE_MUTEXES +# define ACE_HAS_THREAD_SPECIFIC_STORAGE +# define ACE_LACKS_PTHREAD_ATTR_SETSTACK +#endif /* ACE_HAS_THREADS */ + +#define ACE_HAS_POSIX_SEM + +// Platform has POSIX terminal interface. +#define ACE_HAS_TERMIOS + +// gethostbyaddr does not handle IPv6-mapped-IPv4 addresses +#define ACE_HAS_BROKEN_GETHOSTBYADDR_V4MAPPED + +#include /**/ "ace/post.h" +#endif /* ACE_CONFIG_H */ diff --git a/dep/ACE_wrappers/ace/config-icc-common.h b/dep/ACE_wrappers/ace/config-icc-common.h new file mode 100644 index 00000000000..1ebd0c52ed7 --- /dev/null +++ b/dep/ACE_wrappers/ace/config-icc-common.h @@ -0,0 +1,113 @@ +// -*- C++ -*- +// +// $Id: config-icc-common.h 81935 2008-06-12 22:01:53Z jtc $ + +#ifndef ACE_LINUX_ICC_COMMON_H +#define ACE_LINUX_ICC_COMMON_H +#include /**/ "ace/pre.h" + +# define ACE_HAS_CPLUSPLUS_HEADERS +# define ACE_HAS_STDCPP_STL_INCLUDES +# define ACE_HAS_TEMPLATE_TYPEDEFS +# define ACE_HAS_STANDARD_CPP_LIBRARY 1 +# define ACE_HAS_WORKING_EXPLICIT_TEMPLATE_DESTRUCTOR +# define ACE_USES_STD_NAMESPACE_FOR_STDCPP_LIB 1 +# define ACE_HAS_STRING_CLASS + +#if defined (ACE_HAS_CUSTOM_EXPORT_MACROS) && ACE_HAS_CUSTOM_EXPORT_MACROS == 0 +# undef ACE_HAS_CUSTOM_EXPORT_MACROS +# if defined (ACE_GCC_HAS_TEMPLATE_INSTANTIATION_VISIBILITY_ATTRS) +# undef ACE_GCC_HAS_TEMPLATE_INSTANTIATION_VISIBILITY_ATTRS +# endif /* ACE_GCC_HAS_TEMPLATE_INSTANTIATION_VISIBILITY_ATTRS */ +# define ACE_GCC_HAS_TEMPLATE_INSTANTIATION_VISIBILITY_ATTRS 0 +#else +# ifndef ACE_HAS_CUSTOM_EXPORT_MACROS +# define ACE_HAS_CUSTOM_EXPORT_MACROS +# endif /* !ACE_HAS_CUSTOM_EXPORT_MACROS */ +# define ACE_Proper_Export_Flag __attribute__ ((visibility("default"))) +# define ACE_Proper_Import_Flag __attribute__ ((visibility("default"))) + +# if (__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 2)) +// Sadly, G++ 4.x silently ignores visibility attributes on +// template instantiations, which breaks singletons. +// As a workaround, we use the GCC visibility pragmas. +// And to make them fit in a macro, we use C99's _Pragma() +// http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17470 +// This has been fixed in GCC 4.1.1 with FC6 but not with SuSE 10.2 +// that gets shipped with GCC 4.1.2 so we assume that with GCC 4.2 +// this will be fixed on the head. With FC6 just set this define yourself +# ifndef ACE_GCC_HAS_TEMPLATE_INSTANTIATION_VISIBILITY_ATTRS +# define ACE_GCC_HAS_TEMPLATE_INSTANTIATION_VISIBILITY_ATTRS 1 +# endif +# endif + +# if defined (ACE_GCC_HAS_TEMPLATE_INSTANTIATION_VISIBILITY_ATTRS) && ACE_GCC_HAS_TEMPLATE_INSTANTIATION_VISIBILITY_ATTRS == 1 +# define ACE_EXPORT_SINGLETON_DECLARATION(T) template class ACE_Proper_Export_Flag T +# define ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) template class ACE_Proper_Export_Flag SINGLETON_TYPE ; +# else /* ACE_GCC_HAS_TEMPLATE_INSTANTIATION_VISIBILITY_ATTRS */ +# define ACE_EXPORT_SINGLETON_DECLARATION(T) \ + _Pragma ("GCC visibility push(default)") \ + template class T \ + _Pragma ("GCC visibility pop") +# define ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) \ + _Pragma ("GCC visibility push(default)") \ + template class SINGLETON_TYPE; \ + _Pragma ("GCC visibility pop") +# endif /* ACE_GCC_HAS_TEMPLATE_INSTANTIATION_VISIBILITY_ATTRS */ + +// Note that the "__extension__" is needed to prevent g++ from issuing +// an error when using its "-pedantic" command line flag. +# define ACE_IMPORT_SINGLETON_DECLARATION(T) __extension__ extern template class T +# define ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) __extension__ extern template class SINGLETON_TYPE; +#endif /* ACE_HAS_CUSTOM_EXPORT_MACROS == 0 */ + +// __EXCEPTIONS is defined with -fexceptions, the egcs default. It +// is not defined with -fno-exceptions, the ACE default for g++. +// ACE_HAS_EXCEPTIONS is defined in +// include/makeinclude/wrapper_macros.GNU, so this really isn't +// necessary. Just in case . . . +# if defined (__EXCEPTIONS) && !defined (ACE_HAS_EXCEPTIONS) +# define ACE_HAS_EXCEPTIONS +# endif /* __EXCEPTIONS && ! ACE_HAS_EXCEPTIONS */ + +# if defined (ACE_HAS_EXCEPTIONS) +# define ACE_NEW_THROWS_EXCEPTIONS +# endif /* ACE_HAS_EXCEPTIONS */ + +#if (defined (i386) || defined (__i386__)) && !defined (ACE_SIZEOF_LONG_DOUBLE) +# define ACE_SIZEOF_LONG_DOUBLE 12 +#endif /* i386 */ + +#if !defined (__MINGW32__) && (defined (i386) || defined (__i386__)) + // If running an Intel, assume that it's a Pentium so that + // ACE_OS::gethrtime () can use the RDTSC instruction. If running a + // 486 or lower, be sure to comment this out. (If not running an + // Intel CPU, this #define will not be seen because of the i386 + // protection, so it can be ignored.) +# define ACE_HAS_PENTIUM +#endif /* i386 */ + +#if (defined (ACE_HAS_PENTIUM) || defined (__amd64__) || defined (__x86_64__)) +# define ACE_HAS_INTEL_ASSEMBLY +#endif + +#if !defined (ACE_LACKS_PRAGMA_ONCE) + // We define it with a -D with make depend. +# define ACE_LACKS_PRAGMA_ONCE +#endif /* ! ACE_LACKS_PRAGMA_ONCE */ + +#define ACE_TEMPLATES_REQUIRE_SOURCE + +#if (__INTEL_COMPILER >= 910) +# define ACE_EXPLICIT_TEMPLATE_DESTRUCTOR_TAKES_ARGS +#endif + +#if defined (__ia64) +# define ACE_HAS_IA64INTRIN_H +# define ACE_HAS_INTRINSIC_INTERLOCKED +#else +# define ACE_HAS_IA32INTRIN_H +#endif + +#include /**/ "ace/post.h" +#endif /* ACE_LINUX_ICC_COMMON_H */ diff --git a/dep/ACE_wrappers/ace/config-integritySCA.h b/dep/ACE_wrappers/ace/config-integritySCA.h new file mode 100644 index 00000000000..62a5d5963a6 --- /dev/null +++ b/dep/ACE_wrappers/ace/config-integritySCA.h @@ -0,0 +1,233 @@ +// -*- C++ -*- + +#ifndef ACE_INT_CONFIG_H +#define ACE_INT_CONFIG_H + +/* + * This config.h file is for version 4.0.x of the + * Integrity RTOS with SCA from Green Hills Software + * http://www.ghs.com/products/rtos/integrity.html + * + * $Id: config-integritySCA.h 81935 2008-06-12 22:01:53Z jtc $ + */ + +#define ghs +/* compilation defines */ +#define ACE_LACKS_GETPGID +#define ACE_LACKS_SETPGID +#define ACE_LACKS_SETREUID +#define ACE_LACKS_SETREGID +#define ACE_LACKS_SETSID +#define ACE_LACKS_SETEGID +#define ACE_LACKS_SETUID +#define ACE_LACKS_SETEUID +#define ACE_LACKS_GETEUID +#define ACE_LACKS_GETUID +#define ACE_LACKS_GETEGID +#define ACE_LACKS_GETGID + +#ifndef ACE_HAS_EXCEPTIONS + #define ACE_HAS_EXCEPTIONS +#endif +#define ACE_NEW_THROWS_EXCEPTIONS +#define ACE_HAS_STANDARD_CPP_LIBRARY 1 +#define ACE_TEMPLATES_REQUIRE_SOURCE 1 +#define ACE_HAS_TEMPLATE_TYPEDEFS +#define TAO_USE_SEQUENCE_TEMPLATES +#define ACE_NEEDS_FUNC_DEFINITIONS +#define _REENTRANT +#define ACE_MT_SAFE 1 + +// Compiler/platform has correctly prototyped header files. +#define ACE_HAS_CPLUSPLUS_HEADERS + +#define ACE_HAS_SHM_OPEN + +/***** Operating System Defines *****/ + +/***** ANSI defines *****/ +#define ACE_LACKS_TEMPNAM /* believe it or not, this is ANSI C */ +#define ACE_HAS_STRERROR + + +#define ACE_LACKS_SENDMSG + +/***** End Stack Defines *****/ + + +/* SCA STUFF */ +#if defined(INTEGRITY_VERSION) && (INTEGRITY_VERSION >= 40108) +#define ACE_HAS_SIG_ATOMIC_T +#endif /* INTEGRITY_VERSION */ +#define ACE_HAS_SIGWAIT +#define ACE_HAS_SIGACTION +#define ACE_HAS_SIGINFO_T +#define ACE_LACKS_SIGINFO_H +#define ACE_LACKS_UCONTEXT_H +#define ACE_HAS_SIG_C_FUNC +#define ACE_LACKS_SI_ADDR +#define ACE_HAS_AIO_CALLS + +#define ACE_HAS_POSIX_NONBLOCK +#define ACE_HAS_DIRENT + +#define ACE_HAS_THREADS + +#define ACE_HAS_PTHREADS +/***** End Threading Defines *****/ + +/***** Hardware Defines *****/ +#define ACE_PAGE_SIZE 4096 +/***** End Hardware Defines *****/ + +/****** SYSV_IPC STUFF *****/ +#define ACE_LACKS_KEY_T + +/****** Posix Defines *****/ +#define ACE_LACKS_WAIT +#define ACE_LACKS_WAITPID +#define ACE_HAS_POSIX_TIME +#define ACE_HAS_POSIX_SEM +#define ACE_HAS_STRDUP_EMULATION +#define ACE_HAS_MSG +#define ACE_LACKS_CONDATTR_PSHARED +#define ACE_LACKS_EXEC +#define ACE_LACKS_FORK +#define ACE_LACKS_MKFIFO +#define ACE_LACKS_MKTEMP +#define ACE_LACKS_MKSTEMP +#define ACE_LACKS_MPROTECT +#define ACE_LACKS_MUTEXATTR_PSHARED +#define ACE_LACKS_PIPE +#define ACE_LACKS_RLIMIT +#define ACE_LACKS_RECVMSG +#define ACE_LACKS_RWLOCK_T +#define ACE_LACKS_SEMBUF_T +#define ACE_LACKS_UNIX_DOMAIN_SOCKETS +#define ACE_LACKS_USER +#define ACE_LACKS_FILE_FCNTL +#define ACE_LACKS_FCNTL +#define ACE_LACKS_UMASK +#define ACE_LACKS_SEEK +#define ACE_LACKS_SHARED_MEMORY +#define ACE_LACKS_MSYNC +#define ACE_LACKS_PID_STUFF +#define ACE_LACKS_NETDB_REENTRANT_FUNCTIONS +#define ACE_LACKS_IPC_H +#define ACE_LACKS_SETGID +#define ACE_LACKS_PIPE +#define ACE_LACKS_SYS_PARAM_H +#define ACE_LACKS_SYS_MSG_H +#define ACE_LACKS_UTSNAME_T +#define ACE_LACKS_UNAME +#define ACE_LACKS_UMASK +#define ACE_LACKS_ISATTY +#define ACE_LACKS_GETOPT +#define ACE_LACKS_STRCASECMP +#define ACE_LACKS_TRUNCATE +#define ACE_LACKS_PWD_FUNCTIONS +#define ACE_LACKS_UNIX_SIGNALS +#define ACE_HAS_THREAD_SPECIFIC_STORAGE +#define ACE_LACKS_SYSV_SHMEM +#define ACE_LACKS_PUTENV +#define ACE_HAS_4_4BSD_SENDMSG_RECVMSG +#define ACE_HAS_CLOCK_GETTIME +#define ACE_HAS_CLOCK_SETTIME +#define ACE_LACKS_THREAD_PROCESS_SCOPING +#define ACE_LACKS_SETSCHED +#define ACE_LACKS_STRRECVFD +#define ACE_LACKS_WRITEV +#define ACE_LACKS_READV +#define ACE_LACKS_SYSCONF +#define ACE_LACKS_GETOPT +/* below refers to fcntl style locking */ +#define ACE_LACKS_FILELOCKS + +#define ACE_LACKS_REALPATH +#define ACE_HAS_CONST_CHAR_SWAB +#define ACE_HAS_CONSISTENT_SIGNAL_PROTOTYPES + +/***** Not tied to standards AFAIK ****/ +#define ACE_LACKS_MADVISE /* paging optimization not needed with INTEGRITY */ +#define ACE_LACKS_MALLOC_H /* netbsd's just includes stdlib.h */ +#define ACE_LACKS_MEMORY_H /* netbsd's just includes string.h */ +#define ACE_LACKS_INTTYPES_H +#define ACE_LACKS_SYS_RESOURCE_H +#define ACE_LACKS_SYS_WAIT_H +#define ACE_LACKS_SEARCH_H +#define ACE_LACKS_SYS_IPC_H +#define ACE_LACKS_SYS_SEM_H +#define ACE_LACKS_PWD_H +#define ACE_LACKS_STROPTS_H +#define ACE_LACKS_DLFCN_H +#define ACE_LACKS_REGEX_H +#define ACE_LACKS_POLL_H +#define ACE_LACKS_SYS_SHM_H +#define ACE_LACKS_TERMIOS_H + +/***** STUFF INTEGRITY 4.0.8 APPEARS TO SUPPORT ****/ +/* note, possibly untested with ace */ + +/***** TAO STUFF ****/ +#define TAO_USE_DOTTED_DECIMAL_ADDRESSES 1 + +#include + +#include + +typedef void (*__sighandler_t)(int); + +extern "C" +{ + inline int isatty(int) { return 0; } +} + +#ifdef ppc +#define ACE_HAS_POWERPC_TIMER +#endif + +/* MIKEC Addtions */ +#define ACE_HAS_NONCONST_SELECT_TIMEVAL +#include // needed to define iovec +#define ACE_LACKS_READLINK +#define ACE_LACKS_GETPPID +#define NSIG (SIGRTMAX+1) +#define ACE_USES_STD_NAMESPACE_FOR_STDCPP_LIB 1 +#define ACE_USE_RCSID 0 +#define ACE_LACKS_CUSERID +#define ACE_NEEDS_HUGE_THREAD_STACKSIZE 0x5000 +#define fileno(file) ((file)->io_channel) //Hack to get Svc_Conf_l.cpp compiled +#define ACE_DEFAULT_THREAD_PRIORITY 127 +#define PRI_FIFO_MIN 1 +#define PRI_FIFO_MAX 127 +#define ACE_THR_PRI_FIFO_DEF 127 +#define PRI_RR_MIN 1 +#define PRI_RR_MAX 127 +#define ACE_THR_PRI_RR_DEF 127 +#define PRI_OTHER_MIN 1 +#define PRI_OTHER_MAX 127 +#define ACE_THR_PRI_OTHER_DEF 127 +#define ACE_PTHREAD_RETURN_ON_EXIT +#undef ACE_LACKS_UNLINK + +#define ACE_HAS_TIMED_MESSAGE_BLOCKS + +extern "C" { +int unlink(const char *); +} + +#define ACE_LACKS_SETSID +#define ACE_HAS_VOIDPTR_GETTIMEOFDAY +#define ACE_LACKS_UNIX_SYSLOG +#define ACE_LACKS_TELLDIR +#define ACE_LACKS_SEEKDIR +#define ACE_LACKS_GETHOSTENT + + +/* end MIKEC Addtions */ + +// Hack to avoid ensure that things defined in ind_io.h +// have the right linkage +#include + +#endif /* ACE_CONFIG_H */ diff --git a/dep/ACE_wrappers/ace/config-irix6.5.x-sgic++.h b/dep/ACE_wrappers/ace/config-irix6.5.x-sgic++.h new file mode 100644 index 00000000000..2d501010b68 --- /dev/null +++ b/dep/ACE_wrappers/ace/config-irix6.5.x-sgic++.h @@ -0,0 +1,18 @@ +// -*- C++ -*- +// $Id: config-irix6.5.x-sgic++.h 80826 2008-03-04 14:51:23Z wotte $ + +// Use this file for IRIX 6.5.x + +#ifndef ACE_CONFIG_IRIX65X_H +#define ACE_CONFIG_IRIX65X_H +#include /**/ "ace/pre.h" + +// Include IRIX 6.[234] configuration +#include "ace/config-irix6.x-sgic++.h" + +// Irix 6.5 man pages show that they exist +#undef ACE_LACKS_CONDATTR_PSHARED +#undef ACE_LACKS_MUTEXATTR_PSHARED + +#include /**/ "ace/post.h" +#endif /* ACE_CONFIG_IRIX65X_H */ diff --git a/dep/ACE_wrappers/ace/config-irix6.x-common.h b/dep/ACE_wrappers/ace/config-irix6.x-common.h new file mode 100644 index 00000000000..d968fa422e0 --- /dev/null +++ b/dep/ACE_wrappers/ace/config-irix6.x-common.h @@ -0,0 +1,257 @@ +/* -*- C++ -*- */ +// +// $Id: config-irix6.x-common.h 81697 2008-05-14 18:33:11Z johnnyw $ +// +// This file contains the common configuration options for both +// SGI/MIPSPro C++ and g++ under IRIX 6.X +// +// For IRIX 6.2 there are several patches that should be applied to +// get reliable operation with multi-threading and exceptions. +// Specifically you should get a reasonable current IRIX, Compiler +// and POSIX patch-sets. + +// For IRIX 6.[34] it's less critical, but it's still recommended +// that you apply the applicable patch-sets (IRIX and Compiler I believe). + +// These patches are updated frequently, so you should ask your support +// contact or search SGI's web site (http://www.sgi.com) for the latest +// version. + +// Use this file for IRIX 6.[234] if you have the pthreads patches +// installed. + +#ifndef ACE_CONFIG_IRIX6X_COMMON_H + +#ifndef IRIX6 +# define IRIX6 +#endif + +#if ! defined(ACE_CONFIG_H) +#error "This file may only be included by config-irix6.x-sgic++.h, config-irix6.x-kcc.h or config-irix6.x-g++.h" +#endif + +// The Irix 6.x float.h doesn't allow us to distinguish between a +// double and a long double. So, we have to hard-code this. Thanks +// to Bob Laferriere for figuring it out. +#if defined (_MIPS_SIM) /* 6.X System */ +# include +# if defined (__GNUC__) +# define ACE_SIZEOF_LONG_DOUBLE 16 +# elif defined (_MIPS_SIM_NABI32) && (_MIPS_SIM == _MIPS_SIM_NABI32) +# define ACE_SIZEOF_LONG_DOUBLE 16 +# elif defined (_MIPS_SIM_ABI32) && (_MIPS_SIM == _MIPS_SIM_ABI32) +# define ACE_SIZEOF_LONG_DOUBLE 8 +# elif defined (_MIPS_SIM_ABI64) && (_MIPS_SIM == _MIPS_SIM_ABI64) +# define ACE_SIZEOF_LONG_DOUBLE 16 +# elif !defined (ACE_SIZEOF_LONG_DOUBLE) +# define ACE_SIZEOF_LONG_DOUBLE 8 +# endif +#else +# define ACE_SIZEOF_LONG_DOUBLE 8 /* 5.3 System */ +#endif + +// petern, Next part of it: + +// Platform supports getpagesize() call. +#define ACE_HAS_GETPAGESIZE + +// Platform has no implementation of pthread_condattr_setpshared(), +// even though it supports pthreads! (like Irix 6.2) +#define ACE_LACKS_CONDATTR_PSHARED +#define ACE_LACKS_MUTEXATTR_PSHARED + +#define ACE_LACKS_SUSECONDS_T + +// Platform/compiler has the sigwait(2) prototype +#define ACE_HAS_SIGWAIT +#define ACE_HAS_SIGTIMEDWAIT +#define ACE_HAS_SIGSUSPEND + +// Platform supports System V IPC (most versions of UNIX, but not Win32) +#define ACE_HAS_SYSV_IPC + +// Platform requires void * for mmap(). +#define ACE_HAS_VOIDPTR_MMAP + +// Platform supports recvmsg and sendmsg. +#define ACE_HAS_MSG + +// Compiler/platform contains the file. +#define ACE_HAS_SYS_SYSCALL_H + +// Compiler/platform supports alloca() +// Although ACE does have alloca() on this compiler/platform combination, it is +// disabled by default since it can be dangerous. Uncomment the following line +// if you ACE to use it. +//#define ACE_HAS_ALLOCA + +// Compiler/platform has +#define ACE_HAS_ALLOCA_H + +// Irix needs to define bzero() in this odd file +#define ACE_HAS_BSTRING + +// Compiler/platform has the getrusage() system call. +#define ACE_HAS_GETRUSAGE + +// Platform supports POSIX O_NONBLOCK semantics. +#define ACE_HAS_POSIX_NONBLOCK + +// Compiler/platform has correctly prototyped header files. +#define ACE_HAS_CPLUSPLUS_HEADERS + +// Platform contains . +#define ACE_HAS_POLL + +// Platform supports the /proc file system. +#define ACE_HAS_PROC_FS + +// Compiler/platform defines the sig_atomic_t typedef. +#define ACE_HAS_SIG_ATOMIC_T + +// Platform supports SVR4 extended signals. +#define ACE_HAS_SIGINFO_T +#define ACE_HAS_UCONTEXT_T + +// Compiler supports the ssize_t typedef. +#define ACE_HAS_SSIZE_T + +// Platform supports STREAMS. +#define ACE_HAS_STREAMS + +// Compiler/platform supports strerror (). +#define ACE_HAS_STRERROR + +// Compiler/platform supports struct strbuf. +#define ACE_HAS_STRBUF_T + +// Compiler/platform supports SVR4 dynamic linking semantics. +#define ACE_HAS_SVR4_DYNAMIC_LINKING + +// Platform provides header. +#define ACE_HAS_SYS_FILIO_H + +// Compiler/platform defines a union semun for SysV shared memory. +#define ACE_HAS_SEMUN + +// Platform supports IP multicast +#define ACE_HAS_IP_MULTICAST +#ifdef ACE_LACKS_PERFECT_MULTICAST_FILTERING + #undef ACE_LACKS_PERFECT_MULTICAST_FILTERING +#endif +#define ACE_LACKS_PERFECT_MULTICAST_FILTERING 1 + +//************************************************************** +// Not so sure how next lines should look like + +// Platform supports POSIX timers via timestruc_t. +#define ACE_HAS_POSIX_TIME + +//************************************************************** + +// IRIX 6.4 and below do not support reentrant netdb functions +// (getprotobyname_r, getprotobynumber_r, gethostbyaddr_r, +// gethostbyname_r, getservbyname_r). +#if (ACE_IRIX_VERS <= 64) && !defined (ACE_HAS_NETDB_REENTRANT_FUNCTIONS) +#define ACE_LACKS_NETDB_REENTRANT_FUNCTIONS +#endif /* ACE_HAS_NETDB_REENTRANT_FUNCTIONS */ + +#define ACE_HAS_DIRENT +// Unless the thread enabled version is used the readdir_r interface +// does not get defined in IRIX 6.2 +#define ACE_LACKS_READDIR_R +#define ACE_LACKS_RWLOCK_T + +#define ACE_HAS_GPERF + +#define ACE_HAS_NONCONST_SELECT_TIMEVAL +#define ACE_HAS_BROKEN_DGRAM_SENDV + +#define ACE_LACKS_PLACEMENT_OPERATOR_DELETE +#define ACE_PI_CONTROL_BLOCK_ALIGN_LONGS 2 + +// Platform has POSIX terminal interface. +#define ACE_HAS_TERMIOS + +// IRIX 6.5 supports AIO +#define ACE_HAS_AIO_CALLS +#define ACE_POSIX_AIOCB_PROACTOR +#define ACE_HAS_SGIDLADD +#define ACE_HAS_P_READ_WRITE +#define ACE_LACKS_LINEBUFFERED_STREAMBUF +#define ACE_LACKS_STDINT_H +#define ACE_HAS_SYSENT_H +#define ACE_HAS_SYSINFO +#define ACE_HAS_SYS_SYSTEMINFO_H + +// Platform has support for multi-byte character support compliant +// with the XPG4 Worldwide Portability Interface wide-character +// classification. +#define ACE_HAS_XPG4_MULTIBYTE_CHAR + +// We need to setup a very high address or Naming_Test won't run. +#define ACE_DEFAULT_BASE_ADDR ((char *) (1024U * 1024 * 1024)) + +#define ACE_LACKS_SIGNED_CHAR + +// Platform supports reentrant functions (i.e., all the POSIX *_r +// functions). +#define ACE_HAS_REENTRANT_FUNCTIONS + +// Optimize ACE_Handle_Set for select(). +#define ACE_HAS_HANDLE_SET_OPTIMIZED_FOR_SELECT + +// Platform does not support reentrant password file accessor functiions. +#define ACE_LACKS_PWD_REENTRANT_FUNCTIONS + +// uses ctime_r & asctime_r with only two parameters vs. three +#define ACE_HAS_2_PARAM_ASCTIME_R_AND_CTIME_R + +// Prototypes for both signal() and struct sigaction are consistent. +#define ACE_HAS_CONSISTENT_SIGNAL_PROTOTYPES + +#define ACE_HAS_UALARM + +// Scheduling functions are declared in +#define ACE_NEEDS_SCHED_H + +// Compile using multi-thread libraries by default +#if !defined (ACE_MT_SAFE) + #define ACE_MT_SAFE 1 +#endif /* ACE_MT_SAFE */ + +#if (ACE_MT_SAFE != 0) + +// Add threading support + +#define ACE_HAS_IRIX62_THREADS + +// Needed for the threading stuff? +#include /**/ +#define PTHREAD_MIN_PRIORITY PX_PRIO_MIN +#define PTHREAD_MAX_PRIORITY PX_PRIO_MAX + +// ACE supports threads. +#define ACE_HAS_THREADS + +// Platform has no implementation of pthread_condattr_setpshared(), +// even though it supports pthreads! (like Irix 6.2) +#define ACE_LACKS_CONDATTR_PSHARED +#define ACE_LACKS_MUTEXATTR_PSHARED + +// IRIX 6.2 supports a variant of POSIX Pthreads, supposedly POSIX 1c +#define ACE_HAS_PTHREADS + +// Compiler/platform has thread-specific storage +#define ACE_HAS_THREAD_SPECIFIC_STORAGE + +// The pthread_cond_timedwait call does not reset the timer. +#define ACE_LACKS_COND_TIMEDWAIT_RESET 1 + +// When threads are enabled READDIR_R is supported on IRIX. +#undef ACE_LACKS_READDIR_R + +#endif /* (ACE_MT_SAFE == 0) */ + + +#endif /* ACE_CONFIG_IRIX6X_COMMON_H */ diff --git a/dep/ACE_wrappers/ace/config-irix6.x-g++.h b/dep/ACE_wrappers/ace/config-irix6.x-g++.h new file mode 100644 index 00000000000..2211e0e7ce3 --- /dev/null +++ b/dep/ACE_wrappers/ace/config-irix6.x-g++.h @@ -0,0 +1,23 @@ +/* -*- C++ -*- */ +// $Id: config-irix6.x-g++.h 80826 2008-03-04 14:51:23Z wotte $ + +// The following configuration file is designed to work for the SGI +// Indigo2EX running Irix 6.2 platform using the GNU C++ Compiler + +#ifndef ACE_CONFIG_H +#define ACE_CONFIG_H +#include /**/ "ace/pre.h" + +// config-g++-common.h undef's ACE_HAS_STRING_CLASS with -frepo, so +// this must appear before its #include. +#define ACE_HAS_STRING_CLASS + +#include "ace/config-g++-common.h" +#include "ace/config-irix6.x-common.h" + +// Denotes that GNU has cstring.h as standard +// which redefines memchr() +#define ACE_HAS_GNU_CSTRING_H + +#include /**/ "ace/post.h" +#endif /* ACE_CONFIG_H */ diff --git a/dep/ACE_wrappers/ace/config-irix6.x-sgic++.h b/dep/ACE_wrappers/ace/config-irix6.x-sgic++.h new file mode 100644 index 00000000000..8bba07ac671 --- /dev/null +++ b/dep/ACE_wrappers/ace/config-irix6.x-sgic++.h @@ -0,0 +1,36 @@ +/* -*- C++ -*- */ +// $Id: config-irix6.x-sgic++.h 81935 2008-06-12 22:01:53Z jtc $ + +// Use this file for IRIX 6.[234] if you have the pthreads patches +// installed. + +#ifndef ACE_CONFIG_H +#define ACE_CONFIG_H +#include /**/ "ace/pre.h" + +#include "ace/config-irix6.x-common.h" + +// This is the config file for IRIX 6.2, 6.4 and hopefully 6.3, using +// the SGI C++ compiler (7.1 or higher). + +// The following three should be enabled/disabled together. +#if _COMPILER_VERSION < 720 +#define ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA +#endif /* _COMPILER_VERSION < 720 */ +#define ACE_TEMPLATES_REQUIRE_SOURCE +#define ACE_NEEDS_FUNC_DEFINITIONS + +// Platform supports STREAM pipes (note that this is disabled by +// default, see the manual page on pipe(2) to find out how to enable +// it). +// #define ACE_HAS_STREAM_PIPES + +#if defined (_COMPILER_VERSION) +# define ACE_CC_NAME ACE_TEXT ("SGI/MIPSPro") +# define ACE_CC_MAJOR_VERSION (_COMPILER_VERSION / 100) +# define ACE_CC_MINOR_VERSION (_COMPILER_VERSION % 100) +# define ACE_CC_BETA_VERSION (0) +#endif /* _COMPILER_VERSION */ + +#include /**/ "ace/post.h" +#endif /* ACE_CONFIG_H */ diff --git a/dep/ACE_wrappers/ace/config-linux-common.h b/dep/ACE_wrappers/ace/config-linux-common.h new file mode 100644 index 00000000000..bbb10b175da --- /dev/null +++ b/dep/ACE_wrappers/ace/config-linux-common.h @@ -0,0 +1,448 @@ +/* -*- C++ -*- */ +// $Id: config-linux-common.h 82516 2008-08-05 19:22:59Z shuston $ + +// Do not use this configuration file directly since it's designed to +// be included by another, specific configuration file, such as +// config-linux.h. It provides config information common to all Linux +// platforms. It automatically determines the CPU architecture, +// compiler (g++ or egcs), and libc (libc5 or glibc), and configures +// based on those. + +#ifndef ACE_LINUX_COMMON_H +#define ACE_LINUX_COMMON_H +#include /**/ "ace/pre.h" + +#define ACE_HAS_BYTESEX_H + +#if ! defined (__ACE_INLINE__) +#define __ACE_INLINE__ +#endif /* ! __ACE_INLINE__ */ + +// Needed to differentiate between libc 5 and libc 6 (aka glibc). +#include + +#if (defined _XOPEN_SOURCE && (_XOPEN_SOURCE - 0) >= 500) +# define ACE_HAS_PTHREADS_UNIX98_EXT +#endif /* _XOPEN_SOURCE - 0 >= 500 */ + +#if !defined (ACE_LACKS_LINUX_NPTL) + +# include "ace/config-posix.h" + + // Temporary fix because NPTL kernels do have shm_open but there is a problem + // with shm_open/shm_unlink pairing in ACE which needs to be fixed when I have time. +# if defined (ACE_HAS_SHM_OPEN) +# undef ACE_HAS_SHM_OPEN +# endif /* ACE_HAS_SHM_OPEN */ + +# if defined (ACE_USES_FIFO_SEM) + // Don't use this for Linux NPTL since this has complete + // POSIX semaphores which are more efficient +# undef ACE_USES_FIFO_SEM +# endif /* ACE_USES_FIFO_SEM */ + +# if defined (ACE_HAS_POSIX_SEM) + // Linux NPTL may not define the right POSIX macro + // but they have the actual runtime support for this stuff +# if !defined (ACE_HAS_POSIX_SEM_TIMEOUT) && (((_POSIX_C_SOURCE - 0) >= 200112L) || (_XOPEN_SOURCE >= 600)) +# define ACE_HAS_POSIX_SEM_TIMEOUT +# endif /* !ACE_HAS_POSIX_SEM_TIMEOUT && (((_POSIX_C_SOURCE - 0) >= 200112L) || (_XOPEN_SOURCE >= 600)) */ +# endif /* ACE_HAS_POSIX_SEM */ +#endif /* !ACE_LACKS_LINUX_NPTL */ + +// First the machine specific part + +#if defined (__powerpc__) || defined (__x86_64__) +# if !defined (ACE_DEFAULT_BASE_ADDR) +# define ACE_DEFAULT_BASE_ADDR ((char *) 0x40000000) +# endif /* ! ACE_DEFAULT_BASE_ADDR */ +#elif defined (__ia64) +# if !defined (ACE_DEFAULT_BASE_ADDR) +// Zero base address should work fine for Linux of IA-64: it just lets +// the kernel to choose the right value. +# define ACE_DEFAULT_BASE_ADDR ((char *) 0x0000000000000000) +# endif /* ! ACE_DEFAULT_BASE_ADDR */ +#endif /* ! __powerpc__ && ! __ia64 */ + +// Then glibc/libc5 specific parts + +#if defined(__GLIBC__) +# if (__GLIBC__ < 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 1) +# define ACE_HAS_NONCONST_SETRLIMIT +# endif +# if (__GLIBC__ < 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 3) +# define ACE_HAS_RUSAGE_WHO_ENUM enum __rusage_who +# define ACE_HAS_RLIMIT_RESOURCE_ENUM enum __rlimit_resource +# endif +# define ACE_HAS_SOCKLEN_T +# define ACE_HAS_4_4BSD_SENDMSG_RECVMSG + + // glibc defines both of these, used in OS_String. +# if defined (_GNU_SOURCE) +# define ACE_HAS_STRNLEN +# define ACE_HAS_WCSNLEN + + // This is probably not a 100%-sure-fire check... Red Hat Linux 9 + // and Enterprise Linux 3 and up have a new kernel that can send signals + // across threads. This was not possible prior because there was no real + // difference between a process and a thread. With this, the + // ACE_POSIX_SIG_Proactor is the only chance of getting asynch I/O working. + // There are restrictions, such as all socket operations being silently + // converted to synchronous by the kernel, that make aio a non-starter + // for most Linux platforms at this time. But we'll start to crawl... +# define ACE_POSIX_SIG_PROACTOR +# endif + + // To avoid the strangeness with Linux's ::select (), which modifies + // its timeout argument, use ::poll () instead. +# define ACE_HAS_POLL + +// Don't define _XOPEN_SOURCE and _XOPEN_SOURCE_EXTENDED in ACE to make +// getpgid() prototype visible. ACE shouldn't depend on feature test +// macros to make prototypes visible. +# define ACE_LACKS_GETPGID_PROTOTYPE + +// @note the following defines are necessary with glibc 2.0 (0.961212-5) +// on Alpha. I assume that they're necessary on Intel as well, +// but that may depend on the version of glibc that is used. +//# define ACE_HAS_DLFCN_H_BROKEN_EXTERN_C +# define ACE_HAS_VOIDPTR_SOCKOPT + +// Don't define _POSIX_SOURCE in ACE to make strtok() prototype +// visible. ACE shouldn't depend on feature test macros to make +// prototypes visible. +# define ACE_LACKS_STRTOK_R_PROTOTYPE +// @note end of glibc 2.0 (0.961212-5)-specific configuration. + +# if __GLIBC__ > 1 && __GLIBC_MINOR__ >= 1 + // These were suggested by Robert Hanzlik to get + // ACE to compile on Linux using glibc 2.1 and libg++/gcc 2.8. +# undef ACE_HAS_BYTESEX_H +# define ACE_HAS_SIGINFO_T +# define ACE_LACKS_SIGINFO_H +# define ACE_HAS_UCONTEXT_T + + // Pre-glibc (RedHat 5.2) doesn't have sigtimedwait. +# define ACE_HAS_SIGTIMEDWAIT +# endif /* __GLIBC__ 2.1+ */ +#else /* ! __GLIBC__ */ + // Fixes a problem with some non-glibc versions of Linux... +# define ACE_LACKS_MADVISE +# define ACE_LACKS_MSG_ACCRIGHTS +#endif /* ! __GLIBC__ */ + +// Don't define _LARGEFILE64_SOURCE in ACE to make llseek() or +// lseek64() prototype visible. ACE shouldn't depend on feature test +// macros to make prototypes visible. +#if __GLIBC__ > 1 +# if __GLIBC_MINOR__ == 0 +# define ACE_HAS_LLSEEK +# define ACE_LACKS_LLSEEK_PROTOTYPE +# else /* __GLIBC_MINOR__ > 0 */ +# define ACE_HAS_LSEEK64 +# define ACE_LACKS_LSEEK64_PROTOTYPE +# endif +#endif /* __GLIBC__ > 1 */ + +#if __GLIBC__ > 1 && __GLIBC_MINOR__ >= 1 +# define ACE_HAS_P_READ_WRITE +# define ACE_LACKS_PREAD_PROTOTYPE +// Use ACE's alternate cuserid() implementation since the use of the +// system cuserid() is discouraged. +# define ACE_HAS_ALT_CUSERID +#endif /* __GLIBC__ > 1 && __GLIBC_MINOR__ >= 0 */ + +#if (__GLIBC__ > 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 3) +# define ACE_HAS_ISASTREAM_PROTOTYPE +# define ACE_HAS_PTHREAD_SIGMASK_PROTOTYPE +# define ACE_HAS_CPU_SET_T +#endif /* __GLIBC__ > 2 || __GLIBC__ === 2 && __GLIBC_MINOR__ >= 3) */ + +// Then the compiler specific parts + +#if defined (__INTEL_COMPILER) +# include "ace/config-icc-common.h" +#elif defined (__GNUG__) + // config-g++-common.h undef's ACE_HAS_STRING_CLASS with -frepo, so + // this must appear before its #include. +# define ACE_HAS_STRING_CLASS +# include "ace/config-g++-common.h" +#define ACE_CC_NAME ACE_TEXT ("g++") +#define ACE_CC_MAJOR_VERSION __GNUC__ +#define ACE_CC_MINOR_VERSION __GNUC_MINOR__ +//#define ACE_CC_BETA_VERSION 0 /* ??? */ +#elif defined (__DECCXX) +# define ACE_CONFIG_INCLUDE_CXX_COMMON +# include "ace/config-cxx-common.h" +#elif defined (__BORLANDC__) +# undef ACE_HAS_LLSEEK +# undef ACE_HAS_LSEEK64 +# undef ACE_LACKS_LLSEEK_PROTOTYPE +# undef ACE_LACKS_LSEEK64_PROTOTYPE +# include "ace/config-borland-common.h" +#elif defined (__SUNCC_PRO) +# include "ace/config-suncc-common.h" +#elif defined (__PGI) +// Portable group compiler +# define ACE_HAS_CPLUSPLUS_HEADERS +# define ACE_HAS_STDCPP_STL_INCLUDES +# define ACE_HAS_TEMPLATE_TYPEDEFS +# define ACE_HAS_STANDARD_CPP_LIBRARY 1 +# define ACE_USES_STD_NAMESPACE_FOR_STDCPP_LIB 1 +# define ACE_LACKS_SWAB +#elif defined (__GNUC__) +/** + * GNU C compiler. + * + * We need to recognize the GNU C compiler since TAO has at least one + * C source header and file + * (TAO/orbsvcs/orbsvcs/SSLIOP/params_dup.{h,c}) that may indirectly + * include this + */ +#else /* ! __GNUG__ && !__DECCXX && !__INTEL_COMPILER && !__BORLANDC__ && !__PGI */ +# ifdef __cplusplus /* Let it slide for C compilers. */ +# error unsupported compiler in ace/config-linux-common.h +# endif /* __cplusplus */ +#endif /* ! __GNUG__*/ + +// Completely common part :-) + +// Platform/compiler has the sigwait(2) prototype +# define ACE_HAS_SIGWAIT + +# define ACE_HAS_SIGSUSPEND + +# define ACE_HAS_UALARM + +#if __GLIBC__ >= 2 +#ifndef ACE_HAS_POSIX_REALTIME_SIGNALS +#define ACE_HAS_POSIX_REALTIME_SIGNALS +#endif /* ACE_HAS_POSIX_REALTIME_SIGNALS */ + +#ifndef ACE_HAS_AIO_CALLS +#define ACE_HAS_AIO_CALLS +#endif /* ACE_HAS_AIO_CALLS */ +#endif + +#if __GLIBC__ >= 2 +// glibc 2 and higher has wchar support +# define ACE_HAS_XPG4_MULTIBYTE_CHAR +# define ACE_HAS_VFWPRINTF +#endif + +#if __GLIBC__ < 2 +// These are present in glibc 2 and higher +# define ACE_LACKS_WCSTOK +# define ACE_LACKS_WCSDUP_PROTOTYPE +#endif /* __GLIBC__ < 2 */ + +#define ACE_LACKS_ITOW +#define ACE_LACKS_WCSICMP +#define ACE_LACKS_WCSNICMP + +#if __GLIBC__ >= 2 +# define ACE_HAS_3_PARAM_WCSTOK +#endif + +#define ACE_HAS_3_PARAM_READDIR_R + +#if !defined (ACE_DEFAULT_BASE_ADDR) +# define ACE_DEFAULT_BASE_ADDR ((char *) 0x80000000) +#endif /* ! ACE_DEFAULT_BASE_ADDR */ + +// Compiler/platform supports alloca(). +// Although ACE does have alloca() on this compiler/platform combination, it is +// disabled by default since it can be dangerous. Uncomment the following line +// if you ACE to use it. +//#define ACE_HAS_ALLOCA + +// Compiler/platform has +#define ACE_HAS_ALLOCA_H +#define ACE_HAS_SYS_SYSINFO_H +#define ACE_HAS_LINUX_SYSINFO + +// Compiler/platform has the getrusage() system call. +#define ACE_HAS_GETRUSAGE +#define ACE_HAS_GETRUSAGE_PROTOTYPE + +#define ACE_HAS_BYTESWAP_H +#define ACE_HAS_BSWAP_16 +#define ACE_HAS_BSWAP_32 + +#if defined __GNUC__ && __GNUC__ >= 2 +# define ACE_HAS_BSWAP_64 +#endif + +#define ACE_HAS_CONSISTENT_SIGNAL_PROTOTYPES + +// Optimize ACE_Handle_Set for select(). +#define ACE_HAS_HANDLE_SET_OPTIMIZED_FOR_SELECT + +// ONLY define this if you have config'd multicast into a 2.0.34 or +// prior kernel. It is enabled by default in 2.0.35 kernels. +#if !defined (ACE_HAS_IP_MULTICAST) +# define ACE_HAS_IP_MULTICAST +#endif /* ! ACE_HAS_IP_MULTICAST */ + +// At least for IPv4, Linux lacks perfect filtering. +#if !defined ACE_LACKS_PERFECT_MULTICAST_FILTERING +# define ACE_LACKS_PERFECT_MULTICAST_FILTERING 1 +#endif /* ACE_LACKS_PERFECT_MULTICAST_FILTERING */ + +#define ACE_HAS_BIG_FD_SET + +// Linux defines struct msghdr in /usr/include/socket.h +#define ACE_HAS_MSG + +// Linux "improved" the interface to select() so that it modifies +// the struct timeval to reflect the amount of time not slept +// (see NOTES in Linux's select(2) man page). +#define ACE_HAS_NONCONST_SELECT_TIMEVAL + +#define ACE_DEFAULT_MAX_SOCKET_BUFSIZ 65535 + +#define ACE_CDR_IMPLEMENT_WITH_NATIVE_DOUBLE 1 + +#define ACE_HAS_GETPAGESIZE 1 + +#if (__GLIBC__ < 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 2) +// glibc supports wchar, but lacks fgetwc and ungetwc +# define ACE_LACKS_FGETWC +# define ACE_HAS_NONCONST_MSGSND +# define ACE_LACKS_STRNLEN_PROTOTYPE +#endif + +// glibc requires _XOPEN_SOURCE_EXTENDED to make this prototype +// visible, so force ACE to declare one. Yuk! +#ifndef _XOPEN_SOURCE_EXTENDED +# define ACE_LACKS_MKSTEMP_PROTOTYPE +#endif /* !_XOPEN_SOURCE_EXTENDED */ + +// Platform defines struct timespec but not timespec_t +#define ACE_LACKS_TIMESPEC_T + +// Platform supplies scandir() +#define ACE_HAS_SCANDIR +// Although the scandir man page says otherwise, this setting is correct. +#define ACE_SCANDIR_CMP_USES_CONST_VOIDPTR + +// A conflict appears when including both and +// with recent glibc headers. +//#define ACE_HAS_PROC_FS + +// Platform supports System V IPC (most versions of UNIX, but not Win32) +#define ACE_HAS_SYSV_IPC + +// Compiler/platform contains the file. +#define ACE_HAS_SYS_SYSCALL_H + +// Platform/compiler supports global timezone variable. +#define ACE_HAS_TIMEZONE + +#define ACE_HAS_TIMEZONE_GETTIMEOFDAY + +// Compiler/platform supports strerror (). +#define ACE_HAS_STRERROR + +// Don't define _XOPEN_SOURCE in ACE to make strptime() prototype +// visible. ACE shouldn't depend on feature test macros to make +// prototypes visible. +#define ACE_LACKS_STRPTIME_PROTOTYPE + +// Compiler supports the ssize_t typedef. +#define ACE_HAS_SSIZE_T + +// Compiler/platform defines the sig_atomic_t typedef. +#define ACE_HAS_SIG_ATOMIC_T + +// Compiler/platform defines a union semun for SysV shared memory. +#define ACE_HAS_SEMUN + +#define ACE_HAS_POSIX_TIME + +#define ACE_HAS_GPERF + +#define ACE_HAS_DIRENT + +// Starting with FC9 rawhide this file is not available anymore but +// this define is set +#if defined _XOPEN_STREAMS && _XOPEN_STREAMS == -1 +# define ACE_LACKS_STROPTS_H +# define ACE_LACKS_STRRECVFD +#endif + +#if !defined (ACE_LACKS_STROPTS_H) +# define ACE_HAS_STRBUF_T +#endif + +#if defined (__ia64) || defined(__alpha) || defined (__x86_64__) +// On 64 bit platforms, the "long" type is 64-bits. Override the +// default 32-bit platform-specific format specifiers appropriately. +# define ACE_UINT64_FORMAT_SPECIFIER ACE_TEXT ("%lu") +# define ACE_SSIZE_T_FORMAT_SPECIFIER ACE_TEXT ("%ld") +# define ACE_SIZE_T_FORMAT_SPECIFIER ACE_TEXT ("%lu") +#endif /* __ia64 */ + +#define ACE_SIZEOF_WCHAR 4 + +#define ACE_LACKS_GETIPNODEBYADDR +#define ACE_LACKS_GETIPNODEBYNAME + +// Platform has POSIX terminal interface. +#define ACE_HAS_TERMIOS + +// Linux implements sendfile(). +#define ACE_HAS_SENDFILE + +#define ACE_HAS_VOIDPTR_MMAP + +#if defined (ACE_LACKS_NETWORKING) +# include "ace/config-posix-nonetworking.h" +#else +# define ACE_HAS_NETLINK +# define ACE_HAS_GETIFADDRS +#endif + +#if !defined (ACE_GETNAME_RETURNS_RANDOM_SIN_ZERO) +// Detect if getsockname() and getpeername() returns random values in +// the sockaddr_in::sin_zero field by evaluation of the kernel +// version. Since version 2.5.47 this problem is fixed. +# if !defined (ACE_LACKS_LINUX_VERSION_H) +# include +# endif /* !ACE_LACKS_LINUX_VERSION_H */ +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,47)) +# define ACE_GETNAME_RETURNS_RANDOM_SIN_ZERO 0 +# else +# define ACE_GETNAME_RETURNS_RANDOM_SIN_ZERO 1 +# endif /* (LINUX_VERSION_CODE <= KERNEL_VERSION(2,5,47)) */ +#endif /* ACE_GETNAME_RETURNS_RANDOM_SIN_ZERO */ + +#if defined (ACE_HAS_EVENT_POLL) +// The sys_epoll interface was introduced in Linux kernel 2.5.45. +// Don't support backported versions since they appear to be buggy. +// The obsolete ioctl()-based interface is no longer supported. +#if 0 +// linux/version.h may not be accurate. It's not for Fedora Core 2... +# if !defined (ACE_LACKS_LINUX_VERSION_H) +# include +# endif /* !ACE_LACKS_LINUX_VERSION_H */ +# if (LINUX_VERSION_CODE < KERNEL_VERSION (2,5,45)) +# undef ACE_HAS_EVENT_POLL +# error Disabling Linux epoll support. Kernel used in C library is too old. +# error Linux kernel 2.5.45 or better is required. +# endif /* LINUX_VERSION_CODE < KERNEL_VERSION (2,5,45) */ +#endif /* ACE_HAS_EVENT_POLL */ +#endif + +#if !defined (ACE_HAS_EVENT_POLL) && !defined (ACE_HAS_DEV_POLL) +# if !defined (ACE_LACKS_LINUX_VERSION_H) +# include +# endif /* !ACE_LACKS_LINUX_VERSION_H */ +# if (LINUX_VERSION_CODE > KERNEL_VERSION (2,6,0)) +# define ACE_HAS_EVENT_POLL +# endif +#endif + +#include /**/ "ace/post.h" + +#endif /* ACE_LINUX_COMMON_H */ diff --git a/dep/ACE_wrappers/ace/config-linux.h b/dep/ACE_wrappers/ace/config-linux.h new file mode 100644 index 00000000000..8b79c13a415 --- /dev/null +++ b/dep/ACE_wrappers/ace/config-linux.h @@ -0,0 +1,75 @@ +// -*- C++ -*- +// +// $Id: config-linux.h 80826 2008-03-04 14:51:23Z wotte $ + +// The following configuration file is designed to work for Linux +// platforms using GNU C++. + +#ifndef ACE_CONFIG_LINUX_H +#define ACE_CONFIG_LINUX_H +#include /**/ "ace/pre.h" + +#define ACE_PLATFORM_CONFIG config-linux.h + +#include "ace/config-linux-common.h" + +#define ACE_HAS_SVR4_DYNAMIC_LINKING +#define ACE_HAS_AUTOMATIC_INIT_FINI +#define ACE_HAS_DLSYM_SEGFAULT_ON_INVALID_HANDLE + +#if !defined (ACE_MT_SAFE) +#define ACE_MT_SAFE 1 // JCEJ 12/22/96 #1 +#endif + +#if ACE_MT_SAFE +// Yes, we do have threads. +#define ACE_HAS_THREADS +// And they're even POSIX pthreads (LinuxThreads implementation) +#define ACE_HAS_PTHREADS + +// On linux this is part of pthreads +# if (defined _POSIX_C_SOURCE && (_POSIX_C_SOURCE - 0) >= 199309L) +# if !defined (ACE_HAS_CLOCK_GETTIME) +# if !defined(__PGI) +# define ACE_HAS_CLOCK_GETTIME +# endif /* __PGI */ +# define ACE_HAS_CLOCK_SETTIME +# endif /* !ACE_HAS_CLOCK_GETTIME */ +# endif /* _POSIX_C_SOURCE >= 199309L */ + +#if !defined (ACE_HAS_PTHREADS_UNIX98_EXT) +# define ACE_LACKS_RWLOCK_T +#else +# define ACE_HAS_RECURSIVE_MUTEXES +#endif /* !ACE_HAS_PTHREADS_UNIX98_EXT */ + +#define ACE_HAS_THREAD_SPECIFIC_STORAGE // jcej 12/22/96 #2 + +#define ACE_HAS_RECURSIVE_THR_EXIT_SEMANTICS // JCEJ 1/7-8/96 + +#if defined(__GLIBC__) +// Platform supports reentrant functions (i.e., all the POSIX *_r +// functions). +#define ACE_HAS_REENTRANT_FUNCTIONS + +#if (__GLIBC__ < 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 1) + // Older versions of glibc lacked reentrant netdb functions +# define ACE_LACKS_NETDB_REENTRANT_FUNCTIONS + + // glibc < 2.1 lacks pthread_attr_setstacksize() +# define ACE_LACKS_PTHREAD_ATTR_SETSTACKSIZE +#endif /* (__GLIBC__ < 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 1) */ + +// uses ctime_r & asctime_r with only two parameters vs. three +#define ACE_HAS_2_PARAM_ASCTIME_R_AND_CTIME_R +#endif + +#else +// AIO support pulls in the rt library, which pulls in the pthread +// library. Disable AIO in single-threaded builds. +# undef ACE_HAS_AIO_CALLS +#endif /* ACE_MT_SAFE */ + +#include /**/ "ace/post.h" + +#endif /* ACE_CONFIG_LINUX_H */ diff --git a/dep/ACE_wrappers/ace/config-lite.h b/dep/ACE_wrappers/ace/config-lite.h new file mode 100644 index 00000000000..0992925a601 --- /dev/null +++ b/dep/ACE_wrappers/ace/config-lite.h @@ -0,0 +1,164 @@ +// -*- C++ -*- + +//========================================================================== +/** + * @file config-lite.h + * + * $Id: config-lite.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author (Originally in OS.h)Doug Schmidt + * @author Jesper S. M|ller + * @author and a cast of thousands... + * + * This file contains the contents of the old config-all.h in order to + * avoid a circular dependency problem caused by some of the new + * includes added to config-all.h, e.g., OS_main.h. + */ +//========================================================================== + +#ifndef ACE_CONFIG_LITE_H +#define ACE_CONFIG_LITE_H + +#include /**/ "ace/pre.h" + +#include "ace/config-macros.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +// Empty ACE_OS namespace to help identify compiler errors more +// easily. -- @@ Do we really need this? +ACE_BEGIN_VERSIONED_NAMESPACE_DECL +namespace ACE_OS {} +ACE_END_VERSIONED_NAMESPACE_DECL + +// ============================================================================ +// UNICODE macros (to be added later) +// ============================================================================ + +// Get the unicode (i.e. ACE_TCHAR) defines +# include "ace/ace_wchar.h" + +// ============================================================================ +// at_exit declarations +// ============================================================================ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +// Marker for cleanup, used by ACE_Exit_Info. +extern int ace_exit_hook_marker; + +ACE_END_VERSIONED_NAMESPACE_DECL + +// For use by . +extern "C" +{ + typedef void (*ACE_EXIT_HOOK) (void); +} + +// Signature for registering a cleanup function that is used by the +// ACE_Object_Manager and the ACE_Thread_Manager. +# if defined (ACE_HAS_SIG_C_FUNC) +extern "C" { +# endif /* ACE_HAS_SIG_C_FUNC */ +typedef void (*ACE_CLEANUP_FUNC)(void *object, void *param) /* throw () */; +# if defined (ACE_HAS_SIG_C_FUNC) +} +# endif /* ACE_HAS_SIG_C_FUNC */ + +// ============================================================================ +// log_msg declarations +// ============================================================================ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +# if defined (ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS) +typedef int (*ACE_SEH_EXCEPT_HANDLER)(void *); +// Prototype of win32 structured exception handler functions. +// They are used to get the exception handling expression or +// as exception handlers. +# endif /* ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS */ + +class ACE_OS_Thread_Descriptor; +class ACE_OS_Log_Msg_Attributes; +typedef void (*ACE_INIT_LOG_MSG_HOOK) (ACE_OS_Log_Msg_Attributes &attr +# if defined (ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS) + , ACE_SEH_EXCEPT_HANDLER selector + , ACE_SEH_EXCEPT_HANDLER handler +# endif /* ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS */ + ); +typedef void (*ACE_INHERIT_LOG_MSG_HOOK) (ACE_OS_Thread_Descriptor*, + ACE_OS_Log_Msg_Attributes &); + +typedef void (*ACE_CLOSE_LOG_MSG_HOOK) (void); + +typedef void (*ACE_SYNC_LOG_MSG_HOOK) (const ACE_TCHAR *prog_name); + +typedef ACE_OS_Thread_Descriptor *(*ACE_THR_DESC_LOG_MSG_HOOK) (void); + +ACE_END_VERSIONED_NAMESPACE_DECL + +/** + * @deprecated ACE_DECLARE_STL_REVERSE_ITERATORS is a crutch to be + * used until all C++ compiler supported by ACE support + * the standard reverse_iterator adapters. + * @internal ACE_DECLARE_STL_REVERSE_ITERATORS is not meant for use + * outside of ACE. + */ +// STL reverse_iterator declaration generator +// Make sure you include in the file you're using this +// generator, and that the following traits are available: +// +// iterator +// const_iterator +// value_type +// reference +// pointer +// const_reference +// const_pointer +// difference_type +// +// Once all C++ compilers support the standard reverse_iterator +// adapters, we can drop this generator macro or at least drop the +// MSVC++ or Sun Studio preprocessor conditional blocks. +#if defined (__SUNPRO_CC) && __SUNPRO_CC <= 0x590 \ + && !defined (_STLPORT_VERSION) + // If we're not using the stlport4 C++ library (which has standard + // iterators), we need to ensure this is included in order to test + // the _RWSTD_NO_CLASS_PARTIAL_SPEC feature test macro below. +# include +#endif /* __SUNPRO_CC <= 0x580 */ +#if (defined (_MSC_VER) && (_MSC_VER <= 1310) && defined (_WIN64)) \ + || defined (ACE_HAS_BROKEN_STD_REVERSE_ITERATOR) + // VC 7.1 and the latest 64-bit platform SDK still don't define a standard + // compliant reverse_iterator adapter. +# define ACE_DECLARE_STL_REVERSE_ITERATORS \ + typedef std::reverse_iterator reverse_iterator; \ + typedef std::reverse_iterator const_reverse_iterator; +#elif defined (__SUNPRO_CC) && __SUNPRO_CC <= 0x590 \ + && defined (_RWSTD_NO_CLASS_PARTIAL_SPEC) +# define ACE_DECLARE_STL_REVERSE_ITERATORS \ + typedef std::reverse_iterator reverse_iterator; \ + typedef std::reverse_iterator const_reverse_iterator; +#else +# define ACE_DECLARE_STL_REVERSE_ITERATORS \ + typedef std::reverse_iterator reverse_iterator; \ + typedef std::reverse_iterator const_reverse_iterator; +#endif /* _MSC_VER && _WIN64 */ + + +#include /**/ "ace/post.h" + +#endif /* ACE_CONFIG_LITE_H */ diff --git a/dep/ACE_wrappers/ace/config-lynxos.h b/dep/ACE_wrappers/ace/config-lynxos.h new file mode 100644 index 00000000000..c65e9b0f72a --- /dev/null +++ b/dep/ACE_wrappers/ace/config-lynxos.h @@ -0,0 +1,162 @@ +// $Id: config-lynxos.h 81780 2008-05-26 13:56:49Z olli $ + +// The following configuration file is designed to work for LynxOS, +// version 4.0.0 and later, using the GNU g++ compiler. + +#ifndef ACE_CONFIG_H +#define ACE_CONFIG_H +#include /**/ "ace/pre.h" + +#if ! defined (__ACE_INLINE__) +# define __ACE_INLINE__ +#endif /* ! __ACE_INLINE__ */ + +#if defined (__GNUG__) +# include "ace/config-g++-common.h" +#endif /* __GNUG__ */ + +// Compile using multi-thread libraries. +#if !defined (ACE_MT_SAFE) +# define ACE_MT_SAFE 1 +#endif + +#include "ace/config-posix.h" + +#if defined (__x86__) +# define ACE_HAS_PENTIUM +#elif defined (__powerpc__) + // It looks like the default stack size is 15000. + // ACE's Recursive_Mutex_Test needs more. +# define ACE_NEEDS_HUGE_THREAD_STACKSIZE 65536 + // This doesn't work on LynxOS 3.0.0, because it resets the TimeBaseRegister. + // # define ACE_HAS_POWERPC_TIMER +#endif /* __x86__ || __powerpc__ */ + +#define ACE_DEFAULT_BASE_ADDR ((char *) 0) +#define ACE_HAS_4_4BSD_SENDMSG_RECVMSG +#define ACE_HAS_ALLOCA +#define ACE_HAS_ALLOCA_H +#define ACE_HAS_AUTOMATIC_INIT_FINI +#define ACE_HAS_BROKEN_PREALLOCATED_OBJECTS_AFTER_FORK 1 +#define ACE_HAS_BROKEN_SIGEVENT_STRUCT +#define ACE_HAS_CHARPTR_SHMAT +#define ACE_HAS_CHARPTR_SHMDT +#define ACE_HAS_CLOCK_GETTIME +#define ACE_HAS_CLOCK_SETTIME +#define ACE_HAS_CPLUSPLUS_HEADERS +#define ACE_HAS_DIRENT +#define ACE_HAS_GETPAGESIZE +#define ACE_HAS_GETRUSAGE +#define ACE_HAS_GNU_CSTRING_H +#define ACE_HAS_GPERF +#define ACE_HAS_ICMP_SUPPORT 1 +#define ACE_HAS_IP_MULTICAST +#define ACE_HAS_LYNXOS_SIGNALS +#define ACE_HAS_MSG +#define ACE_HAS_NONCONST_CLOCK_SETTIME +#define ACE_HAS_NONCONST_MSGSND +#define ACE_HAS_NONCONST_READV +#define ACE_HAS_NONCONST_SELECT_TIMEVAL +#define ACE_HAS_NONCONST_SETRLIMIT +#define ACE_HAS_NONCONST_WRITEV +#define ACE_HAS_POSIX_NONBLOCK +#define ACE_HAS_POSIX_TIME +#define ACE_HAS_RECURSIVE_THR_EXIT_SEMANTICS +#define ACE_HAS_SCANDIR +#define ACE_HAS_SEMUN +#define ACE_HAS_SIGINFO_T +#define ACE_HAS_SIGTIMEDWAIT +#define ACE_HAS_SIGWAIT +#define ACE_HAS_SIG_ATOMIC_T +#define ACE_HAS_SSIZE_T +#define ACE_HAS_STRBUF_T +#define ACE_HAS_STREAMS +#define ACE_HAS_STRERROR +#define ACE_HAS_SYSV_IPC +#define ACE_HAS_SYS_SIGLIST +#define ACE_HAS_SYS_SOCKIO_H +#define ACE_HAS_TERMIOS +#define ACE_HAS_TIMEZONE_GETTIMEOFDAY +#define ACE_LACKS_ALPHASORT_PROTOTYPE +#define ACE_LACKS_CONST_TIMESPEC_PTR +#define ACE_LACKS_GETPGID +#define ACE_LACKS_MADVISE +#define ACE_LACKS_MKSTEMP_PROTOTYPE +#define ACE_LACKS_MKTEMP_PROTOTYPE +#define ACE_LACKS_PUTENV_PROTOTYPE +#define ACE_LACKS_REALPATH +#define ACE_LACKS_RLIMIT_NOFILE +#define ACE_LACKS_RWLOCK_T +#define ACE_LACKS_SCANDIR_PROTOTYPE +#define ACE_LACKS_SETEGID +#define ACE_LACKS_SETEUID +#define ACE_LACKS_SIGINFO_H +#define ACE_LACKS_STRPTIME +#define ACE_LACKS_SUSECONDS_T +#define ACE_LACKS_SWAB_PROTOTYPE +#define ACE_LACKS_TIMESPEC_T +#define ACE_LACKS_UCONTEXT_H +#define ACE_LACKS_USECONDS_T +#define ACE_LACKS_VSNPRINTF +#define ACE_LACKS_WCHAR_H +#define ACE_MALLOC_ALIGN 8 +#define ACE_PAGE_SIZE 4096 +#define ACE_POSIX_SIG_PROACTOR +#define ACE_SCANDIR_CMP_USES_CONST_VOIDPTR + +// LynxOS has poll.h but it is unusable since implementation is not provided +#define ACE_LACKS_POLL_H + +#if ACE_MT_SAFE == 1 + // Platform supports threads. +# define ACE_HAS_PTHREADS +# define ACE_HAS_THREAD_SPECIFIC_STORAGE +# define ACE_LACKS_NULL_PTHREAD_STATUS +# define ACE_LACKS_THREAD_PROCESS_SCOPING +# define ACE_LACKS_PTHREAD_ATTR_SETSTACK +# if ACE_LYNXOS_MAJOR == 4 && ACE_LYNXOS_MINOR == 0 +# define ACE_LACKS_SETDETACH +# define ACE_LACKS_PTHREAD_ATTR_SETSTACKADDR +# endif +#endif /* ACE_MT_SAFE */ + +#if __GNUC__ < 3 +# define ACE_LACKS_NUMERIC_LIMITS +#endif /* __GNUC__ < 3 */ + +// By default, don't include RCS Id strings in object code. +#if !defined (ACE_USE_RCSID) +# define ACE_USE_RCSID 0 +#endif /* ! ACE_USE_RCSID */ + +// System include files are not in sys/, this gets rid of warning. +#define __NO_INCLUDE_WARN__ + +// "changes signedness" error (OS.i and many other files) +#define ACE_HAS_SOCKLEN_T +// LSOCK.cpp uses a macro from param.h, not included +#define ALIGNBYTES (sizeof(int) - 1) +#define ALIGN(p) (((unsigned)p + ALIGNBYTES) & ~ALIGNBYTES) + +#if ACE_LYNXOS_MAJOR == 4 && ACE_LYNXOS_MINOR == 0 +# define ACE_LACKS_GETOPT_PROTOTYPE +# define ACE_LACKS_INET_ATON_PROTOTYPE +# define ACE_LACKS_REGEX_H +# define ACE_LACKS_STRCASECMP_PROTOTYPE +# define ACE_LACKS_STRNCASECMP_PROTOTYPE +# define ACE_LACKS_SYS_SELECT_H +# define ACE_HAS_NONCONST_GETBY +#endif + +#if (ACE_LYNXOS_MAJOR > 4) || (ACE_LYNXOS_MAJOR == 4 && ACE_LYNXOS_MINOR >= 2) +// LynxOS 4.2 additons +# define ACE_HAS_POSIX_SEM_TIMEOUT +# define ACE_HAS_MUTEX_TIMEOUTS +#endif + +#if defined (ACE_HAS_SVR4_DYNAMIC_LINKING) +# define ACE_HAS_BROKEN_THREAD_KEYFREE +#endif /* ACE_HAS_SVR4_DYNAMIC_LINKING */ + +#include /**/ "ace/post.h" +#endif /* ACE_CONFIG_H */ diff --git a/dep/ACE_wrappers/ace/config-macosx-leopard.h b/dep/ACE_wrappers/ace/config-macosx-leopard.h new file mode 100644 index 00000000000..a56067b9707 --- /dev/null +++ b/dep/ACE_wrappers/ace/config-macosx-leopard.h @@ -0,0 +1,227 @@ +/* -*- C++ -*- */ +// $Id: config-macosx-leopard.h 81858 2008-06-07 03:31:22Z dai_y $ + +// This configuration file is designed to work with the MacOS X operating system. + +#ifndef ACE_CONFIG_MACOSX_LEOPARD_H +#define ACE_CONFIG_MACOSX_LEOPARD_H + +#if ! defined (__ACE_INLINE__) +#define __ACE_INLINE__ +#endif /* ! __ACE_INLINE__ */ + +#if !defined (ACE_SIZEOF_LONG_DOUBLE) +# if (__GNUC__ == 3 && __GNUC_MINOR__ == 3) + // Size of long double in GCC 3.3 is 8. +# define ACE_SIZEOF_LONG_DOUBLE 8 +# else // Else, the compiler is GCC4 + // For GCC4, the size is 16. +# define ACE_SIZEOF_LONG_DOUBLE 16 +# endif // GCC 3.3 +#endif // ACE_SIZEOF_LONG_DOUBLE + +#if defined (__GNUG__) +# include "ace/config-g++-common.h" +#endif /* __GNUG__ */ + +#ifndef ACE_HAS_NONCONST_FD_ISSET +#define ACE_HAS_NONCONST_FD_ISSET +#endif + +#define ACE_HAS_WORKING_EXPLICIT_TEMPLATE_DESTRUCTOR + +#define ACE_SIZE_T_FORMAT_SPECIFIER ACE_TEXT ("%lu") + +#if !defined (__i386__) +# if defined (ACE_HAS_PENTIUM) +# undef ACE_HAS_PENTIUM +# endif /* ACE_HAS_PENTIUM */ +#else // __i386__ +# define ACE_HAS_PENTIUM +#endif //__i386__ + +#if !defined (_THREAD_SAFE) +#define _THREAD_SAFE +#endif /* _THREAD_SAFE */ + +#define ACE_HAS_GPERF +#define ACE_HAS_POSIX_SEM + +#define ACE_HAS_SUNOS4_GETTIMEOFDAY + +#define ACE_LACKS_STROPTS_H + +// Platform provides header. +#define ACE_HAS_EXECINFO_H + +// Wcharness.... +#define ACE_HAS_WCHAR +#define ACE_SIZEOF_WCHAR 4 + + +#define ACE_HAS_3_PARAM_WCSTOK +#define ACE_LACKS_ITOW +#define ACE_LACKS_WCSICMP +#define ACE_LACKS_WCSNICMP +#define ACE_LACKS_WCSDUP + +// Mac lacks the following pthread features +#define ACE_LACKS_MUTEXATTR_PSHARED +#define ACE_LACKS_CONDATTR_PSHARED +// +// Compiler/platform defines the sig_atomic_t typedef. +#define ACE_HAS_SIG_ATOMIC_T + +// Compiler/platform supports SVR4 signal typedef +#define ACE_HAS_SVR4_SIGNAL_T + +//Platform/compiler has the sigwait(2) prototype +#define ACE_HAS_SIGWAIT + +#define ACE_HAS_AIO_CALLS + +//Platform supports sigsuspend() +#define ACE_HAS_SIGSUSPEND + +//Platform/compiler has macros for sig{empty,fill,add,del}set (e.g., SCO and FreeBSD) +#define ACE_HAS_SIG_MACROS + +#define ACE_LACKS_GETPGID +#define ACE_LACKS_RWLOCK_T + +// Optimize ACE_Handle_Set for select(). +#define ACE_HAS_HANDLE_SET_OPTIMIZED_FOR_SELECT + +#define ACE_HAS_NONCONST_SELECT_TIMEVAL + +//? +#define ACE_LACKS_SIGSET + +#define ACE_NEEDS_SCHED_H + +// Use of is deprecated. +#define ACE_LACKS_MALLOC_H + +#define ACE_HAS_ALT_CUSERID + +// Platform supports POSIX timers via struct timespec. +#define ACE_HAS_POSIX_TIME +#define ACE_HAS_UALARM + +// Platform defines struct timespec but not timespec_t +#define ACE_LACKS_TIMESPEC_T + +#define ACE_LACKS_STRRECVFD + +#define ACE_HAS_SOCKADDR_IN6_SIN6_LEN + +// Platform supports System V IPC (most versions of UNIX, but not Win32) +#define ACE_HAS_SYSV_IPC + +// Compiler/platform contains the file. +#define ACE_HAS_SYS_SYSCALL_H + +#define ACE_HAS_CONSISTENT_SIGNAL_PROTOTYPES + +// Compiler/platform supports alloca(). +// Although ACE does have alloca() on this compiler/platform combination, it is +// disabled by default since it can be dangerous. Uncomment the following line +// if you ACE to use it. +//#define ACE_HAS_ALLOCA + +// Compiler/platform correctly calls init()/fini() for shared libraries. +#define ACE_HAS_AUTOMATIC_INIT_FINI + +// platform supports POSIX O_NONBLOCK semantics +#define ACE_HAS_POSIX_NONBLOCK + +// platform supports IP multicast +#define ACE_HAS_IP_MULTICAST +#define ACE_LACKS_PERFECT_MULTICAST_FILTERING 1 + +// Compiler/platform has the getrusage() system call. +#define ACE_HAS_GETRUSAGE + +// Compiler supports the ssize_t typedef. +#define ACE_HAS_SSIZE_T + +// Compiler/platform supports strerror (). +#define ACE_HAS_STRERROR + +// Compiler/platform provides the sockio.h file. +#define ACE_HAS_SYS_SOCKIO_H + +// Compiler/platform provides the socklen_t type. +#define ACE_HAS_SOCKLEN_T + +// Defines the page size of the system. +#define ACE_HAS_GETPAGESIZE + +// Platform provides header. +#define ACE_HAS_SYS_FILIO_H + +// Platform/compiler supports timezone * as second parameter to gettimeofday(). +#define ACE_HAS_TIMEZONE_GETTIMEOFDAY + +#define ACE_LACKS_SYS_MSG_H +#define ACE_LACKS_SYSV_MSQ_PROTOS +#define ACE_HAS_MSG +#define ACE_HAS_4_4BSD_SENDMSG_RECVMSG +#define ACE_HAS_NONCONST_MSGSND + +#if !defined (ACE_MT_SAFE) +# define ACE_MT_SAFE 1 +#endif + +#if ACE_MT_SAFE == 1 +// Yes, we do have threads. +# define ACE_HAS_THREADS +// And they're even POSIX pthreads +# define ACE_HAS_PTHREADS +# define ACE_HAS_PTHREADS_STD +# define ACE_HAS_PTHREAD_SCHEDPARAM +# define ACE_HAS_THREAD_SPECIFIC_STORAGE +#endif /* ACE_MT_SAFE == 1 */ + +#define ACE_LACKS_THREAD_PROCESS_SCOPING + +#define ACE_HAS_DIRENT +#define ACE_LACKS_POLL_H +#define ACE_LACKS_SEARCH_H + +#define ACE_LACKS_SETSCHED +//#define ACE_HAS_RECURSIVE_MUTEXES + +// Platform has POSIX terminal interface. +#define ACE_HAS_TERMIOS + +#define ACE_HAS_SEMUN +#define ACE_HAS_SIGINFO_T +#define ACE_LACKS_SIGINFO_H +#define ACE_HAS_UCONTEXT_T +#define ACE_HAS_GETIFADDRS +#define ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES +#define ACE_LACKS_UNNAMED_SEMAPHORE + +// dlcompat package (not part of base Darwin) is needed for dlopen(). +// You may download directly from sourceforge and install or use fink +// Fink installer puts libraries in /sw/lib and headers in /sw/include +// In order to install dlcompat do the following: +// - download fink from http://fink.sf.net +// - type: +// fink install dlcompat +// as of Dec 2002, if you use fink you will need to uncomment the next line +// #define ACE_NEEDS_DL_UNDERSCORE +#define ACE_HAS_SVR4_DYNAMIC_LINKING +#define ACE_LD_SEARCH_PATH ACE_TEXT ("DYLD_LIBRARY_PATH") +#define ACE_DLL_SUFFIX ACE_TEXT (".dylib") +//#define ACE_LACKS_DLCLOSE + +// gperf seems to need this +//#define ACE_HAS_NONSTATIC_OBJECT_MANAGER + +#if defined(__APPLE_CC__) && (__APPLE_CC__ < 1173) +#error "Compiler must be upgraded, see http://developer.apple.com" +#endif /* __APPLE_CC__ */ + +#endif /* ACE_CONFIG_MACOSX_TIGER_H */ diff --git a/dep/ACE_wrappers/ace/config-macosx-panther.h b/dep/ACE_wrappers/ace/config-macosx-panther.h new file mode 100644 index 00000000000..8b4010e796a --- /dev/null +++ b/dep/ACE_wrappers/ace/config-macosx-panther.h @@ -0,0 +1,191 @@ +/* -*- C++ -*- */ +// $Id: config-macosx-panther.h 80826 2008-03-04 14:51:23Z wotte $ + +// This configuration file is designed to work with the MacOS X operating system. + +#ifndef ACE_CONFIG_MACOSX_H +#define ACE_CONFIG_MACOSX_H + +#if ! defined (__ACE_INLINE__) +#define __ACE_INLINE__ +#endif /* ! __ACE_INLINE__ */ + +#if defined (__GNUG__) +# include "ace/config-g++-common.h" +#endif /* __GNUG__ */ + +#define ACE_LACKS_SUSECONDS_T +#define ACE_SIZE_T_FORMAT_SPECIFIER ACE_TEXT ("%lu") + +#if defined (ACE_HAS_PENTIUM) +# undef ACE_HAS_PENTIUM +#endif /* ACE_HAS_PENTIUM */ + +#if !defined (_THREAD_SAFE) +#define _THREAD_SAFE +#endif /* _THREAD_SAFE */ + +#define ACE_HAS_GPERF +#define ACE_HAS_POSIX_SEM + +//#define ACE_HAS_SVR4_TLI + +#define ACE_LACKS_STROPTS_H +#define ACE_LACKS_WCHAR_H + +// +// Compiler/platform defines the sig_atomic_t typedef. +#define ACE_HAS_SIG_ATOMIC_T + +// Compiler/platform supports SVR4 signal typedef +#define ACE_HAS_SVR4_SIGNAL_T + +//Platform/compiler has the sigwait(2) prototype +#define ACE_HAS_SIGWAIT + +//Platform supports sigsuspend() +#define ACE_HAS_SIGSUSPEND + +//Platform/compiler has macros for sig{empty,fill,add,del}set (e.g., SCO and FreeBSD) +#define ACE_HAS_SIG_MACROS + +//#define ACE_HAS_RECURSIVE_THR_EXIT_SEMANTICS +#define ACE_LACKS_GETPGID +#define ACE_LACKS_RWLOCK_T + +// Optimize ACE_Handle_Set for select(). +#define ACE_HAS_HANDLE_SET_OPTIMIZED_FOR_SELECT + +#define ACE_HAS_NONCONST_SELECT_TIMEVAL + +//? +#define ACE_LACKS_SIGSET + +#define ACE_NEEDS_SCHED_H + +// Use of is deprecated. +#define ACE_LACKS_MALLOC_H + +#define ACE_HAS_ALT_CUSERID + +// Platform supports POSIX timers via struct timespec. +#define ACE_HAS_POSIX_TIME +#define ACE_HAS_UALARM + +// Platform defines struct timespec but not timespec_t +#define ACE_LACKS_TIMESPEC_T + +#define ACE_LACKS_STRRECVFD + +#define ACE_HAS_SOCKADDR_IN_SIN_LEN +#define ACE_HAS_SOCKADDR_IN6_SIN6_LEN + +// Platform supports System V IPC (most versions of UNIX, but not Win32) +#define ACE_HAS_SYSV_IPC + +// Compiler/platform contains the file. +#define ACE_HAS_SYS_SYSCALL_H + +#define ACE_HAS_CONSISTENT_SIGNAL_PROTOTYPES + +// Compiler/platform supports alloca(). +// Although ACE does have alloca() on this compiler/platform combination, it is +// disabled by default since it can be dangerous. Uncomment the following line +// if you ACE to use it. +//#define ACE_HAS_ALLOCA + +// Compiler/platform correctly calls init()/fini() for shared libraries. +#define ACE_HAS_AUTOMATIC_INIT_FINI + +// Explicit dynamic linking permits "lazy" symbol resolution +//#define ACE_HAS_RTLD_LAZY_V + +// platform supports POSIX O_NONBLOCK semantics +#define ACE_HAS_POSIX_NONBLOCK + +// platform supports IP multicast +#define ACE_HAS_IP_MULTICAST +#define ACE_LACKS_PERFECT_MULTICAST_FILTERING 1 + +// Compiler/platform has the getrusage() system call. +#define ACE_HAS_GETRUSAGE + +// Compiler supports the ssize_t typedef. +#define ACE_HAS_SSIZE_T + +// Compiler/platform supports strerror (). +#define ACE_HAS_STRERROR + +// Compiler/platform provides the sockio.h file. +#define ACE_HAS_SYS_SOCKIO_H + +// Defines the page size of the system. +#define ACE_HAS_GETPAGESIZE + +// Platform provides header. +#define ACE_HAS_SYS_FILIO_H + +// Platform/compiler supports timezone * as second parameter to gettimeofday(). +#define ACE_HAS_TIMEZONE_GETTIMEOFDAY + +#define ACE_LACKS_SYS_MSG_H +#define ACE_LACKS_SYSV_MSQ_PROTOS +#define ACE_HAS_MSG +#define ACE_HAS_4_4BSD_SENDMSG_RECVMSG +#define ACE_HAS_NONCONST_MSGSND + +#if !defined (ACE_MT_SAFE) +# define ACE_MT_SAFE 1 +#endif + +#if ACE_MT_SAFE == 1 +// Yes, we do have threads. +# define ACE_HAS_THREADS +// And they're even POSIX pthreads +# define ACE_HAS_PTHREADS +# define ACE_HAS_PTHREAD_SCHEDPARAM +# define ACE_HAS_THREAD_SPECIFIC_STORAGE +#endif /* ACE_MT_SAFE == 1 */ + +# define ACE_LACKS_THREAD_PROCESS_SCOPING + +#define ACE_HAS_DIRENT +#define ACE_LACKS_POLL_H +#define ACE_LACKS_SEARCH_H + +#define ACE_LACKS_SETSCHED +//#define ACE_HAS_RECURSIVE_MUTEXES + +// Platform has POSIX terminal interface. +#define ACE_HAS_TERMIOS + +#define ACE_HAS_SEMUN +#define ACE_HAS_SIGINFO_T +#define ACE_LACKS_SIGINFO_H +#define ACE_HAS_UCONTEXT_T +#define ACE_HAS_GETIFADDRS +#define ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES +#define ACE_LACKS_UNNAMED_SEMAPHORE + +// dlcompat package (not part of base Darwin) is needed for dlopen(). +// You may download directly from sourceforge and install or use fink +// Fink installer puts libraries in /sw/lib and headers in /sw/include +// In order to install dlcompat do the following: +// - download fink from http://fink.sf.net +// - type: +// fink install dlcompat +// as of Dec 2002, if you use fink you will need to uncomment the next line +//#define ACE_NEEDS_DL_UNDERSCORE +#define ACE_HAS_SVR4_DYNAMIC_LINKING +#define ACE_LD_SEARCH_PATH ACE_TEXT ("DYLD_LIBRARY_PATH") +#define ACE_DLL_SUFFIX ACE_TEXT (".dylib") +//#define ACE_LACKS_DLCLOSE + +// gperf seems to need this +//#define ACE_HAS_NONSTATIC_OBJECT_MANAGER + +#if defined(__APPLE_CC__) && (__APPLE_CC__ < 1173) +#error "Compiler must be upgraded, see http://developer.apple.com" +#endif /* __APPLE_CC__ */ + +#endif /* ACE_CONFIG_MACOSX_H */ diff --git a/dep/ACE_wrappers/ace/config-macosx-tiger.h b/dep/ACE_wrappers/ace/config-macosx-tiger.h new file mode 100644 index 00000000000..f920690edb0 --- /dev/null +++ b/dep/ACE_wrappers/ace/config-macosx-tiger.h @@ -0,0 +1,219 @@ +/* -*- C++ -*- */ +// $Id: config-macosx-tiger.h 82344 2008-07-19 20:04:18Z johnnyw $ + +// This configuration file is designed to work with the MacOS X operating system. + +#ifndef ACE_CONFIG_MACOSX_TIGER_H +#define ACE_CONFIG_MACOSX_TIGER_H + +#if ! defined (__ACE_INLINE__) +#define __ACE_INLINE__ +#endif /* ! __ACE_INLINE__ */ + +#if !defined (ACE_SIZEOF_LONG_DOUBLE) +# if (__GNUC__ == 3 && __GNUC_MINOR__ == 3) + // Size of long double in GCC 3.3 is 8. +# define ACE_SIZEOF_LONG_DOUBLE 8 +# else // Else, the compiler is GCC4 + // For GCC4, the size is 16. +# define ACE_SIZEOF_LONG_DOUBLE 16 +# endif // GCC 3.3 +#endif // ACE_SIZEOF_LONG_DOUBLE + +#if defined (__GNUG__) +# include "ace/config-g++-common.h" +#endif /* __GNUG__ */ + +#define ACE_HAS_WORKING_EXPLICIT_TEMPLATE_DESTRUCTOR + +#define ACE_SIZE_T_FORMAT_SPECIFIER ACE_TEXT ("%lu") + +#if !defined (__i386__) +# if defined (ACE_HAS_PENTIUM) +# undef ACE_HAS_PENTIUM +# endif /* ACE_HAS_PENTIUM */ +#else // __i386__ +# define ACE_HAS_PENTIUM +#endif //__i386__ + +#if !defined (_THREAD_SAFE) +#define _THREAD_SAFE +#endif /* _THREAD_SAFE */ + +#define ACE_HAS_GPERF +#define ACE_HAS_POSIX_SEM + +#define ACE_HAS_SUNOS4_GETTIMEOFDAY + +#define ACE_LACKS_STROPTS_H + +// Wcharness.... +#define ACE_HAS_WCHAR +#define ACE_SIZEOF_WCHAR 4 + + +#define ACE_HAS_3_PARAM_WCSTOK +#define ACE_LACKS_ITOW +#define ACE_LACKS_WCSICMP +#define ACE_LACKS_WCSNICMP +#define ACE_LACKS_WCSDUP + +// Mac lacks the following pthread features +#define ACE_LACKS_MUTEXATTR_PSHARED +#define ACE_LACKS_CONDATTR_PSHARED +// +// Compiler/platform defines the sig_atomic_t typedef. +#define ACE_HAS_SIG_ATOMIC_T + +// Compiler/platform supports SVR4 signal typedef +#define ACE_HAS_SVR4_SIGNAL_T + +//Platform/compiler has the sigwait(2) prototype +#define ACE_HAS_SIGWAIT + +#define ACE_HAS_AIO_CALLS + +//Platform supports sigsuspend() +#define ACE_HAS_SIGSUSPEND + +//Platform/compiler has macros for sig{empty,fill,add,del}set (e.g., SCO and FreeBSD) +#define ACE_HAS_SIG_MACROS + +#define ACE_LACKS_GETPGID +#define ACE_LACKS_RWLOCK_T + +// Optimize ACE_Handle_Set for select(). +#define ACE_HAS_HANDLE_SET_OPTIMIZED_FOR_SELECT + +#define ACE_HAS_NONCONST_SELECT_TIMEVAL + +//? +#define ACE_LACKS_SIGSET + +#define ACE_NEEDS_SCHED_H + +// Use of is deprecated. +#define ACE_LACKS_MALLOC_H + +#define ACE_HAS_ALT_CUSERID + +// Platform supports POSIX timers via struct timespec. +#define ACE_HAS_POSIX_TIME +#define ACE_HAS_UALARM + +// Platform defines struct timespec but not timespec_t +#define ACE_LACKS_TIMESPEC_T + +#define ACE_LACKS_STRRECVFD + +#define ACE_HAS_SOCKADDR_IN6_SIN6_LEN + +// Platform supports System V IPC (most versions of UNIX, but not Win32) +#define ACE_HAS_SYSV_IPC + +// Compiler/platform contains the file. +#define ACE_HAS_SYS_SYSCALL_H + +#define ACE_HAS_CONSISTENT_SIGNAL_PROTOTYPES + +// Compiler/platform supports alloca(). +// Although ACE does have alloca() on this compiler/platform combination, it is +// disabled by default since it can be dangerous. Uncomment the following line +// if you ACE to use it. +//#define ACE_HAS_ALLOCA + +// Compiler/platform correctly calls init()/fini() for shared libraries. +#define ACE_HAS_AUTOMATIC_INIT_FINI + +// platform supports POSIX O_NONBLOCK semantics +#define ACE_HAS_POSIX_NONBLOCK + +// platform supports IP multicast +#define ACE_HAS_IP_MULTICAST +#define ACE_LACKS_PERFECT_MULTICAST_FILTERING 1 + +// Compiler/platform has the getrusage() system call. +#define ACE_HAS_GETRUSAGE + +// Compiler supports the ssize_t typedef. +#define ACE_HAS_SSIZE_T + +// Compiler/platform supports strerror (). +#define ACE_HAS_STRERROR + +// Compiler/platform provides the sockio.h file. +#define ACE_HAS_SYS_SOCKIO_H + +// Compiler/platform provides the socklen_t type. +#define ACE_HAS_SOCKLEN_T + +// Defines the page size of the system. +#define ACE_HAS_GETPAGESIZE + +// Platform provides header. +#define ACE_HAS_SYS_FILIO_H + +// Platform/compiler supports timezone * as second parameter to gettimeofday(). +#define ACE_HAS_TIMEZONE_GETTIMEOFDAY + +#define ACE_LACKS_SYS_MSG_H +#define ACE_LACKS_SYSV_MSQ_PROTOS +#define ACE_HAS_MSG +#define ACE_HAS_4_4BSD_SENDMSG_RECVMSG +#define ACE_HAS_NONCONST_MSGSND + +#if !defined (ACE_MT_SAFE) +# define ACE_MT_SAFE 1 +#endif + +#if ACE_MT_SAFE == 1 +// Yes, we do have threads. +# define ACE_HAS_THREADS +// And they're even POSIX pthreads +# define ACE_HAS_PTHREADS +# define ACE_HAS_PTHREAD_SCHEDPARAM +# define ACE_HAS_THREAD_SPECIFIC_STORAGE +#endif /* ACE_MT_SAFE == 1 */ + +#define ACE_LACKS_THREAD_PROCESS_SCOPING + +#define ACE_HAS_DIRENT +#define ACE_LACKS_POLL_H +#define ACE_LACKS_SEARCH_H + +#define ACE_LACKS_SETSCHED +//#define ACE_HAS_RECURSIVE_MUTEXES + +// Platform has POSIX terminal interface. +#define ACE_HAS_TERMIOS + +#define ACE_HAS_SEMUN +#define ACE_HAS_SIGINFO_T +#define ACE_LACKS_SIGINFO_H +#define ACE_HAS_UCONTEXT_T +#define ACE_HAS_GETIFADDRS +#define ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES +#define ACE_LACKS_UNNAMED_SEMAPHORE + +// dlcompat package (not part of base Darwin) is needed for dlopen(). +// You may download directly from sourceforge and install or use fink +// Fink installer puts libraries in /sw/lib and headers in /sw/include +// In order to install dlcompat do the following: +// - download fink from http://fink.sf.net +// - type: +// fink install dlcompat +// as of Dec 2002, if you use fink you will need to uncomment the next line +// #define ACE_NEEDS_DL_UNDERSCORE +#define ACE_HAS_SVR4_DYNAMIC_LINKING +#define ACE_LD_SEARCH_PATH ACE_TEXT ("DYLD_LIBRARY_PATH") +#define ACE_DLL_SUFFIX ACE_TEXT (".dylib") +//#define ACE_LACKS_DLCLOSE + +// gperf seems to need this +//#define ACE_HAS_NONSTATIC_OBJECT_MANAGER + +#if defined(__APPLE_CC__) && (__APPLE_CC__ < 1173) +#error "Compiler must be upgraded, see http://developer.apple.com" +#endif /* __APPLE_CC__ */ + +#endif /* ACE_CONFIG_MACOSX_TIGER_H */ diff --git a/dep/ACE_wrappers/ace/config-macosx.h b/dep/ACE_wrappers/ace/config-macosx.h new file mode 100644 index 00000000000..904eae5ac00 --- /dev/null +++ b/dep/ACE_wrappers/ace/config-macosx.h @@ -0,0 +1,191 @@ +/* -*- C++ -*- */ +// $Id: config-macosx.h 80826 2008-03-04 14:51:23Z wotte $ + +// This configuration file is designed to work with the MacOS X operating system, version 10.2 (Jaguar). + +#ifndef ACE_CONFIG_MACOSX_H +#define ACE_CONFIG_MACOSX_H + +#if ! defined (__ACE_INLINE__) +#define __ACE_INLINE__ +#endif /* ! __ACE_INLINE__ */ + +#if defined (__GNUG__) +# include "ace/config-g++-common.h" +#endif /* __GNUG__ */ + +#define ACE_SIZE_T_FORMAT_SPECIFIER ACE_TEXT ("%lu") + +#if defined (ACE_HAS_PENTIUM) +# undef ACE_HAS_PENTIUM +#endif /* ACE_HAS_PENTIUM */ + +#if !defined (_THREAD_SAFE) +#define _THREAD_SAFE +#endif /* _THREAD_SAFE */ + +#define ACE_HAS_GPERF +#define ACE_HAS_POSIX_SEM + +//#define ACE_HAS_SVR4_TLI + +#define ACE_LACKS_STROPTS_H +#define ACE_LACKS_WCHAR_H + +#define ACE_SYS_SELECT_NEEDS_UNISTD_H + +// +// Compiler/platform defines the sig_atomic_t typedef. +#define ACE_HAS_SIG_ATOMIC_T + +// Compiler/platform supports SVR4 signal typedef +#define ACE_HAS_SVR4_SIGNAL_T + +//Platform/compiler has the sigwait(2) prototype +#define ACE_HAS_SIGWAIT + +//Platform supports sigsuspend() +#define ACE_HAS_SIGSUSPEND + +//Platform/compiler has macros for sig{empty,fill,add,del}set (e.g., SCO and FreeBSD) +#define ACE_HAS_SIG_MACROS + +//#define ACE_HAS_RECURSIVE_THR_EXIT_SEMANTICS +#define ACE_LACKS_GETPGID +#define ACE_LACKS_RWLOCK_T + +// Optimize ACE_Handle_Set for select(). +#define ACE_HAS_HANDLE_SET_OPTIMIZED_FOR_SELECT + +#define ACE_HAS_NONCONST_SELECT_TIMEVAL + +#define ACE_HAS_SYSCTL + +//? +#define ACE_LACKS_SIGSET + +#define ACE_NEEDS_SCHED_H + +// Use of is deprecated. +#define ACE_LACKS_MALLOC_H + +#define ACE_HAS_ALT_CUSERID + +// Platform supports POSIX timers via struct timespec. +#define ACE_HAS_POSIX_TIME +#define ACE_HAS_UALARM + +// Platform defines struct timespec but not timespec_t +#define ACE_LACKS_TIMESPEC_T + +#define ACE_LACKS_STRRECVFD + +#define ACE_HAS_SOCKADDR_IN6_SIN6_LEN + +// Platform supports System V IPC (most versions of UNIX, but not Win32) +//#define ACE_HAS_SYSV_IPC + +// Compiler/platform contains the file. +#define ACE_HAS_SYS_SYSCALL_H + +#define ACE_HAS_CONSISTENT_SIGNAL_PROTOTYPES + +// Compiler/platform supports alloca(). +// Although ACE does have alloca() on this compiler/platform combination, it is +// disabled by default since it can be dangerous. Uncomment the following line +// if you ACE to use it. +//#define ACE_HAS_ALLOCA + +// Compiler/platform correctly calls init()/fini() for shared libraries. +#define ACE_HAS_AUTOMATIC_INIT_FINI + +// Explicit dynamic linking permits "lazy" symbol resolution +//#define ACE_HAS_RTLD_LAZY_V + +// platform supports POSIX O_NONBLOCK semantics +#define ACE_HAS_POSIX_NONBLOCK + +// platform supports IP multicast +#define ACE_HAS_IP_MULTICAST +#define ACE_LACKS_PERFECT_MULTICAST_FILTERING 1 + +// Compiler/platform has the getrusage() system call. +#define ACE_HAS_GETRUSAGE + +// Compiler supports the ssize_t typedef. +#define ACE_HAS_SSIZE_T + +// Compiler/platform supports strerror (). +#define ACE_HAS_STRERROR + +// Compiler/platform provides the sockio.h file. +#define ACE_HAS_SYS_SOCKIO_H + +// Defines the page size of the system. +#define ACE_HAS_GETPAGESIZE + +// Platform provides header. +#define ACE_HAS_SYS_FILIO_H + +// Platform/compiler supports timezone * as second parameter to gettimeofday(). +#define ACE_HAS_TIMEZONE_GETTIMEOFDAY + +#define ACE_LACKS_SYS_MSG_H +#define ACE_LACKS_SYSV_MSQ_PROTOS +#define ACE_HAS_MSG +#define ACE_HAS_4_4BSD_SENDMSG_RECVMSG +#define ACE_HAS_NONCONST_MSGSND + +#if !defined (ACE_MT_SAFE) +# define ACE_MT_SAFE 1 +#endif + +#if ACE_MT_SAFE == 1 +// Yes, we do have threads. +# define ACE_HAS_THREADS +// And they're even POSIX pthreads +# define ACE_HAS_PTHREADS +# define ACE_HAS_THREAD_SPECIFIC_STORAGE +# define ACE_LACKS_THREAD_PROCESS_SCOPING +#endif /* ACE_MT_SAFE == 1 */ + +#define ACE_HAS_DIRENT +#define ACE_LACKS_POLL_H +#define ACE_LACKS_SEARCH_H + +#define ACE_LACKS_SETSCHED +//#define ACE_HAS_RECURSIVE_MUTEXES + +// Platform has POSIX terminal interface. +#define ACE_HAS_TERMIOS + +#define ACE_HAS_SEMUN +#define ACE_HAS_SIGINFO_T +#define ACE_LACKS_SIGINFO_H +#define ACE_HAS_UCONTEXT_T +#define ACE_HAS_GETIFADDRS +#define ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES +#define ACE_LACKS_UNNAMED_SEMAPHORE + +// dlcompat package (not part of base Darwin) is needed for dlopen(). +// You may download directly from sourceforge and install or use fink +// Fink installer puts libraries in /sw/lib and headers in /sw/include +// In order to install dlcompat do the following: +// - download fink from http://fink.sf.net +// - type: +// fink install dlcompat +// as of Dec 2002, if you use fink you will need to uncomment the next line +//#define ACE_NEEDS_DL_UNDERSCORE +#define ACE_HAS_SVR4_DYNAMIC_LINKING +#define ACE_LD_SEARCH_PATH ACE_TEXT ("DYLD_LIBRARY_PATH") +#define ACE_DLL_SUFFIX ACE_TEXT (".dylib") +#define ACE_LACKS_DLCLOSE + +// gperf seems to need this +#define ACE_HAS_NONSTATIC_OBJECT_MANAGER + +#if defined(__APPLE_CC__) && (__APPLE_CC__ < 1173) +#error "Compiler must be upgraded, see http://developer.apple.com" +#endif /* __APPLE_CC__ */ + +#endif /* ACE_CONFIG_MACOSX_H */ diff --git a/dep/ACE_wrappers/ace/config-macros.h b/dep/ACE_wrappers/ace/config-macros.h new file mode 100644 index 00000000000..ca7f49c31b4 --- /dev/null +++ b/dep/ACE_wrappers/ace/config-macros.h @@ -0,0 +1,636 @@ +// -*- C++ -*- + +//========================================================================== +/** + * @file config-macros.h + * + * $Id: config-macros.h 82495 2008-08-04 07:23:01Z johnnyw $ + * + * @author (Originally in OS.h)Doug Schmidt + * @author Jesper S. M|ller + * @author and a cast of thousands... + * + * This file contains the contents of the old config-lite.h header + * without C++ code (except for C++ code in macros). Specifically, + * only macros or C language constructs are found in this header. + * Allows configuration values and macros to be used by some C + * language sources. + */ +//========================================================================== + +#ifndef ACE_CONFIG_MACROS_H +#define ACE_CONFIG_MACROS_H + +#ifdef _WIN32 +#include "ace/config-win32.h" +#else +#include "ace/config.h" +#endif //_WIN32 + +#include "ace/Version.h" +#include "ace/Versioned_Namespace.h" + +// ACE_HAS_TLI is used to decide whether to try any XTI/TLI functionality +// so if it isn't set, set it. Capabilities and differences between +// XTI and TLI favor XTI, but when deciding to do anything, as opposed to +// ACE_NOTSUP_RETURN for example, ACE_HAS_TLI is the deciding factor. +#if !defined (ACE_HAS_TLI) +# if defined (ACE_HAS_XTI) +# define ACE_HAS_TLI +# endif /* ACE_HAS_XTI */ +#endif /* ACE_HAS_TLI */ + +#define ACE_BITS_PER_ULONG (8 * sizeof (u_long)) + +#if !defined (ACE_OSTREAM_TYPE) +# if defined (ACE_LACKS_IOSTREAM_TOTALLY) +# define ACE_OSTREAM_TYPE FILE +# else /* ! ACE_LACKS_IOSTREAM_TOTALLY */ +# define ACE_OSTREAM_TYPE ostream +# endif /* ! ACE_LACKS_IOSTREAM_TOTALLY */ +#endif /* ! ACE_OSTREAM_TYPE */ + +#if !defined (ACE_DEFAULT_LOG_STREAM) +# if defined (ACE_LACKS_IOSTREAM_TOTALLY) +# define ACE_DEFAULT_LOG_STREAM 0 +# else /* ! ACE_LACKS_IOSTREAM_TOTALLY */ +# define ACE_DEFAULT_LOG_STREAM (&cerr) +# endif /* ! ACE_LACKS_IOSTREAM_TOTALLY */ +#endif /* ! ACE_DEFAULT_LOG_STREAM */ + +// These two are only for backward compatibility. You should avoid +// using them if not necessary. +#if !defined (ACE_LACKS_DEPRECATED_MACROS) +/** + * @deprecated The ACE_SYNCH_1 macro is deprecated + */ +# define ACE_SYNCH_1 ACE_SYNCH_DECL +/** + * @deprecated The ACE_SYNCH_2 macro is deprecated + */ +# define ACE_SYNCH_2 ACE_SYNCH_USE +#endif + +// For Win32 compatibility... +# if !defined (ACE_WSOCK_VERSION) +# define ACE_WSOCK_VERSION 0, 0 +# endif /* ACE_WSOCK_VERSION */ + +# if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0) +# define ACE_MT(X) X +# if !defined (_REENTRANT) +# define _REENTRANT +# endif /* _REENTRANT */ +# else +# define ACE_MT(X) +# endif /* ACE_MT_SAFE */ + +# if defined (ACE_HAS_PURIFY) +# define ACE_INITIALIZE_MEMORY_BEFORE_USE +# endif /* ACE_HAS_PURIFY */ + +# if defined (ACE_HAS_VALGRIND) +# define ACE_INITIALIZE_MEMORY_BEFORE_USE +# endif /* ACE_HAS_VALGRIND */ + +#if !defined (ACE_LACKS_DEPRECATED_MACROS) +/** + * @deprecated The @c ACE_HAS_USING macros are deprecated + */ +# define ACE_USING using +#endif /* !ACE_LACKS_DEPRECATED_MACROS */ + +#if !defined (ACE_LACKS_DEPRECATED_MACROS) +/** + * @deprecated The @c ACE_TYPENAME macros is deprecated. Use standard + * C++ keyword typename instead. + */ +# define ACE_TYPENAME typename +#endif /* !ACE_LACKS_DEPRECATED_MACROS */ + +#if !defined (ACE_LACKS_DEPRECATED_MACROS) +/** + * @deprecated The @c ACE_TEMPLATE_SPECIALIZATION and + * @c ACE_TEMPLATE_CLASS_MEMBER_SPECIALIZATION macros are + * deprecated. Use standard C++ template specialization + * syntax instead. + */ +# define ACE_TEMPLATE_SPECIALIZATION template<> +# define ACE_TEMPLATE_CLASS_MEMBER_SPECIALIZATION +#endif /* !ACE_LACKS_DEPRECATED_MACROS */ + +// ========================================================================= +// Perfect Multicast filting refers to RFC 3376, where a socket is only +// delivered dgrams for groups joined even if it didn't bind the group +// address. We turn this option off by default, although most OS's +// except for Windows and Solaris probably lack perfect filtering. +// ========================================================================= + +# if !defined (ACE_LACKS_PERFECT_MULTICAST_FILTERING) +# define ACE_LACKS_PERFECT_MULTICAST_FILTERING 0 +# endif /* ACE_LACKS_PERFECT_MULTICAST_FILTERING */ + +// ========================================================================= +// Enable/Disable Features By Default +// ========================================================================= + +# if !defined (ACE_HAS_POSITION_INDEPENDENT_POINTERS) +# define ACE_HAS_POSITION_INDEPENDENT_POINTERS 1 +# endif /* ACE_HAS_POSITION_INDEPENDENT_POINTERS */ + +# if !defined (ACE_HAS_PROCESS_SPAWN) +# if !defined (ACE_LACKS_FORK) || \ + (defined (ACE_WIN32) && !defined (ACE_HAS_PHARLAP)) || \ + defined (ACE_WINCE) || defined (ACE_OPENVMS) +# define ACE_HAS_PROCESS_SPAWN 1 +# endif +# endif /* ACE_HAS_PROCESS_SPAWN */ + +# if !defined (ACE_HAS_DYNAMIC_LINKING) +# if defined (ACE_HAS_SVR4_DYNAMIC_LINKING) || defined (ACE_WIN32) || defined (ACE_VXWORKS) || defined (__hpux) +# define ACE_HAS_DYNAMIC_LINKING 1 +# endif +# endif /* ACE_HAS_DYNAMIC_LINKING */ + +# if defined (ACE_USES_FIFO_SEM) +# if defined (ACE_HAS_POSIX_SEM) || defined (ACE_LACKS_MKFIFO) || defined (ACE_LACKS_FCNTL) +# undef ACE_USES_FIFO_SEM +# endif +# endif /* ACE_USES_FIFO_SEM */ + +// ========================================================================= +// RCSID Macros +// ========================================================================= + +// By default, DO NOT include RCS Id strings in object code. +#if ! defined (ACE_USE_RCSID) +# define ACE_USE_RCSID 0 +#endif /* #if ! defined (ACE_USE_RCSID) */ + +#if (defined (ACE_USE_RCSID) && (ACE_USE_RCSID != 0)) +# if ! defined (ACE_RCSID) + + // This hack has the following purposes: + // 1. To define the RCS id string variable as a static char*, so + // that there won't be any duplicate extern symbols at link + // time. + // 2. To have a RCS id string variable with a unique name for each + // file. + // 3. To avoid warnings of the type "variable declared and never + // used". + +# define ACE_RCSID(path, file, id) \ + static inline const char* get_rcsid_ ## path ## _ ## file (const char*) \ + { \ + return id ; \ + } \ + static const char* rcsid_ ## path ## _ ## file = \ + get_rcsid_ ## path ## _ ## file ( rcsid_ ## path ## _ ## file ) ; + +# endif /* #if ! defined (ACE_RCSID) */ +#else + + // RCS id strings are not wanted. +# if defined (ACE_RCSID) +# undef ACE_RCSID +# endif /* #if defined (ACE_RCSID) */ +# define ACE_RCSID(path, file, id) /* noop */ +#endif /* #if (defined (ACE_USE_RCSID) && (ACE_USE_RCSID != 0)) */ + +// ========================================================================= +// INLINE macros +// +// These macros handle all the inlining of code via the .i or .inl files +// ========================================================================= + +#if defined (ACE_LACKS_INLINE_FUNCTIONS) && !defined (ACE_NO_INLINE) +# define ACE_NO_INLINE +#endif /* defined (ACE_LACKS_INLINE_FUNCTIONS) && !defined (ACE_NO_INLINE) */ + +// ACE inlining has been explicitly disabled. Implement +// internally within ACE by undefining __ACE_INLINE__. +#if defined (ACE_NO_INLINE) +# undef __ACE_INLINE__ +#endif /* ! ACE_NO_INLINE */ + +#if defined (__ACE_INLINE__) +# define ACE_INLINE inline +# if !defined (ACE_HAS_INLINED_OSCALLS) +# define ACE_HAS_INLINED_OSCALLS +# endif /* !ACE_HAS_INLINED_OSCALLS */ +#else +# define ACE_INLINE +#endif /* __ACE_INLINE__ */ + +#if !defined (ACE_LACKS_DEPRECATED_MACROS) + // ========================================================================= + // EXPLICIT macro + // ========================================================================= + + /** + * @deprecated explicit is deprecated. ACE requires C++ + * "explicit" keyword support. + */ + # define ACE_EXPLICIT explicit +#endif /* ACE_LACKS_DEPRECATED_MACROS */ + +#if !defined (ACE_LACKS_DEPRECATED_MACROS) + // ========================================================================= + // MUTABLE macro + // ========================================================================= + + /** + * @deprecated ACE_MUTABLE is deprecated. ACE requires C++ "mutable" + * keyword support. + */ + # define ACE_MUTABLE mutable + # define ACE_CONST_WHEN_MUTABLE const +#endif /* ACE_LACKS_DEPRECATED_MACROS */ + +// ============================================================================ +// EXPORT macros +// +// Since Win32 DLL's do not export all symbols by default, they must be +// explicitly exported (which is done by *_Export macros). +// ============================================================================ + +// Win32 should have already defined the macros in config-win32-common.h +#if !defined (ACE_HAS_CUSTOM_EXPORT_MACROS) +# define ACE_Proper_Export_Flag +# define ACE_Proper_Import_Flag +# define ACE_EXPORT_SINGLETON_DECLARATION(T) +# define ACE_IMPORT_SINGLETON_DECLARATION(T) +# define ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# define ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +#else +// An export macro should at the very least have been defined. + +# ifndef ACE_Proper_Import_Flag +# define ACE_Proper_Import_Flag +# endif /* !ACE_Proper_Import_Flag */ + +# ifndef ACE_EXPORT_SINGLETON_DECLARATION +# define ACE_EXPORT_SINGLETON_DECLARATION(T) +# endif /* !ACE_EXPORT_SINGLETON_DECLARATION */ + +# ifndef ACE_IMPORT_SINGLETON_DECLARATION +# define ACE_IMPORT_SINGLETON_DECLARATION(T) +# endif /* !ACE_IMPORT_SINGLETON_DECLARATION */ + +# ifndef ACE_EXPORT_SINGLETON_DECLARE +# define ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# endif /* !ACE_EXPORT_SINGLETON_DECLARE */ + +# ifndef ACE_IMPORT_SINGLETON_DECLARE +# define ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# endif /* !ACE_IMPORT_SINGLETON_DECLARE */ + +#endif /* !ACE_HAS_CUSTOM_EXPORT_MACROS */ + +// This is a whim of mine -- that instead of annotating a class with +// ACE_Export in its declaration, we make the declaration near the TOP +// of the file with ACE_DECLARE_EXPORT. +// TS = type specifier (e.g., class, struct, int, etc.) +// ID = identifier +// So, how do you use it? Most of the time, just use ... +// ACE_DECLARE_EXPORT(class, someobject); +// If there are global functions to be exported, then use ... +// ACE_DECLARE_EXPORT(void, globalfunction) (int, ...); +// Someday, when template libraries are supported, we made need ... +// ACE_DECLARE_EXPORT(template class, sometemplate) ; +# define ACE_DECLARE_EXPORT(TS,ID) TS ACE_Export ID + +// ============================================================================ +// Cast macros +// +// These macros are used to choose between the old cast style and the new +// *_cast<> operators +// ============================================================================ + +# define ACE_sap_any_cast(TYPE) reinterpret_cast (const_cast (ACE_Addr::sap_any)) + +#if !defined (ACE_LACKS_DEPRECATED_MACROS) + /** + * @deprecated ACE_{static,reinterpret,dynamic,const}_cast@<@> is + * deprecated. Directly use standard C++ casts instead. + */ + # define ACE_static_cast(TYPE, EXPR) static_cast (EXPR) + # define ACE_static_cast_1_ptr(TYPE, T1, EXPR) static_cast *> (EXPR) + # define ACE_static_cast_2_ptr(TYPE, T1, T2, EXPR) static_cast *> (EXPR) + # define ACE_static_cast_3_ptr(TYPE, T1, T2, T3, EXPR) static_cast *> (EXPR) + # define ACE_static_cast_4_ptr(TYPE, T1, T2, T3, T4, EXPR) static_cast *> (EXPR) + # define ACE_static_cast_5_ptr(TYPE, T1, T2, T3, T4, T5, EXPR) static_cast *> (EXPR) + # define ACE_static_cast_1_ref(TYPE, T1, EXPR) static_cast &> (EXPR) + # define ACE_static_cast_2_ref(TYPE, T1, T2, EXPR) static_cast &> (EXPR) + # define ACE_static_cast_3_ref(TYPE, T1, T2, T3, EXPR) static_cast &> (EXPR) + # define ACE_static_cast_4_ref(TYPE, T1, T2, T3, T4, EXPR) static_cast &> (EXPR) + # define ACE_static_cast_5_ref(TYPE, T1, T2, T3, T4, T5, EXPR) static_cast &> (EXPR) + + # define ACE_const_cast(TYPE, EXPR) const_cast (EXPR) + # define ACE_const_cast_1_ptr(TYPE, T1, EXPR) const_cast *> (EXPR) + # define ACE_const_cast_2_ptr(TYPE, T1, T2, EXPR) const_cast *> (EXPR) + # define ACE_const_cast_3_ptr(TYPE, T1, T2, T3, EXPR) const_cast *> (EXPR) + # define ACE_const_cast_4_ptr(TYPE, T1, T2, T3, T4, EXPR) const_cast *> (EXPR) + # define ACE_const_cast_5_ptr(TYPE, T1, T2, T3, T4, T5, EXPR) const_cast *> (EXPR) + # define ACE_const_cast_1_ref(TYPE, T1, EXPR) const_cast &> (EXPR) + # define ACE_const_cast_2_ref(TYPE, T1, T2, EXPR) const_cast &> (EXPR) + # define ACE_const_cast_3_ref(TYPE, T1, T2, T3, EXPR) const_cast &> (EXPR) + # define ACE_const_cast_4_ref(TYPE, T1, T2, T3, T4, EXPR) const_cast &> (EXPR) + # define ACE_const_cast_5_ref(TYPE, T1, T2, T3, T4, T5, EXPR) const_cast &> (EXPR) + + # define ACE_reinterpret_cast(TYPE, EXPR) reinterpret_cast (EXPR) + # define ACE_reinterpret_cast_1_ptr(TYPE, T1, EXPR) reinterpret_cast *> (EXPR) + # define ACE_reinterpret_cast_2_ptr(TYPE, T1, T2, EXPR) reinterpret_cast *> (EXPR) + # define ACE_reinterpret_cast_3_ptr(TYPE, T1, T2, T3, EXPR) reinterpret_cast *> (EXPR) + # define ACE_reinterpret_cast_4_ptr(TYPE, T1, T2, T3, T4, EXPR) reinterpret_cast *> (EXPR) + # define ACE_reinterpret_cast_5_ptr(TYPE, T1, T2, T3, T4, T5, EXPR) reinterpret_cast *> (EXPR) + # define ACE_reinterpret_cast_1_ref(TYPE, T1, EXPR) reinterpret_cast &> (EXPR) + # define ACE_reinterpret_cast_2_ref(TYPE, T1, T2, EXPR) reinterpret_cast &> (EXPR) + # define ACE_reinterpret_cast_3_ref(TYPE, T1, T2, T3, EXPR) reinterpret_cast &> (EXPR) + # define ACE_reinterpret_cast_4_ref(TYPE, T1, T2, T3, T4, EXPR) reinterpret_cast &> (EXPR) + # define ACE_reinterpret_cast_5_ref(TYPE, T1, T2, T3, T4, T5, EXPR) reinterpret_cast &> (EXPR) + + # define ACE_dynamic_cast(TYPE, EXPR) dynamic_cast (EXPR) + # define ACE_dynamic_cast_1_ptr(TYPE, T1, EXPR) dynamic_cast *> (EXPR) + # define ACE_dynamic_cast_2_ptr(TYPE, T1, T2, EXPR) dynamic_cast *> (EXPR) + # define ACE_dynamic_cast_3_ptr(TYPE, T1, T2, T3, EXPR) dynamic_cast *> (EXPR) + # define ACE_dynamic_cast_4_ptr(TYPE, T1, T2, T3, T4, EXPR) dynamic_cast *> (EXPR) + # define ACE_dynamic_cast_5_ptr(TYPE, T1, T2, T3, T4, T5, EXPR) dynamic_cast *> (EXPR) + # define ACE_dynamic_cast_1_ref(TYPE, T1, EXPR) dynamic_cast &> (EXPR) + # define ACE_dynamic_cast_2_ref(TYPE, T1, T2, EXPR) dynamic_cast &> (EXPR) + # define ACE_dynamic_cast_3_ref(TYPE, T1, T2, T3, EXPR) dynamic_cast &> (EXPR) + # define ACE_dynamic_cast_4_ref(TYPE, T1, T2, T3, T4, EXPR) dynamic_cast &> (EXPR) + # define ACE_dynamic_cast_5_ref(TYPE, T1, T2, T3, T4, T5, EXPR) dynamic_cast &> (EXPR) +#endif /* ACE_LACKS_DEPRECATED_MACROS */ + +# if !defined (ACE_CAST_CONST) + // Sun CC 4.2, for example, requires const in reinterpret casts of + // data members in const member functions. But, other compilers + // complain about the useless const. This keeps everyone happy. +# if defined (__SUNPRO_CC) +# define ACE_CAST_CONST const +# else /* ! __SUNPRO_CC */ +# define ACE_CAST_CONST +# endif /* ! __SUNPRO_CC */ +# endif /* ! ACE_CAST_CONST */ + +// ============================================================================ +// Compiler Silencing macros +// +// Some compilers complain about parameters that are not used. This macro +// should keep them quiet. +// ============================================================================ + +#if !defined (ACE_UNUSED_ARG) +# if defined (__GNUC__) && ((__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 2))) +# define ACE_UNUSED_ARG(a) (void) (a) +# elif defined (__GNUC__) || defined (ghs) || defined (__hpux) || defined (__sgi) || defined (__DECCXX) || defined (__rational__) || defined (__USLC__) || defined (ACE_RM544) || defined (__DCC__) || defined (__PGI) || defined (__TANDEM) +// Some compilers complain about "statement with no effect" with (a). +// This eliminates the warnings, and no code is generated for the null +// conditional statement. @note that may only be true if -O is enabled, +// such as with GreenHills (ghs) 1.8.8. +# define ACE_UNUSED_ARG(a) do {/* null */} while (&a == 0) +# elif defined (__DMC__) + #define ACE_UNUSED_ID(identifier) + template + inline void ACE_UNUSED_ARG(const T& ACE_UNUSED_ID(t)) { } +# else /* ghs || __GNUC__ || ..... */ +# define ACE_UNUSED_ARG(a) (a) +# endif /* ghs || __GNUC__ || ..... */ +#endif /* !ACE_UNUSED_ARG */ + +#if defined (_MSC_VER) || defined(__sgi) || defined (ghs) || defined (__DECCXX) || defined(__BORLANDC__) || defined (ACE_RM544) || defined (__USLC__) || defined (__DCC__) || defined (__PGI) || defined (__TANDEM) || (defined (__HP_aCC) && (__HP_aCC >= 60500)) +# define ACE_NOTREACHED(a) +#else /* __sgi || ghs || ..... */ +# define ACE_NOTREACHED(a) a +#endif /* __sgi || ghs || ..... */ + +// ============================================================================ +// ACE_ALLOC_HOOK* macros +// +// Macros to declare and define class-specific allocation operators. +// ============================================================================ + +# if defined (ACE_HAS_ALLOC_HOOKS) +# define ACE_ALLOC_HOOK_DECLARE \ + void *operator new (size_t bytes); \ + void operator delete (void *ptr); + + // Note that these are just place holders for now. Some day they + // may be be replaced by . +# define ACE_ALLOC_HOOK_DEFINE(CLASS) \ + void *CLASS::operator new (size_t bytes) { return ::new char[bytes]; } \ + void CLASS::operator delete (void *ptr) { delete [] ((char *) ptr); } +# else +# define ACE_ALLOC_HOOK_DECLARE struct __Ace {} /* Just need a dummy... */ +# define ACE_ALLOC_HOOK_DEFINE(CLASS) +# endif /* ACE_HAS_ALLOC_HOOKS */ + +// ============================================================================ +/** + * ACE_OSCALL* macros + * + * @deprecated ACE_OSCALL_RETURN and ACE_OSCALL should not be used. + * Please restart system calls in your application code. + * See the @c sigaction(2) man page for documentation + * regarding enabling restartable system calls across + * signals via the @c SA_RESTART flag. + * + * The following two macros used ensure that system calls are properly + * restarted (if necessary) when interrupts occur. However, that + * capability was never enabled by any of our supported platforms. + * In fact, some parts of ACE would not function properly when that + * ability was enabled. Furthermore, they assumed that ability to + * restart system calls was determined statically. That assumption + * does not hold for modern platforms, where that ability is + * determined dynamically at run-time. + */ +// ============================================================================ + +#define ACE_OSCALL_RETURN(X,TYPE,FAILVALUE) \ + do \ + return (TYPE) (X); \ + while (0) +#define ACE_OSCALL(X,TYPE,FAILVALUE,RESULT) \ + do \ + RESULT = (TYPE) (X); \ + while (0) + +#if defined (ACE_WIN32) +# define ACE_WIN32CALL_RETURN(X,TYPE,FAILVALUE) \ + do { \ + TYPE ace_result_ = (TYPE) X; \ + if (ace_result_ == FAILVALUE) \ + ACE_OS::set_errno_to_last_error (); \ + return ace_result_; \ + } while (0) +# define ACE_WIN32CALL(X,TYPE,FAILVALUE,RESULT) \ + do { \ + RESULT = (TYPE) X; \ + if (RESULT == FAILVALUE) \ + ACE_OS::set_errno_to_last_error (); \ + } while (0) +#endif /* ACE_WIN32 */ + +// The C99 security-improved run-time returns an error value on failure; +// 0 on success. +#if defined (ACE_HAS_TR24731_2005_CRT) +# define ACE_SECURECRTCALL(X,TYPE,FAILVALUE,RESULT) \ + do { \ + errno_t ___ = X; \ + if (___ != 0) { errno = ___; RESULT = FAILVALUE; } \ + } while (0) +#endif /* ACE_HAS_TR24731_2005_CRT */ + +// ============================================================================ +// Fundamental types +// ============================================================================ + +#if defined (ACE_WIN32) + +typedef HANDLE ACE_HANDLE; +typedef SOCKET ACE_SOCKET; +# define ACE_INVALID_HANDLE INVALID_HANDLE_VALUE + +#else /* ! ACE_WIN32 */ + +typedef int ACE_HANDLE; +typedef ACE_HANDLE ACE_SOCKET; +# define ACE_INVALID_HANDLE -1 + +#endif /* ACE_WIN32 */ + +// Define the type that's returned from the platform's native thread +// functions. ACE_THR_FUNC_RETURN is the type defined as the thread +// function's return type, except when the thread function doesn't return +// anything (pSoS). The ACE_THR_FUNC_NO_RETURN_VAL macro is used to +// indicate that the actual thread function doesn't return anything. The +// rest of ACE uses a real type so there's no a ton of conditional code +// everywhere to deal with the possibility of no return type. +# if defined (ACE_VXWORKS) && !defined (ACE_HAS_PTHREADS) +# include /**/ +typedef int ACE_THR_FUNC_RETURN; +#define ACE_HAS_INTEGRAL_TYPE_THR_FUNC_RETURN +# elif defined (ACE_WIN32) +typedef DWORD ACE_THR_FUNC_RETURN; +#define ACE_HAS_INTEGRAL_TYPE_THR_FUNC_RETURN +# else +typedef void* ACE_THR_FUNC_RETURN; +# endif /* ACE_VXWORKS */ +typedef ACE_THR_FUNC_RETURN (*ACE_THR_FUNC)(void *); + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ +typedef void (*ACE_THR_C_DEST)(void *); +#ifdef __cplusplus +} +#endif /* __cplusplus */ +typedef void (*ACE_THR_DEST)(void *); + +// Now some platforms have special requirements... +# if defined (ACE_VXWORKS) && !defined (ACE_HAS_PTHREADS) +typedef FUNCPTR ACE_THR_FUNC_INTERNAL; // where typedef int (*FUNCPTR) (...) +# else +typedef ACE_THR_FUNC ACE_THR_FUNC_INTERNAL; +# endif /* ACE_VXWORKS */ + +# ifdef __cplusplus +extern "C" +{ +# endif /* __cplusplus */ +# if defined (ACE_VXWORKS) && !defined (ACE_HAS_PTHREADS) +typedef FUNCPTR ACE_THR_C_FUNC; // where typedef int (*FUNCPTR) (...) +# else +typedef ACE_THR_FUNC_RETURN (*ACE_THR_C_FUNC)(void *); +# endif /* ACE_VXWORKS */ +# ifdef __cplusplus +} +# endif /* __cplusplus */ + +// ============================================================================ +// Macros for controlling the lifetimes of dlls loaded by ACE_DLL--including +// all dlls loaded via the ACE Service Config framework. +// +// Please don't change these values or add new ones wantonly, since we use +// the ACE_BIT_ENABLED, etc..., macros to test them. +// ============================================================================ + +// Per-process policy that unloads dlls eagerly. +#define ACE_DLL_UNLOAD_POLICY_PER_PROCESS 0 +// Apply policy on a per-dll basis. If the dll doesn't use one of the macros +// below, the current per-process policy will be used. +#define ACE_DLL_UNLOAD_POLICY_PER_DLL 1 +// Don't unload dll when refcount reaches zero, i.e., wait for either an +// explicit unload request or program exit. +#define ACE_DLL_UNLOAD_POLICY_LAZY 2 +// Default policy allows dlls to control their own destinies, but will +// unload those that don't make a choice eagerly. +#define ACE_DLL_UNLOAD_POLICY_DEFAULT ACE_DLL_UNLOAD_POLICY_PER_DLL + +// Add this macro you one of your cpp file in your dll. X should +// be either ACE_DLL_UNLOAD_POLICY_DEFAULT or ACE_DLL_UNLOAD_POLICY_LAZY. +#define ACE_DLL_UNLOAD_POLICY(CLS,X) \ +extern "C" u_long CLS##_Export _get_dll_unload_policy (void) \ + { return X;} + +// ============================================================================ +// ACE_USES_CLASSIC_SVC_CONF macro +// ============================================================================ + +// For now, default is to use the classic svc.conf format. +#if !defined (ACE_USES_CLASSIC_SVC_CONF) +# if defined (ACE_HAS_CLASSIC_SVC_CONF) && defined (ACE_HAS_XML_SVC_CONF) +# error You can only use either CLASSIC or XML svc.conf, not both. +# endif +// Change the ACE_HAS_XML_SVC_CONF to ACE_HAS_CLASSIC_SVC_CONF when +// we switch ACE to use XML svc.conf as default format. +# if defined (ACE_HAS_XML_SVC_CONF) +# define ACE_USES_CLASSIC_SVC_CONF 0 +# else +# define ACE_USES_CLASSIC_SVC_CONF 1 +# endif /* ACE_HAS_XML_SVC_CONF */ +#endif /* ACE_USES_CLASSIC_SVC_CONF */ + +// ============================================================================ +// Default svc.conf file extension. +// ============================================================================ +#if defined (ACE_USES_CLASSIC_SVC_CONF) && (ACE_USES_CLASSIC_SVC_CONF == 1) +# define ACE_DEFAULT_SVC_CONF_EXT ".conf" +#else +# define ACE_DEFAULT_SVC_CONF_EXT ".conf.xml" +#endif /* ACE_USES_CLASSIC_SVC_CONF && ACE_USES_CLASSIC_SVC_CONF == 1 */ + +// ============================================================================ +// Miscellaneous macros +// ============================================================================ + +#if defined (ACE_USES_EXPLICIT_STD_NAMESPACE) +# define ACE_STD_NAMESPACE std +#else +# define ACE_STD_NAMESPACE +#endif + +#if !defined (ACE_OS_String) +# define ACE_OS_String ACE_OS +#endif /* ACE_OS_String */ +#if !defined (ACE_OS_Memory) +# define ACE_OS_Memory ACE_OS +#endif /* ACE_OS_Memory */ +#if !defined (ACE_OS_Dirent) +# define ACE_OS_Dirent ACE_OS +#endif /* ACE_OS_Dirent */ +#if !defined (ACE_OS_TLI) +# define ACE_OS_TLI ACE_OS +#endif /* ACE_OS_TLI */ + +// ------------------------------------------------------------------- +// Preprocessor symbols will not be expanded if they are +// concatenated. Force the preprocessor to expand them during the +// argument prescan by calling a macro that itself calls another that +// performs the actual concatenation. +#define ACE_PREPROC_CONCATENATE_IMPL(A,B) A ## B +#define ACE_PREPROC_CONCATENATE(A,B) ACE_PREPROC_CONCATENATE_IMPL(A,B) +// ------------------------------------------------------------------- + +#endif /* ACE_CONFIG_MACROS_H */ diff --git a/dep/ACE_wrappers/ace/config-minimal.h b/dep/ACE_wrappers/ace/config-minimal.h new file mode 100644 index 00000000000..4cf2e8a487b --- /dev/null +++ b/dep/ACE_wrappers/ace/config-minimal.h @@ -0,0 +1,39 @@ +/* -*- C++ -*- */ +// $Id: config-minimal.h 80826 2008-03-04 14:51:23Z wotte $ + +// This configuration file is designed to build only the minimal +// ACE_OS adaptation layer. + +#ifndef ACE_CONFIG_MINIMAL_H +#define ACE_CONFIG_MINIMAL_H +#include /**/ "ace/pre.h" + +#define ACE_HAS_MINIMAL_ACE_OS + +// Only instantiate the ACE_OS_Object_Manager. +#define ACE_MAIN_OBJECT_MANAGER \ + ACE_OS_Object_Manager ace_os_object_manager; + +#if !defined(ACE_USE_THREAD_MANAGER_ADAPTER) + // To prevent use of ACE_Thread_Exit functions in + // ACE_Thread_Adapter::invoke (). +# define ACE_USE_THREAD_MANAGER_ADAPTER +#endif /* ! ACE_USE_THREAD_MANAGER_ADAPTER */ + +#if defined (ACE_ASSERT) +# undef ACE_ASSERT +#endif /* ACE_ASSERT */ +#define ACE_ASSERT(x) + +#if defined (ACE_DEBUG) +# undef ACE_DEBUG +#endif /* ACE_DEBUG */ +#define ACE_DEBUG(x) + +#if defined (ACE_ERROR) +# undef ACE_ERROR +#endif /* ACE_ERROR */ +#define ACE_ERROR(x) + +#include /**/ "ace/post.h" +#endif /* ACE_CONFIG_MINIMAL_H */ diff --git a/dep/ACE_wrappers/ace/config-mvs.h b/dep/ACE_wrappers/ace/config-mvs.h new file mode 100644 index 00000000000..c37bac25892 --- /dev/null +++ b/dep/ACE_wrappers/ace/config-mvs.h @@ -0,0 +1,131 @@ +/* -*- C++ -*- */ +// $Id: config-mvs.h 81992 2008-06-16 19:09:50Z wotte $ + +// Config file for MVS with OpenEdition + +#ifndef ACE_CONFIG_H +#define ACE_CONFIG_H +#include /**/ "ace/pre.h" + +// The following #defines are hacks to get around things +// that seem to be missing or different in MVS land +#define MAXPATHLEN 1024 /* sys/param.h not on MVS */ +#define NSIG 44 /* missing from Signal.h */ +#define MAXHOSTNAMELEN 256 /* missing form netdb.h */ +#define howmany __howmany /* MVS uses different names than most others */ +#define fd_mask __fd_mask +#define MAXNAMLEN __DIR_NAME_MAX +#if defined (log) /* log is a macro in math.h */ +# undef log /* conflicts with log function in ACE */ +#endif /* log */ + +#define ACE_MVS + +// Preprocesor requires an extra argument +#ifndef ACE_USING_MCPP_PREPROCESSOR +# define ACE_CC_PREPROCESSOR_ARGS "-+ -E" +#endif + +// See the README file in this directory +// for a description of the following ACE_ macros + +#if __COMPILER_VER__ >= 0x21020000 /* OS/390 r2 or higher */ +# define ACE_HAS_4_4BSD_SENDMSG_RECVMSG +# define ACE_HAS_UCONTEXT_T +#else /* __COMPILER_VER__ < 0x21020000 */ +# define ACE_LACKS_UCONTEXT_H +#endif /* __COMPILER_VER__ < 0x21020000 */ + +#if __COMPILER_VER__ < 0x22060000 /* before OS/390 r2.6 */ +# define ACE_LACKS_LONGLONG_T +#endif /* __COMPILER_VER__ < 0x22060000 */ + +#define ERRMAX __sys_nerr + +#define ACE_HAS_3_PARAM_WCSTOK +#define ACE_HAS_BROKEN_CTIME +#define ACE_HAS_CONSISTENT_SIGNAL_PROTOTYPES +#define ACE_HAS_CPLUSPLUS_HEADERS +#define ACE_HAS_DIRENT +#define ACE_HAS_GETPAGESIZE +#define ACE_HAS_GETRUSAGE +#define ACE_HAS_HANDLE_SET_OPTIMIZED_FOR_SELECT +#define ACE_HAS_LIMITED_RUSAGE_T +#define ACE_HAS_MSG +#define ACE_HAS_NONCONST_SELECT_TIMEVAL +#define ACE_HAS_NONSCALAR_THREAD_KEY_T +#define ACE_HAS_POLL +#define ACE_HAS_POSIX_NONBLOCK +#define ACE_HAS_POSIX_TIME +#define ACE_HAS_PTHREADS +#define ACE_HAS_PTHREAD_CONDATTR_SETKIND_NP +#define ACE_HAS_PTHREAD_MUTEXATTR_SETKIND_NP +#define ACE_HAS_SIGINFO_T +#define ACE_HAS_SIGWAIT +#define ACE_HAS_SIG_ATOMIC_T +#define ACE_HAS_SIG_C_FUNC +#define ACE_HAS_SOCKADDR_IN_SIN_LEN +#define ACE_HAS_SIZET_SOCKET_LEN +#define ACE_HAS_SSIZE_T +#define ACE_HAS_STRERROR +#define ACE_HAS_STRBUF_T +#define ACE_HAS_STRINGS +#define ACE_HAS_SYSV_IPC +#define ACE_HAS_TEMPLATE_TYPEDEFS +#define ACE_HAS_THREADS +#define ACE_HAS_THREAD_SPECIFIC_STORAGE +#define ACE_HAS_THR_C_DEST +#define ACE_HAS_THR_C_FUNC +#define ACE_HAS_TIMEZONE_GETTIMEOFDAY +#define ACE_HAS_UALARM +#define ACE_HAS_UTIME +#define ACE_HAS_VOIDPTR_MMAP +#define ACE_HAS_VOIDPTR_SOCKOPT +#define ACE_HAS_XPG4_MULTIBYTE_CHAR + +#define ACE_LACKS_CONDATTR_PSHARED +#define ACE_LACKS_INET_ATON +#define ACE_LACKS_MSGBUF_T +#define ACE_LACKS_MUTEXATTR_PSHARED +#define ACE_LACKS_IOSTREAM_FX +#define ACE_LACKS_LINEBUFFERED_STREAMBUF +#define ACE_LACKS_MADVISE +#define ACE_LACKS_MALLOC_H +#define ACE_LACKS_PARAM_H +#define ACE_LACKS_SYS_PARAM_H +#define ACE_LACKS_PLACEMENT_OPERATOR_DELETE +#define ACE_LACKS_PTHREAD_THR_SIGSETMASK +#define ACE_LACKS_READDIR_R +#define ACE_LACKS_RWLOCK_T +#define ACE_LACKS_SCHED_H +#define ACE_LACKS_SETSCHED +#define ACE_LACKS_SEMAPHORE_H +#define ACE_LACKS_SIGINFO_H +#define ACE_LACKS_STDINT_H +#define ACE_LACKS_SYS_NERR +#define ACE_LACKS_SYS_SELECT_H +#define ACE_LACKS_SYS_SYSCTL_H +#define ACE_LACKS_SYSTIME_H +#define ACE_LACKS_NETINET_TCP_H +#define ACE_LACKS_TCP_H +#define ACE_LACKS_THREAD_PROCESS_SCOPING +#define ACE_LACKS_PTHREAD_ATTR_SETSTACKADDR +#define ACE_LACKS_TIMESPEC_T + +#if !defined (ACE_MT_SAFE) +# define ACE_MT_SAFE 1 +#endif + +#define ACE_NEEDS_DEV_IO_CONVERSION + +#define ACE_SIZEOF_FLOAT 4 +#define ACE_SIZEOF_DOUBLE 8 +#define ACE_SIZEOF_LONG_DOUBLE 16 +#define ACE_HAS_EBCDIC + +#define ACE_TEMPLATES_REQUIRE_SOURCE + +#define IN_CLASSD(a) ((((in_addr_t)(a)) & 0xf0000000) == 0xe0000000) +#define IN_MULTICAST(a) IN_CLASSD(a) +#include /**/ "ace/post.h" +#endif /* ACE_CONFIG_H */ diff --git a/dep/ACE_wrappers/ace/config-netbsd.h b/dep/ACE_wrappers/ace/config-netbsd.h new file mode 100644 index 00000000000..551718015f9 --- /dev/null +++ b/dep/ACE_wrappers/ace/config-netbsd.h @@ -0,0 +1,167 @@ +/* -*- C++ -*- */ +// $Id: config-netbsd.h 80826 2008-03-04 14:51:23Z wotte $ + +#ifndef ACE_CONFIG_H +#define ACE_CONFIG_H + +#ifndef ACE_MT_SAFE +#define ACE_MT_SAFE 1 +#endif + +#if defined (__GNUG__) +# include "ace/config-g++-common.h" +#endif /* __GNUG__ */ + +#if defined(ACE_MT_SAFE) && (ACE_MT_SAFE != 0) +# define ACE_HAS_THREADS 1 +# define ACE_HAS_PTHREADS 1 +# define ACE_HAS_PTHREADS_UNIX98_EXT 1 +# define ACE_HAS_PTHREAD_RESUME_NP 1 +# define ACE_HAS_PTHREAD_SUSPEND_NP 1 +# define ACE_LACKS_PTHREAD_THR_SIGSETMASK 1 +# define ACE_LACKS_PTHREAD_YIELD 1 +#endif /* ACE_MT_SAFE */ + +#define ACE_HAS_CLOCK_SETTIME 1 +#define ACE_HAS_CLOCK_GETTIME 1 +#define ACE_HAS_SETTIMEOFDAY 1 +#define ACE_HAS_GETTIMEOFDAY 1 +#define ACE_HAS_2_PARAM_ASCTIME_R_AND_CTIME_R 1 +#define ACE_HAS_3_PARAM_WCSTOK 1 +#define ACE_HAS_3_PARAM_READDIR_R 1 +#define ACE_HAS_4_4BSD_SENDMSG_RECVMSG 1 +#define ACE_HAS_ALT_CUSERID 1 +#define ACE_HAS_AUTOMATIC_INIT_FINI 1 +#define ACE_HAS_CLOCK_GETTIME 1 +#define ACE_HAS_CONSISTENT_SIGNAL_PROTOTYPES 1 +#define ACE_HAS_DIRENT 1 +#define ACE_HAS_EXCEPTIONS 1 +#define ACE_HAS_GETIFADDRS 1 +#define ACE_HAS_GETPAGESIZE 1 +#define ACE_HAS_GETPROGNAME 1 +#define ACE_HAS_GETRUSAGE 1 +#define ACE_HAS_GETRUSAGE_PROTOTYPE 1 +#define ACE_HAS_GNU_CSTRING_H 1 +#define ACE_HAS_GPERF 1 +#define ACE_HAS_HANDLE_SET_OPTIMIZED_FOR_SELECT 1 +#define ACE_HAS_IP_MULTICAST 1 +#define ACE_HAS_MSG 1 +#define ACE_HAS_NEW_NO_H 1 +#define ACE_HAS_NONCONST_SELECT_TIMEVAL 1 +#define ACE_HAS_ONLY_SCHED_OTHER 1 +#define ACE_HAS_POLL 1 +#define ACE_HAS_POSITION_INDEPENDENT_POINTERS 1 +#define ACE_HAS_POSIX_NONBLOCK 1 +#define ACE_HAS_POSIX_TIME 1 +#define ACE_HAS_P_READ_WRITE 1 +#define ACE_HAS_RECURSIVE_THR_EXIT_SEMANTICS 1 +#define ACE_HAS_REENTRANT_FUNCTIONS 1 +#define ACE_HAS_SCANDIR 1 +#define ACE_HAS_SETPROGNAME 1 +#define ACE_HAS_SIGACTION_CONSTP2 1 +#define ACE_HAS_SIGINFO_T 1 +#define ACE_HAS_SIGSUSPEND 1 +#define ACE_HAS_SIGTIMEDWAIT 1 +#define ACE_HAS_SIGWAIT 1 +#define ACE_HAS_SIG_ATOMIC_T 1 +#define ACE_HAS_SIG_C_FUNC 1 +#define ACE_HAS_SOCKADDR_IN_SIN_LEN 1 +#define ACE_HAS_SOCKADDR_IN6_SIN6_LEN 1 +#define ACE_HAS_SOCKADDR_MSG_NAME 1 +#define ACE_HAS_SOCKLEN_T 1 +#define ACE_HAS_SSIZE_T 1 +#define ACE_HAS_STANDARD_CPP_LIBRARY 1 +#define ACE_HAS_STDEXCEPT_NO_H 1 +#define ACE_HAS_STRERROR 1 +#define ACE_HAS_STRINGS 1 +#define ACE_HAS_STRING_CLASS 1 +#define ACE_HAS_SVR4_DYNAMIC_LINKING 1 +#define ACE_HAS_SYSV_IPC 1 +#define ACE_HAS_SYS_ERRLIST 1 +#define ACE_HAS_SYS_FILIO_H 1 +#define ACE_HAS_SYS_SIGLIST 1 +#define ACE_HAS_SYS_SOCKIO_H 1 +#define ACE_HAS_SYS_SYSCALL_H 1 +#define ACE_HAS_SYSCTL +#define ACE_HAS_TERMIOS 1 +#define ACE_HAS_THREAD_SPECIFIC_STORAGE 1 +#define ACE_HAS_TIMEZONE 1 +#define ACE_HAS_TIMEZONE_GETTIMEOFDAY 1 +#define ACE_HAS_UALARM 1 +#define ACE_HAS_UCONTEXT_T 1 +#define ACE_HAS_VOIDPTR_MMAP 1 +#define ACE_HAS_VOIDPTR_SOCKOPT 1 +#define ACE_HAS_WCHAR 1 +#define ACE_HAS_XPG4_MULTIBYTE_CHAR 1 +#define ACE_IOCTL_TYPE_ARG2 u_long +#define ACE_LACKS_CONDATTR_PSHARED 1 +#define ACE_LACKS_GETHOSTENT 1 +#define ACE_LACKS_GETIPNODEBYADDR 1 +#define ACE_LACKS_GETIPNODEBYNAME 1 +#define ACE_LACKS_IOSTREAM_FX 1 +#define ACE_LACKS_ITOW 1 +#define ACE_LACKS_LINEBUFFERED_STREAMBUF 1 +#define ACE_LACKS_LOG2 1 +#define ACE_LACKS_MSG_ACCRIGHTS 1 +#define ACE_LACKS_MUTEXATTR_PSHARED 1 +#define ACE_LACKS_NETDB_REENTRANT_FUNCTIONS 1 +#define ACE_LACKS_PERFECT_MULTICAST_FILTERING 1 +#define ACE_LACKS_PRI_T 1 +#define ACE_LACKS_PTHREAD_THR_SIGSETMASK 1 +#define ACE_LACKS_PTHREAD_YIELD 1 +#define ACE_LACKS_PWD_REENTRANT_FUNCTIONS 1 +#define ACE_LACKS_RWLOCKATTR_PSHARED 1 +#define ACE_LACKS_RWLOCK_T 1 +#define ACE_LACKS_SETSCHED 1 +#define ACE_LACKS_SIGINFO_H 1 +#define ACE_LACKS_STROPTS_H 1 +#define ACE_LACKS_STRRECVFD 1 +#define ACE_LACKS_TIMEDWAIT_PROTOTYPES 1 +#define ACE_LACKS_TIMESPEC_T 1 +#define ACE_LACKS_UNBUFFERED_STREAMBUF 1 +#define ACE_LACKS_WCSDUP 1 +#define ACE_LACKS_WCSICMP 1 +#define ACE_LACKS_WCSNICMP 1 +#define ACE_SCANDIR_CMP_USES_CONST_VOIDPTR 1 + +#if defined(__x86_64__) +#define ACE_SIZEOF_DOUBLE 8 +#define ACE_SIZEOF_FLOAT 4 +#define ACE_SIZEOF_INT 4 +#define ACE_SIZEOF_LONG 8 +#define ACE_SIZEOF_LONG_DOUBLE 16 +#define ACE_SIZEOF_LONG_LONG 8 +#define ACE_SIZEOF_SHORT 2 +#define ACE_SIZEOF_VOID_P 8 +#define ACE_SIZEOF_WCHAR 4 + +typedef unsigned long ACE_UINT64; +typedef signed long ACE_INT64; + +#define ACE_SSIZE_T_FORMAT_SPECIFIER ACE_TEXT ("%ld") +#define ACE_SIZE_T_FORMAT_SPECIFIER ACE_TEXT ("%lu") + +#elif defined(__i386__) + +#define ACE_SIZEOF_DOUBLE 8 +#define ACE_SIZEOF_FLOAT 4 +#define ACE_SIZEOF_INT 4 +#define ACE_SIZEOF_LONG 4 +#define ACE_SIZEOF_LONG_DOUBLE 12 +#define ACE_SIZEOF_LONG_LONG 8 +#define ACE_SIZEOF_SHORT 2 +#define ACE_SIZEOF_VOID_P 4 +#define ACE_SIZEOF_WCHAR 4 + +typedef unsigned long long ACE_UINT64; +typedef signed long long ACE_INT64; + +#else +# error unknown CPU architecture +#endif + +#endif /* ACE_CONFIG_H */ + +// Local Variables: +// mode:C++ +// End: diff --git a/dep/ACE_wrappers/ace/config-openbsd.h b/dep/ACE_wrappers/ace/config-openbsd.h new file mode 100644 index 00000000000..a730c810da3 --- /dev/null +++ b/dep/ACE_wrappers/ace/config-openbsd.h @@ -0,0 +1,235 @@ +/* -*- C++ -*- */ +// $Id: config-openbsd.h 80826 2008-03-04 14:51:23Z wotte $ + +// The following configuration file is designed to work for OpenBSD +// platforms using GNU g++. + +#ifndef ACE_CONFIG_H +#define ACE_CONFIG_H +#include /**/ "ace/pre.h" + +#if defined (ACE_HAS_THREADS) +#include /**/ +#endif /* ACE_HAS_THREADS */ + +#include "ace/config-posix.h" + +#if ! defined (__ACE_INLINE__) +#define __ACE_INLINE__ +#endif /* ! __ACE_INLINE__ */ + +#define ACE_SIZEOF_LONG_DOUBLE 12 + +#if defined (__GNUG__) +# include "ace/config-g++-common.h" +#endif /* __GNUG__ */ + +// Platform specific directives +// gcc defines __OpenBSD__ automatically for us. +#include + +#if defined (ACE_HAS_THREADS) +#if !defined (_THREAD_SAFE) +#define _THREAD_SAFE +#endif /* _THREAD_SAFE */ + +// Check if pthreads and native exceptions are being used together. +// This causes SEGVs to tbe thrown somewhat randomly for some +// reason. According to newsgroup postings, it appears to be an +// OpenBSD or gcc bug. +#if defined (ACE_USES_NATIVE_EXCEPTIONS) +#error "OpenBSD pthreads and native exceptions currently do not work. See OpenBSD bug #1750" +#endif /* ACE_USES_NATIVE_EXCEPTIONS */ + +#endif /* ACE_HAS_THREADS */ + +#define ACE_HAS_GPERF + +// Platform specific directives +/* Are the following true? */ +#define ACE_LACKS_GETPGID +#define ACE_LACKS_SETPGID +#define ACE_LACKS_SETREGID +#define ACE_LACKS_SETREUID + +#define ACE_HAS_ALT_CUSERID +#define ACE_HAS_RECURSIVE_THR_EXIT_SEMANTICS + +#define ACE_LACKS_RWLOCK_T +#define ACE_HAS_SIG_MACROS +#define ACE_HAS_CHARPTR_DL +#define ACE_HAS_DIRENT + +// OpenBSD 3.6 +#if (OpenBSD < 200411) +# define ACE_USES_ASM_SYMBOL_IN_DLSYM +#endif + +#define ACE_LACKS_UCONTEXT_H + +// ucontext_t is in OpenBSD 3.5 and later. +#if (OpenBSD >= 200405) +# define ACE_HAS_UCONTEXT_T +#endif /* OpenBSD >= 200405 */ + + +// OpenBSD has sigwait defined +#define ACE_HAS_SIGWAIT +#define ACE_HAS_SIGINFO_T + +#define ACE_HAS_REENTRANT_FUNCTIONS +#define ACE_LACKS_NETDB_REENTRANT_FUNCTIONS +#define ACE_LACKS_PWD_REENTRANT_FUNCTIONS +#define ACE_LACKS_RAND_REENTRANT_FUNCTIONS +#define ACE_HAS_2_PARAM_ASCTIME_R_AND_CTIME_R + +#define ACE_HAS_SOCKLEN_T + +#define ACE_HAS_POLL + +// Use of is deprecated. +#define ACE_LACKS_MALLOC_H + +// NetBSD appears to have a sigset_t type. +// #define ACE_LACKS_SIGSET + +// Platform supports POSIX timers via struct timespec. +#define ACE_HAS_POSIX_TIME +#define ACE_HAS_UALARM + +// Platform defines struct timespec but not timespec_t +#define ACE_LACKS_TIMESPEC_T + +#define ACE_LACKS_STDINT_H +#define ACE_LACKS_STROPTS_H +#define ACE_LACKS_WCHAR_H + +#define ACE_LACKS_STRRECVFD + +#define ACE_HAS_SOCKADDR_IN_SIN_LEN +#define ACE_HAS_SOCKADDR_IN6_SIN6_LEN + +// Platform supports System V IPC (most versions of UNIX, but not Win32) +#define ACE_HAS_SYSV_IPC + +// Compiler/platform contains the file. +#define ACE_HAS_SYS_SYSCALL_H + +// OpenBSD supports the getifaddrs interface +#define ACE_HAS_GETIFADDRS + +// Compiler/platform supports SVR4 signal typedef +#define ACE_HAS_SVR4_SIGNAL_T +#define ACE_HAS_CONSISTENT_SIGNAL_PROTOTYPES + +// Compiler/platform supports alloca(). +// Although ACE does have alloca() on this compiler/platform combination, it is +// disabled by default since it can be dangerous. Uncomment the following line +// if you ACE to use it. +//#define ACE_HAS_ALLOCA + +// Compiler/platform supports SVR4 dynamic linking semantics.. +#define ACE_HAS_SVR4_DYNAMIC_LINKING + +// Compiler/platform correctly calls init()/fini() for shared libraries. +#define ACE_HAS_AUTOMATIC_INIT_FINI + +// Explicit dynamic linking permits "lazy" symbol resolution +#define ACE_HAS_RTLD_LAZY_V + +// platform supports POSIX O_NONBLOCK semantics +#define ACE_HAS_POSIX_NONBLOCK + +// platform supports IP multicast +#define ACE_HAS_IP_MULTICAST + +// Lacks perfect filtering, must bind group address. +#if !defined ACE_LACKS_PERFECT_MULTICAST_FILTERING +# define ACE_LACKS_PERFECT_MULTICAST_FILTERING 1 +#endif /* ACE_LACKS_PERFECT_MULTICAST_FILTERING */ + +// Compiler/platform has +//#define ACE_HAS_ALLOCA_H + +// Compiler/platform has the getrusage() system call. +#define ACE_HAS_GETRUSAGE + +// Compiler/platform defines the sig_atomic_t typedef. +#define ACE_HAS_SIG_ATOMIC_T + +// Compiler/platform defines a union semun for SysV shared memory. +#define ACE_HAS_SEMUN + +// Compiler supports the ssize_t typedef. +#define ACE_HAS_SSIZE_T + +// Compiler/platform supports strerror (). +#define ACE_HAS_STRERROR + +// Compiler/platform provides the sockio.h file. +#define ACE_HAS_SYS_SOCKIO_H + +// Defines the page size of the system. +#define ACE_PAGE_SIZE 4096 + +// Platform provides header. +#define ACE_HAS_SYS_FILIO_H + +#define ACE_HAS_SYSCTL + +// Platform/compiler supports timezone * as second parameter to gettimeofday(). +#define ACE_HAS_TIMEZONE_GETTIMEOFDAY + +// OpenBSD's dlsym call segfaults when passed an invalid handle. +// It seems as if most other OSs detect this and just report an +// error. +#define ACE_HAS_DLSYM_SEGFAULT_ON_INVALID_HANDLE + +#define ACE_HAS_MSG +#define ACE_HAS_4_4BSD_SENDMSG_RECVMSG +#define ACE_HAS_NONCONST_MSGSND + +#ifdef ACE_HAS_THREADS +// Thread specific settings + +// And they're even POSIX pthreads +#if !defined (ACE_MT_SAFE) +# define ACE_MT_SAFE 1 +#endif /* ! ACE_MT_SAFE */ +#endif /* ACE_HAS_THREADS */ + +#define ACE_HAS_SIGWAIT + +// Optimize ACE_Handle_Set for select(). +#define ACE_HAS_HANDLE_SET_OPTIMIZED_FOR_SELECT +#define ACE_HAS_NONCONST_SELECT_TIMEVAL +#define ACE_LACKS_THREAD_PROCESS_SCOPING +#define ACE_LACKS_CONDATTR_PSHARED +#define ACE_LACKS_MUTEXATTR_PSHARED +#define ACE_HAS_THREAD_SPECIFIC_STORAGE +#define ACE_HAS_DIRENT + +#if !defined (ACE_HAS_THREADS) +// OpenBSD really has readdir_r () in single threaded mode, +// but the #ifdefs in OS.i select one with the wrong parameter +// sets if the ACE_HAS_POSIX_STD isn't defined (which is defined +// when ACE_HAS_THREADS is defined.) + +#define ACE_LACKS_READDIR_R + +#endif /* ! ACE_HAD_THREADS */ + +// Platform has POSIX terminal interface. +#define ACE_HAS_TERMIOS + +// OpenBSD 3.2 lacks sched_setscheduler (see /usr/src/lib/libc_r/TODO) +#define ACE_LACKS_SETSCHED + +// OpenBSD supports IPv6 by default, but ACE IPv6 code +// has compile errors. +//#define ACE_HAS_IPV6 + +#define ACE_HAS_3_PARAM_READDIR_R + +#include /**/ "ace/post.h" +#endif /* ACE_CONFIG_H */ diff --git a/dep/ACE_wrappers/ace/config-openvms.h b/dep/ACE_wrappers/ace/config-openvms.h new file mode 100644 index 00000000000..0b3d3c15f8e --- /dev/null +++ b/dep/ACE_wrappers/ace/config-openvms.h @@ -0,0 +1,195 @@ +/* -*- C++ -*- */ +// $Id: config-openvms.h 81935 2008-06-12 22:01:53Z jtc $ + +// The following configuration file is designed to work for OpenVMS 7.3-2 + +#ifndef ACE_CONFIG_H +#define ACE_CONFIG_H + +#if !defined (ACE_USE_RCSID) +# define ACE_USE_RCSID 0 +#endif + +#ifdef __cplusplus +#pragma message disable CODCAUUNR +#pragma message disable CODEUNREACHABLE +//#pragma message disable DOLLARID +//#pragma message disable NOSIMPINT +//#pragma message disable NOSTDLONGLONG +#pragma message disable NARROWPTR +//#pragma message disable LONGEXTERN +#pragma message disable UNSCOMZER +#endif + +// Use a signed int to match POSIX +#define __SIGNED_INT_TIME_T + +#define ACE_OPENVMS __VMS_VER + +#define ACE_DLL_SUFFIX ACE_TEXT("") + +#define ACE_HAS_DUMP 1 + +// need this includes to ensure proper sequence of definitions so that +// f.i. HP C/C++ does not '#define ' memcpy, memmove etc. +#include +#include +#include +#undef clearerr +#undef memset +#undef memcpy +#undef memmove + +#if defined(__ia64__) + // on OpenVMS IA64 we need this get the singleton exported since we build + // ACE/TAO with the NOTEMPLATES export option which prohibits exporting + // of any template symbols unless explicitly exported + #define ACE_HAS_CUSTOM_EXPORT_MACROS + #define ACE_Proper_Export_Flag + #define ACE_Proper_Import_Flag + #define ACE_EXPORT_SINGLETON_DECLARATION(T) template class __declspec (dllexport) T + #define ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) template class __declspec (dllexport) SINGLETON_TYPE; +#else + #define ACE_HAS_EXPLICIT_STATIC_TEMPLATE_MEMBER_INSTANTIATION +#endif + +#define ACE_DEFAULT_BASE_ADDR ((char*)(0x30000000)) + +#define ACE_MAX_UDP_PACKET_SIZE 65535 + +#define ACE_HAS_STDCPP_STL_INCLUDES 1 + +/* missing system headers */ +#define ACE_LACKS_STDINT_H 1 +#define ACE_LACKS_SYS_IPC_H 1 +#define ACE_LACKS_SYS_SEM_H 1 +#define ACE_LACKS_SEMAPHORE_H 1 +#define ACE_LACKS_SYS_SELECT_H 1 +#define ACE_LACKS_TERMIOS_H 1 +#define ACE_LACKS_SYS_SHM_H 1 +#define ACE_LACKS_SYS_MSG_H 1 +#define ACE_LACKS_REGEX_H 1 +#define ACE_LACKS_SEARCH_H 1 +#define ACE_LACKS_SCHED_H 1 +#define ACE_LACKS_SYS_SYSCTL_H 1 +#define ACE_LACKS_MALLOC_H 1 +#define ACE_LACKS_SYS_PARAM_H 1 +#define ACE_LACKS_SIGINFO_H 1 +#define ACE_LACKS_UCONTEXT_H 1 + +/* missing rtl functions */ +#define ACE_LACKS_SETPGID 1 +#define ACE_LACKS_SETREUID 1 +#define ACE_LACKS_SETREGID 1 +#define ACE_LACKS_FORK 1 +#define ACE_LACKS_GETPGID 1 +#define ACE_LACKS_SETSID 1 +#define ACE_LACKS_FCNTL 1 +#define ACE_LACKS_SETEGID 1 +#define ACE_LACKS_SETEUID 1 + +#define ACE_LACKS_REALPATH 1 + +#define ACE_LACKS_SYMLINKS 1 + +#define ACE_LACKS_PWD_REENTRANT_FUNCTIONS 1 +#define ACE_LACKS_RAND_REENTRANT_FUNCTIONS 1 + +#define ACE_HAS_P_READ_WRITE +#define ACE_HAS_CHARPTR_DL 1 +#define ACE_HAS_CLOCK_GETTIME 1 +#define ACE_HAS_CLOCK_SETTIME 1 +#define ACE_HAS_VOIDPTR_GETTIMEOFDAY 1 +#define ACE_HAS_DIRENT 1 +#define ACE_HAS_GETPAGESIZE 1 +#define ACE_HAS_MSG +#define ACE_HAS_NONCONST_SELECT_TIMEVAL 1 +#define ACE_HAS_2_PARAM_ASCTIME_R_AND_CTIME_R 1 +#define ACE_HAS_3_PARAM_WCSTOK 1 +#define ACE_HAS_SIGSUSPEND 1 +#define ACE_HAS_SIG_MACROS 1 +#define ACE_HAS_SIGWAIT 1 +#define ACE_HAS_SIGTIMEDWAIT 1 + +#define ACE_HAS_SIG_C_FUNC 1 +#define ACE_HAS_SIGISMEMBER_BUG +#define ACE_HAS_STRNLEN 1 +#define ACE_HAS_STREAMS 1 +#define ACE_HAS_STRERROR 1 +#define ACE_HAS_UALARM 1 +#define ACE_HAS_VOIDPTR_MMAP 1 +#define ACE_HAS_VOIDPTR_SOCKOPT 1 +#define ACE_LACKS_LSTAT 1 +#define ACE_LACKS_MADVISE 1 +#define ACE_LACKS_MKFIFO 1 +#define ACE_LACKS_NETDB_REENTRANT_FUNCTIONS 1 +#define ACE_LACKS_READLINK 1 +#define ACE_LACKS_RLIMIT 1 +#define ACE_LACKS_RLIMIT_PROTOTYPE 1 +#define ACE_LACKS_SETSCHED +#define ACE_LACKS_SYSCALL 1 +#define ACE_LACKS_WCSTOULL 1 + +/* (missing) standard data types */ +#define ACE_LACKS_CONST_TIMESPEC_PTR 1 +#define ACE_LACKS_SUSECONDS_T 1 +#define ACE_HAS_IDTYPE_T 1 +#define ACE_HAS_SIGINFO_T 1 +#define ACE_HAS_XPG4_MULTIBYTE_CHAR 1 +#define ACE_HAS_SIZET_SOCKET_LEN 1 +#define ACE_HAS_SSIZE_T 1 +#define ACE_LACKS_PRI_T 1 +#define ACE_LACKS_SEMBUF_T 1 +#define ACE_LACKS_STRRECVFD 1 +#define ACE_LACKS_T_ERRNO 1 + +/* POSIX threads ompatibilities */ +#define ACE_LACKS_RWLOCK_T 1 +#define ACE_LACKS_PTHREAD_KILL 1 +#define ACE_LACKS_THREAD_PROCESS_SCOPING 1 + +#define ACE_HAS_PTHREADS 1 +#define ACE_HAS_PTHREAD_PROCESS_ENUM 1 +#define ACE_LACKS_UNNAMED_SEMAPHORE 1 +#define ACE_MT_SAFE 1 +#define ACE_HAS_THREADS 1 +#define ACE_HAS_THREAD_SPECIFIC_STORAGE 1 +#define ACE_HAS_THR_C_DEST 1 +#define ACE_HAS_THR_C_FUNC 1 +#define ACE_LACKS_PTHREAD_SIGMASK 1 +#define ACE_LACKS_PTHREAD_THR_SIGSETMASK 1 +#define ACE_NEEDS_HUGE_THREAD_STACKSIZE (64U*1024) +#define ACE_HAS_PTHREAD_SETCONCURRENCY 1 +#define ACE_HAS_PTHREAD_GETCONCURRENCY 1 +#define ACE_HAS_PTHREAD_SCHEDPARAM 1 + +/* language/platform conformance */ +#define ACE_NEW_THROWS_EXCEPTIONS 1 +#define ACE_TEMPLATES_REQUIRE_SOURCE 1 +#define ACE_USES_STD_NAMESPACE_FOR_STDCPP_LIB 1 +#define ACE_HAS_AUTOMATIC_INIT_FINI 1 +#define ACE_LACKS_UNIX_SIGNALS 1 + +#define ACE_HAS_CONSISTENT_SIGNAL_PROTOTYPES 1 +#define ACE_HAS_CPLUSPLUS_HEADERS 1 +#define ACE_HAS_EXCEPTIONS 1 +#define ACE_LACKS_LINEBUFFERED_STREAMBUF 1 + +#define ACE_HAS_GPERF 1 +#define ACE_HAS_IP_MULTICAST 1 +#define ACE_LACKS_PERFECT_MULTICAST_FILTERING 1 +#define ACE_HAS_POSIX_NONBLOCK 1 +#define ACE_HAS_POSIX_TIME 1 +#define ACE_HAS_BROKEN_POSIX_TIME 1 +#define ACE_HAS_STANDARD_CPP_LIBRARY 1 +#define ACE_HAS_STRING_CLASS 1 +#define ACE_HAS_SVR4_DYNAMIC_LINKING 1 + +#define ACE_HAS_TEMPLATE_TYPEDEFS 1 +#define ACE_LACKS_NAMED_POSIX_SEM 1 +#define ACE_LACKS_SYSV_SHMEM 1 +#define ACE_LACKS_UNIX_DOMAIN_SOCKETS 1 +#define ACE_LACKS_UNIX_SYSLOG 1 +#define ACE_LACKS_ALPHASORT 1 + +#endif diff --git a/dep/ACE_wrappers/ace/config-pharlap.h b/dep/ACE_wrappers/ace/config-pharlap.h new file mode 100644 index 00000000000..8a0d2792a44 --- /dev/null +++ b/dep/ACE_wrappers/ace/config-pharlap.h @@ -0,0 +1,90 @@ +/* -*- C++ -*- */ +// $Id: config-pharlap.h 81837 2008-06-04 22:48:08Z shuston $ + +// This configuration file is for use with the PharLap Realtime ETS Kernel. +// It has been tested with PharLap TNT Embedded ToolSuite version 9.1. + +#ifndef ACE_CONFIG_PHARLAP_H +#define ACE_CONFIG_PHARLAP_H +#include /**/ "ace/pre.h" + +#define ACE_HAS_PHARLAP +// Some features are only available with the Realtime edition of ETS. +// Assume that if using ACE, the realtime version is also being used, but +// allow it to be turned off as well. +#ifndef ACE_HAS_PHARLAP_RT +# define ACE_HAS_PHARLAP_RT +#else +# if (ACE_HAS_PHARLAP_RT == 0) +# undef ACE_HAS_PHARLAP_RT +# endif +#endif + +// Fortunately, PharLap ETS offers much of the Win32 API. But it's still on +// Winsock 1.1 +#define ACE_HAS_WINSOCK2 0 + +// The TSS implementation doesn't pass muster on the TSS_Test, but it works +// well with ACE's TSS emulation. +#define ACE_HAS_TSS_EMULATION + +#define ACE_LACKS_MMAP +#define ACE_LACKS_MPROTECT +#define ACE_LACKS_MSYNC +#define ACE_LACKS_TCP_NODELAY +#define ACE_LACKS_MSG_WFMO +#define ACE_LACKS_WIN32_MOVEFILEEX +#define ACE_LACKS_WIN32_REGISTRY +#define ACE_LACKS_WIN32_SECURITY_DESCRIPTORS +#define ACE_LACKS_WIN32_SERVICES +#define ACE_LACKS_WIN32_SETFILEPOINTEREX + +// There's no host table, by default. So using "localhost" won't work. +// If your system does have the ability to use "localhost" and you want to, +// define it before including this file. +#if !defined (ACE_LOCALHOST) +# define ACE_LOCALHOST "127.0.0.1" +#endif /* ACE_LOCALHOST */ + +// The normal Windows default stack size doesn't hold for ETS. Set what you +// want explicitly. +#if !defined (ACE_DEFAULT_THREAD_STACKSIZE) +# define ACE_DEFAULT_THREAD_STACKSIZE (1024*1024) +#endif /* ACE_DEFAULT_THREAD_STACKSIZE */ + +// Don't know how to get the page size at execution time. This is most likely +// the correct value. +#define ACE_PAGE_SIZE 4096 + +#if defined (ACE_HAS_PHARLAP_RT) +# define ACE_HAS_IP_MULTICAST + // ETS winsock doesn't define IP level socket options +//# define IP_TOS 8 +#endif /* ACE_HAS_PHARLAP_RT */ + +// Let the config-win32.h file do its thing +#undef ACE_CONFIG_H +#include "ace/config-win32.h" +// Now remove things that desktop/server Windows has but Pharlap ETS doesn't. +#undef ACE_HAS_INTERLOCKED_EXCHANGEADD +#undef ACE_HAS_WCHAR + +// PharLap's exports apparantly define LockFile, but it's documented as +// unsupported. LockFileEx is not present. +#define ACE_LACKS_FILELOCKS + +#include /**/ +#if defined (ACE_HAS_PHARLAP_RT) +# include /**/ +#define ACE_LACKS_IP_ADD_MEMBERSHIP +#endif /* ACE_HAS_PHARLAP_RT */ + +// Although IN_CLASSD is defined in both winsock.h and winsock2.h, it ends +// up undefined for Pharlap ETS builds. If this is the case, set things up +// so nothing looks like class D. +#if !defined (IN_CLASSD) +# define IN_CLASSD(i) (0) +#endif + +#include /**/ "ace/post.h" +#endif /* ACE_CONFIG_PHARLAP_H */ diff --git a/dep/ACE_wrappers/ace/config-posix-nonetworking.h b/dep/ACE_wrappers/ace/config-posix-nonetworking.h new file mode 100644 index 00000000000..7edc31d0dab --- /dev/null +++ b/dep/ACE_wrappers/ace/config-posix-nonetworking.h @@ -0,0 +1,86 @@ +/* -*- C -*- */ +// $Id: config-posix-nonetworking.h 80826 2008-03-04 14:51:23Z wotte $ + +/* The following configuration file is designed to work for RTEMS + platforms using GNU C. +*/ + +#ifndef ACE_CONFIG_POSIX_NONETWORKING_H +#define ACE_CONFIG_POSIX_NONETWORKING_H + +// Missing header files +# define ACE_LACKS_SYS_UIO_H +# define ACE_LACKS_SYS_SOCKET_H +# define ACE_LACKS_NETINET_IN_H +# define ACE_LACKS_NETDB_H +# define ACE_LACKS_ARPA_INET_H +# define ACE_LACKS_SYS_SELECT_H +# define ACE_LACKS_NET_IF_H +# define ACE_LACKS_SYSLOG_H +# define ACE_LACKS_SYS_UN_H +# define ACE_LACKS_MEMORY_H +# define ACE_LACKS_SYS_SYSCTL_H +# define ACE_LACKS_NETINET_TCP_H + +// Missing types +# define ACE_LACKS_IOVEC +# define ACE_LACKS_IN_ADDR +# define ACE_LACKS_SOCKADDR_IN +# define ACE_LACKS_SOCKADDR_UN +# define ACE_LACKS_HOSTENT +# define ACE_LACKS_SOCKADDR +# define ACE_LACKS_IP_MREQ +# define ACE_LACKS_PROTOENT +# define ACE_LACKS_SERVENT +# define ACE_LACKS_IFREQ +# define ACE_LACKS_IFCONF +# define ACE_LACKS_LINGER + +// Missing methods +# define ACE_LACKS_GETHOSTBYADDR +# define ACE_LACKS_GETHOSTBYNAME +# define ACE_LACKS_GETIPNODEBYADDR +# define ACE_LACKS_LISTEN +# define ACE_LACKS_BIND +# define ACE_LACKS_NTOHL +# define ACE_LACKS_HTONL +# define ACE_LACKS_HTONS +# define ACE_LACKS_NTOHS +# define ACE_LACKS_SELECT +# define ACE_LACKS_SOCKET +# define ACE_LACKS_SHUTDOWN +# define ACE_LACKS_SETSOCKOPT +# define ACE_LACKS_INET_ATON +# define ACE_LACKS_INET_ADDR +# define ACE_LACKS_INET_NTOA +# define ACE_LACKS_GET_BCAST_ADDR +# define ACE_LACKS_GETHOSTENT +# define ACE_LACKS_GETSERVBYNAME +# define ACE_LACKS_ACCEPT +# define ACE_LACKS_CONNECT +# define ACE_LACKS_GETPEERNAME +# define ACE_LACKS_GETSOCKNAME +# define ACE_LACKS_GETSOCKOPT +# define ACE_LACKS_RECV +# define ACE_LACKS_SEND +# define ACE_LACKS_SENDTO +# define ACE_LACKS_RECVFROM +# define ACE_LACKS_RECVMSG +# define ACE_LACKS_SENDMSG +# define ACE_LACKS_GETHOSTBYADDR_R +# define ACE_LACKS_GETPROTOBYNAME +# define ACE_LACKS_GETPROTOBYNUMBER +# define ACE_LACKS_GETSERVBYNAME +# define ACE_LACKS_READV +# define ACE_LACKS_WRITEV +# define ACE_LACKS_SOCKETPAIR +# undef ACE_HAS_MSG + +// Missing OS features +# define ACE_LACKS_UNIX_SYSLOG +# define ACE_LACKS_TCP_NODELAY + +// Missing ACE features +# define ACE_DISABLE_NOTIFY_PIPE_DEFAULT 1 + +#endif /* ACE_CONFIG_POSIX_NONETWORKING_H */ diff --git a/dep/ACE_wrappers/ace/config-posix.h b/dep/ACE_wrappers/ace/config-posix.h new file mode 100644 index 00000000000..09b4e0671f3 --- /dev/null +++ b/dep/ACE_wrappers/ace/config-posix.h @@ -0,0 +1,73 @@ +/* -*- C++ -*- */ +// $Id: config-posix.h 82517 2008-08-05 19:36:26Z shuston $ + +#ifndef ACE_CONFIG_POSIX_H +#define ACE_CONFIG_POSIX_H + +#include + +/* The following POSIX constants are defined after is + * included. They are documented in: + * http://www.opengroup.org/onlinepubs/007904975/basedefs/unistd.h.html + */ +#if defined(_POSIX_REALTIME_SIGNALS) && (_POSIX_REALTIME_SIGNALS-0 != -1 ) +# if !defined(ACE_HAS_POSIX_REALTIME_SIGNALS) +# define ACE_HAS_POSIX_REALTIME_SIGNALS +# endif /* ACE_HAS_POSIX_REALTIME_SIGNALS */ +#endif /* _POSIX_REALTIME_SIGNALS */ + +#if defined(_POSIX_ASYNCHRONOUS_IO) && (_POSIX_ASYNCHRONOUS_IO-0 != -1 ) +# if !defined(ACE_HAS_AIO_CALLS) +# define ACE_HAS_AIO_CALLS +# endif /* ACE_HAS_AIO_CALLS */ +#endif /* _POSIX_ASYNCHRONOUS_IO */ + +#if !defined (ACE_MT_SAFE) || (ACE_MT_SAFE != 0) +# if defined(_POSIX_SEMAPHORES) && (_POSIX_SEMAPHORES-0 != -1 ) +# if !defined(ACE_HAS_POSIX_SEM) +# define ACE_HAS_POSIX_SEM +# endif /* ACE_HAS_POSIX_SEM */ +# if defined(ACE_HAS_POSIX_SEM) +# if !defined (ACE_HAS_POSIX_SEM_TIMEOUT) && \ + (defined (_POSIX_TIMEOUTS) && (_POSIX_TIMEOUTS-0 != -1)) +# define ACE_HAS_POSIX_SEM_TIMEOUT +# endif /* ACE_HAS_POSIX_SEM_TIMEOUT && _POSIX_TIMEOUTS */ +# endif /* ACE_HAS_POSIX_SEM */ +# endif /* ACE_HAS_POSIX_SEM */ +#endif /* !ACE_MT_SAFE */ + +#if defined(_POSIX_SHARED_MEMORY_OBJECTS) && (_POSIX_SHARED_MEMORY_OBJECTS-0 != -1 ) +# if !defined(ACE_HAS_SHM_OPEN) +# define ACE_HAS_SHM_OPEN +# endif /* ACE_HAS_SHM_OPEN */ +#endif /* _POSIX_SHARED_MEMORY_OBJECTS */ + +// Check if threading enabled/disable through platform_macros +#if !defined (ACE_MT_SAFE) || (ACE_MT_SAFE != 0) +// Allow the user to disable use of threads by setting ACE_HAS_THREADS to 0 +// before including this file. The platform config (not macros) file can +// often detect that the compiler was invoked with or without threads support +// and set this accordingly. +# if defined (ACE_HAS_THREADS) && (ACE_HAS_THREADS == 0) +# undef ACE_HAS_THREADS +# else +# if defined(_POSIX_THREADS) && (_POSIX_THREADS-0 != -1 ) +# if !defined(ACE_HAS_THREADS) +# define ACE_HAS_THREADS +# endif /* ACE_HAS_THREADS */ + +# if !defined(ACE_HAS_PTHREADS) +# define ACE_HAS_PTHREADS +# endif /* ACE_HAS_PTHREADS */ + +# endif /* _POSIX_THREADS */ +# endif /* ACE_HAS_THREADS */ +#endif /* !ACE_MT_SAFE */ + +#if defined(_POSIX_MESSAGE_PASSING) && (_POSIX_MESSAGE_PASSING-0 != -1 ) +# if !defined(ACE_HAS_POSIX_MESSAGE_PASSING) +# define ACE_HAS_POSIX_MESSAGE_PASSING +# endif /* ACE_HAS_POSIX_MESSAGE_PASSING */ +#endif /* _POSIX_MESSAGE_PASSING */ + +#endif /* ACE_CONFIG_POSIX_H */ diff --git a/dep/ACE_wrappers/ace/config-qnx-neutrino.h b/dep/ACE_wrappers/ace/config-qnx-neutrino.h new file mode 100644 index 00000000000..745b864916b --- /dev/null +++ b/dep/ACE_wrappers/ace/config-qnx-neutrino.h @@ -0,0 +1,137 @@ +// -*- C++ -*- +// $Id: config-qnx-neutrino.h 80826 2008-03-04 14:51:23Z wotte $ +// The following configuration file is designed to work for Neutrino +// 2.0 (Beta) with GNU C++ and the POSIX (pthread) threads package. + +#ifndef ACE_CONFIG_H +#define ACE_CONFIG_H +#include /**/ "ace/pre.h" + +#define _POSIX_C_SOURCE 199506 +#define _QNX_SOURCE + +// These constants are in i386-nto/include/limits.h, but egcs +// picks up its own limits.h instead: +#define _POSIX_NAME_MAX 14 /* Max bytes in a filename */ +#define _POSIX_PATH_MAX 256 /* Num. bytes in pathname (excl. NULL) */ + +#if defined(__OPTIMIZE__) +# if defined(__X86__) + // string.h can't be used by ACE with __OPTIMIZE__. +# undef __OPTIMIZE__ +# include +# define __OPTIMIZE__ +# endif /* __X86__ */ +#endif /* __OPTIMIZE__ */ + +#include "ace/config-g++-common.h" + +// The following defines the Neutrino compiler. +// gcc should know to call g++ as necessary +#ifdef __GNUC__ +# define ACE_CC_NAME ACE_TEXT ("gcc") +#else +# define ACE_CC_NAME ACE_TEXT ("NTO compiler ??") +#endif + +// /usr/nto/include/float.h defines +// FLT_MAX_EXP 127 +// DBL_MAX_EXP 1023 +// ace expects 128 & 1024 respectively +// to set the following macros in ace/Basic_Types.h +// These macros are: +// #define ACE_SIZEOF_DOUBLE 8 +// #define ACE_SIZEOF_FLOAT 4 + +#define ACE_HAS_2_PARAM_ASCTIME_R_AND_CTIME_R +#define ACE_HAS_4_4BSD_SENDMSG_RECVMSG +// Although ACE does have alloca() on this compiler/platform combination, it is +// disabled by default since it can be dangerous. Uncomment the following line +// if you ACE to use it. +//#define ACE_HAS_ALLOCA +#define ACE_HAS_ALLOCA_H +#define ACE_HAS_AUTOMATIC_INIT_FINI +#define ACE_HAS_CLOCK_GETTIME +#define ACE_HAS_CLOCK_SETTIME +#define ACE_HAS_CONSISTENT_SIGNAL_PROTOTYPES +#define ACE_HAS_DIRENT +#define ACE_HAS_GETPAGESIZE +#define ACE_HAS_HANDLE_SET_OPTIMIZED_FOR_SELECT +#define ACE_HAS_NONSTATIC_OBJECT_MANAGER +#define ACE_HAS_INLINED_OSCALLS +#define ACE_HAS_IP_MULTICAST +#define ACE_HAS_MSG +#define ACE_HAS_MT_SAFE_MKTIME +#define ACE_HAS_MUTEX_TIMEOUTS +#define ACE_HAS_NONCONST_SELECT_TIMEVAL +#define ACE_HAS_NONCONST_SWAB +#define ACE_HAS_POSIX_SEM +#define ACE_HAS_POSIX_TIME +#define ACE_HAS_PTHREADS +#define ACE_HAS_P_READ_WRITE +#define ACE_HAS_REENTRANT_FUNCTIONS +#define ACE_HAS_SELECT_H +#define ACE_HAS_SIGINFO_T +#define ACE_HAS_SIGISMEMBER_BUG +#define ACE_HAS_SIGWAIT +#define ACE_HAS_SIG_ATOMIC_T +#define ACE_HAS_SIG_MACROS +#define ACE_HAS_SOCKADDR_IN_SIN_LEN +#define ACE_HAS_SSIZE_T +#define ACE_HAS_STRERROR +#define ACE_HAS_STRINGS +#define ACE_HAS_SVR4_GETTIMEOFDAY +#define ACE_HAS_TERMIOS +#define ACE_HAS_THREADS +#define ACE_HAS_THREAD_SPECIFIC_STORAGE +#define ACE_HAS_THR_C_DEST +#define ACE_HAS_THR_C_FUNC +#define ACE_HAS_TIMEZONE_GETTIMEOFDAY +#define ACE_HAS_UALARM +#define ACE_HAS_UCONTEXT_T +#define ACE_HAS_VOIDPTR_MMAP +#define ACE_HAS_VOIDPTR_SOCKOPT +#define ACE_LACKS_CONDATTR_PSHARED +#define ACE_LACKS_CONST_TIMESPEC_PTR +#define ACE_LACKS_CUSERID +#define ACE_LACKS_FORK +#define ACE_LACKS_LINEBUFFERED_STREAMBUF +#define ACE_LACKS_MADVISE +#define ACE_LACKS_MUTEXATTR_PSHARED +#define ACE_LACKS_NAMED_POSIX_SEM +#define ACE_LACKS_NETDB_REENTRANT_FUNCTIONS +#define ACE_LACKS_NETDB_REENTRANT_FUNCTIONS +#define ACE_LACKS_POLL_H +#define ACE_LACKS_PTHREAD_THR_SIGSETMASK +#define ACE_LACKS_RWLOCK_T +#define ACE_LACKS_SBRK +#define ACE_LACKS_SEEKDIR +#define ACE_LACKS_SOCKET_BUFSIZ +#define ACE_LACKS_SOCKETPAIR +#define ACE_LACKS_STROPTS_H +#define ACE_LACKS_STREAM_MODULES +#define ACE_LACKS_STRRECVFD +#define ACE_LACKS_SYSCALL +#define ACE_LACKS_SYS_MSG_H +#define ACE_LACKS_SYS_SHM_H +#define ACE_LACKS_SYSV_SHMEM +#define ACE_LACKS_TCP_NODELAY +#define ACE_LACKS_TELLDIR +#define ACE_LACKS_TIMESPEC_T +#define ACE_LACKS_TRUNCATE +#define ACE_LACKS_T_ERRNO +#define ACE_LACKS_UALARM_PROTOTYPE +#define ACE_LACKS_UCONTEXT_H +#define ACE_LACKS_UNIX_DOMAIN_SOCKETS +#define ACE_LACKS_U_LONGLONG_T +#define ACE_MT_SAFE 1 +#define ACE_NEEDS_FUNC_DEFINITIONS +#define ACE_NEEDS_HUGE_THREAD_STACKSIZE 65536 +#define ACE_TEMPLATES_REQUIRE_SOURCE +#define ACE_THR_PRI_FIFO_DEF 10 +#define ACE_USES_STD_NAMESPACE_FOR_STDCPP_LIB 1 +#define ACE_HAS_SIGTIMEDWAIT +#define ACE_HAS_SIGSUSPEND + +#include /**/ "ace/post.h" +#endif /* ACE_CONFIG_H */ diff --git a/dep/ACE_wrappers/ace/config-qnx-rtp-62x.h b/dep/ACE_wrappers/ace/config-qnx-rtp-62x.h new file mode 100644 index 00000000000..3574153baf6 --- /dev/null +++ b/dep/ACE_wrappers/ace/config-qnx-rtp-62x.h @@ -0,0 +1,129 @@ +// -*- C++ -*- +// $Id: config-qnx-rtp-62x.h 80826 2008-03-04 14:51:23Z wotte $ +// The following configuration file is designed to work for QNX RTP 621 +// GNU C++ and the POSIX (pthread) threads package. You can get QNX +// RTP at http://get.qnx.com +#ifndef ACE_CONFIG_QNX_RTP_62x_H +#define ACE_CONFIG_QNX_RTP_62x_H +#include /**/ "ace/pre.h" +#include /**/ "ace/config-qnx-rtp-common.h" + +///////////////////////////////////////////////////////////////// +// Definition of the features that are available. +// +// ACE_HAS Section +///////////////////////////////////////////////////////////////// +#define ACE_HAS_2_PARAM_ASCTIME_R_AND_CTIME_R +#define ACE_HAS_3_PARAM_WCSTOK +#define ACE_HAS_3_PARAM_READDIR_R +#define ACE_HAS_4_4BSD_SENDMSG_RECVMSG +// Although ACE does have alloca() on this compiler/platform combination, it is +// disabled by default since it can be dangerous. Uncomment the following line +// if you ACE to use it. +//#define ACE_HAS_ALLOCA +#define ACE_HAS_ALLOCA_H +#define ACE_HAS_ALT_CUSERID +#define ACE_HAS_AUTOMATIC_INIT_FINI +#define ACE_HAS_CLOCK_GETTIME +#define ACE_HAS_CLOCK_SETTIME +#define ACE_HAS_CONSISTENT_SIGNAL_PROTOTYPES +#define ACE_HAS_DIRENT +#define ACE_HAS_GETPAGESIZE +#define ACE_HAS_GETIFADDRS +// Enable gperf, this is a hosted configuration. +#define ACE_HAS_GPERF +#define ACE_HAS_HANDLE_SET_OPTIMIZED_FOR_SELECT +//#define ACE_HAS_NONSTATIC_OBJECT_MANAGER +#define ACE_HAS_IP_MULTICAST +#define ACE_HAS_MSG +#define ACE_HAS_MT_SAFE_MKTIME +#define ACE_HAS_MUTEX_TIMEOUTS +#define ACE_HAS_NONCONST_SELECT_TIMEVAL +#define ACE_HAS_NONCONST_SWAB +#define ACE_HAS_POSIX_SEM +#define ACE_HAS_POSIX_TIME +#define ACE_HAS_PTHREADS +#define ACE_HAS_P_READ_WRITE +#define ACE_HAS_REENTRANT_FUNCTIONS +#define ACE_HAS_SELECT_H +#define ACE_HAS_SHM_OPEN +#define ACE_HAS_SIGINFO_T +#define ACE_HAS_SIGISMEMBER_BUG +#define ACE_HAS_SIGWAIT +#define ACE_HAS_SIG_ATOMIC_T +#define ACE_HAS_SIG_MACROS +#define ACE_HAS_SOCKADDR_IN_SIN_LEN +#define ACE_HAS_SOCKLEN_T +#define ACE_HAS_SSIZE_T +#define ACE_HAS_STRERROR +#define ACE_HAS_STRINGS +#define ACE_HAS_SVR4_DYNAMIC_LINKING +#define ACE_HAS_SVR4_GETTIMEOFDAY +#define ACE_HAS_TERMIOS +#define ACE_HAS_THREADS +#define ACE_HAS_THREAD_SPECIFIC_STORAGE +#define ACE_HAS_THR_C_DEST +#define ACE_HAS_THR_C_FUNC +#define ACE_HAS_TIMEZONE_GETTIMEOFDAY +#define ACE_HAS_UALARM +#define ACE_HAS_UCONTEXT_T +#define ACE_HAS_VOIDPTR_MMAP +#define ACE_HAS_VOIDPTR_SOCKOPT + +///////////////////////////////////////////////////////////////// +// Definition of the features that are not available. +// +// ACE_LACKS Section +///////////////////////////////////////////////////////////////// +#define ACE_LACKS_CONST_TIMESPEC_PTR +#define ACE_LACKS_LINEBUFFERED_STREAMBUF +#define ACE_LACKS_MADVISE +// lacks mqueue mgr or speed-up named sem by shm emulation +#define ACE_LACKS_NAMED_POSIX_SEM +#define ACE_LACKS_NETDB_REENTRANT_FUNCTIONS +// Multicast_Tests reports for NTO 621 frames from unsubscribed groups +#define ACE_LACKS_PERFECT_MULTICAST_FILTERING 1 +#define ACE_LACKS_POLL_H +#define ACE_LACKS_PTHREAD_THR_SIGSETMASK +#define ACE_LACKS_RWLOCK_T +#define ACE_LACKS_SOCKET_BUFSIZ +#define ACE_LACKS_STREAM_MODULES +#define ACE_LACKS_STROPTS_H +#define ACE_LACKS_STRPTIME +#define ACE_LACKS_STRRECVFD +#define ACE_LACKS_SYSCALL +#define ACE_LACKS_SYS_MSG_H +#define ACE_LACKS_SYSV_SHMEM +#define ACE_LACKS_SYS_SHM_H +#define ACE_LACKS_TIMESPEC_T +#define ACE_LACKS_T_ERRNO +#define ACE_LACKS_U_LONGLONG_T +#define ACE_LACKS_ALPHASORT + +#define ACE_LACKS_RLIMIT // QNX rlimit syscalls don't work properly with ACE. + +#define ACE_MT_SAFE 1 +#define ACE_NEEDS_FUNC_DEFINITIONS +#define ACE_NEEDS_HUGE_THREAD_STACKSIZE 64000 +#define ACE_THR_PRI_FIFO_DEF 10 +#define ACE_USES_STD_NAMESPACE_FOR_STDCPP_LIB 1 +#define ACE_HAS_SIGTIMEDWAIT +#define ACE_HAS_SIGSUSPEND + +#define ACE_HAS_BROKEN_PREALLOCATED_OBJECTS_AFTER_FORK 1 + +#define ACE_SIZEOF_WCHAR 4 + +// No prototypes +#define ACE_LACKS_ITOW +#define ACE_LACKS_WCSICMP +#define ACE_LACKS_WCSNICMP +#define ACE_LACKS_WCSDUP +// The default value of FD_SETSIZE is 32, but actually x86 NTO +// supports by default at least 1000 descriptors in fd_set. +#if defined( FD_SETSIZE ) +#undef FD_SETSIZE +#endif +#define FD_SETSIZE 1000 +#include /**/ "ace/post.h" +#endif /* ACE_CONFIG_QNX_RTP_62x_H*/ diff --git a/dep/ACE_wrappers/ace/config-qnx-rtp-common.h b/dep/ACE_wrappers/ace/config-qnx-rtp-common.h new file mode 100644 index 00000000000..410d94e4ee5 --- /dev/null +++ b/dep/ACE_wrappers/ace/config-qnx-rtp-common.h @@ -0,0 +1,46 @@ +// -*- C++ -*- +// $Id: config-qnx-rtp-common.h 80826 2008-03-04 14:51:23Z wotte $ +// several macros common to various qnx neutrino version. + +#ifndef ACE_CONFIG_QNX_RTP_COMMON_H +#define ACE_CONFIG_QNX_RTP_COMMON_H +#include /**/ "ace/pre.h" + +#define _POSIX_C_SOURCE 199506 +#define _QNX_SOURCE + +// These constants are in i386-nto/include/limits.h, but egcs +// picks up its own limits.h instead: +#define _POSIX_NAME_MAX 14 /* Max bytes in a filename */ +#define _POSIX_PATH_MAX 256 /* Num. bytes in pathname (excl. NULL) */ + +#if defined(__OPTIMIZE__) +# if defined(__X86__) + // string.h can't be used by ACE with __OPTIMIZE__. +# undef __OPTIMIZE__ +# include +# define __OPTIMIZE__ +# endif /* __X86__ */ +#endif /* __OPTIMIZE__ */ + +#include "ace/config-g++-common.h" + +// The following defines the Neutrino compiler. +// gcc should know to call g++ as necessary +#ifdef __GNUC__ +# define ACE_CC_NAME ACE_TEXT ("gcc") +#else +# define ACE_CC_NAME ACE_TEXT ("QNX-RTP compiler ??") +#endif + +// /usr/nto/include/float.h defines +// FLT_MAX_EXP 127 +// DBL_MAX_EXP 1023 +// ace expects 128 & 1024 respectively +// to set the following macros in ace/Basic_Types.h +// These macros are: +#define ACE_SIZEOF_DOUBLE 8 +#define ACE_SIZEOF_FLOAT 4 + +#include /**/ "ace/post.h" +#endif /* ACE_CONFIG_QNX_RTP_COMMON_H */ diff --git a/dep/ACE_wrappers/ace/config-qnx-rtp-pre62x.h b/dep/ACE_wrappers/ace/config-qnx-rtp-pre62x.h new file mode 100644 index 00000000000..92adf76b162 --- /dev/null +++ b/dep/ACE_wrappers/ace/config-qnx-rtp-pre62x.h @@ -0,0 +1,151 @@ +// -*- C++ -*- +// $Id: config-qnx-rtp-pre62x.h 80826 2008-03-04 14:51:23Z wotte $ +// The following configuration file is designed to work for QNX RTP +// GNU C++ and the POSIX (pthread) threads package. You can get QNX +// RTP at http://get.qnx.com + +#ifndef ACE_CONFIG_RTP_PRE62x_H +#define ACE_CONFIG_RTP_PRE62x_H +#include /**/ "ace/pre.h" +#include /**/ "ace/config-qnx-rtp-common.h" + +///////////////////////////////////////////////////////////////// +// Definition of the features that are available. +// +// ACE_HAS Section +///////////////////////////////////////////////////////////////// + +#define ACE_HAS_2_PARAM_ASCTIME_R_AND_CTIME_R +#define ACE_HAS_4_4BSD_SENDMSG_RECVMSG +// Although ACE does have alloca() on this compiler/platform combination, it is +// disabled by default since it can be dangerous. Uncomment the following line +// if you ACE to use it. +//#define ACE_HAS_ALLOCA +#define ACE_HAS_ALLOCA_H +#define ACE_HAS_AUTOMATIC_INIT_FINI +#define ACE_HAS_CLOCK_GETTIME +#define ACE_HAS_CLOCK_SETTIME +#define ACE_HAS_CONSISTENT_SIGNAL_PROTOTYPES +#define ACE_HAS_DIRENT +#define ACE_HAS_GETPAGESIZE +// Enable gperf, this is a hosted configuration. +#define ACE_HAS_GPERF +#define ACE_HAS_HANDLE_SET_OPTIMIZED_FOR_SELECT +//#define ACE_HAS_NONSTATIC_OBJECT_MANAGER +#define ACE_HAS_INLINED_OSCALLS +#define ACE_HAS_IP_MULTICAST +#define ACE_HAS_MSG +#define ACE_HAS_MT_SAFE_MKTIME +#define ACE_HAS_MUTEX_TIMEOUTS +#define ACE_HAS_NONCONST_SELECT_TIMEVAL +#define ACE_HAS_POSIX_SEM +#define ACE_HAS_POSIX_TIME +#define ACE_HAS_PTHREADS +#define ACE_HAS_P_READ_WRITE +#define ACE_HAS_REENTRANT_FUNCTIONS +#define ACE_HAS_SELECT_H +#define ACE_HAS_SIGINFO_T +#define ACE_HAS_SIGISMEMBER_BUG +#define ACE_HAS_SIGWAIT +#define ACE_HAS_SIG_ATOMIC_T +#define ACE_HAS_SIG_MACROS +#define ACE_HAS_SOCKADDR_IN_SIN_LEN +// #define ACE_HAS_SIZET_SOCKET_LEN +#define ACE_HAS_SOCKLEN_T +#define ACE_HAS_SSIZE_T +#define ACE_HAS_STRERROR +#define ACE_HAS_STRINGS +#define ACE_HAS_SVR4_GETTIMEOFDAY +#define ACE_HAS_TERMIOS +#define ACE_HAS_THREADS +#define ACE_HAS_THREAD_SPECIFIC_STORAGE +#define ACE_HAS_THR_C_DEST +#define ACE_HAS_THR_C_FUNC +#define ACE_HAS_TIMEZONE_GETTIMEOFDAY +#define ACE_HAS_UALARM +#define ACE_HAS_UCONTEXT_T +#define ACE_HAS_VOIDPTR_MMAP +#define ACE_HAS_VOIDPTR_SOCKOPT + +///////////////////////////////////////////////////////////////// +// Definition of the features that are not available. +// +// ACE_LACKS Section +///////////////////////////////////////////////////////////////// +#define ACE_LACKS_CONDATTR_PSHARED +#define ACE_LACKS_CONST_TIMESPEC_PTR +#define ACE_LACKS_LINEBUFFERED_STREAMBUF +#define ACE_LACKS_MADVISE +#define ACE_LACKS_MUTEXATTR_PSHARED +#define ACE_LACKS_NAMED_POSIX_SEM +#define ACE_LACKS_NETDB_REENTRANT_FUNCTIONS +#define ACE_LACKS_NETDB_REENTRANT_FUNCTIONS +#define ACE_LACKS_PTHREAD_THR_SIGSETMASK +#define ACE_LACKS_RWLOCK_T +#define ACE_LACKS_SBRK +#define ACE_LACKS_SEEKDIR +#define ACE_LACKS_SOCKET_BUFSIZ +#define ACE_LACKS_SOCKETPAIR +// Even if the QNX RTP docs says that socket pair are +// available, there is actually no implementation of +// soket-pairs. +#define ACE_LACKS_STREAM_MODULES +#define ACE_LACKS_STRRECVFD +#define ACE_LACKS_SYSCALL +#define ACE_LACKS_SYS_MSG_H +#define ACE_LACKS_SYSV_SHMEM +#define ACE_LACKS_ALPHASORT +//#define ACE_LACKS_TCP_NODELAY // Based on the QNX RTP documentation, this option seems to + // to be supported. +#define ACE_LACKS_TELLDIR +#define ACE_LACKS_TIMESPEC_T +#define ACE_LACKS_TRUNCATE +#define ACE_LACKS_T_ERRNO +#define ACE_LACKS_UALARM_PROTOTYPE +#define ACE_LACKS_UCONTEXT_H +#define ACE_LACKS_UNIX_DOMAIN_SOCKETS +#define ACE_LACKS_U_LONGLONG_T + +#define ACE_LACKS_RLIMIT // QNX rlimit syscalls don't work properly with ACE. + +#define ACE_MT_SAFE 1 +#define ACE_NEEDS_FUNC_DEFINITIONS +#define ACE_NEEDS_HUGE_THREAD_STACKSIZE 64000 +#define ACE_TEMPLATES_REQUIRE_SOURCE +#define ACE_THR_PRI_FIFO_DEF 10 +#define ACE_USES_STD_NAMESPACE_FOR_STDCPP_LIB 1 +#define ACE_HAS_SIGTIMEDWAIT +#define ACE_HAS_SIGSUSPEND + +#define ACE_HAS_BROKEN_PREALLOCATED_OBJECTS_AFTER_FORK 1 + +#define ACE_SIZEOF_WCHAR 4 + +// Not really, but the prototype returns wchar_t instead of wchar_t * +#define ACE_LACKS_WCSSTR + +// No prototypes +#define ACE_LACKS_ITOW +#define ACE_LACKS_WCSICMP +#define ACE_LACKS_WCSNICMP +#define ACE_LACKS_WCSDUP + +// And these have prototypes but no implementation +#define ACE_LACKS_WCSLEN +#define ACE_LACKS_WCSNCMP +#define ACE_LACKS_WCSCPY +#define ACE_LACKS_WCSNCPY +#define ACE_LACKS_TOWLOWER +#define ACE_LACKS_TOWUPPER +#define ACE_LACKS_WCSCMP +#define ACE_LACKS_WCSCAT +#define ACE_LACKS_WCSNCAT +#define ACE_LACKS_WCSSPN +#define ACE_LACKS_WCSCHR +#define ACE_LACKS_WCSPBRK +#define ACE_LACKS_WCSRCHR + +#define ACE_LACKS_ACE_IOSTREAM + +#include /**/ "ace/post.h" +#endif /* ACE_CONFIG_RTP_PRE62x_H */ diff --git a/dep/ACE_wrappers/ace/config-qnx-rtp.h b/dep/ACE_wrappers/ace/config-qnx-rtp.h new file mode 100644 index 00000000000..c55a4abb988 --- /dev/null +++ b/dep/ACE_wrappers/ace/config-qnx-rtp.h @@ -0,0 +1,25 @@ +// -*- C++ -*- +// $Id: config-qnx-rtp.h 80826 2008-03-04 14:51:23Z wotte $ +// The following configuration file is designed to work for QNX RTP +// GNU C++ and the POSIX (pthread) threads package. You can get QNX +// RTP at http://get.qnx.com. +// This header is intended to switch between configuration for +// various NTO versions. +#ifndef ACE_CONFIG_QNX_RTP_H +#define ACE_CONFIG_QNX_RTP_H +#include /**/ "ace/pre.h" + +#include +#if !defined(_NTO_VERSION) +# error "Could not detect QNX version from macro _NTO_VERSION" +#else +# define ACE_NTO_VERS _NTO_VERSION +# if ACE_NTO_VERS < 620 +# include /**/ "ace/config-qnx-rtp-pre62x.h" +# else +# include /**/ "ace/config-qnx-rtp-62x.h" +# endif +#endif + +#include /**/ "ace/post.h" +#endif /* ACE_CONFIG_QNX_RTP_H */ diff --git a/dep/ACE_wrappers/ace/config-rtems.h b/dep/ACE_wrappers/ace/config-rtems.h new file mode 100644 index 00000000000..e2b45861559 --- /dev/null +++ b/dep/ACE_wrappers/ace/config-rtems.h @@ -0,0 +1,165 @@ +/* -*- C -*- */ +// $Id: config-rtems.h 80826 2008-03-04 14:51:23Z wotte $ + +/* The following configuration file is designed to work for RTEMS + platforms using GNU C. +*/ + +#ifndef ACE_CONFIG_H +#define ACE_CONFIG_H + +#if ! defined (__ACE_INLINE__) +#define __ACE_INLINE__ +#endif /* ! __ACE_INLINE__ */ + +// Needed to make some prototypes visible. +// #if ! defined (_GNU_SOURCE) +// #define _GNU_SOURCE +// #endif /* ! _GNU_SOURCE */ + +// First the machine specific part +// There are no known port specific issues with the RTEMS port of ACE. +// XXX Pentium and PowerPC have high res timer support in ACE. + +// Then the compiler specific parts +#if defined (__GNUG__) + // config-g-common.h undef's ACE_HAS_STRING_CLASS with -frepo, so + // this must appear before its #include. +# define ACE_HAS_STRING_CLASS +# include "ace/config-g++-common.h" +#else /* ! __GNUG__ */ +# ifdef __cplusplus /* Let it slide for C compilers. */ +# error unsupported compiler in ace/config-rtems.h +# endif /* __cplusplus */ +#endif /* ! __GNUG__ */ + +#include "ace/config-posix.h" + +// Completely common part :-) + +#define ACE_HAS_NONSTATIC_OBJECT_MANAGER + +#define ACE_LACKS_ALPHASORT +#define ACE_LACKS_REGEX_H +#define ACE_LACKS_STROPTS_H +#define ACE_LACKS_DLFCN_H +#define ACE_LACKS_SIGINFO_H +#define ACE_LACKS_SYS_IPC_H +#define ACE_LACKS_SYS_SEM_H +#define ACE_LACKS_STRINGS_H +#define ACE_LACKS_SYS_SHM_H +#define ACE_LACKS_SETEGID +#define ACE_LACKS_SETEUID +#define ACE_LACKS_POLL_H +#define ACE_HAS_NONCONST_SELECT_TIMEVAL +#define ACE_LACKS_STRCASECMP +#define ACE_LACKS_MKSTEMP +#define ACE_LACKS_STRDUP +#define ACE_LACKS_STRTOK_R +#define ACE_LACKS_RAND_REENTRANT_FUNCTIONS +#define ACE_LACKS_REALPATH +#define ACE_LACKS_TEMPNAM + +// Temporarily, enabling this results in compile errors with +// rtems 4.6.6. +#define ACE_LACKS_WCHAR_H + +#if !defined (ACE_MT_SAFE) +#define ACE_MT_SAFE 1 +#endif + +#if ACE_MT_SAFE +# define ACE_HAS_THREADS +# define ACE_HAS_PTHREADS +# define ACE_HAS_THREAD_SPECIFIC_STORAGE +# define ACE_HAS_PTHREAD_SCHEDPARAM +# define ACE_LACKS_THREAD_PROCESS_SCOPING +#else +# define ACE_HAS_POSIX_GETPWNAM_R +# define ACE_HAS_2_PARAM_ASCTIME_R_AND_CTIME_R +#endif + +#define ACE_HAS_ALT_CUSERID +#define ACE_HAS_4_4BSD_SENDMSG_RECVMSG +#define ACE_HAS_3_PARAM_READDIR_R +#define ACE_HAS_CLOCK_GETTIME +#define ACE_HAS_CLOCK_SETTIME +#define ACE_HAS_DIRENT +#define ACE_HAS_HANDLE_SET_OPTIMIZED_FOR_SELECT +#define ACE_HAS_MSG +#define ACE_HAS_MT_SAFE_MKTIME +#define ACE_HAS_NONCONST_READV +#define ACE_HAS_GETPAGESIZE +#define ACE_HAS_POSIX_SEM +#define ACE_HAS_POSIX_TIME +#define ACE_HAS_REENTRANT_FUNCTIONS +#define ACE_HAS_SIGACTION_CONSTP2 +#define ACE_HAS_SIGINFO_T +#define ACE_HAS_SIGSUSPEND +#define ACE_HAS_SSIZE_T +#define ACE_HAS_STRERROR +#define ACE_HAS_VOIDPTR_GETTIMEOFDAY +#define ACE_HAS_SYS_ERRLIST +#define ACE_HAS_SYS_FILIO_H +#define ACE_HAS_TIMEZONE_GETTIMEOFDAY +#define ACE_LACKS_EXEC +#define ACE_LACKS_FILELOCKS +#define ACE_LACKS_FORK +#define ACE_LACKS_GETPGID +#define ACE_LACKS_TIMESPEC_T +#define ACE_LACKS_MADVISE +#define ACE_LACKS_MMAP +#define ACE_LACKS_MPROTECT +#define ACE_LACKS_MSYNC +#define ACE_LACKS_NETDB_REENTRANT_FUNCTIONS +#define ACE_LACKS_PTHREAD_THR_SIGSETMASK +#define ACE_LACKS_READDIR_R +#define ACE_LACKS_READLINK +#define ACE_LACKS_READV +#define ACE_LACKS_RLIMIT +#define ACE_LACKS_RLIMIT_PROTOTYPE +#define ACE_LACKS_RWLOCK_T +#define ACE_LACKS_SBRK +#define ACE_LACKS_SEMBUF_T +#define ACE_LACKS_SETREUID +#define ACE_LACKS_SETREUID_PROTOTYPE +#define ACE_LACKS_SETREGID +#define ACE_LACKS_SETREGID_PROTOTYPE +#define ACE_LACKS_STRPTIME +#define ACE_LACKS_STRRECVFD +#define ACE_LACKS_SI_ADDR +#define ACE_LACKS_SOCKETPAIR +#define ACE_LACKS_SYS_MSG_H +#define ACE_LACKS_SYSV_SHMEM +#define ACE_LACKS_SYSCALL +#define ACE_LACKS_UCONTEXT_H +#define ACE_HAS_NONCONST_WRITEV +#define ACE_LACKS_WRITEV +#define ACE_NEEDS_HUGE_THREAD_STACKSIZE 65536 +#define ACE_NEEDS_SCHED_H +#define ACE_HAS_POSIX_NONBLOCK +#define ACE_HAS_TERMIOS + +// rtems 4.7 or higher +#if (__RTEMS_MAJOR__ > 4) || (__RTEMS_MAJOR__ == 4 && __RTEMS_MINOR__ > 6) +# define ACE_HAS_UALARM +#else +# define ACE_HAS_NOTSUP_SC_PAGESIZE +# define ACE_LACKS_SUSECONDS_T +# define ACE_LACKS_INTPTR_T +# undef ACE_HAS_SHM_OPEN +# undef ACE_HAS_AIO_CALLS +#endif + +// __RTEMS_REVISION__ could also be used but this is broken according +// to the rtems people + +#if !defined (_POSIX_REALTIME_SIGNALS) +# define ACE_HAS_CONSISTENT_SIGNAL_PROTOTYPES +#endif + +#if defined (ACE_LACKS_NETWORKING) +# include "ace/config-posix-nonetworking.h" +#endif + +#endif /* ACE_CONFIG_H */ diff --git a/dep/ACE_wrappers/ace/config-sco-5.0.0-nothread.h b/dep/ACE_wrappers/ace/config-sco-5.0.0-nothread.h new file mode 100644 index 00000000000..b8368063967 --- /dev/null +++ b/dep/ACE_wrappers/ace/config-sco-5.0.0-nothread.h @@ -0,0 +1,14 @@ +/* -*- C++ -*- */ +// $Id: config-sco-5.0.0-nothread.h 80826 2008-03-04 14:51:23Z wotte $ + +#ifndef ACE_CONFIG_H +#define ACE_CONFIG_H +#include /**/ "ace/pre.h" + +#include "ace/config-g++-common.h" +#include "ace/config-sco-5.0.0.h" + +#define ACE_HAS_GNU_CSTRING_H + +#include /**/ "ace/post.h" +#endif /* ACE_CONFIG_H */ diff --git a/dep/ACE_wrappers/ace/config-sco-5.0.0.h b/dep/ACE_wrappers/ace/config-sco-5.0.0.h new file mode 100644 index 00000000000..22849e50518 --- /dev/null +++ b/dep/ACE_wrappers/ace/config-sco-5.0.0.h @@ -0,0 +1,97 @@ +/* -*- C++ -*- */ +// $Id: config-sco-5.0.0.h 80826 2008-03-04 14:51:23Z wotte $ + +#ifndef ACE_CONFIG_SCO_5_0_0_H +#define ACE_CONFIG_SCO_5_0_0_H +#include /**/ "ace/pre.h" + +// Compiling for SCO. +#if !defined (SCO) +#define SCO +#endif /* SCO */ + +#if defined (SCO) && !defined (MAXPATHLEN) +#define MAXPATHLEN 1023 +#endif /* SCO */ + +#define ACE_HAS_NONCONST_SELECT_TIMEVAL +#define ACE_HAS_SIG_MACROS +#define ACE_LACKS_CONST_TIMESPEC_PTR +#define ACE_LACKS_SYSCALL +#define ACE_LACKS_STRRECVFD +#define ACE_NEEDS_FTRUNCATE +#define ACE_LACKS_MADVISE +#define ACE_LACKS_NETDB_REENTRANT_FUNCTIONS + +#define ACE_DEFAULT_CLOSE_ALL_HANDLES 0 + +// Platform supports System V IPC (most versions of UNIX, but not Win32) +#define ACE_HAS_SYSV_IPC +#define ACE_HAS_NONCONST_MSGSND +#define ACE_HAS_BIG_FD_SET +#define ACE_HAS_SVR4_DYNAMIC_LINKING +#define ACE_HAS_AUTOMATIC_INIT_FINI + +// Platform has POSIX terminal interface. +#define ACE_HAS_TERMIOS + +// Compiler/platform contains the file. +//#define ACE_HAS_SYS_SYSCALL_H + +// Fixes a problem with HP/UX not wrapping the mmap(2) header files +// with extern "C". +//#define ACE_HAS_BROKEN_MMAP_H + +// Prototypes for both signal() and struct sigaction are consistent. +#define ACE_HAS_CONSISTENT_SIGNAL_PROTOTYPES + +// Compiler/platform has correctly prototyped header files. +#define ACE_HAS_CPLUSPLUS_HEADERS + +// Header files lack t_errno for ACE_TLI. +//#define ACE_LACKS_T_ERRNO + +// Compiler/platform supports poll(). +// #define ACE_HAS_POLL + +// Platform supports POSIX O_NONBLOCK semantics. +#define ACE_HAS_POSIX_NONBLOCK + +// Compiler/platform defines the sig_atomic_t typedef +#define ACE_HAS_SIG_ATOMIC_T + +// Compiler supports the ssize_t typedef. +//#define ACE_HAS_SSIZE_T + +// Defines the page size of the system. +#define ACE_PAGE_SIZE 4096 + +// Compiler/platform supports strerror (). +#define ACE_HAS_STRERROR + +#define ACE_HAS_TIMEZONE_GETTIMEOFDAY + +// Note, this only works if the flag is set above! +//#define ACE_HAS_GETRUSAGE + +// Platform uses int for select() rather than fd_set. +#define ACE_HAS_SELECT_H + +// Platform has prototypes for ACE_TLI. +#define ACE_HAS_TLI_PROTOTYPES +// Platform has the XLI version of ACE_TLI. +// #define ACE_HAS_XLI + +#define ACE_HAS_SIGINFO_T +#define ACE_HAS_UCONTEXT_T + +#define ACE_LACKS_STRCASECMP + +// #define ACE_HAS_POSIX_TIME +#define ACE_HAS_IP_MULTICAST +#define ACE_HAS_DIRENT +#define ACE_LACKS_READDIR_R +#define ACE_HAS_GPERF + +#include /**/ "ace/post.h" +#endif /* ACE_CONFIG_SCO_5_0_0_H */ diff --git a/dep/ACE_wrappers/ace/config-suncc-common.h b/dep/ACE_wrappers/ace/config-suncc-common.h new file mode 100644 index 00000000000..3f0bae8a295 --- /dev/null +++ b/dep/ACE_wrappers/ace/config-suncc-common.h @@ -0,0 +1,67 @@ +// -*- C++ -*- +// +// $Id: config-suncc-common.h 81935 2008-06-12 22:01:53Z jtc $ + +#ifndef ACE_SUNCC_COMMON_H +#define ACE_SUNCC_COMMON_H +#include /**/ "ace/pre.h" + +# define ACE_HAS_CPLUSPLUS_HEADERS +# define ACE_HAS_STDCPP_STL_INCLUDES +# define ACE_HAS_TEMPLATE_TYPEDEFS +# define ACE_HAS_STANDARD_CPP_LIBRARY 1 +# define ACE_HAS_WORKING_EXPLICIT_TEMPLATE_DESTRUCTOR +# define ACE_USES_STD_NAMESPACE_FOR_STDCPP_LIB 1 +# define ACE_HAS_STRING_CLASS +# define ACE_EXPLICIT_TEMPLATE_DESTRUCTOR_TAKES_ARGS +# define ACE_HAS_THR_C_DEST 1 +# define ACE_LACKS_SWAB +#if defined (ACE_HAS_CUSTOM_EXPORT_MACROS) && ACE_HAS_CUSTOM_EXPORT_MACROS == 0 +# undef ACE_HAS_CUSTOM_EXPORT_MACROS +#else +# ifndef ACE_HAS_CUSTOM_EXPORT_MACROS +# define ACE_HAS_CUSTOM_EXPORT_MACROS +# endif /* !ACE_HAS_CUSTOM_EXPORT_MACROS */ +# define ACE_Proper_Export_Flag __attribute__ ((visibility("default"))) +# define ACE_Proper_Import_Flag +# define ACE_EXPORT_SINGLETON_DECLARATION(T) template class ACE_Proper_Export_Flag T +# define ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) template class ACE_Proper_Export_Flag SINGLETON_TYPE ; +# define ACE_IMPORT_SINGLETON_DECLARATION(T) __extension__ extern template class T +# define ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) __extension__ extern template class SINGLETON_TYPE; +#endif /* ACE_HAS_CUSTOM_EXPORT_MACROS == 0 */ + +// __EXCEPTIONS is defined with -fexceptions, the egcs default. It +// is not defined with -fno-exceptions, the ACE default for g++. +// ACE_HAS_EXCEPTIONS is defined in +// include/makeinclude/wrapper_macros.GNU, so this really isn't +// necessary. Just in case . . . +# if defined (__EXCEPTIONS) && !defined (ACE_HAS_EXCEPTIONS) +# define ACE_HAS_EXCEPTIONS +# endif /* __EXCEPTIONS && ! ACE_HAS_EXCEPTIONS */ + +# if defined (ACE_HAS_EXCEPTIONS) +# define ACE_NEW_THROWS_EXCEPTIONS +# endif /* ACE_HAS_EXCEPTIONS */ + +#if (defined (i386) || defined (__i386__)) && !defined (ACE_SIZEOF_LONG_DOUBLE) +# define ACE_SIZEOF_LONG_DOUBLE 12 +#endif /* i386 */ + +#if defined (i386) || defined (__i386__) + // If running an Intel, assume that it's a Pentium so that + // ACE_OS::gethrtime () can use the RDTSC instruction. If running a + // 486 or lower, be sure to comment this out. (If not running an + // Intel CPU, this #define will not be seen because of the i386 + // protection, so it can be ignored.) +# define ACE_HAS_PENTIUM +#endif /* i386 */ + +#if !defined (ACE_LACKS_PRAGMA_ONCE) + // We define it with a -D with make depend. +# define ACE_LACKS_PRAGMA_ONCE +#endif /* ! ACE_LACKS_PRAGMA_ONCE */ + +#define ACE_TEMPLATES_REQUIRE_SOURCE + +#include /**/ "ace/post.h" +#endif /* ACE_SUNCC_COMMON_H */ diff --git a/dep/ACE_wrappers/ace/config-sunos5.10.h b/dep/ACE_wrappers/ace/config-sunos5.10.h new file mode 100644 index 00000000000..79ec20a637c --- /dev/null +++ b/dep/ACE_wrappers/ace/config-sunos5.10.h @@ -0,0 +1,51 @@ +/* -*- C++ -*- */ +// $Id: config-sunos5.10.h 81805 2008-05-30 10:14:59Z vzykov $ + +// The following configuration file is designed to work for SunOS 5.10 +// (Solaris 10) platforms using the SunC++ 5.x (Sun Studio 8-10), or g++ +// compilers. + +#ifndef ACE_CONFIG_H + +// ACE_CONFIG_H is defined by one of the following #included headers. + +// #include the SunOS 5.9 config, then add any SunOS 5.10 updates below. +#include "ace/config-sunos5.9.h" + +// Solaris 10 can do sem_timedwait() (see ACE_OS::sema_wait). +#define ACE_HAS_POSIX_SEM_TIMEOUT + +#define ACE_HAS_SCANDIR + +// Solaris 10 offers a useable alphasort() unlike previous Solaris versions. +#if defined (ACE_LACKS_ALPHASORT) +# undef ACE_LACKS_ALPHASORT +#endif + +// Solaris 10 offers a useable log2() unlike previous Solaris versions. +#if defined (ACE_LACKS_LOG2) +# undef ACE_LACKS_LOG2 +#endif + +// Solaris 10 delivers pthread_attr_setstack +#if defined (ACE_LACKS_PTHREAD_ATTR_SETSTACK) +# undef ACE_LACKS_PTHREAD_ATTR_SETSTACK +#endif + +// Solaris 10 introduced printf() modifiers for [s]size_t types. +#if defined (ACE_SSIZE_T_FORMAT_SPECIFIER) +# undef ACE_SSIZE_T_FORMAT_SPECIFIER +# define ACE_SSIZE_T_FORMAT_SPECIFIER ACE_TEXT ("%zd") +#endif /* ACE_SSIZE_T_FORMAT_SPECIFIER */ + +#if defined (ACE_SIZE_T_FORMAT_SPECIFIER) +# undef ACE_SIZE_T_FORMAT_SPECIFIER +# define ACE_SIZE_T_FORMAT_SPECIFIER ACE_TEXT ("%zu") +#endif /* ACE_SIZE_T_FORMAT_SPECIFIER */ + +// Solaris 10 offers wcstoull() +#if defined (ACE_LACKS_WCSTOULL) +# undef ACE_LACKS_WCSTOULL +#endif /* ACE_LACKS_WCSTOULL */ + +#endif /* ACE_CONFIG_H */ diff --git a/dep/ACE_wrappers/ace/config-sunos5.11.h b/dep/ACE_wrappers/ace/config-sunos5.11.h new file mode 100644 index 00000000000..bbfd91c82fe --- /dev/null +++ b/dep/ACE_wrappers/ace/config-sunos5.11.h @@ -0,0 +1,15 @@ +/* -*- C++ -*- */ +// $Id: config-sunos5.11.h 80826 2008-03-04 14:51:23Z wotte $ + +// The following configuration file is designed to work for SunOS 5.11 +// (Solaris 11) platforms using the SunC++ 5.x (Sun Studio 10-12), or g++ +// compilers. + +#ifndef ACE_CONFIG_H + +// ACE_CONFIG_H is defined by one of the following #included headers. + +// #include the SunOS 5.10 config, then add any SunOS 5.11 updates below. +#include "ace/config-sunos5.10.h" + +#endif /* ACE_CONFIG_H */ diff --git a/dep/ACE_wrappers/ace/config-sunos5.4-g++.h b/dep/ACE_wrappers/ace/config-sunos5.4-g++.h new file mode 100644 index 00000000000..f911da8d361 --- /dev/null +++ b/dep/ACE_wrappers/ace/config-sunos5.4-g++.h @@ -0,0 +1,181 @@ +/* -*- C++ -*- */ +// $Id: config-sunos5.4-g++.h 81697 2008-05-14 18:33:11Z johnnyw $ + +// The following configuration file is designed to work for SunOS 5.4 +// platforms using the GNU g++ compiler. + +#ifndef ACE_CONFIG_H +#define ACE_CONFIG_H +#include /**/ "ace/pre.h" + +#if ! defined (__ACE_INLINE__) +# define __ACE_INLINE__ +#endif /* ! __ACE_INLINE__ */ + +// config-g++-common.h undef's ACE_HAS_STRING_CLASS with -frepo, so +// this must appear before its #include. +#define ACE_HAS_STRING_CLASS + +#include "ace/config-g++-common.h" +#define ACE_HAS_GNU_CSTRING_H + +#define ACE_HAS_HANDLE_SET_OPTIMIZED_FOR_SELECT + +// Platform supports pread() and pwrite() +#define ACE_HAS_P_READ_WRITE + +#define ACE_HAS_XPG4_MULTIBYTE_CHAR + +// Platform has POSIX terminal interface. +#define ACE_HAS_TERMIOS + +// Platform supports System V IPC (most versions of UNIX, but not Win32) +#define ACE_HAS_SYSV_IPC + +// Sun has the wrong prototype for sendmsg. +#define ACE_HAS_NONCONST_SENDMSG + +// The SunOS 5.x version of rand_r is inconsistent with the header files... +#define ACE_HAS_BROKEN_RANDR + +// Platform supports system configuration information. +#define ACE_HAS_SYS_SYSTEMINFO_H +#define ACE_HAS_SYSINFO + +// Platform supports the POSIX regular expression library +#define ACE_HAS_REGEX + +// Platform supports recvmsg and sendmsg. +#define ACE_HAS_MSG + +// Compiler/platform contains the file. +#define ACE_HAS_SYS_SYSCALL_H + +// Compiler/platform correctly calls init()/fini() for shared libraries. +#define ACE_HAS_AUTOMATIC_INIT_FINI + +// Platform supports POSIX O_NONBLOCK semantics. +#define ACE_HAS_POSIX_NONBLOCK + +// Compiler/platform has correctly prototyped header files. +#define ACE_HAS_CPLUSPLUS_HEADERS + +// Compiler/platform supports SunOS high resolution timers. +#define ACE_HAS_HI_RES_TIMER + +// Platform supports IP multicast +#define ACE_HAS_IP_MULTICAST + +// Compiler/platform supports alloca() +// Although ACE does have alloca() on this compiler/platform combination, it is +// disabled by default since it can be dangerous. Uncomment the following line +// if you ACE to use it. +//#define ACE_HAS_ALLOCA + +// Compiler/platform has +#define ACE_HAS_ALLOCA_H + +// Platform contains . +#define ACE_HAS_POLL + +// Platform supports POSIX timers via timestruc_t. +#define ACE_HAS_POSIX_TIME + +// Platform supports the /proc file system. +#define ACE_HAS_PROC_FS + +// Platform supports the prusage_t struct. +#define ACE_HAS_PRUSAGE_T + +// Compiler/platform defines the sig_atomic_t typedef. +#define ACE_HAS_SIG_ATOMIC_T + +// Platform supports SVR4 extended signals. +#define ACE_HAS_SIGINFO_T +#define ACE_HAS_UCONTEXT_T + +// Compiler/platform provides the sockio.h file. +#define ACE_HAS_SYS_SOCKIO_H + +// Compiler supports the ssize_t typedef. +#define ACE_HAS_SSIZE_T + +// Platform supports STREAMS. +#define ACE_HAS_STREAMS + +// Platform supports STREAM pipes. +#define ACE_HAS_STREAM_PIPES + +// Compiler/platform supports strerror (). +#define ACE_HAS_STRERROR + +// Compiler/platform supports struct strbuf. +#define ACE_HAS_STRBUF_T + +// Compiler/platform supports SVR4 dynamic linking semantics. +#define ACE_HAS_SVR4_DYNAMIC_LINKING + +// Compiler/platform supports SVR4 gettimeofday() prototype. +#define ACE_HAS_SVR4_GETTIMEOFDAY + +// Platform lacks pthread_sigaction +#define ACE_LACKS_PTHREAD_THR_SIGSETMASK + +// Compiler/platform supports SVR4 TLI (in particular, T_GETNAME stuff)... +#define ACE_HAS_SVR4_TLI + +// Platform provides header. +#define ACE_HAS_SYS_FILIO_H + +// Compiler/platform supports sys_siglist array. +#define ACE_HAS_SYS_SIGLIST + +/* Turn off the following defines if you want to disable threading. */ +// Compile using multi-thread libraries. +#if !defined (ACE_MT_SAFE) +# define ACE_MT_SAFE 1 +# if !defined (_REENTRANT) +# define _REENTRANT +# endif /* _REENTRANT */ +#endif /* !ACE_MT_SAFE */ + +// Platform supports Solaris threads. +#define ACE_HAS_STHREADS + +// Platform supports threads. +#define ACE_HAS_THREADS + +// Compiler/platform has thread-specific storage +#define ACE_HAS_THREAD_SPECIFIC_STORAGE + +// Platform supports reentrant functions (i.e., all the POSIX *_r functions). +#define ACE_HAS_REENTRANT_FUNCTIONS + +/* end threading defines */ + +#define ACE_HAS_PRIOCNTL +#define ACE_NEEDS_LWP_PRIO_SET + +// Platform supports TLI timod STREAMS module. +#define ACE_HAS_TIMOD_H + +// Platform supports TLI tiuser header. +#define ACE_HAS_TIUSER_H + +// Platform provides TLI function prototypes. +#define ACE_HAS_TLI_PROTOTYPES + +// Platform supports TLI. +#define ACE_HAS_TLI + +// Use the poll() event demultiplexor rather than select(). +//#define ACE_USE_POLL + +// Defines the page size of the system. +#define ACE_PAGE_SIZE 4096 +#define ACE_HAS_IDTYPE_T +#define ACE_HAS_GPERF +#define ACE_HAS_DIRENT + +#include /**/ "ace/post.h" +#endif /* ACE_CONFIG_H */ diff --git a/dep/ACE_wrappers/ace/config-sunos5.4-sunc++-4.x.h b/dep/ACE_wrappers/ace/config-sunos5.4-sunc++-4.x.h new file mode 100644 index 00000000000..36a155cdbab --- /dev/null +++ b/dep/ACE_wrappers/ace/config-sunos5.4-sunc++-4.x.h @@ -0,0 +1,190 @@ +/* -*- C++ -*- */ +// $Id: config-sunos5.4-sunc++-4.x.h 81935 2008-06-12 22:01:53Z jtc $ + +// The following configuration file is designed to work for SunOS 5.4 +// platforms using the SunC++ 4.0.x compiler. + +#ifndef ACE_CONFIG_H +#define ACE_CONFIG_H +#include /**/ "ace/pre.h" + +#if ! defined (__ACE_INLINE__) +# define __ACE_INLINE__ +#endif /* ! __ACE_INLINE__ */ + +// Optimize ACE_Handle_Set for select(). +#define ACE_HAS_HANDLE_SET_OPTIMIZED_FOR_SELECT + +// Platform supports pread() and pwrite() +#define ACE_HAS_P_READ_WRITE + +#define ACE_HAS_XPG4_MULTIBYTE_CHAR + +// Platform supports System V IPC (most versions of UNIX, but not Win32) +#define ACE_HAS_SYSV_IPC + +// Sun has the wrong prototype for sendmsg. +#define ACE_HAS_NONCONST_SENDMSG + +// The SunOS 5.x version of rand_r is inconsistent with the header files... +#define ACE_HAS_BROKEN_RANDR + +// Platform supports system configuration information. +#define ACE_HAS_SYS_SYSTEMINFO_H +#define ACE_HAS_SYSINFO + +// Platform supports the POSIX regular expression library. +#define ACE_HAS_REGEX + +// Platform supports recvmsg and sendmsg. +#define ACE_HAS_MSG + +// Compiler/platform contains the file. +#define ACE_HAS_SYS_SYSCALL_H + +// Platform has POSIX terminal interface. +#define ACE_HAS_TERMIOS + +// Compiler/platform correctly calls init()/fini() for shared libraries. +#define ACE_HAS_AUTOMATIC_INIT_FINI + +// Platform supports POSIX O_NONBLOCK semantics. +#define ACE_HAS_POSIX_NONBLOCK + +// Compiler/platform has correctly prototyped header files. +#define ACE_HAS_CPLUSPLUS_HEADERS + +// Compiler/platform supports SunOS high resolution timers. +#define ACE_HAS_HI_RES_TIMER + +// Platform supports IP multicast +#define ACE_HAS_IP_MULTICAST + +// Compiler/platform supports alloca() +// Although ACE does have alloca() on this compiler/platform combination, it is +// disabled by default since it can be dangerous. Uncomment the following line +// if you ACE to use it. +//#define ACE_HAS_ALLOCA + +// Compiler/platform has +#define ACE_HAS_ALLOCA_H + +// Platform contains . +#define ACE_HAS_POLL + +// Platform supports POSIX timers via timestruc_t. +#define ACE_HAS_POSIX_TIME + +// Platform supports the /proc file system. +#define ACE_HAS_PROC_FS + +// Platform supports the prusage_t struct. +#define ACE_HAS_PRUSAGE_T + +// Compiler/platform defines the sig_atomic_t typedef. +#define ACE_HAS_SIG_ATOMIC_T + +// Platform supports SVR4 extended signals. +#define ACE_HAS_SIGINFO_T +#define ACE_HAS_UCONTEXT_T + +// Compiler/platform provides the sockio.h file. +#define ACE_HAS_SYS_SOCKIO_H + +// Compiler supports the ssize_t typedef. +#define ACE_HAS_SSIZE_T + +// Platform supports STREAMS. +#define ACE_HAS_STREAMS + +// Platform supports STREAM pipes. +#define ACE_HAS_STREAM_PIPES + +// Compiler/platform supports strerror (). +#define ACE_HAS_STRERROR + +// Compiler/platform supports struct strbuf. +#define ACE_HAS_STRBUF_T + +// Compiler/platform supports SVR4 dynamic linking semantics. +#define ACE_HAS_SVR4_DYNAMIC_LINKING + +// Compiler/platform supports SVR4 gettimeofday() prototype. +#define ACE_HAS_SVR4_GETTIMEOFDAY + +// Compiler/platform supports SVR4 signal typedef. +#define ACE_HAS_SVR4_SIGNAL_T + +// Platform lacks pthread_sigaction +#define ACE_LACKS_PTHREAD_THR_SIGSETMASK + +// Compiler/platform supports SVR4 ACE_TLI (in particular, T_GETNAME stuff)... +#define ACE_HAS_SVR4_TLI + +// Platform provides header. +#define ACE_HAS_SYS_FILIO_H + +// Compiler/platform supports sys_siglist array. +#define ACE_HAS_SYS_SIGLIST + +/* Turn off the following defines if you want to disable threading. */ +// Compile using multi-thread libraries. +#if !defined (ACE_MT_SAFE) +# define ACE_MT_SAFE 1 +#endif + +// Platform supports Solaris threads. +#define ACE_HAS_STHREADS + +// Platform supports threads. +#define ACE_HAS_THREADS + +// Compiler/platform has thread-specific storage +#define ACE_HAS_THREAD_SPECIFIC_STORAGE + +// Platform supports reentrant functions (i.e., all the POSIX *_r functions). +#define ACE_HAS_REENTRANT_FUNCTIONS + +/* end threading defines */ + +#define ACE_HAS_PRIOCNTL +#define ACE_NEEDS_LWP_PRIO_SET + +// Reactor detects deadlock +// #define ACE_REACTOR_HAS_DEADLOCK_DETECTION + +// Platform supports ACE_TLI timod STREAMS module. +#define ACE_HAS_TIMOD_H + +// Platform supports ACE_TLI tiuser header. +#define ACE_HAS_TIUSER_H + +// Platform provides ACE_TLI function prototypes. +#define ACE_HAS_TLI_PROTOTYPES + +// Platform supports ACE_TLI. +#define ACE_HAS_TLI + +#define ACE_LACKS_LINEBUFFERED_STREAMBUF +#define ACE_LACKS_SIGNED_CHAR + +// Use the poll() event demultiplexor rather than select(). +//#define ACE_USE_POLL + +#define ACE_NEEDS_DEV_IO_CONVERSION + +// Defines the page size of the system. +#define ACE_PAGE_SIZE 4096 +#define ACE_HAS_IDTYPE_T + +#define ACE_HAS_GPERF +#define ACE_HAS_DIRENT + +# if defined (ACE_HAS_EXCEPTIONS) + // If exceptions are enabled and we are using Sun/CC then + // throws an exception instead of returning 0. +# define ACE_NEW_THROWS_EXCEPTIONS +# endif /* ACE_HAS_EXCEPTIONS */ + +#include /**/ "ace/post.h" +#endif /* ACE_CONFIG_H */ diff --git a/dep/ACE_wrappers/ace/config-sunos5.5.h b/dep/ACE_wrappers/ace/config-sunos5.5.h new file mode 100644 index 00000000000..3608a28abe2 --- /dev/null +++ b/dep/ACE_wrappers/ace/config-sunos5.5.h @@ -0,0 +1,417 @@ +/* -*- C++ -*- */ +// $Id: config-sunos5.5.h 81971 2008-06-16 12:15:00Z parsons $ + +// This configuration file is designed to work for SunOS 5.5 platforms +// using the following compilers: +// * Sun C++ 4.2 and later (including 5.x), patched as noted below +// * g++ 2.7.2 and later, including egcs +// * Green Hills 1.8.8 and later + +#ifndef ACE_CONFIG_H +#define ACE_CONFIG_H +#include /**/ "ace/pre.h" + +#define ACE_LACKS_STDINT_H + +// alphasort() is present on earlier Solaris versions but is marked as not for +// use on non-BSD systems and not supported for use in applications that use +// system libraries or with multiple threads. So it's mostly useless. +#define ACE_LACKS_ALPHASORT + +// Solaris doesn't support log2() +#define ACE_LACKS_LOG2 + +// SunOS 5.5 does not provide getloadavg() +#define ACE_LACKS_GETLOADAVG + +// Before we do anything, we should include to +// ensure that things are set up properly. +#include + +// Sun has the posix defines so let this file sort out what Sun delivers +#include "ace/config-posix.h" + +// Compiler version-specific settings: +#if defined (__SUNPRO_CC) +# if (__SUNPRO_CC < 0x410) + // The following might not be necessary, but I can't tell: my build + // with Sun C++ 4.0.1 never completes. +# define ACE_NEEDS_DEV_IO_CONVERSION +# elif (__SUNPRO_CC >= 0x420) +# if (__SUNPRO_CC >= 0x500) + // string.h and memory.h conflict for memchr definitions +# define ACE_LACKS_MEMORY_H + // If -compat=4 is turned on, the old 4.2 settings for iostreams are used, + // but the newer, explicit instantiation is used (above) +# if (__SUNPRO_CC_COMPAT >= 5) +# define ACE_HAS_TEMPLATE_TYPEDEFS +# define ACE_HAS_STANDARD_CPP_LIBRARY 1 +# define ACE_USES_STD_NAMESPACE_FOR_STDCPP_LIB 1 +# define ACE_HAS_THR_C_DEST +# endif /* __SUNPRO_CC_COMPAT >= 5 */ +# if defined (ACE_HAS_EXCEPTIONS) +# define ACE_HAS_NEW_NOTHROW +# else + // See /opt/SUNWspro_5.0/SC5.0/include/CC/stdcomp.h: +# define _RWSTD_NO_EXCEPTIONS 1 +# endif /* ! ACE_HAS_EXCEPTIONS */ +# elif (__SUNPRO_CC == 0x420) || (__SUNPRO_CC == 0x410) +# define ACE_LACKS_PLACEMENT_OPERATOR_DELETE +# endif /* __SUNPRO_CC >= 0x500 */ +# endif /* __SUNPRO_CC >= 0x420 */ + +# define ACE_CAST_CONST const +# define ACE_HAS_HI_RES_TIMER +# define ACE_HAS_SIG_C_FUNC /* Sun CC 5.0 needs this, 4.2 doesn't mind. */ +# define ACE_HAS_XPG4_MULTIBYTE_CHAR +# define ACE_LACKS_LINEBUFFERED_STREAMBUF +# define ACE_LACKS_SIGNED_CHAR + + // ACE_HAS_EXCEPTIONS precludes -noex in + // include/makeinclude/platform_macros.GNU. But beware, we have + // seen problems with exception handling on multiprocessor + // UltraSparcs: threaded executables core dump when threads exit. + // This problem does not seem to appear on single-processor UltraSparcs. + // And, it is solved with the application of patch + // 104631-02 "C++ 4.2: Jumbo Patch for C++ 4.2 on Solaris SPARC" + // to Sun C++ 4.2. + // To provide optimum performance, ACE_HAS_EXCEPTIONS is disabled by + // default. It can be enabled by adding "exceptions=1" to the "make" + // invocation. See include/makeinclude/platform_sunos5_sunc++.GNU + // for details. + +# if defined (ACE_HAS_EXCEPTIONS) + // If exceptions are enabled and we are using Sun/CC then + // throws an exception instead of returning 0. +# define ACE_NEW_THROWS_EXCEPTIONS +# endif /* ACE_HAS_EXCEPTIONS */ + + /* If you want to disable threading with Sun CC, remove -mt + from your CFLAGS, e.g., using make threads=0. */ + + +// Take advantage of Sun Studio 8 (Sun C++ 5.5) or better symbol +// visibility to generate improved shared library binaries. +# if (__SUNPRO_CC > 0x540) + +# if defined (ACE_HAS_CUSTOM_EXPORT_MACROS) && ACE_HAS_CUSTOM_EXPORT_MACROS == 0 +# undef ACE_HAS_CUSTOM_EXPORT_MACROS +# else +# ifndef ACE_HAS_CUSTOM_EXPORT_MACROS +# define ACE_HAS_CUSTOM_EXPORT_MACROS +# endif /* !ACE_HAS_CUSTOM_EXPORT_MACROS */ +# define ACE_Proper_Export_Flag __symbolic +# define ACE_Proper_Import_Flag __global + +# define ACE_EXPORT_SINGLETON_DECLARATION(T) template class ACE_Proper_Export_Flag T +# define ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) template class ACE_Proper_Export_Flag SINGLETON_TYPE ; + +// # define ACE_IMPORT_SINGLETON_DECLARATION(T) extern template class T +// # define ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) extern template class SINGLETON_TYPE; + +# endif /* ACE_HAS_CUSTOM_EXPORT_MACROS == 0 */ +# endif /* __SUNPRO_CC > 0x540 (> Sun C++ 5.4) */ + +#elif defined (__GNUG__) + // config-g++-common.h undef's ACE_HAS_STRING_CLASS with -frepo, so + // this must appear before its #include. +# define ACE_HAS_STRING_CLASS +# include "ace/config-g++-common.h" +# define ACE_HAS_HI_RES_TIMER + // Denotes that GNU has cstring.h as standard, to redefine memchr(). +# define ACE_HAS_GNU_CSTRING_H +# define ACE_HAS_XPG4_MULTIBYTE_CHAR + +# if !defined (ACE_MT_SAFE) || ACE_MT_SAFE != 0 + // ACE_MT_SAFE is #defined below, for all compilers. +# if !defined (_REENTRANT) + /* If you want to disable threading, comment out the following + line. Or, add -DACE_MT_SAFE=0 to your CFLAGS, e.g., using + make threads=0. */ +# define _REENTRANT +# endif /* _REENTRANT */ +# endif /* !ACE_MT_SAFE */ + +#elif defined (ghs) + +# if !defined (ACE_MT_SAFE) || ACE_MT_SAFE != 0 + // ACE_MT_SAFE is #defined below, for all compilers. +# if !defined (_REENTRANT) + /* If you want to disable threading, comment out the following + line. Or, add -DACE_MT_SAFE=0 to your CFLAGS, e.g., using + make threads=0. */ +# define _REENTRANT +# endif /* _REENTRANT */ +# endif /* !ACE_MT_SAFE */ + +# define ACE_CONFIG_INCLUDE_GHS_COMMON +# include "ace/config-ghs-common.h" + + // To avoid warning about inconsistent declaration between Sun's + // stdlib.h and Green Hills' ctype.h. +# include + + // IOStream_Test never halts with Green Hills 1.8.9. +# define ACE_LACKS_ACE_IOSTREAM + +#else /* ! __SUNPRO_CC && ! __GNUG__ && ! ghs */ +# ifdef __cplusplus /* Let it slide for C compilers. */ +# error unsupported compiler in ace/config-sunos5.5.h +# endif /* __cplusplus */ +#endif /* ! __SUNPRO_CC && ! __GNUG__ && ! ghs */ + +#if !defined (__ACE_INLINE__) +// @note If you have link problems with undefined inline template +// functions with Sun C++, be sure that the #define of __ACE_INLINE__ +// below is not commented out. +# define __ACE_INLINE__ +#endif /* ! __ACE_INLINE__ */ + +// Platform supports the POSIX regular expression library. +// @note Please comment out the ACE_HAS_REGEX #define if you +// have link problems with g++ or egcs on SunOS 5.5. +#define ACE_HAS_REGEX + +// Optimize ACE_Handle_Set for select(). +#define ACE_HAS_HANDLE_SET_OPTIMIZED_FOR_SELECT + +// select()'s timeval arg is not declared as const and may be modified +#define ACE_HAS_NONCONST_SELECT_TIMEVAL + +// Platform supports pread() and pwrite() +#define ACE_HAS_P_READ_WRITE +#define ACE_HAS_RECURSIVE_THR_EXIT_SEMANTICS +#define ACE_HAS_UALARM +#define ACE_LACKS_UALARM_PROTOTYPE + +// Platform supports System V IPC (most versions of UNIX, but not Win32) +#define ACE_HAS_SYSV_IPC + +#define ACE_HAS_CONSISTENT_SIGNAL_PROTOTYPES + +// Platform supports system configuration information. +#define ACE_HAS_SYS_SYSTEMINFO_H +#define ACE_HAS_SYSINFO + +// Platform supports recvmsg and sendmsg. +#define ACE_HAS_MSG + +// Compiler/platform contains the file. +#define ACE_HAS_SYS_SYSCALL_H + +// Platform has POSIX terminal interface. +#define ACE_HAS_TERMIOS + +// Compiler/platform correctly calls init()/fini() for shared libraries. +#define ACE_HAS_AUTOMATIC_INIT_FINI + +// Platform supports POSIX O_NONBLOCK semantics. +#define ACE_HAS_POSIX_NONBLOCK + +// Compiler/platform has correctly prototyped header files. +#define ACE_HAS_CPLUSPLUS_HEADERS + +// Platform supports IP multicast +#define ACE_HAS_IP_MULTICAST + +// This setting was determined by running the autoconf tests. If it doesn't +// work uniformly, will need some tweaking, possibly based on other +// XPG feature-test macros. +#define ACE_HAS_CONST_CHAR_SWAB + +// Compiler/platform supports alloca() +// Although ACE does have alloca() on this compiler/platform combination, it is +// disabled by default since it can be dangerous. Uncomment the following line +// if you ACE to use it. +//#define ACE_HAS_ALLOCA + +// Compiler/platform has +#define ACE_HAS_ALLOCA_H + +// Platform contains . +#define ACE_HAS_POLL + +// Platform supports POSIX timers via timestruc_t. +#define ACE_HAS_POSIX_TIME + +// ACE_HAS_CLOCK_GETTIME requires linking with -lposix4. +#define ACE_HAS_CLOCK_GETTIME +#define ACE_HAS_CLOCK_SETTIME + +// Platform supports the /proc file system. +#define ACE_HAS_PROC_FS + +// Platform supports the prusage_t struct. +#define ACE_HAS_PRUSAGE_T +#define ACE_HAS_GETRUSAGE + +// Compiler/platform defines the sig_atomic_t typedef. +#define ACE_HAS_SIG_ATOMIC_T + +// Platform supports SVR4 extended signals. +#define ACE_HAS_SIGINFO_T +#define ACE_HAS_UCONTEXT_T + +// Compiler/platform provides the sockio.h file. +#define ACE_HAS_SYS_SOCKIO_H + +// Compiler supports the ssize_t typedef. +#define ACE_HAS_SSIZE_T + +// Platform supports STREAMS. +#define ACE_HAS_STREAMS + +// Platform supports STREAM pipes. +#define ACE_HAS_STREAM_PIPES + +// Compiler/platform supports strerror (). +#define ACE_HAS_STRERROR + +// Compiler/platform supports struct strbuf. +#define ACE_HAS_STRBUF_T + +// Compiler/platform supports SVR4 dynamic linking semantics. +#define ACE_HAS_SVR4_DYNAMIC_LINKING + +// Compiler/platform supports SVR4 gettimeofday() prototype. +#define ACE_HAS_SVR4_GETTIMEOFDAY + +// Compiler/platform supports SVR4 ACE_TLI (in particular, T_GETNAME stuff)... +#define ACE_HAS_SVR4_TLI + +// Platform provides header. +#define ACE_HAS_SYS_FILIO_H + +// Compiler/platform supports sys_siglist array. +#define ACE_HAS_SYS_SIGLIST + +// SunOS 5.5.x does not support mkstemp +#define ACE_LACKS_MKSTEMP +#define ACE_LACKS_SYS_SYSCTL_H + +#if !(defined(_XOPEN_SOURCE) && (_XOPEN_VERSION - 0 >= 4)) +# define ACE_HAS_CHARPTR_SHMDT +#endif + +// Platform has posix getpwnam_r +#if (defined (_POSIX_C_SOURCE) && _POSIX_C_SOURCE - 0 >= 199506L) || \ + defined(_POSIX_PTHREAD_SEMANTICS) +# define ACE_HAS_POSIX_GETPWNAM_R +#endif /* _POSIX_C_SOURCE || _POSIX_PTHREAD_SEMANTICS */ + +#if !defined (ACE_MT_SAFE) || (ACE_MT_SAFE == 1) +#if defined (_REENTRANT) || \ + (defined (_POSIX_C_SOURCE) && (_POSIX_C_SOURCE - 0 >= 199506L)) || \ + defined (_POSIX_PTHREAD_SEMANTICS) + // Compile using multi-thread libraries. +# define ACE_HAS_THREADS + +# if !defined (ACE_MT_SAFE) +# define ACE_MT_SAFE 1 +# endif /* ACE_MT_SAFE */ + + // Platform supports POSIX pthreads *and* Solaris threads, by + // default! If you only want to use POSIX pthreads, add + // -D_POSIX_PTHREAD_SEMANTICS to your CFLAGS. Or, #define it right + // here. See the Intro (3) man page for information on + // -D_POSIX_PTHREAD_SEMANTICS. +# if defined (_POSIX_PTHREAD_SEMANTICS) +# define ACE_LACKS_RWLOCK_T +# else +# define ACE_HAS_STHREADS +# endif /* ! _POSIX_PTHREAD_SEMANTICS */ + +# define ACE_HAS_PTHREADS + // . . . but only supports SCHED_OTHER scheduling policy +# define ACE_HAS_ONLY_SCHED_OTHER +# define ACE_HAS_SIGWAIT +# define ACE_HAS_SIGTIMEDWAIT +# define ACE_HAS_SIGSUSPEND +# define ACE_LACKS_PTHREAD_ATTR_SETSTACK + + // Compiler/platform has thread-specific storage +# define ACE_HAS_THREAD_SPECIFIC_STORAGE + + // Platform supports reentrant functions (i.e., all the POSIX *_r functions). +# define ACE_HAS_REENTRANT_FUNCTIONS + +# define ACE_NEEDS_LWP_PRIO_SET +# define ACE_HAS_THR_YIELD +# define ACE_LACKS_PTHREAD_YIELD +#endif /* _REENTRANT || _POSIX_C_SOURCE >= 199506L || \ + _POSIX_PTHREAD_SEMANTICS */ +#endif /* !ACE_MT_SAFE || ACE_MT_SAFE == 1 */ + +#define ACE_HAS_PRIOCNTL + +// Platform supports ACE_TLI timod STREAMS module. +#define ACE_HAS_TIMOD_H + +// Platform supports ACE_TLI tiuser header. +#define ACE_HAS_TIUSER_H + +// Platform provides ACE_TLI function prototypes. +#define ACE_HAS_TLI_PROTOTYPES + +// Platform has broken t_error() prototype. +#define ACE_HAS_BROKEN_T_ERROR + +// Platform supports ACE_TLI. +#define ACE_HAS_TLI + +#define ACE_HAS_GETPAGESIZE 1 + +#define ACE_HAS_STL_MAP_CONFLICT + +#define ACE_HAS_IDTYPE_T + +#define ACE_HAS_GPERF +#define ACE_HAS_DIRENT + +#if defined (__SUNPRO_CC) +# define ACE_CC_NAME ACE_TEXT ("SunPro C++") +# define ACE_CC_MAJOR_VERSION (__SUNPRO_CC >> 8) +# define ACE_CC_MINOR_VERSION (__SUNPRO_CC & 0x00ff) +# define ACE_CC_BETA_VERSION (0) +#elif defined (__GNUG__) +# define ACE_CC_MAJOR_VERSION __GNUC__ +# define ACE_CC_MINOR_VERSION __GNUC_MINOR__ +# define ACE_CC_BETA_VERSION (0) +# if __GNUC_MINOR__ >= 90 +# define ACE_CC_NAME ACE_TEXT ("egcs") +# else +# define ACE_CC_NAME ACE_TEXT ("g++") +# endif /* __GNUC_MINOR__ */ +#endif /* __GNUG__ */ + +#if defined (i386) && (_FILE_OFFSET_BITS==32) +# define ACE_HAS_X86_STAT_MACROS +#endif /* i386 && _FILE_OFFSET_BITS==32 */ + +#define ACE_MALLOC_ALIGN ((size_t)8) +#define ACE_LACKS_SETREUID_PROTOTYPE +#define ACE_LACKS_SETREGID_PROTOTYPE + +// Solaris does indeed implement the inet_aton() function, but it is +// found in `libresolv.*'. It doesn't seem worth it to link another +// library just for that function. Just use the emulation in ACE that +// has been used for years. +#define ACE_LACKS_INET_ATON + +// Solaris doesn't have wcstoull +#define ACE_LACKS_WCSTOULL + +#if defined (_LARGEFILE_SOURCE) || (_FILE_OFFSET_BITS==64) +#undef ACE_HAS_PROC_FS +#undef ACE_HAS_PRUSAGE_T +#endif /* (_LARGEFILE_SOURCE) || (_FILE_OFFSET_BITS==64) */ + +#if defined (_POSIX_PTHREAD_SEMANTICS) || (_FILE_OFFSET_BITS == 64) || (_POSIX_C_SOURCE - 0 >= 199506L) +# define ACE_HAS_3_PARAM_READDIR_R +#endif + +// Sum of the iov_len values can't be larger then SSIZE_MAX +#define ACE_HAS_SOCK_BUF_SIZE_MAX + +#include /**/ "ace/post.h" +#endif /* ACE_CONFIG_H */ diff --git a/dep/ACE_wrappers/ace/config-sunos5.6.h b/dep/ACE_wrappers/ace/config-sunos5.6.h new file mode 100644 index 00000000000..d100627a212 --- /dev/null +++ b/dep/ACE_wrappers/ace/config-sunos5.6.h @@ -0,0 +1,126 @@ +/* -*- C++ -*- */ +// $Id: config-sunos5.6.h 81935 2008-06-12 22:01:53Z jtc $ + +// The following configuration file is designed to work for SunOS 5.6 +// platforms using the SunC++ 4.x or g++ compilers. + +#ifndef ACE_CONFIG_H + +// ACE_CONFIG_H is defined by one of the following #included headers. + +// #include the SunOS 5.5 config file, then add SunOS 5.6 updates below. + +#include "ace/config-sunos5.5.h" + +#if (defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE > 2) || \ + defined (__EXTENSIONS__) +// The asctime_r/ctime_r parameters change at POSIX.1c-1995 +# if (defined (_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 199506L) +# define ACE_HAS_2_PARAM_ASCTIME_R_AND_CTIME_R +# endif /* POSIX_C_SOURCE >= 199506L */ +# define ACE_HAS_SIGWAIT +// Hack 'cuz _POSIX_C_SOURCE > 2 and -DEXTENSIONS hides this. +# define ACE_LACKS_MADVISE_PROTOTYPE +#endif /* _POSIX_C_SOURCE > 2 || __EXTENSIONS__ */ + +// Support for the SunC++ 5.2 compiler. +// Do not undefine for compat mode < 5 +#if defined (__SUNPRO_CC) && __SUNPRO_CC > 0x510 +#if defined (__SUNPRO_CC_COMPAT) && (__SUNPRO_CC_COMPAT >= 5) +#ifdef ACE_LACKS_ACE_IOSTREAM +#undef ACE_LACKS_ACE_IOSTREAM +#endif /* ACE_LACKS_ACE_IOSTREAM */ +#endif /* defined (__SUNPRO_CC_COMPAT) && (__SUNPRO_CC_COMPAT >= 5) */ + +#ifndef ACE_LACKS_UNBUFFERED_STREAMBUF +#define ACE_LACKS_UNBUFFERED_STREAMBUF 1 +#endif /* ACE_LACKS_UNBUFFERED_STREAMBUF */ +#ifndef ACE_TEMPLATES_REQUIRE_SOURCE +#define ACE_TEMPLATES_REQUIRE_SOURCE 1 +#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ +#ifndef ACE_HAS_TEMPLATE_TYPEDEFS +#define ACE_HAS_TEMPLATE_TYPEDEFS 1 +#endif /* ACE_HAS_TEMPLATE_TYPEDEFS */ +// Forte 7 seems to botch this one... +#if __SUNPRO_CC == 0x540 +#undef ACE_HAS_TEMPLATE_TYPEDEFS +#endif +#ifndef ACE_HAS_THR_C_DEST +#define ACE_HAS_THR_C_DEST 1 +#endif /* ACE_HAS_THR_C_DEST */ +#ifndef ACE_HAS_THR_C_FUNC +#define ACE_HAS_THR_C_FUNC 1 +#endif /* ACE_HAS_THR_C_FUNC */ +#ifndef ACE_HAS_CONSISTENT_SIGNAL_PROTOTYPES +#define ACE_HAS_CONSISTENT_SIGNAL_PROTOTYPES 1 +#endif /* ACE_HAS_CONSISTENT_SIGNAL_PROTOTYPES */ +#ifndef ACE_HAS_SIG_C_FUNC +#define ACE_HAS_SIG_C_FUNC 1 +#endif /* ACE_HAS_SIG_C_FUNC */ +#ifndef ACE_HAS_STDCPP_STL_INCLUDES +#define ACE_HAS_STDCPP_STL_INCLUDES 1 +#endif /* ACE_HAS_STDCPP_STL_INCLUDES */ +#ifndef ACE_HAS_STRING_CLASS +#define ACE_HAS_STRING_CLASS 1 +#endif /* ACE_HAS_STRING_CLASS */ +#ifndef ACE_HAS_STANDARD_CPP_LIBRARY +#define ACE_HAS_STANDARD_CPP_LIBRARY 1 +#endif /* ACE_HAS_STANDARD_CPP_LIBRARY */ +#ifndef ACE_HAS_STDCPP_STL_INCLUDES +#define ACE_HAS_STDCPP_STL_INCLUDES 1 +#endif /* ACE_HAS_STDCPP_STL_INCLUDES */ +#ifndef ACE_USES_STD_NAMESPACE_FOR_STDCPP_LIB +#define ACE_USES_STD_NAMESPACE_FOR_STDCPP_LIB 1 +#endif /* ACE_USES_STD_NAMESPACE_FOR_STDCPP_LIB */ +#ifndef ACE_LACKS_IOSTREAM_FX +#define ACE_LACKS_IOSTREAM_FX 1 +#endif /* ACE_LACKS_IOSTREAM_FX */ +#ifndef ACE_LACKS_LINEBUFFERED_STREAMBUF +#define ACE_LACKS_LINEBUFFERED_STREAMBUF 1 +#endif /* ACE_LACKS_LINEBUFFERED_STREAMBUF */ + +#endif /* defined (__SUNPRO_CC) && __SUNPRO_CC > 0x510 */ + +// SunOS 5.6 and above support mkstemp +#undef ACE_LACKS_MKSTEMP + + +// SunOS 5.6 has AIO calls. +#if !defined (ACE_HAS_AIO_CALLS) +#define ACE_HAS_AIO_CALLS +#endif /* ACE_HAS_AIO_CALLS */ + +#if !defined (ACE_HAS_POSIX_REALTIME_SIGNALS) +#define ACE_HAS_POSIX_REALTIME_SIGNALS +#endif /* ACE_HAS_POSIX_REALTIME_SIGNALS */ + +#if !defined (ACE_HAS_POSIX_MESSAGE_PASSING) +#define ACE_HAS_POSIX_MESSAGE_PASSING +#endif /* ACE_HAS_POSIX_MESSAGE_PASSING */ + +#if !defined (ACE_HAS_POSIX_SEM) +#define ACE_HAS_POSIX_SEM +#endif /* ACE_HAS_POSIX_SEM */ + +// Sunos 5.6's aio_* with RT signals is broken. +#if !defined (ACE_POSIX_AIOCB_PROACTOR) +#define ACE_POSIX_AIOCB_PROACTOR +#endif /* ACE_POSIX_AIOCB_PROACTOR */ + +// SunOS 5.6 has a buggy select +#define ACE_HAS_LIMITED_SELECT + +// SunOS 5.6 introduced shm_open, but need to turn on POSIX.1b or higher +// to pick it up. +#if defined (_POSIX_C_SOURCE) && (_POSIX_C_SOURCE > 2) +# define ACE_HAS_SHM_OPEN +#else +# undef ACE_HAS_SHM_OPEN +#endif /* _POSIX_C_SOURCE > 2 */ + +// The struct msghdr is conditional on SunOS 5.6 based on _XPG4_2 +#if defined(_XPG4_2) +# define ACE_HAS_4_4BSD_SENDMSG_RECVMSG +#endif /* _XPG4_2 */ + +#endif /* ACE_CONFIG_H */ diff --git a/dep/ACE_wrappers/ace/config-sunos5.7.h b/dep/ACE_wrappers/ace/config-sunos5.7.h new file mode 100644 index 00000000000..60e1d993a13 --- /dev/null +++ b/dep/ACE_wrappers/ace/config-sunos5.7.h @@ -0,0 +1,78 @@ +/* -*- C++ -*- */ +// $Id: config-sunos5.7.h 80826 2008-03-04 14:51:23Z wotte $ + +// The following configuration file is designed to work for SunOS 5.7 +// (Solaris 7) platforms using the SunC++ 4.x, 5.x, or g++ compilers. + +#ifndef ACE_CONFIG_H + +// ACE_CONFIG_H is defined by one of the following #included headers. + +// #include the SunOS 5.6 config file, then add SunOS 5.7 updates below. + +#include "ace/config-sunos5.6.h" + +// This may be true for earlier Solaris versions, but I can only verify +// it for Solaris 7 and later. +#define ACE_HAS_VFWPRINTF +#if defined (ACE_HAS_SHM_OPEN) +# define ACE_SHM_OPEN_REQUIRES_ONE_SLASH +#endif + +// Sun began distributing with SunOS 5.7 +#define ACE_HAS_SYS_LOADAVG_H + +// SunOS 5.7 has getloadavg() +#undef ACE_LACKS_GETLOADAVG + +#if defined (ghs) + // SunOS 5.7's /usr/include/sys/procfs_isa.h needs uint64_t, + // but /usr/include/sys/int_types.h doesn't #define it because + // _NO_LONGLONG is # +# undef ACE_HAS_PROC_FS +# undef ACE_HAS_PRUSAGE_T + +#elif defined (__SUNPRO_CC) && (__SUNPRO_CC <= 0x530) + // Wide character methods are in std:: when using SunCC 5.3 +# define ACE_WCHAR_IN_STD_NAMESPACE +#endif /* __GNUG__ || ghs */ + +// SunOS 5.7 supports SCHED_FIFO and SCHED_RR, as well as SCHED_OTHER. +#undef ACE_HAS_ONLY_SCHED_OTHER + +// SunOS 5.7 gets this right . . . +#undef ACE_HAS_BROKEN_T_ERROR + +// And doesn't need to set LWP priorities, as shown by +// performance-tests/Misc/preempt. +#undef ACE_NEEDS_LWP_PRIO_SET + +// SunOS 5.7 can support Real-Time Signals and POSIX4 AIO operations +// are supported. + +#if !defined (ACE_HAS_AIO_CALLS) +#define ACE_HAS_AIO_CALLS +#endif /* !ACE_HAS_AIO_CALLS */ + +#ifdef ACE_HAS_LIMITED_SELECT +#undef ACE_HAS_LIMITED_SELECT +#endif /* ACE_HAS_LIMITED_SELECT */ + +// SunOS 5.7 has socklen_t +#define ACE_HAS_SOCKLEN_T + +#if defined (__sparcv9) +#define _LP64 +#define ACE_SIZEOF_LONG 8 /* Needed to circumvent compiler bug #4294969 */ +#endif /* __sparcv9 */ + +#if (defined(_XOPEN_SOURCE) && (_XOPEN_VERSION - 0 == 4)) /* XPG4 or XPG4v2 */ +// 2 parameter wcstok() +#else /* XPG4 or XPG4v2 */ +# define ACE_HAS_3_PARAM_WCSTOK +#endif + +// Solaris 7 started to support /dev/poll +#define ACE_HAS_DEV_POLL + +#endif /* ACE_CONFIG_H */ diff --git a/dep/ACE_wrappers/ace/config-sunos5.8.h b/dep/ACE_wrappers/ace/config-sunos5.8.h new file mode 100644 index 00000000000..eb83e91490b --- /dev/null +++ b/dep/ACE_wrappers/ace/config-sunos5.8.h @@ -0,0 +1,39 @@ +/* -*- C++ -*- */ +// $Id: config-sunos5.8.h 80826 2008-03-04 14:51:23Z wotte $ + +// The following configuration file is designed to work for SunOS 5.8 +// (Solaris 8) platforms using the SunC++ 4.x, 5.x, 6.x, or g++ compilers. + +#ifndef ACE_CONFIG_H + +// ACE_CONFIG_H is defined by one of the following #included headers. + +// #include the SunOS 5.7 config, then add any SunOS 5.8 updates below. +#include "ace/config-sunos5.7.h" + +#undef ACE_WCHAR_IN_STD_NAMESPACE + +// This may be true for versions prior to Solaris 8 as well, but I don't +// have any to try it on. +#if !defined (ACE_HAS_TIMEZONE) +# define ACE_HAS_TIMEZONE +#endif + +// The range of thread priorities for 5.8 differs from 5.7 in the +// minimum priority for the SCHED_OTHER policy (i.e., +// ACE_THR_PRI_OTHER_MIN) +# define ACE_THR_PRI_OTHER_MIN (long) -20 + +# if defined (_POSIX_PTHREAD_SEMANTICS) +# ifdef ACE_LACKS_RWLOCK_T +# undef ACE_LACKS_RWLOCK_T +# endif /* ACE_LACKS_RWLOCK_T */ +# endif /* _POSIX_PTHREAD_SEMANTICS */ + +// This is no longer the case for Sun 5.9 onwards +# undef ACE_HAS_X86_STAT_MACROS + +// gethostbyaddr does not handle IPv6-mapped-IPv4 addresses +#define ACE_HAS_BROKEN_GETHOSTBYADDR_V4MAPPED + +#endif /* ACE_CONFIG_H */ diff --git a/dep/ACE_wrappers/ace/config-sunos5.9.h b/dep/ACE_wrappers/ace/config-sunos5.9.h new file mode 100644 index 00000000000..0e6aa8d5b9c --- /dev/null +++ b/dep/ACE_wrappers/ace/config-sunos5.9.h @@ -0,0 +1,18 @@ +/* -*- C++ -*- */ +// $Id: config-sunos5.9.h 80826 2008-03-04 14:51:23Z wotte $ + +// The following configuration file is designed to work for SunOS 5.9 +// (Solaris 9) platforms using the SunC++ 5.x (Forte 6 and 7), or g++ +// compilers. + +#ifndef ACE_CONFIG_H + +// ACE_CONFIG_H is defined by one of the following #included headers. + +// #include the SunOS 5.8 config, then add any SunOS 5.9 updates below. +#include "ace/config-sunos5.8.h" + +#define ACE_HAS_SENDFILE +#define ACE_LACKS_THR_CONCURRENCY_FUNCS + +#endif /* ACE_CONFIG_H */ diff --git a/dep/ACE_wrappers/ace/config-tandem-nsk-mips-v2.h b/dep/ACE_wrappers/ace/config-tandem-nsk-mips-v2.h new file mode 100644 index 00000000000..20d555321a8 --- /dev/null +++ b/dep/ACE_wrappers/ace/config-tandem-nsk-mips-v2.h @@ -0,0 +1,401 @@ +// -*- C++ -*- +// +// $Id: config-tandem-nsk-mips-v2.h 81935 2008-06-12 22:01:53Z jtc $ + +#ifndef ACE_CONFIG_NSK_H +#define ACE_CONFIG_NSK_H + +#include /**/ "ace/pre.h" + +// The following configuration file contains defines for Tandem NSK +// platform, MIPS processor, version 2 C++ compiler. + + +//========================================================================= +// Tandem NSK specific parts +//========================================================================= + + +// Disable pthread renaming of symbols such as "open" and "close" +#define _CMA_NOWRAPPERS_ 1 + +// Get Handle_Set.cpp to generate correct bit operations for NSK platform +#define ACE_TANDEM_NSK_BIT_ORDER + +// Use facilities provided by T1248 version of pthreads. +// (If not defined, will use old version of pthreads.) +#define ACE_TANDEM_T1248_PTHREADS + +// Use all available T1248 thread aware wrapper functions for providing +// non-blocking I/O. +// [@note this causes a significant performance degradation] +//#define ACE_TANDEM_T1248_PTHREADS_ALL_IO_WRAPPERS + + +// Need this include here because some symbols defined by pthreads +// (e.g. timespec_t) are needed before spthread.h is normally included +// by ACE +#ifdef ACE_TANDEM_T1248_PTHREADS +#include +#else +#include "pthread.h" +#include "dce/cma_dispatch_coop.h" +#endif + +// The following #defines are hacks to get around things +// that seem to be missing or different in Tandem land +#define NSIG 32 // missing from Signal.h + // note: on nsk TNS/R there is room in + // sigset_t for 128 signals but those + // above 31 are not valid. +typedef long fd_mask; // should be in select.h but no such file +#define NBBY 8 // must be consistent with value in sys/types.h +#define NFDBITS (sizeof (fd_mask) * NBBY) /* bits per mask */ +#define MAXNAMLEN 248 // missing from dirent.h +#define ERRMAX 4218 // from errno.h + +// Following seems to be missing from G06.20 version of standard +// pthreads includes (it appeared in older version of standard pthreads) +// (SCHED_FIFO (aka cma_c_sched_fifo) used in Dynamic_Priority_Test) +#ifdef ACE_TANDEM_T1248_PTHREADS +typedef enum CMA_T_SCHED_POLICY { + cma_c_sched_fifo = 0, + cma_c_sched_rr = 1, + cma_c_sched_throughput = 2, + cma_c_sched_background = 3, + cma_c_sched_ada_low = 4 + } cma_t_sched_policy; +#endif + +// T1248 doesn't define these constants. They're defined in spt/cma.h +// (formerly dce/cma.h), but this header is not included or provided +// by T1248 G07-AAL. +#define cma_c_prio_fifo_min 16 +#define cma_c_prio_fifo_mid 24 +#define cma_c_prio_fifo_max 31 +#define cma_c_prio_rr_min 16 +#define cma_c_prio_rr_mid 24 +#define cma_c_prio_rr_max 31 +#define cma_c_prio_through_min 8 +#define cma_c_prio_through_mid 12 +#define cma_c_prio_through_max 15 +#define cma_c_prio_back_min 1 +#define cma_c_prio_back_mid 4 +#define cma_c_prio_back_max 7 + +// Enable NSK Pluggable Protocols +#define TAO_HAS_NSKPW 1 +#define TAO_HAS_NSKFS 1 + +//========================================================================= +// Platform specific parts +//========================================================================= + +// Platform lacks getpwnam_r() methods (e.g., SGI 6.2). +#define ACE_LACKS_PWD_REENTRANT_FUNCTIONS + +// Platform/compiler lacks {get,set}rlimit() function +#define ACE_LACKS_RLIMIT + +// The platform doesn't have mmap(2) +#define ACE_LACKS_MMAP + +// Platform lacks streambuf "linebuffered ()". [C++ iostream] +#define ACE_LACKS_LINEBUFFERED_STREAMBUF + +// Platform supports recvmsg and sendmsg +#define ACE_HAS_MSG + +// Platform defines ACE_HAS_MSG, but lacks msg_accrights{,len}. +#define ACE_LACKS_MSG_ACCRIGHTS + +// Platform supports sigsuspend() +#define ACE_HAS_SIGSUSPEND + +// Platform/compiler has the sigwait(2) prototype +#define ACE_HAS_SIGWAIT + +// Compiler/platform defines the sig_atomic_t typedef +#define ACE_HAS_SIG_ATOMIC_T + +// OS/compiler uses size_t * rather than int * for socket lengths +#define ACE_HAS_SIZET_SOCKET_LEN + +// OS/compiler uses void * arg 4 setsockopt() rather than const char * +#define ACE_HAS_VOIDPTR_SOCKOPT + +// The platform doesn't have mprotect(2) +#define ACE_LACKS_MPROTECT + +// Platform lacks msync() +#define ACE_LACKS_MSYNC + +// Platform does not support reentrant netdb functions (getprotobyname_r, +// getprotobynumber_r, gethostbyaddr_r, gethostbyname_r, getservbyname_r). +#define ACE_LACKS_NETDB_REENTRANT_FUNCTIONS Platform does not support + +// Platform lacks madvise() +#define ACE_LACKS_MADVISE + +// Platform lacks pri_t +#define ACE_LACKS_PRI_T + +// Platform lacks a working sbrk() +#define ACE_LACKS_SBRK + +// Platform doesn't have syscall() prototype +#define ACE_LACKS_SYSCALL + +// Platform lacks the inet_aton() function. +#define ACE_LACKS_INET_ATON + +// Compiler/platform has Dirent iterator functions +#define ACE_HAS_DIRENT + +// Platform uses ACE_HAS_DIRENT but does not have readdir_r() +#define ACE_LACKS_READDIR_R + +// Platform supports getpagesize() call (otherwise, +// ACE_PAGE_SIZE must be defined) +#define ACE_HAS_GETPAGESIZE + +// Platform supports IP multicast +#define ACE_HAS_IP_MULTICAST + +// Platform's select() uses non-const timeval* +#define ACE_HAS_NONCONST_SELECT_TIMEVAL + +// Platform supports POSIX O_NONBLOCK semantics +#define ACE_HAS_POSIX_NONBLOCK + +// Platform lacks named POSIX semaphores +#define ACE_LACKS_NAMED_POSIX_SEM + +// Platform has support for multi-byte character support compliant +// with the XPG4 Worldwide Portability Interface wide-character +// classification. +#define ACE_HAS_XPG4_MULTIBYTE_CHAR + +// No wcsstr function available for this compiler +#define ACE_LACKS_WCSSTR + +// No wctype.h available for this compiler +#define ACE_LACKS_WCTYPE_H + +// Platform supports the POSIX regular expression library. +// [Note Tandem NSK platform does have regular expresson support but it +// does not follow the assumptions made by ACE. To use it would need +// to make some ACE modifications.] +//#define ACE_HAS_REGEX + +// Compiler/platform supports strerror () +#define ACE_HAS_STRERROR + +// Platform doesn't have truncate() +#define ACE_LACKS_TRUNCATE + +// Platform lacks readers/writer locks. +#define ACE_LACKS_RWLOCK_T + +// Compiler's 'new' throws exception on failure (ANSI C++ behavior). +#define ACE_NEW_THROWS_EXCEPTIONS + +// Optimize ACE_Handle_Set::count_bits for select() operations (common +// case) +#define ACE_HAS_HANDLE_SET_OPTIMIZED_FOR_SELECT + +// Platform lacks setreuid() +#define ACE_LACKS_SETREUID + +// Platform lacks setregid() +#define ACE_LACKS_SETREGID + +// Compile using multi-thread libraries +#define ACE_MT_SAFE 1 + + + +// Platform supports System V IPC +#define ACE_HAS_SYSV_IPC + +// Platform lacks the socketpair() call +// [Needed due to failure of Pipe_Test. even though nsk platform +// has socketpair(), Pipe.cpp tries to set socket buf size but this +// is not allowed for AF_UNIX protocol on nsk.] +#define ACE_LACKS_SOCKET_BUFSIZ + +// Platform lacks the socketpair() call +#define ACE_LACKS_SOCKETPAIR + +// Platform limits the maximum socket message size. +#define ACE_HAS_SOCK_BUF_SIZE_MAX + +// hrtime_t is a basic type that doesn't require ACE_U64_TO_U32 conversion +#define ACE_HRTIME_T_IS_BASIC_TYPE + +// printf format specifiers for 64 bit integers +# define ACE_UINT64_FORMAT_SPECIFIER ACE_TEXT ("%Ld") +# define ACE_INT64_FORMAT_SPECIFIER ACE_TEXT ("%Ld") + +//========================================================================= +// Threads specific parts +//========================================================================= + +// Platform supports threads +#define ACE_HAS_THREADS + +// Platform supports POSIX Pthreads, of one form or another. This +// macro says the platform has a pthreads variety - should also define +// one of the below to say which one. Also may need some +// ACE_HAS_... thing for extensions. +#define ACE_HAS_PTHREADS + +// Standard pthreads supports only SCHED_FIFO +#define ACE_HAS_ONLY_SCHED_FIFO + +// Compiler/platform has thread-specific storage +#define ACE_HAS_THREAD_SPECIFIC_STORAGE + +// Platform has no implementation of pthread_condattr_setpshared(), +// even though it supports pthreads! +#define ACE_LACKS_CONDATTR_PSHARED + +// pthread_cond_timedwait does *not* reset the time argument when the +// lock is acquired. +#define ACE_LACKS_COND_TIMEDWAIT_RESET + +// Platform lacks pthread_attr_setsched() +#define ACE_LACKS_SETSCHED + +// Platform has pthread_mutexattr_setkind_np(). +#define ACE_HAS_PTHREAD_MUTEXATTR_SETKIND_NP + +// Platform lacks pthread_mutexattr_setpshared(). +#define ACE_LACKS_MUTEXATTR_PSHARED + +// Platform lacks pthread_attr_setscope() +#define ACE_LACKS_THREAD_PROCESS_SCOPING + +// Platform lacks pthread_attr_setstackaddr +#define ACE_LACKS_PTHREAD_ATTR_SETSTACKADDR + +// Defining ACE_HAS_UCONTEXT_T since G06.21 version of spthreads has +// a definition for it. +#ifdef ACE_TANDEM_T1248_PTHREADS +#define ACE_HAS_UCONTEXT_T +#endif + +//========================================================================= +// Include file characteristics +//========================================================================= + +// Compiler/platform contains the file. +#define ACE_HAS_SYS_SYSCALL_H + +// Platform lacks malloc.h +#define ACE_LACKS_MALLOC_H + +// Platform lacks the siginfo.h include file +#define ACE_LACKS_SIGINFO_H + +// Platform doesn't define struct strrecvfd. +#define ACE_LACKS_STRRECVFD + +// Platform lacks the ucontext.h file +#define ACE_LACKS_UCONTEXT_H + +// Prototypes for both signal() and struct sigaction are consistent. +#define ACE_HAS_CONSISTENT_SIGNAL_PROTOTYPES + +// Platform supports the POSIX struct timespec type +#define ACE_HAS_POSIX_TIME + +// Platform/compiler supports timezone * as second parameter to gettimeofday() +#define ACE_HAS_TIMEZONE_GETTIMEOFDAY + +// Platform has (which contains bzero() prototype) +#define ACE_HAS_STRINGS 1 + + +// OS/compiler omits the const from the iovec parameter in the +// writev() prototype. +#define ACE_HAS_NONCONST_WRITEV + +// Platform lacks +#define ACE_LACKS_STDINT_H + +// Platform lacks +#define ACE_LACKS_INTTYPES_H + +// Platform lacks +#define ACE_LACKS_SYS_SELECT_H + +// Platform lacks +#define ACE_LACKS_DLFCN_H + +// Platform lacks +#define ACE_LACKS_SEMAPHORE_H + +// Platform lacks +#define ACE_LACKS_POLL_H + +//========================================================================= +// Compiler specific parts +//========================================================================= + +// Compiler supports C++ exception handling +#define ACE_HAS_EXCEPTIONS + +// Compiler/platform has correctly prototyped header files +#define ACE_HAS_CPLUSPLUS_HEADERS + +// Compiler/platform does not support the unsigned long long datatype. +#define ACE_LACKS_LONGLONG_T + +// Compiler supports the ssize_t typedef +#define ACE_HAS_SSIZE_T + +// Platform/compiler supports Standard C++ Library +#define ACE_HAS_STANDARD_CPP_LIBRARY 0 + +// Compiler's template mechanism must see source code (i.e., +// .cpp files). +#define ACE_TEMPLATES_REQUIRE_SOURCE + +// Compiler implements templates that support typedefs inside +// of classes used as formal arguments to a template class. +#define ACE_HAS_TEMPLATE_TYPEDEFS + +// Platform has its standard c++ library in the namespace std. +#define ACE_USES_STD_NAMESPACE_FOR_STDCPP_LIB 1 + +// Compiler doesn't support static data member templates +#define ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES + +// Platform lacks "signed char" type (broken!) +// Following will not be needed if use standard c library (G06.20 and later) +#define ACE_LACKS_SIGNED_CHAR + +//========================================================================= +// Build options +//========================================================================= + +// Disable the inclusion of RCS ids in the generated code. +#define ACE_USE_RCSID 0 + +// For debugging problems in os calls (but this doesn't work too well +// since output is not interleaved properly with output from ACE_TRACE +//# define ACE_OS_TRACE(X) ::printf(X) + +// Uncomment the following if timed message blocks are needed (e.g. +// for Dynamic_Priority_Test. Otherwise leave this disabled because +// enabling it adds overhead to message blocks and timed message blocks +// are "rarely used." +//#define ACE_HAS_TIMED_MESSAGE_BLOCKS + +// Uncomment the following if tokens library is needed. +//#define ACE_HAS_TOKENS_LIBRARY + +#include /**/ "ace/post.h" + +#endif /* ACE_CONFIG_NSK_H */ diff --git a/dep/ACE_wrappers/ace/config-tandem-nsk-mips-v3.h b/dep/ACE_wrappers/ace/config-tandem-nsk-mips-v3.h new file mode 100644 index 00000000000..0e6fd291c29 --- /dev/null +++ b/dep/ACE_wrappers/ace/config-tandem-nsk-mips-v3.h @@ -0,0 +1,471 @@ +// -*- C++ -*- +// +// $Id: config-tandem-nsk-mips-v3.h 81935 2008-06-12 22:01:53Z jtc $ + + +#ifndef ACE_CONFIG_NSK_H +#define ACE_CONFIG_NSK_H + +#include /**/ "ace/pre.h" + +// The following configuration file contains defines for Tandem NSK +// platform, MIPS processor, version 3 C++ compiler. + + +//========================================================================= +// Tandem NSK specific parts +//========================================================================= + + +// Disable pthread renaming of symbols such as "open" and "close" +#define _CMA_NOWRAPPERS_ 1 + +// Get Handle_Set.cpp to generate correct bit operations for NSK platform +#define ACE_TANDEM_NSK_BIT_ORDER + +// Use facilities provided by T1248 version of pthreads. +// (If not defined, will use old version of pthreads.) +#define ACE_TANDEM_T1248_PTHREADS + +// Use all available T1248 thread aware wrapper functions for providing +// non-blocking I/O. +// [Note: this causes a significant performance degradation] +//#define ACE_TANDEM_T1248_PTHREADS_ALL_IO_WRAPPERS + + +// Need this include here because some symbols defined by pthreads +// (e.g. timespec_t) are needed before spthread.h is normally included +// by ACE +#ifdef ACE_TANDEM_T1248_PTHREADS +#include +#else +#include "pthread.h" +#include "dce/cma_dispatch_coop.h" +#endif + +// The following #defines are hacks to get around things +// that seem to be missing or different in Tandem land +#define NSIG 32 // missing from Signal.h + // note: on nsk TNS/R there is room in + // sigset_t for 128 signals but those + // above 31 are not valid. +typedef long fd_mask; // should be in select.h but no such file +#define NBBY 8 // must be consistent with value in sys/types.h +#define NFDBITS (sizeof (fd_mask) * NBBY) /* bits per mask */ +#define MAXNAMLEN 248 // missing from dirent.h +#define ERRMAX 4218 // from errno.h + +// Following seems to be missing from G06.20 version of standard +// pthreads includes (it appeared in older version of standard pthreads) +// (SCHED_FIFO (aka cma_c_sched_fifo) used in Dynamic_Priority_Test) +#ifdef ACE_TANDEM_T1248_PTHREADS +typedef enum CMA_T_SCHED_POLICY { + cma_c_sched_fifo = 0, + cma_c_sched_rr = 1, + cma_c_sched_throughput = 2, + cma_c_sched_background = 3, + cma_c_sched_ada_low = 4 + } cma_t_sched_policy; +#endif + +// T1248 doesn't define these constants. They're defined in spt/cma.h +// (formerly dce/cma.h), but this header is not included or provided +// by T1248 G07-AAL. +#define cma_c_prio_fifo_min 16 +#define cma_c_prio_fifo_mid 24 +#define cma_c_prio_fifo_max 31 +#define cma_c_prio_rr_min 16 +#define cma_c_prio_rr_mid 24 +#define cma_c_prio_rr_max 31 +#define cma_c_prio_through_min 8 +#define cma_c_prio_through_mid 12 +#define cma_c_prio_through_max 15 +#define cma_c_prio_back_min 1 +#define cma_c_prio_back_mid 4 +#define cma_c_prio_back_max 7 + +// Enable NSK Pluggable Protocols +#define TAO_HAS_NSKPW 1 +#define TAO_HAS_NSKFS 1 + +//========================================================================= +// Platform specific parts +//========================================================================= + +// Platform lacks getpwnam_r() methods (e.g., SGI 6.2). +#define ACE_LACKS_PWD_REENTRANT_FUNCTIONS + +// Platform/compiler lacks {get,set}rlimit() function +#define ACE_LACKS_RLIMIT + +// The platform doesn't have mmap(2) +#define ACE_LACKS_MMAP + +// Platform lacks streambuf "linebuffered ()". [C++ iostream] +#define ACE_LACKS_LINEBUFFERED_STREAMBUF + +// Platform supports recvmsg and sendmsg +#define ACE_HAS_MSG + +// Platform defines ACE_HAS_MSG, but lacks msg_accrights{,len}. +#define ACE_LACKS_MSG_ACCRIGHTS + +// Platform supports sigsuspend() +#define ACE_HAS_SIGSUSPEND + +// Platform/compiler has the sigwait(2) prototype +#define ACE_HAS_SIGWAIT + +// Compiler/platform defines the sig_atomic_t typedef +#define ACE_HAS_SIG_ATOMIC_T + +// OS/compiler uses size_t * rather than int * for socket lengths +#define ACE_HAS_SIZET_SOCKET_LEN + +// OS/compiler uses void * arg 4 setsockopt() rather than const char * +#define ACE_HAS_VOIDPTR_SOCKOPT + +// The platform doesn't have mprotect(2) +#define ACE_LACKS_MPROTECT + +// Platform lacks msync() +#define ACE_LACKS_MSYNC + +// Platform does not support reentrant netdb functions (getprotobyname_r, +// getprotobynumber_r, gethostbyaddr_r, gethostbyname_r, getservbyname_r). +#define ACE_LACKS_NETDB_REENTRANT_FUNCTIONS Platform does not support + +// Platform lacks madvise() +#define ACE_LACKS_MADVISE + +// Platform lacks pri_t +#define ACE_LACKS_PRI_T + +// Platform lacks a working sbrk() +#define ACE_LACKS_SBRK + +// Platform doesn't have syscall() prototype +#define ACE_LACKS_SYSCALL + +// Platform lacks the inet_aton() function. +#define ACE_LACKS_INET_ATON + +// Compiler/platform has Dirent iterator functions +#define ACE_HAS_DIRENT + +// Platform uses ACE_HAS_DIRENT but does not have readdir_r() +#define ACE_LACKS_READDIR_R + +// Platform supports getpagesize() call (otherwise, +// ACE_PAGE_SIZE must be defined) +#define ACE_HAS_GETPAGESIZE + +// Platform supports IP multicast +#define ACE_HAS_IP_MULTICAST + +// Platform's select() uses non-const timeval* +#define ACE_HAS_NONCONST_SELECT_TIMEVAL + +// Platform supports POSIX O_NONBLOCK semantics +#define ACE_HAS_POSIX_NONBLOCK + +// Platform lacks named POSIX semaphores +#define ACE_LACKS_NAMED_POSIX_SEM + +// Platform has support for multi-byte character support compliant +// with the XPG4 Worldwide Portability Interface wide-character +// classification. +#define ACE_HAS_XPG4_MULTIBYTE_CHAR + +// No wcsstr function available for this compiler +#define ACE_LACKS_WCSSTR + +// No wctype.h available for this compiler +#define ACE_LACKS_WCTYPE_H + +// Platform supports the POSIX regular expression library. +// [Note Tandem NSK platform does have regular expresson support but it +// does not follow the assumptions made by ACE. To use it would need +// to make some ACE modifications.] +//#define ACE_HAS_REGEX + +// Compiler/platform supports strerror () +#define ACE_HAS_STRERROR + +// Platform doesn't have truncate() +#define ACE_LACKS_TRUNCATE + +// Platform lacks readers/writer locks. +#define ACE_LACKS_RWLOCK_T + +// Compiler's 'new' throws exception on failure (ANSI C++ behavior). +#define ACE_NEW_THROWS_EXCEPTIONS + +// Optimize ACE_Handle_Set::count_bits for select() operations (common +// case) +#define ACE_HAS_HANDLE_SET_OPTIMIZED_FOR_SELECT + +// Platform lacks setreuid() +#define ACE_LACKS_SETREUID + +// Platform lacks setregid() +#define ACE_LACKS_SETREGID + +// Compile using multi-thread libraries +#define ACE_MT_SAFE 1 + + + +// Platform supports System V IPC +#define ACE_HAS_SYSV_IPC + +// Platform lacks the socketpair() call +// [Needed due to failure of Pipe_Test. even though nsk platform +// has socketpair(), Pipe.cpp tries to set socket buf size but this +// is not allowed for AF_UNIX protocol on nsk.] +#define ACE_LACKS_SOCKET_BUFSIZ + +// Platform lacks the socketpair() call +#define ACE_LACKS_SOCKETPAIR + +// Platform limits the maximum socket message size. +#define ACE_HAS_SOCK_BUF_SIZE_MAX + +// hrtime_t is a basic type that doesn't require ACE_U64_TO_U32 conversion +#define ACE_HRTIME_T_IS_BASIC_TYPE + +// printf format specifiers for 64 bit integers +# define ACE_UINT64_FORMAT_SPECIFIER ACE_TEXT ("%Ld") +# define ACE_INT64_FORMAT_SPECIFIER ACE_TEXT ("%Ld") + +// Use larger default buffer size for ease of interoperability +#define ACE_DEFAULT_CDR_BUFSIZE 4096 + +// Size of a wchar +#define ACE_SIZEOF_WCHAR 2 + +// Platform lacks time typedefs +#define ACE_LACKS_SUSECONDS_T +#define ACE_LACKS_USECONDS_T + +// Platform lacks setegid() and seteuid() +#define ACE_LACKS_SETEGID +#define ACE_LACKS_SETEUID + +// Platform lacks vsnprintf() +#define ACE_LACKS_VSNPRINTF + +// Platform lacks log2() +#define ACE_LACKS_LOG2 + +// Platform lacks alphasort() +#define ACE_LACKS_ALPHASORT + + +//========================================================================= +// Threads specific parts +//========================================================================= + +// Platform supports threads +#define ACE_HAS_THREADS + +// Platform supports POSIX Pthreads, of one form or another. This +// macro says the platform has a pthreads variety - should also define +// one of the below to say which one. Also may need some +// ACE_HAS_... thing for extensions. +#define ACE_HAS_PTHREADS + +// Standard pthreads supports only SCHED_FIFO +#define ACE_HAS_ONLY_SCHED_FIFO + +// Compiler/platform has thread-specific storage +#define ACE_HAS_THREAD_SPECIFIC_STORAGE + +// Platform has no implementation of pthread_condattr_setpshared(), +// even though it supports pthreads! +#define ACE_LACKS_CONDATTR_PSHARED + +// pthread_cond_timedwait does *not* reset the time argument when the +// lock is acquired. +#define ACE_LACKS_COND_TIMEDWAIT_RESET + +// Platform lacks pthread_attr_setsched() +#define ACE_LACKS_SETSCHED + +// Platform has pthread_getschedparam and pthread_setschedparam +// even when ACE_LACKS_SETSCHED is defined. +#define ACE_HAS_PTHREAD_SCHEDPARAM + +// Platform has pthread_mutexattr_setkind_np(). +#define ACE_HAS_PTHREAD_MUTEXATTR_SETKIND_NP + +// Platform lacks pthread_mutexattr_setpshared(). +#define ACE_LACKS_MUTEXATTR_PSHARED + +// Platform lacks pthread_attr_setscope() +#define ACE_LACKS_THREAD_PROCESS_SCOPING + +// Platform lacks pthread_attr_setstackaddr +#define ACE_LACKS_PTHREAD_ATTR_SETSTACKADDR + +// Platform lacks pthread_attr_setstack +#define ACE_LACKS_PTHREAD_ATTR_SETSTACK + +// Defining ACE_HAS_UCONTEXT_T since G06.21 version of spthreads has +// a definition for it. +#ifdef ACE_TANDEM_T1248_PTHREADS +#define ACE_HAS_UCONTEXT_T +#endif + +//========================================================================= +// Include file characteristics +//========================================================================= + +// Compiler/platform contains the file. +#define ACE_HAS_SYS_SYSCALL_H + +// Platform lacks malloc.h +#define ACE_LACKS_MALLOC_H + +// Platform lacks the siginfo.h include file +#define ACE_LACKS_SIGINFO_H + +// Platform doesn't define struct strrecvfd. +#define ACE_LACKS_STRRECVFD + +// Platform lacks the ucontext.h file +#define ACE_LACKS_UCONTEXT_H + +// Prototypes for both signal() and struct sigaction are consistent. +#define ACE_HAS_CONSISTENT_SIGNAL_PROTOTYPES + +// Platform supports the POSIX struct timespec type +#define ACE_HAS_POSIX_TIME + +// Platform/compiler supports timezone * as second parameter to gettimeofday() +#define ACE_HAS_TIMEZONE_GETTIMEOFDAY + +// Platform has (which contains bzero() prototype) +#define ACE_HAS_STRINGS 1 + + +// OS/compiler omits the const from the iovec parameter in the +// writev() prototype. +#define ACE_HAS_NONCONST_WRITEV + +// Platform lacks +#define ACE_LACKS_STDINT_H + +// Platform lacks +#define ACE_LACKS_INTTYPES_H + +// Platform lacks +#define ACE_LACKS_SYS_SELECT_H + +// Platform lacks +#define ACE_LACKS_DLFCN_H + +// Platform lacks +#define ACE_LACKS_SEMAPHORE_H + +// Platform lacks +#define ACE_LACKS_POLL_H + +// Platform lacks +#define ACE_LACKS_SYS_SYSCTL_H + +//========================================================================= +// Compiler specific parts +//========================================================================= + +// Compiler supports C++ exception handling +#define ACE_HAS_EXCEPTIONS 1 + +// Compiler/platform has correctly prototyped header files +#define ACE_HAS_CPLUSPLUS_HEADERS + +// Compiler/platform does not support the unsigned long long datatype. +#define ACE_LACKS_UNSIGNEDLONGLONG_T + +// Compiler supports the ssize_t typedef +#define ACE_HAS_SSIZE_T + +// Platform/compiler supports Standard C++ Library +#define ACE_HAS_STANDARD_CPP_LIBRARY 1 + +// Compiler's template mechanism must see source code (i.e., +// .cpp files). +#define ACE_TEMPLATES_REQUIRE_SOURCE + +// Compiler implements templates that support typedefs inside +// of classes used as formal arguments to a template class. +#define ACE_HAS_TEMPLATE_TYPEDEFS + +// Platform/Compiler supports a String class +#define ACE_HAS_STRING_CLASS +#define ACE_HAS_STDCPP_STL_INCLUDES + +// Platform has its standard c++ library in the namespace std. +#define ACE_USES_STD_NAMESPACE_FOR_STDCPP_LIB 1 + +// Compiler doesn't support static data member templates +#define ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES + +// Platform lacks "signed char" type (broken!) +// Following will not be needed if use standard c library (G06.20 and later) +#define ACE_LACKS_SIGNED_CHAR + +// Compiler can handle any operators in namespace +#define ACE_ANY_OPS_USE_NAMESPACE + +// Platform lacks intptr_t typedef +#define ACE_LACKS_INTPTR_T + +//========================================================================= +// C++ version3 import/export macros +//========================================================================= + +// Define the export macros needed to export symbols outside a DLL +// The ACE_IMPORT_SINGLETON_DECLARE macro has been modified to not explicitly +// instantiate the class template. +#if defined(USE_EXPLICIT_EXPORT) +#define ACE_LACKS_INLINE_FUNCTIONS + +#define ACE_HAS_CUSTOM_EXPORT_MACROS +#define ACE_Proper_Export_Flag export$ +#define ACE_Proper_Import_Flag import$ +#define ACE_EXPORT_SINGLETON_DECLARATION(T) template class export$ T +#define ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) template class export$ SINGLETON_TYPE; +#define ACE_IMPORT_SINGLETON_DECLARATION(T) template class import$ T +#define ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) template class import$ SINGLETON_TYPE ; +#endif + + +//========================================================================= +// Build options +//========================================================================= + +// Disable the inclusion of RCS ids in the generated code. +#define ACE_USE_RCSID 0 + +// For debugging problems in os calls (but this doesn't work too well +// since output is not interleaved properly with output from ACE_TRACE +//# define ACE_OS_TRACE(X) ::printf(X) + +// Uncomment the following if timed message blocks are needed (e.g. +// for Dynamic_Priority_Test. Otherwise leave this disabled because +// enabling it adds overhead to message blocks and timed message blocks +// are "rarely used." +//#define ACE_HAS_TIMED_MESSAGE_BLOCKS + +// Uncomment the following if tokens library is needed. +//#define ACE_HAS_TOKENS_LIBRARY + +// NonStop CORBA uses the XML Service Configurator +#define ACE_HAS_XML_SVC_CONF + +#define ACE_LD_SEARCH_PATH "_RLD_LIB_PATH" + +#include /**/ "ace/post.h" + +#endif /* ACE_CONFIG_NSK_H */ diff --git a/dep/ACE_wrappers/ace/config-tandem.h b/dep/ACE_wrappers/ace/config-tandem.h new file mode 100644 index 00000000000..981fdfb2d99 --- /dev/null +++ b/dep/ACE_wrappers/ace/config-tandem.h @@ -0,0 +1,193 @@ +/* -*- C++ -*- */ +// Testing TANDEM +// $Id: config-tandem.h 81697 2008-05-14 18:33:11Z johnnyw $ + +// The following configuration file is designed to work for Tandems NonStop-UX +// 4.2MP platforms using the NCC 3.20 compiler. + +// Note this is a test version it might include several errors I +// have done a test and set/unset until I errors disappered. +// Some of the options that should be set aren't because of the simple fact +// that i haven't the time to check what is wrong. +// e.g. widecharacter are supported but a wcstok which only take 2 parameters +// are included by the compiler, to get the correct wcstok that takes 3 params +// we must set _XOPEN_SOURCE and we get ALOT of errors and warnings. +// So this config is done to get things to start to work it isn't finished. +// Janne (Jan.Perman@osd.Ericsson.se) + +#ifndef ACE_CONFIG_H +#define ACE_CONFIG_H +#include /**/ "ace/pre.h" + +#if ! defined (__ACE_INLINE__) +# define __ACE_INLINE__ +#endif /* ! __ACE_INLINE__ */ + +#define ACE_HAS_IDTYPE_T +// Optimize ACE_Handle_Set for select(). +#define ACE_HAS_HANDLE_SET_OPTIMIZED_FOR_SELECT + +// Tandem doesn't include this although they are defined +// in sys/time.h and sys/resource.h +#define ACE_LACKS_RLIMIT_PROTOTYPE // jjpp +// Tandem has a function to set t_errno (set_t_errno) +#define ACE_HAS_SET_T_ERRNO // jjpp + +//Platform supports System V IPC (most versions of UNIX, but not Win32) +#define ACE_HAS_SYSV_IPC + +// OS/compiler omits the const from the sendmsg() prototype. +#define ACE_HAS_NONCONST_SENDMSG + +//Platform supports system configuration information +#define ACE_HAS_SYS_SYSTEMINFO_H +#define ACE_HAS_SYSINFO + +//Platform supports the POSIX regular expression library +#define ACE_HAS_REGEX + +// Platform supports recvmsg and sendmsg +#define ACE_HAS_MSG + +//Compiler/platform contains the file. +#define ACE_HAS_SYS_SYSCALL_H + +//Platform provides header +#define ACE_HAS_SYSENT_H + +// Platform has POSIX terminal interface. +#define ACE_HAS_TERMIOS + +//Platform supports POSIX O_NONBLOCK semantics +#define ACE_HAS_POSIX_NONBLOCK + +// Compiler/platform has correctly prototyped header files +#define ACE_HAS_CPLUSPLUS_HEADERS + +//Compiler/platform supports alloca() +// Although ACE does have alloca() on this compiler/platform combination, it is +// disabled by default since it can be dangerous. Uncomment the following line +// if you ACE to use it. +//#define ACE_HAS_ALLOCA + +//Compiler/platform has +#define ACE_HAS_ALLOCA_H + +//Platform contains +#define ACE_HAS_POLL + +// Platform supports the POSIX struct timespec type +#define ACE_HAS_POSIX_TIME // As i understand it, but i'm in deep water +//Platform supports the SVR4 timestruc_t type + +// To get this to work a patch in sys/signal must be made +// typedef void SIG_FUNC_TYPE(int); +//#if defined (__cplusplus) +// void (*sa_handler)(int); +//#else +// ... +//#endif +//#define ACE_HAS_CONSISTENT_SIGNAL_PROTOTYPES +#define ACE_HAS_TANDEM_SIGNALS +//Compiler/platform defines the sig_atomic_t typedef +#define ACE_HAS_SIG_ATOMIC_T +//Platform supports SVR4 extended signals +#define ACE_HAS_SIGINFO_T +//Platform supports ucontext_t (which is used in the extended signal API). +#define ACE_HAS_UCONTEXT_T + +// Platform/compiler has the sigwait(2) prototype +#define ACE_HAS_SIGWAIT + +//Compiler/platform provides the sockio.h file +#define ACE_HAS_SYS_SOCKIO_H + +// Compiler supports the ssize_t typedef +#define ACE_HAS_SSIZE_T // Limits.h must be included + +//Platform supports STREAMS +#define ACE_HAS_STREAMS + +#define ACE_HAS_STREAM_PIPES +//Platform supports STREAM pipes + +//Compiler/platform supports strerror () +#define ACE_HAS_STRERROR + +//Compiler/platform supports struct strbuf +#define ACE_HAS_STRBUF_T + +//Compiler/platform supports SVR4 dynamic linking semantics +#define ACE_HAS_SVR4_DYNAMIC_LINKING + +//Compiler/platform supports SVR4 TLI (in particular, T_GETNAME stuff)... +#define ACE_HAS_SVR4_TLI + +//Platform provides header +#define ACE_HAS_SYS_FILIO_H + +//Platform supports TLI timod STREAMS module +#define ACE_HAS_TIMOD_H +//Platform supports TLI tiuser header +#define ACE_HAS_TIUSER_H + +//Platform supports TLI +#define ACE_HAS_TLI +//Platform provides TLI function prototypes +#define ACE_HAS_TLI_PROTOTYPES + +//Platform lacks streambuf "linebuffered ()". +#define ACE_LACKS_LINEBUFFERED_STREAMBUF + +// Platform lacks "signed char" type (broken!) +#define ACE_LACKS_SIGNED_CHAR + + +#define ACE_PAGE_SIZE 4096 +// Defines the page size of the system (not used on Win32 or +// with ACE_HAS_GETPAGESIZE). + +/****** THREAD SPECIFIC **********/ +/* If you want to remove threading then comment out the following four #defines .*/ +#if !defined (ACE_MT_SAFE) + #define ACE_MT_SAFE 1 //Compile using multi-thread libraries +#endif +#define ACE_HAS_THREADS //Platform supports threads +#define ACE_HAS_STHREADS //Platform supports Solaris threads + +// Compiler/platform has threadspecific storage +#define ACE_HAS_THREAD_SPECIFIC_STORAGE +//Platform supports thr_keydelete (e.g,. UNIXWARE) + +#define ACE_HAS_THR_MINSTACK // Tandem uses thr_minstack instead of thr_min_stack +#define ACE_LACKS_PRI_T // Tandem lacks pri_t +#define ACE_HAS_THR_KEYDELETE + +//************************************* + +/*********************************/ + +/******* SIGNAL STUFF *******/ + +//Platform uses non-const char * in calls to gethostbyaddr, gethostbyname, +// getservbyname +#define ACE_HAS_NONCONST_GETBY +// Platform's select() uses non-const timeval* (only found on Linux right now) +#define ACE_HAS_NONCONST_SELECT_TIMEVAL +// And on Tandem :-) +//Uses ctime_r & asctime_r with only two parameters vs. three. +#define ACE_HAS_2_PARAM_ASCTIME_R_AND_CTIME_R +//Platform has special header for select(). +#define ACE_HAS_SELECT_H +// Platform/compiler supports Standard C++ Library +#define ACE_HAS_STANDARD_CPP_LIBRARY +//Platform lacks madvise() (e.g., Linux) +#define ACE_LACKS_MADVISE +//Compiler/platform lacks strcasecmp() (e.g., DG/UX, UNIXWARE, VXWORKS) +#define ACE_LACKS_STRCASECMP + +// Defines the page size of the system. +#define ACE_PAGE_SIZE 4096 + +#include /**/ "ace/post.h" +#endif /* ACE_CONFIG_H */ diff --git a/dep/ACE_wrappers/ace/config-tru64.h b/dep/ACE_wrappers/ace/config-tru64.h new file mode 100644 index 00000000000..f2825b996a9 --- /dev/null +++ b/dep/ACE_wrappers/ace/config-tru64.h @@ -0,0 +1,154 @@ +/* -*- C++ -*- */ +// $Id: config-tru64.h 81935 2008-06-12 22:01:53Z jtc $ + +// The following configuration file is designed to work for the +// Digital UNIX V4.0a and later platforms. It relies on +// config-osf1-4.0.h, and adds deltas for newer platforms. + +#ifndef ACE_CONFIG_TRU64_H +#define ACE_CONFIG_TRU64_H +#include /**/ "ace/pre.h" + +#if !defined (__ACE_INLINE__) +# define __ACE_INLINE__ +#endif /* ! __ACE_INLINE__ */ + +// Compile using multi-thread libraries. +#if !defined (ACE_MT_SAFE) +# define ACE_MT_SAFE 1 +#endif /* ! ACE_MT_SAFE */ + +/*clearerr is not defined when _REENTRANT is not defined*/ +#if ACE_MT_SAFE == 0 +#define ACE_LACKS_CLEARERR +#endif /* ACE_MT_SAFE == 0 */ + +#include "ace/config-posix.h" + +// Configuration-specific #defines: +// 1) g++ or cxx +// 2) pthreads or DCE threads +#if defined (__GNUG__) + // g++ with pthreads + + // config-g++-common.h undef's ACE_HAS_STRING_CLASS with -frepo, so + // this must appear before its #include. +# define ACE_HAS_STRING_CLASS + +# include "ace/config-g++-common.h" + +# define ACE_HAS_GNU_CSTRING_H +# define ACE_HAS_REENTRANT_FUNCTIONS +#elif defined (__DECCXX) + +# define ACE_CONFIG_INCLUDE_CXX_COMMON +# include "ace/config-cxx-common.h" + +#elif defined (__rational__) +# define ACE_HAS_REENTRANT_FUNCTIONS +# define ACE_HAS_STRING_CLASS +# define ACE_LACKS_LINEBUFFERED_STREAMBUF +# define ACE_LACKS_SIGNED_CHAR + + // Exceptions are enabled by platform_osf1_4.0_rcc.GNU. +# define ACE_HAS_STDCPP_STL_INCLUDES +#else +# ifdef __cplusplus /* Let it slide for C compilers. */ +# error unsupported compiler on Digital Unix +# endif /* __cplusplus */ +#endif /* ! __GNUG__ && ! __DECCXX && ! __rational__ */ + +#define ACE_HAS_2_PARAM_ASCTIME_R_AND_CTIME_R +#define ACE_HAS_BROKEN_IF_HEADER +#define ACE_HAS_BROKEN_R_ROUTINES +#if (ACE_MT_SAFE != 0) +# define ACE_HAS_PTHREADS +# define ACE_HAS_RECURSIVE_THR_EXIT_SEMANTICS +#endif /* ACE_MT_SAFE != 0 */ +#define ACE_LACKS_T_ERRNO +#if !defined (DIGITAL_UNIX) +# define DIGITAL_UNIX 0x400 +#endif /* ! DIGITAL_UNIX */ + +#define ACE_SIZEOF_LONG 8 + +#define ACE_DEFAULT_BASE_ADDR ((char *) 0x80000000) +#define ACE_HAS_AUTOMATIC_INIT_FINI +#define ACE_HAS_NONCONST_SETRLIMIT +#define ACE_HAS_BROKEN_T_ERROR +#define ACE_HAS_NONCONST_WRITEV +#define ACE_HAS_CLOCK_GETTIME +#define ACE_HAS_CLOCK_SETTIME +#define ACE_HAS_CONSISTENT_SIGNAL_PROTOTYPES +#define ACE_HAS_CPLUSPLUS_HEADERS +#define ACE_HAS_DIRENT +#define ACE_HAS_GETRUSAGE +#define ACE_HAS_GPERF +#define ACE_HAS_HANDLE_SET_OPTIMIZED_FOR_SELECT +#define ACE_HAS_IP_MULTICAST +#define ACE_HAS_LLSEEK +#define ACE_HAS_LONG_MAP_FAILED +#define ACE_HAS_MSG +#define ACE_HAS_NONCONST_SELECT_TIMEVAL +#define ACE_HAS_NONCONST_SENDMSG +#define ACE_HAS_OSF1_GETTIMEOFDAY +#define ACE_HAS_OSF_TIMOD_H +#define ACE_HAS_POLL +#define ACE_HAS_POSIX_NONBLOCK +#define ACE_HAS_POSIX_TIME +#define ACE_HAS_PRIOCNTL +#define ACE_HAS_SIGINFO_T +#define ACE_HAS_SIG_ATOMIC_T +#define ACE_HAS_SSIZE_T +#define ACE_HAS_STRBUF_T +#define ACE_HAS_STREAMS +#define ACE_HAS_STRERROR +#define ACE_HAS_STRPTIME +#define ACE_HAS_SVR4_DYNAMIC_LINKING +#define ACE_HAS_SVR4_SIGNAL_T +#define ACE_HAS_SYS_SYSCALL_H +#define ACE_HAS_SYSV_IPC +#if (ACE_MT_SAFE == 0) +// clearerr is not defined when _REENTRANT is not defined +#define ACE_LACKS_CLEARERR +#else /* ACE_MT_SAFE != 0 */ +#define ACE_HAS_THREADS +#define ACE_HAS_THREAD_SPECIFIC_STORAGE +#define ACE_LACKS_PTHREAD_ATTR_SETSTACKADDR +#endif /* ACE_MT_SAFE != 0 */ +#define ACE_HAS_TIUSER_H +#define ACE_HAS_XTI +#define ACE_HAS_TLI_PROTOTYPES +#define ACE_HAS_UALARM +#define ACE_HAS_UCONTEXT_T +#define ACE_LACKS_PRI_T +#define ACE_LACKS_RWLOCK_T +#define ACE_PAGE_SIZE 8192 +#define ACE_HAS_SIGTIMEDWAIT +#define ACE_HAS_SIGSUSPEND + +// DJT 6/10/96 All these broken macro's can now be removed with the +// approporiate ordering of the include files. The Platinum release +// now temporarily supports both forms. Platform's implementation of +// sendmsg() has a non-const msgheader parameter. +#define ACE_HAS_NONCONST_SENDMSG +#define ACE_HAS_IDTYPE_T +#define ACE_HAS_NONSTATIC_OBJECT_MANAGER + +#if DIGITAL_UNIX >= 0x500 +# define ACE_HAS_XPG4_MULTIBYTE_CHAR 1 +#endif /* DIGITAL_UNIX >= 0x500 */ + +#if DIGITAL_UNIX >= 0x40E +# define ACE_LACKS_STDINT_H +#endif /* DIGITAL_UNIX >= 0x40E */ + +#if (DIGITAL_UNIX >= 0x400) && (DIGITAL_UNIX < 0x500) +#define ACE_LACKS_PREAD_PROTOTYPE +#endif /* (DIGITAL_UNIX >= 0x400) && (DIGITAL_UNIX < 0x500) */ + +// gethostbyaddr does not handle IPv6-mapped-IPv4 addresses +#define ACE_HAS_BROKEN_GETHOSTBYADDR_V4MAPPED + +#include /**/ "ace/post.h" +#endif /* ACE_CONFIG_TRU64_H */ diff --git a/dep/ACE_wrappers/ace/config-unixware-7.1.0.h b/dep/ACE_wrappers/ace/config-unixware-7.1.0.h new file mode 100644 index 00000000000..b75fac4dcd8 --- /dev/null +++ b/dep/ACE_wrappers/ace/config-unixware-7.1.0.h @@ -0,0 +1,412 @@ +/* -*- C++ -*- */ +// $Id: config-unixware-7.1.0.h 82267 2008-07-08 16:39:19Z jtc $ + +#ifndef ACE_CONFIG_H +#define ACE_CONFIG_H + +/* ACE configuration header file */ + +/* Include the commong gnu config file */ +#include "config-g++-common.h" + +/* For unixware 7.1 && g++ 2.91.57, see if this fixes my problem */ +#ifndef UNIXWARE_7_1 +#define UNIXWARE_7_1 +#endif + +/* Define if you have alloca, as a function or macro. */ +#define HAVE_ALLOCA 1 + +/* Define if you have the strftime function. */ +#define HAVE_STRFTIME 1 + +/* Define if you have that is POSIX.1 compatible. */ +#define HAVE_SYS_WAIT_H 1 + +/* Define if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* Define if lex declares yytext as a char * by default, not a char[]. */ +#define YYTEXT_POINTER 1 + +/* Define _REENTRANT if reentrant functions should be used. */ +#ifndef _REENTRANT +# define _REENTRANT 1 +#endif + +#define ACE_HAS_NEW_NO_H 1 +#define ACE_HAS_STDEXCEPT_NO_H 1 + +#define ACE_THREAD_MIN_PRIORITY 0 +#if defined (ACE_THREAD_MIN_PRIORITY) +# define PTHREAD_MIN_PRIORITY ACE_THREAD_MIN_PRIORITY +#endif /* #if defined (ACE_THREAD_MIN_PRIORITY) */ + +#define ACE_THREAD_MAX_PRIORITY 99 +#if defined (ACE_THREAD_MAX_PRIORITY) +# define PTHREAD_MAX_PRIORITY ACE_THREAD_MAX_PRIORITY +#endif /* #if defined (ACE_THREAD_MAX_PRIORITY) */ + +/* Specify sizes of given built-in types. If a size isn't defined here, + then ace/Basic_Types.h will attempt to deduce the size. */ +/* #undef ACE_SIZEOF_CHAR */ +#define ACE_SIZEOF_SHORT 2 +#define ACE_SIZEOF_INT 4 +#define ACE_SIZEOF_LONG 4 +#define ACE_SIZEOF_LONG_LONG 8 +#define ACE_SIZEOF_VOID_P 4 +#define ACE_SIZEOF_FLOAT 4 +#define ACE_SIZEOF_DOUBLE 8 +#define ACE_SIZEOF_LONG_DOUBLE 12 + +/* Enable ACE inlining */ +#define __ACE_INLINE__ 1 + +/* OS has priocntl (2) */ +#define ACE_HAS_PRIOCNTL 1 + +/* Platform has pread() and pwrite() support */ +#define ACE_HAS_P_READ_WRITE 1 + +/* Compiler/platform supports alloca() */ +// Although ACE does have alloca() on this compiler/platform combination, it is +// disabled by default since it can be dangerous. Uncomment the following line +// if you ACE to use it. +//#define ACE_HAS_ALLOCA 1 + +/* Compiler/platform correctly calls init()/fini() for shared libraries */ +#define ACE_HAS_AUTOMATIC_INIT_FINI 1 + +/* Platform doesn't cast MAP_FAILED to a (void *). */ +/* #undef ACE_HAS_BROKEN_MAP_FAILED */ +/* Staller: oh yes, let's do this! */ +#define ACE_HAS_BROKEN_MAP_FAILED + +/* Prototypes for both signal() and struct sigaction are consistent. */ +#define ACE_HAS_CONSISTENT_SIGNAL_PROTOTYPES 1 + +/* Platform supports operations on directories via struct dirent, + readdir_r, etc. */ +#define ACE_HAS_DIRENT 1 + +/* Compiler supports C++ exception handling */ +// MM-Graz if ! defined inserted, to prevent warnings, because it is already +// defined in config-g++common.h +# if !defined (ACE_HAS_EXCEPTIONS) +#define ACE_HAS_EXCEPTIONS 1 +# endif + +/* Platform supports getpagesize() call (otherwise, ACE_PAGE_SIZE must be + defined, except on Win32) */ +#define ACE_HAS_GETPAGESIZE 1 + +/* Platform supports the getrusage() system call. */ +#define ACE_HAS_GETRUSAGE 1 + +/* Platform has a getrusage () prototype in sys/resource.h that differs from + the one in ace/OS.i. */ +#define ACE_HAS_GETRUSAGE_PROTOTYPE 1 + +/* Denotes that GNU has cstring.h as standard which redefines memchr() */ +#define ACE_HAS_GNU_CSTRING_H + +/* The GPERF utility is compiled for this platform */ +#define ACE_HAS_GPERF 1 + +/* Optimize ACE_Handle_Set::count_bits for select() operations (common case) */ +#define ACE_HAS_HANDLE_SET_OPTIMIZED_FOR_SELECT 1 + +/* Compiler/platform supports idtype_t. */ +#define ACE_HAS_IDTYPE_T 1 + +/* Platform supports IP multicast */ +#define ACE_HAS_IP_MULTICAST 1 + +/* Platform supports thr_keydelete (e.g,. UNIXWARE) */ +#define ACE_HAS_THR_KEYDELETE 1 + +/* Platform calls thr_minstack() rather than thr_min_stack() (e.g., Tandem). */ +#define ACE_HAS_THR_MINSTACK 1 + +/* Platform supports recvmsg and sendmsg */ +#define ACE_HAS_MSG 1 + +/* Platform's select() uses non-const timeval* (only found on Linux right + now) */ +#define ACE_HAS_NONCONST_SELECT_TIMEVAL 1 + +/* Uses ctime_r & asctime_r with only two parameters vs. three. */ +#define ACE_HAS_2_PARAM_ASCTIME_R_AND_CTIME_R 1 + +/* Platform is an Intel Pentium microprocessor. */ +/* There is a problem with the gethrtime() because of (apparently) a problem + with the inline assembly instruction. Hopefully there is a way to resolve + that with an improvement to the assembler +*/ +#ifdef ACE_HAS_PENTIUM +#undef ACE_HAS_PENTIUM +#endif /* ACE_HAS_PENTIUM */ + + +/* Platform contains */ +#define ACE_HAS_POLL 1 + +/* Platform supports POSIX O_NONBLOCK semantics */ +#define ACE_HAS_POSIX_NONBLOCK 1 + +/* Platform supports the POSIX struct timespec type */ +#define ACE_HAS_POSIX_TIME 1 + +/* Platform supports the /proc file system and defines tid_t + in */ +#define ACE_HAS_PROC_FS 1 + +/* Platform supports POSIX Threads */ +#define ACE_HAS_PTHREADS 1 + +/* pthread.h declares an enum with PTHREAD_PROCESS_PRIVATE and + PTHREAD_PROCESS_SHARED values */ +#define ACE_HAS_PTHREAD_PROCESS_ENUM 1 + +/* Platform will recurse infinitely on thread exits from TSS cleanup routines + (e.g., AIX) */ +#define ACE_HAS_RECURSIVE_THR_EXIT_SEMANTICS 1 + +/* Platform supports reentrant functions (i.e., all the POSIX *_r + functions). */ +#define ACE_HAS_REENTRANT_FUNCTIONS 1 + +/* Platform has support for multi-byte character support compliant with the + XPG4 Worldwide Portability Interface wide-character classification. */ +#define ACE_HAS_XPG4_MULTIBYTE_CHAR 1 + +/* Platform does not support reentrant netdb functions (getprotobyname_r, + getprotobynumber_r, gethostbyaddr_r, gethostbyname_r, getservbyname_r). */ +#define ACE_LACKS_NETDB_REENTRANT_FUNCTIONS 1 + +/* Platform supports the POSIX regular expression library */ +#define ACE_HAS_REGEX 1 + +/* Platform has special header for select(). */ +#define ACE_HAS_SELECT_H 1 + +/* Platform has a function to set t_errno (e.g., Tandem). */ +#define ACE_HAS_SET_T_ERRNO 1 + +/* Platform supports SVR4 extended signals */ +#define ACE_HAS_SIGINFO_T 1 + +/* Platform/compiler has the sigwait(2) prototype */ +#define ACE_HAS_SIGWAIT 1 + +/* Compiler/platform defines the sig_atomic_t typedef */ +#define ACE_HAS_SIG_ATOMIC_T 1 + +/* Platform supports new BSD inet_addr len field. */ +#define ACE_HAS_SOCKADDR_IN_SIN_LEN 1 + +/* OS/compiler uses size_t * rather than int * for socket lengths */ +#define ACE_HAS_SIZET_SOCKET_LEN 1 + +/* Compiler/platform provides the sys/sockio.h file */ +#define ACE_HAS_SYS_SOCKIO_H 1 + +/* Compiler supports the ssize_t typedef */ +#define ACE_HAS_SSIZE_T 1 + +/* Platform supports UNIX International Threads */ +#define ACE_HAS_STHREADS 1 + +/* Platform has thr_yield() */ +#define ACE_HAS_THR_YIELD 1 + +/* Compiler/platform supports struct strbuf */ +#define ACE_HAS_STRBUF_T 1 + +/* Platform supports STREAMS */ +#define ACE_HAS_STREAMS 1 + +/* Platform supports STREAM pipes */ +#define ACE_HAS_STREAM_PIPES 1 + +/* Compiler/platform supports strerror () */ +#define ACE_HAS_STRERROR 1 + +/* Platform/Compiler supports a String class (e.g., GNU or Win32). */ +#define ACE_HAS_STRING_CLASS 1 + +/* Platform has (which contains bzero() prototype) */ +#define ACE_HAS_STRINGS 1 + +/* Platform/compiler supports void * as second parameter to gettimeofday(). */ +#define ACE_HAS_VOIDPTR_GETTIMEOFDAY 1 + +/* Compiler/platform supports SVR4 dynamic linking semantics */ +#define ACE_HAS_SVR4_DYNAMIC_LINKING 1 + +/* Compiler/platform supports SVR4 TLI (in particular, T_GETNAME stuff)... */ +#define ACE_HAS_SVR4_TLI 1 + +/* Compiler/platform contains the file. */ +#define ACE_HAS_SYS_SYSCALL_H 1 + +/* Platform supports system configuration information */ +#define ACE_HAS_SYS_SYSTEMINFO_H +#define ACE_HAS_SYSINFO 1 + +/* Platform supports System V IPC (most versions of UNIX, but not Win32) */ +#define ACE_HAS_SYSV_IPC 1 + +/* Platform provides header */ +#define ACE_HAS_SYS_FILIO_H 1 + +/* Platform provides header */ +#define ACE_HAS_SYS_XTI_H 1 + +/* Platform has POSIX terminal interface. */ +#define ACE_HAS_TERMIOS 1 + +/* Platform supports threads */ +#define ACE_HAS_THREADS 1 + +/* Compiler/platform has thread-specific storage */ +#define ACE_HAS_THREAD_SPECIFIC_STORAGE 1 + +/* Platform supports TLI timod STREAMS module */ +#define ACE_HAS_TIMOD_H 1 + +/* Platform supports TLI tiuser header */ +#define ACE_HAS_TIUSER_H 1 + +/* Platform supports TLI. Also see ACE_TLI_TCP_DEVICE. */ +#define ACE_HAS_TLI 1 + +/* Platform provides TLI function prototypes */ +#define ACE_HAS_TLI_PROTOTYPES 1 + +/* Platform supports ualarm() */ +#define ACE_HAS_UALARM 1 + +/* Platform supports ucontext_t (which is used in the extended signal API). */ +#define ACE_HAS_UCONTEXT_T 1 + +/* Platform has header file */ +#define ACE_HAS_UTIME 1 + +/* Platform requires void * for mmap(). */ +#define ACE_HAS_VOIDPTR_MMAP 1 + +/* Platform has XTI (X/Open-standardized superset of TLI). Implies + ACE_HAS_TLI but uses a different header file. */ +#define ACE_HAS_XTI 1 + +/* Platform can not build ace/IOStream{,_T}.cpp. This does not necessarily + mean that the platform does not support iostreams. */ +#define ACE_LACKS_ACE_IOSTREAM 1 + +/* Platform does not have u_longlong_t typedef */ +#define ACE_LACKS_U_LONGLONG_T 1 + +/* Platform lacks madvise() (e.g., Linux) */ +#define ACE_LACKS_MADVISE 1 + +/* Platform lacks pri_t (e.g., Tandem NonStop UNIX). */ +#define ACE_LACKS_PRI_T 1 + +/* Platform lacks pthread_thr_sigsetmask (e.g., MVS, HP/UX, and OSF/1 3.2) */ +#define ACE_LACKS_PTHREAD_THR_SIGSETMASK 1 + +/* Platfrom lack pthread_yield() support. */ +#define ACE_LACKS_PTHREAD_YIELD 1 + +/* Platform lacks readers/writer locks. */ +#define ACE_LACKS_RWLOCK_T 1 + +/* MIT pthreads platform lacks the timedwait prototypes */ +#define ACE_LACKS_TIMEDWAIT_PROTOTYPES 1 + +/* Platform does not define timepec_t as a typedef for struct timespec. */ +#define ACE_LACKS_TIMESPEC_T 1 + +/* Compile using multi-thread libraries */ +#define ACE_MT_SAFE 1 + +/* Platform needs to #include to get thread scheduling defs. */ +#define ACE_NEEDS_SCHED_H 1 + +/*********************************************************************/ +/* Compiler's template mechanim must see source code (i.e., .cpp files). This + is used for GNU G++. */ +/* Staller -> make 0 */ +// #undef ACE_TEMPLATES_REQUIRE_SOURCE + +/*********************************************************************/ + +/* The OS/platform supports the poll() event demultiplexor */ +#define ACE_USE_POLL 1 + +/* Platform has its standard c++ library in the namespace std. */ +#define ACE_USES_STD_NAMESPACE_FOR_STDCPP_LIB 1 + +/* The number of bytes in a double. */ +#define SIZEOF_DOUBLE 8 + +/* The number of bytes in a float. */ +#define SIZEOF_FLOAT 4 + +/* The number of bytes in a int. */ +#define SIZEOF_INT 4 + +/* The number of bytes in a long. */ +#define SIZEOF_LONG 4 + +/* The number of bytes in a long double. */ +#define SIZEOF_LONG_DOUBLE 12 + +/* The number of bytes in a long long. */ +#define SIZEOF_LONG_LONG 8 + +/* The number of bytes in a short. */ +#define SIZEOF_SHORT 2 + +/* The number of bytes in a signed char. */ +#define SIZEOF_SIGNED_CHAR 1 + +/* The number of bytes in a void *. */ +#define SIZEOF_VOID_P 4 + +/* Define if you have the execv function. */ +#define HAVE_EXECV 1 + +/* Define if you have the execve function. */ +#define HAVE_EXECVE 1 + +/* Define if you have the execvp function. */ +#define HAVE_EXECVP 1 + +/* Define if you have the header file. */ +#define HAVE_DIRENT_H 1 + +/* Define if you have the header file. */ +#define HAVE_FSTREAM 1 + +/* Define if you have the header file. */ +#define HAVE_IOMANIP 1 + +/* Define if you have the header file. */ +#define HAVE_IOSTREAM 1 + +/* Define if you have the header file. */ +#define HAVE_PWD_H 1 + +/* Name of package */ +#define PACKAGE "ace" + +/* Added by Staller */ +#define ENUM_BOOLEAN // See file /usr/local/lib/gcc-lib/i486-pc-sysv5/egcs-2.91.60/include/sys/types.h +#define howmany(x, y) (((x)+((y)-1))/(y)) +#define ACE_HAS_BROKEN_T_ERROR // make a nasty warning disappear in OS.i +#define __USLC__ 1 +#define __IOCTL_VERSIONED__ // By Carlo! + +#endif /* ACE_CONFIG_H */ diff --git a/dep/ACE_wrappers/ace/config-unixware-7.1.0.udk.h b/dep/ACE_wrappers/ace/config-unixware-7.1.0.udk.h new file mode 100644 index 00000000000..477130d3d2d --- /dev/null +++ b/dep/ACE_wrappers/ace/config-unixware-7.1.0.udk.h @@ -0,0 +1,460 @@ +/* -*- C++ -*- */ +#ifndef ACE_CONFIG_UNIXWARE_UDK_H +#define ACE_CONFIG_UNIXWARE_UDK_H + +// $Id: config-unixware-7.1.0.udk.h 82267 2008-07-08 16:39:19Z jtc $ + +// Configuration for the unixware UDK compiler. derived from the unixware/g++ config +// which was itself derived from an autoconfig run. + +/* ACE configuration header file */ + +#define ACE_TEMPLATES_REQUIRE_SOURCE + +#ifndef UNIXWARE_7_1 +#define UNIXWARE_7_1 +#endif + +#define ACE_LACKS_PLACEMENT_OPERATOR_DELETE + +/* Define if you have the strftime function. */ +#define HAVE_STRFTIME 1 + +/* Define if you have that is POSIX.1 compatible. */ +#define HAVE_SYS_WAIT_H 1 + +/* Define if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* Define if lex declares yytext as a char * by default, not a char[]. */ +#define YYTEXT_POINTER 1 + +/* Define _REENTRANT if reentrant functions should be used. */ +#ifndef _REENTRANT +# define _REENTRANT 1 +#endif + +#define ACE_HAS_NEW_NO_H 1 +#define ACE_HAS_STDEXCEPT_NO_H 1 + +/* + * TODO: These two next #defines have an #undef before them, in + * case the variable being defined already had a value. + * The #undefs are being picked up by configure, and are commented out! + */ +#define ACE_THREAD_MIN_PRIORITY 0 +#if defined (ACE_THREAD_MIN_PRIORITY) +/* # undef PTHREAD_MIN_PRIORITY */ +# define PTHREAD_MIN_PRIORITY ACE_THREAD_MIN_PRIORITY +#endif /* #if defined (ACE_THREAD_MIN_PRIORITY) */ + +#define ACE_THREAD_MAX_PRIORITY 99 +#if defined (ACE_THREAD_MAX_PRIORITY) +/* # undef PTHREAD_MAX_PRIORITY */ +# define PTHREAD_MAX_PRIORITY ACE_THREAD_MAX_PRIORITY +#endif /* #if defined (ACE_THREAD_MAX_PRIORITY) */ + + + +/* UnixWare specific configuration parameters */ +/* #undef UNIXWARE */ +/* #undef UNIXWARE_2_0 */ +/* #undef UNIXWARE_2_1 */ + +/* Specify sizes of given built-in types. If a size isn't defined here, + then ace/Basic_Types.h will attempt to deduce the size. */ +/* #undef ACE_SIZEOF_CHAR */ +#define ACE_SIZEOF_SHORT 2 +#define ACE_SIZEOF_INT 4 +#define ACE_SIZEOF_LONG 4 +#define ACE_SIZEOF_LONG_LONG 8 +#define ACE_SIZEOF_VOID_P 4 +#define ACE_SIZEOF_FLOAT 4 +#define ACE_SIZEOF_DOUBLE 8 +#define ACE_SIZEOF_LONG_DOUBLE 12 + +/* Enable ACE inlining */ +#define __ACE_INLINE__ 1 + +/* Platform supports Asynchronous IO calls */ +/* #define ACE_HAS_AIO_CALLS */ + +/* Specify this if you don't want threads to inherit parent thread's + ACE_Log_Msg properties. */ +/* #undef ACE_THREADS_DONT_INHERIT_LOG_MSG */ + +/* OS has priocntl (2) */ +#define ACE_HAS_PRIOCNTL 1 + +/* Platform has pread() and pwrite() support */ +#define ACE_HAS_P_READ_WRITE 1 + +/* Compiler/platform correctly calls init()/fini() for shared libraries */ +#define ACE_HAS_AUTOMATIC_INIT_FINI 1 + +/* Compiler handles explicit calling of template destructor correctly. + See "ace/OS.h" for details. */ +/* Staller: already defined by config-g++-common.h +#define ACE_HAS_WORKING_EXPLICIT_TEMPLATE_DESTRUCTOR 1 +*/ + +/* Platform doesn't cast MAP_FAILED to a (void *). */ +/* #undef ACE_HAS_BROKEN_MAP_FAILED */ +/* Staller: oh yes, let's do this! */ +#define ACE_HAS_BROKEN_MAP_FAILED + + +/* Prototypes for both signal() and struct sigaction are consistent. */ +#define ACE_HAS_CONSISTENT_SIGNAL_PROTOTYPES 1 + +/* Compiler/platform has correctly prototyped header files */ +#define ACE_HAS_CPLUSPLUS_HEADERS + +/* Platform supports operations on directories via struct dirent, + readdir_r, etc. */ +#define ACE_HAS_DIRENT + +/* Compiler supports C++ exception handling */ +# if !defined (ACE_HAS_EXCEPTIONS) +#define ACE_HAS_EXCEPTIONS +# endif + +/* Platform supports getpagesize() call (otherwise, ACE_PAGE_SIZE must be + defined, except on Win32) */ +#define ACE_HAS_GETPAGESIZE + +/* Platform supports the getrusage() system call. */ +#define ACE_HAS_GETRUSAGE + +/* Platform has a getrusage () prototype in sys/resource.h that differs from + the one in ace/OS.i. */ +#define ACE_HAS_GETRUSAGE_PROTOTYPE + +/* The GPERF utility is compiled for this platform */ +#define ACE_HAS_GPERF + +/* Optimize ACE_Handle_Set::count_bits for select() operations (common case) */ +#define ACE_HAS_HANDLE_SET_OPTIMIZED_FOR_SELECT 1 + +/* Compiler/platform supports SunOS high resolution timers */ +/* #undef ACE_HAS_HI_RES_TIMER */ + +/* Compiler/platform supports idtype_t. */ +#define ACE_HAS_IDTYPE_T + +/* Inline all the static class OS methods to remove call overhead */ +/* Note: This gets defined by OS.h if __ACE_INLINE__ is defined */ +/* #undef ACE_HAS_INLINED_OSCALLS */ + +/* Platform supports IP multicast */ +#define ACE_HAS_IP_MULTICAST + +/* Platform supports thr_keydelete (e.g,. UNIXWARE) */ +#define ACE_HAS_THR_KEYDELETE + +/* Platform calls thr_minstack() rather than thr_min_stack() (e.g., Tandem). */ +#define ACE_HAS_THR_MINSTACK + +/* Some files, such as ace/streams.h, want to include new style C++ stream + headers. These headers are iomanip, ios, iostream, istream, ostream, + fstream and streambuf. If _all_ of these headers aren't available, then + assume that only iostream.h and fstream.h are available. */ +/* #define ACE_USES_OLD_IOSTREAMS */ + +/* Platform supports recvmsg and sendmsg */ +#define ACE_HAS_MSG + +/* Platform's select() uses non-const timeval* (only found on Linux right + now) */ +#define ACE_HAS_NONCONST_SELECT_TIMEVAL + +/* Uses ctime_r & asctime_r with only two parameters vs. three. */ +#define ACE_HAS_2_PARAM_ASCTIME_R_AND_CTIME_R + + +/* Platform is an Intel Pentium microprocessor. */ +/* There is a problem with the gethrtime() because of (apparently) a problem + with the inline assembly instruction. Hopefully there is a way to resolve + that with an improvement to the assembler +*/ +#ifdef ACE_HAS_PENTIUM +//#undef ACE_HAS_PENTIUM +#endif /* ACE_HAS_PENTIUM */ + + +/* Platform contains */ +#define ACE_HAS_POLL + +/* Platform supports POSIX O_NONBLOCK semantics */ +#define ACE_HAS_POSIX_NONBLOCK + +/* Platform supports the POSIX struct timespec type */ +#define ACE_HAS_POSIX_TIME + +/* Platform supports the /proc file system and defines tid_t + in */ +#define ACE_HAS_PROC_FS + +/* Platform supports POSIX Threads */ +#define ACE_HAS_PTHREADS + +/* pthread.h declares an enum with PTHREAD_PROCESS_PRIVATE and + PTHREAD_PROCESS_SHARED values */ +#define ACE_HAS_PTHREAD_PROCESS_ENUM + +/* Platform will recurse infinitely on thread exits from TSS cleanup routines + (e.g., AIX) */ +#define ACE_HAS_RECURSIVE_THR_EXIT_SEMANTICS + +/* Platform supports reentrant functions (i.e., all the POSIX *_r + functions). */ +#define ACE_HAS_REENTRANT_FUNCTIONS + +/* Platform has support for multi-byte character support compliant with the + XPG4 Worldwide Portability Interface wide-character classification. */ +#define ACE_HAS_XPG4_MULTIBYTE_CHAR + +/* Platform does not support reentrant netdb functions (getprotobyname_r, + getprotobynumber_r, gethostbyaddr_r, gethostbyname_r, getservbyname_r). */ +#define ACE_LACKS_NETDB_REENTRANT_FUNCTIONS + +/* Platform supports the POSIX regular expression library */ +#define ACE_HAS_REGEX + +/* Platform has special header for select(). */ +#define ACE_HAS_SELECT_H + +/* Platform has a function to set t_errno (e.g., Tandem). */ +#define ACE_HAS_SET_T_ERRNO + +/* Platform supports SVR4 extended signals */ +#define ACE_HAS_SIGINFO_T + +/* Platform/compiler has the sigwait(2) prototype */ +#define ACE_HAS_SIGWAIT + +/* Compiler/platform defines the sig_atomic_t typedef */ +#define ACE_HAS_SIG_ATOMIC_T + +/* Platform supports new BSD inet_addr len field. */ +#define ACE_HAS_SOCKADDR_IN_SIN_LEN + +/* OS/compiler uses size_t * rather than int * for socket lengths */ +#define ACE_HAS_SIZET_SOCKET_LEN + +/* Compiler/platform provides the sys/sockio.h file */ +#define ACE_HAS_SYS_SOCKIO_H + +/* Compiler supports the ssize_t typedef */ +#define ACE_HAS_SSIZE_T + +/* Platform supports UNIX International Threads */ +#define ACE_HAS_STHREADS + +/* Platform has thr_yield() */ +#define ACE_HAS_THR_YIELD + +/* Platform/compiler supports Standard C++ Library */ +/* It seems that UDK provides std-like declarations for only portions + such as +*/ +#define ACE_HAS_STANDARD_CPP_LIBRARY 0 + +/* Compiler/platform supports struct strbuf */ +#define ACE_HAS_STRBUF_T + +/* Platform supports STREAMS */ +#define ACE_HAS_STREAMS + +/* Platform supports STREAM pipes */ +#define ACE_HAS_STREAM_PIPES + +/* Compiler/platform supports strerror () */ +#define ACE_HAS_STRERROR + +/* Platform/Compiler supports a String class (e.g., GNU or Win32). */ +#define ACE_HAS_STRING_CLASS + +/* Platform has (which contains bzero() prototype) */ +#define ACE_HAS_STRINGS + +/* Platform/compiler supports void * as second parameter to gettimeofday(). */ +#define ACE_HAS_VOIDPTR_GETTIMEOFDAY + +/* Compiler/platform supports SVR4 dynamic linking semantics */ +#define ACE_HAS_SVR4_DYNAMIC_LINKING + +/* Compiler/platform supports SVR4 TLI (in particular, T_GETNAME stuff)... */ +#define ACE_HAS_SVR4_TLI + +/* Compiler/platform contains the file. */ +#define ACE_HAS_SYS_SYSCALL_H + +/* Platform supports system configuration information */ +#define ACE_HAS_SYS_SYSTEMINFO_H +#define ACE_HAS_SYSINFO 1 + +/* Platform supports System V IPC (most versions of UNIX, but not Win32) */ +#define ACE_HAS_SYSV_IPC 1 + +/* Platform provides header */ +#define ACE_HAS_SYS_FILIO_H 1 + +/* Platform provides header */ +#define ACE_HAS_SYS_XTI_H 1 + +/* Compiler implements templates that support typedefs inside of classes used + as formal arguments to a template class. */ +#define ACE_HAS_TEMPLATE_TYPEDEFS 1 + +/* Platform has POSIX terminal interface. */ +#define ACE_HAS_TERMIOS 1 + +/* Platform supports threads */ +#define ACE_HAS_THREADS 1 + +/* Compiler/platform has thread-specific storage */ +#define ACE_HAS_THREAD_SPECIFIC_STORAGE 1 + +/* Platform supports TLI timod STREAMS module */ +#define ACE_HAS_TIMOD_H 1 + +/* Platform supports TLI tiuser header */ +#define ACE_HAS_TIUSER_H 1 + +/* Platform supports TLI. Also see ACE_TLI_TCP_DEVICE. */ +#define ACE_HAS_TLI 1 + +/* Platform provides TLI function prototypes */ +#define ACE_HAS_TLI_PROTOTYPES 1 + +/* Platform supports ualarm() */ +#define ACE_HAS_UALARM 1 + +/* Platform supports ucontext_t (which is used in the extended signal API). */ +#define ACE_HAS_UCONTEXT_T 1 + +/* Platform has header file */ +#define ACE_HAS_UTIME 1 + +/* Prints out console message in ACE_NOTSUP. Useful for tracking down origin + of ACE_NOTSUP. */ +/* #undef ACE_HAS_VERBOSE_NOTSUP */ + +/* Platform requires void * for mmap(). */ +#define ACE_HAS_VOIDPTR_MMAP 1 + +/* Platform has XTI (X/Open-standardized superset of TLI). Implies + ACE_HAS_TLI but uses a different header file. */ +#define ACE_HAS_XTI 1 + +/* Platform can not build ace/IOStream{,_T}.cpp. This does not necessarily + mean that the platform does not support iostreams. */ +#define ACE_LACKS_ACE_IOSTREAM 1 + +/* Platform does not have u_longlong_t typedef */ +#define ACE_LACKS_U_LONGLONG_T 1 + +/* Platform lacks madvise() (e.g., Linux) */ +#define ACE_LACKS_MADVISE 1 + +/* Platform lacks pri_t (e.g., Tandem NonStop UNIX). */ +#define ACE_LACKS_PRI_T 1 + +/* Platform lacks pthread_thr_sigsetmask (e.g., MVS, HP/UX, and OSF/1 3.2) */ +#define ACE_LACKS_PTHREAD_THR_SIGSETMASK 1 + +/* Platfrom lack pthread_yield() support. */ +#define ACE_LACKS_PTHREAD_YIELD 1 + +/* Platform lacks readers/writer locks. */ +#define ACE_LACKS_RWLOCK_T 1 + +/* MIT pthreads platform lacks the timedwait prototypes */ +#define ACE_LACKS_TIMEDWAIT_PROTOTYPES 1 + +/* Platform does not define timepec_t as a typedef for struct timespec. */ +#define ACE_LACKS_TIMESPEC_T 1 + +/* Compile using multi-thread libraries */ +#define ACE_MT_SAFE 1 + +/* Platform needs to #include to get thread scheduling defs. */ +#define ACE_NEEDS_SCHED_H 1 + +/* The OS/platform supports the poll() event demultiplexor */ +#define ACE_USE_POLL 1 + +/* Platform has its standard c++ library in the namespace std. */ +#define ACE_USES_STD_NAMESPACE_FOR_STDCPP_LIB 1 + +/* The number of bytes in a double. */ +#define SIZEOF_DOUBLE 8 + +/* The number of bytes in a float. */ +#define SIZEOF_FLOAT 4 + +/* The number of bytes in a int. */ +#define SIZEOF_INT 4 + +/* The number of bytes in a long. */ +#define SIZEOF_LONG 4 + +/* The number of bytes in a long double. */ +#define SIZEOF_LONG_DOUBLE 12 + +/* The number of bytes in a long long. */ +#define SIZEOF_LONG_LONG 8 + +/* The number of bytes in a short. */ +#define SIZEOF_SHORT 2 + +/* The number of bytes in a signed char. */ +#define SIZEOF_SIGNED_CHAR 1 + +/* The number of bytes in a void *. */ +#define SIZEOF_VOID_P 4 + +/* Define if you have the execv function. */ +#define HAVE_EXECV 1 + +/* Define if you have the execve function. */ +#define HAVE_EXECVE 1 + +/* Define if you have the execvp function. */ +#define HAVE_EXECVP 1 + +/* Define if you have the header file. */ +#define HAVE_DIRENT_H 1 + +/* Define if you have the header file. */ +#define HAVE_FSTREAM 1 + +/* Define if you have the header file. */ +#define HAVE_IOMANIP 1 + +/* Define if you have the header file. */ +#define HAVE_IOSTREAM 1 + +/* Define if you have the header file. */ +#define HAVE_PWD_H 1 + +/* Name of package */ +#define PACKAGE "ace" + +/* Version number of package */ +#define VERSION "4.6.37" + +/* Added by Staller */ +#define ENUM_BOOLEAN // See file /usr/local/lib/gcc-lib/i486-pc-sysv5/egcs-2.91.60/include/sys/types.h +/* Hat nix gebracht +#define ACE_DEFAULT_SELECT_REACTOR_SIZE 256 // this is like in linux config fileto avoid another error +*/ +#define howmany(x, y) (((x)+((y)-1))/(y)) +#define ACE_HAS_BROKEN_T_ERROR // let disappear a nasty warning from OS.i +#if !defined (__USLC__) +# define __USLC__ 1 +#endif + +#define __IOCTL_VERSIONED__ // By Carlo! +#endif /* ACE_UNIXWARE_UDK_H */ diff --git a/dep/ACE_wrappers/ace/config-visualage.h b/dep/ACE_wrappers/ace/config-visualage.h new file mode 100644 index 00000000000..4cef8108bc5 --- /dev/null +++ b/dep/ACE_wrappers/ace/config-visualage.h @@ -0,0 +1,20 @@ +/* -*- C++ -*- */ +// $Id: config-visualage.h 80826 2008-03-04 14:51:23Z wotte $ + +// This configuration file automatically includes the proper +// configurations for IBM's VisualAge C++ compiler on Win32 and AIX. + +#ifndef CONFIG_VISUALAGE_H +#define CONFIG_VISUALAGE_H +#include /**/ "ace/pre.h" + +#ifdef __TOS_WIN__ + #include "ace/config-win32.h" +#elif __TOS_AIX__ + #include "ace/config-aix-4.x.h" +#else + #include "PLATFORM NOT SPECIFIED" +#endif /* __TOS_WIN__ */ + +#include /**/ "ace/post.h" +#endif //CONFIG_VISUALAGE_H diff --git a/dep/ACE_wrappers/ace/config-vxworks.h b/dep/ACE_wrappers/ace/config-vxworks.h new file mode 100644 index 00000000000..bb6ed5796d5 --- /dev/null +++ b/dep/ACE_wrappers/ace/config-vxworks.h @@ -0,0 +1,55 @@ +//* -*- C++ -*- */ +// $Id: config-vxworks.h 81046 2008-03-21 10:11:12Z johnnyw $ + +// The following configuration file is designed to work for VxWorks +// Based on ACE_VXWORKS it will select the correct config file + +#ifndef ACE_CONFIG_VXWORKS_H +#define ACE_CONFIG_VXWORKS_H +#include /**/ "ace/pre.h" + +// If ACE_VXWORKS is not defined try to figure out the VxWorks version +#if !defined (ACE_VXWORKS) +# include "vxWorks.h" +# if !defined (_WRS_VXWORKS_MAJOR) && !defined (_WRS_VXWORKS_MINOR) +# error You must define ACE_VXWORKS +# else +# if (_WRS_VXWORKS_MAJOR == 6) +# if (_WRS_VXWORKS_MINOR == 0) +# define ACE_VXWORKS 0x600 +# elif (_WRS_VXWORKS_MINOR == 1) +# define ACE_VXWORKS 0x610 +# elif (_WRS_VXWORKS_MINOR == 2) +# define ACE_VXWORKS 0x620 +# elif (_WRS_VXWORKS_MINOR == 3) +# define ACE_VXWORKS 0x630 +# elif (_WRS_VXWORKS_MINOR == 4) +# define ACE_VXWORKS 0x640 +# elif (_WRS_VXWORKS_MINOR == 5) +# define ACE_VXWORKS 0x650 +# elif (_WRS_VXWORKS_MINOR == 6) +# define ACE_VXWORKS 0x660 +# endif +# endif +# endif +#endif /* ! ACE_VXWORKS */ + +#if (ACE_VXWORKS == 0x551) +# include "ace/config-vxworks5.x.h" +#elif (ACE_VXWORKS == 0x620) +# include "ace/config-vxworks6.2.h" +#elif (ACE_VXWORKS == 0x630) +# include "ace/config-vxworks6.3.h" +#elif (ACE_VXWORKS == 0x640) +# include "ace/config-vxworks6.4.h" +#elif (ACE_VXWORKS == 0x650) +# include "ace/config-vxworks6.5.h" +#elif (ACE_VXWORKS == 0x660) +# include "ace/config-vxworks6.6.h" +#else +#error Unknown VxWorks version +#endif + +#include /**/ "ace/post.h" +#endif /* ACE_CONFIG_VXWORKS_H */ + diff --git a/dep/ACE_wrappers/ace/config-vxworks5.x.h b/dep/ACE_wrappers/ace/config-vxworks5.x.h new file mode 100644 index 00000000000..a13ce4720d1 --- /dev/null +++ b/dep/ACE_wrappers/ace/config-vxworks5.x.h @@ -0,0 +1,345 @@ +/* -*- C++ -*- */ +// $Id: config-vxworks5.x.h 81850 2008-06-06 08:39:54Z vzykov $ + +// The following configuration file is designed to work for VxWorks +// 5.5.x platforms using one of these compilers: +// 1) The GNU g++ compiler that is shipped with Tornado 2.2 or newer. +// 2) The Green Hills 1.8.8 and newer 1.8.9 compilers (not tested +// already for a long time) +// 3) The WindRiver Compiler (formerly known as Diab) + +#ifndef ACE_CONFIG_H +#define ACE_CONFIG_H +#include /**/ "ace/pre.h" + +#if ! defined (VXWORKS) +# define VXWORKS +#endif /* ! VXWORKS */ + +#if ! defined (ACE_VXWORKS) +# define ACE_VXWORKS 0x551 +#endif /* ! ACE_VXWORKS */ + +#if ! defined (__ACE_INLINE__) +# define __ACE_INLINE__ +#endif /* ! __ACE_INLINE__ */ + +// Compiler-specific configuration. +#if defined (__GNUG__) +# include "ace/config-g++-common.h" + +# define ACE_LACKS_IOSTREAM_FX + +# if !defined (ACE_MAIN) +# define ACE_MAIN ace_main +# endif /* ! ACE_MAIN */ + +# define ACE_LACKS_LINEBUFFERED_STREAMBUF + +# if (__GNUC__ == 2) +# define ACE_CDR_IMPLEMENT_WITH_NATIVE_DOUBLE 1 +# endif + +# if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3)) + // GNU 3.3+ toolchain supports long long types but fails to define this so STL + // skips some definitions +# if !defined (_GLIBCPP_USE_LONG_LONG) +# define _GLIBCPP_USE_LONG_LONG +# endif +# endif /* (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3)) */ + +#elif defined (ghs) + // Processor type, if necessary. Green Hills defines "ppc". +# if defined (ppc) +# define ACE_HAS_POWERPC_TIMER +# define ACE_LACKS_CLEARERR +# endif /* ppc */ + +# define ACE_CONFIG_INCLUDE_GHS_COMMON +# include "ace/config-ghs-common.h" + +# define ACE_LACKS_UNISTD_H +# define ACE_LACKS_IOSTREAM_TOTALLY + +// Short-circuit the include of +// Green Hills has a problem with multiply defined functions +// with different parameters. +# define __INCineth + +#elif defined (__DCPLUSPLUS__) || defined (__DCC__) + // Diab 4.2a or later. +# if !defined (ACE_LACKS_PRAGMA_ONCE) + // We define it with a -D with make depend. +# define ACE_LACKS_PRAGMA_ONCE +# endif /* ! ACE_LACKS_PRAGMA_ONCE */ + + // Diab doesn't support VxWorks' iostream libraries. +# define ACE_LACKS_IOSTREAM_TOTALLY +# define ACE_LACKS_ACE_IOSTREAM + +# define ACE_HAS_STANDARD_CPP_LIBRARY 1 +# define ACE_USES_STD_NAMESPACE_FOR_STDCPP_LIB 0 + +# define ACE_TEMPLATES_REQUIRE_SOURCE + +#else /* ! __GNUG__ && ! ghs && !__DCC__ */ +# ifdef __cplusplus /* Let it slide for C compilers. */ +# error unsupported compiler on VxWorks +# endif /* __cplusplus */ +#endif /* ! __GNUG__ && ! ghs */ + +// OS-specific configuration +#define ACE_HAS_4_4BSD_SENDMSG_RECVMSG +#define ACE_HAS_SIZET_PTR_ASCTIME_R_AND_CTIME_R +#define ACE_MKDIR_LACKS_MODE +#define ACE_HAS_NONCONST_GETBY +#define ACE_HAS_NONCONST_STAT +#define ACE_HAS_NONCONST_SWAB +#define ACE_HAS_NONCONST_READV +#define ACE_HAS_NONCONST_CHDIR +#define ACE_HAS_NONCONST_UNLINK +#define ACE_HAS_NONCONST_OPENDIR +#define ACE_LACKS_UNIX_SYSLOG +#define ACE_DEFAULT_MAX_SOCKET_BUFSIZ 32768 +#define ACE_DEFAULT_THREAD_KEYS 16 +#define ACE_HAS_BROKEN_ACCEPT_ADDR +#define ACE_HAS_NONCONST_SENDMSG +#define ACE_HAS_NONCONST_WRITEV +#define ACE_HAS_CHARPTR_DL +#define ACE_HAS_CHARPTR_SOCKOPT +#define ACE_HAS_CLOCK_GETTIME +#define ACE_HAS_CLOCK_SETTIME +#define ACE_HAS_CONSISTENT_SIGNAL_PROTOTYPES +#define ACE_HAS_CPLUSPLUS_HEADERS +#define ACE_HAS_DIRENT +#define ACE_HAS_DLL 0 +#define ACE_HAS_HANDLE_SET_OPTIMIZED_FOR_SELECT +#define ACE_HAS_IOCTL_INT_3_PARAM +#define ACE_HAS_MSG +#define ACE_HAS_NONCONST_READV +#define ACE_HAS_NONCONST_SELECT_TIMEVAL +#define ACE_HAS_NONSTATIC_OBJECT_MANAGER +#define ACE_HAS_POSIX_NONBLOCK +#define ACE_HAS_POSIX_TIME +#define ACE_HAS_REENTRANT_FUNCTIONS +#define ACE_HAS_SIGINFO_T +#define ACE_HAS_SIGWAIT +#define ACE_HAS_SIG_ATOMIC_T +#define ACE_HAS_SOCKADDR_IN_SIN_LEN +#define ACE_HAS_SOCKADDR_IN6_SIN6_LEN +#define ACE_HAS_STRDUP_EMULATION +#define ACE_HAS_STRERROR +#define ACE_HAS_THREADS +#define ACE_LACKS_ALPHASORT +#define ACE_LACKS_ACCESS +#define ACE_LACKS_EXEC +#define ACE_LACKS_FCNTL +#define ACE_LACKS_FILELOCKS +#define ACE_LACKS_FORK +#define ACE_LACKS_FSYNC +#define ACE_LACKS_GETHOSTENT +#define ACE_LACKS_GETOPT +#define ACE_LACKS_GETPID +#define ACE_LACKS_GETPPID +#define ACE_LACKS_GETSERVBYNAME +#define ACE_LACKS_KEY_T +#define ACE_LACKS_LSTAT +#define ACE_LACKS_MADVISE +#define ACE_LACKS_MALLOC_H +#define ACE_LACKS_MEMORY_H +#define ACE_LACKS_MKFIFO +#define ACE_LACKS_MKTEMP +#define ACE_LACKS_MKSTEMP +#define ACE_LACKS_MMAP +#define ACE_LACKS_MPROTECT +#define ACE_LACKS_MSYNC +#define ACE_LACKS_NUMERIC_LIMITS +#define ACE_LACKS_GETPROTOBYNAME +#define ACE_LACKS_GETPROTOBYNUMBER +#define ACE_LACKS_GETHOSTBYADDR +#define ACE_LACKS_GETHOSTBYNAME +#define ACE_LACKS_NETDB_REENTRANT_FUNCTIONS +#define ACE_LACKS_SYS_PARAM_H +#define ACE_LACKS_PWD_FUNCTIONS +#define ACE_LACKS_RAND_REENTRANT_FUNCTIONS +#define ACE_LACKS_READDIR_R +#define ACE_LACKS_READLINK +#define ACE_LACKS_REALPATH +#define ACE_LACKS_RLIMIT +#define ACE_LACKS_RWLOCK_T +#define ACE_LACKS_SBRK +#define ACE_LACKS_SEEKDIR +#define ACE_LACKS_SEMBUF_T +#define ACE_LACKS_SIGINFO_H +#define ACE_LACKS_SI_ADDR +#define ACE_LACKS_SOCKETPAIR +#define ACE_LACKS_STRCASECMP +#define ACE_LACKS_STRRECVFD +#define ACE_LACKS_SYSCALL +#define ACE_LACKS_SYSCONF +#define ACE_LACKS_SYS_SYSCTL_H +#define ACE_LACKS_SYSV_SHMEM +#define ACE_LACKS_TELLDIR +#define ACE_LACKS_TEMPNAM +#define ACE_LACKS_TIMESPEC_T +#define ACE_LACKS_TRUNCATE +#define ACE_LACKS_UCONTEXT_H +#define ACE_LACKS_UMASK +#define ACE_LACKS_UTSNAME_T +#define ACE_LACKS_UNAME +#define ACE_LACKS_STRPTIME +#define ACE_LACKS_VSNPRINTF +#define ACE_LACKS_WAIT +#define ACE_LACKS_WAITPID +#define ACE_LACKS_DUP2 +#define ACE_LACKS_DUP +#define ACE_LACKS_SUSECONDS_T +#define ACE_LACKS_USECONDS_T +#define ACE_LACKS_INTPTR_T +#define ACE_PAGE_SIZE 4096 +#define ACE_THR_PRI_FIFO_DEF 101 +#define ACE_THR_PRI_OTHER_DEF ACE_THR_PRI_FIFO_DEF +#define ACE_HAS_SIGTIMEDWAIT +#define ACE_HAS_SIGSUSPEND +#if !defined (ACE_VXWORKS_SPARE) +# define ACE_VXWORKS_SPARE spare4 +#endif /* ! ACE_VXWORKS_SPARE */ + +#define ACE_LACKS_SETEGID +#define ACE_LACKS_SETPGID +#define ACE_LACKS_SETREGID +#define ACE_LACKS_SETREUID +#define ACE_LACKS_SETSID +#define ACE_LACKS_SETUID +#define ACE_LACKS_SETEUID +#define ACE_LACKS_GETEGID +#define ACE_LACKS_GETGID +#define ACE_LACKS_GETEUID +#define ACE_LACKS_GETUID +#define ACE_LACKS_SETGID +#define ACE_LACKS_GETPGID + +#define ACE_LACKS_PIPE +#define ACE_LACKS_STDINT_H +#define ACE_LACKS_INTTYPES_H +#define ACE_LACKS_UNISTD_H +#define ACE_LACKS_SYS_SELECT_H +#define ACE_LACKS_SYS_TIME_H +#define ACE_LACKS_SYS_RESOURCE_H +#define ACE_LACKS_DLFCN_H +#define ACE_LACKS_SYS_UIO_H +#define ACE_LACKS_SYS_IPC_H +#define ACE_LACKS_SYS_SEM_H +#define ACE_LACKS_STROPTS_H +#define ACE_LACKS_SYS_MSG_H +#define ACE_LACKS_WCHAR_H +#define ACE_LACKS_PWD_H +#define ACE_LACKS_SEARCH_H +#define ACE_LACKS_SYS_SHM_H +#define ACE_LACKS_STRINGS_H +#define ACE_LACKS_TERMIOS_H +#define ACE_LACKS_POLL_H +#define ACE_LACKS_WCTYPE_H + +// Not sure if these should always be defined. +#define ACE_LACKS_SYS_UN_H + +// Some string things +#define ACE_LACKS_WCSCAT +#define ACE_LACKS_WCSCHR +#define ACE_LACKS_WCSCMP +#define ACE_LACKS_WCSCPY +#define ACE_LACKS_WCSCSPN +#define ACE_LACKS_WCSLEN +#define ACE_LACKS_WCSNCAT +#define ACE_LACKS_WCSNCMP +#define ACE_LACKS_WCSNCPY +#define ACE_LACKS_WCSPBRK +#define ACE_LACKS_WCSRCHR +#define ACE_LACKS_WCSSPN +#define ACE_LACKS_WCSSTR +#define ACE_LACKS_WCSTOK +#define ACE_LACKS_TOWLOWER +#define ACE_LACKS_TOWUPPER +#define ACE_LACKS_ITOW +#define ACE_LACKS_WCSICMP +#define ACE_LACKS_WCSNICMP +#define ACE_LACKS_WCSTOD +#define ACE_LACKS_WCSTOL +#define ACE_LACKS_WCSTOUL +#define ACE_LACKS_WCSDUP +#define ACE_LACKS_STRTOULL +#define ACE_LACKS_WCSTOULL + +#define ACE_LACKS_SYMLINKS +#define ACE_LACKS_FGETWC +#define ACE_LACKS_FGETWS +#define ACE_LACKS_FPUTWS + +#if defined (ACE_HAS_VXWORKS551_PID) || (ACE_HAS_VXWORKS551_PCD) || (ACE_HAS_VXWORKS551_PNE) +# define ACE_HAS_VXWORKS551_MEDUSA +#endif + +#if defined (ACE_HAS_VXWORKS551_MEDUSA) +# define ACE_HAS_GETIFADDRS +#endif + +// It is possible to enable pthread support with VxWorks, when the user decides +// to use this, we need some more defines +#if defined ACE_HAS_PTHREADS +# define ACE_LACKS_CONDATTR_PSHARED +# define ACE_LACKS_MUTEXATTR_PSHARED +# define ACE_HAS_THREAD_SPECIFIC_STORAGE +# define ACE_HAS_POSIX_SEM +// Include this file, the sys/stat.h file shipped with VxWorks has old types +// and without this include we get a lot of compile errors. A TSR has been filed +// so that hopefully in the future we can zap this include +#include "types/vxTypesOld.h" +#else +# define ACE_HAS_VXTHREADS +# define ACE_LACKS_PTHREAD_H +# define ACE_LACKS_COND_T +// VxWorks has no recursive mutexes. This was set in the past but it doesn't +// work with the pthread support, so only set it for the time being when pthread +// is disabled +# define ACE_HAS_RECURSIVE_MUTEXES +// VxWorks does not have the pthread_mutex_timedlock operation, but there is +// an emulation for this when not using the pthread mapping +#define ACE_HAS_MUTEX_TIMEOUTS +#define ACE_HAS_TSS_EMULATION +#endif + +#if !defined (ACE_MT_SAFE) +# define ACE_MT_SAFE 1 +#endif + +// Needed include to get all VxWorks CPU types +#include "types/vxCpu.h" +#if (CPU == PENTIUM || CPU == PENTIUM2 || CPU == PENTIUM3 || CPU == PENTIUM4) +// If running an Intel Pentium the +// ACE_OS::gethrtime () can use the RDTSC instruction. +# define ACE_HAS_PENTIUM +#endif + +# if defined (TOOL) && (TOOL == gnu) +# if defined (CPU) && (CPU == PPC85XX || CPU == PPC604 || CPU == PPC603) +// These PPC's do lack log2 +# define ACE_LACKS_LOG2 +# endif +# endif + +#if !defined (ACE_NEEDS_HUGE_THREAD_STACKSIZE) +# define ACE_NEEDS_HUGE_THREAD_STACKSIZE 65536 +#endif /* ACE_NEEDS_HUGE_THREAD_STACKSIZE */ + +#if !defined (ACE_NTRACE) +# define ACE_NTRACE 1 +#endif /* ACE_NTRACE */ + +// By default, don't include RCS Id strings in object code. +#if !defined (ACE_USE_RCSID) +#define ACE_USE_RCSID 0 +#endif /* !ACE_USE_RCSID */ + +#include /**/ "ace/post.h" +#endif /* ACE_CONFIG_H */ diff --git a/dep/ACE_wrappers/ace/config-vxworks6.2.h b/dep/ACE_wrappers/ace/config-vxworks6.2.h new file mode 100644 index 00000000000..0d03b44cd50 --- /dev/null +++ b/dep/ACE_wrappers/ace/config-vxworks6.2.h @@ -0,0 +1,328 @@ +/* -*- C++ -*- */ +// $Id: config-vxworks6.2.h 81850 2008-06-06 08:39:54Z vzykov $ + +// The following configuration file is designed to work for VxWorks +// 6.2 platforms using one of these compilers: +// 1) The GNU g++ compiler that is shipped with VxWorks 6.2 + +#ifndef ACE_CONFIG_VXWORKS_6_2_H +#define ACE_CONFIG_VXWORKS_6_2_H +#include /**/ "ace/pre.h" + +#if ! defined (VXWORKS) +# define VXWORKS +#endif /* ! VXWORKS */ + +#if ! defined (ACE_VXWORKS) +# define ACE_VXWORKS 0x620 +#endif /* ! ACE_VXWORKS */ + +#if defined __RTP__ + // Fix wrong typedef in unistd.h (unsigned short) + #define _SUSECONDS_T + typedef long suseconds_t; +#endif +#include + +// Fix for including right typedef for pid_t in VxTypes.h (int) +#include + +#if ! defined (__ACE_INLINE__) +# define __ACE_INLINE__ +#endif /* ! __ACE_INLINE__ */ + +// Compiler-specific configuration. +#if defined (__GNUG__) +# include "ace/config-g++-common.h" + +# define ACE_LACKS_IOSTREAM_FX +# define ACE_LACKS_LINEBUFFERED_STREAMBUF + +# if defined (__RTP__) && !defined (_HAS_C9X) +// Workaround for the fact that under RTP the log2 method can't be used +// without this define set, see TSR560446 +# if !defined (_C99) +# define _C99 +# endif +# endif + +#elif defined (__DCPLUSPLUS__) || defined (__DCC__) + // Diab 4.2a or later. +# if !defined (ACE_LACKS_PRAGMA_ONCE) + // We define it with a -D with make depend. +# define ACE_LACKS_PRAGMA_ONCE +# endif /* ! ACE_LACKS_PRAGMA_ONCE */ + +# define ACE_HAS_STANDARD_CPP_LIBRARY 1 +# define ACE_USES_STD_NAMESPACE_FOR_STDCPP_LIB 1 +# define ACE_TEMPLATES_REQUIRE_SOURCE + +#else /* ! __GNUG__ && ! ghs && !__DCC__ */ +# ifdef __cplusplus /* Let it slide for C compilers. */ +# error unsupported compiler on VxWorks +# endif /* __cplusplus */ +#endif /* ! __GNUG__ && ! ghs */ + +#if !defined __RTP__ +# if defined (TOOL) && (TOOL == gnu) +# if defined (CPU) && (CPU == PPC85XX || CPU == PPC604 || CPU == PPC603) +// These PPC's do lack log2 in kernel mode +# define ACE_LACKS_LOG2 +# endif +# endif +#endif + +// OS-specific configuration +#define ACE_HAS_4_4BSD_SENDMSG_RECVMSG +#define ACE_HAS_NONCONST_GETBY +#define ACE_HAS_NONCONST_SWAB +#define ACE_HAS_NONCONST_READV +#define ACE_LACKS_UNIX_SYSLOG +#define ACE_DEFAULT_MAX_SOCKET_BUFSIZ 32768 +#define ACE_DEFAULT_THREAD_KEYS 16 +#define ACE_HAS_BROKEN_ACCEPT_ADDR +#define ACE_HAS_NONCONST_SENDMSG +#define ACE_HAS_NONCONST_WRITEV +#define ACE_HAS_CHARPTR_DL +#define ACE_HAS_CLOCK_GETTIME +#define ACE_HAS_CLOCK_SETTIME +#define ACE_HAS_CONSISTENT_SIGNAL_PROTOTYPES +#define ACE_HAS_CPLUSPLUS_HEADERS +#define ACE_HAS_DIRENT +#define ACE_HAS_DLL 0 +#define ACE_HAS_HANDLE_SET_OPTIMIZED_FOR_SELECT +#define ACE_HAS_IOCTL_INT_3_PARAM +#define ACE_HAS_MSG +#define ACE_HAS_NONCONST_READV +#define ACE_HAS_NONCONST_SELECT_TIMEVAL +#define ACE_HAS_NONSTATIC_OBJECT_MANAGER +#define ACE_HAS_POSIX_NONBLOCK +#define ACE_HAS_POSIX_TIME +#define ACE_HAS_REENTRANT_FUNCTIONS +#define ACE_HAS_SIGACTION_CONSTP2 +#define ACE_HAS_SIGINFO_T +#define ACE_HAS_SIGWAIT +#define ACE_HAS_SIG_ATOMIC_T +#define ACE_HAS_SOCKADDR_IN_SIN_LEN +#define ACE_HAS_SOCKADDR_IN6_SIN6_LEN +#define ACE_HAS_STRERROR +#define ACE_HAS_THREADS +#define ACE_HAS_SYSCTL +#define ACE_LACKS_ALPHASORT +#define ACE_LACKS_EXEC +#define ACE_LACKS_FILELOCKS +#define ACE_LACKS_FORK +#define ACE_LACKS_GETHOSTENT +#define ACE_LACKS_GETSERVBYNAME +#define ACE_LACKS_GETPROTOBYNAME +#define ACE_LACKS_GETPROTOBYNUMBER +#define ACE_LACKS_KEY_T +#define ACE_LACKS_LSTAT +#define ACE_LACKS_MADVISE +#define ACE_LACKS_MALLOC_H +#define ACE_LACKS_MEMORY_H +#define ACE_LACKS_MKFIFO +#define ACE_LACKS_MKTEMP +#define ACE_LACKS_MKSTEMP +#define ACE_LACKS_MMAP +#define ACE_LACKS_MPROTECT +#define ACE_LACKS_MSYNC +#define ACE_LACKS_NETDB_REENTRANT_FUNCTIONS +#define ACE_LACKS_SYS_PARAM_H +#define ACE_LACKS_PWD_FUNCTIONS +#define ACE_LACKS_READDIR_R +#define ACE_LACKS_READLINK +#define ACE_LACKS_REALPATH +#define ACE_LACKS_PIPE +#define ACE_LACKS_RLIMIT +#define ACE_LACKS_RWLOCK_T +#define ACE_LACKS_SBRK +#define ACE_LACKS_SEEKDIR +#define ACE_LACKS_SEMBUF_T +#define ACE_LACKS_SIGINFO_H +#define ACE_LACKS_SI_ADDR +#define ACE_LACKS_SOCKETPAIR +#define ACE_LACKS_STRRECVFD +#define ACE_LACKS_SYSV_SHMEM +#define ACE_LACKS_TELLDIR +#define ACE_LACKS_TEMPNAM +#define ACE_LACKS_TIMESPEC_T +#define ACE_LACKS_TRUNCATE +#define ACE_LACKS_UCONTEXT_H +#define ACE_LACKS_USECONDS_T +#define ACE_LACKS_UMASK +#define ACE_LACKS_STRPTIME +#define ACE_PAGE_SIZE 4096 +#define ACE_THR_PRI_FIFO_DEF 101 +#define ACE_THR_PRI_OTHER_DEF ACE_THR_PRI_FIFO_DEF +#define ACE_HAS_SIGTIMEDWAIT +#define ACE_HAS_SIGSUSPEND +#if !defined (ACE_VXWORKS_SPARE) +# define ACE_VXWORKS_SPARE spare4 +#endif /* ! ACE_VXWORKS_SPARE */ +#define ACE_HAS_GETIFADDRS + +#define ACE_LACKS_SETEGID +#define ACE_LACKS_SETPGID +#define ACE_LACKS_SETREGID +#define ACE_LACKS_SETREUID +#define ACE_LACKS_SETSID +#define ACE_LACKS_SETUID +#define ACE_LACKS_SETEUID +#define ACE_LACKS_GETEUID +#define ACE_LACKS_GETUID +#define ACE_LACKS_GETPGID +#define ACE_LACKS_GETEGID +#define ACE_LACKS_GETGID +#define ACE_LACKS_SETGID + +#define ACE_LACKS_SYS_UIO_H +#define ACE_LACKS_SYS_IPC_H +#define ACE_LACKS_SYS_SEM_H +#define ACE_LACKS_STROPTS_H +#define ACE_LACKS_SYS_MSG_H +#define ACE_LACKS_PWD_H +#define ACE_LACKS_SYS_SHM_H +#define ACE_LACKS_TERMIOS_H +#define ACE_LACKS_POLL_H +#define ACE_LACKS_FCNTL + +// Some string things +#define ACE_LACKS_STRCASECMP +#define ACE_LACKS_ITOW +#define ACE_LACKS_WCSDUP +#define ACE_LACKS_WCSICMP +#define ACE_LACKS_WCSNICMP +#define ACE_LACKS_STRTOULL +#define ACE_LACKS_WCSTOULL + +#define ACE_HAS_CHARPTR_SOCKOPT +#define ACE_LACKS_SYMLINKS + +#if defined __RTP__ + // We are building for RTP mode + #if !defined (ACE_AS_STATIC_LIBS) + # define ACE_HAS_SVR4_DYNAMIC_LINKING + #endif + #define ACE_HAS_2_PARAM_ASCTIME_R_AND_CTIME_R + #define ACE_LACKS_REGEX_H + #define ACE_LACKS_PUTENV + #define ACE_HAS_SETENV + #define ACE_HAS_3_PARAM_WCSTOK + #define ACE_HAS_WCHAR + #define ACE_HAS_VFWPRINTF + #define ACE_SIZEOF_WCHAR 2 +#else + // We are building for kernel mode + #define ACE_LACKS_INTPTR_T + #define ACE_LACKS_SUSECONDS_T + #define ACE_LACKS_INTTYPES_H + #define ACE_LACKS_STDINT_H + #define ACE_LACKS_UNAME + #define ACE_LACKS_UTSNAME_T + #define ACE_LACKS_RAND_REENTRANT_FUNCTIONS + #define ACE_LACKS_DLFCN_H + #define ACE_LACKS_WAIT + #define ACE_LACKS_WAITPID + #define ACE_LACKS_SYS_TIME_H + #define ACE_LACKS_SYS_SELECT_H + #define ACE_LACKS_STRINGS_H + #define ACE_MKDIR_LACKS_MODE + #define ACE_HAS_SIZET_PTR_ASCTIME_R_AND_CTIME_R + #define ACE_LACKS_SEARCH_H + #define ACE_LACKS_SYSCONF + #define ACE_LACKS_GETPID + #define ACE_LACKS_GETPPID + #define ACE_LACKS_WCHAR_H + #define ACE_LACKS_WCTYPE_H + #define ACE_LACKS_WCSCAT + #define ACE_LACKS_WCSCHR + #define ACE_LACKS_WCSCMP + #define ACE_LACKS_WCSCPY + #define ACE_LACKS_WCSCSPN + #define ACE_LACKS_WCSLEN + #define ACE_LACKS_WCSNCAT + #define ACE_LACKS_WCSNCMP + #define ACE_LACKS_WCSNCPY + #define ACE_LACKS_WCSPBRK + #define ACE_LACKS_WCSRCHR + #define ACE_LACKS_WCSSPN + #define ACE_LACKS_WCSSTR + #define ACE_LACKS_WCSTOK + #define ACE_LACKS_TOWLOWER + #define ACE_LACKS_TOWUPPER + #define ACE_LACKS_WCSTOD + #define ACE_LACKS_WCSTOL + #define ACE_LACKS_WCSTOUL + #define ACE_LACKS_FGETWC + #define ACE_LACKS_FGETWS + #define ACE_LACKS_FPUTWS + #if !defined (ACE_MAIN) + # define ACE_MAIN ace_main + #endif /* ! ACE_MAIN */ +#endif + +// It is possible to enable pthread support with VxWorks, when the user decides +// to use this, we need some more defines +#if defined ACE_HAS_PTHREADS +# define ACE_HAS_THREAD_SPECIFIC_STORAGE +# define ACE_HAS_POSIX_SEM +# define ACE_LACKS_MUTEXATTR_PSHARED +# define ACE_LACKS_CONDATTR_PSHARED +// Include this file, the sys/stat.h file shipped with VxWorks has old types +// and without this include we get a lot of compile errors. A TSR has been filed +// so that hopefully in the future we can zap this include +#include "types/vxTypesOld.h" +#else +# define ACE_LACKS_PTHREAD_H +# define ACE_HAS_VXTHREADS +# if !defined __RTP__ +// Only when building for kernel mode we can use TSS emulation, in rtp mode +// we can't use the WIND_TCB struct anymore +# define ACE_HAS_TSS_EMULATION +# endif +// VxWorks has no recursive mutexes. This was set in the past but it doesn't +// work with the pthread support, so only set it for the time being when pthread +// is disabled +# define ACE_HAS_RECURSIVE_MUTEXES +# define ACE_LACKS_COND_T +# define ACE_HAS_MUTEX_TIMEOUTS +#endif + +#if !defined (ACE_MT_SAFE) +# define ACE_MT_SAFE 1 +#endif + +// Needed include to get all VxWorks CPU types +#include "types/vxCpu.h" +#if (CPU == PENTIUM || CPU == PENTIUM2 || CPU == PENTIUM3 || CPU == PENTIUM4) +// If running an Intel Pentium the +// ACE_OS::gethrtime () can use the RDTSC instruction. +# define ACE_HAS_PENTIUM +#endif + +// VxWorks defines the CPU define MAP, undef it to prevent problems with +// application code +#if defined (MAP) +#undef MAP +#endif /* MAP */ + +#if !defined (ACE_NEEDS_HUGE_THREAD_STACKSIZE) +# define ACE_NEEDS_HUGE_THREAD_STACKSIZE 65536 +#endif /* ACE_NEEDS_HUGE_THREAD_STACKSIZE */ + +#if !defined (ACE_NTRACE) +# define ACE_NTRACE 1 +#endif /* ACE_NTRACE */ + +// By default, don't include RCS Id strings in object code. +#if !defined (ACE_USE_RCSID) +#define ACE_USE_RCSID 0 +#endif /* !ACE_USE_RCSID */ + +#if defined (ACE_HAS_IP_MULTICAST) +# define ACE_LACKS_PERFECT_MULTICAST_FILTERING 1 +#endif /* ACE_HAS_IP_MULTICAST */ + +#include /**/ "ace/post.h" +#endif /* ACE_CONFIG_VXWORKS_6_2_H */ diff --git a/dep/ACE_wrappers/ace/config-vxworks6.3.h b/dep/ACE_wrappers/ace/config-vxworks6.3.h new file mode 100644 index 00000000000..1b7cd4100c3 --- /dev/null +++ b/dep/ACE_wrappers/ace/config-vxworks6.3.h @@ -0,0 +1,317 @@ +/* -*- C++ -*- */ +// $Id: config-vxworks6.3.h 81850 2008-06-06 08:39:54Z vzykov $ + +// The following configuration file is designed to work for VxWorks +// 6.3 platforms using one of these compilers: +// 1) The GNU g++ compiler that is shipped with VxWorks 6.3 + +#ifndef ACE_CONFIG_VXWORKS_6_3_H +#define ACE_CONFIG_VXWORKS_6_3_H +#include /**/ "ace/pre.h" + +#if ! defined (VXWORKS) +# define VXWORKS +#endif /* ! VXWORKS */ + +#if ! defined (ACE_VXWORKS) +# define ACE_VXWORKS 0x630 +#endif /* ! ACE_VXWORKS */ + +#if ! defined (__ACE_INLINE__) +# define __ACE_INLINE__ +#endif /* ! __ACE_INLINE__ */ + +// Compiler-specific configuration. +#if defined (__GNUG__) +# include "ace/config-g++-common.h" + +# define ACE_LACKS_IOSTREAM_FX +# define ACE_LACKS_LINEBUFFERED_STREAMBUF + +# if defined (__RTP__) && !defined (_HAS_C9X) +// Workaround for the fact that under RTP the log2 method can't be used +// without this define set, see TSR560446 +# if !defined (_C99) +# define _C99 +# endif +# endif + +#elif defined (__DCC__) +# define ACE_HAS_STANDARD_CPP_LIBRARY 1 +# define ACE_TEMPLATES_REQUIRE_SOURCE +#else /* ! __GNUG__ && ! ghs && !__DCC__ */ +# ifdef __cplusplus /* Let it slide for C compilers. */ +# error unsupported compiler on VxWorks +# endif /* __cplusplus */ +#endif /* ! __GNUG__ && ! ghs */ + +#if !defined __RTP__ +# if defined (TOOL) && (TOOL == gnu) +# if defined (CPU) && (CPU == PPC85XX || CPU == PPC604 || CPU == PPC603) +// These PPC's do lack log2 in kernel mode +# define ACE_LACKS_LOG2 +# endif +# endif +#endif + +// OS-specific configuration +#define ACE_HAS_4_4BSD_SENDMSG_RECVMSG +#define ACE_HAS_NONCONST_GETBY +#define ACE_HAS_NONCONST_SWAB +#define ACE_LACKS_UNIX_SYSLOG +#define ACE_DEFAULT_MAX_SOCKET_BUFSIZ 32768 +#define ACE_DEFAULT_THREAD_KEYS 16 +#define ACE_HAS_BROKEN_ACCEPT_ADDR +#define ACE_HAS_NONCONST_SENDMSG +#define ACE_HAS_NONCONST_WRITEV +#define ACE_HAS_CHARPTR_DL +#define ACE_HAS_CLOCK_GETTIME +#define ACE_HAS_CLOCK_SETTIME +#define ACE_HAS_CONSISTENT_SIGNAL_PROTOTYPES +#define ACE_HAS_CPLUSPLUS_HEADERS +#define ACE_HAS_DIRENT +#define ACE_HAS_DLL 0 +#define ACE_HAS_HANDLE_SET_OPTIMIZED_FOR_SELECT +#define ACE_HAS_MSG +#define ACE_HAS_NONCONST_READV +#define ACE_HAS_NONCONST_SELECT_TIMEVAL +#define ACE_HAS_NONSTATIC_OBJECT_MANAGER +#define ACE_HAS_POSIX_NONBLOCK +#define ACE_HAS_POSIX_TIME +#define ACE_HAS_REENTRANT_FUNCTIONS +#define ACE_HAS_SIGACTION_CONSTP2 +#define ACE_HAS_SIGINFO_T +#define ACE_HAS_SIGWAIT +#define ACE_HAS_SIG_ATOMIC_T +#define ACE_HAS_SOCKADDR_IN_SIN_LEN +#define ACE_HAS_SOCKADDR_IN6_SIN6_LEN +#define ACE_HAS_STRERROR +#define ACE_HAS_THREADS +#define ACE_HAS_SYSCTL +#define ACE_LACKS_ALPHASORT +#define ACE_LACKS_EXEC +#define ACE_LACKS_FILELOCKS +#define ACE_LACKS_FORK +#define ACE_LACKS_GETHOSTENT +#define ACE_LACKS_GETSERVBYNAME +#define ACE_LACKS_GETPROTOBYNAME +#define ACE_LACKS_GETPROTOBYNUMBER +#define ACE_LACKS_GETIPNODEBYADDR +#define ACE_LACKS_GETIPNODEBYNAME_IPV6 +#define ACE_LACKS_LSTAT +#define ACE_LACKS_MADVISE +#define ACE_LACKS_MALLOC_H +#define ACE_LACKS_MEMORY_H +#define ACE_LACKS_MKFIFO +#define ACE_LACKS_MKTEMP +#define ACE_LACKS_MKSTEMP +#define ACE_LACKS_NETDB_REENTRANT_FUNCTIONS +#define ACE_LACKS_SYS_PARAM_H +#define ACE_LACKS_PWD_FUNCTIONS +#define ACE_LACKS_READDIR_R +#define ACE_LACKS_READLINK +#define ACE_LACKS_REALPATH +#define ACE_LACKS_PIPE +#define ACE_LACKS_RLIMIT +#define ACE_LACKS_RWLOCK_T +#define ACE_LACKS_SBRK +#define ACE_LACKS_SEEKDIR +#define ACE_LACKS_SEMBUF_T +#define ACE_LACKS_SIGINFO_H +#define ACE_LACKS_SI_ADDR +#define ACE_LACKS_SOCKETPAIR +#define ACE_LACKS_STRRECVFD +#define ACE_LACKS_SYSV_SHMEM +#define ACE_LACKS_TELLDIR +#define ACE_LACKS_TEMPNAM +#define ACE_LACKS_TIMESPEC_T +#define ACE_LACKS_TRUNCATE +#define ACE_LACKS_UCONTEXT_H +#define ACE_LACKS_USECONDS_T +#define ACE_LACKS_UMASK +#define ACE_LACKS_STRPTIME +#define ACE_PAGE_SIZE 4096 +#define ACE_THR_PRI_FIFO_DEF 101 +#define ACE_THR_PRI_OTHER_DEF ACE_THR_PRI_FIFO_DEF +#define ACE_HAS_SIGTIMEDWAIT +#define ACE_HAS_SIGSUSPEND +#define ACE_HAS_GETIFADDRS + +#define ACE_LACKS_SETEGID +#define ACE_LACKS_SETPGID +#define ACE_LACKS_SETREGID +#define ACE_LACKS_SETREUID +#define ACE_LACKS_SETSID +#define ACE_LACKS_SETUID +#define ACE_LACKS_SETEUID +#define ACE_LACKS_GETEUID +#define ACE_LACKS_GETUID +#define ACE_LACKS_GETPGID +#define ACE_LACKS_GETEGID +#define ACE_LACKS_GETGID +#define ACE_LACKS_SETGID + +#define ACE_LACKS_SYS_UIO_H +#define ACE_LACKS_SYS_IPC_H +#define ACE_LACKS_SYS_SEM_H +#define ACE_LACKS_STROPTS_H +#define ACE_LACKS_SYS_MSG_H +#define ACE_LACKS_PWD_H +#define ACE_LACKS_SYS_SHM_H +#define ACE_LACKS_TERMIOS_H +#define ACE_LACKS_POLL_H +#define ACE_LACKS_FCNTL + +// Some string things +#define ACE_LACKS_ITOW +#define ACE_LACKS_WCSDUP +#define ACE_LACKS_WCSICMP +#define ACE_LACKS_WCSNICMP +#define ACE_LACKS_STRTOULL +#define ACE_LACKS_WCSTOULL + +#define ACE_HAS_CHARPTR_SOCKOPT +#define ACE_LACKS_SYMLINKS + +#if defined __RTP__ + // We are building for RTP mode + #if !defined (ACE_AS_STATIC_LIBS) + # define ACE_HAS_SVR4_DYNAMIC_LINKING + #endif + #define ACE_HAS_2_PARAM_ASCTIME_R_AND_CTIME_R + #define ACE_LACKS_REGEX_H + #define ACE_LACKS_PUTENV + #define ACE_HAS_SETENV + #define ACE_HAS_3_PARAM_WCSTOK + #define ACE_HAS_WCHAR + #define ACE_HAS_VFWPRINTF + #define ACE_SIZEOF_WCHAR 2 + #define ACE_HAS_SHM_OPEN + #if defined (ACE_AS_STATIC_LIBS) + # define ACE_HAS_AIO_CALLS + #endif + #define ACE_LACKS_STRCASECMP + // VxWorks seems to either not define this or define as zero up till now + #if !defined (IOV_MAX) || (IOV_MAX == 0) + #define ACE_IOV_MAX 16 + #endif +#else + // We are building for kernel mode + #define ACE_LACKS_SUSECONDS_T + #define ACE_LACKS_INTPTR_T + #define ACE_LACKS_INTTYPES_H + #define ACE_LACKS_STDINT_H + #define ACE_LACKS_UNAME + #define ACE_LACKS_UTSNAME_T + #define ACE_LACKS_RAND_REENTRANT_FUNCTIONS + #define ACE_LACKS_DLFCN_H + #define ACE_LACKS_WAIT + #define ACE_LACKS_WAITPID + #define ACE_LACKS_SYS_TIME_H + #define ACE_LACKS_SYS_SELECT_H + #define ACE_MKDIR_LACKS_MODE + #define ACE_HAS_SIZET_PTR_ASCTIME_R_AND_CTIME_R + #define ACE_LACKS_SEARCH_H + #define ACE_LACKS_SYSCONF + #define ACE_LACKS_GETPID + #define ACE_LACKS_GETPPID + #define ACE_LACKS_WCHAR_H + #define ACE_LACKS_WCTYPE_H + #define ACE_LACKS_WCSCAT + #define ACE_LACKS_WCSCHR + #define ACE_LACKS_WCSCMP + #define ACE_LACKS_WCSCPY + #define ACE_LACKS_WCSCSPN + #define ACE_LACKS_WCSLEN + #define ACE_LACKS_WCSNCAT + #define ACE_LACKS_WCSNCMP + #define ACE_LACKS_WCSNCPY + #define ACE_LACKS_WCSPBRK + #define ACE_LACKS_WCSRCHR + #define ACE_LACKS_WCSSPN + #define ACE_LACKS_WCSSTR + #define ACE_LACKS_WCSTOK + #define ACE_LACKS_TOWLOWER + #define ACE_LACKS_TOWUPPER + #define ACE_LACKS_WCSTOD + #define ACE_LACKS_WCSTOL + #define ACE_LACKS_WCSTOUL + #define ACE_LACKS_FGETWC + #define ACE_LACKS_FGETWS + #define ACE_LACKS_FPUTWS + #define ACE_HAS_IOCTL_INT_3_PARAM + #define ACE_LACKS_MMAP + #define ACE_LACKS_MSYNC + #define ACE_LACKS_MPROTECT + #if !defined (ACE_MAIN) + # define ACE_MAIN ace_main + #endif /* ! ACE_MAIN */ +#endif + +// It is possible to enable pthread support with VxWorks, when the user decides +// to use this, we need some more defines +#if defined ACE_HAS_PTHREADS +# define ACE_HAS_THREAD_SPECIFIC_STORAGE +# define ACE_HAS_POSIX_SEM +# define ACE_LACKS_MUTEXATTR_PSHARED +# define ACE_LACKS_CONDATTR_PSHARED +// Include this file, the sys/stat.h file shipped with VxWorks has old types +// and without this include we get a lot of compile errors. A TSR has been filed +// so that hopefully in the future we can zap this include +#include "types/vxTypesOld.h" +#else +# define ACE_LACKS_PTHREAD_H +# define ACE_HAS_VXTHREADS +# if !defined __RTP__ +// Only when building for kernel mode we can use TSS emulation, in rtp mode +// we can't use the WIND_TCB struct anymore +# define ACE_HAS_TSS_EMULATION +# if !defined (ACE_VXWORKS_SPARE) +# define ACE_VXWORKS_SPARE spare4 +# endif /* ! ACE_VXWORKS_SPARE */ +# endif +// VxWorks has no recursive mutexes. This was set in the past but it doesn't +// work with the pthread support, so only set it for the time being when pthread +// is disabled +# define ACE_HAS_RECURSIVE_MUTEXES +# define ACE_LACKS_COND_T +# define ACE_HAS_MUTEX_TIMEOUTS +#endif + +#if !defined (ACE_MT_SAFE) +# define ACE_MT_SAFE 1 +#endif + +// Needed include to get all VxWorks CPU types +#include "types/vxCpu.h" +#if defined (CPU) && (CPU == PENTIUM || CPU == PENTIUM2 || CPU == PENTIUM3 || CPU == PENTIUM4) + // If running an Intel Pentium the + // ACE_OS::gethrtime () can use the RDTSC instruction. + # define ACE_HAS_PENTIUM +#endif + +// VxWorks defines the CPU define MAP, undef it to prevent problems with +// application code +#if defined (MAP) +#undef MAP +#endif /* MAP */ + +#if !defined (ACE_NEEDS_HUGE_THREAD_STACKSIZE) +# define ACE_NEEDS_HUGE_THREAD_STACKSIZE 65536 +#endif /* ACE_NEEDS_HUGE_THREAD_STACKSIZE */ + +#if !defined (ACE_NTRACE) +# define ACE_NTRACE 1 +#endif /* ACE_NTRACE */ + +// By default, don't include RCS Id strings in object code. +#if !defined (ACE_USE_RCSID) +#define ACE_USE_RCSID 0 +#endif /* !ACE_USE_RCSID */ + +#if defined (ACE_HAS_IP_MULTICAST) +# define ACE_LACKS_PERFECT_MULTICAST_FILTERING 1 +#endif /* ACE_HAS_IP_MULTICAST */ + +#include /**/ "ace/post.h" +#endif /* ACE_CONFIG_VXWORKS_6_3_H */ diff --git a/dep/ACE_wrappers/ace/config-vxworks6.4.h b/dep/ACE_wrappers/ace/config-vxworks6.4.h new file mode 100644 index 00000000000..2d8db5294fd --- /dev/null +++ b/dep/ACE_wrappers/ace/config-vxworks6.4.h @@ -0,0 +1,340 @@ +//* -*- C++ -*- */ +// $Id: config-vxworks6.4.h 81850 2008-06-06 08:39:54Z vzykov $ + +// The following configuration file is designed to work for VxWorks +// 6.4 platforms using one of these compilers: +// 1) The GNU g++ compiler that is shipped with VxWorks 6.4 +// 2) The Diab compiler that is shipped with VxWorks 6.4 + +#ifndef ACE_CONFIG_VXWORKS_6_4_H +#define ACE_CONFIG_VXWORKS_6_4_H +#include /**/ "ace/pre.h" + +#if ! defined (VXWORKS) +# define VXWORKS +#endif /* ! VXWORKS */ + +#if ! defined (ACE_VXWORKS) +# define ACE_VXWORKS 0x640 +#endif /* ! ACE_VXWORKS */ + +#if !defined (__RTP__) + // Fix for wrong typedef of time_t in kernel mode + #ifndef _TIME_T + #define _TIME_T + typedef long time_t; + #endif +#endif + +#if ! defined (__ACE_INLINE__) +# define __ACE_INLINE__ +#endif /* ! __ACE_INLINE__ */ + +// Compiler-specific configuration. +#if defined (__GNUG__) +# include "ace/config-g++-common.h" + +# define ACE_LACKS_IOSTREAM_FX +# define ACE_LACKS_LINEBUFFERED_STREAMBUF + +# if defined (__RTP__) && !defined (_HAS_C9X) +// Workaround for the fact that under RTP the log2 method can't be used +// without this define set, see TSR560446 +# if !defined (_C99) +# define _C99 +# endif +# endif + +#elif defined (__DCC__) +# define ACE_HAS_STANDARD_CPP_LIBRARY 1 +# define ACE_TEMPLATES_REQUIRE_SOURCE +#else /* ! __GNUG__ && ! ghs && !__DCC__ */ +# ifdef __cplusplus /* Let it slide for C compilers. */ +# error unsupported compiler on VxWorks +# endif /* __cplusplus */ +#endif /* ! __GNUG__ && ! ghs */ + +// Needed include to get all VxWorks CPU types +#include "types/vxCpu.h" +#if defined __RTP__ + #if defined (_VX_CPU) && (_VX_CPU == _VX_PENTIUM || _VX_CPU == _VX_PENTIUM2 || _VX_CPU == _VX_PENTIUM3 || _VX_CPU == _VX_PENTIUM4) + // If running an Intel Pentium the + // ACE_OS::gethrtime () can use the RDTSC instruction. + # define ACE_HAS_PENTIUM + #endif +#else + #if defined (CPU) && (CPU == PENTIUM || CPU == PENTIUM2 || CPU == PENTIUM3 || CPU == PENTIUM4) + // If running an Intel Pentium the + // ACE_OS::gethrtime () can use the RDTSC instruction. + # define ACE_HAS_PENTIUM + #endif +#endif + +#if !defined __RTP__ +# if defined (TOOL) && (TOOL == gnu) +# if defined (CPU) && (CPU == PPC85XX || CPU == PPC604 || CPU == PPC603) +// These PPC's do lack log2 in kernel mode +# define ACE_LACKS_LOG2 +# endif +# endif +#endif + +// OS-specific configuration +#define ACE_HAS_4_4BSD_SENDMSG_RECVMSG +#define ACE_HAS_3_PARAM_READDIR_R +#define ACE_HAS_NONCONST_GETBY +#define ACE_HAS_NONCONST_SWAB +#define ACE_LACKS_UNIX_SYSLOG +#define ACE_DEFAULT_MAX_SOCKET_BUFSIZ 32768 +#define ACE_DEFAULT_THREAD_KEYS 16 +#define ACE_HAS_BROKEN_ACCEPT_ADDR +#define ACE_HAS_NONCONST_SENDMSG +#define ACE_HAS_NONCONST_WRITEV +#define ACE_HAS_CHARPTR_DL +#define ACE_HAS_CLOCK_GETTIME +#define ACE_HAS_CLOCK_SETTIME +#define ACE_HAS_CONSISTENT_SIGNAL_PROTOTYPES +#define ACE_HAS_CPLUSPLUS_HEADERS +#define ACE_HAS_DIRENT +#define ACE_HAS_DLL 0 +#define ACE_HAS_HANDLE_SET_OPTIMIZED_FOR_SELECT +#define ACE_HAS_MSG +#define ACE_HAS_NONCONST_READV +#define ACE_HAS_NONCONST_SELECT_TIMEVAL +#define ACE_HAS_NONSTATIC_OBJECT_MANAGER +#define ACE_HAS_POSIX_NONBLOCK +#define ACE_HAS_POSIX_TIME +#define ACE_HAS_REENTRANT_FUNCTIONS +#define ACE_HAS_SIGACTION_CONSTP2 +#define ACE_HAS_SIGINFO_T +#define ACE_HAS_SIGWAIT +#define ACE_HAS_SIG_ATOMIC_T +#define ACE_HAS_SOCKADDR_IN_SIN_LEN +#define ACE_HAS_SOCKADDR_IN6_SIN6_LEN +#define ACE_HAS_STRERROR +#define ACE_HAS_THREADS +#define ACE_HAS_SYSCTL +#define ACE_LACKS_ALPHASORT +#define ACE_LACKS_EXEC +#define ACE_LACKS_RLIMIT +#define ACE_LACKS_FILELOCKS +#define ACE_LACKS_FORK +#define ACE_LACKS_GETHOSTENT +#define ACE_LACKS_GETSERVBYNAME +#define ACE_LACKS_GETPROTOBYNAME +#define ACE_LACKS_GETPROTOBYNUMBER +#define ACE_LACKS_GETIPNODEBYADDR +#define ACE_LACKS_GETIPNODEBYNAME_IPV6 +#define ACE_LACKS_LSTAT +#define ACE_LACKS_MADVISE +#define ACE_LACKS_MALLOC_H +#define ACE_LACKS_MEMORY_H +#define ACE_LACKS_MKFIFO +#define ACE_LACKS_MKSTEMP +#define ACE_LACKS_NETDB_REENTRANT_FUNCTIONS +#define ACE_LACKS_SYS_PARAM_H +#define ACE_LACKS_PWD_FUNCTIONS +#define ACE_LACKS_READLINK +#define ACE_LACKS_REALPATH +#define ACE_LACKS_PIPE +#define ACE_LACKS_RWLOCK_T +#define ACE_LACKS_SBRK +#define ACE_LACKS_SEEKDIR +#define ACE_LACKS_SEMBUF_T +#define ACE_LACKS_SIGINFO_H +#define ACE_LACKS_SI_ADDR +#define ACE_LACKS_SOCKETPAIR +#define ACE_LACKS_STRRECVFD +#define ACE_LACKS_SYSV_SHMEM +#define ACE_LACKS_TELLDIR +#define ACE_LACKS_TIMESPEC_T +#define ACE_LACKS_TRUNCATE +#define ACE_LACKS_UCONTEXT_H +#define ACE_LACKS_USECONDS_T +#define ACE_LACKS_UMASK +#define ACE_LACKS_STRPTIME +#define ACE_LACKS_MKTEMP +#define ACE_LACKS_TEMPNAM +#define ACE_PAGE_SIZE 4096 +#define ACE_THR_PRI_FIFO_DEF 101 +#define ACE_THR_PRI_OTHER_DEF ACE_THR_PRI_FIFO_DEF +#define ACE_HAS_SIGTIMEDWAIT +#define ACE_HAS_SIGSUSPEND +#define ACE_HAS_GETIFADDRS + +#define ACE_LACKS_SETEGID +#define ACE_LACKS_SETPGID +#define ACE_LACKS_SETREGID +#define ACE_LACKS_SETREUID +#define ACE_LACKS_SETSID +#define ACE_LACKS_SETUID +#define ACE_LACKS_SETEUID +#define ACE_LACKS_GETEUID +#define ACE_LACKS_GETUID +#define ACE_LACKS_GETPGID +#define ACE_LACKS_GETEGID +#define ACE_LACKS_GETGID +#define ACE_LACKS_SETGID + +#define ACE_LACKS_SYS_UIO_H +#define ACE_LACKS_SYS_IPC_H +#define ACE_LACKS_SYS_SEM_H +#define ACE_LACKS_STROPTS_H +#define ACE_LACKS_SYS_MSG_H +#define ACE_LACKS_PWD_H +#define ACE_LACKS_SYS_SHM_H +#define ACE_LACKS_TERMIOS_H +#define ACE_LACKS_POLL_H +#define ACE_LACKS_FCNTL + +// Some string things +#define ACE_LACKS_ITOW +#define ACE_LACKS_WCSDUP +#define ACE_LACKS_WCSICMP +#define ACE_LACKS_WCSNICMP +#define ACE_LACKS_STRTOULL +#define ACE_LACKS_WCSTOULL + +#define ACE_HAS_CHARPTR_SOCKOPT +#define ACE_LACKS_SYMLINKS + +#if defined __RTP__ + // We are building for RTP mode + #if !defined (ACE_AS_STATIC_LIBS) + # define ACE_HAS_SVR4_DYNAMIC_LINKING + #endif + #define ACE_HAS_2_PARAM_ASCTIME_R_AND_CTIME_R + #define ACE_LACKS_REGEX_H + #if defined ACE_HAS_PENTIUM + // Bug to workaround VxWorks 6.4 x86 + # define ACE_LACKS_PUTENV + #endif + #define ACE_HAS_SETENV + #define ACE_LACKS_STRCASECMP + #define ACE_HAS_3_PARAM_WCSTOK + #define ACE_HAS_WCHAR + #define ACE_HAS_VFWPRINTF + #define ACE_SIZEOF_WCHAR 2 + #define ACE_HAS_SHM_OPEN + #if defined (ACE_AS_STATIC_LIBS) + # define ACE_HAS_AIO_CALLS + #endif + // VxWorks seems to either not define this or define as zero up till now + #if !defined (IOV_MAX) || (IOV_MAX == 0) + #define ACE_IOV_MAX 16 + #endif +#else + // We are building for kernel mode + #define ACE_LACKS_SUSECONDS_T + #define ACE_LACKS_INTPTR_T + #define ACE_LACKS_INTTYPES_H + #define ACE_LACKS_STDINT_H + #define ACE_LACKS_UNAME + #define ACE_LACKS_UTSNAME_T + #define ACE_LACKS_RAND_REENTRANT_FUNCTIONS + #define ACE_LACKS_DLFCN_H + #define ACE_LACKS_WAIT + #define ACE_LACKS_WAITPID + #define ACE_LACKS_SYS_TIME_H + #define ACE_LACKS_SYS_SELECT_H + #define ACE_MKDIR_LACKS_MODE + #define ACE_HAS_SIZET_PTR_ASCTIME_R_AND_CTIME_R + #define ACE_LACKS_SEARCH_H + #define ACE_LACKS_SYSCONF + #define ACE_LACKS_GETPPID + #define ACE_LACKS_WCHAR_H + #define ACE_LACKS_WCTYPE_H + #define ACE_LACKS_WCSCAT + #define ACE_LACKS_WCSCHR + #define ACE_LACKS_WCSCMP + #define ACE_LACKS_WCSCPY + #define ACE_LACKS_WCSCSPN + #define ACE_LACKS_WCSLEN + #define ACE_LACKS_WCSNCAT + #define ACE_LACKS_WCSNCMP + #define ACE_LACKS_WCSNCPY + #define ACE_LACKS_WCSPBRK + #define ACE_LACKS_WCSRCHR + #define ACE_LACKS_WCSSPN + #define ACE_LACKS_WCSSTR + #define ACE_LACKS_WCSTOK + #define ACE_LACKS_TOWLOWER + #define ACE_LACKS_TOWUPPER + #define ACE_LACKS_WCSTOD + #define ACE_LACKS_WCSTOL + #define ACE_LACKS_WCSTOUL + #define ACE_LACKS_FGETWC + #define ACE_LACKS_FGETWS + #define ACE_LACKS_FPUTWS + #define ACE_HAS_IOCTL_INT_3_PARAM + #define ACE_LACKS_MMAP + #define ACE_LACKS_MSYNC + #define ACE_LACKS_MPROTECT + #if !defined (ACE_MAIN) + # define ACE_MAIN ace_main + #endif /* ! ACE_MAIN */ +#endif + +// It is possible to enable pthread support with VxWorks, when the user decides +// to use this, we need some more defines +#if defined ACE_HAS_PTHREADS +# define ACE_HAS_THREAD_SPECIFIC_STORAGE +# if !defined __RTP__ +# define ACE_LACKS_PTHREAD_ATTR_SETSTACK +# endif +# define ACE_HAS_PTHREAD_ATTR_SETNAME +# define ACE_HAS_POSIX_SEM +# define ACE_LACKS_MUTEXATTR_PSHARED +# define ACE_LACKS_CONDATTR_PSHARED +// Include this file, the sys/stat.h file shipped with VxWorks has old types +// and without this include we get a lot of compile errors. A TSR has been filed +// so that hopefully in the future we can zap this include +#include "types/vxTypesOld.h" +#else +# define ACE_LACKS_PTHREAD_H +# define ACE_HAS_VXTHREADS +# if !defined __RTP__ +// Only when building for kernel mode we can use TSS emulation, in rtp mode +// we can't use the WIND_TCB struct anymore +# define ACE_HAS_TSS_EMULATION +# if !defined (ACE_VXWORKS_SPARE) +# define ACE_VXWORKS_SPARE spare4 +# endif /* ! ACE_VXWORKS_SPARE */ +# endif +// VxWorks has no recursive mutexes. This was set in the past but it doesn't +// work with the pthread support, so only set it for the time being when pthread +// is disabled +# define ACE_HAS_RECURSIVE_MUTEXES +# define ACE_LACKS_COND_T +# define ACE_HAS_MUTEX_TIMEOUTS +#endif + +#if !defined (ACE_MT_SAFE) +# define ACE_MT_SAFE 1 +#endif + +// VxWorks defines the CPU define MAP, undef it to prevent problems with +// application code +#if defined (MAP) +#undef MAP +#endif /* MAP */ + +#if !defined (ACE_NEEDS_HUGE_THREAD_STACKSIZE) +# define ACE_NEEDS_HUGE_THREAD_STACKSIZE 65536 +#endif /* ACE_NEEDS_HUGE_THREAD_STACKSIZE */ + +#if !defined (ACE_NTRACE) +# define ACE_NTRACE 1 +#endif /* ACE_NTRACE */ + +// By default, don't include RCS Id strings in object code. +#if !defined (ACE_USE_RCSID) +#define ACE_USE_RCSID 0 +#endif /* !ACE_USE_RCSID */ + +#if defined (ACE_HAS_IP_MULTICAST) +# define ACE_LACKS_PERFECT_MULTICAST_FILTERING 1 +#endif /* ACE_HAS_IP_MULTICAST */ + +#include /**/ "ace/post.h" +#endif /* ACE_CONFIG_VXWORKS_6_4_H */ diff --git a/dep/ACE_wrappers/ace/config-vxworks6.5.h b/dep/ACE_wrappers/ace/config-vxworks6.5.h new file mode 100644 index 00000000000..19273e6cad4 --- /dev/null +++ b/dep/ACE_wrappers/ace/config-vxworks6.5.h @@ -0,0 +1,25 @@ +//* -*- C++ -*- */ +// $Id: config-vxworks6.5.h 80826 2008-03-04 14:51:23Z wotte $ + +// The following configuration file is designed to work for VxWorks +// 6.5 platforms using one of these compilers: +// 1) The GNU g++ compiler that is shipped with VxWorks 6.5 +// 2) The Diab compiler that is shipped with VxWorks 6.5 + +#ifndef ACE_CONFIG_VXWORKS_6_5_H +#define ACE_CONFIG_VXWORKS_6_5_H +#include /**/ "ace/pre.h" + +#if !defined (ACE_VXWORKS) +# define ACE_VXWORKS 0x650 +#endif /* ! ACE_VXWORKS */ + +#include "ace/config-vxworks6.4.h" + +#if defined (__RTP__) +# undef ACE_HAS_GETIFADDRS +#endif + +#include /**/ "ace/post.h" +#endif /* ACE_CONFIG_VXWORKS_6_5_H */ + diff --git a/dep/ACE_wrappers/ace/config-vxworks6.6.h b/dep/ACE_wrappers/ace/config-vxworks6.6.h new file mode 100644 index 00000000000..98787f39e00 --- /dev/null +++ b/dep/ACE_wrappers/ace/config-vxworks6.6.h @@ -0,0 +1,29 @@ +//* -*- C++ -*- */ +// $Id: config-vxworks6.6.h 80826 2008-03-04 14:51:23Z wotte $ + +// The following configuration file is designed to work for VxWorks +// 6.6 platforms using one of these compilers: +// 1) The GNU g++ compiler that is shipped with VxWorks 6.6 +// 2) The Diab compiler that is shipped with VxWorks 6.6 + +#ifndef ACE_CONFIG_VXWORKS_6_6_H +#define ACE_CONFIG_VXWORKS_6_6_H +#include /**/ "ace/pre.h" + +#if !defined (ACE_VXWORKS) +# define ACE_VXWORKS 0x660 +#endif /* ! ACE_VXWORKS */ + +#include "ace/config-vxworks6.5.h" + +#if defined (ACE_HAS_PENTIUM) +# define ACE_LACKS_LOG2 +#endif + +#if !defined (__RTP__) +# undef ACE_HAS_IOCTL_INT_3_PARAM +#endif + +#include /**/ "ace/post.h" +#endif /* ACE_CONFIG_VXWORKS_6_6_H */ + diff --git a/dep/ACE_wrappers/ace/config-win32-borland.h b/dep/ACE_wrappers/ace/config-win32-borland.h new file mode 100644 index 00000000000..2c05bc074a2 --- /dev/null +++ b/dep/ACE_wrappers/ace/config-win32-borland.h @@ -0,0 +1,125 @@ +// -*- C++ -*- +//$Id: config-win32-borland.h 82643 2008-08-19 14:02:12Z johnnyw $ + +// The following configuration file contains defines for Borland compilers. + +#ifndef ACE_CONFIG_WIN32_BORLAND_H +#define ACE_CONFIG_WIN32_BORLAND_H +#include /**/ "ace/pre.h" + +#ifndef ACE_CONFIG_WIN32_H +#error Use config-win32.h in config.h instead of this header +#endif /* ACE_CONFIG_WIN32_H */ + +#include "config-borland-common.h" + +// Automatically define WIN32 macro if the compiler tells us it is our +// target platform. +# if defined (__WIN32__) && !defined (WIN32) +# define WIN32 1 +# endif + +// When building a VCL application, the main VCL header file should be +// included before anything else. You can define ACE_HAS_VCL=1 in your +// project settings to have this file included for you automatically. +# if defined (ACE_HAS_VCL) && (ACE_HAS_VCL != 0) +# include /**/ +# endif + +# define ACE_CC_PREPROCESSOR "CPP32.EXE" + +# include "ace/config-win32-common.h" + +// Borland on win32 has swab +# undef ACE_LACKS_SWAB + +# define ACE_WSTRING_HAS_USHORT_SUPPORT 1 +# define ACE_HAS_DIRENT + +#ifdef ACE_USES_STD_NAMESPACE_FOR_STDC_LIB +#undef ACE_USES_STD_NAMESPACE_FOR_STDC_LIB +#define ACE_USES_STD_NAMESPACE_FOR_STDC_LIB 1 +#endif + +#define ACE_NEEDS_DL_UNDERSCORE + +#define ACE_LACKS_TERMIOS_H +#define ACE_LACKS_NETINET_TCP_H +#define ACE_LACKS_REGEX_H +#define ACE_LACKS_SYS_MSG_H +#define ACE_LACKS_PWD_H +#define ACE_LACKS_POLL_H +#define ACE_LACKS_SYS_SHM_H +#define ACE_LACKS_STRINGS_H +#define ACE_LACKS_SEMAPHORE_H +#define ACE_LACKS_INTTYPES_H +#define ACE_LACKS_UCONTEXT_H +#define ACE_LACKS_SYS_SELECT_H +#define ACE_LACKS_SYS_TIME_H +#define ACE_LACKS_SYS_RESOURCE_H +#define ACE_LACKS_SYS_WAIT_H +#define ACE_LACKS_DLFCN_H +#define ACE_LACKS_SYS_MMAN_H +#define ACE_LACKS_SYS_UIO_H +#define ACE_LACKS_SYS_SOCKET_H +#define ACE_LACKS_NETINET_IN_H +#define ACE_LACKS_NETDB_H +#define ACE_LACKS_NET_IF_H +#define ACE_LACKS_SYS_IPC_H +#define ACE_LACKS_SYS_SEM_H +#define ACE_LACKS_SYS_IOCTL_H +#define ACE_LACKS_STROPTS_H + +#undef ACE_LACKS_STRUCT_DIR +#undef ACE_LACKS_CLOSEDIR +#undef ACE_LACKS_OPENDIR +#undef ACE_LACKS_READDIR +#undef ACE_LACKS_REWINDDIR + +#define ACE_HAS_WOPENDIR +#define ACE_HAS_WCLOSEDIR +#define ACE_HAS_WREADDIR +#define ACE_HAS_WREWINDDIR + +#define ACE_LACKS_STRRECVFD +#define ACE_USES_EXPLICIT_STD_NAMESPACE + +#if defined(ACE_MT_SAFE) && (ACE_MT_SAFE != 0) +// must have _MT defined to include multithreading +// features from win32 headers +# if !defined(__MT__) +// *** DO NOT *** defeat this error message by defining __MT__ yourself. +// You must link with the multi threaded libraries. Add -tWM to your +// compiler options +# error You must link against multi-threaded libraries when using ACE (check your project settings) +# endif /* !_MT && !ACE_HAS_WINCE */ +#endif /* ACE_MT_SAFE && ACE_MT_SAFE != 0 */ + +#if (__BORLANDC__ < 0x580) +# define ACE_LACKS_INTPTR_T +# define ACE_HAS_NONCONST_SWAB +# define ACE_HAS_NONCONST_FDOPEN +#endif + +#if (__BORLANDC__ < 0x610) +# define ACE_HAS_NONCONST_TEMPNAM +# define ACE_LACKS_STRTOULL +# define ACE_LACKS_WCSTOULL +#endif + +#if (__BORLANDC__ <= 0x610) +// Older Borland compilers can't handle assembly in inline methods or +// templates (E2211). When we build for pentium optimized and we are inlining +// then we disable inline assembly +# if defined (ACE_HAS_PENTIUM) && defined(__ACE_INLINE__) +# define ACE_LACKS_INLINE_ASSEMBLY +# endif +#endif + +#define ACE_WCSDUP_EQUIVALENT ::_wcsdup +#define ACE_STRCASECMP_EQUIVALENT ::stricmp +#define ACE_STRNCASECMP_EQUIVALENT ::strnicmp +#define ACE_HAS_ITOA 1 + +#include /**/ "ace/post.h" +#endif /* ACE_CONFIG_WIN32_BORLAND_H */ diff --git a/dep/ACE_wrappers/ace/config-win32-common.h b/dep/ACE_wrappers/ace/config-win32-common.h new file mode 100644 index 00000000000..837f9ce4d21 --- /dev/null +++ b/dep/ACE_wrappers/ace/config-win32-common.h @@ -0,0 +1,666 @@ +/* -*- C++ -*- */ +// $Id: config-win32-common.h 82316 2008-07-15 01:28:39Z johnnyw $ + + +#ifndef ACE_CONFIG_WIN32_COMMON_H +#define ACE_CONFIG_WIN32_COMMON_H +#include /**/ "ace/pre.h" + +#ifndef ACE_CONFIG_WIN32_H +#error Use config-win32.h in config.h instead of this header +#endif /* ACE_CONFIG_WIN32_H */ + + +// Windows Mobile (CE) stuff is primarily further restrictions to what's +// in the rest of this file. Also, it defined ACE_HAS_WINCE, which is used +// in this file. +#if defined (_WIN32_WCE) +# include "ace/config-WinCE.h" +#endif /* _WIN32_WCE */ + +// Complain if WIN32 is not already defined. +#if !defined (WIN32) && !defined (ACE_HAS_WINCE) +# error Please define WIN32 in your project settings. +#endif + +#define ACE_WIN32 +#if defined (_WIN64) || defined (WIN64) +# define ACE_WIN64 + +// Use 64-bit file offsets by default in the WIN64 case, similar to +// what 64-bit UNIX systems do. +// +// Note that _FILE_OFFSET_BITS is not recognized by Windows. It is, +// however, recognized by ACE. +# ifndef _FILE_OFFSET_BITS +# define _FILE_OFFSET_BITS 64 +# endif /* !_FILE_OFFSET_BITS */ +#endif /* _WIN64 || WIN64 */ + +#if !defined (_WIN32_WINNT) +# define _WIN32_WINNT 0x0501 // pretend it's at least Windows XP or Win2003 +#endif + +// If the invoking procedure turned off debugging by setting NDEBUG, then +// also set ACE_NDEBUG, unless the user has already set it. +#if defined (NDEBUG) +# if !defined (ACE_NDEBUG) +# define ACE_NDEBUG +# endif /* ACE_NDEBUG */ +#endif /* NDEBUG */ + +// Define ACE_HAS_MFC to 1, if you want ACE to use CWinThread. This should +// be defined, if your application uses MFC. +// Setting applies to : building ACE +// Runtime restrictions: MFC DLLs must be installed +// Additonal notes : If both ACE_HAS_MFC and ACE_MT_SAFE are +// defined, the MFC DLL (not the static lib) +// will be used from ACE. +#if !defined (ACE_HAS_MFC) +# define ACE_HAS_MFC 0 +#endif + +// ACE_USES_STATIC_MFC always implies ACE_HAS_MFC +#if defined (ACE_USES_STATIC_MFC) +# if defined (ACE_HAS_MFC) +# undef ACE_HAS_MFC +# endif +# define ACE_HAS_MFC 1 +#endif /* ACE_USES_STATIC_MFC */ + +// Define ACE_HAS_STRICT to 1 in your config.h file if you want to use +// STRICT type checking. It is disabled by default because it will +// break existing application code. However, if ACE_HAS_MFC is turned on, +// ACE_HAS_STRICT is required by MFC. +// Setting applies to : building ACE, linking with ACE +// Runtime restrictions: - +#if !defined (ACE_HAS_STRICT) +# define ACE_HAS_STRICT 0 +#endif + +// MFC itself defines STRICT. +#if defined (ACE_HAS_MFC) && (ACE_HAS_MFC != 0) +# undef ACE_HAS_STRICT +# define ACE_HAS_STRICT 1 +#endif + +// Turn off the following define if you want to disable threading. +// Compile using multi-thread libraries. +// Setting applies to : building ACE, linking with ACE +// Runtime restrictions: multithreaded runtime DLL must be installed +#if !defined (ACE_MT_SAFE) +# define ACE_MT_SAFE 1 +#endif + +// Build ACE services as DLLs. If you write a library and want it to +// use ACE_Svc_Export, this will cause those macros to build dlls. If +// you want your ACE service to be a static library, comment out this +// line. As far as I know, the only reason to have a library be an +// ACE "service" is to leverage the ACE_Svc_Export macros. It's just +// as easy to define your own export macros. +// #if !defined (ACE_SVC_HAS_DLL) +// # define ACE_SVC_HAS_DLL 1 +// #endif + +// Define the special export macros needed to export symbols outside a dll +#if !defined(__BORLANDC__) +#define ACE_HAS_CUSTOM_EXPORT_MACROS 1 +#define ACE_Proper_Export_Flag __declspec (dllexport) +#define ACE_Proper_Import_Flag __declspec (dllimport) +#define ACE_EXPORT_SINGLETON_DECLARATION(T) template class __declspec (dllexport) T +#define ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) template class __declspec (dllexport) SINGLETON_TYPE; +#define ACE_IMPORT_SINGLETON_DECLARATION(T) extern template class T +#define ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) extern template class SINGLETON_TYPE ; +#endif /* !__BORLANDC__ */ + +// Define ACE_HAS_WINSOCK2 to 0 in your config.h file if you do *not* +// want to compile with WinSock 2.0. +// Setting applies to : building ACE +// Runtime restrictions: winsock2 must be installed. +// #define ACE_HAS_WINSOCK2 0 + +// By default, we use non-static object manager on Win32. That is, +// the object manager is allocated in main's stack memory. If this +// does not suit your need, i.e., if your programs depend on the use +// of static object manager, you neet to disable the behavior by adding +// +// #undef ACE_HAS_NONSTATIC_OBJECT_MANAGER +// +// in the config.h after including config-win32.h +// +// MFC users: the main function is defined within a MFC library and +// therefore, ACE won't be able to meddle with main function and +// instantiate the non-static object manager for you. To solve the +// problem, you'll need to instantiate the ACE_Object_Manager by +// either: +// +// 1. Using static object manager (as described above), however, using +// the non-static object manager is prefered, therefore, +// 2. Instantiate the non-static object manager yourself by either 1) +// call ACE::init () at the beginning and ACE::fini () at the end, +// _or_ 2) instantiate the ACE_Object_Manager in your CWinApp +// derived class. +// +// Optionally, you can #define +// ACE_DOESNT_INSTANTIATE_NONSTATIC_OBJECT_MANAGER in your +// ace/config.h and always take care of the business by yourself. +// ACE_DOESNT_INSTANTIATE_NONSTATIC_OBJECT_MANAGER has no effect when +// using static object managers. +#if !defined (ACE_HAS_NONSTATIC_OBJECT_MANAGER) +# define ACE_HAS_NONSTATIC_OBJECT_MANAGER +#elif (ACE_HAS_NONSTATIC_OBJECT_MANAGER == 0) +# undef ACE_HAS_NONSTATIC_OBJECT_MANAGER +#endif /* ACE_HAS_NONSTATIC_OBJECT_MANAGER */ + +#define ACE_HAS_GPERF + +// By default, don't include RCS Id strings in object code. +#if !defined (ACE_USE_RCSID) +# define ACE_USE_RCSID 0 +#endif /* ! ACE_USE_RCSID */ + +// ---------------- platform features or lack of them ------------- + +// By default WIN32 has FD_SETSIZE of 64, which places the limit +// between 61 and 64 on the number of clients a server using the +// Select Reactor can support at the same time (i.e., 64 - standard in, +// out, error). Here we raise the limit to 1024. Adjust the definition +// below if you need to raise or lower it. + +#if !defined (FD_SETSIZE) +#define FD_SETSIZE 1024 +#endif /* FD_SETSIZE */ + + +// Windows doesn't like 65536 ;-) If 65536 is specified, it is +// silently ignored by the OS, i.e., setsockopt does not fail, and you +// get stuck with the default size of 8k. +#define ACE_DEFAULT_MAX_SOCKET_BUFSIZ 65535 + +// It seems like Win32 does not have a limit on the number of buffers +// that can be transferred by the scatter/gather type of I/O +// functions, e.g., WSASend and WSARecv. We are setting this to be 64 +// for now. The typically use case is to create an I/O vector array +// of size ACE_IOV_MAX on the stack and then filled in. Note that we +// probably don't want too big a value for ACE_IOV_MAX since it may +// mostly go to waste or the size of the activation record may become +// excessively large. +#if !defined (ACE_IOV_MAX) +# define ACE_IOV_MAX 64 +#endif /* ACE_IOV_MAX */ + +#if !defined (ACE_HAS_WINCE) +// Platform supports pread() and pwrite() +# define ACE_HAS_P_READ_WRITE +#endif /* ! ACE_HAS_WINCE */ + +#if !defined (__MINGW32__) +# define ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS +#endif /* __MINGW32__ */ + +#define ACE_DEFAULT_THREAD_PRIORITY 0 + +#define ACE_HAS_DIRENT +#define ACE_HAS_MSG +#define ACE_HAS_RECURSIVE_MUTEXES +#define ACE_HAS_SOCKADDR_MSG_NAME +#define ACE_HAS_THREAD_SAFE_ACCEPT + +/* LACKS dir-related facilities */ +#define ACE_LACKS_READDIR_R +#define ACE_LACKS_REWINDDIR +#define ACE_LACKS_SEEKDIR +#define ACE_LACKS_TELLDIR + +/* LACKS gid/pid/sid/uid facilities */ +#define ACE_LACKS_GETPGID +#define ACE_LACKS_GETPPID +#define ACE_LACKS_SETPGID +#define ACE_LACKS_SETREGID +#define ACE_LACKS_SETREUID +#define ACE_LACKS_SETSID +#define ACE_LACKS_SETEGID +#define ACE_LACKS_SETUID +#define ACE_LACKS_SETEUID +#define ACE_LACKS_GETGID +#define ACE_LACKS_GETEGID +#define ACE_LACKS_GETUID +#define ACE_LACKS_GETEUID +#define ACE_LACKS_SETGID + +/* LACKS miscellaneous */ +#define ACE_LACKS_ALARM +#define ACE_LACKS_ARPA_INET_H +#define ACE_LACKS_DUP2 +#define ACE_LACKS_FORK +#define ACE_LACKS_GETHOSTENT +#define ACE_LACKS_GETOPT +#define ACE_LACKS_GETIPNODEBYNAME_IPV6 +#define ACE_LACKS_KILL +#define ACE_LACKS_INET_ATON +#define ACE_LACKS_MADVISE +#define ACE_LACKS_MKFIFO +#define ACE_LACKS_MODE_MASKS +#define ACE_LACKS_PTHREAD_H +#define ACE_LACKS_PWD_FUNCTIONS +#define ACE_LACKS_READLINK +#define ACE_LACKS_RLIMIT +#define ACE_LACKS_SBRK +#define ACE_LACKS_SCHED_H +#define ACE_LACKS_SEMBUF_T +#define ACE_LACKS_SIGACTION +#define ACE_LACKS_SIGSET +#define ACE_LACKS_SOCKETPAIR +#define ACE_LACKS_SUSECONDS_T +#define ACE_LACKS_USECONDS_T +#define ACE_LACKS_SYS_PARAM_H +#define ACE_LACKS_SYS_SYSCTL_H +#define ACE_LACKS_SYSCONF +#define ACE_LACKS_SYSV_SHMEM +#define ACE_LACKS_UNISTD_H +#define ACE_LACKS_UNIX_SIGNALS +#define ACE_LACKS_UNIX_SYSLOG +#define ACE_LACKS_UTSNAME_T +#define ACE_LACKS_UNAME +#define ACE_LACKS_WAIT +#define ACE_LACKS_IOVEC +#define ACE_LACKS_LOG2 + +#define ACE_HAS_PDH_H +#define ACE_HAS_PDHMSG_H + +#define ACE_HAS_VFWPRINTF + +#define ACE_MKDIR_LACKS_MODE + +#define ACE_SIZEOF_LONG_LONG 8 +// Green Hills Native x86 does not support __int64 keyword +// Neither does mingw32. +#if !defined (ACE_LACKS_LONGLONG_T) && !defined (__MINGW32__) +#define ACE_INT64_TYPE signed __int64 +#define ACE_UINT64_TYPE unsigned __int64 +#endif /* (ghs) */ + +#if defined (__MINGW32__) +#define ACE_INT64_TYPE signed long long +#define ACE_UINT64_TYPE unsigned long long +#endif + +// Optimize ACE_Handle_Set for select(). +#define ACE_HAS_HANDLE_SET_OPTIMIZED_FOR_SELECT + +// Win32 has wide-char support. Use of the compiler-defined wchar_t type +// is controlled in compiler configs since it's a compiler switch. +#define ACE_HAS_WCHAR + +// Compiler/platform correctly calls init()/fini() for shared +// libraries. - applied for DLLs ? +//define ACE_HAS_AUTOMATIC_INIT_FINI + +// Platform supports POSIX O_NONBLOCK semantics. +//define ACE_HAS_POSIX_NONBLOCK + +// Platform contains . +//define ACE_HAS_POLL + +// Platform supports the /proc file system. +//define ACE_HAS_PROC_FS + +// Platform supports the rusage struct. +#define ACE_HAS_GETRUSAGE + +// Compiler/platform supports SVR4 signal typedef. +//define ACE_HAS_SVR4_SIGNAL_T + +// Platform provides header. +//define ACE_HAS_SYS_FILIO_H + +// Compiler/platform supports sys_siglist array. +//define ACE_HAS_SYS_SIGLIST + +// Platform supports ACE_TLI timod STREAMS module. +//define ACE_HAS_TIMOD_H + +// Platform supports ACE_TLI tiuser header. +//define ACE_HAS_TIUSER_H + +// Platform provides ACE_TLI function prototypes. +// For Win32, this is not really true, but saves a lot of hassle! +#define ACE_HAS_TLI_PROTOTYPES + +// Platform supports ACE_TLI. +//define ACE_HAS_TLI + +// I'm pretty sure NT lacks these +#define ACE_LACKS_UNIX_DOMAIN_SOCKETS + +// Windows NT needs readv() and writev() +#define ACE_LACKS_WRITEV +#define ACE_LACKS_READV + +#define ACE_LACKS_COND_T +#define ACE_LACKS_RWLOCK_T + +#define ACE_LACKS_KEY_T + +// No system support for replacing any previous mappings. +#define ACE_LACKS_AUTO_MMAP_REPLACEMENT + +// ACE_HAS_PENTIUM is used to optimize some CDR operations; it's used for +// some other time-related things using g++, but not for VC. Current VC +// compilers set _M_IX86 > 400 by default so if you're not using a Pentium +// class CPU, set the project code generation options appropriately. +#if !defined(ACE_HAS_PENTIUM) && (_M_IX86 > 400) +# define ACE_HAS_PENTIUM +#endif + +#if defined(ACE_MT_SAFE) && (ACE_MT_SAFE != 0) +// Platform supports threads. +# define ACE_HAS_THREADS + +// Platform supports Windows32 threads. +# define ACE_HAS_WTHREADS + +// Compiler/platform has thread-specific storage +# define ACE_HAS_THREAD_SPECIFIC_STORAGE + +// Win32 doesn't have fcntl +#define ACE_LACKS_FCNTL + +#endif /* ACE_MT_SAFE && ACE_MT_SAFE != 0 */ + +#if !defined(_DEBUG) +// If we are making a release, and the user has not specified +// inline directives, we will default to inline +# if ! defined (__ACE_INLINE__) +# define __ACE_INLINE__ 1 +# endif /* __ACE_INLINE__ */ +#endif + +// If __ACE_INLINE__ is defined to be 0, we will undefine it +#if defined (__ACE_INLINE__) && (__ACE_INLINE__ == 0) +# undef __ACE_INLINE__ +#endif /* __ACE_INLINE__ */ + +// We are build ACE and want to use MFC (multithreaded) +#if defined(ACE_HAS_MFC) && (ACE_HAS_MFC != 0) && defined (_MT) +# if (ACE_HAS_DLL != 0) && defined(ACE_BUILD_DLL) && !defined (_WINDLL) +// force multithreaded MFC DLL +# define _WINDLL +# endif /* _AFXDLL */ +# if !defined (_AFXDLL) && !defined (ACE_USES_STATIC_MFC) +# define _AFXDLL +# endif /* _AFXDLL */ +#endif + +// and MFC's are mutually +// incompatible. is brain-dead about MFC; it doesn't check +// to see whether MFC stuff is anticipated or already in progress +// before doing its thing. ACE needs (practically always) , +// and winsock in turn needs support either from windows.h or from +// afxwin.h. One or the other, not both. +// +// The MSVC++ V4.0 environment defines preprocessor macros that +// indicate the programmer has chosen something from the +// Build-->Settings-->General-->MFC combo-box. defines a +// macro itself to protect against double inclusion. We'll take +// advantage of all this to select the proper support for winsock. - +// trl 26-July-1996 + +// This is necessary since MFC users apparently can't #include +// directly. +#if defined (ACE_HAS_MFC) && (ACE_HAS_MFC != 0) +# include /**/ /* He is doing MFC */ +// Windows.h will be included via afxwin.h->afx.h->afx_ver_.h->afxv_w32.h +// #define _INC_WINDOWS // Prevent winsock.h from including windows.h +#elif defined (ACE_HAS_WINCE) +# include /**/ +#endif + +#if !defined (_INC_WINDOWS) /* Already include windows.h ? */ +// Must define strict before including windows.h ! +# if defined (ACE_HAS_STRICT) && (ACE_HAS_STRICT != 0) && !defined (STRICT) +# define STRICT 1 +# endif /* ACE_HAS_STRICT */ + +# if !defined (WIN32_LEAN_AND_MEAN) && !defined (ACE_NO_WIN32_LEAN_AND_MEAN) +# define WIN32_LEAN_AND_MEAN +# endif /* WIN32_LEAN_AND_MEAN */ + +#endif /* !defined (_INC_WINDOWS) */ + +// Always use WS2 when available +#if !defined(ACE_HAS_WINSOCK2) +# define ACE_HAS_WINSOCK2 1 +#endif /* !defined(ACE_HAS_WINSOCK2) */ + + +#if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) +# if !defined (_WINSOCK2API_) +// will also include windows.h, if not present +# include /**/ +// WinCE 4 doesn't define the Exxx values without the WSA prefix, so do that +// here. This is all lifted from the #if 0'd out part of winsock2.h. +# if defined (UNDER_CE) +# define EWOULDBLOCK WSAEWOULDBLOCK +# define EINPROGRESS WSAEINPROGRESS +# define EALREADY WSAEALREADY +# define ENOTSOCK WSAENOTSOCK +# define EDESTADDRREQ WSAEDESTADDRREQ +# define EMSGSIZE WSAEMSGSIZE +# define EPROTOTYPE WSAEPROTOTYPE +# define ENOPROTOOPT WSAENOPROTOOPT +# define EPROTONOSUPPORT WSAEPROTONOSUPPORT +# define ESOCKTNOSUPPORT WSAESOCKTNOSUPPORT +# define EOPNOTSUPP WSAEOPNOTSUPP +# define EPFNOSUPPORT WSAEPFNOSUPPORT +# define EAFNOSUPPORT WSAEAFNOSUPPORT +# define EADDRINUSE WSAEADDRINUSE +# define EADDRNOTAVAIL WSAEADDRNOTAVAIL +# define ENETDOWN WSAENETDOWN +# define ENETUNREACH WSAENETUNREACH +# define ENETRESET WSAENETRESET +# define ECONNABORTED WSAECONNABORTED +# define ECONNRESET WSAECONNRESET +# define ENOBUFS WSAENOBUFS +# define EISCONN WSAEISCONN +# define ENOTCONN WSAENOTCONN +# define ESHUTDOWN WSAESHUTDOWN +# define ETOOMANYREFS WSAETOOMANYREFS +# define ETIMEDOUT WSAETIMEDOUT +# define ECONNREFUSED WSAECONNREFUSED +# define ELOOP WSAELOOP +# define ENAMETOOLONG WSAENAMETOOLONG +# define EHOSTDOWN WSAEHOSTDOWN +# define EHOSTUNREACH WSAEHOSTUNREACH +# define ENOTEMPTY WSAENOTEMPTY +# define EPROCLIM WSAEPROCLIM +# define EUSERS WSAEUSERS +# define EDQUOT WSAEDQUOT +# define ESTALE WSAESTALE +# define EREMOTE WSAEREMOTE +# endif /* UNDER_CE */ +# endif /* _WINSOCK2API */ + +# if defined (ACE_HAS_FORE_ATM_WS2) +# include /**/ +# endif /*ACE_HAS_FORE_ATM_WS2 */ + +// CE doesn't have Microsoft Winsock 2 extensions +# if !defined _MSWSOCK_ && !defined (ACE_HAS_WINCE) +# include /**/ +# endif /* _MSWSOCK_ */ + +# if defined (_MSC_VER) +# if defined (ACE_HAS_WINCE) +# pragma comment(lib, "ws2.lib") +# else +# pragma comment(lib, "ws2_32.lib") +# pragma comment(lib, "mswsock.lib") +# if defined (ACE_HAS_IPV6) +# pragma comment(lib, "iphlpapi.lib") +# endif +# endif /* ACE_HAS_WINCE */ +# endif /* _MSC_VER */ + +# define ACE_WSOCK_VERSION 2, 0 +#else +# if !defined (_WINSOCKAPI_) + // will also include windows.h, if not present +# include /**/ +# endif /* _WINSOCKAPI */ + +// PharLap ETS has its own winsock lib, so don't grab the one +// supplied with the OS. +# if defined (_MSC_VER) && !defined (UNDER_CE) && !defined (ACE_HAS_PHARLAP) +# pragma comment(lib, "wsock32.lib") +# endif /* _MSC_VER */ + +// We can't use recvmsg and sendmsg unless WinSock 2 is available +# define ACE_LACKS_RECVMSG +# define ACE_LACKS_SENDMSG + +// Version 1.1 of WinSock +# define ACE_WSOCK_VERSION 1, 1 +#endif /* ACE_HAS_WINSOCK2 */ + +// Platform supports IP multicast on Winsock 2 +#if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) +# define ACE_HAS_IP_MULTICAST +#endif /* ACE_HAS_WINSOCK2 */ + +#if !defined (ACE_HAS_WINCE) || defined (PPC) /* CE only on some CPUs */ +# define ACE_HAS_INTERLOCKED_EXCHANGEADD +#endif +#define ACE_HAS_WIN32_TRYLOCK + +#if !defined (ACE_HAS_WINCE) && !defined (ACE_HAS_PHARLAP) +# define ACE_HAS_SIGNAL_OBJECT_AND_WAIT + +// If CancelIO is undefined get the updated sp2-sdk from MS +# define ACE_HAS_CANCEL_IO +# define ACE_HAS_WIN32_OVERLAPPED_IO +# define ACE_HAS_WIN32_NAMED_PIPES +#endif /* !defined (ACE_USES_WINCE_SEMA_SIMULATION) && !ACE_HAS_PHARLAP */ + +#if !defined (ACE_SEH_DEFAULT_EXCEPTION_HANDLING_ACTION) +# define ACE_SEH_DEFAULT_EXCEPTION_HANDLING_ACTION EXCEPTION_CONTINUE_SEARCH +#endif /* ACE_SEH_DEFAULT_EXCEPTION_HANDLING_ACTION */ + +// ACE_HAS_QOS is defined in the qos.mpb base project. +// If qos=1 in default.features, then this macro will be defined. +#if defined (ACE_HAS_QOS) && !defined (ACE_HAS_WINSOCK2_GQOS) +# if defined (WINSOCK_VERSION) +# define ACE_HAS_WINSOCK2_GQOS 1 +# endif /* WINSOCK_VERSION */ +#endif /* ACE_HAS_WINSOCK2_GQOS */ + +// These are the defaults and can be overridden by a user's config.h +#if !defined (ACE_DEFAULT_FILE_PERMS) +# define ACE_DEFAULT_FILE_PERMS (FILE_SHARE_READ | FILE_SHARE_WRITE | \ + FILE_SHARE_DELETE) +// This alternate used to be used for pre-NT4 systems; may still be needed +// by knock-offs such as CE and Pharlap. +//# define ACE_DEFAULT_FILE_PERMS (FILE_SHARE_READ | FILE_SHARE_WRITE) +#endif /* !defined (ACE_DEFAULT_FILE_PERMS) */ + +#define ACE_SIZEOF_WCHAR 2 +#define ACE_HAS_MUTEX_TIMEOUTS +#define ACE_LACKS_STRUCT_DIR +#define ACE_LACKS_OPENDIR +#define ACE_LACKS_CLOSEDIR +#define ACE_LACKS_READDIR +#define ACE_LACKS_ALPHASORT +#define ACE_LACKS_MKSTEMP +#define ACE_LACKS_LSTAT +// Looks like Win32 has a non-const swab function +#define ACE_HAS_NONCONST_SWAB + +// If we are using winsock2 then the SO_REUSEADDR feature is broken +// SO_REUSEADDR=1 behaves like SO_REUSEPORT=1. (SO_REUSEPORT is an +// extension to sockets on some platforms) +// We define SO_REUSEPORT here so that ACE_OS::setsockopt() can still +// allow the user to specify that a socketaddr can *always* be reused. +#if defined (ACE_HAS_WINSOCK2) && ACE_HAS_WINSOCK2 != 0 && ! defined(SO_REUSEPORT) +#define SO_REUSEPORT 0x0400 // We just have to pick a value that won't conflict +#endif + +#if defined (ACE_WIN64) +// Data must be aligned on 8-byte boundaries, at a minimum. +# define ACE_MALLOC_ALIGN 8 +// Void pointers are 8 bytes +# define ACE_SIZEOF_VOID_P 8 +#endif /* ACE_WIN64 */ + +#if !defined (ACE_DISABLES_THREAD_LIBRARY_CALLS) +# define ACE_DISABLES_THREAD_LIBRARY_CALLS 0 +#endif /* ACE_DISABLES_THREAD_LIBRARY_CALLS */ + +#if !defined (ACE_HAS_WINCE) && !defined (ACE_HAS_PHARLAP) +# define ACE_HAS_LOG_MSG_NT_EVENT_LOG +#endif /* !ACE_HAS_WINCE && !ACE_HAS_PHARLAP */ + +#if !defined (ACE_HAS_WINCE) +# define ACE_HAS_LLSEEK +#endif /* !ACE_HAS_WINCE */ + +// Needed for obtaining the MAC address +// I dont believe this will work under CE, notice the +// check for ACE_HAS_WINCE. +# if !defined (ACE_HAS_WINCE) +# include +# if defined (_MSC_VER) +# pragma comment(lib, "netapi32.lib") // needed for obtaing MACaddress +# endif +# endif /* !ACE_HAS_WINCE */ + +#if !defined (WINVER) +# define WINVER 0x0400 // pretend it's at least WinNT 4.0 +#endif + +/////////////////////////////////////// +// windows version-specific definitions +// see: http://msdn2.microsoft.com/en-us/library/aa383745.aspx +// +// For TSS information +// see http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/thread_local_storage.asp + +#if (WINVER>=0x0600) +// Windows Server 2008 definitions go here +// Windows Vista defintions go here +# if ! defined(ACE_DEFAULT_THREAD_KEYS) +# define ACE_DEFAULT_THREAD_KEYS 1088 +# endif // ! defined(ACE_DEFAULT_THREAD_KEYS) +#elif (WINVER>=0x0502) + // Windows Server 2003 SP1 definitions go here +# if ! defined(ACE_DEFAULT_THREAD_KEYS) +# define ACE_DEFAULT_THREAD_KEYS 1088 +# endif // ! defined(ACE_DEFAULT_THREAD_KEYS) +#elif (WINVER>=0x0501) +// Windows XP definitions go here +# if ! defined(ACE_DEFAULT_THREAD_KEYS) +# define ACE_DEFAULT_THREAD_KEYS 1088 +# endif // ! defined(ACE_DEFAULT_THREAD_KEYS) +#elif (WINVER>=0x0500) +// Windows 2000 definitions go here +# if ! defined(ACE_DEFAULT_THREAD_KEYS) +# define ACE_DEFAULT_THREAD_KEYS 1088 +# endif // ! defined(ACE_DEFAULT_THREAD_KEYS) +#elif (WINVER>=0x0410) +// Windows 98 definitions go here +# if ! defined(ACE_DEFAULT_THREAD_KEYS) +# define ACE_DEFAULT_THREAD_KEYS 80 +# endif // ! defined(ACE_DEFAULT_THREAD_KEYS) +#else +// antique windows +# if ! defined(ACE_DEFAULT_THREAD_KEYS) +# define ACE_DEFAULT_THREAD_KEYS 64 +# endif // ! defined(ACE_DEFAULT_THREAD_KEYS) +#endif + +#if !defined (ACE_DEFAULT_BACKLOG) +# define ACE_DEFAULT_BACKLOG SOMAXCONN +#endif /* ACE_DEFAULT_BACKLOG */ + +#include /**/ "ace/post.h" +#endif /* ACE_CONFIG_WIN32_COMMON_H */ diff --git a/dep/ACE_wrappers/ace/config-win32-dmc.h b/dep/ACE_wrappers/ace/config-win32-dmc.h new file mode 100644 index 00000000000..91adf86b8b9 --- /dev/null +++ b/dep/ACE_wrappers/ace/config-win32-dmc.h @@ -0,0 +1,110 @@ +// -*- C++ -*- +// $Id: config-win32-dmc.h 81992 2008-06-16 19:09:50Z wotte $ + +// The following configuration file contains defines for Digital Mars compilers. + +#ifndef ACE_CONFIG_WIN32_DMC_H +#define ACE_CONFIG_WIN32_DMC_H +#include /**/ "ace/pre.h" + +#ifndef ACE_CONFIG_WIN32_H +#error Use config-win32.h in config.h instead of this header +#endif /* ACE_CONFIG_WIN32_H */ + +#ifndef WIN32 +# define WIN32 +#endif /* WIN32 */ + +#undef _M_IX86 +// This turns on ACE_HAS_PENTIUM +#define _M_IX86 500 + +#if defined ACE_LACKS_STRUCT_DIR +# undef ACE_LACKS_STRUCT_DIR +#endif + +// Changed ACE_TEXT to ACE_TEXT in the following line +# define ACE_CC_NAME ACE_TEXT ("Digital Mars") +# define ACE_CC_MAJOR_VERSION (1) +# define ACE_CC_MINOR_VERSION (8) +# define ACE_CC_BETA_VERSION (9) +# ifndef ACE_USING_MCPP_PREPROCESSOR +# define ACE_CC_PREPROCESSOR "DMC.EXE" +# define ACE_CC_PREPROCESSOR_ARGS "-E" +# endif + +// Microsoft's standard cpp library auto_ptr doesn't have reset (). +# define ACE_AUTO_PTR_LACKS_RESET + +#define ACE_ENDTHREADEX(STATUS) ::_endthreadex ((DWORD) STATUS) + +// This section below was extracted from config-win32-msvc +#define ACE_HAS_ITOA +#define ACE_ITOA_EQUIVALENT ::_itoa +#define ACE_STRCASECMP_EQUIVALENT ::_stricmp +#define ACE_STRNCASECMP_EQUIVALENT ::_strnicmp +#define ACE_WCSDUP_EQUIVALENT ::_wcsdup +// This section above was extracted from config-win32-msvc + +# define ACE_EXPORT_NESTED_CLASSES 1 +# define ACE_HAS_CPLUSPLUS_HEADERS 1 +//# define ACE_HAS_EXCEPTIONS 1 +# define ACE_HAS_GNU_CSTRING_H 1 +# define ACE_HAS_NONCONST_SELECT_TIMEVAL 1 +# define ACE_HAS_SIG_ATOMIC_T 1 +# define ACE_HAS_STANDARD_CPP_LIBRARY 0 +# define ACE_HAS_STDCPP_STL_INCLUDES 1 +# define ACE_HAS_STRERROR 1 +# define ACE_HAS_STRING_CLASS 1 +# define ACE_HAS_TEMPLATE_TYPEDEFS 1 +# define ACE_HAS_USER_MODE_MASKS 1 +//# define ACE_LACKS_LINEBUFFERED_STREAMBUF 1 +# define ACE_LACKS_STRPTIME 1 +//# define ACE_LACKS_PRAGMA_ONCE 1 +//# define ACE_NEW_THROWS_EXCEPTIONS 1 +# define ACE_SIZEOF_LONG_DOUBLE 10 +# define ACE_TEMPLATES_REQUIRE_SOURCE 1 +// Changed ACE_TEXT to ACE_TEXT in the following two lines +# define ACE_USES_STD_NAMESPACE_FOR_STDCPP_LIB 1 +# define ACE_HAS_STRBUF_T +#define ACE_HAS_3_PARAM_WCSTOK +#define ACE_USES_OLD_IOSTREAMS +#define ACE_LACKS_UCONTEXT_H +#define ACE_LACKS_SYS_RESOURCE_H +#define ACE_LACKS_SYS_WAIT_H +#define ACE_LACKS_STRINGS_H +#define ACE_LACKS_SYS_IPC_H +#define ACE_LACKS_SYS_SEM_H +#define ACE_LACKS_SEMAPHORE_H +#define ACE_LACKS_SYS_MMAN_H +#define ACE_LACKS_SYS_UIO_H +#define ACE_LACKS_SYS_SOCKET_H +#define ACE_LACKS_NETINET_IN_H +#define ACE_LACKS_SYS_IOCTL_H +#define ACE_LACKS_SYS_SELECT_H +#define ACE_LACKS_NET_IF_H +#define ACE_LACKS_DLFCN_H +#define ACE_LACKS_NETDB_H +#define ACE_LACKS_SYS_SHM_H +#define ACE_LACKS_REGEX_H +#define ACE_LACKS_SYS_MSG_H +#define ACE_LACKS_NETINET_TCP_H +#define ACE_LACKS_UNISTD_H +#define ACE_LACKS_TERMIOS_H +#define ACE_LACKS_ACE_IOSTREAM +#define ACE_HAS_NONCONST_TEMPNAM + +// Typedefs which we expect DMC to do, but they don't do that +typedef long o_uid_t; +typedef long o_gid_t; + +#include "io.h" +#undef umask; +#undef tell; + +# if !defined (ACE_LD_DECORATOR_STR) && defined (_DEBUG) +# define ACE_LD_DECORATOR_STR ACE_TEXT ("d") +# endif + +#include /**/ "ace/post.h" +#endif /* ACE_CONFIG_WIN32_DMC_H */ diff --git a/dep/ACE_wrappers/ace/config-win32-ghs.h b/dep/ACE_wrappers/ace/config-win32-ghs.h new file mode 100644 index 00000000000..77cff1d803d --- /dev/null +++ b/dep/ACE_wrappers/ace/config-win32-ghs.h @@ -0,0 +1,96 @@ +// -*- C++ -*- +// $Id: config-win32-ghs.h 81992 2008-06-16 19:09:50Z wotte $ + +// The following configuration file contains defines for Green Hills compilers. + +#ifndef ACE_CONFIG_WIN32_GHS_H +#define ACE_CONFIG_WIN32_GHS_H +#include /**/ "ace/pre.h" + +#ifndef ACE_CONFIG_WIN32_H +#error Use config-win32.h in config.h instead of this header +#endif /* ACE_CONFIG_WIN32_H */ + +#ifndef WIN32 +# define WIN32 +#endif /* WIN32 */ + +#undef _M_IX86 +// This turns on ACE_HAS_PENTIUM +#define _M_IX86 500 +// GHS does not provide DLL support +#define ACE_HAS_DLL 0 +#define TAO_HAS_DLL 0 +#undef _DLL + +//Green Hills Native x86 does not support structural exceptions +# undef ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS +# undef ACE_HAS_WCHAR +# define ACE_CONFIG_INCLUDE_GHS_COMMON +# include "ace/config-ghs-common.h" + +// Changed ACE_TEXT to ACE_TEXT in the following line +# define ACE_CC_NAME ACE_TEXT ("Green Hills C++") +# define ACE_CC_MAJOR_VERSION (1) +# define ACE_CC_MINOR_VERSION (8) +# define ACE_CC_BETA_VERSION (9) +# ifndef ACE_USING_MCPP_PREPROCESSOR +# define ACE_CC_PREPROCESSOR "GCX.EXE" +# define ACE_CC_PREPROCESSOR_ARGS "-E" +# endif + +// GHS uses Microsoft's standard cpp library, which has auto_ptr. +# undef ACE_LACKS_AUTO_PTR +// Microsoft's standard cpp library auto_ptr doesn't have reset (). +# define ACE_AUTO_PTR_LACKS_RESET + +#define ACE_ENDTHREADEX(STATUS) ::_endthreadex ((DWORD) STATUS) + +// This section below was extracted from config-win32-msvc +#define ACE_HAS_ITOA +#define ACE_ITOA_EQUIVALENT ::_itoa +#define ACE_STRCASECMP_EQUIVALENT ::_stricmp +#define ACE_STRNCASECMP_EQUIVALENT ::_strnicmp +#define ACE_WCSDUP_EQUIVALENT ::_wcsdup +// This section above was extracted from config-win32-msvc + +# define ACE_EXPORT_NESTED_CLASSES 1 +# define ACE_HAS_CPLUSPLUS_HEADERS 1 +//# define ACE_HAS_EXCEPTIONS 1 +# define ACE_HAS_GNU_CSTRING_H 1 +# define ACE_HAS_NONCONST_SELECT_TIMEVAL 1 +# define ACE_HAS_SIG_ATOMIC_T 1 +# define ACE_HAS_STANDARD_CPP_LIBRARY 1 +# define ACE_HAS_STDCPP_STL_INCLUDES 1 +# define ACE_HAS_STRERROR 1 +# define ACE_HAS_STRING_CLASS 1 +# define ACE_HAS_TEMPLATE_TYPEDEFS 1 +# define ACE_HAS_USER_MODE_MASKS 1 +# define ACE_LACKS_ACE_IOSTREAM 1 +//# define ACE_LACKS_LINEBUFFERED_STREAMBUF 1 +# define ACE_LACKS_STRPTIME 1 +//# define ACE_LACKS_PRAGMA_ONCE 1 +# define ACE_LACKS_STRRECVFD 1 +//# define ACE_NEW_THROWS_EXCEPTIONS 1 +# define ACE_SIZEOF_LONG_DOUBLE 10 +# define ACE_TEMPLATES_REQUIRE_SOURCE 1 +// Changed ACE_TEXT to ACE_TEXT in the following two lines +# define ACE_UINT64_FORMAT_SPECIFIER ACE_TEXT ("%I64u") +# define ACE_INT64_FORMAT_SPECIFIER ACE_TEXT ("%I64d") +# define ACE_USES_STD_NAMESPACE_FOR_STDCPP_LIB 1 +// Set the following to zero to placate SString.h ACE_WString CTOR +# undef ACE_WSTRING_HAS_USHORT_SUPPORT + +// Green Hills Native x86 does not support __int64 keyword +# define ACE_LACKS_LONGLONG_T + +/* need to ensure these are included before */ +# include +# include + +# if !defined (ACE_LD_DECORATOR_STR) && defined (_DEBUG) +# define ACE_LD_DECORATOR_STR ACE_TEXT ("d") +# endif + +#include /**/ "ace/post.h" +#endif /* ACE_CONFIG_WIN32_GHS_H */ diff --git a/dep/ACE_wrappers/ace/config-win32-interix.h b/dep/ACE_wrappers/ace/config-win32-interix.h new file mode 100644 index 00000000000..d613444fadb --- /dev/null +++ b/dep/ACE_wrappers/ace/config-win32-interix.h @@ -0,0 +1,100 @@ +// -*- C++ -*- +// $Id: config-win32-interix.h 80826 2008-03-04 14:51:23Z wotte $ + +// The following configuration file is designed to work for Interix +// platforms using GNU g++ (Interix == Microsoft's Services for Unix) + +#ifndef ACE_CONFIG_WIN32_INTERIX_H +#define ACE_CONFIG_WIN32_INTERIX_H +#include /**/ "ace/pre.h" +#include + +# define ACE_LACKS_SENDMSG +# define ACE_LACKS_RECVMSG +# define ACE_LACKS_STDINT_H +# define ACE_LACKS_INTTYPES_H +# define ACE_LACKS_PRAGMA_ONCE +# define ACE_LACKS_RWLOCK_T +# define ACE_LACKS_GETPGID // Don't have getpgid(), have setpgid() though... +# define ACE_LACKS_UCONTEXT_H +# define ACE_HAS_REENTRANT_FUNCTIONS +# define ACE_LACKS_NETDB_REENTRANT_FUNCTIONS // Don't have gethostbyaddr_r and friends. +# define ACE_HAS_DIRENT +# define ACE_HAS_STDCPP_STL_INCLUDES +# define ACE_HAS_STANDARD_CPP_LIBRARY 1 +# define ACE_USES_STD_NAMESPACE_FOR_STDCPP_LIB 1 +# define ACE_HAS_NONCONST_SELECT_TIMEVAL +# define ACE_HAS_SIGWAIT +# define ACE_HAS_SIGINFO_T + +#include "ace/config-g++-common.h" + +#define ACE_HAS_NEW_NOTHROW // Need to know 'new's failure semantics. + +#if defined (ACE_HAS_THREADS) +#define ACE_HAS_THREADS +#define ACE_HAS_PTHREADS +#define _THREAD_SAFE +#define ACE_MTSAFE 1 +#define ACE_MT_SAFE 1 +#define ACE_LACKS_PTHREAD_YIELD +#define ACE_HAS_MUTEX_TIMEOUTS +#else + error "You need to enable threads for this Interix port." +#endif /* ACE_HAS_THREADS */ + +// INTERIX has the following, just an issue with porting for the moment +#define ACE_LACKS_ACCESS +// END INTERIX has the following.... + +#define ACE_SIZEOF_LONG_DOUBLE 12 +#define ACE_PAGE_SIZE 4096 + +#define ACE_HAS_SYSV_IPC +#define ACE_HAS_SVR4_SIGNAL_T +#define ACE_HAS_CONSISTENT_SIGNAL_PROTOTYPES +#define ACE_HAS_SVR4_DYNAMIC_LINKING +#define ACE_HAS_POSIX_TIME // Supports POSIX timers via struct timespec. +#define ACE_LACKS_TIMESPEC_T // Defines struct timespec but not timespec_t. +#define ACE_LACKS_STRRECVFD +#define ACE_LACKS_SETSCHED +#define ACE_HAS_SOCKADDR_IN_SIN_LEN +#define ACE_HAS_RTLD_LAZY_V +#define ACE_HAS_POSIX_NONBLOCK +#define ACE_HAS_GETRUSAGE +#define ACE_HAS_SIG_ATOMIC_T +#define ACE_HAS_SEMUN +#define ACE_HAS_SSIZE_T +#define ACE_HAS_STRERROR +#define ACE_HAS_SVR4_GETTIMEOFDAY +#define ACE_HAS_UALARM +#define ACE_HAS_TERMIOS +#define ACE_HAS_SIGWAIT + +// Turns off the tracing feature. +#if !defined (ACE_NTRACE) +#define ACE_NTRACE 1 +#endif /* ACE_NTRACE */ + +// NOTE: In debugging some of the test apps they would all memory fault in using +// ACE_Errno_Guard. Upon inspection of that code it uses TSS to save ERRNO in +// a TSS pointer. Access to that pointer caused the fault. The work around here +// is to tell ACE we have TSS and use emulation. More investigation is needed to +// determine whether Interix TSS is broken or the correct semantics for usage under +// Interix simply need to be ported. +// To get around the issue ACE_HAS_TSS_EMULATION is defined to use TSS emulation +// however while many test programs that use TSS pass the TSS_Test program fails. +#define ACE_HAS_THREAD_SPECIFIC_STORAGE // We need thread specific storage even though... +#define ACE_HAS_TSS_EMULATION // It would appear to be broken in Interix! + +#include /**/ "ace/post.h" +#endif /* ACE_CONFIG_WIN32_INTERIX_H */ + +/* +The following tests do not run. +Dynamic_Priority_Test.log ACE_HAS_TIMED_MESSAGE_BLOCKS +Enum_Interfaces_Test.log +IOStream_Test.log ACE_IOSTREAM not supported on this platform +*/ + + diff --git a/dep/ACE_wrappers/ace/config-win32-mingw.h b/dep/ACE_wrappers/ace/config-win32-mingw.h new file mode 100644 index 00000000000..f4439865de2 --- /dev/null +++ b/dep/ACE_wrappers/ace/config-win32-mingw.h @@ -0,0 +1,100 @@ +// -*- C++ -*- +// $Id: config-win32-mingw.h 81693 2008-05-14 12:35:01Z johnnyw $ + +// +// The following configuration file is designed to work for win32 +// platforms using gcc/g++ with mingw32 (http://www.mingw.org). +// + +#ifndef ACE_CONFIG_WIN32_MINGW_H +#define ACE_CONFIG_WIN32_MINGW_H +#include /**/ "ace/pre.h" + +#ifndef ACE_CONFIG_WIN32_H +# error Use config-win32.h in config.h instead of this header +#endif /* ACE_CONFIG_WIN32_H */ + +#define ACE_CC_NAME ACE_TEXT ("g++") +#define ACE_CC_PREPROCESSOR "cpp" +#define ACE_CC_PREPROCESOR_ARGS "" + +// Why all this is not in config-g++-common.h? +#define ACE_CC_MAJOR_VERSION __GNUC__ +#define ACE_CC_MINOR_VERSION __GNUC_MINOR__ +#define ACE_CC_BETA_VERSION (0) + +#if !defined(__MINGW32__) +# error You do not seem to be using mingw32 +#endif + +#include "ace/config-g++-common.h" + +#include /**/ <_mingw.h> +#include /**/ + +#define ACE_HAS_USER_MODE_MASKS + +#if (__MINGW32_MAJOR_VERSION < 2) +# error You need a newer version (>= 2.0) of mingw32/w32api +#endif + +#if (__MINGW32_MAJOR_VERSION >= 3) +# define ACE_HAS_SSIZE_T +# undef ACE_LACKS_STRUCT_DIR +# undef ACE_LACKS_OPENDIR +# undef ACE_LACKS_CLOSEDIR +# undef ACE_LACKS_READDIR +# undef ACE_LACKS_TELLDIR +# undef ACE_LACKS_SEEKDIR +# undef ACE_LACKS_REWINDDIR +#else +# define ACE_LACKS_DIRENT_H +#endif + +#undef ACE_LACKS_SIGSET + +#define ACE_LACKS_SIGSET_DEFINITIONS +#define ACE_LACKS_SYS_SHM_H +#define ACE_LACKS_TERMIOS_H +#define ACE_LACKS_NETINET_TCP_H +#define ACE_LACKS_STRRECVFD +#define ACE_LACKS_STRPTIME +#define ACE_HAS_STRERROR +#define ACE_LACKS_POLL_H +#define ACE_LACKS_REGEX_H +#define ACE_LACKS_SYS_MSG_H +#define ACE_LACKS_PWD_H +#define ACE_LACKS_SEMAPHORE_H +#define ACE_LACKS_UCONTEXT_H +#define ACE_LACKS_SYS_SELECT_H +#define ACE_LACKS_SYS_RESOURCE_H +#define ACE_LACKS_SYS_WAIT_H +#define ACE_LACKS_DLFCN_H +#define ACE_LACKS_SYS_MMAN_H +#define ACE_LACKS_SYS_UIO_H +#define ACE_LACKS_SYS_SOCKET_H +#define ACE_LACKS_NETINET_IN_H +#define ACE_LACKS_NETDB_H +#define ACE_LACKS_NET_IF_H +#define ACE_LACKS_SYS_IPC_H +#define ACE_LACKS_SYS_SEM_H +#define ACE_LACKS_STROPTS_H +#define ACE_LACKS_SYS_IOCTL_H +#define ACE_LACKS_PDH_H +#define ACE_LACKS_PDHMSG_H +#define ACE_HAS_NONCONST_WCSDUP +#define ACE_HAS_WINSOCK2_GQOS + +// We trust the user: He must have used -mpentiumpro or -mpentium +// if that is what he wants. +#if defined(pentiumpro) || defined(pentium) +# define ACE_HAS_PENTIUM +#endif + +#define ACE_INT64_FORMAT_SPECIFIER ACE_TEXT ("%I64d") +#define ACE_UINT64_FORMAT_SPECIFIER ACE_TEXT ("%I64u") + +#define ACE_ENDTHREADEX(STATUS) ::_endthreadex ((DWORD) (STATUS)) + +#include /**/ "ace/post.h" +#endif /* ACE_CONFIG_WIN32_MINGW_H */ diff --git a/dep/ACE_wrappers/ace/config-win32-msvc-7.h b/dep/ACE_wrappers/ace/config-win32-msvc-7.h new file mode 100644 index 00000000000..535643a8fbf --- /dev/null +++ b/dep/ACE_wrappers/ace/config-win32-msvc-7.h @@ -0,0 +1,125 @@ +/* -*- C++ -*- */ +//============================================================================= +/** + * @file config-win32-msvc-7.h + * + * $Id: config-win32-msvc-7.h 81935 2008-06-12 22:01:53Z jtc $ + * + * @brief Microsoft Visual C++ 7.0 configuration file. + * + * This file is the ACE configuration file for Microsoft Visual C++ version 7. + * + * @note Do not include this file directly, include config-win32.h instead. + * + * @author Darrell Brunsch + */ +//============================================================================= + +#ifndef ACE_CONFIG_WIN32_MSVC_7_H +#define ACE_CONFIG_WIN32_MSVC_7_H +#include /**/ "ace/pre.h" + +#ifndef ACE_CONFIG_WIN32_H +#error Use config-win32.h in config.h instead of this header +#endif /* ACE_CONFIG_WIN32_H */ + +// Visual C++ 7.0 (.NET) deprecated the old iostreams +#if !defined (ACE_HAS_STANDARD_CPP_LIBRARY) +#define ACE_HAS_STANDARD_CPP_LIBRARY 1 +#endif + +#if !defined (ACE_USES_STD_NAMESPACE_FOR_STDCPP_LIB) +#define ACE_USES_STD_NAMESPACE_FOR_STDCPP_LIB 1 +#endif + +// Win64 SDK compiler claims std::auto_ptr<>::reset not available. +#if defined (_WIN64) || defined (WIN64) +#define ACE_AUTO_PTR_LACKS_RESET +#endif + +#define ACE_HAS_ITOA +#define ACE_HAS_HEADER_ALLOCATED_CLASS_STATIC_CONST_INT_STOREAGE +#define ACE_HAS_WORKING_EXPLICIT_TEMPLATE_DESTRUCTOR + +#define ACE_ITOA_EQUIVALENT ::_itoa +#define ACE_STRCASECMP_EQUIVALENT ::_stricmp +#define ACE_STRNCASECMP_EQUIVALENT ::_strnicmp +#define ACE_WCSDUP_EQUIVALENT ::_wcsdup + +#if !defined (ACE_HAS_WINCE) && !defined (ACE_HAS_EXCEPTIONS) +#define ACE_HAS_EXCEPTIONS +#endif /* ACE_HAS_WINCE */ + +#define ACE_HAS_STRERROR +#define ACE_LACKS_STRPTIME + +#define ACE_HAS_SIG_ATOMIC_T +#define ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES +#define ACE_LACKS_STRRECVFD +#define ACE_HAS_CPLUSPLUS_HEADERS + +#define ACE_HAS_TEMPLATE_TYPEDEFS +#define ACE_TEMPLATES_REQUIRE_SOURCE + +// Platform provides ACE_TLI function prototypes. +// For Win32, this is not really true, but saves a lot of hassle! +#define ACE_HAS_TLI_PROTOTYPES + +// Platform support linebuffered streaming is broken +#define ACE_LACKS_LINEBUFFERED_STREAMBUF + +#if !defined (ACE_HAS_WINCE) && !(defined (__INTEL_COMPILER) && (__INTEL_COMPILER == 900)) +# define ACE_HAS_INTRINSIC_INTERLOCKED +# define ACE_HAS_INTRINSIC_BYTESWAP +#endif + +#if defined (ACE_HAS_STANDARD_CPP_LIBRARY) && (ACE_HAS_STANDARD_CPP_LIBRARY != 0) + +// Platform has its Standard C++ library in the namespace std +# if !defined (ACE_USES_STD_NAMESPACE_FOR_STDCPP_LIB) +# define ACE_USES_STD_NAMESPACE_FOR_STDCPP_LIB 1 +# endif /* ACE_USES_STD_NAMESPACE_FOR_STDCPP_LIB */ + +// ace/iostream.h does not work with the standard cpp library (yet). +# if !defined (ACE_USES_OLD_IOSTREAMS) +# define ACE_LACKS_ACE_IOSTREAM +# endif /* ! ACE_USES_OLD_IOSTREAMS */ + +// Starting with MSVC 7.1, std::new throws std::bad_alloc on out-of-memory. +// Since we don't support MSVC 7.0, don't test for it. +# define ACE_NEW_THROWS_EXCEPTIONS +# define ACE_HAS_NEW_NOTHROW + +#else + +// iostream header lacks ipfx (), isfx (), etc., declarations +# define ACE_LACKS_IOSTREAM_FX + +#endif + +// There are too many instances of this warning to fix it right now. +// Maybe in the future. +// 'this' : used in base member initializer list +#pragma warning(disable:4355) + +// 'class1' : inherits 'class2::member' via dominance +#pragma warning(disable:4250) + +// C++ Exception Specification ignored +#pragma warning(disable:4290) + +// Disable warning of using Microsoft Extension. +#pragma warning(disable:4231) + +// 'function' : unreferenced local function has been removed +# pragma warning(disable:4505) + +// A template can not be exported. Only an instantiation may be exported. +#define ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION_EXPORT + +// At least for ACE_UNIMPLEMENTED_FUNC in class templates, this is needed to +// explicitly instantiate a template that has ACE_UNIMPLEMENTED_FUNC. +# define ACE_NEEDS_FUNC_DEFINITIONS + +#include /**/ "ace/post.h" +#endif /* ACE_CONFIG_WIN32_MSVC_7_H */ diff --git a/dep/ACE_wrappers/ace/config-win32-msvc-8.h b/dep/ACE_wrappers/ace/config-win32-msvc-8.h new file mode 100644 index 00000000000..73c29e1d482 --- /dev/null +++ b/dep/ACE_wrappers/ace/config-win32-msvc-8.h @@ -0,0 +1,148 @@ +/* -*- C++ -*- */ +//============================================================================= +/** + * @file config-win32-msvc-8.h + * + * $Id: config-win32-msvc-8.h 81935 2008-06-12 22:01:53Z jtc $ + * + * @brief Microsoft Visual C++ 8.0 configuration file. + * + * This file is the ACE configuration file for Microsoft Visual C++ version 8. + * + * @note Do not include this file directly, include config-win32.h instead. + * + * @author Darrell Brunsch + */ +//============================================================================= + +#ifndef ACE_CONFIG_WIN32_MSVC_8_H +#define ACE_CONFIG_WIN32_MSVC_8_H +#include /**/ "ace/pre.h" + +#ifndef ACE_CONFIG_WIN32_H +#error Use config-win32.h in config.h instead of this header +#endif /* ACE_CONFIG_WIN32_H */ + +#ifndef ACE_WIN32_VC8 +# define ACE_WIN32_VC8 +#endif + +// Visual C++ 8.0 (.NET) deprecated the old iostreams +#if !defined (ACE_HAS_STANDARD_CPP_LIBRARY) +#define ACE_HAS_STANDARD_CPP_LIBRARY 1 +#endif + +#if !defined (ACE_USES_STD_NAMESPACE_FOR_STDCPP_LIB) +#define ACE_USES_STD_NAMESPACE_FOR_STDCPP_LIB 1 +#endif + +// Windows' timeval is non-conformant (defined in terms of long instead of +// time_t) and VC8 (on desktop, not CE) changed time_t to a 64-bit value +// even when compiling a 32-bit application. Therefore, ace/Time_Value +// needs to rearrange a few things for this compiler. See Time_Value.h +// for complete details. +#if !defined (ACE_HAS_WINCE) +# define ACE_HAS_TIME_T_LONG_MISMATCH +#endif + +#define ACE_HAS_ITOA +#define ACE_HAS_HEADER_ALLOCATED_CLASS_STATIC_CONST_INT_STOREAGE +#define ACE_HAS_WORKING_EXPLICIT_TEMPLATE_DESTRUCTOR + +#define ACE_ITOA_EQUIVALENT ::_itoa +#define ACE_STRCASECMP_EQUIVALENT ::_stricmp +#define ACE_STRNCASECMP_EQUIVALENT ::_strnicmp +#define ACE_WCSDUP_EQUIVALENT ::_wcsdup + +#define ACE_HAS_EXCEPTIONS + +// Windows Mobile 5 doesn't do sig_atomic_t, but maybe future versions will. +# if !defined (_WIN32_WCE) || (_WIN32_WCE > 0x501) +# define ACE_HAS_SIG_ATOMIC_T +# endif /* !Win CE 5.0 or less */ + +#define ACE_HAS_STRERROR +#define ACE_LACKS_STRPTIME + +#if !defined (ACE_HAS_WINCE) +# define ACE_HAS_INTRIN_H +# define ACE_HAS_INTRINSIC_INTERLOCKED +#endif + +#if !defined (_WIN32_WCE) || (_WIN32_WCE >= 0x501) +# define ACE_HAS_INTRINSIC_BYTESWAP +#endif + +#define ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES +#define ACE_LACKS_STRRECVFD +#define ACE_HAS_CPLUSPLUS_HEADERS + +#define ACE_HAS_TEMPLATE_TYPEDEFS +#define ACE_TEMPLATES_REQUIRE_SOURCE + +// Platform provides ACE_TLI function prototypes. +// For Win32, this is not really true, but saves a lot of hassle! +#define ACE_HAS_TLI_PROTOTYPES + +// Platform support linebuffered streaming is broken +#define ACE_LACKS_LINEBUFFERED_STREAMBUF + +#if defined (ACE_HAS_STANDARD_CPP_LIBRARY) && (ACE_HAS_STANDARD_CPP_LIBRARY != 0) + +// Platform has its Standard C++ library in the namespace std +# if !defined (ACE_USES_STD_NAMESPACE_FOR_STDCPP_LIB) +# define ACE_USES_STD_NAMESPACE_FOR_STDCPP_LIB 1 +# endif /* ACE_USES_STD_NAMESPACE_FOR_STDCPP_LIB */ + +// ace/iostream.h does not work with the standard cpp library (yet). +# if !defined (ACE_USES_OLD_IOSTREAMS) +# define ACE_LACKS_ACE_IOSTREAM +# endif /* ! ACE_USES_OLD_IOSTREAMS */ + +// Starting with MSVC 7.1, std::new throws std::bad_alloc on out-of-memory. +#define ACE_NEW_THROWS_EXCEPTIONS +#define ACE_HAS_NEW_NOTHROW + +#else + +// iostream header lacks ipfx (), isfx (), etc., declarations +# define ACE_LACKS_IOSTREAM_FX + +#endif + +// There are too many instances of this warning to fix it right now. +// Maybe in the future. + +// Disable warning of using Microsoft Extension. +# pragma warning(disable:4231) + +// CE (at least thru Windows Mobile 5) doesn't have the new, secure CRT. +#if !defined (ACE_HAS_WINCE) && !defined (ACE_HAS_TR24731_2005_CRT) +# define ACE_HAS_TR24731_2005_CRT +#endif + +//Detect Platform SDK 64-bit (AMD64) compiler using _MSC_FULL_VER +#if (defined (_WIN64) || defined (WIN64)) && _MSC_FULL_VER < 140050000 +# define ACE_AUTO_PTR_LACKS_RESET +# define ACE_MSVC_USES_DOUBLE_UNDERSCORE_STAT64 +# define ACE_HAS_BROKEN_STD_REVERSE_ITERATOR +# define ACE_LACKS_NUMERIC_LIMITS_64_BIT_TYPES +# undef ACE_HAS_TR24731_2005_CRT +# undef ACE_HAS_INTRIN_H +#endif + +// On CE w/o MFC config-WinCE.h needs to declare a placement new. This +// triggers a warning that there's no placement delete, which can be ignored. +#if defined (ACE_HAS_WINCE) && !defined (ACE_HAS_MFC) +# pragma warning(disable:4291) +#endif + +// A template can not be exported. Only an instantiation may be exported. +#define ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION_EXPORT + +// At least for ACE_UNIMPLEMENTED_FUNC in class templates, this is needed to +// explicitly instantiate a template that has ACE_UNIMPLEMENTED_FUNC. +# define ACE_NEEDS_FUNC_DEFINITIONS + +#include /**/ "ace/post.h" +#endif /* ACE_CONFIG_WIN32_MSVC_8_H */ diff --git a/dep/ACE_wrappers/ace/config-win32-msvc-9.h b/dep/ACE_wrappers/ace/config-win32-msvc-9.h new file mode 100644 index 00000000000..8f148b4c00e --- /dev/null +++ b/dep/ACE_wrappers/ace/config-win32-msvc-9.h @@ -0,0 +1,140 @@ +/* -*- C++ -*- */ +//============================================================================= +/** + * @file config-win32-msvc-9.h + * + * $Id: config-win32-msvc-9.h 81935 2008-06-12 22:01:53Z jtc $ + * + * @brief Microsoft Visual C++ 9.0 configuration file. + * + * This file is the ACE configuration file for Microsoft Visual C++ version 9. + * + * @note Do not include this file directly, include config-win32.h instead. + */ +//============================================================================= + +#ifndef ACE_CONFIG_WIN32_MSVC_9_H +#define ACE_CONFIG_WIN32_MSVC_9_H +#include /**/ "ace/pre.h" + +#ifndef ACE_CONFIG_WIN32_H +#error Use config-win32.h in config.h instead of this header +#endif /* ACE_CONFIG_WIN32_H */ + +#ifndef ACE_WIN32_VC9 +# define ACE_WIN32_VC9 +#endif + +// Visual C++ 9.0 (.NET) deprecated the old iostreams +#if !defined (ACE_HAS_STANDARD_CPP_LIBRARY) +#define ACE_HAS_STANDARD_CPP_LIBRARY 1 +#endif + +#if !defined (ACE_USES_STD_NAMESPACE_FOR_STDCPP_LIB) +#define ACE_USES_STD_NAMESPACE_FOR_STDCPP_LIB 1 +#endif + +// Windows' timeval is non-conformant (defined in terms of long instead of +// time_t) and VC9 (on desktop, not CE) changed time_t to a 64-bit value +// even when compiling a 32-bit application. Therefore, ace/Time_Value +// needs to rearrange a few things for this compiler. See Time_Value.h +// for complete details. +#if !defined (ACE_HAS_WINCE) +# define ACE_HAS_TIME_T_LONG_MISMATCH +#endif + +#define ACE_HAS_ITOA +#define ACE_HAS_HEADER_ALLOCATED_CLASS_STATIC_CONST_INT_STOREAGE +#define ACE_HAS_WORKING_EXPLICIT_TEMPLATE_DESTRUCTOR + +#define ACE_ITOA_EQUIVALENT ::_itoa +#define ACE_STRCASECMP_EQUIVALENT ::_stricmp +#define ACE_STRNCASECMP_EQUIVALENT ::_strnicmp +#define ACE_WCSDUP_EQUIVALENT ::_wcsdup + +#define ACE_HAS_EXCEPTIONS + +// Windows Mobile 5 doesn't do sig_atomic_t, but maybe future versions will. +# if !defined (_WIN32_WCE) || (_WIN32_WCE > 0x501) +# define ACE_HAS_SIG_ATOMIC_T +# endif /* !Win CE 5.0 or less */ + +#define ACE_HAS_STRERROR +#define ACE_LACKS_STRPTIME + +// Evaluate this with a WinCE build; maybe things have improved since VC8. +//#if !defined (ACE_HAS_WINCE) +# define ACE_HAS_INTRIN_H +# define ACE_HAS_INTRINSIC_INTERLOCKED +//#endif + +#if !defined (_WIN32_WCE) || (_WIN32_WCE >= 0x501) +# define ACE_HAS_INTRINSIC_BYTESWAP +#endif + +#define ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES +#define ACE_LACKS_STRRECVFD +#define ACE_HAS_CPLUSPLUS_HEADERS + +#define ACE_HAS_TEMPLATE_TYPEDEFS +#define ACE_TEMPLATES_REQUIRE_SOURCE + +// Platform provides ACE_TLI function prototypes. +// For Win32, this is not really true, but saves a lot of hassle! +#define ACE_HAS_TLI_PROTOTYPES + +// Platform support linebuffered streaming is broken +#define ACE_LACKS_LINEBUFFERED_STREAMBUF + +#if defined (ACE_HAS_STANDARD_CPP_LIBRARY) && (ACE_HAS_STANDARD_CPP_LIBRARY != 0) + +// Platform has its Standard C++ library in the namespace std +# if !defined (ACE_USES_STD_NAMESPACE_FOR_STDCPP_LIB) +# define ACE_USES_STD_NAMESPACE_FOR_STDCPP_LIB 1 +# endif /* ACE_USES_STD_NAMESPACE_FOR_STDCPP_LIB */ + +// ace/iostream.h does not work with the standard cpp library (yet). +# if !defined (ACE_USES_OLD_IOSTREAMS) +# define ACE_LACKS_ACE_IOSTREAM +# endif /* ! ACE_USES_OLD_IOSTREAMS */ + +// Starting with MSVC 7.1, std::new throws std::bad_alloc on out-of-memory. +#define ACE_NEW_THROWS_EXCEPTIONS +#define ACE_HAS_NEW_NOTHROW + +#else + +// iostream header lacks ipfx (), isfx (), etc., declarations +# define ACE_LACKS_IOSTREAM_FX + +#endif + +// There are too many instances of this warning to fix it right now. +// Maybe in the future. + +// Disable warning of using Microsoft Extension. +# pragma warning(disable:4231) + +// 'class1' : inherits 'class2::member' via dominance +#pragma warning(disable:4250) + +// CE (at least thru Windows Mobile 5) doesn't have the new, secure CRT. +#if !defined (ACE_HAS_WINCE) && !defined (ACE_HAS_TR24731_2005_CRT) +# define ACE_HAS_TR24731_2005_CRT +#endif + +// On CE w/o MFC config-WinCE.h needs to declare a placement new. This +// triggers a warning that there's no placement delete, which can be ignored. +#if defined (ACE_HAS_WINCE) && !defined (ACE_HAS_MFC) +# pragma warning(disable:4291) +#endif + +// A template can not be exported. Only an instantiation may be exported. +#define ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION_EXPORT + +// At least for ACE_UNIMPLEMENTED_FUNC in class templates, this is needed to +// explicitly instantiate a template that has ACE_UNIMPLEMENTED_FUNC. +# define ACE_NEEDS_FUNC_DEFINITIONS + +#include /**/ "ace/post.h" +#endif /* ACE_CONFIG_WIN32_MSVC_9_H */ diff --git a/dep/ACE_wrappers/ace/config-win32-msvc.h b/dep/ACE_wrappers/ace/config-win32-msvc.h new file mode 100644 index 00000000000..a7f8898fce7 --- /dev/null +++ b/dep/ACE_wrappers/ace/config-win32-msvc.h @@ -0,0 +1,169 @@ +//============================================================================= +/** + * @file config-win32-msvc.h + * + * $Id: config-win32-msvc.h 82643 2008-08-19 14:02:12Z johnnyw $ + * + * @brief Microsoft Visual C++ configuration file. + * + * This file is the ACE configuration file for Microsoft Visual C++ versions + * 5.0, 6.0, and 7.0 (.NET) + * + * @author Darrell Brunsch + */ +//============================================================================= + +#ifndef ACE_CONFIG_WIN32_MSVC_H +#define ACE_CONFIG_WIN32_MSVC_H +#include /**/ "ace/pre.h" + +#ifndef ACE_CONFIG_WIN32_H +#error Use config-win32.h in config.h instead of this header +#endif /* ACE_CONFIG_WIN32_H */ + +#define ACE_CC_NAME ACE_TEXT ("Visual C++") +#ifndef ACE_USING_MCPP_PREPROCESSOR +# define ACE_CC_PREPROCESSOR "CL.EXE" +# define ACE_CC_PREPROCESSOR_ARGS "-nologo -E" +#endif + +#define ACE_CC_MAJOR_VERSION (_MSC_VER / 100 - 6) +#define ACE_CC_MINOR_VERSION (_MSC_VER % 100) +#define ACE_CC_BETA_VERSION (0) + +#if !defined (ACE_LD_DECORATOR_STR) +# if defined (_DEBUG) +# define ACE_LD_DECORATOR_STR ACE_TEXT ("d") +# endif /* _DEBUG */ +#endif /* ACE_LD_DECORATOR_STR */ + +#if !defined(_NATIVE_WCHAR_T_DEFINED) + #define ACE_LACKS_NATIVE_WCHAR_T +#endif + +// Win Mobile still does thread exits differently than PC Windows. +#if defined (_WIN32_WCE) +# define ACE_ENDTHREADEX(STATUS) ExitThread ((DWORD) STATUS) +#else +# define ACE_ENDTHREADEX(STATUS) ::_endthreadex ((DWORD) STATUS) +#endif /* _WIN32_WCE */ + +#if (_MSC_VER >= 1500) +# include "ace/config-win32-msvc-9.h" +#elif (_MSC_VER >= 1400) +# include "ace/config-win32-msvc-8.h" +#elif (_MSC_VER >= 1310) +# include "ace/config-win32-msvc-7.h" +#else +# error This version of Microsoft Visual C++ is not supported. +#endif + +// MFC changes the behavior of operator new at all MSVC versions from 6 up +// by throwing a static CMemoryException* instead of std::bad_alloc +// (see ace/OS_Memory.h). This MFC exception object needs to be cleaned up +// by calling its Delete() method. +#if defined (ACE_HAS_MFC) && (ACE_HAS_MFC == 1) +# if !defined (ACE_NEW_THROWS_EXCEPTIONS) +# define ACE_NEW_THROWS_EXCEPTIONS +# endif +# if defined (ACE_bad_alloc) +# undef ACE_bad_alloc +# endif +# define ACE_bad_alloc CMemoryException *e +# if defined (ACE_del_bad_alloc) +# undef ACE_del_bad_alloc +# endif +# define ACE_del_bad_alloc e->Delete(); +#endif /* ACE_HAS_MFC && ACE_HAS_MFC==1 */ + +#if defined(ACE_MT_SAFE) && (ACE_MT_SAFE != 0) +// must have _MT defined to include multithreading +// features from win32 headers +# if !defined(_MT) && !defined (ACE_HAS_WINCE) +// *** DO NOT *** defeat this error message by defining _MT yourself. +// On MSVC, this is changed by selecting the Multithreaded +// DLL or Debug Multithreaded DLL in the Project Settings +// under C++ Code Generation. +# error You must link against multi-threaded libraries when using ACE (check your project settings) +# endif /* !_MT && !ACE_HAS_WINCE */ +#endif /* ACE_MT_SAFE && ACE_MT_SAFE != 0 */ + +#include +// Although ACE does have alloca() on this compiler/platform combination, it is +// disabled by default since it can be dangerous. Uncomment the following line +// if you ACE to use it. +//#define ACE_HAS_ALLOCA 1 + +#define ACE_LACKS_DIRENT_H +#define ACE_LACKS_DLFCN_H +#define ACE_LACKS_INTTYPES_H +#define ACE_LACKS_NETDB_H +#define ACE_LACKS_NET_IF_H +#define ACE_LACKS_NETINET_IN_H +#define ACE_LACKS_STDINT_H +#define ACE_LACKS_STROPTS_H +#define ACE_LACKS_SYS_IOCTL_H +#define ACE_LACKS_SYS_IPC_H +#define ACE_LACKS_SYS_MMAN_H +#define ACE_LACKS_SYS_RESOURCE_H +#define ACE_LACKS_SYS_SELECT_H +#define ACE_LACKS_SYS_SEM_H +#define ACE_LACKS_SYS_SOCKET_H +#define ACE_LACKS_SYS_TIME_H +#define ACE_LACKS_SYS_UIO_H +#define ACE_LACKS_SYS_WAIT_H +#define ACE_LACKS_UCONTEXT_H + +#define ACE_LACKS_SEMAPHORE_H +#define ACE_LACKS_STRINGS_H +#define ACE_LACKS_PWD_H +#define ACE_LACKS_POLL_H +#define ACE_LACKS_SYS_SHM_H +#define ACE_LACKS_SYS_MSG_H +#define ACE_LACKS_NETINET_TCP_H +#define ACE_LACKS_TERMIOS_H +#define ACE_LACKS_REGEX_H + +#define ACE_INT64_FORMAT_SPECIFIER ACE_TEXT ("%I64d") +#define ACE_UINT64_FORMAT_SPECIFIER ACE_TEXT ("%I64u") + +#define ACE_STRTOULL_EQUIVALENT ::_strtoui64 +#define ACE_WCSTOOULL_EQUIVALENT ::_wcstoui64 + +// Turn off warnings for /W4 +// To resume any of these warning: #pragma warning(default: 4xxx) +// which should be placed after these defines + +#if !defined (ALL_WARNINGS) && defined(_MSC_VER) && !defined(ghs) && !defined(__MINGW32__) +# pragma warning(disable: 4127) /* constant expression for TRACE/ASSERT */ +# pragma warning(disable: 4134) /* message map member fxn casts */ +# pragma warning(disable: 4511) /* private copy constructors are good to have */ +# pragma warning(disable: 4512) /* private operator= are good to have */ +# pragma warning(disable: 4514) /* unreferenced inlines are common */ +# pragma warning(disable: 4710) /* private constructors are disallowed */ +# pragma warning(disable: 4705) /* statement has no effect in optimized code */ +# pragma warning(disable: 4791) /* loss of debugging info in retail version */ +# pragma warning(disable: 4275) /* deriving exported class from non-exported */ +# pragma warning(disable: 4251) /* using non-exported as public in exported */ +# pragma warning(disable: 4786) /* identifier was truncated to '255' characters in the browser information */ +# pragma warning(disable: 4097) /* typedef-name used as synonym for class-name */ +# pragma warning(disable: 4800) /* converting int to boolean */ +# if defined (__INTEL_COMPILER) +# pragma warning(disable: 1744) /* field of class type without a DLL interface used in a class with a DLL interface */ +# pragma warning(disable: 1738) +# endif +#endif /* !ALL_WARNINGS && _MSV_VER && !ghs && !__MINGW32__ */ + +// STRICT type checking in WINDOWS.H enhances type safety for Windows +// programs by using distinct types to represent all the different +// HANDLES in Windows. So for example, STRICT prevents you from +// mistakenly passing an HPEN to a routine expecting an HBITMAP. +// Note that we only use this if we +# if defined (ACE_HAS_STRICT) && (ACE_HAS_STRICT != 0) +# if !defined (STRICT) /* may already be defined */ +# define STRICT +# endif /* !STRICT */ +# endif /* ACE_HAS_STRICT */ + +#include /**/ "ace/post.h" +#endif /* ACE_CONFIG_WIN32_MSVC_H */ diff --git a/dep/ACE_wrappers/ace/config-win32.h b/dep/ACE_wrappers/ace/config-win32.h new file mode 100644 index 00000000000..76f258eb3ee --- /dev/null +++ b/dep/ACE_wrappers/ace/config-win32.h @@ -0,0 +1,93 @@ +/* -*- C++ -*- */ +//============================================================================= +/** + * @file config-win32.h + * + * $Id: config-win32.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @brief Microsoft Windows configuration file. + * + * This file is the ACE configuration file for all of Microsoft Windows + * platforms that ACE runs on. Based on preprocessor definitions, it + * includes other more specific configuration files. + * + * @author Darrell Brunsch + */ +//============================================================================= + +#ifndef ACE_CONFIG_WIN32_H +#define ACE_CONFIG_WIN32_H +#include /**/ "ace/pre.h" + +// by derex ,I include the win32 specific header here, +// this violates the idea of this file a bit ;) +#define ACE_HAS_REACTOR_NOTIFICATION_QUEUE + +// Max amount of connections for non-epoll platforms +#ifndef FD_SETSIZE + #define FD_SETSIZE 4096 +#endif + +//disable some deprecate warnings on windows +#ifndef _CRT_NONSTDC_NO_WARNINGS + #define _CRT_NONSTDC_NO_WARNINGS +#endif + +#ifndef _CRT_SECURE_NO_WARNINGS + #define _CRT_SECURE_NO_WARNINGS +#endif + +#ifndef _CRT_SECURE_NO_DEPRECATE + #define _CRT_SECURE_NO_DEPRECATE +#endif + +#ifndef _CRT_NONSTDC_NO_DEPRECATE + #define _CRT_NONSTDC_NO_DEPRECATE +#endif + +#ifndef _WINDOWS + #define _WINDOWS +#endif + +// end custom config stuff + + +// NOTE: Please do not add anything besides #include's here. Put other stuff +// (definitions, etc.) in the included headers + +// We need to ensure that for Borland vcl.h can be included before +// windows.h. So we will not include config-win32-common.h from here, +// but instead let it be included at the appropriate place in +// config-win32-borland.h. +#if !defined (__BORLANDC__) +# include "ace/config-win32-common.h" +#endif /* !__BORLANDC__ */ + +// Include the config-win32-* file specific to the compiler +#if defined (__BORLANDC__) +# include "ace/config-win32-borland.h" +#elif defined (_MSC_VER) +# include "ace/config-win32-msvc.h" +#elif defined (ghs) +# include "ace/config-win32-ghs.h" +#elif defined (__MINGW32__) +# include "ace/config-win32-mingw.h" +#elif defined (__DMC__) +# include "ace/config-win32-dmc.h" +#else +# error Compiler is not supported +#endif + +// gethostbyaddr does not handle IPv6-mapped-IPv4 addresses +#define ACE_HAS_BROKEN_GETHOSTBYADDR_V4MAPPED + +// TODO remove this at some point when we add ACE::init and ACE::fini +// by derex +#ifdef ACE_HAS_NONSTATIC_OBJECT_MANAGER +#undef ACE_HAS_NONSTATIC_OBJECT_MANAGER +#endif //ACE_HAS_NONSTATIC_OBJECT_MANAGER + + +#include /**/ "ace/post.h" +#endif /* ACE_CONFIG_WIN32_H */ + diff --git a/dep/ACE_wrappers/ace/config.h.in b/dep/ACE_wrappers/ace/config.h.in new file mode 100644 index 00000000000..298a9a270ce --- /dev/null +++ b/dep/ACE_wrappers/ace/config.h.in @@ -0,0 +1,2163 @@ +/* ace/config.h.in. Generated from configure.ac by autoheader. */ + + +#ifndef ACE_CONFIG_H +#define ACE_CONFIG_H + +// ACE configuration header file + + + + +/* Compiler/platform standard C++ auto_ptr implementation lacks reset() method + */ +#undef ACE_AUTO_PTR_LACKS_RESET + +/* Enable ACE_Timeprobes */ +#undef ACE_COMPILE_TIMEPROBES + +/* */ +#undef ACE_DEFAULT_BASE_ADDR + +/* */ +#undef ACE_DEFAULT_BASE_ADDRL + +/* */ +#undef ACE_DEFAULT_CLOSE_ALL_HANDLES + +/* */ +#undef ACE_DEFAULT_MAX_SOCKET_BUFSIZ + +/* The default number of handles the select()-based reactor should handle */ +#undef ACE_DEFAULT_SELECT_REACTOR_SIZE + +/* Number of TSS keys, with ACE_HAS_TSS_EMULATION _only_. Defaults to 64. */ +#undef ACE_DEFAULT_THREAD_KEYS + +/* Define this if you don't want debug version ACE search for debug version + DLLs first before looking for the DLL names specified. */ +#undef ACE_DISABLE_DEBUG_DLL_CHECK + +/* Do not include emulation for timed semaphore acquisitions. */ +#undef ACE_DISABLE_POSIX_SEM_TIMEOUT_EMULATION + +/* Define to 1 to disable swapping swapping CDR on read */ +#undef ACE_DISABLE_SWAP_ON_READ + +/* Define to DLL file suffix */ +#undef ACE_DLL_SUFFIX + +/* Define to 1 to enable swapping swapping CDR on write */ +#undef ACE_ENABLE_SWAP_ON_WRITE + +/* Compiler requires template args when explicitly calling template + destructor. */ +#undef ACE_EXPLICIT_TEMPLATE_DESTRUCTOR_TAKES_ARGS + +/* Define to 1 if the getsockname() and getpeername() return random values in + the sockaddr_in.sin_zero field. */ +#undef ACE_GETNAME_RETURNS_RANDOM_SIN_ZERO + +/* Uses ctime_r & asctime_r with only two parameters vs. three. */ +#undef ACE_HAS_2_PARAM_ASCTIME_R_AND_CTIME_R + +/* Define to 1 if platform has 2 parameter sched_getaffinity() */ +#undef ACE_HAS_2_PARAM_SCHED_GETAFFINITY + +/* Define to 1 if platform has 2 parameter sched_setaffinity() */ +#undef ACE_HAS_2_PARAM_SCHED_SETAFFINITY + +/* Define to 1 if platform has 3 parameter readdir_r() */ +#undef ACE_HAS_3_PARAM_READDIR_R + +/* Define to 1 if platform has 3 parameter wcstok() */ +#undef ACE_HAS_3_PARAM_WCSTOK + +/* Platform has BSD 4.4 sendmsg()/recvmsg() APIs. */ +#undef ACE_HAS_4_4BSD_SENDMSG_RECVMSG + +/* Platform supports Asynchronous IO calls */ +#undef ACE_HAS_AIO_CALLS + +/* Platform has AIX4 ::read_real_time() */ +#undef ACE_HAS_AIX_HI_RES_TIMER + +/* Compiler/platform supports alloca(). */ +#undef ACE_HAS_ALLOCA + +/* Compiler/platform has */ +#undef ACE_HAS_ALLOCA_H + +/* Define to 1 if system should use Alpha's cycle counter */ +#undef ACE_HAS_ALPHA_TIMER + +/* Use ACE's alternate cuserid() implementation since a system cuserid() may + not exist, or it is not desirable to use it. The implementation requires + ACE_LACKS_PWD_FUNCTIONS to be undefined and that the geteuid() system call + exists. */ +#undef ACE_HAS_ALT_CUSERID + +/* Compiler/platform correctly calls init()/fini() for shared libraries. */ +#undef ACE_HAS_AUTOMATIC_INIT_FINI + +/* Compiler/platform has "big" fd_set, i.e. large number of bits set in fd_set + passed back from select(). */ +#undef ACE_HAS_BIG_FD_SET + +/* Compiler/platform uses macro for ctime (e.g., MVS) */ +#undef ACE_HAS_BROKEN_CTIME + +/* Platform sendv() does not work properly with datagrams, i.e. it fails when + the iovec size is IOV_MAX. */ +#undef ACE_HAS_BROKEN_DGRAM_SENDV + +/* Platform doesn't cast MAP_FAILED to a (void *). */ +#undef ACE_HAS_BROKEN_MAP_FAILED + +/* HP/UX does not wrap the mmap(2) header files with extern "C". */ +#undef ACE_HAS_BROKEN_MMAP_H + +/* Platform headers don't support prototypes */ +#undef ACE_HAS_BROKEN_MSG_H + +/* Platform defines struct timespec in */ +#undef ACE_HAS_BROKEN_POSIX_TIME + +/* OS/compiler's header files are inconsistent with libC definition of + rand_r(). */ +#undef ACE_HAS_BROKEN_RANDR + +/* Platform defines ctime_r, asctime_r, rand_r and getpwnam_r as macros */ +#undef ACE_HAS_BROKEN_R_ROUTINES + +/* Compiler/platform has the wrong prototype for t_error(), i.e., t_error(char + *) rather than t_error(const char *). */ +#undef ACE_HAS_BROKEN_T_ERROR + +/* Platform has (which contains bzero() prototype) */ +#undef ACE_HAS_BSTRING + +/* Define to 1 if platform has bswap16(). */ +#undef ACE_HAS_BSWAP16 + +/* Define to 1 if platform has bswap32(). */ +#undef ACE_HAS_BSWAP32 + +/* Define to 1 if platform has bswap64(). */ +#undef ACE_HAS_BSWAP64 + +/* Define to 1 if platform has bswap_16(). */ +#undef ACE_HAS_BSWAP_16 + +/* Define to 1 if platform has bswap_32(). */ +#undef ACE_HAS_BSWAP_32 + +/* Define to 1 if platform has bswap_64(). */ +#undef ACE_HAS_BSWAP_64 + +/* Define to 1 if platform has the header file. */ +#undef ACE_HAS_BYTESEX_H + +/* Define to 1 if platform has the header file. */ +#undef ACE_HAS_BYTESWAP_H + +/* Platform supports the Win32 CancelIO() function. (WinNT 4.0 and beyond) */ +#undef ACE_HAS_CANCEL_IO + +/* OS/platform uses char * for dlopen/dlsym args, rather than const char *. */ +#undef ACE_HAS_CHARPTR_DL + +/* Define to 1 if arg 2 of 'shmat' is char *' */ +#undef ACE_HAS_CHARPTR_SHMAT + +/* Define to 1 if arg 1 of 'shmdt' is char *' */ +#undef ACE_HAS_CHARPTR_SHMDT + +/* OS/platform uses char * for sockopt, rather than const char * */ +#undef ACE_HAS_CHARPTR_SOCKOPT + +/* Define to 1 if platform has clock_gettime(). */ +#undef ACE_HAS_CLOCK_GETTIME + +/* Define to 1 if platform has clock_settime(). */ +#undef ACE_HAS_CLOCK_SETTIME + +/* OS header files have some problems with XTI (HP/UX 11). */ +#undef ACE_HAS_CONFLICTING_XTI_MACROS + +/* Prototypes for both signal() and struct sigaction are consistent. */ +#undef ACE_HAS_CONSISTENT_SIGNAL_PROTOTYPES + +/* Platform has swab(const char*, char*, ssize_t) variant. */ +#undef ACE_HAS_CONST_CHAR_SWAB + +/* Compiler/platform has correctly prototyped header files. */ +#undef ACE_HAS_CPLUSPLUS_HEADERS + +/* Define to 1 if the system has the type `cpu_set_t'. */ +#undef ACE_HAS_CPU_SET_T + +/* Platform defines custom DSO/DLL symbol export macros. */ +#undef ACE_HAS_CUSTOM_EXPORT_MACROS + +/* Platform supports /dev/poll character device. */ +#undef ACE_HAS_DEV_POLL + +/* Platform supports operations on directories via struct dirent, readdir_r, + etc. */ +#undef ACE_HAS_DIRENT + +/* Build ACE using the frigging PC DLL nonsense... */ +#undef ACE_HAS_DLL + +/* Define to 1 if the dlsym() call segfaults when passed an invalid handle. */ +#undef ACE_HAS_DLSYM_SEGFAULT_ON_INVALID_HANDLE + +/* Platform (Linux) supports event poll interface. */ +#undef ACE_HAS_EVENT_POLL + +/* Compiler supports C++ exception handling. */ +#undef ACE_HAS_EXCEPTIONS + +/* Platform has Fast-Light (FL) toolkit installed. */ +#undef ACE_HAS_FL + +/* Define to 1 if platform has getifaddrs(). */ +#undef ACE_HAS_GETIFADDRS + +/* Platform supports getpagesize() call (otherwise, ACE_PAGE_SIZE must be + defined, except on Win32). */ +#undef ACE_HAS_GETPAGESIZE + +/* Define to 1 if platform has getprogname(). */ +#undef ACE_HAS_GETPROGNAME + +/* Define to 1 if platform has getrusage(). */ +#undef ACE_HAS_GETRUSAGE + +/* Define to 1 if platform has the declaration of getrusage(). */ +#undef ACE_HAS_GETRUSAGE_PROTOTYPE + +/* Denotes that GNU has cstring.h as standard which redefines memchr() */ +#undef ACE_HAS_GNU_CSTRING_H + +/* Enable use of GNU template repositories. GNU C++ w/repo patch and EGCS only + */ +#undef ACE_HAS_GNU_REPO + +/* The GPERF utility is compiled for this platform */ +#undef ACE_HAS_GPERF + +/* Optimize ACE_Handle_Set::count_bits for select() operations (common case) + */ +#undef ACE_HAS_HANDLE_SET_OPTIMIZED_FOR_SELECT + +/* Compiler/platform supports SunOS high resolution timers */ +#undef ACE_HAS_HI_RES_TIMER + +/* Define to 1 if platform has the header file. */ +#undef ACE_HAS_IA32INTRIN_H + +/* Define to 1 if platform has the header file. */ +#undef ACE_HAS_IA64INTRIN_H + +/* Defined to 1 if platform supports ICMP over raw sockets */ +#undef ACE_HAS_ICMP_SUPPORT + +/* Define to 1 if the system has the type `idtype_t'. */ +#undef ACE_HAS_IDTYPE_T + +/* Inline all the static class OS methods to remove call overhead Note: This + gets defined by OS.h if __ACE_INLINE__ is defined */ +#undef ACE_HAS_INLINED_OSCALLS + +/* Define to 1 if the system has the type `int16_t'. */ +#undef ACE_HAS_INT16_T + +/* Define to 1 if the system has the type `int32_t'. */ +#undef ACE_HAS_INT32_T + +/* Define to 1 if the system has the type `int64_t'. */ +#undef ACE_HAS_INT64_T + +/* Define to 1 if the system has the type `int8_t'. */ +#undef ACE_HAS_INT8_T + +/* Define to 1 if the system supports x86/x86_64 inline assembly */ +#undef ACE_HAS_INTEL_ASSEMBLY + +/* Platform supports the intrinsic interlocked optimizations. */ +#undef ACE_HAS_INTRINSIC_INTERLOCKED + +/* Define to 1 if platform has the header file. */ +#undef ACE_HAS_INTRIN_H + +/* Platform supports IPv6 */ +#undef ACE_HAS_IPV6 + +/* Platform supports IP multicast */ +#undef ACE_HAS_IP_MULTICAST + +/* Platform supports the very odd IRIX 6.2 threads... */ +#undef ACE_HAS_IRIX62_THREADS + +/* Define to 1 if platform has the declaration of isastream(). */ +#undef ACE_HAS_ISASTREAM_PROTOTYPE + +/* Define to 1 if platform has itoa(). */ +#undef ACE_HAS_ITOA + +/* The rusage_t structure has only two fields. */ +#undef ACE_HAS_LIMITED_RUSAGE_T + +/* Platform supports llseek(). This should not be defined if ACE_HAS_LSEEK64 + is defined. */ +#undef ACE_HAS_LLSEEK + +/* Platform defines MAP_FAILED as a long constant. */ +#undef ACE_HAS_LONG_MAP_FAILED + +/* Platform supports lseek64(). This should not be defined if ACE_HAS_LLSEEK + is defined. */ +#undef ACE_HAS_LSEEK64 + +/* */ +#undef ACE_HAS_LYNXOS_SIGNALS + +/* Enabled malloc statistics collection. */ +#undef ACE_HAS_MALLOC_STATS + +/* Define to 1 if platform has memchr(). */ +#undef ACE_HAS_MEMCHR + +/* Define to 1 if unrolled ACE_OS::fast_memcpy() is faster than system + memcpy() */ +#undef ACE_HAS_MEMCPY_LOOP_UNROLL + +/* Platform supports Microsoft Foundation Classes */ +#undef ACE_HAS_MFC + +/* Define to 1 if platform has mkdir(). */ +#undef ACE_HAS_MKDIR + +/* Platform supports recvmsg and sendmsg */ +#undef ACE_HAS_MSG + +/* Platform supports MT safe mktime() call (do any of them?) */ +#undef ACE_HAS_MT_SAFE_MKTIME + +/* Sockets may be called in multi-threaded programs */ +#undef ACE_HAS_MT_SAFE_SOCKETS + +/* Compiler supports timed mutex acquisitions (e.g. + pthread_mutex_timedlock()). */ +#undef ACE_HAS_MUTEX_TIMEOUTS + +/* Define to 1 if platform has nanosleep(). */ +#undef ACE_HAS_NANOSLEEP + +/* Define to 1 if platform has the header file. */ +#undef ACE_HAS_NEW_H + +/* Compiler supports new (std::nothrow) */ +#undef ACE_HAS_NEW_NOTHROW + +/* Platform provides new style C++ header */ +#undef ACE_HAS_NEW_NO_H + +/* Define to 1 if system has nonconst FD_ISSET() macro. */ +#undef ACE_HAS_NONCONST_FD_ISSET + +/* Platform uses non-const char * in calls to gethostbyaddr, gethostbyname, + getservbyname */ +#undef ACE_HAS_NONCONST_GETBY + +/* Platform has a non-const parameter to msgsnd() (e.g., SCO). */ +#undef ACE_HAS_NONCONST_MSGSND + +/* Platform omits const qualifier from iovec parameter in readv() prototype. + */ +#undef ACE_HAS_NONCONST_READV + +/* Platform's select() uses non-const timeval* (only found on Linux right now) + */ +#undef ACE_HAS_NONCONST_SELECT_TIMEVAL + +/* Platform omits const qualifier from msghdr parameter in sendmsg() + prototype. */ +#undef ACE_HAS_NONCONST_SENDMSG + +/* Platform omits const qualifier from rlimit parameter in setrlimit() + prototype. */ +#undef ACE_HAS_NONCONST_SETRLIMIT + +/* Platform has swab(char*, char*, ssize_t) variant. */ +#undef ACE_HAS_NONCONST_SWAB + +/* Platform omits const qualifier from iovec parameter in writev() prototype. + */ +#undef ACE_HAS_NONCONST_WRITEV + +/* Causes the ACE_Object_Manager instance to be created in main (int, char + *[]), instead of as a static (global) instance. */ +#undef ACE_HAS_NONSTATIC_OBJECT_MANAGER + +/* Compiler/platform uses old malloc()/free() prototypes (ugh) */ +#undef ACE_HAS_OLD_MALLOC + +/* Platform, e.g., Solaris 2.5, only supports SCHED_OTHER POSIX scheduling + policy. */ +#undef ACE_HAS_ONLY_SCHED_OTHER + +/* Use the semaphore implementation of ACE_Message_Queue rather than the + emulated condition variable (NT and VxWorks). */ +#undef ACE_HAS_OPTIMIZED_MESSAGE_QUEUE + +/* timezone* 2nd parameter & no prototype */ +#undef ACE_HAS_OSF1_GETTIMEOFDAY + +/* Platform supports the OSF TLI timod STREAMS module */ +#undef ACE_HAS_OSF_TIMOD_H + +/* Define to 1 if platform has the header file. */ +#undef ACE_HAS_PDH_H + +/* Define to 1 if system is using Intel Pentium(tm) processor */ +#undef ACE_HAS_PENTIUM + +/* Platform contains */ +#undef ACE_HAS_POLL + +/* Platform supports "position-independent" features provided by + ACE_Based_Pointer<>. */ +#undef ACE_HAS_POSITION_INDEPENDENT_POINTERS + +/* Platform supports POSIX getpwnam_r() function */ +#undef ACE_HAS_POSIX_GETPWNAM_R + +/* Platform supports POSIX O_NONBLOCK semantics */ +#undef ACE_HAS_POSIX_NONBLOCK + +/* Platform supports POSIX realtime signals */ +#undef ACE_HAS_POSIX_REALTIME_SIGNALS + +/* Platform supports POSIX real-time semaphores (e.g., VxWorks and Solaris) */ +#undef ACE_HAS_POSIX_SEM + +/* Platform supports timed POSIX semaphore acquisitions (sem_timedwait()). */ +#undef ACE_HAS_POSIX_SEM_TIMEOUT + +/* Platform supports the POSIX struct timespec type */ +#undef ACE_HAS_POSIX_TIME + +/* Define to 1 if system should use PowerPC's cycle counter */ +#undef ACE_HAS_POWERPC_TIMER + +/* OS has priocntl (2) */ +#undef ACE_HAS_PRIOCNTL + +/* Platform supports the /proc file system and defines tid_t in + */ +#undef ACE_HAS_PROC_FS + +/* Platform supports the prusage_t struct */ +#undef ACE_HAS_PRUSAGE_T + +/* Define to 1 if platform has POSIX threads */ +#undef ACE_HAS_PTHREADS + +/* Platform supports POSIX Threads .4a Draft 4 */ +#undef ACE_HAS_PTHREADS_DRAFT4 + +/* Platform supports POSIX Threads .4a Draft 6 */ +#undef ACE_HAS_PTHREADS_DRAFT6 + +/* Platform supports POSIX Threads .1c Draft 7 */ +#undef ACE_HAS_PTHREADS_DRAFT7 + +/* Platform supports POSIX.1c-1995 threads */ +#undef ACE_HAS_PTHREADS_STD + +/* Platform has the UNIX98 extensions to Pthreads (rwlocks) */ +#undef ACE_HAS_PTHREADS_UNIX98_EXT + +/* Define to 1 if platform has pthread_attr_setcreatesuspend_np(). */ +#undef ACE_HAS_PTHREAD_ATTR_SETCREATESUSPEND_NP + +/* Define to 1 if platform has pthread_condattr_setkind_np(). */ +#undef ACE_HAS_PTHREAD_CONDATTR_SETKIND_NP + +/* Define to 1 if platform has pthread_continue(). */ +#undef ACE_HAS_PTHREAD_CONTINUE + +/* Define to 1 if platform has pthread_continue_np(). */ +#undef ACE_HAS_PTHREAD_CONTINUE_NP + +/* Define to 1 if platform has pthread_getaffinity_np(). */ +#undef ACE_HAS_PTHREAD_GETAFFINITY_NP + +/* Define to 1 if platform has pthread_getconcurrency(). */ +#undef ACE_HAS_PTHREAD_GETCONCURRENCY + +/* Define to 1 if platform has pthread_mutexattr_setkind_np(). */ +#undef ACE_HAS_PTHREAD_MUTEXATTR_SETKIND_NP + +/* Define to 1 if platform has the header file. */ +#undef ACE_HAS_PTHREAD_NP_H + +/* pthread.h declares an enum with PTHREAD_PROCESS_PRIVATE and + PTHREAD_PROCESS_SHARED values */ +#undef ACE_HAS_PTHREAD_PROCESS_ENUM + +/* Define to 1 if platform has pthread_resume_np(). */ +#undef ACE_HAS_PTHREAD_RESUME_NP + +/* Define to 1 if platform has pthread_setaffinity_np(). */ +#undef ACE_HAS_PTHREAD_SETAFFINITY_NP + +/* Define to 1 if platform has pthread_setconcurrency(). */ +#undef ACE_HAS_PTHREAD_SETCONCURRENCY + +/* Define to 1 if platform has the declaration of pthread_sigmask(). */ +#undef ACE_HAS_PTHREAD_SIGMASK_PROTOTYPE + +/* Define to 1 if platform has pthread_suspend(). */ +#undef ACE_HAS_PTHREAD_SUSPEND + +/* Define to 1 if platform has pthread_suspend_np(). */ +#undef ACE_HAS_PTHREAD_SUSPEND_NP + +/* Purify'ing. Defined on command line. */ +#undef ACE_HAS_PURIFY + +/* Platform has pread() and pwrite() support. */ +#undef ACE_HAS_P_READ_WRITE + +/* Quantify'ing. Defined on command line. */ +#undef ACE_HAS_QUANTIFY + +/* Define to 1 to configure Reactor to use a user-space queue for + notifications */ +#undef ACE_HAS_REACTOR_NOTIFICATION_QUEUE + +/* Mutexes are inherently recursive (e.g., Win32) */ +#undef ACE_HAS_RECURSIVE_MUTEXES + +/* Platform will recurse infinitely on thread exits from TSS cleanup routines + (e.g., AIX) */ +#undef ACE_HAS_RECURSIVE_THR_EXIT_SEMANTICS + +/* Platform supports reentrant functions (i.e., all the POSIX *_r functions). + */ +#undef ACE_HAS_REENTRANT_FUNCTIONS + +/* Platform supports the POSIX regular expression library */ +#undef ACE_HAS_REGEX + +/* Platform has enum instead of int for first argument to ::{get,set}rlimit + (). The value of this macro is the enum definition, e.g., enum + __rlimit_resource, for Linux glibc 2.0. */ +#undef ACE_HAS_RLIMIT_RESOURCE_ENUM + +/* Platform has enum instead of int for first argument to ::getrusage (). The + value of this macro is the enum definition, e.g., enum __rusage_who, for + Linux glibc 2.0. */ +#undef ACE_HAS_RUSAGE_WHO_ENUM + +/* Define to 1 if platform has sched_getaffinity(). */ +#undef ACE_HAS_SCHED_GETAFFINITY + +/* Define to 1 if platform has sched_setaffinity(). */ +#undef ACE_HAS_SCHED_SETAFFINITY + +/* Define to 1 if platform has the header file. */ +#undef ACE_HAS_SELECT_H + +/* Compiler/platform defines a union semun for SysV shared memory */ +#undef ACE_HAS_SEMUN + +/* Define to 1 if platform has setprogname(). */ +#undef ACE_HAS_SETPROGNAME + +/* Define to 1 if platform has set_t_errno(). */ +#undef ACE_HAS_SET_T_ERRNO + +/* Platform has shm_open() */ +#undef ACE_HAS_SHM_OPEN + +/* Platform's sigaction() function takes const sigaction* as 2nd parameter */ +#undef ACE_HAS_SIGACTION_CONSTP2 + +/* Define to 1 if the system has the type `siginfo_t'. */ +#undef ACE_HAS_SIGINFO_T + +/* Platform has bug with sigismember() (HP/UX 11). */ +#undef ACE_HAS_SIGISMEMBER_BUG + +/* Platform supports the Win32 SignalObjectAndWait() function (WinNT 4.0 and + beyond). */ +#undef ACE_HAS_SIGNAL_OBJECT_AND_WAIT + +/* Define to 1 if platform has sigsuspend(). */ +#undef ACE_HAS_SIGSUSPEND + +/* Define to 1 if platform has sigtimedwait(). */ +#undef ACE_HAS_SIGTIMEDWAIT + +/* Define to 1 if `sigval_int' is a member of `union sigval'. */ +#undef ACE_HAS_SIGVAL_SIGVAL_INT + +/* Define to 1 if `sigval_ptr' is a member of `union sigval'. */ +#undef ACE_HAS_SIGVAL_SIGVAL_PTR + +/* Define to 1 if platform has sigwait(). */ +#undef ACE_HAS_SIGWAIT + +/* Define to 1 if the system has the type 'sig_atomic_t'. */ +#undef ACE_HAS_SIG_ATOMIC_T + +/* Compiler requires extern "C" functions for signals. */ +#undef ACE_HAS_SIG_C_FUNC + +/* Platform/compiler has macros for sig{empty,fill,add,del}set (e.g., SCO and + FreeBSD) */ +#undef ACE_HAS_SIG_MACROS + +/* OS/compiler uses size_t * rather than int * for socket lengths */ +#undef ACE_HAS_SIZET_SOCKET_LEN + +/* Define to 1 if platform has snprintf(). */ +#undef ACE_HAS_SNPRINTF + +/* Define to 1 if `sin6_len' is a member of `sockaddr_in6'. */ +#undef ACE_HAS_SOCKADDR_IN6_SIN6_LEN + +/* Define to 1 if `sin_len' is a member of `sockaddr_in'. */ +#undef ACE_HAS_SOCKADDR_IN_SIN_LEN + +/* Platform requires (struct sockaddr *) for msg_name field of struct msghdr. + */ +#undef ACE_HAS_SOCKADDR_MSG_NAME + +/* Define to 1 if the system has the type `socklen_t'. */ +#undef ACE_HAS_SOCKLEN_T + +/* Define to 1 if the system has the type `ssize_t'. */ +#undef ACE_HAS_SSIZE_T + +/* Platform/compiler supports Standard C++ Library */ +#undef ACE_HAS_STANDARD_CPP_LIBRARY + +/* Platform has void (*)(...) prototype for pthread_key_create() destructor + (e.g., LynxOS). */ +#undef ACE_HAS_STDARG_THR_DEST + +/* */ +#undef ACE_HAS_STDCPP_STL_INCLUDES + +/* Platform provides C++ header */ +#undef ACE_HAS_STDEXCEPT_NO_H + +/* Define to 1 if platform has UNIX International Threads */ +#undef ACE_HAS_STHREADS + +/* Used when users want to compile ACE with STL and STL map class conflicts + with map struct. */ +#undef ACE_HAS_STL_MAP_CONFLICT + +/* Used when users want to compile ACE with STL and STL queue class conflicts + with queue struct. */ +#undef ACE_HAS_STL_QUEUE_CONFLICT + +/* Compiler/platform supports struct strbuf */ +#undef ACE_HAS_STRBUF_T + +/* Define to 1 use ACE's strdup() emulation */ +#undef ACE_HAS_STRDUP_EMULATION + +/* Platform supports STREAMS */ +#undef ACE_HAS_STREAMS + +/* Platform supports STREAM pipes */ +#undef ACE_HAS_STREAM_PIPES + +/* Define to 1 if platform has strerror(). */ +#undef ACE_HAS_STRERROR + +/* Use the STRICT compilation mode on Win32. */ +#undef ACE_HAS_STRICT + +/* Platform has (which contains bzero() prototype) */ +#undef ACE_HAS_STRINGS + +/* Platform/Compiler supports a String class (e.g., GNU or Win32). */ +#undef ACE_HAS_STRING_CLASS + +/* Define to 1 if platform has strnlen(). */ +#undef ACE_HAS_STRNLEN + +/* Compiler/platform has strange hostent API for socket *_r() calls */ +#undef ACE_HAS_STRUCT_NETDB_DATA + +/* Compiler/platform supports SVR4 dynamic linking semantics */ +#undef ACE_HAS_SVR4_DYNAMIC_LINKING + +/* Compiler/platform supports SVR4 gettimeofday() prototype but doesn't have a + prototype */ +#undef ACE_HAS_SVR4_GETTIMEOFDAY + +/* Compiler/platform supports SVR4 signal typedef. */ +#undef ACE_HAS_SVR4_SIGNAL_T + +/* Compiler/platform supports SVR4 TLI (in particular, T_GETNAME stuff). */ +#undef ACE_HAS_SVR4_TLI + +/* Define to 1 if platform has sysctl(). */ +#undef ACE_HAS_SYSCTL + +/* Define to 1 if platform has the header file. */ +#undef ACE_HAS_SYSENT_H + +/* Platform supports system configuration information. */ +#undef ACE_HAS_SYSINFO + +/* Platform supports System V IPC (most versions of UNIX, but not Win32) */ +#undef ACE_HAS_SYSV_IPC + +/* Platform/compiler supports _sys_errlist symbol */ +#undef ACE_HAS_SYS_ERRLIST + +/* Define to 1 if platform has the header file. */ +#undef ACE_HAS_SYS_FILIO_H + +/* Define to 1 if platform has the header file. */ +#undef ACE_HAS_SYS_LOADAVG_H + +/* Define to 1 if platform has the header file. */ +#undef ACE_HAS_SYS_PSTAT_H + +/* Compiler/platform supports _sys_siglist array */ +#undef ACE_HAS_SYS_SIGLIST + +/* Define to 1 if platform has the header file. */ +#undef ACE_HAS_SYS_SOCKIO_H + +/* Define to 1 if platform has the header file. */ +#undef ACE_HAS_SYS_SYSCALL_H + +/* Define to 1 if platform has the header file. */ +#undef ACE_HAS_SYS_SYSINFO_H + +/* Define to 1 if platform has the header file. */ +#undef ACE_HAS_SYS_SYSTEMINFO_H + +/* Platform provides header */ +#undef ACE_HAS_SYS_XTI_H + +/* */ +#undef ACE_HAS_TANDEM_SIGNALS + +/* Compiler implements templates that support typedefs inside of classes used + as formal arguments to a template class. */ +#undef ACE_HAS_TEMPLATE_TYPEDEFS + +/* Define to 1 if system supports SysV tty API. */ +#undef ACE_HAS_TERMIO + +/* Define to 1 if system supports POSIX tty API. */ +#undef ACE_HAS_TERMIOS + +/* Platform supports threads. */ +#undef ACE_HAS_THREADS + +/* Platform allows multiple threads to call accept() on the same port (e.g., + WinNT). */ +#undef ACE_HAS_THREAD_SAFE_ACCEPT + +/* Platform has thread_self() rather than pthread_self() (e.g., DCETHREADS and + AIX) */ +#undef ACE_HAS_THREAD_SELF + +/* Compiler/platform has thread-specific storage */ +#undef ACE_HAS_THREAD_SPECIFIC_STORAGE + +/* The pthread_keycreate() routine *must* take extern C functions. */ +#undef ACE_HAS_THR_C_DEST + +/* The pthread_create() routine *must* take extern C functions. */ +#undef ACE_HAS_THR_C_FUNC + +/* Platform supports thr_keydelete (e.g,. UNIXWARE) */ +#undef ACE_HAS_THR_KEYDELETE + +/* Platform calls thr_minstack() rather than thr_min_stack() (e.g., Tandem). + */ +#undef ACE_HAS_THR_MINSTACK + +/* Platform has thr_yield() */ +#undef ACE_HAS_THR_YIELD + +/* Define to 1 if platform has global timezone variable */ +#undef ACE_HAS_TIMEZONE + +/* Platform/compiler supports timezone * as second parameter to gettimeofday() + and has a prototype. */ +#undef ACE_HAS_TIMEZONE_GETTIMEOFDAY + +/* Platform supports TLI timod STREAMS module */ +#undef ACE_HAS_TIMOD_H + +/* Platform supports TLI tiuser header */ +#undef ACE_HAS_TIUSER_H + +/* Platform does not protect with extern "C" */ +#undef ACE_HAS_TIUSER_H_BROKEN_EXTERN_C + +/* Platform supports TLI. Also see ACE_TLI_TCP_DEVICE. */ +#undef ACE_HAS_TLI + +/* Platform provides TLI function prototypes */ +#undef ACE_HAS_TLI_PROTOTYPES + +/* ACE provides TSS emulation. See also ACE_DEFAULT_THREAD_KEYS. */ +#undef ACE_HAS_TSS_EMULATION + +/* Define to 1 if platform has ualarm(). */ +#undef ACE_HAS_UALARM + +/* Define to 1 if the system has the type `ucontext_t'. */ +#undef ACE_HAS_UCONTEXT_T + +/* Define to 1 if the system has the type `uint16_t'. */ +#undef ACE_HAS_UINT16_T + +/* Define to 1 if the system has the type `uint32_t'. */ +#undef ACE_HAS_UINT32_T + +/* Define to 1 if the system has the type `uint64_t'. */ +#undef ACE_HAS_UINT64_T + +/* Define to 1 if the system has the type `uint8_t'. */ +#undef ACE_HAS_UINT8_T + +/* Has inconsistent SVR4 signal stuff, but not the same as the other platforms + */ +#undef ACE_HAS_UNIXWARE_SVR4_SIGNAL_T + +/* Define to 1 if platform has vasprintf(). */ +#undef ACE_HAS_VASPRINTF + +/* Define to 1 if platform has vaswprintf(). */ +#undef ACE_HAS_VASWPRINTF + +/* Prints out console message in ACE_NOTSUP. Useful for tracking down origin + of ACE_NOTSUP. */ +#undef ACE_HAS_VERBOSE_NOTSUP + +/* Define to 1 if platform has vfwprintf(). */ +#undef ACE_HAS_VFWPRINTF + +/* Platform/compiler supports void * as second parameter to gettimeofday() and + has a prototype. */ +#undef ACE_HAS_VOIDPTR_GETTIMEOFDAY + +/* Platform requires void * for mmap(). */ +#undef ACE_HAS_VOIDPTR_MMAP + +/* OS/compiler uses void * arg 4 setsockopt() rather than const char * */ +#undef ACE_HAS_VOIDPTR_SOCKOPT + +/* Define to 1 if platform has vswprintf(). */ +#undef ACE_HAS_VSWPRINTF + +/* Platform/compiler supports wchar_t */ +#undef ACE_HAS_WCHAR + +/* Define to 1 use ACE's wcsdup() emulation */ +#undef ACE_HAS_WCSDUP_EMULATION + +/* Define to 1 if platform has wcsnlen(). */ +#undef ACE_HAS_WCSNLEN + +/* Platform/compiler supports Win32 structural exceptions. */ +#undef ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS + +/* The Win32 platform support TryEnterCriticalSection(). (WinNT 4.0 and + beyond) */ +#undef ACE_HAS_WIN32_TRYLOCK + +/* The Win32 platform supports WinSock 2.0. */ +#undef ACE_HAS_WINSOCK2 + +/* Compiler handles explicit calling of template destructor correctly. */ +#undef ACE_HAS_WORKING_EXPLICIT_TEMPLATE_DESTRUCTOR + +/* Solaris for intel uses macros for fstat() and stat(), these are wrappers + for _fxstat() and _xstat() uses of the macros. Causes compile and runtime + problems. */ +#undef ACE_HAS_X86_STAT_MACROS + +/* Platform has the XLI version of TLI */ +#undef ACE_HAS_XLI + +/* Platform has support for multi-byte character support compliant with the + XPG4 Worldwide Portability Interface wide-character classification. */ +#undef ACE_HAS_XPG4_MULTIBYTE_CHAR + +/* Platform has Xt Intrinsics Toolkit */ +#undef ACE_HAS_XT + +/* Platform has XTI (X/Open-standardized superset of TLI). Implies ACE_HAS_TLI + but uses a different header file. */ +#undef ACE_HAS_XTI + +/* Define to 1 if platform has _InterlockedDecrement(). */ +#undef ACE_HAS__INTERLOCKEDDECREMENT + +/* Define to 1 if platform has _InterlockedExchangeAdd(). */ +#undef ACE_HAS__INTERLOCKEDEXCHANGEADD + +/* Define to 1 if platform has _InterlockedIncrement(). */ +#undef ACE_HAS__INTERLOCKEDINCREMENT + +/* Define to the *printf format specifier (e.g. "%lld") for ACE_INT64 */ +#undef ACE_INT64_FORMAT_SPECIFIER + +/* Define to signed 64 bit integer type */ +#undef ACE_INT64_TYPE + +/* Define to the type of arg 2 for `ioctl'. */ +#undef ACE_IOCTL_TYPE_ARG2 + +/* Define to 1 if platform lacks access(). */ +#undef ACE_LACKS_ACCESS + +/* Do not compile support for the "Codecs" ACE features. */ +#undef ACE_LACKS_ACE_CODECS + +/* Platform can not build ace/IOStream{,_T}.cpp. This does not necessarily + mean that the platform does not support iostreams. */ +#undef ACE_LACKS_ACE_IOSTREAM + +/* Do not compile support for the "other" ACE features, such as CORBA + handling, name services, and QoS. */ +#undef ACE_LACKS_ACE_OTHER + +/* Do not compile support for the ACE Service Configurator. */ +#undef ACE_LACKS_ACE_SVCCONF + +/* Do not compile support for the ACE Token feature. */ +#undef ACE_LACKS_ACE_TOKEN + +/* Do not compile support for the ACE UUID feature. */ +#undef ACE_LACKS_ACE_UUID + +/* Define to 1 if platform lacks alarm(). */ +#undef ACE_LACKS_ALARM + +/* Define to 1 if platform lacks alphasort(). */ +#undef ACE_LACKS_ALPHASORT + +/* Define to 1 if platform lacks the header file. */ +#undef ACE_LACKS_ARPA_INET_H + +/* Define to 1 if platform lacks asctime(). */ +#undef ACE_LACKS_ASCTIME + +/* Define to 1 if platform lacks asctime_r(). */ +#undef ACE_LACKS_ASCTIME_R + +/* No system support for replacing any previous mappings. */ +#undef ACE_LACKS_AUTO_MMAP_REPLACEMENT + +/* Platform lacks support for the standard C++ auto_ptr class */ +#undef ACE_LACKS_AUTO_PTR + +/* Define to 1 if platform lacks bsearch(). */ +#undef ACE_LACKS_BSEARCH + +/* Define to 1 to support unaligned CDR */ +#undef ACE_LACKS_CDR_ALIGNMENT + +/* Compiler does not have any istream operator>> for chars, u_chars, or signed + chars. */ +#undef ACE_LACKS_CHAR_RIGHT_SHIFTS + +/* Compiler does not have operator>> (istream &, u_char *) or operator>> + (istream &, signed char *) */ +#undef ACE_LACKS_CHAR_STAR_RIGHT_SHIFTS + +/* Define to 1 if platform lacks chdir(). */ +#undef ACE_LACKS_CHDIR + +/* Platform has no implementation of pthread_condattr_setpshared(), even + though it supports pthreads! */ +#undef ACE_LACKS_CONDATTR_PSHARED + +/* Platform lacks condition variables (e.g., Win32 and VxWorks) */ +#undef ACE_LACKS_COND_T + +/* pthread_cond_timedwait does *not* reset the time argument when the lock is + acquired. */ +#undef ACE_LACKS_COND_TIMEDWAIT_RESET + +/* Platform uses struct strbuf * rather than const struct strbuf * (e.g., + HP/UX 10.x) */ +#undef ACE_LACKS_CONST_STRBUF_PTR + +/* Platform forgot const in cond_timewait (e.g., HP/UX). */ +#undef ACE_LACKS_CONST_TIMESPEC_PTR + +/* Define to 1 if platform lacks difftime(). */ +#undef ACE_LACKS_DIFFTIME + +/* Define to 1 if platform lacks the header file. */ +#undef ACE_LACKS_DIRENT_H + +/* Define to 1 if platform lacks the header file. */ +#undef ACE_LACKS_DLFCN_H + +/* Define to 1 if platform lacks dup(). */ +#undef ACE_LACKS_DUP + +/* Define to 1 if platform lacks dup2(). */ +#undef ACE_LACKS_DUP2 + +/* Define to 1 if platform lacks the header file. */ +#undef ACE_LACKS_ERRNO_H + +/* Platform lacks the exec() family of system calls (e.g., Win32, VxWorks, + Chorus) */ +#undef ACE_LACKS_EXEC + +/* Define to 1 if platform lacks the header file. */ +#undef ACE_LACKS_EXECINFO_H + +/* Define to 1 if platform lacks fcntl(). */ +#undef ACE_LACKS_FCNTL + +/* Define to 1 if platform lacks the header file. */ +#undef ACE_LACKS_FCNTL_H + +/* Define to 1 if platform lacks fgetwc(). */ +#undef ACE_LACKS_FGETWC + +/* Define to 1 if platform lacks fgetws(). */ +#undef ACE_LACKS_FGETWS + +/* Platform lacks file locking mechanism */ +#undef ACE_LACKS_FILELOCKS + +/* Define to 1 if platform lacks fork(). */ +#undef ACE_LACKS_FORK + +/* Define to 1 if platform lacks fputws(). */ +#undef ACE_LACKS_FPUTWS + +/* Define to 1 if platform lacks fsync(). */ +#undef ACE_LACKS_FSYNC + +/* Define to 1 if platform lacks getcwd(). */ +#undef ACE_LACKS_GETCWD + +/* Define to 1 if platform lacks getegid(). */ +#undef ACE_LACKS_GETEGID + +/* Define to 1 if platform lacks geteuid(). */ +#undef ACE_LACKS_GETEUID + +/* Define to 1 if platform lacks getgid(). */ +#undef ACE_LACKS_GETGID + +/* Define to 1 if platform lacks gethostent(). */ +#undef ACE_LACKS_GETHOSTENT + +/* Define to 1 if platform lacks getipnodebyaddr(). */ +#undef ACE_LACKS_GETIPNODEBYADDR + +/* Define to 1 if platform lacks getipnodebyname(). */ +#undef ACE_LACKS_GETIPNODEBYNAME + +/* Define to 1 if platform lacks getopt(). */ +#undef ACE_LACKS_GETOPT + +/* Define to 1 if platform lacks the declaration of getopt(). */ +#undef ACE_LACKS_GETOPT_PROTOTYPE + +/* Define to 1 if platform lacks getpgid(). */ +#undef ACE_LACKS_GETPGID + +/* Define to 1 if platform lacks getpgid() declaration in . */ +#undef ACE_LACKS_GETPGID_PROTOTYPE + +/* Define to 1 if platform lacks getpid(). */ +#undef ACE_LACKS_GETPID + +/* Define to 1 if platform lacks getppid(). */ +#undef ACE_LACKS_GETPPID + +/* Platforms lacks getservbyname() (e.g., VxWorks and Chorus). */ +#undef ACE_LACKS_GETSERVBYNAME + +/* Define to 1 if platform lacks getuid(). */ +#undef ACE_LACKS_GETUID + +/* Define to 1 if platform lacks gmtime(). */ +#undef ACE_LACKS_GMTIME + +/* Define to 1 if platform lacks gmtime_r(). */ +#undef ACE_LACKS_GMTIME_R + +/* Define to 1 if platform lacks inet_aton(). */ +#undef ACE_LACKS_INET_ATON + +/* Platform can't handle "inline" keyword correctly. */ +#undef ACE_LACKS_INLINE_FUNCTIONS + +/* Define to 1 if the system lacks the type `intmax_t'. */ +#undef ACE_LACKS_INTMAX_T + +/* Define to 1 if the system lacks the type `intptr_t'. */ +#undef ACE_LACKS_INTPTR_T + +/* Define to 1 if platform lacks the header file. */ +#undef ACE_LACKS_INTTYPES_H + +/* iostream header does not declare ipfx (), opfx (), etc. */ +#undef ACE_LACKS_IOSTREAM_FX + +/* iostreams are not supported adequately on the given platform. */ +#undef ACE_LACKS_IOSTREAM_TOTALLY + +/* Define to 1 if platform lacks isatty(). */ +#undef ACE_LACKS_ISATTY + +/* Define to 1 if platform lacks itow(). */ +#undef ACE_LACKS_ITOW + +/* Define to 1 if the system lacks the type `key_t'. */ +#undef ACE_LACKS_KEY_T + +/* Define to 1 if platform lacks kill(). */ +#undef ACE_LACKS_KILL + +/* Platform lacks streambuf "linebuffered ()". */ +#undef ACE_LACKS_LINEBUFFERED_STREAMBUF + +/* Platform/compiler lacks the llseek() prototype. This should not be defined + if ACE_LACKS_LSEEK64_PROTOTYPE is defined. */ +#undef ACE_LACKS_LLSEEK_PROTOTYPE + +/* Define to 1 if platform lacks localtime(). */ +#undef ACE_LACKS_LOCALTIME + +/* Define to 1 if platform lacks log2(). */ +#undef ACE_LACKS_LOG2 + +/* Compiler/platform does not support the unsigned long long datatype. */ +#undef ACE_LACKS_LONGLONG_T + +/* Platform/compiler lacks the lseek64() prototype. This should not be defined + if ACE_LACKS_LLSEEK_PROTOTYPE is defined. */ +#undef ACE_LACKS_LSEEK64_PROTOTYPE + +/* Define to 1 if platform lacks lstat(). */ +#undef ACE_LACKS_LSTAT + +/* Define to 1 if platform lacks madvise(). */ +#undef ACE_LACKS_MADVISE + +/* Define to 1 if platform lacks the declaration of madvise(). */ +#undef ACE_LACKS_MADVISE_PROTOTYPE + +/* Define to 1 if platform lacks the header file. */ +#undef ACE_LACKS_MALLOC_H + +/* Define to 1 if platform lacks the header file. */ +#undef ACE_LACKS_MEMORY_H + +/* Define to 1 if platform lacks mkfifo(). */ +#undef ACE_LACKS_MKFIFO + +/* Define to 1 if platform lacks mkstemp(). */ +#undef ACE_LACKS_MKSTEMP + +/* Define to 1 if platform lacks the declaration of mkstemp(). */ +#undef ACE_LACKS_MKSTEMP_PROTOTYPE + +/* Define to 1 if platform lacks mktemp(). */ +#undef ACE_LACKS_MKTEMP + +/* Define to 1 if platform lacks the declaration of mktemp(). */ +#undef ACE_LACKS_MKTEMP_PROTOTYPE + +/* The platform doesn't have mmap(2) (e.g., SCO UNIX). */ +#undef ACE_LACKS_MMAP + +/* Platform/compiler doesn't have open() mode masks. */ +#undef ACE_LACKS_MODE_MASKS + +/* Platform does not have Motif X toolkit available */ +#undef ACE_LACKS_MOTIF + +/* Define to 1 if platform lacks mprotect(). */ +#undef ACE_LACKS_MPROTECT + +/* Platform defines ACE_HAS_MSG, but lacks msg_accrights{len}. */ +#undef ACE_LACKS_MSG_ACCRIGHTS + +/* Define to 1 if platform lacks msync(). */ +#undef ACE_LACKS_MSYNC + +/* Platform lacks pthread_mutexattr_setpshared(). */ +#undef ACE_LACKS_MUTEXATTR_PSHARED + +/* Platform lacks named POSIX semaphores (e.g., Chorus) */ +#undef ACE_LACKS_NAMED_POSIX_SEM + +/* Define to 1 if platform lacks the header file. */ +#undef ACE_LACKS_NETDB_H + +/* Platform does not support reentrant netdb functions (getprotobyname_r, + getprotobynumber_r, gethostbyaddr_r, gethostbyname_r, getservbyname_r). */ +#undef ACE_LACKS_NETDB_REENTRANT_FUNCTIONS + +/* Define to 1 if platform lacks the header file. */ +#undef ACE_LACKS_NETINET_IN_H + +/* Define to 1 if platform lacks the header file. */ +#undef ACE_LACKS_NETINET_TCP_H + +/* Define to 1 if platform lacks the header file. */ +#undef ACE_LACKS_NET_IF_H + +/* OS requires non-null status pointer for pthread_join () */ +#undef ACE_LACKS_NULL_PTHREAD_STATUS + +/* Platform lacks std::numeric_limits<> */ +#undef ACE_LACKS_NUMERIC_LIMITS + +/* Define to 1 if platform lacks IGMPv3 "perfect" filtering of multicast + datagrams at the socket level. If defined, ACE_SOCK_Dgram_Mcast will bind + the first joined multicast group to the socket, and all future joins on + that socket will fail with an error. */ +#undef ACE_LACKS_PERFECT_MULTICAST_FILTERING + +/* Define to 1 if platform lacks pipe(). */ +#undef ACE_LACKS_PIPE + +/* Compiler doesn't support placement operator delete(void *, void *). */ +#undef ACE_LACKS_PLACEMENT_OPERATOR_DELETE + +/* Compiler doesn't support placement operator new(size_t, void *). */ +#undef ACE_LACKS_PLACEMENT_OPERATOR_NEW + +/* Compiler complains about use of obsolete "pragma once" */ +#undef ACE_LACKS_PRAGMA_ONCE + +/* Platform/compiler lacks the pread() and pwrite() prototypes */ +#undef ACE_LACKS_PREAD_PROTOTYPE + +/* Define to 1 if the system lacks the type 'pri_t'. */ +#undef ACE_LACKS_PRI_T + +/* Define to 1 if platform lacks pthread_attr_setstack() */ +#undef ACE_LACKS_PTHREAD_ATTR_SETSTACK + +/* Define to 1 if platform lacks pthread_attr_setstackaddr(). */ +#undef ACE_LACKS_PTHREAD_ATTR_SETSTACKADDR + +/* Define to 1 if platform lacks pthread_attr_setstacksize(). */ +#undef ACE_LACKS_PTHREAD_ATTR_SETSTACKSIZE + +/* Platform lacks pthread_cancel() */ +#undef ACE_LACKS_PTHREAD_CANCEL + +/* Define to 1 if platform lacks pthread_sigmask(). */ +#undef ACE_LACKS_PTHREAD_SIGMASK + +/* Define to 1 if platform lacks pthread_thr_sigsetmask(). */ +#undef ACE_LACKS_PTHREAD_THR_SIGSETMASK + +/* Define to 1 if platform lacks pthread_yield(). */ +#undef ACE_LACKS_PTHREAD_YIELD + +/* Platform lacks, getpwnam(), etc. */ +#undef ACE_LACKS_PWD_FUNCTIONS + +/* Define to 1 if platform lacks the header file. */ +#undef ACE_LACKS_PWD_H + +/* Platform lacks getpwnam_r() methods (e.g., SGI 6.2). */ +#undef ACE_LACKS_PWD_REENTRANT_FUNCTIONS + +/* Define to 1 if platform lacks qsort(). */ +#undef ACE_LACKS_QSORT + +/* Define to 1 if platform lacks readdir_r(). */ +#undef ACE_LACKS_READDIR_R + +/* Define to 1 if platform lacks readlink(). */ +#undef ACE_LACKS_READLINK + +/* Define to 1 if platform lacks readv(). */ +#undef ACE_LACKS_READV + +/* Define to 1 if platform lacks realpath(). */ +#undef ACE_LACKS_REALPATH + +/* Define to 1 if platform lacks recvmsg(). */ +#undef ACE_LACKS_RECVMSG + +/* Define to 1 if platform lacks rename(). */ +#undef ACE_LACKS_RENAME + +/* Platform/compiler lacks {get,set}rlimit() function (e.g., VxWorks, Chorus, + and SCO UNIX) */ +#undef ACE_LACKS_RLIMIT + +/* Define to 1 if platform lacks the declaration of {get,set}rlimit(). */ +#undef ACE_LACKS_RLIMIT_PROTOTYPE + +/* Platform lacks pthread_rwlockattr_setpshared(). */ +#undef ACE_LACKS_RWLOCKATTR_PSHARED + +/* Platform lacks readers/writer locks. */ +#undef ACE_LACKS_RWLOCK_T + +/* Define to 1 if platform lacks sbrk(). */ +#undef ACE_LACKS_SBRK + +/* Define to 1 if platform lacks the header file. */ +#undef ACE_LACKS_SCHED_H + +/* Define to 1 if platform lacks the header file. */ +#undef ACE_LACKS_SEARCH_H + +/* Define to 1 if platform lacks seekdir(). */ +#undef ACE_LACKS_SEEKDIR + +/* Define to 1 if platform lacks the header file. */ +#undef ACE_LACKS_SEMAPHORE_H + +/* Platform lacks struct sembuf (e.g., Win32 and VxWorks) */ +#undef ACE_LACKS_SEMBUF_T + +/* Define to 1 if platform lacks sendmsg(). */ +#undef ACE_LACKS_SENDMSG + +/* Platform lacks pthread_attr_setdetachstate() (e.g., HP/UX 10.x) */ +#undef ACE_LACKS_SETDETACH + +/* Define to 1 if platform lacks setegid(). */ +#undef ACE_LACKS_SETEGID + +/* Define to 1 if platform lacks seteuid(). */ +#undef ACE_LACKS_SETEUID + +/* Define to 1 if platform lacks setgid(). */ +#undef ACE_LACKS_SETGID + +/* Define to 1 if platform lacks setpgid(). */ +#undef ACE_LACKS_SETPGID + +/* Define to 1 if platform lacks setpgid() declaration in . */ +#undef ACE_LACKS_SETPGID_PROTOTYPE + +/* Define to 1 if platform lacks setregid(). */ +#undef ACE_LACKS_SETREGID + +/* Define to 1 if platform lacks setregid() declaration in . */ +#undef ACE_LACKS_SETREGID_PROTOTYPE + +/* Define to 1 if platform lacks setreuid(). */ +#undef ACE_LACKS_SETREUID + +/* Define to 1 if platform lacks setreuid() declaration in . */ +#undef ACE_LACKS_SETREUID_PROTOTYPE + +/* Platform lacks pthread_attr_setsched() (e.g. MVS) */ +#undef ACE_LACKS_SETSCHED + +/* Define to 1 if platform lacks setsid(). */ +#undef ACE_LACKS_SETSID + +/* Define to 1 if platform lacks setuid(). */ +#undef ACE_LACKS_SETUID + +/* Define to 1 if platform lacks sigaction(). */ +#undef ACE_LACKS_SIGACTION + +/* Define to 1 if platform lacks the header file. */ +#undef ACE_LACKS_SIGINFO_H + +/* Define to 1 if platform lacks the header file. */ +#undef ACE_LACKS_SIGNAL_H + +/* Platform lacks "signed char" type (broken!) */ +#undef ACE_LACKS_SIGNED_CHAR + +/* Platform lacks signal sets (e.g., Chorus and Win32) */ +#undef ACE_LACKS_SIGSET + +/* Define to 1 if `si_addr' is not a member of `siginfo_t'. */ +#undef ACE_LACKS_SI_ADDR + +/* Define to 1 if platform lacks socketpair(). */ +#undef ACE_LACKS_SOCKETPAIR + +/* Platform doesn't support SO_SNDBUF/SO_RCVBUF (used in TAO) */ +#undef ACE_LACKS_SOCKET_BUFSIZ + +/* Compiler doesn't support static data member templates */ +#undef ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES + +/* Define to 1 if platform lacks the header file. */ +#undef ACE_LACKS_STDINT_H + +/* Define to 1 if platform lacks the header file. */ +#undef ACE_LACKS_STDLIB_H + +/* Define to 1 if platform lacks strcasecmp(). */ +#undef ACE_LACKS_STRCASECMP + +/* Define to 1 if platform lacks a declaration for strcasecmp() */ +#undef ACE_LACKS_STRCASECMP_PROTOTYPE + +/* Define to 1 if platform lacks strchr(). */ +#undef ACE_LACKS_STRCHR + +/* Define to 1 if platform lacks strdup(). */ +#undef ACE_LACKS_STRDUP + +/* Define to 1 if platform lacks strerror(). */ +#undef ACE_LACKS_STRERROR + +/* Define to 1 if platform lacks strftime(). */ +#undef ACE_LACKS_STRFTIME + +/* Define to 1 if platform lacks the header file. */ +#undef ACE_LACKS_STRINGS_H + +/* Define to 1 if platform lacks the header file. */ +#undef ACE_LACKS_STRING_H + +/* Define to 1 if platform lacks strncasecmp(). */ +#undef ACE_LACKS_STRNCASECMP + +/* Define to 1 if platform lacks a declaration for strncasecmp() */ +#undef ACE_LACKS_STRNCASECMP_PROTOTYPE + +/* Define to 1 if platform lacks the declaration of strnlen(). */ +#undef ACE_LACKS_STRNLEN_PROTOTYPE + +/* Platform lacks stropts.h */ +#undef ACE_LACKS_STROPTS_H + +/* Define to 1 if platform lacks strpbrk(). */ +#undef ACE_LACKS_STRPBRK + +/* Define to 1 if platform lacks strptime(). */ +#undef ACE_LACKS_STRPTIME + +/* Define to 1 if platform lacks the declaration of strptime(). */ +#undef ACE_LACKS_STRPTIME_PROTOTYPE + +/* Define to 1 if platform lacks strrchr(). */ +#undef ACE_LACKS_STRRCHR + +/* Platform doesn't define struct strrecvfd. */ +#undef ACE_LACKS_STRRECVFD + +/* Define to 1 if platform lacks strspn(). */ +#undef ACE_LACKS_STRSPN + +/* Define to 1 if platform lacks strtod(). */ +#undef ACE_LACKS_STRTOD + +/* Platform/compiler lacks the strtok_r() prototype */ +#undef ACE_LACKS_STRTOK_R_PROTOTYPE + +/* Define to 1 if platform lacks strtol(). */ +#undef ACE_LACKS_STRTOL + +/* Define to 1 if platform lacks strtoul(). */ +#undef ACE_LACKS_STRTOUL + +/* Define to 1 if platform lacks strtoull(). */ +#undef ACE_LACKS_STRTOULL + +/* Platform lacks dirent structure. */ +#undef ACE_LACKS_STRUCT_DIR + +/* Define to 1 if the system lacks the type 'suseconds_t'. */ +#undef ACE_LACKS_SUSECONDS_T + +/* Define to 1 if platform lacks swab(). */ +#undef ACE_LACKS_SWAB + +/* Define to 1 if platform lacks syscall(). */ +#undef ACE_LACKS_SYSCALL + +/* Define to 1 if platform lacks sysconf(). */ +#undef ACE_LACKS_SYSCONF + +/* Define to 1 if platform lacks system(). */ +#undef ACE_LACKS_SYSTEM + +/* Platform lacks SYSV message queue prototypes */ +#undef ACE_LACKS_SYSV_MSQ_PROTOS + +/* Platform lacks System V shared memory (e.g., Win32 and VxWorks) */ +#undef ACE_LACKS_SYSV_SHMEM + +/* Define to 1 if platform lacks the header file. */ +#undef ACE_LACKS_SYS_IOCTL_H + +/* Define to 1 if platform lacks the header file. */ +#undef ACE_LACKS_SYS_IPC_H + +/* Define to 1 if platform lacks the header file. */ +#undef ACE_LACKS_SYS_MMAN_H + +/* Platform lacks sys/msg.h (e.g., Chorus and VxWorks) */ +#undef ACE_LACKS_SYS_MSG_H + +/* Define to 1 if platform lacks the header file. */ +#undef ACE_LACKS_SYS_PARAM_H + +/* Define to 1 if platform lacks the header file. */ +#undef ACE_LACKS_SYS_RESOURCE_H + +/* Define to 1 if platform lacks the header file. */ +#undef ACE_LACKS_SYS_SELECT_H + +/* Define to 1 if platform lacks the header file. */ +#undef ACE_LACKS_SYS_SEM_H + +/* Define to 1 if platform lacks the header file. */ +#undef ACE_LACKS_SYS_SHM_H + +/* Define to 1 if platform lacks the header file. */ +#undef ACE_LACKS_SYS_SOCKET_H + +/* Define to 1 if platform lacks the header file. */ +#undef ACE_LACKS_SYS_STAT_H + +/* Define to 1 if platform lacks the header file. */ +#undef ACE_LACKS_SYS_SYSCTL_H + +/* Define to 1 if platform lacks the header file. */ +#undef ACE_LACKS_SYS_TIME_H + +/* Define to 1 if platform lacks the header file. */ +#undef ACE_LACKS_SYS_TYPES_H + +/* Define to 1 if platform lacks the header file. */ +#undef ACE_LACKS_SYS_UIO_H + +/* Define to 1 if platform lacks the header file. */ +#undef ACE_LACKS_SYS_UN_H + +/* Define to 1 if platform lacks the header file. */ +#undef ACE_LACKS_SYS_WAIT_H + +/* OS does not support TCP_NODELAY */ +#undef ACE_LACKS_TCP_NODELAY + +/* Define to 1 if platform lacks telldir(). */ +#undef ACE_LACKS_TELLDIR + +/* Define to 1 if platform lacks tempnam(). */ +#undef ACE_LACKS_TEMPNAM + +/* Define to 1 if platform lacks the header file. */ +#undef ACE_LACKS_TERMIOS_H + +/* Define to 1 if platform lacks the header file. */ +#undef ACE_LACKS_TERMIO_H + +/* Platform lacks pthread_attr_setscope() */ +#undef ACE_LACKS_THREAD_PROCESS_SCOPING + +/* Define to 1 if platform lacks the declarations of recv_timedwait, + send_timedwait, etc. */ +#undef ACE_LACKS_TIMEDWAIT_PROTOTYPES + +/* Platform does not define timepec_t as a typedef for struct timespec. */ +#undef ACE_LACKS_TIMESPEC_T + +/* Define to 1 if platform lacks the header file. */ +#undef ACE_LACKS_TIME_H + +/* Define to 1 if platform lacks towlower(). */ +#undef ACE_LACKS_TOWLOWER + +/* Define to 1 if platform lacks towupper(). */ +#undef ACE_LACKS_TOWUPPER + +/* Define to 1 if platform lacks truncate(). */ +#undef ACE_LACKS_TRUNCATE + +/* Header files lack t_errno for TLI */ +#undef ACE_LACKS_T_ERRNO + +/* Define to 1 if platform lacks the declaration of ualarm(). */ +#undef ACE_LACKS_UALARM_PROTOTYPE + +/* Define to 1 if platform lacks the header file. */ +#undef ACE_LACKS_UCONTEXT_H + +/* Define to 1 if the system lacks the type `uintmax_t'. */ +#undef ACE_LACKS_UINTMAX_T + +/* Define to 1 if the system lacks the type `uintptr_t'. */ +#undef ACE_LACKS_UINTPTR_T + +/* Define to 1 if platform lacks umask(). */ +#undef ACE_LACKS_UMASK + +/* Define to 1 if platform lacks uname(). */ +#undef ACE_LACKS_UNAME + +/* */ +#undef ACE_LACKS_UNBUFFERED_STREAMBUF + +/* Define to 1 if platform lacks the header file. */ +#undef ACE_LACKS_UNISTD_H + +/* ACE platform has no UNIX domain sockets */ +#undef ACE_LACKS_UNIX_DOMAIN_SOCKETS + +/* Platform lacks full signal support (e.g., Win32 and Chorus). */ +#undef ACE_LACKS_UNIX_SIGNALS + +/* Define to 1 if platform lacks unlink(). */ +#undef ACE_LACKS_UNLINK + +/* Define to 1 if the system lacks the type 'useconds_t'. */ +#undef ACE_LACKS_USECONDS_T + +/* Define to 1 if platform lacks the header file. */ +#undef ACE_LACKS_UTIME_H + +/* Platform lacks struct utsname (e.g., Win32 and VxWorks) */ +#undef ACE_LACKS_UTSNAME_T + +/* Define to 1 if the system lacks the type `u_long_long_t'. */ +#undef ACE_LACKS_U_LONGLONG_T + +/* Define to 1 if platform lacks the header file. */ +#undef ACE_LACKS_WCHAR_H + +/* Define to 1 if the system lacks the type `wchar_t'. */ +#undef ACE_LACKS_WCHAR_T + +/* Define to 1 if platform lacks wcscasecmp(). */ +#undef ACE_LACKS_WCSCASECMP + +/* Define to 1 if platform lacks wcscat(). */ +#undef ACE_LACKS_WCSCAT + +/* Define to 1 if platform lacks wcschr(). */ +#undef ACE_LACKS_WCSCHR + +/* Define to 1 if platform lacks wcscmp(). */ +#undef ACE_LACKS_WCSCMP + +/* Define to 1 if platform lacks wcscpy(). */ +#undef ACE_LACKS_WCSCPY + +/* Define to 1 if platform lacks wcscspn(). */ +#undef ACE_LACKS_WCSCSPN + +/* Define to 1 if platform lacks wcsdup(). */ +#undef ACE_LACKS_WCSDUP + +/* Define to 1 if platform lacks wcslen(). */ +#undef ACE_LACKS_WCSLEN + +/* Define to 1 if platform lacks wcsncasecmp(). */ +#undef ACE_LACKS_WCSNCASECMP + +/* Define to 1 if platform lacks wcsncat(). */ +#undef ACE_LACKS_WCSNCAT + +/* Define to 1 if platform lacks wcsncmp(). */ +#undef ACE_LACKS_WCSNCMP + +/* Define to 1 if platform lacks wcsncpy(). */ +#undef ACE_LACKS_WCSNCPY + +/* Define to 1 if platform lacks wcsnicmp(). */ +#undef ACE_LACKS_WCSNICMP + +/* Define to 1 if platform lacks wcspbrk(). */ +#undef ACE_LACKS_WCSPBRK + +/* Define to 1 if platform lacks wcsrchr(). */ +#undef ACE_LACKS_WCSRCHR + +/* Define to 1 if platform lacks wcsspn(). */ +#undef ACE_LACKS_WCSSPN + +/* Define to 1 if platform lacks wcsstr(). */ +#undef ACE_LACKS_WCSSTR + +/* Define to 1 if platform lacks wcstod(). */ +#undef ACE_LACKS_WCSTOD + +/* Define to 1 if platform lacks wcstok(). */ +#undef ACE_LACKS_WCSTOK + +/* Define to 1 if platform lacks wcstol(). */ +#undef ACE_LACKS_WCSTOL + +/* Define to 1 if platform lacks wcstoul(). */ +#undef ACE_LACKS_WCSTOUL + +/* Define to 1 if platform lacks wcstoull(). */ +#undef ACE_LACKS_WCSTOULL + +/* Define to 1 if platform lacks the header file. */ +#undef ACE_LACKS_WCTYPE_H + +/* Define to 1 if platform lacks writev(). */ +#undef ACE_LACKS_WRITEV + +/* Define to environment variable used for DLL search path */ +#undef ACE_LD_SEARCH_PATH + +/* typedef for ACE_LOFF_T */ +#undef ACE_LOFF_T_TYPEDEF + +/* Renames "main (int, char *[])", for platforms such as g++/VxWorks that + don't allow main. Requires the use of ACE_HAS_NONSTATIC_OBJECT_MANAGER. */ +#undef ACE_MAIN + +/* */ +#undef ACE_MALLOC_ALIGN + +/* */ +#undef ACE_MAP_PRIVATE + +/* Define to 1 if platform has 1 parameter mkdir() */ +#undef ACE_MKDIR_LACKS_MODE + +/* Compile using multi-thread libraries */ +#undef ACE_MT_SAFE + +/* Turns off debugging features */ +#undef ACE_NDEBUG + +/* Necessary with some compilers to pass ACE_TTY_IO as parameter to + DEV_Connector. */ +#undef ACE_NEEDS_DEV_IO_CONVERSION + +/* Compiler requires a definition for a "hidden" function, e.g., a private, + unimplemented copy constructor or assignment operator. The SGI C++ compiler + needs this, in template classes, with + ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA. */ +#undef ACE_NEEDS_FUNC_DEFINITIONS + +/* Required by platforms with small default stacks. */ +#undef ACE_NEEDS_HUGE_THREAD_STACKSIZE + +/* OS has LWPs, and when the priority of a bound thread is set, then the LWP + priority must be set also. */ +#undef ACE_NEEDS_LWP_PRIO_SET + +/* Platform needs to #include to get thread scheduling defs. */ +#undef ACE_NEEDS_SCHED_H + +/* Compiler's 'new' throws exception on failure (ANSI C++ behavior). */ +#undef ACE_NEW_THROWS_EXCEPTIONS + +/* Turns off the LM_DEBUG and LM_ERROR logging macros... */ +#undef ACE_NLOGGING + +/* Explicitly disable ACE inlining */ +#undef ACE_NO_INLINE + +/* Turns off the tracing feature. */ +#undef ACE_NTRACE + +/* Defines the page size of the system (not used on Win32 or with + ACE_HAS_GETPAGESIZE). */ +#undef ACE_PAGE_SIZE + +/* Flag that denotes the symbol should be exported from the DSO/DLL. */ +#undef ACE_Proper_Export_Flag + +/* Flag that denotes the symbol should be imported from the DSO/DLL. */ +#undef ACE_Proper_Import_Flag + +/* Platform redefines the t_... names (UnixWare) */ +#undef ACE_REDEFINES_XTI_FUNCTIONS + +/* shm_open() requires a leading slash in name */ +#undef ACE_SHM_OPEN_REQUIRES_ONE_SLASH + +/* Size of the native "double" type */ +#undef ACE_SIZEOF_DOUBLE + +/* Size of the native "float" type */ +#undef ACE_SIZEOF_FLOAT + +/* Size of the native "int" type */ +#undef ACE_SIZEOF_INT + +/* Size of the native "long" type */ +#undef ACE_SIZEOF_LONG + +/* Size of the native "long double" type */ +#undef ACE_SIZEOF_LONG_DOUBLE + +/* Size of the native "long long" type */ +#undef ACE_SIZEOF_LONG_LONG + +/* Size of the native "short" type */ +#undef ACE_SIZEOF_SHORT + +/* Size of the native "pointer to void" type */ +#undef ACE_SIZEOF_VOID_P + +/* Size of the native "wchar_t" type */ +#undef ACE_SIZEOF_WCHAR + +/* Define to the *printf format specifier (e.g. "%u") for size_t */ +#undef ACE_SIZE_T_FORMAT_SPECIFIER + +/* Define to the *printf format specifier (e.g. "%d") for ssize_t */ +#undef ACE_SSIZE_T_FORMAT_SPECIFIER + +/* Define to function that is equivalent to strcasecmp() */ +#undef ACE_STRCASECMP_EQUIVALENT + +/* Define to function that is equivalent to strdup() */ +#undef ACE_STRDUP_EQUIVALENT + +/* Define to function that is equivalent to strncasecmp() */ +#undef ACE_STRNCASECMP_EQUIVALENT + +/* Compiler's template mechanism must use a pragma. This is used for AIX's C++ + compiler. */ +#undef ACE_TEMPLATES_REQUIRE_PRAGMA + +/* Compiler's template mechanim must see source code (i.e., .cpp files). This + is used for GNU G++. */ +#undef ACE_TEMPLATES_REQUIRE_SOURCE + +/* Specify this if you don't want threads to inherit parent thread's + ACE_Log_Msg properties. */ +#undef ACE_THREADS_DONT_INHERIT_LOG_MSG + +/* */ +#undef ACE_THR_PRI_FIFO_DEF + +/* */ +#undef ACE_TIMER_SKEW + +/* Device the platform uses for TCP on TLI. Only needed if not /dev/tcp. */ +#undef ACE_TLI_TCP_DEVICE + +/* Define to the *printf format specifier (e.g. "%llu") for ACE_UINT64 */ +#undef ACE_UINT64_FORMAT_SPECIFIER + +/* Define to unsigned 64 bit integer type */ +#undef ACE_UINT64_TYPE + +/* Platform uses assembly symbols instead of C symbols in dlsym() */ +#undef ACE_USES_ASM_SYMBOL_IN_DLSYM + +/* Enable IPv6 support on platforms that don't have IPv6 turned on by default + */ +#undef ACE_USES_IPV4_IPV6_MIGRATION + +/* Some files, such as ace/streams.h, want to include new style C++ stream + headers. These headers are iomanip, ios, iostream, istream, ostream, + fstream and streambuf. If _all_ of these headers aren't available, then + assume that only iostream.h and fstream.h are available. */ +#undef ACE_USES_OLD_IOSTREAMS + +/* When linking MFC as a static library is desired */ +#undef ACE_USES_STATIC_MFC + +/* Platform has its standard C++ library in the namespace std. */ +#undef ACE_USES_STD_NAMESPACE_FOR_STDCPP_LIB + +/* ACE is built to use wide characters internally */ +#undef ACE_USES_WCHAR + +/* The OS/platform supports the poll() event demultiplexor */ +#undef ACE_USE_POLL + +/* Define to 1 to embed RCS ID strings into compiled object files. */ +#undef ACE_USE_RCSID + +/* For Win32: Use Select_Reactor as default implementation of Reactor instead + of WFMO_Reactor. */ +#undef ACE_USE_SELECT_REACTOR_FOR_REACTOR_IMPL + +/* Define to function that is equivalent to wcscasecmp() */ +#undef ACE_WCSCASECMP_EQUIVALENT + +/* Define to function that is equivalent to wcsdup() */ +#undef ACE_WCSDUP_EQUIVALENT + +/* Define to function that is equivalent to wcsncasecmp() */ +#undef ACE_WCSNCASECMP_EQUIVALENT + +/* Configure for use on Win32 */ +#undef ACE_WIN32 + +/* A parameter list indicating the version of WinSock (e.g., "1, 1" is version + 1.1). */ +#undef ACE_WSOCK_VERSION + +/* Configure for use on AIX */ +#undef AIX + +/* Define to 1 if the `closedir' function returns void instead of `int'. */ +#undef CLOSEDIR_VOID + +/* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP + systems. This function is required for `alloca.c' support on those systems. + */ +#undef CRAY_STACKSEG_END + +/* GNU Win32 environement */ +#undef CYGWIN32 + +/* Define to 1 if using `alloca.c'. */ +#undef C_ALLOCA + +/* */ +#undef DEC_CXX + +/* Configure for use on Digital Unix */ +#undef DIGITAL_UNIX + +/* Define to 1 if you have `alloca', as a function or macro. */ +#undef HAVE_ALLOCA + +/* Define to 1 if you have and it should be used (not on Ultrix). + */ +#undef HAVE_ALLOCA_H + +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +#undef HAVE_DIRENT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_DLFCN_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_FSTREAM + +/* Define to 1 if you have the header file. */ +#undef HAVE_FSTREAM_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_INTTYPES_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_IOMANIP + +/* Define to 1 if you have the header file. */ +#undef HAVE_IOS + +/* Define to 1 if you have the header file. */ +#undef HAVE_IOSTREAM + +/* Define to 1 if you have the header file. */ +#undef HAVE_IOSTREAM_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_ISTREAM + +/* Define to 1 if you have the `dld' library (-ldld). */ +#undef HAVE_LIBDLD + +/* Define to 1 if you have the header file. */ +#undef HAVE_MEMORY_H + +/* Define to 1 if you have the header file, and it defines `DIR'. */ +#undef HAVE_NDIR_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_OSTREAM + +/* Define to 1 if you have the header file. */ +#undef HAVE_STDINT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STDLIB_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STREAMBUF + +/* Define to 1 if you have the `strftime' function. */ +#undef HAVE_STRFTIME + +/* Define to 1 if you have the header file. */ +#undef HAVE_STRINGS_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STRING_H + +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +#undef HAVE_SYS_DIR_H + +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +#undef HAVE_SYS_NDIR_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_STAT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_TYPES_H + +/* Define to 1 if you have that is POSIX.1 compatible. */ +#undef HAVE_SYS_WAIT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_UNISTD_H + +/* Configure for use on HP-UX */ +#undef HPUX + +/* Configure for use on HP-UX 10 */ +#undef HPUX_10 + +/* Configure for use on HP-UX 11 */ +#undef HPUX_11 + +/* */ +#undef IP_ADD_MEMBERSHIP + +/* */ +#undef IP_DROP_MEMBERSHIP + +/* Configure for use on Irix 5 */ +#undef IRIX5 + +/* Configure for use on Irix 6 */ +#undef IRIX6 + +/* Define to the address where bug reports for this package should be sent. */ +#undef PACKAGE_BUGREPORT + +/* Define to the full name of this package. */ +#undef PACKAGE_NAME + +/* Define to the full name and version of this package. */ +#undef PACKAGE_STRING + +/* Define to the one symbol short name of this package. */ +#undef PACKAGE_TARNAME + +/* Define to the version of this package. */ +#undef PACKAGE_VERSION + +/* Maximum thread priority */ +#undef PTHREAD_MAX_PRIORITY + +/* Minimum thread priority */ +#undef PTHREAD_MIN_PRIORITY + +/* */ +#undef PTHREAD_STACK_MIN + +/* */ +#undef SCO + +/* The size of `double', as computed by sizeof. */ +#undef SIZEOF_DOUBLE + +/* The size of `float', as computed by sizeof. */ +#undef SIZEOF_FLOAT + +/* The size of `int', as computed by sizeof. */ +#undef SIZEOF_INT + +/* The size of `long', as computed by sizeof. */ +#undef SIZEOF_LONG + +/* The size of `long double', as computed by sizeof. */ +#undef SIZEOF_LONG_DOUBLE + +/* The size of `long long', as computed by sizeof. */ +#undef SIZEOF_LONG_LONG + +/* The size of `short', as computed by sizeof. */ +#undef SIZEOF_SHORT + +/* The size of `signed char', as computed by sizeof. */ +#undef SIZEOF_SIGNED_CHAR + +/* The size of `void *', as computed by sizeof. */ +#undef SIZEOF_VOID_P + +/* The size of `wchar_t', as computed by sizeof. */ +#undef SIZEOF_WCHAR_T + +/* If using the C implementation of alloca, define if you know the + direction of stack growth for your system; otherwise it will be + automatically deduced at runtime. + STACK_DIRECTION > 0 => grows toward higher addresses + STACK_DIRECTION < 0 => grows toward lower addresses + STACK_DIRECTION = 0 => direction of growth unknown */ +#undef STACK_DIRECTION + +/* Define to 1 if you have the ANSI C header files. */ +#undef STDC_HEADERS + +/* Configure for use on UnixWare */ +#undef UNIXWARE + +/* */ +#undef UNIXWARE_2_0 + +/* */ +#undef UNIXWARE_2_1 + +/* */ +#undef UNIXWARE_7_1 + +/* Configure for use on VxWorks */ +#undef VXWORKS + +/* Define to 1 if your processor stores words with the most significant byte + first (like Motorola and SPARC, unlike Intel and VAX). */ +#undef WORDS_BIGENDIAN + +/* Define to 1 if the X Window System is missing or not being used. */ +#undef X_DISPLAY_MISSING + +/* Define to 1 if `lex' declares `yytext' as a `char *' by default, not a + `char[]'. */ +#undef YYTEXT_POINTER + +/* Enable ACE inlining */ +#undef __ACE_INLINE__ + +/* */ +#undef __IOCTL_VERSIONED__ + +/* */ +#undef __NO_INCLUDE_WARN__ + + + + +#endif /* ACE_CONFIG_H */ + + +// Local Variables: +// mode:C++ +// End: + + diff --git a/dep/ACE_wrappers/ace/filecache.mpb b/dep/ACE_wrappers/ace/filecache.mpb new file mode 100644 index 00000000000..16c71483398 --- /dev/null +++ b/dep/ACE_wrappers/ace/filecache.mpb @@ -0,0 +1,8 @@ +// -*- MPC -*- +// $Id: filecache.mpb 80826 2008-03-04 14:51:23Z wotte $ + +feature(ace_filecache) { + Source_Files(ACE_COMPONENTS) { + Filecache.cpp + } +} diff --git a/dep/ACE_wrappers/ace/gethrtime.cpp b/dep/ACE_wrappers/ace/gethrtime.cpp new file mode 100644 index 00000000000..69de03153a1 --- /dev/null +++ b/dep/ACE_wrappers/ace/gethrtime.cpp @@ -0,0 +1,60 @@ +// $Id: gethrtime.cpp 80826 2008-03-04 14:51:23Z wotte $ +// +// Build this file with g++. It can be linked in to a ACE application +// that was compiled with GreenHills. It wouldn't be necessary if I +// knew a way to correctly move values from registers to a 64-bit +// variable in GHS asm code. That's easy with g++ asm. + +#include "ace/config-all.h" + +ACE_RCSID(ace, gethrtime, "$Id: gethrtime.cpp 80826 2008-03-04 14:51:23Z wotte $") + +#if defined (ghs) && (defined (i386) || defined(__i386__)) + +#include "ace/OS_NS_time.h" + +extern "C" +ACE_hrtime_t +ACE_GETHRTIME_NAME (void) +{ +#if defined (ACE_HAS_PENTIUM) + // ACE_TRACE ("ACE_GETHRTIME_NAME"); + +#if defined (ACE_LACKS_LONGLONG_T) + double now; +#else /* ! ACE_LACKS_LONGLONG_T */ + ACE_hrtime_t now; +#endif /* ! ACE_LACKS_LONGLONG_T */ + + // Read the high-res tick counter directly into memory variable + // "now". The A constraint signifies a 64-bit int. +#if defined (__GNUG__) + asm volatile ("rdtsc" : "=A" (now) : : "memory"); +// #elif defined (ghs) +// The following doesn't work. For now, this file must be compile with g++. +// asm ("rdtsc"); +// asm ("movl %edx,-16(%ebp)"); +// asm ("movl %eax,-12(%ebp)"); +#else +# error unsupported compiler +#endif + +#if defined (ACE_LACKS_LONGLONG_T) + // ACE_U_LongLong doesn't have the same layout as now, so construct + // it "properly". + ACE_UINT32 least, most; + ACE_OS::memcpy (&least, &now, sizeof (ACE_UINT32)); + ACE_OS::memcpy (&most, (unsigned char *) &now + sizeof (ACE_UINT32), + sizeof (ACE_UINT32)); + + const ACE_hrtime_t ret (least, most); + return ret; +#else /* ! ACE_LACKS_LONGLONG_T */ + return now; +#endif /* ! ACE_LACKS_LONGLONG_T */ + +#else /* ! ACE_HAS_PENTIUM */ +# error This file can _only_ be compiled with ACE_HAS_PENTIUM. +#endif /* ! ACE_HAS_PENTIUM */ +} +#endif /* ghs */ diff --git a/dep/ACE_wrappers/ace/iosfwd.h b/dep/ACE_wrappers/ace/iosfwd.h new file mode 100644 index 00000000000..b07a9f11b05 --- /dev/null +++ b/dep/ACE_wrappers/ace/iosfwd.h @@ -0,0 +1,99 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file iosfwd.h + * + * $Id: iosfwd.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Irfan Pyarali + * + * This file contains the portability ugliness for the Standard C++ + * Library. As implementations of the "standard" emerge, this file + * will need to be updated. + * + * This files deals with forward declaration for the stream + * classes. Remember that since the new Standard C++ Library code + * for streams uses templates, simple forward declaration will not + * work. + */ +//============================================================================= + + +#ifndef ACE_IOSFWD_H +#define ACE_IOSFWD_H + +#include /**/ "ace/pre.h" + +#include /**/ "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#if !defined (ACE_LACKS_IOSTREAM_TOTALLY) + +#if defined (__APPLE_CC__) +// Should this really be here? dhinton +// FUZZ: disable check_for_streams_include +# include "ace/streams.h" +#endif + +#if defined (ACE_HAS_STANDARD_CPP_LIBRARY) && \ + (ACE_HAS_STANDARD_CPP_LIBRARY != 0) + +# if !defined (ACE_USES_OLD_IOSTREAMS) +# include /**/ +# else + // @note If these forward declarations don't work (e.g. aren't + // portable), we may have to include "ace/streams.h" as a last + // resort. Doing so would defeat the purpose of this header, + // unfortunately. + class ios; + class streambuf; + class istream; + class ostream; + class iostream; + class filebuf; + class ifstream; + class ofstream; + class fstream; +# endif /* ! ACE_USES_OLD_IOSTREAMS */ + +# if defined (ACE_USES_STD_NAMESPACE_FOR_STDCPP_LIB) && \ + (ACE_USES_STD_NAMESPACE_FOR_STDCPP_LIB != 0) + +# if !defined (ACE_USES_OLD_IOSTREAMS) + // Make these available in the global name space + using std::ios; + using std::streambuf; + using std::istream; + using std::ostream; + using std::iostream; + using std::filebuf; + using std::ifstream; + using std::ofstream; + using std::fstream; +# endif /* ! ACE_USES_OLD_IOSTREAMS */ + +# endif /* ACE_USES_STD_NAMESPACE_FOR_STDCPP_LIB */ + +#else /* ! ACE_HAS_STANDARD_CPP_LIBRARY */ + + class ios; + class streambuf; + class istream; + class ostream; + class iostream; + class filebuf; + class ifstream; + class ofstream; + class fstream; + +# endif /* ! ACE_HAS_STANDARD_CPP_LIBRARY */ + +#include /**/ "ace/post.h" + +#endif /* ACE_LACKS_IOSTREAM_TOTALLY */ + +#endif /* ACE_IOSFWD_H */ diff --git a/dep/ACE_wrappers/ace/os_include/arpa/os_inet.h b/dep/ACE_wrappers/ace/os_include/arpa/os_inet.h new file mode 100644 index 00000000000..090484d2850 --- /dev/null +++ b/dep/ACE_wrappers/ace/os_include/arpa/os_inet.h @@ -0,0 +1,74 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file os_inet.h + * + * definitions for internet operations + * + * $Id: os_inet.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Don Hinton + * @author This code was originally in various places including ace/OS.h. + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_ARPA_OS_INET_H +#define ACE_OS_INCLUDE_ARPA_OS_INET_H + +#include /**/ "ace/pre.h" + +#include /**/ "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/os_include/netinet/os_in.h" + +#if !defined (ACE_LACKS_ARPA_INET_H) + extern "C" { +# include /**/ + } +#endif /* !ACE_LACKS_ARPA_INET_H */ + +#if defined (ACE_VXWORKS) +# include /**/ +#endif /* ACE_VXWORKS */ + +/** + * In some environments it is useful to swap the bytes on write, for + * instance: a fast server can be feeding a lot of slow clients that + * happen to have the wrong byte order. + * Because this is a rarely used feature we disable it by default to + * minimize footprint. + * This macro enables the functionality, but we still need a way to + * activate it on a per-connection basis. + */ +// #define ACE_ENABLE_SWAP_ON_WRITE + +/** + * In some environements we never need to swap bytes when reading, for + * instance embebbed systems (such as avionics) or homogenous + * networks. + * Setting this macro disables the capabilities to demarshall streams + * in the wrong byte order. + */ +// #define ACE_DISABLE_SWAP_ON_READ + +// Place all additions (especially function declarations) within extern "C" {} +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +#if defined (ACE_LACKS_INET_ATON_PROTOTYPE) + int inet_aton (const char *, struct in_addr *); +#endif /* ACE_LACKS_INET_ATON_PROTOTYPE */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#include /**/ "ace/post.h" +#endif /* ACE_OS_INCLUDE_ARPA_OS_INET_H */ diff --git a/dep/ACE_wrappers/ace/os_include/net/os_if.h b/dep/ACE_wrappers/ace/os_include/net/os_if.h new file mode 100644 index 00000000000..1f59a177292 --- /dev/null +++ b/dep/ACE_wrappers/ace/os_include/net/os_if.h @@ -0,0 +1,119 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file os_if.h + * + * sockets local interfaces + * + * $Id: os_if.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Don Hinton + * @author This code was originally in various places including ace/OS.h. + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_NET_OS_IF_H +#define ACE_OS_INCLUDE_NET_OS_IF_H + +#include /**/ "ace/pre.h" + +#include /**/ "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#if !defined (ACE_LACKS_NET_IF_H) + // This part if to avoid STL name conflict with the map structure + // in net/if.h. +# if defined (ACE_HAS_STL_MAP_CONFLICT) +# define map _Resource_Allocation_Map_ +# endif /* ACE_HAS_STL_MAP_CONFLICT */ + extern "C" { +# include /**/ + } +# if defined (ACE_HAS_STL_MAP_CONFLICT) +# undef map +# endif /* ACE_HAS_STL_MAP_CONFLICT */ +# if defined (HPUX) && defined (IOR) + /* HP-UX 11.11 defines IOR in /usr/include/pa/inline.h + and we don't want that definition. See IOP_IORC.h. + Thanks to Torsten Kopper for this patch.*/ +# undef IOR +# endif /* HPUX && IOR */ +#endif /* !ACE_LACKS_NET_IF_H */ + +#if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) +# include /**/ +#endif /* ACE_HAS_WINSOCK2 */ + +// Place all additions (especially function declarations) within extern "C" {} +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +#if defined (ACE_HAS_BROKEN_IF_HEADER) + struct ifafilt; +#endif /* ACE_HAS_BROKEN_IF_HEADER */ + +#if defined (ACE_LACKS_IFREQ) +struct ifreq { +#define IFNAMSIZ 16 + char ifr_name[IFNAMSIZ]; /* if name, e.g. "en0" */ + union { + struct sockaddr ifru_addr; + struct sockaddr ifru_dstaddr; + struct sockaddr ifru_broadaddr; + short ifru_flags; + int ifru_metric; + int ifru_mtu; + int ifru_phys; + int ifru_media; + caddr_t ifru_data; + int (*ifru_tap)(struct ifnet *, struct ether_header *, struct mbuf *); + } ifr_ifru; +#define ifr_addr ifr_ifru.ifru_addr /* address */ +#define ifr_dstaddr ifr_ifru.ifru_dstaddr /* other end of p-to-p link */ +#define ifr_broadaddr ifr_ifru.ifru_broadaddr /* broadcast address */ +#define ifr_flags ifr_ifru.ifru_flags /* flags */ +#define ifr_metric ifr_ifru.ifru_metric /* metric */ +#define ifr_mtu ifr_ifru.ifru_mtu /* mtu */ +#define ifr_phys ifr_ifru.ifru_phys /* physical wire */ +#define ifr_media ifr_ifru.ifru_media /* physical media */ +#define ifr_data ifr_ifru.ifru_data /* for use by interface */ +#define ifr_tap ifr_ifru.ifru_tap /* tap function */ +}; +#endif /* ACE_LACKS_IFREQ */ + +#if defined (ACE_LACKS_IFCONF) +struct ifconf { + int ifc_len; + union { + caddr_t ifcu_buf; + struct ifreq *ifcu_req; + } ifc_ifcu; +#define ifc_buf ifc_ifcu.ifcu_buf /* buffer address */ +#define ifc_req ifc_ifcu.ifcu_req /* array of structures returned */ + }; +#endif /* ACE_LACKS_IFCONF */ + +#if !defined (IFF_UP) +# define IFF_UP 0x1 +#endif /* IFF_UP */ + +#if !defined (IFF_LOOPBACK) +# define IFF_LOOPBACK 0x8 +#endif /* IFF_LOOPBACK */ + +#if !defined (IFF_BROADCAST) +# define IFF_BROADCAST 0x2 +#endif /* IFF_BROADCAST */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#include /**/ "ace/post.h" +#endif /* ACE_OS_INCLUDE_NET_OS_IF_H */ diff --git a/dep/ACE_wrappers/ace/os_include/netinet/os_in.h b/dep/ACE_wrappers/ace/os_include/netinet/os_in.h new file mode 100644 index 00000000000..4a4346ed4d6 --- /dev/null +++ b/dep/ACE_wrappers/ace/os_include/netinet/os_in.h @@ -0,0 +1,185 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file os_in.h + * + * Internet address family + * + * $Id: os_in.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Don Hinton + * @author This code was originally in various places including ace/OS.h. + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_NETINET_OS_IN_H +#define ACE_OS_INCLUDE_NETINET_OS_IN_H + +#include /**/ "ace/pre.h" + +#include /**/ "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/os_include/os_inttypes.h" +#include "ace/os_include/sys/os_socket.h" + +#if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) +# include /**/ +#endif /* ACE_HAS_WINSOCK2 */ + +#if !defined (ACE_LACKS_NETINET_IN_H) +# if defined (ACE_HAS_STL_QUEUE_CONFLICT) +# define queue _Queue_ +# endif /* ACE_HAS_STL_QUEUE_CONFLICT */ + extern "C" { +# include /**/ + } +# if defined (ACE_HAS_STL_QUEUE_CONFLICT) +# undef queue +# endif /* ACE_HAS_STL_QUEUE_CONFLICT */ +#endif /* !ACE_LACKS_NETINET_IN_H */ + +// Place all additions (especially function declarations) within extern "C" {} +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +# if defined (ACE_HAS_PHARLAP_RT) +# define ACE_IPPROTO_TCP SOL_SOCKET +# else +# define ACE_IPPROTO_TCP IPPROTO_TCP +# endif /* ACE_HAS_PHARLAP_RT */ + +# if !defined (ACE_HAS_IP_MULTICAST) && defined (ACE_LACKS_IP_ADD_MEMBERSHIP) + // Even if ACE_HAS_IP_MULTICAST is not defined, if IP_ADD_MEMBERSHIP + // is defined, assume that the ip_mreq struct is also defined + // (presumably in netinet/in.h). + struct ip_mreq + { + /// IP multicast address of group + struct in_addr imr_multiaddr; + /// Local IP address of interface + struct in_addr imr_interface; + }; +# endif /* ! ACE_HAS_IP_MULTICAST && ACE_LACKS_IP_ADD_MEMBERSHIP */ + +# if defined (ACE_LACKS_IN_ADDR) + struct in_addr + { + u_long s_addr; + }; +# endif /* ACE_LACKS_IN_ADDR */ + +# if defined (ACE_LACKS_SOCKADDR_IN) + struct sockaddr_in + { + short sin_family; // e.g. AF_INET + unsigned short sin_port; // e.g. htons(3490) + struct in_addr sin_addr; // see struct in_addr, below + char sin_zero[8]; // zero this if you want to + }; +# endif /* ACE_LACKS_SOCKADDR_IN */ + +# if defined (ACE_LACKS_SOCKADDR_UN) + struct sockaddr_un { + u_char sun_len; /* sockaddr len including null */ + u_char sun_family; /* AF_UNIX */ + char sun_path[104]; /* path name (gag) */ + }; +#endif /* ACE_LACKS_SOCKADDR_UN */ + +# if defined (ACE_LACKS_IP_MREQ) + struct ip_mreq + { + struct in_addr imr_multiaddr; /* IP multicast address of group */ + struct in_addr imr_interface; /* local IP address of interface */ + }; +# endif /* ACE_LACKS_IP_MREQ */ + +#if !defined (IPPORT_RESERVED) +# define IPPORT_RESERVED 1024 +#endif /* !IPPORT_RESERVED */ + +#if !defined (IPPORT_USERRESERVED) +# define IPPORT_USERRESERVED 5000 +#endif /* !IPPORT_USERRESERVED */ + +// Define INET loopback address constant if it hasn't been defined +// Dotted Decimal 127.0.0.1 == Hexidecimal 0x7f000001 +#if !defined (INADDR_LOOPBACK) +# define INADDR_LOOPBACK ((ACE_UINT32) 0x7f000001) +#endif /* INADDR_LOOPBACK */ + +// The INADDR_NONE address is generally 255.255.255.255. +#if !defined (INADDR_NONE) +# define INADDR_NONE ((ACE_UINT32) 0xffffffff) +#endif /* INADDR_NONE */ + +// Define INET string length constants if they haven't been defined +// +// for IPv4 dotted-decimal +#if !defined (INET_ADDRSTRLEN) +# define INET_ADDRSTRLEN 16 +#endif /* INET_ADDRSTRLEN */ +// +// for IPv6 hex string +#if !defined (INET6_ADDRSTRLEN) +# define INET6_ADDRSTRLEN 46 +#endif /* INET6_ADDRSTRLEN */ + +# if !defined (IP_DROP_MEMBERSHIP) +# define IP_DROP_MEMBERSHIP 0 +# endif /* IP_DROP_MEMBERSHIP */ + +# if !defined (IP_ADD_MEMBERSHIP) +# define IP_ADD_MEMBERSHIP 0 +# define ACE_LACKS_IP_ADD_MEMBERSHIP +# endif /* IP_ADD_MEMBERSHIP */ + +# if !defined (IP_DEFAULT_MULTICAST_TTL) +# define IP_DEFAULT_MULTICAST_TTL 0 +# endif /* IP_DEFAULT_MULTICAST_TTL */ + +# if !defined (IP_DEFAULT_MULTICAST_LOOP) +# define IP_DEFAULT_MULTICAST_LOOP 0 +# endif /* IP_DEFAULT_MULTICAST_LOOP */ + +# if !defined (IP_MULTICAST_IF) +# define IP_MULTICAST_IF 0 +# endif /* IP_MULTICAST_IF */ + +# if !defined (IP_MULTICAST_TTL) +# define IP_MULTICAST_TTL 1 +# endif /* IP_MULTICAST_TTL */ + +# if !defined (IP_MULTICAST_LOOP) +# define IP_MULTICAST_LOOP 2 +# endif /* IP_MULTICAST_LOOP */ + +# if !defined (IP_MAX_MEMBERSHIPS) +# define IP_MAX_MEMBERSHIPS 0 +# endif /* IP_MAX_MEMBERSHIP */ + +# if !defined (IPPROTO_IP) +# define IPPROTO_IP 0 +# endif /* IPPROTO_IP */ + +# if !defined (IPPROTO_TCP) +# define IPPROTO_TCP 6 +# endif /* IPPROTO_TCP */ + +# if !defined (INADDR_ANY) +# define INADDR_ANY (u_long)0x00000000 +# endif /* INADDR_ANY */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#include /**/ "ace/post.h" +#endif /* ACE_OS_INCLUDE_NETINET_OS_IN_H */ diff --git a/dep/ACE_wrappers/ace/os_include/netinet/os_tcp.h b/dep/ACE_wrappers/ace/os_include/netinet/os_tcp.h new file mode 100644 index 00000000000..6e6c6675708 --- /dev/null +++ b/dep/ACE_wrappers/ace/os_include/netinet/os_tcp.h @@ -0,0 +1,46 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file os_tcp.h + * + * definitions for the Internet Transmission Control Protocol (TCP) + * + * $Id: os_tcp.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Don Hinton + * @author This code was originally in various places including ace/OS.h. + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_NETINET_OS_TCP_H +#define ACE_OS_INCLUDE_NETINET_OS_TCP_H + +#include /**/ "ace/pre.h" + +#include /**/ "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#if !defined (ACE_LACKS_NETINET_TCP_H) +# include /**/ +#endif /* !ACE_LACKS_NETIINET_TCP_H */ + +// Place all additions (especially function declarations) within extern "C" {} +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +# if !defined (TCP_NODELAY) +# define TCP_NODELAY 0x01 +# endif /* TCP_NODELAY */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#include /**/ "ace/post.h" +#endif /* ACE_OS_INCLUDE_NETINET_OS_TCP_H */ diff --git a/dep/ACE_wrappers/ace/os_include/os_aio.h b/dep/ACE_wrappers/ace/os_include/os_aio.h new file mode 100644 index 00000000000..4ec9fe9d127 --- /dev/null +++ b/dep/ACE_wrappers/ace/os_include/os_aio.h @@ -0,0 +1,47 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file os_aio.h + * + * asynchronous input and output (REALTIME) + * + * $Id: os_aio.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Don Hinton + * @author This code was originally in various places including ace/OS.h. + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_OS_AIO_H +#define ACE_OS_INCLUDE_OS_AIO_H + +#include /**/ "ace/pre.h" + +#include /**/ "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +// Inclusion of the header may make visible symbols defined in +// the headers , , , and . + +#include "ace/os_include/os_signal.h" // for sigevent + +#if !defined (ACE_LACKS_AIO_H) +# include /**/ +#endif /* !ACE_LACKS_AIO_H */ + +// Place all additions (especially function declarations) within extern "C" {} +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#include /**/ "ace/post.h" +#endif /* ACE_OS_INCLUDE_OS_AIO_H */ diff --git a/dep/ACE_wrappers/ace/os_include/os_assert.h b/dep/ACE_wrappers/ace/os_include/os_assert.h new file mode 100644 index 00000000000..fdca573fe8e --- /dev/null +++ b/dep/ACE_wrappers/ace/os_include/os_assert.h @@ -0,0 +1,46 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file os_assert.h + * + * verify program assertion + * + * $Id: os_assert.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Don Hinton + * @author This code was originally in various places including ace/OS.h. + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_OS_ASSERT_H +#define ACE_OS_INCLUDE_OS_ASSERT_H + +#include /**/ "ace/pre.h" + +#include /**/ "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#if !defined (ACE_LACKS_ASSERT_H) +# include /**/ +#endif /* !ACE_LACKS_ASSERT_H */ + +// Place all additions (especially function declarations) within extern "C" {} +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +#if defined (ACE_LACKS_ASSERT_MACRO) +# define assert(expr) +#endif + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#include /**/ "ace/post.h" +#endif /* ACE_OS_INCLUDE_OS_ASSERT_H */ diff --git a/dep/ACE_wrappers/ace/os_include/os_byteswap.h b/dep/ACE_wrappers/ace/os_include/os_byteswap.h new file mode 100644 index 00000000000..b55754ee810 --- /dev/null +++ b/dep/ACE_wrappers/ace/os_include/os_byteswap.h @@ -0,0 +1,41 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file os_byteswap.h + * + * Byteswap methods + * + * $Id: os_byteswap.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Johnny Willemsen + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_OS_BYTESWAP_H +#define ACE_OS_INCLUDE_OS_BYTESWAP_H + +#include /**/ "ace/pre.h" + +#include /**/ "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#if defined (ACE_HAS_BYTESWAP_H) +# include /**/ +#endif /* !ACE_HAS_INTRIN_H */ + +// Place all additions (especially function declarations) within extern "C" {} +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#include /**/ "ace/post.h" +#endif /* ACE_OS_INCLUDE_OS_BYTESWAP_H */ diff --git a/dep/ACE_wrappers/ace/os_include/os_complex.h b/dep/ACE_wrappers/ace/os_include/os_complex.h new file mode 100644 index 00000000000..5e6546f82df --- /dev/null +++ b/dep/ACE_wrappers/ace/os_include/os_complex.h @@ -0,0 +1,42 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file os_complex.h + * + * complex arithmetic + * + * $Id: os_complex.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Don Hinton + * @author This code was originally in various places including ace/OS.h. + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_OS_COMPLEX_H +#define ACE_OS_INCLUDE_OS_COMPLEX_H + +#include /**/ "ace/pre.h" + +#include /**/ "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#if !defined (ACE_LACKS_COMPLEX_H) +# include /**/ +#endif /* !ACE_LACKS_COMPLEX_H */ + +// Place all additions (especially function declarations) within extern "C" {} +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#include /**/ "ace/post.h" +#endif /* ACE_OS_INCLUDE_OS_COMPLEX_H */ diff --git a/dep/ACE_wrappers/ace/os_include/os_cpio.h b/dep/ACE_wrappers/ace/os_include/os_cpio.h new file mode 100644 index 00000000000..2c06e8eb2f5 --- /dev/null +++ b/dep/ACE_wrappers/ace/os_include/os_cpio.h @@ -0,0 +1,42 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file os_cpio.h + * + * cpio archive values + * + * $Id: os_cpio.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Don Hinton + * @author This code was originally in various places including ace/OS.h. + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_OS_CPIO_H +#define ACE_OS_INCLUDE_OS_CPIO_H + +#include /**/ "ace/pre.h" + +#include /**/ "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#if !defined (ACE_LACKS_CPIO_H) +# include /**/ +#endif /* !ACE_LACKS_CPIO_H */ + +// Place all additions (especially function declarations) within extern "C" {} +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#include /**/ "ace/post.h" +#endif /* ACE_OS_INCLUDE_OS_CPIO_H */ diff --git a/dep/ACE_wrappers/ace/os_include/os_ctype.h b/dep/ACE_wrappers/ace/os_include/os_ctype.h new file mode 100644 index 00000000000..faa04af65ba --- /dev/null +++ b/dep/ACE_wrappers/ace/os_include/os_ctype.h @@ -0,0 +1,45 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file os_ctype.h + * + * character types + * + * $Id: os_ctype.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Don Hinton + * @author This code was originally in various places including ace/OS.h. + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_OS_CTYPE_H +#define ACE_OS_INCLUDE_OS_CTYPE_H + +#include /**/ "ace/pre.h" + +#include /**/ "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#if !defined (ACE_LACKS_CTYPE_H) +# include /**/ +#endif /* !ACE_LACKS_CTYPE_H */ + +// Place all additions (especially function declarations) within extern "C" {} +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +// @todo move the is* and is* emulation methods in ACE_OS here +// and let ACE_OS just call them. + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#include /**/ "ace/post.h" +#endif /* ACE_OS_INCLUDE_OS_CTYPE_H */ diff --git a/dep/ACE_wrappers/ace/os_include/os_dirent.h b/dep/ACE_wrappers/ace/os_include/os_dirent.h new file mode 100644 index 00000000000..2db95c65a52 --- /dev/null +++ b/dep/ACE_wrappers/ace/os_include/os_dirent.h @@ -0,0 +1,108 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file os_dirent.h + * + * format of directory entries + * + * $Id: os_dirent.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Don Hinton + * @author This code was originally in various places including ace/OS.h. + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_OS_DIRENT_H +#define ACE_OS_INCLUDE_OS_DIRENT_H + +#include /**/ "ace/pre.h" + +#include /**/ "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/os_include/sys/os_types.h" +#include "ace/os_include/os_limits.h" + +#if defined (ACE_VXWORKS) && (ACE_VXWORKS < 0x620) +# include "ace/os_include/os_unistd.h" // VxWorks needs this to compile +#endif /* ACE_VXWORKS */ + +#if !defined (ACE_LACKS_DIRENT_H) +# include /**/ +#endif /* !ACE_LACKS_DIRENT_H */ + +// Place all additions (especially function declarations) within extern "C" {} +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +#if !defined (MAXNAMLEN) +# define MAXNAMLEN NAME_MAX +#endif /* !MAXNAMLEN */ + +// At least compile on some of the platforms without info yet. +#if !defined (ACE_HAS_DIRENT) +typedef int ACE_DIR; +struct dirent { +}; +#endif /* ACE_HAS_DIRENT */ + +#if defined (ACE_LACKS_STRUCT_DIR) +struct dirent { + unsigned short d_ino; + unsigned short d_off; + unsigned short d_reclen; + // This must be a ACE_TCHAR * and not a one element + // ACE_TCHAR array. It causes problems on wide + // character builds with Visual C++ 6.0. + ACE_TCHAR *d_name; +}; + +#define ACE_DIRENT dirent + +struct ACE_DIR { + /// The name of the directory we are looking into + ACE_TCHAR *directory_name_; + + /// Remember the handle between calls. + HANDLE current_handle_; + + /// The struct for the results + ACE_DIRENT *dirent_; + + /// The struct for intermediate results. + ACE_TEXT_WIN32_FIND_DATA fdata_; + + /// A flag to remember if we started reading already. + int started_reading_; +}; +#elif defined (ACE_WIN32) && (__BORLANDC__) && defined (ACE_USES_WCHAR) +#define ACE_DIRENT wdirent +typedef wDIR ACE_DIR; +#else +#define ACE_DIRENT dirent +typedef DIR ACE_DIR; +#endif /* ACE_LACKS_STRUCT_DIR */ + +#if defined (ACE_LACKS_SCANDIR_PROTOTYPE) +int scandir (const char *, + struct dirent ***, + int (*) (const struct dirent *), + int (*) (const void *, const void *)); +#endif /* ACE_LACKS_SCANDIR_PROTOTYPE */ + +#if defined (ACE_LACKS_ALPHASORT_PROTOTYPE) +int alphasort (const void *, const void *); +#endif /* ACE_LACKS_ALPHASORT_PROTOTYPE */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#include /**/ "ace/post.h" +#endif /* ACE_OS_INCLUDE_OS_DIRENT_H */ diff --git a/dep/ACE_wrappers/ace/os_include/os_dlfcn.h b/dep/ACE_wrappers/ace/os_include/os_dlfcn.h new file mode 100644 index 00000000000..0f74437fb80 --- /dev/null +++ b/dep/ACE_wrappers/ace/os_include/os_dlfcn.h @@ -0,0 +1,101 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file os_dlfcn.h + * + * dynamic linking + * + * $Id: os_dlfcn.h 82273 2008-07-09 14:21:45Z jtc $ + * + * @author Don Hinton + * @author This code was originally in various places including ace/OS.h. + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_OS_DLFCN_H +#define ACE_OS_INCLUDE_OS_DLFCN_H + +#include /**/ "ace/pre.h" + +#include /**/ "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#if !defined (ACE_LACKS_DLFCN_H) +# include /**/ +#endif /* !ACE_LACKS_DLFCN_H */ + +#if defined (__hpux) +# if defined(__GNUC__) || __cplusplus >= 199707L +# include /**/ +# else +# include /**/ +# endif /* (g++ || HP aC++) vs. HP C++ */ +#endif /* __hpux */ + +#if defined (ACE_VXWORKS) && !defined (__RTP__) +# include /**/ /* for module load */ +# include /**/ /* for module unload */ +# include /**/ /* for findSymbol */ +# include /**/ /* for global symbol table */ +#endif /* ACE_VXWORKS */ + +// Place all additions (especially function declarations) within extern "C" {} +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +#if defined (_M_UNIX) + int _dlclose (void *); + char *_dlerror (void); + void *_dlopen (const char *, int); + void * _dlsym (void *, const char *); +#endif /* _M_UNIX */ + +/* Set the proper handle type for dynamically-loaded libraries. */ +/* Also define a default 'mode' for loading a library - the names and values */ +/* differ between OSes, so if you write code that uses the mode, be careful */ +/* of the platform differences. */ +#if defined (ACE_WIN32) + // Dynamic loading-related types - used for dlopen and family. + typedef HINSTANCE ACE_SHLIB_HANDLE; +# define ACE_SHLIB_INVALID_HANDLE 0 +# define ACE_DEFAULT_SHLIB_MODE 0 +#elif defined (ACE_HAS_SVR4_DYNAMIC_LINKING) + typedef void *ACE_SHLIB_HANDLE; +# define ACE_SHLIB_INVALID_HANDLE 0 + // This is needed to for dynamic_cast to work properly on objects passed to + // libraries. +# define ACE_DEFAULT_SHLIB_MODE RTLD_LAZY | RTLD_GLOBAL +#elif defined (__hpux) + typedef shl_t ACE_SHLIB_HANDLE; +# define ACE_SHLIB_INVALID_HANDLE 0 +# define ACE_DEFAULT_SHLIB_MODE BIND_DEFERRED | DYNAMIC_PATH +#else /* !ACE_WIN32 && !ACE_HAS_SVR4_DYNAMIC_LINKING && !__hpux */ + typedef void *ACE_SHLIB_HANDLE; +# define ACE_SHLIB_INVALID_HANDLE 0 +# define ACE_DEFAULT_SHLIB_MODE RTLD_LAZY +#endif /* ACE_WIN32 */ + +#if !defined (RTLD_LAZY) +#define RTLD_LAZY 1 +#endif /* !RTLD_LAZY */ + +#if !defined (RTLD_NOW) +#define RTLD_NOW 2 +#endif /* !RTLD_NOW */ + +#if !defined (RTLD_GLOBAL) +#define RTLD_GLOBAL 3 +#endif /* !RTLD_GLOBAL */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#include /**/ "ace/post.h" +#endif /* ACE_OS_INCLUDE_OS_DLFCN_H */ diff --git a/dep/ACE_wrappers/ace/os_include/os_errno.h b/dep/ACE_wrappers/ace/os_include/os_errno.h new file mode 100644 index 00000000000..1e297e36495 --- /dev/null +++ b/dep/ACE_wrappers/ace/os_include/os_errno.h @@ -0,0 +1,153 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file os_errno.h + * + * system error numbers + * + * $Id: os_errno.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Don Hinton + * @author This code was originally in various places including ace/OS.h. + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_OS_ERRNO_H +#define ACE_OS_INCLUDE_OS_ERRNO_H + +#include /**/ "ace/pre.h" + +#include "ace/config-lite.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#if !defined (ACE_LACKS_ERRNO_H) +# include /**/ +#endif /* !ACE_LACKS_ERRNO_H */ + +#if defined (ACE_VXWORKS) +// Needed for VxWorks to pickup errnoSet() +#include /**/ +#endif /* ACE_VXWORKS */ + +// Place all additions (especially function declarations) within extern "C" {} +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +#if defined (ACE_WIN32) + // error code mapping for windows +# define ETIME ERROR_SEM_TIMEOUT +# define EWOULDBLOCK WSAEWOULDBLOCK +# define EINPROGRESS WSAEINPROGRESS +# define EALREADY WSAEALREADY +# define ENOTSOCK WSAENOTSOCK +# define EDESTADDRREQ WSAEDESTADDRREQ +# define EMSGSIZE WSAEMSGSIZE +# define EPROTOTYPE WSAEPROTOTYPE +# define ENOPROTOOPT WSAENOPROTOOPT +# define EPROTONOSUPPORT WSAEPROTONOSUPPORT +# define ESOCKTNOSUPPORT WSAESOCKTNOSUPPORT +# define EOPNOTSUPP WSAEOPNOTSUPP +# define EPFNOSUPPORT WSAEPFNOSUPPORT +# define EAFNOSUPPORT WSAEAFNOSUPPORT +# define EADDRINUSE WSAEADDRINUSE +# define EADDRNOTAVAIL WSAEADDRNOTAVAIL +# define ENETDOWN WSAENETDOWN +# define ENETUNREACH WSAENETUNREACH +# define ENETRESET WSAENETRESET +# define ECONNABORTED WSAECONNABORTED +# define ECONNRESET WSAECONNRESET +# define ENOBUFS WSAENOBUFS +# define EISCONN WSAEISCONN +# define ENOTCONN WSAENOTCONN +# define ESHUTDOWN WSAESHUTDOWN +# define ETOOMANYREFS WSAETOOMANYREFS +# define ETIMEDOUT WSAETIMEDOUT +# define ECONNREFUSED WSAECONNREFUSED +# define ELOOP WSAELOOP +# define EHOSTDOWN WSAEHOSTDOWN +# define EHOSTUNREACH WSAEHOSTUNREACH +# define EPROCLIM WSAEPROCLIM +# define EUSERS WSAEUSERS +# define EDQUOT WSAEDQUOT +# define ESTALE WSAESTALE +# define EREMOTE WSAEREMOTE + // Grrr! ENAMETOOLONG and ENOTEMPTY are already defined by the horrible + // 'standard' library. + // #define ENAMETOOLONG WSAENAMETOOLONG +# define EADDRINUSE WSAEADDRINUSE + + // CE needs this... +# if !defined (EPERM) +# define EPERM ERROR_ACCESS_DENIED +# endif +#endif /* ACE_WIN32 */ + +#if defined (ACE_HAS_H_ERRNO) +void herror (const char *str); +#endif /* ACE_HAS_H_ERRNO */ + +#if !defined (ACE_WIN32) && defined (ACE_LACKS_T_ERRNO) +extern int t_errno; +#endif /* ACE_WIN32 && ACE_LACKS_T_ERRNO */ + +#if !defined (ENOSYS) +# define ENOSYS EFAULT /* Operation not supported or unknown error. */ +#endif /* !ENOSYS */ + +#if !defined (ENOTSUP) +# define ENOTSUP ENOSYS /* Operation not supported. */ +#endif /* !ENOTSUP */ + +#if !defined (ESUCCESS) +# define ESUCCESS 0 +#endif /* !ESUCCESS */ + +#if !defined (EIDRM) +# define EIDRM 0 +#endif /* !EIDRM */ + +#if !defined (ENFILE) +# define ENFILE EMFILE /* No more socket descriptors are available. */ +#endif /* !ENFILE */ + +#if !defined (ECOMM) + // Not the same, but ECONNABORTED is provided on NT. +# define ECOMM ECONNABORTED +#endif /* ECOMM */ + +#if !defined (EDEADLK) +# define EDEADLK 1000 /* Some large number.... */ +#endif /* !EDEADLK */ + +#if !defined (ENXIO) /* Needed in SOCK_Dgram_Mcast */ +# define ENXIO 6 +#endif /* ENXIO */ + +#if !defined (ETIMEDOUT) && defined (ETIME) +# define ETIMEDOUT ETIME +#endif /* ETIMEDOUT */ + +#if !defined (ETIME) && defined (ETIMEDOUT) +# define ETIME ETIMEDOUT +#endif /* ETIMED */ + +#if !defined (EBUSY) +# define EBUSY ETIME +#endif /* EBUSY */ + +#if !defined (ECANCELED) +# define ECANCELED 125 +#endif /* ECANCELED */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#include /**/ "ace/post.h" +#endif /* ACE_OS_INCLUDE_OS_ERRNO_H */ diff --git a/dep/ACE_wrappers/ace/os_include/os_fcntl.h b/dep/ACE_wrappers/ace/os_include/os_fcntl.h new file mode 100644 index 00000000000..048ff62ae6e --- /dev/null +++ b/dep/ACE_wrappers/ace/os_include/os_fcntl.h @@ -0,0 +1,106 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file os_fcntl.h + * + * file control options + * + * $Id: os_fcntl.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Don Hinton + * @author This code was originally in various places including ace/OS.h. + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_OS_FCNTL_H +#define ACE_OS_INCLUDE_OS_FCNTL_H + +#include /**/ "ace/pre.h" + +#include /**/ "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/os_include/sys/os_stat.h" +#include "ace/os_include/sys/os_types.h" + +#if !defined (ACE_LACKS_FCNTL_H) +# include /**/ +#endif /* !ACE_LACKS_FCNTL_H */ + +#if defined (ACE_VXWORKS) && (ACE_VXWORKS < 0x620) +// for creat(), open() +# include /**/ +#endif /* ACE_VXWORKS */ + +// Place all additions (especially function declarations) within extern "C" {} +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +#if defined (__BORLANDC__) +# define _O_CREAT O_CREAT +# define _O_EXCL O_EXCL +# define _O_TRUNC O_TRUNC + // 0x0800 is used for O_APPEND. 0x08 looks free. +# define _O_TEMPORARY 0x08 /* see fcntl.h */ +# define _O_RDWR O_RDWR +# define _O_WRONLY O_WRONLY +# define _O_RDONLY O_RDONLY +# define _O_APPEND O_APPEND +# define _O_BINARY O_BINARY +# define _O_TEXT O_TEXT +#endif /* __BORLANDC__ */ + +#if defined (__DMC__) +# define _O_TEMPORARY 0x08 /* see fcntl.h */ +#endif /* __DMC__ */ + +// defined Win32 specific macros for UNIX platforms +#if !defined (O_BINARY) +# define O_BINARY 0 +#endif /* O_BINARY */ +#if !defined (_O_BINARY) +# define _O_BINARY O_BINARY +#endif /* _O_BINARY */ +#if !defined (O_TEXT) +# define O_TEXT 0 +#endif /* O_TEXT */ +#if !defined (_O_TEXT) +# define _O_TEXT O_TEXT +#endif /* _O_TEXT */ +#if !defined (O_RAW) +# define O_RAW 0 +#endif /* O_RAW */ +#if !defined (_O_RAW) +# define _O_RAW O_RAW +#endif /* _O_RAW */ + +#if defined (ACE_WIN32) +# define O_NDELAY 1 +#endif /* ACE_WIN32 */ + +# if !defined (O_NONBLOCK) +# define O_NONBLOCK 1 +# endif /* O_NONBLOCK */ + +#if defined (ACE_HAS_POSIX_NONBLOCK) +# define ACE_NONBLOCK O_NONBLOCK +#else +# define ACE_NONBLOCK O_NDELAY +#endif /* ACE_HAS_POSIX_NONBLOCK */ + +# if !defined (F_GETFL) +# define F_GETFL 0 +# endif /* F_GETFL */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#include /**/ "ace/post.h" +#endif /* ACE_OS_INCLUDE_OS_FCNTL_H */ diff --git a/dep/ACE_wrappers/ace/os_include/os_fenv.h b/dep/ACE_wrappers/ace/os_include/os_fenv.h new file mode 100644 index 00000000000..cbf5ab41100 --- /dev/null +++ b/dep/ACE_wrappers/ace/os_include/os_fenv.h @@ -0,0 +1,42 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file os_fenv.h + * + * floating-point environment + * + * $Id: os_fenv.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Don Hinton + * @author This code was originally in various places including ace/OS.h. + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_OS_FENV_H +#define ACE_OS_INCLUDE_OS_FENV_H + +#include /**/ "ace/pre.h" + +#include /**/ "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#if !defined (ACE_LACKS_FENV_H) +# include /**/ +#endif /* !ACE_LACKS_FENV_H */ + +// Place all additions (especially function declarations) within extern "C" {} +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#include /**/ "ace/post.h" +#endif /* ACE_OS_INCLUDE_OS_FENV_H */ diff --git a/dep/ACE_wrappers/ace/os_include/os_float.h b/dep/ACE_wrappers/ace/os_include/os_float.h new file mode 100644 index 00000000000..ac4b2f8f961 --- /dev/null +++ b/dep/ACE_wrappers/ace/os_include/os_float.h @@ -0,0 +1,42 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file os_float.h + * + * floating types + * + * $Id: os_float.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Don Hinton + * @author This code was originally in various places including ace/OS.h. + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_OS_FLOAT_H +#define ACE_OS_INCLUDE_OS_FLOAT_H + +#include /**/ "ace/pre.h" + +#include "ace/config-lite.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#if !defined (ACE_LACKS_FLOAT_H) +# include /**/ +#endif /* !ACE_LACKS_FLOAT_H */ + +// Place all additions (especially function declarations) within extern "C" {} +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#include /**/ "ace/post.h" +#endif /* ACE_OS_INCLUDE_OS_FLOAT_H */ diff --git a/dep/ACE_wrappers/ace/os_include/os_fmtmsg.h b/dep/ACE_wrappers/ace/os_include/os_fmtmsg.h new file mode 100644 index 00000000000..74251a950d6 --- /dev/null +++ b/dep/ACE_wrappers/ace/os_include/os_fmtmsg.h @@ -0,0 +1,42 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file os_fmtmsg.h + * + * message display structures + * + * $Id: os_fmtmsg.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Don Hinton + * @author This code was originally in various places including ace/OS.h. + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_OS_FMTMSG_H +#define ACE_OS_INCLUDE_OS_FMTMSG_H + +#include /**/ "ace/pre.h" + +#include /**/ "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#if !defined (ACE_LACKS_FMTMSG_H) +# include /**/ +#endif /* !ACE_LACKS_FMTMSG_H */ + +// Place all additions (especially function declarations) within extern "C" {} +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#include /**/ "ace/post.h" +#endif /* ACE_OS_INCLUDE_OS_FMTMSG_H */ diff --git a/dep/ACE_wrappers/ace/os_include/os_fnmatch.h b/dep/ACE_wrappers/ace/os_include/os_fnmatch.h new file mode 100644 index 00000000000..36726e293ae --- /dev/null +++ b/dep/ACE_wrappers/ace/os_include/os_fnmatch.h @@ -0,0 +1,42 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file os_fnmatch.h + * + * filename-matching types + * + * $Id: os_fnmatch.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Don Hinton + * @author This code was originally in various places including ace/OS.h. + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_OS_FNMATCH_H +#define ACE_OS_INCLUDE_OS_FNMATCH_H + +#include /**/ "ace/pre.h" + +#include /**/ "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#if !defined (ACE_LACKS_FNMATCH_H) +# include /**/ +#endif /* !ACE_LACKS_FNMATCH_H */ + +// Place all additions (especially function declarations) within extern "C" {} +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#include /**/ "ace/post.h" +#endif /* ACE_OS_INCLUDE_OS_FNMATCH_H */ diff --git a/dep/ACE_wrappers/ace/os_include/os_ftw.h b/dep/ACE_wrappers/ace/os_include/os_ftw.h new file mode 100644 index 00000000000..225d3251339 --- /dev/null +++ b/dep/ACE_wrappers/ace/os_include/os_ftw.h @@ -0,0 +1,44 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file os_ftw.h + * + * file tree traversal + * + * $Id: os_ftw.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Don Hinton + * @author This code was originally in various places including ace/OS.h. + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_OS_FTW_H +#define ACE_OS_INCLUDE_OS_FTW_H + +#include /**/ "ace/pre.h" + +#include /**/ "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/os_include/sys/os_stat.h" + +#if !defined (ACE_LACKS_FTW_H) +# include /**/ +#endif /* !ACE_LACKS_FTW_H */ + +// Place all additions (especially function declarations) within extern "C" {} +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#include /**/ "ace/post.h" +#endif /* ACE_OS_INCLUDE_OS_FTW_H */ diff --git a/dep/ACE_wrappers/ace/os_include/os_glob.h b/dep/ACE_wrappers/ace/os_include/os_glob.h new file mode 100644 index 00000000000..0ced3a36234 --- /dev/null +++ b/dep/ACE_wrappers/ace/os_include/os_glob.h @@ -0,0 +1,42 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file os_glob.h + * + * pathname pattern-matching types + * + * $Id: os_glob.h 81692 2008-05-14 12:25:02Z johnnyw $ + * + * @author Don Hinton + * @author This code was originally in various places including ace/OS.h. + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_OS_GLOB_H +#define ACE_OS_INCLUDE_OS_GLOB_H + +#include /**/ "ace/pre.h" + +#include /**/ "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#if !defined (ACE_LACKS_GLOB_H) +# include /**/ +#endif /* !ACE_LACKS_GLOB_H */ + +// Place all additions (especially function declarations) within extern "C" {} +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#include /**/ "ace/post.h" +#endif /* ACE_OS_INCLUDE_OS_GLOB_H */ diff --git a/dep/ACE_wrappers/ace/os_include/os_grp.h b/dep/ACE_wrappers/ace/os_include/os_grp.h new file mode 100644 index 00000000000..74bb6e64737 --- /dev/null +++ b/dep/ACE_wrappers/ace/os_include/os_grp.h @@ -0,0 +1,44 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file os_grp.h + * + * group structure + * + * $Id: os_grp.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Don Hinton + * @author This code was originally in various places including ace/OS.h. + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_OS_GRP_H +#define ACE_OS_INCLUDE_OS_GRP_H + +#include /**/ "ace/pre.h" + +#include /**/ "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/os_include/sys/os_types.h" // for gid_t + +#if !defined (ACE_LACKS_GRP_H) +# include /**/ +#endif /* !ACE_LACKS_GRP_H */ + +// Place all additions (especially function declarations) within extern "C" {} +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#include /**/ "ace/post.h" +#endif /* ACE_OS_INCLUDE_OS_GRP_H */ diff --git a/dep/ACE_wrappers/ace/os_include/os_iconv.h b/dep/ACE_wrappers/ace/os_include/os_iconv.h new file mode 100644 index 00000000000..33b061cd789 --- /dev/null +++ b/dep/ACE_wrappers/ace/os_include/os_iconv.h @@ -0,0 +1,44 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file os_iconv.h + * + * codeset conversion facility + * + * $Id: os_iconv.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Don Hinton + * @author This code was originally in various places including ace/OS.h. + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_OS_ICONV_H +#define ACE_OS_INCLUDE_OS_ICONV_H + +#include /**/ "ace/pre.h" + +#include /**/ "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/os_include/sys/os_types.h" + +#if !defined (ACE_LACKS_ICONV_H) +# include /**/ +#endif /* !ACE_LACKS_ICONV_H */ + +// Place all additions (especially function declarations) within extern "C" {} +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#include /**/ "ace/post.h" +#endif /* ACE_OS_INCLUDE_OS_ICONV_H */ diff --git a/dep/ACE_wrappers/ace/os_include/os_intrin.h b/dep/ACE_wrappers/ace/os_include/os_intrin.h new file mode 100644 index 00000000000..37b669500e2 --- /dev/null +++ b/dep/ACE_wrappers/ace/os_include/os_intrin.h @@ -0,0 +1,57 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file os_intrin.h + * + * Intrinsic methods + * + * $Id: os_intrin.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Johnny Willemsen + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_OS_INTRIN_H +#define ACE_OS_INCLUDE_OS_INTRIN_H + +#include /**/ "ace/pre.h" + +#include /**/ "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#if defined (ACE_HAS_INTRIN_H) +# include /**/ +#endif /* !ACE_HAS_INTRIN_H */ + +#if defined (ACE_HAS_IA64INTRIN_H) +# include /**/ +#endif /* !ACE_HAS_IA64INTRIN_H */ + +#if defined (ACE_HAS_IA32INTRIN_H) +# include /**/ +#endif /* !ACE_HAS_IA32INTRIN_H */ + +// Place all additions (especially function declarations) within extern "C" {} +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +#if defined (_MSC_VER) && (_MSC_VER < 1400) && !(defined (__INTEL_COMPILER) && (__INTEL_COMPILER == 900)) +// See http://msdn2.microsoft.com/en-us/library/f24ya7ct(VS.71).aspx +LONG __cdecl _InterlockedIncrement (LONG volatile *Addend); +LONG __cdecl _InterlockedDecrement (LONG volatile *Addend); +LONG __cdecl _InterlockedExchange (LONG volatile *Target, LONG Value); +LONG __cdecl _InterlockedExchangeAdd (LONG volatile *Addend, LONG Value); +#endif //_MSC_VER + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#include /**/ "ace/post.h" +#endif /* ACE_OS_INCLUDE_OS_INTRIN_H */ diff --git a/dep/ACE_wrappers/ace/os_include/os_inttypes.h b/dep/ACE_wrappers/ace/os_include/os_inttypes.h new file mode 100644 index 00000000000..2f0c188699e --- /dev/null +++ b/dep/ACE_wrappers/ace/os_include/os_inttypes.h @@ -0,0 +1,46 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file os_inttypes.h + * + * fixed size integer types + * + * $Id: os_inttypes.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Don Hinton + * @author This code was originally in various places including ace/OS.h. + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_OS_INTTYPES_H +#define ACE_OS_INCLUDE_OS_INTTYPES_H + +#include /**/ "ace/pre.h" + +#include "ace/config-lite.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/os_include/os_stdint.h" + +#if !defined (ACE_LACKS_INTTYPES_H) +# include /**/ +#endif /* !ACE_LACKS_INTTYPES_H */ + +// Place all additions (especially function declarations) within extern "C" {} +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +// @todo if needbe, we can define the macros if they aren't available. + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#include /**/ "ace/post.h" +#endif /* ACE_OS_INCLUDE_OS_INTTYPES_H */ diff --git a/dep/ACE_wrappers/ace/os_include/os_iso646.h b/dep/ACE_wrappers/ace/os_include/os_iso646.h new file mode 100644 index 00000000000..0c5ab2ae4aa --- /dev/null +++ b/dep/ACE_wrappers/ace/os_include/os_iso646.h @@ -0,0 +1,42 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file os_iso646.h + * + * alternative spellings + * + * $Id: os_iso646.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Don Hinton + * @author This code was originally in various places including ace/OS.h. + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_OS_ISO646_H +#define ACE_OS_INCLUDE_OS_ISO646_H + +#include /**/ "ace/pre.h" + +#include /**/ "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#if !defined (ACE_LACKS_ISO646_H) +# include /**/ +#endif /* !ACE_LACKS_ISO646_H */ + +// Place all additions (especially function declarations) within extern "C" {} +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#include /**/ "ace/post.h" +#endif /* ACE_OS_INCLUDE_OS_ISO646_H */ diff --git a/dep/ACE_wrappers/ace/os_include/os_kstat.h b/dep/ACE_wrappers/ace/os_include/os_kstat.h new file mode 100644 index 00000000000..31836cd27d0 --- /dev/null +++ b/dep/ACE_wrappers/ace/os_include/os_kstat.h @@ -0,0 +1,43 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file os_kstat.h + * + * $Id: os_kstat.h 81692 2008-05-14 12:25:02Z johnnyw $ + * + * @author Johnny Willemsen + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_OS_KSTAT_H +#define ACE_OS_INCLUDE_OS_KSTAT_H + +#include /**/ "ace/pre.h" + +#include /**/ "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#if defined (ACE_HAS_KSTAT) +# define ACE_HAS_KSTAT_H +#endif /* ACE_HAS_KSTAT */ + +#if defined (ACE_HAS_KSTAT_H) +# include +#endif /* ACE_HAS_KSTAT_H */ + +// Place all additions (especially function declarations) within extern "C" {} +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#include /**/ "ace/post.h" +#endif /* ACE_OS_INCLUDE_OS_KSTAT_H */ diff --git a/dep/ACE_wrappers/ace/os_include/os_langinfo.h b/dep/ACE_wrappers/ace/os_include/os_langinfo.h new file mode 100644 index 00000000000..bfcd67cc2dc --- /dev/null +++ b/dep/ACE_wrappers/ace/os_include/os_langinfo.h @@ -0,0 +1,44 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file os_langinfo.h + * + * language information constants + * + * $Id: os_langinfo.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Don Hinton + * @author This code was originally in various places including ace/OS.h. + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_OS_LANGINFO_H +#define ACE_OS_INCLUDE_OS_LANGINFO_H + +#include /**/ "ace/pre.h" + +#include /**/ "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/os_include/os_nl_types.h" + +#if !defined (ACE_LACKS_LANGINFO_H) +# include /**/ +#endif /* !ACE_LACKS_LANGINFO_H */ + +// Place all additions (especially function declarations) within extern "C" {} +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#include /**/ "ace/post.h" +#endif /* ACE_OS_INCLUDE_OS_LANGINFO_H */ diff --git a/dep/ACE_wrappers/ace/os_include/os_libgen.h b/dep/ACE_wrappers/ace/os_include/os_libgen.h new file mode 100644 index 00000000000..ca24a4d7f9b --- /dev/null +++ b/dep/ACE_wrappers/ace/os_include/os_libgen.h @@ -0,0 +1,42 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file os_libgen.h + * + * definitions for pattern matching functions + * + * $Id: os_libgen.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Don Hinton + * @author This code was originally in various places including ace/OS.h. + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_OS_LIBGEN_H +#define ACE_OS_INCLUDE_OS_LIBGEN_H + +#include /**/ "ace/pre.h" + +#include /**/ "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#if !defined (ACE_LACKS_LIBGEN_H) +# include /**/ +#endif /* !ACE_LACKS_LIBGEN_H */ + +// Place all additions (especially function declarations) within extern "C" {} +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#include /**/ "ace/post.h" +#endif /* ACE_OS_INCLUDE_OS_LIBGEN_H */ diff --git a/dep/ACE_wrappers/ace/os_include/os_limits.h b/dep/ACE_wrappers/ace/os_include/os_limits.h new file mode 100644 index 00000000000..1b1267721ae --- /dev/null +++ b/dep/ACE_wrappers/ace/os_include/os_limits.h @@ -0,0 +1,143 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file os_limits.h + * + * implementation-defined constants + * + * $Id: os_limits.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Don Hinton + * @author This code was originally in various places including ace/OS.h. + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_OS_LIMITS_H +#define ACE_OS_INCLUDE_OS_LIMITS_H + +#include /**/ "ace/pre.h" + +#include "ace/config-lite.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/os_include/os_unistd.h" +#include "ace/os_include/os_stdio.h" // for FILENAME_MAX on Windows + +#if !defined (ACE_LACKS_LIMITS_H) +# include /**/ +#endif /* !ACE_LACKS_LIMITS_H */ + +#if !defined (ACE_LACKS_SYS_PARAM_H) +# include /**/ +#endif /* ACE_LACKS_SYS_PARAM_H */ + +// On VxWorks 5.5.1 _POSIX_TIMER_MAX is defined in time.h +#if defined (ACE_VXWORKS) && (ACE_VXWORKS < 0x620) +# include /**/ +#endif /* ACE_VXWORKS */ + +// Place all additions (especially function declarations) within extern "C" {} +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +#if ! defined (howmany) +# define howmany(x, y) (((x)+((y)-1))/(y)) +#endif /* howmany */ + +#if !defined (NAME_MAX) +# if defined (MAXNAMLEN) +# define NAME_MAX MAXNAMLEN +# elif defined (MAXNAMELEN) +# define NAME_MAX MAXNAMELEN +# elif defined (FILENAME_MAX) +# define NAME_MAX FILENAME_MAX +# elif defined (_MAX_FNAME) +# define NAME_MAX _MAX_FNAME +# else /* _MAX_FNAME */ +# define NAME_MAX 256 +# endif /* MAXNAMLEN */ +#endif /* !NAME_MAX */ + +#if !defined (MAXNAMELEN) +# define MAXNAMELEN NAME_MAX +#endif /* MAXNAMELEN */ + +#if !defined (HOST_NAME_MAX) +# define HOST_NAME_MAX 256 +#endif /* !HOST_NAME_MAX */ + +// Note that we are using PATH_MAX instead of _POSIX_PATH_MAX, since +// _POSIX_PATH_MAX is the *minimun* maximum value for PATH_MAX and is +// defined by POSIX as 256. +#if !defined (PATH_MAX) +# if defined (_MAX_PATH) +# define PATH_MAX _MAX_PATH +# elif defined (MAX_PATH) +# define PATH_MAX MAX_PATH +# else /* !_MAX_PATH */ +# define PATH_MAX 1024 +# endif /* _MAX_PATH */ +#endif /* !PATH_MAX */ + +// Leaving this for backward compatibility, but PATH_MAX should always be +// used directly. +#if !defined (MAXPATHLEN) +# define MAXPATHLEN PATH_MAX +#endif /* !MAXPATHLEN */ + +// This is defined by XOPEN to be a minimum of 16. POSIX.1g +// also defines this value. platform-specific config.h can +// override this if need be. +#if !defined (IOV_MAX) +# define IOV_MAX 16 +#endif /* IOV_MAX */ + +#if !defined (ACE_IOV_MAX) +# define ACE_IOV_MAX IOV_MAX +#endif /* ACE_IOV_MAX */ + +#if defined (ACE_VXWORKS) && ((ACE_VXWORKS >= 0x620) && (ACE_VXWORKS <= 0x660)) && !defined (__RTP__) +# if defined (PIPE_BUF) && (PIPE_BUF == -1) +# undef PIPE_BUF +# endif +#endif /* ACE_VXWORKS */ + +#if !defined (PIPE_BUF) +# define PIPE_BUF 5120 +#endif /* PIPE_BUF */ + +#if defined (ACE_HAS_POSIX_REALTIME_SIGNALS) + // = Giving unique ACE scoped names for some important + // RTSignal-Related constants. Becuase sometimes, different + // platforms use different names for these constants. + + // Number of realtime signals provided in the system. + // _POSIX_RTSIG_MAX is the upper limit on the number of real time + // signals supported in a posix-4 compliant system. +# if defined (_POSIX_RTSIG_MAX) +# define ACE_RTSIG_MAX _POSIX_RTSIG_MAX +# else /* not _POSIX_RTSIG_MAX */ + // POSIX-4 compilant system has to provide atleast 8 RT signals. + // @@ Make sure the platform does *not* define this constant with + // some other name. If yes, use that instead of 8. +# define ACE_RTSIG_MAX 8 +# endif /* _POSIX_RTSIG_MAX */ +#endif /* ACE_HAS_POSIX_REALTIME_SIGNALS */ + + // The maximum number of concurrent timers per process. +# if !defined (_POSIX_TIMER_MAX) +# define _POSIX_TIMER_MAX 44 +# endif /* _POSIX_TIMER_MAX */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#include /**/ "ace/post.h" +#endif /* ACE_OS_INCLUDE_OS_LIMITS_H */ diff --git a/dep/ACE_wrappers/ace/os_include/os_local.h b/dep/ACE_wrappers/ace/os_include/os_local.h new file mode 100644 index 00000000000..b5752f9ab95 --- /dev/null +++ b/dep/ACE_wrappers/ace/os_include/os_local.h @@ -0,0 +1,44 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file os_local.h + * + * category macros + * + * $Id: os_local.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Don Hinton + * @author This code was originally in various places including ace/OS.h. + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_OS_LOCAL_H +#define ACE_OS_INCLUDE_OS_LOCAL_H + +#include /**/ "ace/pre.h" + +#include /**/ "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/os_include/os_stddef.h" + +#if !defined (ACE_LACKS_LOCAL_H) +# include /**/ +#endif /* !ACE_LACKS_LOCAL_H */ + +// Place all additions (especially function declarations) within extern "C" {} +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#include /**/ "ace/post.h" +#endif /* ACE_OS_INCLUDE_OS_LOCAL_H */ diff --git a/dep/ACE_wrappers/ace/os_include/os_math.h b/dep/ACE_wrappers/ace/os_include/os_math.h new file mode 100644 index 00000000000..6fb53cb1576 --- /dev/null +++ b/dep/ACE_wrappers/ace/os_include/os_math.h @@ -0,0 +1,44 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file os_math.h + * + * mathematical declarations + * + * $Id: os_math.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Don Hinton + * @author This code was originally in various places including ace/OS.h. + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_OS_MATH_H +#define ACE_OS_INCLUDE_OS_MATH_H + +#include /**/ "ace/pre.h" + +#include /**/ "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +// FUZZ: disable check_for_math_include + +#if !defined (ACE_LACKS_MATH_H) +# include /**/ +#endif /* !ACE_LACKS_MATH_H */ + +// Place all additions (especially function declarations) within extern "C" {} +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#include /**/ "ace/post.h" +#endif /* ACE_OS_INCLUDE_OS_MATH_H */ diff --git a/dep/ACE_wrappers/ace/os_include/os_monetary.h b/dep/ACE_wrappers/ace/os_include/os_monetary.h new file mode 100644 index 00000000000..6e956885ad6 --- /dev/null +++ b/dep/ACE_wrappers/ace/os_include/os_monetary.h @@ -0,0 +1,44 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file os_monetary.h + * + * monetary types + * + * $Id: os_monetary.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Don Hinton + * @author This code was originally in various places including ace/OS.h. + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_OS_MONETARY_H +#define ACE_OS_INCLUDE_OS_MONETARY_H + +#include /**/ "ace/pre.h" + +#include /**/ "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/os_include/sys/os_types.h" + +#if !defined (ACE_LACKS_MONETARY_H) +# include /**/ +#endif /* !ACE_LACKS_MONETARY_H */ + +// Place all additions (especially function declarations) within extern "C" {} +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#include /**/ "ace/post.h" +#endif /* ACE_OS_INCLUDE_OS_MONETARY_H */ diff --git a/dep/ACE_wrappers/ace/os_include/os_mqueue.h b/dep/ACE_wrappers/ace/os_include/os_mqueue.h new file mode 100644 index 00000000000..7b3cbb9209a --- /dev/null +++ b/dep/ACE_wrappers/ace/os_include/os_mqueue.h @@ -0,0 +1,44 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file os_mqueue.h + * + * message queues (REALTIME) + * + * $Id: os_mqueue.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Don Hinton + * @author This code was originally in various places including ace/OS.h. + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_OS_MQUEUE_H +#define ACE_OS_INCLUDE_OS_MQUEUE_H + +#include /**/ "ace/pre.h" + +#include /**/ "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/os_include/os_signal.h" + +#if !defined (ACE_LACKS_MQUEUE_H) +# include /**/ +#endif /* !ACE_LACKS_MQUEUE_H */ + +// Place all additions (especially function declarations) within extern "C" {} +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#include /**/ "ace/post.h" +#endif /* ACE_OS_INCLUDE_OS_MQUEUE_H */ diff --git a/dep/ACE_wrappers/ace/os_include/os_ndbm.h b/dep/ACE_wrappers/ace/os_include/os_ndbm.h new file mode 100644 index 00000000000..042dcebf2ff --- /dev/null +++ b/dep/ACE_wrappers/ace/os_include/os_ndbm.h @@ -0,0 +1,44 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file os_ndbm.h + * + * definitions for ndbm database operations + * + * $Id: os_ndbm.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Don Hinton + * @author This code was originally in various places including ace/OS.h. + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_OS_NDBM_H +#define ACE_OS_INCLUDE_OS_NDBM_H + +#include /**/ "ace/pre.h" + +#include /**/ "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/os_include/sys/os_types.h" + +#if !defined (ACE_LACKS_NDBM_H) +# include /**/ +#endif /* !ACE_LACKS_NDBM_H */ + +// Place all additions (especially function declarations) within extern "C" {} +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#include /**/ "ace/post.h" +#endif /* ACE_OS_INCLUDE_OS_NDBM_H */ diff --git a/dep/ACE_wrappers/ace/os_include/os_netdb.h b/dep/ACE_wrappers/ace/os_include/os_netdb.h new file mode 100644 index 00000000000..286cb275481 --- /dev/null +++ b/dep/ACE_wrappers/ace/os_include/os_netdb.h @@ -0,0 +1,108 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file os_netdb.h + * + * definitions for network database operations + * + * $Id: os_netdb.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Don Hinton + * @author This code was originally in various places including ace/OS.h. + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_OS_NETDB_H +#define ACE_OS_INCLUDE_OS_NETDB_H + +#include /**/ "ace/pre.h" + +#include /**/ "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/os_include/netinet/os_in.h" +#include "ace/os_include/os_limits.h" + +#if !defined (ACE_LACKS_NETDB_H) +# if defined (ACE_HAS_STL_QUEUE_CONFLICT) +# define queue _Queue_ +# endif /* ACE_HAS_STL_QUEUE_CONFLICT */ + extern "C" { +# include /**/ + } +# if defined (ACE_HAS_STL_QUEUE_CONFLICT) +# undef queue +# endif /* ACE_HAS_STL_QUEUE_CONFLICT */ +#endif /* !ACE_LACKS_NETDB_H */ + +#if defined (ACE_VXWORKS) && (ACE_VXWORKS < 0x620) +# include /**/ +#endif /* ACE_VXWORKS */ + +// Place all additions (especially function declarations) within extern "C" {} +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +#if defined (ACE_LACKS_HOSTENT) +struct hostent { + char *h_name; /* official name of host */ + char **h_aliases; /* alias list */ + int h_addrtype; /* host address type */ + int h_length; /* length of address */ + char **h_addr_list; /* list of addresses from name server */ +#define h_addr h_addr_list[0] /* address, for backward compatibility */ +}; +#endif /* ACE_LACKS_HOSTENT */ + +#if defined (ACE_LACKS_PROTOENT) +struct protoent { + char *p_name; /* official protocol name */ + char **p_aliases; /* alias list */ + int p_proto; /* protocol # */ +}; +#endif /* ACE_LACKS_PROTOENT */ + +#if defined (ACE_LACKS_SERVENT) +struct servent { + char *s_name; /* official service name */ + char **s_aliases; /* alias list */ + int s_port; /* port # */ + char *s_proto; /* protocol to use */ +}; +#endif /* ACE_LACKS_SERVENT */ + +#if defined (ACE_HAS_STRUCT_NETDB_DATA) + typedef char ACE_HOSTENT_DATA[sizeof(struct hostent_data)]; + typedef char ACE_SERVENT_DATA[sizeof(struct servent_data)]; + typedef char ACE_PROTOENT_DATA[sizeof(struct protoent_data)]; +#else +# if !defined ACE_HOSTENT_DATA_SIZE +# define ACE_HOSTENT_DATA_SIZE (4*1024) +# endif /*ACE_HOSTENT_DATA_SIZE */ +# if !defined ACE_SERVENT_DATA_SIZE +# define ACE_SERVENT_DATA_SIZE (4*1024) +# endif /*ACE_SERVENT_DATA_SIZE */ +# if !defined ACE_PROTOENT_DATA_SIZE +# define ACE_PROTOENT_DATA_SIZE (2*1024) +# endif /*ACE_PROTOENT_DATA_SIZE */ + typedef char ACE_HOSTENT_DATA[ACE_HOSTENT_DATA_SIZE]; + typedef char ACE_SERVENT_DATA[ACE_SERVENT_DATA_SIZE]; + typedef char ACE_PROTOENT_DATA[ACE_PROTOENT_DATA_SIZE]; +#endif /* ACE_HAS_STRUCT_NETDB_DATA */ + +# if !defined(MAXHOSTNAMELEN) +# define MAXHOSTNAMELEN HOST_NAME_MAX +# endif /* MAXHOSTNAMELEN */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#include /**/ "ace/post.h" +#endif /* ACE_OS_INCLUDE_OS_NETDB_H */ diff --git a/dep/ACE_wrappers/ace/os_include/os_nl_types.h b/dep/ACE_wrappers/ace/os_include/os_nl_types.h new file mode 100644 index 00000000000..e043f6ae6d3 --- /dev/null +++ b/dep/ACE_wrappers/ace/os_include/os_nl_types.h @@ -0,0 +1,42 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file os_nl_types.h + * + * data types + * + * $Id: os_nl_types.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Don Hinton + * @author This code was originally in various places including ace/OS.h. + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_OS_NL_TYPES_H +#define ACE_OS_INCLUDE_OS_NL_TYPES_H + +#include /**/ "ace/pre.h" + +#include /**/ "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#if !defined (ACE_LACKS_NL_TYPES_H) +# include /**/ +#endif /* !ACE_LACKS_nl_types_H */ + +// Place all additions (especially function declarations) within extern "C" {} +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#include /**/ "ace/post.h" +#endif /* ACE_OS_INCLUDE_OS_NL_TYPES_H */ diff --git a/dep/ACE_wrappers/ace/os_include/os_pdh.h b/dep/ACE_wrappers/ace/os_include/os_pdh.h new file mode 100644 index 00000000000..5c60c60d10e --- /dev/null +++ b/dep/ACE_wrappers/ace/os_include/os_pdh.h @@ -0,0 +1,45 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file os_pdh.h + * + * definitions for the windows pdh API + * + * $Id: os_pdh.h 81614 2008-05-05 14:04:25Z johnnyw $ + * + * @author Johnny Willemsen + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_OS_PDH_H +#define ACE_OS_INCLUDE_OS_PDH_H + +#include /**/ "ace/pre.h" + +#include /**/ "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#if defined (ACE_HAS_PDH_H) && !defined (ACE_LACKS_PDH_H) +# include /**/ +#endif /* ACE_HAS_PDH_H && !ACE_LACKS_PDH_H */ + +#if defined (ACE_HAS_PDH_H) && !defined (ACE_LACKS_PDH_H) +# define ACE_HAS_WIN32_PDH +#endif + +// Place all additions (especially function declarations) within extern "C" {} +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#include /**/ "ace/post.h" +#endif /* ACE_OS_INCLUDE_OS_PDH_H */ diff --git a/dep/ACE_wrappers/ace/os_include/os_pdhmsg.h b/dep/ACE_wrappers/ace/os_include/os_pdhmsg.h new file mode 100644 index 00000000000..2156236e07c --- /dev/null +++ b/dep/ACE_wrappers/ace/os_include/os_pdhmsg.h @@ -0,0 +1,41 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file os_pdhmsg.h + * + * definitions for the windows pdh API + * + * $Id: os_pdhmsg.h 81693 2008-05-14 12:35:01Z johnnyw $ + * + * @author Johnny Willemsen + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_OS_PDHMSG_H +#define ACE_OS_INCLUDE_OS_PDHMSG_H + +#include /**/ "ace/pre.h" + +#include /**/ "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#if defined (ACE_HAS_PDHMSG_H) && !defined (ACE_LACKS_PDHMSG_H) +# include /**/ +#endif /* ACE_HAS_PDH_H && !ACE_LACKS_PDH_H */ + +// Place all additions (especially function declarations) within extern "C" {} +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#include /**/ "ace/post.h" +#endif /* ACE_OS_INCLUDE_OS_PDHMSG_H */ diff --git a/dep/ACE_wrappers/ace/os_include/os_poll.h b/dep/ACE_wrappers/ace/os_include/os_poll.h new file mode 100644 index 00000000000..646c1bb853c --- /dev/null +++ b/dep/ACE_wrappers/ace/os_include/os_poll.h @@ -0,0 +1,42 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file os_poll.h + * + * definitions for the poll() function + * + * $Id: os_poll.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Don Hinton + * @author This code was originally in various places including ace/OS.h. + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_OS_POLL_H +#define ACE_OS_INCLUDE_OS_POLL_H + +#include /**/ "ace/pre.h" + +#include /**/ "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#if !defined (ACE_LACKS_POLL_H) +# include /**/ +#endif /* !ACE_LACKS_POLL_H */ + +// Place all additions (especially function declarations) within extern "C" {} +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#include /**/ "ace/post.h" +#endif /* ACE_OS_INCLUDE_OS_POLL_H */ diff --git a/dep/ACE_wrappers/ace/os_include/os_pthread.h b/dep/ACE_wrappers/ace/os_include/os_pthread.h new file mode 100644 index 00000000000..368f4254a34 --- /dev/null +++ b/dep/ACE_wrappers/ace/os_include/os_pthread.h @@ -0,0 +1,424 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file os_pthread.h + * + * threads + * + * $Id: os_pthread.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Don Hinton + * @author This code was originally in various places including ace/OS.h. + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_OS_PTHREAD_H +#define ACE_OS_INCLUDE_OS_PTHREAD_H + +#include /**/ "ace/pre.h" + +#include /**/ "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#if defined (ACE_HAS_PRIOCNTL) + // Need to #include thread.h before #defining THR_BOUND, etc., + // when building without threads on SunOS 5.x. +# if defined (sun) +# include /**/ +# endif /* sun */ + + // Need to #include these before #defining USYNC_PROCESS on SunOS 5.x. +# include /**/ +# include /**/ +#endif /* ACE_HAS_PRIOCNTL */ + +#include "ace/os_include/sys/os_types.h" + +// This needs to go here *first* to avoid problems with AIX. +# if defined (ACE_HAS_PTHREADS) +# define ACE_DONT_INCLUDE_ACE_SIGNAL_H +# include "ace/os_include/os_signal.h" +# undef ACE_DONT_INCLUDE_ACE_SIGNAL_H +# if defined (DIGITAL_UNIX) +# define pthread_self __pthread_self +extern "C" pthread_t pthread_self (void); +# endif /* DIGITAL_UNIX */ +# endif /* ACE_HAS_PTHREADS */ + + +#if !defined (ACE_LACKS_PTHREAD_H) + extern "C" { +# if defined (ACE_TANDEM_T1248_PTHREADS) +# include /**/ +# else +# include /**/ +# endif + } +#endif /* !ACE_LACKS_PTHREAD_H */ + +#if defined (ACE_HAS_PTHREAD_NP_H) +// FreeBSD declares _np (non-portable) pthread extensions in +# include /**/ +#endif + +// @todo: need to reoganize to put includes at the top and the rest of the +// code at the bottom. Also, move the classes out of this file. +#if defined (ACE_HAS_PTHREADS) +# define ACE_SCHED_OTHER SCHED_OTHER +# define ACE_SCHED_FIFO SCHED_FIFO +# define ACE_SCHED_RR SCHED_RR + +// Definitions for THREAD- and PROCESS-LEVEL priorities...some +// implementations define these while others don't. In order to +// further complicate matters, we don't redefine the default (*_DEF) +// values if they've already been defined, which allows individual +// programs to have their own ACE-wide "default". + +// PROCESS-level values +# if (defined (_POSIX_PRIORITY_SCHEDULING) || defined (ACE_TANDEM_T1248_PTHREADS)) \ + && !defined(_UNICOS) && !defined(UNIXWARE_7_1) +# define ACE_PROC_PRI_FIFO_MIN (sched_get_priority_min(SCHED_FIFO)) +# define ACE_PROC_PRI_RR_MIN (sched_get_priority_min(SCHED_RR)) +# if defined (HPUX) + // HP-UX's other is the SCHED_HPUX class, which uses historical + // values that have reverse semantics from POSIX (low value is + // more important priority). To use these in pthreads calls, + // the values need to be converted. The other scheduling classes + // don't need this special treatment. +# define ACE_PROC_PRI_OTHER_MIN \ + (sched_get_priority_min(SCHED_OTHER)) +# else +# define ACE_PROC_PRI_OTHER_MIN (sched_get_priority_min(SCHED_OTHER)) +# endif /* HPUX */ +# else /* UNICOS is missing a sched_get_priority_min() implementation, + SCO too */ +# define ACE_PROC_PRI_FIFO_MIN 0 +# define ACE_PROC_PRI_RR_MIN 0 +# define ACE_PROC_PRI_OTHER_MIN 0 +# endif + +# if defined (_POSIX_PRIORITY_SCHEDULING) && !defined(UNIXWARE_7_1) +# define ACE_PROC_PRI_FIFO_MAX (sched_get_priority_max(SCHED_FIFO)) +# define ACE_PROC_PRI_RR_MAX (sched_get_priority_max(SCHED_RR)) +# if defined (HPUX) +# define ACE_PROC_PRI_OTHER_MAX \ + (sched_get_priority_max(SCHED_OTHER)) +# else +# define ACE_PROC_PRI_OTHER_MAX (sched_get_priority_max(SCHED_OTHER)) +# endif /* HPUX */ +# else /* SCO missing sched_get_priority_max() implementation */ +# define ACE_PROC_PRI_FIFO_MAX 59 +# define ACE_PROC_PRI_RR_MAX 59 +# define ACE_PROC_PRI_OTHER_MAX 59 +# endif + +# if !defined(ACE_PROC_PRI_FIFO_DEF) +# define ACE_PROC_PRI_FIFO_DEF (ACE_PROC_PRI_FIFO_MIN + (ACE_PROC_PRI_FIFO_MAX - ACE_PROC_PRI_FIFO_MIN)/2) +# endif +# if !defined(ACE_PROC_PRI_RR_DEF) +# define ACE_PROC_PRI_RR_DEF (ACE_PROC_PRI_RR_MIN + (ACE_PROC_PRI_RR_MAX - ACE_PROC_PRI_RR_MIN)/2) +# endif +# if !defined(ACE_PROC_PRI_OTHER_DEF) +# define ACE_PROC_PRI_OTHER_DEF (ACE_PROC_PRI_OTHER_MIN + (ACE_PROC_PRI_OTHER_MAX - ACE_PROC_PRI_OTHER_MIN)/2) +# endif + +// THREAD-level values +# if defined(PRI_FIFO_MIN) && defined(PRI_FIFO_MAX) && defined(PRI_RR_MIN) && defined(PRI_RR_MAX) && defined(PRI_OTHER_MIN) && defined(PRI_OTHER_MAX) +# if !defined (ACE_THR_PRI_FIFO_MIN) +# define ACE_THR_PRI_FIFO_MIN (long) PRI_FIFO_MIN +# endif /* !ACE_THR_PRI_FIFO_MIN */ +# if !defined (ACE_THR_PRI_FIFO_MAX) +# define ACE_THR_PRI_FIFO_MAX (long) PRI_FIFO_MAX +# endif /* !ACE_THR_PRI_FIFO_MAX */ +# if !defined (ACE_THR_PRI_RR_MIN) +# define ACE_THR_PRI_RR_MIN (long) PRI_RR_MIN +# endif /* !ACE_THR_PRI_RR_MIN */ +# if !defined (ACE_THR_PRI_RR_MAX) +# define ACE_THR_PRI_RR_MAX (long) PRI_RR_MAX +# endif /* !ACE_THR_PRI_RR_MAX */ +# if !defined (ACE_THR_PRI_OTHER_MIN) +# define ACE_THR_PRI_OTHER_MIN (long) PRI_OTHER_MIN +# endif /* !ACE_THR_PRI_OTHER_MIN */ +# if !defined (ACE_THR_PRI_OTHER_MAX) +# define ACE_THR_PRI_OTHER_MAX (long) PRI_OTHER_MAX +# endif /* !ACE_THR_PRI_OTHER_MAX */ +# elif defined (AIX) + // AIX's priority range is 1 (low) to 127 (high). There aren't + // any preprocessor macros I can find. PRIORITY_MIN is for + // process priorities, as far as I can see, and does not apply + // to thread priority. The 1 to 127 range is from the + // pthread_attr_setschedparam man page (Steve Huston, 18-May-2001). +# if !defined (ACE_THR_PRI_FIFO_MIN) +# define ACE_THR_PRI_FIFO_MIN (long) 1 +# endif /* !ACE_THR_PRI_FIFO_MIN */ +# if !defined (ACE_THR_PRI_FIFO_MAX) +# define ACE_THR_PRI_FIFO_MAX (long) 127 +# endif /* !ACE_THR_PRI_FIFO_MAX */ +# if !defined (ACE_THR_PRI_RR_MIN) +# define ACE_THR_PRI_RR_MIN (long) 1 +# endif /* !ACE_THR_PRI_RR_MIN */ +# if !defined (ACE_THR_PRI_RR_MAX) +# define ACE_THR_PRI_RR_MAX (long) 127 +# endif /* !ACE_THR_PRI_RR_MAX */ +# if !defined (ACE_THR_PRI_OTHER_MIN) +# define ACE_THR_PRI_OTHER_MIN (long) 1 +# endif /* !ACE_THR_PRI_OTHER_MIN */ +# if !defined (ACE_THR_PRI_OTHER_MAX) +# define ACE_THR_PRI_OTHER_MAX (long) 127 +# endif /* !ACE_THR_PRI_OTHER_MAX */ +# elif defined (sun) +# if !defined (ACE_THR_PRI_FIFO_MIN) +# define ACE_THR_PRI_FIFO_MIN (long) 0 +# endif /* !ACE_THR_PRI_FIFO_MIN */ +# if !defined (ACE_THR_PRI_FIFO_MAX) +# define ACE_THR_PRI_FIFO_MAX (long) 59 +# endif /* !ACE_THR_PRI_FIFO_MAX */ +# if !defined (ACE_THR_PRI_RR_MIN) +# define ACE_THR_PRI_RR_MIN (long) 0 +# endif /* !ACE_THR_PRI_RR_MIN */ +# if !defined (ACE_THR_PRI_RR_MAX) +# define ACE_THR_PRI_RR_MAX (long) 59 +# endif /* !ACE_THR_PRI_RR_MAX */ +# if !defined (ACE_THR_PRI_OTHER_MIN) +# define ACE_THR_PRI_OTHER_MIN (long) 0 +# endif /* !ACE_THR_PRI_OTHER_MIN */ +# if !defined (ACE_THR_PRI_OTHER_MAX) +# define ACE_THR_PRI_OTHER_MAX (long) 127 +# endif /* !ACE_THR_PRI_OTHER_MAX */ +# else +# if !defined (ACE_THR_PRI_FIFO_MIN) +# define ACE_THR_PRI_FIFO_MIN (long) ACE_PROC_PRI_FIFO_MIN +# endif /* !ACE_THR_PRI_FIFO_MIN */ +# if !defined (ACE_THR_PRI_FIFO_MAX) +# define ACE_THR_PRI_FIFO_MAX (long) ACE_PROC_PRI_FIFO_MAX +# endif /* !ACE_THR_PRI_FIFO_MAX */ +# if !defined (ACE_THR_PRI_RR_MIN) +# define ACE_THR_PRI_RR_MIN (long) ACE_PROC_PRI_RR_MIN +# endif /* !ACE_THR_PRI_RR_MIN */ +# if !defined (ACE_THR_PRI_RR_MAX) +# define ACE_THR_PRI_RR_MAX (long) ACE_PROC_PRI_RR_MAX +# endif /* !ACE_THR_PRI_RR_MAX */ +# if !defined (ACE_THR_PRI_OTHER_MIN) +# define ACE_THR_PRI_OTHER_MIN (long) ACE_PROC_PRI_OTHER_MIN +# endif /* !ACE_THR_PRI_OTHER_MIN */ +# if !defined (ACE_THR_PRI_OTHER_MAX) +# define ACE_THR_PRI_OTHER_MAX (long) ACE_PROC_PRI_OTHER_MAX +# endif /* !ACE_THR_PRI_OTHER_MAX */ +# endif +# if !defined(ACE_THR_PRI_FIFO_DEF) +# define ACE_THR_PRI_FIFO_DEF ((ACE_THR_PRI_FIFO_MIN + ACE_THR_PRI_FIFO_MAX)/2) +# endif +# if !defined(ACE_THR_PRI_RR_DEF) +# define ACE_THR_PRI_RR_DEF ((ACE_THR_PRI_RR_MIN + ACE_THR_PRI_RR_MAX)/2) +# endif +# if !defined(ACE_THR_PRI_OTHER_DEF) +# define ACE_THR_PRI_OTHER_DEF ((ACE_THR_PRI_OTHER_MIN + ACE_THR_PRI_OTHER_MAX)/2) +# endif + // Typedefs to help compatibility with Windows NT and Pthreads. + typedef pthread_t ACE_hthread_t; + typedef pthread_t ACE_thread_t; + + // native TSS key type + typedef pthread_key_t ACE_OS_thread_key_t; + // TSS key type to be used by application +# if defined (ACE_HAS_TSS_EMULATION) + typedef u_int ACE_thread_key_t; +# else /* ! ACE_HAS_TSS_EMULATION */ + typedef ACE_OS_thread_key_t ACE_thread_key_t; +# endif /* ! ACE_HAS_TSS_EMULATION */ + +# if !defined (ACE_LACKS_COND_T) + typedef pthread_mutex_t ACE_mutex_t; + typedef pthread_cond_t ACE_cond_t; + typedef pthread_condattr_t ACE_condattr_t; + typedef pthread_mutexattr_t ACE_mutexattr_t; +# endif /* ! ACE_LACKS_COND_T */ + typedef pthread_mutex_t ACE_thread_mutex_t; + +# if !defined (PTHREAD_CANCEL_DISABLE) +# define PTHREAD_CANCEL_DISABLE 0 +# endif /* PTHREAD_CANCEL_DISABLE */ + +# if !defined (PTHREAD_CANCEL_ENABLE) +# define PTHREAD_CANCEL_ENABLE 0 +# endif /* PTHREAD_CANCEL_ENABLE */ + +# if !defined (PTHREAD_CANCEL_DEFERRED) +# define PTHREAD_CANCEL_DEFERRED 0 +# endif /* PTHREAD_CANCEL_DEFERRED */ + +# if !defined (PTHREAD_CANCEL_ASYNCHRONOUS) +# define PTHREAD_CANCEL_ASYNCHRONOUS 0 +# endif /* PTHREAD_CANCEL_ASYNCHRONOUS */ + +# define THR_CANCEL_DISABLE PTHREAD_CANCEL_DISABLE +# define THR_CANCEL_ENABLE PTHREAD_CANCEL_ENABLE +# define THR_CANCEL_DEFERRED PTHREAD_CANCEL_DEFERRED +# define THR_CANCEL_ASYNCHRONOUS PTHREAD_CANCEL_ASYNCHRONOUS + +# if !defined (PTHREAD_CREATE_JOINABLE) +# if defined (PTHREAD_CREATE_UNDETACHED) +# define PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED +# else +# define PTHREAD_CREATE_JOINABLE 0 +# endif /* PTHREAD_CREATE_UNDETACHED */ +# endif /* PTHREAD_CREATE_JOINABLE */ + +# if !defined (PTHREAD_CREATE_DETACHED) +# define PTHREAD_CREATE_DETACHED 1 +# endif /* PTHREAD_CREATE_DETACHED */ + +# if !defined (PTHREAD_PROCESS_PRIVATE) && !defined (ACE_HAS_PTHREAD_PROCESS_ENUM) +# if defined (PTHREAD_MUTEXTYPE_FAST) +# define PTHREAD_PROCESS_PRIVATE PTHREAD_MUTEXTYPE_FAST +# else +# define PTHREAD_PROCESS_PRIVATE 0 +# endif /* PTHREAD_MUTEXTYPE_FAST */ +# endif /* PTHREAD_PROCESS_PRIVATE */ + +# if !defined (PTHREAD_PROCESS_SHARED) && !defined (ACE_HAS_PTHREAD_PROCESS_ENUM) +# if defined (PTHREAD_MUTEXTYPE_FAST) +# define PTHREAD_PROCESS_SHARED PTHREAD_MUTEXTYPE_FAST +# else +# define PTHREAD_PROCESS_SHARED 1 +# endif /* PTHREAD_MUTEXTYPE_FAST */ +# endif /* PTHREAD_PROCESS_SHARED */ + +# if !defined (ACE_HAS_STHREADS) +# if !defined (USYNC_THREAD) +# define USYNC_THREAD PTHREAD_PROCESS_PRIVATE +# endif /* ! USYNC_THREAD */ +# if !defined (USYNC_PROCESS) +# define USYNC_PROCESS PTHREAD_PROCESS_SHARED +# endif /* ! USYNC_PROCESS */ +# endif /* ACE_HAS_STHREADS */ + + /* MM-Graz: prevent warnings */ +# if !defined (UNIXWARE_7_1) +# undef THR_BOUND +# undef THR_NEW_LWP +# undef THR_DETACHED +# undef THR_SUSPENDED +# undef THR_DAEMON + +# define THR_BOUND 0x00000001 +# define THR_NEW_LWP 0x00000002 +# define THR_DETACHED 0x00000040 +# define THR_SUSPENDED 0x00000080 +# define THR_DAEMON 0x00000100 +# define THR_SCHED_FIFO 0x00020000 +# define THR_SCHED_RR 0x00040000 +# define THR_SCHED_DEFAULT 0x00080000 +# endif /* UNIXWARE_7_1 */ + +# define THR_JOINABLE 0x00010000 + +# if defined (ACE_HAS_IRIX62_THREADS) +# define THR_SCOPE_SYSTEM 0x00100000 +# else +# define THR_SCOPE_SYSTEM THR_BOUND +# endif /*ACE_HAS_IRIX62_THREADS*/ + +# define THR_SCOPE_PROCESS 0x00200000 +# define THR_INHERIT_SCHED 0x00400000 +# define THR_EXPLICIT_SCHED 0x00800000 +# define THR_SCHED_IO 0x01000000 + +# if !defined (ACE_HAS_STHREADS) +# if !defined (ACE_HAS_POSIX_SEM) && !defined (ACE_USES_FIFO_SEM) + +// This needs to be moved out of here. +#include /**/ "ace/ACE_export.h" +/** + * @class ACE_sema_t + * + * @brief This is used to implement semaphores for platforms that support + * POSIX pthreads, but do *not* support POSIX semaphores, i.e., + * it's a different type than the POSIX . + */ +class ACE_Export ACE_sema_t +{ +public: + /// Serialize access to internal state. + ACE_mutex_t lock_; + + /// Block until there are no waiters. + ACE_cond_t count_nonzero_; + + /// Count of the semaphore. + u_long count_; + + /// Number of threads that have called . + u_long waiters_; +}; +# endif /* !ACE_HAS_POSIX_SEM */ + +# if defined (ACE_LACKS_PTHREAD_YIELD) && defined (ACE_HAS_THR_YIELD) + // If we are on Solaris we can just reuse the existing + // implementations of these synchronization types. +# if !defined (ACE_LACKS_RWLOCK_T) && !defined (ACE_HAS_PTHREADS_UNIX98_EXT) +# include /**/ + typedef rwlock_t ACE_rwlock_t; +# endif /* !ACE_LACKS_RWLOCK_T */ +# include /**/ +# endif /* (ACE_LACKS_PTHREAD_YIELD) && defined (ACE_HAS_THR_YIELD) */ + +# else +# if !defined (ACE_HAS_POSIX_SEM) + typedef sema_t ACE_sema_t; +# endif /* !ACE_HAS_POSIX_SEM */ +# endif /* !ACE_HAS_STHREADS */ + +# if defined (ACE_HAS_PTHREADS_UNIX98_EXT) + typedef pthread_rwlock_t ACE_rwlock_t; +# endif /* ACE_HAS_PTHREADS_UNIX98_EXT */ + +# if defined (__GLIBC__) && ((__GLIBC__ > 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2)) + + // glibc 2.2.x or better has pthread_mutex_timedlock() +# ifndef ACE_HAS_MUTEX_TIMEOUTS +# define ACE_HAS_MUTEX_TIMEOUTS +# endif /* ACE_HAS_MUTEX_TIMEOUTS */ + + // Use new pthread_attr_setstack if XPG6 support is enabled. +# if defined (_XOPEN_SOURCE) && (_XOPEN_SOURCE - 0) < 600 +# define ACE_LACKS_PTHREAD_ATTR_SETSTACK +# endif /* (_XOPEN_SOURCE - 0) < 600 */ + +# if !defined (_XOPEN_SOURCE) \ + || (defined (_XOPEN_SOURCE) && (_XOPEN_SOURCE - 0) < 600) + // pthread_mutex_timedlock() prototype is not visible if _XOPEN_SOURCE + // is not >= 600 (i.e. for XPG6). + extern "C" int pthread_mutex_timedlock (pthread_mutex_t *mutex, + const struct timespec * abstime); +# endif /* _XOPEN_SOURCE && _XOPEN_SOURCE < 600 */ + +# endif /* linux && ((__GLIBC__ > 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2)) */ + +#elif defined (ACE_HAS_STHREADS) +# if !defined (ACE_THR_PRI_FIFO_MIN) +# define ACE_THR_PRI_FIFO_MIN (long) 0 +# endif /* !ACE_THR_PRI_FIFO_MIN */ +# if !defined (ACE_THR_PRI_FIFO_MAX) +# define ACE_THR_PRI_FIFO_MAX (long) 59 +# endif /* !ACE_THR_PRI_FIFO_MAX */ +# if !defined (ACE_THR_PRI_RR_MIN) +# define ACE_THR_PRI_RR_MIN (long) 0 +# endif /* !ACE_THR_PRI_RR_MIN */ +# if !defined (ACE_THR_PRI_RR_MAX) +# define ACE_THR_PRI_RR_MAX (long) 59 +# endif /* !ACE_THR_PRI_RR_MAX */ +# if !defined (ACE_THR_PRI_OTHER_MIN) +# define ACE_THR_PRI_OTHER_MIN (long) 0 +# endif /* !ACE_THR_PRI_OTHER_MIN */ +# if !defined (ACE_THR_PRI_OTHER_MAX) +# define ACE_THR_PRI_OTHER_MAX (long) 127 +# endif /* !ACE_THR_PRI_OTHER_MAX */ +#endif /* ACE_HAS_PTHREADS */ + +#include /**/ "ace/post.h" +#endif /* ACE_OS_INCLUDE_OS_PTHREAD_H */ diff --git a/dep/ACE_wrappers/ace/os_include/os_pwd.h b/dep/ACE_wrappers/ace/os_include/os_pwd.h new file mode 100644 index 00000000000..b1bc94af381 --- /dev/null +++ b/dep/ACE_wrappers/ace/os_include/os_pwd.h @@ -0,0 +1,58 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file os_pwd.h + * + * password structure + * + * $Id: os_pwd.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Don Hinton + * @author This code was originally in various places including ace/OS.h. + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_OS_PWD_H +#define ACE_OS_INCLUDE_OS_PWD_H + +#include /**/ "ace/pre.h" + +#include /**/ "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/os_include/sys/os_types.h" + +#if !defined (ACE_LACKS_PWD_H) +# include /**/ +#endif /* !ACE_LACKS_PWD_H */ + +// Place all additions (especially function declarations) within extern "C" {} +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +#if !defined (ACE_WIN32) +// VAC++ doesn't correctly grok the ::getpwnam_r - the function is redefined +// in pwd.h, and that redefinition is used here +# if defined (_AIX) && defined (__IBMCPP__) && (__IBMCPP__ >= 400) + extern int _posix_getpwnam_r(const char *, struct passwd *, char *, + int, struct passwd **); +# endif /* AIX and VAC++ 4 */ +#endif /* !ACE_WIN32 */ + +#if defined (DIGITAL_UNIX) + extern int _Pgetpwnam_r (const char *, struct passwd *, + char *, size_t, struct passwd **); +#endif /* DIGITAL_UNIX */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#include /**/ "ace/post.h" +#endif /* ACE_OS_INCLUDE_OS_PWD_H */ diff --git a/dep/ACE_wrappers/ace/os_include/os_regex.h b/dep/ACE_wrappers/ace/os_include/os_regex.h new file mode 100644 index 00000000000..1c856da26f0 --- /dev/null +++ b/dep/ACE_wrappers/ace/os_include/os_regex.h @@ -0,0 +1,48 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file os_regex.h + * + * regular expression matching types + * + * $Id: os_regex.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Don Hinton + * @author This code was originally in various places including ace/OS.h. + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_OS_REGEX_H +#define ACE_OS_INCLUDE_OS_REGEX_H + +#include /**/ "ace/pre.h" + +#include /**/ "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/os_include/sys/os_types.h" + +#if !defined (ACE_LACKS_REGEX_H) +# include /**/ +#endif /* !ACE_LACKS_REGEX_H */ + +#if defined (ACE_HAS_REGEX) +# include /**/ +#endif /* ACE_HAS_REGEX */ + +// Place all additions (especially function declarations) within extern "C" {} +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#include /**/ "ace/post.h" +#endif /* ACE_OS_INCLUDE_OS_REGEX_H */ diff --git a/dep/ACE_wrappers/ace/os_include/os_sched.h b/dep/ACE_wrappers/ace/os_include/os_sched.h new file mode 100644 index 00000000000..a80b454df0a --- /dev/null +++ b/dep/ACE_wrappers/ace/os_include/os_sched.h @@ -0,0 +1,52 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file os_sched.h + * + * execution scheduling (REALTIME) + * + * $Id: os_sched.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Don Hinton + * @author This code was originally in various places including ace/OS.h. + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_OS_SCHED_H +#define ACE_OS_INCLUDE_OS_SCHED_H + +#include /**/ "ace/pre.h" + +#include /**/ "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/os_include/os_time.h" + +#if !defined (ACE_LACKS_SCHED_H) +# include /**/ +#endif /* !ACE_LACKS_SCHED_H */ + +// Place all additions (especially function declarations) within extern "C" {} +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +#if !defined (__cpu_set_t_defined) || !defined (ACE_HAS_CPU_SET_T) +# define ACE_CPU_SETSIZE 1024 + typedef struct + { + ACE_UINT32 bit_array_[ACE_CPU_SETSIZE / (8 * sizeof (ACE_UINT32))]; + } cpu_set_t; +#endif /* !ACE_HAS_CPU_SET_T || !__cpu_set_t_defined */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#include /**/ "ace/post.h" +#endif /* ACE_OS_INCLUDE_OS_SCHED_H */ diff --git a/dep/ACE_wrappers/ace/os_include/os_search.h b/dep/ACE_wrappers/ace/os_include/os_search.h new file mode 100644 index 00000000000..605fd365c09 --- /dev/null +++ b/dep/ACE_wrappers/ace/os_include/os_search.h @@ -0,0 +1,44 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file os_search.h + * + * search tables + * + * $Id: os_search.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Don Hinton + * @author This code was originally in various places including ace/OS.h. + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_OS_SEARCH_H +#define ACE_OS_INCLUDE_OS_SEARCH_H + +#include /**/ "ace/pre.h" + +#include /**/ "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/os_include/sys/os_types.h" + +#if !defined (ACE_LACKS_SEARCH_H) +# include /**/ +#endif /* !ACE_LACKS_SEARCH_H */ + +// Place all additions (especially function declarations) within extern "C" {} +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#include /**/ "ace/post.h" +#endif /* ACE_OS_INCLUDE_OS_SEARCH_H */ diff --git a/dep/ACE_wrappers/ace/os_include/os_semaphore.h b/dep/ACE_wrappers/ace/os_include/os_semaphore.h new file mode 100644 index 00000000000..7fad7dafb4e --- /dev/null +++ b/dep/ACE_wrappers/ace/os_include/os_semaphore.h @@ -0,0 +1,77 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file os_semaphore.h + * + * semaphores (REALTIME) + * + * $Id: os_semaphore.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Don Hinton + * @author This code was originally in various places including ace/OS.h. + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_OS_SEMAPHORE_H +#define ACE_OS_INCLUDE_OS_SEMAPHORE_H + +#include /**/ "ace/pre.h" + +#include /**/ "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/os_include/os_time.h" + +#if !defined (ACE_LACKS_SEMAPHORE_H) +# include /**/ +#endif /* !ACE_LACKS_SEMAPHORE_H */ + +// Place all additions (especially function declarations) within extern "C" {} +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +#if defined (ACE_HAS_POSIX_SEM) +# if !defined (SEM_FAILED) && !defined (ACE_LACKS_NAMED_POSIX_SEM) +# define SEM_FAILED ((sem_t *) -1) +# endif /* !SEM_FAILED */ + + typedef struct + { + /// Pointer to semaphore handle. This is allocated by ACE if we are + /// working with an unnamed POSIX semaphore or by the OS if we are + /// working with a named POSIX semaphore. + sem_t *sema_; + + /// Name of the semaphore (if this is non-NULL then this is a named + /// POSIX semaphore, else its an unnamed POSIX semaphore). + char *name_; + +# if defined (ACE_LACKS_NAMED_POSIX_SEM) + /// this->sema_ doesn't always get created dynamically if a platform + /// doesn't support named posix semaphores. We use this flag to + /// remember if we need to delete or not. + bool new_sema_; +# endif /* ACE_LACKS_NAMED_POSIX_SEM */ + +# if !defined (ACE_HAS_POSIX_SEM_TIMEOUT) && !defined (ACE_DISABLE_POSIX_SEM_TIMEOUT_EMULATION) + /// Serialize access to internal state. + ACE_mutex_t lock_; + + /// Block until there are no waiters. + ACE_cond_t count_nonzero_; +# endif /* !ACE_HAS_POSIX_SEM_TIMEOUT && !ACE_DISABLE_POSIX_SEM_TIMEOUT_EMULATION */ + } ACE_sema_t; +#endif /* ACE_HAS_POSIX_SEM */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#include /**/ "ace/post.h" +#endif /* ACE_OS_INCLUDE_OS_SEMAPHORE_H */ diff --git a/dep/ACE_wrappers/ace/os_include/os_setjmp.h b/dep/ACE_wrappers/ace/os_include/os_setjmp.h new file mode 100644 index 00000000000..2ab4a18a9f9 --- /dev/null +++ b/dep/ACE_wrappers/ace/os_include/os_setjmp.h @@ -0,0 +1,42 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file os_setjmp.h + * + * stack environment declarations + * + * $Id: os_setjmp.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Don Hinton + * @author This code was originally in various places including ace/OS.h. + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_OS_SETJMP_H +#define ACE_OS_INCLUDE_OS_SETJMP_H + +#include /**/ "ace/pre.h" + +#include /**/ "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#if !defined (ACE_LACKS_SETJMP_H) +# include /**/ +#endif /* !ACE_LACKS_SETJMP_H */ + +// Place all additions (especially function declarations) within extern "C" {} +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#include /**/ "ace/post.h" +#endif /* ACE_OS_INCLUDE_OS_SETJMP_H */ diff --git a/dep/ACE_wrappers/ace/os_include/os_signal.h b/dep/ACE_wrappers/ace/os_include/os_signal.h new file mode 100644 index 00000000000..fdfd21e99ba --- /dev/null +++ b/dep/ACE_wrappers/ace/os_include/os_signal.h @@ -0,0 +1,253 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file os_signal.h + * + * signals + * + * $Id: os_signal.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Don Hinton + * @author This code was originally in various places including ace/OS.h. + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_OS_SIGNAL_H +#define ACE_OS_INCLUDE_OS_SIGNAL_H + +#include /**/ "ace/pre.h" + +#include "ace/config-lite.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/os_include/sys/os_types.h" + +#if !defined (ACE_LACKS_SIGNAL_H) + extern "C" { +# include /**/ + } +#endif /* !ACE_LACKS_SIGNAL_H */ + +// This must come after signal.h is #included. +#if defined (SCO) +# define SIGIO SIGPOLL +# include /**/ +#endif /* SCO */ + +#if defined (ACE_HAS_SIGINFO_T) +# if !defined (ACE_LACKS_SIGINFO_H) +# if defined (__QNX__) || defined (__OpenBSD__) || defined (__INTERIX) +# include /**/ +# else /* __QNX__ || __OpenBSD__ */ +# include /**/ +# endif /* __QNX__ || __OpenBSD__ */ +# endif /* ACE_LACKS_SIGINFO_H */ +#endif /* ACE_HAS_SIGINFO_T */ + +#if defined (ACE_VXWORKS) && (ACE_VXWORKS < 0x620) && !defined (__RTP__) +# include /**/ +#endif /* ACE_VXWORKS */ + +// Place all additions (especially function declarations) within extern "C" {} +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +#if defined (ACE_LACKS_SIGSET) + typedef u_int sigset_t; +#endif /* ACE_LACKS_SIGSET */ + +#if defined (ACE_HAS_SIG_MACROS) +# undef sigemptyset +# undef sigfillset +# undef sigaddset +# undef sigdelset +# undef sigismember +#endif /* ACE_HAS_SIG_MACROS */ + +// This must come after signal.h is #included. It's to counteract +// the sigemptyset and sigfillset #defines, which only happen +// when __OPTIMIZE__ is #defined (really!) on Linux. +#if defined (linux) && defined (__OPTIMIZE__) +# undef sigemptyset +# undef sigfillset +#endif /* linux && __OPTIMIZE__ */ + +#if !defined (ACE_HAS_SIG_ATOMIC_T) + typedef int sig_atomic_t; +#endif /* !ACE_HAS_SIG_ATOMIC_T */ + +# if !defined (SA_SIGINFO) +# define SA_SIGINFO 0 +# endif /* SA_SIGINFO */ + +# if !defined (SA_RESTART) +# define SA_RESTART 0 +# endif /* SA_RESTART */ + +#if !defined (SIGHUP) +# define SIGHUP 0 +#endif /* SIGHUP */ + +#if !defined (SIGINT) +# define SIGINT 0 +#endif /* SIGINT */ + +#if !defined (SIGSEGV) +# define SIGSEGV 0 +#endif /* SIGSEGV */ + +#if !defined (SIGIO) +# define SIGIO 0 +#endif /* SIGSEGV */ + +#if !defined (SIGUSR1) +# define SIGUSR1 0 +#endif /* SIGUSR1 */ + +#if !defined (SIGUSR2) +# define SIGUSR2 0 +#endif /* SIGUSR2 */ + +#if !defined (SIGCHLD) +# define SIGCHLD 0 +#endif /* SIGCHLD */ + +#if !defined (SIGCLD) +# define SIGCLD SIGCHLD +#endif /* SIGCLD */ + +#if !defined (SIGQUIT) +# define SIGQUIT 0 +#endif /* SIGQUIT */ + +#if !defined (SIGPIPE) +# define SIGPIPE 0 +#endif /* SIGPIPE */ + +#if !defined (SIGALRM) +# define SIGALRM 0 +#endif /* SIGALRM */ + +#if !defined (SIG_DFL) +# define SIG_DFL ((__sighandler_t) 0) +#endif /* SIG_DFL */ + +#if !defined (SIG_IGN) +# define SIG_IGN ((__sighandler_t) 1) /* ignore signal */ +#endif /* SIG_IGN */ + +#if !defined (SIG_ERR) +# define SIG_ERR ((__sighandler_t) -1) /* error return from signal */ +#endif /* SIG_ERR */ + +// These are used by the and +// methods. They must be unique and cannot +// conflict with the value of . We make the numbers +// negative here so they won't conflict with other values like SIGIO, +// etc. +# define ACE_SIGIO -1 +# define ACE_SIGURG -2 +# define ACE_CLOEXEC -3 + +#if defined (ACE_VXWORKS) +# define ACE_NSIG (_NSIGS + 1) +#elif defined (__Lynx__) || defined (ACE_HAS_RTEMS) +# define ACE_NSIG (NSIG + 1) +#else + // All other platforms set NSIG to one greater than the + // highest-numbered signal. +# define ACE_NSIG NSIG +#endif /* __Lynx__ */ + +#if defined (ACE_HAS_CONSISTENT_SIGNAL_PROTOTYPES) + // Prototypes for both signal() and struct sigaction are consistent.. + typedef void (*ACE_SignalHandler)(int); + typedef void (*ACE_SignalHandlerV)(int); +#elif defined (ACE_HAS_LYNXOS_SIGNALS) || defined (ACE_HAS_TANDEM_SIGNALS) + typedef void (*ACE_SignalHandler)(...); + typedef void (*ACE_SignalHandlerV)(...); +#elif defined (ACE_HAS_SVR4_SIGNAL_T) + // SVR4 Signals are inconsistent (e.g., see struct sigaction).. + typedef void (*ACE_SignalHandler)(int); + typedef void (*ACE_SignalHandlerV)(void); +#elif defined (ACE_WIN32) + typedef void (__cdecl *ACE_SignalHandler)(int); + typedef void (__cdecl *ACE_SignalHandlerV)(int); +#elif defined (ACE_HAS_UNIXWARE_SVR4_SIGNAL_T) + typedef void (*ACE_SignalHandler)(int); + typedef void (*ACE_SignalHandlerV)(...); +#elif defined (INTEGRITY) + typedef void (*ACE_SignalHandler)(); + typedef void (*ACE_SignalHandlerV)(int); +#elif defined (ACE_HAS_RTEMS) + typedef void (*ACE_SignalHandler)(); + typedef void (*ACE_SignalHandlerV)(); +#else /* This is necessary for some older broken version of cfront */ +# if defined (SIG_PF) +# define ACE_SignalHandler SIG_PF +# else + typedef void (*ACE_SignalHandler)(int); +# endif /* SIG_PF */ + typedef void (*ACE_SignalHandlerV)(...); +#endif /* ACE_HAS_CONSISTENT_SIGNAL_PROTOTYPES */ + +#if defined (ACE_LACKS_SIGACTION) + struct sigaction + { + int sa_flags; + ACE_SignalHandlerV sa_handler; + sigset_t sa_mask; + }; +#endif /* ACE_LACKS_SIGACTION */ + +// Defining POSIX4 real-time signal range. +#if defined(ACE_HAS_POSIX_REALTIME_SIGNALS) +# define ACE_SIGRTMIN SIGRTMIN +# define ACE_SIGRTMAX SIGRTMAX +#else /* !ACE_HAS_POSIX_REALTIME_SIGNALS */ +# ifndef ACE_SIGRTMIN +# define ACE_SIGRTMIN 0 +# endif /* ACE_SIGRTMIN */ +# ifndef ACE_SIGRTMAX +# define ACE_SIGRTMAX 0 +# endif /* ACE_SIGRTMAX */ +#endif /* ACE_HAS_POSIX_REALTIME_SIGNALS */ + +#if defined (DIGITAL_UNIX) + // sigwait is yet another macro on Digital UNIX 4.0, just causing + // trouble when introducing member functions with the same name. + // Thanks to Thilo Kielmann" for + // this fix. +# if defined (__DECCXX_VER) +# undef sigwait + // cxx on Digital Unix 4.0 needs this declaration. With it, + // <::_Psigwait> works with cxx -pthread. g++ does _not_ need + // it. + int _Psigwait __((const sigset_t *set, int *sig)); +# endif /* __DECCXX_VER */ +#elif !defined (ACE_HAS_SIGWAIT) +# if defined(ACE_HAS_RTEMS) + int sigwait (const sigset_t *set, int *sig); +# else + int sigwait (sigset_t *set); +# endif /* ACE_HAS_RTEMS */ +#endif /* ! DIGITAL_UNIX && ! ACE_HAS_SIGWAIT */ + +#if !defined (ACE_HAS_PTHREAD_SIGMASK_PROTOTYPE) + int pthread_sigmask(int, const sigset_t *, sigset_t *); +#endif /*!ACE_HAS_PTHREAD_SIGMASK_PROTOTYPE */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#include "ace/os_include/os_ucontext.h" + +#include /**/ "ace/post.h" +#endif /* ACE_OS_INCLUDE_OS_SIGNAL_H */ diff --git a/dep/ACE_wrappers/ace/os_include/os_spawn.h b/dep/ACE_wrappers/ace/os_include/os_spawn.h new file mode 100644 index 00000000000..0f825640ff9 --- /dev/null +++ b/dep/ACE_wrappers/ace/os_include/os_spawn.h @@ -0,0 +1,46 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file os_spawn.h + * + * spawn (ADVANCED REALTIME) + * + * $Id: os_spawn.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Don Hinton + * @author This code was originally in various places including ace/OS.h. + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_OS_SPAWN_H +#define ACE_OS_INCLUDE_OS_SPAWN_H + +#include /**/ "ace/pre.h" + +#include /**/ "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/os_include/os_signal.h" +#include "ace/os_include/sys/os_types.h" +#include "ace/os_include/os_sched.h" + +#if !defined (ACE_LACKS_SPAWN_H) +# include /**/ +#endif /* !ACE_LACKS_SPAWN_H */ + +// Place all additions (especially function declarations) within extern "C" {} +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#include /**/ "ace/post.h" +#endif /* ACE_OS_INCLUDE_OS_SPAWN_H */ diff --git a/dep/ACE_wrappers/ace/os_include/os_stdarg.h b/dep/ACE_wrappers/ace/os_include/os_stdarg.h new file mode 100644 index 00000000000..0e9d234b55e --- /dev/null +++ b/dep/ACE_wrappers/ace/os_include/os_stdarg.h @@ -0,0 +1,50 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file os_stdarg.h + * + * handle variable argument list + * + * $Id: os_stdarg.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Don Hinton + * @author This code was originally in various places including ace/OS.h. + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_OS_STDARG_H +#define ACE_OS_INCLUDE_OS_STDARG_H + +#include /**/ "ace/pre.h" + +#include "ace/config-lite.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#if !defined (ACE_LACKS_STDARG_H) +# include /**/ +#endif /* !ACE_LACKS_STDARG_H */ + +#if !defined (va_copy) +#if defined (__va_copy) +#define va_copy(d, s) __va_copy((d),(s)) +#else +#define va_copy(d, s) memcpy((void *)&(d),(void *)&(s),sizeof(va_list)) +#endif +#endif + +// Place all additions (especially function declarations) within extern "C" {} +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#include /**/ "ace/post.h" +#endif /* ACE_OS_INCLUDE_OS_STDARG_H */ diff --git a/dep/ACE_wrappers/ace/os_include/os_stdbool.h b/dep/ACE_wrappers/ace/os_include/os_stdbool.h new file mode 100644 index 00000000000..ddb3f8e0ddb --- /dev/null +++ b/dep/ACE_wrappers/ace/os_include/os_stdbool.h @@ -0,0 +1,42 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file os_stdbool.h + * + * boolean type and values + * + * $Id: os_stdbool.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Don Hinton + * @author This code was originally in various places including ace/OS.h. + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_OS_STDBOOL_H +#define ACE_OS_INCLUDE_OS_STDBOOL_H + +#include /**/ "ace/pre.h" + +#include /**/ "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#if !defined (ACE_LACKS_STDBOOL_H) +# include /**/ +#endif /* !ACE_LACKS_STDBOOL_H */ + +// Place all additions (especially function declarations) within extern "C" {} +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#include /**/ "ace/post.h" +#endif /* ACE_OS_INCLUDE_OS_STDBOOL_H */ diff --git a/dep/ACE_wrappers/ace/os_include/os_stddef.h b/dep/ACE_wrappers/ace/os_include/os_stddef.h new file mode 100644 index 00000000000..b842ffe80ab --- /dev/null +++ b/dep/ACE_wrappers/ace/os_include/os_stddef.h @@ -0,0 +1,97 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file os_stddef.h + * + * standard type definitions + * + * $Id: os_stddef.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Don Hinton + * @author This code was originally in various places including ace/OS.h. + */ +//============================================================================= + +// From http://www.UNIX-systems.org/single_unix_specification/ + +#ifndef ACE_OS_INCLUDE_OS_STDDEF_H +#define ACE_OS_INCLUDE_OS_STDDEF_H + +#include /**/ "ace/pre.h" + +#include "ace/config-lite.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#if !defined (ACE_LACKS_STDDEF_H) +# include /**/ +#endif /* !ACE_LACKS_STDDEF_H */ + +// Place all additions (especially function declarations) within extern "C" {} +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +//FUZZ: disable check_for_NULL +// NULL pointer constant +#if defined (ACE_LACKS_NULL) +# undef NULL +# if defined(__cplusplus) +# define NULL 0 +# else +# define NULL ((void *)0) +# endif +#endif /* ACE_LACKS_NULL */ +//FUZZ: enable check_for_NULL + +/* + Integer constant expression of type size_t, the value of which is the offset + in bytes to the structure member (member-designator), from the beginning of + its structure (type). +*/ +#if defined (ACE_LACKS_OFFSETOF) +# undef offsetof +# define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) +#endif /* ACE_LACKS_OFFSETOF */ + +// Signed integer type of the result of subtracting two pointers. +#if defined (ACE_LACKS_PTRDIFF_T) +# if !defined (ACE_PTRDIFF_T_TYPE) +# define ACE_PTRDIFF_T_TYPE unsigned long +# endif /* !ACE_PTRDIFF_T_TYPE */ + typedef ACE_PTRDIFF_T_TYPE ptrdiff_t; +#endif /* ACE_LACKS_PTRDIFF_T */ + +/* + Integer type whose range of values can represent distinct wide-character + codes for all members of the largest character set specified among the + locales supported by the compilation environment: the null character has + the code value 0 and each member of the portable character set has a code + value equal to its value when used as the lone character in an integer + character constant. +*/ +#if defined (ACE_LACKS_WCHAR_T) +# if !defined (ACE_WCHAR_T_TYPE) +# define ACE_WCHAR_T_TYPE long; +# endif /* !ACE_WCHAR_T_TYPE */ + typedef ACE_WCHAR_T_TYPE wchar_t; +#endif /* ACE_LACKS_WCHAR_T */ + +// Unsigned integer type of the result of the sizeof operator. +#if defined (ACE_LACKS_SIZE_T) +# if !defined (ACE_SIZE_T_TYPE) +# define ACE_SIZE_T_TYPE unsigned int; +# endif /* !ACE_SIZE_T_TYPE */ + typedef ACE_SIZE_T_TYPE size_t; +#endif /* ACE_LACKS_SIZE_T */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#include /**/ "ace/post.h" +#endif /* ACE_OS_INCLUDE_OS_STDDEF_H */ diff --git a/dep/ACE_wrappers/ace/os_include/os_stdint.h b/dep/ACE_wrappers/ace/os_include/os_stdint.h new file mode 100644 index 00000000000..ac6fec664c5 --- /dev/null +++ b/dep/ACE_wrappers/ace/os_include/os_stdint.h @@ -0,0 +1,141 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file os_stdint.h + * + * integer types + * + * $Id: os_stdint.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Don Hinton + * @author This code was originally in various places including ace/OS.h. + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_OS_STDINT_H +#define ACE_OS_INCLUDE_OS_STDINT_H + +#include /**/ "ace/pre.h" + +#include "ace/config-lite.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#if !defined (ACE_LACKS_STDINT_H) +# include /**/ +#endif /* !ACE_LACKS_STDINT_H */ + +// Place all additions (especially function declarations) within extern "C" {} +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +// BSD style types +#if defined (ACE_LACKS_SYS_TYPES_H) \ + || (defined (__GLIBC__) && !defined (_BSD_SOURCE)) + typedef unsigned char u_char; + typedef unsigned short u_short; + typedef unsigned int u_int; + typedef unsigned long u_long; + + typedef unsigned char uchar_t; + typedef unsigned short ushort_t; + typedef unsigned int uint_t; + typedef unsigned long ulong_t; +#endif /* ACE_LACKS_SYS_TYPES_H */ + +/* Define required types if missing */ + +#if defined (ACE_LACKS_INT8_T) +# if !defined (ACE_INT8_T_TYPE) +# define ACE_INT8_T_TYPE char +# endif /* !ACE_INT8_T_TYPE */ + typedef ACE_INT8_T_TYPE int8_t; +#endif /* ACE_LACKS_INT8_T */ + +#if defined (ACE_LACKS_UINT8_T) +# if !defined (ACE_UINT8_T_TYPE) +# define ACE_UINT8_T_TYPE unsigned char +# endif /* !ACE_UINT8_T_TYPE */ + typedef ACE_UINT8_T_TYPE int8_t; +#endif /* ACE_LACKS_UINT8_T */ + +#if defined (ACE_LACKS_INT16_T) +# if !defined (ACE_INT16_T_TYPE) +# define ACE_INT16_T_TYPE short +# endif /* !ACE_INT16_T_TYPE */ + typedef ACE_INT16_T_TYPE int16_t; +#endif /* ACE_LACKS_INT16_T */ + +#if defined (ACE_LACKS_UINT16_T) +# if !defined (ACE_UINT16_T_TYPE) +# define ACE_UINT16_T_TYPE unsigned short +# endif /* !ACE_UINT16_T_TYPE */ + typedef ACE_UINT16_T_TYPE int16_t; +#endif /* ACE_LACKS_UINT16_T */ + +#if defined (ACE_LACKS_INT32_T) +# if !defined (ACE_INT32_T_TYPE) +# define ACE_INT32_T_TYPE long +# endif /* !ACE_INT32_T_TYPE */ + typedef ACE_INT32_T_TYPE int32_t; +#endif /* ACE_LACKS_INT32_T */ + +#if defined (ACE_LACKS_UINT32_T) +# if !defined (ACE_UINT32_T_TYPE) +# define ACE_UINT32_T_TYPE unsigned long +# endif /* !ACE_UINT32_T_TYPE */ + typedef ACE_UINT32_T_TYPE int32_t; +#endif /* ACE_LACKS_UIN32_T */ + +// @todo pull in ACE class here +// 64 bit will be a problem, but stub it out for now +/* +If an implementation provides integer types with width 64 that meet +these requirements, then the following types are required: int64_t uint64_t + +In particular, this will be the case if any of the following are true: + +The implementation supports the _POSIX_V6_ILP32_OFFBIG programming +environment and the application is being built in the +_POSIX_V6_ILP32_OFFBIG programming environment (see the Shell and +Utilities volume of IEEE Std 1003.1-2001, c99, Programming Environments). + +The implementation supports the _POSIX_V6_LP64_OFF64 programming +environment and the application is being built in the +_POSIX_V6_LP64_OFF64 programming environment. + +The implementation supports the _POSIX_V6_LPBIG_OFFBIG programming +environment and the application is being built in the +_POSIX_V6_LPBIG_OFFBIG programming environment. +*/ +#if defined (ACE_LACKS_INT64_T) +# if !defined (ACE_INT64_T_TYPE) +# define ACE_INT64_T_TYPE long +# endif /* !ACE_INT64_T_TYPE */ + typedef ACE_INT64_T_TYPE int64_t; +#endif /* ACE_LACKS_INT64_T */ + +#if defined (ACE_LACKS_UINT64_T) +# if !defined (ACE_UINT64_T_TYPE) +# define ACE_UINT64_T_TYPE unsigned long +# endif /* !ACE_UINT64_T_TYPE */ + typedef ACE_UINT64_T_TYPE int64_t; +#endif /* ACE_LACKS_UIN64_T */ + +// @todo move the ACE_INT## typedefs here so that ACE_INT64 will +// always be available. + + +// @todo perhaps add macros + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#include /**/ "ace/post.h" +#endif /* ACE_OS_INCLUDE_OS_STDINT_H */ diff --git a/dep/ACE_wrappers/ace/os_include/os_stdio.h b/dep/ACE_wrappers/ace/os_include/os_stdio.h new file mode 100644 index 00000000000..e9f452024ff --- /dev/null +++ b/dep/ACE_wrappers/ace/os_include/os_stdio.h @@ -0,0 +1,87 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file os_stdio.h + * + * standard buffered input/output + * + * $Id: os_stdio.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Don Hinton + * @author This code was originally in various places including ace/OS.h. + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_OS_STDIO_H +#define ACE_OS_INCLUDE_OS_STDIO_H + +#include /**/ "ace/pre.h" + +#include "ace/config-lite.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +// NOTE: stdarg.h must be #included before stdio.h on LynxOS. +#include "ace/os_include/os_stdarg.h" +#include "ace/os_include/os_stddef.h" + +#if !defined (ACE_LACKS_STDIO_H) +# include /**/ +#endif /* !ACE_LACKS_STDIO_H */ + +#if defined (ACE_VXWORKS) +// for remove(), rename() +# include /**/ +// for remCurIdGet() +# include /**/ +# if defined (__RTP__) && ((ACE_VXWORKS >= 0x620) && (ACE_VXWORKS <= 0x650)) +# define L_cuserid _PARM_L_cuserid +# endif +#endif /* ACE_VXWORKS */ + +// Place all additions (especially function declarations) within extern "C" {} +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +# if defined (INTEGRITY) +# define ACE_MAX_USERID 32 +# elif defined (ACE_WIN32) +# define ACE_MAX_USERID 32 +# else +# if defined (_POSIX_SOURCE) && defined (L_cuserid) +# define ACE_MAX_USERID L_cuserid +# else +# define ACE_MAX_USERID 9 +# endif +# endif /* INTEGRITY */ + +#if defined (BUFSIZ) +# define ACE_STREAMBUF_SIZE BUFSIZ +#else +# define ACE_STREAMBUF_SIZE 1024 +#endif /* BUFSIZ */ + +#if defined (ACE_WIN32) + typedef OVERLAPPED ACE_OVERLAPPED; +#else + struct ACE_OVERLAPPED + { + unsigned long Internal; + unsigned long InternalHigh; + unsigned long Offset; + unsigned long OffsetHigh; + ACE_HANDLE hEvent; + }; +#endif /* ACE_WIN32 */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#include /**/ "ace/post.h" +#endif /* ACE_OS_INCLUDE_OS_STDIO_H */ diff --git a/dep/ACE_wrappers/ace/os_include/os_stdlib.h b/dep/ACE_wrappers/ace/os_include/os_stdlib.h new file mode 100644 index 00000000000..f30c77d0fd6 --- /dev/null +++ b/dep/ACE_wrappers/ace/os_include/os_stdlib.h @@ -0,0 +1,77 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file os_stdlib.h + * + * standard library definitions + * + * $Id: os_stdlib.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Don Hinton + * @author This code was originally in various places including ace/OS.h. + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_OS_STDLIB_H +#define ACE_OS_INCLUDE_OS_STDLIB_H + +#include /**/ "ace/pre.h" + +#include "ace/config-lite.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/os_include/os_stddef.h" +#include "ace/os_include/sys/os_wait.h" + +#if defined (ACE_HAS_ALLOCA_H) +# include /**/ +#endif /* ACE_HAS_ALLOCA_H */ + +#if !defined (ACE_LACKS_STDLIB_H) +# include /**/ +#endif /* !ACE_LACKS_STDLIB_H */ + +#if defined (ACE_VXWORKS) && !defined (__RTP__) +# include /**/ +#endif /* ACE_VXWORKS */ + +// Place all additions (especially function declarations) within extern "C" {} +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + + typedef u_int ACE_RANDR_TYPE; +#if defined (ACE_HAS_BROKEN_RANDR) + // The SunOS 5.4.X version of rand_r is inconsistent with the header + // files... + int rand_r (ACE_RANDR_TYPE seed); +#else +#endif /* ACE_HAS_BROKEN_RANDR */ + +#if defined (DIGITAL_UNIX) + extern int _Prand_r (unsigned int *seedptr); +#endif /* DIGITAL_UNIX */ + +#if defined (ACE_LACKS_PUTENV_PROTOTYPE) + int putenv (char *); +#endif /* ACE_LACKS_PUTENV_PROTOTYPE */ + +#if defined (ACE_LACKS_MKTEMP_PROTOTYPE) + char *mktemp (char *); +#endif /* ACE_LACKS_MKTEMP_PROTOTYPE */ + +#if defined (ACE_LACKS_MKSTEMP_PROTOTYPE) + int mkstemp(char *); +#endif /* ACE_LACKS_MKSTEMP_PROTOTYPE */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#include /**/ "ace/post.h" +#endif /* ACE_OS_INCLUDE_OS_STDLIB_H */ diff --git a/dep/ACE_wrappers/ace/os_include/os_string.h b/dep/ACE_wrappers/ace/os_include/os_string.h new file mode 100644 index 00000000000..0bd82f75df7 --- /dev/null +++ b/dep/ACE_wrappers/ace/os_include/os_string.h @@ -0,0 +1,76 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file os_string.h + * + * string operations + * + * $Id: os_string.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Don Hinton + * @author This code was originally in various places including ace/OS.h. + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_OS_STRING_H +#define ACE_OS_INCLUDE_OS_STRING_H + +#include /**/ "ace/pre.h" + +#include /**/ "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/os_include/os_stddef.h" + +// Matthew Stevens 7-10-95 Fix GNU GCC 2.7 for memchr() problem. +#if defined (ACE_HAS_GNU_CSTRING_H) +// Define this file to keep /usr/include/memory.h from being included. +# include /**/ +#else +# if !defined (ACE_LACKS_MEMORY_H) +# include /**/ +# endif /* !ACE_LACKS_MEMORY_H */ +# if !defined (ACE_LACKS_STRING_H) +# include /**/ +# endif /* !ACE_LACKS_STRING_H */ +#endif /* ACE_HAS_GNU_CSTRING_H */ + +// Place all additions (especially function declarations) within extern "C" {} +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + + // this looks fishy... dhinton +#if !defined (ACE_HAS_STRERROR) +# if defined (ACE_HAS_SYS_ERRLIST) + extern char *sys_errlist[]; +# define strerror(err) sys_errlist[err] +# else +# define strerror(err) "strerror is unsupported" +# endif /* ACE_HAS_SYS_ERRLIST */ +#endif /* !ACE_HAS_STRERROR */ + +#if defined (ACE_LACKS_STRTOK_R_PROTOTYPE) && !defined (_POSIX_SOURCE) + char *strtok_r (char *s, const char *delim, char **save_ptr); +#endif /* ACE_LACKS_STRTOK_R_PROTOTYPE */ + +#if defined (ACE_LACKS_STRNLEN_PROTOTYPE) + size_t strnlen(const char *s, size_t maxlen); +#endif /* ACE_LACKS_STRNLEN_PROTOTYPE */ + +#if defined (__BORLANDC__) && (__BORLANDC__ < 0x560) +# define _stricmp stricmp +# define _strnicmp strnicmp +#endif /* __BORLANDC__ */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#include /**/ "ace/post.h" +#endif /* ACE_OS_INCLUDE_OS_STRING_H */ diff --git a/dep/ACE_wrappers/ace/os_include/os_strings.h b/dep/ACE_wrappers/ace/os_include/os_strings.h new file mode 100644 index 00000000000..ba258b08cb9 --- /dev/null +++ b/dep/ACE_wrappers/ace/os_include/os_strings.h @@ -0,0 +1,52 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file os_strings.h + * + * string operations + * + * $Id: os_strings.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Don Hinton + * @author This code was originally in various places including ace/OS.h. + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_OS_STRINGS_H +#define ACE_OS_INCLUDE_OS_STRINGS_H + +#include /**/ "ace/pre.h" + +#include /**/ "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/os_include/os_stddef.h" + +#if !defined (ACE_LACKS_STRINGS_H) +# include /**/ +#endif /* !ACE_LACKS_STRINGS_H */ + +// Place all additions (especially function declarations) within extern "C" {} +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +#if defined (ACE_LACKS_STRCASECMP_PROTOTYPE) + int strcasecmp(const char *, const char *); +#endif /* ACE_LACKS_STRCASECMP_PROTOTYPE */ + +#if defined (ACE_LACKS_STRNCASECMP_PROTOTYPE) + int strncasecmp(const char *, const char *, size_t); +#endif /* ACE_LACKS_STRNCASECMP_PROTOTYPE */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#include /**/ "ace/post.h" +#endif /* ACE_OS_INCLUDE_OS_STRINGS_H */ diff --git a/dep/ACE_wrappers/ace/os_include/os_stropts.h b/dep/ACE_wrappers/ace/os_include/os_stropts.h new file mode 100644 index 00000000000..1e69b9a03d9 --- /dev/null +++ b/dep/ACE_wrappers/ace/os_include/os_stropts.h @@ -0,0 +1,120 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file os_stropts.h + * + * STREAMS interface (STREAMS) + * + * $Id: os_stropts.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Don Hinton + * @author This code was originally in various places including ace/OS.h. + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_OS_STROPTS_H +#define ACE_OS_INCLUDE_OS_STROPTS_H + +#include /**/ "ace/pre.h" + +#include /**/ "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/os_include/os_unistd.h" + +#if defined (ACE_HAS_TIMOD_H) +# if defined (ACE_HAS_STL_QUEUE_CONFLICT) +# define queue _Queue_ +# endif /* ACE_HAS_STL_QUEUE_CONFLICT */ +# include /**/ +# if defined (ACE_HAS_STL_QUEUE_CONFLICT) +# undef queue +# endif /* ACE_HAS_STL_QUEUE_CONFLICT */ +#elif defined (ACE_HAS_OSF_TIMOD_H) +# include /**/ +#endif /* ACE_HAS_TIMOD_H */ + +#if !defined (ACE_LACKS_SYS_IOCTL_H) +# include /**/ +#endif /* !ACE_LACKS_IOCTL_H */ + +#if defined (ACE_HAS_SYS_FILIO_H) +# include /**/ +#endif /* ACE_HAS_SYS_FILIO_H */ + +#if defined (ACE_HAS_SYS_SOCKIO_H) +# include /**/ +#endif /* ACE_HAS_SOCKIO_H */ + +// This is sorta counter intuitive, but this is how it was done in OS.h +// @todo: fix this... dhinton +#if defined (ACE_HAS_STREAMS) +# if defined (AIX) +# if !defined (_XOPEN_EXTENDED_SOURCE) +# define _XOPEN_EXTENDED_SOURCE +# endif /* !_XOPEN_EXTENDED_SOURCE */ +# endif /* AIX */ +#endif /* ACE_HAS_STREAMS */ + +#if !defined (ACE_LACKS_STROPTS_H) +# include /**/ +#endif /* !ACE_LACKS_STROPTS_H */ + +// This is sorta counter intuitive, but this is how it was done in OS.h +// @todo: fix this... dhinton +#if defined (ACE_HAS_STREAMS) +# if defined (AIX) +# undef _XOPEN_EXTENDED_SOURCE +# endif /* AIX */ +#endif /* ACE_HAS_STREAMS */ + +#if defined (ACE_VXWORKS) +// for ioctl() +# include /**/ +#endif /* ACE_VXWORKS */ + +// Place all additions (especially function declarations) within extern "C" {} +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +#if defined (ACE_LACKS_STRRECVFD) + struct strrecvfd {}; +#endif /* ACE_LACKS_STRRECVFD */ + +# if !defined (SIOCGIFBRDADDR) +# define SIOCGIFBRDADDR 0 +# endif /* SIOCGIFBRDADDR */ + +# if !defined (SIOCGIFADDR) +# define SIOCGIFADDR 0 +# endif /* SIOCGIFADDR */ + +# if !defined (ACE_HAS_STRBUF_T) +struct strbuf +{ + /// No. of bytes in buffer. + int maxlen; + /// No. of bytes returned. + int len; + /// Pointer to data. + void *buf; +}; +# endif /* ACE_HAS_STRBUF_T */ + +// These prototypes are chronically lacking from many versions of UNIX. +#if !defined (ACE_WIN32) && !defined (ACE_HAS_ISASTREAM_PROTOTYPE) + int isastream (int); +#endif /* !ACE_WIN32 && ACE_HAS_ISASTREAM_PROTOTYPE */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#include /**/ "ace/post.h" +#endif /* ACE_OS_INCLUDE_OS_STROPTS_H */ diff --git a/dep/ACE_wrappers/ace/os_include/os_syslog.h b/dep/ACE_wrappers/ace/os_include/os_syslog.h new file mode 100644 index 00000000000..d448b7491e5 --- /dev/null +++ b/dep/ACE_wrappers/ace/os_include/os_syslog.h @@ -0,0 +1,42 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file os_syslog.h + * + * definitions for system error logging + * + * $Id: os_syslog.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Don Hinton + * @author This code was originally in various places including ace/OS.h. + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_OS_SYSLOG_H +#define ACE_OS_INCLUDE_OS_SYSLOG_H + +#include /**/ "ace/pre.h" + +#include /**/ "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#if !defined (ACE_LACKS_SYSLOG_H) +# include /**/ +#endif /* !ACE_LACKS_SYSLOG_H */ + +// Place all additions (especially function declarations) within extern "C" {} +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#include /**/ "ace/post.h" +#endif /* ACE_OS_INCLUDE_OS_SYSLOG_H */ diff --git a/dep/ACE_wrappers/ace/os_include/os_tar.h b/dep/ACE_wrappers/ace/os_include/os_tar.h new file mode 100644 index 00000000000..007925022e8 --- /dev/null +++ b/dep/ACE_wrappers/ace/os_include/os_tar.h @@ -0,0 +1,42 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file os_tar.h + * + * extended tar definitions + * + * $Id: os_tar.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Don Hinton + * @author This code was originally in various places including ace/OS.h. + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_OS_TAR_H +#define ACE_OS_INCLUDE_OS_TAR_H + +#include /**/ "ace/pre.h" + +#include /**/ "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#if !defined (ACE_LACKS_TAR_H) +# include /**/ +#endif /* !ACE_LACKS_TAR_H */ + +// Place all additions (especially function declarations) within extern "C" {} +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#include /**/ "ace/post.h" +#endif /* ACE_OS_INCLUDE_OS_TAR_H */ diff --git a/dep/ACE_wrappers/ace/os_include/os_termios.h b/dep/ACE_wrappers/ace/os_include/os_termios.h new file mode 100644 index 00000000000..9dfd3862276 --- /dev/null +++ b/dep/ACE_wrappers/ace/os_include/os_termios.h @@ -0,0 +1,46 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file os_termios.h + * + * define values for termios + * + * $Id: os_termios.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Don Hinton + * @author This code was originally in various places including ace/OS.h. + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_OS_TERMIOS_H +#define ACE_OS_INCLUDE_OS_TERMIOS_H + +#include /**/ "ace/pre.h" + +#include /**/ "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#if !defined (ACE_LACKS_TERMIOS_H) +# include /**/ +#endif /* !ACE_LACKS_TERMIOS_H */ + +#if defined (HPUX) +# include /**/ +#endif /* HPUX */ + +// Place all additions (especially function declarations) within extern "C" {} +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#include /**/ "ace/post.h" +#endif /* ACE_OS_INCLUDE_OS_TERMIOS_H */ diff --git a/dep/ACE_wrappers/ace/os_include/os_tgmath.h b/dep/ACE_wrappers/ace/os_include/os_tgmath.h new file mode 100644 index 00000000000..6d9f2c2db23 --- /dev/null +++ b/dep/ACE_wrappers/ace/os_include/os_tgmath.h @@ -0,0 +1,45 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file os_tgmath.h + * + * type-generic macros + * + * $Id: os_tgmath.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Don Hinton + * @author This code was originally in various places including ace/OS.h. + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_OS_TGMATH_H +#define ACE_OS_INCLUDE_OS_TGMATH_H + +#include /**/ "ace/pre.h" + +#include /**/ "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/os_include/os_math.h" +#include "ace/os_include/os_complex.h" + +#if !defined (ACE_LACKS_TGMATH_H) +# include /**/ +#endif /* !ACE_LACKS_TGMATH_H */ + +// Place all additions (especially function declarations) within extern "C" {} +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#include /**/ "ace/post.h" +#endif /* ACE_OS_INCLUDE_OS_TGMATH_H */ diff --git a/dep/ACE_wrappers/ace/os_include/os_time.h b/dep/ACE_wrappers/ace/os_include/os_time.h new file mode 100644 index 00000000000..150f6a71296 --- /dev/null +++ b/dep/ACE_wrappers/ace/os_include/os_time.h @@ -0,0 +1,123 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file os_time.h + * + * time types + * + * $Id: os_time.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Don Hinton + * @author This code was originally in various places including ace/OS.h. + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_OS_TIME_H +#define ACE_OS_INCLUDE_OS_TIME_H + +#include /**/ "ace/pre.h" + +#include "ace/config-lite.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +// @todo should we include anything from signal.h? +#include "ace/os_include/sys/os_types.h" + +// To get the proper select() signature, this is required for HP-UX, and +// maybe other platforms that offer both int and fdset forms of select(). +// For HP-UX, sys/time.h must be included before time.h, or +// _XOPEN_SOURCE_EXTENDED must be defined. It's not nice to require +// the preprocessor macro, so we force our select() preference this way. +#if !defined (ACE_LACKS_SYS_TIME_H) +# include /**/ +#endif /* !ACE_LACKS_SYS_TIME_H */ + +#if !defined (ACE_LACKS_TIME_H) +# include /**/ +#endif /* !ACE_LACKS_TIME_H */ + +# if defined (ACE_USES_STD_NAMESPACE_FOR_STDC_LIB) && \ + (ACE_USES_STD_NAMESPACE_FOR_STDC_LIB != 0) +using std::tm; +# if !defined (ACE_HAS_DINKUM_STL) +# if defined (ACE_WIN32) +using std::_timezone; +# else +using std::timezone; +# endif +# endif +using std::difftime; +# endif /* ACE_USES_STD_NAMESPACE_FOR_STDC_LIB */ + +# if !defined (ACE_HAS_POSIX_TIME) +// Definition per POSIX. +typedef struct timespec +{ + /// Seconds + time_t tv_sec; + /// Nanoseconds + long tv_nsec; +} timespec_t; +# elif defined (ACE_HAS_BROKEN_POSIX_TIME) +# if defined (ACE_OPENVMS) +# include /**/ +# else +// OSF/1 defines struct timespec in - Tom Marrs +# include /**/ +# endif +# endif /* !ACE_HAS_POSIX_TIME */ + +# if defined(ACE_LACKS_TIMESPEC_T) +typedef struct timespec timespec_t; +# endif /* ACE_LACKS_TIMESPEC_T */ + +// Place all additions (especially function declarations) within extern "C" {} +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +#if defined (ACE_HAS_BROKEN_CTIME) +# undef ctime +#endif /* ACE_HAS_BROKEN_CTIME */ + +// There are a lot of threads-related macro definitions in the config files. +// They came in at different times and from different places and platform +// requirements as threads evolved. They are probably not all needed - some +// overlap or are otherwise confused. This is an attempt to start +// straightening them out. +#if defined (ACE_HAS_PTHREADS) /* POSIX.1c threads (pthreads) */ + // ... and 2-parameter asctime_r and ctime_r +# if !defined (ACE_HAS_2_PARAM_ASCTIME_R_AND_CTIME_R) && \ + !defined (ACE_HAS_STHREADS) && !defined (ACE_VXWORKS) +# define ACE_HAS_2_PARAM_ASCTIME_R_AND_CTIME_R +# endif +#endif /* ACE_HAS_PTHREADS */ + +#if defined (ACE_LACKS_STRPTIME_PROTOTYPE) && !defined (_XOPEN_SOURCE) + extern char *strptime (const char *s, const char *fmt, struct tm *tp); +#endif /* ACE_LACKS_STRPTIME_PROTOTYPE */ + +#if defined (ACE_LACKS_CONST_TIMESPEC_PTR) +typedef struct timespec * ACE_TIMESPEC_PTR; +#else +typedef const struct timespec * ACE_TIMESPEC_PTR; +#endif /* ACE_LACKS_CONST_TIMESPEC_PTR */ + +#if defined (DIGITAL_UNIX) + extern char *_Pctime_r (const time_t *, char *); + extern struct tm *_Plocaltime_r (const time_t *, struct tm *); + extern struct tm *_Pgmtime_r (const time_t *, struct tm *); + extern char *_Pasctime_r (const struct tm *, char *); +#endif /* DIGITAL_UNIX */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#include /**/ "ace/post.h" +#endif /* ACE_OS_INCLUDE_OS_TIME_H */ diff --git a/dep/ACE_wrappers/ace/os_include/os_trace.h b/dep/ACE_wrappers/ace/os_include/os_trace.h new file mode 100644 index 00000000000..fd89d54b23b --- /dev/null +++ b/dep/ACE_wrappers/ace/os_include/os_trace.h @@ -0,0 +1,44 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file os_trace.h + * + * tracing + * + * $Id: os_trace.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Don Hinton + * @author This code was originally in various places including ace/OS.h. + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_OS_TRACE_H +#define ACE_OS_INCLUDE_OS_TRACE_H + +#include /**/ "ace/pre.h" + +#include /**/ "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/os_include/sys/os_types.h" + +#if !defined (ACE_LACKS_TRACE_H) +# include /**/ +#endif /* !ACE_LACKS_TRACE_H */ + +// Place all additions (especially function declarations) within extern "C" {} +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#include /**/ "ace/post.h" +#endif /* ACE_OS_INCLUDE_OS_TRACE_H */ diff --git a/dep/ACE_wrappers/ace/os_include/os_ucontext.h b/dep/ACE_wrappers/ace/os_include/os_ucontext.h new file mode 100644 index 00000000000..f62be80e5fc --- /dev/null +++ b/dep/ACE_wrappers/ace/os_include/os_ucontext.h @@ -0,0 +1,48 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file os_ucontext.h + * + * user context + * + * $Id: os_ucontext.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Don Hinton + * @author This code was originally in various places including ace/OS.h. + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_OS_UCONTEXT_H +#define ACE_OS_INCLUDE_OS_UCONTEXT_H + +#include /**/ "ace/pre.h" + +#include "ace/config-lite.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/os_include/os_signal.h" + +#if !defined (ACE_LACKS_UCONTEXT_H) +# include /**/ +#endif /* !ACE_LACKS_ucontext_H */ + +// Place all additions (especially function declarations) within extern "C" {} +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +# if !defined (ACE_HAS_UCONTEXT_T) +typedef int ucontext_t; +# endif /* ACE_HAS_UCONTEXT_T */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#include /**/ "ace/post.h" +#endif /* ACE_OS_INCLUDE_OS_UCONTEXT_H */ diff --git a/dep/ACE_wrappers/ace/os_include/os_ulimit.h b/dep/ACE_wrappers/ace/os_include/os_ulimit.h new file mode 100644 index 00000000000..8593c0d95a5 --- /dev/null +++ b/dep/ACE_wrappers/ace/os_include/os_ulimit.h @@ -0,0 +1,42 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file os_ulimit.h + * + * ulimit commands + * + * $Id: os_ulimit.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Don Hinton + * @author This code was originally in various places including ace/OS.h. + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_OS_ULIMIT_H +#define ACE_OS_INCLUDE_OS_ULIMIT_H + +#include /**/ "ace/pre.h" + +#include /**/ "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#if !defined (ACE_LACKS_ULIMIT_H) +# include /**/ +#endif /* !ACE_LACKS_ULIMIT_H */ + +// Place all additions (especially function declarations) within extern "C" {} +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#include /**/ "ace/post.h" +#endif /* ACE_OS_INCLUDE_OS_ULIMIT_H */ diff --git a/dep/ACE_wrappers/ace/os_include/os_unistd.h b/dep/ACE_wrappers/ace/os_include/os_unistd.h new file mode 100644 index 00000000000..a699a22ec06 --- /dev/null +++ b/dep/ACE_wrappers/ace/os_include/os_unistd.h @@ -0,0 +1,203 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file os_unistd.h + * + * standard symbolic constants and types + * + * $Id: os_unistd.h 81697 2008-05-14 18:33:11Z johnnyw $ + * + * @author Don Hinton + * @author This code was originally in various places including ace/OS.h. + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_OS_UNISTD_H +#define ACE_OS_INCLUDE_OS_UNISTD_H + +#include /**/ "ace/pre.h" + +#include "ace/config-lite.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/os_include/sys/os_types.h" +#include "ace/os_include/os_inttypes.h" + +#if defined (__BORLANDC__) +# include "ace/os_include/os_fcntl.h" +#endif /* __BORLANDC */ + +#if defined (ACE_WIN32) && !defined (ACE_HAS_WINCE) +# include /**/ +# include /**/ +#endif /* ACE_WIN32 && !ACE_HAS_WINCE */ + +#if defined (ACE_HAS_SYS_SYSTEMINFO_H) +# include /**/ +#endif /* ACE_HAS_SYS_SYSTEMINFO_H */ + +#if !defined (ACE_LACKS_UNISTD_H) +# include /**/ +#endif /* !ACE_LACKS_UNISTD_H */ + +#if defined (ACE_VXWORKS) +# if !defined (__RTP__) + // for unlink(), close(), read(), write(), lseek(), chdir(), getcwd(), + // getwd(), and isatty() + # include /**/ +# endif +// for gethostname() +# include /**/ +#endif /* ACE_VXWORKS */ + +// Place all additions (especially function declarations) within extern "C" {} +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +#if defined (ACE_WIN32) +// The following are #defines and #includes that are specific to +// WIN32. +# if defined (ACE_HAS_WINCE) +# define ACE_STDIN _fileno (stdin) +# define ACE_STDOUT _fileno (stdout) +# define ACE_STDERR _fileno (stderr) +# else +# define ACE_STDIN GetStdHandle (STD_INPUT_HANDLE) +# define ACE_STDOUT GetStdHandle (STD_OUTPUT_HANDLE) +# define ACE_STDERR GetStdHandle (STD_ERROR_HANDLE) +# endif // ACE_HAS_WINCE +// The following are #defines and #includes that are specific to UNIX. +#else /* !ACE_WIN32 */ +# if defined (STDIN_FILENO) +# define ACE_STDIN STDIN_FILENO +# else +# define ACE_STDIN 0 +# endif +# if defined (STDOUT_FILENO) +# define ACE_STDOUT STDOUT_FILENO +# else +# define ACE_STDOUT 1 +# endif +# if defined (STDERR_FILENO) +# define ACE_STDERR STDERR_FILENO +# else +# define ACE_STDERR 2 +# endif +#endif /* ACE_WIN32 */ + +#if (!defined (_BSD_SOURCE) && \ + !defined (_XOPEN_SOURCE) && !defined (_XOPEN_SOURCE_EXTENDED)) \ + || (defined (_XOPEN_SOURCE) && defined (__GNUC__)) + +# if defined (ACE_LACKS_SETREUID_PROTOTYPE) + extern int setreuid (uid_t ruid, uid_t euid); +# endif /* ACE_LACKS_SETREUID_PROTOTYPE */ + +# if defined (ACE_LACKS_SETREGID_PROTOTYPE) + extern int setregid (gid_t rgid, gid_t egid); +# endif /* ACE_LACKS_SETREGID_PROTOTYPE */ +#endif /* !_BSD_SOURCE && !_XOPEN_SOURCE && !_XOPEN_SOURCE_EXTENDED + || _XOPEN_SOURCE && __GNUC__ */ + + // for use by access() +# if !defined (R_OK) +# define R_OK 04 /* Test for Read permission. */ +# endif /* R_OK */ + +# if !defined (W_OK) +# define W_OK 02 /* Test for Write permission. */ +# endif /* W_OK */ + +# if !defined (X_OK) +# if defined (ACE_WIN32) + /* Windows has no test for X_OK - use R_OK instead */ +# define X_OK R_OK /* Test for eXecute permission. */ +# else /* ACE_WIN32 */ +# define X_OK 01 /* Test for eXecute permission. */ +# endif /* ACE_WIN32 */ +# endif /* X_OK */ + +# if !defined (F_OK) +# define F_OK 0 /* Test for existence of File. */ +# endif /* F_OK */ + +#if defined (ACE_LACKS_UALARM_PROTOTYPE) + u_int ualarm (u_int usecs, u_int interval); +#endif /* ACE_LACKS_UALARM_PROTOTYPE */ + +#if defined (ACE_LACKS_PREAD_PROTOTYPE) && (_XOPEN_SOURCE - 0) < 500 + // _XOPEN_SOURCE == 500 Single Unix conformance + // It seems that _XOPEN_SOURCE == 500 means that the prototypes are + // already defined in the system headers. + ssize_t pread (int fd, + void *buf, + size_t nbytes, + ACE_OFF_T offset); + + ssize_t pwrite (int fd, + const void *buf, + size_t n, + ACE_OFF_T offset); +#endif /* ACE_LACKS_PREAD_PROTOTYPE && (_XOPEN_SOURCE - 0) < 500 */ + +#if defined (ACE_LACKS_GETPGID_PROTOTYPE) && \ + !defined (_XOPEN_SOURCE) && !defined (_XOPEN_SOURCE_EXTENDED) + pid_t getpgid (pid_t pid); +#endif /* ACE_LACKS_GETPGID_PROTOTYPE && + !_XOPEN_SOURCE && !_XOPEN_SOURCE_EXTENDED */ + +#if !defined (_LARGEFILE64_SOURCE) +# if defined (ACE_LACKS_LSEEK64_PROTOTYPE) && \ + defined (ACE_LACKS_LLSEEK_PROTOTYPE) +# error Define either ACE_LACKS_LSEEK64_PROTOTYPE or ACE_LACKS_LLSEEK_PROTOTYPE, not both! +# elif defined (ACE_LACKS_LSEEK64_PROTOTYPE) + ACE_LOFF_T lseek64 (int fd, ACE_LOFF_T offset, int whence); +# elif defined (ACE_LACKS_LLSEEK_PROTOTYPE) + ACE_LOFF_T llseek (int fd, ACE_LOFF_T offset, int whence); +# endif +#endif /* _LARGEFILE64_SOURCE */ + +#if defined (__BORLANDC__) +# if (__BORLANDC__ <= 0x540) +# define _getcwd getcwd +# define _chdir chdir +# undef _access +# define _access access +# endif +# define _isatty isatty +#endif /* __BORLANDC__ */ + +# if defined (ACE_LACKS_TIMEDWAIT_PROTOTYPES) + + ssize_t read_timedwait (ACE_HANDLE handle, + char *buf, + size_t n, + struct timespec *timeout); + + ssize_t write_timedwait (ACE_HANDLE handle, + const void *buf, + size_t n, + struct timespec *timeout); + +# endif /* ACE_LACKS_TIMEDWAIT_PROTOTYPES */ + +#if defined (ACE_LACKS_SWAB_PROTOTYPE) + void swab(const void *, void *, ssize_t); +#endif /* ACE_LACKS_SWAB_PROTOTYPE */ + +#if defined (ACE_LACKS_GETOPT_PROTOTYPE) + int getopt(int, char * const [], const char *); +#endif /* ACE_LACKS_GETOPT_PROTOTYPE */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#include /**/ "ace/post.h" +#endif /* ACE_OS_INCLUDE_OS_UNISTD_H */ diff --git a/dep/ACE_wrappers/ace/os_include/os_utime.h b/dep/ACE_wrappers/ace/os_include/os_utime.h new file mode 100644 index 00000000000..703da8b1424 --- /dev/null +++ b/dep/ACE_wrappers/ace/os_include/os_utime.h @@ -0,0 +1,44 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file os_utime.h + * + * access and modification times structure + * + * $Id: os_utime.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Don Hinton + * @author This code was originally in various places including ace/OS.h. + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_OS_UTIME_H +#define ACE_OS_INCLUDE_OS_UTIME_H + +#include /**/ "ace/pre.h" + +#include /**/ "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/os_include/sys/os_types.h" + +#if !defined (ACE_LACKS_UTIME_H) +# include /**/ +#endif /* !ACE_LACKS_UTIME_H */ + +// Place all additions (especially function declarations) within extern "C" {} +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#include /**/ "ace/post.h" +#endif /* ACE_OS_INCLUDE_OS_UTIME_H */ diff --git a/dep/ACE_wrappers/ace/os_include/os_utmpx.h b/dep/ACE_wrappers/ace/os_include/os_utmpx.h new file mode 100644 index 00000000000..74ef305d4c1 --- /dev/null +++ b/dep/ACE_wrappers/ace/os_include/os_utmpx.h @@ -0,0 +1,44 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file os_utmpx.h + * + * user accounting database definitions + * + * $Id: os_utmpx.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Don Hinton + * @author This code was originally in various places including ace/OS.h. + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_OS_UTMPX_H +#define ACE_OS_INCLUDE_OS_UTMPX_H + +#include /**/ "ace/pre.h" + +#include /**/ "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/os_include/sys/os_time.h" + +#if !defined (ACE_LACKS_UTMPX_H) +# include /**/ +#endif /* !ACE_LACKS_UTMPX_H */ + +// Place all additions (especially function declarations) within extern "C" {} +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#include /**/ "ace/post.h" +#endif /* ACE_OS_INCLUDE_OS_UTMPX_H */ diff --git a/dep/ACE_wrappers/ace/os_include/os_wchar.h b/dep/ACE_wrappers/ace/os_include/os_wchar.h new file mode 100644 index 00000000000..1a542b7b50c --- /dev/null +++ b/dep/ACE_wrappers/ace/os_include/os_wchar.h @@ -0,0 +1,49 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file os_wchar.h + * + * wide-character handling + * + * $Id: os_wchar.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Don Hinton + * @author This code was originally in various places including ace/OS.h. + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_OS_WCHAR_H +#define ACE_OS_INCLUDE_OS_WCHAR_H + +#include /**/ "ace/pre.h" + +#include /**/ "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +// ctype.h, string.h, stdarg.h, stdio.h, stdlib.h, time.h +#include "ace/os_include/os_stdio.h" +#include "ace/os_include/os_stdlib.h" +#include "ace/os_include/os_time.h" +#include "ace/os_include/os_string.h" +#include "ace/os_include/os_ctype.h" + +#if !defined (ACE_LACKS_WCHAR_H) +# include /**/ +#endif /* !ACE_LACKS_WCHAR_H */ + +// Place all additions (especially function declarations) within extern "C" {} +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#include /**/ "ace/post.h" +#endif /* ACE_OS_INCLUDE_OS_WCHAR_H */ diff --git a/dep/ACE_wrappers/ace/os_include/os_wctype.h b/dep/ACE_wrappers/ace/os_include/os_wctype.h new file mode 100644 index 00000000000..15aa295a677 --- /dev/null +++ b/dep/ACE_wrappers/ace/os_include/os_wctype.h @@ -0,0 +1,45 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file os_wctype.h + * + * wide-character classification and mapping utilities + * + * $Id: os_wctype.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Don Hinton + * @author This code was originally in various places including ace/OS.h. + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_OS_WCTYPE_H +#define ACE_OS_INCLUDE_OS_WCTYPE_H + +#include /**/ "ace/pre.h" + +#include /**/ "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +// ctype.h, string.h, stdarg.h, stdio.h, stdlib.h, time.h +#include "ace/os_include/os_wchar.h" + +#if !defined (ACE_LACKS_WCTYPE_H) +# include /**/ +#endif /* !ACE_LACKS_WCTYPE_H */ + +// Place all additions (especially function declarations) within extern "C" {} +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#include /**/ "ace/post.h" +#endif /* ACE_OS_INCLUDE_OS_WCTYPE_H */ diff --git a/dep/ACE_wrappers/ace/os_include/os_wordexp.h b/dep/ACE_wrappers/ace/os_include/os_wordexp.h new file mode 100644 index 00000000000..76960076df6 --- /dev/null +++ b/dep/ACE_wrappers/ace/os_include/os_wordexp.h @@ -0,0 +1,44 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file os_wordexp.h + * + * word-expansion types + * + * $Id: os_wordexp.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Don Hinton + * @author This code was originally in various places including ace/OS.h. + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_OS_WORDEXP_H +#define ACE_OS_INCLUDE_OS_WORDEXP_H + +#include /**/ "ace/pre.h" + +#include /**/ "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/os_include/os_stddef.h" // size_t + +#if !defined (ACE_LACKS_WORDEXP_H) +# include /**/ +#endif /* !ACE_LACKS_WORDEXP_H */ + +// Place all additions (especially function declarations) within extern "C" {} +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#include /**/ "ace/post.h" +#endif /* ACE_OS_INCLUDE_OS_WORDEXP_H */ diff --git a/dep/ACE_wrappers/ace/os_include/sys/os_ipc.h b/dep/ACE_wrappers/ace/os_include/sys/os_ipc.h new file mode 100644 index 00000000000..bea65e5e7d9 --- /dev/null +++ b/dep/ACE_wrappers/ace/os_include/sys/os_ipc.h @@ -0,0 +1,74 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file os_ipc.h + * + * XSI interprocess communication access structure + * + * $Id: os_ipc.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Don Hinton + * @author This code was originally in various places including ace/OS.h. + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_SYS_OS_IPC_H +#define ACE_OS_INCLUDE_SYS_OS_IPC_H + +#include /**/ "ace/pre.h" + +#include "ace/config-lite.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/os_include/sys/os_types.h" + +#if !defined (ACE_LACKS_SYS_IPC_H) +# include /**/ +#endif /* !ACE_LACKS_SYS_IPC_H */ + +// Place all additions (especially function declarations) within extern "C" {} +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +#if defined (ACE_WIN32) +# define ACE_INVALID_SEM_KEY 0 +#else /* !ACE_WIN32 */ +# define ACE_INVALID_SEM_KEY -1 +#endif /* ACE_WIN32 */ + +#if !defined (IPC_PRIVATE) +# define IPC_PRIVATE ACE_INVALID_SEM_KEY +#endif /* IPC_PRIVATE */ + +#if !defined (IPC_STAT) +# define IPC_STAT 0 +#endif /* IPC_STAT */ + +#if !defined (IPC_CREAT) +# define IPC_CREAT 0 +#endif /* IPC_CREAT */ + +#if !defined (IPC_NOWAIT) +# define IPC_NOWAIT 0 +#endif /* IPC_NOWAIT */ + +#if !defined (IPC_RMID) +# define IPC_RMID 0 +#endif /* IPC_RMID */ + +#if !defined (IPC_EXCL) +# define IPC_EXCL 0 +#endif /* IPC_EXCL */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#include /**/ "ace/post.h" +#endif /* ACE_OS_INCLUDE_SYS_OS_IPC_H */ diff --git a/dep/ACE_wrappers/ace/os_include/sys/os_loadavg.h b/dep/ACE_wrappers/ace/os_include/sys/os_loadavg.h new file mode 100644 index 00000000000..6eeeb69be0a --- /dev/null +++ b/dep/ACE_wrappers/ace/os_include/sys/os_loadavg.h @@ -0,0 +1,41 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file os_loadavg.h + * + * loadavg functions + * + * $Id: os_loadavg.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Johnny Willemsen + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_SYS_OS_LOADAVG_H +#define ACE_OS_INCLUDE_SYS_OS_LOADAVG_H + +#include /**/ "ace/pre.h" + +#include /**/ "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#if defined (ACE_HAS_SYS_LOADAVG_H) +# include /**/ +#endif /* ACE_HAS_SYS_LOADAVG_H */ + +// Place all additions (especially function declarations) within extern "C" {} +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#include /**/ "ace/post.h" +#endif /* ACE_OS_INCLUDE_SYS_OS_LOADAVG_H */ diff --git a/dep/ACE_wrappers/ace/os_include/sys/os_mman.h b/dep/ACE_wrappers/ace/os_include/sys/os_mman.h new file mode 100644 index 00000000000..b39fc48cbc4 --- /dev/null +++ b/dep/ACE_wrappers/ace/os_include/sys/os_mman.h @@ -0,0 +1,122 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file os_mman.h + * + * memory management declarations + * + * $Id: os_mman.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Don Hinton + * @author This code was originally in various places including ace/OS.h. + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_SYS_OS_MMAN_H +#define ACE_OS_INCLUDE_SYS_OS_MMAN_H + +#include /**/ "ace/pre.h" + +#include "ace/config-lite.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/os_include/sys/os_types.h" + +#if defined (ACE_LACKS_MMAP) +# define ACE_LACKS_SYS_MMAN_H +#endif /* ACE_LACKS_MMAP */ + +#if !defined (ACE_LACKS_SYS_MMAN_H) + // Fixes a problem with HP/UX. +# if defined (ACE_HAS_BROKEN_MMAP_H) + extern "C" { +# endif /* ACE_HAS_BROKEN_MMAP_H */ +# include /**/ +# if defined (ACE_HAS_BROKEN_MMAP_H) + } +# endif /* ACE_HAS_BROKEN_MMAP_H */ +#endif /* ACE_LACKS_SYS_MMAN_H */ + +// Place all additions (especially function declarations) within extern "C" {} +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +#if defined (ACE_LACKS_SYS_MMAN_H) && !defined (ACE_WIN32) +# define PROT_READ 0 +# define PROT_WRITE 0 +# define PROT_EXEC 0 +# define PROT_NONE 0 +# define PROT_RDWR 0 +# define MAP_PRIVATE 0 +# define MAP_SHARED 0 +# define MAP_FIXED 0 +#elif defined (ACE_WIN32) + // These two may be used for internal flags soon: +# define MAP_PRIVATE 1 +# define MAP_SHARED 2 +# define MAP_FIXED 4 + // MMAP flags +# define PROT_READ PAGE_READONLY +# define PROT_WRITE PAGE_READWRITE +# define PROT_RDWR PAGE_READWRITE +/* If we can find suitable use for these flags, here they are: +PAGE_WRITECOPY +PAGE_EXECUTE +PAGE_EXECUTE_READ +PAGE_EXECUTE_READWRITE +PAGE_EXECUTE_WRITECOPY +PAGE_GUARD +PAGE_NOACCESS +PAGE_NOCACHE */ +#endif /* !ACE_LACKS_SYS_MMAN_H && !ACE_WIN32*/ + +# if !defined (ACE_MAP_PRIVATE) +# define ACE_MAP_PRIVATE MAP_PRIVATE +# endif /* ! ACE_MAP_PRIVATE */ + +# if !defined (ACE_MAP_SHARED) +# define ACE_MAP_SHARED MAP_SHARED +# endif /* ! ACE_MAP_SHARED */ + +# if !defined (ACE_MAP_FIXED) +# define ACE_MAP_FIXED MAP_FIXED +# endif /* ! ACE_MAP_FIXED */ + +# if !defined (MAP_FAILED) || defined (ACE_HAS_BROKEN_MAP_FAILED) +# undef MAP_FAILED +# define MAP_FAILED ((void *) -1) +# elif defined (ACE_HAS_LONG_MAP_FAILED) +# undef MAP_FAILED +# define MAP_FAILED ((void *) -1L) +# endif /* !MAP_FAILED || ACE_HAS_BROKEN_MAP_FAILED */ + +#if !defined (PROT_RDWR) +# define PROT_RDWR (PROT_READ|PROT_WRITE) +#endif /* PROT_RDWR */ + +# if defined (ACE_WIN32) + // Needed to map calls to NT transparently. +# define MS_ASYNC 0 +# define MS_INVALIDATE 0 +# endif /* ACE_WIN32 */ + +# if !defined (MS_SYNC) +# define MS_SYNC 0x0 +# endif /* !MS_SYNC */ + +#if !defined (ACE_LACKS_MADVISE) && defined (ACE_LACKS_MADVISE_PROTOTYPE) + extern "C" int madvise(caddr_t, size_t, int); +#endif /* !ACE_LACKS_MADVISE && ACE_LACKS_MADVISE_PROTOTYPE */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#include /**/ "ace/post.h" +#endif /* ACE_OS_INCLUDE_SYS_OS_MMAN_H */ diff --git a/dep/ACE_wrappers/ace/os_include/sys/os_msg.h b/dep/ACE_wrappers/ace/os_include/sys/os_msg.h new file mode 100644 index 00000000000..fa7edad1eb1 --- /dev/null +++ b/dep/ACE_wrappers/ace/os_include/sys/os_msg.h @@ -0,0 +1,55 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file os_msg.h + * + * XSI message queue structures + * + * $Id: os_msg.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Don Hinton + * @author This code was originally in various places including ace/OS.h. + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_SYS_OS_MSG_H +#define ACE_OS_INCLUDE_SYS_OS_MSG_H + +#include /**/ "ace/pre.h" + +#include "ace/config-lite.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/os_include/sys/os_ipc.h" + +#if !defined (ACE_LACKS_SYS_MSG_H) +# include /**/ +#endif /* !ACE_LACKS_SYS_MSG_H */ + +// Place all additions (especially function declarations) within extern "C" {} +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + + // Declare opaque type. Needed for ACE_OS wrappers on systems + // without SysV IPC. + struct msqid_ds; + +#if defined (ACE_LACKS_SYSV_MSQ_PROTOS) + int msgget (key_t, int); + int msgrcv (int, void *, size_t, long, int); + int msgsnd (int, const void *, size_t, int); + int msgctl (int, int, struct msqid_ds *); +#endif /* ACE_LACKS_SYSV_MSQ_PROTOS */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#include /**/ "ace/post.h" +#endif /* ACE_OS_INCLUDE_SYS_OS_MSG_H */ diff --git a/dep/ACE_wrappers/ace/os_include/sys/os_pstat.h b/dep/ACE_wrappers/ace/os_include/sys/os_pstat.h new file mode 100644 index 00000000000..dcb3467b623 --- /dev/null +++ b/dep/ACE_wrappers/ace/os_include/sys/os_pstat.h @@ -0,0 +1,42 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file os_pstat.h + * + * pstat functions + * + * $Id: os_pstat.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Johnny Willemsen + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_SYS_OS_PSTAT_H +#define ACE_OS_INCLUDE_SYS_OS_PSTAT_H + +#include /**/ "ace/pre.h" + +#include /**/ "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#if defined (ACE_HAS_SYS_PSTAT_H) +# include /**/ +# include /**/ +#endif /* ACE_HAS_SYS_PSTAT_H */ + +// Place all additions (especially function declarations) within extern "C" {} +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#include /**/ "ace/post.h" +#endif /* ACE_OS_INCLUDE_SYS_OS_PSTAT_H */ diff --git a/dep/ACE_wrappers/ace/os_include/sys/os_resource.h b/dep/ACE_wrappers/ace/os_include/sys/os_resource.h new file mode 100644 index 00000000000..23486b616e2 --- /dev/null +++ b/dep/ACE_wrappers/ace/os_include/sys/os_resource.h @@ -0,0 +1,104 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file os_resource.h + * + * definitions for XSI resource operations + * + * $Id: os_resource.h 81697 2008-05-14 18:33:11Z johnnyw $ + * + * @author Don Hinton + * @author This code was originally in various places including ace/OS.h. + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_SYS_OS_RESOURCE_H +#define ACE_OS_INCLUDE_SYS_OS_RESOURCE_H + +#include /**/ "ace/pre.h" + +#include "ace/config-lite.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/os_include/sys/os_time.h" +#include "ace/os_include/sys/os_types.h" + +#if !defined (ACE_LACKS_SYS_RESOURCE_H) +# include /**/ +#endif /* !ACE_LACKS_SYS_RESOURCE_H */ + +#if defined (ACE_HAS_SYS_SYSTEMINFO_H) +# include /**/ +#endif /* ACE_HAS_SYS_SYSTEMINFO_H */ + +#if defined (ACE_HAS_SYS_SYSCALL_H) +# include /**/ +#endif /* ACE_HAS_SYS_SYSCALL_H */ + +// prusage_t is defined in +#if defined (ACE_HAS_PROC_FS) +# include /**/ +#endif /* ACE_HAS_PROC_FS */ + +// Place all additions (especially function declarations) within extern "C" {} +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +// There must be a better way to do this... +#if !defined (RLIMIT_NOFILE) && !defined (ACE_LACKS_RLIMIT_NOFILE) +# if defined (linux) || defined (AIX) || defined (SCO) +# if defined (RLIMIT_OFILE) +# define RLIMIT_NOFILE RLIMIT_OFILE +# else +# define RLIMIT_NOFILE 200 +# endif /* RLIMIT_OFILE */ +# endif /* defined (linux) || defined (AIX) || defined (SCO) */ +#endif /* RLIMIT_NOFILE */ + +#if defined (ACE_WIN32) +# define RUSAGE_SELF 1 + /// Fake the UNIX rusage structure. Perhaps we can add more to this + /// later on? + struct rusage + { + FILETIME ru_utime; + FILETIME ru_stime; + }; +#endif /* ACE_WIN32 */ + +#if defined (ACE_LACKS_RLIMIT_PROTOTYPE) + int getrlimit (int resource, struct rlimit *rlp); + int setrlimit (int resource, const struct rlimit *rlp); +#endif /* ACE_LACKS_RLIMIT_PROTOTYPE */ + +#if defined (ACE_HAS_PRUSAGE_T) + typedef prusage_t ACE_Rusage; +#elif defined (ACE_HAS_GETRUSAGE) + typedef rusage ACE_Rusage; +#else + typedef int ACE_Rusage; +#endif /* ACE_HAS_PRUSAGE_T */ + +#if !defined (ACE_WIN32) +// These prototypes are chronically lacking from many versions of UNIX. +# if !defined (ACE_HAS_GETRUSAGE_PROTOTYPE) + int getrusage (int who, struct rusage *rusage); +# endif /* ! ACE_HAS_GETRUSAGE_PROTOTYPE */ + +# if defined (ACE_LACKS_SYSCALL) + int syscall (int, ACE_HANDLE, struct rusage *); +# endif /* ACE_LACKS_SYSCALL */ +#endif /* !ACE_WIN32 */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#include /**/ "ace/post.h" +#endif /* ACE_OS_INCLUDE_SYS_OS_RESOURCE_H */ diff --git a/dep/ACE_wrappers/ace/os_include/sys/os_select.h b/dep/ACE_wrappers/ace/os_include/sys/os_select.h new file mode 100644 index 00000000000..26a3fabd776 --- /dev/null +++ b/dep/ACE_wrappers/ace/os_include/sys/os_select.h @@ -0,0 +1,59 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file os_select.h + * + * select types + * + * $Id: os_select.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Don Hinton + * @author This code was originally in various places including ace/OS.h. + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_SYS_OS_SELECT_H +#define ACE_OS_INCLUDE_SYS_OS_SELECT_H + +#include /**/ "ace/pre.h" + +#include "ace/config-lite.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/os_include/sys/os_time.h" +#include "ace/os_include/os_signal.h" +#include "ace/os_include/os_unistd.h" + +#if !defined (ACE_LACKS_SYS_SELECT_H) +# include /**/ +#endif /* !ACE_LACKS_SYS_SELECT_H */ + +#if defined (ACE_VXWORKS) && defined (ACE_LACKS_SYS_SELECT_H) +# include /**/ +#endif /* ACE_VXWORKS */ + +// Place all additions (especially function declarations) within extern "C" {} +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +#if defined (ACE_WIN32) + // This will help until we figure out everything: +# define NFDBITS 32 /* only used in unused functions... */ +#elif defined (__QNX__) +# if !defined (NFDBITS) +# define NFDBITS (sizeof(fd_mask) * NBBY) /* bits per mask */ +# endif /* ! NFDBITS */ +#endif /* ACE_WIN32 */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#include /**/ "ace/post.h" +#endif /* ACE_OS_INCLUDE_SYS_OS_SELECT_H */ diff --git a/dep/ACE_wrappers/ace/os_include/sys/os_sem.h b/dep/ACE_wrappers/ace/os_include/sys/os_sem.h new file mode 100644 index 00000000000..926092b7d06 --- /dev/null +++ b/dep/ACE_wrappers/ace/os_include/sys/os_sem.h @@ -0,0 +1,90 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file os_sem.h + * + * XSI semaphore facility + * + * $Id: os_sem.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Don Hinton + * @author This code was originally in various places including ace/OS.h. + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_SYS_OS_SEM_H +#define ACE_OS_INCLUDE_SYS_OS_SEM_H + +#include /**/ "ace/pre.h" + +#include "ace/config-lite.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/os_include/sys/os_ipc.h" + +#if !defined (ACE_LACKS_SYS_SEM_H) +# include /**/ +#endif /* !ACE_LACKS_SYS_SEM_H */ + +// Place all additions (especially function declarations) within extern "C" {} +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +# if !defined (GETVAL) +# define GETVAL 0 +# endif /* GETVAL */ + +# if !defined (SETVAL) +# define SETVAL 0 +# endif /* SETVAL */ + +# if !defined (GETALL) +# define GETALL 0 +# endif /* GETALL */ + +# if !defined (SETALL) +# define SETALL 0 +# endif /* SETALL */ + +# if !defined (SEM_UNDO) +# define SEM_UNDO 0 +# endif /* SEM_UNDO */ + +#if defined (ACE_LACKS_SEMBUF_T) + struct sembuf + { + /// semaphore # + unsigned short sem_num; + + /// semaphore operation + short sem_op; + + /// operation flags + short sem_flg; + }; +#endif /* ACE_LACKS_SEMBUF_T */ + +#if !defined (ACE_HAS_SEMUN) || (defined (__GLIBC__) && defined (_SEM_SEMUN_UNDEFINED)) + union semun + { + /// value for SETVAL + int val; + /// buffer for IPC_STAT & IPC_SET + struct semid_ds *buf; + /// array for GETALL & SETALL + u_short *array; + }; +#endif /* !ACE_HAS_SEMUN || (defined (__GLIBC__) && defined (_SEM_SEMUN_UNDEFINED)) */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#include /**/ "ace/post.h" +#endif /* ACE_OS_INCLUDE_SYS_OS_SEM_H */ diff --git a/dep/ACE_wrappers/ace/os_include/sys/os_shm.h b/dep/ACE_wrappers/ace/os_include/sys/os_shm.h new file mode 100644 index 00000000000..79d502fec0d --- /dev/null +++ b/dep/ACE_wrappers/ace/os_include/sys/os_shm.h @@ -0,0 +1,48 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file os_shm.h + * + * XSI shared memory facility + * + * $Id: os_shm.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Don Hinton + * @author This code was originally in various places including ace/OS.h. + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_SYS_OS_SHM_H +#define ACE_OS_INCLUDE_SYS_OS_SHM_H + +#include /**/ "ace/pre.h" + +#include "ace/config-lite.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/os_include/sys/os_ipc.h" + +#if !defined (ACE_LACKS_SYS_SHM_H) +# include /**/ +#endif /* !ACE_LACKS_SYS_SHM_H */ + +// Place all additions (especially function declarations) within extern "C" {} +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + + // Declare opaque type. Needed for ACE_OS wrappers on systems + // without SysV IPC. + struct shmid_ds; + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#include /**/ "ace/post.h" +#endif /* ACE_OS_INCLUDE_SYS_OS_SHM_H */ diff --git a/dep/ACE_wrappers/ace/os_include/sys/os_socket.h b/dep/ACE_wrappers/ace/os_include/sys/os_socket.h new file mode 100644 index 00000000000..f70fee9dfd6 --- /dev/null +++ b/dep/ACE_wrappers/ace/os_include/sys/os_socket.h @@ -0,0 +1,307 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file os_socket.h + * + * main sockets header + * + * $Id: os_socket.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Don Hinton + * @author This code was originally in various places including ace/OS.h. + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_SYS_OS_SOCKET_H +#define ACE_OS_INCLUDE_SYS_OS_SOCKET_H + +#include /**/ "ace/pre.h" + +#include "ace/config-lite.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/os_include/sys/os_uio.h" + +#if !defined (ACE_LACKS_SYS_SOCKET_H) +# include /**/ +#endif /* !ACE_LACKS_SYS_SOCKET_H */ + +#if defined (ACE_VXWORKS) && (ACE_VXWORKS < 0x620) +# include /**/ +#endif /* ACE_VXWORKS */ + +// Place all additions (especially function declarations) within extern "C" {} +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +#if !defined (ACE_HAS_MSG) && !defined (SCO) + struct msghdr {}; +#endif /* ACE_HAS_MSG */ + +#if defined (ACE_HAS_MSG) && defined (ACE_LACKS_MSG_ACCRIGHTS) +# if !defined (msg_accrights) +# undef msg_control +# define msg_accrights msg_control +# endif /* ! msg_accrights */ + +# if !defined (msg_accrightslen) +# undef msg_controllen +# define msg_accrightslen msg_controllen +# endif /* ! msg_accrightslen */ +#endif /* ACE_HAS_MSG && ACE_LACKS_MSG_ACCRIGHTS */ + +# if defined (ACE_LACKS_SOCKADDR) + struct sockaddr { + u_char sa_len; /* total length */ + u_char sa_family; /* address family */ + char sa_data[14]; /* actually longer; address value */ + }; +# endif /* ACE_LACKS_SOCKADDR */ + +# if defined (ACE_LACKS_LINGER) + struct linger { + int l_onoff; /* option on/off */ + int l_linger; /* linger time */ + }; +# endif /* ACE_LACKS_LINGER */ + +#if defined (ACE_WIN32) + struct msghdr + { + /// Optional address + sockaddr * msg_name; + + /// Size of address + int msg_namelen; + + /// Scatter/gather array + iovec *msg_iov; + + /// # elements in msg_iov + int msg_iovlen; + + /// Access rights sent/received + caddr_t msg_accrights; + + int msg_accrightslen; + }; +#endif /* ACE_WIN32 */ + +#if defined (ACE_HAS_4_4BSD_SENDMSG_RECVMSG) + // Control message size to pass a file descriptor. +# define ACE_BSD_CONTROL_MSG_LEN sizeof (struct cmsghdr) + sizeof (ACE_HANDLE) +#endif /* ACE_HAS_4_4BSD_SENDMSG_RECVMSG */ + +// Increase the range of "address families". Please note that this +// must appear _after_ the include of sys/socket.h, for the AF_FILE +// definition on Linux/glibc2. +#if !defined (AF_ANY) +# define AF_ANY (-1) +#endif /* AF_ANY */ + +#if !defined (AF_UNSPEC) +# define AF_UNSPEC 0 +#endif /* AF_UNSPEC */ + +#if !defined (AF_LOCAL) +# define AF_LOCAL 1 +#endif /* AF_LOCAL */ + +#if !defined (AF_UNIX) +# define AF_UNIX AF_LOCAL +#endif /* AF_UNIX */ + +#if !defined (AF_INET) +# define AF_INET 2 +#endif /* AF_INET */ + +#if !defined (PF_INET) +# define PF_INET AF_INET +#endif /* PF_INET */ + +#if !defined (PF_LOCAL) +# define PF_LOCAL AF_LOCAL +#endif /* PF_LOCAL */ + +#if !defined (PF_UNIX) +# define PF_UNIX PF_LOCAL +#endif /* PF_UNIX */ + +#if !defined (AF_MAX) +# define AF_MAX 29 +#endif /* AF_MAX */ + +#if !defined (PF_UNSPEC) +# define PF_UNSPEC 0 +#endif /* PF_UNSPEC */ + +#define AF_SPIPE (AF_MAX + 1) +#if !defined (AF_FILE) +# define AF_FILE (AF_MAX + 2) +#endif /* ! AF_FILE */ +#define AF_DEV (AF_MAX + 3) +#define AF_UPIPE (AF_SPIPE) + +#if !defined (MSG_OOB) +# define MSG_OOB 0x1 +#endif /* MSG_OOB */ + +#if !defined (MSG_PEEK) +# define MSG_PEEK 0x2 +#endif /* MSG_PEEK */ + +#if !defined (SOCK_STREAM) +# define SOCK_STREAM 1 +#endif /* SOCK_STREAM */ + +#if !defined (SOCK_DGRAM) +# define SOCK_DGRAM 2 +#endif /* SOCK_DGRAM */ + +#if !defined (SOCK_SEQPACKET) +# define SOCK_SEQPACKET 5 +#endif /* SOCK_SEQPACKET */ + +#if !defined (SOL_SOCKET) +# define SOL_SOCKET 0xffff +#endif /* SOL_SOCKET */ + +#if !defined (SO_REUSEADDR) +# define SO_REUSEADDR 0x0004 +#endif /* SO_REUSEADDR */ + +#if !defined (SO_LINGER) +# define SO_LINGER 0x0080 +#endif /* SO_LINGER */ + +#if !defined (SO_SNDBUF) +# define SO_SNDBUF 0x1001 +#endif /* SO_SNDBUF */ + +#if !defined (SO_RCVBUF) +# define SO_RCVBUF 0x1002 +#endif /* SO_RCVBUF */ + +#if !defined (SO_BROADCAST) +# define SO_BROADCAST 0x0020 +#endif /* SO_BROADCAST */ + +#if !defined (SO_ERROR) +# define SO_ERROR 0x1007 +#endif /* SO_ERROR */ + +#if !defined (SCM_RIGHTS) +# define SCM_RIGHTS 0x01 +#endif /* SCM_RIGHTS */ + +#if defined (ACE_HAS_IPV6) +# if defined (ACE_USES_IPV4_IPV6_MIGRATION) +# define ACE_ADDRESS_FAMILY_INET AF_UNSPEC +# define ACE_PROTOCOL_FAMILY_INET PF_UNSPEC +# else +# define ACE_ADDRESS_FAMILY_INET AF_INET6 +# define ACE_PROTOCOL_FAMILY_INET PF_INET6 +# endif /* ACE_USES_IPV4_IPV6_MIGRATION */ +#else /* !ACE_HAS_IPV6 */ +# define ACE_ADDRESS_FAMILY_INET AF_INET +# define ACE_PROTOCOL_FAMILY_INET PF_INET +#endif /* ACE_HAS_IPV6 */ + +#if !defined (ACE_HAS_SOCK_BUF_SIZE_MAX_VALUE) +#define ACE_HAS_SOCK_BUF_SIZE_MAX_VALUE SSIZE_MAX +#endif /* ACE_HAS_SOCK_BUF_SIZE_MAX_VALUE */ + +#if defined (ACE_HAS_SOCKLEN_T) +# if defined (__hpux) + /* + ** HP-UX supplies the socklen_t type unless some feature set less than + ** _XOPEN_SOURCE_EXTENDED is specifically requested. However, it only + ** actually uses the socklen_t type in supplied socket functions if + ** _XOPEN_SOURCE_EXTENDED is specifically requested. So, for example, + ** the compile options ACE usually uses (includes -mt) cause _HPUX_SOURCE + ** to be set, which sets _INCLUDE_XOPEN_SOURCE_EXTENDED (causing socklen_t + ** to be defined) but _not_ _XOPEN_SOURCE_EXTENDED (causing socket functions + ** to use int, not socklen_t). React to this situation here... + */ +# if defined (_XOPEN_SOURCE_EXTENDED) +typedef socklen_t ACE_SOCKET_LEN; +# else +typedef int ACE_SOCKET_LEN; +# endif /* _XOPEN_SOURCE_EXTENDED */ +# else +typedef socklen_t ACE_SOCKET_LEN; +# endif /* __hpux */ +#elif defined (ACE_HAS_SIZET_SOCKET_LEN) +typedef size_t ACE_SOCKET_LEN; +#else +typedef int ACE_SOCKET_LEN; +#endif /* ACE_HAS_SIZET_SOCKET_LEN */ + +#if defined (ACE_HAS_NETLINK) +# include /**/ +# include /**/ +# define ACE_PROTOCOL_FAMILY_NETLINK AF_NETLINK +#endif + +#if defined (ACE_HAS_LKSCTP) +extern "C" +{ +#include /**/ +#include /**/ +} +#endif /* ACE_HAS_LKSCTP */ + +# if defined (ACE_LACKS_TIMEDWAIT_PROTOTYPES) + + ssize_t recv_timedwait (ACE_HANDLE handle, + char *buf, + int len, + int flags, + struct timespec *timeout); + + ssize_t recvmsg_timedwait (ACE_HANDLE handle, + struct msghdr *msg, + int flags, + struct timespec *timeout); + + ssize_t recvfrom_timedwait (ACE_HANDLE handle, + char *buf, + int len, + int flags, + struct sockaddr *addr, + int *addrlen, + struct timespec *timeout); + + ssize_t send_timedwait (ACE_HANDLE handle, + const char *buf, + int len, + int flags, + struct timespec *timeout); + + ssize_t sendmsg_timedwait (ACE_HANDLE handle, + const struct msghdr *msg, + int flags, + struct timespec *timeout); + + ssize_t sendto_timedwait (ACE_HANDLE handle, + const char *buf, + int len, + int flags, + const struct sockaddr *addr, + int addrlen, + struct timespec *timeout); + +# endif /* ACE_LACKS_TIMEDWAIT_PROTOTYPES */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#include /**/ "ace/post.h" +#endif /* ACE_OS_INCLUDE_SYS_OS_SOCKET_H */ diff --git a/dep/ACE_wrappers/ace/os_include/sys/os_stat.h b/dep/ACE_wrappers/ace/os_include/sys/os_stat.h new file mode 100644 index 00000000000..a6ad4eeafd6 --- /dev/null +++ b/dep/ACE_wrappers/ace/os_include/sys/os_stat.h @@ -0,0 +1,127 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file os_stat.h + * + * data returned by the stat() function + * + * $Id: os_stat.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Don Hinton + * @author This code was originally in various places including ace/OS.h. + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_SYS_OS_STAT_H +#define ACE_OS_INCLUDE_SYS_OS_STAT_H + +#include /**/ "ace/pre.h" + +#include "ace/config-lite.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/os_include/sys/os_types.h" + +#if defined (ACE_WIN32) && !defined (ACE_HAS_WINCE) +# include /**/ +#endif /* ACE_WIN32 && !ACE_HAS_WINCE */ + +#if !defined (ACE_LACKS_SYS_STAT_H) +# include /**/ +#endif /* !ACE_LACKS_SYS_STAT_H */ + +// Place all additions (especially function declarations) within extern "C" {} +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +#if defined (ACE_LACKS_MODE_MASKS) +// MODE MASKS + +// the following macros are for POSIX conformance. + +# if !defined (ACE_HAS_USER_MODE_MASKS) +# define S_IRWXU 00700 /* read, write, execute: owner. */ +# define S_IRUSR 00400 /* read permission: owner. */ +# define S_IWUSR 00200 /* write permission: owner. */ +# define S_IXUSR 00100 /* execute permission: owner. */ +# endif /* ACE_HAS_USER_MODE_MASKS */ +# define S_IRWXG 00070 /* read, write, execute: group. */ +# define S_IRGRP 00040 /* read permission: group. */ +# define S_IWGRP 00020 /* write permission: group. */ +# define S_IXGRP 00010 /* execute permission: group. */ +# define S_IRWXO 00007 /* read, write, execute: other. */ +# define S_IROTH 00004 /* read permission: other. */ +# define S_IWOTH 00002 /* write permission: other. */ +# define S_IXOTH 00001 /* execute permission: other. */ + +// WinCE's S_IFLNK is defined with the other bits, below. +#if !defined (S_IFLNK) && !defined (ACE_HAS_WINCE) +#define S_IFLNK 0200000 +#endif /* S_IFLNK && !ACE_HAS_WINCE */ + +#endif /* ACE_LACKS_MODE_MASKS */ + +// Some systems (VxWorks) don't define S_ISLNK +#if !defined (S_ISLNK) +# if defined (S_IFLNK) +# define S_ISLNK(mode) (((mode)&S_IFLNK) == S_IFLNK) +# else +# define S_ISLNK(mode) 0 +# endif /* S_IFLNK */ +#endif /* S_ISLNK */ + +#if defined (ACE_HAS_WINCE) +# include "ace/Time_Value.h" + +// Translate the WinCE bits into names expected by our callers. +// The dwFileAttributes parameter doesn't have protection info, so +// S_IFMT is the whole thing. Since there are no symbolic links, S_IFLNK is 0. +# define S_IFMT 0xFFFF +# define S_IFDIR FILE_ATTRIBUTE_DIRECTORY +# define S_IFREG FILE_ATTRIBUTE_NORMAL +# define S_IFLNK 0 + + struct stat + { + /// always 0 on Windows platforms + dev_t st_dev; + + /// always 0 on Windows platforms + dev_t st_rdev; + + /// file attribute + unsigned short st_mode; + + /// number of hard links + short st_nlink; + + /// time of last access + ACE_Time_Value st_atime; + + /// time of last data modification + ACE_Time_Value st_mtime; + + /// time of creation + ACE_Time_Value st_ctime; + + /// file size, in bytes + ACE_OFF_T st_size; + + // Following members do not have direct conversion in Window platforms. + //u_long st_blksize; // optimal blocksize for I/O + //u_long st_flags; // user defined flags for file + }; +#endif /* ACE_HAS_WINCE */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#include /**/ "ace/post.h" +#endif /* ACE_OS_INCLUDE_SYS_OS_STAT_H */ diff --git a/dep/ACE_wrappers/ace/os_include/sys/os_statvfs.h b/dep/ACE_wrappers/ace/os_include/sys/os_statvfs.h new file mode 100644 index 00000000000..7988c4f5060 --- /dev/null +++ b/dep/ACE_wrappers/ace/os_include/sys/os_statvfs.h @@ -0,0 +1,42 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file os_statvfs.h + * + * VFS File System information structure + * + * $Id: os_statvfs.h 81692 2008-05-14 12:25:02Z johnnyw $ + * + * @author Don Hinton + * @author This code was originally in various places including ace/OS.h. + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_SYS_OS_STATVFS_H +#define ACE_OS_INCLUDE_SYS_OS_STATVFS_H + +#include /**/ "ace/pre.h" + +#include "ace/config-lite.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#if !defined (ACE_LACKS_SYS_STATVFS_H) +# include /**/ +#endif /* !ACE_LACKS_SYS_STATVFS_H */ + +// Place all additions (especially function declarations) within extern "C" {} +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#include /**/ "ace/post.h" +#endif /* ACE_OS_INCLUDE_SYS_OS_STATVFS_H */ diff --git a/dep/ACE_wrappers/ace/os_include/sys/os_sysctl.h b/dep/ACE_wrappers/ace/os_include/sys/os_sysctl.h new file mode 100644 index 00000000000..ee51cd7db65 --- /dev/null +++ b/dep/ACE_wrappers/ace/os_include/sys/os_sysctl.h @@ -0,0 +1,41 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file os_sysctl.h + * + * declarations for sysctl + * + * $Id: os_sysctl.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Johnny Willemsen + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_SYS_OS_SYSCTL_H +#define ACE_OS_INCLUDE_SYS_OS_SYSCTL_H + +#include /**/ "ace/pre.h" + +#include "ace/config-lite.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#if !defined (ACE_LACKS_SYS_SYSCTL_H) +# include /**/ +#endif /* !ACE_LACKS_SYS_SYSCTL_H */ + +// Place all additions (especially function declarations) within extern "C" {} +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#include /**/ "ace/post.h" +#endif /* ACE_OS_INCLUDE_SYS_OS_SYSCTL_H */ diff --git a/dep/ACE_wrappers/ace/os_include/sys/os_sysinfo.h b/dep/ACE_wrappers/ace/os_include/sys/os_sysinfo.h new file mode 100644 index 00000000000..7aca1f44d1f --- /dev/null +++ b/dep/ACE_wrappers/ace/os_include/sys/os_sysinfo.h @@ -0,0 +1,39 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file os_sysinfo.h + * + * $Id: os_sysinfo.h 81692 2008-05-14 12:25:02Z johnnyw $ + * + * @author Johnny Willemsen + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_SYS_OS_SYSINFO_H +#define ACE_OS_INCLUDE_SYS_OS_SYSINFO_H + +#include /**/ "ace/pre.h" + +#include "ace/config-lite.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#if defined (ACE_HAS_SYS_SYSINFO_H) +# include /**/ +#endif /* ACE_HAS_SYS_SYSINFO_H */ + +// Place all additions (especially function declarations) within extern "C" {} +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#include /**/ "ace/post.h" +#endif /* ACE_OS_INCLUDE_SYS_OS_SYSINFO_H */ diff --git a/dep/ACE_wrappers/ace/os_include/sys/os_time.h b/dep/ACE_wrappers/ace/os_include/sys/os_time.h new file mode 100644 index 00000000000..4c6fdce763b --- /dev/null +++ b/dep/ACE_wrappers/ace/os_include/sys/os_time.h @@ -0,0 +1,60 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file os_time.h + * + * time types + * + * $Id: os_time.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Don Hinton + * @author This code was originally in various places including ace/OS.h. + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_SYS_OS_TIME_H +#define ACE_OS_INCLUDE_SYS_OS_TIME_H + +#include /**/ "ace/pre.h" + +#include "ace/config-lite.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/os_include/sys/os_types.h" + +#if !defined (ACE_LACKS_SYS_TIME_H) +# include /**/ +#endif /* !ACE_LACKS_SYS_TIME_H */ + +#if defined (ACE_VXWORKS) && (ACE_VXWORKS == 0x620) +# include /**/ // VxWorks 6.2 defined timeval in time.h +#endif + +// Place all additions (especially function declarations) within extern "C" {} +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +#if defined (ACE_HAS_SVR4_GETTIMEOFDAY) +# if !defined (SCO) + int gettimeofday (struct timeval *tp, void * = 0); +# else + int gettimeofday (struct timeval *tp); +# endif /* !SCO */ +#elif defined (ACE_HAS_OSF1_GETTIMEOFDAY) + int gettimeofday (struct timeval *tp, struct timezone * = 0); +#elif defined (ACE_HAS_VOIDPTR_GETTIMEOFDAY) +# define ACE_HAS_SVR4_GETTIMEOFDAY +#endif /* ACE_HAS_SVR4_GETTIMEOFDAY */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#include /**/ "ace/post.h" +#endif /* ACE_OS_INCLUDE_SYS_OS_TIME_H */ diff --git a/dep/ACE_wrappers/ace/os_include/sys/os_timeb.h b/dep/ACE_wrappers/ace/os_include/sys/os_timeb.h new file mode 100644 index 00000000000..e276ba8bbd9 --- /dev/null +++ b/dep/ACE_wrappers/ace/os_include/sys/os_timeb.h @@ -0,0 +1,49 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file os_timeb.h + * + * additional definitions for date and time + * + * $Id: os_timeb.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Don Hinton + * @author This code was originally in various places including ace/OS.h. + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_SYS_OS_TIMEB_H +#define ACE_OS_INCLUDE_SYS_OS_TIMEB_H + +#include /**/ "ace/pre.h" + +#include "ace/config-lite.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/os_include/sys/os_types.h" + +#if !defined (ACE_LACKS_SYS_TIMEB_H) +# include /**/ +#endif /* !ACE_LACKS_SYS_TIMEB_H */ + +// Place all additions (especially function declarations) within extern "C" {} +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +#if defined (__BORLANDC__) && (__BORLANDC__ <= 0x560) +# define _ftime ftime +# define _timeb timeb +#endif /* __BORLANDC__ */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#include /**/ "ace/post.h" +#endif /* ACE_OS_INCLUDE_SYS_OS_TIMEB_H */ diff --git a/dep/ACE_wrappers/ace/os_include/sys/os_times.h b/dep/ACE_wrappers/ace/os_include/sys/os_times.h new file mode 100644 index 00000000000..617b416ec56 --- /dev/null +++ b/dep/ACE_wrappers/ace/os_include/sys/os_times.h @@ -0,0 +1,44 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file os_times.h + * + * file access and modification times structure + * + * $Id: os_times.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Don Hinton + * @author This code was originally in various places including ace/OS.h. + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_SYS_OS_TIMES_H +#define ACE_OS_INCLUDE_SYS_OS_TIMES_H + +#include /**/ "ace/pre.h" + +#include "ace/config-lite.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/os_include/sys/os_types.h" + +#if !defined (ACE_LACKS_SYS_TIMES_H) +# include /**/ +#endif /* !ACE_LACKS_SYS_TIMES_H */ + +// Place all additions (especially function declarations) within extern "C" {} +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#include /**/ "ace/post.h" +#endif /* ACE_OS_INCLUDE_SYS_OS_TIMES_H */ diff --git a/dep/ACE_wrappers/ace/os_include/sys/os_types.h b/dep/ACE_wrappers/ace/os_include/sys/os_types.h new file mode 100644 index 00000000000..794faf86d01 --- /dev/null +++ b/dep/ACE_wrappers/ace/os_include/sys/os_types.h @@ -0,0 +1,158 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file os_types.h + * + * data types + * + * $Id: os_types.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Don Hinton + * @author This code was originally in various places including ace/OS.h. + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_SYS_OS_TYPES_H +#define ACE_OS_INCLUDE_SYS_OS_TYPES_H + +#include /**/ "ace/pre.h" + +#include "ace/config-lite.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/os_include/os_stddef.h" + +#if !defined (ACE_LACKS_SYS_TYPES_H) +# include /**/ +#endif /* !ACE_LACKS_SYS_TYPES_H */ + +#if defined (ACE_HAS_WINCE) +# include /**/ +#endif /* ACE_HAS_WINCE */ + +# if defined (ACE_USES_STD_NAMESPACE_FOR_STDC_LIB) && \ + (ACE_USES_STD_NAMESPACE_FOR_STDC_LIB != 0) +using std::time_t; +# endif /* ACE_USES_STD_NAMESPACE_FOR_STDC_LIB */ + +// Place all additions (especially function declarations) within extern "C" {} +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +typedef double ACE_timer_t; + +// todo: don't forget to clean this up! ;-) +#if !defined (ACE_HAS_CLOCK_GETTIME) && !(defined (_CLOCKID_T_) || defined (_CLOCKID_T)) + typedef int clockid_t; +# if !defined (CLOCK_REALTIME) +# define CLOCK_REALTIME 0 +# endif /* CLOCK_REALTIME */ +#endif /* ! ACE_HAS_CLOCK_GETTIME && ! _CLOCKID_T_ */ + +#if defined (ACE_HAS_WINCE) + +// CE's add-on for c-style fstat/stat functionalities. This struct is +// by no mean complete compared to what you usually find in UNIX +// platforms. Only members that have direct conversion using Win32's +// BY_HANDLE_FILE_INFORMATION are defined so that users can discover +// non-supported members at compile time. Time values are of type +// ACE_Time_Value for easy comparison. + +// Since CE does not have _stat by default as NT/2000 does, the 'stat' +// struct defined here will be used. Also note that CE file system +// struct is only for the CE 3.0 or later. +// Refer to the WCHAR.H from Visual C++ and WIBASE.H from eVC 3.0. + + typedef unsigned int dev_t; +#endif /* ACE_HAS_WINCE */ + +#if defined(ACE_WIN32) && defined(_FILE_OFFSET_BITS) && (_FILE_OFFSET_BITS==64) + typedef __int64 ACE_OFF_T; +#else + typedef off_t ACE_OFF_T; +#endif + +#if defined (ACE_SIZEOF_LONG) && ACE_SIZEOF_LONG == 8 + typedef off_t ACE_LOFF_T; +#elif defined (ACE_HAS_RTEMS) || defined (__FreeBSD__) || defined (__NetBSD__) || defined (__OpenBSD__) || defined (__APPLE__) || \ + (defined (ACE_OPENVMS) && defined (_LARGEFILE)) || defined(ACE_MVS) + typedef off_t ACE_LOFF_T; +#elif defined (__sgi) || defined (AIX) || defined (HPUX) || defined (__QNX__) + typedef off64_t ACE_LOFF_T; +#elif defined (__sun) + typedef offset_t ACE_LOFF_T; +#elif defined (WIN32) + typedef __int64 ACE_LOFF_T; +#elif (defined (ACE_VXWORKS) && (ACE_VXWORKS <= 0x660)) || \ + defined (ACE_LYNXOS_MAJOR) || \ + (defined (ACE_OPENVMS) && !defined (_LARGEFILE)) || \ + defined (__TANDEM) + typedef long long ACE_LOFF_T; +#else + typedef loff_t ACE_LOFF_T; +#endif + +#if defined (ACE_WIN32) +# if !defined (__BORLANDC__) + typedef DWORD nlink_t; +# if !defined(__MINGW32__) + typedef int mode_t; +# endif /* !__MINGW32__ */ + typedef long uid_t; + typedef long gid_t; +# endif /* __BORLANDC__ */ + typedef char *caddr_t; +#endif /* ACE_WIN32 */ + +#if defined (ACE_LACKS_KEY_T) +# if defined (ACE_WIN32) + // Win32 doesn't use numeric values to name its semaphores, it uses + // strings! + typedef char *key_t; +# else + typedef int key_t; +# endif /* ACE_WIN32 */ +#endif /* ACE_LACKS_KEY_T */ + +#if !defined (ACE_HAS_SSIZE_T) +# if defined (ACE_WIN64) + typedef SSIZE_T ssize_t; +# else + typedef int ssize_t; +# endif /* ACE_WIN64 */ +#endif /* ACE_HAS_SSIZE_T */ + +#if defined (ACE_WIN32) + typedef DWORD ACE_exitcode; +#else + typedef int ACE_exitcode; +#endif /* ACE_WIN32 */ + +#if defined (ACE_LACKS_SUSECONDS_T) + typedef long suseconds_t; +#endif + +#if defined (ACE_LACKS_USECONDS_T) + typedef unsigned long useconds_t; +#endif + +#if defined (ACE_WIN32) && !defined(__MINGW32__) + typedef int pid_t; +#endif /* ACE_WIN32 */ + +# if !defined (ACE_INVALID_PID) +# define ACE_INVALID_PID ((pid_t) -1) +# endif /* ACE_INVALID_PID */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#include /**/ "ace/post.h" +#endif /* ACE_OS_INCLUDE_SYS_OS_TYPES_H */ diff --git a/dep/ACE_wrappers/ace/os_include/sys/os_uio.h b/dep/ACE_wrappers/ace/os_include/sys/os_uio.h new file mode 100644 index 00000000000..7baaec57e75 --- /dev/null +++ b/dep/ACE_wrappers/ace/os_include/sys/os_uio.h @@ -0,0 +1,77 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file os_uio.h + * + * definitions for vector I/O operations + * + * $Id: os_uio.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Don Hinton + * @author This code was originally in various places including ace/OS.h. + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_SYS_OS_UIO_H +#define ACE_OS_INCLUDE_SYS_OS_UIO_H + +#include /**/ "ace/pre.h" + +#include "ace/config-lite.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/os_include/sys/os_types.h" +#include "ace/os_include/os_limits.h" + +#if !defined (ACE_LACKS_SYS_UIO_H) +# include /**/ +#endif /* !ACE_LACKS_SYS_UIO_H */ + +// Place all additions (especially function declarations) within extern "C" {} +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +#if defined (ACE_LACKS_IOVEC) + /// The ordering of the fields in this struct is important. It has to + /// match those in WSABUF. + struct iovec + { + /// byte count to read/write + u_long iov_len; + /// data to be read/written + char *iov_base; + + // WSABUF is a Winsock2-only type. +# if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) + operator WSABUF &(void) { return *((WSABUF *) this); } +# endif /* defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) */ + }; +#endif /* ACE_LACKS_IOVEC */ + + +# if defined (ACE_LACKS_TIMEDWAIT_PROTOTYPES) + + ssize_t readv_timedwait (ACE_HANDLE handle, + const iovec *iov, + int iovcnt, + struct timespec* timeout); + + ssize_t writev_timedwait (ACE_HANDLE handle, + const iovec *iov, + int iovcnt, + struct timespec *timeout); + +# endif /* ACE_LACKS_TIMEDWAIT_PROTOTYPES */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#include /**/ "ace/post.h" +#endif /* ACE_OS_INCLUDE_SYS_OS_UIO_H */ diff --git a/dep/ACE_wrappers/ace/os_include/sys/os_un.h b/dep/ACE_wrappers/ace/os_include/sys/os_un.h new file mode 100644 index 00000000000..6fe6ec6e1ef --- /dev/null +++ b/dep/ACE_wrappers/ace/os_include/sys/os_un.h @@ -0,0 +1,52 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file os_un.h + * + * definitions for UNIX domain sockets + * + * $Id: os_un.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Don Hinton + * @author This code was originally in various places including ace/OS.h. + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_SYS_OS_UN_H +#define ACE_OS_INCLUDE_SYS_OS_UN_H + +#include /**/ "ace/pre.h" + +#include "ace/config-lite.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/os_include/sys/os_socket.h" + +#if !defined (ACE_LACKS_SYS_UN_H) +# include /**/ +#endif /* !ACE_LACKS_SYS_UN_H */ + +// Place all additions (especially function declarations) within extern "C" {} +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +#if defined (ACE_VXWORKS) && (ACE_VXWORKS <= 0x600) +struct sockaddr_un { + short sun_family; // AF_UNIX. + char sun_path[108]; // path name. +}; +#endif /* ACE_VXWORKS */ + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#include /**/ "ace/post.h" +#endif /* ACE_OS_INCLUDE_SYS_OS_UN_H */ diff --git a/dep/ACE_wrappers/ace/os_include/sys/os_utsname.h b/dep/ACE_wrappers/ace/os_include/sys/os_utsname.h new file mode 100644 index 00000000000..d78d1e3463a --- /dev/null +++ b/dep/ACE_wrappers/ace/os_include/sys/os_utsname.h @@ -0,0 +1,42 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file os_utsname.h + * + * system name structure + * + * $Id: os_utsname.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Don Hinton + * @author This code was originally in various places including ace/OS.h. + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_SYS_OS_UTSNAME_H +#define ACE_OS_INCLUDE_SYS_OS_UTSNAME_H + +#include /**/ "ace/pre.h" + +#include "ace/config-lite.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#if !defined (ACE_LACKS_SYS_UTSNAME_H) +# include /**/ +#endif /* !ACE_LACKS_SYS_UTSNAME_H */ + +// Place all additions (especially function declarations) within extern "C" {} +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#include /**/ "ace/post.h" +#endif /* ACE_OS_INCLUDE_SYS_OS_UTSNAME_H */ diff --git a/dep/ACE_wrappers/ace/os_include/sys/os_wait.h b/dep/ACE_wrappers/ace/os_include/sys/os_wait.h new file mode 100644 index 00000000000..b7a219ac82e --- /dev/null +++ b/dep/ACE_wrappers/ace/os_include/sys/os_wait.h @@ -0,0 +1,97 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file os_wait.h + * + * declarations for waiting + * + * $Id: os_wait.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Don Hinton + * @author This code was originally in various places including ace/OS.h. + */ +//============================================================================= + +#ifndef ACE_OS_INCLUDE_SYS_OS_WAIT_H +#define ACE_OS_INCLUDE_SYS_OS_WAIT_H + +#include /**/ "ace/pre.h" + +#include "ace/config-lite.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/os_include/os_signal.h" +#include "ace/os_include/sys/os_resource.h" + +#if !defined (ACE_LACKS_SYS_WAIT_H) +# include /**/ +#endif /* !ACE_LACKS_SYS_WAIT_H */ + +// Place all additions (especially function declarations) within extern "C" {} +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + + // Wrapping around wait status macros for platforms that + // lack them. + +# if !defined (WCOREDUMP) +# define WCOREDUMP(stat) 0 +# endif /* WCOREDUMP */ + +# if !defined (WNOHANG) +# define WNOHANG 0100 +# endif /* !WNOHANG */ + + // If the value of WIFEXITED(stat) is non-zero, this macro evaluates + // to the exit code that the child process exit(3C), or the value + // that the child process returned from main. Peaceful exit code is + // 0. +# if !defined (WEXITSTATUS) +# define WEXITSTATUS(stat) stat +# endif /* WEXITSTATUS */ + +# if !defined (WIFCONTINUED) +# define WIFCONTINUED(stat) 0 +# endif /* WIFCONTINUED */ + + // Evaluates to a non-zero value if status was returned for a child + // process that terminated normally. 0 means status wasn't + // returned. +# if !defined (WIFEXITED) +# define WIFEXITED(stat) 1 +# endif /* WIFEXITED */ + + // Evaluates to a non-zero value if status was returned for a child + // process that terminated due to the receipt of a signal. 0 means + // status wasnt returned. +# if !defined (WIFSIGNALED) +# define WIFSIGNALED(stat) 0 +# endif /* WIFSIGNALED */ + +# if !defined (WIFSTOPPED) +# define WIFSTOPPED(stat) 0 +# endif /* WIFSTOPPED */ + +# if !defined (WSTOPSIG) +# define WSTOPSIG(stat) 0 +# endif /* WSTOPSIG */ + + // If the value of WIFSIGNALED(stat) is non-zero, this macro + // evaluates to the number of the signal that caused the + // termination of the child process. +# if !defined (WTERMSIG) +# define WTERMSIG(stat) 0 +# endif /* WTERMSIG */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#include /**/ "ace/post.h" +#endif /* ACE_OS_INCLUDE_SYS_OS_WAIT_H */ diff --git a/dep/ACE_wrappers/ace/other.mpb b/dep/ACE_wrappers/ace/other.mpb new file mode 100644 index 00000000000..88adc8fa8d8 --- /dev/null +++ b/dep/ACE_wrappers/ace/other.mpb @@ -0,0 +1,15 @@ +// -*- MPC -*- +// $Id: other.mpb 80826 2008-03-04 14:51:23Z wotte $ + +feature(ace_other) { + Source_Files(ACE_COMPONENTS) { + Local_Name_Space.cpp + Name_Proxy.cpp + Name_Request_Reply.cpp + Name_Space.cpp + Naming_Context.cpp + Registry_Name_Space.cpp + Remote_Name_Space.cpp + NT_Service.cpp + } +} diff --git a/dep/ACE_wrappers/ace/post.h b/dep/ACE_wrappers/ace/post.h new file mode 100644 index 00000000000..c393dfe50aa --- /dev/null +++ b/dep/ACE_wrappers/ace/post.h @@ -0,0 +1,22 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file post.h + * + * $Id: post.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Christopher Kohlhoff + * + * This file restores the original alignment rules. + */ +//============================================================================= + +// No header guard +#if defined (_MSC_VER) +# pragma pack (pop) +#elif defined (__BORLANDC__) +# pragma option pop +# pragma nopushoptwarn +# pragma nopackwarning +#endif diff --git a/dep/ACE_wrappers/ace/pre.h b/dep/ACE_wrappers/ace/pre.h new file mode 100644 index 00000000000..7cc32d8ff30 --- /dev/null +++ b/dep/ACE_wrappers/ace/pre.h @@ -0,0 +1,24 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file pre.h + * + * $Id: pre.h 80826 2008-03-04 14:51:23Z wotte $ + * + * @author Christopher Kohlhoff + * + * This file saves the original alignment rules and changes the alignment + * boundary to ACE's default. + */ +//============================================================================= + +// No header guard +#if defined (_MSC_VER) +# pragma warning (disable:4103) +# pragma pack (push, 8) +#elif defined (__BORLANDC__) +# pragma option push -a8 -b -Ve- -Vx- -w-rvl -w-rch -w-ccc -w-obs -w-aus -w-pia -w-inl -w-sig +# pragma nopushoptwarn +# pragma nopackwarning +#endif diff --git a/dep/ACE_wrappers/ace/streams.h b/dep/ACE_wrappers/ace/streams.h new file mode 100644 index 00000000000..396a67c712e --- /dev/null +++ b/dep/ACE_wrappers/ace/streams.h @@ -0,0 +1,138 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file streams.h + * + * $Id: streams.h 82445 2008-07-28 13:40:01Z johnnyw $ + * + * @author Irfan Pyarali + * + * This file contains the portability ugliness for the Standard C++ + * Library. As implementations of the "standard" emerge, this file + * will need to be updated. + * + * This files deals with the streams includes. + * + * + */ +//============================================================================= + + +#ifndef ACE_STREAMS_H +#define ACE_STREAMS_H +#include /**/ "ace/pre.h" + +#include /**/ "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +// Do this so the #pragma warning in the MSVC headers do not +// affect our #pragma warning settings +#if defined (_MSC_VER) +#pragma warning(push) +#endif /* _MSC_VER*/ + + +#if !defined (ACE_LACKS_IOSTREAM_TOTALLY) + +# if defined (ACE_HAS_STANDARD_CPP_LIBRARY) && \ + (ACE_HAS_STANDARD_CPP_LIBRARY != 0) + +# if defined (_MSC_VER) +# pragma warning(disable: 4018 4114 4146 4245) +# pragma warning(disable: 4663 4664 4665 4511 4512) +# endif /* _MSC_VER */ + +# if defined (ACE_USES_OLD_IOSTREAMS) +# include /**/ +# include /**/ + // This has been commented as it is not needed and causes problems with Qt. + // (brunsch) But has been uncommented since it should be included. Qt + // probably should have some sort of macro that will prevent including this + // when it is used. +# include /**/ +# else +# include /**/ +# include /**/ +# include /**/ +# include /**/ +# include /**/ +# include /**/ +# include /**/ +# endif /* ACE_USES_OLD_IOSTREAMS */ + +# if defined (ACE_USES_STD_NAMESPACE_FOR_STDCPP_LIB) && \ + (ACE_USES_STD_NAMESPACE_FOR_STDCPP_LIB != 0) + +# if !defined (ACE_USES_OLD_IOSTREAMS) + // Make these available in the global name space + using std::ios; + using std::ios_base; + using std::streambuf; + using std::istream; + using std::ostream; + using std::iostream; + using std::filebuf; + using std::ifstream; + using std::ofstream; + using std::fstream; + + using std::cin; + using std::cout; + using std::cerr; + using std::clog; + + using std::endl; + using std::ends; + using std::flush; + + using std::ws; + + using std::resetiosflags; + using std::setfill; + using std::setiosflags; + using std::setprecision; + using std::setw; + + using std::dec; + using std::hex; + using std::oct; +# endif /* ! ACE_USES_OLD_IOSTREAMS */ + +# endif /* ACE_USES_STD_NAMESPACE_FOR_STDCPP_LIB */ + +# if defined (_MSC_VER) +# pragma warning(4: 4018 4114 4146 4245) +# pragma warning(4: 4663 4664 4665 4512 4511) +# endif /* _MSC_VER */ + +# else /* ! ACE_HAS_STANDARD_CPP_LIBRARY */ + +# include /**/ +# include /**/ +# include /**/ + +# if defined (ACE_WIN32) && !defined(__MINGW32__) +# if defined(_MSC_VER) // VSB +# include /**/ +# include /**/ +# include /**/ +# include /**/ +# endif /* _MSC_VER */ +# endif /* ACE_WIN32 && !__MINGW32__ */ + +# endif /* ! ACE_HAS_STANDARD_CPP_LIBRARY */ + +#endif /* ! ACE_LACKS_IOSTREAM_TOTALLY */ + +// Do this so the #pragma warning in the MSVC headers do not +// affect our #pragma warning settings +#if defined (_MSC_VER) +#pragma warning(pop) +#endif /* _MSC_VER */ + +#include /**/ "ace/post.h" +#endif /* ACE_STREAMS_H */ diff --git a/dep/ACE_wrappers/ace/svc_export.h b/dep/ACE_wrappers/ace/svc_export.h new file mode 100644 index 00000000000..e84907b6e38 --- /dev/null +++ b/dep/ACE_wrappers/ace/svc_export.h @@ -0,0 +1,44 @@ +// -*- C++ -*- +// $Id: svc_export.h 80826 2008-03-04 14:51:23Z wotte $ +// Definition for Win32 Export directives. + +// This file was generated by generate_export_file.pl +// but needed to be altered to support ACE_BUILD_SVC_DLL +// instead of ACE_SVC_BUILD_DLL which was already being +// used. + +// ------------------------------ +#if !defined (ACE_SVC_EXPORT_H) +#define ACE_SVC_EXPORT_H + +#include /**/ "ace/config-all.h" + +#if defined (ACE_AS_STATIC_LIBS) && !defined (ACE_SVC_HAS_DLL) +# define ACE_SVC_HAS_DLL 0 +#endif /* ACE_AS_STATIC_LIBS && ACE_SVC_HAS_DLL */ + +#if !defined (ACE_SVC_HAS_DLL) +#define ACE_SVC_HAS_DLL 1 +#endif /* ! ACE_SVC_HAS_DLL */ + +#if defined (ACE_SVC_HAS_DLL) +# if (ACE_SVC_HAS_DLL == 1) +# if defined (ACE_BUILD_SVC_DLL) || defined (ACE_SVC_BUILD_DLL) +# define ACE_Svc_Export ACE_Proper_Export_Flag +# define ACE_SVC_SINGLETON_DECLARATION(T) ACE_EXPORT_SINGLETON_DECLARATION (T) +# else +# define ACE_Svc_Export ACE_Proper_Import_Flag +# define ACE_SVC_SINGLETON_DECLARATION(T) ACE_IMPORT_SINGLETON_DECLARATION (T) +# endif /* ACE_BUILD_SVC_DLL */ +# else +# define ACE_Svc_Export +# define ACE_SVC_SINGLETON_DECLARATION(T) +# endif /* ! ACE_SVC_HAS_DLL == 1 */ +#else +# define ACE_Svc_Export +# define ACE_SVC_SINGLETON_DECLARATION(T) +#endif /* ACE_SVC_HAS_DLL */ + +#endif /* ACE_SVC_EXPORT_H */ + +// End of auto generated file. diff --git a/dep/ACE_wrappers/ace/svcconf.mpb b/dep/ACE_wrappers/ace/svcconf.mpb new file mode 100644 index 00000000000..c2eee25b8c8 --- /dev/null +++ b/dep/ACE_wrappers/ace/svcconf.mpb @@ -0,0 +1,58 @@ +// -*- MPC -*- +// $Id: svcconf.mpb 81335 2008-04-11 01:53:36Z iliyan $ + +feature(ace_svcconf) { + macros -= ACE_LACKS_ACE_SVCCONF + + Source_Files(ACE_COMPONENTS) { + DLL.cpp + Dynamic_Service_Base.cpp + Dynamic_Service_Dependency.cpp + Parse_Node.cpp + Service_Config.cpp + Service_Gestalt.cpp + Service_Manager.cpp + Service_Object.cpp + Service_Repository.cpp + Service_Types.cpp + Shared_Object.cpp + Svc_Conf_Lexer.cpp + Svc_Conf_y.cpp + Encoding_Converter.cpp + Encoding_Converter_Factory.cpp + UTF8_Encoding_Converter.cpp + UTF16_Encoding_Converter.cpp + UTF32_Encoding_Converter.cpp + XML_Svc_Conf.cpp + } + + verbatim(gnuace, local) { + "Svc_Conf_y.cpp: Svc_Conf.y" + "ifeq ($(notdir $(YACC)), bison)" + " $(YACC) -l -d Svc_Conf.y" + " sed -e 's/fprintf/ACE_OS::fprintf/g' \\" // Use ACE's fprintf, not library's + " -e 's/\\t/ /g' \\" // Eliminate tabs (replace with 2 spaces) + " -e 's/yy/ace_yy/g' \\" + " -e 's/->ace_yyerrno/->yyerrno/g' \\" // This reverses the ace_ prefix where it + " -e 's/->ace_yylineno/->yylineno/g' \\" // should not have been added by the substitution, above. + " -e 's/ NULL/ 0/g' \\" + " -e 's/ace_yyerror[ ]*([ ]*\"/ace_yyerror (ACE_SVC_CONF_PARAM->yyerrno, ACE_SVC_CONF_PARAM->yylineno, \"/g' \\" + " -e 's/ace_yyerror[ ]*([ ]*ace_yymsg/ace_yyerror (ACE_SVC_CONF_PARAM->yyerrno, ACE_SVC_CONF_PARAM->yylineno, ace_yymsg/g' \\" + " -e 's/ace_yyerror[ ]*([ ]*YY_/ace_yyerror (ACE_SVC_CONF_PARAM->yyerrno, ACE_SVC_CONF_PARAM->yylineno, YY_/g' \\" + " -e 's@#include @@' \\" + " -e 's/Svc_Conf\\.tab\\.c/Svc_Conf_y.cpp/g' $@" + " $(RM) -f Svc_Conf.tab.c Svc_Conf_y.cpp.orig" + "else" + " @echo 'ERROR: You must use bison 1.35 or higher to process this file'" + " @/bin/false" + "endif" + + "Svc_Conf_Token_Table.h: Svc_Conf.y Svc_Conf_y.cpp" + "ifeq ($(notdir $(YACC)), bison)" + " mv Svc_Conf.tab.h Svc_Conf_Token_Table.h" + "else" + " @echo 'ERROR: You must use bison 1.35 or higher to process this file'" + " @/bin/false" + "endif" + } +} diff --git a/dep/ACE_wrappers/ace/token.mpb b/dep/ACE_wrappers/ace/token.mpb new file mode 100644 index 00000000000..169afe1bb96 --- /dev/null +++ b/dep/ACE_wrappers/ace/token.mpb @@ -0,0 +1,15 @@ +// -*- MPC -*- +// $Id: token.mpb 80826 2008-03-04 14:51:23Z wotte $ + +feature(ace_token) { + macros -= ACE_LACKS_ACE_TOKEN + + Source_Files(ACE_COMPONENTS) { + Local_Tokens.cpp + Remote_Tokens.cpp + Token_Collection.cpp + Token_Invariants.cpp + Token_Manager.cpp + Token_Request_Reply.cpp + } +} diff --git a/dep/ACE_wrappers/ace/uuid.mpb b/dep/ACE_wrappers/ace/uuid.mpb new file mode 100644 index 00000000000..2d249aba768 --- /dev/null +++ b/dep/ACE_wrappers/ace/uuid.mpb @@ -0,0 +1,8 @@ +// -*- MPC -*- +// $Id: uuid.mpb 80826 2008-03-04 14:51:23Z wotte $ + +feature(ace_uuid) { + Source_Files(ACE_COMPONENTS) { + UUID.cpp + } +} diff --git a/dep/ACE_wrappers/aclocal.m4 b/dep/ACE_wrappers/aclocal.m4 new file mode 100644 index 00000000000..52e76f40123 --- /dev/null +++ b/dep/ACE_wrappers/aclocal.m4 @@ -0,0 +1,7555 @@ +# generated automatically by aclocal 1.10.1 -*- Autoconf -*- + +# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, +# 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +m4_ifndef([AC_AUTOCONF_VERSION], + [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl +m4_if(AC_AUTOCONF_VERSION, [2.61],, +[m4_warning([this file was generated for autoconf 2.61. +You have another version of autoconf. It may work, but is not guaranteed to. +If you have problems, you may need to regenerate the build system entirely. +To do so, use the procedure documented by the package, typically `autoreconf'.])]) + +# libtool.m4 - Configure libtool for the host system. -*-Autoconf-*- + +# serial 52 Debian 1.5.26-4 AC_PROG_LIBTOOL + + +# AC_PROVIDE_IFELSE(MACRO-NAME, IF-PROVIDED, IF-NOT-PROVIDED) +# ----------------------------------------------------------- +# If this macro is not defined by Autoconf, define it here. +m4_ifdef([AC_PROVIDE_IFELSE], + [], + [m4_define([AC_PROVIDE_IFELSE], + [m4_ifdef([AC_PROVIDE_$1], + [$2], [$3])])]) + + +# AC_PROG_LIBTOOL +# --------------- +AC_DEFUN([AC_PROG_LIBTOOL], +[AC_REQUIRE([_AC_PROG_LIBTOOL])dnl +dnl If AC_PROG_CXX has already been expanded, run AC_LIBTOOL_CXX +dnl immediately, otherwise, hook it in at the end of AC_PROG_CXX. + AC_PROVIDE_IFELSE([AC_PROG_CXX], + [AC_LIBTOOL_CXX], + [define([AC_PROG_CXX], defn([AC_PROG_CXX])[AC_LIBTOOL_CXX + ])]) +dnl And a similar setup for Fortran 77 support + AC_PROVIDE_IFELSE([AC_PROG_F77], + [AC_LIBTOOL_F77], + [define([AC_PROG_F77], defn([AC_PROG_F77])[AC_LIBTOOL_F77 +])]) + +dnl Quote A][M_PROG_GCJ so that aclocal doesn't bring it in needlessly. +dnl If either AC_PROG_GCJ or A][M_PROG_GCJ have already been expanded, run +dnl AC_LIBTOOL_GCJ immediately, otherwise, hook it in at the end of both. + AC_PROVIDE_IFELSE([AC_PROG_GCJ], + [AC_LIBTOOL_GCJ], + [AC_PROVIDE_IFELSE([A][M_PROG_GCJ], + [AC_LIBTOOL_GCJ], + [AC_PROVIDE_IFELSE([LT_AC_PROG_GCJ], + [AC_LIBTOOL_GCJ], + [ifdef([AC_PROG_GCJ], + [define([AC_PROG_GCJ], defn([AC_PROG_GCJ])[AC_LIBTOOL_GCJ])]) + ifdef([A][M_PROG_GCJ], + [define([A][M_PROG_GCJ], defn([A][M_PROG_GCJ])[AC_LIBTOOL_GCJ])]) + ifdef([LT_AC_PROG_GCJ], + [define([LT_AC_PROG_GCJ], + defn([LT_AC_PROG_GCJ])[AC_LIBTOOL_GCJ])])])]) +])])# AC_PROG_LIBTOOL + + +# _AC_PROG_LIBTOOL +# ---------------- +AC_DEFUN([_AC_PROG_LIBTOOL], +[AC_REQUIRE([AC_LIBTOOL_SETUP])dnl +AC_BEFORE([$0],[AC_LIBTOOL_CXX])dnl +AC_BEFORE([$0],[AC_LIBTOOL_F77])dnl +AC_BEFORE([$0],[AC_LIBTOOL_GCJ])dnl + +# This can be used to rebuild libtool when needed +LIBTOOL_DEPS="$ac_aux_dir/ltmain.sh" + +# Always use our own libtool. +LIBTOOL='$(SHELL) $(top_builddir)/libtool' +AC_SUBST(LIBTOOL)dnl + +# Prevent multiple expansion +define([AC_PROG_LIBTOOL], []) +])# _AC_PROG_LIBTOOL + + +# AC_LIBTOOL_SETUP +# ---------------- +AC_DEFUN([AC_LIBTOOL_SETUP], +[AC_PREREQ(2.50)dnl +AC_REQUIRE([AC_ENABLE_SHARED])dnl +AC_REQUIRE([AC_ENABLE_STATIC])dnl +AC_REQUIRE([AC_ENABLE_FAST_INSTALL])dnl +AC_REQUIRE([AC_CANONICAL_HOST])dnl +AC_REQUIRE([AC_CANONICAL_BUILD])dnl +AC_REQUIRE([AC_PROG_CC])dnl +AC_REQUIRE([AC_PROG_LD])dnl +AC_REQUIRE([AC_PROG_LD_RELOAD_FLAG])dnl +AC_REQUIRE([AC_PROG_NM])dnl + +AC_REQUIRE([AC_PROG_LN_S])dnl +AC_REQUIRE([AC_DEPLIBS_CHECK_METHOD])dnl +# Autoconf 2.13's AC_OBJEXT and AC_EXEEXT macros only works for C compilers! +AC_REQUIRE([AC_OBJEXT])dnl +AC_REQUIRE([AC_EXEEXT])dnl +dnl +AC_LIBTOOL_SYS_MAX_CMD_LEN +AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE +AC_LIBTOOL_OBJDIR + +AC_REQUIRE([_LT_AC_SYS_COMPILER])dnl +_LT_AC_PROG_ECHO_BACKSLASH + +case $host_os in +aix3*) + # AIX sometimes has problems with the GCC collect2 program. For some + # reason, if we set the COLLECT_NAMES environment variable, the problems + # vanish in a puff of smoke. + if test "X${COLLECT_NAMES+set}" != Xset; then + COLLECT_NAMES= + export COLLECT_NAMES + fi + ;; +esac + +# Sed substitution that helps us do robust quoting. It backslashifies +# metacharacters that are still active within double-quoted strings. +Xsed='sed -e 1s/^X//' +[sed_quote_subst='s/\([\\"\\`$\\\\]\)/\\\1/g'] + +# Same as above, but do not quote variable references. +[double_quote_subst='s/\([\\"\\`\\\\]\)/\\\1/g'] + +# Sed substitution to delay expansion of an escaped shell variable in a +# double_quote_subst'ed string. +delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g' + +# Sed substitution to avoid accidental globbing in evaled expressions +no_glob_subst='s/\*/\\\*/g' + +# Constants: +rm="rm -f" + +# Global variables: +default_ofile=libtool +can_build_shared=yes + +# All known linkers require a `.a' archive for static linking (except MSVC, +# which needs '.lib'). +libext=a +ltmain="$ac_aux_dir/ltmain.sh" +ofile="$default_ofile" +with_gnu_ld="$lt_cv_prog_gnu_ld" + +AC_CHECK_TOOL(AR, ar, false) +AC_CHECK_TOOL(RANLIB, ranlib, :) +AC_CHECK_TOOL(STRIP, strip, :) + +old_CC="$CC" +old_CFLAGS="$CFLAGS" + +# Set sane defaults for various variables +test -z "$AR" && AR=ar +test -z "$AR_FLAGS" && AR_FLAGS=cru +test -z "$AS" && AS=as +test -z "$CC" && CC=cc +test -z "$LTCC" && LTCC=$CC +test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS +test -z "$DLLTOOL" && DLLTOOL=dlltool +test -z "$LD" && LD=ld +test -z "$LN_S" && LN_S="ln -s" +test -z "$MAGIC_CMD" && MAGIC_CMD=file +test -z "$NM" && NM=nm +test -z "$SED" && SED=sed +test -z "$OBJDUMP" && OBJDUMP=objdump +test -z "$RANLIB" && RANLIB=: +test -z "$STRIP" && STRIP=: +test -z "$ac_objext" && ac_objext=o + +# Determine commands to create old-style static archives. +old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs' +old_postinstall_cmds='chmod 644 $oldlib' +old_postuninstall_cmds= + +if test -n "$RANLIB"; then + case $host_os in + openbsd*) + old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$oldlib" + ;; + *) + old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$oldlib" + ;; + esac + old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib" +fi + +_LT_CC_BASENAME([$compiler]) + +# Only perform the check for file, if the check method requires it +case $deplibs_check_method in +file_magic*) + if test "$file_magic_cmd" = '$MAGIC_CMD'; then + AC_PATH_MAGIC + fi + ;; +esac + +_LT_REQUIRED_DARWIN_CHECKS + +AC_PROVIDE_IFELSE([AC_LIBTOOL_DLOPEN], enable_dlopen=yes, enable_dlopen=no) +AC_PROVIDE_IFELSE([AC_LIBTOOL_WIN32_DLL], +enable_win32_dll=yes, enable_win32_dll=no) + +AC_ARG_ENABLE([libtool-lock], + [AC_HELP_STRING([--disable-libtool-lock], + [avoid locking (might break parallel builds)])]) +test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes + +AC_ARG_WITH([pic], + [AC_HELP_STRING([--with-pic], + [try to use only PIC/non-PIC objects @<:@default=use both@:>@])], + [pic_mode="$withval"], + [pic_mode=default]) +test -z "$pic_mode" && pic_mode=default + +# Use C for the default configuration in the libtool script +tagname= +AC_LIBTOOL_LANG_C_CONFIG +_LT_AC_TAGCONFIG +])# AC_LIBTOOL_SETUP + + +# _LT_AC_SYS_COMPILER +# ------------------- +AC_DEFUN([_LT_AC_SYS_COMPILER], +[AC_REQUIRE([AC_PROG_CC])dnl + +# If no C compiler was specified, use CC. +LTCC=${LTCC-"$CC"} + +# If no C compiler flags were specified, use CFLAGS. +LTCFLAGS=${LTCFLAGS-"$CFLAGS"} + +# Allow CC to be a program name with arguments. +compiler=$CC +])# _LT_AC_SYS_COMPILER + + +# _LT_CC_BASENAME(CC) +# ------------------- +# Calculate cc_basename. Skip known compiler wrappers and cross-prefix. +AC_DEFUN([_LT_CC_BASENAME], +[for cc_temp in $1""; do + case $cc_temp in + compile | *[[\\/]]compile | ccache | *[[\\/]]ccache ) ;; + distcc | *[[\\/]]distcc | purify | *[[\\/]]purify ) ;; + \-*) ;; + *) break;; + esac +done +cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"` +]) + + +# _LT_COMPILER_BOILERPLATE +# ------------------------ +# Check for compiler boilerplate output or warnings with +# the simple compiler test code. +AC_DEFUN([_LT_COMPILER_BOILERPLATE], +[AC_REQUIRE([LT_AC_PROG_SED])dnl +ac_outfile=conftest.$ac_objext +echo "$lt_simple_compile_test_code" >conftest.$ac_ext +eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err +_lt_compiler_boilerplate=`cat conftest.err` +$rm conftest* +])# _LT_COMPILER_BOILERPLATE + + +# _LT_LINKER_BOILERPLATE +# ---------------------- +# Check for linker boilerplate output or warnings with +# the simple link test code. +AC_DEFUN([_LT_LINKER_BOILERPLATE], +[AC_REQUIRE([LT_AC_PROG_SED])dnl +ac_outfile=conftest.$ac_objext +echo "$lt_simple_link_test_code" >conftest.$ac_ext +eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err +_lt_linker_boilerplate=`cat conftest.err` +$rm -r conftest* +])# _LT_LINKER_BOILERPLATE + +# _LT_REQUIRED_DARWIN_CHECKS +# -------------------------- +# Check for some things on darwin +AC_DEFUN([_LT_REQUIRED_DARWIN_CHECKS],[ + case $host_os in + rhapsody* | darwin*) + AC_CHECK_TOOL([DSYMUTIL], [dsymutil], [:]) + AC_CHECK_TOOL([NMEDIT], [nmedit], [:]) + + AC_CACHE_CHECK([for -single_module linker flag],[lt_cv_apple_cc_single_mod], + [lt_cv_apple_cc_single_mod=no + if test -z "${LT_MULTI_MODULE}"; then + # By default we will add the -single_module flag. You can override + # by either setting the environment variable LT_MULTI_MODULE + # non-empty at configure time, or by adding -multi_module to the + # link flags. + echo "int foo(void){return 1;}" > conftest.c + $LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ + -dynamiclib ${wl}-single_module conftest.c + if test -f libconftest.dylib; then + lt_cv_apple_cc_single_mod=yes + rm -rf libconftest.dylib* + fi + rm conftest.c + fi]) + AC_CACHE_CHECK([for -exported_symbols_list linker flag], + [lt_cv_ld_exported_symbols_list], + [lt_cv_ld_exported_symbols_list=no + save_LDFLAGS=$LDFLAGS + echo "_main" > conftest.sym + LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym" + AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])], + [lt_cv_ld_exported_symbols_list=yes], + [lt_cv_ld_exported_symbols_list=no]) + LDFLAGS="$save_LDFLAGS" + ]) + case $host_os in + rhapsody* | darwin1.[[0123]]) + _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;; + darwin1.*) + _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; + darwin*) + # if running on 10.5 or later, the deployment target defaults + # to the OS version, if on x86, and 10.4, the deployment + # target defaults to 10.4. Don't you love it? + case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in + 10.0,*86*-darwin8*|10.0,*-darwin[[91]]*) + _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;; + 10.[[012]]*) + _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; + 10.*) + _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;; + esac + ;; + esac + if test "$lt_cv_apple_cc_single_mod" = "yes"; then + _lt_dar_single_mod='$single_module' + fi + if test "$lt_cv_ld_exported_symbols_list" = "yes"; then + _lt_dar_export_syms=' ${wl}-exported_symbols_list,$output_objdir/${libname}-symbols.expsym' + else + _lt_dar_export_syms="~$NMEDIT -s \$output_objdir/\${libname}-symbols.expsym \${lib}" + fi + if test "$DSYMUTIL" != ":"; then + _lt_dsymutil="~$DSYMUTIL \$lib || :" + else + _lt_dsymutil= + fi + ;; + esac +]) + +# _LT_AC_SYS_LIBPATH_AIX +# ---------------------- +# Links a minimal program and checks the executable +# for the system default hardcoded library path. In most cases, +# this is /usr/lib:/lib, but when the MPI compilers are used +# the location of the communication and MPI libs are included too. +# If we don't find anything, use the default library path according +# to the aix ld manual. +AC_DEFUN([_LT_AC_SYS_LIBPATH_AIX], +[AC_REQUIRE([LT_AC_PROG_SED])dnl +AC_LINK_IFELSE(AC_LANG_PROGRAM,[ +lt_aix_libpath_sed=' + /Import File Strings/,/^$/ { + /^0/ { + s/^0 *\(.*\)$/\1/ + p + } + }' +aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` +# Check for a 64-bit object if we didn't find anything. +if test -z "$aix_libpath"; then + aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` +fi],[]) +if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi +])# _LT_AC_SYS_LIBPATH_AIX + + +# _LT_AC_SHELL_INIT(ARG) +# ---------------------- +AC_DEFUN([_LT_AC_SHELL_INIT], +[ifdef([AC_DIVERSION_NOTICE], + [AC_DIVERT_PUSH(AC_DIVERSION_NOTICE)], + [AC_DIVERT_PUSH(NOTICE)]) +$1 +AC_DIVERT_POP +])# _LT_AC_SHELL_INIT + + +# _LT_AC_PROG_ECHO_BACKSLASH +# -------------------------- +# Add some code to the start of the generated configure script which +# will find an echo command which doesn't interpret backslashes. +AC_DEFUN([_LT_AC_PROG_ECHO_BACKSLASH], +[_LT_AC_SHELL_INIT([ +# Check that we are running under the correct shell. +SHELL=${CONFIG_SHELL-/bin/sh} + +case X$ECHO in +X*--fallback-echo) + # Remove one level of quotation (which was required for Make). + ECHO=`echo "$ECHO" | sed 's,\\\\\[$]\\[$]0,'[$]0','` + ;; +esac + +echo=${ECHO-echo} +if test "X[$]1" = X--no-reexec; then + # Discard the --no-reexec flag, and continue. + shift +elif test "X[$]1" = X--fallback-echo; then + # Avoid inline document here, it may be left over + : +elif test "X`($echo '\t') 2>/dev/null`" = 'X\t' ; then + # Yippee, $echo works! + : +else + # Restart under the correct shell. + exec $SHELL "[$]0" --no-reexec ${1+"[$]@"} +fi + +if test "X[$]1" = X--fallback-echo; then + # used as fallback echo + shift + cat </dev/null 2>&1 && unset CDPATH + +if test -z "$ECHO"; then +if test "X${echo_test_string+set}" != Xset; then +# find a string as large as possible, as long as the shell can cope with it + for cmd in 'sed 50q "[$]0"' 'sed 20q "[$]0"' 'sed 10q "[$]0"' 'sed 2q "[$]0"' 'echo test'; do + # expected sizes: less than 2Kb, 1Kb, 512 bytes, 16 bytes, ... + if (echo_test_string=`eval $cmd`) 2>/dev/null && + echo_test_string=`eval $cmd` && + (test "X$echo_test_string" = "X$echo_test_string") 2>/dev/null + then + break + fi + done +fi + +if test "X`($echo '\t') 2>/dev/null`" = 'X\t' && + echo_testing_string=`($echo "$echo_test_string") 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + : +else + # The Solaris, AIX, and Digital Unix default echo programs unquote + # backslashes. This makes it impossible to quote backslashes using + # echo "$something" | sed 's/\\/\\\\/g' + # + # So, first we look for a working echo in the user's PATH. + + lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR + for dir in $PATH /usr/ucb; do + IFS="$lt_save_ifs" + if (test -f $dir/echo || test -f $dir/echo$ac_exeext) && + test "X`($dir/echo '\t') 2>/dev/null`" = 'X\t' && + echo_testing_string=`($dir/echo "$echo_test_string") 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + echo="$dir/echo" + break + fi + done + IFS="$lt_save_ifs" + + if test "X$echo" = Xecho; then + # We didn't find a better echo, so look for alternatives. + if test "X`(print -r '\t') 2>/dev/null`" = 'X\t' && + echo_testing_string=`(print -r "$echo_test_string") 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + # This shell has a builtin print -r that does the trick. + echo='print -r' + elif (test -f /bin/ksh || test -f /bin/ksh$ac_exeext) && + test "X$CONFIG_SHELL" != X/bin/ksh; then + # If we have ksh, try running configure again with it. + ORIGINAL_CONFIG_SHELL=${CONFIG_SHELL-/bin/sh} + export ORIGINAL_CONFIG_SHELL + CONFIG_SHELL=/bin/ksh + export CONFIG_SHELL + exec $CONFIG_SHELL "[$]0" --no-reexec ${1+"[$]@"} + else + # Try using printf. + echo='printf %s\n' + if test "X`($echo '\t') 2>/dev/null`" = 'X\t' && + echo_testing_string=`($echo "$echo_test_string") 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + # Cool, printf works + : + elif echo_testing_string=`($ORIGINAL_CONFIG_SHELL "[$]0" --fallback-echo '\t') 2>/dev/null` && + test "X$echo_testing_string" = 'X\t' && + echo_testing_string=`($ORIGINAL_CONFIG_SHELL "[$]0" --fallback-echo "$echo_test_string") 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + CONFIG_SHELL=$ORIGINAL_CONFIG_SHELL + export CONFIG_SHELL + SHELL="$CONFIG_SHELL" + export SHELL + echo="$CONFIG_SHELL [$]0 --fallback-echo" + elif echo_testing_string=`($CONFIG_SHELL "[$]0" --fallback-echo '\t') 2>/dev/null` && + test "X$echo_testing_string" = 'X\t' && + echo_testing_string=`($CONFIG_SHELL "[$]0" --fallback-echo "$echo_test_string") 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + echo="$CONFIG_SHELL [$]0 --fallback-echo" + else + # maybe with a smaller string... + prev=: + + for cmd in 'echo test' 'sed 2q "[$]0"' 'sed 10q "[$]0"' 'sed 20q "[$]0"' 'sed 50q "[$]0"'; do + if (test "X$echo_test_string" = "X`eval $cmd`") 2>/dev/null + then + break + fi + prev="$cmd" + done + + if test "$prev" != 'sed 50q "[$]0"'; then + echo_test_string=`eval $prev` + export echo_test_string + exec ${ORIGINAL_CONFIG_SHELL-${CONFIG_SHELL-/bin/sh}} "[$]0" ${1+"[$]@"} + else + # Oops. We lost completely, so just stick with echo. + echo=echo + fi + fi + fi + fi +fi +fi + +# Copy echo and quote the copy suitably for passing to libtool from +# the Makefile, instead of quoting the original, which is used later. +ECHO=$echo +if test "X$ECHO" = "X$CONFIG_SHELL [$]0 --fallback-echo"; then + ECHO="$CONFIG_SHELL \\\$\[$]0 --fallback-echo" +fi + +AC_SUBST(ECHO) +])])# _LT_AC_PROG_ECHO_BACKSLASH + + +# _LT_AC_LOCK +# ----------- +AC_DEFUN([_LT_AC_LOCK], +[AC_ARG_ENABLE([libtool-lock], + [AC_HELP_STRING([--disable-libtool-lock], + [avoid locking (might break parallel builds)])]) +test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes + +# Some flags need to be propagated to the compiler or linker for good +# libtool support. +case $host in +ia64-*-hpux*) + # Find out which ABI we are using. + echo 'int i;' > conftest.$ac_ext + if AC_TRY_EVAL(ac_compile); then + case `/usr/bin/file conftest.$ac_objext` in + *ELF-32*) + HPUX_IA64_MODE="32" + ;; + *ELF-64*) + HPUX_IA64_MODE="64" + ;; + esac + fi + rm -rf conftest* + ;; +*-*-irix6*) + # Find out which ABI we are using. + echo '[#]line __oline__ "configure"' > conftest.$ac_ext + if AC_TRY_EVAL(ac_compile); then + if test "$lt_cv_prog_gnu_ld" = yes; then + case `/usr/bin/file conftest.$ac_objext` in + *32-bit*) + LD="${LD-ld} -melf32bsmip" + ;; + *N32*) + LD="${LD-ld} -melf32bmipn32" + ;; + *64-bit*) + LD="${LD-ld} -melf64bmip" + ;; + esac + else + case `/usr/bin/file conftest.$ac_objext` in + *32-bit*) + LD="${LD-ld} -32" + ;; + *N32*) + LD="${LD-ld} -n32" + ;; + *64-bit*) + LD="${LD-ld} -64" + ;; + esac + fi + fi + rm -rf conftest* + ;; + +x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \ +s390*-*linux*|sparc*-*linux*) + # Find out which ABI we are using. + echo 'int i;' > conftest.$ac_ext + if AC_TRY_EVAL(ac_compile); then + case `/usr/bin/file conftest.o` in + *32-bit*) + case $host in + x86_64-*kfreebsd*-gnu) + LD="${LD-ld} -m elf_i386_fbsd" + ;; + x86_64-*linux*) + LD="${LD-ld} -m elf_i386" + ;; + ppc64-*linux*|powerpc64-*linux*) + LD="${LD-ld} -m elf32ppclinux" + ;; + s390x-*linux*) + LD="${LD-ld} -m elf_s390" + ;; + sparc64-*linux*) + LD="${LD-ld} -m elf32_sparc" + ;; + esac + ;; + *64-bit*) + case $host in + x86_64-*kfreebsd*-gnu) + LD="${LD-ld} -m elf_x86_64_fbsd" + ;; + x86_64-*linux*) + LD="${LD-ld} -m elf_x86_64" + ;; + ppc*-*linux*|powerpc*-*linux*) + LD="${LD-ld} -m elf64ppc" + ;; + s390*-*linux*) + LD="${LD-ld} -m elf64_s390" + ;; + sparc*-*linux*) + LD="${LD-ld} -m elf64_sparc" + ;; + esac + ;; + esac + fi + rm -rf conftest* + ;; + +*-*-sco3.2v5*) + # On SCO OpenServer 5, we need -belf to get full-featured binaries. + SAVE_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS -belf" + AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf, + [AC_LANG_PUSH(C) + AC_TRY_LINK([],[],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no]) + AC_LANG_POP]) + if test x"$lt_cv_cc_needs_belf" != x"yes"; then + # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf + CFLAGS="$SAVE_CFLAGS" + fi + ;; +sparc*-*solaris*) + # Find out which ABI we are using. + echo 'int i;' > conftest.$ac_ext + if AC_TRY_EVAL(ac_compile); then + case `/usr/bin/file conftest.o` in + *64-bit*) + case $lt_cv_prog_gnu_ld in + yes*) LD="${LD-ld} -m elf64_sparc" ;; + *) + if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then + LD="${LD-ld} -64" + fi + ;; + esac + ;; + esac + fi + rm -rf conftest* + ;; + +AC_PROVIDE_IFELSE([AC_LIBTOOL_WIN32_DLL], +[*-*-cygwin* | *-*-mingw* | *-*-pw32*) + AC_CHECK_TOOL(DLLTOOL, dlltool, false) + AC_CHECK_TOOL(AS, as, false) + AC_CHECK_TOOL(OBJDUMP, objdump, false) + ;; + ]) +esac + +need_locks="$enable_libtool_lock" + +])# _LT_AC_LOCK + + +# AC_LIBTOOL_COMPILER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS, +# [OUTPUT-FILE], [ACTION-SUCCESS], [ACTION-FAILURE]) +# ---------------------------------------------------------------- +# Check whether the given compiler option works +AC_DEFUN([AC_LIBTOOL_COMPILER_OPTION], +[AC_REQUIRE([LT_AC_PROG_SED]) +AC_CACHE_CHECK([$1], [$2], + [$2=no + ifelse([$4], , [ac_outfile=conftest.$ac_objext], [ac_outfile=$4]) + echo "$lt_simple_compile_test_code" > conftest.$ac_ext + lt_compiler_flag="$3" + # Insert the option either (1) after the last *FLAGS variable, or + # (2) before a word containing "conftest.", or (3) at the end. + # Note that $ac_compile itself does not contain backslashes and begins + # with a dollar sign (not a hyphen), so the echo should work correctly. + # The option is referenced via a variable to avoid confusing sed. + lt_compile=`echo "$ac_compile" | $SED \ + -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ + -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` + (eval echo "\"\$as_me:__oline__: $lt_compile\"" >&AS_MESSAGE_LOG_FD) + (eval "$lt_compile" 2>conftest.err) + ac_status=$? + cat conftest.err >&AS_MESSAGE_LOG_FD + echo "$as_me:__oline__: \$? = $ac_status" >&AS_MESSAGE_LOG_FD + if (exit $ac_status) && test -s "$ac_outfile"; then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings other than the usual output. + $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp + $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 + if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then + $2=yes + fi + fi + $rm conftest* +]) + +if test x"[$]$2" = xyes; then + ifelse([$5], , :, [$5]) +else + ifelse([$6], , :, [$6]) +fi +])# AC_LIBTOOL_COMPILER_OPTION + + +# AC_LIBTOOL_LINKER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS, +# [ACTION-SUCCESS], [ACTION-FAILURE]) +# ------------------------------------------------------------ +# Check whether the given compiler option works +AC_DEFUN([AC_LIBTOOL_LINKER_OPTION], +[AC_REQUIRE([LT_AC_PROG_SED])dnl +AC_CACHE_CHECK([$1], [$2], + [$2=no + save_LDFLAGS="$LDFLAGS" + LDFLAGS="$LDFLAGS $3" + echo "$lt_simple_link_test_code" > conftest.$ac_ext + if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then + # The linker can only warn and ignore the option if not recognized + # So say no if there are warnings + if test -s conftest.err; then + # Append any errors to the config.log. + cat conftest.err 1>&AS_MESSAGE_LOG_FD + $echo "X$_lt_linker_boilerplate" | $Xsed -e '/^$/d' > conftest.exp + $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 + if diff conftest.exp conftest.er2 >/dev/null; then + $2=yes + fi + else + $2=yes + fi + fi + $rm -r conftest* + LDFLAGS="$save_LDFLAGS" +]) + +if test x"[$]$2" = xyes; then + ifelse([$4], , :, [$4]) +else + ifelse([$5], , :, [$5]) +fi +])# AC_LIBTOOL_LINKER_OPTION + + +# AC_LIBTOOL_SYS_MAX_CMD_LEN +# -------------------------- +AC_DEFUN([AC_LIBTOOL_SYS_MAX_CMD_LEN], +[# find the maximum length of command line arguments +AC_MSG_CHECKING([the maximum length of command line arguments]) +AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl + i=0 + teststring="ABCD" + + case $build_os in + msdosdjgpp*) + # On DJGPP, this test can blow up pretty badly due to problems in libc + # (any single argument exceeding 2000 bytes causes a buffer overrun + # during glob expansion). Even if it were fixed, the result of this + # check would be larger than it should be. + lt_cv_sys_max_cmd_len=12288; # 12K is about right + ;; + + gnu*) + # Under GNU Hurd, this test is not required because there is + # no limit to the length of command line arguments. + # Libtool will interpret -1 as no limit whatsoever + lt_cv_sys_max_cmd_len=-1; + ;; + + cygwin* | mingw*) + # On Win9x/ME, this test blows up -- it succeeds, but takes + # about 5 minutes as the teststring grows exponentially. + # Worse, since 9x/ME are not pre-emptively multitasking, + # you end up with a "frozen" computer, even though with patience + # the test eventually succeeds (with a max line length of 256k). + # Instead, let's just punt: use the minimum linelength reported by + # all of the supported platforms: 8192 (on NT/2K/XP). + lt_cv_sys_max_cmd_len=8192; + ;; + + amigaos*) + # On AmigaOS with pdksh, this test takes hours, literally. + # So we just punt and use a minimum line length of 8192. + lt_cv_sys_max_cmd_len=8192; + ;; + + netbsd* | freebsd* | openbsd* | darwin* | dragonfly*) + # This has been around since 386BSD, at least. Likely further. + if test -x /sbin/sysctl; then + lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax` + elif test -x /usr/sbin/sysctl; then + lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax` + else + lt_cv_sys_max_cmd_len=65536 # usable default for all BSDs + fi + # And add a safety zone + lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` + lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` + ;; + + interix*) + # We know the value 262144 and hardcode it with a safety zone (like BSD) + lt_cv_sys_max_cmd_len=196608 + ;; + + osf*) + # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure + # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not + # nice to cause kernel panics so lets avoid the loop below. + # First set a reasonable default. + lt_cv_sys_max_cmd_len=16384 + # + if test -x /sbin/sysconfig; then + case `/sbin/sysconfig -q proc exec_disable_arg_limit` in + *1*) lt_cv_sys_max_cmd_len=-1 ;; + esac + fi + ;; + sco3.2v5*) + lt_cv_sys_max_cmd_len=102400 + ;; + sysv5* | sco5v6* | sysv4.2uw2*) + kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null` + if test -n "$kargmax"; then + lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[[ ]]//'` + else + lt_cv_sys_max_cmd_len=32768 + fi + ;; + *) + lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null` + if test -n "$lt_cv_sys_max_cmd_len"; then + lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` + lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` + else + SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}} + while (test "X"`$SHELL [$]0 --fallback-echo "X$teststring" 2>/dev/null` \ + = "XX$teststring") >/dev/null 2>&1 && + new_result=`expr "X$teststring" : ".*" 2>&1` && + lt_cv_sys_max_cmd_len=$new_result && + test $i != 17 # 1/2 MB should be enough + do + i=`expr $i + 1` + teststring=$teststring$teststring + done + teststring= + # Add a significant safety factor because C++ compilers can tack on massive + # amounts of additional arguments before passing them to the linker. + # It appears as though 1/2 is a usable value. + lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2` + fi + ;; + esac +]) +if test -n $lt_cv_sys_max_cmd_len ; then + AC_MSG_RESULT($lt_cv_sys_max_cmd_len) +else + AC_MSG_RESULT(none) +fi +])# AC_LIBTOOL_SYS_MAX_CMD_LEN + + +# _LT_AC_CHECK_DLFCN +# ------------------ +AC_DEFUN([_LT_AC_CHECK_DLFCN], +[AC_CHECK_HEADERS(dlfcn.h)dnl +])# _LT_AC_CHECK_DLFCN + + +# _LT_AC_TRY_DLOPEN_SELF (ACTION-IF-TRUE, ACTION-IF-TRUE-W-USCORE, +# ACTION-IF-FALSE, ACTION-IF-CROSS-COMPILING) +# --------------------------------------------------------------------- +AC_DEFUN([_LT_AC_TRY_DLOPEN_SELF], +[AC_REQUIRE([_LT_AC_CHECK_DLFCN])dnl +if test "$cross_compiling" = yes; then : + [$4] +else + lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 + lt_status=$lt_dlunknown + cat > conftest.$ac_ext < +#endif + +#include + +#ifdef RTLD_GLOBAL +# define LT_DLGLOBAL RTLD_GLOBAL +#else +# ifdef DL_GLOBAL +# define LT_DLGLOBAL DL_GLOBAL +# else +# define LT_DLGLOBAL 0 +# endif +#endif + +/* We may have to define LT_DLLAZY_OR_NOW in the command line if we + find out it does not work in some platform. */ +#ifndef LT_DLLAZY_OR_NOW +# ifdef RTLD_LAZY +# define LT_DLLAZY_OR_NOW RTLD_LAZY +# else +# ifdef DL_LAZY +# define LT_DLLAZY_OR_NOW DL_LAZY +# else +# ifdef RTLD_NOW +# define LT_DLLAZY_OR_NOW RTLD_NOW +# else +# ifdef DL_NOW +# define LT_DLLAZY_OR_NOW DL_NOW +# else +# define LT_DLLAZY_OR_NOW 0 +# endif +# endif +# endif +# endif +#endif + +#ifdef __cplusplus +extern "C" void exit (int); +#endif + +void fnord() { int i=42;} +int main () +{ + void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); + int status = $lt_dlunknown; + + if (self) + { + if (dlsym (self,"fnord")) status = $lt_dlno_uscore; + else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; + /* dlclose (self); */ + } + else + puts (dlerror ()); + + exit (status); +}] +EOF + if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext} 2>/dev/null; then + (./conftest; exit; ) >&AS_MESSAGE_LOG_FD 2>/dev/null + lt_status=$? + case x$lt_status in + x$lt_dlno_uscore) $1 ;; + x$lt_dlneed_uscore) $2 ;; + x$lt_dlunknown|x*) $3 ;; + esac + else : + # compilation failed + $3 + fi +fi +rm -fr conftest* +])# _LT_AC_TRY_DLOPEN_SELF + + +# AC_LIBTOOL_DLOPEN_SELF +# ---------------------- +AC_DEFUN([AC_LIBTOOL_DLOPEN_SELF], +[AC_REQUIRE([_LT_AC_CHECK_DLFCN])dnl +if test "x$enable_dlopen" != xyes; then + enable_dlopen=unknown + enable_dlopen_self=unknown + enable_dlopen_self_static=unknown +else + lt_cv_dlopen=no + lt_cv_dlopen_libs= + + case $host_os in + beos*) + lt_cv_dlopen="load_add_on" + lt_cv_dlopen_libs= + lt_cv_dlopen_self=yes + ;; + + mingw* | pw32*) + lt_cv_dlopen="LoadLibrary" + lt_cv_dlopen_libs= + ;; + + cygwin*) + lt_cv_dlopen="dlopen" + lt_cv_dlopen_libs= + ;; + + darwin*) + # if libdl is installed we need to link against it + AC_CHECK_LIB([dl], [dlopen], + [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"],[ + lt_cv_dlopen="dyld" + lt_cv_dlopen_libs= + lt_cv_dlopen_self=yes + ]) + ;; + + *) + AC_CHECK_FUNC([shl_load], + [lt_cv_dlopen="shl_load"], + [AC_CHECK_LIB([dld], [shl_load], + [lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld"], + [AC_CHECK_FUNC([dlopen], + [lt_cv_dlopen="dlopen"], + [AC_CHECK_LIB([dl], [dlopen], + [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"], + [AC_CHECK_LIB([svld], [dlopen], + [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"], + [AC_CHECK_LIB([dld], [dld_link], + [lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld"]) + ]) + ]) + ]) + ]) + ]) + ;; + esac + + if test "x$lt_cv_dlopen" != xno; then + enable_dlopen=yes + else + enable_dlopen=no + fi + + case $lt_cv_dlopen in + dlopen) + save_CPPFLAGS="$CPPFLAGS" + test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H" + + save_LDFLAGS="$LDFLAGS" + wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\" + + save_LIBS="$LIBS" + LIBS="$lt_cv_dlopen_libs $LIBS" + + AC_CACHE_CHECK([whether a program can dlopen itself], + lt_cv_dlopen_self, [dnl + _LT_AC_TRY_DLOPEN_SELF( + lt_cv_dlopen_self=yes, lt_cv_dlopen_self=yes, + lt_cv_dlopen_self=no, lt_cv_dlopen_self=cross) + ]) + + if test "x$lt_cv_dlopen_self" = xyes; then + wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\" + AC_CACHE_CHECK([whether a statically linked program can dlopen itself], + lt_cv_dlopen_self_static, [dnl + _LT_AC_TRY_DLOPEN_SELF( + lt_cv_dlopen_self_static=yes, lt_cv_dlopen_self_static=yes, + lt_cv_dlopen_self_static=no, lt_cv_dlopen_self_static=cross) + ]) + fi + + CPPFLAGS="$save_CPPFLAGS" + LDFLAGS="$save_LDFLAGS" + LIBS="$save_LIBS" + ;; + esac + + case $lt_cv_dlopen_self in + yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;; + *) enable_dlopen_self=unknown ;; + esac + + case $lt_cv_dlopen_self_static in + yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;; + *) enable_dlopen_self_static=unknown ;; + esac +fi +])# AC_LIBTOOL_DLOPEN_SELF + + +# AC_LIBTOOL_PROG_CC_C_O([TAGNAME]) +# --------------------------------- +# Check to see if options -c and -o are simultaneously supported by compiler +AC_DEFUN([AC_LIBTOOL_PROG_CC_C_O], +[AC_REQUIRE([LT_AC_PROG_SED])dnl +AC_REQUIRE([_LT_AC_SYS_COMPILER])dnl +AC_CACHE_CHECK([if $compiler supports -c -o file.$ac_objext], + [_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)], + [_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)=no + $rm -r conftest 2>/dev/null + mkdir conftest + cd conftest + mkdir out + echo "$lt_simple_compile_test_code" > conftest.$ac_ext + + lt_compiler_flag="-o out/conftest2.$ac_objext" + # Insert the option either (1) after the last *FLAGS variable, or + # (2) before a word containing "conftest.", or (3) at the end. + # Note that $ac_compile itself does not contain backslashes and begins + # with a dollar sign (not a hyphen), so the echo should work correctly. + lt_compile=`echo "$ac_compile" | $SED \ + -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ + -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` + (eval echo "\"\$as_me:__oline__: $lt_compile\"" >&AS_MESSAGE_LOG_FD) + (eval "$lt_compile" 2>out/conftest.err) + ac_status=$? + cat out/conftest.err >&AS_MESSAGE_LOG_FD + echo "$as_me:__oline__: \$? = $ac_status" >&AS_MESSAGE_LOG_FD + if (exit $ac_status) && test -s out/conftest2.$ac_objext + then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings + $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp + $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 + if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then + _LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes + fi + fi + chmod u+w . 2>&AS_MESSAGE_LOG_FD + $rm conftest* + # SGI C++ compiler will create directory out/ii_files/ for + # template instantiation + test -d out/ii_files && $rm out/ii_files/* && rmdir out/ii_files + $rm out/* && rmdir out + cd .. + rmdir conftest + $rm conftest* +]) +])# AC_LIBTOOL_PROG_CC_C_O + + +# AC_LIBTOOL_SYS_HARD_LINK_LOCKS([TAGNAME]) +# ----------------------------------------- +# Check to see if we can do hard links to lock some files if needed +AC_DEFUN([AC_LIBTOOL_SYS_HARD_LINK_LOCKS], +[AC_REQUIRE([_LT_AC_LOCK])dnl + +hard_links="nottested" +if test "$_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)" = no && test "$need_locks" != no; then + # do not overwrite the value of need_locks provided by the user + AC_MSG_CHECKING([if we can lock with hard links]) + hard_links=yes + $rm conftest* + ln conftest.a conftest.b 2>/dev/null && hard_links=no + touch conftest.a + ln conftest.a conftest.b 2>&5 || hard_links=no + ln conftest.a conftest.b 2>/dev/null && hard_links=no + AC_MSG_RESULT([$hard_links]) + if test "$hard_links" = no; then + AC_MSG_WARN([`$CC' does not support `-c -o', so `make -j' may be unsafe]) + need_locks=warn + fi +else + need_locks=no +fi +])# AC_LIBTOOL_SYS_HARD_LINK_LOCKS + + +# AC_LIBTOOL_OBJDIR +# ----------------- +AC_DEFUN([AC_LIBTOOL_OBJDIR], +[AC_CACHE_CHECK([for objdir], [lt_cv_objdir], +[rm -f .libs 2>/dev/null +mkdir .libs 2>/dev/null +if test -d .libs; then + lt_cv_objdir=.libs +else + # MS-DOS does not allow filenames that begin with a dot. + lt_cv_objdir=_libs +fi +rmdir .libs 2>/dev/null]) +objdir=$lt_cv_objdir +])# AC_LIBTOOL_OBJDIR + + +# AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH([TAGNAME]) +# ---------------------------------------------- +# Check hardcoding attributes. +AC_DEFUN([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH], +[AC_MSG_CHECKING([how to hardcode library paths into programs]) +_LT_AC_TAGVAR(hardcode_action, $1)= +if test -n "$_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)" || \ + test -n "$_LT_AC_TAGVAR(runpath_var, $1)" || \ + test "X$_LT_AC_TAGVAR(hardcode_automatic, $1)" = "Xyes" ; then + + # We can hardcode non-existant directories. + if test "$_LT_AC_TAGVAR(hardcode_direct, $1)" != no && + # If the only mechanism to avoid hardcoding is shlibpath_var, we + # have to relink, otherwise we might link with an installed library + # when we should be linking with a yet-to-be-installed one + ## test "$_LT_AC_TAGVAR(hardcode_shlibpath_var, $1)" != no && + test "$_LT_AC_TAGVAR(hardcode_minus_L, $1)" != no; then + # Linking always hardcodes the temporary library directory. + _LT_AC_TAGVAR(hardcode_action, $1)=relink + else + # We can link without hardcoding, and we can hardcode nonexisting dirs. + _LT_AC_TAGVAR(hardcode_action, $1)=immediate + fi +else + # We cannot hardcode anything, or else we can only hardcode existing + # directories. + _LT_AC_TAGVAR(hardcode_action, $1)=unsupported +fi +AC_MSG_RESULT([$_LT_AC_TAGVAR(hardcode_action, $1)]) + +if test "$_LT_AC_TAGVAR(hardcode_action, $1)" = relink; then + # Fast installation is not supported + enable_fast_install=no +elif test "$shlibpath_overrides_runpath" = yes || + test "$enable_shared" = no; then + # Fast installation is not necessary + enable_fast_install=needless +fi +])# AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH + + +# AC_LIBTOOL_SYS_LIB_STRIP +# ------------------------ +AC_DEFUN([AC_LIBTOOL_SYS_LIB_STRIP], +[striplib= +old_striplib= +AC_MSG_CHECKING([whether stripping libraries is possible]) +if test -n "$STRIP" && $STRIP -V 2>&1 | grep "GNU strip" >/dev/null; then + test -z "$old_striplib" && old_striplib="$STRIP --strip-debug" + test -z "$striplib" && striplib="$STRIP --strip-unneeded" + AC_MSG_RESULT([yes]) +else +# FIXME - insert some real tests, host_os isn't really good enough + case $host_os in + darwin*) + if test -n "$STRIP" ; then + striplib="$STRIP -x" + old_striplib="$STRIP -S" + AC_MSG_RESULT([yes]) + else + AC_MSG_RESULT([no]) +fi + ;; + *) + AC_MSG_RESULT([no]) + ;; + esac +fi +])# AC_LIBTOOL_SYS_LIB_STRIP + + +# AC_LIBTOOL_SYS_DYNAMIC_LINKER +# ----------------------------- +# PORTME Fill in your ld.so characteristics +AC_DEFUN([AC_LIBTOOL_SYS_DYNAMIC_LINKER], +[AC_REQUIRE([LT_AC_PROG_SED])dnl +AC_MSG_CHECKING([dynamic linker characteristics]) +library_names_spec= +libname_spec='lib$name' +soname_spec= +shrext_cmds=".so" +postinstall_cmds= +postuninstall_cmds= +finish_cmds= +finish_eval= +shlibpath_var= +shlibpath_overrides_runpath=unknown +version_type=none +dynamic_linker="$host_os ld.so" +sys_lib_dlsearch_path_spec="/lib /usr/lib" +m4_if($1,[],[ +if test "$GCC" = yes; then + case $host_os in + darwin*) lt_awk_arg="/^libraries:/,/LR/" ;; + *) lt_awk_arg="/^libraries:/" ;; + esac + lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e "s,=/,/,g"` + if echo "$lt_search_path_spec" | grep ';' >/dev/null ; then + # if the path contains ";" then we assume it to be the separator + # otherwise default to the standard path separator (i.e. ":") - it is + # assumed that no part of a normal pathname contains ";" but that should + # okay in the real world where ";" in dirpaths is itself problematic. + lt_search_path_spec=`echo "$lt_search_path_spec" | $SED -e 's/;/ /g'` + else + lt_search_path_spec=`echo "$lt_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` + fi + # Ok, now we have the path, separated by spaces, we can step through it + # and add multilib dir if necessary. + lt_tmp_lt_search_path_spec= + lt_multi_os_dir=`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null` + for lt_sys_path in $lt_search_path_spec; do + if test -d "$lt_sys_path/$lt_multi_os_dir"; then + lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path/$lt_multi_os_dir" + else + test -d "$lt_sys_path" && \ + lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path" + fi + done + lt_search_path_spec=`echo $lt_tmp_lt_search_path_spec | awk ' +BEGIN {RS=" "; FS="/|\n";} { + lt_foo=""; + lt_count=0; + for (lt_i = NF; lt_i > 0; lt_i--) { + if ($lt_i != "" && $lt_i != ".") { + if ($lt_i == "..") { + lt_count++; + } else { + if (lt_count == 0) { + lt_foo="/" $lt_i lt_foo; + } else { + lt_count--; + } + } + } + } + if (lt_foo != "") { lt_freq[[lt_foo]]++; } + if (lt_freq[[lt_foo]] == 1) { print lt_foo; } +}'` + sys_lib_search_path_spec=`echo $lt_search_path_spec` +else + sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" +fi]) +need_lib_prefix=unknown +hardcode_into_libs=no + +# when you set need_version to no, make sure it does not cause -set_version +# flags to be left without arguments +need_version=unknown + +case $host_os in +aix3*) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a' + shlibpath_var=LIBPATH + + # AIX 3 has no versioning support, so we append a major version to the name. + soname_spec='${libname}${release}${shared_ext}$major' + ;; + +aix[[4-9]]*) + version_type=linux + need_lib_prefix=no + need_version=no + hardcode_into_libs=yes + if test "$host_cpu" = ia64; then + # AIX 5 supports IA64 + library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}' + shlibpath_var=LD_LIBRARY_PATH + else + # With GCC up to 2.95.x, collect2 would create an import file + # for dependence libraries. The import file would start with + # the line `#! .'. This would cause the generated library to + # depend on `.', always an invalid library. This was fixed in + # development snapshots of GCC prior to 3.0. + case $host_os in + aix4 | aix4.[[01]] | aix4.[[01]].*) + if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' + echo ' yes ' + echo '#endif'; } | ${CC} -E - | grep yes > /dev/null; then + : + else + can_build_shared=no + fi + ;; + esac + # AIX (on Power*) has no versioning support, so currently we can not hardcode correct + # soname into executable. Probably we can add versioning support to + # collect2, so additional links can be useful in future. + if test "$aix_use_runtimelinking" = yes; then + # If using run time linking (on AIX 4.2 or later) use lib.so + # instead of lib.a to let people know that these are not + # typical AIX shared libraries. + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + else + # We preserve .a as extension for shared libraries through AIX4.2 + # and later when we are not doing run time linking. + library_names_spec='${libname}${release}.a $libname.a' + soname_spec='${libname}${release}${shared_ext}$major' + fi + shlibpath_var=LIBPATH + fi + ;; + +amigaos*) + library_names_spec='$libname.ixlibrary $libname.a' + # Create ${libname}_ixlibrary.a entries in /sys/libs. + finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$echo "X$lib" | $Xsed -e '\''s%^.*/\([[^/]]*\)\.ixlibrary$%\1%'\''`; test $rm /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' + ;; + +beos*) + library_names_spec='${libname}${shared_ext}' + dynamic_linker="$host_os ld.so" + shlibpath_var=LIBRARY_PATH + ;; + +bsdi[[45]]*) + version_type=linux + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' + shlibpath_var=LD_LIBRARY_PATH + sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" + sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" + # the default ld.so.conf also contains /usr/contrib/lib and + # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow + # libtool to hard-code these into programs + ;; + +cygwin* | mingw* | pw32*) + version_type=windows + shrext_cmds=".dll" + need_version=no + need_lib_prefix=no + + case $GCC,$host_os in + yes,cygwin* | yes,mingw* | yes,pw32*) + library_names_spec='$libname.dll.a' + # DLL is installed to $(libdir)/../bin by postinstall_cmds + postinstall_cmds='base_file=`basename \${file}`~ + dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i;echo \$dlname'\''`~ + dldir=$destdir/`dirname \$dlpath`~ + test -d \$dldir || mkdir -p \$dldir~ + $install_prog $dir/$dlname \$dldir/$dlname~ + chmod a+x \$dldir/$dlname' + postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ + dlpath=$dir/\$dldll~ + $rm \$dlpath' + shlibpath_overrides_runpath=yes + + case $host_os in + cygwin*) + # Cygwin DLLs use 'cyg' prefix rather than 'lib' + soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' + sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib" + ;; + mingw*) + # MinGW DLLs use traditional 'lib' prefix + soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' + sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"` + if echo "$sys_lib_search_path_spec" | [grep ';[c-zC-Z]:/' >/dev/null]; then + # It is most probably a Windows format PATH printed by + # mingw gcc, but we are running on Cygwin. Gcc prints its search + # path with ; separators, and with drive letters. We can handle the + # drive letters (cygwin fileutils understands them), so leave them, + # especially as we might pass files found there to a mingw objdump, + # which wouldn't understand a cygwinified path. Ahh. + sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` + else + sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` + fi + ;; + pw32*) + # pw32 DLLs use 'pw' prefix rather than 'lib' + library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' + ;; + esac + ;; + + *) + library_names_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext} $libname.lib' + ;; + esac + dynamic_linker='Win32 ld.exe' + # FIXME: first we should search . and the directory the executable is in + shlibpath_var=PATH + ;; + +darwin* | rhapsody*) + dynamic_linker="$host_os dyld" + version_type=darwin + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${versuffix}$shared_ext ${libname}${release}${major}$shared_ext ${libname}$shared_ext' + soname_spec='${libname}${release}${major}$shared_ext' + shlibpath_overrides_runpath=yes + shlibpath_var=DYLD_LIBRARY_PATH + shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`' + m4_if([$1], [],[ + sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/local/lib"]) + sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib' + ;; + +dgux*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + ;; + +freebsd1*) + dynamic_linker=no + ;; + +freebsd* | dragonfly*) + # DragonFly does not have aout. When/if they implement a new + # versioning mechanism, adjust this. + if test -x /usr/bin/objformat; then + objformat=`/usr/bin/objformat` + else + case $host_os in + freebsd[[123]]*) objformat=aout ;; + *) objformat=elf ;; + esac + fi + version_type=freebsd-$objformat + case $version_type in + freebsd-elf*) + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' + need_version=no + need_lib_prefix=no + ;; + freebsd-*) + library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix' + need_version=yes + ;; + esac + shlibpath_var=LD_LIBRARY_PATH + case $host_os in + freebsd2*) + shlibpath_overrides_runpath=yes + ;; + freebsd3.[[01]]* | freebsdelf3.[[01]]*) + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + ;; + freebsd3.[[2-9]]* | freebsdelf3.[[2-9]]* | \ + freebsd4.[[0-5]] | freebsdelf4.[[0-5]] | freebsd4.1.1 | freebsdelf4.1.1) + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + ;; + *) # from 4.6 on, and DragonFly + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + ;; + esac + ;; + +gnu*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + hardcode_into_libs=yes + ;; + +hpux9* | hpux10* | hpux11*) + # Give a soname corresponding to the major version so that dld.sl refuses to + # link against other versions. + version_type=sunos + need_lib_prefix=no + need_version=no + case $host_cpu in + ia64*) + shrext_cmds='.so' + hardcode_into_libs=yes + dynamic_linker="$host_os dld.so" + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + if test "X$HPUX_IA64_MODE" = X32; then + sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" + else + sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" + fi + sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec + ;; + hppa*64*) + shrext_cmds='.sl' + hardcode_into_libs=yes + dynamic_linker="$host_os dld.sl" + shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH + shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64" + sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec + ;; + *) + shrext_cmds='.sl' + dynamic_linker="$host_os dld.sl" + shlibpath_var=SHLIB_PATH + shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + ;; + esac + # HP-UX runs *really* slowly unless shared libraries are mode 555. + postinstall_cmds='chmod 555 $lib' + ;; + +interix[[3-9]]*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + ;; + +irix5* | irix6* | nonstopux*) + case $host_os in + nonstopux*) version_type=nonstopux ;; + *) + if test "$lt_cv_prog_gnu_ld" = yes; then + version_type=linux + else + version_type=irix + fi ;; + esac + need_lib_prefix=no + need_version=no + soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}' + case $host_os in + irix5* | nonstopux*) + libsuff= shlibsuff= + ;; + *) + case $LD in # libtool.m4 will add one of these switches to LD + *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") + libsuff= shlibsuff= libmagic=32-bit;; + *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") + libsuff=32 shlibsuff=N32 libmagic=N32;; + *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") + libsuff=64 shlibsuff=64 libmagic=64-bit;; + *) libsuff= shlibsuff= libmagic=never-match;; + esac + ;; + esac + shlibpath_var=LD_LIBRARY${shlibsuff}_PATH + shlibpath_overrides_runpath=no + sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}" + sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}" + hardcode_into_libs=yes + ;; + +# No shared lib support for Linux oldld, aout, or coff. +linux*oldld* | linux*aout* | linux*coff*) + dynamic_linker=no + ;; + +# This must be Linux ELF. +linux* | k*bsd*-gnu) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + # This implies no fast_install, which is unacceptable. + # Some rework will be needed to allow for fast_install + # before this can be enabled. + hardcode_into_libs=yes + + # Append ld.so.conf contents to the search path + if test -f /etc/ld.so.conf; then + lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \[$]2)); skip = 1; } { if (!skip) print \[$]0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '` + sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" + fi + + # We used to test for /lib/ld.so.1 and disable shared libraries on + # powerpc, because MkLinux only supported shared libraries with the + # GNU dynamic linker. Since this was broken with cross compilers, + # most powerpc-linux boxes support dynamic linking these days and + # people can always --disable-shared, the test was removed, and we + # assume the GNU/Linux dynamic linker is in use. + dynamic_linker='GNU/Linux ld.so' + ;; + +netbsdelf*-gnu) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + dynamic_linker='NetBSD ld.elf_so' + ;; + +netbsd*) + version_type=sunos + need_lib_prefix=no + need_version=no + if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' + dynamic_linker='NetBSD (a.out) ld.so' + else + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + dynamic_linker='NetBSD ld.elf_so' + fi + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + ;; + +newsos6) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + ;; + +nto-qnx*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + ;; + +openbsd*) + version_type=sunos + sys_lib_dlsearch_path_spec="/usr/lib" + need_lib_prefix=no + # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs. + case $host_os in + openbsd3.3 | openbsd3.3.*) need_version=yes ;; + *) need_version=no ;; + esac + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' + shlibpath_var=LD_LIBRARY_PATH + if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + case $host_os in + openbsd2.[[89]] | openbsd2.[[89]].*) + shlibpath_overrides_runpath=no + ;; + *) + shlibpath_overrides_runpath=yes + ;; + esac + else + shlibpath_overrides_runpath=yes + fi + ;; + +os2*) + libname_spec='$name' + shrext_cmds=".dll" + need_lib_prefix=no + library_names_spec='$libname${shared_ext} $libname.a' + dynamic_linker='OS/2 ld.exe' + shlibpath_var=LIBPATH + ;; + +osf3* | osf4* | osf5*) + version_type=osf + need_lib_prefix=no + need_version=no + soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + shlibpath_var=LD_LIBRARY_PATH + sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" + sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec" + ;; + +rdos*) + dynamic_linker=no + ;; + +solaris*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + # ldd complains unless libraries are executable + postinstall_cmds='chmod +x $lib' + ;; + +sunos4*) + version_type=sunos + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' + finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + if test "$with_gnu_ld" = yes; then + need_lib_prefix=no + fi + need_version=yes + ;; + +sysv4 | sysv4.3*) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + case $host_vendor in + sni) + shlibpath_overrides_runpath=no + need_lib_prefix=no + export_dynamic_flag_spec='${wl}-Blargedynsym' + runpath_var=LD_RUN_PATH + ;; + siemens) + need_lib_prefix=no + ;; + motorola) + need_lib_prefix=no + need_version=no + shlibpath_overrides_runpath=no + sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' + ;; + esac + ;; + +sysv4*MP*) + if test -d /usr/nec ;then + version_type=linux + library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}' + soname_spec='$libname${shared_ext}.$major' + shlibpath_var=LD_LIBRARY_PATH + fi + ;; + +sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) + version_type=freebsd-elf + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + hardcode_into_libs=yes + if test "$with_gnu_ld" = yes; then + sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib' + shlibpath_overrides_runpath=no + else + sys_lib_search_path_spec='/usr/ccs/lib /usr/lib' + shlibpath_overrides_runpath=yes + case $host_os in + sco3.2v5*) + sys_lib_search_path_spec="$sys_lib_search_path_spec /lib" + ;; + esac + fi + sys_lib_dlsearch_path_spec='/usr/lib' + ;; + +uts4*) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + ;; + +*) + dynamic_linker=no + ;; +esac +AC_MSG_RESULT([$dynamic_linker]) +test "$dynamic_linker" = no && can_build_shared=no + +AC_CACHE_VAL([lt_cv_sys_lib_search_path_spec], +[lt_cv_sys_lib_search_path_spec="$sys_lib_search_path_spec"]) +sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec" +AC_CACHE_VAL([lt_cv_sys_lib_dlsearch_path_spec], +[lt_cv_sys_lib_dlsearch_path_spec="$sys_lib_dlsearch_path_spec"]) +sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec" + +variables_saved_for_relink="PATH $shlibpath_var $runpath_var" +if test "$GCC" = yes; then + variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" +fi +])# AC_LIBTOOL_SYS_DYNAMIC_LINKER + + +# _LT_AC_TAGCONFIG +# ---------------- +AC_DEFUN([_LT_AC_TAGCONFIG], +[AC_REQUIRE([LT_AC_PROG_SED])dnl +AC_ARG_WITH([tags], + [AC_HELP_STRING([--with-tags@<:@=TAGS@:>@], + [include additional configurations @<:@automatic@:>@])], + [tagnames="$withval"]) + +if test -f "$ltmain" && test -n "$tagnames"; then + if test ! -f "${ofile}"; then + AC_MSG_WARN([output file `$ofile' does not exist]) + fi + + if test -z "$LTCC"; then + eval "`$SHELL ${ofile} --config | grep '^LTCC='`" + if test -z "$LTCC"; then + AC_MSG_WARN([output file `$ofile' does not look like a libtool script]) + else + AC_MSG_WARN([using `LTCC=$LTCC', extracted from `$ofile']) + fi + fi + if test -z "$LTCFLAGS"; then + eval "`$SHELL ${ofile} --config | grep '^LTCFLAGS='`" + fi + + # Extract list of available tagged configurations in $ofile. + # Note that this assumes the entire list is on one line. + available_tags=`grep "^available_tags=" "${ofile}" | $SED -e 's/available_tags=\(.*$\)/\1/' -e 's/\"//g'` + + lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," + for tagname in $tagnames; do + IFS="$lt_save_ifs" + # Check whether tagname contains only valid characters + case `$echo "X$tagname" | $Xsed -e 's:[[-_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890,/]]::g'` in + "") ;; + *) AC_MSG_ERROR([invalid tag name: $tagname]) + ;; + esac + + if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$" < "${ofile}" > /dev/null + then + AC_MSG_ERROR([tag name \"$tagname\" already exists]) + fi + + # Update the list of available tags. + if test -n "$tagname"; then + echo appending configuration tag \"$tagname\" to $ofile + + case $tagname in + CXX) + if test -n "$CXX" && ( test "X$CXX" != "Xno" && + ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) || + (test "X$CXX" != "Xg++"))) ; then + AC_LIBTOOL_LANG_CXX_CONFIG + else + tagname="" + fi + ;; + + F77) + if test -n "$F77" && test "X$F77" != "Xno"; then + AC_LIBTOOL_LANG_F77_CONFIG + else + tagname="" + fi + ;; + + GCJ) + if test -n "$GCJ" && test "X$GCJ" != "Xno"; then + AC_LIBTOOL_LANG_GCJ_CONFIG + else + tagname="" + fi + ;; + + RC) + AC_LIBTOOL_LANG_RC_CONFIG + ;; + + *) + AC_MSG_ERROR([Unsupported tag name: $tagname]) + ;; + esac + + # Append the new tag name to the list of available tags. + if test -n "$tagname" ; then + available_tags="$available_tags $tagname" + fi + fi + done + IFS="$lt_save_ifs" + + # Now substitute the updated list of available tags. + if eval "sed -e 's/^available_tags=.*\$/available_tags=\"$available_tags\"/' \"$ofile\" > \"${ofile}T\""; then + mv "${ofile}T" "$ofile" + chmod +x "$ofile" + else + rm -f "${ofile}T" + AC_MSG_ERROR([unable to update list of available tagged configurations.]) + fi +fi +])# _LT_AC_TAGCONFIG + + +# AC_LIBTOOL_DLOPEN +# ----------------- +# enable checks for dlopen support +AC_DEFUN([AC_LIBTOOL_DLOPEN], + [AC_BEFORE([$0],[AC_LIBTOOL_SETUP]) +])# AC_LIBTOOL_DLOPEN + + +# AC_LIBTOOL_WIN32_DLL +# -------------------- +# declare package support for building win32 DLLs +AC_DEFUN([AC_LIBTOOL_WIN32_DLL], +[AC_BEFORE([$0], [AC_LIBTOOL_SETUP]) +])# AC_LIBTOOL_WIN32_DLL + + +# AC_ENABLE_SHARED([DEFAULT]) +# --------------------------- +# implement the --enable-shared flag +# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. +AC_DEFUN([AC_ENABLE_SHARED], +[define([AC_ENABLE_SHARED_DEFAULT], ifelse($1, no, no, yes))dnl +AC_ARG_ENABLE([shared], + [AC_HELP_STRING([--enable-shared@<:@=PKGS@:>@], + [build shared libraries @<:@default=]AC_ENABLE_SHARED_DEFAULT[@:>@])], + [p=${PACKAGE-default} + case $enableval in + yes) enable_shared=yes ;; + no) enable_shared=no ;; + *) + enable_shared=no + # Look at the argument we got. We use all the common list separators. + lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," + for pkg in $enableval; do + IFS="$lt_save_ifs" + if test "X$pkg" = "X$p"; then + enable_shared=yes + fi + done + IFS="$lt_save_ifs" + ;; + esac], + [enable_shared=]AC_ENABLE_SHARED_DEFAULT) +])# AC_ENABLE_SHARED + + +# AC_DISABLE_SHARED +# ----------------- +# set the default shared flag to --disable-shared +AC_DEFUN([AC_DISABLE_SHARED], +[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl +AC_ENABLE_SHARED(no) +])# AC_DISABLE_SHARED + + +# AC_ENABLE_STATIC([DEFAULT]) +# --------------------------- +# implement the --enable-static flag +# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. +AC_DEFUN([AC_ENABLE_STATIC], +[define([AC_ENABLE_STATIC_DEFAULT], ifelse($1, no, no, yes))dnl +AC_ARG_ENABLE([static], + [AC_HELP_STRING([--enable-static@<:@=PKGS@:>@], + [build static libraries @<:@default=]AC_ENABLE_STATIC_DEFAULT[@:>@])], + [p=${PACKAGE-default} + case $enableval in + yes) enable_static=yes ;; + no) enable_static=no ;; + *) + enable_static=no + # Look at the argument we got. We use all the common list separators. + lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," + for pkg in $enableval; do + IFS="$lt_save_ifs" + if test "X$pkg" = "X$p"; then + enable_static=yes + fi + done + IFS="$lt_save_ifs" + ;; + esac], + [enable_static=]AC_ENABLE_STATIC_DEFAULT) +])# AC_ENABLE_STATIC + + +# AC_DISABLE_STATIC +# ----------------- +# set the default static flag to --disable-static +AC_DEFUN([AC_DISABLE_STATIC], +[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl +AC_ENABLE_STATIC(no) +])# AC_DISABLE_STATIC + + +# AC_ENABLE_FAST_INSTALL([DEFAULT]) +# --------------------------------- +# implement the --enable-fast-install flag +# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. +AC_DEFUN([AC_ENABLE_FAST_INSTALL], +[define([AC_ENABLE_FAST_INSTALL_DEFAULT], ifelse($1, no, no, yes))dnl +AC_ARG_ENABLE([fast-install], + [AC_HELP_STRING([--enable-fast-install@<:@=PKGS@:>@], + [optimize for fast installation @<:@default=]AC_ENABLE_FAST_INSTALL_DEFAULT[@:>@])], + [p=${PACKAGE-default} + case $enableval in + yes) enable_fast_install=yes ;; + no) enable_fast_install=no ;; + *) + enable_fast_install=no + # Look at the argument we got. We use all the common list separators. + lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," + for pkg in $enableval; do + IFS="$lt_save_ifs" + if test "X$pkg" = "X$p"; then + enable_fast_install=yes + fi + done + IFS="$lt_save_ifs" + ;; + esac], + [enable_fast_install=]AC_ENABLE_FAST_INSTALL_DEFAULT) +])# AC_ENABLE_FAST_INSTALL + + +# AC_DISABLE_FAST_INSTALL +# ----------------------- +# set the default to --disable-fast-install +AC_DEFUN([AC_DISABLE_FAST_INSTALL], +[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl +AC_ENABLE_FAST_INSTALL(no) +])# AC_DISABLE_FAST_INSTALL + + +# AC_LIBTOOL_PICMODE([MODE]) +# -------------------------- +# implement the --with-pic flag +# MODE is either `yes' or `no'. If omitted, it defaults to `both'. +AC_DEFUN([AC_LIBTOOL_PICMODE], +[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl +pic_mode=ifelse($#,1,$1,default) +])# AC_LIBTOOL_PICMODE + + +# AC_PROG_EGREP +# ------------- +# This is predefined starting with Autoconf 2.54, so this conditional +# definition can be removed once we require Autoconf 2.54 or later. +m4_ifndef([AC_PROG_EGREP], [AC_DEFUN([AC_PROG_EGREP], +[AC_CACHE_CHECK([for egrep], [ac_cv_prog_egrep], + [if echo a | (grep -E '(a|b)') >/dev/null 2>&1 + then ac_cv_prog_egrep='grep -E' + else ac_cv_prog_egrep='egrep' + fi]) + EGREP=$ac_cv_prog_egrep + AC_SUBST([EGREP]) +])]) + + +# AC_PATH_TOOL_PREFIX +# ------------------- +# find a file program which can recognize shared library +AC_DEFUN([AC_PATH_TOOL_PREFIX], +[AC_REQUIRE([AC_PROG_EGREP])dnl +AC_MSG_CHECKING([for $1]) +AC_CACHE_VAL(lt_cv_path_MAGIC_CMD, +[case $MAGIC_CMD in +[[\\/*] | ?:[\\/]*]) + lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path. + ;; +*) + lt_save_MAGIC_CMD="$MAGIC_CMD" + lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR +dnl $ac_dummy forces splitting on constant user-supplied paths. +dnl POSIX.2 word splitting is done only on the output of word expansions, +dnl not every word. This closes a longstanding sh security hole. + ac_dummy="ifelse([$2], , $PATH, [$2])" + for ac_dir in $ac_dummy; do + IFS="$lt_save_ifs" + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$1; then + lt_cv_path_MAGIC_CMD="$ac_dir/$1" + if test -n "$file_magic_test_file"; then + case $deplibs_check_method in + "file_magic "*) + file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` + MAGIC_CMD="$lt_cv_path_MAGIC_CMD" + if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | + $EGREP "$file_magic_regex" > /dev/null; then + : + else + cat <&2 + +*** Warning: the command libtool uses to detect shared libraries, +*** $file_magic_cmd, produces output that libtool cannot recognize. +*** The result is that libtool may fail to recognize shared libraries +*** as such. This will affect the creation of libtool libraries that +*** depend on shared libraries, but programs linked with such libtool +*** libraries will work regardless of this problem. Nevertheless, you +*** may want to report the problem to your system manager and/or to +*** bug-libtool@gnu.org + +EOF + fi ;; + esac + fi + break + fi + done + IFS="$lt_save_ifs" + MAGIC_CMD="$lt_save_MAGIC_CMD" + ;; +esac]) +MAGIC_CMD="$lt_cv_path_MAGIC_CMD" +if test -n "$MAGIC_CMD"; then + AC_MSG_RESULT($MAGIC_CMD) +else + AC_MSG_RESULT(no) +fi +])# AC_PATH_TOOL_PREFIX + + +# AC_PATH_MAGIC +# ------------- +# find a file program which can recognize a shared library +AC_DEFUN([AC_PATH_MAGIC], +[AC_PATH_TOOL_PREFIX(${ac_tool_prefix}file, /usr/bin$PATH_SEPARATOR$PATH) +if test -z "$lt_cv_path_MAGIC_CMD"; then + if test -n "$ac_tool_prefix"; then + AC_PATH_TOOL_PREFIX(file, /usr/bin$PATH_SEPARATOR$PATH) + else + MAGIC_CMD=: + fi +fi +])# AC_PATH_MAGIC + + +# AC_PROG_LD +# ---------- +# find the pathname to the GNU or non-GNU linker +AC_DEFUN([AC_PROG_LD], +[AC_ARG_WITH([gnu-ld], + [AC_HELP_STRING([--with-gnu-ld], + [assume the C compiler uses GNU ld @<:@default=no@:>@])], + [test "$withval" = no || with_gnu_ld=yes], + [with_gnu_ld=no]) +AC_REQUIRE([LT_AC_PROG_SED])dnl +AC_REQUIRE([AC_PROG_CC])dnl +AC_REQUIRE([AC_CANONICAL_HOST])dnl +AC_REQUIRE([AC_CANONICAL_BUILD])dnl +ac_prog=ld +if test "$GCC" = yes; then + # Check if gcc -print-prog-name=ld gives a path. + AC_MSG_CHECKING([for ld used by $CC]) + case $host in + *-*-mingw*) + # gcc leaves a trailing carriage return which upsets mingw + ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; + *) + ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; + esac + case $ac_prog in + # Accept absolute paths. + [[\\/]]* | ?:[[\\/]]*) + re_direlt='/[[^/]][[^/]]*/\.\./' + # Canonicalize the pathname of ld + ac_prog=`echo $ac_prog| $SED 's%\\\\%/%g'` + while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do + ac_prog=`echo $ac_prog| $SED "s%$re_direlt%/%"` + done + test -z "$LD" && LD="$ac_prog" + ;; + "") + # If it fails, then pretend we aren't using GCC. + ac_prog=ld + ;; + *) + # If it is relative, then search for the first ld in PATH. + with_gnu_ld=unknown + ;; + esac +elif test "$with_gnu_ld" = yes; then + AC_MSG_CHECKING([for GNU ld]) +else + AC_MSG_CHECKING([for non-GNU ld]) +fi +AC_CACHE_VAL(lt_cv_path_LD, +[if test -z "$LD"; then + lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR + for ac_dir in $PATH; do + IFS="$lt_save_ifs" + test -z "$ac_dir" && ac_dir=. + if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then + lt_cv_path_LD="$ac_dir/$ac_prog" + # Check to see if the program is GNU ld. I'd rather use --version, + # but apparently some variants of GNU ld only accept -v. + # Break only if it was the GNU/non-GNU ld that we prefer. + case `"$lt_cv_path_LD" -v 2>&1 &1 /dev/null 2>&1; then + lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' + lt_cv_file_magic_cmd='func_win32_libid' + else + lt_cv_deplibs_check_method='file_magic file format pei*-i386(.*architecture: i386)?' + lt_cv_file_magic_cmd='$OBJDUMP -f' + fi + ;; + +darwin* | rhapsody*) + lt_cv_deplibs_check_method=pass_all + ;; + +freebsd* | dragonfly*) + if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then + case $host_cpu in + i*86 ) + # Not sure whether the presence of OpenBSD here was a mistake. + # Let's accept both of them until this is cleared up. + lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[[3-9]]86 (compact )?demand paged shared library' + lt_cv_file_magic_cmd=/usr/bin/file + lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*` + ;; + esac + else + lt_cv_deplibs_check_method=pass_all + fi + ;; + +gnu*) + lt_cv_deplibs_check_method=pass_all + ;; + +hpux10.20* | hpux11*) + lt_cv_file_magic_cmd=/usr/bin/file + case $host_cpu in + ia64*) + lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|ELF-[[0-9]][[0-9]]) shared object file - IA64' + lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so + ;; + hppa*64*) + [lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - PA-RISC [0-9].[0-9]'] + lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl + ;; + *) + lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|PA-RISC[[0-9]].[[0-9]]) shared library' + lt_cv_file_magic_test_file=/usr/lib/libc.sl + ;; + esac + ;; + +interix[[3-9]]*) + # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here + lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|\.a)$' + ;; + +irix5* | irix6* | nonstopux*) + case $LD in + *-32|*"-32 ") libmagic=32-bit;; + *-n32|*"-n32 ") libmagic=N32;; + *-64|*"-64 ") libmagic=64-bit;; + *) libmagic=never-match;; + esac + lt_cv_deplibs_check_method=pass_all + ;; + +# This must be Linux ELF. +linux* | k*bsd*-gnu) + lt_cv_deplibs_check_method=pass_all + ;; + +netbsd* | netbsdelf*-gnu) + if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then + lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$' + else + lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|_pic\.a)$' + fi + ;; + +newos6*) + lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (executable|dynamic lib)' + lt_cv_file_magic_cmd=/usr/bin/file + lt_cv_file_magic_test_file=/usr/lib/libnls.so + ;; + +nto-qnx*) + lt_cv_deplibs_check_method=unknown + ;; + +openbsd*) + if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|\.so|_pic\.a)$' + else + lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$' + fi + ;; + +osf3* | osf4* | osf5*) + lt_cv_deplibs_check_method=pass_all + ;; + +rdos*) + lt_cv_deplibs_check_method=pass_all + ;; + +solaris*) + lt_cv_deplibs_check_method=pass_all + ;; + +sysv4 | sysv4.3*) + case $host_vendor in + motorola) + lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib) M[[0-9]][[0-9]]* Version [[0-9]]' + lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*` + ;; + ncr) + lt_cv_deplibs_check_method=pass_all + ;; + sequent) + lt_cv_file_magic_cmd='/bin/file' + lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB (shared object|dynamic lib )' + ;; + sni) + lt_cv_file_magic_cmd='/bin/file' + lt_cv_deplibs_check_method="file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB dynamic lib" + lt_cv_file_magic_test_file=/lib/libc.so + ;; + siemens) + lt_cv_deplibs_check_method=pass_all + ;; + pc) + lt_cv_deplibs_check_method=pass_all + ;; + esac + ;; + +sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) + lt_cv_deplibs_check_method=pass_all + ;; +esac +]) +file_magic_cmd=$lt_cv_file_magic_cmd +deplibs_check_method=$lt_cv_deplibs_check_method +test -z "$deplibs_check_method" && deplibs_check_method=unknown +])# AC_DEPLIBS_CHECK_METHOD + + +# AC_PROG_NM +# ---------- +# find the pathname to a BSD-compatible name lister +AC_DEFUN([AC_PROG_NM], +[AC_CACHE_CHECK([for BSD-compatible nm], lt_cv_path_NM, +[if test -n "$NM"; then + # Let the user override the test. + lt_cv_path_NM="$NM" +else + lt_nm_to_check="${ac_tool_prefix}nm" + if test -n "$ac_tool_prefix" && test "$build" = "$host"; then + lt_nm_to_check="$lt_nm_to_check nm" + fi + for lt_tmp_nm in $lt_nm_to_check; do + lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR + for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do + IFS="$lt_save_ifs" + test -z "$ac_dir" && ac_dir=. + tmp_nm="$ac_dir/$lt_tmp_nm" + if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then + # Check to see if the nm accepts a BSD-compat flag. + # Adding the `sed 1q' prevents false positives on HP-UX, which says: + # nm: unknown option "B" ignored + # Tru64's nm complains that /dev/null is an invalid object file + case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in + */dev/null* | *'Invalid file or object type'*) + lt_cv_path_NM="$tmp_nm -B" + break + ;; + *) + case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in + */dev/null*) + lt_cv_path_NM="$tmp_nm -p" + break + ;; + *) + lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but + continue # so that we can try to find one that supports BSD flags + ;; + esac + ;; + esac + fi + done + IFS="$lt_save_ifs" + done + test -z "$lt_cv_path_NM" && lt_cv_path_NM=nm +fi]) +NM="$lt_cv_path_NM" +])# AC_PROG_NM + + +# AC_CHECK_LIBM +# ------------- +# check for math library +AC_DEFUN([AC_CHECK_LIBM], +[AC_REQUIRE([AC_CANONICAL_HOST])dnl +LIBM= +case $host in +*-*-beos* | *-*-cygwin* | *-*-pw32* | *-*-darwin*) + # These system don't have libm, or don't need it + ;; +*-ncr-sysv4.3*) + AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM="-lmw") + AC_CHECK_LIB(m, cos, LIBM="$LIBM -lm") + ;; +*) + AC_CHECK_LIB(m, cos, LIBM="-lm") + ;; +esac +])# AC_CHECK_LIBM + + +# AC_LIBLTDL_CONVENIENCE([DIRECTORY]) +# ----------------------------------- +# sets LIBLTDL to the link flags for the libltdl convenience library and +# LTDLINCL to the include flags for the libltdl header and adds +# --enable-ltdl-convenience to the configure arguments. Note that +# AC_CONFIG_SUBDIRS is not called here. If DIRECTORY is not provided, +# it is assumed to be `libltdl'. LIBLTDL will be prefixed with +# '${top_builddir}/' and LTDLINCL will be prefixed with '${top_srcdir}/' +# (note the single quotes!). If your package is not flat and you're not +# using automake, define top_builddir and top_srcdir appropriately in +# the Makefiles. +AC_DEFUN([AC_LIBLTDL_CONVENIENCE], +[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl + case $enable_ltdl_convenience in + no) AC_MSG_ERROR([this package needs a convenience libltdl]) ;; + "") enable_ltdl_convenience=yes + ac_configure_args="$ac_configure_args --enable-ltdl-convenience" ;; + esac + LIBLTDL='${top_builddir}/'ifelse($#,1,[$1],['libltdl'])/libltdlc.la + LTDLINCL='-I${top_srcdir}/'ifelse($#,1,[$1],['libltdl']) + # For backwards non-gettext consistent compatibility... + INCLTDL="$LTDLINCL" +])# AC_LIBLTDL_CONVENIENCE + + +# AC_LIBLTDL_INSTALLABLE([DIRECTORY]) +# ----------------------------------- +# sets LIBLTDL to the link flags for the libltdl installable library and +# LTDLINCL to the include flags for the libltdl header and adds +# --enable-ltdl-install to the configure arguments. Note that +# AC_CONFIG_SUBDIRS is not called here. If DIRECTORY is not provided, +# and an installed libltdl is not found, it is assumed to be `libltdl'. +# LIBLTDL will be prefixed with '${top_builddir}/'# and LTDLINCL with +# '${top_srcdir}/' (note the single quotes!). If your package is not +# flat and you're not using automake, define top_builddir and top_srcdir +# appropriately in the Makefiles. +# In the future, this macro may have to be called after AC_PROG_LIBTOOL. +AC_DEFUN([AC_LIBLTDL_INSTALLABLE], +[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl + AC_CHECK_LIB(ltdl, lt_dlinit, + [test x"$enable_ltdl_install" != xyes && enable_ltdl_install=no], + [if test x"$enable_ltdl_install" = xno; then + AC_MSG_WARN([libltdl not installed, but installation disabled]) + else + enable_ltdl_install=yes + fi + ]) + if test x"$enable_ltdl_install" = x"yes"; then + ac_configure_args="$ac_configure_args --enable-ltdl-install" + LIBLTDL='${top_builddir}/'ifelse($#,1,[$1],['libltdl'])/libltdl.la + LTDLINCL='-I${top_srcdir}/'ifelse($#,1,[$1],['libltdl']) + else + ac_configure_args="$ac_configure_args --enable-ltdl-install=no" + LIBLTDL="-lltdl" + LTDLINCL= + fi + # For backwards non-gettext consistent compatibility... + INCLTDL="$LTDLINCL" +])# AC_LIBLTDL_INSTALLABLE + + +# AC_LIBTOOL_CXX +# -------------- +# enable support for C++ libraries +AC_DEFUN([AC_LIBTOOL_CXX], +[AC_REQUIRE([_LT_AC_LANG_CXX]) +])# AC_LIBTOOL_CXX + + +# _LT_AC_LANG_CXX +# --------------- +AC_DEFUN([_LT_AC_LANG_CXX], +[AC_REQUIRE([AC_PROG_CXX]) +AC_REQUIRE([_LT_AC_PROG_CXXCPP]) +_LT_AC_SHELL_INIT([tagnames=${tagnames+${tagnames},}CXX]) +])# _LT_AC_LANG_CXX + +# _LT_AC_PROG_CXXCPP +# ------------------ +AC_DEFUN([_LT_AC_PROG_CXXCPP], +[ +AC_REQUIRE([AC_PROG_CXX]) +if test -n "$CXX" && ( test "X$CXX" != "Xno" && + ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) || + (test "X$CXX" != "Xg++"))) ; then + AC_PROG_CXXCPP +fi +])# _LT_AC_PROG_CXXCPP + +# AC_LIBTOOL_F77 +# -------------- +# enable support for Fortran 77 libraries +AC_DEFUN([AC_LIBTOOL_F77], +[AC_REQUIRE([_LT_AC_LANG_F77]) +])# AC_LIBTOOL_F77 + + +# _LT_AC_LANG_F77 +# --------------- +AC_DEFUN([_LT_AC_LANG_F77], +[AC_REQUIRE([AC_PROG_F77]) +_LT_AC_SHELL_INIT([tagnames=${tagnames+${tagnames},}F77]) +])# _LT_AC_LANG_F77 + + +# AC_LIBTOOL_GCJ +# -------------- +# enable support for GCJ libraries +AC_DEFUN([AC_LIBTOOL_GCJ], +[AC_REQUIRE([_LT_AC_LANG_GCJ]) +])# AC_LIBTOOL_GCJ + + +# _LT_AC_LANG_GCJ +# --------------- +AC_DEFUN([_LT_AC_LANG_GCJ], +[AC_PROVIDE_IFELSE([AC_PROG_GCJ],[], + [AC_PROVIDE_IFELSE([A][M_PROG_GCJ],[], + [AC_PROVIDE_IFELSE([LT_AC_PROG_GCJ],[], + [ifdef([AC_PROG_GCJ],[AC_REQUIRE([AC_PROG_GCJ])], + [ifdef([A][M_PROG_GCJ],[AC_REQUIRE([A][M_PROG_GCJ])], + [AC_REQUIRE([A][C_PROG_GCJ_OR_A][M_PROG_GCJ])])])])])]) +_LT_AC_SHELL_INIT([tagnames=${tagnames+${tagnames},}GCJ]) +])# _LT_AC_LANG_GCJ + + +# AC_LIBTOOL_RC +# ------------- +# enable support for Windows resource files +AC_DEFUN([AC_LIBTOOL_RC], +[AC_REQUIRE([LT_AC_PROG_RC]) +_LT_AC_SHELL_INIT([tagnames=${tagnames+${tagnames},}RC]) +])# AC_LIBTOOL_RC + + +# AC_LIBTOOL_LANG_C_CONFIG +# ------------------------ +# Ensure that the configuration vars for the C compiler are +# suitably defined. Those variables are subsequently used by +# AC_LIBTOOL_CONFIG to write the compiler configuration to `libtool'. +AC_DEFUN([AC_LIBTOOL_LANG_C_CONFIG], [_LT_AC_LANG_C_CONFIG]) +AC_DEFUN([_LT_AC_LANG_C_CONFIG], +[lt_save_CC="$CC" +AC_LANG_PUSH(C) + +# Source file extension for C test sources. +ac_ext=c + +# Object file extension for compiled C test sources. +objext=o +_LT_AC_TAGVAR(objext, $1)=$objext + +# Code to be used in simple compile tests +lt_simple_compile_test_code="int some_variable = 0;" + +# Code to be used in simple link tests +lt_simple_link_test_code='int main(){return(0);}' + +_LT_AC_SYS_COMPILER + +# save warnings/boilerplate of simple test code +_LT_COMPILER_BOILERPLATE +_LT_LINKER_BOILERPLATE + +AC_LIBTOOL_PROG_COMPILER_NO_RTTI($1) +AC_LIBTOOL_PROG_COMPILER_PIC($1) +AC_LIBTOOL_PROG_CC_C_O($1) +AC_LIBTOOL_SYS_HARD_LINK_LOCKS($1) +AC_LIBTOOL_PROG_LD_SHLIBS($1) +AC_LIBTOOL_SYS_DYNAMIC_LINKER($1) +AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH($1) +AC_LIBTOOL_SYS_LIB_STRIP +AC_LIBTOOL_DLOPEN_SELF + +# Report which library types will actually be built +AC_MSG_CHECKING([if libtool supports shared libraries]) +AC_MSG_RESULT([$can_build_shared]) + +AC_MSG_CHECKING([whether to build shared libraries]) +test "$can_build_shared" = "no" && enable_shared=no + +# On AIX, shared libraries and static libraries use the same namespace, and +# are all built from PIC. +case $host_os in +aix3*) + test "$enable_shared" = yes && enable_static=no + if test -n "$RANLIB"; then + archive_cmds="$archive_cmds~\$RANLIB \$lib" + postinstall_cmds='$RANLIB $lib' + fi + ;; + +aix[[4-9]]*) + if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then + test "$enable_shared" = yes && enable_static=no + fi + ;; +esac +AC_MSG_RESULT([$enable_shared]) + +AC_MSG_CHECKING([whether to build static libraries]) +# Make sure either enable_shared or enable_static is yes. +test "$enable_shared" = yes || enable_static=yes +AC_MSG_RESULT([$enable_static]) + +AC_LIBTOOL_CONFIG($1) + +AC_LANG_POP +CC="$lt_save_CC" +])# AC_LIBTOOL_LANG_C_CONFIG + + +# AC_LIBTOOL_LANG_CXX_CONFIG +# -------------------------- +# Ensure that the configuration vars for the C compiler are +# suitably defined. Those variables are subsequently used by +# AC_LIBTOOL_CONFIG to write the compiler configuration to `libtool'. +AC_DEFUN([AC_LIBTOOL_LANG_CXX_CONFIG], [_LT_AC_LANG_CXX_CONFIG(CXX)]) +AC_DEFUN([_LT_AC_LANG_CXX_CONFIG], +[AC_LANG_PUSH(C++) +AC_REQUIRE([AC_PROG_CXX]) +AC_REQUIRE([_LT_AC_PROG_CXXCPP]) + +_LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no +_LT_AC_TAGVAR(allow_undefined_flag, $1)= +_LT_AC_TAGVAR(always_export_symbols, $1)=no +_LT_AC_TAGVAR(archive_expsym_cmds, $1)= +_LT_AC_TAGVAR(export_dynamic_flag_spec, $1)= +_LT_AC_TAGVAR(hardcode_direct, $1)=no +_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)= +_LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)= +_LT_AC_TAGVAR(hardcode_libdir_separator, $1)= +_LT_AC_TAGVAR(hardcode_minus_L, $1)=no +_LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=unsupported +_LT_AC_TAGVAR(hardcode_automatic, $1)=no +_LT_AC_TAGVAR(module_cmds, $1)= +_LT_AC_TAGVAR(module_expsym_cmds, $1)= +_LT_AC_TAGVAR(link_all_deplibs, $1)=unknown +_LT_AC_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds +_LT_AC_TAGVAR(no_undefined_flag, $1)= +_LT_AC_TAGVAR(whole_archive_flag_spec, $1)= +_LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=no + +# Dependencies to place before and after the object being linked: +_LT_AC_TAGVAR(predep_objects, $1)= +_LT_AC_TAGVAR(postdep_objects, $1)= +_LT_AC_TAGVAR(predeps, $1)= +_LT_AC_TAGVAR(postdeps, $1)= +_LT_AC_TAGVAR(compiler_lib_search_path, $1)= +_LT_AC_TAGVAR(compiler_lib_search_dirs, $1)= + +# Source file extension for C++ test sources. +ac_ext=cpp + +# Object file extension for compiled C++ test sources. +objext=o +_LT_AC_TAGVAR(objext, $1)=$objext + +# Code to be used in simple compile tests +lt_simple_compile_test_code="int some_variable = 0;" + +# Code to be used in simple link tests +lt_simple_link_test_code='int main(int, char *[[]]) { return(0); }' + +# ltmain only uses $CC for tagged configurations so make sure $CC is set. +_LT_AC_SYS_COMPILER + +# save warnings/boilerplate of simple test code +_LT_COMPILER_BOILERPLATE +_LT_LINKER_BOILERPLATE + +# Allow CC to be a program name with arguments. +lt_save_CC=$CC +lt_save_LD=$LD +lt_save_GCC=$GCC +GCC=$GXX +lt_save_with_gnu_ld=$with_gnu_ld +lt_save_path_LD=$lt_cv_path_LD +if test -n "${lt_cv_prog_gnu_ldcxx+set}"; then + lt_cv_prog_gnu_ld=$lt_cv_prog_gnu_ldcxx +else + $as_unset lt_cv_prog_gnu_ld +fi +if test -n "${lt_cv_path_LDCXX+set}"; then + lt_cv_path_LD=$lt_cv_path_LDCXX +else + $as_unset lt_cv_path_LD +fi +test -z "${LDCXX+set}" || LD=$LDCXX +CC=${CXX-"c++"} +compiler=$CC +_LT_AC_TAGVAR(compiler, $1)=$CC +_LT_CC_BASENAME([$compiler]) + +# We don't want -fno-exception wen compiling C++ code, so set the +# no_builtin_flag separately +if test "$GXX" = yes; then + _LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin' +else + _LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)= +fi + +if test "$GXX" = yes; then + # Set up default GNU C++ configuration + + AC_PROG_LD + + # Check if GNU C++ uses GNU ld as the underlying linker, since the + # archiving commands below assume that GNU ld is being used. + if test "$with_gnu_ld" = yes; then + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir' + _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' + + # If archive_cmds runs LD, not CC, wlarc should be empty + # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to + # investigate it a little bit more. (MM) + wlarc='${wl}' + + # ancient GNU ld didn't support --whole-archive et. al. + if eval "`$CC -print-prog-name=ld` --help 2>&1" | \ + grep 'no-whole-archive' > /dev/null; then + _LT_AC_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' + else + _LT_AC_TAGVAR(whole_archive_flag_spec, $1)= + fi + else + with_gnu_ld=no + wlarc= + + # A generic and very simple default shared library creation + # command for GNU C++ for the case where it uses the native + # linker, instead of GNU ld. If possible, this setting should + # overridden to take advantage of the native linker features on + # the platform it is being used on. + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' + fi + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "\-L"' + +else + GXX=no + with_gnu_ld=no + wlarc= +fi + +# PORTME: fill in a description of your system's C++ link characteristics +AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries]) +_LT_AC_TAGVAR(ld_shlibs, $1)=yes +case $host_os in + aix3*) + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + aix[[4-9]]*) + if test "$host_cpu" = ia64; then + # On IA64, the linker does run time linking by default, so we don't + # have to do anything special. + aix_use_runtimelinking=no + exp_sym_flag='-Bexport' + no_entry_flag="" + else + aix_use_runtimelinking=no + + # Test if we are trying to use run time linking or normal + # AIX style linking. If -brtl is somewhere in LDFLAGS, we + # need to do runtime linking. + case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*) + for ld_flag in $LDFLAGS; do + case $ld_flag in + *-brtl*) + aix_use_runtimelinking=yes + break + ;; + esac + done + ;; + esac + + exp_sym_flag='-bexport' + no_entry_flag='-bnoentry' + fi + + # When large executables or shared objects are built, AIX ld can + # have problems creating the table of contents. If linking a library + # or program results in "error TOC overflow" add -mminimal-toc to + # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not + # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. + + _LT_AC_TAGVAR(archive_cmds, $1)='' + _LT_AC_TAGVAR(hardcode_direct, $1)=yes + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=':' + _LT_AC_TAGVAR(link_all_deplibs, $1)=yes + + if test "$GXX" = yes; then + case $host_os in aix4.[[012]]|aix4.[[012]].*) + # We only want to do this on AIX 4.2 and lower, the check + # below for broken collect2 doesn't work under 4.3+ + collect2name=`${CC} -print-prog-name=collect2` + if test -f "$collect2name" && \ + strings "$collect2name" | grep resolve_lib_name >/dev/null + then + # We have reworked collect2 + : + else + # We have old collect2 + _LT_AC_TAGVAR(hardcode_direct, $1)=unsupported + # It fails to find uninstalled libraries when the uninstalled + # path is not listed in the libpath. Setting hardcode_minus_L + # to unsupported forces relinking + _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)= + fi + ;; + esac + shared_flag='-shared' + if test "$aix_use_runtimelinking" = yes; then + shared_flag="$shared_flag "'${wl}-G' + fi + else + # not using gcc + if test "$host_cpu" = ia64; then + # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release + # chokes on -Wl,-G. The following line is correct: + shared_flag='-G' + else + if test "$aix_use_runtimelinking" = yes; then + shared_flag='${wl}-G' + else + shared_flag='${wl}-bM:SRE' + fi + fi + fi + + # It seems that -bexpall does not export symbols beginning with + # underscore (_), so it is better to generate a list of symbols to export. + _LT_AC_TAGVAR(always_export_symbols, $1)=yes + if test "$aix_use_runtimelinking" = yes; then + # Warning - without using the other runtime loading flags (-brtl), + # -berok will link without error, but may produce a broken library. + _LT_AC_TAGVAR(allow_undefined_flag, $1)='-berok' + # Determine the default libpath from the value encoded in an empty executable. + _LT_AC_SYS_LIBPATH_AIX + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" + + _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" + else + if test "$host_cpu" = ia64; then + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib' + _LT_AC_TAGVAR(allow_undefined_flag, $1)="-z nodefs" + _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols" + else + # Determine the default libpath from the value encoded in an empty executable. + _LT_AC_SYS_LIBPATH_AIX + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" + # Warning - without using the other run time loading flags, + # -berok will link without error, but may produce a broken library. + _LT_AC_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok' + _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok' + # Exported symbols can be pulled into shared objects from archives + _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='$convenience' + _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=yes + # This is similar to how AIX traditionally builds its shared libraries. + _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' + fi + fi + ;; + + beos*) + if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported + # Joseph Beckenbach says some releases of gcc + # support --undefined. This deserves some investigation. FIXME + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + else + _LT_AC_TAGVAR(ld_shlibs, $1)=no + fi + ;; + + chorus*) + case $cc_basename in + *) + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + esac + ;; + + cygwin* | mingw* | pw32*) + # _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless, + # as there is no search path for DLLs. + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported + _LT_AC_TAGVAR(always_export_symbols, $1)=no + _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=yes + + if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' + # If the export-symbols file already is a .def file (1st line + # is EXPORTS), use it as is; otherwise, prepend... + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then + cp $export_symbols $output_objdir/$soname.def; + else + echo EXPORTS > $output_objdir/$soname.def; + cat $export_symbols >> $output_objdir/$soname.def; + fi~ + $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' + else + _LT_AC_TAGVAR(ld_shlibs, $1)=no + fi + ;; + darwin* | rhapsody*) + _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no + _LT_AC_TAGVAR(hardcode_direct, $1)=no + _LT_AC_TAGVAR(hardcode_automatic, $1)=yes + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=unsupported + _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='' + _LT_AC_TAGVAR(link_all_deplibs, $1)=yes + _LT_AC_TAGVAR(allow_undefined_flag, $1)="$_lt_dar_allow_undefined" + if test "$GXX" = yes ; then + output_verbose_link_cmd='echo' + _LT_AC_TAGVAR(archive_cmds, $1)="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}" + _LT_AC_TAGVAR(module_cmds, $1)="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}" + _LT_AC_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}" + _LT_AC_TAGVAR(module_expsym_cmds, $1)="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}" + if test "$lt_cv_apple_cc_single_mod" != "yes"; then + _LT_AC_TAGVAR(archive_cmds, $1)="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dsymutil}" + _LT_AC_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dar_export_syms}${_lt_dsymutil}" + fi + else + case $cc_basename in + xlc*) + output_verbose_link_cmd='echo' + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj ${wl}-single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $xlcverstring' + _LT_AC_TAGVAR(module_cmds, $1)='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags' + # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj ${wl}-single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $xlcverstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' + _LT_AC_TAGVAR(module_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' + ;; + *) + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + esac + fi + ;; + + dgux*) + case $cc_basename in + ec++*) + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + ghcx*) + # Green Hills C++ Compiler + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + *) + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + esac + ;; + freebsd[[12]]*) + # C++ shared libraries reported to be fairly broken before switch to ELF + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + freebsd-elf*) + _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no + ;; + freebsd* | dragonfly*) + # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF + # conventions + _LT_AC_TAGVAR(ld_shlibs, $1)=yes + ;; + gnu*) + ;; + hpux9*) + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: + _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' + _LT_AC_TAGVAR(hardcode_direct, $1)=yes + _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH, + # but as the default + # location of the library. + + case $cc_basename in + CC*) + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + aCC*) + _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/$soname~$CC -b ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # explicitly linking system object files so we need to strip them + # from the output so that they don't get included in the library + # dependencies. + output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | grep "[[-]]L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list' + ;; + *) + if test "$GXX" = yes; then + _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/$soname~$CC -shared -nostdlib -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' + else + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + fi + ;; + esac + ;; + hpux10*|hpux11*) + if test $with_gnu_ld = no; then + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: + + case $host_cpu in + hppa*64*|ia64*) ;; + *) + _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' + ;; + esac + fi + case $host_cpu in + hppa*64*|ia64*) + _LT_AC_TAGVAR(hardcode_direct, $1)=no + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + *) + _LT_AC_TAGVAR(hardcode_direct, $1)=yes + _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH, + # but as the default + # location of the library. + ;; + esac + + case $cc_basename in + CC*) + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + aCC*) + case $host_cpu in + hppa*64*) + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + ;; + ia64*) + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + ;; + *) + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + ;; + esac + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # explicitly linking system object files so we need to strip them + # from the output so that they don't get included in the library + # dependencies. + output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | grep "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list' + ;; + *) + if test "$GXX" = yes; then + if test $with_gnu_ld = no; then + case $host_cpu in + hppa*64*) + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + ;; + ia64*) + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + ;; + *) + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + ;; + esac + fi + else + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + fi + ;; + esac + ;; + interix[[3-9]]*) + _LT_AC_TAGVAR(hardcode_direct, $1)=no + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' + _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' + # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. + # Instead, shared libraries are loaded at an image base (0x10000000 by + # default) and relocated if they conflict, which is a slow very memory + # consuming and fragmenting process. To avoid this, we pick a random, + # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link + # time. Moving up from 0x10000000 also allows more sbrk(2) space. + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' + ;; + irix5* | irix6*) + case $cc_basename in + CC*) + # SGI C++ + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' + + # Archives containing C++ object files must be created using + # "CC -ar", where "CC" is the IRIX C++ compiler. This is + # necessary to make sure instantiated templates are included + # in the archive. + _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -ar -WR,-u -o $oldlib $oldobjs' + ;; + *) + if test "$GXX" = yes; then + if test "$with_gnu_ld" = no; then + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + else + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` -o $lib' + fi + fi + _LT_AC_TAGVAR(link_all_deplibs, $1)=yes + ;; + esac + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: + ;; + linux* | k*bsd*-gnu) + case $cc_basename in + KCC*) + # Kuck and Associates, Inc. (KAI) C++ Compiler + + # KCC will only create a shared library if the output file + # ends with ".so" (or ".sl" for HP-UX), so rename the library + # to its proper name (with version) after linking. + _LT_AC_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib ${wl}-retain-symbols-file,$export_symbols; mv \$templib $lib' + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # explicitly linking system object files so we need to strip them + # from the output so that they don't get included in the library + # dependencies. + output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | grep "ld"`; rm -f libconftest$shared_ext; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list' + + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath,$libdir' + _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' + + # Archives containing C++ object files must be created using + # "CC -Bstatic", where "CC" is the KAI C++ compiler. + _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs' + ;; + icpc*) + # Intel C++ + with_gnu_ld=yes + # version 8.0 and above of icpc choke on multiply defined symbols + # if we add $predep_objects and $postdep_objects, however 7.1 and + # earlier do not add the objects themselves. + case `$CC -V 2>&1` in + *"Version 7."*) + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + ;; + *) # Version 8.0 or newer + tmp_idyn= + case $host_cpu in + ia64*) tmp_idyn=' -i_dynamic';; + esac + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + ;; + esac + _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' + _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' + _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive' + ;; + pgCC* | pgcpp*) + # Portland Group C++ compiler + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib' + + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir' + _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' + _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive' + ;; + cxx*) + # Compaq C++ + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib ${wl}-retain-symbols-file $wl$export_symbols' + + runpath_var=LD_RUN_PATH + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # explicitly linking system object files so we need to strip them + # from the output so that they don't get included in the library + # dependencies. + output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "ld"`; templist=`echo $templist | $SED "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list' + ;; + *) + case `$CC -V 2>&1 | sed 5q` in + *Sun\ C*) + # Sun C++ 5.9 + _LT_AC_TAGVAR(no_undefined_flag, $1)=' -zdefs' + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file ${wl}$export_symbols' + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive' + + # Not sure whether something based on + # $CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 + # would be better. + output_verbose_link_cmd='echo' + + # Archives containing C++ object files must be created using + # "CC -xar", where "CC" is the Sun C++ compiler. This is + # necessary to make sure instantiated templates are included + # in the archive. + _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs' + ;; + esac + ;; + esac + ;; + lynxos*) + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + m88k*) + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + mvs*) + case $cc_basename in + cxx*) + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + *) + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + esac + ;; + netbsd* | netbsdelf*-gnu) + if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags' + wlarc= + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + _LT_AC_TAGVAR(hardcode_direct, $1)=yes + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + fi + # Workaround some broken pre-1.5 toolchains + output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep conftest.$objext | $SED -e "s:-lgcc -lc -lgcc::"' + ;; + openbsd2*) + # C++ shared libraries are fairly broken + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + openbsd*) + if test -f /usr/libexec/ld.so; then + _LT_AC_TAGVAR(hardcode_direct, $1)=yes + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' + if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file,$export_symbols -o $lib' + _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' + _LT_AC_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' + fi + output_verbose_link_cmd='echo' + else + _LT_AC_TAGVAR(ld_shlibs, $1)=no + fi + ;; + osf3*) + case $cc_basename in + KCC*) + # Kuck and Associates, Inc. (KAI) C++ Compiler + + # KCC will only create a shared library if the output file + # ends with ".so" (or ".sl" for HP-UX), so rename the library + # to its proper name (with version) after linking. + _LT_AC_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' + + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: + + # Archives containing C++ object files must be created using + # "CC -Bstatic", where "CC" is the KAI C++ compiler. + _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs' + + ;; + RCC*) + # Rational C++ 2.4.1 + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + cxx*) + _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && echo ${wl}-set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' + + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # explicitly linking system object files so we need to strip them + # from the output so that they don't get included in the library + # dependencies. + output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "ld" | grep -v "ld:"`; templist=`echo $templist | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list' + ;; + *) + if test "$GXX" = yes && test "$with_gnu_ld" = no; then + _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "\-L"' + + else + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + fi + ;; + esac + ;; + osf4* | osf5*) + case $cc_basename in + KCC*) + # Kuck and Associates, Inc. (KAI) C++ Compiler + + # KCC will only create a shared library if the output file + # ends with ".so" (or ".sl" for HP-UX), so rename the library + # to its proper name (with version) after linking. + _LT_AC_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' + + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: + + # Archives containing C++ object files must be created using + # the KAI C++ compiler. + _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -o $oldlib $oldobjs' + ;; + RCC*) + # Rational C++ 2.4.1 + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + cxx*) + _LT_AC_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~ + echo "-hidden">> $lib.exp~ + $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname -Wl,-input -Wl,$lib.exp `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib~ + $rm $lib.exp' + + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # explicitly linking system object files so we need to strip them + # from the output so that they don't get included in the library + # dependencies. + output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "ld" | grep -v "ld:"`; templist=`echo $templist | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list' + ;; + *) + if test "$GXX" = yes && test "$with_gnu_ld" = no; then + _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "\-L"' + + else + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + fi + ;; + esac + ;; + psos*) + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + sunos4*) + case $cc_basename in + CC*) + # Sun C++ 4.x + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + lcc*) + # Lucid + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + *) + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + esac + ;; + solaris*) + case $cc_basename in + CC*) + # Sun C++ 4.2, 5.x and Centerline C++ + _LT_AC_TAGVAR(archive_cmds_need_lc,$1)=yes + _LT_AC_TAGVAR(no_undefined_flag, $1)=' -zdefs' + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ + $CC -G${allow_undefined_flag} ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp' + + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + case $host_os in + solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; + *) + # The compiler driver will combine and reorder linker options, + # but understands `-z linker_flag'. + # Supported since Solaris 2.6 (maybe 2.5.1?) + _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract' + ;; + esac + _LT_AC_TAGVAR(link_all_deplibs, $1)=yes + + output_verbose_link_cmd='echo' + + # Archives containing C++ object files must be created using + # "CC -xar", where "CC" is the Sun C++ compiler. This is + # necessary to make sure instantiated templates are included + # in the archive. + _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs' + ;; + gcx*) + # Green Hills C++ Compiler + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' + + # The C++ compiler must be used to create the archive. + _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC $LDFLAGS -archive -o $oldlib $oldobjs' + ;; + *) + # GNU C++ compiler with Solaris linker + if test "$GXX" = yes && test "$with_gnu_ld" = no; then + _LT_AC_TAGVAR(no_undefined_flag, $1)=' ${wl}-z ${wl}defs' + if $CC --version | grep -v '^2\.7' > /dev/null; then + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ + $CC -shared -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp' + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + output_verbose_link_cmd="$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep \"\-L\"" + else + # g++ 2.7 appears to require `-G' NOT `-shared' on this + # platform. + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ + $CC -G -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp' + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + output_verbose_link_cmd="$CC -G $CFLAGS -v conftest.$objext 2>&1 | grep \"\-L\"" + fi + + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $wl$libdir' + case $host_os in + solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; + *) + _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract' + ;; + esac + fi + ;; + esac + ;; + sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*) + _LT_AC_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' + _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + runpath_var='LD_RUN_PATH' + + case $cc_basename in + CC*) + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + *) + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + esac + ;; + sysv5* | sco3.2v5* | sco5v6*) + # Note: We can NOT use -z defs as we might desire, because we do not + # link with -lc, and that would cause any symbols used from libc to + # always be unresolved, which means just about no library would + # ever link correctly. If we're not using GNU ld we use -z text + # though, which does catch some bad symbols but isn't as heavy-handed + # as -z defs. + # For security reasons, it is highly recommended that you always + # use absolute paths for naming shared libraries, and exclude the + # DT_RUNPATH tag from executables and libraries. But doing so + # requires that you compile everything twice, which is a pain. + # So that behaviour is only enabled if SCOABSPATH is set to a + # non-empty value in the environment. Most likely only useful for + # creating official distributions of packages. + # This is a hack until libtool officially supports absolute path + # names for shared libraries. + _LT_AC_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' + _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs' + _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='`test -z "$SCOABSPATH" && echo ${wl}-R,$libdir`' + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=':' + _LT_AC_TAGVAR(link_all_deplibs, $1)=yes + _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport' + runpath_var='LD_RUN_PATH' + + case $cc_basename in + CC*) + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + *) + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + esac + ;; + tandem*) + case $cc_basename in + NCC*) + # NonStop-UX NCC 3.20 + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + *) + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + esac + ;; + vxworks*) + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + *) + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; +esac +AC_MSG_RESULT([$_LT_AC_TAGVAR(ld_shlibs, $1)]) +test "$_LT_AC_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no + +_LT_AC_TAGVAR(GCC, $1)="$GXX" +_LT_AC_TAGVAR(LD, $1)="$LD" + +AC_LIBTOOL_POSTDEP_PREDEP($1) +AC_LIBTOOL_PROG_COMPILER_PIC($1) +AC_LIBTOOL_PROG_CC_C_O($1) +AC_LIBTOOL_SYS_HARD_LINK_LOCKS($1) +AC_LIBTOOL_PROG_LD_SHLIBS($1) +AC_LIBTOOL_SYS_DYNAMIC_LINKER($1) +AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH($1) + +AC_LIBTOOL_CONFIG($1) + +AC_LANG_POP +CC=$lt_save_CC +LDCXX=$LD +LD=$lt_save_LD +GCC=$lt_save_GCC +with_gnu_ldcxx=$with_gnu_ld +with_gnu_ld=$lt_save_with_gnu_ld +lt_cv_path_LDCXX=$lt_cv_path_LD +lt_cv_path_LD=$lt_save_path_LD +lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld +lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld +])# AC_LIBTOOL_LANG_CXX_CONFIG + +# AC_LIBTOOL_POSTDEP_PREDEP([TAGNAME]) +# ------------------------------------ +# Figure out "hidden" library dependencies from verbose +# compiler output when linking a shared library. +# Parse the compiler output and extract the necessary +# objects, libraries and library flags. +AC_DEFUN([AC_LIBTOOL_POSTDEP_PREDEP], +[AC_REQUIRE([LT_AC_PROG_SED])dnl +dnl we can't use the lt_simple_compile_test_code here, +dnl because it contains code intended for an executable, +dnl not a library. It's possible we should let each +dnl tag define a new lt_????_link_test_code variable, +dnl but it's only used here... +ifelse([$1],[],[cat > conftest.$ac_ext < conftest.$ac_ext < conftest.$ac_ext < conftest.$ac_ext <&1 | sed 5q` in + *Sun\ C*) + # Sun C++ 5.9 + # + # The more standards-conforming stlport4 library is + # incompatible with the Cstd library. Avoid specifying + # it if it's in CXXFLAGS. Ignore libCrun as + # -library=stlport4 depends on it. + case " $CXX $CXXFLAGS " in + *" -library=stlport4 "*) + solaris_use_stlport4=yes + ;; + esac + if test "$solaris_use_stlport4" != yes; then + _LT_AC_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun' + fi + ;; + esac + ;; + +solaris*) + case $cc_basename in + CC*) + # The more standards-conforming stlport4 library is + # incompatible with the Cstd library. Avoid specifying + # it if it's in CXXFLAGS. Ignore libCrun as + # -library=stlport4 depends on it. + case " $CXX $CXXFLAGS " in + *" -library=stlport4 "*) + solaris_use_stlport4=yes + ;; + esac + + # Adding this requires a known-good setup of shared libraries for + # Sun compiler versions before 5.6, else PIC objects from an old + # archive will be linked into the output, leading to subtle bugs. + if test "$solaris_use_stlport4" != yes; then + _LT_AC_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun' + fi + ;; + esac + ;; +esac +]) +case " $_LT_AC_TAGVAR(postdeps, $1) " in +*" -lc "*) _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no ;; +esac +])# AC_LIBTOOL_POSTDEP_PREDEP + +# AC_LIBTOOL_LANG_F77_CONFIG +# -------------------------- +# Ensure that the configuration vars for the C compiler are +# suitably defined. Those variables are subsequently used by +# AC_LIBTOOL_CONFIG to write the compiler configuration to `libtool'. +AC_DEFUN([AC_LIBTOOL_LANG_F77_CONFIG], [_LT_AC_LANG_F77_CONFIG(F77)]) +AC_DEFUN([_LT_AC_LANG_F77_CONFIG], +[AC_REQUIRE([AC_PROG_F77]) +AC_LANG_PUSH(Fortran 77) + +_LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no +_LT_AC_TAGVAR(allow_undefined_flag, $1)= +_LT_AC_TAGVAR(always_export_symbols, $1)=no +_LT_AC_TAGVAR(archive_expsym_cmds, $1)= +_LT_AC_TAGVAR(export_dynamic_flag_spec, $1)= +_LT_AC_TAGVAR(hardcode_direct, $1)=no +_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)= +_LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)= +_LT_AC_TAGVAR(hardcode_libdir_separator, $1)= +_LT_AC_TAGVAR(hardcode_minus_L, $1)=no +_LT_AC_TAGVAR(hardcode_automatic, $1)=no +_LT_AC_TAGVAR(module_cmds, $1)= +_LT_AC_TAGVAR(module_expsym_cmds, $1)= +_LT_AC_TAGVAR(link_all_deplibs, $1)=unknown +_LT_AC_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds +_LT_AC_TAGVAR(no_undefined_flag, $1)= +_LT_AC_TAGVAR(whole_archive_flag_spec, $1)= +_LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=no + +# Source file extension for f77 test sources. +ac_ext=f + +# Object file extension for compiled f77 test sources. +objext=o +_LT_AC_TAGVAR(objext, $1)=$objext + +# Code to be used in simple compile tests +lt_simple_compile_test_code="\ + subroutine t + return + end +" + +# Code to be used in simple link tests +lt_simple_link_test_code="\ + program t + end +" + +# ltmain only uses $CC for tagged configurations so make sure $CC is set. +_LT_AC_SYS_COMPILER + +# save warnings/boilerplate of simple test code +_LT_COMPILER_BOILERPLATE +_LT_LINKER_BOILERPLATE + +# Allow CC to be a program name with arguments. +lt_save_CC="$CC" +CC=${F77-"f77"} +compiler=$CC +_LT_AC_TAGVAR(compiler, $1)=$CC +_LT_CC_BASENAME([$compiler]) + +AC_MSG_CHECKING([if libtool supports shared libraries]) +AC_MSG_RESULT([$can_build_shared]) + +AC_MSG_CHECKING([whether to build shared libraries]) +test "$can_build_shared" = "no" && enable_shared=no + +# On AIX, shared libraries and static libraries use the same namespace, and +# are all built from PIC. +case $host_os in +aix3*) + test "$enable_shared" = yes && enable_static=no + if test -n "$RANLIB"; then + archive_cmds="$archive_cmds~\$RANLIB \$lib" + postinstall_cmds='$RANLIB $lib' + fi + ;; +aix[[4-9]]*) + if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then + test "$enable_shared" = yes && enable_static=no + fi + ;; +esac +AC_MSG_RESULT([$enable_shared]) + +AC_MSG_CHECKING([whether to build static libraries]) +# Make sure either enable_shared or enable_static is yes. +test "$enable_shared" = yes || enable_static=yes +AC_MSG_RESULT([$enable_static]) + +_LT_AC_TAGVAR(GCC, $1)="$G77" +_LT_AC_TAGVAR(LD, $1)="$LD" + +AC_LIBTOOL_PROG_COMPILER_PIC($1) +AC_LIBTOOL_PROG_CC_C_O($1) +AC_LIBTOOL_SYS_HARD_LINK_LOCKS($1) +AC_LIBTOOL_PROG_LD_SHLIBS($1) +AC_LIBTOOL_SYS_DYNAMIC_LINKER($1) +AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH($1) + +AC_LIBTOOL_CONFIG($1) + +AC_LANG_POP +CC="$lt_save_CC" +])# AC_LIBTOOL_LANG_F77_CONFIG + + +# AC_LIBTOOL_LANG_GCJ_CONFIG +# -------------------------- +# Ensure that the configuration vars for the C compiler are +# suitably defined. Those variables are subsequently used by +# AC_LIBTOOL_CONFIG to write the compiler configuration to `libtool'. +AC_DEFUN([AC_LIBTOOL_LANG_GCJ_CONFIG], [_LT_AC_LANG_GCJ_CONFIG(GCJ)]) +AC_DEFUN([_LT_AC_LANG_GCJ_CONFIG], +[AC_LANG_SAVE + +# Source file extension for Java test sources. +ac_ext=java + +# Object file extension for compiled Java test sources. +objext=o +_LT_AC_TAGVAR(objext, $1)=$objext + +# Code to be used in simple compile tests +lt_simple_compile_test_code="class foo {}" + +# Code to be used in simple link tests +lt_simple_link_test_code='public class conftest { public static void main(String[[]] argv) {}; }' + +# ltmain only uses $CC for tagged configurations so make sure $CC is set. +_LT_AC_SYS_COMPILER + +# save warnings/boilerplate of simple test code +_LT_COMPILER_BOILERPLATE +_LT_LINKER_BOILERPLATE + +# Allow CC to be a program name with arguments. +lt_save_CC="$CC" +CC=${GCJ-"gcj"} +compiler=$CC +_LT_AC_TAGVAR(compiler, $1)=$CC +_LT_CC_BASENAME([$compiler]) + +# GCJ did not exist at the time GCC didn't implicitly link libc in. +_LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no + +_LT_AC_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds + +AC_LIBTOOL_PROG_COMPILER_NO_RTTI($1) +AC_LIBTOOL_PROG_COMPILER_PIC($1) +AC_LIBTOOL_PROG_CC_C_O($1) +AC_LIBTOOL_SYS_HARD_LINK_LOCKS($1) +AC_LIBTOOL_PROG_LD_SHLIBS($1) +AC_LIBTOOL_SYS_DYNAMIC_LINKER($1) +AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH($1) + +AC_LIBTOOL_CONFIG($1) + +AC_LANG_RESTORE +CC="$lt_save_CC" +])# AC_LIBTOOL_LANG_GCJ_CONFIG + + +# AC_LIBTOOL_LANG_RC_CONFIG +# ------------------------- +# Ensure that the configuration vars for the Windows resource compiler are +# suitably defined. Those variables are subsequently used by +# AC_LIBTOOL_CONFIG to write the compiler configuration to `libtool'. +AC_DEFUN([AC_LIBTOOL_LANG_RC_CONFIG], [_LT_AC_LANG_RC_CONFIG(RC)]) +AC_DEFUN([_LT_AC_LANG_RC_CONFIG], +[AC_LANG_SAVE + +# Source file extension for RC test sources. +ac_ext=rc + +# Object file extension for compiled RC test sources. +objext=o +_LT_AC_TAGVAR(objext, $1)=$objext + +# Code to be used in simple compile tests +lt_simple_compile_test_code='sample MENU { MENUITEM "&Soup", 100, CHECKED }' + +# Code to be used in simple link tests +lt_simple_link_test_code="$lt_simple_compile_test_code" + +# ltmain only uses $CC for tagged configurations so make sure $CC is set. +_LT_AC_SYS_COMPILER + +# save warnings/boilerplate of simple test code +_LT_COMPILER_BOILERPLATE +_LT_LINKER_BOILERPLATE + +# Allow CC to be a program name with arguments. +lt_save_CC="$CC" +CC=${RC-"windres"} +compiler=$CC +_LT_AC_TAGVAR(compiler, $1)=$CC +_LT_CC_BASENAME([$compiler]) +_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes + +AC_LIBTOOL_CONFIG($1) + +AC_LANG_RESTORE +CC="$lt_save_CC" +])# AC_LIBTOOL_LANG_RC_CONFIG + + +# AC_LIBTOOL_CONFIG([TAGNAME]) +# ---------------------------- +# If TAGNAME is not passed, then create an initial libtool script +# with a default configuration from the untagged config vars. Otherwise +# add code to config.status for appending the configuration named by +# TAGNAME from the matching tagged config vars. +AC_DEFUN([AC_LIBTOOL_CONFIG], +[# The else clause should only fire when bootstrapping the +# libtool distribution, otherwise you forgot to ship ltmain.sh +# with your package, and you will get complaints that there are +# no rules to generate ltmain.sh. +if test -f "$ltmain"; then + # See if we are running on zsh, and set the options which allow our commands through + # without removal of \ escapes. + if test -n "${ZSH_VERSION+set}" ; then + setopt NO_GLOB_SUBST + fi + # Now quote all the things that may contain metacharacters while being + # careful not to overquote the AC_SUBSTed values. We take copies of the + # variables and quote the copies for generation of the libtool script. + for var in echo old_CC old_CFLAGS AR AR_FLAGS EGREP RANLIB LN_S LTCC LTCFLAGS NM \ + SED SHELL STRIP \ + libname_spec library_names_spec soname_spec extract_expsyms_cmds \ + old_striplib striplib file_magic_cmd finish_cmds finish_eval \ + deplibs_check_method reload_flag reload_cmds need_locks \ + lt_cv_sys_global_symbol_pipe lt_cv_sys_global_symbol_to_cdecl \ + lt_cv_sys_global_symbol_to_c_name_address \ + sys_lib_search_path_spec sys_lib_dlsearch_path_spec \ + old_postinstall_cmds old_postuninstall_cmds \ + _LT_AC_TAGVAR(compiler, $1) \ + _LT_AC_TAGVAR(CC, $1) \ + _LT_AC_TAGVAR(LD, $1) \ + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1) \ + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1) \ + _LT_AC_TAGVAR(lt_prog_compiler_static, $1) \ + _LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1) \ + _LT_AC_TAGVAR(export_dynamic_flag_spec, $1) \ + _LT_AC_TAGVAR(thread_safe_flag_spec, $1) \ + _LT_AC_TAGVAR(whole_archive_flag_spec, $1) \ + _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1) \ + _LT_AC_TAGVAR(old_archive_cmds, $1) \ + _LT_AC_TAGVAR(old_archive_from_new_cmds, $1) \ + _LT_AC_TAGVAR(predep_objects, $1) \ + _LT_AC_TAGVAR(postdep_objects, $1) \ + _LT_AC_TAGVAR(predeps, $1) \ + _LT_AC_TAGVAR(postdeps, $1) \ + _LT_AC_TAGVAR(compiler_lib_search_path, $1) \ + _LT_AC_TAGVAR(compiler_lib_search_dirs, $1) \ + _LT_AC_TAGVAR(archive_cmds, $1) \ + _LT_AC_TAGVAR(archive_expsym_cmds, $1) \ + _LT_AC_TAGVAR(postinstall_cmds, $1) \ + _LT_AC_TAGVAR(postuninstall_cmds, $1) \ + _LT_AC_TAGVAR(old_archive_from_expsyms_cmds, $1) \ + _LT_AC_TAGVAR(allow_undefined_flag, $1) \ + _LT_AC_TAGVAR(no_undefined_flag, $1) \ + _LT_AC_TAGVAR(export_symbols_cmds, $1) \ + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1) \ + _LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1) \ + _LT_AC_TAGVAR(hardcode_libdir_separator, $1) \ + _LT_AC_TAGVAR(hardcode_automatic, $1) \ + _LT_AC_TAGVAR(module_cmds, $1) \ + _LT_AC_TAGVAR(module_expsym_cmds, $1) \ + _LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1) \ + _LT_AC_TAGVAR(fix_srcfile_path, $1) \ + _LT_AC_TAGVAR(exclude_expsyms, $1) \ + _LT_AC_TAGVAR(include_expsyms, $1); do + + case $var in + _LT_AC_TAGVAR(old_archive_cmds, $1) | \ + _LT_AC_TAGVAR(old_archive_from_new_cmds, $1) | \ + _LT_AC_TAGVAR(archive_cmds, $1) | \ + _LT_AC_TAGVAR(archive_expsym_cmds, $1) | \ + _LT_AC_TAGVAR(module_cmds, $1) | \ + _LT_AC_TAGVAR(module_expsym_cmds, $1) | \ + _LT_AC_TAGVAR(old_archive_from_expsyms_cmds, $1) | \ + _LT_AC_TAGVAR(export_symbols_cmds, $1) | \ + extract_expsyms_cmds | reload_cmds | finish_cmds | \ + postinstall_cmds | postuninstall_cmds | \ + old_postinstall_cmds | old_postuninstall_cmds | \ + sys_lib_search_path_spec | sys_lib_dlsearch_path_spec) + # Double-quote double-evaled strings. + eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$double_quote_subst\" -e \"\$sed_quote_subst\" -e \"\$delay_variable_subst\"\`\\\"" + ;; + *) + eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$sed_quote_subst\"\`\\\"" + ;; + esac + done + + case $lt_echo in + *'\[$]0 --fallback-echo"') + lt_echo=`$echo "X$lt_echo" | $Xsed -e 's/\\\\\\\[$]0 --fallback-echo"[$]/[$]0 --fallback-echo"/'` + ;; + esac + +ifelse([$1], [], + [cfgfile="${ofile}T" + trap "$rm \"$cfgfile\"; exit 1" 1 2 15 + $rm -f "$cfgfile" + AC_MSG_NOTICE([creating $ofile])], + [cfgfile="$ofile"]) + + cat <<__EOF__ >> "$cfgfile" +ifelse([$1], [], +[#! $SHELL + +# `$echo "$cfgfile" | sed 's%^.*/%%'` - Provide generalized library-building support services. +# Generated automatically by $PROGRAM (GNU $PACKAGE $VERSION$TIMESTAMP) +# NOTE: Changes made to this file will be lost: look at ltmain.sh. +# +# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 +# Free Software Foundation, Inc. +# +# This file is part of GNU Libtool: +# Originally by Gordon Matzigkeit , 1996 +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# A sed program that does not truncate output. +SED=$lt_SED + +# Sed that helps us avoid accidentally triggering echo(1) options like -n. +Xsed="$SED -e 1s/^X//" + +# The HP-UX ksh and POSIX shell print the target directory to stdout +# if CDPATH is set. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + +# The names of the tagged configurations supported by this script. +available_tags= + +# ### BEGIN LIBTOOL CONFIG], +[# ### BEGIN LIBTOOL TAG CONFIG: $tagname]) + +# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: + +# Shell to use when invoking shell scripts. +SHELL=$lt_SHELL + +# Whether or not to build shared libraries. +build_libtool_libs=$enable_shared + +# Whether or not to build static libraries. +build_old_libs=$enable_static + +# Whether or not to add -lc for building shared libraries. +build_libtool_need_lc=$_LT_AC_TAGVAR(archive_cmds_need_lc, $1) + +# Whether or not to disallow shared libs when runtime libs are static +allow_libtool_libs_with_static_runtimes=$_LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1) + +# Whether or not to optimize for fast installation. +fast_install=$enable_fast_install + +# The host system. +host_alias=$host_alias +host=$host +host_os=$host_os + +# The build system. +build_alias=$build_alias +build=$build +build_os=$build_os + +# An echo program that does not interpret backslashes. +echo=$lt_echo + +# The archiver. +AR=$lt_AR +AR_FLAGS=$lt_AR_FLAGS + +# A C compiler. +LTCC=$lt_LTCC + +# LTCC compiler flags. +LTCFLAGS=$lt_LTCFLAGS + +# A language-specific compiler. +CC=$lt_[]_LT_AC_TAGVAR(compiler, $1) + +# Is the compiler the GNU C compiler? +with_gcc=$_LT_AC_TAGVAR(GCC, $1) + +# An ERE matcher. +EGREP=$lt_EGREP + +# The linker used to build libraries. +LD=$lt_[]_LT_AC_TAGVAR(LD, $1) + +# Whether we need hard or soft links. +LN_S=$lt_LN_S + +# A BSD-compatible nm program. +NM=$lt_NM + +# A symbol stripping program +STRIP=$lt_STRIP + +# Used to examine libraries when file_magic_cmd begins "file" +MAGIC_CMD=$MAGIC_CMD + +# Used on cygwin: DLL creation program. +DLLTOOL="$DLLTOOL" + +# Used on cygwin: object dumper. +OBJDUMP="$OBJDUMP" + +# Used on cygwin: assembler. +AS="$AS" + +# The name of the directory that contains temporary libtool files. +objdir=$objdir + +# How to create reloadable object files. +reload_flag=$lt_reload_flag +reload_cmds=$lt_reload_cmds + +# How to pass a linker flag through the compiler. +wl=$lt_[]_LT_AC_TAGVAR(lt_prog_compiler_wl, $1) + +# Object file suffix (normally "o"). +objext="$ac_objext" + +# Old archive suffix (normally "a"). +libext="$libext" + +# Shared library suffix (normally ".so"). +shrext_cmds='$shrext_cmds' + +# Executable file suffix (normally ""). +exeext="$exeext" + +# Additional compiler flags for building library objects. +pic_flag=$lt_[]_LT_AC_TAGVAR(lt_prog_compiler_pic, $1) +pic_mode=$pic_mode + +# What is the maximum length of a command? +max_cmd_len=$lt_cv_sys_max_cmd_len + +# Does compiler simultaneously support -c and -o options? +compiler_c_o=$lt_[]_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1) + +# Must we lock files when doing compilation? +need_locks=$lt_need_locks + +# Do we need the lib prefix for modules? +need_lib_prefix=$need_lib_prefix + +# Do we need a version for libraries? +need_version=$need_version + +# Whether dlopen is supported. +dlopen_support=$enable_dlopen + +# Whether dlopen of programs is supported. +dlopen_self=$enable_dlopen_self + +# Whether dlopen of statically linked programs is supported. +dlopen_self_static=$enable_dlopen_self_static + +# Compiler flag to prevent dynamic linking. +link_static_flag=$lt_[]_LT_AC_TAGVAR(lt_prog_compiler_static, $1) + +# Compiler flag to turn off builtin functions. +no_builtin_flag=$lt_[]_LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1) + +# Compiler flag to allow reflexive dlopens. +export_dynamic_flag_spec=$lt_[]_LT_AC_TAGVAR(export_dynamic_flag_spec, $1) + +# Compiler flag to generate shared objects directly from archives. +whole_archive_flag_spec=$lt_[]_LT_AC_TAGVAR(whole_archive_flag_spec, $1) + +# Compiler flag to generate thread-safe objects. +thread_safe_flag_spec=$lt_[]_LT_AC_TAGVAR(thread_safe_flag_spec, $1) + +# Library versioning type. +version_type=$version_type + +# Format of library name prefix. +libname_spec=$lt_libname_spec + +# List of archive names. First name is the real one, the rest are links. +# The last name is the one that the linker finds with -lNAME. +library_names_spec=$lt_library_names_spec + +# The coded name of the library, if different from the real name. +soname_spec=$lt_soname_spec + +# Commands used to build and install an old-style archive. +RANLIB=$lt_RANLIB +old_archive_cmds=$lt_[]_LT_AC_TAGVAR(old_archive_cmds, $1) +old_postinstall_cmds=$lt_old_postinstall_cmds +old_postuninstall_cmds=$lt_old_postuninstall_cmds + +# Create an old-style archive from a shared archive. +old_archive_from_new_cmds=$lt_[]_LT_AC_TAGVAR(old_archive_from_new_cmds, $1) + +# Create a temporary old-style archive to link instead of a shared archive. +old_archive_from_expsyms_cmds=$lt_[]_LT_AC_TAGVAR(old_archive_from_expsyms_cmds, $1) + +# Commands used to build and install a shared archive. +archive_cmds=$lt_[]_LT_AC_TAGVAR(archive_cmds, $1) +archive_expsym_cmds=$lt_[]_LT_AC_TAGVAR(archive_expsym_cmds, $1) +postinstall_cmds=$lt_postinstall_cmds +postuninstall_cmds=$lt_postuninstall_cmds + +# Commands used to build a loadable module (assumed same as above if empty) +module_cmds=$lt_[]_LT_AC_TAGVAR(module_cmds, $1) +module_expsym_cmds=$lt_[]_LT_AC_TAGVAR(module_expsym_cmds, $1) + +# Commands to strip libraries. +old_striplib=$lt_old_striplib +striplib=$lt_striplib + +# Dependencies to place before the objects being linked to create a +# shared library. +predep_objects=$lt_[]_LT_AC_TAGVAR(predep_objects, $1) + +# Dependencies to place after the objects being linked to create a +# shared library. +postdep_objects=$lt_[]_LT_AC_TAGVAR(postdep_objects, $1) + +# Dependencies to place before the objects being linked to create a +# shared library. +predeps=$lt_[]_LT_AC_TAGVAR(predeps, $1) + +# Dependencies to place after the objects being linked to create a +# shared library. +postdeps=$lt_[]_LT_AC_TAGVAR(postdeps, $1) + +# The directories searched by this compiler when creating a shared +# library +compiler_lib_search_dirs=$lt_[]_LT_AC_TAGVAR(compiler_lib_search_dirs, $1) + +# The library search path used internally by the compiler when linking +# a shared library. +compiler_lib_search_path=$lt_[]_LT_AC_TAGVAR(compiler_lib_search_path, $1) + +# Method to check whether dependent libraries are shared objects. +deplibs_check_method=$lt_deplibs_check_method + +# Command to use when deplibs_check_method == file_magic. +file_magic_cmd=$lt_file_magic_cmd + +# Flag that allows shared libraries with undefined symbols to be built. +allow_undefined_flag=$lt_[]_LT_AC_TAGVAR(allow_undefined_flag, $1) + +# Flag that forces no undefined symbols. +no_undefined_flag=$lt_[]_LT_AC_TAGVAR(no_undefined_flag, $1) + +# Commands used to finish a libtool library installation in a directory. +finish_cmds=$lt_finish_cmds + +# Same as above, but a single script fragment to be evaled but not shown. +finish_eval=$lt_finish_eval + +# Take the output of nm and produce a listing of raw symbols and C names. +global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe + +# Transform the output of nm in a proper C declaration +global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl + +# Transform the output of nm in a C name address pair +global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address + +# This is the shared library runtime path variable. +runpath_var=$runpath_var + +# This is the shared library path variable. +shlibpath_var=$shlibpath_var + +# Is shlibpath searched before the hard-coded library search path? +shlibpath_overrides_runpath=$shlibpath_overrides_runpath + +# How to hardcode a shared library path into an executable. +hardcode_action=$_LT_AC_TAGVAR(hardcode_action, $1) + +# Whether we should hardcode library paths into libraries. +hardcode_into_libs=$hardcode_into_libs + +# Flag to hardcode \$libdir into a binary during linking. +# This must work even if \$libdir does not exist. +hardcode_libdir_flag_spec=$lt_[]_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1) + +# If ld is used when linking, flag to hardcode \$libdir into +# a binary during linking. This must work even if \$libdir does +# not exist. +hardcode_libdir_flag_spec_ld=$lt_[]_LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1) + +# Whether we need a single -rpath flag with a separated argument. +hardcode_libdir_separator=$lt_[]_LT_AC_TAGVAR(hardcode_libdir_separator, $1) + +# Set to yes if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the +# resulting binary. +hardcode_direct=$_LT_AC_TAGVAR(hardcode_direct, $1) + +# Set to yes if using the -LDIR flag during linking hardcodes DIR into the +# resulting binary. +hardcode_minus_L=$_LT_AC_TAGVAR(hardcode_minus_L, $1) + +# Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into +# the resulting binary. +hardcode_shlibpath_var=$_LT_AC_TAGVAR(hardcode_shlibpath_var, $1) + +# Set to yes if building a shared library automatically hardcodes DIR into the library +# and all subsequent libraries and executables linked against it. +hardcode_automatic=$_LT_AC_TAGVAR(hardcode_automatic, $1) + +# Variables whose values should be saved in libtool wrapper scripts and +# restored at relink time. +variables_saved_for_relink="$variables_saved_for_relink" + +# Whether libtool must link a program against all its dependency libraries. +link_all_deplibs=$_LT_AC_TAGVAR(link_all_deplibs, $1) + +# Compile-time system search path for libraries +sys_lib_search_path_spec=$lt_sys_lib_search_path_spec + +# Run-time system search path for libraries +sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec + +# Fix the shell variable \$srcfile for the compiler. +fix_srcfile_path=$lt_fix_srcfile_path + +# Set to yes if exported symbols are required. +always_export_symbols=$_LT_AC_TAGVAR(always_export_symbols, $1) + +# The commands to list exported symbols. +export_symbols_cmds=$lt_[]_LT_AC_TAGVAR(export_symbols_cmds, $1) + +# The commands to extract the exported symbol list from a shared archive. +extract_expsyms_cmds=$lt_extract_expsyms_cmds + +# Symbols that should not be listed in the preloaded symbols. +exclude_expsyms=$lt_[]_LT_AC_TAGVAR(exclude_expsyms, $1) + +# Symbols that must always be exported. +include_expsyms=$lt_[]_LT_AC_TAGVAR(include_expsyms, $1) + +ifelse([$1],[], +[# ### END LIBTOOL CONFIG], +[# ### END LIBTOOL TAG CONFIG: $tagname]) + +__EOF__ + +ifelse([$1],[], [ + case $host_os in + aix3*) + cat <<\EOF >> "$cfgfile" + +# AIX sometimes has problems with the GCC collect2 program. For some +# reason, if we set the COLLECT_NAMES environment variable, the problems +# vanish in a puff of smoke. +if test "X${COLLECT_NAMES+set}" != Xset; then + COLLECT_NAMES= + export COLLECT_NAMES +fi +EOF + ;; + esac + + # We use sed instead of cat because bash on DJGPP gets confused if + # if finds mixed CR/LF and LF-only lines. Since sed operates in + # text mode, it properly converts lines to CR/LF. This bash problem + # is reportedly fixed, but why not run on old versions too? + sed '$q' "$ltmain" >> "$cfgfile" || (rm -f "$cfgfile"; exit 1) + + mv -f "$cfgfile" "$ofile" || \ + (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile") + chmod +x "$ofile" +]) +else + # If there is no Makefile yet, we rely on a make rule to execute + # `config.status --recheck' to rerun these tests and create the + # libtool script then. + ltmain_in=`echo $ltmain | sed -e 's/\.sh$/.in/'` + if test -f "$ltmain_in"; then + test -f Makefile && make "$ltmain" + fi +fi +])# AC_LIBTOOL_CONFIG + + +# AC_LIBTOOL_PROG_COMPILER_NO_RTTI([TAGNAME]) +# ------------------------------------------- +AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_NO_RTTI], +[AC_REQUIRE([_LT_AC_SYS_COMPILER])dnl + +_LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)= + +if test "$GCC" = yes; then + _LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin' + + AC_LIBTOOL_COMPILER_OPTION([if $compiler supports -fno-rtti -fno-exceptions], + lt_cv_prog_compiler_rtti_exceptions, + [-fno-rtti -fno-exceptions], [], + [_LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)="$_LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1) -fno-rtti -fno-exceptions"]) +fi +])# AC_LIBTOOL_PROG_COMPILER_NO_RTTI + + +# AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE +# --------------------------------- +AC_DEFUN([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE], +[AC_REQUIRE([AC_CANONICAL_HOST]) +AC_REQUIRE([LT_AC_PROG_SED]) +AC_REQUIRE([AC_PROG_NM]) +AC_REQUIRE([AC_OBJEXT]) +# Check for command to grab the raw symbol name followed by C symbol from nm. +AC_MSG_CHECKING([command to parse $NM output from $compiler object]) +AC_CACHE_VAL([lt_cv_sys_global_symbol_pipe], +[ +# These are sane defaults that work on at least a few old systems. +# [They come from Ultrix. What could be older than Ultrix?!! ;)] + +# Character class describing NM global symbol codes. +symcode='[[BCDEGRST]]' + +# Regexp to match symbols that can be accessed directly from C. +sympat='\([[_A-Za-z]][[_A-Za-z0-9]]*\)' + +# Transform an extracted symbol line into a proper C declaration +lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^. .* \(.*\)$/extern int \1;/p'" + +# Transform an extracted symbol line into symbol name and symbol address +lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\) $/ {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode \([[^ ]]*\) \([[^ ]]*\)$/ {\"\2\", (lt_ptr) \&\2},/p'" + +# Define system-specific variables. +case $host_os in +aix*) + symcode='[[BCDT]]' + ;; +cygwin* | mingw* | pw32*) + symcode='[[ABCDGISTW]]' + ;; +hpux*) # Its linker distinguishes data from code symbols + if test "$host_cpu" = ia64; then + symcode='[[ABCDEGRST]]' + fi + lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'" + lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\) $/ {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"\2\", (lt_ptr) \&\2},/p'" + ;; +linux* | k*bsd*-gnu) + if test "$host_cpu" = ia64; then + symcode='[[ABCDGIRSTW]]' + lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'" + lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\) $/ {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"\2\", (lt_ptr) \&\2},/p'" + fi + ;; +irix* | nonstopux*) + symcode='[[BCDEGRST]]' + ;; +osf*) + symcode='[[BCDEGQRST]]' + ;; +solaris*) + symcode='[[BDRT]]' + ;; +sco3.2v5*) + symcode='[[DT]]' + ;; +sysv4.2uw2*) + symcode='[[DT]]' + ;; +sysv5* | sco5v6* | unixware* | OpenUNIX*) + symcode='[[ABDT]]' + ;; +sysv4) + symcode='[[DFNSTU]]' + ;; +esac + +# Handle CRLF in mingw tool chain +opt_cr= +case $build_os in +mingw*) + opt_cr=`echo 'x\{0,1\}' | tr x '\015'` # option cr in regexp + ;; +esac + +# If we're using GNU nm, then use its standard symbol codes. +case `$NM -V 2>&1` in +*GNU* | *'with BFD'*) + symcode='[[ABCDGIRSTW]]' ;; +esac + +# Try without a prefix undercore, then with it. +for ac_symprfx in "" "_"; do + + # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol. + symxfrm="\\1 $ac_symprfx\\2 \\2" + + # Write the raw and C identifiers. + lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[[ ]]\($symcode$symcode*\)[[ ]][[ ]]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'" + + # Check to see that the pipe works correctly. + pipe_works=no + + rm -f conftest* + cat > conftest.$ac_ext < $nlist) && test -s "$nlist"; then + # Try sorting and uniquifying the output. + if sort "$nlist" | uniq > "$nlist"T; then + mv -f "$nlist"T "$nlist" + else + rm -f "$nlist"T + fi + + # Make sure that we snagged all the symbols we need. + if grep ' nm_test_var$' "$nlist" >/dev/null; then + if grep ' nm_test_func$' "$nlist" >/dev/null; then + cat < conftest.$ac_ext +#ifdef __cplusplus +extern "C" { +#endif + +EOF + # Now generate the symbol file. + eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | grep -v main >> conftest.$ac_ext' + + cat <> conftest.$ac_ext +#if defined (__STDC__) && __STDC__ +# define lt_ptr_t void * +#else +# define lt_ptr_t char * +# define const +#endif + +/* The mapping between symbol names and symbols. */ +const struct { + const char *name; + lt_ptr_t address; +} +lt_preloaded_symbols[[]] = +{ +EOF + $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/ {\"\2\", (lt_ptr_t) \&\2},/" < "$nlist" | grep -v main >> conftest.$ac_ext + cat <<\EOF >> conftest.$ac_ext + {0, (lt_ptr_t) 0} +}; + +#ifdef __cplusplus +} +#endif +EOF + # Now try linking the two files. + mv conftest.$ac_objext conftstm.$ac_objext + lt_save_LIBS="$LIBS" + lt_save_CFLAGS="$CFLAGS" + LIBS="conftstm.$ac_objext" + CFLAGS="$CFLAGS$_LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)" + if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext}; then + pipe_works=yes + fi + LIBS="$lt_save_LIBS" + CFLAGS="$lt_save_CFLAGS" + else + echo "cannot find nm_test_func in $nlist" >&AS_MESSAGE_LOG_FD + fi + else + echo "cannot find nm_test_var in $nlist" >&AS_MESSAGE_LOG_FD + fi + else + echo "cannot run $lt_cv_sys_global_symbol_pipe" >&AS_MESSAGE_LOG_FD + fi + else + echo "$progname: failed program was:" >&AS_MESSAGE_LOG_FD + cat conftest.$ac_ext >&5 + fi + rm -rf conftest* conftst* + + # Do not use the global_symbol_pipe unless it works. + if test "$pipe_works" = yes; then + break + else + lt_cv_sys_global_symbol_pipe= + fi +done +]) +if test -z "$lt_cv_sys_global_symbol_pipe"; then + lt_cv_sys_global_symbol_to_cdecl= +fi +if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then + AC_MSG_RESULT(failed) +else + AC_MSG_RESULT(ok) +fi +]) # AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE + + +# AC_LIBTOOL_PROG_COMPILER_PIC([TAGNAME]) +# --------------------------------------- +AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_PIC], +[_LT_AC_TAGVAR(lt_prog_compiler_wl, $1)= +_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)= +_LT_AC_TAGVAR(lt_prog_compiler_static, $1)= + +AC_MSG_CHECKING([for $compiler option to produce PIC]) + ifelse([$1],[CXX],[ + # C++ specific cases for pic, static, wl, etc. + if test "$GXX" = yes; then + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-static' + + case $host_os in + aix*) + # All AIX code is PIC. + if test "$host_cpu" = ia64; then + # AIX 5 now supports IA64 processor + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + fi + ;; + amigaos*) + # FIXME: we need at least 68020 code to build shared libraries, but + # adding the `-m68020' flag to GCC prevents building anything better, + # like `-m68040'. + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4' + ;; + beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) + # PIC is the default for these OSes. + ;; + mingw* | cygwin* | os2* | pw32*) + # This hack is so that the source file can tell whether it is being + # built for inclusion in a dll (and should export symbols for example). + # Although the cygwin gcc ignores -fPIC, still need this for old-style + # (--disable-auto-import) libraries + m4_if([$1], [GCJ], [], + [_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) + ;; + darwin* | rhapsody*) + # PIC is the default on this platform + # Common symbols not allowed in MH_DYLIB files + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common' + ;; + *djgpp*) + # DJGPP does not support shared libraries at all + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)= + ;; + interix[[3-9]]*) + # Interix 3.x gcc -fpic/-fPIC options generate broken code. + # Instead, we relocate shared libraries at runtime. + ;; + sysv4*MP*) + if test -d /usr/nec; then + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic + fi + ;; + hpux*) + # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but + # not for PA HP-UX. + case $host_cpu in + hppa*64*|ia64*) + ;; + *) + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + ;; + esac + ;; + *) + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + ;; + esac + else + case $host_os in + aix[[4-9]]*) + # All AIX code is PIC. + if test "$host_cpu" = ia64; then + # AIX 5 now supports IA64 processor + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + else + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp' + fi + ;; + chorus*) + case $cc_basename in + cxch68*) + # Green Hills C++ Compiler + # _LT_AC_TAGVAR(lt_prog_compiler_static, $1)="--no_auto_instantiation -u __main -u __premain -u _abort -r $COOL_DIR/lib/libOrb.a $MVME_DIR/lib/CC/libC.a $MVME_DIR/lib/classix/libcx.s.a" + ;; + esac + ;; + darwin*) + # PIC is the default on this platform + # Common symbols not allowed in MH_DYLIB files + case $cc_basename in + xlc*) + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-qnocommon' + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + ;; + esac + ;; + dgux*) + case $cc_basename in + ec++*) + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + ;; + ghcx*) + # Green Hills C++ Compiler + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic' + ;; + *) + ;; + esac + ;; + freebsd* | dragonfly*) + # FreeBSD uses GNU C++ + ;; + hpux9* | hpux10* | hpux11*) + case $cc_basename in + CC*) + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive' + if test "$host_cpu" != ia64; then + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='+Z' + fi + ;; + aCC*) + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive' + case $host_cpu in + hppa*64*|ia64*) + # +Z the default + ;; + *) + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='+Z' + ;; + esac + ;; + *) + ;; + esac + ;; + interix*) + # This is c89, which is MS Visual C++ (no shared libs) + # Anyone wants to do a port? + ;; + irix5* | irix6* | nonstopux*) + case $cc_basename in + CC*) + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' + # CC pic flag -KPIC is the default. + ;; + *) + ;; + esac + ;; + linux* | k*bsd*-gnu) + case $cc_basename in + KCC*) + # KAI C++ Compiler + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,' + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + ;; + icpc* | ecpc*) + # Intel C++ + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-static' + ;; + pgCC* | pgcpp*) + # Portland Group C++ compiler. + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fpic' + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + cxx*) + # Compaq C++ + # Make sure the PIC flag is empty. It appears that all Alpha + # Linux and Compaq Tru64 Unix objects are PIC. + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)= + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' + ;; + *) + case `$CC -V 2>&1 | sed 5q` in + *Sun\ C*) + # Sun C++ 5.9 + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' + ;; + esac + ;; + esac + ;; + lynxos*) + ;; + m88k*) + ;; + mvs*) + case $cc_basename in + cxx*) + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-W c,exportall' + ;; + *) + ;; + esac + ;; + netbsd* | netbsdelf*-gnu) + ;; + osf3* | osf4* | osf5*) + case $cc_basename in + KCC*) + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,' + ;; + RCC*) + # Rational C++ 2.4.1 + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic' + ;; + cxx*) + # Digital/Compaq C++ + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + # Make sure the PIC flag is empty. It appears that all Alpha + # Linux and Compaq Tru64 Unix objects are PIC. + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)= + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' + ;; + *) + ;; + esac + ;; + psos*) + ;; + solaris*) + case $cc_basename in + CC*) + # Sun C++ 4.2, 5.x and Centerline C++ + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' + ;; + gcx*) + # Green Hills C++ Compiler + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' + ;; + *) + ;; + esac + ;; + sunos4*) + case $cc_basename in + CC*) + # Sun C++ 4.x + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic' + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + lcc*) + # Lucid + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic' + ;; + *) + ;; + esac + ;; + tandem*) + case $cc_basename in + NCC*) + # NonStop-UX NCC 3.20 + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + ;; + *) + ;; + esac + ;; + sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) + case $cc_basename in + CC*) + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + esac + ;; + vxworks*) + ;; + *) + _LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no + ;; + esac + fi +], +[ + if test "$GCC" = yes; then + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-static' + + case $host_os in + aix*) + # All AIX code is PIC. + if test "$host_cpu" = ia64; then + # AIX 5 now supports IA64 processor + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + fi + ;; + + amigaos*) + # FIXME: we need at least 68020 code to build shared libraries, but + # adding the `-m68020' flag to GCC prevents building anything better, + # like `-m68040'. + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4' + ;; + + beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) + # PIC is the default for these OSes. + ;; + + mingw* | cygwin* | pw32* | os2*) + # This hack is so that the source file can tell whether it is being + # built for inclusion in a dll (and should export symbols for example). + # Although the cygwin gcc ignores -fPIC, still need this for old-style + # (--disable-auto-import) libraries + m4_if([$1], [GCJ], [], + [_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) + ;; + + darwin* | rhapsody*) + # PIC is the default on this platform + # Common symbols not allowed in MH_DYLIB files + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common' + ;; + + interix[[3-9]]*) + # Interix 3.x gcc -fpic/-fPIC options generate broken code. + # Instead, we relocate shared libraries at runtime. + ;; + + msdosdjgpp*) + # Just because we use GCC doesn't mean we suddenly get shared libraries + # on systems that don't support them. + _LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no + enable_shared=no + ;; + + sysv4*MP*) + if test -d /usr/nec; then + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic + fi + ;; + + hpux*) + # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but + # not for PA HP-UX. + case $host_cpu in + hppa*64*|ia64*) + # +Z the default + ;; + *) + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + ;; + esac + ;; + + *) + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + ;; + esac + else + # PORTME Check for flag to pass linker flags through the system compiler. + case $host_os in + aix*) + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + if test "$host_cpu" = ia64; then + # AIX 5 now supports IA64 processor + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + else + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp' + fi + ;; + darwin*) + # PIC is the default on this platform + # Common symbols not allowed in MH_DYLIB files + case $cc_basename in + xlc*) + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-qnocommon' + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + ;; + esac + ;; + + mingw* | cygwin* | pw32* | os2*) + # This hack is so that the source file can tell whether it is being + # built for inclusion in a dll (and should export symbols for example). + m4_if([$1], [GCJ], [], + [_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) + ;; + + hpux9* | hpux10* | hpux11*) + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but + # not for PA HP-UX. + case $host_cpu in + hppa*64*|ia64*) + # +Z the default + ;; + *) + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='+Z' + ;; + esac + # Is there a better lt_prog_compiler_static that works with the bundled CC? + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive' + ;; + + irix5* | irix6* | nonstopux*) + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + # PIC (with -KPIC) is the default. + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' + ;; + + newsos6) + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + + linux* | k*bsd*-gnu) + case $cc_basename in + icc* | ecc*) + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-static' + ;; + pgcc* | pgf77* | pgf90* | pgf95*) + # Portland Group compilers (*not* the Pentium gcc compiler, + # which looks to be a dead project) + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fpic' + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + ccc*) + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + # All Alpha code is PIC. + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' + ;; + *) + case `$CC -V 2>&1 | sed 5q` in + *Sun\ C*) + # Sun C 5.9 + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + ;; + *Sun\ F*) + # Sun Fortran 8.3 passes all unrecognized flags to the linker + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='' + ;; + esac + ;; + esac + ;; + + osf3* | osf4* | osf5*) + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + # All OSF/1 code is PIC. + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' + ;; + + rdos*) + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' + ;; + + solaris*) + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + case $cc_basename in + f77* | f90* | f95*) + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ';; + *) + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,';; + esac + ;; + + sunos4*) + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + + sysv4 | sysv4.2uw2* | sysv4.3*) + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + + sysv4*MP*) + if test -d /usr/nec ;then + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-Kconform_pic' + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + fi + ;; + + sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + + unicos*) + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no + ;; + + uts4*) + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic' + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + + *) + _LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no + ;; + esac + fi +]) +AC_MSG_RESULT([$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)]) + +# +# Check to make sure the PIC flag actually works. +# +if test -n "$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)"; then + AC_LIBTOOL_COMPILER_OPTION([if $compiler PIC flag $_LT_AC_TAGVAR(lt_prog_compiler_pic, $1) works], + _LT_AC_TAGVAR(lt_cv_prog_compiler_pic_works, $1), + [$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)ifelse([$1],[],[ -DPIC],[ifelse([$1],[CXX],[ -DPIC],[])])], [], + [case $_LT_AC_TAGVAR(lt_prog_compiler_pic, $1) in + "" | " "*) ;; + *) _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=" $_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)" ;; + esac], + [_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)= + _LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no]) +fi +case $host_os in + # For platforms which do not support PIC, -DPIC is meaningless: + *djgpp*) + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)= + ;; + *) + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)="$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)ifelse([$1],[],[ -DPIC],[ifelse([$1],[CXX],[ -DPIC],[])])" + ;; +esac + +# +# Check to make sure the static flag actually works. +# +wl=$_LT_AC_TAGVAR(lt_prog_compiler_wl, $1) eval lt_tmp_static_flag=\"$_LT_AC_TAGVAR(lt_prog_compiler_static, $1)\" +AC_LIBTOOL_LINKER_OPTION([if $compiler static flag $lt_tmp_static_flag works], + _LT_AC_TAGVAR(lt_cv_prog_compiler_static_works, $1), + $lt_tmp_static_flag, + [], + [_LT_AC_TAGVAR(lt_prog_compiler_static, $1)=]) +]) + + +# AC_LIBTOOL_PROG_LD_SHLIBS([TAGNAME]) +# ------------------------------------ +# See if the linker supports building shared libraries. +AC_DEFUN([AC_LIBTOOL_PROG_LD_SHLIBS], +[AC_REQUIRE([LT_AC_PROG_SED])dnl +AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries]) +ifelse([$1],[CXX],[ + _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' + case $host_os in + aix[[4-9]]*) + # If we're using GNU nm, then we don't want the "-C" option. + # -C means demangle to AIX nm, but means don't demangle with GNU nm + if $NM -V 2>&1 | grep 'GNU' > /dev/null; then + _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\[$]2 == "T") || (\[$]2 == "D") || (\[$]2 == "B")) && ([substr](\[$]3,1,1) != ".")) { print \[$]3 } }'\'' | sort -u > $export_symbols' + else + _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\[$]2 == "T") || (\[$]2 == "D") || (\[$]2 == "B")) && ([substr](\[$]3,1,1) != ".")) { print \[$]3 } }'\'' | sort -u > $export_symbols' + fi + ;; + pw32*) + _LT_AC_TAGVAR(export_symbols_cmds, $1)="$ltdll_cmds" + ;; + cygwin* | mingw*) + _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/;/^.*[[ ]]__nm__/s/^.*[[ ]]__nm__\([[^ ]]*\)[[ ]][[^ ]]*/\1 DATA/;/^I[[ ]]/d;/^[[AITW]][[ ]]/s/.*[[ ]]//'\'' | sort | uniq > $export_symbols' + ;; + linux* | k*bsd*-gnu) + _LT_AC_TAGVAR(link_all_deplibs, $1)=no + ;; + *) + _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' + ;; + esac + _LT_AC_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'] +],[ + runpath_var= + _LT_AC_TAGVAR(allow_undefined_flag, $1)= + _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=no + _LT_AC_TAGVAR(archive_cmds, $1)= + _LT_AC_TAGVAR(archive_expsym_cmds, $1)= + _LT_AC_TAGVAR(old_archive_From_new_cmds, $1)= + _LT_AC_TAGVAR(old_archive_from_expsyms_cmds, $1)= + _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)= + _LT_AC_TAGVAR(whole_archive_flag_spec, $1)= + _LT_AC_TAGVAR(thread_safe_flag_spec, $1)= + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)= + _LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)= + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)= + _LT_AC_TAGVAR(hardcode_direct, $1)=no + _LT_AC_TAGVAR(hardcode_minus_L, $1)=no + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=unsupported + _LT_AC_TAGVAR(link_all_deplibs, $1)=unknown + _LT_AC_TAGVAR(hardcode_automatic, $1)=no + _LT_AC_TAGVAR(module_cmds, $1)= + _LT_AC_TAGVAR(module_expsym_cmds, $1)= + _LT_AC_TAGVAR(always_export_symbols, $1)=no + _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' + # include_expsyms should be a list of space-separated symbols to be *always* + # included in the symbol list + _LT_AC_TAGVAR(include_expsyms, $1)= + # exclude_expsyms can be an extended regexp of symbols to exclude + # it will be wrapped by ` (' and `)$', so one must not match beginning or + # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc', + # as well as any symbol that contains `d'. + _LT_AC_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'] + # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out + # platforms (ab)use it in PIC code, but their linkers get confused if + # the symbol is explicitly referenced. Since portable code cannot + # rely on this symbol name, it's probably fine to never include it in + # preloaded symbol tables. + # Exclude shared library initialization/finalization symbols. +dnl Note also adjust exclude_expsyms for C++ above. + extract_expsyms_cmds= + # Just being paranoid about ensuring that cc_basename is set. + _LT_CC_BASENAME([$compiler]) + case $host_os in + cygwin* | mingw* | pw32*) + # FIXME: the MSVC++ port hasn't been tested in a loooong time + # When not using gcc, we currently assume that we are using + # Microsoft Visual C++. + if test "$GCC" != yes; then + with_gnu_ld=no + fi + ;; + interix*) + # we just hope/assume this is gcc and not c89 (= MSVC++) + with_gnu_ld=yes + ;; + openbsd*) + with_gnu_ld=no + ;; + esac + + _LT_AC_TAGVAR(ld_shlibs, $1)=yes + if test "$with_gnu_ld" = yes; then + # If archive_cmds runs LD, not CC, wlarc should be empty + wlarc='${wl}' + + # Set some defaults for GNU ld with shared library support. These + # are reset later if shared libraries are not supported. Putting them + # here allows them to be overridden if necessary. + runpath_var=LD_RUN_PATH + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir' + _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' + # ancient GNU ld didn't support --whole-archive et. al. + if $LD --help 2>&1 | grep 'no-whole-archive' > /dev/null; then + _LT_AC_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' + else + _LT_AC_TAGVAR(whole_archive_flag_spec, $1)= + fi + supports_anon_versioning=no + case `$LD -v 2>/dev/null` in + *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.10.*) ;; # catch versions < 2.11 + *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ... + *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ... + *\ 2.11.*) ;; # other 2.11 versions + *) supports_anon_versioning=yes ;; + esac + + # See if GNU ld supports shared libraries. + case $host_os in + aix[[3-9]]*) + # On AIX/PPC, the GNU linker is very broken + if test "$host_cpu" != ia64; then + _LT_AC_TAGVAR(ld_shlibs, $1)=no + cat <&2 + +*** Warning: the GNU linker, at least up to release 2.9.1, is reported +*** to be unable to reliably create shared libraries on AIX. +*** Therefore, libtool is disabling shared libraries support. If you +*** really care for shared libraries, you may want to modify your PATH +*** so that a non-GNU linker is found, and then restart. + +EOF + fi + ;; + + amigaos*) + _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes + + # Samuel A. Falvo II reports + # that the semantics of dynamic libraries on AmigaOS, at least up + # to version 4, is to share data among multiple programs linked + # with the same dynamic library. Since this doesn't match the + # behavior of shared libraries on other platforms, we can't use + # them. + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + + beos*) + if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported + # Joseph Beckenbach says some releases of gcc + # support --undefined. This deserves some investigation. FIXME + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + else + _LT_AC_TAGVAR(ld_shlibs, $1)=no + fi + ;; + + cygwin* | mingw* | pw32*) + # _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless, + # as there is no search path for DLLs. + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported + _LT_AC_TAGVAR(always_export_symbols, $1)=no + _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=yes + _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/'\'' -e '\''/^[[AITW]][[ ]]/s/.*[[ ]]//'\'' | sort | uniq > $export_symbols' + + if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' + # If the export-symbols file already is a .def file (1st line + # is EXPORTS), use it as is; otherwise, prepend... + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then + cp $export_symbols $output_objdir/$soname.def; + else + echo EXPORTS > $output_objdir/$soname.def; + cat $export_symbols >> $output_objdir/$soname.def; + fi~ + $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' + else + _LT_AC_TAGVAR(ld_shlibs, $1)=no + fi + ;; + + interix[[3-9]]*) + _LT_AC_TAGVAR(hardcode_direct, $1)=no + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' + _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' + # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. + # Instead, shared libraries are loaded at an image base (0x10000000 by + # default) and relocated if they conflict, which is a slow very memory + # consuming and fragmenting process. To avoid this, we pick a random, + # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link + # time. Moving up from 0x10000000 also allows more sbrk(2) space. + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' + ;; + + gnu* | linux* | k*bsd*-gnu) + if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + tmp_addflag= + case $cc_basename,$host_cpu in + pgcc*) # Portland Group C compiler + _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive' + tmp_addflag=' $pic_flag' + ;; + pgf77* | pgf90* | pgf95*) # Portland Group f77 and f90 compilers + _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive' + tmp_addflag=' $pic_flag -Mnomain' ;; + ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64 + tmp_addflag=' -i_dynamic' ;; + efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64 + tmp_addflag=' -i_dynamic -nofor_main' ;; + ifc* | ifort*) # Intel Fortran compiler + tmp_addflag=' -nofor_main' ;; + esac + case `$CC -V 2>&1 | sed 5q` in + *Sun\ C*) # Sun C 5.9 + _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive' + tmp_sharedflag='-G' ;; + *Sun\ F*) # Sun Fortran 8.3 + tmp_sharedflag='-G' ;; + *) + tmp_sharedflag='-shared' ;; + esac + _LT_AC_TAGVAR(archive_cmds, $1)='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + + if test $supports_anon_versioning = yes; then + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $output_objdir/$libname.ver~ + cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ + $echo "local: *; };" >> $output_objdir/$libname.ver~ + $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib' + fi + _LT_AC_TAGVAR(link_all_deplibs, $1)=no + else + _LT_AC_TAGVAR(ld_shlibs, $1)=no + fi + ;; + + netbsd* | netbsdelf*-gnu) + if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' + wlarc= + else + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + fi + ;; + + solaris*) + if $LD -v 2>&1 | grep 'BFD 2\.8' > /dev/null; then + _LT_AC_TAGVAR(ld_shlibs, $1)=no + cat <&2 + +*** Warning: The releases 2.8.* of the GNU linker cannot reliably +*** create shared libraries on Solaris systems. Therefore, libtool +*** is disabling shared libraries support. We urge you to upgrade GNU +*** binutils to release 2.9.1 or newer. Another option is to modify +*** your PATH or compiler configuration so that the native linker is +*** used, and then restart. + +EOF + elif $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + else + _LT_AC_TAGVAR(ld_shlibs, $1)=no + fi + ;; + + sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*) + case `$LD -v 2>&1` in + *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.1[[0-5]].*) + _LT_AC_TAGVAR(ld_shlibs, $1)=no + cat <<_LT_EOF 1>&2 + +*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not +*** reliably create shared libraries on SCO systems. Therefore, libtool +*** is disabling shared libraries support. We urge you to upgrade GNU +*** binutils to release 2.16.91.0.3 or newer. Another option is to modify +*** your PATH or compiler configuration so that the native linker is +*** used, and then restart. + +_LT_EOF + ;; + *) + if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='`test -z "$SCOABSPATH" && echo ${wl}-rpath,$libdir`' + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname,\${SCOABSPATH:+${install_libdir}/}$soname,-retain-symbols-file,$export_symbols -o $lib' + else + _LT_AC_TAGVAR(ld_shlibs, $1)=no + fi + ;; + esac + ;; + + sunos4*) + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags' + wlarc= + _LT_AC_TAGVAR(hardcode_direct, $1)=yes + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + *) + if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + else + _LT_AC_TAGVAR(ld_shlibs, $1)=no + fi + ;; + esac + + if test "$_LT_AC_TAGVAR(ld_shlibs, $1)" = no; then + runpath_var= + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)= + _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)= + _LT_AC_TAGVAR(whole_archive_flag_spec, $1)= + fi + else + # PORTME fill in a description of your system's linker (not GNU ld) + case $host_os in + aix3*) + _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported + _LT_AC_TAGVAR(always_export_symbols, $1)=yes + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname' + # Note: this linker hardcodes the directories in LIBPATH if there + # are no directories specified by -L. + _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes + if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then + # Neither direct hardcoding nor static linking is supported with a + # broken collect2. + _LT_AC_TAGVAR(hardcode_direct, $1)=unsupported + fi + ;; + + aix[[4-9]]*) + if test "$host_cpu" = ia64; then + # On IA64, the linker does run time linking by default, so we don't + # have to do anything special. + aix_use_runtimelinking=no + exp_sym_flag='-Bexport' + no_entry_flag="" + else + # If we're using GNU nm, then we don't want the "-C" option. + # -C means demangle to AIX nm, but means don't demangle with GNU nm + if $NM -V 2>&1 | grep 'GNU' > /dev/null; then + _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\[$]2 == "T") || (\[$]2 == "D") || (\[$]2 == "B")) && ([substr](\[$]3,1,1) != ".")) { print \[$]3 } }'\'' | sort -u > $export_symbols' + else + _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\[$]2 == "T") || (\[$]2 == "D") || (\[$]2 == "B")) && ([substr](\[$]3,1,1) != ".")) { print \[$]3 } }'\'' | sort -u > $export_symbols' + fi + aix_use_runtimelinking=no + + # Test if we are trying to use run time linking or normal + # AIX style linking. If -brtl is somewhere in LDFLAGS, we + # need to do runtime linking. + case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*) + for ld_flag in $LDFLAGS; do + if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then + aix_use_runtimelinking=yes + break + fi + done + ;; + esac + + exp_sym_flag='-bexport' + no_entry_flag='-bnoentry' + fi + + # When large executables or shared objects are built, AIX ld can + # have problems creating the table of contents. If linking a library + # or program results in "error TOC overflow" add -mminimal-toc to + # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not + # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. + + _LT_AC_TAGVAR(archive_cmds, $1)='' + _LT_AC_TAGVAR(hardcode_direct, $1)=yes + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=':' + _LT_AC_TAGVAR(link_all_deplibs, $1)=yes + + if test "$GCC" = yes; then + case $host_os in aix4.[[012]]|aix4.[[012]].*) + # We only want to do this on AIX 4.2 and lower, the check + # below for broken collect2 doesn't work under 4.3+ + collect2name=`${CC} -print-prog-name=collect2` + if test -f "$collect2name" && \ + strings "$collect2name" | grep resolve_lib_name >/dev/null + then + # We have reworked collect2 + : + else + # We have old collect2 + _LT_AC_TAGVAR(hardcode_direct, $1)=unsupported + # It fails to find uninstalled libraries when the uninstalled + # path is not listed in the libpath. Setting hardcode_minus_L + # to unsupported forces relinking + _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)= + fi + ;; + esac + shared_flag='-shared' + if test "$aix_use_runtimelinking" = yes; then + shared_flag="$shared_flag "'${wl}-G' + fi + else + # not using gcc + if test "$host_cpu" = ia64; then + # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release + # chokes on -Wl,-G. The following line is correct: + shared_flag='-G' + else + if test "$aix_use_runtimelinking" = yes; then + shared_flag='${wl}-G' + else + shared_flag='${wl}-bM:SRE' + fi + fi + fi + + # It seems that -bexpall does not export symbols beginning with + # underscore (_), so it is better to generate a list of symbols to export. + _LT_AC_TAGVAR(always_export_symbols, $1)=yes + if test "$aix_use_runtimelinking" = yes; then + # Warning - without using the other runtime loading flags (-brtl), + # -berok will link without error, but may produce a broken library. + _LT_AC_TAGVAR(allow_undefined_flag, $1)='-berok' + # Determine the default libpath from the value encoded in an empty executable. + _LT_AC_SYS_LIBPATH_AIX + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" + _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" + else + if test "$host_cpu" = ia64; then + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib' + _LT_AC_TAGVAR(allow_undefined_flag, $1)="-z nodefs" + _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols" + else + # Determine the default libpath from the value encoded in an empty executable. + _LT_AC_SYS_LIBPATH_AIX + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" + # Warning - without using the other run time loading flags, + # -berok will link without error, but may produce a broken library. + _LT_AC_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok' + _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok' + # Exported symbols can be pulled into shared objects from archives + _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='$convenience' + _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=yes + # This is similar to how AIX traditionally builds its shared libraries. + _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' + fi + fi + ;; + + amigaos*) + _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes + # see comment about different semantics on the GNU ld section + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + + bsdi[[45]]*) + _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)=-rdynamic + ;; + + cygwin* | mingw* | pw32*) + # When not using gcc, we currently assume that we are using + # Microsoft Visual C++. + # hardcode_libdir_flag_spec is actually meaningless, as there is + # no search path for DLLs. + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)=' ' + _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported + # Tell ltmain to make .lib files, not .a files. + libext=lib + # Tell ltmain to make .dll files, not .so files. + shrext_cmds=".dll" + # FIXME: Setting linknames here is a bad hack. + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -o $lib $libobjs $compiler_flags `echo "$deplibs" | $SED -e '\''s/ -lc$//'\''` -link -dll~linknames=' + # The linker will automatically build a .lib file if we build a DLL. + _LT_AC_TAGVAR(old_archive_From_new_cmds, $1)='true' + # FIXME: Should let the user specify the lib program. + _LT_AC_TAGVAR(old_archive_cmds, $1)='lib -OUT:$oldlib$oldobjs$old_deplibs' + _LT_AC_TAGVAR(fix_srcfile_path, $1)='`cygpath -w "$srcfile"`' + _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=yes + ;; + + darwin* | rhapsody*) + case $host_os in + rhapsody* | darwin1.[[012]]) + _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-undefined ${wl}suppress' + ;; + *) # Darwin 1.3 on + if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then + _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' + else + case ${MACOSX_DEPLOYMENT_TARGET} in + 10.[[012]]) + _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' + ;; + 10.*) + _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-undefined ${wl}dynamic_lookup' + ;; + esac + fi + ;; + esac + _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no + _LT_AC_TAGVAR(hardcode_direct, $1)=no + _LT_AC_TAGVAR(hardcode_automatic, $1)=yes + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=unsupported + _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='' + _LT_AC_TAGVAR(link_all_deplibs, $1)=yes + if test "$GCC" = yes ; then + output_verbose_link_cmd='echo' + _LT_AC_TAGVAR(archive_cmds, $1)="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}" + _LT_AC_TAGVAR(module_cmds, $1)="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}" + _LT_AC_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}" + _LT_AC_TAGVAR(module_expsym_cmds, $1)="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}" + else + case $cc_basename in + xlc*) + output_verbose_link_cmd='echo' + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $xlcverstring' + _LT_AC_TAGVAR(module_cmds, $1)='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags' + # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $xlcverstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' + _LT_AC_TAGVAR(module_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' + ;; + *) + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + esac + fi + ;; + + dgux*) + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + freebsd1*) + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + + # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor + # support. Future versions do this automatically, but an explicit c++rt0.o + # does not break anything, and helps significantly (at the cost of a little + # extra space). + freebsd2.2*) + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o' + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + _LT_AC_TAGVAR(hardcode_direct, $1)=yes + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + # Unfortunately, older versions of FreeBSD 2 do not have this feature. + freebsd2*) + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' + _LT_AC_TAGVAR(hardcode_direct, $1)=yes + _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + # FreeBSD 3 and greater uses gcc -shared to do shared libraries. + freebsd* | dragonfly*) + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -o $lib $libobjs $deplibs $compiler_flags' + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + _LT_AC_TAGVAR(hardcode_direct, $1)=yes + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + hpux9*) + if test "$GCC" = yes; then + _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/$soname~$CC -shared -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' + else + _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' + fi + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: + _LT_AC_TAGVAR(hardcode_direct, $1)=yes + + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes + _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' + ;; + + hpux10*) + if test "$GCC" = yes -a "$with_gnu_ld" = no; then + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' + else + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' + fi + if test "$with_gnu_ld" = no; then + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: + + _LT_AC_TAGVAR(hardcode_direct, $1)=yes + _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' + + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes + fi + ;; + + hpux11*) + if test "$GCC" = yes -a "$with_gnu_ld" = no; then + case $host_cpu in + hppa*64*) + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + ia64*) + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' + ;; + *) + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' + ;; + esac + else + case $host_cpu in + hppa*64*) + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + ia64*) + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' + ;; + *) + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' + ;; + esac + fi + if test "$with_gnu_ld" = no; then + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: + + case $host_cpu in + hppa*64*|ia64*) + _LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='+b $libdir' + _LT_AC_TAGVAR(hardcode_direct, $1)=no + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + *) + _LT_AC_TAGVAR(hardcode_direct, $1)=yes + _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' + + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes + ;; + esac + fi + ;; + + irix5* | irix6* | nonstopux*) + if test "$GCC" = yes; then + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + else + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -shared $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' + _LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='-rpath $libdir' + fi + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: + _LT_AC_TAGVAR(link_all_deplibs, $1)=yes + ;; + + netbsd* | netbsdelf*-gnu) + if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out + else + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF + fi + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + _LT_AC_TAGVAR(hardcode_direct, $1)=yes + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + newsos6) + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_AC_TAGVAR(hardcode_direct, $1)=yes + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + openbsd*) + if test -f /usr/libexec/ld.so; then + _LT_AC_TAGVAR(hardcode_direct, $1)=yes + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols' + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' + _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' + else + case $host_os in + openbsd[[01]].* | openbsd2.[[0-7]] | openbsd2.[[0-7]].*) + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + ;; + *) + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' + ;; + esac + fi + else + _LT_AC_TAGVAR(ld_shlibs, $1)=no + fi + ;; + + os2*) + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes + _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported + _LT_AC_TAGVAR(archive_cmds, $1)='$echo "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$echo "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~$echo DATA >> $output_objdir/$libname.def~$echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~$echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def' + _LT_AC_TAGVAR(old_archive_From_new_cmds, $1)='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def' + ;; + + osf3*) + if test "$GCC" = yes; then + _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + else + _LT_AC_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' + fi + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: + ;; + + osf4* | osf5*) # as osf3* with the addition of -msym flag + if test "$GCC" = yes; then + _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + else + _LT_AC_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; echo "-hidden">> $lib.exp~ + $LD -shared${allow_undefined_flag} -input $lib.exp $linker_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib~$rm $lib.exp' + + # Both c and cxx compiler support -rpath directly + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' + fi + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: + ;; + + solaris*) + _LT_AC_TAGVAR(no_undefined_flag, $1)=' -z text' + if test "$GCC" = yes; then + wlarc='${wl}' + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ + $CC -shared ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$rm $lib.exp' + else + wlarc='' + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ + $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp' + fi + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + case $host_os in + solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; + *) + # The compiler driver will combine and reorder linker options, + # but understands `-z linker_flag'. GCC discards it without `$wl', + # but is careful enough not to reorder. + # Supported since Solaris 2.6 (maybe 2.5.1?) + if test "$GCC" = yes; then + _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract' + else + _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract' + fi + ;; + esac + _LT_AC_TAGVAR(link_all_deplibs, $1)=yes + ;; + + sunos4*) + if test "x$host_vendor" = xsequent; then + # Use $CC to link under sequent, because it throws in some extra .o + # files that make .init and .fini sections work. + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags' + else + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags' + fi + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_AC_TAGVAR(hardcode_direct, $1)=yes + _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + sysv4) + case $host_vendor in + sni) + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_AC_TAGVAR(hardcode_direct, $1)=yes # is this really true??? + ;; + siemens) + ## LD is ld it makes a PLAMLIB + ## CC just makes a GrossModule. + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -o $lib $libobjs $deplibs $linker_flags' + _LT_AC_TAGVAR(reload_cmds, $1)='$CC -r -o $output$reload_objs' + _LT_AC_TAGVAR(hardcode_direct, $1)=no + ;; + motorola) + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_AC_TAGVAR(hardcode_direct, $1)=no #Motorola manual says yes, but my tests say they lie + ;; + esac + runpath_var='LD_RUN_PATH' + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + sysv4.3*) + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='-Bexport' + ;; + + sysv4*MP*) + if test -d /usr/nec; then + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + runpath_var=LD_RUN_PATH + hardcode_runpath_var=yes + _LT_AC_TAGVAR(ld_shlibs, $1)=yes + fi + ;; + + sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*) + _LT_AC_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' + _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + runpath_var='LD_RUN_PATH' + + if test "$GCC" = yes; then + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + else + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + fi + ;; + + sysv5* | sco3.2v5* | sco5v6*) + # Note: We can NOT use -z defs as we might desire, because we do not + # link with -lc, and that would cause any symbols used from libc to + # always be unresolved, which means just about no library would + # ever link correctly. If we're not using GNU ld we use -z text + # though, which does catch some bad symbols but isn't as heavy-handed + # as -z defs. + _LT_AC_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' + _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs' + _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='`test -z "$SCOABSPATH" && echo ${wl}-R,$libdir`' + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=':' + _LT_AC_TAGVAR(link_all_deplibs, $1)=yes + _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport' + runpath_var='LD_RUN_PATH' + + if test "$GCC" = yes; then + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags' + else + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags' + fi + ;; + + uts4*) + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + *) + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + esac + fi +]) +AC_MSG_RESULT([$_LT_AC_TAGVAR(ld_shlibs, $1)]) +test "$_LT_AC_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no + +# +# Do we need to explicitly link libc? +# +case "x$_LT_AC_TAGVAR(archive_cmds_need_lc, $1)" in +x|xyes) + # Assume -lc should be added + _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=yes + + if test "$enable_shared" = yes && test "$GCC" = yes; then + case $_LT_AC_TAGVAR(archive_cmds, $1) in + *'~'*) + # FIXME: we may have to deal with multi-command sequences. + ;; + '$CC '*) + # Test whether the compiler implicitly links with -lc since on some + # systems, -lgcc has to come before -lc. If gcc already passes -lc + # to ld, don't add -lc before -lgcc. + AC_MSG_CHECKING([whether -lc should be explicitly linked in]) + $rm conftest* + echo "$lt_simple_compile_test_code" > conftest.$ac_ext + + if AC_TRY_EVAL(ac_compile) 2>conftest.err; then + soname=conftest + lib=conftest + libobjs=conftest.$ac_objext + deplibs= + wl=$_LT_AC_TAGVAR(lt_prog_compiler_wl, $1) + pic_flag=$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1) + compiler_flags=-v + linker_flags=-v + verstring= + output_objdir=. + libname=conftest + lt_save_allow_undefined_flag=$_LT_AC_TAGVAR(allow_undefined_flag, $1) + _LT_AC_TAGVAR(allow_undefined_flag, $1)= + if AC_TRY_EVAL(_LT_AC_TAGVAR(archive_cmds, $1) 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1) + then + _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no + else + _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=yes + fi + _LT_AC_TAGVAR(allow_undefined_flag, $1)=$lt_save_allow_undefined_flag + else + cat conftest.err 1>&5 + fi + $rm conftest* + AC_MSG_RESULT([$_LT_AC_TAGVAR(archive_cmds_need_lc, $1)]) + ;; + esac + fi + ;; +esac +])# AC_LIBTOOL_PROG_LD_SHLIBS + + +# _LT_AC_FILE_LTDLL_C +# ------------------- +# Be careful that the start marker always follows a newline. +AC_DEFUN([_LT_AC_FILE_LTDLL_C], [ +# /* ltdll.c starts here */ +# #define WIN32_LEAN_AND_MEAN +# #include +# #undef WIN32_LEAN_AND_MEAN +# #include +# +# #ifndef __CYGWIN__ +# # ifdef __CYGWIN32__ +# # define __CYGWIN__ __CYGWIN32__ +# # endif +# #endif +# +# #ifdef __cplusplus +# extern "C" { +# #endif +# BOOL APIENTRY DllMain (HINSTANCE hInst, DWORD reason, LPVOID reserved); +# #ifdef __cplusplus +# } +# #endif +# +# #ifdef __CYGWIN__ +# #include +# DECLARE_CYGWIN_DLL( DllMain ); +# #endif +# HINSTANCE __hDllInstance_base; +# +# BOOL APIENTRY +# DllMain (HINSTANCE hInst, DWORD reason, LPVOID reserved) +# { +# __hDllInstance_base = hInst; +# return TRUE; +# } +# /* ltdll.c ends here */ +])# _LT_AC_FILE_LTDLL_C + + +# _LT_AC_TAGVAR(VARNAME, [TAGNAME]) +# --------------------------------- +AC_DEFUN([_LT_AC_TAGVAR], [ifelse([$2], [], [$1], [$1_$2])]) + + +# old names +AC_DEFUN([AM_PROG_LIBTOOL], [AC_PROG_LIBTOOL]) +AC_DEFUN([AM_ENABLE_SHARED], [AC_ENABLE_SHARED($@)]) +AC_DEFUN([AM_ENABLE_STATIC], [AC_ENABLE_STATIC($@)]) +AC_DEFUN([AM_DISABLE_SHARED], [AC_DISABLE_SHARED($@)]) +AC_DEFUN([AM_DISABLE_STATIC], [AC_DISABLE_STATIC($@)]) +AC_DEFUN([AM_PROG_LD], [AC_PROG_LD]) +AC_DEFUN([AM_PROG_NM], [AC_PROG_NM]) + +# This is just to silence aclocal about the macro not being used +ifelse([AC_DISABLE_FAST_INSTALL]) + +AC_DEFUN([LT_AC_PROG_GCJ], +[AC_CHECK_TOOL(GCJ, gcj, no) + test "x${GCJFLAGS+set}" = xset || GCJFLAGS="-g -O2" + AC_SUBST(GCJFLAGS) +]) + +AC_DEFUN([LT_AC_PROG_RC], +[AC_CHECK_TOOL(RC, windres, no) +]) + + +# Cheap backport of AS_EXECUTABLE_P and required macros +# from Autoconf 2.59; we should not use $as_executable_p directly. + +# _AS_TEST_PREPARE +# ---------------- +m4_ifndef([_AS_TEST_PREPARE], +[m4_defun([_AS_TEST_PREPARE], +[if test -x / >/dev/null 2>&1; then + as_executable_p='test -x' +else + as_executable_p='test -f' +fi +])])# _AS_TEST_PREPARE + +# AS_EXECUTABLE_P +# --------------- +# Check whether a file is executable. +m4_ifndef([AS_EXECUTABLE_P], +[m4_defun([AS_EXECUTABLE_P], +[AS_REQUIRE([_AS_TEST_PREPARE])dnl +$as_executable_p $1[]dnl +])])# AS_EXECUTABLE_P + +# NOTE: This macro has been submitted for inclusion into # +# GNU Autoconf as AC_PROG_SED. When it is available in # +# a released version of Autoconf we should remove this # +# macro and use it instead. # +# LT_AC_PROG_SED +# -------------- +# Check for a fully-functional sed program, that truncates +# as few characters as possible. Prefer GNU sed if found. +AC_DEFUN([LT_AC_PROG_SED], +[AC_MSG_CHECKING([for a sed that does not truncate output]) +AC_CACHE_VAL(lt_cv_path_SED, +[# Loop through the user's path and test for sed and gsed. +# Then use that list of sed's as ones to test for truncation. +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for lt_ac_prog in sed gsed; do + for ac_exec_ext in '' $ac_executable_extensions; do + if AS_EXECUTABLE_P(["$as_dir/$lt_ac_prog$ac_exec_ext"]); then + lt_ac_sed_list="$lt_ac_sed_list $as_dir/$lt_ac_prog$ac_exec_ext" + fi + done + done +done +IFS=$as_save_IFS +lt_ac_max=0 +lt_ac_count=0 +# Add /usr/xpg4/bin/sed as it is typically found on Solaris +# along with /bin/sed that truncates output. +for lt_ac_sed in $lt_ac_sed_list /usr/xpg4/bin/sed; do + test ! -f $lt_ac_sed && continue + cat /dev/null > conftest.in + lt_ac_count=0 + echo $ECHO_N "0123456789$ECHO_C" >conftest.in + # Check for GNU sed and select it if it is found. + if "$lt_ac_sed" --version 2>&1 < /dev/null | grep 'GNU' > /dev/null; then + lt_cv_path_SED=$lt_ac_sed + break + fi + while true; do + cat conftest.in conftest.in >conftest.tmp + mv conftest.tmp conftest.in + cp conftest.in conftest.nl + echo >>conftest.nl + $lt_ac_sed -e 's/a$//' < conftest.nl >conftest.out || break + cmp -s conftest.out conftest.nl || break + # 10000 chars as input seems more than enough + test $lt_ac_count -gt 10 && break + lt_ac_count=`expr $lt_ac_count + 1` + if test $lt_ac_count -gt $lt_ac_max; then + lt_ac_max=$lt_ac_count + lt_cv_path_SED=$lt_ac_sed + fi + done +done +]) +SED=$lt_cv_path_SED +AC_SUBST([SED]) +AC_MSG_RESULT([$SED]) +]) + +# Copyright (C) 2002, 2003, 2005, 2006, 2007 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# AM_AUTOMAKE_VERSION(VERSION) +# ---------------------------- +# Automake X.Y traces this macro to ensure aclocal.m4 has been +# generated from the m4 files accompanying Automake X.Y. +# (This private macro should not be called outside this file.) +AC_DEFUN([AM_AUTOMAKE_VERSION], +[am__api_version='1.10' +dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to +dnl require some minimum version. Point them to the right macro. +m4_if([$1], [1.10.1], [], + [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl +]) + +# _AM_AUTOCONF_VERSION(VERSION) +# ----------------------------- +# aclocal traces this macro to find the Autoconf version. +# This is a private macro too. Using m4_define simplifies +# the logic in aclocal, which can simply ignore this definition. +m4_define([_AM_AUTOCONF_VERSION], []) + +# AM_SET_CURRENT_AUTOMAKE_VERSION +# ------------------------------- +# Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced. +# This function is AC_REQUIREd by AC_INIT_AUTOMAKE. +AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], +[AM_AUTOMAKE_VERSION([1.10.1])dnl +m4_ifndef([AC_AUTOCONF_VERSION], + [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl +_AM_AUTOCONF_VERSION(AC_AUTOCONF_VERSION)]) + +# AM_AUX_DIR_EXPAND -*- Autoconf -*- + +# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets +# $ac_aux_dir to `$srcdir/foo'. In other projects, it is set to +# `$srcdir', `$srcdir/..', or `$srcdir/../..'. +# +# Of course, Automake must honor this variable whenever it calls a +# tool from the auxiliary directory. The problem is that $srcdir (and +# therefore $ac_aux_dir as well) can be either absolute or relative, +# depending on how configure is run. This is pretty annoying, since +# it makes $ac_aux_dir quite unusable in subdirectories: in the top +# source directory, any form will work fine, but in subdirectories a +# relative path needs to be adjusted first. +# +# $ac_aux_dir/missing +# fails when called from a subdirectory if $ac_aux_dir is relative +# $top_srcdir/$ac_aux_dir/missing +# fails if $ac_aux_dir is absolute, +# fails when called from a subdirectory in a VPATH build with +# a relative $ac_aux_dir +# +# The reason of the latter failure is that $top_srcdir and $ac_aux_dir +# are both prefixed by $srcdir. In an in-source build this is usually +# harmless because $srcdir is `.', but things will broke when you +# start a VPATH build or use an absolute $srcdir. +# +# So we could use something similar to $top_srcdir/$ac_aux_dir/missing, +# iff we strip the leading $srcdir from $ac_aux_dir. That would be: +# am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"` +# and then we would define $MISSING as +# MISSING="\${SHELL} $am_aux_dir/missing" +# This will work as long as MISSING is not called from configure, because +# unfortunately $(top_srcdir) has no meaning in configure. +# However there are other variables, like CC, which are often used in +# configure, and could therefore not use this "fixed" $ac_aux_dir. +# +# Another solution, used here, is to always expand $ac_aux_dir to an +# absolute PATH. The drawback is that using absolute paths prevent a +# configured tree to be moved without reconfiguration. + +AC_DEFUN([AM_AUX_DIR_EXPAND], +[dnl Rely on autoconf to set up CDPATH properly. +AC_PREREQ([2.50])dnl +# expand $ac_aux_dir to an absolute path +am_aux_dir=`cd $ac_aux_dir && pwd` +]) + +# AM_CONDITIONAL -*- Autoconf -*- + +# Copyright (C) 1997, 2000, 2001, 2003, 2004, 2005, 2006 +# Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 8 + +# AM_CONDITIONAL(NAME, SHELL-CONDITION) +# ------------------------------------- +# Define a conditional. +AC_DEFUN([AM_CONDITIONAL], +[AC_PREREQ(2.52)dnl + ifelse([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])], + [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl +AC_SUBST([$1_TRUE])dnl +AC_SUBST([$1_FALSE])dnl +_AM_SUBST_NOTMAKE([$1_TRUE])dnl +_AM_SUBST_NOTMAKE([$1_FALSE])dnl +if $2; then + $1_TRUE= + $1_FALSE='#' +else + $1_TRUE='#' + $1_FALSE= +fi +AC_CONFIG_COMMANDS_PRE( +[if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then + AC_MSG_ERROR([[conditional "$1" was never defined. +Usually this means the macro was only invoked conditionally.]]) +fi])]) + +# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 +# Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 9 + +# There are a few dirty hacks below to avoid letting `AC_PROG_CC' be +# written in clear, in which case automake, when reading aclocal.m4, +# will think it sees a *use*, and therefore will trigger all it's +# C support machinery. Also note that it means that autoscan, seeing +# CC etc. in the Makefile, will ask for an AC_PROG_CC use... + + +# _AM_DEPENDENCIES(NAME) +# ---------------------- +# See how the compiler implements dependency checking. +# NAME is "CC", "CXX", "GCJ", or "OBJC". +# We try a few techniques and use that to set a single cache variable. +# +# We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was +# modified to invoke _AM_DEPENDENCIES(CC); we would have a circular +# dependency, and given that the user is not expected to run this macro, +# just rely on AC_PROG_CC. +AC_DEFUN([_AM_DEPENDENCIES], +[AC_REQUIRE([AM_SET_DEPDIR])dnl +AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl +AC_REQUIRE([AM_MAKE_INCLUDE])dnl +AC_REQUIRE([AM_DEP_TRACK])dnl + +ifelse([$1], CC, [depcc="$CC" am_compiler_list=], + [$1], CXX, [depcc="$CXX" am_compiler_list=], + [$1], OBJC, [depcc="$OBJC" am_compiler_list='gcc3 gcc'], + [$1], UPC, [depcc="$UPC" am_compiler_list=], + [$1], GCJ, [depcc="$GCJ" am_compiler_list='gcc3 gcc'], + [depcc="$$1" am_compiler_list=]) + +AC_CACHE_CHECK([dependency style of $depcc], + [am_cv_$1_dependencies_compiler_type], +[if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then + # We make a subdir and do the tests there. Otherwise we can end up + # making bogus files that we don't know about and never remove. For + # instance it was reported that on HP-UX the gcc test will end up + # making a dummy file named `D' -- because `-MD' means `put the output + # in D'. + mkdir conftest.dir + # Copy depcomp to subdir because otherwise we won't find it if we're + # using a relative directory. + cp "$am_depcomp" conftest.dir + cd conftest.dir + # We will build objects and dependencies in a subdirectory because + # it helps to detect inapplicable dependency modes. For instance + # both Tru64's cc and ICC support -MD to output dependencies as a + # side effect of compilation, but ICC will put the dependencies in + # the current directory while Tru64 will put them in the object + # directory. + mkdir sub + + am_cv_$1_dependencies_compiler_type=none + if test "$am_compiler_list" = ""; then + am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp` + fi + for depmode in $am_compiler_list; do + # Setup a source with many dependencies, because some compilers + # like to wrap large dependency lists on column 80 (with \), and + # we should not choose a depcomp mode which is confused by this. + # + # We need to recreate these files for each test, as the compiler may + # overwrite some of them when testing with obscure command lines. + # This happens at least with the AIX C compiler. + : > sub/conftest.c + for i in 1 2 3 4 5 6; do + echo '#include "conftst'$i'.h"' >> sub/conftest.c + # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with + # Solaris 8's {/usr,}/bin/sh. + touch sub/conftst$i.h + done + echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf + + case $depmode in + nosideeffect) + # after this tag, mechanisms are not by side-effect, so they'll + # only be used when explicitly requested + if test "x$enable_dependency_tracking" = xyes; then + continue + else + break + fi + ;; + none) break ;; + esac + # We check with `-c' and `-o' for the sake of the "dashmstdout" + # mode. It turns out that the SunPro C++ compiler does not properly + # handle `-M -o', and we need to detect this. + if depmode=$depmode \ + source=sub/conftest.c object=sub/conftest.${OBJEXT-o} \ + depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ + $SHELL ./depcomp $depcc -c -o sub/conftest.${OBJEXT-o} sub/conftest.c \ + >/dev/null 2>conftest.err && + grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && + grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && + grep sub/conftest.${OBJEXT-o} sub/conftest.Po > /dev/null 2>&1 && + ${MAKE-make} -s -f confmf > /dev/null 2>&1; then + # icc doesn't choke on unknown options, it will just issue warnings + # or remarks (even with -Werror). So we grep stderr for any message + # that says an option was ignored or not supported. + # When given -MP, icc 7.0 and 7.1 complain thusly: + # icc: Command line warning: ignoring option '-M'; no argument required + # The diagnosis changed in icc 8.0: + # icc: Command line remark: option '-MP' not supported + if (grep 'ignoring option' conftest.err || + grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else + am_cv_$1_dependencies_compiler_type=$depmode + break + fi + fi + done + + cd .. + rm -rf conftest.dir +else + am_cv_$1_dependencies_compiler_type=none +fi +]) +AC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type]) +AM_CONDITIONAL([am__fastdep$1], [ + test "x$enable_dependency_tracking" != xno \ + && test "$am_cv_$1_dependencies_compiler_type" = gcc3]) +]) + + +# AM_SET_DEPDIR +# ------------- +# Choose a directory name for dependency files. +# This macro is AC_REQUIREd in _AM_DEPENDENCIES +AC_DEFUN([AM_SET_DEPDIR], +[AC_REQUIRE([AM_SET_LEADING_DOT])dnl +AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl +]) + + +# AM_DEP_TRACK +# ------------ +AC_DEFUN([AM_DEP_TRACK], +[AC_ARG_ENABLE(dependency-tracking, +[ --disable-dependency-tracking speeds up one-time build + --enable-dependency-tracking do not reject slow dependency extractors]) +if test "x$enable_dependency_tracking" != xno; then + am_depcomp="$ac_aux_dir/depcomp" + AMDEPBACKSLASH='\' +fi +AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno]) +AC_SUBST([AMDEPBACKSLASH])dnl +_AM_SUBST_NOTMAKE([AMDEPBACKSLASH])dnl +]) + +# Generate code to set up dependency tracking. -*- Autoconf -*- + +# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005 +# Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +#serial 3 + +# _AM_OUTPUT_DEPENDENCY_COMMANDS +# ------------------------------ +AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS], +[for mf in $CONFIG_FILES; do + # Strip MF so we end up with the name of the file. + mf=`echo "$mf" | sed -e 's/:.*$//'` + # Check whether this is an Automake generated Makefile or not. + # We used to match only the files named `Makefile.in', but + # some people rename them; so instead we look at the file content. + # Grep'ing the first line is not enough: some people post-process + # each Makefile.in and add a new line on top of each file to say so. + # Grep'ing the whole file is not good either: AIX grep has a line + # limit of 2048, but all sed's we know have understand at least 4000. + if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then + dirpart=`AS_DIRNAME("$mf")` + else + continue + fi + # Extract the definition of DEPDIR, am__include, and am__quote + # from the Makefile without running `make'. + DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` + test -z "$DEPDIR" && continue + am__include=`sed -n 's/^am__include = //p' < "$mf"` + test -z "am__include" && continue + am__quote=`sed -n 's/^am__quote = //p' < "$mf"` + # When using ansi2knr, U may be empty or an underscore; expand it + U=`sed -n 's/^U = //p' < "$mf"` + # Find all dependency output files, they are included files with + # $(DEPDIR) in their names. We invoke sed twice because it is the + # simplest approach to changing $(DEPDIR) to its actual value in the + # expansion. + for file in `sed -n " + s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ + sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do + # Make sure the directory exists. + test -f "$dirpart/$file" && continue + fdir=`AS_DIRNAME(["$file"])` + AS_MKDIR_P([$dirpart/$fdir]) + # echo "creating $dirpart/$file" + echo '# dummy' > "$dirpart/$file" + done +done +])# _AM_OUTPUT_DEPENDENCY_COMMANDS + + +# AM_OUTPUT_DEPENDENCY_COMMANDS +# ----------------------------- +# This macro should only be invoked once -- use via AC_REQUIRE. +# +# This code is only required when automatic dependency tracking +# is enabled. FIXME. This creates each `.P' file that we will +# need in order to bootstrap the dependency handling code. +AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS], +[AC_CONFIG_COMMANDS([depfiles], + [test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS], + [AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"]) +]) + +# Do all the work for Automake. -*- Autoconf -*- + +# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, +# 2005, 2006, 2008 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 13 + +# This macro actually does too much. Some checks are only needed if +# your package does certain things. But this isn't really a big deal. + +# AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE]) +# AM_INIT_AUTOMAKE([OPTIONS]) +# ----------------------------------------------- +# The call with PACKAGE and VERSION arguments is the old style +# call (pre autoconf-2.50), which is being phased out. PACKAGE +# and VERSION should now be passed to AC_INIT and removed from +# the call to AM_INIT_AUTOMAKE. +# We support both call styles for the transition. After +# the next Automake release, Autoconf can make the AC_INIT +# arguments mandatory, and then we can depend on a new Autoconf +# release and drop the old call support. +AC_DEFUN([AM_INIT_AUTOMAKE], +[AC_PREREQ([2.60])dnl +dnl Autoconf wants to disallow AM_ names. We explicitly allow +dnl the ones we care about. +m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl +AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl +AC_REQUIRE([AC_PROG_INSTALL])dnl +if test "`cd $srcdir && pwd`" != "`pwd`"; then + # Use -I$(srcdir) only when $(srcdir) != ., so that make's output + # is not polluted with repeated "-I." + AC_SUBST([am__isrc], [' -I$(srcdir)'])_AM_SUBST_NOTMAKE([am__isrc])dnl + # test to see if srcdir already configured + if test -f $srcdir/config.status; then + AC_MSG_ERROR([source directory already configured; run "make distclean" there first]) + fi +fi + +# test whether we have cygpath +if test -z "$CYGPATH_W"; then + if (cygpath --version) >/dev/null 2>/dev/null; then + CYGPATH_W='cygpath -w' + else + CYGPATH_W=echo + fi +fi +AC_SUBST([CYGPATH_W]) + +# Define the identity of the package. +dnl Distinguish between old-style and new-style calls. +m4_ifval([$2], +[m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl + AC_SUBST([PACKAGE], [$1])dnl + AC_SUBST([VERSION], [$2])], +[_AM_SET_OPTIONS([$1])dnl +dnl Diagnose old-style AC_INIT with new-style AM_AUTOMAKE_INIT. +m4_if(m4_ifdef([AC_PACKAGE_NAME], 1)m4_ifdef([AC_PACKAGE_VERSION], 1), 11,, + [m4_fatal([AC_INIT should be called with package and version arguments])])dnl + AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl + AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl + +_AM_IF_OPTION([no-define],, +[AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package]) + AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package])])dnl + +# Some tools Automake needs. +AC_REQUIRE([AM_SANITY_CHECK])dnl +AC_REQUIRE([AC_ARG_PROGRAM])dnl +AM_MISSING_PROG(ACLOCAL, aclocal-${am__api_version}) +AM_MISSING_PROG(AUTOCONF, autoconf) +AM_MISSING_PROG(AUTOMAKE, automake-${am__api_version}) +AM_MISSING_PROG(AUTOHEADER, autoheader) +AM_MISSING_PROG(MAKEINFO, makeinfo) +AM_PROG_INSTALL_SH +AM_PROG_INSTALL_STRIP +AC_REQUIRE([AM_PROG_MKDIR_P])dnl +# We need awk for the "check" target. The system "awk" is bad on +# some platforms. +AC_REQUIRE([AC_PROG_AWK])dnl +AC_REQUIRE([AC_PROG_MAKE_SET])dnl +AC_REQUIRE([AM_SET_LEADING_DOT])dnl +_AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])], + [_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])], + [_AM_PROG_TAR([v7])])]) +_AM_IF_OPTION([no-dependencies],, +[AC_PROVIDE_IFELSE([AC_PROG_CC], + [_AM_DEPENDENCIES(CC)], + [define([AC_PROG_CC], + defn([AC_PROG_CC])[_AM_DEPENDENCIES(CC)])])dnl +AC_PROVIDE_IFELSE([AC_PROG_CXX], + [_AM_DEPENDENCIES(CXX)], + [define([AC_PROG_CXX], + defn([AC_PROG_CXX])[_AM_DEPENDENCIES(CXX)])])dnl +AC_PROVIDE_IFELSE([AC_PROG_OBJC], + [_AM_DEPENDENCIES(OBJC)], + [define([AC_PROG_OBJC], + defn([AC_PROG_OBJC])[_AM_DEPENDENCIES(OBJC)])])dnl +]) +]) + + +# When config.status generates a header, we must update the stamp-h file. +# This file resides in the same directory as the config header +# that is generated. The stamp files are numbered to have different names. + +# Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the +# loop where config.status creates the headers, so we can generate +# our stamp files there. +AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK], +[# Compute $1's index in $config_headers. +_am_arg=$1 +_am_stamp_count=1 +for _am_header in $config_headers :; do + case $_am_header in + $_am_arg | $_am_arg:* ) + break ;; + * ) + _am_stamp_count=`expr $_am_stamp_count + 1` ;; + esac +done +echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count]) + +# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# AM_PROG_INSTALL_SH +# ------------------ +# Define $install_sh. +AC_DEFUN([AM_PROG_INSTALL_SH], +[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl +install_sh=${install_sh-"\$(SHELL) $am_aux_dir/install-sh"} +AC_SUBST(install_sh)]) + +# Copyright (C) 2003, 2005 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 2 + +# Check whether the underlying file-system supports filenames +# with a leading dot. For instance MS-DOS doesn't. +AC_DEFUN([AM_SET_LEADING_DOT], +[rm -rf .tst 2>/dev/null +mkdir .tst 2>/dev/null +if test -d .tst; then + am__leading_dot=. +else + am__leading_dot=_ +fi +rmdir .tst 2>/dev/null +AC_SUBST([am__leading_dot])]) + +# Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2005 +# Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 5 + +# AM_PROG_LEX +# ----------- +# Autoconf leaves LEX=: if lex or flex can't be found. Change that to a +# "missing" invocation, for better error output. +AC_DEFUN([AM_PROG_LEX], +[AC_PREREQ(2.50)dnl +AC_REQUIRE([AM_MISSING_HAS_RUN])dnl +AC_REQUIRE([AC_PROG_LEX])dnl +if test "$LEX" = :; then + LEX=${am_missing_run}flex +fi]) + +# Check to see how 'make' treats includes. -*- Autoconf -*- + +# Copyright (C) 2001, 2002, 2003, 2005 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 3 + +# AM_MAKE_INCLUDE() +# ----------------- +# Check to see how make treats includes. +AC_DEFUN([AM_MAKE_INCLUDE], +[am_make=${MAKE-make} +cat > confinc << 'END' +am__doit: + @echo done +.PHONY: am__doit +END +# If we don't find an include directive, just comment out the code. +AC_MSG_CHECKING([for style of include used by $am_make]) +am__include="#" +am__quote= +_am_result=none +# First try GNU make style include. +echo "include confinc" > confmf +# We grep out `Entering directory' and `Leaving directory' +# messages which can occur if `w' ends up in MAKEFLAGS. +# In particular we don't look at `^make:' because GNU make might +# be invoked under some other name (usually "gmake"), in which +# case it prints its new name instead of `make'. +if test "`$am_make -s -f confmf 2> /dev/null | grep -v 'ing directory'`" = "done"; then + am__include=include + am__quote= + _am_result=GNU +fi +# Now try BSD make style include. +if test "$am__include" = "#"; then + echo '.include "confinc"' > confmf + if test "`$am_make -s -f confmf 2> /dev/null`" = "done"; then + am__include=.include + am__quote="\"" + _am_result=BSD + fi +fi +AC_SUBST([am__include]) +AC_SUBST([am__quote]) +AC_MSG_RESULT([$_am_result]) +rm -f confinc confmf +]) + +# Fake the existence of programs that GNU maintainers use. -*- Autoconf -*- + +# Copyright (C) 1997, 1999, 2000, 2001, 2003, 2004, 2005 +# Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 5 + +# AM_MISSING_PROG(NAME, PROGRAM) +# ------------------------------ +AC_DEFUN([AM_MISSING_PROG], +[AC_REQUIRE([AM_MISSING_HAS_RUN]) +$1=${$1-"${am_missing_run}$2"} +AC_SUBST($1)]) + + +# AM_MISSING_HAS_RUN +# ------------------ +# Define MISSING if not defined so far and test if it supports --run. +# If it does, set am_missing_run to use it, otherwise, to nothing. +AC_DEFUN([AM_MISSING_HAS_RUN], +[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl +AC_REQUIRE_AUX_FILE([missing])dnl +test x"${MISSING+set}" = xset || MISSING="\${SHELL} $am_aux_dir/missing" +# Use eval to expand $SHELL +if eval "$MISSING --run true"; then + am_missing_run="$MISSING --run " +else + am_missing_run= + AC_MSG_WARN([`missing' script is too old or missing]) +fi +]) + +# Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# AM_PROG_MKDIR_P +# --------------- +# Check for `mkdir -p'. +AC_DEFUN([AM_PROG_MKDIR_P], +[AC_PREREQ([2.60])dnl +AC_REQUIRE([AC_PROG_MKDIR_P])dnl +dnl Automake 1.8 to 1.9.6 used to define mkdir_p. We now use MKDIR_P, +dnl while keeping a definition of mkdir_p for backward compatibility. +dnl @MKDIR_P@ is magic: AC_OUTPUT adjusts its value for each Makefile. +dnl However we cannot define mkdir_p as $(MKDIR_P) for the sake of +dnl Makefile.ins that do not define MKDIR_P, so we do our own +dnl adjustment using top_builddir (which is defined more often than +dnl MKDIR_P). +AC_SUBST([mkdir_p], ["$MKDIR_P"])dnl +case $mkdir_p in + [[\\/$]]* | ?:[[\\/]]*) ;; + */*) mkdir_p="\$(top_builddir)/$mkdir_p" ;; +esac +]) + +# Helper functions for option handling. -*- Autoconf -*- + +# Copyright (C) 2001, 2002, 2003, 2005 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 3 + +# _AM_MANGLE_OPTION(NAME) +# ----------------------- +AC_DEFUN([_AM_MANGLE_OPTION], +[[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])]) + +# _AM_SET_OPTION(NAME) +# ------------------------------ +# Set option NAME. Presently that only means defining a flag for this option. +AC_DEFUN([_AM_SET_OPTION], +[m4_define(_AM_MANGLE_OPTION([$1]), 1)]) + +# _AM_SET_OPTIONS(OPTIONS) +# ---------------------------------- +# OPTIONS is a space-separated list of Automake options. +AC_DEFUN([_AM_SET_OPTIONS], +[AC_FOREACH([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])]) + +# _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET]) +# ------------------------------------------- +# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise. +AC_DEFUN([_AM_IF_OPTION], +[m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])]) + +# Check to make sure that the build environment is sane. -*- Autoconf -*- + +# Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005 +# Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 4 + +# AM_SANITY_CHECK +# --------------- +AC_DEFUN([AM_SANITY_CHECK], +[AC_MSG_CHECKING([whether build environment is sane]) +# Just in case +sleep 1 +echo timestamp > conftest.file +# Do `set' in a subshell so we don't clobber the current shell's +# arguments. Must try -L first in case configure is actually a +# symlink; some systems play weird games with the mod time of symlinks +# (eg FreeBSD returns the mod time of the symlink's containing +# directory). +if ( + set X `ls -Lt $srcdir/configure conftest.file 2> /dev/null` + if test "$[*]" = "X"; then + # -L didn't work. + set X `ls -t $srcdir/configure conftest.file` + fi + rm -f conftest.file + if test "$[*]" != "X $srcdir/configure conftest.file" \ + && test "$[*]" != "X conftest.file $srcdir/configure"; then + + # If neither matched, then we have a broken ls. This can happen + # if, for instance, CONFIG_SHELL is bash and it inherits a + # broken ls alias from the environment. This has actually + # happened. Such a system could not be considered "sane". + AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken +alias in your environment]) + fi + + test "$[2]" = conftest.file + ) +then + # Ok. + : +else + AC_MSG_ERROR([newly created file is older than distributed files! +Check your system clock]) +fi +AC_MSG_RESULT(yes)]) + +# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# AM_PROG_INSTALL_STRIP +# --------------------- +# One issue with vendor `install' (even GNU) is that you can't +# specify the program used to strip binaries. This is especially +# annoying in cross-compiling environments, where the build's strip +# is unlikely to handle the host's binaries. +# Fortunately install-sh will honor a STRIPPROG variable, so we +# always use install-sh in `make install-strip', and initialize +# STRIPPROG with the value of the STRIP variable (set by the user). +AC_DEFUN([AM_PROG_INSTALL_STRIP], +[AC_REQUIRE([AM_PROG_INSTALL_SH])dnl +# Installed binaries are usually stripped using `strip' when the user +# run `make install-strip'. However `strip' might not be the right +# tool to use in cross-compilation environments, therefore Automake +# will honor the `STRIP' environment variable to overrule this program. +dnl Don't test for $cross_compiling = yes, because it might be `maybe'. +if test "$cross_compiling" != no; then + AC_CHECK_TOOL([STRIP], [strip], :) +fi +INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" +AC_SUBST([INSTALL_STRIP_PROGRAM])]) + +# Copyright (C) 2006 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# _AM_SUBST_NOTMAKE(VARIABLE) +# --------------------------- +# Prevent Automake from outputting VARIABLE = @VARIABLE@ in Makefile.in. +# This macro is traced by Automake. +AC_DEFUN([_AM_SUBST_NOTMAKE]) + +# Check how to create a tarball. -*- Autoconf -*- + +# Copyright (C) 2004, 2005 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 2 + +# _AM_PROG_TAR(FORMAT) +# -------------------- +# Check how to create a tarball in format FORMAT. +# FORMAT should be one of `v7', `ustar', or `pax'. +# +# Substitute a variable $(am__tar) that is a command +# writing to stdout a FORMAT-tarball containing the directory +# $tardir. +# tardir=directory && $(am__tar) > result.tar +# +# Substitute a variable $(am__untar) that extract such +# a tarball read from stdin. +# $(am__untar) < result.tar +AC_DEFUN([_AM_PROG_TAR], +[# Always define AMTAR for backward compatibility. +AM_MISSING_PROG([AMTAR], [tar]) +m4_if([$1], [v7], + [am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -'], + [m4_case([$1], [ustar],, [pax],, + [m4_fatal([Unknown tar format])]) +AC_MSG_CHECKING([how to create a $1 tar archive]) +# Loop over all known methods to create a tar archive until one works. +_am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none' +_am_tools=${am_cv_prog_tar_$1-$_am_tools} +# Do not fold the above two line into one, because Tru64 sh and +# Solaris sh will not grok spaces in the rhs of `-'. +for _am_tool in $_am_tools +do + case $_am_tool in + gnutar) + for _am_tar in tar gnutar gtar; + do + AM_RUN_LOG([$_am_tar --version]) && break + done + am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"' + am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"' + am__untar="$_am_tar -xf -" + ;; + plaintar) + # Must skip GNU tar: if it does not support --format= it doesn't create + # ustar tarball either. + (tar --version) >/dev/null 2>&1 && continue + am__tar='tar chf - "$$tardir"' + am__tar_='tar chf - "$tardir"' + am__untar='tar xf -' + ;; + pax) + am__tar='pax -L -x $1 -w "$$tardir"' + am__tar_='pax -L -x $1 -w "$tardir"' + am__untar='pax -r' + ;; + cpio) + am__tar='find "$$tardir" -print | cpio -o -H $1 -L' + am__tar_='find "$tardir" -print | cpio -o -H $1 -L' + am__untar='cpio -i -H $1 -d' + ;; + none) + am__tar=false + am__tar_=false + am__untar=false + ;; + esac + + # If the value was cached, stop now. We just wanted to have am__tar + # and am__untar set. + test -n "${am_cv_prog_tar_$1}" && break + + # tar/untar a dummy directory, and stop if the command works + rm -rf conftest.dir + mkdir conftest.dir + echo GrepMe > conftest.dir/file + AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar]) + rm -rf conftest.dir + if test -s conftest.tar; then + AM_RUN_LOG([$am__untar /dev/null 2>&1 && break + fi +done +rm -rf conftest.dir + +AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool]) +AC_MSG_RESULT([$am_cv_prog_tar_$1])]) +AC_SUBST([am__tar]) +AC_SUBST([am__untar]) +]) # _AM_PROG_TAR + +m4_include([m4/ace.m4]) +m4_include([m4/ace_defines.m4]) +m4_include([m4/ace_func.m4]) +m4_include([m4/ace_functions.m4]) +m4_include([m4/ace_headers.m4]) +m4_include([m4/acinclude.m4]) +m4_include([m4/aio.m4]) +m4_include([m4/compiler.m4]) +m4_include([m4/config_h.m4]) +m4_include([m4/pkg.m4]) +m4_include([m4/platform.m4]) +m4_include([m4/subsets.m4]) +m4_include([m4/threads.m4]) +m4_include([m4/tls.m4]) diff --git a/dep/ACE_wrappers/configure.ac b/dep/ACE_wrappers/configure.ac new file mode 100644 index 00000000000..31fa4825f50 --- /dev/null +++ b/dep/ACE_wrappers/configure.ac @@ -0,0 +1,7483 @@ +dnl $Id: configure.ac 82573 2008-08-08 18:13:53Z jtc $ + +dnl An autoconf script to automatically configure ACE. +dnl Process this file with autoconf to produce a configure script. + +dnl Statically (i.e. at autoconf-time) determine the version of ACE. +dnl This is necessary since the version argument to AC_INIT is +dnl supposed to be a static value, not a dynamic one (e.g. a shell +dnl variable). +dnl +dnl Note that this macro removes the newline output by the M4 +dnl "esyscmd" built-in. Unless you understand what you're doing, +dnl particularly with M4, do not modify this macro definition. +define([ACE_VERSION], patsubst(esyscmd(grep ACE_VERSION ace/Version.h | sed 's/.*\" *\(.*\)\".*/\1/'), [ +]))dnl remove newline ending every `esyscmd' answer + +AC_INIT([ACE], + ACE_VERSION, + [ace-bugs@cs.wustl.edu], + [ace]) + +AC_REVISION([$Id: configure.ac 82573 2008-08-08 18:13:53Z jtc $]) + +AC_COPYRIGHT([ACE(TM), TAO(TM), CIAO(TM), and CoSMIC(TM) (henceforth +referred to as "DOC software") are copyrighted by Douglas C. +Schmidt and his research group at Washington University, +University of California, Irvine, and Vanderbilt University, +Copyright (c) 1993-2005, all rights reserved. Since DOC software is +open-source, free software, you are free to use, modify, copy, and +distribute--perpetually and irrevocably--the DOC software source code +and object code produced from the source, as well as copy and +distribute modified versions of this software. You must, however, +include this copyright statement along with code built using DOC +software. + +Please see the file `COPYING' in the top level ACE directory for +additional details.]) + + +dnl Require GNU Autoconf 2.58 or better. Previous versions did not +dnl correctly support HP-UX. +AC_PREREQ([2.58]) + +dnl Autoconf explicitly forbids patterns containing "_AC_". This causes +dnl a problem when using MPC to generate the Automake ".am" files since +dnl the "AC_CLD" project in ACE_wrappers/examples/C++NPv2 ends up having +dnl a Makefile containing "NPv2_AC_CLD" in it, triggering the forbidden +dnl "_AC_" pattern. Explicitly allow our pattern. +m4_pattern_allow([NPv2_AC_CLD]) + +AC_CONFIG_SRCDIR([ace/ACE.cpp]) + +AC_CONFIG_AUX_DIR([aux_config]) +AC_CONFIG_MACRO_DIR([m4]) + +dnl Check what platform we are running on. +AC_CANONICAL_TARGET([]) + +dnl Initialize GNU Automake, and require Automake 1.9.6 or better. +AM_INIT_AUTOMAKE([1.9.6 foreign no-define nostdinc]) + +dnl Add maintainer mode option to the option list. +dnl AM_MAINTAINER_MODE + +dnl The maintainer of this configure script. +ACE_CONFIGURE_MAINTAINER='ace-users@cs.wustl.edu' + + +dnl Until autoconf support in ACE is complete, prevent this script +dnl from running unless the user explictly forces the configure script +dnl to run using the "--enable-maintainer-mode" configure script +dnl option. +dnl if test $USE_MAINTAINER_MODE != yes; then +dnl AC_MSG_ERROR([ +dnl ACE autoconf support is currently disabled by default since it is +dnl still under development. Please use the stock ACE build procedure +dnl detailed in the file \`ACE-INSTALL.html'. +dnl +dnl If you wish to experiment with ACE's autoconf support then use the +dnl \"--enable-maintainer-mode\" configure script option to enable +dnl autoconf support. For more details see the file +dnl \`ACE-configuration.txt'.]) +dnl fi dnl test $USE_MAINTAINER_MODE != yes + +dnl Should we use "egrep" or "grep -E"? This sets the "$EGREP" shell +dnl variable. +AC_PROG_EGREP + +dnl If we are configuring in a CVS controlled directory then don't +dnl continue any further. The idea is to prevent automatically +dnl generated files from being checked into the repository. This +dnl will prevent accidental overwrites of ACE's current Makefiles by +dnl the automatically generated ones, for example. +dnl ACE_CHECK_FOR_CVS_DIR + +dnl Prevent the configure script from continuing any further if +dnl configuration is being performed in the top-level directory. The +dnl idea is to prevent files generated during configuration and build +dnl from overwriting the stock files of the same name. +ACE_CHECK_TOP_SRCDIR + +dnl Prepare the `ace/config.h.in' header template. +ACE_PREP_CONFIG_HEADER + +dnl Allow the standard program name transformations. +dnl We probably don't need AC_ARG_PROGRAM any longer since AM_INIT_AUTOMAKE +dnl handles this functionality. -- Ossama +dnl AC_ARG_PROGRAM + +dnl Generate a header file with all settings. +AC_CONFIG_HEADERS([ace/config.h]) + +dnl Move before the AC_ARG_ENABLE stuff to prevent autoconf complaints. +dnl This is a bit messy but it makes life easier for me. +dnl -Ossama +dnl +dnl SECTION: checks for programs +dnl + +dnl Check if system supports "#! /bin/sh" line in scripts +AC_SYS_INTERPRETER + +dnl Check the C compiler and preprocessor. +dnl AC_PROG_CC +dnl AC_PROG_CPP +dnl AC_PROG_CC_C_O + +dnl Check the C++ compiler and preprocessor. +AC_PROG_CXX +AC_PROG_CXXCPP + +dnl Set the test language as C++ +AC_LANG([C++]) + +dnl If we are cross compiling disable certain things in the Makefiles. +AM_CONDITIONAL([ACE_CROSS_COMPILED], [test X$cross_compiling = Xyes]) + +dnl Look for the best awk-style program available. +AC_PROG_AWK + +dnl Parse the version information argument. +dnl Note that "ACE_VERSION" is an m4 macro. +ace_version_temp=ACE_VERSION +ace_save_ifs="$IFS"; IFS='.' +set dummy $ace_version_temp 0 0 0 +IFS="$ace_save_ifs" + +ACE_MAJOR=$2 +ACE_MINOR=$3 +ACE_BETA=$4 +ACE_VERSION_NAME=ACE_VERSION + +AC_SUBST([ACE_MAJOR]) +AC_SUBST([ACE_MINOR]) +AC_SUBST([ACE_BETA]) +AC_SUBST([ACE_VERSION_NAME]) + +dnl Do the usual install settings; don't forget to include a +dnl `install-sh' script, in case there is no BSD compatible `install' +dnl installed (no pun intended) in your machine. + +dnl We don't need this anymore since AM_INIT_AUTOMAKE calls AC_PROG_INSTALL. +dnl -- Ossama +dnl AC_PROG_INSTALL + +dnl Special handling for some UNIX variants and Cygwin32 +dnl AC_AIX + +dnl AC_MINIX + +case $host_os in + *cygwin* ) CYGWIN=yes;; + * ) CYGWIN=no;; +esac + + +dnl Check if we support symbolic links +AC_PROG_LN_S + +dnl Check if a lexical analyzer exists (lex, flex, etc.) +AM_PROG_LEX + +dnl Check if some implementation of YACC exists (yacc, byacc, bison, etc.) +AC_PROG_YACC +dnl if test -z "$YACC"; then +dnl ./missing yacc +dnl fi + +dnl Check for perfect hash function generator +AC_CHECK_PROG([GPERF],[gperf],[gperf]) + +dnl Check for profiling progam +AC_CHECK_PROGS([PROF],[gprof prof],) + +dnl The user's/default C++ flags are stored in "CXXFLAGS." We use +dnl the variable "ACE_CXXFLAGS" to set the C++ flags we want. At the end +dnl of the configuration process we combine ACE_CXXFLAGS and CXXFLAGS +dnl into CXXFLAGS (e.g., CXXFLAGS="$ACE_CXXFLAGS $CXXFLAGS"). CXXFLAGS +dnl goes after ACE_CXXFLAGS so that the user's C++ flag command line +dnl choices always override the configure script's choices. +ACE_CXXFLAGS="" +ACE_CFLAGS="" + + + +dnl SECTION 2: Configure script command line options + + +dnl Determine which subsets to build +dnl This is done using the autoconf "--enable-foobar" mechanism. +ACE_CHECK_SUBSETS + +dnl Some of the third party libraries (X11, openssl, etc.) depend on +dnl other libraries. Check for those before the processing --enable +dnl options. + +dnl Check if the socket library is available +AC_SEARCH_LIBS([socket],[socket],,,[-lnsl]) + +dnl Check for gethostbyname in -lnsl since some platforms (e.g. Solaris) +dnl put it there. +AC_SEARCH_LIBS([gethostbyname],[nsl],,) + + +dnl Add --{enable,disable,with,without}-feature options. +ACE_CONFIGURATION_OPTIONS +ACE_COMPILATION_OPTIONS + +# Autoconf's AC_OBJEXT and AC_EXEEXT macros only works for C compilers! +# Libtool's setup macro calls AC_OBJEXT and AC_EXEEXT without setting +# the test language to C. We do it before any libtool setup macros are +# called so that the proper values are cached beforehand. We also do +# it before any linker flags (LDFLAGS) are set so that C++ specific +# ones don't break the tests. +dnl AC_LANG_PUSH([C]) +dnl AC_OBJEXT +dnl AC_EXEEXT +dnl AC_LANG_POP([C]) + +dnl Call ACE_SET_COMPILER_FLAGS before AC_PROG_LIBTOOL and after the +dnl AC_ARG_ENABLE and AC_ARG_WITH calls. +ACE_SET_COMPILER_FLAGS + + +dnl SECTION 3: check for programs <--- moved before section 2 (Ossama) + + +dnl Platform specific libraries needed for ACE's autoconf tests +dnl that currently do not have tests themselves. +dnl Platform specific flags +case "$host" in + *osf3.2*) + LIBS="$LIBS -lmach -lsys5 -lcxx -lc" + ;; + *osf4.0* | *osf5.0*) + LIBS="$LIBS -lmach" + ;; + *psos*) + LIBS="$LIBS -lm" + ;; +esac + + +dnl SECTION 4: checks for libraries + + +dnl Additional X library checks +dnl We only check for these libraries if the user has +dnl enabled XtReactor support. + +xt_reactor_go=no + +if test "$ace_user_enable_xt_reactor" = yes; then +XTREACTOR_TEST_XLIBS="" +dnl Check for Motif if we have X + T_LDFLAGS="$LDFLAGS" + LDFLAGS="$LDFLAGS $X_LIBS" + +dnl Note that ACE currently only needs -lX11 and -lXt for the XtReactor +dnl so we define another library variable that contains additional +dnl libraries for the XtReactor test since it needs either Motif or the +dnl Athena widget set. + + AC_CHECK_LIB([Xm],[XmCreateRowColumn], + [ + AC_DEFINE([ACE_HAS_XT]) + XTREACTOR_TEST_XLIBS="-lXm" + xt_reactor_go=yes + ], + [ + AC_DEFINE([ACE_LACKS_MOTIF]) + AC_CHECK_LIB([Xaw],[XawInitializeWidgetSet], + [ + AC_DEFINE([ACE_HAS_XT]) + XTREACTOR_TEST_XLIBS="-lXaw -lXmu" + xt_reactor_go=yes + ], + [ + xt_reactor_go=no + AC_MSG_WARN([No usable X widget libraries were found.]) + AC_MSG_WARN([XtReactor support will be disabled.]) + ],[-lXmu]) + ],[-lXt]) + + AC_SUBST([XTREACTOR_TEST_XLIBS]) + +dnl Restore pre-test linker flags + LDFLAGS="$T_LDFLAGS" + +fi dnl test "$ace_user_enable_xt_reactor"= yes + + AM_CONDITIONAL([COMPILE_XTREACTOR_TEST],[test X$xt_reactor_go = Xyes]) + +dnl End additional X library checks + +dnl Some platforms do not have a dynamic linking library, however the +dnl dlopen, dlclose, etc., functions may exist in the C library. +dnl (e.g. Digital UNIX) +dnl Check for dynamic linking library +AC_SEARCH_LIBS([dlopen],[dl svld],[ace_has_svr4_dynamic_linking=yes], + [ + ace_has_svr4_dynamic_linking=no + AC_CHECK_LIB([dld],[shl_get],,) + ]) + +dnl Check for getservbyname in -lxnet since some platforms (e.g. Solaris) +dnl may put it there. +AC_SEARCH_LIBS([getservbyname],[socket xnet],,[AC_DEFINE([ACE_LACKS_GETSERVBYNAME])],[-lnsl]) + +dnl Check for compile() regex function in -lgen. Solaris, for example, +dnl may put it there. +AC_SEARCH_LIBS([compile],[gen],,) + +dnl Check for exception handling library (e.g. for Digital UNIX) +AC_SEARCH_LIBS([exc_continue],[exc],,) + +dnl Check for ctime_r in -lc_r. Some platforms, such as Digital UNIX, +dnl put reentrant functions such as asctime_r, ctime_r, gmtime_r, and +dnl localtime_r in -lc_r. +AC_SEARCH_LIBS([ctime_r],[c_r],,) + +dnl XTI/TLI check. Check for XTI first, since it's preferred. If there's +dnl no XTI, try for TLI. t_getprotaddr() is only in XTI. +AC_SEARCH_LIBS([t_getprotaddr],[xti nsl], + [ace_has_xti_funcs=yes],[ace_has_xti_funcs=no]) +AS_IF([test "$ace_has_xti_funcs" = no], + [ + AC_SEARCH_LIBS([t_accept],[tli_r tli nsl], + [ace_has_tli_funcs=yes],[ace_has_tli_funcs=no]) + ],[]) + +dnl Check for all of the things we need to compile and link threads +dnl properly. +AS_IF([test "$ace_user_enable_threads" = yes], + [ + ACE_CHECK_THREADS + ],[]) + +dnl Setup Libtool + +dnl This should be done in the "programs" section of this file but +dnl libtool may then be unaware of compiler flags set during the +dnl thread checks. + +dnl Disable building of static libraries by default +AC_DISABLE_STATIC + +dnl Enable Libtool module support +AC_LIBTOOL_DLOPEN + +dnl Enable support for "clean" DLLs. +AC_LIBTOOL_WIN32_DLL + +dnl +dnl ###### Relies on the as of yet unreleased Libtool 1.6 distribuion ### +dnl +dnl Only enable C++ libtool support. Support for other languages is +dnl unnecessary. +dnl AC_LIBTOOL_TAGS([CXX]) + +dnl FIXME: Temporary hack to make libtool work with g++. +dnl Shared library support will only work with GNU g++ and GNU ld +dnl right now. +dnl save_CC="$CC" +dnl CC="$CXX" + +dnl Check for libtool and turn on Automake processing for Libtool +AC_PROG_LIBTOOL + +dnl Enable C++ support in libtool +dnl AC_LIBTOOL_CXX + +dnl Temporary hack until I get integrate libtool's new tag support +dnl into automake. +dnl This hack forces libtool to always use the C++ tag. +dnl LIBTOOL="$LIBTOOL --tag=CXX" + +dnl Check for sched_yield() in posix4 library. +dnl Some platforms, such as Solaris, may define sched_yield() there. +dnl Later we run AC_CHECK_FUNC(sched_yield), which is redundant in this case +dnl but is needed if sched_yield() is defined in one of the other libraries +dnl we check for. +AC_SEARCH_LIBS([sched_yield],[rt posix4],[ace_has_sched_yield=yes],) + +dnl Check for asynchronous IO calls (perform check *after* thread check!) +ACE_CHECK_ASYNCH_IO + +dnl Additional `-lposix4' library check since it may not be added by the +dnl above checks on some platforms that may need it +dnl AC_SEARCH_LIBS([clock_gettime], +dnl [rt posix4],[AC_DEFINE(ACE_HAS_CLOCK_GETTIME)],) + +dnl This check was added to work around a system-supplied header +dnl (/usr/include/netinet/ip.h) that won't compile with Visual Age C++ +dnl unless the _NO_BITFIELDS preprocessor macro is defined. The comments +dnl there recommend use of _NO_BITFIELDS (and recode where needed to allow +dnl that), but we won't just turn it on. Check to see if it's needed. Note +dnl that this check is related to headers but done before we really know if +dnl the header is present. Thus, if the bare compile fails, but succeeds +dnl with _NO_BITFIELDS, set the flag, else leave things alone. + +AC_CACHE_CHECK([to see if _NO_BITFIELDS needed to compile netinet/ip.h], +[ac_cv_needs_no_bitfields], +[ + ace_save_CXXFLAGS="$CXXFLAGS" + + dnl Try compiling without any flags first. + + AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM([ +#include + ], + [ + return 0; + ]) + ], + [ + ac_cv_needs_no_bitfields=no + ], + [ + CXXFLAGS="$CXXFLAGS -D_NO_BITFIELDS" + + AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM([ +#include + ], + [ + return 0; + ]) + ], + [ + ac_cv_needs_no_bitfields=yes + ], + [ + ac_cv_needs_no_bitfields=no + CXXFLAGS="$ace_save_CXXFLAGS" + ]) + ]) +]) + + +dnl SECTION 5: checks for header files + +dnl Set known platform specific flags +ACE_SET_PLATFORM_MACROS + +dnl Check for dirent headers +AC_HEADER_DIRENT + +AS_IF([test "$ac_cv_header_dirent_dirent_h" = yes || + test "$ac_cv_header_dirent_sys_ndir_h" = yes || + test "$ac_cv_header_dirent_sys_dir_h" = yes || + test "$ac_cv_header_dirent_ndir_h" = yes], + [ + AC_DEFINE([ACE_HAS_DIRENT]) + ],[]) + +dnl Check for sys/wait.h Posix.1 compliance +AC_HEADER_SYS_WAIT + +AC_CHECK_HEADER([dlfcn.h], + [ + dnl We already checked for dlopen in the previous library checks however, + dnl it is possible that ac_cv_func_dlopen=yes if dlopen wasn't found before + dnl the library test. Hence we cannot use AC_CHECK_FUNC(dlopen) here + dnl the previously cached value may prevent ACE_HAS_SVR4_DYNAMIC_LINKING + dnl from being defined. + dnl -Ossama + AS_IF([test "$ace_has_svr4_dynamic_linking" = yes], + [ + AC_DEFINE([ACE_HAS_SVR4_DYNAMIC_LINKING]) + + case "$host_os" in + darwin*) + AC_DEFINE([ACE_LD_SEARCH_PATH], + [ACE_LIB_TEXT ("DYLD_LIBRARY_PATH")], + [Define to environment variable used for DLL search path]) + AC_DEFINE([ACE_DLL_SUFFIX], + [ACE_LIB_TEXT (".dylib")], + [Define to DLL file suffix]) + ;; + esac + ],[]) + ],) + +ACE_CHECK_LACKS_HEADERS(inttypes.h malloc.h memory.h stdint.h) + +ACE_CHECK_HAS_HEADERS(bytesex.h) + +AC_CHECK_HEADER([sys/msg.h], + [ + ACE_CACHE_CHECK([if _KERNEL is needed for msg prototypes], + [ace_cv_lib_broken_msg_h], + [ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#ifdef UNIXWARE_7_1 +# define _KMEMUSER +#endif + +#include + ]],[[ + struct msg ace_msg; + ]])],[ + ace_cv_lib_broken_msg_h=no + ],[ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#ifndef _KERNEL +# define _KERNEL +# ifdef UNIXWARE_7_1 +# define _KMEMUSER +# endif +#endif +#include + ]], + [[ + struct msg ace_msg; + ]])], + [ + ace_cv_lib_broken_msg_h=yes + ], + [ + dnl If we get here, then we have no idea if it is broken or not. + ace_cv_lib_broken_msg_h=no + ]) + ]) + ], + [ + AC_DEFINE([ACE_HAS_BROKEN_MSG_H]) + ],) + ], + [AC_DEFINE([ACE_LACKS_SYS_MSG_H])]) + +AC_CHECK_HEADER([sys/sem.h],,) +AC_CHECK_HEADER([sys/shm.h],,) + +ACE_CHECK_LACKS_HEADERS(sys/param.h) + +AC_CHECK_HEADER([sys/priocntl.h],[],[]) + +dnl Check for _before_ +ACE_CHECK_LACKS_HEADERS(ucontext.h) + +AC_CHECK_HEADER([sys/procfs.h], + [ + dnl Check if conflicts with + dnl Some (early?) versions of glibc2.1 define the same variables + dnl in and . + ACE_CACHE_CHECK([if sys/procfs.h conflicts with ucontext.h], + [ace_cv_has_procfs_conflict], + [ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#ifndef ACE_LACKS_UCONTEXT_H +# include +#endif + +#include + ]],[[ + int a = 0; + ]])],[ + ace_cv_has_procfs_conflict=no + ],[ + ace_cv_has_procfs_conflict=yes + ]) + ], + [ + ], + [ + dnl If ace_cv_has_procfs_conflict = no then define ACE_HAS_PROC_FS. + AC_DEFINE([ACE_HAS_PROC_FS]) + ]) + ],) + +ACE_CHECK_LACKS_HEADERS(arpa/inet.h) + +ACE_CHECK_HAS_HEADERS(byteswap.h) + +ACE_CHECK_LACKS_HEADERS(dirent.h) + +ACE_CHECK_LACKS_HEADERS(dlfcn.h) + +ACE_CHECK_LACKS_HEADERS(errno.h) + +ACE_CHECK_LACKS_HEADERS(execinfo.h) + +ACE_CHECK_LACKS_HEADERS(fcntl.h) + +ACE_CHECK_HAS_HEADERS(pdh.h) + +ACE_CHECK_HAS_HEADERS(pthread_np.h) + +ACE_CHECK_LACKS_HEADERS(sched.h) + +ACE_CHECK_LACKS_HEADERS(search.h) + +ACE_CHECK_HAS_HEADERS(select.h) + +ACE_CHECK_LACKS_HEADERS(semaphore.h) + +ACE_CHECK_LACKS_HEADERS(signal.h) + +ACE_CHECK_LACKS_HEADERS(stdlib.h) + +ACE_CHECK_LACKS_HEADERS(string.h) + +ACE_CHECK_LACKS_HEADERS(strings.h) + +ACE_CHECK_LACKS_HEADERS(netdb.h) + +ACE_CHECK_LACKS_HEADERS(netinet/in.h) + +ACE_CHECK_LACKS_HEADERS(netinet/tcp.h) + +ACE_CHECK_LACKS_HEADERS(sys/socket.h) + +ACE_CHECK_LACKS_HEADERS(net/if.h, [], [], +[ +#ifndef ACE_LACKS_SYS_TYPES_H +# include +#endif +#ifndef ACE_LACKS_SYS_SOCKET_H +# include +# endif +]) + +ACE_CHECK_HAS_HEADERS(sys/filio.h) + +ACE_CHECK_HAS_HEADERS(intrin.h) + +ACE_CHECK_HAS_HEADERS(ia64intrin.h) + +ACE_CHECK_HAS_HEADERS(ia32intrin.h) + +ACE_CHECK_LACKS_HEADERS(sys/ioctl.h) + +ACE_CHECK_LACKS_HEADERS(sys/ipc.h) + +ACE_CHECK_HAS_HEADERS(sys/loadavg.h) + +ACE_CHECK_LACKS_HEADERS(sys/mman.h) + +ACE_CHECK_HAS_HEADERS(sys/pstat.h) + +ACE_CHECK_LACKS_HEADERS(sys/resource.h) + +ACE_CHECK_LACKS_HEADERS(sys/sem.h) + +ACE_CHECK_LACKS_HEADERS(sys/shm.h) + +ACE_CHECK_LACKS_HEADERS(sys/select.h) + +ACE_CHECK_HAS_HEADERS(sys/sockio.h) + +ACE_CHECK_LACKS_HEADERS(sys/stat.h) + +dnl Test for out of alphabetical order, since it must +dnl be (conditionally) #included in other feature tests. +ACE_CHECK_LACKS_HEADERS(sys/types.h) + +ACE_CHECK_LACKS_HEADERS(sys/sysctl.h, [], [], +[ +#ifndef ACE_LACKS_SYS_TYPES_H +# include +#endif +#ifndef ACE_LACKS_SYS_PARAM_H +# include +#endif +]) + +ACE_CHECK_HAS_HEADERS(sys/sysinfo.h) + +ACE_CHECK_HAS_HEADERS(sys/systeminfo.h) + +ACE_CHECK_LACKS_HEADERS(sys/time.h) + +ACE_CHECK_LACKS_HEADERS(sys/uio.h) + +ACE_CHECK_LACKS_HEADERS(sys/un.h) + +ACE_CHECK_LACKS_HEADERS(sys/wait.h) + +ACE_CHECK_HAS_HEADERS(sysent.h) + +ACE_CHECK_LACKS_HEADERS(time.h) + +ACE_CHECK_LACKS_HEADERS(termio.h termios.h) + +ACE_CHECK_LACKS_HEADERS(wctype.h) + +AC_CHECK_HEADER([sys/systeminfo.h],[],[]) + +AC_CHECK_TYPE([struct termio], + [AC_DEFINE([ACE_HAS_TERMIO], 1, + [Define to 1 if system supports SysV tty API.])], + [], + [ +#ifndef ACE_LACKS_TERMIO_H +#include +#endif + ]) + +AC_CHECK_TYPE([struct termios], + [AC_DEFINE([ACE_HAS_TERMIOS], 1, + [Define to 1 if system supports POSIX tty API.])], + [], + [ +#ifndef ACE_LACKS_TERMIOS_H +#include +#endif + ]) + +dnl If the platform has XTI, don't bother with the TLI checks as XTI is +dnl preferred. +AS_IF([test "$ace_has_xti_funcs" = yes], + [ + AC_CHECK_HEADER([xti.h], + [ + ace_has_xti=yes + AC_DEFINE([ACE_HAS_XTI]) + ],) + + AC_CHECK_HEADER([sys/xti.h], + [ + ace_has_xti=yes + AC_DEFINE([ACE_HAS_SYS_XTI_H]) + AC_DEFINE([ACE_HAS_XTI]) + ],) + + AC_CHECK_HEADER([sys/timod.h], + [ + AC_DEFINE([ACE_HAS_TIMOD_H]) + ],) + +dnl Check if XTI headers define TCP macros that conflict with netinet/tcp.h's + ACE_CACHE_CHECK([if TCP macros in sys/xti.h conflict with netinet/tcp.h], + [ace_cv_lib_has_conflicting_xti_macros], + [ + ACE_CONVERT_WARNINGS_TO_ERRORS([ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +# if defined (ACE_HAS_XTI) +# include +# if defined (ACE_HAS_SYS_XTI_H) +# include /**/ +# else +# include /**/ +# endif /* ACE_HAS_SYS_XTI_H */ +# else +# if defined (ACE_HAS_TIUSER_H) +# include /**/ +# endif +# endif /* ACE_HAS_XTI */ +# if !defined (ACE_LACKS_NETINET_TCP_H) +# include /**/ +# endif /* !ACE_LACKS_NETIINET_TCP_H */ + ]],[[ + int a = 0; + ]])],[ + ace_cv_lib_has_conflicting_xti_macros=no + ],[ + ace_cv_lib_has_conflicting_xti_macros=yes + ]) + ]) + ], + [ + AC_DEFINE([ACE_HAS_CONFLICTING_XTI_MACROS]) + ],) + + ],[]) + +AS_IF([test "$ace_has_tli_funcs" = yes], + [ + AC_CHECK_HEADER([tiuser.h], + [ + ace_has_tli=yes + AC_DEFINE([ACE_HAS_TIUSER_H]) + AC_DEFINE([ACE_HAS_TLI]) + ],) + + AC_CHECK_HEADER([sys/timod.h], + [ + AC_DEFINE([ACE_HAS_TIMOD_H]) + ], + [ + AC_CHECK_HEADER([tli/timod.h], + [ + AC_DEFINE([ACE_HAS_OSF_TIMOD_H]) + ],) + ]) + + AC_CHECK_FUNC([t_getname], + [AC_DEFINE([ACE_HAS_SVR4_TLI])],) + + +if test "$ac_cv_header_tiuser_h" = yes; then + ACE_CACHE_CHECK([if tiuser.h is protected by extern "C"], + [ace_cv_lib_tiuser_with_extern_c],[ + AC_EGREP_HEADER([extern \"C\"],[tiuser.h], + [ + ace_cv_lib_tiuser_with_extern_c=yes + ], + [ + ace_cv_lib_tiuser_with_extern_c=no + ]) + ],,[AC_DEFINE([ACE_HAS_TIUSER_H_BROKEN_EXTERN_C])]) +fi dnl test "$ac_cv_header_tiuser_h" = yes + +AC_CHECK_HEADER([xliuser.h], + [ + ace_has_tli=yes + AC_DEFINE([ACE_HAS_XLI]) + AC_DEFINE([ACE_HAS_TLI]) + ],) + + +dnl Check for TLI prototypes. +if test "$ace_has_tli" = yes; then + ACE_CACHE_CHECK([for TLI prototypes], + [ace_cv_lib_tli_prototypes], + [ +dnl We only check for t_accept. This should hopefully be enough. + AC_EGREP_CPP([t_accept], + [ +#ifndef ACE_LACKS_SYS_TYPES_H +# include +#endif + +#if defined (ACE_HAS_TIMOD_H) +# include +#endif + +#if defined (ACE_HAS_OSF_TIMOD_H) +# include +#endif + +#if defined (ACE_HAS_TIUSER_H) +# include /**/ +#endif /* ACE_HAS_TIUSER_H */ + +#if defined (ACE_HAS_XLI) +# include +#endif + ], + [ + ace_cv_lib_tli_prototypes=yes + ], + [ + ace_cv_lib_tli_prototypes=no + ]) + ],[AC_DEFINE([ACE_HAS_TLI_PROTOTYPES])],) + +dnl Check for t_errno type in TLI headers + ACE_CACHE_CHECK([for t_errno in TLI headers], + [ace_cv_lib_has_t_errno], + [ + dnl Check if t_errno is declared in the TLI headers + AC_EGREP_CPP([t_errno], + [ +#ifndef ACE_LACKS_SYS_TYPES_H +# include +#endif + +#if defined (ACE_HAS_TIMOD_H) +# include +#endif + +#if defined (ACE_HAS_OSF_TIMOD_H) +# include +#endif + +#if defined (ACE_HAS_TIUSER_H) +# include /**/ +#endif /* ACE_HAS_TIUSER_H */ + +#if defined (ACE_HAS_XLI) +# include +#endif + ], + [ + ace_cv_lib_has_t_errno=yes + ], + [ + ace_cv_lib_has_t_errno=no + ]) + ],,[AC_DEFINE([ACE_LACKS_T_ERRNO])]) + +fi dnl test "$ace_has_tli_funcs" = yes +],[]) + +dnl These checks are needed for both XTI and TLI. +AS_IF([test "$ace_has_xti" = yes || test "$ace_has_tli" = yes], + [ + dnl Check if t_error incorrectly accepts char * + ACE_CONVERT_WARNINGS_TO_ERRORS([ + ACE_CACHE_CHECK([if t_error incorrectly accepts char *], + [ace_cv_lib_has_broken_t_error], + [ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#ifndef ACE_LACKS_SYS_TYPES_H +# include +#endif + +#if defined (ACE_HAS_XTI) +# if defined (ACE_HAS_SYS_XTI_H) +# include +# else +# include +# endif /* ACE_HAS_SYS_XTI_H */ +#elif defined (ACE_HAS_TIUSER_H) +# include /**/ +#endif /* ACE_HAS_TIUSER_H */ + +#if defined (ACE_HAS_XLI) +# include +#endif + ]],[[ + const char *ace_errmsg = "FOO"; + t_error (ace_errmsg); + ]])],[ + ace_cv_lib_has_broken_t_error=no + ],[ + ace_cv_lib_has_broken_t_error=yes + ]) + ], + [ + AC_DEFINE([ACE_HAS_BROKEN_T_ERROR]) + ],) + ]) dnl ACE_CONVERT_WARNINGS_TO_ERRORS + + ],[]) + +dnl See the notes about ACE_LACKS_MMAP in the functions section of this +dnl configure script. +dnl -Ossama +AC_CHECK_HEADER([sys/mman.h], + [ + AC_EGREP_HEADER([extern \"C\"],[sys/mman.h], + , + [ + AC_DEFINE([ACE_HAS_BROKEN_MMAP_H]) + ]) + ], + [ + AC_DEFINE([ACE_LACKS_MMAP]) + ]) + +dnl Check for bzero() prototype if bstring.h exists. +AC_CHECK_HEADER([bstring.h], + [ + AC_EGREP_HEADER([bzero],[bstring.h], + [ + AC_DEFINE([ACE_HAS_BSTRING]) + ],) + ],) + +AC_CHECK_HEADER([strings.h], + [ + AC_EGREP_HEADER([bzero],[strings.h], + [ + AC_DEFINE([ACE_HAS_STRINGS]) + ],) + ],) + +ACE_CHECK_HAS_HEADERS(sys/syscall.h) + +AC_CHECK_HEADER([poll.h], + [AC_DEFINE([ACE_HAS_POLL])],) + +ACE_CHECK_LACKS_HEADERS(pwd.h) + +AC_CHECK_HEADER([regexpr.h], + [AC_DEFINE([ACE_HAS_REGEX])],) + +AC_CHECK_HEADER([stropts.h], + [AC_DEFINE([ACE_HAS_STREAMS])], + [AC_DEFINE([ACE_LACKS_STROPTS_H])]) + +ACE_CHECK_LACKS_HEADERS(siginfo.h) + +ACE_CHECK_LACKS_HEADERS(unistd.h) + +ACE_CHECK_LACKS_HEADERS(utime.h) + +ACE_CHECK_LACKS_HEADERS(wchar.h) + +AC_CHECK_HEADER([wchar.h], + [AC_DEFINE([ACE_HAS_WCHAR])],) + +AC_CHECK_HEADER([new], + [AC_DEFINE([ACE_HAS_NEW_NO_H])], + [ + ACE_CHECK_HAS_HEADERS([new.h]) + ]) + +dnl ace/OS.i can #include ,not #include +dnl "cstring" is the correct form. +dnl TODO: Double check the above comment. +AC_CHECK_HEADER([cstring], + [AC_DEFINE([ACE_HAS_GNU_CSTRING_H])],) + +AC_CHECK_HEADER([memory],,) + +dnl Check for availablity of "new style" C++ stream headers +AC_CHECK_HEADERS([iomanip ios iostream istream ostream fstream streambuf], + , + [AC_CHECK_HEADERS([iostream.h fstream.h], + [AC_DEFINE([ACE_USES_OLD_IOSTREAMS])], + [AC_DEFINE([ACE_LACKS_IOSTREAM_TOTALLY])])]) + +dnl Check for old malloc() prototype. +ACE_CONVERT_WARNINGS_TO_ERRORS([ +ACE_CACHE_CHECK([for old malloc() prototype], + [ace_cv_lib_old_malloc_proto], + [ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#include +#ifndef ACE_LACKS_MALLOC_H +# include +#endif + ]],[[ + char *s = 0; + s = malloc(sizeof(int)); + ]])],[ + ace_cv_lib_old_malloc_proto=yes + ],[ + ace_cv_lib_old_malloc_proto=no + ]) + ],[AC_DEFINE([ACE_HAS_OLD_MALLOC])],) +]) dnl ACE_CONVERT_WARNINGS_TO_ERRORS + + +dnl Check for *_timedwait() prototypes +dnl TODO: We only check for one of the *_timedwait() prototypes. +dnl Is this enough? +AC_CHECK_DECL([recv_timedwait], + [], + [AC_DEFINE([ACE_LACKS_TIMEDWAIT_PROTOTYPES], 1, + [Define to 1 if platform lacks the declarations + of recv_timedwait, send_timedwait, etc.])], + [#include + #include ]) + +dnl Check for {get,set}rlimit prototypes +AC_CHECK_DECL([getrlimit],[],[],[#include ]) +AC_CHECK_DECL([setrlimit],[],[],[#include ]) +if test "$ac_cv_have_decl_getrlimit" != yes || + test "$ac_cv_have_decl_setrlimit" != yes; then + AC_DEFINE([ACE_LACKS_RLIMIT_PROTOTYPE], 1, + [Define to 1 if platform lacks the declaration of + {get,set}rlimit().]) +fi + + +dnl SECTION 6: Checks for typedefs + +dnl dnl Standard typedef checks (All of them may not be needed) +dnl AC_TYPE_UID_T +dnl AC_TYPE_MODE_T +dnl AC_TYPE_OFF_T +dnl AC_TYPE_PID_T +dnl AC_TYPE_SIZE_T + +dnl AC_CHECK_TYPE([off64_t],[long long]) + +dnl Specific typedef checks +dnl TODO: Check whether these typedefs can be defined somewhere else. +AC_CHECK_TYPE([cpu_set_t], + [AC_DEFINE([ACE_HAS_CPU_SET_T], 1, + [Define to 1 if the system has the type `cpu_set_t'.])], + [], + [ +#if !defined(ACE_LACKS_SCHED_H) +#include +#endif + ]) + +AC_CHECK_TYPE([idtype_t], + [AC_DEFINE([ACE_HAS_IDTYPE_T], 1, + [Define to 1 if the system has the type `idtype_t'.])], + [], + [#include ]) + +AC_CHECK_TYPE([key_t], + [], + [AC_DEFINE([ACE_LACKS_KEY_T], 1, + [Define to 1 if the system lacks the type `key_t'.])], + [#include ]) + +ACE_CHECK_TYPE([sem_t],[semaphore.h],,) + +AC_CHECK_TYPE([pri_t], + [], + [AC_DEFINE([ACE_LACKS_PRI_T], 1, + [Define to 1 if the system lacks the type 'pri_t'.])], + [#include ]) + +AC_CHECK_TYPE([sig_atomic_t], + [AC_DEFINE([ACE_HAS_SIG_ATOMIC_T], 1, + [Define to 1 if the system has the type 'sig_atomic_t'.])], + [], + [#include ]) + +AC_CHECK_TYPE([union sigval], + [], + [], + [#include ]) + +if test "$ac_cv_type_union_sigval" = yes; then + dnl Depending on the system, the field names of union sigval have + dnl either a sival_ (POSIX) or sigval_ (older versions of FreeBSD) + dnl prefix. Define ACE_HAS_SIGVAL_SIGVAL_INT accordingly. + AC_CHECK_MEMBER([union sigval.sigval_int], + [AC_DEFINE([ACE_HAS_SIGVAL_SIGVAL_INT], 1, + [Define to 1 if `sigval_int' is a member of `union sigval'.])], + [], + [#include ]) + + dnl Depending on the system, the field names of union sigval have + dnl either a sival_ (POSIX) or sigval_ (older versions of FreeBSD) + dnl prefix. Define ACE_HAS_SIGVAL_SIGVAL_PTR accordingly. + AC_CHECK_MEMBER([union sigval.sigval_ptr], + [AC_DEFINE([ACE_HAS_SIGVAL_SIGVAL_PTR], 1, + [Define to 1 if `sigval_ptr' is a member of `union sigval'.])], + [], + [#include ]) +fi + +AC_CHECK_TYPE([ssize_t], + [AC_DEFINE([ACE_HAS_SSIZE_T], 1, + [Define to 1 if the system has the type `ssize_t'.])], + [], + [#include ]) + +AC_CHECK_TYPE([suseconds_t], + [], + [AC_DEFINE([ACE_LACKS_SUSECONDS_T], 1, + [Define to 1 if the system lacks the type 'suseconds_t'.])], + [#include ]) + +AC_CHECK_TYPE([useconds_t], + [], + [AC_DEFINE([ACE_LACKS_USECONDS_T], 1, + [Define to 1 if the system lacks the type 'useconds_t'.])], + [#include ]) + + +dnl Some platforms define ucontext_t in , but ACE +dnl doesn't explicitly include that header. However, it is very +dnl likely that does, either directly or indirectly. +AC_CHECK_TYPE([ucontext_t], + [AC_DEFINE([ACE_HAS_UCONTEXT_T], 1, + [Define to 1 if the system has the type `ucontext_t'.])], + [], +[#include +#ifndef ACE_LACKS_UCONTEXT_H +# include +#endif +]) + +AC_CHECK_TYPE([u_longlong_t], + [], + [AC_DEFINE([ACE_LACKS_U_LONGLONG_T], 1, + [Define to 1 if the system lacks the type `u_long_long_t'.])], + [#include ]) + +AC_CHECK_TYPE([wchar_t], + [], + [AC_DEFINE([ACE_LACKS_WCHAR_T], 1, + [Define to 1 if the system lacks the type `wchar_t'.])], +[#include +#include +]) + +AC_CHECK_TYPE([socklen_t], + [AC_DEFINE([ACE_HAS_SOCKLEN_T], 1, + [Define to 1 if the system has the type `socklen_t'.])], + [], +[ +#ifndef ACE_LACKS_SYS_TYPES_H +#include +#endif +#ifndef ACE_LACKS_SYS_SOCKET_H +#include +#endif +]) + +if test $ac_cv_type_socklen_t = no; then + dnl The compiler in linux just issues a warning, and the test + dnl passes!!! + + dnl FIXED by adding "-Werror" to compiler flags when using GNU C++ + dnl -Ossama + ACE_CONVERT_WARNINGS_TO_ERRORS( + [ + dnl Check if socket size is denoted by size_t + ACE_CACHE_CHECK([if socket size is denoted by size_t], + [ace_cv_lib_posix_socket_len_size_t],[ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#ifndef ACE_LACKS_SYS_TYPES_H +# include +#endif +#ifndef ACE_LACKS_SYS_SOCKET_H +# include +#endif + ]],[[ + int s = 0; + struct sockaddr* addr = 0; + int* addrlen = 0; + accept(s, addr, addrlen); + ]])],[ + ace_cv_lib_posix_socket_len_size_t=no + ],[ + dnl Now see if it really does take a size_t socket size + AC_COMPILE_IFELSE([AC_LANG_PROGRAM( + [[ +#ifndef ACE_LACKS_SYS_TYPES_H +# include +#endif +#ifndef ACE_LACKS_SYS_SOCKET_H +# include +#endif + ]], + [[ + int s = 0; + struct sockaddr* addr = 0; + size_t* addrlen = 0; + accept(s, addr, addrlen); + ]])], + [ + ace_cv_lib_posix_socket_len_size_t=yes + ], + [ + ace_cv_lib_posix_socket_len_size_t=no + ]) + ]) + ],[AC_DEFINE([ACE_HAS_SIZET_SOCKET_LEN])],) + ]) +fi + + +dnl SECTION 7: checks for structures + + +dnl TODO: Check whether these structures can be defined somewhere else. +ACE_CHECK_STRUCT([dirent],[dirent.h],,[AC_DEFINE([ACE_LACKS_STRUCT_DIR])]) +ACE_CHECK_STRUCT([flock],[fcntl.h],,[AC_DEFINE([ACE_LACKS_FILELOCKS])]) +ACE_CHECK_STRUCT([rwlock_t],[synch.h],,[AC_DEFINE([ACE_LACKS_RWLOCK_T])]) +ACE_CHECK_STRUCT([strbuf],[stropts.h],[AC_DEFINE([ACE_HAS_STRBUF_T])],) +case "$host" in +*irix*) + dnl IRIX prusage fields don't match what ACE currently supports. + ;; +*) + ACE_CHECK_STRUCT([prusage_t],[sys/procfs.h],[AC_DEFINE([ACE_HAS_PRUSAGE_T])],) + ;; +esac +ACE_CHECK_STRUCT([strrecvfd],[stropts.h],,[AC_DEFINE([ACE_LACKS_STRRECVFD])]) +ACE_CHECK_STRUCT([sigaction],[signal.h],,[AC_DEFINE([ACE_LACKS_SIGACTION])]) +ACE_CHECK_STRUCT([sigset_t],[signal.h],,[AC_DEFINE([ACE_LACKS_SIGSET])]) +ACE_CHECK_STRUCT([utsname],[sys/utsname.h],,[AC_DEFINE([ACE_LACKS_UTSNAME_T])]) + +ACE_CACHE_CHECK([for struct sembuf],[ace_cv_struct_sembuf], + [ + dnl Some platforms may need to include some headers before . + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#ifndef ACE_LACKS_SYS_TYPES_H +# include +#endif +#include +#include + ]],[[ + struct sembuf ace_sembuf; + ]])],[ + ace_cv_struct_sembuf=yes + ],[ +dnl Some compilers don't like the "struct" but we need the struct for +dnl some platforms to resolve ambiguities between functions and +dnl structures with with the same name. So, we try the same test but +dnl without "struct" if the above test with "struct" fails. If both +dnl tests fail, then we can be reasonably sure that we don't have the +dnl structure we are testing for. + AC_COMPILE_IFELSE([AC_LANG_PROGRAM( + [[ +#ifndef ACE_LACKS_SYS_TYPES_H +# include +#endif +#include +#include + ]], + [[ + sembuf ace_sembuf; + ]])], + [ + ace_cv_struct_sembuf=yes + ], + [ + ace_cv_struct_sembuf=no + ]) + ]) + ],,[AC_DEFINE([ACE_LACKS_SEMBUF_T])]) + +dnl Thanks to Konstantinos Margaritis for pointing out +dnl that struct siginfo_t may also be defined in signal.h +AC_CHECK_TYPE([siginfo_t], + [AC_DEFINE([ACE_HAS_SIGINFO_T], 1, + [Define to 1 if the system has the type `siginfo_t'.])], + [], + [#include +#ifndef ACE_LACKS_SIGINFO_H +#include +#endif]) + +if test "$ac_cv_type_siginfo_t" = yes; then + AC_CHECK_MEMBER([siginfo_t.si_addr], + [], + [AC_DEFINE([ACE_LACKS_SI_ADDR], 1, + [Define to 1 if `si_addr' is not a member of `siginfo_t'.])], + [#include +#ifndef ACE_LACKS_SIGINFO_H +#include +#endif]) +fi + + +dnl Some platforms need to include sys/types.h before sys/socket.h +dnl in order for struct msghdr to work. +dnl Check for msghdr structure. +ACE_CACHE_CHECK([for struct msghdr],[ace_cv_struct_msghdr], + [ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#ifndef ACE_LACKS_SYS_TYPES_H +# include +#endif +#include + ]],[[ + struct msghdr ace_msghdr; + ]])],[ + ace_cv_struct_msghdr=yes + ],[ + ace_cv_struct_msghdr=no + ]) + ], [AC_DEFINE([ACE_HAS_MSG])],) + +ACE_CACHE_CHECK([for condition variable support],[ace_cv_struct_cond_t], + [ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#include + ]],[[ + pthread_cond_t ace_pthread_cond_t; + ]])],[ + ace_cv_struct_cond_t=yes + ],[ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM( + [[ +#include + ]], + [[ + cond_t ace_cond_t; + ]])], + [ + ace_cv_struct_cond_t=yes + ], + [ + ace_cv_struct_cond_t=no + ]) + ]) + ],,[AC_DEFINE([ACE_LACKS_COND_T])]) + +dnl Check for struct timespec +ACE_CACHE_CHECK([for POSIX timer structure], + [ace_cv_lib_posix_timer_struct], + [ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#if !defined(ACE_LACKS_SYS_TIME_H) +# include +#endif +#include + ]],[[ + timespec sr; + ]])],[ + ace_cv_lib_posix_timer_struct=yes + ],[ + dnl Check if platform uses struct timestruc_t for POSIX timers + dnl instead of struct timespec. + AC_COMPILE_IFELSE([AC_LANG_PROGRAM( + [[ +#include + ]], + [[ + timestruc_t sr; + ]])], + [ + ace_cv_lib_posix_timer_struct=yes + dnl Check for struct timespec in + ACE_CACHE_CHECK([for struct timespec in sys/timers.h], + [ace_cv_lib_posix_struct_timespec_broken],[ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM( + [[ +#include + ]], + [[ + timespec sr; + ]])], + [ + ace_cv_lib_posix_struct_timespec_broken=yes + ], + [ + ace_cv_lib_posix_struct_timespec_broken=no + ]) + ],,) + ], + [ + ace_cv_lib_posix_timer_struct=no + ]) + ]) + ], + [ + AC_DEFINE([ACE_HAS_POSIX_TIME]) + if test "$ace_cv_lib_posix_struct_timespec_broken" = yes; then + AC_DEFINE([ACE_HAS_BROKEN_POSIX_TIME]) + fi + ], + [ + dnl Check for struct timespec in + ACE_CACHE_CHECK([for struct timespec in sys/timers.h], + [ace_cv_lib_posix_struct_timespec_broken],[ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#include + ]],[[ + timespec sr; + ]])],[ + ace_cv_lib_posix_struct_timespec_broken=yes + ],[ + ace_cv_lib_posix_struct_timespec_broken=no + ]) + ],[AC_DEFINE([ACE_HAS_BROKEN_POSIX_TIME])],) + ]) + +dnl Check for typedef timespec_t +dnl TODO: Check whether this typedef can be defined somewhere else. +ACE_CACHE_CHECK([for timespec_t], + [ace_cv_lib_posix_timespec_t],[ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#include + ]],[[ + timespec_t tt; + ]])],[ + ace_cv_lib_posix_timespec_t=yes + ],[ + ace_cv_lib_posix_timespec_t=no + ]) +],,[AC_DEFINE([ACE_LACKS_TIMESPEC_T])]) + +dnl Check for union semun +ACE_CACHE_CHECK([for union semun], + [ace_cv_lib_posix_defines_union_semun],[ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#ifndef ACE_LACKS_SYS_TYPES_H +# include +#endif +#include + ]],[[ +/* We could also check if the macro _SEM_SEMUN_UNDEFINED is defined. + No big deal. */ + +semun us; + ]])],[ + ace_cv_lib_posix_defines_union_semun=yes + ],[ + ace_cv_lib_posix_defines_union_semun=no + ]) +],[AC_DEFINE([ACE_HAS_SEMUN])],) + + + +dnl SECTION 8: checks for variables + +dnl Check for more than two fields in struct rusage +ACE_CACHE_CHECK([for limited struct rusage], + [ace_cv_lib_limited_rusage],[ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#include +#include + ]],[[ + rusage ace_rusage; + /* + We just pick three (i.e. > 2) of the fields that + ACE uses to see if we have a struct rusage that + has more than two fields. + */ + ace_rusage.ru_ixrss = 0; + ace_rusage.ru_idrss = 0; + ace_rusage.ru_isrss = 0; + ]])],[ + ace_cv_lib_limited_rusage=no + ],[ + ace_cv_lib_limited_rusage=yes + ]) +],[AC_DEFINE([ACE_HAS_LIMITED_RUSAGE_T])],) + +if test "$ace_cv_struct_siginfo_t" = yes; then + dnl Check for si_addr member in struct siginfo_t + ACE_CACHE_CHECK([for si_addr member in struct siginfo_t], + [ace_cv_lib_posix_si_addr],[ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#ifndef ACE_LACKS_SIGINFO_H +# include +#endif +#include + ]],[[ + siginfo_t acesig; + acesig.si_addr = 0; + ]])],[ + ace_cv_lib_posix_si_addr=yes + ],[ + ace_cv_lib_posix_si_addr=no + ]) + ],,[AC_DEFINE([ACE_LACKS_SI_ADDR])]) +fi dnl test "$ace_cv_struct_siginfo_t" = yes + +dnl Check for sin_len member in struct sockaddr_in +AC_CHECK_MEMBER([struct sockaddr_in.sin_len], + [AC_DEFINE([ACE_HAS_SOCKADDR_IN_SIN_LEN], 1, + [Define to 1 if `sin_len' is a member of `sockaddr_in'.])], + [], + [ +#ifndef ACE_LACKS_SYS_TYPES_H +# include +#endif +#include +#include + ]) + +dnl Check for sin6_len member in struct sockaddr_in6 +AC_CHECK_MEMBER([struct sockaddr_in6.sin6_len], + [AC_DEFINE([ACE_HAS_SOCKADDR_IN6_SIN6_LEN], 1, + [Define to 1 if `sin6_len' is a member of `sockaddr_in6'.])], + [], + [ +#ifndef ACE_LACKS_SYS_TYPES_H +# include +#endif +#include +#include + ]) + +dnl Check for sys_siglist +dnl TODO: Check whether this variable can be defined somewhere else. +dnl [OSSAMA: Should we use autoconf's AC_CHECK_DECLS([sys_siglist]) +dnl test instead?] +ACE_CACHE_CHECK([for sys_siglist], + [ace_cv_lib_posix_sys_siglist],[ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#ifndef ACE_LACKS_UNISTD_H +# include +#endif +#include +#if !defined (_sys_siglist) +# define _sys_siglist sys_siglist +#endif + ]],[[ + void* vp = (void*) &_sys_siglist; + ]])],[ + ace_cv_lib_posix_sys_siglist=yes + ],[ + ace_cv_lib_posix_sys_siglist=no + ]) +],[AC_DEFINE([ACE_HAS_SYS_SIGLIST])],) + +dnl Check for sys_errlist +dnl TODO: Check whether this variable can be defined somewhere else. +ACE_CACHE_CHECK([for sys_errlist], + [ace_cv_lib_posix_sys_errlist],[ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#include +#include +#if !defined (_sys_errlist) +# define _sys_errlist sys_errlist +#endif + ]],[[ + void* vp = (void*) &_sys_errlist; + ]])],[ + ace_cv_lib_posix_sys_errlist=yes + ],[ + dnl Check if sys_errlist is a global variable in a library + AC_LINK_IFELSE([AC_LANG_PROGRAM( + [[ +#include +#include + +#if !defined (_sys_errlist) +# define _sys_errlist sys_errlist +#endif + +extern const char * const _sys_errlist[]; + ]], + [[ + void* vp = (void*) &_sys_errlist; + ]])], + [ + ace_cv_lib_posix_sys_errlist=yes + ], + [ + ace_cv_lib_posix_sys_errlist=no + ]) + ]) + ],[AC_DEFINE([ACE_HAS_SYS_ERRLIST])],) + +dnl Save the cache for debugging purposes +AC_CACHE_SAVE + + +dnl SECTION 9: checks for compiler characteristics + + +dnl Check if compiler accepts "#pragma once" directive +ACE_CONVERT_WARNINGS_TO_ERRORS([ + ACE_CACHE_CHECK([if compiler accepts "pragma once" directive], + [ace_cv_has_pragma_once], + [ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#pragma once + ]],[[ + int a = 0; /* Put this here so we don't have an empty main(). */ + ]])],[ + ace_cv_has_pragma_once=yes + ],[ + ace_cv_has_pragma_once=no + ]) + ],,[AC_DEFINE([ACE_LACKS_PRAGMA_ONCE])]) +]) dnl ACE_CONVERT_WARNINGS_TO_ERRORS + +dnl If we are using GNU C++, see if it accepts the -pipe compiler flag. +dnl "-pipe" on cygwin32 doesn't seem to work, for example. +if test "$GXX" = yes; then + PREPIPECXXFLAGS="$CXXFLAGS" + CXXFLAGS="$CXXFLAGS -pipe" + PREPIPECFLAGS="$CFLAGS" + CFLAGS="$CFLAGS -pipe" + ACE_CACHE_CHECK([if "-pipe" compiler flag is supported], + [ace_cv_feature_gxx_has_pipe], + [ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]],[[int a = 0;]])],[ + ace_cv_feature_gxx_has_pipe=yes + ],[ + ace_cv_feature_gxx_has_pipe=no + ]) + ], + [ + dnl We don't need to add "-pipe" here since it was already added + dnl for the test. + dnl CXXFLAGS="$PREPIPECXXFLAGS -pipe" + dnl CFLAGS="$PREPIPECFLAGS -pipe" + ], + [ + CXXFLAGS="$PREPIPECXXFLAGS" + CFLAGS="$PREPIPECFLAGS" + ]) +fi + +dnl Check to see if we are running on a big endian platform +dnl "ace/Basic_Types.h" should perhaps be modified to take advantage +dnl of the results of this test. +dnl Do not run this test if we are using a cross-compiler. +AS_IF([test "$cross_compiling" != yes], + [ + AC_C_BIGENDIAN + ],[]) + +dnl Check type sizes +dnl If we get a size of zero, then the type is unknown to the compiler. + +dnl We don't need to check for sizeof(char) right now. Also conflicts with +dnl ACE definition in Basic_Types.h, so we leave the test out. +if test "$cross_compiling" != yes; then + AC_CHECK_SIZEOF([wchar_t]) + if test "$ac_cv_sizeof_wchar_t" != 0; then + AC_DEFINE_UNQUOTED([ACE_SIZEOF_WCHAR],[$ac_cv_sizeof_wchar_t], + [Size of the native "wchar_t" type]) + fi + AC_CHECK_SIZEOF([short]) + if test "$ac_cv_sizeof_short" != 0; then + AC_DEFINE_UNQUOTED([ACE_SIZEOF_SHORT],[$ac_cv_sizeof_short], + [Size of the native "short" type]) + fi + AC_CHECK_SIZEOF([int]) + if test $ac_cv_sizeof_int != 0; then + AC_DEFINE_UNQUOTED([ACE_SIZEOF_INT],[$ac_cv_sizeof_int], + [Size of the native "int" type]) + fi + AC_CHECK_SIZEOF([long]) + if test $ac_cv_sizeof_long != 0; then + AC_DEFINE_UNQUOTED([ACE_SIZEOF_LONG],[$ac_cv_sizeof_long], + [Size of the native "long" type]) + fi + AC_CHECK_SIZEOF([long long]) + if test $ac_cv_sizeof_long_long != 0; then + AC_DEFINE_UNQUOTED([ACE_SIZEOF_LONG_LONG],[$ac_cv_sizeof_long_long], + [Size of the native "long long" type]) + else + AC_DEFINE([ACE_LACKS_LONGLONG_T]) + fi + AC_CHECK_SIZEOF([void *]) + if test $ac_cv_sizeof_void_p != 0; then + AC_DEFINE_UNQUOTED([ACE_SIZEOF_VOID_P],[$ac_cv_sizeof_void_p], + [Size of the native "pointer to void" type]) + fi + AC_CHECK_SIZEOF([float]) + if test $ac_cv_sizeof_float != 0; then + AC_DEFINE_UNQUOTED([ACE_SIZEOF_FLOAT],[$ac_cv_sizeof_float], + [Size of the native "float" type]) + fi + AC_CHECK_SIZEOF([double]) + if test $ac_cv_sizeof_double != 0; then + AC_DEFINE_UNQUOTED([ACE_SIZEOF_DOUBLE],[$ac_cv_sizeof_double], + [Size of the native "double" type]) + fi + AC_CHECK_SIZEOF([long double]) + if test $ac_cv_sizeof_long_double != 0; then + AC_DEFINE_UNQUOTED([ACE_SIZEOF_LONG_DOUBLE],[$ac_cv_sizeof_long_double], + [Size of the native "long double" type]) + fi + + dnl Set the 64 bit typedefs + ACE_INT64="" + ACE_UINT64="" + dnl if test "$ace_cv_type_u_longlong_t" = yes; then + dnl This doesn't work: AC_CHECK_SIZEOF([u_longlong_t],[8]) + dnl if test $ac_cv_sizeof_u_longlong_t = 8; then + dnl ACE_UINT64="u_longlong_t" + dnl ace_u_long_long_typedef_set=yes + dnl fi + dnl elif test $ac_cv_sizeof_long = 8; then + if test $ac_cv_sizeof_long = 8; then + ACE_INT64="signed long" + ACE_UINT64="unsigned long" + ace_u_long_long_typedef_set=yes + elif test $ac_cv_sizeof_long_long = 8; then + ACE_INT64="signed long long" + ACE_UINT64="unsigned long long" + ace_u_long_long_typedef_set=yes + else + ace_u_long_long_typedef_set=no + fi + + dnl Check for broken "signed char" + dnl If AC_CHECK_SIZEOF(signed char) returns zero then "signed char" + dnl is broken. + AC_CHECK_SIZEOF([signed char],[1]) + if test $ac_cv_sizeof_signed_char = 0; then + AC_DEFINE([ACE_LACKS_SIGNED_CHAR]) + fi +else + ace_u_long_long_typedef_set=no +fi dnl test "$cross_compiling" != yes + +AC_CHECK_TYPE([intmax_t], + [], + [AC_DEFINE([ACE_LACKS_INTMAX_T], 1, + [Define to 1 if the system lacks the type `intmax_t'.])], + [ +#ifndef ACE_LACKS_STDINT_H +#include +#endif +#ifndef ACE_LACKS_INTTYPES_H +#include +#endif]) + +AC_CHECK_TYPE([uintmax_t], + [], + [AC_DEFINE([ACE_LACKS_UINTMAX_T], 1, + [Define to 1 if the system lacks the type `uintmax_t'.])], + [ +#ifndef ACE_LACKS_STDINT_H +#include +#endif +#ifndef ACE_LACKS_INTTYPES_H +#include +#endif]) + +AC_CHECK_TYPE([intptr_t], + [], + [AC_DEFINE([ACE_LACKS_INTPTR_T], 1, + [Define to 1 if the system lacks the type `intptr_t'.])], + [ +#ifndef ACE_LACKS_STDINT_H +#include +#endif +#ifndef ACE_LACKS_INTTYPES_H +#include +#endif]) + +AC_CHECK_TYPE([uintptr_t], + [], + [AC_DEFINE([ACE_LACKS_UINTPTR_T], 1, + [Define to 1 if the system lacks the type `uintptr_t'.])], + [ +#ifndef ACE_LACKS_STDINT_H +#include +#endif +#ifndef ACE_LACKS_INTTYPES_H +#include +#endif]) + +AC_CHECK_TYPE([int8_t], + [AC_DEFINE([ACE_HAS_INT8_T], 1, + [Define to 1 if the system has the type `int8_t'.])], + [], + [ +#ifndef ACE_LACKS_STDINT_H +#include +#endif +#ifndef ACE_LACKS_INTTYPES_H +#include +#endif]) + +AC_CHECK_TYPE([uint8_t], + [AC_DEFINE([ACE_HAS_UINT8_T], 1, + [Define to 1 if the system has the type `uint8_t'.])], + [], + [ +#ifndef ACE_LACKS_STDINT_H +#include +#endif +#ifndef ACE_LACKS_INTTYPES_H +#include +#endif]) + +AC_CHECK_TYPE([int16_t], + [AC_DEFINE([ACE_HAS_INT16_T], 1, + [Define to 1 if the system has the type `int16_t'.])], + [], + [ +#ifndef ACE_LACKS_STDINT_H +#include +#endif +#ifndef ACE_LACKS_INTTYPES_H +#include +#endif]) + +AC_CHECK_TYPE([uint16_t], + [AC_DEFINE([ACE_HAS_UINT16_T], 1, + [Define to 1 if the system has the type `uint16_t'.])], + [], + [ +#ifndef ACE_LACKS_STDINT_H +#include +#endif +#ifndef ACE_LACKS_INTTYPES_H +#include +#endif]) + +AC_CHECK_TYPE([int32_t], + [AC_DEFINE([ACE_HAS_INT32_T], 1, + [Define to 1 if the system has the type `int32_t'.])], + [], + [ +#ifndef ACE_LACKS_STDINT_H +#include +#endif +#ifndef ACE_LACKS_INTTYPES_H +#include +#endif]) + +AC_CHECK_TYPE([uint32_t], + [AC_DEFINE([ACE_HAS_UINT32_T], 1, + [Define to 1 if the system has the type `uint32_t'.])], + [], + [ +#ifndef ACE_LACKS_STDINT_H +#include +#endif +#ifndef ACE_LACKS_INTTYPES_H +#include +#endif]) + +AC_CHECK_TYPE([int64_t], + [AC_DEFINE([ACE_HAS_INT64_T], 1, + [Define to 1 if the system has the type `int64_t'.])], + [], + [ +#ifndef ACE_LACKS_STDINT_H +#include +#endif +#ifndef ACE_LACKS_INTTYPES_H +#include +#endif]) + +AC_CHECK_TYPE([uint64_t], + [AC_DEFINE([ACE_HAS_UINT64_T], 1, + [Define to 1 if the system has the type `uint64_t'.])], + [], + [ +#ifndef ACE_LACKS_STDINT_H +#include +#endif +#ifndef ACE_LACKS_INTTYPES_H +#include +#endif]) + +ACE_CACHE_CHECK([for std::numeric_limits<>], +[ace_cv_func_numeric_limits], +[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include ], + [return std::numeric_limits::max();])], + [ace_cv_func_numeric_limits=yes], + [ace_cv_func_numeric_limits=no]) +],,[AC_DEFINE([ACE_LACKS_NUMERIC_LIMITS])]) + +dnl Other checks + +ACE_VAR_TIMEZONE + + +dnl Check for istream operator>> for char, unsigned char and signed char +ACE_CACHE_CHECK([for istream operator>> for char types], + [ace_cv_feature_char_right_shifts], + [ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#include + ]],[[ +unsigned char a = 0; +cin >> a; + +#ifndef ACE_LACKS_SIGNED_CHAR +signed char b = 0; +cin >> b; +#endif + ]])],[ + ace_cv_feature_char_right_shifts=yes + ],[ + ace_cv_feature_char_right_shifts=no + ]) + ],,[AC_DEFINE([ACE_LACKS_CHAR_RIGHT_SHIFTS])]) + + +dnl Check for istream operator>> for char *, unsigned char * and signed char * +ACE_CACHE_CHECK([for istream operator>> for char * types], + [ace_cv_feature_char_ptr_right_shifts], + [ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#include + ]],[[ +unsigned char * a = 0; +cin >> a; + +#ifndef ACE_LACKS_SIGNED_CHAR +signed char * b = 0; +cin >> b; +#endif + ]])],[ + ace_cv_feature_char_ptr_right_shifts=yes + ],[ + ace_cv_feature_char_ptr_right_shifts=no + ]) + ],,[AC_DEFINE([ACE_LACKS_CHAR_STAR_RIGHT_SHIFTS])]) + +dnl Check to see how to call the explicit destructor on a template. +dnl There are a few different possibilities: +dnl ACE_HAS_WORKING_EXPLICIT_TEMPLATE_DESTRUCTOR (two cases): +dnl ACE_EXPLICIT_TEMPLATE_DESTRUCTOR_TAKES_ARGS: ~CLASS() +dnl (no other settings): ~CLASS() +dnl w/o ACE_HAS_WORKING_EXPLICIT_TEMPLATE_DESTRUCTOR: +dnl CLASS::~CLASS() +dnl +dnl The first seems to be the most widely used form, although very few +dnl hand-made configs have it set. Many compilers take all three forms. +dnl The only one that seems to be less-used is #2 above, ~CLASS(). +dnl So, we check for the first two cases, and if neither of them work, +dnl we assume the third (no config macros). + +ACE_CACHE_CHECK([to see if template destructor call takes template args], + [ace_cv_feature_explicit_template_des_takes_args], + [ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ + +class dyn +{ + public: + dyn () { } + ~dyn () { } +}; + +template +class Base +{ + public: + Base () { } + virtual void f (void) { } + ~Base () { } +}; + +template +class Derived +{ + public: + Derived () + { + x_ = new Base (); + } + virtual void f (void) { } + ~Derived () { x_->~Base (); } + private: + Base *x_; + T t_; +}; + ]],[[ + Derived *x = new Derived (); + + x->f (); + + delete x; + return 0; + ]])],[ + ace_cv_feature_explicit_template_des_takes_args=yes + ],[ + ace_cv_feature_explicit_template_des_takes_args=no + ]) + ],[ + AC_DEFINE([ACE_EXPLICIT_TEMPLATE_DESTRUCTOR_TAKES_ARGS]) + AC_DEFINE([ACE_HAS_WORKING_EXPLICIT_TEMPLATE_DESTRUCTOR]) + ], +) + +dnl Check for the second form of C++ explicit template destructors +dnl Thanks to Nanbor Wang for providing this test. +if test "$ace_cv_feature_explicit_template_des_takes_args" = no; then +ACE_CACHE_CHECK([for working C++ explicit template destructors], + [ace_cv_feature_working_explicit_des], + [ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ + +class dyn +{ + public: + dyn () { } + ~dyn () { } +}; + +template +class Base +{ + public: + Base () { } + virtual void f (void) { } + ~Base () { } +}; + +template +class Derived +{ + public: + Derived () + { + x_ = new Base (); + } + virtual void f (void) { } + ~Derived () { x_->~Base (); } + private: + Base *x_; + T t_; +}; + ]],[[ + Derived *x = new Derived (); + + x->f (); + + delete x; + return 0; + ]])],[ + ace_cv_feature_working_explicit_des=yes + ],[ + ace_cv_feature_working_explicit_des=no + ]) + ],[AC_DEFINE([ACE_HAS_WORKING_EXPLICIT_TEMPLATE_DESTRUCTOR])],) +fi + +dnl Check for C++ "std" namespace +ACE_CACHE_CHECK([for C++ "std" namespace], + [ace_cv_feature_posix_uses_std_namespace],[ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#if defined (ACE_USES_OLD_IOSTREAMS) +# include +#else +# include +#endif + ]],[[ + std::cout << "FOO" << std::endl; + ]])],[ + ace_cv_feature_posix_uses_std_namespace=yes + ],[ + ace_cv_feature_posix_uses_std_namespace=no + ]) + ],[AC_DEFINE([ACE_USES_STD_NAMESPACE_FOR_STDCPP_LIB])],) + +dnl Check for new style C++ include file support +ACE_CACHE_CHECK([for new style C++ include file support], + [ace_cv_lib_posix_standard_includes],[ + ace_cv_lib_posix_standard_includes=no + if test "$ace_cv_feature_posix_uses_std_namespace" = yes; then + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#include + ]],[[ +#ifdef ACE_USES_STD_NAMESPACE_FOR_STDCPP_LIB + std::string str; +#else + string str; +#endif /* ACE_USES_STD_NAMESPACE_FOR_STDCPP_LIB */ + ]])],[ace_cv_lib_posix_standard_includes=yes],[]) + fi + ], + [ + AC_DEFINE([ACE_HAS_STDCPP_STL_INCLUDES]) + AC_DEFINE([ACE_HAS_STRING_CLASS]) + ],) + +AC_CHECK_HEADER([map], +[ + AC_CHECK_HEADER([net/if.h], + [ + ACE_CACHE_CHECK([if STL map class conflicts with map struct], + [ace_cv_header_stl_map_conflict], + [ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#ifndef ACE_LACKS_SYS_TYPES_H +# include +#endif +#include +#include + ]],[[ +#ifdef ACE_USES_STD_NAMESPACE_FOR_STDCPP_LIB + std::map ace_map; +#else + map ace_map; +#endif /* ACE_USES_STD_NAMESPACE_FOR_STDCPP_LIB */ + ]])],[ + ace_cv_header_stl_map_conflict=no + ],[ + ace_cv_header_stl_map_conflict=yes + ]) + ],[AC_DEFINE([ACE_HAS_STL_MAP_CONFLICT])],) + ],) +],) + +AC_CHECK_HEADER([queue], +[ + AC_CHECK_HEADER([netinet/in.h], + [ + ACE_CACHE_CHECK([if STL queue class conflicts with queue struct], + [ace_cv_header_stl_queue_conflict], + [ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#ifndef ACE_LACKS_SYS_TYPES_H +# include +#endif +#include +#include + ]],[[ +#ifdef ACE_USES_STD_NAMESPACE_FOR_STDCPP_LIB + std::queue ace_queue; +#else + queue ace_queue; +#endif /* ACE_USES_STD_NAMESPACE_FOR_STDCPP_LIB */ + ]])],[ + ace_cv_header_stl_queue_conflict=no + ],[ + ace_cv_header_stl_queue_conflict=yes + ]) + ],[AC_DEFINE([ACE_HAS_STL_QUEUE_CONFLICT])],) + ],) +],) + +dnl Check whether platform supports the standard C++ library +dnl TODO: For now, check whether headers , +dnl and exist; is there a better way? +if test "$ac_cv_header_new" = yes && + test "$ac_cv_header_iomanip" = yes && + test "$ac_cv_header_memory" = yes; then + + dnl Check for auto_ptr class + ACE_CACHE_CHECK([for C++ auto_ptr class], + [ace_cv_lib_auto_ptr_class], + [ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#include + ]],[[ + int *foo = new int; + +#ifdef ACE_USES_STD_NAMESPACE_FOR_STDCPP_LIB + std::auto_ptr safe (foo); +#else + auto_ptr safe (foo); +#endif + foo = safe.release (); + + delete foo; + ]])],[ + ace_cv_lib_auto_ptr_class=yes + ],[ + ace_cv_lib_auto_ptr_class=no + ]) + ], + [ + AC_DEFINE([ACE_HAS_STANDARD_CPP_LIBRARY]) + ], + [ + AC_DEFINE([ACE_LACKS_AUTO_PTR]) + ]) +fi + +if test "$ace_cv_lib_auto_ptr_class" = yes; then + dnl Check for auto_ptr reset method + ACE_CACHE_CHECK([for C++ auto_ptr reset method], + [ace_cv_lib_auto_ptr_reset], + [ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#include + ]],[[ + int *foo = new int; + +#ifdef ACE_USES_STD_NAMESPACE_FOR_STDCPP_LIB + std::auto_ptr safe (foo); +#else + auto_ptr safe (foo); +#endif + int *bar = new int; + + safe.reset (bar); + + foo = safe.release (); + ]])],[ + ace_cv_lib_auto_ptr_reset=yes + ],[ + ace_cv_lib_auto_ptr_reset=no + ]) + ],,[AC_DEFINE([ACE_AUTO_PTR_LACKS_RESET])]) +fi dnl test $ace_cv_lib_auto_ptr_class=yes + +dnl Check if platform supports placement new operator +ACE_CACHE_CHECK([for C++ placement new operator], + [ace_cv_feature_placement_new],[ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#if defined (ACE_HAS_NEW_NO_H) +# include +#elif defined (ACE_HAS_NEW_H) +# include +#endif + +class foo +{ +public: + void *operator new (size_t, void *p) { return p; } +}; + ]],[[ +int *x = 0; +foo *f = new (x) foo; + ]])],[ + ace_cv_feature_placement_new=yes + ],[ + ace_cv_feature_placement_new=no + ]) + ],,[AC_DEFINE([ACE_LACKS_PLACEMENT_OPERATOR_NEW])]) + +dnl Check if platform supports placement delete operator +ACE_CACHE_CHECK([for C++ placement delete operator], + [ace_cv_feature_placement_delete],[ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#if defined (ACE_HAS_NEW_NO_H) +# include +#elif defined (ACE_HAS_NEW_H) +# include +#endif + +class foo +{ +public: + void *operator new (size_t, void *p) { return p; } + void operator delete (void *p, void *) {} +}; + ]],[[ +int *x = 0; +foo *f = new (x) foo; + +// delete f; // Don't call delete for this test! + ]])],[ + ace_cv_feature_placement_delete=yes + ],[ + ace_cv_feature_placement_delete=no + ]) + ],,[AC_DEFINE([ACE_LACKS_PLACEMENT_OPERATOR_DELETE])]) + + +dnl Check if templates require source on platform +dnl +dnl FIXME: This test may be broken. +dnl +dnl FIXME: This test contains vestigial bits of tests for explicit +dnl template instantiation feature macros, even though support for +dnl the same has been removed. +dnl +dnl A rewrite to test only whether ACE_TEMPLATES_REQUIRE_SOURCE or +dnl ACE_TEMPLATES_REQUIRE_PRAGMA is clearly needed. +dnl +ACE_CACHE_CHECK([if templates require source], + [ace_cv_feature_templates_require_source], + [ + dnl Create the common header file + cat > ace_test.h < +class Foo +{ + public: + Foo (T val); + private: + T value_; +}; + +template +class Bar +{ + public: + Bar (Foo *); + private: + Foo *foo_ptr; +}; +#endif /* FOO_H */ +EOF + + dnl Create template source test file + cat > ace_test.$ac_ext < +Foo::Foo (T val) + : value_ (val) +{ + // Nothing else to do. +} + +template +Bar::Bar (Foo *val) + : foo_ptr (val) +{ + // Nothing else to do. +} +#endif /* FOO_CXX */ +EOF + + dnl Add the ACE-specific compiler flags to the compiler flags for + dnl the duration of this test. + ace_cxx_template_save_CXXFLAGS="$CXXFLAGS" + ace_cxx_template_save_CPPFLAGS="$CPPFLAGS" + ace_cxx_template_save_LDFLAGS="$LDFLAGS" + CXXFLAGS="$ACE_CXXFLAGS $CXXFLAGS" + CPPFLAGS="$ACE_CPPFLAGS $CPPFLAGS" + LDFLAGS="$ACE_LDFLAGS $LDFLAGS" + + dnl Remove any template repositories. + rm -rf Templates.DB SunWS_cache ptrepository *.rpo + + dnl First try without explicit template instantiation. + AC_LINK_IFELSE([AC_LANG_PROGRAM([[ +#include "ace_test.h" + ]],[[ +Foo foo (15); +Bar bar (0); + ]])],[ + dnl Template source is not required. + ace_cv_feature_templates_require_source=no + + dnl Template source does not require pragma. + AC_CACHE_VAL([ace_cv_feature_templates_require_pragma], + [ace_cv_feature_templates_require_pragma=no]) + + dnl Explicit template instantiation is not required. + AC_CACHE_VAL([ace_cv_feature_explicit_template_instantiation], + [ace_cv_feature_explicit_template_instantiation=no]) + + dnl Pragma template instantiation is not required. + AC_CACHE_VAL([ace_cv_feature_pragma_template_instantiation], + [ace_cv_feature_pragma_template_instantiation=no]) + ],[ + dnl Remove any template repositories. + rm -rf Templates.DB SunWS_cache ptrepository *.rpo + + dnl Now try including the template source. + AC_LINK_IFELSE([AC_LANG_PROGRAM( + [[ +#include "ace_test.h" +#include "ace_test.$ac_ext" + ]], + [[ +Foo foo (15); + +Bar bar (0); + ]])], + [ + dnl Template source is required! + ace_cv_feature_templates_require_source=yes + + dnl Template source does not require pragma. + AC_CACHE_VAL([ace_cv_feature_templates_require_pragma], + [ace_cv_feature_templates_require_pragma=no]) + + dnl Explicit template instantiation is not required. + AC_CACHE_VAL([ace_cv_feature_explicit_template_instantiation], + [ace_cv_feature_explicit_template_instantiation=no]) + + dnl Pragma template instantiation is not required. + AC_CACHE_VAL([ace_cv_feature_pragma_template_instantiation], + [ace_cv_feature_pragma_template_instantiation=no]) + ], + [ +dnl BEGIN OUTER REQUIRE SOURCE ######################################### + dnl Remove any generated template repositories. + rm -rf Templates.DB SunWS_cache ptrepository *.rpo + + dnl Now try with explicit template instantiation. + AC_LINK_IFELSE([AC_LANG_PROGRAM( + [[ +#include "ace_test.h" + +template class Foo; +template class Bar; + ]], + [[ +Foo foo (15); +Bar bar (0); + ]])], + [ + dnl Template source is not required. + ace_cv_feature_templates_require_source=no + + dnl Template source does not require pragma. + AC_CACHE_VAL([ace_cv_feature_templates_require_pragma], + [ace_cv_feature_templates_require_pragma=no]) + + dnl Explicit template instantiation is required. + AC_CACHE_VAL([ace_cv_feature_explicit_template_instantiation], + [ace_cv_feature_explicit_template_instantiation=yes]) + + dnl Pragma template instantiation is not required. + AC_CACHE_VAL([ace_cv_feature_pragma_template_instantiation], + [ace_cv_feature_pragma_template_instantiation=no]) + ], + [ + dnl Remove any generated template repositories. + rm -rf Templates.DB SunWS_cache ptrepository *.rpo + + dnl Don't set + dnl ace_cv_feature_pragma_template_instantiation + dnl to "no" here. It should only be set to "no" if + dnl explicit template instantiation works. + + dnl Now try including the template source. + AC_LINK_IFELSE([AC_LANG_PROGRAM( + [[ +#include "ace_test.h" +#include "ace_test.$ac_ext" + +template class Foo; +template class Bar; + ]], + [[ +Foo foo (15); +Bar bar (0); + ]])], + [ + dnl Template source is required! + ace_cv_feature_templates_require_source=yes + + dnl Template source does not require pragma. + AC_CACHE_VAL([ace_cv_feature_templates_require_pragma], + [ace_cv_feature_templates_require_pragma=no]) + + dnl Explicit template instantiation is required. + AC_CACHE_VAL( + [ace_cv_feature_explicit_template_instantiation], + [ace_cv_feature_explicit_template_instantiation=yes]) + + dnl Pragma template instantiation is not required. + AC_CACHE_VAL( + [ace_cv_feature_pragma_template_instantiation], + [ace_cv_feature_pragma_template_instantiation=no]) + ], + [ +dnl BEGIN INNER REQUIRE SOURCE ######################################### + dnl Remove any generated template repositories. + rm -rf Templates.DB SunWS_cache ptrepository *.rpo + + dnl Don't set + dnl ace_cv_feature_explicit_template_instantiation + dnl to "no" here. It should only be set to "no" if + dnl pragma template instantiation works. + + dnl Now try with pragma template instantiation. + AC_LINK_IFELSE([AC_LANG_PROGRAM( + [[ +#include "ace_test.h" + +#pragma instantiate Foo +#pragma instantiate Bar + ]], + [[ +Foo foo (15); +Bar bar (0); + ]])], + [ + dnl Template source is not required. + ace_cv_feature_templates_require_source=no + + dnl Template source does not require pragma. + AC_CACHE_VAL( + [ace_cv_feature_templates_require_pragma], + [ace_cv_feature_templates_require_pragma=no]) + + dnl Explicit template instantiation is not required. + AC_CACHE_VAL( + [ace_cv_feature_explicit_template_instantiation], + [ace_cv_feature_explicit_template_instantiation=no]) + + dnl Pragma template instantiation is required. + AC_CACHE_VAL( + [ace_cv_feature_pragma_template_instantiation], + [ace_cv_feature_pragma_template_instantiation=yes]) + ], + [ + dnl Remove any generated template repositories. + rm -rf Templates.DB SunWS_cache ptrepository *.rpo + + dnl Don't set + dnl ace_cv_feature_explicit_template_instantiation + dnl to "no" here. It should only be set to "no" if + dnl pragma template instantiation works. + + dnl Now try including the template source. + AC_LINK_IFELSE([AC_LANG_PROGRAM( + [[ +#include "ace_test.h" +#include "ace_test.$ac_ext" + +#pragma instantiate Foo +#pragma instantiate Bar + ]], + [[ +Foo foo (15); +Bar bar (0); + ]])], + [ + dnl Template source is required! + ace_cv_feature_templates_require_source=yes + + dnl Template source does not require pragma. + AC_CACHE_VAL( + [ace_cv_feature_templates_require_pragma], + [ace_cv_feature_templates_require_pragma=no]) + + dnl Explicit template instantiation is not required. + AC_CACHE_VAL( + [ace_cv_feature_explicit_template_instantiation], + [ace_cv_feature_explicit_template_instantiation=no]) + + dnl Pragma template instantiation is required. + AC_CACHE_VAL( + [ace_cv_feature_pragma_template_instantiation], + [ace_cv_feature_pragma_template_instantiation=yes]) + ], + [ + dnl If we get here, then we have no idea what is needed! + ace_cv_feature_templates_require_source=no + ]) + ]) +dnl END INNER REQUIRE SOURCE ######################################### + ]) + ]) +dnl END OUTER REQUIRE SOURCE ######################################### + ]) + ]) + + dnl Remove any generated template repositories. + rm -rf Templates.DB SunWS_cache ptrepository *.rpo + + dnl Remove the test additional test files. + rm -f ace_test* + + dnl Restore the compiler flags + CXXFLAGS="$ace_cxx_template_save_CXXFLAGS" + CPPFLAGS="$ace_cxx_template_save_CPPFLAGS" + LDFLAGS="$ace_cxx_template_save_LDFLAGS" + ], + [ + AC_DEFINE([ACE_TEMPLATES_REQUIRE_SOURCE]) + ], + [ + dnl Check if templates require pragma. + ACE_CACHE_CHECK([if templates require pragma], + [ace_cv_feature_templates_require_pragma], + [ + dnl Create the common header file + cat > ace_test.h < +class Foo +{ + public: + Foo (T val); + private: + T value_; +}; + +template +class Bar +{ + public: + Bar (Foo *); + private: + Foo *foo_ptr; +}; +#endif /* FOO_H */ +EOF + + dnl Create template source test file + cat > ace_test.$ac_ext < +Foo::Foo (T val) + : value_ (val) +{ + // Nothing else to do. +} + +template +Bar::Bar (Foo *val) + : foo_ptr (val) +{ + // Nothing else to do. +} +#endif /* FOO_CXX */ +EOF + + dnl Add the ACE-specific compiler flags to the compiler flags for + dnl the duration of this test. + ace_cxx_template_save_CXXFLAGS="$CXXFLAGS" + ace_cxx_template_save_CPPFLAGS="$CPPFLAGS" + ace_cxx_template_save_LDFLAGS="$LDFLAGS" + CXXFLAGS="$ACE_CXXFLAGS $CXXFLAGS" + CPPFLAGS="$ACE_CPPFLAGS $CPPFLAGS" + LDFLAGS="$ACE_LDFLAGS $LDFLAGS" + + dnl Remove any template repositories. + rm -rf Templates.DB SunWS_cache ptrepository *.rpo + + dnl We already know that the simplest case doesn't work so go + dnl straight to the "require pragma" test. + + dnl Now try including the template pragma. + AC_LINK_IFELSE([AC_LANG_PROGRAM([[ +#include "ace_test.h" + +#pragma implementation ("ace_test.$ac_ext") + ]],[[ +Foo foo (15); +Bar bar (0); + ]])],[ + dnl Template source is required! + ace_cv_feature_templates_require_pragma=yes + ],[ +dnl BEGIN OUTER REQUIRE PRAGMA ######################################### + dnl Remove any generated template repositories. + rm -rf Templates.DB SunWS_cache ptrepository *.rpo + + dnl Now try with explicit template instantiation. + AC_LINK_IFELSE([AC_LANG_PROGRAM( + [[ +#include "ace_test.h" + +#pragma implementation ("ace_test.$ac_ext") + +template class Foo; +template class Bar; + ]], + [[ +Foo foo (15); +Bar bar (0); + ]])], + [ + dnl Template pragma is required! + ace_cv_feature_templates_require_pragma=yes + + dnl Explicit template instantiation is required. + AC_CACHE_VAL( + [ace_cv_feature_explicit_template_instantiation], + [ace_cv_feature_explicit_template_instantiation=yes]) + + dnl Pragma template instantiation is not required. + AC_CACHE_VAL( + [ace_cv_feature_pragma_template_instantiation], + [ace_cv_feature_pragma_template_instantiation=no]) + ], + [ +dnl BEGIN INNER REQUIRE PRAGMA ######################################### + dnl Remove any generated template repositories. + rm -rf Templates.DB SunWS_cache ptrepository *.rpo + + dnl Now try with pragma template instantiation. + AC_LINK_IFELSE([AC_LANG_PROGRAM( + [[ +#include "ace_test.h" + +#pragma implementation ("ace_test.$ac_ext") + +#pragma instantiate Foo +#pragma instantiate Bar + ]], + [[ +Foo foo (15); +Bar bar (0); + ]])], + [ + dnl Template pragma is required! + ace_cv_feature_templates_require_pragma=yes + + dnl Explicit template instantiation is not required. + AC_CACHE_VAL( + [ace_cv_feature_explicit_template_instantiation], + [ace_cv_feature_explicit_template_instantiation=no]) + + dnl Pragma template instantiation is required. + AC_CACHE_VAL( + [ace_cv_feature_pragma_template_instantiation], + [ace_cv_feature_pragma_template_instantiation=yes]) + ], + [ + dnl If we get here, then we have no idea what is needed! + ace_cv_feature_templates_require_pragma=no + ]) +dnl END INNER REQUIRE PRAGMA ######################################### + ]) +dnl END OUTER REQUIRE PRAGMA ######################################### + ]) + + dnl Remove any generated template repositories. + rm -rf Templates.DB SunWS_cache ptrepository *.rpo + + dnl Remove the additional test files. + rm -f ace_test* + + dnl Restore the compiler flags + CXXFLAGS="$ace_cxx_template_save_CXXFLAGS" + CPPFLAGS="$ace_cxx_template_save_CPPFLAGS" + LDFLAGS="$ace_cxx_template_save_LDFLAGS" + ], + [ + AC_DEFINE([ACE_TEMPLATES_REQUIRE_PRAGMA]) + ], + [ + dnl Do nothing. + ]) + ]) + + +dnl Check if platform supports template typedefs +ACE_CACHE_CHECK([for template typedefs], + [ace_cv_feature_posix_template_typedefs],[ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ + +class Bar +{ +public: + typedef int Y; + Bar(int bar) : bar_(bar) {} + int value() const { return bar_; } +private: + int bar_; +}; + +template +class Foo +{ +public: + typedef typename T::Y Y; + Foo(T* foo) : foo_(foo) {} + void print(Y); +private: + T* foo_; +}; + +template +void Foo::print(typename T::Y) +{ +} + ]],[[ +Bar bar(15); +Foo foo(&bar); +foo.print(11); + ]])],[ + ace_cv_feature_posix_template_typedefs=yes + ],[ + ace_cv_feature_posix_template_typedefs=no + ]) + ],[AC_DEFINE([ACE_HAS_TEMPLATE_TYPEDEFS])],) + +dnl Check if platform supports static data member templates +ACE_CACHE_CHECK([for static data member templates], + [ace_cv_feature_posix_static_data_member_templates],[ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +template +class Foo +{ +public: + static T* sdm; +}; + +template T* Foo::sdm = 0; + ]],[[ + /* No body */ + ]])],[ + ace_cv_feature_posix_static_data_member_templates=yes + ],[ + ace_cv_feature_posix_static_data_member_templates=no + ]) + ],,[AC_DEFINE([ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES])]) + +dnl Check if compiler needs definitions for hidden functions +ACE_CACHE_CHECK([if definition is needed for hidden functions], + [ace_cv_feature_need_func_def], + [ + AC_LINK_IFELSE([AC_LANG_PROGRAM([[ + class Foo + { + public: + Foo (void) { a_ = 0; } + private: + Foo (const Foo &); + void operator= (const Foo &); + + int a_; + }; + ]],[[ + Foo Bar; + ]])],[ + ace_cv_feature_need_func_def=no + ],[ + AC_LINK_IFELSE([AC_LANG_PROGRAM( + [[ + class Foo + { + public: + Foo (void) { a_ = 0; } + private: + Foo (const Foo &); + const Foo & operator= (const Foo &); + + int a_; + }; + + Foo::Foo (const Foo &) + { + a_ = 0; + } + + const Foo & + Foo::operator= (const Foo &) + { + a_ = 0; + + return *this; + } + ]], + [[ + Foo Bar; + ]])], + [ + ace_cv_feature_need_func_def=yes + ], + [ + dnl If we get here then we don't know what is needed! + ace_cv_feature_need_func_def=no + ]) + ]) + ], + [ + AC_DEFINE([ACE_NEEDS_FUNC_DEFINITIONS]) + ],) + +dnl Check if platform supports C++ exceptions +if test "$ace_user_enable_exceptions" = yes; then + ACE_CACHE_CHECK([for C++ exceptions], + [ace_cv_feature_posix_exceptions],[ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]],[[ + int ret = 0; + class ACE {}; + try + { + throw ACE(); + } + catch (ACE) + { + ret = 1; + } + ]])],[ + ace_cv_feature_posix_exceptions=yes + ],[ + ace_cv_feature_posix_exceptions=no + ]) + ],[AC_DEFINE([ACE_HAS_EXCEPTIONS])],[ace_user_enable_exceptions=no]) + +fi dnl test "$ace_user_enable_exceptions" = yes + +dnl Check if we need a non-static object manager +dnl TODO / FIXME +dnl ACE_CACHE_CHECK([if we need a non-static object manager], +dnl [ace_cv_feature_nonstatic_object_manager],[ +dnl ace_cv_feature_nonstatic_object_manager=yes + dnl TODO: Should we check for this thing (and HOW), or + dnl should it be the user's choice? + + dnl For now, we will leave it as a user's choice. + dnl -Ossama +dnl ], +dnl [ + dnl Don't define anything until we have a test for this. + dnl AC_DEFINE([ACE_HAS_NONSTATIC_OBJECT_MANAGER]) +dnl ],) + +dnl Save the cache for debugging purposes +AC_CACHE_SAVE + + +dnl SECTION 10: checks for library functions + +ACE_FUNC_STRCASECMP +ACE_FUNC_STRNCASECMP +ACE_FUNC_STRDUP +ACE_FUNC_WCSCASECMP +ACE_FUNC_WCSNCASECMP +ACE_FUNC_WCSDUP + +if test "$ace_user_enable_alloca" = yes; then + AC_FUNC_ALLOCA + if test "$ac_cv_header_alloca_h" = yes; then + AC_DEFINE([ACE_HAS_ALLOCA_H]) + fi + if test "$ac_cv_func_alloca_works" = yes; then + AC_DEFINE([ACE_HAS_ALLOCA]) + fi +fi + +dnl ACE should really have something for both the sys/mman.h header +dnl and the mmap function since we need sys/mman.h for functions like +dnl mprotect and msync, but don't want to use mmap if it doesn't work. +dnl For now, we just check for the sys/mman.h header earlier in this +dnl configure script. + +dnl AC_FUNC_MMAP +dnl if test "$ac_cv_func_mmap_fixed_mapped" = no; then +dnl Even if we have mmap, do not use if broken! +dnl AC_DEFINE(ACE_LACKS_MMAP) +dnl fi + +dnl Check if closedir() returns a meaningful value +AC_FUNC_CLOSEDIR_VOID + +dnl Check for PWD functions +AC_CHECK_FUNC([getpwnam],,) +AC_CHECK_FUNC([setpwent],,) +AC_CHECK_FUNC([endpwent],,) +AC_CHECK_FUNC([getpwent],,) +AC_CHECK_FUNC([getpwuid],,) + +if test "$ac_cv_func_getpwnam" != yes || + test "$ac_cv_func_setpwent" != yes || + test "$ac_cv_func_endpwent" != yes || + test "$ac_cv_func_getpwent" != yes || + test "$ac_cv_func_getpwuid" != yes; then + AC_DEFINE([ACE_LACKS_PWD_FUNCTIONS]) +else + dnl The password file related functions above are required for ACE's + dnl alternate implementation. + + ACE_CONVERT_WARNINGS_TO_ERRORS([ + dnl Check for functions necessary for ACE's alternate implementation + dnl of the now obsolete cuserid() function. + ACE_CACHE_CHECK([checking if ACE cuserid() implementation should be used], + [ace_cv_lib_use_alt_cuserid], + [ + AC_LINK_IFELSE([AC_LANG_PROGRAM([[ +/* Undefine _XOPEN_SOURCE since it may make the cuserid() prototype + visible. ACE should not rely on such feature test macros. */ +#undef _XOPEN_SOURCE +#ifndef ACE_LACKS_UNISTD_H +# include +#else +# error No unistd.h header. Need header where cuserid() is located. +#endif /* ACE_LACKS_UNISTD_H */ + ]],[[ + char * foo = cuserid ((char *)0); + ]])],[ + dnl If successful then use the system cuserid() implementation, + dnl despite the fact that ACE's implementation may be safer. + ace_cv_lib_use_alt_cuserid=no + ],[ + AC_LINK_IFELSE([AC_LANG_PROGRAM( + [[ +#ifndef ACE_LACKS_SYS_TYPES_H +# include +#endif +#undef _XOPEN_SOURCE +#ifndef ACE_LACKS_UNISTD_H +# include +#else +# error No unistd.h header. Need header where geteuid() is located. +#endif + ]], + [[ + uid_t foo = geteuid (); + ]])], + [ + dnl All of the functions necessary for ACE's cuserid() + dnl implementation exist. + ace_cv_lib_use_alt_cuserid=yes + ], + [ + dnl If we get here, we're hosed! + ace_cv_lib_use_alt_cuserid=no + ]) + ]) + ], + [ + AC_DEFINE([ACE_HAS_ALT_CUSERID]) + ],) + ]) +fi + + + +dnl Check for `strftime' in the `intl' library, for SCO UNIX +AC_FUNC_STRFTIME + +case "$host_os" in + *win32*) + AC_CHECK_FUNC([CancelIO], + [AC_DEFINE([ACE_HAS_CANCEL_IO])],) + + AC_CHECK_FUNC([SignalObjectAndWait], + [AC_DEFINE([ACE_HAS_SIGNAL_OBJECT_AND_WAIT])],) + + AC_CHECK_FUNC([TryEnterCriticalSection], + [AC_DEFINE([ACE_HAS_WIN32_TRYLOCK])],) + ;; + *) + ;; +esac + +ACE_CHECK_HAS_FUNCS(_InterlockedIncrement _InterlockedDecrement _InterlockedExchangeAdd) +if test "$ac_cv_func__InterlockedIncrement" == yes && + test "$ac_cv_func__InterlockedDecrement" == yes && + test "$ac_cv_func__InterlockedExchangeAdd" == yes; then + AC_DEFINE([ACE_HAS_INTRINSIC_INTERLOCKED]) +fi + +ACE_CHECK_LACKS_FUNCS(access) + +ACE_CHECK_LACKS_FUNCS(alphasort) + +ACE_CHECK_LACKS_FUNCS(asctime) + +ACE_CHECK_LACKS_FUNCS(asctime_r) + +ACE_CHECK_LACKS_FUNCS(alarm) + +ACE_CHECK_LACKS_FUNCS(bsearch) + +ACE_CHECK_HAS_DEFINES([bswap16]) +if test "$ace_cv_defined_bswap16" = no; then + ACE_CHECK_HAS_DEFINES([bswap_16],[],[],[ +#if ACE_HAS_BYTESWAP_H +#include +#endif]) +fi +ACE_CHECK_HAS_DEFINES([bswap32]) +if test "$ace_cv_defined_bswap32" = no; then + ACE_CHECK_HAS_DEFINES([bswap_32],[],[],[ +#if ACE_HAS_BYTESWAP_H +#include +#endif]) +fi +ACE_CHECK_HAS_DEFINES([bswap64]) +if test "$ace_cv_defined_bswap64" = no; then + ACE_CHECK_HAS_DEFINES([bswap_64],[],[],[ +#if ACE_HAS_BYTESWAP_H +#include +#endif]) +fi + +ACE_CHECK_LACKS_FUNCS(chdir) + +ACE_CHECK_HAS_FUNCS(clock_gettime clock_settime nanosleep) + +ACE_CHECK_LACKS_FUNCS(difftime) + +ACE_CHECK_LACKS_FUNCS(dup) + +ACE_CHECK_LACKS_FUNCS(dup2) + +dnl ACE uses execv, execvp and execve, so we don't bother to check +dnl for the others (e.g. execl, execlp, execle) +AC_CHECK_FUNC(execv) +AC_CHECK_FUNC(execvp) +AC_CHECK_FUNC(execve) +if test "$ac_cv_func_execv" != yes && + test "$ac_cv_func_execvp" != yes && + test "$ac_cv_func_execve" != yes; then + AC_DEFINE([ACE_LACKS_EXEC]) +fi + +ACE_CHECK_LACKS_FUNCS(fgetwc fcntl fork fsync) + +ACE_CHECK_LACKS_FUNCS(getcwd) + +ACE_CHECK_LACKS_FUNCS(gethostent) + +ACE_CHECK_LACKS_FUNCS(getipnodebyaddr) + +ACE_CHECK_LACKS_FUNCS(getipnodebyname) + +ACE_CHECK_HAS_FUNCS(getifaddrs) + +ACE_CHECK_LACKS_FUNCS(getegid geteuid getgid) + +ACE_CHECK_LACKS_FUNCS(getopt) +if test $ac_cv_func_getopt = yes; then + AC_CHECK_DECL([getopt], + [], + [AC_DEFINE([ACE_LACKS_GETOPT_PROTOTYPE], 1, + [Define to 1 if platform lacks the declaration + of getopt().])], + [#include + #ifndef ACE_LACKS_UNISTD_H + # include + #endif]) +fi + +AC_CHECK_FUNC([getpagesize], + [AC_DEFINE([ACE_HAS_GETPAGESIZE])], + [AC_DEFINE([ACE_PAGE_SIZE], [4096])]) + +ACE_CHECK_LACKS_FUNCS(getpid) + +ACE_CHECK_LACKS_FUNCS([getpgid]) +if test "$ac_cv_func_getpgid" = yes; then + dnl Check if _XOPEN_SOURCE and _XOPEN_SOURCE_EXTENDED macros are + dnl needed to make the getpgid() prototype visible. + ACE_CACHE_CHECK([for getpgid prototype], + [ace_cv_lib_has_getpgid_prototype], + [ + ace_save_CPPFLAGS="$CPPFLAGS" + ace_no_xopen="-U_XOPEN_SOURCE -U_XOPEN_SOURCE_EXTENDED" + CPPFLAGS="$CPPFLAGS $ace_no_xopen" + AC_EGREP_HEADER([[^_]+getpgid], [unistd.h], + [ + ace_cv_lib_has_getpgid_prototype=yes + ], + [ + ace_cv_lib_has_getpgid_prototype=no + ]) + dnl Reset the compiler flags + CPPFLAGS="$ace_save_CPPFLAGS" + ],, [AC_DEFINE([ACE_LACKS_GETPGID_PROTOTYPE])]) + AH_TEMPLATE([ACE_LACKS_GETPGID_PROTOTYPE], + [Define to 1 if platform lacks getpgid() declaration in .]) +fi + +ACE_CHECK_LACKS_FUNCS(getppid) + +ACE_CHECK_HAS_FUNCS(getprogname) + +ACE_CHECK_HAS_FUNCS(getrusage) +if test $ac_cv_func_getrusage = yes; then + AC_CHECK_DECL([getrusage], + [AC_DEFINE([ACE_HAS_GETRUSAGE_PROTOTYPE], 1, + [Define to 1 if platform has the declaration + of getrusage().])], + [], + [#include ]) +fi + +ACE_CHECK_LACKS_FUNCS(getuid) + +ACE_CHECK_LACKS_FUNCS(gmtime) + +ACE_CHECK_LACKS_FUNCS(gmtime_r) + +ACE_CHECK_LACKS_FUNCS(inet_aton) + +ACE_CHECK_LACKS_FUNCS(isatty) + +AC_CHECK_FUNC(isastream) +if test $ac_cv_func_isastream = yes; then + AC_CHECK_DECL([isastream], + [AC_DEFINE([ACE_HAS_ISASTREAM_PROTOTYPE], 1, + [Define to 1 if platform has the declaration + of isastream().])], + [], + [#include ]) +fi + +ACE_CHECK_HAS_FUNCS(itoa) + +dnl Check for 64 bit llseek() or lseek64() +case "$host" in + *UnixWare7*) + dnl Skip the check + ;; + *) + ACE_CHECK_LSEEK64 + ;; +esac + +ACE_CHECK_LACKS_FUNCS(kill) + +ACE_CHECK_LACKS_FUNCS(localtime) + +ACE_CHECK_LACKS_FUNCS(log2) + +ACE_CHECK_LACKS_FUNCS(lstat) + +ACE_CHECK_LACKS_FUNCS(madvise) +if test $ac_cv_func_madvise = yes; then + AC_CHECK_DECL([madvise], + [], + [AC_DEFINE([ACE_LACKS_MADVISE_PROTOTYPE], 1, + [Define to 1 if platform lacks the declaration + of madvise().])], + [ +#if !defined(ACE_LACKS_SYS_TYPES_H) +# include +#endif +#include + ]) +fi + +ACE_CHECK_HAS_FUNCS(mkdir) + +if test "$ac_cv_func_mkdir" = yes; then +dnl The mkdir() function has only one argument on Windows and VxWorks +AC_MSG_CHECKING([for 1- or 2-param mkdir]) +AC_LINK_IFELSE([AC_LANG_PROGRAM( + [[ +#include + ]], + [[ + const char path[] = "mypath"; + int result = mkdir (path); + ]])], + [ + AC_DEFINE([ACE_MKDIR_LACKS_MODE], 1, + [Define to 1 if platform has 1 parameter mkdir()]) + AC_MSG_RESULT([1]) + ], + [ + AC_MSG_RESULT([2]) + ]) +fi dnl test "$ac_cv_func_mkdir" = yes + +ACE_CHECK_HAS_FUNCS(memchr) + +ACE_CHECK_LACKS_FUNCS(mkfifo) + +ACE_CHECK_LACKS_FUNCS(mkstemp) +if test $ac_cv_func_mkstemp = yes; then + AC_CHECK_DECL([mkstemp], + [], + [AC_DEFINE([ACE_LACKS_MKSTEMP_PROTOTYPE], 1, + [Define to 1 if platform lacks the declaration + of mkstemp().])], + [#include ]) +fi + +ACE_CHECK_LACKS_FUNCS(mktemp) +if test $ac_cv_func_mktemp = yes; then + AC_CHECK_DECL([mktemp], + [], + [AC_DEFINE([ACE_LACKS_MKTEMP_PROTOTYPE], 1, + [Define to 1 if platform lacks the declaration + of mktemp().])], + [#include ]) +fi + +ACE_CHECK_LACKS_FUNCS(msync mprotect) + +ACE_CHECK_LACKS_FUNCS(pipe) + +ACE_CHECK_LACKS_FUNCS(qsort) + +ACE_CHECK_LACKS_FUNCS(realpath) + +ACE_CHECK_LACKS_FUNCS(setegid seteuid setgid) + +ACE_CHECK_LACKS_FUNCS([setpgid]) +if test "$ac_cv_func_setpgid" = yes; then + dnl Check if _XOPEN_SOURCE and _XOPEN_SOURCE_EXTENDED macros are + dnl needed to make the setpgid() prototype visible. + ACE_CACHE_CHECK([for setpgid prototype], + [ace_cv_lib_has_setpgid_prototype], + [ + ace_save_CPPFLAGS="$CPPFLAGS" + ace_no_xopen="-U_XOPEN_SOURCE -U_XOPEN_SOURCE_EXTENDED" + CPPFLAGS="$CPPFLAGS $ace_no_xopen" + AC_EGREP_HEADER([[^_]+setpgid], [unistd.h], + [ + ace_cv_lib_has_setpgid_prototype=yes + ], + [ + ace_cv_lib_has_setpgid_prototype=no + ]) + dnl Reset the compiler flags + CPPFLAGS="$ace_save_CPPFLAGS" + ],, [AC_DEFINE([ACE_LACKS_SETPGID_PROTOTYPE])]) + AH_TEMPLATE([ACE_LACKS_SETPGID_PROTOTYPE], + [Define to 1 if platform lacks setpgid() declaration in .]) +fi + +ACE_CHECK_HAS_FUNCS([setprogname]) + +ACE_CHECK_LACKS_FUNCS([setregid]) +if test "$ac_cv_func_setregid" = yes; then + dnl Check if _XOPEN_SOURCE and _XOPEN_SOURCE_EXTENDED macros are + dnl needed to make the setregid() prototype visible. + ACE_CACHE_CHECK([for setregid prototype], + [ace_cv_lib_has_setregid_prototype], + [ + ace_save_CPPFLAGS="$CPPFLAGS" + ace_no_xopen="-U_BSD_SOURCE -U_XOPEN_SOURCE -U_XOPEN_SOURCE_EXTENDED" + CPPFLAGS="$CPPFLAGS $ace_no_xopen" + AC_EGREP_HEADER([[^_]+setregid], [unistd.h], + [ + ace_cv_lib_has_setregid_prototype=yes + ], + [ + ace_cv_lib_has_setregid_prototype=no + ]) + dnl Reset the compiler flags + CPPFLAGS="$ace_save_CPPFLAGS" + ],, [AC_DEFINE([ACE_LACKS_SETREGID_PROTOTYPE])]) + AH_TEMPLATE([ACE_LACKS_SETREGID_PROTOTYPE], + [Define to 1 if platform lacks setregid() declaration in .]) +fi + +ACE_CHECK_LACKS_FUNCS([setreuid]) +if test "$ac_cv_func_setreuid" = yes; then + dnl Check if _XOPEN_SOURCE and _XOPEN_SOURCE_EXTENDED macros are + dnl needed to make the setreuid() prototype visible. + ACE_CACHE_CHECK([for setreuid prototype], + [ace_cv_lib_has_setreuid_prototype], + [ + ace_save_CPPFLAGS="$CPPFLAGS" + ace_no_xopen="-U_BSD_SOURCE -U_XOPEN_SOURCE -U_XOPEN_SOURCE_EXTENDED" + CPPFLAGS="$CPPFLAGS $ace_no_xopen" + AC_EGREP_HEADER([[^_]+setreuid], [unistd.h], + [ + ace_cv_lib_has_setreuid_prototype=yes + ], + [ + ace_cv_lib_has_setreuid_prototype=no + ]) + dnl Reset the compiler flags + CPPFLAGS="$ace_save_CPPFLAGS" + ],, [AC_DEFINE([ACE_LACKS_SETREUID_PROTOTYPE])]) + AH_TEMPLATE([ACE_LACKS_SETREUID_PROTOTYPE], + [Define to 1 if platform lacks setreuid() declaration in .]) +fi + +ACE_CHECK_LACKS_FUNCS(setsid setuid) + +ACE_CHECK_LACKS_FUNCS(sigaction) + +ACE_CHECK_HAS_FUNCS(strnlen) +if test "$ac_cv_func_strnlen" = yes; then + AC_CHECK_DECL([strnlen], + [], + [AC_DEFINE([ACE_LACKS_STRNLEN_PROTOTYPE], 1, + [Define to 1 if platform lacks the declaration + of strnlen().])], + [#include ]) +fi + +ACE_CHECK_LACKS_FUNCS(strchr) + +# believe it or not, both ACE_LACKS_STRERROR and ACE_HAS_STRERROR +# feature test macros are currently used. +ACE_CHECK_HAS_FUNCS(strerror) +ACE_CHECK_LACKS_FUNCS(strerror) + +ACE_CHECK_LACKS_FUNCS(strftime) + +ACE_CHECK_LACKS_FUNCS(strpbrk) + +ACE_CHECK_LACKS_FUNCS(strrchr) + +ACE_CHECK_LACKS_FUNCS(strspn) + +ACE_CHECK_LACKS_FUNCS(strtod) + +ACE_CHECK_LACKS_FUNCS(strtol) + +ACE_CHECK_LACKS_FUNCS(strtoul) + +ACE_CHECK_LACKS_FUNCS(strtoull) + +# swab() comes in a number of forms: +# swab (const void*, void*, size_t) is POSIX, XPG4, SUS, SUSv2 standard. +# swab (const char*, char*, size_t) is SVID third edition. +# swab (char*, char*, size_t) is on some odd platforms like Windows. +# So, if swab() is available, figure out which of the three variants it is. +# The second and third have ACE config settings. +ACE_CHECK_LACKS_FUNCS([swab], + [ + AC_LINK_IFELSE([ + AC_LANG_PROGRAM([ +#include +#include + ], + [ +// If this compiles, we have the POSIX, XPG4, etc. standard. +const char src[2] = {'a', 'b'}; +char dst[2]; +const void *vsrc = src; +void *vdst = dst; +swab (vsrc, vdst, 2); + ]) + ], + [ + ace_cv_std_swab=yes + ], + [ + AC_LINK_IFELSE([ + AC_LANG_PROGRAM([ +#include +#include + ], + [ +// If this compiles, we have the SVID3 version, else it's the odd, +// non-const one. +const char src[2] = {'a', 'b'}; +char dst[2]; +swab (src, dst, 2); + ]) + ], + [ + AC_DEFINE([ACE_HAS_CONST_CHAR_SWAB]) + ], + [ + AC_DEFINE([ACE_HAS_NONCONST_SWAB]) + ]) + ]) + ], +) + +ACE_CHECK_LACKS_FUNCS(sysconf) + +ACE_CHECK_HAS_FUNCS(sysctl) + +AC_CHECK_FUNC([sysinfo], + [ + if test "$ac_cv_header_sys_systeminfo_h" = yes; then + AC_DEFINE([ACE_HAS_SYSINFO]) + fi + ],) + +ACE_CHECK_LACKS_FUNCS(system) + +AC_CHECK_FUNC([getmsg], + [ + AC_RUN_IFELSE([AC_LANG_SOURCE([[ +#ifndef ACE_LACKS_UNISTD_H +# include +#endif /* !ACE_LACKS_UNISTD_H */ + +#ifndef ACE_LACKS_SYS_IOCTL_H +# include +#endif /* ACE_LACKS_SYS_IOCTL_H */ + +#ifdef ACE_HAS_STREAMS +# include +#endif /* ACE_HAS_STREAMS */ + +int +main () +{ + int fds[2]; + + if (pipe (fds) != 0) + return -1; + +/* + * Verify that we can actually set a STREAM option that ACE uses. + * This is particularly necessary for platforms where compiling and + * linking succeed but fail at run-time due to a missing actual + * STREAMS implementation. For example, Linux/glibc requires a + * STREAMS patch/add-on. + */ + + int arg = RMSGN; + + if (ioctl (fds[0], I_SRDOPT, (void *) arg) != 0) + return -1; + + return 0; +} + ]])],[ + AC_DEFINE([ACE_HAS_STREAM_PIPES]) + ],[],[ + dnl action if cross-compiling + AC_DEFINE([ACE_HAS_STREAM_PIPES]) + ]) + ],) + +AC_CHECK_FUNC([gethostbyaddr],,) + +case "$host" in + *linux*) + dnl Linux Event Poll + ACE_CACHE_CHECK([for epoll_create], + [ace_cv_linux_event_poll], + [ + AC_RUN_IFELSE([ + AC_LANG_PROGRAM([ +#include + ], + [ +int const ACE_NUM_DESCRIPTORS = 10; +return epoll_create (ACE_NUM_DESCRIPTORS) == -1 ? -1 : 0; + ]) + ], + [ + ace_cv_linux_event_poll=yes + ], + [ + ace_cv_linux_event_poll=no + ]) + ], + [ + AC_DEFINE([ACE_HAS_EVENT_POLL]) + ], + []) + ;; + *) + dnl Check if /dev/poll character device file exists and is + dnl useable. Just because /dev/poll is present doesn't mean its + dnl useable - this is the case on HP-UX 11. /dev/poll is there, but + dnl getting it to work requires a set of patches. + AC_RUN_IFELSE([ + AC_LANG_SOURCE([[ +#include +#include + +int +main () +{ + int fd = open ("/dev/poll", O_RDWR); + close (fd); + return fd == -1 ? -1 : 0; +} + ]])], + [ + AC_DEFINE([ACE_HAS_DEV_POLL]) + ], + [], + []) + ;; +esac + +AC_CHECK_FUNC([gethrtime], + [ + ACE_CHECK_TYPE([hrtime_t],[sys/time.h],[AC_DEFINE([ACE_HAS_HI_RES_TIMER])],) + ],) + +AC_CHECK_FUNC([pread], + [AC_CHECK_FUNC([pwrite], + [ + AC_DEFINE([ACE_HAS_P_READ_WRITE]) + dnl Check if _XOPEN_SOURCE=500 macro is needed to make the pread() and + dnl pwrite() prototypes visible. + ACE_CACHE_CHECK([for pread prototype], + [ace_cv_lib_has_pread_prototype], + [ + ace_save_CPPFLAGS="$CPPFLAGS" + ace_no_xopen="-U_XOPEN_SOURCE" + CPPFLAGS="$CPPFLAGS $ace_no_xopen" + AC_EGREP_HEADER([[^_]+pread], [unistd.h], + [ + ace_cv_lib_has_pread_prototype=yes + ], + [ + ace_cv_lib_has_pread_prototype=no + ]) + dnl Reset the compiler flags + CPPFLAGS="$ace_save_CPPFLAGS" + ],,[AC_DEFINE([ACE_LACKS_PREAD_PROTOTYPE])]) + ],)],) + +ACE_CHECK_LACKS_FUNCS(readv writev) + +ACE_CHECK_HAS_FUNCS(set_t_errno) + +ACE_CHECK_HAS_FUNCS(sigsuspend sigtimedwait) + +ACE_CHECK_LACKS_FUNCS(socketpair) + +AC_CHECK_FUNC(strptime) +if test "$ac_cv_func_strptime" == yes; then + dnl strptime() is available, but its prototype is not always visible to + dnl the compiler. Check if _XOPEN_SOURCE macro is needed to make the + dnl strptime() prototype visible. + ace_save_CPPFLAGS="$CPPFLAGS" + ace_no_xopen="-U_XOPEN_SOURCE" + CPPFLAGS="$CPPFLAGS $ace_no_xopen" + AC_CHECK_DECL([strptime], + [], + [AC_DEFINE([ACE_LACKS_STRPTIME_PROTOTYPE], 1, + [Define to 1 if platform lacks the declaration + of strptime().])], + [#include ]) + dnl Reset the compiler flags + CPPFLAGS="$ace_save_CPPFLAGS" +else + AC_DEFINE([ACE_LACKS_STRPTIME], 1, + [Define to 1 if platform lacks strptime().]) +fi + +if test "$ac_cv_type_wchar_t" = yes; then + AC_CHECK_FUNC([wcslen], + [AC_DEFINE([ACE_HAS_XPG4_MULTIBYTE_CHAR])],) +fi + +ACE_CHECK_LACKS_FUNCS(syscall) + +AC_CHECK_FUNC([alarm],,) +AC_CHECK_FUNC([signal],,) + +if test "$ac_cv_func_alarm" != yes && + test "$ac_cv_func_signal" != yes; then + AC_DEFINE([ACE_LACKS_UNIX_SIGNALS]) +fi + +AC_CHECK_FUNC([getrlimit]) +AC_CHECK_FUNC([setrlimit]) +if test "$ac_cv_func_getrlimit" != yes || + test "$ac_cv_func_setrlimit" != yes; then + AC_DEFINE([ACE_LACKS_RLIMIT]) +fi + +ACE_CHECK_LACKS_FUNCS(readlink rename recvmsg sendmsg) + +if test "$ac_cv_header_sys_priocntl_h" = yes; then + AC_CHECK_FUNC([priocntl], + [AC_DEFINE([ACE_HAS_PRIOCNTL])],) + +dnl Some platforms define priocntl as a macro! + if test "$ac_cv_func_priocntl" = no; then + ACE_CACHE_CHECK([for priocntl macro], + [ace_cv_lib_has_priocntl_macro], + [ + AC_EGREP_CPP([ACE_PRIOCNTL_MACRO], + [ +#include + +#if defined (priocntl) + ACE_PRIOCNTL_MACRO +#endif + ], + [ + ace_cv_lib_has_priocntl_macro=yes + ], + [ + ace_cv_lib_has_priocntl_macro=no + ]) + ], [AC_DEFINE([ACE_HAS_PRIOCNTL])],) + fi dnl test "$ac_cv_func_priocntl" = no +fi dnl test "$ac_cv_header_sys_priocntl_h" = yes + +dnl FIXME: How do we check for a working sbrk()? Do we need to? +ACE_CHECK_LACKS_FUNCS(sbrk) + +ACE_CHECK_HAS_FUNCS(ualarm) +if test $ac_cv_func_ualarm = yes; then + AC_CHECK_DECL([ualarm], + [], + [AC_DEFINE([ACE_LACKS_UALARM_PROTOTYPE], 1, + [Define to 1 if platform lacks the declaration + of ualarm().])], + [#include ]) +fi + +ACE_CHECK_LACKS_FUNCS(umask) + +ACE_CHECK_LACKS_FUNCS(uname) + +ACE_CHECK_LACKS_FUNCS(unlink) + +ACE_CHECK_HAS_FUNCS(vasprintf vaswprintf vfwprintf vswprintf) + +ACE_CHECK_HAS_FUNCS(wcsnlen) + +ACE_CHECK_LACKS_FUNCS(fgetws fputws itow towlower towupper wcscat wcschr wcscmp wcscpy wcscspn wcslen wcsncat wcsncmp wcsncpy wcsnicmp wcspbrk wcsrchr wcsspn wcsstr wcstod wcstok wcstol wcstoul wcstoull) + +if test "$ac_cv_func_wcstok" = yes; then +dnl The wcstok() function varies with standards. Check which one we have. +AC_MSG_CHECKING([for 2- or 3-param wcstok]) +AC_LINK_IFELSE([AC_LANG_PROGRAM( + [[ +#include + ]], + [[ + wchar_t str[] = L"junk"; + const wchar_t delim[] = L"\t\n"; + wchar_t *ptr; + wchar_t *p = wcstok (str, delim, &ptr); + ]])], + [ + AC_DEFINE([ACE_HAS_3_PARAM_WCSTOK], 1, + [Define to 1 if platform has 3 parameter wcstok()]) + AC_MSG_RESULT([3]) + ], + [ + AC_MSG_RESULT([2]) + ]) +fi dnl test "$ac_cv_func_wcstok" = yes + +dnl Check for SYSV IPC functions +dnl +dnl Although Darwin/OS X does not implement any of the SysV IPC API, +dnl its C library contains stubs for all the system calls (probably +dnl left over from the BSD libc). This causes false positives from +dnl AC_CHECK_FUNC which results in configure reporting that SysV IPC +dnl is supported. We avoid this problem by avoiding the function +dnl checks if the cooresponding headers were not detected earlier. +dnl +if test "$ac_cv_header_sys_msg_h" = yes; then + AC_CHECK_FUNC([msgctl],,) + + AC_CHECK_FUNC([msgget],,) + + AC_CHECK_FUNC([msgrcv],,) +fi dnl test "$ac_cv_header_sys_msg_h" = yes + +if test "$ac_cv_header_sys_sem_h" = yes; then + AC_CHECK_FUNC([semctl],,) + + AC_CHECK_FUNC([semget],,) + + AC_CHECK_FUNC([semop],,) +fi dnl test "$ac_cv_header_sys_sem_h" = yes + +if test "$ac_cv_header_sys_shm_h" = yes; then + AC_CHECK_FUNC([shmat],,) + + AC_CHECK_FUNC([shmctl],,) + + AC_CHECK_FUNC([shmdt],,) + + AC_CHECK_FUNC([shmget],,) +fi dnl test "$ac_cv_header_sys_shm_h" = yes + +dnl End check for SYSV IPC functions + +AC_CHECK_FUNC([read_real_time], + [AC_DEFINE([ACE_HAS_AIX_HI_RES_TIMER])],) + +dnl See shm_open() test after this one ... +dnl AC_CHECK_FUNC([shm_open], [AC_DEFINE([ACE_HAS_SHM_OPEN])],) + +dnl Use a more comprehensive test for shm_open() since the prototype +dnl may not be visible on all platforms without enabling POSIX.1b +dnl support (e.g. when the user defines _POSIX_C_SOURCE > 2). +AC_MSG_CHECKING([for shm_open]) +AC_LINK_IFELSE([AC_LANG_PROGRAM( + [[ +#ifndef ACE_LACKS_SYS_TYPES_H +# include +#endif +#include +#include +#include + ]], + [[ + const char name[] = "Foo"; + const int oflag = O_RDONLY; + const mode_t mode = 0400; /* Whatever */ + const int fd = shm_open (name, oflag, mode); + ]])], + [ + AC_DEFINE([ACE_HAS_SHM_OPEN]) + AC_MSG_RESULT([yes]) + + dnl Now see if running it requires a leading slash. + ACE_CACHE_CHECK([if shm_open requires one slash], + [ace_cv_shm_open_requires_one_slash], + [ + AC_RUN_IFELSE([AC_LANG_SOURCE([[ +#ifndef ACE_LACKS_SYS_TYPES_H +# include +#endif +#include +#include +#include +#include + +int main (int argc, char *argv[]) +{ + const char name[] = "ACE_Foo"; + const char name2[] = "/ACE_Foo"; + const int oflag = O_RDWR | O_CREAT; + const mode_t mode = 0400; /* Whatever */ + int fd = shm_open (name, oflag, mode); + if (fd != -1) + { + close (fd); + shm_unlink (name); + return 1; /* Don't need the slash */ + } + fd = shm_open (name2, oflag, mode); + if (fd != -1) + { + close (fd); + shm_unlink (name2); + return 0; + } + return 1; /* Nothing worked, so say 'no' */ +} + ]])],[ + ace_cv_shm_open_requires_one_slash=yes + ],[ + ace_cv_shm_open_requires_one_slash=no + ],[ + dnl action if cross-compiling + ace_cv_shm_open_requires_one_slash=no + ]) + ],AC_DEFINE([ACE_SHM_OPEN_REQUIRES_ONE_SLASH]),) + ], + [ + AC_MSG_RESULT([no]) + ]) + +dnl if test "$ace_cv_shm_open_requires_one_slash" = yes; then +dnl AC_DEFINE([ACE_SHM_OPEN_REQUIRES_ONE_SLASH]) +dnl fi + +ACE_CHECK_HAS_FUNCS(snprintf) + +ACE_CHECK_LACKS_FUNCS(tempnam truncate) + +dnl Save the cache for debugging purposes +AC_CACHE_SAVE + +dnl Check for POSIX Semaphore functions +dnl We only check for a few of them since some platforms don't have these. +dnl On some platforms, a separate library is required, so use AC_SEARCH_LIBS +dnl instead of AC_CHECK_FUNC. This will add any needed library to LIBS. +AC_SEARCH_LIBS([sem_init],rt,[ace_cv_func_sem_init=yes],,) +AC_SEARCH_LIBS([sem_destroy],rt,[ace_cv_func_sem_destroy=yes],,) + +if test "$ace_cv_func_sem_init" = yes && + test "$ace_cv_func_sem_destroy" = yes && + test "$ace_cv_type_sem_t" = yes; then + +dnl Only enable POSIX semaphore support if process shared semaphores +dnl are supported. Presumably process shared semaphores are only +dnl available if the _POSIX_THREAD_PROCESS_SHARED macro is defined by +dnl the platform. + AC_EGREP_CPP([WE_HAVE_SHARED_POSIX_SEMAPHORES], + [ +#ifndef _REENTRANT +#define _REENTRANT +#endif + +#ifndef _THREAD_SAFE +#define _THREAD_SAFE +#endif + +#ifndef ACE_LACKS_UNISTD_H +# include /* needed for _POSIX_THREAD_PROCESS_SHARED */ +#endif + +#include +#include + +#if defined (_POSIX_THREAD_PROCESS_SHARED) +WE_HAVE_SHARED_POSIX_SEMAPHORES +#endif + ], + [ + AC_DEFINE([ACE_HAS_POSIX_SEM]) + + AC_CHECK_FUNC([sem_open]) + AC_CHECK_FUNC([sem_close]) + AC_CHECK_FUNC([sem_unlink]) + if test "$ac_cv_func_sem_open" = no || + test "$ac_cv_func_sem_close" = no || + test "$ac_cv_func_sem_unlink" = no; then + + AC_DEFINE([ACE_LACKS_NAMED_POSIX_SEM]) + else + dnl Check if it works! For example, in glibc 2.x sem_open exists + dnl but it appears to be a stub. However, it isn't listed as a + dnl stub in so the configure script thinks it is + dnl implemented! + ACE_CACHE_CHECK([if sem_open works], + [ace_cv_sem_open_works], + [ + AC_RUN_IFELSE([AC_LANG_SOURCE([[ +#ifndef ACE_LACKS_SYS_TYPES_H +#include +#endif + +#include +#include + +#include /* for definition of "NULL" */ + +#include + +#ifndef SEM_FAILED +# define SEM_FAILED ((sem_t *) -1) +#endif + +int +main () +{ + sem_t *s = 0; + + s = sem_open ("ace_semaphore_foo", O_CREAT | O_EXCL, 0600, 1); + if (s == SEM_FAILED) + return -1; /* FAILURE */ + + sem_unlink ("ace_semaphore_foo"); + if (sem_close (s) != 0) + return -1; /* Something went wrong! */ + + return 0; +} + ]])],[ + ace_cv_sem_open_works=yes + ],[ + ace_cv_sem_open_works=no + ],[ + dnl action if cross-compiling + ace_cv_sem_open_works=yes + ]) + ],, [AC_DEFINE([ACE_LACKS_NAMED_POSIX_SEM])]) + fi + ],) + +fi dnl check for POSIX Semaphore functions + +dnl If we have POSIX semaphores available, check to see if we also have +dnl the timed wait capability. +if test "$ac_cv_func_sem_open" = yes && + test "$ac_cv_func_sem_close" = yes && + test "$ac_cv_func_sem_unlink" = yes; then + dnl Check if sem_timedwait() works - often it compiles and will run + dnl but if called return ENOTSUP. In that case, we don't want it. + ACE_CACHE_CHECK([if sem_timedwait works], + [ace_cv_sem_timedwait_works], + [ + AC_RUN_IFELSE([AC_LANG_SOURCE([[ +#ifndef ACE_LACKS_SYS_TYPES_H +#include +#endif + +#include +#include +#include +#include /* for definition of "NULL" */ +#if !defined (ACE_LACKS_ERRNO_H) +# include +#endif +#include + +#ifndef SEM_FAILED +# define SEM_FAILED ((sem_t *) -1) +#endif + +int +main () +{ + sem_t *s = 0; + struct timespec tmo; + int status = 0; + s = sem_open ("ace_semaphore_foo", O_CREAT, 0600, 1); + if (s == SEM_FAILED) + return -1; /* FAILURE */ + + /* Don't care about the time, only whether the call works */ + tmo.tv_sec = 0; + tmo.tv_nsec = 0; + if (sem_timedwait (s, &tmo) == -1) + { + if (errno == ENOTSUP) + status = -1; + } + else + sem_post (s); + + sem_unlink ("ace_semaphore_foo"); + sem_close (s); + + return status; +} + ]])],[ + ace_cv_sem_timedwait_works=yes + ],[ + ace_cv_sem_timedwait_works=no + ],[ + dnl action if cross-compiling + ace_cv_sem_timedwait_works=yes + ]) + ], + [AC_DEFINE([ACE_HAS_POSIX_SEM_TIMEOUT])],) +fi + + +dnl The following tests are performed only when the user has enabled +dnl support for threads. + +dnl NOTE: Make sure the thread library is in "LIBS" +dnl (e.g.: LIBS="$LIBS -lpthread") +dnl otherwise the below thread "CHECK_FUNCs" +dnl will not work correctly. +if test "$ace_user_enable_threads" = yes; then + + if test "$ace_has_pthreads" = yes; then +dnl Digital UNIX 4.0 "mangles" the following pthread functions: +dnl pthread_attr_getguardsize_np +dnl pthread_attr_getinheritsched +dnl pthread_attr_getstacksize +dnl pthread_attr_setguardsize_np +dnl pthread_attr_setinheritsched +dnl pthread_attr_setstacksize +dnl pthread_cancel +dnl pthread_cond_broadcast +dnl pthread_cond_destroy +dnl pthread_cond_init +dnl pthread_cond_sig_preempt_int_np +dnl pthread_cond_signal +dnl pthread_cond_signal_int_np +dnl pthread_cond_timedwait +dnl pthread_cond_wait +dnl pthread_create +dnl pthread_delay_np +dnl pthread_detach +dnl pthread_equal +dnl pthread_exit +dnl pthread_get_expiration_np +dnl pthread_getspecific +dnl pthread_join +dnl pthread_lock_global_np +dnl pthread_mutex_destroy +dnl pthread_mutex_init +dnl pthread_mutex_lock +dnl pthread_mutex_trylock +dnl pthread_mutex_unlock +dnl pthread_once +dnl pthread_self +dnl pthread_setspecific +dnl pthread_testcancel +dnl pthread_unlock_global_np +dnl These functions have a double underscore "__" prepended to maintain +dnl backwards compatibility with Pthread Draft 4 functions of the same +dnl name. + + ACE_CHECK_LACKS_FUNCS(pthread_sigmask) + if test $ac_cv_func_pthread_sigmask = yes; then + AC_CHECK_DECL([pthread_sigmask], + [AC_DEFINE([ACE_HAS_PTHREAD_SIGMASK_PROTOTYPE], 1, + [Define to 1 if platform has the declaration + of pthread_sigmask().])], + [], + [#include + #include ]) + fi + + AC_CHECK_FUNC([pthread_key_create], + [AC_DEFINE([ACE_HAS_THREAD_SPECIFIC_STORAGE])], + [ + AC_CHECK_FUNC([pthread_keycreate], + [AC_DEFINE(ACE_HAS_THREAD_SPECIFIC_STORAGE)], + [AC_DEFINE(ACE_HAS_TSS_EMULATION)]) + ]) + + ACE_CHECK_HAS_FUNCS(pthread_condattr_setkind_np) + ACE_CHECK_HAS_FUNCS(pthread_mutexattr_setkind_np) + + dnl Can't use ACE_CHECK_LACKS_FUNCS because the macro doesn't match the + dnl tested function name. + AC_CHECK_FUNC([pthread_condattr_setpshared], + , + [AC_DEFINE([ACE_LACKS_CONDATTR_PSHARED])]) + + dnl ACE_CHECK_LACKS_FUNCS(pthread_attr_setstack) + dnl Can't use ACE_CHECK_LACKS_FUNCS because the lower-down AC macros build + dnl a program with a stubbed-out pthread_attr_setstack(), avoiding the need + dnl to see pthread_attr_setstack() in pthreads.h. This is usually not a + dnl problem since the link will fail. However, on HP-UX 11iv2 there is a + dnl pthread_attr_setstack() in libpthread, but not in the header. Thus, + dnl the test passes, but ACE build fails. Don't hack in use of this until + dnl HP sees fit to include it in pthread.h (which it does at 11iv3). + AC_MSG_CHECKING([for pthread_attr_setstack]) + AH_TEMPLATE([ACE_LACKS_PTHREAD_ATTR_SETSTACK], + [Define to 1 if platform lacks pthread_attr_setstack()]) + AC_LINK_IFELSE([AC_LANG_PROGRAM( + [[ +#include + ]], + [[ + pthread_attr_t attr; + void *stack; + size_t size; + pthread_attr_setstack (&attr, stack, size); + ]])], + [ + AC_MSG_RESULT([yes]) + ], + [ + AC_MSG_RESULT([no]) + AC_DEFINE([ACE_LACKS_PTHREAD_ATTR_SETSTACK]) + ]) + + ACE_CHECK_LACKS_FUNCS(pthread_attr_setstackaddr) + ACE_CHECK_LACKS_FUNCS(pthread_attr_setstacksize) + + ACE_CHECK_FUNC([pthread_cancel], [pthread.h], + [ + dnl Make sure the prototype actually exists. Some platforms, + dnl such as FreeBSD 4, appear to have a missing prototype. If + dnl the prototype is missing, then don't use pthread_cancel. + dnl Creating a prototype for it in ACE is probably a bad idea. + + ace_save_CPPFLAGS="$CPPFLAGS" + CPPFLAGS="$CPPFLAGS $ACE_THR_CPPFLAGS" + + AC_EGREP_HEADER([pthread_cancel], [pthread.h],, + [ + AC_DEFINE([ACE_LACKS_PTHREAD_CANCEL]) + ]) + + dnl Reset the preprocessor flags + CPPFLAGS="$ace_save_CPPFLAGS" + ], + [ + AC_DEFINE([ACE_LACKS_PTHREAD_CANCEL]) + ]) + + ACE_CHECK_LACKS_FUNCS(pthread_yield) + ACE_CHECK_LACKS_FUNCS(pthread_thr_sigsetmask) + + AC_CHECK_FUNC([pthread_attr_setdetachstate], + , + [AC_DEFINE([ACE_LACKS_SETDETACH])]) + + dnl ACE currently doesn't provide enough fine grained control over + dnl these functions so both must be present in order to prevent + dnl ACE_LACKS_SETSCHED from being defined. + AC_CHECK_FUNC([sched_setscheduler], + [ + AC_CHECK_FUNC([pthread_attr_setschedpolicy],, + [AC_CHECK_FUNC([pthread_attr_setsched],, + [AC_DEFINE([ACE_LACKS_SETSCHED])])]) + ], + [ + AC_DEFINE([ACE_LACKS_SETSCHED]) + ]) + + AC_CHECK_FUNC([pthread_attr_setscope], + , + [AC_DEFINE([ACE_LACKS_THREAD_PROCESS_SCOPING])]) + + AC_CHECK_FUNC([pthread_mutexattr_setpshared], + , + [AC_DEFINE([ACE_LACKS_MUTEXATTR_PSHARED])]) + +dnl Check for POSIX Threads Draft 4 functions + AC_CHECK_FUNC([pthread_mutexattr_create],,) + AC_CHECK_FUNC([pthread_mutexattr_delete],,) + AC_CHECK_FUNC([pthread_condattr_delete],,) + AC_CHECK_FUNC([pthread_condattr_create],,) + AC_CHECK_FUNC([pthread_setprio],,) + AC_CHECK_FUNC([pthread_getprio],,) + AC_CHECK_FUNC([pthread_setcancel],,) + AC_CHECK_FUNC([pthread_setasynccancel],,) + AC_CHECK_FUNC([pthread_kill],,) +dnl Check for POSIX Threads Draft 6 functions + AC_CHECK_FUNC([pthread_attr_setprio],,) + AC_CHECK_FUNC([pthread_attr_getprio],,) + AC_CHECK_FUNC([pthread_setintr],,) + AC_CHECK_FUNC([pthread_setintrtype],,) +dnl Check for POSIX threads Draft 6, 7 and Standard common functions + AC_CHECK_FUNC([pthread_mutexattr_init],,) + AC_CHECK_FUNC([pthread_mutexattr_destroy],,) + AC_CHECK_FUNC([pthread_condattr_init],,) + AC_CHECK_FUNC([pthread_condattr_destroy],,) +dnl Check for POSIX Threads Draft 7 and Draft Standard common functions + AC_CHECK_FUNC([pthread_setschedparam],,) + AC_CHECK_FUNC([pthread_getschedparam],,) + AC_CHECK_FUNC([pthread_setcancelstate],,) + AC_CHECK_FUNC([pthread_setcanceltype],,) +dnl Check for POSIX Threads Draft Standard functions +dnl sched_yield() is in the C library or perhaps in "-lposix4." +dnl We need to add other library checks in this script's "check libraries" +dnl section if it is in another library. +dnl AC_CHECK_FUNC(sched_yield,,) +dnl We already check for this during the library checks. + +dnl Check for Unix98 pthreads extensions + ACE_CACHE_CHECK([for struct pthread_rwlock_t], + [ace_cv_struct_pthread_rwlock_t], + [ + dnl Since we are checking for pthread_rwlock_t in more than one header + dnl we can't use the ACE_CHECK_STRUCT macro so we have to do things + dnl manually. + ACE_TRY_COMPILE_STRUCT([pthread_rwlock_t], [pthread.h], + [ + ace_cv_struct_pthread_rwlock_t=yes + ], + [ + ACE_TRY_COMPILE_STRUCT([pthread_rwlock_t], [sys/types.h], + [ + ace_cv_struct_pthread_rwlock_t=yes + ], + [ + ace_cv_struct_pthread_rwlock_t=no + ]) + ]) + ],,) + + ACE_CACHE_CHECK([for struct pthread_rwlockattr_t], + [ace_cv_struct_pthread_rwlockattr_t], + [ + dnl Since we are checking for pthread_rwlockattr_t in more than one + dnl header, we can't use the ACE_CHECK_STRUCT macro so we have to do + dnl things manually. + ACE_TRY_COMPILE_STRUCT([pthread_rwlockattr_t], [pthread.h], + [ + ace_cv_struct_pthread_rwlockattr_t=yes + ], + [ + ACE_TRY_COMPILE_STRUCT([pthread_rwlockattr_t], [sys/types.h], + [ + ace_cv_struct_pthread_rwlockattr_t=yes + ], + [ + ace_cv_struct_pthread_rwlockattr_t=no + ]) + ]) + ],,) + + ACE_CHECK_HAS_FUNCS(pthread_continue pthread_continue_np pthread_resume_np pthread_suspend pthread_suspend_np) + ACE_CHECK_HAS_FUNCS(pthread_getconcurrency pthread_setconcurrency) + ACE_CHECK_HAS_FUNCS(pthread_attr_setcreatesuspend_np) + +dnl Don't test for pthread_getaffinity_np() or pthread_setaffinity_np() +dnl if the system doesn't also have cpu_set_t. The functions are almost +dnl certainly incompatible with our wrapper facade, as we use a "dummy" +dnl cpu_set_t defined in ace/os_include/os_sched.h. +if test "$ac_cv_type_cpu_set_t" = yes; then + ACE_CHECK_HAS_FUNCS(pthread_getaffinity_np pthread_setaffinity_np) +fi + +dnl Linux's sched_{set,get}affinity interface has changed three times: +dnl +dnl In glibc 2.3.2, it was: +dnl +dnl int sched_setaffinity(pid_t __pid, +dnl unsigned int __len, unsigned long * __mask); +dnl +dnl In glibc 2.3.3, it was changed to: +dnl +dnl int sched_setaffinity(pid_t __pid, const cpu_set_t* __mask); +dnl +dnl And in glibc ?.?.?, it was changed again to: +dnl +dnl int sched_setaffinity(pid_t __pid, size_t __cpusetsize, +dnl const cpu_set_t* __cpuset); +dnl +dnl The following feature tests attempt to determine which (if any) +dnl version is supported by the system. A further complication is +dnl that the C library may support one version, the kernel may not, +dnl and vice versa. +dnl +dnl As of this writing, ACE's ACE_OS::sched_setaffinity() wrapper +dnl facade implementation only supports the latter two varients. So +dnl if the system doesn't define cpu_set_t, we simply avoid checking +dnl for sched_setaffinity(). No attempt is made to verify C library / +dnl kernel consistency. +dnl +dnl The "right" thing to do is to implement something similar to the +dnl PLPA (Portable Linux Processor Affinity) Library, converting the +dnl arguments and invoking the syscall directly (instead of calling +dnl the C library wrapper). +dnl + +if test "$ac_cv_type_cpu_set_t" = yes; then + + ACE_CHECK_HAS_FUNCS(sched_getaffinity) +if test "$ac_cv_func_sched_getaffinity" = yes; then +dnl The sched_getaffinity() function varies between linux versions +dnl Check which one we have. +AC_MSG_CHECKING([for 2- or 3-param sched_getaffinity]) +AC_LINK_IFELSE([AC_LANG_PROGRAM( + [[ +#if !defined(ACE_LACKS_SYS_TYPES_H) +#include +#endif +#if !defined(ACE_LACKS_SCHED_H) +#include +#endif + ]], + [[ + pid_t pid; + cpu_set_t cpuset; + sched_getaffinity(pid, sizeof(cpuset), &cpuset); + ]])], + [ + AC_MSG_RESULT([3]) + ], + [ + AC_MSG_RESULT([2]) + AC_DEFINE([ACE_HAS_2_PARAM_SCHED_GETAFFINITY], 1, + [Define to 1 if platform has 2 parameter sched_getaffinity()]) + ]) +fi dnl test "$ac_cv_func_sched_getaffinity" = yes + + ACE_CHECK_HAS_FUNCS(sched_setaffinity) +if test "$ac_cv_func_sched_setaffinity" = yes; then +dnl The sched_setaffinity() function varies between linux versions +dnl Check which one we have. +AC_MSG_CHECKING([for 2- or 3-param sched_setaffinity]) +AC_LINK_IFELSE([AC_LANG_PROGRAM( + [[ +#if !defined(ACE_LACKS_SYS_TYPES_H) +#include +#endif +#if !defined(ACE_LACKS_SCHED_H) +#include +#endif + ]], + [[ + pid_t pid; + cpu_set_t cpuset; + sched_setaffinity(pid, sizeof(cpuset), &cpuset); + ]])], + [ + AC_MSG_RESULT([3]) + ], + [ + AC_MSG_RESULT([2]) + AC_DEFINE([ACE_HAS_2_PARAM_SCHED_SETAFFINITY], 1, + [Define to 1 if platform has 2 parameter sched_setaffinity()]) + ]) +fi dnl test "$ac_cv_func_sched_setaffinity" = yes + +fi dnl test "$ac_cv_type_cpu_set_t" = yes + + AC_CHECK_FUNC([pthread_rwlock_init],,) + AC_CHECK_FUNC([pthread_rwlock_destroy],,) + AC_CHECK_FUNC([pthread_rwlock_rdlock],,) + AC_CHECK_FUNC([pthread_rwlock_wrlock],,) + AC_CHECK_FUNC([pthread_rwlock_unlock],,) + AC_CHECK_FUNC([pthread_rwlock_tryrdlock],,) + AC_CHECK_FUNC([pthread_rwlock_trywrlock],,) + AC_CHECK_FUNC([pthread_rwlockattr_init],,) + AC_CHECK_FUNC([pthread_rwlockattr_destroy],,) + AC_CHECK_FUNC([pthread_rwlockattr_setpshared], + , + [AC_DEFINE([ACE_LACKS_RWLOCKATTR_PSHARED])]) + + if test "$ace_cv_struct_pthread_rwlock_t" = yes && + test "$ace_cv_struct_pthread_rwlockattr_t" = yes && + test "$ac_cv_func_pthread_rwlock_init" = yes && + test "$ac_cv_func_pthread_rwlock_destroy" = yes && + test "$ac_cv_func_pthread_rwlock_rdlock" = yes && + test "$ac_cv_func_pthread_rwlock_wrlock" = yes && + test "$ac_cv_func_pthread_rwlock_unlock" = yes && + test "$ac_cv_func_pthread_rwlock_tryrdlock" = yes && + test "$ac_cv_func_pthread_rwlock_trywrlock" = yes && + test "$ac_cv_func_pthread_rwlockattr_init" = yes && + test "$ac_cv_func_pthread_rwlockattr_destroy" = yes; then + AC_DEFINE([ACE_HAS_PTHREADS_UNIX98_EXT]) + fi dnl Unix98 pthreads extensions + +dnl Check if platform has thread_self() rather than pthread_self() + ACE_CHECK_FUNC([pthread_self], [pthread.h], + , + [ + AC_CHECK_FUNC([thread_self], + [ + AC_DEFINE([ACE_HAS_THREAD_SELF]) + ],) + ]) + +dnl Check if pthread.h declares an enum with PTHREAD_PROCESS_PRIVATE and +dnl PTHREAD_PROCESS_SHARED values. + ACE_CACHE_CHECK([for PTHREAD_PROCESS_* enumeration in pthread.h], + [ace_cv_lib_pthread_process_enum], + [ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#include + ]], [[ +/* Undefine PTHREAD_PROCESS_SHARED in case some platforms #define it */ +#undef PTHREAD_PROCESS_SHARED +int foo = PTHREAD_PROCESS_SHARED; + ]])],[ + ace_cv_lib_pthread_process_enum=yes + ],[ + ace_cv_lib_pthread_process_enum=no + ]) + ], + [ + AC_DEFINE([ACE_HAS_PTHREAD_PROCESS_ENUM]) + ],) + +dnl Check if pthread_create requires an extern "C" start routine +ACE_CONVERT_WARNINGS_TO_ERRORS( +[ +ACE_CACHE_CHECK([if pthread_create requires an extern "C" start routine], + [ace_cv_lib_pthread_c_func],[ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#include + +void *ace_start_routine(void *); + ]], [[ +pthread_create(0, 0, ace_start_routine, 0); + ]])],[ + ace_cv_lib_pthread_c_func=no + ],[ + dnl Check if extern "C" start routine is required. + AC_COMPILE_IFELSE([AC_LANG_PROGRAM( + [[ +#include + +extern "C" void *ace_start_routine(void *); + ]], + [[ +pthread_create(0, 0, ace_start_routine, 0); + ]])], + [ + ace_cv_lib_pthread_c_func=yes + ], + [ + ace_cv_lib_pthread_c_func=no + ]) + ]) + ], + [ + AC_DEFINE([ACE_HAS_THR_C_FUNC]) + ],) +]) dnl ACE_CONVERT_WARNINGS_TO_ERRORS + +dnl Check if pthread_key_create has a standard arg thread destructor +ACE_CACHE_CHECK([if pthread_key_create has std arg thread destructor], + [ace_cv_lib_pthread_stdarg_dest],[ + if test "$ac_cv_func_pthread_key_create" = yes; then + ace_pthread_key_create=pthread_key_create + else + ace_pthread_key_create=pthread_keycreate + fi + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#include + +void ace_destructor(void *); + ]], [[ +${ace_pthread_key_create}(0, ace_destructor); + ]])],[ + ace_cv_lib_pthread_stdarg_dest=no + ],[ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM( + [[ +#include + +void ace_destructor(...); + ]], + [[ +${ace_pthread_key_create}(0, ace_destructor); + ]])], + [ + ace_cv_lib_pthread_stdarg_dest=yes + ], + [ + ace_cv_lib_pthread_stdarg_dest=no + ]) + ]) + ], + [ + AC_DEFINE([ACE_HAS_STDARG_THR_DEST]) + ],) + +dnl Check if pthread_key_create requires an extern "C" start routine +ACE_CONVERT_WARNINGS_TO_ERRORS([ +ACE_CACHE_CHECK([if pthread_key_create requires an extern "C" start routine], + [ace_cv_lib_pthread_c_dest],[ + if test "$ac_cv_func_pthread_key_create" = yes; then + ace_pthread_key_create=pthread_key_create + else + ace_pthread_key_create=pthread_keycreate + fi + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#include + +void ace_destructor(void *); + ]], [[ +${ace_pthread_key_create}(0, ace_destructor); + ]])],[ + ace_cv_lib_pthread_c_dest=no + ],[ + dnl Check if extern "C" start routine is required. + AC_COMPILE_IFELSE([AC_LANG_PROGRAM( + [[ +#include + +extern "C" void ace_destructor(void *); + ]], + [[ +${ace_pthread_key_create}(0, ace_destructor); + ]])], + [ + ace_cv_lib_pthread_c_dest=yes + ], + [ + ace_cv_lib_pthread_c_dest=no + ]) + ]) + ], + [ + AC_DEFINE([ACE_HAS_THR_C_DEST]) + ],) +]) dnl ACE_CONVERT_WARNINGS_TO_ERRORS + + +AC_CHECK_FUNC([sched_get_priority_min],, + [ +dnl Check if the PTHREAD_MIN_PRIORITY constant exists. + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#include + ]], [[ + int p = (int) PTHREAD_MIN_PRIORITY; + ]]) + ], + [ + dnl Since we have PTHREAD_MIN_PRIORITY, denote that PX_PRIO_MIN + dnl should not be used. + ace_has_px_prio_min=no + ], + [ + dnl PTHREAD_MIN_PRIORITY doesn't appear to be defined, so + dnl check if the platform defines PX_PRIO_MIN, instead. + + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#include + ]], [[ + int p = (int) PX_PRIO_MIN; + ]])], + [ + ace_has_px_prio_min=yes + ], + [ + ace_has_px_prio_min=no + ]) + ]) + ]) + + if test "$ace_has_px_prio_min" = yes; then + AC_DEFINE([PTHREAD_MIN_PRIORITY], + [PX_PRIO_MIN], + [Minimum thread priority]) + fi + +AC_CHECK_FUNC([sched_get_priority_max],, + [ +dnl Check if the PTHREAD_MAX_PRIORITY constant exists. + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#include + ]], [[ + int p = (int) PTHREAD_MAX_PRIORITY; + ]]) + ], + [ + dnl Since we have PTHREAD_MAX_PRIORITY, denote that PX_PRIO_MAX + dnl should not be used. + ace_has_px_prio_max=no + ], + [ + dnl PTHREAD_MAX_PRIORITY doesn't appear to be defined, so + dnl check if the platform defines PX_PRIO_MAX, instead. + + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#include + ]], [[ + int p = (int) PX_PRIO_MAX; + ]])], + [ + ace_has_px_prio_max=yes + ], + [ + ace_has_px_prio_max=no + ]) + ]) + ]) + + if test "$ace_has_px_prio_max" = yes; then + AC_DEFINE([PTHREAD_MAX_PRIORITY], + [PX_PRIO_MAX], + [Maximum thread priority]) + fi + + fi dnl test "$ace_has_pthreads" = yes + + if test "$ace_has_sthreads" = yes; then +dnl Only check for these functions if we have the UNIX International +dnl Threads library "thread." + AC_CHECK_FUNC([thr_keycreate], + [AC_DEFINE([ACE_HAS_THREAD_SPECIFIC_STORAGE])], + [AC_DEFINE([ACE_HAS_TSS_EMULATION])]) + + AC_CHECK_FUNC([thr_yield], + [AC_DEFINE([ACE_HAS_THR_YIELD])],) + + AC_CHECK_FUNC([thr_keydelete], + [AC_DEFINE([ACE_HAS_THR_KEYDELETE])],) + + AC_CHECK_FUNC([thr_min_stack],[], + [ + AC_CHECK_FUNC([thr_minstack], + [AC_DEFINE([ACE_HAS_THR_MINSTACK])],) + ]) + + fi dnl test "$ace_has_sthreads" = yes + +fi dnl test "$ace_user_enable_threads" = yes + +dnl +dnl By Eric: +dnl ACE will define a sigwait function if we lie and say we don't have +dnl one. Unfortunately, the ACE function may conflict with our +dnl function, so we'll go ahead and turn this on, even if we are +dnl ignoring threads. +ACE_CHECK_HAS_FUNCS(sigwait) + + +dnl Check for reentrant functions +if test "$ace_user_enable_reentrant_funcs" = yes; then + AC_CHECK_FUNC([rand_r]) + + AC_CHECK_FUNC([strtok_r], + [ + dnl Check if _POSIX_SOURCE macro is needed to make the strtok_r() + dnl prototype visible. + ACE_CACHE_CHECK([for strtok_r prototype], + [ace_cv_lib_has_strtok_r_prototype], + [ + ace_save_CPPFLAGS="$CPPFLAGS" + ace_no_posix="-U_POSIX_SOURCE $ACE_THR_CPPFLAGS" + CPPFLAGS="$CPPFLAGS $ace_no_posix" + AC_EGREP_HEADER([[^_]+strtok_r], [string.h], + [ + ace_cv_lib_has_strtok_r_prototype=yes + ], + [ + ace_cv_lib_has_strtok_r_prototype=no + ]) + dnl Reset the preprocessor flags + CPPFLAGS="$ace_save_CPPFLAGS" + ],, [AC_DEFINE([ACE_LACKS_STRTOK_R_PROTOTYPE])]) + ],) + + AC_CHECK_FUNC([getpwnam_r], + [ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#ifndef _REENTRANT +# define _REENTRANT +#endif +#ifndef ACE_LACKS_PWD_H +# include +#endif +#ifndef ACE_LACKS_SYS_TYPES_H +# include +#endif + ]], + [[ + const char * name; + struct passwd * pwent; + char * buffer; + int buflen; + struct passwd * result; + + int status = getpwnam_r (name, pwent, buffer, buflen, &result); + ]])], + [ + if test "$ace_user_enable_reentrant_funcs" = yes; then + AC_DEFINE([ACE_HAS_POSIX_GETPWNAM_R]) + fi + ], + [ + dnl Nothing to do! + ]) + ], + [AC_DEFINE([ACE_LACKS_PWD_REENTRANT_FUNCTIONS])]) + + AC_CHECK_FUNC([ctime_r],,) + + AC_CHECK_FUNC([localtime_r],,) + + AC_CHECK_FUNC([gmtime_r],,) + + AC_CHECK_FUNC([asctime_r],,) + + AC_CHECK_FUNC([getprotobyname_r],,) + + AC_CHECK_FUNC([getprotobynumber_r],,) + + AC_CHECK_FUNC([gethostbyaddr_r],,) + + AC_CHECK_FUNC([gethostbyname_r],,) + + AC_CHECK_FUNC([getservbyname_r],,) +fi dnl End checks for reentrant functions + + +ACE_CHECK_LACKS_FUNCS(readdir_r) +if test "$ac_cv_func_readdir_r" = yes; then +dnl The readdir_r() function varies with standards. Check which one we have. +AC_MSG_CHECKING([for 2- or 3-param readdir_r]) +AC_LINK_IFELSE([AC_LANG_PROGRAM( + [[ +#include + ]], + [[ +readdir_r(0, 0, 0); + ]])], + [ + AC_DEFINE([ACE_HAS_3_PARAM_READDIR_R], 1, + [Define to 1 if platform has 3 parameter readdir_r()]) + AC_MSG_RESULT([3]) + ], + [ + AC_MSG_RESULT([2]) + ]) +fi dnl test "$ac_cv_func_readdir" = yes + + +dnl Disabled until we figure out what to do with the comparator +dnl function argument inconsistencies between different platforms. +dnl For example: +dnl int comparator (const void * d1, const void * d2) +dnl instead of: +dnl int comparator (const dirent ** d1, const dirent ** d2) +dnl +dnl ACE_CHECK_HAS_FUNCS([scandir]) + +ACE_CHECK_LACKS_FUNCS(seekdir telldir) + + +dnl +dnl SECTION 11: checks for function characteristics +dnl + +ACE_CONVERT_WARNINGS_TO_ERRORS([ +dnl Check if dlopen takes a char * arg instead of const char * + if test "$ace_has_svr4_dynamic_linking" = yes; then + ACE_CACHE_CHECK([if dlopen takes a char *], + [ace_cv_lib_charptr_dl], + [ + dnl Check if it takes a const char *, first. + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#include + ]], [[ + const char *filename = 0; + int flag = 0; + void *ptr = dlopen(filename, flag); + ]])],[ + ace_cv_lib_charptr_dl=no + ],[ + dnl Now check if it takes a non-const char *. + AC_COMPILE_IFELSE([AC_LANG_PROGRAM( + [[ +#include + ]], + [[ + char *filename = 0; + int flag = 0; + void *ptr = dlopen(filename, flag); + ]])], + [ + ace_cv_lib_charptr_dl=yes + ], + [ + ace_cv_lib_charptr_dl=no + ]) + ]) + ], [AC_DEFINE([ACE_HAS_CHARPTR_DL])],) + fi dnl test "$ace_has_svr4_dynamic_linking" = yes +]) dnl ACE_CONVERT_WARNINGS_TO_ERRORS + +ACE_CONVERT_WARNINGS_TO_ERRORS([ +dnl Check if "getby" functions use a non-const char * argument + if test "$ac_cv_func_gethostbyaddr" = yes; then + ACE_CACHE_CHECK(["getby" functions take a non-const char *], + [ace_cv_lib_nonconst_getby], + [ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#include + ]], [[ + char *addr = 0; + int len = 0; + int type = 0; + struct hostent *mystruct = 0; + + mystruct = gethostbyaddr(name, len, type); + ]])],[ + ace_cv_lib_nonconst_getby=yes + ],[ + ace_cv_lib_nonconst_getby=no + ]) + ], [AC_DEFINE([ACE_HAS_NONCONST_GETBY])],) + fi dnl test "$ac_cv_func_gethostbyaddr" = yes +]) dnl ACE_CONVERT_WARNINGS_TO_ERRORS + +dnl Check if new throws exception upon failure +if test "$ace_user_enable_exceptions" = yes; then + ACE_CACHE_CHECK([if new throws std::bad_alloc exception on failure], + [ace_cv_new_throws_bad_alloc_exception], + [ + AC_RUN_IFELSE([AC_LANG_SOURCE([[ +#if defined (ACE_HAS_NEW_NO_H) +# include +#elif defined (ACE_HAS_NEW_H) +# include +#endif + +#if defined (ACE_HAS_STDEXCEPT_NO_H) +# include +#elif defined (ACE_HAS_EXCEPTION_H) +# include +#endif + +/* We already checked for ACE_LACKS_NUMERIC_LIMITS */ +#if !defined ACE_LACKS_NUMERIC_LIMITS +#include +#endif + +/* We already checked for ACE_LACKS_SYS_RESOURCE_H */ +#if !defined ACE_LACKS_SYS_RESOURCE_H +#include +#endif + + int main(int, char *[]) { +#if defined ACE_LACKS_NUMERIC_LIMITS + const size_t ALLOC_SIZE = 2 * 1024 * 1024 * 1024; +#else + const size_t ALLOC_SIZE = std::numeric_limits::max () / 2; +#endif + +#if !defined (ACE_LACKS_RLIMIT) + /* set memory limit to the allocation size, so this test + should terminate on the first iteration. */ + struct rlimit rlimit; + if (getrlimit(RLIMIT_DATA, &rlimit) == 0) { + rlimit.rlim_cur = ALLOC_SIZE; + setrlimit(RLIMIT_DATA, &rlimit); + } +#endif + + while (1) { + try { + char *a = new char[ALLOC_SIZE]; + if (a == 0) { + return 1; /* new() does NOT throw exceptions */ + } + } + +#ifdef ACE_USES_STD_NAMESPACE_FOR_STDCPP_LIB + catch (std::bad_alloc) +#else + catch (bad_alloc) +#endif /* ACE_USES_STD_NAMESPACE_FOR_STDCPP_LIB */ + { + return 0; /* new() does throw exceptions */ + } + }; + + return 1; /* ERROR: We shouldn't get this far! */ + } + ]])],[ + ace_cv_new_throws_bad_alloc_exception=yes + ],[ + ace_cv_new_throws_bad_alloc_exception=no + ],[ + ace_cv_new_throws_bad_alloc_exception=no + ]) + ], [AC_DEFINE([ACE_NEW_THROWS_EXCEPTIONS])],) + + if test "$ace_cv_new_throws_bad_alloc_exception" != yes; then + ACE_CACHE_CHECK([if new throws xalloc exception on failure], + [ace_cv_new_throws_xalloc_exception], + [ + AC_RUN_IFELSE([AC_LANG_SOURCE([[ +#if defined (ACE_HAS_NEW_NO_H) +# include +#elif defined (ACE_HAS_NEW_H) +# include +#endif + +#if defined (ACE_HAS_STDEXCEPT_NO_H) +# include +#elif defined (ACE_HAS_EXCEPTION_H) +# include +#endif + +/* We already checked for ACE_LACKS_NUMERIC_LIMITS */ +#if !defined ACE_LACKS_NUMERIC_LIMITS +#include +#endif + +/* We already checked for ACE_LACKS_SYS_RESOURCE_H */ +#if !defined ACE_LACKS_SYS_RESOURCE_H +#include +#endif + + + int main(int, char *[]) { +#if defined ACE_LACKS_NUMERIC_LIMITS + const size_t ALLOC_SIZE = 2 * 1024 * 1024 * 1024; +#else + const size_t ALLOC_SIZE = std::numeric_limits::max () / 2; +#endif + +#if !defined (ACE_LACKS_RLIMIT) + /* set memory limit to the allocation size, so this test + should terminate on the first iteration. */ + struct rlimit rlimit; + if (getrlimit(RLIMIT_DATA, &rlimit) == 0) { + rlimit.rlim_cur = ALLOC_SIZE; + setrlimit(RLIMIT_DATA, &rlimit); + } +#endif + + while (1) { + try { + char *a = new char[ALLOC_SIZE]; + if (a == 0) { + return 1; /* new() does NOT throw exceptions */ + } + } + + catch (xalloc) + { + return 0; /* new() does throw exceptions */ + } + }; + + return 1; /* ERROR: We shouldn't get this far! */ + } + ]])],[ + ace_cv_new_throws_xalloc_exception=yes + ],[ + ace_cv_new_throws_xalloc_exception=no + ],[ + ace_cv_new_throws_xalloc_exception=no + ]) + ], [AC_DEFINE([ACE_NEW_THROWS_EXCEPTIONS])],) + fi dnl ace_cv_new_throws_bad_alloc_exceptions = no +fi dnl $ace_user_enable_exceptions = yes + +AC_CACHE_CHECK([if compiler supports new(std::nothrow)], + [ace_cv_has_new_nothrow], + [AC_COMPILE_IFELSE([AC_LANG_SOURCE([[ +#if defined (ACE_HAS_NEW_NO_H) +# include +#elif defined (ACE_HAS_NEW_H) +# include +#endif + +int main(int, char*[]) { + int *foo; + +#ifdef ACE_USES_STD_NAMESPACE_FOR_STDCPP_LIB + foo = new (std::nothrow) int; +#else + foo = new (nothrow) int; +#endif /* ACE_USES_STD_NAMESPACE_FOR_STDCPP_LIB */ +}]])], [ + ace_cv_has_new_nothrow=yes + ],[ + ace_cv_has_new_nothrow=no + ])]) +if test $ace_cv_has_new_nothrow = yes; then + AC_DEFINE([ACE_HAS_NEW_NOTHROW]) +fi + +ACE_CONVERT_WARNINGS_TO_ERRORS([ +dnl Check if putmsg takes a const struct strbuf * +dnl If we have getmsg() we can be pretty sure that we have putmsg() + if test "$ac_cv_func_getmsg" = yes || + test "$ac_cv_header_stropts_h" = yes; then + ACE_CACHE_CHECK([if putmsg takes a const struct strbuf*], + [ace_cv_lib_const_strbufptr], + [ + dnl Check if it takes a const struct strbuf *, first. + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#include + ]], [[ + int result = 0; + int fd = 0; + const struct strbuf * ace_str = 0; + int flags = 0; + + result = putmsg(fd, ace_str, ace_str, flags); + ]])],[ + ace_cv_lib_const_strbufptr=yes + ],[ + ace_cv_lib_const_strbufptr=no + ]) + ],, [AC_DEFINE([ACE_LACKS_CONST_STRBUF_PTR])]) + fi dnl "$ac_cv_func_getmsg" = yes || "$ac_cv_header_stropts_h" = yes +]) dnl ACE_CONVERT_WARNINGS_TO_ERRORS + +dnl Check if setrlimit() takes an enum as 1st argument +ACE_CHECK_SETRLIMIT_ENUM + +dnl This test fails (i.e. passes when it shouldn't) when compiling with +dnl GCC/G++ since the compiler treats passing a const to a non-const +dnl argument as a warning and not as an error since the const is +dnl simply discarded. To correct this problem, we use "-Werror" which +dnl converts all warnings to errors, whenever we are compiling with +dnl G++. +dnl -Ossama + +dnl Check if getrusage() takes an enum as 1st argument +ACE_CHECK_GETRUSAGE_ENUM + +dnl TODO: This doesn't work. +dnl The compiler in linux just issues a warning, and the test passes!!! +dnl +dnl FIXED by adding "-Werror" to compiler flags when using GNU C++ +dnl -Ossama +ACE_CONVERT_WARNINGS_TO_ERRORS( +[ +dnl Check if select takes a const fifth argument (timeval) +ACE_CACHE_CHECK([if select takes a const struct timeval], + [ace_cv_lib_posix_select_const_timeval],[ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#ifndef ACE_LACKS_SYS_TYPES_H +# include +#endif +#include +#ifndef ACE_LACKS_UNISTD_H +# include +#endif +#ifndef ACE_LACKS_SYS_SELECT_H +# include +#endif + ]], [[ + int n = 0; + fd_set *readfds = 0; + fd_set *writefds = 0; + fd_set *exceptfds = 0; + const struct timeval* timeout = 0; + select(n, readfds, writefds, exceptfds, timeout); + ]])],[ + ace_cv_lib_posix_select_const_timeval=yes + ],[ + ace_cv_lib_posix_select_const_timeval=no + ]) + ], , [AC_DEFINE([ACE_HAS_NONCONST_SELECT_TIMEVAL])]) +]) dnl ACE_CONVERT_WARNINGS_TO_ERRORS + + +dnl Only run the following tests if the msghdr structure exists. +if test "$ace_cv_struct_msghdr" = yes && + test "$ac_cv_func_sendmsg" = yes; then + ACE_CONVERT_WARNINGS_TO_ERRORS( + [ +dnl Check if sendmsg takes a const 2nd argument + ACE_CACHE_CHECK([if sendmsg omits const qualifier from the msghdr argument], + [ace_cv_lib_nonconst_sendmsg],[ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#ifndef ACE_LACKS_SYS_TYPES_H +# include +#endif +#include + ]], [[ + int s = 0; + const struct msghdr *msg = 0; + unsigned int flags = 0; + + int result = 0; + + result = (int) sendmsg(s, msg, flags); + ]])],[ + ace_cv_lib_nonconst_sendmsg=no + ],[ + ace_cv_lib_nonconst_sendmsg=yes + ]) + ], [AC_DEFINE([ACE_HAS_NONCONST_SENDMSG])],) + ]) dnl ACE_CONVERT_WARNINGS_TO_ERRORS +fi dnl "$ace_cv_struct_msghdr" = yes && $ac_cv_func_sendmsg = yes + + +dnl Only run the following tests if the setrlimit function exists +if test "$ac_cv_func_setrlimit" = yes; then + ACE_CONVERT_WARNINGS_TO_ERRORS( + [ +dnl Check if setrlimit() takes a const pointer as 2nd argument + ACE_CACHE_CHECK([if setrlimit omits const qualifier from the rlimit argument], + [ace_cv_lib_nonconst_setrlimit],[ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#include +#include + ]], [[ + const struct rlimit* rlp = 0; + setrlimit(RLIMIT_CPU, rlp); + ]])],[ + ace_cv_lib_nonconst_setrlimit=no + ],[ + ace_cv_lib_nonconst_setrlimit=yes + ]) + ], [AC_DEFINE([ACE_HAS_NONCONST_SETRLIMIT])]) + ]) dnl ACE_CONVERT_WARNINGS_TO_ERRORS +fi dnl "$ac_cv_func_setrlimit" = yes; then + + +dnl Only run the following tests if the readv function exists +if test "$ac_cv_header_sys_uio_h" = yes && + test "$ac_cv_func_readv" = yes; then + ACE_CONVERT_WARNINGS_TO_ERRORS( + [ +dnl Check if readv omits the const from the iovec argument + ACE_CACHE_CHECK([if readv omits const qualifier from the iovec argument], + [ace_cv_lib_nonconst_readv],[ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#ifndef ACE_LACKS_UNISTD_H +# include +#endif + +#include + ]], [[ + int filedes = 0; + const struct iovec *vector = 0; + size_t count = 0; + + int result = 0; + + result = (int) readv(filedes, vector, count); + ]])],[ + ace_cv_lib_nonconst_readv=no + ],[ + ace_cv_lib_nonconst_readv=yes + ]) + ], [AC_DEFINE([ACE_HAS_NONCONST_READV])],) + ]) dnl ACE_CONVERT_WARNINGS_TO_ERRORS +fi dnl $ac_cv_header_sys_uio_h = yes && $ac_cv_func_writev = yes + + +dnl Only run the following tests if the writev function exists +if test "$ac_cv_header_sys_uio_h" = yes && + test "$ac_cv_func_writev" = yes; then + ACE_CONVERT_WARNINGS_TO_ERRORS( + [ +dnl Check if writev omits the const from the iovec argument + ACE_CACHE_CHECK([if writev omits const qualifier from the iovec argument], + [ace_cv_lib_nonconst_writev],[ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#ifndef ACE_LACKS_UNISTD_H +# include +#endif + +#include + ]], [[ + int filedes = 0; + const struct iovec *vector = 0; + size_t count = 0; + + int result = 0; + + result = (int) writev(filedes, vector, count); + ]])],[ + ace_cv_lib_nonconst_writev=no + ],[ + ace_cv_lib_nonconst_writev=yes + ]) + ], [AC_DEFINE([ACE_HAS_NONCONST_WRITEV])],) + ]) dnl ACE_CONVERT_WARNINGS_TO_ERRORS +fi dnl $ac_cv_header_sys_uio_h = yes && $ac_cv_func_writev = yes + + +ACE_CONVERT_WARNINGS_TO_ERRORS( +[ +ACE_CACHE_CHECK([for (struct sockaddr *) msg_name field in msghdr], + [ace_cv_lib_sockaddr_msg_name],[ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#ifndef ACE_LACKS_SYS_TYPES_H +# include +#endif +#include + ]], [[ + msghdr ace_msghdr; + struct sockaddr *addr = 0; + + /* + * Note that some platforms declare msg_name to be a void*, + * in which case this assignment will work. + * Should we _not_ define ACE_HAS_SOCKADDR_MSG_NAME in that + * case? I tend to think it is more appropriate to define + * ACE_HAS_SOCKADDR_MSG_NAME rather than cast addr to a char*, + * as is done in ACE when the macro is not defined. + * -Ossama + */ + ace_msghdr.msg_name = (struct sockaddr *)addr; + ]])],[ + ace_cv_lib_sockaddr_msg_name=yes + ],[ + ace_cv_lib_sockaddr_msg_name=no + ]) + ], [AC_DEFINE([ACE_HAS_SOCKADDR_MSG_NAME])],) +]) dnl ACE_CONVERT_WARNINGS_TO_ERRORS + + +ACE_CONVERT_WARNINGS_TO_ERRORS( +[ +ACE_CACHE_CHECK([if setsockopt() takes a void* fourth argument], + [ace_cv_lib_posix_setsockopt_voidp_4], + [ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#ifndef ACE_LACKS_SYS_TYPES_H +# include +#endif +#include + ]], [[ + int s = 0; + int level = 0; + int optname = 0; + void* optval = 0; + +#if defined (ACE_HAS_SOCKLEN_T) + socklen_t optlen = 0; +#elif defined (ACE_HAS_SIZET_SOCKET_LEN) + size_t optlen = 0; +#else + int optlen = 0; +#endif + + setsockopt (s, level, optname, optval, optlen); + ]])],[ + ace_cv_lib_posix_setsockopt_voidp_4=yes + ],[ + ace_cv_lib_posix_setsockopt_voidp_4=no + ]) + ], + [ + AC_DEFINE([ACE_HAS_VOIDPTR_SOCKOPT]) + ], + [ + ACE_CACHE_CHECK([if setsockopt() takes a char* fourth argument], + [ace_cv_lib_posix_setsockopt_charp_4], + [ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#ifndef ACE_LACKS_SYS_TYPES_H +# include +#endif +#include + ]], [[ + int s = 0; + int level = 0; + int optname = 0; + char* optval = 0; + +#if defined (ACE_HAS_SOCKLEN_T) + socklen_t optlen = 0; +#elif defined (ACE_HAS_SIZET_SOCKET_LEN) + size_t optlen = 0; +#else + int optlen = 0; +#endif + + setsockopt (s, level, optname, optval, optlen); + ]])],[ + ace_cv_lib_posix_setsockopt_charp_4=yes + ],[ + ace_cv_lib_posix_setsockopt_charp_4=no + ]) + ], + [ + AC_DEFINE([ACE_HAS_CHARPTR_SOCKOPT]) + ],) + ]) +]) dnl ACE_CONVERT_WARNINGS_TO_ERRORS + +ACE_CONVERT_WARNINGS_TO_ERRORS( +[ +ACE_CACHE_CHECK([if mmap() takes a void* first argument], + [ace_cv_lib_posix_voidptr_mmap],[ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#ifndef ACE_LACKS_SYS_TYPES_H +# include +#endif +#ifndef ACE_LACKS_UNISTD_H +# include +#endif +#include + ]], [[ + void *start = 0; + size_t length = 0; + int prot = 0; + int flags = 0; + int fd = 0; + off_t offset = 0; + + void *result = 0; + + result = (void *)mmap(start, length, prot, flags, fd, offset); + ]])],[ + ace_cv_lib_posix_voidptr_mmap=yes + ],[ + ace_cv_lib_posix_voidptr_mmap=no + ]) + ], [AC_DEFINE([ACE_HAS_VOIDPTR_MMAP])],) +]) dnl ACE_CONVERT_WARNINGS_TO_ERRORS + +dnl Check if platform has iostream method ipfx() +ACE_CACHE_CHECK([for iostream method ipfx()], + [ace_cv_feature_has_iostream_ipfx],[ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#include + ]], [[ + cin.ipfx(); + ]])],[ + ace_cv_feature_has_iostream_ipfx=yes + ],[ + ace_cv_feature_has_iostream_ipfx=no + ]) + ], , [AC_DEFINE([ACE_LACKS_IOSTREAM_FX])]) + +dnl Check if platform has line-buffered streambufs +ACE_CACHE_CHECK([for line-buffered streambufs], + [ace_cv_feature_has_linebuffered_streambuf],[ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#include + ]], [[ + cin.rdbuf()->linebuffered(1); + ]])],[ + ace_cv_feature_has_linebuffered_streambuf=yes + ],[ + ace_cv_feature_has_linebuffered_streambuf=no + ]) + ], , [AC_DEFINE([ACE_LACKS_LINEBUFFERED_STREAMBUF])]) + +dnl Check if platform has unbuffered streambufs +ACE_CACHE_CHECK([for unbuffered streambufs], + [ace_cv_feature_has_unbuffered_streambuf],[ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#include + ]], [[ + cin.rdbuf()->unbuffered(1); + ]])],[ + ace_cv_feature_has_unbuffered_streambuf=yes + ],[ + ace_cv_feature_has_unbuffered_streambuf=no + ]) + ], , [AC_DEFINE([ACE_LACKS_UNBUFFERED_STREAMBUF])]) + + +dnl Check if signal takes a void (*)(int) as second argument +ACE_CONVERT_WARNINGS_TO_ERRORS( +[ +ACE_CACHE_CHECK([if signal takes a void (*)(int) as second argument], + [ace_cv_lib_signal_vi1_2],[ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#include + typedef void (*SA)(int); + static void handler(int) { } + ]], [[ + SA nn = handler; + signal(SIGINT, nn); + ]])],[ + ace_cv_lib_signal_vi1_2=yes + ],[ + dnl Check if extern "C" signal handler is required. + AC_COMPILE_IFELSE([AC_LANG_PROGRAM( + [[ +#include +extern "C" + { + typedef void (*SA)(int); + void handler(int) { } + } + ]], + [[ + SA nn = handler; + signal(SIGINT, nn); + ]])], + [ + ace_cv_lib_signal_vi1_2=yes + ], + [ + ace_cv_lib_signal_vi1_2=no + ]) + ]) + ], + [ + AC_DEFINE([ACE_HAS_SIG_C_FUNC]) + ],) +]) dnl ACE_CONVERT_WARNINGS_TO_ERRORS + +dnl Check if signal takes a void (*)(void) as second argument +ACE_CONVERT_WARNINGS_TO_ERRORS( +[ +ACE_CACHE_CHECK([if signal takes a void (*)(void) as second argument], + [ace_cv_lib_signal_vv1_2],[ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#include + typedef void (*SA)(void); + void handler(void) { } + ]], [[ + SA nn = handler; + signal(SIGINT, nn); + ]])],[ + ace_cv_lib_signal_vv1_2=yes + ],[ + dnl Check if extern "C" signal handler is required. + AC_COMPILE_IFELSE([AC_LANG_PROGRAM( + [[ +#include +extern "C" + { + typedef void (*SA)(void); + void handler(void) { } + } + ]], + [[ + SA nn = handler; + signal(SIGINT, nn); + ]])], + [ + ace_cv_lib_signal_vv1_2=yes + ], + [ + ace_cv_lib_signal_vv1_2=no + ]) + ]) + ], + [ + AC_DEFINE([ACE_HAS_SIG_C_FUNC]) + ]) +]) dnl ACE_CONVERT_WARNINGS_TO_ERRORS + +dnl Check if signal takes a void (*)(int, ...) as second argument +ACE_CONVERT_WARNINGS_TO_ERRORS( +[ +ACE_CACHE_CHECK([if signal takes a void (*)(int, ...) as second argument], + [ace_cv_lib_signal_vi1a2_2],[ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#include + typedef void (*SA)(int, ...); + void handler(int, ...) { } + ]], [[ + SA nn = handler; + signal(SIGINT, nn); + ]])],[ + ace_cv_lib_signal_vi1a2_2=yes + ],[ + dnl Check if extern "C" signal handler is required. + AC_COMPILE_IFELSE([AC_LANG_PROGRAM( + [[ +#include +extern "C" + { + typedef void (*SA)(int, ...); + void handler(int, ...) { } + } + ]], + [[ + SA nn = handler; + signal(SIGINT, nn); + ]])], + [ + ace_cv_lib_signal_vi1a2_2=yes + ], + [ + ace_cv_lib_signal_vi1a2_2=no + ]) + ]) + ], + [ + AC_DEFINE([ACE_HAS_SIG_C_FUNC]) + ],) +]) dnl ACE_CONVERT_WARNINGS_TO_ERRORS + +dnl Check if signal takes a void (*)(...) as second argument +ACE_CONVERT_WARNINGS_TO_ERRORS( +[ +ACE_CACHE_CHECK([if signal takes a void (*)(...) as second argument], + [ace_cv_lib_signal_va1_2],[ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#include + typedef void (*SA)(...); + void handler(...) { } + ]], [[ + SA nn = handler; + signal(SIGINT, nn); + ]])],[ + ace_cv_lib_signal_va1_2=yes + ],[ + dnl Check if extern "C" signal handler is required. + AC_COMPILE_IFELSE([AC_LANG_PROGRAM( + [[ +#include +extern "C" + { + typedef void (*SA)(...); + void handler(...) { } + } + ]], + [[ + SA nn = handler; + signal(SIGINT, nn); + ]])], + [ + ace_cv_lib_signal_va1_2=yes + ], + [ + ace_cv_lib_signal_va1_2=no + ]) + ]) + ], + [ + AC_DEFINE([ACE_HAS_SIG_C_FUNC]) + ],) +]) dnl ACE_CONVERT_WARNINGS_TO_ERRORS + +dnl Check if signal returns a void (*)(int) +AC_CACHE_CHECK([if signal returns a void (*)(int)], + [ace_cv_lib_signal_vi1_ret],[ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#include + +typedef void (*SA)(int); +void foo(SA nn) { } + ]], [[ +SA nn = SIG_DFL; +nn = signal(SIGINT, 0); +foo(nn); + ]])],[ + ace_cv_lib_signal_vi1_ret=yes + ],[ + ace_cv_lib_signal_vi1_ret=no + ]) + ]) + +dnl Check if signal returns a void (*)(void) +AC_CACHE_CHECK([if signal returns a void (*)(void)], + [ace_cv_lib_signal_vv1_ret],[ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#include + +typedef void (*SA)(void); +void foo(SA nn) { } + ]], [[ +SA nn = SIG_DFL; +nn = signal(SIGINT, 0); +foo(nn); + ]])],[ + ace_cv_lib_signal_vv1_ret=yes + ],[ + ace_cv_lib_signal_vv1_ret=no + ]) + ]) + +dnl Check if signal returns a void (*)(int, ...) +AC_CACHE_CHECK([if signal returns a void (*)(int, ...)], + [ace_cv_lib_signal_vi1a2_ret],[ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#include + +typedef void (*SA)(int, ...); + ]], [[ + SA oo = signal(SIGINT, 0); + ]])],[ + ace_cv_lib_signal_vi1a2_ret=yes + ],[ + ace_cv_lib_signal_vi1a2_ret=no + ]) + ]) + +dnl Check if signal returns a void (*)(...) +AC_CACHE_CHECK([if signal returns a void (*)(...)], + [ace_cv_lib_signal_va1_ret],[ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#include + +typedef void (*SA)(...); + ]], [[ + SA oo = signal(SIGINT, 0); + ]])],[ + ace_cv_lib_signal_va1_ret=yes + ],[ + ace_cv_lib_signal_va1_ret=no + ]) + ]) + +if test "$ace_cv_struct_sigaction" = yes; then +dnl Check if struct sigaction takes a void (*)(int) handler + AC_CACHE_CHECK([if struct sigaction takes a void (*)(int) handler], + [ace_cv_lib_struct_sigaction_vi1_handler],[ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#include + typedef void (*SA)(int); + void foo(struct sigaction* sa, SA nn) { } + ]], [[ + struct sigaction sa; + SA nn = SIG_DFL; + sa.sa_handler = nn; + foo(&sa, nn); + ]])],[ + ace_cv_lib_struct_sigaction_vi1_handler=yes + ],[ + ace_cv_lib_struct_sigaction_vi1_handler=no + ]) + ]) + +dnl Check if struct sigaction takes a void (*)(void) handler + AC_CACHE_CHECK([if struct sigaction takes a void (*)(void) handler], + [ace_cv_lib_struct_sigaction_vv1_handler],[ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#include + typedef void (*SA)(void); + void foo(struct sigaction* sa, SA nn) { } + ]], [[ + struct sigaction sa; + SA nn = SIG_DFL; + sa.sa_handler = nn; + foo(&sa, nn); + ]])],[ + ace_cv_lib_struct_sigaction_vv1_handler=yes + ],[ + ace_cv_lib_struct_sigaction_vv1_handler=no + ]) + ]) + +dnl Check if struct sigaction takes a void (*)(int, ...) handler + AC_CACHE_CHECK([if struct sigaction takes a void (*)(int, ...) handler], + [ace_cv_lib_struct_sigaction_vi1a2_handler],[ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#include + typedef void (*SA)(int, ...); + void foo(struct sigaction* sa, SA nn) { } + ]], [[ + struct sigaction sa; + SA nn = SIG_DFL; + sa.sa_handler = nn; + foo(&sa, nn); + ]])],[ + ace_cv_lib_struct_sigaction_vi1a2_handler=yes + ],[ + ace_cv_lib_struct_sigaction_vi1a2_handler=no + ]) + ]) + +dnl Check if struct sigaction takes a void (*)(...) handler + AC_CACHE_CHECK([if struct sigaction takes a void (*)(...) handler], + [ace_cv_lib_struct_sigaction_va1_handler],[ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#include + typedef void (*SA)(...); + void foo(struct sigaction* sa, SA nn) { } + ]], [[ + struct sigaction sa; + SA nn = SIG_DFL; + sa.sa_handler = nn; + foo(&sa, nn); + ]])],[ + ace_cv_lib_struct_sigaction_va1_handler=yes + ],[ + ace_cv_lib_struct_sigaction_va1_handler=no + ]) + ]) +fi dnl test "$ace_cv_struct_sigaction" = yes + +dnl TODO: This doesn't work. +dnl The linux compiler issues a warning regarding the invalid void* +dnl conversion. +dnl +dnl FIXED by adding "-Werror" to compiler flags when using GNU C++ +dnl -Ossama +ACE_CONVERT_WARNINGS_TO_ERRORS( +[ +dnl Check if msgsnd() takes a struct msgbuf* second argument +ACE_CACHE_CHECK([if msgsnd() takes a struct msgbuf* second argument], + [ace_cv_lib_posix_msgsnd_msgbufp_2],[ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#ifndef ACE_LACKS_SYS_TYPES_H +# include +#endif +# include +#ifndef ACE_LACKS_SYS_MSG_H +# include +#endif + ]], [[ + int msqid = 0; + struct msgbuf* msgp = 0; + int msgsz = 0; + int msgflg = 0; + msgsnd(msqid, msgp, msgsz, msgflg); + ]])],[ + ace_cv_lib_posix_msgsnd_msgbufp_2=yes + ],[ + ace_cv_lib_posix_msgsnd_msgbufp_2=no + ]) + ], + [ + dnl "ACTIONS-IF-SUCCESSFUL" handled later in configure.in + ], + [ + dnl Check if msgsnd() takes a const void* second argument + ACE_CACHE_CHECK([if msgsnd() takes a const void* second argument], + [ace_cv_lib_posix_msgsnd_cvoidp_2],[ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#ifndef ACE_LACKS_SYS_TYPES_H +# include +#endif +# include +#ifndef ACE_LACKS_SYS_MSG_H +# include +#endif + ]], [[ + int msqid = 0; + const void* msgp = 0; + int msgsz = 0; + int msgflg = 0; + msgsnd(msqid, msgp, msgsz, msgflg); + ]])],[ + ace_cv_lib_posix_msgsnd_cvoidp_2=yes + ],[ + ace_cv_lib_posix_msgsnd_cvoidp_2=no + ]) + ], + [ + dnl Do nothing if msgsnd takes a const void* second argument + ], + [ + dnl If we get this far we presumably have a non-const void* second param + AC_DEFINE([ACE_HAS_NONCONST_MSGSND]) + ]) + ]) +]) dnl ACE_CONVERT_WARNINGS_TO_ERRORS + +dnl TODO: This doesn't work. +dnl The linux compiler issues a warning regarding the invalid void* +dnl conversion. +dnl +dnl FIXED by adding "-Werror" to compiler flags when using GNU C++ +dnl -Ossama +ACE_CONVERT_WARNINGS_TO_ERRORS( +[ +dnl Check if msgrcv() takes a void* second argument +AC_CACHE_CHECK([if msgrcv() takes a void* second argument], + [ace_cv_lib_posix_msgrcv_voidp_2],[ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#ifndef ACE_LACKS_SYS_TYPES_H +# include +#endif +# include +#ifndef ACE_LACKS_SYS_MSG_H +# include +#endif + ]], [[ + int msqid = 0; + void* msgp = 0; + int msgsz = 0; + long msgtyp = 0; + int msgflg = 0; + msgrcv(msqid, msgp, msgsz, msgtyp, msgflg); + ]])],[ + ace_cv_lib_posix_msgrcv_voidp_2=yes + ],[ + ace_cv_lib_posix_msgrcv_voidp_2=no + ]) + ]) +]) dnl ACE_CONVERT_WARNINGS_TO_ERRORS + + +if test "$ac_cv_func_shmat" = yes; then + dnl TODO: This doesn't work. + dnl The linux compiler issues a warning regarding the invalid void* + dnl conversion. + dnl + dnl FIXED by adding "-Werror" to compiler flags when using GNU C++ + dnl -Ossama + ACE_CONVERT_WARNINGS_TO_ERRORS( + [ + dnl Check if shmat() takes a void* second argument + AC_CACHE_CHECK([if shmat() takes a void* second argument], + [ace_cv_lib_posix_shmat_voidp_2],[ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ + #ifndef ACE_LACKS_SYS_TYPES_H + # include + #endif + # include + # include + ]], [[ + int shmid = 0; + void* shmaddr = 0; + int shmflg = 0; + shmat(shmid, shmaddr, shmflg); + ]])],[ + ace_cv_lib_posix_shmat_voidp_2=yes + ],[ + ace_cv_lib_posix_shmat_voidp_2=no + ]) + ]) + ]) dnl ACE_CONVERT_WARNINGS_TO_ERRORS + if test "$ace_cv_lib_posix_shmat_voidp_2" = no; then + AC_DEFINE([ACE_HAS_CHARPTR_SHMAT], 1, + [Define to 1 if arg 2 of 'shmat' is char *']) + fi +fi + +if test "$ac_cv_func_shmdt" = yes; then + dnl TODO: This doesn't work. + dnl The linux compiler issues a warning regarding the invalid void* + dnl conversion. + dnl + dnl FIXED by adding "-Werror" to compiler flags when using GNU C++ + dnl -Ossama + ACE_CONVERT_WARNINGS_TO_ERRORS( + [ + dnl Check if shmdt() takes a void* second argument + AC_CACHE_CHECK([if shmdt() takes a void* argument], + [ace_cv_lib_posix_shmdt_voidp],[ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ + #ifndef ACE_LACKS_SYS_TYPES_H + # include + #endif + # include + # include + ]], [[ + void* shmaddr = 0; + shmdt(shmaddr); + ]])],[ + ace_cv_lib_posix_shmdt_voidp=yes + ],[ + ace_cv_lib_posix_shmdt_voidp=no + ]) + ]) + ]) dnl ACE_CONVERT_WARNINGS_TO_ERRORS + if test "$ace_cv_lib_posix_shmdt_voidp" = no; then + AC_DEFINE([ACE_HAS_CHARPTR_SHMDT], 1, + [Define to 1 if arg 1 of 'shmdt' is char *']) + fi +fi + +dnl TODO: This doesn't work. +dnl The linux compiler issues a warning regarding the invalid void* +dnl conversion. +dnl +dnl FIXED by adding "-Werror" to compiler flags when using GNU C++ +dnl -Ossama +ACE_CONVERT_WARNINGS_TO_ERRORS( +[ +dnl Check if sigaction() takes a const* second argument +AC_CACHE_CHECK([if sigaction() takes a const* second argument], + [ace_cv_lib_posix_sigaction_constp_2],[ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#include + ]], [[ + int signum = 0; + const struct sigaction* act = 0; + struct sigaction* oldact = 0; + sigaction(signum, act, oldact); + ]])],[ + ace_cv_lib_posix_sigaction_constp_2=yes + ],[ + ace_cv_lib_posix_sigaction_constp_2=no + ]) + ]) +]) dnl ACE_CONVERT_WARNINGS_TO_ERRORS + +if test "$ace_cv_lib_posix_sigaction_constp_2" = yes; then + AC_DEFINE([ACE_HAS_SIGACTION_CONSTP2]) +fi + +dnl We need to use the ACE_CONVERT_WARNINGS_TO_ERRORS() macro since +dnl passing a void * just caused implicit conversion warnings when +dnl using GNU C++, for example. +ACE_CONVERT_WARNINGS_TO_ERRORS( +[ +dnl Check for SVR4 style gettimeofday() +AC_CACHE_CHECK([if gettimeofday() takes a void * second argument], + [ace_cv_lib_voidptr_gettimeofday], + [ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#include +#ifndef ACE_LACKS_UNISTD_H +# include +#endif + ]], [[ + struct timeval *tv = 0; + void *tzp = 0; + + gettimeofday(tv, tzp); + ]])],[ + ace_cv_lib_voidptr_gettimeofday=yes + ],[ + ace_cv_lib_voidptr_gettimeofday=no + ]) + ]) +]) dnl ACE_CONVERT_WARNINGS_TO_ERRORS + +if test "$ace_cv_lib_voidptr_gettimeofday" = no; then +ACE_CONVERT_WARNINGS_TO_ERRORS( +[ +dnl Check for old OSF1 style gettimeofday() + AC_CACHE_CHECK([if gettimeofday() takes a struct timezone * second argument], + [ace_cv_lib_timezone_gettimeofday], + [ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#include +#ifndef ACE_LACKS_UNISTD_H +# include +#endif + ]], [[ + struct timeval *tv = 0; + struct timezone *tzp = 0; + + gettimeofday(tv, tzp); + ]])],[ + ace_cv_lib_timezone_gettimeofday=yes + ],[ + ace_cv_lib_timezone_gettimeofday=no + ]) + ]) +]) dnl ACE_CONVERT_WARNINGS_TO_ERRORS +fi dnl test "$ace_cv_lib_voidptr_gettimeofday" = no + +dnl Check for gettimeofday() protoype +if test "$ace_cv_lib_voidptr_gettimeofday" = yes || + test "$ace_cv_lib_timezone_gettimeofday" = yes; then + +AC_CHECK_DECL([gettimeofday], + [ +if test "$ace_cv_lib_voidptr_gettimeofday" = yes; then + AC_DEFINE([ACE_HAS_VOIDPTR_GETTIMEOFDAY]) +else + AC_DEFINE([ACE_HAS_TIMEZONE_GETTIMEOFDAY]) +fi + ],[ +if test "$ace_cv_lib_voidptr_gettimeofday" = yes; then + AC_DEFINE([ACE_HAS_SVR4_GETTIMEOFDAY]) +else + AC_DEFINE([ACE_HAS_OSF1_GETTIMEOFDAY]) +fi + ], + [ +#include +#ifndef ACE_LACKS_UNISTD_H +# include +#endif + ]) + +fi dnl Check for gettimeofday() protoype + + +dnl Check if ctime_r() takes two arguments +if test "$ac_cv_func_ctime_r" = yes; then + ACE_CACHE_CHECK([if ctime_r() takes two arguments], + [ace_cv_lib_posix_ctime_r_2_params], + [ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#ifndef _REENTRANT +# define _REENTRANT +#endif + +#include + ]], [[ + const time_t *t = 0; + char *buf; + ctime_r(t, buf); + ]])],[ + ace_cv_lib_posix_ctime_r_2_params=yes + ],[ + ace_cv_lib_posix_ctime_r_2_params=no + ]) + ], [AC_DEFINE([ACE_HAS_2_PARAM_ASCTIME_R_AND_CTIME_R])],) +fi dnl test "$ac_cv_func_ctime_r" = yes + + +dnl +dnl SECTION 12: checks for type characteristics +dnl + +dnl struct msghdr stuff +dnl Only run the following tests if the msghdr structure exists. +if test "$ace_cv_struct_msghdr" = yes; then + + ACE_CACHE_CHECK([if struct msghdr has a msg_accrights member], + [ace_cv_lib_posix_struct_msghdr_has_msg_accrights],[ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#ifndef ACE_LACKS_SYS_TYPES_H +# include +#endif +#include + ]], [[ + msghdr mh; + mh.msg_accrights = 0; + ]])],[ + ace_cv_lib_posix_struct_msghdr_has_msg_accrights=yes + ],[ + ace_cv_lib_posix_struct_msghdr_has_msg_accrights=no + ]) + ]) + + ACE_CACHE_CHECK([if struct msghdr has a msg_accrightslen member], + [ace_cv_lib_posix_struct_msghdr_has_msg_accrightslen],[ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#ifndef ACE_LACKS_SYS_TYPES_H +# include +#endif +#include + ]], [[ + msghdr mh; + mh.msg_accrightslen = 0; + ]])],[ + ace_cv_lib_posix_struct_msghdr_has_msg_accrightslen=yes + ],[ + ace_cv_lib_posix_struct_msghdr_has_msg_accrightslen=no + ]) + ]) + +dnl Check for 4.4 BSD style struct msghdr members +dnl The following test should only be run if the above two testsfail. + if test "$ace_cv_lib_posix_struct_msghdr_has_msg_accrights" = no && + test "$ace_cv_lib_posix_struct_msghdr_has_msg_accrightslen" = no; then + AC_DEFINE([ACE_LACKS_MSG_ACCRIGHTS]) + ACE_CACHE_CHECK([for 4.4 BSD style struct msghdr], + [ace_cv_lib_4_4bsd_msghdr],[ + AC_EGREP_HEADER([msg_control], [sys/socket.h], + [ + ace_cv_lib_4_4bsd_msghdr=yes + ], + [ + ace_cv_lib_4_4bsd_msghdr=no + ]) + ], + [ + AC_DEFINE([ACE_HAS_4_4BSD_SENDMSG_RECVMSG]) + ], + [ + AC_MSG_WARN([No supported msghdr structure was found. ACE may not compile or function properly.]) + ]) + fi + +fi dnl End struct msghdr_stuff + +dnl +dnl SECTION 13: checks for system services +dnl + +dnl Check if platform defines ctime() as a macro +ACE_CACHE_CHECK([for ctime() macro], + [ace_cv_feature_have_ctime_macro], + [ + AC_EGREP_CPP([ACE_CTIME_MACRO], + [ +#include + +#if defined (ctime) + ACE_CTIME_MACRO +#endif + ], + [ + ace_cv_feature_have_ctime_macro=yes + ], + [ + ace_cv_feature_have_ctime_macro=no + ]) + ], [AC_DEFINE([ACE_HAS_BROKEN_CTIME])],) + +dnl Check if platform defines ctime_r, asctime_r, rand_r or getpwnam_r +dnl as macros. +ACE_CACHE_CHECK([for reentrant function macros], + [ace_cv_feature_has_broken_r_routines], + [ + AC_EGREP_CPP([ACE_R_MACROS], + [ +#ifndef _REENTRANT +# define _REENTRANT +#endif + +#include + +#if !defined (ACE_LACKS_PWD_H) +# include +#endif + +#if defined (ctime_r) || \ + defined (asctime_r) || \ + defined (rand_r) || \ + defined (getpwnam_r) + ACE_R_MACROS +#endif + ], + [ + ace_cv_feature_has_broken_r_routines=yes + ], + [ + ace_cv_feature_has_broken_r_routines=no + ]) + ], [AC_DEFINE([ACE_HAS_BROKEN_R_ROUTINES])],) + +dnl Check if platform defines sig{empty,fill,add,del}set as macros +ACE_CACHE_CHECK([for sig{empty fill add del}set macros], + [ace_cv_feature_have_sig_macros], + [ + AC_EGREP_CPP([ACE_SIG_MACROS], + [ +#ifndef ACE_LACKS_SYS_TYPES_H +# include +#endif +#include + +#if defined (sigemptyset) || \ + defined (sigfillset) || \ + defined (sigaddset) || \ + defined (sigdelset) || \ + defined (sigismember) + ACE_SIG_MACROS +#endif + ], + [ + ace_cv_feature_have_sig_macros=yes + ], + [ + ace_cv_feature_have_sig_macros=no + ]) + ], [AC_DEFINE([ACE_HAS_SIG_MACROS])],) + +dnl Check for open() mode masks +ACE_CACHE_CHECK([for open() mode masks], + [ace_cv_feature_have_open_mode_masks],[ + AC_EGREP_CPP([ACE_OPEN_MODE_MASKS_EXIST], + [ +#ifndef ACE_LACKS_SYS_TYPES_H +# include +#endif +#include +#include + +/* These are ORed so that ACE will not redefine any of them if any of + them exist. */ +#if defined (S_IRWXU) || \ + defined (S_IRUSR) || \ + defined (S_IWUSR) || \ + defined (S_IXUSR) || \ + defined (S_IRWXG) || \ + defined (S_IRGRP) || \ + defined (S_IWGRP) || \ + defined (S_IXGRP) || \ + defined (S_IRWXO) || \ + defined (S_IROTH) || \ + defined (S_IWOTH) || \ + defined (S_IXOTH) + ACE_OPEN_MODE_MASKS_EXIST +#endif + ], + [ + ace_cv_feature_have_open_mode_masks=yes + ], + [ + ace_cv_feature_have_open_mode_masks=no + ]) + ], , [AC_DEFINE([ACE_LACKS_MODE_MASKS])]) + + +dnl Check if platform supports POSIX O_NONBLOCK semantics +ACE_CACHE_CHECK([for POSIX O_NONBLOCK semantics], + [ace_cv_feature_posix_o_nonblock],[ + AC_EGREP_CPP([ACE_POSIX_O_NONBLOCK], + [ +#ifndef ACE_LACKS_SYS_TYPES_H +# include +#endif +#include +#include + +#if defined (O_NONBLOCK) + ACE_POSIX_O_NONBLOCK +#endif + ], + [ + ace_cv_feature_posix_o_nonblock=yes + ], + [ + ace_cv_feature_posix_o_nonblock=no + ]) + ], [AC_DEFINE([ACE_HAS_POSIX_NONBLOCK])],) + +dnl Check for MAP_FAILED constant +ACE_CACHE_CHECK([for MAP_FAILED constant], + [ace_cv_lib_have_map_failed],[ + dnl We need the square brackets around "ACEMAPFAILED.+[0-9]" to + dnl prevent the character class "[0-9]" from becoming "0-9" due to + dnl M4 quoting. + AC_EGREP_CPP([ACEMAPFAILED.+[0-9]], + [ +#include + ACEMAPFAILED MAP_FAILED + ], + [ + ace_cv_lib_have_map_failed=yes + ], + [ + ace_cv_lib_have_map_failed=no + ]) + ], + [ + dnl Check if platform defines MAP_FAILED as a long constant + ACE_CACHE_CHECK([if MAP_FAILED is a long constant], + [ace_cv_feature_long_map_failed],[ + dnl We need the square brackets around "ACEMAPFAILED.+[0-9]L" to + dnl prevent the character class "[0-9]" from becoming "0-9" due to + dnl M4 quoting. + AC_EGREP_CPP([ACEMAPFAILED.+[0-9]L], + [ +#include + ACEMAPFAILED MAP_FAILED + ], + [ + ace_cv_feature_long_map_failed=yes + ], + [ + ace_cv_feature_long_map_failed=no + ]) + ], [AC_DEFINE([ACE_HAS_LONG_MAP_FAILED])], + [ + dnl Check if MAP_FAILED is _not_ cast to void * + ACE_CACHE_CHECK([if MAP_FAILED is not cast to void *], + [ace_cv_have_broken_map_failed],[ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#include + ]], [[ + void * foo = MAP_FAILED; + ]])],[ + ace_cv_have_broken_map_failed=no + ],[ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM( + [[ +#include + ]], + [[ + void * foo = (void *) MAP_FAILED; + ]])], + [ + ace_cv_have_broken_map_failed=yes + ], + [ + dnl If we get here then we have no idea what is wrong! + ace_cv_have_broken_map_failed=no + ]) + ]) + ], [AC_DEFINE([ACE_HAS_BROKEN_MAP_FAILED])],) + ]) + ],) + +dnl Check if platform supports TCP_NODELAY support +ACE_CACHE_CHECK([for TCP_NODELAY support], + [ace_cv_feature_tcp_nodelay],[ + AC_EGREP_CPP([ACE_TCPNODELAY], + [ +#ifndef ACE_LACKS_SYS_TYPES_H +# include +#endif +#include + +#if defined (TCP_NODELAY) + ACE_TCPNODELAY +#endif + ], + [ + ace_cv_feature_tcp_nodelay=yes + ], + [ + ace_cv_feature_tcp_nodelay=no + ]) + ], , [AC_DEFINE([ACE_LACKS_TCP_NODELAY])]) + +dnl Check if platform supports SO_SNDBUF/SO_RCVBUF socket options +ACE_CACHE_CHECK([for SO_SNDBUF/SO_RCVBUF socket options], + [ace_cv_feature_so_sndbuf_rcvbuf],[ + AC_EGREP_CPP([ACE_SO_BUF], + [ +#ifndef ACE_LACKS_SYS_TYPES_H +# include +#endif +#include + +#if defined (SO_SNDBUF) && \ + defined (SO_RCVBUF) + ACE_SO_BUF +#endif + ], + [ + ace_cv_feature_so_sndbuf_rcvbuf=yes + ], + [ + ace_cv_feature_so_sndbuf_rcvbuf=no + ]) + ], , [AC_DEFINE([ACE_LACKS_SOCKET_BUFSIZ])]) + +dnl Check if memcpy is faster or loop unrolling is faster on a given +dnl platform +ACE_CACHE_CHECK([if ACE memcpy needs loop unrolling], [ace_cv_memcpy_loop_unroll], +[AC_RUN_IFELSE([AC_LANG_SOURCE([[#include +#include + +void* +smemcpy (void* dest, const void* src, const size_t n) +{ + unsigned char* to = static_cast( dest) ; + const unsigned char* from = static_cast( src) ; + // Unroll the loop... + switch (n) + { + case 16: to[15] = from[15] ; + case 15: to[14] = from[14] ; + case 14: to[13] = from[13] ; + case 13: to[12] = from[12] ; + case 12: to[11] = from[11] ; + case 11: to[10] = from[10] ; + case 10: to[9] = from[9] ; + case 9: to[8] = from[8] ; + case 8: to[7] = from[7] ; + case 7: to[6] = from[6] ; + case 6: to[5] = from[5] ; + case 5: to[4] = from[4] ; + case 4: to[3] = from[3] ; + case 3: to[2] = from[2] ; + case 2: to[1] = from[1] ; + case 1: to[0] = from[0] ; + case 0: return dest; + default: return memcpy (dest, src, n); + } +} + +// Function pointer +void* (* test_func) (void *dst, const void* src, size_t); + +namespace { enum { ITERATIONS = 100000 }; } + +#include +#include + +int +main(int argc, char* argv[]) +{ + struct timeval start, now; + double value; + + // Test buffer + char dest [16]; + const void* src = " THIS IS A TEST"; + + // We want to test if the loop unrolling is faster for sizes + // from 1..16 + for (size_t counter = 16; counter >=1; counter--) + { + test_func = smemcpy; + + // Warm up + for (int i = ITERATIONS ; i > 0 ; --i) + test_func ((void *)dest, src, counter); + + gettimeofday (&start, 0) ; + for (int j = ITERATIONS ; j > 0 ; --j) + test_func ((void *)dest, src, counter); + gettimeofday (&now, 0); + + double fast = 1000000 * (now.tv_sec - start.tv_sec) + + now.tv_usec - start.tv_usec ; + + test_func = memcpy; + + // Warm up + for (int k = ITERATIONS ; k > 0 ; --k) + test_func ((void *)dest, src, counter); + + gettimeofday (&start, 0) ; + for (int l = ITERATIONS ; l > 0 ; --l) + test_func ((void *)dest, src, counter); + gettimeofday (&now, 0) ; + + double slow = 1000000 * (now.tv_sec-start.tv_sec) + + now.tv_usec - start.tv_usec ; + if (fast > slow) + return 1; // Unrolling was slower than actual memcpy + + if (1.10*fast > slow) + return 1; // Unrolling was not faster by 10% + } + return 0; // Unrolling was faster -- success +}]])], [ace_cv_memcpy_loop_unroll=yes], + [ace_cv_memcpy_loop_unroll=no], + dnl Cross compilation case + [ace_cv_memcpy_loop_unroll=no])], + dnl only if the test succeeds set the macro + [AC_DEFINE([ACE_HAS_MEMCPY_LOOP_UNROLL], 1, + [Define to 1 if unrolled ACE_OS::fast_memcpy() is faster than system memcpy()])],) + +dnl TODO: We only check for ACE_HAS_AUTOMATIC_INIT_FINI on platforms that +dnl have SVR4 dynamic linking since ACE doesn't support it otherwise. +if test "$ac_cv_header_dlfcn_h" = yes && + test "$ace_has_svr4_dynamic_linking" = yes; then +dnl Check if platform calls init/fini automatically + ACE_CACHE_CHECK([for automatic init/fini calls], + [ace_cv_feature_auto_init_fini],[ + ace_cv_feature_auto_init_fini=yes + # TODO: We know how to check for this, but we need to: + # + # 1. Compile one file. + # 2. Compile and link another file. + # 3. Run file in point (2); it returns what we need. + # + # How do we do all that? + ], [AC_DEFINE([ACE_HAS_AUTOMATIC_INIT_FINI])],) +fi dnl test "$ac_cv_header_dlfcn_h" = yes && + dnl "$ace_has_svr4_dynamic_linking" = yes + +dnl Check for recursive thread exit semantics +if test "$ace_user_enable_threads" = yes; then + ACE_CACHE_CHECK([for recursive thread exit semantics], + [ace_cv_feature_recursive_thr_exit],[ + ace_cv_feature_recursive_thr_exit=yes + # TODO: How do we check for recursive thread exit semantics + ], [AC_DEFINE([ACE_HAS_RECURSIVE_THR_EXIT_SEMANTICS])],) +fi + +dnl Check for UNIX domain sockets +ACE_CACHE_CHECK([for UNIX domain sockets], + [ace_cv_feature_unix_sockets], + [ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#ifndef ACE_LACKS_SYS_TYPES_H +# include +#endif +#include + ]], [[ + sockaddr_un su; + ]])],[ + ace_cv_feature_unix_sockets=yes + ],[ + ace_cv_feature_unix_sockets=no + ]) + ], , [AC_DEFINE([ACE_LACKS_UNIX_DOMAIN_SOCKETS])]) + +dnl Check for raw sockets +ACE_CACHE_CHECK([for raw sockets], + [ace_cv_feature_raw_sockets], + [ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#ifndef ACE_LACKS_SYS_TYPES_H +# include +#endif +#include +#include + ]], [[ +return socket(AF_INET, SOCK_RAW, IPPROTO_RAW); + ]])],[ + ace_cv_feature_raw_sockets=yes + ],[ + ace_cv_feature_raw_sockets=no + ]) + ], [AC_DEFINE([ACE_HAS_ICMP_SUPPORT])]) + +dnl Check for ACE_Handle_Set optimized for select() +ACE_CACHE_CHECK([for ACE_Handle_Set optimized for select()], + [ace_cv_feature_handle_set_optimized_for_select],[ + ace_cv_feature_handle_set_optimized_for_select=yes + # TODO: We know how to check this. We need to: + # + # 1. Compile and link a file. + # 2. Run nm on that file. + # + # How do we do that? + ], [AC_DEFINE([ACE_HAS_HANDLE_SET_OPTIMIZED_FOR_SELECT])],) + +dnl Even we if we don't have IP multicasting, we still need to define +dnl "ACE_HAS_IP_MULTICAST" since struct ip_mreq gets redefined by ACE. +dnl What do we do about this problem? +dnl -Ossama +dnl Check for IP multicast support +ACE_CACHE_CHECK([for IP multicast support], + [ace_cv_feature_ip_multicast],[ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#ifndef ACE_LACKS_SYS_TYPES_H +# include +#endif +#include + ]], [[ + ip_mreq im; + ]])],[ + ace_cv_feature_ip_multicast=yes + ],[ +dnl Some platforms define ip_mreq in . + AC_COMPILE_IFELSE([AC_LANG_PROGRAM( + [[ +#ifndef ACE_LACKS_SYS_TYPES_H +# include +#endif +#include + ]], + [[ + ip_mreq im; + ]])], + [ + ace_cv_feature_ip_multicast=yes + ], + [ + ace_cv_feature_ip_multicast=no + ]) + ]) + ], [AC_DEFINE([ACE_HAS_IP_MULTICAST])],) + +ACE_CACHE_CHECK([if running on an Alpha], + [ace_cv_feature_alpha],[ + case "$host" in + alpha*) + ace_cv_feature_alpha=yes + ;; + *) + ace_cv_feature_alpha=no + ;; + esac + ], + [ + case "$host" in + *linux*) + dnl We only define ACE_HAS_ALPHA_TIMER if we are running Linux + dnl on an Alpha and are using GNU C++! + if test "$GXX" = yes; then + AC_DEFINE([ACE_HAS_ALPHA_TIMER], 1, + [Define to 1 if system should use Alpha's cycle counter]) + fi + ;; + esac + ],) + +ACE_CACHE_CHECK([if running on a Power PC], + [ace_cv_feature_powerpc],[ + case "$host" in + powerpc*) + ace_cv_feature_powerpc=yes + ;; + *) + ace_cv_feature_powerpc=no + ;; + esac + ], + [ + case "$host" in + *aix*) + dnl We don't do anything for AIX since AIX already has a + dnl hi-res timer function! + ;; + *) + dnl Only define ACE_HAS_POWERPC_TIMER when using GNU C++! + if test "$GXX" = yes; then + AC_DEFINE([ACE_HAS_POWERPC_TIMER], 1, + [Define to 1 if system should use PowerPC's cycle counter]) + fi + ;; + esac + ],) + +ACE_CACHE_CHECK([if running on a Pentium(tm) processor], + [ace_cv_feature_pentium],[ + case "$host" in + i386-* | i486-* |i586-* | i686-*) +dnl If we do have a pentium, than define ACE_HAS_PENTIUM and add +dnl gethrtime.cpp to the source list, but only if we're using GNU C++ +dnl since gethrtime.cpp uses assembler code specific to that compiler. + if test "$GXX" = yes; then + ace_cv_feature_pentium=yes + else + ace_cv_feature_pentium=no + fi + ;; + *) + ace_cv_feature_pentium=no + ;; + esac + ], + [ + AC_DEFINE([ACE_HAS_PENTIUM], 1, + [Define to 1 if system is using Intel Pentium(tm) processor]) + ],) +AM_CONDITIONAL([ACE_ON_PENTIUM], [test X$ace_cv_feature_pentium = Xyes]) + +case "$host" in + i386-* | i486-* | i586-* | i686-* | x86_64-*) + if test "$GXX" = yes; then + ace_cv_has_intel_assembly=yes + else + ace_cv_has_intel_assembly=no + fi + ;; + *) + ace_cv_has_intel_assembly=no + ;; +esac +if test "$ace_cv_has_intel_assembly" != "no"; then + AC_DEFINE([ACE_HAS_INTEL_ASSEMBLY], 1, + [Define to 1 if the system supports x86/x86_64 inline assembly]) +fi + +dnl +dnl SECTION 14: checks for aggregated features +dnl TODO: Little by little, get rid of these... +dnl + + +dnl Macro ACE_HAS_REENTRANT_FUNCTIONS means the following functions +dnl are usable: +dnl +dnl rand_r +dnl strtok_r +dnl getpwnam_r (if we don't have, define ACE_LACKS_PWD_REENTRANT_FUNCTIONS) +dnl ctime_r +dnl localtime_r +dnl gmtime_r +dnl asctime_r +dnl * getprotobyname_r +dnl * getprotobynumber_r +dnl * gethostbyaddr_r +dnl * gethostbyname_r +dnl * getservbyname_r +dnl +dnl Those marked with '*' are NOT usable if +dnl ACE_LACKS_NETDB_REENTRANT_FUNCTIONS) is defined. +dnl +dnl The time has come to create feature macros for each of these... +dnl With the separate feature macros, we will define (for now) +dnl ACE_HAS_REENTRANT_FUNCTIONS only when all of those WITHOUHT a '*' +dnl are defined. Also, if any of those with '*' are missing, we will +dnl define ACE_LACKS_NETDB_REENTRANT_FUNCTIONS. + +dnl Don't bother with reentrant functions if they are disabled by the user. +if test "$ace_user_enable_reentrant_funcs" = yes && + test "$ac_cv_func_rand_r" = yes && + test "$ac_cv_func_strtok_r" = yes && + test "$ac_cv_func_ctime_r" = yes && + test "$ac_cv_func_localtime_r" = yes && + test "$ac_cv_func_gmtime_r" = yes && + test "$ac_cv_func_asctime_r" = yes; then + AC_DEFINE([ACE_HAS_REENTRANT_FUNCTIONS]) + # Explicitly enable reentrant functions if thread support is not enabled. + if test "$ace_user_enable_threads" = no; then + ACE_CPPFLAGS="$ACE_CPPFLAGS -D_REENTRANT" + fi +fi + +dnl Don't bother with reentrant functions if they are disabled by the user. +if test "$ace_user_enable_reentrant_funcs" = no || + test "$ac_cv_func_getprotobyname_r" = no || + test "$ac_cv_func_getprotobynumber_r" = no || + test "$ac_cv_func_gethostbyaddr_r" = no || + test "$ac_cv_func_gethostbyname_r" = no || + test "$ac_cv_func_getservbyname_r" = no; then + AC_DEFINE([ACE_LACKS_NETDB_REENTRANT_FUNCTIONS]) +fi + +dnl FIXME!!! +dnl The following is a kludge until the netdb reentrant function +dnl number of arguments is handled. +case "$host" in + *linux*) AC_DEFINE([ACE_LACKS_NETDB_REENTRANT_FUNCTIONS]);; + *) ;; +esac + + +dnl Macro ACE_LACKS_SOME_POSIX_PROTOTYPES implies any of the following +dnl features: +dnl +dnl ! ACE_HAS_MSGSND_MSGBUFP_2 +dnl ! ACE_LACKS_MSGRCV_VOIDP_2 +dnl ! ACE_LACKS_SHMAT_VOIDP_2 +dnl +dnl So, for now, we define it if any of those were autoconf'ed. + +dnl @@ THESE NEED TO BE ADDED AS PROPER CONFIG SETTINGS. --Steve +dnl if test "$ace_cv_lib_posix_msgsnd_msgbufp_2" = yes || +dnl test "$ace_cv_lib_posix_msgrcv_voidp_2" != yes || +dnl test "$ace_cv_lib_posix_shmat_voidp_2" != yes ; then +dnl AC_DEFINE([ACE_LACKS_SOME_POSIX_PROTOTYPES]) +dnl fi + +if test "$ac_cv_func_msgctl" = yes && + test "$ac_cv_func_msgget" = yes && + test "$ac_cv_func_msgrcv" = yes && + test "$ac_cv_func_semctl" = yes && + test "$ac_cv_func_semget" = yes && + test "$ac_cv_func_semop" = yes && + test "$ac_cv_func_shmat" = yes && + test "$ac_cv_func_shmctl" = yes && + test "$ac_cv_func_shmdt" = yes && + test "$ac_cv_func_shmget" = yes; then + AC_DEFINE([ACE_HAS_SYSV_IPC]) +fi + +if test "$ac_cv_func_shmat" != yes || + test "$ac_cv_func_shmctl" != yes || + test "$ac_cv_func_shmdt" != yes || + test "$ac_cv_func_shmget" != yes; then + AC_DEFINE([ACE_LACKS_SYSV_SHMEM]) +fi + +dnl Check for what POSIX threads draft we have +AC_MSG_CHECKING([which POSIX thread library was found]) + +ace_has_pthreads=no + +dnl Check if we have Pthreads Draft 4 +dnl if test "$ac_cv_func_pthread_delay_np" = yes && +if test "$ac_cv_func_pthread_mutexattr_create" = yes && +dnl test "$ac_cv_func_pthread_mutexattr_setkind_np" = yes && + test "$ac_cv_func_pthread_mutexattr_delete" = yes && + test "$ac_cv_func_pthread_condattr_delete" = yes && + test "$ac_cv_func_pthread_condattr_create" = yes && + test "$ac_cv_func_pthread_setprio" = yes && + test "$ac_cv_func_pthread_getprio" = yes && +dnl test "$ac_cv_func_pthread_getspecific" = yes && + test "$ac_cv_func_pthread_setcancel" = yes && + test "$ac_cv_func_pthread_setasynccancel" = yes && + test "$ac_cv_func_pthread_kill" = yes; then + ace_has_pthreads=yes + AC_MSG_RESULT([POSIX Threads Draft 4]) + AC_DEFINE([ACE_HAS_PTHREADS_DRAFT4], 1, + [Platform supports POSIX Threads .4a Draft 4]) +dnl Check if we have Pthreads Draft 6 +elif test "$ac_cv_func_pthread_mutexattr_init" = yes && + test "$ac_cv_func_pthread_mutexattr_destroy" = yes && + test "$ac_cv_func_pthread_condattr_destroy" = yes && + test "$ac_cv_func_pthread_condattr_init" = yes && + test "$ac_cv_func_pthread_attr_setprio" = yes && + test "$ac_cv_func_pthread_attr_getprio" = yes && + test "$ac_cv_func_pthread_setintr" = yes && + test "$ac_cv_func_pthread_setintrtype" = yes; then + ace_has_pthreads=yes + AC_MSG_RESULT([POSIX Threads Draft 6]) + AC_DEFINE([ACE_HAS_PTHREADS_DRAFT6], 1, + [Platform supports POSIX Threads .4a Draft 6]) +dnl Check if we have Pthreads Draft 7 +elif test "$ac_cv_func_pthread_mutexattr_init" = yes && + test "$ac_cv_func_pthread_mutexattr_destroy" = yes && + test "$ac_cv_func_pthread_condattr_destroy" = yes && + test "$ac_cv_func_pthread_condattr_init" = yes && + test "$ac_cv_func_pthread_setschedparam" = yes && + test "$ac_cv_func_pthread_getschedparam" = yes && + test "$ac_cv_func_pthread_setcancelstate" = yes && + test "$ac_cv_func_pthread_setcanceltype" = yes && + test "$ace_has_sched_yield" != yes; then + ace_has_pthreads=yes + AC_MSG_RESULT([POSIX Threads Draft 7]) + AC_DEFINE([ACE_HAS_PTHREADS_DRAFT7], 1, + [Platform supports POSIX Threads .1c Draft 7]) +dnl Check if we have Pthreads Draft Standard +elif test "$ac_cv_func_pthread_mutexattr_init" = yes && + test "$ac_cv_func_pthread_mutexattr_destroy" = yes && + test "$ac_cv_func_pthread_condattr_destroy" = yes && + test "$ac_cv_func_pthread_condattr_init" = yes && + test "$ac_cv_func_pthread_setschedparam" = yes && + test "$ac_cv_func_pthread_getschedparam" = yes && + test "$ac_cv_func_pthread_setcancelstate" = yes && + test "$ac_cv_func_pthread_setcanceltype" = yes && + test "$ace_has_sched_yield" = yes; then + ace_has_pthreads=yes + AC_MSG_RESULT([POSIX Threads Draft Standard]) + AC_DEFINE([ACE_HAS_PTHREADS_STD], 1, + [Platform supports POSIX.1c-1995 threads]) +else + ace_has_pthreads=no + AC_MSG_RESULT([none]) +fi dnl PTHREAD DRAFT CHECKS + +dnl Check if we have UNIX International threads +AC_MSG_CHECKING([if a UNIX International thread library was found]) +if test "$ace_has_sthreads" = yes; then + AC_MSG_RESULT([yes]) +else + AC_MSG_RESULT([no]) +fi + +if test "$ace_user_enable_threads" != yes || + test "$ace_has_pthreads" != yes && + test "$ace_has_sthreads" != yes; then + dnl We don't have a usable thread library! + ace_user_enable_threads=no + dnl Make sure _REENTRANT and _THREAD_SAFE are not in the + dnl preprocessor flags since thread support is being disabled. + dnl Removal of these flags is only performed if the configure script + dnl added them. + if test -n "$ACE_THR_CPPFLAGS"; then +dnl changequote(, )dnl + CPPFLAGS=`eval "echo $CPPFLAGS | sed -e 's/$ACE_THR_CPPFLAGS//' -e 's/-D_THREAD_SAFE\(=[[0-9]]*\)\?//'"` +dnl changequote([, ])dnl + fi + + AC_MSG_WARN([It appears that you do NOT have any usable thread libraries]) + AC_MSG_WARN([or thread support was explicitly disabled.]) + AC_MSG_WARN([Disabling thread support.]) + dnl ACE uses different versions of readdir_r depending on the thread + dnl library being used, i.e. on the ACE_HAS_*THREADS* macros. Since + dnl it doesn't seem like a good idea to define any ACE_HAS_*THREADS* + dnl macro if ACE won't be supporting threads, define ACE_LACKS_READDIR_R + dnl regardless if readdir_r() exists. + if test "$ac_cv_func_readdir_r" = yes; then + AC_MSG_WARN([Disabling support for readdir_r() since thread support]) + AC_MSG_WARN([is being disabled.]) + AC_DEFINE([ACE_LACKS_READDIR_R]) + fi dnl test "$ac_cv_func_readdir_r" = yes +fi dnl + +if test "$ace_user_enable_threads" = yes; then +dnl If we get this far then we have threads. +dnl FIXME: The "_POSIX" macros may need to be defined _before_ the checks for +dnl reentrant functions! However, we don't want to define them if +dnl the UNIX International threads library was detected. + AC_DEFINE([ACE_HAS_THREADS]) + AC_DEFINE([ACE_MT_SAFE]) + ACE_CPPFLAGS="$ACE_CPPFLAGS $ACE_THR_CPPFLAGS" + + if test "$ace_has_pthreads" = yes; then + + dnl Check if OS requires non-null status pointer for ::pthread_join () + dnl + dnl This test must be performed after the POSIX threads implementation + dnl that the platform supports has been determined. + ACE_CACHE_CHECK([for pthread_join null status pointer support], + [ace_cv_have_null_status_pthread_join],[ + AC_EGREP_CPP([WE_HAVE_PTHREADS_D4], + [ +#if defined (ACE_HAS_PTHREADS) && defined (ACE_HAS_PTHREADS_DRAFT4) +/* This test is only valid for Pthreads Draft 4 */ +WE_HAVE_PTHREADS_D4 +#endif + ], + [ + AC_RUN_IFELSE([AC_LANG_SOURCE([[ +#ifndef _REENTRANT +#define _REENTRANT +#endif + +#include + +/* _THREAD_SAFE is defined in on some platforms. */ +#ifndef _THREAD_SAFE +#define _THREAD_SAFE +#endif + +#include + +#ifdef __cplusplus +extern "C" +#endif +void * +nothing (void *unused) +{ + return (void *) 34; +}; + +int +main () +{ + pthread_attr_t attr; + pthread_t id; + void *status; + int retval = 0; + + /* ----- */ + /* We return 0 on error for these calls since we only want to + return an error status if pthread_join fails. If these calls + fail then we've got other problems! */ + if (pthread_attr_create (&attr) != 0) return 0 /*1*/; + + if (pthread_create (&id, attr, nothing, 0) != 0) return 0 /*2*/; + + if (pthread_attr_delete (&attr) != 0) return /*3*/; + /* ----- */ + + /* With a second (status) arg of 0, LynxOS 3.0.0 pthread_join () + will fail with errno 14 (address fault detected). */ + if (pthread_join (id, 0) == -1) { + fprintf (stderr, "%s: %d; ", __FILE__, __LINE__); + perror ("pthread_join"); + retval = 1; + } + + if (pthread_join (id, &status) == -1) { + fprintf (stderr, "%s: %d; ", __FILE__, __LINE__); + perror ("pthread_join"); + retval = 2; + } + + return retval; +} + ]])],[ + ace_cv_have_null_status_pthread_join=yes + ],[ + ace_cv_have_null_status_pthread_join=no + ],[ + dnl If we are cross-compiling let's hope that + dnl that we have a working null status pointer + dnl for pthread_join. + ace_cv_have_null_status_pthread_join=yes + ]) + ], + [ + ace_cv_have_null_status_pthread_join=yes + ]) + ], , [AC_DEFINE([ACE_LACKS_NULL_PTHREAD_STATUS])]) + + dnl Check if OS supports mutex timeouts + dnl (e.g. pthread_mutex_timedlock()). + ACE_CACHE_CHECK([for mutex timeouts], + [ace_cv_have_mutex_timeouts],[ + AC_RUN_IFELSE([AC_LANG_SOURCE([[ +#ifndef _REENTRANT +#define _REENTRANT +#endif + +#include + +/* _THREAD_SAFE is defined in on some platforms. */ +#ifndef _THREAD_SAFE +#define _THREAD_SAFE +#endif + +#include + +#include +#include + +#include +#ifndef ACE_LACKS_UNISTD_H +# include +#endif + +pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; + +#ifdef __cplusplus +extern "C" +#endif +void *threadFunc (void *parm) +{ + int rc; + int i; + struct timespec deltatime; + struct timeval tv; + + if (gettimeofday (&tv, 0) != 0) + { + return 0; + } + + deltatime.tv_sec = tv.tv_sec + 5; + deltatime.tv_nsec = 0; + + rc = pthread_mutex_timedlock (&mutex, &deltatime); + + if (rc != ETIMEDOUT) + { + /* printf("Got an incorrect return code from pthread_mutex_timedlock\n"); */ + } + + return 0; +} + +int main (void) +{ + int rc =0; + pthread_t thread; + + rc = pthread_mutex_lock (&mutex); + if (rc != 0) + { + exit (-1); + } + + rc = pthread_create (&thread, NULL, threadFunc, NULL); + if (rc != 0) + { + exit (-1); + } + + rc = pthread_join (thread, NULL); + if (rc != 0) + { + exit (-1); + } + + pthread_mutex_destroy (&mutex); + + return 0; +} + ]])],[ + ace_cv_have_mutex_timeouts=yes + ],[ + ace_cv_have_mutex_timeouts=no + ],[ + dnl Cross-compiled case + AC_CHECK_FUNC([pthread_mutex_timedlock], + [ace_cv_have_mutex_timeouts=yes], + [ace_cv_have_mutex_timeouts=no]) + ]) + ], [AC_DEFINE([ACE_HAS_MUTEX_TIMEOUTS])],) + + dnl Check if platform needs to #include to get thread + dnl scheduling defs. + ACE_CACHE_CHECK([if sched.h is needed for thread scheduling definitions], + [ace_cv_needs_sched_h], + [ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#ifdef ACE_HAS_STHREADS +#include +#endif + +#ifdef ACE_HAS_PTHREADS +#include +#endif + ]], [[ +int foo = SCHED_OTHER; + ]])],[ + ace_cv_needs_sched_h=no + ],[ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM( + [[ +#ifdef ACE_HAS_STHREADS +#include +#endif + +#ifdef ACE_HAS_PTHREADS +#include +#endif + +#include + ]], + [[ +int foo = SCHED_OTHER; + ]])], + [ + ace_cv_needs_sched_h=yes + ], + [ + dnl We're hosed if we get here! + ace_cv_needs_sched_h=no + ]) + ]) + ], + [ + AC_DEFINE([ACE_NEEDS_SCHED_H]) + ],) + + dnl Check if platform only supports SCHED_OTHER scheduling policy + dnl + dnl This test must be performed after the POSIX threads implementation + dnl that the platform supports has been determined. + ACE_CACHE_CHECK([if SCHED_OTHER is only scheduling policy], + [ace_cv_feature_only_have_sched_other], + [ + AC_EGREP_CPP([WE_ONLY_HAVE_SCHED_OTHER], + [ +#ifdef ACE_HAS_STHREADS +# include +#endif + +#ifdef ACE_HAS_PTHREADS +# include +#endif + +#if defined (ACE_NEEDS_SCHED_H) +# include +#endif + + /* These are ORed so that ACE will not redefine + any of them if any of them exist. */ +#if !defined (SCHED_FIFO) && \ + !defined (SCHED_RR) && \ + defined (SCHED_OTHER) + WE_ONLY_HAVE_SCHED_OTHER +#endif + ], + [ + ace_cv_feature_only_have_sched_other=yes + ], + [ + AC_RUN_IFELSE([AC_LANG_SOURCE([[ +#ifndef _REENTRANT +#define _REENTRANT +#endif + +#include + +/* _THREAD_SAFE is defined in on some platforms. */ +#ifndef _THREAD_SAFE +#define _THREAD_SAFE +#endif + +#include +#include + +int main () +{ + pthread_attr_t ace_attr; + +#if defined (ACE_HAS_PTHREADS_DRAFT4) + if (pthread_attr_create (&ace_attr) != 0) +#else + if (pthread_attr_init (&ace_attr) != 0) +#endif + { + perror ("pthread_attr_init"); + return 0; /* Return "successfully" since only the policy call + will return with an error for this test. */ + } + +#if defined (ACE_HAS_PTHREADS_DRAFT4) + if (pthread_attr_setsched (&ace_attr, SCHED_FIFO) != 0) +#else + if (pthread_attr_setschedpolicy (&ace_attr, SCHED_FIFO) != 0) +#endif + { + perror ("pthread_attr_setschedpolicy"); + return -1; + } + +#if defined (ACE_HAS_PTHREADS_DRAFT4) + if (pthread_attr_delete (&ace_attr) != 0) +#else + if (pthread_attr_destroy (&ace_attr) != 0) +#endif + { + perror ("pthread_attr_destroy"); + return 0; /* Return "successfully" since only the policy call + will return with an error for this test. */ + } + + return 0; +} + ]])],[ + ace_cv_feature_only_have_sched_other=no + ],[ + ace_cv_feature_only_have_sched_other=yes + ],[ + dnl We only get here if polices other than SCHED_OTHER + dnl were found in the headers and we are cross-compiling. + dnl + dnl If we are cross-compiling let's hope that the + dnl scheduling policies found in the headers + dnl besides SCHED_OTHER (e.g. SCHED_FIFO, SCHED_RR) + dnl are supported. + ace_cv_feature_only_have_sched_other=no + ]) + ]) + ], [AC_DEFINE([ACE_HAS_ONLY_SCHED_OTHER])],) + fi dnl test "$ace_has_pthreads" = yes +fi dnl test "$ace_user_enable_threads" = yes + + +AC_CHECK_HEADER(libc.h) +AC_CHECK_HEADER(osfcn.h) +if test "$ac_cv_header_libc_h" != yes || + test "$ac_cv_header_osfcn_h" != yes; then + AC_DEFINE([ACE_HAS_CPLUSPLUS_HEADERS]) +fi + + + +if test "$ace_cv_lib_signal_vi1_2" = yes && + test "$ace_cv_lib_signal_vi1_ret" = yes && + test "$ace_cv_lib_struct_sigaction_vi1_handler" = yes; then + AC_DEFINE([ACE_HAS_CONSISTENT_SIGNAL_PROTOTYPES]) +elif test "$ace_cv_lib_signal_vi1_2" != yes && + test "$ace_cv_lib_signal_vv1_2" != yes && + test "$ace_cv_lib_signal_vi1a2_2" != yes && + test "$ace_cv_lib_signal_va1_2" = yes && + test "$ace_cv_lib_signal_vi1_ret" != yes && + test "$ace_cv_lib_signal_vv1_ret" != yes && + test "$ace_cv_lib_signal_vi1a2_ret" != yes && + test "$ace_cv_lib_signal_va1_ret" = yes && + test "$ace_cv_lib_struct_sigaction_vi1_handler" != yes && + test "$ace_cv_lib_struct_sigaction_vv1_handler" != yes && + test "$ace_cv_lib_struct_sigaction_vi1a2_handler" != yes && + test "$ace_cv_lib_struct_sigaction_va1_handler" = yes; then + AC_DEFINE([ACE_HAS_LYNXOS_SIGNALS]) + AC_DEFINE([ACE_HAS_TANDEM_SIGNALS]) +elif test "$ace_cv_lib_signal_vi1_2" = yes && + test "$ace_cv_lib_signal_vi1_ret" = yes && + test "$ace_cv_lib_struct_sigaction_vi1_handler" != yes; then + AC_DEFINE([ACE_HAS_SVR4_SIGNAL_T]) +elif test "$ace_cv_lib_signal_vi1_2" = yes && + test "$ace_cv_lib_signal_vv1_ret" = yes && + test "$ace_cv_lib_struct_sigaction_vv1_handler" = yes; then + AC_DEFINE([ACE_HAS_SVR4_SIGNAL_T]) +elif test "$ace_cv_lib_signal_vi1_2" = yes && + test "$ace_cv_lib_signal_vi1_ret" != yes && + test "$ace_cv_lib_signal_vv1_ret" != yes && + test "$ace_cv_lib_signal_vi1a2_ret" != yes && + test "$ace_cv_lib_signal_va1_ret" = yes && + test "$ace_cv_lib_struct_sigaction_vi1_handler" != yes && + test "$ace_cv_lib_struct_sigaction_vv1_handler" != yes && + test "$ace_cv_lib_struct_sigaction_vi1a2_handler" != yes && + test "$ace_cv_lib_struct_sigaction_va1_handler" = yes; then + AC_DEFINE([ACE_HAS_UNIXWARE_SVR4_SIGNAL_T]) +fi dnl ACE_HAS_CONSISTENT_SIGNAL_PROTOTYPES + +dnl +dnl SECTION 15: Final checks +dnl + +dnl Make final substitutions and defines +if test "$ace_u_long_long_typedef_set" = yes; then + AC_DEFINE_UNQUOTED([ACE_INT64_TYPE], [$ACE_INT64], + [Define to signed 64 bit integer type]) + AC_DEFINE_UNQUOTED([ACE_UINT64_TYPE], [$ACE_UINT64], + [Define to unsigned 64 bit integer type]) +fi + +dnl Combine package set flags with user's flags. +dnl User's flags go after package flags to allow user to override +dnl package defaults. +dnl X_CFLAGS comes from AC_PATH_XTRA. It may include, for example, +dnl additional include file paths or macros that need to be defined +dnl in order for X11 related files to be compiled properly. +if test "$ace_user_enable_optimize"; then + dnl We want OCXXFLAGS to be on the end, so we use CXXFLAGS, + dnl not ACE_CXXFLAGS! + CXXFLAGS="$CXXFLAGS $OCXXFLAGS" + CFLAGS="$CFLAGS $OCFLAGS" +fi +CXXFLAGS="$ACE_CXXFLAGS $X_CFLAGS $CXXFLAGS" +CFLAGS="$ACE_CFLAGS $X_CFLAGS $CFLAGS" +CPPFLAGS="$ACE_CPPFLAGS $CPPFLAGS" +LDFLAGS="$ACE_LDFLAGS $LDFLAGS" + +dnl The following tests should be performed _after_ the bulk of the +dnl ACE macros have been defined. + +dnl Flush the cache so that it is easier to debug the configure script +dnl if the following integrity check fails. +AC_CACHE_SAVE + +dnl Verify the integrity of the current configuration. +ACE_CACHE_CHECK([if generated ACE configuration is usable], + [ace_cv_configuration_is_usable], + [ + dnl We want an empty ace/config.h to prevent multiple defines + dnl with Autoconf's confdefs.h + ACE_USE_TEMP_FILE([ace/config.h], + [ + dnl Now run the compilation test + ACE_TRY_COMPILE([-I. -I${srcdir}], + [ +// Include ".cpp" files instead of headers so that we can get a more +// thorough test compile. +#include "ace/Time_Value.cpp" +#include "ace/Reactor.cpp" + ], + [ + ACE_Time_Value t = ACE_OS::gettimeofday (); + t++; + + ACE_Reactor * r = ACE_Reactor::instance (); + + (void) r->close (); + ], + [ + ace_cv_configuration_is_usable=yes + ], + [ + ace_cv_configuration_is_usable=no + ]) + ]) + ], + [ + dnl Looks good! Do nothing. + dnl It appears that ace/OS.cpp compiled. If it didn't compile then + dnl there would be no chance that the rest of ACE would compile. + ], + [ + AC_MSG_ERROR( + [ +The generated configuration appears to be unusable. Please verify +that your system path and environment variables are correct. If they +appear to be correct then please send the maintainer of this configure +script $ACE_CONFIGURE_MAINTAINER the *COMPRESSED* 'config.log' file +and the following information: + + ACE 'configure' Script Information + ================================== + [RCS] translit([$Id: configure.ac 82573 2008-08-08 18:13:53Z jtc $], [$"]) + + + ACE Version: ACE_VERSION + C++ Compiler: $CXX + C++ Preprocessor: $CXXCPP + C++ Flags: $CXXFLAGS + Preprocessor Flags: $CPPFLAGS + Linker: $LD + Linker Flags: $LDFLAGS + Libraries: $LIBS + System type information: + Build: $build Host: $host + +In the meantime, please use the stock ACE build procedure detailed in +the file 'ACE-INSTALL.html'. + ]) + ]) + +dnl " + +dnl Check for ACE_IOStream support +ACE_CACHE_CHECK([for ACE_IOStream support], + [ace_cv_feature_ace_iostream], + [ + dnl We want an empty ace/config.h to prevent multiple defines + dnl with Autoconf's confdefs.h + ACE_USE_TEMP_FILE([ace/config.h], + [ + dnl Now run the compilation test + ACE_TRY_COMPILE([-I. -I${srcdir}], + [ +#include "ace/IOStream.cpp" + ], + [ + int a = 0; a += 1; + ], + [ + ace_cv_feature_ace_iostream=yes + ], + [ + ace_cv_feature_ace_iostream=no + ]) + ]) + ], , [AC_DEFINE([ACE_LACKS_ACE_IOSTREAM])]) + +dnl Check if ACE needs conversion to pass ACE_TTY_IO to DEV_Connector +ACE_CACHE_CHECK([if ACE needs conversion to pass ACE_TTY_IO to DEV_Connector], + [ace_cv_lib_need_dev_io_conv], + [ + dnl We want an empty ace/config.h to prevent multiple defines + dnl with Autoconf's confdefs.h + ACE_USE_TEMP_FILE([ace/config.h], + [ + dnl Now run the compilation test + ACE_TRY_COMPILE([-I. -I${srcdir}], + [ +#include "ace/OS.cpp" + ], + [ + int a=0; a += 1; + ], + [ + ace_cv_lib_need_dev_io_conv=no + ], + [ + dnl Now check if ACE_NEEDS_DEV_IO_CONVERSION makes + dnl compilation work! + ACE_TRY_COMPILE([-I. -I${srcdir}], + [ +#define ACE_NEEDS_DEV_IO_CONVERSION +#include "ace/DEV_Connector.cpp" + ], + [ + int a=0; a += 1; + ], + [ + ace_cv_lib_need_dev_io_conv=yes + ], + [ + dnl If we get here, then we have no idea what is wrong! + ace_cv_lib_need_dev_io_conv=no + ]) + ]) + ]) + ], [AC_DEFINE([ACE_NEEDS_DEV_IO_CONVERSION])],) + +dnl End ACE macro tests! + +dnl Substitute whatever X libraries ACE needs, if any. +AC_SUBST([ACE_XLIBS]) + +dnl Prepend purify and quantify command lines if purify and quantify are +dnl enabled. Otherwise, PURELINK and PRELINK will just be "blank." +LD="$PURELINK $PRELINK $LD" +dnl LDFLAGS="$ACE_LDFLAGS $LDFLAGS" + +dnl AC_SUBST(LDFLAGS) +dnl AC_SUBST(LIBOBJS) + +dnl Force CXXFLAGS to be substituted in Makefiles that don't "need" them. +AC_SUBST([CXXFLAGS]) + +dnl Precompute the absolute pathname of the ACE tests directory so +dnl that we can avoid using GNU Make extensions in the ACE tests +dnl Makefile. +ACE_TESTS_DIR=`pwd`/tests +AC_SUBST([ACE_TESTS_DIR]) + +dnl +dnl SECTION 16: AC_CONFIG_FILES([FILE...]) +dnl +dnl +dnl We can finally create all the files listed here; Makefile is +dnl created from Makefile.in, etc. Top-level Makefiles should be +dnl created first. + +dnl Makefile +dnl ace/Makefile +dnl apps/Makefile +dnl apps/gperf/Makefile +dnl apps/gperf/src/Makefile +dnl man/Makefile +dnl man/man3/Makefile +dnl netsvcs/Makefile +dnl netsvcs/clients/Makefile +dnl netsvcs/clients/Logger/Makefile +dnl netsvcs/clients/Naming/Makefile +dnl netsvcs/clients/Naming/Client/Makefile +dnl netsvcs/clients/Naming/Dump_Restore/Makefile +dnl netsvcs/clients/Tokens/Makefile +dnl netsvcs/clients/Tokens/collection/Makefile +dnl netsvcs/clients/Tokens/deadlock/Makefile +dnl netsvcs/clients/Tokens/invariant/Makefile +dnl netsvcs/clients/Tokens/manual/Makefile +dnl netsvcs/clients/Tokens/mutex/Makefile +dnl netsvcs/clients/Tokens/rw_lock/Makefile +dnl netsvcs/lib/Makefile +dnl netsvcs/servers/Makefile +dnl tests/Makefile + +AC_CONFIG_FILES([ + Makefile + ace/Makefile +]) + +dnl Note that the "ACE_VERSION" in the message below is an M4 macro +dnl that expands to the version of ACE being configured. +AC_CONFIG_COMMANDS([default],[ + echo "" + echo "Configuration of ACE ACE_VERSION is now complete." + echo "" + ],[]) +AC_OUTPUT diff --git a/dep/ACE_wrappers/m4/ace.m4 b/dep/ACE_wrappers/m4/ace.m4 new file mode 100644 index 00000000000..f045557639d --- /dev/null +++ b/dep/ACE_wrappers/m4/ace.m4 @@ -0,0 +1,1770 @@ +dnl ------------------------------------------------------------------------- +dnl $Id: ace.m4 82523 2008-08-06 08:36:01Z johnnyw $ +dnl +dnl ace.m4 +dnl +dnl ACE M4 include file which contains ACE specific M4 macros +dnl for enabling/disabling certain ACE features. +dnl +dnl ------------------------------------------------------------------------- + +dnl Copyright (C) 1998, 1999, 2000, 2002 Ossama Othman +dnl +dnl All Rights Reserved +dnl +dnl This library is free software; you can redistribute it and/or +dnl modify it under the current ACE distribution terms. +dnl +dnl This library is distributed in the hope that it will be useful, +dnl but WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + + +dnl Macros that add ACE configuration options to a `configure' script. +dnl ACE_CONFIGURATION_OPTIONS +AC_DEFUN([ACE_CONFIGURATION_OPTIONS], +[ + AM_CONDITIONAL([BUILD_ACE_FOR_TAO], false) + + AC_ARG_ENABLE([ace-codecs], + AS_HELP_STRING(--enable-ace-codecs,build ACE with codecs support [[[yes]]]), + [ + case "${enableval}" in + yes) + ace_user_enable_ace_codecs=yes + ;; + no) + ace_user_enable_ace_codecs=no + ;; + *) + AC_MSG_ERROR([bad value ${enableval} for --enable-ace-codecs]) + ;; + esac + ], + [ + ace_user_enable_ace_codecs=yes + ]) + AM_CONDITIONAL([BUILD_ACE_CODECS], [test X$ace_user_enable_ace_codecs = Xyes]) + + AC_ARG_ENABLE([ace-filecache], + AS_HELP_STRING(--enable-ace-filecache,build ACE_Filecache support [[[yes]]]), + [ + case "${enableval}" in + yes) + ace_user_enable_ace_filecache=yes + ;; + no) + ace_user_enable_ace_filecache=no + ;; + *) + AC_MSG_ERROR([bad value ${enableval} for --enable-ace-filecache]) + ;; + esac + ], + [ + dnl Enable ACE_Filecache support by default since it's never turned off + dnl in the ACE lib itself. Just required for some things like JAWS. + ace_user_enable_ace_filecache=yes + ]) + AM_CONDITIONAL([BUILD_ACE_FILECACHE], [test X$ace_user_enable_ace_filecache = Xyes]) + + AC_ARG_ENABLE([ace-other], + AS_HELP_STRING(--enable-ace-other,build ACE with all misc pieces [[[yes]]]), + [ + case "${enableval}" in + yes) + ace_user_enable_ace_other=yes + ;; + no) + ace_user_enable_ace_other=no + ;; + *) + AC_MSG_ERROR([bad value ${enableval} for --enable-ace-other]) + ;; + esac + ], + [ + ace_user_enable_ace_other=yes + ]) + AM_CONDITIONAL([BUILD_ACE_OTHER], [test X$ace_user_enable_ace_other = Xyes]) + + AC_ARG_ENABLE([ace-token], + AS_HELP_STRING(--enable-ace-token,build ACE with tokens support [[[yes]]]), + [ + case "${enableval}" in + yes) + ace_user_enable_ace_token=yes + ;; + no) + ace_user_enable_ace_token=no + ;; + *) + AC_MSG_ERROR([bad value ${enableval} for --enable-ace-token]) + ;; + esac + ], + [ + ace_user_enable_ace_token=yes + ]) + AM_CONDITIONAL([BUILD_ACE_TOKEN], [test X$ace_user_enable_ace_token = Xyes]) + + AC_ARG_ENABLE([ace-uuid], + AS_HELP_STRING(--enable-ace-uuid,build ACE with UUID support [[[yes]]]), + [ + case "${enableval}" in + yes) + ace_user_enable_ace_uuid=yes + ;; + no) + ace_user_enable_ace_uuid=no + ;; + *) + AC_MSG_ERROR([bad value ${enableval} for --enable-ace-uuid]) + ;; + esac + ], + [ + ace_user_enable_ace_uuid=yes + ]) + AM_CONDITIONAL([BUILD_ACE_UUID], [test X$ace_user_enable_ace_uuid = Xyes]) + + AC_ARG_ENABLE([alloca], + AS_HELP_STRING(--enable-alloca,compile with alloca() support [[[no]]]), + [ + case "${enableval}" in + yes) + ace_user_enable_alloca=yes + ;; + no) + ace_user_enable_alloca=no + ;; + *) + AC_MSG_ERROR([bad value ${enableval} for --enable-alloca]) + ;; + esac + ], + [ + dnl Disable alloca() support by default since its use is generally + dnl not recommended. + ace_user_enable_alloca=no + ]) + + AC_ARG_ENABLE([rwho], + AS_HELP_STRING(--enable-rwho,build the distributed rwho program [[[no]]]), + [ + case "${enableval}" in + yes) + ace_user_enable_rwho=yes + ;; + no) + ace_user_enable_rwho=no + ;; + *) + AC_MSG_ERROR([bad value ${enableval} for --enable-rwho]) + ;; + esac + ],) + AM_CONDITIONAL([BUILD_RWHO], [test X$ace_user_enable_rwho = Xyes]) + + AC_ARG_ENABLE([ipv4-ipv6], + AS_HELP_STRING(--enable-ipv4-ipv6,compile with IPv4/IPv6 migration support [[[no]]]), + [ + case "${enableval}" in + yes) + AC_DEFINE(ACE_HAS_IPV6) + AC_DEFINE(ACE_USES_IPV4_IPV6_MIGRATION) + ;; + no) + ;; + *) + AC_MSG_ERROR([bad value ${enableval} for --enable-ipv4-ipv6]) + ;; + esac + ],) + + AC_ARG_ENABLE([ipv6], + AS_HELP_STRING(--enable-ipv6,compile with IPv6 support [[[no]]]), + [ + case "${enableval}" in + yes) + AC_DEFINE(ACE_HAS_IPV6) + ace_user_enable_ipv6=yes + ;; + no) + ace_user_enable_ipv6=no + ;; + *) + AC_MSG_ERROR([bad value ${enableval} for --enable-ipv6]) + ;; + esac + ],) + AM_CONDITIONAL([BUILD_IPV6], [test X$ace_user_enable_ipv6 = Xyes]) + + AC_ARG_ENABLE([log-msg-prop], + AS_HELP_STRING(--enable-log-msg-prop,enable threads inheriting ACE_Log_Msg properties from parent thread [[[yes]]]), + [ + case "${enableval}" in + yes) + dnl nothing to do + ;; + no) + AC_DEFINE(ACE_THREADS_DONT_INHERIT_LOG_MSG) + ;; + *) + AC_MSG_ERROR([bad value ${enableval} for --enable-log-msg-prop]) + ;; + esac + ],) + + AC_ARG_ENABLE([logging], + AS_HELP_STRING(--enable-logging,enable ACE logging macros [[[yes]]]), + [ + case "${enableval}" in + yes) + dnl nothing to do + ;; + no) + AC_DEFINE([ACE_NLOGGING]) + ;; + *) + AC_MSG_ERROR([bad value ${enableval} for --enable-logging]) + ;; + esac + ],) + + AC_ARG_ENABLE([malloc-stats], + AS_HELP_STRING(--enable-malloc-stats,enable malloc statistics collection [[[no]]]), + [ + case "${enableval}" in + yes) + AC_DEFINE([ACE_HAS_MALLOC_STATS]) + ;; + no) + dnl nothing to do + ;; + *) + AC_MSG_ERROR([bad value ${enableval} for --enable-malloc-stats]) + ;; + esac + ],) + + AC_ARG_ENABLE([pi-pointers], + AS_HELP_STRING(--enable-pi-pointers,enable pos. indep. pointers [[[yes]]]), + [ + case "${enableval}" in + yes) + AC_DEFINE([ACE_HAS_POSITION_INDEPENDENT_POINTERS]) + ;; + no) + ;; + *) + AC_MSG_ERROR([bad value ${enableval} for --enable-pi-pointers]) + ;; + esac + ], + [ + AC_DEFINE([ACE_HAS_POSITION_INDEPENDENT_POINTERS]) + ]) + + AC_ARG_ENABLE([posix-sem-timeout-emulation], + AS_HELP_STRING(--enable-posix-sem-timeout-emulation,enable POSIX semaphore timeout emulation [[[no]]]), + [ + case "${enableval}" in + yes) + AC_DEFINE([ACE_DISABLE_POSIX_SEM_TIMEOUT_EMULATION]) + ;; + no) + ;; + *) + AC_MSG_ERROR([bad value ${enableval} for --enable-posix-sem-timeout-emulation]) + ;; + esac + ],) + + AC_ARG_ENABLE([probe], + AS_HELP_STRING(--enable-probe,enable ACE_Timeprobes [[[no]]]), + [ + case "${enableval}" in + yes) + AC_DEFINE([ACE_COMPILE_TIMEPROBES]) + ;; + no) + ;; + *) + AC_MSG_ERROR([bad value ${enableval} for --enable-probe]) + ;; + esac + ],) + + AC_ARG_ENABLE([static-obj-mgr], + AS_HELP_STRING(--enable-static-obj-mgr,enable static Object_Manager [[[yes]]]), + [ + case "${enableval}" in + yes) + dnl nothing to do + ;; + no) + AC_DEFINE([ACE_HAS_NONSTATIC_OBJECT_MANAGER]) + ;; + *) + AC_MSG_ERROR([bad value ${enableval} for --enable-static-obj-mgr]) + ;; + esac + ],) + + + AC_ARG_ENABLE([threads], + AS_HELP_STRING(--enable-threads,enable thread support [[[yes]]]), + [ + case "${enableval}" in + yes) + ace_user_enable_threads=yes + ;; + no) + ace_user_enable_threads=no + ;; + *) + AC_MSG_ERROR([bad value ${enableval} for --enable-threads]) + ;; + esac + ], + [ + ace_user_enable_threads=yes + ]) + AM_CONDITIONAL([BUILD_THREADS], [test X$ace_user_enable_threads = Xyes]) + + AC_ARG_ENABLE([pthreads], + AS_HELP_STRING(--enable-pthreads,enable POSIX thread (Pthreads) support [[[yes]]]), + [ + case "${enableval}" in + yes) + ace_user_enable_pthreads=yes + ;; + no) + ace_user_enable_pthreads=no + ;; + *) + AC_MSG_ERROR([bad value ${enableval} for --enable-pthreads]) + ;; + esac + ], + [ + ace_user_enable_pthreads=yes + ]) + + AC_ARG_ENABLE([aio], + AS_HELP_STRING(--enable-aio,enable aio support [[[yes]]]), + [ + case "${enableval}" in + yes) + ace_user_enable_aio=yes + ;; + no) + ace_user_enable_aio=no + ;; + *) + AC_MSG_ERROR([bad value ${enableval} for --enable-aio]) + ;; + esac + ], + [ + ace_user_enable_aio=yes + ]) + + AC_ARG_ENABLE([uithreads], + AS_HELP_STRING(--enable-uithreads,enable UNIX International thread support [[[no]]]), + [ + case "${enableval}" in + yes) + ace_user_enable_uithreads=yes + ;; + no) + ace_user_enable_uithreads=no + ;; + *) + AC_MSG_ERROR([bad value ${enableval} for --enable-uithreads]) + ;; + esac + ], + [ + dnl The default is to disable UI threads. However, on Solaris, we + dnl enable it by default since it's functionality is very useful and + dnl has traditionally been enabled in ACE. + case "$host" in + *solaris2*) + ace_user_enable_uithreads=yes + AC_MSG_NOTICE([[--enable-uithreads enabled by default for Solaris; use --enable-uithreads=no to disable it.]]) + ;; + *) + ace_user_enable_uithreads=no + ;; + esac + ]) + + AC_ARG_ENABLE([verb-not-sup], + AS_HELP_STRING(--enable-verb-not-sup,enable verbose ENOTSUP reports [[[no]]]), + [ + case "${enableval}" in + yes) + AC_DEFINE([ACE_HAS_VERBOSE_NOTSUP]) + ;; + no) + dnl Do nothing + ;; + *) + AC_MSG_ERROR([bad value ${enableval} for --enable-verb-not-sup]) + ;; + esac + ],) + + AC_ARG_ENABLE([rcsid], + AS_HELP_STRING(--enable-rcsid,compile RCS id strings into object files [[[no]]]), + [ + case "${enableval}" in + yes) + ace_user_enable_rcsid=yes + ;; + no) + ace_user_enable_rcsid=no + ;; + *) + AC_MSG_ERROR([bad value ${enableval} for --enable-rcsid]) + ;; + esac + ]) + if test X$ace_user_enable_rcsid = Xyes; then + AC_DEFINE(ACE_USE_RCSID, 1, + [Define to 1 to embed RCS ID strings into compiled object files.]) + fi + + dnl The ace/config-all.h file defaults ACE_NTRACE properly, so only emit + dnl something if the user specifies this option. + AC_ARG_ENABLE([trace], + AS_HELP_STRING(--enable-trace,enable ACE tracing [[[no]]]), + [ + case "${enableval}" in + yes) + AC_DEFINE([ACE_NTRACE],0) + ;; + no) + AC_DEFINE([ACE_NTRACE],1) + ;; + *) + AC_MSG_ERROR([bad value ${enableval} for --enable-trace]) + ;; + esac + ],) + + AC_ARG_ENABLE([wfmo], + AS_HELP_STRING(--enable-wfmo,build WFMO-using examples [[[no]]]), + [ + case "${enableval}" in + yes) + ace_user_enable_wfmo=yes + ;; + no) + ace_user_enable_wfmo=no + ;; + *) + AC_MSG_ERROR([bad value ${enableval} for --enable-wfmo]) + ;; + esac + ], + [ + case "$host" in + *win32*) + ace_user_enable_wfmo=yes + ;; + *) + ace_user_enable_wfmo=no + ;; + esac + ]) + AM_CONDITIONAL([BUILD_WFMO], [test X$ace_user_enable_wfmo = Xyes]) + + AC_ARG_ENABLE([wince], + AS_HELP_STRING(--enable-wince,build Windows CE/Mobile-using examples [[[no]]]), + [ + case "${enableval}" in + yes) + ace_user_enable_wince=no + ;; + no) + ace_user_enable_wince=no + ;; + *) + AC_MSG_ERROR([bad value ${enableval} for --enable-wince]) + ;; + esac + ], + [ + case "$host" in + *win32*) + ace_user_enable_wince=yes + ;; + *) + ace_user_enable_wince=no + ;; + esac + ]) + AM_CONDITIONAL([BUILD_WINCE], [test X$ace_user_enable_wince = Xyes]) + + AC_ARG_ENABLE([winregistry], + AS_HELP_STRING(--enable-winregistry,build Windows registry-using examples [[[no]]]), + [ + case "${enableval}" in + yes) + ace_user_enable_winregistry=no + ;; + no) + ace_user_enable_winregistry=no + ;; + *) + AC_MSG_ERROR([bad value ${enableval} for --enable-winregistry]) + ;; + esac + ], + [ + case "$host" in + *win32*) + ace_user_enable_winregistry=yes + ;; + *) + ace_user_enable_winregistry=no + ;; + esac + ]) + AM_CONDITIONAL([BUILD_WINREGISTRY], [test X$ace_user_enable_winregistry = Xyes]) + + ACE_ENABLE_FL_REACTOR + ACE_ENABLE_QT_REACTOR + ACE_ENABLE_TK_REACTOR + ACE_ENABLE_XT_REACTOR + ACE_ENABLE_FOX_REACTOR + + # placeholder for WxWindows/wxWidgets support + AM_CONDITIONAL([BUILD_WXWINDOWS], false) + + ACE_PATH_BZIP2 + ACE_PATH_ZLIB + ACE_PATH_ZZIP + + AC_ARG_ENABLE([gperf], + AS_HELP_STRING(--enable-gperf,compile the gperf program [[[yes]]]), + [ + case "${enableval}" in + yes) + ace_user_enable_gperf=yes + ;; + no) + ace_user_enable_gperf=no + ;; + *) + AC_MSG_ERROR([bad value ${withval} for --with-gperf]) + ;; + esac + ], + [ + ace_user_enable_gperf=yes + ]) + if test "$ace_user_enable_gperf" = yes; then + AC_DEFINE([ACE_HAS_GPERF]) + AS_IF([test -n "$GPERF"], + [ + AC_MSG_WARN([gperf program already exists]) + AC_MSG_WARN([existing gperf may be overwritten during installation]) + ],[]) + fi + AM_CONDITIONAL([BUILD_GPERF], [test X$ace_user_enable_gperf = Xyes]) + + ACE_ENABLE_QOS + ACE_ENABLE_SSL + ACE_ENABLE_ACEXML + + AC_ARG_WITH([tao], + AS_HELP_STRING(--with-tao,build TAO (the ACE ORB) [[[yes]]]), + [ + case "${withval}" in + yes) + ace_user_with_tao=yes + ;; + no) + ace_user_with_tao=no + ;; + *) + AC_MSG_ERROR([bad value ${withval} for --with-tao]) + ;; + esac + ], + [ + ace_user_with_tao=yes + ]) + + AC_ARG_WITH([tli-device], + AS_HELP_STRING(--with-tli-device(=DEV),device for TCP on TLI [[/dev/tcp]]), + [ + case "${withval}" in + yes) + AC_MSG_ERROR([Specify the TLI/TCP device if you use this option.]) + ;; + no) + ;; + *) + if test -e "${withval}"; then + AC_DEFINE_UNQUOTED([ACE_TLI_TCP_DEVICE], ["${withval}"]) + else + AC_MSG_ERROR([TLI/TCP device ${withval} does not exist.]) + fi + ;; + esac + ],) + + AC_ARG_ENABLE([reentrant], + AS_HELP_STRING(--enable-reentrant,enable reentrant functions [[[yes]]]), + [ + case "${enableval}" in + yes) + ace_user_enable_reentrant_funcs=yes + ;; + no) + ace_user_enable_reentrant_funcs=no + ;; + *) + AC_MSG_ERROR([bad value ${enableval} for --enable-reentrant]) + ;; + esac + ], + [ + ace_user_enable_reentrant_funcs=yes + ]) + + AC_ARG_ENABLE([ace-examples], + AS_HELP_STRING(--enable-ace-examples,build ACE examples [[[yes]]]), + [ + case "${enableval}" in + yes) + ace_build_examples=yes + ;; + no) + ace_build_examples=no + ;; + *) + AC_MSG_ERROR([bad value ${enableval} for --enable-ace-examples]) + ;; + esac + ], + [ + ace_build_examples=yes + ]) + AM_CONDITIONAL([BUILD_EXAMPLES], [test X$ace_build_examples = Xyes]) + + AC_ARG_ENABLE([ace-tests], + AS_HELP_STRING(--enable-ace-tests,build ACE tests [[[yes]]]), + [ + case "${enableval}" in + yes) + ace_build_tests=yes + ;; + no) + ace_build_tests=no + ;; + *) + AC_MSG_ERROR([bad value ${enableval} for --enable-ace-tests]) + ;; + esac + ], + [ + ace_build_tests=yes + ]) + AM_CONDITIONAL([BUILD_TESTS], [test X$ace_build_tests = Xyes]) + + ACE_ENABLE_CDR_SWAP_ON_READ + ACE_ENABLE_CDR_SWAP_ON_WRITE + ACE_ENABLE_CDR_ALIGNMENT + ACE_ENABLE_REACTOR_NOTIFICATION_QUEUE + ACE_ENABLE_STRDUP_EMULATION + ACE_ENABLE_WCSDUP_EMULATION +]) + +AC_DEFUN([ACE_CHECK_LIB64], +[ + AC_ARG_ENABLE(libsuffix, + AC_HELP_STRING([--enable-libsuffix], + [/lib directory suffix (64,32,none,auto[=default])]), + acelibsuff=$enableval, acelibsuff="auto") + + if test "$acelibsuff" = "auto"; then + +cat > conftest.cpp << _ACEOF +#include +int main(int, char **) { + return 0; +} +_ACEOF + acelibsuff=`$CXX conftest.cpp -o conftest.out; ldd conftest.out |sed -ne '/libc.so/{ + s,.*/lib\([[^\/]]*\)/.*,\1, + p +}'` + rm -rf conftest.* + fi + + if test "$acelibsuff" = "no" || test "$acelibsuff" = "none"; then + acelibsuff= + fi + if test -z "$acelibsuff"; then + AC_MSG_RESULT([not using lib directory suffix]) + else + AC_MSG_RESULT([using lib directory suffix $acelibsuff]) + fi +]) + +dnl Macros that add ACE compilation options to a `configure' script. +dnl ACE_COMPILATION_OPTIONS +AC_DEFUN([ACE_COMPILATION_OPTIONS], +[ + AC_ARG_ENABLE([debug], + AS_HELP_STRING(--enable-debug,enable debugging [[[yes]]]), + [ + case "${enableval}" in + yes) + ACE_CXXFLAGS="$ACE_CXXFLAGS $DCXXFLAGS" + ;; + no) + AC_DEFINE([ACE_NDEBUG]) + ;; + *) + AC_MSG_ERROR([bad value ${enableval} for --enable-debug]) + ;; + esac + ],) + + AC_ARG_ENABLE([exceptions], + AS_HELP_STRING(--enable-exceptions,enable C++ exception handling [[[yes]]]), + [ + case "${enableval}" in + yes) + ace_user_enable_exceptions=yes + ;; + no) + ace_user_enable_exceptions=no + if test "$GXX" = yes; then + if $CXX --version | $EGREP -v '^2\.[[0-7]]' > /dev/null; then + ACE_CXXFLAGS="$ACE_CXXFLAGS -fno-exceptions" + fi + fi + ;; + *) + AC_MSG_ERROR([bad value ${enableval} for --enable-exceptions]) + ;; + esac + ], + [ + ace_user_enable_exceptions=yes + +dnl THE FOLLOWING WAS ONLY USED WHEN DISABLING EXCEPTION SUPPORT BY +dnl DEFAULT. +dnl +dnl if test "$GXX" = yes; then +dnl if $CXX --version | $EGREP -v '^2\.[[0-7]]' > /dev/null; then +dnl ACE_CXXFLAGS="$ACE_CXXFLAGS -fno-exceptions" +dnl fi +dnl fi + ]) + AM_CONDITIONAL([BUILD_EXCEPTIONS], [test X$ace_user_enable_exceptions = Xyes]) + + AC_ARG_ENABLE([fast], + AS_HELP_STRING(--enable-fast,enable -fast flag (e.g. Sun C++) [[[no]]]), + [ + case "${enableval}" in + yes) + ACE_CXXFLAGS="$ACE_CXXFLAGS -fast" + ACE_CFLAGS="$ACE_CFLAGS -fast" + ;; + no) + ;; + *) + AC_MSG_ERROR([bad value ${enableval} for --enable-fast]) + ;; + esac + ],) + + AC_ARG_ENABLE([ipo], + AS_HELP_STRING(--enable-ipo,enable -ipo flag (e.g. Intel C++) [[[no]]]), + [ + case "${enableval}" in + yes) + ACE_CXXFLAGS="$ACE_CXXFLAGS -ipo" + ACE_CFLAGS="$ACE_CFLAGS -ipo" + ;; + no) + ;; + *) + AC_MSG_ERROR([bad value ${enableval} for --enable-ipo]) + ;; + esac + ],) + + AC_ARG_ENABLE([inline], + AS_HELP_STRING(--enable-inline,enable code inlining [[[yes]]]), + [ + case "${enableval}" in + yes) + AC_DEFINE([__ACE_INLINE__]) + ;; + no) + AC_DEFINE([ACE_NO_INLINE]) + ;; + *) + AC_MSG_ERROR([bad value ${enableval} for --enable-inline]) + ;; + esac + ], + [ + AC_DEFINE([__ACE_INLINE__]) + ]) + + AC_ARG_ENABLE([optimize], + AS_HELP_STRING(--enable-optimize,enable additional optimizations [[[yes]]]), + [ + case "${enableval}" in + yes) + ace_user_enable_optimize=yes + ;; + no) + AC_MSG_WARN([Optimization configure support not fully implemented yet.]) + ;; + *) + AC_MSG_ERROR([bad value ${enableval} for --enable-optimize]) + ;; + esac + ], + [ + ace_user_enable_optimize=yes + ]) + + + AC_ARG_ENABLE([profile], + AS_HELP_STRING(--enable-profile,enable profiling [[[no]]]), + [ + case "${enableval}" in + yes) + if test -z "$PROF"; then + AC_MSG_WARN([No profiling program found. Assuming 'prof' exists.]) + ACE_CXXFLAGS="$ACE_CXXFLAGS -p" + ACE_CFLAGS="$ACE_CFLAGS -p" + else + case "$PROF" in + gprof) + echo "Building with 'gprof' support" + ACE_CXXFLAGS="$ACE_CXXFLAGS -pg" + ACE_CFLAGS="$ACE_CFLAGS -pg" + ;; + prof) + echo "Building with 'prof' support" + ACE_CXXFLAGS="$ACE_CXXFLAGS -p" + ACE_CFLAGS="$ACE_CFLAGS -p" + ;; + *) + dnl We shouldn't get here. + AC_MSG_WARN([Assuming 'prof' exists.]) + ACE_CXXFLAGS="$ACE_CXXFLAGS -p" + ACE_CFLAGS="$ACE_CFLAGS -p" + ;; + esac + fi + ;; + no) + dnl Do nothing + ;; + *) + AC_MSG_ERROR([bad value ${enableval} for --enable-profile]) + ;; + esac + ],) + + AC_ARG_ENABLE([purify], + AS_HELP_STRING(--enable-purify,Purify all executables [[[no]]]), + [ + case "${enableval}" in + yes) + AC_CHECK_PROG([PURIFY], [purify], [purify],[]) + if test -n "$PURIFY"; then + PURE_CACHE_BASE_DIR=/tmp/purifycache + PURE_CACHE_DIR="${PURE_CACHE_BASE_DIR}-${LOGNAME}" + PURE_CACHE_DIR="${PURE_CACHE_DIR}-"`basename $CXX` + PURELINK="$PURIFY -best-effort -chain-length=20 -cache-dir=$PURE_CACHE_DIR -fds-inuse-at-exit=no -inuse-at-exit -max_threads=100" + dnl Pick up Quantify directory from the users PATH. + ACE_PURIFY_DIR=`type purify | sed -e 's/.* is //' -e 's%/purify'` + ACE_CPPFLAGS="-DACE_HAS_PURIFY -I$ACE_PURIFY_DIR" + else + AC_MSG_WARN([Purify program was not found.]) + AC_MSG_WARN([Disabling purify support.]) + fi + ;; + no) + PURELINK="" + ;; + *) + AC_MSG_ERROR([bad value ${enableval} for --enable-purify]) + ;; + esac + ], PURELINK="") + + AC_ARG_ENABLE([quantify], + AS_HELP_STRING(--enable-quantify,Quantify all executables [[[no]]]), + [ + case "${enableval}" in + yes) + AC_CHECK_PROG([QUANTIFY], [quantify], [quantify],[]) + if test -n "$QUANTIFY"; then + PURE_CACHE_BASE_DIR=/tmp/purifycache + PURE_CACHE_DIR="${PURE_CACHE_BASE_DIR}-${LOGNAME}" + PURE_CACHE_DIR="${PURE_CACHE_DIR}-"`basename $CXX` + + PRELINK="$QUANTIFY -best-effort -max_threads=100 -cache-dir=$PURE_CACHE_DIR" + dnl Pick up Quantify directory from the users PATH. + ACE_QUANTIFY_DIR=`type quantify | sed -e 's/.* is //' -e 's%/quantify$$%%'` + ACE_CPPFLAGS="-DACE_HAS_QUANTIFY -I$ACE_QUANTIFY_DIR" + else + AC_MSG_WARN([Quantify program was not found.]) + AC_MSG_WARN([Disabling quantify support.]) + fi + ;; + no) + PRELINK="" + ;; + *) + AC_MSG_ERROR([bad value ${enableval} for --enable-quantify]) + ;; + esac + ], PRELINK="") + + AC_ARG_ENABLE([repo], + AS_HELP_STRING(--enable-repo,use GNU template repository GNU C++ with repo patches and EGCS only [[[no]]]), + [ + case "${enableval}" in + yes) + if test "$GXX" = yes; then + ace_user_enable_repo=yes + ACE_CXXFLAGS="$ACE_CXXFLAGS -frepo" + AC_DEFINE(ACE_HAS_GNU_REPO) + else + ace_user_enable_repo=no + AC_MSG_WARN([Not using GNU C++! GNU template respository disabled.]) + fi + ;; + no) + ace_user_enable_repo=no + ;; + *) + AC_MSG_ERROR([bad value ${enableval} for --enable-repo]) + ;; + esac + ], + [ + ace_user_enable_repo=no + ]) + + AC_ARG_ENABLE([stdcpplib], + AS_HELP_STRING([--enable-stdcpplib],[enable standard C++ library [[yes]]]), + [ + case "${enableval}" in + yes) + ace_user_enable_stdcpplib=yes + ;; + no) + ace_user_enable_stdcpplib=no + ;; + *) + AC_MSG_ERROR([bad value ${enableval} for --enable-stdcpplib]) + ;; + esac + ], + [ + ace_user_enable_stdcpplib=yes + ]) + + AC_ARG_ENABLE([uses-wchar], + AS_HELP_STRING([--enable-uses-wchar], + [enable use of wide characters [[no]]]), + [case "${enableval}" in + yes) + AC_DEFINE([ACE_USES_WCHAR]) + ace_cv_user_enable_wide_char=yes + ;; + no) + ace_cv_user_enable_wide_char=no + ;; + *) + AC_MSG_ERROR([bad value ${enableval} for --enable-uses-wchar]) + ;; + esac]) + AC_CACHE_CHECK([whether to use wide characters internally], + [ace_cv_user_enable_wide_char], [ace_cv_user_enable_wide_char=no]) + AM_CONDITIONAL([BUILD_USES_WCHAR], [test X$ace_cv_user_enable_wide_char = Xyes]) + +]) + +# ACE_ENABLE_CDR_SWAP_ON_READ +#--------------------------------------------------------------------------- +AC_DEFUN([ACE_ENABLE_CDR_SWAP_ON_READ], +[AC_ARG_ENABLE([ace-cdr-swap-on-read], + AS_HELP_STRING([--enable-ace-cdr-swap-on-read], + [configure CDR to support swap on read [[yes]]]), + [case "${enableval}" in + yes) + ace_user_cdr_swap_on_read=yes + ;; + no) + ace_user_cdr_swap_on_read=no + ;; + *) + AC_MSG_ERROR(bad value ${enableval} for --enable-ace-cdr-swap-on-read) + ;; + esac],[ + ace_user_cdr_swap_on_read=yes + ]) +if test X$ace_user_cdr_swap_on_read = Xno; then + AC_DEFINE(ACE_DISABLE_SWAP_ON_READ, 1, + [Define to 1 to disable swapping swapping CDR on read]) +fi +]) + +# ACE_ENABLE_CDR_SWAP_ON_WRITE +#--------------------------------------------------------------------------- +AC_DEFUN([ACE_ENABLE_CDR_SWAP_ON_WRITE], +[AC_ARG_ENABLE([ace-cdr-swap-on-write], + AS_HELP_STRING([--enable-ace-cdr-swap-on-write], + [configure CDR to support swap on write [[no]]]), + [case "${enableval}" in + yes) + ace_user_cdr_swap_on_write=yes + ;; + no) + ace_user_cdr_swap_on_write=no + ;; + *) + AC_MSG_ERROR(bad value ${enableval} for --enable-ace-cdr-swap-on-write) + ;; + esac],[ + ace_user_cdr_swap_on_write=no + ]) +if test X$ace_user_cdr_swap_on_write = Xyes; then + AC_DEFINE(ACE_ENABLE_SWAP_ON_WRITE, 1, + [Define to 1 to enable swapping swapping CDR on write]) +fi +]) + +# ACE_ENABLE_CDR_ALIGNMENT +#--------------------------------------------------------------------------- +AC_DEFUN([ACE_ENABLE_CDR_ALIGNMENT], +[AC_ARG_ENABLE([ace-cdr-alignment], + AS_HELP_STRING([--enable-ace-cdr-alignment], + [configure CDR to require aligned access [[yes]]]), + [case "${enableval}" in + yes) + ace_user_cdr_alignment=yes + ;; + no) + ace_user_cdr_alignment=no + ;; + *) + AC_MSG_ERROR(bad value ${enableval} for --enable-ace-cdr-alignment) + ;; + esac],[ + ace_user_cdr_alignment=yes + ]) +if test X$ace_user_cdr_alignment = Xno; then + AC_DEFINE(ACE_LACKS_CDR_ALIGNMENT, 1, + [Define to 1 to support unaligned CDR]) +fi +]) + +# ACE_ENABLE_REACTOR_NOTIFICATION_QUEUE +#--------------------------------------------------------------------------- +AC_DEFUN([ACE_ENABLE_REACTOR_NOTIFICATION_QUEUE], +[AC_ARG_ENABLE([ace-reactor-notification-queue], + AS_HELP_STRING([--enable-ace-reactor-notification-queue], + [configure Reactor to use a user-space queue for notifications [[no]]]), + [case "${enableval}" in + yes) + ace_user_reactor_notification_queue=yes + ;; + no) + ace_user_reactor_notification_queue=no + ;; + *) + AC_MSG_ERROR(bad value ${enableval} for --enable-ace-reactor-notification-queue) + ;; + esac],[ + ace_user_reactor_notification_queue=no + ]) +if test X$ace_user_reactor_notification_queue = Xyes; then + AC_DEFINE([ACE_HAS_REACTOR_NOTIFICATION_QUEUE], 1, + [Define to 1 to configure Reactor to use a user-space queue for notifications]) +fi +]) + + +# ACE_ENABLE_STRDUP_EMULATION +#--------------------------------------------------------------------------- +AC_DEFUN([ACE_ENABLE_STRDUP_EMULATION], +[AC_ARG_ENABLE([ace-strdup-emulation], + AS_HELP_STRING([--enable-ace-strdup-emulation], + [use ACE's strdup emulation [[no]]]), + [case "${enableval}" in + yes) + ace_user_strdup_emulation=yes + ;; + no) + ace_user_strdup_emulation=no + ;; + *) + AC_MSG_ERROR(bad value ${enableval} for --enable-ace-strdup-emulation) + ;; + esac],[ + ace_user_strdup_emulation=no + ]) +if test X$ace_user_strdup_emulation = Xyes; then + AC_DEFINE(ACE_HAS_STRDUP_EMULATION, 1, + [Define to 1 use ACE's strdup() emulation]) +fi +]) + +# ACE_ENABLE_WCSDUP_EMULATION +#--------------------------------------------------------------------------- +AC_DEFUN([ACE_ENABLE_WCSDUP_EMULATION], +[AC_ARG_ENABLE([ace-wcsdup-emulation], + AS_HELP_STRING([--enable-ace-wcsdup-emulation], + [use ACE's wcsdup emulation [[no]]]), + [case "${enableval}" in + yes) + ace_user_wcsdup_emulation=yes + ;; + no) + ace_user_wcsdup_emulation=no + ;; + *) + AC_MSG_ERROR(bad value ${enableval} for --enable-ace-wcsdup-emulation) + ;; + esac],[ + ace_user_wcsdup_emulation=no + ]) +if test X$ace_user_wcsdup_emulation = Xyes; then + AC_DEFINE(ACE_HAS_WCSDUP_EMULATION, 1, + [Define to 1 use ACE's wcsdup() emulation]) +fi +]) + +AC_DEFUN([ACE_ENABLE_QOS], +[AC_ARG_ENABLE([qos], + AS_HELP_STRING([--enable-qos], + [compile/use the ACE_QoS library [[no]]]), + [case "${enableval}" in + yes) + ace_cv_user_enable_qos=yes + ;; + no) + ace_cv_user_enable_qos=no + ;; + *) + AC_MSG_ERROR(bad value ${enableval} for --enable-qos) + ;; + esac]) +AC_CACHE_CHECK([whether to compile/use the ACE_QoS library], + [ace_cv_user_enable_qos],[ace_cv_user_enable_qos=no]) +AM_CONDITIONAL([BUILD_QOS], [test X$ace_cv_user_enable_qos = Xyes]) +]) + +AC_DEFUN([ACE_ENABLE_SSL], +[AC_REQUIRE([ACE_CHECK_TLS]) +AC_ARG_ENABLE([ssl], + AS_HELP_STRING([--enable-ssl], + [compile/use the ACE_SSL library [[yes]]]), + [case "${enableval}" in + yes) + ace_cv_user_enable_ssl=yes + ;; + no) + ace_cv_user_enable_ssl=no + ;; + *) + AC_MSG_ERROR(bad value ${enableval} for --enable-ssl) + ;; + esac]) +AC_CACHE_CHECK([whether to compile/use the ACE_SSL library], + [ace_cv_user_enable_ssl], [ace_cv_user_enable_ssl=yes]) +AM_CONDITIONAL([BUILD_SSL], [test X$ace_cv_user_enable_ssl = Xyes]) +]) + +AC_DEFUN([ACE_ENABLE_ACEXML], +[AC_ARG_ENABLE([acexml], + AS_HELP_STRING([--enable-acexml], + [compile/use the ACEXML library [[yes]]]), + [case "${enableval}" in + yes) + ace_cv_user_enable_acexml=yes + ;; + no) + ace_cv_user_enable_acexml=no + ;; + *) + AC_MSG_ERROR(bad value ${enableval} for --enable-acexml) + ;; + esac], + [ + ace_cv_user_enable_acexml=yes + ]) +AC_CACHE_CHECK([whether to compile/use the ACEXML library], + [ace_cv_user_enable_acexml], [ace_cv_user_enable_acexml=yes]) +AM_CONDITIONAL([BUILD_ACEXML], [test X$ace_cv_user_enable_acexml = Xyes]) +]) + + +# ACE_PATH_GL +#--------------------------------------------------------------------------- +# Find OpenGL Libraries, flags, etc. +AC_DEFUN([ACE_PATH_GL], +[ +]) + + +# ACE_PATH_FL +#--------------------------------------------------------------------------- +# Find FL/TK Libraries, flags, etc. +AC_DEFUN([ACE_PATH_FL], +[AC_REQUIRE([ACE_PATH_GL]) + AC_ARG_WITH([fltkconfig], + AS_HELP_STRING([--with-fltkconfig=DIR], + [path to fltk-config [[automatic]]]), + [ ac_fltkconfig_dir="${withval}" ]) + if test X"${ac_fltkconfig_dir}" = X; then + AC_PATH_PROG([FLTKCONFIG], [fltk-config], []) + else + AC_MSG_CHECKING([whether fltk-config exists in ${ac_fltkconfig_dir}]) + if test -f "${ac_fltkconfig_dir}/fltk-config"; then + FLTKCONFIG="${ac_fltkconfig_dir}/fltk-config" + AC_MSG_RESULT([yes]) + else + AC_MSG_RESULT([no]) + fi + fi + if test X"${FLTKCONFIG}" != X; then + ACE_FLTK_CPPFLAGS=`$FLTKCONFIG --use-gl --cxxflags 2>/dev/null` + ACE_FLTK_LIBS=`$FLTKCONFIG --use-gl --ldflags 2>/dev/null` + + AC_SUBST(ACE_FLTK_CPPFLAGS) + AC_SUBST(ACE_FLTK_LIBS) + fi +]) + + +# ACE_PATH_QT +#--------------------------------------------------------------------------- +# Find Qt Libraries, flags, etc. +AC_DEFUN([ACE_PATH_QT], +[ + ac_qt_found=no + PKG_CHECK_MODULES([Qt], [qt-mt], + [ac_qt_found=yes], + [AC_MSG_RESULT([not found])]) + if test X"${ac_qt_found}" = Xyes; then + ACE_QT_CPPFLAGS="${Qt_CFLAGS}" + ACE_QT_LIBS="${Qt_LIBS}" + AC_SUBST(ACE_QT_CPPFLAGS) + AC_SUBST(ACE_QT_LIBS) + + AS_IF([test -n "$QTDIR"], + [], + [QTDIR=`$PKG_CONFIG --variable=prefix qt-mt 2>/dev/null`]) + AC_SUBST(QTDIR) + fi +]) + + +# ACE_PATH_TCL +#--------------------------------------------------------------------------- +# Find Tcl Libraries, flags, etc. +AC_DEFUN([ACE_PATH_TCL], +[AC_REQUIRE([ACE_CHECK_LIB64]) + AC_ARG_WITH([tclconfig], + AS_HELP_STRING([--with-tclconfig=DIR], + [path to tclConfig.sh [[automatic]]]), + [ ac_tclconfig_dir="${withval}" ]) + + if test X"${ac_tclconfig_dir}" = X; then + for i in `ls -d ${exec_prefix}/lib${acelibsuff} 2>/dev/null` \ + `ls -d ${prefix}/lib${acelibsuff} 2>/dev/null` \ + `ls -d /usr/local/lib${acelibsuff} 2>/dev/null` \ + `ls -d /usr/contrib/lib${acelibsuff} 2>/dev/null` \ + `ls -d /usr/lib${acelibsuff} 2>/dev/null` \ + `ls -d /usr/pkg/lib${acelibsuff} 2>/dev/null` \ + `ls -d /usr/lib${acelibsuff}/tcl8.[[43]]* 2>/dev/null` \ + ; do + if test -f "$i/tclConfig.sh" ; then + ac_tclconfig_dir=`(cd $i; pwd)` + break + fi + done + fi + + AC_MSG_CHECKING([whether tclConfig.sh exists in ${ac_tclconfig_dir}]) + if test -f "${ac_tclconfig_dir}/tclConfig.sh"; then + TCLCONFIG="${ac_tclconfig_dir}/tclConfig.sh" + AC_MSG_RESULT([yes]) + else + AC_MSG_RESULT([no]) + fi + + if test X"${TCLCONFIG}" != X; then + . ${TCLCONFIG} + + ACE_TCL_CPPFLAGS="${TCL_INCLUDE_SPEC}" + eval "ACE_TCL_LIBS=\"${TCL_LIB_SPEC}\"" + + AC_SUBST(ACE_TCL_CPPFLAGS) + AC_SUBST(ACE_TCL_LIBS) + fi +]) + + +# ACE_PATH_TK +#--------------------------------------------------------------------------- +# Find Tk Libraries, flags, etc. +AC_DEFUN([ACE_PATH_TK], +[AC_REQUIRE([ACE_PATH_TCL]) + AC_ARG_WITH([tkconfig], + AS_HELP_STRING([--with-tkconfig=DIR], + [path to tkConfig.sh [[automatic]]]), + [ ac_tkconfig_dir="${withval}" ]) + if test X"${ac_tkconfig_dir}" = X; then + if test X"${ac_tclconfig_dir}" != X && test -f ${ac_tclconfig_dir}/tkConfig.sh; then + ac_tkconfig_dir=$ac_tclconfig_dir; + else + for i in `ls -d ${exec_prefix}/lib${acelibsuff} 2>/dev/null` \ + `ls -d ${prefix}/lib${acelibsuff} 2>/dev/null` \ + `ls -d /usr/local/lib${acelibsuff} 2>/dev/null` \ + `ls -d /usr/contrib/lib${acelibsuff} 2>/dev/null` \ + `ls -d /usr/lib${acelibsuff} 2>/dev/null` \ + `ls -d /usr/pkg/lib${acelibsuff} 2>/dev/null` \ + `ls -d /usr/lib${acelibsuff}/tk8.[[43]]* 2>/dev/null` \ + ; do + if test -f "$i/tkConfig.sh" ; then + ac_tkconfig_dir=`(cd $i; pwd)` + break + fi + done + fi + fi + + AC_MSG_CHECKING([whether tkConfig.sh exists in ${ac_tkconfig_dir}]) + if test -f "${ac_tkconfig_dir}/tkConfig.sh"; then + TKCONFIG="${ac_tkconfig_dir}/tkConfig.sh" + AC_MSG_RESULT([yes]) + else + AC_MSG_RESULT([no]) + fi + + if test X"${TKCONFIG}" != X; then + . ${TKCONFIG} + + ACE_TK_CPPFLAGS="${TK_INCLUDE_SPEC} ${TK_XINCLUDES}" + ACE_TK_LIBS="${TK_LIB_SPEC} ${TK_XLIBSW}" + + AC_SUBST(ACE_TK_CPPFLAGS) + AC_SUBST(ACE_TK_LIBS) + fi +]) + + +# ACE_PATH_XT +#--------------------------------------------------------------------------- +# Find Xt libraries, flags, etc. +AC_DEFUN([ACE_PATH_XT], +[AC_REQUIRE([ACE_PATH_X11]) + +if test "$no_x" != yes; then + ACE_XT_CPPFLAGS="" + ACE_XT_LDFLAGS="" + ACE_XT_LIBS="-lXt" + + AC_SUBST(ACE_XT_CPPFLAGS) + AC_SUBST(ACE_XT_LDFLAGS) + AC_SUBST(ACE_XT_LIBS) +fi +AM_CONDITIONAL([BUILD_ATHENA], true) +AM_CONDITIONAL([BUILD_MOTIF], false) +]) + + +# ACE_PATH_X11 +#--------------------------------------------------------------------------- +# Find X11 libraries, flags, etc. +AC_DEFUN([ACE_PATH_X11], +[AC_REQUIRE([AC_PATH_XTRA]) + +if test "$no_x" != yes; then + ACE_X11_CPPFLAGS="${X_CFLAGS}" + ACE_X11_LDFLAGS="${X_LIBS}" + ACE_X11_LIBS="${X_PRE_LIBS} -lX11 ${X_EXTRA_LIBS}" + + AC_SUBST(ACE_X11_CPPFLAGS) + AC_SUBST(ACE_X11_LDFLAGS) + AC_SUBST(ACE_X11_LIBS) +fi + +AM_CONDITIONAL([BUILD_X11], [test X$no_x != Xyes]) +]) + + +# ACE_PATH_BZIP2 +#--------------------------------------------------------------------------- +# Find bzip2 Libraries, flags, etc. +AC_DEFUN([ACE_PATH_BZIP2], +[ +ACE_BZIP2_CPPFLAGS="" +ACE_BZIP2_LDFLAGS="" + +dnl TODO: default to false, at least until we add a check to see if +dnl the bzip2 library is usable. +AC_ARG_WITH([bzip2], + AS_HELP_STRING([--with-bzip2@<:@=DIR@:>@], + [root directory of bzip2 installation]), + [ + ace_with_bzip2="${withval}" + if test "${ace_with_bzip2}" != yes; then + ace_bzip2_include="${ace_with_bzip2}/include" + ace_bzip2_libdir="${ace_with_bzip2}/lib" + fi + ],[ace_with_bzip2=no]) + +dnl TODO: let's wait and see before adding options to specify header +dnl and library location separately. +dnl +dnl AC_ARG_WITH([bzip2_include], +dnl AS_HELP_STRING([--with-bzip2-include=DIR], +dnl [specify exact include dir for bzip2 headers]), +dnl [ace_bzip2_include="$withval"]) +dnl +dnl AC_ARG_WITH([bzip2_libdir], +dnl AS_HELP_STRING([--with-bzip2-libdir=DIR], +dnl [specify exact include dir for bzip2 libraries]), +dnl [ace_bzip2_libdir="$withval"]) + +if test "${ace_bzip2_include}"; then + ACE_BZIP2_CPPFLAGS="-I$ace_bzip2_include" +fi + +if test "${ace_bzip2_libdir}"; then + ACE_BZIP2_LDFLAGS="-L$ace_bzip2_libdir" +fi + +ACE_BZIP2_CPPFLAGS="${ACE_BZIP2_CPPFLAGS} -DBZIP2" + +if test "${ace_with_bzip2}" != no; then + ACE_BZIP2_LIBS="-lbz2" + AC_SUBST(ACE_BZIP2_CPPFLAGS) + AC_SUBST(ACE_BZIP2_LDFLAGS) + AC_SUBST(ACE_BZIP2_LIBS) +fi +AM_CONDITIONAL([BUILD_BZIP2], test "${ace_with_bzip2}" != no) +]) + + +# ACE_PATH_ZLIB +#--------------------------------------------------------------------------- +# Find zlib Libraries, flags, etc. +AC_DEFUN([ACE_PATH_ZLIB], +[ +ACE_ZLIB_CPPFLAGS="" +ACE_ZLIB_LDFLAGS="" + +dnl TODO: default to false, at least until we add a check to see if +dnl the zlib library is usable. +AC_ARG_WITH([zlib], + AS_HELP_STRING([--with-zlib@<:@=DIR@:>@], + [root directory of zlib installation]), + [ + ace_with_zlib="${withval}" + if test "${ace_with_zlib}" != yes; then + ace_zlib_include="${ace_with_zlib}/include" + ace_zlib_libdir="${ace_with_zlib}/lib" + fi + ],[ace_with_zlib=no]) + +dnl TODO: let's wait and see before adding options to specify header +dnl and library location separately. +dnl +dnl AC_ARG_WITH([zlib_include], +dnl AS_HELP_STRING([--with-zlib-include=DIR], +dnl [specify exact include dir for zlib headers]), +dnl [ace_zlib_include="$withval"]) +dnl +dnl AC_ARG_WITH([zlib_libdir], +dnl AS_HELP_STRING([--with-zlib-libdir=DIR], +dnl [specify exact include dir for zlib libraries]), +dnl [ace_zlib_libdir="$withval"]) + +if test "${ace_zlib_include}"; then + ACE_ZLIB_CPPFLAGS="-I$ace_zlib_include" +fi + +if test "${ace_zlib_libdir}"; then + ACE_ZLIB_LDFLAGS="-L$ace_zlib_libdir" +fi + +ACE_ZLIB_CPPFLAGS="${ACE_ZLIB_CPPFLAGS} -DZLIB" + +if test "${ace_with_zlib}" != no; then + ACE_ZLIB_LIBS="-lz" + AC_SUBST(ACE_ZLIB_CPPFLAGS) + AC_SUBST(ACE_ZLIB_LDFLAGS) + AC_SUBST(ACE_ZLIB_LIBS) +fi +AM_CONDITIONAL([BUILD_ZLIB], test "${ace_with_zlib}" != no) +]) + + +# ACE_PATH_ZZIP +#--------------------------------------------------------------------------- +# Find zziplib Libraries, flags, etc. +AC_DEFUN([ACE_PATH_ZZIP], +[AC_REQUIRE([ACE_PATH_ZLIB]) + +ACE_ZZIP_CPPFLAGS="" +ACE_ZZIP_LDFLAGS="" + +dnl TODO: default to false, at least until we add a check to see if +dnl the zlib library is usable. +AC_ARG_WITH([zzip], + AS_HELP_STRING([--with-zzip@<:@=DIR@:>@], + [root directory of zzip installation]), + [ + ace_with_zzip="${withval}" + if test "${ace_with_zzip}" != yes; then + ace_zzip_include="${ace_with_zzip}/include" + ace_zzip_libdir="${ace_with_zzip}/lib" + fi + ],[ace_with_zzip=no]) + +dnl TODO: let's wait and see before adding options to specify header +dnl and library location separately. +dnl +dnl AC_ARG_WITH([zzip_include], +dnl AS_HELP_STRING([--with-zzip-include=DIR], +dnl [specify exact include dir for zzip headers]), +dnl [ace_zzip_include="$withval"]) +dnl +dnl AC_ARG_WITH([zzip_libdir], +dnl AS_HELP_STRING([--with-zzip-libdir=DIR], +dnl [specify exact include dir for zzip libraries]), +dnl [ace_zzip_libdir="$withval"]) + +if test "${ace_zzip_include}"; then + ACE_ZZIP_CPPFLAGS="-I$ace_zzip_include" +fi + +if test "${ace_zzip_libdir}"; then + ACE_ZZIP_LDFLAGS="-L$ace_zzip_libdir" +fi + +ACE_ZZIP_CPPFLAGS="${ACE_ZZIP_CPPFLAGS} -DUSE_ZZIP" + +if test "${ace_with_zzip}" != no; then + ACE_ZZIP_LIBS="-lzzip" + AC_SUBST(ACE_ZZIP_CPPFLAGS) + AC_SUBST(ACE_ZZIP_LDFLAGS) + AC_SUBST(ACE_ZZIP_LIBS) +fi +AM_CONDITIONAL([BUILD_ZZIP], test "${ace_with_zzip}" != no) +]) + +# ACE_ENABLE_FL_REACTOR +#--------------------------------------------------------------------------- +AC_DEFUN([ACE_ENABLE_FL_REACTOR], +[AC_REQUIRE([ACE_PATH_FL]) +AC_REQUIRE([ACE_PATH_X11]) +AC_ARG_ENABLE([fl-reactor], + AS_HELP_STRING([--enable-fl-reactor], + [build support for the FlReactor [[no]]]), + [case "${enableval}" in + yes) + AS_IF([test X"${FLTKCONFIG}" != X], + [ace_user_enable_fl_reactor=yes], + [AC_MSG_ERROR([ACE_FlReactor cannot be enabled: fltk-config not found.])]) + ;; + no) + ace_user_enable_fl_reactor=no + ;; + *) + AC_MSG_ERROR([bad value ${enableval} for --enable-fl-reactor]) + ;; + esac], + [ + ace_user_enable_fl_reactor=no + ]) +AM_CONDITIONAL([BUILD_GL], [test X$ace_user_enable_fl_reactor = Xyes]) +AM_CONDITIONAL([BUILD_FL], [test X$ace_user_enable_fl_reactor = Xyes]) +AM_CONDITIONAL([BUILD_ACE_FLREACTOR], + [test X$ace_user_enable_fl_reactor = Xyes]) +AM_CONDITIONAL([BUILD_TAO_FLRESOURCE], + [test X$ace_user_enable_fl_reactor = Xyes]) +]) + + +# ACE_ENABLE_QT_REACTOR +#--------------------------------------------------------------------------- +AC_DEFUN([ACE_ENABLE_QT_REACTOR], +[AC_REQUIRE([ACE_PATH_QT]) +AC_ARG_ENABLE([qt-reactor], + AS_HELP_STRING([--enable-qt-reactor], + [build support for the QtReactor [[no]]]), + [case "${enableval}" in + yes) + AS_IF([test X"${ac_qt_found}" = Xyes], + [ace_user_enable_qt_reactor=yes], + [AC_MSG_ERROR([ACE_QtReactor cannot be enabled: Qt not found.])]) + ;; + no) + ace_user_enable_qt_reactor=no + ;; + *) + AC_MSG_ERROR([bad value ${enableval} for --enable-qt-reactor]) + ;; + esac], + [ + ace_user_enable_qt_reactor=no + ]) +AM_CONDITIONAL([BUILD_QT], [test X$ace_user_enable_qt_reactor = Xyes]) +AM_CONDITIONAL([BUILD_ACE_QTREACTOR], + [test X$ace_user_enable_qt_reactor = Xyes]) +AM_CONDITIONAL([BUILD_TAO_QTRESOURCE], + [test X$ace_user_enable_qt_reactor = Xyes]) +]) + + +# ACE_ENABLE_TK_REACTOR +#--------------------------------------------------------------------------- +AC_DEFUN([ACE_ENABLE_TK_REACTOR], +[AC_REQUIRE([ACE_PATH_TK]) +AC_ARG_ENABLE([tk-reactor], + AS_HELP_STRING([--enable-tk-reactor], + [build support for the TkReactor [[no]]]), + [case "${enableval}" in + yes) + AS_IF([test X"${TCLCONFIG}" != X], + [AS_IF([test X"${TKCONFIG}" != X], + [ace_user_enable_tk_reactor=yes], + [AC_MSG_ERROR([ACE_TkReactor cannot be enabled: tkConfig not found.])])], + [AC_MSG_ERROR([ACE_TkReactor cannot be enabled: tclConfig not found.])]) + ;; + no) + ace_user_enable_tk_reactor=no + ;; + *) + AC_MSG_ERROR([bad value ${enableval} for --enable-tk-reactor]) + ;; + esac], + [ + ace_user_enable_tk_reactor=no + ]) +AM_CONDITIONAL([BUILD_TK], [test X$ace_user_enable_tk_reactor = Xyes]) +AM_CONDITIONAL([BUILD_ACE_TKREACTOR], + [test X$ace_user_enable_tk_reactor = Xyes]) +AM_CONDITIONAL([BUILD_TAO_TKRESOURCE], + [test X$ace_user_enable_tk_reactor = Xyes]) +]) + + +# ACE_ENABLE_XT_REACTOR +#--------------------------------------------------------------------------- +AC_DEFUN([ACE_ENABLE_XT_REACTOR], +[AC_REQUIRE([ACE_PATH_XT]) +AC_ARG_ENABLE([xt-reactor], + AS_HELP_STRING([--enable-xt-reactor], + [build support for the XtReactor [[no]]]), + [case "${enableval}" in + yes) +dnl Here, if X isn't found or the user sets "--without-x" on the command +dnl line, then "no_x" is set to "yes." + AS_IF([test "$no_x" != yes], + [ + ace_user_enable_xt_reactor=yes + ],[ + ace_user_enable_xt_reactor=no + AC_MSG_WARN([X was not found or it was disabled.]) + AC_MSG_WARN([ACE_XtReactor will not be enabled.]) + ]) + ;; + no) + ace_user_enable_xt_reactor=no + ;; + *) + AC_MSG_ERROR([bad value ${enableval} for --enable-xt-reactor]) + ;; + esac], + [ + ace_user_enable_xt_reactor=no + ]) +AM_CONDITIONAL([BUILD_XT], [test X$ace_user_enable_xt_reactor = Xyes]) +AM_CONDITIONAL([BUILD_ACE_XTREACTOR], + [test X$ace_user_enable_xt_reactor = Xyes]) +AM_CONDITIONAL([BUILD_TAO_XTRESOURCE], + [test X$ace_user_enable_xt_reactor = Xyes]) +]) + +# ACE_PATH_FOX +#--------------------------------------------------------------------------- +AC_DEFUN([ACE_PATH_FOX], +[AC_ARG_WITH([fox-config], + AS_HELP_STRING([--with-fox-config=DIR], + [path to fox-config [[automatic]]]), + [ ac_fox_config_dir="${withval}" ]) + if test X"${ac_fox_config_dir}" = X; then + AC_PATH_PROG([FOXCONFIG], [fox-config], [], []) + else + AC_MSG_CHECKING([whether fox-config exists in ${ac_fox_config_dir}]) + if test -f "${ac_fox_config_dir}/fox-config"; then + FOXCONFIG="${ac_fox_config_dir}/fox-config" + AC_MSG_RESULT([yes]) + else + AC_MSG_RESULT([no]) + fi + fi + if test X"${FOXCONFIG}" != X; then + ACE_FOX_CPPFLAGS=`$FOXCONFIG --cflags 2>/dev/null` + ACE_FOX_LIBS=`$FOXCONFIG --libs 2>/dev/null` + AC_SUBST(ACE_FOX_CPPFLAGS) + AC_SUBST(ACE_FOX_LIBS) + fi +]) + +# ACE_ENABLE_FOX_REACTOR +#--------------------------------------------------------------------------- +AC_DEFUN([ACE_ENABLE_FOX_REACTOR], +[AC_REQUIRE([ACE_PATH_FOX]) +AC_ARG_ENABLE([fox-reactor], + AS_HELP_STRING([--enable-fox-reactor], + [build support for the FoxReactor [[no]]]), + [case "${enableval}" in + yes) + AS_IF([test X"${FOXCONFIG}" != X], + [ace_user_enable_fox_reactor=yes], + [AC_MSG_ERROR([ACE_FoxReactor cannot be enabled: fox-config not found.])]) + ;; + no) + ace_user_enable_fox_reactor=no + ;; + *) + AC_MSG_ERROR([bad value ${enableval} for --enable-fox-reactor]) + ;; + esac], + [ + ace_user_enable_fox_reactor=no + ]) +AM_CONDITIONAL([BUILD_FOX], [test X$ace_user_enable_fox_reactor = Xyes]) +AM_CONDITIONAL([BUILD_ACE_FOXREACTOR], + [test X$ace_user_enable_fox_reactor = Xyes]) +AM_CONDITIONAL([BUILD_TAO_FOXRESOURCE], + [test X$ace_user_enable_fox_reactor = Xyes]) +]) diff --git a/dep/ACE_wrappers/m4/ace_defines.m4 b/dep/ACE_wrappers/m4/ace_defines.m4 new file mode 100644 index 00000000000..bb5ba514afc --- /dev/null +++ b/dep/ACE_wrappers/m4/ace_defines.m4 @@ -0,0 +1,48 @@ +# ACE_CHECK_DEFINE(DEFINE, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND], +# [INCLUDES = 'default-includes']) +#----------------------------------------------------------------------------- +AC_DEFUN([ACE_CHECK_DEFINE],[ +AS_VAR_PUSHDEF([ac_var],[ace_cv_defined_$1])dnl +AC_CACHE_CHECK([for $1], ac_var, +AC_COMPILE_IFELSE([AC_LANG_SOURCE([AC_INCLUDES_DEFAULT([$4]) +#ifdef $1 +int ok; +#else +choke me +#endif +])],AS_VAR_SET(ac_var, yes),AS_VAR_SET(ac_var, no))) +AS_IF([test AS_VAR_GET(ac_var) != "no"], [$2], [$3])dnl +AS_VAR_POPDEF([ac_var])dnl +]) + +# ACE_CHECK_HAS_DEFINES(DEFINE..., [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND], +# [INCLUDES = 'default-includes']) +#----------------------------------------------------------------------------- +AC_DEFUN([ACE_CHECK_HAS_DEFINES], +[AC_FOREACH([ACE_Def], [$1], + [AH_TEMPLATE(AS_TR_CPP(ACE_HAS_[]ACE_Def), + [Define to 1 if platform has ]ACE_Def[().])])dnl +for ace_def in $1 +do +ACE_CHECK_DEFINE($ace_def, + [AC_DEFINE_UNQUOTED([AS_TR_CPP([ACE_HAS_$ace_def])]) $2], + [$3], + [$4])dnl +done +]) + +# ACE_CHECK_LACKS_DEFINES(DEFINE..., [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) +# [INCLUDES = 'default-includes']) +#----------------------------------------------------------------------------- +AC_DEFUN([ACE_CHECK_LACKS_DEFINES], +[AC_FOREACH([ACE_Def], [$1], + [AH_TEMPLATE(AS_TR_CPP(ACE_LACKS_[]ACE_Def), + [Define to 1 if platform lacks ]ACE_Def[().])])dnl +for ace_def in $1 +do +ACE_CHECK_DEFINE($ace_def, + [$2], + [AC_DEFINE_UNQUOTED([AS_TR_CPP([ACE_LACKS_$ace_def])]) $3], + [$4])dnl +done +]) diff --git a/dep/ACE_wrappers/m4/ace_func.m4 b/dep/ACE_wrappers/m4/ace_func.m4 new file mode 100644 index 00000000000..52ff1a0b2c1 --- /dev/null +++ b/dep/ACE_wrappers/m4/ace_func.m4 @@ -0,0 +1,148 @@ +# ACE_FUNC_STRCASECMP +# + Defines ACE_LACKS_STRCASECMP to 1 if platform lacks strcasecmp() +# + Defines ACE_STRCASECMP_EQUIVALENT to identifier name if platform +# has a equivalent function that differs in name only. +# + Defines ACE_LACKS_STRCASECMP_PROTOTYPE to 1 if platform lacks +# declaration for strcasecmp(). +#--------------------------------------------------------------------------- +AC_DEFUN([ACE_FUNC_STRCASECMP], +[ACE_CHECK_LACKS_FUNCS(strcasecmp) +if test "$ac_cv_func_strcasecmp" = yes; then + AC_CHECK_DECL([strcasecmp], + [], + [AC_DEFINE([ACE_LACKS_STRCASECMP_PROTOTYPE], 1, + [Define to 1 if platform lacks a declaration for strcasecmp()])], + [ +#if !defined(ACE_LACKS_STRINGS_H) +#include +#endif +#if !defined(ACE_LACKS_STRING_H) +#include +#endif + ]) +else + AC_CHECK_FUNC(stricmp) + if test "$ac_cv_func_stricmp" = yes; then + AC_DEFINE(ACE_STRCASECMP_EQUIVALENT, [::stricmp], + [Define to function that is equivalent to strcasecmp()]) + else + AC_CHECK_FUNC(_stricmp) + if test "$ac_cv_func__stricmp" = yes; then + AC_DEFINE(ACE_STRCASECMP_EQUIVALENT, [::_stricmp]) + fi + fi +fi +]) + +# ACE_FUNC_STRNCASECMP +# + Defines ACE_LACKS_STRCASECMP to 1 if platform lacks strcasecmp() +# + Defines ACE_STRCASECMP_EQUIVALENT to identifier name if platform +# has a equivalent function that differs in name only. +# + Defines ACE_LACKS_STRNCASECMP_PROTOTYPE to 1 if platform lacks +# declaration for strncasecmp(). +#--------------------------------------------------------------------------- +AC_DEFUN([ACE_FUNC_STRNCASECMP], +[ACE_CHECK_LACKS_FUNCS(strncasecmp) +if test "$ac_cv_func_strncasecmp" = yes; then + AC_CHECK_DECL([strncasecmp], + [], + [AC_DEFINE([ACE_LACKS_STRNCASECMP_PROTOTYPE], 1, + [Define to 1 if platform lacks a declaration for strncasecmp()])], + [ +#if !defined(ACE_LACKS_STRINGS_H) +#include +#endif +#if !defined(ACE_LACKS_STRING_H) +#include +#endif + ]) +else + AC_CHECK_FUNC(strnicmp) + if test "$ac_cv_func_strnicmp" = yes; then + AC_DEFINE(ACE_STRNCASECMP_EQUIVALENT, [::strnicmp], + [Define to function that is equivalent to strncasecmp()]) + else + AC_CHECK_FUNC(_strnicmp) + if test "$ac_cv_func__strnicmp" = yes; then + AC_DEFINE(ACE_STRNCASECMP_EQUIVALENT, [::_strnicmp]) + fi + fi +fi +]) + +# ACE_FUNC_STRDUP +# + Defines ACE_LACKS_STRDUP to 1 if platform lacks strdup() +# + Defines ACE_STRDUP_EQUIVALENT to identifier name if platform +# has a equivalent function that differs in name only. +# + Defines ACE_HAS_NONCONST_STRDUP if argument is char*. (TODO) +#--------------------------------------------------------------------------- +AC_DEFUN([ACE_FUNC_STRDUP], +[ACE_CHECK_LACKS_FUNCS(strdup) +if test "$ac_cv_func_strdup" = no; then + AC_CHECK_FUNC(_strdup) + if test "$ac_cv_func__strdup" = yes; then + AC_DEFINE(ACE_STRDUP_EQUIVALENT, [::_strdup], + [Define to function that is equivalent to strdup()]) + fi +fi +]) + + +# ACE_FUNC_WCSCASECMP +# + Defines ACE_LACKS_WCSCASECMP to 1 if platform lacks strcasecmp() +# + Defines ACE_WCSCASECMP_EQUIVALENT to identifier name if platform +# has a equivalent function that differs in name only. +#--------------------------------------------------------------------------- +AC_DEFUN([ACE_FUNC_WCSCASECMP], +[ACE_CHECK_LACKS_FUNCS(wcscasecmp) +if test "$ac_cv_func_wcscasecmp" = no; then + AC_CHECK_FUNC(wcsicmp) + if test "$ac_cv_func_wcsicmp" = yes; then + AC_DEFINE(ACE_WCSCASECMP_EQUIVALENT, [::wcsicmp], + [Define to function that is equivalent to wcscasecmp()]) + else + AC_CHECK_FUNC(_wcsicmp) + if test "$ac_cv_func__wcsicmp" = yes; then + AC_DEFINE(ACE_WCSCASECMP_EQUIVALENT, [::_wcsicmp]) + fi + fi +fi +]) + +# ACE_FUNC_WCSNCASECMP +# + Defines ACE_LACKS_WCSNCASECMP to 1 if platform lacks strcasecmp() +# + Defines ACE_WCSNCASECMP_EQUIVALENT to identifier name if platform +# has a equivalent function that differs in name only. +#--------------------------------------------------------------------------- +AC_DEFUN([ACE_FUNC_WCSNCASECMP], +[ACE_CHECK_LACKS_FUNCS(wcsncasecmp) +if test "$ac_cv_func_wcsncasecmp" = no; then + AC_CHECK_FUNC(wcsnicmp) + if test "$ac_cv_func_wcsnicmp" = yes; then + AC_DEFINE(ACE_WCSNCASECMP_EQUIVALENT, [::wcsnicmp], + [Define to function that is equivalent to wcsncasecmp()]) + else + AC_CHECK_FUNC(_wcsnicmp) + if test "$ac_cv_func__wcsnicmp" = yes; then + AC_DEFINE(ACE_WCSNCASECMP_EQUIVALENT, [::_wcsnicmp]) + fi + fi +fi +]) + +# ACE_FUNC_WCSDUP +# + Defines ACE_LACKS_WCSDUP to 1 if platform lacks wcsdup() +# + Defines ACE_WCSDUP_EQUIVALENT to identifier name if platform +# has a equivalent function that differs in name only. +# + Defines ACE_HAS_NONCONST_WCSDUP if argument is char*. (TODO) +#--------------------------------------------------------------------------- +AC_DEFUN([ACE_FUNC_WCSDUP], +[ACE_CHECK_LACKS_FUNCS(wcsdup) +if test "$ac_cv_func_wcsdup" = no; then + AC_CHECK_FUNC(_wcsdup) + if test "$ac_cv_func__wcsdup" = yes; then + AC_DEFINE(ACE_WCSDUP_EQUIVALENT, [::_wcsdup], + [Define to function that is equivalent to wcsdup()]) + fi +fi +]) diff --git a/dep/ACE_wrappers/m4/ace_functions.m4 b/dep/ACE_wrappers/m4/ace_functions.m4 new file mode 100644 index 00000000000..97f70eab05c --- /dev/null +++ b/dep/ACE_wrappers/m4/ace_functions.m4 @@ -0,0 +1,27 @@ +# ACE_CHECK_HAS_FUNCS(FUNCTION..., [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) +#--------------------------------------------------------------------------- +AC_DEFUN([ACE_CHECK_HAS_FUNCS], +[AC_FOREACH([ACE_Func], [$1], + [AH_TEMPLATE(AS_TR_CPP(ACE_HAS_[]ACE_Func), + [Define to 1 if platform has ]ACE_Func[().])])dnl +for ace_func in $1 +do +AC_CHECK_FUNC($ace_func, + [AC_DEFINE_UNQUOTED([AS_TR_CPP([ACE_HAS_$ace_func])]) $2], + [$3])dnl +done +]) + +# ACE_CHECK_LACKS_FUNCS(FUNCTION..., [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) +#----------------------------------------------------------------------------- +AC_DEFUN([ACE_CHECK_LACKS_FUNCS], +[AC_FOREACH([ACE_Func], [$1], + [AH_TEMPLATE(AS_TR_CPP(ACE_LACKS_[]ACE_Func), + [Define to 1 if platform lacks ]ACE_Func[().])])dnl +for ace_func in $1 +do +AC_CHECK_FUNC($ace_func, + [$2], + [AC_DEFINE_UNQUOTED([AS_TR_CPP([ACE_LACKS_$ace_func])]) $3])dnl +done +]) diff --git a/dep/ACE_wrappers/m4/ace_headers.m4 b/dep/ACE_wrappers/m4/ace_headers.m4 new file mode 100644 index 00000000000..e873fc640da --- /dev/null +++ b/dep/ACE_wrappers/m4/ace_headers.m4 @@ -0,0 +1,35 @@ +# ACE_CHECK_HAS_HEADERS(HEADER-FILE..., +# [ACTION-IF-FOUND], +# [ACTION-IF-NOT-FOUND], +# [INCLUDES = 'default-includes']) +#----------------------------------------------------------------------------- +AC_DEFUN([ACE_CHECK_HAS_HEADERS], +[AC_FOREACH([ACE_Header], [$1], + [AH_TEMPLATE(AS_TR_CPP(ACE_HAS_[]ACE_Header), + [Define to 1 if platform has the <]ACE_Header[> header file.])])dnl +for ace_header in $1 +do +AC_CHECK_HEADER($ace_header, + [AC_DEFINE_UNQUOTED([AS_TR_CPP([ACE_HAS_$ace_header])]) $2], + [$3], + [$4])dnl +done +]) + +# ACE_CHECK_LACKS_HEADERS(HEADER-FILE..., +# [ACTION-IF-FOUND], +# [ACTION-IF-NOT-FOUND], +# [INCLUDES = 'default-includes']) +#----------------------------------------------------------------------------- +AC_DEFUN([ACE_CHECK_LACKS_HEADERS], +[AC_FOREACH([ACE_Header], [$1], + [AH_TEMPLATE(AS_TR_CPP(ACE_LACKS_[]ACE_Header), + [Define to 1 if platform lacks the <]ACE_Header[> header file.])])dnl +for ace_header in $1 +do +AC_CHECK_HEADER($ace_header, + [$2], + [AC_DEFINE_UNQUOTED([AS_TR_CPP([ACE_LACKS_$ace_header])]) $3], + [$4])dnl +done +]) diff --git a/dep/ACE_wrappers/m4/acinclude.m4 b/dep/ACE_wrappers/m4/acinclude.m4 new file mode 100644 index 00000000000..de18884cee7 --- /dev/null +++ b/dep/ACE_wrappers/m4/acinclude.m4 @@ -0,0 +1,602 @@ +dnl ------------------------------------------------------------------------- +dnl $Id: acinclude.m4 80826 2008-03-04 14:51:23Z wotte $ +dnl +dnl ACE M4 include file which contains general M4 macros +dnl to be used by the ACE configure script. +dnl +dnl The macros in this file were designed for ACE but should be +dnl general enough for general use. +dnl +dnl ------------------------------------------------------------------------- + +dnl Copyright (C) 1998, 1999, 2000, 2002 Ossama Othman +dnl +dnl All Rights Reserved +dnl +dnl This library is free software; you can redistribute it and/or +dnl modify it under the current ACE distribution terms. +dnl +dnl This library is distributed in the hope that it will be useful, +dnl but WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + + +dnl miscellaneous macros + +dnl Prevent the configure script continuing any further if a CVS control +dnl directory is found. The idea is to prevent files generated during +dnl configuration and build from be checked in to the CVS repository that +dnl the sources are checked into. This should only be an issue for +dnl maintainers, not end-users. Maintainers should configure and build in +dnl a directory that doesn't contain any CVS controlled sources and files, +dnl i.e. that doesn't contain a CVS directory. +dnl +dnl Usage: ACE_CHECK_FOR_CVS_DIR +AC_DEFUN([ACE_CHECK_FOR_CVS_DIR], +[ + if test -d CVS; then + AC_MSG_ERROR( + [ + This error is meant for maintainers: + + Please configure and build in a non-CVS controlled directory. + Doing so will prevent accidentally committing automatically + generated files into the CVS repository and help ensure that + the generated files and build scheme are correct. + + For example, try the following from the top-level source + directory: + + mkdir objdir + cd objdir + ../configure + make + + This will create a build space in the directory `objdir' and + start a build in that directory. + ]) + fi +]) + + +dnl Prevent the configure script from continuing any further if +dnl configuration is being performed in the top-level directory. The +dnl idea is to prevent files generated during configuration and build +dnl from overwriting the stock files of the same name. +dnl Usage: ACE_CHECK_TOP_SRCDIR +AC_DEFUN([ACE_CHECK_TOP_SRCDIR], +[ + if test "$srcdir" = "." && test "$USE_MAINTAINER_MODE" != "yes"; then + AC_MSG_ERROR( + [ + Please configure and build in a directory other than the + top-level source directory. Doing so will prevent files + distributed with the package from being overwritten. This is + currently necessary since autoconf support is still + experimental. If you encounter problems please use the stock + build procedure. + + For example, try the following from the top-level source + directory: + + mkdir objdir + cd objdir + ../configure + make + + This will create a build space in the directory `objdir' and + start a build in that directory. + ]) + fi +]) + +dnl Add compiler flags to the CXXFLAGS and CFLAGS variables when doing an +dnl AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],[],[]) (not ACE_TRY_COMPILE). +dnl Use this macro when adding include directories to the compiler flags, +dnl for example. +dnl Usage: ACE_TRY_COMPILE(COMPILER-FLAGS, INCLUDES, FUNCTION-BODY, +dnl [ACTION-IF-FOUND [,ACTION-IF-NOT-FOUND]]) +AC_DEFUN([ACE_TRY_COMPILE], +[ + AC_LANG([C++]) + AC_REQUIRE([AC_LANG]) + + ace_pre_try_CXXFLAGS="$CXXFLAGS" + CXXFLAGS="$CXXFLAGS $1" + + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[$2]], [[$3]])],[$4],[$5]) + + dnl Restore the C++ flags + CXXFLAGS="$ace_pre_try_CXXFLAGS" + +]) + +dnl Create a temporary empty file and remove it after commands are done using +dnl it. The directory in which the temporary file will be created in must +dnl exist. Files will be created under the source directory, not the build +dnl directory. +dnl Use this macro when you need a particular file available but want it to be +dnl empty. This is useful to prevent conflicts with autoconf's confdefs.h +dnl header when doing an AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],[],[]). +dnl Usage: ACE_USE_TEMP_FILE(TEMP-FILE-TO-CREATE, COMMANDS-THAT-WILL-USE-IT) +AC_DEFUN([ACE_USE_TEMP_FILE], +[ + test -d $1 && AC_MSG_ERROR([cannot create file: $acetmp is a directory]) + + dnl Make sure contents of existing file don't override the contents + dnl of the temporary one. + test -f ${srcdir}/$1 && mv ${srcdir}/$1 ${srcdir}/$1.conf + + if test ${srcdir} != "."; then + dnl Create all of the sub-directories. + AS_MKDIR_P([`AS_DIRNAME(["$1"])`]) + fi + + touch $1 + + $2 + + if test -f ${srcdir}/$1.conf; then + mv ${srcdir}/$1.conf ${srcdir}/$1 + fi + + if test ${srcdir} != "."; then + dnl Remove the file. Any sub-directories will not be removed + dnl since we have no way to tell if they existed prior to the + dnl creation of this file. + rm $1 + fi +]) + +dnl Run given test(s) with warnings converted to errors +dnl Usage: ACE_CONVERT_WARNINGS_TO_ERRORS(TEST-BLOCK) +AC_DEFUN([ACE_CONVERT_WARNINGS_TO_ERRORS], +[ +dnl $WERROR is set in the ACE_SET_COMPILER_FLAGS macro. + AC_REQUIRE([ACE_SET_COMPILER_FLAGS]) + +dnl Some tests may pass because the compiler issues warnings +dnl instead of errors when errors should occur. This macro converts +dnl warnings to errors when executing the action/test passed to this +dnl macro so that action/test fails when it is supposed to fail; at +dnl least that is the idea. + + ace_pre_warning_CXXFLAGS="$CXXFLAGS" + CXXFLAGS="$CXXFLAGS $WERROR" + + $1 + + CXXFLAGS="$ace_pre_warning_CXXFLAGS" +]) + +dnl Wrapper around AC_CACHE_VAL used to ensure "ACTION-IF" commands are run +dnl even if results have been previously cached. +dnl Usage: ACE_CACHE_CHECK(MESSAGE, CACHE-ID, COMMANDS-TO-SET-CACHE-VAL, +dnl ACTION-IF-CACHE-ID-IS-YES, +dnl ACTION-IF-CACHE-ID-IS-NO) +dnl The COMMANDS-TO-SET-CACHE-VAL should set the CACHE-ID to yes or "no," +dnl otherwise the "ACTION-IF*" commands may not run. The +dnl COMMANDS-TO-SET-CACHE-VAL should only set the CACHE value. For example, +dnl no AC_DEFINES should be placed in the COMMANDS-TO-SET-CACHE-VAL. +AC_DEFUN([ACE_CACHE_CHECK], +[ + AC_MSG_CHECKING([$1]) + AC_CACHE_VAL([$2], [$3]) + AC_MSG_RESULT([[$]$2]) + if test "[$]$2" != no; then + ace_just_a_place_holder=fixme +ifelse([$4], , :, [$4]) + else + ace_just_a_place_holder=fixme +ifelse([$5], , , [$5 +]) + fi +]) + +dnl checks for programs + +dnl checks for libraries + +dnl checks for header files + +dnl checks for typedefs + +dnl Check for specific typedef in given header file +dnl Usage: ACE_CHECK_TYPE(TYPEDEF, INCLUDE, +dnl [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]) +dnl This macro can only check for one typedef in one header file at a time!! +AC_DEFUN([ACE_CHECK_TYPE], +[ +dnl AC_REQUIRE([AC_PROG_CXX]) +dnl AC_REQUIRE([AC_PROG_CXXCPP]) +dnl AC_LANG([C++]) +dnl AC_REQUIRE([AC_LANG]) + + ACE_CACHE_CHECK([for $1 in $2], [ace_cv_type_$1], + [ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#include <$2> + ]], [[ + $1 ace_$1; + ]])],[ + ace_cv_type_$1=yes + ],[ + ace_cv_type_$1=no + ]) + ],[$3],[$4]) +]) + + +dnl checks for structures + +dnl Check for specific struct in given header file +dnl Usage: ACE_CHECK_STRUCT(STRUCTURE, INCLUDE, +dnl [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]) +dnl This macro can only check for one struct in one header file at a time!! +AC_DEFUN([ACE_CHECK_STRUCT], +[ +dnl AC_REQUIRE([AC_PROG_CXX]) +dnl AC_REQUIRE([AC_PROG_CXXCPP]) +dnl AC_LANG([C++]) +dnl AC_REQUIRE([AC_LANG]) + +dnl Do the transliteration at runtime so arg 1 can be a shell variable. +dnl ac_safe=`echo "$1" | sed 'y%./+-%__p_%'` + + ACE_CACHE_CHECK([for struct $1 in $2], [ace_cv_struct_$1], + [ + ACE_TRY_COMPILE_STRUCT([$1], [$2], + [ + ace_cv_struct_$1=yes + ], + [ + ace_cv_struct_$1=no + ]) + ], $3, $4) +]) + +dnl Check for specific struct in given header file by compiling a test +dnl program. This macro is used by ACE_CHECK_STRUCT. +dnl Usage: ACE_TRY_COMPILE_STRUCT(STRUCTURE, INCLUDE, +dnl [ACTION-IF-SUCCESSFUL[, ACTION-IF-NOT-SUCCESSFUL]]) +dnl This macro can only check for one struct in one header file at a time!! +AC_DEFUN([ACE_TRY_COMPILE_STRUCT], +[ +dnl AC_REQUIRE([AC_PROG_CXX]) +dnl AC_REQUIRE([AC_PROG_CXXCPP]) +dnl AC_LANG([C++]) +dnl AC_REQUIRE([AC_LANG]) + + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#include <$2> + ]], [[ + struct $1 ace_$1; + ]])],[ + $3 + ],[ +dnl Some compilers don't like the "struct" but we need the struct for +dnl some platforms to resolve ambiguities between functions and +dnl structures with with the same name. So, we try the same test but +dnl without "struct" if the above test with "struct" fails. If both +dnl tests fail, then we can be reasonably sure that we don't have the +dnl structure we are testing for. + AC_COMPILE_IFELSE([AC_LANG_PROGRAM( + [[ +#include <$2> + ]], + [[ + $1 ace_$1; + ]])], + [ + $3 + ], + [ + $4 + ]) + ]) +]) + +dnl checks for variables + +dnl checks for compiler characteristics + +dnl checks for library functions + +dnl Check for function using prototype in header +dnl This macro is used if a function is called a different name in a given +dnl library than what is in the header file but the difference is made +dnl transparent to the user since the header may provide a macro to make +dnl things "transparent." If the given header does not exist then this +dnl macro acts just like the standard AC_CHECK_FUNC macro. +dnl Usage: ACE_CHECK_FUNC(FUNCTION, HEADER, +dnl [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]) +AC_DEFUN([ACE_CHECK_FUNC], +[ +dnl AC_REQUIRE([AC_PROG_CXX]) +dnl AC_REQUIRE([AC_PROG_CXXCPP]) +dnl AC_LANG([C++]) +dnl AC_REQUIRE([AC_LANG]) + AC_REQUIRE([AC_PROG_AWK]) + + AC_PREPROC_IFELSE([AC_LANG_SOURCE([[ +#include <$2> + ]])],[ace_header_exists=yes],[ace_header_exists=no]) + + cat > conftest.$ac_ext < + ACE_REAL_FUNCTION $1 + +EOF + + if test "$ace_header_exists" = yes; then + if test -z "$AWK"; then + AC_MSG_WARN([No awk program found. Real $1 function may not be found.]) + fi + + if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "ACE_REAL_FUNCTION" | + (eval "$AWK '{print \[$]2}' > conftest.awk 2>&1"); then + rm -f conftest.$ac_ext + ace_real_function=`cat conftest.awk` + rm -f conftest.awk + fi + + if test $1 != "$ace_real_function"; then + AC_MSG_CHECKING([for real $1 from $2]) + AC_MSG_RESULT([$ace_real_function]) + fi + else + ace_real_function=$1 + fi dnl test "$ace_header_not_exist" != yes + + AC_CHECK_FUNC([$ace_real_function],[$3],[$4]) +]) + +dnl Check for function in library using prototype in header +dnl This macro is used if a function is called a different name in a given +dnl library than what is in the header file but the difference is made +dnl transparent to the user since the header may provide a macro to make +dnl things "transparent." If the given header does not exist then this +dnl macro acts just like the standard AC_CHECK_LIB macro. +dnl Usage: ACE_CHECK_LIB(LIBRARY, FUNCTION, HEADER, +dnl [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]) +AC_DEFUN([ACE_CHECK_LIB], +[ +dnl AC_REQUIRE([AC_PROG_CXX]) +dnl AC_REQUIRE([AC_PROG_CXXCPP]) +dnl AC_LANG([C++]) +dnl AC_REQUIRE([AC_LANG]) + AC_REQUIRE([AC_PROG_AWK]) + + AC_PREPROC_IFELSE([AC_LANG_SOURCE([[ +#include <$3> + ]])],[ace_header_exists=yes],[ace_header_exists=no]) + + cat > conftest.$ac_ext < + ACE_REAL_FUNCTION $2 + +EOF + + if test "$ace_header_exists" = yes; then + if test -z "$AWK"; then + AC_MSG_WARN([No awk program found. "Real" function in library may not be found.]) + fi + + if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "ACE_REAL_FUNCTION" | + eval "$AWK '{print \[$]2}'" > conftest.awk 2>&1; then + rm -f conftest.$ac_ext + ace_real_function=`cat conftest.awk` + rm -f conftest.awk + fi + + if test $2 != "$ace_real_function"; then + AC_MSG_CHECKING([for real $2 from $3]) + AC_MSG_RESULT([$ace_real_function]) + fi + else + ace_real_function=$2 + fi dnl test "$ace_header_not_exist" != yes + + AC_CHECK_LIB([$1], [$ace_real_function], [$4], [$5]) +]) + + +dnl Check if getrlimit() takes an enum as 1st argument +dnl Usage: ACE_CHECK_SETRLIMIT_ENUM +AC_DEFUN([ACE_CHECK_SETRLIMIT_ENUM], +[ +if test "$ac_cv_func_setrlimit" = yes; then + AC_MSG_CHECKING([if setrlimit() takes an enum as 1st argument]) + AC_EGREP_HEADER([setrlimit.*\(.*[^,]*enum], sys/resource.h, + [ + cat > conftest.$ac_ext < +EOF + +dnl Here we attempt to determine the type of the first argument of +dnl getrusage from its prototype. It should either be an int or an +dnl enum. If it is an enum, determine the enum type. + ace_setrlimit_enum=`eval "$ac_cpp conftest.$ac_ext" | \ + $EGREP '[[ ]]+setrlimit.*\(.*[[^,]]*enum' | \ + sed -e 's/^.*setrlimit.*(.*enum//' -e 's/[[^ ]]*,.*$//'` + + ace_setrlimit_enum="enum $ace_setrlimit_enum" + + AC_MSG_RESULT([$ace_setrlimit_enum]) + +if test -n "$ace_setrlimit_enum"; then + AC_DEFINE_UNQUOTED([ACE_HAS_RLIMIT_RESOURCE_ENUM], [$ace_setrlimit_enum]) +fi + + rm -rf conftest* + +dnl Do not remove this parenthesis --> ) +dnl It's only purpose to keep Emacs from getting confused about mismatched +dnl parentheses. + ], + [ + AC_MSG_RESULT([no]) + ]) + +fi dnl test "$ac_cv_func_setrlimit" = yes +]) + +dnl Check if getrusage() takes an enum as 1st argument +dnl Usage: ACE_CHECK_GETRUSAGE_ENUM +AC_DEFUN([ACE_CHECK_GETRUSAGE_ENUM], +[ +if test "$ac_cv_func_getrusage" = yes; then + AC_MSG_CHECKING([if getrusage() takes an enum as 1st argument]) + AC_EGREP_HEADER([getrusage.*\(.*[^,]*enum], [sys/resource.h], + [ + cat > conftest.$ac_ext < +EOF + +dnl Here we attempt to determine the type of the first argument of +dnl getrusage from its prototype. It should either be an int or an +dnl enum. If it is an enum, determine the enum type. + ace_rusage_who=`eval "$ac_cpp conftest.$ac_ext" | \ + $EGREP '[[ ]]+getrusage.*\(.*[[^,]]*enum' | \ + sed -e 's/^.*getrusage.*(.*enum//' -e 's/[[^ ]]*,.*$//'` + + ace_rusage_who="enum $ace_rusage_who" + + AC_MSG_RESULT([$ace_rusage_who]) + +if test -n "$ace_rusage_who"; then + AC_DEFINE_UNQUOTED([ACE_HAS_RUSAGE_WHO_ENUM], [$ace_rusage_who]) +fi + + rm -rf conftest* + +dnl Do not remove this parenthesis --> ) +dnl It's only purpose to keep Emacs from getting confused about mismatched +dnl parentheses. + ], + [ + AC_MSG_RESULT([no]) + ]) + +fi dnl test "$ac_cv_func_getrusage" = yes +]) + + +dnl Check for 64 bit llseek() or lseek64() +dnl Usage: ACE_CHECK_LSEEK64 +AC_DEFUN([ACE_CHECK_LSEEK64], +[ + AC_CHECK_FUNC([lseek64], + [ + AC_DEFINE([ACE_HAS_LSEEK64]) + + dnl Check for 64 bit offset type in the lseek64() prototype, if it + dnl exists. + dnl ACE_CHECK_OFF64_T([lseek64]) + + dnl Check if _LARGEFILE64_SOURCE macro is needed to make the + dnl lseek64() prototype visible, or if the prototype itself is missing. + ACE_CACHE_CHECK([for lseek64 prototype], + [ace_cv_lib_has_lseek64_prototype], + [ + ace_save_CPPFLAGS="$CPPFLAGS" + ace_no_largefile64="-U_LARGEFILE64_SOURCE" + CPPFLAGS="$CPPFLAGS $ace_no_largefile64" + AC_EGREP_HEADER([[^_]+lseek64], [unistd.h], + [ + ace_cv_lib_has_lseek64_prototype=yes + ], + [ + ace_cv_lib_has_lseek64_prototype=no + ]) + dnl Reset the compiler flags + CPPFLAGS="$ace_save_CPPFLAGS" + ],[],[AC_DEFINE([ACE_LACKS_LSEEK64_PROTOTYPE])]) + ], + [ + AC_CHECK_FUNC([llseek], + [ + AC_DEFINE([ACE_HAS_LLSEEK]) + dnl Check if _LARGEFILE64_SOURCE macro is needed to make the + dnl llseek() prototype visible, or if the prototype itself is + dnl missing. + + dnl Check for 64 bit offset type in the llseek() prototype, if + dnl it exists. + dnl ACE_CHECK_OFF64_T([llseek]) + + ACE_CACHE_CHECK([for llseek prototype], + [ace_cv_lib_has_llseek_prototype], + [ + ace_save_CPPFLAGS="$CPPFLAGS" + ace_no_largefile64="-U_LARGEFILE64_SOURCE" + CPPFLAGS="$CPPFLAGS $ace_no_largefile64" + AC_EGREP_HEADER([[^_]+llseek],[unistd.h], + [ + ace_cv_lib_has_llseek_prototype=no + ], + [ + ace_cv_lib_has_llseek_prototype=yes + ],) + dnl Reset the compiler flags + CPPFLAGS="$ace_save_CPPFLAGS" + ],[],[AC_DEFINE([ACE_LACKS_LLSEEK_PROTOTYPE])]) + + + ],) + ]) +]) + +dnl Check what the 64 bit offset type is by checking what the offset +dnl argument for llseek()/lseek64() is. +dnl Usage: ACE_CHECK_LOFF_64(LSEEK64-FUNC) +AC_DEFUN([ACE_CHECK_OFF64_T], +[ + AC_MSG_CHECKING([for 64 bit offset type]) + AC_EGREP_HEADER([[ ]+$1.*\(.*],[unistd.h], + [ + cat > conftest.$ac_ext < /* needed for lseek64()/llseek() prototype */ +#endif +EOF + +dnl Here we attempt to determine the type of the second argument of +dnl lseek64()/llseek() from its prototype. + ace_off64_t=`eval "$ac_cpp conftest.$ac_ext" | \ + $EGREP '[[ ]]+lseek64.*\(.*' | \ + sed -e 's/^.*(.*,[[ ]]*\(.*\) .*,.*$/\1/'` + + +if test -n "$ace_off64_t"; then + AC_MSG_RESULT([$ace_off64_t]) + AC_DEFINE_UNQUOTED([ACE_LOFF_T_TYPEDEF], [$ace_off64_t]) +fi + + rm -rf conftest* + +dnl Do not remove this parenthesis --> ) +dnl It's only purpose is to keep Emacs from getting confused about +dnl mismatched parentheses. + ], + [ + AC_MSG_RESULT([no]) + ]) +]) + +dnl checks for structures + +dnl checks for system services diff --git a/dep/ACE_wrappers/m4/aio.m4 b/dep/ACE_wrappers/m4/aio.m4 new file mode 100644 index 00000000000..b38a8b981aa --- /dev/null +++ b/dep/ACE_wrappers/m4/aio.m4 @@ -0,0 +1,633 @@ +dnl ------------------------------------------------------------------------- +dnl $Id: aio.m4 80826 2008-03-04 14:51:23Z wotte $ +dnl +dnl aio.m4 +dnl +dnl ACE M4 include file which contains ACE specific M4 macros +dnl that determine availablility of POSIX asynchronous IO +dnl support. +dnl +dnl ------------------------------------------------------------------------- + +dnl Copyright (C) 1998, 1999, 2002 Ossama Othman +dnl +dnl All Rights Reserved +dnl +dnl This library is free software; you can redistribute it and/or +dnl modify it under the current ACE distribution terms. +dnl +dnl This library is distributed in the hope that it will be useful, +dnl but WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +dnl Asynchronous IO check +dnl Use this macro to determine if asynchronous IO is working on a +dnl given platform. +dnl Usage: ACE_CHECK_ASYNCH_IO +AC_DEFUN([ACE_CHECK_ASYNCH_IO], +[ + AC_REQUIRE([AC_PROG_CXX]) + AC_REQUIRE([AC_PROG_CXXCPP]) + AC_LANG([C++]) + AC_REQUIRE([AC_LANG]) + AC_REQUIRE([ACE_CHECK_THREADS]) + + dnl In case a library with the asynchronous libraries is found but + dnl the asynchronous IO support is not functional then save a copy + dnl of the list of libraries before the asynch IO function library + dnl is added to the list so that we can revert the list to its + dnl pre-asynch-IO check state. + ace_save_LIBS="$LIBS" + + dnl Asynchronous IO library check + dnl Some platforms, such as Solaris puts aio_read in -lposix4, for example. + dnl In some cases, the thread library must be linked to in addition to the + dnl real-time support library. As such, make sure these checks are done + dnl after the thread library checks. + AC_SEARCH_LIBS([aio_read], [aio rt posix4], + [ace_has_aio_funcs=yes], [ace_has_aio_funcs=no]) + +if test "$ace_has_aio_funcs" = yes; then + ACE_CACHE_CHECK([for working asynchronous IO], + [ace_cv_feature_aio_calls], + [ + AC_RUN_IFELSE([AC_LANG_SOURCE([[ +#ifndef ACE_LACKS_UNISTD_H +#include +#endif +#include +#ifndef ACE_LACKS_SYS_TYPES_H +# include +#endif +#include +#include +#include +#include +#include +#include + +#include + +class Test_Aio +{ +public: + Test_Aio (void); + // Default constructor. + + int init (void); + // Initting the output file and the buffer. + + int do_aio (void); + // Doing the testing stuff. + + ~Test_Aio (void); + // Destructor. +private: + int out_fd_; + // Output file descriptor. + + struct aiocb *aiocb_write_; + // For writing to the file. + + struct aiocb *aiocb_read_; + // Reading stuff from the file. + + char *buffer_write_; + // The buffer to be written to the out_fd. + + char *buffer_read_; + // The buffer to be read back from the file. +}; + +Test_Aio::Test_Aio (void) + : out_fd_ (0), + aiocb_write_ (new struct aiocb), + aiocb_read_ (new struct aiocb), + buffer_write_ (0), + buffer_read_ (0) +{ +} + +Test_Aio::~Test_Aio (void) +{ + if (close (this->out_fd_) != 0) + perror ("close"); + + delete aiocb_write_; + delete aiocb_read_; + delete [] buffer_write_; + delete [] buffer_read_; +} + +// Init the output file and init the buffer. +int +Test_Aio::init (void) +{ + // Open the output file. + this->out_fd_ = open ("test_aio.log", O_RDWR | O_CREAT | O_TRUNC, 0600); + if (this->out_fd_ == -1) + { + perror ("open"); + return -1; + } + + unlink ("test_aio.log"); // Unlink now so we don't have to do so later. + + const char message[] = "Welcome to the world of AIO... AIO Rules !!!"; + + // Init the buffers. + this->buffer_write_ = new char [sizeof (message) + 1]; + strcpy (this->buffer_write_, message); + // cout << "The buffer : " << this->buffer_write_ << endl; + this->buffer_read_ = new char [sizeof (message) + 1]; + + return 0; +} + +// Set the necessary things for the AIO stuff. +// Write the buffer asynchly.hmm Disable signals. +// Go on aio_suspend. Wait for completion. +// Print out the result. +int +Test_Aio::do_aio (void) +{ + // = Write to the file. + + // Setup AIOCB. + this->aiocb_write_->aio_fildes = this->out_fd_; + this->aiocb_write_->aio_offset = 0; + this->aiocb_write_->aio_buf = this->buffer_write_; + this->aiocb_write_->aio_nbytes = strlen (this->buffer_write_); + this->aiocb_write_->aio_reqprio = 0; + this->aiocb_write_->aio_sigevent.sigev_notify = SIGEV_NONE; + //this->this->aiocb_.aio_sigevent.sigev_signo = SIGRTMAX; + this->aiocb_write_->aio_sigevent.sigev_value.sival_ptr = + (void *) this->aiocb_write_; + + // Fire off the aio write. + if (aio_write (this->aiocb_write_) != 0) + { + perror ("aio_write"); + return -1; + } + + // = Read from that file. + + // Setup AIOCB. + this->aiocb_read_->aio_fildes = this->out_fd_; + this->aiocb_read_->aio_offset = 0; + this->aiocb_read_->aio_buf = this->buffer_read_; + this->aiocb_read_->aio_nbytes = strlen (this->buffer_write_); + this->aiocb_read_->aio_reqprio = 0; + this->aiocb_read_->aio_sigevent.sigev_notify = SIGEV_NONE; + //this->this->aiocb_.aio_sigevent.sigev_signo = SIGRTMAX; + this->aiocb_read_->aio_sigevent.sigev_value.sival_ptr = + (void *) this->aiocb_read_; + + // Fire off the aio write. If it doesnt get queued, carry on to get + // the completion for the first one. + if (aio_read (this->aiocb_read_) < 0) + perror ("aio_read"); + + // Wait for the completion on aio_suspend. + struct aiocb *list_aiocb[2]; + list_aiocb [0] = this->aiocb_write_; + list_aiocb [1] = this->aiocb_read_; + + // Do suspend till all the aiocbs in the list are done. + int done = 0; + while (!done) + { + if (aio_suspend (list_aiocb, 2, 0) != 0) + { + perror ("aio_suspend"); + return -1; + } + + // Analyze return and error values. + if (list_aiocb [0] != 0 && aio_error (list_aiocb [0]) != EINPROGRESS) + { + if (aio_return (list_aiocb [0]) == -1) + { + perror ("aio_return"); + return -1; + } + else + { + // Successful. Store the pointer somewhere and make the + // entry NULL in the list. + // @@ no need ----> this->aiocb_write_ = list_aiocb [0]; + list_aiocb [0] = 0; + } + } +// else +// cout << "AIO in progress" << endl; + + if (list_aiocb [1] != 0 && aio_error (list_aiocb [1]) != EINPROGRESS) + { + if (aio_return (list_aiocb [1]) == -1) + { + perror ("aio_return"); + return -1; + } + else + { + // Successful. Store the pointer somewhere and make the + // entry NULL in the list. + // @@ no need ----> this->aiocb_read_ = list_aiocb [1]; + list_aiocb [1] = 0; + } + } +// else +// cout << "AIO in progress" << endl; + + // Is it done? + if ((list_aiocb [0] == 0) && (list_aiocb [1] == 0)) + done = 1; + } + + //cout << "Both the AIO operations done." << endl; + //cout << "The buffer is :" << this->buffer_read_ << endl; + + return 0; +} + +int +main () +{ + Test_Aio test_aio; + + if (test_aio.init () != 0) + { + //printf ("AIOCB test failed:\n" + // "ACE_POSIX_AIOCB_PROACTOR may not work in this platform\n"); + return -1; + } + + if (test_aio.do_aio () != 0) + { + //printf ("AIOCB test failed:\n" + // "ACE_POSIX_AIOCB_PROACTOR may not work in this platform\n"); + return -1; + } + //printf ("AIOCB test successful:\n" + // "ACE_POSIX_AIOCB_PROACTOR should work in this platform\n"); + return 0; +} + ]])],[ + ace_cv_feature_aio_calls=yes + ],[ + ace_cv_feature_aio_calls=no + ],[ + dnl Asynchronous IO test for cross-compiled platforms + dnl This test is weaker than the above run-time tests but it will + dnl have to do. + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[ +#include + ]], + [[ + aiocb* aiocb_ptr (void); + ]])], + [ + ace_cv_feature_aio_calls=yes + ], + [ + ace_cv_feature_aio_calls=no + ]) + ]) + ],[AC_DEFINE([ACE_HAS_AIO_CALLS])],[LIBS="$ace_save_LIBS"]) +fi dnl test "$ace_has_aio_funcs" = yes + + +if test "$ace_cv_feature_aio_calls" = yes; then + ACE_CACHE_CHECK([for working POSIX realtime signals], + [ace_cv_feature_posix_rt_sigs], + [ + dnl Create a file for the test program to read. + cat > test_aiosig.txt < +} +#ifndef ACE_LACKS_UNISTD_H +#include +#endif +#include +#ifndef ACE_LACKS_SYS_TYPES_H +# include +#endif +#include +#include +#include +#include +#include + +#include + +#include + +#ifdef __cplusplus +extern "C" +#endif +void null_handler (int /* signal_number */, + siginfo_t * /* info */, + void * /* context */); + +int file_handle = -1; +char mb1[BUFSIZ + 1]; +char mb2[BUFSIZ + 1]; +aiocb aiocb1, aiocb2; +sigset_t completion_signal; + +// Function prototypes. +int setup_signal_delivery (void); +int issue_aio_calls (void); +int query_aio_completions (void); +int test_aio_calls (void); +int setup_signal_handler (void); +int setup_signal_handler (int signal_number); + +int +setup_signal_delivery (void) +{ + // Make the sigset_t consisting of the completion signal. + if (sigemptyset (&completion_signal) == -1) + { + perror ("Error:Couldn't init the RT completion signal set\n"); + return -1; + } + + if (sigaddset (&completion_signal, SIGRTMIN) == -1) + { + perror ("Error:Couldn't init the RT completion signal set\n"); + return -1; + } + + // Mask them. + if (pthread_sigmask (SIG_BLOCK, &completion_signal, 0) == -1) + { + perror ("Error:Couldn't make the RT completion signals\n"); + return -1; + } + + return setup_signal_handler (SIGRTMIN); +} + +int +issue_aio_calls (void) +{ + // Setup AIOCB. + aiocb1.aio_fildes = file_handle; + aiocb1.aio_offset = 0; + aiocb1.aio_buf = mb1; + aiocb1.aio_nbytes = BUFSIZ; + aiocb1.aio_reqprio = 0; + aiocb1.aio_sigevent.sigev_notify = SIGEV_SIGNAL; + aiocb1.aio_sigevent.sigev_signo = SIGRTMIN; + aiocb1.aio_sigevent.sigev_value.sival_ptr = (void *) &aiocb1; + + // Fire off the aio write. + if (aio_read (&aiocb1) == -1) + { + // Queueing failed. + perror ("Error:Asynch_Read_Stream: aio_read queueing failed\n"); + return -1; + } + + // Setup AIOCB. + aiocb2.aio_fildes = file_handle; + aiocb2.aio_offset = BUFSIZ + 1; + aiocb2.aio_buf = mb2; + aiocb2.aio_nbytes = BUFSIZ; + aiocb2.aio_reqprio = 0; + aiocb2.aio_sigevent.sigev_notify = SIGEV_SIGNAL; + aiocb2.aio_sigevent.sigev_signo = SIGRTMIN; + aiocb2.aio_sigevent.sigev_value.sival_ptr = (void *) &aiocb2; + + // Fire off the aio write. + if (aio_read (&aiocb2) == -1) + { + // Queueing failed. + perror ("Error:Asynch_Read_Stream: aio_read queueing failed\n"); + return -1; + } + return 0; +} + +int +query_aio_completions (void) +{ + int result = 0; + size_t number_of_completions = 0; + for (number_of_completions = 0; + number_of_completions < 2; + number_of_completions++) + { + // Wait for amount of time. + // @@ Assigning to tv_sec. + timespec timeout; + timeout.tv_sec = 5; + timeout.tv_nsec = 0; + + // To get back the signal info. + siginfo_t sig_info; + + // Await the RT completion signal. + int sig_return = sigtimedwait (&completion_signal, + &sig_info, + &timeout); + + // Error case. + // If failure is coz of timeout, then return *0* but set + // errno appropriately. This is what the WinNT proactor + // does. + if (sig_return == -1) + { + perror ("Error:Error waiting for RT completion signals\n"); + return -1; + } + + // RT completion signals returned. + if (sig_return != SIGRTMIN) + { + //printf ("Unexpected signal (%d) has been received while waiting for RT Completion Signals\n", + // sig_return); + return -1; + } + + // @@ Debugging. + //printf ("Sig number found in the sig_info block : %d\n", + // sig_info.si_signo); + + // Is the signo returned consistent? + if (sig_info.si_signo != sig_return) + { + //printf ("Inconsistent signal number (%d) in the signal info block\n", + // sig_info.si_signo); + return -1; + } + + // @@ Debugging. + //printf ("Signal code for this signal delivery : %d\n", + // sig_info.si_code); + + // Is the signal code an aio completion one? + if ((sig_info.si_code != SI_ASYNCIO) && + (sig_info.si_code != SI_QUEUE)) + { + //printf ("Unexpected signal code (%d) returned on completion querying\n", + // sig_info.si_code); + return -1; + } + + // Retrive the aiocb. + aiocb* aiocb_ptr = (aiocb *) sig_info.si_value.sival_ptr; + + // Analyze error and return values. Return values are + // actually 's associated with the call + // corresponding to aiocb_ptr. + int error_code = aio_error (aiocb_ptr); + if (error_code == -1) + { + perror ("Error:Invalid control block was sent to for compleion querying\n"); + return -1; + } + + if (error_code != 0) + { + // Error occurred in the call. Return the errno + // corresponding to that call. + //printf ("Error:An AIO call has failed:Error code = %d\n", + // error_code); + return -1; + } + + // No error occured in the AIO operation. + int nbytes = aio_return (aiocb_ptr); + if (nbytes == -1) + { + perror ("Error:Invalid control block was sent to \n"); + return -1; + } + + //if (number_of_completions == 0) + // Print the buffer. + //printf ("Number of bytes transferred : %d\n The buffer : %s \n", + // nbytes, + // mb1); + //else + // Print the buffer. + //printf ("Number of bytes transferred : %d\n The buffer : %s \n", + // nbytes, + // mb2); + } + return 0; +} + +int +test_aio_calls (void) +{ + // Set up the input file. + // Open file (in SEQUENTIAL_SCAN mode) + file_handle = open ("test_aiosig.txt", O_RDONLY); + + if (file_handle == -1) + { + perror ("open"); + return -1; + } + + unlink ("test_aiosig.txt"); // Unlink now so we don't have to do so later. + + if (setup_signal_delivery () < 0) + return -1; + + if (issue_aio_calls () < 0) + return -1; + + if (query_aio_completions () < 0) + return -1; + + if (close (file_handle) != 0) + { + perror ("close"); + return -1; + } + + return 0; +} + +int +setup_signal_handler (int signal_number) +{ + // Setting up the handler(!) for these signals. + struct sigaction reaction; + sigemptyset (&reaction.sa_mask); // Nothing else to mask. + reaction.sa_flags = SA_SIGINFO; // Realtime flag. +#if defined (SA_SIGACTION) + // Lynx says, it is better to set this bit to be portable. + reaction.sa_flags &= SA_SIGACTION; +#endif /* SA_SIGACTION */ + reaction.sa_sigaction = null_handler; // Null handler. + int sigaction_return = sigaction (SIGRTMIN, + &reaction, + 0); + if (sigaction_return == -1) + { + perror ("Error:Proactor couldn't do sigaction for the RT SIGNAL"); + return -1; + } + + return 0; +} + +void +null_handler (int /* signal_number */, + siginfo_t * /* info */, + void * /* context */) +{ +} + +int +main () +{ + if (test_aio_calls () == 0) + { + // printf ("RT SIG test successful:\n" + // "ACE_POSIX_SIG_PROACTOR should work in this platform\n"); + return 0; + } + + //printf ("RT SIG test failed:\n" + // "ACE_POSIX_SIG_PROACTOR may not work in this platform\n"); + return -1; + +} + ]])], + [ + ace_cv_feature_posix_rt_sigs=yes + ], + [ + ace_cv_feature_posix_rt_sigs=no + ], + [ + dnl Don't bother doing anything for cross-compiling here + dnl since the basic aio run-time test will prevent this + dnl rt sig run-time test from ever running when cross-compiling. + dnl We just put something in here to prevent autoconf + dnl from complaining. + ace_just_a_place_holder=ignoreme + ]) + ],[AC_DEFINE([ACE_HAS_POSIX_REALTIME_SIGNALS])],[]) +fi dnl test "$ace_cv_feature_aio_calls" = yes + +]) diff --git a/dep/ACE_wrappers/m4/compiler.m4 b/dep/ACE_wrappers/m4/compiler.m4 new file mode 100644 index 00000000000..549d29cc901 --- /dev/null +++ b/dep/ACE_wrappers/m4/compiler.m4 @@ -0,0 +1,426 @@ +dnl ------------------------------------------------------------------------- +dnl $Id: compiler.m4 80826 2008-03-04 14:51:23Z wotte $ +dnl +dnl compiler.m4 +dnl +dnl ACE M4 include file which contains ACE specific M4 macros +dnl that set/determine compiler configurations for ACE. +dnl +dnl ------------------------------------------------------------------------- + +dnl Copyright (C) 1998, 1999, 2003 Ossama Othman +dnl +dnl All Rights Reserved +dnl +dnl This library is free software; you can redistribute it and/or +dnl modify it under the current ACE distribution terms. +dnl +dnl This library is distributed in the hope that it will be useful, +dnl but WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + + +dnl Macros to set flags for a given compiler on a given platform. +dnl The flags set here are generally only useful for _KNOWN_ compilers. + +dnl ACE_SET_COMPILER_FLAGS +dnl Usage: ACE_SET_COMPILER_FLAGS +AC_DEFUN([ACE_SET_COMPILER_FLAGS], +[ +dnl AC_BEFORE([$0], [AC_PROG_LIBTOOL]) + + dnl Make sure we know what C++ compiler and preprocessor we have! + AC_REQUIRE([AC_PROG_CXX]) + AC_REQUIRE([AC_PROG_CXXCPP]) + AC_LANG([C++]) + AC_REQUIRE([AC_LANG]) + + AC_REQUIRE([ACE_COMPILATION_OPTIONS]) + + ACE_GXX_MAJOR_VERSION=0 + + if test "$GXX" = yes; then + ACE_GXX_MAJOR_VERSION=`$CXX -dumpversion | sed -e 's/\..*$//'` + +dnl @todo Clean up / consolidate these conditionals + + if test "$ACE_GXX_MAJOR_VERSION -ge 3"; then + if test "$ace_user_enable_exceptions" != yes; then + ACE_CXXFLAGS="$ACE_CXXFLAGS -fcheck-new" + fi + else + case `$CXX --version` in + 2.9*) + if test "$ace_user_enable_exceptions" != yes; then + ACE_CXXFLAGS="$ACE_CXXFLAGS -fcheck-new" + fi + ;; + esac + fi + fi + + dnl Compiler Flag Key + dnl CXXFLAGS - C++ flags to use during the configure script run and + dnl during ACE compilation. The user may set this prior to + dnl running the configure script. As such, it is important + dnl not to replace the existing value of CXXFLAGS; rather + dnl one should only add to it. + dnl ACE_CXXFLAGS + dnl - General C++ flags the configure script should set before + dnl CXXFLAGS to allow the user override them. + dnl DCXXFLAGS - C++ debugging flags + dnl OCXXFLAGS - C++ optimization flags + dnl CPPFLAGS - C++ preprocessor flags + dnl ACE_CPPFLAGS + dnl - General C++ preprocessor flags the configure + dnl script should set before CPPFLAGS to allow the + dnl user to override them. + dnl WERROR - Compiler flag that converts warnings to errors + + if test "$GXX" = yes; then + WERROR="-Werror" + fi + + case "$host" in + *aix*) + dnl In case anything here or in the config depends on OS + dnl version number, grab it here and pass it all to the + dnl compiler as well. + AIX_VERS=`uname -v`0`uname -r` + ACE_CPPFLAGS="$ACE_CPPFLAGS -DACE_AIX_VERS=$AIX_VERS" + + case "$CXX" in + xlC*) + dnl AIX compilers need to have RTTI enabled and ACE requires it. + CXXFLAGS="$CXXFLAGS -qrtti=all" + TEMPLATE_OPTION='-qnotempinc -qnotemplateregistry -DACE_TEMPLATES_REQUIRE_SOURCE' + ACE_CXXFLAGS="$ACE_CXXFLAGS $TEMPLATE_OPTION" + DCXXFLAGS="-g -qcheck=nobounds:div:null" + OCXXFLAGS="-qlibansi -qarch=com" + CPPFLAGS="$CPPFLAGS" + # Use -qhalt=i to cause the compiler to signal failure on any + # diagnostic when converting warnings to errors. This helps to + # find that #pragma once is invalid, even though xlC only triggers + # an informational message, not a warning. + WERROR="-qhalt=i" + ;; + *) + if test "$GXX" = yes; then + ACE_CXXFLAGS="-mcpu=common" + fi + ;; + esac + ;; + *chorus*) + ;; + *cray*) + ;; + *dgux*) + case "$CXX" in + ec++) + CXXFLAGS="$CXXFLAGS" + ACE_CXXFLAGS="$ACE_CXXFLAGS -relax -v -eh" + DCXXFLAGS="-g" + OCXXFLAGS="" + ;; + *) + if test "$GXX" = yes; then + ACE_CXXFLAGS="$ACE_CXXFLAGS" + fi + ;; + esac + ;; + *freebsd*) + ;; + *hpux*) + # In case anything here or in the config depends on OS + # version number, grab it here and pass it all to the + # compiler as well. + OSVERS=`uname -r | $AWK 'BEGIN{FS=".";OFS="";}{print [$][2],[$][3]}' -` + ACE_CPPFLAGS="$ACE_CPPFLAGS -DHPUX_VERS=$OSVERS" + + # HP-UX OS version specific settings. + case "$host" in + *hpux11*) +# aCC's "-mt" flag detected by the configure script should already set +# the appropriate preprocessor, compiler and linker flags. +# if test "$ace_user_enable_threads" = yes; then +# # Prefer kernel threads over CMA (user) threads. +# ACE_CPPFLAGS="$ACE_CPPFLAGS -D_POSIX_C_SOURCE=199506L" +# fi + ;; + esac + + # HP-UX compiler specific settings. + case "$CXX" in + CC) + CXXFLAGS="$CXXFLAGS -pta -ti,/bin/true -tr,/bin/true" + ACE_CXXFLAGS="$ACE_CXXFLAGS -Aa -z +a1" + DCXXFLAGS="-g" + OCXXFLAGS="" + ;; + aCC) + CFLAGS = "${CFLAGS:-} -Ae" + # -AA has been available since aC++ x.27 (2001?) - if using a + # compiler without this support, must --enable_stdcpplib=no. + if test "$ace_user_enable_stdcpplib" = yes; then + CXXFLAGS="$CXXFLAGS -AA" + fi + # Warning 930 is spurious when new(std::nothrow) is + # used. Reported to HP as support call 3201224717. (Steve + # Huston, 23-Nov-2002) + # + # Suppress warning 302 ((...) parameter list is a + # non-portable feature) + # + # Additionally, on HP-UX 10.20, suppress 495 to shut up the + # warnings from the system header files. 667 is also + # suppressed, but the compiler still tells you there was a + # future error, but at least you can pick out any real errors + # by quickly scanning the output. 829 is suppressed because + # the system headers have offending string literals assigned + # to char *. + ACE_CXXFLAGS="$ACE_CXXFLAGS +W302,495,667,829,908,930" + DCXXFLAGS="-g" + OCXXFLAGS="-O" + # Warning 67: Invalid pragma name -- needed for + # ACE_LACKS_PRAGMA_ONCE + WERROR="+We67 +p +We" + + # If exception support is explicitly disabled, tell the + # compiler. This is not recommended since the run-time + # library can throw exceptions. + if test "$ace_user_enable_exceptions" != yes; then + ACE_CXXFLAGS="$ACE_CXXFLAGS +noeh" + fi + ;; + *) + if test "$GXX" = yes; then + ACE_CXXFLAGS="$ACE_CXXFLAGS -w" + fi + ;; + esac + ;; + *irix5*) + case "$CXX" in + CC) + CXXFLAGS="$CXXFLAGS -ptused -prelink +pp -woff 3203,3209,3161,3262,3665" + ACE_CXXFLAGS="$ACE_CXXFLAGS " + DCXXFLAGS="-g" + OCXXFLAGS="" + ;; + *) + ;; + esac + ;; + *irix6*) + case "$CXX" in + CC) + CPPFLAGS="$CPPFLAGS -D_SGI_MP_SOURCE" + CXXFLAGS="$CXXFLAGS -exceptions -ptnone -no_prelink -Wl,-woff,15 -Wl,-woff,84 -Wl,-woff,85 -Wl,-woff,133" + ACE_CXXFLAGS="$ACE_CXXFLAGS " + DCXXFLAGS="-g" + OCXXFLAGS="-O -OPT:Olimit=0" + ;; + esac + ;; + *linux*) + case "$CXX" in + *icpc|*icc) + CXXFLAGS="$CXXFLAGS -i-dynamic -w1" + ACE_CXXFLAGS="$ACE_CXXFLAGS" + DCXXFLAGS="$DCXXFLAGS" + WERROR="-Werror -wr -Wall" + ;; + *) + if test "$GXX" = yes; then + CXXFLAGS="$CXXFLAGS" + ACE_CXXFLAGS="$ACE_CXXFLAGS" + DCXXFLAGS="$DCXXFLAGS" + OCXXFLAGS="-O3" + fi + ;; + esac + ;; + *lynxos*) + ;; + *m88k*) + ;; + *mvs*) + ;; + *netbsd*) + ;; + *osf*) + ;; + *psos*) + ;; + *sco*) + ;; + *sunos4*) + ;; + *solaris2*) + case "$CXX" in + CC) + WERROR="-xwe" + + if test "$ace_user_enable_exceptions" != yes; then + CXXFLAGS="$CXXFLAGS -noex" + fi + + dnl Some flags only work with Sun C++ 4.2. ACE requires RTTI. + if (CC -V 2>&1 | $EGREP 'Compilers 4\.2' > /dev/null); then + CXXFLAGS="$CXXFLAGS -features=castop -features=rtti" + fi + + dnl Sun C++ 5.0 weirdness + if (CC -V 2>&1 | $EGREP 'Compilers 5\.0' > /dev/null); then + if test "$ace_user_enable_stdcpplib" = yes; then + CXXFLAGS="$CXXFLAGS -library=Cstd" + else + CXXFLAGS="$CXXFLAGS -library=iostream,no%Cstd" + AC_DEFINE([ACE_USES_OLD_IOSTREAMS]) + fi + + dnl Inlining appears to cause link problems with early + dnl releases of CC 5.0. + AC_DEFINE([ACE_LACKS_INLINE_FUNCTIONS]) + + if test "$ace_user_enable_exceptions" != yes; then + dnl See /opt/SUNWspro_5.0/SC5.0/include/CC/stdcomp.h. + ACE_CPPFLAGS="$ACE_CPPFLAGS -D_RWSTD_NO_EXCEPTIONS" + fi + + CXXFLAGS="$CXXFLAGS -instances=explicit" + fi + + CXXFLAGS="$CXXFLAGS" + ACE_CXXFLAGS="$ACE_CXXFLAGS" + DCXXFLAGS="$DCXXFLAGS -g" + OCXXFLAGS="$OCXXFLAGS -O" + ;; + esac + ;; + *tandem*) + ;; + *unixware*) + ;; + *vxworks*) + ;; + *) + CXXFLAGS="$CXXFLAGS" + ACE_CXXFLAGS="$ACE_CXXFLAGS" + DCXXFLAGS="-g" + OCXXFLAGS="-O" + ;; + esac + + dnl Warning flags + if test "$GCC" = yes; then + ACE_CFLAGS="$ACE_CFLAGS -W -Wall -Wpointer-arith" + fi + if test "$GXX" = yes; then + ACE_CXXFLAGS="$ACE_CXXFLAGS -W -Wall -Wpointer-arith" + fi + + dnl Symbol Visibility flags + dnl Take advantage of visibility attributes when using g++ 4.0 or + dnl better. + if test "$GXX" = yes; then + dnl As of this writing, there are symbol visibility issues on some + dnl platforms. The --disable-symbol-visibility option is intended + dnl to allow users to explicitly disable symbol visibility support + dnl in the cases where it does not work (or does not work properly), + dnl but the feature test selects it anyway. + + AC_ARG_ENABLE([symbol-visibility], + AS_HELP_STRING([--enable-symbol-visibility], + [build with gcc symbol visibility attributes [[[no]]]]), + [ + case "${enableval}" in + yes) + ace_user_enable_symbol_visibility=yes + ;; + no) + ace_user_enable_symbol_visibility=no + ;; + *) + AC_MSG_ERROR([bad value ${enableval} for --enable-symbol-visibility]) + ;; + esac + ], + [ + ace_user_enable_symbol_visibility=no + ]) + + if test "$ace_user_enable_symbol_visibility" = yes; then + ACE_CHECK_CXXFLAGS([fvisibility=hidden], + [ + ACE_CXXFLAGS="$ACE_CXXFLAGS -fvisibility=hidden" + AC_DEFINE([ACE_HAS_CUSTOM_EXPORT_MACROS]) + AC_DEFINE([ACE_Proper_Export_Flag], + [__attribute__ ((visibility("default")))]) + ]) + ACE_CHECK_CXXFLAGS([fvisibility-inlines-hidden], + [ + ACE_CXXFLAGS="$ACE_CXXFLAGS -fvisibility-inlines-hidden" + ]) + fi + fi + + dnl Additional flags + if test "$GXX" = yes; then + case `$CXX --version` in + 2.9*) + if test "$ace_user_enable_exceptions" != yes; then + ACE_CXXFLAGS="$ACE_CXXFLAGS -fcheck-new" + fi + ;; + esac + +dnl if test "$ace_user_enable_repo" = no; then +dnl ACE_CXXFLAGS="$ACE_CXXFLAGS -fno-implicit-templates" +dnl fi + fi +]) + +AC_DEFUN([ACE_CHECK_CFLAGS], +[ +AS_VAR_PUSHDEF([VAR],'ace_cv_cflag_$1') +AC_MSG_CHECKING([whether $CC supports -$1]) +AC_LANG_SAVE +AC_LANG([C]) +ace_save_CFLAGS=$CFLAGS +CFLAGS="$CFLAGS -$1" +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[return 0])],[VAR=yes],[VAR=no]) +CFLAGS=$ace_save_CFLAGS +AC_LANG_RESTORE +if test $VAR = yes; then + AC_MSG_RESULT([yes]) + $2 +else + AC_MSG_RESULT([no]) + $3 +fi +AS_VAR_POPDEF([VAR]) +]) + +AC_DEFUN([ACE_CHECK_CXXFLAGS], +[ +AS_VAR_PUSHDEF([VAR],'ace_cv_cxxflag_$1') +AC_MSG_CHECKING([whether $CXX supports -$1]) +AC_LANG_SAVE +AC_LANG([C++]) +ace_save_CXXFLAGS=$CXXFLAGS +CXXFLAGS="$CXXFLAGS -$1" +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[return 0])],[VAR=yes],[VAR=no]) +CXXFLAGS=$ace_save_CXXFLAGS +AC_LANG_RESTORE +if test $VAR = yes; then + AC_MSG_RESULT([yes]) + $2 +else + AC_MSG_RESULT([no]) + $3 +fi +AS_VAR_POPDEF([VAR]) +]) diff --git a/dep/ACE_wrappers/m4/config_h.m4 b/dep/ACE_wrappers/m4/config_h.m4 new file mode 100644 index 00000000000..6338b290f49 --- /dev/null +++ b/dep/ACE_wrappers/m4/config_h.m4 @@ -0,0 +1,976 @@ +dnl ------------------------------------------------------------------------- +dnl $Id: config_h.m4 82277 2008-07-09 17:45:59Z jtc $ +dnl +dnl config_h.m4 +dnl +dnl ACE M4 include file which contains preprocessor constants +dnl and other items to be place in the generated ace/config.h +dnl header. +dnl +dnl ------------------------------------------------------------------------- + +dnl Copyright (C) 2002, 2003 Ossama Othman +dnl +dnl All Rights Reserved +dnl +dnl This library is free software; you can redistribute it and/or +dnl modify it under the current ACE distribution terms. +dnl +dnl This library is distributed in the hope that it will be useful, +dnl but WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +dnl Prepare the ace/config.h.in template. +dnl +dnl Usage: ACE_PREP_CONFIG_HEADER +AC_DEFUN([ACE_PREP_CONFIG_HEADER], +[ +dnl Text to be placed at the top of the `ace/config.h' header. +AH_TOP([ +#ifndef ACE_CONFIG_H +#define ACE_CONFIG_H + +// ACE configuration header file + + +]) + +dnl Text to be placed at the bottom of the `ace/config.h' header. +dnl +dnl @note Do not remove the "] [" between the words "Local Variables". +dnl The generated Emacs "Local Variables" block will not contain +dnl those characters. They are merely interpreted by M4 as two +dnl concatenated text blocks. This is necessary to prevent +dnl Emacs from inadvertently applying the "Local Variables" +dnl block being placed in the generated "config.h" header to +dnl this Autoconf/M4 file. +AH_BOTTOM([ + + +#endif /* ACE_CONFIG_H */ + + +// Local] [Variables: +// mode:C++ +// End: + +]) + + +dnl ACE currently doesn't use these; however the configure script does +AH_TEMPLATE([ACE_LACKS_UNBUFFERED_STREAMBUF],[]) +AH_TEMPLATE([ACE_HAS_STDCPP_STL_INCLUDES],[]) + +AH_TEMPLATE([ACE_HAS_NEW_NO_H],[Platform provides new style C++ header]) +AH_TEMPLATE([ACE_HAS_STDEXCEPT_NO_H],[Platform provides C++ header]) + +dnl Deprecated! (or soon to be?) +AH_TEMPLATE([ACE_HAS_OSF1_GETTIMEOFDAY], +[timezone* 2nd parameter & no prototype]) +AH_TEMPLATE([ACE_HAS_LYNXOS_SIGNALS],[]) +AH_TEMPLATE([ACE_HAS_TANDEM_SIGNALS],[]) + +AH_TEMPLATE([PTHREAD_STACK_MIN],[]) + +dnl ///////////////////// OSSAMA'S NEW STUFF ////////////////// */ +dnl THIS STUFF WILL REPLACE THE ABOVE OLDER STUFF AND/OR WILL BE MERGED INTO IT + + +dnl /* results from checks for programs */ +dnl /* results from checks for libraries */ +dnl /* results from checks for header files */ +dnl /* results from checks for typedefs */ +dnl /* results from checks for structures */ +dnl /* results from checks for variables */ +dnl /* results from checks for compiler characteristics */ +dnl /* results from checks for library functions */ +dnl /* results from checks for system services */ + +dnl AIX specific configuration parameters +AH_TEMPLATE([AIX],[Configure for use on AIX]) + +dnl FreeBSD specific configuration parameters +dnl Nothing yet + +dnl HP/UX specific configuration parameters +AH_TEMPLATE([HPUX],[Configure for use on HP-UX]) +AH_TEMPLATE([HPUX_10],[Configure for use on HP-UX 10]) +AH_TEMPLATE([HPUX_11],[Configure for use on HP-UX 11]) + +dnl Irix specific configuration parameters +AH_TEMPLATE([IRIX5],[Configure for use on Irix 5]) +AH_TEMPLATE([IRIX6],[Configure for use on Irix 6]) +AH_TEMPLATE([ACE_HAS_IRIX62_THREADS], +[Platform supports the very odd IRIX 6.2 threads...]) + +dnl Linux specific configuration parameters +dnl Nothing yet */ + +dnl LynxOS specific configuration parameters +AH_TEMPLATE([__NO_INCLUDE_WARN__],[]) + +dnl MVS specific configuration parameters +dnl Nothing yet + +dnl NetBSD specific configuration parameters +dnl Nothing yet + +dnl OSF/1 and Digital Unix specific configuration parameters +AH_TEMPLATE([DEC_CXX],[]) +AH_TEMPLATE([DIGITAL_UNIX],[Configure for use on Digital Unix]) + +dnl SCO specific configuration parameters +AH_TEMPLATE([SCO],[]) + +dnl Tandem specific configuration parameters +dnl Nothing yet + +dnl UnixWare specific configuration parameters +AH_TEMPLATE([UNIXWARE],[Configure for use on UnixWare]) +AH_TEMPLATE([UNIXWARE_2_0],[]) +AH_TEMPLATE([UNIXWARE_2_1],[]) +AH_TEMPLATE([UNIXWARE_7_1],[]) +AH_TEMPLATE([__IOCTL_VERSIONED__],[]) + +dnl VXWorks specific configuration parameters +AH_TEMPLATE([VXWORKS],[Configure for use on VxWorks]) + +dnl Win32 specific configuration parameters +AH_TEMPLATE([ACE_WIN32],[Configure for use on Win32]) + +AH_TEMPLATE([ACE_DISABLE_DEBUG_DLL_CHECK], +[Define this if you don't want debug version ACE search for debug version +DLLs first before looking for the DLL names specified.]) + +AH_TEMPLATE([ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS], +[Platform/compiler supports Win32 structural exceptions.]) + +AH_TEMPLATE([ACE_WSOCK_VERSION], +[A parameter list indicating the version of WinSock (e.g., "1, 1" is +version 1.1).]) + +AH_TEMPLATE([ACE_HAS_MFC],[Platform supports Microsoft Foundation Classes]) + +AH_TEMPLATE([ACE_USES_STATIC_MFC], +[When linking MFC as a static library is desired]) + +AH_TEMPLATE([ACE_HAS_CANCEL_IO], +[Platform supports the Win32 CancelIO() function. (WinNT 4.0 and beyond)]) + +AH_TEMPLATE([ACE_HAS_WIN32_TRYLOCK], +[The Win32 platform support TryEnterCriticalSection(). (WinNT 4.0 and +beyond)]) + +AH_TEMPLATE([ACE_HAS_WINSOCK2],[The Win32 platform supports WinSock 2.0.]) + +AH_TEMPLATE([ACE_USE_SELECT_REACTOR_FOR_REACTOR_IMPL], +[For Win32: Use Select_Reactor as default implementation of Reactor + instead of WFMO_Reactor.]) + +AH_TEMPLATE([ACE_HAS_DLL],[Build ACE using the frigging PC DLL nonsense...]) + +AH_TEMPLATE([ACE_HAS_STRICT],[Use the STRICT compilation mode on Win32.]) + +AH_TEMPLATE([CYGWIN32], [GNU Win32 environement]) + + +dnl ACE internals +AH_TEMPLATE([ACE_DEFAULT_BASE_ADDR],[]) +AH_TEMPLATE([ACE_DEFAULT_BASE_ADDRL],[]) +AH_TEMPLATE([ACE_DEFAULT_CLOSE_ALL_HANDLES],[]) +AH_TEMPLATE([ACE_DEFAULT_MAX_SOCKET_BUFSIZ],[]) +AH_TEMPLATE([ACE_DEFAULT_SELECT_REACTOR_SIZE],[The default number of handles the select()-based reactor should handle]) +AH_TEMPLATE([ACE_MALLOC_ALIGN],[]) +AH_TEMPLATE([ACE_MAP_PRIVATE],[]) +AH_TEMPLATE([ACE_THR_PRI_FIFO_DEF],[]) +AH_TEMPLATE([ACE_TIMER_SKEW],[]) +AH_TEMPLATE([IP_ADD_MEMBERSHIP],[]) +AH_TEMPLATE([IP_DROP_MEMBERSHIP],[]) + +AH_TEMPLATE([ACE_LOFF_T_TYPEDEF],[typedef for ACE_LOFF_T]) + +AH_TEMPLATE([__ACE_INLINE__],[Enable ACE inlining]) + +AH_TEMPLATE([ACE_NO_INLINE],[Explicitly disable ACE inlining]) + +AH_TEMPLATE([ACE_COMPILE_TIMEPROBES],[Enable ACE_Timeprobes]) + +AH_TEMPLATE([ACE_HAS_GNU_REPO], +[Enable use of GNU template repositories. GNU C++ w/repo patch +and EGCS only]) + +AH_TEMPLATE([ACE_HAS_AIO_CALLS],[Platform supports Asynchronous IO calls]) + +AH_TEMPLATE([ACE_HAS_ALT_CUSERID], +[Use ACE's alternate cuserid() implementation since a system +cuserid() may not exist, or it is not desirable to use it. The +implementation requires ACE_LACKS_PWD_FUNCTIONS to be undefined and +that the geteuid() system call exists.]) + +AH_TEMPLATE([ACE_DEFAULT_THREAD_KEYS], +[Number of TSS keys, with ACE_HAS_TSS_EMULATION _only_. Defaults to 64.]) + +AH_TEMPLATE([ACE_THREADS_DONT_INHERIT_LOG_MSG], +[Specify this if you don't want threads to inherit parent thread's +ACE_Log_Msg properties.]) + +AH_TEMPLATE([ACE_HAS_PRIOCNTL],[OS has priocntl (2)]) + +AH_TEMPLATE([ACE_HAS_RLIMIT_RESOURCE_ENUM], +[Platform has enum instead of int for first argument to ::{get,set}rlimit (). +The value of this macro is the enum definition, e.g., +enum __rlimit_resource, for Linux glibc 2.0.]) + +AH_TEMPLATE([ACE_HAS_RUSAGE_WHO_ENUM], +[Platform has enum instead of int for first argument to ::getrusage (). The +value of this macro is the enum definition, e.g., enum __rusage_who, for +Linux glibc 2.0.]) + +AH_TEMPLATE([ACE_HAS_STDARG_THR_DEST], +[Platform has void (*)(...) prototype for pthread_key_create() +destructor (e.g., LynxOS).]) + +AH_TEMPLATE([ACE_HAS_STL_MAP_CONFLICT], +[Used when users want to compile ACE with STL and STL map class +conflicts with map struct.]) + +AH_TEMPLATE([ACE_HAS_STL_QUEUE_CONFLICT], +[Used when users want to compile ACE with STL and STL queue class +conflicts with queue struct.]) + +AH_TEMPLATE([ACE_HAS_4_4BSD_SENDMSG_RECVMSG], +[Platform has BSD 4.4 sendmsg()/recvmsg() APIs.]) + +AH_TEMPLATE([ACE_HAS_P_READ_WRITE], +[Platform has pread() and pwrite() support.]) + +AH_TEMPLATE([ACE_HAS_AIX_HI_RES_TIMER], +[Platform has AIX4 ::read_real_time()]) + +AH_TEMPLATE([ACE_HAS_ALLOCA],[Compiler/platform supports alloca().]) + +AH_TEMPLATE([ACE_HAS_ALLOCA_H],[Compiler/platform has ]) + +AH_TEMPLATE([ACE_HAS_AUTOMATIC_INIT_FINI], +[Compiler/platform correctly calls init()/fini() for shared libraries.]) + +AH_TEMPLATE([ACE_HAS_WORKING_EXPLICIT_TEMPLATE_DESTRUCTOR], +[Compiler handles explicit calling of template destructor correctly.]) + +AH_TEMPLATE([ACE_EXPLICIT_TEMPLATE_DESTRUCTOR_TAKES_ARGS], +[Compiler requires template args when explicitly calling template destructor.]) + +AH_TEMPLATE([ACE_HAS_BROKEN_MAP_FAILED], +[Platform doesn't cast MAP_FAILED to a (void *).]) + +AH_TEMPLATE([ACE_HAS_BROKEN_CTIME], +[Compiler/platform uses macro for ctime (e.g., MVS)]) + +AH_TEMPLATE([ACE_HAS_BROKEN_DGRAM_SENDV], +[Platform sendv() does not work properly with datagrams, i.e. it +fails when the iovec size is IOV_MAX.]) + +AH_TEMPLATE([ACE_HAS_BROKEN_MSG_H], +[Platform headers don't support prototypes]) + +AH_TEMPLATE([ACE_HAS_BROKEN_MMAP_H], +[HP/UX does not wrap the mmap(2) header files with extern "C".]) + +AH_TEMPLATE([ACE_HAS_BROKEN_POSIX_TIME], +[Platform defines struct timespec in ]) + +AH_TEMPLATE([ACE_HAS_BROKEN_R_ROUTINES], +[Platform defines ctime_r, asctime_r, rand_r and getpwnam_r as macros]) + +AH_TEMPLATE([ACE_HAS_BROKEN_RANDR], +[OS/compiler's header files are inconsistent with libC definition of +rand_r().]) + +AH_TEMPLATE([ACE_HAS_BROKEN_T_ERROR], +[Compiler/platform has the wrong prototype for t_error(), i.e., +t_error(char *) rather than t_error(const char *).]) + +AH_TEMPLATE([ACE_HAS_BSTRING], +[Platform has (which contains bzero() prototype)]) + +AH_TEMPLATE([ACE_HAS_CHARPTR_DL], +[OS/platform uses char * for dlopen/dlsym args, rather than const char *.]) + +AH_TEMPLATE([ACE_HAS_CHARPTR_SOCKOPT], +[OS/platform uses char * for sockopt, rather than const char *]) + +AH_TEMPLATE([ACE_HAS_CONFLICTING_XTI_MACROS], +[OS header files have some problems with XTI (HP/UX 11).]) + +AH_TEMPLATE([ACE_HAS_CONSISTENT_SIGNAL_PROTOTYPES], +[Prototypes for both signal() and struct sigaction are consistent.]) + +AH_TEMPLATE([ACE_HAS_CONST_CHAR_SWAB], +[Platform has swab(const char*, char*, ssize_t) variant.]) + +AH_TEMPLATE([ACE_HAS_CPLUSPLUS_HEADERS], +[Compiler/platform has correctly prototyped header files.]) + +AH_TEMPLATE([ACE_HAS_DIRENT], +[Platform supports operations on directories via struct dirent, +readdir_r, etc.]) + +AH_TEMPLATE([ACE_HAS_EXCEPTIONS],[Compiler supports C++ exception handling.]) + +AH_TEMPLATE([ACE_HAS_FL],[Platform has Fast-Light (FL) toolkit installed.]) + +AH_TEMPLATE([ACE_HAS_GETPAGESIZE], +[Platform supports getpagesize() call (otherwise, ACE_PAGE_SIZE must +be defined, except on Win32).]) + +AH_TEMPLATE([ACE_HAS_GNU_CSTRING_H], +[Denotes that GNU has cstring.h as standard which redefines memchr()]) + +AH_TEMPLATE([ACE_HAS_INTRINSIC_INTERLOCKED], +[Platform supports the intrinsic interlocked optimizations.]) + +AH_TEMPLATE([ACE_HAS_GPERF], +[The GPERF utility is compiled for this platform]) + +AH_TEMPLATE([ACE_HAS_HANDLE_SET_OPTIMIZED_FOR_SELECT], +[Optimize ACE_Handle_Set::count_bits for select() operations (common case)]) + +AH_TEMPLATE([ACE_HAS_LSEEK64], +[Platform supports lseek64(). This should not be defined if + ACE_HAS_LLSEEK is defined.]) + +AH_TEMPLATE([ACE_HAS_LLSEEK], +[Platform supports llseek(). This should not be defined if + ACE_HAS_LSEEK64 is defined.]) + +AH_TEMPLATE([ACE_HAS_HI_RES_TIMER], +[Compiler/platform supports SunOS high resolution timers]) + +AH_TEMPLATE([ACE_HAS_INLINED_OSCALLS],[ +Inline all the static class OS methods to remove call overhead +Note: This gets defined by OS.h if __ACE_INLINE__ is defined]) + +AH_TEMPLATE([ACE_HAS_IP_MULTICAST],[Platform supports IP multicast]) + +AH_TEMPLATE([ACE_HAS_IPV6],[Platform supports IPv6]) +AH_TEMPLATE([ACE_USES_IPV4_IPV6_MIGRATION], +[Enable IPv6 support on platforms that don't have IPv6 turned on by default]) + +AH_TEMPLATE([ACE_HAS_NEW_NOTHROW], +[Compiler supports new (std::nothrow)]) + +AH_TEMPLATE([ACE_HAS_NONCONST_SWAB], +[Platform has swab(char*, char*, ssize_t) variant.]) + +AH_TEMPLATE([ACE_HAS_NONSTATIC_OBJECT_MANAGER], +[Causes the ACE_Object_Manager instance to be created in + main (int, char *[]), instead of as a static (global) instance.]) + +AH_TEMPLATE([ACE_HAS_THR_KEYDELETE], +[Platform supports thr_keydelete (e.g,. UNIXWARE)]) + +AH_TEMPLATE([ACE_HAS_THR_MINSTACK], +[Platform calls thr_minstack() rather than thr_min_stack() (e.g., Tandem).]) + +AH_TEMPLATE([ACE_HAS_LIMITED_RUSAGE_T], +[The rusage_t structure has only two fields.]) + +AH_TEMPLATE([ACE_HAS_BIG_FD_SET], +[Compiler/platform has "big" fd_set, i.e. large number of bits set + in fd_set passed back from select().]) + +AH_TEMPLATE([ACE_HAS_LONG_MAP_FAILED], +[Platform defines MAP_FAILED as a long constant.]) + +AH_TEMPLATE([ACE_HAS_MALLOC_STATS], [Enabled malloc statistics collection.]) + +AH_TEMPLATE([ACE_USES_OLD_IOSTREAMS], +[Some files, such as ace/streams.h, want to include new style C++ + stream headers. These headers are iomanip, ios, iostream, istream, + ostream, fstream and streambuf. If _all_ of these headers aren't + available, then assume that only iostream.h and fstream.h are + available.]) + +AH_TEMPLATE([ACE_HAS_MSG],[Platform supports recvmsg and sendmsg]) + +AH_TEMPLATE([ACE_HAS_MT_SAFE_MKTIME], +[Platform supports MT safe mktime() call (do any of them?)]) + +AH_TEMPLATE([ACE_HAS_MT_SAFE_SOCKETS], +[Sockets may be called in multi-threaded programs]) + +AH_TEMPLATE([ACE_HAS_NONCONST_GETBY], +[Platform uses non-const char * in calls to gethostbyaddr, + gethostbyname, getservbyname]) + +AH_TEMPLATE([ACE_HAS_NONCONST_MSGSND], +[Platform has a non-const parameter to msgsnd() (e.g., SCO).]) + +AH_TEMPLATE([ACE_HAS_NONCONST_READV], +[Platform omits const qualifier from iovec parameter in readv() prototype.]) + +AH_TEMPLATE([ACE_HAS_NONCONST_SELECT_TIMEVAL], +[Platform's select() uses non-const timeval* (only found on Linux + right now)]) + +AH_TEMPLATE([ACE_HAS_NONCONST_SENDMSG], +[Platform omits const qualifier from msghdr parameter in sendmsg() + prototype.]) + +AH_TEMPLATE([ACE_HAS_NONCONST_SETRLIMIT], +[Platform omits const qualifier from rlimit parameter in setrlimit() + prototype.]) + +AH_TEMPLATE([ACE_HAS_NONCONST_WRITEV], +[Platform omits const qualifier from iovec parameter in writev() prototype.]) + +AH_TEMPLATE([ACE_HAS_OLD_MALLOC], +[Compiler/platform uses old malloc()/free() prototypes (ugh)]) + +AH_TEMPLATE([ACE_HAS_2_PARAM_ASCTIME_R_AND_CTIME_R], +[Uses ctime_r & asctime_r with only two parameters vs. three.]) + +AH_TEMPLATE([ACE_HAS_ONLY_SCHED_OTHER], +[Platform, e.g., Solaris 2.5, only supports SCHED_OTHER POSIX + scheduling policy.]) + +AH_TEMPLATE([ACE_HAS_OPTIMIZED_MESSAGE_QUEUE], +[Use the semaphore implementation of ACE_Message_Queue rather than + the emulated condition variable (NT and VxWorks).]) + +AH_TEMPLATE([ACE_HAS_OSF_TIMOD_H], +[Platform supports the OSF TLI timod STREAMS module]) + +AH_TEMPLATE([ACE_HAS_POLL],[Platform contains ]) + +AH_TEMPLATE([ACE_HAS_POSITION_INDEPENDENT_POINTERS], +[Platform supports "position-independent" features provided by + ACE_Based_Pointer<>.]) + +AH_TEMPLATE([ACE_HAS_POSIX_GETPWNAM_R], +[Platform supports POSIX getpwnam_r() function]) + +AH_TEMPLATE([ACE_HAS_POSIX_NONBLOCK], +[Platform supports POSIX O_NONBLOCK semantics]) + +AH_TEMPLATE([ACE_HAS_POSIX_REALTIME_SIGNALS], +[Platform supports POSIX realtime signals]) + +AH_TEMPLATE([ACE_HAS_POSIX_SEM], +[Platform supports POSIX real-time semaphores (e.g., VxWorks and + Solaris)]) + +AH_TEMPLATE([ACE_HAS_POSIX_SEM_TIMEOUT], +[Platform supports timed POSIX semaphore acquisitions (sem_timedwait()).]) + +AH_TEMPLATE([ACE_DISABLE_POSIX_SEM_TIMEOUT_EMULATION], +[Do not include emulation for timed semaphore acquisitions.]) + +AH_TEMPLATE([ACE_HAS_POSIX_TIME], +[Platform supports the POSIX struct timespec type]) + +AH_TEMPLATE([ACE_HAS_PROC_FS], +[Platform supports the /proc file system and defines tid_t + in ]) + +AH_TEMPLATE([ACE_HAS_PRUSAGE_T],[Platform supports the prusage_t struct]) + +AH_TEMPLATE([ACE_HAS_PTHREADS_UNIX98_EXT], +[Platform has the UNIX98 extensions to Pthreads (rwlocks)]) + +AH_TEMPLATE([ACE_HAS_PTHREAD_PROCESS_ENUM], +[pthread.h declares an enum with PTHREAD_PROCESS_PRIVATE and + PTHREAD_PROCESS_SHARED values]) + +AH_TEMPLATE([ACE_HAS_PURIFY],[Purify'ing. Defined on command line.]) + +AH_TEMPLATE([ACE_HAS_QUANTIFY],[Quantify'ing. Defined on command line.]) + +AH_TEMPLATE([ACE_HAS_RECURSIVE_MUTEXES], +[Mutexes are inherently recursive (e.g., Win32) ]) + +AH_TEMPLATE([ACE_HAS_RECURSIVE_THR_EXIT_SEMANTICS], +[Platform will recurse infinitely on thread exits from TSS cleanup + routines (e.g., AIX)]) + +AH_TEMPLATE([ACE_HAS_SIGACTION_CONSTP2], +[Platform's sigaction() function takes const sigaction* as 2nd parameter]) + +AH_TEMPLATE([ACE_HAS_REENTRANT_FUNCTIONS], +[Platform supports reentrant functions (i.e., all the POSIX *_r + functions).]) + +AH_TEMPLATE([ACE_HAS_X86_STAT_MACROS], +[Solaris for intel uses macros for fstat() and stat(), these are + wrappers for _fxstat() and _xstat() uses of the macros. Causes + compile and runtime problems.]) + +AH_TEMPLATE([ACE_HAS_XPG4_MULTIBYTE_CHAR], +[Platform has support for multi-byte character support compliant + with the XPG4 Worldwide Portability Interface wide-character + classification.]) + +AH_TEMPLATE([ACE_LACKS_AUTO_MMAP_REPLACEMENT], +[No system support for replacing any previous mappings.]) + +AH_TEMPLATE([ACE_LACKS_AUTO_PTR], +[Platform lacks support for the standard C++ auto_ptr class]) + +AH_TEMPLATE([ACE_AUTO_PTR_LACKS_RESET], +[Compiler/platform standard C++ auto_ptr implementation lacks + reset() method]) + +AH_TEMPLATE([ACE_LACKS_READDIR_R],[Platform lacks readdir_r()]) + +AH_TEMPLATE([ACE_LACKS_INLINE_FUNCTIONS], +[Platform can't handle "inline" keyword correctly.]) + +AH_TEMPLATE([ACE_LACKS_IOSTREAM_TOTALLY], +[iostreams are not supported adequately on the given platform.]) + +AH_TEMPLATE([ACE_LACKS_NETDB_REENTRANT_FUNCTIONS], +[Platform does not support reentrant netdb functions + (getprotobyname_r, getprotobynumber_r, gethostbyaddr_r, + gethostbyname_r, getservbyname_r).]) + +AH_TEMPLATE([ACE_HAS_REGEX], +[Platform supports the POSIX regular expression library]) + +AH_TEMPLATE([ACE_HAS_SEMUN], +[Compiler/platform defines a union semun for SysV shared memory ]) + +AH_TEMPLATE([ACE_HAS_SHM_OPEN],[Platform has shm_open()]) +AH_TEMPLATE([ACE_SHM_OPEN_REQUIRES_ONE_SLASH],[shm_open() requires a leading slash in name]) + +AH_TEMPLATE([ACE_HAS_SIGISMEMBER_BUG], +[Platform has bug with sigismember() (HP/UX 11).]) + +AH_TEMPLATE([ACE_HAS_SIG_MACROS], +[Platform/compiler has macros for sig{empty,fill,add,del}set (e.g., + SCO and FreeBSD)]) + +AH_TEMPLATE([ACE_HAS_SIGNAL_OBJECT_AND_WAIT], +[Platform supports the Win32 SignalObjectAndWait() function (WinNT + 4.0 and beyond).]) + +AH_TEMPLATE([ACE_HAS_SIG_C_FUNC], +[Compiler requires extern "C" functions for signals.]) + +AH_TEMPLATE([ACE_HAS_SIZET_SOCKET_LEN], +[OS/compiler uses size_t * rather than int * for socket lengths]) + +AH_TEMPLATE([ACE_HAS_SOCKADDR_MSG_NAME], +[Platform requires (struct sockaddr *) for msg_name field of + struct msghdr.]) + +AH_TEMPLATE([ACE_HAS_THR_YIELD],[Platform has thr_yield()]) + +AH_TEMPLATE([ACE_HAS_STANDARD_CPP_LIBRARY], +[Platform/compiler supports Standard C++ Library]) + +AH_TEMPLATE([ACE_HAS_STRBUF_T],[Compiler/platform supports struct strbuf]) + +AH_TEMPLATE([ACE_HAS_STREAMS],[Platform supports STREAMS]) + +AH_TEMPLATE([ACE_HAS_STREAM_PIPES],[Platform supports STREAM pipes]) + +AH_TEMPLATE([ACE_LACKS_STROPTS_H],[Platform lacks stropts.h]) + +AH_TEMPLATE([ACE_HAS_STRING_CLASS], +[Platform/Compiler supports a String class (e.g., GNU or Win32).]) + +AH_TEMPLATE([ACE_HAS_STRINGS], +[Platform has (which contains bzero() prototype)]) + +AH_TEMPLATE([ACE_HAS_STRUCT_NETDB_DATA], +[Compiler/platform has strange hostent API for socket *_r() calls]) + +AH_TEMPLATE([ACE_HAS_SVR4_DYNAMIC_LINKING], +[Compiler/platform supports SVR4 dynamic linking semantics]) + +AH_TEMPLATE([ACE_HAS_SVR4_GETTIMEOFDAY], +[Compiler/platform supports SVR4 gettimeofday() prototype but + doesn't have a prototype]) + +AH_TEMPLATE([ACE_HAS_SVR4_SIGNAL_T], +[Compiler/platform supports SVR4 signal typedef.]) + +AH_TEMPLATE([ACE_HAS_SVR4_TLI], +[Compiler/platform supports SVR4 TLI (in particular, T_GETNAME stuff).]) + +AH_TEMPLATE([ACE_HAS_SYSINFO], +[Platform supports system configuration information.]) + +AH_TEMPLATE([ACE_HAS_SYSV_IPC], +[Platform supports System V IPC (most versions of UNIX, but not Win32)]) + +AH_TEMPLATE([ACE_HAS_SYS_ERRLIST], +[Platform/compiler supports _sys_errlist symbol]) + +AH_TEMPLATE([ACE_HAS_SYS_SIGLIST], +[Compiler/platform supports _sys_siglist array]) + +AH_TEMPLATE([ACE_HAS_SYS_XTI_H],[Platform provides header]) + +AH_TEMPLATE([ACE_HAS_TEMPLATE_TYPEDEFS], +[Compiler implements templates that support typedefs inside of + classes used as formal arguments to a template class.]) + +AH_TEMPLATE([ACE_HAS_THREADS],[Platform supports threads.]) + +AH_TEMPLATE([ACE_HAS_THREAD_SAFE_ACCEPT], +[Platform allows multiple threads to call accept() on the same port + (e.g., WinNT).]) + +AH_TEMPLATE([ACE_HAS_THREAD_SELF], +[Platform has thread_self() rather than pthread_self() (e.g., + DCETHREADS and AIX)]) + +AH_TEMPLATE([ACE_HAS_THREAD_SPECIFIC_STORAGE], +[Compiler/platform has thread-specific storage]) + +AH_TEMPLATE([ACE_HAS_THR_C_DEST], +[The pthread_keycreate() routine *must* take extern C functions.]) + +AH_TEMPLATE([ACE_HAS_THR_C_FUNC], +[The pthread_create() routine *must* take extern C functions.]) + +AH_TEMPLATE([ACE_HAS_TIMEZONE_GETTIMEOFDAY], +[Platform/compiler supports timezone * as second parameter to + gettimeofday() and has a prototype.]) + +AH_TEMPLATE([ACE_HAS_TIMOD_H], +[Platform supports TLI timod STREAMS module]) + +AH_TEMPLATE([ACE_HAS_TIUSER_H],[Platform supports TLI tiuser header]) + +AH_TEMPLATE([ACE_HAS_TIUSER_H_BROKEN_EXTERN_C], +[Platform does not protect with extern "C"]) + +AH_TEMPLATE([ACE_HAS_TLI], +[Platform supports TLI. Also see ACE_TLI_TCP_DEVICE.]) + +AH_TEMPLATE([ACE_HAS_TLI_PROTOTYPES], +[Platform provides TLI function prototypes]) + +AH_TEMPLATE([ACE_HAS_TSS_EMULATION], +[ACE provides TSS emulation. See also ACE_DEFAULT_THREAD_KEYS.]) + +AH_TEMPLATE([ACE_HAS_UCONTEXT_T], +[Platform supports ucontext_t (which is used in the extended signal API).]) + +AH_TEMPLATE([ACE_HAS_UNIXWARE_SVR4_SIGNAL_T], +[Has inconsistent SVR4 signal stuff, but not the same as the other + platforms]) + +AH_TEMPLATE([ACE_HAS_WCHAR],[Platform/compiler supports wchar_t]) +AH_TEMPLATE([ACE_USES_WCHAR],[ACE is built to use wide characters internally]) + +AH_TEMPLATE([ACE_HAS_VERBOSE_NOTSUP], +[Prints out console message in ACE_NOTSUP. Useful for tracking down + origin of ACE_NOTSUP.]) + +AH_TEMPLATE([ACE_HAS_VOIDPTR_GETTIMEOFDAY], +[Platform/compiler supports void * as second parameter to + gettimeofday() and has a prototype.]) + +AH_TEMPLATE([ACE_HAS_VOIDPTR_MMAP],[Platform requires void * for mmap().]) + +AH_TEMPLATE([ACE_HAS_VOIDPTR_SOCKOPT], +[OS/compiler uses void * arg 4 setsockopt() rather than const char *]) + +AH_TEMPLATE([ACE_HAS_XLI],[Platform has the XLI version of TLI]) + +AH_TEMPLATE([ACE_HAS_XT],[Platform has Xt Intrinsics Toolkit]) + +AH_TEMPLATE([ACE_LACKS_MOTIF], +[Platform does not have Motif X toolkit available]) + +AH_TEMPLATE([ACE_HAS_XTI], +[Platform has XTI (X/Open-standardized superset of TLI). Implies + ACE_HAS_TLI but uses a different header file.]) + +AH_TEMPLATE([ACE_LACKS_ACE_IOSTREAM], +[Platform can not build ace/IOStream{,_T}.cpp. This does not + necessarily mean that the platform does not support iostreams.]) + +AH_TEMPLATE([ACE_LACKS_ACE_CODECS], +[Do not compile support for the "Codecs" ACE features.]) + +AH_TEMPLATE([ACE_LACKS_ACE_OTHER], +[Do not compile support for the "other" ACE features, such as CORBA + handling, name services, and QoS.]) + +AH_TEMPLATE([ACE_LACKS_ACE_SVCCONF], +[Do not compile support for the ACE Service Configurator.]) + +AH_TEMPLATE([ACE_LACKS_ACE_TOKEN], +[Do not compile support for the ACE Token feature.]) + +AH_TEMPLATE([ACE_LACKS_ACE_UUID], +[Do not compile support for the ACE UUID feature.]) + +AH_TEMPLATE([ACE_LACKS_COND_T], +[Platform lacks condition variables (e.g., Win32 and VxWorks)]) + +AH_TEMPLATE([ACE_LACKS_COND_TIMEDWAIT_RESET], +[pthread_cond_timedwait does *not* reset the time argument when + the lock is acquired.]) + +AH_TEMPLATE([ACE_LACKS_CONDATTR_PSHARED], +[Platform has no implementation of pthread_condattr_setpshared(), even + though it supports pthreads!]) + +AH_TEMPLATE([ACE_LACKS_CONST_STRBUF_PTR], +[Platform uses struct strbuf * rather than const struct strbuf * + (e.g., HP/UX 10.x)]) + +AH_TEMPLATE([ACE_LACKS_CONST_TIMESPEC_PTR], +[Platform forgot const in cond_timewait (e.g., HP/UX).]) + +AH_TEMPLATE([ACE_LACKS_EXEC], +[Platform lacks the exec() family of system calls (e.g., Win32, + VxWorks, Chorus)]) + +AH_TEMPLATE([ACE_LACKS_FILELOCKS],[Platform lacks file locking mechanism]) + +AH_TEMPLATE([ACE_LACKS_GETSERVBYNAME], +[Platforms lacks getservbyname() (e.g., VxWorks and Chorus).]) + +AH_TEMPLATE([ACE_LACKS_IOSTREAM_FX], +[iostream header does not declare ipfx (), opfx (), etc.]) + +AH_TEMPLATE([ACE_LACKS_LINEBUFFERED_STREAMBUF], +[Platform lacks streambuf "linebuffered ()".]) + +AH_TEMPLATE([ACE_LACKS_LONGLONG_T], +[Compiler/platform does not support the unsigned long long datatype.]) + +AH_TEMPLATE([ACE_LACKS_U_LONGLONG_T], +[Platform does not have u_longlong_t typedef]) + +AH_TEMPLATE([ACE_LACKS_MMAP], +[The platform doesn't have mmap(2) (e.g., SCO UNIX).]) + +AH_TEMPLATE([ACE_LACKS_MODE_MASKS], +[Platform/compiler doesn't have open() mode masks.]) + +AH_TEMPLATE([ACE_LACKS_MSG_ACCRIGHTS], +[Platform defines ACE_HAS_MSG, but lacks msg_accrights{len}.]) + +AH_TEMPLATE([ACE_LACKS_MUTEXATTR_PSHARED], +[Platform lacks pthread_mutexattr_setpshared().]) + +AH_TEMPLATE([ACE_LACKS_NULL_PTHREAD_STATUS], +[OS requires non-null status pointer for pthread_join ()]) + +AH_TEMPLATE([ACE_HAS_MUTEX_TIMEOUTS], +[Compiler supports timed mutex acquisitions (e.g. pthread_mutex_timedlock()).]) + +AH_TEMPLATE([ACE_LACKS_NAMED_POSIX_SEM], +[Platform lacks named POSIX semaphores (e.g., Chorus)]) + +AH_TEMPLATE([ACE_LACKS_STRPTIME], +[Platform lacks native strptime() implementation.]) + +AH_TEMPLATE([ACE_LACKS_RLIMIT], +[Platform/compiler lacks {get,set}rlimit() function (e.g., VxWorks, + Chorus, and SCO UNIX)]) + +AH_TEMPLATE([ACE_LACKS_RWLOCKATTR_PSHARED], +[Platform lacks pthread_rwlockattr_setpshared().]) + +AH_TEMPLATE([ACE_LACKS_PLACEMENT_OPERATOR_NEW], +[Compiler doesn't support placement operator new(size_t, void *).]) + +AH_TEMPLATE([ACE_LACKS_PLACEMENT_OPERATOR_DELETE], +[Compiler doesn't support placement operator delete(void *, void *).]) + +AH_TEMPLATE([ACE_LACKS_PRAGMA_ONCE], +[Compiler complains about use of obsolete "pragma once"]) + +AH_TEMPLATE([ACE_LACKS_PTHREAD_CANCEL],[Platform lacks pthread_cancel()]) + +AH_TEMPLATE([ACE_LACKS_PWD_FUNCTIONS], +[Platform lacks, getpwnam(), etc.]) + +AH_TEMPLATE([ACE_LACKS_PWD_REENTRANT_FUNCTIONS], +[Platform lacks getpwnam_r() methods (e.g., SGI 6.2).]) + +AH_TEMPLATE([ACE_LACKS_RWLOCK_T],[Platform lacks readers/writer locks.]) + +AH_TEMPLATE([ACE_LACKS_SEMBUF_T], +[Platform lacks struct sembuf (e.g., Win32 and VxWorks)]) + +AH_TEMPLATE([ACE_LACKS_SETDETACH], +[Platform lacks pthread_attr_setdetachstate() (e.g., HP/UX 10.x)]) + +AH_TEMPLATE([ACE_LACKS_SETSCHED], +[Platform lacks pthread_attr_setsched() (e.g. MVS)]) + +AH_TEMPLATE([ACE_LACKS_SIGACTION], +[Platform lacks struct sigaction (e.g., Win32 and Chorus)]) + +AH_TEMPLATE([ACE_LACKS_SIGNED_CHAR], +[Platform lacks "signed char" type (broken!)]) + +AH_TEMPLATE([ACE_LACKS_SIGSET], +[Platform lacks signal sets (e.g., Chorus and Win32)]) + +AH_TEMPLATE([ACE_LACKS_STRUCT_DIR], +[Platform lacks dirent structure.]) + +AH_TEMPLATE([ACE_LACKS_SYS_MSG_H], +[Platform lacks sys/msg.h (e.g., Chorus and VxWorks)]) + +AH_TEMPLATE([ACE_LACKS_SYSV_MSQ_PROTOS], +[Platform lacks SYSV message queue prototypes]) + +AH_TEMPLATE([ACE_LACKS_SI_ADDR], +[Platform lacks the si_addr field of siginfo_t (e.g., VxWorks and + HP/UX 10.x)]) + +AH_TEMPLATE([ACE_LACKS_SYSV_SHMEM], +[Platform lacks System V shared memory (e.g., Win32 and VxWorks)]) + +AH_TEMPLATE([ACE_LACKS_SOCKET_BUFSIZ], +[Platform doesn't support SO_SNDBUF/SO_RCVBUF (used in TAO)]) + +AH_TEMPLATE([ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES], +[Compiler doesn't support static data member templates]) + +AH_TEMPLATE([ACE_LACKS_STRRECVFD],[Platform doesn't define struct strrecvfd.]) + +AH_TEMPLATE([ACE_LACKS_T_ERRNO],[Header files lack t_errno for TLI]) + +AH_TEMPLATE([ACE_LACKS_TCP_NODELAY],[OS does not support TCP_NODELAY]) + +AH_TEMPLATE([ACE_LACKS_THREAD_PROCESS_SCOPING], +[Platform lacks pthread_attr_setscope()]) + +AH_TEMPLATE([ACE_LACKS_TIMESPEC_T], +[Platform does not define timepec_t as a typedef for struct timespec.]) + +AH_TEMPLATE([ACE_LACKS_STRTOK_R_PROTOTYPE], +[Platform/compiler lacks the strtok_r() prototype]) + +AH_TEMPLATE([ACE_LACKS_LSEEK64_PROTOTYPE], +[Platform/compiler lacks the lseek64() prototype. This should not + be defined if ACE_LACKS_LLSEEK_PROTOTYPE is defined.]) + +AH_TEMPLATE([ACE_LACKS_LLSEEK_PROTOTYPE], +[Platform/compiler lacks the llseek() prototype. This should not + be defined if ACE_LACKS_LSEEK64_PROTOTYPE is defined.]) + +AH_TEMPLATE([ACE_LACKS_PREAD_PROTOTYPE], +[Platform/compiler lacks the pread() and pwrite() prototypes]) + +AH_TEMPLATE([ACE_LACKS_CHAR_RIGHT_SHIFTS], +[Compiler does not have any istream operator>> for chars, u_chars, or + signed chars.]) + +AH_TEMPLATE([ACE_LACKS_CHAR_STAR_RIGHT_SHIFTS], +[Compiler does not have operator>> (istream &, u_char *) or + operator>> (istream &, signed char *)]) + +AH_TEMPLATE([ACE_LACKS_NUMERIC_LIMITS],[Platform lacks std::numeric_limits<>]) + +AH_TEMPLATE([ACE_LACKS_UNIX_DOMAIN_SOCKETS], +[ACE platform has no UNIX domain sockets]) + +AH_TEMPLATE([ACE_LACKS_UNIX_SIGNALS], +[Platform lacks full signal support (e.g., Win32 and Chorus).]) + +AH_TEMPLATE([ACE_LACKS_UTSNAME_T], +[Platform lacks struct utsname (e.g., Win32 and VxWorks)]) + +AH_TEMPLATE([ACE_MAIN], +[Renames "main (int, char *[])", for platforms such as g++/VxWorks + that don't allow main. Requires the use of + ACE_HAS_NONSTATIC_OBJECT_MANAGER.]) + +AH_TEMPLATE([ACE_MT_SAFE],[Compile using multi-thread libraries]) + +AH_TEMPLATE([ACE_NDEBUG],[Turns off debugging features]) + +AH_TEMPLATE([ACE_NEEDS_DEV_IO_CONVERSION], +[Necessary with some compilers to pass ACE_TTY_IO as parameter to + DEV_Connector.]) + +AH_TEMPLATE([ACE_NEEDS_HUGE_THREAD_STACKSIZE], +[Required by platforms with small default stacks.]) + +AH_TEMPLATE([ACE_NEEDS_LWP_PRIO_SET], +[OS has LWPs, and when the priority of a bound thread is set, then + the LWP priority must be set also.]) + +AH_TEMPLATE([ACE_NEEDS_SCHED_H], +[Platform needs to #include to get thread scheduling defs.]) + +AH_TEMPLATE([ACE_NEW_THROWS_EXCEPTIONS], +[Compiler's 'new' throws exception on failure (ANSI C++ behavior).]) + +AH_TEMPLATE([ACE_NLOGGING], +[Turns off the LM_DEBUG and LM_ERROR logging macros...]) + +AH_TEMPLATE([ACE_NTRACE],[Turns off the tracing feature.]) + +AH_TEMPLATE([ACE_PAGE_SIZE], +[Defines the page size of the system (not used on Win32 or with + ACE_HAS_GETPAGESIZE).]) + +AH_TEMPLATE([ACE_REDEFINES_XTI_FUNCTIONS], +[Platform redefines the t_... names (UnixWare)]) + +AH_TEMPLATE([ACE_TEMPLATES_REQUIRE_PRAGMA], +[Compiler's template mechanism must use a pragma. This is used for + AIX's C++ compiler.]) + +AH_TEMPLATE([ACE_TEMPLATES_REQUIRE_SOURCE], +[Compiler's template mechanim must see source code (i.e., .cpp + files). This is used for GNU G++.]) + +AH_TEMPLATE([ACE_HAS_ICMP_SUPPORT], +[Defined to 1 if platform supports ICMP over raw sockets]) + +AH_TEMPLATE([ACE_NEEDS_FUNC_DEFINITIONS], +[Compiler requires a definition for a "hidden" function, e.g., a + private, unimplemented copy constructor or assignment operator. + The SGI C++ compiler needs this, in template classes, with + ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA.]) + +AH_TEMPLATE([ACE_TLI_TCP_DEVICE], +[Device the platform uses for TCP on TLI. Only needed if not + /dev/tcp.]) + +AH_TEMPLATE([ACE_USE_POLL], +[The OS/platform supports the poll() event demultiplexor]) + +AH_TEMPLATE([ACE_HAS_EVENT_POLL],[Platform (Linux) supports event poll + interface.]) + +AH_TEMPLATE([ACE_HAS_DEV_POLL],[Platform supports /dev/poll character + device.]) + +AH_TEMPLATE([ACE_USES_ASM_SYMBOL_IN_DLSYM], +[Platform uses assembly symbols instead of C symbols in dlsym()]) + +AH_TEMPLATE([ACE_USES_STD_NAMESPACE_FOR_STDCPP_LIB], +[Platform has its standard C++ library in the namespace std.]) + +dnl DSO/DLL export macros. +AH_TEMPLATE([ACE_HAS_CUSTOM_EXPORT_MACROS], +[Platform defines custom DSO/DLL symbol export macros.]) + +AH_TEMPLATE([ACE_Proper_Export_Flag], +[Flag that denotes the symbol should be exported from the DSO/DLL.]) + +AH_TEMPLATE([ACE_Proper_Import_Flag], +[Flag that denotes the symbol should be imported from the DSO/DLL.]) + +dnl ACE_EXPORT_SINGLETON_DECLARATION(T) +dnl ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +dnl ACE_IMPORT_SINGLETON_DECLARATION(T) +dnl ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) + +]) dnl End ACE_PREP_CONFIG_HEADER diff --git a/dep/ACE_wrappers/m4/pkg.m4 b/dep/ACE_wrappers/m4/pkg.m4 new file mode 100644 index 00000000000..cbb46dbf832 --- /dev/null +++ b/dep/ACE_wrappers/m4/pkg.m4 @@ -0,0 +1,156 @@ +# pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*- +# +# Copyright © 2004 Scott James Remnant . +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# PKG_PROG_PKG_CONFIG([MIN-VERSION]) +# ---------------------------------- +AC_DEFUN([PKG_PROG_PKG_CONFIG], +[m4_pattern_forbid([^_?PKG_[A-Z_]+$]) +m4_pattern_allow([^PKG_CONFIG(_PATH)?$]) +AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])dnl +if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then + AC_PATH_TOOL([PKG_CONFIG], [pkg-config]) +fi +if test -n "$PKG_CONFIG"; then + _pkg_min_version=m4_default([$1], [0.9.0]) + AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version]) + if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then + AC_MSG_RESULT([yes]) + else + AC_MSG_RESULT([no]) + PKG_CONFIG="" + fi + +fi[]dnl +])# PKG_PROG_PKG_CONFIG + +# PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) +# +# Check to see whether a particular set of modules exists. Similar +# to PKG_CHECK_MODULES(), but does not set variables or print errors. +# +# +# Similar to PKG_CHECK_MODULES, make sure that the first instance of +# this or PKG_CHECK_MODULES is called, or make sure to call +# PKG_CHECK_EXISTS manually +# -------------------------------------------------------------- +AC_DEFUN([PKG_CHECK_EXISTS], +[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl +if test -n "$PKG_CONFIG" && \ + AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then + m4_ifval([$2], [$2], [:]) +m4_ifvaln([$3], [else + $3])dnl +fi]) + + +# _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES]) +# --------------------------------------------- +m4_define([_PKG_CONFIG], +[if test -n "$PKG_CONFIG"; then + if test -n "$$1"; then + pkg_cv_[]$1="$$1" + else + PKG_CHECK_EXISTS([$3], + [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null`], + [pkg_failed=yes]) + fi +else + pkg_failed=untried +fi[]dnl +])# _PKG_CONFIG + +# _PKG_SHORT_ERRORS_SUPPORTED +# ----------------------------- +AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED], +[AC_REQUIRE([PKG_PROG_PKG_CONFIG]) +if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then + _pkg_short_errors_supported=yes +else + _pkg_short_errors_supported=no +fi[]dnl +])# _PKG_SHORT_ERRORS_SUPPORTED + + +# PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND], +# [ACTION-IF-NOT-FOUND]) +# +# +# Note that if there is a possibility the first call to +# PKG_CHECK_MODULES might not happen, you should be sure to include an +# explicit call to PKG_PROG_PKG_CONFIG in your configure.ac +# +# +# -------------------------------------------------------------- +AC_DEFUN([PKG_CHECK_MODULES], +[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl +AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl +AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl + +pkg_failed=no +AC_MSG_CHECKING([for $1]) + +_PKG_CONFIG([$1][_CFLAGS], [cflags], [$2]) +_PKG_CONFIG([$1][_LIBS], [libs], [$2]) + +m4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS +and $1[]_LIBS to avoid the need to call pkg-config. +See the pkg-config man page for more details.]) + +if test $pkg_failed = yes; then + _PKG_SHORT_ERRORS_SUPPORTED + if test $_pkg_short_errors_supported = yes; then + $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --errors-to-stdout --print-errors "$2"` + else + $1[]_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "$2"` + fi + # Put the nasty error message in config.log where it belongs + echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD + + ifelse([$4], , [AC_MSG_ERROR(dnl +[Package requirements ($2) were not met: + +$$1_PKG_ERRORS + +Consider adjusting the PKG_CONFIG_PATH environment variable if you +installed software in a non-standard prefix. + +_PKG_TEXT +])], + [$4]) +elif test $pkg_failed = untried; then + ifelse([$4], , [AC_MSG_FAILURE(dnl +[The pkg-config script could not be found or is too old. Make sure it +is in your PATH or set the PKG_CONFIG environment variable to the full +path to pkg-config. + +_PKG_TEXT + +To get pkg-config, see .])], + [$4]) +else + $1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS + $1[]_LIBS=$pkg_cv_[]$1[]_LIBS + AC_MSG_RESULT([yes]) + ifelse([$3], , :, [$3]) +fi[]dnl +])# PKG_CHECK_MODULES diff --git a/dep/ACE_wrappers/m4/platform.m4 b/dep/ACE_wrappers/m4/platform.m4 new file mode 100644 index 00000000000..f5f1f04b626 --- /dev/null +++ b/dep/ACE_wrappers/m4/platform.m4 @@ -0,0 +1,545 @@ +dnl ------------------------------------------------------------------------- +dnl $Id: platform.m4 82266 2008-07-08 16:09:00Z jtc $ +dnl +dnl platform.m4 +dnl +dnl ACE M4 include file which contains ACE specific M4 macros +dnl that set/determine which known platform specific C++ macros +dnl to define. +dnl +dnl ------------------------------------------------------------------------- + +dnl Copyright (C) 1998, 1999, 2000, 2002, 2003 Ossama Othman +dnl +dnl All Rights Reserved +dnl +dnl This library is free software; you can redistribute it and/or +dnl modify it under the current ACE distribution terms. +dnl +dnl This library is distributed in the hope that it will be useful, +dnl but WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +dnl Check for thread related libraries and compiler flags +dnl Usage: ACE_SET_PLATFORM_MACROS +AC_DEFUN([ACE_SET_PLATFORM_MACROS], +[ +dnl Begin ACE_SET_PLATFORM_MACROS + +dnl At some point the below platform specific settings should be +dnl automated as much as possible! We set things manually just to get +dnl things going with the auto{conf,make}/libtool integration into the +dnl ACE source tree. + +dnl Platform specific flags +case "$host" in + *aix3*) + AC_DEFINE([AIX]) + AC_DEFINE([ACE_DEFAULT_BASE_ADDR], [((char *) 0x80000000)]) + ;; + *aix4.1*) + AC_DEFINE([AIX]) + dnl Use BSD 4.4 socket definitions for pre-AIX 4.2. The _BSD + dnl setting also controls the data type used for waitpid(), + dnl wait(), and wait3(). + ACE_CPPFLAGS="$ACE_CPPFLAGS -D_BSD=44" + dnl pre-AIX 4.3 requires _BSD_INCLUDES + ACE_CPPFLAGS="$ACE_CPPFLAGS -D_BSD_INCLUDES" + AC_DEFINE([ACE_DEFAULT_BASE_ADDR], [((char *) 0x80000000)]) + ;; + *aix4.2*) + AC_DEFINE([AIX]) + dnl pre-AIX 4.3 requires _BSD_INCLUDES + ACE_CPPFLAGS="$ACE_CPPFLAGS -D_BSD_INCLUDES" + AC_DEFINE([ACE_DEFAULT_BASE_ADDR], [((char *) 0x80000000)]) + AC_DEFINE([ACE_TLI_TCP_DEVICE], ["/dev/xti/tcp"]) + ;; + *aix*) + AC_DEFINE([AIX]) + ;; +dnl /* Cray specific configuration parameters */ +dnl /* +dnl * The following predefined macros are used within ACE ifdefs. +dnl * These are defined when using the Cray compilers. _CRAYMPP +dnl * is defined, for example, if you are running on a Cray T3E +dnl * massively parallel machine. Moreover, in the case of the T3E, +dnl * _CRAYT3E will be defined. This is used to determine the +dnl * ACE_SIZEOF defines for primitive types. +dnl * +dnl * _UNICOS is defined as either the major version of UNICOS being run, +dnl * e.g. 9 or 10 on the vector machines (e.g. C90, T90, J90, YMP, ...) +dnl * or the major+minor+level UNICOS/mk version, e.g. 2.0.3 => 203, +dnl * being run on an MPP machine. +dnl * +dnl * Summary: +dnl * +dnl * _CRAYMPP (defined only if running on MPP machine, e.g. T3E, UNICOS/mk) +dnl * _CRAYT3E (defined specifically if compiling on a Cray T3E) +dnl * _UNICOS (defined if running UNICOS or UNICOS/mk) +dnl * +dnl * Tested on UNICOS 10.0.0.2, UNICOS/mk 2.0.3.10 +dnl * +dnl * Contributed by Doug Anderson +dnl */ + t3e-cray-unicosmk*) + ACE_CPPFLAGS="$ACE_CPPFLAGS -D_CRAYMPP -D_CRAYT3E -D_UNICOS" + ;; + t3e-cray*) + ACE_CPPFLAGS="$ACE_CPPFLAGS -D_CRAYT3E -D_UNICOS" + ;; + *cray-unicos*) + ACE_CPPFLAGS="$ACE_CPPFLAGS -D_UNICOS" + ;; + *hpux9*) + AC_DEFINE([HPUX]) + ;; + *hpux10*) + AC_DEFINE([HPUX]) + AC_DEFINE([HPUX_10]) + dnl _HPUX_SOURCE : Enable HP-UX specific features in platform headers + ACE_CPPFLAGS="$ACE_CPPFLAGS -D_HPUX_SOURCE" + AC_DEFINE([ACE_DEFAULT_BASE_ADDR], [((char *) 0x80000000)]) + AC_DEFINE([ACE_TLI_TCP_DEVICE], ["/dev/inet_cots"]) + ;; + *hpux11*) + AC_DEFINE([HPUX]) + AC_DEFINE([HPUX_11]) + AC_EGREP_CPP([ACE_ON_64BIT_HP], + [ +#ifdef __LP64__ + ACE_ON_64BIT_HP +#endif + ], + [ + AC_DEFINE([ACE_DEFAULT_BASE_ADDR], [((char *) 0x0000001100000000)]) + AC_DEFINE([ACE_DEFAULT_BASE_ADDRL], [((char *) 0x0000001100000000)]) + ], + [ + AC_DEFINE([ACE_DEFAULT_BASE_ADDR], [((char *) 0x80000000)]) + ]) + AC_DEFINE([ACE_TIMER_SKEW], [(1000 * 10)]) + ;; + *irix5.2*) + AC_DEFINE([IRIX5]) + ;; + *irix5.3*) + AC_DEFINE([IRIX5]) + if test "$GXX" = no; then + ACE_CPPFLAGS="$ACE_CPPFLAGS -D_BSD_TYPES" + fi + ;; + *irix6*) + AC_DEFINE([IRIX6]) + AC_DEFINE([ACE_DEFAULT_BASE_ADDR], [((char *) (1024U * 1024 * 1024))]) + AC_DEFINE([ACE_TIMER_SKEW], [(1000 * 10)]) + dnl _MODERN_C_ : Enable modern features in SGI C++ compiler + ACE_CPPFLAGS="$ACE_CPPFLAGS -D_SGI_MP_SOURCE -D_MODERN_C_" + + case "$host" in + *irix6.2*) + dnl Recent versions of IRIX do not appear to require this macro. + if test "$ace_user_enable_threads" = yes; then + AC_DEFINE([ACE_HAS_IRIX62_THREADS]) + fi + ;; + esac + ;; + *linux*) + AC_DEFINE([ACE_DEFAULT_MAX_SOCKET_BUFSIZ], [65535]) + AC_DEFINE([ACE_DEFAULT_BASE_ADDR], [((char *) 0x80000000)]) + AC_DEFINE([ACE_HAS_BIG_FD_SET]) dnl FIXME: We need a test for this! + AC_DEFINE([ACE_TIMER_SKEW], [(1000 * 10)]) + dnl Does this box have NPTL? + NPTL=`getconf GNU_LIBPTHREAD_VERSION | $AWK '{print [$][1]}' -` + if test "$NPTL" != NPTL; then + ACE_CPPFLAGS="$ACE_CPPFLAGS -DACE_LACKS_LINUX_NPTL" + fi + ;; + *lynxos*) + ACE_CPPFLAGS="$ACE_CPPFLAGS -D_POSIX_THREADS_CALLS" + AC_DEFINE([__NO_INCLUDE_WARN__]) + AC_DEFINE([ACE_MALLOC_ALIGN], [8]) + AC_DEFINE([ACE_MAP_PRIVATE], [ACE_MAP_SHARED]) + AC_DEFINE([ACE_HAS_LYNXOS_SIGNALS]) + AC_DEFINE([ACE_TIMER_SKEW], [(1000 * 10)]) + ;; + *mvs*) + ACE_CPPFLAGS="$ACE_CPPFLAGS -D_ALL_SOURCE" + ;; + *osf3.2*) + AC_EGREP_CPP([ACE_DEC_CXX], + [ +#if defined(__DECCXX) + ACE_DEC_CXX +#endif + ], + [ + AC_DEFINE([DEC_CXX]) + ],) + ;; + *osf4.0*) +dnl We need to add checks for g++, DEC C++ and Rational C++ + AC_EGREP_CPP([ACE_DEC_CXX], + [ +#if defined(__DECCXX) + ACE_DEC_CXX +#endif + ], + [ + AC_DEFINE([DEC_CXX]) + ],) +dnl Check for _POSIX_C_SOURCE macro + AC_EGREP_CPP([ACE_ON_DEC_WITH_POS_SRC], + [ + /* Include unistd.h to define _POSIX_C_SOURCE. */ +#ifndef ACE_LACKS_UNISTD_H +# include +#endif + +#if defined(_POSIX_C_SOURCE) && (_POSIX_C_SOURCE >= 199506L) + ACE_ON_DEC_WITH_POS_SRC +#endif + ], + [ + AC_DEFINE([DIGITAL_UNIX]) + ],) + AC_DEFINE([ACE_DEFAULT_BASE_ADDR], [((char *) 0x80000000)]) + AC_DEFINE([ACE_NEEDS_HUGE_THREAD_STACKSIZE], [(1024 * 1024)]) + AC_DEFINE([ACE_TIMER_SKEW], [(1000 * 10)]) + ;; + *sco4.2*) + AC_DEFINE([SCO]) + AC_DEFINE([ACE_DEFAULT_CLOSE_ALL_HANDLES], [0]) + ;; + *sco5*) + ACE_CPPFLAGS="$ACE_CPPFLAGS -D_SVID3" + AC_DEFINE([SCO]) + AC_DEFINE([ACE_DEFAULT_CLOSE_ALL_HANDLES], [0]) + AC_DEFINE([ACE_HAS_BIG_FD_SET]) dnl FIXME: We need a test for this! + ;; + *sunos4*) + AC_DEFINE([ACE_TIMER_SKEW], [(1000 * 10)]) + ;; + *solaris2.4*) + AC_DEFINE([ACE_TIMER_SKEW], [(1000 * 10)]) + AC_DEFINE([ACE_NEEDS_LWP_PRIO_SET]) + ;; + *solaris2.5*) + AC_DEFINE([ACE_MALLOC_ALIGN], [8]) + AC_DEFINE([ACE_TIMER_SKEW], [(1000 * 10)]) + AC_DEFINE([ACE_NEEDS_LWP_PRIO_SET]) + ;; + *solaris2.6*) + AC_DEFINE([ACE_MALLOC_ALIGN], [8]) + AC_DEFINE([ACE_TIMER_SKEW], [(1000 * 10)]) + AC_DEFINE([ACE_NEEDS_LWP_PRIO_SET]) + ;; + *solaris2.7*) + AC_DEFINE([ACE_MALLOC_ALIGN], [8]) + AC_DEFINE([ACE_TIMER_SKEW], [(1000 * 10)]) + AC_DEFINE([ACE_NEEDS_LWP_PRIO_SET]) + ;; + *86*solaris*) + AC_DEFINE([ACE_HAS_X86_STAT_MACROS]) + AC_DEFINE([ACE_TIMER_SKEW], [(1000 * 10)]) + AC_DEFINE([ACE_NEEDS_LWP_PRIO_SET]) + ;; + *tandem*) + AC_DEFINE([ACE_TIMER_SKEW], [(1000 * 10)]) + ;; + *unixware2.0*) + AC_DEFINE([UNIXWARE]) + AC_DEFINE([UNIXWARE_2_0]) + ;; + *unixware2.1*) + AC_DEFINE([UNIXWARE]) + AC_DEFINE([UNIXWARE_2_1]) + ;; + *UnixWare7.1*) + AC_DEFINE([UNIXWARE]) + AC_DEFINE([UNIXWARE_7_1]) + AC_DEFINE([__IOCTL_VERSIONED__]) + ACE_CPPFLAGS="$ACE_CPPFLAGS -D_REENTRANT" + ;; + *vxworks*) + AC_DEFINE([VXWORKS]) + AC_DEFINE([ACE_MAIN], [ace_main]) + AC_DEFINE([ACE_DEFAULT_MAX_SOCKET_BUFSIZ], [32768]) + dnl need ACE_HAS_TSS_EMULATION for ACE_DEFAULT_THREAD_KEYS! + AC_EGREP_CPP([ACE_TSS_EMULATION], + [ +#if defined (ACE_HAS_TSS_EMULATION) + ACE_TSS_EMULATION +#endif + ], [AC_DEFINE([ACE_DEFAULT_THREAD_KEYS], [16])],[]) + AC_DEFINE([ACE_THR_PRI_FIFO_DEF], [101]) + ;; + *cygwin32*) + AC_DEFINE([CYGWIN32]) + ;; + *mingw32*) + AC_DEFINE([ACE_WIN32]) + ;; + *win32*) + AC_DEFINE([ACE_WIN32]) +dnl AC_DEFINE(ACE_USE_SELECT_REACTOR_FOR_REACTOR_IMPL) + if test "$ace_u_long_long_typedef_set" != yes; then + ACE_UINT64="unsigned __int64" + ace_u_long_long_typedef_set=yes + fi dnl "$ace_u_long_long_typedef_set" != yes + ;; + *qnx* | *nto* | *neutrino*) + dnl These should be defined on the command line, not in config.h. + ACE_CPPFLAGS="$ACE_CPPFLAGS -D_QNX_SOURCE -D_POSIX_C_SOURCE=199506" + ACE_CPPFLAGS="$ACE_CPPFLAGS -D_POSIX_NAME_MAX=14" # Max bytes in a + # filename + ACE_CPPFLAGS="$ACE_CPPFLAGS -D_POSIX_PATH_MAX=256" # Num. bytes in + # pathname (excl. NULL) + case "$host" in + i[[3456]]86*) + if test "$GXX" = yes; then + # Neutrino defines memcpy as a macro on x86, which then + # hoses the ACE_OS::memcpy() method. Undefining + # __OPTIMIZE__ prevents this from happening. + ACE_CPPFLAGS="$ACE_CPPFLAGS -U__OPTIMIZE__" + fi + ;; + esac + ;; + *) + ;; +esac + +ACE_FUNC_IOCTL_ARGTYPES +ACE_CHECK_GETNAME_RETURNS_RANDOM_SIN_ZERO +ACE_CHECK_HAS_NONCONST_FD_ISSET +ACE_CHECK_FORMAT_SPECIFIERS +ACE_CHECK_LACKS_PERFECT_MULTICAST_FILTERING +ACE_CHECK_HAS_DLSYM_SEGFAULT_ON_INVALID_HANDLE + +dnl End ACE_SET_PLATFORM_MACROS +]) + + + +# ACE_CHECK_FORMAT_SPECIFIERS +# +# Override default *printf format specifiers for size_t, ssize_t, ACE_INT64, +# and ACE_UINT64 +# +# FIXME: Is it possible to write a portable feature test, or is checking +# the the target OS / target CPU the best we can do? +# +#--------------------------------------------------------------------------- +AC_DEFUN([ACE_CHECK_FORMAT_SPECIFIERS], +[dnl +AH_TEMPLATE([ACE_SIZE_T_FORMAT_SPECIFIER], +[Define to the *printf format specifier (e.g. "%u") for size_t])dnl +AH_TEMPLATE([ACE_SSIZE_T_FORMAT_SPECIFIER], +[Define to the *printf format specifier (e.g. "%d") for ssize_t])dnl +AH_TEMPLATE([ACE_INT64_FORMAT_SPECIFIER], +[Define to the *printf format specifier (e.g. "%lld") for ACE_INT64])dnl +AH_TEMPLATE([ACE_UINT64_FORMAT_SPECIFIER], +[Define to the *printf format specifier (e.g. "%llu") for ACE_UINT64])dnl + +case "$host_os" in +darwin*) + AC_DEFINE([ACE_SIZE_T_FORMAT_SPECIFIER], ["%lu"]) + ;; + +linux*) + case "$host_cpu" in + alpha|ia64|x86_64) + AC_DEFINE([ACE_SIZE_T_FORMAT_SPECIFIER], ["%lu"]) + AC_DEFINE([ACE_SSIZE_T_FORMAT_SPECIFIER], ["%ld"]) + AC_DEFINE([ACE_INT64_FORMAT_SPECIFIER], ["%ld"]) + AC_DEFINE([ACE_UINT64_FORMAT_SPECIFIER], ["%lu"]) + ;; + *) + ;; + esac + ;; + +mingw32*) + AC_DEFINE([ACE_INT64_FORMAT_SPECIFIER], ["%I64d"]) + AC_DEFINE([ACE_UINT64_FORMAT_SPECIFIER], ["%I64u"]) + ;; + +netbsd*) + case "$host_cpu" in + x86_64) + AC_DEFINE([ACE_SIZE_T_FORMAT_SPECIFIER], ["%lu"]) + AC_DEFINE([ACE_SSIZE_T_FORMAT_SPECIFIER], ["%ld"]) + ;; + *) + ;; + esac + ;; + +win32*) + AC_DEFINE([ACE_INT64_FORMAT_SPECIFIER], ["%I64d"]) + AC_DEFINE([ACE_UINT64_FORMAT_SPECIFIER], ["%I64u"]) + ;; + +*) + ;; +esac]) + + +# ACE_CHECK_PERFECT_MULTICAST_FILTERING +# +# Checks whether platform lacks "perfect" multicast filtering. +# +# FIXME: Is it possible to write a portable feature test, or is checking +# the the target OS the best we can do? +# +#--------------------------------------------------------------------------- +AC_DEFUN([ACE_CHECK_LACKS_PERFECT_MULTICAST_FILTERING], +[AC_CACHE_CHECK([whether platform lacks perfect multicast filtering], + [ace_cv_lacks_perfect_multicast_filtering], + [case "$host_os" in + darwin* | freebsd* | netbsd* | openbsd* | qnx*) + ace_cv_lacks_perfect_multicast_filtering=yes ;; + *) + ace_cv_lacks_perfect_multicast_filtering=no ;; + esac]) + +if test $ace_cv_lacks_perfect_multicast_filtering = yes; then + AC_DEFINE([ACE_LACKS_PERFECT_MULTICAST_FILTERING], 1, +[Define to 1 if platform lacks IGMPv3 "perfect" filtering of multicast +datagrams at the socket level. If defined, ACE_SOCK_Dgram_Mcast will bind +the first joined multicast group to the socket, and all future joins on that +socket will fail with an error.]) +fi +]) + + +# ACE_FUNC_IOCTL_ARGTYPES +# +# Determine the correct type to be passed to ioctl's second argument and +# define the types in ACE_IOCTL_TYPE_ARG2. +# +# FIXME: Should we support ioctl's third argument as well...? +# +# FIXME: Is it possible to write a portable feature test, or is checking +# the the target OS the best we can do? +# +#--------------------------------------------------------------------------- +AC_DEFUN([ACE_FUNC_IOCTL_ARGTYPES], +[AC_CACHE_CHECK([types of arguments for ioctl()], + [ace_cv_func_ioctl_arg2], + [case "$host_os" in + darwin* | freebsd* | netbsd* | openbsd*) + ace_cv_func_ioctl_arg2="unsigned long" ;; + *) + ace_cv_func_ioctl_arg2="int" ;; + esac]) + +AC_DEFINE_UNQUOTED(ACE_IOCTL_TYPE_ARG2, $ace_cv_func_ioctl_arg2, + [Define to the type of arg 2 for `ioctl'.]) +]) + + +# ACE_VAR_TIMEZONE +# +# Checks whether platform has global "timezone" variable. +# +#--------------------------------------------------------------------------- +AC_DEFUN([ACE_VAR_TIMEZONE], +[AC_CACHE_CHECK([for timezone variable], + [ace_cv_var_timezone], + [AC_TRY_LINK([#include ], + [return (int) timezone(0, 0);], + [ace_cv_var_timezone=no], + [AC_TRY_LINK([#include ], + [return (int) timezone;], + [ace_cv_var_timezone=yes], + [ace_cv_var_timezone=no])]) + ]) +if test "$ace_cv_var_timezone" = yes; then + AC_DEFINE([ACE_HAS_TIMEZONE], 1, + [Define to 1 if platform has global timezone variable]) +fi +]) + + +# ACE_CHECK_GETNAME_RETURNS_RANDOM_SIN_ZERO +# +# Checks whether getsockname() and getpeername() return random values +# in the sockaddr_in.sin_zero field. +# +# FIXME: Is it possible to write a portable feature test, or is checking +# the the target OS the best we can do? +# +AC_DEFUN([ACE_CHECK_GETNAME_RETURNS_RANDOM_SIN_ZERO], +[AC_CACHE_CHECK([whether getsockname() and getpeername() return random values in sockaddr_in.sin_zero], + [ace_cv_getname_returns_random_sin_zero], + [case "$host_os" in + linux*) + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([#include ], + [ + #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,47)) + int ok; + #else + choke me + #endif + ]) + ], + [ace_cv_getname_returns_random_sin_zero=no], + [ace_cv_getname_returns_random_sin_zero=yes]) + ;; + *) + ace_cv_getname_returns_random_sin_zero=no + ;; + esac]) + +if test $ace_cv_getname_returns_random_sin_zero = yes; then + AC_DEFINE([ACE_GETNAME_RETURNS_RANDOM_SIN_ZERO], 1, +[Define to 1 if the getsockname() and getpeername() return random values in the sockaddr_in.sin_zero field.]) +fi +]) + + +# ACE_CHECK_HAS_NONCONST_FD_ISSET +# +# Checks if system has a nonconst FD_ISSET macro. +# +#--------------------------------------------------------------------------- +AC_DEFUN([ACE_CHECK_HAS_NONCONST_FD_ISSET], +[dnl + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([#include ], + [ + //const fd_set* temp = new fd_set(); + //FD_ISSET(0, const_cast< fd_set* >( temp ) ); + const fd_set* temp = new fd_set(); + FD_ISSET(0, temp ); + ]) + ],[],[AC_DEFINE([ACE_HAS_NONCONST_FD_ISSET], 1, + [Define to 1 if system has nonconst FD_ISSET() macro.])] + ) +]) + +# ACE_CHECK_HAS_DLSYM_SEGFAULT_ON_INVALID_HANDLE +# +# Checks whether the dlsym() call segfaults when passed an invalid handle. +# +# FIXME: Is it possible to write a portable feature test, or is checking +# the the target OS the best we can do? +# +AC_DEFUN([ACE_CHECK_HAS_DLSYM_SEGFAULT_ON_INVALID_HANDLE], +[AC_CACHE_CHECK([whether dlsym() segfaults when passed an invalid handle], + [ace_cv_has_dlsym_segfault_on_invalid_handle], + [case "$host_os" in + linux* | openbsd*) + ace_cv_has_dlsym_segfault_on_invalid_handle=yes ;; + *) + ace_cv_has_dlsym_segfault_on_invalid_handle=no;; + esac]) + +if test $ace_cv_has_dlsym_segfault_on_invalid_handle = yes; then + AC_DEFINE([ACE_HAS_DLSYM_SEGFAULT_ON_INVALID_HANDLE], 1, +[Define to 1 if the dlsym() call segfaults when passed an invalid handle.]) +fi +]) diff --git a/dep/ACE_wrappers/m4/subsets.m4 b/dep/ACE_wrappers/m4/subsets.m4 new file mode 100644 index 00000000000..87b2dee7c91 --- /dev/null +++ b/dep/ACE_wrappers/m4/subsets.m4 @@ -0,0 +1,770 @@ +dnl ------------------------------------------------------------------------- +dnl $Id: subsets.m4 80826 2008-03-04 14:51:23Z wotte $ +dnl +dnl subsets.m4 +dnl +dnl ACE M4 include file which contains ACE specific M4 macros +dnl that set/determine which ACE subsets to build. +dnl +dnl ------------------------------------------------------------------------- + +dnl Copyright (C) 1998, 1999, 2001 Ossama Othman +dnl +dnl All Rights Reserved +dnl +dnl This library is free software; you can redistribute it and/or +dnl modify it under the current ACE distribution terms. +dnl +dnl This library is distributed in the hope that it will be useful, +dnl but WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + + +dnl Check for thread related libraries and compiler flags +dnl Usage: ACE_CHECK_SUBSETS +AC_DEFUN([ACE_CHECK_SUBSETS], +[ +dnl Begin ACE_CHECK_SUBSETS + +dnl Assume all subsets will be built, including the full ACE library. +dnl If any of the components is explicitly enabled or disabled by the user +dnl then do NOT build the full ACE library. +AC_ARG_ENABLE([lib-all], + AS_HELP_STRING([--enable-lib-all],[build all ACE components [[no]]]), + [ + case "${enableval}" in + yes) + ace_user_enable_lib_all=yes + ;; + no) + ace_user_enable_lib_all=no + ;; + *) + AC_MSG_ERROR([bad value ${enableval} for --enable-lib-all]) + ;; + esac + ], + [ + ace_user_enable_lib_all=no + ]) + +AC_ARG_ENABLE([lib-full], + AS_HELP_STRING([--enable-lib-full],[build the full ACE library [[yes]]]), + [ + case "${enableval}" in + yes) + ace_user_enable_lib_full=yes + ;; + no) + ace_user_enable_lib_full=no + ;; + *) + AC_MSG_ERROR([bad value ${enableval} for --enable-lib-full]) + ;; + esac + ], + [ + ace_user_enable_lib_full=yes + ]) + +AC_ARG_ENABLE([lib-os], + AS_HELP_STRING([--enable-lib-os],[build ACE_OS library]), + [ + case "${enableval}" in + yes) + ACE_CREATE_LIBACE_OS + ;; + no) + ace_user_enable_lib_os=no + ;; + *) + AC_MSG_ERROR([bad value ${enableval} for --enable-lib-os]) + ;; + esac + + dnl Disable full ACE library build + ace_user_enable_lib_full=no + ],) + +AC_ARG_ENABLE([lib-codecs], + AS_HELP_STRING([--enable-lib-codecs],[build ACE_Codecs library]), + [ + case "${enableval}" in + yes) + ACE_CREATE_LIBACE_CODECS + ;; + no) + ace_user_enable_lib_codecs=no + AC_DEFINE([ACE_LACKS_ACE_CODECS]) + ;; + *) + AC_MSG_ERROR([bad value ${enableval} for --enable-lib-codecs]) + ;; + esac + + dnl Disable full ACE library build + ace_user_enable_lib_full=no + ],) + +AC_ARG_ENABLE([lib-connection], + AS_HELP_STRING([--enable-lib-connection],[build ACE_Connection library ]), + [ + case "${enableval}" in + yes) + ACE_CREATE_LIBACE_CONNECTION + ;; + no) + ace_user_enable_lib_connection=no + ;; + *) + AC_MSG_ERROR([bad value ${enableval} for --enable-lib-connection]) + ;; + esac + + dnl Disable full ACE library build + ace_user_enable_lib_full=no + ],) + +AC_ARG_ENABLE([lib-demux], + AS_HELP_STRING([--enable-lib-demux],[build ACE_Demux library]), + [ + case "${enableval}" in + yes) + ACE_CREATE_LIBACE_DEMUX + ;; + no) + ace_user_enable_lib_demux=no + ;; + *) + AC_MSG_ERROR([bad value ${enableval} for --enable-lib-demux]) + ;; + esac + + dnl Disable full ACE library build + ace_user_enable_lib_full=no + ],) + +AC_ARG_ENABLE([lib-filecache], + AS_HELP_STRING([--enable-lib-filecache],[build ACE_Filecache library]), + [ + case "${enableval}" in + yes) + ACE_CREATE_LIBACE_FILECACHE + ;; + no) + ace_user_enable_lib_filecache=no + ;; + *) + AC_MSG_ERROR([bad value ${enableval} for --enable-lib-filecache]) + ;; + esac + + dnl Disable full ACE library build + ace_user_enable_lib_full=no + ],) + +AC_ARG_ENABLE([lib-ipc], + AS_HELP_STRING([--enable-lib-ipc],[build ACE_IPC library]), + [ + case "${enableval}" in + yes) + ACE_CREATE_LIBACE_IPC + ;; + no) + ace_user_enable_lib_ipc=no + ;; + *) + AC_MSG_ERROR([bad value ${enableval} for --enable-lib-ipc]) + ;; + esac + + dnl Disable full ACE library build + ace_user_enable_lib_full=no + ],) + +AC_ARG_ENABLE([lib-logging], + AS_HELP_STRING([--enable-lib-logging],[build ACE_Logging library]), + [ + case "${enableval}" in + yes) + ACE_CREATE_LIBACE_LOGGING + ;; + no) + ace_user_enable_lib_logging=no + ;; + *) + AC_MSG_ERROR([bad value ${enableval} for --enable-lib-logging]) + ;; + esac + + dnl Disable full ACE library build + ace_user_enable_lib_full=no + ],) + +AC_ARG_ENABLE([lib-memory], + AS_HELP_STRING([--enable-lib-memory],[build ACE_Memory library]), + [ + case "${enableval}" in + yes) + ACE_CREATE_LIBACE_MEMORY + ;; + no) + ace_user_enable_lib_memory=no + ;; + *) + AC_MSG_ERROR([bad value ${enableval} for --enable-lib-memory]) + ;; + esac + + dnl Disable full ACE library build + ace_user_enable_lib_full=no + ],) + +AC_ARG_ENABLE([lib-metrics], + AS_HELP_STRING([--enable-lib-metrics],[build ACE_Metrics library]), + [ + case "${enableval}" in + yes) + ACE_CREATE_LIBACE_METRICS + ;; + no) + ace_user_enable_lib_metrics=no + ;; + *) + AC_MSG_ERROR([bad value ${enableval} for --enable-lib-metrics]) + ;; + esac + + dnl Disable full ACE library build + ace_user_enable_lib_full=no + ],) + +AC_ARG_ENABLE([lib-sockets], + AS_HELP_STRING([--enable-lib-sockets],[build ACE_Sockets library]), + [ + case "${enableval}" in + yes) + ACE_CREATE_LIBACE_SOCKETS + ;; + no) + ace_user_enable_lib_sockets=no + ;; + *) + AC_MSG_ERROR([bad value ${enableval} for --enable-lib-sockets]) + ;; + esac + + dnl Disable full ACE library build + ace_user_enable_lib_full=no + ],) + +AC_ARG_ENABLE([lib-streams], + AS_HELP_STRING([--enable-lib-streams],[build ACE_Streams library]), + [ + case "${enableval}" in + yes) + ACE_CREATE_LIBACE_STREAMS + ;; + no) + ace_user_enable_lib_streams=no + ;; + *) + AC_MSG_ERROR([bad value ${enableval} for --enable-lib-streams]) + ;; + esac + + dnl Disable full ACE library build + ace_user_enable_lib_full=no + ],) + +AC_ARG_ENABLE([lib-svcconf], + AS_HELP_STRING([--enable-lib-svcconf],[build ACE_Svcconf library]), + [ + case "${enableval}" in + yes) + ACE_CREATE_LIBACE_SVCCONF + ;; + no) + ace_user_enable_lib_svcconf=no + AC_DEFINE([ACE_LACKS_ACE_SVCCONF]) + ;; + *) + AC_MSG_ERROR([bad value ${enableval} for --enable-lib-svcconf]) + ;; + esac + + dnl Disable full ACE library build + ace_user_enable_lib_full=no + ],) + +AC_ARG_ENABLE([lib-threads], + AS_HELP_STRING([--enable-lib-threads],[build ACE_Threads library]), + [ + case "${enableval}" in + yes) + ACE_CREATE_LIBACE_THREADS + ;; + no) + ace_user_enable_lib_threads=no + ;; + *) + AC_MSG_ERROR([bad value ${enableval} for --enable-lib-threads]) + ;; + esac + + dnl Disable full ACE library build + ace_user_enable_lib_full=no + ],) + +AC_ARG_ENABLE([lib-timer], + AS_HELP_STRING([--enable-lib-timer],[build ACE_Timer library]), + [ + case "${enableval}" in + yes) + ACE_CREATE_LIBACE_TIMER + ;; + no) + ace_user_enable_lib_timer=no + ;; + *) + AC_MSG_ERROR([bad value ${enableval} for --enable-lib-timer]) + ;; + esac + + dnl Disable full ACE library build + ace_user_enable_lib_full=no + ],) + +AC_ARG_ENABLE([lib-token], + AS_HELP_STRING([--enable-lib-token],[build ACE_Token library]), + [ + case "${enableval}" in + yes) + ACE_CREATE_LIBACE_TOKEN + ;; + no) + ace_user_enable_lib_token=no + AC_DEFINE([ACE_LACKS_ACE_TOKEN]) + ;; + *) + AC_MSG_ERROR([bad value ${enableval} for --enable-lib-token]) + ;; + esac + + dnl Disable full ACE library build + ace_user_enable_lib_full=no + ],) + +AC_ARG_ENABLE([lib-utils], + AS_HELP_STRING([--enable-lib-utils],[build ACE_Utils library]), + [ + case "${enableval}" in + yes) + ACE_CREATE_LIBACE_UTILS + ;; + no) + ace_user_enable_lib_utils=no + ;; + *) + AC_MSG_ERROR([bad value ${enableval} for --enable-lib-utils]) + ;; + esac + + dnl Disable full ACE library build + ace_user_enable_lib_full=no + ],) + +AC_ARG_ENABLE([lib-uuid], + AS_HELP_STRING([--enable-lib-uuid],[build ACE_UUID library]), + [ + case "${enableval}" in + yes) + ACE_CREATE_LIBACE_UUID + ;; + no) + ace_user_enable_lib_uuid=no + AC_DEFINE([ACE_LACKS_ACE_UUID]) + ;; + *) + AC_MSG_ERROR([bad value ${enableval} for --enable-lib-uuid]) + ;; + esac + + dnl Disable full ACE library build + ace_user_enable_lib_full=no + ],) + +AC_ARG_ENABLE([lib-other], + AS_HELP_STRING([--enable-lib-other],[build ACE_Other library]), + [ + case "${enableval}" in + yes) + ACE_CREATE_LIBACE_OTHER + ;; + no) + ace_user_enable_lib_other=no + AC_DEFINE([ACE_LACKS_ACE_OTHER]) + ;; + *) + AC_MSG_ERROR([bad value ${enableval} for --enable-lib-other]) + ;; + esac + + dnl Disable full ACE library build + ace_user_enable_lib_full=no + ],) + + +dnl If no ACE subsets were explicitly enabled or disabled then build +dnl all of them. +if test $ace_user_enable_lib_all = yes; then + + ACE_CREATE_ALL_COMPONENTS + +elif test $ace_user_enable_lib_all = no; then + + ACE_DISABLE_ALL_COMPONENTS + +fi + +if test $ace_user_enable_lib_full = no && + test $ace_user_enable_lib_os = no && + test $ace_user_enable_lib_codecs = no && + test $ace_user_enable_lib_connection = no && + test $ace_user_enable_lib_demux = no && + test $ace_user_enable_lib_filecache = no && + test $ace_user_enable_lib_ipc = no && + test $ace_user_enable_lib_logging = no && + test $ace_user_enable_lib_memory = no && + test $ace_user_enable_lib_metrics = no && + test $ace_user_enable_lib_threads = no && + test $ace_user_enable_lib_sockets = no && + test $ace_user_enable_lib_svcconf = no && + test $ace_user_enable_lib_streams = no && + test $ace_user_enable_lib_timer = no && + test $ace_user_enable_lib_token = no && + test $ace_user_enable_lib_utils = no && + test $ace_user_enable_lib_uuid = no && + test $ace_user_enable_lib_other = no; then + + dnl If we get here then no ACE libraries will be built! + AC_MSG_ERROR([No ACE components will be built. Specify which components to build.]) + +fi dnl No components will be built! + +dnl Set which ACE subsets to build +AM_CONDITIONAL(BUILD_OS_FILES, + test X$ace_user_enable_lib_os = Xyes) + +AM_CONDITIONAL(BUILD_CODECS_FILES, + test X$ace_user_enable_lib_codecs = Xyes) + +AM_CONDITIONAL(BUILD_CONNECTION_FILES, + test X$ace_user_enable_lib_connection = Xyes) + +AM_CONDITIONAL(BUILD_DEMUX_FILES, + test X$ace_user_enable_lib_demux = Xyes) + +AM_CONDITIONAL(BUILD_FILECACHE_FILES, + test X$ace_user_enable_lib_filecache = Xyes) + +AM_CONDITIONAL(BUILD_IPC_FILES, + test X$ace_user_enable_lib_ipc = Xyes) + +AM_CONDITIONAL(BUILD_LOGGING_FILES, + test X$ace_user_enable_lib_logging = Xyes) + +AM_CONDITIONAL(BUILD_MEMORY_FILES, + test X$ace_user_enable_lib_memory = Xyes) + +AM_CONDITIONAL(BUILD_METRICS_FILES, + test X$ace_user_enable_lib_metrics = Xyes) + +AM_CONDITIONAL(BUILD_SOCKETS_FILES, + test X$ace_user_enable_lib_sockets = Xyes) + +AM_CONDITIONAL(BUILD_STREAMS_FILES, + test X$ace_user_enable_lib_streams = Xyes) + +AM_CONDITIONAL(BUILD_SVCCONF_FILES, + test X$ace_user_enable_lib_svcconf = Xyes) + +AM_CONDITIONAL(BUILD_THREADS_FILES, + test X$ace_user_enable_lib_threads = Xyes) + +AM_CONDITIONAL(BUILD_TIMER_FILES, + test X$ace_user_enable_lib_timer = Xyes) + +AM_CONDITIONAL(BUILD_TOKEN_FILES, + test X$ace_user_enable_lib_token = Xyes) + +AM_CONDITIONAL(BUILD_UTILS_FILES, + test X$ace_user_enable_lib_utils = Xyes) + +AM_CONDITIONAL(BUILD_UUID_FILES, + test X$ace_user_enable_lib_uuid = Xyes) + +AM_CONDITIONAL(BUILD_OTHER_FILES, + test X$ace_user_enable_lib_other = Xyes) + +AM_CONDITIONAL(BUILD_FULL_LIBRARY, + test X$ace_user_enable_lib_full = Xyes) + +dnl End ACE_CHECK_SUBSETS +]) + +dnl Set the component dependencies for the libACE_OS library +dnl Usage: ACE_CREATE_LIBACE_OS +AC_DEFUN([ACE_CREATE_LIBACE_OS], +[ + ace_user_enable_lib_os=yes +]) + +dnl Set the component dependencies for the libACE_Utils library +dnl Usage: ACE_CREATE_LIBACE_UTILS +AC_DEFUN([ACE_CREATE_LIBACE_UTILS], +[ + ace_user_enable_lib_utils=yes + + dnl Be careful not to go into a circular/recursive loop with these macros! + ACE_CREATE_LIBACE_OS +]) + +dnl Set the component dependencies for the libACE_UUID library +dnl Usage: ACE_CREATE_LIBACE_UUID +AC_DEFUN([ACE_CREATE_LIBACE_UUID], +[ + ace_user_enable_lib_uuid=yes + + dnl Be careful not to go into a circular/recursive loop with these macros! + ACE_CREATE_LIBACE_OS +]) + +dnl Set the component dependencies for the libACE_Filecache library +dnl Usage: ACE_CREATE_LIBACE_FILECACHE +AC_DEFUN([ACE_CREATE_LIBACE_FILECACHE], +[ + ace_user_enable_lib_filecache=yes + + dnl Be careful not to go into a circular/recursive loop with these macros! + ACE_CREATE_LIBACE_OS +]) + +dnl Set the component dependencies for the libACE_Logging library +dnl Usage: ACE_CREATE_LIBACE_LOGGING +AC_DEFUN([ACE_CREATE_LIBACE_LOGGING], +[ + ace_user_enable_lib_logging=yes + + dnl Be careful not to go into a circular/recursive loop with these macros! + ACE_CREATE_LIBACE_OS +]) + +dnl Set the component dependencies for the libACE_Metrics library +dnl Usage: ACE_CREATE_LIBACE_METRICS +AC_DEFUN([ACE_CREATE_LIBACE_METRICS], +[ + ace_user_enable_lib_metrics=yes + + dnl Be careful not to go into a circular/recursive loop with these macros! + ACE_CREATE_LIBACE_OS +]) + +dnl Set the component dependencies for the libACE_Threads library +dnl Usage: ACE_CREATE_LIBACE_THREADS +AC_DEFUN([ACE_CREATE_LIBACE_THREADS], +[ + ace_user_enable_lib_threads=yes + + dnl Be careful not to go into a circular/recursive loop with these macros! + ACE_CREATE_LIBACE_OS +]) + +dnl Set the component dependencies for the libACE_Demux library +dnl Usage: ACE_CREATE_LIBACE_DEMUX +AC_DEFUN([ACE_CREATE_LIBACE_DEMUX], +[ + ace_user_enable_lib_demux=yes + + dnl Be careful not to go into a circular/recursive loop with these macros! + ACE_CREATE_LIBACE_OS + ACE_CREATE_LIBACE_THREADS +]) + +dnl Set the component dependencies for the libACE_Connection library +dnl Usage: ACE_CREATE_LIBACE_CONNECTION +AC_DEFUN([ACE_CREATE_LIBACE_CONNECTION], +[ + ace_user_enable_lib_connection=yes + + dnl Be careful not to go into a circular/recursive loop with these macros! + ACE_CREATE_LIBACE_OS + ACE_CREATE_LIBACE_THREADS + ACE_CREATE_LIBACE_DEMUX +]) + +dnl Set the component dependencies for the libACE_Sockets library +dnl Usage: ACE_CREATE_LIBACE_SOCKETS +AC_DEFUN([ACE_CREATE_LIBACE_SOCKETS], +[ + ace_user_enable_lib_sockets=yes + + dnl Be careful not to go into a circular/recursive loop with these macros! + ACE_CREATE_LIBACE_OS +]) + +dnl Set the component dependencies for the libACE_IPC library +dnl Usage: ACE_CREATE_LIBACE_IPC +AC_DEFUN([ACE_CREATE_LIBACE_IPC], +[ + ace_user_enable_lib_ipc=yes + + dnl Be careful not to go into a circular/recursive loop with these macros! + ACE_CREATE_LIBACE_OS + ACE_CREATE_LIBACE_SOCKETS +]) + +dnl Set the component dependencies for the libACE_Svcconf library +dnl Usage: ACE_CREATE_LIBACE_SVCCONF +AC_DEFUN([ACE_CREATE_LIBACE_SVCCONF], +[ + ace_user_enable_lib_svcconf=yes + + dnl Be careful not to go into a circular/recursive loop with these macros! + ACE_CREATE_LIBACE_OS + ACE_CREATE_LIBACE_THREADS + ACE_CREATE_LIBACE_DEMUX + ACE_CREATE_LIBACE_SOCKETS +]) + +dnl Set the component dependencies for the libACE_Streams library +dnl Usage: ACE_CREATE_LIBACE_STREAMS +AC_DEFUN([ACE_CREATE_LIBACE_STREAMS], +[ + ace_user_enable_lib_streams=yes + + dnl Be careful not to go into a circular/recursive loop with these macros! + ACE_CREATE_LIBACE_OS + ACE_CREATE_LIBACE_THREADS + ACE_CREATE_LIBACE_DEMUX +]) + +dnl Set the component dependencies for the libACE_Memory library +dnl Usage: ACE_CREATE_LIBACE_MEMORY +AC_DEFUN([ACE_CREATE_LIBACE_MEMORY], +[ + ace_user_enable_lib_memory=yes + + dnl Be careful not to go into a circular/recursive loop with these macros! + ACE_CREATE_LIBACE_OS +]) + +dnl Set the component dependencies for the libACE_Timer library +dnl Usage: ACE_CREATE_LIBACE_TIMER +AC_DEFUN([ACE_CREATE_LIBACE_TIMER], +[ + ace_user_enable_lib_timer=yes + + dnl Be careful not to go into a circular/recursive loop with these macros! + ACE_CREATE_LIBACE_OS +]) + +dnl Set the component dependencies for the libACE_Token library +dnl Usage: ACE_CREATE_LIBACE_TOKEN +AC_DEFUN([ACE_CREATE_LIBACE_TOKEN], +[ + ace_user_enable_lib_token=yes + + dnl Be careful not to go into a circular/recursive loop with these macros! + ACE_CREATE_LIBACE_OS + ACE_CREATE_LIBACE_UTILS + ACE_CREATE_LIBACE_LOGGING + ACE_CREATE_LIBACE_THREADS + ACE_CREATE_LIBACE_DEMUX + ACE_CREATE_LIBACE_CONNECTION + ACE_CREATE_LIBACE_SOCKETS + ACE_CREATE_LIBACE_IPC + ACE_CREATE_LIBACE_SVCCONF + ACE_CREATE_LIBACE_STREAMS + ACE_CREATE_LIBACE_MEMORY + dnl ACE_CREATE_LIBACE_OTHER +]) + +dnl Set the component dependencies for the libACE_Codecs library +dnl Usage: ACE_CREATE_LIBACE_CODECS +AC_DEFUN([ACE_CREATE_LIBACE_CODECS], +[ + ace_user_enable_lib_codecs=yes + + dnl Be careful not to go into a circular/recursive loop with these macros! + ACE_CREATE_LIBACE_OS +]) + +dnl Set the component dependencies for the libACE_Other library +dnl Usage: ACE_CREATE_LIBACE_OTHER +AC_DEFUN([ACE_CREATE_LIBACE_OTHER], +[ + ace_user_enable_lib_other=yes + + dnl Be careful not to go into a circular/recursive loop with these macros! + ACE_CREATE_LIBACE_OS + ACE_CREATE_LIBACE_UTILS + ACE_CREATE_LIBACE_LOGGING + ACE_CREATE_LIBACE_THREADS + ACE_CREATE_LIBACE_DEMUX + ACE_CREATE_LIBACE_CONNECTION + ACE_CREATE_LIBACE_SOCKETS + ACE_CREATE_LIBACE_IPC + ACE_CREATE_LIBACE_SVCCONF + ACE_CREATE_LIBACE_STREAMS + ACE_CREATE_LIBACE_MEMORY + dnl ACE_CREATE_LIBACE_TOKEN +]) + +dnl Build all ACE component libraries +dnl Usage: ACE_CREATE_ALL_COMPONENTS +AC_DEFUN([ACE_CREATE_ALL_COMPONENTS], +[ + ace_user_enable_lib_os=yes + ace_user_enable_lib_codecs=yes + ace_user_enable_lib_connection=yes + ace_user_enable_lib_demux=yes + ace_user_enable_lib_filecache=yes + ace_user_enable_lib_ipc=yes + ace_user_enable_lib_logging=yes + ace_user_enable_lib_memory=yes + ace_user_enable_lib_metrics=yes + ace_user_enable_lib_sockets=yes + ace_user_enable_lib_streams=yes + ace_user_enable_lib_svcconf=yes + ace_user_enable_lib_threads=yes + ace_user_enable_lib_timer=yes + ace_user_enable_lib_token=yes + ace_user_enable_lib_utils=yes + ace_user_enable_lib_uuid=yes + ace_user_enable_lib_other=yes +]) + +dnl Disable all ACE component libraries +dnl Usage: ACE_CREATE_ALL_COMPONENTS +AC_DEFUN([ACE_DISABLE_ALL_COMPONENTS], +[ + ace_user_enable_lib_os=no + ace_user_enable_lib_codecs=no + ace_user_enable_lib_connection=no + ace_user_enable_lib_demux=no + ace_user_enable_lib_filecache=no + ace_user_enable_lib_ipc=no + ace_user_enable_lib_logging=no + ace_user_enable_lib_memory=no + ace_user_enable_lib_metrics=no + ace_user_enable_lib_sockets=no + ace_user_enable_lib_streams=no + ace_user_enable_lib_svcconf=no + ace_user_enable_lib_threads=no + ace_user_enable_lib_timer=no + ace_user_enable_lib_token=no + ace_user_enable_lib_utils=no + ace_user_enable_lib_uuid=no + ace_user_enable_lib_other=no +]) diff --git a/dep/ACE_wrappers/m4/threads.m4 b/dep/ACE_wrappers/m4/threads.m4 new file mode 100644 index 00000000000..f8b2058d924 --- /dev/null +++ b/dep/ACE_wrappers/m4/threads.m4 @@ -0,0 +1,334 @@ +dnl ------------------------------------------------------------------------- +dnl $Id: threads.m4 80826 2008-03-04 14:51:23Z wotte $ +dnl +dnl threads.m4 +dnl +dnl ACE M4 include file which contains ACE specific M4 macros +dnl for configuring thread support. This file is to be used +dnl with the configure script. +dnl +dnl ------------------------------------------------------------------------- + +dnl Copyright (C) 1998, 1999, 2002 Ossama Othman +dnl +dnl All Rights Reserved +dnl +dnl This library is free software; you can redistribute it and/or +dnl modify it under the current ACE distribution terms. +dnl +dnl This library is distributed in the hope that it will be useful, +dnl but WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +dnl Make sure thread library exists +dnl We need to be careful when tests for other thread libraries are +dnl added that we don't screw up handling of "ace_user_enable_threads" +dnl Tests should probably be more platform specific later on. + +dnl Check for thread related libraries and compiler flags +dnl Usage: ACE_CHECK_THREADS +AC_DEFUN([ACE_CHECK_THREADS], +[ +dnl AC_REQUIRE([AC_PROG_CXX]) +dnl AC_REQUIRE([AC_PROG_CXXCPP]) +dnl AC_LANG([C++]) +dnl AC_REQUIRE([AC_LANG]) + + dnl Check if compiler accepts specific flag to enable threads + ACE_CACHE_CHECK([if compiler may need a command line thread flag], + [ace_cv_feature_may_need_thread_flag], + [ + ace_save_CXXFLAGS="$CXXFLAGS" + + ACE_CHECK_THREAD_FLAGS( + [ + ace_cv_feature_may_need_thread_flag=no + ], + [ + ace_cv_feature_may_need_thread_flag=yes + ]) + dnl Reset the flags to a consistent state. + dnl This prevents duplicate flags from being added to + dnl the C/CXXFLAGS variable. + CXXFLAGS="$ace_save_CXXFLAGS" + ], + [ + dnl The compiler/platform has no thread support linked in by default + dnl so search for a usable compiler flag to enable thread support. + dnl If no thread flag is found then the remaining tests should still + dnl figure out how to enable thread support via library checks. + ACE_SEARCH_THREAD_FLAGS( + [mt pthread pthreads mthreads threads Kthread kthread -thread_safe],,) + dnl NOTE: "-thread_safe" is correct, not "thread_safe." + dnl KAI C++ uses the flag "--thread_safe" which is why + dnl "-thread_safe" is passed as the flag to test. + ], + [ + dnl Do nothing + ]) + + dnl Check for UNIX International Threads (ACE calls this STHREADS) + dnl This used to check for thr_create(), but AIX has a semi-functional + dnl UI Threads capability that includes thr_create(). We don't want to + dnl find such a half-hearted UI Threads, so this was changed to look for + dnl a UI Threads function that AIX doesn't offer. + AS_IF([test "$ace_user_enable_uithreads" = yes], + [ AC_MSG_CHECKING([for UNIX International threads capability]) + AC_SEARCH_LIBS([mutex_lock], [thread], + [ + ace_has_sthreads=yes + AC_DEFINE([ACE_HAS_STHREADS], 1, + [Define to 1 if platform has UNIX International Threads]) + ], + [ + ace_has_sthreads=no + ]) + dnl Sometimes thr_create is actually found with explicitly linking against + dnl -lthread, so try a more "exotic" function. + AC_SEARCH_LIBS([rwlock_destroy], [thread],[],[]) + AC_MSG_RESULT([$ace_has_sthreads]) + ],[]) + + dnl Check if any thread related preprocessor flags are needed. + ACE_CHECK_THREAD_CPPFLAGS + + dnl Check for POSIX threads + ace_has_pthreads=no + AS_IF([test "$ace_user_enable_pthreads" = yes], + [ AC_MSG_CHECKING([for POSIX threads library]) + ACE_CHECK_POSIX_THREADS( + [ + ace_has_pthreads=yes + AC_DEFINE([ACE_HAS_PTHREADS], 1, + [Define to 1 if platform has POSIX threads]) + AC_MSG_RESULT([none required]) + ], + []) + + AS_IF([test "$ace_has_pthreads" != yes], + [ + ace_posix_threads_search_LIBS="$LIBS" + for ace_p in pthread pthreads c_r gthreads; do + LIBS="-l$ace_p $ace_posix_threads_search_LIBS" + ACE_CHECK_POSIX_THREADS( + [ + ace_has_pthreads=yes + AC_DEFINE([ACE_HAS_PTHREADS]) + AC_MSG_RESULT([-l$ace_p]) + break + ], + []) + done + + AS_IF([test "$ace_has_pthreads" != yes], + [ + AC_MSG_RESULT([no]) + LIBS="$ace_posix_threads_search_LIBS" + ],[]) + ], + []) + ], + [ + AC_MSG_NOTICE([Pthreads disabled by user; not checking for it]) + ]) + + dnl If we don't have any thread library, then disable threading altogether! + AS_IF([test "$ace_has_pthreads" != yes && test "$ace_has_sthreads" != yes], + [ + ace_user_enable_threads=no + ]) +]) + +dnl This macro will check that the current compiler flags do something +dnl useful in terms of thread libraries and/or functions. +dnl Usage: ACE_CHECK_THREAD_FLAGS(ACTION-IF-USABLE [, ACTION-IF-NOT-USABLE]]) +AC_DEFUN([ACE_CHECK_THREAD_FLAGS], +[ + ACE_CONVERT_WARNINGS_TO_ERRORS([ + dnl Check for UI thread support first. + + dnl Because some platforms are brain damaged enough to provide + dnl useless thread function stubs, link tests may succeed despite the + dnl fact the stubs are no-ops. This forces us to use a run-time test + dnl to get around this nuisance by checking the return value of + dnl thr_create(). The cross-compiled case will use a link-time + dnl test, instead. + dnl Furthermore, we need the implementation to be a real one, not + dnl a half-hearted attempt such as that provided on AIX 5. So, we + dnl make sure it can at least work with a mutex. + + AC_RUN_IFELSE([AC_LANG_SOURCE([[ +#include +#if ((THR_BOUND & THR_SUSPEND & THR_DETACHED) != 0) +# error This is a silly UI Threads implementation. +#endif + +extern "C" void * +ace_start_func (void *) +{ + mutex_t m; + mutex_init (&m, USYNC_THREAD, NULL); + mutex_lock (&m); + mutex_unlock (&m); + mutex_destroy (&m); + return 0; +} + +int +main () +{ + thread_t tid = 0; + + return thr_create (0, 0, ace_start_func, 0, 0, &tid); +} + ]])], + [$1], + [ + dnl Now check for POSIX thread support. + ACE_CHECK_POSIX_THREADS([$1],[$2]) + + ], + [ + dnl UI threads cross-compiled case + + AC_LINK_IFELSE([AC_LANG_PROGRAM([[ +#include + +extern "C" void * +ace_start_func (void *) +{ + return 0; +} + ]], + [[ + thread_t tid = 0; + + (void) thr_create (&tid, 0, ace_start_func, 0); + ]])], + [$1], + [$2]) + ]) + ]) +]) + +dnl Check what compiler thread flag may be used, if any, from the given list. +dnl The flag list is separated by white space. +dnl Usage: ACE_SEARCH_THREAD_FLAGS(THREAD-FLAG-LIST, +dnl [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) +AC_DEFUN([ACE_SEARCH_THREAD_FLAGS], +[ + AC_LANG([C++]) + AC_REQUIRE([AC_LANG]) + + ACE_CACHE_CHECK([for compiler thread flag], + [ace_cv_thread_flag_search], + [ + ace_save_CXXFLAGS="$CXXFLAGS" + + for i in $1; do + CXXFLAGS="$CXXFLAGS -$i" + + ACE_CHECK_THREAD_FLAGS( + [ + ace_cv_thread_flag_search="-$i" + + dnl A usable flag was found so break out of the loop. + break; + ], + [ + ace_cv_thread_flag_search=no + ]) + + dnl Reset the flags for the next flag check. + CXXFLAGS="$ace_save_CXXFLAGS" + done + + dnl Reset the flags to a consistent state. + dnl This prevents duplicate flags from being added to + dnl the CCXXFLAGS variable. + CXXFLAGS="$ace_save_CXXFLAGS" + ], + [ + dnl Add the found/cached thread flag to the C/CXXFLAGS variables + CXXFLAGS="$CXXFLAGS $ace_cv_thread_flag_search" + + $2 + ], + [ + $3 + ]) +]) + + +dnl Check if the compiler defines thread related preprocessor flags. +dnl If not, then provide them. +dnl Usage: ACE_CHECK_THREAD_CPPFLAGS +AC_DEFUN([ACE_CHECK_THREAD_CPPFLAGS], +[ + dnl A compile-time test is used instead of a preprocesse-time test + dnl because compiler thread flags defined in CFLAGS or CXXFLAGS + dnl should be used for this test. + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#if !defined (_REENTRANT) && !defined (_THREAD_SAFE) +#error Neither _REENTRANT nor _THREAD_SAFE were defined. +THROW ME AN ERROR! +#endif + ]], [[ + int a = 0; a++; + ]])],[ + ACE_THR_CPPFLAGS= + ],[ + ACE_THR_CPPFLAGS="-D_REENTRANT -D_THREAD_SAFE" + ]) +]) + +dnl Check for POSIX threads support. +dnl Usage: ACE_CHECK_POSIX_THREADS([ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) +AC_DEFUN([ACE_CHECK_POSIX_THREADS], +[ + dnl Because some platforms are brain damaged enough to provide + dnl useless thread function stubs, link tests may succeed despite the + dnl fact the stubs are no-ops. This forces us to use a run-time test + dnl to get around this nuisance by checking the return value of + dnl pthread_create(). The cross-compiled case will use a link-time + dnl test, instead. + AC_RUN_IFELSE([AC_LANG_SOURCE([[ +#include + +extern "C" void * +ace_start_func (void *) +{ + return 0; +} + +int +main () +{ + pthread_t tid = 0; + + return pthread_create (&tid, 0, ace_start_func, 0); +} + ]])], + [$1], + [$2], + [ + dnl POSIX threads check -- cross-compiled case + + AC_LINK_IFELSE([AC_LANG_PROGRAM([[ +#include + +extern "C" void * +ace_start_func (void *) +{ + return 0; +} + ]], + [[ + pthread_t tid = 0; + + (void) pthread_create (&tid, 0, ace_start_func, 0); + ]])], + [$1], + [$2]) + ]) +]) diff --git a/dep/ACE_wrappers/m4/tls.m4 b/dep/ACE_wrappers/m4/tls.m4 new file mode 100644 index 00000000000..b28023f69ca --- /dev/null +++ b/dep/ACE_wrappers/m4/tls.m4 @@ -0,0 +1,220 @@ +dnl ------------------------------------------------------------------------- +dnl $Id: tls.m4 80826 2008-03-04 14:51:23Z wotte $ +dnl +dnl tls.m4 +dnl +dnl ACE M4 include file which contains ACE specific M4 macros +dnl that determine availablility of SSL/TLS support. +dnl +dnl ------------------------------------------------------------------------- + +dnl Copyright (C) 2003 Ossama Othman +dnl +dnl All Rights Reserved +dnl +dnl This library is free software; you can redistribute it and/or +dnl modify it under the current ACE distribution terms. +dnl +dnl This library is distributed in the hope that it will be useful, +dnl but WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +dnl TLS/SSL library IO check +dnl Use this macro to determine if TLS/SSL support is available on the +dnl current host. +dnl Usage: ACE_CHECK_TLS +AC_DEFUN([ACE_CHECK_TLS], +[ + AC_REQUIRE([AC_PROG_CXX]) + AC_REQUIRE([AC_PROG_CXXCPP]) + AC_LANG([C++]) + AC_REQUIRE([AC_LANG]) + + ace_TLS_CPPFLAGS="" + ace_TLS_LDFLAGS="" + + AC_ARG_WITH([openssl], + AS_HELP_STRING([--with-openssl@<:@=DIR@:>@], + [root directory of openssl installation]), + [ + ace_with_openssl="${withval}" + if test "${ace_with_openssl}" != yes; then + ace_openssl_include="${ace_with_openssl}/include" + ace_openssl_libdir="${ace_with_openssl}/lib" + fi + ]) + + AC_ARG_WITH([openssl_include], + AS_HELP_STRING([--with-openssl-include=DIR], + [specify exact include dir for openssl headers]), + [ace_openssl_include="$withval"]) + + AC_ARG_WITH([openssl_libdir], + AS_HELP_STRING([--with-openssl-libdir=DIR], + [specify exact include dir for openssl libraries]), + [ace_openssl_libdir="$withval"]) + + if test "${ace_openssl_include}"; then + ace_TLS_CPPFLAGS="-I${ace_openssl_include}" + fi + + if test "${ace_openssl_libdir}"; then + ace_TLS_LDFLAGS="-L${ace_openssl_libdir}" + fi + + dnl Save the current library and preprocessor flagslist. We do not + dnl want to add the SSL/TLS-specific ones to the general library link + dnl and preprocessor flags list since they should only be used when + dnl building the ACE_SSL library and/or binaries that use the ACE_SSL + dnl library. + ace_save_LIBS="$LIBS" + ace_save_CPPFLAGS="$CPPFLAGS" + CPPFLAGS="$CPPFLAGS $ace_TLS_CPPFLAGS" + ace_save_LDFLAGS="$LDFLAGS" + LDFLAGS="$LDFLAGS $ace_TLS_LDFLAGS" + + dnl --------------------------------------------------------- + + dnl Check if OpenSSL requires the Kerberos include directory to be + dnl added to the header search path. + + AC_CACHE_CHECK([for Kerberos include flags needed by OpenSSL], + [ac_cv_kerberos_dir], + [ + dnl Try compiling without any Kerberos-specific flags first. + + AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM([ +#include + ], + [ +// ... THIS CODE DOES NOTHING! IT IS JUST USED FOR COMPILE TESTS ... + +// ... Perform TCP connection ... + +// ... Perform TLS/SSL stuff ... +CRYPTO_set_locking_callback (0); +SSLeay_add_ssl_algorithms (); +SSL_load_error_strings (); +SSL_METHOD * meth = TLSv1_method (); +SSL_CTX * ctx = SSL_CTX_new (meth); +SSL * ssl = SSL_new (ctx); +int fd = 2000; // Dummy file descriptor value. +SSL_set_fd (ssl, fd); +SSL_connect (ssl); +SSL_shutdown (ssl); + +// ... + ]) + ], + [ + ac_cv_kerberos_dir=no + ], + [ + ace_kerberos_dir="" + for ace_kerberos in /usr /usr/local; do + ace_kerberos_dir="${ace_kerberos}/kerberos/include" + ace_kerberos_CPPFLAGS="-I${ace_kerberos_dir}" + + CPPFLAGS="$ace_save_CPPFLAGS $ace_TLS_CPPFLAGS $ace_kerberos_CPPFLAGS" + + AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM([ +#include + ], + [ +// ... THIS CODE DOES NOTHING! IT IS JUST USED FOR COMPILE TESTS ... + +// ... Perform TCP connection ... + +// ... Perform TLS/SSL stuff ... +CRYPTO_set_locking_callback (0); +SSLeay_add_ssl_algorithms (); +SSL_load_error_strings (); +SSL_METHOD * meth = TLSv1_method (); +SSL_CTX * ctx = SSL_CTX_new (meth); +SSL * ssl = SSL_new (ctx); +int fd = 2000; // Dummy file descriptor value. +SSL_set_fd (ssl, fd); +SSL_connect (ssl); +SSL_shutdown (ssl); + +// ... + ]) + ], + [ + ac_cv_kerberos_dir="$ace_kerberos_dir" + break + ], + [ + ac_cv_kerberos_dir=no + ]) + done + ]) + ]) + + AS_IF([test "$ac_cv_kerberos_dir" = no], + [ + AC_SUBST([ACE_KERBEROS_INCLUDES],[.]) + ], + [ + ace_TLS_CPPFLAGS="$ace_TLS_CPPFLAGS -I${ac_cv_kerberos_dir}" + AC_SUBST([ACE_KERBEROS_INCLUDES],[$ac_cv_kerberos_dir]) + ]) + + dnl --------------------------------------------------------- + + dnl Add the TLS/SSL libraries to the library list. + ace_TLS_LIBS="-lssl -lcrypto" + + LIBS="$ace_TLS_LIBS $LIBS" + LDFLAGS="$ace_TLS_LDFLAGS $LDFLAGS" + + AC_CACHE_CHECK([for OpenSSL libraries], + [ac_cv_openssl_libs], + [ + AC_LINK_IFELSE([ + AC_LANG_PROGRAM([ +#include + ], + [ +// ... THIS PROGRAM DOES NOTHING! IT IS JUST USED FOR LINK TESTS ... + +// ... Perform TCP connection ... + +// ... Perform TLS/SSL stuff ... +CRYPTO_set_locking_callback (0); +SSLeay_add_ssl_algorithms (); +SSL_load_error_strings (); +SSL_METHOD * meth = TLSv1_method (); +SSL_CTX * ctx = SSL_CTX_new (meth); +SSL * ssl = SSL_new (ctx); +int fd = 2000; // Dummy file descriptor value. +SSL_set_fd (ssl, fd); +SSL_connect (ssl); +SSL_shutdown (ssl); + +// ... + ]) + ], + [ + ac_cv_openssl_libs=yes + ], + [ + ac_cv_openssl_libs=no + ]) + ]) + + AS_IF([test $ac_cv_openssl_libs != no], + [ +AC_SUBST([ACE_TLS_CPPFLAGS],[$ace_TLS_CPPFLAGS]) +AC_SUBST([ACE_TLS_LDFLAGS],[$ace_TLS_LDFLAGS]) +AC_SUBST([ACE_TLS_LIBS],[$ace_TLS_LIBS]) + ], + []) + + dnl Restore the original library list and preprocessor flags. + LIBS="$ace_save_LIBS" + CPPFLAGS="$ace_save_CPPFLAGS" + LDFLAGS="$ace_save_LDFLAGS" +]) diff --git a/dep/Makefile.am b/dep/Makefile.am index f82b7760833..e0856407820 100644 --- a/dep/Makefile.am +++ b/dep/Makefile.am @@ -17,7 +17,7 @@ ## Process this file with automake to produce Makefile.in ## Sub-directories to parse -SUBDIRS = include lib src +SUBDIRS = include lib src ACE_wrappers ## Additional files to include when running 'make dist' # Nothing yet. diff --git a/sql/mangos.sql b/sql/mangos.sql index 8955a959c69..9e0061f45fe 100644 --- a/sql/mangos.sql +++ b/sql/mangos.sql @@ -1,15321 +1,15324 @@ --- MySQL dump 10.11 --- --- Host: localhost Database: mangos --- ------------------------------------------------------ --- Server version 5.0.56-nt - -/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; -/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; -/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; -/*!40101 SET NAMES utf8 */; -/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; -/*!40103 SET TIME_ZONE='+00:00' */; -/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; -/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; -/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; -/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; - --- --- Table structure for table `areatrigger_involvedrelation` --- - -DROP TABLE IF EXISTS `areatrigger_involvedrelation`; -CREATE TABLE `areatrigger_involvedrelation` ( - `id` mediumint(8) unsigned NOT NULL default '0' COMMENT 'Identifier', - `quest` mediumint(8) unsigned NOT NULL default '0' COMMENT 'Quest Identifier', - PRIMARY KEY (`id`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Trigger System'; - --- --- Dumping data for table `areatrigger_involvedrelation` --- - -LOCK TABLES `areatrigger_involvedrelation` WRITE; -/*!40000 ALTER TABLE `areatrigger_involvedrelation` DISABLE KEYS */; -/*!40000 ALTER TABLE `areatrigger_involvedrelation` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `areatrigger_scripts` --- - -DROP TABLE IF EXISTS `areatrigger_scripts`; -CREATE TABLE `areatrigger_scripts` ( - `entry` MEDIUMINT( 8 ) NOT NULL , - `ScriptName` CHAR( 64 ) NOT NULL , - PRIMARY KEY ( `entry` ) -) ENGINE = MYISAM DEFAULT CHARSET=utf8; - --- --- Table structure for table `areatrigger_tavern` --- - -DROP TABLE IF EXISTS `areatrigger_tavern`; -CREATE TABLE `areatrigger_tavern` ( - `id` mediumint(8) unsigned NOT NULL default '0' COMMENT 'Identifier', - `name` text, - PRIMARY KEY (`id`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Trigger System'; - --- --- Dumping data for table `areatrigger_tavern` --- - -LOCK TABLES `areatrigger_tavern` WRITE; -/*!40000 ALTER TABLE `areatrigger_tavern` DISABLE KEYS */; -/*!40000 ALTER TABLE `areatrigger_tavern` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `areatrigger_teleport` --- - -DROP TABLE IF EXISTS `areatrigger_teleport`; -CREATE TABLE `areatrigger_teleport` ( - `id` mediumint(8) unsigned NOT NULL default '0' COMMENT 'Identifier', - `name` text, - `required_level` tinyint(3) unsigned NOT NULL default '0', - `required_item` mediumint(8) unsigned NOT NULL default '0', - `required_item2` mediumint(8) unsigned NOT NULL default '0', - `heroic_key` mediumint(8) unsigned NOT NULL default '0', - `heroic_key2` mediumint(8) unsigned NOT NULL default '0', - `required_quest_done` int(11) unsigned NOT NULL default '0', - `required_failed_text` text, - `target_map` smallint(5) unsigned NOT NULL default '0', - `target_position_x` float NOT NULL default '0', - `target_position_y` float NOT NULL default '0', - `target_position_z` float NOT NULL default '0', - `target_orientation` float NOT NULL default '0', - PRIMARY KEY (`id`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Trigger System'; - --- --- Dumping data for table `areatrigger_teleport` --- - -LOCK TABLES `areatrigger_teleport` WRITE; -/*!40000 ALTER TABLE `areatrigger_teleport` DISABLE KEYS */; -/*!40000 ALTER TABLE `areatrigger_teleport` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `battleground_template` --- - -DROP TABLE IF EXISTS `battleground_template`; -CREATE TABLE `battleground_template` ( - `id` mediumint(8) unsigned NOT NULL, - `MinPlayersPerTeam` smallint(5) unsigned NOT NULL default '0', - `MaxPlayersPerTeam` smallint(5) unsigned NOT NULL default '0', - `MinLvl` tinyint(3) unsigned NOT NULL default '0', - `MaxLvl` tinyint(3) unsigned NOT NULL default '0', - `AllianceStartLoc` mediumint(8) unsigned NOT NULL, - `AllianceStartO` float NOT NULL, - `HordeStartLoc` mediumint(8) unsigned NOT NULL, - `HordeStartO` float NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8; - --- --- Dumping data for table `battleground_template` --- - -LOCK TABLES `battleground_template` WRITE; -/*!40000 ALTER TABLE `battleground_template` DISABLE KEYS */; -INSERT INTO `battleground_template` VALUES -(1,0,0,0,0,611,2.72532,610,2.27452), -(2,0,0,0,0,769,3.14159,770,3.14159), -(4,0,2,10,70,929,0,936,3.14159), -(3,0,0,0,0,890,3.40156,889,0.263892), -(5,0,2,10,70,939,0,940,3.14159), -(6,0,2,10,70,0,0,0,0), -(7,0,0,0,0,1103,3.40156,1104,0.263892), -(8,0,2,10,70,1258,0,1259,3.14159); -/*!40000 ALTER TABLE `battleground_template` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `battlemaster_entry` --- - -DROP TABLE IF EXISTS `battlemaster_entry`; -CREATE TABLE `battlemaster_entry` ( - `entry` mediumint(8) unsigned NOT NULL default '0' COMMENT 'Entry of a creature', - `bg_template` mediumint(8) unsigned NOT NULL default '0' COMMENT 'Battleground template id', - PRIMARY KEY (`entry`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8; - --- --- Dumping data for table `battlemaster_entry` --- - -LOCK TABLES `battlemaster_entry` WRITE; -/*!40000 ALTER TABLE `battlemaster_entry` DISABLE KEYS */; -/*!40000 ALTER TABLE `battlemaster_entry` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `command` --- - -DROP TABLE IF EXISTS `command`; -CREATE TABLE `command` ( - `name` varchar(50) NOT NULL default '', - `security` tinyint(3) unsigned NOT NULL default '0', - `help` longtext, - PRIMARY KEY (`name`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Chat System'; - --- --- Dumping data for table `command` --- - -LOCK TABLES `command` WRITE; -/*!40000 ALTER TABLE `command` DISABLE KEYS */; -INSERT INTO `command` VALUES -('acct',0,'Syntax: .acct\r\n\r\nDisplay the access level of your account.'), -('additem',3,'Syntax: .additem #itemid/[#itemname]/#shift-click-item-link #itemcount\r\n\r\nAdds the specified number of items of id #itemid (or exact (!) name $itemname in brackets, or link created by shift-click at item in inventory or recipe) to your or selected character inventory. If #itemcount is omitted, only one item will be added.\r\n.'), -('additemset',3,'Syntax: .additemset #itemsetid\r\n\r\nAdd items from itemset of id #itemsetid to your or selected character inventory. Will add by one example each item from itemset.'), -('addmove',2,'Syntax: .addmove #creature_guid [#waittime]\r\n\r\nAdd your current location as a waypoint for creature with guid #creature_guid. And optional add wait time.'), -('announce',1,'Syntax: .announce $MessageToBroadcast\r\n\r\nSend a global message to all players online in chat log.'), -('aura',3,'Syntax: .aura #spellid\r\n\r\nAdd the aura from spell #spellid to the selected Unit.'), -('ban',3,'Syntax is: ban $NameOrIp $bantime $reason\r\nBan account or IP and kick player.\r\n$bantime: negative value leads to permban, otherwise use a timestring like \"4d20h3s\".'), -('baninfo',3,'Syntax is: baninfo \r\nWatch full information about a specific ban.'), -('bank',3,'Syntax: .bank\r\n\r\nShow your bank inventory.'), -('banlist',3,'Syntax is: banlist $NameOrIp\r\nsearches the banlist for a pattern.'), -('cast',3,'Syntax: .cast #spellid [triggered]\r\n Cast #spellid to selected target. If no target selected cast to self. If \'trigered\' or part provided then spell casted with triggered flag.'), -('cast back',3,'Syntax: .cast back #spellid [triggered]\r\n Selected target will cast #spellid to your character. If \'trigered\' or part provided then spell casted with triggered flag.'), -('cast dist',3,'Syntax: .cast dist #spellid [#dist [triggered]]\r\n You will cast spell to pint at distance #dist. If \'trigered\' or part provided then spell casted with triggered flag. Not all spells can be casted as area spells.'), -('cast self',3,'Syntax: .cast self #spellid [triggered]\r\nCast #spellid by target at target itself. If \'trigered\' or part provided then spell casted with triggered flag.'), -('cast target',3,'Syntax: .cast target #spellid [triggered]\r\n Selected target will cast #spellid to his victim. If \'trigered\' or part provided then spell casted with triggered flag.'), -('combatstop',2,'Syntax: .combatstop [$playername]\r\nStop combat for selected character. If selected non-player then command applied to self. If $playername provided then attempt applied to online player $playername.'), -('commands',0,'Syntax: .commands\r\n\r\nDisplay a list of available commands for your account level.'), -('cooldown',3,'Syntax: .cooldown [#spell_id]\r\n\r\nRemove all (if spell_id not provided) or #spel_id spell cooldown from selected character or you (if no selection).'), -('damage',3,'Syntax: .damage $damage_amount [$school [$spellid]]\r\n\r\nApply $damage to target. If not $school and $spellid provided then this flat clean melee damage without any modifiers. If $school provided then damage modified by armor reduction (if school physical), and target absorbing modifiers and result applied as melee damage to target. If spell provided then damage modified and applied as spell damage. $spellid can be shift-link.'), -('debug anim',2,'Syntax: .debug anim #emoteid\r\n\r\nPlay emote #emoteid for your character.'), -('debug getvalue',3,'Syntax: .debug getvalue #field #isInt\r\n\r\nGet the field #field of the selected creature. If no creature is selected, get the content of your field.\r\n\r\nUse a #isInt of value 1 if the expected field content is an integer.'), -('debug playsound',1,'Syntax: .debug playsound #soundid\r\n\r\nPlay sound with #soundid.\r\nSound will be play only for you. Other players do not hear this.\r\nWarning: client may have more 5000 sounds...'), -('debug setvalue',3,'Syntax: .debug setvalue #field #value #isInt\r\n\r\nSet the field #field of the selected creature with value #value. If no creature is selected, set the content of your field.\r\n\r\nUse a #isInt of value 1 if #value is an integer.'), -('debug standstate',2,'Syntax: .debug standstate #emoteid\r\n\r\nChange the emote of your character while standing to #emoteid.'), -('debug update',3,'Syntax: .debug update #field #value\r\n\r\nUpdate the field #field of the selected character or creature with value #value.\r\n\r\nIf no #value is provided, display the content of field #field.'), -('delticket',2,'Syntax: .delticket all\r\n .delticket #num\r\n .delticket $character_name\r\n\rall to dalete all tickets at server, $character_name to delete ticket of this character, #num to delete ticket #num.'), -('demorph',2,'Syntax: .demorph\r\n\r\nDemorph the selected player.'), -('die',3,'Syntax: .die\r\n\r\nKill the selected player. If no player is selected, it will kill you.'), -('dismount',0,'Syntax: .dismount\r\n\r\nDismount you, if you are mounted.'), -('distance',3,'Syntax: .distance\r\n\r\nDisplay the distance from your character to the selected creature.'), -('event',2,'Syntax: .event #event_id\r\nShow details about event with #event_id.'), -('event activelist',2,'Syntax: .event activelist\r\nShow list of currently active events.'), -('event start',2,'Syntax: .event start #event_id\r\nStart event #event_id. Set start time for event to current moment (change not saved in DB).'), -('event stop',2,'Syntax: .event stop #event_id\r\nStop event #event_id. Set start time for event to time in past that make current moment is event stop time (change not saved in DB).'), -('explorecheat',3,'Syntax: .explorecheat #flag\r\n\r\nReveal or hide all maps for the selected player. If no player is selected, hide or reveal maps to you.\r\n\r\nUse a #flag of value 1 to reveal, use a #flag value of 0 to hide all maps.'), -('gm',1,'Syntax: .gm on/off\r\n\r\nEnable or Disable GM MODE'), -('gm fly',3,'Syntax: .gm fly on/off\r\nEnable/disable gm fly mode.'), -('gm list',0,'Syntax: .gm list\r\n\r\nDisplay a list of available Game Masters.'), -('gm visible',1,'Syntax: .gm visible on/off\r\n\r\nOutput current visibility state or make GM visible(on) and invisible(off) for other players.'), -('go creature',2,'Syntax: .go creature #creature_guid\r\nTeleport your character to creature with guid #creature_guid.\r\n.gocreature #creature_name\r\nTeleport your character to creature with this name.\r\n.gocreature id #creature_id\r\nTeleport your character to a creature that was spawned from the template with this entry.\r\n*If* more than one creature is found, then you are teleported to the first that is found inside the database.'), -('go graveyard',2,'Syntax: .go graveyard #graveyardId\r\n Teleport to graveyard with the graveyardId specified.'), -('go grid',1,'Syntax: .go grid #gridX #gridY [#mapId]\r\n\r\nTeleport the gm to center of grid with provided indexes at map #mapId (or current map if it not provided).'), -('go object',1,'Syntax: .go object #object_guid\r\nTeleport your character to gameobject with guid #object_guid'), -('go trigger',2,'Syntax: .go trigger #trigger_id\r\n\r\nTeleport your character to areatrigger with id #trigger_id. Character will be teleported to trigger target if selected areatrigger is telporting trigger.'), -('go xy',1,'Syntax: .go xy #x #y [#mapid]\r\n\r\nTeleport player to point with (#x,#y) coordinates at ground(water) level at map #mapid or same map if #mapid not provided.'), -('go xyz',1,'Syntax: .go xyz #x #y #z [#mapid]\r\n\r\nTeleport player to point with (#x,#y,#z) coordinates at ground(water) level at map #mapid or same map if #mapid not provided.'), -('go zonexy',1,'Syntax: .go zonexy #x #y [#zone]\r\n\r\nTeleport player to point with (#x,#y) client coordinates at ground(water) level in zone #zoneid or current zone if #zoneid not provided. You can look up zone using .lookup area $namepart'), -('gobject add',2,'Syntax: .gobject add #id \r\n\r\nAdd a game object from game object templates to the world at your current location using the #id.\r\nspawntimesecs sets the spawntime, it is optional.\r\n\r\nNote: this is a copy of .gameobject.'), -('gobject delete',2,'Syntax: .gobject delete #go_guid\r\nDelete gameobject with guid #go_guid.'), -('gobject move',2,'Syntax: .gobject move #goguid [#x #y #z]\r\n\r\nMove gameobject #goguid to character coordinates (or to (#x,#y,#z) coordinates if its provide).'), -('gobject near ',3,'Syntax: .gobject near [#distance]\r\n\r\nOutput gameobjects at distance #distance from player. Output gameobject guids and coordinates sorted by distance from character. If #distance not provided use 10 as default value.'), -('gobject turn',2,'Syntax: .gobject turn #goguid \r\n\r\nSet for gameobject #goguid orientation same as current character orientation.'), -('gobject target',2,'Syntax: .gobject target [#go_id|#go_name_part]\r\n\r\nLocate and show position nearest gameobject. If #go_id or #go_name_part provide then locate and show position of nearest gameobject with gameobject template id #go_id or name included #go_name_part as part.'), -('goname',1,'Syntax: .goname $charactername\r\n\r\nTeleport to the given character. Either specify the character name or click on the character\'s portrait, e.g. when you are in a group.'), -('gps',1,'Syntax: .gps\r\n\r\nDisplay the position information for a selected character or creature. Position information includes X, Y, Z, and orientation, map Id and zone Id'), -('groupgo',1,'Syntax: .groupgo $charactername\r\n\r\nTeleport the given character and his group to you.'), -('guid',2,'Syntax: .guid\r\n\r\nDisplay the GUID for the selected character.'), -('guild create',2,'Syntax: .guild create $GuildLeaderName $GuildName\r\n\r\nCreate a guild named $GuildName with the player $GuildLeaderName as leader.'), -('guild delete',2,'Syntax: .guild delete $GuildName\r\n\r\nDelete guild $GuildName.'), -('guild invite',2,'Syntax: .guild invite $CharacterName $GuildName\r\n\r\nAdd $CharacterName into a guild $GuildName.'), -('guild rank',2,'Syntax: .guild rank $CharacterName #Rank\r\n\r\nSet for $CharacterName rank #Rank in a guild.'), -('guild uninvite',2,'Syntax: .guild uninvite $CharacterName\r\n\r\nRemove $CharacterName from a guild.'), -('help',0,'Syntax: .help $command\r\n\r\nDisplay usage instructions for the given $command.'), -('hidearea',3,'Syntax: .hidearea #areaid\r\n\r\nHide the area of #areaid to the selected character. If no character is selected, hide this area to you.'), -('honor add',2,'Syntax: .honor add $amount\r\n\r\nAdd a certain amount of honor (gained today) to the selected player.'), -('honor addkill',2,'Syntax: .honor addkikll\r\n\r\nAdd the targeted unit as one of your pvp kills today (you only get honor if it\'s a racial leader or a player)'), -('honor update',2,'Syntax: .honor update\r\n\r\nForce the yesterday\'s honor fields to be updated with today\'s data, which will get reset for the selected player.'), -('hover',3,'Syntax: .hover #flag\r\n\r\nEnable or disable hover mode for your character.\r\n\r\nUse a #flag of value 1 to enable, use a #flag value of 0 to disable hover.'), -('instance unbind',3,'Syntax: .instance unbind all\r\n All of the selected player\'s binds will be cleared.'), -('instance listbinds',3,'Syntax: .instance listbinds\r\n Lists the binds of the selected player.'), -('instance stats',3,'Syntax: .instance stats\r\n Shows statistics about instances.'), -('instance savedata',3,'Syntax: .instance savedata\r\n Save the InstanceData for the current player\'s map to the DB.'), -('itemmove',2,'Syntax: .itemmove #sourceslotid #destinationslotid\r\n\r\nMove an item from slots #sourceslotid to #destinationslotid in your inventory\r\n\r\nNot yet implemented'), -('kick',2,'Syntax: .kick [$charactername]\r\n\r\nKick the given character name from the world. If no character name is provided then the selected player (except for yourself) will be kicked.'), -('learn',3,'Syntax: .learn #parameter\r\n\r\nSelected character learn a spell of id #parameter.'), -('learn all',3,'Syntax: .learn all\r\n\r\nLearn all big set different spell maybe useful for Administaror.'), -('learn all_crafts',2,'Syntax: .learn crafts\r\n\r\nLearn all professions and recipes.'), -('learn all_default',1,'Syntax: .learn all_default [$playername]\r\n\r\nLearn for selected/$playername player all default spells for his race/class and spells rewarded by completed quests.'), -('learn all_gm',2,'Syntax: .learn all_gm\r\n\r\nLearn all default spells for Game Masters.'), -('learn all_lang',1,'Syntax: .learn all_lang\r\n\r\nLearn all languages'), -('learn all_myclass',3,'Syntax: .learn all_myclass\r\n\r\nLearn all spells and talents available for his class.'), -('learn all_myspells',3,'Syntax: .learn all_myspells\r\n\r\nLearn all spells (except talents and spells with first rank learned as talent) available for his class.'), -('learn all_mytalents',3,'Syntax: .learn all_mytalents\r\n\r\nLearn all talents (and spells with first rank learned as talent) available for his class.'), -('learn all_recipes',2,'Syntax: .learn all_recipes [$profession]\r\rLearns all recipes of specified profession and sets skill level to max.\rExample: .learn all_recipes enchanting'), -('levelup',3,'Syntax: .levelup [$playername] [#numberoflevels]\r\n\r\nIncrease/decrease the level of character with $playername (or the selected if not name provided) by #numberoflevels Or +1 if no #numberoflevels provided). If #numberoflevels is omitted, the level will be increase by 1. If #numberoflevels is 0, the same level will be restarted. If no character is selected and name not provided, increase your level. Command can be used for offline character. All stats and dependent VALUESrecalculated. At level decrease talents can be reset if need. Also at level decrease equipped items with greater level requirement can be lost.'), -('linkgrave',3,'Syntax: .linkgrave #graveyard_id [alliance|horde]\r\n\r\nLink current zone to graveyard for any (or alliance/horde faction ghosts). This let character ghost from zone teleport to graveyard after die if graveyard is nearest from linked to zone and accept ghost of this faction. Add only single graveyard at another map and only if no graveyards linked (or planned linked at same map).'), -('list creature',3,'Syntax: .list creature #creature_id [#max_count]\r\n\r\nOutput creatures with creature id #creature_id found in world. Output creature guids and coordinates sorted by distance from character. Will be output maximum #max_count creatures. If #max_count not provided use 10 as default value.'), -('list item',3,'Syntax: .list item #item_id [#max_count]\r\n\r\nOutput items with item id #item_id found in all character inventories, mails and auctions. Output item guids, item owner guid, owner account and owner name. Will be output maximum #max_count items. If #max_count not provided use 10 as default value.'), -('list object',3,'Syntax: .list object #gameobject_id [#max_count]\r\n\r\nOutput gameobjects with gameobject id #gameobject_id found in world. Output gameobject guids and coordinates sorted by distance from character. Will be output maximum #max_count gameobject. If #max_count not provided use 10 as default value.'), -('loadscripts',3,'Syntax: .loadscripts $scriptlibraryname\r\n\r\nUnload current and load the script library $scriptlibraryname or reload current if $scriptlibraryname omitted, in case you changed it while the server was running.'), -('lockaccount',0,'Syntax: .lockaccount [on|off]\r\n\r\nAllow login from account only from current used IP or remove this requirement.'), -('lookup area',1,'Syntax: .lookup area $namepart\r\n\r\nLooks up an area by $namepart, and returns all matches with their area ID\'s.'), -('lookup creature',3,'Syntax: .lookup creature $namepart\r\n\r\nLooks up a creature by $namepart, and returns all matches with their creature ID\'s.'), -('lookup event',2,'Syntax: .lookup event $name\r\nAttempts to find the ID of the event with the provided $name.'), -('lookup faction',3,'Syntax: .lookup faction $name\r\nAttempts to find the ID of the faction with the provided $name.'), -('lookup item',3,'Syntax: .lookup item $itemname\r\n\r\nLooks up an item by $itemname, and returns all matches with their Item ID\'s.'), -('lookup itemset',3,'Syntax: .lookup itemset $itemname\r\n\r\nLooks up an item set by $itemname, and returns all matches with their Item set ID\'s.'), -('lookup object',3,'Syntax: .lookup object $objname\r\n\r\nLooks up an gameobject by $objname, and returns all matches with their Gameobject ID\'s.'), -('lookup quest',3,'Syntax: .lookup quest $namepart\r\n\r\nLooks up a quest by $namepart, and returns all matches with their quest ID\'s.'), -('lookup skill',3,'Syntax: .lookup skill $$namepart\r\n\r\nLooks up a skill by $namepart, and returns all matches with their skill ID\'s.'), -('lookup spell',3,'Syntax: .lookup spell $namepart\r\n\r\nLooks up a spell by $namepart, and returns all matches with their spell ID\'s.'), -('lookup tele',1,'Syntax: .lookup tele $substring\r\n\r\nSearch and output all .tele command locations with provide $substring in name.'), -('maxskill',3,'Syntax: .maxskill\r\nSets all skills of the targeted player to their maximum VALUESfor its current level.'), -('Mod32Value',3,'Syntax: .Mod32Value #field #value\r\n\r\nAdd #value to field #field of your character.'), -('modify arena',3,'Syntax: .modify arena #value\r\nAdd $amount arena points to the selected player.'), -('modify aspeed',1,'Syntax: .modify aspeed #rate\r\n\r\nModify all speeds -run,swim,run back,swim back- of the selected player to \"normalbase speed for this move type\"*rate. If no player is selected, modify your speed.\r\n\r\n #rate may range from 0.1 to 10.'), -('modify bit',1,'Syntax: .modify bit #field #bit\r\n\r\nToggle the #bit bit of the #field field for the selected player. If no player is selected, modify your character.'), -('modify bwalk',1,'Syntax: .modify bwalk #rate\r\n\r\nModify the speed of the selected player while running backwards to \"normal walk back speed\"*rate. If no player is selected, modify your speed.\r\n\r\n #rate may range from 0.1 to 10.'), -('modify drunk',1,'Syntax: .modify drunk #value\r\n Set drunk level to #value (0..100). Value 0 remove drunk state, 100 is max drunked state.'), -('modify energy',1,'Syntax: .modify energy #energy\r\n\r\nModify the energy of the selected player. If no player is selected, modify your energy.'), -('modify faction',1,'Syntax: .modify faction #factionid #flagid #npcflagid #dynamicflagid\r\n\r\nModify the faction and flags of the selected creature. Without arguments, display the faction and flags of the selected creature.'), -('modify honor',1,'Syntax: .modify honor $amount\r\n\r\nAdd $amount honor points to the selected player.'), -('modify hp',1,'Syntax: .modify hp #newhp\r\n\r\nModify the hp of the selected player. If no player is selected, modify your hp.'), -('modify mana',1,'Syntax: .modify mana #newmana\r\n\r\nModify the mana of the selected player. If no player is selected, modify your mana.'), -('modify money',1,'Syntax:\r\n.modify money #money\r\n.money #money\r\n\r\nAdd or remove money to the selected player. If no player is selected, modify your money.\r\n\r\n #gold can be negative to remove money.'), -('modify morph',2,'Syntax: .modify morph #displayid\r\n\r\nChange your current model id to #displayid.'), -('modify mount',1,'Syntax:\r\n.modify mount #id #speed\r\nDisplay selected player as mounted at #id creature and set speed to #speed value.'), -('modify rage',1,'Syntax: .modify rage #newrage\r\n\r\nModify the rage of the selected player. If no player is selected, modify your rage.'), -('modify rep',2,'Syntax: .modify rep #repId (#repvalue | $rankname [#delta])\r\nSets the selected players reputation with faction #repId to #repvalue or to $reprank.\r\nIf the reputation rank name is provided, the resulting reputation will be the lowest reputation for that rank plus the delta amount, if specified.\r\nYou can use \'.pinfo rep\' to list all known reputation ids, or use \'.lookup faction $name\' to locate a specific faction id.'), -('modify scale',1,''), -('modify speed',1,'Syntax:\r\n.modify speed #rate\r\n.speed #rate\r\n\r\nModify the running speed of the selected player to \"normal base run speed\"*rate. If no player is selected, modify your speed.\r\n\r\n #rate may range from 0.1 to 10.'), -('modify spell',1,''), -('modify swim',1,'Syntax: .modify swim #rate\r\n\r\nModify the swim speed of the selected player to \"normal swim speed\"*rate. If no player is selected, modify your speed.\r\n\r\n #rate may range from 0.1 to 10.'), -('modify titles',1,'Syntax:\r\n.modify titles #mask\r\n\r\nAllows user to use all titles from #mask.\r\n\r\n #mask=0 disables the title-choose-field'), -('movegens',3,'Syntax: .movegens\r\n Show movement generators stack for selected creature or player.'), -('mute',1,'Syntax: .mute $playerName $timeInMinutes\r\n\r\nDisible chat messaging for any character from account of character $playerName at $timeInMinutes minutes.'), -('namego',1,'Syntax: .namego $charactername\r\n\r\nTeleport the given character to you.'), -('neargrave',3,'Syntax: .neargrave [alliance|horde]\r\n\r\nFind nearest graveyard linked to zone (or only nearest from accepts alliance or horde faction ghosts).'), -('notify',1,'Syntax: .notify $MessageToBroadcast\r\n\r\nSend a global message to all players online in screen.'), -('npc add',2,'Syntax: .npc add #creatureid\r\n\r\nSpawn a creature by the given template id of #creatureid.'), -('npc additem',2,'Syntax: .npc additem #itemId <#maxcount><#incrtime><#extendedcost>r\r\n\r\nAdd item #itemid to item list of selected vendor. Also optionally set max count item in vendor item list and time to item count restoring and items ExtendedCost.'), -('npc addweapon',3,'Not yet implemented.'), -('npc allowmove',3,'Syntax: .npc allowmove\r\n\r\nEnable or disable movement for the selected creature.'), -('npc changelevel',2,'Syntax: .npc changelevel #level\r\n\r\nChange the level of the selected creature to #level.\r\n\r\n#level may range from 1 to 63.'), -('npc delete',2,'Syntax: .npc delete [#guid]\r\n\r\nDelete creature with guid #guid (or the selected if no guid is provided)'), -('npc delitem',2,'Syntax: .npc delitem #itemId\r\n\r\nRemove item #itemid from item list of selected vendor.'), -('npc factionid',2,'Syntax: .npc factionid #factionid\r\n\r\nSet the faction of the selected creature to #factionid.'), -('npc flag',2,'Syntax: .npc flag #npcflag\r\n\r\nSet the NPC flags of creature template of the selected creature and selected creature to #npcflag. NPC flags will applied to all creatures of selected creature template after server restart or grid unload/load.'), -('npc info',3,'Syntax: .npc info\r\n\r\nDisplay a list of details for the selected creature.\r\n\r\nThe list includes:\r\n- GUID, Faction, NPC flags, Entry ID, Model ID,\r\n- Level,\r\n- Health (current/maximum),\r\n\r\n- Field flags, dynamic flags, faction template, \r\n- Position information,\r\n- and the creature type, e.g. if the creature is a vendor.'), -('npc move',2,'Syntax: .npc move [#creature_guid]\r\n\r\nMove the targeted creature spawn point to your coordinates.'), -('npc name',2,'Syntax: .npc name $name\r\n\r\nChange the name of the selected creature or character to $name.\r\n\r\nCommand disabled.'), -('npc playemote',3,'Syntax: .npc playemote #emoteid\r\n\r\nMake the selected creature emote with an emote of id #emoteid.'), -('npc setmodel',2,'Syntax: .npc setmodel #displayid\r\n\r\nChange the model id of the selected creature to #displayid.'), -('npc setmovetype',2,'Syntax: .npc setmovetype [#creature_guid] stay/random/way [NODEL]\r\n\r\nSet for creature pointed by #creature_guid (or selected if #creature_guid not provided) movement type and move it to respawn position (if creature alive). Any existing waypoints for creature will be removed from the database if you do not use NODEL. If the creature is dead then movement type will applied at creature respawn.\r\nMake sure you use NODEL, if you want to keep the waypoints.'), -('npc spawndist',2,'Syntax: .npc spawndist #dist\r\n\r\nAdjust spawndistance of selected creature to dist.'), -('npc spawntime',2,'Syntax: .npc spawntime #time \r\n\r\nAdjust spawntime of selected creature to time.'), -('npc subname',2,'Syntax: .npc subname $Name\r\n\r\nChange the subname of the selected creature or player to $Name.\r\n\r\nCommand disabled.'), -('npc textemote',3,'Syntax: .npc textemote #emoteid\r\n\r\nMake the selected creature to do textemote with an emote of id #emoteid.'), -('npc whisper',1,'Syntax: .npc whisper #playerguid #text\r\nMake the selected npc whisper #text to #playerguid.'), -('password',0,'Syntax: .password $old_password $new_password $new_password\r\n\r\nChange your account password.'), -('pinfo',2,'Syntax: .pinfo [$player_name] [rep]\r\n\r\nOutput account information for selected player or player find by $player_name. If \"rep\" parameter provided show reputation information for player.'), -('plimit',3,'Syntax: .plimit [#num|-1|-2|-3|reset|player|moderator|gamemaster|administrator]\r\n\r\nWithout arg show current player amount and security level limitations for login to server, with arg set player linit ($num > 0) or securiti limitation ($num < 0 or security leme name. With `reset` sets player limit to the one in the config file'), -('quest add',3,'Syntax: .quest add #quest_id\r\n\r\nAdd to character quest log quest #quest_id. Quest started from item can\'t be added by this command but correct .additem call provided in command output.'), -('quest complete',3,'Syntax: .quest complete #questid\r\nMark all quest objectives as completed for target character active quest. After this target character can go and get quest reward.'), -('quest remove',3,'Syntax: .quest remove #quest_id\r\n\r\nSet quest #quest_id state to not completed and not active (and remove from active quest list) for selected player.'), -('recall',1,'Syntax: .recall [$playername]\r\n\r\nTeleport $playername or selected player to the place where he has been before last use of a teleportation command. If no $playername is entered and no player is selected, it will teleport you.'), -('reload',3,'Syntax: .reload table_name\r\n\r\nReload table `table_name` if reload support added for this table and this table can be _safe_ reloaded.'), -('reload all',3,'Syntax: .reload all\r\n\r\nReload all tables with reload support added and that can be _safe_ reloaded.'), -('reload all_area',3,'Syntax: .reload all_area\r\n\r\nReload all `areatrigger_*` tables if reload support added for this table and this table can be _safe_ reloaded.'), -('reload all_loot',3,'Syntax: .reload all_loot\r\n\r\nReload all `*_loot_template` tables. This can be slow operation with lags for server run.'), -('reload all_quest',3,'Syntax: .reload all_quest\r\n\r\nReload all quest related tables if reload support added for this table and this table can be _safe_ reloaded.'), -('reload all_spell',3,'Syntax: .reload all\r\n\r\nReload all `spell_*` tables with reload support added and that can be _safe_ reloaded.'), -('reload config',3,'Syntax: .reload config\r\n\r\nReload config settings (by default stored in mangosd.conf). Not all settings can be change at reload: some new setting values will be ignored until restart, some values will applied with delay or only to new objects/maps, some values will explicitly rejected to change at reload.'), -('reset all',3,'Syntax: .reset all spells\r\n\r\nSyntax: .reset all talents\r\n\r\nRequest reset spells or talents at next login each existed character.'), -('reset honor',3,'Syntax:\r\n.reset honor [Playername]\r\n Reset all honor data for targeted character.'), -('reset level',3,'Syntax:\r\n.reset level [Playername]\r\n Reset level to 1 including reset stats and talents. Equipped items with greater level requirement can be lost.'), -('reset spells',3,'Syntax:\r\n.reset spells [Playername]\r\n Removes all non-original spells from spellbook.\r\n. Playername can be name of offline character.'), -('reset stats',3,'Syntax:\r\n.reset stats [Playername]\r\n Resets(recalculate) all stats of the targeted player to their original VALUESat current level.'), -('reset talents',3,'Syntax:\r\n.reset talents [Playername]\r\n Removes all talents of the targeted player. Playername can be name of offline character.'), -('respawn',3,'Syntax: .respawn\r\n\r\nRespawn all nearest creatures and GO without waiting respawn time expiration.'), -('revive',3,'Syntax: .revive\r\n\r\nRevive the selected player. If no player is selected, it will revive you.'), -('save',0,'Syntax: .save\r\n\r\nSaves your character.'), -('saveall',1,'Syntax: .saveall\r\n\r\nSave all characters in game.'), -('security',3,'Syntax: .security $name #level\r\n\r\nSet the security level of player $name to a level of #level.\r\n\r\n#level may range from 0 to 5.'), -('sendmail',1,'Syntax: .sendmail #playername #subject #text\r\n\r\nSend a mail to a player. Note: subject may not contain spaces.'), -('server info',0,'Syntax: .server info\r\n\r\nDisplay server version and the number of connected players.'), -('server idleshutdown',3,'Syntax: .server idleshutdown #delay|cancel\r\n\r\nShut the server down after #delay seconds if no active connections are present (no players) or cancel the restart/shutdown if cancel value is used.'), -('server idlerestart',3,'Syntax: .server idlerestart #delay|cancel\r\n\r\nRestart the server after #delay seconds if no active connections are present (no players) or cancel the restart/shutdown if cancel value is used.'), -('server restart',3,'Syntax: .server restart seconds\r\n\r\nRestart the server after given seconds and show "Restart server in X" or cancel the restart/shutdown if cancel value is used.'), -('server shutdown',3,'Syntax: .server shutdown seconds\r\n\r\nShut the server down after given seconds and show "Off server in X" or cancel the restart/shutdown if cancel value is used.'), -('setskill',3,'Syntax: .setskill #skill #level [#max]\r\n\r\nSet a skill of id #skill with a current skill value of #level and a maximum value of #max (or equal current maximum if not provide) for the selected character. If no character is selected, you learn the skill.'), -('showarea',3,'Syntax: .showarea #areaid\r\n\r\nReveal the area of #areaid to the selected character. If no character is selected, reveal this area to you.'), -('start',0,'Syntax: .start\r\n\r\nTeleport you to the starting area of your character.'), -('taxicheat',1,'Syntax: .taxicheat on/off\r\n\r\nTemporary grant access or remove to all taxi routes for the selected character. If no character is selected, hide or reveal all routes to you.\r\n\r\nVisited taxi nodes sill accessible after removing access.'), -('tele',1,'Syntax: .tele #location\r\n\r\nTeleport player to a given location.'), -('tele add',3,'Syntax: .tele add $name\r\n\r\nAdd current your position to .tele command target locations list with name $name.'), -('tele del',3,'Syntax: .tele del $name\r\n\r\nRemove location with name $name for .tele command locations list.'), -('tele group',1,'Syntax: .tele group#location\r\n\r\nTeleport a selected player and his group members to a given location.'), -('tele name',1,'Syntax: .tele name #playername #location\r\n\r\nTeleport a player to a given location.'), -('ticket',2,'Syntax: .ticket on\r\n .ticket off\r\n .ticket #num\r\n .ticket $character_name\r\n\r\non/off for GMs to show or not a new ticket directly, $character_name to show ticket of this character, #num to show ticket #num.'), -('transport',3,'Not yet implemented.'), -('unaura',3,'Syntax: .unaura #spellid\r\n\r\nRemove aura due to spell #spellid from the selected Unit.'), -('unban',3,'Syntax is: unban $NameOrIp\r\nUnban account or IP.'), -('unlearn',3,'Syntax: .unlearn #startspell #endspell\r\n\r\nUnlearn for selected player the range of spells between id #startspell and #endspell. If no #endspell is provided, just unlearn spell of id #startspell.'), -('unmute',1,'Syntax: .unmute $playerName\r\n\r\nRestore chat messaging for any character from account of character $playerName.'), -('wchange',3,'Syntax: .wchange #weathertype #status\r\n\r\nSet current weather to #weathertype with an intensity of #status.\r\n\r\n#weathertype can be 1 for rain, 2 for snow, and 3 for sand. #status can be 0 for disabled, and 1 for enabled.'), -('whispers',1,'Syntax: .whispers on|off\r\nEnable/disable accepting whispers by GM from players. By default use mangosd.conf setting.'), -('wp',2,'Using WP Command:\r\nEach Waypoint Command has it\'s own description!'), -('wp add',2,'Syntax: .wp add [#creature_guid or Select a Creature]'), -('wp export',3,'Syntax: .wp export [#creature_guid or Select a Creature] $filename'), -('wp import',3,'Syntax: .wp import $filename'), -('wp modify',2,'Syntax: .wp modify [#creature_guid or Select a Creature]\r\nadd - Add a waypoint after the selected visual\r\nwaittime $time\r\nemote ID\r\nspell ID\r\ntext1| text2| text3| text4| text5 \r\nmodel1 ID\r\nmodel2 ID\r\nmove(moves wp to player pos)\r\ndel (deletes the wp)\r\n\r\nOnly one parameter per time!'), -('wp show',2,'Syntax: .wp show [#creature_guid or Select a Creature]\r\non\r\nfirst\r\nlast\r\noff\r\ninfo\r\n\r\nFor using info you have to do first show on and than select a Visual-Waypoint and do the show info!'); -/*!40000 ALTER TABLE `command` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `creature` --- - -DROP TABLE IF EXISTS `creature`; -CREATE TABLE `creature` ( - `guid` int(10) unsigned NOT NULL auto_increment COMMENT 'Global Unique Identifier', - `id` mediumint(8) unsigned NOT NULL default '0' COMMENT 'Creature Identifier', - `map` smallint(5) unsigned NOT NULL default '0' COMMENT 'Map Identifier', - `spawnMask` tinyint(3) unsigned NOT NULL default '1', - `modelid` mediumint(8) unsigned NOT NULL default '0', - `equipment_id` mediumint(9) NOT NULL default '0', - `position_x` float NOT NULL default '0', - `position_y` float NOT NULL default '0', - `position_z` float NOT NULL default '0', - `orientation` float NOT NULL default '0', - `spawntimesecs` int(10) unsigned NOT NULL default '120', - `spawndist` float NOT NULL default '5', - `currentwaypoint` mediumint(8) unsigned NOT NULL default '0', - `curhealth` int(10) unsigned NOT NULL default '1', - `curmana` int(10) unsigned NOT NULL default '0', - `DeathState` tinyint(3) unsigned NOT NULL default '0', - `MovementType` tinyint(3) unsigned NOT NULL default '0', - PRIMARY KEY (`guid`), - KEY `idx_map` (`map`), - KEY `index_id` (`id`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='Creature System'; - --- --- Dumping data for table `creature` --- - -LOCK TABLES `creature` WRITE; -/*!40000 ALTER TABLE `creature` DISABLE KEYS */; -/*!40000 ALTER TABLE `creature` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `creature_addon` --- - -DROP TABLE IF EXISTS `creature_addon`; -CREATE TABLE `creature_addon` ( - `guid` int(11) NOT NULL default '0', - `mount` mediumint(8) unsigned NOT NULL default '0', - `bytes0` int(10) unsigned NOT NULL default '0', - `bytes1` int(10) unsigned NOT NULL default '0', - `bytes2` int(10) unsigned NOT NULL default '0', - `emote` int(10) unsigned NOT NULL default '0', - `moveflags` int(10) unsigned NOT NULL default '0', - `auras` text, - PRIMARY KEY (`guid`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8; - --- --- Dumping data for table `creature_addon` --- - -LOCK TABLES `creature_addon` WRITE; -/*!40000 ALTER TABLE `creature_addon` DISABLE KEYS */; -/*!40000 ALTER TABLE `creature_addon` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `creature_equip_template` --- - -DROP TABLE IF EXISTS `creature_equip_template`; -CREATE TABLE `creature_equip_template` ( - `entry` mediumint(8) unsigned NOT NULL default '0' COMMENT 'Unique entry', - `equipmodel1` mediumint(8) unsigned NOT NULL default '0', - `equipmodel2` mediumint(8) unsigned NOT NULL default '0', - `equipmodel3` mediumint(8) unsigned NOT NULL default '0', - `equipinfo1` int(10) unsigned NOT NULL default '0', - `equipinfo2` int(10) unsigned NOT NULL default '0', - `equipinfo3` int(10) unsigned NOT NULL default '0', - `equipslot1` int(11) NOT NULL default '0', - `equipslot2` int(11) NOT NULL default '0', - `equipslot3` int(11) NOT NULL default '0', - PRIMARY KEY (`entry`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Creature System (Equipment)'; - --- --- Dumping data for table `creature_equip_template` --- - -LOCK TABLES `creature_equip_template` WRITE; -/*!40000 ALTER TABLE `creature_equip_template` DISABLE KEYS */; -/*!40000 ALTER TABLE `creature_equip_template` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `creature_involvedrelation` --- - -DROP TABLE IF EXISTS `creature_involvedrelation`; -CREATE TABLE `creature_involvedrelation` ( - `id` mediumint(8) unsigned NOT NULL default '0' COMMENT 'Identifier', - `quest` mediumint(8) unsigned NOT NULL default '0' COMMENT 'Quest Identifier', - PRIMARY KEY (`id`,`quest`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Creature System'; - --- --- Dumping data for table `creature_involvedrelation` --- - -LOCK TABLES `creature_involvedrelation` WRITE; -/*!40000 ALTER TABLE `creature_involvedrelation` DISABLE KEYS */; -/*!40000 ALTER TABLE `creature_involvedrelation` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `creature_loot_template` --- - -DROP TABLE IF EXISTS `creature_loot_template`; -CREATE TABLE `creature_loot_template` ( - `entry` mediumint(8) unsigned NOT NULL default '0', - `item` mediumint(8) unsigned NOT NULL default '0', - `ChanceOrQuestChance` float NOT NULL default '100', - `groupid` tinyint(3) unsigned NOT NULL default '0', - `mincountOrRef` mediumint(9) NOT NULL default '1', - `maxcount` tinyint(3) unsigned NOT NULL default '1', - `lootcondition` tinyint(3) unsigned NOT NULL default '0', - `condition_value1` mediumint(8) unsigned NOT NULL default '0', - `condition_value2` mediumint(8) unsigned NOT NULL default '0', - PRIMARY KEY (`entry`,`item`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Loot System'; - --- --- Dumping data for table `creature_loot_template` --- - -LOCK TABLES `creature_loot_template` WRITE; -/*!40000 ALTER TABLE `creature_loot_template` DISABLE KEYS */; -/*!40000 ALTER TABLE `creature_loot_template` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `creature_model_info` --- - -DROP TABLE IF EXISTS `creature_model_info`; -CREATE TABLE `creature_model_info` ( - `modelid` mediumint(8) unsigned NOT NULL default '0', - `bounding_radius` float NOT NULL default '0', - `combat_reach` float NOT NULL default '0', - `gender` tinyint(3) unsigned NOT NULL default '2', - `modelid_other_gender` mediumint(8) unsigned NOT NULL default '0', - PRIMARY KEY (`modelid`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Creature System (Model related info)'; - --- --- Dumping data for table `creature_model_info` --- - -LOCK TABLES `creature_model_info` WRITE; -/*!40000 ALTER TABLE `creature_model_info` DISABLE KEYS */; -/*!40000 ALTER TABLE `creature_model_info` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `creature_movement` --- - -DROP TABLE IF EXISTS `creature_movement`; -CREATE TABLE `creature_movement` ( - `id` int(10) unsigned NOT NULL COMMENT 'Creature GUID', - `point` mediumint(8) unsigned NOT NULL default '0', - `position_x` float NOT NULL default '0', - `position_y` float NOT NULL default '0', - `position_z` float NOT NULL default '0', - `waittime` int(10) unsigned NOT NULL default '0', - `text1` text, - `text2` text, - `text3` text, - `text4` text, - `text5` text, - `emote` mediumint(8) unsigned NOT NULL default '0', - `spell` mediumint(8) unsigned NOT NULL default '0', - `wpguid` int(11) NOT NULL default '0', - `orientation` float NOT NULL default '0', - `model1` mediumint(9) NOT NULL default '0', - `model2` mediumint(9) NOT NULL default '0', - PRIMARY KEY (`id`,`point`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Creature System'; - --- --- Dumping data for table `creature_movement` --- - -LOCK TABLES `creature_movement` WRITE; -/*!40000 ALTER TABLE `creature_movement` DISABLE KEYS */; -/*!40000 ALTER TABLE `creature_movement` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `creature_onkill_reputation` --- - -DROP TABLE IF EXISTS `creature_onkill_reputation`; -CREATE TABLE `creature_onkill_reputation` ( - `creature_id` mediumint(8) unsigned NOT NULL default '0' COMMENT 'Creature Identifier', - `RewOnKillRepFaction1` smallint(6) NOT NULL default '0', - `RewOnKillRepFaction2` smallint(6) NOT NULL default '0', - `MaxStanding1` tinyint(4) NOT NULL default '0', - `IsTeamAward1` tinyint(4) NOT NULL default '0', - `RewOnKillRepValue1` mediumint(9) NOT NULL default '0', - `MaxStanding2` tinyint(4) NOT NULL default '0', - `IsTeamAward2` tinyint(4) NOT NULL default '0', - `RewOnKillRepValue2` mediumint(9) NOT NULL default '0', - `TeamDependent` tinyint(3) unsigned NOT NULL default '0', - PRIMARY KEY (`creature_id`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='Creature OnKill Reputation gain'; - --- --- Dumping data for table `creature_onkill_reputation` --- - -LOCK TABLES `creature_onkill_reputation` WRITE; -/*!40000 ALTER TABLE `creature_onkill_reputation` DISABLE KEYS */; -/*!40000 ALTER TABLE `creature_onkill_reputation` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `creature_questrelation` --- - -DROP TABLE IF EXISTS `creature_questrelation`; -CREATE TABLE `creature_questrelation` ( - `id` mediumint(8) unsigned NOT NULL default '0' COMMENT 'Identifier', - `quest` mediumint(8) unsigned NOT NULL default '0' COMMENT 'Quest Identifier', - PRIMARY KEY (`id`,`quest`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Creature System'; - --- --- Dumping data for table `creature_questrelation` --- - -LOCK TABLES `creature_questrelation` WRITE; -/*!40000 ALTER TABLE `creature_questrelation` DISABLE KEYS */; -/*!40000 ALTER TABLE `creature_questrelation` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `creature_respawn` --- - -DROP TABLE IF EXISTS `creature_respawn`; -CREATE TABLE `creature_respawn` ( - `guid` int(10) unsigned NOT NULL default '0' COMMENT 'Global Unique Identifier', - `respawntime` bigint(20) NOT NULL default '0', - `instance` mediumint(8) unsigned NOT NULL default '0', - PRIMARY KEY (`guid`,`instance`), - KEY `instance` (`instance`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='Grid Loading System'; - --- --- Dumping data for table `creature_respawn` --- - -LOCK TABLES `creature_respawn` WRITE; -/*!40000 ALTER TABLE `creature_respawn` DISABLE KEYS */; -/*!40000 ALTER TABLE `creature_respawn` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `creature_template` --- - -DROP TABLE IF EXISTS `creature_template`; -CREATE TABLE `creature_template` ( - `entry` mediumint(8) unsigned NOT NULL default '0', - `heroic_entry` mediumint(8) unsigned NOT NULL default '0', - `modelid_A` mediumint(8) unsigned NOT NULL default '0', - `modelid_A2` mediumint(8) unsigned NOT NULL default '0', - `modelid_H` mediumint(8) unsigned NOT NULL default '0', - `modelid_H2` mediumint(8) unsigned NOT NULL default '0', - `name` char(100) NOT NULL default '0', - `subname` char(100) default NULL, - `IconName` char(100) default NULL, - `minlevel` tinyint(3) unsigned NOT NULL default '1', - `maxlevel` tinyint(3) unsigned NOT NULL default '1', - `minhealth` int(10) unsigned NOT NULL default '0', - `maxhealth` int(10) unsigned NOT NULL default '0', - `minmana` int(10) unsigned NOT NULL default '0', - `maxmana` int(10) unsigned NOT NULL default '0', - `armor` mediumint(8) unsigned NOT NULL default '0', - `faction_A` smallint(5) unsigned NOT NULL default '0', - `faction_H` smallint(5) unsigned NOT NULL default '0', - `npcflag` int(10) unsigned NOT NULL default '0', - `speed` float NOT NULL default '1', - `scale` float NOT NULL default '1', - `rank` tinyint(3) unsigned NOT NULL default '0', - `mindmg` float NOT NULL default '0', - `maxdmg` float NOT NULL default '0', - `dmgschool` tinyint(4) NOT NULL default '0', - `attackpower` int(10) unsigned NOT NULL default '0', - `baseattacktime` int(10) unsigned NOT NULL default '0', - `rangeattacktime` int(10) unsigned NOT NULL default '0', - `flags` int(10) unsigned NOT NULL default '0', - `dynamicflags` int(10) unsigned NOT NULL default '0', - `family` tinyint(4) NOT NULL default '0', - `trainer_type` tinyint(4) NOT NULL default '0', - `trainer_spell` mediumint(8) unsigned NOT NULL default '0', - `class` tinyint(3) unsigned NOT NULL default '0', - `race` tinyint(3) unsigned NOT NULL default '0', - `minrangedmg` float NOT NULL default '0', - `maxrangedmg` float NOT NULL default '0', - `rangedattackpower` smallint(5) unsigned NOT NULL default '0', - `type` tinyint(3) unsigned NOT NULL default '0', - `flag1` int(10) unsigned NOT NULL default '0', - `lootid` mediumint(8) unsigned NOT NULL default '0', - `pickpocketloot` mediumint(8) unsigned NOT NULL default '0', - `skinloot` mediumint(8) unsigned NOT NULL default '0', - `resistance1` smallint(5) NOT NULL default '0', - `resistance2` smallint(5) NOT NULL default '0', - `resistance3` smallint(5) NOT NULL default '0', - `resistance4` smallint(5) NOT NULL default '0', - `resistance5` smallint(5) NOT NULL default '0', - `resistance6` smallint(5) NOT NULL default '0', - `spell1` mediumint(8) unsigned NOT NULL default '0', - `spell2` mediumint(8) unsigned NOT NULL default '0', - `spell3` mediumint(8) unsigned NOT NULL default '0', - `spell4` mediumint(8) unsigned NOT NULL default '0', - `PetSpellDataId` mediumint(8) unsigned NOT NULL default '0', - `mingold` mediumint(8) unsigned NOT NULL default '0', - `maxgold` mediumint(8) unsigned NOT NULL default '0', - `AIName` char(64) NOT NULL default '', - `MovementType` tinyint(3) unsigned NOT NULL default '0', - `InhabitType` tinyint(3) unsigned NOT NULL default '3', - `RacialLeader` tinyint(3) unsigned NOT NULL default '0', - `RegenHealth` tinyint(3) unsigned NOT NULL default '1', - `equipment_id` mediumint(8) unsigned NOT NULL default '0', - `mechanic_immune_mask` int(10) unsigned NOT NULL default '0', - `flags_extra` int(10) unsigned NOT NULL default '0', - `ScriptName` char(64) NOT NULL default '', - PRIMARY KEY (`entry`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Creature System'; - --- --- Dumping data for table `creature_template` --- - -LOCK TABLES `creature_template` WRITE; -/*!40000 ALTER TABLE `creature_template` DISABLE KEYS */; -INSERT INTO `creature_template` VALUES -(1,1,10045,0,10045,0,'Waypoint(Only GM can see it)','Visual',NULL,1,1,64,64,0,0,0,35,35,0,0.91,1,0,14,15,0,100,2000,2200,4096,0,8,0,0,0,0,1.76,2.42,100,8,5242886,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,3,0,1,0,0,2,''); -/*!40000 ALTER TABLE `creature_template` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `creature_template_addon` --- - -DROP TABLE IF EXISTS `creature_template_addon`; -CREATE TABLE `creature_template_addon` ( - `entry` mediumint(8) unsigned NOT NULL default '0', - `mount` mediumint(8) unsigned NOT NULL default '0', - `bytes0` int(10) unsigned NOT NULL default '0', - `bytes1` int(10) unsigned NOT NULL default '0', - `bytes2` int(10) unsigned NOT NULL default '0', - `emote` mediumint(8) unsigned NOT NULL default '0', - `moveflags` int(10) unsigned NOT NULL default '0', - `auras` text, - PRIMARY KEY (`entry`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8; - --- --- Dumping data for table `creature_template_addon` --- - -LOCK TABLES `creature_template_addon` WRITE; -/*!40000 ALTER TABLE `creature_template_addon` DISABLE KEYS */; -/*!40000 ALTER TABLE `creature_template_addon` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `db_version` --- - -DROP TABLE IF EXISTS `db_version`; -CREATE TABLE `db_version` ( - `version` varchar(120) default NULL -) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Used DB version notes'; - --- --- Dumping data for table `db_version` --- - -LOCK TABLES `db_version` WRITE; -/*!40000 ALTER TABLE `db_version` DISABLE KEYS */; -INSERT INTO `db_version` VALUES -('Mangos default database.'); -/*!40000 ALTER TABLE `db_version` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `disenchant_loot_template` --- - -DROP TABLE IF EXISTS `disenchant_loot_template`; -CREATE TABLE `disenchant_loot_template` ( - `entry` mediumint(8) unsigned NOT NULL default '0' COMMENT 'Recommended id selection: item_level*100 + item_quality', - `item` mediumint(8) unsigned NOT NULL default '0', - `ChanceOrQuestChance` float NOT NULL default '100', - `groupid` tinyint(3) unsigned NOT NULL default '0', - `mincountOrRef` mediumint(9) NOT NULL default '1', - `maxcount` tinyint(3) unsigned NOT NULL default '1', - `lootcondition` tinyint(3) unsigned NOT NULL default '0', - `condition_value1` mediumint(8) unsigned NOT NULL default '0', - `condition_value2` mediumint(8) unsigned NOT NULL default '0', - PRIMARY KEY (`entry`,`item`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Loot System'; - --- --- Dumping data for table `disenchant_loot_template` --- - -LOCK TABLES `disenchant_loot_template` WRITE; -/*!40000 ALTER TABLE `disenchant_loot_template` DISABLE KEYS */; -/*!40000 ALTER TABLE `disenchant_loot_template` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `event_scripts` --- - -DROP TABLE IF EXISTS `event_scripts`; -CREATE TABLE `event_scripts` ( - `id` mediumint(8) unsigned NOT NULL default '0', - `delay` int(10) unsigned NOT NULL default '0', - `command` mediumint(8) unsigned NOT NULL default '0', - `datalong` mediumint(8) unsigned NOT NULL default '0', - `datalong2` int(10) unsigned NOT NULL default '0', - `datatext` text NOT NULL, - `x` float NOT NULL default '0', - `y` float NOT NULL default '0', - `z` float NOT NULL default '0', - `o` float NOT NULL default '0' -) ENGINE=MyISAM DEFAULT CHARSET=utf8; - --- --- Dumping data for table `event_scripts` --- - -LOCK TABLES `event_scripts` WRITE; -/*!40000 ALTER TABLE `event_scripts` DISABLE KEYS */; -/*!40000 ALTER TABLE `event_scripts` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `exploration_basexp` --- - -DROP TABLE IF EXISTS `exploration_basexp`; -CREATE TABLE `exploration_basexp` ( - `level` tinyint(4) NOT NULL default '0', - `basexp` mediumint(9) NOT NULL default '0', - PRIMARY KEY (`level`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Exploration System'; - --- --- Dumping data for table `exploration_basexp` --- - -LOCK TABLES `exploration_basexp` WRITE; -/*!40000 ALTER TABLE `exploration_basexp` DISABLE KEYS */; -INSERT INTO `exploration_basexp` VALUES -(0,0), -(1,5), -(2,15), -(3,25), -(4,35), -(5,45), -(6,55), -(7,65), -(8,70), -(9,80), -(10,85), -(11,90), -(12,90), -(13,90), -(14,100), -(15,105), -(16,115), -(17,125), -(18,135), -(19,145), -(20,155), -(21,165), -(22,175), -(23,185), -(24,195), -(25,200), -(26,210), -(27,220), -(28,230), -(29,240), -(30,245), -(31,250), -(32,255), -(33,265), -(34,270), -(35,275), -(36,280), -(37,285), -(38,285), -(39,300), -(40,315), -(41,330), -(42,345), -(43,360), -(44,375), -(45,390), -(46,405), -(47,420), -(48,440), -(49,455), -(50,470), -(51,490), -(52,510), -(53,530), -(54,540), -(55,560), -(56,580), -(57,600), -(58,620), -(59,640), -(60,660), -(61,970), -(62,1000), -(63,1050), -(64,1080), -(65,1100), -(66,1130), -(67,1160), -(68,1200), -(69,1230), -(70,1250); -/*!40000 ALTER TABLE `exploration_basexp` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `fishing_loot_template` --- - -DROP TABLE IF EXISTS `fishing_loot_template`; -CREATE TABLE `fishing_loot_template` ( - `entry` mediumint(8) unsigned NOT NULL default '0', - `item` mediumint(8) unsigned NOT NULL default '0', - `ChanceOrQuestChance` float NOT NULL default '100', - `groupid` tinyint(3) unsigned NOT NULL default '0', - `mincountOrRef` mediumint(9) NOT NULL default '1', - `maxcount` tinyint(3) unsigned NOT NULL default '1', - `lootcondition` tinyint(3) unsigned NOT NULL default '0', - `condition_value1` mediumint(8) unsigned NOT NULL default '0', - `condition_value2` mediumint(8) unsigned NOT NULL default '0', - PRIMARY KEY (`entry`,`item`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Loot System'; - --- --- Dumping data for table `fishing_loot_template` --- - -LOCK TABLES `fishing_loot_template` WRITE; -/*!40000 ALTER TABLE `fishing_loot_template` DISABLE KEYS */; -/*!40000 ALTER TABLE `fishing_loot_template` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `game_event` --- - -DROP TABLE IF EXISTS `game_event`; -CREATE TABLE `game_event` ( - `entry` mediumint(8) unsigned NOT NULL COMMENT 'Entry of the game event', - `start_time` timestamp NOT NULL default '0000-00-00 00:00:00' COMMENT 'Absolute start date, the event will never start before', - `end_time` timestamp NOT NULL default '0000-00-00 00:00:00' COMMENT 'Absolute end date, the event will never start afler', - `occurence` bigint(20) unsigned NOT NULL default '86400' COMMENT 'Delay in hours between occurences of the event', - `length` bigint(20) unsigned NOT NULL default '43200' COMMENT 'Length in hours of the event', - `description` varchar(255) default NULL COMMENT 'Description of the event displayed in console', - PRIMARY KEY (`entry`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8; - --- --- Dumping data for table `game_event` --- - -LOCK TABLES `game_event` WRITE; -/*!40000 ALTER TABLE `game_event` DISABLE KEYS */; -/*!40000 ALTER TABLE `game_event` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `game_event_creature` --- - -DROP TABLE IF EXISTS `game_event_creature`; -CREATE TABLE `game_event_creature` ( - `guid` int(10) unsigned NOT NULL, - `event` smallint(6) NOT NULL default '0' COMMENT 'Put negatives values to remove during event', - PRIMARY KEY (`guid`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8; - --- --- Dumping data for table `game_event_creature` --- - -LOCK TABLES `game_event_creature` WRITE; -/*!40000 ALTER TABLE `game_event_creature` DISABLE KEYS */; -/*!40000 ALTER TABLE `game_event_creature` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `game_event_creature_quest` --- - -DROP TABLE IF EXISTS `game_event_creature_quest`; -CREATE TABLE `game_event_creature_quest` ( - `id` mediumint(8) unsigned NOT NULL default '0', - `quest` mediumint(8) unsigned NOT NULL default '0', - `event` smallint(5) unsigned NOT NULL default '0', - PRIMARY KEY (`id`,`quest`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8; - --- --- Dumping data for table `game_event_creature_quest` --- - -LOCK TABLES `game_event_creature_quest` WRITE; -/*!40000 ALTER TABLE `game_event_creature_quest` DISABLE KEYS */; -/*!40000 ALTER TABLE `game_event_creature_quest` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `game_event_gameobject` --- - -DROP TABLE IF EXISTS `game_event_gameobject`; -CREATE TABLE `game_event_gameobject` ( - `guid` int(10) unsigned NOT NULL, - `event` smallint(6) NOT NULL default '0' COMMENT 'Put negatives values to remove during event', - PRIMARY KEY (`guid`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8; - --- --- Dumping data for table `game_event_gameobject` --- - -LOCK TABLES `game_event_gameobject` WRITE; -/*!40000 ALTER TABLE `game_event_gameobject` DISABLE KEYS */; -/*!40000 ALTER TABLE `game_event_gameobject` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `game_event_model_equip` --- - -DROP TABLE IF EXISTS `game_event_model_equip`; -CREATE TABLE `game_event_model_equip` ( - `guid` int(10) unsigned NOT NULL default '0', - `modelid` mediumint(8) unsigned NOT NULL default '0', - `equipment_id` mediumint(8) unsigned NOT NULL default '0', - `event` smallint(5) unsigned NOT NULL default '0', - PRIMARY KEY (`guid`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8; - --- --- Dumping data for table `game_event_model_equip` --- - -LOCK TABLES `game_event_model_equip` WRITE; -/*!40000 ALTER TABLE `game_event_model_equip` DISABLE KEYS */; -/*!40000 ALTER TABLE `game_event_model_equip` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `game_graveyard_zone` --- - -DROP TABLE IF EXISTS `game_graveyard_zone`; -CREATE TABLE `game_graveyard_zone` ( - `id` mediumint(8) unsigned NOT NULL default '0', - `ghost_zone` mediumint(8) unsigned NOT NULL default '0', - `faction` smallint(5) unsigned NOT NULL default '0', - PRIMARY KEY (`id`,`ghost_zone`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Trigger System'; - --- --- Dumping data for table `game_graveyard_zone` --- - -LOCK TABLES `game_graveyard_zone` WRITE; -/*!40000 ALTER TABLE `game_graveyard_zone` DISABLE KEYS */; -/*!40000 ALTER TABLE `game_graveyard_zone` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `game_tele` --- - -DROP TABLE IF EXISTS `game_tele`; -CREATE TABLE `game_tele` ( - `id` mediumint(8) unsigned NOT NULL auto_increment, - `position_x` float NOT NULL default '0', - `position_y` float NOT NULL default '0', - `position_z` float NOT NULL default '0', - `orientation` float NOT NULL default '0', - `map` smallint(5) unsigned NOT NULL default '0', - `name` varchar(100) NOT NULL default '', - PRIMARY KEY (`id`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Tele Command'; - --- --- Dumping data for table `game_tele` --- - -LOCK TABLES `game_tele` WRITE; -/*!40000 ALTER TABLE `game_tele` DISABLE KEYS */; -/*!40000 ALTER TABLE `game_tele` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `game_weather` --- - -DROP TABLE IF EXISTS `game_weather`; -CREATE TABLE `game_weather` ( - `zone` mediumint(8) unsigned NOT NULL default '0', - `spring_rain_chance` tinyint(3) unsigned NOT NULL default '25', - `spring_snow_chance` tinyint(3) unsigned NOT NULL default '25', - `spring_storm_chance` tinyint(3) unsigned NOT NULL default '25', - `summer_rain_chance` tinyint(3) unsigned NOT NULL default '25', - `summer_snow_chance` tinyint(3) unsigned NOT NULL default '25', - `summer_storm_chance` tinyint(3) unsigned NOT NULL default '25', - `fall_rain_chance` tinyint(3) unsigned NOT NULL default '25', - `fall_snow_chance` tinyint(3) unsigned NOT NULL default '25', - `fall_storm_chance` tinyint(3) unsigned NOT NULL default '25', - `winter_rain_chance` tinyint(3) unsigned NOT NULL default '25', - `winter_snow_chance` tinyint(3) unsigned NOT NULL default '25', - `winter_storm_chance` tinyint(3) unsigned NOT NULL default '25', - PRIMARY KEY (`zone`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Weather System'; - --- --- Dumping data for table `game_weather` --- - -LOCK TABLES `game_weather` WRITE; -/*!40000 ALTER TABLE `game_weather` DISABLE KEYS */; -/*!40000 ALTER TABLE `game_weather` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `gameobject` --- - -DROP TABLE IF EXISTS `gameobject`; -CREATE TABLE `gameobject` ( - `guid` int(10) unsigned NOT NULL auto_increment COMMENT 'Global Unique Identifier', - `id` mediumint(8) unsigned NOT NULL default '0' COMMENT 'Gameobject Identifier', - `map` smallint(5) unsigned NOT NULL default '0' COMMENT 'Map Identifier', - `spawnMask` tinyint(3) unsigned NOT NULL default '1', - `position_x` float NOT NULL default '0', - `position_y` float NOT NULL default '0', - `position_z` float NOT NULL default '0', - `orientation` float NOT NULL default '0', - `rotation0` float NOT NULL default '0', - `rotation1` float NOT NULL default '0', - `rotation2` float NOT NULL default '0', - `rotation3` float NOT NULL default '0', - `spawntimesecs` int(11) NOT NULL default '0', - `animprogress` tinyint(3) unsigned NOT NULL default '0', - `state` tinyint(3) unsigned NOT NULL default '0', - PRIMARY KEY (`guid`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Gameobject System'; - --- --- Dumping data for table `gameobject` --- - -LOCK TABLES `gameobject` WRITE; -/*!40000 ALTER TABLE `gameobject` DISABLE KEYS */; -/*!40000 ALTER TABLE `gameobject` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `gameobject_involvedrelation` --- - -DROP TABLE IF EXISTS `gameobject_involvedrelation`; -CREATE TABLE `gameobject_involvedrelation` ( - `id` mediumint(8) unsigned NOT NULL default '0', - `quest` mediumint(8) unsigned NOT NULL default '0' COMMENT 'Quest Identifier', - PRIMARY KEY (`id`,`quest`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8; - --- --- Dumping data for table `gameobject_involvedrelation` --- - -LOCK TABLES `gameobject_involvedrelation` WRITE; -/*!40000 ALTER TABLE `gameobject_involvedrelation` DISABLE KEYS */; -/*!40000 ALTER TABLE `gameobject_involvedrelation` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `gameobject_loot_template` --- - -DROP TABLE IF EXISTS `gameobject_loot_template`; -CREATE TABLE `gameobject_loot_template` ( - `entry` mediumint(8) unsigned NOT NULL default '0', - `item` mediumint(8) unsigned NOT NULL default '0', - `ChanceOrQuestChance` float NOT NULL default '100', - `groupid` tinyint(3) unsigned NOT NULL default '0', - `mincountOrRef` mediumint(9) NOT NULL default '1', - `maxcount` tinyint(3) unsigned NOT NULL default '1', - `lootcondition` tinyint(3) unsigned NOT NULL default '0', - `condition_value1` mediumint(8) unsigned NOT NULL default '0', - `condition_value2` mediumint(8) unsigned NOT NULL default '0', - PRIMARY KEY (`entry`,`item`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Loot System'; - --- --- Dumping data for table `gameobject_loot_template` --- - -LOCK TABLES `gameobject_loot_template` WRITE; -/*!40000 ALTER TABLE `gameobject_loot_template` DISABLE KEYS */; -/*!40000 ALTER TABLE `gameobject_loot_template` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `gameobject_questrelation` --- - -DROP TABLE IF EXISTS `gameobject_questrelation`; -CREATE TABLE `gameobject_questrelation` ( - `id` mediumint(8) unsigned NOT NULL default '0', - `quest` mediumint(8) unsigned NOT NULL default '0' COMMENT 'Quest Identifier', - PRIMARY KEY (`id`,`quest`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8; - --- --- Dumping data for table `gameobject_questrelation` --- - -LOCK TABLES `gameobject_questrelation` WRITE; -/*!40000 ALTER TABLE `gameobject_questrelation` DISABLE KEYS */; -/*!40000 ALTER TABLE `gameobject_questrelation` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `gameobject_respawn` --- - -DROP TABLE IF EXISTS `gameobject_respawn`; -CREATE TABLE `gameobject_respawn` ( - `guid` int(10) unsigned NOT NULL default '0' COMMENT 'Global Unique Identifier', - `respawntime` bigint(20) NOT NULL default '0', - `instance` mediumint(8) unsigned NOT NULL default '0', - PRIMARY KEY (`guid`,`instance`), - KEY `instance` (`instance`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='Grid Loading System'; - --- --- Dumping data for table `gameobject_respawn` --- - -LOCK TABLES `gameobject_respawn` WRITE; -/*!40000 ALTER TABLE `gameobject_respawn` DISABLE KEYS */; -/*!40000 ALTER TABLE `gameobject_respawn` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `gameobject_scripts` --- - -DROP TABLE IF EXISTS `gameobject_scripts`; -CREATE TABLE `gameobject_scripts` ( - `id` mediumint(8) unsigned NOT NULL default '0', - `delay` int(10) unsigned NOT NULL default '0', - `command` mediumint(8) unsigned NOT NULL default '0', - `datalong` mediumint(8) unsigned NOT NULL default '0', - `datalong2` int(10) unsigned NOT NULL default '0', - `datatext` text NOT NULL, - `x` float NOT NULL default '0', - `y` float NOT NULL default '0', - `z` float NOT NULL default '0', - `o` float NOT NULL default '0' -) ENGINE=MyISAM DEFAULT CHARSET=utf8; - --- --- Dumping data for table `gameobject_scripts` --- - -LOCK TABLES `gameobject_scripts` WRITE; -/*!40000 ALTER TABLE `gameobject_scripts` DISABLE KEYS */; -/*!40000 ALTER TABLE `gameobject_scripts` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `gameobject_template` --- - -DROP TABLE IF EXISTS `gameobject_template`; -CREATE TABLE `gameobject_template` ( - `entry` mediumint(8) unsigned NOT NULL default '0', - `type` tinyint(3) unsigned NOT NULL default '0', - `displayId` mediumint(8) unsigned NOT NULL default '0', - `name` varchar(100) NOT NULL default '', - `castBarCaption` varchar(100) NOT NULL default '', - `faction` smallint(5) unsigned NOT NULL default '0', - `flags` int(10) unsigned NOT NULL default '0', - `size` float NOT NULL default '1', - `data0` int(10) unsigned NOT NULL default '0', - `data1` int(10) unsigned NOT NULL default '0', - `data2` int(10) unsigned NOT NULL default '0', - `data3` int(10) unsigned NOT NULL default '0', - `data4` int(10) unsigned NOT NULL default '0', - `data5` int(10) unsigned NOT NULL default '0', - `data6` int(10) unsigned NOT NULL default '0', - `data7` int(10) unsigned NOT NULL default '0', - `data8` int(10) unsigned NOT NULL default '0', - `data9` int(10) unsigned NOT NULL default '0', - `data10` int(10) unsigned NOT NULL default '0', - `data11` int(10) unsigned NOT NULL default '0', - `data12` int(10) unsigned NOT NULL default '0', - `data13` int(10) unsigned NOT NULL default '0', - `data14` int(10) unsigned NOT NULL default '0', - `data15` int(10) unsigned NOT NULL default '0', - `data16` int(10) unsigned NOT NULL default '0', - `data17` int(10) unsigned NOT NULL default '0', - `data18` int(10) unsigned NOT NULL default '0', - `data19` int(10) unsigned NOT NULL default '0', - `data20` int(10) unsigned NOT NULL default '0', - `data21` int(10) unsigned NOT NULL default '0', - `data22` int(10) unsigned NOT NULL default '0', - `data23` int(10) unsigned NOT NULL default '0', - `ScriptName` varchar(64) NOT NULL default '', - PRIMARY KEY (`entry`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Gameobject System'; - --- --- Dumping data for table `gameobject_template` --- - -LOCK TABLES `gameobject_template` WRITE; -/*!40000 ALTER TABLE `gameobject_template` DISABLE KEYS */; -/*!40000 ALTER TABLE `gameobject_template` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `instance_template` --- - -DROP TABLE IF EXISTS `instance_template`; -CREATE TABLE `instance_template` ( - `map` smallint(5) unsigned NOT NULL, - `parent` int(10) unsigned NOT NULL, - `levelMin` tinyint(3) unsigned NOT NULL default '0', - `levelMax` tinyint(3) unsigned NOT NULL default '0', - `maxPlayers` tinyint(3) unsigned NOT NULL default '0', - `reset_delay` int(10) unsigned NOT NULL default '0', - `startLocX` float default NULL, - `startLocY` float default NULL, - `startLocZ` float default NULL, - `startLocO` float default NULL, - `script` varchar(128) NOT NULL default '', - PRIMARY KEY (`map`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8; - --- --- Dumping data for table `instance_template` --- - -LOCK TABLES `instance_template` WRITE; -/*!40000 ALTER TABLE `instance_template` DISABLE KEYS */; -INSERT INTO `instance_template` VALUES -(33,0,22,30,10,7200,NULL,NULL,NULL,NULL,''), -(34,0,24,32,10,7200,NULL,NULL,NULL,NULL,''), -(36,0,15,20,10,7200,NULL,NULL,NULL,NULL,''), -(43,0,15,21,10,7200,NULL,NULL,NULL,NULL,''), -(47,0,29,38,10,7200,NULL,NULL,NULL,NULL,''), -(48,0,24,32,10,7200,NULL,NULL,NULL,NULL,''), -(70,0,35,47,10,7200,NULL,NULL,NULL,NULL,''), -(90,0,29,38,10,7200,NULL,NULL,NULL,NULL,''), -(109,0,45,55,10,7200,NULL,NULL,NULL,NULL,''), -(129,0,37,46,10,7200,NULL,NULL,NULL,NULL,''), -(189,0,34,45,10,7200,NULL,NULL,NULL,NULL,''), -(209,0,44,54,10,7200,NULL,NULL,NULL,NULL,''), -(229,0,58,0,10,120000,78.5083,-225.044,49.839,5.1,''), -(230,0,52,0,5,7200,NULL,NULL,NULL,NULL,''), -(249,0,60,0,40,432000,NULL,NULL,NULL,NULL,''), -(289,0,57,0,5,7200,NULL,NULL,NULL,NULL,''), -(309,0,60,0,20,259200,NULL,NULL,NULL,NULL,''), -(329,0,58,60,5,7200,NULL,NULL,NULL,NULL,''), -(349,0,46,55,10,7200,NULL,NULL,NULL,NULL,''), -(389,0,13,18,10,7200,NULL,NULL,NULL,NULL,''), -(409,0,60,0,40,604800,NULL,NULL,NULL,NULL,''), -(429,0,55,60,5,7200,NULL,NULL,NULL,NULL,''), -(469,0,60,0,40,604800,NULL,NULL,NULL,NULL,''), -(509,0,60,0,20,259200,NULL,NULL,NULL,NULL,''), -(531,0,60,0,40,604800,NULL,NULL,NULL,NULL,''), -(533,0,60,0,40,604800,NULL,NULL,NULL,NULL,''); -/*!40000 ALTER TABLE `instance_template` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `item_enchantment_template` --- - -DROP TABLE IF EXISTS `item_enchantment_template`; -CREATE TABLE `item_enchantment_template` ( - `entry` mediumint(8) unsigned NOT NULL default '0', - `ench` mediumint(8) unsigned NOT NULL default '0', - `chance` float unsigned NOT NULL default '0', - PRIMARY KEY (`entry`,`ench`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Item Random Enchantment System'; - --- --- Dumping data for table `item_enchantment_template` --- - -LOCK TABLES `item_enchantment_template` WRITE; -/*!40000 ALTER TABLE `item_enchantment_template` DISABLE KEYS */; -/*!40000 ALTER TABLE `item_enchantment_template` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `item_loot_template` --- - -DROP TABLE IF EXISTS `item_loot_template`; -CREATE TABLE `item_loot_template` ( - `entry` mediumint(8) unsigned NOT NULL default '0', - `item` mediumint(8) unsigned NOT NULL default '0', - `ChanceOrQuestChance` float NOT NULL default '100', - `groupid` tinyint(3) unsigned NOT NULL default '0', - `mincountOrRef` mediumint(9) NOT NULL default '1', - `maxcount` tinyint(3) unsigned NOT NULL default '1', - `lootcondition` tinyint(3) unsigned NOT NULL default '0', - `condition_value1` mediumint(8) unsigned NOT NULL default '0', - `condition_value2` mediumint(8) unsigned NOT NULL default '0', - PRIMARY KEY (`entry`,`item`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Loot System'; - --- --- Dumping data for table `item_loot_template` --- - -LOCK TABLES `item_loot_template` WRITE; -/*!40000 ALTER TABLE `item_loot_template` DISABLE KEYS */; -/*!40000 ALTER TABLE `item_loot_template` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `item_template` --- - -DROP TABLE IF EXISTS `item_template`; -CREATE TABLE `item_template` ( - `entry` mediumint(8) unsigned NOT NULL default '0', - `class` tinyint(3) unsigned NOT NULL default '0', - `subclass` tinyint(3) unsigned NOT NULL default '0', - `unk0` int(11) NOT NULL default '-1', - `name` varchar(255) NOT NULL default '', - `displayid` mediumint(8) unsigned NOT NULL default '0', - `Quality` tinyint(3) unsigned NOT NULL default '0', - `Flags` int(10) unsigned NOT NULL default '0', - `BuyCount` tinyint(3) unsigned NOT NULL default '1', - `BuyPrice` int(10) unsigned NOT NULL default '0', - `SellPrice` int(10) unsigned NOT NULL default '0', - `InventoryType` tinyint(3) unsigned NOT NULL default '0', - `AllowableClass` mediumint(9) NOT NULL default '-1', - `AllowableRace` mediumint(9) NOT NULL default '-1', - `ItemLevel` tinyint(3) unsigned NOT NULL default '0', - `RequiredLevel` tinyint(3) unsigned NOT NULL default '0', - `RequiredSkill` smallint(5) unsigned NOT NULL default '0', - `RequiredSkillRank` smallint(5) unsigned NOT NULL default '0', - `requiredspell` mediumint(8) unsigned NOT NULL default '0', - `requiredhonorrank` mediumint(8) unsigned NOT NULL default '0', - `RequiredCityRank` mediumint(8) unsigned NOT NULL default '0', - `RequiredReputationFaction` smallint(5) unsigned NOT NULL default '0', - `RequiredReputationRank` smallint(5) unsigned NOT NULL default '0', - `maxcount` smallint(5) unsigned NOT NULL default '0', - `stackable` smallint(5) unsigned NOT NULL default '1', - `ContainerSlots` tinyint(3) unsigned NOT NULL default '0', - `stat_type1` tinyint(3) unsigned NOT NULL default '0', - `stat_value1` smallint(6) NOT NULL default '0', - `stat_type2` tinyint(3) unsigned NOT NULL default '0', - `stat_value2` smallint(6) NOT NULL default '0', - `stat_type3` tinyint(3) unsigned NOT NULL default '0', - `stat_value3` smallint(6) NOT NULL default '0', - `stat_type4` tinyint(3) unsigned NOT NULL default '0', - `stat_value4` smallint(6) NOT NULL default '0', - `stat_type5` tinyint(3) unsigned NOT NULL default '0', - `stat_value5` smallint(6) NOT NULL default '0', - `stat_type6` tinyint(3) unsigned NOT NULL default '0', - `stat_value6` smallint(6) NOT NULL default '0', - `stat_type7` tinyint(3) unsigned NOT NULL default '0', - `stat_value7` smallint(6) NOT NULL default '0', - `stat_type8` tinyint(3) unsigned NOT NULL default '0', - `stat_value8` smallint(6) NOT NULL default '0', - `stat_type9` tinyint(3) unsigned NOT NULL default '0', - `stat_value9` smallint(6) NOT NULL default '0', - `stat_type10` tinyint(3) unsigned NOT NULL default '0', - `stat_value10` smallint(6) NOT NULL default '0', - `dmg_min1` float NOT NULL default '0', - `dmg_max1` float NOT NULL default '0', - `dmg_type1` tinyint(3) unsigned NOT NULL default '0', - `dmg_min2` float NOT NULL default '0', - `dmg_max2` float NOT NULL default '0', - `dmg_type2` tinyint(3) unsigned NOT NULL default '0', - `dmg_min3` float NOT NULL default '0', - `dmg_max3` float NOT NULL default '0', - `dmg_type3` tinyint(3) unsigned NOT NULL default '0', - `dmg_min4` float NOT NULL default '0', - `dmg_max4` float NOT NULL default '0', - `dmg_type4` tinyint(3) unsigned NOT NULL default '0', - `dmg_min5` float NOT NULL default '0', - `dmg_max5` float NOT NULL default '0', - `dmg_type5` tinyint(3) unsigned NOT NULL default '0', - `armor` smallint(5) unsigned NOT NULL default '0', - `holy_res` tinyint(3) unsigned NOT NULL default '0', - `fire_res` tinyint(3) unsigned NOT NULL default '0', - `nature_res` tinyint(3) unsigned NOT NULL default '0', - `frost_res` tinyint(3) unsigned NOT NULL default '0', - `shadow_res` tinyint(3) unsigned NOT NULL default '0', - `arcane_res` tinyint(3) unsigned NOT NULL default '0', - `delay` smallint(5) unsigned NOT NULL default '1000', - `ammo_type` tinyint(3) unsigned NOT NULL default '0', - `RangedModRange` float NOT NULL default '0', - `spellid_1` mediumint(8) unsigned NOT NULL default '0', - `spelltrigger_1` tinyint(3) unsigned NOT NULL default '0', - `spellcharges_1` tinyint(4) NOT NULL default '0', - `spellppmRate_1` float NOT NULL default '0', - `spellcooldown_1` int(11) NOT NULL default '-1', - `spellcategory_1` smallint(5) unsigned NOT NULL default '0', - `spellcategorycooldown_1` int(11) NOT NULL default '-1', - `spellid_2` mediumint(8) unsigned NOT NULL default '0', - `spelltrigger_2` tinyint(3) unsigned NOT NULL default '0', - `spellcharges_2` tinyint(4) NOT NULL default '0', - `spellppmRate_2` float NOT NULL default '0', - `spellcooldown_2` int(11) NOT NULL default '-1', - `spellcategory_2` smallint(5) unsigned NOT NULL default '0', - `spellcategorycooldown_2` int(11) NOT NULL default '-1', - `spellid_3` mediumint(8) unsigned NOT NULL default '0', - `spelltrigger_3` tinyint(3) unsigned NOT NULL default '0', - `spellcharges_3` tinyint(4) NOT NULL default '0', - `spellppmRate_3` float NOT NULL default '0', - `spellcooldown_3` int(11) NOT NULL default '-1', - `spellcategory_3` smallint(5) unsigned NOT NULL default '0', - `spellcategorycooldown_3` int(11) NOT NULL default '-1', - `spellid_4` mediumint(8) unsigned NOT NULL default '0', - `spelltrigger_4` tinyint(3) unsigned NOT NULL default '0', - `spellcharges_4` tinyint(4) NOT NULL default '0', - `spellppmRate_4` float NOT NULL default '0', - `spellcooldown_4` int(11) NOT NULL default '-1', - `spellcategory_4` smallint(5) unsigned NOT NULL default '0', - `spellcategorycooldown_4` int(11) NOT NULL default '-1', - `spellid_5` mediumint(8) unsigned NOT NULL default '0', - `spelltrigger_5` tinyint(3) unsigned NOT NULL default '0', - `spellcharges_5` tinyint(4) NOT NULL default '0', - `spellppmRate_5` float NOT NULL default '0', - `spellcooldown_5` int(11) NOT NULL default '-1', - `spellcategory_5` smallint(5) unsigned NOT NULL default '0', - `spellcategorycooldown_5` int(11) NOT NULL default '-1', - `bonding` tinyint(3) unsigned NOT NULL default '0', - `description` varchar(255) NOT NULL default '', - `PageText` mediumint(8) unsigned NOT NULL default '0', - `LanguageID` tinyint(3) unsigned NOT NULL default '0', - `PageMaterial` tinyint(3) unsigned NOT NULL default '0', - `startquest` mediumint(8) unsigned NOT NULL default '0', - `lockid` mediumint(8) unsigned NOT NULL default '0', - `Material` tinyint(4) NOT NULL default '0', - `sheath` tinyint(3) unsigned NOT NULL default '0', - `RandomProperty` mediumint(8) unsigned NOT NULL default '0', - `RandomSuffix` mediumint(8) unsigned NOT NULL default '0', - `block` mediumint(8) unsigned NOT NULL default '0', - `itemset` mediumint(8) unsigned NOT NULL default '0', - `MaxDurability` smallint(5) unsigned NOT NULL default '0', - `area` mediumint(8) unsigned NOT NULL default '0', - `Map` smallint(6) NOT NULL default '0', - `BagFamily` mediumint(9) NOT NULL default '0', - `TotemCategory` tinyint(4) NOT NULL default '0', - `socketColor_1` tinyint(4) NOT NULL default '0', - `socketContent_1` mediumint(9) NOT NULL default '0', - `socketColor_2` tinyint(4) NOT NULL default '0', - `socketContent_2` mediumint(9) NOT NULL default '0', - `socketColor_3` tinyint(4) NOT NULL default '0', - `socketContent_3` mediumint(9) NOT NULL default '0', - `socketBonus` mediumint(9) NOT NULL default '0', - `GemProperties` mediumint(9) NOT NULL default '0', - `RequiredDisenchantSkill` smallint(6) NOT NULL default '-1', - `ArmorDamageModifier` float NOT NULL default '0', - `ScriptName` varchar(64) NOT NULL default '', - `DisenchantID` mediumint(8) unsigned NOT NULL default '0', - `FoodType` tinyint(3) unsigned NOT NULL default '0', - `minMoneyLoot` int(10) unsigned NOT NULL default '0', - `maxMoneyLoot` int(10) unsigned NOT NULL default '0', - `Duration` int(11) NOT NULL default '0' COMMENT 'Duration in seconds. Negative value means realtime, postive value ingame time', - PRIMARY KEY (`entry`), - KEY `items_index` (`class`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Item System'; - --- --- Dumping data for table `item_template` --- - -LOCK TABLES `item_template` WRITE; -/*!40000 ALTER TABLE `item_template` DISABLE KEYS */; -INSERT INTO `item_template` VALUES -(25,2,7,-1,'Worn Shortsword',1542,1,0,1,35,7,21,32767,511,2,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1900,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,1,0,0,0,1,3,0,0,0,0,20,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), -(35,2,10,-1,'Bent Staff',472,1,0,1,47,9,17,2047,255,2,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2900,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,0,0,0,0,2,2,0,0,0,0,25,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), -(36,2,4,-1,'Worn Mace',5194,1,0,1,38,7,21,2047,255,2,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1900,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,0,0,0,0,2,3,0,0,0,0,20,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), -(37,2,0,-1,'Worn Axe',14029,1,0,1,38,7,21,2047,255,2,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2000,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,0,0,0,0,1,3,0,0,0,0,20,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), -(38,4,0,-1,'Recruit\'s Shirt',9891,1,0,1,1,1,4,-1,-1,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,0,0,0,0,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), -(39,4,1,-1,'Recruit\'s Pants',9892,0,0,1,5,1,7,32767,511,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,0,0,0,0,7,0,0,0,0,0,25,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), -(40,4,0,-1,'Recruit\'s Boots',10141,1,0,1,4,1,8,32767,511,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,0,0,0,0,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), -(43,4,0,-1,'Squire\'s Boots',9938,1,0,1,4,1,8,2047,255,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1000,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,0,0,0,0,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), -(44,4,1,-1,'Squire\'s Pants',9937,0,0,1,4,1,7,2047,255,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,1000,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,0,0,0,0,7,0,0,0,0,0,25,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), -(45,4,0,-1,'Squire\'s Shirt',3265,1,0,1,1,1,4,2047,255,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1000,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,0,0,0,0,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), -(47,4,0,-1,'Footpad\'s Shoes',9915,1,0,1,4,1,8,2047,255,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1000,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,0,0,0,0,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), -(48,4,1,-1,'Footpad\'s Pants',9913,0,0,1,4,1,7,2047,255,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,1000,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,0,0,0,0,7,0,0,0,0,0,25,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), -(49,4,0,-1,'Footpad\'s Shirt',9906,1,0,1,1,1,4,2047,255,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1000,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,0,0,0,0,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), -(51,4,0,-1,'Neophyte\'s Boots',9946,1,0,1,5,1,8,2047,255,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1000,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,0,0,0,0,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), -(52,4,1,-1,'Neophyte\'s Pants',9945,0,0,1,5,1,7,2047,255,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,1000,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,0,0,0,0,7,0,0,0,0,0,25,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), -(53,4,0,-1,'Neophyte\'s Shirt',9944,1,0,1,1,1,4,2047,255,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1000,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,0,0,0,0,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), -(55,4,0,-1,'Apprentice\'s Boots',9929,1,0,1,5,1,8,2047,255,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1000,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,0,0,0,0,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), -(56,4,1,-1,'Apprentice\'s Robe',12647,0,0,1,5,1,20,2047,255,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,0,0,0,0,1000,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,0,0,0,0,7,0,0,0,0,0,35,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), -(57,4,1,-1,'Acolyte\'s Robe',12645,0,0,1,5,1,20,2047,255,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,0,0,0,0,1000,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,0,0,0,0,7,0,0,0,0,0,35,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), -(59,4,0,-1,'Acolyte\'s Shoes',3261,1,0,1,5,1,8,2047,255,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1000,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,0,0,0,0,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), -(117,0,0,-1,'Tough Jerky',2473,1,0,6,25,1,0,2047,255,5,1,0,0,0,0,0,0,0,0,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1000,0,0,433,0,-1,0,-1,11,1000,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), -(120,4,1,-1,'Thug Pants',10006,0,0,1,4,1,7,2047,255,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,1000,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,0,0,0,0,7,0,0,0,0,0,25,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), -(121,4,0,-1,'Thug Boots',10008,1,0,1,4,1,8,2047,255,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1000,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,0,0,0,0,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), -(127,4,0,-1,'Trapper\'s Shirt',9996,1,0,1,1,1,4,2047,255,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1000,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,0,0,0,0,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), -(139,4,1,-1,'Brawler\'s Pants',9988,0,0,1,4,1,7,2047,255,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,1000,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,0,0,0,0,7,0,0,0,0,0,25,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), -(140,4,0,-1,'Brawler\'s Boots',9992,1,0,1,4,1,8,2047,255,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1000,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,0,0,0,0,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), -(147,4,1,-1,'Rugged Trapper\'s Pants',9975,0,0,1,5,1,7,2047,255,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,1000,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,0,0,0,0,7,0,0,0,0,0,25,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), -(148,4,0,-1,'Rugged Trapper\'s Shirt',9976,1,0,1,1,1,4,2047,255,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1000,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,0,0,0,0,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), -(153,4,2,-1,'Primitive Kilt',10050,0,0,1,5,1,7,2047,255,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,14,0,0,0,0,0,0,1000,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,0,0,0,0,8,0,0,0,0,0,30,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), -(154,4,0,-1,'Primitive Mantle',10058,1,0,1,1,1,4,2047,255,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1000,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,0,0,0,0,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), -(159,0,0,-1,'Refreshing Spring Water',18084,1,0,6,25,1,0,2047,255,5,1,0,0,0,0,0,0,0,0,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1000,0,0,430,0,-1,0,-1,59,1000,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), -(1395,4,1,-1,'Apprentice\'s Pants',9924,0,0,1,5,1,7,2047,255,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,1000,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,0,0,0,0,7,0,0,0,0,0,25,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), -(1396,4,1,-1,'Acolyte\'s Pants',3260,0,0,1,4,1,7,2047,255,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,1000,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,0,0,0,0,7,0,0,0,0,0,25,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), -(2070,0,0,-1,'Darnassian Bleu',6353,1,0,6,25,1,0,2047,255,5,1,0,0,0,0,0,0,0,0,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1000,0,0,433,0,-1,0,-1,11,1000,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), -(2092,2,15,-1,'Worn Dagger',6442,1,0,1,35,7,13,2047,255,2,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1600,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,0,0,0,0,1,3,0,0,0,0,16,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), -(2101,1,2,-1,'Light Quiver',21328,1,0,1,4,1,18,2047,255,1,1,0,0,0,0,0,0,0,0,1,6,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1000,0,0,14824,1,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,'',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), -(2102,1,3,-1,'Small Ammo Pouch',1816,1,0,1,4,1,18,2047,255,1,1,0,0,0,0,0,0,0,0,1,6,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1000,0,0,14824,1,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,'',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), -(2105,4,0,-1,'Thug Shirt',10005,1,0,1,5,1,4,2047,255,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1000,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,0,0,0,0,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), -(2361,2,5,-1,'Battleworn Hammer',8690,1,0,1,45,9,17,2047,255,2,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2900,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,0,0,0,0,2,1,0,0,0,0,25,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), -(2362,4,6,-1,'Worn Wooden Shield',18730,0,0,1,7,1,14,32767,511,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,0,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,0,0,0,0,1,4,0,0,1,0,20,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), -(2504,2,2,-1,'Worn Shortbow',8106,1,0,1,29,5,15,2047,255,2,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2300,2,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,0,0,0,0,2,0,0,0,0,0,20,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), -(2508,2,3,-1,'Old Blunderbuss',6606,1,0,1,27,5,26,2047,255,2,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2300,3,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,0,0,0,0,1,0,0,0,0,0,20,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), -(2512,6,2,-1,'Rough Arrow',5996,1,0,1,10,0,24,2047,255,5,1,0,0,0,0,0,0,0,0,200,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3000,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,0,0,0,0,2,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), -(2516,6,3,-1,'Light Shot',5998,1,0,1,10,0,24,2047,255,5,1,0,0,0,0,0,0,0,0,200,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3000,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,0,0,0,0,2,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), -(2947,2,16,-1,'Small Throwing Knife',16754,1,0,1,15,0,25,2047,255,3,1,0,0,0,0,0,0,0,0,200,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2000,4,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), -(3661,2,10,-1,'Handcrafted Staff',18530,1,0,1,45,9,17,2047,255,2,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2900,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,0,0,0,0,2,2,0,0,0,0,25,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), -(4536,0,0,-1,'Shiny Red Apple',6410,1,0,6,25,1,0,2047,255,5,1,0,0,0,0,0,0,0,0,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1000,0,0,433,0,-1,0,-1,11,100,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), -(4540,0,0,-1,'Tough Hunk of Bread',6399,1,0,6,25,1,0,2047,255,5,1,0,0,0,0,0,0,0,0,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1000,0,0,433,0,-1,0,-1,11,1000,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), -(4604,0,0,-1,'Forest Mushroom Cap',15852,1,0,6,25,1,0,2047,255,5,1,0,0,0,0,0,0,0,0,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1000,0,0,433,0,-1,0,-1,11,1000,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), -(6096,4,0,-1,'Apprentice\'s Shirt',2163,1,0,1,1,1,4,2047,255,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1000,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,0,0,0,0,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), -(6097,4,0,-1,'Acolyte\'s Shirt',2470,1,0,1,1,1,4,2047,255,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1000,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,0,0,0,0,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), -(6098,4,1,-1,'Neophyte\'s Robe',12679,0,0,1,4,1,20,2047,255,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,0,0,0,0,1000,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,0,0,0,0,7,0,0,0,0,0,35,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), -(6119,4,1,-1,'Neophyte\'s Robe',12681,0,0,1,4,1,20,2047,255,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,0,0,0,0,1000,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,0,0,0,0,7,0,0,0,0,0,35,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), -(6123,4,1,-1,'Novice\'s Robe',12683,0,0,1,4,1,20,2047,255,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,0,0,0,0,1000,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,0,0,0,0,7,0,0,0,0,0,35,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), -(6124,4,1,-1,'Novice\'s Pants',9987,0,0,1,5,1,7,2047,255,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,1000,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,0,0,0,0,7,0,0,0,0,0,25,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), -(6125,4,0,-1,'Brawler\'s Harness',9995,1,0,1,1,1,4,2047,255,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1000,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,0,0,0,0,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), -(6126,4,1,-1,'Trapper\'s Pants',10002,0,0,1,5,1,7,2047,255,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,1000,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,0,0,0,0,7,0,0,0,0,0,25,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), -(6127,4,0,-1,'Trapper\'s Boots',10003,1,0,1,5,1,8,2047,255,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1000,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,0,0,0,0,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), -(6129,4,1,-1,'Acolyte\'s Robe',12646,0,0,1,5,1,20,2047,255,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,0,0,0,0,1000,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,0,0,0,0,7,0,0,0,0,0,35,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), -(6134,4,0,-1,'Primitive Mantle',10108,1,0,1,1,1,4,2047,255,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1000,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,0,0,0,0,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), -(6135,4,2,-1,'Primitive Kilt',10109,0,0,1,5,1,7,2047,255,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,14,0,0,0,0,0,0,1000,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,0,0,0,0,8,0,0,0,0,0,30,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), -(6139,4,1,-1,'Novice\'s Robe',12684,0,0,1,4,1,20,2047,255,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,0,0,0,0,1000,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,0,0,0,0,7,0,0,0,0,0,35,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), -(6140,4,1,-1,'Apprentice\'s Robe',12649,0,0,1,4,1,20,2047,255,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,0,0,0,0,1000,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,0,0,0,0,7,0,0,0,0,0,35,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), -(6144,4,1,-1,'Neophyte\'s Robe',12680,0,0,1,5,1,20,2047,255,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,0,0,0,0,1000,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,0,0,0,0,7,0,0,0,0,0,35,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), -(6948,15,0,-1,'Hearthstone',6418,1,64,1,0,0,0,32767,511,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,8690,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,'',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), -(12282,2,1,-1,'Worn Battleaxe',22291,1,0,1,43,8,17,2047,255,2,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2900,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,0,0,0,0,1,1,0,0,0,0,25,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), -(14646,12,0,-1,'Northshire Gift Voucher',18499,1,0,1,0,0,0,2047,255,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1000,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,'',0,0,0,5805,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), -(14647,12,0,-1,'Coldridge Valley Gift Voucher',18499,1,0,1,0,0,0,2047,255,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1000,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,'',0,0,0,5841,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), -(14648,12,0,-1,'Shadowglen Gift Voucher',18499,1,0,1,0,0,0,2047,255,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1000,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,'',0,0,0,5842,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), -(14649,12,0,-1,'Valley of Trials Gift Voucher',18499,1,0,1,0,0,0,2047,255,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1000,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,'',0,0,0,5843,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), -(14650,12,0,-1,'Camp Narache Gift Voucher',18499,1,0,1,0,0,0,2047,255,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1000,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,'',0,0,0,5844,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), -(14651,12,0,-1,'Deathknell Gift Voucher',18499,1,0,1,0,0,0,2047,255,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1000,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,'',0,0,0,5847,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), -(25861,2,16,-1,'Crude Throwing Axe',20777,1,0,1,15,0,25,2047,255,3,1,0,0,0,0,0,0,0,0,200,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2000,4,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0); -/*!40000 ALTER TABLE `item_template` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `locales_creature` --- - -DROP TABLE IF EXISTS `locales_creature`; -CREATE TABLE `locales_creature` ( - `entry` mediumint(8) unsigned NOT NULL default '0', - `name_loc1` varchar(100) NOT NULL default '', - `name_loc2` varchar(100) NOT NULL default '', - `name_loc3` varchar(100) NOT NULL default '', - `name_loc4` varchar(100) NOT NULL default '', - `name_loc5` varchar(100) NOT NULL default '', - `name_loc6` varchar(100) NOT NULL default '', - `name_loc7` varchar(100) NOT NULL default '', - `name_loc8` varchar(100) NOT NULL default '', - `subname_loc1` varchar(100) default NULL, - `subname_loc2` varchar(100) default NULL, - `subname_loc3` varchar(100) default NULL, - `subname_loc4` varchar(100) default NULL, - `subname_loc5` varchar(100) default NULL, - `subname_loc6` varchar(100) default NULL, - `subname_loc7` varchar(100) default NULL, - `subname_loc8` varchar(100) default NULL, - PRIMARY KEY (`entry`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8; - --- --- Dumping data for table `locales_creature` --- - -LOCK TABLES `locales_creature` WRITE; -/*!40000 ALTER TABLE `locales_creature` DISABLE KEYS */; -/*!40000 ALTER TABLE `locales_creature` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `locales_gameobject` --- - -DROP TABLE IF EXISTS `locales_gameobject`; -CREATE TABLE `locales_gameobject` ( - `entry` mediumint(8) unsigned NOT NULL default '0', - `name_loc1` varchar(100) NOT NULL default '', - `name_loc2` varchar(100) NOT NULL default '', - `name_loc3` varchar(100) NOT NULL default '', - `name_loc4` varchar(100) NOT NULL default '', - `name_loc5` varchar(100) NOT NULL default '', - `name_loc6` varchar(100) NOT NULL default '', - `name_loc7` varchar(100) NOT NULL default '', - `name_loc8` varchar(100) NOT NULL default '', - `castbarcaption_loc1` varchar(100) NOT NULL default '', - `castbarcaption_loc2` varchar(100) NOT NULL default '', - `castbarcaption_loc3` varchar(100) NOT NULL default '', - `castbarcaption_loc4` varchar(100) NOT NULL default '', - `castbarcaption_loc5` varchar(100) NOT NULL default '', - `castbarcaption_loc6` varchar(100) NOT NULL default '', - `castbarcaption_loc7` varchar(100) NOT NULL default '', - `castbarcaption_loc8` varchar(100) NOT NULL default '', - PRIMARY KEY (`entry`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8; - --- --- Dumping data for table `locales_gameobject` --- - -LOCK TABLES `locales_gameobject` WRITE; -/*!40000 ALTER TABLE `locales_gameobject` DISABLE KEYS */; -/*!40000 ALTER TABLE `locales_gameobject` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `locales_item` --- - -DROP TABLE IF EXISTS `locales_item`; -CREATE TABLE `locales_item` ( - `entry` mediumint(8) unsigned NOT NULL default '0', - `name_loc1` varchar(100) NOT NULL default '', - `name_loc2` varchar(100) NOT NULL default '', - `name_loc3` varchar(100) NOT NULL default '', - `name_loc4` varchar(100) NOT NULL default '', - `name_loc5` varchar(100) NOT NULL default '', - `name_loc6` varchar(100) NOT NULL default '', - `name_loc7` varchar(100) NOT NULL default '', - `name_loc8` varchar(100) NOT NULL default '', - `description_loc1` varchar(255) default NULL, - `description_loc2` varchar(255) default NULL, - `description_loc3` varchar(255) default NULL, - `description_loc4` varchar(255) default NULL, - `description_loc5` varchar(255) default NULL, - `description_loc6` varchar(255) default NULL, - `description_loc7` varchar(255) default NULL, - `description_loc8` varchar(255) default NULL, - PRIMARY KEY (`entry`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8; - --- --- Dumping data for table `locales_item` --- - -LOCK TABLES `locales_item` WRITE; -/*!40000 ALTER TABLE `locales_item` DISABLE KEYS */; -/*!40000 ALTER TABLE `locales_item` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `locales_npc_text` --- - -DROP TABLE IF EXISTS `locales_npc_text`; -CREATE TABLE `locales_npc_text` ( - `entry` mediumint(8) unsigned NOT NULL default '0', - `Text0_0_loc1` longtext, - `Text0_0_loc2` longtext, - `Text0_0_loc3` longtext, - `Text0_0_loc4` longtext, - `Text0_0_loc5` longtext, - `Text0_0_loc6` longtext, - `Text0_0_loc7` longtext, - `Text0_0_loc8` longtext, - `Text0_1_loc1` longtext, - `Text0_1_loc2` longtext, - `Text0_1_loc3` longtext, - `Text0_1_loc4` longtext, - `Text0_1_loc5` longtext, - `Text0_1_loc6` longtext, - `Text0_1_loc7` longtext, - `Text0_1_loc8` longtext, - `Text1_0_loc1` longtext, - `Text1_0_loc2` longtext, - `Text1_0_loc3` longtext, - `Text1_0_loc4` longtext, - `Text1_0_loc5` longtext, - `Text1_0_loc6` longtext, - `Text1_0_loc7` longtext, - `Text1_0_loc8` longtext, - `Text1_1_loc1` longtext, - `Text1_1_loc2` longtext, - `Text1_1_loc3` longtext, - `Text1_1_loc4` longtext, - `Text1_1_loc5` longtext, - `Text1_1_loc6` longtext, - `Text1_1_loc7` longtext, - `Text1_1_loc8` longtext, - `Text2_0_loc1` longtext, - `Text2_0_loc2` longtext, - `Text2_0_loc3` longtext, - `Text2_0_loc4` longtext, - `Text2_0_loc5` longtext, - `Text2_0_loc6` longtext, - `Text2_0_loc7` longtext, - `Text2_0_loc8` longtext, - `Text2_1_loc1` longtext, - `Text2_1_loc2` longtext, - `Text2_1_loc3` longtext, - `Text2_1_loc4` longtext, - `Text2_1_loc5` longtext, - `Text2_1_loc6` longtext, - `Text2_1_loc7` longtext, - `Text2_1_loc8` longtext, - `Text3_0_loc1` longtext, - `Text3_0_loc2` longtext, - `Text3_0_loc3` longtext, - `Text3_0_loc4` longtext, - `Text3_0_loc5` longtext, - `Text3_0_loc6` longtext, - `Text3_0_loc7` longtext, - `Text3_0_loc8` longtext, - `Text3_1_loc1` longtext, - `Text3_1_loc2` longtext, - `Text3_1_loc3` longtext, - `Text3_1_loc4` longtext, - `Text3_1_loc5` longtext, - `Text3_1_loc6` longtext, - `Text3_1_loc7` longtext, - `Text3_1_loc8` longtext, - `Text4_0_loc1` longtext, - `Text4_0_loc2` longtext, - `Text4_0_loc3` longtext, - `Text4_0_loc4` longtext, - `Text4_0_loc5` longtext, - `Text4_0_loc6` longtext, - `Text4_0_loc7` longtext, - `Text4_0_loc8` longtext, - `Text4_1_loc1` longtext, - `Text4_1_loc2` longtext, - `Text4_1_loc3` longtext, - `Text4_1_loc4` longtext, - `Text4_1_loc5` longtext, - `Text4_1_loc6` longtext, - `Text4_1_loc7` longtext, - `Text4_1_loc8` longtext, - `Text5_0_loc1` longtext, - `Text5_0_loc2` longtext, - `Text5_0_loc3` longtext, - `Text5_0_loc4` longtext, - `Text5_0_loc5` longtext, - `Text5_0_loc6` longtext, - `Text5_0_loc7` longtext, - `Text5_0_loc8` longtext, - `Text5_1_loc1` longtext, - `Text5_1_loc2` longtext, - `Text5_1_loc3` longtext, - `Text5_1_loc4` longtext, - `Text5_1_loc5` longtext, - `Text5_1_loc6` longtext, - `Text5_1_loc7` longtext, - `Text5_1_loc8` longtext, - `Text6_0_loc1` longtext, - `Text6_0_loc2` longtext, - `Text6_0_loc3` longtext, - `Text6_0_loc4` longtext, - `Text6_0_loc5` longtext, - `Text6_0_loc6` longtext, - `Text6_0_loc7` longtext, - `Text6_0_loc8` longtext, - `Text6_1_loc1` longtext, - `Text6_1_loc2` longtext, - `Text6_1_loc3` longtext, - `Text6_1_loc4` longtext, - `Text6_1_loc5` longtext, - `Text6_1_loc6` longtext, - `Text6_1_loc7` longtext, - `Text6_1_loc8` longtext, - `Text7_0_loc1` longtext, - `Text7_0_loc2` longtext, - `Text7_0_loc3` longtext, - `Text7_0_loc4` longtext, - `Text7_0_loc5` longtext, - `Text7_0_loc6` longtext, - `Text7_0_loc7` longtext, - `Text7_0_loc8` longtext, - `Text7_1_loc1` longtext, - `Text7_1_loc2` longtext, - `Text7_1_loc3` longtext, - `Text7_1_loc4` longtext, - `Text7_1_loc5` longtext, - `Text7_1_loc6` longtext, - `Text7_1_loc7` longtext, - `Text7_1_loc8` longtext, - PRIMARY KEY (`entry`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8; - --- --- Dumping data for table `locales_npc_text` --- - -LOCK TABLES `locales_npc_text` WRITE; -/*!40000 ALTER TABLE `locales_npc_text` DISABLE KEYS */; -/*!40000 ALTER TABLE `locales_npc_text` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `locales_page_text` --- - -DROP TABLE IF EXISTS `locales_page_text`; -CREATE TABLE `locales_page_text` ( - `entry` mediumint(8) unsigned NOT NULL default '0', - `Text_loc1` longtext, - `Text_loc2` longtext, - `Text_loc3` longtext, - `Text_loc4` longtext, - `Text_loc5` longtext, - `Text_loc6` longtext, - `Text_loc7` longtext, - `Text_loc8` longtext, - PRIMARY KEY (`entry`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8; - --- --- Dumping data for table `locales_page_text` --- - -LOCK TABLES `locales_page_text` WRITE; -/*!40000 ALTER TABLE `locales_page_text` DISABLE KEYS */; -/*!40000 ALTER TABLE `locales_page_text` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `locales_quest` --- - -DROP TABLE IF EXISTS `locales_quest`; -CREATE TABLE `locales_quest` ( - `entry` mediumint(8) unsigned NOT NULL default '0', - `Title_loc1` text, - `Title_loc2` text, - `Title_loc3` text, - `Title_loc4` text, - `Title_loc5` text, - `Title_loc6` text, - `Title_loc7` text, - `Title_loc8` text, - `Details_loc1` text, - `Details_loc2` text, - `Details_loc3` text, - `Details_loc4` text, - `Details_loc5` text, - `Details_loc6` text, - `Details_loc7` text, - `Details_loc8` text, - `Objectives_loc1` text, - `Objectives_loc2` text, - `Objectives_loc3` text, - `Objectives_loc4` text, - `Objectives_loc5` text, - `Objectives_loc6` text, - `Objectives_loc7` text, - `Objectives_loc8` text, - `OfferRewardText_loc1` text, - `OfferRewardText_loc2` text, - `OfferRewardText_loc3` text, - `OfferRewardText_loc4` text, - `OfferRewardText_loc5` text, - `OfferRewardText_loc6` text, - `OfferRewardText_loc7` text, - `OfferRewardText_loc8` text, - `RequestItemsText_loc1` text, - `RequestItemsText_loc2` text, - `RequestItemsText_loc3` text, - `RequestItemsText_loc4` text, - `RequestItemsText_loc5` text, - `RequestItemsText_loc6` text, - `RequestItemsText_loc7` text, - `RequestItemsText_loc8` text, - `EndText_loc1` text, - `EndText_loc2` text, - `EndText_loc3` text, - `EndText_loc4` text, - `EndText_loc5` text, - `EndText_loc6` text, - `EndText_loc7` text, - `EndText_loc8` text, - `ObjectiveText1_loc1` text, - `ObjectiveText1_loc2` text, - `ObjectiveText1_loc3` text, - `ObjectiveText1_loc4` text, - `ObjectiveText1_loc5` text, - `ObjectiveText1_loc6` text, - `ObjectiveText1_loc7` text, - `ObjectiveText1_loc8` text, - `ObjectiveText2_loc1` text, - `ObjectiveText2_loc2` text, - `ObjectiveText2_loc3` text, - `ObjectiveText2_loc4` text, - `ObjectiveText2_loc5` text, - `ObjectiveText2_loc6` text, - `ObjectiveText2_loc7` text, - `ObjectiveText2_loc8` text, - `ObjectiveText3_loc1` text, - `ObjectiveText3_loc2` text, - `ObjectiveText3_loc3` text, - `ObjectiveText3_loc4` text, - `ObjectiveText3_loc5` text, - `ObjectiveText3_loc6` text, - `ObjectiveText3_loc7` text, - `ObjectiveText3_loc8` text, - `ObjectiveText4_loc1` text, - `ObjectiveText4_loc2` text, - `ObjectiveText4_loc3` text, - `ObjectiveText4_loc4` text, - `ObjectiveText4_loc5` text, - `ObjectiveText4_loc6` text, - `ObjectiveText4_loc7` text, - `ObjectiveText4_loc8` text, - PRIMARY KEY (`entry`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8; - --- --- Dumping data for table `locales_quest` --- - -LOCK TABLES `locales_quest` WRITE; -/*!40000 ALTER TABLE `locales_quest` DISABLE KEYS */; -/*!40000 ALTER TABLE `locales_quest` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `mangos_string` --- - -DROP TABLE IF EXISTS `mangos_string`; -CREATE TABLE `mangos_string` ( - `entry` mediumint(8) unsigned NOT NULL default '0', - `content_default` text NOT NULL, - `content_loc1` text, - `content_loc2` text, - `content_loc3` text, - `content_loc4` text, - `content_loc5` text, - `content_loc6` text, - `content_loc7` text, - `content_loc8` text, - PRIMARY KEY (`entry`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8; - --- --- Dumping data for table `mangos_string` --- - -LOCK TABLES `mangos_string` WRITE; -/*!40000 ALTER TABLE `mangos_string` DISABLE KEYS */; -INSERT INTO `mangos_string` VALUES -(1,'You should select a character or a creature.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(2,'You should select a creature.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(3,'|cffff0000[System Message]: %s|r',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(4,'|cffff0000[Event Message]: %s|r',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(5,'There is no help for that command',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(6,'There is no such command',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(7,'There is no such subcommand',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(8,'Command %s have subcommands:%s',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(9,'Commands available to you:',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(10,'Incorrect syntax.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(11,'Your account level is: %i',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(12,'Online players: %u (max: %u) Queued players: %u (max: %u)',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(13,'Server uptime: %s',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(14,'Player saved.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(15,'All players saved.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(16,'There are the following active GMs on this server:',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(17,'There are no GMs currently logged in on this server.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(18,'Cannot do that while flying.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(19,'Cannot do that in Battlegrounds.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(20,'Target is flying you can\'t do that.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(21,'%s is flying command failed.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(22,'You are not mounted so you can\'t dismount.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(23,'Cannot do that while fighting.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(24,'You used it recently.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(25,'Your password can\'t be longer than 16 characters (client limit), password not changed!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(26,'The password was changed',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(27,'The new passwords do not match or the old password is wrong',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(28,'Your account is now locked.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(29,'Your account is now unlocked.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(30,', rank ',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(31,' [known]',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(32,' [learn]',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(33,' [passive]',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(34,' [talent]',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(35,' [active]',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(36,' [complete]',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(37,' (offline)',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(38,'on',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(39,'off',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(40,'You are: %s',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(41,'visible',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(42,'invisible',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(43,'done',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(44,'You',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(45,' ',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(46,'',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(47,'',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(48,'UNKNOWN',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(49,'You must be at least level %u to enter.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(50,'You must be at least level %u and have item %s to enter.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(51,'Hello! Ready for some training?',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(100,'Global notify: ',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(101,'Map: %u (%s) Zone: %u (%s) Area: %u (%s)\nX: %f Y: %f Z: %f Orientation: %f\ngrid[%u,%u]cell[%u,%u] InstanceID: %u\n ZoneX: %f ZoneY: %f\nGroundZ: %f FloorZ: %f Have height data (Map: %u VMap: %u)',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(102,'%s is already being teleported.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(103,'You can summon a player to your instance only if he is in your party with you as leader.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(104,'You cannot go to the player\'s instance because you are in a party now.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(105,'You can go to the player\'s instance while not being in his party only if your GM mode is on.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(106,'You can not go to player %s from instance to instance.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(107,'You can not summon player %s from instance to instance.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(108,'You are summoning %s%s.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(109,'You are being summoned by %s.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(110,'You are teleporting %s%s to %s.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(111,'You are being teleported by %s.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(112,'Player (%s) does not exist.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(113,'Appearing at %s\'s location.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(114,'%s is appearing to your location.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(115,'Incorrect values.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(116,'No character selected.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(117,'%s is not in a group.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(118,'You changed HP of %s to %i/%i.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(119,'%s changed your HP to %i/%i.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(120,'You changed MANA of %s to %i/%i.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(121,'%s changed your MANA to %i/%i.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(122,'You changed ENERGY of %s to %i/%i.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(123,'%s changed your ENERGY to %i/%i.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(124,'Current energy: %u',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(125,'You changed rage of %s to %i/%i.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(126,'%s changed your rage to %i/%i.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(127,'You changed level of %s to %i.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(128,'GUID %i, faction is %i, flags is %i, npcflag is %i, DY flag is %i',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(129,'Wrong faction: %u (not found in factiontemplate.dbc).',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(130,'You changed GUID=%i \'s Faction to %i, flags to %i, npcflag to %i, dyflag to %i.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(131,'You changed the spellflatid=%i, val= %i, mark =%i to %s.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(132,'%s changed your spellflatid=%i, val= %i, mark =%i.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(133,'%s has access to all taxi nodes now (until logout).',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(134,'%s has no more access to all taxi nodes now (only visited accessible).',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(135,'%s has given you access to all taxi nodes (until logout).',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(136,'%s has removed access to all taxi nodes (only visited still accessible).',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(137,'You set all speeds to %2.2f from normal of %s.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(138,'%s set all your speeds to %2.2f from normal.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(139,'You set the speed to %2.2f from normal of %s.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(140,'%s set your speed to %2.2f from normal.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(141,'You set the swim speed to %2.2f from normal of %s.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(142,'%s set your swim speed to %2.2f from normal.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(143,'You set the backwards run speed to %2.2f from normal of %s.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(144,'%s set your backwards run speed to %2.2f from normal.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(145,'You set the fly speed to %2.2f from normal of %s.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(146,'%s set your fly speed to %2.2f from normal.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(147,'You set the size %2.2f of %s.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(148,'%s set your size to %2.2f.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(149,'There is no such mount.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(150,'You give a mount to %s.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(151,'%s gave you a mount.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(152,'USER1: %i, ADD: %i, DIF: %i\n',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(153,'You take all copper of %s.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(154,'%s took you all of your copper.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(155,'You take %i copper from %s.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(156,'%s took %i copper from you.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(157,'You give %i copper to %s.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(158,'%s gave you %i copper.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(159,'You hear sound %u.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(160,'USER2: %i, ADD: %i, RESULT: %i\n',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(161,'Removed bit %i in field %i.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(162,'Set bit %i in field %i.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(163,'Teleport location table is empty!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(164,'Teleport location not found!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(165,'Requires search parameter.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(166,'There are no teleport locations matching your request.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(167,'No locations found.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(168,'Locations found are:\n',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(169,'Mail sent to %s',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(170,'You try to hear sound %u but it doesn\'t exist.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(200,'No selection.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(201,'Object GUID is: lowpart %u highpart %X',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(202,'The name was too long by %i characters.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(203,'Error, name can only contain characters A-Z and a-z.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(204,'The subname was too long by %i characters.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(205,'Not yet implemented',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(206,'Item \'%i\' \'%s\' added to list with maxcount \'%i\' and incrtime \'%i\' and extendedcost \'%i\'',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(207,'Item \'%i\' not found in database.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(208,'Item \'%i\' \'%s\' deleted from vendor list',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(209,'Item \'%i\' not found in vendor list.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(210,'Item \'%i\' already in vendor list.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(211,'Spells of %s reset.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(212,'Spells of %s will reset at next login.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(213,'Talents of %s reset.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(214,'Talents of %s will reset at next login.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(215,'Your spells have been reset.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(216,'Your talents have been reset.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(217,'Unknown case \'%s\' for .resetall command. Type full correct case name.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(218,'Spells will reset for all players at login. Strongly recommend re-login!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(219,'Talents will reset for all players at login. Strongly recommend re-login!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(220,'Creature (GUID: %u) No waypoint found.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(221,'Creature (GUID: %u) Last waypoint not found.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(222,'Creature (GUID: %u) No waypoint found - used \'wpguid\'. Now trying to find it by its position...',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(223,'Creature (GUID: %u) No waypoints found - This is a MaNGOS db problem (single float).',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(224,'Selected creature is ignored - provided GUID is used',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(225,'Creature (GUID: %u) not found',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(226,'You must select a visual waypoint.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(227,'No visual waypoints found',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(228,'Could not create visual waypoint with creatureID: %d',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(229,'All visual waypoints removed',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(230,'Could not create waypoint-creature with ID: %d',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(231,'No GUID provided.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(232,'No waypoint number provided.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(233,'Argument required for \'%s\'.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(234,'Waypoint %i added to GUID: %d',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(235,'Waypoint %d added.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(236,'Waypoint changed.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(237,'Waypoint %s modified.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(238,'WP export successfull.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(239,'No waypoints found inside the database.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(240,'File imported.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(241,'Waypoint removed.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(242,'Warning: Could not delete WP from the world with ID: %d',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(243,'This happens if the waypoint is too far away from your char.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(244,'The WP is deleted from the database, but not from the world here.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(245,'They will disappear after a server restart.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(246,'Waypoint %d: Info for creature: %s, GUID: %d',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(247,'Waittime: %d',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(248,'Model %d: %d',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(249,'Emote: %d',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(250,'Spell: %d',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(251,'Text %d: %s',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(252,'AIScript: %s',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(253,'Forced rename for player %s will be requested at next login.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(254,'Forced rename for player %s (GUID #%u) will be requested at next login.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(255,'Waypoint-Creature (GUID: %u) Not found',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(256,'Could not find NPC...',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(257,'Creature movement type set to \'%s\', waypoints removed (if any).',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(258,'Creature movement type set to \'%s\', waypoints were not removed.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(259,'Incorrect value, use on or off',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(260,'Value saved.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(261,'Value saved, you may need to rejoin or clean your client cache.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(262,'Areatrigger ID %u not found!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(263,'Target map or coordinates is invalid (X: %f Y: %f MapId: %u)',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(264,'Zone coordinates is invalid (X: %f Y: %f AreaId: %u)',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(265,'Zone %u (%s) is part of instanceable map %u (%s)',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(266,'Nothing found!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(267,'Object not found!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(268,'Creature not found!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(269,'Warning: Mob found more than once - you will be teleported to the first one found in DB.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(270,'Creature Removed',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(271,'Creature moved.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(272,'Creature (GUID:%u) must be on the same map as player!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(273,'Game Object (GUID: %u) not found',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(274,'Game Object (GUID: %u) has references in not found creature %u GO list, can\'t be deleted.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(275,'Game Object (GUID: %u) removed',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(276,'Game Object (GUID: %u) turned',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(277,'Game Object (GUID: %u) moved',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(278,'You must select a vendor',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(279,'You must send id for item',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(280,'Vendor has too many items (max 128)',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(281,'You can\'t kick self, logout instead',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(282,'Player %s kicked.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(283,'Player %s not found.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(284,'Accepting Whisper: %s',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(285,'Accepting Whisper: ON',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(286,'Accepting Whisper: OFF',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(287,'Creature (GUID: %u) not found',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(288,'Tickets count: %i show new tickets: %s\n',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(289,'New ticket from %s',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(290,'Ticket of %s (Last updated: %s):\n%s ',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(291,'New ticket show: ON',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(292,'New ticket show: OFF',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(293,'Ticket %i doesn\'t exist',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(294,'All tickets deleted.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(295,'Character %s ticket deleted.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(296,'Ticket deleted.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(297,'Spawn distance changed to: %f',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(298,'Spawn time changed to: %i',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(299,'The honor of %s was set to %u!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(300,'Your chat has been disabled for %u minutes.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(301,'You have disabled %s\'s chat for %u minutes.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(302,'Player\'s chat is already enabled.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(303,'Your chat has been enabled.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(304,'You have enabled %s\'s chat.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(305, 'Faction %s (%u) reputation of %s was set to %5d!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(306, 'The arena points of %s was set to %u!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(307, 'No faction found!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(308, 'Faction %i unknown!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(309, 'Invalid parameter %s',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(310, 'delta must be between 0 and %d (inclusive)',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(311, '%d - |cffffffff|Hfaction:%d|h[%s]|h|r',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(312, ' [visible]',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(313, ' [at war]',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(314, ' [peace forced]',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(315, ' [hidden]',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(316, ' [invisible forced]',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(317, ' [inactive]',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(318, 'Hated',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(319, 'Hostile',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(320, 'Unfriendly',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(321, 'Neutral',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(322, 'Friendly',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(323, 'Honored',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(324, 'Revered',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(325, 'Exalted',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(326, 'Faction %s (%u) can\'not have reputation.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(327, ' [no reputation]',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(400,'|cffff0000[System Message]:|rScripts reloaded',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(401,'You change security level of %s to %i.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(402,'%s changed your security level to %i.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(403,'You have low security level for this.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(404,'Creature movement disabled.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(405,'Creature movement enabled.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(406,'Weather can\'t be changed for this zone.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(407,'Weather system disabled at server.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(408,'%s is banned for %s. Reason: %s.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(409,'%s is banned permanently for %s.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(410,'%s %s not found',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(411,'%s unbanned.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(412,'There was an error removing the ban on %s.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(413,'There is no such account.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(414,'There is no such character.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(415,'There is no such IP in banlist.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(416,'Account %s has never been banned',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(417,'Ban history for account %s:',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(418,'Ban Date: %s Bantime: %s Still active: %s Reason: %s Set by: %s',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(419,'Inf.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(420,'Never',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(421,'Yes',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(422,'No',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(423,'IP: %s\nBan Date: %s\nUnban Date: %s\nRemaining: %s\nReason: %s\nSet by: %s',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(424,'There is no matching IPban.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(425,'There is no matching account.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(426,'There is no banned account owning a character matching this part.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(427,'The following IPs match your pattern:',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(428,'The following accounts match your query:',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(429,'You learned many spells/skills.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(430,'You learned all spells for class.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(431,'You learned all talents for class.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(432,'You learned all languages.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(433,'You learned all craft skills and recipes.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(434,'Could not find \'%s\'',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(435,'Invalid item id: %u',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(436,'No items found!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(437,'Invalid gameobject id: %u',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(438,'Found items %u: %u ( inventory %u mail %u auction %u )',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(439,'Found gameobjects %u: %u ',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(440,'Invalid creature id: %u',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(441,'Found creatures %u: %u ',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(442,'No area found!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(443,'No item sets found!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(444,'No skills found!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(445,'No spells found!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(446,'No quests found!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(447,'No creatures found!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(448,'No gameobjects found!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(449,'Graveyard #%u doesn\'t exist.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(450,'Graveyard #%u already linked to zone #%u (current).',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(451,'Graveyard #%u linked to zone #%u (current).',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(452,'Graveyard #%u can\'t be linked to subzone or not existed zone #%u (internal error).',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(453,'Graveyard can be linked to zone at another map only for all factions (no faction value).',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(454,'No faction in Graveyard with id= #%u , fix your DB',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(455,'invalid team, please fix database',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(456,'any',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(457,'alliance',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(458,'horde',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(459,'Graveyard #%u (faction: %s) is nearest from linked to zone #%u.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(460,'Zone #%u doesn\'t have linked graveyards.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(461,'Zone #%u doesn\'t have linked graveyards for faction: %s.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(462,'Teleport location already exists!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(463,'Teleport location added.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(464,'Teleport location NOT added: database error.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(465,'Teleport location deleted.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(466,'Teleport location NOT deleted: database error.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(467,'Target unit has %d auras:',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(468,'id: %d eff: %d type: %d duration: %d maxduration: %d name: %s%s%s caster: %s %u',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(469,'Target unit has %d auras of type %d:',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(470,'id: %d eff: %d name: %s%s%s caster: %s %u',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(471,'Quest %u not found.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(472,'Quest %u started from item. For correct work, please, add item to inventory and start quest in normal way: .additem %u',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(473,'Quest removed.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(474,' [rewarded]',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(475,' [complete]',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(476,' [active]',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(477,'%s\'s Fly Mode %s',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(478,'Opcode %u sent to %s',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(479,'Character loaded successfully!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(480,'Failed to load the character!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(481,'Character dumped successfully!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(482,'Character dump failed!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(483,'Spell %u broken and not allowed to cast or learn!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(484,'Skill %u (%s) for player %s set to %u and current maximum set to %u (without permanent (talent) bonuses).',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(485,'Player %s must have skill %u (%s) before using this command.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(486,'Invalid skill id (%u)',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(487,'You learned default GM spells/skills.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(488,'You already know that spell.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(489,'Target(%s) already know that spell.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(490,'%s doesn\'t know that spell.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(491,'You already forgot that spell.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(492,'All spell cooldowns removed for %s.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(493,'Spell %u cooldown removed for %s.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(494,'Command : Additem, itemId = %i, amount = %i',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(495,'Command : Additemset, itemsetId = %i',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(496,'Removed itemID = %i, amount = %i from %s',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(497,'Cannot create item \'%i\' (amount: %i)',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(498,'You need to provide a guild name!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(499,'Player not found!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(500,'Player already has a guild!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(501,'Guild not created! (already exists?)',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(502,'No items from itemset \'%u\' found.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(503,'The distance is: (3D) %f (2D) %f yards.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(504,'Item \'%i\' \'%s\' Item Slot %i',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(505,'Item \'%i\' doesn\'t exist.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(506,'Item \'%i\' \'%s\' Added to Slot %i',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(507,'Item save failed!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(508,'%d - owner: %s (guid: %u account: %u ) %s',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(509,'%d - sender: %s (guid: %u account: %u ) receiver: %s (guid: %u account: %u ) %s',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(510,'%d - owner: %s (guid: %u account: %u ) %s',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(511,'Wrong link type!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(512,'%d - |cffffffff|Hitem:%d:0:0:0:0:0:0:0|h[%s]|h|r ',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(513,'%d - |cffffffff|Hquest:%d|h[%s]|h|r %s',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(514,'%d - |cffffffff|Hcreature_entry:%d|h[%s]|h|r ',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(515,'%d - |cffffffff|Hcreature:%d|h[%s X:%f Y:%f Z:%f MapId:%d]|h|r ',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(516,'%d - |cffffffff|Hgameobject_entry:%d|h[%s]|h|r ',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(517,'%d - |cffffffff|Hgameobject:%d|h[%s X:%f Y:%f Z:%f MapId:%d]|h|r ',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(518,'%d - |cffffffff|Hitemset:%d|h[%s %s]|h|r ',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(519,'|cffffffff|Htele:%s|h[%s]|h|r ',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(520,'%d - |cffffffff|Hspell:%d|h[%s]|h|r ',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(521,'%d - |cffffffff|Hskill:%d|h[%s %s]|h|r %s',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(522,'Game Object (GUID: %u) not found',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(523,'>> Game Object %s (GUID: %u) at %f %f %f. Orientation %f.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(524,'Selected object:\n|cffffffff|Hitemset:%d|h[%s]|h|r\nGUID: %u ID: %u\nX: %f Y: %f Z: %f MapId: %u\nOrientation: %f',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(525,'>> Add Game Object \'%i\' (%s) (GUID: %i) added at \'%f %f %f\'.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(526,'%s (lowguid: %u) movement generators stack:',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(527,' Idle',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(528,' Random',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(529,' Waypoint',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(530,' Animal random',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(531,' Confused',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(532,' Targeted to player %s (lowguid %u)',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(533,' Targeted to creature %s (lowguid %u)',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(534,' Targeted to ',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(535,' Home movement to (X:%f Y:%f Z:%f)',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(536,' Home movement used for player?!?',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(537,' Taxi flight',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(538,' Unknown movement generator (%u)',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(539,'Player selected NPC\nGUID: %u.\nFaction: %u.\nnpcFlags: %u.\nEntry: %u.\nDisplayID: %u (Native: %u).',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(540,'Level: %u.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(541,'Health (base): %u. (max): %u. (current): %u.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(542,'Field Flags: %u.\nDynamic Flags: %u.\nFaction Template: %u.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(543,'Loot: %u Pickpocket: %u Skinning: %u',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(544,'Position: %f %f %f.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(545,'*** Is a vendor!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(546,'*** Is a trainer!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(547,'InstanceID: %u',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(548,'Player%s %s (guid: %u) Account: %s (id: %u) GMLevel: %u Last IP: %s Last login: %s Latency: %ums',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(549,'Played time: %s Level: %u Money: %ug%us%uc',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(550,'Command .pinfo doesn\'t support \'rep\' option for offline players.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(551,'%s has explored all zones now.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(552,'%s has no more explored zones.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(553,'%s has explored all zones for you.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(554,'%s has hidden all zones from you.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(555,'Hover enabled',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(556,'Hover disabled',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(557,'You have been leveled up (%i)',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(558,'You have been leveled down (%i)',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(559,'Your level progress has been reset.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(560,'The area has been set as explored.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(561,'The area has been set as not explored.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(562,'GUID=%i \'s updateIndex: %i, value: %i.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(563,'You change GUID=%i \'s UpdateIndex: %i value to %i.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(564,'The value index %u is too big to %u(count: %u).',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(565,'Set %u uint32 Value:[OPCODE]:%u [VALUE]:%u',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(566,'You Set %u Field:%u to uint32 Value: %u',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(567,'Set %u float Value:[OPCODE]:%u [VALUE]:%f',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(568,'You Set %u Field:%i to float Value: %f',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(569,'Get %u uint32 Value:[OPCODE]:%u [VALUE]:%u',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(570,'The uint32 value of %u in %u is: %u',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(571,'Get %u float Value:[OPCODE]:%u [VALUE]:%f',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(572,'The float of %u value in %u is: %f',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(573,'.Set32Bit:[OPCODE]:%u [VALUE]:%u',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(574,'You set Bit of Field:%u to Value: %u',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(575,'.Mod32Value:[OPCODE]:%u [VALUE]:%i',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(576,'You modified the value of Field:%u to Value: %u',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(577,'You are now invisible.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(578,'You are now visible.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(579,'Selected player or creature not have victim.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(580,'You learned all default spells for race/class and completed quests rewarded spells.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(581,'Found near gameobjects (distance %f): %u ',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(582,'SpawnTime: Full:%s Remain:%s',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(583,'%d - |cffffffff|Hgameevent:%d|h[%s]|h|r%s',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(584,'No event found!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(585,'Event not exist!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(586,'Event %u: %s%s\nStart: %s End: %s Occurence: %s Length: %s\nNext state change: %s',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(587,'Event %u already active!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(588,'Event %u not active!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(589,' Point movement to (X:%f Y:%f Z:%f)',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(590,' Fear movement',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(591,' Distract movement',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(592,'You have learned all spells in craft: %s',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(600,'The Alliance wins!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(601,'The Horde wins!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(602,'The battle for Warsong Gulch begins in 1 minute.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(603,'The battle for Warsong Gulch begins in 30 seconds. Prepare yourselves!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(604,'Let the battle for Warsong Gulch begin!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(605,'$n captured the Horde flag!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(606,'$n captured the Alliance flag!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(607,'The Horde flag was dropped by $n!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(608,'The Alliance Flag was dropped by $n!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(609,'The Alliance Flag was returned to its base by $n!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(610,'The Horde flag was returned to its base by $n!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(611,'The Horde flag was picked up by $n!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(612,'The Alliance Flag was picked up by $n!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(613,'The flags are now placed at their bases.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(636,'The Battle for Eye of the Storm begins in 1 minute.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(637,'The Battle for Eye of the Storm begins in 30 seconds.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(638,'The Battle for Eye of the Storm has begun!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(650,'Alliance',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(651,'Horde',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(652,'stables',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(653,'blacksmith',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(654,'farm',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(655,'lumber mill',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(656,'mine',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(657,'The %s has taken the %s',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(658,'$n has defended the %s',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(659,'$n has assaulted the %s',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(660,'$n claims the %s! If left unchallenged, the %s will control it in 1 minute!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(661,'The Battle for Arathi Basin begins in 1 minute.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(662,'The Battle for Arathi Basin begins in 30 seconds. Prepare yourselves!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(663,'The Battle for Arathi Basin has begun!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(664,'The Alliance has gathered $1776W resources, and is near victory!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(665,'The Horde has gathered $1777W resources, and is near victory!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(666,'After your recent battle in %s our best attempts to award you a Mark of Honor failed. Enclosed you will find the Mark of Honor we were not able to deliver to you at the time. Thanks for fighting in %s!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(700,'You must be level %u to form an arena team',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(701,'One minute until the Arena battle begins!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(702,'Thirty seconds until the Arena battle begins!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(703,'Fifteen seconds until the Arena battle begins!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(704,'The Arena battle has begun!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(705,'You must wait %s before speaking again.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(706,'This item(s) have problems with equipping/storing in inventory.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(707,'%s wishes to not be disturbed and cannot receive whisper messages: %s',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(708,'%s is Away from Keyboard: %s',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(709,'Do not Disturb',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(710,'Away from Keyboard',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(711,'Queue status for %s (Lvl: %u to %u)\nQueued alliances: %u (Need at least %u more)\nQueued hordes: %u (Need at least %u more)',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(712,'|cffff0000[BG Queue Announcer]:|r %s -- [%u-%u] A: %u (Need: %u), H: %u (Needs %u)|r',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL); -/*!40000 ALTER TABLE `mangos_string` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `npc_gossip` --- - -DROP TABLE IF EXISTS `npc_gossip`; -CREATE TABLE `npc_gossip` ( - `npc_guid` int(10) unsigned NOT NULL default '0', - `textid` mediumint(8) unsigned NOT NULL default '0', - PRIMARY KEY (`npc_guid`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8; - --- --- Dumping data for table `npc_gossip` --- - -LOCK TABLES `npc_gossip` WRITE; -/*!40000 ALTER TABLE `npc_gossip` DISABLE KEYS */; -/*!40000 ALTER TABLE `npc_gossip` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `npc_gossip_textid` --- - -DROP TABLE IF EXISTS `npc_gossip_textid`; -CREATE TABLE `npc_gossip_textid` ( - `zoneid` smallint(5) unsigned NOT NULL default '0', - `action` smallint(5) unsigned NOT NULL default '0', - `textid` mediumint(8) unsigned NOT NULL default '0', - KEY `zoneid` (`zoneid`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8; - --- --- Dumping data for table `npc_gossip_textid` --- - -LOCK TABLES `npc_gossip_textid` WRITE; -/*!40000 ALTER TABLE `npc_gossip_textid` DISABLE KEYS */; -/*!40000 ALTER TABLE `npc_gossip_textid` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `npc_option` --- - -DROP TABLE IF EXISTS `npc_option`; -CREATE TABLE `npc_option` ( - `id` tinyint(3) unsigned NOT NULL default '0', - `gossip_id` tinyint(3) unsigned NOT NULL default '0', - `npcflag` int(10) unsigned NOT NULL default '0', - `icon` tinyint(3) unsigned NOT NULL default '0', - `action` tinyint(3) unsigned NOT NULL default '0', - `option_text` text, - PRIMARY KEY (`id`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8; - --- --- Dumping data for table `npc_option` --- - -LOCK TABLES `npc_option` WRITE; -/*!40000 ALTER TABLE `npc_option` DISABLE KEYS */; -/*!40000 ALTER TABLE `npc_option` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `npc_text` --- - -DROP TABLE IF EXISTS `npc_text`; -CREATE TABLE `npc_text` ( - `ID` mediumint(8) unsigned NOT NULL default '0', - `text0_0` longtext, - `text0_1` longtext, - `lang0` tinyint(3) unsigned NOT NULL default '0', - `prob0` float NOT NULL default '0', - `em0_0` smallint(5) unsigned NOT NULL default '0', - `em0_1` smallint(5) unsigned NOT NULL default '0', - `em0_2` smallint(5) unsigned NOT NULL default '0', - `em0_3` smallint(5) unsigned NOT NULL default '0', - `em0_4` smallint(5) unsigned NOT NULL default '0', - `em0_5` smallint(5) unsigned NOT NULL default '0', - `text1_0` longtext, - `text1_1` longtext, - `lang1` tinyint(3) unsigned NOT NULL default '0', - `prob1` float NOT NULL default '0', - `em1_0` smallint(5) unsigned NOT NULL default '0', - `em1_1` smallint(5) unsigned NOT NULL default '0', - `em1_2` smallint(5) unsigned NOT NULL default '0', - `em1_3` smallint(5) unsigned NOT NULL default '0', - `em1_4` smallint(5) unsigned NOT NULL default '0', - `em1_5` smallint(5) unsigned NOT NULL default '0', - `text2_0` longtext, - `text2_1` longtext, - `lang2` tinyint(3) unsigned NOT NULL default '0', - `prob2` float NOT NULL default '0', - `em2_0` smallint(5) unsigned NOT NULL default '0', - `em2_1` smallint(5) unsigned NOT NULL default '0', - `em2_2` smallint(5) unsigned NOT NULL default '0', - `em2_3` smallint(5) unsigned NOT NULL default '0', - `em2_4` smallint(5) unsigned NOT NULL default '0', - `em2_5` smallint(5) unsigned NOT NULL default '0', - `text3_0` longtext, - `text3_1` longtext, - `lang3` tinyint(3) unsigned NOT NULL default '0', - `prob3` float NOT NULL default '0', - `em3_0` smallint(5) unsigned NOT NULL default '0', - `em3_1` smallint(5) unsigned NOT NULL default '0', - `em3_2` smallint(5) unsigned NOT NULL default '0', - `em3_3` smallint(5) unsigned NOT NULL default '0', - `em3_4` smallint(5) unsigned NOT NULL default '0', - `em3_5` smallint(5) unsigned NOT NULL default '0', - `text4_0` longtext, - `text4_1` longtext, - `lang4` tinyint(3) unsigned NOT NULL default '0', - `prob4` float NOT NULL default '0', - `em4_0` smallint(5) unsigned NOT NULL default '0', - `em4_1` smallint(5) unsigned NOT NULL default '0', - `em4_2` smallint(5) unsigned NOT NULL default '0', - `em4_3` smallint(5) unsigned NOT NULL default '0', - `em4_4` smallint(5) unsigned NOT NULL default '0', - `em4_5` smallint(5) unsigned NOT NULL default '0', - `text5_0` longtext, - `text5_1` longtext, - `lang5` tinyint(3) unsigned NOT NULL default '0', - `prob5` float NOT NULL default '0', - `em5_0` smallint(5) unsigned NOT NULL default '0', - `em5_1` smallint(5) unsigned NOT NULL default '0', - `em5_2` smallint(5) unsigned NOT NULL default '0', - `em5_3` smallint(5) unsigned NOT NULL default '0', - `em5_4` smallint(5) unsigned NOT NULL default '0', - `em5_5` smallint(5) unsigned NOT NULL default '0', - `text6_0` longtext, - `text6_1` longtext, - `lang6` tinyint(3) unsigned NOT NULL default '0', - `prob6` float NOT NULL default '0', - `em6_0` smallint(5) unsigned NOT NULL default '0', - `em6_1` smallint(5) unsigned NOT NULL default '0', - `em6_2` smallint(5) unsigned NOT NULL default '0', - `em6_3` smallint(5) unsigned NOT NULL default '0', - `em6_4` smallint(5) unsigned NOT NULL default '0', - `em6_5` smallint(5) unsigned NOT NULL default '0', - `text7_0` longtext, - `text7_1` longtext, - `lang7` tinyint(3) unsigned NOT NULL default '0', - `prob7` float NOT NULL default '0', - `em7_0` smallint(5) unsigned NOT NULL default '0', - `em7_1` smallint(5) unsigned NOT NULL default '0', - `em7_2` smallint(5) unsigned NOT NULL default '0', - `em7_3` smallint(5) unsigned NOT NULL default '0', - `em7_4` smallint(5) unsigned NOT NULL default '0', - `em7_5` smallint(5) unsigned NOT NULL default '0', - PRIMARY KEY (`ID`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8; - --- --- Dumping data for table `npc_text` --- - -LOCK TABLES `npc_text` WRITE; -/*!40000 ALTER TABLE `npc_text` DISABLE KEYS */; -/*!40000 ALTER TABLE `npc_text` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `npc_trainer` --- - -DROP TABLE IF EXISTS `npc_trainer`; -CREATE TABLE `npc_trainer` ( - `entry` mediumint(8) unsigned NOT NULL default '0', - `spell` mediumint(8) unsigned NOT NULL default '0', - `spellcost` int(10) unsigned NOT NULL default '0', - `reqskill` smallint(5) unsigned NOT NULL default '0', - `reqskillvalue` smallint(5) unsigned NOT NULL default '0', - `reqlevel` tinyint(3) unsigned NOT NULL default '0', - UNIQUE KEY `entry_spell` (`entry`,`spell`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8; - --- --- Dumping data for table `npc_trainer` --- - -LOCK TABLES `npc_trainer` WRITE; -/*!40000 ALTER TABLE `npc_trainer` DISABLE KEYS */; -/*!40000 ALTER TABLE `npc_trainer` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `npc_vendor` --- - -DROP TABLE IF EXISTS `npc_vendor`; -CREATE TABLE `npc_vendor` ( - `entry` mediumint(8) unsigned NOT NULL default '0', - `item` mediumint(8) unsigned NOT NULL default '0', - `maxcount` tinyint(3) unsigned NOT NULL default '0', - `incrtime` int(10) unsigned NOT NULL default '0', - `ExtendedCost` mediumint(8) unsigned NOT NULL default '0', - PRIMARY KEY (`entry`,`item`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Npc System'; - --- --- Dumping data for table `npc_vendor` --- - -LOCK TABLES `npc_vendor` WRITE; -/*!40000 ALTER TABLE `npc_vendor` DISABLE KEYS */; -/*!40000 ALTER TABLE `npc_vendor` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `page_text` --- - -DROP TABLE IF EXISTS `page_text`; -CREATE TABLE `page_text` ( - `entry` mediumint(8) unsigned NOT NULL default '0', - `text` longtext NOT NULL, - `next_page` mediumint(8) unsigned NOT NULL default '0', - PRIMARY KEY (`entry`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Item System'; - --- --- Dumping data for table `page_text` --- - -LOCK TABLES `page_text` WRITE; -/*!40000 ALTER TABLE `page_text` DISABLE KEYS */; -/*!40000 ALTER TABLE `page_text` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `pet_levelstats` --- - -DROP TABLE IF EXISTS `pet_levelstats`; -CREATE TABLE `pet_levelstats` ( - `creature_entry` mediumint(8) unsigned NOT NULL, - `level` tinyint(3) unsigned NOT NULL, - `hp` smallint(5) unsigned NOT NULL, - `mana` smallint(5) unsigned NOT NULL, - `armor` int(10) unsigned NOT NULL default '0', - `str` smallint(5) unsigned NOT NULL, - `agi` smallint(5) unsigned NOT NULL, - `sta` smallint(5) unsigned NOT NULL, - `inte` smallint(5) unsigned NOT NULL, - `spi` smallint(5) unsigned NOT NULL, - PRIMARY KEY (`creature_entry`,`level`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8 PACK_KEYS=0 COMMENT='Stores pet levels stats.'; - --- --- Dumping data for table `pet_levelstats` --- - -LOCK TABLES `pet_levelstats` WRITE; -/*!40000 ALTER TABLE `pet_levelstats` DISABLE KEYS */; -/*!40000 ALTER TABLE `pet_levelstats` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `pet_name_generation` --- - -DROP TABLE IF EXISTS `pet_name_generation`; -CREATE TABLE `pet_name_generation` ( - `id` mediumint(8) unsigned NOT NULL auto_increment, - `word` tinytext NOT NULL, - `entry` mediumint(8) unsigned NOT NULL default '0', - `half` tinyint(4) NOT NULL default '0', - PRIMARY KEY (`id`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8; - --- --- Dumping data for table `pet_name_generation` --- - -LOCK TABLES `pet_name_generation` WRITE; -/*!40000 ALTER TABLE `pet_name_generation` DISABLE KEYS */; -INSERT INTO `pet_name_generation` (`word`,`entry`,`half`) VALUES -('Aba',416,0), -('Az',416,0), -('Bel',416,0), -('Biz',416,0), -('Cho',416,0), -('Dag',416,0), -('Gak',416,0), -('Gar',416,0), -('Gel',416,0), -('Gho',416,0), -('Gob',416,0), -('Gra',416,0), -('Jak',416,0), -('Jub',416,0), -('Kar',416,0), -('Kup',416,0), -('Laz',416,0), -('Nal',416,0), -('Nok',416,0), -('Pag',416,0), -('Pig',416,0), -('Pip',416,0), -('Piz',416,0), -('Quz',416,0), -('Rui',416,0), -('Rul',416,0), -('Rup',416,0), -('Tar',416,0), -('Vol',416,0), -('Yaz',416,0), -('Zep',416,0), -('Zig',416,0), -('Zil',416,0), -('Zor',416,0), -('bis',416,1), -('fip',416,1), -('gup',416,1), -('ham',416,1), -('jub',416,1), -('kin',416,1), -('kol',416,1), -('lop',416,1), -('loz',416,1), -('mat',416,1), -('mir',416,1), -('nam',416,1), -('nar',416,1), -('nik',416,1), -('nip',416,1), -('pad',416,1), -('pep',416,1), -('pit',416,1), -('qua',416,1), -('rai',416,1), -('rin',416,1), -('rot',416,1), -('tai',416,1), -('tal',416,1), -('tik',416,1), -('tip',416,1), -('tog',416,1), -('tuk',416,1), -('uri',416,1), -('yal',416,1), -('yap',416,1), -('Bhee',417,0), -('Bruu',417,0), -('Czaa',417,0), -('Droo',417,0), -('Flaa',417,0), -('Fzuu',417,0), -('Ghaa',417,0), -('Gree',417,0), -('Gzaa',417,0), -('Haa',417,0), -('Haad',417,0), -('Haag',417,0), -('Haap',417,0), -('Jhaa',417,0), -('Jhuu',417,0), -('Khaa',417,0), -('Khii',417,0), -('Khuu',417,0), -('Kree',417,0), -('Luu',417,0), -('Maa',417,0), -('Nhee',417,0), -('Phuu',417,0), -('Pryy',417,0), -('Rhuu',417,0), -('Shaa',417,0), -('Sloo',417,0), -('Sruu',417,0), -('Thoo',417,0), -('Traa',417,0), -('Wraa',417,0), -('Zhaa',417,0), -('dhon',417,1), -('dhum',417,1), -('dhun',417,1), -('dom',417,1), -('don',417,1), -('drom',417,1), -('dym',417,1), -('fenn',417,1), -('fum',417,1), -('fun',417,1), -('ghon',417,1), -('ghun',417,1), -('grom',417,1), -('grym',417,1), -('hom',417,1), -('hon',417,1), -('hun',417,1), -('jhom',417,1), -('kun',417,1), -('lum',417,1), -('mmon',417,1), -('mon',417,1), -('myn',417,1), -('nam',417,1), -('nem',417,1), -('nhym',417,1), -('nom',417,1), -('num',417,1), -('phom',417,1), -('roon',417,1), -('rym',417,1), -('shon',417,1), -('thun',417,1), -('tom',417,1), -('zhem',417,1), -('zhum',417,1), -('zun',417,1), -('Bar',1860,0), -('Bel',1860,0), -('Char',1860,0), -('Grak\'',1860,0), -('Graz\'',1860,0), -('Grim',1860,0), -('Hath',1860,0), -('Hel',1860,0), -('Hok',1860,0), -('Huk',1860,0), -('Jhaz',1860,0), -('Jhom',1860,0), -('Juk\'',1860,0), -('Kal\'',1860,0), -('Klath',1860,0), -('Kon',1860,0), -('Krag',1860,0), -('Krak',1860,0), -('Mak',1860,0), -('Mezz',1860,0), -('Orm',1860,0), -('Phan',1860,0), -('Sar',1860,0), -('Tang',1860,0), -('Than',1860,0), -('Thog',1860,0), -('Thok',1860,0), -('Thul',1860,0), -('Zag\'',1860,0), -('Zang',1860,0), -('Zhar\'',1860,0), -('kath',1860,1), -('doc',1860,1), -('dok',1860,1), -('gak',1860,1), -('garth',1860,1), -('gore',1860,1), -('gorg',1860,1), -('grave',1860,1), -('gron',1860,1), -('juk',1860,1), -('krast',1860,1), -('kresh',1860,1), -('krit',1860,1), -('los',1860,1), -('mon',1860,1), -('mos',1860,1), -('moth',1860,1), -('nagma',1860,1), -('nak',1860,1), -('nar',1860,1), -('nos',1860,1), -('nuz',1860,1), -('phog',1860,1), -('rath',1860,1), -('tast',1860,1), -('taz',1860,1), -('thak',1860,1), -('thang',1860,1), -('thyk',1860,1), -('vhug',1860,1), -('zazt',1860,1), -('Ael',1863,0), -('Aez',1863,0), -('Ang',1863,0), -('Ban',1863,0), -('Bet',1863,0), -('Bro',1863,0), -('Bry',1863,0), -('Cat',1863,0), -('Dir',1863,0), -('Dis',1863,0), -('Dom',1863,0), -('Drus',1863,0), -('Fie',1863,0), -('Fier',1863,0), -('Gly',1863,0), -('Hel',1863,0), -('Hes',1863,0), -('Kal',1863,0), -('Lyn',1863,0), -('Mir',1863,0), -('Nim',1863,0), -('Sar',1863,0), -('Sel',1863,0), -('Vil',1863,0), -('Zah',1863,0), -('aith',1863,1), -('anda',1863,1), -('antia',1863,1), -('evere',1863,1), -('lia',1863,1), -('lissa',1863,1), -('neri',1863,1), -('neth',1863,1), -('nia',1863,1), -('nlissa',1863,1), -('nora',1863,1), -('nva',1863,1), -('nys',1863,1), -('ola',1863,1), -('ona',1863,1), -('ora',1863,1), -('rah',1863,1), -('riana',1863,1), -('riel',1863,1), -('rona',1863,1), -('tai',1863,1), -('tevere',1863,1), -('thea',1863,1), -('vina',1863,1), -('wena',1863,1), -('wyn',1863,1), -('xia',1863,1), -('yla',1863,1), -('yssa',1863,1), -('Flaa',17252,0), -('Haa',17252,0), -('Jhuu',17252,0), -('Shaa',17252,0), -('Thoo',17252,0), -('dhun',17252,1), -('ghun',17252,1), -('roon',17252,1), -('thun',17252,1), -('tom',17252,1); - -/*!40000 ALTER TABLE `pet_name_generation` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `petcreateinfo_spell` --- - -DROP TABLE IF EXISTS `petcreateinfo_spell`; -CREATE TABLE `petcreateinfo_spell` ( - `entry` mediumint(8) unsigned NOT NULL default '0', - `Spell1` mediumint(8) unsigned NOT NULL default '0', - `Spell2` mediumint(8) unsigned NOT NULL default '0', - `Spell3` mediumint(8) unsigned NOT NULL default '0', - `Spell4` mediumint(8) unsigned NOT NULL default '0', - PRIMARY KEY (`entry`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='Pet Create Spells'; - --- --- Dumping data for table `petcreateinfo_spell` --- - -LOCK TABLES `petcreateinfo_spell` WRITE; -/*!40000 ALTER TABLE `petcreateinfo_spell` DISABLE KEYS */; -/*!40000 ALTER TABLE `petcreateinfo_spell` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `pickpocketing_loot_template` --- - -DROP TABLE IF EXISTS `pickpocketing_loot_template`; -CREATE TABLE `pickpocketing_loot_template` ( - `entry` mediumint(8) unsigned NOT NULL default '0', - `item` mediumint(8) unsigned NOT NULL default '0', - `ChanceOrQuestChance` float NOT NULL default '100', - `groupid` tinyint(3) unsigned NOT NULL default '0', - `mincountOrRef` mediumint(9) NOT NULL default '1', - `maxcount` tinyint(3) unsigned NOT NULL default '1', - `lootcondition` tinyint(3) unsigned NOT NULL default '0', - `condition_value1` mediumint(8) unsigned NOT NULL default '0', - `condition_value2` mediumint(8) unsigned NOT NULL default '0', - PRIMARY KEY (`entry`,`item`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Loot System'; - --- --- Dumping data for table `pickpocketing_loot_template` --- - -LOCK TABLES `pickpocketing_loot_template` WRITE; -/*!40000 ALTER TABLE `pickpocketing_loot_template` DISABLE KEYS */; -/*!40000 ALTER TABLE `pickpocketing_loot_template` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `player_classlevelstats` --- - -DROP TABLE IF EXISTS `player_classlevelstats`; -CREATE TABLE `player_classlevelstats` ( - `class` tinyint(3) unsigned NOT NULL, - `level` tinyint(3) unsigned NOT NULL, - `basehp` smallint(5) unsigned NOT NULL, - `basemana` smallint(5) unsigned NOT NULL, - PRIMARY KEY (`class`,`level`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8 PACK_KEYS=0 COMMENT='Stores levels stats.'; - --- --- Dumping data for table `player_classlevelstats` --- - -LOCK TABLES `player_classlevelstats` WRITE; -/*!40000 ALTER TABLE `player_classlevelstats` DISABLE KEYS */; -INSERT INTO `player_classlevelstats` VALUES -(1,1,20,0), -(1,2,29,0), -(1,3,38,0), -(1,4,47,0), -(1,5,56,0), -(1,6,65,0), -(1,7,74,0), -(1,8,83,0), -(1,9,92,0), -(1,10,101,0), -(1,11,100,0), -(1,12,109,0), -(1,13,118,0), -(1,14,128,0), -(1,15,139,0), -(1,16,151,0), -(1,17,154,0), -(1,18,168,0), -(1,19,183,0), -(1,20,199,0), -(1,21,206,0), -(1,22,224,0), -(1,23,243,0), -(1,24,253,0), -(1,25,274,0), -(1,26,296,0), -(1,27,309,0), -(1,28,333,0), -(1,29,348,0), -(1,30,374,0), -(1,31,401,0), -(1,32,419,0), -(1,33,448,0), -(1,34,468,0), -(1,35,499,0), -(1,36,521,0), -(1,37,545,0), -(1,38,581,0), -(1,39,609,0), -(1,40,649,0), -(1,41,681,0), -(1,42,715,0), -(1,43,761,0), -(1,44,799,0), -(1,45,839,0), -(1,46,881,0), -(1,47,935,0), -(1,48,981,0), -(1,49,1029,0), -(1,50,1079,0), -(1,51,1131,0), -(1,52,1185,0), -(1,53,1241,0), -(1,54,1299,0), -(1,55,1359,0), -(1,56,1421,0), -(1,57,1485,0), -(1,58,1551,0), -(1,59,1619,0), -(1,60,1689,0), -(1,61,1902,0), -(1,62,2129,0), -(1,63,2357,0), -(1,64,2612,0), -(1,65,2883,0), -(1,66,3169,0), -(1,67,3455,0), -(1,68,3774,0), -(1,69,4109,0), -(1,70,4444,0), -(2,1,28,60), -(2,2,36,78), -(2,3,44,98), -(2,4,52,104), -(2,5,60,111), -(2,6,68,134), -(2,7,76,143), -(2,8,84,153), -(2,9,92,179), -(2,10,100,192), -(2,11,108,205), -(2,12,116,219), -(2,13,124,249), -(2,14,132,265), -(2,15,131,282), -(2,16,141,315), -(2,17,152,334), -(2,18,164,354), -(2,19,177,390), -(2,20,191,412), -(2,21,206,435), -(2,22,222,459), -(2,23,239,499), -(2,24,247,525), -(2,25,266,552), -(2,26,286,579), -(2,27,307,621), -(2,28,329,648), -(2,29,342,675), -(2,30,366,702), -(2,31,391,729), -(2,32,407,756), -(2,33,434,798), -(2,34,462,825), -(2,35,481,852), -(2,36,511,879), -(2,37,542,906), -(2,38,564,933), -(2,39,597,960), -(2,40,621,987), -(2,41,656,1014), -(2,42,682,1041), -(2,43,719,1068), -(2,44,747,1110), -(2,45,786,1137), -(2,46,816,1164), -(2,47,857,1176), -(2,48,889,1203), -(2,49,922,1230), -(2,50,966,1257), -(2,51,1001,1284), -(2,52,1037,1311), -(2,53,1084,1338), -(2,54,1122,1365), -(2,55,1161,1392), -(2,56,1201,1419), -(2,57,1252,1446), -(2,58,1294,1458), -(2,59,1337,1485), -(2,60,1381,1512), -(2,61,1540,1656), -(2,62,1708,1800), -(2,63,1884,1944), -(2,64,2068,2088), -(2,65,2262,2232), -(2,66,2466,2377), -(2,67,2679,2521), -(2,68,2901,2665), -(2,69,3134,2809), -(2,70,3377,2953), -(3,1,46,65), -(3,2,53,70), -(3,3,60,76), -(3,4,67,98), -(3,5,74,106), -(3,6,81,130), -(3,7,88,140), -(3,8,95,166), -(3,9,102,193), -(3,10,109,206), -(3,11,116,235), -(3,12,123,250), -(3,13,130,266), -(3,14,138,298), -(3,15,147,316), -(3,16,157,350), -(3,17,168,370), -(3,18,180,391), -(3,19,193,428), -(3,20,207,451), -(3,21,222,475), -(3,22,238,515), -(3,23,255,541), -(3,24,273,568), -(3,25,292,611), -(3,26,312,640), -(3,27,333,670), -(3,28,355,715), -(3,29,378,745), -(3,30,402,775), -(3,31,417,805), -(3,32,443,850), -(3,33,470,880), -(3,34,498,910), -(3,35,527,940), -(3,36,547,970), -(3,37,578,1015), -(3,38,610,1045), -(3,39,643,1075), -(3,40,667,1105), -(3,41,702,1135), -(3,42,738,1180), -(3,43,775,1210), -(3,44,803,1240), -(3,45,842,1270), -(3,46,872,1300), -(3,47,913,1330), -(3,48,955,1360), -(3,49,994,1390), -(3,50,1047,1420), -(3,51,1067,1450), -(3,52,1113,1480), -(3,53,1150,1510), -(3,54,1198,1540), -(3,55,1237,1570), -(3,56,1287,1600), -(3,57,1328,1630), -(3,58,1370,1660), -(3,59,1423,1690), -(3,60,1467,1720), -(3,61,1633,1886), -(3,62,1819,2053), -(3,63,2003,2219), -(3,64,2195,2385), -(3,65,2397,2552), -(3,66,2623,2718), -(3,67,2844,2884), -(3,68,3075,3050), -(3,69,3316,3217), -(3,70,3568,3383), -(4,1,25,0), -(4,2,32,0), -(4,3,49,0), -(4,4,56,0), -(4,5,63,0), -(4,6,70,0), -(4,7,87,0), -(4,8,94,0), -(4,9,101,0), -(4,10,118,0), -(4,11,125,0), -(4,12,142,0), -(4,13,149,0), -(4,14,156,0), -(4,15,173,0), -(4,16,181,0), -(4,17,190,0), -(4,18,200,0), -(4,19,221,0), -(4,20,233,0), -(4,21,246,0), -(4,22,260,0), -(4,23,275,0), -(4,24,301,0), -(4,25,318,0), -(4,26,336,0), -(4,27,355,0), -(4,28,375,0), -(4,29,396,0), -(4,30,428,0), -(4,31,451,0), -(4,32,475,0), -(4,33,500,0), -(4,34,526,0), -(4,35,553,0), -(4,36,581,0), -(4,37,610,0), -(4,38,640,0), -(4,39,671,0), -(4,40,703,0), -(4,41,736,0), -(4,42,770,0), -(4,43,805,0), -(4,44,841,0), -(4,45,878,0), -(4,46,916,0), -(4,47,955,0), -(4,48,995,0), -(4,49,1026,0), -(4,50,1068,0), -(4,51,1111,0), -(4,52,1155,0), -(4,53,1200,0), -(4,54,1246,0), -(4,55,1283,0), -(4,56,1331,0), -(4,57,1380,0), -(4,58,1430,0), -(4,59,1471,0), -(4,60,1523,0), -(4,61,1702,0), -(4,62,1879,0), -(4,63,2077,0), -(4,64,2285,0), -(4,65,2489,0), -(4,66,2717,0), -(4,67,2941,0), -(4,68,3190,0), -(4,69,3450,0), -(4,70,3704,0), -(5,1,52,73), -(5,2,57,76), -(5,3,72,95), -(5,4,77,114), -(5,5,92,133), -(5,6,97,152), -(5,7,112,171), -(5,8,117,190), -(5,9,132,209), -(5,10,137,212), -(5,11,142,215), -(5,12,157,234), -(5,13,172,254), -(5,14,177,260), -(5,15,192,282), -(5,16,197,305), -(5,17,212,329), -(5,18,227,339), -(5,19,232,365), -(5,20,247,377), -(5,21,252,405), -(5,22,268,434), -(5,23,275,449), -(5,24,293,480), -(5,25,302,497), -(5,26,322,530), -(5,27,343,549), -(5,28,355,584), -(5,29,378,605), -(5,30,392,627), -(5,31,417,665), -(5,32,433,689), -(5,33,460,728), -(5,34,478,752), -(5,35,507,776), -(5,36,527,800), -(5,37,548,839), -(5,38,580,863), -(5,39,603,887), -(5,40,637,911), -(5,41,662,950), -(5,42,698,974), -(5,43,725,998), -(5,44,763,1022), -(5,45,792,1046), -(5,46,822,1070), -(5,47,863,1094), -(5,48,895,1118), -(5,49,928,1142), -(5,50,972,1166), -(5,51,1007,1190), -(5,52,1053,1214), -(5,53,1090,1238), -(5,54,1128,1262), -(5,55,1177,1271), -(5,56,1217,1295), -(5,57,1258,1319), -(5,58,1300,1343), -(5,59,1353,1352), -(5,60,1397,1376), -(5,61,1557,1500), -(5,62,1738,1625), -(5,63,1916,1749), -(5,64,2101,1873), -(5,65,2295,1998), -(5,66,2495,2122), -(5,67,2719,2247), -(5,68,2936,2371), -(5,69,3160,2495), -(5,70,3391,2620), -(7,1,37,85), -(7,2,44,91), -(7,3,51,98), -(7,4,58,106), -(7,5,65,115), -(7,6,72,125), -(7,7,79,136), -(7,8,86,148), -(7,9,93,161), -(7,10,100,175), -(7,11,107,190), -(7,12,114,206), -(7,13,121,223), -(7,14,128,241), -(7,15,135,260), -(7,16,142,280), -(7,17,150,301), -(7,18,159,323), -(7,19,169,346), -(7,20,180,370), -(7,21,192,395), -(7,22,205,421), -(7,23,219,448), -(7,24,234,476), -(7,25,240,505), -(7,26,257,535), -(7,27,275,566), -(7,28,294,598), -(7,29,314,631), -(7,30,335,665), -(7,31,347,699), -(7,32,370,733), -(7,33,394,767), -(7,34,419,786), -(7,35,435,820), -(7,36,462,854), -(7,37,490,888), -(7,38,509,922), -(7,39,539,941), -(7,40,570,975), -(7,41,592,1009), -(7,42,625,1028), -(7,43,649,1062), -(7,44,684,1096), -(7,45,710,1115), -(7,46,747,1149), -(7,47,775,1183), -(7,48,814,1202), -(7,49,844,1236), -(7,50,885,1255), -(7,51,917,1289), -(7,52,960,1323), -(7,53,994,1342), -(7,54,1029,1376), -(7,55,1075,1395), -(7,56,1112,1414), -(7,57,1150,1448), -(7,58,1199,1467), -(7,59,1239,1501), -(7,60,1330,1520), -(7,61,1428,1664), -(7,62,1583,1808), -(7,63,1760,1951), -(7,64,1932,2095), -(7,65,2114,2239), -(7,66,2304,2383), -(7,67,2504,2527), -(7,68,2713,2670), -(7,69,2931,2814), -(7,70,3159,2958), -(8,1,32,100), -(8,2,47,110), -(8,3,52,106), -(8,4,67,118), -(8,5,82,131), -(8,6,97,130), -(8,7,102,145), -(8,8,117,146), -(8,9,132,163), -(8,10,137,196), -(8,11,152,215), -(8,12,167,220), -(8,13,172,241), -(8,14,187,263), -(8,15,202,271), -(8,16,207,295), -(8,17,222,305), -(8,18,237,331), -(8,19,242,343), -(8,20,257,371), -(8,21,272,385), -(8,22,277,415), -(8,23,292,431), -(8,24,298,463), -(8,25,315,481), -(8,26,333,515), -(8,27,342,535), -(8,28,362,556), -(8,29,373,592), -(8,30,395,613), -(8,31,418,634), -(8,32,432,670), -(8,33,457,691), -(8,34,473,712), -(8,35,500,733), -(8,36,518,754), -(8,37,547,790), -(8,38,577,811), -(8,39,598,832), -(8,40,630,853), -(8,41,653,874), -(8,42,687,895), -(8,43,712,916), -(8,44,748,937), -(8,45,775,958), -(8,46,813,979), -(8,47,842,1000), -(8,48,882,1021), -(8,49,913,1042), -(8,50,955,1048), -(8,51,988,1069), -(8,52,1032,1090), -(8,53,1067,1111), -(8,54,1103,1117), -(8,55,1150,1138), -(8,56,1188,1159), -(8,57,1237,1165), -(8,58,1277,1186), -(8,59,1328,1192), -(8,60,1370,1213), -(8,61,1526,1316), -(8,62,1702,1419), -(8,63,1875,1521), -(8,64,2070,1624), -(8,65,2261,1727), -(8,66,2461,1830), -(8,67,2686,1932), -(8,68,2906,2035), -(8,69,3136,2138), -(8,70,3393,2241), -(9,1,23,90), -(9,2,28,98), -(9,3,43,107), -(9,4,48,102), -(9,5,63,113), -(9,6,68,126), -(9,7,83,144), -(9,8,88,162), -(9,9,93,180), -(9,10,108,198), -(9,11,123,200), -(9,12,128,218), -(9,13,143,237), -(9,14,148,257), -(9,15,153,278), -(9,16,168,300), -(9,17,173,308), -(9,18,189,332), -(9,19,196,357), -(9,20,204,383), -(9,21,223,395), -(9,22,233,423), -(9,23,244,452), -(9,24,266,467), -(9,25,279,498), -(9,26,293,530), -(9,27,318,548), -(9,28,334,582), -(9,29,351,602), -(9,30,379,638), -(9,31,398,674), -(9,32,418,695), -(9,33,439,731), -(9,34,471,752), -(9,35,494,788), -(9,36,518,809), -(9,37,543,830), -(9,38,569,866), -(9,39,606,887), -(9,40,634,923), -(9,41,663,944), -(9,42,693,965), -(9,43,724,1001), -(9,44,756,1022), -(9,45,799,1043), -(9,46,832,1064), -(9,47,868,1100), -(9,48,904,1121), -(9,49,941,1142), -(9,50,979,1163), -(9,51,1018,1184), -(9,52,1058,1205), -(9,53,1099,1226), -(9,54,1141,1247), -(9,55,1184,1268), -(9,56,1228,1289), -(9,57,1273,1310), -(9,58,1319,1331), -(9,59,1366,1352), -(9,60,1414,1373), -(9,61,1580,1497), -(9,62,1755,1621), -(9,63,1939,1745), -(9,64,2133,1870), -(9,65,2323,1994), -(9,66,2535,2118), -(9,67,2758,2242), -(9,68,2991,2366), -(9,69,3235,2490), -(9,70,3490,2615), -(11,1,44,60), -(11,2,51,66), -(11,3,58,73), -(11,4,75,81), -(11,5,82,90), -(11,6,89,100), -(11,7,106,111), -(11,8,113,123), -(11,9,120,136), -(11,10,137,150), -(11,11,144,165), -(11,12,151,182), -(11,13,168,200), -(11,14,175,219), -(11,15,182,239), -(11,16,199,260), -(11,17,206,282), -(11,18,214,305), -(11,19,233,329), -(11,20,243,354), -(11,21,254,380), -(11,22,266,392), -(11,23,289,420), -(11,24,303,449), -(11,25,318,479), -(11,26,334,509), -(11,27,361,524), -(11,28,379,554), -(11,29,398,584), -(11,30,418,614), -(11,31,439,629), -(11,32,461,659), -(11,33,494,689), -(11,34,518,704), -(11,35,543,734), -(11,36,569,749), -(11,37,596,779), -(11,38,624,809), -(11,39,653,824), -(11,40,683,854), -(11,41,714,869), -(11,42,746,899), -(11,43,779,914), -(11,44,823,944), -(11,45,858,959), -(11,46,894,989), -(11,47,921,1004), -(11,48,959,1019), -(11,49,998,1049), -(11,50,1038,1064), -(11,51,1079,1079), -(11,52,1121,1109), -(11,53,1164,1124), -(11,54,1208,1139), -(11,55,1253,1154), -(11,56,1299,1169), -(11,57,1346,1199), -(11,58,1384,1214), -(11,59,1433,1229), -(11,60,1483,1244), -(11,61,1657,1357), -(11,62,1840,1469), -(11,63,2020,1582), -(11,64,2222,1694), -(11,65,2433,1807), -(11,66,2640,1919), -(11,67,2872,2032), -(11,68,3114,2145), -(11,69,3351,2257), -(11,70,3614,2370); -/*!40000 ALTER TABLE `player_classlevelstats` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `player_levelstats` --- - -DROP TABLE IF EXISTS `player_levelstats`; -CREATE TABLE `player_levelstats` ( - `race` tinyint(3) unsigned NOT NULL, - `class` tinyint(3) unsigned NOT NULL, - `level` tinyint(3) unsigned NOT NULL, - `str` tinyint(3) unsigned NOT NULL, - `agi` tinyint(3) unsigned NOT NULL, - `sta` tinyint(3) unsigned NOT NULL, - `inte` tinyint(3) unsigned NOT NULL, - `spi` tinyint(3) unsigned NOT NULL, - PRIMARY KEY (`race`,`class`,`level`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8 PACK_KEYS=0 COMMENT='Stores levels stats.'; - --- --- Dumping data for table `player_levelstats` --- - -LOCK TABLES `player_levelstats` WRITE; -/*!40000 ALTER TABLE `player_levelstats` DISABLE KEYS */; -INSERT INTO `player_levelstats` VALUES -(1,1,1,23,20,22,20,20), -(1,1,2,24,21,23,20,20), -(1,1,3,26,22,24,20,21), -(1,1,4,27,22,26,20,21), -(1,1,5,28,23,27,20,21), -(1,1,6,30,24,28,20,21), -(1,1,7,31,25,29,21,22), -(1,1,8,32,26,30,21,22), -(1,1,9,34,26,32,21,22), -(1,1,10,35,27,33,21,23), -(1,1,11,36,28,34,21,23), -(1,1,12,38,29,35,21,23), -(1,1,13,39,30,37,21,24), -(1,1,14,41,31,38,21,24), -(1,1,15,42,32,39,21,24), -(1,1,16,44,33,41,21,25), -(1,1,17,45,34,42,22,25), -(1,1,18,47,34,43,22,25), -(1,1,19,48,35,45,22,26), -(1,1,20,50,36,46,22,26), -(1,1,21,51,37,48,22,26), -(1,1,22,53,38,49,22,27), -(1,1,23,54,39,51,22,27), -(1,1,24,56,40,52,23,28), -(1,1,25,58,41,53,23,28), -(1,1,26,59,42,55,23,28), -(1,1,27,61,43,56,23,29), -(1,1,28,63,44,58,23,29), -(1,1,29,64,45,59,23,30), -(1,1,30,66,46,61,24,30), -(1,1,31,68,47,62,24,30), -(1,1,32,69,48,64,24,31), -(1,1,33,71,50,66,24,31), -(1,1,34,73,51,67,24,32), -(1,1,35,74,52,69,24,32), -(1,1,36,76,53,70,25,33), -(1,1,37,78,54,72,25,33), -(1,1,38,80,55,74,25,34), -(1,1,39,82,56,75,25,34), -(1,1,40,83,57,77,25,35), -(1,1,41,85,58,79,26,35), -(1,1,42,87,60,80,26,35), -(1,1,43,89,61,82,26,36), -(1,1,44,91,62,84,26,36), -(1,1,45,93,63,85,26,37), -(1,1,46,95,64,87,27,37), -(1,1,47,97,66,89,27,38), -(1,1,48,99,67,91,27,38), -(1,1,49,101,68,93,27,39), -(1,1,50,103,69,94,28,40), -(1,1,51,105,71,96,28,40), -(1,1,52,107,72,98,28,41), -(1,1,53,109,73,100,28,41), -(1,1,54,111,74,102,29,42), -(1,1,55,113,76,103,29,42), -(1,1,56,115,77,105,29,43), -(1,1,57,117,78,107,29,43), -(1,1,58,119,79,109,30,44), -(1,1,59,121,81,111,30,44), -(1,1,60,123,82,113,30,45), -(1,1,61,125,83,115,30,46), -(1,1,62,127,85,117,31,46), -(1,1,63,129,86,119,31,47), -(1,1,64,132,88,121,31,47), -(1,1,65,134,89,123,32,48), -(1,1,66,136,90,125,32,49), -(1,1,67,138,92,127,32,49), -(1,1,68,140,93,129,32,50), -(1,1,69,143,95,131,33,50), -(1,1,70,145,96,133,33,51), -(1,2,1,22,20,22,20,21), -(1,2,2,23,21,23,21,22), -(1,2,3,24,21,24,21,22), -(1,2,4,25,22,25,22,23), -(1,2,5,26,22,26,23,24), -(1,2,6,28,23,27,23,25), -(1,2,7,29,24,28,24,25), -(1,2,8,30,24,29,25,26), -(1,2,9,31,25,30,25,27), -(1,2,10,32,25,32,26,27), -(1,2,11,33,26,33,27,28), -(1,2,12,35,27,34,27,29), -(1,2,13,36,27,35,28,30), -(1,2,14,37,28,36,29,31), -(1,2,15,38,29,37,30,31), -(1,2,16,40,29,38,30,32), -(1,2,17,41,30,40,31,33), -(1,2,18,42,31,41,32,34), -(1,2,19,43,31,42,33,35), -(1,2,20,45,32,43,33,35), -(1,2,21,46,33,45,34,36), -(1,2,22,47,33,46,35,37), -(1,2,23,49,34,47,36,38), -(1,2,24,50,35,48,37,39), -(1,2,25,51,36,50,37,40), -(1,2,26,53,36,51,38,41), -(1,2,27,54,37,52,39,42), -(1,2,28,56,38,54,40,43), -(1,2,29,57,39,55,41,43), -(1,2,30,58,39,56,42,44), -(1,2,31,60,40,58,43,45), -(1,2,32,61,41,59,43,46), -(1,2,33,63,42,60,44,47), -(1,2,34,64,43,62,45,48), -(1,2,35,66,44,63,46,49), -(1,2,36,67,44,65,47,50), -(1,2,37,69,45,66,48,51), -(1,2,38,70,46,67,49,52), -(1,2,39,72,47,69,50,53), -(1,2,40,73,48,70,51,54), -(1,2,41,75,49,72,52,55), -(1,2,42,77,49,73,53,56), -(1,2,43,78,50,75,54,57), -(1,2,44,80,51,76,55,58), -(1,2,45,81,52,78,56,59), -(1,2,46,83,53,79,57,61), -(1,2,47,85,54,81,58,62), -(1,2,48,86,55,83,59,63), -(1,2,49,88,56,84,60,64), -(1,2,50,90,57,86,61,65), -(1,2,51,91,58,87,62,66), -(1,2,52,93,59,89,63,67), -(1,2,53,95,60,91,64,68), -(1,2,54,97,61,92,65,69), -(1,2,55,98,61,94,66,71), -(1,2,56,100,62,95,67,72), -(1,2,57,102,63,97,68,73), -(1,2,58,104,64,99,69,74), -(1,2,59,105,65,101,70,75), -(1,2,60,107,66,102,71,77), -(1,2,61,109,67,104,73,78), -(1,2,62,111,69,106,74,79), -(1,2,63,113,70,107,75,80), -(1,2,64,115,71,109,76,81), -(1,2,65,116,72,111,77,83), -(1,2,66,118,73,113,78,84), -(1,2,67,120,74,115,79,85), -(1,2,68,122,75,116,81,86), -(1,2,69,124,76,118,82,88), -(1,2,70,126,77,120,83,89), -(1,4,1,21,23,21,20,20), -(1,4,2,22,24,22,20,20), -(1,4,3,23,26,22,20,21), -(1,4,4,23,27,23,20,21), -(1,4,5,24,29,24,21,21), -(1,4,6,25,30,25,21,22), -(1,4,7,26,32,25,21,22), -(1,4,8,26,33,26,21,23), -(1,4,9,27,35,27,21,23), -(1,4,10,28,36,27,21,23), -(1,4,11,29,38,28,22,24), -(1,4,12,30,39,29,22,24), -(1,4,13,31,41,30,22,25), -(1,4,14,31,43,31,22,25), -(1,4,15,32,44,31,22,25), -(1,4,16,33,46,32,23,26), -(1,4,17,34,48,33,23,26), -(1,4,18,35,49,34,23,27), -(1,4,19,36,51,35,23,27), -(1,4,20,37,53,35,23,28), -(1,4,21,38,54,36,24,28), -(1,4,22,39,56,37,24,29), -(1,4,23,40,58,38,24,29), -(1,4,24,41,60,39,24,30), -(1,4,25,42,61,40,25,30), -(1,4,26,43,63,41,25,31), -(1,4,27,44,65,42,25,31), -(1,4,28,45,67,43,25,32), -(1,4,29,46,69,43,25,32), -(1,4,30,47,71,44,26,33), -(1,4,31,48,72,45,26,33), -(1,4,32,49,74,46,26,34), -(1,4,33,50,76,47,27,34), -(1,4,34,51,78,48,27,35), -(1,4,35,52,80,49,27,35), -(1,4,36,53,82,50,27,36), -(1,4,37,54,84,51,28,36), -(1,4,38,55,86,52,28,37), -(1,4,39,56,88,53,28,38), -(1,4,40,57,90,54,28,38), -(1,4,41,58,92,55,29,39), -(1,4,42,60,94,56,29,39), -(1,4,43,61,96,57,29,40), -(1,4,44,62,98,58,30,40), -(1,4,45,63,100,59,30,41), -(1,4,46,64,103,61,30,42), -(1,4,47,65,105,62,31,42), -(1,4,48,66,107,63,31,43), -(1,4,49,68,109,64,31,44), -(1,4,50,69,111,65,32,44), -(1,4,51,70,113,66,32,45), -(1,4,52,71,116,67,32,45), -(1,4,53,73,118,68,33,46), -(1,4,54,74,120,69,33,47), -(1,4,55,75,122,71,33,47), -(1,4,56,76,125,72,34,48), -(1,4,57,78,127,73,34,49), -(1,4,58,79,129,74,34,49), -(1,4,59,80,131,75,35,50), -(1,4,60,81,134,77,35,51), -(1,4,61,83,136,78,35,51), -(1,4,62,84,138,79,36,52), -(1,4,63,85,141,80,36,53), -(1,4,64,87,143,81,37,54), -(1,4,65,88,146,83,37,54), -(1,4,66,89,148,84,37,55), -(1,4,67,91,151,85,38,56), -(1,4,68,92,153,86,38,57), -(1,4,69,94,156,88,39,57), -(1,4,70,95,158,89,39,58), -(1,5,1,20,20,20,22,23), -(1,5,2,20,20,20,23,24), -(1,5,3,20,20,21,25,26), -(1,5,4,20,21,21,26,27), -(1,5,5,21,21,21,27,28), -(1,5,6,21,21,22,29,30), -(1,5,7,21,21,22,30,31), -(1,5,8,21,22,23,31,33), -(1,5,9,21,22,23,33,34), -(1,5,10,21,22,23,34,36), -(1,5,11,22,22,24,36,37), -(1,5,12,22,23,24,37,39), -(1,5,13,22,23,25,38,40), -(1,5,14,22,23,25,40,42), -(1,5,15,22,23,25,41,43), -(1,5,16,23,24,26,43,45), -(1,5,17,23,24,26,44,46), -(1,5,18,23,24,27,46,48), -(1,5,19,23,24,27,47,49), -(1,5,20,23,25,28,49,51), -(1,5,21,24,25,28,51,53), -(1,5,22,24,25,29,52,54), -(1,5,23,24,26,29,54,56), -(1,5,24,24,26,30,55,58), -(1,5,25,25,26,30,57,59), -(1,5,26,25,27,31,59,61), -(1,5,27,25,27,31,60,63), -(1,5,28,25,27,32,62,65), -(1,5,29,25,28,32,64,66), -(1,5,30,26,28,33,65,68), -(1,5,31,26,28,33,67,70), -(1,5,32,26,29,34,69,72), -(1,5,33,27,29,34,70,73), -(1,5,34,27,29,35,72,75), -(1,5,35,27,30,35,74,77), -(1,5,36,27,30,36,76,79), -(1,5,37,28,30,36,78,81), -(1,5,38,28,31,37,79,83), -(1,5,39,28,31,38,81,85), -(1,5,40,28,31,38,83,87), -(1,5,41,29,32,39,85,88), -(1,5,42,29,32,39,87,90), -(1,5,43,29,33,40,89,92), -(1,5,44,30,33,40,91,94), -(1,5,45,30,33,41,92,96), -(1,5,46,30,34,42,94,98), -(1,5,47,31,34,42,96,100), -(1,5,48,31,35,43,98,102), -(1,5,49,31,35,44,100,104), -(1,5,50,32,36,44,102,106), -(1,5,51,32,36,45,104,109), -(1,5,52,32,36,45,106,111), -(1,5,53,33,37,46,108,113), -(1,5,54,33,37,47,110,115), -(1,5,55,33,38,47,112,117), -(1,5,56,34,38,48,114,119), -(1,5,57,34,39,49,117,121), -(1,5,58,34,39,49,119,124), -(1,5,59,35,40,50,121,126), -(1,5,60,35,40,51,123,128), -(1,5,61,35,41,51,125,130), -(1,5,62,36,41,52,127,132), -(1,5,63,36,41,53,129,135), -(1,5,64,37,42,54,132,137), -(1,5,65,37,42,54,134,139), -(1,5,66,37,43,55,136,142), -(1,5,67,38,43,56,138,144), -(1,5,68,38,44,57,140,146), -(1,5,69,39,44,57,143,149), -(1,5,70,39,45,58,145,151), -(1,8,1,20,20,20,23,22), -(1,8,2,20,20,20,24,23), -(1,8,3,20,20,21,26,25), -(1,8,4,20,20,21,27,26), -(1,8,5,20,21,21,28,27), -(1,8,6,20,21,21,30,29), -(1,8,7,21,21,22,31,30), -(1,8,8,21,21,22,33,31), -(1,8,9,21,21,22,34,33), -(1,8,10,21,21,23,36,34), -(1,8,11,21,22,23,37,36), -(1,8,12,21,22,23,39,37), -(1,8,13,21,22,24,40,38), -(1,8,14,21,22,24,42,40), -(1,8,15,21,22,24,43,41), -(1,8,16,21,23,25,45,43), -(1,8,17,22,23,25,46,44), -(1,8,18,22,23,25,48,46), -(1,8,19,22,23,26,49,47), -(1,8,20,22,23,26,51,49), -(1,8,21,22,24,26,53,51), -(1,8,22,22,24,27,54,52), -(1,8,23,22,24,27,56,54), -(1,8,24,23,24,28,58,55), -(1,8,25,23,25,28,59,57), -(1,8,26,23,25,28,61,59), -(1,8,27,23,25,29,63,60), -(1,8,28,23,25,29,65,62), -(1,8,29,23,25,30,66,64), -(1,8,30,24,26,30,68,65), -(1,8,31,24,26,30,70,67), -(1,8,32,24,26,31,72,69), -(1,8,33,24,27,31,73,70), -(1,8,34,24,27,32,75,72), -(1,8,35,24,27,32,77,74), -(1,8,36,25,27,33,79,76), -(1,8,37,25,28,33,81,78), -(1,8,38,25,28,34,83,79), -(1,8,39,25,28,34,85,81), -(1,8,40,25,28,35,87,83), -(1,8,41,26,29,35,88,85), -(1,8,42,26,29,35,90,87), -(1,8,43,26,29,36,92,89), -(1,8,44,26,30,36,94,91), -(1,8,45,26,30,37,96,92), -(1,8,46,27,30,37,98,94), -(1,8,47,27,31,38,100,96), -(1,8,48,27,31,38,102,98), -(1,8,49,27,31,39,104,100), -(1,8,50,28,32,40,106,102), -(1,8,51,28,32,40,109,104), -(1,8,52,28,32,41,111,106), -(1,8,53,28,33,41,113,108), -(1,8,54,29,33,42,115,110), -(1,8,55,29,33,42,117,112), -(1,8,56,29,34,43,119,114), -(1,8,57,29,34,43,121,117), -(1,8,58,30,34,44,124,119), -(1,8,59,30,35,44,126,121), -(1,8,60,30,35,45,128,123), -(1,8,61,30,35,46,130,125), -(1,8,62,31,36,46,132,127), -(1,8,63,31,36,47,135,129), -(1,8,64,31,37,47,137,132), -(1,8,65,32,37,48,139,134), -(1,8,66,32,37,49,142,136), -(1,8,67,32,38,49,144,138), -(1,8,68,32,38,50,146,140), -(1,8,69,33,39,50,149,143), -(1,8,70,33,39,51,151,145), -(1,9,1,20,20,21,22,22), -(1,9,2,20,20,22,23,23), -(1,9,3,21,21,22,24,24), -(1,9,4,21,21,23,26,25), -(1,9,5,21,21,23,27,27), -(1,9,6,21,22,24,28,28), -(1,9,7,22,22,24,29,29), -(1,9,8,22,23,25,30,30), -(1,9,9,22,23,26,32,31), -(1,9,10,23,23,26,33,33), -(1,9,11,23,24,27,34,34), -(1,9,12,23,24,27,35,35), -(1,9,13,24,25,28,37,36), -(1,9,14,24,25,29,38,38), -(1,9,15,24,25,29,39,39), -(1,9,16,25,26,30,41,40), -(1,9,17,25,26,31,42,42), -(1,9,18,25,27,31,43,43), -(1,9,19,26,27,32,45,44), -(1,9,20,26,28,33,46,46), -(1,9,21,26,28,33,48,47), -(1,9,22,27,29,34,49,49), -(1,9,23,27,29,35,51,50), -(1,9,24,28,30,35,52,51), -(1,9,25,28,30,36,53,53), -(1,9,26,28,31,37,55,54), -(1,9,27,29,31,37,56,56), -(1,9,28,29,32,38,58,57), -(1,9,29,30,32,39,59,59), -(1,9,30,30,33,40,61,60), -(1,9,31,30,33,40,62,62), -(1,9,32,31,34,41,64,63), -(1,9,33,31,34,42,66,65), -(1,9,34,32,35,43,67,66), -(1,9,35,32,35,44,69,68), -(1,9,36,33,36,44,70,69), -(1,9,37,33,36,45,72,71), -(1,9,38,34,37,46,74,73), -(1,9,39,34,38,47,75,74), -(1,9,40,35,38,48,77,76), -(1,9,41,35,39,48,79,78), -(1,9,42,35,39,49,80,79), -(1,9,43,36,40,50,82,81), -(1,9,44,36,40,51,84,83), -(1,9,45,37,41,52,85,84), -(1,9,46,37,42,53,87,86), -(1,9,47,38,42,54,89,88), -(1,9,48,38,43,55,91,89), -(1,9,49,39,44,55,93,91), -(1,9,50,40,44,56,94,93), -(1,9,51,40,45,57,96,95), -(1,9,52,41,45,58,98,97), -(1,9,53,41,46,59,100,98), -(1,9,54,42,47,60,102,100), -(1,9,55,42,47,61,103,102), -(1,9,56,43,48,62,105,104), -(1,9,57,43,49,63,107,106), -(1,9,58,44,49,64,109,108), -(1,9,59,44,50,65,111,109), -(1,9,60,45,51,66,113,111), -(1,9,61,46,51,67,115,113), -(1,9,62,46,52,68,117,115), -(1,9,63,47,53,69,119,117), -(1,9,64,47,54,70,121,119), -(1,9,65,48,54,71,123,121), -(1,9,66,49,55,72,125,123), -(1,9,67,49,56,73,127,125), -(1,9,68,50,57,74,129,127), -(1,9,69,50,57,75,131,129), -(1,9,70,51,58,76,133,131), -(2,1,1,26,17,24,17,23), -(2,1,2,27,18,25,17,23), -(2,1,3,29,19,26,17,24), -(2,1,4,30,19,27,17,24), -(2,1,5,31,20,29,17,24), -(2,1,6,32,21,30,17,24), -(2,1,7,34,22,31,18,25), -(2,1,8,35,23,32,18,25), -(2,1,9,37,24,34,18,25), -(2,1,10,38,24,35,18,26), -(2,1,11,39,25,36,18,26), -(2,1,12,41,26,37,18,26), -(2,1,13,42,27,39,18,27), -(2,1,14,44,28,40,18,27), -(2,1,15,45,29,41,18,27), -(2,1,16,47,30,43,19,28), -(2,1,17,48,31,44,19,28), -(2,1,18,50,32,45,19,28), -(2,1,19,51,33,47,19,29), -(2,1,20,53,34,48,19,29), -(2,1,21,54,34,50,19,29), -(2,1,22,56,35,51,19,30), -(2,1,23,57,36,52,20,30), -(2,1,24,59,37,54,20,30), -(2,1,25,60,38,55,20,31), -(2,1,26,62,39,57,20,31), -(2,1,27,64,40,58,20,32), -(2,1,28,65,41,60,20,32), -(2,1,29,67,43,61,21,32), -(2,1,30,69,44,63,21,33), -(2,1,31,70,45,64,21,33), -(2,1,32,72,46,66,21,34), -(2,1,33,74,47,67,21,34), -(2,1,34,76,48,69,21,35), -(2,1,35,77,49,71,22,35), -(2,1,36,79,50,72,22,36), -(2,1,37,81,51,74,22,36), -(2,1,38,83,52,76,22,36), -(2,1,39,84,53,77,22,37), -(2,1,40,86,55,79,23,37), -(2,1,41,88,56,81,23,38), -(2,1,42,90,57,82,23,38), -(2,1,43,92,58,84,23,39), -(2,1,44,94,59,86,23,39), -(2,1,45,96,60,87,24,40), -(2,1,46,98,62,89,24,40), -(2,1,47,100,63,91,24,41), -(2,1,48,101,64,93,24,41), -(2,1,49,103,65,94,25,42), -(2,1,50,105,66,96,25,42), -(2,1,51,107,68,98,25,43), -(2,1,52,109,69,100,25,43), -(2,1,53,111,70,102,25,44), -(2,1,54,113,71,104,26,45), -(2,1,55,115,73,105,26,45), -(2,1,56,118,74,107,26,46), -(2,1,57,120,75,109,26,46), -(2,1,58,122,77,111,27,47), -(2,1,59,124,78,113,27,47), -(2,1,60,126,79,115,27,48), -(2,1,61,128,81,117,27,48), -(2,1,62,130,82,119,28,49), -(2,1,63,132,83,121,28,50), -(2,1,64,135,85,123,28,50), -(2,1,65,137,86,125,29,51), -(2,1,66,139,87,127,29,52), -(2,1,67,141,89,129,29,52), -(2,1,68,143,90,131,29,53), -(2,1,69,146,92,133,30,53), -(2,1,70,148,93,135,30,54), -(2,3,1,23,20,23,17,24), -(2,3,2,23,21,24,18,25), -(2,3,3,24,23,25,18,25), -(2,3,4,24,24,26,19,26), -(2,3,5,25,25,27,19,26), -(2,3,6,25,27,28,20,27), -(2,3,7,26,28,28,21,28), -(2,3,8,26,30,29,21,28), -(2,3,9,26,31,30,22,29), -(2,3,10,27,33,31,22,30), -(2,3,11,27,34,32,23,30), -(2,3,12,28,36,33,24,31), -(2,3,13,28,37,34,24,32), -(2,3,14,29,39,35,25,33), -(2,3,15,29,40,36,26,33), -(2,3,16,30,42,37,26,34), -(2,3,17,30,43,39,27,35), -(2,3,18,31,45,40,28,35), -(2,3,19,31,47,41,28,36), -(2,3,20,32,48,42,29,37), -(2,3,21,32,50,43,30,38), -(2,3,22,33,51,44,31,39), -(2,3,23,34,53,45,31,39), -(2,3,24,34,55,46,32,40), -(2,3,25,35,57,47,33,41), -(2,3,26,35,58,48,34,42), -(2,3,27,36,60,50,34,43), -(2,3,28,36,62,51,35,43), -(2,3,29,37,63,52,36,44), -(2,3,30,38,65,53,37,45), -(2,3,31,38,67,54,37,46), -(2,3,32,39,69,56,38,47), -(2,3,33,39,71,57,39,48), -(2,3,34,40,72,58,40,49), -(2,3,35,41,74,59,41,49), -(2,3,36,41,76,61,42,50), -(2,3,37,42,78,62,42,51), -(2,3,38,43,80,63,43,52), -(2,3,39,43,82,64,44,53), -(2,3,40,44,84,66,45,54), -(2,3,41,45,86,67,46,55), -(2,3,42,45,88,68,47,56), -(2,3,43,46,90,70,47,57), -(2,3,44,47,91,71,48,58), -(2,3,45,47,93,72,49,59), -(2,3,46,48,95,74,50,60), -(2,3,47,49,98,75,51,61), -(2,3,48,50,100,77,52,62), -(2,3,49,50,102,78,53,63), -(2,3,50,51,104,79,54,64), -(2,3,51,52,106,81,55,65), -(2,3,52,52,108,82,56,66), -(2,3,53,53,110,84,57,67), -(2,3,54,54,112,85,58,68), -(2,3,55,55,114,87,59,69), -(2,3,56,55,116,88,60,70), -(2,3,57,56,118,90,61,71), -(2,3,58,57,121,91,62,72), -(2,3,59,58,123,93,63,73), -(2,3,60,59,125,94,64,74), -(2,3,61,59,127,96,65,76), -(2,3,62,60,130,97,66,77), -(2,3,63,61,132,99,67,78), -(2,3,64,62,134,100,68,79), -(2,3,65,63,136,102,69,80), -(2,3,66,64,139,104,70,81), -(2,3,67,64,141,105,71,82), -(2,3,68,65,143,107,72,84), -(2,3,69,66,146,108,73,85), -(2,3,70,67,148,110,74,86), -(2,4,1,24,20,23,17,23), -(2,4,2,25,21,24,17,23), -(2,4,3,25,23,24,17,24), -(2,4,4,26,24,25,17,24), -(2,4,5,27,26,26,18,24), -(2,4,6,28,27,26,18,25), -(2,4,7,29,29,27,18,25), -(2,4,8,29,30,28,18,26), -(2,4,9,30,32,29,18,26), -(2,4,10,31,33,29,19,26), -(2,4,11,32,35,30,19,27), -(2,4,12,33,37,31,19,27), -(2,4,13,34,38,32,19,28), -(2,4,14,34,40,32,19,28), -(2,4,15,35,41,33,19,28), -(2,4,16,36,43,34,20,29), -(2,4,17,37,45,35,20,29), -(2,4,18,38,46,36,20,30), -(2,4,19,39,48,37,20,30), -(2,4,20,40,50,37,21,31), -(2,4,21,41,52,38,21,31), -(2,4,22,42,53,39,21,31), -(2,4,23,43,55,40,21,32), -(2,4,24,43,57,41,21,32), -(2,4,25,44,59,42,22,33), -(2,4,26,45,60,43,22,33), -(2,4,27,46,62,44,22,34), -(2,4,28,47,64,44,22,34), -(2,4,29,48,66,45,23,35), -(2,4,30,49,68,46,23,35), -(2,4,31,50,70,47,23,36), -(2,4,32,51,72,48,23,36), -(2,4,33,53,73,49,24,37), -(2,4,34,54,75,50,24,38), -(2,4,35,55,77,51,24,38), -(2,4,36,56,79,52,24,39), -(2,4,37,57,81,53,25,39), -(2,4,38,58,83,54,25,40), -(2,4,39,59,85,55,25,40), -(2,4,40,60,87,56,26,41), -(2,4,41,61,89,57,26,41), -(2,4,42,62,91,58,26,42), -(2,4,43,63,93,59,27,43), -(2,4,44,65,95,60,27,43), -(2,4,45,66,98,61,27,44), -(2,4,46,67,100,62,27,44), -(2,4,47,68,102,64,28,45), -(2,4,48,69,104,65,28,46), -(2,4,49,71,106,66,28,46), -(2,4,50,72,108,67,29,47), -(2,4,51,73,110,68,29,48), -(2,4,52,74,113,69,29,48), -(2,4,53,75,115,70,30,49), -(2,4,54,77,117,71,30,50), -(2,4,55,78,119,73,30,50), -(2,4,56,79,122,74,31,51), -(2,4,57,80,124,75,31,52), -(2,4,58,82,126,76,31,52), -(2,4,59,83,129,77,32,53), -(2,4,60,84,131,78,32,54), -(2,4,61,86,133,80,33,54), -(2,4,62,87,136,81,33,55), -(2,4,63,88,138,82,33,56), -(2,4,64,90,140,83,34,57), -(2,4,65,91,143,85,34,57), -(2,4,66,92,145,86,34,58), -(2,4,67,94,148,87,35,59), -(2,4,68,95,150,88,35,59), -(2,4,69,97,153,90,36,60), -(2,4,70,98,155,91,36,61), -(2,7,1,24,17,23,18,25), -(2,7,2,25,17,24,19,26), -(2,7,3,26,18,25,20,27), -(2,7,4,26,18,26,21,28), -(2,7,5,27,19,27,22,29), -(2,7,6,28,19,28,23,30), -(2,7,7,29,20,29,24,31), -(2,7,8,30,20,30,25,32), -(2,7,9,31,21,31,26,33), -(2,7,10,32,21,32,27,34), -(2,7,11,33,22,33,28,36), -(2,7,12,34,22,34,29,37), -(2,7,13,34,23,35,30,38), -(2,7,14,35,23,36,31,39), -(2,7,15,36,24,37,32,40), -(2,7,16,37,24,39,33,41), -(2,7,17,38,25,40,34,43), -(2,7,18,39,25,41,35,44), -(2,7,19,40,26,42,36,45), -(2,7,20,41,26,43,37,46), -(2,7,21,42,27,44,38,47), -(2,7,22,43,27,45,39,49), -(2,7,23,44,28,47,40,50), -(2,7,24,45,28,48,41,51), -(2,7,25,47,29,49,43,52), -(2,7,26,48,30,50,44,54), -(2,7,27,49,30,52,45,55), -(2,7,28,50,31,53,46,56), -(2,7,29,51,31,54,47,58), -(2,7,30,52,32,55,48,59), -(2,7,31,53,33,57,50,60), -(2,7,32,54,33,58,51,62), -(2,7,33,55,34,59,52,63), -(2,7,34,57,34,61,53,65), -(2,7,35,58,35,62,55,66), -(2,7,36,59,36,63,56,67), -(2,7,37,60,36,65,57,69), -(2,7,38,61,37,66,58,70), -(2,7,39,62,38,67,60,72), -(2,7,40,64,38,69,61,73), -(2,7,41,65,39,70,62,75), -(2,7,42,66,40,72,64,76), -(2,7,43,67,40,73,65,78), -(2,7,44,69,41,74,66,79), -(2,7,45,70,42,76,68,81), -(2,7,46,71,42,77,69,82), -(2,7,47,72,43,79,70,84), -(2,7,48,74,44,80,72,85), -(2,7,49,75,45,82,73,87), -(2,7,50,76,45,83,75,89), -(2,7,51,78,46,85,76,90), -(2,7,52,79,47,86,77,92), -(2,7,53,80,47,88,79,93), -(2,7,54,82,48,90,80,95), -(2,7,55,83,49,91,82,97), -(2,7,56,85,50,93,83,98), -(2,7,57,86,50,94,85,100), -(2,7,58,87,51,96,86,102), -(2,7,59,89,52,97,88,103), -(2,7,60,90,53,99,89,105), -(2,7,61,92,54,101,91,107), -(2,7,62,93,54,102,92,109), -(2,7,63,95,55,104,94,110), -(2,7,64,96,56,106,95,112), -(2,7,65,97,57,107,97,114), -(2,7,66,99,58,109,99,116), -(2,7,67,100,58,111,100,118), -(2,7,68,102,59,113,102,119), -(2,7,69,103,60,114,103,121), -(2,7,70,105,61,116,105,123), -(2,9,1,23,17,23,19,25), -(2,9,2,23,17,24,20,26), -(2,9,3,24,18,24,21,27), -(2,9,4,24,18,25,23,28), -(2,9,5,24,18,25,24,30), -(2,9,6,24,19,26,25,31), -(2,9,7,25,19,26,26,32), -(2,9,8,25,20,27,27,33), -(2,9,9,25,20,27,29,34), -(2,9,10,26,20,28,30,36), -(2,9,11,26,21,29,31,37), -(2,9,12,26,21,29,33,38), -(2,9,13,27,22,30,34,39), -(2,9,14,27,22,31,35,41), -(2,9,15,27,23,31,37,42), -(2,9,16,28,23,32,38,43), -(2,9,17,28,23,32,39,45), -(2,9,18,28,24,33,41,46), -(2,9,19,29,24,34,42,47), -(2,9,20,29,25,34,43,49), -(2,9,21,29,25,35,45,50), -(2,9,22,30,26,36,46,51), -(2,9,23,30,26,37,48,53), -(2,9,24,30,27,37,49,54), -(2,9,25,31,27,38,51,56), -(2,9,26,31,28,39,52,57), -(2,9,27,32,28,39,54,59), -(2,9,28,32,29,40,55,60), -(2,9,29,32,29,41,57,62), -(2,9,30,33,30,42,58,63), -(2,9,31,33,30,42,60,65), -(2,9,32,34,31,43,61,66), -(2,9,33,34,31,44,63,68), -(2,9,34,35,32,45,64,69), -(2,9,35,35,32,45,66,71), -(2,9,36,36,33,46,68,72), -(2,9,37,36,34,47,69,74), -(2,9,38,36,34,48,71,76), -(2,9,39,37,35,49,72,77), -(2,9,40,37,35,50,74,79), -(2,9,41,38,36,50,76,80), -(2,9,42,38,36,51,77,82), -(2,9,43,39,37,52,79,84), -(2,9,44,39,38,53,81,85), -(2,9,45,40,38,54,83,87), -(2,9,46,40,39,55,84,89), -(2,9,47,41,39,56,86,91), -(2,9,48,41,40,56,88,92), -(2,9,49,42,41,57,90,94), -(2,9,50,42,41,58,91,96), -(2,9,51,43,42,59,93,98), -(2,9,52,43,43,60,95,99), -(2,9,53,44,43,61,97,101), -(2,9,54,45,44,62,99,103), -(2,9,55,45,45,63,101,105), -(2,9,56,46,45,64,102,107), -(2,9,57,46,46,65,104,109), -(2,9,58,47,47,66,106,110), -(2,9,59,47,47,67,108,112), -(2,9,60,48,48,68,110,114), -(2,9,61,48,49,69,112,116), -(2,9,62,49,49,70,114,118), -(2,9,63,50,50,71,116,120), -(2,9,64,50,51,72,118,122), -(2,9,65,51,51,73,120,124), -(2,9,66,52,52,74,122,126), -(2,9,67,52,53,75,124,128), -(2,9,68,53,54,76,126,130), -(2,9,69,53,54,77,128,132), -(2,9,70,54,55,78,130,134), -(3,1,1,25,16,25,19,19), -(3,1,2,26,17,26,19,19), -(3,1,3,28,18,27,19,20), -(3,1,4,29,18,28,19,20), -(3,1,5,30,19,30,19,20), -(3,1,6,31,20,31,19,20), -(3,1,7,33,21,32,20,21), -(3,1,8,34,22,33,20,21), -(3,1,9,36,23,35,20,21), -(3,1,10,37,23,36,20,22), -(3,1,11,38,24,37,20,22), -(3,1,12,40,25,38,20,22), -(3,1,13,41,26,40,20,23), -(3,1,14,43,27,41,20,23), -(3,1,15,44,28,42,20,23), -(3,1,16,46,29,44,21,24), -(3,1,17,47,30,45,21,24), -(3,1,18,49,31,46,21,24), -(3,1,19,50,32,48,21,25), -(3,1,20,52,33,49,21,25), -(3,1,21,53,34,51,21,26), -(3,1,22,55,34,52,21,26), -(3,1,23,56,35,53,21,26), -(3,1,24,58,36,55,22,27), -(3,1,25,59,37,56,22,27), -(3,1,26,61,38,58,22,27), -(3,1,27,63,39,59,22,28), -(3,1,28,64,41,61,22,28), -(3,1,29,66,42,62,22,29), -(3,1,30,68,43,64,23,29), -(3,1,31,69,44,65,23,30), -(3,1,32,71,45,67,23,30), -(3,1,33,73,46,68,23,30), -(3,1,34,75,47,70,23,31), -(3,1,35,76,48,72,24,31), -(3,1,36,78,49,73,24,32), -(3,1,37,80,50,75,24,32), -(3,1,38,82,51,76,24,33), -(3,1,39,84,52,78,24,33), -(3,1,40,85,54,80,24,34), -(3,1,41,87,55,81,25,34), -(3,1,42,89,56,83,25,35), -(3,1,43,91,57,85,25,35), -(3,1,44,93,58,87,25,36), -(3,1,45,95,59,88,26,36), -(3,1,46,97,61,90,26,37), -(3,1,47,99,62,92,26,37), -(3,1,48,101,63,94,26,38), -(3,1,49,102,64,95,26,38), -(3,1,50,104,65,97,27,39), -(3,1,51,106,67,99,27,39), -(3,1,52,108,68,101,27,40), -(3,1,53,110,69,103,27,40), -(3,1,54,112,70,104,28,41), -(3,1,55,115,72,106,28,41), -(3,1,56,117,73,108,28,42), -(3,1,57,119,74,110,28,42), -(3,1,58,121,76,112,29,43), -(3,1,59,123,77,114,29,43), -(3,1,60,125,78,116,29,44), -(3,1,61,127,80,118,29,45), -(3,1,62,129,81,120,30,45), -(3,1,63,131,82,122,30,46), -(3,1,64,134,84,124,30,46), -(3,1,65,136,85,126,31,47), -(3,1,66,138,86,128,31,48), -(3,1,67,140,88,130,31,48), -(3,1,68,142,89,132,31,49), -(3,1,69,145,91,134,32,49), -(3,1,70,147,92,136,32,50), -(3,2,1,24,16,25,19,20), -(3,2,2,25,17,26,20,21), -(3,2,3,26,17,27,20,21), -(3,2,4,27,18,28,21,22), -(3,2,5,28,18,29,22,23), -(3,2,6,29,19,30,22,24), -(3,2,7,31,20,31,23,24), -(3,2,8,32,20,32,24,25), -(3,2,9,33,21,33,24,26), -(3,2,10,34,21,34,25,26), -(3,2,11,35,22,36,26,27), -(3,2,12,36,23,37,26,28), -(3,2,13,38,23,38,27,29), -(3,2,14,39,24,39,28,30), -(3,2,15,40,25,40,29,30), -(3,2,16,41,25,41,29,31), -(3,2,17,43,26,43,30,32), -(3,2,18,44,27,44,31,33), -(3,2,19,45,28,45,32,34), -(3,2,20,47,28,46,32,35), -(3,2,21,48,29,47,33,35), -(3,2,22,49,30,49,34,36), -(3,2,23,51,30,50,35,37), -(3,2,24,52,31,51,36,38), -(3,2,25,53,32,52,36,39), -(3,2,26,55,33,54,37,40), -(3,2,27,56,33,55,38,41), -(3,2,28,57,34,56,39,42), -(3,2,29,59,35,58,40,43), -(3,2,30,60,36,59,41,43), -(3,2,31,62,37,60,42,44), -(3,2,32,63,37,62,42,45), -(3,2,33,65,38,63,43,46), -(3,2,34,66,39,65,44,47), -(3,2,35,68,40,66,45,48), -(3,2,36,69,41,67,46,49), -(3,2,37,71,41,69,47,50), -(3,2,38,72,42,70,48,51), -(3,2,39,74,43,72,49,52), -(3,2,40,75,44,73,50,53), -(3,2,41,77,45,75,51,54), -(3,2,42,78,46,76,52,55), -(3,2,43,80,47,78,53,56), -(3,2,44,82,47,79,54,57), -(3,2,45,83,48,81,55,59), -(3,2,46,85,49,82,56,60), -(3,2,47,87,50,84,57,61), -(3,2,48,88,51,85,58,62), -(3,2,49,90,52,87,59,63), -(3,2,50,92,53,89,60,64), -(3,2,51,93,54,90,61,65), -(3,2,52,95,55,92,62,66), -(3,2,53,97,56,93,63,67), -(3,2,54,98,57,95,64,69), -(3,2,55,100,58,97,65,70), -(3,2,56,102,59,98,66,71), -(3,2,57,104,60,100,67,72), -(3,2,58,106,61,102,68,73), -(3,2,59,107,62,103,69,74), -(3,2,60,109,63,105,70,76), -(3,2,61,111,64,107,72,77), -(3,2,62,113,65,109,73,78), -(3,2,63,115,66,110,74,79), -(3,2,64,117,67,112,75,80), -(3,2,65,118,68,114,76,82), -(3,2,66,120,69,116,77,83), -(3,2,67,122,70,118,78,84), -(3,2,68,124,71,119,80,85), -(3,2,69,126,72,121,81,87), -(3,2,70,128,73,123,82,88), -(3,3,1,22,19,24,19,20), -(3,3,2,22,20,25,20,21), -(3,3,3,23,22,26,20,21), -(3,3,4,23,23,27,21,22), -(3,3,5,24,25,28,21,23), -(3,3,6,24,26,29,22,23), -(3,3,7,25,27,29,23,24), -(3,3,8,25,29,30,23,25), -(3,3,9,25,30,31,24,25), -(3,3,10,26,32,32,24,26), -(3,3,11,26,33,33,25,27), -(3,3,12,27,35,34,26,27), -(3,3,13,27,36,35,26,28), -(3,3,14,28,38,36,27,29), -(3,3,15,28,39,37,28,29), -(3,3,16,29,41,38,28,30), -(3,3,17,29,42,39,29,31), -(3,3,18,30,44,41,30,32), -(3,3,19,30,46,42,30,32), -(3,3,20,31,47,43,31,33), -(3,3,21,32,49,44,32,34), -(3,3,22,32,51,45,33,35), -(3,3,23,33,52,46,33,36), -(3,3,24,33,54,47,34,36), -(3,3,25,34,56,48,35,37), -(3,3,26,34,57,49,35,38), -(3,3,27,35,59,51,36,39), -(3,3,28,35,61,52,37,40), -(3,3,29,36,63,53,38,40), -(3,3,30,37,64,54,39,41), -(3,3,31,37,66,55,39,42), -(3,3,32,38,68,57,40,43), -(3,3,33,38,70,58,41,44), -(3,3,34,39,71,59,42,45), -(3,3,35,40,73,60,43,46), -(3,3,36,40,75,62,43,47), -(3,3,37,41,77,63,44,47), -(3,3,38,42,79,64,45,48), -(3,3,39,42,81,65,46,49), -(3,3,40,43,83,67,47,50), -(3,3,41,44,85,68,48,51), -(3,3,42,44,87,69,49,52), -(3,3,43,45,89,71,49,53), -(3,3,44,46,91,72,50,54), -(3,3,45,46,93,73,51,55), -(3,3,46,47,95,75,52,56), -(3,3,47,48,97,76,53,57), -(3,3,48,49,99,78,54,58), -(3,3,49,49,101,79,55,59), -(3,3,50,50,103,80,56,60), -(3,3,51,51,105,82,57,61), -(3,3,52,51,107,83,58,62), -(3,3,53,52,109,85,59,63), -(3,3,54,53,111,86,60,64), -(3,3,55,54,113,88,61,65), -(3,3,56,55,115,89,62,66), -(3,3,57,55,118,91,62,67), -(3,3,58,56,120,92,63,68), -(3,3,59,57,122,94,64,70), -(3,3,60,58,124,95,65,71), -(3,3,61,58,126,97,67,72), -(3,3,62,59,129,98,68,73), -(3,3,63,60,131,100,69,74), -(3,3,64,61,133,101,70,75), -(3,3,65,62,135,103,71,76), -(3,3,66,63,138,105,72,77), -(3,3,67,63,140,106,73,78), -(3,3,68,64,142,108,74,80), -(3,3,69,65,145,109,75,81), -(3,3,70,66,147,111,76,82), -(3,4,1,23,19,24,19,19), -(3,4,2,24,20,25,19,19), -(3,4,3,24,22,25,19,20), -(3,4,4,25,23,26,19,20), -(3,4,5,26,25,27,20,20), -(3,4,6,27,26,27,20,21), -(3,4,7,28,28,28,20,21), -(3,4,8,28,29,29,20,22), -(3,4,9,29,31,30,20,22), -(3,4,10,30,32,30,20,22), -(3,4,11,31,34,31,21,23), -(3,4,12,32,36,32,21,23), -(3,4,13,33,37,33,21,24), -(3,4,14,33,39,33,21,24), -(3,4,15,34,40,34,21,25), -(3,4,16,35,42,35,22,25), -(3,4,17,36,44,36,22,25), -(3,4,18,37,45,37,22,26), -(3,4,19,38,47,38,22,26), -(3,4,20,39,49,38,22,27), -(3,4,21,40,51,39,23,27), -(3,4,22,41,52,40,23,28), -(3,4,23,42,54,41,23,28), -(3,4,24,43,56,42,23,29), -(3,4,25,44,58,43,24,29), -(3,4,26,44,59,44,24,30), -(3,4,27,45,61,44,24,30), -(3,4,28,46,63,45,24,31), -(3,4,29,47,65,46,25,31), -(3,4,30,48,67,47,25,32), -(3,4,31,49,69,48,25,32), -(3,4,32,51,71,49,25,33), -(3,4,33,52,72,50,26,33), -(3,4,34,53,74,51,26,34), -(3,4,35,54,76,52,26,34), -(3,4,36,55,78,53,26,35), -(3,4,37,56,80,54,27,35), -(3,4,38,57,82,55,27,36), -(3,4,39,58,84,56,27,37), -(3,4,40,59,86,57,28,37), -(3,4,41,60,88,58,28,38), -(3,4,42,61,90,59,28,38), -(3,4,43,63,92,60,28,39), -(3,4,44,64,95,61,29,39), -(3,4,45,65,97,62,29,40), -(3,4,46,66,99,63,29,41), -(3,4,47,67,101,64,30,41), -(3,4,48,68,103,66,30,42), -(3,4,49,70,105,67,30,43), -(3,4,50,71,107,68,31,43), -(3,4,51,72,110,69,31,44), -(3,4,52,73,112,70,31,44), -(3,4,53,74,114,71,32,45), -(3,4,54,76,116,72,32,46), -(3,4,55,77,118,73,32,46), -(3,4,56,78,121,75,33,47), -(3,4,57,80,123,76,33,48), -(3,4,58,81,125,77,33,48), -(3,4,59,82,128,78,34,49), -(3,4,60,83,130,79,34,50), -(3,4,61,85,132,81,34,51), -(3,4,62,86,135,82,35,51), -(3,4,63,87,137,83,35,52), -(3,4,64,89,139,84,36,53), -(3,4,65,90,142,86,36,53), -(3,4,66,91,144,87,36,54), -(3,4,67,93,147,88,37,55), -(3,4,68,94,149,89,37,56), -(3,4,69,96,152,91,38,56), -(3,4,70,97,154,92,38,57), -(3,5,1,22,16,23,21,22), -(3,5,2,22,16,23,22,23), -(3,5,3,22,16,24,24,25), -(3,5,4,22,17,24,25,26), -(3,5,5,23,17,24,26,27), -(3,5,6,23,17,25,28,29), -(3,5,7,23,17,25,29,30), -(3,5,8,23,18,26,30,32), -(3,5,9,23,18,26,32,33), -(3,5,10,23,18,26,33,35), -(3,5,11,24,18,27,35,36), -(3,5,12,24,19,27,36,38), -(3,5,13,24,19,28,37,39), -(3,5,14,24,19,28,39,41), -(3,5,15,24,19,28,40,42), -(3,5,16,24,20,29,42,44), -(3,5,17,25,20,29,43,45), -(3,5,18,25,20,30,45,47), -(3,5,19,25,21,30,46,49), -(3,5,20,25,21,31,48,50), -(3,5,21,25,21,31,50,52), -(3,5,22,26,22,31,51,53), -(3,5,23,26,22,32,53,55), -(3,5,24,26,22,32,54,57), -(3,5,25,26,22,33,56,58), -(3,5,26,27,23,33,58,60), -(3,5,27,27,23,34,59,62), -(3,5,28,27,23,34,61,64), -(3,5,29,27,24,35,63,65), -(3,5,30,28,24,35,64,67), -(3,5,31,28,24,36,66,69), -(3,5,32,28,25,36,68,71), -(3,5,33,28,25,37,70,72), -(3,5,34,29,26,38,71,74), -(3,5,35,29,26,38,73,76), -(3,5,36,29,26,39,75,78), -(3,5,37,29,27,39,77,80), -(3,5,38,30,27,40,78,82), -(3,5,39,30,27,40,80,84), -(3,5,40,30,28,41,82,86), -(3,5,41,31,28,41,84,88), -(3,5,42,31,29,42,86,89), -(3,5,43,31,29,43,88,91), -(3,5,44,32,29,43,90,93), -(3,5,45,32,30,44,92,95), -(3,5,46,32,30,44,93,97), -(3,5,47,32,30,45,95,99), -(3,5,48,33,31,46,97,101), -(3,5,49,33,31,46,99,103), -(3,5,50,33,32,47,101,106), -(3,5,51,34,32,48,103,108), -(3,5,52,34,33,48,105,110), -(3,5,53,35,33,49,107,112), -(3,5,54,35,33,50,109,114), -(3,5,55,35,34,50,111,116), -(3,5,56,36,34,51,113,118), -(3,5,57,36,35,52,116,120), -(3,5,58,36,35,52,118,123), -(3,5,59,37,36,53,120,125), -(3,5,60,37,36,54,122,127), -(3,5,61,37,37,54,124,129), -(3,5,62,38,37,55,126,131), -(3,5,63,38,38,56,128,134), -(3,5,64,39,38,57,131,136), -(3,5,65,39,39,57,133,138), -(3,5,66,39,39,58,135,141), -(3,5,67,40,40,59,137,143), -(3,5,68,40,40,59,139,145), -(3,5,69,41,40,60,142,148), -(3,5,70,41,41,61,144,150), -(4,1,1,20,25,21,20,20), -(4,1,2,21,26,22,20,20), -(4,1,3,23,27,23,20,21), -(4,1,4,24,27,25,20,21), -(4,1,5,25,28,26,20,21), -(4,1,6,27,29,27,20,21), -(4,1,7,28,30,28,21,22), -(4,1,8,29,31,29,21,22), -(4,1,9,31,31,31,21,22), -(4,1,10,32,32,32,21,23), -(4,1,11,33,33,33,21,23), -(4,1,12,35,34,34,21,23), -(4,1,13,36,35,36,21,24), -(4,1,14,38,36,37,21,24), -(4,1,15,39,37,38,21,24), -(4,1,16,41,37,40,21,25), -(4,1,17,42,38,41,22,25), -(4,1,18,44,39,43,22,25), -(4,1,19,45,40,44,22,26), -(4,1,20,47,41,45,22,26), -(4,1,21,48,42,47,22,26), -(4,1,22,50,43,48,22,27), -(4,1,23,52,44,50,22,27), -(4,1,24,53,45,51,23,28), -(4,1,25,55,46,52,23,28), -(4,1,26,56,47,54,23,28), -(4,1,27,58,48,55,23,29), -(4,1,28,60,49,57,23,29), -(4,1,29,61,50,58,23,30), -(4,1,30,63,51,60,24,30), -(4,1,31,65,52,62,24,30), -(4,1,32,66,53,63,24,31), -(4,1,33,68,54,65,24,31), -(4,1,34,70,55,66,24,32), -(4,1,35,72,56,68,24,32), -(4,1,36,73,58,69,25,33), -(4,1,37,75,59,71,25,33), -(4,1,38,77,60,73,25,34), -(4,1,39,79,61,74,25,34), -(4,1,40,81,62,76,25,35), -(4,1,41,82,63,78,26,35), -(4,1,42,84,64,79,26,35), -(4,1,43,86,66,81,26,36), -(4,1,44,88,67,83,26,36), -(4,1,45,90,68,85,26,37), -(4,1,46,92,69,86,27,37), -(4,1,47,94,70,88,27,38), -(4,1,48,96,72,90,27,38), -(4,1,49,98,73,92,27,39), -(4,1,50,100,74,93,28,40), -(4,1,51,102,75,95,28,40), -(4,1,52,104,77,97,28,41), -(4,1,53,106,78,99,28,41), -(4,1,54,108,79,101,29,42), -(4,1,55,110,80,103,29,42), -(4,1,56,112,82,104,29,43), -(4,1,57,114,83,106,29,43), -(4,1,58,116,84,108,30,44), -(4,1,59,118,86,110,30,44), -(4,1,60,120,87,112,30,45), -(4,1,61,122,88,114,30,46), -(4,1,62,124,90,116,31,46), -(4,1,63,127,91,118,31,47), -(4,1,64,129,92,120,31,47), -(4,1,65,131,94,122,32,48), -(4,1,66,133,95,124,32,49), -(4,1,67,135,97,126,32,49), -(4,1,68,138,98,128,32,50), -(4,1,69,140,100,130,33,50), -(4,1,70,142,101,132,33,51), -(4,3,1,17,28,20,20,21), -(4,3,2,17,29,21,21,22), -(4,3,3,18,31,22,21,22), -(4,3,4,18,32,23,22,23), -(4,3,5,19,33,24,22,24), -(4,3,6,19,35,25,23,24), -(4,3,7,20,36,26,24,25), -(4,3,8,20,38,27,24,25), -(4,3,9,21,39,27,25,26), -(4,3,10,21,40,28,25,27), -(4,3,11,22,42,29,26,28), -(4,3,12,22,43,30,27,28), -(4,3,13,23,45,31,27,29), -(4,3,14,23,46,32,28,30), -(4,3,15,24,48,34,29,30), -(4,3,16,24,50,35,29,31), -(4,3,17,25,51,36,30,32), -(4,3,18,25,53,37,31,33), -(4,3,19,26,54,38,31,33), -(4,3,20,26,56,39,32,34), -(4,3,21,27,57,40,33,35), -(4,3,22,27,59,41,33,36), -(4,3,23,28,61,42,34,36), -(4,3,24,28,62,43,35,37), -(4,3,25,29,64,44,36,38), -(4,3,26,30,66,46,36,39), -(4,3,27,30,68,47,37,40), -(4,3,28,31,69,48,38,41), -(4,3,29,31,71,49,39,41), -(4,3,30,32,73,50,39,42), -(4,3,31,33,75,52,40,43), -(4,3,32,33,76,53,41,44), -(4,3,33,34,78,54,42,45), -(4,3,34,34,80,55,43,46), -(4,3,35,35,82,57,44,47), -(4,3,36,36,84,58,44,48), -(4,3,37,36,86,59,45,48), -(4,3,38,37,87,60,46,49), -(4,3,39,38,89,62,47,50), -(4,3,40,38,91,63,48,51), -(4,3,41,39,93,64,49,52), -(4,3,42,40,95,66,49,53), -(4,3,43,40,97,67,50,54), -(4,3,44,41,99,68,51,55), -(4,3,45,42,101,70,52,56), -(4,3,46,42,103,71,53,57), -(4,3,47,43,105,72,54,58), -(4,3,48,44,107,74,55,59), -(4,3,49,45,109,75,56,60), -(4,3,50,45,111,77,57,61), -(4,3,51,46,113,78,58,62), -(4,3,52,47,115,79,59,63), -(4,3,53,47,118,81,60,64), -(4,3,54,48,120,82,61,65), -(4,3,55,49,122,84,61,66), -(4,3,56,50,124,85,62,67), -(4,3,57,50,126,87,63,68), -(4,3,58,51,128,88,64,69), -(4,3,59,52,131,90,65,70), -(4,3,60,53,133,91,66,72), -(4,3,61,54,135,93,67,73), -(4,3,62,54,137,94,69,74), -(4,3,63,55,140,96,70,75), -(4,3,64,56,142,97,71,76), -(4,3,65,57,144,99,72,77), -(4,3,66,58,147,101,73,78), -(4,3,67,58,149,102,74,79), -(4,3,68,59,151,104,75,81), -(4,3,69,60,154,105,76,82), -(4,3,70,61,156,107,77,83), -(4,4,1,18,28,20,20,20), -(4,4,2,19,29,21,20,20), -(4,4,3,20,31,21,20,21), -(4,4,4,20,32,22,20,21), -(4,4,5,21,34,23,21,21), -(4,4,6,22,35,24,21,22), -(4,4,7,23,37,24,21,22), -(4,4,8,24,38,25,21,23), -(4,4,9,24,40,26,21,23), -(4,4,10,25,41,26,21,23), -(4,4,11,26,43,27,22,24), -(4,4,12,27,44,28,22,24), -(4,4,13,28,46,29,22,25), -(4,4,14,29,48,30,22,25), -(4,4,15,29,49,30,22,25), -(4,4,16,30,51,31,23,26), -(4,4,17,31,52,32,23,26), -(4,4,18,32,54,33,23,27), -(4,4,19,33,56,34,23,27), -(4,4,20,34,57,35,23,28), -(4,4,21,35,59,35,24,28), -(4,4,22,36,61,36,24,29), -(4,4,23,37,63,37,24,29), -(4,4,24,38,64,38,24,30), -(4,4,25,39,66,39,25,30), -(4,4,26,40,68,40,25,31), -(4,4,27,41,70,41,25,31), -(4,4,28,42,72,42,25,32), -(4,4,29,43,73,43,25,32), -(4,4,30,44,75,43,26,33), -(4,4,31,45,77,44,26,33), -(4,4,32,46,79,45,26,34), -(4,4,33,47,81,46,27,34), -(4,4,34,48,83,47,27,35), -(4,4,35,49,85,48,27,35), -(4,4,36,50,87,49,27,36), -(4,4,37,51,89,50,28,36), -(4,4,38,52,91,51,28,37), -(4,4,39,53,93,52,28,38), -(4,4,40,54,95,53,28,38), -(4,4,41,56,97,54,29,39), -(4,4,42,57,99,55,29,39), -(4,4,43,58,101,56,29,40), -(4,4,44,59,103,57,30,40), -(4,4,45,60,105,59,30,41), -(4,4,46,61,107,60,30,42), -(4,4,47,62,109,61,31,42), -(4,4,48,64,112,62,31,43), -(4,4,49,65,114,63,31,44), -(4,4,50,66,116,64,32,44), -(4,4,51,67,118,65,32,45), -(4,4,52,68,120,66,32,45), -(4,4,53,70,123,67,33,46), -(4,4,54,71,125,69,33,47), -(4,4,55,72,127,70,33,47), -(4,4,56,73,129,71,34,48), -(4,4,57,75,132,72,34,49), -(4,4,58,76,134,73,34,49), -(4,4,59,77,136,74,35,50), -(4,4,60,79,139,76,35,51), -(4,4,61,80,141,77,35,51), -(4,4,62,81,143,78,36,52), -(4,4,63,82,146,79,36,53), -(4,4,64,84,148,80,37,54), -(4,4,65,85,151,82,37,54), -(4,4,66,87,153,83,37,55), -(4,4,67,88,156,84,38,56), -(4,4,68,89,158,85,38,57), -(4,4,69,91,160,87,39,57), -(4,4,70,92,163,88,39,58), -(4,5,1,17,25,19,22,23), -(4,5,2,17,25,19,23,24), -(4,5,3,17,25,20,25,26), -(4,5,4,17,26,20,26,27), -(4,5,5,18,26,20,27,28), -(4,5,6,18,26,21,29,30), -(4,5,7,18,26,21,30,31), -(4,5,8,18,26,22,31,33), -(4,5,9,18,27,22,33,34), -(4,5,10,19,27,22,34,36), -(4,5,11,19,27,23,36,37), -(4,5,12,19,27,23,37,39), -(4,5,13,19,28,24,38,40), -(4,5,14,19,28,24,40,42), -(4,5,15,19,28,25,41,43), -(4,5,16,20,28,25,43,45), -(4,5,17,20,29,25,44,46), -(4,5,18,20,29,26,46,48), -(4,5,19,20,29,26,47,49), -(4,5,20,21,30,27,49,51), -(4,5,21,21,30,27,51,53), -(4,5,22,21,30,28,52,54), -(4,5,23,21,30,28,54,56), -(4,5,24,21,31,29,55,58), -(4,5,25,22,31,29,57,59), -(4,5,26,22,31,30,59,61), -(4,5,27,22,32,30,60,63), -(4,5,28,22,32,31,62,65), -(4,5,29,23,32,31,64,66), -(4,5,30,23,33,32,65,68), -(4,5,31,23,33,32,67,70), -(4,5,32,23,33,33,69,72), -(4,5,33,24,34,33,70,73), -(4,5,34,24,34,34,72,75), -(4,5,35,24,34,34,74,77), -(4,5,36,24,35,35,76,79), -(4,5,37,25,35,35,78,81), -(4,5,38,25,35,36,79,83), -(4,5,39,25,36,37,81,85), -(4,5,40,26,36,37,83,87), -(4,5,41,26,37,38,85,88), -(4,5,42,26,37,38,87,90), -(4,5,43,27,37,39,89,92), -(4,5,44,27,38,39,91,94), -(4,5,45,27,38,40,92,96), -(4,5,46,27,39,41,94,98), -(4,5,47,28,39,41,96,100), -(4,5,48,28,39,42,98,102), -(4,5,49,28,40,43,100,104), -(4,5,50,29,40,43,102,106), -(4,5,51,29,41,44,104,109), -(4,5,52,29,41,44,106,111), -(4,5,53,30,42,45,108,113), -(4,5,54,30,42,46,110,115), -(4,5,55,30,43,46,112,117), -(4,5,56,31,43,47,114,119), -(4,5,57,31,43,48,117,121), -(4,5,58,31,44,48,119,124), -(4,5,59,32,44,49,121,126), -(4,5,60,32,45,50,123,128), -(4,5,61,33,45,51,125,130), -(4,5,62,33,46,51,127,132), -(4,5,63,33,46,52,129,135), -(4,5,64,34,47,53,132,137), -(4,5,65,34,47,53,134,139), -(4,5,66,34,48,54,136,142), -(4,5,67,35,48,55,138,144), -(4,5,68,35,49,56,140,146), -(4,5,69,36,49,56,143,149), -(4,5,70,36,50,57,145,151), -(4,11,1,18,25,19,22,22), -(4,11,2,19,25,20,23,23), -(4,11,3,19,26,20,24,24), -(4,11,4,20,26,21,25,26), -(4,11,5,20,27,22,26,27), -(4,11,6,21,27,22,27,28), -(4,11,7,21,28,23,28,29), -(4,11,8,22,28,24,29,30), -(4,11,9,23,29,24,30,32), -(4,11,10,23,29,25,32,33), -(4,11,11,24,30,26,33,34), -(4,11,12,24,31,26,34,35), -(4,11,13,25,31,27,35,37), -(4,11,14,26,32,28,36,38), -(4,11,15,26,32,29,37,39), -(4,11,16,27,33,29,38,41), -(4,11,17,28,33,30,40,42), -(4,11,18,28,34,31,41,43), -(4,11,19,29,35,32,42,45), -(4,11,20,30,35,32,43,46), -(4,11,21,30,36,33,45,48), -(4,11,22,31,36,34,46,49), -(4,11,23,32,37,35,47,51), -(4,11,24,32,38,36,48,52), -(4,11,25,33,38,36,50,53), -(4,11,26,34,39,37,51,55), -(4,11,27,35,40,38,52,56), -(4,11,28,35,40,39,54,58), -(4,11,29,36,41,40,55,59), -(4,11,30,37,42,41,56,61), -(4,11,31,38,42,42,58,62), -(4,11,32,38,43,42,59,64), -(4,11,33,39,44,43,60,66), -(4,11,34,40,44,44,62,67), -(4,11,35,41,45,45,63,69), -(4,11,36,42,46,46,65,70), -(4,11,37,42,47,47,66,72), -(4,11,38,43,47,48,67,74), -(4,11,39,44,48,49,69,75), -(4,11,40,45,49,50,70,77), -(4,11,41,46,50,51,72,79), -(4,11,42,46,50,52,73,80), -(4,11,43,47,51,53,75,82), -(4,11,44,48,52,54,76,84), -(4,11,45,49,53,55,78,85), -(4,11,46,50,54,56,79,87), -(4,11,47,51,54,57,81,89), -(4,11,48,52,55,58,83,91), -(4,11,49,53,56,59,84,93), -(4,11,50,53,57,60,86,94), -(4,11,51,54,58,61,87,96), -(4,11,52,55,59,62,89,98), -(4,11,53,56,59,63,91,100), -(4,11,54,57,60,64,92,102), -(4,11,55,58,61,65,94,103), -(4,11,56,59,62,66,95,105), -(4,11,57,60,63,67,97,107), -(4,11,58,61,64,68,99,109), -(4,11,59,62,65,69,101,111), -(4,11,60,63,66,70,102,113), -(4,11,61,64,66,72,104,115), -(4,11,62,65,67,73,106,117), -(4,11,63,66,68,74,107,119), -(4,11,64,67,69,75,109,121), -(4,11,65,68,70,76,111,123), -(4,11,66,69,71,77,113,125), -(4,11,67,70,72,78,115,127), -(4,11,68,71,73,80,116,129), -(4,11,69,72,74,81,118,131), -(4,11,70,73,75,82,120,133), -(5,1,1,22,18,23,18,25), -(5,1,2,23,19,24,18,25), -(5,1,3,25,20,25,18,26), -(5,1,4,26,20,26,18,26), -(5,1,5,27,21,28,18,26), -(5,1,6,29,22,29,18,26), -(5,1,7,30,23,30,19,27), -(5,1,8,31,24,31,19,27), -(5,1,9,33,25,33,19,27), -(5,1,10,34,25,34,19,28), -(5,1,11,35,26,35,19,28), -(5,1,12,37,27,36,19,28), -(5,1,13,38,28,38,19,28), -(5,1,14,40,29,39,19,29), -(5,1,15,41,30,40,19,29), -(5,1,16,43,31,42,20,29), -(5,1,17,44,32,43,20,30), -(5,1,18,46,33,44,20,30), -(5,1,19,47,34,46,20,31), -(5,1,20,49,34,47,20,31), -(5,1,21,50,35,49,20,31), -(5,1,22,52,36,50,20,32), -(5,1,23,53,37,51,21,32), -(5,1,24,55,38,53,21,32), -(5,1,25,57,39,54,21,33), -(5,1,26,58,40,56,21,33), -(5,1,27,60,41,57,21,34), -(5,1,28,62,42,59,21,34), -(5,1,29,63,43,60,21,34), -(5,1,30,65,44,62,22,35), -(5,1,31,67,46,63,22,35), -(5,1,32,68,47,65,22,36), -(5,1,33,70,48,67,22,36), -(5,1,34,72,49,68,22,36), -(5,1,35,74,50,70,23,37), -(5,1,36,75,51,71,23,37), -(5,1,37,77,52,73,23,38), -(5,1,38,79,53,75,23,38), -(5,1,39,81,54,76,23,39), -(5,1,40,83,55,78,24,39), -(5,1,41,84,57,80,24,40), -(5,1,42,86,58,81,24,40), -(5,1,43,88,59,83,24,41), -(5,1,44,90,60,85,24,41), -(5,1,45,92,61,86,25,42), -(5,1,46,94,62,88,25,42), -(5,1,47,96,64,90,25,43), -(5,1,48,98,65,92,25,43), -(5,1,49,100,66,93,25,44), -(5,1,50,102,67,95,26,44), -(5,1,51,104,69,97,26,45), -(5,1,52,106,70,99,26,45), -(5,1,53,108,71,101,26,46), -(5,1,54,110,72,103,27,46), -(5,1,55,112,74,104,27,47), -(5,1,56,114,75,106,27,48), -(5,1,57,116,76,108,27,48), -(5,1,58,118,78,110,28,49), -(5,1,59,120,79,112,28,49), -(5,1,60,122,80,114,28,50), -(5,1,61,124,82,116,28,50), -(5,1,62,126,83,118,29,51), -(5,1,63,128,84,120,29,52), -(5,1,64,131,86,122,29,52), -(5,1,65,133,87,124,30,53), -(5,1,66,135,88,126,30,53), -(5,1,67,137,90,128,30,54), -(5,1,68,139,91,130,30,55), -(5,1,69,142,93,132,31,55), -(5,1,70,144,94,134,31,56), -(5,4,1,20,21,22,18,25), -(5,4,2,21,22,23,18,25), -(5,4,3,22,24,23,18,26), -(5,4,4,22,25,24,18,26), -(5,4,5,23,27,25,19,26), -(5,4,6,24,28,25,19,27), -(5,4,7,25,30,26,19,27), -(5,4,8,25,31,27,19,27), -(5,4,9,26,33,28,19,28), -(5,4,10,27,34,28,19,28), -(5,4,11,28,36,29,20,29), -(5,4,12,29,38,30,20,29), -(5,4,13,30,39,31,20,29), -(5,4,14,31,41,32,20,30), -(5,4,15,31,42,32,20,30), -(5,4,16,32,44,33,21,31), -(5,4,17,33,46,34,21,31), -(5,4,18,34,47,35,21,32), -(5,4,19,35,49,36,21,32), -(5,4,20,36,51,36,21,32), -(5,4,21,37,52,37,22,33), -(5,4,22,38,54,38,22,33), -(5,4,23,39,56,39,22,34), -(5,4,24,40,58,40,22,34), -(5,4,25,41,60,41,23,35), -(5,4,26,42,61,42,23,35), -(5,4,27,43,63,43,23,36), -(5,4,28,44,65,44,23,36), -(5,4,29,45,67,44,24,37), -(5,4,30,46,69,45,24,37), -(5,4,31,47,71,46,24,38), -(5,4,32,48,72,47,24,38), -(5,4,33,49,74,48,25,39), -(5,4,34,50,76,49,25,39), -(5,4,35,51,78,50,25,40), -(5,4,36,52,80,51,25,41), -(5,4,37,53,82,52,26,41), -(5,4,38,54,84,53,26,42), -(5,4,39,55,86,54,26,42), -(5,4,40,56,88,55,27,43), -(5,4,41,57,90,56,27,43), -(5,4,42,59,92,57,27,44), -(5,4,43,60,94,58,27,45), -(5,4,44,61,96,59,28,45), -(5,4,45,62,99,60,28,46), -(5,4,46,63,101,61,28,46), -(5,4,47,64,103,63,29,47), -(5,4,48,66,105,64,29,48), -(5,4,49,67,107,65,29,48), -(5,4,50,68,109,66,30,49), -(5,4,51,69,111,67,30,50), -(5,4,52,70,114,68,30,50), -(5,4,53,72,116,69,31,51), -(5,4,54,73,118,70,31,52), -(5,4,55,74,120,72,31,52), -(5,4,56,75,123,73,32,53), -(5,4,57,77,125,74,32,54), -(5,4,58,78,127,75,32,54), -(5,4,59,79,130,76,33,55), -(5,4,60,81,132,77,33,56), -(5,4,61,82,134,79,34,56), -(5,4,62,83,137,80,34,57), -(5,4,63,84,139,81,34,58), -(5,4,64,86,141,82,35,59), -(5,4,65,87,144,84,35,59), -(5,4,66,88,146,85,35,60), -(5,4,67,90,149,86,36,61), -(5,4,68,91,151,87,36,61), -(5,4,69,93,154,89,37,62), -(5,4,70,94,156,90,37,63), -(5,5,1,19,18,21,20,28), -(5,5,2,19,18,21,21,29), -(5,5,3,19,18,22,23,31), -(5,5,4,19,19,22,24,32), -(5,5,5,20,19,22,25,33), -(5,5,6,20,19,23,27,35), -(5,5,7,20,19,23,28,36), -(5,5,8,20,20,24,29,38), -(5,5,9,20,20,24,31,39), -(5,5,10,20,20,24,32,40), -(5,5,11,21,20,25,34,42), -(5,5,12,21,21,25,35,43), -(5,5,13,21,21,26,37,45), -(5,5,14,21,21,26,38,46), -(5,5,15,21,21,26,39,48), -(5,5,16,22,22,27,41,50), -(5,5,17,22,22,27,42,51), -(5,5,18,22,22,28,44,53), -(5,5,19,22,23,28,46,54), -(5,5,20,22,23,29,47,56), -(5,5,21,23,23,29,49,57), -(5,5,22,23,23,30,50,59), -(5,5,23,23,24,30,52,61), -(5,5,24,23,24,31,53,62), -(5,5,25,24,24,31,55,64), -(5,5,26,24,25,32,57,66), -(5,5,27,24,25,32,58,68), -(5,5,28,24,25,33,60,69), -(5,5,29,25,26,33,62,71), -(5,5,30,25,26,34,63,73), -(5,5,31,25,26,34,65,75), -(5,5,32,25,27,35,67,76), -(5,5,33,26,27,35,69,78), -(5,5,34,26,27,36,70,80), -(5,5,35,26,28,36,72,82), -(5,5,36,26,28,37,74,84), -(5,5,37,27,28,37,76,86), -(5,5,38,27,29,38,77,87), -(5,5,39,27,29,38,79,89), -(5,5,40,28,30,39,81,91), -(5,5,41,28,30,40,83,93), -(5,5,42,28,30,40,85,95), -(5,5,43,28,31,41,87,97), -(5,5,44,29,31,41,89,99), -(5,5,45,29,32,42,91,101), -(5,5,46,29,32,43,92,103), -(5,5,47,30,32,43,94,105), -(5,5,48,30,33,44,96,107), -(5,5,49,30,33,44,98,109), -(5,5,50,31,34,45,100,111), -(5,5,51,31,34,46,102,113), -(5,5,52,31,35,46,104,115), -(5,5,53,32,35,47,106,118), -(5,5,54,32,35,48,108,120), -(5,5,55,32,36,48,110,122), -(5,5,56,33,36,49,113,124), -(5,5,57,33,37,50,115,126), -(5,5,58,33,37,50,117,128), -(5,5,59,34,38,51,119,131), -(5,5,60,34,38,52,121,133), -(5,5,61,34,39,52,123,135), -(5,5,62,35,39,53,125,137), -(5,5,63,35,40,54,127,140), -(5,5,64,36,40,55,130,142), -(5,5,65,36,41,55,132,144), -(5,5,66,36,41,56,134,147), -(5,5,67,37,41,57,136,149), -(5,5,68,37,42,58,138,151), -(5,5,69,38,42,58,141,154), -(5,5,70,38,43,59,143,156), -(5,8,1,19,18,21,21,27), -(5,8,2,19,18,21,22,28), -(5,8,3,19,18,22,24,30), -(5,8,4,19,18,22,25,31), -(5,8,5,19,19,22,26,32), -(5,8,6,19,19,22,28,34), -(5,8,7,20,19,23,29,35), -(5,8,8,20,19,23,31,36), -(5,8,9,20,19,23,32,38), -(5,8,10,20,19,24,34,39), -(5,8,11,20,20,24,35,40), -(5,8,12,20,20,24,37,42), -(5,8,13,20,20,25,38,43), -(5,8,14,20,20,25,40,45), -(5,8,15,20,20,25,41,46), -(5,8,16,21,21,26,43,48), -(5,8,17,21,21,26,44,49), -(5,8,18,21,21,26,46,51), -(5,8,19,21,21,27,48,52), -(5,8,20,21,21,27,49,54), -(5,8,21,21,22,27,51,55), -(5,8,22,21,22,28,52,57), -(5,8,23,21,22,28,54,58), -(5,8,24,22,22,29,56,60), -(5,8,25,22,23,29,57,62), -(5,8,26,22,23,29,59,63), -(5,8,27,22,23,30,61,65), -(5,8,28,22,23,30,63,67), -(5,8,29,22,24,31,64,68), -(5,8,30,23,24,31,66,70), -(5,8,31,23,24,31,68,72), -(5,8,32,23,24,32,70,73), -(5,8,33,23,25,32,72,75), -(5,8,34,23,25,33,73,77), -(5,8,35,24,25,33,75,79), -(5,8,36,24,25,34,77,80), -(5,8,37,24,26,34,79,82), -(5,8,38,24,26,35,81,84), -(5,8,39,24,26,35,83,86), -(5,8,40,24,27,35,85,88), -(5,8,41,25,27,36,87,90), -(5,8,42,25,27,36,89,91), -(5,8,43,25,27,37,90,93), -(5,8,44,25,28,37,92,95), -(5,8,45,26,28,38,94,97), -(5,8,46,26,28,38,96,99), -(5,8,47,26,29,39,98,101), -(5,8,48,26,29,39,100,103), -(5,8,49,26,29,40,103,105), -(5,8,50,27,30,40,105,107), -(5,8,51,27,30,41,107,109), -(5,8,52,27,30,42,109,111), -(5,8,53,27,31,42,111,113), -(5,8,54,28,31,43,113,115), -(5,8,55,28,31,43,115,117), -(5,8,56,28,32,44,117,119), -(5,8,57,28,32,44,119,121), -(5,8,58,29,32,45,122,123), -(5,8,59,29,33,45,124,126), -(5,8,60,29,33,46,126,128), -(5,8,61,29,34,47,128,130), -(5,8,62,30,34,47,131,132), -(5,8,63,30,34,48,133,134), -(5,8,64,30,35,48,135,136), -(5,8,65,31,35,49,137,139), -(5,8,66,31,35,50,140,141), -(5,8,67,31,36,50,142,143), -(5,8,68,31,36,51,144,145), -(5,8,69,32,37,51,147,148), -(5,8,70,32,37,52,149,150), -(5,9,1,19,18,22,20,27), -(5,9,2,19,18,23,21,28), -(5,9,3,20,19,23,22,29), -(5,9,4,20,19,24,24,30), -(5,9,5,20,19,24,25,32), -(5,9,6,20,20,25,26,33), -(5,9,7,21,20,25,27,34), -(5,9,8,21,21,26,28,35), -(5,9,9,21,21,26,30,36), -(5,9,10,22,21,27,31,38), -(5,9,11,22,22,28,32,39), -(5,9,12,22,22,28,34,40), -(5,9,13,23,23,29,35,41), -(5,9,14,23,23,30,36,43), -(5,9,15,23,24,30,37,44), -(5,9,16,24,24,31,39,45), -(5,9,17,24,24,31,40,47), -(5,9,18,24,25,32,42,48), -(5,9,19,25,25,33,43,49), -(5,9,20,25,26,33,44,51), -(5,9,21,26,26,34,46,52), -(5,9,22,26,27,35,47,53), -(5,9,23,26,27,36,49,55), -(5,9,24,27,28,36,50,56), -(5,9,25,27,28,37,52,58), -(5,9,26,27,29,38,53,59), -(5,9,27,28,29,38,55,60), -(5,9,28,28,30,39,56,62), -(5,9,29,29,30,40,58,63), -(5,9,30,29,31,41,59,65), -(5,9,31,30,31,41,61,66), -(5,9,32,30,32,42,62,68), -(5,9,33,30,32,43,64,69), -(5,9,34,31,33,44,65,71), -(5,9,35,31,33,45,67,73), -(5,9,36,32,34,45,69,74), -(5,9,37,32,34,46,70,76), -(5,9,38,33,35,47,72,77), -(5,9,39,33,36,48,73,79), -(5,9,40,34,36,49,75,81), -(5,9,41,34,37,49,77,82), -(5,9,42,35,37,50,78,84), -(5,9,43,35,38,51,80,86), -(5,9,44,36,39,52,82,87), -(5,9,45,36,39,53,84,89), -(5,9,46,37,40,54,85,91), -(5,9,47,37,40,55,87,92), -(5,9,48,38,41,55,89,94), -(5,9,49,38,42,56,91,96), -(5,9,50,39,42,57,92,98), -(5,9,51,39,43,58,94,100), -(5,9,52,40,44,59,96,101), -(5,9,53,40,44,60,98,103), -(5,9,54,41,45,61,100,105), -(5,9,55,41,45,62,102,107), -(5,9,56,42,46,63,103,109), -(5,9,57,42,47,64,105,111), -(5,9,58,43,47,65,107,112), -(5,9,59,43,48,66,109,114), -(5,9,60,44,49,67,111,116), -(5,9,61,45,50,68,113,118), -(5,9,62,45,50,69,115,120), -(5,9,63,46,51,70,117,122), -(5,9,64,46,52,71,119,124), -(5,9,65,47,52,72,121,126), -(5,9,66,48,53,73,123,128), -(5,9,67,48,54,74,125,130), -(5,9,68,49,55,75,127,132), -(5,9,69,49,55,76,129,134), -(5,9,70,50,56,77,131,136), -(6,1,1,28,15,24,15,22), -(6,1,2,29,16,25,15,22), -(6,1,3,31,17,26,15,23), -(6,1,4,32,17,27,15,23), -(6,1,5,33,18,29,15,23), -(6,1,6,34,19,30,15,23), -(6,1,7,36,20,31,16,24), -(6,1,8,37,21,32,16,24), -(6,1,9,38,22,34,16,24), -(6,1,10,40,22,35,16,25), -(6,1,11,41,23,36,16,25), -(6,1,12,43,24,37,16,25), -(6,1,13,44,25,39,16,26), -(6,1,14,46,26,40,16,26), -(6,1,15,47,27,41,17,26), -(6,1,16,48,28,43,17,27), -(6,1,17,50,29,44,17,27), -(6,1,18,51,30,45,17,27), -(6,1,19,53,31,47,17,28), -(6,1,20,54,32,48,17,28), -(6,1,21,56,33,50,17,28), -(6,1,22,58,34,51,18,29), -(6,1,23,59,35,52,18,29), -(6,1,24,61,36,54,18,30), -(6,1,25,62,37,55,18,30), -(6,1,26,64,38,57,18,30), -(6,1,27,66,39,58,18,31), -(6,1,28,67,40,60,18,31), -(6,1,29,69,41,61,19,32), -(6,1,30,71,42,63,19,32), -(6,1,31,72,43,64,19,32), -(6,1,32,74,44,66,19,33), -(6,1,33,76,45,67,19,33), -(6,1,34,77,46,69,20,34), -(6,1,35,79,47,71,20,34), -(6,1,36,81,48,72,20,35), -(6,1,37,83,49,74,20,35), -(6,1,38,85,50,76,20,35), -(6,1,39,86,51,77,21,36), -(6,1,40,88,53,79,21,36), -(6,1,41,90,54,81,21,37), -(6,1,42,92,55,82,21,37), -(6,1,43,94,56,84,21,38), -(6,1,44,96,57,86,22,38), -(6,1,45,98,58,87,22,39), -(6,1,46,99,60,89,22,39), -(6,1,47,101,61,91,22,40), -(6,1,48,103,62,93,22,40), -(6,1,49,105,63,94,23,41), -(6,1,50,107,65,96,23,41), -(6,1,51,109,66,98,23,42), -(6,1,52,111,67,100,23,42), -(6,1,53,113,68,102,24,43), -(6,1,54,115,70,104,24,44), -(6,1,55,117,71,105,24,44), -(6,1,56,119,72,107,24,45), -(6,1,57,122,73,109,25,45), -(6,1,58,124,75,111,25,46), -(6,1,59,126,76,113,25,46), -(6,1,60,128,77,115,25,47), -(6,1,61,130,79,117,26,48), -(6,1,62,132,80,119,26,48), -(6,1,63,134,81,121,26,49), -(6,1,64,137,83,123,26,49), -(6,1,65,139,84,125,27,50), -(6,1,66,141,85,127,27,51), -(6,1,67,143,87,129,27,51), -(6,1,68,145,88,131,27,52), -(6,1,69,148,90,133,28,52), -(6,1,70,150,91,135,28,53), -(6,3,1,25,18,23,15,23), -(6,3,2,25,19,24,16,24), -(6,3,3,26,21,25,16,24), -(6,3,4,26,22,26,17,25), -(6,3,5,27,24,27,17,25), -(6,3,6,27,25,28,18,26), -(6,3,7,28,26,28,19,27), -(6,3,8,28,28,29,19,27), -(6,3,9,28,29,30,20,28), -(6,3,10,29,31,31,20,29), -(6,3,11,29,32,32,21,29), -(6,3,12,30,34,33,22,30), -(6,3,13,30,35,34,22,31), -(6,3,14,31,37,35,23,32), -(6,3,15,31,38,36,24,32), -(6,3,16,32,40,37,24,33), -(6,3,17,32,41,39,25,34), -(6,3,18,33,43,40,26,35), -(6,3,19,33,45,41,27,35), -(6,3,20,34,46,42,27,36), -(6,3,21,34,48,43,28,37), -(6,3,22,35,50,44,29,38), -(6,3,23,35,51,45,29,38), -(6,3,24,36,53,46,30,39), -(6,3,25,37,55,47,31,40), -(6,3,26,37,56,48,32,41), -(6,3,27,38,58,50,32,42), -(6,3,28,38,60,51,33,42), -(6,3,29,39,62,52,34,43), -(6,3,30,39,63,53,35,44), -(6,3,31,40,65,54,36,45), -(6,3,32,41,67,56,36,46), -(6,3,33,41,69,57,37,47), -(6,3,34,42,71,58,38,48), -(6,3,35,43,72,59,39,48), -(6,3,36,43,74,61,40,49), -(6,3,37,44,76,62,40,50), -(6,3,38,45,78,63,41,51), -(6,3,39,45,80,64,42,52), -(6,3,40,46,82,66,43,53), -(6,3,41,47,84,67,44,54), -(6,3,42,47,86,68,45,55), -(6,3,43,48,88,70,46,56), -(6,3,44,49,90,71,46,57), -(6,3,45,49,92,72,47,58), -(6,3,46,50,94,74,48,59), -(6,3,47,51,96,75,49,60), -(6,3,48,51,98,77,50,61), -(6,3,49,52,100,78,51,62), -(6,3,50,53,102,79,52,63), -(6,3,51,54,104,81,53,64), -(6,3,52,54,106,82,54,65), -(6,3,53,55,108,84,55,66), -(6,3,54,56,110,85,56,67), -(6,3,55,57,112,87,57,68), -(6,3,56,57,114,88,58,69), -(6,3,57,58,117,90,59,70), -(6,3,58,59,119,91,60,71), -(6,3,59,60,121,93,61,72), -(6,3,60,61,123,94,62,74), -(6,3,61,61,125,96,63,75), -(6,3,62,62,128,97,64,76), -(6,3,63,63,130,99,65,77), -(6,3,64,64,132,100,66,78), -(6,3,65,65,134,102,67,79), -(6,3,66,66,137,104,68,80), -(6,3,67,66,139,105,69,81), -(6,3,68,67,141,107,70,83), -(6,3,69,68,144,108,71,84), -(6,3,70,69,146,110,72,85), -(6,7,1,26,15,23,16,24), -(6,7,2,27,15,24,17,25), -(6,7,3,28,16,25,18,26), -(6,7,4,28,16,26,19,27), -(6,7,5,29,17,27,20,28), -(6,7,6,30,17,28,21,29), -(6,7,7,31,18,29,22,30), -(6,7,8,32,18,30,23,31), -(6,7,9,33,19,31,24,32), -(6,7,10,34,19,32,25,33), -(6,7,11,35,20,33,26,35), -(6,7,12,35,20,34,27,36), -(6,7,13,36,21,35,28,37), -(6,7,14,37,21,36,29,38), -(6,7,15,38,22,37,30,39), -(6,7,16,39,22,39,31,40), -(6,7,17,40,23,40,32,42), -(6,7,18,41,23,41,33,43), -(6,7,19,42,24,42,34,44), -(6,7,20,43,24,43,35,45), -(6,7,21,44,25,44,36,46), -(6,7,22,45,25,45,37,48), -(6,7,23,46,26,47,38,49), -(6,7,24,47,27,48,40,50), -(6,7,25,48,27,49,41,51), -(6,7,26,49,28,50,42,53), -(6,7,27,51,28,52,43,54), -(6,7,28,52,29,53,44,55), -(6,7,29,53,29,54,45,57), -(6,7,30,54,30,55,47,58), -(6,7,31,55,31,57,48,59), -(6,7,32,56,31,58,49,61), -(6,7,33,57,32,59,50,62), -(6,7,34,58,33,61,51,64), -(6,7,35,60,33,62,53,65), -(6,7,36,61,34,63,54,66), -(6,7,37,62,34,65,55,68), -(6,7,38,63,35,66,57,69), -(6,7,39,64,36,67,58,71), -(6,7,40,66,36,69,59,72), -(6,7,41,67,37,70,60,74), -(6,7,42,68,38,72,62,75), -(6,7,43,69,38,73,63,77), -(6,7,44,70,39,74,64,78), -(6,7,45,72,40,76,66,80), -(6,7,46,73,41,77,67,81), -(6,7,47,74,41,79,69,83), -(6,7,48,76,42,80,70,84), -(6,7,49,77,43,82,71,86), -(6,7,50,78,43,83,73,88), -(6,7,51,80,44,85,74,89), -(6,7,52,81,45,86,76,91), -(6,7,53,82,46,88,77,92), -(6,7,54,84,46,90,78,94), -(6,7,55,85,47,91,80,96), -(6,7,56,86,48,93,81,97), -(6,7,57,88,49,94,83,99), -(6,7,58,89,49,96,84,101), -(6,7,59,91,50,97,86,102), -(6,7,60,92,51,99,87,104), -(6,7,61,94,52,101,89,106), -(6,7,62,95,52,102,90,108), -(6,7,63,96,53,104,92,109), -(6,7,64,98,54,106,93,111), -(6,7,65,99,55,107,95,113), -(6,7,66,101,56,109,97,115), -(6,7,67,102,57,111,98,117), -(6,7,68,104,57,113,100,118), -(6,7,69,105,58,114,101,120), -(6,7,70,107,59,116,103,122), -(6,11,1,26,15,22,17,24), -(6,11,2,27,16,23,18,25), -(6,11,3,27,16,23,19,26), -(6,11,4,28,17,24,20,27), -(6,11,5,28,17,25,21,29), -(6,11,6,29,18,25,22,30), -(6,11,7,29,18,26,23,31), -(6,11,8,30,19,27,24,32), -(6,11,9,30,19,27,26,34), -(6,11,10,31,20,28,27,35), -(6,11,11,32,20,29,28,36), -(6,11,12,32,21,29,29,37), -(6,11,13,33,21,30,30,39), -(6,11,14,33,22,31,31,40), -(6,11,15,34,23,32,32,41), -(6,11,16,35,23,32,34,43), -(6,11,17,35,24,33,35,44), -(6,11,18,36,24,34,36,45), -(6,11,19,37,25,35,37,47), -(6,11,20,37,26,35,39,48), -(6,11,21,38,26,36,40,50), -(6,11,22,39,27,37,41,51), -(6,11,23,39,28,38,42,52), -(6,11,24,40,28,39,44,54), -(6,11,25,41,29,39,45,55), -(6,11,26,41,30,40,46,57), -(6,11,27,42,30,41,47,58), -(6,11,28,43,31,42,49,60), -(6,11,29,44,32,43,50,61), -(6,11,30,44,32,44,52,63), -(6,11,31,45,33,44,53,64), -(6,11,32,46,34,45,54,66), -(6,11,33,47,34,46,56,67), -(6,11,34,47,35,47,57,69), -(6,11,35,48,36,48,58,71), -(6,11,36,49,36,49,60,72), -(6,11,37,50,37,50,61,74), -(6,11,38,51,38,51,63,76), -(6,11,39,52,39,52,64,77), -(6,11,40,52,39,53,66,79), -(6,11,41,53,40,54,67,81), -(6,11,42,54,41,55,69,82), -(6,11,43,55,42,56,70,84), -(6,11,44,56,43,57,72,86), -(6,11,45,57,43,57,73,87), -(6,11,46,57,44,58,75,89), -(6,11,47,58,45,60,76,91), -(6,11,48,59,46,61,78,93), -(6,11,49,60,47,62,79,94), -(6,11,50,61,47,63,81,96), -(6,11,51,62,48,64,83,98), -(6,11,52,63,49,65,84,100), -(6,11,53,64,50,66,86,102), -(6,11,54,65,51,67,87,104), -(6,11,55,66,51,68,89,105), -(6,11,56,67,52,69,91,107), -(6,11,57,68,53,70,92,109), -(6,11,58,69,54,71,94,111), -(6,11,59,70,55,72,96,113), -(6,11,60,71,56,73,97,115), -(6,11,61,72,57,74,99,117), -(6,11,62,73,58,76,101,119), -(6,11,63,74,59,77,103,121), -(6,11,64,75,59,78,104,123), -(6,11,65,76,60,79,106,125), -(6,11,66,77,61,80,108,127), -(6,11,67,78,62,81,110,129), -(6,11,68,79,63,83,111,131), -(6,11,69,80,64,84,113,133), -(6,11,70,81,65,85,115,135), -(7,1,1,18,23,21,24,20), -(7,1,2,19,24,22,24,20), -(7,1,3,21,25,23,24,21), -(7,1,4,22,25,25,24,21), -(7,1,5,23,26,26,24,21), -(7,1,6,25,27,27,24,21), -(7,1,7,26,28,28,24,22), -(7,1,8,27,29,29,25,22), -(7,1,9,29,29,31,25,22), -(7,1,10,30,30,32,25,23), -(7,1,11,32,31,33,25,23), -(7,1,12,33,32,34,25,23), -(7,1,13,34,33,36,25,24), -(7,1,14,36,34,37,25,24), -(7,1,15,37,35,38,25,24), -(7,1,16,39,36,40,25,25), -(7,1,17,40,36,41,25,25), -(7,1,18,42,37,43,26,25), -(7,1,19,43,38,44,26,26), -(7,1,20,45,39,45,26,26), -(7,1,21,47,40,47,26,26), -(7,1,22,48,41,48,26,27), -(7,1,23,50,42,50,26,27), -(7,1,24,51,43,51,26,28), -(7,1,25,53,44,52,27,28), -(7,1,26,55,45,54,27,28), -(7,1,27,56,46,55,27,29), -(7,1,28,58,47,57,27,29), -(7,1,29,59,48,58,27,30), -(7,1,30,61,49,60,27,30), -(7,1,31,63,50,62,27,30), -(7,1,32,65,51,63,28,31), -(7,1,33,66,52,65,28,31), -(7,1,34,68,53,66,28,32), -(7,1,35,70,55,68,28,32), -(7,1,36,72,56,69,28,33), -(7,1,37,73,57,71,29,33), -(7,1,38,75,58,73,29,34), -(7,1,39,77,59,74,29,34), -(7,1,40,79,60,76,29,35), -(7,1,41,81,61,78,29,35), -(7,1,42,82,62,79,30,35), -(7,1,43,84,64,81,30,36), -(7,1,44,86,65,83,30,36), -(7,1,45,88,66,85,30,37), -(7,1,46,90,67,86,30,37), -(7,1,47,92,68,88,31,38), -(7,1,48,94,70,90,31,38), -(7,1,49,96,71,92,31,39), -(7,1,50,98,72,93,31,40), -(7,1,51,100,73,95,32,40), -(7,1,52,102,75,97,32,41), -(7,1,53,104,76,99,32,41), -(7,1,54,106,77,101,32,42), -(7,1,55,108,78,103,33,42), -(7,1,56,110,80,104,33,43), -(7,1,57,112,81,106,33,43), -(7,1,58,114,82,108,33,44), -(7,1,59,116,84,110,34,44), -(7,1,60,118,85,112,34,45), -(7,1,61,120,86,114,34,46), -(7,1,62,122,88,116,35,46), -(7,1,63,125,89,118,35,47), -(7,1,64,127,91,120,35,47), -(7,1,65,129,92,122,35,48), -(7,1,66,131,93,124,36,49), -(7,1,67,133,95,126,36,49), -(7,1,68,136,96,128,36,50), -(7,1,69,138,98,130,37,50), -(7,1,70,140,99,132,37,51), -(7,4,1,16,26,20,24,20), -(7,4,2,17,27,21,24,20), -(7,4,3,18,29,21,24,21), -(7,4,4,18,30,22,24,21), -(7,4,5,19,32,23,25,21), -(7,4,6,20,33,24,25,22), -(7,4,7,21,35,24,25,22), -(7,4,8,22,36,25,25,23), -(7,4,9,22,38,26,25,23), -(7,4,10,23,39,26,25,23), -(7,4,11,24,41,27,25,24), -(7,4,12,25,42,28,26,24), -(7,4,13,26,44,29,26,25), -(7,4,14,27,46,30,26,25), -(7,4,15,28,47,30,26,25), -(7,4,16,28,49,31,26,26), -(7,4,17,29,50,32,27,26), -(7,4,18,30,52,33,27,27), -(7,4,19,31,54,34,27,27), -(7,4,20,32,56,35,27,28), -(7,4,21,33,57,35,27,28), -(7,4,22,34,59,36,28,29), -(7,4,23,35,61,37,28,29), -(7,4,24,36,62,38,28,30), -(7,4,25,37,64,39,28,30), -(7,4,26,38,66,40,29,31), -(7,4,27,39,68,41,29,31), -(7,4,28,40,70,42,29,32), -(7,4,29,41,72,43,29,32), -(7,4,30,42,73,43,29,33), -(7,4,31,43,75,44,30,33), -(7,4,32,44,77,45,30,34), -(7,4,33,45,79,46,30,34), -(7,4,34,46,81,47,31,35), -(7,4,35,47,83,48,31,35), -(7,4,36,48,85,49,31,36), -(7,4,37,49,87,50,31,36), -(7,4,38,50,89,51,32,37), -(7,4,39,51,91,52,32,38), -(7,4,40,53,93,53,32,38), -(7,4,41,54,95,54,33,39), -(7,4,42,55,97,55,33,39), -(7,4,43,56,99,56,33,40), -(7,4,44,57,101,57,33,40), -(7,4,45,58,103,59,34,41), -(7,4,46,59,105,60,34,42), -(7,4,47,61,107,61,34,42), -(7,4,48,62,110,62,35,43), -(7,4,49,63,112,63,35,44), -(7,4,50,64,114,64,35,44), -(7,4,51,65,116,65,36,45), -(7,4,52,67,118,66,36,45), -(7,4,53,68,121,67,36,46), -(7,4,54,69,123,69,37,47), -(7,4,55,70,125,70,37,47), -(7,4,56,72,127,71,37,48), -(7,4,57,73,130,72,38,49), -(7,4,58,74,132,73,38,49), -(7,4,59,75,134,74,39,50), -(7,4,60,77,137,76,39,51), -(7,4,61,78,139,77,39,51), -(7,4,62,79,141,78,40,52), -(7,4,63,81,144,79,40,53), -(7,4,64,82,146,80,41,54), -(7,4,65,83,149,82,41,54), -(7,4,66,85,151,83,41,55), -(7,4,67,86,154,84,42,56), -(7,4,68,87,156,85,42,57), -(7,4,69,89,158,87,43,57), -(7,4,70,90,161,88,43,58), -(7,8,1,15,23,19,27,22), -(7,8,2,15,23,19,28,23), -(7,8,3,15,23,20,30,25), -(7,8,4,15,23,20,31,26), -(7,8,5,15,24,20,32,27), -(7,8,6,15,24,20,34,29), -(7,8,7,16,24,21,35,30), -(7,8,8,16,24,21,37,31), -(7,8,9,16,24,21,38,33), -(7,8,10,16,24,22,40,34), -(7,8,11,16,25,22,41,36), -(7,8,12,16,25,22,42,37), -(7,8,13,16,25,23,44,38), -(7,8,14,16,25,23,45,40), -(7,8,15,17,25,23,47,41), -(7,8,16,17,25,24,49,43), -(7,8,17,17,26,24,50,44), -(7,8,18,17,26,24,52,46), -(7,8,19,17,26,25,53,47), -(7,8,20,17,26,25,55,49), -(7,8,21,17,26,26,57,51), -(7,8,22,18,27,26,58,52), -(7,8,23,18,27,26,60,54), -(7,8,24,18,27,27,61,55), -(7,8,25,18,27,27,63,57), -(7,8,26,18,28,27,65,59), -(7,8,27,18,28,28,67,60), -(7,8,28,18,28,28,68,62), -(7,8,29,19,28,29,70,64), -(7,8,30,19,29,29,72,65), -(7,8,31,19,29,30,74,67), -(7,8,32,19,29,30,75,69), -(7,8,33,19,29,30,77,70), -(7,8,34,20,30,31,79,72), -(7,8,35,20,30,31,81,74), -(7,8,36,20,30,32,83,76), -(7,8,37,20,30,32,85,78), -(7,8,38,20,31,33,86,79), -(7,8,39,21,31,33,88,81), -(7,8,40,21,31,34,90,83), -(7,8,41,21,32,34,92,85), -(7,8,42,21,32,35,94,87), -(7,8,43,21,32,35,96,89), -(7,8,44,22,32,36,98,91), -(7,8,45,22,33,36,100,92), -(7,8,46,22,33,37,102,94), -(7,8,47,22,33,37,104,96), -(7,8,48,22,34,38,106,98), -(7,8,49,23,34,38,108,100), -(7,8,50,23,34,39,110,102), -(7,8,51,23,35,39,112,104), -(7,8,52,23,35,40,114,106), -(7,8,53,24,35,40,117,108), -(7,8,54,24,36,41,119,110), -(7,8,55,24,36,41,121,112), -(7,8,56,24,37,42,123,114), -(7,8,57,25,37,42,125,117), -(7,8,58,25,37,43,127,119), -(7,8,59,25,38,43,130,121), -(7,8,60,25,38,44,132,123), -(7,8,61,26,38,45,134,125), -(7,8,62,26,39,45,136,127), -(7,8,63,26,39,46,139,129), -(7,8,64,26,40,46,141,132), -(7,8,65,27,40,47,143,134), -(7,8,66,27,40,48,146,136), -(7,8,67,27,41,48,148,138), -(7,8,68,27,41,49,150,140), -(7,8,69,28,42,49,153,143), -(7,8,70,28,42,50,155,145), -(7,9,1,15,23,20,26,22), -(7,9,2,15,23,21,27,23), -(7,9,3,16,24,21,28,24), -(7,9,4,16,24,22,29,25), -(7,9,5,16,24,22,31,27), -(7,9,6,17,25,23,32,28), -(7,9,7,17,25,23,33,29), -(7,9,8,17,26,24,34,30), -(7,9,9,17,26,25,36,31), -(7,9,10,18,26,25,37,33), -(7,9,11,18,27,26,38,34), -(7,9,12,18,27,26,39,35), -(7,9,13,19,28,27,41,36), -(7,9,14,19,28,28,42,38), -(7,9,15,20,28,28,43,39), -(7,9,16,20,29,29,45,40), -(7,9,17,20,29,30,46,42), -(7,9,18,21,30,30,47,43), -(7,9,19,21,30,31,49,44), -(7,9,20,21,31,32,50,46), -(7,9,21,22,31,32,51,47), -(7,9,22,22,31,33,53,49), -(7,9,23,23,32,34,54,50), -(7,9,24,23,32,34,56,51), -(7,9,25,23,33,35,57,53), -(7,9,26,24,33,36,59,54), -(7,9,27,24,34,37,60,56), -(7,9,28,25,34,37,62,57), -(7,9,29,25,35,38,63,59), -(7,9,30,25,35,39,65,60), -(7,9,31,26,36,40,66,62), -(7,9,32,26,36,40,68,63), -(7,9,33,27,37,41,69,65), -(7,9,34,27,38,42,71,66), -(7,9,35,28,38,43,73,68), -(7,9,36,28,39,43,74,69), -(7,9,37,28,39,44,76,71), -(7,9,38,29,40,45,77,73), -(7,9,39,29,40,46,79,74), -(7,9,40,30,41,47,81,76), -(7,9,41,30,41,48,82,78), -(7,9,42,31,42,48,84,79), -(7,9,43,31,43,49,86,81), -(7,9,44,32,43,50,88,83), -(7,9,45,32,44,51,89,84), -(7,9,46,33,44,52,91,86), -(7,9,47,33,45,53,93,88), -(7,9,48,34,46,54,95,89), -(7,9,49,34,46,54,96,91), -(7,9,50,35,47,55,98,93), -(7,9,51,35,48,56,100,95), -(7,9,52,36,48,57,102,97), -(7,9,53,36,49,58,104,98), -(7,9,54,37,50,59,105,100), -(7,9,55,37,50,60,107,102), -(7,9,56,38,51,61,109,104), -(7,9,57,38,52,62,111,106), -(7,9,58,39,52,63,113,108), -(7,9,59,40,53,64,115,109), -(7,9,60,40,54,65,117,111), -(7,9,61,41,54,66,119,113), -(7,9,62,41,55,67,121,115), -(7,9,63,42,56,68,123,117), -(7,9,64,42,57,69,125,119), -(7,9,65,43,57,70,127,121), -(7,9,66,44,58,71,129,123), -(7,9,67,44,59,72,131,125), -(7,9,68,45,59,73,133,127), -(7,9,69,45,60,74,135,129), -(7,9,70,46,61,75,137,131), -(8,1,1,24,22,23,16,21), -(8,1,2,25,23,24,16,21), -(8,1,3,27,24,25,16,22), -(8,1,4,28,24,26,16,22), -(8,1,5,29,25,28,16,22), -(8,1,6,31,26,29,16,22), -(8,1,7,32,27,30,17,23), -(8,1,8,33,28,31,17,23), -(8,1,9,35,28,33,17,23), -(8,1,10,36,29,34,17,24), -(8,1,11,37,30,35,17,24), -(8,1,12,39,31,36,17,24), -(8,1,13,40,32,38,17,25), -(8,1,14,42,33,39,17,25), -(8,1,15,43,34,40,18,25), -(8,1,16,45,35,42,18,26), -(8,1,17,46,35,43,18,26), -(8,1,18,48,36,44,18,26), -(8,1,19,49,37,46,18,27), -(8,1,20,51,38,47,18,27), -(8,1,21,52,39,49,18,27), -(8,1,22,54,40,50,18,28), -(8,1,23,55,41,51,19,28), -(8,1,24,57,42,53,19,29), -(8,1,25,59,43,54,19,29), -(8,1,26,60,44,56,19,29), -(8,1,27,62,45,57,19,30), -(8,1,28,63,46,59,19,30), -(8,1,29,65,47,60,20,31), -(8,1,30,67,48,62,20,31), -(8,1,31,69,49,63,20,31), -(8,1,32,70,50,65,20,32), -(8,1,33,72,51,67,20,32), -(8,1,34,74,53,68,20,33), -(8,1,35,75,54,70,21,33), -(8,1,36,77,55,71,21,34), -(8,1,37,79,56,73,21,34), -(8,1,38,81,57,75,21,35), -(8,1,39,83,58,76,21,35), -(8,1,40,84,59,78,22,35), -(8,1,41,86,60,80,22,36), -(8,1,42,88,62,81,22,36), -(8,1,43,90,63,83,22,37), -(8,1,44,92,64,85,22,37), -(8,1,45,94,65,86,23,38), -(8,1,46,96,66,88,23,38), -(8,1,47,98,67,90,23,39), -(8,1,48,100,69,92,23,39), -(8,1,49,102,70,93,24,40), -(8,1,50,103,71,95,24,40), -(8,1,51,105,72,97,24,41), -(8,1,52,107,74,99,24,42), -(8,1,53,109,75,101,25,42), -(8,1,54,112,76,103,25,43), -(8,1,55,114,78,104,25,43), -(8,1,56,116,79,106,25,44), -(8,1,57,118,80,108,25,44), -(8,1,58,120,81,110,26,45), -(8,1,59,122,83,112,26,45), -(8,1,60,124,84,114,26,46), -(8,1,61,126,85,116,27,47), -(8,1,62,128,87,118,27,47), -(8,1,63,130,88,120,27,48), -(8,1,64,133,90,122,27,48), -(8,1,65,135,91,124,28,49), -(8,1,66,137,92,126,28,50), -(8,1,67,139,94,128,28,50), -(8,1,68,141,95,130,28,51), -(8,1,69,144,97,132,29,51), -(8,1,70,146,98,134,29,52), -(8,3,1,21,25,22,16,22), -(8,3,2,21,26,23,17,23), -(8,3,3,22,28,24,17,23), -(8,3,4,22,29,25,18,24), -(8,3,5,23,30,26,18,25), -(8,3,6,23,32,27,19,25), -(8,3,7,24,33,28,20,26), -(8,3,8,24,35,28,20,26), -(8,3,9,25,36,29,21,27), -(8,3,10,25,38,30,21,28), -(8,3,11,25,39,31,22,29), -(8,3,12,26,41,32,23,29), -(8,3,13,26,42,33,23,30), -(8,3,14,27,44,34,24,31), -(8,3,15,27,45,35,25,31), -(8,3,16,28,47,36,25,32), -(8,3,17,28,48,38,26,33), -(8,3,18,29,50,39,27,34), -(8,3,19,29,51,40,28,34), -(8,3,20,30,53,41,28,35), -(8,3,21,31,55,42,29,36), -(8,3,22,31,56,43,30,37), -(8,3,23,32,58,44,30,37), -(8,3,24,32,60,45,31,38), -(8,3,25,33,61,46,32,39), -(8,3,26,33,63,48,33,40), -(8,3,27,34,65,49,33,41), -(8,3,28,35,66,50,34,41), -(8,3,29,35,68,51,35,42), -(8,3,30,36,70,52,36,43), -(8,3,31,36,72,53,37,44), -(8,3,32,37,73,55,37,45), -(8,3,33,38,75,56,38,46), -(8,3,34,38,77,57,39,47), -(8,3,35,39,79,58,40,48), -(8,3,36,39,81,60,41,48), -(8,3,37,40,83,61,41,49), -(8,3,38,41,85,62,42,50), -(8,3,39,41,86,63,43,51), -(8,3,40,42,88,65,44,52), -(8,3,41,43,90,66,45,53), -(8,3,42,43,92,67,46,54), -(8,3,43,44,94,69,47,55), -(8,3,44,45,96,70,47,56), -(8,3,45,45,98,71,48,57), -(8,3,46,46,100,73,49,58), -(8,3,47,47,102,74,50,59), -(8,3,48,48,104,76,51,60), -(8,3,49,48,106,77,52,61), -(8,3,50,49,108,78,53,62), -(8,3,51,50,110,80,54,63), -(8,3,52,51,113,81,55,64), -(8,3,53,51,115,83,56,65), -(8,3,54,52,117,84,57,66), -(8,3,55,53,119,86,58,67), -(8,3,56,54,121,87,59,68), -(8,3,57,54,123,89,60,69), -(8,3,58,55,126,90,61,70), -(8,3,59,56,128,92,62,71), -(8,3,60,57,130,93,63,73), -(8,3,61,58,132,95,64,74), -(8,3,62,58,134,96,65,75), -(8,3,63,59,137,98,66,76), -(8,3,64,60,139,99,67,77), -(8,3,65,61,141,101,68,78), -(8,3,66,62,144,103,69,79), -(8,3,67,62,146,104,70,80), -(8,3,68,63,148,106,71,82), -(8,3,69,64,151,107,72,83), -(8,3,70,65,153,109,73,84), -(8,4,1,22,25,22,16,21), -(8,4,2,23,26,23,16,21), -(8,4,3,24,28,23,16,22), -(8,4,4,24,29,24,16,22), -(8,4,5,25,31,25,17,22), -(8,4,6,26,32,25,17,23), -(8,4,7,27,34,26,17,23), -(8,4,8,27,35,27,17,24), -(8,4,9,28,37,28,17,24), -(8,4,10,29,38,28,18,24), -(8,4,11,30,40,29,18,25), -(8,4,12,31,41,30,18,25), -(8,4,13,32,43,31,18,26), -(8,4,14,32,45,32,18,26), -(8,4,15,33,46,32,19,26), -(8,4,16,34,48,33,19,27), -(8,4,17,35,50,34,19,27), -(8,4,18,36,51,35,19,28), -(8,4,19,37,53,36,19,28), -(8,4,20,38,55,36,20,29), -(8,4,21,39,56,37,20,29), -(8,4,22,40,58,38,20,30), -(8,4,23,41,60,39,20,30), -(8,4,24,42,62,40,20,31), -(8,4,25,43,63,41,21,31), -(8,4,26,44,65,42,21,32), -(8,4,27,45,67,43,21,32), -(8,4,28,46,69,44,21,33), -(8,4,29,47,71,44,22,33), -(8,4,30,48,72,45,22,34), -(8,4,31,49,74,46,22,34), -(8,4,32,50,76,47,22,35), -(8,4,33,51,78,48,23,35), -(8,4,34,52,80,49,23,36), -(8,4,35,53,82,50,23,36), -(8,4,36,54,84,51,24,37), -(8,4,37,55,86,52,24,37), -(8,4,38,56,88,53,24,38), -(8,4,39,57,90,54,24,38), -(8,4,40,58,92,55,25,39), -(8,4,41,59,94,56,25,40), -(8,4,42,60,96,57,25,40), -(8,4,43,62,98,58,26,41), -(8,4,44,63,100,59,26,41), -(8,4,45,64,102,60,26,42), -(8,4,46,65,104,61,27,43), -(8,4,47,66,107,63,27,43), -(8,4,48,67,109,64,27,44), -(8,4,49,69,111,65,27,44), -(8,4,50,70,113,66,28,45), -(8,4,51,71,115,67,28,46), -(8,4,52,72,117,68,28,46), -(8,4,53,74,120,69,29,47), -(8,4,54,75,122,70,29,48), -(8,4,55,76,124,72,29,48), -(8,4,56,77,126,73,30,49), -(8,4,57,79,129,74,30,50), -(8,4,58,80,131,75,30,50), -(8,4,59,81,133,76,31,51), -(8,4,60,82,136,77,31,52), -(8,4,61,84,138,79,32,52), -(8,4,62,85,140,80,32,53), -(8,4,63,86,143,81,32,54), -(8,4,64,88,145,82,33,55), -(8,4,65,89,148,84,33,55), -(8,4,66,90,150,85,33,56), -(8,4,67,92,153,86,34,57), -(8,4,68,93,155,87,34,58), -(8,4,69,95,157,89,35,58), -(8,4,70,96,160,90,35,59), -(8,5,1,21,22,21,18,24), -(8,5,2,21,22,21,19,25), -(8,5,3,21,22,22,21,27), -(8,5,4,21,23,22,22,28), -(8,5,5,22,23,22,23,29), -(8,5,6,22,23,23,25,31), -(8,5,7,22,23,23,26,32), -(8,5,8,22,24,24,27,34), -(8,5,9,22,24,24,29,35), -(8,5,10,22,24,24,30,37), -(8,5,11,23,24,25,32,38), -(8,5,12,23,24,25,33,40), -(8,5,13,23,25,26,35,41), -(8,5,14,23,25,26,36,43), -(8,5,15,23,25,26,38,44), -(8,5,16,24,26,27,39,46), -(8,5,17,24,26,27,41,47), -(8,5,18,24,26,28,42,49), -(8,5,19,24,26,28,44,50), -(8,5,20,24,27,29,45,52), -(8,5,21,25,27,29,47,54), -(8,5,22,25,27,30,48,55), -(8,5,23,25,28,30,50,57), -(8,5,24,25,28,31,52,59), -(8,5,25,25,28,31,53,60), -(8,5,26,26,28,32,55,62), -(8,5,27,26,29,32,56,64), -(8,5,28,26,29,33,58,65), -(8,5,29,26,29,33,60,67), -(8,5,30,27,30,34,62,69), -(8,5,31,27,30,34,63,71), -(8,5,32,27,30,35,65,73), -(8,5,33,27,31,35,67,74), -(8,5,34,28,31,36,68,76), -(8,5,35,28,32,36,70,78), -(8,5,36,28,32,37,72,80), -(8,5,37,29,32,37,74,82), -(8,5,38,29,33,38,76,84), -(8,5,39,29,33,38,77,86), -(8,5,40,29,33,39,79,87), -(8,5,41,30,34,40,81,89), -(8,5,42,30,34,40,83,91), -(8,5,43,30,35,41,85,93), -(8,5,44,31,35,41,87,95), -(8,5,45,31,35,42,89,97), -(8,5,46,31,36,43,91,99), -(8,5,47,32,36,43,93,101), -(8,5,48,32,37,44,94,103), -(8,5,49,32,37,44,96,105), -(8,5,50,33,37,45,98,107), -(8,5,51,33,38,46,100,110), -(8,5,52,33,38,46,102,112), -(8,5,53,34,39,47,104,114), -(8,5,54,34,39,48,106,116), -(8,5,55,34,40,48,109,118), -(8,5,56,35,40,49,111,120), -(8,5,57,35,41,50,113,122), -(8,5,58,35,41,50,115,125), -(8,5,59,36,42,51,117,127), -(8,5,60,36,42,52,119,129), -(8,5,61,36,42,52,121,131), -(8,5,62,37,43,53,123,133), -(8,5,63,37,43,54,125,136), -(8,5,64,38,44,55,128,138), -(8,5,65,38,44,55,130,140), -(8,5,66,38,45,56,132,143), -(8,5,67,39,45,57,134,145), -(8,5,68,39,46,58,136,147), -(8,5,69,40,46,58,139,150), -(8,5,70,40,47,59,141,152), -(8,7,1,22,22,22,17,23), -(8,7,2,23,22,23,18,24), -(8,7,3,24,23,24,19,25), -(8,7,4,25,23,25,20,26), -(8,7,5,25,24,26,21,27), -(8,7,6,26,24,27,22,28), -(8,7,7,27,25,28,23,29), -(8,7,8,28,25,29,24,30), -(8,7,9,29,25,30,25,31), -(8,7,10,30,26,31,26,33), -(8,7,11,31,26,32,27,34), -(8,7,12,32,27,33,28,35), -(8,7,13,33,27,34,29,36), -(8,7,14,34,28,35,30,37), -(8,7,15,34,28,36,31,38), -(8,7,16,35,29,38,32,39), -(8,7,17,36,29,39,33,41), -(8,7,18,37,30,40,34,42), -(8,7,19,38,30,41,35,43), -(8,7,20,39,31,42,36,44), -(8,7,21,40,32,43,37,45), -(8,7,22,41,32,45,38,47), -(8,7,23,43,33,46,39,48), -(8,7,24,44,33,47,40,49), -(8,7,25,45,34,48,42,51), -(8,7,26,46,34,49,43,52), -(8,7,27,47,35,51,44,53), -(8,7,28,48,35,52,45,54), -(8,7,29,49,36,53,46,56), -(8,7,30,50,37,54,48,57), -(8,7,31,51,37,56,49,59), -(8,7,32,52,38,57,50,60), -(8,7,33,53,38,58,51,61), -(8,7,34,55,39,60,52,63), -(8,7,35,56,40,61,54,64), -(8,7,36,57,40,62,55,66), -(8,7,37,58,41,64,56,67), -(8,7,38,59,42,65,57,68), -(8,7,39,61,42,66,59,70), -(8,7,40,62,43,68,60,71), -(8,7,41,63,44,69,61,73), -(8,7,42,64,44,71,63,74), -(8,7,43,65,45,72,64,76), -(8,7,44,67,46,74,65,77), -(8,7,45,68,46,75,67,79), -(8,7,46,69,47,76,68,80), -(8,7,47,71,48,78,69,82), -(8,7,48,72,49,79,71,83), -(8,7,49,73,49,81,72,85), -(8,7,50,74,50,82,74,87), -(8,7,51,76,51,84,75,88), -(8,7,52,77,51,85,77,90), -(8,7,53,78,52,87,78,92), -(8,7,54,80,53,89,79,93), -(8,7,55,81,54,90,81,95), -(8,7,56,83,55,92,82,96), -(8,7,57,84,55,93,84,98), -(8,7,58,85,56,95,85,100), -(8,7,59,87,57,97,87,102), -(8,7,60,88,58,98,88,103), -(8,7,61,90,58,100,90,105), -(8,7,62,91,59,101,91,107), -(8,7,63,93,60,103,93,108), -(8,7,64,94,61,105,94,110), -(8,7,65,95,62,106,96,112), -(8,7,66,97,63,108,98,114), -(8,7,67,98,63,110,99,116), -(8,7,68,100,64,112,101,117), -(8,7,69,101,65,113,102,119), -(8,7,70,103,66,115,104,121), -(8,8,1,21,22,21,19,23), -(8,8,2,21,22,21,20,24), -(8,8,3,21,22,22,22,26), -(8,8,4,21,22,22,23,27), -(8,8,5,21,23,22,25,28), -(8,8,6,21,23,22,26,30), -(8,8,7,21,23,23,27,31), -(8,8,8,22,23,23,29,32), -(8,8,9,22,23,23,30,34), -(8,8,10,22,23,24,32,35), -(8,8,11,22,24,24,33,37), -(8,8,12,22,24,24,35,38), -(8,8,13,22,24,25,36,39), -(8,8,14,22,24,25,38,41), -(8,8,15,22,24,25,39,42), -(8,8,16,22,24,26,41,44), -(8,8,17,23,25,26,42,45), -(8,8,18,23,25,26,44,47), -(8,8,19,23,25,27,46,48), -(8,8,20,23,25,27,47,50), -(8,8,21,23,25,27,49,51), -(8,8,22,23,26,28,51,53), -(8,8,23,23,26,28,52,55), -(8,8,24,24,26,29,54,56), -(8,8,25,24,26,29,56,58), -(8,8,26,24,27,29,57,60), -(8,8,27,24,27,30,59,61), -(8,8,28,24,27,30,61,63), -(8,8,29,24,27,31,63,65), -(8,8,30,24,28,31,64,66), -(8,8,31,25,28,31,66,68), -(8,8,32,25,28,32,68,70), -(8,8,33,25,28,32,70,71), -(8,8,34,25,29,33,71,73), -(8,8,35,25,29,33,73,75), -(8,8,36,26,29,34,75,77), -(8,8,37,26,29,34,77,79), -(8,8,38,26,30,35,79,80), -(8,8,39,26,30,35,81,82), -(8,8,40,26,30,35,83,84), -(8,8,41,27,31,36,85,86), -(8,8,42,27,31,36,87,88), -(8,8,43,27,31,37,89,90), -(8,8,44,27,32,37,91,91), -(8,8,45,27,32,38,93,93), -(8,8,46,28,32,38,95,95), -(8,8,47,28,32,39,97,97), -(8,8,48,28,33,39,99,99), -(8,8,49,28,33,40,101,101), -(8,8,50,29,33,40,103,103), -(8,8,51,29,34,41,105,105), -(8,8,52,29,34,42,107,107), -(8,8,53,29,35,42,109,109), -(8,8,54,30,35,43,111,111), -(8,8,55,30,35,43,113,113), -(8,8,56,30,36,44,115,115), -(8,8,57,30,36,44,118,118), -(8,8,58,31,36,45,120,120), -(8,8,59,31,37,45,122,122), -(8,8,60,31,37,46,124,124), -(8,8,61,31,37,47,126,126), -(8,8,62,32,38,47,129,128), -(8,8,63,32,38,48,131,130), -(8,8,64,32,39,48,133,133), -(8,8,65,33,39,49,135,135), -(8,8,66,33,39,50,138,137), -(8,8,67,33,40,50,140,139), -(8,8,68,33,40,51,142,141), -(8,8,69,34,41,51,145,144), -(8,8,70,34,41,52,147,146), -(10,2,1,19,22,21,24,20), -(10,2,2,20,23,22,25,21), -(10,2,3,21,23,23,25,21), -(10,2,4,22,24,24,26,22), -(10,2,5,23,24,25,27,23), -(10,2,6,25,25,26,27,24), -(10,2,7,26,25,27,28,24), -(10,2,8,27,26,28,29,25), -(10,2,9,28,27,29,29,26), -(10,2,10,29,27,31,30,26), -(10,2,11,30,28,32,31,27), -(10,2,12,32,29,33,31,28), -(10,2,13,33,29,34,32,29), -(10,2,14,34,30,35,33,30), -(10,2,15,35,31,36,33,30), -(10,2,16,37,31,37,34,31), -(10,2,17,38,32,39,35,32), -(10,2,18,39,33,40,36,33), -(10,2,19,40,33,41,36,34), -(10,2,20,42,34,42,37,35), -(10,2,21,43,35,44,38,35), -(10,2,22,44,35,45,39,36), -(10,2,23,46,36,46,40,37), -(10,2,24,47,37,47,40,38), -(10,2,25,49,38,49,41,39), -(10,2,26,50,38,50,42,40), -(10,2,27,51,39,51,43,41), -(10,2,28,53,40,53,44,42), -(10,2,29,54,41,54,45,43), -(10,2,30,56,41,55,45,43), -(10,2,31,57,42,57,46,44), -(10,2,32,58,43,58,47,45), -(10,2,33,60,44,59,48,46), -(10,2,34,61,45,61,49,47), -(10,2,35,63,45,62,50,48), -(10,2,36,64,46,64,51,49), -(10,2,37,66,47,65,52,50), -(10,2,38,67,48,67,53,51), -(10,2,39,69,49,68,54,52), -(10,2,40,71,50,69,55,53), -(10,2,41,72,50,71,55,54), -(10,2,42,74,51,72,56,55), -(10,2,43,75,52,74,57,56), -(10,2,44,77,53,75,58,57), -(10,2,45,79,54,77,59,59), -(10,2,46,80,55,78,60,60), -(10,2,47,82,56,80,61,61), -(10,2,48,83,57,82,62,62), -(10,2,49,85,58,83,63,63), -(10,2,50,87,59,85,64,64), -(10,2,51,89,60,86,66,65), -(10,2,52,90,61,88,67,66), -(10,2,53,92,61,90,68,67), -(10,2,54,94,62,91,69,69), -(10,2,55,95,63,93,70,70), -(10,2,56,97,64,95,71,71), -(10,2,57,99,65,96,72,72), -(10,2,58,101,66,98,73,73), -(10,2,59,102,67,100,74,74), -(10,2,60,104,68,101,75,76), -(10,2,61,106,69,103,76,77), -(10,2,62,108,70,105,78,78), -(10,2,63,110,72,106,79,79), -(10,2,64,112,73,108,80,80), -(10,2,65,113,74,110,81,82), -(10,2,66,115,75,112,82,83), -(10,2,67,117,76,114,83,84), -(10,2,68,119,77,115,85,85), -(10,2,69,121,78,117,86,87), -(10,2,70,123,79,119,87,88), -(10,3,1,17,25,20,24,20), -(10,3,2,17,26,21,25,21), -(10,3,3,18,28,22,25,21), -(10,3,4,18,29,23,26,22), -(10,3,5,19,30,24,26,23), -(10,3,6,19,32,25,27,23), -(10,3,7,20,33,26,27,24), -(10,3,8,20,35,27,28,25), -(10,3,9,21,36,27,29,25), -(10,3,10,21,38,28,29,26), -(10,3,11,22,39,29,30,27), -(10,3,12,22,41,30,31,27), -(10,3,13,23,42,31,31,28), -(10,3,14,23,44,32,32,29), -(10,3,15,24,45,34,32,29), -(10,3,16,24,47,35,33,30), -(10,3,17,25,48,36,34,31), -(10,3,18,25,50,37,34,32), -(10,3,19,26,51,38,35,32), -(10,3,20,26,53,39,36,33), -(10,3,21,27,55,40,37,34), -(10,3,22,27,56,41,37,35), -(10,3,23,28,58,42,38,36), -(10,3,24,28,60,43,39,36), -(10,3,25,29,61,44,39,37), -(10,3,26,30,63,46,40,38), -(10,3,27,30,65,47,41,39), -(10,3,28,31,66,48,42,40), -(10,3,29,31,68,49,42,40), -(10,3,30,32,70,50,43,41), -(10,3,31,33,72,52,44,42), -(10,3,32,33,73,53,45,43), -(10,3,33,34,75,54,46,44), -(10,3,34,34,77,55,46,45), -(10,3,35,35,79,57,47,46), -(10,3,36,36,81,58,48,47), -(10,3,37,36,83,59,49,47), -(10,3,38,37,85,60,50,48), -(10,3,39,38,86,62,51,49), -(10,3,40,38,88,63,51,50), -(10,3,41,39,90,64,52,51), -(10,3,42,40,92,66,53,52), -(10,3,43,40,94,67,54,53), -(10,3,44,41,96,68,55,54), -(10,3,45,42,98,70,56,55), -(10,3,46,42,100,71,57,56), -(10,3,47,43,102,72,58,57), -(10,3,48,44,104,74,59,58), -(10,3,49,45,106,75,60,59), -(10,3,50,45,108,77,61,60), -(10,3,51,46,110,78,61,61), -(10,3,52,47,113,79,62,62), -(10,3,53,47,115,81,63,63), -(10,3,54,48,117,82,64,64), -(10,3,55,49,119,84,65,65), -(10,3,56,50,121,85,66,66), -(10,3,57,50,123,87,67,67), -(10,3,58,51,126,88,68,68), -(10,3,59,52,128,90,69,70), -(10,3,60,53,130,91,70,71), -(10,3,61,54,132,93,71,72), -(10,3,62,54,134,94,72,73), -(10,3,63,55,137,96,73,74), -(10,3,64,56,139,97,75,75), -(10,3,65,57,141,99,76,76), -(10,3,66,58,144,101,77,77), -(10,3,67,58,146,102,78,78), -(10,3,68,59,148,104,79,80), -(10,3,69,60,151,105,80,81), -(10,3,70,61,153,107,81,82), -(10,4,1,18,25,20,24,19), -(10,4,2,19,26,21,24,19), -(10,4,3,20,28,21,24,20), -(10,4,4,20,29,22,24,20), -(10,4,5,21,31,23,25,20), -(10,4,6,22,32,24,25,21), -(10,4,7,23,34,24,25,21), -(10,4,8,24,35,25,25,22), -(10,4,9,24,37,26,25,22), -(10,4,10,25,38,26,25,22), -(10,4,11,26,40,27,25,23), -(10,4,12,27,41,28,26,23), -(10,4,13,28,43,29,26,24), -(10,4,14,29,45,30,26,24), -(10,4,15,29,46,30,26,25), -(10,4,16,30,48,31,26,25), -(10,4,17,31,50,32,27,25), -(10,4,18,32,51,33,27,26), -(10,4,19,33,53,34,27,26), -(10,4,20,34,55,35,27,27), -(10,4,21,35,56,35,27,27), -(10,4,22,36,58,36,28,28), -(10,4,23,37,60,37,28,28), -(10,4,24,38,62,38,28,29), -(10,4,25,39,63,39,28,29), -(10,4,26,40,65,40,29,30), -(10,4,27,41,67,41,29,30), -(10,4,28,42,69,42,29,31), -(10,4,29,43,71,43,29,31), -(10,4,30,44,72,43,29,32), -(10,4,31,45,74,44,30,32), -(10,4,32,46,76,45,30,33), -(10,4,33,47,78,46,30,33), -(10,4,34,48,80,47,31,34), -(10,4,35,49,82,48,31,34), -(10,4,36,50,84,49,31,35), -(10,4,37,51,86,50,31,35), -(10,4,38,52,88,51,32,36), -(10,4,39,53,90,52,32,37), -(10,4,40,54,92,53,32,37), -(10,4,41,56,94,54,33,38), -(10,4,42,57,96,55,33,38), -(10,4,43,58,98,56,33,39), -(10,4,44,59,100,57,33,39), -(10,4,45,60,102,59,34,40), -(10,4,46,61,104,60,34,41), -(10,4,47,62,107,61,34,41), -(10,4,48,64,109,62,35,42), -(10,4,49,65,111,63,35,43), -(10,4,50,66,113,64,35,43), -(10,4,51,67,115,65,36,44), -(10,4,52,68,117,66,36,44), -(10,4,53,70,120,67,36,45), -(10,4,54,71,122,69,37,46), -(10,4,55,72,124,70,37,46), -(10,4,56,73,126,71,37,47), -(10,4,57,75,129,72,38,48), -(10,4,58,76,131,73,38,48), -(10,4,59,77,133,74,39,49), -(10,4,60,79,136,76,39,50), -(10,4,61,80,138,77,39,51), -(10,4,62,81,140,78,40,51), -(10,4,63,82,143,79,40,52), -(10,4,64,84,145,80,41,53), -(10,4,65,85,148,82,41,53), -(10,4,66,87,150,83,41,54), -(10,4,67,88,153,84,42,55), -(10,4,68,89,155,85,42,56), -(10,4,69,91,157,87,43,56), -(10,4,70,92,160,88,43,57), -(10,5,1,17,22,19,26,22), -(10,5,2,17,22,19,27,23), -(10,5,3,17,22,20,29,25), -(10,5,4,17,23,20,30,26), -(10,5,5,18,23,20,31,27), -(10,5,6,18,23,21,33,29), -(10,5,7,18,23,21,34,30), -(10,5,8,18,24,22,35,32), -(10,5,9,18,24,22,37,33), -(10,5,10,19,24,22,38,35), -(10,5,11,19,24,23,39,36), -(10,5,12,19,24,23,41,38), -(10,5,13,19,25,24,42,39), -(10,5,14,19,25,24,44,41), -(10,5,15,19,25,25,45,42), -(10,5,16,20,26,25,47,44), -(10,5,17,20,26,25,48,45), -(10,5,18,20,26,26,50,47), -(10,5,19,20,26,26,51,49), -(10,5,20,21,27,27,53,50), -(10,5,21,21,27,27,54,52), -(10,5,22,21,27,28,56,53), -(10,5,23,21,28,28,58,55), -(10,5,24,21,28,29,59,57), -(10,5,25,22,28,29,61,58), -(10,5,26,22,28,30,62,60), -(10,5,27,22,29,30,64,62), -(10,5,28,22,29,31,66,64), -(10,5,29,23,29,31,67,65), -(10,5,30,23,30,32,69,67), -(10,5,31,23,30,32,71,69), -(10,5,32,23,30,33,72,71), -(10,5,33,24,31,33,74,72), -(10,5,34,24,31,34,76,74), -(10,5,35,24,32,34,78,76), -(10,5,36,24,32,35,80,78), -(10,5,37,25,32,35,81,80), -(10,5,38,25,33,36,83,82), -(10,5,39,25,33,37,85,84), -(10,5,40,26,33,37,87,86), -(10,5,41,26,34,38,89,88), -(10,5,42,26,34,38,91,89), -(10,5,43,27,35,39,92,91), -(10,5,44,27,35,39,94,93), -(10,5,45,27,35,40,96,95), -(10,5,46,27,36,41,98,97), -(10,5,47,28,36,41,100,99), -(10,5,48,28,37,42,102,101), -(10,5,49,28,37,43,104,103), -(10,5,50,29,37,43,106,106), -(10,5,51,29,38,44,108,108), -(10,5,52,29,38,44,110,110), -(10,5,53,30,39,45,112,112), -(10,5,54,30,39,46,114,114), -(10,5,55,30,40,46,116,116), -(10,5,56,31,40,47,118,118), -(10,5,57,31,41,48,120,120), -(10,5,58,31,41,48,123,123), -(10,5,59,32,42,49,125,125), -(10,5,60,32,42,50,127,127), -(10,5,61,33,42,51,129,129), -(10,5,62,33,43,51,131,131), -(10,5,63,33,43,52,133,134), -(10,5,64,34,44,53,135,136), -(10,5,65,34,44,53,138,138), -(10,5,66,34,45,54,140,141), -(10,5,67,35,45,55,142,143), -(10,5,68,35,46,56,144,145), -(10,5,69,36,46,56,147,148), -(10,5,70,36,47,57,149,150), -(10,8,1,17,22,19,27,21), -(10,8,2,17,22,19,28,22), -(10,8,3,17,22,20,30,24), -(10,8,4,17,22,20,31,25), -(10,8,5,17,23,20,32,26), -(10,8,6,17,23,20,34,28), -(10,8,7,18,23,21,35,29), -(10,8,8,18,23,21,37,30), -(10,8,9,18,23,21,38,32), -(10,8,10,18,23,22,40,33), -(10,8,11,18,24,22,41,35), -(10,8,12,18,24,22,42,36), -(10,8,13,18,24,23,44,37), -(10,8,14,18,24,23,45,39), -(10,8,15,18,24,23,47,40), -(10,8,16,19,24,24,49,42), -(10,8,17,19,25,24,50,43), -(10,8,18,19,25,24,52,45), -(10,8,19,19,25,25,53,46), -(10,8,20,19,25,25,55,48), -(10,8,21,19,25,26,57,50), -(10,8,22,19,26,26,58,51), -(10,8,23,20,26,26,60,53), -(10,8,24,20,26,27,61,54), -(10,8,25,20,26,27,63,56), -(10,8,26,20,27,27,65,58), -(10,8,27,20,27,28,67,59), -(10,8,28,20,27,28,68,61), -(10,8,29,21,27,29,70,63), -(10,8,30,21,28,29,72,64), -(10,8,31,21,28,30,74,66), -(10,8,32,21,28,30,75,68), -(10,8,33,21,28,30,77,70), -(10,8,34,21,29,31,79,71), -(10,8,35,22,29,31,81,73), -(10,8,36,22,29,32,83,75), -(10,8,37,22,29,32,85,77), -(10,8,38,22,30,33,86,78), -(10,8,39,22,30,33,88,80), -(10,8,40,23,30,34,90,82), -(10,8,41,23,31,34,92,84), -(10,8,42,23,31,35,94,86), -(10,8,43,23,31,35,96,88), -(10,8,44,23,32,36,98,90), -(10,8,45,24,32,36,100,92), -(10,8,46,24,32,37,102,93), -(10,8,47,24,32,37,104,95), -(10,8,48,24,33,38,106,97), -(10,8,49,25,33,38,108,99), -(10,8,50,25,33,39,110,101), -(10,8,51,25,34,39,112,103), -(10,8,52,25,34,40,114,105), -(10,8,53,25,35,40,117,107), -(10,8,54,26,35,41,119,109), -(10,8,55,26,35,41,121,111), -(10,8,56,26,36,42,123,113), -(10,8,57,26,36,42,125,116), -(10,8,58,27,36,43,127,118), -(10,8,59,27,37,43,130,120), -(10,8,60,27,37,44,132,122), -(10,8,61,27,37,45,134,124), -(10,8,62,28,38,45,136,126), -(10,8,63,28,38,46,139,128), -(10,8,64,28,39,46,141,131), -(10,8,65,29,39,47,143,133), -(10,8,66,29,39,48,146,135), -(10,8,67,29,40,48,148,137), -(10,8,68,29,40,49,150,139), -(10,8,69,30,41,49,153,142), -(10,8,70,30,41,50,155,144), -(10,9,1,17,22,20,26,21), -(10,9,2,17,22,21,27,22), -(10,9,3,18,23,21,28,23), -(10,9,4,18,23,22,29,24), -(10,9,5,18,23,22,31,26), -(10,9,6,18,24,23,32,27), -(10,9,7,19,24,23,33,28), -(10,9,8,19,25,24,34,29), -(10,9,9,19,25,25,36,30), -(10,9,10,20,25,25,37,32), -(10,9,11,20,26,26,38,33), -(10,9,12,20,26,26,39,34), -(10,9,13,21,27,27,41,36), -(10,9,14,21,27,28,42,37), -(10,9,15,21,27,28,43,38), -(10,9,16,22,28,29,45,39), -(10,9,17,22,28,30,46,41), -(10,9,18,23,29,30,47,42), -(10,9,19,23,29,31,49,43), -(10,9,20,23,30,32,50,45), -(10,9,21,24,30,32,51,46), -(10,9,22,24,31,33,53,48), -(10,9,23,24,31,34,54,49), -(10,9,24,25,31,34,56,50), -(10,9,25,25,32,35,57,52), -(10,9,26,26,32,36,59,53), -(10,9,27,26,33,37,60,55), -(10,9,28,26,33,37,62,56), -(10,9,29,27,34,38,63,58), -(10,9,30,27,34,39,65,59), -(10,9,31,28,35,40,66,61), -(10,9,32,28,36,40,68,62), -(10,9,33,29,36,41,69,64), -(10,9,34,29,37,42,71,65), -(10,9,35,29,37,43,73,67), -(10,9,36,30,38,43,74,69), -(10,9,37,30,38,44,76,70), -(10,9,38,31,39,45,77,72), -(10,9,39,31,39,46,79,73), -(10,9,40,32,40,47,81,75), -(10,9,41,32,41,48,82,77), -(10,9,42,33,41,48,84,78), -(10,9,43,33,42,49,86,80), -(10,9,44,34,42,50,88,82), -(10,9,45,34,43,51,89,83), -(10,9,46,35,44,52,91,85), -(10,9,47,35,44,53,93,87), -(10,9,48,36,45,54,95,89), -(10,9,49,36,45,54,96,90), -(10,9,50,37,46,55,98,92), -(10,9,51,37,47,56,100,94), -(10,9,52,38,47,57,102,96), -(10,9,53,38,48,58,104,97), -(10,9,54,39,49,59,105,99), -(10,9,55,39,49,60,107,101), -(10,9,56,40,50,61,109,103), -(10,9,57,40,51,62,111,105), -(10,9,58,41,51,63,113,107), -(10,9,59,42,52,64,115,108), -(10,9,60,42,53,65,117,110), -(10,9,61,43,53,66,119,112), -(10,9,62,43,54,67,121,114), -(10,9,63,44,55,68,123,116), -(10,9,64,44,56,69,125,118), -(10,9,65,45,56,70,127,120), -(10,9,66,46,57,71,129,122), -(10,9,67,46,58,72,131,124), -(10,9,68,47,58,73,133,126), -(10,9,69,47,59,74,135,128), -(10,9,70,48,60,75,137,130), -(11,1,1,24,17,21,21,22), -(11,1,2,25,18,22,21,22), -(11,1,3,27,19,23,21,23), -(11,1,4,28,19,25,21,23), -(11,1,5,29,20,26,21,23), -(11,1,6,31,21,27,21,23), -(11,1,7,32,22,28,21,24), -(11,1,8,33,23,29,22,24), -(11,1,9,35,24,31,22,24), -(11,1,10,36,24,32,22,25), -(11,1,11,37,25,33,22,25), -(11,1,12,39,26,34,22,25), -(11,1,13,40,27,36,22,26), -(11,1,14,42,28,37,22,26), -(11,1,15,43,29,38,22,26), -(11,1,16,45,30,40,22,27), -(11,1,17,46,31,41,23,27), -(11,1,18,48,32,43,23,27), -(11,1,19,49,33,44,23,28), -(11,1,20,51,34,45,23,28), -(11,1,21,52,34,47,23,28), -(11,1,22,54,35,48,23,29), -(11,1,23,55,36,50,23,29), -(11,1,24,57,37,51,24,30), -(11,1,25,59,38,52,24,30), -(11,1,26,60,39,54,24,30), -(11,1,27,62,40,55,24,31), -(11,1,28,63,41,57,24,31), -(11,1,29,65,43,58,24,32), -(11,1,30,67,44,60,24,32), -(11,1,31,69,45,62,25,32), -(11,1,32,70,46,63,25,33), -(11,1,33,72,47,65,25,33), -(11,1,34,74,48,66,25,34), -(11,1,35,75,49,68,25,34), -(11,1,36,77,50,69,26,35), -(11,1,37,79,51,71,26,35), -(11,1,38,81,52,73,26,35), -(11,1,39,83,53,74,26,36), -(11,1,40,84,55,76,26,36), -(11,1,41,86,56,78,27,37), -(11,1,42,88,57,79,27,37), -(11,1,43,90,58,81,27,38), -(11,1,44,92,59,83,27,38), -(11,1,45,94,60,85,27,39), -(11,1,46,96,62,86,28,39), -(11,1,47,98,63,88,28,40), -(11,1,48,100,64,90,28,40), -(11,1,49,102,65,92,28,41), -(11,1,50,103,66,93,29,41), -(11,1,51,105,68,95,29,42), -(11,1,52,107,69,97,29,42), -(11,1,53,109,70,99,29,43), -(11,1,54,112,71,101,30,44), -(11,1,55,114,73,103,30,44), -(11,1,56,116,74,104,30,45), -(11,1,57,118,75,106,30,45), -(11,1,58,120,77,108,31,46), -(11,1,59,122,78,110,31,46), -(11,1,60,124,79,112,31,47), -(11,1,61,126,81,114,31,48), -(11,1,62,128,82,116,32,48), -(11,1,63,130,83,118,32,49), -(11,1,64,133,85,120,32,49), -(11,1,65,135,86,122,33,50), -(11,1,66,137,87,124,33,51), -(11,1,67,139,89,126,33,51), -(11,1,68,141,90,128,33,52), -(11,1,69,144,92,130,34,52), -(11,1,70,146,93,132,34,53), -(11,2,1,23,17,21,21,23), -(11,2,2,24,18,22,22,24), -(11,2,3,25,18,23,22,24), -(11,2,4,26,19,24,23,25), -(11,2,5,27,19,25,24,26), -(11,2,6,29,20,26,24,26), -(11,2,7,30,21,27,25,27), -(11,2,8,31,21,28,26,28), -(11,2,9,32,22,29,26,29), -(11,2,10,33,22,31,27,29), -(11,2,11,34,23,32,28,30), -(11,2,12,36,24,33,28,31), -(11,2,13,37,24,34,29,32), -(11,2,14,38,25,35,30,32), -(11,2,15,39,26,36,31,33), -(11,2,16,40,26,37,31,34), -(11,2,17,42,27,39,32,35), -(11,2,18,43,28,40,33,36), -(11,2,19,44,28,41,34,37), -(11,2,20,46,29,42,34,37), -(11,2,21,47,30,44,35,38), -(11,2,22,48,31,45,36,39), -(11,2,23,50,31,46,37,40), -(11,2,24,51,32,47,38,41), -(11,2,25,52,33,49,38,42), -(11,2,26,54,34,50,39,43), -(11,2,27,55,34,51,40,44), -(11,2,28,56,35,53,41,44), -(11,2,29,58,36,54,42,45), -(11,2,30,59,37,55,43,46), -(11,2,31,61,37,57,43,47), -(11,2,32,62,38,58,44,48), -(11,2,33,64,39,59,45,49), -(11,2,34,65,40,61,46,50), -(11,2,35,67,41,62,47,51), -(11,2,36,68,42,64,48,52), -(11,2,37,70,42,65,49,53), -(11,2,38,71,43,67,50,54), -(11,2,39,73,44,68,51,55), -(11,2,40,74,45,69,52,56), -(11,2,41,76,46,71,53,57), -(11,2,42,78,47,72,54,58), -(11,2,43,79,47,74,55,59), -(11,2,44,81,48,75,56,60), -(11,2,45,82,49,77,57,61), -(11,2,46,84,50,78,58,62), -(11,2,47,86,51,80,59,64), -(11,2,48,87,52,82,60,65), -(11,2,49,89,53,83,61,66), -(11,2,50,91,54,85,62,67), -(11,2,51,92,55,86,63,68), -(11,2,52,94,56,88,64,69), -(11,2,53,96,57,90,65,70), -(11,2,54,97,58,91,66,71), -(11,2,55,99,59,93,67,73), -(11,2,56,101,60,95,68,74), -(11,2,57,103,61,96,69,75), -(11,2,58,105,62,98,70,76), -(11,2,59,106,63,100,71,77), -(11,2,60,108,64,101,72,78), -(11,2,61,110,65,103,74,80), -(11,2,62,112,66,105,75,81), -(11,2,63,114,67,106,76,82), -(11,2,64,116,68,108,77,83), -(11,2,65,117,69,110,78,85), -(11,2,66,119,70,112,79,86), -(11,2,67,121,71,114,80,87), -(11,2,68,123,72,115,82,88), -(11,2,69,125,73,117,83,90), -(11,2,70,127,74,119,84,91), -(11,3,1,21,20,20,21,23), -(11,3,2,21,21,21,22,24), -(11,3,3,22,23,22,22,24), -(11,3,4,22,24,23,23,25), -(11,3,5,23,25,24,23,25), -(11,3,6,23,27,25,24,26), -(11,3,7,24,28,26,24,27), -(11,3,8,24,30,27,25,27), -(11,3,9,25,31,27,26,28), -(11,3,10,25,33,28,26,29), -(11,3,11,25,34,29,27,29), -(11,3,12,26,36,30,28,30), -(11,3,13,26,37,31,28,31), -(11,3,14,27,39,32,29,32), -(11,3,15,27,40,34,30,32), -(11,3,16,28,42,35,30,33), -(11,3,17,28,43,36,31,34), -(11,3,18,29,45,37,32,35), -(11,3,19,29,47,38,32,35), -(11,3,20,30,48,39,33,36), -(11,3,21,31,50,40,34,37), -(11,3,22,31,51,41,34,38), -(11,3,23,32,53,42,35,38), -(11,3,24,32,55,43,36,39), -(11,3,25,33,57,44,37,40), -(11,3,26,33,58,46,37,41), -(11,3,27,34,60,47,38,42), -(11,3,28,35,62,48,39,42), -(11,3,29,35,63,49,40,43), -(11,3,30,36,65,50,40,44), -(11,3,31,36,67,52,41,45), -(11,3,32,37,69,53,42,46), -(11,3,33,38,71,54,43,47), -(11,3,34,38,72,55,44,48), -(11,3,35,39,74,57,44,48), -(11,3,36,39,76,58,45,49), -(11,3,37,40,78,59,46,50), -(11,3,38,41,80,60,47,51), -(11,3,39,41,82,62,48,52), -(11,3,40,42,84,63,49,53), -(11,3,41,43,86,64,50,54), -(11,3,42,43,88,66,50,55), -(11,3,43,44,90,67,51,56), -(11,3,44,45,91,68,52,57), -(11,3,45,45,93,70,53,58), -(11,3,46,46,95,71,54,59), -(11,3,47,47,98,72,55,60), -(11,3,48,48,100,74,56,61), -(11,3,49,48,102,75,57,62), -(11,3,50,49,104,77,58,63), -(11,3,51,50,106,78,59,64), -(11,3,52,51,108,79,60,65), -(11,3,53,51,110,81,61,66), -(11,3,54,52,112,82,61,67), -(11,3,55,53,114,84,62,68), -(11,3,56,54,116,85,63,69), -(11,3,57,54,118,87,64,70), -(11,3,58,55,121,88,65,71), -(11,3,59,56,123,90,66,72), -(11,3,60,57,125,91,67,74), -(11,3,61,58,127,93,68,75), -(11,3,62,58,130,94,69,76), -(11,3,63,59,132,96,71,77), -(11,3,64,60,134,97,72,78), -(11,3,65,61,136,99,73,79), -(11,3,66,62,139,101,74,80), -(11,3,67,62,141,102,75,81), -(11,3,68,63,143,104,76,83), -(11,3,69,64,146,105,77,84), -(11,3,70,65,148,107,78,85), -(11,5,1,21,17,19,23,25), -(11,5,2,21,17,19,24,26), -(11,5,3,21,17,20,26,28), -(11,5,4,21,18,20,27,29), -(11,5,5,22,18,20,28,30), -(11,5,6,22,18,21,30,32), -(11,5,7,22,18,21,31,33), -(11,5,8,22,19,22,32,35), -(11,5,9,22,19,22,34,36), -(11,5,10,22,19,22,35,38), -(11,5,11,23,19,23,37,39), -(11,5,12,23,20,23,38,41), -(11,5,13,23,20,24,39,42), -(11,5,14,23,20,24,41,44), -(11,5,15,23,20,25,42,45), -(11,5,16,24,21,25,44,47), -(11,5,17,24,21,25,45,48), -(11,5,18,24,21,26,47,50), -(11,5,19,24,22,26,48,51), -(11,5,20,24,22,27,50,53), -(11,5,21,25,22,27,51,55), -(11,5,22,25,22,28,53,56), -(11,5,23,25,23,28,55,58), -(11,5,24,25,23,29,56,60), -(11,5,25,25,23,29,58,61), -(11,5,26,26,24,30,60,63), -(11,5,27,26,24,30,61,65), -(11,5,28,26,24,31,63,66), -(11,5,29,26,25,31,65,68), -(11,5,30,27,25,32,66,70), -(11,5,31,27,25,32,68,72), -(11,5,32,27,26,33,70,73), -(11,5,33,27,26,33,71,75), -(11,5,34,28,26,34,73,77), -(11,5,35,28,27,34,75,79), -(11,5,36,28,27,35,77,81), -(11,5,37,29,28,35,79,83), -(11,5,38,29,28,36,80,85), -(11,5,39,29,28,37,82,86), -(11,5,40,29,29,37,84,88), -(11,5,41,30,29,38,86,90), -(11,5,42,30,29,38,88,92), -(11,5,43,30,30,39,90,94), -(11,5,44,31,30,39,91,96), -(11,5,45,31,31,40,93,98), -(11,5,46,31,31,41,95,100), -(11,5,47,32,31,41,97,102), -(11,5,48,32,32,42,99,104), -(11,5,49,32,32,43,101,106), -(11,5,50,33,33,43,103,108), -(11,5,51,33,33,44,105,110), -(11,5,52,33,34,44,107,113), -(11,5,53,34,34,45,109,115), -(11,5,54,34,34,46,111,117), -(11,5,55,34,35,46,113,119), -(11,5,56,35,35,47,115,121), -(11,5,57,35,36,48,118,123), -(11,5,58,35,36,48,120,126), -(11,5,59,36,37,49,122,128), -(11,5,60,36,37,50,124,130), -(11,5,61,36,38,51,126,132), -(11,5,62,37,38,51,128,134), -(11,5,63,37,39,52,130,137), -(11,5,64,38,39,53,133,139), -(11,5,65,38,40,53,135,141), -(11,5,66,38,40,54,137,144), -(11,5,67,39,40,55,139,146), -(11,5,68,39,41,56,141,148), -(11,5,69,40,41,56,144,151), -(11,5,70,40,42,57,146,153), -(11,7,1,22,17,20,22,24), -(11,7,2,23,17,21,23,25), -(11,7,3,24,18,22,24,26), -(11,7,4,25,18,23,25,27), -(11,7,5,25,19,24,26,28), -(11,7,6,26,19,25,27,29), -(11,7,7,27,20,26,28,30), -(11,7,8,28,20,27,28,31), -(11,7,9,29,21,28,29,32), -(11,7,10,30,21,29,30,33), -(11,7,11,31,22,30,31,35), -(11,7,12,32,22,31,32,36), -(11,7,13,33,23,32,33,37), -(11,7,14,34,23,33,34,38), -(11,7,15,34,24,35,35,39), -(11,7,16,35,24,36,36,40), -(11,7,17,36,25,37,38,42), -(11,7,18,37,25,38,39,43), -(11,7,19,38,26,39,40,44), -(11,7,20,39,26,40,41,45), -(11,7,21,40,27,41,42,46), -(11,7,22,41,27,43,43,48), -(11,7,23,43,28,44,44,49), -(11,7,24,44,28,45,45,50), -(11,7,25,45,29,46,46,51), -(11,7,26,46,30,47,48,53), -(11,7,27,47,30,49,49,54), -(11,7,28,48,31,50,50,55), -(11,7,29,49,31,51,51,57), -(11,7,30,50,32,53,52,58), -(11,7,31,51,33,54,53,59), -(11,7,32,52,33,55,55,61), -(11,7,33,53,34,56,56,62), -(11,7,34,55,34,58,57,64), -(11,7,35,56,35,59,58,65), -(11,7,36,57,36,60,60,66), -(11,7,37,58,36,62,61,68), -(11,7,38,59,37,63,62,69), -(11,7,39,61,38,65,63,71), -(11,7,40,62,38,66,65,72), -(11,7,41,63,39,67,66,74), -(11,7,42,64,40,69,67,75), -(11,7,43,65,40,70,69,77), -(11,7,44,67,41,72,70,78), -(11,7,45,68,42,73,71,80), -(11,7,46,69,42,75,73,81), -(11,7,47,71,43,76,74,83), -(11,7,48,72,44,78,76,84), -(11,7,49,73,45,79,77,86), -(11,7,50,74,45,81,78,88), -(11,7,51,76,46,82,80,89), -(11,7,52,77,47,84,81,91), -(11,7,53,78,47,85,83,92), -(11,7,54,80,48,87,84,94), -(11,7,55,81,49,88,86,96), -(11,7,56,83,50,90,87,97), -(11,7,57,84,50,91,89,99), -(11,7,58,85,51,93,90,101), -(11,7,59,87,52,95,92,102), -(11,7,60,88,53,96,93,104), -(11,7,61,90,54,98,95,106), -(11,7,62,91,54,99,96,108), -(11,7,63,93,55,101,98,109), -(11,7,64,94,56,103,99,111), -(11,7,65,95,57,104,101,113), -(11,7,66,97,58,106,103,115), -(11,7,67,98,58,108,104,117), -(11,7,68,100,59,110,106,118), -(11,7,69,101,60,111,107,120), -(11,7,70,103,61,113,109,122), -(11,8,1,21,17,19,24,24), -(11,8,2,21,17,19,25,25), -(11,8,3,21,17,20,27,27), -(11,8,4,21,17,20,28,28), -(11,8,5,21,18,20,29,29), -(11,8,6,21,18,20,31,31), -(11,8,7,21,18,21,32,32), -(11,8,8,22,18,21,34,33), -(11,8,9,22,18,21,35,35), -(11,8,10,22,19,22,37,36), -(11,8,11,22,19,22,38,37), -(11,8,12,22,19,22,40,39), -(11,8,13,22,19,23,41,40), -(11,8,14,22,19,23,43,42), -(11,8,15,22,19,23,44,43), -(11,8,16,22,20,24,46,45), -(11,8,17,23,20,24,47,46), -(11,8,18,23,20,24,49,48), -(11,8,19,23,20,25,50,49), -(11,8,20,23,21,25,52,51), -(11,8,21,23,21,26,54,52), -(11,8,22,23,21,26,55,54), -(11,8,23,23,21,26,57,56), -(11,8,24,24,21,27,59,57), -(11,8,25,24,22,27,60,59), -(11,8,26,24,22,27,62,60), -(11,8,27,24,22,28,64,62), -(11,8,28,24,22,28,65,64), -(11,8,29,24,23,29,67,65), -(11,8,30,24,23,29,69,67), -(11,8,31,25,23,30,71,69), -(11,8,32,25,23,30,73,71), -(11,8,33,25,24,30,74,72), -(11,8,34,25,24,31,76,74), -(11,8,35,25,24,31,78,76), -(11,8,36,26,24,32,80,78), -(11,8,37,26,25,32,82,79), -(11,8,38,26,25,33,84,81), -(11,8,39,26,25,33,86,83), -(11,8,40,26,26,34,87,85), -(11,8,41,27,26,34,89,87), -(11,8,42,27,26,35,91,89), -(11,8,43,27,27,35,93,91), -(11,8,44,27,27,36,95,92), -(11,8,45,27,27,36,97,94), -(11,8,46,28,27,37,99,96), -(11,8,47,28,28,37,101,98), -(11,8,48,28,28,38,103,100), -(11,8,49,28,28,38,105,102), -(11,8,50,29,29,39,107,104), -(11,8,51,29,29,39,110,106), -(11,8,52,29,29,40,112,108), -(11,8,53,29,30,40,114,110), -(11,8,54,30,30,41,116,112), -(11,8,55,30,30,41,118,114), -(11,8,56,30,31,42,120,116), -(11,8,57,30,31,42,122,118), -(11,8,58,31,31,43,125,121), -(11,8,59,31,32,43,127,123), -(11,8,60,31,32,44,129,125), -(11,8,61,31,33,45,131,127), -(11,8,62,32,33,45,133,129), -(11,8,63,32,33,46,136,131), -(11,8,64,32,34,46,138,134), -(11,8,65,33,34,47,140,136), -(11,8,66,33,34,48,143,138), -(11,8,67,33,35,48,145,140), -(11,8,68,33,35,49,147,142), -(11,8,69,34,36,49,150,145), -(11,8,70,34,36,50,152,147); -/*!40000 ALTER TABLE `player_levelstats` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `playercreateinfo` --- - -DROP TABLE IF EXISTS `playercreateinfo`; -CREATE TABLE `playercreateinfo` ( - `race` tinyint(3) unsigned NOT NULL default '0', - `class` tinyint(3) unsigned NOT NULL default '0', - `map` smallint(5) unsigned NOT NULL default '0', - `zone` mediumint(8) unsigned NOT NULL default '0', - `position_x` float NOT NULL default '0', - `position_y` float NOT NULL default '0', - `position_z` float NOT NULL default '0', - PRIMARY KEY (`race`,`class`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8; - --- --- Dumping data for table `playercreateinfo` --- - -LOCK TABLES `playercreateinfo` WRITE; -/*!40000 ALTER TABLE `playercreateinfo` DISABLE KEYS */; -INSERT INTO `playercreateinfo` VALUES -(1,1,0,12,-8949,-132,84), -(1,2,0,12,-8949,-132,84), -(1,4,0,12,-8949,-132,84), -(1,5,0,12,-8949,-132,84), -(1,8,0,12,-8949,-132,84), -(1,9,0,12,-8949,-132,84), -(2,1,1,14,-618,-4251,39), -(2,3,1,14,-618,-4251,39), -(2,4,1,14,-618,-4251,39), -(2,7,1,14,-618,-4251,39), -(2,9,1,14,-618,-4251,39), -(3,1,0,1,-6240,331,383), -(3,2,0,1,-6240,331,383), -(3,3,0,1,-6240,331,383), -(3,4,0,1,-6240,331,383), -(3,5,0,1,-6240,331,383), -(4,1,1,141,10311,832,1327), -(4,3,1,141,10311,832,1327), -(4,4,1,141,10311,832,1327), -(4,5,1,141,10311,832,1327), -(4,11,1,141,10311,832,1327), -(5,1,0,85,1676,1677,122), -(5,4,0,85,1676,1677,122), -(5,5,0,85,1676,1677,122), -(5,8,0,85,1676,1677,122), -(5,9,0,85,1676,1677,122), -(6,1,1,215,-2917,-257,53), -(6,3,1,215,-2917,-257,53), -(6,7,1,215,-2917,-257,53), -(6,11,1,215,-2917,-257,53), -(7,1,0,1,-6240,331,383), -(7,4,0,1,-6340,331,383), -(7,8,0,1,-6340,331,383), -(7,9,0,1,-6340,331,383), -(8,1,1,14,-618,-4251,39), -(8,3,1,14,-618,-4251,39), -(8,4,1,14,-618,-4251,39), -(8,5,1,14,-618,-4251,39), -(8,7,1,14,-618,-4251,39), -(8,8,1,14,-618,-4251,39), -(10,2,530,3431,10349.6,-6357.29,33.4026), -(10,3,530,3431,10349.6,-6357.29,33.4026), -(10,4,530,3431,10349.6,-6357.29,33.4026), -(10,5,530,3431,10349.6,-6357.29,33.4026), -(10,8,530,3431,10349.6,-6357.29,33.4026), -(10,9,530,3431,10349.6,-6357.29,33.4026), -(11,1,530,3526,-3961.64,-13931.2,100.615), -(11,2,530,3526,-3961.64,-13931.2,100.615), -(11,3,530,3526,-3961.64,-13931.2,100.615), -(11,5,530,3526,-3961.64,-13931.2,100.615), -(11,7,530,3526,-3961.64,-13931.2,100.615), -(11,8,530,3526,-3961.64,-13931.2,100.615); -/*!40000 ALTER TABLE `playercreateinfo` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `playercreateinfo_action` --- - -DROP TABLE IF EXISTS `playercreateinfo_action`; -CREATE TABLE `playercreateinfo_action` ( - `race` tinyint(3) unsigned NOT NULL default '0', - `class` tinyint(3) unsigned NOT NULL default '0', - `button` smallint(5) unsigned NOT NULL default '0', - `action` smallint(5) unsigned NOT NULL default '0', - `type` smallint(5) unsigned NOT NULL default '0', - `misc` smallint(5) unsigned NOT NULL default '0', - KEY `playercreateinfo_race_class_index` (`race`,`class`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8; - --- --- Dumping data for table `playercreateinfo_action` --- - -LOCK TABLES `playercreateinfo_action` WRITE; -/*!40000 ALTER TABLE `playercreateinfo_action` DISABLE KEYS */; -INSERT INTO `playercreateinfo_action` VALUES -(1,1,1,78,0,0), -(1,1,0,6603,0,0), -(1,1,11,117,128,0), -(1,2,2,635,0,0), -(1,2,0,6603,0,0), -(1,2,1,21084,0,0), -(1,2,10,159,128,0), -(1,2,11,2070,128,0), -(1,4,1,1752,0,0), -(1,4,2,2098,0,0), -(1,4,3,2764,0,0), -(1,4,0,6603,0,0), -(1,4,11,2070,128,0), -(1,5,1,585,0,0), -(1,5,2,2050,0,0), -(1,5,0,6603,0,0), -(1,5,10,159,128,0), -(1,5,11,2070,128,0), -(1,8,1,133,0,0), -(1,8,2,168,0,0), -(1,8,0,6603,0,0), -(1,8,10,159,128,0), -(1,8,11,2070,128,0), -(1,9,1,686,0,0), -(1,9,2,687,0,0), -(1,9,0,6603,0,0), -(1,9,10,159,128,0), -(1,9,11,4604,128,0), -(2,1,1,78,0,0), -(2,1,0,6603,0,0), -(2,1,11,117,128,0), -(2,3,2,75,0,0), -(2,3,1,2973,0,0), -(2,3,0,6603,0,0), -(2,3,11,117,128,0), -(2,3,10,159,128,0), -(2,4,10,0,128,0), -(2,4,1,1752,0,0), -(2,4,2,2098,0,0), -(2,4,0,6603,0,0), -(2,4,11,117,128,0), -(2,7,2,331,0,0), -(2,7,1,403,0,0), -(2,7,0,6603,0,0), -(2,7,11,117,128,0), -(2,7,10,159,128,0), -(2,9,1,686,0,0), -(2,9,2,687,0,0), -(2,9,0,6603,0,0), -(2,9,11,117,128,0), -(2,9,10,159,128,0), -(3,1,1,78,0,0), -(3,1,0,6603,0,0), -(3,1,11,117,128,0), -(3,2,2,635,0,0), -(3,2,0,6603,0,0), -(3,2,1,21084,0,0), -(3,2,10,159,128,0), -(3,2,11,4540,128,0), -(3,3,2,75,0,0), -(3,3,1,2973,0,0), -(3,3,0,6603,0,0), -(3,3,11,117,128,0), -(3,3,10,159,128,0), -(3,4,1,1752,0,0), -(3,4,2,2098,0,0), -(3,4,3,2764,0,0), -(3,4,0,6603,0,0), -(3,4,11,4540,128,0), -(3,5,1,585,0,0), -(3,5,2,2050,0,0), -(3,5,0,6603,0,0), -(3,5,10,159,128,0), -(3,5,11,4540,128,0), -(4,1,1,78,0,0), -(4,1,0,6603,0,0), -(4,1,11,117,128,0), -(4,3,2,75,0,0), -(4,3,1,2973,0,0), -(4,3,0,6603,0,0), -(4,3,11,117,128,0), -(4,3,10,159,128,0), -(4,4,1,1752,0,0), -(4,4,2,2098,0,0), -(4,4,3,2764,0,0), -(4,4,0,6603,0,0), -(4,4,11,4540,128,0), -(4,5,1,585,0,0), -(4,5,2,2050,0,0), -(4,5,0,6603,0,0), -(4,5,10,159,128,0), -(4,5,11,2070,128,0), -(4,11,1,5176,0,0), -(4,11,2,5185,0,0), -(4,11,0,6603,0,0), -(4,11,10,159,128,0), -(4,11,11,4536,128,0), -(5,1,11,4604,128,0), -(5,1,0,6603,0,0), -(5,1,1,78,0,0), -(5,4,11,4604,128,0), -(5,4,3,2764,0,0), -(5,4,2,2098,0,0), -(5,4,1,1752,0,0), -(5,4,0,6603,0,0), -(5,5,10,159,128,0), -(5,5,2,2050,0,0), -(5,5,1,585,0,0), -(5,5,11,4604,128,0), -(5,5,0,6603,0,0), -(5,8,11,4604,128,0), -(5,8,10,159,128,0), -(5,8,2,168,0,0), -(5,8,1,133,0,0), -(5,8,0,6603,0,0), -(5,9,1,686,0,0), -(5,9,10,159,128,0), -(5,9,2,687,0,0), -(5,9,11,4604,128,0), -(5,9,0,6603,0,0), -(6,1,1,78,0,0), -(6,1,2,20549,0,0), -(6,1,11,4540,128,0), -(6,1,0,6603,0,0), -(6,3,1,2973,0,0), -(6,3,10,159,128,0), -(6,3,2,75,0,0), -(6,3,3,20549,0,0), -(6,3,11,117,128,0), -(6,3,0,6603,0,0), -(6,7,1,403,0,0), -(6,7,10,159,128,0), -(6,7,2,331,0,0), -(6,7,3,20549,0,0), -(6,7,11,4604,128,0), -(6,7,0,6603,0,0), -(6,11,1,5176,0,0), -(6,11,10,159,128,0), -(6,11,2,5185,0,0), -(6,11,3,20549,0,0), -(6,11,11,4536,128,0), -(6,11,0,6603,0,0), -(7,1,11,117,128,0), -(7,1,1,78,0,0), -(7,1,0,6603,0,0), -(7,4,11,117,128,0), -(7,4,3,2764,0,0), -(7,4,1,1752,0,0), -(7,4,2,2098,0,0), -(7,4,0,6603,0,0), -(7,8,11,4536,128,0), -(7,8,1,133,0,0), -(7,8,2,168,0,0), -(7,8,10,159,128,0), -(7,8,0,6603,0,0), -(7,9,11,4604,128,0), -(7,9,1,686,0,0), -(7,9,2,687,0,0), -(7,9,10,159,128,0), -(7,9,0,6603,0,0), -(8,1,11,117,128,0), -(8,1,1,78,0,0), -(8,1,3,2764,0,0), -(8,1,0,6603,0,0), -(8,3,10,159,128,0), -(8,3,11,4604,128,0), -(8,3,1,2973,0,0), -(8,3,2,75,0,0), -(8,3,0,6603,0,0), -(8,4,1,1752,0,0), -(8,4,3,2764,0,0), -(8,4,2,2098,0,0), -(8,4,11,117,128,0), -(8,4,0,6603,0,0), -(8,5,1,585,0,0), -(8,5,10,159,128,0), -(8,5,2,2050,0,0), -(8,5,11,4540,128,0), -(8,5,0,6603,0,0), -(8,7,1,403,0,0), -(8,7,10,159,128,0), -(8,7,2,331,0,0), -(8,7,11,117,128,0), -(8,7,0,6603,0,0), -(8,8,1,133,0,0), -(8,8,10,159,128,0), -(8,8,2,168,0,0), -(8,8,11,117,128,0), -(8,8,0,6603,0,0), -(10,2,0,6603,0,0), -(10,2,1,21084,0,0), -(10,2,2,635,0,0), -(10,2,3,28734,0,0), -(10,2,4,28730,0,0), -(10,2,10,159,128,0), -(10,2,11,20857,128,0), -(10,3,0,6603,0,0), -(10,3,1,2973,0,0), -(10,3,2,75,0,0), -(10,3,3,28734,0,0), -(10,3,4,28730,0,0), -(10,3,10,159,128,0), -(10,3,11,20857,128,0), -(10,4,0,6603,0,0), -(10,4,1,1752,0,0), -(10,4,2,2098,0,0), -(10,4,3,2764,0,0), -(10,4,4,28734,0,0), -(10,4,5,25046,0,0), -(10,4,11,20857,128,0), -(10,5,0,6603,0,0), -(10,5,1,585,0,0), -(10,5,2,2050,0,0), -(10,5,3,28734,0,0), -(10,5,4,28730,0,0), -(10,5,10,159,128,0), -(10,5,11,20857,128,0), -(10,8,0,6603,0,0), -(10,8,1,133,0,0), -(10,8,2,168,0,0), -(10,8,3,28734,0,0), -(10,8,4,28730,0,0), -(10,8,10,159,128,0), -(10,8,11,20857,128,0), -(10,9,11,20857,128,0), -(10,9,10,159,128,0), -(10,9,4,28730,0,0), -(10,9,3,28734,0,0), -(10,9,2,687,0,0), -(10,9,1,686,0,0), -(10,9,0,6603,0,0), -(11,1,0,6603,0,0), -(11,1,72,6603,0,0), -(11,1,73,78,0,0), -(11,1,74,28880,0,0), -(11,1,83,4540,128,0), -(11,1,84,6603,0,0), -(11,1,96,6603,0,0), -(11,1,108,6603,0,0), -(11,2,0,6603,0,0), -(11,2,1,21084,0,0), -(11,2,2,635,0,0), -(11,2,3,28880,0,0), -(11,2,10,159,128,0), -(11,2,11,4540,128,0), -(11,2,83,4540,128,0), -(11,3,0,6603,0,0), -(11,3,1,2973,0,0), -(11,3,2,75,0,0), -(11,3,3,28880,0,0), -(11,3,10,159,128,0), -(11,3,11,4540,128,0), -(11,3,72,6603,0,0), -(11,3,73,2973,0,0), -(11,3,74,75,0,0), -(11,3,82,159,128,0), -(11,3,83,4540,128,0), -(11,5,0,6603,0,0), -(11,5,1,585,0,0), -(11,5,2,2050,0,0), -(11,5,3,28880,0,0), -(11,5,10,159,128,0), -(11,5,11,4540,128,0), -(11,5,83,4540,128,0), -(11,7,0,6603,0,0), -(11,7,1,403,0,0), -(11,7,2,331,0,0), -(11,7,3,28880,0,0), -(11,7,10,159,128,0), -(11,7,11,4540,128,0), -(11,8,0,6603,0,0), -(11,8,1,133,0,0), -(11,8,2,168,0,0), -(11,8,3,28880,0,0), -(11,8,10,159,128,0), -(11,8,11,4540,128,0), -(11,8,83,4540,128,0); -/*!40000 ALTER TABLE `playercreateinfo_action` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `playercreateinfo_item` --- - -DROP TABLE IF EXISTS `playercreateinfo_item`; -CREATE TABLE `playercreateinfo_item` ( - `race` tinyint(3) unsigned NOT NULL default '0', - `class` tinyint(3) unsigned NOT NULL default '0', - `itemid` mediumint(8) unsigned NOT NULL default '0', - `amount` tinyint(3) unsigned NOT NULL default '1', - KEY `playercreateinfo_race_class_index` (`race`,`class`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8; - --- --- Dumping data for table `playercreateinfo_item` --- - -LOCK TABLES `playercreateinfo_item` WRITE; -/*!40000 ALTER TABLE `playercreateinfo_item` DISABLE KEYS */; -INSERT INTO `playercreateinfo_item` VALUES -(1,1,38,1), -(1,1,39,1), -(1,1,40,1), -(1,1,25,1), -(1,1,2362,1), -(1,1,117,4), -(1,1,6948,1), -(1,1,14646,1), -(1,2,45,1), -(1,2,44,1), -(1,2,43,1), -(1,2,2361,1), -(1,2,6948,1), -(1,2,159,2), -(1,2,2070,4), -(1,2,14646,1), -(1,4,49,1), -(1,4,48,1), -(1,4,47,1), -(1,4,2092,1), -(1,4,2947,100), -(1,4,2070,4), -(1,4,6948,1), -(1,4,14646,1), -(1,5,53,1), -(1,5,6098,1), -(1,5,52,1), -(1,5,51,1), -(1,5,36,1), -(1,5,159,2), -(1,5,2070,4), -(1,5,6948,1), -(1,5,14646,1), -(1,8,6096,1), -(1,8,56,1), -(1,8,1395,1), -(1,8,55,1), -(1,8,35,1), -(1,8,2070,4), -(1,8,159,2), -(1,8,6948,1), -(1,8,14646,1), -(1,9,6097,1), -(1,9,57,1), -(1,9,1396,1), -(1,9,59,1), -(1,9,2092,1), -(1,9,4604,4), -(1,9,159,2), -(1,9,6948,1), -(1,9,14646,1), -(2,1,6125,1), -(2,1,139,1), -(2,1,140,1), -(2,1,12282,1), -(2,1,6948,1), -(2,1,117,4), -(2,1,14649,1), -(2,3,127,1), -(2,3,6126,1), -(2,3,6127,1), -(2,3,37,1), -(2,3,2504,1), -(2,3,159,2), -(2,3,117,4), -(2,3,6948,1), -(2,3,14649,1), -(2,3,2512,200), -(2,3,2101,1), -(2,4,2105,1), -(2,4,120,1), -(2,4,121,1), -(2,4,2092,1), -(2,4,25861,100), -(2,4,117,4), -(2,4,6948,1), -(2,4,14649,1), -(2,7,154,1), -(2,7,153,1), -(2,7,36,1), -(2,7,6948,1), -(2,7,117,4), -(2,7,159,2), -(2,7,14649,1), -(2,9,6129,1), -(2,9,1396,1), -(2,9,59,1), -(2,9,2092,1), -(2,9,6948,1), -(2,9,117,4), -(2,9,159,2), -(2,9,14649,1), -(3,1,38,1), -(3,1,39,1), -(3,1,40,1), -(3,1,12282,1), -(3,1,6948,1), -(3,1,117,4), -(3,1,14647,1), -(3,2,45,1), -(3,2,44,1), -(3,2,43,1), -(3,2,2361,1), -(3,2,4540,4), -(3,2,159,2), -(3,2,6948,1), -(3,2,14647,1), -(3,3,148,1), -(3,3,147,1), -(3,3,129,1), -(3,3,37,1), -(3,3,2508,1), -(3,3,159,2), -(3,3,117,4), -(3,3,6948,1), -(3,3,14647,1), -(3,3,2516,200), -(3,3,2102,1), -(3,4,49,1), -(3,4,48,1), -(3,4,47,1), -(3,4,2092,1), -(3,4,25861,100), -(3,4,4540,4), -(3,4,6948,1), -(3,4,14647,1), -(3,5,53,1), -(3,5,6098,1), -(3,5,52,1), -(3,5,51,1), -(3,5,36,1), -(3,5,159,2), -(3,5,4540,4), -(3,5,6948,1), -(3,5,14647,1), -(4,1,38,1), -(4,1,39,1), -(4,1,40,1), -(4,1,25,1), -(4,1,2362,1), -(4,1,117,4), -(4,1,6948,1), -(4,1,14648,1), -(4,3,148,1), -(4,3,147,1), -(4,3,129,1), -(4,3,2092,1), -(4,3,2504,1), -(4,3,159,2), -(4,3,117,4), -(4,3,6948,1), -(4,3,14648,1), -(4,3,2512,200), -(4,3,2101,1), -(4,4,49,1), -(4,4,48,1), -(4,4,47,1), -(4,4,2092,1), -(4,4,2947,100), -(4,4,4540,4), -(4,4,6948,1), -(4,4,14648,1), -(4,5,53,1), -(4,5,6119,1), -(4,5,52,1), -(4,5,51,1), -(4,5,36,1), -(4,5,2070,4), -(4,5,159,2), -(4,5,6948,1), -(4,5,14648,1), -(4,11,6123,1), -(4,11,44,1), -(4,11,3661,1), -(4,11,159,2), -(4,11,4536,4), -(4,11,6948,1), -(4,11,14648,1), -(5,1,6125,1), -(5,1,139,1), -(5,1,140,1), -(5,1,25,1), -(5,1,2362,1), -(5,1,4604,4), -(5,1,6948,1), -(5,1,14651,1), -(5,4,2105,1), -(5,4,120,1), -(5,4,121,1), -(5,4,2092,1), -(5,4,2947,100), -(5,4,4604,4), -(5,4,6948,1), -(5,4,14651,1), -(5,5,53,1), -(5,5,6144,1), -(5,5,52,1), -(5,5,51,1), -(5,5,36,1), -(5,5,4604,4), -(5,5,159,2), -(5,5,6948,1), -(5,5,14651,1), -(5,8,6096,1), -(5,8,6140,1), -(5,8,1395,1), -(5,8,55,1), -(5,8,35,1), -(5,8,4604,4), -(5,8,159,2), -(5,8,6948,1), -(5,8,14651,1), -(5,9,6129,1), -(5,9,1396,1), -(5,9,59,1), -(5,9,2092,1), -(5,9,4604,4), -(5,9,159,2), -(5,9,6948,1), -(5,9,14651,1), -(6,1,6125,1), -(6,1,139,1), -(6,1,2361,1), -(6,1,6948,1), -(6,1,4540,4), -(6,1,14650,1), -(6,3,127,1), -(6,3,6126,1), -(6,3,37,1), -(6,3,2508,1), -(6,3,159,2), -(6,3,117,4), -(6,3,6948,1), -(6,3,14650,1), -(6,3,2516,200), -(6,3,2102,1), -(6,7,154,1), -(6,7,153,1), -(6,7,36,1), -(6,7,6948,1), -(6,7,4604,4), -(6,7,159,2), -(6,7,14650,1), -(6,11,6139,1), -(6,11,6124,1), -(6,11,35,1), -(6,11,159,2), -(6,11,4536,4), -(6,11,6948,1), -(6,11,14650,1), -(7,1,38,1), -(7,1,39,1), -(7,1,40,1), -(7,1,25,1), -(7,1,2362,1), -(7,1,117,4), -(7,1,6948,1), -(7,1,14647,1), -(7,4,49,1), -(7,4,48,1), -(7,4,47,1), -(7,4,2092,1), -(7,4,2947,100), -(7,4,117,4), -(7,4,6948,1), -(7,4,14647,1), -(7,8,6096,1), -(7,8,56,1), -(7,8,1395,1), -(7,8,55,1), -(7,8,35,1), -(7,8,4536,4), -(7,8,159,2), -(7,8,6948,1), -(7,8,14647,1), -(7,9,6097,1), -(7,9,57,1), -(7,9,1396,1), -(7,9,59,1), -(7,9,2092,1), -(7,9,159,2), -(7,9,4604,4), -(7,9,6948,1), -(7,9,14647,1), -(8,1,6125,1), -(8,1,139,1), -(8,1,140,1), -(8,1,37,1), -(8,1,2362,1), -(8,1,25861,100), -(8,1,117,4), -(8,1,6948,1), -(8,1,14649,1), -(8,3,127,1), -(8,3,6126,1), -(8,3,6127,1), -(8,3,37,1), -(8,3,2504,1), -(8,3,4604,4), -(8,3,159,2), -(8,3,2512,200), -(8,3,2101,1), -(8,3,14649,1), -(8,3,6948,1), -(8,4,2105,1), -(8,4,120,1), -(8,4,121,1), -(8,4,2092,1), -(8,4,25861,100), -(8,4,117,4), -(8,4,6948,1), -(8,4,14649,1), -(8,5,53,1), -(8,5,6144,1), -(8,5,52,1), -(8,5,36,1), -(8,5,4540,4), -(8,5,159,2), -(8,5,6948,1), -(8,5,14649,1), -(8,7,6134,1), -(8,7,6135,1), -(8,7,36,1), -(8,7,117,4), -(8,7,159,2), -(8,7,6948,1), -(8,7,14649,1), -(8,8,6096,1), -(8,8,6140,1), -(8,8,1395,1), -(8,8,55,1), -(8,8,35,1), -(8,8,117,4), -(8,8,159,2), -(8,8,6948,1), -(8,8,14649,1), -(10,2,159,5), -(10,2,2070,5), -(10,2,6948,1), -(10,2,23346,1), -(10,2,24143,1), -(10,2,24145,1), -(10,2,24146,1), -(10,3,159,5), -(10,3,2101,1), -(10,3,2512,200), -(10,3,6948,1), -(10,3,20857,5), -(10,3,20899,1), -(10,3,20900,1), -(10,3,20901,1), -(10,3,20980,1), -(10,3,20982,1), -(10,4,3111,100), -(10,4,6948,1), -(10,4,20857,10), -(10,4,20896,1), -(10,4,20897,1), -(10,4,20898,1), -(10,4,20982,1), -(10,5,51,1), -(10,5,52,1), -(10,5,53,1), -(10,5,159,5), -(10,5,6948,1), -(10,5,20891,1), -(10,5,20981,5), -(10,8,35,1), -(10,8,159,5), -(10,8,6096,1), -(10,8,6948,1), -(10,8,20857,5), -(10,8,20893,1), -(10,8,20894,1), -(10,8,20895,1), -(10,9,59,1), -(10,9,159,5), -(10,9,1396,1), -(10,9,6948,1), -(10,9,20857,5), -(10,9,20892,1), -(10,9,20983,1), -(11,1,4540,5), -(11,1,6948,1), -(11,1,23346,1), -(11,1,23473,1), -(11,1,23474,1), -(11,1,23475,1), -(11,2,159,5), -(11,2,2361,1), -(11,2,4540,5), -(11,2,6948,1), -(11,2,23476,1), -(11,2,23476,1), -(11,2,23477,1), -(11,3,25,1), -(11,3,159,5), -(11,3,2101,1), -(11,3,2504,1), -(11,3,2512,200), -(11,3,4540,5), -(11,3,6948,1), -(11,3,23344,1), -(11,3,23345,1), -(11,3,23348,1), -(11,5,36,1), -(11,5,59,1), -(11,5,159,5), -(11,5,1396,1), -(11,5,4540,5), -(11,5,6097,1), -(11,5,6948,1), -(11,5,23322,1), -(11,7,36,1), -(11,7,159,5), -(11,7,4540,5), -(11,7,6948,1), -(11,7,23344,1), -(11,7,23345,1), -(11,7,23348,1), -(11,8,35,1), -(11,8,159,5), -(11,8,4540,5), -(11,8,6948,1), -(11,8,23473,1), -(11,8,23475,1), -(11,8,23478,1), -(11,8,23479,1); -/*!40000 ALTER TABLE `playercreateinfo_item` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `playercreateinfo_spell` --- - -DROP TABLE IF EXISTS `playercreateinfo_spell`; -CREATE TABLE `playercreateinfo_spell` ( - `race` tinyint(3) unsigned NOT NULL default '0', - `class` tinyint(3) unsigned NOT NULL default '0', - `Spell` mediumint(8) unsigned NOT NULL default '0', - `Note` varchar(255) default NULL, - `Active` tinyint(3) unsigned NOT NULL default '1', - PRIMARY KEY (`race`,`class`,`Spell`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8; - --- --- Dumping data for table `playercreateinfo_spell` --- - -LOCK TABLES `playercreateinfo_spell` WRITE; -/*!40000 ALTER TABLE `playercreateinfo_spell` DISABLE KEYS */; -INSERT INTO `playercreateinfo_spell` VALUES -(1,1,78,'Heroic Strike',1), -(1,1,81,'Dodge',1), -(1,1,107,'Block',1), -(1,1,196,'One-Handed Axes',1), -(1,1,198,'One-Handed Maces',1), -(1,1,201,'One-Handed Swords',1), -(1,1,203,'Unarmed',1), -(1,1,204,'Defense',1), -(1,1,522,'SPELLDEFENSE(DND)',1), -(1,1,668,'Language Common',1), -(1,1,2382,'Generic',1), -(1,1,2457,'Battle Stance',1), -(1,1,2479,'Honorless Target',1), -(1,1,3050,'Detect',1), -(1,1,3365,'Opening',1), -(1,1,5301,'Defensive State(DND)',1), -(1,1,6233,'Closing',1), -(1,1,6246,'Closing',1), -(1,1,6247,'Opening',1), -(1,1,6477,'Opening',1), -(1,1,6478,'Opening',1), -(1,1,6603,'Attack',1), -(1,1,7266,'Duel',1), -(1,1,7267,'Grovel',1), -(1,1,7355,'Stuck',1), -(1,1,7376,'Defensive Stance Passive',0), -(1,1,7381,'Berserker Stance Passive',0), -(1,1,8386,'Attacking',1), -(1,1,8737,'Mail',1), -(1,1,9077,'Leather',1), -(1,1,9078,'Cloth',1), -(1,1,9116,'Shield',1), -(1,1,9125,'Generic',1), -(1,1,20597,'Sword Specialization',1), -(1,1,20598,'The Human Spirit',1), -(1,1,20599,'Diplomacy',1), -(1,1,20600,'Perception',1), -(1,1,20864,'Mace Specialization',1), -(1,1,21156,'Battle Stance Passive',0), -(1,1,21651,'Opening',1), -(1,1,21652,'Closing',1), -(1,1,22027,'Remove Insignia',1), -(1,1,22810,'Opening - No Text',1), -(1,1,32215,'Victorious State',1), -(1,2,81,'Dodge',1), -(1,2,107,'Block',1), -(1,2,198,'One-Handed Maces',1), -(1,2,199,'Two-Handed Maces',1), -(1,2,203,'Unarmed',1), -(1,2,204,'Defense',1), -(1,2,522,'SPELLDEFENSE(DND)',1), -(1,2,635,'Holy Light',1), -(1,2,668,'Language Common',1), -(1,2,2382,'Generic',1), -(1,2,2479,'Honorless Target',1), -(1,2,3050,'Detect',1), -(1,2,3365,'Opening',1), -(1,2,6233,'Closing',1), -(1,2,6246,'Closing',1), -(1,2,6247,'Opening',1), -(1,2,6477,'Opening',1), -(1,2,6478,'Opening',1), -(1,2,6603,'Attack',1), -(1,2,7266,'Duel',1), -(1,2,7267,'Grovel',1), -(1,2,7355,'Stuck',1), -(1,2,8386,'Attacking',1), -(1,2,8737,'Mail',1), -(1,2,9077,'Leather',1), -(1,2,9078,'Cloth',1), -(1,2,9116,'Shield',1), -(1,2,9125,'Generic',1), -(1,2,21084,'Seal of Righteousness',1), -(1,2,20597,'Sword Specialization',1), -(1,2,20598,'The Human Spirit',1), -(1,2,20599,'Diplomacy',1), -(1,2,20600,'Perception',1), -(1,2,20864,'Mace Specialization',1), -(1,2,21651,'Opening',1), -(1,2,21652,'Closing',1), -(1,2,22027,'Remove Insignia',1), -(1,2,22810,'Opening - No Text',1), -(1,2,27762,'Libram',1), -(1,4,81,'Dodge',1), -(1,4,203,'Unarmed',1), -(1,4,204,'Defense',1), -(1,4,522,'SPELLDEFENSE(DND)',1), -(1,4,668,'Language Common',1), -(1,4,1180,'Daggers',1), -(1,4,1752,'Sinister Strike',1), -(1,4,2098,'Eviscerate',1), -(1,4,2382,'Generic',1), -(1,4,2479,'Honorless Target',1), -(1,4,2567,'Thrown',1), -(1,4,2764,'Throw',1), -(1,4,3050,'Detect',1), -(1,4,3365,'Opening',1), -(1,4,6233,'Closing',1), -(1,4,6246,'Closing',1), -(1,4,6247,'Opening',1), -(1,4,6477,'Opening',1), -(1,4,6478,'Opening',1), -(1,4,6603,'Attack',1), -(1,4,7266,'Duel',1), -(1,4,7267,'Grovel',1), -(1,4,7355,'Stuck',1), -(1,4,8386,'Attacking',1), -(1,4,9077,'Leather',1), -(1,4,9078,'Cloth',1), -(1,4,9125,'Generic',1), -(1,4,16092,'Defensive State(DND)',1), -(1,4,20597,'Sword Specialization',1), -(1,4,20598,'The Human Spirit',1), -(1,4,20599,'Diplomacy',1), -(1,4,20600,'Perception',1), -(1,4,20864,'Mace Specialization',1), -(1,4,21184,'Rogue Passive(DND)',1), -(1,4,21651,'Opening',1), -(1,4,21652,'Closing',1), -(1,4,22027,'Remove Insignia',1), -(1,4,22810,'Opening - No Text',1), -(1,5,81,'Dodge',1), -(1,5,198,'One-Handed Maces',1), -(1,5,203,'Unarmed',1), -(1,5,204,'Defense',1), -(1,5,522,'SPELLDEFENSE(DND)',1), -(1,5,585,'Smite',1), -(1,5,668,'Language Common',1), -(1,5,2050,'Lesser Heal',1), -(1,5,2382,'Generic',1), -(1,5,2479,'Honorless Target',1), -(1,5,3050,'Detect',1), -(1,5,3365,'Opening',1), -(1,5,5009,'Wands',1), -(1,5,5019,'Shoot',1), -(1,5,6233,'Closing',1), -(1,5,6246,'Closing',1), -(1,5,6247,'Opening',1), -(1,5,6477,'Opening',1), -(1,5,6478,'Opening',1), -(1,5,6603,'Attack',1), -(1,5,7266,'Duel',1), -(1,5,7267,'Grovel',1), -(1,5,7355,'Stuck',1), -(1,5,8386,'Attacking',1), -(1,5,9078,'Cloth',1), -(1,5,9125,'Generic',1), -(1,5,20597,'Sword Specialization',1), -(1,5,20598,'The Human Spirit',1), -(1,5,20599,'Diplomacy',1), -(1,5,20600,'Perception',1), -(1,5,20864,'Mace Specialization',1), -(1,5,21651,'Opening',1), -(1,5,21652,'Closing',1), -(1,5,22027,'Remove Insignia',1), -(1,5,22810,'Opening - No Text',1), -(1,8,81,'Dodge',1), -(1,8,133,'Fireball',1), -(1,8,168,'Frost Armor',1), -(1,8,203,'Unarmed',1), -(1,8,204,'Defense',1), -(1,8,227,'Staves',1), -(1,8,522,'SPELLDEFENSE(DND)',1), -(1,8,668,'Language Common',1), -(1,8,2382,'Generic',1), -(1,8,2479,'Honorless Target',1), -(1,8,3050,'Detect',1), -(1,8,3365,'Opening',1), -(1,8,5009,'Wands',1), -(1,8,5019,'Shoot',1), -(1,8,6233,'Closing',1), -(1,8,6246,'Closing',1), -(1,8,6247,'Opening',1), -(1,8,6477,'Opening',1), -(1,8,6478,'Opening',1), -(1,8,6603,'Attack',1), -(1,8,7266,'Duel',1), -(1,8,7267,'Grovel',1), -(1,8,7355,'Stuck',1), -(1,8,8386,'Attacking',1), -(1,8,9078,'Cloth',1), -(1,8,9125,'Generic',1), -(1,8,20597,'Sword Specialization',1), -(1,8,20598,'The Human Spirit',1), -(1,8,20599,'Diplomacy',1), -(1,8,20600,'Perception',1), -(1,8,20864,'Mace Specialization',1), -(1,8,21651,'Opening',1), -(1,8,21652,'Closing',1), -(1,8,22027,'Remove Insignia',1), -(1,8,22810,'Opening - No Text',1), -(1,9,81,'Dodge',1), -(1,9,203,'Unarmed',1), -(1,9,204,'Defense',1), -(1,9,522,'SPELLDEFENSE(DND)',1), -(1,9,668,'Language Common',1), -(1,9,686,'Shadow Bolt',1), -(1,9,687,'Demon Skin',1), -(1,9,1180,'Daggers',1), -(1,9,2382,'Generic',1), -(1,9,2479,'Honorless Target',1), -(1,9,3050,'Detect',1), -(1,9,3365,'Opening',1), -(1,9,5009,'Wands',1), -(1,9,5019,'Shoot',1), -(1,9,6233,'Closing',1), -(1,9,6246,'Closing',1), -(1,9,6247,'Opening',1), -(1,9,6477,'Opening',1), -(1,9,6478,'Opening',1), -(1,9,6603,'Attack',1), -(1,9,7266,'Duel',1), -(1,9,7267,'Grovel',1), -(1,9,7355,'Stuck',1), -(1,9,8386,'Attacking',1), -(1,9,9078,'Cloth',1), -(1,9,9125,'Generic',1), -(1,9,20597,'Sword Specialization',1), -(1,9,20598,'The Human Spirit',1), -(1,9,20599,'Diplomacy',1), -(1,9,20600,'Perception',1), -(1,9,20864,'Mace Specialization',1), -(1,9,21651,'Opening',1), -(1,9,21652,'Closing',1), -(1,9,22027,'Remove Insignia',1), -(1,9,22810,'Opening - No Text',1), -(2,1,78,'Heroic Strike',1), -(2,1,81,'Dodge',1), -(2,1,107,'Block',1), -(2,1,196,'One-Handed Axes',1), -(2,1,197,'Two-Handed Axes',1), -(2,1,201,'One-Handed Swords',1), -(2,1,203,'Unarmed',1), -(2,1,204,'Defense',1), -(2,1,522,'SPELLDEFENSE(DND)',1), -(2,1,669,'Language Orcish',1), -(2,1,2382,'Generic',1), -(2,1,2457,'Battle Stance',1), -(2,1,2479,'Honorless Target',1), -(2,1,3050,'Detect',1), -(2,1,3365,'Opening',1), -(2,1,5301,'Defensive State(DND)',1), -(2,1,6233,'Closing',1), -(2,1,6246,'Closing',1), -(2,1,6247,'Opening',1), -(2,1,6477,'Opening',1), -(2,1,6478,'Opening',1), -(2,1,6603,'Attack',1), -(2,1,7266,'Duel',1), -(2,1,7267,'Grovel',1), -(2,1,7355,'Stuck',1), -(2,1,7376,'Defensive Stance Passive',0), -(2,1,7381,'Berserker Stance Passive',0), -(2,1,8386,'Attacking',1), -(2,1,8737,'Mail',1), -(2,1,9077,'Leather',1), -(2,1,9078,'Cloth',1), -(2,1,9116,'Shield',1), -(2,1,9125,'Generic',1), -(2,1,20572,'Blood Fury',1), -(2,1,20573,'Hardiness',1), -(2,1,20574,'Axe Specialization',1), -(2,1,21156,'Battle Stance Passive',0), -(2,1,21563,'Command',1), -(2,1,21651,'Opening',1), -(2,1,21652,'Closing',1), -(2,1,22027,'Remove Insignia',1), -(2,1,22810,'Opening - No Text',1), -(2,1,32215,'Victorious State',1), -(2,3,75,'Auto Shot',1), -(2,3,81,'Dodge',1), -(2,3,196,'One-Handed Axes',1), -(2,3,203,'Unarmed',1), -(2,3,204,'Defense',1), -(2,3,264,'Bows',1), -(2,3,522,'SPELLDEFENSE(DND)',1), -(2,3,669,'Language Orcish',1), -(2,3,2382,'Generic',1), -(2,3,2479,'Honorless Target',1), -(2,3,2973,'Raptor Strike',1), -(2,3,3050,'Detect',1), -(2,3,3365,'Opening',1), -(2,3,6233,'Closing',1), -(2,3,6246,'Closing',1), -(2,3,6247,'Opening',1), -(2,3,6477,'Opening',1), -(2,3,6478,'Opening',1), -(2,3,6603,'Attack',1), -(2,3,7266,'Duel',1), -(2,3,7267,'Grovel',1), -(2,3,7355,'Stuck',1), -(2,3,8386,'Attacking',1), -(2,3,9077,'Leather',1), -(2,3,9078,'Cloth',1), -(2,3,9125,'Generic',1), -(2,3,13358,'Defensive State(DND)',1), -(2,3,20572,'Blood Fury',1), -(2,3,20573,'Hardiness',1), -(2,3,20574,'Axe Specialization',1), -(2,3,20576,'Command',1), -(2,3,21651,'Opening',1), -(2,3,21652,'Closing',1), -(2,3,22027,'Remove Insignia',1), -(2,3,22810,'Opening - No Text',1), -(2,3,24949,'Defensive State 2(DND)',1), -(2,3,34082,'Advantaged State(DND)',1), -(2,4,81,'Dodge',1), -(2,4,203,'Unarmed',1), -(2,4,204,'Defense',1), -(2,4,522,'SPELLDEFENSE(DND)',1), -(2,4,669,'Language Orcish',1), -(2,4,1180,'Daggers',1), -(2,4,1752,'Sinister Strike',1), -(2,4,2098,'Eviscerate',1), -(2,4,2382,'Generic',1), -(2,4,2479,'Honorless Target',1), -(2,4,2567,'Thrown',1), -(2,4,2764,'Throw',1), -(2,4,3050,'Detect',1), -(2,4,3365,'Opening',1), -(2,4,6233,'Closing',1), -(2,4,6246,'Closing',1), -(2,4,6247,'Opening',1), -(2,4,6477,'Opening',1), -(2,4,6478,'Opening',1), -(2,4,6603,'Attack',1), -(2,4,7266,'Duel',1), -(2,4,7267,'Grovel',1), -(2,4,7355,'Stuck',1), -(2,4,8386,'Attacking',1), -(2,4,9077,'Leather',1), -(2,4,9078,'Cloth',1), -(2,4,9125,'Generic',1), -(2,4,16092,'Defensive State(DND)',1), -(2,4,20572,'Blood Fury',1), -(2,4,20573,'Hardiness',1), -(2,4,20574,'Axe Specialization',1), -(2,4,21184,'Rogue Passive(DND)',1), -(2,4,21563,'Command',1), -(2,4,21651,'Opening',1), -(2,4,21652,'Closing',1), -(2,4,22027,'Remove Insignia',1), -(2,4,22810,'Opening - No Text',1), -(2,7,81,'Dodge',1), -(2,7,107,'Block',1), -(2,7,198,'One-Handed Maces',1), -(2,7,203,'Unarmed',1), -(2,7,204,'Defense',1), -(2,7,227,'Staves',1), -(2,7,331,'Healing Wave',1), -(2,7,403,'Lightning Bolt',1), -(2,7,522,'SPELLDEFENSE(DND)',1), -(2,7,669,'Language Orcish',1), -(2,7,2382,'Generic',1), -(2,7,2479,'Honorless Target',1), -(2,7,3050,'Detect',1), -(2,7,3365,'Opening',1), -(2,7,6233,'Closing',1), -(2,7,6246,'Closing',1), -(2,7,6247,'Opening',1), -(2,7,6477,'Opening',1), -(2,7,6478,'Opening',1), -(2,7,6603,'Attack',1), -(2,7,7266,'Duel',1), -(2,7,7267,'Grovel',1), -(2,7,7355,'Stuck',1), -(2,7,8386,'Attacking',1), -(2,7,9077,'Leather',1), -(2,7,9078,'Cloth',1), -(2,7,9116,'Shield',1), -(2,7,9125,'Generic',1), -(2,7,20573,'Hardiness',1), -(2,7,20574,'Axe Specialization',1), -(2,7,21563,'Command',1), -(2,7,21651,'Opening',1), -(2,7,21652,'Closing',1), -(2,7,22027,'Remove Insignia',1), -(2,7,22810,'Opening - No Text',1), -(2,7,27763,'Totem',1), -(2,7,33697,'Blood Fury',1), -(2,9,81,'Dodge',1), -(2,9,203,'Unarmed',1), -(2,9,204,'Defense',1), -(2,9,522,'SPELLDEFENSE(DND)',1), -(2,9,669,'Language Orcish',1), -(2,9,686,'Shadow Bolt',1), -(2,9,687,'Demon Skin',1), -(2,9,1180,'Daggers',1), -(2,9,2382,'Generic',1), -(2,9,2479,'Honorless Target',1), -(2,9,3050,'Detect',1), -(2,9,3365,'Opening',1), -(2,9,5009,'Wands',1), -(2,9,5019,'Shoot',1), -(2,9,6233,'Closing',1), -(2,9,6246,'Closing',1), -(2,9,6247,'Opening',1), -(2,9,6477,'Opening',1), -(2,9,6478,'Opening',1), -(2,9,6603,'Attack',1), -(2,9,7266,'Duel',1), -(2,9,7267,'Grovel',1), -(2,9,7355,'Stuck',1), -(2,9,8386,'Attacking',1), -(2,9,9078,'Cloth',1), -(2,9,9125,'Generic',1), -(2,9,20573,'Hardiness',1), -(2,9,20574,'Axe Specialization',1), -(2,9,20575,'Command',1), -(2,9,21651,'Opening',1), -(2,9,21652,'Closing',1), -(2,9,22027,'Remove Insignia',1), -(2,9,22810,'Opening - No Text',1), -(2,9,33702,'Blood Fury',1), -(3,1,78,'Heroic Strike',1), -(3,1,81,'Dodge',1), -(3,1,107,'Block',1), -(3,1,196,'One-Handed Axes',1), -(3,1,197,'Two-Handed Axes',1), -(3,1,198,'One-Handed Maces',1), -(3,1,203,'Unarmed',1), -(3,1,204,'Defense',1), -(3,1,522,'SPELLDEFENSE(DND)',1), -(3,1,668,'Language Common',1), -(3,1,672,'Language Dwarven',1), -(3,1,2382,'Generic',1), -(3,1,2457,'Battle Stance',1), -(3,1,2479,'Honorless Target',1), -(3,1,2481,'Find Treasure',1), -(3,1,3050,'Detect',1), -(3,1,3365,'Opening',1), -(3,1,5301,'Defensive State(DND)',1), -(3,1,6233,'Closing',1), -(3,1,6246,'Closing',1), -(3,1,6247,'Opening',1), -(3,1,6477,'Opening',1), -(3,1,6478,'Opening',1), -(3,1,6603,'Attack',1), -(3,1,7266,'Duel',1), -(3,1,7267,'Grovel',1), -(3,1,7355,'Stuck',1), -(3,1,7376,'Defensive Stance Passive',0), -(3,1,7381,'Berserker Stance Passive',0), -(3,1,8386,'Attacking',1), -(3,1,8737,'Mail',1), -(3,1,9077,'Leather',1), -(3,1,9078,'Cloth',1), -(3,1,9116,'Shield',1), -(3,1,9125,'Generic',1), -(3,1,20594,'Stoneform',1), -(3,1,20595,'Gun Specialization',1), -(3,1,20596,'Frost Resistance',1), -(3,1,21156,'Battle Stance Passive',0), -(3,1,21651,'Opening',1), -(3,1,21652,'Closing',1), -(3,1,22027,'Remove Insignia',1), -(3,1,22810,'Opening - No Text',1), -(3,1,32215,'Victorious State',1), -(3,2,81,'Dodge',1), -(3,2,107,'Block',1), -(3,2,198,'One-Handed Maces',1), -(3,2,199,'Two-Handed Maces',1), -(3,2,203,'Unarmed',1), -(3,2,204,'Defense',1), -(3,2,522,'SPELLDEFENSE(DND)',1), -(3,2,635,'Holy Light',1), -(3,2,668,'Language Common',1), -(3,2,672,'Language Dwarven',1), -(3,2,2382,'Generic',1), -(3,2,2479,'Honorless Target',1), -(3,2,2481,'Find Treasure',1), -(3,2,3050,'Detect',1), -(3,2,3365,'Opening',1), -(3,2,6233,'Closing',1), -(3,2,6246,'Closing',1), -(3,2,6247,'Opening',1), -(3,2,6477,'Opening',1), -(3,2,6478,'Opening',1), -(3,2,6603,'Attack',1), -(3,2,7266,'Duel',1), -(3,2,7267,'Grovel',1), -(3,2,7355,'Stuck',1), -(3,2,8386,'Attacking',1), -(3,2,8737,'Mail',1), -(3,2,9077,'Leather',1), -(3,2,9078,'Cloth',1), -(3,2,9116,'Shield',1), -(3,2,9125,'Generic',1), -(3,2,21084,'Seal of Righteousness',1), -(3,2,20594,'Stoneform',1), -(3,2,20595,'Gun Specialization',1), -(3,2,20596,'Frost Resistance',1), -(3,2,21651,'Opening',1), -(3,2,21652,'Closing',1), -(3,2,22027,'Remove Insignia',1), -(3,2,22810,'Opening - No Text',1), -(3,2,27762,'Libram',1), -(3,3,75,'Auto Shot',1), -(3,3,81,'Dodge',1), -(3,3,196,'One-Handed Axes',1), -(3,3,203,'Unarmed',1), -(3,3,204,'Defense',1), -(3,3,266,'Guns',1), -(3,3,522,'SPELLDEFENSE(DND)',1), -(3,3,668,'Language Common',1), -(3,3,672,'Language Dwarven',1), -(3,3,2382,'Generic',1), -(3,3,2479,'Honorless Target',1), -(3,3,2481,'Find Treasure',1), -(3,3,2973,'Raptor Strike',1), -(3,3,3050,'Detect',1), -(3,3,3365,'Opening',1), -(3,3,6233,'Closing',1), -(3,3,6246,'Closing',1), -(3,3,6247,'Opening',1), -(3,3,6477,'Opening',1), -(3,3,6478,'Opening',1), -(3,3,6603,'Attack',1), -(3,3,7266,'Duel',1), -(3,3,7267,'Grovel',1), -(3,3,7355,'Stuck',1), -(3,3,8386,'Attacking',1), -(3,3,9077,'Leather',1), -(3,3,9078,'Cloth',1), -(3,3,9125,'Generic',1), -(3,3,13358,'Defensive State(DND)',1), -(3,3,20594,'Stoneform',1), -(3,3,20595,'Gun Specialization',1), -(3,3,20596,'Frost Resistance',1), -(3,3,21651,'Opening',1), -(3,3,21652,'Closing',1), -(3,3,22027,'Remove Insignia',1), -(3,3,22810,'Opening - No Text',1), -(3,3,24949,'Defensive State 2(DND)',1), -(3,3,34082,'Advantaged State(DND)',1), -(3,4,81,'Dodge',1), -(3,4,203,'Unarmed',1), -(3,4,204,'Defense',1), -(3,4,522,'SPELLDEFENSE(DND)',1), -(3,4,668,'Language Common',1), -(3,4,672,'Language Dwarven',1), -(3,4,1180,'Daggers',1), -(3,4,1752,'Sinister Strike',1), -(3,4,2098,'Eviscerate',1), -(3,4,2382,'Generic',1), -(3,4,2479,'Honorless Target',1), -(3,4,2481,'Find Treasure',1), -(3,4,2567,'Thrown',1), -(3,4,2764,'Throw',1), -(3,4,3050,'Detect',1), -(3,4,3365,'Opening',1), -(3,4,6233,'Closing',1), -(3,4,6246,'Closing',1), -(3,4,6247,'Opening',1), -(3,4,6477,'Opening',1), -(3,4,6478,'Opening',1), -(3,4,6603,'Attack',1), -(3,4,7266,'Duel',1), -(3,4,7267,'Grovel',1), -(3,4,7355,'Stuck',1), -(3,4,8386,'Attacking',1), -(3,4,9077,'Leather',1), -(3,4,9078,'Cloth',1), -(3,4,9125,'Generic',1), -(3,4,16092,'Defensive State(DND)',1), -(3,4,20594,'Stoneform',1), -(3,4,20595,'Gun Specialization',1), -(3,4,20596,'Frost Resistance',1), -(3,4,21184,'Rogue Passive(DND)',1), -(3,4,21651,'Opening',1), -(3,4,21652,'Closing',1), -(3,4,22027,'Remove Insignia',1), -(3,4,22810,'Opening - No Text',1), -(3,5,81,'Dodge',1), -(3,5,198,'One-Handed Maces',1), -(3,5,203,'Unarmed',1), -(3,5,204,'Defense',1), -(3,5,522,'SPELLDEFENSE(DND)',1), -(3,5,585,'Smite',1), -(3,5,668,'Language Common',1), -(3,5,672,'Language Dwarven',1), -(3,5,2050,'Lesser Heal',1), -(3,5,2382,'Generic',1), -(3,5,2479,'Honorless Target',1), -(3,5,2481,'Find Treasure',1), -(3,5,3050,'Detect',1), -(3,5,3365,'Opening',1), -(3,5,5009,'Wands',1), -(3,5,5019,'Shoot',1), -(3,5,6233,'Closing',1), -(3,5,6246,'Closing',1), -(3,5,6247,'Opening',1), -(3,5,6477,'Opening',1), -(3,5,6478,'Opening',1), -(3,5,6603,'Attack',1), -(3,5,7266,'Duel',1), -(3,5,7267,'Grovel',1), -(3,5,7355,'Stuck',1), -(3,5,8386,'Attacking',1), -(3,5,9078,'Cloth',1), -(3,5,9125,'Generic',1), -(3,5,20594,'Stoneform',1), -(3,5,20595,'Gun Specialization',1), -(3,5,20596,'Frost Resistance',1), -(3,5,21651,'Opening',1), -(3,5,21652,'Closing',1), -(3,5,22027,'Remove Insignia',1), -(3,5,22810,'Opening - No Text',1), -(4,1,78,'Heroic Strike',1), -(4,1,81,'Dodge',1), -(4,1,107,'Block',1), -(4,1,198,'One-Handed Maces',1), -(4,1,201,'One-Handed Swords',1), -(4,1,203,'Unarmed',1), -(4,1,204,'Defense',1), -(4,1,522,'SPELLDEFENSE(DND)',1), -(4,1,668,'Language Common',1), -(4,1,671,'Language Darnassian',1), -(4,1,1180,'Daggers',1), -(4,1,2382,'Generic',1), -(4,1,2457,'Battle Stance',1), -(4,1,2479,'Honorless Target',1), -(4,1,3050,'Detect',1), -(4,1,3365,'Opening',1), -(4,1,5301,'Defensive State(DND)',1), -(4,1,6233,'Closing',1), -(4,1,6246,'Closing',1), -(4,1,6247,'Opening',1), -(4,1,6477,'Opening',1), -(4,1,6478,'Opening',1), -(4,1,6603,'Attack',1), -(4,1,7266,'Duel',1), -(4,1,7267,'Grovel',1), -(4,1,7355,'Stuck',1), -(4,1,7376,'Defensive Stance Passive',0), -(4,1,7381,'Berserker Stance Passive',0), -(4,1,8386,'Attacking',1), -(4,1,8737,'Mail',1), -(4,1,9077,'Leather',1), -(4,1,9078,'Cloth',1), -(4,1,9116,'Shield',1), -(4,1,9125,'Generic',1), -(4,1,20580,'Shadowmeld',1), -(4,1,20582,'Quickness',1), -(4,1,20583,'Nature Resistance',1), -(4,1,20585,'Wisp Spirit',1), -(4,1,21009,'Shadowmeld Passive',1), -(4,1,21156,'Battle Stance Passive',0), -(4,1,21651,'Opening',1), -(4,1,21652,'Closing',1), -(4,1,22027,'Remove Insignia',1), -(4,1,22810,'Opening - No Text',1), -(4,1,32215,'Victorious State',1), -(4,3,75,'Auto Shot',1), -(4,3,81,'Dodge',1), -(4,3,203,'Unarmed',1), -(4,3,204,'Defense',1), -(4,3,264,'Bows',1), -(4,3,522,'SPELLDEFENSE(DND)',1), -(4,3,668,'Language Common',1), -(4,3,671,'Language Darnassian',1), -(4,3,1180,'Daggers',1), -(4,3,2382,'Generic',1), -(4,3,2479,'Honorless Target',1), -(4,3,2973,'Raptor Strike',1), -(4,3,3050,'Detect',1), -(4,3,3365,'Opening',1), -(4,3,6233,'Closing',1), -(4,3,6246,'Closing',1), -(4,3,6247,'Opening',1), -(4,3,6477,'Opening',1), -(4,3,6478,'Opening',1), -(4,3,6603,'Attack',1), -(4,3,7266,'Duel',1), -(4,3,7267,'Grovel',1), -(4,3,7355,'Stuck',1), -(4,3,8386,'Attacking',1), -(4,3,9077,'Leather',1), -(4,3,9078,'Cloth',1), -(4,3,9125,'Generic',1), -(4,3,13358,'Defensive State(DND)',1), -(4,3,20580,'Shadowmeld',1), -(4,3,20582,'Quickness',1), -(4,3,20583,'Nature Resistance',1), -(4,3,20585,'Wisp Spirit',1), -(4,3,21009,'Shadowmeld Passive',1), -(4,3,21651,'Opening',1), -(4,3,21652,'Closing',1), -(4,3,22027,'Remove Insignia',1), -(4,3,22810,'Opening - No Text',1), -(4,3,24949,'Defensive State 2(DND)',1), -(4,3,34082,'Advantaged State(DND)',1), -(4,4,81,'Dodge',1), -(4,4,203,'Unarmed',1), -(4,4,204,'Defense',1), -(4,4,522,'SPELLDEFENSE(DND)',1), -(4,4,668,'Language Common',1), -(4,4,671,'Language Darnassian',1), -(4,4,1180,'Daggers',1), -(4,4,1752,'Sinister Strike',1), -(4,4,2098,'Eviscerate',1), -(4,4,2382,'Generic',1), -(4,4,2479,'Honorless Target',1), -(4,4,2567,'Thrown',1), -(4,4,2764,'Throw',1), -(4,4,3050,'Detect',1), -(4,4,3365,'Opening',1), -(4,4,6233,'Closing',1), -(4,4,6246,'Closing',1), -(4,4,6247,'Opening',1), -(4,4,6477,'Opening',1), -(4,4,6478,'Opening',1), -(4,4,6603,'Attack',1), -(4,4,7266,'Duel',1), -(4,4,7267,'Grovel',1), -(4,4,7355,'Stuck',1), -(4,4,8386,'Attacking',1), -(4,4,9077,'Leather',1), -(4,4,9078,'Cloth',1), -(4,4,9125,'Generic',1), -(4,4,16092,'Defensive State(DND)',1), -(4,4,20580,'Shadowmeld',1), -(4,4,20582,'Quickness',1), -(4,4,20583,'Nature Resistance',1), -(4,4,20585,'Wisp Spirit',1), -(4,4,21009,'Shadowmeld Passive',1), -(4,4,21184,'Rogue Passive(DND)',1), -(4,4,21651,'Opening',1), -(4,4,21652,'Closing',1), -(4,4,22027,'Remove Insignia',1), -(4,4,22810,'Opening - No Text',1), -(4,5,81,'Dodge',1), -(4,5,198,'One-Handed Maces',1), -(4,5,203,'Unarmed',1), -(4,5,204,'Defense',1), -(4,5,522,'SPELLDEFENSE(DND)',1), -(4,5,585,'Smite',1), -(4,5,668,'Language Common',1), -(4,5,671,'Language Darnassian',1), -(4,5,2050,'Lesser Heal',1), -(4,5,2382,'Generic',1), -(4,5,2479,'Honorless Target',1), -(4,5,3050,'Detect',1), -(4,5,3365,'Opening',1), -(4,5,5009,'Wands',1), -(4,5,5019,'Shoot',1), -(4,5,6233,'Closing',1), -(4,5,6246,'Closing',1), -(4,5,6247,'Opening',1), -(4,5,6477,'Opening',1), -(4,5,6478,'Opening',1), -(4,5,6603,'Attack',1), -(4,5,7266,'Duel',1), -(4,5,7267,'Grovel',1), -(4,5,7355,'Stuck',1), -(4,5,8386,'Attacking',1), -(4,5,9078,'Cloth',1), -(4,5,9125,'Generic',1), -(4,5,20580,'Shadowmeld',1), -(4,5,20582,'Quickness',1), -(4,5,20583,'Nature Resistance',1), -(4,5,20585,'Wisp Spirit',1), -(4,5,21009,'Shadowmeld Passive',1), -(4,5,21651,'Opening',1), -(4,5,21652,'Closing',1), -(4,5,22027,'Remove Insignia',1), -(4,5,22810,'Opening - No Text',1), -(4,11,81,'Dodge',1), -(4,11,203,'Unarmed',1), -(4,11,204,'Defense',1), -(4,11,227,'Staves',1), -(4,11,522,'SPELLDEFENSE(DND)',1), -(4,11,668,'Language Common',1), -(4,11,671,'Language Darnassian',1), -(4,11,1178,'Bear Form(Passive)',0), -(4,11,1180,'Daggers',1), -(4,11,2382,'Generic',1), -(4,11,2479,'Honorless Target',1), -(4,11,3025,'Cat Form(Passive)',0), -(4,11,3050,'Detect',1), -(4,11,3365,'Opening',1), -(4,11,5176,'Wrath',1), -(4,11,5185,'Healing Touch',1), -(4,11,5419,'Travel Form(Passive)',0), -(4,11,5420,'Tree of Life',0), -(4,11,5421,'Aquatic Form(Passive)',0), -(4,11,6233,'Closing',1), -(4,11,6246,'Closing',1), -(4,11,6247,'Opening',1), -(4,11,6477,'Opening',1), -(4,11,6478,'Opening',1), -(4,11,6603,'Attack',1), -(4,11,7266,'Duel',1), -(4,11,7267,'Grovel',1), -(4,11,7355,'Stuck',1), -(4,11,8386,'Attacking',1), -(4,11,9077,'Leather',1), -(4,11,9078,'Cloth',1), -(4,11,9125,'Generic',1), -(4,11,9635,'Dire Bear Form(Passive)',0), -(4,11,20580,'Shadowmeld',1), -(4,11,20582,'Quickness',1), -(4,11,20583,'Nature Resistance',1), -(4,11,20585,'Wisp Spirit',1), -(4,11,21009,'Shadowmeld Passive',1), -(4,11,21178,'Bear Form(Passive2)',0), -(4,11,21651,'Opening',1), -(4,11,21652,'Closing',1), -(4,11,22027,'Remove Insignia',1), -(4,11,22810,'Opening - No Text',1), -(4,11,24905,'Moonkin Form(Passive)',0), -(4,11,27764,'Fetish',1), -(4,11,33948,'Flight Form(Passive)',0), -(4,11,34123,'Tree of Life(Passive)',0), -(4,11,40121,'Swift Flight Form(Passive)',0), -(5,1,78,'Heroic Strike',1), -(5,1,81,'Dodge',1), -(5,1,107,'Block',1), -(5,1,201,'One-Handed Swords',1), -(5,1,202,'Two-Handed Swords',1), -(5,1,203,'Unarmed',1), -(5,1,204,'Defense',1), -(5,1,522,'SPELLDEFENSE(DND)',1), -(5,1,669,'Language Orcish',1), -(5,1,1180,'Daggers',1), -(5,1,2382,'Generic',1), -(5,1,2457,'Battle Stance',1), -(5,1,2479,'Honorless Target',1), -(5,1,3050,'Detect',1), -(5,1,3365,'Opening',1), -(5,1,5227,'Underwater Breathing',1), -(5,1,5301,'Defensive State(DND)',1), -(5,1,6233,'Closing',1), -(5,1,6246,'Closing',1), -(5,1,6247,'Opening',1), -(5,1,6477,'Opening',1), -(5,1,6478,'Opening',1), -(5,1,6603,'Attack',1), -(5,1,7266,'Duel',1), -(5,1,7267,'Grovel',1), -(5,1,7355,'Stuck',1), -(5,1,7376,'Defensive Stance Passive',0), -(5,1,7381,'Berserker Stance Passive',0), -(5,1,7744,'Will of the Forsaken',1), -(5,1,8386,'Attacking',1), -(5,1,8737,'Mail',1), -(5,1,9077,'Leather',1), -(5,1,9078,'Cloth',1), -(5,1,9116,'Shield',1), -(5,1,9125,'Generic',1), -(5,1,17737,'Language Gutterspeak',1), -(5,1,20577,'Cannibalize',1), -(5,1,20579,'Shadow Resistance',1), -(5,1,21156,'Battle Stance Passive',0), -(5,1,21651,'Opening',1), -(5,1,21652,'Closing',1), -(5,1,22027,'Remove Insignia',1), -(5,1,22810,'Opening - No Text',1), -(5,1,32215,'Victorious State',1), -(5,4,81,'Dodge',1), -(5,4,203,'Unarmed',1), -(5,4,204,'Defense',1), -(5,4,522,'SPELLDEFENSE(DND)',1), -(5,4,669,'Language Orcish',1), -(5,4,1180,'Daggers',1), -(5,4,1752,'Sinister Strike',1), -(5,4,2098,'Eviscerate',1), -(5,4,2382,'Generic',1), -(5,4,2479,'Honorless Target',1), -(5,4,2567,'Thrown',1), -(5,4,2764,'Throw',1), -(5,4,3050,'Detect',1), -(5,4,3365,'Opening',1), -(5,4,5227,'Underwater Breathing',1), -(5,4,6233,'Closing',1), -(5,4,6246,'Closing',1), -(5,4,6247,'Opening',1), -(5,4,6477,'Opening',1), -(5,4,6478,'Opening',1), -(5,4,6603,'Attack',1), -(5,4,7266,'Duel',1), -(5,4,7267,'Grovel',1), -(5,4,7355,'Stuck',1), -(5,4,7744,'Will of the Forsaken',1), -(5,4,8386,'Attacking',1), -(5,4,9077,'Leather',1), -(5,4,9078,'Cloth',1), -(5,4,9125,'Generic',1), -(5,4,16092,'Defensive State(DND)',1), -(5,4,17737,'Language Gutterspeak',1), -(5,4,20577,'Cannibalize',1), -(5,4,20579,'Shadow Resistance',1), -(5,4,21184,'Rogue Passive(DND)',1), -(5,4,21651,'Opening',1), -(5,4,21652,'Closing',1), -(5,4,22027,'Remove Insignia',1), -(5,4,22810,'Opening - No Text',1), -(5,5,81,'Dodge',1), -(5,5,198,'One-Handed Maces',1), -(5,5,203,'Unarmed',1), -(5,5,204,'Defense',1), -(5,5,522,'SPELLDEFENSE(DND)',1), -(5,5,585,'Smite',1), -(5,5,669,'Language Orcish',1), -(5,5,2050,'Lesser Heal',1), -(5,5,2382,'Generic',1), -(5,5,2479,'Honorless Target',1), -(5,5,3050,'Detect',1), -(5,5,3365,'Opening',1), -(5,5,5009,'Wands',1), -(5,5,5019,'Shoot',1), -(5,5,5227,'Underwater Breathing',1), -(5,5,6233,'Closing',1), -(5,5,6246,'Closing',1), -(5,5,6247,'Opening',1), -(5,5,6477,'Opening',1), -(5,5,6478,'Opening',1), -(5,5,6603,'Attack',1), -(5,5,7266,'Duel',1), -(5,5,7267,'Grovel',1), -(5,5,7355,'Stuck',1), -(5,5,7744,'Will of the Forsaken',1), -(5,5,8386,'Attacking',1), -(5,5,9078,'Cloth',1), -(5,5,9125,'Generic',1), -(5,5,17737,'Language Gutterspeak',1), -(5,5,20577,'Cannibalize',1), -(5,5,20579,'Shadow Resistance',1), -(5,5,21651,'Opening',1), -(5,5,21652,'Closing',1), -(5,5,22027,'Remove Insignia',1), -(5,5,22810,'Opening - No Text',1), -(5,8,81,'Dodge',1), -(5,8,133,'Fireball',1), -(5,8,168,'Frost Armor',1), -(5,8,203,'Unarmed',1), -(5,8,204,'Defense',1), -(5,8,227,'Staves',1), -(5,8,522,'SPELLDEFENSE(DND)',1), -(5,8,669,'Language Orcish',1), -(5,8,2382,'Generic',1), -(5,8,2479,'Honorless Target',1), -(5,8,3050,'Detect',1), -(5,8,3365,'Opening',1), -(5,8,5009,'Wands',1), -(5,8,5019,'Shoot',1), -(5,8,5227,'Underwater Breathing',1), -(5,8,6233,'Closing',1), -(5,8,6246,'Closing',1), -(5,8,6247,'Opening',1), -(5,8,6477,'Opening',1), -(5,8,6478,'Opening',1), -(5,8,6603,'Attack',1), -(5,8,7266,'Duel',1), -(5,8,7267,'Grovel',1), -(5,8,7355,'Stuck',1), -(5,8,7744,'Will of the Forsaken',1), -(5,8,8386,'Attacking',1), -(5,8,9078,'Cloth',1), -(5,8,9125,'Generic',1), -(5,8,17737,'Language Gutterspeak',1), -(5,8,20577,'Cannibalize',1), -(5,8,20579,'Shadow Resistance',1), -(5,8,21651,'Opening',1), -(5,8,21652,'Closing',1), -(5,8,22027,'Remove Insignia',1), -(5,8,22810,'Opening - No Text',1), -(5,9,81,'Dodge',1), -(5,9,203,'Unarmed',1), -(5,9,204,'Defense',1), -(5,9,522,'SPELLDEFENSE(DND)',1), -(5,9,669,'Language Orcish',1), -(5,9,686,'Shadow Bolt',1), -(5,9,687,'Demon Skin',1), -(5,9,1180,'Daggers',1), -(5,9,2382,'Generic',1), -(5,9,2479,'Honorless Target',1), -(5,9,3050,'Detect',1), -(5,9,3365,'Opening',1), -(5,9,5009,'Wands',1), -(5,9,5019,'Shoot',1), -(5,9,5227,'Underwater Breathing',1), -(5,9,6233,'Closing',1), -(5,9,6246,'Closing',1), -(5,9,6247,'Opening',1), -(5,9,6477,'Opening',1), -(5,9,6478,'Opening',1), -(5,9,6603,'Attack',1), -(5,9,7266,'Duel',1), -(5,9,7267,'Grovel',1), -(5,9,7355,'Stuck',1), -(5,9,7744,'Will of the Forsaken',1), -(5,9,8386,'Attacking',1), -(5,9,9078,'Cloth',1), -(5,9,9125,'Generic',1), -(5,9,17737,'Language Gutterspeak',1), -(5,9,20577,'Cannibalize',1), -(5,9,20579,'Shadow Resistance',1), -(5,9,21651,'Opening',1), -(5,9,21652,'Closing',1), -(5,9,22027,'Remove Insignia',1), -(5,9,22810,'Opening - No Text',1), -(6,1,78,'Heroic Strike',1), -(6,1,81,'Dodge',1), -(6,1,107,'Block',1), -(6,1,196,'One-Handed Axes',1), -(6,1,198,'One-Handed Maces',1), -(6,1,199,'Two-Handed Maces',1), -(6,1,203,'Unarmed',1), -(6,1,204,'Defense',1), -(6,1,522,'SPELLDEFENSE(DND)',1), -(6,1,669,'Language Orcish',1), -(6,1,670,'Language Taurahe',1), -(6,1,2382,'Generic',1), -(6,1,2457,'Battle Stance',1), -(6,1,2479,'Honorless Target',1), -(6,1,3050,'Detect',1), -(6,1,3365,'Opening',1), -(6,1,5301,'Defensive State(DND)',1), -(6,1,6233,'Closing',1), -(6,1,6246,'Closing',1), -(6,1,6247,'Opening',1), -(6,1,6477,'Opening',1), -(6,1,6478,'Opening',1), -(6,1,6603,'Attack',1), -(6,1,7266,'Duel',1), -(6,1,7267,'Grovel',1), -(6,1,7355,'Stuck',1), -(6,1,7376,'Defensive Stance Passive',0), -(6,1,7381,'Berserker Stance Passive',0), -(6,1,8386,'Attacking',1), -(6,1,8737,'Mail',1), -(6,1,9077,'Leather',1), -(6,1,9078,'Cloth',1), -(6,1,9116,'Shield',1), -(6,1,9125,'Generic',1), -(6,1,20549,'War Stomp',1), -(6,1,20550,'Endurance',1), -(6,1,20551,'Nature Resistance',1), -(6,1,20552,'Cultivation',1), -(6,1,21156,'Battle Stance Passive',0), -(6,1,21651,'Opening',1), -(6,1,21652,'Closing',1), -(6,1,22027,'Remove Insignia',1), -(6,1,22810,'Opening - No Text',1), -(6,1,32215,'Victorious State',1), -(6,3,75,'Auto Shot',1), -(6,3,81,'Dodge',1), -(6,3,196,'One-Handed Axes',1), -(6,3,203,'Unarmed',1), -(6,3,204,'Defense',1), -(6,3,266,'Guns',1), -(6,3,522,'SPELLDEFENSE(DND)',1), -(6,3,669,'Language Orcish',1), -(6,3,670,'Language Taurahe',1), -(6,3,2382,'Generic',1), -(6,3,2479,'Honorless Target',1), -(6,3,2973,'Raptor Strike',1), -(6,3,3050,'Detect',1), -(6,3,3365,'Opening',1), -(6,3,6233,'Closing',1), -(6,3,6246,'Closing',1), -(6,3,6247,'Opening',1), -(6,3,6477,'Opening',1), -(6,3,6478,'Opening',1), -(6,3,6603,'Attack',1), -(6,3,7266,'Duel',1), -(6,3,7267,'Grovel',1), -(6,3,7355,'Stuck',1), -(6,3,8386,'Attacking',1), -(6,3,9077,'Leather',1), -(6,3,9078,'Cloth',1), -(6,3,9125,'Generic',1), -(6,3,13358,'Defensive State(DND)',1), -(6,3,20549,'War Stomp',1), -(6,3,20550,'Endurance',1), -(6,3,20551,'Nature Resistance',1), -(6,3,20552,'Cultivation',1), -(6,3,21651,'Opening',1), -(6,3,21652,'Closing',1), -(6,3,22027,'Remove Insignia',1), -(6,3,22810,'Opening - No Text',1), -(6,3,24949,'Defensive State 2(DND)',1), -(6,3,34082,'Advantaged State(DND)',1), -(6,7,81,'Dodge',1), -(6,7,107,'Block',1), -(6,7,198,'One-Handed Maces',1), -(6,7,203,'Unarmed',1), -(6,7,204,'Defense',1), -(6,7,227,'Staves',1), -(6,7,331,'Healing Wave',1), -(6,7,403,'Lightning Bolt',1), -(6,7,522,'SPELLDEFENSE(DND)',1), -(6,7,669,'Language Orcish',1), -(6,7,670,'Language Taurahe',1), -(6,7,2382,'Generic',1), -(6,7,2479,'Honorless Target',1), -(6,7,3050,'Detect',1), -(6,7,3365,'Opening',1), -(6,7,6233,'Closing',1), -(6,7,6246,'Closing',1), -(6,7,6247,'Opening',1), -(6,7,6477,'Opening',1), -(6,7,6478,'Opening',1), -(6,7,6603,'Attack',1), -(6,7,7266,'Duel',1), -(6,7,7267,'Grovel',1), -(6,7,7355,'Stuck',1), -(6,7,8386,'Attacking',1), -(6,7,9077,'Leather',1), -(6,7,9078,'Cloth',1), -(6,7,9116,'Shield',1), -(6,7,9125,'Generic',1), -(6,7,20549,'War Stomp',1), -(6,7,20550,'Endurance',1), -(6,7,20551,'Nature Resistance',1), -(6,7,20552,'Cultivation',1), -(6,7,21651,'Opening',1), -(6,7,21652,'Closing',1), -(6,7,22027,'Remove Insignia',1), -(6,7,22810,'Opening - No Text',1), -(6,7,27763,'Totem',1), -(6,11,81,'Dodge',1), -(6,11,198,'One-Handed Maces',1), -(6,11,203,'Unarmed',1), -(6,11,204,'Defense',1), -(6,11,227,'Staves',1), -(6,11,522,'SPELLDEFENSE(DND)',1), -(6,11,669,'Language Orcish',1), -(6,11,670,'Language Taurahe',1), -(6,11,1178,'Bear Form(Passive)',0), -(6,11,2382,'Generic',1), -(6,11,2479,'Honorless Target',1), -(6,11,3025,'Cat Form(Passive)',0), -(6,11,3050,'Detect',1), -(6,11,3365,'Opening',1), -(6,11,5176,'Wrath',1), -(6,11,5185,'Healing Touch',1), -(6,11,5419,'Travel Form(Passive)',0), -(6,11,5420,'Tree of Life',0), -(6,11,5421,'Aquatic Form(Passive)',0), -(6,11,6233,'Closing',1), -(6,11,6246,'Closing',1), -(6,11,6247,'Opening',1), -(6,11,6477,'Opening',1), -(6,11,6478,'Opening',1), -(6,11,6603,'Attack',1), -(6,11,7266,'Duel',1), -(6,11,7267,'Grovel',1), -(6,11,7355,'Stuck',1), -(6,11,8386,'Attacking',1), -(6,11,9077,'Leather',1), -(6,11,9078,'Cloth',1), -(6,11,9125,'Generic',1), -(6,11,9635,'Dire Bear Form(Passive)',0), -(6,11,20549,'War Stomp',1), -(6,11,20550,'Endurance',1), -(6,11,20551,'Nature Resistance',1), -(6,11,20552,'Cultivation',1), -(6,11,21178,'Bear Form(Passive2)',0), -(6,11,21651,'Opening',1), -(6,11,21652,'Closing',1), -(6,11,22027,'Remove Insignia',1), -(6,11,22810,'Opening - No Text',1), -(6,11,24905,'Moonkin Form(Passive)',0), -(6,11,27764,'Fetish',1), -(6,11,33948,'Flight Form(Passive)',0), -(6,11,34123,'Tree of Life(Passive)',0), -(6,11,40121,'Swift Flight Form(Passive)',0), -(7,1,78,'Heroic Strike',1), -(7,1,81,'Dodge',1), -(7,1,107,'Block',1), -(7,1,198,'One-Handed Maces',1), -(7,1,201,'One-Handed Swords',1), -(7,1,203,'Unarmed',1), -(7,1,204,'Defense',1), -(7,1,522,'SPELLDEFENSE(DND)',1), -(7,1,668,'Language Common',1), -(7,1,1180,'Daggers',1), -(7,1,2382,'Generic',1), -(7,1,2457,'Battle Stance',1), -(7,1,2479,'Honorless Target',1), -(7,1,3050,'Detect',1), -(7,1,3365,'Opening',1), -(7,1,5301,'Defensive State(DND)',1), -(7,1,6233,'Closing',1), -(7,1,6246,'Closing',1), -(7,1,6247,'Opening',1), -(7,1,6477,'Opening',1), -(7,1,6478,'Opening',1), -(7,1,6603,'Attack',1), -(7,1,7266,'Duel',1), -(7,1,7267,'Grovel',1), -(7,1,7340,'Language Gnomish',1), -(7,1,7355,'Stuck',1), -(7,1,7376,'Defensive Stance Passive',0), -(7,1,7381,'Berserker Stance Passive',0), -(7,1,8386,'Attacking',1), -(7,1,8737,'Mail',1), -(7,1,9077,'Leather',1), -(7,1,9078,'Cloth',1), -(7,1,9116,'Shield',1), -(7,1,9125,'Generic',1), -(7,1,20589,'Escape Artist',1), -(7,1,20591,'Expansive Mind',1), -(7,1,20592,'Arcane Resistance',1), -(7,1,20593,'Engineering Specialization',1), -(7,1,21156,'Battle Stance Passive',0), -(7,1,21651,'Opening',1), -(7,1,21652,'Closing',1), -(7,1,22027,'Remove Insignia',1), -(7,1,22810,'Opening - No Text',1), -(7,1,32215,'Victorious State',1), -(7,4,81,'Dodge',1), -(7,4,203,'Unarmed',1), -(7,4,204,'Defense',1), -(7,4,522,'SPELLDEFENSE(DND)',1), -(7,4,668,'Language Common',1), -(7,4,1180,'Daggers',1), -(7,4,1752,'Sinister Strike',1), -(7,4,2098,'Eviscerate',1), -(7,4,2382,'Generic',1), -(7,4,2479,'Honorless Target',1), -(7,4,2567,'Thrown',1), -(7,4,2764,'Throw',1), -(7,4,3050,'Detect',1), -(7,4,3365,'Opening',1), -(7,4,6233,'Closing',1), -(7,4,6246,'Closing',1), -(7,4,6247,'Opening',1), -(7,4,6477,'Opening',1), -(7,4,6478,'Opening',1), -(7,4,6603,'Attack',1), -(7,4,7266,'Duel',1), -(7,4,7267,'Grovel',1), -(7,4,7340,'Language Gnomish',1), -(7,4,7355,'Stuck',1), -(7,4,8386,'Attacking',1), -(7,4,9077,'Leather',1), -(7,4,9078,'Cloth',1), -(7,4,9125,'Generic',1), -(7,4,16092,'Defensive State(DND)',1), -(7,4,20589,'Escape Artist',1), -(7,4,20591,'Expansive Mind',1), -(7,4,20592,'Arcane Resistance',1), -(7,4,20593,'Engineering Specialization',1), -(7,4,21184,'Rogue Passive(DND)',1), -(7,4,21651,'Opening',1), -(7,4,21652,'Closing',1), -(7,4,22027,'Remove Insignia',1), -(7,4,22810,'Opening - No Text',1), -(7,8,81,'Dodge',1), -(7,8,133,'Fireball',1), -(7,8,168,'Frost Armor',1), -(7,8,203,'Unarmed',1), -(7,8,204,'Defense',1), -(7,8,227,'Staves',1), -(7,8,522,'SPELLDEFENSE(DND)',1), -(7,8,668,'Language Common',1), -(7,8,2382,'Generic',1), -(7,8,2479,'Honorless Target',1), -(7,8,3050,'Detect',1), -(7,8,3365,'Opening',1), -(7,8,5009,'Wands',1), -(7,8,5019,'Shoot',1), -(7,8,6233,'Closing',1), -(7,8,6246,'Closing',1), -(7,8,6247,'Opening',1), -(7,8,6477,'Opening',1), -(7,8,6478,'Opening',1), -(7,8,6603,'Attack',1), -(7,8,7266,'Duel',1), -(7,8,7267,'Grovel',1), -(7,8,7340,'Language Gnomish',1), -(7,8,7355,'Stuck',1), -(7,8,8386,'Attacking',1), -(7,8,9078,'Cloth',1), -(7,8,9125,'Generic',1), -(7,8,20589,'Escape Artist',1), -(7,8,20591,'Expansive Mind',1), -(7,8,20592,'Arcane Resistance',1), -(7,8,20593,'Engineering Specialization',1), -(7,8,21651,'Opening',1), -(7,8,21652,'Closing',1), -(7,8,22027,'Remove Insignia',1), -(7,8,22810,'Opening - No Text',1), -(7,9,81,'Dodge',1), -(7,9,203,'Unarmed',1), -(7,9,204,'Defense',1), -(7,9,522,'SPELLDEFENSE(DND)',1), -(7,9,668,'Language Common',1), -(7,9,686,'Shadow Bolt',1), -(7,9,687,'Demon Skin',1), -(7,9,1180,'Daggers',1), -(7,9,2382,'Generic',1), -(7,9,2479,'Honorless Target',1), -(7,9,3050,'Detect',1), -(7,9,3365,'Opening',1), -(7,9,5009,'Wands',1), -(7,9,5019,'Shoot',1), -(7,9,6233,'Closing',1), -(7,9,6246,'Closing',1), -(7,9,6247,'Opening',1), -(7,9,6477,'Opening',1), -(7,9,6478,'Opening',1), -(7,9,6603,'Attack',1), -(7,9,7266,'Duel',1), -(7,9,7267,'Grovel',1), -(7,9,7340,'Language Gnomish',1), -(7,9,7355,'Stuck',1), -(7,9,8386,'Attacking',1), -(7,9,9078,'Cloth',1), -(7,9,9125,'Generic',1), -(7,9,20589,'Escape Artist',1), -(7,9,20591,'Expansive Mind',1), -(7,9,20592,'Arcane Resistance',1), -(7,9,20593,'Engineering Specialization',1), -(7,9,21651,'Opening',1), -(7,9,21652,'Closing',1), -(7,9,22027,'Remove Insignia',1), -(7,9,22810,'Opening - No Text',1), -(8,1,78,'Heroic Strike',1), -(8,1,81,'Dodge',1), -(8,1,107,'Block',1), -(8,1,196,'One-Handed Axes',1), -(8,1,203,'Unarmed',1), -(8,1,204,'Defense',1), -(8,1,522,'SPELLDEFENSE(DND)',1), -(8,1,669,'Language Orcish',1), -(8,1,1180,'Daggers',1), -(8,1,2382,'Generic',1), -(8,1,2457,'Battle Stance',1), -(8,1,2479,'Honorless Target',1), -(8,1,2567,'Thrown',1), -(8,1,2764,'Throw',1), -(8,1,3050,'Detect',1), -(8,1,3365,'Opening',1), -(8,1,5301,'Defensive State(DND)',1), -(8,1,6233,'Closing',1), -(8,1,6246,'Closing',1), -(8,1,6247,'Opening',1), -(8,1,6477,'Opening',1), -(8,1,6478,'Opening',1), -(8,1,6603,'Attack',1), -(8,1,7266,'Duel',1), -(8,1,7267,'Grovel',1), -(8,1,7341,'Language Troll',1), -(8,1,7355,'Stuck',1), -(8,1,7376,'Defensive Stance Passive',0), -(8,1,7381,'Berserker Stance Passive',0), -(8,1,8386,'Attacking',1), -(8,1,8737,'Mail',1), -(8,1,9077,'Leather',1), -(8,1,9078,'Cloth',1), -(8,1,9116,'Shield',1), -(8,1,9125,'Generic',1), -(8,1,20555,'Regeneration',1), -(8,1,20557,'Beast Slaying',1), -(8,1,20558,'Throwing Specialization',1), -(8,1,21156,'Battle Stance Passive',0), -(8,1,21651,'Opening',1), -(8,1,21652,'Closing',1), -(8,1,22027,'Remove Insignia',1), -(8,1,22810,'Opening - No Text',1), -(8,1,26290,'Bow Specialization',1), -(8,1,26296,'Berserking',1), -(8,1,32215,'Victorious State',1), -(8,3,75,'Auto Shot',1), -(8,3,81,'Dodge',1), -(8,3,196,'One-Handed Axes',1), -(8,3,203,'Unarmed',1), -(8,3,204,'Defense',1), -(8,3,264,'Bows',1), -(8,3,522,'SPELLDEFENSE(DND)',1), -(8,3,669,'Language Orcish',1), -(8,3,2382,'Generic',1), -(8,3,2479,'Honorless Target',1), -(8,3,2973,'Raptor Strike',1), -(8,3,3050,'Detect',1), -(8,3,3365,'Opening',1), -(8,3,6233,'Closing',1), -(8,3,6246,'Closing',1), -(8,3,6247,'Opening',1), -(8,3,6477,'Opening',1), -(8,3,6478,'Opening',1), -(8,3,6603,'Attack',1), -(8,3,7266,'Duel',1), -(8,3,7267,'Grovel',1), -(8,3,7341,'Language Troll',1), -(8,3,7355,'Stuck',1), -(8,3,8386,'Attacking',1), -(8,3,9077,'Leather',1), -(8,3,9078,'Cloth',1), -(8,3,9125,'Generic',1), -(8,3,13358,'Defensive State(DND)',1), -(8,3,20554,'Berserking',1), -(8,3,20555,'Regeneration',1), -(8,3,20557,'Beast Slaying',1), -(8,3,20558,'Throwing Specialization',1), -(8,3,21651,'Opening',1), -(8,3,21652,'Closing',1), -(8,3,22027,'Remove Insignia',1), -(8,3,22810,'Opening - No Text',1), -(8,3,24949,'Defensive State 2(DND)',1), -(8,3,26290,'Bow Specialization',1), -(8,3,34082,'Advantaged State(DND)',1), -(8,4,81,'Dodge',1), -(8,4,203,'Unarmed',1), -(8,4,204,'Defense',1), -(8,4,522,'SPELLDEFENSE(DND)',1), -(8,4,669,'Language Orcish',1), -(8,4,1180,'Daggers',1), -(8,4,1752,'Sinister Strike',1), -(8,4,2098,'Eviscerate',1), -(8,4,2382,'Generic',1), -(8,4,2479,'Honorless Target',1), -(8,4,2567,'Thrown',1), -(8,4,2764,'Throw',1), -(8,4,3050,'Detect',1), -(8,4,3365,'Opening',1), -(8,4,6233,'Closing',1), -(8,4,6246,'Closing',1), -(8,4,6247,'Opening',1), -(8,4,6477,'Opening',1), -(8,4,6478,'Opening',1), -(8,4,6603,'Attack',1), -(8,4,7266,'Duel',1), -(8,4,7267,'Grovel',1), -(8,4,7341,'Language Troll',1), -(8,4,7355,'Stuck',1), -(8,4,8386,'Attacking',1), -(8,4,9077,'Leather',1), -(8,4,9078,'Cloth',1), -(8,4,9125,'Generic',1), -(8,4,16092,'Defensive State(DND)',1), -(8,4,20555,'Regeneration',1), -(8,4,20557,'Beast Slaying',1), -(8,4,20558,'Throwing Specialization',1), -(8,4,21184,'Rogue Passive(DND)',1), -(8,4,21651,'Opening',1), -(8,4,21652,'Closing',1), -(8,4,22027,'Remove Insignia',1), -(8,4,22810,'Opening - No Text',1), -(8,4,26290,'Bow Specialization',1), -(8,4,26297,'Berserking',1), -(8,5,81,'Dodge',1), -(8,5,198,'One-Handed Maces',1), -(8,5,203,'Unarmed',1), -(8,5,204,'Defense',1), -(8,5,522,'SPELLDEFENSE(DND)',1), -(8,5,585,'Smite',1), -(8,5,669,'Language Orcish',1), -(8,5,2050,'Lesser Heal',1), -(8,5,2382,'Generic',1), -(8,5,2479,'Honorless Target',1), -(8,5,3050,'Detect',1), -(8,5,3365,'Opening',1), -(8,5,5009,'Wands',1), -(8,5,5019,'Shoot',1), -(8,5,6233,'Closing',1), -(8,5,6246,'Closing',1), -(8,5,6247,'Opening',1), -(8,5,6477,'Opening',1), -(8,5,6478,'Opening',1), -(8,5,6603,'Attack',1), -(8,5,7266,'Duel',1), -(8,5,7267,'Grovel',1), -(8,5,7341,'Language Troll',1), -(8,5,7355,'Stuck',1), -(8,5,8386,'Attacking',1), -(8,5,9078,'Cloth',1), -(8,5,9125,'Generic',1), -(8,5,20554,'Berserking',1), -(8,5,20555,'Regeneration',1), -(8,5,20557,'Beast Slaying',1), -(8,5,20558,'Throwing Specialization',1), -(8,5,21651,'Opening',1), -(8,5,21652,'Closing',1), -(8,5,22027,'Remove Insignia',1), -(8,5,22810,'Opening - No Text',1), -(8,5,26290,'Bow Specialization',1), -(8,7,81,'Dodge',1), -(8,7,107,'Block',1), -(8,7,198,'One-Handed Maces',1), -(8,7,203,'Unarmed',1), -(8,7,204,'Defense',1), -(8,7,227,'Staves',1), -(8,7,331,'Healing Wave',1), -(8,7,403,'Lightning Bolt',1), -(8,7,522,'SPELLDEFENSE(DND)',1), -(8,7,669,'Language Orcish',1), -(8,7,2382,'Generic',1), -(8,7,2479,'Honorless Target',1), -(8,7,3050,'Detect',1), -(8,7,3365,'Opening',1), -(8,7,6233,'Closing',1), -(8,7,6246,'Closing',1), -(8,7,6247,'Opening',1), -(8,7,6477,'Opening',1), -(8,7,6478,'Opening',1), -(8,7,6603,'Attack',1), -(8,7,7266,'Duel',1), -(8,7,7267,'Grovel',1), -(8,7,7341,'Language Troll',1), -(8,7,7355,'Stuck',1), -(8,7,8386,'Attacking',1), -(8,7,9077,'Leather',1), -(8,7,9078,'Cloth',1), -(8,7,9116,'Shield',1), -(8,7,9125,'Generic',1), -(8,7,20554,'Berserking',1), -(8,7,20555,'Regeneration',1), -(8,7,20557,'Beast Slaying',1), -(8,7,20558,'Throwing Specialization',1), -(8,7,21651,'Opening',1), -(8,7,21652,'Closing',1), -(8,7,22027,'Remove Insignia',1), -(8,7,22810,'Opening - No Text',1), -(8,7,26290,'Bow Specialization',1), -(8,7,27763,'Totem',1), -(8,8,81,'Dodge',1), -(8,8,133,'Fireball',1), -(8,8,168,'Frost Armor',1), -(8,8,203,'Unarmed',1), -(8,8,204,'Defense',1), -(8,8,227,'Staves',1), -(8,8,522,'SPELLDEFENSE(DND)',1), -(8,8,669,'Language Orcish',1), -(8,8,2382,'Generic',1), -(8,8,2479,'Honorless Target',1), -(8,8,3050,'Detect',1), -(8,8,3365,'Opening',1), -(8,8,5009,'Wands',1), -(8,8,5019,'Shoot',1), -(8,8,6233,'Closing',1), -(8,8,6246,'Closing',1), -(8,8,6247,'Opening',1), -(8,8,6477,'Opening',1), -(8,8,6478,'Opening',1), -(8,8,6603,'Attack',1), -(8,8,7266,'Duel',1), -(8,8,7267,'Grovel',1), -(8,8,7341,'Language Troll',1), -(8,8,7355,'Stuck',1), -(8,8,8386,'Attacking',1), -(8,8,9078,'Cloth',1), -(8,8,9125,'Generic',1), -(8,8,20554,'Berserking',1), -(8,8,20555,'Regeneration',1), -(8,8,20557,'Beast Slaying',1), -(8,8,20558,'Throwing Specialization',1), -(8,8,21651,'Opening',1), -(8,8,21652,'Closing',1), -(8,8,22027,'Remove Insignia',1), -(8,8,22810,'Opening - No Text',1), -(8,8,26290,'Bow Specialization',1), -(10,2,81,'Dodge',1), -(10,2,107,'Block',1), -(10,2,201,'One-Handed Swords',1), -(10,2,202,'Two-Handed Swords',1), -(10,2,203,'Unarmed',1), -(10,2,204,'Defense',1), -(10,2,522,'SPELLDEFENSE(DND)',1), -(10,2,635,'Holy Light',1), -(10,2,669,'Language Orcish',1), -(10,2,813,'Language Thalassian',1), -(10,2,822,'Magic Resistance',1), -(10,2,2382,'Generic',1), -(10,2,2479,'Honorless Target',1), -(10,2,3050,'Detect',1), -(10,2,3365,'Opening',1), -(10,2,6233,'Closing',1), -(10,2,6246,'Closing',1), -(10,2,6247,'Opening',1), -(10,2,6477,'Opening',1), -(10,2,6478,'Opening',1), -(10,2,6603,'Attack',1), -(10,2,7266,'Duel',1), -(10,2,7267,'Grovel',1), -(10,2,7355,'Stuck',1), -(10,2,8386,'Attacking',1), -(10,2,8737,'Mail',1), -(10,2,9077,'Leather',1), -(10,2,9078,'Cloth',1), -(10,2,9116,'Shield',1), -(10,2,9125,'Generic',1), -(10,2,21084,'Seal of Righteousness',1), -(10,2,21651,'Opening',1), -(10,2,21652,'Closing',1), -(10,2,22027,'Remove Insignia',1), -(10,2,22810,'Opening - No Text',1), -(10,2,27762,'Libram',1), -(10,2,28730,'Arcane Torrent',1), -(10,2,28734,'Mana Tap',1), -(10,2,28877,'Arcane Affinity',1), -(10,3,75,'Auto Shot',1), -(10,3,81,'Dodge',1), -(10,3,203,'Unarmed',1), -(10,3,204,'Defense',1), -(10,3,264,'Bows',1), -(10,3,522,'SPELLDEFENSE(DND)',1), -(10,3,669,'Language Orcish',1), -(10,3,813,'Language Thalassian',1), -(10,3,822,'Magic Resistance',1), -(10,3,1180,'Daggers',1), -(10,3,2382,'Generic',1), -(10,3,2479,'Honorless Target',1), -(10,3,2973,'Raptor Strike',1), -(10,3,3050,'Detect',1), -(10,3,3365,'Opening',1), -(10,3,6233,'Closing',1), -(10,3,6246,'Closing',1), -(10,3,6247,'Opening',1), -(10,3,6477,'Opening',1), -(10,3,6478,'Opening',1), -(10,3,6603,'Attack',1), -(10,3,7266,'Duel',1), -(10,3,7267,'Grovel',1), -(10,3,7355,'Stuck',1), -(10,3,8386,'Attacking',1), -(10,3,9077,'Leather',1), -(10,3,9078,'Cloth',1), -(10,3,9125,'Generic',1), -(10,3,13358,'Defensive State(DND)',1), -(10,3,21651,'Opening',1), -(10,3,21652,'Closing',1), -(10,3,22027,'Remove Insignia',1), -(10,3,22810,'Opening - No Text',1), -(10,3,24949,'Defensive State 2(DND)',1), -(10,3,28730,'Arcane Torrent',1), -(10,3,28734,'Mana Tap',1), -(10,3,28877,'Arcane Affinity',1), -(10,3,34082,'Advantaged State(DND)',1), -(10,4,81,'Dodge',1), -(10,4,203,'Unarmed',1), -(10,4,204,'Defense',1), -(10,4,522,'SPELLDEFENSE(DND)',1), -(10,4,669,'Language Orcish',1), -(10,4,813,'Language Thalassian',1), -(10,4,822,'Magic Resistance',1), -(10,4,1180,'Daggers',1), -(10,4,1752,'Sinister Strike',1), -(10,4,2098,'Eviscerate',1), -(10,4,2382,'Generic',1), -(10,4,2479,'Honorless Target',1), -(10,4,2567,'Thrown',1), -(10,4,2764,'Throw',1), -(10,4,3050,'Detect',1), -(10,4,3365,'Opening',1), -(10,4,6233,'Closing',1), -(10,4,6246,'Closing',1), -(10,4,6247,'Opening',1), -(10,4,6477,'Opening',1), -(10,4,6478,'Opening',1), -(10,4,6603,'Attack',1), -(10,4,7266,'Duel',1), -(10,4,7267,'Grovel',1), -(10,4,7355,'Stuck',1), -(10,4,8386,'Attacking',1), -(10,4,9077,'Leather',1), -(10,4,9078,'Cloth',1), -(10,4,9125,'Generic',1), -(10,4,16092,'Defensive State(DND)',1), -(10,4,21184,'Rogue Passive(DND)',1), -(10,4,21651,'Opening',1), -(10,4,21652,'Closing',1), -(10,4,22027,'Remove Insignia',1), -(10,4,22810,'Opening - No Text',1), -(10,4,25046,'Arcane Torrent',1), -(10,4,28734,'Mana Tap',1), -(10,4,28877,'Arcane Affinity',1), -(10,5,81,'Dodge',1), -(10,5,198,'One-Handed Maces',1), -(10,5,203,'Unarmed',1), -(10,5,204,'Defense',1), -(10,5,522,'SPELLDEFENSE(DND)',1), -(10,5,585,'Smite',1), -(10,5,669,'Language Orcish',1), -(10,5,813,'Language Thalassian',1), -(10,5,822,'Magic Resistance',1), -(10,5,2050,'Lesser Heal',1), -(10,5,2382,'Generic',1), -(10,5,2479,'Honorless Target',1), -(10,5,3050,'Detect',1), -(10,5,3365,'Opening',1), -(10,5,5009,'Wands',1), -(10,5,5019,'Shoot',1), -(10,5,6233,'Closing',1), -(10,5,6246,'Closing',1), -(10,5,6247,'Opening',1), -(10,5,6477,'Opening',1), -(10,5,6478,'Opening',1), -(10,5,6603,'Attack',1), -(10,5,7266,'Duel',1), -(10,5,7267,'Grovel',1), -(10,5,7355,'Stuck',1), -(10,5,8386,'Attacking',1), -(10,5,9078,'Cloth',1), -(10,5,9125,'Generic',1), -(10,5,21651,'Opening',1), -(10,5,21652,'Closing',1), -(10,5,22027,'Remove Insignia',1), -(10,5,22810,'Opening - No Text',1), -(10,5,28730,'Arcane Torrent',1), -(10,5,28734,'Mana Tap',1), -(10,5,28877,'Arcane Affinity',1), -(10,8,81,'Dodge',1), -(10,8,133,'Fireball',1), -(10,8,168,'Frost Armor',1), -(10,8,203,'Unarmed',1), -(10,8,204,'Defense',1), -(10,8,227,'Staves',1), -(10,8,522,'SPELLDEFENSE(DND)',1), -(10,8,669,'Language Orcish',1), -(10,8,813,'Language Thalassian',1), -(10,8,822,'Magic Resistance',1), -(10,8,2382,'Generic',1), -(10,8,2479,'Honorless Target',1), -(10,8,3050,'Detect',1), -(10,8,3365,'Opening',1), -(10,8,5009,'Wands',1), -(10,8,5019,'Shoot',1), -(10,8,6233,'Closing',1), -(10,8,6246,'Closing',1), -(10,8,6247,'Opening',1), -(10,8,6477,'Opening',1), -(10,8,6478,'Opening',1), -(10,8,6603,'Attack',1), -(10,8,7266,'Duel',1), -(10,8,7267,'Grovel',1), -(10,8,7355,'Stuck',1), -(10,8,8386,'Attacking',1), -(10,8,9078,'Cloth',1), -(10,8,9125,'Generic',1), -(10,8,21651,'Opening',1), -(10,8,21652,'Closing',1), -(10,8,22027,'Remove Insignia',1), -(10,8,22810,'Opening - No Text',1), -(10,8,28730,'Arcane Torrent',1), -(10,8,28734,'Mana Tap',1), -(10,8,28877,'Arcane Affinity',1), -(10,9,81,'Dodge',1), -(10,9,203,'Unarmed',1), -(10,9,204,'Defense',1), -(10,9,522,'SPELLDEFENSE(DND)',1), -(10,9,669,'Language Orcish',1), -(10,9,686,'Shadow Bolt',1), -(10,9,687,'Demon Skin',1), -(10,9,813,'Language Thalassian',1), -(10,9,822,'Magic Resistance',1), -(10,9,1180,'Daggers',1), -(10,9,2382,'Generic',1), -(10,9,2479,'Honorless Target',1), -(10,9,3050,'Detect',1), -(10,9,3365,'Opening',1), -(10,9,5009,'Wands',1), -(10,9,5019,'Shoot',1), -(10,9,6233,'Closing',1), -(10,9,6246,'Closing',1), -(10,9,6247,'Opening',1), -(10,9,6477,'Opening',1), -(10,9,6478,'Opening',1), -(10,9,6603,'Attack',1), -(10,9,7266,'Duel',1), -(10,9,7267,'Grovel',1), -(10,9,7355,'Stuck',1), -(10,9,8386,'Attacking',1), -(10,9,9078,'Cloth',1), -(10,9,9125,'Generic',1), -(10,9,21651,'Opening',1), -(10,9,21652,'Closing',1), -(10,9,22027,'Remove Insignia',1), -(10,9,22810,'Opening - No Text',1), -(10,9,28730,'Arcane Torrent',1), -(10,9,28734,'Mana Tap',1), -(10,9,28877,'Arcane Affinity',1), -(11,1,78,'Heroic Strike',1), -(11,1,81,'Dodge',1), -(11,1,107,'Block',1), -(11,1,198,'One-Handed Maces',1), -(11,1,201,'One-Handed Swords',1), -(11,1,202,'Two-Handed Swords',1), -(11,1,203,'Unarmed',1), -(11,1,204,'Defense',1), -(11,1,522,'SPELLDEFENSE(DND)',1), -(11,1,668,'Language Common',1), -(11,1,2382,'Generic',1), -(11,1,2457,'Battle Stance',1), -(11,1,2479,'Honorless Target',1), -(11,1,3050,'Detect',1), -(11,1,3365,'Opening',1), -(11,1,5301,'Defensive State(DND)',1), -(11,1,6233,'Closing',1), -(11,1,6246,'Closing',1), -(11,1,6247,'Opening',1), -(11,1,6477,'Opening',1), -(11,1,6478,'Opening',1), -(11,1,6562,'Heroic Presence',1), -(11,1,6603,'Attack',1), -(11,1,7266,'Duel',1), -(11,1,7267,'Grovel',1), -(11,1,7355,'Stuck',1), -(11,1,7376,'Defensive Stance Passive',0), -(11,1,7381,'Berserker Stance Passive',0), -(11,1,8386,'Attacking',1), -(11,1,8737,'Mail',1), -(11,1,9077,'Leather',1), -(11,1,9078,'Cloth',1), -(11,1,9116,'Shield',1), -(11,1,9125,'Generic',1), -(11,1,20579,'Shadow Resistance',1), -(11,1,21156,'Battle Stance Passive',0), -(11,1,21651,'Opening',1), -(11,1,21652,'Closing',1), -(11,1,22027,'Remove Insignia',1), -(11,1,22810,'Opening - No Text',1), -(11,1,28875,'Gemcutting',1), -(11,1,28880,'Gift of the Naaru',1), -(11,1,29932,'Language Draenei',1), -(11,1,32215,'Victorious State',1), -(11,2,81,'Dodge',1), -(11,2,107,'Block',1), -(11,2,198,'One-Handed Maces',1), -(11,2,199,'Two-Handed Maces',1), -(11,2,203,'Unarmed',1), -(11,2,204,'Defense',1), -(11,2,522,'SPELLDEFENSE(DND)',1), -(11,2,635,'Holy Light',1), -(11,2,668,'Language Common',1), -(11,2,2382,'Generic',1), -(11,2,2479,'Honorless Target',1), -(11,2,3050,'Detect',1), -(11,2,3365,'Opening',1), -(11,2,6233,'Closing',1), -(11,2,6246,'Closing',1), -(11,2,6247,'Opening',1), -(11,2,6477,'Opening',1), -(11,2,6478,'Opening',1), -(11,2,6562,'Heroic Presence',1), -(11,2,6603,'Attack',1), -(11,2,7266,'Duel',1), -(11,2,7267,'Grovel',1), -(11,2,7355,'Stuck',1), -(11,2,8386,'Attacking',1), -(11,2,8737,'Mail',1), -(11,2,9077,'Leather',1), -(11,2,9078,'Cloth',1), -(11,2,9116,'Shield',1), -(11,2,9125,'Generic',1), -(11,2,21084,'Seal of Righteousness',1), -(11,2,20579,'Shadow Resistance',1), -(11,2,21651,'Opening',1), -(11,2,21652,'Closing',1), -(11,2,22027,'Remove Insignia',1), -(11,2,22810,'Opening - No Text',1), -(11,2,27762,'Libram',1), -(11,2,28875,'Gemcutting',1), -(11,2,28880,'Gift of the Naaru',1), -(11,2,29932,'Language Draenei',1), -(11,3,75,'Auto Shot',1), -(11,3,81,'Dodge',1), -(11,3,201,'One-Handed Swords',1), -(11,3,203,'Unarmed',1), -(11,3,204,'Defense',1), -(11,3,522,'SPELLDEFENSE(DND)',1), -(11,3,668,'Language Common',1), -(11,3,2382,'Generic',1), -(11,3,2479,'Honorless Target',1), -(11,3,2973,'Raptor Strike',1), -(11,3,3050,'Detect',1), -(11,3,3365,'Opening',1), -(11,3,5011,'Crossbows',1), -(11,3,6233,'Closing',1), -(11,3,6246,'Closing',1), -(11,3,6247,'Opening',1), -(11,3,6477,'Opening',1), -(11,3,6478,'Opening',1), -(11,3,6562,'Heroic Presence',1), -(11,3,6603,'Attack',1), -(11,3,7266,'Duel',1), -(11,3,7267,'Grovel',1), -(11,3,7355,'Stuck',1), -(11,3,8386,'Attacking',1), -(11,3,9077,'Leather',1), -(11,3,9078,'Cloth',1), -(11,3,9125,'Generic',1), -(11,3,13358,'Defensive State(DND)',1), -(11,3,20579,'Shadow Resistance',1), -(11,3,21651,'Opening',1), -(11,3,21652,'Closing',1), -(11,3,22027,'Remove Insignia',1), -(11,3,22810,'Opening - No Text',1), -(11,3,24949,'Defensive State 2(DND)',1), -(11,3,28875,'Gemcutting',1), -(11,3,28880,'Gift of the Naaru',1), -(11,3,29932,'Language Draenei',1), -(11,3,34082,'Advantaged State(DND)',1), -(11,5,81,'Dodge',1), -(11,5,198,'One-Handed Maces',1), -(11,5,203,'Unarmed',1), -(11,5,204,'Defense',1), -(11,5,522,'SPELLDEFENSE(DND)',1), -(11,5,585,'Smite',1), -(11,5,668,'Language Common',1), -(11,5,2050,'Lesser Heal',1), -(11,5,2382,'Generic',1), -(11,5,2479,'Honorless Target',1), -(11,5,3050,'Detect',1), -(11,5,3365,'Opening',1), -(11,5,5009,'Wands',1), -(11,5,5019,'Shoot',1), -(11,5,6233,'Closing',1), -(11,5,6246,'Closing',1), -(11,5,6247,'Opening',1), -(11,5,6477,'Opening',1), -(11,5,6478,'Opening',1), -(11,5,6603,'Attack',1), -(11,5,7266,'Duel',1), -(11,5,7267,'Grovel',1), -(11,5,7355,'Stuck',1), -(11,5,8386,'Attacking',1), -(11,5,9078,'Cloth',1), -(11,5,9125,'Generic',1), -(11,5,20579,'Shadow Resistance',1), -(11,5,21651,'Opening',1), -(11,5,21652,'Closing',1), -(11,5,22027,'Remove Insignia',1), -(11,5,22810,'Opening - No Text',1), -(11,5,28875,'Gemcutting',1), -(11,5,28878,'Inspiring Presence',1), -(11,5,28880,'Gift of the Naaru',1), -(11,5,29932,'Language Draenei',1), -(11,7,81,'Dodge',1), -(11,7,107,'Block',1), -(11,7,198,'One-Handed Maces',1), -(11,7,203,'Unarmed',1), -(11,7,204,'Defense',1), -(11,7,227,'Staves',1), -(11,7,331,'Healing Wave',1), -(11,7,403,'Lightning Bolt',1), -(11,7,522,'SPELLDEFENSE(DND)',1), -(11,7,668,'Language Common',1), -(11,7,2382,'Generic',1), -(11,7,2479,'Honorless Target',1), -(11,7,3050,'Detect',1), -(11,7,3365,'Opening',1), -(11,7,6233,'Closing',1), -(11,7,6246,'Closing',1), -(11,7,6247,'Opening',1), -(11,7,6477,'Opening',1), -(11,7,6478,'Opening',1), -(11,7,6603,'Attack',1), -(11,7,7266,'Duel',1), -(11,7,7267,'Grovel',1), -(11,7,7355,'Stuck',1), -(11,7,8386,'Attacking',1), -(11,7,9077,'Leather',1), -(11,7,9078,'Cloth',1), -(11,7,9116,'Shield',1), -(11,7,9125,'Generic',1), -(11,7,20579,'Shadow Resistance',1), -(11,7,21651,'Opening',1), -(11,7,21652,'Closing',1), -(11,7,22027,'Remove Insignia',1), -(11,7,22810,'Opening - No Text',1), -(11,7,27763,'Totem',1), -(11,7,28875,'Gemcutting',1), -(11,7,28878,'Inspiring Presence',1), -(11,7,28880,'Gift of the Naaru',1), -(11,7,29932,'Language Draenei',1), -(11,8,81,'Dodge',1), -(11,8,133,'Fireball',1), -(11,8,168,'Frost Armor',1), -(11,8,203,'Unarmed',1), -(11,8,204,'Defense',1), -(11,8,227,'Staves',1), -(11,8,522,'SPELLDEFENSE(DND)',1), -(11,8,668,'Language Common',1), -(11,8,2382,'Generic',1), -(11,8,2479,'Honorless Target',1), -(11,8,3050,'Detect',1), -(11,8,3365,'Opening',1), -(11,8,5009,'Wands',1), -(11,8,5019,'Shoot',1), -(11,8,6233,'Closing',1), -(11,8,6246,'Closing',1), -(11,8,6247,'Opening',1), -(11,8,6477,'Opening',1), -(11,8,6478,'Opening',1), -(11,8,6603,'Attack',1), -(11,8,7266,'Duel',1), -(11,8,7267,'Grovel',1), -(11,8,7355,'Stuck',1), -(11,8,8386,'Attacking',1), -(11,8,9078,'Cloth',1), -(11,8,9125,'Generic',1), -(11,8,20579,'Shadow Resistance',1), -(11,8,21651,'Opening',1), -(11,8,21652,'Closing',1), -(11,8,22027,'Remove Insignia',1), -(11,8,22810,'Opening - No Text',1), -(11,8,28875,'Gemcutting',1), -(11,8,28878,'Inspiring Presence',1), -(11,8,28880,'Gift of the Naaru',1), -(11,8,29932,'Language Draenei',1); -/*!40000 ALTER TABLE `playercreateinfo_spell` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `prospecting_loot_template` --- - -DROP TABLE IF EXISTS `prospecting_loot_template`; -CREATE TABLE `prospecting_loot_template` ( - `entry` mediumint(8) unsigned NOT NULL default '0', - `item` mediumint(8) unsigned NOT NULL default '0', - `ChanceOrQuestChance` float NOT NULL default '100', - `groupid` tinyint(3) unsigned NOT NULL default '0', - `mincountOrRef` mediumint(9) NOT NULL default '1', - `maxcount` tinyint(3) unsigned NOT NULL default '1', - `lootcondition` tinyint(3) unsigned NOT NULL default '0', - `condition_value1` mediumint(8) unsigned NOT NULL default '0', - `condition_value2` mediumint(8) unsigned NOT NULL default '0', - PRIMARY KEY (`entry`,`item`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Loot System'; - --- --- Dumping data for table `prospecting_loot_template` --- - -LOCK TABLES `prospecting_loot_template` WRITE; -/*!40000 ALTER TABLE `prospecting_loot_template` DISABLE KEYS */; -/*!40000 ALTER TABLE `prospecting_loot_template` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `quest_end_scripts` --- - -DROP TABLE IF EXISTS `quest_end_scripts`; -CREATE TABLE `quest_end_scripts` ( - `id` mediumint(8) unsigned NOT NULL default '0', - `delay` int(10) unsigned NOT NULL default '0', - `command` mediumint(8) unsigned NOT NULL default '0', - `datalong` mediumint(8) unsigned NOT NULL default '0', - `datalong2` int(10) unsigned NOT NULL default '0', - `datatext` text NOT NULL, - `x` float NOT NULL default '0', - `y` float NOT NULL default '0', - `z` float NOT NULL default '0', - `o` float NOT NULL default '0' -) ENGINE=MyISAM DEFAULT CHARSET=utf8; - --- --- Dumping data for table `quest_end_scripts` --- - -LOCK TABLES `quest_end_scripts` WRITE; -/*!40000 ALTER TABLE `quest_end_scripts` DISABLE KEYS */; -/*!40000 ALTER TABLE `quest_end_scripts` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `quest_start_scripts` --- - -DROP TABLE IF EXISTS `quest_start_scripts`; -CREATE TABLE `quest_start_scripts` ( - `id` mediumint(8) unsigned NOT NULL default '0', - `delay` int(10) unsigned NOT NULL default '0', - `command` mediumint(8) unsigned NOT NULL default '0', - `datalong` mediumint(8) unsigned NOT NULL default '0', - `datalong2` int(10) unsigned NOT NULL default '0', - `datatext` text NOT NULL, - `x` float NOT NULL default '0', - `y` float NOT NULL default '0', - `z` float NOT NULL default '0', - `o` float NOT NULL default '0' -) ENGINE=MyISAM DEFAULT CHARSET=utf8; - --- --- Dumping data for table `quest_start_scripts` --- - -LOCK TABLES `quest_start_scripts` WRITE; -/*!40000 ALTER TABLE `quest_start_scripts` DISABLE KEYS */; -/*!40000 ALTER TABLE `quest_start_scripts` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `quest_mail_loot_template` --- - -DROP TABLE IF EXISTS `quest_mail_loot_template`; -CREATE TABLE `quest_mail_loot_template` ( - `entry` mediumint(8) unsigned NOT NULL default '0', - `item` mediumint(8) unsigned NOT NULL default '0', - `ChanceOrQuestChance` float NOT NULL default '100', - `groupid` tinyint(3) unsigned NOT NULL default '0', - `mincountOrRef` mediumint(9) NOT NULL default '1', - `maxcount` tinyint(3) unsigned NOT NULL default '1', - `lootcondition` tinyint(3) unsigned NOT NULL default '0', - `condition_value1` mediumint(8) unsigned NOT NULL default '0', - `condition_value2` mediumint(8) unsigned NOT NULL default '0', - PRIMARY KEY (`entry`,`item`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Loot System'; - --- --- Dumping data for table `quest_mail_loot_template` --- - -LOCK TABLES `quest_mail_loot_template` WRITE; -/*!40000 ALTER TABLE `quest_mail_loot_template` DISABLE KEYS */; -/*!40000 ALTER TABLE `quest_mail_loot_template` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `quest_template` --- - -DROP TABLE IF EXISTS `quest_template`; -CREATE TABLE `quest_template` ( - `entry` mediumint(8) unsigned NOT NULL default '0', - `ZoneOrSort` smallint(6) NOT NULL default '0', - `SkillOrClass` smallint(6) NOT NULL default '0', - `MinLevel` tinyint(3) unsigned NOT NULL default '0', - `QuestLevel` tinyint(3) unsigned NOT NULL default '0', - `Type` smallint(5) unsigned NOT NULL default '0', - `RequiredRaces` smallint(5) unsigned NOT NULL default '0', - `RequiredSkillValue` smallint(5) unsigned NOT NULL default '0', - `RepObjectiveFaction` smallint(5) unsigned NOT NULL default '0', - `RepObjectiveValue` mediumint(9) NOT NULL default '0', - `RequiredMinRepFaction` smallint(5) unsigned NOT NULL default '0', - `RequiredMinRepValue` mediumint(9) NOT NULL default '0', - `RequiredMaxRepFaction` smallint(5) unsigned NOT NULL default '0', - `RequiredMaxRepValue` mediumint(9) NOT NULL default '0', - `SuggestedPlayers` tinyint(3) unsigned NOT NULL default '0', - `LimitTime` int(10) unsigned NOT NULL default '0', - `QuestFlags` smallint(5) unsigned NOT NULL default '0', - `SpecialFlags` tinyint(3) unsigned NOT NULL default '0', - `CharTitleId` tinyint(3) unsigned NOT NULL default '0', - `PrevQuestId` mediumint(9) NOT NULL default '0', - `NextQuestId` mediumint(9) NOT NULL default '0', - `ExclusiveGroup` mediumint(9) NOT NULL default '0', - `NextQuestInChain` mediumint(8) unsigned NOT NULL default '0', - `SrcItemId` mediumint(8) unsigned NOT NULL default '0', - `SrcItemCount` tinyint(3) unsigned NOT NULL default '0', - `SrcSpell` mediumint(8) unsigned NOT NULL default '0', - `Title` text, - `Details` text, - `Objectives` text, - `OfferRewardText` text, - `RequestItemsText` text, - `EndText` text, - `ObjectiveText1` text, - `ObjectiveText2` text, - `ObjectiveText3` text, - `ObjectiveText4` text, - `ReqItemId1` mediumint(8) unsigned NOT NULL default '0', - `ReqItemId2` mediumint(8) unsigned NOT NULL default '0', - `ReqItemId3` mediumint(8) unsigned NOT NULL default '0', - `ReqItemId4` mediumint(8) unsigned NOT NULL default '0', - `ReqItemCount1` smallint(5) unsigned NOT NULL default '0', - `ReqItemCount2` smallint(5) unsigned NOT NULL default '0', - `ReqItemCount3` smallint(5) unsigned NOT NULL default '0', - `ReqItemCount4` smallint(5) unsigned NOT NULL default '0', - `ReqSourceId1` mediumint(8) unsigned NOT NULL default '0', - `ReqSourceId2` mediumint(8) unsigned NOT NULL default '0', - `ReqSourceId3` mediumint(8) unsigned NOT NULL default '0', - `ReqSourceId4` mediumint(8) unsigned NOT NULL default '0', - `ReqSourceCount1` smallint(5) unsigned NOT NULL default '0', - `ReqSourceCount2` smallint(5) unsigned NOT NULL default '0', - `ReqSourceCount3` smallint(5) unsigned NOT NULL default '0', - `ReqSourceCount4` smallint(5) unsigned NOT NULL default '0', - `ReqSourceRef1` tinyint(3) unsigned NOT NULL default '0', - `ReqSourceRef2` tinyint(3) unsigned NOT NULL default '0', - `ReqSourceRef3` tinyint(3) unsigned NOT NULL default '0', - `ReqSourceRef4` tinyint(3) unsigned NOT NULL default '0', - `ReqCreatureOrGOId1` mediumint(9) NOT NULL default '0', - `ReqCreatureOrGOId2` mediumint(9) NOT NULL default '0', - `ReqCreatureOrGOId3` mediumint(9) NOT NULL default '0', - `ReqCreatureOrGOId4` mediumint(9) NOT NULL default '0', - `ReqCreatureOrGOCount1` smallint(5) unsigned NOT NULL default '0', - `ReqCreatureOrGOCount2` smallint(5) unsigned NOT NULL default '0', - `ReqCreatureOrGOCount3` smallint(5) unsigned NOT NULL default '0', - `ReqCreatureOrGOCount4` smallint(5) unsigned NOT NULL default '0', - `ReqSpellCast1` mediumint(8) unsigned NOT NULL default '0', - `ReqSpellCast2` mediumint(8) unsigned NOT NULL default '0', - `ReqSpellCast3` mediumint(8) unsigned NOT NULL default '0', - `ReqSpellCast4` mediumint(8) unsigned NOT NULL default '0', - `RewChoiceItemId1` mediumint(8) unsigned NOT NULL default '0', - `RewChoiceItemId2` mediumint(8) unsigned NOT NULL default '0', - `RewChoiceItemId3` mediumint(8) unsigned NOT NULL default '0', - `RewChoiceItemId4` mediumint(8) unsigned NOT NULL default '0', - `RewChoiceItemId5` mediumint(8) unsigned NOT NULL default '0', - `RewChoiceItemId6` mediumint(8) unsigned NOT NULL default '0', - `RewChoiceItemCount1` smallint(5) unsigned NOT NULL default '0', - `RewChoiceItemCount2` smallint(5) unsigned NOT NULL default '0', - `RewChoiceItemCount3` smallint(5) unsigned NOT NULL default '0', - `RewChoiceItemCount4` smallint(5) unsigned NOT NULL default '0', - `RewChoiceItemCount5` smallint(5) unsigned NOT NULL default '0', - `RewChoiceItemCount6` smallint(5) unsigned NOT NULL default '0', - `RewItemId1` mediumint(8) unsigned NOT NULL default '0', - `RewItemId2` mediumint(8) unsigned NOT NULL default '0', - `RewItemId3` mediumint(8) unsigned NOT NULL default '0', - `RewItemId4` mediumint(8) unsigned NOT NULL default '0', - `RewItemCount1` smallint(5) unsigned NOT NULL default '0', - `RewItemCount2` smallint(5) unsigned NOT NULL default '0', - `RewItemCount3` smallint(5) unsigned NOT NULL default '0', - `RewItemCount4` smallint(5) unsigned NOT NULL default '0', - `RewRepFaction1` smallint(5) unsigned NOT NULL default '0' COMMENT 'faction id from Faction.dbc in this case', - `RewRepFaction2` smallint(5) unsigned NOT NULL default '0' COMMENT 'faction id from Faction.dbc in this case', - `RewRepFaction3` smallint(5) unsigned NOT NULL default '0' COMMENT 'faction id from Faction.dbc in this case', - `RewRepFaction4` smallint(5) unsigned NOT NULL default '0' COMMENT 'faction id from Faction.dbc in this case', - `RewRepFaction5` smallint(5) unsigned NOT NULL default '0' COMMENT 'faction id from Faction.dbc in this case', - `RewRepValue1` mediumint(9) NOT NULL default '0', - `RewRepValue2` mediumint(9) NOT NULL default '0', - `RewRepValue3` mediumint(9) NOT NULL default '0', - `RewRepValue4` mediumint(9) NOT NULL default '0', - `RewRepValue5` mediumint(9) NOT NULL default '0', - `RewOrReqMoney` int(11) NOT NULL default '0', - `RewMoneyMaxLevel` int(10) unsigned NOT NULL default '0', - `RewSpell` mediumint(8) unsigned NOT NULL default '0', - `RewSpellCast` mediumint(8) unsigned NOT NULL default '0', - `RewMailTemplateId` mediumint(8) unsigned NOT NULL default '0', - `RewMailDelaySecs` int(11) unsigned NOT NULL default '0', - `PointMapId` smallint(5) unsigned NOT NULL default '0', - `PointX` float NOT NULL default '0', - `PointY` float NOT NULL default '0', - `PointOpt` mediumint(8) unsigned NOT NULL default '0', - `DetailsEmote1` smallint(5) unsigned NOT NULL default '0', - `DetailsEmote2` smallint(5) unsigned NOT NULL default '0', - `DetailsEmote3` smallint(5) unsigned NOT NULL default '0', - `DetailsEmote4` smallint(5) unsigned NOT NULL default '0', - `IncompleteEmote` smallint(5) unsigned NOT NULL default '0', - `CompleteEmote` smallint(5) unsigned NOT NULL default '0', - `OfferRewardEmote1` smallint(5) unsigned NOT NULL default '0', - `OfferRewardEmote2` smallint(5) unsigned NOT NULL default '0', - `OfferRewardEmote3` smallint(5) unsigned NOT NULL default '0', - `OfferRewardEmote4` smallint(5) unsigned NOT NULL default '0', - `StartScript` mediumint(8) unsigned NOT NULL default '0', - `CompleteScript` mediumint(8) unsigned NOT NULL default '0', - PRIMARY KEY (`entry`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Quest System'; - --- --- Dumping data for table `quest_template` --- - -LOCK TABLES `quest_template` WRITE; -/*!40000 ALTER TABLE `quest_template` DISABLE KEYS */; -/*!40000 ALTER TABLE `quest_template` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `reference_loot_template` --- - -DROP TABLE IF EXISTS `reference_loot_template`; -CREATE TABLE `reference_loot_template` ( - `entry` mediumint(8) unsigned NOT NULL default '0', - `item` mediumint(8) unsigned NOT NULL default '0', - `ChanceOrQuestChance` float NOT NULL default '100', - `groupid` tinyint(3) unsigned NOT NULL default '0', - `mincountOrRef` mediumint(9) NOT NULL default '1', - `maxcount` tinyint(3) unsigned NOT NULL default '1', - `lootcondition` tinyint(3) unsigned NOT NULL default '0', - `condition_value1` mediumint(8) unsigned NOT NULL default '0', - `condition_value2` mediumint(8) unsigned NOT NULL default '0', - PRIMARY KEY (`entry`,`item`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Loot System'; - --- --- Dumping data for table `reference_loot_template` --- - -LOCK TABLES `reference_loot_template` WRITE; -/*!40000 ALTER TABLE `reference_loot_template` DISABLE KEYS */; -/*!40000 ALTER TABLE `reference_loot_template` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `reserved_name` --- - -DROP TABLE IF EXISTS `reserved_name`; -CREATE TABLE `reserved_name` ( - `name` varchar(12) NOT NULL default '', - PRIMARY KEY (`name`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='Player Reserved Names'; - --- --- Dumping data for table `reserved_name` --- - -LOCK TABLES `reserved_name` WRITE; -/*!40000 ALTER TABLE `reserved_name` DISABLE KEYS */; -/*!40000 ALTER TABLE `reserved_name` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `skill_discovery_template` --- - -DROP TABLE IF EXISTS `skill_discovery_template`; -CREATE TABLE `skill_discovery_template` ( - `spellId` mediumint(8) unsigned NOT NULL default '0' COMMENT 'SpellId of the discoverable spell', - `reqSpell` mediumint(8) unsigned NOT NULL default '0' COMMENT 'spell requirement', - `chance` float NOT NULL default '0' COMMENT 'chance to discover', - PRIMARY KEY (`spellId`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Skill Discovery System'; - --- --- Dumping data for table `skill_discovery_template` --- - -LOCK TABLES `skill_discovery_template` WRITE; -/*!40000 ALTER TABLE `skill_discovery_template` DISABLE KEYS */; -/*!40000 ALTER TABLE `skill_discovery_template` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `skill_extra_item_template` --- - -DROP TABLE IF EXISTS `skill_extra_item_template`; -CREATE TABLE `skill_extra_item_template` ( - `spellId` mediumint(8) unsigned NOT NULL default '0' COMMENT 'SpellId of the item creation spell', - `requiredSpecialization` mediumint(8) unsigned NOT NULL default '0' COMMENT 'Specialization spell id', - `additionalCreateChance` float NOT NULL default '0' COMMENT 'chance to create add', - `additionalMaxNum` tinyint(3) unsigned NOT NULL default '0' COMMENT 'max num of adds', - PRIMARY KEY (`spellId`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Skill Specialization System'; - --- --- Dumping data for table `skill_extra_item_template` --- - -LOCK TABLES `skill_extra_item_template` WRITE; -/*!40000 ALTER TABLE `skill_extra_item_template` DISABLE KEYS */; -/*!40000 ALTER TABLE `skill_extra_item_template` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `skill_fishing_base_level` --- - -DROP TABLE IF EXISTS `skill_fishing_base_level`; -CREATE TABLE `skill_fishing_base_level` ( - `entry` mediumint(8) unsigned NOT NULL default '0' COMMENT 'Area identifier', - `skill` smallint(6) NOT NULL default '0' COMMENT 'Base skill level requirement', - PRIMARY KEY (`entry`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Fishing system'; - --- --- Dumping data for table `skill_fishing_base_level` --- - -LOCK TABLES `skill_fishing_base_level` WRITE; -/*!40000 ALTER TABLE `skill_fishing_base_level` DISABLE KEYS */; -/*!40000 ALTER TABLE `skill_fishing_base_level` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `skinning_loot_template` --- - -DROP TABLE IF EXISTS `skinning_loot_template`; -CREATE TABLE `skinning_loot_template` ( - `entry` mediumint(8) unsigned NOT NULL default '0', - `item` mediumint(8) unsigned NOT NULL default '0', - `ChanceOrQuestChance` float NOT NULL default '100', - `groupid` tinyint(3) unsigned NOT NULL default '0', - `mincountOrRef` mediumint(9) NOT NULL default '1', - `maxcount` tinyint(3) unsigned NOT NULL default '1', - `lootcondition` tinyint(3) unsigned NOT NULL default '0', - `condition_value1` mediumint(8) unsigned NOT NULL default '0', - `condition_value2` mediumint(8) unsigned NOT NULL default '0', - PRIMARY KEY (`entry`,`item`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Loot System'; - --- --- Dumping data for table `skinning_loot_template` --- - -LOCK TABLES `skinning_loot_template` WRITE; -/*!40000 ALTER TABLE `skinning_loot_template` DISABLE KEYS */; -/*!40000 ALTER TABLE `skinning_loot_template` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `spell_affect` --- - -DROP TABLE IF EXISTS `spell_affect`; -CREATE TABLE `spell_affect` ( - `entry` smallint(5) unsigned NOT NULL default '0', - `effectId` tinyint(3) unsigned NOT NULL default '0', - `SpellFamilyMask` bigint(20) unsigned NOT NULL default '0', - PRIMARY KEY (`entry`,`effectId`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8; - --- --- Dumping data for table `spell_affect` --- - -LOCK TABLES `spell_affect` WRITE; -/*!40000 ALTER TABLE `spell_affect` DISABLE KEYS */; -INSERT INTO `spell_affect` VALUES -(5420,2,0x00001012100000D0), -(8875,1,0x0000040000000000), -(11069,0,0x0000000000000001), -(11070,0,0x0000000000000020), -(11071,0,0x0000000000100000), -(11083,0,0x0000000000C20017), -(11124,0,0x0000000008C20017), -(11151,0,0x00000000000202E0), -(11160,0,0x00000001020203E0), -(11175,1,0x0000000000100000), -(11207,0,0x00000000000202E0), -(11222,0,0x0000000020001800), -(11242,0,0x0000000020001000), -(11247,0,0x0000000000002000), -(12042,0,0x0000000020E01AF7), -(12042,1,0x0000000020E01AF7), -(12042,2,0x0000000020E01AF7), -(12043,0,0x0000000021400035), -(12285,0,0x0000000000000001), -(12286,0,0x0000000000000020), -(12287,1,0x0000000000000080), -(12295,1,0x0000000002000000), -(12295,2,0x0000040000000000), -(12301,0,0x0000000000000100), -(12303,1,0x0000100000000000), -(12308,0,0x0000000000004000), -(12318,0,0x0000008000010000), -(12321,0,0x0000008000030000), -(12321,1,0x0000008000030000), -(12330,0,0x0000000000200000), -(12338,0,0x0000000000000001), -(12339,0,0x0000000000000001), -(12340,0,0x0000000000000001), -(12341,0,0x0000000000000001), -(12351,0,0x0000000000C20017), -(12378,0,0x0000000008C20017), -(12398,0,0x0000000008C20017), -(12399,0,0x0000000008C20017), -(12400,0,0x0000000008C20017), -(12467,0,0x0000000020001000), -(12469,0,0x0000000020001000), -(12472,1,0x00000000E44008A5), -(12473,0,0x0000000000000020), -(12496,0,0x0000000000100000), -(12497,0,0x0000000000100000), -(12518,0,0x00000001020203E0), -(12519,0,0x00000001020203E0), -(12536,0,0x0000000020C01AF7), -(12569,1,0x0000000000100000), -(12571,1,0x0000000000100000), -(12606,0,0x0000000000002000), -(12658,0,0x0000000000000020), -(12659,0,0x0000000000000020), -(12665,1,0x0000000000000080), -(12666,1,0x0000000000000080), -(12672,0,0x00000000000202E0), -(12676,1,0x0000000002000000), -(12676,2,0x0000040000000000), -(12677,1,0x0000000002000000), -(12677,2,0x0000040000000000), -(12697,0,0x0000000000000001), -(12788,1,0x0000100000000000), -(12789,1,0x0000100000000000), -(12810,0,0x0000000000004000), -(12811,0,0x0000000000004000), -(12818,0,0x0000000000000100), -(12835,0,0x0000008000030000), -(12835,1,0x0000008000030000), -(12836,0,0x0000008000030000), -(12836,1,0x0000008000030000), -(12837,0,0x0000008000030000), -(12837,1,0x0000008000030000), -(12838,0,0x0000008000030000), -(12838,1,0x0000008000030000), -(12839,0,0x0000000020001800), -(12840,0,0x0000000020001800), -(12841,0,0x0000000020001800), -(12842,0,0x0000000020001800), -(12857,0,0x0000008000010000), -(12858,0,0x0000008000010000), -(12860,0,0x0000008000010000), -(12861,0,0x0000008000010000), -(12862,0,0x0000000000200000), -(12945,1,0x0000000000001000), -(12952,0,0x00000000000202E0), -(12953,0,0x00000000000202E0), -(12954,0,0x00000000000202E0), -(12957,0,0x00000000000202E0), -(13733,0,0x0000000000000004), -(13733,1,0x0000000400000000), -(13742,0,0x0000000000000060), -(13743,0,0x0000000000000040), -(13865,0,0x0000000000000004), -(13865,1,0x0000000400000000), -(13866,0,0x0000000000000004), -(13866,1,0x0000000400000000), -(13872,0,0x0000000000000060), -(13875,0,0x0000000000000040), -(13975,0,0x0000000000400000), -(13975,1,0x0000000000400000), -(13976,0,0x0000000000000700), -(13979,0,0x0000000000000700), -(13980,0,0x0000000000000700), -(13981,0,0x0000000001000000), -(13981,1,0x0000000000000800), -(14057,0,0x0000000600000304), -(14062,0,0x0000000000400000), -(14062,1,0x0000000000400000), -(14063,0,0x0000000000400000), -(14063,1,0x0000000000400000), -(14064,0,0x0000000000400000), -(14064,1,0x0000000000400000), -(14065,0,0x0000000000400000), -(14065,1,0x0000000000400000), -(14066,0,0x0000000001000000), -(14066,1,0x0000000000000800), -(14072,0,0x0000000600000304), -(14073,0,0x0000000600000304), -(14074,0,0x0000000600000304), -(14075,0,0x0000000600000304), -(14076,0,0x0000000001000080), -(14076,1,0x0000000001000080), -(14082,0,0x0000000000000500), -(14083,0,0x0000000000000500), -(14094,0,0x0000000001000080), -(14094,1,0x0000000001000080), -(14113,0,0x000000000001E000), -(14114,0,0x000000000001E000), -(14115,0,0x000000000001E000), -(14116,0,0x000000000001E000), -(14117,0,0x000000000001E000), -(14128,0,0x000000062600000E), -(14132,0,0x000000062600000E), -(14135,0,0x000000062600000E), -(14136,0,0x000000062600000E), -(14137,0,0x000000062600000E), -(14143,0,0x0000000004000206), -(14149,0,0x0000000004000206), -(14162,0,0x0000000000020000), -(14163,0,0x0000000000020000), -(14164,0,0x0000000000020000), -(14168,0,0x0000000000080000), -(14169,0,0x0000000000080000), -(14174,0,0x0000000000200000), -(14175,0,0x0000000000200000), -(14176,0,0x0000000000200000), -(14177,0,0x0000000C6012031E), -(14179,0,0x00000009003E0000), -(14520,0,0x00000963BF61C16F), -(14523,1,0x000000208030016B), -(14523,2,0x000000208030016B), -(14743,0,0x0000049440963E90), -(14747,0,0x0000000000000002), -(14750,0,0x0000000000000010), -(14751,0,0xFFFFFFFFFFFFFFFF), -(14751,1,0xFFFFFFFFFFFFFFFF), -(14770,0,0x0000000000000002), -(14771,0,0x0000000000000002), -(14772,0,0x0000000000000010), -(14780,0,0x00000963BF61C16F), -(14781,0,0x00000963BF61C16F), -(14782,0,0x00000963BF61C16F), -(14783,0,0x00000963BF61C16F), -(14784,1,0x000000208030016B), -(14784,2,0x000000208030016B), -(14785,1,0x000000208030016B), -(14785,2,0x000000208030016B), -(14786,1,0x000000208030016B), -(14786,2,0x000000208030016B), -(14787,1,0x000000208030016B), -(14787,2,0x000000208030016B), -(14908,0,0x0000000000000040), -(14909,1,0x0000000000100080), -(14911,0,0x0000002000000200), -(14912,0,0x0000000000041400), -(14913,0,0x0000000400041E00), -(15012,0,0x0000000400041E00), -(15013,0,0x0000000000041400), -(15014,0,0x0000000000041400), -(15017,1,0x0000000000100080), -(15018,0,0x0000002000000200), -(15020,0,0x0000000000000040), -(15047,0,0x00000000000202E0), -(15052,0,0x00000000000202E0), -(15053,0,0x00000000000202E0), -(15257,0,0x000004020288A010), -(15259,0,0x0000000202002000), -(15259,1,0x0000040000808000), -(15260,0,0x00000442068BA000), -(15272,0,0x00000D4A068BE104), -(15307,0,0x0000000202002000), -(15307,1,0x0000040000808000), -(15308,0,0x0000000202002000), -(15308,1,0x0000040000808000), -(15309,0,0x0000000202002000), -(15309,1,0x0000040000808000), -(15310,0,0x0000000202002000), -(15310,1,0x0000040000808000), -(15318,0,0x00000D4A068BE104), -(15320,0,0x00000D4A068BE104), -(15327,0,0x00000442068BA000), -(15328,0,0x00000442068BA000), -(15329,0,0x00000442068BA000), -(15330,0,0x00000442068BA000), -(15331,0,0x000004020288A010), -(15332,0,0x000004020288A010), -(15333,0,0x000004020288A010), -(15334,0,0x000004020288A010), -(16035,0,0x0000000090100003), -(16038,0,0x0000000040000000), -(16039,0,0x0000000090100003), -(16041,0,0x0000000000000003), -(16043,0,0x0000000000000008), -(16043,1,0x0000000100000000), -(16086,0,0x0000000000000020), -(16086,1,0x0000000000000020), -(16086,2,0x0000000000000004), -(16089,0,0x00000004D3300407), -(16105,0,0x0000000090100003), -(16106,0,0x0000000090100003), -(16106,1,0x0000000090100003), -(16107,0,0x0000000090100003), -(16108,0,0x0000000090100003), -(16109,0,0x0000000090100003), -(16110,0,0x0000000090100003), -(16111,0,0x0000000090100003), -(16112,0,0x0000000090100003), -(16117,0,0x0000000000000003), -(16118,0,0x0000000000000003), -(16119,0,0x0000000000000003), -(16120,0,0x0000000000000003), -(16130,0,0x0000000000000008), -(16130,1,0x0000000100000000), -(16160,0,0x0000000040000000), -(16161,0,0x0000000040000000), -(16166,0,0x0000000090100003), -(16166,1,0x0000000090100003), -(16173,0,0x0000000020081018), -(16179,0,0x00000000000000C0), -(16181,0,0x00000000000001C0), -(16184,0,0x0000000000000200), -(16184,1,0x0000000000000200), -(16187,0,0x0000000000006000), -(16187,1,0x0000000000006000), -(16188,0,0x00000000000009C3), -(16189,0,0x000001000403E000), -(16205,0,0x0000000000006000), -(16205,1,0x0000000000006000), -(16206,0,0x0000000000006000), -(16206,1,0x0000000000006000), -(16207,0,0x0000000000006000), -(16207,1,0x0000000000006000), -(16208,0,0x0000000000006000), -(16208,1,0x0000000000006000), -(16209,1,0x0000000000000200), -(16214,0,0x00000000000000C0), -(16215,0,0x00000000000000C0), -(16216,0,0x00000000000000C0), -(16217,0,0x00000000000000C0), -(16222,0,0x0000000020081018), -(16223,0,0x0000000020081018), -(16224,0,0x0000000020081018), -(16225,0,0x0000000020081018), -(16230,0,0x00000000000001C0), -(16232,0,0x00000000000001C0), -(16233,0,0x00000000000001C0), -(16234,0,0x00000000000001C0), -(16246,0,0x0000000090100003), -(16258,0,0x0000000000008000), -(16258,1,0x0000000000040000), -(16259,0,0x0000000000010000), -(16259,1,0x0000000000020000), -(16261,0,0x0000000000000400), -(16266,0,0x0000000000400000), -(16266,1,0x0000000001000000), -(16266,2,0x0000000000800000), -(16290,0,0x0000000000000400), -(16291,0,0x0000000000000400), -(16293,0,0x0000000000008000), -(16293,1,0x0000000000040000), -(16295,0,0x0000000000010000), -(16295,1,0x0000000000020000), -(16493,0,0x0000014D2A600CEF), -(16494,0,0x0000014D2A600CEF), -(16513,0,0x000000080001E000), -(16513,1,0x000000000001E000), -(16513,2,0x000000000001E000), -(16514,0,0x000000080001E000), -(16514,1,0x000000000001E000), -(16514,2,0x000000000001E000), -(16515,0,0x000000080001E000), -(16515,1,0x000000000001E000), -(16515,2,0x000000000001E000), -(16544,2,0x0000000000000004), -(16578,0,0x0000000000000003), -(16579,0,0x0000000000000003), -(16580,0,0x0000000000000003), -(16581,0,0x0000000000000003), -(16582,0,0x0000000000000003), -(16719,0,0x000000080001E000), -(16719,1,0x000000000001E000), -(16719,2,0x000000000001E000), -(16720,0,0x000000080001E000), -(16720,1,0x000000000001E000), -(16720,2,0x000000000001E000), -(16757,0,0x00000000000200A0), -(16757,1,0x0000000000000240), -(16758,0,0x00000000000200A0), -(16758,1,0x0000000000000240), -(16763,0,0x0000000000000020), -(16765,0,0x0000000000000020), -(16766,0,0x0000000000000020), -(16814,0,0x0000000000000005), -(16815,0,0x0000000000000005), -(16816,0,0x0000000000000005), -(16817,0,0x0000000000000005), -(16818,0,0x0000000000000005), -(16819,0,0x0002122000600707), -(16820,0,0x0002122000600707), -(16821,0,0x0000000000000002), -(16821,1,0x0000000000000002), -(16821,2,0x0000000000000002), -(16822,0,0x0000000000000002), -(16822,1,0x0000000000000002), -(16822,2,0x0000000000000002), -(16833,0,0x0000E000E2000000), -(16834,0,0x0000E000E2000000), -(16835,0,0x0000E000E2000000), -(16836,1,0x0000000000000300), -(16839,1,0x0000000000000300), -(16840,1,0x0000000000000300), -(16850,1,0x0000000000000001), -(16870,0,0x001007F100E3FEFF), -(16886,0,0x0000000001000265), -(16896,0,0x0000000000000007), -(16896,1,0x0000000000000007), -(16897,0,0x0000000000000007), -(16897,1,0x0000000000000007), -(16899,0,0x0000000000000007), -(16899,1,0x0000000000000007), -(16900,0,0x0000000000000007), -(16900,1,0x0000000000000007), -(16901,0,0x0000000000000007), -(16901,1,0x0000000000000007), -(16918,0,0x0000002000000200), -(16919,0,0x0000002000000200), -(16920,0,0x0000002000000200), -(16923,1,0x0000000000000001), -(16924,1,0x0000000000000001), -(16934,0,0x0010004000000800), -(16934,1,0x0000040000001000), -(16935,0,0x0010004000000800), -(16935,1,0x0000040000001000), -(16936,0,0x0010004000000800), -(16936,1,0x0000040000001000), -(16937,0,0x0010004000000800), -(16937,1,0x0000040000001000), -(16938,0,0x0010004000000800), -(16938,1,0x0000040000001000), -(16947,1,0x0000000002000000), -(16948,1,0x0000000002000000), -(16949,1,0x0000000002000000), -(16966,0,0x0000000000008000), -(16966,1,0x0000010000000000), -(16968,0,0x0000000000008000), -(16968,1,0x0000010000000000), -(16998,0,0x0000000000001000), -(16998,2,0x0000000000001000), -(16999,0,0x0000000000001000), -(16999,2,0x0000000000001000), -(17104,0,0x00000010000000F0), -(17104,1,0x00000010000000F0), -(17111,0,0x0000000000000010), -(17112,0,0x0000000000000010), -(17113,0,0x0000000000000010), -(17114,0,0x0000000000000010), -(17115,0,0x0000000000000010), -(17116,0,0x0002002010000261), -(17118,0,0x001005D000E193F7), -(17118,1,0x0004103000340750), -(17119,0,0x001005D000E193F7), -(17119,1,0x0004103000340750), -(17120,0,0x001005D000E193F7), -(17120,1,0x0004103000340750), -(17121,0,0x001005D000E193F7), -(17121,1,0x0004103000340750), -(17122,0,0x001005D000E193F7), -(17122,1,0x0004103000340750), -(17123,0,0x0000000000000080), -(17124,0,0x0000000000000080), -(17191,0,0x0000000000000040), -(17322,0,0x00000542068AA004), -(17323,0,0x00000542068AA004), -(17768,0,0x0000000040000000), -(17768,1,0x0000000080000000), -(17778,0,0x000010C0000003E5), -(17779,0,0x000010C0000003E5), -(17780,0,0x000010C0000003E5), -(17781,0,0x000010C0000003E5), -(17782,0,0x000010C0000003E5), -(17788,1,0x0000008000000000), -(17789,1,0x0000008000000000), -(17790,1,0x0000008000000000), -(17791,1,0x0000008000000000), -(17792,1,0x0000008000000000), -(17904,0,0x0000000000000000), -(17912,0,0x0000000000000000), -(17913,0,0x0000000000000000), -(17914,0,0x0000000000000000), -(17915,0,0x0000000000000000), -(17916,0,0x0000000000000000), -(17917,0,0x000010C0000003A5), -(17917,1,0x000010C0000003E5), -(17918,0,0x000010C0000003A5), -(17918,1,0x000010C0000003E5), -(17927,0,0x0000000000000100), -(17929,0,0x0000000000000100), -(17930,0,0x0000000000000100), -(17941,0,0x0000000000000001), -(17954,0,0x000000C000001364), -(17954,1,0x000000C000001364), -(17954,2,0x0000004000000000), -(17955,0,0x000000C000001364), -(17955,1,0x000000C000001364), -(17955,2,0x0000004000000000), -(17956,0,0x000000C000001364), -(17956,1,0x000000C000001364), -(17956,2,0x0000004000000000), -(17957,0,0x000000C000001364), -(17957,1,0x000000C000001364), -(17957,2,0x0000004000000000), -(17958,0,0x000000C000001364), -(17958,1,0x000000C000001364), -(17958,2,0x0000004000000000), -(17959,0,0x000010C0000003E5), -(18126,0,0x0000000000001000), -(18127,0,0x0000000000001000), -(18130,0,0x000010C0000003E5), -(18131,0,0x000010C0000003E5), -(18132,0,0x000010C0000003E5), -(18133,0,0x000010C0000003E5), -(18134,0,0x000010C0000003E5), -(18135,0,0x000010C0000003E5), -(18136,0,0x000010C0000003E5), -(18174,0,0x0000071B804CC41A), -(18175,0,0x0000071B804CC41A), -(18176,0,0x0000071B804CC41A), -(18177,0,0x0000071B804CC41A), -(18178,0,0x0000071B804CC41A), -(18179,0,0x0000000000008000), -(18180,0,0x0000000000008000), -(18213,0,0x0000000000004000), -(18213,1,0x0000871B804CC41A), -(18218,0,0x000007138048C41A), -(18219,0,0x000007138048C41A), -(18271,0,0x000011130008A48B), -(18271,1,0x000011130008A48B), -(18272,0,0x000011130008A48B), -(18272,1,0x000011130008A48B), -(18273,0,0x000011130008A48B), -(18273,1,0x000011130008A48B), -(18274,0,0x000011130008A48B), -(18274,1,0x000011130008A48B), -(18275,0,0x000011130008A48B), -(18275,1,0x000011130008A48B), -(18288,0,0x0000000200000400), -(18288,1,0x0000000000400000), -(18372,1,0x0000871B804CC41A), -(18427,0,0x0000000000020006), -(18428,0,0x0000000000020006), -(18429,0,0x0000000000020006), -(18544,0,0x0000041202F8A090), -(18544,1,0x0000001202582090), -(18544,2,0x0000040000A08000), -(18547,0,0x0000041202F8A090), -(18547,1,0x0000001202582090), -(18547,2,0x0000040000A08000), -(18548,0,0x0000041202F8A090), -(18548,1,0x0000001202582090), -(18548,2,0x0000040000A08000), -(18549,0,0x0000041202F8A090), -(18549,1,0x0000001202582090), -(18549,2,0x0000040000A08000), -(18550,0,0x0000041202F8A090), -(18550,1,0x0000001202582090), -(18550,2,0x0000040000A08000), -(18703,1,0x0000000001000000), -(18704,1,0x0000000001000000), -(18731,0,0x0000000010000000), -(18743,0,0x0000000010000000), -(18744,0,0x0000000010000000), -(18748,0,0x0000000008000000), -(18749,0,0x0000000008000000), -(18750,0,0x0000000008000000), -(18767,1,0x0000000000020000), -(18768,1,0x0000000000020000), -(18821,0,0x0000000000000800), -(18821,1,0x0000000000000800), -(18821,2,0x0000000000000800), -(18822,0,0x0000000000000800), -(18822,1,0x0000000000000800), -(18822,2,0x0000000000000800), -(18827,0,0x0000000000000400), -(18829,0,0x0000000000000400), -(19239,0,0x0000000000000018), -(19239,1,0x0000000000000004), -(19245,0,0x0000000000000018), -(19245,1,0x0000200000000004), -(19416,0,0x000210810007FA00), -(19417,0,0x000210810007FA00), -(19418,0,0x000210810007FA00), -(19419,0,0x000210810007FA00), -(19420,0,0x000210810007FA00), -(19461,0,0x0000000000003000), -(19461,1,0x0000000000003000), -(19462,0,0x0000000000003000), -(19462,1,0x0000000000003000), -(19464,0,0x0000010000004000), -(19464,1,0x0000008000000000), -(19464,2,0x000011800000C000), -(19465,0,0x0000010000004000), -(19465,1,0x0000008000000000), -(19465,2,0x000011800000C000), -(19466,0,0x0000010000004000), -(19466,1,0x0000008000000000), -(19466,2,0x000011800000C000), -(19467,0,0x0000010000004000), -(19467,1,0x0000008000000000), -(19467,2,0x000011800000C000), -(19468,0,0x0000010000004000), -(19468,1,0x0000008000000000), -(19468,2,0x000011800000C000), -(19485,0,0x0000000100061801), -(19487,0,0x0000000100061801), -(19488,0,0x0000000100061801), -(19489,0,0x0000000100061801), -(19490,0,0x0000000100061801), -(19498,0,0x000210810007FA01), -(19499,0,0x000210810007FA01), -(19500,0,0x000210810007FA01), -(19549,0,0x0000000000080000), -(19550,0,0x0000000000080000), -(19551,0,0x0000000000080000), -(19552,0,0x0000000000100000), -(19552,1,0x0000020000000000), -(19553,0,0x0000000000100000), -(19553,1,0x0000020000000000), -(19554,0,0x0000000000100000), -(19554,1,0x0000020000000000), -(19555,0,0x0000000000100000), -(19555,1,0x0000020000000000), -(19556,0,0x0000000000100000), -(19556,1,0x0000020000000000), -(19559,0,0x0000000000200000), -(19560,0,0x0000000000200000), -(19572,1,0x0000000000800000), -(19573,1,0x0000000000800000), -(19583,0,0x0000000008000000), -(19584,0,0x0000000008000000), -(19585,0,0x0000000008000000), -(19586,0,0x0000000008000000), -(19587,0,0x0000000008000000), -(19590,0,0x0000000020000000), -(19592,0,0x0000000020000000), -(19598,0,0x0000000040000000), -(19599,0,0x0000000040000000), -(19600,0,0x0000000040000000), -(19601,0,0x0000000040000000), -(19602,0,0x0000000040000000), -(19609,0,0x0000000004000000), -(19610,0,0x0000000004000000), -(19612,0,0x0000000004000000), -(20101,0,0x000004000A000200), -(20102,0,0x000004000A000200), -(20103,0,0x000004000A000200), -(20104,0,0x000004000A000200), -(20105,0,0x000004000A000200), -(20138,0,0x0000000000000040), -(20139,0,0x0000000000000040), -(20140,0,0x0000000000000040), -(20141,0,0x0000000000000040), -(20142,0,0x0000000000000040), -(20174,0,0x0000000000000080), -(20174,1,0x0000000000000010), -(20175,0,0x0000000000000080), -(20175,1,0x0000000000000010), -(20216,0,0x00010000C0200000), -(20224,0,0x0000000008000400), -(20225,0,0x0000000008000400), -(20237,0,0x00000000C0000000), -(20238,0,0x00000000C0000000), -(20239,0,0x00000000C0000000), -(20249,0,0x0000000040000000), -(20250,0,0x0000000040000000), -(20251,0,0x0000000040000000), -(20254,0,0x0000000000020000), -(20254,1,0x0000000000020000), -(20254,2,0x0000000000020000), -(20255,0,0x0000000000020000), -(20255,1,0x0000000000020000), -(20255,2,0x0000000000020000), -(20256,0,0x0000000000020000), -(20256,1,0x0000000000020000), -(20256,2,0x0000000000020000), -(20330,0,0x0000000008000400), -(20331,0,0x0000000008000400), -(20332,0,0x0000000008000400), -(20335,0,0x0000000020000000), -(20336,0,0x0000000020000000), -(20337,0,0x0000000020000000), -(20359,0,0x0000000080000000), -(20360,0,0x0000000080000000), -(20361,0,0x0000000080000000), -(20468,1,0x0000000000000001), -(20469,1,0x0000000000000001), -(20470,1,0x0000000000000001), -(20575,0,0x0000000004000000), -(20575,1,0x0000000004000000), -(20576,0,0x0000000002000000), -(21873,0,0x0000E000E2000000), -(21881,0,0x000000000001E000), -(21887,0,0x0000036C2A764EEF), -(21895,0,0x000000000403E000), -(21899,0,0x0000000000000100), -(21942,1,0x0000000008000000), -(22008,0,0x0000000021400035), -(23025,0,0x0000000000010000), -(23047,0,0x0000040000000000), -(23047,1,0x0000040000000000), -(23158,0,0x0000000000000200), -(23300,0,0x0000000020000000), -(23555,0,0x000010C0000003E5), -(23561,0,0x0000000000004000), -(23566,0,0x0000000000001000), -(23724,0,0x0000E000E2000000), -(23726,0,0x0000000000002000), -(23726,1,0x0000000000010000), -(24348,0,0x0000000000200000), -(24429,0,0x0000000000004000), -(24431,0,0x0000000400000000), -(24460,0,0x0000000010000180), -(24469,0,0x0000000001000000), -(24499,0,0x0000000000000400), -(24542,1,0x00000000000000F0), -(24546,1,0x0000000400041E00), -(24691,0,0x0000000000003000), -(24691,1,0x0000000000003000), -(24943,0,0x00000010000000F0), -(24943,1,0x00000010000000F0), -(24944,0,0x00000010000000F0), -(24944,1,0x00000010000000F0), -(24945,0,0x00000010000000F0), -(24945,1,0x00000010000000F0), -(24946,0,0x00000010000000F0), -(24946,1,0x00000010000000F0), -(26106,0,0x0000000010000000), -(26109,0,0x00000080000F0000), -(26112,0,0x0000000000000020), -(26118,0,0x0000000004000000), -(26118,1,0x0000000004000000), -(26174,0,0x0000000000000020), -(27789,1,0x0000000010400200), -(27790,1,0x0000000010400200), -(27828,0,0x0000049440963E90), -(27846,0,0x0000000000000020), -(27850,0,0x0000000000000040), -(27851,0,0x0000000000001000), -(28088,0,0x000000000001E000), -(28107,0,0x0000000000040000), -(28539,0,0x0000000000001000), -(28682,0,0x0000004008C20017), -(28743,0,0x00000000000000F0), -(28746,1,0x0000000100000406), -(28751,0,0x0000000000021000), -(28755,0,0x0000000000000020), -(28763,0,0x0000000004000000), -(28774,0,0x0000000000008000), -(28775,0,0x0000000100000000), -(28787,0,0x0000000000001000), -(28807,0,0x0000000000000040), -(28808,0,0x0000000411041E40), -(28811,0,0x0000000002020006), -(28814,0,0x0000000000020000), -(28815,0,0x0000000002000006), -(28818,0,0x0000000020081018), -(28821,0,0x0000000000000400), -(28829,0,0x0000000000000002), -(28831,0,0x0000000000000001), -(28842,0,0x0000000100004440), -(28843,0,0x0000000000088000), -(28844,0,0x0000000000000400), -(28852,0,0x0000000000000200), -(28852,1,0x0000000020000000), -(28855,0,0x0000000000000800), -(28855,1,0x0010000000000000), -(28999,0,0x0000000000000003), -(29000,0,0x0000000000000003), -(29005,0,0x0000000090100003), -(29063,0,0x00000000000009C3), -(29079,0,0x0000000000400000), -(29079,1,0x0000000001000000), -(29079,2,0x0000000000800000), -(29080,0,0x0000000000400000), -(29080,1,0x0000000001000000), -(29080,2,0x0000000000800000), -(29171,0,0x0000000000004000), -(29187,0,0x00000000000001C0), -(29187,1,0x0004103000340750), -(29189,0,0x00000000000001C0), -(29189,1,0x0004103000340750), -(29191,0,0x00000000000001C0), -(29191,1,0x0004103000340750), -(29202,0,0x0000000000000040), -(29205,0,0x0000000000000040), -(29206,0,0x0000000000000040), -(29438,0,0x0000000000D000D7), -(29439,0,0x0000000000D000D7), -(29440,0,0x0000000000D000D7), -(29721,0,0x0000000400000000), -(29723,0,0x0000000800002010), -(29723,1,0x0000000800002010), -(29724,0,0x0000000800002010), -(29724,1,0x0000000800002010), -(29725,0,0x0000000800002010), -(29725,1,0x0000000800002010), -(29759,1,0x0000075D6E6ECEEF), -(29760,1,0x0000075D6E6ECEEF), -(29761,1,0x0000075D6E6ECEEF), -(29762,1,0x0000075D6E6ECEEF), -(29763,1,0x0000075D6E6ECEEF), -(29776,0,0x0000000400000000), -(29787,0,0x0000036C2A764EEF), -(29790,0,0x0000036C2A764EEF), -(29792,0,0x0000036C2A764EEF), -(29836,0,0x0000001000000020), -(29859,0,0x0000001000000020), -(29888,0,0x0000000040000000), -(29889,0,0x0000000040000000), -(29976,0,0x0000000021400035), -(30049,0,0x0000000000080000), -(30051,0,0x0000000000080000), -(30052,0,0x0000000000080000), -(30054,0,0x0000000800000000), -(30057,0,0x0000000800000000), -(30060,0,0x0000001000000402), -(30060,1,0x0000001000000402), -(30060,2,0x0000871B804CC41A), -(30061,0,0x0000001000000402), -(30061,1,0x0000001000000402), -(30061,2,0x0000871B804CC41A), -(30062,0,0x0000001000000402), -(30062,1,0x0000001000000402), -(30062,2,0x0000871B804CC41A), -(30063,0,0x0000001000000402), -(30063,1,0x0000001000000402), -(30063,2,0x0000871B804CC41A), -(30064,0,0x0000001000000402), -(30064,1,0x0000001000000402), -(30064,2,0x0000871B804CC41A), -(30085,0,0x0000071B804CC41A), -(30085,1,0x0000000000000400), -(30085,2,0x0000000000000002), -(30086,0,0x0000071B804CC41A), -(30086,1,0x0000000000000400), -(30086,2,0x0000000000000002), -(30143,0,0x0000002000000000), -(30144,0,0x0000002000000000), -(30145,0,0x0000002000000000), -(30242,0,0x0000200000000000), -(30245,0,0x0000200000000000), -(30246,0,0x0000200000000000), -(30247,0,0x0000200000000000), -(30248,0,0x0000200000000000), -(30251,0,0x000010C000000125), -(30256,0,0x000010C000000125), -(30288,0,0x0000004000000001), -(30289,0,0x0000004000000001), -(30290,0,0x0000004000000001), -(30291,0,0x0000004000000001), -(30292,0,0x0000004000000001), -(30319,1,0x0000400000000000), -(30320,1,0x0000400000000000), -(30321,1,0x0000400000000000), -(30326,0,0x0000000000040010), -(30327,0,0x0000000000040010), -(30328,0,0x0000000000040010), -(30812,0,0x00000C78B018141B), -(30813,0,0x00000C78B018141B), -(30814,0,0x00000C78B018141B), -(30872,0,0x0000000000000100), -(30873,0,0x0000000000000100), -(30892,0,0x0000000008000000), -(30893,0,0x0000000008000000), -(31216,1,0x0000000002000004), -(31217,1,0x0000000002000004), -(31218,1,0x0000000002000004), -(31219,1,0x0000000002000004), -(31220,1,0x0000000002000004), -(31226,0,0x000000000001E000), -(31227,0,0x000000000001E000), -(31234,0,0x000001002612030F), -(31234,1,0x0000000000100100), -(31235,0,0x000001002612030F), -(31235,1,0x0000000000100100), -(31236,0,0x000001002612030F), -(31236,1,0x0000000000100100), -(31237,0,0x000001002612030F), -(31237,1,0x0000000000100100), -(31238,0,0x000001002612030F), -(31238,1,0x0000000000100100), -(31571,0,0x0000000200000000), -(31572,0,0x0000000200000000), -(31573,0,0x0000000200000000), -(31579,0,0x0000000000200000), -(31579,1,0x0000000000000800), -(31582,0,0x0000000000200000), -(31582,1,0x0000000000000800), -(31583,0,0x0000000000200000), -(31583,1,0x0000000000000800), -(31656,0,0x0000000000000001), -(31657,0,0x0000000000000001), -(31658,0,0x0000000000000001), -(31659,0,0x0000000000000001), -(31660,0,0x0000000000000001), -(31670,0,0x0000000500000200), -(31672,0,0x0000000500000200), -(31682,0,0x0000000000000020), -(31682,1,0x0000000000000020), -(31683,0,0x0000000000000020), -(31683,1,0x0000000000000020), -(31684,0,0x0000000000000020), -(31684,1,0x0000000000000020), -(31685,0,0x0000000000000020), -(31685,1,0x0000000000000020), -(31686,0,0x0000000000000020), -(31686,1,0x0000000000000020), -(31821,0,0x0000000004020048), -(31825,0,0x0000000000001020), -(31825,1,0x0000000200000000), -(31826,0,0x0000000000001020), -(31826,1,0x0000000200000000), -(31834,0,0x0000000080000000), -(31844,1,0x000005401A00038C), -(31845,1,0x000005401A00038C), -(31848,0,0x0000000000400000), -(31848,1,0x0000000000400000), -(31849,0,0x0000000000400000), -(31849,1,0x0000000000400000), -(31869,0,0x0000002000000000), -(31870,0,0x0000002000000000), -(31879,0,0x0000000800000400), -(31880,0,0x0000000800000400), -(31881,0,0x0000000800000400), -(31882,0,0x0000000800000400), -(31883,0,0x0000000800000400), -(32043,1,0x000004000A000000), -(32203,1,0x0001100001C22000), -(32381,0,0x0000000000000002), -(32382,0,0x0000000000000002), -(32383,0,0x0000000000000002), -(32412,0,0x0000000000000400), -(32477,0,0x0000020000000000), -(32483,0,0x0000020000000000), -(32484,0,0x0000020000000000), -(32601,1,0x0000000020800008), -(32743,0,0x0000000000000800), -(32973,0,0x0000000090100000), -(33018,0,0x0000001000000000), -(33020,0,0x0000000000000400), -(33063,0,0x0000040000000000), -(33066,0,0x0000000000000002), -(33151,0,0x0000000000000080), -(33151,1,0x0000000000000080), -(33151,2,0x0000000000000080), -(33158,0,0x0000000000001000), -(33158,1,0x0000000000000800), -(33159,0,0x0000000000001000), -(33159,1,0x0000000000000800), -(33160,0,0x0000000000001000), -(33160,1,0x0000000000000800), -(33161,0,0x0000000000001000), -(33161,1,0x0000000000000800), -(33162,0,0x0000000000001000), -(33162,1,0x0000000000000800), -(33167,0,0x0000008100000000), -(33171,0,0x0000008100000000), -(33172,0,0x0000008100000000), -(33174,0,0x0000000000000020), -(33174,1,0x0000000000000020), -(33182,0,0x0000000000000020), -(33182,1,0x0000000000000020), -(33186,0,0x0000008000000000), -(33186,1,0x0000008000002080), -(33190,0,0x0000008000000000), -(33190,1,0x0000008000002080), -(33213,0,0x0000000000822000), -(33214,0,0x0000000000822000), -(33215,0,0x0000000000822000), -(33221,0,0x0000000200002000), -(33222,0,0x0000000200002000), -(33223,0,0x0000000200002000), -(33224,0,0x0000000200002000), -(33225,0,0x0000000200002000), -(33333,0,0x0000000020000000), -(33421,0,0x0000000200000000), -(33557,0,0x0000000000000200), -(33557,1,0x0000000020000000), -(33565,0,0x0000000000001000), -(33600,0,0x0000000000000400), -(33600,1,0x0000000000000400), -(33601,0,0x0000000000000400), -(33601,1,0x0000000000000400), -(33602,0,0x0000000000000400), -(33602,1,0x0000000000000400), -(33603,0,0x0000000000000004), -(33603,1,0x0000000000000001), -(33604,0,0x0000000000000004), -(33604,1,0x0000000000000001), -(33605,0,0x0000000000000004), -(33605,1,0x0000000000000001), -(33606,0,0x0000000000000004), -(33606,1,0x0000000000000001), -(33607,0,0x0000000000000004), -(33607,1,0x0000000000000001), -(33693,0,0x0000000000008000), -(33696,0,0x0000000000000001), -(33713,0,0x0000000200000000), -(33714,0,0x0000000200000000), -(33830,0,0x0000002000000000), -(33830,1,0x0000002000000000), -(33877,0,0x0000000000000002), -(33879,0,0x0000000000000020), -(33880,0,0x0000000000000020), -(33886,0,0x00000010000000D0), -(33887,0,0x00000010000000D0), -(33888,0,0x00000010000000D0), -(33889,0,0x00000010000000D0), -(33890,0,0x00000010000000D0), -(34128,0,0x0000001000000000), -(34129,0,0x0000000040000000), -(34129,1,0x0000000040000000), -(34131,0,0x0000000000000080), -(34131,1,0x0000000000000080), -(34253,0,0x0000010000000000), -(34297,0,0x0000080000000000), -(34300,0,0x0000080000000000), -(34318,0,0x0000000000000400), -(34318,1,0x0000002000000000), -(34323,0,0x0000008000800000), -(34453,1,0x0000000400000000), -(34454,1,0x0000000400000000), -(34455,0,0x0000002000000000), -(34455,1,0x0000004000000000), -(34459,0,0x0000002000000000), -(34459,1,0x0000004000000000), -(34460,0,0x0000002000000000), -(34460,1,0x0000004000000000), -(34462,1,0x0000000800000000), -(34464,1,0x0000000800000000), -(34465,1,0x0000000800000000), -(34466,1,0x0000001000000000), -(34467,1,0x0000001000000000), -(34468,1,0x0000001000000000), -(34469,1,0x0000001000000000), -(34470,1,0x0000001000000000), -(34491,0,0x00004000000000C2), -(34491,1,0x0000000000000080), -(34492,0,0x00004000000000C2), -(34492,1,0x0000000000000080), -(34493,0,0x00004000000000C2), -(34493,1,0x0000000000000080), -(34754,0,0x0000000400001800), -(34936,0,0x0000004000000001), -(34948,1,0x0000000000000020), -(34949,1,0x0000000000000020), -(35029,1,0x0000080000000000), -(35030,1,0x0000080000000000), -(35098,0,0x0000000000020801), -(35099,0,0x0000000000020801), -(35104,0,0x0000000000001000), -(35104,1,0x0000000000002000), -(35110,0,0x0000000000001000), -(35110,1,0x0000000000002000), -(35111,0,0x0000000000001000), -(35111,1,0x0000000000002000), -(35363,0,0x0000000000000005), -(35364,0,0x0000000000000005), -(35396,1,0x000004000A000000), -(35397,1,0x000004000A000000), -(35446,0,0x0000000002000000), -(35446,1,0x0000000002000000), -(35448,0,0x0000000002000000), -(35448,1,0x0000000002000000), -(35449,0,0x0000000002000000), -(35449,1,0x0000000002000000), -(35450,0,0x0000000002000000), -(35450,1,0x0000000002000000), -(35451,0,0x0000000002000000), -(35451,1,0x0000000002000000), -(35578,0,0x0000000028E212F7), -(35581,0,0x0000000028E212F7), -(36032,0,0x0000000020000000), -(36032,1,0x0000000020000000), -(36413,0,0x0000000000000001), -(36563,1,0x0000000000000204), -(36563,2,0x0000000000000100), -(37166,0,0x0000000000800000), -(37167,0,0x0000000000040000), -(37171,0,0x00000009003E0000), -(37180,0,0x0000000000000020), -(37181,0,0x0000000400000000), -(37183,0,0x0000010000000000), -(37184,0,0x0000040008000000), -(37184,1,0x0000040008000000), -(37185,0,0x0000004000000000), -(37186,0,0x0000000020000000), -(37187,0,0x0000020000000000), -(37190,0,0x0000000000000008), -(37191,0,0x0000004000000000), -(37194,0,0x0000000000800000), -(37207,0,0x0000000000000002), -(37209,0,0x0000000000000400), -(37209,1,0x0000002000000000), -(37210,0,0x0000000000004000), -(37211,0,0x0000008000000000), -(37212,0,0x0000010000000000), -(37223,0,0x0000000000010000), -(37224,0,0x0000001000000000), -(37225,0,0x0000000000000080), -(37234,0,0x0000000000000080), -(37240,0,0x0000000000000080), -(37241,0,0x0000020000000000), -(37286,0,0x0000000000000010), -(37287,0,0x0000E000E2000000), -(37292,0,0x0008000000000000), -(37297,0,0x0000100000000000), -(37313,0,0x0000000000000040), -(37314,0,0x0000001000000000), -(37316,0,0x0000000000000040), -(37325,0,0x0000000000000040), -(37333,0,0x0000000000008000), -(37333,1,0x0000010000000000), -(37376,0,0x0000001000000000), -(37380,0,0x0000000000000006), -(37423,0,0x0000000000000004), -(37424,0,0x0000000000008000), -(37438,0,0x0000000000000021), -(37439,0,0x0000002000000000), -(37439,1,0x0000004000000000), -(37439,2,0x0000008000000000), -(37441,0,0x0000000020000000), -(37441,1,0x0000000020000000), -(37447,0,0x0000010000000000), -(37481,0,0x0000000000000080), -(37484,0,0x0000000000000100), -(37485,0,0x0000000000001000), -(37505,0,0x0000000100000000), -(37507,0,0x0000000000000800), -(37508,0,0x0000000100061800), -(37512,0,0x00000080000F0000), -(37513,0,0x0000000000000001), -(37517,0,0x0000014D2A600CEF), -(37518,0,0x0000000400000000), -(37522,0,0x0000000000001000), -(37535,0,0x0000000002000000), -(37536,0,0x0000000000010000), -(37556,0,0x0000000400000000), -(37564,0,0x0000000000000200), -(37565,0,0x0000000000001000), -(37570,1,0x0000010000000000), -(37571,0,0x0000000000000080), -(37571,1,0x0000000000800000), -(37593,0,0x0000000000000040), -(37706,0,0x0000000411041E40), -(37721,0,0x00000010000000F0), -(37722,0,0x00000000000001C0), -(37723,0,0x00000000C0000000), -(37736,0,0x0000040000000000), -(37736,1,0x0000004000000000), -(37737,0,0x0000000000000040), -(37738,0,0x0000000000000040), -(37739,0,0x0000000080000000), -(37740,0,0x0000000000000001), -(37742,0,0x0000004000000000), -(37760,0,0x0000000000000001), -(37762,0,0x0000001000000000), -(37763,0,0x0000800000000000), -(37878,0,0x00000010000000F0), -(37879,0,0x00000000C0000000), -(37880,0,0x0000000411041E40), -(37881,0,0x00000000000001C0), -(38314,0,0x0000E000E2000000), -(38321,0,0x0000000000000020), -(38322,0,0x0000000000000100), -(38388,0,0x0000000000040000), -(38389,0,0x0000000E00000006), -(38392,0,0x0000000100000000), -(38393,0,0x0000000000000001), -(38396,0,0x0000000004000000), -(38397,0,0x0000000000000821), -(38398,0,0x0000000020000000), -(38399,0,0x0000000002000000), -(38407,0,0x0000000100000000), -(38408,0,0x0000008000000000), -(38410,0,0x0000000000000200), -(38411,0,0x0000000000001000), -(38412,0,0x0000000000002000), -(38413,0,0x0000000000008000), -(38414,0,0x0000000000000002), -(38415,0,0x0000000000000004), -(38416,0,0x0010000000800000), -(38416,1,0x0010000000800000), -(38417,0,0x0000000200000000), -(38420,0,0x0000000000000020), -(38421,0,0x0000100000000000), -(38422,0,0x0000000000000020), -(38424,0,0x0000008000000000), -(38425,0,0x0000000040000000), -(38426,0,0x0000000080000000), -(38429,0,0x0000000090100000), -(38434,0,0x0000000000000100), -(38435,0,0x0000000000000080), -(38436,0,0x0000000000000001), -(38447,0,0x0000040000000000), -(38447,1,0x0000004000000000), -(38466,0,0x0008000000000000), -(38499,0,0x0000008000000000), -(38501,0,0x0000000000000080), -(38522,0,0x0000000040000000), -(39805,0,0x0000000000000003), -(39805,1,0x0000000000000003), -(39926,1,0x0000080000000000), -(39926,2,0x0000200000000000), -(39950,0,0x0000000000000040), -(40389,0,0x0000800000000000), -(40460,0,0x00000009003E0000), -(41021,0,0x0000004000000000), -(41021,1,0x0000004000000000), -(41026,0,0x0000004000000000), -(41026,1,0x0000004000000000), -(41037,0,0x0000044000000000), -(41042,0,0x0000000000800000), -(42367,0,0x0000001000000000), -(43339,0,0x0000000090100000), -(43725,0,0x0000001000000000), -(43736,0,0x0000000000000010), -(43743,1,0x0000000008000400), -(43752,0,0x0000000000000100), -(43837,0,0x0000000080000000), -(43840,0,0x0000044000000000), -(43841,0,0x0000000000000002), -(43842,0,0x0000044000000000), -(43843,0,0x0000044000000000), -(43844,0,0x0000000000000002), -(43845,0,0x0000000000000002), -(43850,0,0x0000000000800000), -(43851,0,0x0000000000800000), -(43852,0,0x0000000000800000), -(43854,0,0x0000004000000000), -(43855,0,0x0000004000000000), -(43856,0,0x0000004000000000), -(43857,0,0x0000001000000000), -(43858,0,0x0000001000000000), -(43859,0,0x0000001000000000), -(43860,0,0x0000000090100000), -(43861,0,0x0000000090100000), -(43862,0,0x0000000090100000), -(44292,0,0x0000000000001000), -(44293,0,0x0000000000000200), -(44295,0,0x0000000090100000), -(44296,0,0x0000000000000001), -(44297,0,0x0000000000010000), -(44299,0,0x0000000000040000), -(44300,0,0x0000800000000000), -(44301,0,0x0000000001000000), -(44302,0,0x0000000001000000), -(46088,0,0x0000044000000000), -(46090,0,0x0000000000000002), -(46091,0,0x0000000000800000), -(46095,0,0x0000004000000000), -(46096,0,0x0000001000000000), -(46097,0,0x0000000090100000), -(46100,0,0x0000001000000000), -(46833,0,0x0000000000000004), -(46834,0,0x0000000000000040), -(46851,0,0x0001000000000000); - -/*!40000 ALTER TABLE `spell_affect` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `spell_chain` --- - -DROP TABLE IF EXISTS `spell_chain`; -CREATE TABLE `spell_chain` ( - `spell_id` mediumint(9) NOT NULL default '0', - `prev_spell` mediumint(9) NOT NULL default '0', - `first_spell` mediumint(9) NOT NULL default '0', - `rank` tinyint(4) NOT NULL default '0', - `req_spell` mediumint(9) NOT NULL default '0', - PRIMARY KEY (`spell_id`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Spell Additinal Data'; - --- --- Dumping data for table `spell_chain` --- - -LOCK TABLES `spell_chain` WRITE; -/*!40000 ALTER TABLE `spell_chain` DISABLE KEYS */; -INSERT INTO `spell_chain` VALUES -(10,0,10,1,0), -(17,0,17,1,0), -(53,0,53,1,0), -(72,0,72,1,0), -(78,0,78,1,0), -(99,0,99,1,0), -(100,0,100,1,0), -(116,0,116,1,0), -(118,0,118,1,0), -(120,0,120,1,0), -(122,0,122,1,0), -(133,0,133,1,0), -(136,0,136,1,0), -(139,0,139,1,0), -(143,133,133,2,0), -(145,143,133,3,0), -(168,0,168,1,0), -(172,0,172,1,0), -(205,116,116,2,0), -(284,78,78,2,0), -(285,284,78,3,0), -(324,0,324,1,0), -(325,324,324,2,0), -(331,0,331,1,0), -(332,331,331,2,0), -(339,0,339,1,0), -(348,0,348,1,0), -(370,0,370,1,0), -(403,0,403,1,0), -(408,0,408,1,0), -(421,0,421,1,0), -(453,0,453,1,0), -(465,0,465,1,0), -(467,0,467,1,0), -(469,0,469,1,0), -(498,0,498,1,0), -(527,0,527,1,0), -(529,403,403,2,0), -(543,0,543,1,0), -(547,332,331,3,0), -(548,529,403,3,0), -(585,0,585,1,0), -(586,0,586,1,0), -(587,0,587,1,0), -(588,0,588,1,0), -(589,0,589,1,0), -(591,585,585,2,0), -(592,17,17,2,0), -(594,589,589,2,0), -(596,0,596,1,0), -(597,587,587,2,0), -(598,591,585,3,0), -(600,592,17,3,0), -(602,7128,588,3,0), -(603,0,603,1,0), -(604,0,604,1,0), -(605,0,605,1,0), -(633,0,633,1,0), -(635,0,635,1,0), -(639,635,635,2,0), -(642,0,642,1,0), -(643,10290,465,3,0), -(647,639,635,3,0), -(686,0,686,1,0), -(687,0,687,1,0), -(688,0,688,1,0), -(689,0,689,1,0), -(693,0,693,1,0), -(694,0,694,1,0), -(695,686,686,2,0), -(696,687,687,2,0), -(699,689,689,2,0), -(702,0,702,1,0), -(703,0,703,1,0), -(704,0,704,1,0), -(705,695,686,3,0), -(706,0,706,1,0), -(707,348,348,2,0), -(709,699,689,3,0), -(710,0,710,1,0), -(724,0,724,1,0), -(740,0,740,1,0), -(755,0,755,1,0), -(769,780,779,3,0), -(770,0,770,1,0), -(772,0,772,1,0), -(774,0,774,1,0), -(778,770,770,2,0), -(779,0,779,1,0), -(780,779,779,2,0), -(781,0,781,1,0), -(782,467,467,2,0), -(837,205,116,3,0), -(845,0,845,1,0), -(853,0,853,1,0), -(865,122,122,2,0), -(879,0,879,1,0), -(905,325,324,3,0), -(913,547,331,4,0), -(915,548,403,4,0), -(930,421,421,2,0), -(939,913,331,5,0), -(943,915,403,5,0), -(945,905,324,4,0), -(959,939,331,6,0), -(970,594,589,3,0), -(974,0,974,1,0), -(976,0,976,1,0), -(980,0,980,1,0), -(984,598,585,4,0), -(988,527,527,2,0), -(990,597,587,3,0), -(992,970,589,4,0), -(996,596,596,2,0), -(1004,984,585,5,0), -(1006,602,588,4,0), -(1008,0,1008,1,0), -(1014,980,980,2,0), -(1020,642,642,2,0), -(1022,0,1022,1,0), -(1026,647,635,4,0), -(1032,10291,465,5,0), -(1038,0,1038,1,0), -(1042,1026,635,5,0), -(1058,774,774,2,0), -(1062,339,339,2,0), -(1064,0,1064,1,0), -(1075,782,467,3,0), -(1079,0,1079,1,0), -(1082,0,1082,1,0), -(1086,706,706,2,0), -(1088,705,686,4,0), -(1094,707,348,3,0), -(1098,0,1098,1,0), -(1106,1088,686,5,0), -(1108,702,702,2,0), -(1120,0,1120,1,0), -(1126,0,1126,1,0), -(1130,0,1130,1,0), -(1160,0,1160,1,0), -(1243,0,1243,1,0), -(1244,1243,1243,2,0), -(1245,1244,1243,3,0), -(1329,0,1329,1,0), -(1430,1058,774,3,0), -(1449,0,1449,1,0), -(1454,0,1454,1,0), -(1455,1454,1454,2,0), -(1456,1455,1454,3,0), -(1459,0,1459,1,0), -(1460,1459,1459,2,0), -(1461,1460,1459,3,0), -(1463,0,1463,1,0), -(1464,0,1464,1,0), -(1490,0,1490,1,0), -(1495,0,1495,1,0), -(1499,0,1499,1,0), -(1510,0,1510,1,0), -(1513,0,1513,1,0), -(1535,0,1535,1,0), -(1608,285,78,4,0), -(1671,72,72,2,0), -(1672,1671,72,3,0), -(1714,0,1714,1,0), -(1715,0,1715,1,0), -(1735,99,99,2,0), -(1742,0,1742,1,0), -(1752,0,1752,1,0), -(1753,1742,1742,2,0), -(1754,1753,1742,3,0), -(1755,1754,1742,4,0), -(1756,1755,1742,5,0), -(1757,1752,1752,2,0), -(1758,1757,1752,3,0), -(1759,1758,1752,4,0), -(1760,1759,1752,5,0), -(1766,0,1766,1,0), -(1767,1766,1766,2,0), -(1768,1767,1766,3,0), -(1769,1768,1766,4,0), -(1776,0,1776,1,0), -(1777,1776,1776,2,0), -(1784,0,1784,1,0), -(1785,1784,1784,2,0), -(1786,1785,1784,3,0), -(1787,1786,1784,4,0), -(1804,0,1804,1,0), -(1822,0,1822,1,0), -(1823,1822,1822,2,0), -(1824,1823,1822,3,0), -(1850,0,1850,1,0), -(1856,0,1856,1,0), -(1857,1856,1856,2,0), -(1943,0,1943,1,0), -(1949,0,1949,1,0), -(1966,0,1966,1,0), -(1978,0,1978,1,0), -(2006,0,2006,1,0), -(2008,0,2008,1,0), -(2010,2006,2006,2,0), -(2018,0,2018,1,0), -(2048,25289,6673,8,0), -(2050,0,2050,1,0), -(2052,2050,2050,2,0), -(2053,2052,2050,3,0), -(2054,0,2054,1,0), -(2055,2054,2054,2,0), -(2060,0,2060,1,0), -(2061,0,2061,1,0), -(2062,0,2062,1,0), -(2070,6770,6770,2,0), -(2090,1430,774,4,0), -(2091,2090,774,5,0), -(2096,0,2096,1,0), -(2098,0,2098,1,0), -(2108,0,2108,1,0), -(2120,0,2120,1,0), -(2121,2120,2120,2,0), -(2136,0,2136,1,0), -(2137,2136,2136,2,0), -(2138,2137,2136,3,0), -(2259,0,2259,1,0), -(2362,0,2362,1,0), -(2366,0,2366,1,0), -(2368,2366,2366,2,0), -(2550,0,2550,1,0), -(2575,0,2575,1,0), -(2576,2575,2575,2,0), -(2589,53,53,2,0), -(2590,2589,53,3,0), -(2591,2590,53,4,0), -(2637,0,2637,1,0), -(2643,0,2643,1,0), -(2649,0,2649,1,0), -(2651,0,2651,1,0), -(2652,0,2652,1,0), -(2767,992,589,5,0), -(2791,1245,1243,4,0), -(2800,633,633,2,0), -(2812,0,2812,1,0), -(2825,0,2825,1,0), -(2835,0,2835,1,0), -(2837,2835,2835,2,0), -(2860,930,421,3,0), -(2878,0,2878,1,0), -(2894,0,2894,1,0), -(2908,0,2908,1,0), -(2912,0,2912,1,0), -(2941,1094,348,4,0), -(2944,0,2944,1,0), -(2947,0,2947,1,0), -(2948,0,2948,1,0), -(2973,0,2973,1,0), -(2974,0,2974,1,0), -(2983,0,2983,1,0), -(3009,3010,16827,8,0), -(3010,16832,16827,7,0), -(3029,1082,1082,2,0), -(3034,0,3034,1,0), -(3044,0,3044,1,0), -(3100,2018,2018,2,0), -(3101,2259,2259,2,0), -(3102,2550,2550,2,0), -(3104,2108,2108,2,0), -(3110,0,3110,1,0), -(3111,136,136,2,0), -(3140,145,133,4,0), -(3273,0,3273,1,0), -(3274,3273,3273,2,0), -(3413,3102,2550,3,0), -(3420,0,3420,1,0), -(3421,3420,3420,2,0), -(3464,3101,2259,3,0), -(3472,1042,635,6,0), -(3538,3100,2018,3,0), -(3564,2576,2575,3,0), -(3570,2368,2366,3,0), -(3599,0,3599,1,0), -(3627,2091,774,6,0), -(3661,3111,136,3,0), -(3662,3661,136,4,0), -(3698,755,755,2,0), -(3699,3698,755,3,0), -(3700,3699,755,4,0), -(3716,0,3716,1,0), -(3738,0,3738,1,0), -(3747,600,17,4,0), -(3811,3104,2108,3,0), -(3908,0,3908,1,0), -(3909,3908,3908,2,0), -(3910,3909,3908,3,0), -(4036,0,4036,1,0), -(4037,4036,4036,2,0), -(4038,4037,4036,3,0), -(4187,0,4187,1,0), -(4188,4187,4187,2,0), -(4189,4188,4187,3,0), -(4190,4189,4187,4,0), -(4191,4190,4187,5,0), -(4192,4191,4187,6,0), -(4193,4192,4187,7,0), -(4194,4193,4187,8,0), -(5041,4194,4187,9,0), -(5042,5041,4187,10,0), -(5138,0,5138,1,0), -(5143,0,5143,1,0), -(5144,5143,5143,2,0), -(5145,5144,5143,3,0), -(5171,0,5171,1,0), -(5176,0,5176,1,0), -(5177,5176,5176,2,0), -(5178,5177,5176,3,0), -(5179,5178,5176,4,0), -(5180,5179,5176,5,0), -(5185,0,5185,1,0), -(5186,5185,5185,2,0), -(5187,5186,5185,3,0), -(5188,5187,5185,4,0), -(5189,5188,5185,5,0), -(5195,1062,339,3,0), -(5196,5195,339,4,0), -(5201,3029,1082,3,0), -(5211,0,5211,1,0), -(5215,0,5215,1,0), -(5217,0,5217,1,0), -(5221,0,5221,1,0), -(5232,1126,1126,2,0), -(5234,6756,1126,4,0), -(5242,6673,6673,2,0), -(5277,0,5277,1,0), -(5308,0,5308,1,0), -(5394,0,5394,1,0), -(5484,0,5484,1,0), -(5487,0,5487,1,0), -(5504,0,5504,1,0), -(5505,5504,5504,2,0), -(5506,5505,5504,3,0), -(5570,0,5570,1,0), -(5573,498,498,2,0), -(5588,853,853,2,0), -(5589,5588,853,3,0), -(5599,1022,1022,2,0), -(5614,879,879,2,0), -(5615,5614,879,3,0), -(5627,2878,2878,2,0), -(5675,0,5675,1,0), -(5676,0,5676,1,0), -(5699,6202,6201,3,0), -(5730,0,5730,1,0), -(5740,0,5740,1,0), -(5763,0,5763,1,0), -(5782,0,5782,1,0), -(5938,0,5938,1,0), -(6041,943,403,6,0), -(6060,1004,585,6,0), -(6063,2055,2054,3,0), -(6064,6063,2054,4,0), -(6065,3747,17,5,0), -(6066,6065,17,6,0), -(6074,139,139,2,0), -(6075,6074,139,3,0), -(6076,6075,139,4,0), -(6077,6076,139,5,0), -(6078,6077,139,6,0), -(6117,0,6117,1,0), -(6127,5506,5504,4,0), -(6129,990,587,4,0), -(6131,865,122,3,0), -(6141,10,10,2,0), -(6143,0,6143,1,0), -(6178,100,100,2,0), -(6190,1160,1160,2,0), -(6192,5242,6673,3,0), -(6201,0,6201,1,0), -(6202,6201,6201,2,0), -(6205,1108,702,3,0), -(6213,5782,5782,2,0), -(6215,6213,5782,3,0), -(6217,1014,980,3,0), -(6219,5740,5740,2,0), -(6222,172,172,2,0), -(6223,6222,172,3,0), -(6226,5138,5138,2,0), -(6229,0,6229,1,0), -(6307,0,6307,1,0), -(6343,0,6343,1,0), -(6353,0,6353,1,0), -(6360,0,6360,1,0), -(6363,3599,3599,2,0), -(6364,6363,3599,3,0), -(6365,6364,3599,4,0), -(6366,0,6366,1,0), -(6375,5394,5394,2,0), -(6377,6375,5394,3,0), -(6390,5730,5730,2,0), -(6391,6390,5730,3,0), -(6392,6391,5730,4,0), -(6542,0,6542,1,0), -(6546,772,772,2,0), -(6547,6546,772,3,0), -(6548,6547,772,4,0), -(6552,0,6552,1,0), -(6554,6552,6552,2,0), -(6572,0,6572,1,0), -(6574,6572,6572,2,0), -(6673,0,6673,1,0), -(6756,5232,1126,3,0), -(6760,2098,2098,2,0), -(6761,6760,2098,3,0), -(6762,6761,2098,4,0), -(6768,1966,1966,2,0), -(6770,0,6770,1,0), -(6774,5171,5171,2,0), -(6778,5189,5185,6,0), -(6780,5180,5176,6,0), -(6783,5215,5215,2,0), -(6785,0,6785,1,0), -(6787,6785,6785,2,0), -(6789,0,6789,1,0), -(6793,5217,5217,2,0), -(6798,5211,5211,2,0), -(6800,5221,5221,2,0), -(6807,0,6807,1,0), -(6808,6807,6807,2,0), -(6809,6808,6807,3,0), -(6940,0,6940,1,0), -(7128,588,588,2,0), -(7294,0,7294,1,0), -(7300,168,168,2,0), -(7301,7300,168,3,0), -(7302,0,7302,1,0), -(7320,7302,7302,2,0), -(7322,837,116,4,0), -(7328,0,7328,1,0), -(7369,845,845,2,0), -(7371,0,7371,1,0), -(7372,1715,1715,2,0), -(7373,7372,1715,3,0), -(7379,6574,6572,3,0), -(7384,0,7384,1,0), -(7386,0,7386,1,0), -(7400,694,694,2,0), -(7402,7400,694,3,0), -(7405,7386,7386,2,0), -(7411,0,7411,1,0), -(7412,7411,7411,2,0), -(7413,7412,7411,3,0), -(7620,0,7620,1,0), -(7641,1106,686,6,0), -(7646,6205,702,4,0), -(7648,6223,172,4,0), -(7651,709,689,4,0), -(7658,704,704,2,0), -(7659,7658,704,3,0), -(7731,7620,7620,2,0), -(7732,7731,7620,3,0), -(7799,3110,3110,2,0), -(7800,7799,3110,3,0), -(7801,7800,3110,4,0), -(7802,7801,3110,5,0), -(7804,6307,6307,2,0), -(7805,7804,6307,3,0), -(7809,3716,3716,2,0), -(7810,7809,3716,3,0), -(7811,7810,3716,4,0), -(7812,0,7812,1,0), -(7813,6360,6360,2,0), -(7814,0,7814,1,0), -(7815,7814,7814,2,0), -(7816,7815,7814,3,0), -(7887,7384,7384,2,0), -(7924,3274,3273,3,0), -(8004,0,8004,1,0), -(8005,959,331,7,0), -(8008,8004,8004,2,0), -(8010,8008,8004,3,0), -(8012,370,370,2,0), -(8017,0,8017,1,0), -(8018,8017,8017,2,0), -(8019,8018,8017,3,0), -(8024,0,8024,1,0), -(8027,8024,8024,2,0), -(8030,8027,8024,3,0), -(8033,0,8033,1,0), -(8038,8033,8033,2,0), -(8042,0,8042,1,0), -(8044,8042,8042,2,0), -(8045,8044,8042,3,0), -(8046,8045,8042,4,0), -(8050,0,8050,1,0), -(8052,8050,8050,2,0), -(8053,8052,8050,3,0), -(8056,0,8056,1,0), -(8058,8056,8056,2,0), -(8071,0,8071,1,0), -(8075,0,8075,1,0), -(8092,0,8092,1,0), -(8102,8092,8092,2,0), -(8103,8102,8092,3,0), -(8104,8103,8092,4,0), -(8105,8104,8092,5,0), -(8106,8105,8092,6,0), -(8122,0,8122,1,0), -(8124,8122,8122,2,0), -(8129,0,8129,1,0), -(8131,8129,8129,2,0), -(8134,945,324,5,0), -(8154,8071,8071,2,0), -(8155,8154,8071,3,0), -(8160,8075,8075,2,0), -(8161,8160,8075,3,0), -(8181,0,8181,1,0), -(8184,0,8184,1,0), -(8190,0,8190,1,0), -(8192,453,453,2,0), -(8198,6343,6343,2,0), -(8204,8198,6343,3,0), -(8205,8204,6343,4,0), -(8227,0,8227,1,0), -(8232,0,8232,1,0), -(8235,8232,8232,2,0), -(8249,8227,8227,2,0), -(8288,1120,1120,2,0), -(8289,8288,1120,3,0), -(8316,2947,2947,2,0), -(8317,8316,2947,3,0), -(8380,7405,7386,3,0), -(8400,3140,133,5,0), -(8401,8400,133,6,0), -(8402,8401,133,7,0), -(8406,7322,116,5,0), -(8407,8406,116,6,0), -(8408,8407,116,7,0), -(8412,2138,2136,4,0), -(8413,8412,2136,5,0), -(8416,5145,5143,4,0), -(8417,8416,5143,5,0), -(8422,2121,2120,3,0), -(8423,8422,2120,4,0), -(8427,6141,10,3,0), -(8437,1449,1449,2,0), -(8438,8437,1449,3,0), -(8439,8438,1449,4,0), -(8444,2948,2948,2,0), -(8445,8444,2948,3,0), -(8446,8445,2948,4,0), -(8450,604,604,2,0), -(8451,8450,604,3,0), -(8455,1008,1008,2,0), -(8457,543,543,2,0), -(8458,8457,543,3,0), -(8461,6143,6143,2,0), -(8462,8461,6143,3,0), -(8492,120,120,2,0), -(8494,1463,1463,2,0), -(8495,8494,1463,3,0), -(8498,1535,1535,2,0), -(8499,8498,1535,3,0), -(8512,0,8512,1,0), -(8613,0,8613,1,0), -(8617,8613,8613,2,0), -(8618,8617,8613,3,0), -(8621,1760,1752,6,0), -(8623,6762,2098,5,0), -(8624,8623,2098,6,0), -(8629,1777,1776,3,0), -(8631,703,703,2,0), -(8632,8631,703,3,0), -(8633,8632,703,4,0), -(8637,6768,1966,3,0), -(8639,1943,1943,2,0), -(8640,8639,1943,3,0), -(8643,408,408,2,0), -(8647,0,8647,1,0), -(8649,8647,8647,2,0), -(8650,8649,8647,3,0), -(8676,0,8676,1,0), -(8681,0,8681,1,0), -(8687,8681,8681,2,0), -(8691,8687,8681,3,0), -(8694,5763,5763,2,0), -(8696,2983,2983,2,0), -(8721,2591,53,5,0), -(8724,8676,8676,2,0), -(8725,8724,8676,3,0), -(8820,1464,1464,2,0), -(8835,0,8835,1,0), -(8903,6778,5185,7,0), -(8905,6780,5176,7,0), -(8907,5234,1126,5,0), -(8910,3627,774,7,0), -(8914,1075,467,4,0), -(8918,740,740,2,0), -(8921,0,8921,1,0), -(8924,8921,8921,2,0), -(8925,8924,8921,3,0), -(8926,8925,8921,4,0), -(8927,8926,8921,5,0), -(8928,8927,8921,6,0), -(8929,8928,8921,7,0), -(8936,0,8936,1,0), -(8938,8936,8936,2,0), -(8939,8938,8936,3,0), -(8940,8939,8936,4,0), -(8941,8940,8936,5,0), -(8949,2912,2912,2,0), -(8950,8949,2912,3,0), -(8951,8950,2912,4,0), -(8955,2908,2908,2,0), -(8972,6809,6807,4,0), -(8983,6798,5211,3,0), -(8992,6800,5221,3,0), -(8998,0,8998,1,0), -(9000,8998,8998,2,0), -(9005,0,9005,1,0), -(9035,0,9035,1,0), -(9472,2061,2061,2,0), -(9473,9472,2061,3,0), -(9474,9473,2061,4,0), -(9484,0,9484,1,0), -(9485,9484,9484,2,0), -(9490,1735,99,3,0), -(9492,1079,1079,2,0), -(9493,9492,1079,3,0), -(9578,586,586,2,0), -(9579,9578,586,3,0), -(9592,9579,586,4,0), -(9634,5487,5487,2,0), -(9745,8972,6807,5,0), -(9747,9490,99,4,0), -(9749,778,770,3,0), -(9750,8941,8936,6,0), -(9752,9493,1079,4,0), -(9754,769,779,4,0), -(9756,8914,467,5,0), -(9758,8903,5185,8,0), -(9785,3538,2018,4,0), -(9787,9785,2018,5,0), -(9788,9785,2018,5,0), -(9821,1850,1850,2,0), -(9823,9005,9005,2,0), -(9827,9823,9005,3,0), -(9829,8992,5221,4,0), -(9830,9829,5221,5,0), -(9833,8929,8921,8,0), -(9834,9833,8921,9,0), -(9835,9834,8921,10,0), -(9839,8910,774,8,0), -(9840,9839,774,9,0), -(9841,9840,774,10,0), -(9845,6793,5217,3,0), -(9846,9845,5217,4,0), -(9849,5201,1082,4,0), -(9850,9849,1082,5,0), -(9852,5196,339,5,0), -(9853,9852,339,6,0), -(9856,9750,8936,7,0), -(9857,9856,8936,8,0), -(9858,9857,8936,9,0), -(9862,8918,740,3,0), -(9863,9862,740,4,0), -(9866,6787,6785,3,0), -(9867,9866,6785,4,0), -(9875,8951,2912,5,0), -(9876,9875,2912,6,0), -(9880,9745,6807,6,0), -(9881,9880,6807,7,0), -(9884,8907,1126,6,0), -(9885,9884,1126,7,0), -(9888,9758,5185,9,0), -(9889,9888,5185,10,0), -(9892,9000,8998,3,0), -(9894,9752,1079,5,0), -(9896,9894,1079,6,0), -(9898,9747,99,5,0), -(9901,8955,2908,3,0), -(9904,1824,1822,4,0), -(9907,9749,770,4,0), -(9908,9754,779,5,0), -(9910,9756,467,6,0), -(9912,8905,5176,8,0), -(9913,6783,5215,3,0), -(10138,6127,5504,5,0), -(10139,10138,5504,6,0), -(10140,10139,5504,7,0), -(10144,6129,587,5,0), -(10145,10144,587,6,0), -(10148,8402,133,8,0), -(10149,10148,133,9,0), -(10150,10149,133,10,0), -(10151,10150,133,11,0), -(10156,1461,1459,4,0), -(10157,10156,1459,5,0), -(10159,8492,120,3,0), -(10160,10159,120,4,0), -(10161,10160,120,5,0), -(10169,8455,1008,3,0), -(10170,10169,1008,4,0), -(10173,8451,604,4,0), -(10174,10173,604,5,0), -(10177,8462,6143,4,0), -(10179,8408,116,8,0), -(10180,10179,116,9,0), -(10181,10180,116,10,0), -(10185,8427,10,4,0), -(10186,10185,10,5,0), -(10187,10186,10,6,0), -(10191,8495,1463,4,0), -(10192,10191,1463,5,0), -(10193,10192,1463,6,0), -(10197,8413,2136,6,0), -(10199,10197,2136,7,0), -(10201,8439,1449,5,0), -(10202,10201,1449,6,0), -(10205,8446,2948,5,0), -(10206,10205,2948,6,0), -(10207,10206,2948,7,0), -(10211,8417,5143,6,0), -(10212,10211,5143,7,0), -(10215,8423,2120,5,0), -(10216,10215,2120,6,0), -(10219,7320,7302,3,0), -(10220,10219,7302,4,0), -(10223,8458,543,4,0), -(10225,10223,543,5,0), -(10230,6131,122,4,0), -(10248,3564,2575,4,0), -(10278,5599,1022,3,0), -(10290,465,465,2,0), -(10291,643,465,4,0), -(10292,1032,465,6,0), -(10293,10292,465,7,0), -(10298,7294,7294,2,0), -(10299,10298,7294,3,0), -(10300,10299,7294,4,0), -(10301,10300,7294,5,0), -(10308,5589,853,4,0), -(10310,2800,633,3,0), -(10312,5615,879,4,0), -(10313,10312,879,5,0), -(10314,10313,879,6,0), -(10318,2812,2812,2,0), -(10322,7328,7328,2,0), -(10324,10322,7328,3,0), -(10326,5627,2878,3,0), -(10328,3472,635,7,0), -(10329,10328,635,8,0), -(10391,6041,403,7,0), -(10392,10391,403,8,0), -(10395,8005,331,8,0), -(10396,10395,331,9,0), -(10399,8019,8017,4,0), -(10406,8155,8071,4,0), -(10407,10406,8071,5,0), -(10408,10407,8071,6,0), -(10412,8046,8042,5,0), -(10413,10412,8042,6,0), -(10414,10413,8042,7,0), -(10427,6392,5730,5,0), -(10428,10427,5730,6,0), -(10431,8134,324,6,0), -(10432,10431,324,7,0), -(10437,6365,3599,5,0), -(10438,10437,3599,6,0), -(10442,8161,8075,4,0), -(10447,8053,8050,4,0), -(10448,10447,8050,5,0), -(10456,8038,8033,3,0), -(10462,6377,5394,4,0), -(10463,10462,5394,5,0), -(10466,8010,8004,4,0), -(10467,10466,8004,5,0), -(10468,10467,8004,6,0), -(10472,8058,8056,3,0), -(10473,10472,8056,4,0), -(10478,8181,8181,2,0), -(10479,10478,8181,3,0), -(10486,8235,8232,3,0), -(10495,5675,5675,2,0), -(10496,10495,5675,3,0), -(10497,10496,5675,4,0), -(10526,8249,8227,3,0), -(10537,8184,8184,2,0), -(10538,10537,8184,3,0), -(10585,8190,8190,2,0), -(10586,10585,8190,3,0), -(10587,10586,8190,4,0), -(10595,0,10595,1,0), -(10600,10595,10595,2,0), -(10601,10600,10595,3,0), -(10605,2860,421,4,0), -(10613,8512,8512,2,0), -(10614,10613,8512,3,0), -(10622,1064,1064,2,0), -(10623,10622,1064,3,0), -(10627,8835,8835,2,0), -(10656,10662,2108,5,0), -(10658,10662,2108,5,0), -(10660,10662,2108,5,0), -(10662,3811,2108,4,0), -(10768,8618,8613,4,0), -(10797,0,10797,1,0), -(10846,7924,3273,4,0), -(10874,8131,8129,3,0), -(10875,10874,8129,4,0), -(10876,10875,8129,5,0), -(10880,2010,2006,3,0), -(10881,10880,2006,4,0), -(10888,8124,8122,3,0), -(10890,10888,8122,4,0), -(10892,2767,589,6,0), -(10893,10892,589,7,0), -(10894,10893,589,8,0), -(10898,6066,17,7,0), -(10899,10898,17,8,0), -(10900,10899,17,9,0), -(10901,10900,17,10,0), -(10909,2096,2096,2,0), -(10911,605,605,2,0), -(10912,10911,605,3,0), -(10915,9474,2061,5,0), -(10916,10915,2061,6,0), -(10917,10916,2061,7,0), -(10927,6078,139,7,0), -(10928,10927,139,8,0), -(10929,10928,139,9,0), -(10933,6060,585,7,0), -(10934,10933,585,8,0), -(10937,2791,1243,5,0), -(10938,10937,1243,6,0), -(10941,9592,586,5,0), -(10942,10941,586,6,0), -(10945,8106,8092,7,0), -(10946,10945,8092,8,0), -(10947,10946,8092,9,0), -(10951,1006,588,5,0), -(10952,10951,588,6,0), -(10953,8192,453,3,0), -(10955,9485,9484,3,0), -(10957,976,976,2,0), -(10958,10957,976,3,0), -(10960,996,596,3,0), -(10961,10960,596,4,0), -(10963,2060,2060,2,0), -(10964,10963,2060,3,0), -(10965,10964,2060,4,0), -(11113,0,11113,1,0), -(11197,8650,8647,4,0), -(11198,11197,8647,5,0), -(11267,8725,8676,4,0), -(11268,11267,8676,5,0), -(11269,11268,8676,6,0), -(11273,8640,1943,4,0), -(11274,11273,1943,5,0), -(11275,11274,1943,6,0), -(11279,8721,53,6,0), -(11280,11279,53,7,0), -(11281,11280,53,8,0), -(11285,8629,1776,4,0), -(11286,11285,1776,5,0), -(11289,8633,703,5,0), -(11290,11289,703,6,0), -(11293,8621,1752,7,0), -(11294,11293,1752,8,0), -(11297,2070,6770,3,0), -(11299,8624,2098,7,0), -(11300,11299,2098,8,0), -(11303,8637,1966,4,0), -(11305,8696,2983,3,0), -(11314,8499,1535,4,0), -(11315,11314,1535,5,0), -(11341,8691,8681,4,0), -(11342,11341,8681,5,0), -(11343,11342,8681,6,0), -(11357,2837,2835,3,0), -(11358,11357,2835,4,0), -(11366,0,11366,1,0), -(11400,8694,5763,3,0), -(11426,0,11426,1,0), -(11549,6192,6673,4,0), -(11550,11549,6673,5,0), -(11551,11550,6673,6,0), -(11554,6190,1160,3,0), -(11555,11554,1160,4,0), -(11556,11555,1160,5,0), -(11564,1608,78,5,0), -(11565,11564,78,6,0), -(11566,11565,78,7,0), -(11567,11566,78,8,0), -(11572,6548,772,5,0), -(11573,11572,772,6,0), -(11574,11573,772,7,0), -(11578,6178,100,3,0), -(11580,8205,6343,5,0), -(11581,11580,6343,6,0), -(11584,7887,7384,3,0), -(11585,11584,7384,4,0), -(11596,8380,7386,4,0), -(11597,11596,7386,5,0), -(11600,7379,6572,4,0), -(11601,11600,6572,5,0), -(11604,8820,1464,3,0), -(11605,11604,1464,4,0), -(11608,7369,845,3,0), -(11609,11608,845,4,0), -(11611,3464,2259,4,0), -(11659,7641,686,7,0), -(11660,11659,686,8,0), -(11661,11660,686,9,0), -(11665,2941,348,5,0), -(11667,11665,348,6,0), -(11668,11667,348,7,0), -(11671,7648,172,5,0), -(11672,11671,172,6,0), -(11675,8289,1120,4,0), -(11677,6219,5740,3,0), -(11678,11677,5740,4,0), -(11683,1949,1949,2,0), -(11684,11683,1949,3,0), -(11687,1456,1454,4,0), -(11688,11687,1454,5,0), -(11689,11688,1454,6,0), -(11693,3700,755,5,0), -(11694,11693,755,6,0), -(11695,11694,755,7,0), -(11699,7651,689,5,0), -(11700,11699,689,6,0), -(11703,6226,5138,3,0), -(11704,11703,5138,4,0), -(11707,7646,702,5,0), -(11708,11707,702,6,0), -(11711,6217,980,4,0), -(11712,11711,980,5,0), -(11713,11712,980,6,0), -(11717,7659,704,4,0), -(11719,1714,1714,2,0), -(11721,1490,1490,2,0), -(11722,11721,1490,3,0), -(11725,1098,1098,2,0), -(11726,11725,1098,3,0), -(11729,5699,6201,4,0), -(11730,11729,6201,5,0), -(11733,1086,706,3,0), -(11734,11733,706,4,0), -(11735,11734,706,5,0), -(11739,6229,6229,2,0), -(11740,11739,6229,3,0), -(11762,7802,3110,6,0), -(11763,11762,3110,7,0), -(11766,7805,6307,4,0), -(11767,11766,6307,5,0), -(11770,8317,2947,4,0), -(11771,11770,2947,5,0), -(11774,7811,3716,5,0), -(11775,11774,3716,6,0), -(11778,7816,7814,4,0), -(11779,11778,7814,5,0), -(11780,11779,7814,6,0), -(11784,7813,6360,3,0), -(11785,11784,6360,4,0), -(11993,3570,2366,4,0), -(12180,3910,3908,4,0), -(12656,4038,4036,4,0), -(12294,0,12294,1,0), -(12505,11366,11366,2,0), -(12522,12505,11366,3,0), -(12523,12522,11366,4,0), -(12524,12523,11366,5,0), -(12525,12524,11366,6,0), -(12526,12525,11366,7,0), -(12824,118,118,2,0), -(12825,12824,118,3,0), -(12826,12825,118,4,0), -(13018,11113,11113,2,0), -(13019,13018,11113,3,0), -(13020,13019,11113,4,0), -(13021,13020,11113,5,0), -(13031,11426,11426,2,0), -(13032,13031,11426,3,0), -(13033,13032,11426,4,0), -(13165,0,13165,1,0), -(13220,0,13220,1,0), -(13228,13220,13220,2,0), -(13229,13228,13220,3,0), -(13230,13229,13220,4,0), -(13542,3662,136,5,0), -(13543,13542,136,6,0), -(13544,13543,136,7,0), -(13549,1978,1978,2,0), -(13550,13549,1978,3,0), -(13551,13550,1978,4,0), -(13552,13551,1978,5,0), -(13553,13552,1978,6,0), -(13554,13553,1978,7,0), -(13555,13554,1978,8,0), -(13795,0,13795,1,0), -(13813,0,13813,1,0), -(13896,0,13896,1,0), -(13908,0,13908,1,0), -(13920,7413,7411,4,0), -(14260,2973,2973,2,0), -(14261,14260,2973,3,0), -(14262,14261,2973,4,0), -(14263,14262,2973,5,0), -(14264,14263,2973,6,0), -(14265,14264,2973,7,0), -(14266,14265,2973,8,0), -(14267,2974,2974,2,0), -(14268,14267,2974,3,0), -(14269,1495,1495,2,0), -(14270,14269,1495,3,0), -(14271,14270,1495,4,0), -(14272,781,781,2,0), -(14273,14272,781,3,0), -(14274,20736,20736,2,0), -(14279,3034,3034,2,0), -(14280,14279,3034,3,0), -(14281,3044,3044,2,0), -(14282,14281,3044,3,0), -(14283,14282,3044,4,0), -(14284,14283,3044,5,0), -(14285,14284,3044,6,0), -(14286,14285,3044,7,0), -(14287,14286,3044,8,0), -(14288,2643,2643,2,0), -(14289,14288,2643,3,0), -(14290,14289,2643,4,0), -(14294,1510,1510,2,0), -(14295,14294,1510,3,0), -(14302,13795,13795,2,0), -(14303,14302,13795,3,0), -(14304,14303,13795,4,0), -(14305,14304,13795,5,0), -(14310,1499,1499,2,0), -(14311,14310,1499,3,0), -(14316,13813,13813,2,0), -(14317,14316,13813,3,0), -(14318,13165,13165,2,0), -(14319,14318,13165,3,0), -(14320,14319,13165,4,0), -(14321,14320,13165,5,0), -(14322,14321,13165,6,0), -(14323,1130,1130,2,0), -(14324,14323,1130,3,0), -(14325,14324,1130,4,0), -(14326,1513,1513,2,0), -(14327,14326,1513,3,0), -(14752,0,14752,1,0), -(14818,14752,14752,2,0), -(14819,14818,14752,3,0), -(14914,0,14914,1,0), -(14916,2649,2649,2,0), -(14917,14916,2649,3,0), -(14918,14917,2649,4,0), -(14919,14918,2649,5,0), -(14920,14919,2649,6,0), -(14921,14920,2649,7,0), -(15107,0,15107,1,0), -(15111,15107,15107,2,0), -(15112,15111,15107,3,0), -(15207,10392,403,9,0), -(15208,15207,403,10,0), -(15237,0,15237,1,0), -(15261,15267,14914,8,0), -(15262,14914,14914,2,0), -(15263,15262,14914,3,0), -(15264,15263,14914,4,0), -(15265,15264,14914,5,0), -(15266,15265,14914,6,0), -(15267,15266,14914,7,0), -(15407,0,15407,1,0), -(15430,15237,15237,2,0), -(15431,15430,15237,3,0), -(15629,14274,20736,3,0), -(15630,15629,20736,4,0), -(15631,15630,20736,5,0), -(15632,15631,20736,6,0), -(16314,10399,8017,5,0), -(16315,16314,8017,6,0), -(16316,16315,8017,7,0), -(16339,8030,8024,4,0), -(16341,16339,8024,5,0), -(16342,16341,8024,6,0), -(16355,10456,8033,4,0), -(16356,16355,8033,5,0), -(16362,10486,8232,4,0), -(16387,10526,8227,4,0), -(16511,0,16511,1,0), -(16689,0,16689,1,339), -(16697,1756,1742,6,0), -(16810,16689,16689,2,1062), -(16811,16810,16689,3,5195), -(16812,16811,16689,4,5196), -(16813,16812,16689,5,9852), -(16827,0,16827,1,0), -(16828,16827,16827,2,0), -(16829,16828,16827,3,0), -(16830,16829,16827,4,0), -(16831,16830,16827,5,0), -(16832,16831,16827,6,0), -(16857,0,16857,1,0), -(16914,0,16914,1,0), -(17039,9787,2018,6,0), -(17040,9787,2018,6,0), -(17041,9787,2018,6,0), -(17253,0,17253,1,0), -(17255,17253,17253,2,0), -(17256,17255,17253,3,0), -(17257,17256,17253,4,0), -(17258,17257,17253,5,0), -(17259,17258,17253,6,0), -(17260,17259,17253,7,0), -(17261,17260,17253,8,0), -(17311,15407,15407,2,0), -(17312,17311,15407,3,0), -(17313,17312,15407,4,0), -(17314,17313,15407,5,0), -(17329,16813,16689,6,9853), -(17347,16511,16511,2,0), -(17348,17347,16511,3,0), -(17390,16857,16857,2,0), -(17391,17390,16857,3,0), -(17392,17391,16857,4,0), -(17401,16914,16914,2,0), -(17402,17401,16914,3,0), -(17727,2362,2362,2,0), -(17728,17727,2362,3,0), -(17735,0,17735,1,0), -(17750,17735,17735,2,0), -(17751,17750,17735,3,0), -(17752,17751,17735,4,0), -(17767,0,17767,1,0), -(17850,17767,17767,2,0), -(17851,17850,17767,3,0), -(17852,17851,17767,4,0), -(17853,17852,17767,5,0), -(17854,17853,17767,6,0), -(17862,0,17862,1,0), -(17877,0,17877,1,0), -(17919,5676,5676,2,0), -(17920,17919,5676,3,0), -(17921,17920,5676,4,0), -(17922,17921,5676,5,0), -(17923,17922,5676,6,0), -(17924,6353,6353,2,0), -(17925,6789,6789,2,0), -(17926,17925,6789,3,0), -(17928,5484,5484,2,0), -(17937,17862,17862,2,0), -(17951,6366,6366,2,0), -(17952,17951,6366,3,0), -(17953,17952,6366,4,0), -(17962,0,17962,1,0), -(18137,0,18137,1,0), -(18220,0,18220,1,0), -(18248,7732,7620,4,0), -(18260,3413,2550,4,0), -(18265,0,18265,1,0), -(18647,710,710,2,0), -(18657,2637,2637,2,0), -(18658,18657,2637,3,0), -(18807,17314,15407,6,0), -(18809,12526,11366,8,0), -(18867,17877,17877,2,0), -(18868,18867,17877,3,0), -(18869,18868,17877,4,0), -(18870,18869,17877,5,0), -(18871,18870,17877,6,0), -(18879,18265,18265,2,0), -(18880,18879,18265,3,0), -(18881,18880,18265,4,0), -(18930,17962,17962,2,0), -(18931,18930,17962,3,0), -(18932,18931,17962,4,0), -(18937,18220,18220,2,0), -(18938,18937,18220,3,0), -(19236,13908,13908,2,0), -(19238,19236,13908,3,0), -(19240,19238,13908,4,0), -(19241,19240,13908,5,0), -(19242,19241,13908,6,0), -(19243,19242,13908,7,0), -(19261,2652,2652,2,0), -(19262,19261,2652,3,0), -(19264,19262,2652,4,0), -(19265,19264,2652,5,0), -(19266,19265,2652,6,0), -(19271,13896,13896,2,0), -(19273,19271,13896,3,0), -(19274,19273,13896,4,0), -(19275,19274,13896,5,0), -(19276,2944,2944,2,0), -(19277,19276,2944,3,0), -(19278,19277,2944,4,0), -(19279,19278,2944,5,0), -(19280,19279,2944,6,0), -(19281,9035,9035,2,0), -(19282,19281,9035,3,0), -(19283,19282,9035,4,0), -(19284,19283,9035,5,0), -(19285,19284,9035,6,0), -(19296,10797,10797,2,0), -(19299,19296,10797,3,0), -(19302,19299,10797,4,0), -(19303,19302,10797,5,0), -(19304,19303,10797,6,0), -(19305,19304,10797,7,0), -(19306,0,19306,1,0), -(19308,18137,18137,2,0), -(19309,19308,18137,3,0), -(19310,19309,18137,4,0), -(19311,19310,18137,5,0), -(19312,19311,18137,6,0), -(19386,0,19386,1,0), -(19434,0,19434,1,0), -(19438,7812,7812,2,0), -(19440,19438,7812,3,0), -(19441,19440,7812,4,0), -(19442,19441,7812,5,0), -(19443,19442,7812,6,0), -(19244,0,19244,1,0), -(19478,0,19478,1,0), -(19505,0,19505,1,0), -(19506,0,19506,1,0), -(19647,19244,19244,2,0), -(19655,19478,19478,2,0), -(19656,19655,19478,3,0), -(19660,19656,19478,4,0), -(19731,19505,19505,2,0), -(19734,19731,19505,3,0), -(19736,19734,19505,4,0), -(19740,0,19740,1,0), -(19742,0,19742,1,0), -(19750,0,19750,1,0), -(19834,19740,19740,2,0), -(19835,19834,19740,3,0), -(19836,19835,19740,4,0), -(19837,19836,19740,5,0), -(19838,19837,19740,6,0), -(19850,19742,19742,2,0), -(19852,19850,19742,3,0), -(19853,19852,19742,4,0), -(19854,19853,19742,5,0), -(19876,0,19876,1,0), -(19888,0,19888,1,0), -(19891,0,19891,1,0), -(19895,19876,19876,2,0), -(19896,19895,19876,3,0), -(19897,19888,19888,2,0), -(19898,19897,19888,3,0), -(19899,19891,19891,2,0), -(19900,19899,19891,3,0), -(19939,19750,19750,2,0), -(19940,19939,19750,3,0), -(19941,19940,19750,4,0), -(19942,19941,19750,5,0), -(19943,19942,19750,6,0), -(19977,0,19977,1,0), -(19978,19977,19977,2,0), -(19979,19978,19977,3,0), -(20043,0,20043,1,0), -(20116,26573,26573,2,0), -(20162,21082,21082,2,0), -(20164,0,20164,1,0), -(20165,0,20165,1,0), -(20166,0,20166,1,0), -(20190,20043,20043,2,0), -(20217,0,20217,1,0), -(20219,12656,4036,5,0), -(20222,12656,4036,5,0), -(20243,0,20243,1,0), -(20252,0,20252,1,0), -(20287,21084,21084,2,0), -(20288,20287,21084,3,0), -(20289,20288,21084,4,0), -(20290,20289,21084,5,0), -(20291,20290,21084,6,0), -(20292,20291,21084,7,0), -(20293,20292,21084,8,0), -(20305,20162,21082,3,0), -(20306,20305,21082,4,0), -(20307,20306,21082,5,0), -(20308,20307,21082,6,0), -(20347,20165,20165,2,0), -(20348,20347,20165,3,0), -(20349,20348,20165,4,0), -(20356,20166,20166,2,0), -(20357,20356,20166,3,0), -(20375,0,20375,1,0), -(20473,0,20473,1,0), -(20484,0,20484,1,0), -(20559,7402,694,4,0), -(20560,20559,694,5,0), -(20569,11609,845,5,0), -(20609,2008,2008,2,0), -(20610,20609,2008,3,0), -(20616,20252,20252,2,0), -(20617,20616,20252,3,0), -(20658,5308,5308,2,0), -(20660,20658,5308,3,0), -(20661,20660,5308,4,0), -(20662,20661,5308,5,0), -(20729,6940,6940,2,0), -(20736,0,20736,1,0), -(20739,20484,20484,2,0), -(20742,20739,20484,3,0), -(20747,20742,20484,4,0), -(20748,20747,20484,5,0), -(20752,693,693,2,0), -(20755,20752,693,3,0), -(20756,20755,693,4,0), -(20757,20756,693,5,0), -(20770,10881,2006,5,0), -(20772,10324,7328,4,0), -(20773,20772,7328,5,0), -(20776,20610,2008,4,0), -(20777,20776,2008,5,0), -(20900,19434,19434,2,0), -(20901,20900,19434,3,0), -(20902,20901,19434,4,0), -(20903,20902,19434,5,0), -(20904,20903,19434,6,0), -(20905,19506,19506,2,0), -(20906,20905,19506,3,0), -(20909,19306,19306,2,0), -(20910,20909,19306,3,0), -(20911,0,20911,1,0), -(20912,20911,20911,2,0), -(20913,20912,20911,3,0), -(20914,20913,20911,4,0), -(20915,20375,20375,2,0), -(20918,20915,20375,3,0), -(20919,20918,20375,4,0), -(20920,20919,20375,5,0), -(20922,20116,26573,3,0), -(20923,20922,26573,4,0), -(20924,20923,26573,5,0), -(20925,0,20925,1,0), -(20927,20925,20925,2,0), -(20928,20927,20925,3,0), -(20929,20473,20473,2,0), -(20930,20929,20473,3,0), -(21082,0,21082,1,0), -(21084,0,21084,1,0), -(21551,12294,12294,2,0), -(21552,21551,12294,3,0), -(21553,21552,12294,4,0), -(21562,0,21562,1,0), -(21564,21562,21562,2,0), -(21849,0,21849,1,0), -(21850,21849,21849,2,0), -(22568,0,22568,1,0), -(22782,6117,6117,2,0), -(22783,22782,6117,3,0), -(22827,22568,22568,2,0), -(22828,22827,22568,3,0), -(22829,22828,22568,4,0), -(22842,0,22842,1,0), -(22895,22842,22842,2,0), -(22896,22895,22842,3,0), -(23028,0,23028,1,0), -(23099,0,23099,1,0), -(23109,23099,23099,2,0), -(23110,23109,23099,3,0), -(23145,0,23145,1,0), -(23147,23145,23145,2,0), -(23148,23147,23145,3,0), -(23881,0,23881,1,0), -(23892,23881,23881,2,0), -(23893,23892,23881,3,0), -(23894,23893,23881,4,0), -(23922,0,23922,1,0), -(23923,23922,23922,2,0), -(23924,23923,23922,3,0), -(23925,23924,23922,4,0), -(23992,0,23992,1,0), -(24132,19386,19386,2,0), -(24133,24132,19386,3,0), -(24224,0,24224,1,0), -(24239,24274,24275,3,0), -(24248,31018,22568,6,0), -(24274,24275,24275,2,0), -(24275,0,24275,1,0), -(24398,0,24398,1,0), -(24423,0,24423,1,0), -(24439,23992,23992,2,0), -(24444,24439,23992,3,0), -(24445,24444,23992,4,0), -(24446,0,24446,1,0), -(24447,24446,24446,2,0), -(24448,24447,24446,3,0), -(24449,24448,24446,4,0), -(24450,0,24450,1,0), -(24452,24450,24450,2,0), -(24453,24452,24450,3,0), -(24488,0,24488,1,0), -(24492,0,24492,1,0), -(24493,0,24493,1,0), -(24497,24493,24493,2,0), -(24500,24497,24493,3,0), -(24501,24500,24493,4,0), -(24502,24492,24492,2,0), -(24503,24502,24492,3,0), -(24504,24503,24492,4,0), -(24505,24488,24488,2,0), -(24506,24505,24488,3,0), -(24507,24506,24488,4,0), -(24545,0,24545,1,0), -(24549,24545,24545,2,0), -(24550,24549,24545,3,0), -(24551,24550,24545,4,0), -(24552,24551,24545,5,0), -(24553,24552,24545,6,0), -(24554,24553,24545,7,0), -(24555,24554,24545,8,0), -(24577,24423,24423,2,0), -(24578,24577,24423,3,0), -(24579,24578,24423,4,0), -(24583,24640,24640,2,0), -(24586,24583,24640,3,0), -(24587,24586,24640,4,0), -(24597,24603,24604,4,0), -(24604,0,24604,1,0), -(24605,24604,24604,2,0), -(24603,24605,24604,3,0), -(24629,24555,24545,9,0), -(24630,24629,24545,10,0), -(24640,0,24640,1,0), -(24844,0,24844,1,0), -(24974,5570,5570,2,0), -(24975,24974,5570,3,0), -(24976,24975,5570,4,0), -(24977,24976,5570,5,0), -(25008,24844,24844,2,0), -(25009,25008,24844,3,0), -(25010,25009,24844,4,0), -(25011,25010,24844,5,0), -(25012,25011,24844,6,0), -(25076,0,25076,1,0), -(25202,11556,1160,6,0), -(25203,25202,1160,7,0), -(25208,11574,772,8,0), -(25210,25314,2060,6,0), -(25212,7373,1715,4,0), -(25213,25210,2060,7,0), -(25217,10901,17,11,0), -(25218,25217,17,12,0), -(25221,25315,139,11,0), -(25222,25221,139,12,0), -(25225,11597,7386,6,0), -(25229,0,25229,1,0), -(25230,25229,25229,2,0), -(25231,20569,845,6,0), -(25233,10917,2061,8,0), -(25234,20662,5308,6,0), -(25235,25233,2061,9,0), -(25236,25234,5308,7,0), -(25241,11605,1464,5,0), -(25242,25241,1464,6,0), -(25248,21553,12294,5,0), -(25251,23894,23881,5,0), -(25258,23925,23922,5,0), -(25264,11581,6343,7,0), -(25266,20560,694,6,0), -(25269,25288,6572,7,0), -(25272,20617,20252,4,0), -(25275,25272,20252,5,0), -(25286,11567,78,9,0), -(25288,11601,6572,6,0), -(25289,11551,6673,7,0), -(25290,19854,19742,6,0), -(25291,19838,19740,7,0), -(25292,10329,635,9,0), -(25294,14290,2643,5,0), -(25295,13555,1978,9,0), -(25296,14322,13165,7,0), -(25297,9889,5185,11,0), -(25298,9876,2912,7,0), -(25299,9841,774,11,0), -(25300,11281,53,9,0), -(25302,11303,1966,5,0), -(25304,10181,116,11,0), -(25306,10151,133,12,0), -(25307,11661,686,10,0), -(25308,25316,596,6,0), -(25309,11668,348,8,0), -(25311,11672,172,7,0), -(25312,27841,14752,5,0), -(25314,10965,2060,5,0), -(25315,10929,139,10,0), -(25316,10961,596,5,0), -(25331,27801,15237,7,0), -(25345,10212,5143,8,0), -(25347,11358,2835,5,0), -(25357,10396,331,10,0), -(25359,10627,8835,3,0), -(25361,10442,8075,5,0), -(25363,10934,585,9,0), -(25364,25363,585,10,0), -(25367,10894,589,9,0), -(25368,25367,589,10,0), -(25372,10947,8092,10,0), -(25375,25372,8092,11,0), -(25379,10876,8129,6,0), -(25380,25379,8129,7,0), -(25384,15261,14914,9,0), -(25387,18807,15407,7,0), -(25389,10938,1243,7,0), -(25391,25357,331,11,0), -(25396,25391,331,12,0), -(25420,10468,8004,7,0), -(25422,10623,1064,4,0), -(25423,25422,1064,5,0), -(25429,10942,586,7,0), -(25431,10952,588,7,0), -(25433,10958,976,4,0), -(25435,20770,2006,6,0), -(25437,19243,13908,8,0), -(25439,10605,421,5,0), -(25441,19275,13896,6,0), -(25442,25439,421,6,0), -(25446,19305,10797,8,0), -(25448,15208,403,11,0), -(25449,25448,403,12,0), -(25454,10414,8042,8,0), -(25457,29228,8050,7,0), -(25464,10473,8056,5,0), -(25467,19280,2944,7,0), -(25469,10432,324,8,0), -(25470,19285,9035,7,0), -(25472,25469,324,9,0), -(25477,19312,18137,7,0), -(25479,16316,8017,8,0), -(25485,25479,8017,9,0), -(25489,16342,8024,7,0), -(25500,16356,8033,6,0), -(25505,16362,8232,5,0), -(25508,10408,8071,7,0), -(25509,25508,8071,8,0), -(25525,10428,5730,7,0), -(25528,25361,8075,6,0), -(25533,10438,3599,7,0), -(25546,11315,1535,6,0), -(25547,25546,1535,7,0), -(25552,10587,8190,5,0), -(25557,16387,8227,5,0), -(25560,10479,8181,4,0), -(25563,10538,8184,4,0), -(25567,10463,5394,6,0), -(25570,10497,5675,5,0), -(25574,10601,10595,4,0), -(25577,15112,15107,4,0), -(25585,10614,8512,4,0), -(25587,25585,8512,5,0), -(25596,10953,453,4,0), -(25782,0,25782,1,19838), -(25890,0,25890,1,19979), -(25894,0,25894,1,19854), -(25895,0,25895,1,1038), -(25898,0,25898,1,20217), -(25899,0,25899,1,20914), -(25916,25782,25782,2,25291), -(25918,25894,25894,2,25290), -(26064,0,26064,1,0), -(26090,0,26090,1,0), -(26177,7371,7371,2,0), -(26178,26177,7371,3,0), -(26179,26178,7371,4,0), -(26187,26090,26090,2,0), -(26188,26187,26090,3,0), -(26201,26179,7371,5,0), -(26573,0,26573,1,0), -(26790,12180,3908,5,0), -(26797,12180,3908,5,0), -(26798,12180,3908,5,0), -(26801,12180,3908,5,0), -(26839,11290,703,7,0), -(26861,11294,1752,9,0), -(26862,26861,1752,10,0), -(26863,25300,53,10,0), -(26864,17348,16511,4,0), -(26865,31016,2098,10,0), -(26866,11198,8647,6,0), -(26867,11275,1943,7,0), -(26884,26839,703,8,0), -(26889,1857,1856,3,0), -(26892,11343,8681,7,0), -(26969,25347,2835,6,0), -(26978,25297,5185,12,0), -(26979,26978,5185,13,0), -(26980,9858,8936,10,0), -(26981,25299,774,12,0), -(26982,26981,774,13,0), -(26983,9863,740,5,0), -(26984,9912,5176,9,0), -(26985,26984,5176,10,0), -(26986,25298,2912,8,0), -(26987,9835,8921,11,0), -(26988,26987,8921,12,0), -(26989,9853,339,7,0), -(26990,9885,1126,8,0), -(26992,9910,467,7,0), -(26993,9907,770,5,0), -(26994,20748,20484,6,0), -(26995,9901,2908,4,0), -(26996,9881,6807,8,0), -(26997,9908,779,6,0), -(26998,9898,99,6,0), -(26999,22896,22842,4,0), -(27001,9830,5221,6,0), -(27002,27001,5221,7,0), -(27003,9904,1822,5,0), -(27005,9867,6785,5,0), -(27006,9827,9005,4,0), -(27008,9896,1079,7,0), -(27009,17329,16689,7,26989), -(27011,17392,16857,5,0), -(27012,17402,16914,4,0), -(27013,24977,5570,6,0), -(27014,14266,2973,9,0), -(27015,14273,781,4,0), -(27016,25295,1978,10,0), -(27018,14280,3034,4,0), -(27019,14287,3044,9,0), -(27020,15632,20736,7,0), -(27021,25294,2643,6,0), -(27022,14295,1510,4,0), -(27023,14305,13795,6,0), -(27025,14317,13813,4,0), -(27028,10846,3273,5,0), -(27044,25296,13165,8,0), -(27045,20190,20043,3,0), -(27046,13544,136,8,0), -(27047,14921,2649,8,0), -(27048,16697,1742,7,0), -(27049,3009,16827,9,0), -(27050,17261,17253,9,0), -(27051,24579,24423,5,0), -(27052,24501,24493,5,0), -(27053,24445,23992,5,0), -(27054,24449,24446,5,0), -(27055,24504,24492,5,0), -(27056,24507,24488,5,0), -(27060,24587,24640,5,0), -(27061,24630,24545,11,0), -(27062,5042,4187,11,0), -(27063,26188,26090,4,0), -(27065,20904,19434,7,0), -(27066,20906,19506,4,0), -(27067,20910,19306,4,0), -(27068,24133,19386,4,0), -(27070,25306,133,13,0), -(27071,25304,116,12,0), -(27072,27071,116,13,0), -(27073,10207,2948,8,0), -(27074,27073,2948,9,0), -(27075,25345,5143,9,0), -(27078,10199,2136,8,0), -(27079,27078,2136,9,0), -(27080,10202,1449,7,0), -(27082,27080,1449,8,0), -(27085,10187,10,7,0), -(27086,10216,2120,7,0), -(27087,10161,120,6,0), -(27088,10230,122,5,0), -(27090,37420,5504,9,0), -(27124,10220,7302,5,0), -(27125,22783,6117,4,0), -(27126,10157,1459,6,0), -(27128,10225,543,6,0), -(27130,10170,1008,5,0), -(27131,10193,1463,7,0), -(27132,18809,11366,9,0), -(27133,13021,11113,6,0), -(27134,13033,11426,5,0), -(27135,25292,635,10,0), -(27136,27135,635,11,0), -(27137,19943,19750,7,0), -(27138,10314,879,7,0), -(27139,10318,2812,3,0), -(27140,25291,19740,8,0), -(27141,25916,25782,3,27140), -(27142,25290,19742,7,0), -(27143,25918,25894,3,27142), -(27144,19979,19977,4,0), -(27145,25890,25890,2,27144), -(27147,20729,6940,3,0), -(27148,27147,6940,4,0), -(27149,10293,465,8,0), -(27150,10301,7294,6,0), -(27151,19896,19876,4,0), -(27152,19898,19888,4,0), -(27153,19900,19891,4,0), -(27154,10310,633,4,0), -(27155,20293,21084,9,0), -(27158,20308,21082,7,0), -(27166,20357,20166,4,0), -(27168,20914,20911,5,0), -(27169,25899,25899,2,27168), -(27170,20920,20375,6,0), -(27173,20924,26573,6,0), -(27174,20930,20473,4,0), -(27179,20928,20925,4,0), -(27180,24239,24275,4,0), -(27209,25307,686,11,0), -(27210,17923,5676,7,0), -(27211,17924,6353,3,0), -(27212,11678,5740,5,0), -(27213,11684,1949,4,0), -(27215,25309,348,9,0), -(27216,25311,172,8,0), -(27217,11675,1120,5,0), -(27218,11713,980,7,0), -(27219,11700,689,7,0), -(27220,27219,689,8,0), -(27221,11704,5138,5,0), -(27222,11689,1454,7,0), -(27223,17926,6789,4,0), -(27224,11708,702,7,0), -(27226,11717,704,5,0), -(27228,11722,1490,4,0), -(27229,17937,17862,3,0), -(27230,11730,6201,6,0), -(27238,20757,693,6,0), -(27250,17953,6366,5,0), -(27259,11695,755,8,0), -(27260,11735,706,6,0), -(27263,18871,17877,7,0), -(27264,18881,18265,5,0), -(27265,18938,18220,4,0), -(27266,18932,17962,5,0), -(27267,11763,3110,8,0), -(27268,11767,6307,6,0), -(27269,11771,2947,6,0), -(27270,11775,3716,7,0), -(27271,17752,17735,5,0), -(27272,17854,17767,7,0), -(27273,19443,7812,7,0), -(27274,11780,7814,7,0), -(27275,11785,6360,5,0), -(27276,19736,19505,5,0), -(27277,27276,19505,6,0), -(27280,19660,19478,5,0), -(27282,26969,2835,7,0), -(27283,13230,13220,5,0), -(27441,11269,8676,7,0), -(27448,25302,1966,6,0), -(27681,14752,14752,2,0), -(27683,0,27683,1,0), -(27685,26201,7371,6,0), -(27799,15431,15237,4,0), -(27800,27799,15237,5,0), -(27801,27800,15237,6,0), -(27841,14819,14752,4,0), -(27870,724,724,2,0), -(27871,27870,724,3,0), -(28029,13920,7411,5,0), -(28172,17728,2362,4,0), -(28176,0,28176,1,0), -(28189,28176,28176,2,0), -(28275,27871,724,4,0), -(28596,11611,2259,5,0), -(28609,10177,6143,5,0), -(28610,11740,6229,4,0), -(28612,10145,587,7,0), -(28672,11611,2259,5,0), -(28675,11611,2259,5,0), -(28677,11611,2259,5,0), -(28695,11993,2366,5,0), -(28894,25230,25229,3,0), -(28895,28894,25229,4,0), -(28897,28895,25229,5,0), -(29228,10448,8050,6,0), -(29354,10248,2575,5,0), -(29704,1672,72,4,0), -(29707,25286,78,10,0), -(29722,0,29722,1,0), -(29801,0,29801,1,0), -(29844,9785,2018,5,0), -(30016,20243,20243,2,0), -(30022,30016,20243,3,0), -(30030,29801,29801,2,0), -(30033,30030,29801,3,0), -(30108,0,30108,1,0), -(30151,0,30151,1,0), -(30194,30151,30151,2,0), -(30198,30194,30151,3,0), -(30213,0,30213,1,0), -(30219,30213,30213,2,0), -(30223,30219,30213,3,0), -(30283,0,30283,1,0), -(30324,29707,78,11,0), -(30330,25248,12294,6,0), -(30335,25251,23881,6,0), -(30350,12656,4036,5,0), -(30356,25258,23922,6,0), -(30357,25269,6572,8,0), -(30404,30108,30108,2,0), -(30405,30404,30108,3,0), -(30413,30283,30283,2,0), -(30414,30413,30283,3,0), -(30459,27210,5676,8,0), -(30545,27211,6353,4,0), -(30546,27263,17877,8,0), -(30908,27221,5138,6,0), -(30909,27224,702,8,0), -(30910,603,603,2,0), -(30911,27264,18265,6,0), -(30912,27266,17962,6,0), -(31016,11300,2098,9,0), -(31018,22829,22568,5,0), -(31661,0,31661,1,0), -(31785,0,31785,1,0), -(31895,20164,20164,2,0), -(31935,0,31935,1,0), -(32231,29722,29722,2,0), -(32379,0,32379,1,0), -(32549,10662,2108,5,0), -(32593,974,974,2,0), -(32594,32593,974,3,0), -(32645,0,32645,1,0), -(32678,10768,8613,5,0), -(32684,32645,32645,2,0), -(32699,31935,31935,2,0), -(32700,32699,31935,3,0), -(32796,28609,6143,6,0), -(32996,32379,32379,2,0), -(32999,27681,14752,3,0), -(33041,31661,31661,2,0), -(33042,33041,31661,3,0), -(33043,33042,31661,4,0), -(33072,27174,20473,5,0), -(33095,18248,7620,5,0), -(33142,0,33142,1,0), -(33145,33142,33142,2,0), -(33146,33145,33142,3,0), -(33359,18260,2550,5,0), -(33388,0,33388,1,0), -(33391,33388,33388,2,0), -(33405,27134,11426,6,0), -(33698,0,33698,1,0), -(33699,33698,33698,2,0), -(33700,33699,33698,3,0), -(33701,27271,17735,6,0), -(33717,28612,587,8,0), -(33736,24398,24398,2,0), -(33776,31785,31785,2,0), -(33876,0,33876,1,0), -(33878,0,33878,1,0), -(33933,27133,11113,7,0), -(33938,27132,11366,10,0), -(33943,0,33943,1,0), -(33944,10174,604,6,0), -(33946,27130,1008,6,0), -(33982,33876,33876,2,0), -(33983,33982,33876,3,0), -(33986,33878,33878,2,0), -(33987,33986,33878,3,0), -(34411,1329,1329,2,0), -(34412,34411,1329,3,0), -(34413,34412,1329,4,0), -(34506,0,34506,1,0), -(34507,34506,34506,2,0), -(34508,34507,34506,3,0), -(34838,34508,34506,4,0), -(34839,34838,34506,5,0), -(34861,0,34861,1,0), -(34863,34861,34861,2,0), -(34864,34863,34861,3,0), -(34865,34864,34861,4,0), -(34866,34865,34861,5,0), -(34889,0,34889,1,0), -(34914,0,34914,1,0), -(34916,34914,34914,2,0), -(34917,34916,34914,3,0), -(34950,0,34950,1,0), -(34954,34950,34950,2,0), -(35323,34889,34889,2,0), -(35290,0,35290,1,0), -(35291,35290,35290,2,0), -(35292,35291,35290,3,0), -(35293,35292,35290,4,0), -(35294,35293,35290,5,0), -(35295,35294,35290,6,0), -(35296,35295,35290,7,0), -(35297,35296,35290,8,0), -(35298,35297,35290,9,0), -(35387,0,35387,1,0), -(35389,35387,35387,2,0), -(35392,35389,35387,3,0), -(35346,0,35346,1,0), -(35694,0,35694,1,0), -(35698,35694,35694,2,0), -(36916,14271,1495,5,0), -(37420,10140,5504,8,0), -(38692,27070,133,14,0), -(38697,27072,116,14,0), -(38699,27075,5143,10,0), -(38704,38699,5143,11,0), -(38764,11286,1776,6,0), -(38768,1769,1766,5,0), -(40120,33943,33943,2,0); -/*!40000 ALTER TABLE `spell_chain` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `spell_elixir` --- - -DROP TABLE IF EXISTS `spell_elixir`; -CREATE TABLE `spell_elixir` ( - `entry` int(11) unsigned NOT NULL default '0' COMMENT 'SpellId of potion', - `mask` tinyint(1) unsigned NOT NULL default '0' COMMENT 'Mask 0x1 battle 0x2 guardian 0x3 flask 0x7 unstable flasks 0xB shattrath flasks', - PRIMARY KEY (`entry`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Spell System'; - --- --- Dumping data for table `spell_elixir` --- - -LOCK TABLES `spell_elixir` WRITE; -/*!40000 ALTER TABLE `spell_elixir` DISABLE KEYS */; -INSERT INTO `spell_elixir` VALUES -( 673,0x2), -( 2367,0x1), -( 2374,0x1), -( 2378,0x2), -( 2380,0x2), -( 3160,0x1), -( 3164,0x1), -( 3166,0x2), -( 3219,0x2), -( 3220,0x2), -( 3222,0x2), -( 3223,0x2), -( 3593,0x2), -( 7844,0x1), -( 8212,0x1), -(10667,0x1), -(10668,0x2), -(10669,0x1), -(10692,0x2), -(10693,0x2), -(11319,0x2), -(11328,0x1), -(11334,0x1), -(11348,0x2), -(11349,0x2), -(11364,0x2), -(11371,0x2), -(11390,0x1), -(11396,0x2), -(11405,0x1), -(11406,0x1), -(11474,0x1), -(15231,0x2), -(15233,0x2), -(16321,0x2), -(16322,0x1), -(16323,0x1), -(16325,0x2), -(16326,0x2), -(16327,0x2), -(16329,0x1), -(17038,0x1), -(17535,0x2), -(17537,0x1), -(17538,0x1), -(17539,0x1), -(17624,0x3), -(17626,0x3), -(17627,0x3), -(17629,0x3), -(17628,0x3), -(21920,0x1), -(24361,0x2), -(24363,0x2), -(24382,0x2), -(24383,0x2), -(24417,0x2), -(26276,0x1), -(27652,0x2), -(27653,0x2), -(28486,0x1), -(28488,0x1), -(28490,0x1), -(28491,0x1), -(28493,0x1), -(28497,0x1), -(28501,0x1), -(28502,0x2), -(28503,0x1), -(28509,0x2), -(28514,0x2), -(28518,0x3), -(28519,0x3), -(28520,0x3), -(28521,0x3), -(28540,0x3), -(29348,0x2), -(33720,0x1), -(33721,0x1), -(33726,0x1), -(38954,0x1), -(39625,0x2), -(39626,0x2), -(39627,0x2), -(39628,0x2), -(40567,0x7), -(40568,0x7), -(40572,0x7), -(40573,0x7), -(40575,0x7), -(40576,0x7), -(41608,0xB), -(41609,0xB), -(41610,0xB), -(41611,0xB), -(42735,0x3), -(46837,0xB), -(46839,0xB); -/*!40000 ALTER TABLE `spell_elixir` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `spell_learn_spell` --- - -DROP TABLE IF EXISTS `spell_learn_spell`; -CREATE TABLE `spell_learn_spell` ( - `entry` smallint(5) unsigned NOT NULL default '0', - `SpellID` smallint(5) unsigned NOT NULL default '0', - PRIMARY KEY (`entry`,`SpellID`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Item System'; - --- --- Dumping data for table `spell_learn_spell` --- - -LOCK TABLES `spell_learn_spell` WRITE; -/*!40000 ALTER TABLE `spell_learn_spell` DISABLE KEYS */; -INSERT INTO `spell_learn_spell` VALUES -(2842,8681), -(5784,33388), -(13819,33388), -(17002,24867), -(23161,33391), -(23214,33391), -(24866,24864), -(33872,47179), -(33873,47180), -(33943,34090), -(34767,33391), -(34769,33388); - -/*!40000 ALTER TABLE `spell_learn_spell` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `spell_pet_auras` --- - -DROP TABLE IF EXISTS `spell_pet_auras`; -CREATE TABLE `spell_pet_auras` ( - `spell` mediumint(8) unsigned NOT NULL COMMENT 'dummy spell id', - `pet` mediumint(8) unsigned NOT NULL default '0' COMMENT 'pet id; 0 = all', - `aura` mediumint(8) unsigned NOT NULL COMMENT 'pet aura id', - PRIMARY KEY (`spell`,`pet`) -) ENGINE=MyISAM DEFAULT CHARSET=latin1; - --- --- Dumping data for table `spell_pet_auras` --- - -LOCK TABLES `spell_pet_auras` WRITE; -/*!40000 ALTER TABLE `spell_pet_auras` DISABLE KEYS */; -INSERT INTO `spell_pet_auras` VALUES -(19028, 0, 25228), -(19578, 0, 19579), -(20895, 0, 24529), -(28757, 0, 28758), -(35029, 0, 35060), -(35030, 0, 35061), -(35691, 0, 35696), -(35692, 0, 35696), -(35693, 0, 35696), -(23785, 416, 23759), -(23822, 416, 23826), -(23823, 416, 23827), -(23824, 416, 23828), -(23825, 416, 23829), -(23785, 417, 23762), -(23822, 417, 23837), -(23823, 417, 23838), -(23824, 417, 23839), -(23825, 417, 23840), -(23785, 1860, 23760), -(23822, 1860, 23841), -(23823, 1860, 23842), -(23824, 1860, 23843), -(23825, 1860, 23844), -(23785, 1863, 23761), -(23822, 1863, 23833), -(23823, 1863, 23834), -(23824, 1863, 23835), -(23825, 1863, 23836), -(23785, 17252, 35702), -(23822, 17252, 35703), -(23823, 17252, 35704), -(23824, 17252, 35705), -(23825, 17252, 35706); - -/*!40000 ALTER TABLE `spell_pet_auras` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `spell_proc_event` --- - -DROP TABLE IF EXISTS `spell_proc_event`; -CREATE TABLE `spell_proc_event` ( - `entry` smallint(5) unsigned NOT NULL default '0', - `SchoolMask` tinyint(4) NOT NULL default '0', - `Category` smallint(6) NOT NULL default '0', - `SkillID` smallint(6) NOT NULL default '0', - `SpellFamilyName` smallint(5) unsigned NOT NULL default '0', - `SpellFamilyMask` bigint(20) unsigned NOT NULL default '0', - `procFlags` int(10) unsigned NOT NULL default '0', - `ppmRate` float NOT NULL default '0', - `cooldown` int(10) unsigned NOT NULL default '0', - PRIMARY KEY (`entry`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8; - --- --- Dumping data for table `spell_proc_event` --- - -LOCK TABLES `spell_proc_event` WRITE; -/*!40000 ALTER TABLE `spell_proc_event` DISABLE KEYS */; -INSERT INTO `spell_proc_event` VALUES -(168,0,0,0,0,0x0000000000000000,0x00000002,0,0), -(324,0,0,0,0,0x0000000000000000,0x00100402,0,3), -(325,0,0,0,0,0x0000000000000000,0x00100402,0,3), -(588,0,0,0,0,0x0000000000000000,0x00000402,0,0), -(602,0,0,0,0,0x0000000000000000,0x00000402,0,0), -(742,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(905,0,0,0,0,0x0000000000000000,0x00100402,0,3), -(945,0,0,0,0,0x0000000000000000,0x00100402,0,3), -(974,0,0,0,0,0x0000000000000000,0x00100402,0,3), -(1006,0,0,0,0,0x0000000000000000,0x00000402,0,0), -(1120,0,0,0,0,0x0000000000000000,0x00000004,0,0), -(2565,0,0,0,0,0x0000000000000000,0x00000040,0,0), -(2652,0,0,0,0,0x0000000000000000,0x00000002,0,0), -(3235,0,0,0,0,0x0000000000000000,0x00000002,0,0), -(3284,0,0,0,0,0x0000000000000000,0x00000002,0,0), -(3338,0,0,0,0,0x0000000000000000,0x00000002,0,0), -(3394,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(3417,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(3418,0,0,0,0,0x0000000000000000,0x00000002,0,0), -(3424,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(3436,0,0,0,0,0x0000000000000000,0x00000002,0,0), -(3439,0,0,0,0,0x0000000000000000,0x00000002,0,0), -(3440,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(3509,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(3512,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(3582,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(3616,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(3637,0,0,0,0,0x0000000000000000,0x00000002,0,0), -(4070,0,0,0,0,0x0000000000000000,0x00000002,0,0), -(4112,0,0,0,0,0x0000000000000000,0x00000002,0,0), -(4113,0,0,0,0,0x0000000000000000,0x00000002,0,0), -(4114,0,0,0,0,0x0000000000000000,0x00000002,0,0), -(4115,0,0,0,0,0x0000000000000000,0x00000002,0,0), -(4133,0,0,0,0,0x0000000000000000,0x00000002,0,0), -(4136,0,0,0,0,0x0000000000000000,0x00000002,0,0), -(4138,0,0,0,0,0x0000000000000000,0x00000002,0,0), -(4140,0,0,0,0,0x0000000000000000,0x00000002,0,0), -(4142,0,0,0,0,0x0000000000000000,0x00000004,0,0), -(4144,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(4241,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(4242,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(4245,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(4279,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(4283,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(4284,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(4315,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(4317,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(4493,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(4525,0,0,0,0,0x0000000000000000,0x00000002,0,0), -(4932,0,0,0,0,0x0000000000000000,0x00000002,0,0), -(4951,0,0,0,0,0x0000000000000000,0x00000002,0,0), -(5104,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(5118,0,0,0,0,0x0000000000000000,0x00008000,0,0), -(5202,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(5205,0,0,0,0,0x0000000000000000,0x00000002,0,0), -(5262,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(5301,0,0,0,0,0x0000000000000000,0x00000000,0,0), -(5364,0,0,0,0,0x0000000000000000,0x00000002,0,0), -(5368,0,0,0,0,0x0000000000000000,0x00000002,0,0), -(5369,0,0,0,0,0x0000000000000000,0x00000002,0,0), -(5370,0,0,0,0,0x0000000000000000,0x00000002,0,0), -(5377,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(5427,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(5680,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(5728,0,0,0,0,0x0000000000000000,0x00100402,0,0), -(5811,0,0,0,0,0x0000000000000000,0x00000002,0,0), -(6268,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(6397,0,0,0,0,0x0000000000000000,0x00100402,0,0), -(6398,0,0,0,0,0x0000000000000000,0x00100402,0,0), -(6399,0,0,0,0,0x0000000000000000,0x00100402,0,0), -(6433,0,0,0,0,0x0000000000000000,0x00000002,0,0), -(6645,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(6750,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(6752,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(6866,0,0,0,0,0x0000000000000000,0x00000072,0,0), -(6867,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(6870,0,0,0,0,0x0000000000000000,0x00000000,0,0), -(6871,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(6909,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(6921,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(6923,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(6947,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(6961,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(7095,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(7098,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(7102,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(7103,0,0,0,0,0x0000000000000000,0x00000002,0,0), -(7128,0,0,0,0,0x0000000000000000,0x00000402,0,0), -(7131,0,0,0,0,0x0000000000000000,0x000A22A8,0,0), -(7137,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(7276,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(7300,0,0,0,0,0x0000000000000000,0x00000002,0,0), -(7301,0,0,0,0,0x0000000000000000,0x00000002,0,0), -(7302,0,0,0,0,0x0000000000000000,0x00000002,0,0), -(7320,0,0,0,0,0x0000000000000000,0x00000002,0,0), -(7445,0,0,0,0,0x0000000000000000,0x00000002,0,0), -(7446,0,0,0,0,0x0000000000000000,0x00000002,0,0), -(7486,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(7617,0,0,0,0,0x0000000000000000,0x00100002,0,0), -(7619,0,0,0,0,0x0000000000000000,0x00100002,0,0), -(7711,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(7721,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(7722,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(7723,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(7724,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(7725,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(7726,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(7806,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(7807,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(7808,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(7849,0,0,0,0,0x0000000000000000,0x00000002,0,0), -(7999,0,0,0,0,0x0000000000000000,0x00000002,0,0), -(8134,0,0,0,0,0x0000000000000000,0x00100402,0,3), -(8224,0,0,0,0,0x0000000000000000,0x00000002,0,0), -(8247,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(8260,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(8288,0,0,0,0,0x0000000000000000,0x00000004,0,0), -(8289,0,0,0,0,0x0000000000000000,0x00000004,0,0), -(8397,0,0,0,0,0x0000000000000000,0x00000002,0,0), -(8601,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(8612,0,0,0,0,0x0000000000000000,0x00000002,0,0), -(8788,0,0,0,0,0x0000000000000000,0x00000402,0,0), -(8852,0,0,0,0,0x0000000000000000,0x00000002,0,0), -(8876,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(8981,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(9084,0,0,0,0,0x0000000000000000,0x00000008,0,0), -(9160,0,0,0,0,0x0000000000000000,0x00000002,0,0), -(9233,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(9276,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(9452,0,0,0,0,0x0000000000000000,0x00000014,3,0), -(9460,0,0,0,0,0x0000000000000000,0x00000002,0,0), -(9463,0,0,0,0,0x0000000000000000,0x00000002,0,0), -(9778,0,0,0,0,0x0000000000000000,0x00000002,0,0), -(9782,0,0,0,0,0x0000000000000000,0x00000040,0,0), -(9784,0,0,0,0,0x0000000000000000,0x00000040,0,0), -(9799,0,0,0,0,0x0000000000000000,0x00040000,0,0), -(10022,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(10092,0,0,0,0,0x0000000000000000,0x00000080,0,0), -(10219,0,0,0,0,0x0000000000000000,0x00000002,0,0), -(10220,0,0,0,0,0x0000000000000000,0x00000002,0,0), -(10425,0,0,0,0,0x0000000000000000,0x00100402,0,0), -(10426,0,0,0,0,0x0000000000000000,0x00100402,0,0), -(10431,0,0,0,0,0x0000000000000000,0x00100402,0,3), -(10432,0,0,0,0,0x0000000000000000,0x00100402,0,3), -(10951,0,0,0,0,0x0000000000000000,0x00000402,0,0), -(10952,0,0,0,0,0x0000000000000000,0x00000402,0,0), -(11103,4,0,0,0,0x0000000000000000,0x00020000,0,0), -(11119,4,0,0,0,0x0000000000000000,0x00010000,0,0), -(11120,4,0,0,0,0x0000000000000000,0x00010000,0,0), -(11129,4,0,0,0,0x0000000000000000,0x00020000,0,0), -(11180,16,0,0,0,0x0000000000000000,0x00020000,0,0), -(11185,0,0,0,3,0x0000000000000080,0x00020000,0,0), -(11213,0,0,0,0,0x0000000000000000,0x00020000,0,0), -(11255,0,0,0,3,0x0000000000004000,0x00004000,0,0), -(11371,0,0,0,0,0x0000000000000000,0x00000002,0,0), -(11441,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(11675,0,0,0,0,0x0000000000000000,0x00000004,0,0), -(11919,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(11959,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(11964,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(11984,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(12099,0,0,0,0,0x0000000000000000,0x00000040,0,0), -(12169,0,0,0,0,0x0000000000000000,0x00000040,0,0), -(12246,0,0,0,0,0x0000000000000000,0x00000002,0,0), -(12254,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(12281,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(12284,0,0,0,0,0x0000000000000000,0x00000001,0.33252,0), -(12289,0,0,26,0,0x0000000000000002,0x00020000,0,0), -(12292,0,0,0,0,0x0000000000000000,0x00000080,0,0), -(12298,0,0,0,0,0x0000000000000000,0x00000040,0,0), -(12311,0,0,0,4,0x0000000000000800,0x00020000,0,0), -(12317,0,0,0,0,0x0000000000000000,0x00842000,0,0), -(12319,0,0,0,0,0x0000000000000000,0x00011000,0,0), -(12322,0,0,0,0,0x0000000000000000,0x00000001,2,0), -(12328,0,0,0,0,0x0000000000000000,0xC4000001,0,0), -(12357,4,0,0,0,0x0000000000000000,0x00020000,0,0), -(12358,4,0,0,0,0x0000000000000000,0x00020000,0,0), -(12359,4,0,0,0,0x0000000000000000,0x00020000,0,0), -(12360,4,0,0,0,0x0000000000000000,0x00020000,0,0), -(12487,0,0,0,3,0x0000000000000080,0x00020000,0,0), -(12488,0,0,0,3,0x0000000000000080,0x00020000,0,0), -(12529,0,0,0,0,0x0000000000000000,0x00000002,0,0), -(12539,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(12544,0,0,0,0,0x0000000000000000,0x00000002,0,0), -(12550,0,0,0,0,0x0000000000000000,0x00000402,0,0), -(12556,0,0,0,0,0x0000000000000000,0x00000002,0,0), -(12574,0,0,0,0,0x0000000000000000,0x00020000,0,0), -(12575,0,0,0,0,0x0000000000000000,0x00020000,0,0), -(12576,0,0,0,0,0x0000000000000000,0x00020000,0,0), -(12577,0,0,0,0,0x0000000000000000,0x00020000,0,0), -(12598,0,0,0,3,0x0000000000004000,0x00004000,0,0), -(12668,0,0,26,0,0x0000000000000002,0x00020000,0,0), -(12701,0,0,0,0,0x0000000000000000,0x00000001,0.66504,0), -(12702,0,0,0,0,0x0000000000000000,0x00000001,0.99756,0), -(12703,0,0,0,0,0x0000000000000000,0x00000001,1.33008,0), -(12704,0,0,0,0,0x0000000000000000,0x00000001,1.6626,0), -(12724,0,0,0,0,0x0000000000000000,0x00000040,0,0), -(12725,0,0,0,0,0x0000000000000000,0x00000040,0,0), -(12726,0,0,0,0,0x0000000000000000,0x00000040,0,0), -(12727,0,0,0,0,0x0000000000000000,0x00000040,0,0), -(12782,0,0,0,0,0x0000000000000000,0x00000040,0,0), -(12787,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(12797,0,0,0,0,0x0000000000000400,0x00020000,0,0), -(12799,0,0,0,0,0x0000000000000400,0x00020000,0,0), -(12800,0,0,0,0,0x0000000000000400,0x00020000,0,0), -(12812,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(12813,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(12814,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(12815,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(12834,0,0,0,0,0x0000000000000000,0x00011000,0,0), -(12846,4,0,0,0,0x0000000000000000,0x00010000,0,0), -(12847,4,0,0,0,0x0000000000000000,0x00010000,0,0), -(12848,4,0,0,0,0x0000000000000000,0x00010000,0,0), -(12849,0,0,0,0,0x0000000000000000,0x00011000,0,0), -(12867,0,0,0,0,0x0000000000000000,0x00011000,0,0), -(12947,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(12958,0,0,0,4,0x0000000000000800,0x00020000,0,0), -(12966,0,0,0,0,0x0000000000000000,0xC4000001,0,0), -(12967,0,0,0,0,0x0000000000000000,0xC4000001,0,0), -(12968,0,0,0,0,0x0000000000000000,0xC4000001,0,0), -(12969,0,0,0,0,0x0000000000000000,0xC4000001,0,0), -(12970,0,0,0,0,0x0000000000000000,0xC4000001,0,0), -(12971,0,0,0,0,0x0000000000000000,0x00011000,0,0), -(12972,0,0,0,0,0x0000000000000000,0x00011000,0,0), -(12973,0,0,0,0,0x0000000000000000,0x00011000,0,0), -(12974,0,0,0,0,0x0000000000000000,0x00011000,0,0), -(12999,0,0,0,0,0x0000000000000000,0x00000001,4,0), -(13000,0,0,0,0,0x0000000000000000,0x00000001,6,0), -(13001,0,0,0,0,0x0000000000000000,0x00000001,8,0), -(13002,0,0,0,0,0x0000000000000000,0x00000001,10,0), -(13045,0,0,0,0,0x0000000000000000,0x00842000,0,0), -(13046,0,0,0,0,0x0000000000000000,0x00842000,0,0), -(13047,0,0,0,0,0x0000000000000000,0x00842000,0,0), -(13048,0,0,0,0,0x0000000000000000,0x00842000,0,0), -(13159,0,0,0,0,0x0000000000000000,0x00008000,0,0), -(13165,0,0,0,0,0x0000000000000000,0x00080000,0,0), -(13299,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(13358,0,0,0,0,0x0000000000000000,0x00000000,0,0), -(13585,0,0,0,0,0x0000000000000000,0x00000402,0,0), -(13616,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(13709,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(13716,0,0,0,0,0x0000000000000000,0x00000402,0,0), -(13754,0,0,0,0,0x0000000000000010,0x00020000,0,0), -(13800,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(13801,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(13802,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(13803,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(13867,0,0,0,0,0x0000000000000010,0x00020000,0,0), -(13877,0,0,0,0,0x0000000000000000,0xC4000001,0,0), -(13879,0,0,0,0,0x0000000000000000,0x00000002,0,0), -(13886,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(13896,0,0,0,0,0x0000000000000000,0x00100000,0,0), -(13959,0,0,0,0,0x0000000000000000,0x00100002,0,0), -(13960,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(13961,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(13962,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(13963,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(13964,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(13983,0,0,0,0,0x0000000000000000,0x01000010,0,0), -(14070,0,0,0,0,0x0000000000000000,0x01000010,0,0), -(14071,0,0,0,0,0x0000000000000000,0x01000010,0,0), -(14108,0,0,0,0,0x0000000000000000,0x00000002,0,0), -(14111,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(14133,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(14144,0,0,0,0,0x0000000000000000,0x00000004,0,0), -(14148,0,0,0,0,0x0000000000000000,0x00000004,0,0), -(14156,0,0,0,0,0x00000000003E0000,0x00020000,0,0), -(14160,0,0,0,0,0x00000000003E0000,0x00020000,0,0), -(14161,0,0,0,0,0x00000000003E0000,0x00020000,0,0), -(14178,0,0,0,0,0x0000000000000000,0x00000002,0,0), -(14186,0,0,0,8,0x0000000040800508,0x00010000,0,0), -(14190,0,0,0,8,0x0000000040800508,0x00010000,0,0), -(14193,0,0,0,8,0x0000000040800508,0x00010000,0,0), -(14194,0,0,0,8,0x0000000040800508,0x00010000,0,0), -(14195,0,0,0,8,0x0000000040800508,0x00010000,0,0), -(14318,0,0,0,0,0x0000000000000000,0x00080000,0,0), -(14319,0,0,0,0,0x0000000000000000,0x00080000,0,0), -(14320,0,0,0,0,0x0000000000000000,0x00080000,0,0), -(14321,0,0,0,0,0x0000000000000000,0x00080000,0,0), -(14322,0,0,0,0,0x0000000000000000,0x00080000,0,0), -(14531,0,0,0,0,0x0000000000000000,0x00002000,0,0), -(14774,0,0,0,0,0x0000000000000000,0x00002000,0,0), -(14796,0,0,0,0,0x0000000000000000,0x00000800,0,0), -(14869,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(14892,0,0,0,6,0x0000000410001E00,0x10000000,0,0), -(15088,0,0,0,0,0x0000000000000000,0x00001000,0,0), -(15097,0,0,0,0,0x0000000000000000,0x00002000,0,0), -(15268,32,0,0,0,0x0000000000000000,0x00020000,0,0), -(15270,0,0,0,0,0x0000000000000000,0x00000004,0,0), -(15277,0,0,0,0,0x0000000000000000,0x00000001,6,0), -(15286,32,0,0,0,0x0000000000000000,0x00008000,0,0), -(15323,32,0,0,0,0x0000000000000000,0x00020000,0,0), -(15324,32,0,0,0,0x0000000000000000,0x00020000,0,0), -(15325,32,0,0,0,0x0000000000000000,0x00020000,0,0), -(15326,32,0,0,0,0x0000000000000000,0x00020000,0,0), -(15335,0,0,0,0,0x0000000000000000,0x00000004,0,0), -(15336,0,0,0,0,0x0000000000000000,0x00000004,0,0), -(15337,0,0,0,0,0x0000000000000000,0x00000004,0,0), -(15338,0,0,0,0,0x0000000000000000,0x00000004,0,0), -(15346,0,0,0,0,0x0000000000000000,0x00000001,6,0), -(15362,0,0,0,6,0x0000000410001E00,0x10000000,0,0), -(15363,0,0,0,6,0x0000000410001E00,0x10000000,0,0), -(15506,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(15507,0,0,0,0,0x0000000000000000,0x00000402,0,0), -(15573,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(15594,0,0,0,0,0x0000000000000000,0x00000002,0,0), -(15599,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(15600,0,0,0,0,0x0000000000000000,0x00000001,0.6,0), -(15603,0,0,0,0,0x0000000000000000,0x00000002,0,0), -(15636,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(15641,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(15730,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(15733,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(15784,0,0,0,0,0x0000000000000000,0x00000002,0,0), -(15849,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(15852,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(15876,0,0,0,0,0x0000000000000000,0x00000002,0,0), -(15978,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(16092,0,0,0,0,0x0000000000000000,0x00000000,0,0), -(16142,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(16146,0,0,0,0,0x0000000000000000,0x00000800,0,0), -(16164,28,0,0,0,0x0000000000000000,0x00010000,0,0), -(16176,0,0,0,0,0x0000000000000000,0x10000000,0,0), -(16235,0,0,0,0,0x0000000000000000,0x10000000,0,0), -(16240,0,0,0,0,0x0000000000000000,0x10000000,0,0), -(16247,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(16256,0,0,0,0,0x0000000000000000,0x00001000,0,0), -(16257,0,0,0,0,0x0000000000000000,0xC4000001,0,0), -(16277,0,0,0,0,0x0000000000000000,0xC4000001,0,0), -(16278,0,0,0,0,0x0000000000000000,0xC4000001,0,0), -(16279,0,0,0,0,0x0000000000000000,0xC4000001,0,0), -(16280,0,0,0,0,0x0000000000000000,0xC4000001,0,0), -(16281,0,0,0,0,0x0000000000000000,0x00001000,0,0), -(16282,0,0,0,0,0x0000000000000000,0x00001000,0,0), -(16283,0,0,0,0,0x0000000000000000,0x00001000,0,0), -(16284,0,0,0,0,0x0000000000000000,0x00001000,0,0), -(16428,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(16487,0,0,0,0,0x0000000000000000,0x00842000,0,0), -(16489,0,0,0,0,0x0000000000000000,0x00842000,0,0), -(16492,0,0,0,0,0x0000000000000000,0x00842000,0,0), -(16550,0,0,0,0,0x0000000000000000,0x00002000,0,0), -(16574,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(16575,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(16611,0,0,0,0,0x0000000000000000,0x00000002,0,0), -(16615,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(16620,0,0,0,0,0x0000000000000000,0x00100402,0,30), -(16624,0,0,0,0,0x0000000000000000,0x00000040,0,0), -(16689,0,0,0,0,0x0000000000000000,0x00000002,0,0), -(16792,0,0,0,0,0x0000000000000000,0x00002000,0,0), -(16800,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(16810,0,0,0,0,0x0000000000000000,0x00000002,0,0), -(16811,0,0,0,0,0x0000000000000000,0x00000002,0,0), -(16812,0,0,0,0,0x0000000000000000,0x00000002,0,0), -(16813,0,0,0,0,0x0000000000000000,0x00000002,0,0), -(16843,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(16850,0,0,0,0,0x0000000000000004,0x00020000,0,0), -(16864,0,0,0,0,0x0000000000000000,0x00000001,2,0), -(16880,0,0,0,0,0x0000000000000000,0x00010000,0,0), -(16923,0,0,0,0,0x0000000000000004,0x00020000,0,0), -(16924,0,0,0,0,0x0000000000000004,0x00020000,0,0), -(16952,0,0,0,0,0x0000040000039000,0x00010000,0,0), -(16954,0,0,0,0,0x0000040000039000,0x00010000,0,0), -(16958,0,0,0,0,0x0000000000000000,0x00011000,0,0), -(16961,0,0,0,0,0x0000000000000000,0x00011000,0,0), -(16982,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(17010,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(17106,0,0,0,7,0x0000000000080000,0x00004000,0,0), -(17107,0,0,0,7,0x0000000000080000,0x00004000,0,0), -(17108,0,0,0,7,0x0000000000080000,0x00004000,0,0), -(17329,0,0,0,0,0x0000000000000000,0x00000002,0,0), -(17332,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(17350,0,0,0,0,0x0000000000000000,0x00000002,0,0), -(17364,0,0,0,0,0x0000000000000000,0x00008000,0,0), -(17495,0,0,0,0,0x0000000000000000,0x00000040,0,0), -(17670,0,0,0,0,0x0000000000000000,0x00000008,0,0), -(17687,0,0,0,0,0x0000000000000000,0xC4000001,0,0), -(17688,0,0,0,0,0x0000000000000000,0x00000080,0,0), -(17690,0,0,0,0,0x0000000000000000,0x00000002,0,0), -(17793,0,0,0,5,0x0000000000000001,0x00010000,0,0), -(17794,0,0,0,0,0x0000000000000000,0x00008000,0,0), -(17796,0,0,0,5,0x0000000000000001,0x00010000,0,0), -(17797,0,0,0,0,0x0000000000000000,0x00008000,0,0), -(17798,0,0,0,0,0x0000000000000000,0x00008000,0,0), -(17799,0,0,0,0,0x0000000000000000,0x00008000,0,0), -(17800,0,0,0,0,0x0000000000000000,0x00008000,0,0), -(17801,0,0,0,5,0x0000000000000001,0x00010000,0,0), -(17802,0,0,0,5,0x0000000000000001,0x00010000,0,0), -(17803,0,0,0,5,0x0000000000000001,0x00010000,0,0), -(18073,0,0,0,0,0x0000008000000060,0x00020000,0,0), -(18094,0,0,0,5,0x000000000000000A,0x00020000,0,0), -(18095,0,0,0,5,0x000000000000000A,0x00020000,0,0), -(18096,0,0,0,0,0x0000008000000060,0x00020000,0,0), -(18097,0,0,0,0,0x0000000000000000,0x00000002,0,0), -(18100,0,0,0,0,0x0000000000000000,0x00000002,0,0), -(18119,0,0,593,0,0x0000000000000000,0x00020000,0,0), -(18120,0,0,593,0,0x0000000000000000,0x00020000,0,0), -(18121,0,0,593,0,0x0000000000000000,0x00020000,0,0), -(18122,0,0,593,0,0x0000000000000000,0x00020000,0,0), -(18123,0,0,593,0,0x0000000000000000,0x00020000,0,0), -(18137,0,0,0,0,0x0000000000000000,0x00100402,0,3), -(18146,0,0,0,0,0x0000000000000000,0x00000002,0,0), -(18167,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(18186,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(18189,0,0,0,0,0x0000000000000000,0x00020000,0,0), -(18542,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(18765,0,0,0,0,0x0000000000000000,0xC4000001,0,0), -(18799,0,0,0,0,0x0000000000000000,0x00000002,0,0), -(18800,0,0,0,0,0x0000000000000000,0x00000008,0,0), -(18803,0,0,0,0,0x0000000000000000,0x00004000,0,0), -(18815,0,0,0,0,0x0000000000000000,0x00000002,0,0), -(18816,0,0,0,0,0x0000000000000000,0x00000002,0,0), -(18847,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(18943,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(18979,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(18983,0,0,0,0,0x0000000000000000,0x00000004,0,0), -(19184,0,0,0,0,0x0000000000000000,0x00200000,0,0), -(19194,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(19228,0,0,0,0,0x0000000000000040,0x00020000,0,0), -(19232,0,0,0,0,0x0000000000000040,0x00020000,0,0), -(19233,0,0,0,0,0x0000000000000040,0x00020000,0,0), -(19261,0,0,0,0,0x0000000000000000,0x00000002,0,0), -(19262,0,0,0,0,0x0000000000000000,0x00000002,0,0), -(19264,0,0,0,0,0x0000000000000000,0x00000002,0,0), -(19265,0,0,0,0,0x0000000000000000,0x00000002,0,0), -(19266,0,0,0,0,0x0000000000000000,0x00000002,0,0), -(19271,0,0,0,0,0x0000000000000000,0x00100000,0,0), -(19273,0,0,0,0,0x0000000000000000,0x00100000,0,0), -(19274,0,0,0,0,0x0000000000000000,0x00100000,0,0), -(19275,0,0,0,0,0x0000000000000000,0x00100000,0,0), -(19308,0,0,0,0,0x0000000000000000,0x00100402,0,3), -(19309,0,0,0,0,0x0000000000000000,0x00100402,0,3), -(19310,0,0,0,0,0x0000000000000000,0x00100402,0,3), -(19311,0,0,0,0,0x0000000000000000,0x00100402,0,3), -(19312,0,0,0,0,0x0000000000000000,0x00100402,0,3), -(19387,0,0,0,0,0x0000000000000000,0x00200000,0,0), -(19388,0,0,0,0,0x0000000000000000,0x00200000,0,0), -(19407,0,0,0,0,0x0000000000000200,0x00020000,0,0), -(19409,0,0,0,0,0x0000000000000000,0x00100002,0,0), -(19412,0,0,0,0,0x0000000000000200,0x00020000,0,0), -(19413,0,0,0,0,0x0000000000000200,0x00020000,0,0), -(19414,0,0,0,0,0x0000000000000200,0x00020000,0,0), -(19415,0,0,0,0,0x0000000000000200,0x00020000,0,0), -(19449,0,0,0,0,0x0000000000000000,0x00000002,0,0), -(19478,0,0,0,0,0x0000000000000000,0x00000002,0,0), -(19514,0,0,0,0,0x0000000000000000,0x00000402,0,0), -(19572,0,0,0,9,0x0000000000800000,0x08000000,0,0), -(19573,0,0,0,9,0x0000000000800000,0x08000000,0,0), -(19577,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(19655,0,0,0,0,0x0000000000000000,0x00000002,0,0), -(19656,0,0,0,0,0x0000000000000000,0x00000002,0,0), -(19660,0,0,0,0,0x0000000000000000,0x00000002,0,0), -(19817,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(19818,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(20049,0,0,0,0,0x0000000000000000,0x00011000,0,0), -(20056,0,0,0,0,0x0000000000000000,0x00011000,0,0), -(20057,0,0,0,0,0x0000000000000000,0x00011000,0,0), -(20058,0,0,0,0,0x0000000000000000,0x00011000,0,0), -(20059,0,0,0,0,0x0000000000000000,0x00011000,0,0), -(20127,0,0,0,0,0x0000000000000000,0x00000402,0,0), -(20128,0,0,0,0,0x0000000000000000,0x00000040,0,0), -(20130,0,0,0,0,0x0000000000000000,0x00000402,0,0), -(20131,0,0,0,0,0x0000000000000000,0x00000040,0,0), -(20132,0,0,0,0,0x0000000000000000,0x00000040,0,0), -(20133,0,0,0,0,0x0000000000000000,0x00000040,0,0), -(20134,0,0,0,0,0x0000000000000000,0x00000040,0,0), -(20135,0,0,0,0,0x0000000000000000,0x00000402,0,0), -(20136,0,0,0,0,0x0000000000000000,0x00000402,0,0), -(20137,0,0,0,0,0x0000000000000000,0x00000402,0,0), -(20154,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(20164,0,0,0,0,0x0000000000000000,0x00000001,5,0), -(20165,0,0,0,0,0x0000000000000000,0x00000001,20,0), -(20166,0,0,0,0,0x0000000000000000,0x00000001,20,0), -(20177,0,0,0,0,0x0000000000000000,0x00100402,0,0), -(20178,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(20179,0,0,0,0,0x0000000000000000,0x00100402,0,0), -(20180,0,0,0,0,0x0000000000000000,0x00100402,0,0), -(20181,0,0,0,0,0x0000000000000000,0x00100402,0,0), -(20182,0,0,0,0,0x0000000000000000,0x00100402,0,0), -(20185,0,0,0,0,0x0000000000000000,0x00000002,0,0), -(20186,0,0,0,0,0x0000000000000000,0x00100402,0,0), -(20210,0,0,0,10,0x00010000C0000000,0x10000000,0,0), -(20212,0,0,0,10,0x00010000C0000000,0x10000000,0,0), -(20213,0,0,0,10,0x00010000C0000000,0x10000000,0,0), -(20214,0,0,0,10,0x00010000C0000000,0x10000000,0,0), -(20215,0,0,0,10,0x00010000C0000000,0x10000000,0,0), -(20230,0,0,0,0,0x0000000000000000,0x00000002,0,0), -(20234,0,0,0,0,0x0000000000008000,0x00020000,0,0), -(20235,0,0,0,0,0x0000000000008000,0x00020000,0,0), -(20287,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(20288,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(20289,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(20290,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(20291,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(20292,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(20293,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(20344,0,0,0,0,0x0000000000000000,0x00000002,0,0), -(20345,0,0,0,0,0x0000000000000000,0x00000002,0,0), -(20346,0,0,0,0,0x0000000000000000,0x00000002,0,0), -(20347,0,0,0,0,0x0000000000000000,0x00000001,20,0), -(20348,0,0,0,0,0x0000000000000000,0x00000001,20,0), -(20349,0,0,0,0,0x0000000000000000,0x00000001,20,0), -(20354,0,0,0,0,0x0000000000000000,0x00100402,0,0), -(20355,0,0,0,0,0x0000000000000000,0x00100402,0,0), -(20356,0,0,0,0,0x0000000000000000,0x00000001,20,0), -(20357,0,0,0,0,0x0000000000000000,0x00000001,20,0), -(20375,0,0,0,0,0x0000000000000000,0x00000001,7,0), -(20500,0,0,0,4,0x0000000010000000,0x00004000,0,0), -(20501,0,0,0,4,0x0000000010000000,0x00004000,0,0), -(20545,0,0,0,0,0x0000000000000000,0x00000402,0,0), -(20705,0,0,0,0,0x0000000000000000,0x00002000,0,0), -(20725,0,0,0,0,0x0000000000000000,0x00001000,0,0), -(20784,0,0,0,0,0x0000000000000000,0x00001000,0,0), -(20847,0,0,0,0,0x0000000000000000,0x00000002,0,0), -(20884,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(20891,0,0,0,0,0x0000000000000000,0x00001000,0,0), -(20911,0,0,0,0,0x0000000000000000,0x00000040,0,0), -(20912,0,0,0,0,0x0000000000000000,0x00000040,0,0), -(20913,0,0,0,0,0x0000000000000000,0x00000040,0,0), -(20914,0,0,0,0,0x0000000000000000,0x00000040,0,0), -(20915,0,0,0,0,0x0000000000000000,0x00000001,7,0), -(20918,0,0,0,0,0x0000000000000000,0x00000001,7,0), -(20919,0,0,0,0,0x0000000000000000,0x00000001,7,0), -(20920,0,0,0,0,0x0000000000000000,0x00000001,7,0), -(20925,0,0,0,0,0x0000000000000000,0x00000040,0,0), -(20927,0,0,0,0,0x0000000000000000,0x00000040,0,0), -(20928,0,0,0,0,0x0000000000000000,0x00000040,0,0), -(21053,0,0,0,0,0x0000000000000000,0x00000004,0,0), -(21061,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(21063,0,0,0,0,0x0000000000000000,0x00008000,0,0), -(21080,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(21084,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(21185,0,0,0,0,0x0000000000000000,0x00000004,0,10), -(21334,0,0,0,0,0x0000000000000000,0x00008000,0,0), -(21645,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(21747,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(21788,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(21838,0,0,0,0,0x0000000000000000,0x00008000,0,0), -(21841,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(21853,0,0,0,0,0x0000000000000000,0x00000002,0,0), -(21882,0,0,0,0,0x0000000000000000,0x00001000,0,0), -(21890,0,0,0,4,0x0000036C2A764EEF,0x00082001,0,0), -(21893,0,0,0,0,0x0000000000000000,0x00000002,0,0), -(21897,0,0,0,0,0x0000000000000000,0x00000002,0,0), -(21911,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(21969,0,0,0,0,0x0000000000000000,0x00000002,0,0), -(21978,0,0,0,0,0x0000000000000000,0x00020000,0,0), -(22007,0,0,0,0,0x0000000000200821,0x00004000,0,0), -(22413,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(22438,0,0,0,0,0x0000000000000000,0x00000002,0,0), -(22618,0,0,0,0,0x0000000000000000,0x00000040,0,0), -(22620,0,0,0,0,0x0000000000000000,0x00000040,0,0), -(22648,0,0,0,0,0x0000000000000000,0x00001000,0,0), -(22835,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(22857,0,0,0,0,0x0000000000000000,0x00000002,0,0), -(23340,0,0,0,0,0x0000000000000000,0x00000002,0,0), -(23378,0,0,0,0,0x0000000000000000,0x00000002,0,0), -(23547,0,0,0,0,0x0000000000000000,0x00000020,0,0), -(23548,0,0,0,0,0x0000000000000000,0x00000040,0,0), -(23551,0,0,0,0,0x00000000000000C0,0x00004000,0,0), -(23552,0,0,0,0,0x0000000000000000,0x00100402,0,3), -(23572,0,0,0,0,0x00000000000000C0,0x00004000,0,0), -(23578,0,0,0,0,0x0000000000000000,0x00080000,2,0), -(23581,0,0,0,0,0x0000000000000000,0x00000001,2,0), -(23686,0,0,0,0,0x0000000000000000,0x00000001,2,0), -(23688,0,0,0,0,0x0000000000000000,0x00004000,0,0), -(23689,0,0,0,0,0x0000000000000000,0x00000001,4,0), -(23695,0,0,0,0,0x0000000000000002,0x00020000,0,0), -(23721,0,0,0,0,0x0000000000000800,0x00020000,0,0), -(23771,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(23780,0,0,0,0,0x0000000000000000,0x00100002,0,0), -(23863,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(23867,0,0,0,0,0x0000000000000000,0x00000081,0,0), -(23885,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(23886,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(23887,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(23888,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(24051,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(24256,0,0,0,0,0x0000000000000000,0x00080001,0,0), -(24389,4,0,0,0,0x0000000000000000,0x00020000,0,0), -(24398,0,0,0,0,0x0000000000000000,0x00100402,0,3), -(24574,0,0,0,0,0x0000000000000000,0x00100002,0,0), -(24596,0,0,0,0,0x0000000000000000,0x00000000,0,0), -(24597,0,0,0,0,0x0000000000000000,0x00080001,0,0), -(24603,0,0,0,0,0x0000000000000000,0x00080001,0,0), -(24604,0,0,0,0,0x0000000000000000,0x00080001,0,0), -(24605,0,0,0,0,0x0000000000000000,0x00080001,0,0), -(24658,0,0,0,0,0x0000000000000000,0x00004000,0,0), -(24661,0,0,0,0,0x0000000000000000,0x00080001,0,0), -(24905,0,0,0,0,0x0000000000000000,0x00000001,15,0), -(24932,0,0,0,0,0x0000000000000000,0x00001000,0,6), -(24949,0,0,0,0,0x0000000000000000,0x00000000,0,0), -(25020,0,0,0,0,0x0000000000000000,0x00000402,0,0), -(25023,0,0,0,0,0x0000000000000000,0x00000002,0,0), -(25296,0,0,0,0,0x0000000000000000,0x00080000,0,0), -(25431,0,0,0,0,0x0000000000000000,0x00000402,0,0), -(25441,0,0,0,0,0x0000000000000000,0x00100000,0,0), -(25461,0,0,0,0,0x0000000000000000,0x00000002,0,0), -(25469,0,0,0,0,0x0000000000000000,0x00100402,0,3), -(25472,0,0,0,0,0x0000000000000000,0x00100402,0,3), -(25477,0,0,0,0,0x0000000000000000,0x00100402,0,3), -(25513,0,0,0,0,0x0000000000000000,0x00100402,0,0), -(25669,0,0,0,0,0x0000000000000000,0x00000001,1,0), -(25759,0,0,0,0,0x0000000000000000,0x00000000,0,0), -(25760,0,0,0,0,0x0000000000000000,0x00000000,0,0), -(25761,0,0,0,0,0x0000000000000000,0x00000000,0,0), -(25762,0,0,0,0,0x0000000000000000,0x00000000,0,0), -(25767,0,0,0,0,0x0000000000000000,0x00020000,0,0), -(25820,0,0,0,0,0x0000000000000000,0x00100402,0,0), -(25899,0,0,0,0,0x0000000000000000,0x00000040,0,0), -(25906,0,0,0,0,0x0000000000000000,0x00020000,0,0), -(25937,0,0,0,0,0x0000000000000000,0x00000000,0,0), -(25988,0,0,0,0,0x0000000000000000,0x00040000,0,0), -(26016,0,0,0,0,0x0000000000000000,0x00000001,2,0), -(26021,0,0,0,0,0x0000000000000000,0x00000001,2,0), -(26107,0,0,0,7,0x0000008000800000,0xC4000000,0,0), -(26119,0,0,0,11,0x0000000090100003,0x00004000,0,0), -(26128,0,0,0,0,0x0000000000000000,0x02000000,0,0), -(26135,0,0,0,0,0x0000000000800000,0x00004000,0,0), -(26169,0,0,0,0,0x0000000000000000,0x08000000,0,0), -(26376,0,0,0,0,0x0000000000000000,0x00000000,0,0), -(26463,0,0,0,0,0x0000000000000000,0x00100000,0,0), -(26467,0,0,0,0,0x0000000000000000,0x08000000,0,0), -(26480,0,0,0,0,0x0000000000000000,0x00080001,3,0), -(27009,0,0,0,0,0x0000000000000000,0x00000002,0,0), -(27044,0,0,0,0,0x0000000000000000,0x00080000,0,0), -(27124,0,0,0,0,0x0000000000000000,0x00000002,0,0), -(27155,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(27160,0,0,0,0,0x0000000000000000,0x00000001,20,0), -(27162,0,0,0,0,0x0000000000000000,0x00000002,0,0), -(27164,0,0,0,0,0x0000000000000000,0x00100402,0,0), -(27166,0,0,0,0,0x0000000000000000,0x00000001,20,0), -(27168,0,0,0,0,0x0000000000000000,0x00000040,0,0), -(27169,0,0,0,0,0x0000000000000000,0x00000040,0,0), -(27170,0,0,0,0,0x0000000000000000,0x00000001,7,0), -(27179,0,0,0,0,0x0000000000000000,0x00000040,0,0), -(27200,0,0,0,0,0x0000000000000000,0x00000000,0,0), -(27217,0,0,0,0,0x0000000000000000,0x00000004,0,0), -(27243,0,0,0,0,0x0000000000000000,0x00008000,0,0), -(27280,0,0,0,0,0x0000000000000000,0x00000002,0,0), -(27419,0,0,0,0,0x0000000000000000,0x00000001,3,0), -(27420,0,0,0,0,0x0000000000000000,0x00000000,0,0), -(27498,0,0,0,0,0x0000000000000000,0x00000001,3,0), -(27521,0,0,0,0,0x0000000000000000,0x00004000,0,0), -(27522,0,0,0,0,0x0000000000000000,0x00080001,0,0), -(27539,0,0,0,0,0x0000000000000000,0x00100000,0,0), -(27561,0,0,0,0,0x0000000000000000,0x00020000,0,0), -(27656,0,0,0,0,0x0000000000000000,0x00000001,3,0), -(27688,0,0,0,0,0x0000000000000000,0x00100402,0,0), -(27774,0,0,0,0,0x0000000000000000,0x00004000,0,0), -(27776,0,0,0,0,0x0000000000000000,0x00000002,0,0), -(27778,0,0,0,0,0x0000000000000000,0x00000002,0,0), -(27780,0,0,0,0,0x0000000000000000,0x00000002,0,0), -(27781,0,0,0,0,0x0000000000000000,0x00000002,0,0), -(27785,0,0,0,0,0x0000000000000000,0x00080000,0,0), -(27787,0,0,0,0,0x0000000000000000,0x00000001,3,0), -(27811,0,0,0,0,0x0000000000000000,0x00802000,0,0), -(27815,0,0,0,0,0x0000000000000000,0x00802000,0,0), -(27816,0,0,0,0,0x0000000000000000,0x00802000,0,0), -(27852,0,0,0,0,0x0000000000000000,0x00008000,0,0), -(27861,0,0,0,0,0x0000000000000000,0x00000000,0,0), -(27863,0,0,0,0,0x0000000000000000,0x00000000,0,0), -(27864,0,0,0,0,0x0000000000000000,0x00000000,0,0), -(27865,0,0,0,0,0x0000000000000000,0x00000000,0,0), -(27867,0,0,0,0,0x0000000000000000,0x00000002,0,0), -(28200,0,0,0,0,0x0000000000000000,0x08000000,0,0), -(28305,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(28429,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(28458,0,0,0,0,0x0000000000000000,0x00000000,0,0), -(28460,0,0,0,0,0x0000000000000000,0x00000000,0,0), -(28592,16,0,0,0,0x0000000000000000,0x00020000,0,0), -(28593,16,0,0,0,0x0000000000000000,0x00020000,0,0), -(28594,16,0,0,0,0x0000000000000000,0x00020000,0,0), -(28595,16,0,0,0,0x0000000000000000,0x00020000,0,0), -(28716,0,0,0,7,0x0000000000000010,0x08000000,0,0), -(28719,0,0,0,7,0x0000000000000020,0x10000000,0,0), -(28744,0,0,0,7,0x0000000000000040,0x08000000,0,0), -(28752,0,0,0,0,0x0000000000000000,0x00400000,0,0), -(28761,0,0,0,0,0x0000000000000000,0x00020000,0,0), -(28764,0,0,0,0,0x0000000000000000,0x00100000,0,0), -(28771,0,0,0,0,0x0000000000000000,0x00020000,0,0), -(28780,0,0,0,0,0x0000000000000000,0x08020000,0,0), -(28789,0,0,0,10,0x0000000000006000,0x20000000,0,0), -(28802,0,0,0,0,0x0000000000000000,0x00004000,0,0), -(28809,0,0,0,0,0x0000000000001000,0x10000000,0,0), -(28812,0,0,0,0,0x0000000000000000,0x00010000,0,0), -(28816,0,0,0,0,0x0000000000000000,0x00000001,3,0), -(28823,0,0,0,0,0x00000000000000C0,0x08000000,0,0), -(28845,0,0,0,0,0x0000000000000000,0x00000200,0,0), -(28847,0,0,0,7,0x0000000000000020,0x00004000,0,0), -(28849,0,0,0,11,0x0000000000000080,0x00004000,0,0), -(29062,0,0,0,0,0x0000000000000000,0x00802000,0,0), -(29064,0,0,0,0,0x0000000000000000,0x00802000,0,0), -(29065,0,0,0,0,0x0000000000000000,0x00802000,0,0), -(29074,20,0,0,0,0x0000000000000000,0x00010000,0,0), -(29075,20,0,0,0,0x0000000000000000,0x00010000,0,0), -(29076,20,0,0,0,0x0000000000000000,0x00010000,0,0), -(29150,0,0,0,0,0x0000000000000000,0x00000001,3,0), -(29162,0,0,0,0,0x0000000000000000,0x00000002,0,0), -(29179,0,0,0,0,0x0000000000000000,0x00010000,0,0), -(29180,0,0,0,0,0x0000000000000000,0x00010000,0,0), -(29185,0,0,0,0,0x0000000000000000,0x00000000,0,0), -(29194,0,0,0,0,0x0000000000000000,0x00000000,0,0), -(29196,0,0,0,0,0x0000000000000000,0x00000000,0,0), -(29198,0,0,0,0,0x0000000000000000,0x00000000,0,0), -(29220,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(29307,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(29441,0,0,0,0,0x0000000000000000,0x01000000,0,1), -(29444,0,0,0,0,0x0000000000000000,0x01000000,0,1), -(29445,0,0,0,0,0x0000000000000000,0x01000000,0,1), -(29446,0,0,0,0,0x0000000000000000,0x01000000,0,1), -(29447,0,0,0,0,0x0000000000000000,0x01000000,0,1), -(29448,0,0,0,0,0x0000000000000000,0xC4000001,0,0), -(29501,0,0,0,0,0x0000000000000000,0x00080000,3,0), -(29601,0,0,0,7,0x0000000000000000,0x00004000,0,0), -(29624,0,0,0,0,0x0000000000000000,0x00080000,3,0), -(29625,0,0,0,0,0x0000000000000000,0x00080000,3,0), -(29626,0,0,0,0,0x0000000000000000,0x00080000,3,0), -(29632,0,0,0,0,0x0000000000000000,0x00080000,3,0), -(29633,0,0,0,0,0x0000000000000000,0x00080000,3,0), -(29634,0,0,0,0,0x0000000000000000,0x00080000,3,0), -(29635,0,0,0,0,0x0000000000000000,0x00080000,3,0), -(29636,0,0,0,0,0x0000000000000000,0x00080000,3,0), -(29637,0,0,0,0,0x0000000000000000,0x00080000,3,0), -(29801,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(30030,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(30033,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(30079,0,0,0,0,0x0000000000000000,0x00000002,0,0), -(30080,0,0,0,0,0x0000000000000000,0x00000002,0,0), -(30081,0,0,0,0,0x0000000000000000,0x00000002,0,0), -(30160,0,0,0,0,0x0000000000000000,0x00010000,0,0), -(30293,0,0,0,5,0x000000C000000381,0x00020000,0,0), -(30295,0,0,0,5,0x000000C000000381,0x00020000,0,0), -(30296,0,0,0,5,0x000000C000000381,0x00020000,0,0), -(30299,36,0,0,0,0x0000000000000000,0x00100000,0,0), -(30301,36,0,0,0,0x0000000000000000,0x00100000,0,0), -(30302,36,0,0,0,0x0000000000000000,0x00100000,0,0), -(30339,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(30482,0,0,0,0,0x0000000000000000,0x00000002,0,0), -(30636,0,0,0,0,0x0000000000000000,0x00080001,0,0), -(30675,0,0,0,11,0x0000000000000003,0x00004000,0,0), -(30678,0,0,0,11,0x0000000000000003,0x00004000,0,0), -(30679,0,0,0,11,0x0000000000000003,0x00004000,0,0), -(30680,0,0,0,11,0x0000000000000003,0x00004000,0,0), -(30681,0,0,0,11,0x0000000000000003,0x00004000,0,0), -(30802,0,0,0,0,0x0000000000000000,0x00001000,0,0), -(30808,0,0,0,0,0x0000000000000000,0x00001000,0,0), -(30809,0,0,0,0,0x0000000000000000,0x00001000,0,0), -(30810,0,0,0,0,0x0000000000000000,0x00001000,0,0), -(30811,0,0,0,0,0x0000000000000000,0x00001000,0,0), -(30823,0,0,0,0,0x0000000000000000,0x00000001,10.5,0), -(30881,0,0,0,0,0x0000000000000000,0x00008000,0,5), -(30883,0,0,0,0,0x0000000000000000,0x00008000,0,5), -(30884,0,0,0,0,0x0000000000000000,0x00008000,0,5), -(30885,0,0,0,0,0x0000000000000000,0x00008000,0,5), -(30886,0,0,0,0,0x0000000000000000,0x00008000,0,5), -(31233,0,0,0,8,0x00000009003E0000,0x00020000,0,0), -(31239,0,0,0,8,0x00000009003E0000,0x00020000,0,0), -(31240,0,0,0,8,0x00000009003E0000,0x00020000,0,0), -(31241,0,0,0,8,0x00000009003E0000,0x00020000,0,0), -(31242,0,0,0,8,0x00000009003E0000,0x00020000,0,0), -(31244,0,0,0,0,0x0000000000000000,0x80000000,0,0), -(31245,0,0,0,0,0x0000000000000000,0x80000000,0,0), -(31255,0,0,0,0,0x0000000000000000,0x00000100,0,0), -(31316,0,0,0,0,0x0000000000000000,0x00000002,0,0), -(31569,0,0,0,3,0x0000000000010000,0x00004000,0,0), -(31570,0,0,0,3,0x0000000000010000,0x00004000,0,0), -(31641,0,0,0,0,0x0000000000000000,0x00080002,0,0), -(31642,0,0,0,0,0x0000000000000000,0x00080002,0,0), -(31785,0,0,0,0,0x0000000000000000,0x20000000,0,0), -(31794,0,0,0,0,0x0000000000000000,0x00004000,0,0), -(31801,0,0,0,0,0x0000000000000000,0x00000001,20,0), -(31828,0,0,0,0,0x0000000000000000,0x00008000,0,0), -(31829,0,0,0,0,0x0000000000000000,0x00008000,0,0), -(31830,0,0,0,0,0x0000000000000000,0x00008000,0,0), -(31833,0,0,0,10,0x0000000080000000,0x00004000,0,0), -(31835,0,0,0,10,0x0000000080000000,0x00004000,0,0), -(31836,0,0,0,10,0x0000000080000000,0x00004000,0,0), -(31892,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(31895,0,0,0,0,0x0000000000000000,0x00000001,5,0), -(31896,0,0,0,0,0x0000000000000000,0x00000001,2,0), -(32215,0,0,0,0,0x0000000000000000,0x00000004,0,0), -(32385,0,0,0,5,0x0000001100000402,0x00020000,0,0), -(32387,0,0,0,5,0x0000001100000402,0x00020000,0,0), -(32392,0,0,0,5,0x0000001100000402,0x00020000,0,0), -(32393,0,0,0,5,0x0000001100000402,0x00020000,0,0), -(32394,0,0,0,5,0x0000001100000402,0x00020000,0,0), -(32587,0,0,0,0,0x0000000000000000,0x00000040,0,0), -(32593,0,0,0,0,0x0000000000000000,0x00100402,0,3), -(32594,0,0,0,0,0x0000000000000000,0x00100402,0,3), -(32642,0,0,0,0,0x0000000000000000,0x00000040,0,0), -(32734,0,0,0,0,0x0000000000000000,0x00000002,0,3), -(32748,0,0,0,8,0x0000000100000000,0x00080000,0,0), -(32776,0,0,0,0,0x0000000000000000,0x00000040,0,0), -(32777,0,0,0,0,0x0000000000000000,0x00000040,0,0), -(32837,0,0,0,0,0x0000000000000000,0x00004000,0,45), -(32850,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(32863,0,0,0,0,0x0000000000000000,0x00008000,0,0), -(33012,0,0,0,0,0x0000000000000000,0x00000004,0,0), -(33014,0,0,0,0,0x0000000000000000,0x00000004,0,0), -(33089,0,0,0,0,0x0000000000000000,0x00000040,0,0), -(33142,0,0,0,0,0x0000000000000000,0x00842000,0,0), -(33145,0,0,0,0,0x0000000000000000,0x00842000,0,0), -(33146,0,0,0,0,0x0000000000000000,0x00842000,0,0), -(33150,0,0,0,0,0x0000000000000000,0x10010000,0,0), -(33154,0,0,0,0,0x0000000000000000,0x10010000,0,0), -(33191,0,0,0,6,0x0000040000808000,0x00020000,0,0), -(33192,0,0,0,6,0x0000040000808000,0x00020000,0,0), -(33193,0,0,0,6,0x0000040000808000,0x00020000,0,0), -(33194,0,0,0,6,0x0000040000808000,0x00020000,0,0), -(33195,0,0,0,6,0x0000040000808000,0x00020000,0,0), -(33297,0,0,0,0,0x0000000000000000,0x00020000,0,0), -(33299,0,0,0,0,0x0000000000000000,0x00004000,0,0), -(33493,0,0,0,0,0x0000000000000000,0x00000002,0,0), -(33510,0,0,0,0,0x0000000000000000,0x00080001,5,0), -(33511,0,0,0,0,0x0000000000000000,0x00020000,0,0), -(33522,0,0,0,0,0x0000000000000000,0x00020000,0,0), -(33648,0,0,0,0,0x0000000000000000,0x00401000,0,0), -(33727,0,0,0,0,0x0000000000000000,0x00000000,0,0), -(33735,0,0,0,0,0x0000000000000000,0xC4000001,0,0), -(33736,0,0,0,0,0x0000000000000000,0x00100402,0,3), -(33746,0,0,0,0,0x0000000000000000,0x00000004,0,10), -(33754,0,0,0,0,0x0000000000000000,0x00000000,0,0), -(33755,0,0,0,0,0x0000000000000000,0x00000000,0,0), -(33756,0,0,0,0,0x0000000000000000,0x00000000,0,0), -(33757,0,0,0,0,0x0000000000000000,0x00000001,0,3), -(33759,0,0,0,0,0x0000000000000000,0x00000004,0,10), -(33776,0,0,0,0,0x0000000000000000,0x20000000,0,0), -(33881,0,0,0,0,0x0000000000000000,0x00842000,0,0), -(33882,0,0,0,0,0x0000000000000000,0x00842000,0,0), -(33883,0,0,0,0,0x0000000000000000,0x00842000,0,0), -(33953,0,0,0,0,0x0000000000000000,0x08000000,0,0), -(34082,0,0,0,0,0x0000000000000000,0x00000000,0,0), -(34138,0,0,0,11,0x0000000000000080,0x08000000,0,0), -(34303,0,0,0,0,0x0000000000000000,0x00000080,0,0), -(34320,0,0,0,0,0x0000000000000000,0x00010000,0,0), -(34355,0,0,0,0,0x0000000000000000,0x00100402,0,3), -(34457,0,0,0,0,0x0000000000000000,0x00001000,0,0), -(34497,0,0,0,0,0x0000000000000000,0x00400000,0,0), -(34498,0,0,0,0,0x0000000000000000,0x00400000,0,0), -(34499,0,0,0,0,0x0000000000000000,0x00400000,0,0), -(34500,0,0,0,0,0x0000000000000000,0x00400000,0,0), -(34502,0,0,0,0,0x0000000000000000,0x00400000,0,0), -(34503,0,0,0,0,0x0000000000000000,0x00400000,0,0), -(34506,0,0,0,0,0x0000000000000000,0x00080000,0,0), -(34507,0,0,0,0,0x0000000000000000,0x00080000,0,0), -(34508,0,0,0,0,0x0000000000000000,0x00080000,0,0), -(34586,0,0,0,0,0x0000000000000000,0x00080001,1.5,0), -(34749,0,0,0,0,0x0000000000000000,0x02000000,0,0), -(34753,0,0,0,6,0x0000000000001800,0x08000000,0,0), -(34774,0,0,0,0,0x0000000000000000,0x00080001,1.5,20), -(34827,0,0,0,0,0x0000000000000000,0x00100402,0,3), -(34838,0,0,0,0,0x0000000000000000,0x00080000,0,0), -(34839,0,0,0,0,0x0000000000000000,0x00080000,0,0), -(34859,0,0,0,6,0x0000000000001800,0x08000000,0,0), -(34860,0,0,0,6,0x0000000000001800,0x08000000,0,0), -(34914,32,0,0,0,0x0000000000000000,0x00008000,0,0), -(34916,32,0,0,0,0x0000000000000000,0x00008000,0,0), -(34917,32,0,0,0,0x0000000000000000,0x00008000,0,0), -(34935,0,0,0,0,0x0000000000000000,0x00000002,0,8), -(34938,0,0,0,0,0x0000000000000000,0x00000002,0,8), -(34939,0,0,0,0,0x0000000000000000,0x00000002,0,8), -(34948,0,0,0,0,0x0000000000000000,0x00000004,0,0), -(34949,0,0,0,0,0x0000000000000000,0x00000004,0,0), -(34950,0,0,0,0,0x0000000000000000,0x00400000,0,0), -(34954,0,0,0,0,0x0000000000000000,0x00400000,0,0), -(35077,0,0,0,0,0x0000000000000000,0x00008000,0,60), -(35080,0,0,0,0,0x0000000000000000,0x00000001,0,60), -(35083,0,0,0,0,0x0000000000000000,0x00020000,0,60), -(35086,0,0,0,0,0x0000000000000000,0x08020000,0,60), -(35100,0,0,0,0,0x0000000000000000,0x00080000,0,0), -(35102,0,0,0,0,0x0000000000000000,0x00080000,0,0), -(35103,0,0,0,0,0x0000000000000000,0x00080000,0,0), -(35205,0,0,0,0,0x0000000000000000,0xC4000001,0,0), -(35541,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(35550,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(35551,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(35552,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(35553,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(35942,0,0,0,0,0x0000000000000000,0x00080001,0,0), -(36111,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(36123,0,0,0,0,0x0000000000000000,0x00008000,0,0), -(36576,0,0,0,0,0x0000000000000000,0x00008000,0,0), -(37168,0,0,0,8,0x00000009003E0000,0x00020000,0,0), -(37169,0,0,0,8,0x0000000000020000,0x00000000,0,0), -(37170,0,0,0,0,0x0000000000000000,0x00000001,1,0), -(37173,0,0,0,8,0x000001062CBC0598,0x000A0001,0,30), -(37188,0,0,0,10,0x0000000000800000,0x00004000,0,0), -(37189,0,0,0,10,0x0000000000006000,0x10000000,0,60), -(37195,0,0,0,10,0x0000000000800000,0x00004000,0,0), -(37197,0,0,0,0,0x0000000000000000,0x00004000,0,45), -(37213,0,0,0,11,0x0000000090100007,0x00010000,0,0), -(37227,0,0,0,11,0x00000000000001C0,0x10000000,0,60), -(37228,0,0,0,11,0x0000000090100007,0x00020000,0,0), -(37237,0,0,0,11,0x0000000000000001,0x00010000,0,0), -(37239,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(37247,8,0,0,0,0x0000000000000000,0x00004000,0,45), -(37288,0,0,0,0,0x0000000000000000,0x08000000,0,0), -(37295,0,0,0,0,0x0000000000000000,0x00020000,0,0), -(37306,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(37311,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(37336,0,0,0,0,0x0000000000000000,0x00084001,0,0), -(37377,32,0,0,0,0x0000000000000000,0x00004000,0,0), -(37381,0,0,0,0,0x0000000000000000,0x000A0001,0,0), -(37443,0,0,0,0,0x0000000000000000,0x00010000,0,0), -(37447,0,0,0,3,0x0000010000000000,0x00004000,0,0), -(37514,0,0,0,0,0x0000000000000000,0x00000020,0,0), -(37519,0,0,0,0,0x0000000000000000,0x04000000,0,0), -(37525,0,0,0,0,0x0000000000000000,0x00100402,0,0), -(37528,0,0,0,4,0x0000000000000004,0x00000001,0,0), -(37604,0,0,0,0,0x0000000000000000,0x00004000,0,0), -(37617,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(37655,0,0,0,0,0x0000000000000000,0x00004000,0,60), -(37657,0,0,0,0,0x0000000000000000,0x00010000,0,0), -(37705,0,0,0,0,0x0000000000000000,0x08000000,0,0), -(37982,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(38031,0,0,0,0,0x0000000000000000,0x00000040,0,0), -(38196,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(38252,0,0,0,0,0x0000000000000000,0x00008000,0,0), -(38290,0,0,0,0,0x0000000000000000,0x00080000,3,0), -(38299,0,0,0,0,0x0000000000000000,0x08000000,0,0), -(38319,0,0,0,0,0x0000000000000000,0x00004000,0,0), -(38332,0,0,0,0,0x0000000000000000,0x08000000,0,0), -(38334,0,0,0,0,0x0000000000000000,0x00004000,0,60), -(38347,0,0,0,0,0x0000000000000000,0x00010000,0,0), -(38350,0,0,0,0,0x0000000000000000,0x00401000,0,0), -(38394,0,0,0,5,0x0000000000000006,0x00020000,0,0), -(38427,0,0,0,0,0x0000000000000000,0x00000001,0,0), -(39027,0,0,0,0,0x0000000000000000,0x00100402,0,3), -(39367,0,0,0,0,0x0000000000000000,0x00008000,0,0), -(39372,0,0,0,0,0x0000000000000000,0x00020000,0,0), -(39437,4,0,0,0,0x0000000000000000,0x00004000,0,0), -(39438,0,0,0,0,0x0000000000000000,0x00080001,0,0), -(39440,0,0,0,0,0x0000000000000000,0x00020000,0,0), -(39442,0,0,0,0,0x0000000000000000,0x00020001,0,0), -(39443,0,0,0,0,0x0000000000000000,0x00401000,0,0), -(39444,0,0,0,0,0x0000000000000000,0x00100002,0,0), -(39446,0,0,0,0,0x0000000000000000,0x00000004,0,0), -(39530,0,0,0,0,0x0000000000000000,0x00004000,0,0), -(39958,0,0,0,0,0x0000000000000000,0x00000001,0.7,40), -(40353,0,0,0,0,0x0000000000000000,0xC4000001,0,0), -(40407,0,0,0,0,0x0000000000000000,0x00000402,6,0), -(40438,0,0,0,6,0x0000000000008010,0x08020000,0,0), -(40442,0,0,0,7,0x0000044000000014,0x00004001,0,0), -(40444,0,0,0,0,0x0000000000000000,0x00000040,0,0), -(40458,0,0,0,4,0x0000060102000000,0x00000001,0,0), -(40463,0,0,0,11,0x0000001000000081,0x00004001,0,0), -(40470,0,0,0,10,0x00000000C0800000,0x00004000,0,0), -(40475,0,0,0,0,0x0000000000000000,0x00080001,3,0), -(40482,0,0,0,0,0x0000000000000000,0x00010000,0,0), -(40485,0,0,0,9,0x0000000100000000,0x00080000,0,0), -(40478,0,0,0,5,0x0000000000000002,0x00020000,0,0), -(40971,0,0,0,0,0x0000000000000000,0x08000000,0,0), -(41260,0,0,0,0,0x0000000000000000,0x00000004,0,10), -(41262,0,0,0,0,0x0000000000000000,0x00000004,0,10), -(41434,0,0,0,0,0x0000000000000000,0x00000001,2,45), -(41635,0,0,0,0,0x0000000000000000,0x00008000,0,0), -(41989,0,0,0,0,0x0000000000000000,0x00000001,3,0), -(42083,0,0,0,0,0x0000000000000000,0x00401000,0,0), -(42135,0,0,0,0,0x0000000000000000,0x00100402,0,90), -(42136,0,0,0,0,0x0000000000000000,0x00100402,0,90), -(42370,0,0,0,11,0x0000000000000080,0x08000000,0,0), -(43338,0,0,0,0,0x0000000000000000,0x00001000,0,0), -(43728,0,0,0,11,0x0000000000000080,0x08000000,0,0), -(43737,0,0,0,7,0x0000044000000000,0x00000001,0,10), -(43739,0,0,0,7,0x0000000000000002,0x00020000,0,0), -(43745,0,0,0,10,0x0000020000000000,0x00020000,0,0), -(43748,0,0,0,11,0x0000000090100000,0x00004000,0,0), -(43750,0,0,0,11,0x0000000000000001,0x00004000,0,0), -(43823,0,0,0,0,0x0000000000000000,0x00008000,0,0), -(44604,0,0,0,0,0x0000000000000000,0x00004000,0,0), -(44599,0,0,0,0,0x0000000000000000,0x00000001,0,5), -(44835,0,0,0,7,0x0000008000000000,0x00000001,0,0), -(45040,0,0,0,0,0x0000000000000000,0x00080001,0,0), -(45054,0,0,0,0,0x0000000000000000,0x00020000,0,15), -(45057,0,0,0,0,0x0000000000000000,0x00000002,0,30), -(45059,0,0,0,0,0x0000000000000000,0x08000000,0,0), -(45234,0,0,0,0,0x0000000000000000,0x00842000,0,0), -(45243,0,0,0,0,0x0000000000000000,0x00842000,0,0), -(45244,0,0,0,0,0x0000000000000000,0x00842000,0,0), -(45354,0,0,0,0,0x0000000000000000,0x00000001,0,45), -(45355,0,0,0,0,0x0000000000000000,0x00080001,0,0), -(45444,0,0,0,0,0x0000000000000000,0x00100402,0,0), -(45481,0,0,0,0,0x0000000000000000,0x08020000,0,45), -(45482,0,0,0,0,0x0000000000000000,0x00080001,0,45), -(45483,0,0,0,0,0x0000000000000000,0x00080001,0,45), -(45484,0,0,0,0,0x0000000000000000,0x08000000,0,45), -(46046,0,0,0,0,0x0000000000000000,0x00000001,0,5), -(46098,0,0,0,11,0x0000000000000080,0x08000000,0,0), -(46364,0,0,0,0,0x0000000000000000,0x00100402,0,0), -(46569,0,0,0,0,0x0000000000000000,0x00004000,0,45), -(46832,0,0,0,7,0x0000000000000001,0x00004000,0,0); -/*!40000 ALTER TABLE `spell_proc_event` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `spell_script_target` --- - -DROP TABLE IF EXISTS `spell_script_target`; -CREATE TABLE `spell_script_target` ( - `entry` mediumint(8) unsigned NOT NULL, - `type` tinyint(3) unsigned NOT NULL default '0', - `targetEntry` mediumint(8) unsigned NOT NULL default '0', - UNIQUE KEY `entry_type_target` (`entry`,`type`,`targetEntry`) -) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT='Spell System'; - --- --- Dumping data for table `spell_script_target` --- - -LOCK TABLES `spell_script_target` WRITE; -/*!40000 ALTER TABLE `spell_script_target` DISABLE KEYS */; -/*!40000 ALTER TABLE `spell_script_target` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `spell_scripts` --- - -DROP TABLE IF EXISTS `spell_scripts`; -CREATE TABLE `spell_scripts` ( - `id` mediumint(8) unsigned NOT NULL default '0', - `delay` int(10) unsigned NOT NULL default '0', - `command` mediumint(8) unsigned NOT NULL default '0', - `datalong` mediumint(8) unsigned NOT NULL default '0', - `datalong2` int(10) unsigned NOT NULL default '0', - `datatext` text NOT NULL, - `x` float NOT NULL default '0', - `y` float NOT NULL default '0', - `z` float NOT NULL default '0', - `o` float NOT NULL default '0' -) ENGINE=MyISAM DEFAULT CHARSET=utf8; - --- --- Dumping data for table `spell_scripts` --- - -LOCK TABLES `spell_scripts` WRITE; -/*!40000 ALTER TABLE `spell_scripts` DISABLE KEYS */; -/*!40000 ALTER TABLE `spell_scripts` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `spell_target_position` --- - -DROP TABLE IF EXISTS `spell_target_position`; -CREATE TABLE `spell_target_position` ( - `id` mediumint(8) unsigned NOT NULL default '0' COMMENT 'Identifier', - `target_map` smallint(5) unsigned NOT NULL default '0', - `target_position_x` float NOT NULL default '0', - `target_position_y` float NOT NULL default '0', - `target_position_z` float NOT NULL default '0', - `target_orientation` float NOT NULL default '0', - PRIMARY KEY (`id`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Spell System'; - --- --- Dumping data for table `spell_target_position` --- - -LOCK TABLES `spell_target_position` WRITE; -/*!40000 ALTER TABLE `spell_target_position` DISABLE KEYS */; -/*!40000 ALTER TABLE `spell_target_position` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `spell_threat` --- - -DROP TABLE IF EXISTS `spell_threat`; -CREATE TABLE `spell_threat` ( - `entry` mediumint(8) unsigned NOT NULL, - `Threat` smallint(6) NOT NULL, - PRIMARY KEY (`entry`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED; - --- --- Dumping data for table `spell_threat` --- - -LOCK TABLES `spell_threat` WRITE; -/*!40000 ALTER TABLE `spell_threat` DISABLE KEYS */; -INSERT INTO `spell_threat` VALUES -(78,20), -(284,39), -(285,59), -(770,108), -(778,108), -(1608,78), -(1672,180), -(1715,61), -(2139,300), -(6343,17), -(6572,155), -(6574,195), -(6809,89), -(7372,101), -(7373,141), -(7379,235), -(7386,100), -(7405,140), -(8198,40), -(8204,64), -(8205,96), -(8380,180), -(8972,118), -(9745,148), -(9749,108), -(9880,178), -(9881,207), -(9907,108), -(11556,43), -(11564,98), -(11565,118), -(11566,137), -(11567,145), -(11580,143), -(11581,180), -(11596,220), -(11597,261), -(11600,275), -(11601,315), -(11775,395), -(14274,200), -(14921,415), -(15629,300), -(15630,400), -(15631,500), -(15632,600), -(16857,108), -(17735,200), -(17750,300), -(17751,450), -(17752,600), -(17390,108), -(17391,108), -(17392,108), -(20569,100), -(20736,100), -(20925,20), -(20927,30), -(20928,40), -(23922,160), -(23923,190), -(23924,220), -(23925,250), -(24394,580), -(24583,5), -(25225,300), -(25231,130), -(25258,286), -(25264,215), -(25269,400), -(25286,175), -(25288,355), -(25289,60), -(26993,127), -(26996,176), -(27011,127), -(27179,54), -(29704,230), -(29707,196), -(30324,220), -(30356,323), -(30357,483), -(33745,285), -(33878,129), -(33986,180), -(33987,232); -/*!40000 ALTER TABLE `spell_threat` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `transports` --- - -DROP TABLE IF EXISTS `transports`; -CREATE TABLE `transports` ( - `entry` mediumint(8) unsigned NOT NULL default '0', - `name` text, - `period` mediumint(8) unsigned NOT NULL default '0', - PRIMARY KEY (`entry`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Transports'; - --- --- Dumping data for table `transports` --- - -LOCK TABLES `transports` WRITE; -/*!40000 ALTER TABLE `transports` DISABLE KEYS */; -/*!40000 ALTER TABLE `transports` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Table structure for table `uptime` --- - -DROP TABLE IF EXISTS `uptime`; -CREATE TABLE `uptime` ( - `starttime` bigint(20) unsigned NOT NULL default '0', - `startstring` varchar(64) NOT NULL default '', - `uptime` bigint(20) unsigned NOT NULL default '0', - `maxplayers` smallint(5) unsigned NOT NULL default '0', - PRIMARY KEY (`starttime`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='Uptime system'; - --- --- Dumping data for table `uptime` --- - -LOCK TABLES `uptime` WRITE; -/*!40000 ALTER TABLE `uptime` DISABLE KEYS */; -/*!40000 ALTER TABLE `uptime` ENABLE KEYS */; -UNLOCK TABLES; -/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; - -/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; -/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; -/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; -/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; -/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; -/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; -/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; - --- Dump completed on 2008-03-30 15:34:54 +-- MySQL dump 10.11 +-- +-- Host: localhost Database: mangos +-- ------------------------------------------------------ +-- Server version 5.0.56-nt + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!40101 SET NAMES utf8 */; +/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; +/*!40103 SET TIME_ZONE='+00:00' */; +/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; +/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; +/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; + +-- +-- Table structure for table `areatrigger_involvedrelation` +-- + +DROP TABLE IF EXISTS `areatrigger_involvedrelation`; +CREATE TABLE `areatrigger_involvedrelation` ( + `id` mediumint(8) unsigned NOT NULL default '0' COMMENT 'Identifier', + `quest` mediumint(8) unsigned NOT NULL default '0' COMMENT 'Quest Identifier', + PRIMARY KEY (`id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Trigger System'; + +-- +-- Dumping data for table `areatrigger_involvedrelation` +-- + +LOCK TABLES `areatrigger_involvedrelation` WRITE; +/*!40000 ALTER TABLE `areatrigger_involvedrelation` DISABLE KEYS */; +/*!40000 ALTER TABLE `areatrigger_involvedrelation` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `areatrigger_scripts` +-- + +DROP TABLE IF EXISTS `areatrigger_scripts`; +CREATE TABLE `areatrigger_scripts` ( + `entry` MEDIUMINT( 8 ) NOT NULL , + `ScriptName` CHAR( 64 ) NOT NULL , + PRIMARY KEY ( `entry` ) +) ENGINE = MYISAM DEFAULT CHARSET=utf8; + +-- +-- Table structure for table `areatrigger_tavern` +-- + +DROP TABLE IF EXISTS `areatrigger_tavern`; +CREATE TABLE `areatrigger_tavern` ( + `id` mediumint(8) unsigned NOT NULL default '0' COMMENT 'Identifier', + `name` text, + PRIMARY KEY (`id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Trigger System'; + +-- +-- Dumping data for table `areatrigger_tavern` +-- + +LOCK TABLES `areatrigger_tavern` WRITE; +/*!40000 ALTER TABLE `areatrigger_tavern` DISABLE KEYS */; +/*!40000 ALTER TABLE `areatrigger_tavern` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `areatrigger_teleport` +-- + +DROP TABLE IF EXISTS `areatrigger_teleport`; +CREATE TABLE `areatrigger_teleport` ( + `id` mediumint(8) unsigned NOT NULL default '0' COMMENT 'Identifier', + `name` text, + `required_level` tinyint(3) unsigned NOT NULL default '0', + `required_item` mediumint(8) unsigned NOT NULL default '0', + `required_item2` mediumint(8) unsigned NOT NULL default '0', + `heroic_key` mediumint(8) unsigned NOT NULL default '0', + `heroic_key2` mediumint(8) unsigned NOT NULL default '0', + `required_quest_done` int(11) unsigned NOT NULL default '0', + `required_failed_text` text, + `target_map` smallint(5) unsigned NOT NULL default '0', + `target_position_x` float NOT NULL default '0', + `target_position_y` float NOT NULL default '0', + `target_position_z` float NOT NULL default '0', + `target_orientation` float NOT NULL default '0', + PRIMARY KEY (`id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Trigger System'; + +-- +-- Dumping data for table `areatrigger_teleport` +-- + +LOCK TABLES `areatrigger_teleport` WRITE; +/*!40000 ALTER TABLE `areatrigger_teleport` DISABLE KEYS */; +/*!40000 ALTER TABLE `areatrigger_teleport` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `battleground_template` +-- + +DROP TABLE IF EXISTS `battleground_template`; +CREATE TABLE `battleground_template` ( + `id` mediumint(8) unsigned NOT NULL, + `MinPlayersPerTeam` smallint(5) unsigned NOT NULL default '0', + `MaxPlayersPerTeam` smallint(5) unsigned NOT NULL default '0', + `MinLvl` tinyint(3) unsigned NOT NULL default '0', + `MaxLvl` tinyint(3) unsigned NOT NULL default '0', + `AllianceStartLoc` mediumint(8) unsigned NOT NULL, + `AllianceStartO` float NOT NULL, + `HordeStartLoc` mediumint(8) unsigned NOT NULL, + `HordeStartO` float NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + +-- +-- Dumping data for table `battleground_template` +-- + +LOCK TABLES `battleground_template` WRITE; +/*!40000 ALTER TABLE `battleground_template` DISABLE KEYS */; +INSERT INTO `battleground_template` VALUES +(1,0,0,0,0,611,2.72532,610,2.27452), +(2,0,0,0,0,769,3.14159,770,3.14159), +(4,0,2,10,70,929,0,936,3.14159), +(3,0,0,0,0,890,3.40156,889,0.263892), +(5,0,2,10,70,939,0,940,3.14159), +(6,0,2,10,70,0,0,0,0), +(7,0,0,0,0,1103,3.40156,1104,0.263892), +(8,0,2,10,70,1258,0,1259,3.14159); +/*!40000 ALTER TABLE `battleground_template` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `battlemaster_entry` +-- + +DROP TABLE IF EXISTS `battlemaster_entry`; +CREATE TABLE `battlemaster_entry` ( + `entry` mediumint(8) unsigned NOT NULL default '0' COMMENT 'Entry of a creature', + `bg_template` mediumint(8) unsigned NOT NULL default '0' COMMENT 'Battleground template id', + PRIMARY KEY (`entry`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + +-- +-- Dumping data for table `battlemaster_entry` +-- + +LOCK TABLES `battlemaster_entry` WRITE; +/*!40000 ALTER TABLE `battlemaster_entry` DISABLE KEYS */; +/*!40000 ALTER TABLE `battlemaster_entry` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `command` +-- + +DROP TABLE IF EXISTS `command`; +CREATE TABLE `command` ( + `name` varchar(50) NOT NULL default '', + `security` tinyint(3) unsigned NOT NULL default '0', + `help` longtext, + PRIMARY KEY (`name`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Chat System'; + +-- +-- Dumping data for table `command` +-- + +LOCK TABLES `command` WRITE; +/*!40000 ALTER TABLE `command` DISABLE KEYS */; +INSERT INTO `command` VALUES +('acct',0,'Syntax: .acct\r\n\r\nDisplay the access level of your account.'), +('additem',3,'Syntax: .additem #itemid/[#itemname]/#shift-click-item-link #itemcount\r\n\r\nAdds the specified number of items of id #itemid (or exact (!) name $itemname in brackets, or link created by shift-click at item in inventory or recipe) to your or selected character inventory. If #itemcount is omitted, only one item will be added.\r\n.'), +('additemset',3,'Syntax: .additemset #itemsetid\r\n\r\nAdd items from itemset of id #itemsetid to your or selected character inventory. Will add by one example each item from itemset.'), +('addmove',2,'Syntax: .addmove #creature_guid [#waittime]\r\n\r\nAdd your current location as a waypoint for creature with guid #creature_guid. And optional add wait time.'), +('announce',1,'Syntax: .announce $MessageToBroadcast\r\n\r\nSend a global message to all players online in chat log.'), +('aura',3,'Syntax: .aura #spellid\r\n\r\nAdd the aura from spell #spellid to the selected Unit.'), +('ban',3,'Syntax is: ban $NameOrIp $bantime $reason\r\nBan account or IP and kick player.\r\n$bantime: negative value leads to permban, otherwise use a timestring like \"4d20h3s\".'), +('baninfo',3,'Syntax is: baninfo \r\nWatch full information about a specific ban.'), +('bank',3,'Syntax: .bank\r\n\r\nShow your bank inventory.'), +('banlist',3,'Syntax is: banlist $NameOrIp\r\nsearches the banlist for a pattern.'), +('cast',3,'Syntax: .cast #spellid [triggered]\r\n Cast #spellid to selected target. If no target selected cast to self. If \'trigered\' or part provided then spell casted with triggered flag.'), +('cast back',3,'Syntax: .cast back #spellid [triggered]\r\n Selected target will cast #spellid to your character. If \'trigered\' or part provided then spell casted with triggered flag.'), +('cast dist',3,'Syntax: .cast dist #spellid [#dist [triggered]]\r\n You will cast spell to pint at distance #dist. If \'trigered\' or part provided then spell casted with triggered flag. Not all spells can be casted as area spells.'), +('cast self',3,'Syntax: .cast self #spellid [triggered]\r\nCast #spellid by target at target itself. If \'trigered\' or part provided then spell casted with triggered flag.'), +('cast target',3,'Syntax: .cast target #spellid [triggered]\r\n Selected target will cast #spellid to his victim. If \'trigered\' or part provided then spell casted with triggered flag.'), +('combatstop',2,'Syntax: .combatstop [$playername]\r\nStop combat for selected character. If selected non-player then command applied to self. If $playername provided then attempt applied to online player $playername.'), +('commands',0,'Syntax: .commands\r\n\r\nDisplay a list of available commands for your account level.'), +('cooldown',3,'Syntax: .cooldown [#spell_id]\r\n\r\nRemove all (if spell_id not provided) or #spel_id spell cooldown from selected character or you (if no selection).'), +('damage',3,'Syntax: .damage $damage_amount [$school [$spellid]]\r\n\r\nApply $damage to target. If not $school and $spellid provided then this flat clean melee damage without any modifiers. If $school provided then damage modified by armor reduction (if school physical), and target absorbing modifiers and result applied as melee damage to target. If spell provided then damage modified and applied as spell damage. $spellid can be shift-link.'), +('debug anim',2,'Syntax: .debug anim #emoteid\r\n\r\nPlay emote #emoteid for your character.'), +('debug getvalue',3,'Syntax: .debug getvalue #field #isInt\r\n\r\nGet the field #field of the selected creature. If no creature is selected, get the content of your field.\r\n\r\nUse a #isInt of value 1 if the expected field content is an integer.'), +('debug playsound',1,'Syntax: .debug playsound #soundid\r\n\r\nPlay sound with #soundid.\r\nSound will be play only for you. Other players do not hear this.\r\nWarning: client may have more 5000 sounds...'), +('debug setvalue',3,'Syntax: .debug setvalue #field #value #isInt\r\n\r\nSet the field #field of the selected creature with value #value. If no creature is selected, set the content of your field.\r\n\r\nUse a #isInt of value 1 if #value is an integer.'), +('debug standstate',2,'Syntax: .debug standstate #emoteid\r\n\r\nChange the emote of your character while standing to #emoteid.'), +('debug update',3,'Syntax: .debug update #field #value\r\n\r\nUpdate the field #field of the selected character or creature with value #value.\r\n\r\nIf no #value is provided, display the content of field #field.'), +('delticket',2,'Syntax: .delticket all\r\n .delticket #num\r\n .delticket $character_name\r\n\rall to dalete all tickets at server, $character_name to delete ticket of this character, #num to delete ticket #num.'), +('demorph',2,'Syntax: .demorph\r\n\r\nDemorph the selected player.'), +('die',3,'Syntax: .die\r\n\r\nKill the selected player. If no player is selected, it will kill you.'), +('dismount',0,'Syntax: .dismount\r\n\r\nDismount you, if you are mounted.'), +('distance',3,'Syntax: .distance\r\n\r\nDisplay the distance from your character to the selected creature.'), +('event',2,'Syntax: .event #event_id\r\nShow details about event with #event_id.'), +('event activelist',2,'Syntax: .event activelist\r\nShow list of currently active events.'), +('event start',2,'Syntax: .event start #event_id\r\nStart event #event_id. Set start time for event to current moment (change not saved in DB).'), +('event stop',2,'Syntax: .event stop #event_id\r\nStop event #event_id. Set start time for event to time in past that make current moment is event stop time (change not saved in DB).'), +('explorecheat',3,'Syntax: .explorecheat #flag\r\n\r\nReveal or hide all maps for the selected player. If no player is selected, hide or reveal maps to you.\r\n\r\nUse a #flag of value 1 to reveal, use a #flag value of 0 to hide all maps.'), +('gm',1,'Syntax: .gm on/off\r\n\r\nEnable or Disable GM MODE'), +('gm fly',3,'Syntax: .gm fly on/off\r\nEnable/disable gm fly mode.'), +('gm list',0,'Syntax: .gm list\r\n\r\nDisplay a list of available Game Masters.'), +('gm visible',1,'Syntax: .gm visible on/off\r\n\r\nOutput current visibility state or make GM visible(on) and invisible(off) for other players.'), +('go creature',2,'Syntax: .go creature #creature_guid\r\nTeleport your character to creature with guid #creature_guid.\r\n.gocreature #creature_name\r\nTeleport your character to creature with this name.\r\n.gocreature id #creature_id\r\nTeleport your character to a creature that was spawned from the template with this entry.\r\n*If* more than one creature is found, then you are teleported to the first that is found inside the database.'), +('go graveyard',2,'Syntax: .go graveyard #graveyardId\r\n Teleport to graveyard with the graveyardId specified.'), +('go grid',1,'Syntax: .go grid #gridX #gridY [#mapId]\r\n\r\nTeleport the gm to center of grid with provided indexes at map #mapId (or current map if it not provided).'), +('go object',1,'Syntax: .go object #object_guid\r\nTeleport your character to gameobject with guid #object_guid'), +('go trigger',2,'Syntax: .go trigger #trigger_id\r\n\r\nTeleport your character to areatrigger with id #trigger_id. Character will be teleported to trigger target if selected areatrigger is telporting trigger.'), +('go xy',1,'Syntax: .go xy #x #y [#mapid]\r\n\r\nTeleport player to point with (#x,#y) coordinates at ground(water) level at map #mapid or same map if #mapid not provided.'), +('go xyz',1,'Syntax: .go xyz #x #y #z [#mapid]\r\n\r\nTeleport player to point with (#x,#y,#z) coordinates at ground(water) level at map #mapid or same map if #mapid not provided.'), +('go zonexy',1,'Syntax: .go zonexy #x #y [#zone]\r\n\r\nTeleport player to point with (#x,#y) client coordinates at ground(water) level in zone #zoneid or current zone if #zoneid not provided. You can look up zone using .lookup area $namepart'), +('gobject add',2,'Syntax: .gobject add #id \r\n\r\nAdd a game object from game object templates to the world at your current location using the #id.\r\nspawntimesecs sets the spawntime, it is optional.\r\n\r\nNote: this is a copy of .gameobject.'), +('gobject delete',2,'Syntax: .gobject delete #go_guid\r\nDelete gameobject with guid #go_guid.'), +('gobject move',2,'Syntax: .gobject move #goguid [#x #y #z]\r\n\r\nMove gameobject #goguid to character coordinates (or to (#x,#y,#z) coordinates if its provide).'), +('gobject near ',3,'Syntax: .gobject near [#distance]\r\n\r\nOutput gameobjects at distance #distance from player. Output gameobject guids and coordinates sorted by distance from character. If #distance not provided use 10 as default value.'), +('gobject turn',2,'Syntax: .gobject turn #goguid \r\n\r\nSet for gameobject #goguid orientation same as current character orientation.'), +('gobject target',2,'Syntax: .gobject target [#go_id|#go_name_part]\r\n\r\nLocate and show position nearest gameobject. If #go_id or #go_name_part provide then locate and show position of nearest gameobject with gameobject template id #go_id or name included #go_name_part as part.'), +('goname',1,'Syntax: .goname $charactername\r\n\r\nTeleport to the given character. Either specify the character name or click on the character\'s portrait, e.g. when you are in a group.'), +('gps',1,'Syntax: .gps\r\n\r\nDisplay the position information for a selected character or creature. Position information includes X, Y, Z, and orientation, map Id and zone Id'), +('groupgo',1,'Syntax: .groupgo $charactername\r\n\r\nTeleport the given character and his group to you.'), +('guid',2,'Syntax: .guid\r\n\r\nDisplay the GUID for the selected character.'), +('guild create',2,'Syntax: .guild create $GuildLeaderName $GuildName\r\n\r\nCreate a guild named $GuildName with the player $GuildLeaderName as leader.'), +('guild delete',2,'Syntax: .guild delete $GuildName\r\n\r\nDelete guild $GuildName.'), +('guild invite',2,'Syntax: .guild invite $CharacterName $GuildName\r\n\r\nAdd $CharacterName into a guild $GuildName.'), +('guild rank',2,'Syntax: .guild rank $CharacterName #Rank\r\n\r\nSet for $CharacterName rank #Rank in a guild.'), +('guild uninvite',2,'Syntax: .guild uninvite $CharacterName\r\n\r\nRemove $CharacterName from a guild.'), +('help',0,'Syntax: .help $command\r\n\r\nDisplay usage instructions for the given $command.'), +('hidearea',3,'Syntax: .hidearea #areaid\r\n\r\nHide the area of #areaid to the selected character. If no character is selected, hide this area to you.'), +('honor add',2,'Syntax: .honor add $amount\r\n\r\nAdd a certain amount of honor (gained today) to the selected player.'), +('honor addkill',2,'Syntax: .honor addkikll\r\n\r\nAdd the targeted unit as one of your pvp kills today (you only get honor if it\'s a racial leader or a player)'), +('honor update',2,'Syntax: .honor update\r\n\r\nForce the yesterday\'s honor fields to be updated with today\'s data, which will get reset for the selected player.'), +('hover',3,'Syntax: .hover #flag\r\n\r\nEnable or disable hover mode for your character.\r\n\r\nUse a #flag of value 1 to enable, use a #flag value of 0 to disable hover.'), +('instance unbind',3,'Syntax: .instance unbind all\r\n All of the selected player\'s binds will be cleared.'), +('instance listbinds',3,'Syntax: .instance listbinds\r\n Lists the binds of the selected player.'), +('instance stats',3,'Syntax: .instance stats\r\n Shows statistics about instances.'), +('instance savedata',3,'Syntax: .instance savedata\r\n Save the InstanceData for the current player\'s map to the DB.'), +('itemmove',2,'Syntax: .itemmove #sourceslotid #destinationslotid\r\n\r\nMove an item from slots #sourceslotid to #destinationslotid in your inventory\r\n\r\nNot yet implemented'), +('kick',2,'Syntax: .kick [$charactername]\r\n\r\nKick the given character name from the world. If no character name is provided then the selected player (except for yourself) will be kicked.'), +('learn',3,'Syntax: .learn #parameter\r\n\r\nSelected character learn a spell of id #parameter.'), +('learn all',3,'Syntax: .learn all\r\n\r\nLearn all big set different spell maybe useful for Administaror.'), +('learn all_crafts',2,'Syntax: .learn crafts\r\n\r\nLearn all professions and recipes.'), +('learn all_default',1,'Syntax: .learn all_default [$playername]\r\n\r\nLearn for selected/$playername player all default spells for his race/class and spells rewarded by completed quests.'), +('learn all_gm',2,'Syntax: .learn all_gm\r\n\r\nLearn all default spells for Game Masters.'), +('learn all_lang',1,'Syntax: .learn all_lang\r\n\r\nLearn all languages'), +('learn all_myclass',3,'Syntax: .learn all_myclass\r\n\r\nLearn all spells and talents available for his class.'), +('learn all_myspells',3,'Syntax: .learn all_myspells\r\n\r\nLearn all spells (except talents and spells with first rank learned as talent) available for his class.'), +('learn all_mytalents',3,'Syntax: .learn all_mytalents\r\n\r\nLearn all talents (and spells with first rank learned as talent) available for his class.'), +('learn all_recipes',2,'Syntax: .learn all_recipes [$profession]\r\rLearns all recipes of specified profession and sets skill level to max.\rExample: .learn all_recipes enchanting'), +('levelup',3,'Syntax: .levelup [$playername] [#numberoflevels]\r\n\r\nIncrease/decrease the level of character with $playername (or the selected if not name provided) by #numberoflevels Or +1 if no #numberoflevels provided). If #numberoflevels is omitted, the level will be increase by 1. If #numberoflevels is 0, the same level will be restarted. If no character is selected and name not provided, increase your level. Command can be used for offline character. All stats and dependent VALUESrecalculated. At level decrease talents can be reset if need. Also at level decrease equipped items with greater level requirement can be lost.'), +('linkgrave',3,'Syntax: .linkgrave #graveyard_id [alliance|horde]\r\n\r\nLink current zone to graveyard for any (or alliance/horde faction ghosts). This let character ghost from zone teleport to graveyard after die if graveyard is nearest from linked to zone and accept ghost of this faction. Add only single graveyard at another map and only if no graveyards linked (or planned linked at same map).'), +('list creature',3,'Syntax: .list creature #creature_id [#max_count]\r\n\r\nOutput creatures with creature id #creature_id found in world. Output creature guids and coordinates sorted by distance from character. Will be output maximum #max_count creatures. If #max_count not provided use 10 as default value.'), +('list item',3,'Syntax: .list item #item_id [#max_count]\r\n\r\nOutput items with item id #item_id found in all character inventories, mails and auctions. Output item guids, item owner guid, owner account and owner name. Will be output maximum #max_count items. If #max_count not provided use 10 as default value.'), +('list object',3,'Syntax: .list object #gameobject_id [#max_count]\r\n\r\nOutput gameobjects with gameobject id #gameobject_id found in world. Output gameobject guids and coordinates sorted by distance from character. Will be output maximum #max_count gameobject. If #max_count not provided use 10 as default value.'), +('loadscripts',3,'Syntax: .loadscripts $scriptlibraryname\r\n\r\nUnload current and load the script library $scriptlibraryname or reload current if $scriptlibraryname omitted, in case you changed it while the server was running.'), +('lockaccount',0,'Syntax: .lockaccount [on|off]\r\n\r\nAllow login from account only from current used IP or remove this requirement.'), +('lookup area',1,'Syntax: .lookup area $namepart\r\n\r\nLooks up an area by $namepart, and returns all matches with their area ID\'s.'), +('lookup creature',3,'Syntax: .lookup creature $namepart\r\n\r\nLooks up a creature by $namepart, and returns all matches with their creature ID\'s.'), +('lookup event',2,'Syntax: .lookup event $name\r\nAttempts to find the ID of the event with the provided $name.'), +('lookup faction',3,'Syntax: .lookup faction $name\r\nAttempts to find the ID of the faction with the provided $name.'), +('lookup item',3,'Syntax: .lookup item $itemname\r\n\r\nLooks up an item by $itemname, and returns all matches with their Item ID\'s.'), +('lookup itemset',3,'Syntax: .lookup itemset $itemname\r\n\r\nLooks up an item set by $itemname, and returns all matches with their Item set ID\'s.'), +('lookup object',3,'Syntax: .lookup object $objname\r\n\r\nLooks up an gameobject by $objname, and returns all matches with their Gameobject ID\'s.'), +('lookup player account',2,'Syntax : .lookup player account $account ($limit) \r\n\r\n Searchs players, which account username is $account with optional parametr $limit of results.'), +('lookup player ip',2,'Syntax : .lookup player ip $ip ($limit) \r\n\r\n Searchs players, which account ast_ip is $ip with optional parametr $limit of results.'), +('lookup player email',2,'Syntax : .lookup player email $email ($limit) \r\n\r\n Searchs players, which account email is $email with optional parametr $limit of results.'), +('lookup quest',3,'Syntax: .lookup quest $namepart\r\n\r\nLooks up a quest by $namepart, and returns all matches with their quest ID\'s.'), +('lookup skill',3,'Syntax: .lookup skill $$namepart\r\n\r\nLooks up a skill by $namepart, and returns all matches with their skill ID\'s.'), +('lookup spell',3,'Syntax: .lookup spell $namepart\r\n\r\nLooks up a spell by $namepart, and returns all matches with their spell ID\'s.'), +('lookup tele',1,'Syntax: .lookup tele $substring\r\n\r\nSearch and output all .tele command locations with provide $substring in name.'), +('maxskill',3,'Syntax: .maxskill\r\nSets all skills of the targeted player to their maximum VALUESfor its current level.'), +('Mod32Value',3,'Syntax: .Mod32Value #field #value\r\n\r\nAdd #value to field #field of your character.'), +('modify arena',3,'Syntax: .modify arena #value\r\nAdd $amount arena points to the selected player.'), +('modify aspeed',1,'Syntax: .modify aspeed #rate\r\n\r\nModify all speeds -run,swim,run back,swim back- of the selected player to \"normalbase speed for this move type\"*rate. If no player is selected, modify your speed.\r\n\r\n #rate may range from 0.1 to 10.'), +('modify bit',1,'Syntax: .modify bit #field #bit\r\n\r\nToggle the #bit bit of the #field field for the selected player. If no player is selected, modify your character.'), +('modify bwalk',1,'Syntax: .modify bwalk #rate\r\n\r\nModify the speed of the selected player while running backwards to \"normal walk back speed\"*rate. If no player is selected, modify your speed.\r\n\r\n #rate may range from 0.1 to 10.'), +('modify drunk',1,'Syntax: .modify drunk #value\r\n Set drunk level to #value (0..100). Value 0 remove drunk state, 100 is max drunked state.'), +('modify energy',1,'Syntax: .modify energy #energy\r\n\r\nModify the energy of the selected player. If no player is selected, modify your energy.'), +('modify faction',1,'Syntax: .modify faction #factionid #flagid #npcflagid #dynamicflagid\r\n\r\nModify the faction and flags of the selected creature. Without arguments, display the faction and flags of the selected creature.'), +('modify honor',1,'Syntax: .modify honor $amount\r\n\r\nAdd $amount honor points to the selected player.'), +('modify hp',1,'Syntax: .modify hp #newhp\r\n\r\nModify the hp of the selected player. If no player is selected, modify your hp.'), +('modify mana',1,'Syntax: .modify mana #newmana\r\n\r\nModify the mana of the selected player. If no player is selected, modify your mana.'), +('modify money',1,'Syntax:\r\n.modify money #money\r\n.money #money\r\n\r\nAdd or remove money to the selected player. If no player is selected, modify your money.\r\n\r\n #gold can be negative to remove money.'), +('modify morph',2,'Syntax: .modify morph #displayid\r\n\r\nChange your current model id to #displayid.'), +('modify mount',1,'Syntax:\r\n.modify mount #id #speed\r\nDisplay selected player as mounted at #id creature and set speed to #speed value.'), +('modify rage',1,'Syntax: .modify rage #newrage\r\n\r\nModify the rage of the selected player. If no player is selected, modify your rage.'), +('modify rep',2,'Syntax: .modify rep #repId (#repvalue | $rankname [#delta])\r\nSets the selected players reputation with faction #repId to #repvalue or to $reprank.\r\nIf the reputation rank name is provided, the resulting reputation will be the lowest reputation for that rank plus the delta amount, if specified.\r\nYou can use \'.pinfo rep\' to list all known reputation ids, or use \'.lookup faction $name\' to locate a specific faction id.'), +('modify scale',1,''), +('modify speed',1,'Syntax:\r\n.modify speed #rate\r\n.speed #rate\r\n\r\nModify the running speed of the selected player to \"normal base run speed\"*rate. If no player is selected, modify your speed.\r\n\r\n #rate may range from 0.1 to 10.'), +('modify spell',1,''), +('modify swim',1,'Syntax: .modify swim #rate\r\n\r\nModify the swim speed of the selected player to \"normal swim speed\"*rate. If no player is selected, modify your speed.\r\n\r\n #rate may range from 0.1 to 10.'), +('modify titles',1,'Syntax:\r\n.modify titles #mask\r\n\r\nAllows user to use all titles from #mask.\r\n\r\n #mask=0 disables the title-choose-field'), +('movegens',3,'Syntax: .movegens\r\n Show movement generators stack for selected creature or player.'), +('mute',1,'Syntax: .mute $playerName $timeInMinutes\r\n\r\nDisible chat messaging for any character from account of character $playerName at $timeInMinutes minutes.'), +('namego',1,'Syntax: .namego $charactername\r\n\r\nTeleport the given character to you.'), +('neargrave',3,'Syntax: .neargrave [alliance|horde]\r\n\r\nFind nearest graveyard linked to zone (or only nearest from accepts alliance or horde faction ghosts).'), +('notify',1,'Syntax: .notify $MessageToBroadcast\r\n\r\nSend a global message to all players online in screen.'), +('npc add',2,'Syntax: .npc add #creatureid\r\n\r\nSpawn a creature by the given template id of #creatureid.'), +('npc additem',2,'Syntax: .npc additem #itemId <#maxcount><#incrtime><#extendedcost>r\r\n\r\nAdd item #itemid to item list of selected vendor. Also optionally set max count item in vendor item list and time to item count restoring and items ExtendedCost.'), +('npc addweapon',3,'Not yet implemented.'), +('npc allowmove',3,'Syntax: .npc allowmove\r\n\r\nEnable or disable movement for the selected creature.'), +('npc changelevel',2,'Syntax: .npc changelevel #level\r\n\r\nChange the level of the selected creature to #level.\r\n\r\n#level may range from 1 to 63.'), +('npc delete',2,'Syntax: .npc delete [#guid]\r\n\r\nDelete creature with guid #guid (or the selected if no guid is provided)'), +('npc delitem',2,'Syntax: .npc delitem #itemId\r\n\r\nRemove item #itemid from item list of selected vendor.'), +('npc factionid',2,'Syntax: .npc factionid #factionid\r\n\r\nSet the faction of the selected creature to #factionid.'), +('npc flag',2,'Syntax: .npc flag #npcflag\r\n\r\nSet the NPC flags of creature template of the selected creature and selected creature to #npcflag. NPC flags will applied to all creatures of selected creature template after server restart or grid unload/load.'), +('npc info',3,'Syntax: .npc info\r\n\r\nDisplay a list of details for the selected creature.\r\n\r\nThe list includes:\r\n- GUID, Faction, NPC flags, Entry ID, Model ID,\r\n- Level,\r\n- Health (current/maximum),\r\n\r\n- Field flags, dynamic flags, faction template, \r\n- Position information,\r\n- and the creature type, e.g. if the creature is a vendor.'), +('npc move',2,'Syntax: .npc move [#creature_guid]\r\n\r\nMove the targeted creature spawn point to your coordinates.'), +('npc name',2,'Syntax: .npc name $name\r\n\r\nChange the name of the selected creature or character to $name.\r\n\r\nCommand disabled.'), +('npc playemote',3,'Syntax: .npc playemote #emoteid\r\n\r\nMake the selected creature emote with an emote of id #emoteid.'), +('npc setmodel',2,'Syntax: .npc setmodel #displayid\r\n\r\nChange the model id of the selected creature to #displayid.'), +('npc setmovetype',2,'Syntax: .npc setmovetype [#creature_guid] stay/random/way [NODEL]\r\n\r\nSet for creature pointed by #creature_guid (or selected if #creature_guid not provided) movement type and move it to respawn position (if creature alive). Any existing waypoints for creature will be removed from the database if you do not use NODEL. If the creature is dead then movement type will applied at creature respawn.\r\nMake sure you use NODEL, if you want to keep the waypoints.'), +('npc spawndist',2,'Syntax: .npc spawndist #dist\r\n\r\nAdjust spawndistance of selected creature to dist.'), +('npc spawntime',2,'Syntax: .npc spawntime #time \r\n\r\nAdjust spawntime of selected creature to time.'), +('npc subname',2,'Syntax: .npc subname $Name\r\n\r\nChange the subname of the selected creature or player to $Name.\r\n\r\nCommand disabled.'), +('npc textemote',3,'Syntax: .npc textemote #emoteid\r\n\r\nMake the selected creature to do textemote with an emote of id #emoteid.'), +('npc whisper',1,'Syntax: .npc whisper #playerguid #text\r\nMake the selected npc whisper #text to #playerguid.'), +('password',0,'Syntax: .password $old_password $new_password $new_password\r\n\r\nChange your account password.'), +('pinfo',2,'Syntax: .pinfo [$player_name] [rep]\r\n\r\nOutput account information for selected player or player find by $player_name. If \"rep\" parameter provided show reputation information for player.'), +('plimit',3,'Syntax: .plimit [#num|-1|-2|-3|reset|player|moderator|gamemaster|administrator]\r\n\r\nWithout arg show current player amount and security level limitations for login to server, with arg set player linit ($num > 0) or securiti limitation ($num < 0 or security leme name. With `reset` sets player limit to the one in the config file'), +('quest add',3,'Syntax: .quest add #quest_id\r\n\r\nAdd to character quest log quest #quest_id. Quest started from item can\'t be added by this command but correct .additem call provided in command output.'), +('quest complete',3,'Syntax: .quest complete #questid\r\nMark all quest objectives as completed for target character active quest. After this target character can go and get quest reward.'), +('quest remove',3,'Syntax: .quest remove #quest_id\r\n\r\nSet quest #quest_id state to not completed and not active (and remove from active quest list) for selected player.'), +('recall',1,'Syntax: .recall [$playername]\r\n\r\nTeleport $playername or selected player to the place where he has been before last use of a teleportation command. If no $playername is entered and no player is selected, it will teleport you.'), +('reload',3,'Syntax: .reload table_name\r\n\r\nReload table `table_name` if reload support added for this table and this table can be _safe_ reloaded.'), +('reload all',3,'Syntax: .reload all\r\n\r\nReload all tables with reload support added and that can be _safe_ reloaded.'), +('reload all_area',3,'Syntax: .reload all_area\r\n\r\nReload all `areatrigger_*` tables if reload support added for this table and this table can be _safe_ reloaded.'), +('reload all_loot',3,'Syntax: .reload all_loot\r\n\r\nReload all `*_loot_template` tables. This can be slow operation with lags for server run.'), +('reload all_quest',3,'Syntax: .reload all_quest\r\n\r\nReload all quest related tables if reload support added for this table and this table can be _safe_ reloaded.'), +('reload all_spell',3,'Syntax: .reload all\r\n\r\nReload all `spell_*` tables with reload support added and that can be _safe_ reloaded.'), +('reload config',3,'Syntax: .reload config\r\n\r\nReload config settings (by default stored in mangosd.conf). Not all settings can be change at reload: some new setting values will be ignored until restart, some values will applied with delay or only to new objects/maps, some values will explicitly rejected to change at reload.'), +('reset all',3,'Syntax: .reset all spells\r\n\r\nSyntax: .reset all talents\r\n\r\nRequest reset spells or talents at next login each existed character.'), +('reset honor',3,'Syntax:\r\n.reset honor [Playername]\r\n Reset all honor data for targeted character.'), +('reset level',3,'Syntax:\r\n.reset level [Playername]\r\n Reset level to 1 including reset stats and talents. Equipped items with greater level requirement can be lost.'), +('reset spells',3,'Syntax:\r\n.reset spells [Playername]\r\n Removes all non-original spells from spellbook.\r\n. Playername can be name of offline character.'), +('reset stats',3,'Syntax:\r\n.reset stats [Playername]\r\n Resets(recalculate) all stats of the targeted player to their original VALUESat current level.'), +('reset talents',3,'Syntax:\r\n.reset talents [Playername]\r\n Removes all talents of the targeted player. Playername can be name of offline character.'), +('respawn',3,'Syntax: .respawn\r\n\r\nRespawn all nearest creatures and GO without waiting respawn time expiration.'), +('revive',3,'Syntax: .revive\r\n\r\nRevive the selected player. If no player is selected, it will revive you.'), +('save',0,'Syntax: .save\r\n\r\nSaves your character.'), +('saveall',1,'Syntax: .saveall\r\n\r\nSave all characters in game.'), +('security',3,'Syntax: .security $name #level\r\n\r\nSet the security level of player $name to a level of #level.\r\n\r\n#level may range from 0 to 5.'), +('sendmail',1,'Syntax: .sendmail #playername #subject #text\r\n\r\nSend a mail to a player. Note: subject may not contain spaces.'), +('server info',0,'Syntax: .server info\r\n\r\nDisplay server version and the number of connected players.'), +('server idleshutdown',3,'Syntax: .server idleshutdown #delay|cancel\r\n\r\nShut the server down after #delay seconds if no active connections are present (no players) or cancel the restart/shutdown if cancel value is used.'), +('server idlerestart',3,'Syntax: .server idlerestart #delay|cancel\r\n\r\nRestart the server after #delay seconds if no active connections are present (no players) or cancel the restart/shutdown if cancel value is used.'), +('server restart',3,'Syntax: .server restart seconds\r\n\r\nRestart the server after given seconds and show "Restart server in X" or cancel the restart/shutdown if cancel value is used.'), +('server shutdown',3,'Syntax: .server shutdown seconds\r\n\r\nShut the server down after given seconds and show "Off server in X" or cancel the restart/shutdown if cancel value is used.'), +('setskill',3,'Syntax: .setskill #skill #level [#max]\r\n\r\nSet a skill of id #skill with a current skill value of #level and a maximum value of #max (or equal current maximum if not provide) for the selected character. If no character is selected, you learn the skill.'), +('showarea',3,'Syntax: .showarea #areaid\r\n\r\nReveal the area of #areaid to the selected character. If no character is selected, reveal this area to you.'), +('start',0,'Syntax: .start\r\n\r\nTeleport you to the starting area of your character.'), +('taxicheat',1,'Syntax: .taxicheat on/off\r\n\r\nTemporary grant access or remove to all taxi routes for the selected character. If no character is selected, hide or reveal all routes to you.\r\n\r\nVisited taxi nodes sill accessible after removing access.'), +('tele',1,'Syntax: .tele #location\r\n\r\nTeleport player to a given location.'), +('tele add',3,'Syntax: .tele add $name\r\n\r\nAdd current your position to .tele command target locations list with name $name.'), +('tele del',3,'Syntax: .tele del $name\r\n\r\nRemove location with name $name for .tele command locations list.'), +('tele group',1,'Syntax: .tele group#location\r\n\r\nTeleport a selected player and his group members to a given location.'), +('tele name',1,'Syntax: .tele name #playername #location\r\n\r\nTeleport a player to a given location.'), +('ticket',2,'Syntax: .ticket on\r\n .ticket off\r\n .ticket #num\r\n .ticket $character_name\r\n\r\non/off for GMs to show or not a new ticket directly, $character_name to show ticket of this character, #num to show ticket #num.'), +('transport',3,'Not yet implemented.'), +('unaura',3,'Syntax: .unaura #spellid\r\n\r\nRemove aura due to spell #spellid from the selected Unit.'), +('unban',3,'Syntax is: unban $NameOrIp\r\nUnban account or IP.'), +('unlearn',3,'Syntax: .unlearn #startspell #endspell\r\n\r\nUnlearn for selected player the range of spells between id #startspell and #endspell. If no #endspell is provided, just unlearn spell of id #startspell.'), +('unmute',1,'Syntax: .unmute $playerName\r\n\r\nRestore chat messaging for any character from account of character $playerName.'), +('wchange',3,'Syntax: .wchange #weathertype #status\r\n\r\nSet current weather to #weathertype with an intensity of #status.\r\n\r\n#weathertype can be 1 for rain, 2 for snow, and 3 for sand. #status can be 0 for disabled, and 1 for enabled.'), +('whispers',1,'Syntax: .whispers on|off\r\nEnable/disable accepting whispers by GM from players. By default use mangosd.conf setting.'), +('wp',2,'Using WP Command:\r\nEach Waypoint Command has it\'s own description!'), +('wp add',2,'Syntax: .wp add [#creature_guid or Select a Creature]'), +('wp export',3,'Syntax: .wp export [#creature_guid or Select a Creature] $filename'), +('wp import',3,'Syntax: .wp import $filename'), +('wp modify',2,'Syntax: .wp modify [#creature_guid or Select a Creature]\r\nadd - Add a waypoint after the selected visual\r\nwaittime $time\r\nemote ID\r\nspell ID\r\ntext1| text2| text3| text4| text5 \r\nmodel1 ID\r\nmodel2 ID\r\nmove(moves wp to player pos)\r\ndel (deletes the wp)\r\n\r\nOnly one parameter per time!'), +('wp show',2,'Syntax: .wp show [#creature_guid or Select a Creature]\r\non\r\nfirst\r\nlast\r\noff\r\ninfo\r\n\r\nFor using info you have to do first show on and than select a Visual-Waypoint and do the show info!'); +/*!40000 ALTER TABLE `command` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `creature` +-- + +DROP TABLE IF EXISTS `creature`; +CREATE TABLE `creature` ( + `guid` int(10) unsigned NOT NULL auto_increment COMMENT 'Global Unique Identifier', + `id` mediumint(8) unsigned NOT NULL default '0' COMMENT 'Creature Identifier', + `map` smallint(5) unsigned NOT NULL default '0' COMMENT 'Map Identifier', + `spawnMask` tinyint(3) unsigned NOT NULL default '1', + `modelid` mediumint(8) unsigned NOT NULL default '0', + `equipment_id` mediumint(9) NOT NULL default '0', + `position_x` float NOT NULL default '0', + `position_y` float NOT NULL default '0', + `position_z` float NOT NULL default '0', + `orientation` float NOT NULL default '0', + `spawntimesecs` int(10) unsigned NOT NULL default '120', + `spawndist` float NOT NULL default '5', + `currentwaypoint` mediumint(8) unsigned NOT NULL default '0', + `curhealth` int(10) unsigned NOT NULL default '1', + `curmana` int(10) unsigned NOT NULL default '0', + `DeathState` tinyint(3) unsigned NOT NULL default '0', + `MovementType` tinyint(3) unsigned NOT NULL default '0', + PRIMARY KEY (`guid`), + KEY `idx_map` (`map`), + KEY `index_id` (`id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='Creature System'; + +-- +-- Dumping data for table `creature` +-- + +LOCK TABLES `creature` WRITE; +/*!40000 ALTER TABLE `creature` DISABLE KEYS */; +/*!40000 ALTER TABLE `creature` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `creature_addon` +-- + +DROP TABLE IF EXISTS `creature_addon`; +CREATE TABLE `creature_addon` ( + `guid` int(11) NOT NULL default '0', + `mount` mediumint(8) unsigned NOT NULL default '0', + `bytes0` int(10) unsigned NOT NULL default '0', + `bytes1` int(10) unsigned NOT NULL default '0', + `bytes2` int(10) unsigned NOT NULL default '0', + `emote` int(10) unsigned NOT NULL default '0', + `moveflags` int(10) unsigned NOT NULL default '0', + `auras` text, + PRIMARY KEY (`guid`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + +-- +-- Dumping data for table `creature_addon` +-- + +LOCK TABLES `creature_addon` WRITE; +/*!40000 ALTER TABLE `creature_addon` DISABLE KEYS */; +/*!40000 ALTER TABLE `creature_addon` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `creature_equip_template` +-- + +DROP TABLE IF EXISTS `creature_equip_template`; +CREATE TABLE `creature_equip_template` ( + `entry` mediumint(8) unsigned NOT NULL default '0' COMMENT 'Unique entry', + `equipmodel1` mediumint(8) unsigned NOT NULL default '0', + `equipmodel2` mediumint(8) unsigned NOT NULL default '0', + `equipmodel3` mediumint(8) unsigned NOT NULL default '0', + `equipinfo1` int(10) unsigned NOT NULL default '0', + `equipinfo2` int(10) unsigned NOT NULL default '0', + `equipinfo3` int(10) unsigned NOT NULL default '0', + `equipslot1` int(11) NOT NULL default '0', + `equipslot2` int(11) NOT NULL default '0', + `equipslot3` int(11) NOT NULL default '0', + PRIMARY KEY (`entry`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Creature System (Equipment)'; + +-- +-- Dumping data for table `creature_equip_template` +-- + +LOCK TABLES `creature_equip_template` WRITE; +/*!40000 ALTER TABLE `creature_equip_template` DISABLE KEYS */; +/*!40000 ALTER TABLE `creature_equip_template` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `creature_involvedrelation` +-- + +DROP TABLE IF EXISTS `creature_involvedrelation`; +CREATE TABLE `creature_involvedrelation` ( + `id` mediumint(8) unsigned NOT NULL default '0' COMMENT 'Identifier', + `quest` mediumint(8) unsigned NOT NULL default '0' COMMENT 'Quest Identifier', + PRIMARY KEY (`id`,`quest`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Creature System'; + +-- +-- Dumping data for table `creature_involvedrelation` +-- + +LOCK TABLES `creature_involvedrelation` WRITE; +/*!40000 ALTER TABLE `creature_involvedrelation` DISABLE KEYS */; +/*!40000 ALTER TABLE `creature_involvedrelation` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `creature_loot_template` +-- + +DROP TABLE IF EXISTS `creature_loot_template`; +CREATE TABLE `creature_loot_template` ( + `entry` mediumint(8) unsigned NOT NULL default '0', + `item` mediumint(8) unsigned NOT NULL default '0', + `ChanceOrQuestChance` float NOT NULL default '100', + `groupid` tinyint(3) unsigned NOT NULL default '0', + `mincountOrRef` mediumint(9) NOT NULL default '1', + `maxcount` tinyint(3) unsigned NOT NULL default '1', + `lootcondition` tinyint(3) unsigned NOT NULL default '0', + `condition_value1` mediumint(8) unsigned NOT NULL default '0', + `condition_value2` mediumint(8) unsigned NOT NULL default '0', + PRIMARY KEY (`entry`,`item`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Loot System'; + +-- +-- Dumping data for table `creature_loot_template` +-- + +LOCK TABLES `creature_loot_template` WRITE; +/*!40000 ALTER TABLE `creature_loot_template` DISABLE KEYS */; +/*!40000 ALTER TABLE `creature_loot_template` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `creature_model_info` +-- + +DROP TABLE IF EXISTS `creature_model_info`; +CREATE TABLE `creature_model_info` ( + `modelid` mediumint(8) unsigned NOT NULL default '0', + `bounding_radius` float NOT NULL default '0', + `combat_reach` float NOT NULL default '0', + `gender` tinyint(3) unsigned NOT NULL default '2', + `modelid_other_gender` mediumint(8) unsigned NOT NULL default '0', + PRIMARY KEY (`modelid`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Creature System (Model related info)'; + +-- +-- Dumping data for table `creature_model_info` +-- + +LOCK TABLES `creature_model_info` WRITE; +/*!40000 ALTER TABLE `creature_model_info` DISABLE KEYS */; +/*!40000 ALTER TABLE `creature_model_info` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `creature_movement` +-- + +DROP TABLE IF EXISTS `creature_movement`; +CREATE TABLE `creature_movement` ( + `id` int(10) unsigned NOT NULL COMMENT 'Creature GUID', + `point` mediumint(8) unsigned NOT NULL default '0', + `position_x` float NOT NULL default '0', + `position_y` float NOT NULL default '0', + `position_z` float NOT NULL default '0', + `waittime` int(10) unsigned NOT NULL default '0', + `text1` text, + `text2` text, + `text3` text, + `text4` text, + `text5` text, + `emote` mediumint(8) unsigned NOT NULL default '0', + `spell` mediumint(8) unsigned NOT NULL default '0', + `wpguid` int(11) NOT NULL default '0', + `orientation` float NOT NULL default '0', + `model1` mediumint(9) NOT NULL default '0', + `model2` mediumint(9) NOT NULL default '0', + PRIMARY KEY (`id`,`point`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Creature System'; + +-- +-- Dumping data for table `creature_movement` +-- + +LOCK TABLES `creature_movement` WRITE; +/*!40000 ALTER TABLE `creature_movement` DISABLE KEYS */; +/*!40000 ALTER TABLE `creature_movement` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `creature_onkill_reputation` +-- + +DROP TABLE IF EXISTS `creature_onkill_reputation`; +CREATE TABLE `creature_onkill_reputation` ( + `creature_id` mediumint(8) unsigned NOT NULL default '0' COMMENT 'Creature Identifier', + `RewOnKillRepFaction1` smallint(6) NOT NULL default '0', + `RewOnKillRepFaction2` smallint(6) NOT NULL default '0', + `MaxStanding1` tinyint(4) NOT NULL default '0', + `IsTeamAward1` tinyint(4) NOT NULL default '0', + `RewOnKillRepValue1` mediumint(9) NOT NULL default '0', + `MaxStanding2` tinyint(4) NOT NULL default '0', + `IsTeamAward2` tinyint(4) NOT NULL default '0', + `RewOnKillRepValue2` mediumint(9) NOT NULL default '0', + `TeamDependent` tinyint(3) unsigned NOT NULL default '0', + PRIMARY KEY (`creature_id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='Creature OnKill Reputation gain'; + +-- +-- Dumping data for table `creature_onkill_reputation` +-- + +LOCK TABLES `creature_onkill_reputation` WRITE; +/*!40000 ALTER TABLE `creature_onkill_reputation` DISABLE KEYS */; +/*!40000 ALTER TABLE `creature_onkill_reputation` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `creature_questrelation` +-- + +DROP TABLE IF EXISTS `creature_questrelation`; +CREATE TABLE `creature_questrelation` ( + `id` mediumint(8) unsigned NOT NULL default '0' COMMENT 'Identifier', + `quest` mediumint(8) unsigned NOT NULL default '0' COMMENT 'Quest Identifier', + PRIMARY KEY (`id`,`quest`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Creature System'; + +-- +-- Dumping data for table `creature_questrelation` +-- + +LOCK TABLES `creature_questrelation` WRITE; +/*!40000 ALTER TABLE `creature_questrelation` DISABLE KEYS */; +/*!40000 ALTER TABLE `creature_questrelation` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `creature_respawn` +-- + +DROP TABLE IF EXISTS `creature_respawn`; +CREATE TABLE `creature_respawn` ( + `guid` int(10) unsigned NOT NULL default '0' COMMENT 'Global Unique Identifier', + `respawntime` bigint(20) NOT NULL default '0', + `instance` mediumint(8) unsigned NOT NULL default '0', + PRIMARY KEY (`guid`,`instance`), + KEY `instance` (`instance`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='Grid Loading System'; + +-- +-- Dumping data for table `creature_respawn` +-- + +LOCK TABLES `creature_respawn` WRITE; +/*!40000 ALTER TABLE `creature_respawn` DISABLE KEYS */; +/*!40000 ALTER TABLE `creature_respawn` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `creature_template` +-- + +DROP TABLE IF EXISTS `creature_template`; +CREATE TABLE `creature_template` ( + `entry` mediumint(8) unsigned NOT NULL default '0', + `heroic_entry` mediumint(8) unsigned NOT NULL default '0', + `modelid_A` mediumint(8) unsigned NOT NULL default '0', + `modelid_A2` mediumint(8) unsigned NOT NULL default '0', + `modelid_H` mediumint(8) unsigned NOT NULL default '0', + `modelid_H2` mediumint(8) unsigned NOT NULL default '0', + `name` char(100) NOT NULL default '0', + `subname` char(100) default NULL, + `IconName` char(100) default NULL, + `minlevel` tinyint(3) unsigned NOT NULL default '1', + `maxlevel` tinyint(3) unsigned NOT NULL default '1', + `minhealth` int(10) unsigned NOT NULL default '0', + `maxhealth` int(10) unsigned NOT NULL default '0', + `minmana` int(10) unsigned NOT NULL default '0', + `maxmana` int(10) unsigned NOT NULL default '0', + `armor` mediumint(8) unsigned NOT NULL default '0', + `faction_A` smallint(5) unsigned NOT NULL default '0', + `faction_H` smallint(5) unsigned NOT NULL default '0', + `npcflag` int(10) unsigned NOT NULL default '0', + `speed` float NOT NULL default '1', + `scale` float NOT NULL default '1', + `rank` tinyint(3) unsigned NOT NULL default '0', + `mindmg` float NOT NULL default '0', + `maxdmg` float NOT NULL default '0', + `dmgschool` tinyint(4) NOT NULL default '0', + `attackpower` int(10) unsigned NOT NULL default '0', + `baseattacktime` int(10) unsigned NOT NULL default '0', + `rangeattacktime` int(10) unsigned NOT NULL default '0', + `flags` int(10) unsigned NOT NULL default '0', + `dynamicflags` int(10) unsigned NOT NULL default '0', + `family` tinyint(4) NOT NULL default '0', + `trainer_type` tinyint(4) NOT NULL default '0', + `trainer_spell` mediumint(8) unsigned NOT NULL default '0', + `class` tinyint(3) unsigned NOT NULL default '0', + `race` tinyint(3) unsigned NOT NULL default '0', + `minrangedmg` float NOT NULL default '0', + `maxrangedmg` float NOT NULL default '0', + `rangedattackpower` smallint(5) unsigned NOT NULL default '0', + `type` tinyint(3) unsigned NOT NULL default '0', + `flag1` int(10) unsigned NOT NULL default '0', + `lootid` mediumint(8) unsigned NOT NULL default '0', + `pickpocketloot` mediumint(8) unsigned NOT NULL default '0', + `skinloot` mediumint(8) unsigned NOT NULL default '0', + `resistance1` smallint(5) NOT NULL default '0', + `resistance2` smallint(5) NOT NULL default '0', + `resistance3` smallint(5) NOT NULL default '0', + `resistance4` smallint(5) NOT NULL default '0', + `resistance5` smallint(5) NOT NULL default '0', + `resistance6` smallint(5) NOT NULL default '0', + `spell1` mediumint(8) unsigned NOT NULL default '0', + `spell2` mediumint(8) unsigned NOT NULL default '0', + `spell3` mediumint(8) unsigned NOT NULL default '0', + `spell4` mediumint(8) unsigned NOT NULL default '0', + `PetSpellDataId` mediumint(8) unsigned NOT NULL default '0', + `mingold` mediumint(8) unsigned NOT NULL default '0', + `maxgold` mediumint(8) unsigned NOT NULL default '0', + `AIName` char(64) NOT NULL default '', + `MovementType` tinyint(3) unsigned NOT NULL default '0', + `InhabitType` tinyint(3) unsigned NOT NULL default '3', + `RacialLeader` tinyint(3) unsigned NOT NULL default '0', + `RegenHealth` tinyint(3) unsigned NOT NULL default '1', + `equipment_id` mediumint(8) unsigned NOT NULL default '0', + `mechanic_immune_mask` int(10) unsigned NOT NULL default '0', + `flags_extra` int(10) unsigned NOT NULL default '0', + `ScriptName` char(64) NOT NULL default '', + PRIMARY KEY (`entry`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Creature System'; + +-- +-- Dumping data for table `creature_template` +-- + +LOCK TABLES `creature_template` WRITE; +/*!40000 ALTER TABLE `creature_template` DISABLE KEYS */; +INSERT INTO `creature_template` VALUES +(1,1,10045,0,10045,0,'Waypoint(Only GM can see it)','Visual',NULL,1,1,64,64,0,0,0,35,35,0,0.91,1,0,14,15,0,100,2000,2200,4096,0,8,0,0,0,0,1.76,2.42,100,8,5242886,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,3,0,1,0,0,2,''); +/*!40000 ALTER TABLE `creature_template` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `creature_template_addon` +-- + +DROP TABLE IF EXISTS `creature_template_addon`; +CREATE TABLE `creature_template_addon` ( + `entry` mediumint(8) unsigned NOT NULL default '0', + `mount` mediumint(8) unsigned NOT NULL default '0', + `bytes0` int(10) unsigned NOT NULL default '0', + `bytes1` int(10) unsigned NOT NULL default '0', + `bytes2` int(10) unsigned NOT NULL default '0', + `emote` mediumint(8) unsigned NOT NULL default '0', + `moveflags` int(10) unsigned NOT NULL default '0', + `auras` text, + PRIMARY KEY (`entry`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + +-- +-- Dumping data for table `creature_template_addon` +-- + +LOCK TABLES `creature_template_addon` WRITE; +/*!40000 ALTER TABLE `creature_template_addon` DISABLE KEYS */; +/*!40000 ALTER TABLE `creature_template_addon` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `db_version` +-- + +DROP TABLE IF EXISTS `db_version`; +CREATE TABLE `db_version` ( + `version` varchar(120) default NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Used DB version notes'; + +-- +-- Dumping data for table `db_version` +-- + +LOCK TABLES `db_version` WRITE; +/*!40000 ALTER TABLE `db_version` DISABLE KEYS */; +INSERT INTO `db_version` VALUES +('Mangos default database.'); +/*!40000 ALTER TABLE `db_version` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `disenchant_loot_template` +-- + +DROP TABLE IF EXISTS `disenchant_loot_template`; +CREATE TABLE `disenchant_loot_template` ( + `entry` mediumint(8) unsigned NOT NULL default '0' COMMENT 'Recommended id selection: item_level*100 + item_quality', + `item` mediumint(8) unsigned NOT NULL default '0', + `ChanceOrQuestChance` float NOT NULL default '100', + `groupid` tinyint(3) unsigned NOT NULL default '0', + `mincountOrRef` mediumint(9) NOT NULL default '1', + `maxcount` tinyint(3) unsigned NOT NULL default '1', + `lootcondition` tinyint(3) unsigned NOT NULL default '0', + `condition_value1` mediumint(8) unsigned NOT NULL default '0', + `condition_value2` mediumint(8) unsigned NOT NULL default '0', + PRIMARY KEY (`entry`,`item`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Loot System'; + +-- +-- Dumping data for table `disenchant_loot_template` +-- + +LOCK TABLES `disenchant_loot_template` WRITE; +/*!40000 ALTER TABLE `disenchant_loot_template` DISABLE KEYS */; +/*!40000 ALTER TABLE `disenchant_loot_template` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `event_scripts` +-- + +DROP TABLE IF EXISTS `event_scripts`; +CREATE TABLE `event_scripts` ( + `id` mediumint(8) unsigned NOT NULL default '0', + `delay` int(10) unsigned NOT NULL default '0', + `command` mediumint(8) unsigned NOT NULL default '0', + `datalong` mediumint(8) unsigned NOT NULL default '0', + `datalong2` int(10) unsigned NOT NULL default '0', + `datatext` text NOT NULL, + `x` float NOT NULL default '0', + `y` float NOT NULL default '0', + `z` float NOT NULL default '0', + `o` float NOT NULL default '0' +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + +-- +-- Dumping data for table `event_scripts` +-- + +LOCK TABLES `event_scripts` WRITE; +/*!40000 ALTER TABLE `event_scripts` DISABLE KEYS */; +/*!40000 ALTER TABLE `event_scripts` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `exploration_basexp` +-- + +DROP TABLE IF EXISTS `exploration_basexp`; +CREATE TABLE `exploration_basexp` ( + `level` tinyint(4) NOT NULL default '0', + `basexp` mediumint(9) NOT NULL default '0', + PRIMARY KEY (`level`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Exploration System'; + +-- +-- Dumping data for table `exploration_basexp` +-- + +LOCK TABLES `exploration_basexp` WRITE; +/*!40000 ALTER TABLE `exploration_basexp` DISABLE KEYS */; +INSERT INTO `exploration_basexp` VALUES +(0,0), +(1,5), +(2,15), +(3,25), +(4,35), +(5,45), +(6,55), +(7,65), +(8,70), +(9,80), +(10,85), +(11,90), +(12,90), +(13,90), +(14,100), +(15,105), +(16,115), +(17,125), +(18,135), +(19,145), +(20,155), +(21,165), +(22,175), +(23,185), +(24,195), +(25,200), +(26,210), +(27,220), +(28,230), +(29,240), +(30,245), +(31,250), +(32,255), +(33,265), +(34,270), +(35,275), +(36,280), +(37,285), +(38,285), +(39,300), +(40,315), +(41,330), +(42,345), +(43,360), +(44,375), +(45,390), +(46,405), +(47,420), +(48,440), +(49,455), +(50,470), +(51,490), +(52,510), +(53,530), +(54,540), +(55,560), +(56,580), +(57,600), +(58,620), +(59,640), +(60,660), +(61,970), +(62,1000), +(63,1050), +(64,1080), +(65,1100), +(66,1130), +(67,1160), +(68,1200), +(69,1230), +(70,1250); +/*!40000 ALTER TABLE `exploration_basexp` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `fishing_loot_template` +-- + +DROP TABLE IF EXISTS `fishing_loot_template`; +CREATE TABLE `fishing_loot_template` ( + `entry` mediumint(8) unsigned NOT NULL default '0', + `item` mediumint(8) unsigned NOT NULL default '0', + `ChanceOrQuestChance` float NOT NULL default '100', + `groupid` tinyint(3) unsigned NOT NULL default '0', + `mincountOrRef` mediumint(9) NOT NULL default '1', + `maxcount` tinyint(3) unsigned NOT NULL default '1', + `lootcondition` tinyint(3) unsigned NOT NULL default '0', + `condition_value1` mediumint(8) unsigned NOT NULL default '0', + `condition_value2` mediumint(8) unsigned NOT NULL default '0', + PRIMARY KEY (`entry`,`item`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Loot System'; + +-- +-- Dumping data for table `fishing_loot_template` +-- + +LOCK TABLES `fishing_loot_template` WRITE; +/*!40000 ALTER TABLE `fishing_loot_template` DISABLE KEYS */; +/*!40000 ALTER TABLE `fishing_loot_template` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `game_event` +-- + +DROP TABLE IF EXISTS `game_event`; +CREATE TABLE `game_event` ( + `entry` mediumint(8) unsigned NOT NULL COMMENT 'Entry of the game event', + `start_time` timestamp NOT NULL default '0000-00-00 00:00:00' COMMENT 'Absolute start date, the event will never start before', + `end_time` timestamp NOT NULL default '0000-00-00 00:00:00' COMMENT 'Absolute end date, the event will never start afler', + `occurence` bigint(20) unsigned NOT NULL default '86400' COMMENT 'Delay in hours between occurences of the event', + `length` bigint(20) unsigned NOT NULL default '43200' COMMENT 'Length in hours of the event', + `description` varchar(255) default NULL COMMENT 'Description of the event displayed in console', + PRIMARY KEY (`entry`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + +-- +-- Dumping data for table `game_event` +-- + +LOCK TABLES `game_event` WRITE; +/*!40000 ALTER TABLE `game_event` DISABLE KEYS */; +/*!40000 ALTER TABLE `game_event` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `game_event_creature` +-- + +DROP TABLE IF EXISTS `game_event_creature`; +CREATE TABLE `game_event_creature` ( + `guid` int(10) unsigned NOT NULL, + `event` smallint(6) NOT NULL default '0' COMMENT 'Put negatives values to remove during event', + PRIMARY KEY (`guid`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + +-- +-- Dumping data for table `game_event_creature` +-- + +LOCK TABLES `game_event_creature` WRITE; +/*!40000 ALTER TABLE `game_event_creature` DISABLE KEYS */; +/*!40000 ALTER TABLE `game_event_creature` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `game_event_creature_quest` +-- + +DROP TABLE IF EXISTS `game_event_creature_quest`; +CREATE TABLE `game_event_creature_quest` ( + `id` mediumint(8) unsigned NOT NULL default '0', + `quest` mediumint(8) unsigned NOT NULL default '0', + `event` smallint(5) unsigned NOT NULL default '0', + PRIMARY KEY (`id`,`quest`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + +-- +-- Dumping data for table `game_event_creature_quest` +-- + +LOCK TABLES `game_event_creature_quest` WRITE; +/*!40000 ALTER TABLE `game_event_creature_quest` DISABLE KEYS */; +/*!40000 ALTER TABLE `game_event_creature_quest` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `game_event_gameobject` +-- + +DROP TABLE IF EXISTS `game_event_gameobject`; +CREATE TABLE `game_event_gameobject` ( + `guid` int(10) unsigned NOT NULL, + `event` smallint(6) NOT NULL default '0' COMMENT 'Put negatives values to remove during event', + PRIMARY KEY (`guid`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + +-- +-- Dumping data for table `game_event_gameobject` +-- + +LOCK TABLES `game_event_gameobject` WRITE; +/*!40000 ALTER TABLE `game_event_gameobject` DISABLE KEYS */; +/*!40000 ALTER TABLE `game_event_gameobject` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `game_event_model_equip` +-- + +DROP TABLE IF EXISTS `game_event_model_equip`; +CREATE TABLE `game_event_model_equip` ( + `guid` int(10) unsigned NOT NULL default '0', + `modelid` mediumint(8) unsigned NOT NULL default '0', + `equipment_id` mediumint(8) unsigned NOT NULL default '0', + `event` smallint(5) unsigned NOT NULL default '0', + PRIMARY KEY (`guid`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + +-- +-- Dumping data for table `game_event_model_equip` +-- + +LOCK TABLES `game_event_model_equip` WRITE; +/*!40000 ALTER TABLE `game_event_model_equip` DISABLE KEYS */; +/*!40000 ALTER TABLE `game_event_model_equip` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `game_graveyard_zone` +-- + +DROP TABLE IF EXISTS `game_graveyard_zone`; +CREATE TABLE `game_graveyard_zone` ( + `id` mediumint(8) unsigned NOT NULL default '0', + `ghost_zone` mediumint(8) unsigned NOT NULL default '0', + `faction` smallint(5) unsigned NOT NULL default '0', + PRIMARY KEY (`id`,`ghost_zone`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Trigger System'; + +-- +-- Dumping data for table `game_graveyard_zone` +-- + +LOCK TABLES `game_graveyard_zone` WRITE; +/*!40000 ALTER TABLE `game_graveyard_zone` DISABLE KEYS */; +/*!40000 ALTER TABLE `game_graveyard_zone` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `game_tele` +-- + +DROP TABLE IF EXISTS `game_tele`; +CREATE TABLE `game_tele` ( + `id` mediumint(8) unsigned NOT NULL auto_increment, + `position_x` float NOT NULL default '0', + `position_y` float NOT NULL default '0', + `position_z` float NOT NULL default '0', + `orientation` float NOT NULL default '0', + `map` smallint(5) unsigned NOT NULL default '0', + `name` varchar(100) NOT NULL default '', + PRIMARY KEY (`id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Tele Command'; + +-- +-- Dumping data for table `game_tele` +-- + +LOCK TABLES `game_tele` WRITE; +/*!40000 ALTER TABLE `game_tele` DISABLE KEYS */; +/*!40000 ALTER TABLE `game_tele` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `game_weather` +-- + +DROP TABLE IF EXISTS `game_weather`; +CREATE TABLE `game_weather` ( + `zone` mediumint(8) unsigned NOT NULL default '0', + `spring_rain_chance` tinyint(3) unsigned NOT NULL default '25', + `spring_snow_chance` tinyint(3) unsigned NOT NULL default '25', + `spring_storm_chance` tinyint(3) unsigned NOT NULL default '25', + `summer_rain_chance` tinyint(3) unsigned NOT NULL default '25', + `summer_snow_chance` tinyint(3) unsigned NOT NULL default '25', + `summer_storm_chance` tinyint(3) unsigned NOT NULL default '25', + `fall_rain_chance` tinyint(3) unsigned NOT NULL default '25', + `fall_snow_chance` tinyint(3) unsigned NOT NULL default '25', + `fall_storm_chance` tinyint(3) unsigned NOT NULL default '25', + `winter_rain_chance` tinyint(3) unsigned NOT NULL default '25', + `winter_snow_chance` tinyint(3) unsigned NOT NULL default '25', + `winter_storm_chance` tinyint(3) unsigned NOT NULL default '25', + PRIMARY KEY (`zone`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Weather System'; + +-- +-- Dumping data for table `game_weather` +-- + +LOCK TABLES `game_weather` WRITE; +/*!40000 ALTER TABLE `game_weather` DISABLE KEYS */; +/*!40000 ALTER TABLE `game_weather` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `gameobject` +-- + +DROP TABLE IF EXISTS `gameobject`; +CREATE TABLE `gameobject` ( + `guid` int(10) unsigned NOT NULL auto_increment COMMENT 'Global Unique Identifier', + `id` mediumint(8) unsigned NOT NULL default '0' COMMENT 'Gameobject Identifier', + `map` smallint(5) unsigned NOT NULL default '0' COMMENT 'Map Identifier', + `spawnMask` tinyint(3) unsigned NOT NULL default '1', + `position_x` float NOT NULL default '0', + `position_y` float NOT NULL default '0', + `position_z` float NOT NULL default '0', + `orientation` float NOT NULL default '0', + `rotation0` float NOT NULL default '0', + `rotation1` float NOT NULL default '0', + `rotation2` float NOT NULL default '0', + `rotation3` float NOT NULL default '0', + `spawntimesecs` int(11) NOT NULL default '0', + `animprogress` tinyint(3) unsigned NOT NULL default '0', + `state` tinyint(3) unsigned NOT NULL default '0', + PRIMARY KEY (`guid`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Gameobject System'; + +-- +-- Dumping data for table `gameobject` +-- + +LOCK TABLES `gameobject` WRITE; +/*!40000 ALTER TABLE `gameobject` DISABLE KEYS */; +/*!40000 ALTER TABLE `gameobject` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `gameobject_involvedrelation` +-- + +DROP TABLE IF EXISTS `gameobject_involvedrelation`; +CREATE TABLE `gameobject_involvedrelation` ( + `id` mediumint(8) unsigned NOT NULL default '0', + `quest` mediumint(8) unsigned NOT NULL default '0' COMMENT 'Quest Identifier', + PRIMARY KEY (`id`,`quest`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + +-- +-- Dumping data for table `gameobject_involvedrelation` +-- + +LOCK TABLES `gameobject_involvedrelation` WRITE; +/*!40000 ALTER TABLE `gameobject_involvedrelation` DISABLE KEYS */; +/*!40000 ALTER TABLE `gameobject_involvedrelation` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `gameobject_loot_template` +-- + +DROP TABLE IF EXISTS `gameobject_loot_template`; +CREATE TABLE `gameobject_loot_template` ( + `entry` mediumint(8) unsigned NOT NULL default '0', + `item` mediumint(8) unsigned NOT NULL default '0', + `ChanceOrQuestChance` float NOT NULL default '100', + `groupid` tinyint(3) unsigned NOT NULL default '0', + `mincountOrRef` mediumint(9) NOT NULL default '1', + `maxcount` tinyint(3) unsigned NOT NULL default '1', + `lootcondition` tinyint(3) unsigned NOT NULL default '0', + `condition_value1` mediumint(8) unsigned NOT NULL default '0', + `condition_value2` mediumint(8) unsigned NOT NULL default '0', + PRIMARY KEY (`entry`,`item`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Loot System'; + +-- +-- Dumping data for table `gameobject_loot_template` +-- + +LOCK TABLES `gameobject_loot_template` WRITE; +/*!40000 ALTER TABLE `gameobject_loot_template` DISABLE KEYS */; +/*!40000 ALTER TABLE `gameobject_loot_template` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `gameobject_questrelation` +-- + +DROP TABLE IF EXISTS `gameobject_questrelation`; +CREATE TABLE `gameobject_questrelation` ( + `id` mediumint(8) unsigned NOT NULL default '0', + `quest` mediumint(8) unsigned NOT NULL default '0' COMMENT 'Quest Identifier', + PRIMARY KEY (`id`,`quest`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + +-- +-- Dumping data for table `gameobject_questrelation` +-- + +LOCK TABLES `gameobject_questrelation` WRITE; +/*!40000 ALTER TABLE `gameobject_questrelation` DISABLE KEYS */; +/*!40000 ALTER TABLE `gameobject_questrelation` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `gameobject_respawn` +-- + +DROP TABLE IF EXISTS `gameobject_respawn`; +CREATE TABLE `gameobject_respawn` ( + `guid` int(10) unsigned NOT NULL default '0' COMMENT 'Global Unique Identifier', + `respawntime` bigint(20) NOT NULL default '0', + `instance` mediumint(8) unsigned NOT NULL default '0', + PRIMARY KEY (`guid`,`instance`), + KEY `instance` (`instance`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='Grid Loading System'; + +-- +-- Dumping data for table `gameobject_respawn` +-- + +LOCK TABLES `gameobject_respawn` WRITE; +/*!40000 ALTER TABLE `gameobject_respawn` DISABLE KEYS */; +/*!40000 ALTER TABLE `gameobject_respawn` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `gameobject_scripts` +-- + +DROP TABLE IF EXISTS `gameobject_scripts`; +CREATE TABLE `gameobject_scripts` ( + `id` mediumint(8) unsigned NOT NULL default '0', + `delay` int(10) unsigned NOT NULL default '0', + `command` mediumint(8) unsigned NOT NULL default '0', + `datalong` mediumint(8) unsigned NOT NULL default '0', + `datalong2` int(10) unsigned NOT NULL default '0', + `datatext` text NOT NULL, + `x` float NOT NULL default '0', + `y` float NOT NULL default '0', + `z` float NOT NULL default '0', + `o` float NOT NULL default '0' +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + +-- +-- Dumping data for table `gameobject_scripts` +-- + +LOCK TABLES `gameobject_scripts` WRITE; +/*!40000 ALTER TABLE `gameobject_scripts` DISABLE KEYS */; +/*!40000 ALTER TABLE `gameobject_scripts` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `gameobject_template` +-- + +DROP TABLE IF EXISTS `gameobject_template`; +CREATE TABLE `gameobject_template` ( + `entry` mediumint(8) unsigned NOT NULL default '0', + `type` tinyint(3) unsigned NOT NULL default '0', + `displayId` mediumint(8) unsigned NOT NULL default '0', + `name` varchar(100) NOT NULL default '', + `castBarCaption` varchar(100) NOT NULL default '', + `faction` smallint(5) unsigned NOT NULL default '0', + `flags` int(10) unsigned NOT NULL default '0', + `size` float NOT NULL default '1', + `data0` int(10) unsigned NOT NULL default '0', + `data1` int(10) unsigned NOT NULL default '0', + `data2` int(10) unsigned NOT NULL default '0', + `data3` int(10) unsigned NOT NULL default '0', + `data4` int(10) unsigned NOT NULL default '0', + `data5` int(10) unsigned NOT NULL default '0', + `data6` int(10) unsigned NOT NULL default '0', + `data7` int(10) unsigned NOT NULL default '0', + `data8` int(10) unsigned NOT NULL default '0', + `data9` int(10) unsigned NOT NULL default '0', + `data10` int(10) unsigned NOT NULL default '0', + `data11` int(10) unsigned NOT NULL default '0', + `data12` int(10) unsigned NOT NULL default '0', + `data13` int(10) unsigned NOT NULL default '0', + `data14` int(10) unsigned NOT NULL default '0', + `data15` int(10) unsigned NOT NULL default '0', + `data16` int(10) unsigned NOT NULL default '0', + `data17` int(10) unsigned NOT NULL default '0', + `data18` int(10) unsigned NOT NULL default '0', + `data19` int(10) unsigned NOT NULL default '0', + `data20` int(10) unsigned NOT NULL default '0', + `data21` int(10) unsigned NOT NULL default '0', + `data22` int(10) unsigned NOT NULL default '0', + `data23` int(10) unsigned NOT NULL default '0', + `ScriptName` varchar(64) NOT NULL default '', + PRIMARY KEY (`entry`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Gameobject System'; + +-- +-- Dumping data for table `gameobject_template` +-- + +LOCK TABLES `gameobject_template` WRITE; +/*!40000 ALTER TABLE `gameobject_template` DISABLE KEYS */; +/*!40000 ALTER TABLE `gameobject_template` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `instance_template` +-- + +DROP TABLE IF EXISTS `instance_template`; +CREATE TABLE `instance_template` ( + `map` smallint(5) unsigned NOT NULL, + `parent` int(10) unsigned NOT NULL, + `levelMin` tinyint(3) unsigned NOT NULL default '0', + `levelMax` tinyint(3) unsigned NOT NULL default '0', + `maxPlayers` tinyint(3) unsigned NOT NULL default '0', + `reset_delay` int(10) unsigned NOT NULL default '0', + `startLocX` float default NULL, + `startLocY` float default NULL, + `startLocZ` float default NULL, + `startLocO` float default NULL, + `script` varchar(128) NOT NULL default '', + PRIMARY KEY (`map`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + +-- +-- Dumping data for table `instance_template` +-- + +LOCK TABLES `instance_template` WRITE; +/*!40000 ALTER TABLE `instance_template` DISABLE KEYS */; +INSERT INTO `instance_template` VALUES +(33,0,22,30,10,7200,NULL,NULL,NULL,NULL,''), +(34,0,24,32,10,7200,NULL,NULL,NULL,NULL,''), +(36,0,15,20,10,7200,NULL,NULL,NULL,NULL,''), +(43,0,15,21,10,7200,NULL,NULL,NULL,NULL,''), +(47,0,29,38,10,7200,NULL,NULL,NULL,NULL,''), +(48,0,24,32,10,7200,NULL,NULL,NULL,NULL,''), +(70,0,35,47,10,7200,NULL,NULL,NULL,NULL,''), +(90,0,29,38,10,7200,NULL,NULL,NULL,NULL,''), +(109,0,45,55,10,7200,NULL,NULL,NULL,NULL,''), +(129,0,37,46,10,7200,NULL,NULL,NULL,NULL,''), +(189,0,34,45,10,7200,NULL,NULL,NULL,NULL,''), +(209,0,44,54,10,7200,NULL,NULL,NULL,NULL,''), +(229,0,58,0,10,120000,78.5083,-225.044,49.839,5.1,''), +(230,0,52,0,5,7200,NULL,NULL,NULL,NULL,''), +(249,0,60,0,40,432000,NULL,NULL,NULL,NULL,''), +(289,0,57,0,5,7200,NULL,NULL,NULL,NULL,''), +(309,0,60,0,20,259200,NULL,NULL,NULL,NULL,''), +(329,0,58,60,5,7200,NULL,NULL,NULL,NULL,''), +(349,0,46,55,10,7200,NULL,NULL,NULL,NULL,''), +(389,0,13,18,10,7200,NULL,NULL,NULL,NULL,''), +(409,0,60,0,40,604800,NULL,NULL,NULL,NULL,''), +(429,0,55,60,5,7200,NULL,NULL,NULL,NULL,''), +(469,0,60,0,40,604800,NULL,NULL,NULL,NULL,''), +(509,0,60,0,20,259200,NULL,NULL,NULL,NULL,''), +(531,0,60,0,40,604800,NULL,NULL,NULL,NULL,''), +(533,0,60,0,40,604800,NULL,NULL,NULL,NULL,''); +/*!40000 ALTER TABLE `instance_template` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `item_enchantment_template` +-- + +DROP TABLE IF EXISTS `item_enchantment_template`; +CREATE TABLE `item_enchantment_template` ( + `entry` mediumint(8) unsigned NOT NULL default '0', + `ench` mediumint(8) unsigned NOT NULL default '0', + `chance` float unsigned NOT NULL default '0', + PRIMARY KEY (`entry`,`ench`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Item Random Enchantment System'; + +-- +-- Dumping data for table `item_enchantment_template` +-- + +LOCK TABLES `item_enchantment_template` WRITE; +/*!40000 ALTER TABLE `item_enchantment_template` DISABLE KEYS */; +/*!40000 ALTER TABLE `item_enchantment_template` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `item_loot_template` +-- + +DROP TABLE IF EXISTS `item_loot_template`; +CREATE TABLE `item_loot_template` ( + `entry` mediumint(8) unsigned NOT NULL default '0', + `item` mediumint(8) unsigned NOT NULL default '0', + `ChanceOrQuestChance` float NOT NULL default '100', + `groupid` tinyint(3) unsigned NOT NULL default '0', + `mincountOrRef` mediumint(9) NOT NULL default '1', + `maxcount` tinyint(3) unsigned NOT NULL default '1', + `lootcondition` tinyint(3) unsigned NOT NULL default '0', + `condition_value1` mediumint(8) unsigned NOT NULL default '0', + `condition_value2` mediumint(8) unsigned NOT NULL default '0', + PRIMARY KEY (`entry`,`item`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Loot System'; + +-- +-- Dumping data for table `item_loot_template` +-- + +LOCK TABLES `item_loot_template` WRITE; +/*!40000 ALTER TABLE `item_loot_template` DISABLE KEYS */; +/*!40000 ALTER TABLE `item_loot_template` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `item_template` +-- + +DROP TABLE IF EXISTS `item_template`; +CREATE TABLE `item_template` ( + `entry` mediumint(8) unsigned NOT NULL default '0', + `class` tinyint(3) unsigned NOT NULL default '0', + `subclass` tinyint(3) unsigned NOT NULL default '0', + `unk0` int(11) NOT NULL default '-1', + `name` varchar(255) NOT NULL default '', + `displayid` mediumint(8) unsigned NOT NULL default '0', + `Quality` tinyint(3) unsigned NOT NULL default '0', + `Flags` int(10) unsigned NOT NULL default '0', + `BuyCount` tinyint(3) unsigned NOT NULL default '1', + `BuyPrice` int(10) unsigned NOT NULL default '0', + `SellPrice` int(10) unsigned NOT NULL default '0', + `InventoryType` tinyint(3) unsigned NOT NULL default '0', + `AllowableClass` mediumint(9) NOT NULL default '-1', + `AllowableRace` mediumint(9) NOT NULL default '-1', + `ItemLevel` tinyint(3) unsigned NOT NULL default '0', + `RequiredLevel` tinyint(3) unsigned NOT NULL default '0', + `RequiredSkill` smallint(5) unsigned NOT NULL default '0', + `RequiredSkillRank` smallint(5) unsigned NOT NULL default '0', + `requiredspell` mediumint(8) unsigned NOT NULL default '0', + `requiredhonorrank` mediumint(8) unsigned NOT NULL default '0', + `RequiredCityRank` mediumint(8) unsigned NOT NULL default '0', + `RequiredReputationFaction` smallint(5) unsigned NOT NULL default '0', + `RequiredReputationRank` smallint(5) unsigned NOT NULL default '0', + `maxcount` smallint(5) unsigned NOT NULL default '0', + `stackable` smallint(5) unsigned NOT NULL default '1', + `ContainerSlots` tinyint(3) unsigned NOT NULL default '0', + `stat_type1` tinyint(3) unsigned NOT NULL default '0', + `stat_value1` smallint(6) NOT NULL default '0', + `stat_type2` tinyint(3) unsigned NOT NULL default '0', + `stat_value2` smallint(6) NOT NULL default '0', + `stat_type3` tinyint(3) unsigned NOT NULL default '0', + `stat_value3` smallint(6) NOT NULL default '0', + `stat_type4` tinyint(3) unsigned NOT NULL default '0', + `stat_value4` smallint(6) NOT NULL default '0', + `stat_type5` tinyint(3) unsigned NOT NULL default '0', + `stat_value5` smallint(6) NOT NULL default '0', + `stat_type6` tinyint(3) unsigned NOT NULL default '0', + `stat_value6` smallint(6) NOT NULL default '0', + `stat_type7` tinyint(3) unsigned NOT NULL default '0', + `stat_value7` smallint(6) NOT NULL default '0', + `stat_type8` tinyint(3) unsigned NOT NULL default '0', + `stat_value8` smallint(6) NOT NULL default '0', + `stat_type9` tinyint(3) unsigned NOT NULL default '0', + `stat_value9` smallint(6) NOT NULL default '0', + `stat_type10` tinyint(3) unsigned NOT NULL default '0', + `stat_value10` smallint(6) NOT NULL default '0', + `dmg_min1` float NOT NULL default '0', + `dmg_max1` float NOT NULL default '0', + `dmg_type1` tinyint(3) unsigned NOT NULL default '0', + `dmg_min2` float NOT NULL default '0', + `dmg_max2` float NOT NULL default '0', + `dmg_type2` tinyint(3) unsigned NOT NULL default '0', + `dmg_min3` float NOT NULL default '0', + `dmg_max3` float NOT NULL default '0', + `dmg_type3` tinyint(3) unsigned NOT NULL default '0', + `dmg_min4` float NOT NULL default '0', + `dmg_max4` float NOT NULL default '0', + `dmg_type4` tinyint(3) unsigned NOT NULL default '0', + `dmg_min5` float NOT NULL default '0', + `dmg_max5` float NOT NULL default '0', + `dmg_type5` tinyint(3) unsigned NOT NULL default '0', + `armor` smallint(5) unsigned NOT NULL default '0', + `holy_res` tinyint(3) unsigned NOT NULL default '0', + `fire_res` tinyint(3) unsigned NOT NULL default '0', + `nature_res` tinyint(3) unsigned NOT NULL default '0', + `frost_res` tinyint(3) unsigned NOT NULL default '0', + `shadow_res` tinyint(3) unsigned NOT NULL default '0', + `arcane_res` tinyint(3) unsigned NOT NULL default '0', + `delay` smallint(5) unsigned NOT NULL default '1000', + `ammo_type` tinyint(3) unsigned NOT NULL default '0', + `RangedModRange` float NOT NULL default '0', + `spellid_1` mediumint(8) unsigned NOT NULL default '0', + `spelltrigger_1` tinyint(3) unsigned NOT NULL default '0', + `spellcharges_1` tinyint(4) NOT NULL default '0', + `spellppmRate_1` float NOT NULL default '0', + `spellcooldown_1` int(11) NOT NULL default '-1', + `spellcategory_1` smallint(5) unsigned NOT NULL default '0', + `spellcategorycooldown_1` int(11) NOT NULL default '-1', + `spellid_2` mediumint(8) unsigned NOT NULL default '0', + `spelltrigger_2` tinyint(3) unsigned NOT NULL default '0', + `spellcharges_2` tinyint(4) NOT NULL default '0', + `spellppmRate_2` float NOT NULL default '0', + `spellcooldown_2` int(11) NOT NULL default '-1', + `spellcategory_2` smallint(5) unsigned NOT NULL default '0', + `spellcategorycooldown_2` int(11) NOT NULL default '-1', + `spellid_3` mediumint(8) unsigned NOT NULL default '0', + `spelltrigger_3` tinyint(3) unsigned NOT NULL default '0', + `spellcharges_3` tinyint(4) NOT NULL default '0', + `spellppmRate_3` float NOT NULL default '0', + `spellcooldown_3` int(11) NOT NULL default '-1', + `spellcategory_3` smallint(5) unsigned NOT NULL default '0', + `spellcategorycooldown_3` int(11) NOT NULL default '-1', + `spellid_4` mediumint(8) unsigned NOT NULL default '0', + `spelltrigger_4` tinyint(3) unsigned NOT NULL default '0', + `spellcharges_4` tinyint(4) NOT NULL default '0', + `spellppmRate_4` float NOT NULL default '0', + `spellcooldown_4` int(11) NOT NULL default '-1', + `spellcategory_4` smallint(5) unsigned NOT NULL default '0', + `spellcategorycooldown_4` int(11) NOT NULL default '-1', + `spellid_5` mediumint(8) unsigned NOT NULL default '0', + `spelltrigger_5` tinyint(3) unsigned NOT NULL default '0', + `spellcharges_5` tinyint(4) NOT NULL default '0', + `spellppmRate_5` float NOT NULL default '0', + `spellcooldown_5` int(11) NOT NULL default '-1', + `spellcategory_5` smallint(5) unsigned NOT NULL default '0', + `spellcategorycooldown_5` int(11) NOT NULL default '-1', + `bonding` tinyint(3) unsigned NOT NULL default '0', + `description` varchar(255) NOT NULL default '', + `PageText` mediumint(8) unsigned NOT NULL default '0', + `LanguageID` tinyint(3) unsigned NOT NULL default '0', + `PageMaterial` tinyint(3) unsigned NOT NULL default '0', + `startquest` mediumint(8) unsigned NOT NULL default '0', + `lockid` mediumint(8) unsigned NOT NULL default '0', + `Material` tinyint(4) NOT NULL default '0', + `sheath` tinyint(3) unsigned NOT NULL default '0', + `RandomProperty` mediumint(8) unsigned NOT NULL default '0', + `RandomSuffix` mediumint(8) unsigned NOT NULL default '0', + `block` mediumint(8) unsigned NOT NULL default '0', + `itemset` mediumint(8) unsigned NOT NULL default '0', + `MaxDurability` smallint(5) unsigned NOT NULL default '0', + `area` mediumint(8) unsigned NOT NULL default '0', + `Map` smallint(6) NOT NULL default '0', + `BagFamily` mediumint(9) NOT NULL default '0', + `TotemCategory` tinyint(4) NOT NULL default '0', + `socketColor_1` tinyint(4) NOT NULL default '0', + `socketContent_1` mediumint(9) NOT NULL default '0', + `socketColor_2` tinyint(4) NOT NULL default '0', + `socketContent_2` mediumint(9) NOT NULL default '0', + `socketColor_3` tinyint(4) NOT NULL default '0', + `socketContent_3` mediumint(9) NOT NULL default '0', + `socketBonus` mediumint(9) NOT NULL default '0', + `GemProperties` mediumint(9) NOT NULL default '0', + `RequiredDisenchantSkill` smallint(6) NOT NULL default '-1', + `ArmorDamageModifier` float NOT NULL default '0', + `ScriptName` varchar(64) NOT NULL default '', + `DisenchantID` mediumint(8) unsigned NOT NULL default '0', + `FoodType` tinyint(3) unsigned NOT NULL default '0', + `minMoneyLoot` int(10) unsigned NOT NULL default '0', + `maxMoneyLoot` int(10) unsigned NOT NULL default '0', + `Duration` int(11) NOT NULL default '0' COMMENT 'Duration in seconds. Negative value means realtime, postive value ingame time', + PRIMARY KEY (`entry`), + KEY `items_index` (`class`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Item System'; + +-- +-- Dumping data for table `item_template` +-- + +LOCK TABLES `item_template` WRITE; +/*!40000 ALTER TABLE `item_template` DISABLE KEYS */; +INSERT INTO `item_template` VALUES +(25,2,7,-1,'Worn Shortsword',1542,1,0,1,35,7,21,32767,511,2,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1900,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,1,0,0,0,1,3,0,0,0,0,20,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), +(35,2,10,-1,'Bent Staff',472,1,0,1,47,9,17,2047,255,2,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2900,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,0,0,0,0,2,2,0,0,0,0,25,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), +(36,2,4,-1,'Worn Mace',5194,1,0,1,38,7,21,2047,255,2,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1900,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,0,0,0,0,2,3,0,0,0,0,20,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), +(37,2,0,-1,'Worn Axe',14029,1,0,1,38,7,21,2047,255,2,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2000,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,0,0,0,0,1,3,0,0,0,0,20,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), +(38,4,0,-1,'Recruit\'s Shirt',9891,1,0,1,1,1,4,-1,-1,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,0,0,0,0,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), +(39,4,1,-1,'Recruit\'s Pants',9892,0,0,1,5,1,7,32767,511,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,0,0,0,0,7,0,0,0,0,0,25,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), +(40,4,0,-1,'Recruit\'s Boots',10141,1,0,1,4,1,8,32767,511,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,0,0,0,0,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), +(43,4,0,-1,'Squire\'s Boots',9938,1,0,1,4,1,8,2047,255,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1000,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,0,0,0,0,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), +(44,4,1,-1,'Squire\'s Pants',9937,0,0,1,4,1,7,2047,255,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,1000,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,0,0,0,0,7,0,0,0,0,0,25,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), +(45,4,0,-1,'Squire\'s Shirt',3265,1,0,1,1,1,4,2047,255,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1000,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,0,0,0,0,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), +(47,4,0,-1,'Footpad\'s Shoes',9915,1,0,1,4,1,8,2047,255,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1000,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,0,0,0,0,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), +(48,4,1,-1,'Footpad\'s Pants',9913,0,0,1,4,1,7,2047,255,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,1000,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,0,0,0,0,7,0,0,0,0,0,25,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), +(49,4,0,-1,'Footpad\'s Shirt',9906,1,0,1,1,1,4,2047,255,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1000,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,0,0,0,0,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), +(51,4,0,-1,'Neophyte\'s Boots',9946,1,0,1,5,1,8,2047,255,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1000,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,0,0,0,0,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), +(52,4,1,-1,'Neophyte\'s Pants',9945,0,0,1,5,1,7,2047,255,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,1000,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,0,0,0,0,7,0,0,0,0,0,25,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), +(53,4,0,-1,'Neophyte\'s Shirt',9944,1,0,1,1,1,4,2047,255,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1000,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,0,0,0,0,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), +(55,4,0,-1,'Apprentice\'s Boots',9929,1,0,1,5,1,8,2047,255,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1000,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,0,0,0,0,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), +(56,4,1,-1,'Apprentice\'s Robe',12647,0,0,1,5,1,20,2047,255,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,0,0,0,0,1000,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,0,0,0,0,7,0,0,0,0,0,35,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), +(57,4,1,-1,'Acolyte\'s Robe',12645,0,0,1,5,1,20,2047,255,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,0,0,0,0,1000,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,0,0,0,0,7,0,0,0,0,0,35,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), +(59,4,0,-1,'Acolyte\'s Shoes',3261,1,0,1,5,1,8,2047,255,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1000,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,0,0,0,0,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), +(117,0,0,-1,'Tough Jerky',2473,1,0,6,25,1,0,2047,255,5,1,0,0,0,0,0,0,0,0,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1000,0,0,433,0,-1,0,-1,11,1000,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), +(120,4,1,-1,'Thug Pants',10006,0,0,1,4,1,7,2047,255,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,1000,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,0,0,0,0,7,0,0,0,0,0,25,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), +(121,4,0,-1,'Thug Boots',10008,1,0,1,4,1,8,2047,255,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1000,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,0,0,0,0,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), +(127,4,0,-1,'Trapper\'s Shirt',9996,1,0,1,1,1,4,2047,255,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1000,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,0,0,0,0,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), +(139,4,1,-1,'Brawler\'s Pants',9988,0,0,1,4,1,7,2047,255,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,1000,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,0,0,0,0,7,0,0,0,0,0,25,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), +(140,4,0,-1,'Brawler\'s Boots',9992,1,0,1,4,1,8,2047,255,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1000,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,0,0,0,0,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), +(147,4,1,-1,'Rugged Trapper\'s Pants',9975,0,0,1,5,1,7,2047,255,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,1000,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,0,0,0,0,7,0,0,0,0,0,25,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), +(148,4,0,-1,'Rugged Trapper\'s Shirt',9976,1,0,1,1,1,4,2047,255,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1000,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,0,0,0,0,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), +(153,4,2,-1,'Primitive Kilt',10050,0,0,1,5,1,7,2047,255,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,14,0,0,0,0,0,0,1000,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,0,0,0,0,8,0,0,0,0,0,30,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), +(154,4,0,-1,'Primitive Mantle',10058,1,0,1,1,1,4,2047,255,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1000,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,0,0,0,0,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), +(159,0,0,-1,'Refreshing Spring Water',18084,1,0,6,25,1,0,2047,255,5,1,0,0,0,0,0,0,0,0,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1000,0,0,430,0,-1,0,-1,59,1000,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), +(1395,4,1,-1,'Apprentice\'s Pants',9924,0,0,1,5,1,7,2047,255,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,1000,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,0,0,0,0,7,0,0,0,0,0,25,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), +(1396,4,1,-1,'Acolyte\'s Pants',3260,0,0,1,4,1,7,2047,255,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,1000,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,0,0,0,0,7,0,0,0,0,0,25,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), +(2070,0,0,-1,'Darnassian Bleu',6353,1,0,6,25,1,0,2047,255,5,1,0,0,0,0,0,0,0,0,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1000,0,0,433,0,-1,0,-1,11,1000,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), +(2092,2,15,-1,'Worn Dagger',6442,1,0,1,35,7,13,2047,255,2,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1600,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,0,0,0,0,1,3,0,0,0,0,16,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), +(2101,1,2,-1,'Light Quiver',21328,1,0,1,4,1,18,2047,255,1,1,0,0,0,0,0,0,0,0,1,6,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1000,0,0,14824,1,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,'',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), +(2102,1,3,-1,'Small Ammo Pouch',1816,1,0,1,4,1,18,2047,255,1,1,0,0,0,0,0,0,0,0,1,6,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1000,0,0,14824,1,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,'',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), +(2105,4,0,-1,'Thug Shirt',10005,1,0,1,5,1,4,2047,255,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1000,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,0,0,0,0,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), +(2361,2,5,-1,'Battleworn Hammer',8690,1,0,1,45,9,17,2047,255,2,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2900,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,0,0,0,0,2,1,0,0,0,0,25,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), +(2362,4,6,-1,'Worn Wooden Shield',18730,0,0,1,7,1,14,32767,511,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,0,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,0,0,0,0,1,4,0,0,1,0,20,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), +(2504,2,2,-1,'Worn Shortbow',8106,1,0,1,29,5,15,2047,255,2,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2300,2,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,0,0,0,0,2,0,0,0,0,0,20,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), +(2508,2,3,-1,'Old Blunderbuss',6606,1,0,1,27,5,26,2047,255,2,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2300,3,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,0,0,0,0,1,0,0,0,0,0,20,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), +(2512,6,2,-1,'Rough Arrow',5996,1,0,1,10,0,24,2047,255,5,1,0,0,0,0,0,0,0,0,200,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3000,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,0,0,0,0,2,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), +(2516,6,3,-1,'Light Shot',5998,1,0,1,10,0,24,2047,255,5,1,0,0,0,0,0,0,0,0,200,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3000,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,0,0,0,0,2,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), +(2947,2,16,-1,'Small Throwing Knife',16754,1,0,1,15,0,25,2047,255,3,1,0,0,0,0,0,0,0,0,200,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2000,4,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), +(3661,2,10,-1,'Handcrafted Staff',18530,1,0,1,45,9,17,2047,255,2,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2900,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,0,0,0,0,2,2,0,0,0,0,25,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), +(4536,0,0,-1,'Shiny Red Apple',6410,1,0,6,25,1,0,2047,255,5,1,0,0,0,0,0,0,0,0,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1000,0,0,433,0,-1,0,-1,11,100,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), +(4540,0,0,-1,'Tough Hunk of Bread',6399,1,0,6,25,1,0,2047,255,5,1,0,0,0,0,0,0,0,0,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1000,0,0,433,0,-1,0,-1,11,1000,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), +(4604,0,0,-1,'Forest Mushroom Cap',15852,1,0,6,25,1,0,2047,255,5,1,0,0,0,0,0,0,0,0,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1000,0,0,433,0,-1,0,-1,11,1000,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), +(6096,4,0,-1,'Apprentice\'s Shirt',2163,1,0,1,1,1,4,2047,255,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1000,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,0,0,0,0,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), +(6097,4,0,-1,'Acolyte\'s Shirt',2470,1,0,1,1,1,4,2047,255,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1000,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,0,0,0,0,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), +(6098,4,1,-1,'Neophyte\'s Robe',12679,0,0,1,4,1,20,2047,255,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,0,0,0,0,1000,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,0,0,0,0,7,0,0,0,0,0,35,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), +(6119,4,1,-1,'Neophyte\'s Robe',12681,0,0,1,4,1,20,2047,255,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,0,0,0,0,1000,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,0,0,0,0,7,0,0,0,0,0,35,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), +(6123,4,1,-1,'Novice\'s Robe',12683,0,0,1,4,1,20,2047,255,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,0,0,0,0,1000,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,0,0,0,0,7,0,0,0,0,0,35,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), +(6124,4,1,-1,'Novice\'s Pants',9987,0,0,1,5,1,7,2047,255,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,1000,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,0,0,0,0,7,0,0,0,0,0,25,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), +(6125,4,0,-1,'Brawler\'s Harness',9995,1,0,1,1,1,4,2047,255,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1000,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,0,0,0,0,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), +(6126,4,1,-1,'Trapper\'s Pants',10002,0,0,1,5,1,7,2047,255,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,1000,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,0,0,0,0,7,0,0,0,0,0,25,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), +(6127,4,0,-1,'Trapper\'s Boots',10003,1,0,1,5,1,8,2047,255,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1000,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,0,0,0,0,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), +(6129,4,1,-1,'Acolyte\'s Robe',12646,0,0,1,5,1,20,2047,255,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,0,0,0,0,1000,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,0,0,0,0,7,0,0,0,0,0,35,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), +(6134,4,0,-1,'Primitive Mantle',10108,1,0,1,1,1,4,2047,255,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1000,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,0,0,0,0,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), +(6135,4,2,-1,'Primitive Kilt',10109,0,0,1,5,1,7,2047,255,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,14,0,0,0,0,0,0,1000,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,0,0,0,0,8,0,0,0,0,0,30,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), +(6139,4,1,-1,'Novice\'s Robe',12684,0,0,1,4,1,20,2047,255,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,0,0,0,0,1000,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,0,0,0,0,7,0,0,0,0,0,35,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), +(6140,4,1,-1,'Apprentice\'s Robe',12649,0,0,1,4,1,20,2047,255,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,0,0,0,0,1000,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,0,0,0,0,7,0,0,0,0,0,35,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), +(6144,4,1,-1,'Neophyte\'s Robe',12680,0,0,1,5,1,20,2047,255,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,0,0,0,0,1000,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,0,0,0,0,7,0,0,0,0,0,35,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), +(6948,15,0,-1,'Hearthstone',6418,1,64,1,0,0,0,32767,511,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,8690,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,'',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), +(12282,2,1,-1,'Worn Battleaxe',22291,1,0,1,43,8,17,2047,255,2,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2900,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,0,0,0,0,1,1,0,0,0,0,25,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), +(14646,12,0,-1,'Northshire Gift Voucher',18499,1,0,1,0,0,0,2047,255,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1000,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,'',0,0,0,5805,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), +(14647,12,0,-1,'Coldridge Valley Gift Voucher',18499,1,0,1,0,0,0,2047,255,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1000,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,'',0,0,0,5841,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), +(14648,12,0,-1,'Shadowglen Gift Voucher',18499,1,0,1,0,0,0,2047,255,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1000,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,'',0,0,0,5842,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), +(14649,12,0,-1,'Valley of Trials Gift Voucher',18499,1,0,1,0,0,0,2047,255,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1000,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,'',0,0,0,5843,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), +(14650,12,0,-1,'Camp Narache Gift Voucher',18499,1,0,1,0,0,0,2047,255,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1000,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,'',0,0,0,5844,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), +(14651,12,0,-1,'Deathknell Gift Voucher',18499,1,0,1,0,0,0,2047,255,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1000,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,'',0,0,0,5847,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0), +(25861,2,16,-1,'Crude Throwing Axe',20777,1,0,1,15,0,25,2047,255,3,1,0,0,0,0,0,0,0,0,200,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2000,4,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,'internalItemHandler',0,0,0,0,0); +/*!40000 ALTER TABLE `item_template` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `locales_creature` +-- + +DROP TABLE IF EXISTS `locales_creature`; +CREATE TABLE `locales_creature` ( + `entry` mediumint(8) unsigned NOT NULL default '0', + `name_loc1` varchar(100) NOT NULL default '', + `name_loc2` varchar(100) NOT NULL default '', + `name_loc3` varchar(100) NOT NULL default '', + `name_loc4` varchar(100) NOT NULL default '', + `name_loc5` varchar(100) NOT NULL default '', + `name_loc6` varchar(100) NOT NULL default '', + `name_loc7` varchar(100) NOT NULL default '', + `name_loc8` varchar(100) NOT NULL default '', + `subname_loc1` varchar(100) default NULL, + `subname_loc2` varchar(100) default NULL, + `subname_loc3` varchar(100) default NULL, + `subname_loc4` varchar(100) default NULL, + `subname_loc5` varchar(100) default NULL, + `subname_loc6` varchar(100) default NULL, + `subname_loc7` varchar(100) default NULL, + `subname_loc8` varchar(100) default NULL, + PRIMARY KEY (`entry`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + +-- +-- Dumping data for table `locales_creature` +-- + +LOCK TABLES `locales_creature` WRITE; +/*!40000 ALTER TABLE `locales_creature` DISABLE KEYS */; +/*!40000 ALTER TABLE `locales_creature` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `locales_gameobject` +-- + +DROP TABLE IF EXISTS `locales_gameobject`; +CREATE TABLE `locales_gameobject` ( + `entry` mediumint(8) unsigned NOT NULL default '0', + `name_loc1` varchar(100) NOT NULL default '', + `name_loc2` varchar(100) NOT NULL default '', + `name_loc3` varchar(100) NOT NULL default '', + `name_loc4` varchar(100) NOT NULL default '', + `name_loc5` varchar(100) NOT NULL default '', + `name_loc6` varchar(100) NOT NULL default '', + `name_loc7` varchar(100) NOT NULL default '', + `name_loc8` varchar(100) NOT NULL default '', + `castbarcaption_loc1` varchar(100) NOT NULL default '', + `castbarcaption_loc2` varchar(100) NOT NULL default '', + `castbarcaption_loc3` varchar(100) NOT NULL default '', + `castbarcaption_loc4` varchar(100) NOT NULL default '', + `castbarcaption_loc5` varchar(100) NOT NULL default '', + `castbarcaption_loc6` varchar(100) NOT NULL default '', + `castbarcaption_loc7` varchar(100) NOT NULL default '', + `castbarcaption_loc8` varchar(100) NOT NULL default '', + PRIMARY KEY (`entry`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + +-- +-- Dumping data for table `locales_gameobject` +-- + +LOCK TABLES `locales_gameobject` WRITE; +/*!40000 ALTER TABLE `locales_gameobject` DISABLE KEYS */; +/*!40000 ALTER TABLE `locales_gameobject` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `locales_item` +-- + +DROP TABLE IF EXISTS `locales_item`; +CREATE TABLE `locales_item` ( + `entry` mediumint(8) unsigned NOT NULL default '0', + `name_loc1` varchar(100) NOT NULL default '', + `name_loc2` varchar(100) NOT NULL default '', + `name_loc3` varchar(100) NOT NULL default '', + `name_loc4` varchar(100) NOT NULL default '', + `name_loc5` varchar(100) NOT NULL default '', + `name_loc6` varchar(100) NOT NULL default '', + `name_loc7` varchar(100) NOT NULL default '', + `name_loc8` varchar(100) NOT NULL default '', + `description_loc1` varchar(255) default NULL, + `description_loc2` varchar(255) default NULL, + `description_loc3` varchar(255) default NULL, + `description_loc4` varchar(255) default NULL, + `description_loc5` varchar(255) default NULL, + `description_loc6` varchar(255) default NULL, + `description_loc7` varchar(255) default NULL, + `description_loc8` varchar(255) default NULL, + PRIMARY KEY (`entry`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + +-- +-- Dumping data for table `locales_item` +-- + +LOCK TABLES `locales_item` WRITE; +/*!40000 ALTER TABLE `locales_item` DISABLE KEYS */; +/*!40000 ALTER TABLE `locales_item` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `locales_npc_text` +-- + +DROP TABLE IF EXISTS `locales_npc_text`; +CREATE TABLE `locales_npc_text` ( + `entry` mediumint(8) unsigned NOT NULL default '0', + `Text0_0_loc1` longtext, + `Text0_0_loc2` longtext, + `Text0_0_loc3` longtext, + `Text0_0_loc4` longtext, + `Text0_0_loc5` longtext, + `Text0_0_loc6` longtext, + `Text0_0_loc7` longtext, + `Text0_0_loc8` longtext, + `Text0_1_loc1` longtext, + `Text0_1_loc2` longtext, + `Text0_1_loc3` longtext, + `Text0_1_loc4` longtext, + `Text0_1_loc5` longtext, + `Text0_1_loc6` longtext, + `Text0_1_loc7` longtext, + `Text0_1_loc8` longtext, + `Text1_0_loc1` longtext, + `Text1_0_loc2` longtext, + `Text1_0_loc3` longtext, + `Text1_0_loc4` longtext, + `Text1_0_loc5` longtext, + `Text1_0_loc6` longtext, + `Text1_0_loc7` longtext, + `Text1_0_loc8` longtext, + `Text1_1_loc1` longtext, + `Text1_1_loc2` longtext, + `Text1_1_loc3` longtext, + `Text1_1_loc4` longtext, + `Text1_1_loc5` longtext, + `Text1_1_loc6` longtext, + `Text1_1_loc7` longtext, + `Text1_1_loc8` longtext, + `Text2_0_loc1` longtext, + `Text2_0_loc2` longtext, + `Text2_0_loc3` longtext, + `Text2_0_loc4` longtext, + `Text2_0_loc5` longtext, + `Text2_0_loc6` longtext, + `Text2_0_loc7` longtext, + `Text2_0_loc8` longtext, + `Text2_1_loc1` longtext, + `Text2_1_loc2` longtext, + `Text2_1_loc3` longtext, + `Text2_1_loc4` longtext, + `Text2_1_loc5` longtext, + `Text2_1_loc6` longtext, + `Text2_1_loc7` longtext, + `Text2_1_loc8` longtext, + `Text3_0_loc1` longtext, + `Text3_0_loc2` longtext, + `Text3_0_loc3` longtext, + `Text3_0_loc4` longtext, + `Text3_0_loc5` longtext, + `Text3_0_loc6` longtext, + `Text3_0_loc7` longtext, + `Text3_0_loc8` longtext, + `Text3_1_loc1` longtext, + `Text3_1_loc2` longtext, + `Text3_1_loc3` longtext, + `Text3_1_loc4` longtext, + `Text3_1_loc5` longtext, + `Text3_1_loc6` longtext, + `Text3_1_loc7` longtext, + `Text3_1_loc8` longtext, + `Text4_0_loc1` longtext, + `Text4_0_loc2` longtext, + `Text4_0_loc3` longtext, + `Text4_0_loc4` longtext, + `Text4_0_loc5` longtext, + `Text4_0_loc6` longtext, + `Text4_0_loc7` longtext, + `Text4_0_loc8` longtext, + `Text4_1_loc1` longtext, + `Text4_1_loc2` longtext, + `Text4_1_loc3` longtext, + `Text4_1_loc4` longtext, + `Text4_1_loc5` longtext, + `Text4_1_loc6` longtext, + `Text4_1_loc7` longtext, + `Text4_1_loc8` longtext, + `Text5_0_loc1` longtext, + `Text5_0_loc2` longtext, + `Text5_0_loc3` longtext, + `Text5_0_loc4` longtext, + `Text5_0_loc5` longtext, + `Text5_0_loc6` longtext, + `Text5_0_loc7` longtext, + `Text5_0_loc8` longtext, + `Text5_1_loc1` longtext, + `Text5_1_loc2` longtext, + `Text5_1_loc3` longtext, + `Text5_1_loc4` longtext, + `Text5_1_loc5` longtext, + `Text5_1_loc6` longtext, + `Text5_1_loc7` longtext, + `Text5_1_loc8` longtext, + `Text6_0_loc1` longtext, + `Text6_0_loc2` longtext, + `Text6_0_loc3` longtext, + `Text6_0_loc4` longtext, + `Text6_0_loc5` longtext, + `Text6_0_loc6` longtext, + `Text6_0_loc7` longtext, + `Text6_0_loc8` longtext, + `Text6_1_loc1` longtext, + `Text6_1_loc2` longtext, + `Text6_1_loc3` longtext, + `Text6_1_loc4` longtext, + `Text6_1_loc5` longtext, + `Text6_1_loc6` longtext, + `Text6_1_loc7` longtext, + `Text6_1_loc8` longtext, + `Text7_0_loc1` longtext, + `Text7_0_loc2` longtext, + `Text7_0_loc3` longtext, + `Text7_0_loc4` longtext, + `Text7_0_loc5` longtext, + `Text7_0_loc6` longtext, + `Text7_0_loc7` longtext, + `Text7_0_loc8` longtext, + `Text7_1_loc1` longtext, + `Text7_1_loc2` longtext, + `Text7_1_loc3` longtext, + `Text7_1_loc4` longtext, + `Text7_1_loc5` longtext, + `Text7_1_loc6` longtext, + `Text7_1_loc7` longtext, + `Text7_1_loc8` longtext, + PRIMARY KEY (`entry`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + +-- +-- Dumping data for table `locales_npc_text` +-- + +LOCK TABLES `locales_npc_text` WRITE; +/*!40000 ALTER TABLE `locales_npc_text` DISABLE KEYS */; +/*!40000 ALTER TABLE `locales_npc_text` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `locales_page_text` +-- + +DROP TABLE IF EXISTS `locales_page_text`; +CREATE TABLE `locales_page_text` ( + `entry` mediumint(8) unsigned NOT NULL default '0', + `Text_loc1` longtext, + `Text_loc2` longtext, + `Text_loc3` longtext, + `Text_loc4` longtext, + `Text_loc5` longtext, + `Text_loc6` longtext, + `Text_loc7` longtext, + `Text_loc8` longtext, + PRIMARY KEY (`entry`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + +-- +-- Dumping data for table `locales_page_text` +-- + +LOCK TABLES `locales_page_text` WRITE; +/*!40000 ALTER TABLE `locales_page_text` DISABLE KEYS */; +/*!40000 ALTER TABLE `locales_page_text` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `locales_quest` +-- + +DROP TABLE IF EXISTS `locales_quest`; +CREATE TABLE `locales_quest` ( + `entry` mediumint(8) unsigned NOT NULL default '0', + `Title_loc1` text, + `Title_loc2` text, + `Title_loc3` text, + `Title_loc4` text, + `Title_loc5` text, + `Title_loc6` text, + `Title_loc7` text, + `Title_loc8` text, + `Details_loc1` text, + `Details_loc2` text, + `Details_loc3` text, + `Details_loc4` text, + `Details_loc5` text, + `Details_loc6` text, + `Details_loc7` text, + `Details_loc8` text, + `Objectives_loc1` text, + `Objectives_loc2` text, + `Objectives_loc3` text, + `Objectives_loc4` text, + `Objectives_loc5` text, + `Objectives_loc6` text, + `Objectives_loc7` text, + `Objectives_loc8` text, + `OfferRewardText_loc1` text, + `OfferRewardText_loc2` text, + `OfferRewardText_loc3` text, + `OfferRewardText_loc4` text, + `OfferRewardText_loc5` text, + `OfferRewardText_loc6` text, + `OfferRewardText_loc7` text, + `OfferRewardText_loc8` text, + `RequestItemsText_loc1` text, + `RequestItemsText_loc2` text, + `RequestItemsText_loc3` text, + `RequestItemsText_loc4` text, + `RequestItemsText_loc5` text, + `RequestItemsText_loc6` text, + `RequestItemsText_loc7` text, + `RequestItemsText_loc8` text, + `EndText_loc1` text, + `EndText_loc2` text, + `EndText_loc3` text, + `EndText_loc4` text, + `EndText_loc5` text, + `EndText_loc6` text, + `EndText_loc7` text, + `EndText_loc8` text, + `ObjectiveText1_loc1` text, + `ObjectiveText1_loc2` text, + `ObjectiveText1_loc3` text, + `ObjectiveText1_loc4` text, + `ObjectiveText1_loc5` text, + `ObjectiveText1_loc6` text, + `ObjectiveText1_loc7` text, + `ObjectiveText1_loc8` text, + `ObjectiveText2_loc1` text, + `ObjectiveText2_loc2` text, + `ObjectiveText2_loc3` text, + `ObjectiveText2_loc4` text, + `ObjectiveText2_loc5` text, + `ObjectiveText2_loc6` text, + `ObjectiveText2_loc7` text, + `ObjectiveText2_loc8` text, + `ObjectiveText3_loc1` text, + `ObjectiveText3_loc2` text, + `ObjectiveText3_loc3` text, + `ObjectiveText3_loc4` text, + `ObjectiveText3_loc5` text, + `ObjectiveText3_loc6` text, + `ObjectiveText3_loc7` text, + `ObjectiveText3_loc8` text, + `ObjectiveText4_loc1` text, + `ObjectiveText4_loc2` text, + `ObjectiveText4_loc3` text, + `ObjectiveText4_loc4` text, + `ObjectiveText4_loc5` text, + `ObjectiveText4_loc6` text, + `ObjectiveText4_loc7` text, + `ObjectiveText4_loc8` text, + PRIMARY KEY (`entry`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + +-- +-- Dumping data for table `locales_quest` +-- + +LOCK TABLES `locales_quest` WRITE; +/*!40000 ALTER TABLE `locales_quest` DISABLE KEYS */; +/*!40000 ALTER TABLE `locales_quest` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `mangos_string` +-- + +DROP TABLE IF EXISTS `mangos_string`; +CREATE TABLE `mangos_string` ( + `entry` mediumint(8) unsigned NOT NULL default '0', + `content_default` text NOT NULL, + `content_loc1` text, + `content_loc2` text, + `content_loc3` text, + `content_loc4` text, + `content_loc5` text, + `content_loc6` text, + `content_loc7` text, + `content_loc8` text, + PRIMARY KEY (`entry`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + +-- +-- Dumping data for table `mangos_string` +-- + +LOCK TABLES `mangos_string` WRITE; +/*!40000 ALTER TABLE `mangos_string` DISABLE KEYS */; +INSERT INTO `mangos_string` VALUES +(1,'You should select a character or a creature.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(2,'You should select a creature.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(3,'|cffff0000[System Message]: %s|r',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(4,'|cffff0000[Event Message]: %s|r',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(5,'There is no help for that command',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(6,'There is no such command',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(7,'There is no such subcommand',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(8,'Command %s have subcommands:%s',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(9,'Commands available to you:',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(10,'Incorrect syntax.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(11,'Your account level is: %i',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(12,'Online players: %u (max: %u) Queued players: %u (max: %u)',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(13,'Server uptime: %s',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(14,'Player saved.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(15,'All players saved.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(16,'There are the following active GMs on this server:',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(17,'There are no GMs currently logged in on this server.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(18,'Cannot do that while flying.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(19,'Cannot do that in Battlegrounds.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(20,'Target is flying you can\'t do that.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(21,'%s is flying command failed.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(22,'You are not mounted so you can\'t dismount.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(23,'Cannot do that while fighting.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(24,'You used it recently.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(25,'Your password can\'t be longer than 16 characters (client limit), password not changed!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(26,'The password was changed',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(27,'The new passwords do not match or the old password is wrong',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(28,'Your account is now locked.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(29,'Your account is now unlocked.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(30,', rank ',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(31,' [known]',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(32,' [learn]',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(33,' [passive]',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(34,' [talent]',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(35,' [active]',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(36,' [complete]',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(37,' (offline)',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(38,'on',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(39,'off',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(40,'You are: %s',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(41,'visible',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(42,'invisible',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(43,'done',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(44,'You',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(45,' ',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(46,'',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(47,'',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(48,'UNKNOWN',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(49,'You must be at least level %u to enter.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(50,'You must be at least level %u and have item %s to enter.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(51,'Hello! Ready for some training?',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(100,'Global notify: ',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(101,'Map: %u (%s) Zone: %u (%s) Area: %u (%s)\nX: %f Y: %f Z: %f Orientation: %f\ngrid[%u,%u]cell[%u,%u] InstanceID: %u\n ZoneX: %f ZoneY: %f\nGroundZ: %f FloorZ: %f Have height data (Map: %u VMap: %u)',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(102,'%s is already being teleported.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(103,'You can summon a player to your instance only if he is in your party with you as leader.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(104,'You cannot go to the player\'s instance because you are in a party now.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(105,'You can go to the player\'s instance while not being in his party only if your GM mode is on.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(106,'You can not go to player %s from instance to instance.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(107,'You can not summon player %s from instance to instance.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(108,'You are summoning %s%s.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(109,'You are being summoned by %s.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(110,'You are teleporting %s%s to %s.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(111,'You are being teleported by %s.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(112,'Player (%s) does not exist.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(113,'Appearing at %s\'s location.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(114,'%s is appearing to your location.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(115,'Incorrect values.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(116,'No character selected.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(117,'%s is not in a group.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(118,'You changed HP of %s to %i/%i.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(119,'%s changed your HP to %i/%i.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(120,'You changed MANA of %s to %i/%i.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(121,'%s changed your MANA to %i/%i.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(122,'You changed ENERGY of %s to %i/%i.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(123,'%s changed your ENERGY to %i/%i.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(124,'Current energy: %u',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(125,'You changed rage of %s to %i/%i.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(126,'%s changed your rage to %i/%i.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(127,'You changed level of %s to %i.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(128,'GUID %i, faction is %i, flags is %i, npcflag is %i, DY flag is %i',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(129,'Wrong faction: %u (not found in factiontemplate.dbc).',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(130,'You changed GUID=%i \'s Faction to %i, flags to %i, npcflag to %i, dyflag to %i.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(131,'You changed the spellflatid=%i, val= %i, mark =%i to %s.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(132,'%s changed your spellflatid=%i, val= %i, mark =%i.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(133,'%s has access to all taxi nodes now (until logout).',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(134,'%s has no more access to all taxi nodes now (only visited accessible).',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(135,'%s has given you access to all taxi nodes (until logout).',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(136,'%s has removed access to all taxi nodes (only visited still accessible).',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(137,'You set all speeds to %2.2f from normal of %s.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(138,'%s set all your speeds to %2.2f from normal.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(139,'You set the speed to %2.2f from normal of %s.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(140,'%s set your speed to %2.2f from normal.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(141,'You set the swim speed to %2.2f from normal of %s.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(142,'%s set your swim speed to %2.2f from normal.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(143,'You set the backwards run speed to %2.2f from normal of %s.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(144,'%s set your backwards run speed to %2.2f from normal.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(145,'You set the fly speed to %2.2f from normal of %s.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(146,'%s set your fly speed to %2.2f from normal.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(147,'You set the size %2.2f of %s.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(148,'%s set your size to %2.2f.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(149,'There is no such mount.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(150,'You give a mount to %s.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(151,'%s gave you a mount.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(152,'USER1: %i, ADD: %i, DIF: %i\n',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(153,'You take all copper of %s.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(154,'%s took you all of your copper.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(155,'You take %i copper from %s.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(156,'%s took %i copper from you.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(157,'You give %i copper to %s.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(158,'%s gave you %i copper.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(159,'You hear sound %u.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(160,'USER2: %i, ADD: %i, RESULT: %i\n',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(161,'Removed bit %i in field %i.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(162,'Set bit %i in field %i.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(163,'Teleport location table is empty!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(164,'Teleport location not found!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(165,'Requires search parameter.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(166,'There are no teleport locations matching your request.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(168,'Locations found are:\n %s',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(169,'Mail sent to %s',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(170,'You try to hear sound %u but it doesn\'t exist.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(200,'No selection.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(201,'Object GUID is: lowpart %u highpart %X',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(202,'The name was too long by %i characters.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(203,'Error, name can only contain characters A-Z and a-z.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(204,'The subname was too long by %i characters.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(205,'Not yet implemented',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(206,'Item \'%i\' \'%s\' added to list with maxcount \'%i\' and incrtime \'%i\' and extendedcost \'%i\'',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(207,'Item \'%i\' not found in database.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(208,'Item \'%i\' \'%s\' deleted from vendor list',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(209,'Item \'%i\' not found in vendor list.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(210,'Item \'%i\' already in vendor list.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(211,'Spells of %s reset.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(212,'Spells of %s will reset at next login.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(213,'Talents of %s reset.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(214,'Talents of %s will reset at next login.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(215,'Your spells have been reset.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(216,'Your talents have been reset.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(217,'Unknown case \'%s\' for .resetall command. Type full correct case name.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(218,'Spells will reset for all players at login. Strongly recommend re-login!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(219,'Talents will reset for all players at login. Strongly recommend re-login!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(220,'Creature (GUID: %u) No waypoint found.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(221,'Creature (GUID: %u) Last waypoint not found.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(222,'Creature (GUID: %u) No waypoint found - used \'wpguid\'. Now trying to find it by its position...',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(223,'Creature (GUID: %u) No waypoints found - This is a MaNGOS db problem (single float).',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(224,'Selected creature is ignored - provided GUID is used',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(225,'Creature (GUID: %u) not found',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(226,'You must select a visual waypoint.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(227,'No visual waypoints found',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(228,'Could not create visual waypoint with creatureID: %d',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(229,'All visual waypoints removed',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(230,'Could not create waypoint-creature with ID: %d',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(231,'No GUID provided.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(232,'No waypoint number provided.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(233,'Argument required for \'%s\'.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(234,'Waypoint %i added to GUID: %d',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(235,'Waypoint %d added.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(236,'Waypoint changed.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(237,'Waypoint %s modified.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(238,'WP export successfull.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(239,'No waypoints found inside the database.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(240,'File imported.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(241,'Waypoint removed.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(242,'Warning: Could not delete WP from the world with ID: %d',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(243,'This happens if the waypoint is too far away from your char.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(244,'The WP is deleted from the database, but not from the world here.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(245,'They will disappear after a server restart.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(246,'Waypoint %d: Info for creature: %s, GUID: %d',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(247,'Waittime: %d',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(248,'Model %d: %d',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(249,'Emote: %d',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(250,'Spell: %d',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(251,'Text %d: %s',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(252,'AIScript: %s',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(253,'Forced rename for player %s will be requested at next login.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(254,'Forced rename for player %s (GUID #%u) will be requested at next login.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(255,'Waypoint-Creature (GUID: %u) Not found',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(256,'Could not find NPC...',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(257,'Creature movement type set to \'%s\', waypoints removed (if any).',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(258,'Creature movement type set to \'%s\', waypoints were not removed.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(259,'Incorrect value, use on or off',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(260,'Value saved.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(261,'Value saved, you may need to rejoin or clean your client cache.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(262,'Areatrigger ID %u not found!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(263,'Target map or coordinates is invalid (X: %f Y: %f MapId: %u)',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(264,'Zone coordinates is invalid (X: %f Y: %f AreaId: %u)',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(265,'Zone %u (%s) is part of instanceable map %u (%s)',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(266,'Nothing found!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(267,'Object not found!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(268,'Creature not found!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(269,'Warning: Mob found more than once - you will be teleported to the first one found in DB.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(270,'Creature Removed',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(271,'Creature moved.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(272,'Creature (GUID:%u) must be on the same map as player!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(273,'Game Object (GUID: %u) not found',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(274,'Game Object (GUID: %u) has references in not found creature %u GO list, can\'t be deleted.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(275,'Game Object (GUID: %u) removed',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(276,'Game Object (GUID: %u) turned',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(277,'Game Object (GUID: %u) moved',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(278,'You must select a vendor',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(279,'You must send id for item',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(280,'Vendor has too many items (max 128)',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(281,'You can\'t kick self, logout instead',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(282,'Player %s kicked.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(283,'Player %s not found.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(284,'Accepting Whisper: %s',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(285,'Accepting Whisper: ON',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(286,'Accepting Whisper: OFF',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(287,'Creature (GUID: %u) not found',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(288,'Tickets count: %i show new tickets: %s\n',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(289,'New ticket from %s',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(290,'Ticket of %s (Last updated: %s):\n%s ',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(291,'New ticket show: ON',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(292,'New ticket show: OFF',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(293,'Ticket %i doesn\'t exist',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(294,'All tickets deleted.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(295,'Character %s ticket deleted.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(296,'Ticket deleted.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(297,'Spawn distance changed to: %f',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(298,'Spawn time changed to: %i',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(299,'The honor of %s was set to %u!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(300,'Your chat has been disabled for %u minutes.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(301,'You have disabled %s\'s chat for %u minutes.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(302,'Player\'s chat is already enabled.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(303,'Your chat has been enabled.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(304,'You have enabled %s\'s chat.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(305, 'Faction %s (%u) reputation of %s was set to %5d!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(306, 'The arena points of %s was set to %u!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(307, 'No faction found!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(308, 'Faction %i unknown!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(309, 'Invalid parameter %s',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(310, 'delta must be between 0 and %d (inclusive)',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(311, '%d - |cffffffff|Hfaction:%d|h[%s]|h|r',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(312, ' [visible]',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(313, ' [at war]',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(314, ' [peace forced]',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(315, ' [hidden]',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(316, ' [invisible forced]',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(317, ' [inactive]',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(318, 'Hated',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(319, 'Hostile',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(320, 'Unfriendly',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(321, 'Neutral',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(322, 'Friendly',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(323, 'Honored',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(324, 'Revered',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(325, 'Exalted',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(326, 'Faction %s (%u) can\'not have reputation.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(327, ' [no reputation]',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(328,'Characters at account %s (Id: %u)',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(329,' %s (GUID %u)',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(330,'No players found!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(400,'|cffff0000[System Message]:|rScripts reloaded',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(401,'You change security level of %s to %i.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(402,'%s changed your security level to %i.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(403,'You have low security level for this.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(404,'Creature movement disabled.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(405,'Creature movement enabled.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(406,'Weather can\'t be changed for this zone.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(407,'Weather system disabled at server.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(408,'%s is banned for %s. Reason: %s.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(409,'%s is banned permanently for %s.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(410,'%s %s not found',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(411,'%s unbanned.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(412,'There was an error removing the ban on %s.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(413,'There is no such account.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(414,'There is no such character.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(415,'There is no such IP in banlist.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(416,'Account %s has never been banned',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(417,'Ban history for account %s:',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(418,'Ban Date: %s Bantime: %s Still active: %s Reason: %s Set by: %s',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(419,'Inf.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(420,'Never',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(421,'Yes',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(422,'No',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(423,'IP: %s\nBan Date: %s\nUnban Date: %s\nRemaining: %s\nReason: %s\nSet by: %s',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(424,'There is no matching IPban.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(425,'There is no matching account.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(426,'There is no banned account owning a character matching this part.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(427,'The following IPs match your pattern:',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(428,'The following accounts match your query:',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(429,'You learned many spells/skills.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(430,'You learned all spells for class.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(431,'You learned all talents for class.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(432,'You learned all languages.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(433,'You learned all craft skills and recipes.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(434,'Could not find \'%s\'',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(435,'Invalid item id: %u',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(436,'No items found!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(437,'Invalid gameobject id: %u',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(438,'Found items %u: %u ( inventory %u mail %u auction %u )',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(439,'Found gameobjects %u: %u ',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(440,'Invalid creature id: %u',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(441,'Found creatures %u: %u ',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(442,'No area found!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(443,'No item sets found!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(444,'No skills found!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(445,'No spells found!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(446,'No quests found!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(447,'No creatures found!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(448,'No gameobjects found!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(449,'Graveyard #%u doesn\'t exist.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(450,'Graveyard #%u already linked to zone #%u (current).',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(451,'Graveyard #%u linked to zone #%u (current).',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(452,'Graveyard #%u can\'t be linked to subzone or not existed zone #%u (internal error).',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(453,'Graveyard can be linked to zone at another map only for all factions (no faction value).',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(454,'No faction in Graveyard with id= #%u , fix your DB',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(455,'invalid team, please fix database',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(456,'any',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(457,'alliance',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(458,'horde',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(459,'Graveyard #%u (faction: %s) is nearest from linked to zone #%u.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(460,'Zone #%u doesn\'t have linked graveyards.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(461,'Zone #%u doesn\'t have linked graveyards for faction: %s.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(462,'Teleport location already exists!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(463,'Teleport location added.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(464,'Teleport location NOT added: database error.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(465,'Teleport location deleted.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(467,'Target unit has %d auras:',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(468,'id: %d eff: %d type: %d duration: %d maxduration: %d name: %s%s%s caster: %s %u',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(469,'Target unit has %d auras of type %d:',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(470,'id: %d eff: %d name: %s%s%s caster: %s %u',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(471,'Quest %u not found.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(472,'Quest %u started from item. For correct work, please, add item to inventory and start quest in normal way: .additem %u',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(473,'Quest removed.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(474,' [rewarded]',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(475,' [complete]',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(476,' [active]',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(477,'%s\'s Fly Mode %s',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(478,'Opcode %u sent to %s',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(479,'Character loaded successfully!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(480,'Failed to load the character!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(481,'Character dumped successfully!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(482,'Character dump failed!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(483,'Spell %u broken and not allowed to cast or learn!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(484,'Skill %u (%s) for player %s set to %u and current maximum set to %u (without permanent (talent) bonuses).',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(485,'Player %s must have skill %u (%s) before using this command.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(486,'Invalid skill id (%u)',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(487,'You learned default GM spells/skills.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(488,'You already know that spell.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(489,'Target(%s) already know that spell.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(490,'%s doesn\'t know that spell.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(491,'You already forgot that spell.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(492,'All spell cooldowns removed for %s.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(493,'Spell %u cooldown removed for %s.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(494,'Command : Additem, itemId = %i, amount = %i',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(495,'Command : Additemset, itemsetId = %i',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(496,'Removed itemID = %i, amount = %i from %s',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(497,'Cannot create item \'%i\' (amount: %i)',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(498,'You need to provide a guild name!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(499,'Player not found!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(500,'Player already has a guild!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(501,'Guild not created! (already exists?)',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(502,'No items from itemset \'%u\' found.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(503,'The distance is: (3D) %f (2D) %f yards.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(504,'Item \'%i\' \'%s\' Item Slot %i',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(505,'Item \'%i\' doesn\'t exist.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(506,'Item \'%i\' \'%s\' Added to Slot %i',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(507,'Item save failed!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(508,'%d - owner: %s (guid: %u account: %u ) %s',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(509,'%d - sender: %s (guid: %u account: %u ) receiver: %s (guid: %u account: %u ) %s',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(510,'%d - owner: %s (guid: %u account: %u ) %s',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(511,'Wrong link type!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(512,'%d - |cffffffff|Hitem:%d:0:0:0:0:0:0:0|h[%s]|h|r ',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(513,'%d - |cffffffff|Hquest:%d|h[%s]|h|r %s',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(514,'%d - |cffffffff|Hcreature_entry:%d|h[%s]|h|r ',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(515,'%d - |cffffffff|Hcreature:%d|h[%s X:%f Y:%f Z:%f MapId:%d]|h|r ',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(516,'%d - |cffffffff|Hgameobject_entry:%d|h[%s]|h|r ',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(517,'%d - |cffffffff|Hgameobject:%d|h[%s X:%f Y:%f Z:%f MapId:%d]|h|r ',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(518,'%d - |cffffffff|Hitemset:%d|h[%s %s]|h|r ',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(519,'|cffffffff|Htele:%s|h[%s]|h|r ',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(520,'%d - |cffffffff|Hspell:%d|h[%s]|h|r ',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(521,'%d - |cffffffff|Hskill:%d|h[%s %s]|h|r %s',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(522,'Game Object (GUID: %u) not found',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(523,'>> Game Object %s (GUID: %u) at %f %f %f. Orientation %f.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(524,'Selected object:\n|cffffffff|Hitemset:%d|h[%s]|h|r\nGUID: %u ID: %u\nX: %f Y: %f Z: %f MapId: %u\nOrientation: %f',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(525,'>> Add Game Object \'%i\' (%s) (GUID: %i) added at \'%f %f %f\'.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(526,'%s (lowguid: %u) movement generators stack:',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(527,' Idle',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(528,' Random',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(529,' Waypoint',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(530,' Animal random',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(531,' Confused',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(532,' Targeted to player %s (lowguid %u)',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(533,' Targeted to creature %s (lowguid %u)',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(534,' Targeted to ',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(535,' Home movement to (X:%f Y:%f Z:%f)',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(536,' Home movement used for player?!?',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(537,' Taxi flight',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(538,' Unknown movement generator (%u)',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(539,'Player selected NPC\nGUID: %u.\nFaction: %u.\nnpcFlags: %u.\nEntry: %u.\nDisplayID: %u (Native: %u).',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(540,'Level: %u.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(541,'Health (base): %u. (max): %u. (current): %u.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(542,'Field Flags: %u.\nDynamic Flags: %u.\nFaction Template: %u.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(543,'Loot: %u Pickpocket: %u Skinning: %u',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(544,'Position: %f %f %f.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(545,'*** Is a vendor!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(546,'*** Is a trainer!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(547,'InstanceID: %u',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(548,'Player%s %s (guid: %u) Account: %s (id: %u) GMLevel: %u Last IP: %s Last login: %s Latency: %ums',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(549,'Played time: %s Level: %u Money: %ug%us%uc',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(550,'Command .pinfo doesn\'t support \'rep\' option for offline players.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(551,'%s has explored all zones now.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(552,'%s has no more explored zones.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(553,'%s has explored all zones for you.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(554,'%s has hidden all zones from you.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(555,'Hover enabled',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(556,'Hover disabled',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(557,'You have been leveled up (%i)',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(558,'You have been leveled down (%i)',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(559,'Your level progress has been reset.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(560,'The area has been set as explored.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(561,'The area has been set as not explored.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(562,'GUID=%i \'s updateIndex: %i, value: %i.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(563,'You change GUID=%i \'s UpdateIndex: %i value to %i.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(564,'The value index %u is too big to %u(count: %u).',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(565,'Set %u uint32 Value:[OPCODE]:%u [VALUE]:%u',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(566,'You Set %u Field:%u to uint32 Value: %u',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(567,'Set %u float Value:[OPCODE]:%u [VALUE]:%f',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(568,'You Set %u Field:%i to float Value: %f',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(569,'Get %u uint32 Value:[OPCODE]:%u [VALUE]:%u',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(570,'The uint32 value of %u in %u is: %u',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(571,'Get %u float Value:[OPCODE]:%u [VALUE]:%f',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(572,'The float of %u value in %u is: %f',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(573,'.Set32Bit:[OPCODE]:%u [VALUE]:%u',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(574,'You set Bit of Field:%u to Value: %u',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(575,'.Mod32Value:[OPCODE]:%u [VALUE]:%i',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(576,'You modified the value of Field:%u to Value: %u',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(577,'You are now invisible.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(578,'You are now visible.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(579,'Selected player or creature not have victim.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(580,'You learned all default spells for race/class and completed quests rewarded spells.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(581,'Found near gameobjects (distance %f): %u ',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(582,'SpawnTime: Full:%s Remain:%s',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(583,'%d - |cffffffff|Hgameevent:%d|h[%s]|h|r%s',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(584,'No event found!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(585,'Event not exist!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(586,'Event %u: %s%s\nStart: %s End: %s Occurence: %s Length: %s\nNext state change: %s',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(587,'Event %u already active!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(588,'Event %u not active!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(589,' Point movement to (X:%f Y:%f Z:%f)',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(590,' Fear movement',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(591,' Distract movement',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(592,'You have learned all spells in craft: %s',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(600,'The Alliance wins!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(601,'The Horde wins!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(602,'The battle for Warsong Gulch begins in 1 minute.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(603,'The battle for Warsong Gulch begins in 30 seconds. Prepare yourselves!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(604,'Let the battle for Warsong Gulch begin!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(605,'$n captured the Horde flag!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(606,'$n captured the Alliance flag!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(607,'The Horde flag was dropped by $n!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(608,'The Alliance Flag was dropped by $n!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(609,'The Alliance Flag was returned to its base by $n!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(610,'The Horde flag was returned to its base by $n!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(611,'The Horde flag was picked up by $n!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(612,'The Alliance Flag was picked up by $n!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(613,'The flags are now placed at their bases.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(636,'The Battle for Eye of the Storm begins in 1 minute.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(637,'The Battle for Eye of the Storm begins in 30 seconds.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(638,'The Battle for Eye of the Storm has begun!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(650,'Alliance',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(651,'Horde',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(652,'stables',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(653,'blacksmith',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(654,'farm',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(655,'lumber mill',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(656,'mine',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(657,'The %s has taken the %s',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(658,'$n has defended the %s',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(659,'$n has assaulted the %s',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(660,'$n claims the %s! If left unchallenged, the %s will control it in 1 minute!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(661,'The Battle for Arathi Basin begins in 1 minute.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(662,'The Battle for Arathi Basin begins in 30 seconds. Prepare yourselves!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(663,'The Battle for Arathi Basin has begun!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(664,'The Alliance has gathered $1776W resources, and is near victory!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(665,'The Horde has gathered $1777W resources, and is near victory!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(666,'After your recent battle in %s our best attempts to award you a Mark of Honor failed. Enclosed you will find the Mark of Honor we were not able to deliver to you at the time. Thanks for fighting in %s!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(700,'You must be level %u to form an arena team',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(701,'One minute until the Arena battle begins!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(702,'Thirty seconds until the Arena battle begins!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(703,'Fifteen seconds until the Arena battle begins!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(704,'The Arena battle has begun!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(705,'You must wait %s before speaking again.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(706,'This item(s) have problems with equipping/storing in inventory.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(707,'%s wishes to not be disturbed and cannot receive whisper messages: %s',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(708,'%s is Away from Keyboard: %s',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(709,'Do not Disturb',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(710,'Away from Keyboard',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(711,'Queue status for %s (Lvl: %u to %u)\nQueued alliances: %u (Need at least %u more)\nQueued hordes: %u (Need at least %u more)',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(712,'|cffff0000[BG Queue Announcer]:|r %s -- [%u-%u] A: %u (Need: %u), H: %u (Needs %u)|r',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL); +/*!40000 ALTER TABLE `mangos_string` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `npc_gossip` +-- + +DROP TABLE IF EXISTS `npc_gossip`; +CREATE TABLE `npc_gossip` ( + `npc_guid` int(10) unsigned NOT NULL default '0', + `textid` mediumint(8) unsigned NOT NULL default '0', + PRIMARY KEY (`npc_guid`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + +-- +-- Dumping data for table `npc_gossip` +-- + +LOCK TABLES `npc_gossip` WRITE; +/*!40000 ALTER TABLE `npc_gossip` DISABLE KEYS */; +/*!40000 ALTER TABLE `npc_gossip` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `npc_gossip_textid` +-- + +DROP TABLE IF EXISTS `npc_gossip_textid`; +CREATE TABLE `npc_gossip_textid` ( + `zoneid` smallint(5) unsigned NOT NULL default '0', + `action` smallint(5) unsigned NOT NULL default '0', + `textid` mediumint(8) unsigned NOT NULL default '0', + KEY `zoneid` (`zoneid`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + +-- +-- Dumping data for table `npc_gossip_textid` +-- + +LOCK TABLES `npc_gossip_textid` WRITE; +/*!40000 ALTER TABLE `npc_gossip_textid` DISABLE KEYS */; +/*!40000 ALTER TABLE `npc_gossip_textid` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `npc_option` +-- + +DROP TABLE IF EXISTS `npc_option`; +CREATE TABLE `npc_option` ( + `id` tinyint(3) unsigned NOT NULL default '0', + `gossip_id` tinyint(3) unsigned NOT NULL default '0', + `npcflag` int(10) unsigned NOT NULL default '0', + `icon` tinyint(3) unsigned NOT NULL default '0', + `action` tinyint(3) unsigned NOT NULL default '0', + `option_text` text, + PRIMARY KEY (`id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + +-- +-- Dumping data for table `npc_option` +-- + +LOCK TABLES `npc_option` WRITE; +/*!40000 ALTER TABLE `npc_option` DISABLE KEYS */; +/*!40000 ALTER TABLE `npc_option` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `npc_text` +-- + +DROP TABLE IF EXISTS `npc_text`; +CREATE TABLE `npc_text` ( + `ID` mediumint(8) unsigned NOT NULL default '0', + `text0_0` longtext, + `text0_1` longtext, + `lang0` tinyint(3) unsigned NOT NULL default '0', + `prob0` float NOT NULL default '0', + `em0_0` smallint(5) unsigned NOT NULL default '0', + `em0_1` smallint(5) unsigned NOT NULL default '0', + `em0_2` smallint(5) unsigned NOT NULL default '0', + `em0_3` smallint(5) unsigned NOT NULL default '0', + `em0_4` smallint(5) unsigned NOT NULL default '0', + `em0_5` smallint(5) unsigned NOT NULL default '0', + `text1_0` longtext, + `text1_1` longtext, + `lang1` tinyint(3) unsigned NOT NULL default '0', + `prob1` float NOT NULL default '0', + `em1_0` smallint(5) unsigned NOT NULL default '0', + `em1_1` smallint(5) unsigned NOT NULL default '0', + `em1_2` smallint(5) unsigned NOT NULL default '0', + `em1_3` smallint(5) unsigned NOT NULL default '0', + `em1_4` smallint(5) unsigned NOT NULL default '0', + `em1_5` smallint(5) unsigned NOT NULL default '0', + `text2_0` longtext, + `text2_1` longtext, + `lang2` tinyint(3) unsigned NOT NULL default '0', + `prob2` float NOT NULL default '0', + `em2_0` smallint(5) unsigned NOT NULL default '0', + `em2_1` smallint(5) unsigned NOT NULL default '0', + `em2_2` smallint(5) unsigned NOT NULL default '0', + `em2_3` smallint(5) unsigned NOT NULL default '0', + `em2_4` smallint(5) unsigned NOT NULL default '0', + `em2_5` smallint(5) unsigned NOT NULL default '0', + `text3_0` longtext, + `text3_1` longtext, + `lang3` tinyint(3) unsigned NOT NULL default '0', + `prob3` float NOT NULL default '0', + `em3_0` smallint(5) unsigned NOT NULL default '0', + `em3_1` smallint(5) unsigned NOT NULL default '0', + `em3_2` smallint(5) unsigned NOT NULL default '0', + `em3_3` smallint(5) unsigned NOT NULL default '0', + `em3_4` smallint(5) unsigned NOT NULL default '0', + `em3_5` smallint(5) unsigned NOT NULL default '0', + `text4_0` longtext, + `text4_1` longtext, + `lang4` tinyint(3) unsigned NOT NULL default '0', + `prob4` float NOT NULL default '0', + `em4_0` smallint(5) unsigned NOT NULL default '0', + `em4_1` smallint(5) unsigned NOT NULL default '0', + `em4_2` smallint(5) unsigned NOT NULL default '0', + `em4_3` smallint(5) unsigned NOT NULL default '0', + `em4_4` smallint(5) unsigned NOT NULL default '0', + `em4_5` smallint(5) unsigned NOT NULL default '0', + `text5_0` longtext, + `text5_1` longtext, + `lang5` tinyint(3) unsigned NOT NULL default '0', + `prob5` float NOT NULL default '0', + `em5_0` smallint(5) unsigned NOT NULL default '0', + `em5_1` smallint(5) unsigned NOT NULL default '0', + `em5_2` smallint(5) unsigned NOT NULL default '0', + `em5_3` smallint(5) unsigned NOT NULL default '0', + `em5_4` smallint(5) unsigned NOT NULL default '0', + `em5_5` smallint(5) unsigned NOT NULL default '0', + `text6_0` longtext, + `text6_1` longtext, + `lang6` tinyint(3) unsigned NOT NULL default '0', + `prob6` float NOT NULL default '0', + `em6_0` smallint(5) unsigned NOT NULL default '0', + `em6_1` smallint(5) unsigned NOT NULL default '0', + `em6_2` smallint(5) unsigned NOT NULL default '0', + `em6_3` smallint(5) unsigned NOT NULL default '0', + `em6_4` smallint(5) unsigned NOT NULL default '0', + `em6_5` smallint(5) unsigned NOT NULL default '0', + `text7_0` longtext, + `text7_1` longtext, + `lang7` tinyint(3) unsigned NOT NULL default '0', + `prob7` float NOT NULL default '0', + `em7_0` smallint(5) unsigned NOT NULL default '0', + `em7_1` smallint(5) unsigned NOT NULL default '0', + `em7_2` smallint(5) unsigned NOT NULL default '0', + `em7_3` smallint(5) unsigned NOT NULL default '0', + `em7_4` smallint(5) unsigned NOT NULL default '0', + `em7_5` smallint(5) unsigned NOT NULL default '0', + PRIMARY KEY (`ID`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + +-- +-- Dumping data for table `npc_text` +-- + +LOCK TABLES `npc_text` WRITE; +/*!40000 ALTER TABLE `npc_text` DISABLE KEYS */; +/*!40000 ALTER TABLE `npc_text` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `npc_trainer` +-- + +DROP TABLE IF EXISTS `npc_trainer`; +CREATE TABLE `npc_trainer` ( + `entry` mediumint(8) unsigned NOT NULL default '0', + `spell` mediumint(8) unsigned NOT NULL default '0', + `spellcost` int(10) unsigned NOT NULL default '0', + `reqskill` smallint(5) unsigned NOT NULL default '0', + `reqskillvalue` smallint(5) unsigned NOT NULL default '0', + `reqlevel` tinyint(3) unsigned NOT NULL default '0', + UNIQUE KEY `entry_spell` (`entry`,`spell`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + +-- +-- Dumping data for table `npc_trainer` +-- + +LOCK TABLES `npc_trainer` WRITE; +/*!40000 ALTER TABLE `npc_trainer` DISABLE KEYS */; +/*!40000 ALTER TABLE `npc_trainer` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `npc_vendor` +-- + +DROP TABLE IF EXISTS `npc_vendor`; +CREATE TABLE `npc_vendor` ( + `entry` mediumint(8) unsigned NOT NULL default '0', + `item` mediumint(8) unsigned NOT NULL default '0', + `maxcount` tinyint(3) unsigned NOT NULL default '0', + `incrtime` int(10) unsigned NOT NULL default '0', + `ExtendedCost` mediumint(8) unsigned NOT NULL default '0', + PRIMARY KEY (`entry`,`item`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Npc System'; + +-- +-- Dumping data for table `npc_vendor` +-- + +LOCK TABLES `npc_vendor` WRITE; +/*!40000 ALTER TABLE `npc_vendor` DISABLE KEYS */; +/*!40000 ALTER TABLE `npc_vendor` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `page_text` +-- + +DROP TABLE IF EXISTS `page_text`; +CREATE TABLE `page_text` ( + `entry` mediumint(8) unsigned NOT NULL default '0', + `text` longtext NOT NULL, + `next_page` mediumint(8) unsigned NOT NULL default '0', + PRIMARY KEY (`entry`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Item System'; + +-- +-- Dumping data for table `page_text` +-- + +LOCK TABLES `page_text` WRITE; +/*!40000 ALTER TABLE `page_text` DISABLE KEYS */; +/*!40000 ALTER TABLE `page_text` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `pet_levelstats` +-- + +DROP TABLE IF EXISTS `pet_levelstats`; +CREATE TABLE `pet_levelstats` ( + `creature_entry` mediumint(8) unsigned NOT NULL, + `level` tinyint(3) unsigned NOT NULL, + `hp` smallint(5) unsigned NOT NULL, + `mana` smallint(5) unsigned NOT NULL, + `armor` int(10) unsigned NOT NULL default '0', + `str` smallint(5) unsigned NOT NULL, + `agi` smallint(5) unsigned NOT NULL, + `sta` smallint(5) unsigned NOT NULL, + `inte` smallint(5) unsigned NOT NULL, + `spi` smallint(5) unsigned NOT NULL, + PRIMARY KEY (`creature_entry`,`level`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 PACK_KEYS=0 COMMENT='Stores pet levels stats.'; + +-- +-- Dumping data for table `pet_levelstats` +-- + +LOCK TABLES `pet_levelstats` WRITE; +/*!40000 ALTER TABLE `pet_levelstats` DISABLE KEYS */; +/*!40000 ALTER TABLE `pet_levelstats` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `pet_name_generation` +-- + +DROP TABLE IF EXISTS `pet_name_generation`; +CREATE TABLE `pet_name_generation` ( + `id` mediumint(8) unsigned NOT NULL auto_increment, + `word` tinytext NOT NULL, + `entry` mediumint(8) unsigned NOT NULL default '0', + `half` tinyint(4) NOT NULL default '0', + PRIMARY KEY (`id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + +-- +-- Dumping data for table `pet_name_generation` +-- + +LOCK TABLES `pet_name_generation` WRITE; +/*!40000 ALTER TABLE `pet_name_generation` DISABLE KEYS */; +INSERT INTO `pet_name_generation` (`word`,`entry`,`half`) VALUES +('Aba',416,0), +('Az',416,0), +('Bel',416,0), +('Biz',416,0), +('Cho',416,0), +('Dag',416,0), +('Gak',416,0), +('Gar',416,0), +('Gel',416,0), +('Gho',416,0), +('Gob',416,0), +('Gra',416,0), +('Jak',416,0), +('Jub',416,0), +('Kar',416,0), +('Kup',416,0), +('Laz',416,0), +('Nal',416,0), +('Nok',416,0), +('Pag',416,0), +('Pig',416,0), +('Pip',416,0), +('Piz',416,0), +('Quz',416,0), +('Rui',416,0), +('Rul',416,0), +('Rup',416,0), +('Tar',416,0), +('Vol',416,0), +('Yaz',416,0), +('Zep',416,0), +('Zig',416,0), +('Zil',416,0), +('Zor',416,0), +('bis',416,1), +('fip',416,1), +('gup',416,1), +('ham',416,1), +('jub',416,1), +('kin',416,1), +('kol',416,1), +('lop',416,1), +('loz',416,1), +('mat',416,1), +('mir',416,1), +('nam',416,1), +('nar',416,1), +('nik',416,1), +('nip',416,1), +('pad',416,1), +('pep',416,1), +('pit',416,1), +('qua',416,1), +('rai',416,1), +('rin',416,1), +('rot',416,1), +('tai',416,1), +('tal',416,1), +('tik',416,1), +('tip',416,1), +('tog',416,1), +('tuk',416,1), +('uri',416,1), +('yal',416,1), +('yap',416,1), +('Bhee',417,0), +('Bruu',417,0), +('Czaa',417,0), +('Droo',417,0), +('Flaa',417,0), +('Fzuu',417,0), +('Ghaa',417,0), +('Gree',417,0), +('Gzaa',417,0), +('Haa',417,0), +('Haad',417,0), +('Haag',417,0), +('Haap',417,0), +('Jhaa',417,0), +('Jhuu',417,0), +('Khaa',417,0), +('Khii',417,0), +('Khuu',417,0), +('Kree',417,0), +('Luu',417,0), +('Maa',417,0), +('Nhee',417,0), +('Phuu',417,0), +('Pryy',417,0), +('Rhuu',417,0), +('Shaa',417,0), +('Sloo',417,0), +('Sruu',417,0), +('Thoo',417,0), +('Traa',417,0), +('Wraa',417,0), +('Zhaa',417,0), +('dhon',417,1), +('dhum',417,1), +('dhun',417,1), +('dom',417,1), +('don',417,1), +('drom',417,1), +('dym',417,1), +('fenn',417,1), +('fum',417,1), +('fun',417,1), +('ghon',417,1), +('ghun',417,1), +('grom',417,1), +('grym',417,1), +('hom',417,1), +('hon',417,1), +('hun',417,1), +('jhom',417,1), +('kun',417,1), +('lum',417,1), +('mmon',417,1), +('mon',417,1), +('myn',417,1), +('nam',417,1), +('nem',417,1), +('nhym',417,1), +('nom',417,1), +('num',417,1), +('phom',417,1), +('roon',417,1), +('rym',417,1), +('shon',417,1), +('thun',417,1), +('tom',417,1), +('zhem',417,1), +('zhum',417,1), +('zun',417,1), +('Bar',1860,0), +('Bel',1860,0), +('Char',1860,0), +('Grak\'',1860,0), +('Graz\'',1860,0), +('Grim',1860,0), +('Hath',1860,0), +('Hel',1860,0), +('Hok',1860,0), +('Huk',1860,0), +('Jhaz',1860,0), +('Jhom',1860,0), +('Juk\'',1860,0), +('Kal\'',1860,0), +('Klath',1860,0), +('Kon',1860,0), +('Krag',1860,0), +('Krak',1860,0), +('Mak',1860,0), +('Mezz',1860,0), +('Orm',1860,0), +('Phan',1860,0), +('Sar',1860,0), +('Tang',1860,0), +('Than',1860,0), +('Thog',1860,0), +('Thok',1860,0), +('Thul',1860,0), +('Zag\'',1860,0), +('Zang',1860,0), +('Zhar\'',1860,0), +('kath',1860,1), +('doc',1860,1), +('dok',1860,1), +('gak',1860,1), +('garth',1860,1), +('gore',1860,1), +('gorg',1860,1), +('grave',1860,1), +('gron',1860,1), +('juk',1860,1), +('krast',1860,1), +('kresh',1860,1), +('krit',1860,1), +('los',1860,1), +('mon',1860,1), +('mos',1860,1), +('moth',1860,1), +('nagma',1860,1), +('nak',1860,1), +('nar',1860,1), +('nos',1860,1), +('nuz',1860,1), +('phog',1860,1), +('rath',1860,1), +('tast',1860,1), +('taz',1860,1), +('thak',1860,1), +('thang',1860,1), +('thyk',1860,1), +('vhug',1860,1), +('zazt',1860,1), +('Ael',1863,0), +('Aez',1863,0), +('Ang',1863,0), +('Ban',1863,0), +('Bet',1863,0), +('Bro',1863,0), +('Bry',1863,0), +('Cat',1863,0), +('Dir',1863,0), +('Dis',1863,0), +('Dom',1863,0), +('Drus',1863,0), +('Fie',1863,0), +('Fier',1863,0), +('Gly',1863,0), +('Hel',1863,0), +('Hes',1863,0), +('Kal',1863,0), +('Lyn',1863,0), +('Mir',1863,0), +('Nim',1863,0), +('Sar',1863,0), +('Sel',1863,0), +('Vil',1863,0), +('Zah',1863,0), +('aith',1863,1), +('anda',1863,1), +('antia',1863,1), +('evere',1863,1), +('lia',1863,1), +('lissa',1863,1), +('neri',1863,1), +('neth',1863,1), +('nia',1863,1), +('nlissa',1863,1), +('nora',1863,1), +('nva',1863,1), +('nys',1863,1), +('ola',1863,1), +('ona',1863,1), +('ora',1863,1), +('rah',1863,1), +('riana',1863,1), +('riel',1863,1), +('rona',1863,1), +('tai',1863,1), +('tevere',1863,1), +('thea',1863,1), +('vina',1863,1), +('wena',1863,1), +('wyn',1863,1), +('xia',1863,1), +('yla',1863,1), +('yssa',1863,1), +('Flaa',17252,0), +('Haa',17252,0), +('Jhuu',17252,0), +('Shaa',17252,0), +('Thoo',17252,0), +('dhun',17252,1), +('ghun',17252,1), +('roon',17252,1), +('thun',17252,1), +('tom',17252,1); + +/*!40000 ALTER TABLE `pet_name_generation` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `petcreateinfo_spell` +-- + +DROP TABLE IF EXISTS `petcreateinfo_spell`; +CREATE TABLE `petcreateinfo_spell` ( + `entry` mediumint(8) unsigned NOT NULL default '0', + `Spell1` mediumint(8) unsigned NOT NULL default '0', + `Spell2` mediumint(8) unsigned NOT NULL default '0', + `Spell3` mediumint(8) unsigned NOT NULL default '0', + `Spell4` mediumint(8) unsigned NOT NULL default '0', + PRIMARY KEY (`entry`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='Pet Create Spells'; + +-- +-- Dumping data for table `petcreateinfo_spell` +-- + +LOCK TABLES `petcreateinfo_spell` WRITE; +/*!40000 ALTER TABLE `petcreateinfo_spell` DISABLE KEYS */; +/*!40000 ALTER TABLE `petcreateinfo_spell` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `pickpocketing_loot_template` +-- + +DROP TABLE IF EXISTS `pickpocketing_loot_template`; +CREATE TABLE `pickpocketing_loot_template` ( + `entry` mediumint(8) unsigned NOT NULL default '0', + `item` mediumint(8) unsigned NOT NULL default '0', + `ChanceOrQuestChance` float NOT NULL default '100', + `groupid` tinyint(3) unsigned NOT NULL default '0', + `mincountOrRef` mediumint(9) NOT NULL default '1', + `maxcount` tinyint(3) unsigned NOT NULL default '1', + `lootcondition` tinyint(3) unsigned NOT NULL default '0', + `condition_value1` mediumint(8) unsigned NOT NULL default '0', + `condition_value2` mediumint(8) unsigned NOT NULL default '0', + PRIMARY KEY (`entry`,`item`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Loot System'; + +-- +-- Dumping data for table `pickpocketing_loot_template` +-- + +LOCK TABLES `pickpocketing_loot_template` WRITE; +/*!40000 ALTER TABLE `pickpocketing_loot_template` DISABLE KEYS */; +/*!40000 ALTER TABLE `pickpocketing_loot_template` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `player_classlevelstats` +-- + +DROP TABLE IF EXISTS `player_classlevelstats`; +CREATE TABLE `player_classlevelstats` ( + `class` tinyint(3) unsigned NOT NULL, + `level` tinyint(3) unsigned NOT NULL, + `basehp` smallint(5) unsigned NOT NULL, + `basemana` smallint(5) unsigned NOT NULL, + PRIMARY KEY (`class`,`level`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 PACK_KEYS=0 COMMENT='Stores levels stats.'; + +-- +-- Dumping data for table `player_classlevelstats` +-- + +LOCK TABLES `player_classlevelstats` WRITE; +/*!40000 ALTER TABLE `player_classlevelstats` DISABLE KEYS */; +INSERT INTO `player_classlevelstats` VALUES +(1,1,20,0), +(1,2,29,0), +(1,3,38,0), +(1,4,47,0), +(1,5,56,0), +(1,6,65,0), +(1,7,74,0), +(1,8,83,0), +(1,9,92,0), +(1,10,101,0), +(1,11,100,0), +(1,12,109,0), +(1,13,118,0), +(1,14,128,0), +(1,15,139,0), +(1,16,151,0), +(1,17,154,0), +(1,18,168,0), +(1,19,183,0), +(1,20,199,0), +(1,21,206,0), +(1,22,224,0), +(1,23,243,0), +(1,24,253,0), +(1,25,274,0), +(1,26,296,0), +(1,27,309,0), +(1,28,333,0), +(1,29,348,0), +(1,30,374,0), +(1,31,401,0), +(1,32,419,0), +(1,33,448,0), +(1,34,468,0), +(1,35,499,0), +(1,36,521,0), +(1,37,545,0), +(1,38,581,0), +(1,39,609,0), +(1,40,649,0), +(1,41,681,0), +(1,42,715,0), +(1,43,761,0), +(1,44,799,0), +(1,45,839,0), +(1,46,881,0), +(1,47,935,0), +(1,48,981,0), +(1,49,1029,0), +(1,50,1079,0), +(1,51,1131,0), +(1,52,1185,0), +(1,53,1241,0), +(1,54,1299,0), +(1,55,1359,0), +(1,56,1421,0), +(1,57,1485,0), +(1,58,1551,0), +(1,59,1619,0), +(1,60,1689,0), +(1,61,1902,0), +(1,62,2129,0), +(1,63,2357,0), +(1,64,2612,0), +(1,65,2883,0), +(1,66,3169,0), +(1,67,3455,0), +(1,68,3774,0), +(1,69,4109,0), +(1,70,4444,0), +(2,1,28,60), +(2,2,36,78), +(2,3,44,98), +(2,4,52,104), +(2,5,60,111), +(2,6,68,134), +(2,7,76,143), +(2,8,84,153), +(2,9,92,179), +(2,10,100,192), +(2,11,108,205), +(2,12,116,219), +(2,13,124,249), +(2,14,132,265), +(2,15,131,282), +(2,16,141,315), +(2,17,152,334), +(2,18,164,354), +(2,19,177,390), +(2,20,191,412), +(2,21,206,435), +(2,22,222,459), +(2,23,239,499), +(2,24,247,525), +(2,25,266,552), +(2,26,286,579), +(2,27,307,621), +(2,28,329,648), +(2,29,342,675), +(2,30,366,702), +(2,31,391,729), +(2,32,407,756), +(2,33,434,798), +(2,34,462,825), +(2,35,481,852), +(2,36,511,879), +(2,37,542,906), +(2,38,564,933), +(2,39,597,960), +(2,40,621,987), +(2,41,656,1014), +(2,42,682,1041), +(2,43,719,1068), +(2,44,747,1110), +(2,45,786,1137), +(2,46,816,1164), +(2,47,857,1176), +(2,48,889,1203), +(2,49,922,1230), +(2,50,966,1257), +(2,51,1001,1284), +(2,52,1037,1311), +(2,53,1084,1338), +(2,54,1122,1365), +(2,55,1161,1392), +(2,56,1201,1419), +(2,57,1252,1446), +(2,58,1294,1458), +(2,59,1337,1485), +(2,60,1381,1512), +(2,61,1540,1656), +(2,62,1708,1800), +(2,63,1884,1944), +(2,64,2068,2088), +(2,65,2262,2232), +(2,66,2466,2377), +(2,67,2679,2521), +(2,68,2901,2665), +(2,69,3134,2809), +(2,70,3377,2953), +(3,1,46,65), +(3,2,53,70), +(3,3,60,76), +(3,4,67,98), +(3,5,74,106), +(3,6,81,130), +(3,7,88,140), +(3,8,95,166), +(3,9,102,193), +(3,10,109,206), +(3,11,116,235), +(3,12,123,250), +(3,13,130,266), +(3,14,138,298), +(3,15,147,316), +(3,16,157,350), +(3,17,168,370), +(3,18,180,391), +(3,19,193,428), +(3,20,207,451), +(3,21,222,475), +(3,22,238,515), +(3,23,255,541), +(3,24,273,568), +(3,25,292,611), +(3,26,312,640), +(3,27,333,670), +(3,28,355,715), +(3,29,378,745), +(3,30,402,775), +(3,31,417,805), +(3,32,443,850), +(3,33,470,880), +(3,34,498,910), +(3,35,527,940), +(3,36,547,970), +(3,37,578,1015), +(3,38,610,1045), +(3,39,643,1075), +(3,40,667,1105), +(3,41,702,1135), +(3,42,738,1180), +(3,43,775,1210), +(3,44,803,1240), +(3,45,842,1270), +(3,46,872,1300), +(3,47,913,1330), +(3,48,955,1360), +(3,49,994,1390), +(3,50,1047,1420), +(3,51,1067,1450), +(3,52,1113,1480), +(3,53,1150,1510), +(3,54,1198,1540), +(3,55,1237,1570), +(3,56,1287,1600), +(3,57,1328,1630), +(3,58,1370,1660), +(3,59,1423,1690), +(3,60,1467,1720), +(3,61,1633,1886), +(3,62,1819,2053), +(3,63,2003,2219), +(3,64,2195,2385), +(3,65,2397,2552), +(3,66,2623,2718), +(3,67,2844,2884), +(3,68,3075,3050), +(3,69,3316,3217), +(3,70,3568,3383), +(4,1,25,0), +(4,2,32,0), +(4,3,49,0), +(4,4,56,0), +(4,5,63,0), +(4,6,70,0), +(4,7,87,0), +(4,8,94,0), +(4,9,101,0), +(4,10,118,0), +(4,11,125,0), +(4,12,142,0), +(4,13,149,0), +(4,14,156,0), +(4,15,173,0), +(4,16,181,0), +(4,17,190,0), +(4,18,200,0), +(4,19,221,0), +(4,20,233,0), +(4,21,246,0), +(4,22,260,0), +(4,23,275,0), +(4,24,301,0), +(4,25,318,0), +(4,26,336,0), +(4,27,355,0), +(4,28,375,0), +(4,29,396,0), +(4,30,428,0), +(4,31,451,0), +(4,32,475,0), +(4,33,500,0), +(4,34,526,0), +(4,35,553,0), +(4,36,581,0), +(4,37,610,0), +(4,38,640,0), +(4,39,671,0), +(4,40,703,0), +(4,41,736,0), +(4,42,770,0), +(4,43,805,0), +(4,44,841,0), +(4,45,878,0), +(4,46,916,0), +(4,47,955,0), +(4,48,995,0), +(4,49,1026,0), +(4,50,1068,0), +(4,51,1111,0), +(4,52,1155,0), +(4,53,1200,0), +(4,54,1246,0), +(4,55,1283,0), +(4,56,1331,0), +(4,57,1380,0), +(4,58,1430,0), +(4,59,1471,0), +(4,60,1523,0), +(4,61,1702,0), +(4,62,1879,0), +(4,63,2077,0), +(4,64,2285,0), +(4,65,2489,0), +(4,66,2717,0), +(4,67,2941,0), +(4,68,3190,0), +(4,69,3450,0), +(4,70,3704,0), +(5,1,52,73), +(5,2,57,76), +(5,3,72,95), +(5,4,77,114), +(5,5,92,133), +(5,6,97,152), +(5,7,112,171), +(5,8,117,190), +(5,9,132,209), +(5,10,137,212), +(5,11,142,215), +(5,12,157,234), +(5,13,172,254), +(5,14,177,260), +(5,15,192,282), +(5,16,197,305), +(5,17,212,329), +(5,18,227,339), +(5,19,232,365), +(5,20,247,377), +(5,21,252,405), +(5,22,268,434), +(5,23,275,449), +(5,24,293,480), +(5,25,302,497), +(5,26,322,530), +(5,27,343,549), +(5,28,355,584), +(5,29,378,605), +(5,30,392,627), +(5,31,417,665), +(5,32,433,689), +(5,33,460,728), +(5,34,478,752), +(5,35,507,776), +(5,36,527,800), +(5,37,548,839), +(5,38,580,863), +(5,39,603,887), +(5,40,637,911), +(5,41,662,950), +(5,42,698,974), +(5,43,725,998), +(5,44,763,1022), +(5,45,792,1046), +(5,46,822,1070), +(5,47,863,1094), +(5,48,895,1118), +(5,49,928,1142), +(5,50,972,1166), +(5,51,1007,1190), +(5,52,1053,1214), +(5,53,1090,1238), +(5,54,1128,1262), +(5,55,1177,1271), +(5,56,1217,1295), +(5,57,1258,1319), +(5,58,1300,1343), +(5,59,1353,1352), +(5,60,1397,1376), +(5,61,1557,1500), +(5,62,1738,1625), +(5,63,1916,1749), +(5,64,2101,1873), +(5,65,2295,1998), +(5,66,2495,2122), +(5,67,2719,2247), +(5,68,2936,2371), +(5,69,3160,2495), +(5,70,3391,2620), +(7,1,37,85), +(7,2,44,91), +(7,3,51,98), +(7,4,58,106), +(7,5,65,115), +(7,6,72,125), +(7,7,79,136), +(7,8,86,148), +(7,9,93,161), +(7,10,100,175), +(7,11,107,190), +(7,12,114,206), +(7,13,121,223), +(7,14,128,241), +(7,15,135,260), +(7,16,142,280), +(7,17,150,301), +(7,18,159,323), +(7,19,169,346), +(7,20,180,370), +(7,21,192,395), +(7,22,205,421), +(7,23,219,448), +(7,24,234,476), +(7,25,240,505), +(7,26,257,535), +(7,27,275,566), +(7,28,294,598), +(7,29,314,631), +(7,30,335,665), +(7,31,347,699), +(7,32,370,733), +(7,33,394,767), +(7,34,419,786), +(7,35,435,820), +(7,36,462,854), +(7,37,490,888), +(7,38,509,922), +(7,39,539,941), +(7,40,570,975), +(7,41,592,1009), +(7,42,625,1028), +(7,43,649,1062), +(7,44,684,1096), +(7,45,710,1115), +(7,46,747,1149), +(7,47,775,1183), +(7,48,814,1202), +(7,49,844,1236), +(7,50,885,1255), +(7,51,917,1289), +(7,52,960,1323), +(7,53,994,1342), +(7,54,1029,1376), +(7,55,1075,1395), +(7,56,1112,1414), +(7,57,1150,1448), +(7,58,1199,1467), +(7,59,1239,1501), +(7,60,1330,1520), +(7,61,1428,1664), +(7,62,1583,1808), +(7,63,1760,1951), +(7,64,1932,2095), +(7,65,2114,2239), +(7,66,2304,2383), +(7,67,2504,2527), +(7,68,2713,2670), +(7,69,2931,2814), +(7,70,3159,2958), +(8,1,32,100), +(8,2,47,110), +(8,3,52,106), +(8,4,67,118), +(8,5,82,131), +(8,6,97,130), +(8,7,102,145), +(8,8,117,146), +(8,9,132,163), +(8,10,137,196), +(8,11,152,215), +(8,12,167,220), +(8,13,172,241), +(8,14,187,263), +(8,15,202,271), +(8,16,207,295), +(8,17,222,305), +(8,18,237,331), +(8,19,242,343), +(8,20,257,371), +(8,21,272,385), +(8,22,277,415), +(8,23,292,431), +(8,24,298,463), +(8,25,315,481), +(8,26,333,515), +(8,27,342,535), +(8,28,362,556), +(8,29,373,592), +(8,30,395,613), +(8,31,418,634), +(8,32,432,670), +(8,33,457,691), +(8,34,473,712), +(8,35,500,733), +(8,36,518,754), +(8,37,547,790), +(8,38,577,811), +(8,39,598,832), +(8,40,630,853), +(8,41,653,874), +(8,42,687,895), +(8,43,712,916), +(8,44,748,937), +(8,45,775,958), +(8,46,813,979), +(8,47,842,1000), +(8,48,882,1021), +(8,49,913,1042), +(8,50,955,1048), +(8,51,988,1069), +(8,52,1032,1090), +(8,53,1067,1111), +(8,54,1103,1117), +(8,55,1150,1138), +(8,56,1188,1159), +(8,57,1237,1165), +(8,58,1277,1186), +(8,59,1328,1192), +(8,60,1370,1213), +(8,61,1526,1316), +(8,62,1702,1419), +(8,63,1875,1521), +(8,64,2070,1624), +(8,65,2261,1727), +(8,66,2461,1830), +(8,67,2686,1932), +(8,68,2906,2035), +(8,69,3136,2138), +(8,70,3393,2241), +(9,1,23,90), +(9,2,28,98), +(9,3,43,107), +(9,4,48,102), +(9,5,63,113), +(9,6,68,126), +(9,7,83,144), +(9,8,88,162), +(9,9,93,180), +(9,10,108,198), +(9,11,123,200), +(9,12,128,218), +(9,13,143,237), +(9,14,148,257), +(9,15,153,278), +(9,16,168,300), +(9,17,173,308), +(9,18,189,332), +(9,19,196,357), +(9,20,204,383), +(9,21,223,395), +(9,22,233,423), +(9,23,244,452), +(9,24,266,467), +(9,25,279,498), +(9,26,293,530), +(9,27,318,548), +(9,28,334,582), +(9,29,351,602), +(9,30,379,638), +(9,31,398,674), +(9,32,418,695), +(9,33,439,731), +(9,34,471,752), +(9,35,494,788), +(9,36,518,809), +(9,37,543,830), +(9,38,569,866), +(9,39,606,887), +(9,40,634,923), +(9,41,663,944), +(9,42,693,965), +(9,43,724,1001), +(9,44,756,1022), +(9,45,799,1043), +(9,46,832,1064), +(9,47,868,1100), +(9,48,904,1121), +(9,49,941,1142), +(9,50,979,1163), +(9,51,1018,1184), +(9,52,1058,1205), +(9,53,1099,1226), +(9,54,1141,1247), +(9,55,1184,1268), +(9,56,1228,1289), +(9,57,1273,1310), +(9,58,1319,1331), +(9,59,1366,1352), +(9,60,1414,1373), +(9,61,1580,1497), +(9,62,1755,1621), +(9,63,1939,1745), +(9,64,2133,1870), +(9,65,2323,1994), +(9,66,2535,2118), +(9,67,2758,2242), +(9,68,2991,2366), +(9,69,3235,2490), +(9,70,3490,2615), +(11,1,44,60), +(11,2,51,66), +(11,3,58,73), +(11,4,75,81), +(11,5,82,90), +(11,6,89,100), +(11,7,106,111), +(11,8,113,123), +(11,9,120,136), +(11,10,137,150), +(11,11,144,165), +(11,12,151,182), +(11,13,168,200), +(11,14,175,219), +(11,15,182,239), +(11,16,199,260), +(11,17,206,282), +(11,18,214,305), +(11,19,233,329), +(11,20,243,354), +(11,21,254,380), +(11,22,266,392), +(11,23,289,420), +(11,24,303,449), +(11,25,318,479), +(11,26,334,509), +(11,27,361,524), +(11,28,379,554), +(11,29,398,584), +(11,30,418,614), +(11,31,439,629), +(11,32,461,659), +(11,33,494,689), +(11,34,518,704), +(11,35,543,734), +(11,36,569,749), +(11,37,596,779), +(11,38,624,809), +(11,39,653,824), +(11,40,683,854), +(11,41,714,869), +(11,42,746,899), +(11,43,779,914), +(11,44,823,944), +(11,45,858,959), +(11,46,894,989), +(11,47,921,1004), +(11,48,959,1019), +(11,49,998,1049), +(11,50,1038,1064), +(11,51,1079,1079), +(11,52,1121,1109), +(11,53,1164,1124), +(11,54,1208,1139), +(11,55,1253,1154), +(11,56,1299,1169), +(11,57,1346,1199), +(11,58,1384,1214), +(11,59,1433,1229), +(11,60,1483,1244), +(11,61,1657,1357), +(11,62,1840,1469), +(11,63,2020,1582), +(11,64,2222,1694), +(11,65,2433,1807), +(11,66,2640,1919), +(11,67,2872,2032), +(11,68,3114,2145), +(11,69,3351,2257), +(11,70,3614,2370); +/*!40000 ALTER TABLE `player_classlevelstats` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `player_levelstats` +-- + +DROP TABLE IF EXISTS `player_levelstats`; +CREATE TABLE `player_levelstats` ( + `race` tinyint(3) unsigned NOT NULL, + `class` tinyint(3) unsigned NOT NULL, + `level` tinyint(3) unsigned NOT NULL, + `str` tinyint(3) unsigned NOT NULL, + `agi` tinyint(3) unsigned NOT NULL, + `sta` tinyint(3) unsigned NOT NULL, + `inte` tinyint(3) unsigned NOT NULL, + `spi` tinyint(3) unsigned NOT NULL, + PRIMARY KEY (`race`,`class`,`level`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 PACK_KEYS=0 COMMENT='Stores levels stats.'; + +-- +-- Dumping data for table `player_levelstats` +-- + +LOCK TABLES `player_levelstats` WRITE; +/*!40000 ALTER TABLE `player_levelstats` DISABLE KEYS */; +INSERT INTO `player_levelstats` VALUES +(1,1,1,23,20,22,20,20), +(1,1,2,24,21,23,20,20), +(1,1,3,26,22,24,20,21), +(1,1,4,27,22,26,20,21), +(1,1,5,28,23,27,20,21), +(1,1,6,30,24,28,20,21), +(1,1,7,31,25,29,21,22), +(1,1,8,32,26,30,21,22), +(1,1,9,34,26,32,21,22), +(1,1,10,35,27,33,21,23), +(1,1,11,36,28,34,21,23), +(1,1,12,38,29,35,21,23), +(1,1,13,39,30,37,21,24), +(1,1,14,41,31,38,21,24), +(1,1,15,42,32,39,21,24), +(1,1,16,44,33,41,21,25), +(1,1,17,45,34,42,22,25), +(1,1,18,47,34,43,22,25), +(1,1,19,48,35,45,22,26), +(1,1,20,50,36,46,22,26), +(1,1,21,51,37,48,22,26), +(1,1,22,53,38,49,22,27), +(1,1,23,54,39,51,22,27), +(1,1,24,56,40,52,23,28), +(1,1,25,58,41,53,23,28), +(1,1,26,59,42,55,23,28), +(1,1,27,61,43,56,23,29), +(1,1,28,63,44,58,23,29), +(1,1,29,64,45,59,23,30), +(1,1,30,66,46,61,24,30), +(1,1,31,68,47,62,24,30), +(1,1,32,69,48,64,24,31), +(1,1,33,71,50,66,24,31), +(1,1,34,73,51,67,24,32), +(1,1,35,74,52,69,24,32), +(1,1,36,76,53,70,25,33), +(1,1,37,78,54,72,25,33), +(1,1,38,80,55,74,25,34), +(1,1,39,82,56,75,25,34), +(1,1,40,83,57,77,25,35), +(1,1,41,85,58,79,26,35), +(1,1,42,87,60,80,26,35), +(1,1,43,89,61,82,26,36), +(1,1,44,91,62,84,26,36), +(1,1,45,93,63,85,26,37), +(1,1,46,95,64,87,27,37), +(1,1,47,97,66,89,27,38), +(1,1,48,99,67,91,27,38), +(1,1,49,101,68,93,27,39), +(1,1,50,103,69,94,28,40), +(1,1,51,105,71,96,28,40), +(1,1,52,107,72,98,28,41), +(1,1,53,109,73,100,28,41), +(1,1,54,111,74,102,29,42), +(1,1,55,113,76,103,29,42), +(1,1,56,115,77,105,29,43), +(1,1,57,117,78,107,29,43), +(1,1,58,119,79,109,30,44), +(1,1,59,121,81,111,30,44), +(1,1,60,123,82,113,30,45), +(1,1,61,125,83,115,30,46), +(1,1,62,127,85,117,31,46), +(1,1,63,129,86,119,31,47), +(1,1,64,132,88,121,31,47), +(1,1,65,134,89,123,32,48), +(1,1,66,136,90,125,32,49), +(1,1,67,138,92,127,32,49), +(1,1,68,140,93,129,32,50), +(1,1,69,143,95,131,33,50), +(1,1,70,145,96,133,33,51), +(1,2,1,22,20,22,20,21), +(1,2,2,23,21,23,21,22), +(1,2,3,24,21,24,21,22), +(1,2,4,25,22,25,22,23), +(1,2,5,26,22,26,23,24), +(1,2,6,28,23,27,23,25), +(1,2,7,29,24,28,24,25), +(1,2,8,30,24,29,25,26), +(1,2,9,31,25,30,25,27), +(1,2,10,32,25,32,26,27), +(1,2,11,33,26,33,27,28), +(1,2,12,35,27,34,27,29), +(1,2,13,36,27,35,28,30), +(1,2,14,37,28,36,29,31), +(1,2,15,38,29,37,30,31), +(1,2,16,40,29,38,30,32), +(1,2,17,41,30,40,31,33), +(1,2,18,42,31,41,32,34), +(1,2,19,43,31,42,33,35), +(1,2,20,45,32,43,33,35), +(1,2,21,46,33,45,34,36), +(1,2,22,47,33,46,35,37), +(1,2,23,49,34,47,36,38), +(1,2,24,50,35,48,37,39), +(1,2,25,51,36,50,37,40), +(1,2,26,53,36,51,38,41), +(1,2,27,54,37,52,39,42), +(1,2,28,56,38,54,40,43), +(1,2,29,57,39,55,41,43), +(1,2,30,58,39,56,42,44), +(1,2,31,60,40,58,43,45), +(1,2,32,61,41,59,43,46), +(1,2,33,63,42,60,44,47), +(1,2,34,64,43,62,45,48), +(1,2,35,66,44,63,46,49), +(1,2,36,67,44,65,47,50), +(1,2,37,69,45,66,48,51), +(1,2,38,70,46,67,49,52), +(1,2,39,72,47,69,50,53), +(1,2,40,73,48,70,51,54), +(1,2,41,75,49,72,52,55), +(1,2,42,77,49,73,53,56), +(1,2,43,78,50,75,54,57), +(1,2,44,80,51,76,55,58), +(1,2,45,81,52,78,56,59), +(1,2,46,83,53,79,57,61), +(1,2,47,85,54,81,58,62), +(1,2,48,86,55,83,59,63), +(1,2,49,88,56,84,60,64), +(1,2,50,90,57,86,61,65), +(1,2,51,91,58,87,62,66), +(1,2,52,93,59,89,63,67), +(1,2,53,95,60,91,64,68), +(1,2,54,97,61,92,65,69), +(1,2,55,98,61,94,66,71), +(1,2,56,100,62,95,67,72), +(1,2,57,102,63,97,68,73), +(1,2,58,104,64,99,69,74), +(1,2,59,105,65,101,70,75), +(1,2,60,107,66,102,71,77), +(1,2,61,109,67,104,73,78), +(1,2,62,111,69,106,74,79), +(1,2,63,113,70,107,75,80), +(1,2,64,115,71,109,76,81), +(1,2,65,116,72,111,77,83), +(1,2,66,118,73,113,78,84), +(1,2,67,120,74,115,79,85), +(1,2,68,122,75,116,81,86), +(1,2,69,124,76,118,82,88), +(1,2,70,126,77,120,83,89), +(1,4,1,21,23,21,20,20), +(1,4,2,22,24,22,20,20), +(1,4,3,23,26,22,20,21), +(1,4,4,23,27,23,20,21), +(1,4,5,24,29,24,21,21), +(1,4,6,25,30,25,21,22), +(1,4,7,26,32,25,21,22), +(1,4,8,26,33,26,21,23), +(1,4,9,27,35,27,21,23), +(1,4,10,28,36,27,21,23), +(1,4,11,29,38,28,22,24), +(1,4,12,30,39,29,22,24), +(1,4,13,31,41,30,22,25), +(1,4,14,31,43,31,22,25), +(1,4,15,32,44,31,22,25), +(1,4,16,33,46,32,23,26), +(1,4,17,34,48,33,23,26), +(1,4,18,35,49,34,23,27), +(1,4,19,36,51,35,23,27), +(1,4,20,37,53,35,23,28), +(1,4,21,38,54,36,24,28), +(1,4,22,39,56,37,24,29), +(1,4,23,40,58,38,24,29), +(1,4,24,41,60,39,24,30), +(1,4,25,42,61,40,25,30), +(1,4,26,43,63,41,25,31), +(1,4,27,44,65,42,25,31), +(1,4,28,45,67,43,25,32), +(1,4,29,46,69,43,25,32), +(1,4,30,47,71,44,26,33), +(1,4,31,48,72,45,26,33), +(1,4,32,49,74,46,26,34), +(1,4,33,50,76,47,27,34), +(1,4,34,51,78,48,27,35), +(1,4,35,52,80,49,27,35), +(1,4,36,53,82,50,27,36), +(1,4,37,54,84,51,28,36), +(1,4,38,55,86,52,28,37), +(1,4,39,56,88,53,28,38), +(1,4,40,57,90,54,28,38), +(1,4,41,58,92,55,29,39), +(1,4,42,60,94,56,29,39), +(1,4,43,61,96,57,29,40), +(1,4,44,62,98,58,30,40), +(1,4,45,63,100,59,30,41), +(1,4,46,64,103,61,30,42), +(1,4,47,65,105,62,31,42), +(1,4,48,66,107,63,31,43), +(1,4,49,68,109,64,31,44), +(1,4,50,69,111,65,32,44), +(1,4,51,70,113,66,32,45), +(1,4,52,71,116,67,32,45), +(1,4,53,73,118,68,33,46), +(1,4,54,74,120,69,33,47), +(1,4,55,75,122,71,33,47), +(1,4,56,76,125,72,34,48), +(1,4,57,78,127,73,34,49), +(1,4,58,79,129,74,34,49), +(1,4,59,80,131,75,35,50), +(1,4,60,81,134,77,35,51), +(1,4,61,83,136,78,35,51), +(1,4,62,84,138,79,36,52), +(1,4,63,85,141,80,36,53), +(1,4,64,87,143,81,37,54), +(1,4,65,88,146,83,37,54), +(1,4,66,89,148,84,37,55), +(1,4,67,91,151,85,38,56), +(1,4,68,92,153,86,38,57), +(1,4,69,94,156,88,39,57), +(1,4,70,95,158,89,39,58), +(1,5,1,20,20,20,22,23), +(1,5,2,20,20,20,23,24), +(1,5,3,20,20,21,25,26), +(1,5,4,20,21,21,26,27), +(1,5,5,21,21,21,27,28), +(1,5,6,21,21,22,29,30), +(1,5,7,21,21,22,30,31), +(1,5,8,21,22,23,31,33), +(1,5,9,21,22,23,33,34), +(1,5,10,21,22,23,34,36), +(1,5,11,22,22,24,36,37), +(1,5,12,22,23,24,37,39), +(1,5,13,22,23,25,38,40), +(1,5,14,22,23,25,40,42), +(1,5,15,22,23,25,41,43), +(1,5,16,23,24,26,43,45), +(1,5,17,23,24,26,44,46), +(1,5,18,23,24,27,46,48), +(1,5,19,23,24,27,47,49), +(1,5,20,23,25,28,49,51), +(1,5,21,24,25,28,51,53), +(1,5,22,24,25,29,52,54), +(1,5,23,24,26,29,54,56), +(1,5,24,24,26,30,55,58), +(1,5,25,25,26,30,57,59), +(1,5,26,25,27,31,59,61), +(1,5,27,25,27,31,60,63), +(1,5,28,25,27,32,62,65), +(1,5,29,25,28,32,64,66), +(1,5,30,26,28,33,65,68), +(1,5,31,26,28,33,67,70), +(1,5,32,26,29,34,69,72), +(1,5,33,27,29,34,70,73), +(1,5,34,27,29,35,72,75), +(1,5,35,27,30,35,74,77), +(1,5,36,27,30,36,76,79), +(1,5,37,28,30,36,78,81), +(1,5,38,28,31,37,79,83), +(1,5,39,28,31,38,81,85), +(1,5,40,28,31,38,83,87), +(1,5,41,29,32,39,85,88), +(1,5,42,29,32,39,87,90), +(1,5,43,29,33,40,89,92), +(1,5,44,30,33,40,91,94), +(1,5,45,30,33,41,92,96), +(1,5,46,30,34,42,94,98), +(1,5,47,31,34,42,96,100), +(1,5,48,31,35,43,98,102), +(1,5,49,31,35,44,100,104), +(1,5,50,32,36,44,102,106), +(1,5,51,32,36,45,104,109), +(1,5,52,32,36,45,106,111), +(1,5,53,33,37,46,108,113), +(1,5,54,33,37,47,110,115), +(1,5,55,33,38,47,112,117), +(1,5,56,34,38,48,114,119), +(1,5,57,34,39,49,117,121), +(1,5,58,34,39,49,119,124), +(1,5,59,35,40,50,121,126), +(1,5,60,35,40,51,123,128), +(1,5,61,35,41,51,125,130), +(1,5,62,36,41,52,127,132), +(1,5,63,36,41,53,129,135), +(1,5,64,37,42,54,132,137), +(1,5,65,37,42,54,134,139), +(1,5,66,37,43,55,136,142), +(1,5,67,38,43,56,138,144), +(1,5,68,38,44,57,140,146), +(1,5,69,39,44,57,143,149), +(1,5,70,39,45,58,145,151), +(1,8,1,20,20,20,23,22), +(1,8,2,20,20,20,24,23), +(1,8,3,20,20,21,26,25), +(1,8,4,20,20,21,27,26), +(1,8,5,20,21,21,28,27), +(1,8,6,20,21,21,30,29), +(1,8,7,21,21,22,31,30), +(1,8,8,21,21,22,33,31), +(1,8,9,21,21,22,34,33), +(1,8,10,21,21,23,36,34), +(1,8,11,21,22,23,37,36), +(1,8,12,21,22,23,39,37), +(1,8,13,21,22,24,40,38), +(1,8,14,21,22,24,42,40), +(1,8,15,21,22,24,43,41), +(1,8,16,21,23,25,45,43), +(1,8,17,22,23,25,46,44), +(1,8,18,22,23,25,48,46), +(1,8,19,22,23,26,49,47), +(1,8,20,22,23,26,51,49), +(1,8,21,22,24,26,53,51), +(1,8,22,22,24,27,54,52), +(1,8,23,22,24,27,56,54), +(1,8,24,23,24,28,58,55), +(1,8,25,23,25,28,59,57), +(1,8,26,23,25,28,61,59), +(1,8,27,23,25,29,63,60), +(1,8,28,23,25,29,65,62), +(1,8,29,23,25,30,66,64), +(1,8,30,24,26,30,68,65), +(1,8,31,24,26,30,70,67), +(1,8,32,24,26,31,72,69), +(1,8,33,24,27,31,73,70), +(1,8,34,24,27,32,75,72), +(1,8,35,24,27,32,77,74), +(1,8,36,25,27,33,79,76), +(1,8,37,25,28,33,81,78), +(1,8,38,25,28,34,83,79), +(1,8,39,25,28,34,85,81), +(1,8,40,25,28,35,87,83), +(1,8,41,26,29,35,88,85), +(1,8,42,26,29,35,90,87), +(1,8,43,26,29,36,92,89), +(1,8,44,26,30,36,94,91), +(1,8,45,26,30,37,96,92), +(1,8,46,27,30,37,98,94), +(1,8,47,27,31,38,100,96), +(1,8,48,27,31,38,102,98), +(1,8,49,27,31,39,104,100), +(1,8,50,28,32,40,106,102), +(1,8,51,28,32,40,109,104), +(1,8,52,28,32,41,111,106), +(1,8,53,28,33,41,113,108), +(1,8,54,29,33,42,115,110), +(1,8,55,29,33,42,117,112), +(1,8,56,29,34,43,119,114), +(1,8,57,29,34,43,121,117), +(1,8,58,30,34,44,124,119), +(1,8,59,30,35,44,126,121), +(1,8,60,30,35,45,128,123), +(1,8,61,30,35,46,130,125), +(1,8,62,31,36,46,132,127), +(1,8,63,31,36,47,135,129), +(1,8,64,31,37,47,137,132), +(1,8,65,32,37,48,139,134), +(1,8,66,32,37,49,142,136), +(1,8,67,32,38,49,144,138), +(1,8,68,32,38,50,146,140), +(1,8,69,33,39,50,149,143), +(1,8,70,33,39,51,151,145), +(1,9,1,20,20,21,22,22), +(1,9,2,20,20,22,23,23), +(1,9,3,21,21,22,24,24), +(1,9,4,21,21,23,26,25), +(1,9,5,21,21,23,27,27), +(1,9,6,21,22,24,28,28), +(1,9,7,22,22,24,29,29), +(1,9,8,22,23,25,30,30), +(1,9,9,22,23,26,32,31), +(1,9,10,23,23,26,33,33), +(1,9,11,23,24,27,34,34), +(1,9,12,23,24,27,35,35), +(1,9,13,24,25,28,37,36), +(1,9,14,24,25,29,38,38), +(1,9,15,24,25,29,39,39), +(1,9,16,25,26,30,41,40), +(1,9,17,25,26,31,42,42), +(1,9,18,25,27,31,43,43), +(1,9,19,26,27,32,45,44), +(1,9,20,26,28,33,46,46), +(1,9,21,26,28,33,48,47), +(1,9,22,27,29,34,49,49), +(1,9,23,27,29,35,51,50), +(1,9,24,28,30,35,52,51), +(1,9,25,28,30,36,53,53), +(1,9,26,28,31,37,55,54), +(1,9,27,29,31,37,56,56), +(1,9,28,29,32,38,58,57), +(1,9,29,30,32,39,59,59), +(1,9,30,30,33,40,61,60), +(1,9,31,30,33,40,62,62), +(1,9,32,31,34,41,64,63), +(1,9,33,31,34,42,66,65), +(1,9,34,32,35,43,67,66), +(1,9,35,32,35,44,69,68), +(1,9,36,33,36,44,70,69), +(1,9,37,33,36,45,72,71), +(1,9,38,34,37,46,74,73), +(1,9,39,34,38,47,75,74), +(1,9,40,35,38,48,77,76), +(1,9,41,35,39,48,79,78), +(1,9,42,35,39,49,80,79), +(1,9,43,36,40,50,82,81), +(1,9,44,36,40,51,84,83), +(1,9,45,37,41,52,85,84), +(1,9,46,37,42,53,87,86), +(1,9,47,38,42,54,89,88), +(1,9,48,38,43,55,91,89), +(1,9,49,39,44,55,93,91), +(1,9,50,40,44,56,94,93), +(1,9,51,40,45,57,96,95), +(1,9,52,41,45,58,98,97), +(1,9,53,41,46,59,100,98), +(1,9,54,42,47,60,102,100), +(1,9,55,42,47,61,103,102), +(1,9,56,43,48,62,105,104), +(1,9,57,43,49,63,107,106), +(1,9,58,44,49,64,109,108), +(1,9,59,44,50,65,111,109), +(1,9,60,45,51,66,113,111), +(1,9,61,46,51,67,115,113), +(1,9,62,46,52,68,117,115), +(1,9,63,47,53,69,119,117), +(1,9,64,47,54,70,121,119), +(1,9,65,48,54,71,123,121), +(1,9,66,49,55,72,125,123), +(1,9,67,49,56,73,127,125), +(1,9,68,50,57,74,129,127), +(1,9,69,50,57,75,131,129), +(1,9,70,51,58,76,133,131), +(2,1,1,26,17,24,17,23), +(2,1,2,27,18,25,17,23), +(2,1,3,29,19,26,17,24), +(2,1,4,30,19,27,17,24), +(2,1,5,31,20,29,17,24), +(2,1,6,32,21,30,17,24), +(2,1,7,34,22,31,18,25), +(2,1,8,35,23,32,18,25), +(2,1,9,37,24,34,18,25), +(2,1,10,38,24,35,18,26), +(2,1,11,39,25,36,18,26), +(2,1,12,41,26,37,18,26), +(2,1,13,42,27,39,18,27), +(2,1,14,44,28,40,18,27), +(2,1,15,45,29,41,18,27), +(2,1,16,47,30,43,19,28), +(2,1,17,48,31,44,19,28), +(2,1,18,50,32,45,19,28), +(2,1,19,51,33,47,19,29), +(2,1,20,53,34,48,19,29), +(2,1,21,54,34,50,19,29), +(2,1,22,56,35,51,19,30), +(2,1,23,57,36,52,20,30), +(2,1,24,59,37,54,20,30), +(2,1,25,60,38,55,20,31), +(2,1,26,62,39,57,20,31), +(2,1,27,64,40,58,20,32), +(2,1,28,65,41,60,20,32), +(2,1,29,67,43,61,21,32), +(2,1,30,69,44,63,21,33), +(2,1,31,70,45,64,21,33), +(2,1,32,72,46,66,21,34), +(2,1,33,74,47,67,21,34), +(2,1,34,76,48,69,21,35), +(2,1,35,77,49,71,22,35), +(2,1,36,79,50,72,22,36), +(2,1,37,81,51,74,22,36), +(2,1,38,83,52,76,22,36), +(2,1,39,84,53,77,22,37), +(2,1,40,86,55,79,23,37), +(2,1,41,88,56,81,23,38), +(2,1,42,90,57,82,23,38), +(2,1,43,92,58,84,23,39), +(2,1,44,94,59,86,23,39), +(2,1,45,96,60,87,24,40), +(2,1,46,98,62,89,24,40), +(2,1,47,100,63,91,24,41), +(2,1,48,101,64,93,24,41), +(2,1,49,103,65,94,25,42), +(2,1,50,105,66,96,25,42), +(2,1,51,107,68,98,25,43), +(2,1,52,109,69,100,25,43), +(2,1,53,111,70,102,25,44), +(2,1,54,113,71,104,26,45), +(2,1,55,115,73,105,26,45), +(2,1,56,118,74,107,26,46), +(2,1,57,120,75,109,26,46), +(2,1,58,122,77,111,27,47), +(2,1,59,124,78,113,27,47), +(2,1,60,126,79,115,27,48), +(2,1,61,128,81,117,27,48), +(2,1,62,130,82,119,28,49), +(2,1,63,132,83,121,28,50), +(2,1,64,135,85,123,28,50), +(2,1,65,137,86,125,29,51), +(2,1,66,139,87,127,29,52), +(2,1,67,141,89,129,29,52), +(2,1,68,143,90,131,29,53), +(2,1,69,146,92,133,30,53), +(2,1,70,148,93,135,30,54), +(2,3,1,23,20,23,17,24), +(2,3,2,23,21,24,18,25), +(2,3,3,24,23,25,18,25), +(2,3,4,24,24,26,19,26), +(2,3,5,25,25,27,19,26), +(2,3,6,25,27,28,20,27), +(2,3,7,26,28,28,21,28), +(2,3,8,26,30,29,21,28), +(2,3,9,26,31,30,22,29), +(2,3,10,27,33,31,22,30), +(2,3,11,27,34,32,23,30), +(2,3,12,28,36,33,24,31), +(2,3,13,28,37,34,24,32), +(2,3,14,29,39,35,25,33), +(2,3,15,29,40,36,26,33), +(2,3,16,30,42,37,26,34), +(2,3,17,30,43,39,27,35), +(2,3,18,31,45,40,28,35), +(2,3,19,31,47,41,28,36), +(2,3,20,32,48,42,29,37), +(2,3,21,32,50,43,30,38), +(2,3,22,33,51,44,31,39), +(2,3,23,34,53,45,31,39), +(2,3,24,34,55,46,32,40), +(2,3,25,35,57,47,33,41), +(2,3,26,35,58,48,34,42), +(2,3,27,36,60,50,34,43), +(2,3,28,36,62,51,35,43), +(2,3,29,37,63,52,36,44), +(2,3,30,38,65,53,37,45), +(2,3,31,38,67,54,37,46), +(2,3,32,39,69,56,38,47), +(2,3,33,39,71,57,39,48), +(2,3,34,40,72,58,40,49), +(2,3,35,41,74,59,41,49), +(2,3,36,41,76,61,42,50), +(2,3,37,42,78,62,42,51), +(2,3,38,43,80,63,43,52), +(2,3,39,43,82,64,44,53), +(2,3,40,44,84,66,45,54), +(2,3,41,45,86,67,46,55), +(2,3,42,45,88,68,47,56), +(2,3,43,46,90,70,47,57), +(2,3,44,47,91,71,48,58), +(2,3,45,47,93,72,49,59), +(2,3,46,48,95,74,50,60), +(2,3,47,49,98,75,51,61), +(2,3,48,50,100,77,52,62), +(2,3,49,50,102,78,53,63), +(2,3,50,51,104,79,54,64), +(2,3,51,52,106,81,55,65), +(2,3,52,52,108,82,56,66), +(2,3,53,53,110,84,57,67), +(2,3,54,54,112,85,58,68), +(2,3,55,55,114,87,59,69), +(2,3,56,55,116,88,60,70), +(2,3,57,56,118,90,61,71), +(2,3,58,57,121,91,62,72), +(2,3,59,58,123,93,63,73), +(2,3,60,59,125,94,64,74), +(2,3,61,59,127,96,65,76), +(2,3,62,60,130,97,66,77), +(2,3,63,61,132,99,67,78), +(2,3,64,62,134,100,68,79), +(2,3,65,63,136,102,69,80), +(2,3,66,64,139,104,70,81), +(2,3,67,64,141,105,71,82), +(2,3,68,65,143,107,72,84), +(2,3,69,66,146,108,73,85), +(2,3,70,67,148,110,74,86), +(2,4,1,24,20,23,17,23), +(2,4,2,25,21,24,17,23), +(2,4,3,25,23,24,17,24), +(2,4,4,26,24,25,17,24), +(2,4,5,27,26,26,18,24), +(2,4,6,28,27,26,18,25), +(2,4,7,29,29,27,18,25), +(2,4,8,29,30,28,18,26), +(2,4,9,30,32,29,18,26), +(2,4,10,31,33,29,19,26), +(2,4,11,32,35,30,19,27), +(2,4,12,33,37,31,19,27), +(2,4,13,34,38,32,19,28), +(2,4,14,34,40,32,19,28), +(2,4,15,35,41,33,19,28), +(2,4,16,36,43,34,20,29), +(2,4,17,37,45,35,20,29), +(2,4,18,38,46,36,20,30), +(2,4,19,39,48,37,20,30), +(2,4,20,40,50,37,21,31), +(2,4,21,41,52,38,21,31), +(2,4,22,42,53,39,21,31), +(2,4,23,43,55,40,21,32), +(2,4,24,43,57,41,21,32), +(2,4,25,44,59,42,22,33), +(2,4,26,45,60,43,22,33), +(2,4,27,46,62,44,22,34), +(2,4,28,47,64,44,22,34), +(2,4,29,48,66,45,23,35), +(2,4,30,49,68,46,23,35), +(2,4,31,50,70,47,23,36), +(2,4,32,51,72,48,23,36), +(2,4,33,53,73,49,24,37), +(2,4,34,54,75,50,24,38), +(2,4,35,55,77,51,24,38), +(2,4,36,56,79,52,24,39), +(2,4,37,57,81,53,25,39), +(2,4,38,58,83,54,25,40), +(2,4,39,59,85,55,25,40), +(2,4,40,60,87,56,26,41), +(2,4,41,61,89,57,26,41), +(2,4,42,62,91,58,26,42), +(2,4,43,63,93,59,27,43), +(2,4,44,65,95,60,27,43), +(2,4,45,66,98,61,27,44), +(2,4,46,67,100,62,27,44), +(2,4,47,68,102,64,28,45), +(2,4,48,69,104,65,28,46), +(2,4,49,71,106,66,28,46), +(2,4,50,72,108,67,29,47), +(2,4,51,73,110,68,29,48), +(2,4,52,74,113,69,29,48), +(2,4,53,75,115,70,30,49), +(2,4,54,77,117,71,30,50), +(2,4,55,78,119,73,30,50), +(2,4,56,79,122,74,31,51), +(2,4,57,80,124,75,31,52), +(2,4,58,82,126,76,31,52), +(2,4,59,83,129,77,32,53), +(2,4,60,84,131,78,32,54), +(2,4,61,86,133,80,33,54), +(2,4,62,87,136,81,33,55), +(2,4,63,88,138,82,33,56), +(2,4,64,90,140,83,34,57), +(2,4,65,91,143,85,34,57), +(2,4,66,92,145,86,34,58), +(2,4,67,94,148,87,35,59), +(2,4,68,95,150,88,35,59), +(2,4,69,97,153,90,36,60), +(2,4,70,98,155,91,36,61), +(2,7,1,24,17,23,18,25), +(2,7,2,25,17,24,19,26), +(2,7,3,26,18,25,20,27), +(2,7,4,26,18,26,21,28), +(2,7,5,27,19,27,22,29), +(2,7,6,28,19,28,23,30), +(2,7,7,29,20,29,24,31), +(2,7,8,30,20,30,25,32), +(2,7,9,31,21,31,26,33), +(2,7,10,32,21,32,27,34), +(2,7,11,33,22,33,28,36), +(2,7,12,34,22,34,29,37), +(2,7,13,34,23,35,30,38), +(2,7,14,35,23,36,31,39), +(2,7,15,36,24,37,32,40), +(2,7,16,37,24,39,33,41), +(2,7,17,38,25,40,34,43), +(2,7,18,39,25,41,35,44), +(2,7,19,40,26,42,36,45), +(2,7,20,41,26,43,37,46), +(2,7,21,42,27,44,38,47), +(2,7,22,43,27,45,39,49), +(2,7,23,44,28,47,40,50), +(2,7,24,45,28,48,41,51), +(2,7,25,47,29,49,43,52), +(2,7,26,48,30,50,44,54), +(2,7,27,49,30,52,45,55), +(2,7,28,50,31,53,46,56), +(2,7,29,51,31,54,47,58), +(2,7,30,52,32,55,48,59), +(2,7,31,53,33,57,50,60), +(2,7,32,54,33,58,51,62), +(2,7,33,55,34,59,52,63), +(2,7,34,57,34,61,53,65), +(2,7,35,58,35,62,55,66), +(2,7,36,59,36,63,56,67), +(2,7,37,60,36,65,57,69), +(2,7,38,61,37,66,58,70), +(2,7,39,62,38,67,60,72), +(2,7,40,64,38,69,61,73), +(2,7,41,65,39,70,62,75), +(2,7,42,66,40,72,64,76), +(2,7,43,67,40,73,65,78), +(2,7,44,69,41,74,66,79), +(2,7,45,70,42,76,68,81), +(2,7,46,71,42,77,69,82), +(2,7,47,72,43,79,70,84), +(2,7,48,74,44,80,72,85), +(2,7,49,75,45,82,73,87), +(2,7,50,76,45,83,75,89), +(2,7,51,78,46,85,76,90), +(2,7,52,79,47,86,77,92), +(2,7,53,80,47,88,79,93), +(2,7,54,82,48,90,80,95), +(2,7,55,83,49,91,82,97), +(2,7,56,85,50,93,83,98), +(2,7,57,86,50,94,85,100), +(2,7,58,87,51,96,86,102), +(2,7,59,89,52,97,88,103), +(2,7,60,90,53,99,89,105), +(2,7,61,92,54,101,91,107), +(2,7,62,93,54,102,92,109), +(2,7,63,95,55,104,94,110), +(2,7,64,96,56,106,95,112), +(2,7,65,97,57,107,97,114), +(2,7,66,99,58,109,99,116), +(2,7,67,100,58,111,100,118), +(2,7,68,102,59,113,102,119), +(2,7,69,103,60,114,103,121), +(2,7,70,105,61,116,105,123), +(2,9,1,23,17,23,19,25), +(2,9,2,23,17,24,20,26), +(2,9,3,24,18,24,21,27), +(2,9,4,24,18,25,23,28), +(2,9,5,24,18,25,24,30), +(2,9,6,24,19,26,25,31), +(2,9,7,25,19,26,26,32), +(2,9,8,25,20,27,27,33), +(2,9,9,25,20,27,29,34), +(2,9,10,26,20,28,30,36), +(2,9,11,26,21,29,31,37), +(2,9,12,26,21,29,33,38), +(2,9,13,27,22,30,34,39), +(2,9,14,27,22,31,35,41), +(2,9,15,27,23,31,37,42), +(2,9,16,28,23,32,38,43), +(2,9,17,28,23,32,39,45), +(2,9,18,28,24,33,41,46), +(2,9,19,29,24,34,42,47), +(2,9,20,29,25,34,43,49), +(2,9,21,29,25,35,45,50), +(2,9,22,30,26,36,46,51), +(2,9,23,30,26,37,48,53), +(2,9,24,30,27,37,49,54), +(2,9,25,31,27,38,51,56), +(2,9,26,31,28,39,52,57), +(2,9,27,32,28,39,54,59), +(2,9,28,32,29,40,55,60), +(2,9,29,32,29,41,57,62), +(2,9,30,33,30,42,58,63), +(2,9,31,33,30,42,60,65), +(2,9,32,34,31,43,61,66), +(2,9,33,34,31,44,63,68), +(2,9,34,35,32,45,64,69), +(2,9,35,35,32,45,66,71), +(2,9,36,36,33,46,68,72), +(2,9,37,36,34,47,69,74), +(2,9,38,36,34,48,71,76), +(2,9,39,37,35,49,72,77), +(2,9,40,37,35,50,74,79), +(2,9,41,38,36,50,76,80), +(2,9,42,38,36,51,77,82), +(2,9,43,39,37,52,79,84), +(2,9,44,39,38,53,81,85), +(2,9,45,40,38,54,83,87), +(2,9,46,40,39,55,84,89), +(2,9,47,41,39,56,86,91), +(2,9,48,41,40,56,88,92), +(2,9,49,42,41,57,90,94), +(2,9,50,42,41,58,91,96), +(2,9,51,43,42,59,93,98), +(2,9,52,43,43,60,95,99), +(2,9,53,44,43,61,97,101), +(2,9,54,45,44,62,99,103), +(2,9,55,45,45,63,101,105), +(2,9,56,46,45,64,102,107), +(2,9,57,46,46,65,104,109), +(2,9,58,47,47,66,106,110), +(2,9,59,47,47,67,108,112), +(2,9,60,48,48,68,110,114), +(2,9,61,48,49,69,112,116), +(2,9,62,49,49,70,114,118), +(2,9,63,50,50,71,116,120), +(2,9,64,50,51,72,118,122), +(2,9,65,51,51,73,120,124), +(2,9,66,52,52,74,122,126), +(2,9,67,52,53,75,124,128), +(2,9,68,53,54,76,126,130), +(2,9,69,53,54,77,128,132), +(2,9,70,54,55,78,130,134), +(3,1,1,25,16,25,19,19), +(3,1,2,26,17,26,19,19), +(3,1,3,28,18,27,19,20), +(3,1,4,29,18,28,19,20), +(3,1,5,30,19,30,19,20), +(3,1,6,31,20,31,19,20), +(3,1,7,33,21,32,20,21), +(3,1,8,34,22,33,20,21), +(3,1,9,36,23,35,20,21), +(3,1,10,37,23,36,20,22), +(3,1,11,38,24,37,20,22), +(3,1,12,40,25,38,20,22), +(3,1,13,41,26,40,20,23), +(3,1,14,43,27,41,20,23), +(3,1,15,44,28,42,20,23), +(3,1,16,46,29,44,21,24), +(3,1,17,47,30,45,21,24), +(3,1,18,49,31,46,21,24), +(3,1,19,50,32,48,21,25), +(3,1,20,52,33,49,21,25), +(3,1,21,53,34,51,21,26), +(3,1,22,55,34,52,21,26), +(3,1,23,56,35,53,21,26), +(3,1,24,58,36,55,22,27), +(3,1,25,59,37,56,22,27), +(3,1,26,61,38,58,22,27), +(3,1,27,63,39,59,22,28), +(3,1,28,64,41,61,22,28), +(3,1,29,66,42,62,22,29), +(3,1,30,68,43,64,23,29), +(3,1,31,69,44,65,23,30), +(3,1,32,71,45,67,23,30), +(3,1,33,73,46,68,23,30), +(3,1,34,75,47,70,23,31), +(3,1,35,76,48,72,24,31), +(3,1,36,78,49,73,24,32), +(3,1,37,80,50,75,24,32), +(3,1,38,82,51,76,24,33), +(3,1,39,84,52,78,24,33), +(3,1,40,85,54,80,24,34), +(3,1,41,87,55,81,25,34), +(3,1,42,89,56,83,25,35), +(3,1,43,91,57,85,25,35), +(3,1,44,93,58,87,25,36), +(3,1,45,95,59,88,26,36), +(3,1,46,97,61,90,26,37), +(3,1,47,99,62,92,26,37), +(3,1,48,101,63,94,26,38), +(3,1,49,102,64,95,26,38), +(3,1,50,104,65,97,27,39), +(3,1,51,106,67,99,27,39), +(3,1,52,108,68,101,27,40), +(3,1,53,110,69,103,27,40), +(3,1,54,112,70,104,28,41), +(3,1,55,115,72,106,28,41), +(3,1,56,117,73,108,28,42), +(3,1,57,119,74,110,28,42), +(3,1,58,121,76,112,29,43), +(3,1,59,123,77,114,29,43), +(3,1,60,125,78,116,29,44), +(3,1,61,127,80,118,29,45), +(3,1,62,129,81,120,30,45), +(3,1,63,131,82,122,30,46), +(3,1,64,134,84,124,30,46), +(3,1,65,136,85,126,31,47), +(3,1,66,138,86,128,31,48), +(3,1,67,140,88,130,31,48), +(3,1,68,142,89,132,31,49), +(3,1,69,145,91,134,32,49), +(3,1,70,147,92,136,32,50), +(3,2,1,24,16,25,19,20), +(3,2,2,25,17,26,20,21), +(3,2,3,26,17,27,20,21), +(3,2,4,27,18,28,21,22), +(3,2,5,28,18,29,22,23), +(3,2,6,29,19,30,22,24), +(3,2,7,31,20,31,23,24), +(3,2,8,32,20,32,24,25), +(3,2,9,33,21,33,24,26), +(3,2,10,34,21,34,25,26), +(3,2,11,35,22,36,26,27), +(3,2,12,36,23,37,26,28), +(3,2,13,38,23,38,27,29), +(3,2,14,39,24,39,28,30), +(3,2,15,40,25,40,29,30), +(3,2,16,41,25,41,29,31), +(3,2,17,43,26,43,30,32), +(3,2,18,44,27,44,31,33), +(3,2,19,45,28,45,32,34), +(3,2,20,47,28,46,32,35), +(3,2,21,48,29,47,33,35), +(3,2,22,49,30,49,34,36), +(3,2,23,51,30,50,35,37), +(3,2,24,52,31,51,36,38), +(3,2,25,53,32,52,36,39), +(3,2,26,55,33,54,37,40), +(3,2,27,56,33,55,38,41), +(3,2,28,57,34,56,39,42), +(3,2,29,59,35,58,40,43), +(3,2,30,60,36,59,41,43), +(3,2,31,62,37,60,42,44), +(3,2,32,63,37,62,42,45), +(3,2,33,65,38,63,43,46), +(3,2,34,66,39,65,44,47), +(3,2,35,68,40,66,45,48), +(3,2,36,69,41,67,46,49), +(3,2,37,71,41,69,47,50), +(3,2,38,72,42,70,48,51), +(3,2,39,74,43,72,49,52), +(3,2,40,75,44,73,50,53), +(3,2,41,77,45,75,51,54), +(3,2,42,78,46,76,52,55), +(3,2,43,80,47,78,53,56), +(3,2,44,82,47,79,54,57), +(3,2,45,83,48,81,55,59), +(3,2,46,85,49,82,56,60), +(3,2,47,87,50,84,57,61), +(3,2,48,88,51,85,58,62), +(3,2,49,90,52,87,59,63), +(3,2,50,92,53,89,60,64), +(3,2,51,93,54,90,61,65), +(3,2,52,95,55,92,62,66), +(3,2,53,97,56,93,63,67), +(3,2,54,98,57,95,64,69), +(3,2,55,100,58,97,65,70), +(3,2,56,102,59,98,66,71), +(3,2,57,104,60,100,67,72), +(3,2,58,106,61,102,68,73), +(3,2,59,107,62,103,69,74), +(3,2,60,109,63,105,70,76), +(3,2,61,111,64,107,72,77), +(3,2,62,113,65,109,73,78), +(3,2,63,115,66,110,74,79), +(3,2,64,117,67,112,75,80), +(3,2,65,118,68,114,76,82), +(3,2,66,120,69,116,77,83), +(3,2,67,122,70,118,78,84), +(3,2,68,124,71,119,80,85), +(3,2,69,126,72,121,81,87), +(3,2,70,128,73,123,82,88), +(3,3,1,22,19,24,19,20), +(3,3,2,22,20,25,20,21), +(3,3,3,23,22,26,20,21), +(3,3,4,23,23,27,21,22), +(3,3,5,24,25,28,21,23), +(3,3,6,24,26,29,22,23), +(3,3,7,25,27,29,23,24), +(3,3,8,25,29,30,23,25), +(3,3,9,25,30,31,24,25), +(3,3,10,26,32,32,24,26), +(3,3,11,26,33,33,25,27), +(3,3,12,27,35,34,26,27), +(3,3,13,27,36,35,26,28), +(3,3,14,28,38,36,27,29), +(3,3,15,28,39,37,28,29), +(3,3,16,29,41,38,28,30), +(3,3,17,29,42,39,29,31), +(3,3,18,30,44,41,30,32), +(3,3,19,30,46,42,30,32), +(3,3,20,31,47,43,31,33), +(3,3,21,32,49,44,32,34), +(3,3,22,32,51,45,33,35), +(3,3,23,33,52,46,33,36), +(3,3,24,33,54,47,34,36), +(3,3,25,34,56,48,35,37), +(3,3,26,34,57,49,35,38), +(3,3,27,35,59,51,36,39), +(3,3,28,35,61,52,37,40), +(3,3,29,36,63,53,38,40), +(3,3,30,37,64,54,39,41), +(3,3,31,37,66,55,39,42), +(3,3,32,38,68,57,40,43), +(3,3,33,38,70,58,41,44), +(3,3,34,39,71,59,42,45), +(3,3,35,40,73,60,43,46), +(3,3,36,40,75,62,43,47), +(3,3,37,41,77,63,44,47), +(3,3,38,42,79,64,45,48), +(3,3,39,42,81,65,46,49), +(3,3,40,43,83,67,47,50), +(3,3,41,44,85,68,48,51), +(3,3,42,44,87,69,49,52), +(3,3,43,45,89,71,49,53), +(3,3,44,46,91,72,50,54), +(3,3,45,46,93,73,51,55), +(3,3,46,47,95,75,52,56), +(3,3,47,48,97,76,53,57), +(3,3,48,49,99,78,54,58), +(3,3,49,49,101,79,55,59), +(3,3,50,50,103,80,56,60), +(3,3,51,51,105,82,57,61), +(3,3,52,51,107,83,58,62), +(3,3,53,52,109,85,59,63), +(3,3,54,53,111,86,60,64), +(3,3,55,54,113,88,61,65), +(3,3,56,55,115,89,62,66), +(3,3,57,55,118,91,62,67), +(3,3,58,56,120,92,63,68), +(3,3,59,57,122,94,64,70), +(3,3,60,58,124,95,65,71), +(3,3,61,58,126,97,67,72), +(3,3,62,59,129,98,68,73), +(3,3,63,60,131,100,69,74), +(3,3,64,61,133,101,70,75), +(3,3,65,62,135,103,71,76), +(3,3,66,63,138,105,72,77), +(3,3,67,63,140,106,73,78), +(3,3,68,64,142,108,74,80), +(3,3,69,65,145,109,75,81), +(3,3,70,66,147,111,76,82), +(3,4,1,23,19,24,19,19), +(3,4,2,24,20,25,19,19), +(3,4,3,24,22,25,19,20), +(3,4,4,25,23,26,19,20), +(3,4,5,26,25,27,20,20), +(3,4,6,27,26,27,20,21), +(3,4,7,28,28,28,20,21), +(3,4,8,28,29,29,20,22), +(3,4,9,29,31,30,20,22), +(3,4,10,30,32,30,20,22), +(3,4,11,31,34,31,21,23), +(3,4,12,32,36,32,21,23), +(3,4,13,33,37,33,21,24), +(3,4,14,33,39,33,21,24), +(3,4,15,34,40,34,21,25), +(3,4,16,35,42,35,22,25), +(3,4,17,36,44,36,22,25), +(3,4,18,37,45,37,22,26), +(3,4,19,38,47,38,22,26), +(3,4,20,39,49,38,22,27), +(3,4,21,40,51,39,23,27), +(3,4,22,41,52,40,23,28), +(3,4,23,42,54,41,23,28), +(3,4,24,43,56,42,23,29), +(3,4,25,44,58,43,24,29), +(3,4,26,44,59,44,24,30), +(3,4,27,45,61,44,24,30), +(3,4,28,46,63,45,24,31), +(3,4,29,47,65,46,25,31), +(3,4,30,48,67,47,25,32), +(3,4,31,49,69,48,25,32), +(3,4,32,51,71,49,25,33), +(3,4,33,52,72,50,26,33), +(3,4,34,53,74,51,26,34), +(3,4,35,54,76,52,26,34), +(3,4,36,55,78,53,26,35), +(3,4,37,56,80,54,27,35), +(3,4,38,57,82,55,27,36), +(3,4,39,58,84,56,27,37), +(3,4,40,59,86,57,28,37), +(3,4,41,60,88,58,28,38), +(3,4,42,61,90,59,28,38), +(3,4,43,63,92,60,28,39), +(3,4,44,64,95,61,29,39), +(3,4,45,65,97,62,29,40), +(3,4,46,66,99,63,29,41), +(3,4,47,67,101,64,30,41), +(3,4,48,68,103,66,30,42), +(3,4,49,70,105,67,30,43), +(3,4,50,71,107,68,31,43), +(3,4,51,72,110,69,31,44), +(3,4,52,73,112,70,31,44), +(3,4,53,74,114,71,32,45), +(3,4,54,76,116,72,32,46), +(3,4,55,77,118,73,32,46), +(3,4,56,78,121,75,33,47), +(3,4,57,80,123,76,33,48), +(3,4,58,81,125,77,33,48), +(3,4,59,82,128,78,34,49), +(3,4,60,83,130,79,34,50), +(3,4,61,85,132,81,34,51), +(3,4,62,86,135,82,35,51), +(3,4,63,87,137,83,35,52), +(3,4,64,89,139,84,36,53), +(3,4,65,90,142,86,36,53), +(3,4,66,91,144,87,36,54), +(3,4,67,93,147,88,37,55), +(3,4,68,94,149,89,37,56), +(3,4,69,96,152,91,38,56), +(3,4,70,97,154,92,38,57), +(3,5,1,22,16,23,21,22), +(3,5,2,22,16,23,22,23), +(3,5,3,22,16,24,24,25), +(3,5,4,22,17,24,25,26), +(3,5,5,23,17,24,26,27), +(3,5,6,23,17,25,28,29), +(3,5,7,23,17,25,29,30), +(3,5,8,23,18,26,30,32), +(3,5,9,23,18,26,32,33), +(3,5,10,23,18,26,33,35), +(3,5,11,24,18,27,35,36), +(3,5,12,24,19,27,36,38), +(3,5,13,24,19,28,37,39), +(3,5,14,24,19,28,39,41), +(3,5,15,24,19,28,40,42), +(3,5,16,24,20,29,42,44), +(3,5,17,25,20,29,43,45), +(3,5,18,25,20,30,45,47), +(3,5,19,25,21,30,46,49), +(3,5,20,25,21,31,48,50), +(3,5,21,25,21,31,50,52), +(3,5,22,26,22,31,51,53), +(3,5,23,26,22,32,53,55), +(3,5,24,26,22,32,54,57), +(3,5,25,26,22,33,56,58), +(3,5,26,27,23,33,58,60), +(3,5,27,27,23,34,59,62), +(3,5,28,27,23,34,61,64), +(3,5,29,27,24,35,63,65), +(3,5,30,28,24,35,64,67), +(3,5,31,28,24,36,66,69), +(3,5,32,28,25,36,68,71), +(3,5,33,28,25,37,70,72), +(3,5,34,29,26,38,71,74), +(3,5,35,29,26,38,73,76), +(3,5,36,29,26,39,75,78), +(3,5,37,29,27,39,77,80), +(3,5,38,30,27,40,78,82), +(3,5,39,30,27,40,80,84), +(3,5,40,30,28,41,82,86), +(3,5,41,31,28,41,84,88), +(3,5,42,31,29,42,86,89), +(3,5,43,31,29,43,88,91), +(3,5,44,32,29,43,90,93), +(3,5,45,32,30,44,92,95), +(3,5,46,32,30,44,93,97), +(3,5,47,32,30,45,95,99), +(3,5,48,33,31,46,97,101), +(3,5,49,33,31,46,99,103), +(3,5,50,33,32,47,101,106), +(3,5,51,34,32,48,103,108), +(3,5,52,34,33,48,105,110), +(3,5,53,35,33,49,107,112), +(3,5,54,35,33,50,109,114), +(3,5,55,35,34,50,111,116), +(3,5,56,36,34,51,113,118), +(3,5,57,36,35,52,116,120), +(3,5,58,36,35,52,118,123), +(3,5,59,37,36,53,120,125), +(3,5,60,37,36,54,122,127), +(3,5,61,37,37,54,124,129), +(3,5,62,38,37,55,126,131), +(3,5,63,38,38,56,128,134), +(3,5,64,39,38,57,131,136), +(3,5,65,39,39,57,133,138), +(3,5,66,39,39,58,135,141), +(3,5,67,40,40,59,137,143), +(3,5,68,40,40,59,139,145), +(3,5,69,41,40,60,142,148), +(3,5,70,41,41,61,144,150), +(4,1,1,20,25,21,20,20), +(4,1,2,21,26,22,20,20), +(4,1,3,23,27,23,20,21), +(4,1,4,24,27,25,20,21), +(4,1,5,25,28,26,20,21), +(4,1,6,27,29,27,20,21), +(4,1,7,28,30,28,21,22), +(4,1,8,29,31,29,21,22), +(4,1,9,31,31,31,21,22), +(4,1,10,32,32,32,21,23), +(4,1,11,33,33,33,21,23), +(4,1,12,35,34,34,21,23), +(4,1,13,36,35,36,21,24), +(4,1,14,38,36,37,21,24), +(4,1,15,39,37,38,21,24), +(4,1,16,41,37,40,21,25), +(4,1,17,42,38,41,22,25), +(4,1,18,44,39,43,22,25), +(4,1,19,45,40,44,22,26), +(4,1,20,47,41,45,22,26), +(4,1,21,48,42,47,22,26), +(4,1,22,50,43,48,22,27), +(4,1,23,52,44,50,22,27), +(4,1,24,53,45,51,23,28), +(4,1,25,55,46,52,23,28), +(4,1,26,56,47,54,23,28), +(4,1,27,58,48,55,23,29), +(4,1,28,60,49,57,23,29), +(4,1,29,61,50,58,23,30), +(4,1,30,63,51,60,24,30), +(4,1,31,65,52,62,24,30), +(4,1,32,66,53,63,24,31), +(4,1,33,68,54,65,24,31), +(4,1,34,70,55,66,24,32), +(4,1,35,72,56,68,24,32), +(4,1,36,73,58,69,25,33), +(4,1,37,75,59,71,25,33), +(4,1,38,77,60,73,25,34), +(4,1,39,79,61,74,25,34), +(4,1,40,81,62,76,25,35), +(4,1,41,82,63,78,26,35), +(4,1,42,84,64,79,26,35), +(4,1,43,86,66,81,26,36), +(4,1,44,88,67,83,26,36), +(4,1,45,90,68,85,26,37), +(4,1,46,92,69,86,27,37), +(4,1,47,94,70,88,27,38), +(4,1,48,96,72,90,27,38), +(4,1,49,98,73,92,27,39), +(4,1,50,100,74,93,28,40), +(4,1,51,102,75,95,28,40), +(4,1,52,104,77,97,28,41), +(4,1,53,106,78,99,28,41), +(4,1,54,108,79,101,29,42), +(4,1,55,110,80,103,29,42), +(4,1,56,112,82,104,29,43), +(4,1,57,114,83,106,29,43), +(4,1,58,116,84,108,30,44), +(4,1,59,118,86,110,30,44), +(4,1,60,120,87,112,30,45), +(4,1,61,122,88,114,30,46), +(4,1,62,124,90,116,31,46), +(4,1,63,127,91,118,31,47), +(4,1,64,129,92,120,31,47), +(4,1,65,131,94,122,32,48), +(4,1,66,133,95,124,32,49), +(4,1,67,135,97,126,32,49), +(4,1,68,138,98,128,32,50), +(4,1,69,140,100,130,33,50), +(4,1,70,142,101,132,33,51), +(4,3,1,17,28,20,20,21), +(4,3,2,17,29,21,21,22), +(4,3,3,18,31,22,21,22), +(4,3,4,18,32,23,22,23), +(4,3,5,19,33,24,22,24), +(4,3,6,19,35,25,23,24), +(4,3,7,20,36,26,24,25), +(4,3,8,20,38,27,24,25), +(4,3,9,21,39,27,25,26), +(4,3,10,21,40,28,25,27), +(4,3,11,22,42,29,26,28), +(4,3,12,22,43,30,27,28), +(4,3,13,23,45,31,27,29), +(4,3,14,23,46,32,28,30), +(4,3,15,24,48,34,29,30), +(4,3,16,24,50,35,29,31), +(4,3,17,25,51,36,30,32), +(4,3,18,25,53,37,31,33), +(4,3,19,26,54,38,31,33), +(4,3,20,26,56,39,32,34), +(4,3,21,27,57,40,33,35), +(4,3,22,27,59,41,33,36), +(4,3,23,28,61,42,34,36), +(4,3,24,28,62,43,35,37), +(4,3,25,29,64,44,36,38), +(4,3,26,30,66,46,36,39), +(4,3,27,30,68,47,37,40), +(4,3,28,31,69,48,38,41), +(4,3,29,31,71,49,39,41), +(4,3,30,32,73,50,39,42), +(4,3,31,33,75,52,40,43), +(4,3,32,33,76,53,41,44), +(4,3,33,34,78,54,42,45), +(4,3,34,34,80,55,43,46), +(4,3,35,35,82,57,44,47), +(4,3,36,36,84,58,44,48), +(4,3,37,36,86,59,45,48), +(4,3,38,37,87,60,46,49), +(4,3,39,38,89,62,47,50), +(4,3,40,38,91,63,48,51), +(4,3,41,39,93,64,49,52), +(4,3,42,40,95,66,49,53), +(4,3,43,40,97,67,50,54), +(4,3,44,41,99,68,51,55), +(4,3,45,42,101,70,52,56), +(4,3,46,42,103,71,53,57), +(4,3,47,43,105,72,54,58), +(4,3,48,44,107,74,55,59), +(4,3,49,45,109,75,56,60), +(4,3,50,45,111,77,57,61), +(4,3,51,46,113,78,58,62), +(4,3,52,47,115,79,59,63), +(4,3,53,47,118,81,60,64), +(4,3,54,48,120,82,61,65), +(4,3,55,49,122,84,61,66), +(4,3,56,50,124,85,62,67), +(4,3,57,50,126,87,63,68), +(4,3,58,51,128,88,64,69), +(4,3,59,52,131,90,65,70), +(4,3,60,53,133,91,66,72), +(4,3,61,54,135,93,67,73), +(4,3,62,54,137,94,69,74), +(4,3,63,55,140,96,70,75), +(4,3,64,56,142,97,71,76), +(4,3,65,57,144,99,72,77), +(4,3,66,58,147,101,73,78), +(4,3,67,58,149,102,74,79), +(4,3,68,59,151,104,75,81), +(4,3,69,60,154,105,76,82), +(4,3,70,61,156,107,77,83), +(4,4,1,18,28,20,20,20), +(4,4,2,19,29,21,20,20), +(4,4,3,20,31,21,20,21), +(4,4,4,20,32,22,20,21), +(4,4,5,21,34,23,21,21), +(4,4,6,22,35,24,21,22), +(4,4,7,23,37,24,21,22), +(4,4,8,24,38,25,21,23), +(4,4,9,24,40,26,21,23), +(4,4,10,25,41,26,21,23), +(4,4,11,26,43,27,22,24), +(4,4,12,27,44,28,22,24), +(4,4,13,28,46,29,22,25), +(4,4,14,29,48,30,22,25), +(4,4,15,29,49,30,22,25), +(4,4,16,30,51,31,23,26), +(4,4,17,31,52,32,23,26), +(4,4,18,32,54,33,23,27), +(4,4,19,33,56,34,23,27), +(4,4,20,34,57,35,23,28), +(4,4,21,35,59,35,24,28), +(4,4,22,36,61,36,24,29), +(4,4,23,37,63,37,24,29), +(4,4,24,38,64,38,24,30), +(4,4,25,39,66,39,25,30), +(4,4,26,40,68,40,25,31), +(4,4,27,41,70,41,25,31), +(4,4,28,42,72,42,25,32), +(4,4,29,43,73,43,25,32), +(4,4,30,44,75,43,26,33), +(4,4,31,45,77,44,26,33), +(4,4,32,46,79,45,26,34), +(4,4,33,47,81,46,27,34), +(4,4,34,48,83,47,27,35), +(4,4,35,49,85,48,27,35), +(4,4,36,50,87,49,27,36), +(4,4,37,51,89,50,28,36), +(4,4,38,52,91,51,28,37), +(4,4,39,53,93,52,28,38), +(4,4,40,54,95,53,28,38), +(4,4,41,56,97,54,29,39), +(4,4,42,57,99,55,29,39), +(4,4,43,58,101,56,29,40), +(4,4,44,59,103,57,30,40), +(4,4,45,60,105,59,30,41), +(4,4,46,61,107,60,30,42), +(4,4,47,62,109,61,31,42), +(4,4,48,64,112,62,31,43), +(4,4,49,65,114,63,31,44), +(4,4,50,66,116,64,32,44), +(4,4,51,67,118,65,32,45), +(4,4,52,68,120,66,32,45), +(4,4,53,70,123,67,33,46), +(4,4,54,71,125,69,33,47), +(4,4,55,72,127,70,33,47), +(4,4,56,73,129,71,34,48), +(4,4,57,75,132,72,34,49), +(4,4,58,76,134,73,34,49), +(4,4,59,77,136,74,35,50), +(4,4,60,79,139,76,35,51), +(4,4,61,80,141,77,35,51), +(4,4,62,81,143,78,36,52), +(4,4,63,82,146,79,36,53), +(4,4,64,84,148,80,37,54), +(4,4,65,85,151,82,37,54), +(4,4,66,87,153,83,37,55), +(4,4,67,88,156,84,38,56), +(4,4,68,89,158,85,38,57), +(4,4,69,91,160,87,39,57), +(4,4,70,92,163,88,39,58), +(4,5,1,17,25,19,22,23), +(4,5,2,17,25,19,23,24), +(4,5,3,17,25,20,25,26), +(4,5,4,17,26,20,26,27), +(4,5,5,18,26,20,27,28), +(4,5,6,18,26,21,29,30), +(4,5,7,18,26,21,30,31), +(4,5,8,18,26,22,31,33), +(4,5,9,18,27,22,33,34), +(4,5,10,19,27,22,34,36), +(4,5,11,19,27,23,36,37), +(4,5,12,19,27,23,37,39), +(4,5,13,19,28,24,38,40), +(4,5,14,19,28,24,40,42), +(4,5,15,19,28,25,41,43), +(4,5,16,20,28,25,43,45), +(4,5,17,20,29,25,44,46), +(4,5,18,20,29,26,46,48), +(4,5,19,20,29,26,47,49), +(4,5,20,21,30,27,49,51), +(4,5,21,21,30,27,51,53), +(4,5,22,21,30,28,52,54), +(4,5,23,21,30,28,54,56), +(4,5,24,21,31,29,55,58), +(4,5,25,22,31,29,57,59), +(4,5,26,22,31,30,59,61), +(4,5,27,22,32,30,60,63), +(4,5,28,22,32,31,62,65), +(4,5,29,23,32,31,64,66), +(4,5,30,23,33,32,65,68), +(4,5,31,23,33,32,67,70), +(4,5,32,23,33,33,69,72), +(4,5,33,24,34,33,70,73), +(4,5,34,24,34,34,72,75), +(4,5,35,24,34,34,74,77), +(4,5,36,24,35,35,76,79), +(4,5,37,25,35,35,78,81), +(4,5,38,25,35,36,79,83), +(4,5,39,25,36,37,81,85), +(4,5,40,26,36,37,83,87), +(4,5,41,26,37,38,85,88), +(4,5,42,26,37,38,87,90), +(4,5,43,27,37,39,89,92), +(4,5,44,27,38,39,91,94), +(4,5,45,27,38,40,92,96), +(4,5,46,27,39,41,94,98), +(4,5,47,28,39,41,96,100), +(4,5,48,28,39,42,98,102), +(4,5,49,28,40,43,100,104), +(4,5,50,29,40,43,102,106), +(4,5,51,29,41,44,104,109), +(4,5,52,29,41,44,106,111), +(4,5,53,30,42,45,108,113), +(4,5,54,30,42,46,110,115), +(4,5,55,30,43,46,112,117), +(4,5,56,31,43,47,114,119), +(4,5,57,31,43,48,117,121), +(4,5,58,31,44,48,119,124), +(4,5,59,32,44,49,121,126), +(4,5,60,32,45,50,123,128), +(4,5,61,33,45,51,125,130), +(4,5,62,33,46,51,127,132), +(4,5,63,33,46,52,129,135), +(4,5,64,34,47,53,132,137), +(4,5,65,34,47,53,134,139), +(4,5,66,34,48,54,136,142), +(4,5,67,35,48,55,138,144), +(4,5,68,35,49,56,140,146), +(4,5,69,36,49,56,143,149), +(4,5,70,36,50,57,145,151), +(4,11,1,18,25,19,22,22), +(4,11,2,19,25,20,23,23), +(4,11,3,19,26,20,24,24), +(4,11,4,20,26,21,25,26), +(4,11,5,20,27,22,26,27), +(4,11,6,21,27,22,27,28), +(4,11,7,21,28,23,28,29), +(4,11,8,22,28,24,29,30), +(4,11,9,23,29,24,30,32), +(4,11,10,23,29,25,32,33), +(4,11,11,24,30,26,33,34), +(4,11,12,24,31,26,34,35), +(4,11,13,25,31,27,35,37), +(4,11,14,26,32,28,36,38), +(4,11,15,26,32,29,37,39), +(4,11,16,27,33,29,38,41), +(4,11,17,28,33,30,40,42), +(4,11,18,28,34,31,41,43), +(4,11,19,29,35,32,42,45), +(4,11,20,30,35,32,43,46), +(4,11,21,30,36,33,45,48), +(4,11,22,31,36,34,46,49), +(4,11,23,32,37,35,47,51), +(4,11,24,32,38,36,48,52), +(4,11,25,33,38,36,50,53), +(4,11,26,34,39,37,51,55), +(4,11,27,35,40,38,52,56), +(4,11,28,35,40,39,54,58), +(4,11,29,36,41,40,55,59), +(4,11,30,37,42,41,56,61), +(4,11,31,38,42,42,58,62), +(4,11,32,38,43,42,59,64), +(4,11,33,39,44,43,60,66), +(4,11,34,40,44,44,62,67), +(4,11,35,41,45,45,63,69), +(4,11,36,42,46,46,65,70), +(4,11,37,42,47,47,66,72), +(4,11,38,43,47,48,67,74), +(4,11,39,44,48,49,69,75), +(4,11,40,45,49,50,70,77), +(4,11,41,46,50,51,72,79), +(4,11,42,46,50,52,73,80), +(4,11,43,47,51,53,75,82), +(4,11,44,48,52,54,76,84), +(4,11,45,49,53,55,78,85), +(4,11,46,50,54,56,79,87), +(4,11,47,51,54,57,81,89), +(4,11,48,52,55,58,83,91), +(4,11,49,53,56,59,84,93), +(4,11,50,53,57,60,86,94), +(4,11,51,54,58,61,87,96), +(4,11,52,55,59,62,89,98), +(4,11,53,56,59,63,91,100), +(4,11,54,57,60,64,92,102), +(4,11,55,58,61,65,94,103), +(4,11,56,59,62,66,95,105), +(4,11,57,60,63,67,97,107), +(4,11,58,61,64,68,99,109), +(4,11,59,62,65,69,101,111), +(4,11,60,63,66,70,102,113), +(4,11,61,64,66,72,104,115), +(4,11,62,65,67,73,106,117), +(4,11,63,66,68,74,107,119), +(4,11,64,67,69,75,109,121), +(4,11,65,68,70,76,111,123), +(4,11,66,69,71,77,113,125), +(4,11,67,70,72,78,115,127), +(4,11,68,71,73,80,116,129), +(4,11,69,72,74,81,118,131), +(4,11,70,73,75,82,120,133), +(5,1,1,22,18,23,18,25), +(5,1,2,23,19,24,18,25), +(5,1,3,25,20,25,18,26), +(5,1,4,26,20,26,18,26), +(5,1,5,27,21,28,18,26), +(5,1,6,29,22,29,18,26), +(5,1,7,30,23,30,19,27), +(5,1,8,31,24,31,19,27), +(5,1,9,33,25,33,19,27), +(5,1,10,34,25,34,19,28), +(5,1,11,35,26,35,19,28), +(5,1,12,37,27,36,19,28), +(5,1,13,38,28,38,19,28), +(5,1,14,40,29,39,19,29), +(5,1,15,41,30,40,19,29), +(5,1,16,43,31,42,20,29), +(5,1,17,44,32,43,20,30), +(5,1,18,46,33,44,20,30), +(5,1,19,47,34,46,20,31), +(5,1,20,49,34,47,20,31), +(5,1,21,50,35,49,20,31), +(5,1,22,52,36,50,20,32), +(5,1,23,53,37,51,21,32), +(5,1,24,55,38,53,21,32), +(5,1,25,57,39,54,21,33), +(5,1,26,58,40,56,21,33), +(5,1,27,60,41,57,21,34), +(5,1,28,62,42,59,21,34), +(5,1,29,63,43,60,21,34), +(5,1,30,65,44,62,22,35), +(5,1,31,67,46,63,22,35), +(5,1,32,68,47,65,22,36), +(5,1,33,70,48,67,22,36), +(5,1,34,72,49,68,22,36), +(5,1,35,74,50,70,23,37), +(5,1,36,75,51,71,23,37), +(5,1,37,77,52,73,23,38), +(5,1,38,79,53,75,23,38), +(5,1,39,81,54,76,23,39), +(5,1,40,83,55,78,24,39), +(5,1,41,84,57,80,24,40), +(5,1,42,86,58,81,24,40), +(5,1,43,88,59,83,24,41), +(5,1,44,90,60,85,24,41), +(5,1,45,92,61,86,25,42), +(5,1,46,94,62,88,25,42), +(5,1,47,96,64,90,25,43), +(5,1,48,98,65,92,25,43), +(5,1,49,100,66,93,25,44), +(5,1,50,102,67,95,26,44), +(5,1,51,104,69,97,26,45), +(5,1,52,106,70,99,26,45), +(5,1,53,108,71,101,26,46), +(5,1,54,110,72,103,27,46), +(5,1,55,112,74,104,27,47), +(5,1,56,114,75,106,27,48), +(5,1,57,116,76,108,27,48), +(5,1,58,118,78,110,28,49), +(5,1,59,120,79,112,28,49), +(5,1,60,122,80,114,28,50), +(5,1,61,124,82,116,28,50), +(5,1,62,126,83,118,29,51), +(5,1,63,128,84,120,29,52), +(5,1,64,131,86,122,29,52), +(5,1,65,133,87,124,30,53), +(5,1,66,135,88,126,30,53), +(5,1,67,137,90,128,30,54), +(5,1,68,139,91,130,30,55), +(5,1,69,142,93,132,31,55), +(5,1,70,144,94,134,31,56), +(5,4,1,20,21,22,18,25), +(5,4,2,21,22,23,18,25), +(5,4,3,22,24,23,18,26), +(5,4,4,22,25,24,18,26), +(5,4,5,23,27,25,19,26), +(5,4,6,24,28,25,19,27), +(5,4,7,25,30,26,19,27), +(5,4,8,25,31,27,19,27), +(5,4,9,26,33,28,19,28), +(5,4,10,27,34,28,19,28), +(5,4,11,28,36,29,20,29), +(5,4,12,29,38,30,20,29), +(5,4,13,30,39,31,20,29), +(5,4,14,31,41,32,20,30), +(5,4,15,31,42,32,20,30), +(5,4,16,32,44,33,21,31), +(5,4,17,33,46,34,21,31), +(5,4,18,34,47,35,21,32), +(5,4,19,35,49,36,21,32), +(5,4,20,36,51,36,21,32), +(5,4,21,37,52,37,22,33), +(5,4,22,38,54,38,22,33), +(5,4,23,39,56,39,22,34), +(5,4,24,40,58,40,22,34), +(5,4,25,41,60,41,23,35), +(5,4,26,42,61,42,23,35), +(5,4,27,43,63,43,23,36), +(5,4,28,44,65,44,23,36), +(5,4,29,45,67,44,24,37), +(5,4,30,46,69,45,24,37), +(5,4,31,47,71,46,24,38), +(5,4,32,48,72,47,24,38), +(5,4,33,49,74,48,25,39), +(5,4,34,50,76,49,25,39), +(5,4,35,51,78,50,25,40), +(5,4,36,52,80,51,25,41), +(5,4,37,53,82,52,26,41), +(5,4,38,54,84,53,26,42), +(5,4,39,55,86,54,26,42), +(5,4,40,56,88,55,27,43), +(5,4,41,57,90,56,27,43), +(5,4,42,59,92,57,27,44), +(5,4,43,60,94,58,27,45), +(5,4,44,61,96,59,28,45), +(5,4,45,62,99,60,28,46), +(5,4,46,63,101,61,28,46), +(5,4,47,64,103,63,29,47), +(5,4,48,66,105,64,29,48), +(5,4,49,67,107,65,29,48), +(5,4,50,68,109,66,30,49), +(5,4,51,69,111,67,30,50), +(5,4,52,70,114,68,30,50), +(5,4,53,72,116,69,31,51), +(5,4,54,73,118,70,31,52), +(5,4,55,74,120,72,31,52), +(5,4,56,75,123,73,32,53), +(5,4,57,77,125,74,32,54), +(5,4,58,78,127,75,32,54), +(5,4,59,79,130,76,33,55), +(5,4,60,81,132,77,33,56), +(5,4,61,82,134,79,34,56), +(5,4,62,83,137,80,34,57), +(5,4,63,84,139,81,34,58), +(5,4,64,86,141,82,35,59), +(5,4,65,87,144,84,35,59), +(5,4,66,88,146,85,35,60), +(5,4,67,90,149,86,36,61), +(5,4,68,91,151,87,36,61), +(5,4,69,93,154,89,37,62), +(5,4,70,94,156,90,37,63), +(5,5,1,19,18,21,20,28), +(5,5,2,19,18,21,21,29), +(5,5,3,19,18,22,23,31), +(5,5,4,19,19,22,24,32), +(5,5,5,20,19,22,25,33), +(5,5,6,20,19,23,27,35), +(5,5,7,20,19,23,28,36), +(5,5,8,20,20,24,29,38), +(5,5,9,20,20,24,31,39), +(5,5,10,20,20,24,32,40), +(5,5,11,21,20,25,34,42), +(5,5,12,21,21,25,35,43), +(5,5,13,21,21,26,37,45), +(5,5,14,21,21,26,38,46), +(5,5,15,21,21,26,39,48), +(5,5,16,22,22,27,41,50), +(5,5,17,22,22,27,42,51), +(5,5,18,22,22,28,44,53), +(5,5,19,22,23,28,46,54), +(5,5,20,22,23,29,47,56), +(5,5,21,23,23,29,49,57), +(5,5,22,23,23,30,50,59), +(5,5,23,23,24,30,52,61), +(5,5,24,23,24,31,53,62), +(5,5,25,24,24,31,55,64), +(5,5,26,24,25,32,57,66), +(5,5,27,24,25,32,58,68), +(5,5,28,24,25,33,60,69), +(5,5,29,25,26,33,62,71), +(5,5,30,25,26,34,63,73), +(5,5,31,25,26,34,65,75), +(5,5,32,25,27,35,67,76), +(5,5,33,26,27,35,69,78), +(5,5,34,26,27,36,70,80), +(5,5,35,26,28,36,72,82), +(5,5,36,26,28,37,74,84), +(5,5,37,27,28,37,76,86), +(5,5,38,27,29,38,77,87), +(5,5,39,27,29,38,79,89), +(5,5,40,28,30,39,81,91), +(5,5,41,28,30,40,83,93), +(5,5,42,28,30,40,85,95), +(5,5,43,28,31,41,87,97), +(5,5,44,29,31,41,89,99), +(5,5,45,29,32,42,91,101), +(5,5,46,29,32,43,92,103), +(5,5,47,30,32,43,94,105), +(5,5,48,30,33,44,96,107), +(5,5,49,30,33,44,98,109), +(5,5,50,31,34,45,100,111), +(5,5,51,31,34,46,102,113), +(5,5,52,31,35,46,104,115), +(5,5,53,32,35,47,106,118), +(5,5,54,32,35,48,108,120), +(5,5,55,32,36,48,110,122), +(5,5,56,33,36,49,113,124), +(5,5,57,33,37,50,115,126), +(5,5,58,33,37,50,117,128), +(5,5,59,34,38,51,119,131), +(5,5,60,34,38,52,121,133), +(5,5,61,34,39,52,123,135), +(5,5,62,35,39,53,125,137), +(5,5,63,35,40,54,127,140), +(5,5,64,36,40,55,130,142), +(5,5,65,36,41,55,132,144), +(5,5,66,36,41,56,134,147), +(5,5,67,37,41,57,136,149), +(5,5,68,37,42,58,138,151), +(5,5,69,38,42,58,141,154), +(5,5,70,38,43,59,143,156), +(5,8,1,19,18,21,21,27), +(5,8,2,19,18,21,22,28), +(5,8,3,19,18,22,24,30), +(5,8,4,19,18,22,25,31), +(5,8,5,19,19,22,26,32), +(5,8,6,19,19,22,28,34), +(5,8,7,20,19,23,29,35), +(5,8,8,20,19,23,31,36), +(5,8,9,20,19,23,32,38), +(5,8,10,20,19,24,34,39), +(5,8,11,20,20,24,35,40), +(5,8,12,20,20,24,37,42), +(5,8,13,20,20,25,38,43), +(5,8,14,20,20,25,40,45), +(5,8,15,20,20,25,41,46), +(5,8,16,21,21,26,43,48), +(5,8,17,21,21,26,44,49), +(5,8,18,21,21,26,46,51), +(5,8,19,21,21,27,48,52), +(5,8,20,21,21,27,49,54), +(5,8,21,21,22,27,51,55), +(5,8,22,21,22,28,52,57), +(5,8,23,21,22,28,54,58), +(5,8,24,22,22,29,56,60), +(5,8,25,22,23,29,57,62), +(5,8,26,22,23,29,59,63), +(5,8,27,22,23,30,61,65), +(5,8,28,22,23,30,63,67), +(5,8,29,22,24,31,64,68), +(5,8,30,23,24,31,66,70), +(5,8,31,23,24,31,68,72), +(5,8,32,23,24,32,70,73), +(5,8,33,23,25,32,72,75), +(5,8,34,23,25,33,73,77), +(5,8,35,24,25,33,75,79), +(5,8,36,24,25,34,77,80), +(5,8,37,24,26,34,79,82), +(5,8,38,24,26,35,81,84), +(5,8,39,24,26,35,83,86), +(5,8,40,24,27,35,85,88), +(5,8,41,25,27,36,87,90), +(5,8,42,25,27,36,89,91), +(5,8,43,25,27,37,90,93), +(5,8,44,25,28,37,92,95), +(5,8,45,26,28,38,94,97), +(5,8,46,26,28,38,96,99), +(5,8,47,26,29,39,98,101), +(5,8,48,26,29,39,100,103), +(5,8,49,26,29,40,103,105), +(5,8,50,27,30,40,105,107), +(5,8,51,27,30,41,107,109), +(5,8,52,27,30,42,109,111), +(5,8,53,27,31,42,111,113), +(5,8,54,28,31,43,113,115), +(5,8,55,28,31,43,115,117), +(5,8,56,28,32,44,117,119), +(5,8,57,28,32,44,119,121), +(5,8,58,29,32,45,122,123), +(5,8,59,29,33,45,124,126), +(5,8,60,29,33,46,126,128), +(5,8,61,29,34,47,128,130), +(5,8,62,30,34,47,131,132), +(5,8,63,30,34,48,133,134), +(5,8,64,30,35,48,135,136), +(5,8,65,31,35,49,137,139), +(5,8,66,31,35,50,140,141), +(5,8,67,31,36,50,142,143), +(5,8,68,31,36,51,144,145), +(5,8,69,32,37,51,147,148), +(5,8,70,32,37,52,149,150), +(5,9,1,19,18,22,20,27), +(5,9,2,19,18,23,21,28), +(5,9,3,20,19,23,22,29), +(5,9,4,20,19,24,24,30), +(5,9,5,20,19,24,25,32), +(5,9,6,20,20,25,26,33), +(5,9,7,21,20,25,27,34), +(5,9,8,21,21,26,28,35), +(5,9,9,21,21,26,30,36), +(5,9,10,22,21,27,31,38), +(5,9,11,22,22,28,32,39), +(5,9,12,22,22,28,34,40), +(5,9,13,23,23,29,35,41), +(5,9,14,23,23,30,36,43), +(5,9,15,23,24,30,37,44), +(5,9,16,24,24,31,39,45), +(5,9,17,24,24,31,40,47), +(5,9,18,24,25,32,42,48), +(5,9,19,25,25,33,43,49), +(5,9,20,25,26,33,44,51), +(5,9,21,26,26,34,46,52), +(5,9,22,26,27,35,47,53), +(5,9,23,26,27,36,49,55), +(5,9,24,27,28,36,50,56), +(5,9,25,27,28,37,52,58), +(5,9,26,27,29,38,53,59), +(5,9,27,28,29,38,55,60), +(5,9,28,28,30,39,56,62), +(5,9,29,29,30,40,58,63), +(5,9,30,29,31,41,59,65), +(5,9,31,30,31,41,61,66), +(5,9,32,30,32,42,62,68), +(5,9,33,30,32,43,64,69), +(5,9,34,31,33,44,65,71), +(5,9,35,31,33,45,67,73), +(5,9,36,32,34,45,69,74), +(5,9,37,32,34,46,70,76), +(5,9,38,33,35,47,72,77), +(5,9,39,33,36,48,73,79), +(5,9,40,34,36,49,75,81), +(5,9,41,34,37,49,77,82), +(5,9,42,35,37,50,78,84), +(5,9,43,35,38,51,80,86), +(5,9,44,36,39,52,82,87), +(5,9,45,36,39,53,84,89), +(5,9,46,37,40,54,85,91), +(5,9,47,37,40,55,87,92), +(5,9,48,38,41,55,89,94), +(5,9,49,38,42,56,91,96), +(5,9,50,39,42,57,92,98), +(5,9,51,39,43,58,94,100), +(5,9,52,40,44,59,96,101), +(5,9,53,40,44,60,98,103), +(5,9,54,41,45,61,100,105), +(5,9,55,41,45,62,102,107), +(5,9,56,42,46,63,103,109), +(5,9,57,42,47,64,105,111), +(5,9,58,43,47,65,107,112), +(5,9,59,43,48,66,109,114), +(5,9,60,44,49,67,111,116), +(5,9,61,45,50,68,113,118), +(5,9,62,45,50,69,115,120), +(5,9,63,46,51,70,117,122), +(5,9,64,46,52,71,119,124), +(5,9,65,47,52,72,121,126), +(5,9,66,48,53,73,123,128), +(5,9,67,48,54,74,125,130), +(5,9,68,49,55,75,127,132), +(5,9,69,49,55,76,129,134), +(5,9,70,50,56,77,131,136), +(6,1,1,28,15,24,15,22), +(6,1,2,29,16,25,15,22), +(6,1,3,31,17,26,15,23), +(6,1,4,32,17,27,15,23), +(6,1,5,33,18,29,15,23), +(6,1,6,34,19,30,15,23), +(6,1,7,36,20,31,16,24), +(6,1,8,37,21,32,16,24), +(6,1,9,38,22,34,16,24), +(6,1,10,40,22,35,16,25), +(6,1,11,41,23,36,16,25), +(6,1,12,43,24,37,16,25), +(6,1,13,44,25,39,16,26), +(6,1,14,46,26,40,16,26), +(6,1,15,47,27,41,17,26), +(6,1,16,48,28,43,17,27), +(6,1,17,50,29,44,17,27), +(6,1,18,51,30,45,17,27), +(6,1,19,53,31,47,17,28), +(6,1,20,54,32,48,17,28), +(6,1,21,56,33,50,17,28), +(6,1,22,58,34,51,18,29), +(6,1,23,59,35,52,18,29), +(6,1,24,61,36,54,18,30), +(6,1,25,62,37,55,18,30), +(6,1,26,64,38,57,18,30), +(6,1,27,66,39,58,18,31), +(6,1,28,67,40,60,18,31), +(6,1,29,69,41,61,19,32), +(6,1,30,71,42,63,19,32), +(6,1,31,72,43,64,19,32), +(6,1,32,74,44,66,19,33), +(6,1,33,76,45,67,19,33), +(6,1,34,77,46,69,20,34), +(6,1,35,79,47,71,20,34), +(6,1,36,81,48,72,20,35), +(6,1,37,83,49,74,20,35), +(6,1,38,85,50,76,20,35), +(6,1,39,86,51,77,21,36), +(6,1,40,88,53,79,21,36), +(6,1,41,90,54,81,21,37), +(6,1,42,92,55,82,21,37), +(6,1,43,94,56,84,21,38), +(6,1,44,96,57,86,22,38), +(6,1,45,98,58,87,22,39), +(6,1,46,99,60,89,22,39), +(6,1,47,101,61,91,22,40), +(6,1,48,103,62,93,22,40), +(6,1,49,105,63,94,23,41), +(6,1,50,107,65,96,23,41), +(6,1,51,109,66,98,23,42), +(6,1,52,111,67,100,23,42), +(6,1,53,113,68,102,24,43), +(6,1,54,115,70,104,24,44), +(6,1,55,117,71,105,24,44), +(6,1,56,119,72,107,24,45), +(6,1,57,122,73,109,25,45), +(6,1,58,124,75,111,25,46), +(6,1,59,126,76,113,25,46), +(6,1,60,128,77,115,25,47), +(6,1,61,130,79,117,26,48), +(6,1,62,132,80,119,26,48), +(6,1,63,134,81,121,26,49), +(6,1,64,137,83,123,26,49), +(6,1,65,139,84,125,27,50), +(6,1,66,141,85,127,27,51), +(6,1,67,143,87,129,27,51), +(6,1,68,145,88,131,27,52), +(6,1,69,148,90,133,28,52), +(6,1,70,150,91,135,28,53), +(6,3,1,25,18,23,15,23), +(6,3,2,25,19,24,16,24), +(6,3,3,26,21,25,16,24), +(6,3,4,26,22,26,17,25), +(6,3,5,27,24,27,17,25), +(6,3,6,27,25,28,18,26), +(6,3,7,28,26,28,19,27), +(6,3,8,28,28,29,19,27), +(6,3,9,28,29,30,20,28), +(6,3,10,29,31,31,20,29), +(6,3,11,29,32,32,21,29), +(6,3,12,30,34,33,22,30), +(6,3,13,30,35,34,22,31), +(6,3,14,31,37,35,23,32), +(6,3,15,31,38,36,24,32), +(6,3,16,32,40,37,24,33), +(6,3,17,32,41,39,25,34), +(6,3,18,33,43,40,26,35), +(6,3,19,33,45,41,27,35), +(6,3,20,34,46,42,27,36), +(6,3,21,34,48,43,28,37), +(6,3,22,35,50,44,29,38), +(6,3,23,35,51,45,29,38), +(6,3,24,36,53,46,30,39), +(6,3,25,37,55,47,31,40), +(6,3,26,37,56,48,32,41), +(6,3,27,38,58,50,32,42), +(6,3,28,38,60,51,33,42), +(6,3,29,39,62,52,34,43), +(6,3,30,39,63,53,35,44), +(6,3,31,40,65,54,36,45), +(6,3,32,41,67,56,36,46), +(6,3,33,41,69,57,37,47), +(6,3,34,42,71,58,38,48), +(6,3,35,43,72,59,39,48), +(6,3,36,43,74,61,40,49), +(6,3,37,44,76,62,40,50), +(6,3,38,45,78,63,41,51), +(6,3,39,45,80,64,42,52), +(6,3,40,46,82,66,43,53), +(6,3,41,47,84,67,44,54), +(6,3,42,47,86,68,45,55), +(6,3,43,48,88,70,46,56), +(6,3,44,49,90,71,46,57), +(6,3,45,49,92,72,47,58), +(6,3,46,50,94,74,48,59), +(6,3,47,51,96,75,49,60), +(6,3,48,51,98,77,50,61), +(6,3,49,52,100,78,51,62), +(6,3,50,53,102,79,52,63), +(6,3,51,54,104,81,53,64), +(6,3,52,54,106,82,54,65), +(6,3,53,55,108,84,55,66), +(6,3,54,56,110,85,56,67), +(6,3,55,57,112,87,57,68), +(6,3,56,57,114,88,58,69), +(6,3,57,58,117,90,59,70), +(6,3,58,59,119,91,60,71), +(6,3,59,60,121,93,61,72), +(6,3,60,61,123,94,62,74), +(6,3,61,61,125,96,63,75), +(6,3,62,62,128,97,64,76), +(6,3,63,63,130,99,65,77), +(6,3,64,64,132,100,66,78), +(6,3,65,65,134,102,67,79), +(6,3,66,66,137,104,68,80), +(6,3,67,66,139,105,69,81), +(6,3,68,67,141,107,70,83), +(6,3,69,68,144,108,71,84), +(6,3,70,69,146,110,72,85), +(6,7,1,26,15,23,16,24), +(6,7,2,27,15,24,17,25), +(6,7,3,28,16,25,18,26), +(6,7,4,28,16,26,19,27), +(6,7,5,29,17,27,20,28), +(6,7,6,30,17,28,21,29), +(6,7,7,31,18,29,22,30), +(6,7,8,32,18,30,23,31), +(6,7,9,33,19,31,24,32), +(6,7,10,34,19,32,25,33), +(6,7,11,35,20,33,26,35), +(6,7,12,35,20,34,27,36), +(6,7,13,36,21,35,28,37), +(6,7,14,37,21,36,29,38), +(6,7,15,38,22,37,30,39), +(6,7,16,39,22,39,31,40), +(6,7,17,40,23,40,32,42), +(6,7,18,41,23,41,33,43), +(6,7,19,42,24,42,34,44), +(6,7,20,43,24,43,35,45), +(6,7,21,44,25,44,36,46), +(6,7,22,45,25,45,37,48), +(6,7,23,46,26,47,38,49), +(6,7,24,47,27,48,40,50), +(6,7,25,48,27,49,41,51), +(6,7,26,49,28,50,42,53), +(6,7,27,51,28,52,43,54), +(6,7,28,52,29,53,44,55), +(6,7,29,53,29,54,45,57), +(6,7,30,54,30,55,47,58), +(6,7,31,55,31,57,48,59), +(6,7,32,56,31,58,49,61), +(6,7,33,57,32,59,50,62), +(6,7,34,58,33,61,51,64), +(6,7,35,60,33,62,53,65), +(6,7,36,61,34,63,54,66), +(6,7,37,62,34,65,55,68), +(6,7,38,63,35,66,57,69), +(6,7,39,64,36,67,58,71), +(6,7,40,66,36,69,59,72), +(6,7,41,67,37,70,60,74), +(6,7,42,68,38,72,62,75), +(6,7,43,69,38,73,63,77), +(6,7,44,70,39,74,64,78), +(6,7,45,72,40,76,66,80), +(6,7,46,73,41,77,67,81), +(6,7,47,74,41,79,69,83), +(6,7,48,76,42,80,70,84), +(6,7,49,77,43,82,71,86), +(6,7,50,78,43,83,73,88), +(6,7,51,80,44,85,74,89), +(6,7,52,81,45,86,76,91), +(6,7,53,82,46,88,77,92), +(6,7,54,84,46,90,78,94), +(6,7,55,85,47,91,80,96), +(6,7,56,86,48,93,81,97), +(6,7,57,88,49,94,83,99), +(6,7,58,89,49,96,84,101), +(6,7,59,91,50,97,86,102), +(6,7,60,92,51,99,87,104), +(6,7,61,94,52,101,89,106), +(6,7,62,95,52,102,90,108), +(6,7,63,96,53,104,92,109), +(6,7,64,98,54,106,93,111), +(6,7,65,99,55,107,95,113), +(6,7,66,101,56,109,97,115), +(6,7,67,102,57,111,98,117), +(6,7,68,104,57,113,100,118), +(6,7,69,105,58,114,101,120), +(6,7,70,107,59,116,103,122), +(6,11,1,26,15,22,17,24), +(6,11,2,27,16,23,18,25), +(6,11,3,27,16,23,19,26), +(6,11,4,28,17,24,20,27), +(6,11,5,28,17,25,21,29), +(6,11,6,29,18,25,22,30), +(6,11,7,29,18,26,23,31), +(6,11,8,30,19,27,24,32), +(6,11,9,30,19,27,26,34), +(6,11,10,31,20,28,27,35), +(6,11,11,32,20,29,28,36), +(6,11,12,32,21,29,29,37), +(6,11,13,33,21,30,30,39), +(6,11,14,33,22,31,31,40), +(6,11,15,34,23,32,32,41), +(6,11,16,35,23,32,34,43), +(6,11,17,35,24,33,35,44), +(6,11,18,36,24,34,36,45), +(6,11,19,37,25,35,37,47), +(6,11,20,37,26,35,39,48), +(6,11,21,38,26,36,40,50), +(6,11,22,39,27,37,41,51), +(6,11,23,39,28,38,42,52), +(6,11,24,40,28,39,44,54), +(6,11,25,41,29,39,45,55), +(6,11,26,41,30,40,46,57), +(6,11,27,42,30,41,47,58), +(6,11,28,43,31,42,49,60), +(6,11,29,44,32,43,50,61), +(6,11,30,44,32,44,52,63), +(6,11,31,45,33,44,53,64), +(6,11,32,46,34,45,54,66), +(6,11,33,47,34,46,56,67), +(6,11,34,47,35,47,57,69), +(6,11,35,48,36,48,58,71), +(6,11,36,49,36,49,60,72), +(6,11,37,50,37,50,61,74), +(6,11,38,51,38,51,63,76), +(6,11,39,52,39,52,64,77), +(6,11,40,52,39,53,66,79), +(6,11,41,53,40,54,67,81), +(6,11,42,54,41,55,69,82), +(6,11,43,55,42,56,70,84), +(6,11,44,56,43,57,72,86), +(6,11,45,57,43,57,73,87), +(6,11,46,57,44,58,75,89), +(6,11,47,58,45,60,76,91), +(6,11,48,59,46,61,78,93), +(6,11,49,60,47,62,79,94), +(6,11,50,61,47,63,81,96), +(6,11,51,62,48,64,83,98), +(6,11,52,63,49,65,84,100), +(6,11,53,64,50,66,86,102), +(6,11,54,65,51,67,87,104), +(6,11,55,66,51,68,89,105), +(6,11,56,67,52,69,91,107), +(6,11,57,68,53,70,92,109), +(6,11,58,69,54,71,94,111), +(6,11,59,70,55,72,96,113), +(6,11,60,71,56,73,97,115), +(6,11,61,72,57,74,99,117), +(6,11,62,73,58,76,101,119), +(6,11,63,74,59,77,103,121), +(6,11,64,75,59,78,104,123), +(6,11,65,76,60,79,106,125), +(6,11,66,77,61,80,108,127), +(6,11,67,78,62,81,110,129), +(6,11,68,79,63,83,111,131), +(6,11,69,80,64,84,113,133), +(6,11,70,81,65,85,115,135), +(7,1,1,18,23,21,24,20), +(7,1,2,19,24,22,24,20), +(7,1,3,21,25,23,24,21), +(7,1,4,22,25,25,24,21), +(7,1,5,23,26,26,24,21), +(7,1,6,25,27,27,24,21), +(7,1,7,26,28,28,24,22), +(7,1,8,27,29,29,25,22), +(7,1,9,29,29,31,25,22), +(7,1,10,30,30,32,25,23), +(7,1,11,32,31,33,25,23), +(7,1,12,33,32,34,25,23), +(7,1,13,34,33,36,25,24), +(7,1,14,36,34,37,25,24), +(7,1,15,37,35,38,25,24), +(7,1,16,39,36,40,25,25), +(7,1,17,40,36,41,25,25), +(7,1,18,42,37,43,26,25), +(7,1,19,43,38,44,26,26), +(7,1,20,45,39,45,26,26), +(7,1,21,47,40,47,26,26), +(7,1,22,48,41,48,26,27), +(7,1,23,50,42,50,26,27), +(7,1,24,51,43,51,26,28), +(7,1,25,53,44,52,27,28), +(7,1,26,55,45,54,27,28), +(7,1,27,56,46,55,27,29), +(7,1,28,58,47,57,27,29), +(7,1,29,59,48,58,27,30), +(7,1,30,61,49,60,27,30), +(7,1,31,63,50,62,27,30), +(7,1,32,65,51,63,28,31), +(7,1,33,66,52,65,28,31), +(7,1,34,68,53,66,28,32), +(7,1,35,70,55,68,28,32), +(7,1,36,72,56,69,28,33), +(7,1,37,73,57,71,29,33), +(7,1,38,75,58,73,29,34), +(7,1,39,77,59,74,29,34), +(7,1,40,79,60,76,29,35), +(7,1,41,81,61,78,29,35), +(7,1,42,82,62,79,30,35), +(7,1,43,84,64,81,30,36), +(7,1,44,86,65,83,30,36), +(7,1,45,88,66,85,30,37), +(7,1,46,90,67,86,30,37), +(7,1,47,92,68,88,31,38), +(7,1,48,94,70,90,31,38), +(7,1,49,96,71,92,31,39), +(7,1,50,98,72,93,31,40), +(7,1,51,100,73,95,32,40), +(7,1,52,102,75,97,32,41), +(7,1,53,104,76,99,32,41), +(7,1,54,106,77,101,32,42), +(7,1,55,108,78,103,33,42), +(7,1,56,110,80,104,33,43), +(7,1,57,112,81,106,33,43), +(7,1,58,114,82,108,33,44), +(7,1,59,116,84,110,34,44), +(7,1,60,118,85,112,34,45), +(7,1,61,120,86,114,34,46), +(7,1,62,122,88,116,35,46), +(7,1,63,125,89,118,35,47), +(7,1,64,127,91,120,35,47), +(7,1,65,129,92,122,35,48), +(7,1,66,131,93,124,36,49), +(7,1,67,133,95,126,36,49), +(7,1,68,136,96,128,36,50), +(7,1,69,138,98,130,37,50), +(7,1,70,140,99,132,37,51), +(7,4,1,16,26,20,24,20), +(7,4,2,17,27,21,24,20), +(7,4,3,18,29,21,24,21), +(7,4,4,18,30,22,24,21), +(7,4,5,19,32,23,25,21), +(7,4,6,20,33,24,25,22), +(7,4,7,21,35,24,25,22), +(7,4,8,22,36,25,25,23), +(7,4,9,22,38,26,25,23), +(7,4,10,23,39,26,25,23), +(7,4,11,24,41,27,25,24), +(7,4,12,25,42,28,26,24), +(7,4,13,26,44,29,26,25), +(7,4,14,27,46,30,26,25), +(7,4,15,28,47,30,26,25), +(7,4,16,28,49,31,26,26), +(7,4,17,29,50,32,27,26), +(7,4,18,30,52,33,27,27), +(7,4,19,31,54,34,27,27), +(7,4,20,32,56,35,27,28), +(7,4,21,33,57,35,27,28), +(7,4,22,34,59,36,28,29), +(7,4,23,35,61,37,28,29), +(7,4,24,36,62,38,28,30), +(7,4,25,37,64,39,28,30), +(7,4,26,38,66,40,29,31), +(7,4,27,39,68,41,29,31), +(7,4,28,40,70,42,29,32), +(7,4,29,41,72,43,29,32), +(7,4,30,42,73,43,29,33), +(7,4,31,43,75,44,30,33), +(7,4,32,44,77,45,30,34), +(7,4,33,45,79,46,30,34), +(7,4,34,46,81,47,31,35), +(7,4,35,47,83,48,31,35), +(7,4,36,48,85,49,31,36), +(7,4,37,49,87,50,31,36), +(7,4,38,50,89,51,32,37), +(7,4,39,51,91,52,32,38), +(7,4,40,53,93,53,32,38), +(7,4,41,54,95,54,33,39), +(7,4,42,55,97,55,33,39), +(7,4,43,56,99,56,33,40), +(7,4,44,57,101,57,33,40), +(7,4,45,58,103,59,34,41), +(7,4,46,59,105,60,34,42), +(7,4,47,61,107,61,34,42), +(7,4,48,62,110,62,35,43), +(7,4,49,63,112,63,35,44), +(7,4,50,64,114,64,35,44), +(7,4,51,65,116,65,36,45), +(7,4,52,67,118,66,36,45), +(7,4,53,68,121,67,36,46), +(7,4,54,69,123,69,37,47), +(7,4,55,70,125,70,37,47), +(7,4,56,72,127,71,37,48), +(7,4,57,73,130,72,38,49), +(7,4,58,74,132,73,38,49), +(7,4,59,75,134,74,39,50), +(7,4,60,77,137,76,39,51), +(7,4,61,78,139,77,39,51), +(7,4,62,79,141,78,40,52), +(7,4,63,81,144,79,40,53), +(7,4,64,82,146,80,41,54), +(7,4,65,83,149,82,41,54), +(7,4,66,85,151,83,41,55), +(7,4,67,86,154,84,42,56), +(7,4,68,87,156,85,42,57), +(7,4,69,89,158,87,43,57), +(7,4,70,90,161,88,43,58), +(7,8,1,15,23,19,27,22), +(7,8,2,15,23,19,28,23), +(7,8,3,15,23,20,30,25), +(7,8,4,15,23,20,31,26), +(7,8,5,15,24,20,32,27), +(7,8,6,15,24,20,34,29), +(7,8,7,16,24,21,35,30), +(7,8,8,16,24,21,37,31), +(7,8,9,16,24,21,38,33), +(7,8,10,16,24,22,40,34), +(7,8,11,16,25,22,41,36), +(7,8,12,16,25,22,42,37), +(7,8,13,16,25,23,44,38), +(7,8,14,16,25,23,45,40), +(7,8,15,17,25,23,47,41), +(7,8,16,17,25,24,49,43), +(7,8,17,17,26,24,50,44), +(7,8,18,17,26,24,52,46), +(7,8,19,17,26,25,53,47), +(7,8,20,17,26,25,55,49), +(7,8,21,17,26,26,57,51), +(7,8,22,18,27,26,58,52), +(7,8,23,18,27,26,60,54), +(7,8,24,18,27,27,61,55), +(7,8,25,18,27,27,63,57), +(7,8,26,18,28,27,65,59), +(7,8,27,18,28,28,67,60), +(7,8,28,18,28,28,68,62), +(7,8,29,19,28,29,70,64), +(7,8,30,19,29,29,72,65), +(7,8,31,19,29,30,74,67), +(7,8,32,19,29,30,75,69), +(7,8,33,19,29,30,77,70), +(7,8,34,20,30,31,79,72), +(7,8,35,20,30,31,81,74), +(7,8,36,20,30,32,83,76), +(7,8,37,20,30,32,85,78), +(7,8,38,20,31,33,86,79), +(7,8,39,21,31,33,88,81), +(7,8,40,21,31,34,90,83), +(7,8,41,21,32,34,92,85), +(7,8,42,21,32,35,94,87), +(7,8,43,21,32,35,96,89), +(7,8,44,22,32,36,98,91), +(7,8,45,22,33,36,100,92), +(7,8,46,22,33,37,102,94), +(7,8,47,22,33,37,104,96), +(7,8,48,22,34,38,106,98), +(7,8,49,23,34,38,108,100), +(7,8,50,23,34,39,110,102), +(7,8,51,23,35,39,112,104), +(7,8,52,23,35,40,114,106), +(7,8,53,24,35,40,117,108), +(7,8,54,24,36,41,119,110), +(7,8,55,24,36,41,121,112), +(7,8,56,24,37,42,123,114), +(7,8,57,25,37,42,125,117), +(7,8,58,25,37,43,127,119), +(7,8,59,25,38,43,130,121), +(7,8,60,25,38,44,132,123), +(7,8,61,26,38,45,134,125), +(7,8,62,26,39,45,136,127), +(7,8,63,26,39,46,139,129), +(7,8,64,26,40,46,141,132), +(7,8,65,27,40,47,143,134), +(7,8,66,27,40,48,146,136), +(7,8,67,27,41,48,148,138), +(7,8,68,27,41,49,150,140), +(7,8,69,28,42,49,153,143), +(7,8,70,28,42,50,155,145), +(7,9,1,15,23,20,26,22), +(7,9,2,15,23,21,27,23), +(7,9,3,16,24,21,28,24), +(7,9,4,16,24,22,29,25), +(7,9,5,16,24,22,31,27), +(7,9,6,17,25,23,32,28), +(7,9,7,17,25,23,33,29), +(7,9,8,17,26,24,34,30), +(7,9,9,17,26,25,36,31), +(7,9,10,18,26,25,37,33), +(7,9,11,18,27,26,38,34), +(7,9,12,18,27,26,39,35), +(7,9,13,19,28,27,41,36), +(7,9,14,19,28,28,42,38), +(7,9,15,20,28,28,43,39), +(7,9,16,20,29,29,45,40), +(7,9,17,20,29,30,46,42), +(7,9,18,21,30,30,47,43), +(7,9,19,21,30,31,49,44), +(7,9,20,21,31,32,50,46), +(7,9,21,22,31,32,51,47), +(7,9,22,22,31,33,53,49), +(7,9,23,23,32,34,54,50), +(7,9,24,23,32,34,56,51), +(7,9,25,23,33,35,57,53), +(7,9,26,24,33,36,59,54), +(7,9,27,24,34,37,60,56), +(7,9,28,25,34,37,62,57), +(7,9,29,25,35,38,63,59), +(7,9,30,25,35,39,65,60), +(7,9,31,26,36,40,66,62), +(7,9,32,26,36,40,68,63), +(7,9,33,27,37,41,69,65), +(7,9,34,27,38,42,71,66), +(7,9,35,28,38,43,73,68), +(7,9,36,28,39,43,74,69), +(7,9,37,28,39,44,76,71), +(7,9,38,29,40,45,77,73), +(7,9,39,29,40,46,79,74), +(7,9,40,30,41,47,81,76), +(7,9,41,30,41,48,82,78), +(7,9,42,31,42,48,84,79), +(7,9,43,31,43,49,86,81), +(7,9,44,32,43,50,88,83), +(7,9,45,32,44,51,89,84), +(7,9,46,33,44,52,91,86), +(7,9,47,33,45,53,93,88), +(7,9,48,34,46,54,95,89), +(7,9,49,34,46,54,96,91), +(7,9,50,35,47,55,98,93), +(7,9,51,35,48,56,100,95), +(7,9,52,36,48,57,102,97), +(7,9,53,36,49,58,104,98), +(7,9,54,37,50,59,105,100), +(7,9,55,37,50,60,107,102), +(7,9,56,38,51,61,109,104), +(7,9,57,38,52,62,111,106), +(7,9,58,39,52,63,113,108), +(7,9,59,40,53,64,115,109), +(7,9,60,40,54,65,117,111), +(7,9,61,41,54,66,119,113), +(7,9,62,41,55,67,121,115), +(7,9,63,42,56,68,123,117), +(7,9,64,42,57,69,125,119), +(7,9,65,43,57,70,127,121), +(7,9,66,44,58,71,129,123), +(7,9,67,44,59,72,131,125), +(7,9,68,45,59,73,133,127), +(7,9,69,45,60,74,135,129), +(7,9,70,46,61,75,137,131), +(8,1,1,24,22,23,16,21), +(8,1,2,25,23,24,16,21), +(8,1,3,27,24,25,16,22), +(8,1,4,28,24,26,16,22), +(8,1,5,29,25,28,16,22), +(8,1,6,31,26,29,16,22), +(8,1,7,32,27,30,17,23), +(8,1,8,33,28,31,17,23), +(8,1,9,35,28,33,17,23), +(8,1,10,36,29,34,17,24), +(8,1,11,37,30,35,17,24), +(8,1,12,39,31,36,17,24), +(8,1,13,40,32,38,17,25), +(8,1,14,42,33,39,17,25), +(8,1,15,43,34,40,18,25), +(8,1,16,45,35,42,18,26), +(8,1,17,46,35,43,18,26), +(8,1,18,48,36,44,18,26), +(8,1,19,49,37,46,18,27), +(8,1,20,51,38,47,18,27), +(8,1,21,52,39,49,18,27), +(8,1,22,54,40,50,18,28), +(8,1,23,55,41,51,19,28), +(8,1,24,57,42,53,19,29), +(8,1,25,59,43,54,19,29), +(8,1,26,60,44,56,19,29), +(8,1,27,62,45,57,19,30), +(8,1,28,63,46,59,19,30), +(8,1,29,65,47,60,20,31), +(8,1,30,67,48,62,20,31), +(8,1,31,69,49,63,20,31), +(8,1,32,70,50,65,20,32), +(8,1,33,72,51,67,20,32), +(8,1,34,74,53,68,20,33), +(8,1,35,75,54,70,21,33), +(8,1,36,77,55,71,21,34), +(8,1,37,79,56,73,21,34), +(8,1,38,81,57,75,21,35), +(8,1,39,83,58,76,21,35), +(8,1,40,84,59,78,22,35), +(8,1,41,86,60,80,22,36), +(8,1,42,88,62,81,22,36), +(8,1,43,90,63,83,22,37), +(8,1,44,92,64,85,22,37), +(8,1,45,94,65,86,23,38), +(8,1,46,96,66,88,23,38), +(8,1,47,98,67,90,23,39), +(8,1,48,100,69,92,23,39), +(8,1,49,102,70,93,24,40), +(8,1,50,103,71,95,24,40), +(8,1,51,105,72,97,24,41), +(8,1,52,107,74,99,24,42), +(8,1,53,109,75,101,25,42), +(8,1,54,112,76,103,25,43), +(8,1,55,114,78,104,25,43), +(8,1,56,116,79,106,25,44), +(8,1,57,118,80,108,25,44), +(8,1,58,120,81,110,26,45), +(8,1,59,122,83,112,26,45), +(8,1,60,124,84,114,26,46), +(8,1,61,126,85,116,27,47), +(8,1,62,128,87,118,27,47), +(8,1,63,130,88,120,27,48), +(8,1,64,133,90,122,27,48), +(8,1,65,135,91,124,28,49), +(8,1,66,137,92,126,28,50), +(8,1,67,139,94,128,28,50), +(8,1,68,141,95,130,28,51), +(8,1,69,144,97,132,29,51), +(8,1,70,146,98,134,29,52), +(8,3,1,21,25,22,16,22), +(8,3,2,21,26,23,17,23), +(8,3,3,22,28,24,17,23), +(8,3,4,22,29,25,18,24), +(8,3,5,23,30,26,18,25), +(8,3,6,23,32,27,19,25), +(8,3,7,24,33,28,20,26), +(8,3,8,24,35,28,20,26), +(8,3,9,25,36,29,21,27), +(8,3,10,25,38,30,21,28), +(8,3,11,25,39,31,22,29), +(8,3,12,26,41,32,23,29), +(8,3,13,26,42,33,23,30), +(8,3,14,27,44,34,24,31), +(8,3,15,27,45,35,25,31), +(8,3,16,28,47,36,25,32), +(8,3,17,28,48,38,26,33), +(8,3,18,29,50,39,27,34), +(8,3,19,29,51,40,28,34), +(8,3,20,30,53,41,28,35), +(8,3,21,31,55,42,29,36), +(8,3,22,31,56,43,30,37), +(8,3,23,32,58,44,30,37), +(8,3,24,32,60,45,31,38), +(8,3,25,33,61,46,32,39), +(8,3,26,33,63,48,33,40), +(8,3,27,34,65,49,33,41), +(8,3,28,35,66,50,34,41), +(8,3,29,35,68,51,35,42), +(8,3,30,36,70,52,36,43), +(8,3,31,36,72,53,37,44), +(8,3,32,37,73,55,37,45), +(8,3,33,38,75,56,38,46), +(8,3,34,38,77,57,39,47), +(8,3,35,39,79,58,40,48), +(8,3,36,39,81,60,41,48), +(8,3,37,40,83,61,41,49), +(8,3,38,41,85,62,42,50), +(8,3,39,41,86,63,43,51), +(8,3,40,42,88,65,44,52), +(8,3,41,43,90,66,45,53), +(8,3,42,43,92,67,46,54), +(8,3,43,44,94,69,47,55), +(8,3,44,45,96,70,47,56), +(8,3,45,45,98,71,48,57), +(8,3,46,46,100,73,49,58), +(8,3,47,47,102,74,50,59), +(8,3,48,48,104,76,51,60), +(8,3,49,48,106,77,52,61), +(8,3,50,49,108,78,53,62), +(8,3,51,50,110,80,54,63), +(8,3,52,51,113,81,55,64), +(8,3,53,51,115,83,56,65), +(8,3,54,52,117,84,57,66), +(8,3,55,53,119,86,58,67), +(8,3,56,54,121,87,59,68), +(8,3,57,54,123,89,60,69), +(8,3,58,55,126,90,61,70), +(8,3,59,56,128,92,62,71), +(8,3,60,57,130,93,63,73), +(8,3,61,58,132,95,64,74), +(8,3,62,58,134,96,65,75), +(8,3,63,59,137,98,66,76), +(8,3,64,60,139,99,67,77), +(8,3,65,61,141,101,68,78), +(8,3,66,62,144,103,69,79), +(8,3,67,62,146,104,70,80), +(8,3,68,63,148,106,71,82), +(8,3,69,64,151,107,72,83), +(8,3,70,65,153,109,73,84), +(8,4,1,22,25,22,16,21), +(8,4,2,23,26,23,16,21), +(8,4,3,24,28,23,16,22), +(8,4,4,24,29,24,16,22), +(8,4,5,25,31,25,17,22), +(8,4,6,26,32,25,17,23), +(8,4,7,27,34,26,17,23), +(8,4,8,27,35,27,17,24), +(8,4,9,28,37,28,17,24), +(8,4,10,29,38,28,18,24), +(8,4,11,30,40,29,18,25), +(8,4,12,31,41,30,18,25), +(8,4,13,32,43,31,18,26), +(8,4,14,32,45,32,18,26), +(8,4,15,33,46,32,19,26), +(8,4,16,34,48,33,19,27), +(8,4,17,35,50,34,19,27), +(8,4,18,36,51,35,19,28), +(8,4,19,37,53,36,19,28), +(8,4,20,38,55,36,20,29), +(8,4,21,39,56,37,20,29), +(8,4,22,40,58,38,20,30), +(8,4,23,41,60,39,20,30), +(8,4,24,42,62,40,20,31), +(8,4,25,43,63,41,21,31), +(8,4,26,44,65,42,21,32), +(8,4,27,45,67,43,21,32), +(8,4,28,46,69,44,21,33), +(8,4,29,47,71,44,22,33), +(8,4,30,48,72,45,22,34), +(8,4,31,49,74,46,22,34), +(8,4,32,50,76,47,22,35), +(8,4,33,51,78,48,23,35), +(8,4,34,52,80,49,23,36), +(8,4,35,53,82,50,23,36), +(8,4,36,54,84,51,24,37), +(8,4,37,55,86,52,24,37), +(8,4,38,56,88,53,24,38), +(8,4,39,57,90,54,24,38), +(8,4,40,58,92,55,25,39), +(8,4,41,59,94,56,25,40), +(8,4,42,60,96,57,25,40), +(8,4,43,62,98,58,26,41), +(8,4,44,63,100,59,26,41), +(8,4,45,64,102,60,26,42), +(8,4,46,65,104,61,27,43), +(8,4,47,66,107,63,27,43), +(8,4,48,67,109,64,27,44), +(8,4,49,69,111,65,27,44), +(8,4,50,70,113,66,28,45), +(8,4,51,71,115,67,28,46), +(8,4,52,72,117,68,28,46), +(8,4,53,74,120,69,29,47), +(8,4,54,75,122,70,29,48), +(8,4,55,76,124,72,29,48), +(8,4,56,77,126,73,30,49), +(8,4,57,79,129,74,30,50), +(8,4,58,80,131,75,30,50), +(8,4,59,81,133,76,31,51), +(8,4,60,82,136,77,31,52), +(8,4,61,84,138,79,32,52), +(8,4,62,85,140,80,32,53), +(8,4,63,86,143,81,32,54), +(8,4,64,88,145,82,33,55), +(8,4,65,89,148,84,33,55), +(8,4,66,90,150,85,33,56), +(8,4,67,92,153,86,34,57), +(8,4,68,93,155,87,34,58), +(8,4,69,95,157,89,35,58), +(8,4,70,96,160,90,35,59), +(8,5,1,21,22,21,18,24), +(8,5,2,21,22,21,19,25), +(8,5,3,21,22,22,21,27), +(8,5,4,21,23,22,22,28), +(8,5,5,22,23,22,23,29), +(8,5,6,22,23,23,25,31), +(8,5,7,22,23,23,26,32), +(8,5,8,22,24,24,27,34), +(8,5,9,22,24,24,29,35), +(8,5,10,22,24,24,30,37), +(8,5,11,23,24,25,32,38), +(8,5,12,23,24,25,33,40), +(8,5,13,23,25,26,35,41), +(8,5,14,23,25,26,36,43), +(8,5,15,23,25,26,38,44), +(8,5,16,24,26,27,39,46), +(8,5,17,24,26,27,41,47), +(8,5,18,24,26,28,42,49), +(8,5,19,24,26,28,44,50), +(8,5,20,24,27,29,45,52), +(8,5,21,25,27,29,47,54), +(8,5,22,25,27,30,48,55), +(8,5,23,25,28,30,50,57), +(8,5,24,25,28,31,52,59), +(8,5,25,25,28,31,53,60), +(8,5,26,26,28,32,55,62), +(8,5,27,26,29,32,56,64), +(8,5,28,26,29,33,58,65), +(8,5,29,26,29,33,60,67), +(8,5,30,27,30,34,62,69), +(8,5,31,27,30,34,63,71), +(8,5,32,27,30,35,65,73), +(8,5,33,27,31,35,67,74), +(8,5,34,28,31,36,68,76), +(8,5,35,28,32,36,70,78), +(8,5,36,28,32,37,72,80), +(8,5,37,29,32,37,74,82), +(8,5,38,29,33,38,76,84), +(8,5,39,29,33,38,77,86), +(8,5,40,29,33,39,79,87), +(8,5,41,30,34,40,81,89), +(8,5,42,30,34,40,83,91), +(8,5,43,30,35,41,85,93), +(8,5,44,31,35,41,87,95), +(8,5,45,31,35,42,89,97), +(8,5,46,31,36,43,91,99), +(8,5,47,32,36,43,93,101), +(8,5,48,32,37,44,94,103), +(8,5,49,32,37,44,96,105), +(8,5,50,33,37,45,98,107), +(8,5,51,33,38,46,100,110), +(8,5,52,33,38,46,102,112), +(8,5,53,34,39,47,104,114), +(8,5,54,34,39,48,106,116), +(8,5,55,34,40,48,109,118), +(8,5,56,35,40,49,111,120), +(8,5,57,35,41,50,113,122), +(8,5,58,35,41,50,115,125), +(8,5,59,36,42,51,117,127), +(8,5,60,36,42,52,119,129), +(8,5,61,36,42,52,121,131), +(8,5,62,37,43,53,123,133), +(8,5,63,37,43,54,125,136), +(8,5,64,38,44,55,128,138), +(8,5,65,38,44,55,130,140), +(8,5,66,38,45,56,132,143), +(8,5,67,39,45,57,134,145), +(8,5,68,39,46,58,136,147), +(8,5,69,40,46,58,139,150), +(8,5,70,40,47,59,141,152), +(8,7,1,22,22,22,17,23), +(8,7,2,23,22,23,18,24), +(8,7,3,24,23,24,19,25), +(8,7,4,25,23,25,20,26), +(8,7,5,25,24,26,21,27), +(8,7,6,26,24,27,22,28), +(8,7,7,27,25,28,23,29), +(8,7,8,28,25,29,24,30), +(8,7,9,29,25,30,25,31), +(8,7,10,30,26,31,26,33), +(8,7,11,31,26,32,27,34), +(8,7,12,32,27,33,28,35), +(8,7,13,33,27,34,29,36), +(8,7,14,34,28,35,30,37), +(8,7,15,34,28,36,31,38), +(8,7,16,35,29,38,32,39), +(8,7,17,36,29,39,33,41), +(8,7,18,37,30,40,34,42), +(8,7,19,38,30,41,35,43), +(8,7,20,39,31,42,36,44), +(8,7,21,40,32,43,37,45), +(8,7,22,41,32,45,38,47), +(8,7,23,43,33,46,39,48), +(8,7,24,44,33,47,40,49), +(8,7,25,45,34,48,42,51), +(8,7,26,46,34,49,43,52), +(8,7,27,47,35,51,44,53), +(8,7,28,48,35,52,45,54), +(8,7,29,49,36,53,46,56), +(8,7,30,50,37,54,48,57), +(8,7,31,51,37,56,49,59), +(8,7,32,52,38,57,50,60), +(8,7,33,53,38,58,51,61), +(8,7,34,55,39,60,52,63), +(8,7,35,56,40,61,54,64), +(8,7,36,57,40,62,55,66), +(8,7,37,58,41,64,56,67), +(8,7,38,59,42,65,57,68), +(8,7,39,61,42,66,59,70), +(8,7,40,62,43,68,60,71), +(8,7,41,63,44,69,61,73), +(8,7,42,64,44,71,63,74), +(8,7,43,65,45,72,64,76), +(8,7,44,67,46,74,65,77), +(8,7,45,68,46,75,67,79), +(8,7,46,69,47,76,68,80), +(8,7,47,71,48,78,69,82), +(8,7,48,72,49,79,71,83), +(8,7,49,73,49,81,72,85), +(8,7,50,74,50,82,74,87), +(8,7,51,76,51,84,75,88), +(8,7,52,77,51,85,77,90), +(8,7,53,78,52,87,78,92), +(8,7,54,80,53,89,79,93), +(8,7,55,81,54,90,81,95), +(8,7,56,83,55,92,82,96), +(8,7,57,84,55,93,84,98), +(8,7,58,85,56,95,85,100), +(8,7,59,87,57,97,87,102), +(8,7,60,88,58,98,88,103), +(8,7,61,90,58,100,90,105), +(8,7,62,91,59,101,91,107), +(8,7,63,93,60,103,93,108), +(8,7,64,94,61,105,94,110), +(8,7,65,95,62,106,96,112), +(8,7,66,97,63,108,98,114), +(8,7,67,98,63,110,99,116), +(8,7,68,100,64,112,101,117), +(8,7,69,101,65,113,102,119), +(8,7,70,103,66,115,104,121), +(8,8,1,21,22,21,19,23), +(8,8,2,21,22,21,20,24), +(8,8,3,21,22,22,22,26), +(8,8,4,21,22,22,23,27), +(8,8,5,21,23,22,25,28), +(8,8,6,21,23,22,26,30), +(8,8,7,21,23,23,27,31), +(8,8,8,22,23,23,29,32), +(8,8,9,22,23,23,30,34), +(8,8,10,22,23,24,32,35), +(8,8,11,22,24,24,33,37), +(8,8,12,22,24,24,35,38), +(8,8,13,22,24,25,36,39), +(8,8,14,22,24,25,38,41), +(8,8,15,22,24,25,39,42), +(8,8,16,22,24,26,41,44), +(8,8,17,23,25,26,42,45), +(8,8,18,23,25,26,44,47), +(8,8,19,23,25,27,46,48), +(8,8,20,23,25,27,47,50), +(8,8,21,23,25,27,49,51), +(8,8,22,23,26,28,51,53), +(8,8,23,23,26,28,52,55), +(8,8,24,24,26,29,54,56), +(8,8,25,24,26,29,56,58), +(8,8,26,24,27,29,57,60), +(8,8,27,24,27,30,59,61), +(8,8,28,24,27,30,61,63), +(8,8,29,24,27,31,63,65), +(8,8,30,24,28,31,64,66), +(8,8,31,25,28,31,66,68), +(8,8,32,25,28,32,68,70), +(8,8,33,25,28,32,70,71), +(8,8,34,25,29,33,71,73), +(8,8,35,25,29,33,73,75), +(8,8,36,26,29,34,75,77), +(8,8,37,26,29,34,77,79), +(8,8,38,26,30,35,79,80), +(8,8,39,26,30,35,81,82), +(8,8,40,26,30,35,83,84), +(8,8,41,27,31,36,85,86), +(8,8,42,27,31,36,87,88), +(8,8,43,27,31,37,89,90), +(8,8,44,27,32,37,91,91), +(8,8,45,27,32,38,93,93), +(8,8,46,28,32,38,95,95), +(8,8,47,28,32,39,97,97), +(8,8,48,28,33,39,99,99), +(8,8,49,28,33,40,101,101), +(8,8,50,29,33,40,103,103), +(8,8,51,29,34,41,105,105), +(8,8,52,29,34,42,107,107), +(8,8,53,29,35,42,109,109), +(8,8,54,30,35,43,111,111), +(8,8,55,30,35,43,113,113), +(8,8,56,30,36,44,115,115), +(8,8,57,30,36,44,118,118), +(8,8,58,31,36,45,120,120), +(8,8,59,31,37,45,122,122), +(8,8,60,31,37,46,124,124), +(8,8,61,31,37,47,126,126), +(8,8,62,32,38,47,129,128), +(8,8,63,32,38,48,131,130), +(8,8,64,32,39,48,133,133), +(8,8,65,33,39,49,135,135), +(8,8,66,33,39,50,138,137), +(8,8,67,33,40,50,140,139), +(8,8,68,33,40,51,142,141), +(8,8,69,34,41,51,145,144), +(8,8,70,34,41,52,147,146), +(10,2,1,19,22,21,24,20), +(10,2,2,20,23,22,25,21), +(10,2,3,21,23,23,25,21), +(10,2,4,22,24,24,26,22), +(10,2,5,23,24,25,27,23), +(10,2,6,25,25,26,27,24), +(10,2,7,26,25,27,28,24), +(10,2,8,27,26,28,29,25), +(10,2,9,28,27,29,29,26), +(10,2,10,29,27,31,30,26), +(10,2,11,30,28,32,31,27), +(10,2,12,32,29,33,31,28), +(10,2,13,33,29,34,32,29), +(10,2,14,34,30,35,33,30), +(10,2,15,35,31,36,33,30), +(10,2,16,37,31,37,34,31), +(10,2,17,38,32,39,35,32), +(10,2,18,39,33,40,36,33), +(10,2,19,40,33,41,36,34), +(10,2,20,42,34,42,37,35), +(10,2,21,43,35,44,38,35), +(10,2,22,44,35,45,39,36), +(10,2,23,46,36,46,40,37), +(10,2,24,47,37,47,40,38), +(10,2,25,49,38,49,41,39), +(10,2,26,50,38,50,42,40), +(10,2,27,51,39,51,43,41), +(10,2,28,53,40,53,44,42), +(10,2,29,54,41,54,45,43), +(10,2,30,56,41,55,45,43), +(10,2,31,57,42,57,46,44), +(10,2,32,58,43,58,47,45), +(10,2,33,60,44,59,48,46), +(10,2,34,61,45,61,49,47), +(10,2,35,63,45,62,50,48), +(10,2,36,64,46,64,51,49), +(10,2,37,66,47,65,52,50), +(10,2,38,67,48,67,53,51), +(10,2,39,69,49,68,54,52), +(10,2,40,71,50,69,55,53), +(10,2,41,72,50,71,55,54), +(10,2,42,74,51,72,56,55), +(10,2,43,75,52,74,57,56), +(10,2,44,77,53,75,58,57), +(10,2,45,79,54,77,59,59), +(10,2,46,80,55,78,60,60), +(10,2,47,82,56,80,61,61), +(10,2,48,83,57,82,62,62), +(10,2,49,85,58,83,63,63), +(10,2,50,87,59,85,64,64), +(10,2,51,89,60,86,66,65), +(10,2,52,90,61,88,67,66), +(10,2,53,92,61,90,68,67), +(10,2,54,94,62,91,69,69), +(10,2,55,95,63,93,70,70), +(10,2,56,97,64,95,71,71), +(10,2,57,99,65,96,72,72), +(10,2,58,101,66,98,73,73), +(10,2,59,102,67,100,74,74), +(10,2,60,104,68,101,75,76), +(10,2,61,106,69,103,76,77), +(10,2,62,108,70,105,78,78), +(10,2,63,110,72,106,79,79), +(10,2,64,112,73,108,80,80), +(10,2,65,113,74,110,81,82), +(10,2,66,115,75,112,82,83), +(10,2,67,117,76,114,83,84), +(10,2,68,119,77,115,85,85), +(10,2,69,121,78,117,86,87), +(10,2,70,123,79,119,87,88), +(10,3,1,17,25,20,24,20), +(10,3,2,17,26,21,25,21), +(10,3,3,18,28,22,25,21), +(10,3,4,18,29,23,26,22), +(10,3,5,19,30,24,26,23), +(10,3,6,19,32,25,27,23), +(10,3,7,20,33,26,27,24), +(10,3,8,20,35,27,28,25), +(10,3,9,21,36,27,29,25), +(10,3,10,21,38,28,29,26), +(10,3,11,22,39,29,30,27), +(10,3,12,22,41,30,31,27), +(10,3,13,23,42,31,31,28), +(10,3,14,23,44,32,32,29), +(10,3,15,24,45,34,32,29), +(10,3,16,24,47,35,33,30), +(10,3,17,25,48,36,34,31), +(10,3,18,25,50,37,34,32), +(10,3,19,26,51,38,35,32), +(10,3,20,26,53,39,36,33), +(10,3,21,27,55,40,37,34), +(10,3,22,27,56,41,37,35), +(10,3,23,28,58,42,38,36), +(10,3,24,28,60,43,39,36), +(10,3,25,29,61,44,39,37), +(10,3,26,30,63,46,40,38), +(10,3,27,30,65,47,41,39), +(10,3,28,31,66,48,42,40), +(10,3,29,31,68,49,42,40), +(10,3,30,32,70,50,43,41), +(10,3,31,33,72,52,44,42), +(10,3,32,33,73,53,45,43), +(10,3,33,34,75,54,46,44), +(10,3,34,34,77,55,46,45), +(10,3,35,35,79,57,47,46), +(10,3,36,36,81,58,48,47), +(10,3,37,36,83,59,49,47), +(10,3,38,37,85,60,50,48), +(10,3,39,38,86,62,51,49), +(10,3,40,38,88,63,51,50), +(10,3,41,39,90,64,52,51), +(10,3,42,40,92,66,53,52), +(10,3,43,40,94,67,54,53), +(10,3,44,41,96,68,55,54), +(10,3,45,42,98,70,56,55), +(10,3,46,42,100,71,57,56), +(10,3,47,43,102,72,58,57), +(10,3,48,44,104,74,59,58), +(10,3,49,45,106,75,60,59), +(10,3,50,45,108,77,61,60), +(10,3,51,46,110,78,61,61), +(10,3,52,47,113,79,62,62), +(10,3,53,47,115,81,63,63), +(10,3,54,48,117,82,64,64), +(10,3,55,49,119,84,65,65), +(10,3,56,50,121,85,66,66), +(10,3,57,50,123,87,67,67), +(10,3,58,51,126,88,68,68), +(10,3,59,52,128,90,69,70), +(10,3,60,53,130,91,70,71), +(10,3,61,54,132,93,71,72), +(10,3,62,54,134,94,72,73), +(10,3,63,55,137,96,73,74), +(10,3,64,56,139,97,75,75), +(10,3,65,57,141,99,76,76), +(10,3,66,58,144,101,77,77), +(10,3,67,58,146,102,78,78), +(10,3,68,59,148,104,79,80), +(10,3,69,60,151,105,80,81), +(10,3,70,61,153,107,81,82), +(10,4,1,18,25,20,24,19), +(10,4,2,19,26,21,24,19), +(10,4,3,20,28,21,24,20), +(10,4,4,20,29,22,24,20), +(10,4,5,21,31,23,25,20), +(10,4,6,22,32,24,25,21), +(10,4,7,23,34,24,25,21), +(10,4,8,24,35,25,25,22), +(10,4,9,24,37,26,25,22), +(10,4,10,25,38,26,25,22), +(10,4,11,26,40,27,25,23), +(10,4,12,27,41,28,26,23), +(10,4,13,28,43,29,26,24), +(10,4,14,29,45,30,26,24), +(10,4,15,29,46,30,26,25), +(10,4,16,30,48,31,26,25), +(10,4,17,31,50,32,27,25), +(10,4,18,32,51,33,27,26), +(10,4,19,33,53,34,27,26), +(10,4,20,34,55,35,27,27), +(10,4,21,35,56,35,27,27), +(10,4,22,36,58,36,28,28), +(10,4,23,37,60,37,28,28), +(10,4,24,38,62,38,28,29), +(10,4,25,39,63,39,28,29), +(10,4,26,40,65,40,29,30), +(10,4,27,41,67,41,29,30), +(10,4,28,42,69,42,29,31), +(10,4,29,43,71,43,29,31), +(10,4,30,44,72,43,29,32), +(10,4,31,45,74,44,30,32), +(10,4,32,46,76,45,30,33), +(10,4,33,47,78,46,30,33), +(10,4,34,48,80,47,31,34), +(10,4,35,49,82,48,31,34), +(10,4,36,50,84,49,31,35), +(10,4,37,51,86,50,31,35), +(10,4,38,52,88,51,32,36), +(10,4,39,53,90,52,32,37), +(10,4,40,54,92,53,32,37), +(10,4,41,56,94,54,33,38), +(10,4,42,57,96,55,33,38), +(10,4,43,58,98,56,33,39), +(10,4,44,59,100,57,33,39), +(10,4,45,60,102,59,34,40), +(10,4,46,61,104,60,34,41), +(10,4,47,62,107,61,34,41), +(10,4,48,64,109,62,35,42), +(10,4,49,65,111,63,35,43), +(10,4,50,66,113,64,35,43), +(10,4,51,67,115,65,36,44), +(10,4,52,68,117,66,36,44), +(10,4,53,70,120,67,36,45), +(10,4,54,71,122,69,37,46), +(10,4,55,72,124,70,37,46), +(10,4,56,73,126,71,37,47), +(10,4,57,75,129,72,38,48), +(10,4,58,76,131,73,38,48), +(10,4,59,77,133,74,39,49), +(10,4,60,79,136,76,39,50), +(10,4,61,80,138,77,39,51), +(10,4,62,81,140,78,40,51), +(10,4,63,82,143,79,40,52), +(10,4,64,84,145,80,41,53), +(10,4,65,85,148,82,41,53), +(10,4,66,87,150,83,41,54), +(10,4,67,88,153,84,42,55), +(10,4,68,89,155,85,42,56), +(10,4,69,91,157,87,43,56), +(10,4,70,92,160,88,43,57), +(10,5,1,17,22,19,26,22), +(10,5,2,17,22,19,27,23), +(10,5,3,17,22,20,29,25), +(10,5,4,17,23,20,30,26), +(10,5,5,18,23,20,31,27), +(10,5,6,18,23,21,33,29), +(10,5,7,18,23,21,34,30), +(10,5,8,18,24,22,35,32), +(10,5,9,18,24,22,37,33), +(10,5,10,19,24,22,38,35), +(10,5,11,19,24,23,39,36), +(10,5,12,19,24,23,41,38), +(10,5,13,19,25,24,42,39), +(10,5,14,19,25,24,44,41), +(10,5,15,19,25,25,45,42), +(10,5,16,20,26,25,47,44), +(10,5,17,20,26,25,48,45), +(10,5,18,20,26,26,50,47), +(10,5,19,20,26,26,51,49), +(10,5,20,21,27,27,53,50), +(10,5,21,21,27,27,54,52), +(10,5,22,21,27,28,56,53), +(10,5,23,21,28,28,58,55), +(10,5,24,21,28,29,59,57), +(10,5,25,22,28,29,61,58), +(10,5,26,22,28,30,62,60), +(10,5,27,22,29,30,64,62), +(10,5,28,22,29,31,66,64), +(10,5,29,23,29,31,67,65), +(10,5,30,23,30,32,69,67), +(10,5,31,23,30,32,71,69), +(10,5,32,23,30,33,72,71), +(10,5,33,24,31,33,74,72), +(10,5,34,24,31,34,76,74), +(10,5,35,24,32,34,78,76), +(10,5,36,24,32,35,80,78), +(10,5,37,25,32,35,81,80), +(10,5,38,25,33,36,83,82), +(10,5,39,25,33,37,85,84), +(10,5,40,26,33,37,87,86), +(10,5,41,26,34,38,89,88), +(10,5,42,26,34,38,91,89), +(10,5,43,27,35,39,92,91), +(10,5,44,27,35,39,94,93), +(10,5,45,27,35,40,96,95), +(10,5,46,27,36,41,98,97), +(10,5,47,28,36,41,100,99), +(10,5,48,28,37,42,102,101), +(10,5,49,28,37,43,104,103), +(10,5,50,29,37,43,106,106), +(10,5,51,29,38,44,108,108), +(10,5,52,29,38,44,110,110), +(10,5,53,30,39,45,112,112), +(10,5,54,30,39,46,114,114), +(10,5,55,30,40,46,116,116), +(10,5,56,31,40,47,118,118), +(10,5,57,31,41,48,120,120), +(10,5,58,31,41,48,123,123), +(10,5,59,32,42,49,125,125), +(10,5,60,32,42,50,127,127), +(10,5,61,33,42,51,129,129), +(10,5,62,33,43,51,131,131), +(10,5,63,33,43,52,133,134), +(10,5,64,34,44,53,135,136), +(10,5,65,34,44,53,138,138), +(10,5,66,34,45,54,140,141), +(10,5,67,35,45,55,142,143), +(10,5,68,35,46,56,144,145), +(10,5,69,36,46,56,147,148), +(10,5,70,36,47,57,149,150), +(10,8,1,17,22,19,27,21), +(10,8,2,17,22,19,28,22), +(10,8,3,17,22,20,30,24), +(10,8,4,17,22,20,31,25), +(10,8,5,17,23,20,32,26), +(10,8,6,17,23,20,34,28), +(10,8,7,18,23,21,35,29), +(10,8,8,18,23,21,37,30), +(10,8,9,18,23,21,38,32), +(10,8,10,18,23,22,40,33), +(10,8,11,18,24,22,41,35), +(10,8,12,18,24,22,42,36), +(10,8,13,18,24,23,44,37), +(10,8,14,18,24,23,45,39), +(10,8,15,18,24,23,47,40), +(10,8,16,19,24,24,49,42), +(10,8,17,19,25,24,50,43), +(10,8,18,19,25,24,52,45), +(10,8,19,19,25,25,53,46), +(10,8,20,19,25,25,55,48), +(10,8,21,19,25,26,57,50), +(10,8,22,19,26,26,58,51), +(10,8,23,20,26,26,60,53), +(10,8,24,20,26,27,61,54), +(10,8,25,20,26,27,63,56), +(10,8,26,20,27,27,65,58), +(10,8,27,20,27,28,67,59), +(10,8,28,20,27,28,68,61), +(10,8,29,21,27,29,70,63), +(10,8,30,21,28,29,72,64), +(10,8,31,21,28,30,74,66), +(10,8,32,21,28,30,75,68), +(10,8,33,21,28,30,77,70), +(10,8,34,21,29,31,79,71), +(10,8,35,22,29,31,81,73), +(10,8,36,22,29,32,83,75), +(10,8,37,22,29,32,85,77), +(10,8,38,22,30,33,86,78), +(10,8,39,22,30,33,88,80), +(10,8,40,23,30,34,90,82), +(10,8,41,23,31,34,92,84), +(10,8,42,23,31,35,94,86), +(10,8,43,23,31,35,96,88), +(10,8,44,23,32,36,98,90), +(10,8,45,24,32,36,100,92), +(10,8,46,24,32,37,102,93), +(10,8,47,24,32,37,104,95), +(10,8,48,24,33,38,106,97), +(10,8,49,25,33,38,108,99), +(10,8,50,25,33,39,110,101), +(10,8,51,25,34,39,112,103), +(10,8,52,25,34,40,114,105), +(10,8,53,25,35,40,117,107), +(10,8,54,26,35,41,119,109), +(10,8,55,26,35,41,121,111), +(10,8,56,26,36,42,123,113), +(10,8,57,26,36,42,125,116), +(10,8,58,27,36,43,127,118), +(10,8,59,27,37,43,130,120), +(10,8,60,27,37,44,132,122), +(10,8,61,27,37,45,134,124), +(10,8,62,28,38,45,136,126), +(10,8,63,28,38,46,139,128), +(10,8,64,28,39,46,141,131), +(10,8,65,29,39,47,143,133), +(10,8,66,29,39,48,146,135), +(10,8,67,29,40,48,148,137), +(10,8,68,29,40,49,150,139), +(10,8,69,30,41,49,153,142), +(10,8,70,30,41,50,155,144), +(10,9,1,17,22,20,26,21), +(10,9,2,17,22,21,27,22), +(10,9,3,18,23,21,28,23), +(10,9,4,18,23,22,29,24), +(10,9,5,18,23,22,31,26), +(10,9,6,18,24,23,32,27), +(10,9,7,19,24,23,33,28), +(10,9,8,19,25,24,34,29), +(10,9,9,19,25,25,36,30), +(10,9,10,20,25,25,37,32), +(10,9,11,20,26,26,38,33), +(10,9,12,20,26,26,39,34), +(10,9,13,21,27,27,41,36), +(10,9,14,21,27,28,42,37), +(10,9,15,21,27,28,43,38), +(10,9,16,22,28,29,45,39), +(10,9,17,22,28,30,46,41), +(10,9,18,23,29,30,47,42), +(10,9,19,23,29,31,49,43), +(10,9,20,23,30,32,50,45), +(10,9,21,24,30,32,51,46), +(10,9,22,24,31,33,53,48), +(10,9,23,24,31,34,54,49), +(10,9,24,25,31,34,56,50), +(10,9,25,25,32,35,57,52), +(10,9,26,26,32,36,59,53), +(10,9,27,26,33,37,60,55), +(10,9,28,26,33,37,62,56), +(10,9,29,27,34,38,63,58), +(10,9,30,27,34,39,65,59), +(10,9,31,28,35,40,66,61), +(10,9,32,28,36,40,68,62), +(10,9,33,29,36,41,69,64), +(10,9,34,29,37,42,71,65), +(10,9,35,29,37,43,73,67), +(10,9,36,30,38,43,74,69), +(10,9,37,30,38,44,76,70), +(10,9,38,31,39,45,77,72), +(10,9,39,31,39,46,79,73), +(10,9,40,32,40,47,81,75), +(10,9,41,32,41,48,82,77), +(10,9,42,33,41,48,84,78), +(10,9,43,33,42,49,86,80), +(10,9,44,34,42,50,88,82), +(10,9,45,34,43,51,89,83), +(10,9,46,35,44,52,91,85), +(10,9,47,35,44,53,93,87), +(10,9,48,36,45,54,95,89), +(10,9,49,36,45,54,96,90), +(10,9,50,37,46,55,98,92), +(10,9,51,37,47,56,100,94), +(10,9,52,38,47,57,102,96), +(10,9,53,38,48,58,104,97), +(10,9,54,39,49,59,105,99), +(10,9,55,39,49,60,107,101), +(10,9,56,40,50,61,109,103), +(10,9,57,40,51,62,111,105), +(10,9,58,41,51,63,113,107), +(10,9,59,42,52,64,115,108), +(10,9,60,42,53,65,117,110), +(10,9,61,43,53,66,119,112), +(10,9,62,43,54,67,121,114), +(10,9,63,44,55,68,123,116), +(10,9,64,44,56,69,125,118), +(10,9,65,45,56,70,127,120), +(10,9,66,46,57,71,129,122), +(10,9,67,46,58,72,131,124), +(10,9,68,47,58,73,133,126), +(10,9,69,47,59,74,135,128), +(10,9,70,48,60,75,137,130), +(11,1,1,24,17,21,21,22), +(11,1,2,25,18,22,21,22), +(11,1,3,27,19,23,21,23), +(11,1,4,28,19,25,21,23), +(11,1,5,29,20,26,21,23), +(11,1,6,31,21,27,21,23), +(11,1,7,32,22,28,21,24), +(11,1,8,33,23,29,22,24), +(11,1,9,35,24,31,22,24), +(11,1,10,36,24,32,22,25), +(11,1,11,37,25,33,22,25), +(11,1,12,39,26,34,22,25), +(11,1,13,40,27,36,22,26), +(11,1,14,42,28,37,22,26), +(11,1,15,43,29,38,22,26), +(11,1,16,45,30,40,22,27), +(11,1,17,46,31,41,23,27), +(11,1,18,48,32,43,23,27), +(11,1,19,49,33,44,23,28), +(11,1,20,51,34,45,23,28), +(11,1,21,52,34,47,23,28), +(11,1,22,54,35,48,23,29), +(11,1,23,55,36,50,23,29), +(11,1,24,57,37,51,24,30), +(11,1,25,59,38,52,24,30), +(11,1,26,60,39,54,24,30), +(11,1,27,62,40,55,24,31), +(11,1,28,63,41,57,24,31), +(11,1,29,65,43,58,24,32), +(11,1,30,67,44,60,24,32), +(11,1,31,69,45,62,25,32), +(11,1,32,70,46,63,25,33), +(11,1,33,72,47,65,25,33), +(11,1,34,74,48,66,25,34), +(11,1,35,75,49,68,25,34), +(11,1,36,77,50,69,26,35), +(11,1,37,79,51,71,26,35), +(11,1,38,81,52,73,26,35), +(11,1,39,83,53,74,26,36), +(11,1,40,84,55,76,26,36), +(11,1,41,86,56,78,27,37), +(11,1,42,88,57,79,27,37), +(11,1,43,90,58,81,27,38), +(11,1,44,92,59,83,27,38), +(11,1,45,94,60,85,27,39), +(11,1,46,96,62,86,28,39), +(11,1,47,98,63,88,28,40), +(11,1,48,100,64,90,28,40), +(11,1,49,102,65,92,28,41), +(11,1,50,103,66,93,29,41), +(11,1,51,105,68,95,29,42), +(11,1,52,107,69,97,29,42), +(11,1,53,109,70,99,29,43), +(11,1,54,112,71,101,30,44), +(11,1,55,114,73,103,30,44), +(11,1,56,116,74,104,30,45), +(11,1,57,118,75,106,30,45), +(11,1,58,120,77,108,31,46), +(11,1,59,122,78,110,31,46), +(11,1,60,124,79,112,31,47), +(11,1,61,126,81,114,31,48), +(11,1,62,128,82,116,32,48), +(11,1,63,130,83,118,32,49), +(11,1,64,133,85,120,32,49), +(11,1,65,135,86,122,33,50), +(11,1,66,137,87,124,33,51), +(11,1,67,139,89,126,33,51), +(11,1,68,141,90,128,33,52), +(11,1,69,144,92,130,34,52), +(11,1,70,146,93,132,34,53), +(11,2,1,23,17,21,21,23), +(11,2,2,24,18,22,22,24), +(11,2,3,25,18,23,22,24), +(11,2,4,26,19,24,23,25), +(11,2,5,27,19,25,24,26), +(11,2,6,29,20,26,24,26), +(11,2,7,30,21,27,25,27), +(11,2,8,31,21,28,26,28), +(11,2,9,32,22,29,26,29), +(11,2,10,33,22,31,27,29), +(11,2,11,34,23,32,28,30), +(11,2,12,36,24,33,28,31), +(11,2,13,37,24,34,29,32), +(11,2,14,38,25,35,30,32), +(11,2,15,39,26,36,31,33), +(11,2,16,40,26,37,31,34), +(11,2,17,42,27,39,32,35), +(11,2,18,43,28,40,33,36), +(11,2,19,44,28,41,34,37), +(11,2,20,46,29,42,34,37), +(11,2,21,47,30,44,35,38), +(11,2,22,48,31,45,36,39), +(11,2,23,50,31,46,37,40), +(11,2,24,51,32,47,38,41), +(11,2,25,52,33,49,38,42), +(11,2,26,54,34,50,39,43), +(11,2,27,55,34,51,40,44), +(11,2,28,56,35,53,41,44), +(11,2,29,58,36,54,42,45), +(11,2,30,59,37,55,43,46), +(11,2,31,61,37,57,43,47), +(11,2,32,62,38,58,44,48), +(11,2,33,64,39,59,45,49), +(11,2,34,65,40,61,46,50), +(11,2,35,67,41,62,47,51), +(11,2,36,68,42,64,48,52), +(11,2,37,70,42,65,49,53), +(11,2,38,71,43,67,50,54), +(11,2,39,73,44,68,51,55), +(11,2,40,74,45,69,52,56), +(11,2,41,76,46,71,53,57), +(11,2,42,78,47,72,54,58), +(11,2,43,79,47,74,55,59), +(11,2,44,81,48,75,56,60), +(11,2,45,82,49,77,57,61), +(11,2,46,84,50,78,58,62), +(11,2,47,86,51,80,59,64), +(11,2,48,87,52,82,60,65), +(11,2,49,89,53,83,61,66), +(11,2,50,91,54,85,62,67), +(11,2,51,92,55,86,63,68), +(11,2,52,94,56,88,64,69), +(11,2,53,96,57,90,65,70), +(11,2,54,97,58,91,66,71), +(11,2,55,99,59,93,67,73), +(11,2,56,101,60,95,68,74), +(11,2,57,103,61,96,69,75), +(11,2,58,105,62,98,70,76), +(11,2,59,106,63,100,71,77), +(11,2,60,108,64,101,72,78), +(11,2,61,110,65,103,74,80), +(11,2,62,112,66,105,75,81), +(11,2,63,114,67,106,76,82), +(11,2,64,116,68,108,77,83), +(11,2,65,117,69,110,78,85), +(11,2,66,119,70,112,79,86), +(11,2,67,121,71,114,80,87), +(11,2,68,123,72,115,82,88), +(11,2,69,125,73,117,83,90), +(11,2,70,127,74,119,84,91), +(11,3,1,21,20,20,21,23), +(11,3,2,21,21,21,22,24), +(11,3,3,22,23,22,22,24), +(11,3,4,22,24,23,23,25), +(11,3,5,23,25,24,23,25), +(11,3,6,23,27,25,24,26), +(11,3,7,24,28,26,24,27), +(11,3,8,24,30,27,25,27), +(11,3,9,25,31,27,26,28), +(11,3,10,25,33,28,26,29), +(11,3,11,25,34,29,27,29), +(11,3,12,26,36,30,28,30), +(11,3,13,26,37,31,28,31), +(11,3,14,27,39,32,29,32), +(11,3,15,27,40,34,30,32), +(11,3,16,28,42,35,30,33), +(11,3,17,28,43,36,31,34), +(11,3,18,29,45,37,32,35), +(11,3,19,29,47,38,32,35), +(11,3,20,30,48,39,33,36), +(11,3,21,31,50,40,34,37), +(11,3,22,31,51,41,34,38), +(11,3,23,32,53,42,35,38), +(11,3,24,32,55,43,36,39), +(11,3,25,33,57,44,37,40), +(11,3,26,33,58,46,37,41), +(11,3,27,34,60,47,38,42), +(11,3,28,35,62,48,39,42), +(11,3,29,35,63,49,40,43), +(11,3,30,36,65,50,40,44), +(11,3,31,36,67,52,41,45), +(11,3,32,37,69,53,42,46), +(11,3,33,38,71,54,43,47), +(11,3,34,38,72,55,44,48), +(11,3,35,39,74,57,44,48), +(11,3,36,39,76,58,45,49), +(11,3,37,40,78,59,46,50), +(11,3,38,41,80,60,47,51), +(11,3,39,41,82,62,48,52), +(11,3,40,42,84,63,49,53), +(11,3,41,43,86,64,50,54), +(11,3,42,43,88,66,50,55), +(11,3,43,44,90,67,51,56), +(11,3,44,45,91,68,52,57), +(11,3,45,45,93,70,53,58), +(11,3,46,46,95,71,54,59), +(11,3,47,47,98,72,55,60), +(11,3,48,48,100,74,56,61), +(11,3,49,48,102,75,57,62), +(11,3,50,49,104,77,58,63), +(11,3,51,50,106,78,59,64), +(11,3,52,51,108,79,60,65), +(11,3,53,51,110,81,61,66), +(11,3,54,52,112,82,61,67), +(11,3,55,53,114,84,62,68), +(11,3,56,54,116,85,63,69), +(11,3,57,54,118,87,64,70), +(11,3,58,55,121,88,65,71), +(11,3,59,56,123,90,66,72), +(11,3,60,57,125,91,67,74), +(11,3,61,58,127,93,68,75), +(11,3,62,58,130,94,69,76), +(11,3,63,59,132,96,71,77), +(11,3,64,60,134,97,72,78), +(11,3,65,61,136,99,73,79), +(11,3,66,62,139,101,74,80), +(11,3,67,62,141,102,75,81), +(11,3,68,63,143,104,76,83), +(11,3,69,64,146,105,77,84), +(11,3,70,65,148,107,78,85), +(11,5,1,21,17,19,23,25), +(11,5,2,21,17,19,24,26), +(11,5,3,21,17,20,26,28), +(11,5,4,21,18,20,27,29), +(11,5,5,22,18,20,28,30), +(11,5,6,22,18,21,30,32), +(11,5,7,22,18,21,31,33), +(11,5,8,22,19,22,32,35), +(11,5,9,22,19,22,34,36), +(11,5,10,22,19,22,35,38), +(11,5,11,23,19,23,37,39), +(11,5,12,23,20,23,38,41), +(11,5,13,23,20,24,39,42), +(11,5,14,23,20,24,41,44), +(11,5,15,23,20,25,42,45), +(11,5,16,24,21,25,44,47), +(11,5,17,24,21,25,45,48), +(11,5,18,24,21,26,47,50), +(11,5,19,24,22,26,48,51), +(11,5,20,24,22,27,50,53), +(11,5,21,25,22,27,51,55), +(11,5,22,25,22,28,53,56), +(11,5,23,25,23,28,55,58), +(11,5,24,25,23,29,56,60), +(11,5,25,25,23,29,58,61), +(11,5,26,26,24,30,60,63), +(11,5,27,26,24,30,61,65), +(11,5,28,26,24,31,63,66), +(11,5,29,26,25,31,65,68), +(11,5,30,27,25,32,66,70), +(11,5,31,27,25,32,68,72), +(11,5,32,27,26,33,70,73), +(11,5,33,27,26,33,71,75), +(11,5,34,28,26,34,73,77), +(11,5,35,28,27,34,75,79), +(11,5,36,28,27,35,77,81), +(11,5,37,29,28,35,79,83), +(11,5,38,29,28,36,80,85), +(11,5,39,29,28,37,82,86), +(11,5,40,29,29,37,84,88), +(11,5,41,30,29,38,86,90), +(11,5,42,30,29,38,88,92), +(11,5,43,30,30,39,90,94), +(11,5,44,31,30,39,91,96), +(11,5,45,31,31,40,93,98), +(11,5,46,31,31,41,95,100), +(11,5,47,32,31,41,97,102), +(11,5,48,32,32,42,99,104), +(11,5,49,32,32,43,101,106), +(11,5,50,33,33,43,103,108), +(11,5,51,33,33,44,105,110), +(11,5,52,33,34,44,107,113), +(11,5,53,34,34,45,109,115), +(11,5,54,34,34,46,111,117), +(11,5,55,34,35,46,113,119), +(11,5,56,35,35,47,115,121), +(11,5,57,35,36,48,118,123), +(11,5,58,35,36,48,120,126), +(11,5,59,36,37,49,122,128), +(11,5,60,36,37,50,124,130), +(11,5,61,36,38,51,126,132), +(11,5,62,37,38,51,128,134), +(11,5,63,37,39,52,130,137), +(11,5,64,38,39,53,133,139), +(11,5,65,38,40,53,135,141), +(11,5,66,38,40,54,137,144), +(11,5,67,39,40,55,139,146), +(11,5,68,39,41,56,141,148), +(11,5,69,40,41,56,144,151), +(11,5,70,40,42,57,146,153), +(11,7,1,22,17,20,22,24), +(11,7,2,23,17,21,23,25), +(11,7,3,24,18,22,24,26), +(11,7,4,25,18,23,25,27), +(11,7,5,25,19,24,26,28), +(11,7,6,26,19,25,27,29), +(11,7,7,27,20,26,28,30), +(11,7,8,28,20,27,28,31), +(11,7,9,29,21,28,29,32), +(11,7,10,30,21,29,30,33), +(11,7,11,31,22,30,31,35), +(11,7,12,32,22,31,32,36), +(11,7,13,33,23,32,33,37), +(11,7,14,34,23,33,34,38), +(11,7,15,34,24,35,35,39), +(11,7,16,35,24,36,36,40), +(11,7,17,36,25,37,38,42), +(11,7,18,37,25,38,39,43), +(11,7,19,38,26,39,40,44), +(11,7,20,39,26,40,41,45), +(11,7,21,40,27,41,42,46), +(11,7,22,41,27,43,43,48), +(11,7,23,43,28,44,44,49), +(11,7,24,44,28,45,45,50), +(11,7,25,45,29,46,46,51), +(11,7,26,46,30,47,48,53), +(11,7,27,47,30,49,49,54), +(11,7,28,48,31,50,50,55), +(11,7,29,49,31,51,51,57), +(11,7,30,50,32,53,52,58), +(11,7,31,51,33,54,53,59), +(11,7,32,52,33,55,55,61), +(11,7,33,53,34,56,56,62), +(11,7,34,55,34,58,57,64), +(11,7,35,56,35,59,58,65), +(11,7,36,57,36,60,60,66), +(11,7,37,58,36,62,61,68), +(11,7,38,59,37,63,62,69), +(11,7,39,61,38,65,63,71), +(11,7,40,62,38,66,65,72), +(11,7,41,63,39,67,66,74), +(11,7,42,64,40,69,67,75), +(11,7,43,65,40,70,69,77), +(11,7,44,67,41,72,70,78), +(11,7,45,68,42,73,71,80), +(11,7,46,69,42,75,73,81), +(11,7,47,71,43,76,74,83), +(11,7,48,72,44,78,76,84), +(11,7,49,73,45,79,77,86), +(11,7,50,74,45,81,78,88), +(11,7,51,76,46,82,80,89), +(11,7,52,77,47,84,81,91), +(11,7,53,78,47,85,83,92), +(11,7,54,80,48,87,84,94), +(11,7,55,81,49,88,86,96), +(11,7,56,83,50,90,87,97), +(11,7,57,84,50,91,89,99), +(11,7,58,85,51,93,90,101), +(11,7,59,87,52,95,92,102), +(11,7,60,88,53,96,93,104), +(11,7,61,90,54,98,95,106), +(11,7,62,91,54,99,96,108), +(11,7,63,93,55,101,98,109), +(11,7,64,94,56,103,99,111), +(11,7,65,95,57,104,101,113), +(11,7,66,97,58,106,103,115), +(11,7,67,98,58,108,104,117), +(11,7,68,100,59,110,106,118), +(11,7,69,101,60,111,107,120), +(11,7,70,103,61,113,109,122), +(11,8,1,21,17,19,24,24), +(11,8,2,21,17,19,25,25), +(11,8,3,21,17,20,27,27), +(11,8,4,21,17,20,28,28), +(11,8,5,21,18,20,29,29), +(11,8,6,21,18,20,31,31), +(11,8,7,21,18,21,32,32), +(11,8,8,22,18,21,34,33), +(11,8,9,22,18,21,35,35), +(11,8,10,22,19,22,37,36), +(11,8,11,22,19,22,38,37), +(11,8,12,22,19,22,40,39), +(11,8,13,22,19,23,41,40), +(11,8,14,22,19,23,43,42), +(11,8,15,22,19,23,44,43), +(11,8,16,22,20,24,46,45), +(11,8,17,23,20,24,47,46), +(11,8,18,23,20,24,49,48), +(11,8,19,23,20,25,50,49), +(11,8,20,23,21,25,52,51), +(11,8,21,23,21,26,54,52), +(11,8,22,23,21,26,55,54), +(11,8,23,23,21,26,57,56), +(11,8,24,24,21,27,59,57), +(11,8,25,24,22,27,60,59), +(11,8,26,24,22,27,62,60), +(11,8,27,24,22,28,64,62), +(11,8,28,24,22,28,65,64), +(11,8,29,24,23,29,67,65), +(11,8,30,24,23,29,69,67), +(11,8,31,25,23,30,71,69), +(11,8,32,25,23,30,73,71), +(11,8,33,25,24,30,74,72), +(11,8,34,25,24,31,76,74), +(11,8,35,25,24,31,78,76), +(11,8,36,26,24,32,80,78), +(11,8,37,26,25,32,82,79), +(11,8,38,26,25,33,84,81), +(11,8,39,26,25,33,86,83), +(11,8,40,26,26,34,87,85), +(11,8,41,27,26,34,89,87), +(11,8,42,27,26,35,91,89), +(11,8,43,27,27,35,93,91), +(11,8,44,27,27,36,95,92), +(11,8,45,27,27,36,97,94), +(11,8,46,28,27,37,99,96), +(11,8,47,28,28,37,101,98), +(11,8,48,28,28,38,103,100), +(11,8,49,28,28,38,105,102), +(11,8,50,29,29,39,107,104), +(11,8,51,29,29,39,110,106), +(11,8,52,29,29,40,112,108), +(11,8,53,29,30,40,114,110), +(11,8,54,30,30,41,116,112), +(11,8,55,30,30,41,118,114), +(11,8,56,30,31,42,120,116), +(11,8,57,30,31,42,122,118), +(11,8,58,31,31,43,125,121), +(11,8,59,31,32,43,127,123), +(11,8,60,31,32,44,129,125), +(11,8,61,31,33,45,131,127), +(11,8,62,32,33,45,133,129), +(11,8,63,32,33,46,136,131), +(11,8,64,32,34,46,138,134), +(11,8,65,33,34,47,140,136), +(11,8,66,33,34,48,143,138), +(11,8,67,33,35,48,145,140), +(11,8,68,33,35,49,147,142), +(11,8,69,34,36,49,150,145), +(11,8,70,34,36,50,152,147); +/*!40000 ALTER TABLE `player_levelstats` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `playercreateinfo` +-- + +DROP TABLE IF EXISTS `playercreateinfo`; +CREATE TABLE `playercreateinfo` ( + `race` tinyint(3) unsigned NOT NULL default '0', + `class` tinyint(3) unsigned NOT NULL default '0', + `map` smallint(5) unsigned NOT NULL default '0', + `zone` mediumint(8) unsigned NOT NULL default '0', + `position_x` float NOT NULL default '0', + `position_y` float NOT NULL default '0', + `position_z` float NOT NULL default '0', + PRIMARY KEY (`race`,`class`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + +-- +-- Dumping data for table `playercreateinfo` +-- + +LOCK TABLES `playercreateinfo` WRITE; +/*!40000 ALTER TABLE `playercreateinfo` DISABLE KEYS */; +INSERT INTO `playercreateinfo` VALUES +(1,1,0,12,-8949,-132,84), +(1,2,0,12,-8949,-132,84), +(1,4,0,12,-8949,-132,84), +(1,5,0,12,-8949,-132,84), +(1,8,0,12,-8949,-132,84), +(1,9,0,12,-8949,-132,84), +(2,1,1,14,-618,-4251,39), +(2,3,1,14,-618,-4251,39), +(2,4,1,14,-618,-4251,39), +(2,7,1,14,-618,-4251,39), +(2,9,1,14,-618,-4251,39), +(3,1,0,1,-6240,331,383), +(3,2,0,1,-6240,331,383), +(3,3,0,1,-6240,331,383), +(3,4,0,1,-6240,331,383), +(3,5,0,1,-6240,331,383), +(4,1,1,141,10311,832,1327), +(4,3,1,141,10311,832,1327), +(4,4,1,141,10311,832,1327), +(4,5,1,141,10311,832,1327), +(4,11,1,141,10311,832,1327), +(5,1,0,85,1676,1677,122), +(5,4,0,85,1676,1677,122), +(5,5,0,85,1676,1677,122), +(5,8,0,85,1676,1677,122), +(5,9,0,85,1676,1677,122), +(6,1,1,215,-2917,-257,53), +(6,3,1,215,-2917,-257,53), +(6,7,1,215,-2917,-257,53), +(6,11,1,215,-2917,-257,53), +(7,1,0,1,-6240,331,383), +(7,4,0,1,-6340,331,383), +(7,8,0,1,-6340,331,383), +(7,9,0,1,-6340,331,383), +(8,1,1,14,-618,-4251,39), +(8,3,1,14,-618,-4251,39), +(8,4,1,14,-618,-4251,39), +(8,5,1,14,-618,-4251,39), +(8,7,1,14,-618,-4251,39), +(8,8,1,14,-618,-4251,39), +(10,2,530,3431,10349.6,-6357.29,33.4026), +(10,3,530,3431,10349.6,-6357.29,33.4026), +(10,4,530,3431,10349.6,-6357.29,33.4026), +(10,5,530,3431,10349.6,-6357.29,33.4026), +(10,8,530,3431,10349.6,-6357.29,33.4026), +(10,9,530,3431,10349.6,-6357.29,33.4026), +(11,1,530,3526,-3961.64,-13931.2,100.615), +(11,2,530,3526,-3961.64,-13931.2,100.615), +(11,3,530,3526,-3961.64,-13931.2,100.615), +(11,5,530,3526,-3961.64,-13931.2,100.615), +(11,7,530,3526,-3961.64,-13931.2,100.615), +(11,8,530,3526,-3961.64,-13931.2,100.615); +/*!40000 ALTER TABLE `playercreateinfo` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `playercreateinfo_action` +-- + +DROP TABLE IF EXISTS `playercreateinfo_action`; +CREATE TABLE `playercreateinfo_action` ( + `race` tinyint(3) unsigned NOT NULL default '0', + `class` tinyint(3) unsigned NOT NULL default '0', + `button` smallint(5) unsigned NOT NULL default '0', + `action` smallint(5) unsigned NOT NULL default '0', + `type` smallint(5) unsigned NOT NULL default '0', + `misc` smallint(5) unsigned NOT NULL default '0', + KEY `playercreateinfo_race_class_index` (`race`,`class`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + +-- +-- Dumping data for table `playercreateinfo_action` +-- + +LOCK TABLES `playercreateinfo_action` WRITE; +/*!40000 ALTER TABLE `playercreateinfo_action` DISABLE KEYS */; +INSERT INTO `playercreateinfo_action` VALUES +(1,1,1,78,0,0), +(1,1,0,6603,0,0), +(1,1,11,117,128,0), +(1,2,2,635,0,0), +(1,2,0,6603,0,0), +(1,2,1,21084,0,0), +(1,2,10,159,128,0), +(1,2,11,2070,128,0), +(1,4,1,1752,0,0), +(1,4,2,2098,0,0), +(1,4,3,2764,0,0), +(1,4,0,6603,0,0), +(1,4,11,2070,128,0), +(1,5,1,585,0,0), +(1,5,2,2050,0,0), +(1,5,0,6603,0,0), +(1,5,10,159,128,0), +(1,5,11,2070,128,0), +(1,8,1,133,0,0), +(1,8,2,168,0,0), +(1,8,0,6603,0,0), +(1,8,10,159,128,0), +(1,8,11,2070,128,0), +(1,9,1,686,0,0), +(1,9,2,687,0,0), +(1,9,0,6603,0,0), +(1,9,10,159,128,0), +(1,9,11,4604,128,0), +(2,1,1,78,0,0), +(2,1,0,6603,0,0), +(2,1,11,117,128,0), +(2,3,2,75,0,0), +(2,3,1,2973,0,0), +(2,3,0,6603,0,0), +(2,3,11,117,128,0), +(2,3,10,159,128,0), +(2,4,10,0,128,0), +(2,4,1,1752,0,0), +(2,4,2,2098,0,0), +(2,4,0,6603,0,0), +(2,4,11,117,128,0), +(2,7,2,331,0,0), +(2,7,1,403,0,0), +(2,7,0,6603,0,0), +(2,7,11,117,128,0), +(2,7,10,159,128,0), +(2,9,1,686,0,0), +(2,9,2,687,0,0), +(2,9,0,6603,0,0), +(2,9,11,117,128,0), +(2,9,10,159,128,0), +(3,1,1,78,0,0), +(3,1,0,6603,0,0), +(3,1,11,117,128,0), +(3,2,2,635,0,0), +(3,2,0,6603,0,0), +(3,2,1,21084,0,0), +(3,2,10,159,128,0), +(3,2,11,4540,128,0), +(3,3,2,75,0,0), +(3,3,1,2973,0,0), +(3,3,0,6603,0,0), +(3,3,11,117,128,0), +(3,3,10,159,128,0), +(3,4,1,1752,0,0), +(3,4,2,2098,0,0), +(3,4,3,2764,0,0), +(3,4,0,6603,0,0), +(3,4,11,4540,128,0), +(3,5,1,585,0,0), +(3,5,2,2050,0,0), +(3,5,0,6603,0,0), +(3,5,10,159,128,0), +(3,5,11,4540,128,0), +(4,1,1,78,0,0), +(4,1,0,6603,0,0), +(4,1,11,117,128,0), +(4,3,2,75,0,0), +(4,3,1,2973,0,0), +(4,3,0,6603,0,0), +(4,3,11,117,128,0), +(4,3,10,159,128,0), +(4,4,1,1752,0,0), +(4,4,2,2098,0,0), +(4,4,3,2764,0,0), +(4,4,0,6603,0,0), +(4,4,11,4540,128,0), +(4,5,1,585,0,0), +(4,5,2,2050,0,0), +(4,5,0,6603,0,0), +(4,5,10,159,128,0), +(4,5,11,2070,128,0), +(4,11,1,5176,0,0), +(4,11,2,5185,0,0), +(4,11,0,6603,0,0), +(4,11,10,159,128,0), +(4,11,11,4536,128,0), +(5,1,11,4604,128,0), +(5,1,0,6603,0,0), +(5,1,1,78,0,0), +(5,4,11,4604,128,0), +(5,4,3,2764,0,0), +(5,4,2,2098,0,0), +(5,4,1,1752,0,0), +(5,4,0,6603,0,0), +(5,5,10,159,128,0), +(5,5,2,2050,0,0), +(5,5,1,585,0,0), +(5,5,11,4604,128,0), +(5,5,0,6603,0,0), +(5,8,11,4604,128,0), +(5,8,10,159,128,0), +(5,8,2,168,0,0), +(5,8,1,133,0,0), +(5,8,0,6603,0,0), +(5,9,1,686,0,0), +(5,9,10,159,128,0), +(5,9,2,687,0,0), +(5,9,11,4604,128,0), +(5,9,0,6603,0,0), +(6,1,1,78,0,0), +(6,1,2,20549,0,0), +(6,1,11,4540,128,0), +(6,1,0,6603,0,0), +(6,3,1,2973,0,0), +(6,3,10,159,128,0), +(6,3,2,75,0,0), +(6,3,3,20549,0,0), +(6,3,11,117,128,0), +(6,3,0,6603,0,0), +(6,7,1,403,0,0), +(6,7,10,159,128,0), +(6,7,2,331,0,0), +(6,7,3,20549,0,0), +(6,7,11,4604,128,0), +(6,7,0,6603,0,0), +(6,11,1,5176,0,0), +(6,11,10,159,128,0), +(6,11,2,5185,0,0), +(6,11,3,20549,0,0), +(6,11,11,4536,128,0), +(6,11,0,6603,0,0), +(7,1,11,117,128,0), +(7,1,1,78,0,0), +(7,1,0,6603,0,0), +(7,4,11,117,128,0), +(7,4,3,2764,0,0), +(7,4,1,1752,0,0), +(7,4,2,2098,0,0), +(7,4,0,6603,0,0), +(7,8,11,4536,128,0), +(7,8,1,133,0,0), +(7,8,2,168,0,0), +(7,8,10,159,128,0), +(7,8,0,6603,0,0), +(7,9,11,4604,128,0), +(7,9,1,686,0,0), +(7,9,2,687,0,0), +(7,9,10,159,128,0), +(7,9,0,6603,0,0), +(8,1,11,117,128,0), +(8,1,1,78,0,0), +(8,1,3,2764,0,0), +(8,1,0,6603,0,0), +(8,3,10,159,128,0), +(8,3,11,4604,128,0), +(8,3,1,2973,0,0), +(8,3,2,75,0,0), +(8,3,0,6603,0,0), +(8,4,1,1752,0,0), +(8,4,3,2764,0,0), +(8,4,2,2098,0,0), +(8,4,11,117,128,0), +(8,4,0,6603,0,0), +(8,5,1,585,0,0), +(8,5,10,159,128,0), +(8,5,2,2050,0,0), +(8,5,11,4540,128,0), +(8,5,0,6603,0,0), +(8,7,1,403,0,0), +(8,7,10,159,128,0), +(8,7,2,331,0,0), +(8,7,11,117,128,0), +(8,7,0,6603,0,0), +(8,8,1,133,0,0), +(8,8,10,159,128,0), +(8,8,2,168,0,0), +(8,8,11,117,128,0), +(8,8,0,6603,0,0), +(10,2,0,6603,0,0), +(10,2,1,21084,0,0), +(10,2,2,635,0,0), +(10,2,3,28734,0,0), +(10,2,4,28730,0,0), +(10,2,10,159,128,0), +(10,2,11,20857,128,0), +(10,3,0,6603,0,0), +(10,3,1,2973,0,0), +(10,3,2,75,0,0), +(10,3,3,28734,0,0), +(10,3,4,28730,0,0), +(10,3,10,159,128,0), +(10,3,11,20857,128,0), +(10,4,0,6603,0,0), +(10,4,1,1752,0,0), +(10,4,2,2098,0,0), +(10,4,3,2764,0,0), +(10,4,4,28734,0,0), +(10,4,5,25046,0,0), +(10,4,11,20857,128,0), +(10,5,0,6603,0,0), +(10,5,1,585,0,0), +(10,5,2,2050,0,0), +(10,5,3,28734,0,0), +(10,5,4,28730,0,0), +(10,5,10,159,128,0), +(10,5,11,20857,128,0), +(10,8,0,6603,0,0), +(10,8,1,133,0,0), +(10,8,2,168,0,0), +(10,8,3,28734,0,0), +(10,8,4,28730,0,0), +(10,8,10,159,128,0), +(10,8,11,20857,128,0), +(10,9,11,20857,128,0), +(10,9,10,159,128,0), +(10,9,4,28730,0,0), +(10,9,3,28734,0,0), +(10,9,2,687,0,0), +(10,9,1,686,0,0), +(10,9,0,6603,0,0), +(11,1,0,6603,0,0), +(11,1,72,6603,0,0), +(11,1,73,78,0,0), +(11,1,74,28880,0,0), +(11,1,83,4540,128,0), +(11,1,84,6603,0,0), +(11,1,96,6603,0,0), +(11,1,108,6603,0,0), +(11,2,0,6603,0,0), +(11,2,1,21084,0,0), +(11,2,2,635,0,0), +(11,2,3,28880,0,0), +(11,2,10,159,128,0), +(11,2,11,4540,128,0), +(11,2,83,4540,128,0), +(11,3,0,6603,0,0), +(11,3,1,2973,0,0), +(11,3,2,75,0,0), +(11,3,3,28880,0,0), +(11,3,10,159,128,0), +(11,3,11,4540,128,0), +(11,3,72,6603,0,0), +(11,3,73,2973,0,0), +(11,3,74,75,0,0), +(11,3,82,159,128,0), +(11,3,83,4540,128,0), +(11,5,0,6603,0,0), +(11,5,1,585,0,0), +(11,5,2,2050,0,0), +(11,5,3,28880,0,0), +(11,5,10,159,128,0), +(11,5,11,4540,128,0), +(11,5,83,4540,128,0), +(11,7,0,6603,0,0), +(11,7,1,403,0,0), +(11,7,2,331,0,0), +(11,7,3,28880,0,0), +(11,7,10,159,128,0), +(11,7,11,4540,128,0), +(11,8,0,6603,0,0), +(11,8,1,133,0,0), +(11,8,2,168,0,0), +(11,8,3,28880,0,0), +(11,8,10,159,128,0), +(11,8,11,4540,128,0), +(11,8,83,4540,128,0); +/*!40000 ALTER TABLE `playercreateinfo_action` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `playercreateinfo_item` +-- + +DROP TABLE IF EXISTS `playercreateinfo_item`; +CREATE TABLE `playercreateinfo_item` ( + `race` tinyint(3) unsigned NOT NULL default '0', + `class` tinyint(3) unsigned NOT NULL default '0', + `itemid` mediumint(8) unsigned NOT NULL default '0', + `amount` tinyint(3) unsigned NOT NULL default '1', + KEY `playercreateinfo_race_class_index` (`race`,`class`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + +-- +-- Dumping data for table `playercreateinfo_item` +-- + +LOCK TABLES `playercreateinfo_item` WRITE; +/*!40000 ALTER TABLE `playercreateinfo_item` DISABLE KEYS */; +INSERT INTO `playercreateinfo_item` VALUES +(1,1,38,1), +(1,1,39,1), +(1,1,40,1), +(1,1,25,1), +(1,1,2362,1), +(1,1,117,4), +(1,1,6948,1), +(1,1,14646,1), +(1,2,45,1), +(1,2,44,1), +(1,2,43,1), +(1,2,2361,1), +(1,2,6948,1), +(1,2,159,2), +(1,2,2070,4), +(1,2,14646,1), +(1,4,49,1), +(1,4,48,1), +(1,4,47,1), +(1,4,2092,1), +(1,4,2947,100), +(1,4,2070,4), +(1,4,6948,1), +(1,4,14646,1), +(1,5,53,1), +(1,5,6098,1), +(1,5,52,1), +(1,5,51,1), +(1,5,36,1), +(1,5,159,2), +(1,5,2070,4), +(1,5,6948,1), +(1,5,14646,1), +(1,8,6096,1), +(1,8,56,1), +(1,8,1395,1), +(1,8,55,1), +(1,8,35,1), +(1,8,2070,4), +(1,8,159,2), +(1,8,6948,1), +(1,8,14646,1), +(1,9,6097,1), +(1,9,57,1), +(1,9,1396,1), +(1,9,59,1), +(1,9,2092,1), +(1,9,4604,4), +(1,9,159,2), +(1,9,6948,1), +(1,9,14646,1), +(2,1,6125,1), +(2,1,139,1), +(2,1,140,1), +(2,1,12282,1), +(2,1,6948,1), +(2,1,117,4), +(2,1,14649,1), +(2,3,127,1), +(2,3,6126,1), +(2,3,6127,1), +(2,3,37,1), +(2,3,2504,1), +(2,3,159,2), +(2,3,117,4), +(2,3,6948,1), +(2,3,14649,1), +(2,3,2512,200), +(2,3,2101,1), +(2,4,2105,1), +(2,4,120,1), +(2,4,121,1), +(2,4,2092,1), +(2,4,25861,100), +(2,4,117,4), +(2,4,6948,1), +(2,4,14649,1), +(2,7,154,1), +(2,7,153,1), +(2,7,36,1), +(2,7,6948,1), +(2,7,117,4), +(2,7,159,2), +(2,7,14649,1), +(2,9,6129,1), +(2,9,1396,1), +(2,9,59,1), +(2,9,2092,1), +(2,9,6948,1), +(2,9,117,4), +(2,9,159,2), +(2,9,14649,1), +(3,1,38,1), +(3,1,39,1), +(3,1,40,1), +(3,1,12282,1), +(3,1,6948,1), +(3,1,117,4), +(3,1,14647,1), +(3,2,45,1), +(3,2,44,1), +(3,2,43,1), +(3,2,2361,1), +(3,2,4540,4), +(3,2,159,2), +(3,2,6948,1), +(3,2,14647,1), +(3,3,148,1), +(3,3,147,1), +(3,3,129,1), +(3,3,37,1), +(3,3,2508,1), +(3,3,159,2), +(3,3,117,4), +(3,3,6948,1), +(3,3,14647,1), +(3,3,2516,200), +(3,3,2102,1), +(3,4,49,1), +(3,4,48,1), +(3,4,47,1), +(3,4,2092,1), +(3,4,25861,100), +(3,4,4540,4), +(3,4,6948,1), +(3,4,14647,1), +(3,5,53,1), +(3,5,6098,1), +(3,5,52,1), +(3,5,51,1), +(3,5,36,1), +(3,5,159,2), +(3,5,4540,4), +(3,5,6948,1), +(3,5,14647,1), +(4,1,38,1), +(4,1,39,1), +(4,1,40,1), +(4,1,25,1), +(4,1,2362,1), +(4,1,117,4), +(4,1,6948,1), +(4,1,14648,1), +(4,3,148,1), +(4,3,147,1), +(4,3,129,1), +(4,3,2092,1), +(4,3,2504,1), +(4,3,159,2), +(4,3,117,4), +(4,3,6948,1), +(4,3,14648,1), +(4,3,2512,200), +(4,3,2101,1), +(4,4,49,1), +(4,4,48,1), +(4,4,47,1), +(4,4,2092,1), +(4,4,2947,100), +(4,4,4540,4), +(4,4,6948,1), +(4,4,14648,1), +(4,5,53,1), +(4,5,6119,1), +(4,5,52,1), +(4,5,51,1), +(4,5,36,1), +(4,5,2070,4), +(4,5,159,2), +(4,5,6948,1), +(4,5,14648,1), +(4,11,6123,1), +(4,11,44,1), +(4,11,3661,1), +(4,11,159,2), +(4,11,4536,4), +(4,11,6948,1), +(4,11,14648,1), +(5,1,6125,1), +(5,1,139,1), +(5,1,140,1), +(5,1,25,1), +(5,1,2362,1), +(5,1,4604,4), +(5,1,6948,1), +(5,1,14651,1), +(5,4,2105,1), +(5,4,120,1), +(5,4,121,1), +(5,4,2092,1), +(5,4,2947,100), +(5,4,4604,4), +(5,4,6948,1), +(5,4,14651,1), +(5,5,53,1), +(5,5,6144,1), +(5,5,52,1), +(5,5,51,1), +(5,5,36,1), +(5,5,4604,4), +(5,5,159,2), +(5,5,6948,1), +(5,5,14651,1), +(5,8,6096,1), +(5,8,6140,1), +(5,8,1395,1), +(5,8,55,1), +(5,8,35,1), +(5,8,4604,4), +(5,8,159,2), +(5,8,6948,1), +(5,8,14651,1), +(5,9,6129,1), +(5,9,1396,1), +(5,9,59,1), +(5,9,2092,1), +(5,9,4604,4), +(5,9,159,2), +(5,9,6948,1), +(5,9,14651,1), +(6,1,6125,1), +(6,1,139,1), +(6,1,2361,1), +(6,1,6948,1), +(6,1,4540,4), +(6,1,14650,1), +(6,3,127,1), +(6,3,6126,1), +(6,3,37,1), +(6,3,2508,1), +(6,3,159,2), +(6,3,117,4), +(6,3,6948,1), +(6,3,14650,1), +(6,3,2516,200), +(6,3,2102,1), +(6,7,154,1), +(6,7,153,1), +(6,7,36,1), +(6,7,6948,1), +(6,7,4604,4), +(6,7,159,2), +(6,7,14650,1), +(6,11,6139,1), +(6,11,6124,1), +(6,11,35,1), +(6,11,159,2), +(6,11,4536,4), +(6,11,6948,1), +(6,11,14650,1), +(7,1,38,1), +(7,1,39,1), +(7,1,40,1), +(7,1,25,1), +(7,1,2362,1), +(7,1,117,4), +(7,1,6948,1), +(7,1,14647,1), +(7,4,49,1), +(7,4,48,1), +(7,4,47,1), +(7,4,2092,1), +(7,4,2947,100), +(7,4,117,4), +(7,4,6948,1), +(7,4,14647,1), +(7,8,6096,1), +(7,8,56,1), +(7,8,1395,1), +(7,8,55,1), +(7,8,35,1), +(7,8,4536,4), +(7,8,159,2), +(7,8,6948,1), +(7,8,14647,1), +(7,9,6097,1), +(7,9,57,1), +(7,9,1396,1), +(7,9,59,1), +(7,9,2092,1), +(7,9,159,2), +(7,9,4604,4), +(7,9,6948,1), +(7,9,14647,1), +(8,1,6125,1), +(8,1,139,1), +(8,1,140,1), +(8,1,37,1), +(8,1,2362,1), +(8,1,25861,100), +(8,1,117,4), +(8,1,6948,1), +(8,1,14649,1), +(8,3,127,1), +(8,3,6126,1), +(8,3,6127,1), +(8,3,37,1), +(8,3,2504,1), +(8,3,4604,4), +(8,3,159,2), +(8,3,2512,200), +(8,3,2101,1), +(8,3,14649,1), +(8,3,6948,1), +(8,4,2105,1), +(8,4,120,1), +(8,4,121,1), +(8,4,2092,1), +(8,4,25861,100), +(8,4,117,4), +(8,4,6948,1), +(8,4,14649,1), +(8,5,53,1), +(8,5,6144,1), +(8,5,52,1), +(8,5,36,1), +(8,5,4540,4), +(8,5,159,2), +(8,5,6948,1), +(8,5,14649,1), +(8,7,6134,1), +(8,7,6135,1), +(8,7,36,1), +(8,7,117,4), +(8,7,159,2), +(8,7,6948,1), +(8,7,14649,1), +(8,8,6096,1), +(8,8,6140,1), +(8,8,1395,1), +(8,8,55,1), +(8,8,35,1), +(8,8,117,4), +(8,8,159,2), +(8,8,6948,1), +(8,8,14649,1), +(10,2,159,5), +(10,2,2070,5), +(10,2,6948,1), +(10,2,23346,1), +(10,2,24143,1), +(10,2,24145,1), +(10,2,24146,1), +(10,3,159,5), +(10,3,2101,1), +(10,3,2512,200), +(10,3,6948,1), +(10,3,20857,5), +(10,3,20899,1), +(10,3,20900,1), +(10,3,20901,1), +(10,3,20980,1), +(10,3,20982,1), +(10,4,3111,100), +(10,4,6948,1), +(10,4,20857,10), +(10,4,20896,1), +(10,4,20897,1), +(10,4,20898,1), +(10,4,20982,1), +(10,5,51,1), +(10,5,52,1), +(10,5,53,1), +(10,5,159,5), +(10,5,6948,1), +(10,5,20891,1), +(10,5,20981,5), +(10,8,35,1), +(10,8,159,5), +(10,8,6096,1), +(10,8,6948,1), +(10,8,20857,5), +(10,8,20893,1), +(10,8,20894,1), +(10,8,20895,1), +(10,9,59,1), +(10,9,159,5), +(10,9,1396,1), +(10,9,6948,1), +(10,9,20857,5), +(10,9,20892,1), +(10,9,20983,1), +(11,1,4540,5), +(11,1,6948,1), +(11,1,23346,1), +(11,1,23473,1), +(11,1,23474,1), +(11,1,23475,1), +(11,2,159,5), +(11,2,2361,1), +(11,2,4540,5), +(11,2,6948,1), +(11,2,23476,1), +(11,2,23476,1), +(11,2,23477,1), +(11,3,25,1), +(11,3,159,5), +(11,3,2101,1), +(11,3,2504,1), +(11,3,2512,200), +(11,3,4540,5), +(11,3,6948,1), +(11,3,23344,1), +(11,3,23345,1), +(11,3,23348,1), +(11,5,36,1), +(11,5,59,1), +(11,5,159,5), +(11,5,1396,1), +(11,5,4540,5), +(11,5,6097,1), +(11,5,6948,1), +(11,5,23322,1), +(11,7,36,1), +(11,7,159,5), +(11,7,4540,5), +(11,7,6948,1), +(11,7,23344,1), +(11,7,23345,1), +(11,7,23348,1), +(11,8,35,1), +(11,8,159,5), +(11,8,4540,5), +(11,8,6948,1), +(11,8,23473,1), +(11,8,23475,1), +(11,8,23478,1), +(11,8,23479,1); +/*!40000 ALTER TABLE `playercreateinfo_item` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `playercreateinfo_spell` +-- + +DROP TABLE IF EXISTS `playercreateinfo_spell`; +CREATE TABLE `playercreateinfo_spell` ( + `race` tinyint(3) unsigned NOT NULL default '0', + `class` tinyint(3) unsigned NOT NULL default '0', + `Spell` mediumint(8) unsigned NOT NULL default '0', + `Note` varchar(255) default NULL, + `Active` tinyint(3) unsigned NOT NULL default '1', + PRIMARY KEY (`race`,`class`,`Spell`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + +-- +-- Dumping data for table `playercreateinfo_spell` +-- + +LOCK TABLES `playercreateinfo_spell` WRITE; +/*!40000 ALTER TABLE `playercreateinfo_spell` DISABLE KEYS */; +INSERT INTO `playercreateinfo_spell` VALUES +(1,1,78,'Heroic Strike',1), +(1,1,81,'Dodge',1), +(1,1,107,'Block',1), +(1,1,196,'One-Handed Axes',1), +(1,1,198,'One-Handed Maces',1), +(1,1,201,'One-Handed Swords',1), +(1,1,203,'Unarmed',1), +(1,1,204,'Defense',1), +(1,1,522,'SPELLDEFENSE(DND)',1), +(1,1,668,'Language Common',1), +(1,1,2382,'Generic',1), +(1,1,2457,'Battle Stance',1), +(1,1,2479,'Honorless Target',1), +(1,1,3050,'Detect',1), +(1,1,3365,'Opening',1), +(1,1,5301,'Defensive State(DND)',1), +(1,1,6233,'Closing',1), +(1,1,6246,'Closing',1), +(1,1,6247,'Opening',1), +(1,1,6477,'Opening',1), +(1,1,6478,'Opening',1), +(1,1,6603,'Attack',1), +(1,1,7266,'Duel',1), +(1,1,7267,'Grovel',1), +(1,1,7355,'Stuck',1), +(1,1,7376,'Defensive Stance Passive',0), +(1,1,7381,'Berserker Stance Passive',0), +(1,1,8386,'Attacking',1), +(1,1,8737,'Mail',1), +(1,1,9077,'Leather',1), +(1,1,9078,'Cloth',1), +(1,1,9116,'Shield',1), +(1,1,9125,'Generic',1), +(1,1,20597,'Sword Specialization',1), +(1,1,20598,'The Human Spirit',1), +(1,1,20599,'Diplomacy',1), +(1,1,20600,'Perception',1), +(1,1,20864,'Mace Specialization',1), +(1,1,21156,'Battle Stance Passive',0), +(1,1,21651,'Opening',1), +(1,1,21652,'Closing',1), +(1,1,22027,'Remove Insignia',1), +(1,1,22810,'Opening - No Text',1), +(1,1,32215,'Victorious State',1), +(1,2,81,'Dodge',1), +(1,2,107,'Block',1), +(1,2,198,'One-Handed Maces',1), +(1,2,199,'Two-Handed Maces',1), +(1,2,203,'Unarmed',1), +(1,2,204,'Defense',1), +(1,2,522,'SPELLDEFENSE(DND)',1), +(1,2,635,'Holy Light',1), +(1,2,668,'Language Common',1), +(1,2,2382,'Generic',1), +(1,2,2479,'Honorless Target',1), +(1,2,3050,'Detect',1), +(1,2,3365,'Opening',1), +(1,2,6233,'Closing',1), +(1,2,6246,'Closing',1), +(1,2,6247,'Opening',1), +(1,2,6477,'Opening',1), +(1,2,6478,'Opening',1), +(1,2,6603,'Attack',1), +(1,2,7266,'Duel',1), +(1,2,7267,'Grovel',1), +(1,2,7355,'Stuck',1), +(1,2,8386,'Attacking',1), +(1,2,8737,'Mail',1), +(1,2,9077,'Leather',1), +(1,2,9078,'Cloth',1), +(1,2,9116,'Shield',1), +(1,2,9125,'Generic',1), +(1,2,21084,'Seal of Righteousness',1), +(1,2,20597,'Sword Specialization',1), +(1,2,20598,'The Human Spirit',1), +(1,2,20599,'Diplomacy',1), +(1,2,20600,'Perception',1), +(1,2,20864,'Mace Specialization',1), +(1,2,21651,'Opening',1), +(1,2,21652,'Closing',1), +(1,2,22027,'Remove Insignia',1), +(1,2,22810,'Opening - No Text',1), +(1,2,27762,'Libram',1), +(1,4,81,'Dodge',1), +(1,4,203,'Unarmed',1), +(1,4,204,'Defense',1), +(1,4,522,'SPELLDEFENSE(DND)',1), +(1,4,668,'Language Common',1), +(1,4,1180,'Daggers',1), +(1,4,1752,'Sinister Strike',1), +(1,4,2098,'Eviscerate',1), +(1,4,2382,'Generic',1), +(1,4,2479,'Honorless Target',1), +(1,4,2567,'Thrown',1), +(1,4,2764,'Throw',1), +(1,4,3050,'Detect',1), +(1,4,3365,'Opening',1), +(1,4,6233,'Closing',1), +(1,4,6246,'Closing',1), +(1,4,6247,'Opening',1), +(1,4,6477,'Opening',1), +(1,4,6478,'Opening',1), +(1,4,6603,'Attack',1), +(1,4,7266,'Duel',1), +(1,4,7267,'Grovel',1), +(1,4,7355,'Stuck',1), +(1,4,8386,'Attacking',1), +(1,4,9077,'Leather',1), +(1,4,9078,'Cloth',1), +(1,4,9125,'Generic',1), +(1,4,16092,'Defensive State(DND)',1), +(1,4,20597,'Sword Specialization',1), +(1,4,20598,'The Human Spirit',1), +(1,4,20599,'Diplomacy',1), +(1,4,20600,'Perception',1), +(1,4,20864,'Mace Specialization',1), +(1,4,21184,'Rogue Passive(DND)',1), +(1,4,21651,'Opening',1), +(1,4,21652,'Closing',1), +(1,4,22027,'Remove Insignia',1), +(1,4,22810,'Opening - No Text',1), +(1,5,81,'Dodge',1), +(1,5,198,'One-Handed Maces',1), +(1,5,203,'Unarmed',1), +(1,5,204,'Defense',1), +(1,5,522,'SPELLDEFENSE(DND)',1), +(1,5,585,'Smite',1), +(1,5,668,'Language Common',1), +(1,5,2050,'Lesser Heal',1), +(1,5,2382,'Generic',1), +(1,5,2479,'Honorless Target',1), +(1,5,3050,'Detect',1), +(1,5,3365,'Opening',1), +(1,5,5009,'Wands',1), +(1,5,5019,'Shoot',1), +(1,5,6233,'Closing',1), +(1,5,6246,'Closing',1), +(1,5,6247,'Opening',1), +(1,5,6477,'Opening',1), +(1,5,6478,'Opening',1), +(1,5,6603,'Attack',1), +(1,5,7266,'Duel',1), +(1,5,7267,'Grovel',1), +(1,5,7355,'Stuck',1), +(1,5,8386,'Attacking',1), +(1,5,9078,'Cloth',1), +(1,5,9125,'Generic',1), +(1,5,20597,'Sword Specialization',1), +(1,5,20598,'The Human Spirit',1), +(1,5,20599,'Diplomacy',1), +(1,5,20600,'Perception',1), +(1,5,20864,'Mace Specialization',1), +(1,5,21651,'Opening',1), +(1,5,21652,'Closing',1), +(1,5,22027,'Remove Insignia',1), +(1,5,22810,'Opening - No Text',1), +(1,8,81,'Dodge',1), +(1,8,133,'Fireball',1), +(1,8,168,'Frost Armor',1), +(1,8,203,'Unarmed',1), +(1,8,204,'Defense',1), +(1,8,227,'Staves',1), +(1,8,522,'SPELLDEFENSE(DND)',1), +(1,8,668,'Language Common',1), +(1,8,2382,'Generic',1), +(1,8,2479,'Honorless Target',1), +(1,8,3050,'Detect',1), +(1,8,3365,'Opening',1), +(1,8,5009,'Wands',1), +(1,8,5019,'Shoot',1), +(1,8,6233,'Closing',1), +(1,8,6246,'Closing',1), +(1,8,6247,'Opening',1), +(1,8,6477,'Opening',1), +(1,8,6478,'Opening',1), +(1,8,6603,'Attack',1), +(1,8,7266,'Duel',1), +(1,8,7267,'Grovel',1), +(1,8,7355,'Stuck',1), +(1,8,8386,'Attacking',1), +(1,8,9078,'Cloth',1), +(1,8,9125,'Generic',1), +(1,8,20597,'Sword Specialization',1), +(1,8,20598,'The Human Spirit',1), +(1,8,20599,'Diplomacy',1), +(1,8,20600,'Perception',1), +(1,8,20864,'Mace Specialization',1), +(1,8,21651,'Opening',1), +(1,8,21652,'Closing',1), +(1,8,22027,'Remove Insignia',1), +(1,8,22810,'Opening - No Text',1), +(1,9,81,'Dodge',1), +(1,9,203,'Unarmed',1), +(1,9,204,'Defense',1), +(1,9,522,'SPELLDEFENSE(DND)',1), +(1,9,668,'Language Common',1), +(1,9,686,'Shadow Bolt',1), +(1,9,687,'Demon Skin',1), +(1,9,1180,'Daggers',1), +(1,9,2382,'Generic',1), +(1,9,2479,'Honorless Target',1), +(1,9,3050,'Detect',1), +(1,9,3365,'Opening',1), +(1,9,5009,'Wands',1), +(1,9,5019,'Shoot',1), +(1,9,6233,'Closing',1), +(1,9,6246,'Closing',1), +(1,9,6247,'Opening',1), +(1,9,6477,'Opening',1), +(1,9,6478,'Opening',1), +(1,9,6603,'Attack',1), +(1,9,7266,'Duel',1), +(1,9,7267,'Grovel',1), +(1,9,7355,'Stuck',1), +(1,9,8386,'Attacking',1), +(1,9,9078,'Cloth',1), +(1,9,9125,'Generic',1), +(1,9,20597,'Sword Specialization',1), +(1,9,20598,'The Human Spirit',1), +(1,9,20599,'Diplomacy',1), +(1,9,20600,'Perception',1), +(1,9,20864,'Mace Specialization',1), +(1,9,21651,'Opening',1), +(1,9,21652,'Closing',1), +(1,9,22027,'Remove Insignia',1), +(1,9,22810,'Opening - No Text',1), +(2,1,78,'Heroic Strike',1), +(2,1,81,'Dodge',1), +(2,1,107,'Block',1), +(2,1,196,'One-Handed Axes',1), +(2,1,197,'Two-Handed Axes',1), +(2,1,201,'One-Handed Swords',1), +(2,1,203,'Unarmed',1), +(2,1,204,'Defense',1), +(2,1,522,'SPELLDEFENSE(DND)',1), +(2,1,669,'Language Orcish',1), +(2,1,2382,'Generic',1), +(2,1,2457,'Battle Stance',1), +(2,1,2479,'Honorless Target',1), +(2,1,3050,'Detect',1), +(2,1,3365,'Opening',1), +(2,1,5301,'Defensive State(DND)',1), +(2,1,6233,'Closing',1), +(2,1,6246,'Closing',1), +(2,1,6247,'Opening',1), +(2,1,6477,'Opening',1), +(2,1,6478,'Opening',1), +(2,1,6603,'Attack',1), +(2,1,7266,'Duel',1), +(2,1,7267,'Grovel',1), +(2,1,7355,'Stuck',1), +(2,1,7376,'Defensive Stance Passive',0), +(2,1,7381,'Berserker Stance Passive',0), +(2,1,8386,'Attacking',1), +(2,1,8737,'Mail',1), +(2,1,9077,'Leather',1), +(2,1,9078,'Cloth',1), +(2,1,9116,'Shield',1), +(2,1,9125,'Generic',1), +(2,1,20572,'Blood Fury',1), +(2,1,20573,'Hardiness',1), +(2,1,20574,'Axe Specialization',1), +(2,1,21156,'Battle Stance Passive',0), +(2,1,21563,'Command',1), +(2,1,21651,'Opening',1), +(2,1,21652,'Closing',1), +(2,1,22027,'Remove Insignia',1), +(2,1,22810,'Opening - No Text',1), +(2,1,32215,'Victorious State',1), +(2,3,75,'Auto Shot',1), +(2,3,81,'Dodge',1), +(2,3,196,'One-Handed Axes',1), +(2,3,203,'Unarmed',1), +(2,3,204,'Defense',1), +(2,3,264,'Bows',1), +(2,3,522,'SPELLDEFENSE(DND)',1), +(2,3,669,'Language Orcish',1), +(2,3,2382,'Generic',1), +(2,3,2479,'Honorless Target',1), +(2,3,2973,'Raptor Strike',1), +(2,3,3050,'Detect',1), +(2,3,3365,'Opening',1), +(2,3,6233,'Closing',1), +(2,3,6246,'Closing',1), +(2,3,6247,'Opening',1), +(2,3,6477,'Opening',1), +(2,3,6478,'Opening',1), +(2,3,6603,'Attack',1), +(2,3,7266,'Duel',1), +(2,3,7267,'Grovel',1), +(2,3,7355,'Stuck',1), +(2,3,8386,'Attacking',1), +(2,3,9077,'Leather',1), +(2,3,9078,'Cloth',1), +(2,3,9125,'Generic',1), +(2,3,13358,'Defensive State(DND)',1), +(2,3,20572,'Blood Fury',1), +(2,3,20573,'Hardiness',1), +(2,3,20574,'Axe Specialization',1), +(2,3,20576,'Command',1), +(2,3,21651,'Opening',1), +(2,3,21652,'Closing',1), +(2,3,22027,'Remove Insignia',1), +(2,3,22810,'Opening - No Text',1), +(2,3,24949,'Defensive State 2(DND)',1), +(2,3,34082,'Advantaged State(DND)',1), +(2,4,81,'Dodge',1), +(2,4,203,'Unarmed',1), +(2,4,204,'Defense',1), +(2,4,522,'SPELLDEFENSE(DND)',1), +(2,4,669,'Language Orcish',1), +(2,4,1180,'Daggers',1), +(2,4,1752,'Sinister Strike',1), +(2,4,2098,'Eviscerate',1), +(2,4,2382,'Generic',1), +(2,4,2479,'Honorless Target',1), +(2,4,2567,'Thrown',1), +(2,4,2764,'Throw',1), +(2,4,3050,'Detect',1), +(2,4,3365,'Opening',1), +(2,4,6233,'Closing',1), +(2,4,6246,'Closing',1), +(2,4,6247,'Opening',1), +(2,4,6477,'Opening',1), +(2,4,6478,'Opening',1), +(2,4,6603,'Attack',1), +(2,4,7266,'Duel',1), +(2,4,7267,'Grovel',1), +(2,4,7355,'Stuck',1), +(2,4,8386,'Attacking',1), +(2,4,9077,'Leather',1), +(2,4,9078,'Cloth',1), +(2,4,9125,'Generic',1), +(2,4,16092,'Defensive State(DND)',1), +(2,4,20572,'Blood Fury',1), +(2,4,20573,'Hardiness',1), +(2,4,20574,'Axe Specialization',1), +(2,4,21184,'Rogue Passive(DND)',1), +(2,4,21563,'Command',1), +(2,4,21651,'Opening',1), +(2,4,21652,'Closing',1), +(2,4,22027,'Remove Insignia',1), +(2,4,22810,'Opening - No Text',1), +(2,7,81,'Dodge',1), +(2,7,107,'Block',1), +(2,7,198,'One-Handed Maces',1), +(2,7,203,'Unarmed',1), +(2,7,204,'Defense',1), +(2,7,227,'Staves',1), +(2,7,331,'Healing Wave',1), +(2,7,403,'Lightning Bolt',1), +(2,7,522,'SPELLDEFENSE(DND)',1), +(2,7,669,'Language Orcish',1), +(2,7,2382,'Generic',1), +(2,7,2479,'Honorless Target',1), +(2,7,3050,'Detect',1), +(2,7,3365,'Opening',1), +(2,7,6233,'Closing',1), +(2,7,6246,'Closing',1), +(2,7,6247,'Opening',1), +(2,7,6477,'Opening',1), +(2,7,6478,'Opening',1), +(2,7,6603,'Attack',1), +(2,7,7266,'Duel',1), +(2,7,7267,'Grovel',1), +(2,7,7355,'Stuck',1), +(2,7,8386,'Attacking',1), +(2,7,9077,'Leather',1), +(2,7,9078,'Cloth',1), +(2,7,9116,'Shield',1), +(2,7,9125,'Generic',1), +(2,7,20573,'Hardiness',1), +(2,7,20574,'Axe Specialization',1), +(2,7,21563,'Command',1), +(2,7,21651,'Opening',1), +(2,7,21652,'Closing',1), +(2,7,22027,'Remove Insignia',1), +(2,7,22810,'Opening - No Text',1), +(2,7,27763,'Totem',1), +(2,7,33697,'Blood Fury',1), +(2,9,81,'Dodge',1), +(2,9,203,'Unarmed',1), +(2,9,204,'Defense',1), +(2,9,522,'SPELLDEFENSE(DND)',1), +(2,9,669,'Language Orcish',1), +(2,9,686,'Shadow Bolt',1), +(2,9,687,'Demon Skin',1), +(2,9,1180,'Daggers',1), +(2,9,2382,'Generic',1), +(2,9,2479,'Honorless Target',1), +(2,9,3050,'Detect',1), +(2,9,3365,'Opening',1), +(2,9,5009,'Wands',1), +(2,9,5019,'Shoot',1), +(2,9,6233,'Closing',1), +(2,9,6246,'Closing',1), +(2,9,6247,'Opening',1), +(2,9,6477,'Opening',1), +(2,9,6478,'Opening',1), +(2,9,6603,'Attack',1), +(2,9,7266,'Duel',1), +(2,9,7267,'Grovel',1), +(2,9,7355,'Stuck',1), +(2,9,8386,'Attacking',1), +(2,9,9078,'Cloth',1), +(2,9,9125,'Generic',1), +(2,9,20573,'Hardiness',1), +(2,9,20574,'Axe Specialization',1), +(2,9,20575,'Command',1), +(2,9,21651,'Opening',1), +(2,9,21652,'Closing',1), +(2,9,22027,'Remove Insignia',1), +(2,9,22810,'Opening - No Text',1), +(2,9,33702,'Blood Fury',1), +(3,1,78,'Heroic Strike',1), +(3,1,81,'Dodge',1), +(3,1,107,'Block',1), +(3,1,196,'One-Handed Axes',1), +(3,1,197,'Two-Handed Axes',1), +(3,1,198,'One-Handed Maces',1), +(3,1,203,'Unarmed',1), +(3,1,204,'Defense',1), +(3,1,522,'SPELLDEFENSE(DND)',1), +(3,1,668,'Language Common',1), +(3,1,672,'Language Dwarven',1), +(3,1,2382,'Generic',1), +(3,1,2457,'Battle Stance',1), +(3,1,2479,'Honorless Target',1), +(3,1,2481,'Find Treasure',1), +(3,1,3050,'Detect',1), +(3,1,3365,'Opening',1), +(3,1,5301,'Defensive State(DND)',1), +(3,1,6233,'Closing',1), +(3,1,6246,'Closing',1), +(3,1,6247,'Opening',1), +(3,1,6477,'Opening',1), +(3,1,6478,'Opening',1), +(3,1,6603,'Attack',1), +(3,1,7266,'Duel',1), +(3,1,7267,'Grovel',1), +(3,1,7355,'Stuck',1), +(3,1,7376,'Defensive Stance Passive',0), +(3,1,7381,'Berserker Stance Passive',0), +(3,1,8386,'Attacking',1), +(3,1,8737,'Mail',1), +(3,1,9077,'Leather',1), +(3,1,9078,'Cloth',1), +(3,1,9116,'Shield',1), +(3,1,9125,'Generic',1), +(3,1,20594,'Stoneform',1), +(3,1,20595,'Gun Specialization',1), +(3,1,20596,'Frost Resistance',1), +(3,1,21156,'Battle Stance Passive',0), +(3,1,21651,'Opening',1), +(3,1,21652,'Closing',1), +(3,1,22027,'Remove Insignia',1), +(3,1,22810,'Opening - No Text',1), +(3,1,32215,'Victorious State',1), +(3,2,81,'Dodge',1), +(3,2,107,'Block',1), +(3,2,198,'One-Handed Maces',1), +(3,2,199,'Two-Handed Maces',1), +(3,2,203,'Unarmed',1), +(3,2,204,'Defense',1), +(3,2,522,'SPELLDEFENSE(DND)',1), +(3,2,635,'Holy Light',1), +(3,2,668,'Language Common',1), +(3,2,672,'Language Dwarven',1), +(3,2,2382,'Generic',1), +(3,2,2479,'Honorless Target',1), +(3,2,2481,'Find Treasure',1), +(3,2,3050,'Detect',1), +(3,2,3365,'Opening',1), +(3,2,6233,'Closing',1), +(3,2,6246,'Closing',1), +(3,2,6247,'Opening',1), +(3,2,6477,'Opening',1), +(3,2,6478,'Opening',1), +(3,2,6603,'Attack',1), +(3,2,7266,'Duel',1), +(3,2,7267,'Grovel',1), +(3,2,7355,'Stuck',1), +(3,2,8386,'Attacking',1), +(3,2,8737,'Mail',1), +(3,2,9077,'Leather',1), +(3,2,9078,'Cloth',1), +(3,2,9116,'Shield',1), +(3,2,9125,'Generic',1), +(3,2,21084,'Seal of Righteousness',1), +(3,2,20594,'Stoneform',1), +(3,2,20595,'Gun Specialization',1), +(3,2,20596,'Frost Resistance',1), +(3,2,21651,'Opening',1), +(3,2,21652,'Closing',1), +(3,2,22027,'Remove Insignia',1), +(3,2,22810,'Opening - No Text',1), +(3,2,27762,'Libram',1), +(3,3,75,'Auto Shot',1), +(3,3,81,'Dodge',1), +(3,3,196,'One-Handed Axes',1), +(3,3,203,'Unarmed',1), +(3,3,204,'Defense',1), +(3,3,266,'Guns',1), +(3,3,522,'SPELLDEFENSE(DND)',1), +(3,3,668,'Language Common',1), +(3,3,672,'Language Dwarven',1), +(3,3,2382,'Generic',1), +(3,3,2479,'Honorless Target',1), +(3,3,2481,'Find Treasure',1), +(3,3,2973,'Raptor Strike',1), +(3,3,3050,'Detect',1), +(3,3,3365,'Opening',1), +(3,3,6233,'Closing',1), +(3,3,6246,'Closing',1), +(3,3,6247,'Opening',1), +(3,3,6477,'Opening',1), +(3,3,6478,'Opening',1), +(3,3,6603,'Attack',1), +(3,3,7266,'Duel',1), +(3,3,7267,'Grovel',1), +(3,3,7355,'Stuck',1), +(3,3,8386,'Attacking',1), +(3,3,9077,'Leather',1), +(3,3,9078,'Cloth',1), +(3,3,9125,'Generic',1), +(3,3,13358,'Defensive State(DND)',1), +(3,3,20594,'Stoneform',1), +(3,3,20595,'Gun Specialization',1), +(3,3,20596,'Frost Resistance',1), +(3,3,21651,'Opening',1), +(3,3,21652,'Closing',1), +(3,3,22027,'Remove Insignia',1), +(3,3,22810,'Opening - No Text',1), +(3,3,24949,'Defensive State 2(DND)',1), +(3,3,34082,'Advantaged State(DND)',1), +(3,4,81,'Dodge',1), +(3,4,203,'Unarmed',1), +(3,4,204,'Defense',1), +(3,4,522,'SPELLDEFENSE(DND)',1), +(3,4,668,'Language Common',1), +(3,4,672,'Language Dwarven',1), +(3,4,1180,'Daggers',1), +(3,4,1752,'Sinister Strike',1), +(3,4,2098,'Eviscerate',1), +(3,4,2382,'Generic',1), +(3,4,2479,'Honorless Target',1), +(3,4,2481,'Find Treasure',1), +(3,4,2567,'Thrown',1), +(3,4,2764,'Throw',1), +(3,4,3050,'Detect',1), +(3,4,3365,'Opening',1), +(3,4,6233,'Closing',1), +(3,4,6246,'Closing',1), +(3,4,6247,'Opening',1), +(3,4,6477,'Opening',1), +(3,4,6478,'Opening',1), +(3,4,6603,'Attack',1), +(3,4,7266,'Duel',1), +(3,4,7267,'Grovel',1), +(3,4,7355,'Stuck',1), +(3,4,8386,'Attacking',1), +(3,4,9077,'Leather',1), +(3,4,9078,'Cloth',1), +(3,4,9125,'Generic',1), +(3,4,16092,'Defensive State(DND)',1), +(3,4,20594,'Stoneform',1), +(3,4,20595,'Gun Specialization',1), +(3,4,20596,'Frost Resistance',1), +(3,4,21184,'Rogue Passive(DND)',1), +(3,4,21651,'Opening',1), +(3,4,21652,'Closing',1), +(3,4,22027,'Remove Insignia',1), +(3,4,22810,'Opening - No Text',1), +(3,5,81,'Dodge',1), +(3,5,198,'One-Handed Maces',1), +(3,5,203,'Unarmed',1), +(3,5,204,'Defense',1), +(3,5,522,'SPELLDEFENSE(DND)',1), +(3,5,585,'Smite',1), +(3,5,668,'Language Common',1), +(3,5,672,'Language Dwarven',1), +(3,5,2050,'Lesser Heal',1), +(3,5,2382,'Generic',1), +(3,5,2479,'Honorless Target',1), +(3,5,2481,'Find Treasure',1), +(3,5,3050,'Detect',1), +(3,5,3365,'Opening',1), +(3,5,5009,'Wands',1), +(3,5,5019,'Shoot',1), +(3,5,6233,'Closing',1), +(3,5,6246,'Closing',1), +(3,5,6247,'Opening',1), +(3,5,6477,'Opening',1), +(3,5,6478,'Opening',1), +(3,5,6603,'Attack',1), +(3,5,7266,'Duel',1), +(3,5,7267,'Grovel',1), +(3,5,7355,'Stuck',1), +(3,5,8386,'Attacking',1), +(3,5,9078,'Cloth',1), +(3,5,9125,'Generic',1), +(3,5,20594,'Stoneform',1), +(3,5,20595,'Gun Specialization',1), +(3,5,20596,'Frost Resistance',1), +(3,5,21651,'Opening',1), +(3,5,21652,'Closing',1), +(3,5,22027,'Remove Insignia',1), +(3,5,22810,'Opening - No Text',1), +(4,1,78,'Heroic Strike',1), +(4,1,81,'Dodge',1), +(4,1,107,'Block',1), +(4,1,198,'One-Handed Maces',1), +(4,1,201,'One-Handed Swords',1), +(4,1,203,'Unarmed',1), +(4,1,204,'Defense',1), +(4,1,522,'SPELLDEFENSE(DND)',1), +(4,1,668,'Language Common',1), +(4,1,671,'Language Darnassian',1), +(4,1,1180,'Daggers',1), +(4,1,2382,'Generic',1), +(4,1,2457,'Battle Stance',1), +(4,1,2479,'Honorless Target',1), +(4,1,3050,'Detect',1), +(4,1,3365,'Opening',1), +(4,1,5301,'Defensive State(DND)',1), +(4,1,6233,'Closing',1), +(4,1,6246,'Closing',1), +(4,1,6247,'Opening',1), +(4,1,6477,'Opening',1), +(4,1,6478,'Opening',1), +(4,1,6603,'Attack',1), +(4,1,7266,'Duel',1), +(4,1,7267,'Grovel',1), +(4,1,7355,'Stuck',1), +(4,1,7376,'Defensive Stance Passive',0), +(4,1,7381,'Berserker Stance Passive',0), +(4,1,8386,'Attacking',1), +(4,1,8737,'Mail',1), +(4,1,9077,'Leather',1), +(4,1,9078,'Cloth',1), +(4,1,9116,'Shield',1), +(4,1,9125,'Generic',1), +(4,1,20580,'Shadowmeld',1), +(4,1,20582,'Quickness',1), +(4,1,20583,'Nature Resistance',1), +(4,1,20585,'Wisp Spirit',1), +(4,1,21009,'Shadowmeld Passive',1), +(4,1,21156,'Battle Stance Passive',0), +(4,1,21651,'Opening',1), +(4,1,21652,'Closing',1), +(4,1,22027,'Remove Insignia',1), +(4,1,22810,'Opening - No Text',1), +(4,1,32215,'Victorious State',1), +(4,3,75,'Auto Shot',1), +(4,3,81,'Dodge',1), +(4,3,203,'Unarmed',1), +(4,3,204,'Defense',1), +(4,3,264,'Bows',1), +(4,3,522,'SPELLDEFENSE(DND)',1), +(4,3,668,'Language Common',1), +(4,3,671,'Language Darnassian',1), +(4,3,1180,'Daggers',1), +(4,3,2382,'Generic',1), +(4,3,2479,'Honorless Target',1), +(4,3,2973,'Raptor Strike',1), +(4,3,3050,'Detect',1), +(4,3,3365,'Opening',1), +(4,3,6233,'Closing',1), +(4,3,6246,'Closing',1), +(4,3,6247,'Opening',1), +(4,3,6477,'Opening',1), +(4,3,6478,'Opening',1), +(4,3,6603,'Attack',1), +(4,3,7266,'Duel',1), +(4,3,7267,'Grovel',1), +(4,3,7355,'Stuck',1), +(4,3,8386,'Attacking',1), +(4,3,9077,'Leather',1), +(4,3,9078,'Cloth',1), +(4,3,9125,'Generic',1), +(4,3,13358,'Defensive State(DND)',1), +(4,3,20580,'Shadowmeld',1), +(4,3,20582,'Quickness',1), +(4,3,20583,'Nature Resistance',1), +(4,3,20585,'Wisp Spirit',1), +(4,3,21009,'Shadowmeld Passive',1), +(4,3,21651,'Opening',1), +(4,3,21652,'Closing',1), +(4,3,22027,'Remove Insignia',1), +(4,3,22810,'Opening - No Text',1), +(4,3,24949,'Defensive State 2(DND)',1), +(4,3,34082,'Advantaged State(DND)',1), +(4,4,81,'Dodge',1), +(4,4,203,'Unarmed',1), +(4,4,204,'Defense',1), +(4,4,522,'SPELLDEFENSE(DND)',1), +(4,4,668,'Language Common',1), +(4,4,671,'Language Darnassian',1), +(4,4,1180,'Daggers',1), +(4,4,1752,'Sinister Strike',1), +(4,4,2098,'Eviscerate',1), +(4,4,2382,'Generic',1), +(4,4,2479,'Honorless Target',1), +(4,4,2567,'Thrown',1), +(4,4,2764,'Throw',1), +(4,4,3050,'Detect',1), +(4,4,3365,'Opening',1), +(4,4,6233,'Closing',1), +(4,4,6246,'Closing',1), +(4,4,6247,'Opening',1), +(4,4,6477,'Opening',1), +(4,4,6478,'Opening',1), +(4,4,6603,'Attack',1), +(4,4,7266,'Duel',1), +(4,4,7267,'Grovel',1), +(4,4,7355,'Stuck',1), +(4,4,8386,'Attacking',1), +(4,4,9077,'Leather',1), +(4,4,9078,'Cloth',1), +(4,4,9125,'Generic',1), +(4,4,16092,'Defensive State(DND)',1), +(4,4,20580,'Shadowmeld',1), +(4,4,20582,'Quickness',1), +(4,4,20583,'Nature Resistance',1), +(4,4,20585,'Wisp Spirit',1), +(4,4,21009,'Shadowmeld Passive',1), +(4,4,21184,'Rogue Passive(DND)',1), +(4,4,21651,'Opening',1), +(4,4,21652,'Closing',1), +(4,4,22027,'Remove Insignia',1), +(4,4,22810,'Opening - No Text',1), +(4,5,81,'Dodge',1), +(4,5,198,'One-Handed Maces',1), +(4,5,203,'Unarmed',1), +(4,5,204,'Defense',1), +(4,5,522,'SPELLDEFENSE(DND)',1), +(4,5,585,'Smite',1), +(4,5,668,'Language Common',1), +(4,5,671,'Language Darnassian',1), +(4,5,2050,'Lesser Heal',1), +(4,5,2382,'Generic',1), +(4,5,2479,'Honorless Target',1), +(4,5,3050,'Detect',1), +(4,5,3365,'Opening',1), +(4,5,5009,'Wands',1), +(4,5,5019,'Shoot',1), +(4,5,6233,'Closing',1), +(4,5,6246,'Closing',1), +(4,5,6247,'Opening',1), +(4,5,6477,'Opening',1), +(4,5,6478,'Opening',1), +(4,5,6603,'Attack',1), +(4,5,7266,'Duel',1), +(4,5,7267,'Grovel',1), +(4,5,7355,'Stuck',1), +(4,5,8386,'Attacking',1), +(4,5,9078,'Cloth',1), +(4,5,9125,'Generic',1), +(4,5,20580,'Shadowmeld',1), +(4,5,20582,'Quickness',1), +(4,5,20583,'Nature Resistance',1), +(4,5,20585,'Wisp Spirit',1), +(4,5,21009,'Shadowmeld Passive',1), +(4,5,21651,'Opening',1), +(4,5,21652,'Closing',1), +(4,5,22027,'Remove Insignia',1), +(4,5,22810,'Opening - No Text',1), +(4,11,81,'Dodge',1), +(4,11,203,'Unarmed',1), +(4,11,204,'Defense',1), +(4,11,227,'Staves',1), +(4,11,522,'SPELLDEFENSE(DND)',1), +(4,11,668,'Language Common',1), +(4,11,671,'Language Darnassian',1), +(4,11,1178,'Bear Form(Passive)',0), +(4,11,1180,'Daggers',1), +(4,11,2382,'Generic',1), +(4,11,2479,'Honorless Target',1), +(4,11,3025,'Cat Form(Passive)',0), +(4,11,3050,'Detect',1), +(4,11,3365,'Opening',1), +(4,11,5176,'Wrath',1), +(4,11,5185,'Healing Touch',1), +(4,11,5419,'Travel Form(Passive)',0), +(4,11,5420,'Tree of Life',0), +(4,11,5421,'Aquatic Form(Passive)',0), +(4,11,6233,'Closing',1), +(4,11,6246,'Closing',1), +(4,11,6247,'Opening',1), +(4,11,6477,'Opening',1), +(4,11,6478,'Opening',1), +(4,11,6603,'Attack',1), +(4,11,7266,'Duel',1), +(4,11,7267,'Grovel',1), +(4,11,7355,'Stuck',1), +(4,11,8386,'Attacking',1), +(4,11,9077,'Leather',1), +(4,11,9078,'Cloth',1), +(4,11,9125,'Generic',1), +(4,11,9635,'Dire Bear Form(Passive)',0), +(4,11,20580,'Shadowmeld',1), +(4,11,20582,'Quickness',1), +(4,11,20583,'Nature Resistance',1), +(4,11,20585,'Wisp Spirit',1), +(4,11,21009,'Shadowmeld Passive',1), +(4,11,21178,'Bear Form(Passive2)',0), +(4,11,21651,'Opening',1), +(4,11,21652,'Closing',1), +(4,11,22027,'Remove Insignia',1), +(4,11,22810,'Opening - No Text',1), +(4,11,24905,'Moonkin Form(Passive)',0), +(4,11,27764,'Fetish',1), +(4,11,33948,'Flight Form(Passive)',0), +(4,11,34123,'Tree of Life(Passive)',0), +(4,11,40121,'Swift Flight Form(Passive)',0), +(5,1,78,'Heroic Strike',1), +(5,1,81,'Dodge',1), +(5,1,107,'Block',1), +(5,1,201,'One-Handed Swords',1), +(5,1,202,'Two-Handed Swords',1), +(5,1,203,'Unarmed',1), +(5,1,204,'Defense',1), +(5,1,522,'SPELLDEFENSE(DND)',1), +(5,1,669,'Language Orcish',1), +(5,1,1180,'Daggers',1), +(5,1,2382,'Generic',1), +(5,1,2457,'Battle Stance',1), +(5,1,2479,'Honorless Target',1), +(5,1,3050,'Detect',1), +(5,1,3365,'Opening',1), +(5,1,5227,'Underwater Breathing',1), +(5,1,5301,'Defensive State(DND)',1), +(5,1,6233,'Closing',1), +(5,1,6246,'Closing',1), +(5,1,6247,'Opening',1), +(5,1,6477,'Opening',1), +(5,1,6478,'Opening',1), +(5,1,6603,'Attack',1), +(5,1,7266,'Duel',1), +(5,1,7267,'Grovel',1), +(5,1,7355,'Stuck',1), +(5,1,7376,'Defensive Stance Passive',0), +(5,1,7381,'Berserker Stance Passive',0), +(5,1,7744,'Will of the Forsaken',1), +(5,1,8386,'Attacking',1), +(5,1,8737,'Mail',1), +(5,1,9077,'Leather',1), +(5,1,9078,'Cloth',1), +(5,1,9116,'Shield',1), +(5,1,9125,'Generic',1), +(5,1,17737,'Language Gutterspeak',1), +(5,1,20577,'Cannibalize',1), +(5,1,20579,'Shadow Resistance',1), +(5,1,21156,'Battle Stance Passive',0), +(5,1,21651,'Opening',1), +(5,1,21652,'Closing',1), +(5,1,22027,'Remove Insignia',1), +(5,1,22810,'Opening - No Text',1), +(5,1,32215,'Victorious State',1), +(5,4,81,'Dodge',1), +(5,4,203,'Unarmed',1), +(5,4,204,'Defense',1), +(5,4,522,'SPELLDEFENSE(DND)',1), +(5,4,669,'Language Orcish',1), +(5,4,1180,'Daggers',1), +(5,4,1752,'Sinister Strike',1), +(5,4,2098,'Eviscerate',1), +(5,4,2382,'Generic',1), +(5,4,2479,'Honorless Target',1), +(5,4,2567,'Thrown',1), +(5,4,2764,'Throw',1), +(5,4,3050,'Detect',1), +(5,4,3365,'Opening',1), +(5,4,5227,'Underwater Breathing',1), +(5,4,6233,'Closing',1), +(5,4,6246,'Closing',1), +(5,4,6247,'Opening',1), +(5,4,6477,'Opening',1), +(5,4,6478,'Opening',1), +(5,4,6603,'Attack',1), +(5,4,7266,'Duel',1), +(5,4,7267,'Grovel',1), +(5,4,7355,'Stuck',1), +(5,4,7744,'Will of the Forsaken',1), +(5,4,8386,'Attacking',1), +(5,4,9077,'Leather',1), +(5,4,9078,'Cloth',1), +(5,4,9125,'Generic',1), +(5,4,16092,'Defensive State(DND)',1), +(5,4,17737,'Language Gutterspeak',1), +(5,4,20577,'Cannibalize',1), +(5,4,20579,'Shadow Resistance',1), +(5,4,21184,'Rogue Passive(DND)',1), +(5,4,21651,'Opening',1), +(5,4,21652,'Closing',1), +(5,4,22027,'Remove Insignia',1), +(5,4,22810,'Opening - No Text',1), +(5,5,81,'Dodge',1), +(5,5,198,'One-Handed Maces',1), +(5,5,203,'Unarmed',1), +(5,5,204,'Defense',1), +(5,5,522,'SPELLDEFENSE(DND)',1), +(5,5,585,'Smite',1), +(5,5,669,'Language Orcish',1), +(5,5,2050,'Lesser Heal',1), +(5,5,2382,'Generic',1), +(5,5,2479,'Honorless Target',1), +(5,5,3050,'Detect',1), +(5,5,3365,'Opening',1), +(5,5,5009,'Wands',1), +(5,5,5019,'Shoot',1), +(5,5,5227,'Underwater Breathing',1), +(5,5,6233,'Closing',1), +(5,5,6246,'Closing',1), +(5,5,6247,'Opening',1), +(5,5,6477,'Opening',1), +(5,5,6478,'Opening',1), +(5,5,6603,'Attack',1), +(5,5,7266,'Duel',1), +(5,5,7267,'Grovel',1), +(5,5,7355,'Stuck',1), +(5,5,7744,'Will of the Forsaken',1), +(5,5,8386,'Attacking',1), +(5,5,9078,'Cloth',1), +(5,5,9125,'Generic',1), +(5,5,17737,'Language Gutterspeak',1), +(5,5,20577,'Cannibalize',1), +(5,5,20579,'Shadow Resistance',1), +(5,5,21651,'Opening',1), +(5,5,21652,'Closing',1), +(5,5,22027,'Remove Insignia',1), +(5,5,22810,'Opening - No Text',1), +(5,8,81,'Dodge',1), +(5,8,133,'Fireball',1), +(5,8,168,'Frost Armor',1), +(5,8,203,'Unarmed',1), +(5,8,204,'Defense',1), +(5,8,227,'Staves',1), +(5,8,522,'SPELLDEFENSE(DND)',1), +(5,8,669,'Language Orcish',1), +(5,8,2382,'Generic',1), +(5,8,2479,'Honorless Target',1), +(5,8,3050,'Detect',1), +(5,8,3365,'Opening',1), +(5,8,5009,'Wands',1), +(5,8,5019,'Shoot',1), +(5,8,5227,'Underwater Breathing',1), +(5,8,6233,'Closing',1), +(5,8,6246,'Closing',1), +(5,8,6247,'Opening',1), +(5,8,6477,'Opening',1), +(5,8,6478,'Opening',1), +(5,8,6603,'Attack',1), +(5,8,7266,'Duel',1), +(5,8,7267,'Grovel',1), +(5,8,7355,'Stuck',1), +(5,8,7744,'Will of the Forsaken',1), +(5,8,8386,'Attacking',1), +(5,8,9078,'Cloth',1), +(5,8,9125,'Generic',1), +(5,8,17737,'Language Gutterspeak',1), +(5,8,20577,'Cannibalize',1), +(5,8,20579,'Shadow Resistance',1), +(5,8,21651,'Opening',1), +(5,8,21652,'Closing',1), +(5,8,22027,'Remove Insignia',1), +(5,8,22810,'Opening - No Text',1), +(5,9,81,'Dodge',1), +(5,9,203,'Unarmed',1), +(5,9,204,'Defense',1), +(5,9,522,'SPELLDEFENSE(DND)',1), +(5,9,669,'Language Orcish',1), +(5,9,686,'Shadow Bolt',1), +(5,9,687,'Demon Skin',1), +(5,9,1180,'Daggers',1), +(5,9,2382,'Generic',1), +(5,9,2479,'Honorless Target',1), +(5,9,3050,'Detect',1), +(5,9,3365,'Opening',1), +(5,9,5009,'Wands',1), +(5,9,5019,'Shoot',1), +(5,9,5227,'Underwater Breathing',1), +(5,9,6233,'Closing',1), +(5,9,6246,'Closing',1), +(5,9,6247,'Opening',1), +(5,9,6477,'Opening',1), +(5,9,6478,'Opening',1), +(5,9,6603,'Attack',1), +(5,9,7266,'Duel',1), +(5,9,7267,'Grovel',1), +(5,9,7355,'Stuck',1), +(5,9,7744,'Will of the Forsaken',1), +(5,9,8386,'Attacking',1), +(5,9,9078,'Cloth',1), +(5,9,9125,'Generic',1), +(5,9,17737,'Language Gutterspeak',1), +(5,9,20577,'Cannibalize',1), +(5,9,20579,'Shadow Resistance',1), +(5,9,21651,'Opening',1), +(5,9,21652,'Closing',1), +(5,9,22027,'Remove Insignia',1), +(5,9,22810,'Opening - No Text',1), +(6,1,78,'Heroic Strike',1), +(6,1,81,'Dodge',1), +(6,1,107,'Block',1), +(6,1,196,'One-Handed Axes',1), +(6,1,198,'One-Handed Maces',1), +(6,1,199,'Two-Handed Maces',1), +(6,1,203,'Unarmed',1), +(6,1,204,'Defense',1), +(6,1,522,'SPELLDEFENSE(DND)',1), +(6,1,669,'Language Orcish',1), +(6,1,670,'Language Taurahe',1), +(6,1,2382,'Generic',1), +(6,1,2457,'Battle Stance',1), +(6,1,2479,'Honorless Target',1), +(6,1,3050,'Detect',1), +(6,1,3365,'Opening',1), +(6,1,5301,'Defensive State(DND)',1), +(6,1,6233,'Closing',1), +(6,1,6246,'Closing',1), +(6,1,6247,'Opening',1), +(6,1,6477,'Opening',1), +(6,1,6478,'Opening',1), +(6,1,6603,'Attack',1), +(6,1,7266,'Duel',1), +(6,1,7267,'Grovel',1), +(6,1,7355,'Stuck',1), +(6,1,7376,'Defensive Stance Passive',0), +(6,1,7381,'Berserker Stance Passive',0), +(6,1,8386,'Attacking',1), +(6,1,8737,'Mail',1), +(6,1,9077,'Leather',1), +(6,1,9078,'Cloth',1), +(6,1,9116,'Shield',1), +(6,1,9125,'Generic',1), +(6,1,20549,'War Stomp',1), +(6,1,20550,'Endurance',1), +(6,1,20551,'Nature Resistance',1), +(6,1,20552,'Cultivation',1), +(6,1,21156,'Battle Stance Passive',0), +(6,1,21651,'Opening',1), +(6,1,21652,'Closing',1), +(6,1,22027,'Remove Insignia',1), +(6,1,22810,'Opening - No Text',1), +(6,1,32215,'Victorious State',1), +(6,3,75,'Auto Shot',1), +(6,3,81,'Dodge',1), +(6,3,196,'One-Handed Axes',1), +(6,3,203,'Unarmed',1), +(6,3,204,'Defense',1), +(6,3,266,'Guns',1), +(6,3,522,'SPELLDEFENSE(DND)',1), +(6,3,669,'Language Orcish',1), +(6,3,670,'Language Taurahe',1), +(6,3,2382,'Generic',1), +(6,3,2479,'Honorless Target',1), +(6,3,2973,'Raptor Strike',1), +(6,3,3050,'Detect',1), +(6,3,3365,'Opening',1), +(6,3,6233,'Closing',1), +(6,3,6246,'Closing',1), +(6,3,6247,'Opening',1), +(6,3,6477,'Opening',1), +(6,3,6478,'Opening',1), +(6,3,6603,'Attack',1), +(6,3,7266,'Duel',1), +(6,3,7267,'Grovel',1), +(6,3,7355,'Stuck',1), +(6,3,8386,'Attacking',1), +(6,3,9077,'Leather',1), +(6,3,9078,'Cloth',1), +(6,3,9125,'Generic',1), +(6,3,13358,'Defensive State(DND)',1), +(6,3,20549,'War Stomp',1), +(6,3,20550,'Endurance',1), +(6,3,20551,'Nature Resistance',1), +(6,3,20552,'Cultivation',1), +(6,3,21651,'Opening',1), +(6,3,21652,'Closing',1), +(6,3,22027,'Remove Insignia',1), +(6,3,22810,'Opening - No Text',1), +(6,3,24949,'Defensive State 2(DND)',1), +(6,3,34082,'Advantaged State(DND)',1), +(6,7,81,'Dodge',1), +(6,7,107,'Block',1), +(6,7,198,'One-Handed Maces',1), +(6,7,203,'Unarmed',1), +(6,7,204,'Defense',1), +(6,7,227,'Staves',1), +(6,7,331,'Healing Wave',1), +(6,7,403,'Lightning Bolt',1), +(6,7,522,'SPELLDEFENSE(DND)',1), +(6,7,669,'Language Orcish',1), +(6,7,670,'Language Taurahe',1), +(6,7,2382,'Generic',1), +(6,7,2479,'Honorless Target',1), +(6,7,3050,'Detect',1), +(6,7,3365,'Opening',1), +(6,7,6233,'Closing',1), +(6,7,6246,'Closing',1), +(6,7,6247,'Opening',1), +(6,7,6477,'Opening',1), +(6,7,6478,'Opening',1), +(6,7,6603,'Attack',1), +(6,7,7266,'Duel',1), +(6,7,7267,'Grovel',1), +(6,7,7355,'Stuck',1), +(6,7,8386,'Attacking',1), +(6,7,9077,'Leather',1), +(6,7,9078,'Cloth',1), +(6,7,9116,'Shield',1), +(6,7,9125,'Generic',1), +(6,7,20549,'War Stomp',1), +(6,7,20550,'Endurance',1), +(6,7,20551,'Nature Resistance',1), +(6,7,20552,'Cultivation',1), +(6,7,21651,'Opening',1), +(6,7,21652,'Closing',1), +(6,7,22027,'Remove Insignia',1), +(6,7,22810,'Opening - No Text',1), +(6,7,27763,'Totem',1), +(6,11,81,'Dodge',1), +(6,11,198,'One-Handed Maces',1), +(6,11,203,'Unarmed',1), +(6,11,204,'Defense',1), +(6,11,227,'Staves',1), +(6,11,522,'SPELLDEFENSE(DND)',1), +(6,11,669,'Language Orcish',1), +(6,11,670,'Language Taurahe',1), +(6,11,1178,'Bear Form(Passive)',0), +(6,11,2382,'Generic',1), +(6,11,2479,'Honorless Target',1), +(6,11,3025,'Cat Form(Passive)',0), +(6,11,3050,'Detect',1), +(6,11,3365,'Opening',1), +(6,11,5176,'Wrath',1), +(6,11,5185,'Healing Touch',1), +(6,11,5419,'Travel Form(Passive)',0), +(6,11,5420,'Tree of Life',0), +(6,11,5421,'Aquatic Form(Passive)',0), +(6,11,6233,'Closing',1), +(6,11,6246,'Closing',1), +(6,11,6247,'Opening',1), +(6,11,6477,'Opening',1), +(6,11,6478,'Opening',1), +(6,11,6603,'Attack',1), +(6,11,7266,'Duel',1), +(6,11,7267,'Grovel',1), +(6,11,7355,'Stuck',1), +(6,11,8386,'Attacking',1), +(6,11,9077,'Leather',1), +(6,11,9078,'Cloth',1), +(6,11,9125,'Generic',1), +(6,11,9635,'Dire Bear Form(Passive)',0), +(6,11,20549,'War Stomp',1), +(6,11,20550,'Endurance',1), +(6,11,20551,'Nature Resistance',1), +(6,11,20552,'Cultivation',1), +(6,11,21178,'Bear Form(Passive2)',0), +(6,11,21651,'Opening',1), +(6,11,21652,'Closing',1), +(6,11,22027,'Remove Insignia',1), +(6,11,22810,'Opening - No Text',1), +(6,11,24905,'Moonkin Form(Passive)',0), +(6,11,27764,'Fetish',1), +(6,11,33948,'Flight Form(Passive)',0), +(6,11,34123,'Tree of Life(Passive)',0), +(6,11,40121,'Swift Flight Form(Passive)',0), +(7,1,78,'Heroic Strike',1), +(7,1,81,'Dodge',1), +(7,1,107,'Block',1), +(7,1,198,'One-Handed Maces',1), +(7,1,201,'One-Handed Swords',1), +(7,1,203,'Unarmed',1), +(7,1,204,'Defense',1), +(7,1,522,'SPELLDEFENSE(DND)',1), +(7,1,668,'Language Common',1), +(7,1,1180,'Daggers',1), +(7,1,2382,'Generic',1), +(7,1,2457,'Battle Stance',1), +(7,1,2479,'Honorless Target',1), +(7,1,3050,'Detect',1), +(7,1,3365,'Opening',1), +(7,1,5301,'Defensive State(DND)',1), +(7,1,6233,'Closing',1), +(7,1,6246,'Closing',1), +(7,1,6247,'Opening',1), +(7,1,6477,'Opening',1), +(7,1,6478,'Opening',1), +(7,1,6603,'Attack',1), +(7,1,7266,'Duel',1), +(7,1,7267,'Grovel',1), +(7,1,7340,'Language Gnomish',1), +(7,1,7355,'Stuck',1), +(7,1,7376,'Defensive Stance Passive',0), +(7,1,7381,'Berserker Stance Passive',0), +(7,1,8386,'Attacking',1), +(7,1,8737,'Mail',1), +(7,1,9077,'Leather',1), +(7,1,9078,'Cloth',1), +(7,1,9116,'Shield',1), +(7,1,9125,'Generic',1), +(7,1,20589,'Escape Artist',1), +(7,1,20591,'Expansive Mind',1), +(7,1,20592,'Arcane Resistance',1), +(7,1,20593,'Engineering Specialization',1), +(7,1,21156,'Battle Stance Passive',0), +(7,1,21651,'Opening',1), +(7,1,21652,'Closing',1), +(7,1,22027,'Remove Insignia',1), +(7,1,22810,'Opening - No Text',1), +(7,1,32215,'Victorious State',1), +(7,4,81,'Dodge',1), +(7,4,203,'Unarmed',1), +(7,4,204,'Defense',1), +(7,4,522,'SPELLDEFENSE(DND)',1), +(7,4,668,'Language Common',1), +(7,4,1180,'Daggers',1), +(7,4,1752,'Sinister Strike',1), +(7,4,2098,'Eviscerate',1), +(7,4,2382,'Generic',1), +(7,4,2479,'Honorless Target',1), +(7,4,2567,'Thrown',1), +(7,4,2764,'Throw',1), +(7,4,3050,'Detect',1), +(7,4,3365,'Opening',1), +(7,4,6233,'Closing',1), +(7,4,6246,'Closing',1), +(7,4,6247,'Opening',1), +(7,4,6477,'Opening',1), +(7,4,6478,'Opening',1), +(7,4,6603,'Attack',1), +(7,4,7266,'Duel',1), +(7,4,7267,'Grovel',1), +(7,4,7340,'Language Gnomish',1), +(7,4,7355,'Stuck',1), +(7,4,8386,'Attacking',1), +(7,4,9077,'Leather',1), +(7,4,9078,'Cloth',1), +(7,4,9125,'Generic',1), +(7,4,16092,'Defensive State(DND)',1), +(7,4,20589,'Escape Artist',1), +(7,4,20591,'Expansive Mind',1), +(7,4,20592,'Arcane Resistance',1), +(7,4,20593,'Engineering Specialization',1), +(7,4,21184,'Rogue Passive(DND)',1), +(7,4,21651,'Opening',1), +(7,4,21652,'Closing',1), +(7,4,22027,'Remove Insignia',1), +(7,4,22810,'Opening - No Text',1), +(7,8,81,'Dodge',1), +(7,8,133,'Fireball',1), +(7,8,168,'Frost Armor',1), +(7,8,203,'Unarmed',1), +(7,8,204,'Defense',1), +(7,8,227,'Staves',1), +(7,8,522,'SPELLDEFENSE(DND)',1), +(7,8,668,'Language Common',1), +(7,8,2382,'Generic',1), +(7,8,2479,'Honorless Target',1), +(7,8,3050,'Detect',1), +(7,8,3365,'Opening',1), +(7,8,5009,'Wands',1), +(7,8,5019,'Shoot',1), +(7,8,6233,'Closing',1), +(7,8,6246,'Closing',1), +(7,8,6247,'Opening',1), +(7,8,6477,'Opening',1), +(7,8,6478,'Opening',1), +(7,8,6603,'Attack',1), +(7,8,7266,'Duel',1), +(7,8,7267,'Grovel',1), +(7,8,7340,'Language Gnomish',1), +(7,8,7355,'Stuck',1), +(7,8,8386,'Attacking',1), +(7,8,9078,'Cloth',1), +(7,8,9125,'Generic',1), +(7,8,20589,'Escape Artist',1), +(7,8,20591,'Expansive Mind',1), +(7,8,20592,'Arcane Resistance',1), +(7,8,20593,'Engineering Specialization',1), +(7,8,21651,'Opening',1), +(7,8,21652,'Closing',1), +(7,8,22027,'Remove Insignia',1), +(7,8,22810,'Opening - No Text',1), +(7,9,81,'Dodge',1), +(7,9,203,'Unarmed',1), +(7,9,204,'Defense',1), +(7,9,522,'SPELLDEFENSE(DND)',1), +(7,9,668,'Language Common',1), +(7,9,686,'Shadow Bolt',1), +(7,9,687,'Demon Skin',1), +(7,9,1180,'Daggers',1), +(7,9,2382,'Generic',1), +(7,9,2479,'Honorless Target',1), +(7,9,3050,'Detect',1), +(7,9,3365,'Opening',1), +(7,9,5009,'Wands',1), +(7,9,5019,'Shoot',1), +(7,9,6233,'Closing',1), +(7,9,6246,'Closing',1), +(7,9,6247,'Opening',1), +(7,9,6477,'Opening',1), +(7,9,6478,'Opening',1), +(7,9,6603,'Attack',1), +(7,9,7266,'Duel',1), +(7,9,7267,'Grovel',1), +(7,9,7340,'Language Gnomish',1), +(7,9,7355,'Stuck',1), +(7,9,8386,'Attacking',1), +(7,9,9078,'Cloth',1), +(7,9,9125,'Generic',1), +(7,9,20589,'Escape Artist',1), +(7,9,20591,'Expansive Mind',1), +(7,9,20592,'Arcane Resistance',1), +(7,9,20593,'Engineering Specialization',1), +(7,9,21651,'Opening',1), +(7,9,21652,'Closing',1), +(7,9,22027,'Remove Insignia',1), +(7,9,22810,'Opening - No Text',1), +(8,1,78,'Heroic Strike',1), +(8,1,81,'Dodge',1), +(8,1,107,'Block',1), +(8,1,196,'One-Handed Axes',1), +(8,1,203,'Unarmed',1), +(8,1,204,'Defense',1), +(8,1,522,'SPELLDEFENSE(DND)',1), +(8,1,669,'Language Orcish',1), +(8,1,1180,'Daggers',1), +(8,1,2382,'Generic',1), +(8,1,2457,'Battle Stance',1), +(8,1,2479,'Honorless Target',1), +(8,1,2567,'Thrown',1), +(8,1,2764,'Throw',1), +(8,1,3050,'Detect',1), +(8,1,3365,'Opening',1), +(8,1,5301,'Defensive State(DND)',1), +(8,1,6233,'Closing',1), +(8,1,6246,'Closing',1), +(8,1,6247,'Opening',1), +(8,1,6477,'Opening',1), +(8,1,6478,'Opening',1), +(8,1,6603,'Attack',1), +(8,1,7266,'Duel',1), +(8,1,7267,'Grovel',1), +(8,1,7341,'Language Troll',1), +(8,1,7355,'Stuck',1), +(8,1,7376,'Defensive Stance Passive',0), +(8,1,7381,'Berserker Stance Passive',0), +(8,1,8386,'Attacking',1), +(8,1,8737,'Mail',1), +(8,1,9077,'Leather',1), +(8,1,9078,'Cloth',1), +(8,1,9116,'Shield',1), +(8,1,9125,'Generic',1), +(8,1,20555,'Regeneration',1), +(8,1,20557,'Beast Slaying',1), +(8,1,20558,'Throwing Specialization',1), +(8,1,21156,'Battle Stance Passive',0), +(8,1,21651,'Opening',1), +(8,1,21652,'Closing',1), +(8,1,22027,'Remove Insignia',1), +(8,1,22810,'Opening - No Text',1), +(8,1,26290,'Bow Specialization',1), +(8,1,26296,'Berserking',1), +(8,1,32215,'Victorious State',1), +(8,3,75,'Auto Shot',1), +(8,3,81,'Dodge',1), +(8,3,196,'One-Handed Axes',1), +(8,3,203,'Unarmed',1), +(8,3,204,'Defense',1), +(8,3,264,'Bows',1), +(8,3,522,'SPELLDEFENSE(DND)',1), +(8,3,669,'Language Orcish',1), +(8,3,2382,'Generic',1), +(8,3,2479,'Honorless Target',1), +(8,3,2973,'Raptor Strike',1), +(8,3,3050,'Detect',1), +(8,3,3365,'Opening',1), +(8,3,6233,'Closing',1), +(8,3,6246,'Closing',1), +(8,3,6247,'Opening',1), +(8,3,6477,'Opening',1), +(8,3,6478,'Opening',1), +(8,3,6603,'Attack',1), +(8,3,7266,'Duel',1), +(8,3,7267,'Grovel',1), +(8,3,7341,'Language Troll',1), +(8,3,7355,'Stuck',1), +(8,3,8386,'Attacking',1), +(8,3,9077,'Leather',1), +(8,3,9078,'Cloth',1), +(8,3,9125,'Generic',1), +(8,3,13358,'Defensive State(DND)',1), +(8,3,20554,'Berserking',1), +(8,3,20555,'Regeneration',1), +(8,3,20557,'Beast Slaying',1), +(8,3,20558,'Throwing Specialization',1), +(8,3,21651,'Opening',1), +(8,3,21652,'Closing',1), +(8,3,22027,'Remove Insignia',1), +(8,3,22810,'Opening - No Text',1), +(8,3,24949,'Defensive State 2(DND)',1), +(8,3,26290,'Bow Specialization',1), +(8,3,34082,'Advantaged State(DND)',1), +(8,4,81,'Dodge',1), +(8,4,203,'Unarmed',1), +(8,4,204,'Defense',1), +(8,4,522,'SPELLDEFENSE(DND)',1), +(8,4,669,'Language Orcish',1), +(8,4,1180,'Daggers',1), +(8,4,1752,'Sinister Strike',1), +(8,4,2098,'Eviscerate',1), +(8,4,2382,'Generic',1), +(8,4,2479,'Honorless Target',1), +(8,4,2567,'Thrown',1), +(8,4,2764,'Throw',1), +(8,4,3050,'Detect',1), +(8,4,3365,'Opening',1), +(8,4,6233,'Closing',1), +(8,4,6246,'Closing',1), +(8,4,6247,'Opening',1), +(8,4,6477,'Opening',1), +(8,4,6478,'Opening',1), +(8,4,6603,'Attack',1), +(8,4,7266,'Duel',1), +(8,4,7267,'Grovel',1), +(8,4,7341,'Language Troll',1), +(8,4,7355,'Stuck',1), +(8,4,8386,'Attacking',1), +(8,4,9077,'Leather',1), +(8,4,9078,'Cloth',1), +(8,4,9125,'Generic',1), +(8,4,16092,'Defensive State(DND)',1), +(8,4,20555,'Regeneration',1), +(8,4,20557,'Beast Slaying',1), +(8,4,20558,'Throwing Specialization',1), +(8,4,21184,'Rogue Passive(DND)',1), +(8,4,21651,'Opening',1), +(8,4,21652,'Closing',1), +(8,4,22027,'Remove Insignia',1), +(8,4,22810,'Opening - No Text',1), +(8,4,26290,'Bow Specialization',1), +(8,4,26297,'Berserking',1), +(8,5,81,'Dodge',1), +(8,5,198,'One-Handed Maces',1), +(8,5,203,'Unarmed',1), +(8,5,204,'Defense',1), +(8,5,522,'SPELLDEFENSE(DND)',1), +(8,5,585,'Smite',1), +(8,5,669,'Language Orcish',1), +(8,5,2050,'Lesser Heal',1), +(8,5,2382,'Generic',1), +(8,5,2479,'Honorless Target',1), +(8,5,3050,'Detect',1), +(8,5,3365,'Opening',1), +(8,5,5009,'Wands',1), +(8,5,5019,'Shoot',1), +(8,5,6233,'Closing',1), +(8,5,6246,'Closing',1), +(8,5,6247,'Opening',1), +(8,5,6477,'Opening',1), +(8,5,6478,'Opening',1), +(8,5,6603,'Attack',1), +(8,5,7266,'Duel',1), +(8,5,7267,'Grovel',1), +(8,5,7341,'Language Troll',1), +(8,5,7355,'Stuck',1), +(8,5,8386,'Attacking',1), +(8,5,9078,'Cloth',1), +(8,5,9125,'Generic',1), +(8,5,20554,'Berserking',1), +(8,5,20555,'Regeneration',1), +(8,5,20557,'Beast Slaying',1), +(8,5,20558,'Throwing Specialization',1), +(8,5,21651,'Opening',1), +(8,5,21652,'Closing',1), +(8,5,22027,'Remove Insignia',1), +(8,5,22810,'Opening - No Text',1), +(8,5,26290,'Bow Specialization',1), +(8,7,81,'Dodge',1), +(8,7,107,'Block',1), +(8,7,198,'One-Handed Maces',1), +(8,7,203,'Unarmed',1), +(8,7,204,'Defense',1), +(8,7,227,'Staves',1), +(8,7,331,'Healing Wave',1), +(8,7,403,'Lightning Bolt',1), +(8,7,522,'SPELLDEFENSE(DND)',1), +(8,7,669,'Language Orcish',1), +(8,7,2382,'Generic',1), +(8,7,2479,'Honorless Target',1), +(8,7,3050,'Detect',1), +(8,7,3365,'Opening',1), +(8,7,6233,'Closing',1), +(8,7,6246,'Closing',1), +(8,7,6247,'Opening',1), +(8,7,6477,'Opening',1), +(8,7,6478,'Opening',1), +(8,7,6603,'Attack',1), +(8,7,7266,'Duel',1), +(8,7,7267,'Grovel',1), +(8,7,7341,'Language Troll',1), +(8,7,7355,'Stuck',1), +(8,7,8386,'Attacking',1), +(8,7,9077,'Leather',1), +(8,7,9078,'Cloth',1), +(8,7,9116,'Shield',1), +(8,7,9125,'Generic',1), +(8,7,20554,'Berserking',1), +(8,7,20555,'Regeneration',1), +(8,7,20557,'Beast Slaying',1), +(8,7,20558,'Throwing Specialization',1), +(8,7,21651,'Opening',1), +(8,7,21652,'Closing',1), +(8,7,22027,'Remove Insignia',1), +(8,7,22810,'Opening - No Text',1), +(8,7,26290,'Bow Specialization',1), +(8,7,27763,'Totem',1), +(8,8,81,'Dodge',1), +(8,8,133,'Fireball',1), +(8,8,168,'Frost Armor',1), +(8,8,203,'Unarmed',1), +(8,8,204,'Defense',1), +(8,8,227,'Staves',1), +(8,8,522,'SPELLDEFENSE(DND)',1), +(8,8,669,'Language Orcish',1), +(8,8,2382,'Generic',1), +(8,8,2479,'Honorless Target',1), +(8,8,3050,'Detect',1), +(8,8,3365,'Opening',1), +(8,8,5009,'Wands',1), +(8,8,5019,'Shoot',1), +(8,8,6233,'Closing',1), +(8,8,6246,'Closing',1), +(8,8,6247,'Opening',1), +(8,8,6477,'Opening',1), +(8,8,6478,'Opening',1), +(8,8,6603,'Attack',1), +(8,8,7266,'Duel',1), +(8,8,7267,'Grovel',1), +(8,8,7341,'Language Troll',1), +(8,8,7355,'Stuck',1), +(8,8,8386,'Attacking',1), +(8,8,9078,'Cloth',1), +(8,8,9125,'Generic',1), +(8,8,20554,'Berserking',1), +(8,8,20555,'Regeneration',1), +(8,8,20557,'Beast Slaying',1), +(8,8,20558,'Throwing Specialization',1), +(8,8,21651,'Opening',1), +(8,8,21652,'Closing',1), +(8,8,22027,'Remove Insignia',1), +(8,8,22810,'Opening - No Text',1), +(8,8,26290,'Bow Specialization',1), +(10,2,81,'Dodge',1), +(10,2,107,'Block',1), +(10,2,201,'One-Handed Swords',1), +(10,2,202,'Two-Handed Swords',1), +(10,2,203,'Unarmed',1), +(10,2,204,'Defense',1), +(10,2,522,'SPELLDEFENSE(DND)',1), +(10,2,635,'Holy Light',1), +(10,2,669,'Language Orcish',1), +(10,2,813,'Language Thalassian',1), +(10,2,822,'Magic Resistance',1), +(10,2,2382,'Generic',1), +(10,2,2479,'Honorless Target',1), +(10,2,3050,'Detect',1), +(10,2,3365,'Opening',1), +(10,2,6233,'Closing',1), +(10,2,6246,'Closing',1), +(10,2,6247,'Opening',1), +(10,2,6477,'Opening',1), +(10,2,6478,'Opening',1), +(10,2,6603,'Attack',1), +(10,2,7266,'Duel',1), +(10,2,7267,'Grovel',1), +(10,2,7355,'Stuck',1), +(10,2,8386,'Attacking',1), +(10,2,8737,'Mail',1), +(10,2,9077,'Leather',1), +(10,2,9078,'Cloth',1), +(10,2,9116,'Shield',1), +(10,2,9125,'Generic',1), +(10,2,21084,'Seal of Righteousness',1), +(10,2,21651,'Opening',1), +(10,2,21652,'Closing',1), +(10,2,22027,'Remove Insignia',1), +(10,2,22810,'Opening - No Text',1), +(10,2,27762,'Libram',1), +(10,2,28730,'Arcane Torrent',1), +(10,2,28734,'Mana Tap',1), +(10,2,28877,'Arcane Affinity',1), +(10,3,75,'Auto Shot',1), +(10,3,81,'Dodge',1), +(10,3,203,'Unarmed',1), +(10,3,204,'Defense',1), +(10,3,264,'Bows',1), +(10,3,522,'SPELLDEFENSE(DND)',1), +(10,3,669,'Language Orcish',1), +(10,3,813,'Language Thalassian',1), +(10,3,822,'Magic Resistance',1), +(10,3,1180,'Daggers',1), +(10,3,2382,'Generic',1), +(10,3,2479,'Honorless Target',1), +(10,3,2973,'Raptor Strike',1), +(10,3,3050,'Detect',1), +(10,3,3365,'Opening',1), +(10,3,6233,'Closing',1), +(10,3,6246,'Closing',1), +(10,3,6247,'Opening',1), +(10,3,6477,'Opening',1), +(10,3,6478,'Opening',1), +(10,3,6603,'Attack',1), +(10,3,7266,'Duel',1), +(10,3,7267,'Grovel',1), +(10,3,7355,'Stuck',1), +(10,3,8386,'Attacking',1), +(10,3,9077,'Leather',1), +(10,3,9078,'Cloth',1), +(10,3,9125,'Generic',1), +(10,3,13358,'Defensive State(DND)',1), +(10,3,21651,'Opening',1), +(10,3,21652,'Closing',1), +(10,3,22027,'Remove Insignia',1), +(10,3,22810,'Opening - No Text',1), +(10,3,24949,'Defensive State 2(DND)',1), +(10,3,28730,'Arcane Torrent',1), +(10,3,28734,'Mana Tap',1), +(10,3,28877,'Arcane Affinity',1), +(10,3,34082,'Advantaged State(DND)',1), +(10,4,81,'Dodge',1), +(10,4,203,'Unarmed',1), +(10,4,204,'Defense',1), +(10,4,522,'SPELLDEFENSE(DND)',1), +(10,4,669,'Language Orcish',1), +(10,4,813,'Language Thalassian',1), +(10,4,822,'Magic Resistance',1), +(10,4,1180,'Daggers',1), +(10,4,1752,'Sinister Strike',1), +(10,4,2098,'Eviscerate',1), +(10,4,2382,'Generic',1), +(10,4,2479,'Honorless Target',1), +(10,4,2567,'Thrown',1), +(10,4,2764,'Throw',1), +(10,4,3050,'Detect',1), +(10,4,3365,'Opening',1), +(10,4,6233,'Closing',1), +(10,4,6246,'Closing',1), +(10,4,6247,'Opening',1), +(10,4,6477,'Opening',1), +(10,4,6478,'Opening',1), +(10,4,6603,'Attack',1), +(10,4,7266,'Duel',1), +(10,4,7267,'Grovel',1), +(10,4,7355,'Stuck',1), +(10,4,8386,'Attacking',1), +(10,4,9077,'Leather',1), +(10,4,9078,'Cloth',1), +(10,4,9125,'Generic',1), +(10,4,16092,'Defensive State(DND)',1), +(10,4,21184,'Rogue Passive(DND)',1), +(10,4,21651,'Opening',1), +(10,4,21652,'Closing',1), +(10,4,22027,'Remove Insignia',1), +(10,4,22810,'Opening - No Text',1), +(10,4,25046,'Arcane Torrent',1), +(10,4,28734,'Mana Tap',1), +(10,4,28877,'Arcane Affinity',1), +(10,5,81,'Dodge',1), +(10,5,198,'One-Handed Maces',1), +(10,5,203,'Unarmed',1), +(10,5,204,'Defense',1), +(10,5,522,'SPELLDEFENSE(DND)',1), +(10,5,585,'Smite',1), +(10,5,669,'Language Orcish',1), +(10,5,813,'Language Thalassian',1), +(10,5,822,'Magic Resistance',1), +(10,5,2050,'Lesser Heal',1), +(10,5,2382,'Generic',1), +(10,5,2479,'Honorless Target',1), +(10,5,3050,'Detect',1), +(10,5,3365,'Opening',1), +(10,5,5009,'Wands',1), +(10,5,5019,'Shoot',1), +(10,5,6233,'Closing',1), +(10,5,6246,'Closing',1), +(10,5,6247,'Opening',1), +(10,5,6477,'Opening',1), +(10,5,6478,'Opening',1), +(10,5,6603,'Attack',1), +(10,5,7266,'Duel',1), +(10,5,7267,'Grovel',1), +(10,5,7355,'Stuck',1), +(10,5,8386,'Attacking',1), +(10,5,9078,'Cloth',1), +(10,5,9125,'Generic',1), +(10,5,21651,'Opening',1), +(10,5,21652,'Closing',1), +(10,5,22027,'Remove Insignia',1), +(10,5,22810,'Opening - No Text',1), +(10,5,28730,'Arcane Torrent',1), +(10,5,28734,'Mana Tap',1), +(10,5,28877,'Arcane Affinity',1), +(10,8,81,'Dodge',1), +(10,8,133,'Fireball',1), +(10,8,168,'Frost Armor',1), +(10,8,203,'Unarmed',1), +(10,8,204,'Defense',1), +(10,8,227,'Staves',1), +(10,8,522,'SPELLDEFENSE(DND)',1), +(10,8,669,'Language Orcish',1), +(10,8,813,'Language Thalassian',1), +(10,8,822,'Magic Resistance',1), +(10,8,2382,'Generic',1), +(10,8,2479,'Honorless Target',1), +(10,8,3050,'Detect',1), +(10,8,3365,'Opening',1), +(10,8,5009,'Wands',1), +(10,8,5019,'Shoot',1), +(10,8,6233,'Closing',1), +(10,8,6246,'Closing',1), +(10,8,6247,'Opening',1), +(10,8,6477,'Opening',1), +(10,8,6478,'Opening',1), +(10,8,6603,'Attack',1), +(10,8,7266,'Duel',1), +(10,8,7267,'Grovel',1), +(10,8,7355,'Stuck',1), +(10,8,8386,'Attacking',1), +(10,8,9078,'Cloth',1), +(10,8,9125,'Generic',1), +(10,8,21651,'Opening',1), +(10,8,21652,'Closing',1), +(10,8,22027,'Remove Insignia',1), +(10,8,22810,'Opening - No Text',1), +(10,8,28730,'Arcane Torrent',1), +(10,8,28734,'Mana Tap',1), +(10,8,28877,'Arcane Affinity',1), +(10,9,81,'Dodge',1), +(10,9,203,'Unarmed',1), +(10,9,204,'Defense',1), +(10,9,522,'SPELLDEFENSE(DND)',1), +(10,9,669,'Language Orcish',1), +(10,9,686,'Shadow Bolt',1), +(10,9,687,'Demon Skin',1), +(10,9,813,'Language Thalassian',1), +(10,9,822,'Magic Resistance',1), +(10,9,1180,'Daggers',1), +(10,9,2382,'Generic',1), +(10,9,2479,'Honorless Target',1), +(10,9,3050,'Detect',1), +(10,9,3365,'Opening',1), +(10,9,5009,'Wands',1), +(10,9,5019,'Shoot',1), +(10,9,6233,'Closing',1), +(10,9,6246,'Closing',1), +(10,9,6247,'Opening',1), +(10,9,6477,'Opening',1), +(10,9,6478,'Opening',1), +(10,9,6603,'Attack',1), +(10,9,7266,'Duel',1), +(10,9,7267,'Grovel',1), +(10,9,7355,'Stuck',1), +(10,9,8386,'Attacking',1), +(10,9,9078,'Cloth',1), +(10,9,9125,'Generic',1), +(10,9,21651,'Opening',1), +(10,9,21652,'Closing',1), +(10,9,22027,'Remove Insignia',1), +(10,9,22810,'Opening - No Text',1), +(10,9,28730,'Arcane Torrent',1), +(10,9,28734,'Mana Tap',1), +(10,9,28877,'Arcane Affinity',1), +(11,1,78,'Heroic Strike',1), +(11,1,81,'Dodge',1), +(11,1,107,'Block',1), +(11,1,198,'One-Handed Maces',1), +(11,1,201,'One-Handed Swords',1), +(11,1,202,'Two-Handed Swords',1), +(11,1,203,'Unarmed',1), +(11,1,204,'Defense',1), +(11,1,522,'SPELLDEFENSE(DND)',1), +(11,1,668,'Language Common',1), +(11,1,2382,'Generic',1), +(11,1,2457,'Battle Stance',1), +(11,1,2479,'Honorless Target',1), +(11,1,3050,'Detect',1), +(11,1,3365,'Opening',1), +(11,1,5301,'Defensive State(DND)',1), +(11,1,6233,'Closing',1), +(11,1,6246,'Closing',1), +(11,1,6247,'Opening',1), +(11,1,6477,'Opening',1), +(11,1,6478,'Opening',1), +(11,1,6562,'Heroic Presence',1), +(11,1,6603,'Attack',1), +(11,1,7266,'Duel',1), +(11,1,7267,'Grovel',1), +(11,1,7355,'Stuck',1), +(11,1,7376,'Defensive Stance Passive',0), +(11,1,7381,'Berserker Stance Passive',0), +(11,1,8386,'Attacking',1), +(11,1,8737,'Mail',1), +(11,1,9077,'Leather',1), +(11,1,9078,'Cloth',1), +(11,1,9116,'Shield',1), +(11,1,9125,'Generic',1), +(11,1,20579,'Shadow Resistance',1), +(11,1,21156,'Battle Stance Passive',0), +(11,1,21651,'Opening',1), +(11,1,21652,'Closing',1), +(11,1,22027,'Remove Insignia',1), +(11,1,22810,'Opening - No Text',1), +(11,1,28875,'Gemcutting',1), +(11,1,28880,'Gift of the Naaru',1), +(11,1,29932,'Language Draenei',1), +(11,1,32215,'Victorious State',1), +(11,2,81,'Dodge',1), +(11,2,107,'Block',1), +(11,2,198,'One-Handed Maces',1), +(11,2,199,'Two-Handed Maces',1), +(11,2,203,'Unarmed',1), +(11,2,204,'Defense',1), +(11,2,522,'SPELLDEFENSE(DND)',1), +(11,2,635,'Holy Light',1), +(11,2,668,'Language Common',1), +(11,2,2382,'Generic',1), +(11,2,2479,'Honorless Target',1), +(11,2,3050,'Detect',1), +(11,2,3365,'Opening',1), +(11,2,6233,'Closing',1), +(11,2,6246,'Closing',1), +(11,2,6247,'Opening',1), +(11,2,6477,'Opening',1), +(11,2,6478,'Opening',1), +(11,2,6562,'Heroic Presence',1), +(11,2,6603,'Attack',1), +(11,2,7266,'Duel',1), +(11,2,7267,'Grovel',1), +(11,2,7355,'Stuck',1), +(11,2,8386,'Attacking',1), +(11,2,8737,'Mail',1), +(11,2,9077,'Leather',1), +(11,2,9078,'Cloth',1), +(11,2,9116,'Shield',1), +(11,2,9125,'Generic',1), +(11,2,21084,'Seal of Righteousness',1), +(11,2,20579,'Shadow Resistance',1), +(11,2,21651,'Opening',1), +(11,2,21652,'Closing',1), +(11,2,22027,'Remove Insignia',1), +(11,2,22810,'Opening - No Text',1), +(11,2,27762,'Libram',1), +(11,2,28875,'Gemcutting',1), +(11,2,28880,'Gift of the Naaru',1), +(11,2,29932,'Language Draenei',1), +(11,3,75,'Auto Shot',1), +(11,3,81,'Dodge',1), +(11,3,201,'One-Handed Swords',1), +(11,3,203,'Unarmed',1), +(11,3,204,'Defense',1), +(11,3,522,'SPELLDEFENSE(DND)',1), +(11,3,668,'Language Common',1), +(11,3,2382,'Generic',1), +(11,3,2479,'Honorless Target',1), +(11,3,2973,'Raptor Strike',1), +(11,3,3050,'Detect',1), +(11,3,3365,'Opening',1), +(11,3,5011,'Crossbows',1), +(11,3,6233,'Closing',1), +(11,3,6246,'Closing',1), +(11,3,6247,'Opening',1), +(11,3,6477,'Opening',1), +(11,3,6478,'Opening',1), +(11,3,6562,'Heroic Presence',1), +(11,3,6603,'Attack',1), +(11,3,7266,'Duel',1), +(11,3,7267,'Grovel',1), +(11,3,7355,'Stuck',1), +(11,3,8386,'Attacking',1), +(11,3,9077,'Leather',1), +(11,3,9078,'Cloth',1), +(11,3,9125,'Generic',1), +(11,3,13358,'Defensive State(DND)',1), +(11,3,20579,'Shadow Resistance',1), +(11,3,21651,'Opening',1), +(11,3,21652,'Closing',1), +(11,3,22027,'Remove Insignia',1), +(11,3,22810,'Opening - No Text',1), +(11,3,24949,'Defensive State 2(DND)',1), +(11,3,28875,'Gemcutting',1), +(11,3,28880,'Gift of the Naaru',1), +(11,3,29932,'Language Draenei',1), +(11,3,34082,'Advantaged State(DND)',1), +(11,5,81,'Dodge',1), +(11,5,198,'One-Handed Maces',1), +(11,5,203,'Unarmed',1), +(11,5,204,'Defense',1), +(11,5,522,'SPELLDEFENSE(DND)',1), +(11,5,585,'Smite',1), +(11,5,668,'Language Common',1), +(11,5,2050,'Lesser Heal',1), +(11,5,2382,'Generic',1), +(11,5,2479,'Honorless Target',1), +(11,5,3050,'Detect',1), +(11,5,3365,'Opening',1), +(11,5,5009,'Wands',1), +(11,5,5019,'Shoot',1), +(11,5,6233,'Closing',1), +(11,5,6246,'Closing',1), +(11,5,6247,'Opening',1), +(11,5,6477,'Opening',1), +(11,5,6478,'Opening',1), +(11,5,6603,'Attack',1), +(11,5,7266,'Duel',1), +(11,5,7267,'Grovel',1), +(11,5,7355,'Stuck',1), +(11,5,8386,'Attacking',1), +(11,5,9078,'Cloth',1), +(11,5,9125,'Generic',1), +(11,5,20579,'Shadow Resistance',1), +(11,5,21651,'Opening',1), +(11,5,21652,'Closing',1), +(11,5,22027,'Remove Insignia',1), +(11,5,22810,'Opening - No Text',1), +(11,5,28875,'Gemcutting',1), +(11,5,28878,'Inspiring Presence',1), +(11,5,28880,'Gift of the Naaru',1), +(11,5,29932,'Language Draenei',1), +(11,7,81,'Dodge',1), +(11,7,107,'Block',1), +(11,7,198,'One-Handed Maces',1), +(11,7,203,'Unarmed',1), +(11,7,204,'Defense',1), +(11,7,227,'Staves',1), +(11,7,331,'Healing Wave',1), +(11,7,403,'Lightning Bolt',1), +(11,7,522,'SPELLDEFENSE(DND)',1), +(11,7,668,'Language Common',1), +(11,7,2382,'Generic',1), +(11,7,2479,'Honorless Target',1), +(11,7,3050,'Detect',1), +(11,7,3365,'Opening',1), +(11,7,6233,'Closing',1), +(11,7,6246,'Closing',1), +(11,7,6247,'Opening',1), +(11,7,6477,'Opening',1), +(11,7,6478,'Opening',1), +(11,7,6603,'Attack',1), +(11,7,7266,'Duel',1), +(11,7,7267,'Grovel',1), +(11,7,7355,'Stuck',1), +(11,7,8386,'Attacking',1), +(11,7,9077,'Leather',1), +(11,7,9078,'Cloth',1), +(11,7,9116,'Shield',1), +(11,7,9125,'Generic',1), +(11,7,20579,'Shadow Resistance',1), +(11,7,21651,'Opening',1), +(11,7,21652,'Closing',1), +(11,7,22027,'Remove Insignia',1), +(11,7,22810,'Opening - No Text',1), +(11,7,27763,'Totem',1), +(11,7,28875,'Gemcutting',1), +(11,7,28878,'Inspiring Presence',1), +(11,7,28880,'Gift of the Naaru',1), +(11,7,29932,'Language Draenei',1), +(11,8,81,'Dodge',1), +(11,8,133,'Fireball',1), +(11,8,168,'Frost Armor',1), +(11,8,203,'Unarmed',1), +(11,8,204,'Defense',1), +(11,8,227,'Staves',1), +(11,8,522,'SPELLDEFENSE(DND)',1), +(11,8,668,'Language Common',1), +(11,8,2382,'Generic',1), +(11,8,2479,'Honorless Target',1), +(11,8,3050,'Detect',1), +(11,8,3365,'Opening',1), +(11,8,5009,'Wands',1), +(11,8,5019,'Shoot',1), +(11,8,6233,'Closing',1), +(11,8,6246,'Closing',1), +(11,8,6247,'Opening',1), +(11,8,6477,'Opening',1), +(11,8,6478,'Opening',1), +(11,8,6603,'Attack',1), +(11,8,7266,'Duel',1), +(11,8,7267,'Grovel',1), +(11,8,7355,'Stuck',1), +(11,8,8386,'Attacking',1), +(11,8,9078,'Cloth',1), +(11,8,9125,'Generic',1), +(11,8,20579,'Shadow Resistance',1), +(11,8,21651,'Opening',1), +(11,8,21652,'Closing',1), +(11,8,22027,'Remove Insignia',1), +(11,8,22810,'Opening - No Text',1), +(11,8,28875,'Gemcutting',1), +(11,8,28878,'Inspiring Presence',1), +(11,8,28880,'Gift of the Naaru',1), +(11,8,29932,'Language Draenei',1); +/*!40000 ALTER TABLE `playercreateinfo_spell` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `prospecting_loot_template` +-- + +DROP TABLE IF EXISTS `prospecting_loot_template`; +CREATE TABLE `prospecting_loot_template` ( + `entry` mediumint(8) unsigned NOT NULL default '0', + `item` mediumint(8) unsigned NOT NULL default '0', + `ChanceOrQuestChance` float NOT NULL default '100', + `groupid` tinyint(3) unsigned NOT NULL default '0', + `mincountOrRef` mediumint(9) NOT NULL default '1', + `maxcount` tinyint(3) unsigned NOT NULL default '1', + `lootcondition` tinyint(3) unsigned NOT NULL default '0', + `condition_value1` mediumint(8) unsigned NOT NULL default '0', + `condition_value2` mediumint(8) unsigned NOT NULL default '0', + PRIMARY KEY (`entry`,`item`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Loot System'; + +-- +-- Dumping data for table `prospecting_loot_template` +-- + +LOCK TABLES `prospecting_loot_template` WRITE; +/*!40000 ALTER TABLE `prospecting_loot_template` DISABLE KEYS */; +/*!40000 ALTER TABLE `prospecting_loot_template` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `quest_end_scripts` +-- + +DROP TABLE IF EXISTS `quest_end_scripts`; +CREATE TABLE `quest_end_scripts` ( + `id` mediumint(8) unsigned NOT NULL default '0', + `delay` int(10) unsigned NOT NULL default '0', + `command` mediumint(8) unsigned NOT NULL default '0', + `datalong` mediumint(8) unsigned NOT NULL default '0', + `datalong2` int(10) unsigned NOT NULL default '0', + `datatext` text NOT NULL, + `x` float NOT NULL default '0', + `y` float NOT NULL default '0', + `z` float NOT NULL default '0', + `o` float NOT NULL default '0' +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + +-- +-- Dumping data for table `quest_end_scripts` +-- + +LOCK TABLES `quest_end_scripts` WRITE; +/*!40000 ALTER TABLE `quest_end_scripts` DISABLE KEYS */; +/*!40000 ALTER TABLE `quest_end_scripts` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `quest_start_scripts` +-- + +DROP TABLE IF EXISTS `quest_start_scripts`; +CREATE TABLE `quest_start_scripts` ( + `id` mediumint(8) unsigned NOT NULL default '0', + `delay` int(10) unsigned NOT NULL default '0', + `command` mediumint(8) unsigned NOT NULL default '0', + `datalong` mediumint(8) unsigned NOT NULL default '0', + `datalong2` int(10) unsigned NOT NULL default '0', + `datatext` text NOT NULL, + `x` float NOT NULL default '0', + `y` float NOT NULL default '0', + `z` float NOT NULL default '0', + `o` float NOT NULL default '0' +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + +-- +-- Dumping data for table `quest_start_scripts` +-- + +LOCK TABLES `quest_start_scripts` WRITE; +/*!40000 ALTER TABLE `quest_start_scripts` DISABLE KEYS */; +/*!40000 ALTER TABLE `quest_start_scripts` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `quest_mail_loot_template` +-- + +DROP TABLE IF EXISTS `quest_mail_loot_template`; +CREATE TABLE `quest_mail_loot_template` ( + `entry` mediumint(8) unsigned NOT NULL default '0', + `item` mediumint(8) unsigned NOT NULL default '0', + `ChanceOrQuestChance` float NOT NULL default '100', + `groupid` tinyint(3) unsigned NOT NULL default '0', + `mincountOrRef` mediumint(9) NOT NULL default '1', + `maxcount` tinyint(3) unsigned NOT NULL default '1', + `lootcondition` tinyint(3) unsigned NOT NULL default '0', + `condition_value1` mediumint(8) unsigned NOT NULL default '0', + `condition_value2` mediumint(8) unsigned NOT NULL default '0', + PRIMARY KEY (`entry`,`item`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Loot System'; + +-- +-- Dumping data for table `quest_mail_loot_template` +-- + +LOCK TABLES `quest_mail_loot_template` WRITE; +/*!40000 ALTER TABLE `quest_mail_loot_template` DISABLE KEYS */; +/*!40000 ALTER TABLE `quest_mail_loot_template` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `quest_template` +-- + +DROP TABLE IF EXISTS `quest_template`; +CREATE TABLE `quest_template` ( + `entry` mediumint(8) unsigned NOT NULL default '0', + `ZoneOrSort` smallint(6) NOT NULL default '0', + `SkillOrClass` smallint(6) NOT NULL default '0', + `MinLevel` tinyint(3) unsigned NOT NULL default '0', + `QuestLevel` tinyint(3) unsigned NOT NULL default '0', + `Type` smallint(5) unsigned NOT NULL default '0', + `RequiredRaces` smallint(5) unsigned NOT NULL default '0', + `RequiredSkillValue` smallint(5) unsigned NOT NULL default '0', + `RepObjectiveFaction` smallint(5) unsigned NOT NULL default '0', + `RepObjectiveValue` mediumint(9) NOT NULL default '0', + `RequiredMinRepFaction` smallint(5) unsigned NOT NULL default '0', + `RequiredMinRepValue` mediumint(9) NOT NULL default '0', + `RequiredMaxRepFaction` smallint(5) unsigned NOT NULL default '0', + `RequiredMaxRepValue` mediumint(9) NOT NULL default '0', + `SuggestedPlayers` tinyint(3) unsigned NOT NULL default '0', + `LimitTime` int(10) unsigned NOT NULL default '0', + `QuestFlags` smallint(5) unsigned NOT NULL default '0', + `SpecialFlags` tinyint(3) unsigned NOT NULL default '0', + `CharTitleId` tinyint(3) unsigned NOT NULL default '0', + `PrevQuestId` mediumint(9) NOT NULL default '0', + `NextQuestId` mediumint(9) NOT NULL default '0', + `ExclusiveGroup` mediumint(9) NOT NULL default '0', + `NextQuestInChain` mediumint(8) unsigned NOT NULL default '0', + `SrcItemId` mediumint(8) unsigned NOT NULL default '0', + `SrcItemCount` tinyint(3) unsigned NOT NULL default '0', + `SrcSpell` mediumint(8) unsigned NOT NULL default '0', + `Title` text, + `Details` text, + `Objectives` text, + `OfferRewardText` text, + `RequestItemsText` text, + `EndText` text, + `ObjectiveText1` text, + `ObjectiveText2` text, + `ObjectiveText3` text, + `ObjectiveText4` text, + `ReqItemId1` mediumint(8) unsigned NOT NULL default '0', + `ReqItemId2` mediumint(8) unsigned NOT NULL default '0', + `ReqItemId3` mediumint(8) unsigned NOT NULL default '0', + `ReqItemId4` mediumint(8) unsigned NOT NULL default '0', + `ReqItemCount1` smallint(5) unsigned NOT NULL default '0', + `ReqItemCount2` smallint(5) unsigned NOT NULL default '0', + `ReqItemCount3` smallint(5) unsigned NOT NULL default '0', + `ReqItemCount4` smallint(5) unsigned NOT NULL default '0', + `ReqSourceId1` mediumint(8) unsigned NOT NULL default '0', + `ReqSourceId2` mediumint(8) unsigned NOT NULL default '0', + `ReqSourceId3` mediumint(8) unsigned NOT NULL default '0', + `ReqSourceId4` mediumint(8) unsigned NOT NULL default '0', + `ReqSourceCount1` smallint(5) unsigned NOT NULL default '0', + `ReqSourceCount2` smallint(5) unsigned NOT NULL default '0', + `ReqSourceCount3` smallint(5) unsigned NOT NULL default '0', + `ReqSourceCount4` smallint(5) unsigned NOT NULL default '0', + `ReqSourceRef1` tinyint(3) unsigned NOT NULL default '0', + `ReqSourceRef2` tinyint(3) unsigned NOT NULL default '0', + `ReqSourceRef3` tinyint(3) unsigned NOT NULL default '0', + `ReqSourceRef4` tinyint(3) unsigned NOT NULL default '0', + `ReqCreatureOrGOId1` mediumint(9) NOT NULL default '0', + `ReqCreatureOrGOId2` mediumint(9) NOT NULL default '0', + `ReqCreatureOrGOId3` mediumint(9) NOT NULL default '0', + `ReqCreatureOrGOId4` mediumint(9) NOT NULL default '0', + `ReqCreatureOrGOCount1` smallint(5) unsigned NOT NULL default '0', + `ReqCreatureOrGOCount2` smallint(5) unsigned NOT NULL default '0', + `ReqCreatureOrGOCount3` smallint(5) unsigned NOT NULL default '0', + `ReqCreatureOrGOCount4` smallint(5) unsigned NOT NULL default '0', + `ReqSpellCast1` mediumint(8) unsigned NOT NULL default '0', + `ReqSpellCast2` mediumint(8) unsigned NOT NULL default '0', + `ReqSpellCast3` mediumint(8) unsigned NOT NULL default '0', + `ReqSpellCast4` mediumint(8) unsigned NOT NULL default '0', + `RewChoiceItemId1` mediumint(8) unsigned NOT NULL default '0', + `RewChoiceItemId2` mediumint(8) unsigned NOT NULL default '0', + `RewChoiceItemId3` mediumint(8) unsigned NOT NULL default '0', + `RewChoiceItemId4` mediumint(8) unsigned NOT NULL default '0', + `RewChoiceItemId5` mediumint(8) unsigned NOT NULL default '0', + `RewChoiceItemId6` mediumint(8) unsigned NOT NULL default '0', + `RewChoiceItemCount1` smallint(5) unsigned NOT NULL default '0', + `RewChoiceItemCount2` smallint(5) unsigned NOT NULL default '0', + `RewChoiceItemCount3` smallint(5) unsigned NOT NULL default '0', + `RewChoiceItemCount4` smallint(5) unsigned NOT NULL default '0', + `RewChoiceItemCount5` smallint(5) unsigned NOT NULL default '0', + `RewChoiceItemCount6` smallint(5) unsigned NOT NULL default '0', + `RewItemId1` mediumint(8) unsigned NOT NULL default '0', + `RewItemId2` mediumint(8) unsigned NOT NULL default '0', + `RewItemId3` mediumint(8) unsigned NOT NULL default '0', + `RewItemId4` mediumint(8) unsigned NOT NULL default '0', + `RewItemCount1` smallint(5) unsigned NOT NULL default '0', + `RewItemCount2` smallint(5) unsigned NOT NULL default '0', + `RewItemCount3` smallint(5) unsigned NOT NULL default '0', + `RewItemCount4` smallint(5) unsigned NOT NULL default '0', + `RewRepFaction1` smallint(5) unsigned NOT NULL default '0' COMMENT 'faction id from Faction.dbc in this case', + `RewRepFaction2` smallint(5) unsigned NOT NULL default '0' COMMENT 'faction id from Faction.dbc in this case', + `RewRepFaction3` smallint(5) unsigned NOT NULL default '0' COMMENT 'faction id from Faction.dbc in this case', + `RewRepFaction4` smallint(5) unsigned NOT NULL default '0' COMMENT 'faction id from Faction.dbc in this case', + `RewRepFaction5` smallint(5) unsigned NOT NULL default '0' COMMENT 'faction id from Faction.dbc in this case', + `RewRepValue1` mediumint(9) NOT NULL default '0', + `RewRepValue2` mediumint(9) NOT NULL default '0', + `RewRepValue3` mediumint(9) NOT NULL default '0', + `RewRepValue4` mediumint(9) NOT NULL default '0', + `RewRepValue5` mediumint(9) NOT NULL default '0', + `RewOrReqMoney` int(11) NOT NULL default '0', + `RewMoneyMaxLevel` int(10) unsigned NOT NULL default '0', + `RewSpell` mediumint(8) unsigned NOT NULL default '0', + `RewSpellCast` mediumint(8) unsigned NOT NULL default '0', + `RewMailTemplateId` mediumint(8) unsigned NOT NULL default '0', + `RewMailDelaySecs` int(11) unsigned NOT NULL default '0', + `PointMapId` smallint(5) unsigned NOT NULL default '0', + `PointX` float NOT NULL default '0', + `PointY` float NOT NULL default '0', + `PointOpt` mediumint(8) unsigned NOT NULL default '0', + `DetailsEmote1` smallint(5) unsigned NOT NULL default '0', + `DetailsEmote2` smallint(5) unsigned NOT NULL default '0', + `DetailsEmote3` smallint(5) unsigned NOT NULL default '0', + `DetailsEmote4` smallint(5) unsigned NOT NULL default '0', + `IncompleteEmote` smallint(5) unsigned NOT NULL default '0', + `CompleteEmote` smallint(5) unsigned NOT NULL default '0', + `OfferRewardEmote1` smallint(5) unsigned NOT NULL default '0', + `OfferRewardEmote2` smallint(5) unsigned NOT NULL default '0', + `OfferRewardEmote3` smallint(5) unsigned NOT NULL default '0', + `OfferRewardEmote4` smallint(5) unsigned NOT NULL default '0', + `StartScript` mediumint(8) unsigned NOT NULL default '0', + `CompleteScript` mediumint(8) unsigned NOT NULL default '0', + PRIMARY KEY (`entry`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Quest System'; + +-- +-- Dumping data for table `quest_template` +-- + +LOCK TABLES `quest_template` WRITE; +/*!40000 ALTER TABLE `quest_template` DISABLE KEYS */; +/*!40000 ALTER TABLE `quest_template` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `reference_loot_template` +-- + +DROP TABLE IF EXISTS `reference_loot_template`; +CREATE TABLE `reference_loot_template` ( + `entry` mediumint(8) unsigned NOT NULL default '0', + `item` mediumint(8) unsigned NOT NULL default '0', + `ChanceOrQuestChance` float NOT NULL default '100', + `groupid` tinyint(3) unsigned NOT NULL default '0', + `mincountOrRef` mediumint(9) NOT NULL default '1', + `maxcount` tinyint(3) unsigned NOT NULL default '1', + `lootcondition` tinyint(3) unsigned NOT NULL default '0', + `condition_value1` mediumint(8) unsigned NOT NULL default '0', + `condition_value2` mediumint(8) unsigned NOT NULL default '0', + PRIMARY KEY (`entry`,`item`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Loot System'; + +-- +-- Dumping data for table `reference_loot_template` +-- + +LOCK TABLES `reference_loot_template` WRITE; +/*!40000 ALTER TABLE `reference_loot_template` DISABLE KEYS */; +/*!40000 ALTER TABLE `reference_loot_template` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `reserved_name` +-- + +DROP TABLE IF EXISTS `reserved_name`; +CREATE TABLE `reserved_name` ( + `name` varchar(12) NOT NULL default '', + PRIMARY KEY (`name`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='Player Reserved Names'; + +-- +-- Dumping data for table `reserved_name` +-- + +LOCK TABLES `reserved_name` WRITE; +/*!40000 ALTER TABLE `reserved_name` DISABLE KEYS */; +/*!40000 ALTER TABLE `reserved_name` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `skill_discovery_template` +-- + +DROP TABLE IF EXISTS `skill_discovery_template`; +CREATE TABLE `skill_discovery_template` ( + `spellId` mediumint(8) unsigned NOT NULL default '0' COMMENT 'SpellId of the discoverable spell', + `reqSpell` mediumint(8) unsigned NOT NULL default '0' COMMENT 'spell requirement', + `chance` float NOT NULL default '0' COMMENT 'chance to discover', + PRIMARY KEY (`spellId`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Skill Discovery System'; + +-- +-- Dumping data for table `skill_discovery_template` +-- + +LOCK TABLES `skill_discovery_template` WRITE; +/*!40000 ALTER TABLE `skill_discovery_template` DISABLE KEYS */; +/*!40000 ALTER TABLE `skill_discovery_template` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `skill_extra_item_template` +-- + +DROP TABLE IF EXISTS `skill_extra_item_template`; +CREATE TABLE `skill_extra_item_template` ( + `spellId` mediumint(8) unsigned NOT NULL default '0' COMMENT 'SpellId of the item creation spell', + `requiredSpecialization` mediumint(8) unsigned NOT NULL default '0' COMMENT 'Specialization spell id', + `additionalCreateChance` float NOT NULL default '0' COMMENT 'chance to create add', + `additionalMaxNum` tinyint(3) unsigned NOT NULL default '0' COMMENT 'max num of adds', + PRIMARY KEY (`spellId`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Skill Specialization System'; + +-- +-- Dumping data for table `skill_extra_item_template` +-- + +LOCK TABLES `skill_extra_item_template` WRITE; +/*!40000 ALTER TABLE `skill_extra_item_template` DISABLE KEYS */; +/*!40000 ALTER TABLE `skill_extra_item_template` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `skill_fishing_base_level` +-- + +DROP TABLE IF EXISTS `skill_fishing_base_level`; +CREATE TABLE `skill_fishing_base_level` ( + `entry` mediumint(8) unsigned NOT NULL default '0' COMMENT 'Area identifier', + `skill` smallint(6) NOT NULL default '0' COMMENT 'Base skill level requirement', + PRIMARY KEY (`entry`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Fishing system'; + +-- +-- Dumping data for table `skill_fishing_base_level` +-- + +LOCK TABLES `skill_fishing_base_level` WRITE; +/*!40000 ALTER TABLE `skill_fishing_base_level` DISABLE KEYS */; +/*!40000 ALTER TABLE `skill_fishing_base_level` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `skinning_loot_template` +-- + +DROP TABLE IF EXISTS `skinning_loot_template`; +CREATE TABLE `skinning_loot_template` ( + `entry` mediumint(8) unsigned NOT NULL default '0', + `item` mediumint(8) unsigned NOT NULL default '0', + `ChanceOrQuestChance` float NOT NULL default '100', + `groupid` tinyint(3) unsigned NOT NULL default '0', + `mincountOrRef` mediumint(9) NOT NULL default '1', + `maxcount` tinyint(3) unsigned NOT NULL default '1', + `lootcondition` tinyint(3) unsigned NOT NULL default '0', + `condition_value1` mediumint(8) unsigned NOT NULL default '0', + `condition_value2` mediumint(8) unsigned NOT NULL default '0', + PRIMARY KEY (`entry`,`item`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Loot System'; + +-- +-- Dumping data for table `skinning_loot_template` +-- + +LOCK TABLES `skinning_loot_template` WRITE; +/*!40000 ALTER TABLE `skinning_loot_template` DISABLE KEYS */; +/*!40000 ALTER TABLE `skinning_loot_template` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `spell_affect` +-- + +DROP TABLE IF EXISTS `spell_affect`; +CREATE TABLE `spell_affect` ( + `entry` smallint(5) unsigned NOT NULL default '0', + `effectId` tinyint(3) unsigned NOT NULL default '0', + `SpellFamilyMask` bigint(20) unsigned NOT NULL default '0', + PRIMARY KEY (`entry`,`effectId`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + +-- +-- Dumping data for table `spell_affect` +-- + +LOCK TABLES `spell_affect` WRITE; +/*!40000 ALTER TABLE `spell_affect` DISABLE KEYS */; +INSERT INTO `spell_affect` VALUES +(5420,2,0x00001012100000D0), +(8875,1,0x0000040000000000), +(11069,0,0x0000000000000001), +(11070,0,0x0000000000000020), +(11071,0,0x0000000000100000), +(11083,0,0x0000000000C20017), +(11124,0,0x0000000008C20017), +(11151,0,0x00000000000202E0), +(11160,0,0x00000001020203E0), +(11175,1,0x0000000000100000), +(11207,0,0x00000000000202E0), +(11222,0,0x0000000020001800), +(11242,0,0x0000000020001000), +(11247,0,0x0000000000002000), +(12042,0,0x0000000020E01AF7), +(12042,1,0x0000000020E01AF7), +(12042,2,0x0000000020E01AF7), +(12043,0,0x0000000021400035), +(12285,0,0x0000000000000001), +(12286,0,0x0000000000000020), +(12287,1,0x0000000000000080), +(12295,1,0x0000000002000000), +(12295,2,0x0000040000000000), +(12301,0,0x0000000000000100), +(12303,1,0x0000100000000000), +(12308,0,0x0000000000004000), +(12318,0,0x0000008000010000), +(12321,0,0x0000008000030000), +(12321,1,0x0000008000030000), +(12330,0,0x0000000000200000), +(12338,0,0x0000000000000001), +(12339,0,0x0000000000000001), +(12340,0,0x0000000000000001), +(12341,0,0x0000000000000001), +(12351,0,0x0000000000C20017), +(12378,0,0x0000000008C20017), +(12398,0,0x0000000008C20017), +(12399,0,0x0000000008C20017), +(12400,0,0x0000000008C20017), +(12467,0,0x0000000020001000), +(12469,0,0x0000000020001000), +(12472,1,0x00000000E44008A5), +(12473,0,0x0000000000000020), +(12496,0,0x0000000000100000), +(12497,0,0x0000000000100000), +(12518,0,0x00000001020203E0), +(12519,0,0x00000001020203E0), +(12536,0,0x0000000020C01AF7), +(12569,1,0x0000000000100000), +(12571,1,0x0000000000100000), +(12658,0,0x0000000000000020), +(12659,0,0x0000000000000020), +(12665,1,0x0000000000000080), +(12666,1,0x0000000000000080), +(12672,0,0x00000000000202E0), +(12676,1,0x0000000002000000), +(12676,2,0x0000040000000000), +(12677,1,0x0000000002000000), +(12677,2,0x0000040000000000), +(12697,0,0x0000000000000001), +(12788,1,0x0000100000000000), +(12789,1,0x0000100000000000), +(12810,0,0x0000000000004000), +(12811,0,0x0000000000004000), +(12818,0,0x0000000000000100), +(12835,0,0x0000008000030000), +(12835,1,0x0000008000030000), +(12836,0,0x0000008000030000), +(12836,1,0x0000008000030000), +(12837,0,0x0000008000030000), +(12837,1,0x0000008000030000), +(12838,0,0x0000008000030000), +(12838,1,0x0000008000030000), +(12839,0,0x0000000020001800), +(12840,0,0x0000000020001800), +(12841,0,0x0000000020001800), +(12842,0,0x0000000020001800), +(12857,0,0x0000008000010000), +(12858,0,0x0000008000010000), +(12860,0,0x0000008000010000), +(12861,0,0x0000008000010000), +(12862,0,0x0000000000200000), +(12945,1,0x0000000000001000), +(12952,0,0x00000000000202E0), +(12953,0,0x00000000000202E0), +(12954,0,0x00000000000202E0), +(12957,0,0x00000000000202E0), +(13733,0,0x0000000000000004), +(13733,1,0x0000000400000000), +(13742,0,0x0000000000000060), +(13743,0,0x0000000000000040), +(13865,0,0x0000000000000004), +(13865,1,0x0000000400000000), +(13866,0,0x0000000000000004), +(13866,1,0x0000000400000000), +(13872,0,0x0000000000000060), +(13875,0,0x0000000000000040), +(13975,0,0x0000000000400000), +(13975,1,0x0000000000400000), +(13976,0,0x0000000000000700), +(13979,0,0x0000000000000700), +(13980,0,0x0000000000000700), +(13981,0,0x0000000001000000), +(13981,1,0x0000000000000800), +(14057,0,0x0000000600000304), +(14062,0,0x0000000000400000), +(14062,1,0x0000000000400000), +(14063,0,0x0000000000400000), +(14063,1,0x0000000000400000), +(14064,0,0x0000000000400000), +(14064,1,0x0000000000400000), +(14065,0,0x0000000000400000), +(14065,1,0x0000000000400000), +(14066,0,0x0000000001000000), +(14066,1,0x0000000000000800), +(14072,0,0x0000000600000304), +(14073,0,0x0000000600000304), +(14074,0,0x0000000600000304), +(14075,0,0x0000000600000304), +(14076,0,0x0000000001000080), +(14076,1,0x0000000001000080), +(14082,0,0x0000000000000500), +(14083,0,0x0000000000000500), +(14094,0,0x0000000001000080), +(14094,1,0x0000000001000080), +(14113,0,0x000000000001E000), +(14114,0,0x000000000001E000), +(14115,0,0x000000000001E000), +(14116,0,0x000000000001E000), +(14117,0,0x000000000001E000), +(14128,0,0x000000062600000E), +(14132,0,0x000000062600000E), +(14135,0,0x000000062600000E), +(14136,0,0x000000062600000E), +(14137,0,0x000000062600000E), +(14143,0,0x0000000004000206), +(14149,0,0x0000000004000206), +(14162,0,0x0000000000020000), +(14163,0,0x0000000000020000), +(14164,0,0x0000000000020000), +(14168,0,0x0000000000080000), +(14169,0,0x0000000000080000), +(14174,0,0x0000000000200000), +(14175,0,0x0000000000200000), +(14176,0,0x0000000000200000), +(14177,0,0x0000000C6012031E), +(14179,0,0x00000009003E0000), +(14520,0,0x00000963BF61C16F), +(14523,1,0x000000208030016B), +(14523,2,0x000000208030016B), +(14743,0,0x0000049440963E90), +(14747,0,0x0000000000000002), +(14750,0,0x0000000000000010), +(14751,0,0xFFFFFFFFFFFFFFFF), +(14751,1,0xFFFFFFFFFFFFFFFF), +(14770,0,0x0000000000000002), +(14771,0,0x0000000000000002), +(14772,0,0x0000000000000010), +(14780,0,0x00000963BF61C16F), +(14781,0,0x00000963BF61C16F), +(14782,0,0x00000963BF61C16F), +(14783,0,0x00000963BF61C16F), +(14784,1,0x000000208030016B), +(14784,2,0x000000208030016B), +(14785,1,0x000000208030016B), +(14785,2,0x000000208030016B), +(14786,1,0x000000208030016B), +(14786,2,0x000000208030016B), +(14787,1,0x000000208030016B), +(14787,2,0x000000208030016B), +(14908,0,0x0000000000000040), +(14909,1,0x0000000000100080), +(14911,0,0x0000002000000200), +(14912,0,0x0000000000041400), +(14913,0,0x0000000400041E00), +(15012,0,0x0000000400041E00), +(15013,0,0x0000000000041400), +(15014,0,0x0000000000041400), +(15017,1,0x0000000000100080), +(15018,0,0x0000002000000200), +(15020,0,0x0000000000000040), +(15047,0,0x00000000000202E0), +(15052,0,0x00000000000202E0), +(15053,0,0x00000000000202E0), +(15257,0,0x000004020288A010), +(15259,0,0x0000000202002000), +(15259,1,0x0000040000808000), +(15260,0,0x00000442068BA000), +(15272,0,0x00000D4A068BE104), +(15307,0,0x0000000202002000), +(15307,1,0x0000040000808000), +(15308,0,0x0000000202002000), +(15308,1,0x0000040000808000), +(15309,0,0x0000000202002000), +(15309,1,0x0000040000808000), +(15310,0,0x0000000202002000), +(15310,1,0x0000040000808000), +(15318,0,0x00000D4A068BE104), +(15320,0,0x00000D4A068BE104), +(15327,0,0x00000442068BA000), +(15328,0,0x00000442068BA000), +(15329,0,0x00000442068BA000), +(15330,0,0x00000442068BA000), +(15331,0,0x000004020288A010), +(15332,0,0x000004020288A010), +(15333,0,0x000004020288A010), +(15334,0,0x000004020288A010), +(16035,0,0x0000000090100003), +(16038,0,0x0000000040000000), +(16039,0,0x0000000090100003), +(16041,0,0x0000000000000003), +(16043,0,0x0000000000000008), +(16043,1,0x0000000100000000), +(16086,0,0x0000000000000020), +(16086,1,0x0000000000000020), +(16086,2,0x0000000000000004), +(16089,0,0x00000004D3300407), +(16105,0,0x0000000090100003), +(16106,0,0x0000000090100003), +(16106,1,0x0000000090100003), +(16107,0,0x0000000090100003), +(16108,0,0x0000000090100003), +(16109,0,0x0000000090100003), +(16110,0,0x0000000090100003), +(16111,0,0x0000000090100003), +(16112,0,0x0000000090100003), +(16117,0,0x0000000000000003), +(16118,0,0x0000000000000003), +(16119,0,0x0000000000000003), +(16120,0,0x0000000000000003), +(16130,0,0x0000000000000008), +(16130,1,0x0000000100000000), +(16160,0,0x0000000040000000), +(16161,0,0x0000000040000000), +(16166,0,0x0000000090100003), +(16166,1,0x0000000090100003), +(16173,0,0x0000000020081018), +(16179,0,0x00000000000000C0), +(16181,0,0x00000000000001C0), +(16184,0,0x0000000000000200), +(16184,1,0x0000000000000200), +(16187,0,0x0000000000006000), +(16187,1,0x0000000000006000), +(16188,0,0x00000000000009C3), +(16189,0,0x000001000403E000), +(16205,0,0x0000000000006000), +(16205,1,0x0000000000006000), +(16206,0,0x0000000000006000), +(16206,1,0x0000000000006000), +(16207,0,0x0000000000006000), +(16207,1,0x0000000000006000), +(16208,0,0x0000000000006000), +(16208,1,0x0000000000006000), +(16209,1,0x0000000000000200), +(16214,0,0x00000000000000C0), +(16215,0,0x00000000000000C0), +(16216,0,0x00000000000000C0), +(16217,0,0x00000000000000C0), +(16222,0,0x0000000020081018), +(16223,0,0x0000000020081018), +(16224,0,0x0000000020081018), +(16225,0,0x0000000020081018), +(16230,0,0x00000000000001C0), +(16232,0,0x00000000000001C0), +(16233,0,0x00000000000001C0), +(16234,0,0x00000000000001C0), +(16246,0,0x0000000090100003), +(16258,0,0x0000000000008000), +(16258,1,0x0000000000040000), +(16259,0,0x0000000000010000), +(16259,1,0x0000000000020000), +(16261,0,0x0000000000000400), +(16266,0,0x0000000000400000), +(16266,1,0x0000000001000000), +(16266,2,0x0000000000800000), +(16290,0,0x0000000000000400), +(16291,0,0x0000000000000400), +(16293,0,0x0000000000008000), +(16293,1,0x0000000000040000), +(16295,0,0x0000000000010000), +(16295,1,0x0000000000020000), +(16493,0,0x0000014D2A600CEF), +(16494,0,0x0000014D2A600CEF), +(16513,0,0x000000080001E000), +(16513,1,0x000000000001E000), +(16513,2,0x000000000001E000), +(16514,0,0x000000080001E000), +(16514,1,0x000000000001E000), +(16514,2,0x000000000001E000), +(16515,0,0x000000080001E000), +(16515,1,0x000000000001E000), +(16515,2,0x000000000001E000), +(16544,2,0x0000000000000004), +(16578,0,0x0000000000000003), +(16579,0,0x0000000000000003), +(16580,0,0x0000000000000003), +(16581,0,0x0000000000000003), +(16582,0,0x0000000000000003), +(16719,0,0x000000080001E000), +(16719,1,0x000000000001E000), +(16719,2,0x000000000001E000), +(16720,0,0x000000080001E000), +(16720,1,0x000000000001E000), +(16720,2,0x000000000001E000), +(16757,0,0x00000000000200A0), +(16757,1,0x0000000000000240), +(16758,0,0x00000000000200A0), +(16758,1,0x0000000000000240), +(16763,0,0x0000000000000020), +(16765,0,0x0000000000000020), +(16766,0,0x0000000000000020), +(16814,0,0x0000000000000005), +(16815,0,0x0000000000000005), +(16816,0,0x0000000000000005), +(16817,0,0x0000000000000005), +(16818,0,0x0000000000000005), +(16819,0,0x0002122000600707), +(16820,0,0x0002122000600707), +(16821,0,0x0000000000000002), +(16821,1,0x0000000000000002), +(16821,2,0x0000000000000002), +(16822,0,0x0000000000000002), +(16822,1,0x0000000000000002), +(16822,2,0x0000000000000002), +(16833,0,0x0000E000E2000000), +(16834,0,0x0000E000E2000000), +(16835,0,0x0000E000E2000000), +(16836,1,0x0000000000000300), +(16839,1,0x0000000000000300), +(16840,1,0x0000000000000300), +(16850,1,0x0000000000000001), +(16870,0,0x001007F100E3FEFF), +(16886,0,0x0000000001000265), +(16896,0,0x0000000000000007), +(16896,1,0x0000000000000007), +(16897,0,0x0000000000000007), +(16897,1,0x0000000000000007), +(16899,0,0x0000000000000007), +(16899,1,0x0000000000000007), +(16900,0,0x0000000000000007), +(16900,1,0x0000000000000007), +(16901,0,0x0000000000000007), +(16901,1,0x0000000000000007), +(16918,0,0x0000002000000200), +(16919,0,0x0000002000000200), +(16920,0,0x0000002000000200), +(16923,1,0x0000000000000001), +(16924,1,0x0000000000000001), +(16934,0,0x0010004000000800), +(16934,1,0x0000040000001000), +(16935,0,0x0010004000000800), +(16935,1,0x0000040000001000), +(16936,0,0x0010004000000800), +(16936,1,0x0000040000001000), +(16937,0,0x0010004000000800), +(16937,1,0x0000040000001000), +(16938,0,0x0010004000000800), +(16938,1,0x0000040000001000), +(16947,1,0x0000000002000000), +(16948,1,0x0000000002000000), +(16949,1,0x0000000002000000), +(16966,0,0x0000000000008000), +(16966,1,0x0000010000000000), +(16968,0,0x0000000000008000), +(16968,1,0x0000010000000000), +(16998,0,0x0000000000001000), +(16998,2,0x0000000000001000), +(16999,0,0x0000000000001000), +(16999,2,0x0000000000001000), +(17104,0,0x00000010000000F0), +(17104,1,0x00000010000000F0), +(17111,0,0x0000000000000010), +(17112,0,0x0000000000000010), +(17113,0,0x0000000000000010), +(17114,0,0x0000000000000010), +(17115,0,0x0000000000000010), +(17116,0,0x0002002010000261), +(17118,0,0x001005D000E193F7), +(17118,1,0x0004103000340750), +(17119,0,0x001005D000E193F7), +(17119,1,0x0004103000340750), +(17120,0,0x001005D000E193F7), +(17120,1,0x0004103000340750), +(17121,0,0x001005D000E193F7), +(17121,1,0x0004103000340750), +(17122,0,0x001005D000E193F7), +(17122,1,0x0004103000340750), +(17123,0,0x0000000000000080), +(17124,0,0x0000000000000080), +(17191,0,0x0000000000000040), +(17322,0,0x00000542068AA004), +(17323,0,0x00000542068AA004), +(17768,0,0x0000000040000000), +(17768,1,0x0000000080000000), +(17778,0,0x000010C0000003E5), +(17779,0,0x000010C0000003E5), +(17780,0,0x000010C0000003E5), +(17781,0,0x000010C0000003E5), +(17782,0,0x000010C0000003E5), +(17788,1,0x0000008000000000), +(17789,1,0x0000008000000000), +(17790,1,0x0000008000000000), +(17791,1,0x0000008000000000), +(17792,1,0x0000008000000000), +(17904,0,0x0000000000000000), +(17912,0,0x0000000000000000), +(17913,0,0x0000000000000000), +(17914,0,0x0000000000000000), +(17915,0,0x0000000000000000), +(17916,0,0x0000000000000000), +(17917,0,0x000010C0000003A5), +(17917,1,0x000010C0000003E5), +(17918,0,0x000010C0000003A5), +(17918,1,0x000010C0000003E5), +(17927,0,0x0000000000000100), +(17929,0,0x0000000000000100), +(17930,0,0x0000000000000100), +(17941,0,0x0000000000000001), +(17954,0,0x000000C000001364), +(17954,1,0x000000C000001364), +(17954,2,0x0000004000000000), +(17955,0,0x000000C000001364), +(17955,1,0x000000C000001364), +(17955,2,0x0000004000000000), +(17956,0,0x000000C000001364), +(17956,1,0x000000C000001364), +(17956,2,0x0000004000000000), +(17957,0,0x000000C000001364), +(17957,1,0x000000C000001364), +(17957,2,0x0000004000000000), +(17958,0,0x000000C000001364), +(17958,1,0x000000C000001364), +(17958,2,0x0000004000000000), +(17959,0,0x000010C0000003E5), +(18126,0,0x0000000000001000), +(18127,0,0x0000000000001000), +(18130,0,0x000010C0000003E5), +(18131,0,0x000010C0000003E5), +(18132,0,0x000010C0000003E5), +(18133,0,0x000010C0000003E5), +(18134,0,0x000010C0000003E5), +(18135,0,0x000010C0000003E5), +(18136,0,0x000010C0000003E5), +(18174,0,0x0000071B804CC41A), +(18175,0,0x0000071B804CC41A), +(18176,0,0x0000071B804CC41A), +(18177,0,0x0000071B804CC41A), +(18178,0,0x0000071B804CC41A), +(18179,0,0x0000000000008000), +(18180,0,0x0000000000008000), +(18213,0,0x0000000000004000), +(18213,1,0x0000871B804CC41A), +(18218,0,0x000007138048C41A), +(18219,0,0x000007138048C41A), +(18271,0,0x000011130008A48B), +(18271,1,0x000011130008A48B), +(18272,0,0x000011130008A48B), +(18272,1,0x000011130008A48B), +(18273,0,0x000011130008A48B), +(18273,1,0x000011130008A48B), +(18274,0,0x000011130008A48B), +(18274,1,0x000011130008A48B), +(18275,0,0x000011130008A48B), +(18275,1,0x000011130008A48B), +(18288,0,0x0000000200000400), +(18288,1,0x0000000000400000), +(18372,1,0x0000871B804CC41A), +(18427,0,0x0000000000020006), +(18428,0,0x0000000000020006), +(18429,0,0x0000000000020006), +(18544,0,0x0000041202F8A090), +(18544,1,0x0000001202582090), +(18544,2,0x0000040000A08000), +(18547,0,0x0000041202F8A090), +(18547,1,0x0000001202582090), +(18547,2,0x0000040000A08000), +(18548,0,0x0000041202F8A090), +(18548,1,0x0000001202582090), +(18548,2,0x0000040000A08000), +(18549,0,0x0000041202F8A090), +(18549,1,0x0000001202582090), +(18549,2,0x0000040000A08000), +(18550,0,0x0000041202F8A090), +(18550,1,0x0000001202582090), +(18550,2,0x0000040000A08000), +(18703,1,0x0000000001000000), +(18704,1,0x0000000001000000), +(18731,0,0x0000000010000000), +(18743,0,0x0000000010000000), +(18744,0,0x0000000010000000), +(18748,0,0x0000000008000000), +(18749,0,0x0000000008000000), +(18750,0,0x0000000008000000), +(18767,1,0x0000000000020000), +(18768,1,0x0000000000020000), +(18821,0,0x0000000000000800), +(18821,1,0x0000000000000800), +(18821,2,0x0000000000000800), +(18822,0,0x0000000000000800), +(18822,1,0x0000000000000800), +(18822,2,0x0000000000000800), +(18827,0,0x0000000000000400), +(18829,0,0x0000000000000400), +(19239,0,0x0000000000000018), +(19239,1,0x0000000000000004), +(19245,0,0x0000000000000018), +(19245,1,0x0000200000000004), +(19416,0,0x000210810007FA00), +(19417,0,0x000210810007FA00), +(19418,0,0x000210810007FA00), +(19419,0,0x000210810007FA00), +(19420,0,0x000210810007FA00), +(19461,0,0x0000000000003000), +(19461,1,0x0000000000003000), +(19462,0,0x0000000000003000), +(19462,1,0x0000000000003000), +(19464,0,0x0000010000004000), +(19464,1,0x0000008000000000), +(19464,2,0x000011800000C000), +(19465,0,0x0000010000004000), +(19465,1,0x0000008000000000), +(19465,2,0x000011800000C000), +(19466,0,0x0000010000004000), +(19466,1,0x0000008000000000), +(19466,2,0x000011800000C000), +(19467,0,0x0000010000004000), +(19467,1,0x0000008000000000), +(19467,2,0x000011800000C000), +(19468,0,0x0000010000004000), +(19468,1,0x0000008000000000), +(19468,2,0x000011800000C000), +(19485,0,0x0000000100061801), +(19487,0,0x0000000100061801), +(19488,0,0x0000000100061801), +(19489,0,0x0000000100061801), +(19490,0,0x0000000100061801), +(19498,0,0x000210810007FA01), +(19499,0,0x000210810007FA01), +(19500,0,0x000210810007FA01), +(19549,0,0x0000000000080000), +(19550,0,0x0000000000080000), +(19551,0,0x0000000000080000), +(19552,0,0x0000000000100000), +(19552,1,0x0000020000000000), +(19553,0,0x0000000000100000), +(19553,1,0x0000020000000000), +(19554,0,0x0000000000100000), +(19554,1,0x0000020000000000), +(19555,0,0x0000000000100000), +(19555,1,0x0000020000000000), +(19556,0,0x0000000000100000), +(19556,1,0x0000020000000000), +(19559,0,0x0000000000200000), +(19560,0,0x0000000000200000), +(19572,1,0x0000000000800000), +(19573,1,0x0000000000800000), +(19583,0,0x0000000008000000), +(19584,0,0x0000000008000000), +(19585,0,0x0000000008000000), +(19586,0,0x0000000008000000), +(19587,0,0x0000000008000000), +(19590,0,0x0000000020000000), +(19592,0,0x0000000020000000), +(19598,0,0x0000000040000000), +(19599,0,0x0000000040000000), +(19600,0,0x0000000040000000), +(19601,0,0x0000000040000000), +(19602,0,0x0000000040000000), +(19609,0,0x0000000004000000), +(19610,0,0x0000000004000000), +(19612,0,0x0000000004000000), +(20101,0,0x000004000A000200), +(20102,0,0x000004000A000200), +(20103,0,0x000004000A000200), +(20104,0,0x000004000A000200), +(20105,0,0x000004000A000200), +(20138,0,0x0000000000000040), +(20139,0,0x0000000000000040), +(20140,0,0x0000000000000040), +(20141,0,0x0000000000000040), +(20142,0,0x0000000000000040), +(20174,0,0x0000000000000080), +(20174,1,0x0000000000000010), +(20175,0,0x0000000000000080), +(20175,1,0x0000000000000010), +(20216,0,0x00010000C0200000), +(20224,0,0x0000000008000400), +(20225,0,0x0000000008000400), +(20237,0,0x00000000C0000000), +(20238,0,0x00000000C0000000), +(20239,0,0x00000000C0000000), +(20249,0,0x0000000040000000), +(20250,0,0x0000000040000000), +(20251,0,0x0000000040000000), +(20254,0,0x0000000000020000), +(20254,1,0x0000000000020000), +(20254,2,0x0000000000020000), +(20255,0,0x0000000000020000), +(20255,1,0x0000000000020000), +(20255,2,0x0000000000020000), +(20256,0,0x0000000000020000), +(20256,1,0x0000000000020000), +(20256,2,0x0000000000020000), +(20330,0,0x0000000008000400), +(20331,0,0x0000000008000400), +(20332,0,0x0000000008000400), +(20335,0,0x0000000020000000), +(20336,0,0x0000000020000000), +(20337,0,0x0000000020000000), +(20359,0,0x0000000080000000), +(20360,0,0x0000000080000000), +(20361,0,0x0000000080000000), +(20468,1,0x0000000000000001), +(20469,1,0x0000000000000001), +(20470,1,0x0000000000000001), +(20575,0,0x0000000004000000), +(20575,1,0x0000000004000000), +(20576,0,0x0000000002000000), +(21873,0,0x0000E000E2000000), +(21881,0,0x000000000001E000), +(21887,0,0x0000036C2A764EEF), +(21895,0,0x000000000403E000), +(21899,0,0x0000000000000100), +(21942,1,0x0000000008000000), +(22008,0,0x0000000021400035), +(23025,0,0x0000000000010000), +(23047,0,0x0000040000000000), +(23047,1,0x0000040000000000), +(23158,0,0x0000000000000200), +(23300,0,0x0000000020000000), +(23555,0,0x000010C0000003E5), +(23561,0,0x0000000000004000), +(23566,0,0x0000000000001000), +(23724,0,0x0000E000E2000000), +(23726,0,0x0000000000002000), +(23726,1,0x0000000000010000), +(24348,0,0x0000000000200000), +(24429,0,0x0000000000004000), +(24431,0,0x0000000400000000), +(24460,0,0x0000000010000180), +(24469,0,0x0000000001000000), +(24499,0,0x0000000000000400), +(24542,1,0x00000000000000F0), +(24546,1,0x0000000400041E00), +(24691,0,0x0000000000003000), +(24691,1,0x0000000000003000), +(24943,0,0x00000010000000F0), +(24943,1,0x00000010000000F0), +(24944,0,0x00000010000000F0), +(24944,1,0x00000010000000F0), +(24945,0,0x00000010000000F0), +(24945,1,0x00000010000000F0), +(24946,0,0x00000010000000F0), +(24946,1,0x00000010000000F0), +(26106,0,0x0000000010000000), +(26109,0,0x00000080000F0000), +(26112,0,0x0000000000000020), +(26118,0,0x0000000004000000), +(26118,1,0x0000000004000000), +(26174,0,0x0000000000000020), +(27789,1,0x0000000010400200), +(27790,1,0x0000000010400200), +(27828,0,0x0000049440963E90), +(27846,0,0x0000000000000020), +(27850,0,0x0000000000000040), +(27851,0,0x0000000000001000), +(28088,0,0x000000000001E000), +(28107,0,0x0000000000040000), +(28539,0,0x0000000000001000), +(28682,0,0x0000004008C20017), +(28743,0,0x00000000000000F0), +(28746,1,0x0000000100000406), +(28751,0,0x0000000000021000), +(28755,0,0x0000000000000020), +(28763,0,0x0000000004000000), +(28774,0,0x0000000000008000), +(28775,0,0x0000000100000000), +(28787,0,0x0000000000001000), +(28807,0,0x0000000000000040), +(28808,0,0x0000000411041E40), +(28811,0,0x0000000002020006), +(28814,0,0x0000000000020000), +(28815,0,0x0000000002000006), +(28818,0,0x0000000020081018), +(28821,0,0x0000000000000400), +(28829,0,0x0000000000000002), +(28831,0,0x0000000000000001), +(28842,0,0x0000000100004440), +(28843,0,0x0000000000088000), +(28844,0,0x0000000000000400), +(28852,0,0x0000000000000200), +(28852,1,0x0000000020000000), +(28855,0,0x0000000000000800), +(28855,1,0x0010000000000000), +(28999,0,0x0000000000000003), +(29000,0,0x0000000000000003), +(29005,0,0x0000000090100003), +(29063,0,0x00000000000009C3), +(29079,0,0x0000000000400000), +(29079,1,0x0000000001000000), +(29079,2,0x0000000000800000), +(29080,0,0x0000000000400000), +(29080,1,0x0000000001000000), +(29080,2,0x0000000000800000), +(29171,0,0x0000000000004000), +(29187,0,0x00000000000001C0), +(29187,1,0x0004103000340750), +(29189,0,0x00000000000001C0), +(29189,1,0x0004103000340750), +(29191,0,0x00000000000001C0), +(29191,1,0x0004103000340750), +(29202,0,0x0000000000000040), +(29205,0,0x0000000000000040), +(29206,0,0x0000000000000040), +(29438,0,0x0000000000D000D7), +(29439,0,0x0000000000D000D7), +(29440,0,0x0000000000D000D7), +(29721,0,0x0000000400000000), +(29723,0,0x0000000800002010), +(29723,1,0x0000000800002010), +(29724,0,0x0000000800002010), +(29724,1,0x0000000800002010), +(29725,0,0x0000000800002010), +(29725,1,0x0000000800002010), +(29759,1,0x0000075D6E6ECEEF), +(29760,1,0x0000075D6E6ECEEF), +(29761,1,0x0000075D6E6ECEEF), +(29762,1,0x0000075D6E6ECEEF), +(29763,1,0x0000075D6E6ECEEF), +(29776,0,0x0000000400000000), +(29787,0,0x0000036C2A764EEF), +(29790,0,0x0000036C2A764EEF), +(29792,0,0x0000036C2A764EEF), +(29836,0,0x0000001000000020), +(29859,0,0x0000001000000020), +(29888,0,0x0000000040000000), +(29889,0,0x0000000040000000), +(29976,0,0x0000000021400035), +(30049,0,0x0000000000080000), +(30051,0,0x0000000000080000), +(30052,0,0x0000000000080000), +(30054,0,0x0000000800000000), +(30057,0,0x0000000800000000), +(30060,0,0x0000001000000402), +(30060,1,0x0000001000000402), +(30060,2,0x0000871B804CC41A), +(30061,0,0x0000001000000402), +(30061,1,0x0000001000000402), +(30061,2,0x0000871B804CC41A), +(30062,0,0x0000001000000402), +(30062,1,0x0000001000000402), +(30062,2,0x0000871B804CC41A), +(30063,0,0x0000001000000402), +(30063,1,0x0000001000000402), +(30063,2,0x0000871B804CC41A), +(30064,0,0x0000001000000402), +(30064,1,0x0000001000000402), +(30064,2,0x0000871B804CC41A), +(30085,0,0x0000071B804CC41A), +(30085,1,0x0000000000000400), +(30085,2,0x0000000000000002), +(30086,0,0x0000071B804CC41A), +(30086,1,0x0000000000000400), +(30086,2,0x0000000000000002), +(30143,0,0x0000002000000000), +(30144,0,0x0000002000000000), +(30145,0,0x0000002000000000), +(30242,0,0x0000200000000000), +(30245,0,0x0000200000000000), +(30246,0,0x0000200000000000), +(30247,0,0x0000200000000000), +(30248,0,0x0000200000000000), +(30251,0,0x000010C000000125), +(30256,0,0x000010C000000125), +(30288,0,0x0000004000000001), +(30289,0,0x0000004000000001), +(30290,0,0x0000004000000001), +(30291,0,0x0000004000000001), +(30292,0,0x0000004000000001), +(30319,1,0x0000400000000000), +(30320,1,0x0000400000000000), +(30321,1,0x0000400000000000), +(30326,0,0x0000000000040010), +(30327,0,0x0000000000040010), +(30328,0,0x0000000000040010), +(30812,0,0x00000C78B018141B), +(30813,0,0x00000C78B018141B), +(30814,0,0x00000C78B018141B), +(30872,0,0x0000000000000100), +(30873,0,0x0000000000000100), +(30892,0,0x0000000008000000), +(30893,0,0x0000000008000000), +(31216,1,0x0000000002000004), +(31217,1,0x0000000002000004), +(31218,1,0x0000000002000004), +(31219,1,0x0000000002000004), +(31220,1,0x0000000002000004), +(31226,0,0x000000000001E000), +(31227,0,0x000000000001E000), +(31234,0,0x000001002612030F), +(31234,1,0x0000000000100100), +(31235,0,0x000001002612030F), +(31235,1,0x0000000000100100), +(31236,0,0x000001002612030F), +(31236,1,0x0000000000100100), +(31237,0,0x000001002612030F), +(31237,1,0x0000000000100100), +(31238,0,0x000001002612030F), +(31238,1,0x0000000000100100), +(31571,0,0x0000000200000000), +(31572,0,0x0000000200000000), +(31573,0,0x0000000200000000), +(31579,0,0x0000000000200000), +(31579,1,0x0000000000000800), +(31582,0,0x0000000000200000), +(31582,1,0x0000000000000800), +(31583,0,0x0000000000200000), +(31583,1,0x0000000000000800), +(31656,0,0x0000000000000001), +(31657,0,0x0000000000000001), +(31658,0,0x0000000000000001), +(31659,0,0x0000000000000001), +(31660,0,0x0000000000000001), +(31670,0,0x0000000500000200), +(31672,0,0x0000000500000200), +(31682,0,0x0000000000000020), +(31682,1,0x0000000000000020), +(31683,0,0x0000000000000020), +(31683,1,0x0000000000000020), +(31684,0,0x0000000000000020), +(31684,1,0x0000000000000020), +(31685,0,0x0000000000000020), +(31685,1,0x0000000000000020), +(31686,0,0x0000000000000020), +(31686,1,0x0000000000000020), +(31821,0,0x0000000004020048), +(31825,0,0x0000000000001020), +(31825,1,0x0000000200000000), +(31826,0,0x0000000000001020), +(31826,1,0x0000000200000000), +(31834,0,0x0000000080000000), +(31844,1,0x000005401A00038C), +(31845,1,0x000005401A00038C), +(31848,0,0x0000000000400000), +(31848,1,0x0000000000400000), +(31849,0,0x0000000000400000), +(31849,1,0x0000000000400000), +(31869,0,0x0000002000000000), +(31870,0,0x0000002000000000), +(31879,0,0x0000000800000400), +(31880,0,0x0000000800000400), +(31881,0,0x0000000800000400), +(31882,0,0x0000000800000400), +(31883,0,0x0000000800000400), +(32043,1,0x000004000A000000), +(32203,1,0x0001100001C22000), +(32381,0,0x0000000000000002), +(32382,0,0x0000000000000002), +(32383,0,0x0000000000000002), +(32412,0,0x0000000000000400), +(32477,0,0x0000020000000000), +(32483,0,0x0000020000000000), +(32484,0,0x0000020000000000), +(32601,1,0x0000000020800008), +(32743,0,0x0000000000000800), +(32973,0,0x0000000090100000), +(33018,0,0x0000001000000000), +(33020,0,0x0000000000000400), +(33063,0,0x0000040000000000), +(33066,0,0x0000000000000002), +(33151,0,0x0000000000000080), +(33151,1,0x0000000000000080), +(33151,2,0x0000000000000080), +(33158,0,0x0000000000001000), +(33158,1,0x0000000000000800), +(33159,0,0x0000000000001000), +(33159,1,0x0000000000000800), +(33160,0,0x0000000000001000), +(33160,1,0x0000000000000800), +(33161,0,0x0000000000001000), +(33161,1,0x0000000000000800), +(33162,0,0x0000000000001000), +(33162,1,0x0000000000000800), +(33167,0,0x0000008100000000), +(33171,0,0x0000008100000000), +(33172,0,0x0000008100000000), +(33174,0,0x0000000000000020), +(33174,1,0x0000000000000020), +(33182,0,0x0000000000000020), +(33182,1,0x0000000000000020), +(33186,0,0x0000008000000000), +(33186,1,0x0000008000002080), +(33190,0,0x0000008000000000), +(33190,1,0x0000008000002080), +(33213,0,0x0000000000822000), +(33214,0,0x0000000000822000), +(33215,0,0x0000000000822000), +(33221,0,0x0000000200002000), +(33222,0,0x0000000200002000), +(33223,0,0x0000000200002000), +(33224,0,0x0000000200002000), +(33225,0,0x0000000200002000), +(33333,0,0x0000000020000000), +(33421,0,0x0000000200000000), +(33557,0,0x0000000000000200), +(33557,1,0x0000000020000000), +(33565,0,0x0000000000001000), +(33600,0,0x0000000000000400), +(33600,1,0x0000000000000400), +(33601,0,0x0000000000000400), +(33601,1,0x0000000000000400), +(33602,0,0x0000000000000400), +(33602,1,0x0000000000000400), +(33603,0,0x0000000000000004), +(33603,1,0x0000000000000001), +(33604,0,0x0000000000000004), +(33604,1,0x0000000000000001), +(33605,0,0x0000000000000004), +(33605,1,0x0000000000000001), +(33606,0,0x0000000000000004), +(33606,1,0x0000000000000001), +(33607,0,0x0000000000000004), +(33607,1,0x0000000000000001), +(33693,0,0x0000000000008000), +(33696,0,0x0000000000000001), +(33713,0,0x0000000200000000), +(33714,0,0x0000000200000000), +(33830,0,0x0000002000000000), +(33830,1,0x0000002000000000), +(33877,0,0x0000000000000002), +(33879,0,0x0000000000000020), +(33880,0,0x0000000000000020), +(33886,0,0x00000010000000D0), +(33887,0,0x00000010000000D0), +(33888,0,0x00000010000000D0), +(33889,0,0x00000010000000D0), +(33890,0,0x00000010000000D0), +(34128,0,0x0000001000000000), +(34129,0,0x0000000040000000), +(34129,1,0x0000000040000000), +(34131,0,0x0000000000000080), +(34131,1,0x0000000000000080), +(34253,0,0x0000010000000000), +(34297,0,0x0000080000000000), +(34300,0,0x0000080000000000), +(34318,0,0x0000000000000400), +(34318,1,0x0000002000000000), +(34323,0,0x0000008000800000), +(34453,1,0x0000000400000000), +(34454,1,0x0000000400000000), +(34455,0,0x0000002000000000), +(34455,1,0x0000004000000000), +(34459,0,0x0000002000000000), +(34459,1,0x0000004000000000), +(34460,0,0x0000002000000000), +(34460,1,0x0000004000000000), +(34462,1,0x0000000800000000), +(34464,1,0x0000000800000000), +(34465,1,0x0000000800000000), +(34466,1,0x0000001000000000), +(34467,1,0x0000001000000000), +(34468,1,0x0000001000000000), +(34469,1,0x0000001000000000), +(34470,1,0x0000001000000000), +(34491,0,0x00004000000000C2), +(34491,1,0x0000000000000080), +(34492,0,0x00004000000000C2), +(34492,1,0x0000000000000080), +(34493,0,0x00004000000000C2), +(34493,1,0x0000000000000080), +(34754,0,0x0000000400001800), +(34936,0,0x0000004000000001), +(34948,1,0x0000000000000020), +(34949,1,0x0000000000000020), +(35029,1,0x0000080000000000), +(35030,1,0x0000080000000000), +(35098,0,0x0000000000020801), +(35099,0,0x0000000000020801), +(35104,0,0x0000000000001000), +(35104,1,0x0000000000002000), +(35110,0,0x0000000000001000), +(35110,1,0x0000000000002000), +(35111,0,0x0000000000001000), +(35111,1,0x0000000000002000), +(35363,0,0x0000000000000005), +(35364,0,0x0000000000000005), +(35396,1,0x000004000A000000), +(35397,1,0x000004000A000000), +(35446,0,0x0000000002000000), +(35446,1,0x0000000002000000), +(35448,0,0x0000000002000000), +(35448,1,0x0000000002000000), +(35449,0,0x0000000002000000), +(35449,1,0x0000000002000000), +(35450,0,0x0000000002000000), +(35450,1,0x0000000002000000), +(35451,0,0x0000000002000000), +(35451,1,0x0000000002000000), +(35578,0,0x0000000028E212F7), +(35581,0,0x0000000028E212F7), +(36032,0,0x0000000020000000), +(36032,1,0x0000000020000000), +(36413,0,0x0000000000000001), +(36563,1,0x0000000000000204), +(36563,2,0x0000000000000100), +(37166,0,0x0000000000800000), +(37167,0,0x0000000000040000), +(37171,0,0x00000009003E0000), +(37180,0,0x0000000000000020), +(37181,0,0x0000000400000000), +(37183,0,0x0000010000000000), +(37184,0,0x0000040008000000), +(37184,1,0x0000040008000000), +(37185,0,0x0000004000000000), +(37186,0,0x0000000020000000), +(37187,0,0x0000020000000000), +(37190,0,0x0000000000000008), +(37191,0,0x0000004000000000), +(37194,0,0x0000000000800000), +(37207,0,0x0000000000000002), +(37209,0,0x0000000000000400), +(37209,1,0x0000002000000000), +(37210,0,0x0000000000004000), +(37211,0,0x0000008000000000), +(37212,0,0x0000010000000000), +(37223,0,0x0000000000010000), +(37224,0,0x0000001000000000), +(37225,0,0x0000000000000080), +(37234,0,0x0000000000000080), +(37240,0,0x0000000000000080), +(37241,0,0x0000020000000000), +(37286,0,0x0000000000000010), +(37287,0,0x0000E000E2000000), +(37292,0,0x0008000000000000), +(37297,0,0x0000100000000000), +(37313,0,0x0000000000000040), +(37314,0,0x0000001000000000), +(37316,0,0x0000000000000040), +(37325,0,0x0000000000000040), +(37333,0,0x0000000000008000), +(37333,1,0x0000010000000000), +(37376,0,0x0000001000000000), +(37380,0,0x0000000000000006), +(37423,0,0x0000000000000004), +(37424,0,0x0000000000008000), +(37438,0,0x0000000000000021), +(37439,0,0x0000002000000000), +(37439,1,0x0000004000000000), +(37439,2,0x0000008000000000), +(37441,0,0x0000000020000000), +(37441,1,0x0000000020000000), +(37447,0,0x0000010000000000), +(37481,0,0x0000000000000080), +(37484,0,0x0000000000000100), +(37485,0,0x0000000000001000), +(37505,0,0x0000000100000000), +(37507,0,0x0000000000000800), +(37508,0,0x0000000100061800), +(37512,0,0x00000080000F0000), +(37513,0,0x0000000000000001), +(37517,0,0x0000014D2A600CEF), +(37518,0,0x0000000400000000), +(37522,0,0x0000000000001000), +(37535,0,0x0000000002000000), +(37536,0,0x0000000000010000), +(37556,0,0x0000000400000000), +(37564,0,0x0000000000000200), +(37565,0,0x0000000000001000), +(37570,1,0x0000010000000000), +(37571,0,0x0000000000000080), +(37571,1,0x0000000000800000), +(37593,0,0x0000000000000040), +(37706,0,0x0000000411041E40), +(37721,0,0x00000010000000F0), +(37722,0,0x00000000000001C0), +(37723,0,0x00000000C0000000), +(37736,0,0x0000040000000000), +(37736,1,0x0000004000000000), +(37737,0,0x0000000000000040), +(37738,0,0x0000000000000040), +(37739,0,0x0000000080000000), +(37740,0,0x0000000000000001), +(37742,0,0x0000004000000000), +(37760,0,0x0000000000000001), +(37762,0,0x0000001000000000), +(37763,0,0x0000800000000000), +(37878,0,0x00000010000000F0), +(37879,0,0x00000000C0000000), +(37880,0,0x0000000411041E40), +(37881,0,0x00000000000001C0), +(38314,0,0x0000E000E2000000), +(38321,0,0x0000000000000020), +(38322,0,0x0000000000000100), +(38388,0,0x0000000000040000), +(38389,0,0x0000000E00000006), +(38392,0,0x0000000100000000), +(38393,0,0x0000000000000001), +(38396,0,0x0000000004000000), +(38397,0,0x0000000000000821), +(38398,0,0x0000000020000000), +(38399,0,0x0000000002000000), +(38407,0,0x0000000100000000), +(38408,0,0x0000008000000000), +(38410,0,0x0000000000000200), +(38411,0,0x0000000000001000), +(38412,0,0x0000000000002000), +(38413,0,0x0000000000008000), +(38414,0,0x0000000000000002), +(38415,0,0x0000000000000004), +(38416,0,0x0010000000800000), +(38416,1,0x0010000000800000), +(38417,0,0x0000000200000000), +(38420,0,0x0000000000000020), +(38421,0,0x0000100000000000), +(38422,0,0x0000000000000020), +(38424,0,0x0000008000000000), +(38425,0,0x0000000040000000), +(38426,0,0x0000000080000000), +(38429,0,0x0000000090100000), +(38434,0,0x0000000000000100), +(38435,0,0x0000000000000080), +(38436,0,0x0000000000000001), +(38447,0,0x0000040000000000), +(38447,1,0x0000004000000000), +(38466,0,0x0008000000000000), +(38499,0,0x0000008000000000), +(38501,0,0x0000000000000080), +(38522,0,0x0000000040000000), +(39805,0,0x0000000000000003), +(39805,1,0x0000000000000003), +(39926,1,0x0000080000000000), +(39926,2,0x0000200000000000), +(39950,0,0x0000000000000040), +(40389,0,0x0000800000000000), +(40460,0,0x00000009003E0000), +(41021,0,0x0000004000000000), +(41021,1,0x0000004000000000), +(41026,0,0x0000004000000000), +(41026,1,0x0000004000000000), +(41037,0,0x0000044000000000), +(41042,0,0x0000000000800000), +(42367,0,0x0000001000000000), +(43339,0,0x0000000090100000), +(43725,0,0x0000001000000000), +(43736,0,0x0000000000000010), +(43743,1,0x0000000008000400), +(43752,0,0x0000000000000100), +(43837,0,0x0000000080000000), +(43840,0,0x0000044000000000), +(43841,0,0x0000000000000002), +(43842,0,0x0000044000000000), +(43843,0,0x0000044000000000), +(43844,0,0x0000000000000002), +(43845,0,0x0000000000000002), +(43850,0,0x0000000000800000), +(43851,0,0x0000000000800000), +(43852,0,0x0000000000800000), +(43854,0,0x0000004000000000), +(43855,0,0x0000004000000000), +(43856,0,0x0000004000000000), +(43857,0,0x0000001000000000), +(43858,0,0x0000001000000000), +(43859,0,0x0000001000000000), +(43860,0,0x0000000090100000), +(43861,0,0x0000000090100000), +(43862,0,0x0000000090100000), +(44292,0,0x0000000000001000), +(44293,0,0x0000000000000200), +(44295,0,0x0000000090100000), +(44296,0,0x0000000000000001), +(44297,0,0x0000000000010000), +(44299,0,0x0000000000040000), +(44300,0,0x0000800000000000), +(44301,0,0x0000000001000000), +(44302,0,0x0000000001000000), +(46088,0,0x0000044000000000), +(46090,0,0x0000000000000002), +(46091,0,0x0000000000800000), +(46095,0,0x0000004000000000), +(46096,0,0x0000001000000000), +(46097,0,0x0000000090100000), +(46100,0,0x0000001000000000), +(46833,0,0x0000000000000004), +(46834,0,0x0000000000000040), +(46851,0,0x0001000000000000); + +/*!40000 ALTER TABLE `spell_affect` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `spell_chain` +-- + +DROP TABLE IF EXISTS `spell_chain`; +CREATE TABLE `spell_chain` ( + `spell_id` mediumint(9) NOT NULL default '0', + `prev_spell` mediumint(9) NOT NULL default '0', + `first_spell` mediumint(9) NOT NULL default '0', + `rank` tinyint(4) NOT NULL default '0', + `req_spell` mediumint(9) NOT NULL default '0', + PRIMARY KEY (`spell_id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Spell Additinal Data'; + +-- +-- Dumping data for table `spell_chain` +-- + +LOCK TABLES `spell_chain` WRITE; +/*!40000 ALTER TABLE `spell_chain` DISABLE KEYS */; +INSERT INTO `spell_chain` VALUES +(10,0,10,1,0), +(17,0,17,1,0), +(53,0,53,1,0), +(72,0,72,1,0), +(78,0,78,1,0), +(99,0,99,1,0), +(100,0,100,1,0), +(116,0,116,1,0), +(118,0,118,1,0), +(120,0,120,1,0), +(122,0,122,1,0), +(133,0,133,1,0), +(136,0,136,1,0), +(139,0,139,1,0), +(143,133,133,2,0), +(145,143,133,3,0), +(168,0,168,1,0), +(172,0,172,1,0), +(205,116,116,2,0), +(284,78,78,2,0), +(285,284,78,3,0), +(324,0,324,1,0), +(325,324,324,2,0), +(331,0,331,1,0), +(332,331,331,2,0), +(339,0,339,1,0), +(348,0,348,1,0), +(370,0,370,1,0), +(403,0,403,1,0), +(408,0,408,1,0), +(421,0,421,1,0), +(453,0,453,1,0), +(465,0,465,1,0), +(467,0,467,1,0), +(469,0,469,1,0), +(498,0,498,1,0), +(527,0,527,1,0), +(529,403,403,2,0), +(543,0,543,1,0), +(547,332,331,3,0), +(548,529,403,3,0), +(585,0,585,1,0), +(586,0,586,1,0), +(587,0,587,1,0), +(588,0,588,1,0), +(589,0,589,1,0), +(591,585,585,2,0), +(592,17,17,2,0), +(594,589,589,2,0), +(596,0,596,1,0), +(597,587,587,2,0), +(598,591,585,3,0), +(600,592,17,3,0), +(602,7128,588,3,0), +(603,0,603,1,0), +(604,0,604,1,0), +(605,0,605,1,0), +(633,0,633,1,0), +(635,0,635,1,0), +(639,635,635,2,0), +(642,0,642,1,0), +(643,10290,465,3,0), +(647,639,635,3,0), +(686,0,686,1,0), +(687,0,687,1,0), +(688,0,688,1,0), +(689,0,689,1,0), +(693,0,693,1,0), +(694,0,694,1,0), +(695,686,686,2,0), +(696,687,687,2,0), +(699,689,689,2,0), +(702,0,702,1,0), +(703,0,703,1,0), +(704,0,704,1,0), +(705,695,686,3,0), +(706,0,706,1,0), +(707,348,348,2,0), +(709,699,689,3,0), +(710,0,710,1,0), +(724,0,724,1,0), +(740,0,740,1,0), +(755,0,755,1,0), +(769,780,779,3,0), +(770,0,770,1,0), +(772,0,772,1,0), +(774,0,774,1,0), +(778,770,770,2,0), +(779,0,779,1,0), +(780,779,779,2,0), +(781,0,781,1,0), +(782,467,467,2,0), +(837,205,116,3,0), +(845,0,845,1,0), +(853,0,853,1,0), +(865,122,122,2,0), +(879,0,879,1,0), +(905,325,324,3,0), +(913,547,331,4,0), +(915,548,403,4,0), +(930,421,421,2,0), +(939,913,331,5,0), +(943,915,403,5,0), +(945,905,324,4,0), +(959,939,331,6,0), +(970,594,589,3,0), +(974,0,974,1,0), +(976,0,976,1,0), +(980,0,980,1,0), +(984,598,585,4,0), +(988,527,527,2,0), +(990,597,587,3,0), +(992,970,589,4,0), +(996,596,596,2,0), +(1004,984,585,5,0), +(1006,602,588,4,0), +(1008,0,1008,1,0), +(1014,980,980,2,0), +(1020,642,642,2,0), +(1022,0,1022,1,0), +(1026,647,635,4,0), +(1032,10291,465,5,0), +(1038,0,1038,1,0), +(1042,1026,635,5,0), +(1058,774,774,2,0), +(1062,339,339,2,0), +(1064,0,1064,1,0), +(1075,782,467,3,0), +(1079,0,1079,1,0), +(1082,0,1082,1,0), +(1086,706,706,2,0), +(1088,705,686,4,0), +(1094,707,348,3,0), +(1098,0,1098,1,0), +(1106,1088,686,5,0), +(1108,702,702,2,0), +(1120,0,1120,1,0), +(1126,0,1126,1,0), +(1130,0,1130,1,0), +(1160,0,1160,1,0), +(1243,0,1243,1,0), +(1244,1243,1243,2,0), +(1245,1244,1243,3,0), +(1329,0,1329,1,0), +(1430,1058,774,3,0), +(1449,0,1449,1,0), +(1454,0,1454,1,0), +(1455,1454,1454,2,0), +(1456,1455,1454,3,0), +(1459,0,1459,1,0), +(1460,1459,1459,2,0), +(1461,1460,1459,3,0), +(1463,0,1463,1,0), +(1464,0,1464,1,0), +(1490,0,1490,1,0), +(1495,0,1495,1,0), +(1499,0,1499,1,0), +(1510,0,1510,1,0), +(1513,0,1513,1,0), +(1535,0,1535,1,0), +(1608,285,78,4,0), +(1671,72,72,2,0), +(1672,1671,72,3,0), +(1714,0,1714,1,0), +(1715,0,1715,1,0), +(1735,99,99,2,0), +(1742,0,1742,1,0), +(1752,0,1752,1,0), +(1753,1742,1742,2,0), +(1754,1753,1742,3,0), +(1755,1754,1742,4,0), +(1756,1755,1742,5,0), +(1757,1752,1752,2,0), +(1758,1757,1752,3,0), +(1759,1758,1752,4,0), +(1760,1759,1752,5,0), +(1766,0,1766,1,0), +(1767,1766,1766,2,0), +(1768,1767,1766,3,0), +(1769,1768,1766,4,0), +(1776,0,1776,1,0), +(1777,1776,1776,2,0), +(1784,0,1784,1,0), +(1785,1784,1784,2,0), +(1786,1785,1784,3,0), +(1787,1786,1784,4,0), +(1804,0,1804,1,0), +(1822,0,1822,1,0), +(1823,1822,1822,2,0), +(1824,1823,1822,3,0), +(1850,0,1850,1,0), +(1856,0,1856,1,0), +(1857,1856,1856,2,0), +(1943,0,1943,1,0), +(1949,0,1949,1,0), +(1966,0,1966,1,0), +(1978,0,1978,1,0), +(2006,0,2006,1,0), +(2008,0,2008,1,0), +(2010,2006,2006,2,0), +(2018,0,2018,1,0), +(2048,25289,6673,8,0), +(2050,0,2050,1,0), +(2052,2050,2050,2,0), +(2053,2052,2050,3,0), +(2054,0,2054,1,0), +(2055,2054,2054,2,0), +(2060,0,2060,1,0), +(2061,0,2061,1,0), +(2062,0,2062,1,0), +(2070,6770,6770,2,0), +(2090,1430,774,4,0), +(2091,2090,774,5,0), +(2096,0,2096,1,0), +(2098,0,2098,1,0), +(2108,0,2108,1,0), +(2120,0,2120,1,0), +(2121,2120,2120,2,0), +(2136,0,2136,1,0), +(2137,2136,2136,2,0), +(2138,2137,2136,3,0), +(2259,0,2259,1,0), +(2362,0,2362,1,0), +(2366,0,2366,1,0), +(2368,2366,2366,2,0), +(2550,0,2550,1,0), +(2575,0,2575,1,0), +(2576,2575,2575,2,0), +(2589,53,53,2,0), +(2590,2589,53,3,0), +(2591,2590,53,4,0), +(2637,0,2637,1,0), +(2643,0,2643,1,0), +(2649,0,2649,1,0), +(2651,0,2651,1,0), +(2652,0,2652,1,0), +(2767,992,589,5,0), +(2791,1245,1243,4,0), +(2800,633,633,2,0), +(2812,0,2812,1,0), +(2825,0,2825,1,0), +(2835,0,2835,1,0), +(2837,2835,2835,2,0), +(2860,930,421,3,0), +(2878,0,2878,1,0), +(2894,0,2894,1,0), +(2908,0,2908,1,0), +(2912,0,2912,1,0), +(2941,1094,348,4,0), +(2944,0,2944,1,0), +(2947,0,2947,1,0), +(2948,0,2948,1,0), +(2973,0,2973,1,0), +(2974,0,2974,1,0), +(2983,0,2983,1,0), +(3009,3010,16827,8,0), +(3010,16832,16827,7,0), +(3029,1082,1082,2,0), +(3034,0,3034,1,0), +(3044,0,3044,1,0), +(3100,2018,2018,2,0), +(3101,2259,2259,2,0), +(3102,2550,2550,2,0), +(3104,2108,2108,2,0), +(3110,0,3110,1,0), +(3111,136,136,2,0), +(3140,145,133,4,0), +(3273,0,3273,1,0), +(3274,3273,3273,2,0), +(3413,3102,2550,3,0), +(3420,0,3420,1,0), +(3421,3420,3420,2,0), +(3464,3101,2259,3,0), +(3472,1042,635,6,0), +(3538,3100,2018,3,0), +(3564,2576,2575,3,0), +(3570,2368,2366,3,0), +(3599,0,3599,1,0), +(3627,2091,774,6,0), +(3661,3111,136,3,0), +(3662,3661,136,4,0), +(3698,755,755,2,0), +(3699,3698,755,3,0), +(3700,3699,755,4,0), +(3716,0,3716,1,0), +(3738,0,3738,1,0), +(3747,600,17,4,0), +(3811,3104,2108,3,0), +(3908,0,3908,1,0), +(3909,3908,3908,2,0), +(3910,3909,3908,3,0), +(4036,0,4036,1,0), +(4037,4036,4036,2,0), +(4038,4037,4036,3,0), +(4187,0,4187,1,0), +(4188,4187,4187,2,0), +(4189,4188,4187,3,0), +(4190,4189,4187,4,0), +(4191,4190,4187,5,0), +(4192,4191,4187,6,0), +(4193,4192,4187,7,0), +(4194,4193,4187,8,0), +(5041,4194,4187,9,0), +(5042,5041,4187,10,0), +(5138,0,5138,1,0), +(5143,0,5143,1,0), +(5144,5143,5143,2,0), +(5145,5144,5143,3,0), +(5171,0,5171,1,0), +(5176,0,5176,1,0), +(5177,5176,5176,2,0), +(5178,5177,5176,3,0), +(5179,5178,5176,4,0), +(5180,5179,5176,5,0), +(5185,0,5185,1,0), +(5186,5185,5185,2,0), +(5187,5186,5185,3,0), +(5188,5187,5185,4,0), +(5189,5188,5185,5,0), +(5195,1062,339,3,0), +(5196,5195,339,4,0), +(5201,3029,1082,3,0), +(5211,0,5211,1,0), +(5215,0,5215,1,0), +(5217,0,5217,1,0), +(5221,0,5221,1,0), +(5232,1126,1126,2,0), +(5234,6756,1126,4,0), +(5242,6673,6673,2,0), +(5277,0,5277,1,0), +(5308,0,5308,1,0), +(5394,0,5394,1,0), +(5484,0,5484,1,0), +(5487,0,5487,1,0), +(5504,0,5504,1,0), +(5505,5504,5504,2,0), +(5506,5505,5504,3,0), +(5570,0,5570,1,0), +(5573,498,498,2,0), +(5588,853,853,2,0), +(5589,5588,853,3,0), +(5599,1022,1022,2,0), +(5614,879,879,2,0), +(5615,5614,879,3,0), +(5627,2878,2878,2,0), +(5675,0,5675,1,0), +(5676,0,5676,1,0), +(5699,6202,6201,3,0), +(5730,0,5730,1,0), +(5740,0,5740,1,0), +(5763,0,5763,1,0), +(5782,0,5782,1,0), +(5938,0,5938,1,0), +(6041,943,403,6,0), +(6060,1004,585,6,0), +(6063,2055,2054,3,0), +(6064,6063,2054,4,0), +(6065,3747,17,5,0), +(6066,6065,17,6,0), +(6074,139,139,2,0), +(6075,6074,139,3,0), +(6076,6075,139,4,0), +(6077,6076,139,5,0), +(6078,6077,139,6,0), +(6117,0,6117,1,0), +(6127,5506,5504,4,0), +(6129,990,587,4,0), +(6131,865,122,3,0), +(6141,10,10,2,0), +(6143,0,6143,1,0), +(6178,100,100,2,0), +(6190,1160,1160,2,0), +(6192,5242,6673,3,0), +(6201,0,6201,1,0), +(6202,6201,6201,2,0), +(6205,1108,702,3,0), +(6213,5782,5782,2,0), +(6215,6213,5782,3,0), +(6217,1014,980,3,0), +(6219,5740,5740,2,0), +(6222,172,172,2,0), +(6223,6222,172,3,0), +(6226,5138,5138,2,0), +(6229,0,6229,1,0), +(6307,0,6307,1,0), +(6343,0,6343,1,0), +(6353,0,6353,1,0), +(6360,0,6360,1,0), +(6363,3599,3599,2,0), +(6364,6363,3599,3,0), +(6365,6364,3599,4,0), +(6366,0,6366,1,0), +(6375,5394,5394,2,0), +(6377,6375,5394,3,0), +(6390,5730,5730,2,0), +(6391,6390,5730,3,0), +(6392,6391,5730,4,0), +(6542,0,6542,1,0), +(6546,772,772,2,0), +(6547,6546,772,3,0), +(6548,6547,772,4,0), +(6552,0,6552,1,0), +(6554,6552,6552,2,0), +(6572,0,6572,1,0), +(6574,6572,6572,2,0), +(6673,0,6673,1,0), +(6756,5232,1126,3,0), +(6760,2098,2098,2,0), +(6761,6760,2098,3,0), +(6762,6761,2098,4,0), +(6768,1966,1966,2,0), +(6770,0,6770,1,0), +(6774,5171,5171,2,0), +(6778,5189,5185,6,0), +(6780,5180,5176,6,0), +(6783,5215,5215,2,0), +(6785,0,6785,1,0), +(6787,6785,6785,2,0), +(6789,0,6789,1,0), +(6793,5217,5217,2,0), +(6798,5211,5211,2,0), +(6800,5221,5221,2,0), +(6807,0,6807,1,0), +(6808,6807,6807,2,0), +(6809,6808,6807,3,0), +(6940,0,6940,1,0), +(7128,588,588,2,0), +(7294,0,7294,1,0), +(7300,168,168,2,0), +(7301,7300,168,3,0), +(7302,0,7302,1,0), +(7320,7302,7302,2,0), +(7322,837,116,4,0), +(7328,0,7328,1,0), +(7369,845,845,2,0), +(7371,0,7371,1,0), +(7372,1715,1715,2,0), +(7373,7372,1715,3,0), +(7379,6574,6572,3,0), +(7384,0,7384,1,0), +(7386,0,7386,1,0), +(7400,694,694,2,0), +(7402,7400,694,3,0), +(7405,7386,7386,2,0), +(7411,0,7411,1,0), +(7412,7411,7411,2,0), +(7413,7412,7411,3,0), +(7620,0,7620,1,0), +(7641,1106,686,6,0), +(7646,6205,702,4,0), +(7648,6223,172,4,0), +(7651,709,689,4,0), +(7658,704,704,2,0), +(7659,7658,704,3,0), +(7731,7620,7620,2,0), +(7732,7731,7620,3,0), +(7799,3110,3110,2,0), +(7800,7799,3110,3,0), +(7801,7800,3110,4,0), +(7802,7801,3110,5,0), +(7804,6307,6307,2,0), +(7805,7804,6307,3,0), +(7809,3716,3716,2,0), +(7810,7809,3716,3,0), +(7811,7810,3716,4,0), +(7812,0,7812,1,0), +(7813,6360,6360,2,0), +(7814,0,7814,1,0), +(7815,7814,7814,2,0), +(7816,7815,7814,3,0), +(7887,7384,7384,2,0), +(7924,3274,3273,3,0), +(8004,0,8004,1,0), +(8005,959,331,7,0), +(8008,8004,8004,2,0), +(8010,8008,8004,3,0), +(8012,370,370,2,0), +(8017,0,8017,1,0), +(8018,8017,8017,2,0), +(8019,8018,8017,3,0), +(8024,0,8024,1,0), +(8027,8024,8024,2,0), +(8030,8027,8024,3,0), +(8033,0,8033,1,0), +(8038,8033,8033,2,0), +(8042,0,8042,1,0), +(8044,8042,8042,2,0), +(8045,8044,8042,3,0), +(8046,8045,8042,4,0), +(8050,0,8050,1,0), +(8052,8050,8050,2,0), +(8053,8052,8050,3,0), +(8056,0,8056,1,0), +(8058,8056,8056,2,0), +(8071,0,8071,1,0), +(8075,0,8075,1,0), +(8092,0,8092,1,0), +(8102,8092,8092,2,0), +(8103,8102,8092,3,0), +(8104,8103,8092,4,0), +(8105,8104,8092,5,0), +(8106,8105,8092,6,0), +(8122,0,8122,1,0), +(8124,8122,8122,2,0), +(8129,0,8129,1,0), +(8131,8129,8129,2,0), +(8134,945,324,5,0), +(8154,8071,8071,2,0), +(8155,8154,8071,3,0), +(8160,8075,8075,2,0), +(8161,8160,8075,3,0), +(8181,0,8181,1,0), +(8184,0,8184,1,0), +(8190,0,8190,1,0), +(8192,453,453,2,0), +(8198,6343,6343,2,0), +(8204,8198,6343,3,0), +(8205,8204,6343,4,0), +(8227,0,8227,1,0), +(8232,0,8232,1,0), +(8235,8232,8232,2,0), +(8249,8227,8227,2,0), +(8288,1120,1120,2,0), +(8289,8288,1120,3,0), +(8316,2947,2947,2,0), +(8317,8316,2947,3,0), +(8380,7405,7386,3,0), +(8400,3140,133,5,0), +(8401,8400,133,6,0), +(8402,8401,133,7,0), +(8406,7322,116,5,0), +(8407,8406,116,6,0), +(8408,8407,116,7,0), +(8412,2138,2136,4,0), +(8413,8412,2136,5,0), +(8416,5145,5143,4,0), +(8417,8416,5143,5,0), +(8422,2121,2120,3,0), +(8423,8422,2120,4,0), +(8427,6141,10,3,0), +(8437,1449,1449,2,0), +(8438,8437,1449,3,0), +(8439,8438,1449,4,0), +(8444,2948,2948,2,0), +(8445,8444,2948,3,0), +(8446,8445,2948,4,0), +(8450,604,604,2,0), +(8451,8450,604,3,0), +(8455,1008,1008,2,0), +(8457,543,543,2,0), +(8458,8457,543,3,0), +(8461,6143,6143,2,0), +(8462,8461,6143,3,0), +(8492,120,120,2,0), +(8494,1463,1463,2,0), +(8495,8494,1463,3,0), +(8498,1535,1535,2,0), +(8499,8498,1535,3,0), +(8512,0,8512,1,0), +(8613,0,8613,1,0), +(8617,8613,8613,2,0), +(8618,8617,8613,3,0), +(8621,1760,1752,6,0), +(8623,6762,2098,5,0), +(8624,8623,2098,6,0), +(8629,1777,1776,3,0), +(8631,703,703,2,0), +(8632,8631,703,3,0), +(8633,8632,703,4,0), +(8637,6768,1966,3,0), +(8639,1943,1943,2,0), +(8640,8639,1943,3,0), +(8643,408,408,2,0), +(8647,0,8647,1,0), +(8649,8647,8647,2,0), +(8650,8649,8647,3,0), +(8676,0,8676,1,0), +(8681,0,8681,1,0), +(8687,8681,8681,2,0), +(8691,8687,8681,3,0), +(8694,5763,5763,2,0), +(8696,2983,2983,2,0), +(8721,2591,53,5,0), +(8724,8676,8676,2,0), +(8725,8724,8676,3,0), +(8820,1464,1464,2,0), +(8835,0,8835,1,0), +(8903,6778,5185,7,0), +(8905,6780,5176,7,0), +(8907,5234,1126,5,0), +(8910,3627,774,7,0), +(8914,1075,467,4,0), +(8918,740,740,2,0), +(8921,0,8921,1,0), +(8924,8921,8921,2,0), +(8925,8924,8921,3,0), +(8926,8925,8921,4,0), +(8927,8926,8921,5,0), +(8928,8927,8921,6,0), +(8929,8928,8921,7,0), +(8936,0,8936,1,0), +(8938,8936,8936,2,0), +(8939,8938,8936,3,0), +(8940,8939,8936,4,0), +(8941,8940,8936,5,0), +(8949,2912,2912,2,0), +(8950,8949,2912,3,0), +(8951,8950,2912,4,0), +(8955,2908,2908,2,0), +(8972,6809,6807,4,0), +(8983,6798,5211,3,0), +(8992,6800,5221,3,0), +(8998,0,8998,1,0), +(9000,8998,8998,2,0), +(9005,0,9005,1,0), +(9035,0,9035,1,0), +(9472,2061,2061,2,0), +(9473,9472,2061,3,0), +(9474,9473,2061,4,0), +(9484,0,9484,1,0), +(9485,9484,9484,2,0), +(9490,1735,99,3,0), +(9492,1079,1079,2,0), +(9493,9492,1079,3,0), +(9578,586,586,2,0), +(9579,9578,586,3,0), +(9592,9579,586,4,0), +(9634,5487,5487,2,0), +(9745,8972,6807,5,0), +(9747,9490,99,4,0), +(9749,778,770,3,0), +(9750,8941,8936,6,0), +(9752,9493,1079,4,0), +(9754,769,779,4,0), +(9756,8914,467,5,0), +(9758,8903,5185,8,0), +(9785,3538,2018,4,0), +(9787,9785,2018,5,0), +(9788,9785,2018,5,0), +(9821,1850,1850,2,0), +(9823,9005,9005,2,0), +(9827,9823,9005,3,0), +(9829,8992,5221,4,0), +(9830,9829,5221,5,0), +(9833,8929,8921,8,0), +(9834,9833,8921,9,0), +(9835,9834,8921,10,0), +(9839,8910,774,8,0), +(9840,9839,774,9,0), +(9841,9840,774,10,0), +(9845,6793,5217,3,0), +(9846,9845,5217,4,0), +(9849,5201,1082,4,0), +(9850,9849,1082,5,0), +(9852,5196,339,5,0), +(9853,9852,339,6,0), +(9856,9750,8936,7,0), +(9857,9856,8936,8,0), +(9858,9857,8936,9,0), +(9862,8918,740,3,0), +(9863,9862,740,4,0), +(9866,6787,6785,3,0), +(9867,9866,6785,4,0), +(9875,8951,2912,5,0), +(9876,9875,2912,6,0), +(9880,9745,6807,6,0), +(9881,9880,6807,7,0), +(9884,8907,1126,6,0), +(9885,9884,1126,7,0), +(9888,9758,5185,9,0), +(9889,9888,5185,10,0), +(9892,9000,8998,3,0), +(9894,9752,1079,5,0), +(9896,9894,1079,6,0), +(9898,9747,99,5,0), +(9901,8955,2908,3,0), +(9904,1824,1822,4,0), +(9907,9749,770,4,0), +(9908,9754,779,5,0), +(9910,9756,467,6,0), +(9912,8905,5176,8,0), +(9913,6783,5215,3,0), +(10138,6127,5504,5,0), +(10139,10138,5504,6,0), +(10140,10139,5504,7,0), +(10144,6129,587,5,0), +(10145,10144,587,6,0), +(10148,8402,133,8,0), +(10149,10148,133,9,0), +(10150,10149,133,10,0), +(10151,10150,133,11,0), +(10156,1461,1459,4,0), +(10157,10156,1459,5,0), +(10159,8492,120,3,0), +(10160,10159,120,4,0), +(10161,10160,120,5,0), +(10169,8455,1008,3,0), +(10170,10169,1008,4,0), +(10173,8451,604,4,0), +(10174,10173,604,5,0), +(10177,8462,6143,4,0), +(10179,8408,116,8,0), +(10180,10179,116,9,0), +(10181,10180,116,10,0), +(10185,8427,10,4,0), +(10186,10185,10,5,0), +(10187,10186,10,6,0), +(10191,8495,1463,4,0), +(10192,10191,1463,5,0), +(10193,10192,1463,6,0), +(10197,8413,2136,6,0), +(10199,10197,2136,7,0), +(10201,8439,1449,5,0), +(10202,10201,1449,6,0), +(10205,8446,2948,5,0), +(10206,10205,2948,6,0), +(10207,10206,2948,7,0), +(10211,8417,5143,6,0), +(10212,10211,5143,7,0), +(10215,8423,2120,5,0), +(10216,10215,2120,6,0), +(10219,7320,7302,3,0), +(10220,10219,7302,4,0), +(10223,8458,543,4,0), +(10225,10223,543,5,0), +(10230,6131,122,4,0), +(10248,3564,2575,4,0), +(10278,5599,1022,3,0), +(10290,465,465,2,0), +(10291,643,465,4,0), +(10292,1032,465,6,0), +(10293,10292,465,7,0), +(10298,7294,7294,2,0), +(10299,10298,7294,3,0), +(10300,10299,7294,4,0), +(10301,10300,7294,5,0), +(10308,5589,853,4,0), +(10310,2800,633,3,0), +(10312,5615,879,4,0), +(10313,10312,879,5,0), +(10314,10313,879,6,0), +(10318,2812,2812,2,0), +(10322,7328,7328,2,0), +(10324,10322,7328,3,0), +(10326,5627,2878,3,0), +(10328,3472,635,7,0), +(10329,10328,635,8,0), +(10391,6041,403,7,0), +(10392,10391,403,8,0), +(10395,8005,331,8,0), +(10396,10395,331,9,0), +(10399,8019,8017,4,0), +(10406,8155,8071,4,0), +(10407,10406,8071,5,0), +(10408,10407,8071,6,0), +(10412,8046,8042,5,0), +(10413,10412,8042,6,0), +(10414,10413,8042,7,0), +(10427,6392,5730,5,0), +(10428,10427,5730,6,0), +(10431,8134,324,6,0), +(10432,10431,324,7,0), +(10437,6365,3599,5,0), +(10438,10437,3599,6,0), +(10442,8161,8075,4,0), +(10447,8053,8050,4,0), +(10448,10447,8050,5,0), +(10456,8038,8033,3,0), +(10462,6377,5394,4,0), +(10463,10462,5394,5,0), +(10466,8010,8004,4,0), +(10467,10466,8004,5,0), +(10468,10467,8004,6,0), +(10472,8058,8056,3,0), +(10473,10472,8056,4,0), +(10478,8181,8181,2,0), +(10479,10478,8181,3,0), +(10486,8235,8232,3,0), +(10495,5675,5675,2,0), +(10496,10495,5675,3,0), +(10497,10496,5675,4,0), +(10526,8249,8227,3,0), +(10537,8184,8184,2,0), +(10538,10537,8184,3,0), +(10585,8190,8190,2,0), +(10586,10585,8190,3,0), +(10587,10586,8190,4,0), +(10595,0,10595,1,0), +(10600,10595,10595,2,0), +(10601,10600,10595,3,0), +(10605,2860,421,4,0), +(10613,8512,8512,2,0), +(10614,10613,8512,3,0), +(10622,1064,1064,2,0), +(10623,10622,1064,3,0), +(10627,8835,8835,2,0), +(10656,10662,2108,5,0), +(10658,10662,2108,5,0), +(10660,10662,2108,5,0), +(10662,3811,2108,4,0), +(10768,8618,8613,4,0), +(10797,0,10797,1,0), +(10846,7924,3273,4,0), +(10874,8131,8129,3,0), +(10875,10874,8129,4,0), +(10876,10875,8129,5,0), +(10880,2010,2006,3,0), +(10881,10880,2006,4,0), +(10888,8124,8122,3,0), +(10890,10888,8122,4,0), +(10892,2767,589,6,0), +(10893,10892,589,7,0), +(10894,10893,589,8,0), +(10898,6066,17,7,0), +(10899,10898,17,8,0), +(10900,10899,17,9,0), +(10901,10900,17,10,0), +(10909,2096,2096,2,0), +(10911,605,605,2,0), +(10912,10911,605,3,0), +(10915,9474,2061,5,0), +(10916,10915,2061,6,0), +(10917,10916,2061,7,0), +(10927,6078,139,7,0), +(10928,10927,139,8,0), +(10929,10928,139,9,0), +(10933,6060,585,7,0), +(10934,10933,585,8,0), +(10937,2791,1243,5,0), +(10938,10937,1243,6,0), +(10941,9592,586,5,0), +(10942,10941,586,6,0), +(10945,8106,8092,7,0), +(10946,10945,8092,8,0), +(10947,10946,8092,9,0), +(10951,1006,588,5,0), +(10952,10951,588,6,0), +(10953,8192,453,3,0), +(10955,9485,9484,3,0), +(10957,976,976,2,0), +(10958,10957,976,3,0), +(10960,996,596,3,0), +(10961,10960,596,4,0), +(10963,2060,2060,2,0), +(10964,10963,2060,3,0), +(10965,10964,2060,4,0), +(11113,0,11113,1,0), +(11197,8650,8647,4,0), +(11198,11197,8647,5,0), +(11267,8725,8676,4,0), +(11268,11267,8676,5,0), +(11269,11268,8676,6,0), +(11273,8640,1943,4,0), +(11274,11273,1943,5,0), +(11275,11274,1943,6,0), +(11279,8721,53,6,0), +(11280,11279,53,7,0), +(11281,11280,53,8,0), +(11285,8629,1776,4,0), +(11286,11285,1776,5,0), +(11289,8633,703,5,0), +(11290,11289,703,6,0), +(11293,8621,1752,7,0), +(11294,11293,1752,8,0), +(11297,2070,6770,3,0), +(11299,8624,2098,7,0), +(11300,11299,2098,8,0), +(11303,8637,1966,4,0), +(11305,8696,2983,3,0), +(11314,8499,1535,4,0), +(11315,11314,1535,5,0), +(11341,8691,8681,4,0), +(11342,11341,8681,5,0), +(11343,11342,8681,6,0), +(11357,2837,2835,3,0), +(11358,11357,2835,4,0), +(11366,0,11366,1,0), +(11400,8694,5763,3,0), +(11426,0,11426,1,0), +(11549,6192,6673,4,0), +(11550,11549,6673,5,0), +(11551,11550,6673,6,0), +(11554,6190,1160,3,0), +(11555,11554,1160,4,0), +(11556,11555,1160,5,0), +(11564,1608,78,5,0), +(11565,11564,78,6,0), +(11566,11565,78,7,0), +(11567,11566,78,8,0), +(11572,6548,772,5,0), +(11573,11572,772,6,0), +(11574,11573,772,7,0), +(11578,6178,100,3,0), +(11580,8205,6343,5,0), +(11581,11580,6343,6,0), +(11584,7887,7384,3,0), +(11585,11584,7384,4,0), +(11596,8380,7386,4,0), +(11597,11596,7386,5,0), +(11600,7379,6572,4,0), +(11601,11600,6572,5,0), +(11604,8820,1464,3,0), +(11605,11604,1464,4,0), +(11608,7369,845,3,0), +(11609,11608,845,4,0), +(11611,3464,2259,4,0), +(11659,7641,686,7,0), +(11660,11659,686,8,0), +(11661,11660,686,9,0), +(11665,2941,348,5,0), +(11667,11665,348,6,0), +(11668,11667,348,7,0), +(11671,7648,172,5,0), +(11672,11671,172,6,0), +(11675,8289,1120,4,0), +(11677,6219,5740,3,0), +(11678,11677,5740,4,0), +(11683,1949,1949,2,0), +(11684,11683,1949,3,0), +(11687,1456,1454,4,0), +(11688,11687,1454,5,0), +(11689,11688,1454,6,0), +(11693,3700,755,5,0), +(11694,11693,755,6,0), +(11695,11694,755,7,0), +(11699,7651,689,5,0), +(11700,11699,689,6,0), +(11703,6226,5138,3,0), +(11704,11703,5138,4,0), +(11707,7646,702,5,0), +(11708,11707,702,6,0), +(11711,6217,980,4,0), +(11712,11711,980,5,0), +(11713,11712,980,6,0), +(11717,7659,704,4,0), +(11719,1714,1714,2,0), +(11721,1490,1490,2,0), +(11722,11721,1490,3,0), +(11725,1098,1098,2,0), +(11726,11725,1098,3,0), +(11729,5699,6201,4,0), +(11730,11729,6201,5,0), +(11733,1086,706,3,0), +(11734,11733,706,4,0), +(11735,11734,706,5,0), +(11739,6229,6229,2,0), +(11740,11739,6229,3,0), +(11762,7802,3110,6,0), +(11763,11762,3110,7,0), +(11766,7805,6307,4,0), +(11767,11766,6307,5,0), +(11770,8317,2947,4,0), +(11771,11770,2947,5,0), +(11774,7811,3716,5,0), +(11775,11774,3716,6,0), +(11778,7816,7814,4,0), +(11779,11778,7814,5,0), +(11780,11779,7814,6,0), +(11784,7813,6360,3,0), +(11785,11784,6360,4,0), +(11993,3570,2366,4,0), +(12180,3910,3908,4,0), +(12656,4038,4036,4,0), +(12294,0,12294,1,0), +(12505,11366,11366,2,0), +(12522,12505,11366,3,0), +(12523,12522,11366,4,0), +(12524,12523,11366,5,0), +(12525,12524,11366,6,0), +(12526,12525,11366,7,0), +(12824,118,118,2,0), +(12825,12824,118,3,0), +(12826,12825,118,4,0), +(13018,11113,11113,2,0), +(13019,13018,11113,3,0), +(13020,13019,11113,4,0), +(13021,13020,11113,5,0), +(13031,11426,11426,2,0), +(13032,13031,11426,3,0), +(13033,13032,11426,4,0), +(13165,0,13165,1,0), +(13220,0,13220,1,0), +(13228,13220,13220,2,0), +(13229,13228,13220,3,0), +(13230,13229,13220,4,0), +(13542,3662,136,5,0), +(13543,13542,136,6,0), +(13544,13543,136,7,0), +(13549,1978,1978,2,0), +(13550,13549,1978,3,0), +(13551,13550,1978,4,0), +(13552,13551,1978,5,0), +(13553,13552,1978,6,0), +(13554,13553,1978,7,0), +(13555,13554,1978,8,0), +(13795,0,13795,1,0), +(13813,0,13813,1,0), +(13896,0,13896,1,0), +(13908,0,13908,1,0), +(13920,7413,7411,4,0), +(14260,2973,2973,2,0), +(14261,14260,2973,3,0), +(14262,14261,2973,4,0), +(14263,14262,2973,5,0), +(14264,14263,2973,6,0), +(14265,14264,2973,7,0), +(14266,14265,2973,8,0), +(14267,2974,2974,2,0), +(14268,14267,2974,3,0), +(14269,1495,1495,2,0), +(14270,14269,1495,3,0), +(14271,14270,1495,4,0), +(14272,781,781,2,0), +(14273,14272,781,3,0), +(14274,20736,20736,2,0), +(14279,3034,3034,2,0), +(14280,14279,3034,3,0), +(14281,3044,3044,2,0), +(14282,14281,3044,3,0), +(14283,14282,3044,4,0), +(14284,14283,3044,5,0), +(14285,14284,3044,6,0), +(14286,14285,3044,7,0), +(14287,14286,3044,8,0), +(14288,2643,2643,2,0), +(14289,14288,2643,3,0), +(14290,14289,2643,4,0), +(14294,1510,1510,2,0), +(14295,14294,1510,3,0), +(14302,13795,13795,2,0), +(14303,14302,13795,3,0), +(14304,14303,13795,4,0), +(14305,14304,13795,5,0), +(14310,1499,1499,2,0), +(14311,14310,1499,3,0), +(14316,13813,13813,2,0), +(14317,14316,13813,3,0), +(14318,13165,13165,2,0), +(14319,14318,13165,3,0), +(14320,14319,13165,4,0), +(14321,14320,13165,5,0), +(14322,14321,13165,6,0), +(14323,1130,1130,2,0), +(14324,14323,1130,3,0), +(14325,14324,1130,4,0), +(14326,1513,1513,2,0), +(14327,14326,1513,3,0), +(14752,0,14752,1,0), +(14818,14752,14752,2,0), +(14819,14818,14752,3,0), +(14914,0,14914,1,0), +(14916,2649,2649,2,0), +(14917,14916,2649,3,0), +(14918,14917,2649,4,0), +(14919,14918,2649,5,0), +(14920,14919,2649,6,0), +(14921,14920,2649,7,0), +(15107,0,15107,1,0), +(15111,15107,15107,2,0), +(15112,15111,15107,3,0), +(15207,10392,403,9,0), +(15208,15207,403,10,0), +(15237,0,15237,1,0), +(15261,15267,14914,8,0), +(15262,14914,14914,2,0), +(15263,15262,14914,3,0), +(15264,15263,14914,4,0), +(15265,15264,14914,5,0), +(15266,15265,14914,6,0), +(15267,15266,14914,7,0), +(15407,0,15407,1,0), +(15430,15237,15237,2,0), +(15431,15430,15237,3,0), +(15629,14274,20736,3,0), +(15630,15629,20736,4,0), +(15631,15630,20736,5,0), +(15632,15631,20736,6,0), +(16314,10399,8017,5,0), +(16315,16314,8017,6,0), +(16316,16315,8017,7,0), +(16339,8030,8024,4,0), +(16341,16339,8024,5,0), +(16342,16341,8024,6,0), +(16355,10456,8033,4,0), +(16356,16355,8033,5,0), +(16362,10486,8232,4,0), +(16387,10526,8227,4,0), +(16511,0,16511,1,0), +(16689,0,16689,1,339), +(16697,1756,1742,6,0), +(16810,16689,16689,2,1062), +(16811,16810,16689,3,5195), +(16812,16811,16689,4,5196), +(16813,16812,16689,5,9852), +(16827,0,16827,1,0), +(16828,16827,16827,2,0), +(16829,16828,16827,3,0), +(16830,16829,16827,4,0), +(16831,16830,16827,5,0), +(16832,16831,16827,6,0), +(16857,0,16857,1,0), +(16914,0,16914,1,0), +(17039,9787,2018,6,0), +(17040,9787,2018,6,0), +(17041,9787,2018,6,0), +(17253,0,17253,1,0), +(17255,17253,17253,2,0), +(17256,17255,17253,3,0), +(17257,17256,17253,4,0), +(17258,17257,17253,5,0), +(17259,17258,17253,6,0), +(17260,17259,17253,7,0), +(17261,17260,17253,8,0), +(17311,15407,15407,2,0), +(17312,17311,15407,3,0), +(17313,17312,15407,4,0), +(17314,17313,15407,5,0), +(17329,16813,16689,6,9853), +(17347,16511,16511,2,0), +(17348,17347,16511,3,0), +(17390,16857,16857,2,0), +(17391,17390,16857,3,0), +(17392,17391,16857,4,0), +(17401,16914,16914,2,0), +(17402,17401,16914,3,0), +(17727,2362,2362,2,0), +(17728,17727,2362,3,0), +(17735,0,17735,1,0), +(17750,17735,17735,2,0), +(17751,17750,17735,3,0), +(17752,17751,17735,4,0), +(17767,0,17767,1,0), +(17850,17767,17767,2,0), +(17851,17850,17767,3,0), +(17852,17851,17767,4,0), +(17853,17852,17767,5,0), +(17854,17853,17767,6,0), +(17862,0,17862,1,0), +(17877,0,17877,1,0), +(17919,5676,5676,2,0), +(17920,17919,5676,3,0), +(17921,17920,5676,4,0), +(17922,17921,5676,5,0), +(17923,17922,5676,6,0), +(17924,6353,6353,2,0), +(17925,6789,6789,2,0), +(17926,17925,6789,3,0), +(17928,5484,5484,2,0), +(17937,17862,17862,2,0), +(17951,6366,6366,2,0), +(17952,17951,6366,3,0), +(17953,17952,6366,4,0), +(17962,0,17962,1,0), +(18137,0,18137,1,0), +(18220,0,18220,1,0), +(18248,7732,7620,4,0), +(18260,3413,2550,4,0), +(18265,0,18265,1,0), +(18647,710,710,2,0), +(18657,2637,2637,2,0), +(18658,18657,2637,3,0), +(18807,17314,15407,6,0), +(18809,12526,11366,8,0), +(18867,17877,17877,2,0), +(18868,18867,17877,3,0), +(18869,18868,17877,4,0), +(18870,18869,17877,5,0), +(18871,18870,17877,6,0), +(18879,18265,18265,2,0), +(18880,18879,18265,3,0), +(18881,18880,18265,4,0), +(18930,17962,17962,2,0), +(18931,18930,17962,3,0), +(18932,18931,17962,4,0), +(18937,18220,18220,2,0), +(18938,18937,18220,3,0), +(19236,13908,13908,2,0), +(19238,19236,13908,3,0), +(19240,19238,13908,4,0), +(19241,19240,13908,5,0), +(19242,19241,13908,6,0), +(19243,19242,13908,7,0), +(19261,2652,2652,2,0), +(19262,19261,2652,3,0), +(19264,19262,2652,4,0), +(19265,19264,2652,5,0), +(19266,19265,2652,6,0), +(19271,13896,13896,2,0), +(19273,19271,13896,3,0), +(19274,19273,13896,4,0), +(19275,19274,13896,5,0), +(19276,2944,2944,2,0), +(19277,19276,2944,3,0), +(19278,19277,2944,4,0), +(19279,19278,2944,5,0), +(19280,19279,2944,6,0), +(19281,9035,9035,2,0), +(19282,19281,9035,3,0), +(19283,19282,9035,4,0), +(19284,19283,9035,5,0), +(19285,19284,9035,6,0), +(19296,10797,10797,2,0), +(19299,19296,10797,3,0), +(19302,19299,10797,4,0), +(19303,19302,10797,5,0), +(19304,19303,10797,6,0), +(19305,19304,10797,7,0), +(19306,0,19306,1,0), +(19308,18137,18137,2,0), +(19309,19308,18137,3,0), +(19310,19309,18137,4,0), +(19311,19310,18137,5,0), +(19312,19311,18137,6,0), +(19386,0,19386,1,0), +(19434,0,19434,1,0), +(19438,7812,7812,2,0), +(19440,19438,7812,3,0), +(19441,19440,7812,4,0), +(19442,19441,7812,5,0), +(19443,19442,7812,6,0), +(19244,0,19244,1,0), +(19478,0,19478,1,0), +(19505,0,19505,1,0), +(19506,0,19506,1,0), +(19647,19244,19244,2,0), +(19655,19478,19478,2,0), +(19656,19655,19478,3,0), +(19660,19656,19478,4,0), +(19731,19505,19505,2,0), +(19734,19731,19505,3,0), +(19736,19734,19505,4,0), +(19740,0,19740,1,0), +(19742,0,19742,1,0), +(19750,0,19750,1,0), +(19834,19740,19740,2,0), +(19835,19834,19740,3,0), +(19836,19835,19740,4,0), +(19837,19836,19740,5,0), +(19838,19837,19740,6,0), +(19850,19742,19742,2,0), +(19852,19850,19742,3,0), +(19853,19852,19742,4,0), +(19854,19853,19742,5,0), +(19876,0,19876,1,0), +(19888,0,19888,1,0), +(19891,0,19891,1,0), +(19895,19876,19876,2,0), +(19896,19895,19876,3,0), +(19897,19888,19888,2,0), +(19898,19897,19888,3,0), +(19899,19891,19891,2,0), +(19900,19899,19891,3,0), +(19939,19750,19750,2,0), +(19940,19939,19750,3,0), +(19941,19940,19750,4,0), +(19942,19941,19750,5,0), +(19943,19942,19750,6,0), +(19977,0,19977,1,0), +(19978,19977,19977,2,0), +(19979,19978,19977,3,0), +(20043,0,20043,1,0), +(20116,26573,26573,2,0), +(20162,21082,21082,2,0), +(20164,0,20164,1,0), +(20165,0,20165,1,0), +(20166,0,20166,1,0), +(20190,20043,20043,2,0), +(20217,0,20217,1,0), +(20219,12656,4036,5,0), +(20222,12656,4036,5,0), +(20243,0,20243,1,0), +(20252,0,20252,1,0), +(20287,21084,21084,2,0), +(20288,20287,21084,3,0), +(20289,20288,21084,4,0), +(20290,20289,21084,5,0), +(20291,20290,21084,6,0), +(20292,20291,21084,7,0), +(20293,20292,21084,8,0), +(20305,20162,21082,3,0), +(20306,20305,21082,4,0), +(20307,20306,21082,5,0), +(20308,20307,21082,6,0), +(20347,20165,20165,2,0), +(20348,20347,20165,3,0), +(20349,20348,20165,4,0), +(20356,20166,20166,2,0), +(20357,20356,20166,3,0), +(20375,0,20375,1,0), +(20473,0,20473,1,0), +(20484,0,20484,1,0), +(20559,7402,694,4,0), +(20560,20559,694,5,0), +(20569,11609,845,5,0), +(20609,2008,2008,2,0), +(20610,20609,2008,3,0), +(20616,20252,20252,2,0), +(20617,20616,20252,3,0), +(20658,5308,5308,2,0), +(20660,20658,5308,3,0), +(20661,20660,5308,4,0), +(20662,20661,5308,5,0), +(20729,6940,6940,2,0), +(20736,0,20736,1,0), +(20739,20484,20484,2,0), +(20742,20739,20484,3,0), +(20747,20742,20484,4,0), +(20748,20747,20484,5,0), +(20752,693,693,2,0), +(20755,20752,693,3,0), +(20756,20755,693,4,0), +(20757,20756,693,5,0), +(20770,10881,2006,5,0), +(20772,10324,7328,4,0), +(20773,20772,7328,5,0), +(20776,20610,2008,4,0), +(20777,20776,2008,5,0), +(20900,19434,19434,2,0), +(20901,20900,19434,3,0), +(20902,20901,19434,4,0), +(20903,20902,19434,5,0), +(20904,20903,19434,6,0), +(20905,19506,19506,2,0), +(20906,20905,19506,3,0), +(20909,19306,19306,2,0), +(20910,20909,19306,3,0), +(20911,0,20911,1,0), +(20912,20911,20911,2,0), +(20913,20912,20911,3,0), +(20914,20913,20911,4,0), +(20915,20375,20375,2,0), +(20918,20915,20375,3,0), +(20919,20918,20375,4,0), +(20920,20919,20375,5,0), +(20922,20116,26573,3,0), +(20923,20922,26573,4,0), +(20924,20923,26573,5,0), +(20925,0,20925,1,0), +(20927,20925,20925,2,0), +(20928,20927,20925,3,0), +(20929,20473,20473,2,0), +(20930,20929,20473,3,0), +(21082,0,21082,1,0), +(21084,0,21084,1,0), +(21551,12294,12294,2,0), +(21552,21551,12294,3,0), +(21553,21552,12294,4,0), +(21562,0,21562,1,0), +(21564,21562,21562,2,0), +(21849,0,21849,1,0), +(21850,21849,21849,2,0), +(22568,0,22568,1,0), +(22782,6117,6117,2,0), +(22783,22782,6117,3,0), +(22827,22568,22568,2,0), +(22828,22827,22568,3,0), +(22829,22828,22568,4,0), +(22842,0,22842,1,0), +(22895,22842,22842,2,0), +(22896,22895,22842,3,0), +(23028,0,23028,1,0), +(23099,0,23099,1,0), +(23109,23099,23099,2,0), +(23110,23109,23099,3,0), +(23145,0,23145,1,0), +(23147,23145,23145,2,0), +(23148,23147,23145,3,0), +(23881,0,23881,1,0), +(23892,23881,23881,2,0), +(23893,23892,23881,3,0), +(23894,23893,23881,4,0), +(23922,0,23922,1,0), +(23923,23922,23922,2,0), +(23924,23923,23922,3,0), +(23925,23924,23922,4,0), +(23992,0,23992,1,0), +(24132,19386,19386,2,0), +(24133,24132,19386,3,0), +(24224,0,24224,1,0), +(24239,24274,24275,3,0), +(24248,31018,22568,6,0), +(24274,24275,24275,2,0), +(24275,0,24275,1,0), +(24398,0,24398,1,0), +(24423,0,24423,1,0), +(24439,23992,23992,2,0), +(24444,24439,23992,3,0), +(24445,24444,23992,4,0), +(24446,0,24446,1,0), +(24447,24446,24446,2,0), +(24448,24447,24446,3,0), +(24449,24448,24446,4,0), +(24450,0,24450,1,0), +(24452,24450,24450,2,0), +(24453,24452,24450,3,0), +(24488,0,24488,1,0), +(24492,0,24492,1,0), +(24493,0,24493,1,0), +(24497,24493,24493,2,0), +(24500,24497,24493,3,0), +(24501,24500,24493,4,0), +(24502,24492,24492,2,0), +(24503,24502,24492,3,0), +(24504,24503,24492,4,0), +(24505,24488,24488,2,0), +(24506,24505,24488,3,0), +(24507,24506,24488,4,0), +(24545,0,24545,1,0), +(24549,24545,24545,2,0), +(24550,24549,24545,3,0), +(24551,24550,24545,4,0), +(24552,24551,24545,5,0), +(24553,24552,24545,6,0), +(24554,24553,24545,7,0), +(24555,24554,24545,8,0), +(24577,24423,24423,2,0), +(24578,24577,24423,3,0), +(24579,24578,24423,4,0), +(24583,24640,24640,2,0), +(24586,24583,24640,3,0), +(24587,24586,24640,4,0), +(24597,24603,24604,4,0), +(24604,0,24604,1,0), +(24605,24604,24604,2,0), +(24603,24605,24604,3,0), +(24629,24555,24545,9,0), +(24630,24629,24545,10,0), +(24640,0,24640,1,0), +(24844,0,24844,1,0), +(24974,5570,5570,2,0), +(24975,24974,5570,3,0), +(24976,24975,5570,4,0), +(24977,24976,5570,5,0), +(25008,24844,24844,2,0), +(25009,25008,24844,3,0), +(25010,25009,24844,4,0), +(25011,25010,24844,5,0), +(25012,25011,24844,6,0), +(25076,0,25076,1,0), +(25202,11556,1160,6,0), +(25203,25202,1160,7,0), +(25208,11574,772,8,0), +(25210,25314,2060,6,0), +(25212,7373,1715,4,0), +(25213,25210,2060,7,0), +(25217,10901,17,11,0), +(25218,25217,17,12,0), +(25221,25315,139,11,0), +(25222,25221,139,12,0), +(25225,11597,7386,6,0), +(25229,0,25229,1,0), +(25230,25229,25229,2,0), +(25231,20569,845,6,0), +(25233,10917,2061,8,0), +(25234,20662,5308,6,0), +(25235,25233,2061,9,0), +(25236,25234,5308,7,0), +(25241,11605,1464,5,0), +(25242,25241,1464,6,0), +(25248,21553,12294,5,0), +(25251,23894,23881,5,0), +(25258,23925,23922,5,0), +(25264,11581,6343,7,0), +(25266,20560,694,6,0), +(25269,25288,6572,7,0), +(25272,20617,20252,4,0), +(25275,25272,20252,5,0), +(25286,11567,78,9,0), +(25288,11601,6572,6,0), +(25289,11551,6673,7,0), +(25290,19854,19742,6,0), +(25291,19838,19740,7,0), +(25292,10329,635,9,0), +(25294,14290,2643,5,0), +(25295,13555,1978,9,0), +(25296,14322,13165,7,0), +(25297,9889,5185,11,0), +(25298,9876,2912,7,0), +(25299,9841,774,11,0), +(25300,11281,53,9,0), +(25302,11303,1966,5,0), +(25304,10181,116,11,0), +(25306,10151,133,12,0), +(25307,11661,686,10,0), +(25308,25316,596,6,0), +(25309,11668,348,8,0), +(25311,11672,172,7,0), +(25312,27841,14752,5,0), +(25314,10965,2060,5,0), +(25315,10929,139,10,0), +(25316,10961,596,5,0), +(25331,27801,15237,7,0), +(25345,10212,5143,8,0), +(25347,11358,2835,5,0), +(25357,10396,331,10,0), +(25359,10627,8835,3,0), +(25361,10442,8075,5,0), +(25363,10934,585,9,0), +(25364,25363,585,10,0), +(25367,10894,589,9,0), +(25368,25367,589,10,0), +(25372,10947,8092,10,0), +(25375,25372,8092,11,0), +(25379,10876,8129,6,0), +(25380,25379,8129,7,0), +(25384,15261,14914,9,0), +(25387,18807,15407,7,0), +(25389,10938,1243,7,0), +(25391,25357,331,11,0), +(25396,25391,331,12,0), +(25420,10468,8004,7,0), +(25422,10623,1064,4,0), +(25423,25422,1064,5,0), +(25429,10942,586,7,0), +(25431,10952,588,7,0), +(25433,10958,976,4,0), +(25435,20770,2006,6,0), +(25437,19243,13908,8,0), +(25439,10605,421,5,0), +(25441,19275,13896,6,0), +(25442,25439,421,6,0), +(25446,19305,10797,8,0), +(25448,15208,403,11,0), +(25449,25448,403,12,0), +(25454,10414,8042,8,0), +(25457,29228,8050,7,0), +(25464,10473,8056,5,0), +(25467,19280,2944,7,0), +(25469,10432,324,8,0), +(25470,19285,9035,7,0), +(25472,25469,324,9,0), +(25477,19312,18137,7,0), +(25479,16316,8017,8,0), +(25485,25479,8017,9,0), +(25489,16342,8024,7,0), +(25500,16356,8033,6,0), +(25505,16362,8232,5,0), +(25508,10408,8071,7,0), +(25509,25508,8071,8,0), +(25525,10428,5730,7,0), +(25528,25361,8075,6,0), +(25533,10438,3599,7,0), +(25546,11315,1535,6,0), +(25547,25546,1535,7,0), +(25552,10587,8190,5,0), +(25557,16387,8227,5,0), +(25560,10479,8181,4,0), +(25563,10538,8184,4,0), +(25567,10463,5394,6,0), +(25570,10497,5675,5,0), +(25574,10601,10595,4,0), +(25577,15112,15107,4,0), +(25585,10614,8512,4,0), +(25587,25585,8512,5,0), +(25596,10953,453,4,0), +(25782,0,25782,1,19838), +(25890,0,25890,1,19979), +(25894,0,25894,1,19854), +(25895,0,25895,1,1038), +(25898,0,25898,1,20217), +(25899,0,25899,1,20914), +(25916,25782,25782,2,25291), +(25918,25894,25894,2,25290), +(26064,0,26064,1,0), +(26090,0,26090,1,0), +(26177,7371,7371,2,0), +(26178,26177,7371,3,0), +(26179,26178,7371,4,0), +(26187,26090,26090,2,0), +(26188,26187,26090,3,0), +(26201,26179,7371,5,0), +(26573,0,26573,1,0), +(26790,12180,3908,5,0), +(26797,12180,3908,5,0), +(26798,12180,3908,5,0), +(26801,12180,3908,5,0), +(26839,11290,703,7,0), +(26861,11294,1752,9,0), +(26862,26861,1752,10,0), +(26863,25300,53,10,0), +(26864,17348,16511,4,0), +(26865,31016,2098,10,0), +(26866,11198,8647,6,0), +(26867,11275,1943,7,0), +(26884,26839,703,8,0), +(26889,1857,1856,3,0), +(26892,11343,8681,7,0), +(26969,25347,2835,6,0), +(26978,25297,5185,12,0), +(26979,26978,5185,13,0), +(26980,9858,8936,10,0), +(26981,25299,774,12,0), +(26982,26981,774,13,0), +(26983,9863,740,5,0), +(26984,9912,5176,9,0), +(26985,26984,5176,10,0), +(26986,25298,2912,8,0), +(26987,9835,8921,11,0), +(26988,26987,8921,12,0), +(26989,9853,339,7,0), +(26990,9885,1126,8,0), +(26992,9910,467,7,0), +(26993,9907,770,5,0), +(26994,20748,20484,6,0), +(26995,9901,2908,4,0), +(26996,9881,6807,8,0), +(26997,9908,779,6,0), +(26998,9898,99,6,0), +(26999,22896,22842,4,0), +(27001,9830,5221,6,0), +(27002,27001,5221,7,0), +(27003,9904,1822,5,0), +(27005,9867,6785,5,0), +(27006,9827,9005,4,0), +(27008,9896,1079,7,0), +(27009,17329,16689,7,26989), +(27011,17392,16857,5,0), +(27012,17402,16914,4,0), +(27013,24977,5570,6,0), +(27014,14266,2973,9,0), +(27015,14273,781,4,0), +(27016,25295,1978,10,0), +(27018,14280,3034,4,0), +(27019,14287,3044,9,0), +(27020,15632,20736,7,0), +(27021,25294,2643,6,0), +(27022,14295,1510,4,0), +(27023,14305,13795,6,0), +(27025,14317,13813,4,0), +(27028,10846,3273,5,0), +(27044,25296,13165,8,0), +(27045,20190,20043,3,0), +(27046,13544,136,8,0), +(27047,14921,2649,8,0), +(27048,16697,1742,7,0), +(27049,3009,16827,9,0), +(27050,17261,17253,9,0), +(27051,24579,24423,5,0), +(27052,24501,24493,5,0), +(27053,24445,23992,5,0), +(27054,24449,24446,5,0), +(27055,24504,24492,5,0), +(27056,24507,24488,5,0), +(27060,24587,24640,5,0), +(27061,24630,24545,11,0), +(27062,5042,4187,11,0), +(27063,26188,26090,4,0), +(27065,20904,19434,7,0), +(27066,20906,19506,4,0), +(27067,20910,19306,4,0), +(27068,24133,19386,4,0), +(27070,25306,133,13,0), +(27071,25304,116,12,0), +(27072,27071,116,13,0), +(27073,10207,2948,8,0), +(27074,27073,2948,9,0), +(27075,25345,5143,9,0), +(27078,10199,2136,8,0), +(27079,27078,2136,9,0), +(27080,10202,1449,7,0), +(27082,27080,1449,8,0), +(27085,10187,10,7,0), +(27086,10216,2120,7,0), +(27087,10161,120,6,0), +(27088,10230,122,5,0), +(27090,37420,5504,9,0), +(27124,10220,7302,5,0), +(27125,22783,6117,4,0), +(27126,10157,1459,6,0), +(27128,10225,543,6,0), +(27130,10170,1008,5,0), +(27131,10193,1463,7,0), +(27132,18809,11366,9,0), +(27133,13021,11113,6,0), +(27134,13033,11426,5,0), +(27135,25292,635,10,0), +(27136,27135,635,11,0), +(27137,19943,19750,7,0), +(27138,10314,879,7,0), +(27139,10318,2812,3,0), +(27140,25291,19740,8,0), +(27141,25916,25782,3,27140), +(27142,25290,19742,7,0), +(27143,25918,25894,3,27142), +(27144,19979,19977,4,0), +(27145,25890,25890,2,27144), +(27147,20729,6940,3,0), +(27148,27147,6940,4,0), +(27149,10293,465,8,0), +(27150,10301,7294,6,0), +(27151,19896,19876,4,0), +(27152,19898,19888,4,0), +(27153,19900,19891,4,0), +(27154,10310,633,4,0), +(27155,20293,21084,9,0), +(27158,20308,21082,7,0), +(27166,20357,20166,4,0), +(27168,20914,20911,5,0), +(27169,25899,25899,2,27168), +(27170,20920,20375,6,0), +(27173,20924,26573,6,0), +(27174,20930,20473,4,0), +(27179,20928,20925,4,0), +(27180,24239,24275,4,0), +(27209,25307,686,11,0), +(27210,17923,5676,7,0), +(27211,17924,6353,3,0), +(27212,11678,5740,5,0), +(27213,11684,1949,4,0), +(27215,25309,348,9,0), +(27216,25311,172,8,0), +(27217,11675,1120,5,0), +(27218,11713,980,7,0), +(27219,11700,689,7,0), +(27220,27219,689,8,0), +(27221,11704,5138,5,0), +(27222,11689,1454,7,0), +(27223,17926,6789,4,0), +(27224,11708,702,7,0), +(27226,11717,704,5,0), +(27228,11722,1490,4,0), +(27229,17937,17862,3,0), +(27230,11730,6201,6,0), +(27238,20757,693,6,0), +(27250,17953,6366,5,0), +(27259,11695,755,8,0), +(27260,11735,706,6,0), +(27263,18871,17877,7,0), +(27264,18881,18265,5,0), +(27265,18938,18220,4,0), +(27266,18932,17962,5,0), +(27267,11763,3110,8,0), +(27268,11767,6307,6,0), +(27269,11771,2947,6,0), +(27270,11775,3716,7,0), +(27271,17752,17735,5,0), +(27272,17854,17767,7,0), +(27273,19443,7812,7,0), +(27274,11780,7814,7,0), +(27275,11785,6360,5,0), +(27276,19736,19505,5,0), +(27277,27276,19505,6,0), +(27280,19660,19478,5,0), +(27282,26969,2835,7,0), +(27283,13230,13220,5,0), +(27441,11269,8676,7,0), +(27448,25302,1966,6,0), +(27681,14752,14752,2,0), +(27683,0,27683,1,0), +(27685,26201,7371,6,0), +(27799,15431,15237,4,0), +(27800,27799,15237,5,0), +(27801,27800,15237,6,0), +(27841,14819,14752,4,0), +(27870,724,724,2,0), +(27871,27870,724,3,0), +(28029,13920,7411,5,0), +(28172,17728,2362,4,0), +(28176,0,28176,1,0), +(28189,28176,28176,2,0), +(28275,27871,724,4,0), +(28596,11611,2259,5,0), +(28609,10177,6143,5,0), +(28610,11740,6229,4,0), +(28612,10145,587,7,0), +(28672,11611,2259,5,0), +(28675,11611,2259,5,0), +(28677,11611,2259,5,0), +(28695,11993,2366,5,0), +(28894,25230,25229,3,0), +(28895,28894,25229,4,0), +(28897,28895,25229,5,0), +(29228,10448,8050,6,0), +(29354,10248,2575,5,0), +(29704,1672,72,4,0), +(29707,25286,78,10,0), +(29722,0,29722,1,0), +(29801,0,29801,1,0), +(29844,9785,2018,5,0), +(30016,20243,20243,2,0), +(30022,30016,20243,3,0), +(30030,29801,29801,2,0), +(30033,30030,29801,3,0), +(30108,0,30108,1,0), +(30151,0,30151,1,0), +(30194,30151,30151,2,0), +(30198,30194,30151,3,0), +(30213,0,30213,1,0), +(30219,30213,30213,2,0), +(30223,30219,30213,3,0), +(30283,0,30283,1,0), +(30324,29707,78,11,0), +(30330,25248,12294,6,0), +(30335,25251,23881,6,0), +(30350,12656,4036,5,0), +(30356,25258,23922,6,0), +(30357,25269,6572,8,0), +(30404,30108,30108,2,0), +(30405,30404,30108,3,0), +(30413,30283,30283,2,0), +(30414,30413,30283,3,0), +(30459,27210,5676,8,0), +(30545,27211,6353,4,0), +(30546,27263,17877,8,0), +(30908,27221,5138,6,0), +(30909,27224,702,8,0), +(30910,603,603,2,0), +(30911,27264,18265,6,0), +(30912,27266,17962,6,0), +(31016,11300,2098,9,0), +(31018,22829,22568,5,0), +(31661,0,31661,1,0), +(31785,0,31785,1,0), +(31895,20164,20164,2,0), +(31935,0,31935,1,0), +(32231,29722,29722,2,0), +(32379,0,32379,1,0), +(32549,10662,2108,5,0), +(32593,974,974,2,0), +(32594,32593,974,3,0), +(32645,0,32645,1,0), +(32678,10768,8613,5,0), +(32684,32645,32645,2,0), +(32699,31935,31935,2,0), +(32700,32699,31935,3,0), +(32796,28609,6143,6,0), +(32996,32379,32379,2,0), +(32999,27681,14752,3,0), +(33041,31661,31661,2,0), +(33042,33041,31661,3,0), +(33043,33042,31661,4,0), +(33072,27174,20473,5,0), +(33095,18248,7620,5,0), +(33142,0,33142,1,0), +(33145,33142,33142,2,0), +(33146,33145,33142,3,0), +(33359,18260,2550,5,0), +(33388,0,33388,1,0), +(33391,33388,33388,2,0), +(33405,27134,11426,6,0), +(33698,0,33698,1,0), +(33699,33698,33698,2,0), +(33700,33699,33698,3,0), +(33701,27271,17735,6,0), +(33717,28612,587,8,0), +(33736,24398,24398,2,0), +(33776,31785,31785,2,0), +(33876,0,33876,1,0), +(33878,0,33878,1,0), +(33933,27133,11113,7,0), +(33938,27132,11366,10,0), +(33943,0,33943,1,0), +(33944,10174,604,6,0), +(33946,27130,1008,6,0), +(33982,33876,33876,2,0), +(33983,33982,33876,3,0), +(33986,33878,33878,2,0), +(33987,33986,33878,3,0), +(34411,1329,1329,2,0), +(34412,34411,1329,3,0), +(34413,34412,1329,4,0), +(34506,0,34506,1,0), +(34507,34506,34506,2,0), +(34508,34507,34506,3,0), +(34838,34508,34506,4,0), +(34839,34838,34506,5,0), +(34861,0,34861,1,0), +(34863,34861,34861,2,0), +(34864,34863,34861,3,0), +(34865,34864,34861,4,0), +(34866,34865,34861,5,0), +(34889,0,34889,1,0), +(34914,0,34914,1,0), +(34916,34914,34914,2,0), +(34917,34916,34914,3,0), +(34950,0,34950,1,0), +(34954,34950,34950,2,0), +(35323,34889,34889,2,0), +(35290,0,35290,1,0), +(35291,35290,35290,2,0), +(35292,35291,35290,3,0), +(35293,35292,35290,4,0), +(35294,35293,35290,5,0), +(35295,35294,35290,6,0), +(35296,35295,35290,7,0), +(35297,35296,35290,8,0), +(35298,35297,35290,9,0), +(35387,0,35387,1,0), +(35389,35387,35387,2,0), +(35392,35389,35387,3,0), +(35346,0,35346,1,0), +(35694,0,35694,1,0), +(35698,35694,35694,2,0), +(36916,14271,1495,5,0), +(37420,10140,5504,8,0), +(38692,27070,133,14,0), +(38697,27072,116,14,0), +(38699,27075,5143,10,0), +(38704,38699,5143,11,0), +(38764,11286,1776,6,0), +(38768,1769,1766,5,0), +(40120,33943,33943,2,0); +/*!40000 ALTER TABLE `spell_chain` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `spell_elixir` +-- + +DROP TABLE IF EXISTS `spell_elixir`; +CREATE TABLE `spell_elixir` ( + `entry` int(11) unsigned NOT NULL default '0' COMMENT 'SpellId of potion', + `mask` tinyint(1) unsigned NOT NULL default '0' COMMENT 'Mask 0x1 battle 0x2 guardian 0x3 flask 0x7 unstable flasks 0xB shattrath flasks', + PRIMARY KEY (`entry`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Spell System'; + +-- +-- Dumping data for table `spell_elixir` +-- + +LOCK TABLES `spell_elixir` WRITE; +/*!40000 ALTER TABLE `spell_elixir` DISABLE KEYS */; +INSERT INTO `spell_elixir` VALUES +( 673,0x2), +( 2367,0x1), +( 2374,0x1), +( 2378,0x2), +( 2380,0x2), +( 3160,0x1), +( 3164,0x1), +( 3166,0x2), +( 3219,0x2), +( 3220,0x2), +( 3222,0x2), +( 3223,0x2), +( 3593,0x2), +( 7844,0x1), +( 8212,0x1), +(10667,0x1), +(10668,0x2), +(10669,0x1), +(10692,0x2), +(10693,0x2), +(11319,0x2), +(11328,0x1), +(11334,0x1), +(11348,0x2), +(11349,0x2), +(11364,0x2), +(11371,0x2), +(11390,0x1), +(11396,0x2), +(11405,0x1), +(11406,0x1), +(11474,0x1), +(15231,0x2), +(15233,0x2), +(16321,0x2), +(16322,0x1), +(16323,0x1), +(16325,0x2), +(16326,0x2), +(16327,0x2), +(16329,0x1), +(17038,0x1), +(17535,0x2), +(17537,0x1), +(17538,0x1), +(17539,0x1), +(17624,0x3), +(17626,0x3), +(17627,0x3), +(17629,0x3), +(17628,0x3), +(21920,0x1), +(24361,0x2), +(24363,0x2), +(24382,0x2), +(24383,0x2), +(24417,0x2), +(26276,0x1), +(27652,0x2), +(27653,0x2), +(28486,0x1), +(28488,0x1), +(28490,0x1), +(28491,0x1), +(28493,0x1), +(28497,0x1), +(28501,0x1), +(28502,0x2), +(28503,0x1), +(28509,0x2), +(28514,0x2), +(28518,0x3), +(28519,0x3), +(28520,0x3), +(28521,0x3), +(28540,0x3), +(29348,0x2), +(33720,0x1), +(33721,0x1), +(33726,0x1), +(38954,0x1), +(39625,0x2), +(39626,0x2), +(39627,0x2), +(39628,0x2), +(40567,0x7), +(40568,0x7), +(40572,0x7), +(40573,0x7), +(40575,0x7), +(40576,0x7), +(41608,0xB), +(41609,0xB), +(41610,0xB), +(41611,0xB), +(42735,0x3), +(46837,0xB), +(46839,0xB); +/*!40000 ALTER TABLE `spell_elixir` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `spell_learn_spell` +-- + +DROP TABLE IF EXISTS `spell_learn_spell`; +CREATE TABLE `spell_learn_spell` ( + `entry` smallint(5) unsigned NOT NULL default '0', + `SpellID` smallint(5) unsigned NOT NULL default '0', + PRIMARY KEY (`entry`,`SpellID`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Item System'; + +-- +-- Dumping data for table `spell_learn_spell` +-- + +LOCK TABLES `spell_learn_spell` WRITE; +/*!40000 ALTER TABLE `spell_learn_spell` DISABLE KEYS */; +INSERT INTO `spell_learn_spell` VALUES +(2842,8681), +(5784,33388), +(13819,33388), +(17002,24867), +(23161,33391), +(23214,33391), +(24866,24864), +(33872,47179), +(33873,47180), +(33943,34090), +(34767,33391), +(34769,33388); + +/*!40000 ALTER TABLE `spell_learn_spell` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `spell_pet_auras` +-- + +DROP TABLE IF EXISTS `spell_pet_auras`; +CREATE TABLE `spell_pet_auras` ( + `spell` mediumint(8) unsigned NOT NULL COMMENT 'dummy spell id', + `pet` mediumint(8) unsigned NOT NULL default '0' COMMENT 'pet id; 0 = all', + `aura` mediumint(8) unsigned NOT NULL COMMENT 'pet aura id', + PRIMARY KEY (`spell`,`pet`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; + +-- +-- Dumping data for table `spell_pet_auras` +-- + +LOCK TABLES `spell_pet_auras` WRITE; +/*!40000 ALTER TABLE `spell_pet_auras` DISABLE KEYS */; +INSERT INTO `spell_pet_auras` VALUES +(19028, 0, 25228), +(19578, 0, 19579), +(20895, 0, 24529), +(28757, 0, 28758), +(35029, 0, 35060), +(35030, 0, 35061), +(35691, 0, 35696), +(35692, 0, 35696), +(35693, 0, 35696), +(23785, 416, 23759), +(23822, 416, 23826), +(23823, 416, 23827), +(23824, 416, 23828), +(23825, 416, 23829), +(23785, 417, 23762), +(23822, 417, 23837), +(23823, 417, 23838), +(23824, 417, 23839), +(23825, 417, 23840), +(23785, 1860, 23760), +(23822, 1860, 23841), +(23823, 1860, 23842), +(23824, 1860, 23843), +(23825, 1860, 23844), +(23785, 1863, 23761), +(23822, 1863, 23833), +(23823, 1863, 23834), +(23824, 1863, 23835), +(23825, 1863, 23836), +(23785, 17252, 35702), +(23822, 17252, 35703), +(23823, 17252, 35704), +(23824, 17252, 35705), +(23825, 17252, 35706); + +/*!40000 ALTER TABLE `spell_pet_auras` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `spell_proc_event` +-- + +DROP TABLE IF EXISTS `spell_proc_event`; +CREATE TABLE `spell_proc_event` ( + `entry` smallint(5) unsigned NOT NULL default '0', + `SchoolMask` tinyint(4) NOT NULL default '0', + `Category` smallint(6) NOT NULL default '0', + `SkillID` smallint(6) NOT NULL default '0', + `SpellFamilyName` smallint(5) unsigned NOT NULL default '0', + `SpellFamilyMask` bigint(20) unsigned NOT NULL default '0', + `procFlags` int(10) unsigned NOT NULL default '0', + `ppmRate` float NOT NULL default '0', + `cooldown` int(10) unsigned NOT NULL default '0', + PRIMARY KEY (`entry`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + +-- +-- Dumping data for table `spell_proc_event` +-- + +LOCK TABLES `spell_proc_event` WRITE; +/*!40000 ALTER TABLE `spell_proc_event` DISABLE KEYS */; +INSERT INTO `spell_proc_event` VALUES +(168,0,0,0,0,0x0000000000000000,0x00000002,0,0), +(324,0,0,0,0,0x0000000000000000,0x00100402,0,3), +(325,0,0,0,0,0x0000000000000000,0x00100402,0,3), +(588,0,0,0,0,0x0000000000000000,0x00000402,0,0), +(602,0,0,0,0,0x0000000000000000,0x00000402,0,0), +(742,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(905,0,0,0,0,0x0000000000000000,0x00100402,0,3), +(945,0,0,0,0,0x0000000000000000,0x00100402,0,3), +(974,0,0,0,0,0x0000000000000000,0x00100402,0,3), +(1006,0,0,0,0,0x0000000000000000,0x00000402,0,0), +(1120,0,0,0,0,0x0000000000000000,0x00000004,0,0), +(2565,0,0,0,0,0x0000000000000000,0x00000040,0,0), +(2652,0,0,0,0,0x0000000000000000,0x00000002,0,0), +(3235,0,0,0,0,0x0000000000000000,0x00000002,0,0), +(3284,0,0,0,0,0x0000000000000000,0x00000002,0,0), +(3338,0,0,0,0,0x0000000000000000,0x00000002,0,0), +(3394,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(3417,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(3418,0,0,0,0,0x0000000000000000,0x00000002,0,0), +(3424,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(3436,0,0,0,0,0x0000000000000000,0x00000002,0,0), +(3439,0,0,0,0,0x0000000000000000,0x00000002,0,0), +(3440,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(3509,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(3512,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(3582,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(3616,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(3637,0,0,0,0,0x0000000000000000,0x00000002,0,0), +(4070,0,0,0,0,0x0000000000000000,0x00000002,0,0), +(4112,0,0,0,0,0x0000000000000000,0x00000002,0,0), +(4113,0,0,0,0,0x0000000000000000,0x00000002,0,0), +(4114,0,0,0,0,0x0000000000000000,0x00000002,0,0), +(4115,0,0,0,0,0x0000000000000000,0x00000002,0,0), +(4133,0,0,0,0,0x0000000000000000,0x00000002,0,0), +(4136,0,0,0,0,0x0000000000000000,0x00000002,0,0), +(4138,0,0,0,0,0x0000000000000000,0x00000002,0,0), +(4140,0,0,0,0,0x0000000000000000,0x00000002,0,0), +(4142,0,0,0,0,0x0000000000000000,0x00000004,0,0), +(4144,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(4241,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(4242,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(4245,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(4279,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(4283,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(4284,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(4315,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(4317,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(4493,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(4525,0,0,0,0,0x0000000000000000,0x00000002,0,0), +(4932,0,0,0,0,0x0000000000000000,0x00000002,0,0), +(4951,0,0,0,0,0x0000000000000000,0x00000002,0,0), +(5104,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(5118,0,0,0,0,0x0000000000000000,0x00008000,0,0), +(5202,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(5205,0,0,0,0,0x0000000000000000,0x00000002,0,0), +(5262,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(5301,0,0,0,0,0x0000000000000000,0x00000000,0,0), +(5364,0,0,0,0,0x0000000000000000,0x00000002,0,0), +(5368,0,0,0,0,0x0000000000000000,0x00000002,0,0), +(5369,0,0,0,0,0x0000000000000000,0x00000002,0,0), +(5370,0,0,0,0,0x0000000000000000,0x00000002,0,0), +(5377,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(5427,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(5680,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(5728,0,0,0,0,0x0000000000000000,0x00100402,0,0), +(5811,0,0,0,0,0x0000000000000000,0x00000002,0,0), +(6268,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(6397,0,0,0,0,0x0000000000000000,0x00100402,0,0), +(6398,0,0,0,0,0x0000000000000000,0x00100402,0,0), +(6399,0,0,0,0,0x0000000000000000,0x00100402,0,0), +(6433,0,0,0,0,0x0000000000000000,0x00000002,0,0), +(6645,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(6750,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(6752,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(6866,0,0,0,0,0x0000000000000000,0x00000072,0,0), +(6867,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(6870,0,0,0,0,0x0000000000000000,0x00000000,0,0), +(6871,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(6909,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(6921,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(6923,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(6947,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(6961,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(7095,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(7098,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(7102,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(7103,0,0,0,0,0x0000000000000000,0x00000002,0,0), +(7128,0,0,0,0,0x0000000000000000,0x00000402,0,0), +(7131,0,0,0,0,0x0000000000000000,0x000A22A8,0,0), +(7137,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(7276,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(7300,0,0,0,0,0x0000000000000000,0x00000002,0,0), +(7301,0,0,0,0,0x0000000000000000,0x00000002,0,0), +(7302,0,0,0,0,0x0000000000000000,0x00000002,0,0), +(7320,0,0,0,0,0x0000000000000000,0x00000002,0,0), +(7445,0,0,0,0,0x0000000000000000,0x00000002,0,0), +(7446,0,0,0,0,0x0000000000000000,0x00000002,0,0), +(7486,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(7617,0,0,0,0,0x0000000000000000,0x00100002,0,0), +(7619,0,0,0,0,0x0000000000000000,0x00100002,0,0), +(7711,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(7721,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(7722,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(7723,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(7724,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(7725,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(7726,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(7806,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(7807,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(7808,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(7849,0,0,0,0,0x0000000000000000,0x00000002,0,0), +(7999,0,0,0,0,0x0000000000000000,0x00000002,0,0), +(8134,0,0,0,0,0x0000000000000000,0x00100402,0,3), +(8224,0,0,0,0,0x0000000000000000,0x00000002,0,0), +(8247,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(8260,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(8288,0,0,0,0,0x0000000000000000,0x00000004,0,0), +(8289,0,0,0,0,0x0000000000000000,0x00000004,0,0), +(8397,0,0,0,0,0x0000000000000000,0x00000002,0,0), +(8601,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(8612,0,0,0,0,0x0000000000000000,0x00000002,0,0), +(8788,0,0,0,0,0x0000000000000000,0x00000402,0,0), +(8852,0,0,0,0,0x0000000000000000,0x00000002,0,0), +(8876,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(8981,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(9084,0,0,0,0,0x0000000000000000,0x00000008,0,0), +(9160,0,0,0,0,0x0000000000000000,0x00000002,0,0), +(9233,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(9276,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(9452,0,0,0,0,0x0000000000000000,0x00000014,3,0), +(9460,0,0,0,0,0x0000000000000000,0x00000002,0,0), +(9463,0,0,0,0,0x0000000000000000,0x00000002,0,0), +(9778,0,0,0,0,0x0000000000000000,0x00000002,0,0), +(9782,0,0,0,0,0x0000000000000000,0x00000040,0,0), +(9784,0,0,0,0,0x0000000000000000,0x00000040,0,0), +(9799,0,0,0,0,0x0000000000000000,0x00040000,0,0), +(10022,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(10092,0,0,0,0,0x0000000000000000,0x00000080,0,0), +(10219,0,0,0,0,0x0000000000000000,0x00000002,0,0), +(10220,0,0,0,0,0x0000000000000000,0x00000002,0,0), +(10425,0,0,0,0,0x0000000000000000,0x00100402,0,0), +(10426,0,0,0,0,0x0000000000000000,0x00100402,0,0), +(10431,0,0,0,0,0x0000000000000000,0x00100402,0,3), +(10432,0,0,0,0,0x0000000000000000,0x00100402,0,3), +(10951,0,0,0,0,0x0000000000000000,0x00000402,0,0), +(10952,0,0,0,0,0x0000000000000000,0x00000402,0,0), +(11103,4,0,0,0,0x0000000000000000,0x00020000,0,0), +(11119,4,0,0,0,0x0000000000000000,0x00010000,0,0), +(11120,4,0,0,0,0x0000000000000000,0x00010000,0,0), +(11129,4,0,0,0,0x0000000000000000,0x00020000,0,0), +(11180,16,0,0,0,0x0000000000000000,0x00020000,0,0), +(11185,0,0,0,3,0x0000000000000080,0x00020000,0,0), +(11213,0,0,0,0,0x0000000000000000,0x00020000,0,0), +(11255,0,0,0,3,0x0000000000004000,0x00004000,0,0), +(11371,0,0,0,0,0x0000000000000000,0x00000002,0,0), +(11441,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(11675,0,0,0,0,0x0000000000000000,0x00000004,0,0), +(11919,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(11959,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(11964,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(11984,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(12099,0,0,0,0,0x0000000000000000,0x00000040,0,0), +(12169,0,0,0,0,0x0000000000000000,0x00000040,0,0), +(12246,0,0,0,0,0x0000000000000000,0x00000002,0,0), +(12254,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(12281,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(12284,0,0,0,0,0x0000000000000000,0x00000001,0.33252,0), +(12289,0,0,26,0,0x0000000000000002,0x00020000,0,0), +(12292,0,0,0,0,0x0000000000000000,0x00000080,0,0), +(12298,0,0,0,0,0x0000000000000000,0x00000040,0,0), +(12311,0,0,0,4,0x0000000000000800,0x00020000,0,0), +(12317,0,0,0,0,0x0000000000000000,0x00842000,0,0), +(12319,0,0,0,0,0x0000000000000000,0x00011000,0,0), +(12322,0,0,0,0,0x0000000000000000,0x00000001,2,0), +(12328,0,0,0,0,0x0000000000000000,0xC4000001,0,0), +(12357,4,0,0,0,0x0000000000000000,0x00020000,0,0), +(12358,4,0,0,0,0x0000000000000000,0x00020000,0,0), +(12359,4,0,0,0,0x0000000000000000,0x00020000,0,0), +(12360,4,0,0,0,0x0000000000000000,0x00020000,0,0), +(12487,0,0,0,3,0x0000000000000080,0x00020000,0,0), +(12488,0,0,0,3,0x0000000000000080,0x00020000,0,0), +(12529,0,0,0,0,0x0000000000000000,0x00000002,0,0), +(12539,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(12544,0,0,0,0,0x0000000000000000,0x00000002,0,0), +(12550,0,0,0,0,0x0000000000000000,0x00000402,0,0), +(12556,0,0,0,0,0x0000000000000000,0x00000002,0,0), +(12574,0,0,0,0,0x0000000000000000,0x00020000,0,0), +(12575,0,0,0,0,0x0000000000000000,0x00020000,0,0), +(12576,0,0,0,0,0x0000000000000000,0x00020000,0,0), +(12577,0,0,0,0,0x0000000000000000,0x00020000,0,0), +(12598,0,0,0,3,0x0000000000004000,0x00004000,0,0), +(12668,0,0,26,0,0x0000000000000002,0x00020000,0,0), +(12701,0,0,0,0,0x0000000000000000,0x00000001,0.66504,0), +(12702,0,0,0,0,0x0000000000000000,0x00000001,0.99756,0), +(12703,0,0,0,0,0x0000000000000000,0x00000001,1.33008,0), +(12704,0,0,0,0,0x0000000000000000,0x00000001,1.6626,0), +(12724,0,0,0,0,0x0000000000000000,0x00000040,0,0), +(12725,0,0,0,0,0x0000000000000000,0x00000040,0,0), +(12726,0,0,0,0,0x0000000000000000,0x00000040,0,0), +(12727,0,0,0,0,0x0000000000000000,0x00000040,0,0), +(12782,0,0,0,0,0x0000000000000000,0x00000040,0,0), +(12787,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(12797,0,0,0,0,0x0000000000000400,0x00020000,0,0), +(12799,0,0,0,0,0x0000000000000400,0x00020000,0,0), +(12800,0,0,0,0,0x0000000000000400,0x00020000,0,0), +(12812,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(12813,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(12814,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(12815,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(12834,0,0,0,0,0x0000000000000000,0x00011000,0,0), +(12846,4,0,0,0,0x0000000000000000,0x00010000,0,0), +(12847,4,0,0,0,0x0000000000000000,0x00010000,0,0), +(12848,4,0,0,0,0x0000000000000000,0x00010000,0,0), +(12849,0,0,0,0,0x0000000000000000,0x00011000,0,0), +(12867,0,0,0,0,0x0000000000000000,0x00011000,0,0), +(12947,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(12958,0,0,0,4,0x0000000000000800,0x00020000,0,0), +(12966,0,0,0,0,0x0000000000000000,0xC4000001,0,0), +(12967,0,0,0,0,0x0000000000000000,0xC4000001,0,0), +(12968,0,0,0,0,0x0000000000000000,0xC4000001,0,0), +(12969,0,0,0,0,0x0000000000000000,0xC4000001,0,0), +(12970,0,0,0,0,0x0000000000000000,0xC4000001,0,0), +(12971,0,0,0,0,0x0000000000000000,0x00011000,0,0), +(12972,0,0,0,0,0x0000000000000000,0x00011000,0,0), +(12973,0,0,0,0,0x0000000000000000,0x00011000,0,0), +(12974,0,0,0,0,0x0000000000000000,0x00011000,0,0), +(12999,0,0,0,0,0x0000000000000000,0x00000001,4,0), +(13000,0,0,0,0,0x0000000000000000,0x00000001,6,0), +(13001,0,0,0,0,0x0000000000000000,0x00000001,8,0), +(13002,0,0,0,0,0x0000000000000000,0x00000001,10,0), +(13045,0,0,0,0,0x0000000000000000,0x00842000,0,0), +(13046,0,0,0,0,0x0000000000000000,0x00842000,0,0), +(13047,0,0,0,0,0x0000000000000000,0x00842000,0,0), +(13048,0,0,0,0,0x0000000000000000,0x00842000,0,0), +(13159,0,0,0,0,0x0000000000000000,0x00008000,0,0), +(13165,0,0,0,0,0x0000000000000000,0x00080000,0,0), +(13299,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(13358,0,0,0,0,0x0000000000000000,0x00000000,0,0), +(13585,0,0,0,0,0x0000000000000000,0x00000402,0,0), +(13616,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(13709,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(13716,0,0,0,0,0x0000000000000000,0x00000402,0,0), +(13754,0,0,0,0,0x0000000000000010,0x00020000,0,0), +(13800,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(13801,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(13802,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(13803,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(13867,0,0,0,0,0x0000000000000010,0x00020000,0,0), +(13877,0,0,0,0,0x0000000000000000,0xC4000001,0,0), +(13879,0,0,0,0,0x0000000000000000,0x00000002,0,0), +(13886,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(13896,0,0,0,0,0x0000000000000000,0x00100000,0,0), +(13959,0,0,0,0,0x0000000000000000,0x00100002,0,0), +(13960,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(13961,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(13962,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(13963,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(13964,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(13983,0,0,0,0,0x0000000000000000,0x01000010,0,0), +(14070,0,0,0,0,0x0000000000000000,0x01000010,0,0), +(14071,0,0,0,0,0x0000000000000000,0x01000010,0,0), +(14108,0,0,0,0,0x0000000000000000,0x00000002,0,0), +(14111,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(14133,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(14144,0,0,0,0,0x0000000000000000,0x00000004,0,0), +(14148,0,0,0,0,0x0000000000000000,0x00000004,0,0), +(14156,0,0,0,0,0x00000000003E0000,0x00020000,0,0), +(14160,0,0,0,0,0x00000000003E0000,0x00020000,0,0), +(14161,0,0,0,0,0x00000000003E0000,0x00020000,0,0), +(14178,0,0,0,0,0x0000000000000000,0x00000002,0,0), +(14186,0,0,0,8,0x0000000040800508,0x00010000,0,0), +(14190,0,0,0,8,0x0000000040800508,0x00010000,0,0), +(14193,0,0,0,8,0x0000000040800508,0x00010000,0,0), +(14194,0,0,0,8,0x0000000040800508,0x00010000,0,0), +(14195,0,0,0,8,0x0000000040800508,0x00010000,0,0), +(14318,0,0,0,0,0x0000000000000000,0x00080000,0,0), +(14319,0,0,0,0,0x0000000000000000,0x00080000,0,0), +(14320,0,0,0,0,0x0000000000000000,0x00080000,0,0), +(14321,0,0,0,0,0x0000000000000000,0x00080000,0,0), +(14322,0,0,0,0,0x0000000000000000,0x00080000,0,0), +(14531,0,0,0,0,0x0000000000000000,0x00002000,0,0), +(14774,0,0,0,0,0x0000000000000000,0x00002000,0,0), +(14796,0,0,0,0,0x0000000000000000,0x00000800,0,0), +(14869,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(14892,0,0,0,6,0x0000000410001E00,0x10000000,0,0), +(15088,0,0,0,0,0x0000000000000000,0x00001000,0,0), +(15097,0,0,0,0,0x0000000000000000,0x00002000,0,0), +(15268,32,0,0,0,0x0000000000000000,0x00020000,0,0), +(15270,0,0,0,0,0x0000000000000000,0x00000004,0,0), +(15277,0,0,0,0,0x0000000000000000,0x00000001,6,0), +(15286,32,0,0,0,0x0000000000000000,0x00008000,0,0), +(15323,32,0,0,0,0x0000000000000000,0x00020000,0,0), +(15324,32,0,0,0,0x0000000000000000,0x00020000,0,0), +(15325,32,0,0,0,0x0000000000000000,0x00020000,0,0), +(15326,32,0,0,0,0x0000000000000000,0x00020000,0,0), +(15335,0,0,0,0,0x0000000000000000,0x00000004,0,0), +(15336,0,0,0,0,0x0000000000000000,0x00000004,0,0), +(15337,0,0,0,0,0x0000000000000000,0x00000004,0,0), +(15338,0,0,0,0,0x0000000000000000,0x00000004,0,0), +(15346,0,0,0,0,0x0000000000000000,0x00000001,6,0), +(15362,0,0,0,6,0x0000000410001E00,0x10000000,0,0), +(15363,0,0,0,6,0x0000000410001E00,0x10000000,0,0), +(15506,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(15507,0,0,0,0,0x0000000000000000,0x00000402,0,0), +(15573,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(15594,0,0,0,0,0x0000000000000000,0x00000002,0,0), +(15599,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(15600,0,0,0,0,0x0000000000000000,0x00000001,0.6,0), +(15603,0,0,0,0,0x0000000000000000,0x00000002,0,0), +(15636,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(15641,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(15730,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(15733,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(15784,0,0,0,0,0x0000000000000000,0x00000002,0,0), +(15849,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(15852,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(15876,0,0,0,0,0x0000000000000000,0x00000002,0,0), +(15978,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(16092,0,0,0,0,0x0000000000000000,0x00000000,0,0), +(16142,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(16146,0,0,0,0,0x0000000000000000,0x00000800,0,0), +(16164,28,0,0,0,0x0000000000000000,0x00010000,0,0), +(16176,0,0,0,0,0x0000000000000000,0x10000000,0,0), +(16235,0,0,0,0,0x0000000000000000,0x10000000,0,0), +(16240,0,0,0,0,0x0000000000000000,0x10000000,0,0), +(16247,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(16256,0,0,0,0,0x0000000000000000,0x00001000,0,0), +(16257,0,0,0,0,0x0000000000000000,0xC4000001,0,0), +(16277,0,0,0,0,0x0000000000000000,0xC4000001,0,0), +(16278,0,0,0,0,0x0000000000000000,0xC4000001,0,0), +(16279,0,0,0,0,0x0000000000000000,0xC4000001,0,0), +(16280,0,0,0,0,0x0000000000000000,0xC4000001,0,0), +(16281,0,0,0,0,0x0000000000000000,0x00001000,0,0), +(16282,0,0,0,0,0x0000000000000000,0x00001000,0,0), +(16283,0,0,0,0,0x0000000000000000,0x00001000,0,0), +(16284,0,0,0,0,0x0000000000000000,0x00001000,0,0), +(16428,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(16487,0,0,0,0,0x0000000000000000,0x00842000,0,0), +(16489,0,0,0,0,0x0000000000000000,0x00842000,0,0), +(16492,0,0,0,0,0x0000000000000000,0x00842000,0,0), +(16550,0,0,0,0,0x0000000000000000,0x00002000,0,0), +(16574,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(16575,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(16611,0,0,0,0,0x0000000000000000,0x00000002,0,0), +(16615,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(16620,0,0,0,0,0x0000000000000000,0x00100402,0,30), +(16624,0,0,0,0,0x0000000000000000,0x00000040,0,0), +(16689,0,0,0,0,0x0000000000000000,0x00000002,0,0), +(16792,0,0,0,0,0x0000000000000000,0x00002000,0,0), +(16800,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(16810,0,0,0,0,0x0000000000000000,0x00000002,0,0), +(16811,0,0,0,0,0x0000000000000000,0x00000002,0,0), +(16812,0,0,0,0,0x0000000000000000,0x00000002,0,0), +(16813,0,0,0,0,0x0000000000000000,0x00000002,0,0), +(16843,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(16850,0,0,0,0,0x0000000000000004,0x00020000,0,0), +(16864,0,0,0,0,0x0000000000000000,0x00000001,2,0), +(16880,0,0,0,0,0x0000000000000000,0x00010000,0,0), +(16923,0,0,0,0,0x0000000000000004,0x00020000,0,0), +(16924,0,0,0,0,0x0000000000000004,0x00020000,0,0), +(16952,0,0,0,0,0x0000040000039000,0x00010000,0,0), +(16954,0,0,0,0,0x0000040000039000,0x00010000,0,0), +(16958,0,0,0,0,0x0000000000000000,0x00011000,0,0), +(16961,0,0,0,0,0x0000000000000000,0x00011000,0,0), +(16982,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(17010,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(17106,0,0,0,7,0x0000000000080000,0x00004000,0,0), +(17107,0,0,0,7,0x0000000000080000,0x00004000,0,0), +(17108,0,0,0,7,0x0000000000080000,0x00004000,0,0), +(17329,0,0,0,0,0x0000000000000000,0x00000002,0,0), +(17332,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(17350,0,0,0,0,0x0000000000000000,0x00000002,0,0), +(17364,0,0,0,0,0x0000000000000000,0x00008000,0,0), +(17495,0,0,0,0,0x0000000000000000,0x00000040,0,0), +(17670,0,0,0,0,0x0000000000000000,0x00000008,0,0), +(17687,0,0,0,0,0x0000000000000000,0xC4000001,0,0), +(17688,0,0,0,0,0x0000000000000000,0x00000080,0,0), +(17690,0,0,0,0,0x0000000000000000,0x00000002,0,0), +(17793,0,0,0,5,0x0000000000000001,0x00010000,0,0), +(17794,0,0,0,0,0x0000000000000000,0x00008000,0,0), +(17796,0,0,0,5,0x0000000000000001,0x00010000,0,0), +(17797,0,0,0,0,0x0000000000000000,0x00008000,0,0), +(17798,0,0,0,0,0x0000000000000000,0x00008000,0,0), +(17799,0,0,0,0,0x0000000000000000,0x00008000,0,0), +(17800,0,0,0,0,0x0000000000000000,0x00008000,0,0), +(17801,0,0,0,5,0x0000000000000001,0x00010000,0,0), +(17802,0,0,0,5,0x0000000000000001,0x00010000,0,0), +(17803,0,0,0,5,0x0000000000000001,0x00010000,0,0), +(18073,0,0,0,0,0x0000008000000060,0x00020000,0,0), +(18094,0,0,0,5,0x000000000000000A,0x00020000,0,0), +(18095,0,0,0,5,0x000000000000000A,0x00020000,0,0), +(18096,0,0,0,0,0x0000008000000060,0x00020000,0,0), +(18097,0,0,0,0,0x0000000000000000,0x00000002,0,0), +(18100,0,0,0,0,0x0000000000000000,0x00000002,0,0), +(18119,0,0,593,0,0x0000000000000000,0x00020000,0,0), +(18120,0,0,593,0,0x0000000000000000,0x00020000,0,0), +(18121,0,0,593,0,0x0000000000000000,0x00020000,0,0), +(18122,0,0,593,0,0x0000000000000000,0x00020000,0,0), +(18123,0,0,593,0,0x0000000000000000,0x00020000,0,0), +(18137,0,0,0,0,0x0000000000000000,0x00100402,0,3), +(18146,0,0,0,0,0x0000000000000000,0x00000002,0,0), +(18167,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(18186,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(18189,0,0,0,0,0x0000000000000000,0x00020000,0,0), +(18542,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(18765,0,0,0,0,0x0000000000000000,0xC4000001,0,0), +(18799,0,0,0,0,0x0000000000000000,0x00000002,0,0), +(18800,0,0,0,0,0x0000000000000000,0x00000008,0,0), +(18803,0,0,0,0,0x0000000000000000,0x00004000,0,0), +(18815,0,0,0,0,0x0000000000000000,0x00000002,0,0), +(18816,0,0,0,0,0x0000000000000000,0x00000002,0,0), +(18847,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(18943,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(18979,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(18983,0,0,0,0,0x0000000000000000,0x00000004,0,0), +(19184,0,0,0,0,0x0000000000000000,0x00200000,0,0), +(19194,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(19228,0,0,0,0,0x0000000000000040,0x00020000,0,0), +(19232,0,0,0,0,0x0000000000000040,0x00020000,0,0), +(19233,0,0,0,0,0x0000000000000040,0x00020000,0,0), +(19261,0,0,0,0,0x0000000000000000,0x00000002,0,0), +(19262,0,0,0,0,0x0000000000000000,0x00000002,0,0), +(19264,0,0,0,0,0x0000000000000000,0x00000002,0,0), +(19265,0,0,0,0,0x0000000000000000,0x00000002,0,0), +(19266,0,0,0,0,0x0000000000000000,0x00000002,0,0), +(19271,0,0,0,0,0x0000000000000000,0x00100000,0,0), +(19273,0,0,0,0,0x0000000000000000,0x00100000,0,0), +(19274,0,0,0,0,0x0000000000000000,0x00100000,0,0), +(19275,0,0,0,0,0x0000000000000000,0x00100000,0,0), +(19308,0,0,0,0,0x0000000000000000,0x00100402,0,3), +(19309,0,0,0,0,0x0000000000000000,0x00100402,0,3), +(19310,0,0,0,0,0x0000000000000000,0x00100402,0,3), +(19311,0,0,0,0,0x0000000000000000,0x00100402,0,3), +(19312,0,0,0,0,0x0000000000000000,0x00100402,0,3), +(19387,0,0,0,0,0x0000000000000000,0x00200000,0,0), +(19388,0,0,0,0,0x0000000000000000,0x00200000,0,0), +(19407,0,0,0,0,0x0000000000000200,0x00020000,0,0), +(19409,0,0,0,0,0x0000000000000000,0x00100002,0,0), +(19412,0,0,0,0,0x0000000000000200,0x00020000,0,0), +(19413,0,0,0,0,0x0000000000000200,0x00020000,0,0), +(19414,0,0,0,0,0x0000000000000200,0x00020000,0,0), +(19415,0,0,0,0,0x0000000000000200,0x00020000,0,0), +(19449,0,0,0,0,0x0000000000000000,0x00000002,0,0), +(19478,0,0,0,0,0x0000000000000000,0x00000002,0,0), +(19514,0,0,0,0,0x0000000000000000,0x00000402,0,0), +(19572,0,0,0,9,0x0000000000800000,0x08000000,0,0), +(19573,0,0,0,9,0x0000000000800000,0x08000000,0,0), +(19577,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(19655,0,0,0,0,0x0000000000000000,0x00000002,0,0), +(19656,0,0,0,0,0x0000000000000000,0x00000002,0,0), +(19660,0,0,0,0,0x0000000000000000,0x00000002,0,0), +(19817,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(19818,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(20049,0,0,0,0,0x0000000000000000,0x00011000,0,0), +(20056,0,0,0,0,0x0000000000000000,0x00011000,0,0), +(20057,0,0,0,0,0x0000000000000000,0x00011000,0,0), +(20058,0,0,0,0,0x0000000000000000,0x00011000,0,0), +(20059,0,0,0,0,0x0000000000000000,0x00011000,0,0), +(20127,0,0,0,0,0x0000000000000000,0x00000402,0,0), +(20128,0,0,0,0,0x0000000000000000,0x00000040,0,0), +(20130,0,0,0,0,0x0000000000000000,0x00000402,0,0), +(20131,0,0,0,0,0x0000000000000000,0x00000040,0,0), +(20132,0,0,0,0,0x0000000000000000,0x00000040,0,0), +(20133,0,0,0,0,0x0000000000000000,0x00000040,0,0), +(20134,0,0,0,0,0x0000000000000000,0x00000040,0,0), +(20135,0,0,0,0,0x0000000000000000,0x00000402,0,0), +(20136,0,0,0,0,0x0000000000000000,0x00000402,0,0), +(20137,0,0,0,0,0x0000000000000000,0x00000402,0,0), +(20154,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(20164,0,0,0,0,0x0000000000000000,0x00000001,5,0), +(20165,0,0,0,0,0x0000000000000000,0x00000001,20,0), +(20166,0,0,0,0,0x0000000000000000,0x00000001,20,0), +(20177,0,0,0,0,0x0000000000000000,0x00100402,0,0), +(20178,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(20179,0,0,0,0,0x0000000000000000,0x00100402,0,0), +(20180,0,0,0,0,0x0000000000000000,0x00100402,0,0), +(20181,0,0,0,0,0x0000000000000000,0x00100402,0,0), +(20182,0,0,0,0,0x0000000000000000,0x00100402,0,0), +(20185,0,0,0,0,0x0000000000000000,0x00000002,0,0), +(20186,0,0,0,0,0x0000000000000000,0x00100402,0,0), +(20210,0,0,0,10,0x00010000C0000000,0x10000000,0,0), +(20212,0,0,0,10,0x00010000C0000000,0x10000000,0,0), +(20213,0,0,0,10,0x00010000C0000000,0x10000000,0,0), +(20214,0,0,0,10,0x00010000C0000000,0x10000000,0,0), +(20215,0,0,0,10,0x00010000C0000000,0x10000000,0,0), +(20230,0,0,0,0,0x0000000000000000,0x00000002,0,0), +(20234,0,0,0,0,0x0000000000008000,0x00020000,0,0), +(20235,0,0,0,0,0x0000000000008000,0x00020000,0,0), +(20287,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(20288,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(20289,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(20290,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(20291,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(20292,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(20293,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(20344,0,0,0,0,0x0000000000000000,0x00000002,0,0), +(20345,0,0,0,0,0x0000000000000000,0x00000002,0,0), +(20346,0,0,0,0,0x0000000000000000,0x00000002,0,0), +(20347,0,0,0,0,0x0000000000000000,0x00000001,20,0), +(20348,0,0,0,0,0x0000000000000000,0x00000001,20,0), +(20349,0,0,0,0,0x0000000000000000,0x00000001,20,0), +(20354,0,0,0,0,0x0000000000000000,0x00100402,0,0), +(20355,0,0,0,0,0x0000000000000000,0x00100402,0,0), +(20356,0,0,0,0,0x0000000000000000,0x00000001,20,0), +(20357,0,0,0,0,0x0000000000000000,0x00000001,20,0), +(20375,0,0,0,0,0x0000000000000000,0x00000001,7,0), +(20500,0,0,0,4,0x0000000010000000,0x00004000,0,0), +(20501,0,0,0,4,0x0000000010000000,0x00004000,0,0), +(20545,0,0,0,0,0x0000000000000000,0x00000402,0,0), +(20705,0,0,0,0,0x0000000000000000,0x00002000,0,0), +(20725,0,0,0,0,0x0000000000000000,0x00001000,0,0), +(20784,0,0,0,0,0x0000000000000000,0x00001000,0,0), +(20847,0,0,0,0,0x0000000000000000,0x00000002,0,0), +(20884,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(20891,0,0,0,0,0x0000000000000000,0x00001000,0,0), +(20911,0,0,0,0,0x0000000000000000,0x00000040,0,0), +(20912,0,0,0,0,0x0000000000000000,0x00000040,0,0), +(20913,0,0,0,0,0x0000000000000000,0x00000040,0,0), +(20914,0,0,0,0,0x0000000000000000,0x00000040,0,0), +(20915,0,0,0,0,0x0000000000000000,0x00000001,7,0), +(20918,0,0,0,0,0x0000000000000000,0x00000001,7,0), +(20919,0,0,0,0,0x0000000000000000,0x00000001,7,0), +(20920,0,0,0,0,0x0000000000000000,0x00000001,7,0), +(20925,0,0,0,0,0x0000000000000000,0x00000040,0,0), +(20927,0,0,0,0,0x0000000000000000,0x00000040,0,0), +(20928,0,0,0,0,0x0000000000000000,0x00000040,0,0), +(21053,0,0,0,0,0x0000000000000000,0x00000004,0,0), +(21061,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(21063,0,0,0,0,0x0000000000000000,0x00008000,0,0), +(21080,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(21084,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(21185,0,0,0,0,0x0000000000000000,0x00000004,0,10), +(21334,0,0,0,0,0x0000000000000000,0x00008000,0,0), +(21645,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(21747,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(21788,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(21838,0,0,0,0,0x0000000000000000,0x00008000,0,0), +(21841,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(21853,0,0,0,0,0x0000000000000000,0x00000002,0,0), +(21882,0,0,0,0,0x0000000000000000,0x00001000,0,0), +(21890,0,0,0,4,0x0000036C2A764EEF,0x00082001,0,0), +(21893,0,0,0,0,0x0000000000000000,0x00000002,0,0), +(21897,0,0,0,0,0x0000000000000000,0x00000002,0,0), +(21911,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(21969,0,0,0,0,0x0000000000000000,0x00000002,0,0), +(21978,0,0,0,0,0x0000000000000000,0x00020000,0,0), +(22007,0,0,0,0,0x0000000000200821,0x00004000,0,0), +(22413,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(22438,0,0,0,0,0x0000000000000000,0x00000002,0,0), +(22618,0,0,0,0,0x0000000000000000,0x00000040,0,0), +(22620,0,0,0,0,0x0000000000000000,0x00000040,0,0), +(22648,0,0,0,0,0x0000000000000000,0x00001000,0,0), +(22835,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(22857,0,0,0,0,0x0000000000000000,0x00000002,0,0), +(23340,0,0,0,0,0x0000000000000000,0x00000002,0,0), +(23378,0,0,0,0,0x0000000000000000,0x00000002,0,0), +(23547,0,0,0,0,0x0000000000000000,0x00000020,0,0), +(23548,0,0,0,0,0x0000000000000000,0x00000040,0,0), +(23551,0,0,0,0,0x00000000000000C0,0x00004000,0,0), +(23552,0,0,0,0,0x0000000000000000,0x00100402,0,3), +(23572,0,0,0,0,0x00000000000000C0,0x00004000,0,0), +(23578,0,0,0,0,0x0000000000000000,0x00080000,2,0), +(23581,0,0,0,0,0x0000000000000000,0x00000001,2,0), +(23686,0,0,0,0,0x0000000000000000,0x00000001,2,0), +(23688,0,0,0,0,0x0000000000000000,0x00004000,0,0), +(23689,0,0,0,0,0x0000000000000000,0x00000001,4,0), +(23695,0,0,0,0,0x0000000000000002,0x00020000,0,0), +(23721,0,0,0,0,0x0000000000000800,0x00020000,0,0), +(23771,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(23780,0,0,0,0,0x0000000000000000,0x00100002,0,0), +(23863,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(23867,0,0,0,0,0x0000000000000000,0x00000081,0,0), +(23885,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(23886,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(23887,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(23888,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(24051,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(24256,0,0,0,0,0x0000000000000000,0x00080001,0,0), +(24389,4,0,0,0,0x0000000000000000,0x00020000,0,0), +(24398,0,0,0,0,0x0000000000000000,0x00100402,0,3), +(24574,0,0,0,0,0x0000000000000000,0x00100002,0,0), +(24596,0,0,0,0,0x0000000000000000,0x00000000,0,0), +(24597,0,0,0,0,0x0000000000000000,0x00080001,0,0), +(24603,0,0,0,0,0x0000000000000000,0x00080001,0,0), +(24604,0,0,0,0,0x0000000000000000,0x00080001,0,0), +(24605,0,0,0,0,0x0000000000000000,0x00080001,0,0), +(24658,0,0,0,0,0x0000000000000000,0x00004000,0,0), +(24661,0,0,0,0,0x0000000000000000,0x00080001,0,0), +(24905,0,0,0,0,0x0000000000000000,0x00000001,15,0), +(24932,0,0,0,0,0x0000000000000000,0x00001000,0,6), +(24949,0,0,0,0,0x0000000000000000,0x00000000,0,0), +(25020,0,0,0,0,0x0000000000000000,0x00000402,0,0), +(25023,0,0,0,0,0x0000000000000000,0x00000002,0,0), +(25296,0,0,0,0,0x0000000000000000,0x00080000,0,0), +(25431,0,0,0,0,0x0000000000000000,0x00000402,0,0), +(25441,0,0,0,0,0x0000000000000000,0x00100000,0,0), +(25461,0,0,0,0,0x0000000000000000,0x00000002,0,0), +(25469,0,0,0,0,0x0000000000000000,0x00100402,0,3), +(25472,0,0,0,0,0x0000000000000000,0x00100402,0,3), +(25477,0,0,0,0,0x0000000000000000,0x00100402,0,3), +(25513,0,0,0,0,0x0000000000000000,0x00100402,0,0), +(25669,0,0,0,0,0x0000000000000000,0x00000001,1,0), +(25759,0,0,0,0,0x0000000000000000,0x00000000,0,0), +(25760,0,0,0,0,0x0000000000000000,0x00000000,0,0), +(25761,0,0,0,0,0x0000000000000000,0x00000000,0,0), +(25762,0,0,0,0,0x0000000000000000,0x00000000,0,0), +(25767,0,0,0,0,0x0000000000000000,0x00020000,0,0), +(25820,0,0,0,0,0x0000000000000000,0x00100402,0,0), +(25899,0,0,0,0,0x0000000000000000,0x00000040,0,0), +(25906,0,0,0,0,0x0000000000000000,0x00020000,0,0), +(25937,0,0,0,0,0x0000000000000000,0x00000000,0,0), +(25988,0,0,0,0,0x0000000000000000,0x00040000,0,0), +(26016,0,0,0,0,0x0000000000000000,0x00000001,2,0), +(26021,0,0,0,0,0x0000000000000000,0x00000001,2,0), +(26107,0,0,0,7,0x0000008000800000,0xC4000000,0,0), +(26119,0,0,0,11,0x0000000090100003,0x00004000,0,0), +(26128,0,0,0,0,0x0000000000000000,0x02000000,0,0), +(26135,0,0,0,0,0x0000000000800000,0x00004000,0,0), +(26169,0,0,0,0,0x0000000000000000,0x08000000,0,0), +(26376,0,0,0,0,0x0000000000000000,0x00000000,0,0), +(26463,0,0,0,0,0x0000000000000000,0x00100000,0,0), +(26467,0,0,0,0,0x0000000000000000,0x08000000,0,0), +(26480,0,0,0,0,0x0000000000000000,0x00080001,3,0), +(27009,0,0,0,0,0x0000000000000000,0x00000002,0,0), +(27044,0,0,0,0,0x0000000000000000,0x00080000,0,0), +(27124,0,0,0,0,0x0000000000000000,0x00000002,0,0), +(27155,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(27160,0,0,0,0,0x0000000000000000,0x00000001,20,0), +(27162,0,0,0,0,0x0000000000000000,0x00000002,0,0), +(27164,0,0,0,0,0x0000000000000000,0x00100402,0,0), +(27166,0,0,0,0,0x0000000000000000,0x00000001,20,0), +(27168,0,0,0,0,0x0000000000000000,0x00000040,0,0), +(27169,0,0,0,0,0x0000000000000000,0x00000040,0,0), +(27170,0,0,0,0,0x0000000000000000,0x00000001,7,0), +(27179,0,0,0,0,0x0000000000000000,0x00000040,0,0), +(27200,0,0,0,0,0x0000000000000000,0x00000000,0,0), +(27217,0,0,0,0,0x0000000000000000,0x00000004,0,0), +(27243,0,0,0,0,0x0000000000000000,0x00008000,0,0), +(27280,0,0,0,0,0x0000000000000000,0x00000002,0,0), +(27419,0,0,0,0,0x0000000000000000,0x00000001,3,0), +(27420,0,0,0,0,0x0000000000000000,0x00000000,0,0), +(27498,0,0,0,0,0x0000000000000000,0x00000001,3,0), +(27521,0,0,0,0,0x0000000000000000,0x00004000,0,0), +(27522,0,0,0,0,0x0000000000000000,0x00080001,0,0), +(27539,0,0,0,0,0x0000000000000000,0x00100000,0,0), +(27561,0,0,0,0,0x0000000000000000,0x00020000,0,0), +(27656,0,0,0,0,0x0000000000000000,0x00000001,3,0), +(27688,0,0,0,0,0x0000000000000000,0x00100402,0,0), +(27774,0,0,0,0,0x0000000000000000,0x00004000,0,0), +(27776,0,0,0,0,0x0000000000000000,0x00000002,0,0), +(27778,0,0,0,0,0x0000000000000000,0x00000002,0,0), +(27780,0,0,0,0,0x0000000000000000,0x00000002,0,0), +(27781,0,0,0,0,0x0000000000000000,0x00000002,0,0), +(27785,0,0,0,0,0x0000000000000000,0x00080000,0,0), +(27787,0,0,0,0,0x0000000000000000,0x00000001,3,0), +(27811,0,0,0,0,0x0000000000000000,0x00802000,0,0), +(27815,0,0,0,0,0x0000000000000000,0x00802000,0,0), +(27816,0,0,0,0,0x0000000000000000,0x00802000,0,0), +(27852,0,0,0,0,0x0000000000000000,0x00008000,0,0), +(27861,0,0,0,0,0x0000000000000000,0x00000000,0,0), +(27863,0,0,0,0,0x0000000000000000,0x00000000,0,0), +(27864,0,0,0,0,0x0000000000000000,0x00000000,0,0), +(27865,0,0,0,0,0x0000000000000000,0x00000000,0,0), +(27867,0,0,0,0,0x0000000000000000,0x00000002,0,0), +(28200,0,0,0,0,0x0000000000000000,0x08000000,0,0), +(28305,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(28429,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(28458,0,0,0,0,0x0000000000000000,0x00000000,0,0), +(28460,0,0,0,0,0x0000000000000000,0x00000000,0,0), +(28592,16,0,0,0,0x0000000000000000,0x00020000,0,0), +(28593,16,0,0,0,0x0000000000000000,0x00020000,0,0), +(28594,16,0,0,0,0x0000000000000000,0x00020000,0,0), +(28595,16,0,0,0,0x0000000000000000,0x00020000,0,0), +(28716,0,0,0,7,0x0000000000000010,0x08000000,0,0), +(28719,0,0,0,7,0x0000000000000020,0x10000000,0,0), +(28744,0,0,0,7,0x0000000000000040,0x08000000,0,0), +(28752,0,0,0,0,0x0000000000000000,0x00400000,0,0), +(28761,0,0,0,0,0x0000000000000000,0x00020000,0,0), +(28764,0,0,0,0,0x0000000000000000,0x00100000,0,0), +(28771,0,0,0,0,0x0000000000000000,0x00020000,0,0), +(28780,0,0,0,0,0x0000000000000000,0x08020000,0,0), +(28789,0,0,0,10,0x0000000000006000,0x20000000,0,0), +(28802,0,0,0,0,0x0000000000000000,0x00004000,0,0), +(28809,0,0,0,0,0x0000000000001000,0x10000000,0,0), +(28812,0,0,0,0,0x0000000000000000,0x00010000,0,0), +(28816,0,0,0,0,0x0000000000000000,0x00000001,3,0), +(28823,0,0,0,0,0x00000000000000C0,0x08000000,0,0), +(28845,0,0,0,0,0x0000000000000000,0x00000200,0,0), +(28847,0,0,0,7,0x0000000000000020,0x00004000,0,0), +(28849,0,0,0,11,0x0000000000000080,0x00004000,0,0), +(29062,0,0,0,0,0x0000000000000000,0x00802000,0,0), +(29064,0,0,0,0,0x0000000000000000,0x00802000,0,0), +(29065,0,0,0,0,0x0000000000000000,0x00802000,0,0), +(29074,20,0,0,0,0x0000000000000000,0x00010000,0,0), +(29075,20,0,0,0,0x0000000000000000,0x00010000,0,0), +(29076,20,0,0,0,0x0000000000000000,0x00010000,0,0), +(29150,0,0,0,0,0x0000000000000000,0x00000001,3,0), +(29162,0,0,0,0,0x0000000000000000,0x00000002,0,0), +(29179,0,0,0,0,0x0000000000000000,0x00010000,0,0), +(29180,0,0,0,0,0x0000000000000000,0x00010000,0,0), +(29185,0,0,0,0,0x0000000000000000,0x00000000,0,0), +(29194,0,0,0,0,0x0000000000000000,0x00000000,0,0), +(29196,0,0,0,0,0x0000000000000000,0x00000000,0,0), +(29198,0,0,0,0,0x0000000000000000,0x00000000,0,0), +(29220,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(29307,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(29441,0,0,0,0,0x0000000000000000,0x01000000,0,1), +(29444,0,0,0,0,0x0000000000000000,0x01000000,0,1), +(29445,0,0,0,0,0x0000000000000000,0x01000000,0,1), +(29446,0,0,0,0,0x0000000000000000,0x01000000,0,1), +(29447,0,0,0,0,0x0000000000000000,0x01000000,0,1), +(29448,0,0,0,0,0x0000000000000000,0xC4000001,0,0), +(29501,0,0,0,0,0x0000000000000000,0x00080000,3,0), +(29601,0,0,0,7,0x0000000000000000,0x00004000,0,0), +(29624,0,0,0,0,0x0000000000000000,0x00080000,3,0), +(29625,0,0,0,0,0x0000000000000000,0x00080000,3,0), +(29626,0,0,0,0,0x0000000000000000,0x00080000,3,0), +(29632,0,0,0,0,0x0000000000000000,0x00080000,3,0), +(29633,0,0,0,0,0x0000000000000000,0x00080000,3,0), +(29634,0,0,0,0,0x0000000000000000,0x00080000,3,0), +(29635,0,0,0,0,0x0000000000000000,0x00080000,3,0), +(29636,0,0,0,0,0x0000000000000000,0x00080000,3,0), +(29637,0,0,0,0,0x0000000000000000,0x00080000,3,0), +(29801,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(30030,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(30033,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(30079,0,0,0,0,0x0000000000000000,0x00000002,0,0), +(30080,0,0,0,0,0x0000000000000000,0x00000002,0,0), +(30081,0,0,0,0,0x0000000000000000,0x00000002,0,0), +(30160,0,0,0,0,0x0000000000000000,0x00010000,0,0), +(30293,0,0,0,5,0x000000C000000381,0x00020000,0,0), +(30295,0,0,0,5,0x000000C000000381,0x00020000,0,0), +(30296,0,0,0,5,0x000000C000000381,0x00020000,0,0), +(30299,36,0,0,0,0x0000000000000000,0x00100000,0,0), +(30301,36,0,0,0,0x0000000000000000,0x00100000,0,0), +(30302,36,0,0,0,0x0000000000000000,0x00100000,0,0), +(30339,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(30482,0,0,0,0,0x0000000000000000,0x00000002,0,0), +(30636,0,0,0,0,0x0000000000000000,0x00080001,0,0), +(30675,0,0,0,11,0x0000000000000003,0x00004000,0,0), +(30678,0,0,0,11,0x0000000000000003,0x00004000,0,0), +(30679,0,0,0,11,0x0000000000000003,0x00004000,0,0), +(30680,0,0,0,11,0x0000000000000003,0x00004000,0,0), +(30681,0,0,0,11,0x0000000000000003,0x00004000,0,0), +(30802,0,0,0,0,0x0000000000000000,0x00001000,0,0), +(30808,0,0,0,0,0x0000000000000000,0x00001000,0,0), +(30809,0,0,0,0,0x0000000000000000,0x00001000,0,0), +(30810,0,0,0,0,0x0000000000000000,0x00001000,0,0), +(30811,0,0,0,0,0x0000000000000000,0x00001000,0,0), +(30823,0,0,0,0,0x0000000000000000,0x00000001,10.5,0), +(30881,0,0,0,0,0x0000000000000000,0x00008000,0,5), +(30883,0,0,0,0,0x0000000000000000,0x00008000,0,5), +(30884,0,0,0,0,0x0000000000000000,0x00008000,0,5), +(30885,0,0,0,0,0x0000000000000000,0x00008000,0,5), +(30886,0,0,0,0,0x0000000000000000,0x00008000,0,5), +(31233,0,0,0,8,0x00000009003E0000,0x00020000,0,0), +(31239,0,0,0,8,0x00000009003E0000,0x00020000,0,0), +(31240,0,0,0,8,0x00000009003E0000,0x00020000,0,0), +(31241,0,0,0,8,0x00000009003E0000,0x00020000,0,0), +(31242,0,0,0,8,0x00000009003E0000,0x00020000,0,0), +(31244,0,0,0,0,0x0000000000000000,0x80000000,0,0), +(31245,0,0,0,0,0x0000000000000000,0x80000000,0,0), +(31255,0,0,0,0,0x0000000000000000,0x00000100,0,0), +(31316,0,0,0,0,0x0000000000000000,0x00000002,0,0), +(31569,0,0,0,3,0x0000000000010000,0x00004000,0,0), +(31570,0,0,0,3,0x0000000000010000,0x00004000,0,0), +(31641,0,0,0,0,0x0000000000000000,0x00080002,0,0), +(31642,0,0,0,0,0x0000000000000000,0x00080002,0,0), +(31785,0,0,0,0,0x0000000000000000,0x20000000,0,0), +(31794,0,0,0,0,0x0000000000000000,0x00004000,0,0), +(31801,0,0,0,0,0x0000000000000000,0x00000001,20,0), +(31828,0,0,0,0,0x0000000000000000,0x00008000,0,0), +(31829,0,0,0,0,0x0000000000000000,0x00008000,0,0), +(31830,0,0,0,0,0x0000000000000000,0x00008000,0,0), +(31833,0,0,0,10,0x0000000080000000,0x00004000,0,0), +(31835,0,0,0,10,0x0000000080000000,0x00004000,0,0), +(31836,0,0,0,10,0x0000000080000000,0x00004000,0,0), +(31892,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(31895,0,0,0,0,0x0000000000000000,0x00000001,5,0), +(31896,0,0,0,0,0x0000000000000000,0x00000001,2,0), +(32215,0,0,0,0,0x0000000000000000,0x00000004,0,0), +(32385,0,0,0,5,0x0000001100000402,0x00020000,0,0), +(32387,0,0,0,5,0x0000001100000402,0x00020000,0,0), +(32392,0,0,0,5,0x0000001100000402,0x00020000,0,0), +(32393,0,0,0,5,0x0000001100000402,0x00020000,0,0), +(32394,0,0,0,5,0x0000001100000402,0x00020000,0,0), +(32587,0,0,0,0,0x0000000000000000,0x00000040,0,0), +(32593,0,0,0,0,0x0000000000000000,0x00100402,0,3), +(32594,0,0,0,0,0x0000000000000000,0x00100402,0,3), +(32642,0,0,0,0,0x0000000000000000,0x00000040,0,0), +(32734,0,0,0,0,0x0000000000000000,0x00000002,0,3), +(32748,0,0,0,8,0x0000000100000000,0x00080000,0,0), +(32776,0,0,0,0,0x0000000000000000,0x00000040,0,0), +(32777,0,0,0,0,0x0000000000000000,0x00000040,0,0), +(32837,0,0,0,0,0x0000000000000000,0x00004000,0,45), +(32850,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(32863,0,0,0,0,0x0000000000000000,0x00008000,0,0), +(33012,0,0,0,0,0x0000000000000000,0x00000004,0,0), +(33014,0,0,0,0,0x0000000000000000,0x00000004,0,0), +(33089,0,0,0,0,0x0000000000000000,0x00000040,0,0), +(33142,0,0,0,0,0x0000000000000000,0x00842000,0,0), +(33145,0,0,0,0,0x0000000000000000,0x00842000,0,0), +(33146,0,0,0,0,0x0000000000000000,0x00842000,0,0), +(33150,0,0,0,0,0x0000000000000000,0x10010000,0,0), +(33154,0,0,0,0,0x0000000000000000,0x10010000,0,0), +(33191,0,0,0,6,0x0000040000808000,0x00020000,0,0), +(33192,0,0,0,6,0x0000040000808000,0x00020000,0,0), +(33193,0,0,0,6,0x0000040000808000,0x00020000,0,0), +(33194,0,0,0,6,0x0000040000808000,0x00020000,0,0), +(33195,0,0,0,6,0x0000040000808000,0x00020000,0,0), +(33297,0,0,0,0,0x0000000000000000,0x00020000,0,0), +(33299,0,0,0,0,0x0000000000000000,0x00004000,0,0), +(33493,0,0,0,0,0x0000000000000000,0x00000002,0,0), +(33510,0,0,0,0,0x0000000000000000,0x00080001,5,0), +(33511,0,0,0,0,0x0000000000000000,0x00020000,0,0), +(33522,0,0,0,0,0x0000000000000000,0x00020000,0,0), +(33648,0,0,0,0,0x0000000000000000,0x00401000,0,0), +(33727,0,0,0,0,0x0000000000000000,0x00000000,0,0), +(33735,0,0,0,0,0x0000000000000000,0xC4000001,0,0), +(33736,0,0,0,0,0x0000000000000000,0x00100402,0,3), +(33746,0,0,0,0,0x0000000000000000,0x00000004,0,10), +(33754,0,0,0,0,0x0000000000000000,0x00000000,0,0), +(33755,0,0,0,0,0x0000000000000000,0x00000000,0,0), +(33756,0,0,0,0,0x0000000000000000,0x00000000,0,0), +(33757,0,0,0,0,0x0000000000000000,0x00000001,0,3), +(33759,0,0,0,0,0x0000000000000000,0x00000004,0,10), +(33776,0,0,0,0,0x0000000000000000,0x20000000,0,0), +(33881,0,0,0,0,0x0000000000000000,0x00842000,0,0), +(33882,0,0,0,0,0x0000000000000000,0x00842000,0,0), +(33883,0,0,0,0,0x0000000000000000,0x00842000,0,0), +(33953,0,0,0,0,0x0000000000000000,0x08000000,0,0), +(34082,0,0,0,0,0x0000000000000000,0x00000000,0,0), +(34138,0,0,0,11,0x0000000000000080,0x08000000,0,0), +(34303,0,0,0,0,0x0000000000000000,0x00000080,0,0), +(34320,0,0,0,0,0x0000000000000000,0x00010000,0,0), +(34355,0,0,0,0,0x0000000000000000,0x00100402,0,3), +(34457,0,0,0,0,0x0000000000000000,0x00001000,0,0), +(34497,0,0,0,0,0x0000000000000000,0x00400000,0,0), +(34498,0,0,0,0,0x0000000000000000,0x00400000,0,0), +(34499,0,0,0,0,0x0000000000000000,0x00400000,0,0), +(34500,0,0,0,0,0x0000000000000000,0x00400000,0,0), +(34502,0,0,0,0,0x0000000000000000,0x00400000,0,0), +(34503,0,0,0,0,0x0000000000000000,0x00400000,0,0), +(34506,0,0,0,0,0x0000000000000000,0x00080000,0,0), +(34507,0,0,0,0,0x0000000000000000,0x00080000,0,0), +(34508,0,0,0,0,0x0000000000000000,0x00080000,0,0), +(34586,0,0,0,0,0x0000000000000000,0x00080001,1.5,0), +(34749,0,0,0,0,0x0000000000000000,0x02000000,0,0), +(34753,0,0,0,6,0x0000000000001800,0x08000000,0,0), +(34774,0,0,0,0,0x0000000000000000,0x00080001,1.5,20), +(34827,0,0,0,0,0x0000000000000000,0x00100402,0,3), +(34838,0,0,0,0,0x0000000000000000,0x00080000,0,0), +(34839,0,0,0,0,0x0000000000000000,0x00080000,0,0), +(34859,0,0,0,6,0x0000000000001800,0x08000000,0,0), +(34860,0,0,0,6,0x0000000000001800,0x08000000,0,0), +(34914,32,0,0,0,0x0000000000000000,0x00008000,0,0), +(34916,32,0,0,0,0x0000000000000000,0x00008000,0,0), +(34917,32,0,0,0,0x0000000000000000,0x00008000,0,0), +(34935,0,0,0,0,0x0000000000000000,0x00000002,0,8), +(34938,0,0,0,0,0x0000000000000000,0x00000002,0,8), +(34939,0,0,0,0,0x0000000000000000,0x00000002,0,8), +(34948,0,0,0,0,0x0000000000000000,0x00000004,0,0), +(34949,0,0,0,0,0x0000000000000000,0x00000004,0,0), +(34950,0,0,0,0,0x0000000000000000,0x00400000,0,0), +(34954,0,0,0,0,0x0000000000000000,0x00400000,0,0), +(35077,0,0,0,0,0x0000000000000000,0x00008000,0,60), +(35080,0,0,0,0,0x0000000000000000,0x00000001,0,60), +(35083,0,0,0,0,0x0000000000000000,0x00020000,0,60), +(35086,0,0,0,0,0x0000000000000000,0x08020000,0,60), +(35100,0,0,0,0,0x0000000000000000,0x00080000,0,0), +(35102,0,0,0,0,0x0000000000000000,0x00080000,0,0), +(35103,0,0,0,0,0x0000000000000000,0x00080000,0,0), +(35205,0,0,0,0,0x0000000000000000,0xC4000001,0,0), +(35541,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(35550,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(35551,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(35552,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(35553,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(35942,0,0,0,0,0x0000000000000000,0x00080001,0,0), +(36111,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(36123,0,0,0,0,0x0000000000000000,0x00008000,0,0), +(36576,0,0,0,0,0x0000000000000000,0x00008000,0,0), +(37168,0,0,0,8,0x00000009003E0000,0x00020000,0,0), +(37169,0,0,0,8,0x0000000000020000,0x00000000,0,0), +(37170,0,0,0,0,0x0000000000000000,0x00000001,1,0), +(37173,0,0,0,8,0x000001062CBC0598,0x000A0001,0,30), +(37188,0,0,0,10,0x0000000000800000,0x00004000,0,0), +(37189,0,0,0,10,0x0000000000006000,0x10000000,0,60), +(37195,0,0,0,10,0x0000000000800000,0x00004000,0,0), +(37197,0,0,0,0,0x0000000000000000,0x00004000,0,45), +(37213,0,0,0,11,0x0000000090100007,0x00010000,0,0), +(37227,0,0,0,11,0x00000000000001C0,0x10000000,0,60), +(37228,0,0,0,11,0x0000000090100007,0x00020000,0,0), +(37237,0,0,0,11,0x0000000000000001,0x00010000,0,0), +(37239,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(37247,8,0,0,0,0x0000000000000000,0x00004000,0,45), +(37288,0,0,0,0,0x0000000000000000,0x08000000,0,0), +(37295,0,0,0,0,0x0000000000000000,0x00020000,0,0), +(37306,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(37311,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(37336,0,0,0,0,0x0000000000000000,0x00084001,0,0), +(37377,32,0,0,0,0x0000000000000000,0x00004000,0,0), +(37381,0,0,0,0,0x0000000000000000,0x000A0001,0,0), +(37443,0,0,0,0,0x0000000000000000,0x00010000,0,0), +(37447,0,0,0,3,0x0000010000000000,0x00004000,0,0), +(37514,0,0,0,0,0x0000000000000000,0x00000020,0,0), +(37519,0,0,0,0,0x0000000000000000,0x04000000,0,0), +(37525,0,0,0,0,0x0000000000000000,0x00100402,0,0), +(37528,0,0,0,4,0x0000000000000004,0x00000001,0,0), +(37604,0,0,0,0,0x0000000000000000,0x00004000,0,0), +(37617,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(37655,0,0,0,0,0x0000000000000000,0x00004000,0,60), +(37657,0,0,0,0,0x0000000000000000,0x00010000,0,0), +(37705,0,0,0,0,0x0000000000000000,0x08000000,0,0), +(37982,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(38031,0,0,0,0,0x0000000000000000,0x00000040,0,0), +(38196,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(38252,0,0,0,0,0x0000000000000000,0x00008000,0,0), +(38290,0,0,0,0,0x0000000000000000,0x00080000,3,0), +(38299,0,0,0,0,0x0000000000000000,0x08000000,0,0), +(38319,0,0,0,0,0x0000000000000000,0x00004000,0,0), +(38332,0,0,0,0,0x0000000000000000,0x08000000,0,0), +(38334,0,0,0,0,0x0000000000000000,0x00004000,0,60), +(38347,0,0,0,0,0x0000000000000000,0x00010000,0,0), +(38350,0,0,0,0,0x0000000000000000,0x00401000,0,0), +(38394,0,0,0,5,0x0000000000000006,0x00020000,0,0), +(38427,0,0,0,0,0x0000000000000000,0x00000001,0,0), +(39027,0,0,0,0,0x0000000000000000,0x00100402,0,3), +(39367,0,0,0,0,0x0000000000000000,0x00008000,0,0), +(39372,0,0,0,0,0x0000000000000000,0x00020000,0,0), +(39437,4,0,0,0,0x0000000000000000,0x00004000,0,0), +(39438,0,0,0,0,0x0000000000000000,0x00080001,0,0), +(39440,0,0,0,0,0x0000000000000000,0x00020000,0,0), +(39442,0,0,0,0,0x0000000000000000,0x00020001,0,0), +(39443,0,0,0,0,0x0000000000000000,0x00401000,0,0), +(39444,0,0,0,0,0x0000000000000000,0x00100002,0,0), +(39446,0,0,0,0,0x0000000000000000,0x00000004,0,0), +(39530,0,0,0,0,0x0000000000000000,0x00004000,0,0), +(39958,0,0,0,0,0x0000000000000000,0x00000001,0.7,40), +(40353,0,0,0,0,0x0000000000000000,0xC4000001,0,0), +(40407,0,0,0,0,0x0000000000000000,0x00000402,6,0), +(40438,0,0,0,6,0x0000000000008010,0x08020000,0,0), +(40442,0,0,0,7,0x0000044000000014,0x00004001,0,0), +(40444,0,0,0,0,0x0000000000000000,0x00000040,0,0), +(40458,0,0,0,4,0x0000060102000000,0x00000001,0,0), +(40463,0,0,0,11,0x0000001000000081,0x00004001,0,0), +(40470,0,0,0,10,0x00000000C0800000,0x00004000,0,0), +(40475,0,0,0,0,0x0000000000000000,0x00080001,3,0), +(40482,0,0,0,0,0x0000000000000000,0x00010000,0,0), +(40485,0,0,0,9,0x0000000100000000,0x00080000,0,0), +(40478,0,0,0,5,0x0000000000000002,0x00020000,0,0), +(40971,0,0,0,0,0x0000000000000000,0x08000000,0,0), +(41260,0,0,0,0,0x0000000000000000,0x00000004,0,10), +(41262,0,0,0,0,0x0000000000000000,0x00000004,0,10), +(41434,0,0,0,0,0x0000000000000000,0x00000001,2,45), +(41635,0,0,0,0,0x0000000000000000,0x00008000,0,0), +(41989,0,0,0,0,0x0000000000000000,0x00000001,3,0), +(42083,0,0,0,0,0x0000000000000000,0x00401000,0,0), +(42135,0,0,0,0,0x0000000000000000,0x00100402,0,90), +(42136,0,0,0,0,0x0000000000000000,0x00100402,0,90), +(42370,0,0,0,11,0x0000000000000080,0x08000000,0,0), +(43338,0,0,0,0,0x0000000000000000,0x00001000,0,0), +(43728,0,0,0,11,0x0000000000000080,0x08000000,0,0), +(43737,0,0,0,7,0x0000044000000000,0x00000001,0,10), +(43739,0,0,0,7,0x0000000000000002,0x00020000,0,0), +(43745,0,0,0,10,0x0000020000000000,0x00020000,0,0), +(43748,0,0,0,11,0x0000000090100000,0x00004000,0,0), +(43750,0,0,0,11,0x0000000000000001,0x00004000,0,0), +(43823,0,0,0,0,0x0000000000000000,0x00008000,0,0), +(44604,0,0,0,0,0x0000000000000000,0x00004000,0,0), +(44599,0,0,0,0,0x0000000000000000,0x00000001,0,5), +(44835,0,0,0,7,0x0000008000000000,0x00000001,0,0), +(45040,0,0,0,0,0x0000000000000000,0x00080001,0,0), +(45054,0,0,0,0,0x0000000000000000,0x00020000,0,15), +(45057,0,0,0,0,0x0000000000000000,0x00000002,0,30), +(45059,0,0,0,0,0x0000000000000000,0x08000000,0,0), +(45234,0,0,0,0,0x0000000000000000,0x00842000,0,0), +(45243,0,0,0,0,0x0000000000000000,0x00842000,0,0), +(45244,0,0,0,0,0x0000000000000000,0x00842000,0,0), +(45354,0,0,0,0,0x0000000000000000,0x00000001,0,45), +(45355,0,0,0,0,0x0000000000000000,0x00080001,0,0), +(45444,0,0,0,0,0x0000000000000000,0x00100402,0,0), +(45481,0,0,0,0,0x0000000000000000,0x08020000,0,45), +(45482,0,0,0,0,0x0000000000000000,0x00080001,0,45), +(45483,0,0,0,0,0x0000000000000000,0x00080001,0,45), +(45484,0,0,0,0,0x0000000000000000,0x08000000,0,45), +(46046,0,0,0,0,0x0000000000000000,0x00000001,0,5), +(46098,0,0,0,11,0x0000000000000080,0x08000000,0,0), +(46364,0,0,0,0,0x0000000000000000,0x00100402,0,0), +(46569,0,0,0,0,0x0000000000000000,0x00004000,0,45), +(46832,0,0,0,7,0x0000000000000001,0x00004000,0,0); +/*!40000 ALTER TABLE `spell_proc_event` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `spell_script_target` +-- + +DROP TABLE IF EXISTS `spell_script_target`; +CREATE TABLE `spell_script_target` ( + `entry` mediumint(8) unsigned NOT NULL, + `type` tinyint(3) unsigned NOT NULL default '0', + `targetEntry` mediumint(8) unsigned NOT NULL default '0', + UNIQUE KEY `entry_type_target` (`entry`,`type`,`targetEntry`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT='Spell System'; + +-- +-- Dumping data for table `spell_script_target` +-- + +LOCK TABLES `spell_script_target` WRITE; +/*!40000 ALTER TABLE `spell_script_target` DISABLE KEYS */; +/*!40000 ALTER TABLE `spell_script_target` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `spell_scripts` +-- + +DROP TABLE IF EXISTS `spell_scripts`; +CREATE TABLE `spell_scripts` ( + `id` mediumint(8) unsigned NOT NULL default '0', + `delay` int(10) unsigned NOT NULL default '0', + `command` mediumint(8) unsigned NOT NULL default '0', + `datalong` mediumint(8) unsigned NOT NULL default '0', + `datalong2` int(10) unsigned NOT NULL default '0', + `datatext` text NOT NULL, + `x` float NOT NULL default '0', + `y` float NOT NULL default '0', + `z` float NOT NULL default '0', + `o` float NOT NULL default '0' +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + +-- +-- Dumping data for table `spell_scripts` +-- + +LOCK TABLES `spell_scripts` WRITE; +/*!40000 ALTER TABLE `spell_scripts` DISABLE KEYS */; +/*!40000 ALTER TABLE `spell_scripts` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `spell_target_position` +-- + +DROP TABLE IF EXISTS `spell_target_position`; +CREATE TABLE `spell_target_position` ( + `id` mediumint(8) unsigned NOT NULL default '0' COMMENT 'Identifier', + `target_map` smallint(5) unsigned NOT NULL default '0', + `target_position_x` float NOT NULL default '0', + `target_position_y` float NOT NULL default '0', + `target_position_z` float NOT NULL default '0', + `target_orientation` float NOT NULL default '0', + PRIMARY KEY (`id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Spell System'; + +-- +-- Dumping data for table `spell_target_position` +-- + +LOCK TABLES `spell_target_position` WRITE; +/*!40000 ALTER TABLE `spell_target_position` DISABLE KEYS */; +/*!40000 ALTER TABLE `spell_target_position` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `spell_threat` +-- + +DROP TABLE IF EXISTS `spell_threat`; +CREATE TABLE `spell_threat` ( + `entry` mediumint(8) unsigned NOT NULL, + `Threat` smallint(6) NOT NULL, + PRIMARY KEY (`entry`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED; + +-- +-- Dumping data for table `spell_threat` +-- + +LOCK TABLES `spell_threat` WRITE; +/*!40000 ALTER TABLE `spell_threat` DISABLE KEYS */; +INSERT INTO `spell_threat` VALUES +(78,20), +(284,39), +(285,59), +(770,108), +(778,108), +(1608,78), +(1672,180), +(1715,61), +(2139,300), +(6343,17), +(6572,155), +(6574,195), +(6809,89), +(7372,101), +(7373,141), +(7379,235), +(7386,100), +(7405,140), +(8198,40), +(8204,64), +(8205,96), +(8380,180), +(8972,118), +(9745,148), +(9749,108), +(9880,178), +(9881,207), +(9907,108), +(11556,43), +(11564,98), +(11565,118), +(11566,137), +(11567,145), +(11580,143), +(11581,180), +(11596,220), +(11597,261), +(11600,275), +(11601,315), +(11775,395), +(14274,200), +(14921,415), +(15629,300), +(15630,400), +(15631,500), +(15632,600), +(16857,108), +(17735,200), +(17750,300), +(17751,450), +(17752,600), +(17390,108), +(17391,108), +(17392,108), +(20569,100), +(20736,100), +(20925,20), +(20927,30), +(20928,40), +(23922,160), +(23923,190), +(23924,220), +(23925,250), +(24394,580), +(24583,5), +(25225,300), +(25231,130), +(25258,286), +(25264,215), +(25269,400), +(25286,175), +(25288,355), +(25289,60), +(26993,127), +(26996,176), +(27011,127), +(27179,54), +(29704,230), +(29707,196), +(30324,220), +(30356,323), +(30357,483), +(33745,285), +(33878,129), +(33986,180), +(33987,232); +/*!40000 ALTER TABLE `spell_threat` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `transports` +-- + +DROP TABLE IF EXISTS `transports`; +CREATE TABLE `transports` ( + `entry` mediumint(8) unsigned NOT NULL default '0', + `name` text, + `period` mediumint(8) unsigned NOT NULL default '0', + PRIMARY KEY (`entry`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Transports'; + +-- +-- Dumping data for table `transports` +-- + +LOCK TABLES `transports` WRITE; +/*!40000 ALTER TABLE `transports` DISABLE KEYS */; +/*!40000 ALTER TABLE `transports` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `uptime` +-- + +DROP TABLE IF EXISTS `uptime`; +CREATE TABLE `uptime` ( + `starttime` bigint(20) unsigned NOT NULL default '0', + `startstring` varchar(64) NOT NULL default '', + `uptime` bigint(20) unsigned NOT NULL default '0', + `maxplayers` smallint(5) unsigned NOT NULL default '0', + PRIMARY KEY (`starttime`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='Uptime system'; + +-- +-- Dumping data for table `uptime` +-- + +LOCK TABLES `uptime` WRITE; +/*!40000 ALTER TABLE `uptime` DISABLE KEYS */; +/*!40000 ALTER TABLE `uptime` ENABLE KEYS */; +UNLOCK TABLES; +/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; + +/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; +/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; +/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; +/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; + +-- Dump completed on 2008-03-30 15:34:54 diff --git a/src/bindings/scripts/ScriptMgr.cpp b/src/bindings/scripts/ScriptMgr.cpp index fb156a313aa..4dff1b7c374 100644 --- a/src/bindings/scripts/ScriptMgr.cpp +++ b/src/bindings/scripts/ScriptMgr.cpp @@ -1119,9 +1119,10 @@ void ScriptsFree() MANGOS_DLL_EXPORT void ScriptsInit() { - //Trinity Script startup + //Trinity Script startup + outstring_log(" _____ _ _ _ ____ _ _"); outstring_log("|_ _| __(_)_ __ (_) |_ _ _/ ___| ___ _ __(_)_ __ | |_ "); - outstring_log(" | || '__| | '_ \\| | __| | | \\___ \\ / __| \\'__| | \\'_ \\| __|"); + outstring_log(" | || '__| | '_ \\| | __| | | \\___ \\ / __| \'__| | \'_ \\| __|"); outstring_log(" | || | | | | | | | |_| |_| |___) | (__| | | | |_) | |_ "); outstring_log(" |_||_| |_|_| |_|_|\\__|\\__, |____/ \\___|_| |_| .__/ \\__|"); outstring_log(" |___/ |_| "); diff --git a/src/bindings/scripts/VC71/71ScriptDev2.vcproj b/src/bindings/scripts/VC71/71ScriptDev2.vcproj index 4b015248add..9ea083bc56e 100644 --- a/src/bindings/scripts/VC71/71ScriptDev2.vcproj +++ b/src/bindings/scripts/VC71/71ScriptDev2.vcproj @@ -20,7 +20,7 @@ - * This program is free software licensed under GPL version 2 - * Please see the included DOCS/LICENSE.TXT for more information */ - -#include "precompiled.h" -#include "Item.h" -#include "Spell.h" -#include "WorldPacket.h" - -// Spell summary for ScriptedAI::SelectSpell -struct TSpellSummary { - uint8 Targets; // set of enum SelectTarget - uint8 Effects; // set of enum SelectEffect -} *SpellSummary; - -bool ScriptedAI::IsVisible(Unit* who) const -{ - if (!who) - return false; - - return (m_creature->GetDistance(who) < VISIBLE_RANGE) && who->isVisibleForOrDetect(m_creature,true); -} - -void ScriptedAI::MoveInLineOfSight(Unit *who) -{ - if( !m_creature->getVictim() && who->isTargetableForAttack() && ( m_creature->IsHostileTo( who )) && who->isInAccessablePlaceFor(m_creature) ) - { - if (m_creature->GetDistanceZ(who) > CREATURE_Z_ATTACK_RANGE) - return; - - float attackRadius = m_creature->GetAttackDistance(who); - if( m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->IsWithinLOSInMap(who) ) - { - DoStartAttackAndMovement(who); - who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); - - if (!InCombat) - { - Aggro(who); - InCombat = true; - } - } - } -} - -void ScriptedAI::AttackStart(Unit* who) -{ - if (!who) - return; - - if (who->isTargetableForAttack()) - { - //Begin attack - DoStartAttackAndMovement(who); - - if (!InCombat) - { - Aggro(who); - InCombat = true; - } - } -} - -void ScriptedAI::UpdateAI(const uint32 diff) -{ - //Check if we have a current target - if( m_creature->isAlive() && m_creature->SelectHostilTarget() && m_creature->getVictim()) - { - if( m_creature->isAttackReady() ) - { - //If we are within range melee the target - if( m_creature->IsWithinDistInMap(m_creature->getVictim(), ATTACK_DISTANCE)) - { - m_creature->AttackerStateUpdate(m_creature->getVictim()); - m_creature->resetAttackTimer(); - } - } - } -} - -void ScriptedAI::EnterEvadeMode() -{ - m_creature->InterruptNonMeleeSpells(true); - m_creature->RemoveAllAuras(); - m_creature->DeleteThreatList(); - m_creature->CombatStop(); - m_creature->LoadCreaturesAddon(); - - if( m_creature->isAlive() ) - m_creature->GetMotionMaster()->MoveTargetedHome(); - - m_creature->SetLootRecipient(NULL); - - InCombat = false; - Reset(); -} - -void ScriptedAI::JustRespawned() -{ - InCombat = false; - Reset(); -} - -void ScriptedAI::DoStartAttackAndMovement(Unit* victim, float distance, float angle) -{ - if (!victim) - return; - - if ( m_creature->Attack(victim, true) ) - { - m_creature->GetMotionMaster()->MoveChase(victim, distance, angle); - m_creature->AddThreat(victim, 0.0f); - } -} - -void ScriptedAI::DoStartAttackNoMovement(Unit* victim) -{ - if (!victim) - return; - - if ( m_creature->Attack(victim, true) ) - { - m_creature->AddThreat(victim, 0.0f); - } -} - - -void ScriptedAI::DoMeleeAttackIfReady() -{ - //Make sure our attack is ready and we aren't currently casting before checking distance - if( m_creature->isAttackReady() && !m_creature->IsNonMeleeSpellCasted(false)) - { - //If we are within range melee the target - if( m_creature->IsWithinDistInMap(m_creature->getVictim(), ATTACK_DISTANCE)) - { - m_creature->AttackerStateUpdate(m_creature->getVictim()); - m_creature->resetAttackTimer(); - } - } -} - -void ScriptedAI::DoStopAttack() -{ - if( m_creature->getVictim() != NULL ) - { - m_creature->AttackStop(); - } -} - -void ScriptedAI::DoCast(Unit* victim, uint32 spellId, bool triggered) -{ - if (!victim || m_creature->IsNonMeleeSpellCasted(false)) - return; - - m_creature->StopMoving(); - m_creature->CastSpell(victim, spellId, triggered); -} - -void ScriptedAI::DoCastSpell(Unit* who,SpellEntry const *spellInfo, bool triggered) -{ - if (!who || m_creature->IsNonMeleeSpellCasted(false)) - return; - - m_creature->StopMoving(); - m_creature->CastSpell(who, spellInfo, triggered); -} - -void ScriptedAI::DoSay(const char* text, uint32 language, Unit* target) -{ - if (target)m_creature->Say(text, language, target->GetGUID()); - else m_creature->Say(text, language, 0); -} - -void ScriptedAI::DoYell(const char* text, uint32 language, Unit* target) -{ - if (target)m_creature->Yell(text, language, target->GetGUID()); - else m_creature->Yell(text, language, 0); -} - -void ScriptedAI::DoTextEmote(const char* text, Unit* target, bool IsBossEmote) -{ - if (target)m_creature->TextEmote(text, target->GetGUID(), IsBossEmote); - else m_creature->TextEmote(text, 0, IsBossEmote); -} - -void ScriptedAI::DoWhisper(const char* text, Unit* reciever, bool IsBossWhisper) -{ - if (!reciever || reciever->GetTypeId() != TYPEID_PLAYER) - return; - - m_creature->Whisper(text, reciever->GetGUID(), IsBossWhisper); -} - -void ScriptedAI::DoPlaySoundToSet(Unit* unit, uint32 sound) -{ - if (!unit) - return; - - if (!GetSoundEntriesStore()->LookupEntry(sound)) - { - error_log("SD2: Invalid soundId %u used in DoPlaySoundToSet (by unit TypeId %u, guid %u)", sound, unit->GetTypeId(), unit->GetGUID()); - return; - } - - WorldPacket data(4); - data.SetOpcode(SMSG_PLAY_SOUND); - data << uint32(sound); - unit->SendMessageToSet(&data,false); -} - -Creature* ScriptedAI::DoSpawnCreature(uint32 id, float x, float y, float z, float angle, uint32 type, uint32 despawntime) -{ - return m_creature->SummonCreature(id,m_creature->GetPositionX() + x,m_creature->GetPositionY() + y,m_creature->GetPositionZ() + z, angle, (TempSummonType)type, despawntime); -} - -Unit* ScriptedAI::SelectUnit(SelectAggroTarget target, uint32 position) -{ - //ThreatList m_threatlist; - std::list& m_threatlist = m_creature->getThreatManager().getThreatList(); - std::list::iterator i = m_threatlist.begin(); - std::list::reverse_iterator r = m_threatlist.rbegin(); - - if (position >= m_threatlist.size() || !m_threatlist.size()) - return NULL; - - switch (target) - { - case SELECT_TARGET_RANDOM: - advance ( i , position + (rand() % (m_threatlist.size() - position ) )); - return Unit::GetUnit((*m_creature),(*i)->getUnitGuid()); - break; - - case SELECT_TARGET_TOPAGGRO: - advance ( i , position); - return Unit::GetUnit((*m_creature),(*i)->getUnitGuid()); - break; - - case SELECT_TARGET_BOTTOMAGGRO: - advance ( r , position); - return Unit::GetUnit((*m_creature),(*r)->getUnitGuid()); - break; - } - - return NULL; -} - -SpellEntry const* ScriptedAI::SelectSpell(Unit* Target, int32 School, int32 Mechanic, SelectTarget Targets, uint32 PowerCostMin, uint32 PowerCostMax, float RangeMin, float RangeMax, SelectEffect Effects) -{ - //No target so we can't cast - if (!Target) - return false; - - //Silenced so we can't cast - if (m_creature->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SILENCED)) - return false; - - //Using the extended script system we first create a list of viable spells - SpellEntry const* Spell[4]; - Spell[0] = 0; - Spell[1] = 0; - Spell[2] = 0; - Spell[3] = 0; - - uint32 SpellCount = 0; - - SpellEntry const* TempSpell; - SpellRangeEntry const* TempRange; - - //Check if each spell is viable(set it to null if not) - for (uint32 i = 0; i < 4; i++) - { - TempSpell = GetSpellStore()->LookupEntry(m_creature->m_spells[i]); - - //This spell doesn't exist - if (!TempSpell) - continue; - - // Targets and Effects checked first as most used restrictions - //Check the spell targets if specified - if ( Targets && !(SpellSummary[m_creature->m_spells[i]].Targets & (1 << (Targets-1))) ) - continue; - - //Check the type of spell if we are looking for a specific spell type - if ( Effects && !(SpellSummary[m_creature->m_spells[i]].Effects & (1 << (Effects-1))) ) - continue; - - //Check for school if specified - if (School >= 0 && TempSpell->SchoolMask & School) - continue; - - //Check for spell mechanic if specified - if (Mechanic >= 0 && TempSpell->Mechanic != Mechanic) - continue; - - //Make sure that the spell uses the requested amount of power - if (PowerCostMin && TempSpell->manaCost < PowerCostMin) - continue; - - if (PowerCostMax && TempSpell->manaCost > PowerCostMax) - continue; - - //Continue if we don't have the mana to actually cast this spell - if (TempSpell->manaCost > m_creature->GetPower((Powers)TempSpell->powerType)) - continue; - - //Get the Range - TempRange = GetSpellRangeStore()->LookupEntry(TempSpell->rangeIndex); - - //Spell has invalid range store so we can't use it - if (!TempRange) - continue; - - //Check if the spell meets our range requirements - if (RangeMin && TempRange->maxRange < RangeMin) - continue; - if (RangeMax && TempRange->maxRange > RangeMax) - continue; - - //Check if our target is in range - if (m_creature->IsWithinDistInMap(Target, TempRange->minRange) || !m_creature->IsWithinDistInMap(Target, TempRange->maxRange)) - continue; - - //All good so lets add it to the spell list - Spell[SpellCount] = TempSpell; - SpellCount++; - } - - //We got our usable spells so now lets randomly pick one - if (!SpellCount) - return NULL; - - return Spell[rand()%SpellCount]; -} - -bool ScriptedAI::CanCast(Unit* Target, SpellEntry const *Spell, bool Triggered) -{ - //No target so we can't cast - if (!Target || !Spell) - return false; - - //Silenced so we can't cast - if (!Triggered && m_creature->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SILENCED)) - return false; - - //Check for power - if (!Triggered && m_creature->GetPower((Powers)Spell->powerType) < Spell->manaCost) - return false; - - SpellRangeEntry const *TempRange = NULL; - - TempRange = GetSpellRangeStore()->LookupEntry(Spell->rangeIndex); - - //Spell has invalid range store so we can't use it - if (!TempRange) - return false; - - //Unit is out of range of this spell - if (m_creature->GetDistance(Target) > TempRange->maxRange || m_creature->GetDistance(Target) < TempRange->minRange) - return false; - - return true; -} - -void FillSpellSummary() -{ - SpellSummary = new TSpellSummary[GetSpellStore()->GetNumRows()]; - - SpellEntry const* TempSpell; - - for (int i=0; i < GetSpellStore()->GetNumRows(); i++ ) - { - SpellSummary[i].Effects = 0; - SpellSummary[i].Targets = 0; - - TempSpell = GetSpellStore()->LookupEntry(i); - //This spell doesn't exist - if (!TempSpell) - continue; - - for (int j=0; j<3; j++) - { - //Spell targets self - if ( TempSpell->EffectImplicitTargetA[j] == TARGET_SELF ) - SpellSummary[i].Targets |= 1 << (SELECT_TARGET_SELF-1); - - //Spell targets a single enemy - if ( TempSpell->EffectImplicitTargetA[j] == TARGET_CHAIN_DAMAGE || - TempSpell->EffectImplicitTargetA[j] == TARGET_CURRENT_ENEMY_COORDINATES ) - SpellSummary[i].Targets |= 1 << (SELECT_TARGET_SINGLE_ENEMY-1); - - //Spell targets AoE at enemy - if ( TempSpell->EffectImplicitTargetA[j] == TARGET_ALL_ENEMY_IN_AREA || - TempSpell->EffectImplicitTargetA[j] == TARGET_ALL_ENEMY_IN_AREA_INSTANT || - TempSpell->EffectImplicitTargetA[j] == TARGET_ALL_AROUND_CASTER || - TempSpell->EffectImplicitTargetA[j] == TARGET_ALL_ENEMY_IN_AREA_CHANNELED ) - SpellSummary[i].Targets |= 1 << (SELECT_TARGET_AOE_ENEMY-1); - - //Spell targets an enemy - if ( TempSpell->EffectImplicitTargetA[j] == TARGET_CHAIN_DAMAGE || - TempSpell->EffectImplicitTargetA[j] == TARGET_CURRENT_ENEMY_COORDINATES || - TempSpell->EffectImplicitTargetA[j] == TARGET_ALL_ENEMY_IN_AREA || - TempSpell->EffectImplicitTargetA[j] == TARGET_ALL_ENEMY_IN_AREA_INSTANT || - TempSpell->EffectImplicitTargetA[j] == TARGET_ALL_AROUND_CASTER || - TempSpell->EffectImplicitTargetA[j] == TARGET_ALL_ENEMY_IN_AREA_CHANNELED ) - SpellSummary[i].Targets |= 1 << (SELECT_TARGET_ANY_ENEMY-1); - - //Spell targets a single friend(or self) - if ( TempSpell->EffectImplicitTargetA[j] == TARGET_SELF || - TempSpell->EffectImplicitTargetA[j] == TARGET_SINGLE_FRIEND || - TempSpell->EffectImplicitTargetA[j] == TARGET_SINGLE_PARTY ) - SpellSummary[i].Targets |= 1 << (SELECT_TARGET_SINGLE_FRIEND-1); - - //Spell targets aoe friends - if ( TempSpell->EffectImplicitTargetA[j] == TARGET_ALL_PARTY_AROUND_CASTER || - TempSpell->EffectImplicitTargetA[j] == TARGET_AREAEFFECT_PARTY || - TempSpell->EffectImplicitTargetA[j] == TARGET_ALL_AROUND_CASTER) - SpellSummary[i].Targets |= 1 << (SELECT_TARGET_AOE_FRIEND-1); - - //Spell targets any friend(or self) - if ( TempSpell->EffectImplicitTargetA[j] == TARGET_SELF || - TempSpell->EffectImplicitTargetA[j] == TARGET_SINGLE_FRIEND || - TempSpell->EffectImplicitTargetA[j] == TARGET_SINGLE_PARTY || - TempSpell->EffectImplicitTargetA[j] == TARGET_ALL_PARTY_AROUND_CASTER || - TempSpell->EffectImplicitTargetA[j] == TARGET_AREAEFFECT_PARTY || - TempSpell->EffectImplicitTargetA[j] == TARGET_ALL_AROUND_CASTER) - SpellSummary[i].Targets |= 1 << (SELECT_TARGET_ANY_FRIEND-1); - - //Make sure that this spell includes a damage effect - if ( TempSpell->Effect[j] == SPELL_EFFECT_SCHOOL_DAMAGE || - TempSpell->Effect[j] == SPELL_EFFECT_INSTAKILL || - TempSpell->Effect[j] == SPELL_EFFECT_ENVIRONMENTAL_DAMAGE || - TempSpell->Effect[j] == SPELL_EFFECT_HEALTH_LEECH ) - SpellSummary[i].Effects |= 1 << (SELECT_EFFECT_DAMAGE-1); - - //Make sure that this spell includes a healing effect (or an apply aura with a periodic heal) - if ( TempSpell->Effect[j] == SPELL_EFFECT_HEAL || - TempSpell->Effect[j] == SPELL_EFFECT_HEAL_MAX_HEALTH || - TempSpell->Effect[j] == SPELL_EFFECT_HEAL_MECHANICAL || - (TempSpell->Effect[j] == SPELL_EFFECT_APPLY_AURA && TempSpell->EffectApplyAuraName[j]== 8 )) - SpellSummary[i].Effects |= 1 << (SELECT_EFFECT_HEALING-1); - - //Make sure that this spell applies an aura - if ( TempSpell->Effect[j] == SPELL_EFFECT_APPLY_AURA ) - SpellSummary[i].Effects |= 1 << (SELECT_EFFECT_AURA-1); - } - } -} - -void ScriptedAI::DoZoneInCombat(Unit* pUnit) -{ - if (!pUnit) - pUnit = m_creature; - - Map *map = pUnit->GetMap(); - - if (!map->IsDungeon()) //use IsDungeon instead of Instanceable, in case battlegrounds will be instantiated - { - error_log("SD2: DoZoneInCombat call for map that isn't an instance (pUnit entry = %d)", pUnit->GetTypeId() == TYPEID_UNIT ? ((Creature*)pUnit)->GetEntry() : 0); - return; - } - - if (!pUnit->CanHaveThreatList() || pUnit->getThreatManager().isThreatListEmpty()) - { - error_log("SD2: DoZoneInCombat called for creature that either cannot have threat list or has empty threat list (pUnit entry = %d)", pUnit->GetTypeId() == TYPEID_UNIT ? ((Creature*)pUnit)->GetEntry() : 0); - - return; - } - - InstanceMap::PlayerList const &PlayerList = ((InstanceMap*)map)->GetPlayers(); - InstanceMap::PlayerList::const_iterator i; - for (i = PlayerList.begin(); i != PlayerList.end(); ++i) - { - if(!(*i)->isGameMaster()) - pUnit->AddThreat(*i, 0.0f); - } -} - -void ScriptedAI::DoResetThreat() -{ - if (!m_creature->CanHaveThreatList() || m_creature->getThreatManager().isThreatListEmpty()) - { - error_log("SD2: DoResetThreat called for creature that either cannot have threat list or has empty threat list (m_creature entry = %d)", m_creature->GetEntry()); - - return; - } - - std::list& m_threatlist = m_creature->getThreatManager().getThreatList(); - std::list::iterator itr; - - for(itr = m_threatlist.begin(); itr != m_threatlist.end(); ++itr) - { - Unit* pUnit = NULL; - pUnit = Unit::GetUnit((*m_creature), (*itr)->getUnitGuid()); - if(pUnit && m_creature->getThreatManager().getThreat(pUnit)) - m_creature->getThreatManager().modifyThreatPercent(pUnit, -100); - } -} - -void ScriptedAI::DoTeleportPlayer(Unit* pUnit, float x, float y, float z, float o) -{ - if(!pUnit || pUnit->GetTypeId() != TYPEID_PLAYER) - { - if(pUnit) - error_log("SD2: Creature %u (Entry: %u) Tried to teleport non-player unit (Type: %u GUID: %u) to x: %f y:%f z: %f o: %f. Aborted.", m_creature->GetGUID(), m_creature->GetEntry(), pUnit->GetTypeId(), pUnit->GetGUID(), x, y, z, o); - return; - } - - ((Player*)pUnit)->TeleportTo(pUnit->GetMapId(), x, y, z, o, TELE_TO_NOT_LEAVE_COMBAT); -} - -Unit* ScriptedAI::DoSelectLowestHpFriendly(float range, uint32 MinHPDiff) -{ - CellPair p(MaNGOS::ComputeCellPair(m_creature->GetPositionX(), m_creature->GetPositionY())); - Cell cell(p); - cell.data.Part.reserved = ALL_DISTRICT; - cell.SetNoCreate(); - - Unit* pUnit = NULL; - - MostHPMissingInRange u_check(m_creature, range, MinHPDiff); - MaNGOS::UnitLastSearcher searcher(pUnit, u_check); - - /* - typedef TYPELIST_4(GameObject, Creature*except pets*, DynamicObject, Corpse*Bones*) AllGridObjectTypes; - This means that if we only search grid then we cannot possibly return pets or players so this is safe - */ - TypeContainerVisitor, GridTypeMapContainer > grid_unit_searcher(searcher); - - CellLock cell_lock(cell, p); - cell_lock->Visit(cell_lock, grid_unit_searcher, *(m_creature->GetMap())); - return pUnit; -} - -std::list ScriptedAI::DoFindFriendlyCC(float range) -{ - CellPair p(MaNGOS::ComputeCellPair(m_creature->GetPositionX(), m_creature->GetPositionY())); - Cell cell(p); - cell.data.Part.reserved = ALL_DISTRICT; - cell.SetNoCreate(); - - std::list pList; - - FriendlyCCedInRange u_check(m_creature, range); - MaNGOS::CreatureListSearcher searcher(pList, u_check); - - TypeContainerVisitor, GridTypeMapContainer > grid_creature_searcher(searcher); - - CellLock cell_lock(cell, p); - cell_lock->Visit(cell_lock, grid_creature_searcher, *(m_creature->GetMap())); - - return pList; -} - -std::list ScriptedAI::DoFindFriendlyMissingBuff(float range, uint32 spellid) -{ - CellPair p(MaNGOS::ComputeCellPair(m_creature->GetPositionX(), m_creature->GetPositionY())); - Cell cell(p); - cell.data.Part.reserved = ALL_DISTRICT; - cell.SetNoCreate(); - - std::list pList; - - FriendlyMissingBuffInRange u_check(m_creature, range, spellid); - MaNGOS::CreatureListSearcher searcher(pList, u_check); - - TypeContainerVisitor, GridTypeMapContainer > grid_creature_searcher(searcher); - - CellLock cell_lock(cell, p); - cell_lock->Visit(cell_lock, grid_creature_searcher, *(m_creature->GetMap())); - - return pList; -} - -void Scripted_NoMovementAI::MoveInLineOfSight(Unit *who) -{ - if( !m_creature->getVictim() && who->isTargetableForAttack() && ( m_creature->IsHostileTo( who )) && who->isInAccessablePlaceFor(m_creature) ) - { - if (m_creature->GetDistanceZ(who) > CREATURE_Z_ATTACK_RANGE) - return; - - float attackRadius = m_creature->GetAttackDistance(who); - if( m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->IsWithinLOSInMap(who) ) - { - DoStartAttackNoMovement(who); - who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); - - if (!InCombat) - { - Aggro(who); - InCombat = true; - } - } - } -} - -void Scripted_NoMovementAI::AttackStart(Unit* who) -{ - if (!who) - return; - - if (who->isTargetableForAttack()) - { - //Begin attack - DoStartAttackNoMovement(who); - - if (!InCombat) - { - Aggro(who); - InCombat = true; - } - } -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software licensed under GPL version 2 + * Please see the included DOCS/LICENSE.TXT for more information */ + +#include "precompiled.h" +#include "Item.h" +#include "Spell.h" +#include "WorldPacket.h" + +// Spell summary for ScriptedAI::SelectSpell +struct TSpellSummary { + uint8 Targets; // set of enum SelectTarget + uint8 Effects; // set of enum SelectEffect +} *SpellSummary; + +bool ScriptedAI::IsVisible(Unit* who) const +{ + if (!who) + return false; + + return (m_creature->GetDistance(who) < VISIBLE_RANGE) && who->isVisibleForOrDetect(m_creature,true); +} + +void ScriptedAI::MoveInLineOfSight(Unit *who) +{ + if( !m_creature->getVictim() && who->isTargetableForAttack() && ( m_creature->IsHostileTo( who )) && who->isInAccessablePlaceFor(m_creature) ) + { + if (!m_creature->canFly() && m_creature->GetDistanceZ(who) > CREATURE_Z_ATTACK_RANGE) + return; + + float attackRadius = m_creature->GetAttackDistance(who); + if( m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->IsWithinLOSInMap(who) ) + { + DoStartAttackAndMovement(who); + who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); + + if (!InCombat) + { + Aggro(who); + InCombat = true; + } + } + } +} + +void ScriptedAI::AttackStart(Unit* who) +{ + if (!who) + return; + + if (who->isTargetableForAttack()) + { + //Begin attack + DoStartAttackAndMovement(who); + + if (!InCombat) + { + Aggro(who); + InCombat = true; + } + } +} + +void ScriptedAI::UpdateAI(const uint32 diff) +{ + //Check if we have a current target + if( m_creature->isAlive() && m_creature->SelectHostilTarget() && m_creature->getVictim()) + { + if( m_creature->isAttackReady() ) + { + //If we are within range melee the target + if( m_creature->IsWithinDistInMap(m_creature->getVictim(), ATTACK_DISTANCE)) + { + m_creature->AttackerStateUpdate(m_creature->getVictim()); + m_creature->resetAttackTimer(); + } + } + } +} + +void ScriptedAI::EnterEvadeMode() +{ + m_creature->InterruptNonMeleeSpells(true); + m_creature->RemoveAllAuras(); + m_creature->DeleteThreatList(); + m_creature->CombatStop(); + m_creature->LoadCreaturesAddon(); + + if( m_creature->isAlive() ) + m_creature->GetMotionMaster()->MoveTargetedHome(); + + m_creature->SetLootRecipient(NULL); + + InCombat = false; + Reset(); +} + +void ScriptedAI::JustRespawned() +{ + InCombat = false; + Reset(); +} + +void ScriptedAI::DoStartAttackAndMovement(Unit* victim, float distance, float angle) +{ + if (!victim) + return; + + if ( m_creature->Attack(victim, true) ) + { + m_creature->GetMotionMaster()->MoveChase(victim, distance, angle); + m_creature->AddThreat(victim, 0.0f); + } +} + +void ScriptedAI::DoStartAttackNoMovement(Unit* victim) +{ + if (!victim) + return; + + if ( m_creature->Attack(victim, true) ) + { + m_creature->AddThreat(victim, 0.0f); + } +} + + +void ScriptedAI::DoMeleeAttackIfReady() +{ + //Make sure our attack is ready and we aren't currently casting before checking distance + if( m_creature->isAttackReady() && !m_creature->IsNonMeleeSpellCasted(false)) + { + //If we are within range melee the target + if( m_creature->IsWithinDistInMap(m_creature->getVictim(), ATTACK_DISTANCE)) + { + m_creature->AttackerStateUpdate(m_creature->getVictim()); + m_creature->resetAttackTimer(); + } + } +} + +void ScriptedAI::DoStopAttack() +{ + if( m_creature->getVictim() != NULL ) + { + m_creature->AttackStop(); + } +} + +void ScriptedAI::DoCast(Unit* victim, uint32 spellId, bool triggered) +{ + if (!victim || m_creature->IsNonMeleeSpellCasted(false)) + return; + + m_creature->StopMoving(); + m_creature->CastSpell(victim, spellId, triggered); +} + +void ScriptedAI::DoCastSpell(Unit* who,SpellEntry const *spellInfo, bool triggered) +{ + if (!who || m_creature->IsNonMeleeSpellCasted(false)) + return; + + m_creature->StopMoving(); + m_creature->CastSpell(who, spellInfo, triggered); +} + +void ScriptedAI::DoSay(const char* text, uint32 language, Unit* target) +{ + if (target)m_creature->Say(text, language, target->GetGUID()); + else m_creature->Say(text, language, 0); +} + +void ScriptedAI::DoYell(const char* text, uint32 language, Unit* target) +{ + if (target)m_creature->Yell(text, language, target->GetGUID()); + else m_creature->Yell(text, language, 0); +} + +void ScriptedAI::DoTextEmote(const char* text, Unit* target, bool IsBossEmote) +{ + if (target)m_creature->TextEmote(text, target->GetGUID(), IsBossEmote); + else m_creature->TextEmote(text, 0, IsBossEmote); +} + +void ScriptedAI::DoWhisper(const char* text, Unit* reciever, bool IsBossWhisper) +{ + if (!reciever || reciever->GetTypeId() != TYPEID_PLAYER) + return; + + m_creature->Whisper(text, reciever->GetGUID(), IsBossWhisper); +} + +void ScriptedAI::DoPlaySoundToSet(Unit* unit, uint32 sound) +{ + if (!unit) + return; + + if (!GetSoundEntriesStore()->LookupEntry(sound)) + { + error_log("SD2: Invalid soundId %u used in DoPlaySoundToSet (by unit TypeId %u, guid %u)", sound, unit->GetTypeId(), unit->GetGUID()); + return; + } + + WorldPacket data(4); + data.SetOpcode(SMSG_PLAY_SOUND); + data << uint32(sound); + unit->SendMessageToSet(&data,false); +} + +Creature* ScriptedAI::DoSpawnCreature(uint32 id, float x, float y, float z, float angle, uint32 type, uint32 despawntime) +{ + return m_creature->SummonCreature(id,m_creature->GetPositionX() + x,m_creature->GetPositionY() + y,m_creature->GetPositionZ() + z, angle, (TempSummonType)type, despawntime); +} + +Unit* ScriptedAI::SelectUnit(SelectAggroTarget target, uint32 position) +{ + //ThreatList m_threatlist; + std::list& m_threatlist = m_creature->getThreatManager().getThreatList(); + std::list::iterator i = m_threatlist.begin(); + std::list::reverse_iterator r = m_threatlist.rbegin(); + + if (position >= m_threatlist.size() || !m_threatlist.size()) + return NULL; + + switch (target) + { + case SELECT_TARGET_RANDOM: + advance ( i , position + (rand() % (m_threatlist.size() - position ) )); + return Unit::GetUnit((*m_creature),(*i)->getUnitGuid()); + break; + + case SELECT_TARGET_TOPAGGRO: + advance ( i , position); + return Unit::GetUnit((*m_creature),(*i)->getUnitGuid()); + break; + + case SELECT_TARGET_BOTTOMAGGRO: + advance ( r , position); + return Unit::GetUnit((*m_creature),(*r)->getUnitGuid()); + break; + } + + return NULL; +} + +SpellEntry const* ScriptedAI::SelectSpell(Unit* Target, int32 School, int32 Mechanic, SelectTarget Targets, uint32 PowerCostMin, uint32 PowerCostMax, float RangeMin, float RangeMax, SelectEffect Effects) +{ + //No target so we can't cast + if (!Target) + return false; + + //Silenced so we can't cast + if (m_creature->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SILENCED)) + return false; + + //Using the extended script system we first create a list of viable spells + SpellEntry const* Spell[4]; + Spell[0] = 0; + Spell[1] = 0; + Spell[2] = 0; + Spell[3] = 0; + + uint32 SpellCount = 0; + + SpellEntry const* TempSpell; + SpellRangeEntry const* TempRange; + + //Check if each spell is viable(set it to null if not) + for (uint32 i = 0; i < 4; i++) + { + TempSpell = GetSpellStore()->LookupEntry(m_creature->m_spells[i]); + + //This spell doesn't exist + if (!TempSpell) + continue; + + // Targets and Effects checked first as most used restrictions + //Check the spell targets if specified + if ( Targets && !(SpellSummary[m_creature->m_spells[i]].Targets & (1 << (Targets-1))) ) + continue; + + //Check the type of spell if we are looking for a specific spell type + if ( Effects && !(SpellSummary[m_creature->m_spells[i]].Effects & (1 << (Effects-1))) ) + continue; + + //Check for school if specified + if (School >= 0 && TempSpell->SchoolMask & School) + continue; + + //Check for spell mechanic if specified + if (Mechanic >= 0 && TempSpell->Mechanic != Mechanic) + continue; + + //Make sure that the spell uses the requested amount of power + if (PowerCostMin && TempSpell->manaCost < PowerCostMin) + continue; + + if (PowerCostMax && TempSpell->manaCost > PowerCostMax) + continue; + + //Continue if we don't have the mana to actually cast this spell + if (TempSpell->manaCost > m_creature->GetPower((Powers)TempSpell->powerType)) + continue; + + //Get the Range + TempRange = GetSpellRangeStore()->LookupEntry(TempSpell->rangeIndex); + + //Spell has invalid range store so we can't use it + if (!TempRange) + continue; + + //Check if the spell meets our range requirements + if (RangeMin && TempRange->maxRange < RangeMin) + continue; + if (RangeMax && TempRange->maxRange > RangeMax) + continue; + + //Check if our target is in range + if (m_creature->IsWithinDistInMap(Target, TempRange->minRange) || !m_creature->IsWithinDistInMap(Target, TempRange->maxRange)) + continue; + + //All good so lets add it to the spell list + Spell[SpellCount] = TempSpell; + SpellCount++; + } + + //We got our usable spells so now lets randomly pick one + if (!SpellCount) + return NULL; + + return Spell[rand()%SpellCount]; +} + +bool ScriptedAI::CanCast(Unit* Target, SpellEntry const *Spell, bool Triggered) +{ + //No target so we can't cast + if (!Target || !Spell) + return false; + + //Silenced so we can't cast + if (!Triggered && m_creature->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SILENCED)) + return false; + + //Check for power + if (!Triggered && m_creature->GetPower((Powers)Spell->powerType) < Spell->manaCost) + return false; + + SpellRangeEntry const *TempRange = NULL; + + TempRange = GetSpellRangeStore()->LookupEntry(Spell->rangeIndex); + + //Spell has invalid range store so we can't use it + if (!TempRange) + return false; + + //Unit is out of range of this spell + if (m_creature->GetDistance(Target) > TempRange->maxRange || m_creature->GetDistance(Target) < TempRange->minRange) + return false; + + return true; +} + +void FillSpellSummary() +{ + SpellSummary = new TSpellSummary[GetSpellStore()->GetNumRows()]; + + SpellEntry const* TempSpell; + + for (int i=0; i < GetSpellStore()->GetNumRows(); i++ ) + { + SpellSummary[i].Effects = 0; + SpellSummary[i].Targets = 0; + + TempSpell = GetSpellStore()->LookupEntry(i); + //This spell doesn't exist + if (!TempSpell) + continue; + + for (int j=0; j<3; j++) + { + //Spell targets self + if ( TempSpell->EffectImplicitTargetA[j] == TARGET_SELF ) + SpellSummary[i].Targets |= 1 << (SELECT_TARGET_SELF-1); + + //Spell targets a single enemy + if ( TempSpell->EffectImplicitTargetA[j] == TARGET_CHAIN_DAMAGE || + TempSpell->EffectImplicitTargetA[j] == TARGET_CURRENT_ENEMY_COORDINATES ) + SpellSummary[i].Targets |= 1 << (SELECT_TARGET_SINGLE_ENEMY-1); + + //Spell targets AoE at enemy + if ( TempSpell->EffectImplicitTargetA[j] == TARGET_ALL_ENEMY_IN_AREA || + TempSpell->EffectImplicitTargetA[j] == TARGET_ALL_ENEMY_IN_AREA_INSTANT || + TempSpell->EffectImplicitTargetA[j] == TARGET_ALL_AROUND_CASTER || + TempSpell->EffectImplicitTargetA[j] == TARGET_ALL_ENEMY_IN_AREA_CHANNELED ) + SpellSummary[i].Targets |= 1 << (SELECT_TARGET_AOE_ENEMY-1); + + //Spell targets an enemy + if ( TempSpell->EffectImplicitTargetA[j] == TARGET_CHAIN_DAMAGE || + TempSpell->EffectImplicitTargetA[j] == TARGET_CURRENT_ENEMY_COORDINATES || + TempSpell->EffectImplicitTargetA[j] == TARGET_ALL_ENEMY_IN_AREA || + TempSpell->EffectImplicitTargetA[j] == TARGET_ALL_ENEMY_IN_AREA_INSTANT || + TempSpell->EffectImplicitTargetA[j] == TARGET_ALL_AROUND_CASTER || + TempSpell->EffectImplicitTargetA[j] == TARGET_ALL_ENEMY_IN_AREA_CHANNELED ) + SpellSummary[i].Targets |= 1 << (SELECT_TARGET_ANY_ENEMY-1); + + //Spell targets a single friend(or self) + if ( TempSpell->EffectImplicitTargetA[j] == TARGET_SELF || + TempSpell->EffectImplicitTargetA[j] == TARGET_SINGLE_FRIEND || + TempSpell->EffectImplicitTargetA[j] == TARGET_SINGLE_PARTY ) + SpellSummary[i].Targets |= 1 << (SELECT_TARGET_SINGLE_FRIEND-1); + + //Spell targets aoe friends + if ( TempSpell->EffectImplicitTargetA[j] == TARGET_ALL_PARTY_AROUND_CASTER || + TempSpell->EffectImplicitTargetA[j] == TARGET_AREAEFFECT_PARTY || + TempSpell->EffectImplicitTargetA[j] == TARGET_ALL_AROUND_CASTER) + SpellSummary[i].Targets |= 1 << (SELECT_TARGET_AOE_FRIEND-1); + + //Spell targets any friend(or self) + if ( TempSpell->EffectImplicitTargetA[j] == TARGET_SELF || + TempSpell->EffectImplicitTargetA[j] == TARGET_SINGLE_FRIEND || + TempSpell->EffectImplicitTargetA[j] == TARGET_SINGLE_PARTY || + TempSpell->EffectImplicitTargetA[j] == TARGET_ALL_PARTY_AROUND_CASTER || + TempSpell->EffectImplicitTargetA[j] == TARGET_AREAEFFECT_PARTY || + TempSpell->EffectImplicitTargetA[j] == TARGET_ALL_AROUND_CASTER) + SpellSummary[i].Targets |= 1 << (SELECT_TARGET_ANY_FRIEND-1); + + //Make sure that this spell includes a damage effect + if ( TempSpell->Effect[j] == SPELL_EFFECT_SCHOOL_DAMAGE || + TempSpell->Effect[j] == SPELL_EFFECT_INSTAKILL || + TempSpell->Effect[j] == SPELL_EFFECT_ENVIRONMENTAL_DAMAGE || + TempSpell->Effect[j] == SPELL_EFFECT_HEALTH_LEECH ) + SpellSummary[i].Effects |= 1 << (SELECT_EFFECT_DAMAGE-1); + + //Make sure that this spell includes a healing effect (or an apply aura with a periodic heal) + if ( TempSpell->Effect[j] == SPELL_EFFECT_HEAL || + TempSpell->Effect[j] == SPELL_EFFECT_HEAL_MAX_HEALTH || + TempSpell->Effect[j] == SPELL_EFFECT_HEAL_MECHANICAL || + (TempSpell->Effect[j] == SPELL_EFFECT_APPLY_AURA && TempSpell->EffectApplyAuraName[j]== 8 )) + SpellSummary[i].Effects |= 1 << (SELECT_EFFECT_HEALING-1); + + //Make sure that this spell applies an aura + if ( TempSpell->Effect[j] == SPELL_EFFECT_APPLY_AURA ) + SpellSummary[i].Effects |= 1 << (SELECT_EFFECT_AURA-1); + } + } +} + +void ScriptedAI::DoZoneInCombat(Unit* pUnit) +{ + if (!pUnit) + pUnit = m_creature; + + Map *map = pUnit->GetMap(); + + if (!map->IsDungeon()) //use IsDungeon instead of Instanceable, in case battlegrounds will be instantiated + { + error_log("SD2: DoZoneInCombat call for map that isn't an instance (pUnit entry = %d)", pUnit->GetTypeId() == TYPEID_UNIT ? ((Creature*)pUnit)->GetEntry() : 0); + return; + } + + if (!pUnit->CanHaveThreatList() || pUnit->getThreatManager().isThreatListEmpty()) + { + error_log("SD2: DoZoneInCombat called for creature that either cannot have threat list or has empty threat list (pUnit entry = %d)", pUnit->GetTypeId() == TYPEID_UNIT ? ((Creature*)pUnit)->GetEntry() : 0); + + return; + } + + InstanceMap::PlayerList const &PlayerList = ((InstanceMap*)map)->GetPlayers(); + InstanceMap::PlayerList::const_iterator i; + for (i = PlayerList.begin(); i != PlayerList.end(); ++i) + { + if(!(*i)->isGameMaster()) + pUnit->AddThreat(*i, 0.0f); + } +} + +void ScriptedAI::DoResetThreat() +{ + if (!m_creature->CanHaveThreatList() || m_creature->getThreatManager().isThreatListEmpty()) + { + error_log("SD2: DoResetThreat called for creature that either cannot have threat list or has empty threat list (m_creature entry = %d)", m_creature->GetEntry()); + + return; + } + + std::list& m_threatlist = m_creature->getThreatManager().getThreatList(); + std::list::iterator itr; + + for(itr = m_threatlist.begin(); itr != m_threatlist.end(); ++itr) + { + Unit* pUnit = NULL; + pUnit = Unit::GetUnit((*m_creature), (*itr)->getUnitGuid()); + if(pUnit && m_creature->getThreatManager().getThreat(pUnit)) + m_creature->getThreatManager().modifyThreatPercent(pUnit, -100); + } +} + +void ScriptedAI::DoTeleportPlayer(Unit* pUnit, float x, float y, float z, float o) +{ + if(!pUnit || pUnit->GetTypeId() != TYPEID_PLAYER) + { + if(pUnit) + error_log("SD2: Creature %u (Entry: %u) Tried to teleport non-player unit (Type: %u GUID: %u) to x: %f y:%f z: %f o: %f. Aborted.", m_creature->GetGUID(), m_creature->GetEntry(), pUnit->GetTypeId(), pUnit->GetGUID(), x, y, z, o); + return; + } + + ((Player*)pUnit)->TeleportTo(pUnit->GetMapId(), x, y, z, o, TELE_TO_NOT_LEAVE_COMBAT); +} + +Unit* ScriptedAI::DoSelectLowestHpFriendly(float range, uint32 MinHPDiff) +{ + CellPair p(MaNGOS::ComputeCellPair(m_creature->GetPositionX(), m_creature->GetPositionY())); + Cell cell(p); + cell.data.Part.reserved = ALL_DISTRICT; + cell.SetNoCreate(); + + Unit* pUnit = NULL; + + MostHPMissingInRange u_check(m_creature, range, MinHPDiff); + MaNGOS::UnitLastSearcher searcher(pUnit, u_check); + + /* + typedef TYPELIST_4(GameObject, Creature*except pets*, DynamicObject, Corpse*Bones*) AllGridObjectTypes; + This means that if we only search grid then we cannot possibly return pets or players so this is safe + */ + TypeContainerVisitor, GridTypeMapContainer > grid_unit_searcher(searcher); + + CellLock cell_lock(cell, p); + cell_lock->Visit(cell_lock, grid_unit_searcher, *(m_creature->GetMap())); + return pUnit; +} + +std::list ScriptedAI::DoFindFriendlyCC(float range) +{ + CellPair p(MaNGOS::ComputeCellPair(m_creature->GetPositionX(), m_creature->GetPositionY())); + Cell cell(p); + cell.data.Part.reserved = ALL_DISTRICT; + cell.SetNoCreate(); + + std::list pList; + + FriendlyCCedInRange u_check(m_creature, range); + MaNGOS::CreatureListSearcher searcher(pList, u_check); + + TypeContainerVisitor, GridTypeMapContainer > grid_creature_searcher(searcher); + + CellLock cell_lock(cell, p); + cell_lock->Visit(cell_lock, grid_creature_searcher, *(m_creature->GetMap())); + + return pList; +} + +std::list ScriptedAI::DoFindFriendlyMissingBuff(float range, uint32 spellid) +{ + CellPair p(MaNGOS::ComputeCellPair(m_creature->GetPositionX(), m_creature->GetPositionY())); + Cell cell(p); + cell.data.Part.reserved = ALL_DISTRICT; + cell.SetNoCreate(); + + std::list pList; + + FriendlyMissingBuffInRange u_check(m_creature, range, spellid); + MaNGOS::CreatureListSearcher searcher(pList, u_check); + + TypeContainerVisitor, GridTypeMapContainer > grid_creature_searcher(searcher); + + CellLock cell_lock(cell, p); + cell_lock->Visit(cell_lock, grid_creature_searcher, *(m_creature->GetMap())); + + return pList; +} + +void Scripted_NoMovementAI::MoveInLineOfSight(Unit *who) +{ + if( !m_creature->getVictim() && who->isTargetableForAttack() && ( m_creature->IsHostileTo( who )) && who->isInAccessablePlaceFor(m_creature) ) + { + if (!m_creature->canFly() && m_creature->GetDistanceZ(who) > CREATURE_Z_ATTACK_RANGE) + return; + + float attackRadius = m_creature->GetAttackDistance(who); + if( m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->IsWithinLOSInMap(who) ) + { + DoStartAttackNoMovement(who); + who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); + + if (!InCombat) + { + Aggro(who); + InCombat = true; + } + } + } +} + +void Scripted_NoMovementAI::AttackStart(Unit* who) +{ + if (!who) + return; + + if (who->isTargetableForAttack()) + { + //Begin attack + DoStartAttackNoMovement(who); + + if (!InCombat) + { + Aggro(who); + InCombat = true; + } + } +} diff --git a/src/bindings/scripts/include/sc_gossip.h b/src/bindings/scripts/include/sc_gossip.h index af304a2d63f..48d9786a4ed 100644 --- a/src/bindings/scripts/include/sc_gossip.h +++ b/src/bindings/scripts/include/sc_gossip.h @@ -1,183 +1,183 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 -* This program is free software licensed under GPL version 2 -* Please see the included DOCS/LICENSE.TXT for more information */ - -#ifndef SC_PLAYER_H -#define SC_PLAYER_H - -#include "Player.h" -#include "GossipDef.h" -#include "QuestDef.h" - -// Gossip Item Text -#define GOSSIP_TEXT_BROWSE_GOODS "I'd like to browse your goods." -#define GOSSIP_TEXT_TRAIN "Train me!" - -#define GOSSIP_TEXT_BANK "The Bank" -#define GOSSIP_TEXT_WINDRIDER "Wind rider master" -#define GOSSIP_TEXT_GRYPHON "Gryphon Master" -#define GOSSIP_TEXT_BATHANDLER "Bat Handler" -#define GOSSIP_TEXT_HIPPOGRYPH "Hippogryph Master" -#define GOSSIP_TEXT_FLIGHTMASTER "Flight Master" -#define GOSSIP_TEXT_AUCTIONHOUSE "Auction House" -#define GOSSIP_TEXT_GUILDMASTER "Guild Master" -#define GOSSIP_TEXT_INN "The Inn" -#define GOSSIP_TEXT_MAILBOX "Mailbox" -#define GOSSIP_TEXT_STABLEMASTER "Stable Master" -#define GOSSIP_TEXT_WEAPONMASTER "Weapons Trainer" -#define GOSSIP_TEXT_BATTLEMASTER "Battlemaster" -#define GOSSIP_TEXT_CLASSTRAINER "Class Trainer" -#define GOSSIP_TEXT_PROFTRAINER "Profession Trainer" -#define GOSSIP_TEXT_OFFICERS "The officers` lounge" - -#define GOSSIP_TEXT_ALTERACVALLEY "Alterac Valley" -#define GOSSIP_TEXT_ARATHIBASIN "Arathi Basin" -#define GOSSIP_TEXT_WARSONGULCH "Warsong Gulch" -#define GOSSIP_TEXT_ARENA "Arena" -#define GOSSIP_TEXT_EYEOFTHESTORM "Eye of The Storm" - -#define GOSSIP_TEXT_DRUID "Druid" -#define GOSSIP_TEXT_HUNTER "Hunter" -#define GOSSIP_TEXT_PRIEST "Priest" -#define GOSSIP_TEXT_ROGUE "Rogue" -#define GOSSIP_TEXT_WARRIOR "Warrior" -#define GOSSIP_TEXT_PALADIN "Paladin" -#define GOSSIP_TEXT_SHAMAN "Shaman" -#define GOSSIP_TEXT_MAGE "Mage" -#define GOSSIP_TEXT_WARLOCK "Warlock" - -#define GOSSIP_TEXT_ALCHEMY "Alchemy" -#define GOSSIP_TEXT_BLACKSMITHING "Blacksmithing" -#define GOSSIP_TEXT_COOKING "Cooking" -#define GOSSIP_TEXT_ENCHANTING "Enchanting" -#define GOSSIP_TEXT_ENGINEERING "Engineering" -#define GOSSIP_TEXT_FIRSTAID "First Aid" -#define GOSSIP_TEXT_HERBALISM "Herbalism" -#define GOSSIP_TEXT_LEATHERWORKING "Leatherworking" -#define GOSSIP_TEXT_POISONS "Poisons" -#define GOSSIP_TEXT_TAILORING "Tailoring" -#define GOSSIP_TEXT_MINING "Mining" -#define GOSSIP_TEXT_FISHING "Fishing" -#define GOSSIP_TEXT_SKINNING "Skinning" -#define GOSSIP_TEXT_JEWELCRAFTING "Jewelcrafting" - -#define GOSSIP_TEXT_IRONFORGE_BANK "Bank of Ironforge" -#define GOSSIP_TEXT_STORMWIND_BANK "Bank of Stormwind" -#define GOSSIP_TEXT_DEEPRUNTRAM "Deeprun Tram" -#define GOSSIP_TEXT_ZEPPLINMASTER "Zeppelin master" -#define GOSSIP_TEXT_FERRY "Rut'theran Ferry" - -// Skill defines - -#define TRADESKILL_ALCHEMY 1 -#define TRADESKILL_BLACKSMITHING 2 -#define TRADESKILL_COOKING 3 -#define TRADESKILL_ENCHANTING 4 -#define TRADESKILL_ENGINEERING 5 -#define TRADESKILL_FIRSTAID 6 -#define TRADESKILL_HERBALISM 7 -#define TRADESKILL_LEATHERWORKING 8 -#define TRADESKILL_POISONS 9 -#define TRADESKILL_TAILORING 10 -#define TRADESKILL_MINING 11 -#define TRADESKILL_FISHING 12 -#define TRADESKILL_SKINNING 13 -#define TRADESKILL_JEWLCRAFTING 14 - -#define TRADESKILL_LEVEL_NONE 0 -#define TRADESKILL_LEVEL_APPRENTICE 1 -#define TRADESKILL_LEVEL_JOURNEYMAN 2 -#define TRADESKILL_LEVEL_EXPERT 3 -#define TRADESKILL_LEVEL_ARTISAN 4 -#define TRADESKILL_LEVEL_MASTER 5 - -// Gossip defines - -#define GOSSIP_ACTION_TRADE 1 -#define GOSSIP_ACTION_TRAIN 2 -#define GOSSIP_ACTION_TAXI 3 -#define GOSSIP_ACTION_GUILD 4 -#define GOSSIP_ACTION_BATTLE 5 -#define GOSSIP_ACTION_BANK 6 -#define GOSSIP_ACTION_INN 7 -#define GOSSIP_ACTION_HEAL 8 -#define GOSSIP_ACTION_TABARD 9 -#define GOSSIP_ACTION_AUCTION 10 -#define GOSSIP_ACTION_INN_INFO 11 -#define GOSSIP_ACTION_UNLEARN 12 -#define GOSSIP_ACTION_INFO_DEF 1000 - -#define GOSSIP_SENDER_MAIN 1 -#define GOSSIP_SENDER_INN_INFO 2 -#define GOSSIP_SENDER_INFO 3 -#define GOSSIP_SENDER_SEC_PROFTRAIN 4 -#define GOSSIP_SENDER_SEC_CLASSTRAIN 5 -#define GOSSIP_SENDER_SEC_BATTLEINFO 6 -#define GOSSIP_SENDER_SEC_BANK 7 -#define GOSSIP_SENDER_SEC_INN 8 -#define GOSSIP_SENDER_SEC_MAILBOX 9 -#define GOSSIP_SENDER_SEC_STABLEMASTER 10 - -#define DEFAULT_GOSSIP_MESSAGE 0xffffff - -extern uint32 GetSkillLevel(Player *player,uint32 skill); - -// Defined fuctions to use with player. - -// This fuction add's a menu item, -// a - Icon Id -// b - Text -// c - Sender(this is to identify the current Menu with this item) -// d - Action (identifys this Menu Item) -// e - Text to be displayed in pop up box -// f - Money value in pop up box -#define ADD_GOSSIP_ITEM(a,b,c,d) PlayerTalkClass->GetGossipMenu()->AddMenuItem(a,b,c,d,"",0) -#define ADD_GOSSIP_ITEM_EXTENDED(a,b,c,d,e,f) PlayerTalkClass->GetGossipMenu()->AddMenuItem(a,b,c,d,e,f) - -// This fuction Sends the current menu to show to client, a - NPCTEXTID(uint32) , b - npc guid(uint64) -#define SEND_GOSSIP_MENU(a,b) PlayerTalkClass->SendGossipMenu(a,b) - -// This fuction shows POI(point of interest) to client. -// a - position X -// b - position Y -// c - Icon Id -// d - Flags -// e - Data -// f - Location Name -#define SEND_POI(a,b,c,d,e,f) PlayerTalkClass->SendPointOfInterest(a,b,c,d,e,f) - -// Closes the Menu -#define CLOSE_GOSSIP_MENU() PlayerTalkClass->CloseGossip() - -// Fuction to tell to client the details -// a - quest object -// b - npc guid(uint64) -// c - Activate accept(bool) -#define SEND_QUEST_DETAILS(a,b,c) PlayerTalkClass->SendQuestDetails(a,b,c) - -// Fuction to tell to client the requested items to complete quest -// a - quest object -// b - npc guid(uint64) -// c - Iscompletable(bool) -// d - close at cancel(bool) - in case single incomplite ques -#define SEND_REQUESTEDITEMS(a,b,c,d) PlayerTalkClass->SendRequestedItems(a,b,c,d) - -// Fuctions to send NPC lists, a - is always the npc guid(uint64) -#define SEND_VENDORLIST(a) GetSession()->SendListInventory(a) -#define SEND_TRAINERLIST(a) GetSession()->SendTrainerList(a) -#define SEND_BANKERLIST(a) GetSession()->SendShowBank(a) -#define SEND_TABARDLIST(a) GetSession()->SendTabardVendorActivate(a) -#define SEND_AUCTIONLIST(a) GetSession()->SendAuctionHello(a) -#define SEND_TAXILIST(a) GetSession()->SendTaxiStatus(a) - -// Ressurect's the player if is dead. -#define SEND_SPRESURRECT() GetSession()->SendSpiritResurrect() - -// Get the player's honor rank. -#define GET_HONORRANK() GetHonorRank() -// ----------------------------------- - -// defined fuctions to use with Creature - -#define QUEST_DIALOG_STATUS(a,b,c) GetSession()->getDialogStatus(a,b,c) -#endif +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software licensed under GPL version 2 + * Please see the included DOCS/LICENSE.TXT for more information */ + +#ifndef SC_PLAYER_H +#define SC_PLAYER_H + +#include "Player.h" +#include "GossipDef.h" +#include "QuestDef.h" + +// Gossip Item Text +#define GOSSIP_TEXT_BROWSE_GOODS "I'd like to browse your goods." +#define GOSSIP_TEXT_TRAIN "Train me!" + +#define GOSSIP_TEXT_BANK "The Bank" +#define GOSSIP_TEXT_WINDRIDER "Wind rider master" +#define GOSSIP_TEXT_GRYPHON "Gryphon Master" +#define GOSSIP_TEXT_BATHANDLER "Bat Handler" +#define GOSSIP_TEXT_HIPPOGRYPH "Hippogryph Master" +#define GOSSIP_TEXT_FLIGHTMASTER "Flight Master" +#define GOSSIP_TEXT_AUCTIONHOUSE "Auction House" +#define GOSSIP_TEXT_GUILDMASTER "Guild Master" +#define GOSSIP_TEXT_INN "The Inn" +#define GOSSIP_TEXT_MAILBOX "Mailbox" +#define GOSSIP_TEXT_STABLEMASTER "Stable Master" +#define GOSSIP_TEXT_WEAPONMASTER "Weapons Trainer" +#define GOSSIP_TEXT_BATTLEMASTER "Battlemaster" +#define GOSSIP_TEXT_CLASSTRAINER "Class Trainer" +#define GOSSIP_TEXT_PROFTRAINER "Profession Trainer" +#define GOSSIP_TEXT_OFFICERS "The officers` lounge" + +#define GOSSIP_TEXT_ALTERACVALLEY "Alterac Valley" +#define GOSSIP_TEXT_ARATHIBASIN "Arathi Basin" +#define GOSSIP_TEXT_WARSONGULCH "Warsong Gulch" +#define GOSSIP_TEXT_ARENA "Arena" +#define GOSSIP_TEXT_EYEOFTHESTORM "Eye of The Storm" + +#define GOSSIP_TEXT_DRUID "Druid" +#define GOSSIP_TEXT_HUNTER "Hunter" +#define GOSSIP_TEXT_PRIEST "Priest" +#define GOSSIP_TEXT_ROGUE "Rogue" +#define GOSSIP_TEXT_WARRIOR "Warrior" +#define GOSSIP_TEXT_PALADIN "Paladin" +#define GOSSIP_TEXT_SHAMAN "Shaman" +#define GOSSIP_TEXT_MAGE "Mage" +#define GOSSIP_TEXT_WARLOCK "Warlock" + +#define GOSSIP_TEXT_ALCHEMY "Alchemy" +#define GOSSIP_TEXT_BLACKSMITHING "Blacksmithing" +#define GOSSIP_TEXT_COOKING "Cooking" +#define GOSSIP_TEXT_ENCHANTING "Enchanting" +#define GOSSIP_TEXT_ENGINEERING "Engineering" +#define GOSSIP_TEXT_FIRSTAID "First Aid" +#define GOSSIP_TEXT_HERBALISM "Herbalism" +#define GOSSIP_TEXT_LEATHERWORKING "Leatherworking" +#define GOSSIP_TEXT_POISONS "Poisons" +#define GOSSIP_TEXT_TAILORING "Tailoring" +#define GOSSIP_TEXT_MINING "Mining" +#define GOSSIP_TEXT_FISHING "Fishing" +#define GOSSIP_TEXT_SKINNING "Skinning" +#define GOSSIP_TEXT_JEWELCRAFTING "Jewelcrafting" + +#define GOSSIP_TEXT_IRONFORGE_BANK "Bank of Ironforge" +#define GOSSIP_TEXT_STORMWIND_BANK "Bank of Stormwind" +#define GOSSIP_TEXT_DEEPRUNTRAM "Deeprun Tram" +#define GOSSIP_TEXT_ZEPPLINMASTER "Zeppelin master" +#define GOSSIP_TEXT_FERRY "Rut'theran Ferry" + +// Skill defines + +#define TRADESKILL_ALCHEMY 1 +#define TRADESKILL_BLACKSMITHING 2 +#define TRADESKILL_COOKING 3 +#define TRADESKILL_ENCHANTING 4 +#define TRADESKILL_ENGINEERING 5 +#define TRADESKILL_FIRSTAID 6 +#define TRADESKILL_HERBALISM 7 +#define TRADESKILL_LEATHERWORKING 8 +#define TRADESKILL_POISONS 9 +#define TRADESKILL_TAILORING 10 +#define TRADESKILL_MINING 11 +#define TRADESKILL_FISHING 12 +#define TRADESKILL_SKINNING 13 +#define TRADESKILL_JEWLCRAFTING 14 + +#define TRADESKILL_LEVEL_NONE 0 +#define TRADESKILL_LEVEL_APPRENTICE 1 +#define TRADESKILL_LEVEL_JOURNEYMAN 2 +#define TRADESKILL_LEVEL_EXPERT 3 +#define TRADESKILL_LEVEL_ARTISAN 4 +#define TRADESKILL_LEVEL_MASTER 5 + +// Gossip defines + +#define GOSSIP_ACTION_TRADE 1 +#define GOSSIP_ACTION_TRAIN 2 +#define GOSSIP_ACTION_TAXI 3 +#define GOSSIP_ACTION_GUILD 4 +#define GOSSIP_ACTION_BATTLE 5 +#define GOSSIP_ACTION_BANK 6 +#define GOSSIP_ACTION_INN 7 +#define GOSSIP_ACTION_HEAL 8 +#define GOSSIP_ACTION_TABARD 9 +#define GOSSIP_ACTION_AUCTION 10 +#define GOSSIP_ACTION_INN_INFO 11 +#define GOSSIP_ACTION_UNLEARN 12 +#define GOSSIP_ACTION_INFO_DEF 1000 + +#define GOSSIP_SENDER_MAIN 1 +#define GOSSIP_SENDER_INN_INFO 2 +#define GOSSIP_SENDER_INFO 3 +#define GOSSIP_SENDER_SEC_PROFTRAIN 4 +#define GOSSIP_SENDER_SEC_CLASSTRAIN 5 +#define GOSSIP_SENDER_SEC_BATTLEINFO 6 +#define GOSSIP_SENDER_SEC_BANK 7 +#define GOSSIP_SENDER_SEC_INN 8 +#define GOSSIP_SENDER_SEC_MAILBOX 9 +#define GOSSIP_SENDER_SEC_STABLEMASTER 10 + +#define DEFAULT_GOSSIP_MESSAGE 0xffffff + +extern uint32 GetSkillLevel(Player *player,uint32 skill); + +// Defined fuctions to use with player. + +// This fuction add's a menu item, +// a - Icon Id +// b - Text +// c - Sender(this is to identify the current Menu with this item) +// d - Action (identifys this Menu Item) +// e - Text to be displayed in pop up box +// f - Money value in pop up box +#define ADD_GOSSIP_ITEM(a,b,c,d) PlayerTalkClass->GetGossipMenu().AddMenuItem(a,b,c,d,"",0) +#define ADD_GOSSIP_ITEM_EXTENDED(a,b,c,d,e,f,g) PlayerTalkClass->GetGossipMenu().AddMenuItem(a,b,c,d,e,f,g) + +// This fuction Sends the current menu to show to client, a - NPCTEXTID(uint32) , b - npc guid(uint64) +#define SEND_GOSSIP_MENU(a,b) PlayerTalkClass->SendGossipMenu(a,b) + +// This fuction shows POI(point of interest) to client. +// a - position X +// b - position Y +// c - Icon Id +// d - Flags +// e - Data +// f - Location Name +#define SEND_POI(a,b,c,d,e,f) PlayerTalkClass->SendPointOfInterest(a,b,c,d,e,f) + +// Closes the Menu +#define CLOSE_GOSSIP_MENU() PlayerTalkClass->CloseGossip() + +// Fuction to tell to client the details +// a - quest object +// b - npc guid(uint64) +// c - Activate accept(bool) +#define SEND_QUEST_DETAILS(a,b,c) PlayerTalkClass->SendQuestDetails(a,b,c) + +// Fuction to tell to client the requested items to complete quest +// a - quest object +// b - npc guid(uint64) +// c - Iscompletable(bool) +// d - close at cancel(bool) - in case single incomplite ques +#define SEND_REQUESTEDITEMS(a,b,c,d) PlayerTalkClass->SendRequestedItems(a,b,c,d) + +// Fuctions to send NPC lists, a - is always the npc guid(uint64) +#define SEND_VENDORLIST(a) GetSession()->SendListInventory(a) +#define SEND_TRAINERLIST(a) GetSession()->SendTrainerList(a) +#define SEND_BANKERLIST(a) GetSession()->SendShowBank(a) +#define SEND_TABARDLIST(a) GetSession()->SendTabardVendorActivate(a) +#define SEND_AUCTIONLIST(a) GetSession()->SendAuctionHello(a) +#define SEND_TAXILIST(a) GetSession()->SendTaxiStatus(a) + +// Ressurect's the player if is dead. +#define SEND_SPRESURRECT() GetSession()->SendSpiritResurrect() + +// Get the player's honor rank. +#define GET_HONORRANK() GetHonorRank() +// ----------------------------------- + +// defined fuctions to use with Creature + +#define QUEST_DIALOG_STATUS(a,b,c) GetSession()->getDialogStatus(a,b,c) +#endif diff --git a/src/bindings/scripts/scripts/areatrigger/areatrigger_scripts.cpp b/src/bindings/scripts/scripts/areatrigger/areatrigger_scripts.cpp index c62d7c33bed..28ad1eafdbe 100644 --- a/src/bindings/scripts/scripts/areatrigger/areatrigger_scripts.cpp +++ b/src/bindings/scripts/scripts/areatrigger/areatrigger_scripts.cpp @@ -1,44 +1,44 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Areatrigger_Scripts -SD%Complete: 100 -SDComment: Scripts for areatriggers -SDCategory: Areatrigger -EndScriptData */ - -/* ContentData -at_test script test only -EndContentData */ - -#include "precompiled.h" - -bool ATtest(Player *player, AreaTriggerEntry *at) -{ - player->Say("Hi!",LANG_UNIVERSAL); - return true; -} - -void AddSC_areatrigger_scripts() -{ - Script *newscript; - - newscript = new Script; - newscript->Name="at_test"; - newscript->pAreaTrigger = ATtest; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Areatrigger_Scripts +SD%Complete: 100 +SDComment: Scripts for areatriggers +SDCategory: Areatrigger +EndScriptData */ + +/* ContentData +at_test script test only +EndContentData */ + +#include "precompiled.h" + +bool ATtest(Player *player, AreaTriggerEntry *at) +{ + player->Say("Hi!",LANG_UNIVERSAL); + return true; +} + +void AddSC_areatrigger_scripts() +{ + Script *newscript; + + newscript = new Script; + newscript->Name="at_test"; + newscript->pAreaTrigger = ATtest; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/boss/boss_emeriss.cpp b/src/bindings/scripts/scripts/boss/boss_emeriss.cpp index 0870be567c5..14686f02a6e 100644 --- a/src/bindings/scripts/scripts/boss/boss_emeriss.cpp +++ b/src/bindings/scripts/scripts/boss/boss_emeriss.cpp @@ -1,156 +1,156 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Emeriss -SD%Complete: 90 -SDComment: Teleport function & Mark of Nature missing -SDCategory: Bosses -EndScriptData */ - -#include "precompiled.h" - -#define SPELL_SLEEP 24777 -#define SPELL_NOXIOUSBREATH 24818 -#define SPELL_TAILSWEEP 15847 -//#define SPELL_MARKOFNATURE 25040 // Not working -#define SPELL_VOLATILEINFECTION 24928 -#define SPELL_CORRUPTIONOFEARTH 24910 - -struct MANGOS_DLL_DECL boss_emerissAI : public ScriptedAI -{ - boss_emerissAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 Sleep_Timer; - uint32 NoxiousBreath_Timer; - uint32 TailSweep_Timer; - //uint32 MarkOfNature_Timer; - uint32 VolatileInfection_Timer; - uint32 CorruptionofEarth1_Timer; - uint32 CorruptionofEarth2_Timer; - uint32 CorruptionofEarth3_Timer; - - void Reset() - { - Sleep_Timer = 15000 + rand()%5000; - NoxiousBreath_Timer = 8000; - TailSweep_Timer = 4000; - //MarkOfNature_Timer = 45000; - VolatileInfection_Timer = 12000; - CorruptionofEarth1_Timer = 0; - CorruptionofEarth2_Timer = 0; - CorruptionofEarth3_Timer = 0; - } - - void Aggro(Unit *who) {} - - void UpdateAI(const uint32 diff) - { - //Return since we have no target - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - //Sleep_Timer - if (Sleep_Timer < diff) - { - if( Unit *target = SelectUnit(SELECT_TARGET_RANDOM,0) ) - DoCast(target,SPELL_SLEEP); - - Sleep_Timer = 8000 + rand()%8000; - }else Sleep_Timer -= diff; - - //NoxiousBreath_Timer - if (NoxiousBreath_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_NOXIOUSBREATH); - NoxiousBreath_Timer = 14000 + rand()%6000; - }else NoxiousBreath_Timer -= diff; - - //Tailsweep every 2 seconds - if (TailSweep_Timer < diff) - { - if( Unit *target = SelectUnit(SELECT_TARGET_RANDOM,0) ) - DoCast(target,SPELL_TAILSWEEP); - - TailSweep_Timer = 2000; - }else TailSweep_Timer -= diff; - - //MarkOfNature_Timer - //if (MarkOfNature_Timer < diff) - //{ - // DoCast(m_creature->getVictim(),SPELL_MARKOFNATURE); - // MarkOfNature_Timer = 45000; - //}else MarkOfNature_Timer -= diff; - - //VolatileInfection_Timer - if (VolatileInfection_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_VOLATILEINFECTION); - VolatileInfection_Timer = 7000 + rand()%5000; - }else VolatileInfection_Timer -= diff; - - //CorruptionofEarth_Timer - if ( (int) (m_creature->GetHealth()*100 / m_creature->GetMaxHealth() +0.5) == 75) - { - if (CorruptionofEarth1_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_CORRUPTIONOFEARTH); - - //1 minutes for next one. Means not again with this health value - CorruptionofEarth1_Timer = 60000; - } else CorruptionofEarth1_Timer -= diff; - } - - //CorruptionofEarth_Timer - if ( (int) (m_creature->GetHealth()*100 / m_creature->GetMaxHealth() +0.5) == 50) - { - if (CorruptionofEarth2_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_CORRUPTIONOFEARTH); - - //1 minutes for next one. Means not again with this health value - CorruptionofEarth2_Timer = 60000; - } else CorruptionofEarth2_Timer -= diff; - } - - //CorruptionofEarth_Timer - if ( (int) (m_creature->GetHealth()*100 / m_creature->GetMaxHealth() +0.5) == 25) - { - if (CorruptionofEarth3_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_CORRUPTIONOFEARTH); - - //1 minutes for next one. Means not again with this health value - CorruptionofEarth3_Timer = 60000; - } else CorruptionofEarth3_Timer -= diff; - } - - DoMeleeAttackIfReady(); - } -}; -CreatureAI* GetAI_boss_emeriss(Creature *_Creature) -{ - return new boss_emerissAI (_Creature); -} - -void AddSC_boss_emeriss() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_emeriss"; - newscript->GetAI = GetAI_boss_emeriss; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Emeriss +SD%Complete: 90 +SDComment: Teleport function & Mark of Nature missing +SDCategory: Bosses +EndScriptData */ + +#include "precompiled.h" + +#define SPELL_SLEEP 24777 +#define SPELL_NOXIOUSBREATH 24818 +#define SPELL_TAILSWEEP 15847 +//#define SPELL_MARKOFNATURE 25040 // Not working +#define SPELL_VOLATILEINFECTION 24928 +#define SPELL_CORRUPTIONOFEARTH 24910 + +struct MANGOS_DLL_DECL boss_emerissAI : public ScriptedAI +{ + boss_emerissAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 Sleep_Timer; + uint32 NoxiousBreath_Timer; + uint32 TailSweep_Timer; + //uint32 MarkOfNature_Timer; + uint32 VolatileInfection_Timer; + uint32 CorruptionofEarth1_Timer; + uint32 CorruptionofEarth2_Timer; + uint32 CorruptionofEarth3_Timer; + + void Reset() + { + Sleep_Timer = 15000 + rand()%5000; + NoxiousBreath_Timer = 8000; + TailSweep_Timer = 4000; + //MarkOfNature_Timer = 45000; + VolatileInfection_Timer = 12000; + CorruptionofEarth1_Timer = 0; + CorruptionofEarth2_Timer = 0; + CorruptionofEarth3_Timer = 0; + } + + void Aggro(Unit *who) {} + + void UpdateAI(const uint32 diff) + { + //Return since we have no target + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + //Sleep_Timer + if (Sleep_Timer < diff) + { + if( Unit *target = SelectUnit(SELECT_TARGET_RANDOM,0) ) + DoCast(target,SPELL_SLEEP); + + Sleep_Timer = 8000 + rand()%8000; + }else Sleep_Timer -= diff; + + //NoxiousBreath_Timer + if (NoxiousBreath_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_NOXIOUSBREATH); + NoxiousBreath_Timer = 14000 + rand()%6000; + }else NoxiousBreath_Timer -= diff; + + //Tailsweep every 2 seconds + if (TailSweep_Timer < diff) + { + if( Unit *target = SelectUnit(SELECT_TARGET_RANDOM,0) ) + DoCast(target,SPELL_TAILSWEEP); + + TailSweep_Timer = 2000; + }else TailSweep_Timer -= diff; + + //MarkOfNature_Timer + //if (MarkOfNature_Timer < diff) + //{ + // DoCast(m_creature->getVictim(),SPELL_MARKOFNATURE); + // MarkOfNature_Timer = 45000; + //}else MarkOfNature_Timer -= diff; + + //VolatileInfection_Timer + if (VolatileInfection_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_VOLATILEINFECTION); + VolatileInfection_Timer = 7000 + rand()%5000; + }else VolatileInfection_Timer -= diff; + + //CorruptionofEarth_Timer + if ( (int) (m_creature->GetHealth()*100 / m_creature->GetMaxHealth() +0.5) == 75) + { + if (CorruptionofEarth1_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_CORRUPTIONOFEARTH); + + //1 minutes for next one. Means not again with this health value + CorruptionofEarth1_Timer = 60000; + } else CorruptionofEarth1_Timer -= diff; + } + + //CorruptionofEarth_Timer + if ( (int) (m_creature->GetHealth()*100 / m_creature->GetMaxHealth() +0.5) == 50) + { + if (CorruptionofEarth2_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_CORRUPTIONOFEARTH); + + //1 minutes for next one. Means not again with this health value + CorruptionofEarth2_Timer = 60000; + } else CorruptionofEarth2_Timer -= diff; + } + + //CorruptionofEarth_Timer + if ( (int) (m_creature->GetHealth()*100 / m_creature->GetMaxHealth() +0.5) == 25) + { + if (CorruptionofEarth3_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_CORRUPTIONOFEARTH); + + //1 minutes for next one. Means not again with this health value + CorruptionofEarth3_Timer = 60000; + } else CorruptionofEarth3_Timer -= diff; + } + + DoMeleeAttackIfReady(); + } +}; +CreatureAI* GetAI_boss_emeriss(Creature *_Creature) +{ + return new boss_emerissAI (_Creature); +} + +void AddSC_boss_emeriss() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_emeriss"; + newscript->GetAI = GetAI_boss_emeriss; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/boss/boss_lethon.cpp b/src/bindings/scripts/scripts/boss/boss_lethon.cpp index 66822e5a920..c921eac1e97 100644 --- a/src/bindings/scripts/scripts/boss/boss_lethon.cpp +++ b/src/bindings/scripts/scripts/boss/boss_lethon.cpp @@ -1,24 +1,24 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Lethon -SD%Complete: 0 -SDComment: Place Holder -SDCategory: Bosses -EndScriptData */ - -#include "precompiled.h" +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Lethon +SD%Complete: 0 +SDComment: Place Holder +SDCategory: Bosses +EndScriptData */ + +#include "precompiled.h" diff --git a/src/bindings/scripts/scripts/boss/boss_taerar.cpp b/src/bindings/scripts/scripts/boss/boss_taerar.cpp index 8c7f8471880..8bff4300a43 100644 --- a/src/bindings/scripts/scripts/boss/boss_taerar.cpp +++ b/src/bindings/scripts/scripts/boss/boss_taerar.cpp @@ -1,306 +1,306 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Taerar -SD%Complete: 90 -SDComment: Mark of Nature & Teleport NYI -SDCategory: Bosses -EndScriptData */ - -#include "precompiled.h" - -//Spells of Taerar - -#define SPELL_SLEEP 24777 -#define SPELL_NOXIOUSBREATH 24818 -#define SPELL_TAILSWEEP 15847 -//#define SPELL_MARKOFNATURE 25040 // Not working -#define SPELL_ARCANEBLAST 24857 -#define SPELL_BELLOWINGROAR 22686 -#define SPELL_SUMMONSHADE 24843 - -//Spells of Shades of Taerar - -#define SPELL_POSIONCLOUD 24840 -#define SPELL_POSIONBREATH 20667 - -struct MANGOS_DLL_DECL boss_taerarAI : public ScriptedAI -{ - boss_taerarAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 Sleep_Timer; - uint32 NoxiousBreath_Timer; - uint32 TailSweep_Timer; - //uint32 MarkOfNature_Timer; - uint32 ArcaneBlast_Timer; - uint32 BellowingRoar_Timer; - uint32 Shades_Timer; - uint32 Summon1_Timer; - uint32 Summon2_Timer; - uint32 Summon3_Timer; - int Rand; - int RandX; - int RandY; - Creature* Summoned; - bool Shades; - - void Reset() - { - Sleep_Timer = 15000 + rand()%5000; - NoxiousBreath_Timer = 8000; - TailSweep_Timer = 4000; - //MarkOfNature_Timer = 45000; - ArcaneBlast_Timer = 12000; - BellowingRoar_Timer = 30000; - Summon1_Timer = 0; - Summon2_Timer = 0; - Summon3_Timer = 0; - Shades_Timer = 60000; //The time that Taerar is banished - Shades = false; - } - - void Aggro(Unit *who) - { - } - - void SummonShades(Unit* victim) - { - Rand = rand()%15; - switch (rand()%2) - { - case 0: RandX = 0 - Rand; break; - case 1: RandX = 0 + Rand; break; - } - Rand = 0; - Rand = rand()%15; - switch (rand()%2) - { - case 0: RandY = 0 - Rand; break; - case 1: RandY = 0 + Rand; break; - } - Rand = 0; - Summoned = DoSpawnCreature(15302, RandX, RandY, 0, 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 300000); - if(Summoned) - ((CreatureAI*)Summoned->AI())->AttackStart(victim); - } - - void UpdateAI(const uint32 diff) - { - if (Shades && Shades_Timer < diff) - { - //Become unbanished again - m_creature->setFaction(14); - m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - //m_creature->m_canMove = true; - Shades = false; - } else if (Shades) - { - Shades_Timer -= diff; - //Do nothing while banished - return; - } - - //Return since we have no target - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - //Sleep_Timer - if (Sleep_Timer < diff) - { - Unit* target = NULL; - target = SelectUnit(SELECT_TARGET_RANDOM,0); - if (target) DoCast(target,SPELL_SLEEP); - - Sleep_Timer = 8000 + rand()%7000; - }else Sleep_Timer -= diff; - - //NoxiousBreath_Timer - if (NoxiousBreath_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_NOXIOUSBREATH); - NoxiousBreath_Timer = 14000 + rand()%6000; - } else NoxiousBreath_Timer -= diff; - - //Tailsweep every 2 seconds - if (TailSweep_Timer < diff) - { - if( Unit *target = SelectUnit(SELECT_TARGET_RANDOM,0) ) - DoCast(target,SPELL_TAILSWEEP); - - TailSweep_Timer = 2000; - }else TailSweep_Timer -= diff; - - //MarkOfNature_Timer - //if (MarkOfNature_Timer < diff) - //{ - // DoCast(m_creature->getVictim(),SPELL_MARKOFNATURE); - // MarkOfNature_Timer = 45000; - //}else MarkOfNature_Timer -= diff; - - //ArcaneBlast_Timer - if (ArcaneBlast_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_ARCANEBLAST); - ArcaneBlast_Timer = 7000 + rand()%5000; - }else ArcaneBlast_Timer -= diff; - - //BellowingRoar_Timer - if (BellowingRoar_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_BELLOWINGROAR); - BellowingRoar_Timer = 20000 + rand()%10000; - } else BellowingRoar_Timer -= diff; - - //Summon 3 Shades - if ( !Shades && (int) (m_creature->GetHealth()*100 / m_creature->GetMaxHealth() +0.5) == 75) - { - if (Summon1_Timer < diff) - { - //Inturrupt any spell casting - m_creature->InterruptNonMeleeSpells(false); - m_creature->setFaction(35); - m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - //m_creature->m_canMove = false; - - //Cast - Unit* target = NULL; - target = SelectUnit(SELECT_TARGET_RANDOM,0); - SummonShades(target); - SummonShades(target); - SummonShades(target); - Summon1_Timer = 120000; - Shades = true; - Shades_Timer = 60000; - } else Summon1_Timer -= diff; - } - - //Summon 3 Shades - if ( !Shades && (int) (m_creature->GetHealth()*100 / m_creature->GetMaxHealth() +0.5) == 50) - { - if (Summon2_Timer < diff) - { - //Inturrupt any spell casting - m_creature->InterruptNonMeleeSpells(false); - m_creature->setFaction(35); - m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - //m_creature->m_canMove = false; - - //Cast - Unit* target = NULL; - target = SelectUnit(SELECT_TARGET_RANDOM,0); - SummonShades(target); - SummonShades(target); - SummonShades(target); - Summon2_Timer = 120000; - Shades = true; - Shades_Timer = 60000; - } else Summon2_Timer -= diff; - } - - //Summon 3 Shades - if ( !Shades && (int) (m_creature->GetHealth()*100 / m_creature->GetMaxHealth() +0.5) == 25) - { - if (Summon3_Timer < diff) - { - //Inturrupt any spell casting - m_creature->InterruptNonMeleeSpells(false); - m_creature->setFaction(35); - m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - //m_creature->m_canMove = false; - - //Cast - Unit* target = NULL; - target = SelectUnit(SELECT_TARGET_RANDOM,0); - SummonShades(target); - SummonShades(target); - SummonShades(target); - Summon3_Timer = 120000; - Shades = true; - Shades_Timer = 60000; - } else Summon3_Timer -= diff; - } - - DoMeleeAttackIfReady(); - } -}; - -// Shades of Taerar Script - -struct MANGOS_DLL_DECL boss_shadeoftaerarAI : public ScriptedAI -{ - boss_shadeoftaerarAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 PoisonCloud_Timer; - uint32 PosionBreath_Timer; - - void Reset() - { - PoisonCloud_Timer = 8000; - PosionBreath_Timer = 12000; - } - - void Aggro(Unit *who) - { - } - - void UpdateAI(const uint32 diff) - { - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - //PoisonCloud_Timer - if (PoisonCloud_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_POSIONCLOUD); - PoisonCloud_Timer = 30000; - }else PoisonCloud_Timer -= diff; - - //PosionBreath_Timer - if (PosionBreath_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_POSIONBREATH); - PosionBreath_Timer = 12000; - }else PosionBreath_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; - -CreatureAI* GetAI_boss_taerar(Creature *_Creature) -{ - return new boss_taerarAI (_Creature); -} - -CreatureAI* GetAI_boss_shadeoftaerar(Creature *_Creature) -{ - return new boss_shadeoftaerarAI (_Creature); -} - -void AddSC_boss_taerar() -{ - Script *newscript; - - newscript = new Script; - newscript->Name="boss_taerar"; - newscript->GetAI = GetAI_boss_taerar; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="boss_shade_of_taerar"; - newscript->GetAI = GetAI_boss_shadeoftaerar; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Taerar +SD%Complete: 90 +SDComment: Mark of Nature & Teleport NYI +SDCategory: Bosses +EndScriptData */ + +#include "precompiled.h" + +//Spells of Taerar + +#define SPELL_SLEEP 24777 +#define SPELL_NOXIOUSBREATH 24818 +#define SPELL_TAILSWEEP 15847 +//#define SPELL_MARKOFNATURE 25040 // Not working +#define SPELL_ARCANEBLAST 24857 +#define SPELL_BELLOWINGROAR 22686 +#define SPELL_SUMMONSHADE 24843 + +//Spells of Shades of Taerar + +#define SPELL_POSIONCLOUD 24840 +#define SPELL_POSIONBREATH 20667 + +struct MANGOS_DLL_DECL boss_taerarAI : public ScriptedAI +{ + boss_taerarAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 Sleep_Timer; + uint32 NoxiousBreath_Timer; + uint32 TailSweep_Timer; + //uint32 MarkOfNature_Timer; + uint32 ArcaneBlast_Timer; + uint32 BellowingRoar_Timer; + uint32 Shades_Timer; + uint32 Summon1_Timer; + uint32 Summon2_Timer; + uint32 Summon3_Timer; + int Rand; + int RandX; + int RandY; + Creature* Summoned; + bool Shades; + + void Reset() + { + Sleep_Timer = 15000 + rand()%5000; + NoxiousBreath_Timer = 8000; + TailSweep_Timer = 4000; + //MarkOfNature_Timer = 45000; + ArcaneBlast_Timer = 12000; + BellowingRoar_Timer = 30000; + Summon1_Timer = 0; + Summon2_Timer = 0; + Summon3_Timer = 0; + Shades_Timer = 60000; //The time that Taerar is banished + Shades = false; + } + + void Aggro(Unit *who) + { + } + + void SummonShades(Unit* victim) + { + Rand = rand()%15; + switch (rand()%2) + { + case 0: RandX = 0 - Rand; break; + case 1: RandX = 0 + Rand; break; + } + Rand = 0; + Rand = rand()%15; + switch (rand()%2) + { + case 0: RandY = 0 - Rand; break; + case 1: RandY = 0 + Rand; break; + } + Rand = 0; + Summoned = DoSpawnCreature(15302, RandX, RandY, 0, 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 300000); + if(Summoned) + ((CreatureAI*)Summoned->AI())->AttackStart(victim); + } + + void UpdateAI(const uint32 diff) + { + if (Shades && Shades_Timer < diff) + { + //Become unbanished again + m_creature->setFaction(14); + m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + //m_creature->m_canMove = true; + Shades = false; + } else if (Shades) + { + Shades_Timer -= diff; + //Do nothing while banished + return; + } + + //Return since we have no target + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + //Sleep_Timer + if (Sleep_Timer < diff) + { + Unit* target = NULL; + target = SelectUnit(SELECT_TARGET_RANDOM,0); + if (target) DoCast(target,SPELL_SLEEP); + + Sleep_Timer = 8000 + rand()%7000; + }else Sleep_Timer -= diff; + + //NoxiousBreath_Timer + if (NoxiousBreath_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_NOXIOUSBREATH); + NoxiousBreath_Timer = 14000 + rand()%6000; + } else NoxiousBreath_Timer -= diff; + + //Tailsweep every 2 seconds + if (TailSweep_Timer < diff) + { + if( Unit *target = SelectUnit(SELECT_TARGET_RANDOM,0) ) + DoCast(target,SPELL_TAILSWEEP); + + TailSweep_Timer = 2000; + }else TailSweep_Timer -= diff; + + //MarkOfNature_Timer + //if (MarkOfNature_Timer < diff) + //{ + // DoCast(m_creature->getVictim(),SPELL_MARKOFNATURE); + // MarkOfNature_Timer = 45000; + //}else MarkOfNature_Timer -= diff; + + //ArcaneBlast_Timer + if (ArcaneBlast_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_ARCANEBLAST); + ArcaneBlast_Timer = 7000 + rand()%5000; + }else ArcaneBlast_Timer -= diff; + + //BellowingRoar_Timer + if (BellowingRoar_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_BELLOWINGROAR); + BellowingRoar_Timer = 20000 + rand()%10000; + } else BellowingRoar_Timer -= diff; + + //Summon 3 Shades + if ( !Shades && (int) (m_creature->GetHealth()*100 / m_creature->GetMaxHealth() +0.5) == 75) + { + if (Summon1_Timer < diff) + { + //Inturrupt any spell casting + m_creature->InterruptNonMeleeSpells(false); + m_creature->setFaction(35); + m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + //m_creature->m_canMove = false; + + //Cast + Unit* target = NULL; + target = SelectUnit(SELECT_TARGET_RANDOM,0); + SummonShades(target); + SummonShades(target); + SummonShades(target); + Summon1_Timer = 120000; + Shades = true; + Shades_Timer = 60000; + } else Summon1_Timer -= diff; + } + + //Summon 3 Shades + if ( !Shades && (int) (m_creature->GetHealth()*100 / m_creature->GetMaxHealth() +0.5) == 50) + { + if (Summon2_Timer < diff) + { + //Inturrupt any spell casting + m_creature->InterruptNonMeleeSpells(false); + m_creature->setFaction(35); + m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + //m_creature->m_canMove = false; + + //Cast + Unit* target = NULL; + target = SelectUnit(SELECT_TARGET_RANDOM,0); + SummonShades(target); + SummonShades(target); + SummonShades(target); + Summon2_Timer = 120000; + Shades = true; + Shades_Timer = 60000; + } else Summon2_Timer -= diff; + } + + //Summon 3 Shades + if ( !Shades && (int) (m_creature->GetHealth()*100 / m_creature->GetMaxHealth() +0.5) == 25) + { + if (Summon3_Timer < diff) + { + //Inturrupt any spell casting + m_creature->InterruptNonMeleeSpells(false); + m_creature->setFaction(35); + m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + //m_creature->m_canMove = false; + + //Cast + Unit* target = NULL; + target = SelectUnit(SELECT_TARGET_RANDOM,0); + SummonShades(target); + SummonShades(target); + SummonShades(target); + Summon3_Timer = 120000; + Shades = true; + Shades_Timer = 60000; + } else Summon3_Timer -= diff; + } + + DoMeleeAttackIfReady(); + } +}; + +// Shades of Taerar Script + +struct MANGOS_DLL_DECL boss_shadeoftaerarAI : public ScriptedAI +{ + boss_shadeoftaerarAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 PoisonCloud_Timer; + uint32 PosionBreath_Timer; + + void Reset() + { + PoisonCloud_Timer = 8000; + PosionBreath_Timer = 12000; + } + + void Aggro(Unit *who) + { + } + + void UpdateAI(const uint32 diff) + { + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + //PoisonCloud_Timer + if (PoisonCloud_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_POSIONCLOUD); + PoisonCloud_Timer = 30000; + }else PoisonCloud_Timer -= diff; + + //PosionBreath_Timer + if (PosionBreath_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_POSIONBREATH); + PosionBreath_Timer = 12000; + }else PosionBreath_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; + +CreatureAI* GetAI_boss_taerar(Creature *_Creature) +{ + return new boss_taerarAI (_Creature); +} + +CreatureAI* GetAI_boss_shadeoftaerar(Creature *_Creature) +{ + return new boss_shadeoftaerarAI (_Creature); +} + +void AddSC_boss_taerar() +{ + Script *newscript; + + newscript = new Script; + newscript->Name="boss_taerar"; + newscript->GetAI = GetAI_boss_taerar; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="boss_shade_of_taerar"; + newscript->GetAI = GetAI_boss_shadeoftaerar; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/boss/boss_ysondre.cpp b/src/bindings/scripts/scripts/boss/boss_ysondre.cpp index a5348630af2..7a811c3535f 100644 --- a/src/bindings/scripts/scripts/boss/boss_ysondre.cpp +++ b/src/bindings/scripts/scripts/boss/boss_ysondre.cpp @@ -1,246 +1,246 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Ysondre -SD%Complete: 90 -SDComment: Mark of Nature & Teleport missing -SDCategory: Bosses -EndScriptData */ - -#include "precompiled.h" - -#define SPELL_SLEEP 24777 -#define SPELL_NOXIOUSBREATH 24818 -#define SPELL_TAILSWEEP 15847 -//#define SPELL_MARKOFNATURE 25040 // Not working -#define SPELL_LIGHTNINGWAVE 24819 -#define SPELL_SUMMONDRUIDS 24795 - -//druid spells -#define SPELL_MOONFIRE 21669 - -// Ysondre script -struct MANGOS_DLL_DECL boss_ysondreAI : public ScriptedAI -{ - boss_ysondreAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 Sleep_Timer; - uint32 NoxiousBreath_Timer; - uint32 TailSweep_Timer; - //uint32 MarkOfNature_Timer; - uint32 LightningWave_Timer; - uint32 SummonDruids1_Timer; - uint32 SummonDruids2_Timer; - uint32 SummonDruids3_Timer; - int Rand; - int RandX; - int RandY; - Creature* Summoned; - - void Reset() - { - Sleep_Timer = 15000 + rand()%5000; - NoxiousBreath_Timer = 8000; - TailSweep_Timer = 4000; - //MarkOfNature_Timer = 45000; - LightningWave_Timer = 12000; - SummonDruids1_Timer = 0; - SummonDruids2_Timer = 0; - SummonDruids3_Timer = 0; - } - - void Aggro(Unit *who) - { - } - - void SummonDruids(Unit* victim) - { - Rand = rand()%10; - switch (rand()%2) - { - case 0: RandX = 0 - Rand; break; - case 1: RandX = 0 + Rand; break; - } - Rand = 0; - Rand = rand()%10; - switch (rand()%2) - { - case 0: RandY = 0 - Rand; break; - case 1: RandY = 0 + Rand; break; - } - Rand = 0; - Summoned = DoSpawnCreature(15260, RandX, RandY, 0, 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 300000); - if(Summoned) - ((CreatureAI*)Summoned->AI())->AttackStart(victim); - } - - void UpdateAI(const uint32 diff) - { - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - //Sleep_Timer - if (Sleep_Timer < diff) - { - if( Unit *target = SelectUnit(SELECT_TARGET_RANDOM,0) ) - DoCast(target,SPELL_SLEEP); - - Sleep_Timer = 8000 + rand()%7000; - }else Sleep_Timer -= diff; - - //NoxiousBreath_Timer - if (NoxiousBreath_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_NOXIOUSBREATH); - NoxiousBreath_Timer = 14000 + rand()%6000; - }else NoxiousBreath_Timer -= diff; - - //Tailsweep every 2 seconds - if (TailSweep_Timer < diff) - { - if( Unit *target = SelectUnit(SELECT_TARGET_RANDOM,0) ) - DoCast(target,SPELL_TAILSWEEP); - - TailSweep_Timer = 2000; - }else TailSweep_Timer -= diff; - - //MarkOfNature_Timer - //if (MarkOfNature_Timer < diff) - //{ - // DoCast(m_creature->getVictim(),SPELL_MARKOFNATURE); - // MarkOfNature_Timer = 45000; - //}else MarkOfNature_Timer -= diff; - - //LightningWave_Timer - if (LightningWave_Timer < diff) - { - //Cast LIGHTNINGWAVE on a Random target - if( Unit *target = SelectUnit(SELECT_TARGET_RANDOM,0) ) - DoCast(target,SPELL_LIGHTNINGWAVE); - - LightningWave_Timer = 7000 + rand()%5000; - }else LightningWave_Timer -= diff; - - //Summon Druids - if ( (int) (m_creature->GetHealth()*100 / m_creature->GetMaxHealth() +0.5) == 75) - { - if (SummonDruids1_Timer < diff) - { - // summon 10 druids - Unit* target = NULL; - for(int i = 0; i < 10;i++) - { - target = SelectUnit(SELECT_TARGET_RANDOM,0); - SummonDruids(target); - } - - SummonDruids1_Timer = 60000; - } else SummonDruids1_Timer -= diff; - } - - //Summon Druids - if ( (int) (m_creature->GetHealth()*100 / m_creature->GetMaxHealth() +0.5) == 50) - { - if (SummonDruids2_Timer < diff) - { - // summon 10 druids - Unit* target = NULL; - for(int i = 0; i < 10;i++) - { - target = SelectUnit(SELECT_TARGET_RANDOM,0); - SummonDruids(target); - } - - SummonDruids2_Timer = 60000; - } else SummonDruids2_Timer -= diff; - } - - //Summon Druids - if ( (int) (m_creature->GetHealth()*100 / m_creature->GetMaxHealth() +0.5) == 25) - { - if (SummonDruids3_Timer < diff) - { - // summon 10 druids - Unit* target = NULL; - for(int i = 0; i < 10;i++) - { - target = SelectUnit(SELECT_TARGET_RANDOM,0); - SummonDruids(target); - } - - SummonDruids3_Timer = 60000; - } else SummonDruids3_Timer -= diff; - } - DoMeleeAttackIfReady(); - } -}; -// Summoned druid script -struct MANGOS_DLL_DECL mob_dementeddruidsAI : public ScriptedAI -{ - mob_dementeddruidsAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 MoonFire_Timer; - - void Reset() - { - MoonFire_Timer = 3000; - } - - void Aggro(Unit *who) - { - } - - void UpdateAI(const uint32 diff) - { - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - //MoonFire_Timer - if (MoonFire_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_MOONFIRE); - MoonFire_Timer = 5000; - }else MoonFire_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; - -CreatureAI* GetAI_boss_ysondre(Creature *_Creature) -{ - return new boss_ysondreAI (_Creature); -} - -CreatureAI* GetAI_mob_dementeddruids(Creature *_Creature) -{ - return new mob_dementeddruidsAI (_Creature); -} - -void AddSC_boss_ysondre() -{ - Script *newscript; - - newscript = new Script; - newscript->Name="boss_ysondre"; - newscript->GetAI = GetAI_boss_ysondre; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="mob_dementeddruids"; - newscript->GetAI = GetAI_mob_dementeddruids; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Ysondre +SD%Complete: 90 +SDComment: Mark of Nature & Teleport missing +SDCategory: Bosses +EndScriptData */ + +#include "precompiled.h" + +#define SPELL_SLEEP 24777 +#define SPELL_NOXIOUSBREATH 24818 +#define SPELL_TAILSWEEP 15847 +//#define SPELL_MARKOFNATURE 25040 // Not working +#define SPELL_LIGHTNINGWAVE 24819 +#define SPELL_SUMMONDRUIDS 24795 + +//druid spells +#define SPELL_MOONFIRE 21669 + +// Ysondre script +struct MANGOS_DLL_DECL boss_ysondreAI : public ScriptedAI +{ + boss_ysondreAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 Sleep_Timer; + uint32 NoxiousBreath_Timer; + uint32 TailSweep_Timer; + //uint32 MarkOfNature_Timer; + uint32 LightningWave_Timer; + uint32 SummonDruids1_Timer; + uint32 SummonDruids2_Timer; + uint32 SummonDruids3_Timer; + int Rand; + int RandX; + int RandY; + Creature* Summoned; + + void Reset() + { + Sleep_Timer = 15000 + rand()%5000; + NoxiousBreath_Timer = 8000; + TailSweep_Timer = 4000; + //MarkOfNature_Timer = 45000; + LightningWave_Timer = 12000; + SummonDruids1_Timer = 0; + SummonDruids2_Timer = 0; + SummonDruids3_Timer = 0; + } + + void Aggro(Unit *who) + { + } + + void SummonDruids(Unit* victim) + { + Rand = rand()%10; + switch (rand()%2) + { + case 0: RandX = 0 - Rand; break; + case 1: RandX = 0 + Rand; break; + } + Rand = 0; + Rand = rand()%10; + switch (rand()%2) + { + case 0: RandY = 0 - Rand; break; + case 1: RandY = 0 + Rand; break; + } + Rand = 0; + Summoned = DoSpawnCreature(15260, RandX, RandY, 0, 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 300000); + if(Summoned) + ((CreatureAI*)Summoned->AI())->AttackStart(victim); + } + + void UpdateAI(const uint32 diff) + { + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + //Sleep_Timer + if (Sleep_Timer < diff) + { + if( Unit *target = SelectUnit(SELECT_TARGET_RANDOM,0) ) + DoCast(target,SPELL_SLEEP); + + Sleep_Timer = 8000 + rand()%7000; + }else Sleep_Timer -= diff; + + //NoxiousBreath_Timer + if (NoxiousBreath_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_NOXIOUSBREATH); + NoxiousBreath_Timer = 14000 + rand()%6000; + }else NoxiousBreath_Timer -= diff; + + //Tailsweep every 2 seconds + if (TailSweep_Timer < diff) + { + if( Unit *target = SelectUnit(SELECT_TARGET_RANDOM,0) ) + DoCast(target,SPELL_TAILSWEEP); + + TailSweep_Timer = 2000; + }else TailSweep_Timer -= diff; + + //MarkOfNature_Timer + //if (MarkOfNature_Timer < diff) + //{ + // DoCast(m_creature->getVictim(),SPELL_MARKOFNATURE); + // MarkOfNature_Timer = 45000; + //}else MarkOfNature_Timer -= diff; + + //LightningWave_Timer + if (LightningWave_Timer < diff) + { + //Cast LIGHTNINGWAVE on a Random target + if( Unit *target = SelectUnit(SELECT_TARGET_RANDOM,0) ) + DoCast(target,SPELL_LIGHTNINGWAVE); + + LightningWave_Timer = 7000 + rand()%5000; + }else LightningWave_Timer -= diff; + + //Summon Druids + if ( (int) (m_creature->GetHealth()*100 / m_creature->GetMaxHealth() +0.5) == 75) + { + if (SummonDruids1_Timer < diff) + { + // summon 10 druids + Unit* target = NULL; + for(int i = 0; i < 10;i++) + { + target = SelectUnit(SELECT_TARGET_RANDOM,0); + SummonDruids(target); + } + + SummonDruids1_Timer = 60000; + } else SummonDruids1_Timer -= diff; + } + + //Summon Druids + if ( (int) (m_creature->GetHealth()*100 / m_creature->GetMaxHealth() +0.5) == 50) + { + if (SummonDruids2_Timer < diff) + { + // summon 10 druids + Unit* target = NULL; + for(int i = 0; i < 10;i++) + { + target = SelectUnit(SELECT_TARGET_RANDOM,0); + SummonDruids(target); + } + + SummonDruids2_Timer = 60000; + } else SummonDruids2_Timer -= diff; + } + + //Summon Druids + if ( (int) (m_creature->GetHealth()*100 / m_creature->GetMaxHealth() +0.5) == 25) + { + if (SummonDruids3_Timer < diff) + { + // summon 10 druids + Unit* target = NULL; + for(int i = 0; i < 10;i++) + { + target = SelectUnit(SELECT_TARGET_RANDOM,0); + SummonDruids(target); + } + + SummonDruids3_Timer = 60000; + } else SummonDruids3_Timer -= diff; + } + DoMeleeAttackIfReady(); + } +}; +// Summoned druid script +struct MANGOS_DLL_DECL mob_dementeddruidsAI : public ScriptedAI +{ + mob_dementeddruidsAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 MoonFire_Timer; + + void Reset() + { + MoonFire_Timer = 3000; + } + + void Aggro(Unit *who) + { + } + + void UpdateAI(const uint32 diff) + { + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + //MoonFire_Timer + if (MoonFire_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_MOONFIRE); + MoonFire_Timer = 5000; + }else MoonFire_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; + +CreatureAI* GetAI_boss_ysondre(Creature *_Creature) +{ + return new boss_ysondreAI (_Creature); +} + +CreatureAI* GetAI_mob_dementeddruids(Creature *_Creature) +{ + return new mob_dementeddruidsAI (_Creature); +} + +void AddSC_boss_ysondre() +{ + Script *newscript; + + newscript = new Script; + newscript->Name="boss_ysondre"; + newscript->GetAI = GetAI_boss_ysondre; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="mob_dementeddruids"; + newscript->GetAI = GetAI_mob_dementeddruids; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/creature/mob_event_ai.cpp b/src/bindings/scripts/scripts/creature/mob_event_ai.cpp index f86931df766..4e772ed4b23 100644 --- a/src/bindings/scripts/scripts/creature/mob_event_ai.cpp +++ b/src/bindings/scripts/scripts/creature/mob_event_ai.cpp @@ -1,1389 +1,1361 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Mob_Event_AI -SD%Complete: 90 -SDComment: Database Event AI -SDCategory: Creatures -EndScriptData */ - -#include "precompiled.h" -#include "mob_event_ai.h" - -#define EVENT_UPDATE_TIME 500 -#define SPELL_RUN_AWAY 8225 - -struct EventHolder -{ - EventHolder(EventAI_Event p) : Event(p), Time(0), Enabled(true){} - - EventAI_Event Event; - uint32 Time; - bool Enabled; -}; - -struct MANGOS_DLL_DECL Mob_EventAI : public ScriptedAI -{ - Mob_EventAI(Creature *c, std::list pEventList) : ScriptedAI(c) - { - EventList = pEventList; - Phase = 0; - CombatMovementEnabled = true; - MeleeEnabled = true; - AttackDistance = 0; - AttackAngle = 0.0f; - - //Handle Spawned Events - for (std::list::iterator i = EventList.begin(); i != EventList.end(); ++i) - { - switch ((*i).Event.event_type) - { - case EVENT_T_SPAWNED: - ProcessEvent(*i); - break; - } - } - - Reset(); - } - - ~Mob_EventAI() - { - EventList.clear(); - } - - //Variables used by EventAI for handling events - std::list EventList; //Holder for events (stores enabled, time, and eventid) - uint32 EventUpdateTime; //Time between event updates - uint32 EventDiff; //Time between the last event call - - //Variables used by Events themselves - uint8 Phase; //Current phase, max 32 phases - bool CombatMovementEnabled; //If we allow targeted movment gen (movement twoards top threat) - bool MeleeEnabled; //If we allow melee auto attack - uint32 AttackDistance; //Distance to attack from - float AttackAngle; //Angle of attack - - void AttackTarget(Unit* pTarget, bool Follow) - { - if (!pTarget) - return; - - if ( m_creature->Attack(pTarget, true) ) - { - if (Follow) - { - m_creature->GetMotionMaster()->Clear(false); - m_creature->GetMotionMaster()->MoveChase(pTarget, AttackDistance, AttackAngle); - } - - m_creature->AddThreat(pTarget, 0.0f); - } - } - - bool ProcessEvent(EventHolder& pHolder, Unit* pActionInvoker = NULL) - { - if (!pHolder.Enabled || pHolder.Time) - return false; - - //Check the inverse phase mask (event doesn't trigger if current phase bit is set in mask) - if (pHolder.Event.event_inverse_phase_mask & (1 << Phase)) - return false; - - //Store random here so that all random actions match up - uint32 rnd = rand(); - - //Return if chance for event is not met - if (pHolder.Event.event_chance <= rnd % 100) - return false; - - union - { - uint32 param1; - int32 param1_s; - }; - - union - { - uint32 param2; - int32 param2_s; - }; - - union - { - uint32 param3; - int32 param3_s; - }; - - union - { - uint32 param4; - int32 param4_s; - }; - - param1 = pHolder.Event.event_param1; - param2 = pHolder.Event.event_param2; - param3 = pHolder.Event.event_param3; - param4 = pHolder.Event.event_param4; - - //Check event conditions based on the event type, also reset events - switch (pHolder.Event.event_type) - { - case EVENT_T_TIMER: - { - if (!InCombat) - return false; - - //Repeat Timers - if (param3 == param4) - { - pHolder.Time = param3; - - }else if (param4 > param3) - pHolder.Time = urand(param3, param4); - else - { - if (EAI_ErrorLevel > 0) - error_db_log("SD2: Creature %u using Event %u (Type = %u) has RandomMax < RandomMin. Event repeating disabled.", m_creature->GetEntry(), pHolder.Event.event_id, pHolder.Event.event_type); - pHolder.Enabled = false; - } - } - break; - case EVENT_T_TIMER_OOC: - { - if (InCombat) - return false; - - //Repeat Timers - if (param3 == param4) - { - pHolder.Time = param3; - - }else if (param4 > param3) - pHolder.Time = urand(param3, param4); - else - { - if (EAI_ErrorLevel > 0) - error_db_log("SD2: Creature %u using Event %u (Type = %u) has RandomMax < RandomMin. Event repeating disabled.", m_creature->GetEntry(), pHolder.Event.event_id, pHolder.Event.event_type); - pHolder.Enabled = false; - } - } - break; - case EVENT_T_HP: - { - if (!InCombat || !m_creature->GetMaxHealth()) - return false; - - uint32 perc = (m_creature->GetHealth()*100) / m_creature->GetMaxHealth(); - - if (perc > param1 || perc < param2) - return false; - - //Repeat Timers - if (param3 == param4) - { - pHolder.Time = param3; - - }else if (param4 > param3) - pHolder.Time = urand(param3, param4); - else - { - if (EAI_ErrorLevel > 0) - error_db_log("SD2: Creature %u using Event %u (Type = %u) has RandomMax < RandomMin. Event repeating disabled.", m_creature->GetEntry(), pHolder.Event.event_id, pHolder.Event.event_type); - pHolder.Enabled = false; - } - } - break; - case EVENT_T_MANA: - { - if (!InCombat || !m_creature->GetMaxPower(POWER_MANA)) - return false; - - uint32 perc = (m_creature->GetPower(POWER_MANA)*100) / m_creature->GetMaxPower(POWER_MANA); - - if (perc > param1 || perc < param2) - return false; - - //Repeat Timers - if (param3 == param4) - { - pHolder.Time = param3; - - }else if (param4 > param3) - pHolder.Time = urand(param3, param4); - else - { - if (EAI_ErrorLevel > 0) - error_db_log("SD2: Creature %u using Event %u (Type = %u) has RandomMax < RandomMin. Event repeating disabled.", m_creature->GetEntry(), pHolder.Event.event_id, pHolder.Event.event_type); - pHolder.Enabled = false; - } - } - break; - case EVENT_T_AGGRO: - { - } - break; - case EVENT_T_KILL: - { - //Repeat Timers - if (param1 == param2) - { - pHolder.Time = param1; - - }else if (param2 > param1) - pHolder.Time = urand(param1, param2); - else - { - if (EAI_ErrorLevel > 0) - error_db_log("SD2: Creature %u using Event %u (Type = %u) has RandomMax < RandomMin. Event repeating disabled.", m_creature->GetEntry(), pHolder.Event.event_id, pHolder.Event.event_type); - pHolder.Enabled = false; - } - } - case EVENT_T_DEATH: - { - } - break; - case EVENT_T_EVADE: - { - } - break; - case EVENT_T_SPELLHIT: - { - //Spell hit is special case, param1 and param2 handled within EventAI::SpellHit - - //Repeat Timers - if (param3 == param4) - { - pHolder.Time = param3; - - }else if (param4 > param3) - pHolder.Time = urand(param3, param4); - else - { - if (EAI_ErrorLevel > 0) - error_db_log("SD2: Creature %u using Event %u (Type = %u) has RandomMax < RandomMin. Event repeating disabled.", m_creature->GetEntry(), pHolder.Event.event_id, pHolder.Event.event_type); - pHolder.Enabled = false; - } - } - break; - case EVENT_T_RANGE: - { - //Repeat Timers - if (param3 == param4) - { - pHolder.Time = param3; - - }else if (param4 > param3) - pHolder.Time = urand(param3, param4); - else - { - if (EAI_ErrorLevel > 0) - error_db_log("SD2: Creature %u using Event %u (Type = %u) has RandomMax < RandomMin. Event repeating disabled.", m_creature->GetEntry(), pHolder.Event.event_id, pHolder.Event.event_type); - pHolder.Enabled = false; - } - } - break; - case EVENT_T_OOC_LOS: - { - //Repeat Timers - if (param3 == param4) - { - pHolder.Time = param3; - - }else if (param4 > param3) - pHolder.Time = urand(param3, param4); - else - { - if (EAI_ErrorLevel > 0) - error_db_log("SD2: Creature %u using Event %u (Type = %u) has RandomMax < RandomMin. Event repeating disabled.", m_creature->GetEntry(), pHolder.Event.event_id, pHolder.Event.event_type); - pHolder.Enabled = false; - } - } - break; - case EVENT_T_SPAWNED: - { - } - break; - case EVENT_T_TARGET_HP: - { - if (!InCombat || !m_creature->getVictim() || !m_creature->getVictim()->GetMaxHealth()) - return false; - - uint32 perc = (m_creature->getVictim()->GetHealth()*100) / m_creature->getVictim()->GetMaxHealth(); - - if (perc > param1 || perc < param2) - return false; - - //Repeat Timers - if (param3 == param4) - { - pHolder.Time = param3; - - }else if (param4 > param3) - pHolder.Time = urand(param3, param4); - else - { - if (EAI_ErrorLevel > 0) - error_db_log("SD2: Creature %u using Event %u (Type = %u) has RandomMax < RandomMin. Event repeating disabled.", m_creature->GetEntry(), pHolder.Event.event_id, pHolder.Event.event_type); - pHolder.Enabled = false; - } - } - break; - case EVENT_T_TARGET_CASTING: - { - if (!InCombat || !m_creature->getVictim() || !m_creature->getVictim()->IsNonMeleeSpellCasted(false, false, true)) - return false; - - //Repeat Timers - if (param1 == param2) - { - pHolder.Time = param1; - - }else if (param2 > param1) - pHolder.Time = urand(param1, param2); - else - { - if (EAI_ErrorLevel > 0) - error_db_log("SD2: Creature %u using Event %u (Type = %u) has RandomMax < RandomMin. Event repeating disabled.", m_creature->GetEntry(), pHolder.Event.event_id, pHolder.Event.event_type); - pHolder.Enabled = false; - } - } - break; - case EVENT_T_FRIENDLY_HP: - { - if (!InCombat) - return false; - - Unit* pUnit = DoSelectLowestHpFriendly(param2, param1); - - if (!pUnit) - return false; - - pActionInvoker = pUnit; - - //Repeat Timers - if (param3 == param4) - { - pHolder.Time = param3; - - }else if (param4 > param3) - pHolder.Time = urand(param3, param4); - else - { - if (EAI_ErrorLevel > 0) - error_db_log("SD2: Creature %u using Event %u (Type = %u) has RandomMax < RandomMin. Event repeating disabled.", m_creature->GetEntry(), pHolder.Event.event_id, pHolder.Event.event_type); - pHolder.Enabled = false; - } - } - break; - - case EVENT_T_FRIENDLY_IS_CC: - { - if (!InCombat) - return false; - - std::list pList = DoFindFriendlyCC(param2); - - //List is empty - if (pList.empty()) - return false; - - //We don't really care about the whole list, just return first available - pActionInvoker = *(pList.begin()); - - //Repeat Timers - if (param3 == param4) - { - pHolder.Time = param3; - - }else if (param4 > param3) - pHolder.Time = urand(param3, param4); - else - { - if (EAI_ErrorLevel > 0) - error_db_log("SD2: Creature %u using Event %u (Type = %u) has RandomMax < RandomMin. Event repeating disabled.", m_creature->GetEntry(), pHolder.Event.event_id, pHolder.Event.event_type); - pHolder.Enabled = false; - } - } - break; - - case EVENT_T_FRIENDLY_MISSING_BUFF: - { - std::list pList = DoFindFriendlyMissingBuff(param2, param1); - - //List is empty - if (pList.empty()) - return false; - - //We don't really care about the whole list, just return first available - pActionInvoker = *(pList.begin()); - - //Repeat Timers - if (param3 == param4) - { - pHolder.Time = param3; - - }else if (param4 > param3) - pHolder.Time = urand(param3, param4); - else - { - if (EAI_ErrorLevel > 0) - error_db_log("SD2: Creature %u using Event %u (Type = %u) has RandomMax < RandomMin. Event repeating disabled.", m_creature->GetEntry(), pHolder.Event.event_id, pHolder.Event.event_type); - pHolder.Enabled = false; - } - } - break; - - case EVENT_T_SUMMONED_UNIT: - { - //Prevent event from occuring on no unit or non creatures - if (!pActionInvoker || pActionInvoker->GetTypeId()!=TYPEID_UNIT) - return false; - - //Creature id doesn't match up - if (param1 && ((Creature*)pActionInvoker)->GetEntry() != param1) - return false; - - //Repeat Timers - if (param2 == param3) - { - pHolder.Time = param2; - - }else if (param3 > param2) - pHolder.Time = urand(param2, param3); - else - { - if (EAI_ErrorLevel > 0) - error_db_log("SD2: Creature %u using Event %u (Type = %u) has RandomMax < RandomMin. Event repeating disabled.", m_creature->GetEntry(), pHolder.Event.event_id, pHolder.Event.event_type); - pHolder.Enabled = false; - } - } - break; - default: - if (EAI_ErrorLevel > 0) - error_db_log("SD2: Creature %u using Event %u has invalid Event Type(%u), missing from ProcessEvent() Switch.", m_creature->GetEntry(), pHolder.Event.event_id, pHolder.Event.event_type); - break; - } - - //Disable non-repeatable events - if (!(pHolder.Event.event_flags & EFLAG_REPEATABLE)) - pHolder.Enabled = false; - - //Process actions - for (uint32 j = 0; j < MAX_ACTIONS; j++) - ProcessAction(pHolder.Event.action[j].type, pHolder.Event.action[j].param1, pHolder.Event.action[j].param2, pHolder.Event.action[j].param3, rnd, pHolder.Event.event_id, pActionInvoker); - - return true; - } - - inline uint32 GetRandActionParam(uint32 rnd, uint32 param1, uint32 param2, uint32 param3) - { - switch (rnd % 3) - { - case 0: - return param1; - break; - - case 1: - return param2; - break; - - case 2: - return param3; - break; - } - return 0; - } - - inline Unit* GetTargetByType(uint32 Target, Unit* pActionInvoker) - { - switch (Target) - { - case TARGET_T_SELF: - return m_creature; - break; - case TARGET_T_HOSTILE: - return m_creature->getVictim(); - break; - case TARGET_T_HOSTILE_SECOND_AGGRO: - return SelectUnit(SELECT_TARGET_TOPAGGRO,1); - break; - case TARGET_T_HOSTILE_LAST_AGGRO: - return SelectUnit(SELECT_TARGET_BOTTOMAGGRO,0); - break; - case TARGET_T_HOSTILE_RANDOM: - return SelectUnit(SELECT_TARGET_RANDOM,0); - break; - case TARGET_T_HOSTILE_RANDOM_NOT_TOP: - return SelectUnit(SELECT_TARGET_RANDOM,1); - break; - case TARGET_T_ACTION_INVOKER: - return pActionInvoker; - break; - default: - return NULL; - break; - }; - } - - void ProcessAction(uint16 type, uint32 param1, uint32 param2, uint32 param3, uint32 rnd, uint32 EventId, Unit* pActionInvoker) - { - switch (type) - { - case ACTION_T_SAY: - DoSay(GetEventAIText(param1), LANG_UNIVERSAL, pActionInvoker ? pActionInvoker : m_creature->getVictim()); - break; - - case ACTION_T_YELL: - DoYell(GetEventAIText(param1), LANG_UNIVERSAL, pActionInvoker ? pActionInvoker : m_creature->getVictim()); - break; - - case ACTION_T_TEXTEMOTE: - DoTextEmote(GetEventAIText(param1), pActionInvoker ? pActionInvoker : m_creature->getVictim()); - break; - - case ACTION_T_SOUND: - DoPlaySoundToSet(m_creature, param1); - break; - - case ACTION_T_EMOTE: - m_creature->HandleEmoteCommand(param1); - break; - - case ACTION_T_RANDOM_SAY: - { - uint32 temp = GetRandActionParam(rnd, param1, param2, param3); - - if (temp != 0xffffffff) - DoSay(GetEventAIText(temp), LANG_UNIVERSAL, pActionInvoker ? pActionInvoker : m_creature->getVictim()); - } - break; - - case ACTION_T_RANDOM_YELL: - { - uint32 temp = GetRandActionParam(rnd, param1, param2, param3); - - if (temp != 0xffffffff) - DoYell(GetEventAIText(temp), LANG_UNIVERSAL, pActionInvoker ? pActionInvoker : m_creature->getVictim()); - } - break; - - case ACTION_T_RANDOM_TEXTEMOTE: - { - uint32 temp = GetRandActionParam(rnd, param1, param2, param3); - - if (temp != 0xffffffff) - DoTextEmote(GetEventAIText(temp), pActionInvoker ? pActionInvoker : m_creature->getVictim()); - } - break; - - case ACTION_T_RANDOM_SOUND: - { - uint32 temp = GetRandActionParam(rnd, param1, param2, param3); - - if (temp != 0xffffffff) - DoPlaySoundToSet(m_creature, temp); - } - break; - - case ACTION_T_RANDOM_EMOTE: - { - uint32 temp = GetRandActionParam(rnd, param1, param2, param3); - - if (temp != 0xffffffff) - m_creature->HandleEmoteCommand(temp); - } - break; - - case ACTION_T_CAST: - { - Unit* target = GetTargetByType(param2, pActionInvoker); - Unit* caster = m_creature; - - if (!target) - return; - - //Cast is always triggered if target is forced to cast on self - if (param3 & CAST_FORCE_TARGET_SELF) - { - param3 |= CAST_TRIGGERED; - caster = target; - } - - //Interrupt any previous spell - if (caster->IsNonMeleeSpellCasted(false) && param3 & CAST_INTURRUPT_PREVIOUS) - caster->InterruptNonMeleeSpells(false); - - //Cast only if not casting or if spell is triggered - if (param3 & CAST_TRIGGERED || !caster->IsNonMeleeSpellCasted(false)) - { - const SpellEntry* tSpell = GetSpellStore()->LookupEntry(param1); - - //Verify that spell exists - if (tSpell) - { - //Check if cannot cast spell - if (!(param3 & (CAST_FORCE_TARGET_SELF | CAST_FORCE_CAST)) && - !CanCast(target, tSpell, (param3 & CAST_TRIGGERED))) - { - //Melee current victim if flag not set - if (!(param3 & CAST_NO_MELEE_IF_OOM)) - { - AttackDistance = 0; - AttackAngle = 0; - - m_creature->GetMotionMaster()->Clear(false); - m_creature->GetMotionMaster()->MoveChase(m_creature->getVictim(), AttackDistance, AttackAngle); - } - - }else caster->CastSpell(target, param1, (param3 & CAST_TRIGGERED)); - - }else if (EAI_ErrorLevel > 0) - error_db_log("SD2: EventAI event %d creature %d attempt to cast spell that doesn't exist %d", EventId, m_creature->GetEntry(), param1); - } - } - break; - - case ACTION_T_SUMMON: - { - Unit* target = GetTargetByType(param2, pActionInvoker); - - Creature* pCreature = NULL; - - if (param3) - pCreature = DoSpawnCreature(param1, 0, 0, 0, 0, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, param3); - else pCreature = pCreature = DoSpawnCreature(param1, 0, 0, 0, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 0); - - if (!pCreature) - { - if (EAI_ErrorLevel > 0) - error_db_log( "SD2: EventAI failed to spawn creature %u. Spawn event %d is on creature %d", param1, EventId, m_creature->GetEntry()); - } - else if (param2 != TARGET_T_SELF && target) - pCreature->AI()->AttackStart(target); - } - break; - - case ACTION_T_THREAT_SINGLE_PCT: - { - Unit* target = GetTargetByType(param2, pActionInvoker); - - if (target) - m_creature->getThreatManager().modifyThreatPercent(target, param1); - } - break; - - case ACTION_T_THREAT_ALL_PCT: - { - Unit* Temp = NULL; - - std::list::iterator i = m_creature->getThreatManager().getThreatList().begin(); - for (; i != m_creature->getThreatManager().getThreatList().end(); ++i) - { - Temp = Unit::GetUnit((*m_creature),(*i)->getUnitGuid()); - if (Temp) - m_creature->getThreatManager().modifyThreatPercent(Temp, param1); - } - } - break; - - case ACTION_T_QUEST_EVENT: - { - Unit* target = GetTargetByType(param2, pActionInvoker); - - if (target && target->GetTypeId() == TYPEID_PLAYER) - ((Player*)target)->AreaExploredOrEventHappens(param1); - } - break; - - case ACTION_T_CASTCREATUREGO: - { - Unit* target = GetTargetByType(param3, pActionInvoker); - - if (target && target->GetTypeId() == TYPEID_PLAYER) - ((Player*)target)->CastedCreatureOrGO(param1, m_creature->GetGUID(), param2); - } - break; - - case ACTION_T_SET_UNIT_FIELD: - { - Unit* target = GetTargetByType(param3, pActionInvoker); - - if (target) - target->SetUInt32Value(param1, param2); - } - break; - - case ACTION_T_SET_UNIT_FLAG: - { - Unit* target = GetTargetByType(param2, pActionInvoker); - - if (target) - target->SetFlag(UNIT_FIELD_FLAGS, param1); - } - break; - - case ACTION_T_REMOVE_UNIT_FLAG: - { - Unit* target = GetTargetByType(param2, pActionInvoker); - - if (target) - target->RemoveFlag(UNIT_FIELD_FLAGS, param1); - } - break; - - case ACTION_T_AUTO_ATTACK: - { - if (param1) - MeleeEnabled = true; - else MeleeEnabled = false; - } - break; - - case ACTION_T_COMBAT_MOVEMENT: - { - CombatMovementEnabled = param1; - - //Allow movement (create new targeted movement gen if none exist already) - if (CombatMovementEnabled) - { - if (m_creature->GetMotionMaster()->GetCurrentMovementGeneratorType() != TARGETED_MOTION_TYPE) - { - m_creature->GetMotionMaster()->Clear(false); - m_creature->GetMotionMaster()->MoveChase(m_creature->getVictim(), AttackDistance, AttackAngle); - } - } - else - if (m_creature->GetMotionMaster()->GetCurrentMovementGeneratorType() == TARGETED_MOTION_TYPE) - { - m_creature->GetMotionMaster()->Clear(false); - m_creature->GetMotionMaster()->MoveIdle(); - m_creature->StopMoving(); - } - } - break; - case ACTION_T_SET_PHASE: - { - Phase = param1; - } - break; - case ACTION_T_INC_PHASE: - { - Phase += param1; - - if (Phase > 31) - if (EAI_ErrorLevel > 0) - error_db_log( "SD2: Event %d incremented Phase above 31. Phase mask cannot be used with phases past 31. CreatureEntry = %d", EventId, m_creature->GetEntry()); - } - break; - - case ACTION_T_EVADE: - { - EnterEvadeMode(); - } - break; - case ACTION_T_FLEE: - { - //TODO: Replace with Flee movement generator - m_creature->CastSpell(m_creature, SPELL_RUN_AWAY, true); - } - break; - case ACTION_T_QUEST_EVENT_ALL: - { - Unit* Temp = NULL; - if( pActionInvoker && pActionInvoker->GetTypeId() == TYPEID_PLAYER ) - { - Temp = Unit::GetUnit((*m_creature),pActionInvoker->GetGUID()); - if( Temp ) - ((Player*)Temp)->GroupEventHappens(param1,m_creature); - } - } - break; - - case ACTION_T_CASTCREATUREGO_ALL: - { - Unit* Temp = NULL; - - std::list::iterator i = m_creature->getThreatManager().getThreatList().begin(); - for (; i != m_creature->getThreatManager().getThreatList().end(); ++i) - { - Temp = Unit::GetUnit((*m_creature),(*i)->getUnitGuid()); - if (Temp && Temp->GetTypeId() == TYPEID_PLAYER) - ((Player*)Temp)->CastedCreatureOrGO(param1, m_creature->GetGUID(), param2); - } - } - break; - - case ACTION_T_REMOVEAURASFROMSPELL: - { - Unit* target = GetTargetByType(param1, pActionInvoker); - - if (target) - target->RemoveAurasDueToSpell(param2); - } - break; - - case ACTION_T_RANGED_MOVEMENT: - { - AttackDistance = param1; - AttackAngle = ((float)param2/180)*M_PI; - - if (CombatMovementEnabled) - { - //Drop current movement gen - m_creature->GetMotionMaster()->Clear(false); - m_creature->GetMotionMaster()->MoveChase(m_creature->getVictim(), AttackDistance, AttackAngle); - } - } - break; - - case ACTION_T_RANDOM_PHASE: - { - uint32 temp = GetRandActionParam(rnd, param1, param2, param3); - - Phase = temp; - } - break; - - case ACTION_T_RANDOM_PHASE_RANGE: - { - if (param2 > param1) - { - Phase = param1 + (rnd % (param2 - param1)); - } - else if (EAI_ErrorLevel > 0) - error_db_log( "SD2: ACTION_T_RANDOM_PHASE_RANGE cannot have Param2 <= Param1. Divide by Zero. Event = %d. CreatureEntry = %d", EventId, m_creature->GetEntry()); - } - break; - case ACTION_T_SUMMON_ID: - { - Unit* target = GetTargetByType(param2, pActionInvoker); - - //Duration - Creature* pCreature = NULL; - - HM_NAMESPACE::hash_map::iterator i = EventAI_Summon_Map.find(param3); - - if (i == EventAI_Summon_Map.end()) - { - if (EAI_ErrorLevel > 0) - error_db_log( "SD2: EventAI failed to spawn creature %u. Summon map index %u does not exist. EventID %d. CreatureID %d", param1, param3, EventId, m_creature->GetEntry()); - return; - } - - if ((*i).second.SpawnTimeSecs) - pCreature = m_creature->SummonCreature(param1, (*i).second.position_x, (*i).second.position_y, (*i).second.position_z, (*i).second.orientation, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, (*i).second.SpawnTimeSecs); - else pCreature = m_creature->SummonCreature(param1, (*i).second.position_x, (*i).second.position_y, (*i).second.position_z, (*i).second.orientation, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 0); - - if (!pCreature) - { - if (EAI_ErrorLevel > 0) - error_db_log( "SD2: EventAI failed to spawn creature %u. EventId %d.Creature %d", param1, EventId, m_creature->GetEntry()); - } - else if (param2 != TARGET_T_SELF && target) - pCreature->AI()->AttackStart(target); - } - break; - - case ACTION_T_KILLED_MONSTER: - { - Unit* target = GetTargetByType(param2, pActionInvoker); - - if (target && target->GetTypeId() == TYPEID_PLAYER) - ((Player*)target)->KilledMonster(param1, m_creature->GetGUID()); - } - break; - - case ACTION_T_SET_INST_DATA: - { - ScriptedInstance* pInst = (ScriptedInstance*)m_creature->GetInstanceData(); - if (!pInst) - { - if (EAI_ErrorLevel > 0) - error_db_log("SD2: Event %d attempt to set instance data without instance script. Creature %d", EventId, m_creature->GetEntry()); - return; - } - - pInst->SetData(param1, param2); - } - break; - - case ACTION_T_SET_INST_DATA64: - { - Unit* target = GetTargetByType(param2, pActionInvoker); - - if (!target) - { - if (EAI_ErrorLevel > 0) - error_db_log("SD2: Event %d attempt to set instance data64 but Target == NULL. Creature %d", EventId, m_creature->GetEntry()); - return; - } - - ScriptedInstance* pInst = (ScriptedInstance*)m_creature->GetInstanceData(); - - if (!pInst) - { - if (EAI_ErrorLevel > 0) - error_db_log("SD2: Event %d attempt to set instance data64 without instance script. Creature %d", EventId, m_creature->GetEntry()); - return; - } - - pInst->SetData64(param1, target->GetGUID()); - } - break; - - case ACTION_T_UPDATE_TEMPLATE: - { - if (m_creature->GetEntry() == param1) - { - if (EAI_ErrorLevel > 0) - error_db_log("SD2: Event %d ACTION_T_UPDATE_TEMPLATE call with param1 == current entry. Creature %d", EventId, m_creature->GetEntry()); - return; - } - - m_creature->UpdateEntry(param1, param2 ? HORDE : ALLIANCE); - } - break; - - case ACTION_T_DIE: - { - if (m_creature->isDead()) - { - if (EAI_ErrorLevel > 0) - error_db_log("SD2: Event %d ACTION_T_DIE on dead creature. Creature %d", EventId, m_creature->GetEntry()); - return; - } - m_creature->DealDamage(m_creature, m_creature->GetMaxHealth(),NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); - } - break; - - case ACTION_T_ZONE_COMBAT_PULSE: - { - if (!m_creature->isInCombat() || !m_creature->GetMap()->IsDungeon()) - { - if (EAI_ErrorLevel > 0) - error_db_log("SD2: Event %d ACTION_T_ZONE_COMBAT_PULSE on creature out of combat or in non-dungeon map. Creature %d", EventId, m_creature->GetEntry()); - return; - } - - DoZoneInCombat(); - } - break; - }; - } - - void JustRespawned() - { - InCombat = false; - Reset(); - - //Handle Spawned Events - for (std::list::iterator i = EventList.begin(); i != EventList.end(); ++i) - { - switch ((*i).Event.event_type) - { - case EVENT_T_SPAWNED: - ProcessEvent(*i); - break; - } - } - } - - void Reset() - { - EventUpdateTime = EVENT_UPDATE_TIME; - EventDiff = 0; - - //Handle Evade events and reset all events to enabled - for (std::list::iterator i = EventList.begin(); i != EventList.end(); ++i) - { - switch ((*i).Event.event_type) - { - //Reset all out of combat timers - case EVENT_T_TIMER_OOC: - { - if ((*i).Event.event_param2 == (*i).Event.event_param1) - { - (*i).Time = (*i).Event.event_param1; - (*i).Enabled = true; - - }else if ((*i).Event.event_param2 > (*i).Event.event_param1) - { - (*i).Time = urand((*i).Event.event_param1, (*i).Event.event_param2); - (*i).Enabled = true; - }else if (EAI_ErrorLevel > 0) - error_db_log("SD2: Creature %u using Event %u (Type = %u) has InitialMax < InitialMin. Event disabled.", m_creature->GetEntry(), (*i).Event.event_id, (*i).Event.event_type); - - }break; - } - } - } - - void EnterEvadeMode() - { - m_creature->RemoveAllAuras(); - m_creature->DeleteThreatList(); - m_creature->CombatStop(); - m_creature->LoadCreaturesAddon(); - if( m_creature->isAlive() ) - m_creature->GetMotionMaster()->MoveTargetedHome(); - - m_creature->SetLootRecipient(NULL); - - InCombat = false; - Reset(); - - //Handle Evade events - for (std::list::iterator i = EventList.begin(); i != EventList.end(); ++i) - { - switch ((*i).Event.event_type) - { - //Evade - case EVENT_T_EVADE: - ProcessEvent(*i); - break; - } - } - } - - void JustDied(Unit* killer) - { - InCombat = false; - Reset(); - - //Handle Evade events - for (std::list::iterator i = EventList.begin(); i != EventList.end(); ++i) - { - switch ((*i).Event.event_type) - { - //Evade - case EVENT_T_DEATH: - ProcessEvent(*i, killer); - break; - } - } - } - - void KilledUnit(Unit* victim) - { - if (victim->GetTypeId() != TYPEID_PLAYER) - return; - - for (std::list::iterator i = EventList.begin(); i != EventList.end(); ++i) - { - switch ((*i).Event.event_type) - { - //Kill - case EVENT_T_KILL: - ProcessEvent(*i, victim); - break; - } - } - - } - - void JustSummoned(Creature* pUnit) - { - if (!pUnit) - return; - - for (std::list::iterator i = EventList.begin(); i != EventList.end(); ++i) - { - switch ((*i).Event.event_type) - { - //Summoned - case EVENT_T_SUMMONED_UNIT: - ProcessEvent(*i, pUnit); - break; - } - } - } - - void Aggro(Unit *who) - { - //Check for on combat start events - for (std::list::iterator i = EventList.begin(); i != EventList.end(); ++i) - { - switch ((*i).Event.event_type) - { - case EVENT_T_AGGRO: - ProcessEvent(*i, who); - break; - - //Reset all in combat timers - case EVENT_T_TIMER: - - if ((*i).Event.event_param2 == (*i).Event.event_param1) - { - (*i).Time = (*i).Event.event_param1; - (*i).Enabled = true; - - }else if ((*i).Event.event_param2 > (*i).Event.event_param1) - { - (*i).Time = urand((*i).Event.event_param1, (*i).Event.event_param2); - (*i).Enabled = true; - }else if (EAI_ErrorLevel > 0) - error_db_log("SD2: Creature %u using Event %u (Type = %u) has InitialMax < InitialMin. Event disabled.", m_creature->GetEntry(), (*i).Event.event_id, (*i).Event.event_type); - - break; - - //All normal events need to be re-enabled and their time set to 0 - default: - (*i).Enabled = true; - (*i).Time = 0; - break; - } - } - - EventUpdateTime = EVENT_UPDATE_TIME; - EventDiff = 0; - } - - void AttackStart(Unit *who) - { - if (!who) - return; - - if (who->isTargetableForAttack()) - { - //Begin melee attack if we are within range - if (CombatMovementEnabled) - AttackTarget(who, true); - else AttackTarget(who, false); - - if (!InCombat) - { - Aggro(who); - InCombat = true; - } - } - } - - void MoveInLineOfSight(Unit *who) - { - if (!who || InCombat) - return; - - //Check for OOC LOS Event - for (std::list::iterator i = EventList.begin(); i != EventList.end(); ++i) - { - switch ((*i).Event.event_type) - { - case EVENT_T_OOC_LOS: - { - if ((*i).Event.event_param1 && m_creature->IsHostileTo(who)) - break; - - if ((*i).Event.event_param2 && !m_creature->IsHostileTo(who)) - break; - - ProcessEvent(*i, who); - } - break; - } - } - - if (who->isTargetableForAttack() && who->isInAccessablePlaceFor(m_creature) && m_creature->IsHostileTo(who)) - { - float attackRadius = m_creature->GetAttackDistance(who); - if (m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->GetDistanceZ(who) <= CREATURE_Z_ATTACK_RANGE && m_creature->IsWithinLOSInMap(who)) - { - if(who->HasStealthAura()) - who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); - - //Begin melee attack if we are within range - if (CombatMovementEnabled) - AttackTarget(who, true); - else AttackTarget(who, false); - - if (!InCombat) - { - Aggro(who); - InCombat = true; - } - } - } - } - - void SpellHit(Unit* pUnit, const SpellEntry* pSpell) - { - for (std::list::iterator i = EventList.begin(); i != EventList.end(); ++i) - { - switch ((*i).Event.event_type) - { - //Spell hit - case EVENT_T_SPELLHIT: - { - //If spell id matches (or no spell id) & if spell school matches (or no spell school) - if (!(*i).Event.event_param1 || pSpell->Id == (*i).Event.event_param1) - if ((*i).Event.event_param2_s == -1 || pSpell->SchoolMask == (*i).Event.event_param2) - ProcessEvent(*i, pUnit); - } - break; - } - } - } - - void UpdateAI(const uint32 diff) - { - //Check if we are in combat (also updates calls threat update code) - bool Combat = InCombat ? (m_creature->SelectHostilTarget() && m_creature->getVictim()) : false; - - //Must return if creature isn't alive. Normally select hostil target and get victim prevent this - if (!m_creature->isAlive()) - return; - - //Events are only updated once every EVENT_UPDATE_TIME ms to prevent lag with large amount of events - if (EventUpdateTime < diff) - { - EventDiff += diff; - - //Check for range based events - //if (m_creature->GetDistance(m_creature->getVictim()) > - if (Combat) - for (std::list::iterator i = EventList.begin(); i != EventList.end(); ++i) - { - switch ((*i).Event.event_type) - { - case EVENT_T_RANGE: - float dist = m_creature->GetDistance(m_creature->getVictim()); - if (dist > (*i).Event.event_param1 && dist < (*i).Event.event_param2) - ProcessEvent(*i); - break; - } - } - - //Check for time based events - for (std::list::iterator i = EventList.begin(); i != EventList.end(); ++i) - { - //Decrement Timers - if ((*i).Time) - if ((*i).Time > EventDiff) - { - //Do not decrement timers if event cannot trigger in this phase - if (!((*i).Event.event_inverse_phase_mask & (1 << Phase))) - (*i).Time -= EventDiff; - - //Skip processing of events that have time remaining - continue; - } - else (*i).Time = 0; - - switch ((*i).Event.event_type) - { - //Events that are updated every EVENT_UPDATE_TIME - case EVENT_T_TIMER: - case EVENT_T_TIMER_OOC: - case EVENT_T_MANA: - case EVENT_T_HP: - case EVENT_T_TARGET_HP: - case EVENT_T_TARGET_CASTING: - case EVENT_T_FRIENDLY_HP: - ProcessEvent(*i); - break; - } - } - - EventDiff = 0; - EventUpdateTime = EVENT_UPDATE_TIME; - }else - { - EventDiff += diff; - EventUpdateTime -= diff; - } - - //Melee Auto-Attack - if (Combat && MeleeEnabled) - DoMeleeAttackIfReady(); - - } -}; - -CreatureAI* GetAI_Mob_EventAI(Creature *_Creature) -{ - //Select events by creature id - std::list EventList; - uint32 ID = _Creature->GetEntry(); - - std::list::iterator i; - - for (i = EventAI_Event_List.begin(); i != EventAI_Event_List.end(); ++i) - { - if ((*i).creature_id == ID) - { - //Debug check -#ifndef _DEBUG - if ((*i).event_flags & EFLAG_DEBUG_ONLY) - continue; -#endif - - //Heroic Instance Difficulty check - if ((*i).event_flags & EFLAG_HEROIC) - { - //Creature isn't even in a dungeon - if (!_Creature->GetMap() || !_Creature->GetMap()->IsDungeon()) - { - if (EAI_ErrorLevel > 1) - error_db_log("SD2: Creature %u, Event %u using EFLAG_HEROIC but creature is not inside of an instance. Event skipped.", _Creature->GetEntry(), (*i).event_id); - continue; - } - - if (!_Creature->GetMap()->IsHeroic()) - continue; - } else - - //Normal Instance Difficulty check - if ((*i).event_flags & EFLAG_NORMAL) - { - //Creature isn't even in a dungeon - if (!_Creature->GetMap() || !_Creature->GetMap()->IsDungeon()) - { - if (EAI_ErrorLevel > 1) - error_db_log("SD2: Creature %u, Event %u using EFLAG_NORMAL but creature is not inside of an instance. Event skipped.", _Creature->GetEntry(), (*i).event_id); - continue; - } - - if (_Creature->GetMap()->IsHeroic()) - continue; - } else if (_Creature->GetMap() && _Creature->GetMap()->IsDungeon() && EAI_ErrorLevel > 1) - error_db_log("SD2: Creature %u, Event %u. Creature is in instance but neither EFLAG_NORMAL or EFLAG_HEROIC are set.", _Creature->GetEntry(), (*i).event_id); - - //Push back event - EventList.push_back(EventHolder(*i)); - } - } - - //EventAI is pointless to use without events and may cause crashes - if (EventList.empty()) - { - if (EAI_ErrorLevel > 1) - error_db_log("SD2: Eventlist for Creature %u is empty but creature is using Mob_EventAI. Preventing EventAI on this creature.", _Creature->GetEntry()); - - return NULL; - } - - return new Mob_EventAI (_Creature, EventList); -} - -void AddSC_mob_event() -{ - Script *newscript; - newscript = new Script; - newscript->Name="mob_eventai"; - newscript->GetAI = GetAI_Mob_EventAI; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Mob_Event_AI +SD%Complete: 90 +SDComment: Database Event AI +SDCategory: Creatures +EndScriptData */ + +#include "precompiled.h" +#include "mob_event_ai.h" + +#define EVENT_UPDATE_TIME 500 +#define SPELL_RUN_AWAY 8225 + +struct EventHolder +{ + EventHolder(EventAI_Event p) : Event(p), Time(0), Enabled(true){} + + EventAI_Event Event; + uint32 Time; + bool Enabled; +}; + +struct MANGOS_DLL_DECL Mob_EventAI : public ScriptedAI +{ + Mob_EventAI(Creature *c, std::list pEventList) : ScriptedAI(c) + { + EventList = pEventList; + Phase = 0; + CombatMovementEnabled = true; + MeleeEnabled = true; + AttackDistance = 0; + AttackAngle = 0.0f; + + //Handle Spawned Events + for (std::list::iterator i = EventList.begin(); i != EventList.end(); ++i) + { + switch ((*i).Event.event_type) + { + case EVENT_T_SPAWNED: + ProcessEvent(*i); + break; + default: + break; + } + } + + Reset(); + } + + ~Mob_EventAI() + { + EventList.clear(); + } + + //Variables used by EventAI for handling events + std::list EventList; //Holder for events (stores enabled, time, and eventid) + uint32 EventUpdateTime; //Time between event updates + uint32 EventDiff; //Time between the last event call + + //Variables used by Events themselves + uint8 Phase; //Current phase, max 32 phases + bool CombatMovementEnabled; //If we allow targeted movment gen (movement twoards top threat) + bool MeleeEnabled; //If we allow melee auto attack + uint32 AttackDistance; //Distance to attack from + float AttackAngle; //Angle of attack + + void AttackTarget(Unit* pTarget, bool Follow) + { + if (!pTarget) + return; + + if ( m_creature->Attack(pTarget, true) ) + { + if (Follow) + { + m_creature->GetMotionMaster()->Clear(false); + m_creature->GetMotionMaster()->MoveChase(pTarget, AttackDistance, AttackAngle); + } + + m_creature->AddThreat(pTarget, 0.0f); + } + } + + bool ProcessEvent(EventHolder& pHolder, Unit* pActionInvoker = NULL) + { + if (!pHolder.Enabled || pHolder.Time) + return false; + + //Check the inverse phase mask (event doesn't trigger if current phase bit is set in mask) + if (pHolder.Event.event_inverse_phase_mask & (1 << Phase)) + return false; + + //Store random here so that all random actions match up + uint32 rnd = rand(); + + //Return if chance for event is not met + if (pHolder.Event.event_chance <= rnd % 100) + return false; + + union + { + uint32 param1; + int32 param1_s; + }; + + union + { + uint32 param2; + int32 param2_s; + }; + + union + { + uint32 param3; + int32 param3_s; + }; + + union + { + uint32 param4; + int32 param4_s; + }; + + param1 = pHolder.Event.event_param1; + param2 = pHolder.Event.event_param2; + param3 = pHolder.Event.event_param3; + param4 = pHolder.Event.event_param4; + + //Check event conditions based on the event type, also reset events + switch (pHolder.Event.event_type) + { + case EVENT_T_TIMER: + { + if (!InCombat) + return false; + + //Repeat Timers + if (param3 == param4) + { + pHolder.Time = param3; + + }else if (param4 > param3) + pHolder.Time = urand(param3, param4); + else + { + if (EAI_ErrorLevel > 0) + error_db_log("SD2: Creature %u using Event %u (Type = %u) has RandomMax < RandomMin. Event repeating disabled.", m_creature->GetEntry(), pHolder.Event.event_id, pHolder.Event.event_type); + pHolder.Enabled = false; + } + } + break; + case EVENT_T_TIMER_OOC: + { + if (InCombat) + return false; + + //Repeat Timers + if (param3 == param4) + { + pHolder.Time = param3; + + }else if (param4 > param3) + pHolder.Time = urand(param3, param4); + else + { + if (EAI_ErrorLevel > 0) + error_db_log("SD2: Creature %u using Event %u (Type = %u) has RandomMax < RandomMin. Event repeating disabled.", m_creature->GetEntry(), pHolder.Event.event_id, pHolder.Event.event_type); + pHolder.Enabled = false; + } + } + break; + case EVENT_T_HP: + { + if (!InCombat || !m_creature->GetMaxHealth()) + return false; + + uint32 perc = (m_creature->GetHealth()*100) / m_creature->GetMaxHealth(); + + if (perc > param1 || perc < param2) + return false; + + //Repeat Timers + if (param3 == param4) + { + pHolder.Time = param3; + + }else if (param4 > param3) + pHolder.Time = urand(param3, param4); + else + { + if (EAI_ErrorLevel > 0) + error_db_log("SD2: Creature %u using Event %u (Type = %u) has RandomMax < RandomMin. Event repeating disabled.", m_creature->GetEntry(), pHolder.Event.event_id, pHolder.Event.event_type); + pHolder.Enabled = false; + } + } + break; + case EVENT_T_MANA: + { + if (!InCombat || !m_creature->GetMaxPower(POWER_MANA)) + return false; + + uint32 perc = (m_creature->GetPower(POWER_MANA)*100) / m_creature->GetMaxPower(POWER_MANA); + + if (perc > param1 || perc < param2) + return false; + + //Repeat Timers + if (param3 == param4) + { + pHolder.Time = param3; + + }else if (param4 > param3) + pHolder.Time = urand(param3, param4); + else + { + if (EAI_ErrorLevel > 0) + error_db_log("SD2: Creature %u using Event %u (Type = %u) has RandomMax < RandomMin. Event repeating disabled.", m_creature->GetEntry(), pHolder.Event.event_id, pHolder.Event.event_type); + pHolder.Enabled = false; + } + } + break; + case EVENT_T_AGGRO: + { + } + break; + case EVENT_T_KILL: + { + //Repeat Timers + if (param1 == param2) + { + pHolder.Time = param1; + + }else if (param2 > param1) + pHolder.Time = urand(param1, param2); + else + { + if (EAI_ErrorLevel > 0) + error_db_log("SD2: Creature %u using Event %u (Type = %u) has RandomMax < RandomMin. Event repeating disabled.", m_creature->GetEntry(), pHolder.Event.event_id, pHolder.Event.event_type); + pHolder.Enabled = false; + } + } + case EVENT_T_DEATH: + { + } + break; + case EVENT_T_EVADE: + { + } + break; + case EVENT_T_SPELLHIT: + { + //Spell hit is special case, param1 and param2 handled within EventAI::SpellHit + + //Repeat Timers + if (param3 == param4) + { + pHolder.Time = param3; + + }else if (param4 > param3) + pHolder.Time = urand(param3, param4); + else + { + if (EAI_ErrorLevel > 0) + error_db_log("SD2: Creature %u using Event %u (Type = %u) has RandomMax < RandomMin. Event repeating disabled.", m_creature->GetEntry(), pHolder.Event.event_id, pHolder.Event.event_type); + pHolder.Enabled = false; + } + } + break; + case EVENT_T_RANGE: + { + //Repeat Timers + if (param3 == param4) + { + pHolder.Time = param3; + + }else if (param4 > param3) + pHolder.Time = urand(param3, param4); + else + { + if (EAI_ErrorLevel > 0) + error_db_log("SD2: Creature %u using Event %u (Type = %u) has RandomMax < RandomMin. Event repeating disabled.", m_creature->GetEntry(), pHolder.Event.event_id, pHolder.Event.event_type); + pHolder.Enabled = false; + } + } + break; + case EVENT_T_OOC_LOS: + { + //Repeat Timers + if (param3 == param4) + { + pHolder.Time = param3; + + }else if (param4 > param3) + pHolder.Time = urand(param3, param4); + else + { + if (EAI_ErrorLevel > 0) + error_db_log("SD2: Creature %u using Event %u (Type = %u) has RandomMax < RandomMin. Event repeating disabled.", m_creature->GetEntry(), pHolder.Event.event_id, pHolder.Event.event_type); + pHolder.Enabled = false; + } + } + break; + case EVENT_T_SPAWNED: + { + } + break; + case EVENT_T_TARGET_HP: + { + if (!InCombat || !m_creature->getVictim() || !m_creature->getVictim()->GetMaxHealth()) + return false; + + uint32 perc = (m_creature->getVictim()->GetHealth()*100) / m_creature->getVictim()->GetMaxHealth(); + + if (perc > param1 || perc < param2) + return false; + + //Repeat Timers + if (param3 == param4) + { + pHolder.Time = param3; + + }else if (param4 > param3) + pHolder.Time = urand(param3, param4); + else + { + if (EAI_ErrorLevel > 0) + error_db_log("SD2: Creature %u using Event %u (Type = %u) has RandomMax < RandomMin. Event repeating disabled.", m_creature->GetEntry(), pHolder.Event.event_id, pHolder.Event.event_type); + pHolder.Enabled = false; + } + } + break; + case EVENT_T_TARGET_CASTING: + { + if (!InCombat || !m_creature->getVictim() || !m_creature->getVictim()->IsNonMeleeSpellCasted(false, false, true)) + return false; + + //Repeat Timers + if (param1 == param2) + { + pHolder.Time = param1; + + }else if (param2 > param1) + pHolder.Time = urand(param1, param2); + else + { + if (EAI_ErrorLevel > 0) + error_db_log("SD2: Creature %u using Event %u (Type = %u) has RandomMax < RandomMin. Event repeating disabled.", m_creature->GetEntry(), pHolder.Event.event_id, pHolder.Event.event_type); + pHolder.Enabled = false; + } + } + break; + case EVENT_T_FRIENDLY_HP: + { + if (!InCombat) + return false; + + Unit* pUnit = DoSelectLowestHpFriendly(param2, param1); + + if (!pUnit) + return false; + + pActionInvoker = pUnit; + + //Repeat Timers + if (param3 == param4) + { + pHolder.Time = param3; + + }else if (param4 > param3) + pHolder.Time = urand(param3, param4); + else + { + if (EAI_ErrorLevel > 0) + error_db_log("SD2: Creature %u using Event %u (Type = %u) has RandomMax < RandomMin. Event repeating disabled.", m_creature->GetEntry(), pHolder.Event.event_id, pHolder.Event.event_type); + pHolder.Enabled = false; + } + } + break; + case EVENT_T_FRIENDLY_IS_CC: + { + if (!InCombat) + return false; + + std::list pList = DoFindFriendlyCC(param2); + + //List is empty + if (pList.empty()) + return false; + + //We don't really care about the whole list, just return first available + pActionInvoker = *(pList.begin()); + + //Repeat Timers + if (param3 == param4) + { + pHolder.Time = param3; + + }else if (param4 > param3) + pHolder.Time = urand(param3, param4); + else + { + if (EAI_ErrorLevel > 0) + error_db_log("SD2: Creature %u using Event %u (Type = %u) has RandomMax < RandomMin. Event repeating disabled.", m_creature->GetEntry(), pHolder.Event.event_id, pHolder.Event.event_type); + pHolder.Enabled = false; + } + } + break; + case EVENT_T_FRIENDLY_MISSING_BUFF: + { + std::list pList = DoFindFriendlyMissingBuff(param2, param1); + + //List is empty + if (pList.empty()) + return false; + + //We don't really care about the whole list, just return first available + pActionInvoker = *(pList.begin()); + + //Repeat Timers + if (param3 == param4) + { + pHolder.Time = param3; + + }else if (param4 > param3) + pHolder.Time = urand(param3, param4); + else + { + if (EAI_ErrorLevel > 0) + error_db_log("SD2: Creature %u using Event %u (Type = %u) has RandomMax < RandomMin. Event repeating disabled.", m_creature->GetEntry(), pHolder.Event.event_id, pHolder.Event.event_type); + pHolder.Enabled = false; + } + } + break; + case EVENT_T_SUMMONED_UNIT: + { + //Prevent event from occuring on no unit or non creatures + if (!pActionInvoker || pActionInvoker->GetTypeId()!=TYPEID_UNIT) + return false; + + //Creature id doesn't match up + if (param1 && ((Creature*)pActionInvoker)->GetEntry() != param1) + return false; + + //Repeat Timers + if (param2 == param3) + { + pHolder.Time = param2; + + }else if (param3 > param2) + pHolder.Time = urand(param2, param3); + else + { + if (EAI_ErrorLevel > 0) + error_db_log("SD2: Creature %u using Event %u (Type = %u) has RandomMax < RandomMin. Event repeating disabled.", m_creature->GetEntry(), pHolder.Event.event_id, pHolder.Event.event_type); + pHolder.Enabled = false; + } + } + break; + default: + if (EAI_ErrorLevel > 0) + error_db_log("SD2: Creature %u using Event %u has invalid Event Type(%u), missing from ProcessEvent() Switch.", m_creature->GetEntry(), pHolder.Event.event_id, pHolder.Event.event_type); + break; + } + + //Disable non-repeatable events + if (!(pHolder.Event.event_flags & EFLAG_REPEATABLE)) + pHolder.Enabled = false; + + //Process actions + for (uint32 j = 0; j < MAX_ACTIONS; j++) + ProcessAction(pHolder.Event.action[j].type, pHolder.Event.action[j].param1, pHolder.Event.action[j].param2, pHolder.Event.action[j].param3, rnd, pHolder.Event.event_id, pActionInvoker); + + return true; + } + + inline uint32 GetRandActionParam(uint32 rnd, uint32 param1, uint32 param2, uint32 param3) + { + switch (rnd % 3) + { + case 0: + return param1; + break; + case 1: + return param2; + break; + case 2: + return param3; + break; + } + return 0; + } + + inline Unit* GetTargetByType(uint32 Target, Unit* pActionInvoker) + { + switch (Target) + { + case TARGET_T_SELF: + return m_creature; + break; + case TARGET_T_HOSTILE: + return m_creature->getVictim(); + break; + case TARGET_T_HOSTILE_SECOND_AGGRO: + return SelectUnit(SELECT_TARGET_TOPAGGRO,1); + break; + case TARGET_T_HOSTILE_LAST_AGGRO: + return SelectUnit(SELECT_TARGET_BOTTOMAGGRO,0); + break; + case TARGET_T_HOSTILE_RANDOM: + return SelectUnit(SELECT_TARGET_RANDOM,0); + break; + case TARGET_T_HOSTILE_RANDOM_NOT_TOP: + return SelectUnit(SELECT_TARGET_RANDOM,1); + break; + case TARGET_T_ACTION_INVOKER: + return pActionInvoker; + break; + default: + return NULL; + break; + }; + } + + void ProcessAction(uint16 type, uint32 param1, uint32 param2, uint32 param3, uint32 rnd, uint32 EventId, Unit* pActionInvoker) + { + switch (type) + { + case ACTION_T_SAY: + DoSay(GetEventAIText(param1), LANG_UNIVERSAL, pActionInvoker ? pActionInvoker : m_creature->getVictim()); + break; + case ACTION_T_YELL: + DoYell(GetEventAIText(param1), LANG_UNIVERSAL, pActionInvoker ? pActionInvoker : m_creature->getVictim()); + break; + case ACTION_T_TEXTEMOTE: + DoTextEmote(GetEventAIText(param1), pActionInvoker ? pActionInvoker : m_creature->getVictim()); + break; + case ACTION_T_SOUND: + DoPlaySoundToSet(m_creature, param1); + break; + case ACTION_T_EMOTE: + m_creature->HandleEmoteCommand(param1); + break; + case ACTION_T_RANDOM_SAY: + { + uint32 temp = GetRandActionParam(rnd, param1, param2, param3); + + if (temp != 0xffffffff) + DoSay(GetEventAIText(temp), LANG_UNIVERSAL, pActionInvoker ? pActionInvoker : m_creature->getVictim()); + } + break; + case ACTION_T_RANDOM_YELL: + { + uint32 temp = GetRandActionParam(rnd, param1, param2, param3); + + if (temp != 0xffffffff) + DoYell(GetEventAIText(temp), LANG_UNIVERSAL, pActionInvoker ? pActionInvoker : m_creature->getVictim()); + } + break; + case ACTION_T_RANDOM_TEXTEMOTE: + { + uint32 temp = GetRandActionParam(rnd, param1, param2, param3); + + if (temp != 0xffffffff) + DoTextEmote(GetEventAIText(temp), pActionInvoker ? pActionInvoker : m_creature->getVictim()); + } + break; + case ACTION_T_RANDOM_SOUND: + { + uint32 temp = GetRandActionParam(rnd, param1, param2, param3); + + if (temp != 0xffffffff) + DoPlaySoundToSet(m_creature, temp); + } + break; + case ACTION_T_RANDOM_EMOTE: + { + uint32 temp = GetRandActionParam(rnd, param1, param2, param3); + + if (temp != 0xffffffff) + m_creature->HandleEmoteCommand(temp); + } + break; + case ACTION_T_CAST: + { + Unit* target = GetTargetByType(param2, pActionInvoker); + Unit* caster = m_creature; + + if (!target) + return; + + //Cast is always triggered if target is forced to cast on self + if (param3 & CAST_FORCE_TARGET_SELF) + { + param3 |= CAST_TRIGGERED; + caster = target; + } + + //Interrupt any previous spell + if (caster->IsNonMeleeSpellCasted(false) && param3 & CAST_INTURRUPT_PREVIOUS) + caster->InterruptNonMeleeSpells(false); + + //Cast only if not casting or if spell is triggered + if (param3 & CAST_TRIGGERED || !caster->IsNonMeleeSpellCasted(false)) + { + const SpellEntry* tSpell = GetSpellStore()->LookupEntry(param1); + + //Verify that spell exists + if (tSpell) + { + //Check if cannot cast spell + if (!(param3 & (CAST_FORCE_TARGET_SELF | CAST_FORCE_CAST)) && + !CanCast(target, tSpell, (param3 & CAST_TRIGGERED))) + { + //Melee current victim if flag not set + if (!(param3 & CAST_NO_MELEE_IF_OOM)) + { + AttackDistance = 0; + AttackAngle = 0; + + m_creature->GetMotionMaster()->Clear(false); + m_creature->GetMotionMaster()->MoveChase(m_creature->getVictim(), AttackDistance, AttackAngle); + } + + }else caster->CastSpell(target, param1, (param3 & CAST_TRIGGERED)); + + }else if (EAI_ErrorLevel > 0) + error_db_log("SD2: EventAI event %d creature %d attempt to cast spell that doesn't exist %d", EventId, m_creature->GetEntry(), param1); + } + } + break; + case ACTION_T_SUMMON: + { + Unit* target = GetTargetByType(param2, pActionInvoker); + + Creature* pCreature = NULL; + + if (param3) + pCreature = DoSpawnCreature(param1, 0, 0, 0, 0, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, param3); + else pCreature = pCreature = DoSpawnCreature(param1, 0, 0, 0, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 0); + + if (!pCreature) + { + if (EAI_ErrorLevel > 0) + error_db_log( "SD2: EventAI failed to spawn creature %u. Spawn event %d is on creature %d", param1, EventId, m_creature->GetEntry()); + } + else if (param2 != TARGET_T_SELF && target) + pCreature->AI()->AttackStart(target); + } + break; + case ACTION_T_THREAT_SINGLE_PCT: + { + Unit* target = GetTargetByType(param2, pActionInvoker); + + if (target) + m_creature->getThreatManager().modifyThreatPercent(target, param1); + } + break; + case ACTION_T_THREAT_ALL_PCT: + { + Unit* Temp = NULL; + + std::list::iterator i = m_creature->getThreatManager().getThreatList().begin(); + for (; i != m_creature->getThreatManager().getThreatList().end(); ++i) + { + Temp = Unit::GetUnit((*m_creature),(*i)->getUnitGuid()); + if (Temp) + m_creature->getThreatManager().modifyThreatPercent(Temp, param1); + } + } + break; + case ACTION_T_QUEST_EVENT: + { + Unit* target = GetTargetByType(param2, pActionInvoker); + + if (target && target->GetTypeId() == TYPEID_PLAYER) + ((Player*)target)->AreaExploredOrEventHappens(param1); + } + break; + case ACTION_T_CASTCREATUREGO: + { + Unit* target = GetTargetByType(param3, pActionInvoker); + + if (target && target->GetTypeId() == TYPEID_PLAYER) + ((Player*)target)->CastedCreatureOrGO(param1, m_creature->GetGUID(), param2); + } + break; + case ACTION_T_SET_UNIT_FIELD: + { + Unit* target = GetTargetByType(param3, pActionInvoker); + + if (target) + target->SetUInt32Value(param1, param2); + } + break; + case ACTION_T_SET_UNIT_FLAG: + { + Unit* target = GetTargetByType(param2, pActionInvoker); + + if (target) + target->SetFlag(UNIT_FIELD_FLAGS, param1); + } + break; + case ACTION_T_REMOVE_UNIT_FLAG: + { + Unit* target = GetTargetByType(param2, pActionInvoker); + + if (target) + target->RemoveFlag(UNIT_FIELD_FLAGS, param1); + } + break; + case ACTION_T_AUTO_ATTACK: + { + if (param1) + MeleeEnabled = true; + else MeleeEnabled = false; + } + break; + case ACTION_T_COMBAT_MOVEMENT: + { + CombatMovementEnabled = param1; + + //Allow movement (create new targeted movement gen if none exist already) + if (CombatMovementEnabled) + { + if (m_creature->GetMotionMaster()->GetCurrentMovementGeneratorType() != TARGETED_MOTION_TYPE) + { + m_creature->GetMotionMaster()->Clear(false); + m_creature->GetMotionMaster()->MoveChase(m_creature->getVictim(), AttackDistance, AttackAngle); + } + } + else + if (m_creature->GetMotionMaster()->GetCurrentMovementGeneratorType() == TARGETED_MOTION_TYPE) + { + m_creature->GetMotionMaster()->Clear(false); + m_creature->GetMotionMaster()->MoveIdle(); + m_creature->StopMoving(); + } + } + break; + case ACTION_T_SET_PHASE: + { + Phase = param1; + } + break; + case ACTION_T_INC_PHASE: + { + Phase += param1; + + if (Phase > 31) + if (EAI_ErrorLevel > 0) + error_db_log( "SD2: Event %d incremented Phase above 31. Phase mask cannot be used with phases past 31. CreatureEntry = %d", EventId, m_creature->GetEntry()); + } + break; + case ACTION_T_EVADE: + { + EnterEvadeMode(); + } + break; + case ACTION_T_FLEE: + { + //TODO: Replace with Flee movement generator + m_creature->CastSpell(m_creature, SPELL_RUN_AWAY, true); + } + break; + case ACTION_T_QUEST_EVENT_ALL: + { + Unit* Temp = NULL; + if( pActionInvoker && pActionInvoker->GetTypeId() == TYPEID_PLAYER ) + { + Temp = Unit::GetUnit((*m_creature),pActionInvoker->GetGUID()); + if( Temp ) + ((Player*)Temp)->GroupEventHappens(param1,m_creature); + } + } + break; + case ACTION_T_CASTCREATUREGO_ALL: + { + Unit* Temp = NULL; + + std::list::iterator i = m_creature->getThreatManager().getThreatList().begin(); + for (; i != m_creature->getThreatManager().getThreatList().end(); ++i) + { + Temp = Unit::GetUnit((*m_creature),(*i)->getUnitGuid()); + if (Temp && Temp->GetTypeId() == TYPEID_PLAYER) + ((Player*)Temp)->CastedCreatureOrGO(param1, m_creature->GetGUID(), param2); + } + } + break; + case ACTION_T_REMOVEAURASFROMSPELL: + { + Unit* target = GetTargetByType(param1, pActionInvoker); + + if (target) + target->RemoveAurasDueToSpell(param2); + } + break; + case ACTION_T_RANGED_MOVEMENT: + { + AttackDistance = param1; + AttackAngle = ((float)param2/180)*M_PI; + + if (CombatMovementEnabled) + { + //Drop current movement gen + m_creature->GetMotionMaster()->Clear(false); + m_creature->GetMotionMaster()->MoveChase(m_creature->getVictim(), AttackDistance, AttackAngle); + } + } + break; + case ACTION_T_RANDOM_PHASE: + { + uint32 temp = GetRandActionParam(rnd, param1, param2, param3); + + Phase = temp; + } + break; + case ACTION_T_RANDOM_PHASE_RANGE: + { + if (param2 > param1) + { + Phase = param1 + (rnd % (param2 - param1)); + } + else if (EAI_ErrorLevel > 0) + error_db_log( "SD2: ACTION_T_RANDOM_PHASE_RANGE cannot have Param2 <= Param1. Divide by Zero. Event = %d. CreatureEntry = %d", EventId, m_creature->GetEntry()); + } + break; + case ACTION_T_SUMMON_ID: + { + Unit* target = GetTargetByType(param2, pActionInvoker); + + //Duration + Creature* pCreature = NULL; + + HM_NAMESPACE::hash_map::iterator i = EventAI_Summon_Map.find(param3); + + if (i == EventAI_Summon_Map.end()) + { + if (EAI_ErrorLevel > 0) + error_db_log( "SD2: EventAI failed to spawn creature %u. Summon map index %u does not exist. EventID %d. CreatureID %d", param1, param3, EventId, m_creature->GetEntry()); + return; + } + + if ((*i).second.SpawnTimeSecs) + pCreature = m_creature->SummonCreature(param1, (*i).second.position_x, (*i).second.position_y, (*i).second.position_z, (*i).second.orientation, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, (*i).second.SpawnTimeSecs); + else pCreature = m_creature->SummonCreature(param1, (*i).second.position_x, (*i).second.position_y, (*i).second.position_z, (*i).second.orientation, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 0); + + if (!pCreature) + { + if (EAI_ErrorLevel > 0) + error_db_log( "SD2: EventAI failed to spawn creature %u. EventId %d.Creature %d", param1, EventId, m_creature->GetEntry()); + } + else if (param2 != TARGET_T_SELF && target) + pCreature->AI()->AttackStart(target); + } + break; + case ACTION_T_KILLED_MONSTER: + { + Unit* target = GetTargetByType(param2, pActionInvoker); + + if (target && target->GetTypeId() == TYPEID_PLAYER) + ((Player*)target)->KilledMonster(param1, m_creature->GetGUID()); + } + break; + case ACTION_T_SET_INST_DATA: + { + ScriptedInstance* pInst = (ScriptedInstance*)m_creature->GetInstanceData(); + if (!pInst) + { + if (EAI_ErrorLevel > 0) + error_db_log("SD2: Event %d attempt to set instance data without instance script. Creature %d", EventId, m_creature->GetEntry()); + return; + } + + pInst->SetData(param1, param2); + } + break; + case ACTION_T_SET_INST_DATA64: + { + Unit* target = GetTargetByType(param2, pActionInvoker); + + if (!target) + { + if (EAI_ErrorLevel > 0) + error_db_log("SD2: Event %d attempt to set instance data64 but Target == NULL. Creature %d", EventId, m_creature->GetEntry()); + return; + } + + ScriptedInstance* pInst = (ScriptedInstance*)m_creature->GetInstanceData(); + + if (!pInst) + { + if (EAI_ErrorLevel > 0) + error_db_log("SD2: Event %d attempt to set instance data64 without instance script. Creature %d", EventId, m_creature->GetEntry()); + return; + } + + pInst->SetData64(param1, target->GetGUID()); + } + break; + case ACTION_T_UPDATE_TEMPLATE: + { + if (m_creature->GetEntry() == param1) + { + if (EAI_ErrorLevel > 0) + error_db_log("SD2: Event %d ACTION_T_UPDATE_TEMPLATE call with param1 == current entry. Creature %d", EventId, m_creature->GetEntry()); + return; + } + + m_creature->UpdateEntry(param1, param2 ? HORDE : ALLIANCE); + } + break; + case ACTION_T_DIE: + { + if (m_creature->isDead()) + { + if (EAI_ErrorLevel > 0) + error_db_log("SD2: Event %d ACTION_T_DIE on dead creature. Creature %d", EventId, m_creature->GetEntry()); + return; + } + m_creature->DealDamage(m_creature, m_creature->GetMaxHealth(),NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); + } + break; + case ACTION_T_ZONE_COMBAT_PULSE: + { + if (!m_creature->isInCombat() || !m_creature->GetMap()->IsDungeon()) + { + if (EAI_ErrorLevel > 0) + error_db_log("SD2: Event %d ACTION_T_ZONE_COMBAT_PULSE on creature out of combat or in non-dungeon map. Creature %d", EventId, m_creature->GetEntry()); + return; + } + + DoZoneInCombat(); + } + break; + } + } + + void JustRespawned() + { + InCombat = false; + Reset(); + + //Handle Spawned Events + for (std::list::iterator i = EventList.begin(); i != EventList.end(); ++i) + { + switch ((*i).Event.event_type) + { + case EVENT_T_SPAWNED: + ProcessEvent(*i); + break; + } + } + } + + void Reset() + { + EventUpdateTime = EVENT_UPDATE_TIME; + EventDiff = 0; + + //Handle Evade events and reset all events to enabled + for (std::list::iterator i = EventList.begin(); i != EventList.end(); ++i) + { + switch ((*i).Event.event_type) + { + //Reset all out of combat timers + case EVENT_T_TIMER_OOC: + { + if ((*i).Event.event_param2 == (*i).Event.event_param1) + { + (*i).Time = (*i).Event.event_param1; + (*i).Enabled = true; + }else if ((*i).Event.event_param2 > (*i).Event.event_param1) + { + (*i).Time = urand((*i).Event.event_param1, (*i).Event.event_param2); + (*i).Enabled = true; + }else if (EAI_ErrorLevel > 0) + error_db_log("SD2: Creature %u using Event %u (Type = %u) has InitialMax < InitialMin. Event disabled.", m_creature->GetEntry(), (*i).Event.event_id, (*i).Event.event_type); + } + break; + default: + //TODO: enable below code line / verify this is correct to enable events previously disabled (ex. aggro yell), instead of enable this in void Aggro() + //(*i).Enabled = true; + //(*i).Time = 0; + break; + } + } + } + + void EnterEvadeMode() + { + m_creature->RemoveAllAuras(); + m_creature->DeleteThreatList(); + m_creature->CombatStop(); + m_creature->LoadCreaturesAddon(); + if( m_creature->isAlive() ) + m_creature->GetMotionMaster()->MoveTargetedHome(); + + m_creature->SetLootRecipient(NULL); + + InCombat = false; + Reset(); + + //Handle Evade events + for (std::list::iterator i = EventList.begin(); i != EventList.end(); ++i) + { + switch ((*i).Event.event_type) + { + //Evade + case EVENT_T_EVADE: + ProcessEvent(*i); + break; + default: + break; + } + } + } + + void JustDied(Unit* killer) + { + InCombat = false; + Reset(); + + //Handle Evade events + for (std::list::iterator i = EventList.begin(); i != EventList.end(); ++i) + { + switch ((*i).Event.event_type) + { + //Evade + case EVENT_T_DEATH: + ProcessEvent(*i, killer); + break; + default: + break; + } + } + } + + void KilledUnit(Unit* victim) + { + if (victim->GetTypeId() != TYPEID_PLAYER) + return; + + for (std::list::iterator i = EventList.begin(); i != EventList.end(); ++i) + { + switch ((*i).Event.event_type) + { + //Kill + case EVENT_T_KILL: + ProcessEvent(*i, victim); + break; + default: + break; + } + } + + } + + void JustSummoned(Creature* pUnit) + { + if (!pUnit) + return; + + for (std::list::iterator i = EventList.begin(); i != EventList.end(); ++i) + { + switch ((*i).Event.event_type) + { + //Summoned + case EVENT_T_SUMMONED_UNIT: + ProcessEvent(*i, pUnit); + break; + default: + break; + } + } + } + + void Aggro(Unit *who) + { + //Check for on combat start events + for (std::list::iterator i = EventList.begin(); i != EventList.end(); ++i) + { + switch ((*i).Event.event_type) + { + case EVENT_T_AGGRO: + (*i).Enabled = true; + ProcessEvent(*i, who); + break; + //Reset all in combat timers + case EVENT_T_TIMER: + if ((*i).Event.event_param2 == (*i).Event.event_param1) + { + (*i).Time = (*i).Event.event_param1; + (*i).Enabled = true; + }else if ((*i).Event.event_param2 > (*i).Event.event_param1) + { + (*i).Time = urand((*i).Event.event_param1, (*i).Event.event_param2); + (*i).Enabled = true; + }else if (EAI_ErrorLevel > 0) + error_db_log("SD2: Creature %u using Event %u (Type = %u) has InitialMax < InitialMin. Event disabled.", m_creature->GetEntry(), (*i).Event.event_id, (*i).Event.event_type); + break; + //All normal events need to be re-enabled and their time set to 0 + default: + (*i).Enabled = true; + (*i).Time = 0; + break; + } + } + + EventUpdateTime = EVENT_UPDATE_TIME; + EventDiff = 0; + } + + void AttackStart(Unit *who) + { + if (!who) + return; + + if (who->isTargetableForAttack()) + { + //Begin melee attack if we are within range + if (CombatMovementEnabled) + AttackTarget(who, true); + else AttackTarget(who, false); + + if (!InCombat) + { + Aggro(who); + InCombat = true; + } + } + } + + void MoveInLineOfSight(Unit *who) + { + if (!who || InCombat) + return; + + //Check for OOC LOS Event + for (std::list::iterator i = EventList.begin(); i != EventList.end(); ++i) + { + switch ((*i).Event.event_type) + { + case EVENT_T_OOC_LOS: + { + if ((*i).Event.event_param1 && m_creature->IsHostileTo(who)) + break; + + if ((*i).Event.event_param2 && !m_creature->IsHostileTo(who)) + break; + + ProcessEvent(*i, who); + } + break; + } + } + + if (who->isTargetableForAttack() && who->isInAccessablePlaceFor(m_creature) && m_creature->IsHostileTo(who)) + { + if (!m_creature->canFly() && m_creature->GetDistanceZ(who) > CREATURE_Z_ATTACK_RANGE) + return; + + float attackRadius = m_creature->GetAttackDistance(who); + if (m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->IsWithinLOSInMap(who)) + { + if(who->HasStealthAura()) + who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); + + //Begin melee attack if we are within range + if (CombatMovementEnabled) + AttackTarget(who, true); + else AttackTarget(who, false); + + if (!InCombat) + { + Aggro(who); + InCombat = true; + } + } + } + } + + void SpellHit(Unit* pUnit, const SpellEntry* pSpell) + { + for (std::list::iterator i = EventList.begin(); i != EventList.end(); ++i) + { + switch ((*i).Event.event_type) + { + //Spell hit + case EVENT_T_SPELLHIT: + { + //If spell id matches (or no spell id) & if spell school matches (or no spell school) + if (!(*i).Event.event_param1 || pSpell->Id == (*i).Event.event_param1) + if ((*i).Event.event_param2_s == -1 || pSpell->SchoolMask == (*i).Event.event_param2) + ProcessEvent(*i, pUnit); + } + break; + default: + break; + } + } + } + + void UpdateAI(const uint32 diff) + { + //Check if we are in combat (also updates calls threat update code) + bool Combat = InCombat ? (m_creature->SelectHostilTarget() && m_creature->getVictim()) : false; + + //Must return if creature isn't alive. Normally select hostil target and get victim prevent this + if (!m_creature->isAlive()) + return; + + //Events are only updated once every EVENT_UPDATE_TIME ms to prevent lag with large amount of events + if (EventUpdateTime < diff) + { + EventDiff += diff; + + //Check for range based events + //if (m_creature->GetDistance(m_creature->getVictim()) > + if (Combat) + for (std::list::iterator i = EventList.begin(); i != EventList.end(); ++i) + { + switch ((*i).Event.event_type) + { + case EVENT_T_RANGE: + float dist = m_creature->GetDistance(m_creature->getVictim()); + if (dist > (*i).Event.event_param1 && dist < (*i).Event.event_param2) + ProcessEvent(*i); + break; + } + } + + //Check for time based events + for (std::list::iterator i = EventList.begin(); i != EventList.end(); ++i) + { + //Decrement Timers + if ((*i).Time) + if ((*i).Time > EventDiff) + { + //Do not decrement timers if event cannot trigger in this phase + if (!((*i).Event.event_inverse_phase_mask & (1 << Phase))) + (*i).Time -= EventDiff; + + //Skip processing of events that have time remaining + continue; + } + else (*i).Time = 0; + + switch ((*i).Event.event_type) + { + //Events that are updated every EVENT_UPDATE_TIME + case EVENT_T_TIMER: + case EVENT_T_TIMER_OOC: + case EVENT_T_MANA: + case EVENT_T_HP: + case EVENT_T_TARGET_HP: + case EVENT_T_TARGET_CASTING: + case EVENT_T_FRIENDLY_HP: + ProcessEvent(*i); + break; + } + } + + EventDiff = 0; + EventUpdateTime = EVENT_UPDATE_TIME; + }else + { + EventDiff += diff; + EventUpdateTime -= diff; + } + + //Melee Auto-Attack + if (Combat && MeleeEnabled) + DoMeleeAttackIfReady(); + + } +}; + +CreatureAI* GetAI_Mob_EventAI(Creature *_Creature) +{ + //Select events by creature id + std::list EventList; + uint32 ID = _Creature->GetEntry(); + + std::list::iterator i; + + for (i = EventAI_Event_List.begin(); i != EventAI_Event_List.end(); ++i) + { + if ((*i).creature_id == ID) + { +//Debug check +#ifndef _DEBUG + if ((*i).event_flags & EFLAG_DEBUG_ONLY) + continue; +#endif + if( _Creature->GetMap()->IsDungeon() ) + { + if( _Creature->GetMap()->IsHeroic() ) + { + if( (*i).event_flags & EFLAG_HEROIC ) + { + EventList.push_back(EventHolder(*i)); + continue; + }else if( (*i).event_flags & EFLAG_NORMAL ) + continue; + } + else + { + if( (*i).event_flags & EFLAG_NORMAL ) + { + EventList.push_back(EventHolder(*i)); + continue; + }else if( (*i).event_flags & EFLAG_HEROIC ) + continue; + } + + if (EAI_ErrorLevel > 1) + error_db_log("SD2: Creature %u Event %u. Creature are in instance but neither EFLAG_NORMAL or EFLAG_HEROIC are set. Event Disabled.", _Creature->GetEntry(), (*i).event_id); + + continue; + } + + EventList.push_back(EventHolder(*i)); + } + } + + //EventAI is pointless to use without events and may cause crashes + if (EventList.empty()) + { + if (EAI_ErrorLevel > 1) + error_db_log("SD2: Eventlist for Creature %u is empty but creature is using Mob_EventAI. Preventing EventAI on this creature.", _Creature->GetEntry()); + + return NULL; + } + + return new Mob_EventAI (_Creature, EventList); +} + +void AddSC_mob_event() +{ + Script *newscript; + newscript = new Script; + newscript->Name="mob_eventai"; + newscript->GetAI = GetAI_Mob_EventAI; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/creature/mob_event_ai.h b/src/bindings/scripts/scripts/creature/mob_event_ai.h index 05b0b6d7b45..8c9b06cd5ce 100644 --- a/src/bindings/scripts/scripts/creature/mob_event_ai.h +++ b/src/bindings/scripts/scripts/creature/mob_event_ai.h @@ -1,215 +1,215 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 -* This program is free software licensed under GPL version 2 -* Please see the included DOCS/LICENSE.TXT for more information */ - -#ifndef SC_EVENTAI_H -#define SC_EVENTAI_H - -#define MAX_ACTIONS 3 - -enum Event_Types -{ - EVENT_T_TIMER = 0, //InitialMin, InitialMax, RepeatMin, RepeatMax - EVENT_T_TIMER_OOC = 1, //InitialMin, InitialMax, RepeatMin, RepeatMax - EVENT_T_HP = 2, //HPMax%, HPMin%, RepeatMin, RepeatMax - EVENT_T_MANA = 3, //ManaMax%,ManaMin% RepeatMin, RepeatMax - EVENT_T_AGGRO = 4, //NONE - EVENT_T_KILL = 5, //RepeatMin, RepeatMax - EVENT_T_DEATH = 6, //NONE - EVENT_T_EVADE = 7, //NONE - EVENT_T_SPELLHIT = 8, //SpellID, School, RepeatMin, RepeatMax - EVENT_T_RANGE = 9, //MinDist, MaxDist, RepeatMin, RepeatMax - EVENT_T_OOC_LOS = 10, //NoHostile, NoFriendly, RepeatMin, RepeatMax - EVENT_T_SPAWNED = 11, //NONE - EVENT_T_TARGET_HP = 12, //HPMax%, HPMin%, RepeatMin, RepeatMax - EVENT_T_TARGET_CASTING = 13, //RepeatMin, RepeatMax - EVENT_T_FRIENDLY_HP = 14, //HPDeficit, Radius, RepeatMin, RepeatMax - EVENT_T_FRIENDLY_IS_CC = 15, //DispelType, Radius, RepeatMin, RepeatMax - EVENT_T_FRIENDLY_MISSING_BUFF = 16, //SpellId, Radius, RepeatMin, RepeatMax - EVENT_T_SUMMONED_UNIT = 17, //CreatureId, RepeatMin, RepeatMax - EVENT_T_TARGET_MANA = 18, //ManaMax%, ManaMin%, RepeatMin, RepeatMax - EVENT_T_QUEST_ACCEPT = 19, //QuestID - EVENT_T_QUEST_COMPLETE = 20, // - - EVENT_T_END, -}; - -enum Action_Types -{ - ACTION_T_NONE = 0, //No action - ACTION_T_SAY = 1, //TextId - ACTION_T_YELL = 2, //TextId - ACTION_T_TEXTEMOTE = 3, //TextId - ACTION_T_SOUND = 4, //SoundId - ACTION_T_EMOTE = 5, //EmoteId - ACTION_T_RANDOM_SAY = 6, //TextId1, TextId2, TextId3 (-1 in any field means no output if randomed that field) - ACTION_T_RANDOM_YELL = 7, //TextId1, TextId2, TextId3 (-1 in any field means no output if randomed that field) - ACTION_T_RANDOM_TEXTEMOTE = 8, //TextId1, TextId2, TextId3 (-1 in any field means no output if randomed that field) - ACTION_T_RANDOM_SOUND = 9, //SoundId1, SoundId2, SoundId3 (-1 in any field means no output if randomed that field) - ACTION_T_RANDOM_EMOTE = 10, //EmoteId1, EmoteId2, EmoteId3 (-1 in any field means no output if randomed that field) - ACTION_T_CAST = 11, //SpellId, Target, CastFlags - ACTION_T_SUMMON = 12, //CreatureID, Target, Duration in ms - ACTION_T_THREAT_SINGLE_PCT = 13, //Threat%, Target - ACTION_T_THREAT_ALL_PCT = 14, //Threat% - ACTION_T_QUEST_EVENT = 15, //QuestID, Target - ACTION_T_CASTCREATUREGO = 16, //QuestID, SpellId, Target - ACTION_T_SET_UNIT_FIELD = 17, //Field_Number, Value, Target - ACTION_T_SET_UNIT_FLAG = 18, //Flags (may be more than one field OR'd together), Target - ACTION_T_REMOVE_UNIT_FLAG = 19, //Flags (may be more than one field OR'd together), Target - ACTION_T_AUTO_ATTACK = 20, //AllowAttackState (0 = stop attack, anything else means continue attacking) - ACTION_T_COMBAT_MOVEMENT = 21, //AllowCombatMovement (0 = stop combat based movement, anything else continue attacking) - ACTION_T_SET_PHASE = 22, //Phase - ACTION_T_INC_PHASE = 23, //Value (may be negative to decrement phase, should not be 0) - ACTION_T_EVADE = 24, //No Params - ACTION_T_FLEE = 25, //No Params - ACTION_T_QUEST_EVENT_ALL = 26, //QuestID - ACTION_T_CASTCREATUREGO_ALL = 27, //QuestId, SpellId - ACTION_T_REMOVEAURASFROMSPELL = 28, //Target, Spellid - ACTION_T_RANGED_MOVEMENT = 29, //Distance, Angle - ACTION_T_RANDOM_PHASE = 30, //PhaseId1, PhaseId2, PhaseId3 - ACTION_T_RANDOM_PHASE_RANGE = 31, //PhaseMin, PhaseMax - ACTION_T_SUMMON_ID = 32, //CreatureId, Target, SpawnId - ACTION_T_KILLED_MONSTER = 33, //CreatureId, Target - ACTION_T_SET_INST_DATA = 34, //Field, Data - ACTION_T_SET_INST_DATA64 = 35, //Field, Target - ACTION_T_UPDATE_TEMPLATE = 36, //Entry, Team - ACTION_T_DIE = 37, //No Params - ACTION_T_ZONE_COMBAT_PULSE = 38, //No Params - - ACTION_T_END, -}; - -enum Target -{ - //Self (m_creature) - TARGET_T_SELF = 0, //Self cast - - //Hostile targets (if pet then returns pet owner) - TARGET_T_HOSTILE, //Our current target (ie: highest aggro) - TARGET_T_HOSTILE_SECOND_AGGRO, //Second highest aggro (generaly used for cleaves and some special attacks) - TARGET_T_HOSTILE_LAST_AGGRO, //Dead last on aggro (no idea what this could be used for) - TARGET_T_HOSTILE_RANDOM, //Just any random target on our threat list - TARGET_T_HOSTILE_RANDOM_NOT_TOP, //Any random target except top threat - - //Invoker targets (if pet then returns pet owner) - TARGET_T_ACTION_INVOKER, //Unit who caused this Event to occur (only works for EVENT_T_AGGRO, EVENT_T_KILL, EVENT_T_DEATH, EVENT_T_SPELLHIT, EVENT_T_OOC_LOS, EVENT_T_FRIENDLY_HP, EVENT_T_FRIENDLY_IS_CC, EVENT_T_FRIENDLY_MISSING_BUFF) - - //Hostile targets (including pets) - TARGET_T_HOSTILE_WPET, //Current target (can be a pet) - TARGET_T_HOSTILE_WPET_SECOND_AGGRO, //Second highest aggro (generaly used for cleaves and some special attacks) - TARGET_T_HOSTILE_WPET_LAST_AGGRO, //Dead last on aggro (no idea what this could be used for) - TARGET_T_HOSTILE_WPET_RANDOM, //Just any random target on our threat list - TARGET_T_HOSTILE_WPET_RANDOM_NOT_TOP, //Any random target except top threat - - TARGET_T_ACTION_INVOKER_WPET, - - TARGET_T_END -}; - -enum CastFlags -{ - CAST_INTURRUPT_PREVIOUS = 0x01, //Interrupt any spell casting - CAST_TRIGGERED = 0x02, //Triggered (this makes spell cost zero mana and have no cast time) - CAST_FORCE_CAST = 0x04, //Forces cast even if creature is out of mana or out of range - CAST_NO_MELEE_IF_OOM = 0x08, //Prevents creature from entering melee if out of mana or out of range - CAST_FORCE_TARGET_SELF = 0x10, //Forces the target to cast this spell on itself -}; - -enum EventFlags -{ - EFLAG_REPEATABLE = 0x01, //Event repeats - EFLAG_NORMAL = 0x02, //Event only occurs in Normal instance difficulty - EFLAG_HEROIC = 0x04, //Event only occurs in Heroic instance difficulty - EFLAG_RESERVED_3 = 0x08, - EFLAG_RESERVED_4 = 0x10, - EFLAG_RESERVED_5 = 0x20, - EFLAG_RESERVED_6 = 0x40, - EFLAG_DEBUG_ONLY = 0x80, //Event only occurs in debug build of SD2 only -}; - -struct EventAI_Event -{ - uint32 event_id; - - uint32 creature_id; - - uint16 event_type; - uint32 event_inverse_phase_mask; - uint8 event_chance; - uint8 event_flags; - union - { - uint32 event_param1; - int32 event_param1_s; - }; - union - { - uint32 event_param2; - int32 event_param2_s; - }; - union - { - uint32 event_param3; - int32 event_param3_s; - }; - union - { - uint32 event_param4; - int32 event_param4_s; - }; - - struct _action - { - uint16 type; - union - { - uint32 param1; - int32 param1_s; - }; - union - { - uint32 param2; - int32 param2_s; - }; - union - { - uint32 param3; - int32 param3_s; - }; - }action[MAX_ACTIONS]; -}; - -//Event_Map -extern std::list EventAI_Event_List; - -struct EventAI_Summon -{ - uint32 id; - - float position_x; - float position_y; - float position_z; - float orientation; - uint32 SpawnTimeSecs; -}; - -//EventSummon_Map -extern HM_NAMESPACE::hash_map EventAI_Summon_Map; - -//EventAI Error handling -extern uint32 EAI_ErrorLevel; -/* - -struct EventAI_CreatureError -{ - bool ListEmpty; - bool NoInstance; -}; - -//Error prevention list -extern HM_NAMESPACE::hash_map EventAI_CreatureErrorPreventionList; - -//Defines -#define EVENTAI_EMPTY_EVENTLIST "SD2: Eventlist for Creature %i is empty but creature is using Mob_EventAI. Preventing EventAI on this creature." -*/ -#endif +/* Copyright (C) 2006 - 2008 ScriptDev2 +* This program is free software licensed under GPL version 2 +* Please see the included DOCS/LICENSE.TXT for more information */ + +#ifndef SC_EVENTAI_H +#define SC_EVENTAI_H + +#define MAX_ACTIONS 3 + +enum Event_Types +{ + EVENT_T_TIMER = 0, //InitialMin, InitialMax, RepeatMin, RepeatMax + EVENT_T_TIMER_OOC = 1, //InitialMin, InitialMax, RepeatMin, RepeatMax + EVENT_T_HP = 2, //HPMax%, HPMin%, RepeatMin, RepeatMax + EVENT_T_MANA = 3, //ManaMax%,ManaMin% RepeatMin, RepeatMax + EVENT_T_AGGRO = 4, //NONE + EVENT_T_KILL = 5, //RepeatMin, RepeatMax + EVENT_T_DEATH = 6, //NONE + EVENT_T_EVADE = 7, //NONE + EVENT_T_SPELLHIT = 8, //SpellID, School, RepeatMin, RepeatMax + EVENT_T_RANGE = 9, //MinDist, MaxDist, RepeatMin, RepeatMax + EVENT_T_OOC_LOS = 10, //NoHostile, NoFriendly, RepeatMin, RepeatMax + EVENT_T_SPAWNED = 11, //NONE + EVENT_T_TARGET_HP = 12, //HPMax%, HPMin%, RepeatMin, RepeatMax + EVENT_T_TARGET_CASTING = 13, //RepeatMin, RepeatMax + EVENT_T_FRIENDLY_HP = 14, //HPDeficit, Radius, RepeatMin, RepeatMax + EVENT_T_FRIENDLY_IS_CC = 15, //DispelType, Radius, RepeatMin, RepeatMax + EVENT_T_FRIENDLY_MISSING_BUFF = 16, //SpellId, Radius, RepeatMin, RepeatMax + EVENT_T_SUMMONED_UNIT = 17, //CreatureId, RepeatMin, RepeatMax + EVENT_T_TARGET_MANA = 18, //ManaMax%, ManaMin%, RepeatMin, RepeatMax + EVENT_T_QUEST_ACCEPT = 19, //QuestID + EVENT_T_QUEST_COMPLETE = 20, // + + EVENT_T_END, +}; + +enum Action_Types +{ + ACTION_T_NONE = 0, //No action + ACTION_T_SAY = 1, //TextId + ACTION_T_YELL = 2, //TextId + ACTION_T_TEXTEMOTE = 3, //TextId + ACTION_T_SOUND = 4, //SoundId + ACTION_T_EMOTE = 5, //EmoteId + ACTION_T_RANDOM_SAY = 6, //TextId1, TextId2, TextId3 (-1 in any field means no output if randomed that field) + ACTION_T_RANDOM_YELL = 7, //TextId1, TextId2, TextId3 (-1 in any field means no output if randomed that field) + ACTION_T_RANDOM_TEXTEMOTE = 8, //TextId1, TextId2, TextId3 (-1 in any field means no output if randomed that field) + ACTION_T_RANDOM_SOUND = 9, //SoundId1, SoundId2, SoundId3 (-1 in any field means no output if randomed that field) + ACTION_T_RANDOM_EMOTE = 10, //EmoteId1, EmoteId2, EmoteId3 (-1 in any field means no output if randomed that field) + ACTION_T_CAST = 11, //SpellId, Target, CastFlags + ACTION_T_SUMMON = 12, //CreatureID, Target, Duration in ms + ACTION_T_THREAT_SINGLE_PCT = 13, //Threat%, Target + ACTION_T_THREAT_ALL_PCT = 14, //Threat% + ACTION_T_QUEST_EVENT = 15, //QuestID, Target + ACTION_T_CASTCREATUREGO = 16, //QuestID, SpellId, Target + ACTION_T_SET_UNIT_FIELD = 17, //Field_Number, Value, Target + ACTION_T_SET_UNIT_FLAG = 18, //Flags (may be more than one field OR'd together), Target + ACTION_T_REMOVE_UNIT_FLAG = 19, //Flags (may be more than one field OR'd together), Target + ACTION_T_AUTO_ATTACK = 20, //AllowAttackState (0 = stop attack, anything else means continue attacking) + ACTION_T_COMBAT_MOVEMENT = 21, //AllowCombatMovement (0 = stop combat based movement, anything else continue attacking) + ACTION_T_SET_PHASE = 22, //Phase + ACTION_T_INC_PHASE = 23, //Value (may be negative to decrement phase, should not be 0) + ACTION_T_EVADE = 24, //No Params + ACTION_T_FLEE = 25, //No Params + ACTION_T_QUEST_EVENT_ALL = 26, //QuestID + ACTION_T_CASTCREATUREGO_ALL = 27, //QuestId, SpellId + ACTION_T_REMOVEAURASFROMSPELL = 28, //Target, Spellid + ACTION_T_RANGED_MOVEMENT = 29, //Distance, Angle + ACTION_T_RANDOM_PHASE = 30, //PhaseId1, PhaseId2, PhaseId3 + ACTION_T_RANDOM_PHASE_RANGE = 31, //PhaseMin, PhaseMax + ACTION_T_SUMMON_ID = 32, //CreatureId, Target, SpawnId + ACTION_T_KILLED_MONSTER = 33, //CreatureId, Target + ACTION_T_SET_INST_DATA = 34, //Field, Data + ACTION_T_SET_INST_DATA64 = 35, //Field, Target + ACTION_T_UPDATE_TEMPLATE = 36, //Entry, Team + ACTION_T_DIE = 37, //No Params + ACTION_T_ZONE_COMBAT_PULSE = 38, //No Params + + ACTION_T_END, +}; + +enum Target +{ + //Self (m_creature) + TARGET_T_SELF = 0, //Self cast + + //Hostile targets (if pet then returns pet owner) + TARGET_T_HOSTILE, //Our current target (ie: highest aggro) + TARGET_T_HOSTILE_SECOND_AGGRO, //Second highest aggro (generaly used for cleaves and some special attacks) + TARGET_T_HOSTILE_LAST_AGGRO, //Dead last on aggro (no idea what this could be used for) + TARGET_T_HOSTILE_RANDOM, //Just any random target on our threat list + TARGET_T_HOSTILE_RANDOM_NOT_TOP, //Any random target except top threat + + //Invoker targets (if pet then returns pet owner) + TARGET_T_ACTION_INVOKER, //Unit who caused this Event to occur (only works for EVENT_T_AGGRO, EVENT_T_KILL, EVENT_T_DEATH, EVENT_T_SPELLHIT, EVENT_T_OOC_LOS, EVENT_T_FRIENDLY_HP, EVENT_T_FRIENDLY_IS_CC, EVENT_T_FRIENDLY_MISSING_BUFF) + + //Hostile targets (including pets) + TARGET_T_HOSTILE_WPET, //Current target (can be a pet) + TARGET_T_HOSTILE_WPET_SECOND_AGGRO, //Second highest aggro (generaly used for cleaves and some special attacks) + TARGET_T_HOSTILE_WPET_LAST_AGGRO, //Dead last on aggro (no idea what this could be used for) + TARGET_T_HOSTILE_WPET_RANDOM, //Just any random target on our threat list + TARGET_T_HOSTILE_WPET_RANDOM_NOT_TOP, //Any random target except top threat + + TARGET_T_ACTION_INVOKER_WPET, + + TARGET_T_END +}; + +enum CastFlags +{ + CAST_INTURRUPT_PREVIOUS = 0x01, //Interrupt any spell casting + CAST_TRIGGERED = 0x02, //Triggered (this makes spell cost zero mana and have no cast time) + CAST_FORCE_CAST = 0x04, //Forces cast even if creature is out of mana or out of range + CAST_NO_MELEE_IF_OOM = 0x08, //Prevents creature from entering melee if out of mana or out of range + CAST_FORCE_TARGET_SELF = 0x10, //Forces the target to cast this spell on itself +}; + +enum EventFlags +{ + EFLAG_REPEATABLE = 0x01, //Event repeats + EFLAG_NORMAL = 0x02, //Event only occurs in Normal instance difficulty + EFLAG_HEROIC = 0x04, //Event only occurs in Heroic instance difficulty + EFLAG_RESERVED_3 = 0x08, + EFLAG_RESERVED_4 = 0x10, + EFLAG_RESERVED_5 = 0x20, + EFLAG_RESERVED_6 = 0x40, + EFLAG_DEBUG_ONLY = 0x80, //Event only occurs in debug build of SD2 only +}; + +struct EventAI_Event +{ + uint32 event_id; + + uint32 creature_id; + + uint16 event_type; + uint32 event_inverse_phase_mask; + uint8 event_chance; + uint8 event_flags; + union + { + uint32 event_param1; + int32 event_param1_s; + }; + union + { + uint32 event_param2; + int32 event_param2_s; + }; + union + { + uint32 event_param3; + int32 event_param3_s; + }; + union + { + uint32 event_param4; + int32 event_param4_s; + }; + + struct _action + { + uint16 type; + union + { + uint32 param1; + int32 param1_s; + }; + union + { + uint32 param2; + int32 param2_s; + }; + union + { + uint32 param3; + int32 param3_s; + }; + }action[MAX_ACTIONS]; +}; + +//Event_Map +extern std::list EventAI_Event_List; + +struct EventAI_Summon +{ + uint32 id; + + float position_x; + float position_y; + float position_z; + float orientation; + uint32 SpawnTimeSecs; +}; + +//EventSummon_Map +extern HM_NAMESPACE::hash_map EventAI_Summon_Map; + +//EventAI Error handling +extern uint32 EAI_ErrorLevel; +/* + +struct EventAI_CreatureError +{ + bool ListEmpty; + bool NoInstance; +}; + +//Error prevention list +extern HM_NAMESPACE::hash_map EventAI_CreatureErrorPreventionList; + +//Defines +#define EVENTAI_EMPTY_EVENTLIST "SD2: Eventlist for Creature %i is empty but creature is using Mob_EventAI. Preventing EventAI on this creature." +*/ +#endif diff --git a/src/bindings/scripts/scripts/creature/mob_generic_creature.cpp b/src/bindings/scripts/scripts/creature/mob_generic_creature.cpp index 6c05ceffc80..74162537fdf 100644 --- a/src/bindings/scripts/scripts/creature/mob_generic_creature.cpp +++ b/src/bindings/scripts/scripts/creature/mob_generic_creature.cpp @@ -1,172 +1,172 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -/* ScriptData -SDName: Generic_Creature -SD%Complete: 80 -SDComment: Should be replaced with core based AI -SDCategory: Creatures -EndScriptData */ - -#include "precompiled.h" - -#define GENERIC_CREATURE_COOLDOWN 5000 - -struct MANGOS_DLL_DECL generic_creatureAI : public ScriptedAI -{ - generic_creatureAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 GlobalCooldown; //This variable acts like the global cooldown that players have (1.5 seconds) - uint32 BuffTimer; //This variable keeps track of buffs - bool IsSelfRooted; - - void Reset() - { - GlobalCooldown = 0; - BuffTimer = 0; //Rebuff as soon as we can - IsSelfRooted = false; - } - - void Aggro(Unit *who) - { - if (!m_creature->IsWithinDistInMap(who, ATTACK_DISTANCE)) - { - IsSelfRooted = true; - } - } - - void UpdateAI(const uint32 diff) - { - //Always decrease our global cooldown first - if (GlobalCooldown > diff) - GlobalCooldown -= diff; - else GlobalCooldown = 0; - - //Buff timer (only buff when we are alive and not in combat - if (!InCombat && m_creature->isAlive()) - if (BuffTimer < diff ) - { - //Find a spell that targets friendly and applies an aura (these are generally buffs) - SpellEntry const *info = SelectSpell(m_creature, -1, -1, SELECT_TARGET_ANY_FRIEND, 0, 0, 0, 0, SELECT_EFFECT_AURA); - - if (info && !GlobalCooldown) - { - //Cast the buff spell - DoCastSpell(m_creature, info); - - //Set our global cooldown - GlobalCooldown = GENERIC_CREATURE_COOLDOWN; - - //Set our timer to 10 minutes before rebuff - BuffTimer = 600000; - }//Try agian in 30 seconds - else BuffTimer = 30000; - }else BuffTimer -= diff; - - //Return since we have no target - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - //If we are within range melee the target - if( m_creature->IsWithinDistInMap(m_creature->getVictim(), ATTACK_DISTANCE)) - { - //Make sure our attack is ready and we arn't currently casting - if( m_creature->isAttackReady() && !m_creature->IsNonMeleeSpellCasted(false)) - { - bool Healing = false; - SpellEntry const *info = NULL; - - //Select a healing spell if less than 30% hp - if (m_creature->GetHealth()*100 / m_creature->GetMaxHealth() < 30) - info = SelectSpell(m_creature, -1, -1, SELECT_TARGET_ANY_FRIEND, 0, 0, 0, 0, SELECT_EFFECT_HEALING); - - //No healing spell available, select a hostile spell - if (info) Healing = true; - else info = SelectSpell(m_creature->getVictim(), -1, -1, SELECT_TARGET_ANY_ENEMY, 0, 0, 0, 0, SELECT_EFFECT_DONTCARE); - - //50% chance if elite or higher, 20% chance if not, to replace our white hit with a spell - if (info && (rand() % (m_creature->GetCreatureInfo()->rank > 1 ? 2 : 5) == 0) && !GlobalCooldown) - { - //Cast the spell - if (Healing)DoCastSpell(m_creature, info); - else DoCastSpell(m_creature->getVictim(), info); - - //Set our global cooldown - GlobalCooldown = GENERIC_CREATURE_COOLDOWN; - } - else m_creature->AttackerStateUpdate(m_creature->getVictim()); - - m_creature->resetAttackTimer(); - } - } - else - { - //Only run this code if we arn't already casting - if (!m_creature->IsNonMeleeSpellCasted(false)) - { - bool Healing = false; - SpellEntry const *info = NULL; - - //Select a healing spell if less than 30% hp ONLY 33% of the time - if (m_creature->GetHealth()*100 / m_creature->GetMaxHealth() < 30 && rand() % 3 == 0) - info = SelectSpell(m_creature, -1, -1, SELECT_TARGET_ANY_FRIEND, 0, 0, 0, 0, SELECT_EFFECT_HEALING); - - //No healing spell available, See if we can cast a ranged spell (Range must be greater than ATTACK_DISTANCE) - if (info) Healing = true; - else info = SelectSpell(m_creature->getVictim(), -1, -1, SELECT_TARGET_ANY_ENEMY, 0, 0, ATTACK_DISTANCE, 0, SELECT_EFFECT_DONTCARE); - - //Found a spell, check if we arn't on cooldown - if (info && !GlobalCooldown) - { - //If we are currently moving stop us and set the movement generator - if (!IsSelfRooted) - { - IsSelfRooted = true; - } - - //Cast spell - if (Healing) DoCastSpell(m_creature,info); - else DoCastSpell(m_creature->getVictim(),info); - - //Set our global cooldown - GlobalCooldown = GENERIC_CREATURE_COOLDOWN; - - - }//If no spells available and we arn't moving run to target - else if (IsSelfRooted) - { - //Cancel our current spell and then allow movement agian - m_creature->InterruptNonMeleeSpells(false); - IsSelfRooted = false; - } - } - } - } -}; -CreatureAI* GetAI_generic_creature(Creature *_Creature) -{ - return new generic_creatureAI (_Creature); -} - - -void AddSC_generic_creature() -{ - Script *newscript; - newscript = new Script; - newscript->Name="generic_creature"; - newscript->GetAI = GetAI_generic_creature; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +/* ScriptData +SDName: Generic_Creature +SD%Complete: 80 +SDComment: Should be replaced with core based AI +SDCategory: Creatures +EndScriptData */ + +#include "precompiled.h" + +#define GENERIC_CREATURE_COOLDOWN 5000 + +struct MANGOS_DLL_DECL generic_creatureAI : public ScriptedAI +{ + generic_creatureAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 GlobalCooldown; //This variable acts like the global cooldown that players have (1.5 seconds) + uint32 BuffTimer; //This variable keeps track of buffs + bool IsSelfRooted; + + void Reset() + { + GlobalCooldown = 0; + BuffTimer = 0; //Rebuff as soon as we can + IsSelfRooted = false; + } + + void Aggro(Unit *who) + { + if (!m_creature->IsWithinDistInMap(who, ATTACK_DISTANCE)) + { + IsSelfRooted = true; + } + } + + void UpdateAI(const uint32 diff) + { + //Always decrease our global cooldown first + if (GlobalCooldown > diff) + GlobalCooldown -= diff; + else GlobalCooldown = 0; + + //Buff timer (only buff when we are alive and not in combat + if (!InCombat && m_creature->isAlive()) + if (BuffTimer < diff ) + { + //Find a spell that targets friendly and applies an aura (these are generally buffs) + SpellEntry const *info = SelectSpell(m_creature, -1, -1, SELECT_TARGET_ANY_FRIEND, 0, 0, 0, 0, SELECT_EFFECT_AURA); + + if (info && !GlobalCooldown) + { + //Cast the buff spell + DoCastSpell(m_creature, info); + + //Set our global cooldown + GlobalCooldown = GENERIC_CREATURE_COOLDOWN; + + //Set our timer to 10 minutes before rebuff + BuffTimer = 600000; + }//Try agian in 30 seconds + else BuffTimer = 30000; + }else BuffTimer -= diff; + + //Return since we have no target + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + //If we are within range melee the target + if( m_creature->IsWithinDistInMap(m_creature->getVictim(), ATTACK_DISTANCE)) + { + //Make sure our attack is ready and we arn't currently casting + if( m_creature->isAttackReady() && !m_creature->IsNonMeleeSpellCasted(false)) + { + bool Healing = false; + SpellEntry const *info = NULL; + + //Select a healing spell if less than 30% hp + if (m_creature->GetHealth()*100 / m_creature->GetMaxHealth() < 30) + info = SelectSpell(m_creature, -1, -1, SELECT_TARGET_ANY_FRIEND, 0, 0, 0, 0, SELECT_EFFECT_HEALING); + + //No healing spell available, select a hostile spell + if (info) Healing = true; + else info = SelectSpell(m_creature->getVictim(), -1, -1, SELECT_TARGET_ANY_ENEMY, 0, 0, 0, 0, SELECT_EFFECT_DONTCARE); + + //50% chance if elite or higher, 20% chance if not, to replace our white hit with a spell + if (info && (rand() % (m_creature->GetCreatureInfo()->rank > 1 ? 2 : 5) == 0) && !GlobalCooldown) + { + //Cast the spell + if (Healing)DoCastSpell(m_creature, info); + else DoCastSpell(m_creature->getVictim(), info); + + //Set our global cooldown + GlobalCooldown = GENERIC_CREATURE_COOLDOWN; + } + else m_creature->AttackerStateUpdate(m_creature->getVictim()); + + m_creature->resetAttackTimer(); + } + } + else + { + //Only run this code if we arn't already casting + if (!m_creature->IsNonMeleeSpellCasted(false)) + { + bool Healing = false; + SpellEntry const *info = NULL; + + //Select a healing spell if less than 30% hp ONLY 33% of the time + if (m_creature->GetHealth()*100 / m_creature->GetMaxHealth() < 30 && rand() % 3 == 0) + info = SelectSpell(m_creature, -1, -1, SELECT_TARGET_ANY_FRIEND, 0, 0, 0, 0, SELECT_EFFECT_HEALING); + + //No healing spell available, See if we can cast a ranged spell (Range must be greater than ATTACK_DISTANCE) + if (info) Healing = true; + else info = SelectSpell(m_creature->getVictim(), -1, -1, SELECT_TARGET_ANY_ENEMY, 0, 0, ATTACK_DISTANCE, 0, SELECT_EFFECT_DONTCARE); + + //Found a spell, check if we arn't on cooldown + if (info && !GlobalCooldown) + { + //If we are currently moving stop us and set the movement generator + if (!IsSelfRooted) + { + IsSelfRooted = true; + } + + //Cast spell + if (Healing) DoCastSpell(m_creature,info); + else DoCastSpell(m_creature->getVictim(),info); + + //Set our global cooldown + GlobalCooldown = GENERIC_CREATURE_COOLDOWN; + + + }//If no spells available and we arn't moving run to target + else if (IsSelfRooted) + { + //Cancel our current spell and then allow movement agian + m_creature->InterruptNonMeleeSpells(false); + IsSelfRooted = false; + } + } + } + } +}; +CreatureAI* GetAI_generic_creature(Creature *_Creature) +{ + return new generic_creatureAI (_Creature); +} + + +void AddSC_generic_creature() +{ + Script *newscript; + newscript = new Script; + newscript->Name="generic_creature"; + newscript->GetAI = GetAI_generic_creature; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/creature/simple_ai.cpp b/src/bindings/scripts/scripts/creature/simple_ai.cpp index e93bfba6425..a341510b63e 100644 --- a/src/bindings/scripts/scripts/creature/simple_ai.cpp +++ b/src/bindings/scripts/scripts/creature/simple_ai.cpp @@ -1,294 +1,294 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -/* ScriptData -SDName: SimpleAI -SD%Complete: 100 -SDComment: Base Class for SimpleAI creatures -SDCategory: Creatures -EndScriptData */ - -#include "precompiled.h" -#include "simple_ai.h" - -SimpleAI::SimpleAI(Creature *c) : ScriptedAI(c) -{ - //Clear all data - Aggro_Text[0] = NULL; - Aggro_Text[1] = NULL; - Aggro_Text[2] = NULL; - Aggro_Say[0] = false; - Aggro_Say[1] = false; - Aggro_Say[2] = false; - Aggro_Sound[0] = 0; - Aggro_Sound[1] = 0; - Aggro_Sound[2] = 0; - - Death_Text[0] = NULL; - Death_Text[1] = NULL; - Death_Text[2] = NULL; - Death_Say[0] = false; - Death_Say[1] = false; - Death_Say[2] = false; - Death_Sound[0] = 0; - Death_Sound[1] = 0; - Death_Sound[2] = 0; - Death_Spell = 0; - Death_Target_Type = 0; - - Kill_Text[0] = NULL; - Kill_Text[1] = NULL; - Kill_Text[2] = NULL; - Kill_Say[0] = false; - Kill_Say[1] = false; - Kill_Say[2] = false; - Kill_Sound[0] = 0; - Kill_Sound[1] = 0; - Kill_Sound[2] = 0; - Kill_Spell = 0; - Kill_Target_Type = 0; - - memset(Spell,0,sizeof(Spell)); - - EnterEvadeMode(); -} - -void SimpleAI::Reset() -{ -} - -void SimpleAI::Aggro(Unit *who) -{ - //Reset cast timers - if (Spell[0].First_Cast >= 0) - Spell_Timer[0] = Spell[0].First_Cast; - else Spell_Timer[0] = 1000; - if (Spell[1].First_Cast >= 0) - Spell_Timer[1] = Spell[1].First_Cast; - else Spell_Timer[1] = 1000; - if (Spell[2].First_Cast >= 0) - Spell_Timer[2] = Spell[2].First_Cast; - else Spell_Timer[2] = 1000; - if (Spell[3].First_Cast >= 0) - Spell_Timer[3] = Spell[3].First_Cast; - else Spell_Timer[3] = 1000; - if (Spell[4].First_Cast >= 0) - Spell_Timer[4] = Spell[4].First_Cast; - else Spell_Timer[4] = 1000; - if (Spell[5].First_Cast >= 0) - Spell_Timer[5] = Spell[5].First_Cast; - else Spell_Timer[5] = 1000; - if (Spell[6].First_Cast >= 0) - Spell_Timer[6] = Spell[6].First_Cast; - else Spell_Timer[6] = 1000; - if (Spell[7].First_Cast >= 0) - Spell_Timer[7] = Spell[7].First_Cast; - else Spell_Timer[7] = 1000; - if (Spell[8].First_Cast >= 0) - Spell_Timer[8] = Spell[8].First_Cast; - else Spell_Timer[8] = 1000; - if (Spell[9].First_Cast >= 0) - Spell_Timer[9] = Spell[9].First_Cast; - else Spell_Timer[9] = 1000; - - uint32 random_text = rand()%3; - - //Random yell - if (Aggro_Text[random_text]) - if (Aggro_Say[random_text]) - DoSay(Aggro_Text[random_text], LANG_UNIVERSAL, who); - else DoYell(Aggro_Text[random_text], LANG_UNIVERSAL, who); - - //Random sound - if (Aggro_Sound[random_text]) - DoPlaySoundToSet(m_creature, Aggro_Sound[random_text]); -} - -void SimpleAI::KilledUnit(Unit *victim) -{ - uint32 random_text = rand()%3; - - //Random yell - if (Kill_Text[random_text]) - if (Kill_Say[random_text]) - DoSay(Kill_Text[random_text], LANG_UNIVERSAL, victim); - else DoYell(Kill_Text[random_text], LANG_UNIVERSAL, victim); - - //Random sound - if (Kill_Sound[random_text]) - DoPlaySoundToSet(m_creature, Kill_Sound[random_text]); - - if (!Kill_Spell) - return; - - Unit* target = NULL; - - switch (Kill_Target_Type) - { - case CAST_SELF: - target = m_creature; - break; - case CAST_HOSTILE_TARGET: - target = m_creature->getVictim(); - break; - case CAST_HOSTILE_SECOND_AGGRO: - target = SelectUnit(SELECT_TARGET_TOPAGGRO,1); - break; - case CAST_HOSTILE_LAST_AGGRO: - target = SelectUnit(SELECT_TARGET_BOTTOMAGGRO,0); - break; - case CAST_HOSTILE_RANDOM: - target = SelectUnit(SELECT_TARGET_RANDOM,0); - break; - case CAST_KILLEDUNIT_VICTIM: - target = victim; - break; - } - - //Target is ok, cast a spell on it - if (target) - DoCast(target, Kill_Spell); -} - -void SimpleAI::DamageTaken(Unit *killer, uint32 &damage) -{ - //Return if damage taken won't kill us - if (m_creature->GetHealth() > damage) - return; - - uint32 random_text = rand()%3; - - //Random yell - if (Death_Text[random_text]) - if (Death_Say[random_text]) - DoSay(Death_Text[random_text], LANG_UNIVERSAL, killer); - else DoYell(Death_Text[random_text], LANG_UNIVERSAL, killer); - - //Random sound - if (Death_Sound[random_text]) - DoPlaySoundToSet(m_creature, Death_Sound[random_text]); - - if (!Death_Spell) - return; - - Unit* target = NULL; - - switch (Death_Target_Type) - { - case CAST_SELF: - target = m_creature; - break; - case CAST_HOSTILE_TARGET: - target = m_creature->getVictim(); - break; - case CAST_HOSTILE_SECOND_AGGRO: - target = SelectUnit(SELECT_TARGET_TOPAGGRO,1); - break; - case CAST_HOSTILE_LAST_AGGRO: - target = SelectUnit(SELECT_TARGET_BOTTOMAGGRO,0); - break; - case CAST_HOSTILE_RANDOM: - target = SelectUnit(SELECT_TARGET_RANDOM,0); - break; - case CAST_JUSTDIED_KILLER: - target = killer; - break; - } - - //Target is ok, cast a spell on it - if (target) - DoCast(target, Death_Spell); -} - -void SimpleAI::UpdateAI(const uint32 diff) -{ - //Return since we have no target - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - //Spells - for (uint32 i = 0; i < 10; ++i) - { - //Spell not valid - if (!Spell[i].Enabled || !Spell[i].Spell_Id) - continue; - - if (Spell_Timer[i] < diff) - { - //Check if this is a percentage based - if (Spell[i].First_Cast < 0 && Spell[i].First_Cast > -100 && m_creature->GetHealth()*100 / m_creature->GetMaxHealth() > -Spell[i].First_Cast) - continue; - - //Check Current spell - if (!(Spell[i].InterruptPreviousCast && m_creature->IsNonMeleeSpellCasted(false))) - { - Unit* target = NULL; - - switch (Spell[i].Cast_Target_Type) - { - case CAST_SELF: - target = m_creature; - break; - case CAST_HOSTILE_TARGET: - target = m_creature->getVictim(); - break; - case CAST_HOSTILE_SECOND_AGGRO: - target = SelectUnit(SELECT_TARGET_TOPAGGRO,1); - break; - case CAST_HOSTILE_LAST_AGGRO: - target = SelectUnit(SELECT_TARGET_BOTTOMAGGRO,0); - break; - case CAST_HOSTILE_RANDOM: - target = SelectUnit(SELECT_TARGET_RANDOM,0); - break; - } - - //Target is ok, cast a spell on it and then do our random yell - if (target) - { - if (m_creature->IsNonMeleeSpellCasted(false)) - m_creature->InterruptNonMeleeSpells(false); - - DoCast(target, Spell[i].Spell_Id); - - //Yell and sound use the same number so that you can make - //the creature yell with the correct sound effect attached - uint32 random_text = rand()%3; - - //Random yell - if (Spell[i].Text[random_text]) - if (Spell[i].Say[random_text]) - DoSay(Spell[i].Text[random_text], LANG_UNIVERSAL, target); - else DoYell(Spell[i].Text[random_text], LANG_UNIVERSAL, target); - - //Random sound - if (Spell[i].Text_Sound[random_text]) - DoPlaySoundToSet(m_creature, Spell[i].Text_Sound[random_text]); - } - - } - - //Spell will cast agian when the cooldown is up - if (Spell[i].CooldownRandomAddition) - Spell_Timer[i] = Spell[i].Cooldown + (rand() % Spell[i].CooldownRandomAddition); - else Spell_Timer[i] = Spell[i].Cooldown; - - }else Spell_Timer[i] -= diff; - - } - - DoMeleeAttackIfReady(); -} +/* Copyright (C) 2006 - 2008 ScriptDev2 +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +/* ScriptData +SDName: SimpleAI +SD%Complete: 100 +SDComment: Base Class for SimpleAI creatures +SDCategory: Creatures +EndScriptData */ + +#include "precompiled.h" +#include "simple_ai.h" + +SimpleAI::SimpleAI(Creature *c) : ScriptedAI(c) +{ + //Clear all data + Aggro_Text[0] = NULL; + Aggro_Text[1] = NULL; + Aggro_Text[2] = NULL; + Aggro_Say[0] = false; + Aggro_Say[1] = false; + Aggro_Say[2] = false; + Aggro_Sound[0] = 0; + Aggro_Sound[1] = 0; + Aggro_Sound[2] = 0; + + Death_Text[0] = NULL; + Death_Text[1] = NULL; + Death_Text[2] = NULL; + Death_Say[0] = false; + Death_Say[1] = false; + Death_Say[2] = false; + Death_Sound[0] = 0; + Death_Sound[1] = 0; + Death_Sound[2] = 0; + Death_Spell = 0; + Death_Target_Type = 0; + + Kill_Text[0] = NULL; + Kill_Text[1] = NULL; + Kill_Text[2] = NULL; + Kill_Say[0] = false; + Kill_Say[1] = false; + Kill_Say[2] = false; + Kill_Sound[0] = 0; + Kill_Sound[1] = 0; + Kill_Sound[2] = 0; + Kill_Spell = 0; + Kill_Target_Type = 0; + + memset(Spell,0,sizeof(Spell)); + + EnterEvadeMode(); +} + +void SimpleAI::Reset() +{ +} + +void SimpleAI::Aggro(Unit *who) +{ + //Reset cast timers + if (Spell[0].First_Cast >= 0) + Spell_Timer[0] = Spell[0].First_Cast; + else Spell_Timer[0] = 1000; + if (Spell[1].First_Cast >= 0) + Spell_Timer[1] = Spell[1].First_Cast; + else Spell_Timer[1] = 1000; + if (Spell[2].First_Cast >= 0) + Spell_Timer[2] = Spell[2].First_Cast; + else Spell_Timer[2] = 1000; + if (Spell[3].First_Cast >= 0) + Spell_Timer[3] = Spell[3].First_Cast; + else Spell_Timer[3] = 1000; + if (Spell[4].First_Cast >= 0) + Spell_Timer[4] = Spell[4].First_Cast; + else Spell_Timer[4] = 1000; + if (Spell[5].First_Cast >= 0) + Spell_Timer[5] = Spell[5].First_Cast; + else Spell_Timer[5] = 1000; + if (Spell[6].First_Cast >= 0) + Spell_Timer[6] = Spell[6].First_Cast; + else Spell_Timer[6] = 1000; + if (Spell[7].First_Cast >= 0) + Spell_Timer[7] = Spell[7].First_Cast; + else Spell_Timer[7] = 1000; + if (Spell[8].First_Cast >= 0) + Spell_Timer[8] = Spell[8].First_Cast; + else Spell_Timer[8] = 1000; + if (Spell[9].First_Cast >= 0) + Spell_Timer[9] = Spell[9].First_Cast; + else Spell_Timer[9] = 1000; + + uint32 random_text = rand()%3; + + //Random yell + if (Aggro_Text[random_text]) + if (Aggro_Say[random_text]) + DoSay(Aggro_Text[random_text], LANG_UNIVERSAL, who); + else DoYell(Aggro_Text[random_text], LANG_UNIVERSAL, who); + + //Random sound + if (Aggro_Sound[random_text]) + DoPlaySoundToSet(m_creature, Aggro_Sound[random_text]); +} + +void SimpleAI::KilledUnit(Unit *victim) +{ + uint32 random_text = rand()%3; + + //Random yell + if (Kill_Text[random_text]) + if (Kill_Say[random_text]) + DoSay(Kill_Text[random_text], LANG_UNIVERSAL, victim); + else DoYell(Kill_Text[random_text], LANG_UNIVERSAL, victim); + + //Random sound + if (Kill_Sound[random_text]) + DoPlaySoundToSet(m_creature, Kill_Sound[random_text]); + + if (!Kill_Spell) + return; + + Unit* target = NULL; + + switch (Kill_Target_Type) + { + case CAST_SELF: + target = m_creature; + break; + case CAST_HOSTILE_TARGET: + target = m_creature->getVictim(); + break; + case CAST_HOSTILE_SECOND_AGGRO: + target = SelectUnit(SELECT_TARGET_TOPAGGRO,1); + break; + case CAST_HOSTILE_LAST_AGGRO: + target = SelectUnit(SELECT_TARGET_BOTTOMAGGRO,0); + break; + case CAST_HOSTILE_RANDOM: + target = SelectUnit(SELECT_TARGET_RANDOM,0); + break; + case CAST_KILLEDUNIT_VICTIM: + target = victim; + break; + } + + //Target is ok, cast a spell on it + if (target) + DoCast(target, Kill_Spell); +} + +void SimpleAI::DamageTaken(Unit *killer, uint32 &damage) +{ + //Return if damage taken won't kill us + if (m_creature->GetHealth() > damage) + return; + + uint32 random_text = rand()%3; + + //Random yell + if (Death_Text[random_text]) + if (Death_Say[random_text]) + DoSay(Death_Text[random_text], LANG_UNIVERSAL, killer); + else DoYell(Death_Text[random_text], LANG_UNIVERSAL, killer); + + //Random sound + if (Death_Sound[random_text]) + DoPlaySoundToSet(m_creature, Death_Sound[random_text]); + + if (!Death_Spell) + return; + + Unit* target = NULL; + + switch (Death_Target_Type) + { + case CAST_SELF: + target = m_creature; + break; + case CAST_HOSTILE_TARGET: + target = m_creature->getVictim(); + break; + case CAST_HOSTILE_SECOND_AGGRO: + target = SelectUnit(SELECT_TARGET_TOPAGGRO,1); + break; + case CAST_HOSTILE_LAST_AGGRO: + target = SelectUnit(SELECT_TARGET_BOTTOMAGGRO,0); + break; + case CAST_HOSTILE_RANDOM: + target = SelectUnit(SELECT_TARGET_RANDOM,0); + break; + case CAST_JUSTDIED_KILLER: + target = killer; + break; + } + + //Target is ok, cast a spell on it + if (target) + DoCast(target, Death_Spell); +} + +void SimpleAI::UpdateAI(const uint32 diff) +{ + //Return since we have no target + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + //Spells + for (uint32 i = 0; i < 10; ++i) + { + //Spell not valid + if (!Spell[i].Enabled || !Spell[i].Spell_Id) + continue; + + if (Spell_Timer[i] < diff) + { + //Check if this is a percentage based + if (Spell[i].First_Cast < 0 && Spell[i].First_Cast > -100 && m_creature->GetHealth()*100 / m_creature->GetMaxHealth() > -Spell[i].First_Cast) + continue; + + //Check Current spell + if (!(Spell[i].InterruptPreviousCast && m_creature->IsNonMeleeSpellCasted(false))) + { + Unit* target = NULL; + + switch (Spell[i].Cast_Target_Type) + { + case CAST_SELF: + target = m_creature; + break; + case CAST_HOSTILE_TARGET: + target = m_creature->getVictim(); + break; + case CAST_HOSTILE_SECOND_AGGRO: + target = SelectUnit(SELECT_TARGET_TOPAGGRO,1); + break; + case CAST_HOSTILE_LAST_AGGRO: + target = SelectUnit(SELECT_TARGET_BOTTOMAGGRO,0); + break; + case CAST_HOSTILE_RANDOM: + target = SelectUnit(SELECT_TARGET_RANDOM,0); + break; + } + + //Target is ok, cast a spell on it and then do our random yell + if (target) + { + if (m_creature->IsNonMeleeSpellCasted(false)) + m_creature->InterruptNonMeleeSpells(false); + + DoCast(target, Spell[i].Spell_Id); + + //Yell and sound use the same number so that you can make + //the creature yell with the correct sound effect attached + uint32 random_text = rand()%3; + + //Random yell + if (Spell[i].Text[random_text]) + if (Spell[i].Say[random_text]) + DoSay(Spell[i].Text[random_text], LANG_UNIVERSAL, target); + else DoYell(Spell[i].Text[random_text], LANG_UNIVERSAL, target); + + //Random sound + if (Spell[i].Text_Sound[random_text]) + DoPlaySoundToSet(m_creature, Spell[i].Text_Sound[random_text]); + } + + } + + //Spell will cast agian when the cooldown is up + if (Spell[i].CooldownRandomAddition) + Spell_Timer[i] = Spell[i].Cooldown + (rand() % Spell[i].CooldownRandomAddition); + else Spell_Timer[i] = Spell[i].Cooldown; + + }else Spell_Timer[i] -= diff; + + } + + DoMeleeAttackIfReady(); +} diff --git a/src/bindings/scripts/scripts/creature/simple_ai.h b/src/bindings/scripts/scripts/creature/simple_ai.h index 0ac78dc1222..74cd6e1d56b 100644 --- a/src/bindings/scripts/scripts/creature/simple_ai.h +++ b/src/bindings/scripts/scripts/creature/simple_ai.h @@ -1,74 +1,74 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 -* This program is free software licensed under GPL version 2 -* Please see the included DOCS/LICENSE.TXT for more information */ - -#ifndef SC_SIMPLEAI_H -#define SC_SIMPLEAI_H - -enum CastTarget -{ - CAST_SELF = 0, //Self cast - CAST_HOSTILE_TARGET, //Our current target (ie: highest aggro) - CAST_HOSTILE_SECOND_AGGRO, //Second highest aggro (generaly used for cleaves and some special attacks) - CAST_HOSTILE_LAST_AGGRO, //Dead last on aggro (no idea what this could be used for) - CAST_HOSTILE_RANDOM, //Just any random target on our threat list - CAST_FRIENDLY_RANDOM, //NOT YET IMPLEMENTED - - //Special cases - CAST_KILLEDUNIT_VICTIM, //Only works within KilledUnit function - CAST_JUSTDIED_KILLER, //Only works within JustDied function -}; - -struct MANGOS_DLL_DECL SimpleAI : public ScriptedAI -{ - SimpleAI(Creature *c);// : ScriptedAI(c); - - void Reset(); - - void Aggro(Unit *who); - - void KilledUnit(Unit *victim); - - void DamageTaken(Unit *killer, uint32 &damage); - - void UpdateAI(const uint32 diff); - -public: - - char* Aggro_Text[3]; - bool Aggro_Say[3]; - uint32 Aggro_Sound[3]; - - char* Death_Text[3]; - bool Death_Say[3]; - uint32 Death_Sound[3]; - uint32 Death_Spell; - uint32 Death_Target_Type; - - char* Kill_Text[3]; - bool Kill_Say[3]; - uint32 Kill_Sound[3]; - uint32 Kill_Spell; - uint32 Kill_Target_Type; - - struct SimpleAI_Spell - { - uint32 Spell_Id; //Spell ID to cast - int32 First_Cast; //Delay for first cast - uint32 Cooldown; //Cooldown between casts - uint32 CooldownRandomAddition; //Random addition to cooldown (in range from 0 - CooldownRandomAddition) - uint32 Cast_Target_Type; //Target type (note that certain spells may ignore this) - bool InterruptPreviousCast; //Interrupt a previous cast if this spell needs to be cast - bool Enabled; //Spell enabled or disabled (default: false) - - //3 texts to many? - char* Text[3]; - bool Say[3]; - uint32 Text_Sound[3]; - }Spell[10]; - -protected: - uint32 Spell_Timer[10]; -}; - -#endif +/* Copyright (C) 2006 - 2008 ScriptDev2 +* This program is free software licensed under GPL version 2 +* Please see the included DOCS/LICENSE.TXT for more information */ + +#ifndef SC_SIMPLEAI_H +#define SC_SIMPLEAI_H + +enum CastTarget +{ + CAST_SELF = 0, //Self cast + CAST_HOSTILE_TARGET, //Our current target (ie: highest aggro) + CAST_HOSTILE_SECOND_AGGRO, //Second highest aggro (generaly used for cleaves and some special attacks) + CAST_HOSTILE_LAST_AGGRO, //Dead last on aggro (no idea what this could be used for) + CAST_HOSTILE_RANDOM, //Just any random target on our threat list + CAST_FRIENDLY_RANDOM, //NOT YET IMPLEMENTED + + //Special cases + CAST_KILLEDUNIT_VICTIM, //Only works within KilledUnit function + CAST_JUSTDIED_KILLER, //Only works within JustDied function +}; + +struct MANGOS_DLL_DECL SimpleAI : public ScriptedAI +{ + SimpleAI(Creature *c);// : ScriptedAI(c); + + void Reset(); + + void Aggro(Unit *who); + + void KilledUnit(Unit *victim); + + void DamageTaken(Unit *killer, uint32 &damage); + + void UpdateAI(const uint32 diff); + +public: + + char* Aggro_Text[3]; + bool Aggro_Say[3]; + uint32 Aggro_Sound[3]; + + char* Death_Text[3]; + bool Death_Say[3]; + uint32 Death_Sound[3]; + uint32 Death_Spell; + uint32 Death_Target_Type; + + char* Kill_Text[3]; + bool Kill_Say[3]; + uint32 Kill_Sound[3]; + uint32 Kill_Spell; + uint32 Kill_Target_Type; + + struct SimpleAI_Spell + { + uint32 Spell_Id; //Spell ID to cast + int32 First_Cast; //Delay for first cast + uint32 Cooldown; //Cooldown between casts + uint32 CooldownRandomAddition; //Random addition to cooldown (in range from 0 - CooldownRandomAddition) + uint32 Cast_Target_Type; //Target type (note that certain spells may ignore this) + bool InterruptPreviousCast; //Interrupt a previous cast if this spell needs to be cast + bool Enabled; //Spell enabled or disabled (default: false) + + //3 texts to many? + char* Text[3]; + bool Say[3]; + uint32 Text_Sound[3]; + }Spell[10]; + +protected: + uint32 Spell_Timer[10]; +}; + +#endif diff --git a/src/bindings/scripts/scripts/custom/custom_example.cpp b/src/bindings/scripts/scripts/custom/custom_example.cpp index e6cdd2f8e62..9a185612d37 100644 --- a/src/bindings/scripts/scripts/custom/custom_example.cpp +++ b/src/bindings/scripts/scripts/custom/custom_example.cpp @@ -1,277 +1,277 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Custom_Example -SD%Complete: 100 -SDComment: Short custom scripting example -SDCategory: Script Examples -EndScriptData */ - -#include "precompiled.h" - -// **** This script is designed as an example for others to build on **** -// **** Please modify whatever you'd like to as this script is only for developement **** - -// **** Script Info **** -// This script is written in a way that it can be used for both friendly and hostile monsters -// Its primary purpose is to show just how much you can really do with scripts -// I recommend trying it out on both an agressive NPC and on friendly npc - -// **** Quick Info **** -// Functions with Handled Function marked above them are functions that are called automatically by the core -// Functions that are marked Custom Function are functions I've created to simplify code - -#define SPELL_BUFF 25661 -#define SPELL_ONE 12555 -#define SPELL_ONE_ALT 24099 -#define SPELL_TWO 10017 -#define SPELL_THREE 26027 -#define SPELL_ENRAGE 23537 -#define SPELL_BESERK 32309 - -#define SAY_AGGRO "Let the games begin." -#define SAY_RANDOM_0 "I see endless suffering. I see torment. I see rage. I see everything." -#define SAY_RANDOM_1 "Muahahahaha" -#define SAY_RANDOM_2 "These mortal infedels my lord, they have invaded your sanctum and seek to steal your secrets." -#define SAY_RANDOM_3 "You are already dead." -#define SAY_RANDOM_4 "Where to go? What to do? So many choices that all end in pain, end in death." -#define SAY_BESERK "$N, I sentance you to death!" -#define SAY_PHASE "The suffering has just begun!" - -#define GOSSIP_ITEM "I'm looking for a fight" -#define SAY_DANCE "I always thought I was a good dancer" -#define SAY_SALUTE "Move out Soldier!" - -struct MANGOS_DLL_DECL custom_exampleAI : public ScriptedAI -{ - //*** HANDLED FUNCTION *** - //This is the constructor, called only once when the creature is first created - custom_exampleAI(Creature *c) : ScriptedAI(c) {Reset();} - - //*** CUSTOM VARIABLES **** - //These variables are for use only by this individual script. - //Nothing else will ever call them but us. - - uint32 Say_Timer; //Timer for random chat - uint32 Rebuff_Timer; //Timer for rebuffing - uint32 Spell_1_Timer; //Timer for spell 1 when in combat - uint32 Spell_2_Timer; //Timer for spell 1 when in combat - uint32 Spell_3_Timer; //Timer for spell 1 when in combat - uint32 Beserk_Timer; //Timer until we go into Beserk (enraged) mode - uint32 Phase; //The current battle phase we are in - uint32 Phase_Timer; //Timer until phase transition - - //*** HANDLED FUNCTION *** - //This is called whenever the core decides we need to evade - void Reset() - { - Phase = 1; //Start in phase 1 - Phase_Timer = 60000; //60 seconds - Spell_1_Timer = 5000; //5 seconds - Spell_2_Timer = 37000; //37 seconds - Spell_3_Timer = 19000; //19 seconds - Beserk_Timer = 120000; //2 minutes - } - - //*** HANDLED FUNCTION *** - //Attack Start is called whenever someone hits us. - void Aggro(Unit *who) - { - //Say some stuff - DoSay(SAY_AGGRO,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,8280); - } - - //*** HANDLED FUNCTION *** - //Update AI is called Every single map update (roughly once every 100ms if a player is within the grid) - void UpdateAI(const uint32 diff) - { - //Out of combat timers - if (!m_creature->getVictim()) - { - //Random Say timer - if (Say_Timer < diff) - { - //Random switch between 5 outcomes - switch (rand()%5) - { - case 0: - DoYell(SAY_RANDOM_0,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,8831); //8831 is the index of the sound we are playing. You find these numbers in SoundEntries.dbc - break; - - case 1: - DoYell(SAY_RANDOM_1,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,8818); - break; - - case 2: - DoYell(SAY_RANDOM_2,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,8041); - break; - - case 3: - DoYell(SAY_RANDOM_3,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,8581); - break; - - case 4: - DoYell(SAY_RANDOM_4,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,8791); - break; - } - - Say_Timer = 45000; //Say something agian in 45 seconds - }else Say_Timer -= diff; - - //Rebuff timer - if (Rebuff_Timer < diff) - { - DoCast(m_creature,SPELL_BUFF); - Rebuff_Timer = 900000; //Rebuff agian in 15 minutes - }else Rebuff_Timer -= diff; - } - - //Return since we have no target - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - //Spell 1 timer - if (Spell_1_Timer < diff) - { - //Cast spell one on our current target. - if (rand()%50 > 10) - DoCast(m_creature->getVictim(),SPELL_ONE_ALT); - else if (m_creature->GetDistance(m_creature->getVictim()) < 25) - DoCast(m_creature->getVictim(),SPELL_ONE); - - Spell_1_Timer = 5000; - }else Spell_1_Timer -= diff; - - //Spell 2 timer - if (Spell_2_Timer < diff) - { - //Cast spell one on our current target. - DoCast(m_creature->getVictim(),SPELL_TWO); - - Spell_2_Timer = 37000; - }else Spell_2_Timer -= diff; - - //Spell 3 timer - if (Phase > 1) - if (Spell_3_Timer < diff) - { - //Cast spell one on our current target. - DoCast(m_creature->getVictim(),SPELL_THREE); - - Spell_3_Timer = 19000; - }else Spell_3_Timer -= diff; - - //Beserk timer - if (Phase > 1) - if (Beserk_Timer < diff) - { - //Say our line then cast uber death spell - DoPlaySoundToSet(m_creature,8588); - DoYell(SAY_BESERK,LANG_UNIVERSAL,m_creature->getVictim()); - DoCast(m_creature->getVictim(),SPELL_BESERK); - - //Cast our beserk spell agian in 12 seconds if we didn't kill everyone - Beserk_Timer = 12000; - }else Beserk_Timer -= diff; - - //Phase timer - if (Phase == 1) - if (Phase_Timer < diff) - { - //Go to next phase - Phase++; - DoYell(SAY_PHASE,LANG_UNIVERSAL,NULL); - DoCast(m_creature,SPELL_ENRAGE); - }else Phase_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; - -//This is the GetAI method used by all scripts that involve AI -//It is called every time a new creature using this script is created -CreatureAI* GetAI_custom_example(Creature *_Creature) -{ - return new custom_exampleAI (_Creature); -} - -//This function is called when the player clicks an option on the gossip menu -void SendDefaultMenu_custom_example(Player *player, Creature *_Creature, uint32 action) -{ - if (action == GOSSIP_ACTION_INFO_DEF + 1) //Fight time - { - //Set our faction to hostile twoards all - _Creature->setFaction(24); - _Creature->Attack(player, true); - player->PlayerTalkClass->CloseGossip(); - } -} - -//This function is called when the player clicks an option on the gossip menu -bool GossipSelect_custom_example(Player *player, Creature *_Creature, uint32 sender, uint32 action ) -{ - if (sender == GOSSIP_SENDER_MAIN) - SendDefaultMenu_custom_example(player, _Creature, action); - - return true; -} - -//This function is called when the player opens the gossip menu -bool GossipHello_custom_example(Player *player, Creature *_Creature) -{ - player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); - player->PlayerTalkClass->SendGossipMenu(907,_Creature->GetGUID()); - - return true; -} - -//Our Recive emote function -bool ReceiveEmote_custom_example(Player *player, Creature *_Creature, uint32 emote) -{ - _Creature->HandleEmoteCommand(emote); - - if (emote == TEXTEMOTE_DANCE) - ((custom_exampleAI*)_Creature->AI())->DoSay(SAY_DANCE,LANG_UNIVERSAL,NULL); - - if (emote == TEXTEMOTE_SALUTE) - ((custom_exampleAI*)_Creature->AI())->DoSay(SAY_SALUTE,LANG_UNIVERSAL,NULL); - - return true; -} - -//This is the actual function called only once durring InitScripts() -//It must define all handled functions that are to be run in this script -//For example if you want this Script to handle Emotes you must include -//newscript->ReciveEmote = My_Emote_Function; -void AddSC_custom_example() -{ - Script *newscript; - - newscript = new Script; - newscript->Name="custom_example"; - newscript->GetAI = GetAI_custom_example; - newscript->pGossipHello = &GossipHello_custom_example; - newscript->pGossipSelect = &GossipSelect_custom_example; - newscript->pReceiveEmote = &ReceiveEmote_custom_example; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Custom_Example +SD%Complete: 100 +SDComment: Short custom scripting example +SDCategory: Script Examples +EndScriptData */ + +#include "precompiled.h" + +// **** This script is designed as an example for others to build on **** +// **** Please modify whatever you'd like to as this script is only for developement **** + +// **** Script Info **** +// This script is written in a way that it can be used for both friendly and hostile monsters +// Its primary purpose is to show just how much you can really do with scripts +// I recommend trying it out on both an agressive NPC and on friendly npc + +// **** Quick Info **** +// Functions with Handled Function marked above them are functions that are called automatically by the core +// Functions that are marked Custom Function are functions I've created to simplify code + +#define SPELL_BUFF 25661 +#define SPELL_ONE 12555 +#define SPELL_ONE_ALT 24099 +#define SPELL_TWO 10017 +#define SPELL_THREE 26027 +#define SPELL_ENRAGE 23537 +#define SPELL_BESERK 32309 + +#define SAY_AGGRO "Let the games begin." +#define SAY_RANDOM_0 "I see endless suffering. I see torment. I see rage. I see everything." +#define SAY_RANDOM_1 "Muahahahaha" +#define SAY_RANDOM_2 "These mortal infedels my lord, they have invaded your sanctum and seek to steal your secrets." +#define SAY_RANDOM_3 "You are already dead." +#define SAY_RANDOM_4 "Where to go? What to do? So many choices that all end in pain, end in death." +#define SAY_BESERK "$N, I sentance you to death!" +#define SAY_PHASE "The suffering has just begun!" + +#define GOSSIP_ITEM "I'm looking for a fight" +#define SAY_DANCE "I always thought I was a good dancer" +#define SAY_SALUTE "Move out Soldier!" + +struct MANGOS_DLL_DECL custom_exampleAI : public ScriptedAI +{ + //*** HANDLED FUNCTION *** + //This is the constructor, called only once when the creature is first created + custom_exampleAI(Creature *c) : ScriptedAI(c) {Reset();} + + //*** CUSTOM VARIABLES **** + //These variables are for use only by this individual script. + //Nothing else will ever call them but us. + + uint32 Say_Timer; //Timer for random chat + uint32 Rebuff_Timer; //Timer for rebuffing + uint32 Spell_1_Timer; //Timer for spell 1 when in combat + uint32 Spell_2_Timer; //Timer for spell 1 when in combat + uint32 Spell_3_Timer; //Timer for spell 1 when in combat + uint32 Beserk_Timer; //Timer until we go into Beserk (enraged) mode + uint32 Phase; //The current battle phase we are in + uint32 Phase_Timer; //Timer until phase transition + + //*** HANDLED FUNCTION *** + //This is called whenever the core decides we need to evade + void Reset() + { + Phase = 1; //Start in phase 1 + Phase_Timer = 60000; //60 seconds + Spell_1_Timer = 5000; //5 seconds + Spell_2_Timer = 37000; //37 seconds + Spell_3_Timer = 19000; //19 seconds + Beserk_Timer = 120000; //2 minutes + } + + //*** HANDLED FUNCTION *** + //Attack Start is called whenever someone hits us. + void Aggro(Unit *who) + { + //Say some stuff + DoSay(SAY_AGGRO,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,8280); + } + + //*** HANDLED FUNCTION *** + //Update AI is called Every single map update (roughly once every 100ms if a player is within the grid) + void UpdateAI(const uint32 diff) + { + //Out of combat timers + if (!m_creature->getVictim()) + { + //Random Say timer + if (Say_Timer < diff) + { + //Random switch between 5 outcomes + switch (rand()%5) + { + case 0: + DoYell(SAY_RANDOM_0,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,8831); //8831 is the index of the sound we are playing. You find these numbers in SoundEntries.dbc + break; + + case 1: + DoYell(SAY_RANDOM_1,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,8818); + break; + + case 2: + DoYell(SAY_RANDOM_2,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,8041); + break; + + case 3: + DoYell(SAY_RANDOM_3,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,8581); + break; + + case 4: + DoYell(SAY_RANDOM_4,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,8791); + break; + } + + Say_Timer = 45000; //Say something agian in 45 seconds + }else Say_Timer -= diff; + + //Rebuff timer + if (Rebuff_Timer < diff) + { + DoCast(m_creature,SPELL_BUFF); + Rebuff_Timer = 900000; //Rebuff agian in 15 minutes + }else Rebuff_Timer -= diff; + } + + //Return since we have no target + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + //Spell 1 timer + if (Spell_1_Timer < diff) + { + //Cast spell one on our current target. + if (rand()%50 > 10) + DoCast(m_creature->getVictim(),SPELL_ONE_ALT); + else if (m_creature->GetDistance(m_creature->getVictim()) < 25) + DoCast(m_creature->getVictim(),SPELL_ONE); + + Spell_1_Timer = 5000; + }else Spell_1_Timer -= diff; + + //Spell 2 timer + if (Spell_2_Timer < diff) + { + //Cast spell one on our current target. + DoCast(m_creature->getVictim(),SPELL_TWO); + + Spell_2_Timer = 37000; + }else Spell_2_Timer -= diff; + + //Spell 3 timer + if (Phase > 1) + if (Spell_3_Timer < diff) + { + //Cast spell one on our current target. + DoCast(m_creature->getVictim(),SPELL_THREE); + + Spell_3_Timer = 19000; + }else Spell_3_Timer -= diff; + + //Beserk timer + if (Phase > 1) + if (Beserk_Timer < diff) + { + //Say our line then cast uber death spell + DoPlaySoundToSet(m_creature,8588); + DoYell(SAY_BESERK,LANG_UNIVERSAL,m_creature->getVictim()); + DoCast(m_creature->getVictim(),SPELL_BESERK); + + //Cast our beserk spell agian in 12 seconds if we didn't kill everyone + Beserk_Timer = 12000; + }else Beserk_Timer -= diff; + + //Phase timer + if (Phase == 1) + if (Phase_Timer < diff) + { + //Go to next phase + Phase++; + DoYell(SAY_PHASE,LANG_UNIVERSAL,NULL); + DoCast(m_creature,SPELL_ENRAGE); + }else Phase_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; + +//This is the GetAI method used by all scripts that involve AI +//It is called every time a new creature using this script is created +CreatureAI* GetAI_custom_example(Creature *_Creature) +{ + return new custom_exampleAI (_Creature); +} + +//This function is called when the player clicks an option on the gossip menu +void SendDefaultMenu_custom_example(Player *player, Creature *_Creature, uint32 action) +{ + if (action == GOSSIP_ACTION_INFO_DEF + 1) //Fight time + { + //Set our faction to hostile twoards all + _Creature->setFaction(24); + _Creature->Attack(player, true); + player->PlayerTalkClass->CloseGossip(); + } +} + +//This function is called when the player clicks an option on the gossip menu +bool GossipSelect_custom_example(Player *player, Creature *_Creature, uint32 sender, uint32 action ) +{ + if (sender == GOSSIP_SENDER_MAIN) + SendDefaultMenu_custom_example(player, _Creature, action); + + return true; +} + +//This function is called when the player opens the gossip menu +bool GossipHello_custom_example(Player *player, Creature *_Creature) +{ + player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); + player->PlayerTalkClass->SendGossipMenu(907,_Creature->GetGUID()); + + return true; +} + +//Our Recive emote function +bool ReceiveEmote_custom_example(Player *player, Creature *_Creature, uint32 emote) +{ + _Creature->HandleEmoteCommand(emote); + + if (emote == TEXTEMOTE_DANCE) + ((custom_exampleAI*)_Creature->AI())->DoSay(SAY_DANCE,LANG_UNIVERSAL,NULL); + + if (emote == TEXTEMOTE_SALUTE) + ((custom_exampleAI*)_Creature->AI())->DoSay(SAY_SALUTE,LANG_UNIVERSAL,NULL); + + return true; +} + +//This is the actual function called only once durring InitScripts() +//It must define all handled functions that are to be run in this script +//For example if you want this Script to handle Emotes you must include +//newscript->ReciveEmote = My_Emote_Function; +void AddSC_custom_example() +{ + Script *newscript; + + newscript = new Script; + newscript->Name="custom_example"; + newscript->GetAI = GetAI_custom_example; + newscript->pGossipHello = &GossipHello_custom_example; + newscript->pGossipSelect = &GossipSelect_custom_example; + newscript->pReceiveEmote = &ReceiveEmote_custom_example; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/custom/custom_gossip_codebox.cpp b/src/bindings/scripts/scripts/custom/custom_gossip_codebox.cpp index a61871a71c3..31be3a284b0 100644 --- a/src/bindings/scripts/scripts/custom/custom_gossip_codebox.cpp +++ b/src/bindings/scripts/scripts/custom/custom_gossip_codebox.cpp @@ -1,81 +1,81 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Custom_Gossip_Codebox -SD%Complete: 100 -SDComment: Show a codebox in gossip option -SDCategory: Script Examples -EndScriptData */ - -#include "precompiled.h" -#include - -//This function is called when the player opens the gossip menubool -bool GossipHello_custom_gossip_codebox(Player *player, Creature *_Creature) -{ - player->PlayerTalkClass->GetGossipMenu()->AddMenuItem(0, "A quiz: what's your name?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1, "", 0, true); - player->ADD_GOSSIP_ITEM(0, "I'm not interested", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2); - - player->PlayerTalkClass->SendGossipMenu(907,_Creature->GetGUID()); - return true; -} - -//This function is called when the player clicks an option on the gossip menubool -bool GossipSelect_custom_gossip_codebox(Player *player, Creature *_Creature, uint32 sender, uint32 action ) -{ - if(action == GOSSIP_ACTION_INFO_DEF+2) - { - _Creature->Say("Normal select, guess you're not interested.", LANG_UNIVERSAL, 0); - player->CLOSE_GOSSIP_MENU(); - } - return true; -} - -bool GossipSelectWithCode_custom_gossip_codebox( Player *player, Creature *_Creature, uint32 sender, uint32 action, const char* sCode ) -{ - if(sender == GOSSIP_SENDER_MAIN) - { - if(action == GOSSIP_ACTION_INFO_DEF+1) - { - if(std::strcmp(sCode, player->GetName())!=0) - { - _Creature->Say("Wrong!", LANG_UNIVERSAL, 0); - _Creature->CastSpell(player, 12826, true); - } - else - { - _Creature->Say("You're right, you are allowed to see my inner secrets.", LANG_UNIVERSAL, 0); - _Creature->CastSpell(player, 26990, true); - } - player->CLOSE_GOSSIP_MENU(); - return true; - } - } - return false; -} - -void AddSC_custom_gossip_codebox() -{ - Script *newscript; - - newscript = new Script; - newscript->Name="custom_gossip_codebox"; - newscript->pGossipHello = &GossipHello_custom_gossip_codebox; - newscript->pGossipSelect = &GossipSelect_custom_gossip_codebox; - newscript->pGossipSelectWithCode = &GossipSelectWithCode_custom_gossip_codebox; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Custom_Gossip_Codebox +SD%Complete: 100 +SDComment: Show a codebox in gossip option +SDCategory: Script Examples +EndScriptData */ + +#include "precompiled.h" +#include + +//This function is called when the player opens the gossip menubool +bool GossipHello_custom_gossip_codebox(Player *player, Creature *_Creature) +{ + player->ADD_GOSSIP_ITEM_EXTENDED(0, "A quiz: what's your name?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1, "", 0, true); + player->ADD_GOSSIP_ITEM(0, "I'm not interested", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2); + + player->PlayerTalkClass->SendGossipMenu(907,_Creature->GetGUID()); + return true; +} + +//This function is called when the player clicks an option on the gossip menubool +bool GossipSelect_custom_gossip_codebox(Player *player, Creature *_Creature, uint32 sender, uint32 action ) +{ + if(action == GOSSIP_ACTION_INFO_DEF+2) + { + _Creature->Say("Normal select, guess you're not interested.", LANG_UNIVERSAL, 0); + player->CLOSE_GOSSIP_MENU(); + } + return true; +} + +bool GossipSelectWithCode_custom_gossip_codebox( Player *player, Creature *_Creature, uint32 sender, uint32 action, const char* sCode ) +{ + if(sender == GOSSIP_SENDER_MAIN) + { + if(action == GOSSIP_ACTION_INFO_DEF+1) + { + if(std::strcmp(sCode, player->GetName())!=0) + { + _Creature->Say("Wrong!", LANG_UNIVERSAL, 0); + _Creature->CastSpell(player, 12826, true); + } + else + { + _Creature->Say("You're right, you are allowed to see my inner secrets.", LANG_UNIVERSAL, 0); + _Creature->CastSpell(player, 26990, true); + } + player->CLOSE_GOSSIP_MENU(); + return true; + } + } + return false; +} + +void AddSC_custom_gossip_codebox() +{ + Script *newscript; + + newscript = new Script; + newscript->Name="custom_gossip_codebox"; + newscript->pGossipHello = &GossipHello_custom_gossip_codebox; + newscript->pGossipSelect = &GossipSelect_custom_gossip_codebox; + newscript->pGossipSelectWithCode = &GossipSelectWithCode_custom_gossip_codebox; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/custom/test.cpp b/src/bindings/scripts/scripts/custom/test.cpp index 97876ca0c90..0adf1a07c5a 100644 --- a/src/bindings/scripts/scripts/custom/test.cpp +++ b/src/bindings/scripts/scripts/custom/test.cpp @@ -1,202 +1,200 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Test -SD%Complete: 100 -SDComment: Script used for testing escortAI -SDCategory: Script Examples -EndScriptData */ - -#include "precompiled.h" -#include "../npc/npc_escortAI.h" - -struct MANGOS_DLL_DECL npc_testAI : public npc_escortAI -{ - public: - - // CreatureAI functions - npc_testAI(Creature *c) : npc_escortAI(c) {Reset();} - - uint32 DeathCoilTimer; - uint32 ChatTimer; - - // Pure Virtual Functions - void WaypointReached(uint32 i) - { - switch (i) - { - case 1: - m_creature->Say("Hmm a nice day for a walk alright", LANG_UNIVERSAL, 0); - break; - - case 3: - { - m_creature->Say("Wild Felboar attack!", LANG_UNIVERSAL, 0); - Creature* temp = m_creature->SummonCreature(21878, m_creature->GetPositionX()+5, m_creature->GetPositionY()+7, m_creature->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 3000); - - temp->AI()->AttackStart(m_creature); - } - break; - - case 4: - { - m_creature->Say("Time for me to go! See ya around $N!", LANG_UNIVERSAL, PlayerGUID); - m_creature->HandleEmoteCommand(EMOTE_ONESHOT_WAVE); - - Unit* temp = Unit::GetUnit(*m_creature, PlayerGUID); - if (temp) - { - temp->MonsterSay("Bye Bye!", LANG_UNIVERSAL, 0); - temp->HandleEmoteCommand(EMOTE_ONESHOT_WAVE); - } - } - break; - } - } - - void Aggro(Unit*) - { - if (IsBeingEscorted) - m_creature->Say("Help $N! I'm under attack!", LANG_UNIVERSAL, PlayerGUID); - else m_creature->Say("Die scum!", LANG_UNIVERSAL, 0); - } - - void Reset() - { - DeathCoilTimer = 4000; - ChatTimer = 4000; - } - - void JustDied(Unit* killer) - { - if (IsBeingEscorted) - { - //killer = m_creature when player got to far from creature - if (killer == m_creature) - { - Unit *pTemp = Unit::GetUnit(*m_creature,PlayerGUID); - if( pTemp ) - DoWhisper("How dare you leave me like that! I hate you! =*(", pTemp); - } - else m_creature->Say("...no...how could you let me die $N", LANG_UNIVERSAL, PlayerGUID); - } - else m_creature->Say("ugh...", LANG_UNIVERSAL, 0); - } - - void UpdateAI(const uint32 diff) - { - //Must update npc_escortAI - npc_escortAI::UpdateAI(diff); - - //Combat check - if (InCombat && m_creature->getVictim()) - { - if (DeathCoilTimer < diff) - { - m_creature->Say("Taste death!", LANG_UNIVERSAL, 0); - m_creature->CastSpell(m_creature->getVictim(), 33130, false); - - DeathCoilTimer = 4000; - }else DeathCoilTimer -= diff; - }else - { - //Out of combat but being escorted - if (IsBeingEscorted) - if (ChatTimer < diff) - { - if (m_creature->HasAura(3593, 0)) - { - m_creature->Say("Fireworks!", LANG_UNIVERSAL, 0); - m_creature->CastSpell(m_creature, 11540, false); - }else - { - m_creature->Say("Hmm, I think I could use a buff", LANG_UNIVERSAL, 0); - m_creature->CastSpell(m_creature, 3593, false); - } - - ChatTimer = 12000; - }else ChatTimer -= diff; - } - } -}; - -CreatureAI* GetAI_test(Creature *_Creature) -{ - npc_testAI* testAI = new npc_testAI(_Creature); - - testAI->AddWaypoint(0, 1231, -4419, 23); - testAI->AddWaypoint(1, 1198, -4440, 23, 0); - testAI->AddWaypoint(2, 1208, -4392, 23); - testAI->AddWaypoint(3, 1231, -4419, 23, 5000); - testAI->AddWaypoint(4, 1208, -4392, 23, 5000); - - return (CreatureAI*)testAI; -} - -bool GossipHello_npc_test(Player *player, Creature *_Creature) -{ - player->TalkedToCreature(_Creature->GetEntry(),_Creature->GetGUID()); - _Creature->prepareGossipMenu(player,0); - - player->PlayerTalkClass->GetGossipMenu()->AddMenuItem(0, "Click to Test Escort(Attack, Defend, Run)", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1,"",0); - - player->PlayerTalkClass->GetGossipMenu()->AddMenuItem(0, "Click to Test Escort(NoAttack, NoDefend, Walk)", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2,"",0); - - player->PlayerTalkClass->GetGossipMenu()->AddMenuItem(0, "Click to Test Escort(NoAttack, Defend, Walk)", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+3,"",0); - - _Creature->sendPreparedGossip( player ); - return true; -} - -bool GossipSelect_npc_test(Player *player, Creature *_Creature, uint32 sender, uint32 action ) -{ - if (action == GOSSIP_ACTION_INFO_DEF+1) - { - player->CLOSE_GOSSIP_MENU(); - ((npc_escortAI*)(_Creature->AI()))->Start(true, true, true, player->GetGUID()); - - return true; // prevent mangos core handling - } - - if (action == GOSSIP_ACTION_INFO_DEF+2) - { - player->CLOSE_GOSSIP_MENU(); - ((npc_escortAI*)(_Creature->AI()))->Start(false, false, false, player->GetGUID()); - - return true; // prevent mangos core handling - } - - if (action == GOSSIP_ACTION_INFO_DEF+3) - { - player->CLOSE_GOSSIP_MENU(); - ((npc_escortAI*)(_Creature->AI()))->Start(false, true, false, player->GetGUID()); - - return true; // prevent mangos core handling - } - return false; -} - -void AddSC_test() -{ - Script *newscript; - newscript = new Script; - newscript->Name="test"; - newscript->GetAI = GetAI_test; - newscript->pGossipHello = &GossipHello_npc_test; - newscript->pGossipSelect = &GossipSelect_npc_test; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Test +SD%Complete: 100 +SDComment: Script used for testing escortAI +SDCategory: Script Examples +EndScriptData */ + +#include "precompiled.h" +#include "../npc/npc_escortAI.h" + +struct MANGOS_DLL_DECL npc_testAI : public npc_escortAI +{ + public: + + // CreatureAI functions + npc_testAI(Creature *c) : npc_escortAI(c) {Reset();} + + uint32 DeathCoilTimer; + uint32 ChatTimer; + + // Pure Virtual Functions + void WaypointReached(uint32 i) + { + switch (i) + { + case 1: + m_creature->Say("Hmm a nice day for a walk alright", LANG_UNIVERSAL, 0); + break; + + case 3: + { + m_creature->Say("Wild Felboar attack!", LANG_UNIVERSAL, 0); + Creature* temp = m_creature->SummonCreature(21878, m_creature->GetPositionX()+5, m_creature->GetPositionY()+7, m_creature->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 3000); + + temp->AI()->AttackStart(m_creature); + } + break; + + case 4: + { + m_creature->Say("Time for me to go! See ya around $N!", LANG_UNIVERSAL, PlayerGUID); + m_creature->HandleEmoteCommand(EMOTE_ONESHOT_WAVE); + + Unit* temp = Unit::GetUnit(*m_creature, PlayerGUID); + if (temp) + { + temp->MonsterSay("Bye Bye!", LANG_UNIVERSAL, 0); + temp->HandleEmoteCommand(EMOTE_ONESHOT_WAVE); + } + } + break; + } + } + + void Aggro(Unit*) + { + if (IsBeingEscorted) + m_creature->Say("Help $N! I'm under attack!", LANG_UNIVERSAL, PlayerGUID); + else m_creature->Say("Die scum!", LANG_UNIVERSAL, 0); + } + + void Reset() + { + DeathCoilTimer = 4000; + ChatTimer = 4000; + } + + void JustDied(Unit* killer) + { + if (IsBeingEscorted) + { + //killer = m_creature when player got to far from creature + if (killer == m_creature) + { + Unit *pTemp = Unit::GetUnit(*m_creature,PlayerGUID); + if( pTemp ) + DoWhisper("How dare you leave me like that! I hate you! =*(", pTemp); + } + else m_creature->Say("...no...how could you let me die $N", LANG_UNIVERSAL, PlayerGUID); + } + else m_creature->Say("ugh...", LANG_UNIVERSAL, 0); + } + + void UpdateAI(const uint32 diff) + { + //Must update npc_escortAI + npc_escortAI::UpdateAI(diff); + + //Combat check + if (InCombat && m_creature->getVictim()) + { + if (DeathCoilTimer < diff) + { + m_creature->Say("Taste death!", LANG_UNIVERSAL, 0); + m_creature->CastSpell(m_creature->getVictim(), 33130, false); + + DeathCoilTimer = 4000; + }else DeathCoilTimer -= diff; + }else + { + //Out of combat but being escorted + if (IsBeingEscorted) + if (ChatTimer < diff) + { + if (m_creature->HasAura(3593, 0)) + { + m_creature->Say("Fireworks!", LANG_UNIVERSAL, 0); + m_creature->CastSpell(m_creature, 11540, false); + }else + { + m_creature->Say("Hmm, I think I could use a buff", LANG_UNIVERSAL, 0); + m_creature->CastSpell(m_creature, 3593, false); + } + + ChatTimer = 12000; + }else ChatTimer -= diff; + } + } +}; + +CreatureAI* GetAI_test(Creature *_Creature) +{ + npc_testAI* testAI = new npc_testAI(_Creature); + + testAI->AddWaypoint(0, 1231, -4419, 23); + testAI->AddWaypoint(1, 1198, -4440, 23, 0); + testAI->AddWaypoint(2, 1208, -4392, 23); + testAI->AddWaypoint(3, 1231, -4419, 23, 5000); + testAI->AddWaypoint(4, 1208, -4392, 23, 5000); + + return (CreatureAI*)testAI; +} + +bool GossipHello_npc_test(Player *player, Creature *_Creature) +{ + player->TalkedToCreature(_Creature->GetEntry(),_Creature->GetGUID()); + _Creature->prepareGossipMenu(player,0); + + player->ADD_GOSSIP_ITEM(0, "Click to Test Escort(Attack, Defend, Run)", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); + player->ADD_GOSSIP_ITEM(0, "Click to Test Escort(NoAttack, NoDefend, Walk)", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2); + player->ADD_GOSSIP_ITEM(0, "Click to Test Escort(NoAttack, Defend, Walk)", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+3); + + _Creature->sendPreparedGossip( player ); + return true; +} + +bool GossipSelect_npc_test(Player *player, Creature *_Creature, uint32 sender, uint32 action ) +{ + if (action == GOSSIP_ACTION_INFO_DEF+1) + { + player->CLOSE_GOSSIP_MENU(); + ((npc_escortAI*)(_Creature->AI()))->Start(true, true, true, player->GetGUID()); + + return true; // prevent mangos core handling + } + + if (action == GOSSIP_ACTION_INFO_DEF+2) + { + player->CLOSE_GOSSIP_MENU(); + ((npc_escortAI*)(_Creature->AI()))->Start(false, false, false, player->GetGUID()); + + return true; // prevent mangos core handling + } + + if (action == GOSSIP_ACTION_INFO_DEF+3) + { + player->CLOSE_GOSSIP_MENU(); + ((npc_escortAI*)(_Creature->AI()))->Start(false, true, false, player->GetGUID()); + + return true; // prevent mangos core handling + } + return false; +} + +void AddSC_test() +{ + Script *newscript; + newscript = new Script; + newscript->Name="test"; + newscript->GetAI = GetAI_test; + newscript->pGossipHello = &GossipHello_npc_test; + newscript->pGossipSelect = &GossipSelect_npc_test; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/go/go_scripts.cpp b/src/bindings/scripts/scripts/go/go_scripts.cpp index 158f7fbca36..88949f08392 100644 --- a/src/bindings/scripts/scripts/go/go_scripts.cpp +++ b/src/bindings/scripts/scripts/go/go_scripts.cpp @@ -1,209 +1,209 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: GO_Scripts -SD%Complete: 100 -SDComment: Quest support: 4285,4287,4288(crystal pylons), 4296. Field_Repair_Bot->Teaches spell 22704. Barov_journal->Teaches spell 26089 -SDCategory: Game Objects -EndScriptData */ - -/* ContentData -go_northern_crystal_pylon -go_eastern_crystal_pylon -go_western_crystal_pylon -go_barov_journal -go_field_repair_bot_74A -go_orb_of_command -go_tablet_of_madness -go_tablet_of_the_seven -go_teleporter -EndContentData */ - -#include "precompiled.h" - -/*###### -## go_crystal_pylons (3x) -######*/ - -bool GOHello_go_northern_crystal_pylon(Player *player, GameObject* _GO) -{ - if (_GO->GetGoType() == GAMEOBJECT_TYPE_QUESTGIVER) - { - player->PrepareQuestMenu(_GO->GetGUID()); - player->SendPreparedQuest(_GO->GetGUID()); - } - - if (player->GetQuestStatus(4285) == QUEST_STATUS_INCOMPLETE) - player->AreaExploredOrEventHappens(4285); - - return true; -} - -bool GOHello_go_eastern_crystal_pylon(Player *player, GameObject* _GO) -{ - if (_GO->GetGoType() == GAMEOBJECT_TYPE_QUESTGIVER) - { - player->PrepareQuestMenu(_GO->GetGUID()); - player->SendPreparedQuest(_GO->GetGUID()); - } - - if (player->GetQuestStatus(4287) == QUEST_STATUS_INCOMPLETE) - player->AreaExploredOrEventHappens(4287); - - return true; -} - -bool GOHello_go_western_crystal_pylon(Player *player, GameObject* _GO) -{ - if (_GO->GetGoType() == GAMEOBJECT_TYPE_QUESTGIVER) - { - player->PrepareQuestMenu(_GO->GetGUID()); - player->SendPreparedQuest(_GO->GetGUID()); - } - - if (player->GetQuestStatus(4288) == QUEST_STATUS_INCOMPLETE) - player->AreaExploredOrEventHappens(4288); - - return true; -} - -/*###### -## go_barov_journal -######*/ - -bool GOHello_go_barov_journal(Player *player, GameObject* _GO) -{ - if(player->HasSkill(SKILL_TAILORING) && player->GetBaseSkillValue(SKILL_TAILORING) >= 280 && !player->HasSpell(26086)) - { - player->CastSpell(player,26095,false); - } - return true; -} - -/*###### -## go_field_repair_bot_74A -######*/ - -bool GOHello_go_field_repair_bot_74A(Player *player, GameObject* _GO) -{ - if(player->HasSkill(SKILL_ENGINERING) && player->GetBaseSkillValue(SKILL_ENGINERING) >= 300 && !player->HasSpell(22704)) - { - player->CastSpell(player,22864,false); - } - return true; -} - -/*###### -## go_orb_of_command -######*/ - -bool GOHello_go_orb_of_command(Player *player, GameObject* _GO) -{ - if( player->GetQuestRewardStatus(7761) ) - player->CastSpell(player,23460,true); - - return true; -} - -/*###### -## go_tablet_of_madness -######*/ - -bool GOHello_go_tablet_of_madness(Player *player, GameObject* _GO) -{ - if (player->HasSkill(SKILL_ALCHEMY) && player->GetSkillValue(SKILL_ALCHEMY) >= 300 && !player->HasSpell(24266)) - { - player->CastSpell(player,24267,false); - } - return true; -} - -/*###### -## go_tablet_of_the_seven -######*/ - -//TODO: use gossip option ("Transcript the Tablet") instead, if Mangos adds support. -bool GOHello_go_tablet_of_the_seven(Player *player, GameObject* _GO) -{ - if (_GO->GetGoType() != GAMEOBJECT_TYPE_QUESTGIVER) - return true; - - if (player->GetQuestStatus(4296) == QUEST_STATUS_INCOMPLETE) - player->CastSpell(player,15065,false); - - return true; -} - -/*###### -## go_teleporter -######*/ - -bool GOHello_go_teleporter(Player *player, GameObject* _GO) -{ - player->TeleportTo(0, 1807.07f,336.105f,70.3975f,0.0f); - return false; -} - -void AddSC_go_scripts() -{ - Script *newscript; - - newscript = new Script; - newscript->Name="go_northern_crystal_pylon"; - newscript->pGOHello = &GOHello_go_northern_crystal_pylon; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="go_eastern_crystal_pylon"; - newscript->pGOHello = &GOHello_go_eastern_crystal_pylon; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="go_western_crystal_pylon"; - newscript->pGOHello = &GOHello_go_western_crystal_pylon; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="go_barov_journal"; - newscript->pGOHello = &GOHello_go_barov_journal; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="go_field_repair_bot_74A"; - newscript->pGOHello = &GOHello_go_field_repair_bot_74A; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="go_orb_of_command"; - newscript->pGOHello = &GOHello_go_orb_of_command; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="go_tablet_of_madness"; - newscript->pGOHello = GOHello_go_tablet_of_madness; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="go_tablet_of_the_seven"; - newscript->pGOHello = GOHello_go_tablet_of_the_seven; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="go_teleporter"; - newscript->pGOHello = GOHello_go_teleporter; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: GO_Scripts +SD%Complete: 100 +SDComment: Quest support: 4285,4287,4288(crystal pylons), 4296. Field_Repair_Bot->Teaches spell 22704. Barov_journal->Teaches spell 26089 +SDCategory: Game Objects +EndScriptData */ + +/* ContentData +go_northern_crystal_pylon +go_eastern_crystal_pylon +go_western_crystal_pylon +go_barov_journal +go_field_repair_bot_74A +go_orb_of_command +go_tablet_of_madness +go_tablet_of_the_seven +go_teleporter +EndContentData */ + +#include "precompiled.h" + +/*###### +## go_crystal_pylons (3x) +######*/ + +bool GOHello_go_northern_crystal_pylon(Player *player, GameObject* _GO) +{ + if (_GO->GetGoType() == GAMEOBJECT_TYPE_QUESTGIVER) + { + player->PrepareQuestMenu(_GO->GetGUID()); + player->SendPreparedQuest(_GO->GetGUID()); + } + + if (player->GetQuestStatus(4285) == QUEST_STATUS_INCOMPLETE) + player->AreaExploredOrEventHappens(4285); + + return true; +} + +bool GOHello_go_eastern_crystal_pylon(Player *player, GameObject* _GO) +{ + if (_GO->GetGoType() == GAMEOBJECT_TYPE_QUESTGIVER) + { + player->PrepareQuestMenu(_GO->GetGUID()); + player->SendPreparedQuest(_GO->GetGUID()); + } + + if (player->GetQuestStatus(4287) == QUEST_STATUS_INCOMPLETE) + player->AreaExploredOrEventHappens(4287); + + return true; +} + +bool GOHello_go_western_crystal_pylon(Player *player, GameObject* _GO) +{ + if (_GO->GetGoType() == GAMEOBJECT_TYPE_QUESTGIVER) + { + player->PrepareQuestMenu(_GO->GetGUID()); + player->SendPreparedQuest(_GO->GetGUID()); + } + + if (player->GetQuestStatus(4288) == QUEST_STATUS_INCOMPLETE) + player->AreaExploredOrEventHappens(4288); + + return true; +} + +/*###### +## go_barov_journal +######*/ + +bool GOHello_go_barov_journal(Player *player, GameObject* _GO) +{ + if(player->HasSkill(SKILL_TAILORING) && player->GetBaseSkillValue(SKILL_TAILORING) >= 280 && !player->HasSpell(26086)) + { + player->CastSpell(player,26095,false); + } + return true; +} + +/*###### +## go_field_repair_bot_74A +######*/ + +bool GOHello_go_field_repair_bot_74A(Player *player, GameObject* _GO) +{ + if(player->HasSkill(SKILL_ENGINERING) && player->GetBaseSkillValue(SKILL_ENGINERING) >= 300 && !player->HasSpell(22704)) + { + player->CastSpell(player,22864,false); + } + return true; +} + +/*###### +## go_orb_of_command +######*/ + +bool GOHello_go_orb_of_command(Player *player, GameObject* _GO) +{ + if( player->GetQuestRewardStatus(7761) ) + player->CastSpell(player,23460,true); + + return true; +} + +/*###### +## go_tablet_of_madness +######*/ + +bool GOHello_go_tablet_of_madness(Player *player, GameObject* _GO) +{ + if (player->HasSkill(SKILL_ALCHEMY) && player->GetSkillValue(SKILL_ALCHEMY) >= 300 && !player->HasSpell(24266)) + { + player->CastSpell(player,24267,false); + } + return true; +} + +/*###### +## go_tablet_of_the_seven +######*/ + +//TODO: use gossip option ("Transcript the Tablet") instead, if Mangos adds support. +bool GOHello_go_tablet_of_the_seven(Player *player, GameObject* _GO) +{ + if (_GO->GetGoType() != GAMEOBJECT_TYPE_QUESTGIVER) + return true; + + if (player->GetQuestStatus(4296) == QUEST_STATUS_INCOMPLETE) + player->CastSpell(player,15065,false); + + return true; +} + +/*###### +## go_teleporter +######*/ + +bool GOHello_go_teleporter(Player *player, GameObject* _GO) +{ + player->TeleportTo(0, 1807.07f,336.105f,70.3975f,0.0f); + return false; +} + +void AddSC_go_scripts() +{ + Script *newscript; + + newscript = new Script; + newscript->Name="go_northern_crystal_pylon"; + newscript->pGOHello = &GOHello_go_northern_crystal_pylon; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="go_eastern_crystal_pylon"; + newscript->pGOHello = &GOHello_go_eastern_crystal_pylon; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="go_western_crystal_pylon"; + newscript->pGOHello = &GOHello_go_western_crystal_pylon; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="go_barov_journal"; + newscript->pGOHello = &GOHello_go_barov_journal; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="go_field_repair_bot_74A"; + newscript->pGOHello = &GOHello_go_field_repair_bot_74A; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="go_orb_of_command"; + newscript->pGOHello = &GOHello_go_orb_of_command; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="go_tablet_of_madness"; + newscript->pGOHello = GOHello_go_tablet_of_madness; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="go_tablet_of_the_seven"; + newscript->pGOHello = GOHello_go_tablet_of_the_seven; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="go_teleporter"; + newscript->pGOHello = GOHello_go_teleporter; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/guard/guard_ai.cpp b/src/bindings/scripts/scripts/guard/guard_ai.cpp index 7a9d1210bf1..18b18d69fdf 100644 --- a/src/bindings/scripts/scripts/guard/guard_ai.cpp +++ b/src/bindings/scripts/scripts/guard/guard_ai.cpp @@ -1,160 +1,160 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Guard_AI -SD%Complete: 90 -SDComment: -SDCategory: Guards -EndScriptData */ - -#include "precompiled.h" -#include "guard_ai.h" - -// **** This script is for use within every single guard to save coding time **** - -#define GENERIC_CREATURE_COOLDOWN 5000 - -void guardAI::Reset() -{ - GlobalCooldown = 0; - BuffTimer = 0; //Rebuff as soon as we can -} - -void guardAI::Aggro(Unit *who) -{ -} - -void guardAI::JustDied(Unit *Killer) -{ - //Send Zone Under Attack message to the LocalDefense and WorldDefense Channels - if( Killer->GetTypeId() == TYPEID_PLAYER ) - m_creature->SendZoneUnderAttackMessage((Player*)Killer); - else if( Unit *owner = Killer->GetOwner() ) - { - if( owner->GetTypeId() == TYPEID_PLAYER ) - m_creature->SendZoneUnderAttackMessage((Player*)owner); - } -} - -void guardAI::UpdateAI(const uint32 diff) -{ - //Always decrease our global cooldown first - if (GlobalCooldown > diff) - GlobalCooldown -= diff; - else GlobalCooldown = 0; - - //Buff timer (only buff when we are alive and not in combat - if (m_creature->isAlive() && !InCombat) - if (BuffTimer < diff ) - { - //Find a spell that targets friendly and applies an aura (these are generally buffs) - SpellEntry const *info = SelectSpell(m_creature, -1, -1, SELECT_TARGET_ANY_FRIEND, 0, 0, 0, 0, SELECT_EFFECT_AURA); - - if (info && !GlobalCooldown) - { - //Cast the buff spell - DoCastSpell(m_creature, info); - - //Set our global cooldown - GlobalCooldown = GENERIC_CREATURE_COOLDOWN; - - //Set our timer to 10 minutes before rebuff - BuffTimer = 600000; - } //Try agian in 30 seconds - else BuffTimer = 30000; - }else BuffTimer -= diff; - - //Return since we have no target - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - // Make sure our attack is ready and we arn't currently casting - if( m_creature->isAttackReady() && !m_creature->IsNonMeleeSpellCasted(false)) - { - //If we are within range melee the target - if( m_creature->IsWithinDistInMap(m_creature->getVictim(), ATTACK_DISTANCE)) - { - bool Healing = false; - SpellEntry const *info = NULL; - - //Select a healing spell if less than 30% hp - if (m_creature->GetHealth()*100 / m_creature->GetMaxHealth() < 30) - info = SelectSpell(m_creature, -1, -1, SELECT_TARGET_ANY_FRIEND, 0, 0, 0, 0, SELECT_EFFECT_HEALING); - - //No healing spell available, select a hostile spell - if (info) Healing = true; - else info = SelectSpell(m_creature->getVictim(), -1, -1, SELECT_TARGET_ANY_ENEMY, 0, 0, 0, 0, SELECT_EFFECT_DONTCARE); - - //20% chance to replace our white hit with a spell - if (info && rand() % 5 == 0 && !GlobalCooldown) - { - //Cast the spell - if (Healing)DoCastSpell(m_creature, info); - else DoCastSpell(m_creature->getVictim(), info); - - //Set our global cooldown - GlobalCooldown = GENERIC_CREATURE_COOLDOWN; - } - else m_creature->AttackerStateUpdate(m_creature->getVictim()); - - m_creature->resetAttackTimer(); - } - } - else - { - //Only run this code if we arn't already casting - if (!m_creature->IsNonMeleeSpellCasted(false)) - { - bool Healing = false; - SpellEntry const *info = NULL; - - //Select a healing spell if less than 30% hp ONLY 33% of the time - if (m_creature->GetHealth()*100 / m_creature->GetMaxHealth() < 30 && rand() % 3 == 0) - info = SelectSpell(m_creature, -1, -1, SELECT_TARGET_ANY_FRIEND, 0, 0, 0, 0, SELECT_EFFECT_HEALING); - - //No healing spell available, See if we can cast a ranged spell (Range must be greater than ATTACK_DISTANCE) - if (info) Healing = true; - else info = SelectSpell(m_creature->getVictim(), -1, -1, SELECT_TARGET_ANY_ENEMY, 0, 0, ATTACK_DISTANCE, 0, SELECT_EFFECT_DONTCARE); - - //Found a spell, check if we arn't on cooldown - if (info && !GlobalCooldown) - { - //If we are currently moving stop us and set the movement generator - if ((*m_creature).GetMotionMaster()->GetCurrentMovementGeneratorType()!=IDLE_MOTION_TYPE) - { - (*m_creature).GetMotionMaster()->Clear(false); - (*m_creature).GetMotionMaster()->MoveIdle(); - } - - //Cast spell - if (Healing) DoCastSpell(m_creature,info); - else DoCastSpell(m_creature->getVictim(),info); - - //Set our global cooldown - GlobalCooldown = GENERIC_CREATURE_COOLDOWN; - - } //If no spells available and we arn't moving run to target - else if ((*m_creature).GetMotionMaster()->GetCurrentMovementGeneratorType()!=TARGETED_MOTION_TYPE) - { - //Cancel our current spell and then mutate new movement generator - m_creature->InterruptNonMeleeSpells(false); - (*m_creature).GetMotionMaster()->Clear(false); - (*m_creature).GetMotionMaster()->MoveChase(m_creature->getVictim()); - } - } - } -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Guard_AI +SD%Complete: 90 +SDComment: +SDCategory: Guards +EndScriptData */ + +#include "precompiled.h" +#include "guard_ai.h" + +// **** This script is for use within every single guard to save coding time **** + +#define GENERIC_CREATURE_COOLDOWN 5000 + +void guardAI::Reset() +{ + GlobalCooldown = 0; + BuffTimer = 0; //Rebuff as soon as we can +} + +void guardAI::Aggro(Unit *who) +{ +} + +void guardAI::JustDied(Unit *Killer) +{ + //Send Zone Under Attack message to the LocalDefense and WorldDefense Channels + if( Killer->GetTypeId() == TYPEID_PLAYER ) + m_creature->SendZoneUnderAttackMessage((Player*)Killer); + else if( Unit *owner = Killer->GetOwner() ) + { + if( owner->GetTypeId() == TYPEID_PLAYER ) + m_creature->SendZoneUnderAttackMessage((Player*)owner); + } +} + +void guardAI::UpdateAI(const uint32 diff) +{ + //Always decrease our global cooldown first + if (GlobalCooldown > diff) + GlobalCooldown -= diff; + else GlobalCooldown = 0; + + //Buff timer (only buff when we are alive and not in combat + if (m_creature->isAlive() && !InCombat) + if (BuffTimer < diff ) + { + //Find a spell that targets friendly and applies an aura (these are generally buffs) + SpellEntry const *info = SelectSpell(m_creature, -1, -1, SELECT_TARGET_ANY_FRIEND, 0, 0, 0, 0, SELECT_EFFECT_AURA); + + if (info && !GlobalCooldown) + { + //Cast the buff spell + DoCastSpell(m_creature, info); + + //Set our global cooldown + GlobalCooldown = GENERIC_CREATURE_COOLDOWN; + + //Set our timer to 10 minutes before rebuff + BuffTimer = 600000; + } //Try agian in 30 seconds + else BuffTimer = 30000; + }else BuffTimer -= diff; + + //Return since we have no target + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + // Make sure our attack is ready and we arn't currently casting + if( m_creature->isAttackReady() && !m_creature->IsNonMeleeSpellCasted(false)) + { + //If we are within range melee the target + if( m_creature->IsWithinDistInMap(m_creature->getVictim(), ATTACK_DISTANCE)) + { + bool Healing = false; + SpellEntry const *info = NULL; + + //Select a healing spell if less than 30% hp + if (m_creature->GetHealth()*100 / m_creature->GetMaxHealth() < 30) + info = SelectSpell(m_creature, -1, -1, SELECT_TARGET_ANY_FRIEND, 0, 0, 0, 0, SELECT_EFFECT_HEALING); + + //No healing spell available, select a hostile spell + if (info) Healing = true; + else info = SelectSpell(m_creature->getVictim(), -1, -1, SELECT_TARGET_ANY_ENEMY, 0, 0, 0, 0, SELECT_EFFECT_DONTCARE); + + //20% chance to replace our white hit with a spell + if (info && rand() % 5 == 0 && !GlobalCooldown) + { + //Cast the spell + if (Healing)DoCastSpell(m_creature, info); + else DoCastSpell(m_creature->getVictim(), info); + + //Set our global cooldown + GlobalCooldown = GENERIC_CREATURE_COOLDOWN; + } + else m_creature->AttackerStateUpdate(m_creature->getVictim()); + + m_creature->resetAttackTimer(); + } + } + else + { + //Only run this code if we arn't already casting + if (!m_creature->IsNonMeleeSpellCasted(false)) + { + bool Healing = false; + SpellEntry const *info = NULL; + + //Select a healing spell if less than 30% hp ONLY 33% of the time + if (m_creature->GetHealth()*100 / m_creature->GetMaxHealth() < 30 && rand() % 3 == 0) + info = SelectSpell(m_creature, -1, -1, SELECT_TARGET_ANY_FRIEND, 0, 0, 0, 0, SELECT_EFFECT_HEALING); + + //No healing spell available, See if we can cast a ranged spell (Range must be greater than ATTACK_DISTANCE) + if (info) Healing = true; + else info = SelectSpell(m_creature->getVictim(), -1, -1, SELECT_TARGET_ANY_ENEMY, 0, 0, ATTACK_DISTANCE, 0, SELECT_EFFECT_DONTCARE); + + //Found a spell, check if we arn't on cooldown + if (info && !GlobalCooldown) + { + //If we are currently moving stop us and set the movement generator + if ((*m_creature).GetMotionMaster()->GetCurrentMovementGeneratorType()!=IDLE_MOTION_TYPE) + { + (*m_creature).GetMotionMaster()->Clear(false); + (*m_creature).GetMotionMaster()->MoveIdle(); + } + + //Cast spell + if (Healing) DoCastSpell(m_creature,info); + else DoCastSpell(m_creature->getVictim(),info); + + //Set our global cooldown + GlobalCooldown = GENERIC_CREATURE_COOLDOWN; + + } //If no spells available and we arn't moving run to target + else if ((*m_creature).GetMotionMaster()->GetCurrentMovementGeneratorType()!=TARGETED_MOTION_TYPE) + { + //Cancel our current spell and then mutate new movement generator + m_creature->InterruptNonMeleeSpells(false); + (*m_creature).GetMotionMaster()->Clear(false); + (*m_creature).GetMotionMaster()->MoveChase(m_creature->getVictim()); + } + } + } +} diff --git a/src/bindings/scripts/scripts/guard/guard_ai.h b/src/bindings/scripts/scripts/guard/guard_ai.h index 80f88247945..9c6cca8f8ce 100644 --- a/src/bindings/scripts/scripts/guard/guard_ai.h +++ b/src/bindings/scripts/scripts/guard/guard_ai.h @@ -1,25 +1,25 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software licensed under GPL version 2 - * Please see the included DOCS/LICENSE.TXT for more information */ - -#ifndef SC_GUARDAI_H -#define SC_GUARDAI_H - -#define GENERIC_CREATURE_COOLDOWN 5000 - -struct MANGOS_DLL_DECL guardAI : public ScriptedAI -{ - guardAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 GlobalCooldown; //This variable acts like the global cooldown that players have (1.5 seconds) - uint32 BuffTimer; //This variable keeps track of buffs - - void Reset(); - - void Aggro(Unit *who); - - void JustDied(Unit *Killer); - - void UpdateAI(const uint32 diff); -}; -#endif +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software licensed under GPL version 2 + * Please see the included DOCS/LICENSE.TXT for more information */ + +#ifndef SC_GUARDAI_H +#define SC_GUARDAI_H + +#define GENERIC_CREATURE_COOLDOWN 5000 + +struct MANGOS_DLL_DECL guardAI : public ScriptedAI +{ + guardAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 GlobalCooldown; //This variable acts like the global cooldown that players have (1.5 seconds) + uint32 BuffTimer; //This variable keeps track of buffs + + void Reset(); + + void Aggro(Unit *who); + + void JustDied(Unit *Killer); + + void UpdateAI(const uint32 diff); +}; +#endif diff --git a/src/bindings/scripts/scripts/guard/guards.cpp b/src/bindings/scripts/scripts/guard/guards.cpp index ccd231fc166..7b528c1392a 100644 --- a/src/bindings/scripts/scripts/guard/guards.cpp +++ b/src/bindings/scripts/scripts/guard/guards.cpp @@ -1,4117 +1,4117 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Guards -SD%Complete: 100 -SDComment: All Guard gossip data, quite some npc_text-id's still missing, adding constantly as new id's are known. CombatAI should be organized better for future. -SDCategory: Guards -EndScriptData */ - -/* ContentData -guard_azuremyst -guard_bluffwatcher -guard_contested -guard_darnassus -guard_dunmorogh -guard_durotar -guard_elwynnforest -guard_eversong -guard_exodar -guard_ironforge -guard_mulgore -guard_orgrimmar -guard_shattrath -guard_shattrath_aldor -guard_shattrath_scryer -guard_silvermoon -guard_stormwind -guard_teldrassil -guard_tirisfal -guard_undercity -EndContentData */ - -#include "precompiled.h" -#include "guard_ai.h" - -//script spesific action -#define GOSSIP_ACTION_TAVERN 101 -#define GOSSIP_ACTION_GEMMERCHANT 102 -#define GOSSIP_ACTION_MANALOOM 103 - -//script spesific sender -#define GOSSIP_SENDER_SEC_GEMMERCHANT 101 -#define GOSSIP_SENDER_SEC_AUCTIONHOUSE 102 - -//script spesific gossip text -#define GOSSIP_TEXT_TAVERN "Worlds End Tavern" -#define GOSSIP_TEXT_BANKSCYERS "Scyers bank" -#define GOSSIP_TEXT_BANKALDOR "Aldor Bank" -#define GOSSIP_TEXT_INNSCYERS "Scyers Inn" -#define GOSSIP_TEXT_INNALDOR "Aldor Inn" -#define GOSSIP_TEXT_STABLESCYERS "Scyers Stable" -#define GOSSIP_TEXT_STABLEALDOR "Aldor Stable" -#define GOSSIP_TEXT_BATTLEMASTERALLIANCE "Alliance Battlemasters" -#define GOSSIP_TEXT_BATTLEMASTERHORDE "Horde Battlemasters" -#define GOSSIP_TEXT_BATTLEMASTERARENA "Arena Battlemasters" -#define GOSSIP_TEXT_MANALOOM "Mana Loom" -#define GOSSIP_TEXT_ALCHEMYLAB "Alchemy Lab" -#define GOSSIP_TEXT_GEMMERCHANT "Gem Merchant" -#define GOSSIP_TEXT_GEMSCYERS "Scyers Gem Merchant" -#define GOSSIP_TEXT_GEMALDOR "Aldor Gem Merchant" - -#define GOSSIP_TEXT_AH_SILVERMOON_1 "Western Auction House" -#define GOSSIP_TEXT_AH_SILVERMOON_2 "Royal Exchange Auction House" - -#define GOSSIP_TEXT_INN_SILVERMOON_1 "Silvermoon City Inn" -#define GOSSIP_TEXT_INN_SILVERMOON_2 "Wayfarer's Rest tavern" - -//common used for guards in main cities -void DoReplyToTextEmote(Creature *_Creature,uint32 em) -{ - switch(em) - { - case TEXTEMOTE_KISS: _Creature->HandleEmoteCommand(EMOTE_ONESHOT_BOW); break; - case TEXTEMOTE_WAVE: _Creature->HandleEmoteCommand(EMOTE_ONESHOT_WAVE); break; - case TEXTEMOTE_SALUTE: _Creature->HandleEmoteCommand(EMOTE_ONESHOT_SALUTE); break; - case TEXTEMOTE_SHY: _Creature->HandleEmoteCommand(EMOTE_ONESHOT_FLEX); break; - case TEXTEMOTE_RUDE: - case TEXTEMOTE_CHICKEN: _Creature->HandleEmoteCommand(EMOTE_ONESHOT_POINT); break; - } -} - -/******************************************************* - * guard_azuremyst start - *******************************************************/ - -bool GossipHello_guard_azuremyst(Player *player, Creature *_Creature) -{ - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_BANK , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_HIPPOGRYPH , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_GUILDMASTER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 3); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_INN , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 4); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_STABLEMASTER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 5); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_CLASSTRAINER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 6); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_PROFTRAINER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 7); - player->SEND_GOSSIP_MENU(10066,_Creature->GetGUID()); - return true; -} - -void SendDefaultMenu_guard_azuremyst(Player *player, Creature *_Creature, uint32 action) -{ - switch (action) - { - case GOSSIP_ACTION_INFO_DEF + 1: //Bank - player->SEND_POI(-3918.95, -11544.7, 6, 6, 0, "Bank"); - player->SEND_GOSSIP_MENU(10067,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 2: //Hippogryph Master - player->SEND_POI(-4057.15, -11788.6, 6, 6, 0, "Stephanos"); - player->SEND_GOSSIP_MENU(10071,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 3: //Guild master - player->SEND_POI(-4092.43, -11626.6, 6, 6, 0, "Funaam"); - player->SEND_GOSSIP_MENU(10073,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 4: //Inn - player->SEND_POI(-4129.43, -12469, 6, 6, 0, "Caregiver Chellan"); - player->SEND_GOSSIP_MENU(10074,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 5: //Stable Master - player->SEND_POI(-4146.42, -12492.7, 6, 6, 0, "Esbina"); - player->SEND_GOSSIP_MENU(10075,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 6: //Class trainer - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_DRUID , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 1); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_HUNTER , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 2); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_MAGE , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 3); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_PALADIN , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 4); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_PRIEST , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 5); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_SHAMAN , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 6); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_WARRIOR , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 7); - player->SEND_GOSSIP_MENU(10076,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 7: //Profession trainer - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ALCHEMY , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 1); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_BLACKSMITHING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 2); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_COOKING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 3); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ENCHANTING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 4); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ENGINEERING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 5); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_FIRSTAID , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 6); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_FISHING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 7); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_HERBALISM , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 8); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_JEWELCRAFTING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 9); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_LEATHERWORKING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 10); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_MINING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 11); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_SKINNING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 12); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_TAILORING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 13); - player->SEND_GOSSIP_MENU(10087,_Creature->GetGUID()); - break; - } -} - -void SendClassTrainerMenu_guard_azuremyst(Player *player, Creature *_Creature, uint32 action) -{ - switch (action) - { - case GOSSIP_ACTION_INFO_DEF + 1: //Druid - player->SEND_POI(-4274.81, -11495.3, 6, 6, 0, "Shalannius"); - player->SEND_GOSSIP_MENU(10077,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 2: //Hunter - player->SEND_POI(-4203.65, -12526.5, 6, 6, 0, "Acteon"); - player->SEND_GOSSIP_MENU(10078,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 3: //Mage - player->SEND_POI(-4149.62, -12530.1, 6, 6, 0, "Semid"); - player->SEND_GOSSIP_MENU(10081,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 4: //Paladin - player->SEND_POI(-4138.98, -12468.5, 6, 6, 0, "Tullas"); - player->SEND_GOSSIP_MENU(10083,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 5: //Priest - player->SEND_POI(-4131.66, -12478.6, 6, 6, 0, "Guvan"); - player->SEND_GOSSIP_MENU(10084,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 6: //Shaman - player->SEND_POI(-4162.33, -12456.1, 6, 6, 0, "Tuluun"); - player->SEND_GOSSIP_MENU(10085,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 7: //Warrior - player->SEND_POI(-4165.05, -12536.4, 6, 6, 0, "Ruada"); - player->SEND_GOSSIP_MENU(10086,_Creature->GetGUID()); - break; - } -} - -void SendProfTrainerMenu_guard_azuremyst(Player *player, Creature *_Creature, uint32 action) -{ - switch (action) - { - case GOSSIP_ACTION_INFO_DEF + 1: //Alchemy - player->SEND_POI(-4191.15, -12470, 6, 6, 0, "Daedal"); - player->SEND_GOSSIP_MENU(10088,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 2: //Blacksmithing - player->SEND_POI(-4726.29, -12387, 6, 6, 0, "Blacksmith Calypso"); - player->SEND_GOSSIP_MENU(10089,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 3: //Cooking - player->SEND_POI(-4710.87, -12400.6, 6, 6, 0, "'Cookie' McWeaksauce"); - player->SEND_GOSSIP_MENU(10090,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 4: //Enchanting - player->SEND_POI(-3882.85, -11496.7, 6, 6, 0, "Nahogg"); - player->SEND_GOSSIP_MENU(10091,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 5: //Engineering - player->SEND_POI(-4157.57, -12470.2, 6, 6, 0, "Artificer Daelo"); - player->SEND_GOSSIP_MENU(10092,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 6: //First Aid - player->SEND_POI(-4199.11, -12469.9, 6, 6, 0, "Anchorite Fateema"); - player->SEND_GOSSIP_MENU(10093,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 7: //Fishing - player->SEND_POI(-4266.38, -12985.1, 6, 6, 0, "Diktynna"); - player->SEND_GOSSIP_MENU(10094,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 8: //Herbalism - player->SEND_GOSSIP_MENU(10095,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 9: //Jewelcrafting - player->SEND_POI(-3781.55, -11541.8, 6, 6, 0, "Farii"); - player->SEND_GOSSIP_MENU(10097,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 10: //Leatherworking - player->SEND_POI(-3442.68, -12322.2, 6, 6, 0, "Moordo"); - player->SEND_GOSSIP_MENU(10098,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 11: //Mining - player->SEND_POI(-4179.89, -12493.1, 6, 6, 0, "Dulvi"); - player->SEND_GOSSIP_MENU(10097,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 12: //Skinning - player->SEND_POI(-3431.17, -12316.5, 6, 6, 0, "Gurf"); - player->SEND_GOSSIP_MENU(10098,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 13: //Tailoring - player->SEND_POI(-4711.54, -12386.7, 6, 6, 0, "Erin Kelly"); - player->SEND_GOSSIP_MENU(10099,_Creature->GetGUID()); - break; - } -} - -bool GossipSelect_guard_azuremyst(Player *player, Creature *_Creature, uint32 sender, uint32 action ) -{ - switch (sender) - { - case GOSSIP_SENDER_MAIN: SendDefaultMenu_guard_azuremyst(player, _Creature, action); break; - case GOSSIP_SENDER_SEC_CLASSTRAIN: SendClassTrainerMenu_guard_azuremyst(player, _Creature, action); break; - case GOSSIP_SENDER_SEC_PROFTRAIN: SendProfTrainerMenu_guard_azuremyst(player, _Creature, action); break; - } - return true; -} - -/******************************************************* - * guard_azuremyst end - *******************************************************/ - -CreatureAI* GetAI_guard_azuremyst(Creature *_Creature) -{ - return new guardAI (_Creature); -} - -/******************************************************* - * guard_bluffwatcher start - *******************************************************/ - -bool GossipHello_guard_bluffwatcher(Player *player, Creature *_Creature) -{ - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_BANK , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_WINDRIDER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_GUILDMASTER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 3); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_INN , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 4); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_MAILBOX , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 5); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_AUCTIONHOUSE , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 6); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_WEAPONMASTER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 7); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_STABLEMASTER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 8); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_BATTLEMASTER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 9); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_CLASSTRAINER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 10); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_PROFTRAINER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 11); - player->SEND_GOSSIP_MENU(3543,_Creature->GetGUID()); - return true; -} - -void SendDefaultMenu_guard_bluffwatcher(Player *player, Creature *_Creature, uint32 action) -{ - switch (action) - { - case GOSSIP_ACTION_INFO_DEF + 1: //Bank - player->SEND_POI(-1257.8, 24.14, 6, 6, 0, "Thunder Bluff Bank"); - player->SEND_GOSSIP_MENU(1292,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 2: //Wind master - player->SEND_POI(-1196.43, 28.26, 6, 6, 0, "Wind Rider Roost"); - player->SEND_GOSSIP_MENU(1293,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 3: //Guild master - player->SEND_POI(-1296.5, 127.57, 6, 6, 0, "Thunder Bluff Civic Information"); - player->SEND_GOSSIP_MENU(1291,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 4: //Inn - player->SEND_POI(-1296, 39.7, 6, 6, 0, "Thunder Bluff Inn"); - player->SEND_GOSSIP_MENU(3153,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 5: //Mailbox - player->SEND_POI(-1263.59, 44.36, 6, 6, 0, "Thunder Bluff Mailbox"); - player->SEND_GOSSIP_MENU(3154,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 6: //Auction House - player->SEND_POI(1381.77, -4371.16, 6, 6, 0, GOSSIP_TEXT_AUCTIONHOUSE); - player->SEND_GOSSIP_MENU(3155,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 7: //Weapon master - player->SEND_POI(-1282.31, 89.56, 6, 6, 0, "Ansekhwa"); - player->SEND_GOSSIP_MENU(4520,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 8: //Stable master - player->SEND_POI(-1270.19, 48.84, 6, 6, 0, "Bulrug"); - player->SEND_GOSSIP_MENU(5977,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 9: //battlemaster - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ALTERACVALLEY , GOSSIP_SENDER_SEC_BATTLEINFO, GOSSIP_ACTION_INFO_DEF + 1); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ARATHIBASIN , GOSSIP_SENDER_SEC_BATTLEINFO, GOSSIP_ACTION_INFO_DEF + 2); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_WARSONGULCH , GOSSIP_SENDER_SEC_BATTLEINFO, GOSSIP_ACTION_INFO_DEF + 3); - player->SEND_GOSSIP_MENU(7527,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 10: //Class trainer - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_DRUID , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 1); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_HUNTER , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 2); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_MAGE , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 3); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_PRIEST , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 4); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_SHAMAN , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 5); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_WARRIOR , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 6); - player->SEND_GOSSIP_MENU(3542,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 11: //Profession trainer - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ALCHEMY , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 1); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_BLACKSMITHING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 2); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_COOKING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 3); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ENCHANTING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 4); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_FIRSTAID , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 5); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_FISHING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 6); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_HERBALISM , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 7); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_LEATHERWORKING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 8); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_MINING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 9); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_SKINNING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 10); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_TAILORING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 11); - player->SEND_GOSSIP_MENU(3541,_Creature->GetGUID()); - break; - } -} - -void SendBattleMasterMenu_guard_bluffwatcher(Player *player, Creature *_Creature, uint32 action) -{ - switch (action) - { - case GOSSIP_ACTION_INFO_DEF + 1: //AV - player->SEND_POI(-1387.82, -97.55, 6, 6, 0, "Taim Ragetotem"); - player->SEND_GOSSIP_MENU(7522,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 2: //AB - player->SEND_POI(-997, 214.12, 6, 6, 0, "Martin Lindsey"); - player->SEND_GOSSIP_MENU(7648,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 3: //WSG - player->SEND_POI(-1384.94, -75.91, 6, 6, 0, "Kergul Bloodaxe"); - player->SEND_GOSSIP_MENU(7523,_Creature->GetGUID()); - break; - } -} - -void SendClassTrainerMenu_guard_bluffwatcher(Player *player, Creature *_Creature, uint32 action) -{ - switch (action) - { - case GOSSIP_ACTION_INFO_DEF + 1: //Druid - player->SEND_POI(-1054.47, -285, 6, 6, 0, "Hall of Elders"); - player->SEND_GOSSIP_MENU(1294,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 2: //Hunter - player->SEND_POI(-1416.32, -114.28, 6, 6, 0, "Hunter's Hall"); - player->SEND_GOSSIP_MENU(1295,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 3: //Mage - player->SEND_POI(-1061.2, 195.5, 6, 6, 0, "Pools of Vision"); - player->SEND_GOSSIP_MENU(1296,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 4: //Priest - player->SEND_POI(-1061.2, 195.5, 6, 6, 0, "Pools of Vision"); - player->SEND_GOSSIP_MENU(1297,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 5: //Shaman - player->SEND_POI(-989.54, 278.25, 6, 6, 0, "Hall of Spirits"); - player->SEND_GOSSIP_MENU(1298,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 6: //Warrior - player->SEND_POI(-1416.32, -114.28, 6, 6, 0, "Hunter's Hall"); - player->SEND_GOSSIP_MENU(1299,_Creature->GetGUID()); - break; - } -} - -void SendProfTrainerMenu_guard_bluffwatcher(Player *player, Creature *_Creature, uint32 action) -{ - switch (action) - { - case GOSSIP_ACTION_INFO_DEF + 1: //Alchemy - player->SEND_POI(-1085.56, 27.29, 6, 6, 0, "Bena's Alchemy"); - player->SEND_GOSSIP_MENU(1332,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 2: //Blacksmithing - player->SEND_POI(-1239.75, 104.88, 6, 6, 0, "Karn's Smithy"); - player->SEND_GOSSIP_MENU(1333,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 3: //Cooking - player->SEND_POI(-1214.5, -21.23, 6, 6, 0, "Aska's Kitchen"); - player->SEND_GOSSIP_MENU(1334,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 4: //Enchanting - player->SEND_POI(-1112.65, 48.26, 6, 6, 0, "Dawnstrider Enchanters"); - player->SEND_GOSSIP_MENU(1335,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 5: //First Aid - player->SEND_POI(-996.58, 200.5, 6, 6, 0, "Spiritual Healing"); - player->SEND_GOSSIP_MENU(1336,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 6: //Fishing - player->SEND_POI(-1169.35, -68.87, 6, 6, 0, "Mountaintop Bait & Tackle"); - player->SEND_GOSSIP_MENU(1337,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 7: //Herbalism - player->SEND_POI(-1137.7, -1.51, 6, 6, 0, "Holistic Herbalism"); - player->SEND_GOSSIP_MENU(1338,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 8: //Leatherworking - player->SEND_POI(-1156.22, 66.86, 6, 6, 0, "Thunder Bluff Armorers"); - player->SEND_GOSSIP_MENU(1339,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 9: //Mining - player->SEND_POI(-1249.17, 155, 6, 6, 0, "Stonehoof Geology"); - player->SEND_GOSSIP_MENU(1340,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 10: //Skinning - player->SEND_POI(-1148.56, 51.18, 6, 6, 0, "Mooranta"); - player->SEND_GOSSIP_MENU(1343,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 11: //Tailoring - player->SEND_POI(-1156.22, 66.86, 6, 6, 0, "Thunder Bluff Armorers"); - player->SEND_GOSSIP_MENU(1341,_Creature->GetGUID()); - break; - } -} - -bool GossipSelect_guard_bluffwatcher(Player *player, Creature *_Creature, uint32 sender, uint32 action ) -{ - switch (sender) - { - case GOSSIP_SENDER_MAIN: SendDefaultMenu_guard_bluffwatcher(player, _Creature, action); break; - case GOSSIP_SENDER_SEC_CLASSTRAIN: SendClassTrainerMenu_guard_bluffwatcher(player, _Creature, action); break; - case GOSSIP_SENDER_SEC_PROFTRAIN: SendProfTrainerMenu_guard_bluffwatcher(player, _Creature, action); break; - case GOSSIP_SENDER_SEC_BATTLEINFO: SendBattleMasterMenu_guard_bluffwatcher(player, _Creature, action); break; - } - return true; -} - -/******************************************************* - * guard_bluffwatcher end - *******************************************************/ - -CreatureAI* GetAI_guard_bluffwatcher(Creature *_Creature) -{ - return new guardAI (_Creature); -} - -/******************************************************* - * guard_contested start - *******************************************************/ - -struct MANGOS_DLL_DECL guard_contested : public guardAI -{ - guard_contested(Creature *c) : guardAI(c) {} - - void MoveInLineOfSight(Unit *who) - { - if ( who->isAttackingPlayer() ) - { - if(who->GetTypeId() == TYPEID_PLAYER || who->GetOwnerGUID() && GUID_HIPART(who->GetOwnerGUID())==HIGHGUID_PLAYER) - { - m_creature->AddThreat(who, 0.0f); - if(Unit* owner = who->GetOwner()) - m_creature->AddThreat(owner, 0.0f); - - if(!m_creature->isInCombat()) - { - if (m_creature->GetEntry() == 15184) //Cenarion Hold Infantry - { - srand (time(NULL)); - if (rand()%100 <= 30) - { - DoSay("Taste blade, mongrel!", LANG_UNIVERSAL,NULL); - } - else if (rand()%100 > 30 && rand()%100 < 50) - { - DoSay("Please tell me that you didn`t just do what I think you just did. Please tell me that I`m not going to have to hurt you...", LANG_UNIVERSAL,NULL); - } - else if (rand()%100 >= 50) - { - DoSay("As if we don`t have enough problems, you go and create more!", LANG_UNIVERSAL,NULL); - } - } - else - { - SpellEntry const *spell = m_creature->reachWithSpellAttack(who); - DoCastSpell(who, spell); - } - } - DoStartAttackAndMovement(who); - } - } - } -}; -/******************************************************* - * guard_contested end - *******************************************************/ - -CreatureAI* GetAI_guard_contested(Creature *_Creature) -{ - return new guard_contested (_Creature); -} - -/******************************************************* - * guard_darnassus start - *******************************************************/ - -bool GossipHello_guard_darnassus(Player *player, Creature *_Creature) -{ - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_AUCTIONHOUSE , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_BANK , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_HIPPOGRYPH , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 3); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_GUILDMASTER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 4); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_INN , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 5); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_MAILBOX , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 6); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_STABLEMASTER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 7); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_WEAPONMASTER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 8); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_BATTLEMASTER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 9); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_CLASSTRAINER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 10); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_PROFTRAINER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 11); - player->SEND_GOSSIP_MENU(3016, _Creature->GetGUID()); - return true; -} - -void SendDefaultMenu_guard_darnassus(Player *player, Creature *_Creature, uint32 action) -{ - switch (action) - { - case GOSSIP_ACTION_INFO_DEF + 1: //Auction house - player->SEND_POI(9861.23, 2334.55, 6, 6, 0, "Darnassus Auction House"); - player->SEND_GOSSIP_MENU(3833, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 2: //Bank - player->SEND_POI(9938.45, 2512.35, 6, 6, 0, "Darnassus Bank"); - player->SEND_GOSSIP_MENU(3017, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 3: //Wind master - player->SEND_POI(9945.65, 2618.94, 6, 6, 0, "Rut'theran Village"); - player->SEND_GOSSIP_MENU(3018, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 4: //Guild master - player->SEND_POI(10076.40, 2199.59, 6, 6, 0, "Darnassus Guild Master"); - player->SEND_GOSSIP_MENU(3019, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 5: //Inn - player->SEND_POI(10133.29, 2222.52, 6, 6, 0, "Darnassus Inn"); - player->SEND_GOSSIP_MENU(3020, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 6: //Mailbox - player->SEND_POI(9942.17, 2495.48, 6, 6, 0, "Darnassus Mailbox"); - player->SEND_GOSSIP_MENU(3021, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 7: //Stable master - player->SEND_POI(10167.20, 2522.66, 6, 6, 0, "Alassin"); - player->SEND_GOSSIP_MENU(5980, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 8: //Weapon trainer - player->SEND_POI(9907.11, 2329.70, 6, 6, 0, "Ilyenia Moonfire"); - player->SEND_GOSSIP_MENU(4517, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 9: //Battlemaster - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ALTERACVALLEY , GOSSIP_SENDER_SEC_BATTLEINFO, GOSSIP_ACTION_INFO_DEF + 1); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ARATHIBASIN , GOSSIP_SENDER_SEC_BATTLEINFO, GOSSIP_ACTION_INFO_DEF + 2); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_WARSONGULCH , GOSSIP_SENDER_SEC_BATTLEINFO, GOSSIP_ACTION_INFO_DEF + 3); - player->SEND_GOSSIP_MENU(7519, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 10: //Class trainer - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_DRUID , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 1); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_HUNTER , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 2); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_PRIEST , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 3); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ROGUE , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 4); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_WARRIOR , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 5); - player->SEND_GOSSIP_MENU(4264, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 11: //Profession trainer - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ALCHEMY , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 1); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_COOKING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 2); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ENCHANTING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 3); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_FIRSTAID , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 4); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_FISHING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 5); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_HERBALISM , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 6); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_LEATHERWORKING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 7); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_SKINNING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 8); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_TAILORING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 9); - player->SEND_GOSSIP_MENU(4273, _Creature->GetGUID()); - break; - } -} - -void SendBattleMasterMenu_guard_darnassus(Player *player, Creature *_Creature, uint32 action) -{ - switch (action) - { - case GOSSIP_ACTION_INFO_DEF + 1: //AV - player->SEND_POI(9923.61, 2327.43, 6, 6, 0, "Brogun Stoneshield"); - player->SEND_GOSSIP_MENU(7518, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 2: //AB - player->SEND_POI(9977.37, 2324.39, 6, 6, 0, "Keras Wolfheart"); - player->SEND_GOSSIP_MENU(7651, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 3: //WSG - player->SEND_POI(9979.84, 2315.79, 6, 6, 0, "Aethalas"); - player->SEND_GOSSIP_MENU(7482, _Creature->GetGUID()); - break; - } -} - -void SendClassTrainerMenu_guard_darnassus(Player *player, Creature *_Creature, uint32 action) -{ - switch (action) - { - case GOSSIP_ACTION_INFO_DEF + 1: //Druid - player->SEND_POI(10186, 2570.46, 6, 6, 0, "Darnassus Druid Trainer"); - player->SEND_GOSSIP_MENU(3024, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 2: //Hunter - player->SEND_POI(10177.29, 2511.10, 6, 6, 0, "Darnassus Hunter Trainer"); - player->SEND_GOSSIP_MENU(3023, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 3: //Priest - player->SEND_POI(9659.12, 2524.88, 6, 6, 0, "Temple of the Moon"); - player->SEND_GOSSIP_MENU(3025, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 4: //Rogue - player->SEND_POI(10122, 2599.12, 6, 6, 0, "Darnassus Rogue Trainer"); - player->SEND_GOSSIP_MENU(3026, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 5: //Warrior - player->SEND_POI(9951.91, 2280.38, 6, 6, 0, "Warrior's Terrace"); - player->SEND_GOSSIP_MENU(3033, _Creature->GetGUID()); - break; - } -} - -void SendProfTrainerMenu_guard_darnassus(Player *player, Creature *_Creature, uint32 action) -{ - switch (action) - { - case GOSSIP_ACTION_INFO_DEF + 1: //Alchemy - player->SEND_POI(10075.90, 2356.76, 6, 6, 0, "Darnassus Alchemy Trainer"); - player->SEND_GOSSIP_MENU(3035, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 2: //Cooking - player->SEND_POI(10088.59, 2419.21, 6, 6, 0, "Darnassus Cooking Trainer"); - player->SEND_GOSSIP_MENU(3036, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 3: //Enchanting - player->SEND_POI(10146.09, 2313.42, 6, 6, 0, "Darnassus Enchanting Trainer"); - player->SEND_GOSSIP_MENU(3337, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 4: //First Aid - player->SEND_POI(10150.09, 2390.43, 6, 6, 0, "Darnassus First Aid Trainer"); - player->SEND_GOSSIP_MENU(3037, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 5: //Fishing - player->SEND_POI(9836.20, 2432.17, 6, 6, 0, "Darnassus Fishing Trainer"); - player->SEND_GOSSIP_MENU(3038, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 6: //Herbalism - player->SEND_POI(9757.17, 2430.16, 6, 6, 0, "Darnassus Herbalism Trainer"); - player->SEND_GOSSIP_MENU(3039, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 7: //Leatherworking - player->SEND_POI(10086.59, 2255.77, 6, 6, 0, "Darnassus Leatherworking Trainer"); - player->SEND_GOSSIP_MENU(3040, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 8: //Skinning - player->SEND_POI(10081.40, 2257.18, 6, 6, 0, "Darnassus Skinning Trainer"); - player->SEND_GOSSIP_MENU(3042, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 9: //Tailoring - player->SEND_POI(10079.70, 2268.19, 6, 6, 0, "Darnassus Tailor"); - player->SEND_GOSSIP_MENU(3044, _Creature->GetGUID()); - break; - } -} - -bool GossipSelect_guard_darnassus(Player *player, Creature *_Creature, uint32 sender, uint32 action ) -{ - switch (sender) - { - case GOSSIP_SENDER_MAIN: SendDefaultMenu_guard_darnassus(player, _Creature, action); break; - case GOSSIP_SENDER_SEC_CLASSTRAIN: SendClassTrainerMenu_guard_darnassus(player, _Creature, action); break; - case GOSSIP_SENDER_SEC_PROFTRAIN: SendProfTrainerMenu_guard_darnassus(player, _Creature, action); break; - case GOSSIP_SENDER_SEC_BATTLEINFO: SendBattleMasterMenu_guard_darnassus(player, _Creature, action); break; - } - return true; -} - -/******************************************************* - * guard_darnassus end - *******************************************************/ - -CreatureAI* GetAI_guard_darnassus(Creature *_Creature) -{ - return new guardAI (_Creature); -} - -/******************************************************* - * guard_dunmorogh start - *******************************************************/ - -bool GossipHello_guard_dunmorogh(Player *player, Creature *_Creature) -{ - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_BANK , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_HIPPOGRYPH , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_GUILDMASTER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 3); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_INN , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 4); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_STABLEMASTER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 5); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_CLASSTRAINER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 6); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_PROFTRAINER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 7); - player->SEND_GOSSIP_MENU(4287,_Creature->GetGUID()); - - return true; -} - -void SendDefaultMenu_guard_dunmorogh(Player *player, Creature *_Creature, uint32 action) -{ - switch (action) - { - case GOSSIP_ACTION_INFO_DEF + 1: //Bank - player->SEND_GOSSIP_MENU(4288,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 2: //Gryphon master - player->SEND_GOSSIP_MENU(4289,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 3: //Guild master - player->SEND_GOSSIP_MENU(4290,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 4: //Inn - player->SEND_POI(-5582.66, -525.89, 6, 6, 0, "Thunderbrew Distillery"); - player->SEND_GOSSIP_MENU(4291,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 5: //Stable Master - player->SEND_POI(-5604, -509.58, 6, 6, 0, "Shelby Stoneflint"); - player->SEND_GOSSIP_MENU(5985,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 6: //Class trainer - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_HUNTER , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 1); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_MAGE , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 2); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_PALADIN , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 3); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_PRIEST , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 4); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ROGUE , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 5); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_WARLOCK , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 6); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_WARRIOR , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 7); - player->SEND_GOSSIP_MENU(4292,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 7: //Profession trainer - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ALCHEMY , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 1); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_BLACKSMITHING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 2); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_COOKING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 3); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ENCHANTING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 4); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ENGINEERING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 5); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_FIRSTAID , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 6); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_FISHING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 7); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_HERBALISM , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 8); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_LEATHERWORKING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 9); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_MINING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 10); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_SKINNING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 11); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_TAILORING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 12); - player->SEND_GOSSIP_MENU(4300,_Creature->GetGUID()); - break; - } -} - -void SendClassTrainerMenu_guard_dunmorogh(Player *player, Creature *_Creature, uint32 action) -{ - switch (action) - { - case GOSSIP_ACTION_INFO_DEF + 1: //Hunter - player->SEND_POI(-5618.29, -454.25, 6, 6, 0, "Grif Wildheart"); - player->SEND_GOSSIP_MENU(4293,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 2: //Mage - player->SEND_POI(-5585.6, -539.99, 6, 6, 0, "Magis Sparkmantle"); - player->SEND_GOSSIP_MENU(4294,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 3: //Paladin - player->SEND_POI(-5585.6, -539.99, 6, 6, 0, "Azar Stronghammer"); - player->SEND_GOSSIP_MENU(4295,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 4: //Priest - player->SEND_POI(-5591.74, -525.61, 6, 6, 0, "Maxan Anvol"); - player->SEND_GOSSIP_MENU(4296,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 5: //Rogue - player->SEND_POI(-5602.75, -542.4, 6, 6, 0, "Hogral Bakkan"); - player->SEND_GOSSIP_MENU(4297,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 6: //Warlock - player->SEND_POI(-5641.97, -523.76, 6, 6, 0, "Gimrizz Shadowcog"); - player->SEND_GOSSIP_MENU(4298,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 7: //Warrior - player->SEND_POI(-5604.79, -529.38, 6, 6, 0, "Granis Swiftaxe"); - player->SEND_GOSSIP_MENU(4299,_Creature->GetGUID()); - break; - } -} - -void SendProfTrainerMenu_guard_dunmorogh(Player *player, Creature *_Creature, uint32 action) -{ - switch (action) - { - case GOSSIP_ACTION_INFO_DEF + 1: //Alchemy - player->SEND_GOSSIP_MENU(4301,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 2: //Blacksmithing - player->SEND_POI(-5584.72, -428.41, 6, 6, 0, "Tognus Flintfire"); - player->SEND_GOSSIP_MENU(4302,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 3: //Cooking - player->SEND_POI(-5596.85, -541.43, 6, 6, 0, "Gremlock Pilsnor"); - player->SEND_GOSSIP_MENU(4303,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 4: //Enchanting - player->SEND_GOSSIP_MENU(4304,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 5: //Engineering - player->SEND_POI(-5531, -666.53, 6, 6, 0, "Bronk Guzzlegear"); - player->SEND_GOSSIP_MENU(4305,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 6: //First Aid - player->SEND_POI(-5603.67, -523.57, 6, 6, 0, "Thamner Pol"); - player->SEND_GOSSIP_MENU(4306,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 7: //Fishing - player->SEND_POI(-5199.9, 58.58, 6, 6, 0, "Paxton Ganter"); - player->SEND_GOSSIP_MENU(4307,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 8: //Herbalism - player->SEND_GOSSIP_MENU(4308,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 9: //Leatherworking - player->SEND_GOSSIP_MENU(4310,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 10: //Mining - player->SEND_POI(-5531, -666.53, 6, 6, 0, "Yarr Hamerstone"); - player->SEND_GOSSIP_MENU(4311,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 11: //Skinning - player->SEND_GOSSIP_MENU(4312,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 12: //Tailoring - player->SEND_GOSSIP_MENU(4313,_Creature->GetGUID()); - break; - } -} - -bool GossipSelect_guard_dunmorogh(Player *player, Creature *_Creature, uint32 sender, uint32 action ) -{ - switch (sender) - { - case GOSSIP_SENDER_MAIN: SendDefaultMenu_guard_dunmorogh(player, _Creature, action); break; - case GOSSIP_SENDER_SEC_CLASSTRAIN: SendClassTrainerMenu_guard_dunmorogh(player, _Creature, action); break; - case GOSSIP_SENDER_SEC_PROFTRAIN: SendProfTrainerMenu_guard_dunmorogh(player, _Creature, action); break; - } - return true; -} - -/******************************************************* - * guard_dunmorogh end - *******************************************************/ - -CreatureAI* GetAI_guard_dunmorogh(Creature *_Creature) -{ - return new guardAI (_Creature); -} - -/******************************************************* - * guard_durotar start - *******************************************************/ - -bool GossipHello_guard_durotar(Player *player, Creature *_Creature) -{ - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_BANK , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_WINDRIDER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_INN , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 3); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_STABLEMASTER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 4); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_CLASSTRAINER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 5); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_PROFTRAINER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 6); - player->SEND_GOSSIP_MENU(4037,_Creature->GetGUID()); - return true; -} - -void SendDefaultMenu_guard_durotar(Player *player, Creature *_Creature, uint32 action) -{ - switch (action) - { - case GOSSIP_ACTION_INFO_DEF + 1: //Bank - player->SEND_GOSSIP_MENU(4032,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 2: //Wind rider - player->SEND_GOSSIP_MENU(4033,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 3: //Inn - player->SEND_POI(338.7, -4688.87, 6, 6, 0, "Razor Hill Inn"); - player->SEND_GOSSIP_MENU(4034,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 4: //Stable master - player->SEND_POI(330.31, -4710.66, 6, 6, 0, "Shoja'my"); - player->SEND_GOSSIP_MENU(5973,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 5: //Class trainer - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_HUNTER , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 1); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_MAGE , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 2); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_PRIEST , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 3); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ROGUE , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 4); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_SHAMAN , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 5); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_WARLOCK , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 6); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_WARRIOR , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 7); - player->SEND_GOSSIP_MENU(4035,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 6: //Profession trainer - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ALCHEMY , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 1); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_BLACKSMITHING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 2); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_COOKING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 3); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ENCHANTING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 4); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ENGINEERING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 5); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_FIRSTAID , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 6); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_FISHING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 7); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_HERBALISM , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 8); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_LEATHERWORKING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 9); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_MINING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 10); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_SKINNING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 11); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_TAILORING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 12); - player->SEND_GOSSIP_MENU(4036,_Creature->GetGUID()); - break; - } -} - -void SendClassTrainerMenu_guard_durotar(Player *player, Creature *_Creature, uint32 action) -{ - switch (action) - { - case GOSSIP_ACTION_INFO_DEF + 1: //Hunter - player->SEND_POI(276, -4706.72, 6, 6, 0, "Thotar"); - player->SEND_GOSSIP_MENU(4013,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 2: //Mage - player->SEND_POI(-839.33, -4935.6, 6, 6, 0, "Un'Thuwa"); - player->SEND_GOSSIP_MENU(4014,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 3: //Priest - player->SEND_POI(296.22, -4828.1, 6, 6, 0, "Tai'jin"); - player->SEND_GOSSIP_MENU(4015,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 4: //Rogue - player->SEND_POI(265.76, -4709, 6, 6, 0, "Kaplak"); - player->SEND_GOSSIP_MENU(4016,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 5: //Shaman - player->SEND_POI(307.79, -4836.97, 6, 6, 0, "Swart"); - player->SEND_GOSSIP_MENU(4017,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 6: //Warlock - player->SEND_POI(355.88, -4836.45, 6, 6, 0, "Dhugru Gorelust"); - player->SEND_GOSSIP_MENU(4018,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 7: //Warrior - player->SEND_POI(312.3, -4824.66, 6, 6, 0, "Tarshaw Jaggedscar"); - player->SEND_GOSSIP_MENU(4019,_Creature->GetGUID()); - break; - } -} - -void SendProfTrainerMenu_guard_durotar(Player *player, Creature *_Creature, uint32 action) -{ - switch (action) - { - case GOSSIP_ACTION_INFO_DEF + 1: //Alchemy - player->SEND_POI(-800.25, -4894.33, 6, 6, 0, "Miao'zan"); - player->SEND_GOSSIP_MENU(4020,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 2: //Blacksmithing - player->SEND_POI(373.24, -4716.45, 6, 6, 0, "Dwukk"); - player->SEND_GOSSIP_MENU(4021,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 3: //Cooking - player->SEND_GOSSIP_MENU(4022,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 4: //Enchanting - player->SEND_GOSSIP_MENU(4023,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 5: //Engineering - player->SEND_POI(368.95, -4723.95, 6, 6, 0, "Mukdrak"); - player->SEND_GOSSIP_MENU(4024,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 6: //First Aid - player->SEND_POI(327.17, -4825.62, 6, 6, 0, "Rawrk"); - player->SEND_GOSSIP_MENU(4025,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 7: //Fishing - player->SEND_POI(-1065.48, -4777.43, 6, 6, 0, "Lau'Tiki"); - player->SEND_GOSSIP_MENU(4026,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 8: //Herbalism - player->SEND_POI(-836.25, -4896.89, 6, 6, 0, "Mishiki"); - player->SEND_GOSSIP_MENU(4027,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 9: //Leatherworking - player->SEND_GOSSIP_MENU(4028,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 10: //Mining - player->SEND_POI(366.94, -4705, 6, 6, 0, "Krunn"); - player->SEND_GOSSIP_MENU(4029,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 11: //Skinning - player->SEND_GOSSIP_MENU(4030,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 12: //Tailoring - player->SEND_GOSSIP_MENU(4031,_Creature->GetGUID()); - break; - } -} - -bool GossipSelect_guard_durotar(Player *player, Creature *_Creature, uint32 sender, uint32 action ) -{ - switch (sender) - { - case GOSSIP_SENDER_MAIN: SendDefaultMenu_guard_durotar(player, _Creature, action); break; - case GOSSIP_SENDER_SEC_CLASSTRAIN: SendClassTrainerMenu_guard_durotar(player, _Creature, action); break; - case GOSSIP_SENDER_SEC_PROFTRAIN: SendProfTrainerMenu_guard_durotar(player, _Creature, action); break; - } - return true; -} - -/******************************************************* - * guard_durotar end - *******************************************************/ - -CreatureAI* GetAI_guard_durotar(Creature *_Creature) -{ - return new guardAI (_Creature); -} - -/******************************************************* - * guard_elwynnforest start - *******************************************************/ - -bool GossipHello_guard_elwynnforest(Player *player, Creature *_Creature) -{ - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_BANK , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_GRYPHON , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_GUILDMASTER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 3); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_INN , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 4); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_STABLEMASTER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 5); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_CLASSTRAINER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 6); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_PROFTRAINER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 7); - player->SEND_GOSSIP_MENU(933,_Creature->GetGUID()); - return true; -} - -void SendDefaultMenu_guard_elwynnforest(Player *player, Creature *_Creature, uint32 action) -{ - switch (action) - { - case GOSSIP_ACTION_INFO_DEF + 1: //Bank - player->SEND_GOSSIP_MENU(4260,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 2: //Gryphon master - player->SEND_GOSSIP_MENU(4261,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 3: //Guild master - player->SEND_GOSSIP_MENU(4262,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 4: //Inn - player->SEND_POI(-9459.34, 42.08, 6, 6, 0, "Lion's Pride Inn"); - player->SEND_GOSSIP_MENU(4263,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 5: //Stable Master - player->SEND_POI(-9466.62, 45.87, 6, 6, 0, "Erma"); - player->SEND_GOSSIP_MENU(5983,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 6: //Class trainer - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_DRUID , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 1); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_HUNTER , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 2); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_MAGE , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 3); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_PALADIN , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 4); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_PRIEST , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 5); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ROGUE , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 6); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_WARLOCK , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 7); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_WARRIOR , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 8); - player->SEND_GOSSIP_MENU(4264,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 7: //Profession trainer - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ALCHEMY , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 1); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_BLACKSMITHING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 2); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_COOKING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 3); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ENCHANTING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 4); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ENGINEERING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 5); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_FIRSTAID , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 6); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_FISHING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 7); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_HERBALISM , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 8); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_LEATHERWORKING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 9); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_MINING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 10); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_SKINNING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 11); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_TAILORING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 12); - player->SEND_GOSSIP_MENU(4273,_Creature->GetGUID()); - break; - } -} - -void SendClassTrainerMenu_guard_elwynnforest(Player *player, Creature *_Creature, uint32 action) -{ - switch (action) - { - case GOSSIP_ACTION_INFO_DEF + 1: //Druid - player->SEND_GOSSIP_MENU(4265,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 2: //Hunter - player->SEND_GOSSIP_MENU(4266,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 3: //Mage - player->SEND_POI(-9471.12, 33.44, 6, 6, 0, "Zaldimar Wefhellt"); - player->SEND_GOSSIP_MENU(4268,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 4: //Paladin - player->SEND_POI(-9469, 108.05, 6, 6, 0, "Brother Wilhelm"); - player->SEND_GOSSIP_MENU(4269,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 5: //Priest - player->SEND_POI(-9461.07, 32.6, 6, 6, 0, "Priestess Josetta"); - player->SEND_GOSSIP_MENU(4267,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 6: //Rogue - player->SEND_POI(-9465.13, 13.29, 6, 6, 0, "Keryn Sylvius"); - player->SEND_GOSSIP_MENU(4270,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 7: //Warlock - player->SEND_POI(-9473.21, -4.08, 6, 6, 0, "Maximillian Crowe"); - player->SEND_GOSSIP_MENU(4272,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 8: //Warrior - player->SEND_POI(-9461.82, 109.50, 6, 6, 0, "Lyria Du Lac"); - player->SEND_GOSSIP_MENU(4271,_Creature->GetGUID()); - break; - } -} - -void SendProfTrainerMenu_guard_elwynnforest(Player *player, Creature *_Creature, uint32 action) -{ - switch (action) - { - case GOSSIP_ACTION_INFO_DEF + 1: //Alchemy - player->SEND_POI(-9057.04, 153.63, 6, 6, 0, "Alchemist Mallory"); - player->SEND_GOSSIP_MENU(4274,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 2: //Blacksmithing - player->SEND_POI(-9456.58, 87.90, 6, 6, 0, "Smith Argus"); - player->SEND_GOSSIP_MENU(4275,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 3: //Cooking - player->SEND_POI(-9467.54, -3.16, 6, 6, 0, "Tomas"); - player->SEND_GOSSIP_MENU(4276,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 4: //Enchanting - player->SEND_GOSSIP_MENU(4277,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 5: //Engineering - player->SEND_GOSSIP_MENU(4278,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 6: //First Aid - player->SEND_POI(-9456.82, 30.49, 6, 6, 0, "Michelle Belle"); - player->SEND_GOSSIP_MENU(4279,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 7: //Fishing - player->SEND_POI(-9386.54, -118.73, 6, 6, 0, "Lee Brown"); - player->SEND_GOSSIP_MENU(4280,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 8: //Herbalism - player->SEND_POI(-9060.70, 149.23, 6, 6, 0, "Herbalist Pomeroy"); - player->SEND_GOSSIP_MENU(4281,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 9: //Leatherworking - player->SEND_POI(-9376.12, -75.23, 6, 6, 0, "Adele Fielder"); - player->SEND_GOSSIP_MENU(4282,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 10: //Mining - player->SEND_GOSSIP_MENU(4283,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 11: //Skinning - player->SEND_POI(-9536.91, -1212.76, 6, 6, 0, "Helene Peltskinner"); - player->SEND_GOSSIP_MENU(4284,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 12: //Tailoring - player->SEND_POI(-9376.12, -75.23, 6, 6, 0, "Eldrin"); - player->SEND_GOSSIP_MENU(4285,_Creature->GetGUID()); - break; - } -} - -bool GossipSelect_guard_elwynnforest(Player *player, Creature *_Creature, uint32 sender, uint32 action ) -{ - switch (sender) - { - case GOSSIP_SENDER_MAIN: SendDefaultMenu_guard_elwynnforest(player, _Creature, action); break; - case GOSSIP_SENDER_SEC_CLASSTRAIN: SendClassTrainerMenu_guard_elwynnforest(player, _Creature, action); break; - case GOSSIP_SENDER_SEC_PROFTRAIN: SendProfTrainerMenu_guard_elwynnforest(player, _Creature, action); break; - } - return true; -} - -/******************************************************* - * guard_elwynnforest end - *******************************************************/ - -CreatureAI* GetAI_guard_elwynnforest(Creature *_Creature) -{ - return new guardAI (_Creature); -} - -/******************************************************* - * guard_eversong start - *******************************************************/ - -bool GossipHello_guard_eversong(Player *player, Creature *_Creature) -{ - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_BATHANDLER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_GUILDMASTER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_INN , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 3); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_STABLEMASTER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 4); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_CLASSTRAINER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 5); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_PROFTRAINER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 6); - player->SEND_GOSSIP_MENU(10180,_Creature->GetGUID()); - return true; -} - -void SendDefaultMenu_guard_eversong(Player *player, Creature *_Creature, uint32 action) -{ - switch (action) - { - case GOSSIP_ACTION_INFO_DEF + 1: //Bat Handler - player->SEND_POI(9371.93, -7164.80, 6, 6, 0, "Skymistress Gloaming"); - player->SEND_GOSSIP_MENU(10181,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 2: //Guild master - player->SEND_GOSSIP_MENU(10182,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 3: //Inn - player->SEND_POI(9483.74, -6844.58, 6, 6, 0, "Delaniel's inn"); - player->SEND_GOSSIP_MENU(10183,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 4: //Stable Master - player->SEND_POI(9489.62, -6829.93, 6, 6, 0, "Anathos"); - player->SEND_GOSSIP_MENU(10184,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 5: //Class trainer - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_DRUID , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 1); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_HUNTER , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 2); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_MAGE , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 3); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_PALADIN , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 4); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_PRIEST , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 5); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ROGUE , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 6); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_WARLOCK , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 7); - player->SEND_GOSSIP_MENU(10180,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 6: //Profession trainer - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ALCHEMY , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 1); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_BLACKSMITHING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 2); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_COOKING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 3); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ENGINEERING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 4); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_FIRSTAID , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 5); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_FISHING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 6); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_HERBALISM , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 7); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_JEWELCRAFTING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 8); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_LEATHERWORKING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 9); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_MINING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 10); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_SKINNING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 11); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_TAILORING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 12); - player->SEND_GOSSIP_MENU(10180,_Creature->GetGUID()); - break; - } -} - -void SendClassTrainerMenu_guard_eversong(Player *player, Creature *_Creature, uint32 action) -{ - switch (action) - { - case GOSSIP_ACTION_INFO_DEF + 1: //Druid - player->SEND_GOSSIP_MENU(10185,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 2: //Hunter - player->SEND_POI(9527.44, -6865.25, 6, 6, 0, "Hannovia"); - player->SEND_GOSSIP_MENU(10186,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 3: //Mage - player->SEND_POI(9464.24, -6855.52, 6, 6, 0, "Garridel"); - player->SEND_GOSSIP_MENU(10187,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 4: //Paladin - player->SEND_POI(9517.61, -6871.04, 6, 6, 0, "Noellene"); - player->SEND_GOSSIP_MENU(10189,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 5: //Priest - player->SEND_POI(9467.39, -6845.72, 6, 6, 0, "Ponaris"); - player->SEND_GOSSIP_MENU(10190,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 6: //Rogue - player->SEND_POI(9533.67, -6877.39, 6, 6, 0, "Tannaria"); - player->SEND_GOSSIP_MENU(10191,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 7: //Warlock - player->SEND_POI(9468.99, -6865.60, 6, 6, 0, "Celoenus"); - player->SEND_GOSSIP_MENU(10192,_Creature->GetGUID()); - break; - } -} - -void SendProfTrainerMenu_guard_eversong(Player *player, Creature *_Creature, uint32 action) -{ - switch (action) - { - case GOSSIP_ACTION_INFO_DEF + 1: //Alchemy - player->SEND_POI(8659.90, -6368.12, 6, 6, 0, "Arcanist Sheynathren"); - player->SEND_GOSSIP_MENU(10193,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 2: //Blacksmithing - player->SEND_POI(8984.21, -7419.21, 6, 6, 0, "Arathel Sunforge"); - player->SEND_GOSSIP_MENU(10194,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 3: //Cooking - player->SEND_POI(9494.04, -6881.51, 6, 6, 0, "Quarelestra"); - player->SEND_GOSSIP_MENU(10195,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 4: //Engineering - player->SEND_GOSSIP_MENU(10197,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 5: //First Aid - player->SEND_POI(9479.46, -6879.16, 6, 6, 0, "Kanaria"); - player->SEND_GOSSIP_MENU(10198,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 6: //Fishing - player->SEND_GOSSIP_MENU(10199,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 7: //Herbalism - player->SEND_POI(8678.92, -6329.09, 6, 6, 0, "Botanist Tyniarrel"); - player->SEND_GOSSIP_MENU(10200,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 8: //Jewelcrafting - player->SEND_POI(9484.32, -6874.98, 6, 6, 0, "Aleinia"); - player->SEND_GOSSIP_MENU(10203,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 9: //Leatherworking - player->SEND_POI(9362.04, -7130.33, 6, 6, 0, "Sathein"); - player->SEND_GOSSIP_MENU(10204,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 10: //Mining - player->SEND_GOSSIP_MENU(10205,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 11: //Skinning - player->SEND_POI(9362.04, -7130.33, 6, 6, 0, "Mathreyn"); - player->SEND_GOSSIP_MENU(10206,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 12: //Tailoring - player->SEND_POI(8680.36, -6327.51, 6, 6, 0, "Sempstress Ambershine"); - player->SEND_GOSSIP_MENU(10207,_Creature->GetGUID()); - break; - } -} - -bool GossipSelect_guard_eversong(Player *player, Creature *_Creature, uint32 sender, uint32 action ) -{ - switch (sender) - { - case GOSSIP_SENDER_MAIN: SendDefaultMenu_guard_eversong(player, _Creature, action); break; - case GOSSIP_SENDER_SEC_CLASSTRAIN: SendClassTrainerMenu_guard_eversong(player, _Creature, action); break; - case GOSSIP_SENDER_SEC_PROFTRAIN: SendProfTrainerMenu_guard_eversong(player, _Creature, action); break; - } - return true; -} - -/******************************************************* - * guard_eversong end - *******************************************************/ - -CreatureAI* GetAI_guard_eversong(Creature *_Creature) -{ - return new guardAI (_Creature); -} - -/******************************************************* - * guard_exodar start - *******************************************************/ - -bool GossipHello_guard_exodar(Player *player, Creature *_Creature) -{ - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_AUCTIONHOUSE , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_BANK , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_GUILDMASTER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 3); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_HIPPOGRYPH , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 4); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_INN , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 5); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_MAILBOX , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 6); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_STABLEMASTER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 7); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_WEAPONMASTER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 8); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_BATTLEMASTER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 9); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_CLASSTRAINER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 10); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_PROFTRAINER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 11); - player->SEND_GOSSIP_MENU(9551, _Creature->GetGUID()); - return true; -} - -void SendDefaultMenu_guard_exodar(Player *player, Creature *_Creature, uint32 action) -{ - switch (action) - { - case GOSSIP_ACTION_INFO_DEF + 1: //Auction house - player->SEND_POI(-4023.6, -11739.3, 6, 6, 0, "Exodar Auction House"); - player->SEND_GOSSIP_MENU(9528, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 2: //Bank - player->SEND_POI(-3923.89, -11544.5, 6, 6, 0, "Exodar Bank"); - player->SEND_GOSSIP_MENU(9529, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 3: //Guild master - player->SEND_POI(-4092.57, -11626.5, 6, 6, 0, "Exodar Guild Master"); - player->SEND_GOSSIP_MENU(9539, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 4: //Hippogryph master - player->SEND_POI(-4060.46, -11787.1, 6, 6, 0, "Exodar Hippogryph Master"); - player->SEND_GOSSIP_MENU(9530, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 5: //Inn - player->SEND_POI(-3741.87, -11695.1, 6, 6, 0, "Exodar Inn"); - player->SEND_GOSSIP_MENU(9545, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 6: //Mailbox - player->SEND_POI(-3972.5, -11696.0, 6, 6, 0, "Mailbox"); - player->SEND_GOSSIP_MENU(10254, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 7: //Stable master - player->SEND_POI(-3786.5, -11702.5, 6, 6, 0, "Stable Master Arthaid"); - player->SEND_GOSSIP_MENU(9558, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 8: //Weapon trainer - player->SEND_POI(-4215.68, -11628.9, 6, 6, 0, "Weapon Master Handiir"); - player->SEND_GOSSIP_MENU(9565, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 9: //Battlemaster - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ALTERACVALLEY , GOSSIP_SENDER_SEC_BATTLEINFO, GOSSIP_ACTION_INFO_DEF + 1); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ARATHIBASIN , GOSSIP_SENDER_SEC_BATTLEINFO, GOSSIP_ACTION_INFO_DEF + 2); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ARENA , GOSSIP_SENDER_SEC_BATTLEINFO, GOSSIP_ACTION_INFO_DEF + 3); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_EYEOFTHESTORM , GOSSIP_SENDER_SEC_BATTLEINFO, GOSSIP_ACTION_INFO_DEF + 4); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_WARSONGULCH , GOSSIP_SENDER_SEC_BATTLEINFO, GOSSIP_ACTION_INFO_DEF + 5); - player->SEND_GOSSIP_MENU(9531, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 10: //Class trainer - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_DRUID , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 1); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_HUNTER , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 2); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_MAGE , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 3); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_PALADIN , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 4); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_PRIEST , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 5); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_SHAMAN , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 6); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_WARRIOR , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 7); - player->SEND_GOSSIP_MENU(9533, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 11: //Profession trainer - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ALCHEMY , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 1); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_BLACKSMITHING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 2); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_COOKING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 3); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ENCHANTING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 4); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ENGINEERING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 5); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_FIRSTAID , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 6); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_FISHING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 7); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_JEWELCRAFTING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 8); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_HERBALISM , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 9); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_LEATHERWORKING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 10); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_MINING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 11); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_SKINNING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 12); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_TAILORING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 13); - player->SEND_GOSSIP_MENU(9555, _Creature->GetGUID()); - break; - } -} - -void SendBattleMasterMenu_guard_exodar(Player *player, Creature *_Creature, uint32 action) -{ - switch (action) - { - case GOSSIP_ACTION_INFO_DEF + 1: //AV - player->SEND_POI(-3978.1, -11357, 6, 6, 0, "Alterac Valley Battlemaster"); - player->SEND_GOSSIP_MENU(9531, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 2: //AB - player->SEND_POI(-3998.9, -11345.2, 6, 6, 0, "Arathi Basin Battlemaster"); - player->SEND_GOSSIP_MENU(9531, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 3: //A - player->SEND_POI(-3759.27, -11695.63, 6, 6, 0, "Miglik Blotstrom"); - player->SEND_GOSSIP_MENU(10223, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 4: //EOS - player->SEND_POI(-3978.1, -11357, 6, 6, 0, "Eye Of The Storm Battlemaster"); - player->SEND_GOSSIP_MENU(9531, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 5: //WSG - player->SEND_POI(-3977.5, -11381.2, 6, 6, 0, "Warsong Gulch Battlemaster"); - player->SEND_GOSSIP_MENU(9531, _Creature->GetGUID()); - break; - } -} - -void SendClassTrainerMenu_guard_exodar(Player *player, Creature *_Creature, uint32 action) -{ - switch (action) - { - case GOSSIP_ACTION_INFO_DEF + 1: //Druid - player->SEND_POI(-4276.0, -11495, 6, 6, 0, "Exodar Druid Trainer"); - player->SEND_GOSSIP_MENU(9534, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 2: //Hunter - player->SEND_POI(-4210.6, -11575.2, 6, 6, 0, "Exodar Hunter Trainer"); - player->SEND_GOSSIP_MENU(9544, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 3: //Mage - player->SEND_POI(-4057.32, -11556.5, 6, 6, 0, "Exodar Mage Trainer"); - player->SEND_GOSSIP_MENU(9550, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 4: //Paladin - player->SEND_POI(-4191.2, -11470.4, 6, 6, 0, "Exodar Paladin Trainer"); - player->SEND_GOSSIP_MENU(9553, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 5: //Priest - player->SEND_POI(-3969.63, -11482.8, 6, 6, 0, "Exodar Priest Trainer"); - player->SEND_GOSSIP_MENU(9554, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 6: //Shaman - player->SEND_POI(-3805.5, -11380.7, 6, 6, 0, "Exodar Shaman Trainer"); - player->SEND_GOSSIP_MENU(9556, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 7: //Warrior - player->SEND_POI(-4189.43, -11653.7, 6, 6, 0, "Exodar Warrior Trainer"); - player->SEND_GOSSIP_MENU(9562, _Creature->GetGUID()); - break; - } -} - -void SendProfTrainerMenu_guard_exodar(Player *player, Creature *_Creature, uint32 action) -{ - switch (action) - { - case GOSSIP_ACTION_INFO_DEF + 1: //Alchemy - player->SEND_POI(-4040.6, -11364.5, 6, 6, 0, "Exodar Alchemy Trainer"); - player->SEND_GOSSIP_MENU(9527, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 2: //Blacksmithing - player->SEND_POI(-4229.5, -11706, 6, 6, 0, "Exodar Blacksmithing Trainer"); - player->SEND_GOSSIP_MENU(9532, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 3: //Cooking - player->SEND_POI(-3798.3, -11651.7, 6, 6, 0, "Exodar Cooking Trainer"); - player->SEND_GOSSIP_MENU(9551, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 4: //Enchanting - player->SEND_POI(-3889.3, -11495, 6, 6, 0, "Exodar Enchanting Trainer"); - player->SEND_GOSSIP_MENU(9535, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 5: //Engineering - player->SEND_POI(-4257.68, -11640.3, 6, 6, 0, "Exodar Engineering Trainer"); - player->SEND_GOSSIP_MENU(9536, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 6: //First Aid - player->SEND_POI(-3769.5, -11479.6, 6, 6, 0, "Exodar First Aid Trainer"); - player->SEND_GOSSIP_MENU(9537, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 7: //Fishing - player->SEND_POI(-3725.5, -11385.2, 6, 6, 0, "Exodar Fishing Trainer"); - player->SEND_GOSSIP_MENU(9538, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 8: //Jewelcrafting - player->SEND_POI(-3783, -11546, 6, 6, 0, "Exodar Jewelcrafting Trainer"); - player->SEND_GOSSIP_MENU(9547, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 9: //Herbalism - player->SEND_POI(-4040.6, -11364.5, 6, 6, 0, "Exodar Herbalist Trainer"); - player->SEND_GOSSIP_MENU(9543, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 10: //Leatherworking - player->SEND_POI(-4140.6, -11776.7, 6, 6, 0, "Exodar Leatherworking Trainer"); - player->SEND_GOSSIP_MENU(9549, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 11: //Mining - player->SEND_POI(-4228, -11697, 6, 6, 0, "Exodar Mining Trainer"); - player->SEND_GOSSIP_MENU(9552, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 12: //Skinning - player->SEND_POI(-4134.97, -11760.5, 6, 6, 0, "Exodar Skinning Trainer"); - player->SEND_GOSSIP_MENU(9557, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 13: //Tailoring - player->SEND_POI(-4092.5, -11744.5, 6, 6, 0, "Exodar Tailor Trainer"); - player->SEND_GOSSIP_MENU(9559, _Creature->GetGUID()); - break; - } -} - -bool GossipSelect_guard_exodar(Player *player, Creature *_Creature, uint32 sender, uint32 action ) -{ - switch (sender) - { - case GOSSIP_SENDER_MAIN: SendDefaultMenu_guard_exodar(player, _Creature, action); break; - case GOSSIP_SENDER_SEC_CLASSTRAIN: SendClassTrainerMenu_guard_exodar(player, _Creature, action); break; - case GOSSIP_SENDER_SEC_PROFTRAIN: SendProfTrainerMenu_guard_exodar(player, _Creature, action); break; - case GOSSIP_SENDER_SEC_BATTLEINFO: SendBattleMasterMenu_guard_exodar(player, _Creature, action); break; - } - return true; -} - -/******************************************************* - * guard_exodar end - *******************************************************/ - -CreatureAI* GetAI_guard_exodar(Creature *_Creature) -{ - return new guardAI (_Creature); -} - -/******************************************************* - * guard_ironforge start - *******************************************************/ - -bool GossipHello_guard_ironforge(Player *player, Creature *_Creature) -{ - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_AUCTIONHOUSE , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_IRONFORGE_BANK , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_DEEPRUNTRAM , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 3); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_GRYPHON , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 4); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_GUILDMASTER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 5); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_INN , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 6); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_MAILBOX , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 7); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_STABLEMASTER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 8); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_WEAPONMASTER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 9); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_BATTLEMASTER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 10); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_CLASSTRAINER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 11); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_PROFTRAINER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 12); - player->SEND_GOSSIP_MENU(2760, _Creature->GetGUID()); - return true; -} - -void SendDefaultMenu_guard_ironforge(Player *player, Creature *_Creature, uint32 action) -{ - switch (action) - { - case GOSSIP_ACTION_INFO_DEF + 1: //Auction House - player->SEND_POI(-4957.39, -911.6, 6, 6, 0, "Ironforge Auction House"); - player->SEND_GOSSIP_MENU(3014, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 2: //Bank - player->SEND_POI(-4891.91, -991.47, 6, 6, 0, "The Vault"); - player->SEND_GOSSIP_MENU(2761, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 3: //Tram - player->SEND_POI(-4835.27, -1294.69, 6, 6, 0, "Deeprun Tram"); - player->SEND_GOSSIP_MENU(3814, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 4: //Gryphon Master - player->SEND_POI(-4821.52, -1152.3, 6, 6, 0, "Ironforge Gryphon Master"); - player->SEND_GOSSIP_MENU(2762, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 5: //Guild Master - player->SEND_POI(-5021, -996.45, 6, 6, 0, "Ironforge Visitor's Center"); - player->SEND_GOSSIP_MENU(2764, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 6: //Inn - player->SEND_POI(-4850.47, -872.57, 6, 6, 0, "Stonefire Tavern"); - player->SEND_GOSSIP_MENU(2768, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 7: //Mailbox - player->SEND_POI(-4845.7, -880.55, 6, 6, 0, "Ironforge Mailbox"); - player->SEND_GOSSIP_MENU(2769, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 8: //Stable Master - player->SEND_POI(-5010.2, -1262, 6, 6, 0, "Ulbrek Firehand"); - player->SEND_GOSSIP_MENU(5986, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 9: //Weapons Trainer - player->SEND_POI(-5040, -1201.88, 6, 6, 0, "Bixi and Buliwyf"); - player->SEND_GOSSIP_MENU(4518, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 10: //Battlemaster - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ALTERACVALLEY , GOSSIP_SENDER_SEC_BATTLEINFO, GOSSIP_ACTION_INFO_DEF + 1); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ARATHIBASIN , GOSSIP_SENDER_SEC_BATTLEINFO, GOSSIP_ACTION_INFO_DEF + 2); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_WARSONGULCH , GOSSIP_SENDER_SEC_BATTLEINFO, GOSSIP_ACTION_INFO_DEF + 3); - player->SEND_GOSSIP_MENU(7529, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 11: //Class Trainer - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_HUNTER , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 1); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_MAGE , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 2); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_PALADIN , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 3); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_PRIEST , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 4); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ROGUE , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 5); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_WARLOCK , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 6); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_WARRIOR , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 7); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_SHAMAN , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 8); - player->SEND_GOSSIP_MENU(2766, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 12: //Profession Trainer - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ALCHEMY , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 1); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_BLACKSMITHING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 2); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_COOKING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 3); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ENCHANTING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 4); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ENGINEERING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 5); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_FIRSTAID , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 6); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_FISHING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 7); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_HERBALISM , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 8); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_LEATHERWORKING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 9); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_MINING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 10); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_SKINNING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 11); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_TAILORING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 12); - player->SEND_GOSSIP_MENU(2793, _Creature->GetGUID()); - break; - } -} - -void SendBattleMasterMenu_guard_ironforge(Player *player, Creature *_Creature, uint32 action) -{ - switch (action) - { - case GOSSIP_ACTION_INFO_DEF + 1: //AV - player->SEND_POI(-5047.87, -1263.77, 6, 6, 0, "Glordrum Steelbeard"); - player->SEND_GOSSIP_MENU(7483, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 2: //AB - player->SEND_POI(-5038.37, -1266.39, 6, 6, 0, "Donal Osgood"); - player->SEND_GOSSIP_MENU(7649, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 3: //WSG - player->SEND_POI(-5037.24, -1274.82, 6, 6, 0, "Lylandris"); - player->SEND_GOSSIP_MENU(7528, _Creature->GetGUID()); - break; - } -} - -void SendClassTrainerMenu_guard_ironforge(Player *player, Creature *_Creature, uint32 action) -{ - switch (action) - { - case GOSSIP_ACTION_INFO_DEF + 1: //Hunter - player->SEND_POI(-5023, -1253.68, 6, 6, 0, "Hall of Arms"); - player->SEND_GOSSIP_MENU(2770, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 2: //Mage - player->SEND_POI(-4627, -926.45, 6, 6, 0, "Hall of Mysteries"); - player->SEND_GOSSIP_MENU(2771, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 3: //Paladin - player->SEND_POI(-4627.02, -926.45, 6, 6, 0, "Hall of Mysteries"); - player->SEND_GOSSIP_MENU(2773, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 4: //Priest - player->SEND_POI(-4627, -926.45, 6, 6, 0, "Hall of Mysteries"); - player->SEND_GOSSIP_MENU(2772, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 5: //Rogue - player->SEND_POI(-4647.83, -1124, 6, 6, 0, "Ironforge Rogue Trainer"); - player->SEND_GOSSIP_MENU(2774, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 6: //Warlock - player->SEND_POI(-4605, -1110.45, 6, 6, 0, "Ironforge Warlock Trainer"); - player->SEND_GOSSIP_MENU(2775, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 7: //Warrior - player->SEND_POI(-5023.08, -1253.68, 6, 6, 0, "Hall of Arms"); - player->SEND_GOSSIP_MENU(2776, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 8: //Shaman - player->SEND_POI(-4732, -1147, 6, 6, 0, "Ironforge Shaman Trainer"); - //incorrect id - player->SEND_GOSSIP_MENU(2766, _Creature->GetGUID()); - break; - } -} - -void SendProfTrainerMenu_guard_ironforge(Player *player, Creature *_Creature, uint32 action) -{ - switch (action) - { - case GOSSIP_ACTION_INFO_DEF + 1: //Alchemy - player->SEND_POI(-4858.5, -1241.83, 6, 6, 0, "Berryfizz's Potions and Mixed Drinks"); - player->SEND_GOSSIP_MENU(2794, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 2: //Blacksmithing - player->SEND_POI(-4796.97, -1110.17, 6, 6, 0, "The Great Forge"); - player->SEND_GOSSIP_MENU(2795, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 3: //Cooking - player->SEND_POI(-4767.83, -1184.59, 6, 6, 0, "The Bronze Kettle"); - player->SEND_GOSSIP_MENU(2796, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 4: //Enchanting - player->SEND_POI(-4803.72, -1196.53, 6, 6, 0, "Thistlefuzz Arcanery"); - player->SEND_GOSSIP_MENU(2797, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 5: //Engineering - player->SEND_POI(-4799.56, -1250.23, 6, 6, 0, "Springspindle's Gadgets"); - player->SEND_GOSSIP_MENU(2798, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 6: //First Aid - player->SEND_POI(-4881.6, -1153.13, 6, 6, 0, "Ironforge Physician"); - player->SEND_GOSSIP_MENU(2799, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 7: //Fishing - player->SEND_POI(-4597.91, -1091.93, 6, 6, 0, "Traveling Fisherman"); - player->SEND_GOSSIP_MENU(2800, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 8: //Herbalism - player->SEND_POI(-4876.9, -1151.92, 6, 6, 0, "Ironforge Physician"); - player->SEND_GOSSIP_MENU(2801, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 9: //Leatherworking - player->SEND_POI(-4745, -1027.57, 6, 6, 0, "Finespindle's Leather Goods"); - player->SEND_GOSSIP_MENU(2802, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 10: //Minning - player->SEND_POI(-4705.06, -1116.43, 6, 6, 0, "Deepmountain Mining Guild"); - player->SEND_GOSSIP_MENU(2804, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 11: //Skinning - player->SEND_POI(-4745, -1027.57, 6, 6, 0, "Finespindle's Leather Goods"); - player->SEND_GOSSIP_MENU(2805, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 12: //Tailoring - player->SEND_POI(-4719.60, -1056.96, 6, 6, 0, "Stonebrow's Clothier"); - player->SEND_GOSSIP_MENU(2807, _Creature->GetGUID()); - break; - } -} - -bool GossipSelect_guard_ironforge(Player *player, Creature *_Creature, uint32 sender, uint32 action ) -{ - switch (sender) - { - case GOSSIP_SENDER_MAIN: SendDefaultMenu_guard_ironforge(player, _Creature, action); break; - case GOSSIP_SENDER_SEC_CLASSTRAIN: SendClassTrainerMenu_guard_ironforge(player, _Creature, action); break; - case GOSSIP_SENDER_SEC_PROFTRAIN: SendProfTrainerMenu_guard_ironforge(player, _Creature, action); break; - case GOSSIP_SENDER_SEC_BATTLEINFO: SendBattleMasterMenu_guard_ironforge(player, _Creature, action); break; - } - return true; -} - -/******************************************************* - * guard_ironforge end - *******************************************************/ - -CreatureAI* GetAI_guard_ironforge(Creature *_Creature) -{ - return new guardAI (_Creature); -} - -/******************************************************* - * guard_mulgore start - *******************************************************/ - -bool GossipHello_guard_mulgore(Player *player, Creature *_Creature) -{ - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_BANK , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_WINDRIDER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_INN , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 3); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_STABLEMASTER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 4); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_CLASSTRAINER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 5); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_PROFTRAINER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 6); - player->SEND_GOSSIP_MENU(3543,_Creature->GetGUID()); - return true; -} - -void SendDefaultMenu_guard_mulgore(Player *player, Creature *_Creature, uint32 action) -{ - switch (action) - { - case GOSSIP_ACTION_INFO_DEF + 1: //Bank - player->SEND_GOSSIP_MENU(4051,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 2: //Wind rider - player->SEND_GOSSIP_MENU(4052,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 3: //Inn - player->SEND_POI(-2361.38, -349.19, 6, 6, 0, "Bloodhoof Village Inn"); - player->SEND_GOSSIP_MENU(4053,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 4: //Stable master - player->SEND_POI(-2338.86, -357.56, 6, 6, 0, "Seikwa"); - player->SEND_GOSSIP_MENU(5976,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 5: //Class trainer - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_DRUID , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 1); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_HUNTER , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 2); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_SHAMAN , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 3); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_WARRIOR , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 4); - player->SEND_GOSSIP_MENU(4069,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 6: //Profession trainer - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ALCHEMY , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 1); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_BLACKSMITHING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 2); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_COOKING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 3); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ENCHANTING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 4); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_FIRSTAID , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 5); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_FISHING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 6); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_HERBALISM , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 7); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_LEATHERWORKING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 8); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_MINING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 9); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_SKINNING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 10); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_TAILORING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 11); - player->SEND_GOSSIP_MENU(4070,_Creature->GetGUID()); - break; - } -} - -void SendClassTrainerMenu_guard_mulgore(Player *player, Creature *_Creature, uint32 action) -{ - switch (action) - { - case GOSSIP_ACTION_INFO_DEF + 1: //Druid - player->SEND_POI(-2312.15, -443.69, 6, 6, 0, "Gennia Runetotem"); - player->SEND_GOSSIP_MENU(4054,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 2: //Hunter - player->SEND_POI(-2178.14, -406.14, 6, 6, 0, "Yaw Sharpmane"); - player->SEND_GOSSIP_MENU(4055,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 3: //Shaman - player->SEND_POI(-2301.5, -439.87, 6, 6, 0, "Narm Skychaser"); - player->SEND_GOSSIP_MENU(4056,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 4: //Warrior - player->SEND_POI(-2345.43, -494.11, 6, 6, 0, "Krang Stonehoof"); - player->SEND_GOSSIP_MENU(4057,_Creature->GetGUID()); - break; - } -} - -void SendProfTrainerMenu_guard_mulgore(Player *player, Creature *_Creature, uint32 action) -{ - switch (action) - { - case GOSSIP_ACTION_INFO_DEF + 1: //Alchemy - player->SEND_GOSSIP_MENU(4058,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 2: //Blacksmithing - player->SEND_GOSSIP_MENU(4059,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 3: //Cooking - player->SEND_POI(-2263.34, -287.91, 6, 6, 0, "Pyall Silentstride"); - player->SEND_GOSSIP_MENU(4060,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 4: //Enchanting - player->SEND_GOSSIP_MENU(4061,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 5: //First Aid - player->SEND_POI(-2353.52, -355.82, 6, 6, 0, "Vira Younghoof"); - player->SEND_GOSSIP_MENU(4062,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 6: //Fishing - player->SEND_POI(-2349.21, -241.37, 6, 6, 0, "Uthan Stillwater"); - player->SEND_GOSSIP_MENU(4063,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 7: //Herbalism - player->SEND_GOSSIP_MENU(4064,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 8: //Leatherworking - player->SEND_POI(-2257.12, -288.63, 6, 6, 0, "Chaw Stronghide"); - player->SEND_GOSSIP_MENU(4065,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 9: //Mining - player->SEND_GOSSIP_MENU(4066,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 10: //Skinning - player->SEND_POI(-2252.94, -291.32, 6, 6, 0, "Yonn Deepcut"); - player->SEND_GOSSIP_MENU(4067,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 11: //Tailoring - player->SEND_GOSSIP_MENU(4068,_Creature->GetGUID()); - break; - } -} - -bool GossipSelect_guard_mulgore(Player *player, Creature *_Creature, uint32 sender, uint32 action ) -{ - switch (sender) - { - case GOSSIP_SENDER_MAIN: SendDefaultMenu_guard_mulgore(player, _Creature, action); break; - case GOSSIP_SENDER_SEC_CLASSTRAIN: SendClassTrainerMenu_guard_mulgore(player, _Creature, action); break; - case GOSSIP_SENDER_SEC_PROFTRAIN: SendProfTrainerMenu_guard_mulgore(player, _Creature, action); break; - } - return true; -} - -/******************************************************* - * guard_mulgore end - *******************************************************/ - -CreatureAI* GetAI_guard_mulgore(Creature *_Creature) -{ - return new guardAI (_Creature); -} - -/******************************************************* - * guard_orgrimmar start - *******************************************************/ - -bool GossipHello_guard_orgrimmar(Player *player, Creature *_Creature) -{ - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_BANK , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_WINDRIDER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_GUILDMASTER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 3); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_INN , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 4); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_MAILBOX , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 5); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_AUCTIONHOUSE , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 6); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ZEPPLINMASTER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 7); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_WEAPONMASTER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 8); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_STABLEMASTER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 9); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_OFFICERS , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 10); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_BATTLEMASTER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 11); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_CLASSTRAINER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 12); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_PROFTRAINER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 13); - player->SEND_GOSSIP_MENU(2593,_Creature->GetGUID()); - - return true; -} - -void SendDefaultMenu_guard_orgrimmar(Player *player, Creature *_Creature, uint32 action) -{ - switch (action) - { - case GOSSIP_ACTION_INFO_DEF + 1: //Bank - player->SEND_POI(1631.51, -4375.33, 6, 6, 0, "Bank of Orgrimmar"); - player->SEND_GOSSIP_MENU(2554,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 2: //wind rider - player->SEND_POI(1676.6, -4332.72, 6, 6, 0, "The Sky Tower"); - player->SEND_GOSSIP_MENU(2555,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 3: //guild master - player->SEND_POI(1576.93, -4294.75, 6, 6, 0, "Horde Embassy"); - player->SEND_GOSSIP_MENU(2556,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 4: //Inn - player->SEND_POI(1644.51, -4447.27, 6, 6, 0, "Orgrimmar Inn"); - player->SEND_GOSSIP_MENU(2557,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 5: //mailbox - player->SEND_POI(1622.53, -4388.79, 6, 6, 0, "Orgrimmar Mailbox"); - player->SEND_GOSSIP_MENU(2558,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 6: //auction house - player->SEND_POI(1679.21, -4450.1, 6, 6, 0, "Orgrimmar Auction House"); - player->SEND_GOSSIP_MENU(3075,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 7: //zeppelin - player->SEND_POI(1337.36, -4632.7, 6, 6, 0, "Orgrimmar Zeppelin Tower"); - player->SEND_GOSSIP_MENU(3173,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 8: //weapon master - player->SEND_POI(2092.56, -4823.95, 6, 6, 0, "Sayoc & Hanashi"); - player->SEND_GOSSIP_MENU(4519,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 9: //stable master - player->SEND_POI(2133.12, -4663.93, 6, 6, 0, "Xon'cha"); - player->SEND_GOSSIP_MENU(5974,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 10: //officers lounge - player->SEND_POI(1633.56, -4249.37, 6, 6, 0, "Hall of Legends"); - player->SEND_GOSSIP_MENU(7046,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 11: //battlemaster - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ALTERACVALLEY , GOSSIP_SENDER_SEC_BATTLEINFO, GOSSIP_ACTION_INFO_DEF + 1); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ARATHIBASIN , GOSSIP_SENDER_SEC_BATTLEINFO, GOSSIP_ACTION_INFO_DEF + 2); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_WARSONGULCH , GOSSIP_SENDER_SEC_BATTLEINFO, GOSSIP_ACTION_INFO_DEF + 3); - player->SEND_GOSSIP_MENU(7521,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 12: //class trainer - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_HUNTER , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 1); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_MAGE , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 2); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_PRIEST , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 3); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_SHAMAN , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 4); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ROGUE , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 5); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_WARLOCK , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 6); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_WARRIOR , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 7); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_PALADIN , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 8); - player->SEND_GOSSIP_MENU(2599,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 13: //profession trainer - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ALCHEMY , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 1); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_BLACKSMITHING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 2); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_COOKING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 3); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ENCHANTING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 4); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ENGINEERING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 5); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_FIRSTAID , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 6); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_FISHING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 7); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_HERBALISM , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 8); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_LEATHERWORKING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 9); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_MINING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 10); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_SKINNING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 11); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_TAILORING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 12); - player->SEND_GOSSIP_MENU(2594,_Creature->GetGUID()); - break; - } -} - -void SendBattleMasterMenu_guard_orgrimmar(Player *player, Creature *_Creature, uint32 action) -{ - switch (action) - { - case GOSSIP_ACTION_INFO_DEF + 1: //AV - player->SEND_POI(1983.92, -4794.2, 6, 6, 0, "Hall of the Brave"); - player->SEND_GOSSIP_MENU(7484,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 2: //AB - player->SEND_POI(1983.92, -4794.2, 6, 6, 0, "Hall of the Brave"); - player->SEND_GOSSIP_MENU(7644,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 3: //WSG - player->SEND_POI(1983.92, -4794.2, 6, 6, 0, "Hall of the Brave"); - player->SEND_GOSSIP_MENU(7520,_Creature->GetGUID()); - break; - } -} - -void SendClassTrainerMenu_guard_orgrimmar(Player *player, Creature *_Creature, uint32 action) -{ - switch (action) - { - case GOSSIP_ACTION_INFO_DEF + 1: //Hunter - player->SEND_POI(2114.84, -4625.31, 6, 6, 0, "Orgrimmar Hunter's Hall"); - player->SEND_GOSSIP_MENU(2559,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 2: //Mage - player->SEND_POI(1451.26, -4223.33, 6, 6, 0, "Darkbriar Lodge"); - player->SEND_GOSSIP_MENU(2560,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 3: //Priest - player->SEND_POI(1442.21, -4183.24, 6, 6, 0, "Spirit Lodge"); - player->SEND_GOSSIP_MENU(2561,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 4: //Shaman - player->SEND_POI(1925.34, -4181.89, 6, 6, 0, "Thrall's Fortress"); - player->SEND_GOSSIP_MENU(2562,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 5: //Rogue - player->SEND_POI(1773.39, -4278.97, 6, 6, 0, "Shadowswift Brotherhood"); - player->SEND_GOSSIP_MENU(2563,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 6: //Warlock - player->SEND_POI(1849.57, -4359.68, 6, 6, 0, "Darkfire Enclave"); - player->SEND_GOSSIP_MENU(2564,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 7: //Warrior - player->SEND_POI(1983.92, -4794.2, 6, 6, 0, "Hall of the Brave"); - player->SEND_GOSSIP_MENU(2565,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 8: //Paladin - player->SEND_POI(1906.65, -4134.26, 6, 6, 0, "Valley of Wisdom"); - player->SEND_GOSSIP_MENU(10843,_Creature->GetGUID()); - break; - } -} - -void SendProfTrainerMenu_guard_orgrimmar(Player *player, Creature *_Creature, uint32 action) -{ - switch (action) - { - case GOSSIP_ACTION_INFO_DEF + 1: //Alchemy - player->SEND_POI(1955.17, -4475.79, 6, 6, 0, "Yelmak's Alchemy and Potions"); - player->SEND_GOSSIP_MENU(2497,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 2: //Blacksmithing - player->SEND_POI(2054.34, -4831.85, 6, 6, 0, "The Burning Anvil"); - player->SEND_GOSSIP_MENU(2499,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 3: //Cooking - player->SEND_POI(1780.96, -4481.31, 6, 6, 0, "Borstan's Firepit"); - player->SEND_GOSSIP_MENU(2500,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 4: //Enchanting - player->SEND_POI(1917.5, -4434.95, 6, 6, 0, "Godan's Runeworks"); - player->SEND_GOSSIP_MENU(2501,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 5: //Engineering - player->SEND_POI(2038.45, -4744.75, 6, 6, 0, "Nogg's Machine Shop"); - player->SEND_GOSSIP_MENU(2653,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 6: //First Aid - player->SEND_POI(1485.21, -4160.91, 6, 6, 0, "Survival of the Fittest"); - player->SEND_GOSSIP_MENU(2502,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 7: //Fishing - player->SEND_POI(1994.15, -4655.7, 6, 6, 0, "Lumak's Fishing"); - player->SEND_GOSSIP_MENU(2503,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 8: //Herbalism - player->SEND_POI(1898.61, -4454.93, 6, 6, 0, "Jandi's Arboretum"); - player->SEND_GOSSIP_MENU(2504,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 9: //Leatherworking - player->SEND_POI(1852.82, -4562.31, 6, 6, 0, "Kodohide Leatherworkers"); - player->SEND_GOSSIP_MENU(2513,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 10: //Mining - player->SEND_POI(2029.79, -4704, 6, 6, 0, "Red Canyon Mining"); - player->SEND_GOSSIP_MENU(2515,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 11: //Skinning - player->SEND_POI(1852.82, -4562.31, 6, 6, 0, "Kodohide Leatherworkers"); - player->SEND_GOSSIP_MENU(2516,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 12: //Tailoring - player->SEND_POI(1802.66, -4560.66, 6, 6, 0, "Magar's Cloth Goods"); - player->SEND_GOSSIP_MENU(2518,_Creature->GetGUID()); - break; - } -} - -bool GossipSelect_guard_orgrimmar(Player *player, Creature *_Creature, uint32 sender, uint32 action ) -{ - switch (sender) - { - case GOSSIP_SENDER_MAIN: SendDefaultMenu_guard_orgrimmar(player, _Creature, action); break; - case GOSSIP_SENDER_SEC_CLASSTRAIN: SendClassTrainerMenu_guard_orgrimmar(player, _Creature, action); break; - case GOSSIP_SENDER_SEC_PROFTRAIN: SendProfTrainerMenu_guard_orgrimmar(player, _Creature, action); break; - case GOSSIP_SENDER_SEC_BATTLEINFO: SendBattleMasterMenu_guard_orgrimmar(player, _Creature, action); break; - } - return true; -} - -bool ReceiveEmote_guard_orgrimmar(Player *player, Creature *_Creature, uint32 emote) -{ - if( player->GetTeam() == HORDE ) - DoReplyToTextEmote(_Creature,emote); - return true; -} - -/******************************************************* - * guard_orgrimmar end - *******************************************************/ - -CreatureAI* GetAI_guard_orgrimmar(Creature *_Creature) -{ - return new guardAI (_Creature); -} - -/******************************************************* - * guard_shattrath start - *******************************************************/ - -bool GossipHello_guard_shattrath(Player *player, Creature *_Creature) -{ - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_TAVERN , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_BANK , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_INN , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 3); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_FLIGHTMASTER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 4); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_MAILBOX , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 5); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_STABLEMASTER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 6); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_BATTLEMASTER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 7); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_PROFTRAINER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 8); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_MANALOOM , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 9); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ALCHEMYLAB , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 10); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_GEMMERCHANT , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 11); - player->SEND_GOSSIP_MENU(10321, _Creature->GetGUID()); - - return true; -} - -void SendDefaultMenu_guard_shattrath(Player *player, Creature *_Creature, uint32 action) -{ - switch (action) - { - case GOSSIP_ACTION_INFO_DEF + 1: //Tavern - player->SEND_POI(-1759.5, 5165, 6, 6, 0, "Worlds End Tavern"); - player->SEND_GOSSIP_MENU(10394, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 2: //Bank - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_BANKALDOR , GOSSIP_SENDER_SEC_BANK, GOSSIP_ACTION_INFO_DEF + 1); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_BANKSCYERS , GOSSIP_SENDER_SEC_BANK, GOSSIP_ACTION_INFO_DEF + 2); - player->SEND_GOSSIP_MENU(10379, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 3: //Inn - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_INNALDOR , GOSSIP_SENDER_SEC_INN, GOSSIP_ACTION_INFO_DEF + 1); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_INNSCYERS , GOSSIP_SENDER_SEC_INN, GOSSIP_ACTION_INFO_DEF + 2); - player->SEND_GOSSIP_MENU(10382, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 4: //Flight master - player->SEND_POI(-1832, 5299, 6, 6, 0, "Flight Master"); - player->SEND_GOSSIP_MENU(10385, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 5: //Mailbox - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_BANKALDOR , GOSSIP_SENDER_SEC_MAILBOX, GOSSIP_ACTION_INFO_DEF + 1); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_INNALDOR , GOSSIP_SENDER_SEC_MAILBOX, GOSSIP_ACTION_INFO_DEF + 2); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_BANKSCYERS , GOSSIP_SENDER_SEC_MAILBOX, GOSSIP_ACTION_INFO_DEF + 3); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_INNSCYERS , GOSSIP_SENDER_SEC_MAILBOX, GOSSIP_ACTION_INFO_DEF + 4); - player->SEND_GOSSIP_MENU(10386, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 6: //Stable master - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_STABLEALDOR , GOSSIP_SENDER_SEC_STABLEMASTER, GOSSIP_ACTION_INFO_DEF + 1); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_STABLESCYERS , GOSSIP_SENDER_SEC_STABLEMASTER, GOSSIP_ACTION_INFO_DEF + 2); - player->SEND_GOSSIP_MENU(10387, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 7: //Battlemaster - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_BATTLEMASTERALLIANCE , GOSSIP_SENDER_SEC_BATTLEINFO, GOSSIP_ACTION_INFO_DEF + 1); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_BATTLEMASTERHORDE , GOSSIP_SENDER_SEC_BATTLEINFO, GOSSIP_ACTION_INFO_DEF + 2); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_BATTLEMASTERARENA , GOSSIP_SENDER_SEC_BATTLEINFO, GOSSIP_ACTION_INFO_DEF + 3); - player->SEND_GOSSIP_MENU(10388, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 8: //Profession master - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ALCHEMY , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 1); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_BLACKSMITHING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 2); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_COOKING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 3); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ENCHANTING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 4); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_FIRSTAID , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 5); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_JEWELCRAFTING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 6); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_LEATHERWORKING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 7); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_SKINNING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 8); - player->SEND_GOSSIP_MENU(10391, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 9: //Mana Loom - player->SEND_POI(-2070, 5265.5, 6, 6, 0, "Mana Loom"); - player->SEND_GOSSIP_MENU(10503, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 10: //Alchemy Lab - player->SEND_POI(-1648.5, 5540, 6, 6, 0, "Alchemy Lab"); - player->SEND_GOSSIP_MENU(10321, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 11: //Gem Merchant - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_GEMALDOR , GOSSIP_SENDER_SEC_GEMMERCHANT, GOSSIP_ACTION_INFO_DEF + 1); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_GEMSCYERS , GOSSIP_SENDER_SEC_GEMMERCHANT, GOSSIP_ACTION_INFO_DEF + 2); - player->SEND_GOSSIP_MENU(10697, _Creature->GetGUID()); - break; - } -} - -void SendBankMenu_guard_shattrath(Player *player, Creature *_Creature, uint32 action) -{ - if (action == GOSSIP_ACTION_INFO_DEF + 1) - { - player->SEND_POI(-1730.5, 5496, 6, 6, 0, "Aldor Bank"); - player->SEND_GOSSIP_MENU(10380, _Creature->GetGUID()); - } - if (action == GOSSIP_ACTION_INFO_DEF + 2) - { - player->SEND_POI(-1997.7, 5363, 6, 6, 0, "Scyers Bank"); - player->SEND_GOSSIP_MENU(10381, _Creature->GetGUID()); - } -} - -void SendInnMenu_guard_shattrath(Player *player, Creature *_Creature, uint32 action) -{ - if (action == GOSSIP_ACTION_INFO_DEF + 1) - { - player->SEND_POI(-1895, 5767, 6, 6, 0, "Aldor Inn"); - player->SEND_GOSSIP_MENU(10383, _Creature->GetGUID()); - } - if (action == GOSSIP_ACTION_INFO_DEF + 2) - { - player->SEND_POI(-2178, 5405, 6, 6, 0, "Scyers Inn"); - player->SEND_GOSSIP_MENU(10384, _Creature->GetGUID()); - } -} - -void SendMailboxMenu_guard_shattrath(Player *player, Creature *_Creature, uint32 action) -{ - switch (action) - { - case GOSSIP_ACTION_INFO_DEF + 1: - player->SEND_POI(-1730.5, 5496, 6, 6, 0, "Aldor Bank"); - player->SEND_GOSSIP_MENU(10380, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 2: - player->SEND_POI(-1895, 5767, 6, 6, 0, "Aldor Inn"); - player->SEND_GOSSIP_MENU(10383, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 3: - player->SEND_POI(-1997.7, 5363, 6, 6, 0, "Scyers Bank"); - player->SEND_GOSSIP_MENU(10381, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 4: - player->SEND_POI(-2178, 5405, 6, 6, 0, "Scyers Inn"); - player->SEND_GOSSIP_MENU(10384, _Creature->GetGUID()); - break; - } -} - -void SendStableMasterMenu_guard_shattrath(Player *player, Creature *_Creature, uint32 action) -{ - if (action == GOSSIP_ACTION_INFO_DEF + 1) - { - player->SEND_POI(-1888.5, 5761, 6, 6, 0, "Aldor Stable"); - player->SEND_GOSSIP_MENU(10321, _Creature->GetGUID()); - } - if (action == GOSSIP_ACTION_INFO_DEF + 2) - { - player->SEND_POI(-2170, 5404, 6, 6, 0, "Scyers Stable"); - player->SEND_GOSSIP_MENU(10321, _Creature->GetGUID()); - } -} - -void SendBattleMasterMenu_guard_shattrath(Player *player, Creature *_Creature, uint32 action) -{ - switch (action) - { - case GOSSIP_ACTION_INFO_DEF + 1: - player->SEND_POI(-1774, 5251, 6, 6, 0, "Alliance Battlemasters"); - player->SEND_GOSSIP_MENU(10389, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 2: - player->SEND_POI(-1963, 5263, 6, 6, 0, "Horde Battlemasters"); - player->SEND_GOSSIP_MENU(10390, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 3: - player->SEND_POI(-1960, 5175, 6, 6, 0, "Arena Battlemasters"); - player->SEND_GOSSIP_MENU(12510, _Creature->GetGUID()); - break; - } -} - -void SendProfTrainerMenu_guard_shattrath(Player *player, Creature *_Creature, uint32 action) -{ - switch (action) - { - case GOSSIP_ACTION_INFO_DEF + 1: //Alchemy - player->SEND_POI(-1648.5, 5534, 6, 6, 0, "Lorokeem"); - player->SEND_GOSSIP_MENU(10392, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 2: //Blacksmithing - player->SEND_POI(-1847, 5222, 6, 6, 0, "Kradu Grimblade and Zula Slagfury"); - player->SEND_GOSSIP_MENU(10400, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 3: //Cooking - player->SEND_POI(-2067.4, 5316.5, 6, 6, 0, "Jack Trapper"); - player->SEND_GOSSIP_MENU(10393, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 4: //Enchanting - player->SEND_POI(-2263.5, 5563.5, 6, 6, 0, "High Enchanter Bardolan"); - player->SEND_GOSSIP_MENU(10395, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 5: //First Aid - player->SEND_POI(-1591, 5265.5, 6, 6, 0, "Mildred Fletcher"); - player->SEND_GOSSIP_MENU(10396, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 6: //Jewelcrafting - player->SEND_POI(-1654, 5667.5, 6, 6, 0, "Hamanar"); - player->SEND_GOSSIP_MENU(10397, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 7: //Leatherworking - player->SEND_POI(-2060.5, 5256.5, 6, 6, 0, "Darmari"); - player->SEND_GOSSIP_MENU(10399, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 8: //Skinning - player->SEND_POI(-2048, 5300, 6, 6, 0, "Seymour"); - player->SEND_GOSSIP_MENU(10398, _Creature->GetGUID()); - break; - } -} - -void SendGemMerchantMenu_guard_shattrath(Player *player, Creature *_Creature, uint32 action) -{ - if (action == GOSSIP_ACTION_INFO_DEF + 1) - { - player->SEND_POI(-1645, 5669.5, 6, 6, 0, "Aldor Gem Merchant"); - player->SEND_GOSSIP_MENU(10698, _Creature->GetGUID()); - } - if (action == GOSSIP_ACTION_INFO_DEF + 2) - { - player->SEND_POI(-2193, 5424.5, 6, 6, 0, "Scyers Gem Merchant"); - player->SEND_GOSSIP_MENU(10699, _Creature->GetGUID()); - } -} - -bool GossipSelect_guard_shattrath(Player *player, Creature *_Creature, uint32 sender, uint32 action ) -{ - switch (sender) - { - case GOSSIP_SENDER_MAIN: SendDefaultMenu_guard_shattrath(player, _Creature, action); break; - case GOSSIP_SENDER_SEC_BANK: SendBankMenu_guard_shattrath(player, _Creature, action); break; - case GOSSIP_SENDER_SEC_INN: SendInnMenu_guard_shattrath(player, _Creature, action); break; - case GOSSIP_SENDER_SEC_STABLEMASTER: SendStableMasterMenu_guard_shattrath(player, _Creature, action); break; - case GOSSIP_SENDER_SEC_GEMMERCHANT: SendGemMerchantMenu_guard_shattrath(player, _Creature, action); break; - case GOSSIP_SENDER_SEC_MAILBOX: SendMailboxMenu_guard_shattrath(player, _Creature, action); break; - case GOSSIP_SENDER_SEC_PROFTRAIN: SendProfTrainerMenu_guard_shattrath(player, _Creature, action); break; - case GOSSIP_SENDER_SEC_BATTLEINFO: SendBattleMasterMenu_guard_shattrath(player, _Creature, action); break; - } - return true; -} - -/******************************************************* - * guard_shattrath end - *******************************************************/ - -CreatureAI* GetAI_guard_shattrath(Creature *_Creature) -{ - return new guardAI (_Creature); -} - -/******************************************************* - * guard_shattrath_aldor - *******************************************************/ - -#define SPELL_BANISHED_SHATTRATH_A 36642 -#define SPELL_BANISHED_SHATTRATH_S 36671 -#define SPELL_BANISH_TELEPORT 36643 -#define SPELL_EXILE 39533 - -struct MANGOS_DLL_DECL guard_shattrath_aldorAI : public guardAI -{ - guard_shattrath_aldorAI(Creature *c) : guardAI(c) { Reset(); } - - uint32 Exile_Timer; - uint32 Banish_Timer; - uint64 playerGUID; - bool CanTeleport; - - void Reset() - { - Banish_Timer = 5000; - Exile_Timer = 8500; - playerGUID = 0; - CanTeleport = false; - } - - void Aggro(Unit *who) {} - - void UpdateAI(const uint32 diff) - { - if(!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - if( CanTeleport ) - { - if( Exile_Timer < diff ) - { - if( Unit* temp = Unit::GetUnit(*m_creature,playerGUID) ) - { - temp->CastSpell(temp,SPELL_EXILE,true); - temp->CastSpell(temp,SPELL_BANISH_TELEPORT,true); - } - playerGUID = 0; - Exile_Timer = 8500; - CanTeleport = false; - }else Exile_Timer -= diff; - } - else if( Banish_Timer < diff ) - { - Unit* temp = m_creature->getVictim(); - if( temp && temp->GetTypeId() == TYPEID_PLAYER ) - { - DoCast(temp,SPELL_BANISHED_SHATTRATH_A); - Banish_Timer = 9000; - playerGUID = temp->GetGUID(); - if( playerGUID ) - CanTeleport = true; - } - }else Banish_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; - -bool GossipHello_guard_shattrath_aldor(Player *player, Creature *_Creature) -{ - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_TAVERN , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_BANK , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_INN , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 3); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_FLIGHTMASTER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 4); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_MAILBOX , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 5); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_STABLEMASTER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 6); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_BATTLEMASTER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 7); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_PROFTRAINER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 8); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_MANALOOM , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 9); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ALCHEMYLAB , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 10); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_GEMMERCHANT , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 11); - player->SEND_GOSSIP_MENU(10524, _Creature->GetGUID()); - return true; -} - -void SendDefaultMenu_guard_shattrath_aldor(Player *player, Creature *_Creature, uint32 action) -{ - switch (action) - { - case GOSSIP_ACTION_INFO_DEF + 1: //Tavern - player->SEND_POI(-1759.5, 5165, 6, 6, 0, "Worlds End Tavern"); - player->SEND_GOSSIP_MENU(10394, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 2: //Bank - player->SEND_POI(-1730.5, 5496, 6, 6, 0, "Aldor Bank"); - player->SEND_GOSSIP_MENU(10380, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 3: //Inn - player->SEND_POI(-1895, 5767, 6, 6, 0, "Aldor Inn"); - player->SEND_GOSSIP_MENU(10525, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 4: //Flight master - player->SEND_POI(-1832, 5299, 6, 6, 0, "Shattrath Flight Master"); - player->SEND_GOSSIP_MENU(10402, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 5: //Mailbox - player->SEND_POI(0, 0, 6, 6, 0, "Aldor Mailbox"); - //unknown - player->SEND_GOSSIP_MENU(10524, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 6: //Stable master - player->SEND_POI(-1888.5, 5761, 6, 6, 0, "Aldor Stable Master"); - player->SEND_GOSSIP_MENU(10527, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 7: //Battlemaster - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_BATTLEMASTERALLIANCE , GOSSIP_SENDER_SEC_BATTLEINFO, GOSSIP_ACTION_INFO_DEF + 1); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_BATTLEMASTERHORDE , GOSSIP_SENDER_SEC_BATTLEINFO, GOSSIP_ACTION_INFO_DEF + 2); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_BATTLEMASTERARENA , GOSSIP_SENDER_SEC_BATTLEINFO, GOSSIP_ACTION_INFO_DEF + 3); - player->SEND_GOSSIP_MENU(10388, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 8: //Profession master - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ALCHEMY , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 1); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_BLACKSMITHING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 2); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_COOKING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 3); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ENCHANTING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 4); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_FIRSTAID , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 5); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_JEWELCRAFTING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 6); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_LEATHERWORKING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 7); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_SKINNING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 8); - player->SEND_GOSSIP_MENU(10391, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 9: //Mana Loom - player->SEND_POI(-2070, 5265.5, 6, 6, 0, "Mana Loom"); - player->SEND_GOSSIP_MENU(10522, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 10: //Alchemy Lab - player->SEND_POI(-1648.5, 5540, 6, 6, 0, "Alchemy Lab"); - player->SEND_GOSSIP_MENU(10696, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 11: //Gem Merchant - player->SEND_POI(-1645, 5669.5, 6, 6, 0, "Aldor Gem Merchant"); - player->SEND_GOSSIP_MENU(10411, _Creature->GetGUID()); - break; - } -} - -void SendProfTrainerMenu_guard_shattrath_aldor(Player *player, Creature *_Creature, uint32 action) -{ - switch (action) - { - case GOSSIP_ACTION_INFO_DEF + 1: //Alchemy - player->SEND_POI(-1648.5, 5534, 6, 6, 0, "Lorokeem"); - player->SEND_GOSSIP_MENU(10392, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 2: //Blacksmithing - player->SEND_POI(-1847, 5222, 6, 6, 0, "Kradu Grimblade and Zula Slagfury"); - player->SEND_GOSSIP_MENU(10400, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 3: //Cooking - player->SEND_POI(-2067.4, 5316.5, 6, 6, 0, "Jack Trapper"); - player->SEND_GOSSIP_MENU(10393, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 4: //Enchanting - player->SEND_POI(-2263.5, 5563.5, 6, 6, 0, "High Enchanter Bardolan"); - player->SEND_GOSSIP_MENU(10528, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 5: //First Aid - player->SEND_POI(-1591, 5265.5, 6, 6, 0, "Mildred Fletcher"); - player->SEND_GOSSIP_MENU(10396, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 6: //Jewelcrafting - player->SEND_POI(-1654, 5667.5, 6, 6, 0, "Hamanar"); - player->SEND_GOSSIP_MENU(10529, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 7: //Leatherworking - player->SEND_POI(-2060.5, 5256.5, 6, 6, 0, "Darmari"); - player->SEND_GOSSIP_MENU(10399, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 8: //Skinning - player->SEND_POI(-2048, 5300, 6, 6, 0, "Seymour"); - player->SEND_GOSSIP_MENU(10419, _Creature->GetGUID()); - break; - } -} - -bool GossipSelect_guard_shattrath_aldor(Player *player, Creature *_Creature, uint32 sender, uint32 action ) -{ - switch (sender) - { - case GOSSIP_SENDER_MAIN: SendDefaultMenu_guard_shattrath_aldor(player, _Creature, action); break; - case GOSSIP_SENDER_SEC_PROFTRAIN: SendProfTrainerMenu_guard_shattrath_aldor(player, _Creature, action); break; - case GOSSIP_SENDER_SEC_BATTLEINFO: SendBattleMasterMenu_guard_shattrath(player, _Creature, action); break; - } - return true; -} - -/******************************************************* - * guard_shattrath_aldor end - *******************************************************/ - -CreatureAI* GetAI_guard_shattrath_aldor(Creature *_Creature) -{ - return new guard_shattrath_aldorAI (_Creature); -} - -/******************************************************* - * guard_shattrath_scryer - *******************************************************/ - -struct MANGOS_DLL_DECL guard_shattrath_scryerAI : public guardAI -{ - guard_shattrath_scryerAI(Creature *c) : guardAI(c) { Reset(); } - - uint32 Exile_Timer; - uint32 Banish_Timer; - uint64 playerGUID; - bool CanTeleport; - - void Reset() - { - Banish_Timer = 5000; - Exile_Timer = 8500; - playerGUID = 0; - CanTeleport = false; - } - - void Aggro(Unit *who) {} - - void UpdateAI(const uint32 diff) - { - if(!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - if( CanTeleport ) - { - if( Exile_Timer < diff ) - { - if( Unit* temp = Unit::GetUnit(*m_creature,playerGUID) ) - { - temp->CastSpell(temp,SPELL_EXILE,true); - temp->CastSpell(temp,SPELL_BANISH_TELEPORT,true); - } - playerGUID = 0; - Exile_Timer = 8500; - CanTeleport = false; - }else Exile_Timer -= diff; - } - else if( Banish_Timer < diff ) - { - Unit* temp = m_creature->getVictim(); - if( temp && temp->GetTypeId() == TYPEID_PLAYER ) - { - DoCast(temp,SPELL_BANISHED_SHATTRATH_S); - Banish_Timer = 9000; - playerGUID = temp->GetGUID(); - if( playerGUID ) - CanTeleport = true; - } - }else Banish_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; - -bool GossipHello_guard_shattrath_scryer(Player *player, Creature *_Creature) -{ - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_TAVERN , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_BANK , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_INN , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 3); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_FLIGHTMASTER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 4); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_MAILBOX , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 5); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_STABLEMASTER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 6); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_BATTLEMASTER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 7); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_PROFTRAINER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 8); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_MANALOOM , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 9); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ALCHEMYLAB , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 10); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_GEMMERCHANT , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 11); - player->SEND_GOSSIP_MENU(10430, _Creature->GetGUID()); - return true; -} - -void SendDefaultMenu_guard_shattrath_scryer(Player *player, Creature *_Creature, uint32 action) -{ - switch (action) - { - case GOSSIP_ACTION_INFO_DEF + 1: //Tavern - player->SEND_POI(-1759.5, 5165, 6, 6, 0, "Worlds End Tavern"); - player->SEND_GOSSIP_MENU(10431, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 2: //Bank - player->SEND_POI(-1996.6, 5363.7, 6, 6, 0, "Scryer Bank"); - player->SEND_GOSSIP_MENU(10432, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 3: //Inn - player->SEND_POI(-2176.6, 5405.8, 6, 6, 0, "Scryer Inn"); - player->SEND_GOSSIP_MENU(10433, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 4: //Flight master - player->SEND_POI(-1832, 5299, 6, 6, 0, "Shattrath Flight Master"); - player->SEND_GOSSIP_MENU(10435, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 5: //Mailbox - player->SEND_POI(-2174.3, 5411.4, 6, 6, 0, "Scryer Mailbox"); - player->SEND_GOSSIP_MENU(10436, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 6: //Stable master - player->SEND_POI(-2169.9, 5405.1, 6, 6, 0, "Scryer Stable Master"); - player->SEND_GOSSIP_MENU(10437, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 7: //Battlemaster - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_BATTLEMASTERALLIANCE , GOSSIP_SENDER_SEC_BATTLEINFO, GOSSIP_ACTION_INFO_DEF + 1); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_BATTLEMASTERHORDE , GOSSIP_SENDER_SEC_BATTLEINFO, GOSSIP_ACTION_INFO_DEF + 2); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_BATTLEMASTERARENA , GOSSIP_SENDER_SEC_BATTLEINFO, GOSSIP_ACTION_INFO_DEF + 3); - player->SEND_GOSSIP_MENU(10438, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 8: //Profession master - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ALCHEMY , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 1); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_BLACKSMITHING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 2); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_COOKING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 3); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ENCHANTING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 4); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_FIRSTAID , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 5); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_JEWELCRAFTING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 6); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_LEATHERWORKING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 7); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_SKINNING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 8); - player->SEND_GOSSIP_MENU(10504, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 9: //Mana Loom - player->SEND_POI(-2070, 5265.5, 6, 6, 0, "Mana Loom"); - player->SEND_GOSSIP_MENU(10522, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 10: //Alchemy Lab - player->SEND_POI(-1648.5, 5540, 6, 6, 0, "Alchemy Lab"); - player->SEND_GOSSIP_MENU(10701, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 11: //Gem Merchant - player->SEND_POI(-1645, 5669.5, 6, 6, 0, "Scryer Gem Merchant"); - player->SEND_GOSSIP_MENU(10702, _Creature->GetGUID()); - break; - } -} - -void SendProfTrainerMenu_guard_shattrath_scryer(Player *player, Creature *_Creature, uint32 action) -{ - switch (action) - { - case GOSSIP_ACTION_INFO_DEF + 1: //Alchemy - player->SEND_POI(-1648.5, 5534, 6, 6, 0, "Lorokeem"); - player->SEND_GOSSIP_MENU(10516, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 2: //Blacksmithing - player->SEND_POI(-1847, 5222, 6, 6, 0, "Kradu Grimblade and Zula Slagfury"); - player->SEND_GOSSIP_MENU(10517, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 3: //Cooking - player->SEND_POI(-2067.4, 5316.5, 6, 6, 0, "Jack Trapper"); - player->SEND_GOSSIP_MENU(10518, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 4: //Enchanting - player->SEND_POI(-2263.5, 5563.5, 6, 6, 0, "High Enchanter Bardolan"); - player->SEND_GOSSIP_MENU(10519, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 5: //First Aid - player->SEND_POI(-1591, 5265.5, 6, 6, 0, "Mildred Fletcher"); - player->SEND_GOSSIP_MENU(10520, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 6: //Jewelcrafting - player->SEND_POI(-1654, 5667.5, 6, 6, 0, "Hamanar"); - player->SEND_GOSSIP_MENU(10521, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 7: //Leatherworking - player->SEND_POI(-2060.5, 5256.5, 6, 6, 0, "Darmari"); - player->SEND_GOSSIP_MENU(10523, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 8: //Skinning - player->SEND_POI(-2048, 5300, 6, 6, 0, "Seymour"); - player->SEND_GOSSIP_MENU(10523, _Creature->GetGUID()); - break; - } -} - -bool GossipSelect_guard_shattrath_scryer(Player *player, Creature *_Creature, uint32 sender, uint32 action ) -{ - switch (sender) - { - case GOSSIP_SENDER_MAIN: SendDefaultMenu_guard_shattrath_scryer(player, _Creature, action); break; - case GOSSIP_SENDER_SEC_PROFTRAIN: SendProfTrainerMenu_guard_shattrath_scryer(player, _Creature, action); break; - case GOSSIP_SENDER_SEC_BATTLEINFO: SendBattleMasterMenu_guard_shattrath(player, _Creature, action); break; - } - return true; -} - -/******************************************************* - * guard_shattrath_scryer end - *******************************************************/ - -CreatureAI* GetAI_guard_shattrath_scryer(Creature *_Creature) -{ - return new guard_shattrath_scryerAI (_Creature); -} - -/******************************************************* - * guard_silvermoon start - *******************************************************/ - -bool GossipHello_guard_silvermoon(Player *player, Creature *_Creature) -{ - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_AUCTIONHOUSE , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_BANK , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_GUILDMASTER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 3); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_INN , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 4); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_MAILBOX , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 5); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_STABLEMASTER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 6); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_WEAPONMASTER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 7); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_WINDRIDER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 8); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_BATTLEMASTER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 9); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_CLASSTRAINER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 10); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_PROFTRAINER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 11); - player->SEND_GOSSIP_MENU(9316, _Creature->GetGUID()); - return true; -} - -void SendDefaultMenu_guard_silvermoon(Player *player, Creature *_Creature, uint32 action) -{ - switch (action) - { - case GOSSIP_ACTION_INFO_DEF + 1: //Auction house - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_AH_SILVERMOON_1 , GOSSIP_SENDER_SEC_AUCTIONHOUSE, GOSSIP_ACTION_INFO_DEF + 1); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_AH_SILVERMOON_2 , GOSSIP_SENDER_SEC_AUCTIONHOUSE, GOSSIP_ACTION_INFO_DEF + 2); - player->SEND_GOSSIP_MENU(9317, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 2: //Bank - player->SEND_POI(9808.4, -7488.16, 6, 6, 0, "Silvermoon Bank"); - player->SEND_GOSSIP_MENU(9322, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 3: //Guild master - player->SEND_POI(9474.97, -7345.21, 6, 6, 0, "Tandrine"); - player->SEND_GOSSIP_MENU(9324, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 4: //Inn - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_INN_SILVERMOON_1 , GOSSIP_SENDER_SEC_INN, GOSSIP_ACTION_INFO_DEF + 1); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_INN_SILVERMOON_2 , GOSSIP_SENDER_SEC_INN, GOSSIP_ACTION_INFO_DEF + 2); - player->SEND_GOSSIP_MENU(9602, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 5: //Mailbox - player->SEND_POI(9658.33, -7492.17, 6, 6, 0, "Silvermoon Mailbox"); - player->SEND_GOSSIP_MENU(9326, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 6: //Stable master - player->SEND_POI(9904.95, -7404.31, 6, 6, 0, "Shalenn"); - player->SEND_GOSSIP_MENU(9327, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 7: //Weapon trainer - player->SEND_POI(9841.17, -7505.13, 6, 6, 0, "Ileda"); - player->SEND_GOSSIP_MENU(9328, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 8: //Wind master - player->SEND_POI(9378.45, -7163.94, 6, 6, 0, "Silvermoon Wind Master"); - player->SEND_GOSSIP_MENU(10181, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 9: //Battlemaster - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ALTERACVALLEY , GOSSIP_SENDER_SEC_BATTLEINFO, GOSSIP_ACTION_INFO_DEF + 1); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ARATHIBASIN , GOSSIP_SENDER_SEC_BATTLEINFO, GOSSIP_ACTION_INFO_DEF + 2); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ARENA , GOSSIP_SENDER_SEC_BATTLEINFO, GOSSIP_ACTION_INFO_DEF + 3); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_EYEOFTHESTORM , GOSSIP_SENDER_SEC_BATTLEINFO, GOSSIP_ACTION_INFO_DEF + 4); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_WARSONGULCH , GOSSIP_SENDER_SEC_BATTLEINFO, GOSSIP_ACTION_INFO_DEF + 5); - player->SEND_GOSSIP_MENU(9329, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 10: //Class trainer - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_DRUID , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 1); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_HUNTER , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 2); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_MAGE , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 3); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_PALADIN , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 4); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_PRIEST , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 5); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ROGUE , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 6); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_WARLOCK , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 7); - player->SEND_GOSSIP_MENU(9331, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 11: //Profession trainer - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ALCHEMY , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 1); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_BLACKSMITHING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 2); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_COOKING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 3); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ENCHANTING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 4); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ENGINEERING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 5); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_FIRSTAID , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 6); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_FISHING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 7); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_JEWELCRAFTING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 8); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_HERBALISM , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 9); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_LEATHERWORKING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 10); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_MINING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 11); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_SKINNING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 12); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_TAILORING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 13); - player->SEND_GOSSIP_MENU(9338, _Creature->GetGUID()); - break; - } -} - -void SendAuctionhouseMenu_guard_silvermoon(Player *player, Creature *_Creature, uint32 action) -{ - if (action == GOSSIP_ACTION_INFO_DEF + 1) - { - player->SEND_POI(9644.47, -7140.22, 6, 6, 0, "Western Auction House"); - player->SEND_GOSSIP_MENU(9318, _Creature->GetGUID()); - } - if (action == GOSSIP_ACTION_INFO_DEF + 2) - { - player->SEND_POI(9683.27, -7521.22, 6, 6, 0, "Royal Exchange Auction House"); - player->SEND_GOSSIP_MENU(9319, _Creature->GetGUID()); - } -} - -void SendInnMenu_guard_silvermoon(Player *player, Creature *_Creature, uint32 action) -{ - if (action == GOSSIP_ACTION_INFO_DEF + 1) - { - player->SEND_POI(9677.7, -7368, 6, 6, 0, "Silvermoon City Inn"); - player->SEND_GOSSIP_MENU(9325, _Creature->GetGUID()); - } - if (action == GOSSIP_ACTION_INFO_DEF + 2) - { - player->SEND_POI(9561.1, -7517.5, 6, 6, 0, "Wayfarer's Rest tavern"); - player->SEND_GOSSIP_MENU(9603, _Creature->GetGUID()); - } -} - -void SendBattleMasterMenu_guard_silvermoon(Player *player, Creature *_Creature, uint32 action) -{ - switch (action) - { - case GOSSIP_ACTION_INFO_DEF + 1: //AV - player->SEND_POI(9850.49, -7572.26, 6, 6, 0, "Gurak"); - player->SEND_GOSSIP_MENU(9329, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 2: //AB - player->SEND_POI(9857.18, -7564.36, 6, 6, 0, "Karen Wentworth"); - player->SEND_GOSSIP_MENU(9329, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 3: //A - player->SEND_POI(9850.6, -7559.25, 6, 6, 0, "Bipp Glizzitor"); - player->SEND_GOSSIP_MENU(9329, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 4: //EOS - player->SEND_POI(9857.18, -7564.36, 6, 6, 0, "Karen Wentworth"); - player->SEND_GOSSIP_MENU(9329, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 5: //WSG - player->SEND_POI(9845.45, -7562.58, 6, 6, 0, "Krukk"); - player->SEND_GOSSIP_MENU(9329, _Creature->GetGUID()); - break; - } -} - -void SendClassTrainerMenu_guard_silvermoon(Player *player, Creature *_Creature, uint32 action) -{ - switch (action) - { - case GOSSIP_ACTION_INFO_DEF + 1: //Druid - player->SEND_POI(9700.55, -7262.57, 6, 6, 0, "Harene Plainwalker"); - player->SEND_GOSSIP_MENU(9330, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 2: //Hunter - player->SEND_POI(9927.48, -7426.14, 6, 6, 0, "Zandine"); - player->SEND_GOSSIP_MENU(9332, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 3: //Mage - player->SEND_POI(9995.07, -7118.17, 6, 6, 0, "Quithas"); - player->SEND_GOSSIP_MENU(9333, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 4: //Paladin - player->SEND_POI(9850.22, -7516.93, 6, 6, 0, "Champion Bachi"); - player->SEND_GOSSIP_MENU(9334, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 5: //Priest - player->SEND_POI(9926.79, -7066.66, 6, 6, 0, "Belestra"); - player->SEND_GOSSIP_MENU(9335, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 6: //Rogue - player->SEND_POI(9739.88, -7374.33, 6, 6, 0, "Zelanis"); - player->SEND_GOSSIP_MENU(9336, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 7: //Warlock - player->SEND_POI(9787.57, -7284.63, 6, 6, 0, "Alamma"); - player->SEND_GOSSIP_MENU(9337, _Creature->GetGUID()); - break; - } -} - -void SendProfTrainerMenu_guard_silvermoon(Player *player, Creature *_Creature, uint32 action) -{ - switch (action) - { - case GOSSIP_ACTION_INFO_DEF + 1: //Alchemy - player->SEND_POI(9998.09, -7214.36, 6, 6, 0, "Silvermoon Alchemy Trainer"); - player->SEND_GOSSIP_MENU(9316, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 2: //Blacksmithing - player->SEND_POI(9841.43, -7361.53, 6, 6, 0, "Silvermoon Blacksmithing Trainer"); - player->SEND_GOSSIP_MENU(9340, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 3: //Cooking - player->SEND_POI(9577.26, -7243.6, 6, 6, 0, "Silvermoon Cooking Trainer"); - player->SEND_GOSSIP_MENU(9316, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 4: //Enchanting - player->SEND_POI(9962.57, -7246.18, 6, 6, 0, "Silvermoon Enchanting Trainer"); - player->SEND_GOSSIP_MENU(9341, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 5: //Engineering - player->SEND_POI(9820.18, -7329.56, 6, 6, 0, "Silvermoon Engineering Trainer"); - player->SEND_GOSSIP_MENU(9316, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 6: //First Aid - player->SEND_POI(9579.8, -7343.71, 6, 6, 0, "Silvermoon First Aid Trainer"); - player->SEND_GOSSIP_MENU(9316, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 7: //Fishing - player->SEND_POI(9602.73, -7328.3, 6, 6, 0, "Silvermoon Fishing Trainer"); - player->SEND_GOSSIP_MENU(9316, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 8: //Jewelcrafting - player->SEND_POI(9553.54, -7506.43, 6, 6, 0, "Silvermoon Jewelcrafting Trainer"); - player->SEND_GOSSIP_MENU(9346, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 9: //Herbalism - player->SEND_POI(10004.4, -7216.86, 6, 6, 0, "Silvermoon Herbalism Trainer"); - player->SEND_GOSSIP_MENU(9316, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 10: //Leatherworking - player->SEND_POI(9503.72, -7430.16, 6, 6, 0, "Silvermoon Leatherworking Trainer"); - player->SEND_GOSSIP_MENU(9347, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 11: //Mining - player->SEND_POI(9805.1, -7355.56, 6, 6, 0, "Silvermoon Mining Trainer"); - player->SEND_GOSSIP_MENU(9348, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 12: //Skinning - player->SEND_POI(9513.37, -7429.4, 6, 6, 0, "Silvermoon Skinning Trainer"); - player->SEND_GOSSIP_MENU(9316, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 13: //Tailoring - player->SEND_POI(9750.55, -7095.28, 6, 6, 0, "Silvermoon Tailor"); - player->SEND_GOSSIP_MENU(9350, _Creature->GetGUID()); - break; - } -} - -bool GossipSelect_guard_silvermoon(Player *player, Creature *_Creature, uint32 sender, uint32 action ) -{ - switch (sender) - { - case GOSSIP_SENDER_MAIN: SendDefaultMenu_guard_silvermoon(player, _Creature, action); break; - case GOSSIP_SENDER_SEC_AUCTIONHOUSE: SendAuctionhouseMenu_guard_silvermoon(player, _Creature, action); break; - case GOSSIP_SENDER_SEC_INN: SendInnMenu_guard_silvermoon(player, _Creature, action); break; - case GOSSIP_SENDER_SEC_CLASSTRAIN: SendClassTrainerMenu_guard_silvermoon(player, _Creature, action); break; - case GOSSIP_SENDER_SEC_PROFTRAIN: SendProfTrainerMenu_guard_silvermoon(player, _Creature, action); break; - case GOSSIP_SENDER_SEC_BATTLEINFO: SendBattleMasterMenu_guard_silvermoon(player, _Creature, action); break; - } - return true; -} - -/******************************************************* - * guard_silvermoon end - *******************************************************/ - -CreatureAI* GetAI_guard_silvermoon(Creature *_Creature) -{ - return new guardAI (_Creature); -} - -/******************************************************* - * guard_stormwind start - *******************************************************/ - -bool GossipHello_guard_stormwind(Player *player, Creature *_Creature) -{ - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_AUCTIONHOUSE , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_STORMWIND_BANK , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_DEEPRUNTRAM , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 3); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_INN , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 4); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_GRYPHON , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 5); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_GUILDMASTER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 6); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_MAILBOX , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 7); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_STABLEMASTER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 8); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_WEAPONMASTER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 9); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_OFFICERS , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 10); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_BATTLEMASTER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 11); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_CLASSTRAINER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 12); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_PROFTRAINER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 13); - player->SEND_GOSSIP_MENU(933,_Creature->GetGUID()); - return true; -} - -void SendDefaultMenu_guard_stormwind(Player *player, Creature *_Creature, uint32 action) -{ - switch (action) - { - case GOSSIP_ACTION_INFO_DEF + 1: //Auction House - player->SEND_POI(-8811.46, 667.46, 6, 6, 0, "Stormwind Auction House"); - player->SEND_GOSSIP_MENU(3834,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 2: //Bank - player->SEND_POI(-8916.87, 622.87, 6, 6, 0, "Stormwind Bank"); - player->SEND_GOSSIP_MENU(764,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 3: //Deeprun tram - player->SEND_POI(-8378.88, 554.23, 6, 6, 0, "The Deeprun Tram"); - player->SEND_GOSSIP_MENU(3813,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 4: //Inn - player->SEND_POI(-8869.0, 675.4, 6, 6, 0, "The Gilded Rose"); - player->SEND_GOSSIP_MENU(3860,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 5: //Gryphon Master - player->SEND_POI(-8837.0, 493.5, 6, 6, 0, "Stormwind Gryphon Master"); - player->SEND_GOSSIP_MENU(879,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 6: //Guild Master - player->SEND_POI(-8894.0, 611.2, 6, 6, 0, "Stormwind Vistor`s Center"); - player->SEND_GOSSIP_MENU(882,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 7: //Mailbox - player->SEND_POI(-8876.48, 649.18, 6, 6, 0, "Stormwind Mailbox"); - player->SEND_GOSSIP_MENU(3861,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 8: //Stable Master - player->SEND_POI(-8433.0, 554.7, 6, 6, 0, "Jenova Stoneshield"); - player->SEND_GOSSIP_MENU(5984,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 9: //Weapon Trainer - player->SEND_POI(-8797.0, 612.8, 6, 6, 0, "Woo Ping"); - player->SEND_GOSSIP_MENU(4516,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 10: //Officers Lounge - player->SEND_POI(-8759.92, 399.69, 6, 6, 0, "Champions` Hall"); - player->SEND_GOSSIP_MENU(7047,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 11: //Battlemasters - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ALTERACVALLEY , GOSSIP_SENDER_SEC_BATTLEINFO, GOSSIP_ACTION_INFO_DEF + 1); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ARATHIBASIN , GOSSIP_SENDER_SEC_BATTLEINFO, GOSSIP_ACTION_INFO_DEF + 2); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_WARSONGULCH , GOSSIP_SENDER_SEC_BATTLEINFO, GOSSIP_ACTION_INFO_DEF + 3); - player->SEND_GOSSIP_MENU(7499,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 12: //Class trainers - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_MAGE , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 1); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ROGUE , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 2); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_WARRIOR , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 3); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_DRUID , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 4); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_PRIEST , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 5); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_PALADIN , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 6); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_HUNTER , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 7); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_WARLOCK , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 8); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_SHAMAN , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 9); - player->SEND_GOSSIP_MENU(898,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 13: //Profession trainers - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ALCHEMY , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 1); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_BLACKSMITHING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 2); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_COOKING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 3); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ENCHANTING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 4); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ENGINEERING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 5); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_FIRSTAID , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 6); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_FISHING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 7); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_HERBALISM , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 8); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_LEATHERWORKING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 9); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_MINING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 10); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_SKINNING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 11); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_TAILORING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 12); - player->SEND_GOSSIP_MENU(918,_Creature->GetGUID()); - break; - } -} - -void SendBattleMasterMenu_guard_stormwind(Player *player, Creature *_Creature, uint32 action) -{ - switch (action) - { - case GOSSIP_ACTION_INFO_DEF + 1: //AV - player->SEND_POI(-8443.88, 335.99, 6, 6, 0, "Thelman Slatefist"); - player->SEND_GOSSIP_MENU(7500, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 2: //AB - player->SEND_POI(-8443.88, 335.99, 6, 6, 0, "Lady Hoteshem"); - player->SEND_GOSSIP_MENU(7650, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 3: //WSG - player->SEND_POI(-8443.88, 335.99, 6, 6, 0, "Elfarran"); - player->SEND_GOSSIP_MENU(7501, _Creature->GetGUID()); - break; - } -} - -void SendClassTrainerMenu_guard_stormwind(Player *player, Creature *_Creature, uint32 action) -{ - switch (action) - { - case GOSSIP_ACTION_INFO_DEF + 1: //Mage - player->SEND_POI(-9012.0, 867.6, 6, 6, 0, "Wizard`s Sanctum"); - player->SEND_GOSSIP_MENU(899,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 2: //Rogue - player->SEND_POI(-8753.0, 367.8, 6, 6, 0, "Stormwind - Rogue House"); - player->SEND_GOSSIP_MENU(900,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 3: //Warrior - player->SEND_POI(-8624.54, 402.61, 6, 6, 0, "Pig and Whistle Tavern"); - player->SEND_GOSSIP_MENU(901,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 4: //Druid - player->SEND_POI(-8751.0, 1124.5, 6, 6, 0, "The Park"); - player->SEND_GOSSIP_MENU(902,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 5: //Priest - player->SEND_POI(-8512.0, 862.4, 6, 6, 0, "Catedral Of Light"); - player->SEND_GOSSIP_MENU(903,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 6: //Paladin - player->SEND_POI(-8577.0, 881.7, 6, 6, 0, "Catedral Of Light"); - player->SEND_GOSSIP_MENU(904,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 7: //Hunter - player->SEND_POI(-8413.0, 541.5, 6, 6, 0, "Hunter Lodge"); - player->SEND_GOSSIP_MENU(905,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 8: //Warlock - player->SEND_POI(-8948.91, 998.35, 6, 6, 0, "The Slaughtered Lamb"); - player->SEND_GOSSIP_MENU(906,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 9: //Shaman - player->SEND_POI(-9033, 550, 6, 6, 0, "Valley Of Heroes"); - //incorrect id - player->SEND_GOSSIP_MENU(2593,_Creature->GetGUID()); - break; - } -} - -void SendProfTrainerMenu_guard_stormwind(Player *player, Creature *_Creature, uint32 action) -{ - switch (action) - { - case GOSSIP_ACTION_INFO_DEF + 1: //Alchemy - player->SEND_POI(-8988.0, 759.60, 6, 6, 0, "Alchemy Needs"); - player->SEND_GOSSIP_MENU(919,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 2: //Blacksmithing - player->SEND_POI(-8424.0, 616.9, 6, 6, 0, "Therum Deepforge"); - player->SEND_GOSSIP_MENU(920,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 3: //Cooking - player->SEND_POI(-8611.0, 364.6, 6, 6, 0, "Pig and Whistle Tavern"); - player->SEND_GOSSIP_MENU(921,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 4: //Enchanting - player->SEND_POI(-8858.0, 803.7, 6, 6, 0, "Lucan Cordell"); - player->SEND_GOSSIP_MENU(941,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 5: //Engineering - player->SEND_POI(-8347.0, 644.1, 6, 6, 0, "Lilliam Sparkspindle"); - player->SEND_GOSSIP_MENU(922,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 6: //First Aid - player->SEND_POI(-8513.0, 801.8, 6, 6, 0, "Shaina Fuller"); - player->SEND_GOSSIP_MENU(923,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 7: //Fishing - player->SEND_POI(-8803.0, 767.5, 6, 6, 0, "Arnold Leland"); - player->SEND_GOSSIP_MENU(940,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 8: //Herbalism - player->SEND_POI(-8967.0, 779.5, 6, 6, 0, "Alchemy Needs"); - player->SEND_GOSSIP_MENU(924,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 9: //Leatherworking - player->SEND_POI(-8726.0, 477.4, 6, 6, 0, "The Protective Hide"); - player->SEND_GOSSIP_MENU(925,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 10: //Mining - player->SEND_POI(-8434.0, 692.8, 6, 6, 0, "Gelman Stonehand"); - player->SEND_GOSSIP_MENU(927,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 11: //Skinning - player->SEND_POI(-8716.0, 469.4, 6, 6, 0, "The Protective Hide"); - player->SEND_GOSSIP_MENU(928,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 12: //Tailoring - player->SEND_POI(-8938.0, 800.7, 6, 6, 0, "Duncan`s Textiles"); - player->SEND_GOSSIP_MENU(929,_Creature->GetGUID()); - break; - } -} - -bool GossipSelect_guard_stormwind(Player *player, Creature *_Creature, uint32 sender, uint32 action ) -{ - switch (sender) - { - case GOSSIP_SENDER_MAIN: SendDefaultMenu_guard_stormwind(player, _Creature, action); break; - case GOSSIP_SENDER_SEC_CLASSTRAIN: SendClassTrainerMenu_guard_stormwind(player, _Creature, action); break; - case GOSSIP_SENDER_SEC_PROFTRAIN: SendProfTrainerMenu_guard_stormwind(player, _Creature, action); break; - case GOSSIP_SENDER_SEC_BATTLEINFO: SendBattleMasterMenu_guard_stormwind(player, _Creature, action); break; - } - return true; -} - -bool ReceiveEmote_guard_stormwind(Player *player, Creature *_Creature, uint32 emote) -{ - if( player->GetTeam() == ALLIANCE ) - DoReplyToTextEmote(_Creature,emote); - return true; -} - -/******************************************************* - * guard_stormwind end - *******************************************************/ - -CreatureAI* GetAI_guard_stormwind(Creature *_Creature) -{ - return new guardAI (_Creature); -} - -/******************************************************* - * guard_teldrassil start - *******************************************************/ - -bool GossipHello_guard_teldrassil(Player *player, Creature *_Creature) -{ - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_BANK , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_FERRY , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_GUILDMASTER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 3); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_INN , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 4); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_STABLEMASTER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 5); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_CLASSTRAINER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 6); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_PROFTRAINER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 7); - player->SEND_GOSSIP_MENU(4316,_Creature->GetGUID()); - return true; -} - -void SendDefaultMenu_guard_teldrassil(Player *player, Creature *_Creature, uint32 action) -{ - switch (action) - { - case GOSSIP_ACTION_INFO_DEF + 1: //Bank - player->SEND_GOSSIP_MENU(4317,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 2: //Rut`theran - player->SEND_GOSSIP_MENU(4318,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 3: //Guild master - player->SEND_GOSSIP_MENU(4319,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 4: //Inn - player->SEND_POI(9821.49, 960.13, 6, 6, 0, "Dolanaar Inn"); - player->SEND_GOSSIP_MENU(4320,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 5: //stable master - player->SEND_POI(9808.37, 931.1, 6, 6, 0, "Seriadne"); - player->SEND_GOSSIP_MENU(5982,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 6: //class trainer - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_DRUID , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 1); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_HUNTER , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 2); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_PRIEST , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 3); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ROGUE , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 4); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_WARRIOR , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 5); - player->SEND_GOSSIP_MENU(4264,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 7: //profession trainer - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ALCHEMY , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 1); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_COOKING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 2); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ENCHANTING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 3); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_FIRSTAID , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 4); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_FISHING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 5); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_HERBALISM , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 6); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_LEATHERWORKING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 7); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_SKINNING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 8); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_TAILORING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 9); - player->SEND_GOSSIP_MENU(4273,_Creature->GetGUID()); - break; - } -} - -void SendClassTrainerMenu_guard_teldrassil(Player *player, Creature *_Creature, uint32 action) -{ - switch (action) - { - case GOSSIP_ACTION_INFO_DEF + 1: //Druid - player->SEND_POI(9741.58, 963.7, 6, 6, 0, "Kal"); - player->SEND_GOSSIP_MENU(4323,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 2: //Hunter - player->SEND_POI(9815.12, 926.28, 6, 6, 0, "Dazalar"); - player->SEND_GOSSIP_MENU(4324,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 3: //Priest - player->SEND_POI(9906.16, 986.63, 6, 6, 0, "Laurna Morninglight"); - player->SEND_GOSSIP_MENU(4325,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 4: //Rogue - player->SEND_POI(9789, 942.86, 6, 6, 0, "Jannok Breezesong"); - player->SEND_GOSSIP_MENU(4326,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 5: //Warrior - player->SEND_POI(9821.96, 950.61, 6, 6, 0, "Kyra Windblade"); - player->SEND_GOSSIP_MENU(4327,_Creature->GetGUID()); - break; - } -} - -void SendProfTrainerMenu_guard_teldrassil(Player *player, Creature *_Creature, uint32 action) -{ - switch (action) - { - case GOSSIP_ACTION_INFO_DEF + 1: //Alchemy - player->SEND_POI(9767.59, 878.81, 6, 6, 0, "Cyndra Kindwhisper"); - player->SEND_GOSSIP_MENU(4329,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 2: //Cooking - player->SEND_POI(9751.19, 906.13, 6, 6, 0, "Zarrin"); - player->SEND_GOSSIP_MENU(4330,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 3: //Enchanting - player->SEND_POI(10677.59, 1946.56, 6, 6, 0, "Alanna Raveneye"); - player->SEND_GOSSIP_MENU(4331,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 4: //First Aid - player->SEND_POI(9903.12, 999, 6, 6, 0, "Byancie"); - player->SEND_GOSSIP_MENU(4332,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 5: //Fishing - player->SEND_GOSSIP_MENU(4333,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 6: //Herbalism - player->SEND_POI(9773.78, 875.88, 6, 6, 0, "Malorne Bladeleaf"); - player->SEND_GOSSIP_MENU(4334,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 7: //Leatherworking - player->SEND_POI(10152.59, 1681.46, 6, 6, 0, "Nadyia Maneweaver"); - player->SEND_GOSSIP_MENU(4335,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 8: //Skinning - player->SEND_POI(10135.59, 1673.18, 6, 6, 0, "Radnaal Maneweaver"); - player->SEND_GOSSIP_MENU(4336,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 9: //Tailoring - player->SEND_GOSSIP_MENU(4337,_Creature->GetGUID()); - break; - } -} - -bool GossipSelect_guard_teldrassil(Player *player, Creature *_Creature, uint32 sender, uint32 action ) -{ - switch (sender) - { - case GOSSIP_SENDER_MAIN: SendDefaultMenu_guard_teldrassil(player, _Creature, action); break; - case GOSSIP_SENDER_SEC_CLASSTRAIN: SendClassTrainerMenu_guard_teldrassil(player, _Creature, action); break; - case GOSSIP_SENDER_SEC_PROFTRAIN: SendProfTrainerMenu_guard_teldrassil(player, _Creature, action); break; - } - return true; -} - -/******************************************************* - * guard_teldrassil end - *******************************************************/ - -CreatureAI* GetAI_guard_teldrassil(Creature *_Creature) -{ - return new guardAI (_Creature); -} - -/******************************************************* - * guard_tirisfal start - *******************************************************/ - -bool GossipHello_guard_tirisfal(Player *player, Creature *_Creature) -{ - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_BANK , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_BATHANDLER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_INN , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 3); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_STABLEMASTER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 4); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_CLASSTRAINER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 5); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_PROFTRAINER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 6); - player->SEND_GOSSIP_MENU(4097,_Creature->GetGUID()); - return true; -} - -void SendDefaultMenu_guard_tirisfal(Player *player, Creature *_Creature, uint32 action) -{ - switch (action) - { - case GOSSIP_ACTION_INFO_DEF + 1: //Bank - player->SEND_GOSSIP_MENU(4074,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 2: //bat handler - player->SEND_GOSSIP_MENU(4075,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 3: //Inn - player->SEND_POI(2246.68, 241.89, 6, 6, 0, "Gallows` End Tavern"); - player->SEND_GOSSIP_MENU(4076,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 4: //Stable Master - player->SEND_POI(2267.66, 319.32, 6, 6, 0, "Morganus"); - player->SEND_GOSSIP_MENU(5978,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 5: //Class trainer - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_MAGE , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 1); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_PRIEST , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 2); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ROGUE , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 3); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_WARLOCK , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 4); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_WARRIOR , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 5); - player->SEND_GOSSIP_MENU(4292,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 6: //Profession trainer - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ALCHEMY , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 1); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_BLACKSMITHING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 2); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_COOKING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 3); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ENCHANTING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 4); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ENGINEERING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 5); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_FIRSTAID , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 6); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_FISHING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 7); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_HERBALISM , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 8); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_LEATHERWORKING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 9); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_MINING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 10); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_SKINNING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 11); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_TAILORING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 12); - player->SEND_GOSSIP_MENU(4096,_Creature->GetGUID()); - break; - } -} - -void SendClassTrainerMenu_guard_tirisfal(Player *player, Creature *_Creature, uint32 action) -{ - switch (action) - { - case GOSSIP_ACTION_INFO_DEF + 1: //Mage - player->SEND_POI(2259.18, 240.93, 6, 6, 0, "Cain Firesong"); - player->SEND_GOSSIP_MENU(4077,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 2: //Priest - player->SEND_POI(2259.18, 240.93, 6, 6, 0, "Dark Cleric Beryl"); - player->SEND_GOSSIP_MENU(4078,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 3: //Rogue - player->SEND_POI(2259.18, 240.93, 6, 6, 0, "Marion Call"); - player->SEND_GOSSIP_MENU(4079,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 4: //Warlock - player->SEND_POI(2259.18, 240.93, 6, 6, 0, "Rupert Boch"); - player->SEND_GOSSIP_MENU(4080,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 5: //Warrior - player->SEND_POI(2256.48, 240.32, 6, 6, 0, "Austil de Mon"); - player->SEND_GOSSIP_MENU(4081,_Creature->GetGUID()); - break; - } -} - -void SendProfTrainerMenu_guard_tirisfal(Player *player, Creature *_Creature, uint32 action) -{ - switch (action) - { - case GOSSIP_ACTION_INFO_DEF + 1: //Alchemy - player->SEND_POI(2263.25, 344.23, 6, 6, 0, "Carolai Anise"); - player->SEND_GOSSIP_MENU(4082,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 2: //Blacksmithing - player->SEND_GOSSIP_MENU(4083,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 3: //Cooking - player->SEND_GOSSIP_MENU(4084,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 4: //Enchanting - player->SEND_POI(2250.35, 249.12, 6, 6, 0, "Vance Undergloom"); - player->SEND_GOSSIP_MENU(4085,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 5: //Engineering - player->SEND_GOSSIP_MENU(4086,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 6: //First Aid - player->SEND_POI(2246.68, 241.89, 6, 6, 0, "Nurse Neela"); - player->SEND_GOSSIP_MENU(4087,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 7: //Fishing - player->SEND_POI(2292.37, -10.72, 6, 6, 0, "Clyde Kellen"); - player->SEND_GOSSIP_MENU(4088,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 8: //Herbalism - player->SEND_POI(2268.21, 331.69, 6, 6, 0, "Faruza"); - player->SEND_GOSSIP_MENU(4089,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 9: //Leatherworking - player->SEND_POI(2027, 78.72, 6, 6, 0, "Shelene Rhobart"); - player->SEND_GOSSIP_MENU(4090,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 10: //Mining - player->SEND_GOSSIP_MENU(4091,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 11: //Skinning - player->SEND_POI(2027, 78.72, 6, 6, 0, "Rand Rhobart"); - player->SEND_GOSSIP_MENU(4092,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 12: //Tailoring - player->SEND_POI(2160.45, 659.93, 6, 6, 0, "Bowen Brisboise"); - player->SEND_GOSSIP_MENU(4093,_Creature->GetGUID()); - break; - } -} - -bool GossipSelect_guard_tirisfal(Player *player, Creature *_Creature, uint32 sender, uint32 action ) -{ - switch (sender) - { - case GOSSIP_SENDER_MAIN: SendDefaultMenu_guard_tirisfal(player, _Creature, action); break; - case GOSSIP_SENDER_SEC_CLASSTRAIN: SendClassTrainerMenu_guard_tirisfal(player, _Creature, action); break; - case GOSSIP_SENDER_SEC_PROFTRAIN: SendProfTrainerMenu_guard_tirisfal(player, _Creature, action); break; - } - return true; -} - -/******************************************************* - * guard_tirisfal end - *******************************************************/ - -CreatureAI* GetAI_guard_tirisfal(Creature *_Creature) -{ - return new guardAI (_Creature); -} - -/******************************************************* - * guard_undercity start - *******************************************************/ - -bool GossipHello_guard_undercity(Player *player, Creature *_Creature) -{ - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_BANK , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_BATHANDLER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_GUILDMASTER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 3); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_INN , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 4); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_MAILBOX , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 5); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_AUCTIONHOUSE , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 6); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ZEPPLINMASTER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 7); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_WEAPONMASTER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 8); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_STABLEMASTER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 9); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_BATTLEMASTER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 10); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_CLASSTRAINER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 11); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_PROFTRAINER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 12); - player->SEND_GOSSIP_MENU(3543,_Creature->GetGUID()); - return true; -} - -void SendDefaultMenu_guard_undercity(Player *player, Creature *_Creature, uint32 action) -{ - switch (action) - { - case GOSSIP_ACTION_INFO_DEF + 1: //Bank - player->SEND_POI(1595.64, 232.45, 6, 6, 0, "Undercity Bank"); - player->SEND_GOSSIP_MENU(3514,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 2: //Bat handler - player->SEND_POI(1565.9, 271.43, 6, 6, 0, "Undercity Bat Handler"); - player->SEND_GOSSIP_MENU(3515,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 3: //Guild master - player->SEND_POI(1594.17, 205.57, 6, 6, 0, "Undercity Guild Master"); - player->SEND_GOSSIP_MENU(3516,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 4: //Inn - player->SEND_POI(1639.43, 220.99, 6, 6, 0, "Undercity Inn"); - player->SEND_GOSSIP_MENU(3517,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 5: //Mailbox - player->SEND_POI(1632.68, 219.4, 6, 6, 0, "Undercity Mailbox"); - player->SEND_GOSSIP_MENU(3518,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 6: //Auction House - player->SEND_POI(1647.9, 258.49, 6, 6, 0, "Undercity Auction House"); - player->SEND_GOSSIP_MENU(3519,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 7: //Zeppelin - player->SEND_POI(2059, 274.86, 6, 6, 0, "Undercity Zeppelin"); - player->SEND_GOSSIP_MENU(3520,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 8: //Weapon Master - player->SEND_POI(1670.31, 324.66, 6, 6, 0, "Archibald"); - player->SEND_GOSSIP_MENU(4521,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 9: //Stable master - player->SEND_POI(1634.18, 226.76, 6, 6, 0, "Anya Maulray"); - player->SEND_GOSSIP_MENU(5979,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 10: //Battlemaster - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ALTERACVALLEY , GOSSIP_SENDER_SEC_BATTLEINFO, GOSSIP_ACTION_INFO_DEF + 1); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ARATHIBASIN , GOSSIP_SENDER_SEC_BATTLEINFO, GOSSIP_ACTION_INFO_DEF + 2); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_WARSONGULCH , GOSSIP_SENDER_SEC_BATTLEINFO, GOSSIP_ACTION_INFO_DEF + 3); - player->SEND_GOSSIP_MENU(7527,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 11: //Class trainer - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_MAGE , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 1); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_PRIEST , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 2); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ROGUE , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 3); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_WARLOCK , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 4); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_WARRIOR , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 5); - player->SEND_GOSSIP_MENU(3542,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 12: //Profession trainer - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ALCHEMY , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 1); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_BLACKSMITHING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 2); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_COOKING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 3); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ENCHANTING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 4); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ENGINEERING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 5); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_FIRSTAID , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 6); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_FISHING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 7); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_HERBALISM , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 8); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_LEATHERWORKING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 9); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_MINING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 10); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_SKINNING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 11); - player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_TAILORING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 12); - player->SEND_GOSSIP_MENU(3541,_Creature->GetGUID()); - break; - } -} - -void SendBattleMasterMenu_guard_undercity(Player *player, Creature *_Creature, uint32 action) -{ - switch (action) - { - case GOSSIP_ACTION_INFO_DEF + 1: //AV - player->SEND_POI(1329, 333.92, 6, 6, 0, "Grizzle Halfmane"); - player->SEND_GOSSIP_MENU(7525,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 2: //AB - player->SEND_POI(1283.3, 287.16, 6, 6, 0, "Sir Malory Wheeler"); - player->SEND_GOSSIP_MENU(7646,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 3: //WSG - player->SEND_POI(1265, 351.18, 6, 6, 0, "Kurden Bloodclaw"); - player->SEND_GOSSIP_MENU(7526,_Creature->GetGUID()); - break; - } -} - -void SendClassTrainerMenu_guard_undercity(Player *player, Creature *_Creature, uint32 action) -{ - switch (action) - { - case GOSSIP_ACTION_INFO_DEF + 1: //Mage - player->SEND_POI(1781, 53, 6, 6, 0, "Undercity Mage Trainers"); - player->SEND_GOSSIP_MENU(3513,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 2: //Priest - player->SEND_POI(1758.33, 401.5, 6, 6, 0, "Undercity Priest Trainers"); - player->SEND_GOSSIP_MENU(3521,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 3: //Rogue - player->SEND_POI(1418.56, 65, 6, 6, 0, "Undercity Rogue Trainers"); - player->SEND_GOSSIP_MENU(3524,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 4: //Warlock - player->SEND_POI(1780.92, 53.16, 6, 6, 0, "Undercity Warlock Trainers"); - player->SEND_GOSSIP_MENU(3526,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 5: //Warrior - player->SEND_POI(1775.59, 418.19, 6, 6, 0, "Undercity Warrior Trainers"); - player->SEND_GOSSIP_MENU(3527,_Creature->GetGUID()); - break; - } -} - -void SendProfTrainerMenu_guard_undercity(Player *player, Creature *_Creature, uint32 action) -{ - switch (action) - { - case GOSSIP_ACTION_INFO_DEF + 1: //Alchemy - player->SEND_POI(1419.82, 417.19, 6, 6, 0, "The Apothecarium"); - player->SEND_GOSSIP_MENU(3528,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 2: //Blacksmithing - player->SEND_POI(1696, 285, 6, 6, 0, "Undercity Blacksmithing Trainer"); - player->SEND_GOSSIP_MENU(3529,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 3: //Cooking - player->SEND_POI(1596.34, 274.68, 6, 6, 0, "Undercity Cooking Trainer"); - player->SEND_GOSSIP_MENU(3530,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 4: //Enchanting - player->SEND_POI(1488.54, 280.19, 6, 6, 0, "Undercity Enchanting Trainer"); - player->SEND_GOSSIP_MENU(3531,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 5: //Engineering - player->SEND_POI(1408.58, 143.43, 6, 6, 0, "Undercity Engineering Trainer"); - player->SEND_GOSSIP_MENU(3532,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 6: //First Aid - player->SEND_POI(1519.65, 167.19, 6, 6, 0, "Undercity First Aid Trainer"); - player->SEND_GOSSIP_MENU(3533,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 7: //Fishing - player->SEND_POI(1679.9, 89, 6, 6, 0, "Undercity Fishing Trainer"); - player->SEND_GOSSIP_MENU(3534,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 8: //Herbalism - player->SEND_POI(1558, 349.36, 6, 6, 0, "Undercity Herbalism Trainer"); - player->SEND_GOSSIP_MENU(3535,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 9: //Leatherworking - player->SEND_POI(1498.76, 196.43, 6, 6, 0, "Undercity Leatherworking Trainer"); - player->SEND_GOSSIP_MENU(3536,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 10: //Mining - player->SEND_POI(1642.88, 335.58, 6, 6, 0, "Undercity Mining Trainer"); - player->SEND_GOSSIP_MENU(3537,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 11: //Skinning - player->SEND_POI(1498.6, 196.46, 6, 6, 0, "Undercity Skinning Trainer"); - player->SEND_GOSSIP_MENU(3538,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 12: //Tailoring - player->SEND_POI(1689.55, 193, 6, 6, 0, "Undercity Tailoring Trainer"); - player->SEND_GOSSIP_MENU(3539,_Creature->GetGUID()); - break; - } -} - -bool GossipSelect_guard_undercity(Player *player, Creature *_Creature, uint32 sender, uint32 action ) -{ - switch (sender) - { - case GOSSIP_SENDER_MAIN: SendDefaultMenu_guard_undercity(player, _Creature, action); break; - case GOSSIP_SENDER_SEC_CLASSTRAIN: SendClassTrainerMenu_guard_undercity(player, _Creature, action); break; - case GOSSIP_SENDER_SEC_PROFTRAIN: SendProfTrainerMenu_guard_undercity(player, _Creature, action); break; - case GOSSIP_SENDER_SEC_BATTLEINFO: SendBattleMasterMenu_guard_undercity(player, _Creature, action); break; - } - return true; -} - -/******************************************************* - * guard_undercity end - *******************************************************/ - -CreatureAI* GetAI_guard_undercity(Creature *_Creature) -{ - return new guardAI (_Creature); -} - -/******************************************************* - * AddSC - *******************************************************/ - -void AddSC_guards() -{ - Script *newscript; - - newscript = new Script; - newscript->Name="guard_azuremyst"; - newscript->pGossipHello = &GossipHello_guard_azuremyst; - newscript->pGossipSelect = &GossipSelect_guard_azuremyst; - newscript->GetAI = GetAI_guard_azuremyst; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="guard_bluffwatcher"; - newscript->pGossipHello = &GossipHello_guard_bluffwatcher; - newscript->pGossipSelect = &GossipSelect_guard_bluffwatcher; - newscript->GetAI = GetAI_guard_bluffwatcher; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="guard_contested"; - newscript->GetAI = GetAI_guard_contested; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="guard_darnassus"; - newscript->pGossipHello = &GossipHello_guard_darnassus; - newscript->pGossipSelect = &GossipSelect_guard_darnassus; - newscript->GetAI = GetAI_guard_darnassus; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="guard_dunmorogh"; - newscript->pGossipHello = &GossipHello_guard_dunmorogh; - newscript->pGossipSelect = &GossipSelect_guard_dunmorogh; - newscript->GetAI = GetAI_guard_dunmorogh; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="guard_durotar"; - newscript->pGossipHello = &GossipHello_guard_durotar; - newscript->pGossipSelect = &GossipSelect_guard_durotar; - newscript->GetAI = GetAI_guard_durotar; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="guard_elwynnforest"; - newscript->pGossipHello = &GossipHello_guard_elwynnforest; - newscript->pGossipSelect = &GossipSelect_guard_elwynnforest; - newscript->GetAI = GetAI_guard_elwynnforest; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="guard_eversong"; - newscript->pGossipHello = &GossipHello_guard_eversong; - newscript->pGossipSelect = &GossipSelect_guard_eversong; - newscript->GetAI = GetAI_guard_eversong; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="guard_exodar"; - newscript->pGossipHello = &GossipHello_guard_exodar; - newscript->pGossipSelect = &GossipSelect_guard_exodar; - newscript->GetAI = GetAI_guard_exodar; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="guard_ironforge"; - newscript->pGossipHello = &GossipHello_guard_ironforge; - newscript->pGossipSelect = &GossipSelect_guard_ironforge; - newscript->GetAI = GetAI_guard_ironforge; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="guard_mulgore"; - newscript->pGossipHello = &GossipHello_guard_mulgore; - newscript->pGossipSelect = &GossipSelect_guard_mulgore; - newscript->GetAI = GetAI_guard_mulgore; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="guard_orgrimmar"; - newscript->pGossipHello = &GossipHello_guard_orgrimmar; - newscript->pGossipSelect = &GossipSelect_guard_orgrimmar; - newscript->pReceiveEmote = &ReceiveEmote_guard_orgrimmar; - newscript->GetAI = GetAI_guard_orgrimmar; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="guard_shattrath"; - newscript->pGossipHello = &GossipHello_guard_shattrath; - newscript->pGossipSelect = &GossipSelect_guard_shattrath; - newscript->GetAI = GetAI_guard_shattrath; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="guard_shattrath_aldor"; - newscript->GetAI = GetAI_guard_shattrath_aldor; - newscript->pGossipHello = &GossipHello_guard_shattrath_aldor; - newscript->pGossipSelect = &GossipSelect_guard_shattrath_aldor; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="guard_shattrath_scryer"; - newscript->GetAI = GetAI_guard_shattrath_scryer; - newscript->pGossipHello = &GossipHello_guard_shattrath_scryer; - newscript->pGossipSelect = &GossipSelect_guard_shattrath_scryer; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="guard_silvermoon"; - newscript->pGossipHello = &GossipHello_guard_silvermoon; - newscript->pGossipSelect = &GossipSelect_guard_silvermoon; - newscript->GetAI = GetAI_guard_silvermoon; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="guard_stormwind"; - newscript->pGossipHello = &GossipHello_guard_stormwind; - newscript->pGossipSelect = &GossipSelect_guard_stormwind; - newscript->pReceiveEmote = &ReceiveEmote_guard_stormwind; - newscript->GetAI = GetAI_guard_stormwind; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="guard_teldrassil"; - newscript->pGossipHello = &GossipHello_guard_teldrassil; - newscript->pGossipSelect = &GossipSelect_guard_teldrassil; - newscript->GetAI = GetAI_guard_teldrassil; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="guard_tirisfal"; - newscript->pGossipHello = &GossipHello_guard_tirisfal; - newscript->pGossipSelect = &GossipSelect_guard_tirisfal; - newscript->GetAI = GetAI_guard_tirisfal; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="guard_undercity"; - newscript->pGossipHello = &GossipHello_guard_undercity; - newscript->pGossipSelect = &GossipSelect_guard_undercity; - newscript->GetAI = GetAI_guard_undercity; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Guards +SD%Complete: 100 +SDComment: All Guard gossip data, quite some npc_text-id's still missing, adding constantly as new id's are known. CombatAI should be organized better for future. +SDCategory: Guards +EndScriptData */ + +/* ContentData +guard_azuremyst +guard_bluffwatcher +guard_contested +guard_darnassus +guard_dunmorogh +guard_durotar +guard_elwynnforest +guard_eversong +guard_exodar +guard_ironforge +guard_mulgore +guard_orgrimmar +guard_shattrath +guard_shattrath_aldor +guard_shattrath_scryer +guard_silvermoon +guard_stormwind +guard_teldrassil +guard_tirisfal +guard_undercity +EndContentData */ + +#include "precompiled.h" +#include "guard_ai.h" + +//script spesific action +#define GOSSIP_ACTION_TAVERN 101 +#define GOSSIP_ACTION_GEMMERCHANT 102 +#define GOSSIP_ACTION_MANALOOM 103 + +//script spesific sender +#define GOSSIP_SENDER_SEC_GEMMERCHANT 101 +#define GOSSIP_SENDER_SEC_AUCTIONHOUSE 102 + +//script spesific gossip text +#define GOSSIP_TEXT_TAVERN "Worlds End Tavern" +#define GOSSIP_TEXT_BANKSCYERS "Scyers bank" +#define GOSSIP_TEXT_BANKALDOR "Aldor Bank" +#define GOSSIP_TEXT_INNSCYERS "Scyers Inn" +#define GOSSIP_TEXT_INNALDOR "Aldor Inn" +#define GOSSIP_TEXT_STABLESCYERS "Scyers Stable" +#define GOSSIP_TEXT_STABLEALDOR "Aldor Stable" +#define GOSSIP_TEXT_BATTLEMASTERALLIANCE "Alliance Battlemasters" +#define GOSSIP_TEXT_BATTLEMASTERHORDE "Horde Battlemasters" +#define GOSSIP_TEXT_BATTLEMASTERARENA "Arena Battlemasters" +#define GOSSIP_TEXT_MANALOOM "Mana Loom" +#define GOSSIP_TEXT_ALCHEMYLAB "Alchemy Lab" +#define GOSSIP_TEXT_GEMMERCHANT "Gem Merchant" +#define GOSSIP_TEXT_GEMSCYERS "Scyers Gem Merchant" +#define GOSSIP_TEXT_GEMALDOR "Aldor Gem Merchant" + +#define GOSSIP_TEXT_AH_SILVERMOON_1 "Western Auction House" +#define GOSSIP_TEXT_AH_SILVERMOON_2 "Royal Exchange Auction House" + +#define GOSSIP_TEXT_INN_SILVERMOON_1 "Silvermoon City Inn" +#define GOSSIP_TEXT_INN_SILVERMOON_2 "Wayfarer's Rest tavern" + +//common used for guards in main cities +void DoReplyToTextEmote(Creature *_Creature,uint32 em) +{ + switch(em) + { + case TEXTEMOTE_KISS: _Creature->HandleEmoteCommand(EMOTE_ONESHOT_BOW); break; + case TEXTEMOTE_WAVE: _Creature->HandleEmoteCommand(EMOTE_ONESHOT_WAVE); break; + case TEXTEMOTE_SALUTE: _Creature->HandleEmoteCommand(EMOTE_ONESHOT_SALUTE); break; + case TEXTEMOTE_SHY: _Creature->HandleEmoteCommand(EMOTE_ONESHOT_FLEX); break; + case TEXTEMOTE_RUDE: + case TEXTEMOTE_CHICKEN: _Creature->HandleEmoteCommand(EMOTE_ONESHOT_POINT); break; + } +} + +/******************************************************* + * guard_azuremyst start + *******************************************************/ + +bool GossipHello_guard_azuremyst(Player *player, Creature *_Creature) +{ + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_BANK , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_HIPPOGRYPH , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_GUILDMASTER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 3); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_INN , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 4); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_STABLEMASTER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 5); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_CLASSTRAINER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 6); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_PROFTRAINER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 7); + player->SEND_GOSSIP_MENU(10066,_Creature->GetGUID()); + return true; +} + +void SendDefaultMenu_guard_azuremyst(Player *player, Creature *_Creature, uint32 action) +{ + switch (action) + { + case GOSSIP_ACTION_INFO_DEF + 1: //Bank + player->SEND_POI(-3918.95, -11544.7, 6, 6, 0, "Bank"); + player->SEND_GOSSIP_MENU(10067,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 2: //Hippogryph Master + player->SEND_POI(-4057.15, -11788.6, 6, 6, 0, "Stephanos"); + player->SEND_GOSSIP_MENU(10071,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 3: //Guild master + player->SEND_POI(-4092.43, -11626.6, 6, 6, 0, "Funaam"); + player->SEND_GOSSIP_MENU(10073,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 4: //Inn + player->SEND_POI(-4129.43, -12469, 6, 6, 0, "Caregiver Chellan"); + player->SEND_GOSSIP_MENU(10074,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 5: //Stable Master + player->SEND_POI(-4146.42, -12492.7, 6, 6, 0, "Esbina"); + player->SEND_GOSSIP_MENU(10075,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 6: //Class trainer + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_DRUID , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 1); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_HUNTER , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 2); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_MAGE , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 3); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_PALADIN , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 4); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_PRIEST , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 5); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_SHAMAN , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 6); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_WARRIOR , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 7); + player->SEND_GOSSIP_MENU(10076,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 7: //Profession trainer + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ALCHEMY , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 1); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_BLACKSMITHING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 2); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_COOKING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 3); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ENCHANTING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 4); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ENGINEERING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 5); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_FIRSTAID , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 6); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_FISHING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 7); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_HERBALISM , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 8); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_JEWELCRAFTING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 9); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_LEATHERWORKING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 10); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_MINING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 11); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_SKINNING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 12); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_TAILORING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 13); + player->SEND_GOSSIP_MENU(10087,_Creature->GetGUID()); + break; + } +} + +void SendClassTrainerMenu_guard_azuremyst(Player *player, Creature *_Creature, uint32 action) +{ + switch (action) + { + case GOSSIP_ACTION_INFO_DEF + 1: //Druid + player->SEND_POI(-4274.81, -11495.3, 6, 6, 0, "Shalannius"); + player->SEND_GOSSIP_MENU(10077,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 2: //Hunter + player->SEND_POI(-4203.65, -12526.5, 6, 6, 0, "Acteon"); + player->SEND_GOSSIP_MENU(10078,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 3: //Mage + player->SEND_POI(-4149.62, -12530.1, 6, 6, 0, "Semid"); + player->SEND_GOSSIP_MENU(10081,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 4: //Paladin + player->SEND_POI(-4138.98, -12468.5, 6, 6, 0, "Tullas"); + player->SEND_GOSSIP_MENU(10083,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 5: //Priest + player->SEND_POI(-4131.66, -12478.6, 6, 6, 0, "Guvan"); + player->SEND_GOSSIP_MENU(10084,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 6: //Shaman + player->SEND_POI(-4162.33, -12456.1, 6, 6, 0, "Tuluun"); + player->SEND_GOSSIP_MENU(10085,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 7: //Warrior + player->SEND_POI(-4165.05, -12536.4, 6, 6, 0, "Ruada"); + player->SEND_GOSSIP_MENU(10086,_Creature->GetGUID()); + break; + } +} + +void SendProfTrainerMenu_guard_azuremyst(Player *player, Creature *_Creature, uint32 action) +{ + switch (action) + { + case GOSSIP_ACTION_INFO_DEF + 1: //Alchemy + player->SEND_POI(-4191.15, -12470, 6, 6, 0, "Daedal"); + player->SEND_GOSSIP_MENU(10088,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 2: //Blacksmithing + player->SEND_POI(-4726.29, -12387, 6, 6, 0, "Blacksmith Calypso"); + player->SEND_GOSSIP_MENU(10089,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 3: //Cooking + player->SEND_POI(-4710.87, -12400.6, 6, 6, 0, "'Cookie' McWeaksauce"); + player->SEND_GOSSIP_MENU(10090,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 4: //Enchanting + player->SEND_POI(-3882.85, -11496.7, 6, 6, 0, "Nahogg"); + player->SEND_GOSSIP_MENU(10091,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 5: //Engineering + player->SEND_POI(-4157.57, -12470.2, 6, 6, 0, "Artificer Daelo"); + player->SEND_GOSSIP_MENU(10092,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 6: //First Aid + player->SEND_POI(-4199.11, -12469.9, 6, 6, 0, "Anchorite Fateema"); + player->SEND_GOSSIP_MENU(10093,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 7: //Fishing + player->SEND_POI(-4266.38, -12985.1, 6, 6, 0, "Diktynna"); + player->SEND_GOSSIP_MENU(10094,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 8: //Herbalism + player->SEND_GOSSIP_MENU(10095,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 9: //Jewelcrafting + player->SEND_POI(-3781.55, -11541.8, 6, 6, 0, "Farii"); + player->SEND_GOSSIP_MENU(10097,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 10: //Leatherworking + player->SEND_POI(-3442.68, -12322.2, 6, 6, 0, "Moordo"); + player->SEND_GOSSIP_MENU(10098,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 11: //Mining + player->SEND_POI(-4179.89, -12493.1, 6, 6, 0, "Dulvi"); + player->SEND_GOSSIP_MENU(10097,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 12: //Skinning + player->SEND_POI(-3431.17, -12316.5, 6, 6, 0, "Gurf"); + player->SEND_GOSSIP_MENU(10098,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 13: //Tailoring + player->SEND_POI(-4711.54, -12386.7, 6, 6, 0, "Erin Kelly"); + player->SEND_GOSSIP_MENU(10099,_Creature->GetGUID()); + break; + } +} + +bool GossipSelect_guard_azuremyst(Player *player, Creature *_Creature, uint32 sender, uint32 action ) +{ + switch (sender) + { + case GOSSIP_SENDER_MAIN: SendDefaultMenu_guard_azuremyst(player, _Creature, action); break; + case GOSSIP_SENDER_SEC_CLASSTRAIN: SendClassTrainerMenu_guard_azuremyst(player, _Creature, action); break; + case GOSSIP_SENDER_SEC_PROFTRAIN: SendProfTrainerMenu_guard_azuremyst(player, _Creature, action); break; + } + return true; +} + +/******************************************************* + * guard_azuremyst end + *******************************************************/ + +CreatureAI* GetAI_guard_azuremyst(Creature *_Creature) +{ + return new guardAI (_Creature); +} + +/******************************************************* + * guard_bluffwatcher start + *******************************************************/ + +bool GossipHello_guard_bluffwatcher(Player *player, Creature *_Creature) +{ + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_BANK , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_WINDRIDER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_GUILDMASTER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 3); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_INN , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 4); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_MAILBOX , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 5); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_AUCTIONHOUSE , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 6); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_WEAPONMASTER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 7); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_STABLEMASTER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 8); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_BATTLEMASTER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 9); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_CLASSTRAINER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 10); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_PROFTRAINER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 11); + player->SEND_GOSSIP_MENU(3543,_Creature->GetGUID()); + return true; +} + +void SendDefaultMenu_guard_bluffwatcher(Player *player, Creature *_Creature, uint32 action) +{ + switch (action) + { + case GOSSIP_ACTION_INFO_DEF + 1: //Bank + player->SEND_POI(-1257.8, 24.14, 6, 6, 0, "Thunder Bluff Bank"); + player->SEND_GOSSIP_MENU(1292,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 2: //Wind master + player->SEND_POI(-1196.43, 28.26, 6, 6, 0, "Wind Rider Roost"); + player->SEND_GOSSIP_MENU(1293,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 3: //Guild master + player->SEND_POI(-1296.5, 127.57, 6, 6, 0, "Thunder Bluff Civic Information"); + player->SEND_GOSSIP_MENU(1291,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 4: //Inn + player->SEND_POI(-1296, 39.7, 6, 6, 0, "Thunder Bluff Inn"); + player->SEND_GOSSIP_MENU(3153,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 5: //Mailbox + player->SEND_POI(-1263.59, 44.36, 6, 6, 0, "Thunder Bluff Mailbox"); + player->SEND_GOSSIP_MENU(3154,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 6: //Auction House + player->SEND_POI(1381.77, -4371.16, 6, 6, 0, GOSSIP_TEXT_AUCTIONHOUSE); + player->SEND_GOSSIP_MENU(3155,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 7: //Weapon master + player->SEND_POI(-1282.31, 89.56, 6, 6, 0, "Ansekhwa"); + player->SEND_GOSSIP_MENU(4520,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 8: //Stable master + player->SEND_POI(-1270.19, 48.84, 6, 6, 0, "Bulrug"); + player->SEND_GOSSIP_MENU(5977,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 9: //battlemaster + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ALTERACVALLEY , GOSSIP_SENDER_SEC_BATTLEINFO, GOSSIP_ACTION_INFO_DEF + 1); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ARATHIBASIN , GOSSIP_SENDER_SEC_BATTLEINFO, GOSSIP_ACTION_INFO_DEF + 2); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_WARSONGULCH , GOSSIP_SENDER_SEC_BATTLEINFO, GOSSIP_ACTION_INFO_DEF + 3); + player->SEND_GOSSIP_MENU(7527,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 10: //Class trainer + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_DRUID , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 1); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_HUNTER , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 2); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_MAGE , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 3); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_PRIEST , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 4); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_SHAMAN , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 5); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_WARRIOR , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 6); + player->SEND_GOSSIP_MENU(3542,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 11: //Profession trainer + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ALCHEMY , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 1); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_BLACKSMITHING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 2); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_COOKING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 3); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ENCHANTING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 4); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_FIRSTAID , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 5); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_FISHING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 6); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_HERBALISM , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 7); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_LEATHERWORKING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 8); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_MINING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 9); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_SKINNING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 10); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_TAILORING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 11); + player->SEND_GOSSIP_MENU(3541,_Creature->GetGUID()); + break; + } +} + +void SendBattleMasterMenu_guard_bluffwatcher(Player *player, Creature *_Creature, uint32 action) +{ + switch (action) + { + case GOSSIP_ACTION_INFO_DEF + 1: //AV + player->SEND_POI(-1387.82, -97.55, 6, 6, 0, "Taim Ragetotem"); + player->SEND_GOSSIP_MENU(7522,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 2: //AB + player->SEND_POI(-997, 214.12, 6, 6, 0, "Martin Lindsey"); + player->SEND_GOSSIP_MENU(7648,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 3: //WSG + player->SEND_POI(-1384.94, -75.91, 6, 6, 0, "Kergul Bloodaxe"); + player->SEND_GOSSIP_MENU(7523,_Creature->GetGUID()); + break; + } +} + +void SendClassTrainerMenu_guard_bluffwatcher(Player *player, Creature *_Creature, uint32 action) +{ + switch (action) + { + case GOSSIP_ACTION_INFO_DEF + 1: //Druid + player->SEND_POI(-1054.47, -285, 6, 6, 0, "Hall of Elders"); + player->SEND_GOSSIP_MENU(1294,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 2: //Hunter + player->SEND_POI(-1416.32, -114.28, 6, 6, 0, "Hunter's Hall"); + player->SEND_GOSSIP_MENU(1295,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 3: //Mage + player->SEND_POI(-1061.2, 195.5, 6, 6, 0, "Pools of Vision"); + player->SEND_GOSSIP_MENU(1296,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 4: //Priest + player->SEND_POI(-1061.2, 195.5, 6, 6, 0, "Pools of Vision"); + player->SEND_GOSSIP_MENU(1297,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 5: //Shaman + player->SEND_POI(-989.54, 278.25, 6, 6, 0, "Hall of Spirits"); + player->SEND_GOSSIP_MENU(1298,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 6: //Warrior + player->SEND_POI(-1416.32, -114.28, 6, 6, 0, "Hunter's Hall"); + player->SEND_GOSSIP_MENU(1299,_Creature->GetGUID()); + break; + } +} + +void SendProfTrainerMenu_guard_bluffwatcher(Player *player, Creature *_Creature, uint32 action) +{ + switch (action) + { + case GOSSIP_ACTION_INFO_DEF + 1: //Alchemy + player->SEND_POI(-1085.56, 27.29, 6, 6, 0, "Bena's Alchemy"); + player->SEND_GOSSIP_MENU(1332,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 2: //Blacksmithing + player->SEND_POI(-1239.75, 104.88, 6, 6, 0, "Karn's Smithy"); + player->SEND_GOSSIP_MENU(1333,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 3: //Cooking + player->SEND_POI(-1214.5, -21.23, 6, 6, 0, "Aska's Kitchen"); + player->SEND_GOSSIP_MENU(1334,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 4: //Enchanting + player->SEND_POI(-1112.65, 48.26, 6, 6, 0, "Dawnstrider Enchanters"); + player->SEND_GOSSIP_MENU(1335,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 5: //First Aid + player->SEND_POI(-996.58, 200.5, 6, 6, 0, "Spiritual Healing"); + player->SEND_GOSSIP_MENU(1336,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 6: //Fishing + player->SEND_POI(-1169.35, -68.87, 6, 6, 0, "Mountaintop Bait & Tackle"); + player->SEND_GOSSIP_MENU(1337,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 7: //Herbalism + player->SEND_POI(-1137.7, -1.51, 6, 6, 0, "Holistic Herbalism"); + player->SEND_GOSSIP_MENU(1338,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 8: //Leatherworking + player->SEND_POI(-1156.22, 66.86, 6, 6, 0, "Thunder Bluff Armorers"); + player->SEND_GOSSIP_MENU(1339,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 9: //Mining + player->SEND_POI(-1249.17, 155, 6, 6, 0, "Stonehoof Geology"); + player->SEND_GOSSIP_MENU(1340,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 10: //Skinning + player->SEND_POI(-1148.56, 51.18, 6, 6, 0, "Mooranta"); + player->SEND_GOSSIP_MENU(1343,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 11: //Tailoring + player->SEND_POI(-1156.22, 66.86, 6, 6, 0, "Thunder Bluff Armorers"); + player->SEND_GOSSIP_MENU(1341,_Creature->GetGUID()); + break; + } +} + +bool GossipSelect_guard_bluffwatcher(Player *player, Creature *_Creature, uint32 sender, uint32 action ) +{ + switch (sender) + { + case GOSSIP_SENDER_MAIN: SendDefaultMenu_guard_bluffwatcher(player, _Creature, action); break; + case GOSSIP_SENDER_SEC_CLASSTRAIN: SendClassTrainerMenu_guard_bluffwatcher(player, _Creature, action); break; + case GOSSIP_SENDER_SEC_PROFTRAIN: SendProfTrainerMenu_guard_bluffwatcher(player, _Creature, action); break; + case GOSSIP_SENDER_SEC_BATTLEINFO: SendBattleMasterMenu_guard_bluffwatcher(player, _Creature, action); break; + } + return true; +} + +/******************************************************* + * guard_bluffwatcher end + *******************************************************/ + +CreatureAI* GetAI_guard_bluffwatcher(Creature *_Creature) +{ + return new guardAI (_Creature); +} + +/******************************************************* + * guard_contested start + *******************************************************/ + +struct MANGOS_DLL_DECL guard_contested : public guardAI +{ + guard_contested(Creature *c) : guardAI(c) {} + + void MoveInLineOfSight(Unit *who) + { + if ( who->isAttackingPlayer() ) + { + if(who->GetTypeId() == TYPEID_PLAYER || who->GetOwnerGUID() && GUID_HIPART(who->GetOwnerGUID())==HIGHGUID_PLAYER) + { + m_creature->AddThreat(who, 0.0f); + if(Unit* owner = who->GetOwner()) + m_creature->AddThreat(owner, 0.0f); + + if(!m_creature->isInCombat()) + { + if (m_creature->GetEntry() == 15184) //Cenarion Hold Infantry + { + srand (time(NULL)); + if (rand()%100 <= 30) + { + DoSay("Taste blade, mongrel!", LANG_UNIVERSAL,NULL); + } + else if (rand()%100 > 30 && rand()%100 < 50) + { + DoSay("Please tell me that you didn`t just do what I think you just did. Please tell me that I`m not going to have to hurt you...", LANG_UNIVERSAL,NULL); + } + else if (rand()%100 >= 50) + { + DoSay("As if we don`t have enough problems, you go and create more!", LANG_UNIVERSAL,NULL); + } + } + else + { + SpellEntry const *spell = m_creature->reachWithSpellAttack(who); + DoCastSpell(who, spell); + } + } + DoStartAttackAndMovement(who); + } + } + } +}; +/******************************************************* + * guard_contested end + *******************************************************/ + +CreatureAI* GetAI_guard_contested(Creature *_Creature) +{ + return new guard_contested (_Creature); +} + +/******************************************************* + * guard_darnassus start + *******************************************************/ + +bool GossipHello_guard_darnassus(Player *player, Creature *_Creature) +{ + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_AUCTIONHOUSE , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_BANK , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_HIPPOGRYPH , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 3); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_GUILDMASTER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 4); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_INN , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 5); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_MAILBOX , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 6); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_STABLEMASTER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 7); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_WEAPONMASTER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 8); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_BATTLEMASTER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 9); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_CLASSTRAINER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 10); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_PROFTRAINER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 11); + player->SEND_GOSSIP_MENU(3016, _Creature->GetGUID()); + return true; +} + +void SendDefaultMenu_guard_darnassus(Player *player, Creature *_Creature, uint32 action) +{ + switch (action) + { + case GOSSIP_ACTION_INFO_DEF + 1: //Auction house + player->SEND_POI(9861.23, 2334.55, 6, 6, 0, "Darnassus Auction House"); + player->SEND_GOSSIP_MENU(3833, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 2: //Bank + player->SEND_POI(9938.45, 2512.35, 6, 6, 0, "Darnassus Bank"); + player->SEND_GOSSIP_MENU(3017, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 3: //Wind master + player->SEND_POI(9945.65, 2618.94, 6, 6, 0, "Rut'theran Village"); + player->SEND_GOSSIP_MENU(3018, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 4: //Guild master + player->SEND_POI(10076.40, 2199.59, 6, 6, 0, "Darnassus Guild Master"); + player->SEND_GOSSIP_MENU(3019, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 5: //Inn + player->SEND_POI(10133.29, 2222.52, 6, 6, 0, "Darnassus Inn"); + player->SEND_GOSSIP_MENU(3020, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 6: //Mailbox + player->SEND_POI(9942.17, 2495.48, 6, 6, 0, "Darnassus Mailbox"); + player->SEND_GOSSIP_MENU(3021, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 7: //Stable master + player->SEND_POI(10167.20, 2522.66, 6, 6, 0, "Alassin"); + player->SEND_GOSSIP_MENU(5980, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 8: //Weapon trainer + player->SEND_POI(9907.11, 2329.70, 6, 6, 0, "Ilyenia Moonfire"); + player->SEND_GOSSIP_MENU(4517, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 9: //Battlemaster + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ALTERACVALLEY , GOSSIP_SENDER_SEC_BATTLEINFO, GOSSIP_ACTION_INFO_DEF + 1); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ARATHIBASIN , GOSSIP_SENDER_SEC_BATTLEINFO, GOSSIP_ACTION_INFO_DEF + 2); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_WARSONGULCH , GOSSIP_SENDER_SEC_BATTLEINFO, GOSSIP_ACTION_INFO_DEF + 3); + player->SEND_GOSSIP_MENU(7519, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 10: //Class trainer + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_DRUID , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 1); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_HUNTER , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 2); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_PRIEST , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 3); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ROGUE , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 4); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_WARRIOR , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 5); + player->SEND_GOSSIP_MENU(4264, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 11: //Profession trainer + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ALCHEMY , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 1); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_COOKING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 2); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ENCHANTING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 3); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_FIRSTAID , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 4); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_FISHING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 5); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_HERBALISM , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 6); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_LEATHERWORKING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 7); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_SKINNING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 8); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_TAILORING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 9); + player->SEND_GOSSIP_MENU(4273, _Creature->GetGUID()); + break; + } +} + +void SendBattleMasterMenu_guard_darnassus(Player *player, Creature *_Creature, uint32 action) +{ + switch (action) + { + case GOSSIP_ACTION_INFO_DEF + 1: //AV + player->SEND_POI(9923.61, 2327.43, 6, 6, 0, "Brogun Stoneshield"); + player->SEND_GOSSIP_MENU(7518, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 2: //AB + player->SEND_POI(9977.37, 2324.39, 6, 6, 0, "Keras Wolfheart"); + player->SEND_GOSSIP_MENU(7651, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 3: //WSG + player->SEND_POI(9979.84, 2315.79, 6, 6, 0, "Aethalas"); + player->SEND_GOSSIP_MENU(7482, _Creature->GetGUID()); + break; + } +} + +void SendClassTrainerMenu_guard_darnassus(Player *player, Creature *_Creature, uint32 action) +{ + switch (action) + { + case GOSSIP_ACTION_INFO_DEF + 1: //Druid + player->SEND_POI(10186, 2570.46, 6, 6, 0, "Darnassus Druid Trainer"); + player->SEND_GOSSIP_MENU(3024, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 2: //Hunter + player->SEND_POI(10177.29, 2511.10, 6, 6, 0, "Darnassus Hunter Trainer"); + player->SEND_GOSSIP_MENU(3023, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 3: //Priest + player->SEND_POI(9659.12, 2524.88, 6, 6, 0, "Temple of the Moon"); + player->SEND_GOSSIP_MENU(3025, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 4: //Rogue + player->SEND_POI(10122, 2599.12, 6, 6, 0, "Darnassus Rogue Trainer"); + player->SEND_GOSSIP_MENU(3026, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 5: //Warrior + player->SEND_POI(9951.91, 2280.38, 6, 6, 0, "Warrior's Terrace"); + player->SEND_GOSSIP_MENU(3033, _Creature->GetGUID()); + break; + } +} + +void SendProfTrainerMenu_guard_darnassus(Player *player, Creature *_Creature, uint32 action) +{ + switch (action) + { + case GOSSIP_ACTION_INFO_DEF + 1: //Alchemy + player->SEND_POI(10075.90, 2356.76, 6, 6, 0, "Darnassus Alchemy Trainer"); + player->SEND_GOSSIP_MENU(3035, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 2: //Cooking + player->SEND_POI(10088.59, 2419.21, 6, 6, 0, "Darnassus Cooking Trainer"); + player->SEND_GOSSIP_MENU(3036, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 3: //Enchanting + player->SEND_POI(10146.09, 2313.42, 6, 6, 0, "Darnassus Enchanting Trainer"); + player->SEND_GOSSIP_MENU(3337, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 4: //First Aid + player->SEND_POI(10150.09, 2390.43, 6, 6, 0, "Darnassus First Aid Trainer"); + player->SEND_GOSSIP_MENU(3037, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 5: //Fishing + player->SEND_POI(9836.20, 2432.17, 6, 6, 0, "Darnassus Fishing Trainer"); + player->SEND_GOSSIP_MENU(3038, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 6: //Herbalism + player->SEND_POI(9757.17, 2430.16, 6, 6, 0, "Darnassus Herbalism Trainer"); + player->SEND_GOSSIP_MENU(3039, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 7: //Leatherworking + player->SEND_POI(10086.59, 2255.77, 6, 6, 0, "Darnassus Leatherworking Trainer"); + player->SEND_GOSSIP_MENU(3040, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 8: //Skinning + player->SEND_POI(10081.40, 2257.18, 6, 6, 0, "Darnassus Skinning Trainer"); + player->SEND_GOSSIP_MENU(3042, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 9: //Tailoring + player->SEND_POI(10079.70, 2268.19, 6, 6, 0, "Darnassus Tailor"); + player->SEND_GOSSIP_MENU(3044, _Creature->GetGUID()); + break; + } +} + +bool GossipSelect_guard_darnassus(Player *player, Creature *_Creature, uint32 sender, uint32 action ) +{ + switch (sender) + { + case GOSSIP_SENDER_MAIN: SendDefaultMenu_guard_darnassus(player, _Creature, action); break; + case GOSSIP_SENDER_SEC_CLASSTRAIN: SendClassTrainerMenu_guard_darnassus(player, _Creature, action); break; + case GOSSIP_SENDER_SEC_PROFTRAIN: SendProfTrainerMenu_guard_darnassus(player, _Creature, action); break; + case GOSSIP_SENDER_SEC_BATTLEINFO: SendBattleMasterMenu_guard_darnassus(player, _Creature, action); break; + } + return true; +} + +/******************************************************* + * guard_darnassus end + *******************************************************/ + +CreatureAI* GetAI_guard_darnassus(Creature *_Creature) +{ + return new guardAI (_Creature); +} + +/******************************************************* + * guard_dunmorogh start + *******************************************************/ + +bool GossipHello_guard_dunmorogh(Player *player, Creature *_Creature) +{ + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_BANK , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_HIPPOGRYPH , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_GUILDMASTER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 3); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_INN , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 4); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_STABLEMASTER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 5); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_CLASSTRAINER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 6); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_PROFTRAINER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 7); + player->SEND_GOSSIP_MENU(4287,_Creature->GetGUID()); + + return true; +} + +void SendDefaultMenu_guard_dunmorogh(Player *player, Creature *_Creature, uint32 action) +{ + switch (action) + { + case GOSSIP_ACTION_INFO_DEF + 1: //Bank + player->SEND_GOSSIP_MENU(4288,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 2: //Gryphon master + player->SEND_GOSSIP_MENU(4289,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 3: //Guild master + player->SEND_GOSSIP_MENU(4290,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 4: //Inn + player->SEND_POI(-5582.66, -525.89, 6, 6, 0, "Thunderbrew Distillery"); + player->SEND_GOSSIP_MENU(4291,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 5: //Stable Master + player->SEND_POI(-5604, -509.58, 6, 6, 0, "Shelby Stoneflint"); + player->SEND_GOSSIP_MENU(5985,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 6: //Class trainer + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_HUNTER , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 1); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_MAGE , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 2); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_PALADIN , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 3); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_PRIEST , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 4); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ROGUE , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 5); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_WARLOCK , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 6); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_WARRIOR , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 7); + player->SEND_GOSSIP_MENU(4292,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 7: //Profession trainer + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ALCHEMY , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 1); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_BLACKSMITHING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 2); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_COOKING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 3); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ENCHANTING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 4); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ENGINEERING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 5); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_FIRSTAID , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 6); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_FISHING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 7); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_HERBALISM , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 8); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_LEATHERWORKING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 9); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_MINING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 10); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_SKINNING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 11); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_TAILORING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 12); + player->SEND_GOSSIP_MENU(4300,_Creature->GetGUID()); + break; + } +} + +void SendClassTrainerMenu_guard_dunmorogh(Player *player, Creature *_Creature, uint32 action) +{ + switch (action) + { + case GOSSIP_ACTION_INFO_DEF + 1: //Hunter + player->SEND_POI(-5618.29, -454.25, 6, 6, 0, "Grif Wildheart"); + player->SEND_GOSSIP_MENU(4293,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 2: //Mage + player->SEND_POI(-5585.6, -539.99, 6, 6, 0, "Magis Sparkmantle"); + player->SEND_GOSSIP_MENU(4294,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 3: //Paladin + player->SEND_POI(-5585.6, -539.99, 6, 6, 0, "Azar Stronghammer"); + player->SEND_GOSSIP_MENU(4295,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 4: //Priest + player->SEND_POI(-5591.74, -525.61, 6, 6, 0, "Maxan Anvol"); + player->SEND_GOSSIP_MENU(4296,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 5: //Rogue + player->SEND_POI(-5602.75, -542.4, 6, 6, 0, "Hogral Bakkan"); + player->SEND_GOSSIP_MENU(4297,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 6: //Warlock + player->SEND_POI(-5641.97, -523.76, 6, 6, 0, "Gimrizz Shadowcog"); + player->SEND_GOSSIP_MENU(4298,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 7: //Warrior + player->SEND_POI(-5604.79, -529.38, 6, 6, 0, "Granis Swiftaxe"); + player->SEND_GOSSIP_MENU(4299,_Creature->GetGUID()); + break; + } +} + +void SendProfTrainerMenu_guard_dunmorogh(Player *player, Creature *_Creature, uint32 action) +{ + switch (action) + { + case GOSSIP_ACTION_INFO_DEF + 1: //Alchemy + player->SEND_GOSSIP_MENU(4301,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 2: //Blacksmithing + player->SEND_POI(-5584.72, -428.41, 6, 6, 0, "Tognus Flintfire"); + player->SEND_GOSSIP_MENU(4302,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 3: //Cooking + player->SEND_POI(-5596.85, -541.43, 6, 6, 0, "Gremlock Pilsnor"); + player->SEND_GOSSIP_MENU(4303,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 4: //Enchanting + player->SEND_GOSSIP_MENU(4304,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 5: //Engineering + player->SEND_POI(-5531, -666.53, 6, 6, 0, "Bronk Guzzlegear"); + player->SEND_GOSSIP_MENU(4305,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 6: //First Aid + player->SEND_POI(-5603.67, -523.57, 6, 6, 0, "Thamner Pol"); + player->SEND_GOSSIP_MENU(4306,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 7: //Fishing + player->SEND_POI(-5199.9, 58.58, 6, 6, 0, "Paxton Ganter"); + player->SEND_GOSSIP_MENU(4307,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 8: //Herbalism + player->SEND_GOSSIP_MENU(4308,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 9: //Leatherworking + player->SEND_GOSSIP_MENU(4310,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 10: //Mining + player->SEND_POI(-5531, -666.53, 6, 6, 0, "Yarr Hamerstone"); + player->SEND_GOSSIP_MENU(4311,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 11: //Skinning + player->SEND_GOSSIP_MENU(4312,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 12: //Tailoring + player->SEND_GOSSIP_MENU(4313,_Creature->GetGUID()); + break; + } +} + +bool GossipSelect_guard_dunmorogh(Player *player, Creature *_Creature, uint32 sender, uint32 action ) +{ + switch (sender) + { + case GOSSIP_SENDER_MAIN: SendDefaultMenu_guard_dunmorogh(player, _Creature, action); break; + case GOSSIP_SENDER_SEC_CLASSTRAIN: SendClassTrainerMenu_guard_dunmorogh(player, _Creature, action); break; + case GOSSIP_SENDER_SEC_PROFTRAIN: SendProfTrainerMenu_guard_dunmorogh(player, _Creature, action); break; + } + return true; +} + +/******************************************************* + * guard_dunmorogh end + *******************************************************/ + +CreatureAI* GetAI_guard_dunmorogh(Creature *_Creature) +{ + return new guardAI (_Creature); +} + +/******************************************************* + * guard_durotar start + *******************************************************/ + +bool GossipHello_guard_durotar(Player *player, Creature *_Creature) +{ + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_BANK , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_WINDRIDER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_INN , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 3); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_STABLEMASTER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 4); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_CLASSTRAINER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 5); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_PROFTRAINER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 6); + player->SEND_GOSSIP_MENU(4037,_Creature->GetGUID()); + return true; +} + +void SendDefaultMenu_guard_durotar(Player *player, Creature *_Creature, uint32 action) +{ + switch (action) + { + case GOSSIP_ACTION_INFO_DEF + 1: //Bank + player->SEND_GOSSIP_MENU(4032,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 2: //Wind rider + player->SEND_GOSSIP_MENU(4033,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 3: //Inn + player->SEND_POI(338.7, -4688.87, 6, 6, 0, "Razor Hill Inn"); + player->SEND_GOSSIP_MENU(4034,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 4: //Stable master + player->SEND_POI(330.31, -4710.66, 6, 6, 0, "Shoja'my"); + player->SEND_GOSSIP_MENU(5973,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 5: //Class trainer + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_HUNTER , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 1); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_MAGE , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 2); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_PRIEST , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 3); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ROGUE , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 4); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_SHAMAN , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 5); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_WARLOCK , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 6); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_WARRIOR , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 7); + player->SEND_GOSSIP_MENU(4035,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 6: //Profession trainer + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ALCHEMY , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 1); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_BLACKSMITHING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 2); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_COOKING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 3); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ENCHANTING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 4); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ENGINEERING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 5); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_FIRSTAID , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 6); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_FISHING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 7); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_HERBALISM , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 8); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_LEATHERWORKING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 9); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_MINING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 10); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_SKINNING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 11); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_TAILORING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 12); + player->SEND_GOSSIP_MENU(4036,_Creature->GetGUID()); + break; + } +} + +void SendClassTrainerMenu_guard_durotar(Player *player, Creature *_Creature, uint32 action) +{ + switch (action) + { + case GOSSIP_ACTION_INFO_DEF + 1: //Hunter + player->SEND_POI(276, -4706.72, 6, 6, 0, "Thotar"); + player->SEND_GOSSIP_MENU(4013,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 2: //Mage + player->SEND_POI(-839.33, -4935.6, 6, 6, 0, "Un'Thuwa"); + player->SEND_GOSSIP_MENU(4014,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 3: //Priest + player->SEND_POI(296.22, -4828.1, 6, 6, 0, "Tai'jin"); + player->SEND_GOSSIP_MENU(4015,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 4: //Rogue + player->SEND_POI(265.76, -4709, 6, 6, 0, "Kaplak"); + player->SEND_GOSSIP_MENU(4016,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 5: //Shaman + player->SEND_POI(307.79, -4836.97, 6, 6, 0, "Swart"); + player->SEND_GOSSIP_MENU(4017,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 6: //Warlock + player->SEND_POI(355.88, -4836.45, 6, 6, 0, "Dhugru Gorelust"); + player->SEND_GOSSIP_MENU(4018,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 7: //Warrior + player->SEND_POI(312.3, -4824.66, 6, 6, 0, "Tarshaw Jaggedscar"); + player->SEND_GOSSIP_MENU(4019,_Creature->GetGUID()); + break; + } +} + +void SendProfTrainerMenu_guard_durotar(Player *player, Creature *_Creature, uint32 action) +{ + switch (action) + { + case GOSSIP_ACTION_INFO_DEF + 1: //Alchemy + player->SEND_POI(-800.25, -4894.33, 6, 6, 0, "Miao'zan"); + player->SEND_GOSSIP_MENU(4020,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 2: //Blacksmithing + player->SEND_POI(373.24, -4716.45, 6, 6, 0, "Dwukk"); + player->SEND_GOSSIP_MENU(4021,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 3: //Cooking + player->SEND_GOSSIP_MENU(4022,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 4: //Enchanting + player->SEND_GOSSIP_MENU(4023,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 5: //Engineering + player->SEND_POI(368.95, -4723.95, 6, 6, 0, "Mukdrak"); + player->SEND_GOSSIP_MENU(4024,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 6: //First Aid + player->SEND_POI(327.17, -4825.62, 6, 6, 0, "Rawrk"); + player->SEND_GOSSIP_MENU(4025,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 7: //Fishing + player->SEND_POI(-1065.48, -4777.43, 6, 6, 0, "Lau'Tiki"); + player->SEND_GOSSIP_MENU(4026,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 8: //Herbalism + player->SEND_POI(-836.25, -4896.89, 6, 6, 0, "Mishiki"); + player->SEND_GOSSIP_MENU(4027,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 9: //Leatherworking + player->SEND_GOSSIP_MENU(4028,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 10: //Mining + player->SEND_POI(366.94, -4705, 6, 6, 0, "Krunn"); + player->SEND_GOSSIP_MENU(4029,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 11: //Skinning + player->SEND_GOSSIP_MENU(4030,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 12: //Tailoring + player->SEND_GOSSIP_MENU(4031,_Creature->GetGUID()); + break; + } +} + +bool GossipSelect_guard_durotar(Player *player, Creature *_Creature, uint32 sender, uint32 action ) +{ + switch (sender) + { + case GOSSIP_SENDER_MAIN: SendDefaultMenu_guard_durotar(player, _Creature, action); break; + case GOSSIP_SENDER_SEC_CLASSTRAIN: SendClassTrainerMenu_guard_durotar(player, _Creature, action); break; + case GOSSIP_SENDER_SEC_PROFTRAIN: SendProfTrainerMenu_guard_durotar(player, _Creature, action); break; + } + return true; +} + +/******************************************************* + * guard_durotar end + *******************************************************/ + +CreatureAI* GetAI_guard_durotar(Creature *_Creature) +{ + return new guardAI (_Creature); +} + +/******************************************************* + * guard_elwynnforest start + *******************************************************/ + +bool GossipHello_guard_elwynnforest(Player *player, Creature *_Creature) +{ + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_BANK , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_GRYPHON , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_GUILDMASTER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 3); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_INN , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 4); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_STABLEMASTER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 5); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_CLASSTRAINER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 6); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_PROFTRAINER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 7); + player->SEND_GOSSIP_MENU(933,_Creature->GetGUID()); + return true; +} + +void SendDefaultMenu_guard_elwynnforest(Player *player, Creature *_Creature, uint32 action) +{ + switch (action) + { + case GOSSIP_ACTION_INFO_DEF + 1: //Bank + player->SEND_GOSSIP_MENU(4260,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 2: //Gryphon master + player->SEND_GOSSIP_MENU(4261,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 3: //Guild master + player->SEND_GOSSIP_MENU(4262,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 4: //Inn + player->SEND_POI(-9459.34, 42.08, 6, 6, 0, "Lion's Pride Inn"); + player->SEND_GOSSIP_MENU(4263,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 5: //Stable Master + player->SEND_POI(-9466.62, 45.87, 6, 6, 0, "Erma"); + player->SEND_GOSSIP_MENU(5983,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 6: //Class trainer + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_DRUID , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 1); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_HUNTER , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 2); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_MAGE , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 3); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_PALADIN , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 4); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_PRIEST , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 5); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ROGUE , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 6); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_WARLOCK , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 7); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_WARRIOR , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 8); + player->SEND_GOSSIP_MENU(4264,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 7: //Profession trainer + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ALCHEMY , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 1); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_BLACKSMITHING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 2); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_COOKING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 3); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ENCHANTING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 4); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ENGINEERING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 5); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_FIRSTAID , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 6); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_FISHING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 7); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_HERBALISM , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 8); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_LEATHERWORKING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 9); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_MINING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 10); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_SKINNING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 11); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_TAILORING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 12); + player->SEND_GOSSIP_MENU(4273,_Creature->GetGUID()); + break; + } +} + +void SendClassTrainerMenu_guard_elwynnforest(Player *player, Creature *_Creature, uint32 action) +{ + switch (action) + { + case GOSSIP_ACTION_INFO_DEF + 1: //Druid + player->SEND_GOSSIP_MENU(4265,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 2: //Hunter + player->SEND_GOSSIP_MENU(4266,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 3: //Mage + player->SEND_POI(-9471.12, 33.44, 6, 6, 0, "Zaldimar Wefhellt"); + player->SEND_GOSSIP_MENU(4268,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 4: //Paladin + player->SEND_POI(-9469, 108.05, 6, 6, 0, "Brother Wilhelm"); + player->SEND_GOSSIP_MENU(4269,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 5: //Priest + player->SEND_POI(-9461.07, 32.6, 6, 6, 0, "Priestess Josetta"); + player->SEND_GOSSIP_MENU(4267,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 6: //Rogue + player->SEND_POI(-9465.13, 13.29, 6, 6, 0, "Keryn Sylvius"); + player->SEND_GOSSIP_MENU(4270,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 7: //Warlock + player->SEND_POI(-9473.21, -4.08, 6, 6, 0, "Maximillian Crowe"); + player->SEND_GOSSIP_MENU(4272,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 8: //Warrior + player->SEND_POI(-9461.82, 109.50, 6, 6, 0, "Lyria Du Lac"); + player->SEND_GOSSIP_MENU(4271,_Creature->GetGUID()); + break; + } +} + +void SendProfTrainerMenu_guard_elwynnforest(Player *player, Creature *_Creature, uint32 action) +{ + switch (action) + { + case GOSSIP_ACTION_INFO_DEF + 1: //Alchemy + player->SEND_POI(-9057.04, 153.63, 6, 6, 0, "Alchemist Mallory"); + player->SEND_GOSSIP_MENU(4274,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 2: //Blacksmithing + player->SEND_POI(-9456.58, 87.90, 6, 6, 0, "Smith Argus"); + player->SEND_GOSSIP_MENU(4275,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 3: //Cooking + player->SEND_POI(-9467.54, -3.16, 6, 6, 0, "Tomas"); + player->SEND_GOSSIP_MENU(4276,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 4: //Enchanting + player->SEND_GOSSIP_MENU(4277,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 5: //Engineering + player->SEND_GOSSIP_MENU(4278,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 6: //First Aid + player->SEND_POI(-9456.82, 30.49, 6, 6, 0, "Michelle Belle"); + player->SEND_GOSSIP_MENU(4279,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 7: //Fishing + player->SEND_POI(-9386.54, -118.73, 6, 6, 0, "Lee Brown"); + player->SEND_GOSSIP_MENU(4280,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 8: //Herbalism + player->SEND_POI(-9060.70, 149.23, 6, 6, 0, "Herbalist Pomeroy"); + player->SEND_GOSSIP_MENU(4281,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 9: //Leatherworking + player->SEND_POI(-9376.12, -75.23, 6, 6, 0, "Adele Fielder"); + player->SEND_GOSSIP_MENU(4282,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 10: //Mining + player->SEND_GOSSIP_MENU(4283,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 11: //Skinning + player->SEND_POI(-9536.91, -1212.76, 6, 6, 0, "Helene Peltskinner"); + player->SEND_GOSSIP_MENU(4284,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 12: //Tailoring + player->SEND_POI(-9376.12, -75.23, 6, 6, 0, "Eldrin"); + player->SEND_GOSSIP_MENU(4285,_Creature->GetGUID()); + break; + } +} + +bool GossipSelect_guard_elwynnforest(Player *player, Creature *_Creature, uint32 sender, uint32 action ) +{ + switch (sender) + { + case GOSSIP_SENDER_MAIN: SendDefaultMenu_guard_elwynnforest(player, _Creature, action); break; + case GOSSIP_SENDER_SEC_CLASSTRAIN: SendClassTrainerMenu_guard_elwynnforest(player, _Creature, action); break; + case GOSSIP_SENDER_SEC_PROFTRAIN: SendProfTrainerMenu_guard_elwynnforest(player, _Creature, action); break; + } + return true; +} + +/******************************************************* + * guard_elwynnforest end + *******************************************************/ + +CreatureAI* GetAI_guard_elwynnforest(Creature *_Creature) +{ + return new guardAI (_Creature); +} + +/******************************************************* + * guard_eversong start + *******************************************************/ + +bool GossipHello_guard_eversong(Player *player, Creature *_Creature) +{ + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_BATHANDLER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_GUILDMASTER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_INN , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 3); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_STABLEMASTER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 4); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_CLASSTRAINER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 5); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_PROFTRAINER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 6); + player->SEND_GOSSIP_MENU(10180,_Creature->GetGUID()); + return true; +} + +void SendDefaultMenu_guard_eversong(Player *player, Creature *_Creature, uint32 action) +{ + switch (action) + { + case GOSSIP_ACTION_INFO_DEF + 1: //Bat Handler + player->SEND_POI(9371.93, -7164.80, 6, 6, 0, "Skymistress Gloaming"); + player->SEND_GOSSIP_MENU(10181,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 2: //Guild master + player->SEND_GOSSIP_MENU(10182,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 3: //Inn + player->SEND_POI(9483.74, -6844.58, 6, 6, 0, "Delaniel's inn"); + player->SEND_GOSSIP_MENU(10183,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 4: //Stable Master + player->SEND_POI(9489.62, -6829.93, 6, 6, 0, "Anathos"); + player->SEND_GOSSIP_MENU(10184,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 5: //Class trainer + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_DRUID , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 1); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_HUNTER , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 2); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_MAGE , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 3); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_PALADIN , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 4); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_PRIEST , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 5); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ROGUE , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 6); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_WARLOCK , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 7); + player->SEND_GOSSIP_MENU(10180,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 6: //Profession trainer + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ALCHEMY , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 1); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_BLACKSMITHING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 2); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_COOKING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 3); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ENGINEERING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 4); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_FIRSTAID , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 5); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_FISHING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 6); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_HERBALISM , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 7); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_JEWELCRAFTING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 8); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_LEATHERWORKING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 9); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_MINING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 10); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_SKINNING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 11); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_TAILORING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 12); + player->SEND_GOSSIP_MENU(10180,_Creature->GetGUID()); + break; + } +} + +void SendClassTrainerMenu_guard_eversong(Player *player, Creature *_Creature, uint32 action) +{ + switch (action) + { + case GOSSIP_ACTION_INFO_DEF + 1: //Druid + player->SEND_GOSSIP_MENU(10185,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 2: //Hunter + player->SEND_POI(9527.44, -6865.25, 6, 6, 0, "Hannovia"); + player->SEND_GOSSIP_MENU(10186,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 3: //Mage + player->SEND_POI(9464.24, -6855.52, 6, 6, 0, "Garridel"); + player->SEND_GOSSIP_MENU(10187,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 4: //Paladin + player->SEND_POI(9517.61, -6871.04, 6, 6, 0, "Noellene"); + player->SEND_GOSSIP_MENU(10189,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 5: //Priest + player->SEND_POI(9467.39, -6845.72, 6, 6, 0, "Ponaris"); + player->SEND_GOSSIP_MENU(10190,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 6: //Rogue + player->SEND_POI(9533.67, -6877.39, 6, 6, 0, "Tannaria"); + player->SEND_GOSSIP_MENU(10191,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 7: //Warlock + player->SEND_POI(9468.99, -6865.60, 6, 6, 0, "Celoenus"); + player->SEND_GOSSIP_MENU(10192,_Creature->GetGUID()); + break; + } +} + +void SendProfTrainerMenu_guard_eversong(Player *player, Creature *_Creature, uint32 action) +{ + switch (action) + { + case GOSSIP_ACTION_INFO_DEF + 1: //Alchemy + player->SEND_POI(8659.90, -6368.12, 6, 6, 0, "Arcanist Sheynathren"); + player->SEND_GOSSIP_MENU(10193,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 2: //Blacksmithing + player->SEND_POI(8984.21, -7419.21, 6, 6, 0, "Arathel Sunforge"); + player->SEND_GOSSIP_MENU(10194,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 3: //Cooking + player->SEND_POI(9494.04, -6881.51, 6, 6, 0, "Quarelestra"); + player->SEND_GOSSIP_MENU(10195,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 4: //Engineering + player->SEND_GOSSIP_MENU(10197,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 5: //First Aid + player->SEND_POI(9479.46, -6879.16, 6, 6, 0, "Kanaria"); + player->SEND_GOSSIP_MENU(10198,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 6: //Fishing + player->SEND_GOSSIP_MENU(10199,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 7: //Herbalism + player->SEND_POI(8678.92, -6329.09, 6, 6, 0, "Botanist Tyniarrel"); + player->SEND_GOSSIP_MENU(10200,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 8: //Jewelcrafting + player->SEND_POI(9484.32, -6874.98, 6, 6, 0, "Aleinia"); + player->SEND_GOSSIP_MENU(10203,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 9: //Leatherworking + player->SEND_POI(9362.04, -7130.33, 6, 6, 0, "Sathein"); + player->SEND_GOSSIP_MENU(10204,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 10: //Mining + player->SEND_GOSSIP_MENU(10205,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 11: //Skinning + player->SEND_POI(9362.04, -7130.33, 6, 6, 0, "Mathreyn"); + player->SEND_GOSSIP_MENU(10206,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 12: //Tailoring + player->SEND_POI(8680.36, -6327.51, 6, 6, 0, "Sempstress Ambershine"); + player->SEND_GOSSIP_MENU(10207,_Creature->GetGUID()); + break; + } +} + +bool GossipSelect_guard_eversong(Player *player, Creature *_Creature, uint32 sender, uint32 action ) +{ + switch (sender) + { + case GOSSIP_SENDER_MAIN: SendDefaultMenu_guard_eversong(player, _Creature, action); break; + case GOSSIP_SENDER_SEC_CLASSTRAIN: SendClassTrainerMenu_guard_eversong(player, _Creature, action); break; + case GOSSIP_SENDER_SEC_PROFTRAIN: SendProfTrainerMenu_guard_eversong(player, _Creature, action); break; + } + return true; +} + +/******************************************************* + * guard_eversong end + *******************************************************/ + +CreatureAI* GetAI_guard_eversong(Creature *_Creature) +{ + return new guardAI (_Creature); +} + +/******************************************************* + * guard_exodar start + *******************************************************/ + +bool GossipHello_guard_exodar(Player *player, Creature *_Creature) +{ + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_AUCTIONHOUSE , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_BANK , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_GUILDMASTER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 3); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_HIPPOGRYPH , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 4); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_INN , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 5); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_MAILBOX , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 6); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_STABLEMASTER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 7); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_WEAPONMASTER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 8); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_BATTLEMASTER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 9); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_CLASSTRAINER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 10); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_PROFTRAINER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 11); + player->SEND_GOSSIP_MENU(9551, _Creature->GetGUID()); + return true; +} + +void SendDefaultMenu_guard_exodar(Player *player, Creature *_Creature, uint32 action) +{ + switch (action) + { + case GOSSIP_ACTION_INFO_DEF + 1: //Auction house + player->SEND_POI(-4023.6, -11739.3, 6, 6, 0, "Exodar Auction House"); + player->SEND_GOSSIP_MENU(9528, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 2: //Bank + player->SEND_POI(-3923.89, -11544.5, 6, 6, 0, "Exodar Bank"); + player->SEND_GOSSIP_MENU(9529, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 3: //Guild master + player->SEND_POI(-4092.57, -11626.5, 6, 6, 0, "Exodar Guild Master"); + player->SEND_GOSSIP_MENU(9539, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 4: //Hippogryph master + player->SEND_POI(-4060.46, -11787.1, 6, 6, 0, "Exodar Hippogryph Master"); + player->SEND_GOSSIP_MENU(9530, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 5: //Inn + player->SEND_POI(-3741.87, -11695.1, 6, 6, 0, "Exodar Inn"); + player->SEND_GOSSIP_MENU(9545, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 6: //Mailbox + player->SEND_POI(-3972.5, -11696.0, 6, 6, 0, "Mailbox"); + player->SEND_GOSSIP_MENU(10254, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 7: //Stable master + player->SEND_POI(-3786.5, -11702.5, 6, 6, 0, "Stable Master Arthaid"); + player->SEND_GOSSIP_MENU(9558, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 8: //Weapon trainer + player->SEND_POI(-4215.68, -11628.9, 6, 6, 0, "Weapon Master Handiir"); + player->SEND_GOSSIP_MENU(9565, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 9: //Battlemaster + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ALTERACVALLEY , GOSSIP_SENDER_SEC_BATTLEINFO, GOSSIP_ACTION_INFO_DEF + 1); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ARATHIBASIN , GOSSIP_SENDER_SEC_BATTLEINFO, GOSSIP_ACTION_INFO_DEF + 2); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ARENA , GOSSIP_SENDER_SEC_BATTLEINFO, GOSSIP_ACTION_INFO_DEF + 3); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_EYEOFTHESTORM , GOSSIP_SENDER_SEC_BATTLEINFO, GOSSIP_ACTION_INFO_DEF + 4); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_WARSONGULCH , GOSSIP_SENDER_SEC_BATTLEINFO, GOSSIP_ACTION_INFO_DEF + 5); + player->SEND_GOSSIP_MENU(9531, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 10: //Class trainer + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_DRUID , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 1); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_HUNTER , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 2); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_MAGE , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 3); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_PALADIN , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 4); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_PRIEST , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 5); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_SHAMAN , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 6); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_WARRIOR , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 7); + player->SEND_GOSSIP_MENU(9533, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 11: //Profession trainer + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ALCHEMY , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 1); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_BLACKSMITHING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 2); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_COOKING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 3); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ENCHANTING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 4); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ENGINEERING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 5); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_FIRSTAID , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 6); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_FISHING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 7); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_JEWELCRAFTING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 8); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_HERBALISM , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 9); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_LEATHERWORKING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 10); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_MINING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 11); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_SKINNING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 12); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_TAILORING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 13); + player->SEND_GOSSIP_MENU(9555, _Creature->GetGUID()); + break; + } +} + +void SendBattleMasterMenu_guard_exodar(Player *player, Creature *_Creature, uint32 action) +{ + switch (action) + { + case GOSSIP_ACTION_INFO_DEF + 1: //AV + player->SEND_POI(-3978.1, -11357, 6, 6, 0, "Alterac Valley Battlemaster"); + player->SEND_GOSSIP_MENU(9531, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 2: //AB + player->SEND_POI(-3998.9, -11345.2, 6, 6, 0, "Arathi Basin Battlemaster"); + player->SEND_GOSSIP_MENU(9531, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 3: //A + player->SEND_POI(-3759.27, -11695.63, 6, 6, 0, "Miglik Blotstrom"); + player->SEND_GOSSIP_MENU(10223, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 4: //EOS + player->SEND_POI(-3978.1, -11357, 6, 6, 0, "Eye Of The Storm Battlemaster"); + player->SEND_GOSSIP_MENU(9531, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 5: //WSG + player->SEND_POI(-3977.5, -11381.2, 6, 6, 0, "Warsong Gulch Battlemaster"); + player->SEND_GOSSIP_MENU(9531, _Creature->GetGUID()); + break; + } +} + +void SendClassTrainerMenu_guard_exodar(Player *player, Creature *_Creature, uint32 action) +{ + switch (action) + { + case GOSSIP_ACTION_INFO_DEF + 1: //Druid + player->SEND_POI(-4276.0, -11495, 6, 6, 0, "Exodar Druid Trainer"); + player->SEND_GOSSIP_MENU(9534, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 2: //Hunter + player->SEND_POI(-4210.6, -11575.2, 6, 6, 0, "Exodar Hunter Trainer"); + player->SEND_GOSSIP_MENU(9544, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 3: //Mage + player->SEND_POI(-4057.32, -11556.5, 6, 6, 0, "Exodar Mage Trainer"); + player->SEND_GOSSIP_MENU(9550, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 4: //Paladin + player->SEND_POI(-4191.2, -11470.4, 6, 6, 0, "Exodar Paladin Trainer"); + player->SEND_GOSSIP_MENU(9553, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 5: //Priest + player->SEND_POI(-3969.63, -11482.8, 6, 6, 0, "Exodar Priest Trainer"); + player->SEND_GOSSIP_MENU(9554, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 6: //Shaman + player->SEND_POI(-3805.5, -11380.7, 6, 6, 0, "Exodar Shaman Trainer"); + player->SEND_GOSSIP_MENU(9556, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 7: //Warrior + player->SEND_POI(-4189.43, -11653.7, 6, 6, 0, "Exodar Warrior Trainer"); + player->SEND_GOSSIP_MENU(9562, _Creature->GetGUID()); + break; + } +} + +void SendProfTrainerMenu_guard_exodar(Player *player, Creature *_Creature, uint32 action) +{ + switch (action) + { + case GOSSIP_ACTION_INFO_DEF + 1: //Alchemy + player->SEND_POI(-4040.6, -11364.5, 6, 6, 0, "Exodar Alchemy Trainer"); + player->SEND_GOSSIP_MENU(9527, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 2: //Blacksmithing + player->SEND_POI(-4229.5, -11706, 6, 6, 0, "Exodar Blacksmithing Trainer"); + player->SEND_GOSSIP_MENU(9532, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 3: //Cooking + player->SEND_POI(-3798.3, -11651.7, 6, 6, 0, "Exodar Cooking Trainer"); + player->SEND_GOSSIP_MENU(9551, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 4: //Enchanting + player->SEND_POI(-3889.3, -11495, 6, 6, 0, "Exodar Enchanting Trainer"); + player->SEND_GOSSIP_MENU(9535, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 5: //Engineering + player->SEND_POI(-4257.68, -11640.3, 6, 6, 0, "Exodar Engineering Trainer"); + player->SEND_GOSSIP_MENU(9536, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 6: //First Aid + player->SEND_POI(-3769.5, -11479.6, 6, 6, 0, "Exodar First Aid Trainer"); + player->SEND_GOSSIP_MENU(9537, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 7: //Fishing + player->SEND_POI(-3725.5, -11385.2, 6, 6, 0, "Exodar Fishing Trainer"); + player->SEND_GOSSIP_MENU(9538, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 8: //Jewelcrafting + player->SEND_POI(-3783, -11546, 6, 6, 0, "Exodar Jewelcrafting Trainer"); + player->SEND_GOSSIP_MENU(9547, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 9: //Herbalism + player->SEND_POI(-4040.6, -11364.5, 6, 6, 0, "Exodar Herbalist Trainer"); + player->SEND_GOSSIP_MENU(9543, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 10: //Leatherworking + player->SEND_POI(-4140.6, -11776.7, 6, 6, 0, "Exodar Leatherworking Trainer"); + player->SEND_GOSSIP_MENU(9549, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 11: //Mining + player->SEND_POI(-4228, -11697, 6, 6, 0, "Exodar Mining Trainer"); + player->SEND_GOSSIP_MENU(9552, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 12: //Skinning + player->SEND_POI(-4134.97, -11760.5, 6, 6, 0, "Exodar Skinning Trainer"); + player->SEND_GOSSIP_MENU(9557, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 13: //Tailoring + player->SEND_POI(-4092.5, -11744.5, 6, 6, 0, "Exodar Tailor Trainer"); + player->SEND_GOSSIP_MENU(9559, _Creature->GetGUID()); + break; + } +} + +bool GossipSelect_guard_exodar(Player *player, Creature *_Creature, uint32 sender, uint32 action ) +{ + switch (sender) + { + case GOSSIP_SENDER_MAIN: SendDefaultMenu_guard_exodar(player, _Creature, action); break; + case GOSSIP_SENDER_SEC_CLASSTRAIN: SendClassTrainerMenu_guard_exodar(player, _Creature, action); break; + case GOSSIP_SENDER_SEC_PROFTRAIN: SendProfTrainerMenu_guard_exodar(player, _Creature, action); break; + case GOSSIP_SENDER_SEC_BATTLEINFO: SendBattleMasterMenu_guard_exodar(player, _Creature, action); break; + } + return true; +} + +/******************************************************* + * guard_exodar end + *******************************************************/ + +CreatureAI* GetAI_guard_exodar(Creature *_Creature) +{ + return new guardAI (_Creature); +} + +/******************************************************* + * guard_ironforge start + *******************************************************/ + +bool GossipHello_guard_ironforge(Player *player, Creature *_Creature) +{ + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_AUCTIONHOUSE , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_IRONFORGE_BANK , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_DEEPRUNTRAM , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 3); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_GRYPHON , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 4); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_GUILDMASTER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 5); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_INN , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 6); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_MAILBOX , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 7); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_STABLEMASTER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 8); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_WEAPONMASTER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 9); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_BATTLEMASTER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 10); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_CLASSTRAINER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 11); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_PROFTRAINER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 12); + player->SEND_GOSSIP_MENU(2760, _Creature->GetGUID()); + return true; +} + +void SendDefaultMenu_guard_ironforge(Player *player, Creature *_Creature, uint32 action) +{ + switch (action) + { + case GOSSIP_ACTION_INFO_DEF + 1: //Auction House + player->SEND_POI(-4957.39, -911.6, 6, 6, 0, "Ironforge Auction House"); + player->SEND_GOSSIP_MENU(3014, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 2: //Bank + player->SEND_POI(-4891.91, -991.47, 6, 6, 0, "The Vault"); + player->SEND_GOSSIP_MENU(2761, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 3: //Tram + player->SEND_POI(-4835.27, -1294.69, 6, 6, 0, "Deeprun Tram"); + player->SEND_GOSSIP_MENU(3814, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 4: //Gryphon Master + player->SEND_POI(-4821.52, -1152.3, 6, 6, 0, "Ironforge Gryphon Master"); + player->SEND_GOSSIP_MENU(2762, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 5: //Guild Master + player->SEND_POI(-5021, -996.45, 6, 6, 0, "Ironforge Visitor's Center"); + player->SEND_GOSSIP_MENU(2764, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 6: //Inn + player->SEND_POI(-4850.47, -872.57, 6, 6, 0, "Stonefire Tavern"); + player->SEND_GOSSIP_MENU(2768, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 7: //Mailbox + player->SEND_POI(-4845.7, -880.55, 6, 6, 0, "Ironforge Mailbox"); + player->SEND_GOSSIP_MENU(2769, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 8: //Stable Master + player->SEND_POI(-5010.2, -1262, 6, 6, 0, "Ulbrek Firehand"); + player->SEND_GOSSIP_MENU(5986, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 9: //Weapons Trainer + player->SEND_POI(-5040, -1201.88, 6, 6, 0, "Bixi and Buliwyf"); + player->SEND_GOSSIP_MENU(4518, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 10: //Battlemaster + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ALTERACVALLEY , GOSSIP_SENDER_SEC_BATTLEINFO, GOSSIP_ACTION_INFO_DEF + 1); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ARATHIBASIN , GOSSIP_SENDER_SEC_BATTLEINFO, GOSSIP_ACTION_INFO_DEF + 2); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_WARSONGULCH , GOSSIP_SENDER_SEC_BATTLEINFO, GOSSIP_ACTION_INFO_DEF + 3); + player->SEND_GOSSIP_MENU(7529, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 11: //Class Trainer + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_HUNTER , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 1); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_MAGE , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 2); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_PALADIN , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 3); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_PRIEST , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 4); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ROGUE , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 5); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_WARLOCK , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 6); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_WARRIOR , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 7); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_SHAMAN , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 8); + player->SEND_GOSSIP_MENU(2766, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 12: //Profession Trainer + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ALCHEMY , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 1); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_BLACKSMITHING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 2); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_COOKING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 3); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ENCHANTING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 4); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ENGINEERING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 5); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_FIRSTAID , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 6); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_FISHING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 7); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_HERBALISM , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 8); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_LEATHERWORKING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 9); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_MINING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 10); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_SKINNING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 11); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_TAILORING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 12); + player->SEND_GOSSIP_MENU(2793, _Creature->GetGUID()); + break; + } +} + +void SendBattleMasterMenu_guard_ironforge(Player *player, Creature *_Creature, uint32 action) +{ + switch (action) + { + case GOSSIP_ACTION_INFO_DEF + 1: //AV + player->SEND_POI(-5047.87, -1263.77, 6, 6, 0, "Glordrum Steelbeard"); + player->SEND_GOSSIP_MENU(7483, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 2: //AB + player->SEND_POI(-5038.37, -1266.39, 6, 6, 0, "Donal Osgood"); + player->SEND_GOSSIP_MENU(7649, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 3: //WSG + player->SEND_POI(-5037.24, -1274.82, 6, 6, 0, "Lylandris"); + player->SEND_GOSSIP_MENU(7528, _Creature->GetGUID()); + break; + } +} + +void SendClassTrainerMenu_guard_ironforge(Player *player, Creature *_Creature, uint32 action) +{ + switch (action) + { + case GOSSIP_ACTION_INFO_DEF + 1: //Hunter + player->SEND_POI(-5023, -1253.68, 6, 6, 0, "Hall of Arms"); + player->SEND_GOSSIP_MENU(2770, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 2: //Mage + player->SEND_POI(-4627, -926.45, 6, 6, 0, "Hall of Mysteries"); + player->SEND_GOSSIP_MENU(2771, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 3: //Paladin + player->SEND_POI(-4627.02, -926.45, 6, 6, 0, "Hall of Mysteries"); + player->SEND_GOSSIP_MENU(2773, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 4: //Priest + player->SEND_POI(-4627, -926.45, 6, 6, 0, "Hall of Mysteries"); + player->SEND_GOSSIP_MENU(2772, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 5: //Rogue + player->SEND_POI(-4647.83, -1124, 6, 6, 0, "Ironforge Rogue Trainer"); + player->SEND_GOSSIP_MENU(2774, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 6: //Warlock + player->SEND_POI(-4605, -1110.45, 6, 6, 0, "Ironforge Warlock Trainer"); + player->SEND_GOSSIP_MENU(2775, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 7: //Warrior + player->SEND_POI(-5023.08, -1253.68, 6, 6, 0, "Hall of Arms"); + player->SEND_GOSSIP_MENU(2776, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 8: //Shaman + player->SEND_POI(-4732, -1147, 6, 6, 0, "Ironforge Shaman Trainer"); + //incorrect id + player->SEND_GOSSIP_MENU(2766, _Creature->GetGUID()); + break; + } +} + +void SendProfTrainerMenu_guard_ironforge(Player *player, Creature *_Creature, uint32 action) +{ + switch (action) + { + case GOSSIP_ACTION_INFO_DEF + 1: //Alchemy + player->SEND_POI(-4858.5, -1241.83, 6, 6, 0, "Berryfizz's Potions and Mixed Drinks"); + player->SEND_GOSSIP_MENU(2794, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 2: //Blacksmithing + player->SEND_POI(-4796.97, -1110.17, 6, 6, 0, "The Great Forge"); + player->SEND_GOSSIP_MENU(2795, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 3: //Cooking + player->SEND_POI(-4767.83, -1184.59, 6, 6, 0, "The Bronze Kettle"); + player->SEND_GOSSIP_MENU(2796, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 4: //Enchanting + player->SEND_POI(-4803.72, -1196.53, 6, 6, 0, "Thistlefuzz Arcanery"); + player->SEND_GOSSIP_MENU(2797, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 5: //Engineering + player->SEND_POI(-4799.56, -1250.23, 6, 6, 0, "Springspindle's Gadgets"); + player->SEND_GOSSIP_MENU(2798, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 6: //First Aid + player->SEND_POI(-4881.6, -1153.13, 6, 6, 0, "Ironforge Physician"); + player->SEND_GOSSIP_MENU(2799, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 7: //Fishing + player->SEND_POI(-4597.91, -1091.93, 6, 6, 0, "Traveling Fisherman"); + player->SEND_GOSSIP_MENU(2800, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 8: //Herbalism + player->SEND_POI(-4876.9, -1151.92, 6, 6, 0, "Ironforge Physician"); + player->SEND_GOSSIP_MENU(2801, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 9: //Leatherworking + player->SEND_POI(-4745, -1027.57, 6, 6, 0, "Finespindle's Leather Goods"); + player->SEND_GOSSIP_MENU(2802, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 10: //Minning + player->SEND_POI(-4705.06, -1116.43, 6, 6, 0, "Deepmountain Mining Guild"); + player->SEND_GOSSIP_MENU(2804, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 11: //Skinning + player->SEND_POI(-4745, -1027.57, 6, 6, 0, "Finespindle's Leather Goods"); + player->SEND_GOSSIP_MENU(2805, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 12: //Tailoring + player->SEND_POI(-4719.60, -1056.96, 6, 6, 0, "Stonebrow's Clothier"); + player->SEND_GOSSIP_MENU(2807, _Creature->GetGUID()); + break; + } +} + +bool GossipSelect_guard_ironforge(Player *player, Creature *_Creature, uint32 sender, uint32 action ) +{ + switch (sender) + { + case GOSSIP_SENDER_MAIN: SendDefaultMenu_guard_ironforge(player, _Creature, action); break; + case GOSSIP_SENDER_SEC_CLASSTRAIN: SendClassTrainerMenu_guard_ironforge(player, _Creature, action); break; + case GOSSIP_SENDER_SEC_PROFTRAIN: SendProfTrainerMenu_guard_ironforge(player, _Creature, action); break; + case GOSSIP_SENDER_SEC_BATTLEINFO: SendBattleMasterMenu_guard_ironforge(player, _Creature, action); break; + } + return true; +} + +/******************************************************* + * guard_ironforge end + *******************************************************/ + +CreatureAI* GetAI_guard_ironforge(Creature *_Creature) +{ + return new guardAI (_Creature); +} + +/******************************************************* + * guard_mulgore start + *******************************************************/ + +bool GossipHello_guard_mulgore(Player *player, Creature *_Creature) +{ + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_BANK , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_WINDRIDER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_INN , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 3); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_STABLEMASTER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 4); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_CLASSTRAINER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 5); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_PROFTRAINER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 6); + player->SEND_GOSSIP_MENU(3543,_Creature->GetGUID()); + return true; +} + +void SendDefaultMenu_guard_mulgore(Player *player, Creature *_Creature, uint32 action) +{ + switch (action) + { + case GOSSIP_ACTION_INFO_DEF + 1: //Bank + player->SEND_GOSSIP_MENU(4051,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 2: //Wind rider + player->SEND_GOSSIP_MENU(4052,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 3: //Inn + player->SEND_POI(-2361.38, -349.19, 6, 6, 0, "Bloodhoof Village Inn"); + player->SEND_GOSSIP_MENU(4053,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 4: //Stable master + player->SEND_POI(-2338.86, -357.56, 6, 6, 0, "Seikwa"); + player->SEND_GOSSIP_MENU(5976,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 5: //Class trainer + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_DRUID , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 1); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_HUNTER , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 2); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_SHAMAN , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 3); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_WARRIOR , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 4); + player->SEND_GOSSIP_MENU(4069,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 6: //Profession trainer + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ALCHEMY , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 1); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_BLACKSMITHING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 2); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_COOKING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 3); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ENCHANTING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 4); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_FIRSTAID , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 5); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_FISHING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 6); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_HERBALISM , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 7); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_LEATHERWORKING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 8); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_MINING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 9); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_SKINNING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 10); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_TAILORING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 11); + player->SEND_GOSSIP_MENU(4070,_Creature->GetGUID()); + break; + } +} + +void SendClassTrainerMenu_guard_mulgore(Player *player, Creature *_Creature, uint32 action) +{ + switch (action) + { + case GOSSIP_ACTION_INFO_DEF + 1: //Druid + player->SEND_POI(-2312.15, -443.69, 6, 6, 0, "Gennia Runetotem"); + player->SEND_GOSSIP_MENU(4054,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 2: //Hunter + player->SEND_POI(-2178.14, -406.14, 6, 6, 0, "Yaw Sharpmane"); + player->SEND_GOSSIP_MENU(4055,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 3: //Shaman + player->SEND_POI(-2301.5, -439.87, 6, 6, 0, "Narm Skychaser"); + player->SEND_GOSSIP_MENU(4056,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 4: //Warrior + player->SEND_POI(-2345.43, -494.11, 6, 6, 0, "Krang Stonehoof"); + player->SEND_GOSSIP_MENU(4057,_Creature->GetGUID()); + break; + } +} + +void SendProfTrainerMenu_guard_mulgore(Player *player, Creature *_Creature, uint32 action) +{ + switch (action) + { + case GOSSIP_ACTION_INFO_DEF + 1: //Alchemy + player->SEND_GOSSIP_MENU(4058,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 2: //Blacksmithing + player->SEND_GOSSIP_MENU(4059,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 3: //Cooking + player->SEND_POI(-2263.34, -287.91, 6, 6, 0, "Pyall Silentstride"); + player->SEND_GOSSIP_MENU(4060,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 4: //Enchanting + player->SEND_GOSSIP_MENU(4061,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 5: //First Aid + player->SEND_POI(-2353.52, -355.82, 6, 6, 0, "Vira Younghoof"); + player->SEND_GOSSIP_MENU(4062,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 6: //Fishing + player->SEND_POI(-2349.21, -241.37, 6, 6, 0, "Uthan Stillwater"); + player->SEND_GOSSIP_MENU(4063,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 7: //Herbalism + player->SEND_GOSSIP_MENU(4064,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 8: //Leatherworking + player->SEND_POI(-2257.12, -288.63, 6, 6, 0, "Chaw Stronghide"); + player->SEND_GOSSIP_MENU(4065,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 9: //Mining + player->SEND_GOSSIP_MENU(4066,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 10: //Skinning + player->SEND_POI(-2252.94, -291.32, 6, 6, 0, "Yonn Deepcut"); + player->SEND_GOSSIP_MENU(4067,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 11: //Tailoring + player->SEND_GOSSIP_MENU(4068,_Creature->GetGUID()); + break; + } +} + +bool GossipSelect_guard_mulgore(Player *player, Creature *_Creature, uint32 sender, uint32 action ) +{ + switch (sender) + { + case GOSSIP_SENDER_MAIN: SendDefaultMenu_guard_mulgore(player, _Creature, action); break; + case GOSSIP_SENDER_SEC_CLASSTRAIN: SendClassTrainerMenu_guard_mulgore(player, _Creature, action); break; + case GOSSIP_SENDER_SEC_PROFTRAIN: SendProfTrainerMenu_guard_mulgore(player, _Creature, action); break; + } + return true; +} + +/******************************************************* + * guard_mulgore end + *******************************************************/ + +CreatureAI* GetAI_guard_mulgore(Creature *_Creature) +{ + return new guardAI (_Creature); +} + +/******************************************************* + * guard_orgrimmar start + *******************************************************/ + +bool GossipHello_guard_orgrimmar(Player *player, Creature *_Creature) +{ + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_BANK , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_WINDRIDER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_GUILDMASTER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 3); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_INN , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 4); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_MAILBOX , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 5); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_AUCTIONHOUSE , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 6); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ZEPPLINMASTER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 7); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_WEAPONMASTER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 8); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_STABLEMASTER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 9); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_OFFICERS , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 10); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_BATTLEMASTER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 11); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_CLASSTRAINER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 12); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_PROFTRAINER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 13); + player->SEND_GOSSIP_MENU(2593,_Creature->GetGUID()); + + return true; +} + +void SendDefaultMenu_guard_orgrimmar(Player *player, Creature *_Creature, uint32 action) +{ + switch (action) + { + case GOSSIP_ACTION_INFO_DEF + 1: //Bank + player->SEND_POI(1631.51, -4375.33, 6, 6, 0, "Bank of Orgrimmar"); + player->SEND_GOSSIP_MENU(2554,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 2: //wind rider + player->SEND_POI(1676.6, -4332.72, 6, 6, 0, "The Sky Tower"); + player->SEND_GOSSIP_MENU(2555,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 3: //guild master + player->SEND_POI(1576.93, -4294.75, 6, 6, 0, "Horde Embassy"); + player->SEND_GOSSIP_MENU(2556,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 4: //Inn + player->SEND_POI(1644.51, -4447.27, 6, 6, 0, "Orgrimmar Inn"); + player->SEND_GOSSIP_MENU(2557,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 5: //mailbox + player->SEND_POI(1622.53, -4388.79, 6, 6, 0, "Orgrimmar Mailbox"); + player->SEND_GOSSIP_MENU(2558,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 6: //auction house + player->SEND_POI(1679.21, -4450.1, 6, 6, 0, "Orgrimmar Auction House"); + player->SEND_GOSSIP_MENU(3075,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 7: //zeppelin + player->SEND_POI(1337.36, -4632.7, 6, 6, 0, "Orgrimmar Zeppelin Tower"); + player->SEND_GOSSIP_MENU(3173,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 8: //weapon master + player->SEND_POI(2092.56, -4823.95, 6, 6, 0, "Sayoc & Hanashi"); + player->SEND_GOSSIP_MENU(4519,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 9: //stable master + player->SEND_POI(2133.12, -4663.93, 6, 6, 0, "Xon'cha"); + player->SEND_GOSSIP_MENU(5974,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 10: //officers lounge + player->SEND_POI(1633.56, -4249.37, 6, 6, 0, "Hall of Legends"); + player->SEND_GOSSIP_MENU(7046,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 11: //battlemaster + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ALTERACVALLEY , GOSSIP_SENDER_SEC_BATTLEINFO, GOSSIP_ACTION_INFO_DEF + 1); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ARATHIBASIN , GOSSIP_SENDER_SEC_BATTLEINFO, GOSSIP_ACTION_INFO_DEF + 2); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_WARSONGULCH , GOSSIP_SENDER_SEC_BATTLEINFO, GOSSIP_ACTION_INFO_DEF + 3); + player->SEND_GOSSIP_MENU(7521,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 12: //class trainer + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_HUNTER , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 1); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_MAGE , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 2); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_PRIEST , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 3); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_SHAMAN , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 4); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ROGUE , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 5); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_WARLOCK , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 6); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_WARRIOR , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 7); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_PALADIN , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 8); + player->SEND_GOSSIP_MENU(2599,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 13: //profession trainer + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ALCHEMY , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 1); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_BLACKSMITHING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 2); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_COOKING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 3); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ENCHANTING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 4); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ENGINEERING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 5); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_FIRSTAID , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 6); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_FISHING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 7); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_HERBALISM , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 8); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_LEATHERWORKING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 9); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_MINING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 10); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_SKINNING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 11); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_TAILORING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 12); + player->SEND_GOSSIP_MENU(2594,_Creature->GetGUID()); + break; + } +} + +void SendBattleMasterMenu_guard_orgrimmar(Player *player, Creature *_Creature, uint32 action) +{ + switch (action) + { + case GOSSIP_ACTION_INFO_DEF + 1: //AV + player->SEND_POI(1983.92, -4794.2, 6, 6, 0, "Hall of the Brave"); + player->SEND_GOSSIP_MENU(7484,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 2: //AB + player->SEND_POI(1983.92, -4794.2, 6, 6, 0, "Hall of the Brave"); + player->SEND_GOSSIP_MENU(7644,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 3: //WSG + player->SEND_POI(1983.92, -4794.2, 6, 6, 0, "Hall of the Brave"); + player->SEND_GOSSIP_MENU(7520,_Creature->GetGUID()); + break; + } +} + +void SendClassTrainerMenu_guard_orgrimmar(Player *player, Creature *_Creature, uint32 action) +{ + switch (action) + { + case GOSSIP_ACTION_INFO_DEF + 1: //Hunter + player->SEND_POI(2114.84, -4625.31, 6, 6, 0, "Orgrimmar Hunter's Hall"); + player->SEND_GOSSIP_MENU(2559,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 2: //Mage + player->SEND_POI(1451.26, -4223.33, 6, 6, 0, "Darkbriar Lodge"); + player->SEND_GOSSIP_MENU(2560,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 3: //Priest + player->SEND_POI(1442.21, -4183.24, 6, 6, 0, "Spirit Lodge"); + player->SEND_GOSSIP_MENU(2561,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 4: //Shaman + player->SEND_POI(1925.34, -4181.89, 6, 6, 0, "Thrall's Fortress"); + player->SEND_GOSSIP_MENU(2562,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 5: //Rogue + player->SEND_POI(1773.39, -4278.97, 6, 6, 0, "Shadowswift Brotherhood"); + player->SEND_GOSSIP_MENU(2563,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 6: //Warlock + player->SEND_POI(1849.57, -4359.68, 6, 6, 0, "Darkfire Enclave"); + player->SEND_GOSSIP_MENU(2564,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 7: //Warrior + player->SEND_POI(1983.92, -4794.2, 6, 6, 0, "Hall of the Brave"); + player->SEND_GOSSIP_MENU(2565,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 8: //Paladin + player->SEND_POI(1906.65, -4134.26, 6, 6, 0, "Valley of Wisdom"); + player->SEND_GOSSIP_MENU(10843,_Creature->GetGUID()); + break; + } +} + +void SendProfTrainerMenu_guard_orgrimmar(Player *player, Creature *_Creature, uint32 action) +{ + switch (action) + { + case GOSSIP_ACTION_INFO_DEF + 1: //Alchemy + player->SEND_POI(1955.17, -4475.79, 6, 6, 0, "Yelmak's Alchemy and Potions"); + player->SEND_GOSSIP_MENU(2497,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 2: //Blacksmithing + player->SEND_POI(2054.34, -4831.85, 6, 6, 0, "The Burning Anvil"); + player->SEND_GOSSIP_MENU(2499,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 3: //Cooking + player->SEND_POI(1780.96, -4481.31, 6, 6, 0, "Borstan's Firepit"); + player->SEND_GOSSIP_MENU(2500,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 4: //Enchanting + player->SEND_POI(1917.5, -4434.95, 6, 6, 0, "Godan's Runeworks"); + player->SEND_GOSSIP_MENU(2501,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 5: //Engineering + player->SEND_POI(2038.45, -4744.75, 6, 6, 0, "Nogg's Machine Shop"); + player->SEND_GOSSIP_MENU(2653,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 6: //First Aid + player->SEND_POI(1485.21, -4160.91, 6, 6, 0, "Survival of the Fittest"); + player->SEND_GOSSIP_MENU(2502,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 7: //Fishing + player->SEND_POI(1994.15, -4655.7, 6, 6, 0, "Lumak's Fishing"); + player->SEND_GOSSIP_MENU(2503,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 8: //Herbalism + player->SEND_POI(1898.61, -4454.93, 6, 6, 0, "Jandi's Arboretum"); + player->SEND_GOSSIP_MENU(2504,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 9: //Leatherworking + player->SEND_POI(1852.82, -4562.31, 6, 6, 0, "Kodohide Leatherworkers"); + player->SEND_GOSSIP_MENU(2513,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 10: //Mining + player->SEND_POI(2029.79, -4704, 6, 6, 0, "Red Canyon Mining"); + player->SEND_GOSSIP_MENU(2515,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 11: //Skinning + player->SEND_POI(1852.82, -4562.31, 6, 6, 0, "Kodohide Leatherworkers"); + player->SEND_GOSSIP_MENU(2516,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 12: //Tailoring + player->SEND_POI(1802.66, -4560.66, 6, 6, 0, "Magar's Cloth Goods"); + player->SEND_GOSSIP_MENU(2518,_Creature->GetGUID()); + break; + } +} + +bool GossipSelect_guard_orgrimmar(Player *player, Creature *_Creature, uint32 sender, uint32 action ) +{ + switch (sender) + { + case GOSSIP_SENDER_MAIN: SendDefaultMenu_guard_orgrimmar(player, _Creature, action); break; + case GOSSIP_SENDER_SEC_CLASSTRAIN: SendClassTrainerMenu_guard_orgrimmar(player, _Creature, action); break; + case GOSSIP_SENDER_SEC_PROFTRAIN: SendProfTrainerMenu_guard_orgrimmar(player, _Creature, action); break; + case GOSSIP_SENDER_SEC_BATTLEINFO: SendBattleMasterMenu_guard_orgrimmar(player, _Creature, action); break; + } + return true; +} + +bool ReceiveEmote_guard_orgrimmar(Player *player, Creature *_Creature, uint32 emote) +{ + if( player->GetTeam() == HORDE ) + DoReplyToTextEmote(_Creature,emote); + return true; +} + +/******************************************************* + * guard_orgrimmar end + *******************************************************/ + +CreatureAI* GetAI_guard_orgrimmar(Creature *_Creature) +{ + return new guardAI (_Creature); +} + +/******************************************************* + * guard_shattrath start + *******************************************************/ + +bool GossipHello_guard_shattrath(Player *player, Creature *_Creature) +{ + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_TAVERN , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_BANK , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_INN , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 3); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_FLIGHTMASTER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 4); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_MAILBOX , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 5); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_STABLEMASTER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 6); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_BATTLEMASTER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 7); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_PROFTRAINER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 8); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_MANALOOM , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 9); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ALCHEMYLAB , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 10); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_GEMMERCHANT , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 11); + player->SEND_GOSSIP_MENU(10321, _Creature->GetGUID()); + + return true; +} + +void SendDefaultMenu_guard_shattrath(Player *player, Creature *_Creature, uint32 action) +{ + switch (action) + { + case GOSSIP_ACTION_INFO_DEF + 1: //Tavern + player->SEND_POI(-1759.5, 5165, 6, 6, 0, "Worlds End Tavern"); + player->SEND_GOSSIP_MENU(10394, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 2: //Bank + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_BANKALDOR , GOSSIP_SENDER_SEC_BANK, GOSSIP_ACTION_INFO_DEF + 1); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_BANKSCYERS , GOSSIP_SENDER_SEC_BANK, GOSSIP_ACTION_INFO_DEF + 2); + player->SEND_GOSSIP_MENU(10379, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 3: //Inn + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_INNALDOR , GOSSIP_SENDER_SEC_INN, GOSSIP_ACTION_INFO_DEF + 1); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_INNSCYERS , GOSSIP_SENDER_SEC_INN, GOSSIP_ACTION_INFO_DEF + 2); + player->SEND_GOSSIP_MENU(10382, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 4: //Flight master + player->SEND_POI(-1832, 5299, 6, 6, 0, "Flight Master"); + player->SEND_GOSSIP_MENU(10385, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 5: //Mailbox + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_BANKALDOR , GOSSIP_SENDER_SEC_MAILBOX, GOSSIP_ACTION_INFO_DEF + 1); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_INNALDOR , GOSSIP_SENDER_SEC_MAILBOX, GOSSIP_ACTION_INFO_DEF + 2); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_BANKSCYERS , GOSSIP_SENDER_SEC_MAILBOX, GOSSIP_ACTION_INFO_DEF + 3); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_INNSCYERS , GOSSIP_SENDER_SEC_MAILBOX, GOSSIP_ACTION_INFO_DEF + 4); + player->SEND_GOSSIP_MENU(10386, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 6: //Stable master + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_STABLEALDOR , GOSSIP_SENDER_SEC_STABLEMASTER, GOSSIP_ACTION_INFO_DEF + 1); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_STABLESCYERS , GOSSIP_SENDER_SEC_STABLEMASTER, GOSSIP_ACTION_INFO_DEF + 2); + player->SEND_GOSSIP_MENU(10387, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 7: //Battlemaster + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_BATTLEMASTERALLIANCE , GOSSIP_SENDER_SEC_BATTLEINFO, GOSSIP_ACTION_INFO_DEF + 1); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_BATTLEMASTERHORDE , GOSSIP_SENDER_SEC_BATTLEINFO, GOSSIP_ACTION_INFO_DEF + 2); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_BATTLEMASTERARENA , GOSSIP_SENDER_SEC_BATTLEINFO, GOSSIP_ACTION_INFO_DEF + 3); + player->SEND_GOSSIP_MENU(10388, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 8: //Profession master + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ALCHEMY , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 1); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_BLACKSMITHING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 2); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_COOKING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 3); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ENCHANTING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 4); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_FIRSTAID , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 5); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_JEWELCRAFTING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 6); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_LEATHERWORKING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 7); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_SKINNING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 8); + player->SEND_GOSSIP_MENU(10391, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 9: //Mana Loom + player->SEND_POI(-2070, 5265.5, 6, 6, 0, "Mana Loom"); + player->SEND_GOSSIP_MENU(10503, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 10: //Alchemy Lab + player->SEND_POI(-1648.5, 5540, 6, 6, 0, "Alchemy Lab"); + player->SEND_GOSSIP_MENU(10321, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 11: //Gem Merchant + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_GEMALDOR , GOSSIP_SENDER_SEC_GEMMERCHANT, GOSSIP_ACTION_INFO_DEF + 1); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_GEMSCYERS , GOSSIP_SENDER_SEC_GEMMERCHANT, GOSSIP_ACTION_INFO_DEF + 2); + player->SEND_GOSSIP_MENU(10697, _Creature->GetGUID()); + break; + } +} + +void SendBankMenu_guard_shattrath(Player *player, Creature *_Creature, uint32 action) +{ + if (action == GOSSIP_ACTION_INFO_DEF + 1) + { + player->SEND_POI(-1730.5, 5496, 6, 6, 0, "Aldor Bank"); + player->SEND_GOSSIP_MENU(10380, _Creature->GetGUID()); + } + if (action == GOSSIP_ACTION_INFO_DEF + 2) + { + player->SEND_POI(-1997.7, 5363, 6, 6, 0, "Scyers Bank"); + player->SEND_GOSSIP_MENU(10381, _Creature->GetGUID()); + } +} + +void SendInnMenu_guard_shattrath(Player *player, Creature *_Creature, uint32 action) +{ + if (action == GOSSIP_ACTION_INFO_DEF + 1) + { + player->SEND_POI(-1895, 5767, 6, 6, 0, "Aldor Inn"); + player->SEND_GOSSIP_MENU(10383, _Creature->GetGUID()); + } + if (action == GOSSIP_ACTION_INFO_DEF + 2) + { + player->SEND_POI(-2178, 5405, 6, 6, 0, "Scyers Inn"); + player->SEND_GOSSIP_MENU(10384, _Creature->GetGUID()); + } +} + +void SendMailboxMenu_guard_shattrath(Player *player, Creature *_Creature, uint32 action) +{ + switch (action) + { + case GOSSIP_ACTION_INFO_DEF + 1: + player->SEND_POI(-1730.5, 5496, 6, 6, 0, "Aldor Bank"); + player->SEND_GOSSIP_MENU(10380, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 2: + player->SEND_POI(-1895, 5767, 6, 6, 0, "Aldor Inn"); + player->SEND_GOSSIP_MENU(10383, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 3: + player->SEND_POI(-1997.7, 5363, 6, 6, 0, "Scyers Bank"); + player->SEND_GOSSIP_MENU(10381, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 4: + player->SEND_POI(-2178, 5405, 6, 6, 0, "Scyers Inn"); + player->SEND_GOSSIP_MENU(10384, _Creature->GetGUID()); + break; + } +} + +void SendStableMasterMenu_guard_shattrath(Player *player, Creature *_Creature, uint32 action) +{ + if (action == GOSSIP_ACTION_INFO_DEF + 1) + { + player->SEND_POI(-1888.5, 5761, 6, 6, 0, "Aldor Stable"); + player->SEND_GOSSIP_MENU(10321, _Creature->GetGUID()); + } + if (action == GOSSIP_ACTION_INFO_DEF + 2) + { + player->SEND_POI(-2170, 5404, 6, 6, 0, "Scyers Stable"); + player->SEND_GOSSIP_MENU(10321, _Creature->GetGUID()); + } +} + +void SendBattleMasterMenu_guard_shattrath(Player *player, Creature *_Creature, uint32 action) +{ + switch (action) + { + case GOSSIP_ACTION_INFO_DEF + 1: + player->SEND_POI(-1774, 5251, 6, 6, 0, "Alliance Battlemasters"); + player->SEND_GOSSIP_MENU(10389, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 2: + player->SEND_POI(-1963, 5263, 6, 6, 0, "Horde Battlemasters"); + player->SEND_GOSSIP_MENU(10390, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 3: + player->SEND_POI(-1960, 5175, 6, 6, 0, "Arena Battlemasters"); + player->SEND_GOSSIP_MENU(12510, _Creature->GetGUID()); + break; + } +} + +void SendProfTrainerMenu_guard_shattrath(Player *player, Creature *_Creature, uint32 action) +{ + switch (action) + { + case GOSSIP_ACTION_INFO_DEF + 1: //Alchemy + player->SEND_POI(-1648.5, 5534, 6, 6, 0, "Lorokeem"); + player->SEND_GOSSIP_MENU(10392, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 2: //Blacksmithing + player->SEND_POI(-1847, 5222, 6, 6, 0, "Kradu Grimblade and Zula Slagfury"); + player->SEND_GOSSIP_MENU(10400, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 3: //Cooking + player->SEND_POI(-2067.4, 5316.5, 6, 6, 0, "Jack Trapper"); + player->SEND_GOSSIP_MENU(10393, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 4: //Enchanting + player->SEND_POI(-2263.5, 5563.5, 6, 6, 0, "High Enchanter Bardolan"); + player->SEND_GOSSIP_MENU(10395, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 5: //First Aid + player->SEND_POI(-1591, 5265.5, 6, 6, 0, "Mildred Fletcher"); + player->SEND_GOSSIP_MENU(10396, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 6: //Jewelcrafting + player->SEND_POI(-1654, 5667.5, 6, 6, 0, "Hamanar"); + player->SEND_GOSSIP_MENU(10397, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 7: //Leatherworking + player->SEND_POI(-2060.5, 5256.5, 6, 6, 0, "Darmari"); + player->SEND_GOSSIP_MENU(10399, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 8: //Skinning + player->SEND_POI(-2048, 5300, 6, 6, 0, "Seymour"); + player->SEND_GOSSIP_MENU(10398, _Creature->GetGUID()); + break; + } +} + +void SendGemMerchantMenu_guard_shattrath(Player *player, Creature *_Creature, uint32 action) +{ + if (action == GOSSIP_ACTION_INFO_DEF + 1) + { + player->SEND_POI(-1645, 5669.5, 6, 6, 0, "Aldor Gem Merchant"); + player->SEND_GOSSIP_MENU(10698, _Creature->GetGUID()); + } + if (action == GOSSIP_ACTION_INFO_DEF + 2) + { + player->SEND_POI(-2193, 5424.5, 6, 6, 0, "Scyers Gem Merchant"); + player->SEND_GOSSIP_MENU(10699, _Creature->GetGUID()); + } +} + +bool GossipSelect_guard_shattrath(Player *player, Creature *_Creature, uint32 sender, uint32 action ) +{ + switch (sender) + { + case GOSSIP_SENDER_MAIN: SendDefaultMenu_guard_shattrath(player, _Creature, action); break; + case GOSSIP_SENDER_SEC_BANK: SendBankMenu_guard_shattrath(player, _Creature, action); break; + case GOSSIP_SENDER_SEC_INN: SendInnMenu_guard_shattrath(player, _Creature, action); break; + case GOSSIP_SENDER_SEC_STABLEMASTER: SendStableMasterMenu_guard_shattrath(player, _Creature, action); break; + case GOSSIP_SENDER_SEC_GEMMERCHANT: SendGemMerchantMenu_guard_shattrath(player, _Creature, action); break; + case GOSSIP_SENDER_SEC_MAILBOX: SendMailboxMenu_guard_shattrath(player, _Creature, action); break; + case GOSSIP_SENDER_SEC_PROFTRAIN: SendProfTrainerMenu_guard_shattrath(player, _Creature, action); break; + case GOSSIP_SENDER_SEC_BATTLEINFO: SendBattleMasterMenu_guard_shattrath(player, _Creature, action); break; + } + return true; +} + +/******************************************************* + * guard_shattrath end + *******************************************************/ + +CreatureAI* GetAI_guard_shattrath(Creature *_Creature) +{ + return new guardAI (_Creature); +} + +/******************************************************* + * guard_shattrath_aldor + *******************************************************/ + +#define SPELL_BANISHED_SHATTRATH_A 36642 +#define SPELL_BANISHED_SHATTRATH_S 36671 +#define SPELL_BANISH_TELEPORT 36643 +#define SPELL_EXILE 39533 + +struct MANGOS_DLL_DECL guard_shattrath_aldorAI : public guardAI +{ + guard_shattrath_aldorAI(Creature *c) : guardAI(c) { Reset(); } + + uint32 Exile_Timer; + uint32 Banish_Timer; + uint64 playerGUID; + bool CanTeleport; + + void Reset() + { + Banish_Timer = 5000; + Exile_Timer = 8500; + playerGUID = 0; + CanTeleport = false; + } + + void Aggro(Unit *who) {} + + void UpdateAI(const uint32 diff) + { + if(!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + if( CanTeleport ) + { + if( Exile_Timer < diff ) + { + if( Unit* temp = Unit::GetUnit(*m_creature,playerGUID) ) + { + temp->CastSpell(temp,SPELL_EXILE,true); + temp->CastSpell(temp,SPELL_BANISH_TELEPORT,true); + } + playerGUID = 0; + Exile_Timer = 8500; + CanTeleport = false; + }else Exile_Timer -= diff; + } + else if( Banish_Timer < diff ) + { + Unit* temp = m_creature->getVictim(); + if( temp && temp->GetTypeId() == TYPEID_PLAYER ) + { + DoCast(temp,SPELL_BANISHED_SHATTRATH_A); + Banish_Timer = 9000; + playerGUID = temp->GetGUID(); + if( playerGUID ) + CanTeleport = true; + } + }else Banish_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; + +bool GossipHello_guard_shattrath_aldor(Player *player, Creature *_Creature) +{ + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_TAVERN , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_BANK , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_INN , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 3); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_FLIGHTMASTER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 4); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_MAILBOX , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 5); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_STABLEMASTER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 6); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_BATTLEMASTER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 7); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_PROFTRAINER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 8); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_MANALOOM , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 9); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ALCHEMYLAB , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 10); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_GEMMERCHANT , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 11); + player->SEND_GOSSIP_MENU(10524, _Creature->GetGUID()); + return true; +} + +void SendDefaultMenu_guard_shattrath_aldor(Player *player, Creature *_Creature, uint32 action) +{ + switch (action) + { + case GOSSIP_ACTION_INFO_DEF + 1: //Tavern + player->SEND_POI(-1759.5, 5165, 6, 6, 0, "Worlds End Tavern"); + player->SEND_GOSSIP_MENU(10394, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 2: //Bank + player->SEND_POI(-1730.5, 5496, 6, 6, 0, "Aldor Bank"); + player->SEND_GOSSIP_MENU(10380, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 3: //Inn + player->SEND_POI(-1895, 5767, 6, 6, 0, "Aldor Inn"); + player->SEND_GOSSIP_MENU(10525, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 4: //Flight master + player->SEND_POI(-1832, 5299, 6, 6, 0, "Shattrath Flight Master"); + player->SEND_GOSSIP_MENU(10402, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 5: //Mailbox + player->SEND_POI(0, 0, 6, 6, 0, "Aldor Mailbox"); + //unknown + player->SEND_GOSSIP_MENU(10524, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 6: //Stable master + player->SEND_POI(-1888.5, 5761, 6, 6, 0, "Aldor Stable Master"); + player->SEND_GOSSIP_MENU(10527, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 7: //Battlemaster + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_BATTLEMASTERALLIANCE , GOSSIP_SENDER_SEC_BATTLEINFO, GOSSIP_ACTION_INFO_DEF + 1); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_BATTLEMASTERHORDE , GOSSIP_SENDER_SEC_BATTLEINFO, GOSSIP_ACTION_INFO_DEF + 2); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_BATTLEMASTERARENA , GOSSIP_SENDER_SEC_BATTLEINFO, GOSSIP_ACTION_INFO_DEF + 3); + player->SEND_GOSSIP_MENU(10388, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 8: //Profession master + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ALCHEMY , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 1); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_BLACKSMITHING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 2); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_COOKING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 3); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ENCHANTING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 4); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_FIRSTAID , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 5); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_JEWELCRAFTING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 6); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_LEATHERWORKING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 7); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_SKINNING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 8); + player->SEND_GOSSIP_MENU(10391, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 9: //Mana Loom + player->SEND_POI(-2070, 5265.5, 6, 6, 0, "Mana Loom"); + player->SEND_GOSSIP_MENU(10522, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 10: //Alchemy Lab + player->SEND_POI(-1648.5, 5540, 6, 6, 0, "Alchemy Lab"); + player->SEND_GOSSIP_MENU(10696, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 11: //Gem Merchant + player->SEND_POI(-1645, 5669.5, 6, 6, 0, "Aldor Gem Merchant"); + player->SEND_GOSSIP_MENU(10411, _Creature->GetGUID()); + break; + } +} + +void SendProfTrainerMenu_guard_shattrath_aldor(Player *player, Creature *_Creature, uint32 action) +{ + switch (action) + { + case GOSSIP_ACTION_INFO_DEF + 1: //Alchemy + player->SEND_POI(-1648.5, 5534, 6, 6, 0, "Lorokeem"); + player->SEND_GOSSIP_MENU(10392, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 2: //Blacksmithing + player->SEND_POI(-1847, 5222, 6, 6, 0, "Kradu Grimblade and Zula Slagfury"); + player->SEND_GOSSIP_MENU(10400, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 3: //Cooking + player->SEND_POI(-2067.4, 5316.5, 6, 6, 0, "Jack Trapper"); + player->SEND_GOSSIP_MENU(10393, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 4: //Enchanting + player->SEND_POI(-2263.5, 5563.5, 6, 6, 0, "High Enchanter Bardolan"); + player->SEND_GOSSIP_MENU(10528, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 5: //First Aid + player->SEND_POI(-1591, 5265.5, 6, 6, 0, "Mildred Fletcher"); + player->SEND_GOSSIP_MENU(10396, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 6: //Jewelcrafting + player->SEND_POI(-1654, 5667.5, 6, 6, 0, "Hamanar"); + player->SEND_GOSSIP_MENU(10529, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 7: //Leatherworking + player->SEND_POI(-2060.5, 5256.5, 6, 6, 0, "Darmari"); + player->SEND_GOSSIP_MENU(10399, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 8: //Skinning + player->SEND_POI(-2048, 5300, 6, 6, 0, "Seymour"); + player->SEND_GOSSIP_MENU(10419, _Creature->GetGUID()); + break; + } +} + +bool GossipSelect_guard_shattrath_aldor(Player *player, Creature *_Creature, uint32 sender, uint32 action ) +{ + switch (sender) + { + case GOSSIP_SENDER_MAIN: SendDefaultMenu_guard_shattrath_aldor(player, _Creature, action); break; + case GOSSIP_SENDER_SEC_PROFTRAIN: SendProfTrainerMenu_guard_shattrath_aldor(player, _Creature, action); break; + case GOSSIP_SENDER_SEC_BATTLEINFO: SendBattleMasterMenu_guard_shattrath(player, _Creature, action); break; + } + return true; +} + +/******************************************************* + * guard_shattrath_aldor end + *******************************************************/ + +CreatureAI* GetAI_guard_shattrath_aldor(Creature *_Creature) +{ + return new guard_shattrath_aldorAI (_Creature); +} + +/******************************************************* + * guard_shattrath_scryer + *******************************************************/ + +struct MANGOS_DLL_DECL guard_shattrath_scryerAI : public guardAI +{ + guard_shattrath_scryerAI(Creature *c) : guardAI(c) { Reset(); } + + uint32 Exile_Timer; + uint32 Banish_Timer; + uint64 playerGUID; + bool CanTeleport; + + void Reset() + { + Banish_Timer = 5000; + Exile_Timer = 8500; + playerGUID = 0; + CanTeleport = false; + } + + void Aggro(Unit *who) {} + + void UpdateAI(const uint32 diff) + { + if(!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + if( CanTeleport ) + { + if( Exile_Timer < diff ) + { + if( Unit* temp = Unit::GetUnit(*m_creature,playerGUID) ) + { + temp->CastSpell(temp,SPELL_EXILE,true); + temp->CastSpell(temp,SPELL_BANISH_TELEPORT,true); + } + playerGUID = 0; + Exile_Timer = 8500; + CanTeleport = false; + }else Exile_Timer -= diff; + } + else if( Banish_Timer < diff ) + { + Unit* temp = m_creature->getVictim(); + if( temp && temp->GetTypeId() == TYPEID_PLAYER ) + { + DoCast(temp,SPELL_BANISHED_SHATTRATH_S); + Banish_Timer = 9000; + playerGUID = temp->GetGUID(); + if( playerGUID ) + CanTeleport = true; + } + }else Banish_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; + +bool GossipHello_guard_shattrath_scryer(Player *player, Creature *_Creature) +{ + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_TAVERN , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_BANK , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_INN , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 3); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_FLIGHTMASTER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 4); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_MAILBOX , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 5); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_STABLEMASTER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 6); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_BATTLEMASTER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 7); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_PROFTRAINER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 8); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_MANALOOM , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 9); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ALCHEMYLAB , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 10); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_GEMMERCHANT , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 11); + player->SEND_GOSSIP_MENU(10430, _Creature->GetGUID()); + return true; +} + +void SendDefaultMenu_guard_shattrath_scryer(Player *player, Creature *_Creature, uint32 action) +{ + switch (action) + { + case GOSSIP_ACTION_INFO_DEF + 1: //Tavern + player->SEND_POI(-1759.5, 5165, 6, 6, 0, "Worlds End Tavern"); + player->SEND_GOSSIP_MENU(10431, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 2: //Bank + player->SEND_POI(-1996.6, 5363.7, 6, 6, 0, "Scryer Bank"); + player->SEND_GOSSIP_MENU(10432, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 3: //Inn + player->SEND_POI(-2176.6, 5405.8, 6, 6, 0, "Scryer Inn"); + player->SEND_GOSSIP_MENU(10433, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 4: //Flight master + player->SEND_POI(-1832, 5299, 6, 6, 0, "Shattrath Flight Master"); + player->SEND_GOSSIP_MENU(10435, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 5: //Mailbox + player->SEND_POI(-2174.3, 5411.4, 6, 6, 0, "Scryer Mailbox"); + player->SEND_GOSSIP_MENU(10436, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 6: //Stable master + player->SEND_POI(-2169.9, 5405.1, 6, 6, 0, "Scryer Stable Master"); + player->SEND_GOSSIP_MENU(10437, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 7: //Battlemaster + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_BATTLEMASTERALLIANCE , GOSSIP_SENDER_SEC_BATTLEINFO, GOSSIP_ACTION_INFO_DEF + 1); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_BATTLEMASTERHORDE , GOSSIP_SENDER_SEC_BATTLEINFO, GOSSIP_ACTION_INFO_DEF + 2); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_BATTLEMASTERARENA , GOSSIP_SENDER_SEC_BATTLEINFO, GOSSIP_ACTION_INFO_DEF + 3); + player->SEND_GOSSIP_MENU(10438, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 8: //Profession master + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ALCHEMY , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 1); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_BLACKSMITHING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 2); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_COOKING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 3); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ENCHANTING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 4); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_FIRSTAID , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 5); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_JEWELCRAFTING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 6); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_LEATHERWORKING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 7); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_SKINNING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 8); + player->SEND_GOSSIP_MENU(10504, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 9: //Mana Loom + player->SEND_POI(-2070, 5265.5, 6, 6, 0, "Mana Loom"); + player->SEND_GOSSIP_MENU(10522, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 10: //Alchemy Lab + player->SEND_POI(-1648.5, 5540, 6, 6, 0, "Alchemy Lab"); + player->SEND_GOSSIP_MENU(10701, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 11: //Gem Merchant + player->SEND_POI(-1645, 5669.5, 6, 6, 0, "Scryer Gem Merchant"); + player->SEND_GOSSIP_MENU(10702, _Creature->GetGUID()); + break; + } +} + +void SendProfTrainerMenu_guard_shattrath_scryer(Player *player, Creature *_Creature, uint32 action) +{ + switch (action) + { + case GOSSIP_ACTION_INFO_DEF + 1: //Alchemy + player->SEND_POI(-1648.5, 5534, 6, 6, 0, "Lorokeem"); + player->SEND_GOSSIP_MENU(10516, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 2: //Blacksmithing + player->SEND_POI(-1847, 5222, 6, 6, 0, "Kradu Grimblade and Zula Slagfury"); + player->SEND_GOSSIP_MENU(10517, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 3: //Cooking + player->SEND_POI(-2067.4, 5316.5, 6, 6, 0, "Jack Trapper"); + player->SEND_GOSSIP_MENU(10518, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 4: //Enchanting + player->SEND_POI(-2263.5, 5563.5, 6, 6, 0, "High Enchanter Bardolan"); + player->SEND_GOSSIP_MENU(10519, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 5: //First Aid + player->SEND_POI(-1591, 5265.5, 6, 6, 0, "Mildred Fletcher"); + player->SEND_GOSSIP_MENU(10520, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 6: //Jewelcrafting + player->SEND_POI(-1654, 5667.5, 6, 6, 0, "Hamanar"); + player->SEND_GOSSIP_MENU(10521, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 7: //Leatherworking + player->SEND_POI(-2060.5, 5256.5, 6, 6, 0, "Darmari"); + player->SEND_GOSSIP_MENU(10523, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 8: //Skinning + player->SEND_POI(-2048, 5300, 6, 6, 0, "Seymour"); + player->SEND_GOSSIP_MENU(10523, _Creature->GetGUID()); + break; + } +} + +bool GossipSelect_guard_shattrath_scryer(Player *player, Creature *_Creature, uint32 sender, uint32 action ) +{ + switch (sender) + { + case GOSSIP_SENDER_MAIN: SendDefaultMenu_guard_shattrath_scryer(player, _Creature, action); break; + case GOSSIP_SENDER_SEC_PROFTRAIN: SendProfTrainerMenu_guard_shattrath_scryer(player, _Creature, action); break; + case GOSSIP_SENDER_SEC_BATTLEINFO: SendBattleMasterMenu_guard_shattrath(player, _Creature, action); break; + } + return true; +} + +/******************************************************* + * guard_shattrath_scryer end + *******************************************************/ + +CreatureAI* GetAI_guard_shattrath_scryer(Creature *_Creature) +{ + return new guard_shattrath_scryerAI (_Creature); +} + +/******************************************************* + * guard_silvermoon start + *******************************************************/ + +bool GossipHello_guard_silvermoon(Player *player, Creature *_Creature) +{ + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_AUCTIONHOUSE , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_BANK , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_GUILDMASTER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 3); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_INN , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 4); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_MAILBOX , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 5); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_STABLEMASTER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 6); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_WEAPONMASTER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 7); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_WINDRIDER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 8); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_BATTLEMASTER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 9); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_CLASSTRAINER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 10); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_PROFTRAINER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 11); + player->SEND_GOSSIP_MENU(9316, _Creature->GetGUID()); + return true; +} + +void SendDefaultMenu_guard_silvermoon(Player *player, Creature *_Creature, uint32 action) +{ + switch (action) + { + case GOSSIP_ACTION_INFO_DEF + 1: //Auction house + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_AH_SILVERMOON_1 , GOSSIP_SENDER_SEC_AUCTIONHOUSE, GOSSIP_ACTION_INFO_DEF + 1); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_AH_SILVERMOON_2 , GOSSIP_SENDER_SEC_AUCTIONHOUSE, GOSSIP_ACTION_INFO_DEF + 2); + player->SEND_GOSSIP_MENU(9317, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 2: //Bank + player->SEND_POI(9808.4, -7488.16, 6, 6, 0, "Silvermoon Bank"); + player->SEND_GOSSIP_MENU(9322, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 3: //Guild master + player->SEND_POI(9474.97, -7345.21, 6, 6, 0, "Tandrine"); + player->SEND_GOSSIP_MENU(9324, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 4: //Inn + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_INN_SILVERMOON_1 , GOSSIP_SENDER_SEC_INN, GOSSIP_ACTION_INFO_DEF + 1); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_INN_SILVERMOON_2 , GOSSIP_SENDER_SEC_INN, GOSSIP_ACTION_INFO_DEF + 2); + player->SEND_GOSSIP_MENU(9602, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 5: //Mailbox + player->SEND_POI(9658.33, -7492.17, 6, 6, 0, "Silvermoon Mailbox"); + player->SEND_GOSSIP_MENU(9326, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 6: //Stable master + player->SEND_POI(9904.95, -7404.31, 6, 6, 0, "Shalenn"); + player->SEND_GOSSIP_MENU(9327, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 7: //Weapon trainer + player->SEND_POI(9841.17, -7505.13, 6, 6, 0, "Ileda"); + player->SEND_GOSSIP_MENU(9328, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 8: //Wind master + player->SEND_POI(9378.45, -7163.94, 6, 6, 0, "Silvermoon Wind Master"); + player->SEND_GOSSIP_MENU(10181, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 9: //Battlemaster + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ALTERACVALLEY , GOSSIP_SENDER_SEC_BATTLEINFO, GOSSIP_ACTION_INFO_DEF + 1); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ARATHIBASIN , GOSSIP_SENDER_SEC_BATTLEINFO, GOSSIP_ACTION_INFO_DEF + 2); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ARENA , GOSSIP_SENDER_SEC_BATTLEINFO, GOSSIP_ACTION_INFO_DEF + 3); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_EYEOFTHESTORM , GOSSIP_SENDER_SEC_BATTLEINFO, GOSSIP_ACTION_INFO_DEF + 4); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_WARSONGULCH , GOSSIP_SENDER_SEC_BATTLEINFO, GOSSIP_ACTION_INFO_DEF + 5); + player->SEND_GOSSIP_MENU(9329, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 10: //Class trainer + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_DRUID , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 1); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_HUNTER , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 2); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_MAGE , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 3); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_PALADIN , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 4); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_PRIEST , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 5); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ROGUE , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 6); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_WARLOCK , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 7); + player->SEND_GOSSIP_MENU(9331, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 11: //Profession trainer + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ALCHEMY , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 1); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_BLACKSMITHING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 2); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_COOKING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 3); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ENCHANTING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 4); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ENGINEERING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 5); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_FIRSTAID , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 6); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_FISHING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 7); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_JEWELCRAFTING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 8); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_HERBALISM , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 9); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_LEATHERWORKING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 10); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_MINING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 11); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_SKINNING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 12); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_TAILORING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 13); + player->SEND_GOSSIP_MENU(9338, _Creature->GetGUID()); + break; + } +} + +void SendAuctionhouseMenu_guard_silvermoon(Player *player, Creature *_Creature, uint32 action) +{ + if (action == GOSSIP_ACTION_INFO_DEF + 1) + { + player->SEND_POI(9644.47, -7140.22, 6, 6, 0, "Western Auction House"); + player->SEND_GOSSIP_MENU(9318, _Creature->GetGUID()); + } + if (action == GOSSIP_ACTION_INFO_DEF + 2) + { + player->SEND_POI(9683.27, -7521.22, 6, 6, 0, "Royal Exchange Auction House"); + player->SEND_GOSSIP_MENU(9319, _Creature->GetGUID()); + } +} + +void SendInnMenu_guard_silvermoon(Player *player, Creature *_Creature, uint32 action) +{ + if (action == GOSSIP_ACTION_INFO_DEF + 1) + { + player->SEND_POI(9677.7, -7368, 6, 6, 0, "Silvermoon City Inn"); + player->SEND_GOSSIP_MENU(9325, _Creature->GetGUID()); + } + if (action == GOSSIP_ACTION_INFO_DEF + 2) + { + player->SEND_POI(9561.1, -7517.5, 6, 6, 0, "Wayfarer's Rest tavern"); + player->SEND_GOSSIP_MENU(9603, _Creature->GetGUID()); + } +} + +void SendBattleMasterMenu_guard_silvermoon(Player *player, Creature *_Creature, uint32 action) +{ + switch (action) + { + case GOSSIP_ACTION_INFO_DEF + 1: //AV + player->SEND_POI(9850.49, -7572.26, 6, 6, 0, "Gurak"); + player->SEND_GOSSIP_MENU(9329, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 2: //AB + player->SEND_POI(9857.18, -7564.36, 6, 6, 0, "Karen Wentworth"); + player->SEND_GOSSIP_MENU(9329, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 3: //A + player->SEND_POI(9850.6, -7559.25, 6, 6, 0, "Bipp Glizzitor"); + player->SEND_GOSSIP_MENU(9329, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 4: //EOS + player->SEND_POI(9857.18, -7564.36, 6, 6, 0, "Karen Wentworth"); + player->SEND_GOSSIP_MENU(9329, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 5: //WSG + player->SEND_POI(9845.45, -7562.58, 6, 6, 0, "Krukk"); + player->SEND_GOSSIP_MENU(9329, _Creature->GetGUID()); + break; + } +} + +void SendClassTrainerMenu_guard_silvermoon(Player *player, Creature *_Creature, uint32 action) +{ + switch (action) + { + case GOSSIP_ACTION_INFO_DEF + 1: //Druid + player->SEND_POI(9700.55, -7262.57, 6, 6, 0, "Harene Plainwalker"); + player->SEND_GOSSIP_MENU(9330, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 2: //Hunter + player->SEND_POI(9927.48, -7426.14, 6, 6, 0, "Zandine"); + player->SEND_GOSSIP_MENU(9332, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 3: //Mage + player->SEND_POI(9995.07, -7118.17, 6, 6, 0, "Quithas"); + player->SEND_GOSSIP_MENU(9333, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 4: //Paladin + player->SEND_POI(9850.22, -7516.93, 6, 6, 0, "Champion Bachi"); + player->SEND_GOSSIP_MENU(9334, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 5: //Priest + player->SEND_POI(9926.79, -7066.66, 6, 6, 0, "Belestra"); + player->SEND_GOSSIP_MENU(9335, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 6: //Rogue + player->SEND_POI(9739.88, -7374.33, 6, 6, 0, "Zelanis"); + player->SEND_GOSSIP_MENU(9336, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 7: //Warlock + player->SEND_POI(9787.57, -7284.63, 6, 6, 0, "Alamma"); + player->SEND_GOSSIP_MENU(9337, _Creature->GetGUID()); + break; + } +} + +void SendProfTrainerMenu_guard_silvermoon(Player *player, Creature *_Creature, uint32 action) +{ + switch (action) + { + case GOSSIP_ACTION_INFO_DEF + 1: //Alchemy + player->SEND_POI(9998.09, -7214.36, 6, 6, 0, "Silvermoon Alchemy Trainer"); + player->SEND_GOSSIP_MENU(9316, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 2: //Blacksmithing + player->SEND_POI(9841.43, -7361.53, 6, 6, 0, "Silvermoon Blacksmithing Trainer"); + player->SEND_GOSSIP_MENU(9340, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 3: //Cooking + player->SEND_POI(9577.26, -7243.6, 6, 6, 0, "Silvermoon Cooking Trainer"); + player->SEND_GOSSIP_MENU(9316, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 4: //Enchanting + player->SEND_POI(9962.57, -7246.18, 6, 6, 0, "Silvermoon Enchanting Trainer"); + player->SEND_GOSSIP_MENU(9341, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 5: //Engineering + player->SEND_POI(9820.18, -7329.56, 6, 6, 0, "Silvermoon Engineering Trainer"); + player->SEND_GOSSIP_MENU(9316, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 6: //First Aid + player->SEND_POI(9579.8, -7343.71, 6, 6, 0, "Silvermoon First Aid Trainer"); + player->SEND_GOSSIP_MENU(9316, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 7: //Fishing + player->SEND_POI(9602.73, -7328.3, 6, 6, 0, "Silvermoon Fishing Trainer"); + player->SEND_GOSSIP_MENU(9316, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 8: //Jewelcrafting + player->SEND_POI(9553.54, -7506.43, 6, 6, 0, "Silvermoon Jewelcrafting Trainer"); + player->SEND_GOSSIP_MENU(9346, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 9: //Herbalism + player->SEND_POI(10004.4, -7216.86, 6, 6, 0, "Silvermoon Herbalism Trainer"); + player->SEND_GOSSIP_MENU(9316, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 10: //Leatherworking + player->SEND_POI(9503.72, -7430.16, 6, 6, 0, "Silvermoon Leatherworking Trainer"); + player->SEND_GOSSIP_MENU(9347, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 11: //Mining + player->SEND_POI(9805.1, -7355.56, 6, 6, 0, "Silvermoon Mining Trainer"); + player->SEND_GOSSIP_MENU(9348, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 12: //Skinning + player->SEND_POI(9513.37, -7429.4, 6, 6, 0, "Silvermoon Skinning Trainer"); + player->SEND_GOSSIP_MENU(9316, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 13: //Tailoring + player->SEND_POI(9750.55, -7095.28, 6, 6, 0, "Silvermoon Tailor"); + player->SEND_GOSSIP_MENU(9350, _Creature->GetGUID()); + break; + } +} + +bool GossipSelect_guard_silvermoon(Player *player, Creature *_Creature, uint32 sender, uint32 action ) +{ + switch (sender) + { + case GOSSIP_SENDER_MAIN: SendDefaultMenu_guard_silvermoon(player, _Creature, action); break; + case GOSSIP_SENDER_SEC_AUCTIONHOUSE: SendAuctionhouseMenu_guard_silvermoon(player, _Creature, action); break; + case GOSSIP_SENDER_SEC_INN: SendInnMenu_guard_silvermoon(player, _Creature, action); break; + case GOSSIP_SENDER_SEC_CLASSTRAIN: SendClassTrainerMenu_guard_silvermoon(player, _Creature, action); break; + case GOSSIP_SENDER_SEC_PROFTRAIN: SendProfTrainerMenu_guard_silvermoon(player, _Creature, action); break; + case GOSSIP_SENDER_SEC_BATTLEINFO: SendBattleMasterMenu_guard_silvermoon(player, _Creature, action); break; + } + return true; +} + +/******************************************************* + * guard_silvermoon end + *******************************************************/ + +CreatureAI* GetAI_guard_silvermoon(Creature *_Creature) +{ + return new guardAI (_Creature); +} + +/******************************************************* + * guard_stormwind start + *******************************************************/ + +bool GossipHello_guard_stormwind(Player *player, Creature *_Creature) +{ + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_AUCTIONHOUSE , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_STORMWIND_BANK , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_DEEPRUNTRAM , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 3); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_INN , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 4); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_GRYPHON , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 5); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_GUILDMASTER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 6); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_MAILBOX , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 7); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_STABLEMASTER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 8); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_WEAPONMASTER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 9); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_OFFICERS , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 10); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_BATTLEMASTER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 11); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_CLASSTRAINER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 12); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_PROFTRAINER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 13); + player->SEND_GOSSIP_MENU(933,_Creature->GetGUID()); + return true; +} + +void SendDefaultMenu_guard_stormwind(Player *player, Creature *_Creature, uint32 action) +{ + switch (action) + { + case GOSSIP_ACTION_INFO_DEF + 1: //Auction House + player->SEND_POI(-8811.46, 667.46, 6, 6, 0, "Stormwind Auction House"); + player->SEND_GOSSIP_MENU(3834,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 2: //Bank + player->SEND_POI(-8916.87, 622.87, 6, 6, 0, "Stormwind Bank"); + player->SEND_GOSSIP_MENU(764,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 3: //Deeprun tram + player->SEND_POI(-8378.88, 554.23, 6, 6, 0, "The Deeprun Tram"); + player->SEND_GOSSIP_MENU(3813,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 4: //Inn + player->SEND_POI(-8869.0, 675.4, 6, 6, 0, "The Gilded Rose"); + player->SEND_GOSSIP_MENU(3860,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 5: //Gryphon Master + player->SEND_POI(-8837.0, 493.5, 6, 6, 0, "Stormwind Gryphon Master"); + player->SEND_GOSSIP_MENU(879,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 6: //Guild Master + player->SEND_POI(-8894.0, 611.2, 6, 6, 0, "Stormwind Vistor`s Center"); + player->SEND_GOSSIP_MENU(882,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 7: //Mailbox + player->SEND_POI(-8876.48, 649.18, 6, 6, 0, "Stormwind Mailbox"); + player->SEND_GOSSIP_MENU(3861,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 8: //Stable Master + player->SEND_POI(-8433.0, 554.7, 6, 6, 0, "Jenova Stoneshield"); + player->SEND_GOSSIP_MENU(5984,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 9: //Weapon Trainer + player->SEND_POI(-8797.0, 612.8, 6, 6, 0, "Woo Ping"); + player->SEND_GOSSIP_MENU(4516,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 10: //Officers Lounge + player->SEND_POI(-8759.92, 399.69, 6, 6, 0, "Champions` Hall"); + player->SEND_GOSSIP_MENU(7047,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 11: //Battlemasters + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ALTERACVALLEY , GOSSIP_SENDER_SEC_BATTLEINFO, GOSSIP_ACTION_INFO_DEF + 1); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ARATHIBASIN , GOSSIP_SENDER_SEC_BATTLEINFO, GOSSIP_ACTION_INFO_DEF + 2); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_WARSONGULCH , GOSSIP_SENDER_SEC_BATTLEINFO, GOSSIP_ACTION_INFO_DEF + 3); + player->SEND_GOSSIP_MENU(7499,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 12: //Class trainers + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_MAGE , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 1); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ROGUE , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 2); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_WARRIOR , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 3); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_DRUID , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 4); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_PRIEST , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 5); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_PALADIN , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 6); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_HUNTER , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 7); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_WARLOCK , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 8); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_SHAMAN , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 9); + player->SEND_GOSSIP_MENU(898,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 13: //Profession trainers + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ALCHEMY , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 1); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_BLACKSMITHING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 2); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_COOKING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 3); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ENCHANTING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 4); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ENGINEERING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 5); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_FIRSTAID , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 6); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_FISHING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 7); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_HERBALISM , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 8); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_LEATHERWORKING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 9); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_MINING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 10); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_SKINNING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 11); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_TAILORING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 12); + player->SEND_GOSSIP_MENU(918,_Creature->GetGUID()); + break; + } +} + +void SendBattleMasterMenu_guard_stormwind(Player *player, Creature *_Creature, uint32 action) +{ + switch (action) + { + case GOSSIP_ACTION_INFO_DEF + 1: //AV + player->SEND_POI(-8443.88, 335.99, 6, 6, 0, "Thelman Slatefist"); + player->SEND_GOSSIP_MENU(7500, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 2: //AB + player->SEND_POI(-8443.88, 335.99, 6, 6, 0, "Lady Hoteshem"); + player->SEND_GOSSIP_MENU(7650, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 3: //WSG + player->SEND_POI(-8443.88, 335.99, 6, 6, 0, "Elfarran"); + player->SEND_GOSSIP_MENU(7501, _Creature->GetGUID()); + break; + } +} + +void SendClassTrainerMenu_guard_stormwind(Player *player, Creature *_Creature, uint32 action) +{ + switch (action) + { + case GOSSIP_ACTION_INFO_DEF + 1: //Mage + player->SEND_POI(-9012.0, 867.6, 6, 6, 0, "Wizard`s Sanctum"); + player->SEND_GOSSIP_MENU(899,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 2: //Rogue + player->SEND_POI(-8753.0, 367.8, 6, 6, 0, "Stormwind - Rogue House"); + player->SEND_GOSSIP_MENU(900,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 3: //Warrior + player->SEND_POI(-8624.54, 402.61, 6, 6, 0, "Pig and Whistle Tavern"); + player->SEND_GOSSIP_MENU(901,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 4: //Druid + player->SEND_POI(-8751.0, 1124.5, 6, 6, 0, "The Park"); + player->SEND_GOSSIP_MENU(902,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 5: //Priest + player->SEND_POI(-8512.0, 862.4, 6, 6, 0, "Catedral Of Light"); + player->SEND_GOSSIP_MENU(903,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 6: //Paladin + player->SEND_POI(-8577.0, 881.7, 6, 6, 0, "Catedral Of Light"); + player->SEND_GOSSIP_MENU(904,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 7: //Hunter + player->SEND_POI(-8413.0, 541.5, 6, 6, 0, "Hunter Lodge"); + player->SEND_GOSSIP_MENU(905,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 8: //Warlock + player->SEND_POI(-8948.91, 998.35, 6, 6, 0, "The Slaughtered Lamb"); + player->SEND_GOSSIP_MENU(906,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 9: //Shaman + player->SEND_POI(-9033, 550, 6, 6, 0, "Valley Of Heroes"); + //incorrect id + player->SEND_GOSSIP_MENU(2593,_Creature->GetGUID()); + break; + } +} + +void SendProfTrainerMenu_guard_stormwind(Player *player, Creature *_Creature, uint32 action) +{ + switch (action) + { + case GOSSIP_ACTION_INFO_DEF + 1: //Alchemy + player->SEND_POI(-8988.0, 759.60, 6, 6, 0, "Alchemy Needs"); + player->SEND_GOSSIP_MENU(919,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 2: //Blacksmithing + player->SEND_POI(-8424.0, 616.9, 6, 6, 0, "Therum Deepforge"); + player->SEND_GOSSIP_MENU(920,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 3: //Cooking + player->SEND_POI(-8611.0, 364.6, 6, 6, 0, "Pig and Whistle Tavern"); + player->SEND_GOSSIP_MENU(921,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 4: //Enchanting + player->SEND_POI(-8858.0, 803.7, 6, 6, 0, "Lucan Cordell"); + player->SEND_GOSSIP_MENU(941,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 5: //Engineering + player->SEND_POI(-8347.0, 644.1, 6, 6, 0, "Lilliam Sparkspindle"); + player->SEND_GOSSIP_MENU(922,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 6: //First Aid + player->SEND_POI(-8513.0, 801.8, 6, 6, 0, "Shaina Fuller"); + player->SEND_GOSSIP_MENU(923,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 7: //Fishing + player->SEND_POI(-8803.0, 767.5, 6, 6, 0, "Arnold Leland"); + player->SEND_GOSSIP_MENU(940,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 8: //Herbalism + player->SEND_POI(-8967.0, 779.5, 6, 6, 0, "Alchemy Needs"); + player->SEND_GOSSIP_MENU(924,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 9: //Leatherworking + player->SEND_POI(-8726.0, 477.4, 6, 6, 0, "The Protective Hide"); + player->SEND_GOSSIP_MENU(925,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 10: //Mining + player->SEND_POI(-8434.0, 692.8, 6, 6, 0, "Gelman Stonehand"); + player->SEND_GOSSIP_MENU(927,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 11: //Skinning + player->SEND_POI(-8716.0, 469.4, 6, 6, 0, "The Protective Hide"); + player->SEND_GOSSIP_MENU(928,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 12: //Tailoring + player->SEND_POI(-8938.0, 800.7, 6, 6, 0, "Duncan`s Textiles"); + player->SEND_GOSSIP_MENU(929,_Creature->GetGUID()); + break; + } +} + +bool GossipSelect_guard_stormwind(Player *player, Creature *_Creature, uint32 sender, uint32 action ) +{ + switch (sender) + { + case GOSSIP_SENDER_MAIN: SendDefaultMenu_guard_stormwind(player, _Creature, action); break; + case GOSSIP_SENDER_SEC_CLASSTRAIN: SendClassTrainerMenu_guard_stormwind(player, _Creature, action); break; + case GOSSIP_SENDER_SEC_PROFTRAIN: SendProfTrainerMenu_guard_stormwind(player, _Creature, action); break; + case GOSSIP_SENDER_SEC_BATTLEINFO: SendBattleMasterMenu_guard_stormwind(player, _Creature, action); break; + } + return true; +} + +bool ReceiveEmote_guard_stormwind(Player *player, Creature *_Creature, uint32 emote) +{ + if( player->GetTeam() == ALLIANCE ) + DoReplyToTextEmote(_Creature,emote); + return true; +} + +/******************************************************* + * guard_stormwind end + *******************************************************/ + +CreatureAI* GetAI_guard_stormwind(Creature *_Creature) +{ + return new guardAI (_Creature); +} + +/******************************************************* + * guard_teldrassil start + *******************************************************/ + +bool GossipHello_guard_teldrassil(Player *player, Creature *_Creature) +{ + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_BANK , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_FERRY , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_GUILDMASTER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 3); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_INN , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 4); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_STABLEMASTER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 5); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_CLASSTRAINER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 6); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_PROFTRAINER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 7); + player->SEND_GOSSIP_MENU(4316,_Creature->GetGUID()); + return true; +} + +void SendDefaultMenu_guard_teldrassil(Player *player, Creature *_Creature, uint32 action) +{ + switch (action) + { + case GOSSIP_ACTION_INFO_DEF + 1: //Bank + player->SEND_GOSSIP_MENU(4317,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 2: //Rut`theran + player->SEND_GOSSIP_MENU(4318,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 3: //Guild master + player->SEND_GOSSIP_MENU(4319,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 4: //Inn + player->SEND_POI(9821.49, 960.13, 6, 6, 0, "Dolanaar Inn"); + player->SEND_GOSSIP_MENU(4320,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 5: //stable master + player->SEND_POI(9808.37, 931.1, 6, 6, 0, "Seriadne"); + player->SEND_GOSSIP_MENU(5982,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 6: //class trainer + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_DRUID , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 1); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_HUNTER , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 2); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_PRIEST , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 3); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ROGUE , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 4); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_WARRIOR , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 5); + player->SEND_GOSSIP_MENU(4264,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 7: //profession trainer + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ALCHEMY , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 1); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_COOKING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 2); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ENCHANTING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 3); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_FIRSTAID , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 4); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_FISHING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 5); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_HERBALISM , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 6); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_LEATHERWORKING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 7); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_SKINNING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 8); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_TAILORING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 9); + player->SEND_GOSSIP_MENU(4273,_Creature->GetGUID()); + break; + } +} + +void SendClassTrainerMenu_guard_teldrassil(Player *player, Creature *_Creature, uint32 action) +{ + switch (action) + { + case GOSSIP_ACTION_INFO_DEF + 1: //Druid + player->SEND_POI(9741.58, 963.7, 6, 6, 0, "Kal"); + player->SEND_GOSSIP_MENU(4323,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 2: //Hunter + player->SEND_POI(9815.12, 926.28, 6, 6, 0, "Dazalar"); + player->SEND_GOSSIP_MENU(4324,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 3: //Priest + player->SEND_POI(9906.16, 986.63, 6, 6, 0, "Laurna Morninglight"); + player->SEND_GOSSIP_MENU(4325,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 4: //Rogue + player->SEND_POI(9789, 942.86, 6, 6, 0, "Jannok Breezesong"); + player->SEND_GOSSIP_MENU(4326,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 5: //Warrior + player->SEND_POI(9821.96, 950.61, 6, 6, 0, "Kyra Windblade"); + player->SEND_GOSSIP_MENU(4327,_Creature->GetGUID()); + break; + } +} + +void SendProfTrainerMenu_guard_teldrassil(Player *player, Creature *_Creature, uint32 action) +{ + switch (action) + { + case GOSSIP_ACTION_INFO_DEF + 1: //Alchemy + player->SEND_POI(9767.59, 878.81, 6, 6, 0, "Cyndra Kindwhisper"); + player->SEND_GOSSIP_MENU(4329,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 2: //Cooking + player->SEND_POI(9751.19, 906.13, 6, 6, 0, "Zarrin"); + player->SEND_GOSSIP_MENU(4330,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 3: //Enchanting + player->SEND_POI(10677.59, 1946.56, 6, 6, 0, "Alanna Raveneye"); + player->SEND_GOSSIP_MENU(4331,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 4: //First Aid + player->SEND_POI(9903.12, 999, 6, 6, 0, "Byancie"); + player->SEND_GOSSIP_MENU(4332,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 5: //Fishing + player->SEND_GOSSIP_MENU(4333,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 6: //Herbalism + player->SEND_POI(9773.78, 875.88, 6, 6, 0, "Malorne Bladeleaf"); + player->SEND_GOSSIP_MENU(4334,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 7: //Leatherworking + player->SEND_POI(10152.59, 1681.46, 6, 6, 0, "Nadyia Maneweaver"); + player->SEND_GOSSIP_MENU(4335,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 8: //Skinning + player->SEND_POI(10135.59, 1673.18, 6, 6, 0, "Radnaal Maneweaver"); + player->SEND_GOSSIP_MENU(4336,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 9: //Tailoring + player->SEND_GOSSIP_MENU(4337,_Creature->GetGUID()); + break; + } +} + +bool GossipSelect_guard_teldrassil(Player *player, Creature *_Creature, uint32 sender, uint32 action ) +{ + switch (sender) + { + case GOSSIP_SENDER_MAIN: SendDefaultMenu_guard_teldrassil(player, _Creature, action); break; + case GOSSIP_SENDER_SEC_CLASSTRAIN: SendClassTrainerMenu_guard_teldrassil(player, _Creature, action); break; + case GOSSIP_SENDER_SEC_PROFTRAIN: SendProfTrainerMenu_guard_teldrassil(player, _Creature, action); break; + } + return true; +} + +/******************************************************* + * guard_teldrassil end + *******************************************************/ + +CreatureAI* GetAI_guard_teldrassil(Creature *_Creature) +{ + return new guardAI (_Creature); +} + +/******************************************************* + * guard_tirisfal start + *******************************************************/ + +bool GossipHello_guard_tirisfal(Player *player, Creature *_Creature) +{ + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_BANK , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_BATHANDLER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_INN , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 3); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_STABLEMASTER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 4); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_CLASSTRAINER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 5); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_PROFTRAINER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 6); + player->SEND_GOSSIP_MENU(4097,_Creature->GetGUID()); + return true; +} + +void SendDefaultMenu_guard_tirisfal(Player *player, Creature *_Creature, uint32 action) +{ + switch (action) + { + case GOSSIP_ACTION_INFO_DEF + 1: //Bank + player->SEND_GOSSIP_MENU(4074,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 2: //bat handler + player->SEND_GOSSIP_MENU(4075,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 3: //Inn + player->SEND_POI(2246.68, 241.89, 6, 6, 0, "Gallows` End Tavern"); + player->SEND_GOSSIP_MENU(4076,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 4: //Stable Master + player->SEND_POI(2267.66, 319.32, 6, 6, 0, "Morganus"); + player->SEND_GOSSIP_MENU(5978,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 5: //Class trainer + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_MAGE , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 1); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_PRIEST , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 2); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ROGUE , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 3); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_WARLOCK , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 4); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_WARRIOR , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 5); + player->SEND_GOSSIP_MENU(4292,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 6: //Profession trainer + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ALCHEMY , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 1); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_BLACKSMITHING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 2); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_COOKING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 3); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ENCHANTING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 4); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ENGINEERING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 5); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_FIRSTAID , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 6); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_FISHING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 7); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_HERBALISM , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 8); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_LEATHERWORKING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 9); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_MINING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 10); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_SKINNING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 11); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_TAILORING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 12); + player->SEND_GOSSIP_MENU(4096,_Creature->GetGUID()); + break; + } +} + +void SendClassTrainerMenu_guard_tirisfal(Player *player, Creature *_Creature, uint32 action) +{ + switch (action) + { + case GOSSIP_ACTION_INFO_DEF + 1: //Mage + player->SEND_POI(2259.18, 240.93, 6, 6, 0, "Cain Firesong"); + player->SEND_GOSSIP_MENU(4077,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 2: //Priest + player->SEND_POI(2259.18, 240.93, 6, 6, 0, "Dark Cleric Beryl"); + player->SEND_GOSSIP_MENU(4078,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 3: //Rogue + player->SEND_POI(2259.18, 240.93, 6, 6, 0, "Marion Call"); + player->SEND_GOSSIP_MENU(4079,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 4: //Warlock + player->SEND_POI(2259.18, 240.93, 6, 6, 0, "Rupert Boch"); + player->SEND_GOSSIP_MENU(4080,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 5: //Warrior + player->SEND_POI(2256.48, 240.32, 6, 6, 0, "Austil de Mon"); + player->SEND_GOSSIP_MENU(4081,_Creature->GetGUID()); + break; + } +} + +void SendProfTrainerMenu_guard_tirisfal(Player *player, Creature *_Creature, uint32 action) +{ + switch (action) + { + case GOSSIP_ACTION_INFO_DEF + 1: //Alchemy + player->SEND_POI(2263.25, 344.23, 6, 6, 0, "Carolai Anise"); + player->SEND_GOSSIP_MENU(4082,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 2: //Blacksmithing + player->SEND_GOSSIP_MENU(4083,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 3: //Cooking + player->SEND_GOSSIP_MENU(4084,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 4: //Enchanting + player->SEND_POI(2250.35, 249.12, 6, 6, 0, "Vance Undergloom"); + player->SEND_GOSSIP_MENU(4085,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 5: //Engineering + player->SEND_GOSSIP_MENU(4086,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 6: //First Aid + player->SEND_POI(2246.68, 241.89, 6, 6, 0, "Nurse Neela"); + player->SEND_GOSSIP_MENU(4087,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 7: //Fishing + player->SEND_POI(2292.37, -10.72, 6, 6, 0, "Clyde Kellen"); + player->SEND_GOSSIP_MENU(4088,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 8: //Herbalism + player->SEND_POI(2268.21, 331.69, 6, 6, 0, "Faruza"); + player->SEND_GOSSIP_MENU(4089,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 9: //Leatherworking + player->SEND_POI(2027, 78.72, 6, 6, 0, "Shelene Rhobart"); + player->SEND_GOSSIP_MENU(4090,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 10: //Mining + player->SEND_GOSSIP_MENU(4091,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 11: //Skinning + player->SEND_POI(2027, 78.72, 6, 6, 0, "Rand Rhobart"); + player->SEND_GOSSIP_MENU(4092,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 12: //Tailoring + player->SEND_POI(2160.45, 659.93, 6, 6, 0, "Bowen Brisboise"); + player->SEND_GOSSIP_MENU(4093,_Creature->GetGUID()); + break; + } +} + +bool GossipSelect_guard_tirisfal(Player *player, Creature *_Creature, uint32 sender, uint32 action ) +{ + switch (sender) + { + case GOSSIP_SENDER_MAIN: SendDefaultMenu_guard_tirisfal(player, _Creature, action); break; + case GOSSIP_SENDER_SEC_CLASSTRAIN: SendClassTrainerMenu_guard_tirisfal(player, _Creature, action); break; + case GOSSIP_SENDER_SEC_PROFTRAIN: SendProfTrainerMenu_guard_tirisfal(player, _Creature, action); break; + } + return true; +} + +/******************************************************* + * guard_tirisfal end + *******************************************************/ + +CreatureAI* GetAI_guard_tirisfal(Creature *_Creature) +{ + return new guardAI (_Creature); +} + +/******************************************************* + * guard_undercity start + *******************************************************/ + +bool GossipHello_guard_undercity(Player *player, Creature *_Creature) +{ + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_BANK , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_BATHANDLER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_GUILDMASTER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 3); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_INN , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 4); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_MAILBOX , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 5); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_AUCTIONHOUSE , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 6); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ZEPPLINMASTER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 7); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_WEAPONMASTER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 8); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_STABLEMASTER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 9); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_BATTLEMASTER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 10); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_CLASSTRAINER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 11); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_PROFTRAINER , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 12); + player->SEND_GOSSIP_MENU(3543,_Creature->GetGUID()); + return true; +} + +void SendDefaultMenu_guard_undercity(Player *player, Creature *_Creature, uint32 action) +{ + switch (action) + { + case GOSSIP_ACTION_INFO_DEF + 1: //Bank + player->SEND_POI(1595.64, 232.45, 6, 6, 0, "Undercity Bank"); + player->SEND_GOSSIP_MENU(3514,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 2: //Bat handler + player->SEND_POI(1565.9, 271.43, 6, 6, 0, "Undercity Bat Handler"); + player->SEND_GOSSIP_MENU(3515,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 3: //Guild master + player->SEND_POI(1594.17, 205.57, 6, 6, 0, "Undercity Guild Master"); + player->SEND_GOSSIP_MENU(3516,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 4: //Inn + player->SEND_POI(1639.43, 220.99, 6, 6, 0, "Undercity Inn"); + player->SEND_GOSSIP_MENU(3517,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 5: //Mailbox + player->SEND_POI(1632.68, 219.4, 6, 6, 0, "Undercity Mailbox"); + player->SEND_GOSSIP_MENU(3518,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 6: //Auction House + player->SEND_POI(1647.9, 258.49, 6, 6, 0, "Undercity Auction House"); + player->SEND_GOSSIP_MENU(3519,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 7: //Zeppelin + player->SEND_POI(2059, 274.86, 6, 6, 0, "Undercity Zeppelin"); + player->SEND_GOSSIP_MENU(3520,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 8: //Weapon Master + player->SEND_POI(1670.31, 324.66, 6, 6, 0, "Archibald"); + player->SEND_GOSSIP_MENU(4521,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 9: //Stable master + player->SEND_POI(1634.18, 226.76, 6, 6, 0, "Anya Maulray"); + player->SEND_GOSSIP_MENU(5979,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 10: //Battlemaster + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ALTERACVALLEY , GOSSIP_SENDER_SEC_BATTLEINFO, GOSSIP_ACTION_INFO_DEF + 1); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ARATHIBASIN , GOSSIP_SENDER_SEC_BATTLEINFO, GOSSIP_ACTION_INFO_DEF + 2); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_WARSONGULCH , GOSSIP_SENDER_SEC_BATTLEINFO, GOSSIP_ACTION_INFO_DEF + 3); + player->SEND_GOSSIP_MENU(7527,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 11: //Class trainer + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_MAGE , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 1); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_PRIEST , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 2); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ROGUE , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 3); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_WARLOCK , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 4); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_WARRIOR , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 5); + player->SEND_GOSSIP_MENU(3542,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 12: //Profession trainer + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ALCHEMY , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 1); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_BLACKSMITHING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 2); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_COOKING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 3); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ENCHANTING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 4); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_ENGINEERING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 5); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_FIRSTAID , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 6); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_FISHING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 7); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_HERBALISM , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 8); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_LEATHERWORKING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 9); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_MINING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 10); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_SKINNING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 11); + player->ADD_GOSSIP_ITEM( 0, GOSSIP_TEXT_TAILORING , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 12); + player->SEND_GOSSIP_MENU(3541,_Creature->GetGUID()); + break; + } +} + +void SendBattleMasterMenu_guard_undercity(Player *player, Creature *_Creature, uint32 action) +{ + switch (action) + { + case GOSSIP_ACTION_INFO_DEF + 1: //AV + player->SEND_POI(1329, 333.92, 6, 6, 0, "Grizzle Halfmane"); + player->SEND_GOSSIP_MENU(7525,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 2: //AB + player->SEND_POI(1283.3, 287.16, 6, 6, 0, "Sir Malory Wheeler"); + player->SEND_GOSSIP_MENU(7646,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 3: //WSG + player->SEND_POI(1265, 351.18, 6, 6, 0, "Kurden Bloodclaw"); + player->SEND_GOSSIP_MENU(7526,_Creature->GetGUID()); + break; + } +} + +void SendClassTrainerMenu_guard_undercity(Player *player, Creature *_Creature, uint32 action) +{ + switch (action) + { + case GOSSIP_ACTION_INFO_DEF + 1: //Mage + player->SEND_POI(1781, 53, 6, 6, 0, "Undercity Mage Trainers"); + player->SEND_GOSSIP_MENU(3513,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 2: //Priest + player->SEND_POI(1758.33, 401.5, 6, 6, 0, "Undercity Priest Trainers"); + player->SEND_GOSSIP_MENU(3521,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 3: //Rogue + player->SEND_POI(1418.56, 65, 6, 6, 0, "Undercity Rogue Trainers"); + player->SEND_GOSSIP_MENU(3524,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 4: //Warlock + player->SEND_POI(1780.92, 53.16, 6, 6, 0, "Undercity Warlock Trainers"); + player->SEND_GOSSIP_MENU(3526,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 5: //Warrior + player->SEND_POI(1775.59, 418.19, 6, 6, 0, "Undercity Warrior Trainers"); + player->SEND_GOSSIP_MENU(3527,_Creature->GetGUID()); + break; + } +} + +void SendProfTrainerMenu_guard_undercity(Player *player, Creature *_Creature, uint32 action) +{ + switch (action) + { + case GOSSIP_ACTION_INFO_DEF + 1: //Alchemy + player->SEND_POI(1419.82, 417.19, 6, 6, 0, "The Apothecarium"); + player->SEND_GOSSIP_MENU(3528,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 2: //Blacksmithing + player->SEND_POI(1696, 285, 6, 6, 0, "Undercity Blacksmithing Trainer"); + player->SEND_GOSSIP_MENU(3529,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 3: //Cooking + player->SEND_POI(1596.34, 274.68, 6, 6, 0, "Undercity Cooking Trainer"); + player->SEND_GOSSIP_MENU(3530,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 4: //Enchanting + player->SEND_POI(1488.54, 280.19, 6, 6, 0, "Undercity Enchanting Trainer"); + player->SEND_GOSSIP_MENU(3531,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 5: //Engineering + player->SEND_POI(1408.58, 143.43, 6, 6, 0, "Undercity Engineering Trainer"); + player->SEND_GOSSIP_MENU(3532,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 6: //First Aid + player->SEND_POI(1519.65, 167.19, 6, 6, 0, "Undercity First Aid Trainer"); + player->SEND_GOSSIP_MENU(3533,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 7: //Fishing + player->SEND_POI(1679.9, 89, 6, 6, 0, "Undercity Fishing Trainer"); + player->SEND_GOSSIP_MENU(3534,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 8: //Herbalism + player->SEND_POI(1558, 349.36, 6, 6, 0, "Undercity Herbalism Trainer"); + player->SEND_GOSSIP_MENU(3535,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 9: //Leatherworking + player->SEND_POI(1498.76, 196.43, 6, 6, 0, "Undercity Leatherworking Trainer"); + player->SEND_GOSSIP_MENU(3536,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 10: //Mining + player->SEND_POI(1642.88, 335.58, 6, 6, 0, "Undercity Mining Trainer"); + player->SEND_GOSSIP_MENU(3537,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 11: //Skinning + player->SEND_POI(1498.6, 196.46, 6, 6, 0, "Undercity Skinning Trainer"); + player->SEND_GOSSIP_MENU(3538,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 12: //Tailoring + player->SEND_POI(1689.55, 193, 6, 6, 0, "Undercity Tailoring Trainer"); + player->SEND_GOSSIP_MENU(3539,_Creature->GetGUID()); + break; + } +} + +bool GossipSelect_guard_undercity(Player *player, Creature *_Creature, uint32 sender, uint32 action ) +{ + switch (sender) + { + case GOSSIP_SENDER_MAIN: SendDefaultMenu_guard_undercity(player, _Creature, action); break; + case GOSSIP_SENDER_SEC_CLASSTRAIN: SendClassTrainerMenu_guard_undercity(player, _Creature, action); break; + case GOSSIP_SENDER_SEC_PROFTRAIN: SendProfTrainerMenu_guard_undercity(player, _Creature, action); break; + case GOSSIP_SENDER_SEC_BATTLEINFO: SendBattleMasterMenu_guard_undercity(player, _Creature, action); break; + } + return true; +} + +/******************************************************* + * guard_undercity end + *******************************************************/ + +CreatureAI* GetAI_guard_undercity(Creature *_Creature) +{ + return new guardAI (_Creature); +} + +/******************************************************* + * AddSC + *******************************************************/ + +void AddSC_guards() +{ + Script *newscript; + + newscript = new Script; + newscript->Name="guard_azuremyst"; + newscript->pGossipHello = &GossipHello_guard_azuremyst; + newscript->pGossipSelect = &GossipSelect_guard_azuremyst; + newscript->GetAI = GetAI_guard_azuremyst; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="guard_bluffwatcher"; + newscript->pGossipHello = &GossipHello_guard_bluffwatcher; + newscript->pGossipSelect = &GossipSelect_guard_bluffwatcher; + newscript->GetAI = GetAI_guard_bluffwatcher; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="guard_contested"; + newscript->GetAI = GetAI_guard_contested; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="guard_darnassus"; + newscript->pGossipHello = &GossipHello_guard_darnassus; + newscript->pGossipSelect = &GossipSelect_guard_darnassus; + newscript->GetAI = GetAI_guard_darnassus; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="guard_dunmorogh"; + newscript->pGossipHello = &GossipHello_guard_dunmorogh; + newscript->pGossipSelect = &GossipSelect_guard_dunmorogh; + newscript->GetAI = GetAI_guard_dunmorogh; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="guard_durotar"; + newscript->pGossipHello = &GossipHello_guard_durotar; + newscript->pGossipSelect = &GossipSelect_guard_durotar; + newscript->GetAI = GetAI_guard_durotar; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="guard_elwynnforest"; + newscript->pGossipHello = &GossipHello_guard_elwynnforest; + newscript->pGossipSelect = &GossipSelect_guard_elwynnforest; + newscript->GetAI = GetAI_guard_elwynnforest; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="guard_eversong"; + newscript->pGossipHello = &GossipHello_guard_eversong; + newscript->pGossipSelect = &GossipSelect_guard_eversong; + newscript->GetAI = GetAI_guard_eversong; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="guard_exodar"; + newscript->pGossipHello = &GossipHello_guard_exodar; + newscript->pGossipSelect = &GossipSelect_guard_exodar; + newscript->GetAI = GetAI_guard_exodar; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="guard_ironforge"; + newscript->pGossipHello = &GossipHello_guard_ironforge; + newscript->pGossipSelect = &GossipSelect_guard_ironforge; + newscript->GetAI = GetAI_guard_ironforge; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="guard_mulgore"; + newscript->pGossipHello = &GossipHello_guard_mulgore; + newscript->pGossipSelect = &GossipSelect_guard_mulgore; + newscript->GetAI = GetAI_guard_mulgore; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="guard_orgrimmar"; + newscript->pGossipHello = &GossipHello_guard_orgrimmar; + newscript->pGossipSelect = &GossipSelect_guard_orgrimmar; + newscript->pReceiveEmote = &ReceiveEmote_guard_orgrimmar; + newscript->GetAI = GetAI_guard_orgrimmar; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="guard_shattrath"; + newscript->pGossipHello = &GossipHello_guard_shattrath; + newscript->pGossipSelect = &GossipSelect_guard_shattrath; + newscript->GetAI = GetAI_guard_shattrath; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="guard_shattrath_aldor"; + newscript->GetAI = GetAI_guard_shattrath_aldor; + newscript->pGossipHello = &GossipHello_guard_shattrath_aldor; + newscript->pGossipSelect = &GossipSelect_guard_shattrath_aldor; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="guard_shattrath_scryer"; + newscript->GetAI = GetAI_guard_shattrath_scryer; + newscript->pGossipHello = &GossipHello_guard_shattrath_scryer; + newscript->pGossipSelect = &GossipSelect_guard_shattrath_scryer; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="guard_silvermoon"; + newscript->pGossipHello = &GossipHello_guard_silvermoon; + newscript->pGossipSelect = &GossipSelect_guard_silvermoon; + newscript->GetAI = GetAI_guard_silvermoon; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="guard_stormwind"; + newscript->pGossipHello = &GossipHello_guard_stormwind; + newscript->pGossipSelect = &GossipSelect_guard_stormwind; + newscript->pReceiveEmote = &ReceiveEmote_guard_stormwind; + newscript->GetAI = GetAI_guard_stormwind; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="guard_teldrassil"; + newscript->pGossipHello = &GossipHello_guard_teldrassil; + newscript->pGossipSelect = &GossipSelect_guard_teldrassil; + newscript->GetAI = GetAI_guard_teldrassil; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="guard_tirisfal"; + newscript->pGossipHello = &GossipHello_guard_tirisfal; + newscript->pGossipSelect = &GossipSelect_guard_tirisfal; + newscript->GetAI = GetAI_guard_tirisfal; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="guard_undercity"; + newscript->pGossipHello = &GossipHello_guard_undercity; + newscript->pGossipSelect = &GossipSelect_guard_undercity; + newscript->GetAI = GetAI_guard_undercity; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/item/item_scripts.cpp b/src/bindings/scripts/scripts/item/item_scripts.cpp index 6d2bfe8d852..1b0ecfba27f 100644 --- a/src/bindings/scripts/scripts/item/item_scripts.cpp +++ b/src/bindings/scripts/scripts/item/item_scripts.cpp @@ -1,529 +1,529 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Item_Scripts -SD%Complete: 100 -SDComment: Items for a range of different items. See content below (in script) -SDCategory: Items -EndScriptData */ - -/* ContentData -item_area_52_special(i28132) Prevents abuse of this item -item_attuned_crystal_cores(i34368) Prevent abuse(quest 11524 & 11525) -item_blackwhelp_net(i31129) Quest Whelps of the Wyrmcult (q10747). Prevents abuse -item_draenei_fishing_net(i23654) Hacklike implements chance to spawn item or creature -item_disciplinary_rod Prevents abuse -item_nether_wraith_beacon(i31742) Summons creatures for quest Becoming a Spellfire Tailor (q10832) -item_flying_machine(i34060,i34061) Engineering crafted flying machines -item_gor_dreks_ointment(i30175) Protecting Our Own(q10488) -item_muiseks_vessel Cast on creature, they must be dead(q 3123,3124,3125,3126,3127) -item_protovoltaic_magneto_collector Prevents abuse -item_razorthorn_flayer_gland Quest Discovering Your Roots (q11520) and Rediscovering Your Roots (q11521). Prevents abuse -item_tame_beast_rods(many) Prevent cast on any other creature than the intended (for all tame beast quests) -item_soul_cannon(i32825) Prevents abuse of this item -item_sparrowhawk_net(i32321) Quest To Catch A Sparrowhawk (q10987). Prevents abuse -item_voodoo_charm Provide proper error message and target(q2561) -item_vorenthals_presence(i30259) Prevents abuse of this item -item_yehkinyas_bramble(i10699) Allow cast spell on vale screecher only and remove corpse if cast sucessful (q3520) -item_zezzak_shard(i31463) Quest The eyes of Grillok (q10813). Prevents abuse -EndContentData */ - -#include "precompiled.h" -#include "SpellMgr.h" -#include "Spell.h" -#include "WorldPacket.h" - -/*##### -# item_area_52_special -#####*/ - -bool ItemUse_item_area_52_special(Player *player, Item* _Item, SpellCastTargets const& targets) -{ - if ( player->GetAreaId() == 3803 ) - { - return false; - } - else - { - player->SendEquipError(EQUIP_ERR_OUT_OF_RANGE,_Item,NULL); - return true; - } -} - -/*##### -# item_attuned_crystal_cores -#####*/ - -bool ItemUse_item_attuned_crystal_cores(Player *player, Item* _Item, SpellCastTargets const& targets) -{ - if( targets.getUnitTarget() && targets.getUnitTarget()->GetTypeId()==TYPEID_UNIT && - targets.getUnitTarget()->GetEntry() == 24972 && targets.getUnitTarget()->isDead() ) - return false; - - player->SendEquipError(EQUIP_ERR_CANT_DO_RIGHT_NOW,_Item,NULL); - return true; -} - -/*##### -# item_blackwhelp_net -#####*/ - -bool ItemUse_item_blackwhelp_net(Player *player, Item* _Item, SpellCastTargets const& targets) -{ - if( targets.getUnitTarget() && targets.getUnitTarget()->GetTypeId()==TYPEID_UNIT && - targets.getUnitTarget()->GetEntry() == 21387 ) - return false; - - player->SendEquipError(EQUIP_ERR_YOU_CAN_NEVER_USE_THAT_ITEM,_Item,NULL); - return true; -} - -/*##### -# item_draenei_fishing_net -#####*/ - -//This is just a hack and should be removed from here. -//Creature/Item are in fact created before spell are sucessfully casted, without any checks at all to ensure proper/expected behavior. -bool ItemUse_item_draenei_fishing_net(Player *player, Item* _Item, SpellCastTargets const& targets) -{ - //if( targets.getGOTarget() && targets.getGOTarget()->GetTypeId() == TYPEID_GAMEOBJECT && - //targets.getGOTarget()->GetGOInfo()->type == GAMEOBJECT_TYPE_SPELL_FOCUS && targets.getGOTarget()->GetEntry() == 181616 ) - //{ - if( player->GetQuestStatus(9452) == QUEST_STATUS_INCOMPLETE ) - { - if( rand()%100 < 35 ) - { - Creature *Murloc = player->SummonCreature(17102,player->GetPositionX() ,player->GetPositionY()+20, player->GetPositionZ(), 0,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,10000); - if( Murloc ) - Murloc->AI()->AttackStart(player); - } - else - { - ItemPosCountVec dest; - uint8 msg = player->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, 23614, 1); - if( msg == EQUIP_ERR_OK ) - { - Item* item = player->StoreNewItem(dest,23614,true); - if( item ) - player->SendNewItem(item,1,false,true); - }else - player->SendEquipError(msg,NULL,NULL); - } - } - //} - return false; -} - -/*##### -# item_disciplinary_rod -#####*/ - -bool ItemUse_item_disciplinary_rod(Player *player, Item* _Item, SpellCastTargets const& targets) -{ - if( targets.getUnitTarget() && targets.getUnitTarget()->GetTypeId()==TYPEID_UNIT && - (targets.getUnitTarget()->GetEntry() == 15941 || targets.getUnitTarget()->GetEntry() == 15945) ) - return false; - - player->SendEquipError(EQUIP_ERR_CANT_DO_RIGHT_NOW,_Item,NULL); - return true; -} - -/*##### -# item_nether_wraith_beacon -#####*/ - -bool ItemUse_item_nether_wraith_beacon(Player *player, Item* _Item, SpellCastTargets const& targets) -{ - if (player->GetQuestStatus(10832) == QUEST_STATUS_INCOMPLETE) - { - Creature *Nether; - Nether = player->SummonCreature(22408,player->GetPositionX() ,player->GetPositionY()+20, player->GetPositionZ(), 0,TEMPSUMMON_TIMED_DESPAWN,180000); - Nether = player->SummonCreature(22408,player->GetPositionX() ,player->GetPositionY()-20, player->GetPositionZ(), 0,TEMPSUMMON_TIMED_DESPAWN,180000); - if (Nether) - ((CreatureAI*)Nether->AI())->AttackStart(player); - } - return false; -} - -/*##### -# item_flying_machine -#####*/ - -bool ItemUse_item_flying_machine(Player *player, Item* _Item, SpellCastTargets const& targets) -{ - uint32 itemId = _Item->GetEntry(); - if( itemId == 34060 ) - if( player->GetBaseSkillValue(SKILL_RIDING) >= 225 ) - return false; - - if( itemId == 34061 ) - if( player->GetBaseSkillValue(SKILL_RIDING) == 300 ) - return false; - - debug_log("SD2: Player attempt to use item %u, but did not meet riding requirement",itemId); - player->SendEquipError(EQUIP_ERR_ERR_CANT_EQUIP_SKILL,_Item,NULL); - return true; -} - -/*##### -# item_gor_dreks_ointment -#####*/ - -bool ItemUse_item_gor_dreks_ointment(Player *player, Item* _Item, SpellCastTargets const& targets) -{ - if( targets.getUnitTarget() && targets.getUnitTarget()->GetTypeId()==TYPEID_UNIT && - targets.getUnitTarget()->GetEntry() == 20748 && !targets.getUnitTarget()->HasAura(32578,0) ) - return false; - - player->SendEquipError(EQUIP_ERR_CANT_DO_RIGHT_NOW,_Item,NULL); - return true; -} - -/*##### -# item_muiseks_vessel -#####*/ - -bool ItemUse_item_muiseks_vessel(Player *player, Item* _Item, SpellCastTargets const& targets) -{ - Unit* uTarget = targets.getUnitTarget(); - uint32 itemSpell = _Item->GetProto()->Spells[0].SpellId; - uint32 cEntry = 0; - uint32 cEntry2 = 0; - uint32 cEntry3 = 0; - uint32 cEntry4 = 0; - - if(itemSpell) - { - switch(itemSpell) - { - case 11885: //Wandering Forest Walker - cEntry = 7584; - break; - case 11886: //Owlbeasts - cEntry = 2927; - cEntry2 = 2928; - cEntry3 = 2929; - cEntry4 = 7808; - break; - case 11887: //Freyfeather Hippogryphs - cEntry = 5300; - cEntry2 = 5304; - cEntry3 = 5305; - cEntry4 = 5306; - break; - case 11888: //Sprite Dragon Sprite Darters - cEntry = 5276; - cEntry2 = 5278; - break; - case 11889: //Zapped Land Walker Land Walker Zapped Cliff Giant Cliff Giant - cEntry = 5357; - cEntry2 = 5358; - cEntry3 = 14640; - cEntry4 = 14604; - break; - } - if( uTarget && uTarget->GetTypeId()==TYPEID_UNIT && uTarget->isDead() && - (uTarget->GetEntry()==cEntry || uTarget->GetEntry()==cEntry2 || uTarget->GetEntry()==cEntry3 || uTarget->GetEntry()==cEntry4) ) - { - ((Creature*)uTarget)->RemoveCorpse(); - return false; - } - } - - WorldPacket data(SMSG_CAST_FAILED, (4+2)); // prepare packet error message - data << uint32(_Item->GetEntry()); // itemId - data << uint8(SPELL_FAILED_BAD_TARGETS); // reason - player->GetSession()->SendPacket(&data); // send message: Invalid target - - player->SendEquipError(EQUIP_ERR_NONE,_Item,NULL); // break spell - return true; -} - -/*##### -# item_razorthorn_flayer_gland -#####*/ - -bool ItemUse_item_razorthorn_flayer_gland(Player *player, Item* _Item, SpellCastTargets const& targets) -{ - if( targets.getUnitTarget() && targets.getUnitTarget()->GetTypeId()==TYPEID_UNIT && - targets.getUnitTarget()->GetEntry() == 24922 ) - return false; - - player->SendEquipError(EQUIP_ERR_YOU_CAN_NEVER_USE_THAT_ITEM,_Item,NULL); - return true; -} - -/*##### -# item_tame_beast_rods -#####*/ - -bool ItemUse_item_tame_beast_rods(Player *player, Item* _Item, SpellCastTargets const& targets) -{ - uint32 itemSpell = _Item->GetProto()->Spells[0].SpellId; - uint32 cEntry = 0; - - if(itemSpell) - { - switch(itemSpell) - { - case 19548: cEntry = 1196; break; //Ice Claw Bear - case 19674: cEntry = 1126; break; //Large Crag Boar - case 19687: cEntry = 1201; break; //Snow Leopard - case 19688: cEntry = 2956; break; //Adult Plainstrider - case 19689: cEntry = 2959; break; //Prairie Stalker - case 19692: cEntry = 2970; break; //Swoop - case 19693: cEntry = 1998; break; //Webwood Lurker - case 19694: cEntry = 3099; break; //Dire Mottled Boar - case 19696: cEntry = 3107; break; //Surf Crawler - case 19697: cEntry = 3126; break; //Armored Scorpid - case 19699: cEntry = 2043; break; //Nightsaber Stalker - case 19700: cEntry = 1996; break; //Strigid Screecher - case 30646: cEntry = 17217; break; //Barbed Crawler - case 30653: cEntry = 17374; break; //Greater Timberstrider - case 30654: cEntry = 17203; break; //Nightstalker - case 30099: cEntry = 15650; break; //Crazed Dragonhawk - case 30102: cEntry = 15652; break; //Elder Springpaw - case 30105: cEntry = 16353; break; //Mistbat - } - if( targets.getUnitTarget() && targets.getUnitTarget()->GetTypeId()==TYPEID_UNIT && - targets.getUnitTarget()->GetEntry() == cEntry ) - return false; - } - - WorldPacket data(SMSG_CAST_FAILED, (4+2)); // prepare packet error message - data << uint32(_Item->GetEntry()); // itemId - data << uint8(SPELL_FAILED_BAD_TARGETS); // reason - player->GetSession()->SendPacket(&data); // send message: Invalid target - - player->SendEquipError(EQUIP_ERR_NONE,_Item,NULL); // break spell - return true; -} - -/*##### -# item_protovoltaic_magneto_collector -#####*/ - -bool ItemUse_item_protovoltaic_magneto_collector(Player *player, Item* _Item, SpellCastTargets const& targets) -{ - if( targets.getUnitTarget() && targets.getUnitTarget()->GetTypeId()==TYPEID_UNIT && - targets.getUnitTarget()->GetEntry() == 21729 ) - return false; - - player->SendEquipError(EQUIP_ERR_CANT_DO_RIGHT_NOW,_Item,NULL); - return true; -} - -/*##### -# item_soul_cannon -#####*/ - -bool ItemUse_item_soul_cannon(Player *player, Item* _Item, SpellCastTargets const& targets) -{ - // allow use - if( targets.getUnitTarget() && targets.getUnitTarget()->GetTypeId()==TYPEID_UNIT && - targets.getUnitTarget()->GetEntry() == 22357 ) - return false; - - // error - player->SendEquipError(EQUIP_ERR_YOU_CAN_NEVER_USE_THAT_ITEM,_Item,NULL); - return true; -} - -/*##### -# item_sparrowhawk_net -#####*/ - -bool ItemUse_item_sparrowhawk_net(Player *player, Item* _Item, SpellCastTargets const& targets) -{ - if( targets.getUnitTarget() && targets.getUnitTarget()->GetTypeId()==TYPEID_UNIT && - targets.getUnitTarget()->GetEntry() == 22979 ) - return false; - - player->SendEquipError(EQUIP_ERR_YOU_CAN_NEVER_USE_THAT_ITEM,_Item,NULL); - return true; -} - -/*##### -# item_voodoo_charm -#####*/ - -bool ItemUse_item_voodoo_charm(Player *player, Item* _Item, SpellCastTargets const& targets) -{ - if( targets.getUnitTarget() && targets.getUnitTarget()->GetTypeId()==TYPEID_UNIT && targets.getUnitTarget()->isDead() && - targets.getUnitTarget()->GetEntry()==7318 ) - return false; - - WorldPacket data(SMSG_CAST_FAILED, (4+2)); // prepare packet error message - data << uint32(_Item->GetEntry()); // itemId - data << uint8(SPELL_FAILED_BAD_TARGETS); // reason - player->GetSession()->SendPacket(&data); // send message: Invalid target - - player->SendEquipError(EQUIP_ERR_NONE,_Item,NULL); // break spell - return true; -} - -/*##### -# item_vorenthals_presence -#####*/ - -bool ItemUse_item_vorenthals_presence(Player *player, Item* _Item, SpellCastTargets const& targets) -{ - // allow use - if( targets.getUnitTarget() && targets.getUnitTarget()->GetTypeId()==TYPEID_UNIT && - targets.getUnitTarget()->GetEntry() == 20132 ) - return false; - - // error - player->SendEquipError(EQUIP_ERR_YOU_CAN_NEVER_USE_THAT_ITEM,_Item,NULL); - return true; -} - -/*##### -# item_yehkinyas_bramble -#####*/ - -bool ItemUse_item_yehkinyas_bramble(Player *player, Item* _Item, SpellCastTargets const& targets) -{ - if (player->GetQuestStatus(3520) == QUEST_STATUS_INCOMPLETE) - { - Unit * unit_target = targets.getUnitTarget(); - if( unit_target && - unit_target->GetTypeId()==TYPEID_UNIT && - unit_target->isDead() && - // cast only on corpse 5307 or 5308 - (unit_target->GetEntry()==5307 || unit_target->GetEntry()==5308) ) - { - ((Creature*)unit_target)->RemoveCorpse(); // remove corpse for cancelling second use - return false; // all ok - } - } - WorldPacket data(SMSG_CAST_FAILED, (4+2)); // prepare packet error message - data << uint32(10699); // itemId - data << uint8(SPELL_FAILED_BAD_TARGETS); // reason - player->GetSession()->SendPacket(&data); // send message: Bad target - player->SendEquipError(EQUIP_ERR_NONE,_Item,NULL); // break spell - return true; -} - -/*##### -# item_zezzak_shard -#####*/ - -bool ItemUse_item_zezzak_shard(Player *player, Item* _Item, SpellCastTargets const& targets) -{ - if( targets.getUnitTarget() && targets.getUnitTarget()->GetTypeId()==TYPEID_UNIT && - targets.getUnitTarget()->GetEntry() == 19440 ) - return false; - - player->SendEquipError(EQUIP_ERR_YOU_CAN_NEVER_USE_THAT_ITEM,_Item,NULL); - return true; -} - -void AddSC_item_scripts() -{ - Script *newscript; - - newscript = new Script; - newscript->Name="item_area_52_special"; - newscript->pItemUse = ItemUse_item_area_52_special; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="item_attuned_crystal_cores"; - newscript->pItemUse = ItemUse_item_attuned_crystal_cores; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="item_blackwhelp_net"; - newscript->pItemUse = ItemUse_item_blackwhelp_net; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="item_disciplinary_rod"; - newscript->pItemUse = ItemUse_item_disciplinary_rod; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="item_draenei_fishing_net"; - newscript->pItemUse = ItemUse_item_draenei_fishing_net; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="item_nether_wraith_beacon"; - newscript->pItemUse = ItemUse_item_nether_wraith_beacon; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="item_flying_machine"; - newscript->pItemUse = ItemUse_item_flying_machine; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="item_gor_dreks_ointment"; - newscript->pItemUse = ItemUse_item_gor_dreks_ointment; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="item_muiseks_vessel"; - newscript->pItemUse = ItemUse_item_muiseks_vessel; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="item_razorthorn_flayer_gland"; - newscript->pItemUse = ItemUse_item_razorthorn_flayer_gland; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="item_tame_beast_rods"; - newscript->pItemUse = ItemUse_item_tame_beast_rods; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="item_protovoltaic_magneto_collector"; - newscript->pItemUse = ItemUse_item_protovoltaic_magneto_collector; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="item_soul_cannon"; - newscript->pItemUse = ItemUse_item_soul_cannon; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="item_sparrowhawk_net"; - newscript->pItemUse = ItemUse_item_sparrowhawk_net; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="item_voodoo_charm"; - newscript->pItemUse = ItemUse_item_voodoo_charm; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="item_vorenthals_presence"; - newscript->pItemUse = ItemUse_item_vorenthals_presence; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="item_yehkinyas_bramble"; - newscript->pItemUse = ItemUse_item_yehkinyas_bramble; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="item_zezzaks_shard"; - newscript->pItemUse = ItemUse_item_zezzak_shard; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Item_Scripts +SD%Complete: 100 +SDComment: Items for a range of different items. See content below (in script) +SDCategory: Items +EndScriptData */ + +/* ContentData +item_area_52_special(i28132) Prevents abuse of this item +item_attuned_crystal_cores(i34368) Prevent abuse(quest 11524 & 11525) +item_blackwhelp_net(i31129) Quest Whelps of the Wyrmcult (q10747). Prevents abuse +item_draenei_fishing_net(i23654) Hacklike implements chance to spawn item or creature +item_disciplinary_rod Prevents abuse +item_nether_wraith_beacon(i31742) Summons creatures for quest Becoming a Spellfire Tailor (q10832) +item_flying_machine(i34060,i34061) Engineering crafted flying machines +item_gor_dreks_ointment(i30175) Protecting Our Own(q10488) +item_muiseks_vessel Cast on creature, they must be dead(q 3123,3124,3125,3126,3127) +item_protovoltaic_magneto_collector Prevents abuse +item_razorthorn_flayer_gland Quest Discovering Your Roots (q11520) and Rediscovering Your Roots (q11521). Prevents abuse +item_tame_beast_rods(many) Prevent cast on any other creature than the intended (for all tame beast quests) +item_soul_cannon(i32825) Prevents abuse of this item +item_sparrowhawk_net(i32321) Quest To Catch A Sparrowhawk (q10987). Prevents abuse +item_voodoo_charm Provide proper error message and target(q2561) +item_vorenthals_presence(i30259) Prevents abuse of this item +item_yehkinyas_bramble(i10699) Allow cast spell on vale screecher only and remove corpse if cast sucessful (q3520) +item_zezzak_shard(i31463) Quest The eyes of Grillok (q10813). Prevents abuse +EndContentData */ + +#include "precompiled.h" +#include "SpellMgr.h" +#include "Spell.h" +#include "WorldPacket.h" + +/*##### +# item_area_52_special +#####*/ + +bool ItemUse_item_area_52_special(Player *player, Item* _Item, SpellCastTargets const& targets) +{ + if ( player->GetAreaId() == 3803 ) + { + return false; + } + else + { + player->SendEquipError(EQUIP_ERR_OUT_OF_RANGE,_Item,NULL); + return true; + } +} + +/*##### +# item_attuned_crystal_cores +#####*/ + +bool ItemUse_item_attuned_crystal_cores(Player *player, Item* _Item, SpellCastTargets const& targets) +{ + if( targets.getUnitTarget() && targets.getUnitTarget()->GetTypeId()==TYPEID_UNIT && + targets.getUnitTarget()->GetEntry() == 24972 && targets.getUnitTarget()->isDead() ) + return false; + + player->SendEquipError(EQUIP_ERR_CANT_DO_RIGHT_NOW,_Item,NULL); + return true; +} + +/*##### +# item_blackwhelp_net +#####*/ + +bool ItemUse_item_blackwhelp_net(Player *player, Item* _Item, SpellCastTargets const& targets) +{ + if( targets.getUnitTarget() && targets.getUnitTarget()->GetTypeId()==TYPEID_UNIT && + targets.getUnitTarget()->GetEntry() == 21387 ) + return false; + + player->SendEquipError(EQUIP_ERR_YOU_CAN_NEVER_USE_THAT_ITEM,_Item,NULL); + return true; +} + +/*##### +# item_draenei_fishing_net +#####*/ + +//This is just a hack and should be removed from here. +//Creature/Item are in fact created before spell are sucessfully casted, without any checks at all to ensure proper/expected behavior. +bool ItemUse_item_draenei_fishing_net(Player *player, Item* _Item, SpellCastTargets const& targets) +{ + //if( targets.getGOTarget() && targets.getGOTarget()->GetTypeId() == TYPEID_GAMEOBJECT && + //targets.getGOTarget()->GetGOInfo()->type == GAMEOBJECT_TYPE_SPELL_FOCUS && targets.getGOTarget()->GetEntry() == 181616 ) + //{ + if( player->GetQuestStatus(9452) == QUEST_STATUS_INCOMPLETE ) + { + if( rand()%100 < 35 ) + { + Creature *Murloc = player->SummonCreature(17102,player->GetPositionX() ,player->GetPositionY()+20, player->GetPositionZ(), 0,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,10000); + if( Murloc ) + Murloc->AI()->AttackStart(player); + } + else + { + ItemPosCountVec dest; + uint8 msg = player->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, 23614, 1); + if( msg == EQUIP_ERR_OK ) + { + Item* item = player->StoreNewItem(dest,23614,true); + if( item ) + player->SendNewItem(item,1,false,true); + }else + player->SendEquipError(msg,NULL,NULL); + } + } + //} + return false; +} + +/*##### +# item_disciplinary_rod +#####*/ + +bool ItemUse_item_disciplinary_rod(Player *player, Item* _Item, SpellCastTargets const& targets) +{ + if( targets.getUnitTarget() && targets.getUnitTarget()->GetTypeId()==TYPEID_UNIT && + (targets.getUnitTarget()->GetEntry() == 15941 || targets.getUnitTarget()->GetEntry() == 15945) ) + return false; + + player->SendEquipError(EQUIP_ERR_CANT_DO_RIGHT_NOW,_Item,NULL); + return true; +} + +/*##### +# item_nether_wraith_beacon +#####*/ + +bool ItemUse_item_nether_wraith_beacon(Player *player, Item* _Item, SpellCastTargets const& targets) +{ + if (player->GetQuestStatus(10832) == QUEST_STATUS_INCOMPLETE) + { + Creature *Nether; + Nether = player->SummonCreature(22408,player->GetPositionX() ,player->GetPositionY()+20, player->GetPositionZ(), 0,TEMPSUMMON_TIMED_DESPAWN,180000); + Nether = player->SummonCreature(22408,player->GetPositionX() ,player->GetPositionY()-20, player->GetPositionZ(), 0,TEMPSUMMON_TIMED_DESPAWN,180000); + if (Nether) + ((CreatureAI*)Nether->AI())->AttackStart(player); + } + return false; +} + +/*##### +# item_flying_machine +#####*/ + +bool ItemUse_item_flying_machine(Player *player, Item* _Item, SpellCastTargets const& targets) +{ + uint32 itemId = _Item->GetEntry(); + if( itemId == 34060 ) + if( player->GetBaseSkillValue(SKILL_RIDING) >= 225 ) + return false; + + if( itemId == 34061 ) + if( player->GetBaseSkillValue(SKILL_RIDING) == 300 ) + return false; + + debug_log("SD2: Player attempt to use item %u, but did not meet riding requirement",itemId); + player->SendEquipError(EQUIP_ERR_ERR_CANT_EQUIP_SKILL,_Item,NULL); + return true; +} + +/*##### +# item_gor_dreks_ointment +#####*/ + +bool ItemUse_item_gor_dreks_ointment(Player *player, Item* _Item, SpellCastTargets const& targets) +{ + if( targets.getUnitTarget() && targets.getUnitTarget()->GetTypeId()==TYPEID_UNIT && + targets.getUnitTarget()->GetEntry() == 20748 && !targets.getUnitTarget()->HasAura(32578,0) ) + return false; + + player->SendEquipError(EQUIP_ERR_CANT_DO_RIGHT_NOW,_Item,NULL); + return true; +} + +/*##### +# item_muiseks_vessel +#####*/ + +bool ItemUse_item_muiseks_vessel(Player *player, Item* _Item, SpellCastTargets const& targets) +{ + Unit* uTarget = targets.getUnitTarget(); + uint32 itemSpell = _Item->GetProto()->Spells[0].SpellId; + uint32 cEntry = 0; + uint32 cEntry2 = 0; + uint32 cEntry3 = 0; + uint32 cEntry4 = 0; + + if(itemSpell) + { + switch(itemSpell) + { + case 11885: //Wandering Forest Walker + cEntry = 7584; + break; + case 11886: //Owlbeasts + cEntry = 2927; + cEntry2 = 2928; + cEntry3 = 2929; + cEntry4 = 7808; + break; + case 11887: //Freyfeather Hippogryphs + cEntry = 5300; + cEntry2 = 5304; + cEntry3 = 5305; + cEntry4 = 5306; + break; + case 11888: //Sprite Dragon Sprite Darters + cEntry = 5276; + cEntry2 = 5278; + break; + case 11889: //Zapped Land Walker Land Walker Zapped Cliff Giant Cliff Giant + cEntry = 5357; + cEntry2 = 5358; + cEntry3 = 14640; + cEntry4 = 14604; + break; + } + if( uTarget && uTarget->GetTypeId()==TYPEID_UNIT && uTarget->isDead() && + (uTarget->GetEntry()==cEntry || uTarget->GetEntry()==cEntry2 || uTarget->GetEntry()==cEntry3 || uTarget->GetEntry()==cEntry4) ) + { + ((Creature*)uTarget)->RemoveCorpse(); + return false; + } + } + + WorldPacket data(SMSG_CAST_FAILED, (4+2)); // prepare packet error message + data << uint32(_Item->GetEntry()); // itemId + data << uint8(SPELL_FAILED_BAD_TARGETS); // reason + player->GetSession()->SendPacket(&data); // send message: Invalid target + + player->SendEquipError(EQUIP_ERR_NONE,_Item,NULL); // break spell + return true; +} + +/*##### +# item_razorthorn_flayer_gland +#####*/ + +bool ItemUse_item_razorthorn_flayer_gland(Player *player, Item* _Item, SpellCastTargets const& targets) +{ + if( targets.getUnitTarget() && targets.getUnitTarget()->GetTypeId()==TYPEID_UNIT && + targets.getUnitTarget()->GetEntry() == 24922 ) + return false; + + player->SendEquipError(EQUIP_ERR_YOU_CAN_NEVER_USE_THAT_ITEM,_Item,NULL); + return true; +} + +/*##### +# item_tame_beast_rods +#####*/ + +bool ItemUse_item_tame_beast_rods(Player *player, Item* _Item, SpellCastTargets const& targets) +{ + uint32 itemSpell = _Item->GetProto()->Spells[0].SpellId; + uint32 cEntry = 0; + + if(itemSpell) + { + switch(itemSpell) + { + case 19548: cEntry = 1196; break; //Ice Claw Bear + case 19674: cEntry = 1126; break; //Large Crag Boar + case 19687: cEntry = 1201; break; //Snow Leopard + case 19688: cEntry = 2956; break; //Adult Plainstrider + case 19689: cEntry = 2959; break; //Prairie Stalker + case 19692: cEntry = 2970; break; //Swoop + case 19693: cEntry = 1998; break; //Webwood Lurker + case 19694: cEntry = 3099; break; //Dire Mottled Boar + case 19696: cEntry = 3107; break; //Surf Crawler + case 19697: cEntry = 3126; break; //Armored Scorpid + case 19699: cEntry = 2043; break; //Nightsaber Stalker + case 19700: cEntry = 1996; break; //Strigid Screecher + case 30646: cEntry = 17217; break; //Barbed Crawler + case 30653: cEntry = 17374; break; //Greater Timberstrider + case 30654: cEntry = 17203; break; //Nightstalker + case 30099: cEntry = 15650; break; //Crazed Dragonhawk + case 30102: cEntry = 15652; break; //Elder Springpaw + case 30105: cEntry = 16353; break; //Mistbat + } + if( targets.getUnitTarget() && targets.getUnitTarget()->GetTypeId()==TYPEID_UNIT && + targets.getUnitTarget()->GetEntry() == cEntry ) + return false; + } + + WorldPacket data(SMSG_CAST_FAILED, (4+2)); // prepare packet error message + data << uint32(_Item->GetEntry()); // itemId + data << uint8(SPELL_FAILED_BAD_TARGETS); // reason + player->GetSession()->SendPacket(&data); // send message: Invalid target + + player->SendEquipError(EQUIP_ERR_NONE,_Item,NULL); // break spell + return true; +} + +/*##### +# item_protovoltaic_magneto_collector +#####*/ + +bool ItemUse_item_protovoltaic_magneto_collector(Player *player, Item* _Item, SpellCastTargets const& targets) +{ + if( targets.getUnitTarget() && targets.getUnitTarget()->GetTypeId()==TYPEID_UNIT && + targets.getUnitTarget()->GetEntry() == 21729 ) + return false; + + player->SendEquipError(EQUIP_ERR_CANT_DO_RIGHT_NOW,_Item,NULL); + return true; +} + +/*##### +# item_soul_cannon +#####*/ + +bool ItemUse_item_soul_cannon(Player *player, Item* _Item, SpellCastTargets const& targets) +{ + // allow use + if( targets.getUnitTarget() && targets.getUnitTarget()->GetTypeId()==TYPEID_UNIT && + targets.getUnitTarget()->GetEntry() == 22357 ) + return false; + + // error + player->SendEquipError(EQUIP_ERR_YOU_CAN_NEVER_USE_THAT_ITEM,_Item,NULL); + return true; +} + +/*##### +# item_sparrowhawk_net +#####*/ + +bool ItemUse_item_sparrowhawk_net(Player *player, Item* _Item, SpellCastTargets const& targets) +{ + if( targets.getUnitTarget() && targets.getUnitTarget()->GetTypeId()==TYPEID_UNIT && + targets.getUnitTarget()->GetEntry() == 22979 ) + return false; + + player->SendEquipError(EQUIP_ERR_YOU_CAN_NEVER_USE_THAT_ITEM,_Item,NULL); + return true; +} + +/*##### +# item_voodoo_charm +#####*/ + +bool ItemUse_item_voodoo_charm(Player *player, Item* _Item, SpellCastTargets const& targets) +{ + if( targets.getUnitTarget() && targets.getUnitTarget()->GetTypeId()==TYPEID_UNIT && targets.getUnitTarget()->isDead() && + targets.getUnitTarget()->GetEntry()==7318 ) + return false; + + WorldPacket data(SMSG_CAST_FAILED, (4+2)); // prepare packet error message + data << uint32(_Item->GetEntry()); // itemId + data << uint8(SPELL_FAILED_BAD_TARGETS); // reason + player->GetSession()->SendPacket(&data); // send message: Invalid target + + player->SendEquipError(EQUIP_ERR_NONE,_Item,NULL); // break spell + return true; +} + +/*##### +# item_vorenthals_presence +#####*/ + +bool ItemUse_item_vorenthals_presence(Player *player, Item* _Item, SpellCastTargets const& targets) +{ + // allow use + if( targets.getUnitTarget() && targets.getUnitTarget()->GetTypeId()==TYPEID_UNIT && + targets.getUnitTarget()->GetEntry() == 20132 ) + return false; + + // error + player->SendEquipError(EQUIP_ERR_YOU_CAN_NEVER_USE_THAT_ITEM,_Item,NULL); + return true; +} + +/*##### +# item_yehkinyas_bramble +#####*/ + +bool ItemUse_item_yehkinyas_bramble(Player *player, Item* _Item, SpellCastTargets const& targets) +{ + if (player->GetQuestStatus(3520) == QUEST_STATUS_INCOMPLETE) + { + Unit * unit_target = targets.getUnitTarget(); + if( unit_target && + unit_target->GetTypeId()==TYPEID_UNIT && + unit_target->isDead() && + // cast only on corpse 5307 or 5308 + (unit_target->GetEntry()==5307 || unit_target->GetEntry()==5308) ) + { + ((Creature*)unit_target)->RemoveCorpse(); // remove corpse for cancelling second use + return false; // all ok + } + } + WorldPacket data(SMSG_CAST_FAILED, (4+2)); // prepare packet error message + data << uint32(10699); // itemId + data << uint8(SPELL_FAILED_BAD_TARGETS); // reason + player->GetSession()->SendPacket(&data); // send message: Bad target + player->SendEquipError(EQUIP_ERR_NONE,_Item,NULL); // break spell + return true; +} + +/*##### +# item_zezzak_shard +#####*/ + +bool ItemUse_item_zezzak_shard(Player *player, Item* _Item, SpellCastTargets const& targets) +{ + if( targets.getUnitTarget() && targets.getUnitTarget()->GetTypeId()==TYPEID_UNIT && + targets.getUnitTarget()->GetEntry() == 19440 ) + return false; + + player->SendEquipError(EQUIP_ERR_YOU_CAN_NEVER_USE_THAT_ITEM,_Item,NULL); + return true; +} + +void AddSC_item_scripts() +{ + Script *newscript; + + newscript = new Script; + newscript->Name="item_area_52_special"; + newscript->pItemUse = ItemUse_item_area_52_special; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="item_attuned_crystal_cores"; + newscript->pItemUse = ItemUse_item_attuned_crystal_cores; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="item_blackwhelp_net"; + newscript->pItemUse = ItemUse_item_blackwhelp_net; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="item_disciplinary_rod"; + newscript->pItemUse = ItemUse_item_disciplinary_rod; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="item_draenei_fishing_net"; + newscript->pItemUse = ItemUse_item_draenei_fishing_net; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="item_nether_wraith_beacon"; + newscript->pItemUse = ItemUse_item_nether_wraith_beacon; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="item_flying_machine"; + newscript->pItemUse = ItemUse_item_flying_machine; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="item_gor_dreks_ointment"; + newscript->pItemUse = ItemUse_item_gor_dreks_ointment; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="item_muiseks_vessel"; + newscript->pItemUse = ItemUse_item_muiseks_vessel; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="item_razorthorn_flayer_gland"; + newscript->pItemUse = ItemUse_item_razorthorn_flayer_gland; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="item_tame_beast_rods"; + newscript->pItemUse = ItemUse_item_tame_beast_rods; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="item_protovoltaic_magneto_collector"; + newscript->pItemUse = ItemUse_item_protovoltaic_magneto_collector; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="item_soul_cannon"; + newscript->pItemUse = ItemUse_item_soul_cannon; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="item_sparrowhawk_net"; + newscript->pItemUse = ItemUse_item_sparrowhawk_net; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="item_voodoo_charm"; + newscript->pItemUse = ItemUse_item_voodoo_charm; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="item_vorenthals_presence"; + newscript->pItemUse = ItemUse_item_vorenthals_presence; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="item_yehkinyas_bramble"; + newscript->pItemUse = ItemUse_item_yehkinyas_bramble; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="item_zezzaks_shard"; + newscript->pItemUse = ItemUse_item_zezzak_shard; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/item/item_test.cpp b/src/bindings/scripts/scripts/item/item_test.cpp index e4f7285e52a..d54a42d217a 100644 --- a/src/bindings/scripts/scripts/item/item_test.cpp +++ b/src/bindings/scripts/scripts/item/item_test.cpp @@ -1,42 +1,42 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Item_Test -SD%Complete: 100 -SDComment: Used for Testing Item Scripts -SDCategory: Items -EndScriptData */ - -#include "precompiled.h" - -extern void LoadDatabase(); - -bool ItemUse_item_test(Player *player, Item* _Item, SpellCastTargets const& targets) -{ - LoadDatabase(); - return true; -} - -void AddSC_item_test() -{ - Script *newscript; - - newscript = new Script; - newscript->Name="item_test"; - newscript->pItemUse = ItemUse_item_test; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Item_Test +SD%Complete: 100 +SDComment: Used for Testing Item Scripts +SDCategory: Items +EndScriptData */ + +#include "precompiled.h" + +extern void LoadDatabase(); + +bool ItemUse_item_test(Player *player, Item* _Item, SpellCastTargets const& targets) +{ + LoadDatabase(); + return true; +} + +void AddSC_item_test() +{ + Script *newscript; + + newscript = new Script; + newscript->Name="item_test"; + newscript->pItemUse = ItemUse_item_test; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/npc/npc_escortAI.cpp b/src/bindings/scripts/scripts/npc/npc_escortAI.cpp index d846727ac0a..9be59296dbb 100644 --- a/src/bindings/scripts/scripts/npc/npc_escortAI.cpp +++ b/src/bindings/scripts/scripts/npc/npc_escortAI.cpp @@ -1,304 +1,304 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software licensed under GPL version 2 - * Please see the included DOCS/LICENSE.TXT for more information */ - -/* ScriptData -SDName: Npc_EscortAI -SD%Complete: 100 -SDComment: -SDCategory: Npc -EndScriptData */ - -#include "precompiled.h" -#include "npc_escortAI.h" - -#define WP_LAST_POINT -1 -#define MAX_PLAYER_DISTANCE 50 - -bool npc_escortAI::IsVisible(Unit* who) const -{ - if (!who) - return false; - - return (m_creature->GetDistance(who) < VISIBLE_RANGE) && who->isVisibleForOrDetect(m_creature,true); -} - -void npc_escortAI::AttackStart(Unit *who) -{ - if (!who) - return; - - if (IsBeingEscorted && !Defend) - return; - - if (who->isTargetableForAttack()) - { - //Begin attack - if ( m_creature->Attack(who, true) ) - { - m_creature->GetMotionMaster()->MovementExpired(); - m_creature->GetMotionMaster()->MoveChase(who); - m_creature->AddThreat(who, 0.0f); - } - - if (!InCombat) - { - InCombat = true; - - //Store last position - m_creature->GetPosition(LastPos.x, LastPos.y, LastPos.z); - - debug_log("SD2: EscortAI has entered combat via Attack and stored last location"); - - Aggro(who); - } - } -} - -void npc_escortAI::MoveInLineOfSight(Unit *who) -{ - if (IsBeingEscorted && !Attack) - return; - - if( !m_creature->getVictim() && who->isTargetableForAttack() && ( m_creature->IsHostileTo( who )) && who->isInAccessablePlaceFor(m_creature) ) - { - if (m_creature->GetDistanceZ(who) > CREATURE_Z_ATTACK_RANGE) - return; - - float attackRadius = m_creature->GetAttackDistance(who); - if( m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->IsWithinLOSInMap(who) ) - { - who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); - - //Begin attack - if ( m_creature->Attack(who, true) ) - { - m_creature->GetMotionMaster()->MovementExpired(); - m_creature->GetMotionMaster()->MoveChase(who); - m_creature->AddThreat(who, 0.0f); - } - - if (!InCombat) - { - InCombat = true; - - //Store last position - m_creature->GetPosition(LastPos.x, LastPos.y, LastPos.z); - debug_log("SD2: EscortAI has entered combat via LOS and stored last location"); - - Aggro(who); - } - } - } -} - -void npc_escortAI::JustRespawned() -{ - InCombat = false; - IsBeingEscorted = false; - IsOnHold = false; - - //Re-Enable gossip - m_creature->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP); - - Reset(); -} - -void npc_escortAI::EnterEvadeMode() -{ - InCombat = false; - - m_creature->RemoveAllAuras(); - m_creature->DeleteThreatList(); - m_creature->CombatStop(); - m_creature->SetLootRecipient(NULL); - - if (IsBeingEscorted) - { - debug_log("SD2: EscortAI has left combat and is now returning to last point"); - Returning = true; - m_creature->GetMotionMaster()->MovementExpired(); - m_creature->GetMotionMaster()->MovePoint(WP_LAST_POINT, LastPos.x, LastPos.y, LastPos.z); - - }else - { - m_creature->GetMotionMaster()->MovementExpired(); - m_creature->GetMotionMaster()->MoveTargetedHome(); - } - - Reset(); -} - -void npc_escortAI::UpdateAI(const uint32 diff) -{ - //Waypoint Updating - if (IsBeingEscorted && !InCombat && WaitTimer && !Returning) - if (WaitTimer <= diff) - { - if (ReconnectWP) - { - //Correct movement speed - if (Run) - m_creature->RemoveUnitMovementFlag(MOVEMENTFLAG_WALK_MODE); - else m_creature->AddUnitMovementFlag(MOVEMENTFLAG_WALK_MODE); - - //Continue with waypoints - if( !IsOnHold ) - { - m_creature->GetMotionMaster()->MovePoint(CurrentWP->id, CurrentWP->x, CurrentWP->y, CurrentWP->z ); - debug_log("SD2: EscortAI Reconnect WP is: %d, %f, %f, %f", CurrentWP->id, CurrentWP->x, CurrentWP->y, CurrentWP->z); - WaitTimer = 0; - ReconnectWP = false; - return; - } - } - - //End of the line, Despawn self then immediatly respawn - if (CurrentWP == WaypointList.end()) - { - debug_log("SD2: EscortAI reached end of waypoints"); - - m_creature->setDeathState(JUST_DIED); - m_creature->SetHealth(0); - m_creature->CombatStop(); - m_creature->DeleteThreatList(); - m_creature->Respawn(); - m_creature->GetMotionMaster()->Clear(true); - - //Re-Enable gossip - m_creature->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP); - - IsBeingEscorted = false; - WaitTimer = 0; - return; - } - - if( !IsOnHold ) - { - m_creature->GetMotionMaster()->MovePoint(CurrentWP->id, CurrentWP->x, CurrentWP->y, CurrentWP->z ); - debug_log("SD2: EscortAI Next WP is: %d, %f, %f, %f", CurrentWP->id, CurrentWP->x, CurrentWP->y, CurrentWP->z); - WaitTimer = 0; - } - }else WaitTimer -= diff; - - //Check if player is within range - if (IsBeingEscorted && !InCombat && PlayerGUID) - if (PlayerTimer < diff) - { - Unit* p = Unit::GetUnit(*m_creature, PlayerGUID); - - if (!p || m_creature->GetDistance(p) > MAX_PLAYER_DISTANCE) - { - JustDied(m_creature); - IsBeingEscorted = false; - - debug_log("SD2: EscortAI Evaded back to spawn point because player was to far away or not found"); - - m_creature->setDeathState(JUST_DIED); - m_creature->SetHealth(0); - m_creature->CombatStop(); - m_creature->DeleteThreatList(); - m_creature->Respawn(); - m_creature->GetMotionMaster()->Clear(true); - - //Re-Enable gossip - m_creature->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP); - } - - PlayerTimer = 1000; - }else PlayerTimer -= diff; - - //Check if we have a current target - if( m_creature->isAlive() && m_creature->SelectHostilTarget() && m_creature->getVictim()) - { - //If we are within range melee the target - if( m_creature->IsWithinDistInMap(m_creature->getVictim(), ATTACK_DISTANCE)) - { - if( m_creature->isAttackReady() ) - { - m_creature->AttackerStateUpdate(m_creature->getVictim()); - m_creature->resetAttackTimer(); - } - } - } -} - -void npc_escortAI::MovementInform(uint32 type, uint32 id) -{ - if (type != POINT_MOTION_TYPE || !IsBeingEscorted) - return; - - //Original position reached, continue waypoint movement - if (id == WP_LAST_POINT) - { - debug_log("SD2: EscortAI has returned to original position before combat"); - ReconnectWP = true; - Returning = false; - WaitTimer = 1; - - }else - { - //Make sure that we are still on the right waypoint - if (CurrentWP->id != id) - { - debug_log("SD2 ERROR: EscortAI reached waypoint out of order %d, expected %d", id, CurrentWP->id); - return; - } - - debug_log("SD2: EscortAI Waypoint %d reached", CurrentWP->id); - - //Call WP function - WaypointReached(CurrentWP->id); - - WaitTimer = CurrentWP->WaitTimeMs + 1; - - ++CurrentWP; - } -} - -void npc_escortAI::AddWaypoint(uint32 id, float x, float y, float z, uint32 WaitTimeMs) -{ - Escort_Waypoint t(id, x, y, z, WaitTimeMs); - - WaypointList.push_back(t); -} - -void npc_escortAI::Start(bool bAttack, bool bDefend, bool bRun, uint64 pGUID) -{ - if (InCombat) - { - debug_log("SD2 ERROR: EscortAI attempt to Start while in combat"); - return; - } - - if (WaypointList.empty()) - { - debug_log("SD2 ERROR: Call to escortAI::Start with 0 waypoints"); - return; - } - - Attack = bAttack; - Defend = bDefend; - Run = bRun; - PlayerGUID = pGUID; - - debug_log("SD2: EscortAI started with %d waypoints. Attack = %d, Defend = %d, Run = %d, PlayerGUID = %d", WaypointList.size(), Attack, Defend, Run, PlayerGUID); - - CurrentWP = WaypointList.begin(); - - //Set initial speed - if (Run) - m_creature->RemoveUnitMovementFlag(MOVEMENTFLAG_WALK_MODE); - else m_creature->AddUnitMovementFlag(MOVEMENTFLAG_WALK_MODE); - - //Start WP - m_creature->GetMotionMaster()->MovePoint(CurrentWP->id, CurrentWP->x, CurrentWP->y, CurrentWP->z ); - debug_log("SD2: EscortAI Next WP is: %d, %f, %f, %f", CurrentWP->id, CurrentWP->x, CurrentWP->y, CurrentWP->z); - IsBeingEscorted = true; - ReconnectWP = false; - Returning = false; - IsOnHold = false; - - //Disable gossip - m_creature->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP); -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software licensed under GPL version 2 + * Please see the included DOCS/LICENSE.TXT for more information */ + +/* ScriptData +SDName: Npc_EscortAI +SD%Complete: 100 +SDComment: +SDCategory: Npc +EndScriptData */ + +#include "precompiled.h" +#include "npc_escortAI.h" + +#define WP_LAST_POINT -1 +#define MAX_PLAYER_DISTANCE 50 + +bool npc_escortAI::IsVisible(Unit* who) const +{ + if (!who) + return false; + + return (m_creature->GetDistance(who) < VISIBLE_RANGE) && who->isVisibleForOrDetect(m_creature,true); +} + +void npc_escortAI::AttackStart(Unit *who) +{ + if (!who) + return; + + if (IsBeingEscorted && !Defend) + return; + + if (who->isTargetableForAttack()) + { + //Begin attack + if ( m_creature->Attack(who, true) ) + { + m_creature->GetMotionMaster()->MovementExpired(); + m_creature->GetMotionMaster()->MoveChase(who); + m_creature->AddThreat(who, 0.0f); + } + + if (!InCombat) + { + InCombat = true; + + //Store last position + m_creature->GetPosition(LastPos.x, LastPos.y, LastPos.z); + + debug_log("SD2: EscortAI has entered combat via Attack and stored last location"); + + Aggro(who); + } + } +} + +void npc_escortAI::MoveInLineOfSight(Unit *who) +{ + if (IsBeingEscorted && !Attack) + return; + + if( !m_creature->getVictim() && who->isTargetableForAttack() && ( m_creature->IsHostileTo( who )) && who->isInAccessablePlaceFor(m_creature) ) + { + if (!m_creature->canFly() && m_creature->GetDistanceZ(who) > CREATURE_Z_ATTACK_RANGE) + return; + + float attackRadius = m_creature->GetAttackDistance(who); + if( m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->IsWithinLOSInMap(who) ) + { + who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); + + //Begin attack + if ( m_creature->Attack(who, true) ) + { + m_creature->GetMotionMaster()->MovementExpired(); + m_creature->GetMotionMaster()->MoveChase(who); + m_creature->AddThreat(who, 0.0f); + } + + if (!InCombat) + { + InCombat = true; + + //Store last position + m_creature->GetPosition(LastPos.x, LastPos.y, LastPos.z); + debug_log("SD2: EscortAI has entered combat via LOS and stored last location"); + + Aggro(who); + } + } + } +} + +void npc_escortAI::JustRespawned() +{ + InCombat = false; + IsBeingEscorted = false; + IsOnHold = false; + + //Re-Enable gossip + m_creature->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP); + + Reset(); +} + +void npc_escortAI::EnterEvadeMode() +{ + InCombat = false; + + m_creature->RemoveAllAuras(); + m_creature->DeleteThreatList(); + m_creature->CombatStop(); + m_creature->SetLootRecipient(NULL); + + if (IsBeingEscorted) + { + debug_log("SD2: EscortAI has left combat and is now returning to last point"); + Returning = true; + m_creature->GetMotionMaster()->MovementExpired(); + m_creature->GetMotionMaster()->MovePoint(WP_LAST_POINT, LastPos.x, LastPos.y, LastPos.z); + + }else + { + m_creature->GetMotionMaster()->MovementExpired(); + m_creature->GetMotionMaster()->MoveTargetedHome(); + } + + Reset(); +} + +void npc_escortAI::UpdateAI(const uint32 diff) +{ + //Waypoint Updating + if (IsBeingEscorted && !InCombat && WaitTimer && !Returning) + if (WaitTimer <= diff) + { + if (ReconnectWP) + { + //Correct movement speed + if (Run) + m_creature->RemoveUnitMovementFlag(MOVEMENTFLAG_WALK_MODE); + else m_creature->AddUnitMovementFlag(MOVEMENTFLAG_WALK_MODE); + + //Continue with waypoints + if( !IsOnHold ) + { + m_creature->GetMotionMaster()->MovePoint(CurrentWP->id, CurrentWP->x, CurrentWP->y, CurrentWP->z ); + debug_log("SD2: EscortAI Reconnect WP is: %d, %f, %f, %f", CurrentWP->id, CurrentWP->x, CurrentWP->y, CurrentWP->z); + WaitTimer = 0; + ReconnectWP = false; + return; + } + } + + //End of the line, Despawn self then immediatly respawn + if (CurrentWP == WaypointList.end()) + { + debug_log("SD2: EscortAI reached end of waypoints"); + + m_creature->setDeathState(JUST_DIED); + m_creature->SetHealth(0); + m_creature->CombatStop(); + m_creature->DeleteThreatList(); + m_creature->Respawn(); + m_creature->GetMotionMaster()->Clear(true); + + //Re-Enable gossip + m_creature->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP); + + IsBeingEscorted = false; + WaitTimer = 0; + return; + } + + if( !IsOnHold ) + { + m_creature->GetMotionMaster()->MovePoint(CurrentWP->id, CurrentWP->x, CurrentWP->y, CurrentWP->z ); + debug_log("SD2: EscortAI Next WP is: %d, %f, %f, %f", CurrentWP->id, CurrentWP->x, CurrentWP->y, CurrentWP->z); + WaitTimer = 0; + } + }else WaitTimer -= diff; + + //Check if player is within range + if (IsBeingEscorted && !InCombat && PlayerGUID) + if (PlayerTimer < diff) + { + Unit* p = Unit::GetUnit(*m_creature, PlayerGUID); + + if (!p || m_creature->GetDistance(p) > MAX_PLAYER_DISTANCE) + { + JustDied(m_creature); + IsBeingEscorted = false; + + debug_log("SD2: EscortAI Evaded back to spawn point because player was to far away or not found"); + + m_creature->setDeathState(JUST_DIED); + m_creature->SetHealth(0); + m_creature->CombatStop(); + m_creature->DeleteThreatList(); + m_creature->Respawn(); + m_creature->GetMotionMaster()->Clear(true); + + //Re-Enable gossip + m_creature->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP); + } + + PlayerTimer = 1000; + }else PlayerTimer -= diff; + + //Check if we have a current target + if( m_creature->isAlive() && m_creature->SelectHostilTarget() && m_creature->getVictim()) + { + //If we are within range melee the target + if( m_creature->IsWithinDistInMap(m_creature->getVictim(), ATTACK_DISTANCE)) + { + if( m_creature->isAttackReady() ) + { + m_creature->AttackerStateUpdate(m_creature->getVictim()); + m_creature->resetAttackTimer(); + } + } + } +} + +void npc_escortAI::MovementInform(uint32 type, uint32 id) +{ + if (type != POINT_MOTION_TYPE || !IsBeingEscorted) + return; + + //Original position reached, continue waypoint movement + if (id == WP_LAST_POINT) + { + debug_log("SD2: EscortAI has returned to original position before combat"); + ReconnectWP = true; + Returning = false; + WaitTimer = 1; + + }else + { + //Make sure that we are still on the right waypoint + if (CurrentWP->id != id) + { + debug_log("SD2 ERROR: EscortAI reached waypoint out of order %d, expected %d", id, CurrentWP->id); + return; + } + + debug_log("SD2: EscortAI Waypoint %d reached", CurrentWP->id); + + //Call WP function + WaypointReached(CurrentWP->id); + + WaitTimer = CurrentWP->WaitTimeMs + 1; + + ++CurrentWP; + } +} + +void npc_escortAI::AddWaypoint(uint32 id, float x, float y, float z, uint32 WaitTimeMs) +{ + Escort_Waypoint t(id, x, y, z, WaitTimeMs); + + WaypointList.push_back(t); +} + +void npc_escortAI::Start(bool bAttack, bool bDefend, bool bRun, uint64 pGUID) +{ + if (InCombat) + { + debug_log("SD2 ERROR: EscortAI attempt to Start while in combat"); + return; + } + + if (WaypointList.empty()) + { + debug_log("SD2 ERROR: Call to escortAI::Start with 0 waypoints"); + return; + } + + Attack = bAttack; + Defend = bDefend; + Run = bRun; + PlayerGUID = pGUID; + + debug_log("SD2: EscortAI started with %d waypoints. Attack = %d, Defend = %d, Run = %d, PlayerGUID = %d", WaypointList.size(), Attack, Defend, Run, PlayerGUID); + + CurrentWP = WaypointList.begin(); + + //Set initial speed + if (Run) + m_creature->RemoveUnitMovementFlag(MOVEMENTFLAG_WALK_MODE); + else m_creature->AddUnitMovementFlag(MOVEMENTFLAG_WALK_MODE); + + //Start WP + m_creature->GetMotionMaster()->MovePoint(CurrentWP->id, CurrentWP->x, CurrentWP->y, CurrentWP->z ); + debug_log("SD2: EscortAI Next WP is: %d, %f, %f, %f", CurrentWP->id, CurrentWP->x, CurrentWP->y, CurrentWP->z); + IsBeingEscorted = true; + ReconnectWP = false; + Returning = false; + IsOnHold = false; + + //Disable gossip + m_creature->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP); +} diff --git a/src/bindings/scripts/scripts/npc/npc_escortAI.h b/src/bindings/scripts/scripts/npc/npc_escortAI.h index e1dbf186764..6f735316c6b 100644 --- a/src/bindings/scripts/scripts/npc/npc_escortAI.h +++ b/src/bindings/scripts/scripts/npc/npc_escortAI.h @@ -1,85 +1,85 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software licensed under GPL version 2 - * Please see the included DOCS/LICENSE.TXT for more information */ - -#ifndef SC_ESCORTAI_H -#define SC_ESCORTAI_H - -struct Escort_Waypoint -{ - Escort_Waypoint(uint32 _id, float _x, float _y, float _z, uint32 _w) - { - id = _id; - x = _x; - y = _y; - z = _z; - WaitTimeMs = _w; - } - - uint32 id; - float x; - float y; - float z; - uint32 WaitTimeMs; -}; - -struct MANGOS_DLL_DECL npc_escortAI : public ScriptedAI -{ - public: - - // Pure Virtual Functions - virtual void WaypointReached(uint32) = 0; - - virtual void Aggro(Unit*) = 0; - - virtual void Reset() = 0; - - // CreatureAI functions - npc_escortAI(Creature *c) : ScriptedAI(c), IsBeingEscorted(false), PlayerTimer(1000) {m_creature->GetPosition(LastPos.x, LastPos.y, LastPos.z);} - - bool IsVisible(Unit*) const; - - void AttackStart(Unit*); - - void MoveInLineOfSight(Unit*); - - void JustRespawned(); - - void EnterEvadeMode(); - - void UpdateAI(const uint32); - - void MovementInform(uint32, uint32); - - // EscortAI functions - void AddWaypoint(uint32 id, float x, float y, float z, uint32 WaitTimeMs = 0); - - void Start(bool bAttack, bool bDefend, bool bRun, uint64 pGUID = 0); - - // EscortAI variables - protected: - uint64 PlayerGUID; - bool IsBeingEscorted; - bool IsOnHold; - - private: - uint32 WaitTimer; - uint32 PlayerTimer; - - struct - { - float x; - float y; - float z; - }LastPos; - - std::list WaypointList; - std::list::iterator CurrentWP; - - bool Attack; - bool Defend; - bool Returning; - bool ReconnectWP; - bool Run; -}; -#endif +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software licensed under GPL version 2 + * Please see the included DOCS/LICENSE.TXT for more information */ + +#ifndef SC_ESCORTAI_H +#define SC_ESCORTAI_H + +struct Escort_Waypoint +{ + Escort_Waypoint(uint32 _id, float _x, float _y, float _z, uint32 _w) + { + id = _id; + x = _x; + y = _y; + z = _z; + WaitTimeMs = _w; + } + + uint32 id; + float x; + float y; + float z; + uint32 WaitTimeMs; +}; + +struct MANGOS_DLL_DECL npc_escortAI : public ScriptedAI +{ + public: + + // Pure Virtual Functions + virtual void WaypointReached(uint32) = 0; + + virtual void Aggro(Unit*) = 0; + + virtual void Reset() = 0; + + // CreatureAI functions + npc_escortAI(Creature *c) : ScriptedAI(c), IsBeingEscorted(false), PlayerTimer(1000) {m_creature->GetPosition(LastPos.x, LastPos.y, LastPos.z);} + + bool IsVisible(Unit*) const; + + void AttackStart(Unit*); + + void MoveInLineOfSight(Unit*); + + void JustRespawned(); + + void EnterEvadeMode(); + + void UpdateAI(const uint32); + + void MovementInform(uint32, uint32); + + // EscortAI functions + void AddWaypoint(uint32 id, float x, float y, float z, uint32 WaitTimeMs = 0); + + void Start(bool bAttack, bool bDefend, bool bRun, uint64 pGUID = 0); + + // EscortAI variables + protected: + uint64 PlayerGUID; + bool IsBeingEscorted; + bool IsOnHold; + + private: + uint32 WaitTimer; + uint32 PlayerTimer; + + struct + { + float x; + float y; + float z; + }LastPos; + + std::list WaypointList; + std::list::iterator CurrentWP; + + bool Attack; + bool Defend; + bool Returning; + bool ReconnectWP; + bool Run; +}; +#endif diff --git a/src/bindings/scripts/scripts/npc/npc_innkeeper.cpp b/src/bindings/scripts/scripts/npc/npc_innkeeper.cpp index 429d5b51115..9da0f267cb1 100644 --- a/src/bindings/scripts/scripts/npc/npc_innkeeper.cpp +++ b/src/bindings/scripts/scripts/npc/npc_innkeeper.cpp @@ -1,144 +1,144 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Npc_Innkeeper -SD%Complete: 50 -SDComment: This script are currently not in use. EventSystem cannot be used on Windows build of SD2 -SDCategory: NPCs -EndScriptData */ - -#include "precompiled.h" - -#define HALLOWEEN_EVENTID 12 -#define SPELL_TRICK_OR_TREATED 24755 -#define SPELL_TREAT 24715 - -#define LOCALE_TRICK_OR_TREAT_0 "Trick or Treat!" -#define LOCALE_TRICK_OR_TREAT_2 "Des bonbons ou des blagues!" -#define LOCALE_TRICK_OR_TREAT_3 "Süßes oder Saures!" -#define LOCALE_TRICK_OR_TREAT_6 "¡Truco o trato!" - -bool isEventActive() -{ - /* - const GameEvent::ActiveEvents *ActiveEventsList = gameeventmgr.GetActiveEventList(); - GameEvent::ActiveEvents::const_iterator itr; - for (itr = ActiveEventsList->begin(); itr != ActiveEventsList->end(); ++itr) - { - if (*itr==HALLOWEEN_EVENTID) - { - return true; - } - }*/ - return false; -} - -bool GossipHello_npc_innkeeper(Player *player, Creature *_Creature) -{ - if (_Creature->isQuestGiver()) - player->PrepareQuestMenu( _Creature->GetGUID() ); - - if (isEventActive()&& !player->GetAura(SPELL_TRICK_OR_TREATED,0)) - { - char* localizedEntry; - switch (player->GetSession()->GetSessionDbLocaleIndex()) - { - case 0: - localizedEntry=LOCALE_TRICK_OR_TREAT_0; - break; - case 2: - localizedEntry=LOCALE_TRICK_OR_TREAT_2; - break; - case 3: - localizedEntry=LOCALE_TRICK_OR_TREAT_3; - break; - case 6: - localizedEntry=LOCALE_TRICK_OR_TREAT_6; - break; - default: - localizedEntry=LOCALE_TRICK_OR_TREAT_0; - } - - player->ADD_GOSSIP_ITEM(0, localizedEntry, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+HALLOWEEN_EVENTID); - } - - player->TalkedToCreature(_Creature->GetEntry(),_Creature->GetGUID()); - player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); - return true; -} - -bool GossipSelect_npc_innkeeper(Player *player, Creature *_Creature, uint32 sender, uint32 action ) -{ - if (action == GOSSIP_ACTION_INFO_DEF+HALLOWEEN_EVENTID && isEventActive() && !player->GetAura(SPELL_TRICK_OR_TREATED,0)) - { - player->CLOSE_GOSSIP_MENU(); - player->CastSpell(player, SPELL_TRICK_OR_TREATED, true); - - // either trick or treat, 50% chance - if(rand()%2) - { - player->CastSpell(player, SPELL_TREAT, true); - } - else - { - int32 trickspell=0; - switch (rand()%9) // note that female characters can get male costumes and vice versa - { - case 0: - trickspell=24753; // cannot cast, random 30sec - break; - case 1: - trickspell=24713; // lepper gnome costume - break; - case 2: - trickspell=24735; // male ghost costume - break; - case 3: - trickspell=24736; // female ghostcostume - break; - case 4: - trickspell=24710; // male ninja costume - break; - case 5: - trickspell=24711; // female ninja costume - break; - case 6: - trickspell=24708; // male pirate costume - break; - case 7: - trickspell=24709; // female pirate costume - break; - case 8: - trickspell=24723; // skeleton costume - break; - } - player->CastSpell(player, trickspell, true); - } - return true; // prevent mangos core handling - } - return false; // the player didn't select "trick or treat" or cheated, normal core handling -} - -void AddSC_npc_innkeeper() -{ - Script *newscript; - newscript = new Script; - newscript->Name="npc_innkeeper"; - newscript->pGossipHello = &GossipHello_npc_innkeeper; - newscript->pGossipSelect = &GossipSelect_npc_innkeeper; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Npc_Innkeeper +SD%Complete: 50 +SDComment: This script are currently not in use. EventSystem cannot be used on Windows build of SD2 +SDCategory: NPCs +EndScriptData */ + +#include "precompiled.h" + +#define HALLOWEEN_EVENTID 12 +#define SPELL_TRICK_OR_TREATED 24755 +#define SPELL_TREAT 24715 + +#define LOCALE_TRICK_OR_TREAT_0 "Trick or Treat!" +#define LOCALE_TRICK_OR_TREAT_2 "Des bonbons ou des blagues!" +#define LOCALE_TRICK_OR_TREAT_3 "Süßes oder Saures!" +#define LOCALE_TRICK_OR_TREAT_6 "¡Truco o trato!" + +bool isEventActive() +{ + /* + const GameEvent::ActiveEvents *ActiveEventsList = gameeventmgr.GetActiveEventList(); + GameEvent::ActiveEvents::const_iterator itr; + for (itr = ActiveEventsList->begin(); itr != ActiveEventsList->end(); ++itr) + { + if (*itr==HALLOWEEN_EVENTID) + { + return true; + } + }*/ + return false; +} + +bool GossipHello_npc_innkeeper(Player *player, Creature *_Creature) +{ + if (_Creature->isQuestGiver()) + player->PrepareQuestMenu( _Creature->GetGUID() ); + + if (isEventActive()&& !player->GetAura(SPELL_TRICK_OR_TREATED,0)) + { + char* localizedEntry; + switch (player->GetSession()->GetSessionDbLocaleIndex()) + { + case 0: + localizedEntry=LOCALE_TRICK_OR_TREAT_0; + break; + case 2: + localizedEntry=LOCALE_TRICK_OR_TREAT_2; + break; + case 3: + localizedEntry=LOCALE_TRICK_OR_TREAT_3; + break; + case 6: + localizedEntry=LOCALE_TRICK_OR_TREAT_6; + break; + default: + localizedEntry=LOCALE_TRICK_OR_TREAT_0; + } + + player->ADD_GOSSIP_ITEM(0, localizedEntry, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+HALLOWEEN_EVENTID); + } + + player->TalkedToCreature(_Creature->GetEntry(),_Creature->GetGUID()); + player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); + return true; +} + +bool GossipSelect_npc_innkeeper(Player *player, Creature *_Creature, uint32 sender, uint32 action ) +{ + if (action == GOSSIP_ACTION_INFO_DEF+HALLOWEEN_EVENTID && isEventActive() && !player->GetAura(SPELL_TRICK_OR_TREATED,0)) + { + player->CLOSE_GOSSIP_MENU(); + player->CastSpell(player, SPELL_TRICK_OR_TREATED, true); + + // either trick or treat, 50% chance + if(rand()%2) + { + player->CastSpell(player, SPELL_TREAT, true); + } + else + { + int32 trickspell=0; + switch (rand()%9) // note that female characters can get male costumes and vice versa + { + case 0: + trickspell=24753; // cannot cast, random 30sec + break; + case 1: + trickspell=24713; // lepper gnome costume + break; + case 2: + trickspell=24735; // male ghost costume + break; + case 3: + trickspell=24736; // female ghostcostume + break; + case 4: + trickspell=24710; // male ninja costume + break; + case 5: + trickspell=24711; // female ninja costume + break; + case 6: + trickspell=24708; // male pirate costume + break; + case 7: + trickspell=24709; // female pirate costume + break; + case 8: + trickspell=24723; // skeleton costume + break; + } + player->CastSpell(player, trickspell, true); + } + return true; // prevent mangos core handling + } + return false; // the player didn't select "trick or treat" or cheated, normal core handling +} + +void AddSC_npc_innkeeper() +{ + Script *newscript; + newscript = new Script; + newscript->Name="npc_innkeeper"; + newscript->pGossipHello = &GossipHello_npc_innkeeper; + newscript->pGossipSelect = &GossipSelect_npc_innkeeper; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/npc/npc_professions.cpp b/src/bindings/scripts/scripts/npc/npc_professions.cpp index 65487786058..1f5b3837572 100644 --- a/src/bindings/scripts/scripts/npc/npc_professions.cpp +++ b/src/bindings/scripts/scripts/npc/npc_professions.cpp @@ -1,1205 +1,1205 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Npc_Professions -SD%Complete: 80 -SDComment: Provides learn/unlearn/relearn-options for professions. Not supported: Unlearn engineering, re-learn engineering, re-learn leatherworking. -SDCategory: NPCs -EndScriptData */ - -#include "precompiled.h" - -/* -A few notes for future developement: -- A full implementation of gossip for GO's is required. They must have the same scripting capabilities as creatures. Basically, -there is no difference here (except that default text is chosen with `gameobject_template`.`data3` (for GO type2, different dataN for a few others) -- It's possible blacksmithing still require some tweaks and adjustments due to the way we _have_ to use reputation. -*/ - -/* --- UPDATE `gameobject_template` SET `ScriptName` = 'go_soothsaying_for_dummies' WHERE `entry` = 177226; -*/ - -/*### -# to be removed from here (->ncp_text). This is data for database projects. -###*/ -#define TALK_MUST_UNLEARN_WEAPON "You must forget your weapon type specialty before I can help you. Go to Everlook in Winterspring and seek help there." - -#define TALK_HAMMER_LEARN "Ah, a seasoned veteran you once were. I know you are capable, you merely need to ask and I shall teach you the way of the hammersmith." -#define TALK_AXE_LEARN "Ah, a seasoned veteran you once were. I know you are capable, you merely need to ask and I shall teach you the way of the axesmith." -#define TALK_SWORD_LEARN "Ah, a seasoned veteran you once were. I know you are capable, you merely need to ask and I shall teach you the way of the swordsmith." - -#define TALK_HAMMER_UNLEARN "Forgetting your Hammersmithing skill is not something to do lightly. If you choose to abandon it you will forget all recipes that require Hammersmithing to create!" -#define TALK_AXE_UNLEARN "Forgetting your Axesmithing skill is not something to do lightly. If you choose to abandon it you will forget all recipes that require Axesmithing to create!" -#define TALK_SWORD_UNLEARN "Forgetting your Swordsmithing skill is not something to do lightly. If you choose to abandon it you will forget all recipes that require Swordsmithing to create!" - -/*### -# generic defines -###*/ - -#define GOSSIP_SENDER_LEARN 50 -#define GOSSIP_SENDER_UNLEARN 51 -#define GOSSIP_SENDER_CHECK 52 - -/*### -# gossip item and box texts -###*/ - -#define GOSSIP_LEARN_POTION "Please teach me how to become a Master of Potions, Lauranna" -#define GOSSIP_UNLEARN_POTION "I wish to unlearn Potion Mastery" -#define GOSSIP_LEARN_TRANSMUTE "Please teach me how to become a Master of Transmutations, Zarevhi" -#define GOSSIP_UNLEARN_TRANSMUTE "I wish to unlearn Transmutation Mastery" -#define GOSSIP_LEARN_ELIXIR "Please teach me how to become a Master of Elixirs, Lorokeem" -#define GOSSIP_UNLEARN_ELIXIR "I wish to unlearn Elixir Mastery" - -#define BOX_UNLEARN_ALCHEMY_SPEC "Do you really want to unlearn your alchemy specialty and lose all associated recipes? \n Cost: " - -#define GOSSIP_WEAPON_LEARN "Please teach me how to become a Weaponsmith" -#define GOSSIP_WEAPON_UNLEARN "I wish to unlearn the art of Weaponsmithing" -#define GOSSIP_ARMOR_LEARN "Please teach me how to become a Armorsmith" -#define GOSSIP_ARMOR_UNLEARN "I wish to unlearn the art of Armorsmithing" - -#define GOSSIP_UNLEARN_SMITH_SPEC "I wish to unlearn my blacksmith specialty" -#define BOX_UNLEARN_ARMORORWEAPON "Do you really want to unlearn your blacksmith specialty and lose all associated recipes? \n Cost: " - -#define GOSSIP_LEARN_HAMMER "Please teach me how to become a Hammersmith, Lilith" -#define GOSSIP_UNLEARN_HAMMER "I wish to unlearn Hammersmithing" -#define GOSSIP_LEARN_AXE "Please teach me how to become a Axesmith, Kilram" -#define GOSSIP_UNLEARN_AXE "I wish to unlearn Axesmithing" -#define GOSSIP_LEARN_SWORD "Please teach me how to become a Swordsmith, Seril" -#define GOSSIP_UNLEARN_SWORD "I wish to unlearn Swordsmithing" - -#define BOX_UNLEARN_WEAPON_SPEC "Do you really want to unlearn your weaponsmith specialty and lose all associated recipes? \n Cost: " - -#define GOSSIP_LEARN_DRAGON "I am absolutely certain that i want to learn dragonscale leatherworking" -#define GOSSIP_UNLEARN_DRAGON "I wish to unlearn Dragonscale Leatherworking" -#define GOSSIP_LEARN_ELEMENTAL "I am absolutely certain that i want to learn elemental leatherworking" -#define GOSSIP_UNLEARN_ELEMENTAL "I wish to unlearn Elemental Leatherworking" -#define GOSSIP_LEARN_TRIBAL "I am absolutely certain that i want to learn tribal leatherworking" -#define GOSSIP_UNLEARN_TRIBAL "I wish to unlearn Tribal Leatherworking" - -#define BOX_UNLEARN_LEATHER_SPEC "Do you really want to unlearn your leatherworking specialty and lose all associated recipes? \n Cost: " - -#define GOSSIP_LEARN_SPELLFIRE "Please teach me how to become a Spellcloth tailor" -#define GOSSIP_UNLEARN_SPELLFIRE "I wish to unlearn Spellfire Tailoring" -#define GOSSIP_LEARN_MOONCLOTH "Please teach me how to become a Mooncloth tailor" -#define GOSSIP_UNLEARN_MOONCLOTH "I wish to unlearn Mooncloth Tailoring" -#define GOSSIP_LEARN_SHADOWEAVE "Please teach me how to become a Shadoweave tailor" -#define GOSSIP_UNLEARN_SHADOWEAVE "I wish to unlearn Shadoweave Tailoring" - -#define BOX_UNLEARN_TAILOR_SPEC "Do you really want to unlearn your tailoring specialty and lose all associated recipes? \n Cost: " - -#define GOSSIP_LEARN_GOBLIN "I am absolutely certain that i want to learn Goblin engineering" -#define GOSSIP_LEARN_GNOMISH "I am absolutely certain that i want to learn Gnomish engineering" - -/*### -# spells defines -###*/ - -#define S_WEAPON 9787 -#define S_ARMOR 9788 -#define S_HAMMER 17040 -#define S_AXE 17041 -#define S_SWORD 17039 - -#define S_LEARN_WEAPON 9789 -#define S_LEARN_ARMOR 9790 -#define S_LEARN_HAMMER 39099 -#define S_LEARN_AXE 39098 -#define S_LEARN_SWORD 39097 - -#define S_UNLEARN_WEAPON 36436 -#define S_UNLEARN_ARMOR 36435 -#define S_UNLEARN_HAMMER 36441 -#define S_UNLEARN_AXE 36439 -#define S_UNLEARN_SWORD 36438 - -#define S_REP_ARMOR 17451 -#define S_REP_WEAPON 17452 - -#define REP_ARMOR 46 -#define REP_WEAPON 289 -#define REP_HAMMER 569 -#define REP_AXE 570 -#define REP_SWORD 571 - -#define S_DRAGON 10656 -#define S_ELEMENTAL 10658 -#define S_TRIBAL 10660 - -#define S_LEARN_DRAGON 10657 -#define S_LEARN_ELEMENTAL 10659 -#define S_LEARN_TRIBAL 10661 - -#define S_UNLEARN_DRAGON 36434 -#define S_UNLEARN_ELEMENTAL 36328 -#define S_UNLEARN_TRIBAL 36433 - -#define S_GOBLIN 20222 -#define S_GNOMISH 20219 - -#define S_LEARN_GOBLIN 20221 -#define S_LEARN_GNOMISH 20220 - -#define S_SPELLFIRE 26797 -#define S_MOONCLOTH 26798 -#define S_SHADOWEAVE 26801 - -#define S_LEARN_SPELLFIRE 26796 -#define S_LEARN_MOONCLOTH 26799 -#define S_LEARN_SHADOWEAVE 26800 - -#define S_UNLEARN_SPELLFIRE 41299 -#define S_UNLEARN_MOONCLOTH 41558 -#define S_UNLEARN_SHADOWEAVE 41559 - -#define S_TRANSMUTE 28672 -#define S_ELIXIR 28677 -#define S_POTION 28675 - -#define S_LEARN_TRANSMUTE 28674 -#define S_LEARN_ELIXIR 28678 -#define S_LEARN_POTION 28676 - -#define S_UNLEARN_TRANSMUTE 41565 -#define S_UNLEARN_ELIXIR 41564 -#define S_UNLEARN_POTION 41563 - -/*### -# formulas to calculate unlearning cost -###*/ - -int32 DoLearnCost(Player *player) //tailor, alchemy -{ - return 200000; -} - -int32 DoHighUnlearnCost(Player *player) //tailor, alchemy -{ - return 1500000; -} - -int32 DoMedUnlearnCost(Player *player) //blacksmith, leatherwork -{ - uint32 level = player->getLevel(); - if(level < 51) - return 250000; - else if (level < 66) - return 500000; - else - return 1000000; -} - -int32 DoLowUnlearnCost(Player *player) //blacksmith -{ - uint32 level = player->getLevel(); - if (level < 66) - return 50000; - else - return 100000; -} - -/*### -# unlearning related profession spells -###*/ - -bool EquippedOk(Player* player, uint32 spellId) -{ - SpellEntry const* spell = GetSpellStore()->LookupEntry(spellId); - - if( !spell ) - return false; - - for(int i=0; i<3; i++) - { - uint32 reqSpell = spell->EffectTriggerSpell[i]; - if( !reqSpell ) - continue; - - Item* pItem; - for(int j = EQUIPMENT_SLOT_START; j < EQUIPMENT_SLOT_END; j++) - { - pItem = player->GetItemByPos( INVENTORY_SLOT_BAG_0, j ); - if( pItem ) - if( pItem->GetProto()->RequiredSpell == reqSpell ) - { - //player has item equipped that require specialty. Not allow to unlearn, player has to unequip first - debug_log("SD2: player attempt to unlearn spell %u, but item %u is equipped.",reqSpell,pItem->GetProto()->ItemId); - return false; - } - } - } - return true; -} - -void ProfessionUnlearnSpells(Player *player, uint32 type) -{ - switch (type) - { - case 36436: // S_UNLEARN_WEAPON - player->removeSpell(36125); // Light Earthforged Blade - player->removeSpell(36128); // Light Emberforged Hammer - player->removeSpell(36126); // Light Skyforged Axe - break; - case 36435: // S_UNLEARN_ARMOR - player->removeSpell(36122); // Earthforged Leggings - player->removeSpell(36129); // Heavy Earthforged Breastplate - player->removeSpell(36130); // Stormforged Hauberk - player->removeSpell(34533); // Breastplate of Kings - player->removeSpell(34529); // Nether Chain Shirt - player->removeSpell(34534); // Bulwark of Kings - player->removeSpell(36257); // Bulwark of the Ancient Kings - player->removeSpell(36256); // Embrace of the Twisting Nether - player->removeSpell(34530); // Twisting Nether Chain Shirt - player->removeSpell(36124); // Windforged Leggings - break; - case 36441: // S_UNLEARN_HAMMER - player->removeSpell(36262); // Dragonstrike - player->removeSpell(34546); // Dragonmaw - player->removeSpell(34545); // Drakefist Hammer - player->removeSpell(36136); // Lavaforged Warhammer - player->removeSpell(34547); // Thunder - player->removeSpell(34567); // Deep Thunder - player->removeSpell(36263); // Stormherald - player->removeSpell(36137); // Great Earthforged Hammer - break; - case 36439: // S_UNLEARN_AXE - player->removeSpell(36260); // Wicked Edge of the Planes - player->removeSpell(34562); // Black Planar Edge - player->removeSpell(34541); // The Planar Edge - player->removeSpell(36134); // Stormforged Axe - player->removeSpell(36135); // Skyforged Great Axe - player->removeSpell(36261); // Bloodmoon - player->removeSpell(34543); // Lunar Crescent - player->removeSpell(34544); // Mooncleaver - break; - case 36438: // S_UNLEARN_SWORD - player->removeSpell(36258); // Blazefury - player->removeSpell(34537); // Blazeguard - player->removeSpell(34535); // Fireguard - player->removeSpell(36131); // Windforged Rapier - player->removeSpell(36133); // Stoneforged Claymore - player->removeSpell(34538); // Lionheart Blade - player->removeSpell(34540); // Lionheart Champion - player->removeSpell(36259); // Lionheart Executioner - break; - case 36434: // S_UNLEARN_DRAGON - player->removeSpell(36076); // Dragonstrike Leggings - player->removeSpell(36079); // Golden Dragonstrike Breastplate - player->removeSpell(35576); // Ebon Netherscale Belt - player->removeSpell(35577); // Ebon Netherscale Bracers - player->removeSpell(35575); // Ebon Netherscale Breastplate - player->removeSpell(35582); // Netherstrike Belt - player->removeSpell(35584); // Netherstrike Bracers - player->removeSpell(35580); // Netherstrike Breastplate - break; - case 36328: // S_UNLEARN_ELEMENTAL - player->removeSpell(36074); // Blackstorm Leggings - player->removeSpell(36077); // Primalstorm Breastplate - player->removeSpell(35590); // Primalstrike Belt - player->removeSpell(35591); // Primalstrike Bracers - player->removeSpell(35589); // Primalstrike Vest - break; - case 36433: // S_UNLEARN_TRIBAL - player->removeSpell(35585); // Windhawk Hauberk - player->removeSpell(35587); // Windhawk Belt - player->removeSpell(35588); // Windhawk Bracers - player->removeSpell(36075); // Wildfeather Leggings - player->removeSpell(36078); // Living Crystal Breastplate - break; - case 41299: // S_UNLEARN_SPELLFIRE - player->removeSpell(26752); // Spellfire Belt - player->removeSpell(26753); // Spellfire Gloves - player->removeSpell(26754); // Spellfire Robe - break; - case 41558: // S_UNLEARN_MOONCLOTH - player->removeSpell(26760); // Primal Mooncloth Belt - player->removeSpell(26761); // Primal Mooncloth Shoulders - player->removeSpell(26762); // Primal Mooncloth Robe - break; - case 41559: // S_UNLEARN_SHADOWEAVE - player->removeSpell(26756); // Frozen Shadoweave Shoulders - player->removeSpell(26757); // Frozen Shadoweave Boots - player->removeSpell(26758); // Frozen Shadoweave Robe - break; - } -} - -/*### -# start menues alchemy -###*/ - -bool HasAlchemySpell(Player *player) -{ - if(player->HasSpell(S_TRANSMUTE) || player->HasSpell(S_ELIXIR) || player->HasSpell(S_POTION)) - return true; - return false; -} - -bool GossipHello_npc_prof_alchemy(Player *player, Creature *_Creature) -{ - if (_Creature->isQuestGiver()) - player->PrepareQuestMenu( _Creature->GetGUID() ); - if (_Creature->isVendor()) - player->ADD_GOSSIP_ITEM(1, GOSSIP_TEXT_BROWSE_GOODS, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_TRADE); - if(_Creature->isTrainer()) - player->ADD_GOSSIP_ITEM(2, GOSSIP_TEXT_TRAIN, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_TRAIN); - - uint32 eCreature = _Creature->GetEntry(); - - if (player->HasSkill(SKILL_ALCHEMY) && player->GetBaseSkillValue(SKILL_ALCHEMY)>=350 && player->getLevel() > 67) - { - if (player->GetQuestRewardStatus(10899) || player->GetQuestRewardStatus(10902) || player->GetQuestRewardStatus(10897)) - { - switch (eCreature) - { - case 22427: //Zarevhi - if (!HasAlchemySpell(player)) - player->ADD_GOSSIP_ITEM( 0, GOSSIP_LEARN_TRANSMUTE, GOSSIP_SENDER_LEARN, GOSSIP_ACTION_INFO_DEF + 1); - if (player->HasSpell(S_TRANSMUTE)) - player->ADD_GOSSIP_ITEM( 0, GOSSIP_UNLEARN_TRANSMUTE, GOSSIP_SENDER_UNLEARN, GOSSIP_ACTION_INFO_DEF + 4); - break; - case 19052: //Lorokeem - if (!HasAlchemySpell(player)) - player->ADD_GOSSIP_ITEM( 0, GOSSIP_LEARN_ELIXIR, GOSSIP_SENDER_LEARN, GOSSIP_ACTION_INFO_DEF + 2); - if (player->HasSpell(S_ELIXIR)) - player->ADD_GOSSIP_ITEM( 0, GOSSIP_UNLEARN_ELIXIR, GOSSIP_SENDER_UNLEARN, GOSSIP_ACTION_INFO_DEF + 5); - break; - case 17909: //Lauranna Thar'well - if (!HasAlchemySpell(player)) - player->ADD_GOSSIP_ITEM( 0, GOSSIP_LEARN_POTION, GOSSIP_SENDER_LEARN, GOSSIP_ACTION_INFO_DEF + 3); - if (player->HasSpell(S_POTION)) - player->ADD_GOSSIP_ITEM( 0, GOSSIP_UNLEARN_POTION, GOSSIP_SENDER_UNLEARN, GOSSIP_ACTION_INFO_DEF + 6); - break; - } - } - } - - player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); - return true; -} - -void SendActionMenu_npc_prof_alchemy(Player *player, Creature *_Creature, uint32 action) -{ - switch(action) - { - case GOSSIP_ACTION_TRADE: - player->SEND_VENDORLIST( _Creature->GetGUID() ); - break; - case GOSSIP_ACTION_TRAIN: - player->SEND_TRAINERLIST( _Creature->GetGUID() ); - break; - //Learn Alchemy - case GOSSIP_ACTION_INFO_DEF + 1: - if(!player->HasSpell(S_TRANSMUTE) && player->GetMoney() >= DoLearnCost(player)) - { - player->CastSpell(player, S_LEARN_TRANSMUTE, true); - player->ModifyMoney(-DoLearnCost(player)); - } else - player->SendBuyError( BUY_ERR_NOT_ENOUGHT_MONEY, _Creature, 0, 0); - player->CLOSE_GOSSIP_MENU(); - break; - case GOSSIP_ACTION_INFO_DEF + 2: - if(!player->HasSpell(S_ELIXIR) && player->GetMoney() >= DoLearnCost(player)) - { - player->CastSpell(player, S_LEARN_ELIXIR, true); - player->ModifyMoney(-DoLearnCost(player)); - } else - player->SendBuyError( BUY_ERR_NOT_ENOUGHT_MONEY, _Creature, 0, 0); - player->CLOSE_GOSSIP_MENU(); - break; - case GOSSIP_ACTION_INFO_DEF + 3: - if(!player->HasSpell(S_POTION) && player->GetMoney() >= DoLearnCost(player)) - { - player->CastSpell(player, S_LEARN_POTION, true); - player->ModifyMoney(-DoLearnCost(player)); - } else - player->SendBuyError( BUY_ERR_NOT_ENOUGHT_MONEY, _Creature, 0, 0); - player->CLOSE_GOSSIP_MENU(); - break; - //Unlearn Alchemy - case GOSSIP_ACTION_INFO_DEF + 4: - if(player->GetMoney() >= DoHighUnlearnCost(player)) - { - _Creature->CastSpell(player, S_UNLEARN_TRANSMUTE, true); - player->ModifyMoney(-DoHighUnlearnCost(player)); - } else - player->SendBuyError( BUY_ERR_NOT_ENOUGHT_MONEY, _Creature, 0, 0); - player->CLOSE_GOSSIP_MENU(); - break; - case GOSSIP_ACTION_INFO_DEF + 5: - if(player->GetMoney() >= DoHighUnlearnCost(player)) - { - _Creature->CastSpell(player, S_UNLEARN_ELIXIR, true); - player->ModifyMoney(-DoHighUnlearnCost(player)); - } else - player->SendBuyError( BUY_ERR_NOT_ENOUGHT_MONEY, _Creature, 0, 0); - player->CLOSE_GOSSIP_MENU(); - break; - case GOSSIP_ACTION_INFO_DEF + 6: - if(player->GetMoney() >= DoHighUnlearnCost(player)) - { - _Creature->CastSpell(player, S_UNLEARN_POTION, true); - player->ModifyMoney(-DoHighUnlearnCost(player)); - } else - player->SendBuyError( BUY_ERR_NOT_ENOUGHT_MONEY, _Creature, 0, 0); - player->CLOSE_GOSSIP_MENU(); - break; - } -} - -void SendConfirmLearn_npc_prof_alchemy(Player *player, Creature *_Creature, uint32 action) -{ - if(action) - { - uint32 eCreature = _Creature->GetEntry(); - switch(eCreature) - { - case 22427: - player->ADD_GOSSIP_ITEM( 0, GOSSIP_LEARN_TRANSMUTE, GOSSIP_SENDER_CHECK, action); - //unknown textID () - player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); - break; - case 19052: - player->ADD_GOSSIP_ITEM( 0, GOSSIP_LEARN_ELIXIR, GOSSIP_SENDER_CHECK, action); - //unknown textID () - player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); - break; - case 17909: - player->ADD_GOSSIP_ITEM( 0, GOSSIP_LEARN_POTION, GOSSIP_SENDER_CHECK, action); - //unknown textID () - player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); - break; - } - } -} - -void SendConfirmUnlearn_npc_prof_alchemy(Player *player, Creature *_Creature, uint32 action) -{ - if(action) - { - uint32 eCreature = _Creature->GetEntry(); - switch(eCreature) - { - case 22427: //Zarevhi - player->ADD_GOSSIP_ITEM_EXTENDED( 0, GOSSIP_UNLEARN_TRANSMUTE, GOSSIP_SENDER_CHECK, action, BOX_UNLEARN_ALCHEMY_SPEC, DoHighUnlearnCost(player)); - //unknown textID () - player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); - break; - case 19052: //Lorokeem - player->ADD_GOSSIP_ITEM_EXTENDED( 0, GOSSIP_UNLEARN_ELIXIR, GOSSIP_SENDER_CHECK, action, BOX_UNLEARN_ALCHEMY_SPEC, DoHighUnlearnCost(player)); - //unknown textID () - player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); - break; - case 17909: //Lauranna Thar'well - player->ADD_GOSSIP_ITEM_EXTENDED( 0, GOSSIP_UNLEARN_POTION, GOSSIP_SENDER_CHECK, action, BOX_UNLEARN_ALCHEMY_SPEC, DoHighUnlearnCost(player)); - //unknown textID () - player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); - break; - } - } -} - -bool GossipSelect_npc_prof_alchemy(Player *player, Creature *_Creature, uint32 sender, uint32 action ) -{ - switch(sender) - { - case GOSSIP_SENDER_MAIN: SendActionMenu_npc_prof_alchemy(player, _Creature, action); break; - case GOSSIP_SENDER_LEARN: SendConfirmLearn_npc_prof_alchemy(player, _Creature, action); break; - case GOSSIP_SENDER_UNLEARN: SendConfirmUnlearn_npc_prof_alchemy(player, _Creature, action); break; - case GOSSIP_SENDER_CHECK: SendActionMenu_npc_prof_alchemy(player, _Creature, action); break; - } - return true; -} - -/*### -# start menues blacksmith -###*/ - -bool HasWeaponSub(Player *player) -{ - if (player->HasSpell(S_HAMMER) || player->HasSpell(S_AXE) || player->HasSpell(S_SWORD)) - return true; - return false; -} - -bool GossipHello_npc_prof_blacksmith(Player *player, Creature *_Creature) -{ - if (_Creature->isQuestGiver()) - player->PrepareQuestMenu( _Creature->GetGUID() ); - if (_Creature->isVendor()) - player->ADD_GOSSIP_ITEM(1, GOSSIP_TEXT_BROWSE_GOODS, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_TRADE); - if(_Creature->isTrainer()) - player->ADD_GOSSIP_ITEM(2, GOSSIP_TEXT_TRAIN, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_TRAIN); - - uint32 eCreature = _Creature->GetEntry(); - //WEAPONSMITH & ARMORSMITH - if(player->GetBaseSkillValue(SKILL_BLACKSMITHING)>=225) - { - switch (eCreature) - { - case 11145: //Myolor Sunderfury - case 11176: //Krathok Moltenfist - if(!player->HasSpell(S_ARMOR) && !player->HasSpell(S_WEAPON) && player->GetReputationRank(REP_ARMOR) == REP_FRIENDLY) - player->ADD_GOSSIP_ITEM( 0, GOSSIP_ARMOR_LEARN, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); - if(!player->HasSpell(S_WEAPON) && !player->HasSpell(S_ARMOR) && player->GetReputationRank(REP_WEAPON) == REP_FRIENDLY) - player->ADD_GOSSIP_ITEM( 0, GOSSIP_WEAPON_LEARN, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2); - break; - case 11146: //Ironus Coldsteel - case 11178: //Borgosh Corebender - if(player->HasSpell(S_WEAPON)) - player->ADD_GOSSIP_ITEM( 0, GOSSIP_WEAPON_UNLEARN, GOSSIP_SENDER_UNLEARN, GOSSIP_ACTION_INFO_DEF + 3); - break; - case 5164: //Grumnus Steelshaper - case 11177: //Okothos Ironrager - if(player->HasSpell(S_ARMOR)) - player->ADD_GOSSIP_ITEM( 0, GOSSIP_ARMOR_UNLEARN, GOSSIP_SENDER_UNLEARN, GOSSIP_ACTION_INFO_DEF + 4); - break; - } - } - //WEAPONSMITH SPEC - if(player->HasSpell(S_WEAPON) && player->getLevel() > 49 && player->GetBaseSkillValue(SKILL_BLACKSMITHING)>=250) - { - switch (eCreature) - { - case 11191: //Lilith the Lithe - if(!HasWeaponSub(player)) - player->ADD_GOSSIP_ITEM( 0, GOSSIP_LEARN_HAMMER, GOSSIP_SENDER_LEARN, GOSSIP_ACTION_INFO_DEF + 5); - if(player->HasSpell(S_HAMMER)) - player->ADD_GOSSIP_ITEM( 0, GOSSIP_UNLEARN_HAMMER, GOSSIP_SENDER_UNLEARN, GOSSIP_ACTION_INFO_DEF + 8); - break; - case 11192: //Kilram - if(!HasWeaponSub(player)) - player->ADD_GOSSIP_ITEM( 0, GOSSIP_LEARN_AXE, GOSSIP_SENDER_LEARN, GOSSIP_ACTION_INFO_DEF + 6); - if(player->HasSpell(S_AXE)) - player->ADD_GOSSIP_ITEM( 0, GOSSIP_UNLEARN_AXE, GOSSIP_SENDER_UNLEARN, GOSSIP_ACTION_INFO_DEF + 9); - break; - case 11193: //Seril Scourgebane - if(!HasWeaponSub(player)) - player->ADD_GOSSIP_ITEM( 0, GOSSIP_LEARN_SWORD, GOSSIP_SENDER_LEARN, GOSSIP_ACTION_INFO_DEF + 7); - if(player->HasSpell(S_SWORD)) - player->ADD_GOSSIP_ITEM( 0, GOSSIP_UNLEARN_SWORD, GOSSIP_SENDER_UNLEARN, GOSSIP_ACTION_INFO_DEF + 10); - break; - } - } - - player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); - return true; -} - -void SendActionMenu_npc_prof_blacksmith(Player *player, Creature *_Creature, uint32 action) -{ - switch(action) - { - case GOSSIP_ACTION_TRADE: - player->SEND_VENDORLIST( _Creature->GetGUID() ); - break; - case GOSSIP_ACTION_TRAIN: - player->SEND_TRAINERLIST( _Creature->GetGUID() ); - break; - //Learn Armor/Weapon - case GOSSIP_ACTION_INFO_DEF + 1: - if(!player->HasSpell(S_ARMOR)) - { - player->CastSpell(player, S_LEARN_ARMOR, true); - //_Creature->CastSpell(player, S_REP_ARMOR, true); - } - player->CLOSE_GOSSIP_MENU(); - break; - case GOSSIP_ACTION_INFO_DEF + 2: - if(!player->HasSpell(S_WEAPON)) - { - player->CastSpell(player, S_LEARN_WEAPON, true); - //_Creature->CastSpell(player, S_REP_WEAPON, true); - } - player->CLOSE_GOSSIP_MENU(); - break; - //Unlearn Armor/Weapon - case GOSSIP_ACTION_INFO_DEF + 3: - if(HasWeaponSub(player)) - { - //unknown textID (TALK_MUST_UNLEARN_WEAPON) - player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); - //Temporary, not offilike - _Creature->MonsterSay(TALK_MUST_UNLEARN_WEAPON,0,player->GetGUID()); - } - else if( EquippedOk(player,S_UNLEARN_WEAPON) ) - { - if( player->GetMoney() >= DoLowUnlearnCost(player) ) - { - player->CastSpell(player, S_UNLEARN_WEAPON, true); - ProfessionUnlearnSpells(player, S_UNLEARN_WEAPON); - player->ModifyMoney(-DoLowUnlearnCost(player)); - _Creature->CastSpell(player, S_REP_ARMOR, true); - player->CLOSE_GOSSIP_MENU(); - } else - player->SendBuyError( BUY_ERR_NOT_ENOUGHT_MONEY, _Creature, 0, 0); - } - else - { - player->SendEquipError(EQUIP_ERR_CANT_DO_RIGHT_NOW,NULL,NULL); - player->CLOSE_GOSSIP_MENU(); - } - break; - case GOSSIP_ACTION_INFO_DEF + 4: - if( EquippedOk(player,S_UNLEARN_ARMOR) ) - { - if( player->GetMoney() >= DoLowUnlearnCost(player) ) - { - player->CastSpell(player, S_UNLEARN_ARMOR, true); - ProfessionUnlearnSpells(player, S_UNLEARN_ARMOR); - player->ModifyMoney(-DoLowUnlearnCost(player)); - _Creature->CastSpell(player, S_REP_WEAPON, true); - } else - player->SendBuyError( BUY_ERR_NOT_ENOUGHT_MONEY, _Creature, 0, 0); - } else - player->SendEquipError(EQUIP_ERR_CANT_DO_RIGHT_NOW,NULL,NULL); - player->CLOSE_GOSSIP_MENU(); - break; - //Learn Hammer/Axe/Sword - case GOSSIP_ACTION_INFO_DEF + 5: - player->CastSpell(player, S_LEARN_HAMMER, true); - player->CLOSE_GOSSIP_MENU(); - break; - case GOSSIP_ACTION_INFO_DEF + 6: - player->CastSpell(player, S_LEARN_AXE, true); - player->CLOSE_GOSSIP_MENU(); - break; - case GOSSIP_ACTION_INFO_DEF + 7: - player->CastSpell(player, S_LEARN_SWORD, true); - player->CLOSE_GOSSIP_MENU(); - break; - //Unlearn Hammer/Axe/Sword - case GOSSIP_ACTION_INFO_DEF + 8: - if( EquippedOk(player,S_UNLEARN_HAMMER) ) - { - if( player->GetMoney() >= DoMedUnlearnCost(player)) - { - player->CastSpell(player, S_UNLEARN_HAMMER, true); - ProfessionUnlearnSpells(player, S_UNLEARN_HAMMER); - player->ModifyMoney(-DoMedUnlearnCost(player)); - } else - player->SendBuyError( BUY_ERR_NOT_ENOUGHT_MONEY, _Creature, 0, 0); - } else - player->SendEquipError(EQUIP_ERR_CANT_DO_RIGHT_NOW,NULL,NULL); - player->CLOSE_GOSSIP_MENU(); - break; - case GOSSIP_ACTION_INFO_DEF + 9: - if( EquippedOk(player,S_UNLEARN_AXE) ) - { - if( player->GetMoney() >= DoMedUnlearnCost(player)) - { - player->CastSpell(player, S_UNLEARN_AXE, true); - ProfessionUnlearnSpells(player, S_UNLEARN_AXE); - player->ModifyMoney(-DoMedUnlearnCost(player)); - } else - player->SendBuyError( BUY_ERR_NOT_ENOUGHT_MONEY, _Creature, 0, 0); - } else - player->SendEquipError(EQUIP_ERR_CANT_DO_RIGHT_NOW,NULL,NULL); - player->CLOSE_GOSSIP_MENU(); - break; - case GOSSIP_ACTION_INFO_DEF + 10: - if( EquippedOk(player,S_UNLEARN_SWORD) ) - { - if( player->GetMoney() >= DoMedUnlearnCost(player)) - { - player->CastSpell(player, S_UNLEARN_SWORD, true); - ProfessionUnlearnSpells(player, S_UNLEARN_SWORD); - player->ModifyMoney(-DoMedUnlearnCost(player)); - } else - player->SendBuyError( BUY_ERR_NOT_ENOUGHT_MONEY, _Creature, 0, 0); - } else - player->SendEquipError(EQUIP_ERR_CANT_DO_RIGHT_NOW,NULL,NULL); - player->CLOSE_GOSSIP_MENU(); - break; - } -} - -void SendConfirmLearn_npc_prof_blacksmith(Player *player, Creature *_Creature, uint32 action) -{ - if(action) - { - uint32 eCreature = _Creature->GetEntry(); - switch(eCreature) - { - case 11191: - player->ADD_GOSSIP_ITEM( 0, GOSSIP_LEARN_HAMMER, GOSSIP_SENDER_CHECK, action); - //unknown textID (TALK_HAMMER_LEARN) - player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); - break; - case 11192: - player->ADD_GOSSIP_ITEM( 0, GOSSIP_LEARN_AXE, GOSSIP_SENDER_CHECK, action); - //unknown textID (TALK_AXE_LEARN) - player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); - break; - case 11193: - player->ADD_GOSSIP_ITEM( 0, GOSSIP_LEARN_SWORD, GOSSIP_SENDER_CHECK, action); - //unknown textID (TALK_SWORD_LEARN) - player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); - break; - } - } -} - -void SendConfirmUnlearn_npc_prof_blacksmith(Player *player, Creature *_Creature, uint32 action) -{ - if(action) - { - uint32 eCreature = _Creature->GetEntry(); - switch(eCreature) - { - case 11146: //Ironus Coldsteel - case 11178: //Borgosh Corebender - case 5164: //Grumnus Steelshaper - case 11177: //Okothos Ironrager - player->ADD_GOSSIP_ITEM_EXTENDED( 0, GOSSIP_UNLEARN_SMITH_SPEC, GOSSIP_SENDER_CHECK, action, BOX_UNLEARN_ARMORORWEAPON, DoLowUnlearnCost(player)); - //unknown textID (TALK_UNLEARN_AXEORWEAPON) - player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); - break; - - case 11191: - player->ADD_GOSSIP_ITEM_EXTENDED( 0, GOSSIP_UNLEARN_HAMMER, GOSSIP_SENDER_CHECK, action, BOX_UNLEARN_WEAPON_SPEC, DoMedUnlearnCost(player)); - //unknown textID (TALK_HAMMER_UNLEARN) - player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); - break; - case 11192: - player->ADD_GOSSIP_ITEM_EXTENDED( 0, GOSSIP_UNLEARN_AXE, GOSSIP_SENDER_CHECK, action, BOX_UNLEARN_WEAPON_SPEC, DoMedUnlearnCost(player)); - //unknown textID (TALK_AXE_UNLEARN) - player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); - break; - case 11193: - player->ADD_GOSSIP_ITEM_EXTENDED( 0, GOSSIP_UNLEARN_SWORD, GOSSIP_SENDER_CHECK, action, BOX_UNLEARN_WEAPON_SPEC, DoMedUnlearnCost(player)); - //unknown textID (TALK_SWORD_UNLEARN) - player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); - break; - } - } -} - -bool GossipSelect_npc_prof_blacksmith(Player *player, Creature *_Creature, uint32 sender, uint32 action ) -{ - switch(sender) - { - case GOSSIP_SENDER_MAIN: SendActionMenu_npc_prof_blacksmith(player, _Creature, action); break; - case GOSSIP_SENDER_LEARN: SendConfirmLearn_npc_prof_blacksmith(player, _Creature, action); break; - case GOSSIP_SENDER_UNLEARN: SendConfirmUnlearn_npc_prof_blacksmith(player, _Creature, action); break; - case GOSSIP_SENDER_CHECK: SendActionMenu_npc_prof_blacksmith(player, _Creature, action); break; - } - return true; -} - -/*bool QuestComplete_npc_prof_blacksmith( Player *player, Creature *_Creature, Quest const *_Quest ) -{ - if ( (_Quest->GetQuestId() == 5283) || (_Quest->GetQuestId() == 5301) ) //armorsmith - _Creature->CastSpell(player, 17451, true); - - if ( (_Quest->GetQuestId() == 5284) || (_Quest->GetQuestId() == 5302) ) //weaponsmith - _Creature->CastSpell(player, 17452, true); - - return true; -}*/ - -/*### -# start menues leatherworking -###*/ - -bool GossipHello_npc_prof_leather(Player *player, Creature *_Creature) -{ - if (_Creature->isQuestGiver()) - player->PrepareQuestMenu( _Creature->GetGUID() ); - if (_Creature->isVendor()) - player->ADD_GOSSIP_ITEM(1, GOSSIP_TEXT_BROWSE_GOODS, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_TRADE); - if(_Creature->isTrainer()) - player->ADD_GOSSIP_ITEM(2, GOSSIP_TEXT_TRAIN, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_TRAIN); - - uint32 eCreature = _Creature->GetEntry(); - - if(player->HasSkill(SKILL_LEATHERWORKING) && player->GetBaseSkillValue(SKILL_LEATHERWORKING)>=250 && player->getLevel() > 49 ) - { - switch (eCreature) - { - case 7866: //Peter Galen - case 7867: //Thorkaf Dragoneye - if(player->HasSpell(S_DRAGON)) - player->ADD_GOSSIP_ITEM( 0, GOSSIP_UNLEARN_DRAGON, GOSSIP_SENDER_UNLEARN, GOSSIP_ACTION_INFO_DEF + 1); - break; - case 7868: //Sarah Tanner - case 7869: //Brumn Winterhoof - if(player->HasSpell(S_ELEMENTAL)) - player->ADD_GOSSIP_ITEM( 0, GOSSIP_UNLEARN_ELEMENTAL, GOSSIP_SENDER_UNLEARN, GOSSIP_ACTION_INFO_DEF + 2); - break; - case 7870: //Caryssia Moonhunter - case 7871: //Se'Jib - if(player->HasSpell(S_TRIBAL)) - player->ADD_GOSSIP_ITEM( 0, GOSSIP_UNLEARN_TRIBAL, GOSSIP_SENDER_UNLEARN, GOSSIP_ACTION_INFO_DEF + 3); - break; - } - } - - player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); - return true; -} - -void SendActionMenu_npc_prof_leather(Player *player, Creature *_Creature, uint32 action) -{ - switch(action) - { - case GOSSIP_ACTION_TRADE: - player->SEND_VENDORLIST( _Creature->GetGUID() ); - break; - case GOSSIP_ACTION_TRAIN: - player->SEND_TRAINERLIST( _Creature->GetGUID() ); - break; - //Unlearn Leather - case GOSSIP_ACTION_INFO_DEF + 1: - if( EquippedOk(player,S_UNLEARN_DRAGON) ) - { - if( player->GetMoney() >= DoMedUnlearnCost(player) ) - { - player->CastSpell(player, S_UNLEARN_DRAGON, true); - ProfessionUnlearnSpells(player, S_UNLEARN_DRAGON); - player->ModifyMoney(-DoMedUnlearnCost(player)); - } else - player->SendBuyError( BUY_ERR_NOT_ENOUGHT_MONEY, _Creature, 0, 0); - } else - player->SendEquipError(EQUIP_ERR_CANT_DO_RIGHT_NOW,NULL,NULL); - player->CLOSE_GOSSIP_MENU(); - break; - case GOSSIP_ACTION_INFO_DEF + 2: - if( EquippedOk(player,S_UNLEARN_ELEMENTAL) ) - { - if( player->GetMoney() >= DoMedUnlearnCost(player) ) - { - player->CastSpell(player, S_UNLEARN_ELEMENTAL, true); - ProfessionUnlearnSpells(player, S_UNLEARN_ELEMENTAL); - player->ModifyMoney(-DoMedUnlearnCost(player)); - } else - player->SendBuyError( BUY_ERR_NOT_ENOUGHT_MONEY, _Creature, 0, 0); - } else - player->SendEquipError(EQUIP_ERR_CANT_DO_RIGHT_NOW,NULL,NULL); - player->CLOSE_GOSSIP_MENU(); - break; - case GOSSIP_ACTION_INFO_DEF + 3: - if( EquippedOk(player,S_UNLEARN_TRIBAL) ) - { - if(player->GetMoney() >= DoMedUnlearnCost(player)) - { - player->CastSpell(player, S_UNLEARN_TRIBAL, true); - ProfessionUnlearnSpells(player, S_UNLEARN_TRIBAL); - player->ModifyMoney(-DoMedUnlearnCost(player)); - } else - player->SendBuyError( BUY_ERR_NOT_ENOUGHT_MONEY, _Creature, 0, 0); - } else - player->SendEquipError(EQUIP_ERR_CANT_DO_RIGHT_NOW,NULL,NULL); - player->CLOSE_GOSSIP_MENU(); - break; - } -} - -void SendConfirmUnlearn_npc_prof_leather(Player *player, Creature *_Creature, uint32 action) -{ - if(action) - { - uint32 eCreature = _Creature->GetEntry(); - switch(eCreature) - { - case 7866: //Peter Galen - case 7867: //Thorkaf Dragoneye - player->ADD_GOSSIP_ITEM_EXTENDED( 0, GOSSIP_UNLEARN_DRAGON, GOSSIP_SENDER_CHECK, action, BOX_UNLEARN_LEATHER_SPEC, DoMedUnlearnCost(player)); - //unknown textID () - player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); - break; - case 7868: //Sarah Tanner - case 7869: //Brumn Winterhoof - player->ADD_GOSSIP_ITEM_EXTENDED( 0, GOSSIP_UNLEARN_ELEMENTAL, GOSSIP_SENDER_CHECK, action, BOX_UNLEARN_LEATHER_SPEC, DoMedUnlearnCost(player)); - //unknown textID () - player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); - break; - case 7870: //Caryssia Moonhunter - case 7871: //Se'Jib - player->ADD_GOSSIP_ITEM_EXTENDED( 0, GOSSIP_UNLEARN_TRIBAL, GOSSIP_SENDER_CHECK, action, BOX_UNLEARN_LEATHER_SPEC, DoMedUnlearnCost(player)); - //unknown textID () - player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); - break; - } - } -} - -bool GossipSelect_npc_prof_leather(Player *player, Creature *_Creature, uint32 sender, uint32 action ) -{ - switch(sender) - { - case GOSSIP_SENDER_MAIN: SendActionMenu_npc_prof_leather(player, _Creature, action); break; - case GOSSIP_SENDER_UNLEARN: SendConfirmUnlearn_npc_prof_leather(player, _Creature, action); break; - case GOSSIP_SENDER_CHECK: SendActionMenu_npc_prof_leather(player, _Creature, action); break; - } - return true; -} - -/*### -# start menues tailoring -###*/ - -bool HasTailorSpell(Player *player) -{ - if (player->HasSpell(S_MOONCLOTH) || player->HasSpell(S_SHADOWEAVE) || player->HasSpell(S_SPELLFIRE)) - return true; - return false; -} - -bool GossipHello_npc_prof_tailor(Player *player, Creature *_Creature) -{ - if (_Creature->isQuestGiver()) - player->PrepareQuestMenu( _Creature->GetGUID() ); - if (_Creature->isVendor()) - player->ADD_GOSSIP_ITEM(1, GOSSIP_TEXT_BROWSE_GOODS, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_TRADE); - if (_Creature->isTrainer()) - player->ADD_GOSSIP_ITEM(2, GOSSIP_TEXT_TRAIN, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_TRAIN); - - uint32 eCreature = _Creature->GetEntry(); - //TAILORING SPEC - if (player->HasSkill(SKILL_TAILORING) && player->GetBaseSkillValue(SKILL_TAILORING)>=350 && player->getLevel() > 59) - { - if (player->GetQuestRewardStatus(10831) || player->GetQuestRewardStatus(10832) || player->GetQuestRewardStatus(10833)) - { - switch (eCreature) - { - case 22213: //Gidge Spellweaver - if (!HasTailorSpell(player)) - player->ADD_GOSSIP_ITEM( 0, GOSSIP_LEARN_SPELLFIRE, GOSSIP_SENDER_LEARN, GOSSIP_ACTION_INFO_DEF + 1); - if (player->HasSpell(S_SPELLFIRE)) - player->ADD_GOSSIP_ITEM( 0, GOSSIP_UNLEARN_SPELLFIRE, GOSSIP_SENDER_UNLEARN, GOSSIP_ACTION_INFO_DEF + 4); - break; - case 22208: //Nasmara Moonsong - if (!HasTailorSpell(player)) - player->ADD_GOSSIP_ITEM( 0, GOSSIP_LEARN_MOONCLOTH, GOSSIP_SENDER_LEARN, GOSSIP_ACTION_INFO_DEF + 2); - if (player->HasSpell(S_MOONCLOTH)) - player->ADD_GOSSIP_ITEM( 0, GOSSIP_UNLEARN_MOONCLOTH, GOSSIP_SENDER_UNLEARN, GOSSIP_ACTION_INFO_DEF + 5); - break; - case 22212: //Andrion Darkspinner - if (!HasTailorSpell(player)) - player->ADD_GOSSIP_ITEM( 0, GOSSIP_LEARN_SHADOWEAVE, GOSSIP_SENDER_LEARN, GOSSIP_ACTION_INFO_DEF + 3); - if (player->HasSpell(S_SHADOWEAVE)) - player->ADD_GOSSIP_ITEM( 0, GOSSIP_UNLEARN_SHADOWEAVE, GOSSIP_SENDER_UNLEARN, GOSSIP_ACTION_INFO_DEF + 6); - break; - } - } - } - - player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); - return true; -} - -void SendActionMenu_npc_prof_tailor(Player *player, Creature *_Creature, uint32 action) -{ - switch(action) - { - case GOSSIP_ACTION_TRADE: - player->SEND_VENDORLIST( _Creature->GetGUID() ); - break; - case GOSSIP_ACTION_TRAIN: - player->SEND_TRAINERLIST( _Creature->GetGUID() ); - break; - //Learn Tailor - case GOSSIP_ACTION_INFO_DEF + 1: - if(!player->HasSpell(S_SPELLFIRE) && player->GetMoney() >= DoLearnCost(player)) - { - player->CastSpell(player, S_LEARN_SPELLFIRE, true); - player->ModifyMoney(-DoLearnCost(player)); - } else - player->SendBuyError( BUY_ERR_NOT_ENOUGHT_MONEY, _Creature, 0, 0); - player->CLOSE_GOSSIP_MENU(); - break; - case GOSSIP_ACTION_INFO_DEF + 2: - if(!player->HasSpell(S_MOONCLOTH) && player->GetMoney() >= DoLearnCost(player)) - { - player->CastSpell(player, S_LEARN_MOONCLOTH, true); - player->ModifyMoney(-DoLearnCost(player)); - } else - player->SendBuyError( BUY_ERR_NOT_ENOUGHT_MONEY, _Creature, 0, 0); - player->CLOSE_GOSSIP_MENU(); - break; - case GOSSIP_ACTION_INFO_DEF + 3: - if(!player->HasSpell(S_SHADOWEAVE) && player->GetMoney() >= DoLearnCost(player)) - { - player->CastSpell(player, S_LEARN_SHADOWEAVE, true); - player->ModifyMoney(-DoLearnCost(player)); - } else - player->SendBuyError( BUY_ERR_NOT_ENOUGHT_MONEY, _Creature, 0, 0); - player->CLOSE_GOSSIP_MENU(); - break; - //Unlearn Tailor - case GOSSIP_ACTION_INFO_DEF + 4: - if( EquippedOk(player,S_UNLEARN_SPELLFIRE) ) - { - if( player->GetMoney() >= DoHighUnlearnCost(player) ) - { - player->CastSpell(player, S_UNLEARN_SPELLFIRE, true); - ProfessionUnlearnSpells(player, S_UNLEARN_SPELLFIRE); - player->ModifyMoney(-DoHighUnlearnCost(player)); - } else - player->SendBuyError( BUY_ERR_NOT_ENOUGHT_MONEY, _Creature, 0, 0); - } else - player->SendEquipError(EQUIP_ERR_CANT_DO_RIGHT_NOW,NULL,NULL); - player->CLOSE_GOSSIP_MENU(); - break; - case GOSSIP_ACTION_INFO_DEF + 5: - if( EquippedOk(player,S_UNLEARN_MOONCLOTH) ) - { - if( player->GetMoney() >= DoHighUnlearnCost(player) ) - { - player->CastSpell(player, S_UNLEARN_MOONCLOTH, true); - ProfessionUnlearnSpells(player, S_UNLEARN_MOONCLOTH); - player->ModifyMoney(-DoHighUnlearnCost(player)); - } else - player->SendBuyError( BUY_ERR_NOT_ENOUGHT_MONEY, _Creature, 0, 0); - } else - player->SendEquipError(EQUIP_ERR_CANT_DO_RIGHT_NOW,NULL,NULL); - player->CLOSE_GOSSIP_MENU(); - break; - case GOSSIP_ACTION_INFO_DEF + 6: - if( EquippedOk(player,S_UNLEARN_SHADOWEAVE) ) - { - if( player->GetMoney() >= DoHighUnlearnCost(player) ) - { - player->CastSpell(player, S_UNLEARN_SHADOWEAVE, true); - ProfessionUnlearnSpells(player, S_UNLEARN_SHADOWEAVE); - player->ModifyMoney(-DoHighUnlearnCost(player)); - } else - player->SendBuyError( BUY_ERR_NOT_ENOUGHT_MONEY, _Creature, 0, 0); - } else - player->SendEquipError(EQUIP_ERR_CANT_DO_RIGHT_NOW,NULL,NULL); - player->CLOSE_GOSSIP_MENU(); - break; - } -} - -void SendConfirmLearn_npc_prof_tailor(Player *player, Creature *_Creature, uint32 action) -{ - if(action) - { - uint32 eCreature = _Creature->GetEntry(); - switch(eCreature) - { - case 22213: - player->ADD_GOSSIP_ITEM( 0, GOSSIP_LEARN_SPELLFIRE, GOSSIP_SENDER_CHECK, action); - //unknown textID () - player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); - break; - case 22208: - player->ADD_GOSSIP_ITEM( 0, GOSSIP_LEARN_MOONCLOTH, GOSSIP_SENDER_CHECK, action); - //unknown textID () - player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); - break; - case 22212: - player->ADD_GOSSIP_ITEM( 0, GOSSIP_LEARN_SHADOWEAVE, GOSSIP_SENDER_CHECK, action); - //unknown textID () - player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); - break; - } - } -} - -void SendConfirmUnlearn_npc_prof_tailor(Player *player, Creature *_Creature, uint32 action) -{ - if(action) - { - uint32 eCreature = _Creature->GetEntry(); - switch(eCreature) - { - case 22213: //Gidge Spellweaver - player->ADD_GOSSIP_ITEM_EXTENDED( 0, GOSSIP_UNLEARN_SPELLFIRE, GOSSIP_SENDER_CHECK, action, BOX_UNLEARN_TAILOR_SPEC, DoHighUnlearnCost(player)); - //unknown textID () - player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); - break; - case 22208: //Nasmara Moonsong - player->ADD_GOSSIP_ITEM_EXTENDED( 0, GOSSIP_UNLEARN_MOONCLOTH, GOSSIP_SENDER_CHECK, action, BOX_UNLEARN_TAILOR_SPEC, DoHighUnlearnCost(player)); - //unknown textID () - player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); - break; - case 22212: //Andrion Darkspinner - player->ADD_GOSSIP_ITEM_EXTENDED( 0, GOSSIP_UNLEARN_SHADOWEAVE, GOSSIP_SENDER_CHECK, action,BOX_UNLEARN_TAILOR_SPEC, DoHighUnlearnCost(player)); - //unknown textID () - player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); - break; - } - } -} - -bool GossipSelect_npc_prof_tailor(Player *player, Creature *_Creature, uint32 sender, uint32 action ) -{ - switch(sender) - { - case GOSSIP_SENDER_MAIN: SendActionMenu_npc_prof_tailor(player, _Creature, action); break; - case GOSSIP_SENDER_LEARN: SendConfirmLearn_npc_prof_tailor(player, _Creature, action); break; - case GOSSIP_SENDER_UNLEARN: SendConfirmUnlearn_npc_prof_tailor(player, _Creature, action); break; - case GOSSIP_SENDER_CHECK: SendActionMenu_npc_prof_tailor(player, _Creature, action); break; - } - return true; -} - -/*### -# start menues for GO (engineering and leatherworking) -###*/ - -/*bool GOHello_go_soothsaying_for_dummies(Player *player, GameObject* _GO) -{ - player->PlayerTalkClass->GetGossipMenu()->AddMenuItem(0,GOSSIP_LEARN_DRAGON, GOSSIP_SENDER_INFO, GOSSIP_ACTION_INFO_DEF, "", 0); - - player->SEND_GOSSIP_MENU(5584, _GO->GetGUID()); - - return true; -}*/ - -/*### -# -###*/ - -void AddSC_npc_professions() -{ - Script *newscript; - - newscript = new Script; - newscript->Name="npc_prof_alchemy"; - newscript->pGossipHello = &GossipHello_npc_prof_alchemy; - newscript->pGossipSelect = &GossipSelect_npc_prof_alchemy; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="npc_prof_blacksmith"; - newscript->pGossipHello = &GossipHello_npc_prof_blacksmith; - newscript->pGossipSelect = &GossipSelect_npc_prof_blacksmith; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="npc_prof_leather"; - newscript->pGossipHello = &GossipHello_npc_prof_leather; - newscript->pGossipSelect = &GossipSelect_npc_prof_leather; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="npc_prof_tailor"; - newscript->pGossipHello = &GossipHello_npc_prof_tailor; - newscript->pGossipSelect = &GossipSelect_npc_prof_tailor; - m_scripts[nrscripts++] = newscript; - - /*newscript = new Script; - newscript->Name="go_soothsaying_for_dummies"; - newscript->pGOHello = &GOHello_go_soothsaying_for_dummies; - //newscript->pGossipSelect = &GossipSelect_go_soothsaying_for_dummies; - m_scripts[nrscripts++] = newscript;*/ -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Npc_Professions +SD%Complete: 80 +SDComment: Provides learn/unlearn/relearn-options for professions. Not supported: Unlearn engineering, re-learn engineering, re-learn leatherworking. +SDCategory: NPCs +EndScriptData */ + +#include "precompiled.h" + +/* +A few notes for future developement: +- A full implementation of gossip for GO's is required. They must have the same scripting capabilities as creatures. Basically, +there is no difference here (except that default text is chosen with `gameobject_template`.`data3` (for GO type2, different dataN for a few others) +- It's possible blacksmithing still require some tweaks and adjustments due to the way we _have_ to use reputation. +*/ + +/* +-- UPDATE `gameobject_template` SET `ScriptName` = 'go_soothsaying_for_dummies' WHERE `entry` = 177226; +*/ + +/*### +# to be removed from here (->ncp_text). This is data for database projects. +###*/ +#define TALK_MUST_UNLEARN_WEAPON "You must forget your weapon type specialty before I can help you. Go to Everlook in Winterspring and seek help there." + +#define TALK_HAMMER_LEARN "Ah, a seasoned veteran you once were. I know you are capable, you merely need to ask and I shall teach you the way of the hammersmith." +#define TALK_AXE_LEARN "Ah, a seasoned veteran you once were. I know you are capable, you merely need to ask and I shall teach you the way of the axesmith." +#define TALK_SWORD_LEARN "Ah, a seasoned veteran you once were. I know you are capable, you merely need to ask and I shall teach you the way of the swordsmith." + +#define TALK_HAMMER_UNLEARN "Forgetting your Hammersmithing skill is not something to do lightly. If you choose to abandon it you will forget all recipes that require Hammersmithing to create!" +#define TALK_AXE_UNLEARN "Forgetting your Axesmithing skill is not something to do lightly. If you choose to abandon it you will forget all recipes that require Axesmithing to create!" +#define TALK_SWORD_UNLEARN "Forgetting your Swordsmithing skill is not something to do lightly. If you choose to abandon it you will forget all recipes that require Swordsmithing to create!" + +/*### +# generic defines +###*/ + +#define GOSSIP_SENDER_LEARN 50 +#define GOSSIP_SENDER_UNLEARN 51 +#define GOSSIP_SENDER_CHECK 52 + +/*### +# gossip item and box texts +###*/ + +#define GOSSIP_LEARN_POTION "Please teach me how to become a Master of Potions, Lauranna" +#define GOSSIP_UNLEARN_POTION "I wish to unlearn Potion Mastery" +#define GOSSIP_LEARN_TRANSMUTE "Please teach me how to become a Master of Transmutations, Zarevhi" +#define GOSSIP_UNLEARN_TRANSMUTE "I wish to unlearn Transmutation Mastery" +#define GOSSIP_LEARN_ELIXIR "Please teach me how to become a Master of Elixirs, Lorokeem" +#define GOSSIP_UNLEARN_ELIXIR "I wish to unlearn Elixir Mastery" + +#define BOX_UNLEARN_ALCHEMY_SPEC "Do you really want to unlearn your alchemy specialty and lose all associated recipes? \n Cost: " + +#define GOSSIP_WEAPON_LEARN "Please teach me how to become a Weaponsmith" +#define GOSSIP_WEAPON_UNLEARN "I wish to unlearn the art of Weaponsmithing" +#define GOSSIP_ARMOR_LEARN "Please teach me how to become a Armorsmith" +#define GOSSIP_ARMOR_UNLEARN "I wish to unlearn the art of Armorsmithing" + +#define GOSSIP_UNLEARN_SMITH_SPEC "I wish to unlearn my blacksmith specialty" +#define BOX_UNLEARN_ARMORORWEAPON "Do you really want to unlearn your blacksmith specialty and lose all associated recipes? \n Cost: " + +#define GOSSIP_LEARN_HAMMER "Please teach me how to become a Hammersmith, Lilith" +#define GOSSIP_UNLEARN_HAMMER "I wish to unlearn Hammersmithing" +#define GOSSIP_LEARN_AXE "Please teach me how to become a Axesmith, Kilram" +#define GOSSIP_UNLEARN_AXE "I wish to unlearn Axesmithing" +#define GOSSIP_LEARN_SWORD "Please teach me how to become a Swordsmith, Seril" +#define GOSSIP_UNLEARN_SWORD "I wish to unlearn Swordsmithing" + +#define BOX_UNLEARN_WEAPON_SPEC "Do you really want to unlearn your weaponsmith specialty and lose all associated recipes? \n Cost: " + +#define GOSSIP_LEARN_DRAGON "I am absolutely certain that i want to learn dragonscale leatherworking" +#define GOSSIP_UNLEARN_DRAGON "I wish to unlearn Dragonscale Leatherworking" +#define GOSSIP_LEARN_ELEMENTAL "I am absolutely certain that i want to learn elemental leatherworking" +#define GOSSIP_UNLEARN_ELEMENTAL "I wish to unlearn Elemental Leatherworking" +#define GOSSIP_LEARN_TRIBAL "I am absolutely certain that i want to learn tribal leatherworking" +#define GOSSIP_UNLEARN_TRIBAL "I wish to unlearn Tribal Leatherworking" + +#define BOX_UNLEARN_LEATHER_SPEC "Do you really want to unlearn your leatherworking specialty and lose all associated recipes? \n Cost: " + +#define GOSSIP_LEARN_SPELLFIRE "Please teach me how to become a Spellcloth tailor" +#define GOSSIP_UNLEARN_SPELLFIRE "I wish to unlearn Spellfire Tailoring" +#define GOSSIP_LEARN_MOONCLOTH "Please teach me how to become a Mooncloth tailor" +#define GOSSIP_UNLEARN_MOONCLOTH "I wish to unlearn Mooncloth Tailoring" +#define GOSSIP_LEARN_SHADOWEAVE "Please teach me how to become a Shadoweave tailor" +#define GOSSIP_UNLEARN_SHADOWEAVE "I wish to unlearn Shadoweave Tailoring" + +#define BOX_UNLEARN_TAILOR_SPEC "Do you really want to unlearn your tailoring specialty and lose all associated recipes? \n Cost: " + +#define GOSSIP_LEARN_GOBLIN "I am absolutely certain that i want to learn Goblin engineering" +#define GOSSIP_LEARN_GNOMISH "I am absolutely certain that i want to learn Gnomish engineering" + +/*### +# spells defines +###*/ + +#define S_WEAPON 9787 +#define S_ARMOR 9788 +#define S_HAMMER 17040 +#define S_AXE 17041 +#define S_SWORD 17039 + +#define S_LEARN_WEAPON 9789 +#define S_LEARN_ARMOR 9790 +#define S_LEARN_HAMMER 39099 +#define S_LEARN_AXE 39098 +#define S_LEARN_SWORD 39097 + +#define S_UNLEARN_WEAPON 36436 +#define S_UNLEARN_ARMOR 36435 +#define S_UNLEARN_HAMMER 36441 +#define S_UNLEARN_AXE 36439 +#define S_UNLEARN_SWORD 36438 + +#define S_REP_ARMOR 17451 +#define S_REP_WEAPON 17452 + +#define REP_ARMOR 46 +#define REP_WEAPON 289 +#define REP_HAMMER 569 +#define REP_AXE 570 +#define REP_SWORD 571 + +#define S_DRAGON 10656 +#define S_ELEMENTAL 10658 +#define S_TRIBAL 10660 + +#define S_LEARN_DRAGON 10657 +#define S_LEARN_ELEMENTAL 10659 +#define S_LEARN_TRIBAL 10661 + +#define S_UNLEARN_DRAGON 36434 +#define S_UNLEARN_ELEMENTAL 36328 +#define S_UNLEARN_TRIBAL 36433 + +#define S_GOBLIN 20222 +#define S_GNOMISH 20219 + +#define S_LEARN_GOBLIN 20221 +#define S_LEARN_GNOMISH 20220 + +#define S_SPELLFIRE 26797 +#define S_MOONCLOTH 26798 +#define S_SHADOWEAVE 26801 + +#define S_LEARN_SPELLFIRE 26796 +#define S_LEARN_MOONCLOTH 26799 +#define S_LEARN_SHADOWEAVE 26800 + +#define S_UNLEARN_SPELLFIRE 41299 +#define S_UNLEARN_MOONCLOTH 41558 +#define S_UNLEARN_SHADOWEAVE 41559 + +#define S_TRANSMUTE 28672 +#define S_ELIXIR 28677 +#define S_POTION 28675 + +#define S_LEARN_TRANSMUTE 28674 +#define S_LEARN_ELIXIR 28678 +#define S_LEARN_POTION 28676 + +#define S_UNLEARN_TRANSMUTE 41565 +#define S_UNLEARN_ELIXIR 41564 +#define S_UNLEARN_POTION 41563 + +/*### +# formulas to calculate unlearning cost +###*/ + +int32 DoLearnCost(Player *player) //tailor, alchemy +{ + return 200000; +} + +int32 DoHighUnlearnCost(Player *player) //tailor, alchemy +{ + return 1500000; +} + +int32 DoMedUnlearnCost(Player *player) //blacksmith, leatherwork +{ + uint32 level = player->getLevel(); + if(level < 51) + return 250000; + else if (level < 66) + return 500000; + else + return 1000000; +} + +int32 DoLowUnlearnCost(Player *player) //blacksmith +{ + uint32 level = player->getLevel(); + if (level < 66) + return 50000; + else + return 100000; +} + +/*### +# unlearning related profession spells +###*/ + +bool EquippedOk(Player* player, uint32 spellId) +{ + SpellEntry const* spell = GetSpellStore()->LookupEntry(spellId); + + if( !spell ) + return false; + + for(int i=0; i<3; i++) + { + uint32 reqSpell = spell->EffectTriggerSpell[i]; + if( !reqSpell ) + continue; + + Item* pItem; + for(int j = EQUIPMENT_SLOT_START; j < EQUIPMENT_SLOT_END; j++) + { + pItem = player->GetItemByPos( INVENTORY_SLOT_BAG_0, j ); + if( pItem ) + if( pItem->GetProto()->RequiredSpell == reqSpell ) + { + //player has item equipped that require specialty. Not allow to unlearn, player has to unequip first + debug_log("SD2: player attempt to unlearn spell %u, but item %u is equipped.",reqSpell,pItem->GetProto()->ItemId); + return false; + } + } + } + return true; +} + +void ProfessionUnlearnSpells(Player *player, uint32 type) +{ + switch (type) + { + case 36436: // S_UNLEARN_WEAPON + player->removeSpell(36125); // Light Earthforged Blade + player->removeSpell(36128); // Light Emberforged Hammer + player->removeSpell(36126); // Light Skyforged Axe + break; + case 36435: // S_UNLEARN_ARMOR + player->removeSpell(36122); // Earthforged Leggings + player->removeSpell(36129); // Heavy Earthforged Breastplate + player->removeSpell(36130); // Stormforged Hauberk + player->removeSpell(34533); // Breastplate of Kings + player->removeSpell(34529); // Nether Chain Shirt + player->removeSpell(34534); // Bulwark of Kings + player->removeSpell(36257); // Bulwark of the Ancient Kings + player->removeSpell(36256); // Embrace of the Twisting Nether + player->removeSpell(34530); // Twisting Nether Chain Shirt + player->removeSpell(36124); // Windforged Leggings + break; + case 36441: // S_UNLEARN_HAMMER + player->removeSpell(36262); // Dragonstrike + player->removeSpell(34546); // Dragonmaw + player->removeSpell(34545); // Drakefist Hammer + player->removeSpell(36136); // Lavaforged Warhammer + player->removeSpell(34547); // Thunder + player->removeSpell(34567); // Deep Thunder + player->removeSpell(36263); // Stormherald + player->removeSpell(36137); // Great Earthforged Hammer + break; + case 36439: // S_UNLEARN_AXE + player->removeSpell(36260); // Wicked Edge of the Planes + player->removeSpell(34562); // Black Planar Edge + player->removeSpell(34541); // The Planar Edge + player->removeSpell(36134); // Stormforged Axe + player->removeSpell(36135); // Skyforged Great Axe + player->removeSpell(36261); // Bloodmoon + player->removeSpell(34543); // Lunar Crescent + player->removeSpell(34544); // Mooncleaver + break; + case 36438: // S_UNLEARN_SWORD + player->removeSpell(36258); // Blazefury + player->removeSpell(34537); // Blazeguard + player->removeSpell(34535); // Fireguard + player->removeSpell(36131); // Windforged Rapier + player->removeSpell(36133); // Stoneforged Claymore + player->removeSpell(34538); // Lionheart Blade + player->removeSpell(34540); // Lionheart Champion + player->removeSpell(36259); // Lionheart Executioner + break; + case 36434: // S_UNLEARN_DRAGON + player->removeSpell(36076); // Dragonstrike Leggings + player->removeSpell(36079); // Golden Dragonstrike Breastplate + player->removeSpell(35576); // Ebon Netherscale Belt + player->removeSpell(35577); // Ebon Netherscale Bracers + player->removeSpell(35575); // Ebon Netherscale Breastplate + player->removeSpell(35582); // Netherstrike Belt + player->removeSpell(35584); // Netherstrike Bracers + player->removeSpell(35580); // Netherstrike Breastplate + break; + case 36328: // S_UNLEARN_ELEMENTAL + player->removeSpell(36074); // Blackstorm Leggings + player->removeSpell(36077); // Primalstorm Breastplate + player->removeSpell(35590); // Primalstrike Belt + player->removeSpell(35591); // Primalstrike Bracers + player->removeSpell(35589); // Primalstrike Vest + break; + case 36433: // S_UNLEARN_TRIBAL + player->removeSpell(35585); // Windhawk Hauberk + player->removeSpell(35587); // Windhawk Belt + player->removeSpell(35588); // Windhawk Bracers + player->removeSpell(36075); // Wildfeather Leggings + player->removeSpell(36078); // Living Crystal Breastplate + break; + case 41299: // S_UNLEARN_SPELLFIRE + player->removeSpell(26752); // Spellfire Belt + player->removeSpell(26753); // Spellfire Gloves + player->removeSpell(26754); // Spellfire Robe + break; + case 41558: // S_UNLEARN_MOONCLOTH + player->removeSpell(26760); // Primal Mooncloth Belt + player->removeSpell(26761); // Primal Mooncloth Shoulders + player->removeSpell(26762); // Primal Mooncloth Robe + break; + case 41559: // S_UNLEARN_SHADOWEAVE + player->removeSpell(26756); // Frozen Shadoweave Shoulders + player->removeSpell(26757); // Frozen Shadoweave Boots + player->removeSpell(26758); // Frozen Shadoweave Robe + break; + } +} + +/*### +# start menues alchemy +###*/ + +bool HasAlchemySpell(Player *player) +{ + if(player->HasSpell(S_TRANSMUTE) || player->HasSpell(S_ELIXIR) || player->HasSpell(S_POTION)) + return true; + return false; +} + +bool GossipHello_npc_prof_alchemy(Player *player, Creature *_Creature) +{ + if (_Creature->isQuestGiver()) + player->PrepareQuestMenu( _Creature->GetGUID() ); + if (_Creature->isVendor()) + player->ADD_GOSSIP_ITEM(1, GOSSIP_TEXT_BROWSE_GOODS, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_TRADE); + if(_Creature->isTrainer()) + player->ADD_GOSSIP_ITEM(2, GOSSIP_TEXT_TRAIN, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_TRAIN); + + uint32 eCreature = _Creature->GetEntry(); + + if (player->HasSkill(SKILL_ALCHEMY) && player->GetBaseSkillValue(SKILL_ALCHEMY)>=350 && player->getLevel() > 67) + { + if (player->GetQuestRewardStatus(10899) || player->GetQuestRewardStatus(10902) || player->GetQuestRewardStatus(10897)) + { + switch (eCreature) + { + case 22427: //Zarevhi + if (!HasAlchemySpell(player)) + player->ADD_GOSSIP_ITEM( 0, GOSSIP_LEARN_TRANSMUTE, GOSSIP_SENDER_LEARN, GOSSIP_ACTION_INFO_DEF + 1); + if (player->HasSpell(S_TRANSMUTE)) + player->ADD_GOSSIP_ITEM( 0, GOSSIP_UNLEARN_TRANSMUTE, GOSSIP_SENDER_UNLEARN, GOSSIP_ACTION_INFO_DEF + 4); + break; + case 19052: //Lorokeem + if (!HasAlchemySpell(player)) + player->ADD_GOSSIP_ITEM( 0, GOSSIP_LEARN_ELIXIR, GOSSIP_SENDER_LEARN, GOSSIP_ACTION_INFO_DEF + 2); + if (player->HasSpell(S_ELIXIR)) + player->ADD_GOSSIP_ITEM( 0, GOSSIP_UNLEARN_ELIXIR, GOSSIP_SENDER_UNLEARN, GOSSIP_ACTION_INFO_DEF + 5); + break; + case 17909: //Lauranna Thar'well + if (!HasAlchemySpell(player)) + player->ADD_GOSSIP_ITEM( 0, GOSSIP_LEARN_POTION, GOSSIP_SENDER_LEARN, GOSSIP_ACTION_INFO_DEF + 3); + if (player->HasSpell(S_POTION)) + player->ADD_GOSSIP_ITEM( 0, GOSSIP_UNLEARN_POTION, GOSSIP_SENDER_UNLEARN, GOSSIP_ACTION_INFO_DEF + 6); + break; + } + } + } + + player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); + return true; +} + +void SendActionMenu_npc_prof_alchemy(Player *player, Creature *_Creature, uint32 action) +{ + switch(action) + { + case GOSSIP_ACTION_TRADE: + player->SEND_VENDORLIST( _Creature->GetGUID() ); + break; + case GOSSIP_ACTION_TRAIN: + player->SEND_TRAINERLIST( _Creature->GetGUID() ); + break; + //Learn Alchemy + case GOSSIP_ACTION_INFO_DEF + 1: + if(!player->HasSpell(S_TRANSMUTE) && player->GetMoney() >= DoLearnCost(player)) + { + player->CastSpell(player, S_LEARN_TRANSMUTE, true); + player->ModifyMoney(-DoLearnCost(player)); + } else + player->SendBuyError( BUY_ERR_NOT_ENOUGHT_MONEY, _Creature, 0, 0); + player->CLOSE_GOSSIP_MENU(); + break; + case GOSSIP_ACTION_INFO_DEF + 2: + if(!player->HasSpell(S_ELIXIR) && player->GetMoney() >= DoLearnCost(player)) + { + player->CastSpell(player, S_LEARN_ELIXIR, true); + player->ModifyMoney(-DoLearnCost(player)); + } else + player->SendBuyError( BUY_ERR_NOT_ENOUGHT_MONEY, _Creature, 0, 0); + player->CLOSE_GOSSIP_MENU(); + break; + case GOSSIP_ACTION_INFO_DEF + 3: + if(!player->HasSpell(S_POTION) && player->GetMoney() >= DoLearnCost(player)) + { + player->CastSpell(player, S_LEARN_POTION, true); + player->ModifyMoney(-DoLearnCost(player)); + } else + player->SendBuyError( BUY_ERR_NOT_ENOUGHT_MONEY, _Creature, 0, 0); + player->CLOSE_GOSSIP_MENU(); + break; + //Unlearn Alchemy + case GOSSIP_ACTION_INFO_DEF + 4: + if(player->GetMoney() >= DoHighUnlearnCost(player)) + { + _Creature->CastSpell(player, S_UNLEARN_TRANSMUTE, true); + player->ModifyMoney(-DoHighUnlearnCost(player)); + } else + player->SendBuyError( BUY_ERR_NOT_ENOUGHT_MONEY, _Creature, 0, 0); + player->CLOSE_GOSSIP_MENU(); + break; + case GOSSIP_ACTION_INFO_DEF + 5: + if(player->GetMoney() >= DoHighUnlearnCost(player)) + { + _Creature->CastSpell(player, S_UNLEARN_ELIXIR, true); + player->ModifyMoney(-DoHighUnlearnCost(player)); + } else + player->SendBuyError( BUY_ERR_NOT_ENOUGHT_MONEY, _Creature, 0, 0); + player->CLOSE_GOSSIP_MENU(); + break; + case GOSSIP_ACTION_INFO_DEF + 6: + if(player->GetMoney() >= DoHighUnlearnCost(player)) + { + _Creature->CastSpell(player, S_UNLEARN_POTION, true); + player->ModifyMoney(-DoHighUnlearnCost(player)); + } else + player->SendBuyError( BUY_ERR_NOT_ENOUGHT_MONEY, _Creature, 0, 0); + player->CLOSE_GOSSIP_MENU(); + break; + } +} + +void SendConfirmLearn_npc_prof_alchemy(Player *player, Creature *_Creature, uint32 action) +{ + if(action) + { + uint32 eCreature = _Creature->GetEntry(); + switch(eCreature) + { + case 22427: + player->ADD_GOSSIP_ITEM( 0, GOSSIP_LEARN_TRANSMUTE, GOSSIP_SENDER_CHECK, action); + //unknown textID () + player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); + break; + case 19052: + player->ADD_GOSSIP_ITEM( 0, GOSSIP_LEARN_ELIXIR, GOSSIP_SENDER_CHECK, action); + //unknown textID () + player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); + break; + case 17909: + player->ADD_GOSSIP_ITEM( 0, GOSSIP_LEARN_POTION, GOSSIP_SENDER_CHECK, action); + //unknown textID () + player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); + break; + } + } +} + +void SendConfirmUnlearn_npc_prof_alchemy(Player *player, Creature *_Creature, uint32 action) +{ + if(action) + { + uint32 eCreature = _Creature->GetEntry(); + switch(eCreature) + { + case 22427: //Zarevhi + player->ADD_GOSSIP_ITEM_EXTENDED( 0, GOSSIP_UNLEARN_TRANSMUTE, GOSSIP_SENDER_CHECK, action, BOX_UNLEARN_ALCHEMY_SPEC, DoHighUnlearnCost(player),false); + //unknown textID () + player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); + break; + case 19052: //Lorokeem + player->ADD_GOSSIP_ITEM_EXTENDED( 0, GOSSIP_UNLEARN_ELIXIR, GOSSIP_SENDER_CHECK, action, BOX_UNLEARN_ALCHEMY_SPEC, DoHighUnlearnCost(player),false); + //unknown textID () + player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); + break; + case 17909: //Lauranna Thar'well + player->ADD_GOSSIP_ITEM_EXTENDED( 0, GOSSIP_UNLEARN_POTION, GOSSIP_SENDER_CHECK, action, BOX_UNLEARN_ALCHEMY_SPEC, DoHighUnlearnCost(player),false); + //unknown textID () + player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); + break; + } + } +} + +bool GossipSelect_npc_prof_alchemy(Player *player, Creature *_Creature, uint32 sender, uint32 action ) +{ + switch(sender) + { + case GOSSIP_SENDER_MAIN: SendActionMenu_npc_prof_alchemy(player, _Creature, action); break; + case GOSSIP_SENDER_LEARN: SendConfirmLearn_npc_prof_alchemy(player, _Creature, action); break; + case GOSSIP_SENDER_UNLEARN: SendConfirmUnlearn_npc_prof_alchemy(player, _Creature, action); break; + case GOSSIP_SENDER_CHECK: SendActionMenu_npc_prof_alchemy(player, _Creature, action); break; + } + return true; +} + +/*### +# start menues blacksmith +###*/ + +bool HasWeaponSub(Player *player) +{ + if (player->HasSpell(S_HAMMER) || player->HasSpell(S_AXE) || player->HasSpell(S_SWORD)) + return true; + return false; +} + +bool GossipHello_npc_prof_blacksmith(Player *player, Creature *_Creature) +{ + if (_Creature->isQuestGiver()) + player->PrepareQuestMenu( _Creature->GetGUID() ); + if (_Creature->isVendor()) + player->ADD_GOSSIP_ITEM(1, GOSSIP_TEXT_BROWSE_GOODS, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_TRADE); + if(_Creature->isTrainer()) + player->ADD_GOSSIP_ITEM(2, GOSSIP_TEXT_TRAIN, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_TRAIN); + + uint32 eCreature = _Creature->GetEntry(); + //WEAPONSMITH & ARMORSMITH + if(player->GetBaseSkillValue(SKILL_BLACKSMITHING)>=225) + { + switch (eCreature) + { + case 11145: //Myolor Sunderfury + case 11176: //Krathok Moltenfist + if(!player->HasSpell(S_ARMOR) && !player->HasSpell(S_WEAPON) && player->GetReputationRank(REP_ARMOR) == REP_FRIENDLY) + player->ADD_GOSSIP_ITEM( 0, GOSSIP_ARMOR_LEARN, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); + if(!player->HasSpell(S_WEAPON) && !player->HasSpell(S_ARMOR) && player->GetReputationRank(REP_WEAPON) == REP_FRIENDLY) + player->ADD_GOSSIP_ITEM( 0, GOSSIP_WEAPON_LEARN, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2); + break; + case 11146: //Ironus Coldsteel + case 11178: //Borgosh Corebender + if(player->HasSpell(S_WEAPON)) + player->ADD_GOSSIP_ITEM( 0, GOSSIP_WEAPON_UNLEARN, GOSSIP_SENDER_UNLEARN, GOSSIP_ACTION_INFO_DEF + 3); + break; + case 5164: //Grumnus Steelshaper + case 11177: //Okothos Ironrager + if(player->HasSpell(S_ARMOR)) + player->ADD_GOSSIP_ITEM( 0, GOSSIP_ARMOR_UNLEARN, GOSSIP_SENDER_UNLEARN, GOSSIP_ACTION_INFO_DEF + 4); + break; + } + } + //WEAPONSMITH SPEC + if(player->HasSpell(S_WEAPON) && player->getLevel() > 49 && player->GetBaseSkillValue(SKILL_BLACKSMITHING)>=250) + { + switch (eCreature) + { + case 11191: //Lilith the Lithe + if(!HasWeaponSub(player)) + player->ADD_GOSSIP_ITEM( 0, GOSSIP_LEARN_HAMMER, GOSSIP_SENDER_LEARN, GOSSIP_ACTION_INFO_DEF + 5); + if(player->HasSpell(S_HAMMER)) + player->ADD_GOSSIP_ITEM( 0, GOSSIP_UNLEARN_HAMMER, GOSSIP_SENDER_UNLEARN, GOSSIP_ACTION_INFO_DEF + 8); + break; + case 11192: //Kilram + if(!HasWeaponSub(player)) + player->ADD_GOSSIP_ITEM( 0, GOSSIP_LEARN_AXE, GOSSIP_SENDER_LEARN, GOSSIP_ACTION_INFO_DEF + 6); + if(player->HasSpell(S_AXE)) + player->ADD_GOSSIP_ITEM( 0, GOSSIP_UNLEARN_AXE, GOSSIP_SENDER_UNLEARN, GOSSIP_ACTION_INFO_DEF + 9); + break; + case 11193: //Seril Scourgebane + if(!HasWeaponSub(player)) + player->ADD_GOSSIP_ITEM( 0, GOSSIP_LEARN_SWORD, GOSSIP_SENDER_LEARN, GOSSIP_ACTION_INFO_DEF + 7); + if(player->HasSpell(S_SWORD)) + player->ADD_GOSSIP_ITEM( 0, GOSSIP_UNLEARN_SWORD, GOSSIP_SENDER_UNLEARN, GOSSIP_ACTION_INFO_DEF + 10); + break; + } + } + + player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); + return true; +} + +void SendActionMenu_npc_prof_blacksmith(Player *player, Creature *_Creature, uint32 action) +{ + switch(action) + { + case GOSSIP_ACTION_TRADE: + player->SEND_VENDORLIST( _Creature->GetGUID() ); + break; + case GOSSIP_ACTION_TRAIN: + player->SEND_TRAINERLIST( _Creature->GetGUID() ); + break; + //Learn Armor/Weapon + case GOSSIP_ACTION_INFO_DEF + 1: + if(!player->HasSpell(S_ARMOR)) + { + player->CastSpell(player, S_LEARN_ARMOR, true); + //_Creature->CastSpell(player, S_REP_ARMOR, true); + } + player->CLOSE_GOSSIP_MENU(); + break; + case GOSSIP_ACTION_INFO_DEF + 2: + if(!player->HasSpell(S_WEAPON)) + { + player->CastSpell(player, S_LEARN_WEAPON, true); + //_Creature->CastSpell(player, S_REP_WEAPON, true); + } + player->CLOSE_GOSSIP_MENU(); + break; + //Unlearn Armor/Weapon + case GOSSIP_ACTION_INFO_DEF + 3: + if(HasWeaponSub(player)) + { + //unknown textID (TALK_MUST_UNLEARN_WEAPON) + player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); + //Temporary, not offilike + _Creature->MonsterSay(TALK_MUST_UNLEARN_WEAPON,0,player->GetGUID()); + } + else if( EquippedOk(player,S_UNLEARN_WEAPON) ) + { + if( player->GetMoney() >= DoLowUnlearnCost(player) ) + { + player->CastSpell(player, S_UNLEARN_WEAPON, true); + ProfessionUnlearnSpells(player, S_UNLEARN_WEAPON); + player->ModifyMoney(-DoLowUnlearnCost(player)); + _Creature->CastSpell(player, S_REP_ARMOR, true); + player->CLOSE_GOSSIP_MENU(); + } else + player->SendBuyError( BUY_ERR_NOT_ENOUGHT_MONEY, _Creature, 0, 0); + } + else + { + player->SendEquipError(EQUIP_ERR_CANT_DO_RIGHT_NOW,NULL,NULL); + player->CLOSE_GOSSIP_MENU(); + } + break; + case GOSSIP_ACTION_INFO_DEF + 4: + if( EquippedOk(player,S_UNLEARN_ARMOR) ) + { + if( player->GetMoney() >= DoLowUnlearnCost(player) ) + { + player->CastSpell(player, S_UNLEARN_ARMOR, true); + ProfessionUnlearnSpells(player, S_UNLEARN_ARMOR); + player->ModifyMoney(-DoLowUnlearnCost(player)); + _Creature->CastSpell(player, S_REP_WEAPON, true); + } else + player->SendBuyError( BUY_ERR_NOT_ENOUGHT_MONEY, _Creature, 0, 0); + } else + player->SendEquipError(EQUIP_ERR_CANT_DO_RIGHT_NOW,NULL,NULL); + player->CLOSE_GOSSIP_MENU(); + break; + //Learn Hammer/Axe/Sword + case GOSSIP_ACTION_INFO_DEF + 5: + player->CastSpell(player, S_LEARN_HAMMER, true); + player->CLOSE_GOSSIP_MENU(); + break; + case GOSSIP_ACTION_INFO_DEF + 6: + player->CastSpell(player, S_LEARN_AXE, true); + player->CLOSE_GOSSIP_MENU(); + break; + case GOSSIP_ACTION_INFO_DEF + 7: + player->CastSpell(player, S_LEARN_SWORD, true); + player->CLOSE_GOSSIP_MENU(); + break; + //Unlearn Hammer/Axe/Sword + case GOSSIP_ACTION_INFO_DEF + 8: + if( EquippedOk(player,S_UNLEARN_HAMMER) ) + { + if( player->GetMoney() >= DoMedUnlearnCost(player)) + { + player->CastSpell(player, S_UNLEARN_HAMMER, true); + ProfessionUnlearnSpells(player, S_UNLEARN_HAMMER); + player->ModifyMoney(-DoMedUnlearnCost(player)); + } else + player->SendBuyError( BUY_ERR_NOT_ENOUGHT_MONEY, _Creature, 0, 0); + } else + player->SendEquipError(EQUIP_ERR_CANT_DO_RIGHT_NOW,NULL,NULL); + player->CLOSE_GOSSIP_MENU(); + break; + case GOSSIP_ACTION_INFO_DEF + 9: + if( EquippedOk(player,S_UNLEARN_AXE) ) + { + if( player->GetMoney() >= DoMedUnlearnCost(player)) + { + player->CastSpell(player, S_UNLEARN_AXE, true); + ProfessionUnlearnSpells(player, S_UNLEARN_AXE); + player->ModifyMoney(-DoMedUnlearnCost(player)); + } else + player->SendBuyError( BUY_ERR_NOT_ENOUGHT_MONEY, _Creature, 0, 0); + } else + player->SendEquipError(EQUIP_ERR_CANT_DO_RIGHT_NOW,NULL,NULL); + player->CLOSE_GOSSIP_MENU(); + break; + case GOSSIP_ACTION_INFO_DEF + 10: + if( EquippedOk(player,S_UNLEARN_SWORD) ) + { + if( player->GetMoney() >= DoMedUnlearnCost(player)) + { + player->CastSpell(player, S_UNLEARN_SWORD, true); + ProfessionUnlearnSpells(player, S_UNLEARN_SWORD); + player->ModifyMoney(-DoMedUnlearnCost(player)); + } else + player->SendBuyError( BUY_ERR_NOT_ENOUGHT_MONEY, _Creature, 0, 0); + } else + player->SendEquipError(EQUIP_ERR_CANT_DO_RIGHT_NOW,NULL,NULL); + player->CLOSE_GOSSIP_MENU(); + break; + } +} + +void SendConfirmLearn_npc_prof_blacksmith(Player *player, Creature *_Creature, uint32 action) +{ + if(action) + { + uint32 eCreature = _Creature->GetEntry(); + switch(eCreature) + { + case 11191: + player->ADD_GOSSIP_ITEM( 0, GOSSIP_LEARN_HAMMER, GOSSIP_SENDER_CHECK, action); + //unknown textID (TALK_HAMMER_LEARN) + player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); + break; + case 11192: + player->ADD_GOSSIP_ITEM( 0, GOSSIP_LEARN_AXE, GOSSIP_SENDER_CHECK, action); + //unknown textID (TALK_AXE_LEARN) + player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); + break; + case 11193: + player->ADD_GOSSIP_ITEM( 0, GOSSIP_LEARN_SWORD, GOSSIP_SENDER_CHECK, action); + //unknown textID (TALK_SWORD_LEARN) + player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); + break; + } + } +} + +void SendConfirmUnlearn_npc_prof_blacksmith(Player *player, Creature *_Creature, uint32 action) +{ + if(action) + { + uint32 eCreature = _Creature->GetEntry(); + switch(eCreature) + { + case 11146: //Ironus Coldsteel + case 11178: //Borgosh Corebender + case 5164: //Grumnus Steelshaper + case 11177: //Okothos Ironrager + player->ADD_GOSSIP_ITEM_EXTENDED( 0, GOSSIP_UNLEARN_SMITH_SPEC, GOSSIP_SENDER_CHECK, action, BOX_UNLEARN_ARMORORWEAPON, DoLowUnlearnCost(player),false); + //unknown textID (TALK_UNLEARN_AXEORWEAPON) + player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); + break; + + case 11191: + player->ADD_GOSSIP_ITEM_EXTENDED( 0, GOSSIP_UNLEARN_HAMMER, GOSSIP_SENDER_CHECK, action, BOX_UNLEARN_WEAPON_SPEC, DoMedUnlearnCost(player),false); + //unknown textID (TALK_HAMMER_UNLEARN) + player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); + break; + case 11192: + player->ADD_GOSSIP_ITEM_EXTENDED( 0, GOSSIP_UNLEARN_AXE, GOSSIP_SENDER_CHECK, action, BOX_UNLEARN_WEAPON_SPEC, DoMedUnlearnCost(player),false); + //unknown textID (TALK_AXE_UNLEARN) + player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); + break; + case 11193: + player->ADD_GOSSIP_ITEM_EXTENDED( 0, GOSSIP_UNLEARN_SWORD, GOSSIP_SENDER_CHECK, action, BOX_UNLEARN_WEAPON_SPEC, DoMedUnlearnCost(player),false); + //unknown textID (TALK_SWORD_UNLEARN) + player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); + break; + } + } +} + +bool GossipSelect_npc_prof_blacksmith(Player *player, Creature *_Creature, uint32 sender, uint32 action ) +{ + switch(sender) + { + case GOSSIP_SENDER_MAIN: SendActionMenu_npc_prof_blacksmith(player, _Creature, action); break; + case GOSSIP_SENDER_LEARN: SendConfirmLearn_npc_prof_blacksmith(player, _Creature, action); break; + case GOSSIP_SENDER_UNLEARN: SendConfirmUnlearn_npc_prof_blacksmith(player, _Creature, action); break; + case GOSSIP_SENDER_CHECK: SendActionMenu_npc_prof_blacksmith(player, _Creature, action); break; + } + return true; +} + +/*bool QuestComplete_npc_prof_blacksmith( Player *player, Creature *_Creature, Quest const *_Quest ) +{ + if ( (_Quest->GetQuestId() == 5283) || (_Quest->GetQuestId() == 5301) ) //armorsmith + _Creature->CastSpell(player, 17451, true); + + if ( (_Quest->GetQuestId() == 5284) || (_Quest->GetQuestId() == 5302) ) //weaponsmith + _Creature->CastSpell(player, 17452, true); + + return true; +}*/ + +/*### +# start menues leatherworking +###*/ + +bool GossipHello_npc_prof_leather(Player *player, Creature *_Creature) +{ + if (_Creature->isQuestGiver()) + player->PrepareQuestMenu( _Creature->GetGUID() ); + if (_Creature->isVendor()) + player->ADD_GOSSIP_ITEM(1, GOSSIP_TEXT_BROWSE_GOODS, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_TRADE); + if(_Creature->isTrainer()) + player->ADD_GOSSIP_ITEM(2, GOSSIP_TEXT_TRAIN, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_TRAIN); + + uint32 eCreature = _Creature->GetEntry(); + + if(player->HasSkill(SKILL_LEATHERWORKING) && player->GetBaseSkillValue(SKILL_LEATHERWORKING)>=250 && player->getLevel() > 49 ) + { + switch (eCreature) + { + case 7866: //Peter Galen + case 7867: //Thorkaf Dragoneye + if(player->HasSpell(S_DRAGON)) + player->ADD_GOSSIP_ITEM( 0, GOSSIP_UNLEARN_DRAGON, GOSSIP_SENDER_UNLEARN, GOSSIP_ACTION_INFO_DEF + 1); + break; + case 7868: //Sarah Tanner + case 7869: //Brumn Winterhoof + if(player->HasSpell(S_ELEMENTAL)) + player->ADD_GOSSIP_ITEM( 0, GOSSIP_UNLEARN_ELEMENTAL, GOSSIP_SENDER_UNLEARN, GOSSIP_ACTION_INFO_DEF + 2); + break; + case 7870: //Caryssia Moonhunter + case 7871: //Se'Jib + if(player->HasSpell(S_TRIBAL)) + player->ADD_GOSSIP_ITEM( 0, GOSSIP_UNLEARN_TRIBAL, GOSSIP_SENDER_UNLEARN, GOSSIP_ACTION_INFO_DEF + 3); + break; + } + } + + player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); + return true; +} + +void SendActionMenu_npc_prof_leather(Player *player, Creature *_Creature, uint32 action) +{ + switch(action) + { + case GOSSIP_ACTION_TRADE: + player->SEND_VENDORLIST( _Creature->GetGUID() ); + break; + case GOSSIP_ACTION_TRAIN: + player->SEND_TRAINERLIST( _Creature->GetGUID() ); + break; + //Unlearn Leather + case GOSSIP_ACTION_INFO_DEF + 1: + if( EquippedOk(player,S_UNLEARN_DRAGON) ) + { + if( player->GetMoney() >= DoMedUnlearnCost(player) ) + { + player->CastSpell(player, S_UNLEARN_DRAGON, true); + ProfessionUnlearnSpells(player, S_UNLEARN_DRAGON); + player->ModifyMoney(-DoMedUnlearnCost(player)); + } else + player->SendBuyError( BUY_ERR_NOT_ENOUGHT_MONEY, _Creature, 0, 0); + } else + player->SendEquipError(EQUIP_ERR_CANT_DO_RIGHT_NOW,NULL,NULL); + player->CLOSE_GOSSIP_MENU(); + break; + case GOSSIP_ACTION_INFO_DEF + 2: + if( EquippedOk(player,S_UNLEARN_ELEMENTAL) ) + { + if( player->GetMoney() >= DoMedUnlearnCost(player) ) + { + player->CastSpell(player, S_UNLEARN_ELEMENTAL, true); + ProfessionUnlearnSpells(player, S_UNLEARN_ELEMENTAL); + player->ModifyMoney(-DoMedUnlearnCost(player)); + } else + player->SendBuyError( BUY_ERR_NOT_ENOUGHT_MONEY, _Creature, 0, 0); + } else + player->SendEquipError(EQUIP_ERR_CANT_DO_RIGHT_NOW,NULL,NULL); + player->CLOSE_GOSSIP_MENU(); + break; + case GOSSIP_ACTION_INFO_DEF + 3: + if( EquippedOk(player,S_UNLEARN_TRIBAL) ) + { + if(player->GetMoney() >= DoMedUnlearnCost(player)) + { + player->CastSpell(player, S_UNLEARN_TRIBAL, true); + ProfessionUnlearnSpells(player, S_UNLEARN_TRIBAL); + player->ModifyMoney(-DoMedUnlearnCost(player)); + } else + player->SendBuyError( BUY_ERR_NOT_ENOUGHT_MONEY, _Creature, 0, 0); + } else + player->SendEquipError(EQUIP_ERR_CANT_DO_RIGHT_NOW,NULL,NULL); + player->CLOSE_GOSSIP_MENU(); + break; + } +} + +void SendConfirmUnlearn_npc_prof_leather(Player *player, Creature *_Creature, uint32 action) +{ + if(action) + { + uint32 eCreature = _Creature->GetEntry(); + switch(eCreature) + { + case 7866: //Peter Galen + case 7867: //Thorkaf Dragoneye + player->ADD_GOSSIP_ITEM_EXTENDED( 0, GOSSIP_UNLEARN_DRAGON, GOSSIP_SENDER_CHECK, action, BOX_UNLEARN_LEATHER_SPEC, DoMedUnlearnCost(player),false); + //unknown textID () + player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); + break; + case 7868: //Sarah Tanner + case 7869: //Brumn Winterhoof + player->ADD_GOSSIP_ITEM_EXTENDED( 0, GOSSIP_UNLEARN_ELEMENTAL, GOSSIP_SENDER_CHECK, action, BOX_UNLEARN_LEATHER_SPEC, DoMedUnlearnCost(player),false); + //unknown textID () + player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); + break; + case 7870: //Caryssia Moonhunter + case 7871: //Se'Jib + player->ADD_GOSSIP_ITEM_EXTENDED( 0, GOSSIP_UNLEARN_TRIBAL, GOSSIP_SENDER_CHECK, action, BOX_UNLEARN_LEATHER_SPEC, DoMedUnlearnCost(player),false); + //unknown textID () + player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); + break; + } + } +} + +bool GossipSelect_npc_prof_leather(Player *player, Creature *_Creature, uint32 sender, uint32 action ) +{ + switch(sender) + { + case GOSSIP_SENDER_MAIN: SendActionMenu_npc_prof_leather(player, _Creature, action); break; + case GOSSIP_SENDER_UNLEARN: SendConfirmUnlearn_npc_prof_leather(player, _Creature, action); break; + case GOSSIP_SENDER_CHECK: SendActionMenu_npc_prof_leather(player, _Creature, action); break; + } + return true; +} + +/*### +# start menues tailoring +###*/ + +bool HasTailorSpell(Player *player) +{ + if (player->HasSpell(S_MOONCLOTH) || player->HasSpell(S_SHADOWEAVE) || player->HasSpell(S_SPELLFIRE)) + return true; + return false; +} + +bool GossipHello_npc_prof_tailor(Player *player, Creature *_Creature) +{ + if (_Creature->isQuestGiver()) + player->PrepareQuestMenu( _Creature->GetGUID() ); + if (_Creature->isVendor()) + player->ADD_GOSSIP_ITEM(1, GOSSIP_TEXT_BROWSE_GOODS, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_TRADE); + if (_Creature->isTrainer()) + player->ADD_GOSSIP_ITEM(2, GOSSIP_TEXT_TRAIN, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_TRAIN); + + uint32 eCreature = _Creature->GetEntry(); + //TAILORING SPEC + if (player->HasSkill(SKILL_TAILORING) && player->GetBaseSkillValue(SKILL_TAILORING)>=350 && player->getLevel() > 59) + { + if (player->GetQuestRewardStatus(10831) || player->GetQuestRewardStatus(10832) || player->GetQuestRewardStatus(10833)) + { + switch (eCreature) + { + case 22213: //Gidge Spellweaver + if (!HasTailorSpell(player)) + player->ADD_GOSSIP_ITEM( 0, GOSSIP_LEARN_SPELLFIRE, GOSSIP_SENDER_LEARN, GOSSIP_ACTION_INFO_DEF + 1); + if (player->HasSpell(S_SPELLFIRE)) + player->ADD_GOSSIP_ITEM( 0, GOSSIP_UNLEARN_SPELLFIRE, GOSSIP_SENDER_UNLEARN, GOSSIP_ACTION_INFO_DEF + 4); + break; + case 22208: //Nasmara Moonsong + if (!HasTailorSpell(player)) + player->ADD_GOSSIP_ITEM( 0, GOSSIP_LEARN_MOONCLOTH, GOSSIP_SENDER_LEARN, GOSSIP_ACTION_INFO_DEF + 2); + if (player->HasSpell(S_MOONCLOTH)) + player->ADD_GOSSIP_ITEM( 0, GOSSIP_UNLEARN_MOONCLOTH, GOSSIP_SENDER_UNLEARN, GOSSIP_ACTION_INFO_DEF + 5); + break; + case 22212: //Andrion Darkspinner + if (!HasTailorSpell(player)) + player->ADD_GOSSIP_ITEM( 0, GOSSIP_LEARN_SHADOWEAVE, GOSSIP_SENDER_LEARN, GOSSIP_ACTION_INFO_DEF + 3); + if (player->HasSpell(S_SHADOWEAVE)) + player->ADD_GOSSIP_ITEM( 0, GOSSIP_UNLEARN_SHADOWEAVE, GOSSIP_SENDER_UNLEARN, GOSSIP_ACTION_INFO_DEF + 6); + break; + } + } + } + + player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); + return true; +} + +void SendActionMenu_npc_prof_tailor(Player *player, Creature *_Creature, uint32 action) +{ + switch(action) + { + case GOSSIP_ACTION_TRADE: + player->SEND_VENDORLIST( _Creature->GetGUID() ); + break; + case GOSSIP_ACTION_TRAIN: + player->SEND_TRAINERLIST( _Creature->GetGUID() ); + break; + //Learn Tailor + case GOSSIP_ACTION_INFO_DEF + 1: + if(!player->HasSpell(S_SPELLFIRE) && player->GetMoney() >= DoLearnCost(player)) + { + player->CastSpell(player, S_LEARN_SPELLFIRE, true); + player->ModifyMoney(-DoLearnCost(player)); + } else + player->SendBuyError( BUY_ERR_NOT_ENOUGHT_MONEY, _Creature, 0, 0); + player->CLOSE_GOSSIP_MENU(); + break; + case GOSSIP_ACTION_INFO_DEF + 2: + if(!player->HasSpell(S_MOONCLOTH) && player->GetMoney() >= DoLearnCost(player)) + { + player->CastSpell(player, S_LEARN_MOONCLOTH, true); + player->ModifyMoney(-DoLearnCost(player)); + } else + player->SendBuyError( BUY_ERR_NOT_ENOUGHT_MONEY, _Creature, 0, 0); + player->CLOSE_GOSSIP_MENU(); + break; + case GOSSIP_ACTION_INFO_DEF + 3: + if(!player->HasSpell(S_SHADOWEAVE) && player->GetMoney() >= DoLearnCost(player)) + { + player->CastSpell(player, S_LEARN_SHADOWEAVE, true); + player->ModifyMoney(-DoLearnCost(player)); + } else + player->SendBuyError( BUY_ERR_NOT_ENOUGHT_MONEY, _Creature, 0, 0); + player->CLOSE_GOSSIP_MENU(); + break; + //Unlearn Tailor + case GOSSIP_ACTION_INFO_DEF + 4: + if( EquippedOk(player,S_UNLEARN_SPELLFIRE) ) + { + if( player->GetMoney() >= DoHighUnlearnCost(player) ) + { + player->CastSpell(player, S_UNLEARN_SPELLFIRE, true); + ProfessionUnlearnSpells(player, S_UNLEARN_SPELLFIRE); + player->ModifyMoney(-DoHighUnlearnCost(player)); + } else + player->SendBuyError( BUY_ERR_NOT_ENOUGHT_MONEY, _Creature, 0, 0); + } else + player->SendEquipError(EQUIP_ERR_CANT_DO_RIGHT_NOW,NULL,NULL); + player->CLOSE_GOSSIP_MENU(); + break; + case GOSSIP_ACTION_INFO_DEF + 5: + if( EquippedOk(player,S_UNLEARN_MOONCLOTH) ) + { + if( player->GetMoney() >= DoHighUnlearnCost(player) ) + { + player->CastSpell(player, S_UNLEARN_MOONCLOTH, true); + ProfessionUnlearnSpells(player, S_UNLEARN_MOONCLOTH); + player->ModifyMoney(-DoHighUnlearnCost(player)); + } else + player->SendBuyError( BUY_ERR_NOT_ENOUGHT_MONEY, _Creature, 0, 0); + } else + player->SendEquipError(EQUIP_ERR_CANT_DO_RIGHT_NOW,NULL,NULL); + player->CLOSE_GOSSIP_MENU(); + break; + case GOSSIP_ACTION_INFO_DEF + 6: + if( EquippedOk(player,S_UNLEARN_SHADOWEAVE) ) + { + if( player->GetMoney() >= DoHighUnlearnCost(player) ) + { + player->CastSpell(player, S_UNLEARN_SHADOWEAVE, true); + ProfessionUnlearnSpells(player, S_UNLEARN_SHADOWEAVE); + player->ModifyMoney(-DoHighUnlearnCost(player)); + } else + player->SendBuyError( BUY_ERR_NOT_ENOUGHT_MONEY, _Creature, 0, 0); + } else + player->SendEquipError(EQUIP_ERR_CANT_DO_RIGHT_NOW,NULL,NULL); + player->CLOSE_GOSSIP_MENU(); + break; + } +} + +void SendConfirmLearn_npc_prof_tailor(Player *player, Creature *_Creature, uint32 action) +{ + if(action) + { + uint32 eCreature = _Creature->GetEntry(); + switch(eCreature) + { + case 22213: + player->ADD_GOSSIP_ITEM( 0, GOSSIP_LEARN_SPELLFIRE, GOSSIP_SENDER_CHECK, action); + //unknown textID () + player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); + break; + case 22208: + player->ADD_GOSSIP_ITEM( 0, GOSSIP_LEARN_MOONCLOTH, GOSSIP_SENDER_CHECK, action); + //unknown textID () + player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); + break; + case 22212: + player->ADD_GOSSIP_ITEM( 0, GOSSIP_LEARN_SHADOWEAVE, GOSSIP_SENDER_CHECK, action); + //unknown textID () + player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); + break; + } + } +} + +void SendConfirmUnlearn_npc_prof_tailor(Player *player, Creature *_Creature, uint32 action) +{ + if(action) + { + uint32 eCreature = _Creature->GetEntry(); + switch(eCreature) + { + case 22213: //Gidge Spellweaver + player->ADD_GOSSIP_ITEM_EXTENDED( 0, GOSSIP_UNLEARN_SPELLFIRE, GOSSIP_SENDER_CHECK, action, BOX_UNLEARN_TAILOR_SPEC, DoHighUnlearnCost(player),false); + //unknown textID () + player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); + break; + case 22208: //Nasmara Moonsong + player->ADD_GOSSIP_ITEM_EXTENDED( 0, GOSSIP_UNLEARN_MOONCLOTH, GOSSIP_SENDER_CHECK, action, BOX_UNLEARN_TAILOR_SPEC, DoHighUnlearnCost(player),false); + //unknown textID () + player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); + break; + case 22212: //Andrion Darkspinner + player->ADD_GOSSIP_ITEM_EXTENDED( 0, GOSSIP_UNLEARN_SHADOWEAVE, GOSSIP_SENDER_CHECK, action,BOX_UNLEARN_TAILOR_SPEC, DoHighUnlearnCost(player),false); + //unknown textID () + player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); + break; + } + } +} + +bool GossipSelect_npc_prof_tailor(Player *player, Creature *_Creature, uint32 sender, uint32 action ) +{ + switch(sender) + { + case GOSSIP_SENDER_MAIN: SendActionMenu_npc_prof_tailor(player, _Creature, action); break; + case GOSSIP_SENDER_LEARN: SendConfirmLearn_npc_prof_tailor(player, _Creature, action); break; + case GOSSIP_SENDER_UNLEARN: SendConfirmUnlearn_npc_prof_tailor(player, _Creature, action); break; + case GOSSIP_SENDER_CHECK: SendActionMenu_npc_prof_tailor(player, _Creature, action); break; + } + return true; +} + +/*### +# start menues for GO (engineering and leatherworking) +###*/ + +/*bool GOHello_go_soothsaying_for_dummies(Player *player, GameObject* _GO) +{ + player->PlayerTalkClass->GetGossipMenu()->AddMenuItem(0,GOSSIP_LEARN_DRAGON, GOSSIP_SENDER_INFO, GOSSIP_ACTION_INFO_DEF, "", 0); + + player->SEND_GOSSIP_MENU(5584, _GO->GetGUID()); + + return true; +}*/ + +/*### +# +###*/ + +void AddSC_npc_professions() +{ + Script *newscript; + + newscript = new Script; + newscript->Name="npc_prof_alchemy"; + newscript->pGossipHello = &GossipHello_npc_prof_alchemy; + newscript->pGossipSelect = &GossipSelect_npc_prof_alchemy; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="npc_prof_blacksmith"; + newscript->pGossipHello = &GossipHello_npc_prof_blacksmith; + newscript->pGossipSelect = &GossipSelect_npc_prof_blacksmith; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="npc_prof_leather"; + newscript->pGossipHello = &GossipHello_npc_prof_leather; + newscript->pGossipSelect = &GossipSelect_npc_prof_leather; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="npc_prof_tailor"; + newscript->pGossipHello = &GossipHello_npc_prof_tailor; + newscript->pGossipSelect = &GossipSelect_npc_prof_tailor; + m_scripts[nrscripts++] = newscript; + + /*newscript = new Script; + newscript->Name="go_soothsaying_for_dummies"; + newscript->pGOHello = &GOHello_go_soothsaying_for_dummies; + //newscript->pGossipSelect = &GossipSelect_go_soothsaying_for_dummies; + m_scripts[nrscripts++] = newscript;*/ +} diff --git a/src/bindings/scripts/scripts/npc/npcs_special.cpp b/src/bindings/scripts/scripts/npc/npcs_special.cpp index a8ea8612c58..c7faf4032a6 100644 --- a/src/bindings/scripts/scripts/npc/npcs_special.cpp +++ b/src/bindings/scripts/scripts/npc/npcs_special.cpp @@ -1,878 +1,878 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Npcs_Special -SD%Complete: 100 -SDComment: To be used for special NPCs that are located globally. Support for quest 3861 (Cluck!), 6622 and 6624 (Triage) -SDCategory: NPCs -EndScriptData -*/ - -/* ContentData -npc_chicken_cluck 100% support for quest 3861 (Cluck!) -npc_dancing_flames 100% midsummer event NPC -npc_guardian 100% guardianAI used to prevent players from accessing off-limits areas. Not in use by SD2 -npc_injured_patient 100% patients for triage-quests (6622 and 6624) -npc_doctor 100% Gustaf Vanhowzen and Gregory Victor, quest 6622 and 6624 (Triage) -npc_mount_vendor 100% Regular mount vendors all over the world. Display gossip if player doesn't meet the requirements to buy -npc_rogue_trainer 80% Scripted trainers, so they are able to offer item 17126 for class quest 6681 -npc_sayge 100% Darkmoon event fortune teller, buff player based on answers given -EndContentData */ - -#include "precompiled.h" - -/*######## -# npc_chicken_cluck -#########*/ - -#define QUEST_CLUCK 3861 -#define EMOTE_A_HELLO "looks up at you quizzically. Maybe you should inspect it?" -#define EMOTE_H_HELLO "looks at you unexpectadly." -#define CLUCK_TEXT2 "starts pecking at the feed." -#define FACTION_FRIENDLY 84 -#define FACTION_CHICKEN 31 - -struct MANGOS_DLL_DECL npc_chicken_cluckAI : public ScriptedAI -{ - npc_chicken_cluckAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 ResetFlagTimer; - - void Reset() - { - ResetFlagTimer = 120000; - - m_creature->setFaction(FACTION_CHICKEN); - m_creature->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER); - } - - void Aggro(Unit *who) {} - - void UpdateAI(const uint32 diff) - { - // Reset flags after a certain time has passed so that the next player has to start the 'event' again - if(m_creature->HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER)) - { - if(ResetFlagTimer < diff) - EnterEvadeMode(); - else ResetFlagTimer -= diff; - } - - if(m_creature->SelectHostilTarget() && m_creature->getVictim()) - DoMeleeAttackIfReady(); - } -}; - -CreatureAI* GetAI_npc_chicken_cluck(Creature *_Creature) -{ - return new npc_chicken_cluckAI(_Creature); -} - -bool ReceiveEmote_npc_chicken_cluck( Player *player, Creature *_Creature, uint32 emote ) -{ - if( emote == TEXTEMOTE_CHICKEN ) - { - if( player->GetTeam() == ALLIANCE ) - { - if( rand()%30 == 1 ) - { - if( player->GetQuestStatus(QUEST_CLUCK) == QUEST_STATUS_NONE ) - { - _Creature->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER); - _Creature->setFaction(FACTION_FRIENDLY); - _Creature->MonsterTextEmote(EMOTE_A_HELLO, 0); - } - } - } else - _Creature->MonsterTextEmote(EMOTE_H_HELLO,0); - } - if( emote == TEXTEMOTE_CHEER && player->GetTeam() == ALLIANCE ) - if( player->GetQuestStatus(QUEST_CLUCK) == QUEST_STATUS_COMPLETE ) - { - _Creature->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER); - _Creature->setFaction(FACTION_FRIENDLY); - _Creature->MonsterTextEmote(CLUCK_TEXT2, 0); - } - - return true; -} - -bool QuestAccept_npc_chicken_cluck(Player *player, Creature *_Creature, const Quest *_Quest ) -{ - if(_Quest->GetQuestId() == QUEST_CLUCK) - ((npc_chicken_cluckAI*)_Creature->AI())->Reset(); - - return true; -} - -bool QuestComplete_npc_chicken_cluck(Player *player, Creature *_Creature, const Quest *_Quest) -{ - if(_Quest->GetQuestId() == QUEST_CLUCK) - ((npc_chicken_cluckAI*)_Creature->AI())->Reset(); - - return true; -} - -/*###### -## npc_dancing_flames -######*/ - -bool ReceiveEmote_npc_dancing_flames( Player *player, Creature *_Creature, uint32 emote ) -{ - if( emote == TEXTEMOTE_DANCE ) - _Creature->CastSpell(player,47057,false); - - return true; -} - -/*###### -## Triage quest -######*/ - -#define SAY_DOC1 "I'm saved! Thank you, doctor!" -#define SAY_DOC2 "HOORAY! I AM SAVED!" -#define SAY_DOC3 "Sweet, sweet embrace... take me..." - -struct Location -{ - float x, y, z, o; -}; - -#define DOCTOR_ALLIANCE 12939 - -static Location AllianceCoords[]= -{ - { // Top-far-right bunk as seen from entrance - -3757.38, -4533.05, 14.16, 3.62 - }, - { // Top-far-left bunk - -3754.36, -4539.13, 14.16, 5.13 - }, - { // Far-right bunk - -3749.54, -4540.25, 14.28, 3.34 - }, - { // Right bunk near entrance - -3742.10, -4536.85, 14.28, 3.64 - }, - { // Far-left bunk - -3755.89, -4529.07, 14.05, 0.57 - }, - { // Mid-left bunk - -3749.51, -4527.08, 14.07, 5.26 - }, - { // Left bunk near entrance - -3746.37, -4525.35, 14.16, 5.22 - }, -}; - -#define ALLIANCE_COORDS 7 - -//alliance run to where -#define A_RUNTOX -3742.96 -#define A_RUNTOY -4531.52 -#define A_RUNTOZ 11.91 - -#define DOCTOR_HORDE 12920 - -static Location HordeCoords[]= -{ - { // Left, Behind - -1013.75, -3492.59, 62.62, 4.34 - }, - { // Right, Behind - -1017.72, -3490.92, 62.62, 4.34 - }, - { // Left, Mid - -1015.77, -3497.15, 62.82, 4.34 - }, - { // Right, Mid - -1019.51, -3495.49, 62.82, 4.34 - }, - { // Left, front - -1017.25, -3500.85, 62.98, 4.34 - }, - { // Right, Front - -1020.95, -3499.21, 62.98, 4.34 - } -}; - -#define HORDE_COORDS 6 - -//horde run to where -#define H_RUNTOX -1016.44 -#define H_RUNTOY -3508.48 -#define H_RUNTOZ 62.96 - -const uint32 AllianceSoldierId[3] = -{ - 12938, // 12938 Injured Alliance Soldier - 12936, // 12936 Badly injured Alliance Soldier - 12937 // 12937 Critically injured Alliance Soldier -}; - -const uint32 HordeSoldierId[3] = -{ - 12923, //12923 Injured Soldier - 12924, //12924 Badly injured Soldier - 12925 //12925 Critically injured Soldier -}; - -/*###### -## npc_doctor (handles both Gustaf Vanhowzen and Gregory Victor) -######*/ - -struct MANGOS_DLL_DECL npc_doctorAI : public ScriptedAI -{ - uint64 Playerguid; - - uint32 SummonPatient_Timer; - uint32 SummonPatientCount; - uint32 PatientDiedCount; - uint32 PatientSavedCount; - - bool Event; - - std::list Patients; - std::vector Coordinates; - - npc_doctorAI(Creature *c) : ScriptedAI(c) {Reset();} - - void Reset(){} - - void BeginEvent(Player* player); - void PatientDied(Location* Point); - void PatientSaved(Creature* soldier, Player* player, Location* Point); - void UpdateAI(const uint32 diff); - - void Aggro(Unit* who){} -}; - -/*##### -## npc_injured_patient (handles all the patients, no matter Horde or Alliance) -#####*/ - -struct MANGOS_DLL_DECL npc_injured_patientAI : public ScriptedAI -{ - npc_injured_patientAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint64 Doctorguid; - - Location* Coord; - - void Reset() - { - Doctorguid = 0; - - Coord = NULL; - //no select - m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - //no regen health - m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IN_COMBAT); - //to make them lay with face down - m_creature->SetUInt32Value(UNIT_FIELD_BYTES_1, PLAYER_STATE_DEAD); - - uint32 mobId = m_creature->GetEntry(); - - switch (mobId) - { //lower max health - case 12923: - case 12938: //Injured Soldier - m_creature->SetHealth(uint32(m_creature->GetMaxHealth()*.75)); - break; - case 12924: - case 12936: //Badly injured Soldier - m_creature->SetHealth(uint32(m_creature->GetMaxHealth()*.50)); - break; - case 12925: - case 12937: //Critically injured Soldier - m_creature->SetHealth(uint32(m_creature->GetMaxHealth()*.25)); - break; - } - } - - void Aggro(Unit* who){} - - void SpellHit(Unit *caster, const SpellEntry *spell) - { - if (caster->GetTypeId() == TYPEID_PLAYER && m_creature->isAlive() && spell->Id == 20804) - { - if( (((Player*)caster)->GetQuestStatus(6624) == QUEST_STATUS_INCOMPLETE) || (((Player*)caster)->GetQuestStatus(6622) == QUEST_STATUS_INCOMPLETE)) - { - if(Doctorguid) - { - Creature* Doctor = ((Creature*)Unit::GetUnit((*m_creature), Doctorguid)); - if(Doctor) - ((npc_doctorAI*)Doctor->AI())->PatientSaved(m_creature, ((Player*)caster), Coord); - } - } - //make not selectable - m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - //regen health - m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IN_COMBAT); - //stand up - m_creature->SetUInt32Value(UNIT_FIELD_BYTES_1, PLAYER_STATE_NONE); - DoSay(SAY_DOC1,LANG_UNIVERSAL,NULL); - - uint32 mobId = m_creature->GetEntry(); - m_creature->RemoveUnitMovementFlag(MOVEMENTFLAG_WALK_MODE); - switch (mobId) - { - case 12923: - case 12924: - case 12925: - m_creature->GetMotionMaster()->MovePoint(0, H_RUNTOX, H_RUNTOY, H_RUNTOZ); - break; - case 12936: - case 12937: - case 12938: - m_creature->GetMotionMaster()->MovePoint(0, A_RUNTOX, A_RUNTOY, A_RUNTOZ); - break; - } - } - return; - } - - void UpdateAI(const uint32 diff) - { - if (m_creature->isAlive() && m_creature->GetHealth() > 6) - { //lower HP on every world tick makes it a useful counter, not officlone though - m_creature->SetHealth(uint32(m_creature->GetHealth()-5) ); - } - - if (m_creature->isAlive() && m_creature->GetHealth() <= 6) - { - m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IN_COMBAT); - m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - m_creature->setDeathState(JUST_DIED); - m_creature->SetFlag(UNIT_DYNAMIC_FLAGS, 32); - - if(Doctorguid) - { - Creature* Doctor = ((Creature*)Unit::GetUnit((*m_creature), Doctorguid)); - if(Doctor) - ((npc_doctorAI*)Doctor->AI())->PatientDied(Coord); - } - } - } -}; - -CreatureAI* GetAI_npc_injured_patient(Creature *_Creature) -{ - return new npc_injured_patientAI (_Creature); -} - -/* -npc_doctor (continue) -*/ - -void npc_doctorAI::BeginEvent(Player* player) -{ - Playerguid = player->GetGUID(); - - SummonPatient_Timer = 10000; - SummonPatientCount = 0; - PatientDiedCount = 0; - PatientSavedCount = 0; - - switch(m_creature->GetEntry()) - { - case DOCTOR_ALLIANCE: - for(uint8 i = 0; i < ALLIANCE_COORDS; ++i) - Coordinates.push_back(&AllianceCoords[i]); - break; - - case DOCTOR_HORDE: - for(uint8 i = 0; i < HORDE_COORDS; ++i) - Coordinates.push_back(&HordeCoords[i]); - break; - } - - Event = true; - - m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); -} - -void npc_doctorAI::PatientDied(Location* Point) -{ - Player* player = ((Player*)Unit::GetUnit((*m_creature), Playerguid)); - if(player && ((player->GetQuestStatus(6624) == QUEST_STATUS_INCOMPLETE) || (player->GetQuestStatus(6622) == QUEST_STATUS_INCOMPLETE))) - { - PatientDiedCount++; - if (PatientDiedCount > 5 && Event) - { - if(player->GetQuestStatus(6624) == QUEST_STATUS_INCOMPLETE) - player->FailQuest(6624); - else if(player->GetQuestStatus(6622) == QUEST_STATUS_INCOMPLETE) - player->FailQuest(6622); - - Event = false; - m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - } - - Coordinates.push_back(Point); - } -} - -void npc_doctorAI::PatientSaved(Creature* soldier, Player* player, Location* Point) -{ - if(player && Playerguid == player->GetGUID()) - { - if((player->GetQuestStatus(6624) == QUEST_STATUS_INCOMPLETE) || (player->GetQuestStatus(6622) == QUEST_STATUS_INCOMPLETE)) - { - PatientSavedCount++; - if(PatientSavedCount == 15) - { - if(!Patients.empty()) - { - std::list::iterator itr; - for(itr = Patients.begin(); itr != Patients.end(); ++itr) - { - Creature* Patient = ((Creature*)Unit::GetUnit((*m_creature), *itr)); - if( Patient ) - Patient->setDeathState(JUST_DIED); - } - } - - if(player->GetQuestStatus(6624) == QUEST_STATUS_INCOMPLETE) - player->AreaExploredOrEventHappens(6624); - else if(player->GetQuestStatus(6622) == QUEST_STATUS_INCOMPLETE) - player->AreaExploredOrEventHappens(6622); - - Event = false; - m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - } - - Coordinates.push_back(Point); - } - } -} - -void npc_doctorAI::UpdateAI(const uint32 diff) -{ - if(Event && SummonPatientCount >= 20) - { - Event = false; - m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - } - - if(Event) - if(SummonPatient_Timer < diff) - { - Creature* Patient = NULL; - Location* Point = NULL; - - if(Coordinates.empty()) - return; - - std::vector::iterator itr = Coordinates.begin()+rand()%Coordinates.size(); - uint32 patientEntry = 0; - - switch(m_creature->GetEntry()) - { - case DOCTOR_ALLIANCE: patientEntry = AllianceSoldierId[rand()%3]; break; - case DOCTOR_HORDE: patientEntry = HordeSoldierId[rand()%3]; break; - default: - error_log("SD2: Invalid entry for Triage doctor. Please check your database"); - return; - } - - Point = *itr; - - Patient = m_creature->SummonCreature(patientEntry, Point->x, Point->y, Point->z, Point->o, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000); - - if(Patient) - { - Patients.push_back(Patient->GetGUID()); - ((npc_injured_patientAI*)Patient->AI())->Doctorguid = m_creature->GetGUID(); - if(Point) - ((npc_injured_patientAI*)Patient->AI())->Coord = Point; - Coordinates.erase(itr); - } - SummonPatient_Timer = 10000; - SummonPatientCount++; - }else SummonPatient_Timer -= diff; -} - -bool QuestAccept_npc_doctor(Player *player, Creature *creature, Quest const *quest ) -{ - if((quest->GetQuestId() == 6624) || (quest->GetQuestId() == 6622)) - ((npc_doctorAI*)creature->AI())->BeginEvent(player); - - return true; -} - -CreatureAI* GetAI_npc_doctor(Creature *_Creature) -{ - return new npc_doctorAI (_Creature); -} - -/*###### -## npc_guardian -######*/ - -#define SPELL_DEATHTOUCH 5 -#define SAY_AGGRO "This area is closed!" - -struct MANGOS_DLL_DECL npc_guardianAI : public ScriptedAI -{ - npc_guardianAI(Creature *c) : ScriptedAI(c) {Reset();} - - void Reset() - { - m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); - } - - void Aggro(Unit *who) - { - DoYell(SAY_AGGRO,LANG_UNIVERSAL,NULL); - } - - void UpdateAI(const uint32 diff) - { - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - if (m_creature->isAttackReady()) - { - m_creature->CastSpell(m_creature->getVictim(),SPELL_DEATHTOUCH, true); - m_creature->resetAttackTimer(); - } - } -}; - -CreatureAI* GetAI_npc_guardian(Creature *_Creature) -{ - return new npc_guardianAI (_Creature); -} - -/*###### -## npc_mount_vendor -######*/ - -bool GossipHello_npc_mount_vendor(Player *player, Creature *_Creature) -{ - if (_Creature->isQuestGiver()) - player->PrepareQuestMenu( _Creature->GetGUID() ); - - bool canBuy; - canBuy = false; - uint32 vendor = _Creature->GetEntry(); - uint8 race = player->getRace(); - - switch (vendor) - { - case 384: //Katie Hunter - case 1460: //Unger Statforth - case 2357: //Merideth Carlson - case 4885: //Gregor MacVince - if (player->GetReputationRank(72) != REP_EXALTED && race != RACE_HUMAN) - player->SEND_GOSSIP_MENU(5855, _Creature->GetGUID()); - else canBuy = true; - break; - case 1261: //Veron Amberstill - if (player->GetReputationRank(47) != REP_EXALTED && race != RACE_DWARF) - player->SEND_GOSSIP_MENU(5856, _Creature->GetGUID()); - else canBuy = true; - break; - case 3362: //Ogunaro Wolfrunner - if (player->GetReputationRank(76) != REP_EXALTED && race != RACE_ORC) - player->SEND_GOSSIP_MENU(5841, _Creature->GetGUID()); - else canBuy = true; - break; - case 3685: //Harb Clawhoof - if (player->GetReputationRank(81) != REP_EXALTED && race != RACE_TAUREN) - player->SEND_GOSSIP_MENU(5843, _Creature->GetGUID()); - else canBuy = true; - break; - case 4730: //Lelanai - if (player->GetReputationRank(69) != REP_EXALTED && race != RACE_NIGHTELF) - player->SEND_GOSSIP_MENU(5844, _Creature->GetGUID()); - else canBuy = true; - break; - case 4731: //Zachariah Post - if (player->GetReputationRank(68) != REP_EXALTED && race != RACE_UNDEAD_PLAYER) - player->SEND_GOSSIP_MENU(5840, _Creature->GetGUID()); - else canBuy = true; - break; - case 7952: //Zjolnir - if (player->GetReputationRank(530) != REP_EXALTED && race != RACE_TROLL) - player->SEND_GOSSIP_MENU(5842, _Creature->GetGUID()); - else canBuy = true; - break; - case 7955: //Milli Featherwhistle - if (player->GetReputationRank(54) != REP_EXALTED && race != RACE_GNOME) - player->SEND_GOSSIP_MENU(5857, _Creature->GetGUID()); - else canBuy = true; - break; - case 16264: //Winaestra - if (player->GetReputationRank(911) != REP_EXALTED && race != RACE_BLOODELF) - player->SEND_GOSSIP_MENU(10305, _Creature->GetGUID()); - else canBuy = true; - break; - case 17584: //Torallius the Pack Handler - if (player->GetReputationRank(930) != REP_EXALTED && race != RACE_DRAENEI) - player->SEND_GOSSIP_MENU(10239, _Creature->GetGUID()); - else canBuy = true; - break; - } - - if (canBuy) - { - if (_Creature->isVendor()) - player->ADD_GOSSIP_ITEM( 1, GOSSIP_TEXT_BROWSE_GOODS, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_TRADE); - player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); - } - return true; -} - -bool GossipSelect_npc_mount_vendor(Player *player, Creature *_Creature, uint32 sender, uint32 action) -{ - if (action == GOSSIP_ACTION_TRADE) - player->SEND_VENDORLIST( _Creature->GetGUID() ); - - return true; -} - -/*###### -## npc_rogue_trainer -######*/ - -bool GossipHello_npc_rogue_trainer(Player *player, Creature *_Creature) -{ - if( _Creature->isQuestGiver() ) - player->PrepareQuestMenu( _Creature->GetGUID() ); - - if( _Creature->isTrainer() ) - player->ADD_GOSSIP_ITEM(2, GOSSIP_TEXT_TRAIN, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_TRAIN); - - if( _Creature->isCanTrainingAndResetTalentsOf(player) ) - player->ADD_GOSSIP_ITEM(2, "I wish to unlearn my talents", GOSSIP_SENDER_MAIN, GOSSIP_OPTION_UNLEARNTALENTS); - - if( player->getClass() == CLASS_ROGUE && player->getLevel() >= 24 && !player->HasItemCount(17126,1) && !player->GetQuestRewardStatus(6681) ) - { - player->ADD_GOSSIP_ITEM(0, "", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); - player->SEND_GOSSIP_MENU(5996, _Creature->GetGUID()); - } else - player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); - - return true; -} - -bool GossipSelect_npc_rogue_trainer(Player *player, Creature *_Creature, uint32 sender, uint32 action) -{ - switch( action ) - { - case GOSSIP_ACTION_INFO_DEF+1: - player->CLOSE_GOSSIP_MENU(); - player->CastSpell(player,21100,false); - break; - case GOSSIP_ACTION_TRAIN: - player->SEND_TRAINERLIST( _Creature->GetGUID() ); - break; - case GOSSIP_OPTION_UNLEARNTALENTS: - player->CLOSE_GOSSIP_MENU(); - player->SendTalentWipeConfirm( _Creature->GetGUID() ); - break; - } - return true; -} - -/*###### -## npc_sayge -######*/ - -#define SPELL_DMG 23768 //dmg -#define SPELL_RES 23769 //res -#define SPELL_ARM 23767 //arm -#define SPELL_SPI 23738 //spi -#define SPELL_INT 23766 //int -#define SPELL_STM 23737 //stm -#define SPELL_STR 23735 //str -#define SPELL_AGI 23736 //agi -#define SPELL_FORTUNE 23765 //faire fortune - -bool GossipHello_npc_sayge(Player *player, Creature *_Creature) -{ - if(_Creature->isQuestGiver()) - player->PrepareQuestMenu( _Creature->GetGUID() ); - - if( player->HasSpellCooldown(SPELL_INT) || - player->HasSpellCooldown(SPELL_ARM) || - player->HasSpellCooldown(SPELL_DMG) || - player->HasSpellCooldown(SPELL_RES) || - player->HasSpellCooldown(SPELL_STR) || - player->HasSpellCooldown(SPELL_AGI) || - player->HasSpellCooldown(SPELL_STM) || - player->HasSpellCooldown(SPELL_SPI) ) - player->SEND_GOSSIP_MENU(7393, _Creature->GetGUID()); - else - { - player->ADD_GOSSIP_ITEM(0, "Yes", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); - player->SEND_GOSSIP_MENU(7339, _Creature->GetGUID()); - } - - return true; -} - -void SendAction_npc_sayge(Player *player, Creature *_Creature, uint32 action) -{ - switch(action) - { - case GOSSIP_ACTION_INFO_DEF+1: - player->ADD_GOSSIP_ITEM(0, "Slay the Man", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2); - player->ADD_GOSSIP_ITEM(0, "Turn him over to liege", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+3); - player->ADD_GOSSIP_ITEM(0, "Confiscate the corn", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+4); - player->ADD_GOSSIP_ITEM(0, "Let him go and have the corn", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+5); - player->SEND_GOSSIP_MENU(7340, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+2: - player->ADD_GOSSIP_ITEM(0, "Execute your friend painfully", GOSSIP_SENDER_MAIN+1, GOSSIP_ACTION_INFO_DEF); - player->ADD_GOSSIP_ITEM(0, "Execute your friend painlessly", GOSSIP_SENDER_MAIN+2, GOSSIP_ACTION_INFO_DEF); - player->ADD_GOSSIP_ITEM(0, "Let your friend go", GOSSIP_SENDER_MAIN+3, GOSSIP_ACTION_INFO_DEF); - player->SEND_GOSSIP_MENU(7341, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+3: - player->ADD_GOSSIP_ITEM(0, "Confront the diplomat", GOSSIP_SENDER_MAIN+4, GOSSIP_ACTION_INFO_DEF); - player->ADD_GOSSIP_ITEM(0, "Show not so quiet defiance", GOSSIP_SENDER_MAIN+5, GOSSIP_ACTION_INFO_DEF); - player->ADD_GOSSIP_ITEM(0, "Remain quiet", GOSSIP_SENDER_MAIN+2, GOSSIP_ACTION_INFO_DEF); - player->SEND_GOSSIP_MENU(7361, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+4: - player->ADD_GOSSIP_ITEM(0, "Speak against your brother openly", GOSSIP_SENDER_MAIN+6, GOSSIP_ACTION_INFO_DEF); - player->ADD_GOSSIP_ITEM(0, "Help your brother in", GOSSIP_SENDER_MAIN+7, GOSSIP_ACTION_INFO_DEF); - player->ADD_GOSSIP_ITEM(0, "Keep your brother out without letting him know", GOSSIP_SENDER_MAIN+8, GOSSIP_ACTION_INFO_DEF); - player->SEND_GOSSIP_MENU(7362, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+5: - player->ADD_GOSSIP_ITEM(0, "Take credit, keep gold", GOSSIP_SENDER_MAIN+5, GOSSIP_ACTION_INFO_DEF); - player->ADD_GOSSIP_ITEM(0, "Take credit, share the gold", GOSSIP_SENDER_MAIN+4, GOSSIP_ACTION_INFO_DEF); - player->ADD_GOSSIP_ITEM(0, "Let the knight take credit", GOSSIP_SENDER_MAIN+3, GOSSIP_ACTION_INFO_DEF); - player->SEND_GOSSIP_MENU(7363, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF: - player->ADD_GOSSIP_ITEM(0, "Thanks", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+6); - player->SEND_GOSSIP_MENU(7364, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+6: - _Creature->CastSpell(player, SPELL_FORTUNE, false); - player->SEND_GOSSIP_MENU(7365, _Creature->GetGUID()); - break; - } -} - -bool GossipSelect_npc_sayge(Player *player, Creature *_Creature, uint32 sender, uint32 action ) -{ - switch(sender) - { - case GOSSIP_SENDER_MAIN: - SendAction_npc_sayge(player, _Creature, action); - break; - case GOSSIP_SENDER_MAIN+1: - _Creature->CastSpell(player, SPELL_DMG, false); - player->AddSpellCooldown(SPELL_DMG,0,time(NULL) + 7200); - SendAction_npc_sayge(player, _Creature, action); - break; - case GOSSIP_SENDER_MAIN+2: - _Creature->CastSpell(player, SPELL_RES, false); - player->AddSpellCooldown(SPELL_RES,0,time(NULL) + 7200); - SendAction_npc_sayge(player, _Creature, action); - break; - case GOSSIP_SENDER_MAIN+3: - _Creature->CastSpell(player, SPELL_ARM, false); - player->AddSpellCooldown(SPELL_ARM,0,time(NULL) + 7200); - SendAction_npc_sayge(player, _Creature, action); - break; - case GOSSIP_SENDER_MAIN+4: - _Creature->CastSpell(player, SPELL_SPI, false); - player->AddSpellCooldown(SPELL_SPI,0,time(NULL) + 7200); - SendAction_npc_sayge(player, _Creature, action); - break; - case GOSSIP_SENDER_MAIN+5: - _Creature->CastSpell(player, SPELL_INT, false); - player->AddSpellCooldown(SPELL_INT,0,time(NULL) + 7200); - SendAction_npc_sayge(player, _Creature, action); - break; - case GOSSIP_SENDER_MAIN+6: - _Creature->CastSpell(player, SPELL_STM, false); - player->AddSpellCooldown(SPELL_STM,0,time(NULL) + 7200); - SendAction_npc_sayge(player, _Creature, action); - break; - case GOSSIP_SENDER_MAIN+7: - _Creature->CastSpell(player, SPELL_STR, false); - player->AddSpellCooldown(SPELL_STR,0,time(NULL) + 7200); - SendAction_npc_sayge(player, _Creature, action); - break; - case GOSSIP_SENDER_MAIN+8: - _Creature->CastSpell(player, SPELL_AGI, false); - player->AddSpellCooldown(SPELL_AGI,0,time(NULL) + 7200); - SendAction_npc_sayge(player, _Creature, action); - break; - } - return true; -} - -void AddSC_npcs_special() -{ - Script *newscript; - - newscript = new Script; - newscript->Name="npc_chicken_cluck"; - newscript->GetAI = GetAI_npc_chicken_cluck; - newscript->pReceiveEmote = &ReceiveEmote_npc_chicken_cluck; - newscript->pQuestAccept = &QuestAccept_npc_chicken_cluck; - newscript->pQuestComplete = &QuestComplete_npc_chicken_cluck; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="npc_dancing_flames"; - newscript->pReceiveEmote = &ReceiveEmote_npc_dancing_flames; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="npc_injured_patient"; - newscript->GetAI = GetAI_npc_injured_patient; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="npc_doctor"; - newscript->GetAI = GetAI_npc_doctor; - newscript->pQuestAccept = &QuestAccept_npc_doctor; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="npc_guardian"; - newscript->GetAI = GetAI_npc_guardian; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="npc_mount_vendor"; - newscript->pGossipHello = &GossipHello_npc_mount_vendor; - newscript->pGossipSelect = &GossipSelect_npc_mount_vendor; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="npc_rogue_trainer"; - newscript->pGossipHello = &GossipHello_npc_rogue_trainer; - newscript->pGossipSelect = &GossipSelect_npc_rogue_trainer; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="npc_sayge"; - newscript->pGossipHello = &GossipHello_npc_sayge; - newscript->pGossipSelect = &GossipSelect_npc_sayge; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Npcs_Special +SD%Complete: 100 +SDComment: To be used for special NPCs that are located globally. Support for quest 3861 (Cluck!), 6622 and 6624 (Triage) +SDCategory: NPCs +EndScriptData +*/ + +/* ContentData +npc_chicken_cluck 100% support for quest 3861 (Cluck!) +npc_dancing_flames 100% midsummer event NPC +npc_guardian 100% guardianAI used to prevent players from accessing off-limits areas. Not in use by SD2 +npc_injured_patient 100% patients for triage-quests (6622 and 6624) +npc_doctor 100% Gustaf Vanhowzen and Gregory Victor, quest 6622 and 6624 (Triage) +npc_mount_vendor 100% Regular mount vendors all over the world. Display gossip if player doesn't meet the requirements to buy +npc_rogue_trainer 80% Scripted trainers, so they are able to offer item 17126 for class quest 6681 +npc_sayge 100% Darkmoon event fortune teller, buff player based on answers given +EndContentData */ + +#include "precompiled.h" + +/*######## +# npc_chicken_cluck +#########*/ + +#define QUEST_CLUCK 3861 +#define EMOTE_A_HELLO "looks up at you quizzically. Maybe you should inspect it?" +#define EMOTE_H_HELLO "looks at you unexpectadly." +#define CLUCK_TEXT2 "starts pecking at the feed." +#define FACTION_FRIENDLY 84 +#define FACTION_CHICKEN 31 + +struct MANGOS_DLL_DECL npc_chicken_cluckAI : public ScriptedAI +{ + npc_chicken_cluckAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 ResetFlagTimer; + + void Reset() + { + ResetFlagTimer = 120000; + + m_creature->setFaction(FACTION_CHICKEN); + m_creature->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER); + } + + void Aggro(Unit *who) {} + + void UpdateAI(const uint32 diff) + { + // Reset flags after a certain time has passed so that the next player has to start the 'event' again + if(m_creature->HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER)) + { + if(ResetFlagTimer < diff) + EnterEvadeMode(); + else ResetFlagTimer -= diff; + } + + if(m_creature->SelectHostilTarget() && m_creature->getVictim()) + DoMeleeAttackIfReady(); + } +}; + +CreatureAI* GetAI_npc_chicken_cluck(Creature *_Creature) +{ + return new npc_chicken_cluckAI(_Creature); +} + +bool ReceiveEmote_npc_chicken_cluck( Player *player, Creature *_Creature, uint32 emote ) +{ + if( emote == TEXTEMOTE_CHICKEN ) + { + if( player->GetTeam() == ALLIANCE ) + { + if( rand()%30 == 1 ) + { + if( player->GetQuestStatus(QUEST_CLUCK) == QUEST_STATUS_NONE ) + { + _Creature->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER); + _Creature->setFaction(FACTION_FRIENDLY); + _Creature->MonsterTextEmote(EMOTE_A_HELLO, 0); + } + } + } else + _Creature->MonsterTextEmote(EMOTE_H_HELLO,0); + } + if( emote == TEXTEMOTE_CHEER && player->GetTeam() == ALLIANCE ) + if( player->GetQuestStatus(QUEST_CLUCK) == QUEST_STATUS_COMPLETE ) + { + _Creature->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER); + _Creature->setFaction(FACTION_FRIENDLY); + _Creature->MonsterTextEmote(CLUCK_TEXT2, 0); + } + + return true; +} + +bool QuestAccept_npc_chicken_cluck(Player *player, Creature *_Creature, const Quest *_Quest ) +{ + if(_Quest->GetQuestId() == QUEST_CLUCK) + ((npc_chicken_cluckAI*)_Creature->AI())->Reset(); + + return true; +} + +bool QuestComplete_npc_chicken_cluck(Player *player, Creature *_Creature, const Quest *_Quest) +{ + if(_Quest->GetQuestId() == QUEST_CLUCK) + ((npc_chicken_cluckAI*)_Creature->AI())->Reset(); + + return true; +} + +/*###### +## npc_dancing_flames +######*/ + +bool ReceiveEmote_npc_dancing_flames( Player *player, Creature *_Creature, uint32 emote ) +{ + if( emote == TEXTEMOTE_DANCE ) + _Creature->CastSpell(player,47057,false); + + return true; +} + +/*###### +## Triage quest +######*/ + +#define SAY_DOC1 "I'm saved! Thank you, doctor!" +#define SAY_DOC2 "HOORAY! I AM SAVED!" +#define SAY_DOC3 "Sweet, sweet embrace... take me..." + +struct Location +{ + float x, y, z, o; +}; + +#define DOCTOR_ALLIANCE 12939 + +static Location AllianceCoords[]= +{ + { // Top-far-right bunk as seen from entrance + -3757.38, -4533.05, 14.16, 3.62 + }, + { // Top-far-left bunk + -3754.36, -4539.13, 14.16, 5.13 + }, + { // Far-right bunk + -3749.54, -4540.25, 14.28, 3.34 + }, + { // Right bunk near entrance + -3742.10, -4536.85, 14.28, 3.64 + }, + { // Far-left bunk + -3755.89, -4529.07, 14.05, 0.57 + }, + { // Mid-left bunk + -3749.51, -4527.08, 14.07, 5.26 + }, + { // Left bunk near entrance + -3746.37, -4525.35, 14.16, 5.22 + }, +}; + +#define ALLIANCE_COORDS 7 + +//alliance run to where +#define A_RUNTOX -3742.96 +#define A_RUNTOY -4531.52 +#define A_RUNTOZ 11.91 + +#define DOCTOR_HORDE 12920 + +static Location HordeCoords[]= +{ + { // Left, Behind + -1013.75, -3492.59, 62.62, 4.34 + }, + { // Right, Behind + -1017.72, -3490.92, 62.62, 4.34 + }, + { // Left, Mid + -1015.77, -3497.15, 62.82, 4.34 + }, + { // Right, Mid + -1019.51, -3495.49, 62.82, 4.34 + }, + { // Left, front + -1017.25, -3500.85, 62.98, 4.34 + }, + { // Right, Front + -1020.95, -3499.21, 62.98, 4.34 + } +}; + +#define HORDE_COORDS 6 + +//horde run to where +#define H_RUNTOX -1016.44 +#define H_RUNTOY -3508.48 +#define H_RUNTOZ 62.96 + +const uint32 AllianceSoldierId[3] = +{ + 12938, // 12938 Injured Alliance Soldier + 12936, // 12936 Badly injured Alliance Soldier + 12937 // 12937 Critically injured Alliance Soldier +}; + +const uint32 HordeSoldierId[3] = +{ + 12923, //12923 Injured Soldier + 12924, //12924 Badly injured Soldier + 12925 //12925 Critically injured Soldier +}; + +/*###### +## npc_doctor (handles both Gustaf Vanhowzen and Gregory Victor) +######*/ + +struct MANGOS_DLL_DECL npc_doctorAI : public ScriptedAI +{ + uint64 Playerguid; + + uint32 SummonPatient_Timer; + uint32 SummonPatientCount; + uint32 PatientDiedCount; + uint32 PatientSavedCount; + + bool Event; + + std::list Patients; + std::vector Coordinates; + + npc_doctorAI(Creature *c) : ScriptedAI(c) {Reset();} + + void Reset(){} + + void BeginEvent(Player* player); + void PatientDied(Location* Point); + void PatientSaved(Creature* soldier, Player* player, Location* Point); + void UpdateAI(const uint32 diff); + + void Aggro(Unit* who){} +}; + +/*##### +## npc_injured_patient (handles all the patients, no matter Horde or Alliance) +#####*/ + +struct MANGOS_DLL_DECL npc_injured_patientAI : public ScriptedAI +{ + npc_injured_patientAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint64 Doctorguid; + + Location* Coord; + + void Reset() + { + Doctorguid = 0; + + Coord = NULL; + //no select + m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + //no regen health + m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IN_COMBAT); + //to make them lay with face down + m_creature->SetUInt32Value(UNIT_FIELD_BYTES_1, PLAYER_STATE_DEAD); + + uint32 mobId = m_creature->GetEntry(); + + switch (mobId) + { //lower max health + case 12923: + case 12938: //Injured Soldier + m_creature->SetHealth(uint32(m_creature->GetMaxHealth()*.75)); + break; + case 12924: + case 12936: //Badly injured Soldier + m_creature->SetHealth(uint32(m_creature->GetMaxHealth()*.50)); + break; + case 12925: + case 12937: //Critically injured Soldier + m_creature->SetHealth(uint32(m_creature->GetMaxHealth()*.25)); + break; + } + } + + void Aggro(Unit* who){} + + void SpellHit(Unit *caster, const SpellEntry *spell) + { + if (caster->GetTypeId() == TYPEID_PLAYER && m_creature->isAlive() && spell->Id == 20804) + { + if( (((Player*)caster)->GetQuestStatus(6624) == QUEST_STATUS_INCOMPLETE) || (((Player*)caster)->GetQuestStatus(6622) == QUEST_STATUS_INCOMPLETE)) + { + if(Doctorguid) + { + Creature* Doctor = ((Creature*)Unit::GetUnit((*m_creature), Doctorguid)); + if(Doctor) + ((npc_doctorAI*)Doctor->AI())->PatientSaved(m_creature, ((Player*)caster), Coord); + } + } + //make not selectable + m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + //regen health + m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IN_COMBAT); + //stand up + m_creature->SetUInt32Value(UNIT_FIELD_BYTES_1, PLAYER_STATE_NONE); + DoSay(SAY_DOC1,LANG_UNIVERSAL,NULL); + + uint32 mobId = m_creature->GetEntry(); + m_creature->RemoveUnitMovementFlag(MOVEMENTFLAG_WALK_MODE); + switch (mobId) + { + case 12923: + case 12924: + case 12925: + m_creature->GetMotionMaster()->MovePoint(0, H_RUNTOX, H_RUNTOY, H_RUNTOZ); + break; + case 12936: + case 12937: + case 12938: + m_creature->GetMotionMaster()->MovePoint(0, A_RUNTOX, A_RUNTOY, A_RUNTOZ); + break; + } + } + return; + } + + void UpdateAI(const uint32 diff) + { + if (m_creature->isAlive() && m_creature->GetHealth() > 6) + { //lower HP on every world tick makes it a useful counter, not officlone though + m_creature->SetHealth(uint32(m_creature->GetHealth()-5) ); + } + + if (m_creature->isAlive() && m_creature->GetHealth() <= 6) + { + m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IN_COMBAT); + m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + m_creature->setDeathState(JUST_DIED); + m_creature->SetFlag(UNIT_DYNAMIC_FLAGS, 32); + + if(Doctorguid) + { + Creature* Doctor = ((Creature*)Unit::GetUnit((*m_creature), Doctorguid)); + if(Doctor) + ((npc_doctorAI*)Doctor->AI())->PatientDied(Coord); + } + } + } +}; + +CreatureAI* GetAI_npc_injured_patient(Creature *_Creature) +{ + return new npc_injured_patientAI (_Creature); +} + +/* +npc_doctor (continue) +*/ + +void npc_doctorAI::BeginEvent(Player* player) +{ + Playerguid = player->GetGUID(); + + SummonPatient_Timer = 10000; + SummonPatientCount = 0; + PatientDiedCount = 0; + PatientSavedCount = 0; + + switch(m_creature->GetEntry()) + { + case DOCTOR_ALLIANCE: + for(uint8 i = 0; i < ALLIANCE_COORDS; ++i) + Coordinates.push_back(&AllianceCoords[i]); + break; + + case DOCTOR_HORDE: + for(uint8 i = 0; i < HORDE_COORDS; ++i) + Coordinates.push_back(&HordeCoords[i]); + break; + } + + Event = true; + + m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); +} + +void npc_doctorAI::PatientDied(Location* Point) +{ + Player* player = ((Player*)Unit::GetUnit((*m_creature), Playerguid)); + if(player && ((player->GetQuestStatus(6624) == QUEST_STATUS_INCOMPLETE) || (player->GetQuestStatus(6622) == QUEST_STATUS_INCOMPLETE))) + { + PatientDiedCount++; + if (PatientDiedCount > 5 && Event) + { + if(player->GetQuestStatus(6624) == QUEST_STATUS_INCOMPLETE) + player->FailQuest(6624); + else if(player->GetQuestStatus(6622) == QUEST_STATUS_INCOMPLETE) + player->FailQuest(6622); + + Event = false; + m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + } + + Coordinates.push_back(Point); + } +} + +void npc_doctorAI::PatientSaved(Creature* soldier, Player* player, Location* Point) +{ + if(player && Playerguid == player->GetGUID()) + { + if((player->GetQuestStatus(6624) == QUEST_STATUS_INCOMPLETE) || (player->GetQuestStatus(6622) == QUEST_STATUS_INCOMPLETE)) + { + PatientSavedCount++; + if(PatientSavedCount == 15) + { + if(!Patients.empty()) + { + std::list::iterator itr; + for(itr = Patients.begin(); itr != Patients.end(); ++itr) + { + Creature* Patient = ((Creature*)Unit::GetUnit((*m_creature), *itr)); + if( Patient ) + Patient->setDeathState(JUST_DIED); + } + } + + if(player->GetQuestStatus(6624) == QUEST_STATUS_INCOMPLETE) + player->AreaExploredOrEventHappens(6624); + else if(player->GetQuestStatus(6622) == QUEST_STATUS_INCOMPLETE) + player->AreaExploredOrEventHappens(6622); + + Event = false; + m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + } + + Coordinates.push_back(Point); + } + } +} + +void npc_doctorAI::UpdateAI(const uint32 diff) +{ + if(Event && SummonPatientCount >= 20) + { + Event = false; + m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + } + + if(Event) + if(SummonPatient_Timer < diff) + { + Creature* Patient = NULL; + Location* Point = NULL; + + if(Coordinates.empty()) + return; + + std::vector::iterator itr = Coordinates.begin()+rand()%Coordinates.size(); + uint32 patientEntry = 0; + + switch(m_creature->GetEntry()) + { + case DOCTOR_ALLIANCE: patientEntry = AllianceSoldierId[rand()%3]; break; + case DOCTOR_HORDE: patientEntry = HordeSoldierId[rand()%3]; break; + default: + error_log("SD2: Invalid entry for Triage doctor. Please check your database"); + return; + } + + Point = *itr; + + Patient = m_creature->SummonCreature(patientEntry, Point->x, Point->y, Point->z, Point->o, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000); + + if(Patient) + { + Patients.push_back(Patient->GetGUID()); + ((npc_injured_patientAI*)Patient->AI())->Doctorguid = m_creature->GetGUID(); + if(Point) + ((npc_injured_patientAI*)Patient->AI())->Coord = Point; + Coordinates.erase(itr); + } + SummonPatient_Timer = 10000; + SummonPatientCount++; + }else SummonPatient_Timer -= diff; +} + +bool QuestAccept_npc_doctor(Player *player, Creature *creature, Quest const *quest ) +{ + if((quest->GetQuestId() == 6624) || (quest->GetQuestId() == 6622)) + ((npc_doctorAI*)creature->AI())->BeginEvent(player); + + return true; +} + +CreatureAI* GetAI_npc_doctor(Creature *_Creature) +{ + return new npc_doctorAI (_Creature); +} + +/*###### +## npc_guardian +######*/ + +#define SPELL_DEATHTOUCH 5 +#define SAY_AGGRO "This area is closed!" + +struct MANGOS_DLL_DECL npc_guardianAI : public ScriptedAI +{ + npc_guardianAI(Creature *c) : ScriptedAI(c) {Reset();} + + void Reset() + { + m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + } + + void Aggro(Unit *who) + { + DoYell(SAY_AGGRO,LANG_UNIVERSAL,NULL); + } + + void UpdateAI(const uint32 diff) + { + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + if (m_creature->isAttackReady()) + { + m_creature->CastSpell(m_creature->getVictim(),SPELL_DEATHTOUCH, true); + m_creature->resetAttackTimer(); + } + } +}; + +CreatureAI* GetAI_npc_guardian(Creature *_Creature) +{ + return new npc_guardianAI (_Creature); +} + +/*###### +## npc_mount_vendor +######*/ + +bool GossipHello_npc_mount_vendor(Player *player, Creature *_Creature) +{ + if (_Creature->isQuestGiver()) + player->PrepareQuestMenu( _Creature->GetGUID() ); + + bool canBuy; + canBuy = false; + uint32 vendor = _Creature->GetEntry(); + uint8 race = player->getRace(); + + switch (vendor) + { + case 384: //Katie Hunter + case 1460: //Unger Statforth + case 2357: //Merideth Carlson + case 4885: //Gregor MacVince + if (player->GetReputationRank(72) != REP_EXALTED && race != RACE_HUMAN) + player->SEND_GOSSIP_MENU(5855, _Creature->GetGUID()); + else canBuy = true; + break; + case 1261: //Veron Amberstill + if (player->GetReputationRank(47) != REP_EXALTED && race != RACE_DWARF) + player->SEND_GOSSIP_MENU(5856, _Creature->GetGUID()); + else canBuy = true; + break; + case 3362: //Ogunaro Wolfrunner + if (player->GetReputationRank(76) != REP_EXALTED && race != RACE_ORC) + player->SEND_GOSSIP_MENU(5841, _Creature->GetGUID()); + else canBuy = true; + break; + case 3685: //Harb Clawhoof + if (player->GetReputationRank(81) != REP_EXALTED && race != RACE_TAUREN) + player->SEND_GOSSIP_MENU(5843, _Creature->GetGUID()); + else canBuy = true; + break; + case 4730: //Lelanai + if (player->GetReputationRank(69) != REP_EXALTED && race != RACE_NIGHTELF) + player->SEND_GOSSIP_MENU(5844, _Creature->GetGUID()); + else canBuy = true; + break; + case 4731: //Zachariah Post + if (player->GetReputationRank(68) != REP_EXALTED && race != RACE_UNDEAD_PLAYER) + player->SEND_GOSSIP_MENU(5840, _Creature->GetGUID()); + else canBuy = true; + break; + case 7952: //Zjolnir + if (player->GetReputationRank(530) != REP_EXALTED && race != RACE_TROLL) + player->SEND_GOSSIP_MENU(5842, _Creature->GetGUID()); + else canBuy = true; + break; + case 7955: //Milli Featherwhistle + if (player->GetReputationRank(54) != REP_EXALTED && race != RACE_GNOME) + player->SEND_GOSSIP_MENU(5857, _Creature->GetGUID()); + else canBuy = true; + break; + case 16264: //Winaestra + if (player->GetReputationRank(911) != REP_EXALTED && race != RACE_BLOODELF) + player->SEND_GOSSIP_MENU(10305, _Creature->GetGUID()); + else canBuy = true; + break; + case 17584: //Torallius the Pack Handler + if (player->GetReputationRank(930) != REP_EXALTED && race != RACE_DRAENEI) + player->SEND_GOSSIP_MENU(10239, _Creature->GetGUID()); + else canBuy = true; + break; + } + + if (canBuy) + { + if (_Creature->isVendor()) + player->ADD_GOSSIP_ITEM( 1, GOSSIP_TEXT_BROWSE_GOODS, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_TRADE); + player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); + } + return true; +} + +bool GossipSelect_npc_mount_vendor(Player *player, Creature *_Creature, uint32 sender, uint32 action) +{ + if (action == GOSSIP_ACTION_TRADE) + player->SEND_VENDORLIST( _Creature->GetGUID() ); + + return true; +} + +/*###### +## npc_rogue_trainer +######*/ + +bool GossipHello_npc_rogue_trainer(Player *player, Creature *_Creature) +{ + if( _Creature->isQuestGiver() ) + player->PrepareQuestMenu( _Creature->GetGUID() ); + + if( _Creature->isTrainer() ) + player->ADD_GOSSIP_ITEM(2, GOSSIP_TEXT_TRAIN, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_TRAIN); + + if( _Creature->isCanTrainingAndResetTalentsOf(player) ) + player->ADD_GOSSIP_ITEM(2, "I wish to unlearn my talents", GOSSIP_SENDER_MAIN, GOSSIP_OPTION_UNLEARNTALENTS); + + if( player->getClass() == CLASS_ROGUE && player->getLevel() >= 24 && !player->HasItemCount(17126,1) && !player->GetQuestRewardStatus(6681) ) + { + player->ADD_GOSSIP_ITEM(0, "", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); + player->SEND_GOSSIP_MENU(5996, _Creature->GetGUID()); + } else + player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); + + return true; +} + +bool GossipSelect_npc_rogue_trainer(Player *player, Creature *_Creature, uint32 sender, uint32 action) +{ + switch( action ) + { + case GOSSIP_ACTION_INFO_DEF+1: + player->CLOSE_GOSSIP_MENU(); + player->CastSpell(player,21100,false); + break; + case GOSSIP_ACTION_TRAIN: + player->SEND_TRAINERLIST( _Creature->GetGUID() ); + break; + case GOSSIP_OPTION_UNLEARNTALENTS: + player->CLOSE_GOSSIP_MENU(); + player->SendTalentWipeConfirm( _Creature->GetGUID() ); + break; + } + return true; +} + +/*###### +## npc_sayge +######*/ + +#define SPELL_DMG 23768 //dmg +#define SPELL_RES 23769 //res +#define SPELL_ARM 23767 //arm +#define SPELL_SPI 23738 //spi +#define SPELL_INT 23766 //int +#define SPELL_STM 23737 //stm +#define SPELL_STR 23735 //str +#define SPELL_AGI 23736 //agi +#define SPELL_FORTUNE 23765 //faire fortune + +bool GossipHello_npc_sayge(Player *player, Creature *_Creature) +{ + if(_Creature->isQuestGiver()) + player->PrepareQuestMenu( _Creature->GetGUID() ); + + if( player->HasSpellCooldown(SPELL_INT) || + player->HasSpellCooldown(SPELL_ARM) || + player->HasSpellCooldown(SPELL_DMG) || + player->HasSpellCooldown(SPELL_RES) || + player->HasSpellCooldown(SPELL_STR) || + player->HasSpellCooldown(SPELL_AGI) || + player->HasSpellCooldown(SPELL_STM) || + player->HasSpellCooldown(SPELL_SPI) ) + player->SEND_GOSSIP_MENU(7393, _Creature->GetGUID()); + else + { + player->ADD_GOSSIP_ITEM(0, "Yes", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); + player->SEND_GOSSIP_MENU(7339, _Creature->GetGUID()); + } + + return true; +} + +void SendAction_npc_sayge(Player *player, Creature *_Creature, uint32 action) +{ + switch(action) + { + case GOSSIP_ACTION_INFO_DEF+1: + player->ADD_GOSSIP_ITEM(0, "Slay the Man", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2); + player->ADD_GOSSIP_ITEM(0, "Turn him over to liege", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+3); + player->ADD_GOSSIP_ITEM(0, "Confiscate the corn", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+4); + player->ADD_GOSSIP_ITEM(0, "Let him go and have the corn", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+5); + player->SEND_GOSSIP_MENU(7340, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+2: + player->ADD_GOSSIP_ITEM(0, "Execute your friend painfully", GOSSIP_SENDER_MAIN+1, GOSSIP_ACTION_INFO_DEF); + player->ADD_GOSSIP_ITEM(0, "Execute your friend painlessly", GOSSIP_SENDER_MAIN+2, GOSSIP_ACTION_INFO_DEF); + player->ADD_GOSSIP_ITEM(0, "Let your friend go", GOSSIP_SENDER_MAIN+3, GOSSIP_ACTION_INFO_DEF); + player->SEND_GOSSIP_MENU(7341, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+3: + player->ADD_GOSSIP_ITEM(0, "Confront the diplomat", GOSSIP_SENDER_MAIN+4, GOSSIP_ACTION_INFO_DEF); + player->ADD_GOSSIP_ITEM(0, "Show not so quiet defiance", GOSSIP_SENDER_MAIN+5, GOSSIP_ACTION_INFO_DEF); + player->ADD_GOSSIP_ITEM(0, "Remain quiet", GOSSIP_SENDER_MAIN+2, GOSSIP_ACTION_INFO_DEF); + player->SEND_GOSSIP_MENU(7361, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+4: + player->ADD_GOSSIP_ITEM(0, "Speak against your brother openly", GOSSIP_SENDER_MAIN+6, GOSSIP_ACTION_INFO_DEF); + player->ADD_GOSSIP_ITEM(0, "Help your brother in", GOSSIP_SENDER_MAIN+7, GOSSIP_ACTION_INFO_DEF); + player->ADD_GOSSIP_ITEM(0, "Keep your brother out without letting him know", GOSSIP_SENDER_MAIN+8, GOSSIP_ACTION_INFO_DEF); + player->SEND_GOSSIP_MENU(7362, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+5: + player->ADD_GOSSIP_ITEM(0, "Take credit, keep gold", GOSSIP_SENDER_MAIN+5, GOSSIP_ACTION_INFO_DEF); + player->ADD_GOSSIP_ITEM(0, "Take credit, share the gold", GOSSIP_SENDER_MAIN+4, GOSSIP_ACTION_INFO_DEF); + player->ADD_GOSSIP_ITEM(0, "Let the knight take credit", GOSSIP_SENDER_MAIN+3, GOSSIP_ACTION_INFO_DEF); + player->SEND_GOSSIP_MENU(7363, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF: + player->ADD_GOSSIP_ITEM(0, "Thanks", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+6); + player->SEND_GOSSIP_MENU(7364, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+6: + _Creature->CastSpell(player, SPELL_FORTUNE, false); + player->SEND_GOSSIP_MENU(7365, _Creature->GetGUID()); + break; + } +} + +bool GossipSelect_npc_sayge(Player *player, Creature *_Creature, uint32 sender, uint32 action ) +{ + switch(sender) + { + case GOSSIP_SENDER_MAIN: + SendAction_npc_sayge(player, _Creature, action); + break; + case GOSSIP_SENDER_MAIN+1: + _Creature->CastSpell(player, SPELL_DMG, false); + player->AddSpellCooldown(SPELL_DMG,0,time(NULL) + 7200); + SendAction_npc_sayge(player, _Creature, action); + break; + case GOSSIP_SENDER_MAIN+2: + _Creature->CastSpell(player, SPELL_RES, false); + player->AddSpellCooldown(SPELL_RES,0,time(NULL) + 7200); + SendAction_npc_sayge(player, _Creature, action); + break; + case GOSSIP_SENDER_MAIN+3: + _Creature->CastSpell(player, SPELL_ARM, false); + player->AddSpellCooldown(SPELL_ARM,0,time(NULL) + 7200); + SendAction_npc_sayge(player, _Creature, action); + break; + case GOSSIP_SENDER_MAIN+4: + _Creature->CastSpell(player, SPELL_SPI, false); + player->AddSpellCooldown(SPELL_SPI,0,time(NULL) + 7200); + SendAction_npc_sayge(player, _Creature, action); + break; + case GOSSIP_SENDER_MAIN+5: + _Creature->CastSpell(player, SPELL_INT, false); + player->AddSpellCooldown(SPELL_INT,0,time(NULL) + 7200); + SendAction_npc_sayge(player, _Creature, action); + break; + case GOSSIP_SENDER_MAIN+6: + _Creature->CastSpell(player, SPELL_STM, false); + player->AddSpellCooldown(SPELL_STM,0,time(NULL) + 7200); + SendAction_npc_sayge(player, _Creature, action); + break; + case GOSSIP_SENDER_MAIN+7: + _Creature->CastSpell(player, SPELL_STR, false); + player->AddSpellCooldown(SPELL_STR,0,time(NULL) + 7200); + SendAction_npc_sayge(player, _Creature, action); + break; + case GOSSIP_SENDER_MAIN+8: + _Creature->CastSpell(player, SPELL_AGI, false); + player->AddSpellCooldown(SPELL_AGI,0,time(NULL) + 7200); + SendAction_npc_sayge(player, _Creature, action); + break; + } + return true; +} + +void AddSC_npcs_special() +{ + Script *newscript; + + newscript = new Script; + newscript->Name="npc_chicken_cluck"; + newscript->GetAI = GetAI_npc_chicken_cluck; + newscript->pReceiveEmote = &ReceiveEmote_npc_chicken_cluck; + newscript->pQuestAccept = &QuestAccept_npc_chicken_cluck; + newscript->pQuestComplete = &QuestComplete_npc_chicken_cluck; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="npc_dancing_flames"; + newscript->pReceiveEmote = &ReceiveEmote_npc_dancing_flames; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="npc_injured_patient"; + newscript->GetAI = GetAI_npc_injured_patient; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="npc_doctor"; + newscript->GetAI = GetAI_npc_doctor; + newscript->pQuestAccept = &QuestAccept_npc_doctor; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="npc_guardian"; + newscript->GetAI = GetAI_npc_guardian; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="npc_mount_vendor"; + newscript->pGossipHello = &GossipHello_npc_mount_vendor; + newscript->pGossipSelect = &GossipSelect_npc_mount_vendor; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="npc_rogue_trainer"; + newscript->pGossipHello = &GossipHello_npc_rogue_trainer; + newscript->pGossipSelect = &GossipSelect_npc_rogue_trainer; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="npc_sayge"; + newscript->pGossipHello = &GossipHello_npc_sayge; + newscript->pGossipSelect = &GossipSelect_npc_sayge; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/alterac_mountains/alterac_mountains.cpp b/src/bindings/scripts/scripts/zone/alterac_mountains/alterac_mountains.cpp index 074bf2967b2..b306e38818e 100644 --- a/src/bindings/scripts/scripts/zone/alterac_mountains/alterac_mountains.cpp +++ b/src/bindings/scripts/scripts/zone/alterac_mountains/alterac_mountains.cpp @@ -1,62 +1,62 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Alterac_Mountains -SD%Complete: 100 -SDComment: Quest support: 6681 -SDCategory: Alterac Mountains -EndScriptData */ - -/* ContentData -npc_ravenholdt -EndContentData */ - -#include "precompiled.h" - -/*###### -## npc_ravenholdt -######*/ - -struct MANGOS_DLL_DECL npc_ravenholdtAI : public ScriptedAI -{ - npc_ravenholdtAI(Creature *c) : ScriptedAI(c) { Reset(); } - - void Reset() { } - - void MoveInLineOfSight(Unit *who) - { - if( who->GetTypeId() == TYPEID_PLAYER ) - if( ((Player*)who)->GetQuestStatus(6681) == QUEST_STATUS_INCOMPLETE ) - ((Player*)who)->KilledMonster(m_creature->GetEntry(),m_creature->GetGUID() ); - } - - void Aggro(Unit* who) { } -}; -CreatureAI* GetAI_npc_ravenholdt(Creature *_Creature) -{ - return new npc_ravenholdtAI (_Creature); -} - -void AddSC_alterac_mountains() -{ - Script *newscript; - - newscript = new Script; - newscript->Name="npc_ravenholdt"; - newscript->GetAI = GetAI_npc_ravenholdt; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Alterac_Mountains +SD%Complete: 100 +SDComment: Quest support: 6681 +SDCategory: Alterac Mountains +EndScriptData */ + +/* ContentData +npc_ravenholdt +EndContentData */ + +#include "precompiled.h" + +/*###### +## npc_ravenholdt +######*/ + +struct MANGOS_DLL_DECL npc_ravenholdtAI : public ScriptedAI +{ + npc_ravenholdtAI(Creature *c) : ScriptedAI(c) { Reset(); } + + void Reset() { } + + void MoveInLineOfSight(Unit *who) + { + if( who->GetTypeId() == TYPEID_PLAYER ) + if( ((Player*)who)->GetQuestStatus(6681) == QUEST_STATUS_INCOMPLETE ) + ((Player*)who)->KilledMonster(m_creature->GetEntry(),m_creature->GetGUID() ); + } + + void Aggro(Unit* who) { } +}; +CreatureAI* GetAI_npc_ravenholdt(Creature *_Creature) +{ + return new npc_ravenholdtAI (_Creature); +} + +void AddSC_alterac_mountains() +{ + Script *newscript; + + newscript = new Script; + newscript->Name="npc_ravenholdt"; + newscript->GetAI = GetAI_npc_ravenholdt; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/aunchindoun/auchenai_crypts/boss_exarch_maladaar.cpp b/src/bindings/scripts/scripts/zone/aunchindoun/auchenai_crypts/boss_exarch_maladaar.cpp index 77b0d7eaedd..529d117aa40 100644 --- a/src/bindings/scripts/scripts/zone/aunchindoun/auchenai_crypts/boss_exarch_maladaar.cpp +++ b/src/bindings/scripts/scripts/zone/aunchindoun/auchenai_crypts/boss_exarch_maladaar.cpp @@ -1,405 +1,405 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Exarch_Maladaar -SD%Complete: 95 -SDComment: Most of event implemented, some adjustments to timers remain and possibly make some better code for switching his dark side in to better "images" of player. -SDCategory: Auchindoun, Auchenai Crypts -EndScriptData */ - -/* ContentData -mob_stolen_soul -boss_exarch_maladaar -mob_avatar_of_martyred -EndContentData */ - -#include "precompiled.h" - -#define SPELL_MOONFIRE 37328 -#define SPELL_FIREBALL 37329 -#define SPELL_MIND_FLAY 37330 -#define SPELL_HEMORRHAGE 37331 -#define SPELL_FROSTSHOCK 37332 -#define SPELL_CURSE_OF_AGONY 37334 -#define SPELL_MORTAL_STRIKE 37335 -#define SPELL_FREEZING_TRAP 37368 -#define SPELL_HAMMER_OF_JUSTICE 37369 - -struct MANGOS_DLL_DECL mob_stolen_soulAI : public ScriptedAI -{ - mob_stolen_soulAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint8 myClass; - uint32 Class_Timer; - - void Reset() - { - Class_Timer = 1000; - } - - void Aggro(Unit *who) - { } - - void SetMyClass(uint8 myclass) - { - myClass = myclass; - } - - void UpdateAI(const uint32 diff) - { - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - if( Class_Timer < diff ) - { - switch( myClass ) - { - case CLASS_WARRIOR: - DoCast(m_creature->getVictim(), SPELL_MORTAL_STRIKE); - Class_Timer = 6000; - break; - case CLASS_PALADIN: - DoCast(m_creature->getVictim(), SPELL_HAMMER_OF_JUSTICE); - Class_Timer = 6000; - break; - case CLASS_HUNTER: - DoCast(m_creature->getVictim(), SPELL_FREEZING_TRAP); - Class_Timer = 20000; - break; - case CLASS_ROGUE: - DoCast(m_creature->getVictim(), SPELL_HEMORRHAGE); - Class_Timer = 10000; - break; - case CLASS_PRIEST: - DoCast(m_creature->getVictim(), SPELL_MIND_FLAY); - Class_Timer = 5000; - break; - case CLASS_SHAMAN: - DoCast(m_creature->getVictim(), SPELL_FROSTSHOCK); - Class_Timer = 8000; - break; - case CLASS_MAGE: - DoCast(m_creature->getVictim(), SPELL_FIREBALL); - Class_Timer = 5000; - break; - case CLASS_WARLOCK: - DoCast(m_creature->getVictim(), SPELL_CURSE_OF_AGONY); - Class_Timer = 20000; - break; - case CLASS_DRUID: - DoCast(m_creature->getVictim(), SPELL_MOONFIRE); - Class_Timer = 10000; - break; - default: - break; - } - }else Class_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; - -CreatureAI* GetAI_mob_stolen_soul(Creature *_Creature) -{ - return new mob_stolen_soulAI (_Creature); -} - -#define SAY_INTRO "You have defiled the resting place of our ancestors. For this offense, there can be but one punishment. It is fitting that you have come to a place of the dead... for you will soon be joining them." -#define SOUND_INTRO 10509 -#define SAY_SUMMON "Rise my fallen brothers. Take form and fight!" -#define SOUND_SUMMON 10512 - -#define SAY_AGGRO_1 "You will pay with your life!" -#define SOUND_AGGRO_1 10513 -#define SAY_AGGRO_2 "There's no turning back now!" -#define SOUND_AGGRO_2 10514 -#define SAY_AGGRO_3 "Serve your penitence!" -#define SOUND_AGGRO_3 10515 - -#define SAY_ROAR "Let your mind be clouded." -#define SOUND_ROAR 10510 -#define SAY_SOUL_CLEAVE "Stare into the darkness of your soul." -#define SOUND_SOUL_CLEAVE 10511 - -#define SAY_SLAY_1 "These walls will be your doom." -#define SOUND_SLAY_1 10516 -#define SAY_SLAY_2 " Now, you'll stay for eternity!" -#define SOUND_SLAY_2 10517 - -#define SAY_DEATH "This is... where.. I belong..." -#define SOUND_DEATH 10518 - -#define SPELL_RIBBON_OF_SOULS 32422 -#define SPELL_SOUL_SCREAM 32421 - -#define SPELL_STOLEN_SOUL 32346 -#define SPELL_STOLEN_SOUL_VISUAL 32395 - -#define SPELL_SUMMON_AVATAR 32424 - -#define ENTRY_STOLEN_SOUL 18441 - -struct MANGOS_DLL_DECL boss_exarch_maladaarAI : public ScriptedAI -{ - boss_exarch_maladaarAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 soulmodel; - uint64 soulholder; - uint8 soulclass; - - uint32 Fear_timer; - uint32 Ribbon_of_Souls_timer; - uint32 StolenSoul_Timer; - - bool HasTaunted; - bool Avatar_summoned; - - void Reset() - { - soulmodel = 0; - soulholder = 0; - soulclass = 0; - - Fear_timer = 20000; - Ribbon_of_Souls_timer = 5000; - StolenSoul_Timer = 30000; - - HasTaunted = false; - Avatar_summoned = false; - } - - void MoveInLineOfSight(Unit *who) - { - if( !m_creature->getVictim() && who->isTargetableForAttack() && ( m_creature->IsHostileTo( who )) && who->isInAccessablePlaceFor(m_creature) ) - { - if( !HasTaunted && m_creature->IsWithinDistInMap(who, 150.0) ) - { - DoYell(SAY_INTRO, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature,SOUND_INTRO); - HasTaunted = true; - } - - if (m_creature->GetDistanceZ(who) > CREATURE_Z_ATTACK_RANGE) - return; - - float attackRadius = m_creature->GetAttackDistance(who); - if( m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->IsWithinLOSInMap(who) ) - { - DoStartAttackAndMovement(who); - who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); - - if (!InCombat) - { - Aggro(who); - InCombat = true; - } - } - } - } - - void Aggro(Unit *who) - { - switch(rand()%3) - { - case 0: - DoYell(SAY_AGGRO_1, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature,SOUND_AGGRO_1); - break; - case 1: - DoYell(SAY_AGGRO_2, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature,SOUND_AGGRO_2); - break; - case 2: - DoYell(SAY_AGGRO_3, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature,SOUND_AGGRO_3); - break; - } - } - - void JustSummoned(Creature *summoned) - { - if( summoned->GetEntry() == ENTRY_STOLEN_SOUL ) - { - //SPELL_STOLEN_SOUL_VISUAL has shapeshift effect, but not implemented feature in mangos for this spell. - summoned->SetDisplayId(soulmodel); - summoned->CastSpell(summoned,SPELL_STOLEN_SOUL_VISUAL,false); - - if( Unit *target = Unit::GetUnit(*m_creature,soulholder) ) - summoned->AI()->AttackStart(target); - - ((mob_stolen_soulAI*)summoned->AI())->SetMyClass(soulclass); - } - } - - void KilledUnit(Unit* victim) - { - if (rand()%2) - return; - - switch(rand()%2) - { - case 0: - DoYell(SAY_SLAY_1, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature,SOUND_SLAY_1); - break; - case 1: - DoYell(SAY_SLAY_2, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature,SOUND_SLAY_2); - break; - } - } - - void JustDied(Unit* Killer) - { - DoYell(SAY_DEATH, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature,SOUND_DEATH); - - //When Exarch Maladar is defeated D'ore appear. - DoSpawnCreature(19412,0,0,0,0, TEMPSUMMON_TIMED_DESPAWN, 600000); - } - - void UpdateAI(const uint32 diff) - { - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - if( !Avatar_summoned && ((m_creature->GetHealth()*100) / m_creature->GetMaxHealth() < 25) ) - { - if( m_creature->IsNonMeleeSpellCasted(false) ) - m_creature->InterruptNonMeleeSpells(true); - - DoYell(SAY_SUMMON, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature,SOUND_SUMMON); - - DoCast(m_creature, SPELL_SUMMON_AVATAR); - Avatar_summoned = true; - StolenSoul_Timer = 45000; - } - - if( StolenSoul_Timer < diff ) - { - if( Unit *target = SelectUnit(SELECT_TARGET_RANDOM,0) ) - { - if( target->GetTypeId() == TYPEID_PLAYER ) - { - if( m_creature->IsNonMeleeSpellCasted(false) ) - m_creature->InterruptNonMeleeSpells(true); - - uint32 i = urand(1,2); - if( i == 1 ) - { - DoYell(SAY_ROAR, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature,SOUND_ROAR); - } - else - { - DoYell(SAY_SOUL_CLEAVE, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature,SOUND_SOUL_CLEAVE); - } - - soulmodel = target->GetDisplayId(); - soulholder = target->GetGUID(); - soulclass = target->getClass(); - - DoCast(target,SPELL_STOLEN_SOUL); - DoSpawnCreature(ENTRY_STOLEN_SOUL,0,0,0,0,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,10000); - - StolenSoul_Timer = 45000; - } else StolenSoul_Timer = 1000; - } - }else StolenSoul_Timer -= diff; - - if( Ribbon_of_Souls_timer < diff ) - { - if( Unit *target = SelectUnit(SELECT_TARGET_RANDOM,0) ) - DoCast(target,SPELL_RIBBON_OF_SOULS); - - Ribbon_of_Souls_timer = 5000 + (rand()%20 * 1000); - }else Ribbon_of_Souls_timer -= diff; - - if( Fear_timer < diff ) - { - DoCast(m_creature,SPELL_SOUL_SCREAM); - Fear_timer = 25000 + rand()% 10000; - }else Fear_timer -= diff; - - DoMeleeAttackIfReady(); - } -}; - -CreatureAI* GetAI_boss_exarch_maladaar(Creature *_Creature) -{ - return new boss_exarch_maladaarAI (_Creature); -} - -#define SPELL_MORTAL_STRIKE 16856 -#define SPELL_SUNDER_ARMOR 16145 - -struct MANGOS_DLL_DECL mob_avatar_of_martyredAI : public ScriptedAI -{ - mob_avatar_of_martyredAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 Mortal_Strike_timer; - - void Reset() - { - Mortal_Strike_timer = 10000; - } - - void Aggro(Unit *who) - { - } - - void UpdateAI(const uint32 diff) - { - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - if(Mortal_Strike_timer < diff) - { - DoCast(m_creature->getVictim(), SPELL_MORTAL_STRIKE); - Mortal_Strike_timer = 10000 + rand()%20 * 1000; - }else Mortal_Strike_timer -= diff; - - DoMeleeAttackIfReady(); - } -}; - -CreatureAI* GetAI_mob_avatar_of_martyred(Creature *_Creature) -{ - return new mob_avatar_of_martyredAI (_Creature); -} - -void AddSC_boss_exarch_maladaar() -{ - Script *newscript; - - newscript = new Script; - newscript->Name="boss_exarch_maladaar"; - newscript->GetAI = GetAI_boss_exarch_maladaar; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="mob_avatar_of_martyred"; - newscript->GetAI = GetAI_mob_avatar_of_martyred; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="mob_stolen_soul"; - newscript->GetAI = GetAI_mob_stolen_soul; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Exarch_Maladaar +SD%Complete: 95 +SDComment: Most of event implemented, some adjustments to timers remain and possibly make some better code for switching his dark side in to better "images" of player. +SDCategory: Auchindoun, Auchenai Crypts +EndScriptData */ + +/* ContentData +mob_stolen_soul +boss_exarch_maladaar +mob_avatar_of_martyred +EndContentData */ + +#include "precompiled.h" + +#define SPELL_MOONFIRE 37328 +#define SPELL_FIREBALL 37329 +#define SPELL_MIND_FLAY 37330 +#define SPELL_HEMORRHAGE 37331 +#define SPELL_FROSTSHOCK 37332 +#define SPELL_CURSE_OF_AGONY 37334 +#define SPELL_MORTAL_STRIKE 37335 +#define SPELL_FREEZING_TRAP 37368 +#define SPELL_HAMMER_OF_JUSTICE 37369 + +struct MANGOS_DLL_DECL mob_stolen_soulAI : public ScriptedAI +{ + mob_stolen_soulAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint8 myClass; + uint32 Class_Timer; + + void Reset() + { + Class_Timer = 1000; + } + + void Aggro(Unit *who) + { } + + void SetMyClass(uint8 myclass) + { + myClass = myclass; + } + + void UpdateAI(const uint32 diff) + { + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + if( Class_Timer < diff ) + { + switch( myClass ) + { + case CLASS_WARRIOR: + DoCast(m_creature->getVictim(), SPELL_MORTAL_STRIKE); + Class_Timer = 6000; + break; + case CLASS_PALADIN: + DoCast(m_creature->getVictim(), SPELL_HAMMER_OF_JUSTICE); + Class_Timer = 6000; + break; + case CLASS_HUNTER: + DoCast(m_creature->getVictim(), SPELL_FREEZING_TRAP); + Class_Timer = 20000; + break; + case CLASS_ROGUE: + DoCast(m_creature->getVictim(), SPELL_HEMORRHAGE); + Class_Timer = 10000; + break; + case CLASS_PRIEST: + DoCast(m_creature->getVictim(), SPELL_MIND_FLAY); + Class_Timer = 5000; + break; + case CLASS_SHAMAN: + DoCast(m_creature->getVictim(), SPELL_FROSTSHOCK); + Class_Timer = 8000; + break; + case CLASS_MAGE: + DoCast(m_creature->getVictim(), SPELL_FIREBALL); + Class_Timer = 5000; + break; + case CLASS_WARLOCK: + DoCast(m_creature->getVictim(), SPELL_CURSE_OF_AGONY); + Class_Timer = 20000; + break; + case CLASS_DRUID: + DoCast(m_creature->getVictim(), SPELL_MOONFIRE); + Class_Timer = 10000; + break; + default: + break; + } + }else Class_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; + +CreatureAI* GetAI_mob_stolen_soul(Creature *_Creature) +{ + return new mob_stolen_soulAI (_Creature); +} + +#define SAY_INTRO "You have defiled the resting place of our ancestors. For this offense, there can be but one punishment. It is fitting that you have come to a place of the dead... for you will soon be joining them." +#define SOUND_INTRO 10509 +#define SAY_SUMMON "Rise my fallen brothers. Take form and fight!" +#define SOUND_SUMMON 10512 + +#define SAY_AGGRO_1 "You will pay with your life!" +#define SOUND_AGGRO_1 10513 +#define SAY_AGGRO_2 "There's no turning back now!" +#define SOUND_AGGRO_2 10514 +#define SAY_AGGRO_3 "Serve your penitence!" +#define SOUND_AGGRO_3 10515 + +#define SAY_ROAR "Let your mind be clouded." +#define SOUND_ROAR 10510 +#define SAY_SOUL_CLEAVE "Stare into the darkness of your soul." +#define SOUND_SOUL_CLEAVE 10511 + +#define SAY_SLAY_1 "These walls will be your doom." +#define SOUND_SLAY_1 10516 +#define SAY_SLAY_2 " Now, you'll stay for eternity!" +#define SOUND_SLAY_2 10517 + +#define SAY_DEATH "This is... where.. I belong..." +#define SOUND_DEATH 10518 + +#define SPELL_RIBBON_OF_SOULS 32422 +#define SPELL_SOUL_SCREAM 32421 + +#define SPELL_STOLEN_SOUL 32346 +#define SPELL_STOLEN_SOUL_VISUAL 32395 + +#define SPELL_SUMMON_AVATAR 32424 + +#define ENTRY_STOLEN_SOUL 18441 + +struct MANGOS_DLL_DECL boss_exarch_maladaarAI : public ScriptedAI +{ + boss_exarch_maladaarAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 soulmodel; + uint64 soulholder; + uint8 soulclass; + + uint32 Fear_timer; + uint32 Ribbon_of_Souls_timer; + uint32 StolenSoul_Timer; + + bool HasTaunted; + bool Avatar_summoned; + + void Reset() + { + soulmodel = 0; + soulholder = 0; + soulclass = 0; + + Fear_timer = 20000; + Ribbon_of_Souls_timer = 5000; + StolenSoul_Timer = 30000; + + HasTaunted = false; + Avatar_summoned = false; + } + + void MoveInLineOfSight(Unit *who) + { + if( !m_creature->getVictim() && who->isTargetableForAttack() && ( m_creature->IsHostileTo( who )) && who->isInAccessablePlaceFor(m_creature) ) + { + if( !HasTaunted && m_creature->IsWithinDistInMap(who, 150.0) ) + { + DoYell(SAY_INTRO, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature,SOUND_INTRO); + HasTaunted = true; + } + + if (!m_creature->canFly() && m_creature->GetDistanceZ(who) > CREATURE_Z_ATTACK_RANGE) + return; + + float attackRadius = m_creature->GetAttackDistance(who); + if( m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->IsWithinLOSInMap(who) ) + { + DoStartAttackAndMovement(who); + who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); + + if (!InCombat) + { + Aggro(who); + InCombat = true; + } + } + } + } + + void Aggro(Unit *who) + { + switch(rand()%3) + { + case 0: + DoYell(SAY_AGGRO_1, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature,SOUND_AGGRO_1); + break; + case 1: + DoYell(SAY_AGGRO_2, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature,SOUND_AGGRO_2); + break; + case 2: + DoYell(SAY_AGGRO_3, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature,SOUND_AGGRO_3); + break; + } + } + + void JustSummoned(Creature *summoned) + { + if( summoned->GetEntry() == ENTRY_STOLEN_SOUL ) + { + //SPELL_STOLEN_SOUL_VISUAL has shapeshift effect, but not implemented feature in mangos for this spell. + summoned->SetDisplayId(soulmodel); + summoned->CastSpell(summoned,SPELL_STOLEN_SOUL_VISUAL,false); + + if( Unit *target = Unit::GetUnit(*m_creature,soulholder) ) + summoned->AI()->AttackStart(target); + + ((mob_stolen_soulAI*)summoned->AI())->SetMyClass(soulclass); + } + } + + void KilledUnit(Unit* victim) + { + if (rand()%2) + return; + + switch(rand()%2) + { + case 0: + DoYell(SAY_SLAY_1, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature,SOUND_SLAY_1); + break; + case 1: + DoYell(SAY_SLAY_2, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature,SOUND_SLAY_2); + break; + } + } + + void JustDied(Unit* Killer) + { + DoYell(SAY_DEATH, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature,SOUND_DEATH); + + //When Exarch Maladar is defeated D'ore appear. + DoSpawnCreature(19412,0,0,0,0, TEMPSUMMON_TIMED_DESPAWN, 600000); + } + + void UpdateAI(const uint32 diff) + { + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + if( !Avatar_summoned && ((m_creature->GetHealth()*100) / m_creature->GetMaxHealth() < 25) ) + { + if( m_creature->IsNonMeleeSpellCasted(false) ) + m_creature->InterruptNonMeleeSpells(true); + + DoYell(SAY_SUMMON, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature,SOUND_SUMMON); + + DoCast(m_creature, SPELL_SUMMON_AVATAR); + Avatar_summoned = true; + StolenSoul_Timer = 45000; + } + + if( StolenSoul_Timer < diff ) + { + if( Unit *target = SelectUnit(SELECT_TARGET_RANDOM,0) ) + { + if( target->GetTypeId() == TYPEID_PLAYER ) + { + if( m_creature->IsNonMeleeSpellCasted(false) ) + m_creature->InterruptNonMeleeSpells(true); + + uint32 i = urand(1,2); + if( i == 1 ) + { + DoYell(SAY_ROAR, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature,SOUND_ROAR); + } + else + { + DoYell(SAY_SOUL_CLEAVE, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature,SOUND_SOUL_CLEAVE); + } + + soulmodel = target->GetDisplayId(); + soulholder = target->GetGUID(); + soulclass = target->getClass(); + + DoCast(target,SPELL_STOLEN_SOUL); + DoSpawnCreature(ENTRY_STOLEN_SOUL,0,0,0,0,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,10000); + + StolenSoul_Timer = 45000; + } else StolenSoul_Timer = 1000; + } + }else StolenSoul_Timer -= diff; + + if( Ribbon_of_Souls_timer < diff ) + { + if( Unit *target = SelectUnit(SELECT_TARGET_RANDOM,0) ) + DoCast(target,SPELL_RIBBON_OF_SOULS); + + Ribbon_of_Souls_timer = 5000 + (rand()%20 * 1000); + }else Ribbon_of_Souls_timer -= diff; + + if( Fear_timer < diff ) + { + DoCast(m_creature,SPELL_SOUL_SCREAM); + Fear_timer = 25000 + rand()% 10000; + }else Fear_timer -= diff; + + DoMeleeAttackIfReady(); + } +}; + +CreatureAI* GetAI_boss_exarch_maladaar(Creature *_Creature) +{ + return new boss_exarch_maladaarAI (_Creature); +} + +#define SPELL_MORTAL_STRIKE 16856 +#define SPELL_SUNDER_ARMOR 16145 + +struct MANGOS_DLL_DECL mob_avatar_of_martyredAI : public ScriptedAI +{ + mob_avatar_of_martyredAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 Mortal_Strike_timer; + + void Reset() + { + Mortal_Strike_timer = 10000; + } + + void Aggro(Unit *who) + { + } + + void UpdateAI(const uint32 diff) + { + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + if(Mortal_Strike_timer < diff) + { + DoCast(m_creature->getVictim(), SPELL_MORTAL_STRIKE); + Mortal_Strike_timer = 10000 + rand()%20 * 1000; + }else Mortal_Strike_timer -= diff; + + DoMeleeAttackIfReady(); + } +}; + +CreatureAI* GetAI_mob_avatar_of_martyred(Creature *_Creature) +{ + return new mob_avatar_of_martyredAI (_Creature); +} + +void AddSC_boss_exarch_maladaar() +{ + Script *newscript; + + newscript = new Script; + newscript->Name="boss_exarch_maladaar"; + newscript->GetAI = GetAI_boss_exarch_maladaar; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="mob_avatar_of_martyred"; + newscript->GetAI = GetAI_mob_avatar_of_martyred; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="mob_stolen_soul"; + newscript->GetAI = GetAI_mob_stolen_soul; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/aunchindoun/mana_tombs/boss_nexusprince_shaffar.cpp b/src/bindings/scripts/scripts/zone/aunchindoun/mana_tombs/boss_nexusprince_shaffar.cpp index 7191ea7a663..0583638cfc2 100644 --- a/src/bindings/scripts/scripts/zone/aunchindoun/mana_tombs/boss_nexusprince_shaffar.cpp +++ b/src/bindings/scripts/scripts/zone/aunchindoun/mana_tombs/boss_nexusprince_shaffar.cpp @@ -1,313 +1,313 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_NexusPrince_Shaffar -SD%Complete: 80 -SDComment: Need more tuning of spell timers, it should not be as linear fight as current. Also should possibly find a better way to deal with his three initial beacons to make sure all aggro. -SDCategory: Auchindoun, Mana Tombs -EndScriptData */ - -/* ContentData -boss_nexusprince_shaffar -mob_ethereal_beacon -EndContentData */ - -#include "precompiled.h" - -#define SAY_INTRO "What is this? You must forgive me, but I was not expecting company. As you can see, we are somewhat preoccupied right now. But no matter. As I am a gracious host, I will tend to you... personally." -#define SOUND_INTRO 10539 - -#define SAY_AGGRO_1 "We have not yet been properly introduced." -#define SOUND_AGGRO_1 10541 -#define SAY_AGGRO_2 "An epic battle. How exciting!" -#define SOUND_AGGRO_2 10542 -#define SAY_AGGRO_3 "I have longed for a good adventure." -#define SOUND_AGGRO_3 10543 - -#define SAY_SLAY_1 "It has been... entertaining." -#define SOUND_SLAY_1 10544 -#define SAY_SLAY_2 "And now we part company." -#define SOUND_SLAY_2 10545 - -#define SAY_SUMMON "I have such fascinating things to show you." -#define SOUND_SUMMON 10540 - -#define SAY_DEAD "I must bid you... farewell." -#define SOUND_DEAD 10546 - -#define SPELL_BLINK 34605 -#define SPELL_FROSTBOLT 32364 -#define SPELL_FIREBALL 32363 -#define SPELL_FROSTNOVA 32365 - -#define SPELL_ETHEREAL_BEACON 32371 // Summon 18431 -#define SPELL_ETHEREAL_BEACON_VISUAL 32368 - -#define ENTRY_BEACON 18431 - -struct MANGOS_DLL_DECL boss_nexusprince_shaffarAI : public ScriptedAI -{ - boss_nexusprince_shaffarAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 Blink_Timer; - uint32 Beacon_Timer; - uint32 FireBall_Timer; - uint32 Frostbolt_Timer; - uint32 FrostNova_Timer; - - bool HasTaunted; - bool CanBlink; - - void Reset() - { - Blink_Timer = 1500; - Beacon_Timer = 10000; - FireBall_Timer = 8000; - Frostbolt_Timer = 4000; - FrostNova_Timer = 15000; - - HasTaunted = false; - CanBlink = false; - } - - void MoveInLineOfSight(Unit *who) - { - if( !m_creature->getVictim() && who->isTargetableForAttack() && ( m_creature->IsHostileTo( who )) && who->isInAccessablePlaceFor(m_creature) ) - { - if( !HasTaunted && m_creature->IsWithinDistInMap(who, 100.0) ) - { - DoYell(SAY_INTRO, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature,SOUND_INTRO); - HasTaunted = true; - } - - if (m_creature->GetDistanceZ(who) > CREATURE_Z_ATTACK_RANGE) - return; - - float attackRadius = m_creature->GetAttackDistance(who); - if( m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->IsWithinLOSInMap(who) ) - { - DoStartAttackAndMovement(who); - who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); - - if (!InCombat) - { - Aggro(who); - InCombat = true; - } - } - } - } - - void Aggro(Unit *who) - { - switch(rand()%3) - { - case 0: - DoYell(SAY_AGGRO_1, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature,SOUND_AGGRO_1); - break; - case 1: - DoYell(SAY_AGGRO_2, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature,SOUND_AGGRO_2); - break; - case 2: - DoYell(SAY_AGGRO_3, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature,SOUND_AGGRO_3); - break; - } - } - - void JustSummoned(Creature *summoned) - { - if( summoned->GetEntry() == ENTRY_BEACON ) - { - summoned->CastSpell(summoned,SPELL_ETHEREAL_BEACON_VISUAL,false); - - if( Unit *target = SelectUnit(SELECT_TARGET_RANDOM,0) ) - summoned->AI()->AttackStart(target); - } - } - - void KilledUnit(Unit* victim) - { - switch(rand()%2) - { - case 0: - DoYell(SAY_SLAY_1, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature,SOUND_SLAY_1); - break; - case 1: - DoYell(SAY_SLAY_2, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature,SOUND_SLAY_2); - break; - } - } - - void JustDied(Unit* Killer) - { - DoYell(SAY_DEAD, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature,SOUND_DEAD); - } - - void UpdateAI(const uint32 diff) - { - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - if( FrostNova_Timer < diff ) - { - if( m_creature->IsNonMeleeSpellCasted(false) ) - m_creature->InterruptNonMeleeSpells(true); - - DoCast(m_creature,SPELL_FROSTNOVA); - FrostNova_Timer = 17500 + rand()%7500; - CanBlink = true; - }else FrostNova_Timer -= diff; - - if( Frostbolt_Timer < diff ) - { - DoCast(m_creature->getVictim(),SPELL_FROSTBOLT); - Frostbolt_Timer = 4500 + rand()%1500; - }else Frostbolt_Timer -= diff; - - if( FireBall_Timer < diff ) - { - DoCast(m_creature->getVictim(),SPELL_FIREBALL); - FireBall_Timer = 4500 + rand()%1500; - }else FireBall_Timer -= diff; - - if( CanBlink ) - { - if( Blink_Timer < diff ) - { - if( m_creature->IsNonMeleeSpellCasted(false) ) - m_creature->InterruptNonMeleeSpells(true); - - DoCast(m_creature,SPELL_BLINK); - Blink_Timer = 1000 + rand()%1500; - CanBlink = false; - }else Blink_Timer -= diff; - } - - if( Beacon_Timer < diff) - { - if( m_creature->IsNonMeleeSpellCasted(false) ) - m_creature->InterruptNonMeleeSpells(true); - - if( !urand(0,3) ) - { - DoYell(SAY_SUMMON, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature,SOUND_SUMMON); - } - DoCast(m_creature,SPELL_ETHEREAL_BEACON); - - Beacon_Timer = 10000; - }else Beacon_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; - -CreatureAI* GetAI_boss_nexusprince_shaffar(Creature *_Creature) -{ - return new boss_nexusprince_shaffarAI (_Creature); -} - -#define SPELL_ARCANE_BOLT 15254 -#define SPELL_ETHEREAL_APPRENTICE 32372 // Summon 18430 - -struct MANGOS_DLL_DECL mob_ethereal_beaconAI : public ScriptedAI -{ - mob_ethereal_beaconAI(Creature *c) : ScriptedAI(c) - { - HeroicMode = m_creature->GetMap()->IsHeroic(); - Reset(); - } - - bool HeroicMode; - bool CanEvade; - uint32 Apprentice_Timer; - uint32 ArcaneBolt_Timer; - - void Reset() - { - if( CanEvade ) - m_creature->SetVisibility(VISIBILITY_OFF); - - CanEvade = false; - Apprentice_Timer = (HeroicMode ? 10000 : 20000); - ArcaneBolt_Timer = 1000; - } - - void Aggro(Unit *who) - { - } - - void JustSummoned(Creature *summoned) - { - summoned->AI()->AttackStart(m_creature->getVictim()); - } - - void UpdateAI(const uint32 diff) - { - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - if( ArcaneBolt_Timer < diff ) - { - DoCast(m_creature->getVictim(),SPELL_ARCANE_BOLT); - ArcaneBolt_Timer = 2000 + rand()%2500; - }else ArcaneBolt_Timer -= diff; - - if( Apprentice_Timer < diff ) - { - if( m_creature->IsNonMeleeSpellCasted(false) ) - m_creature->InterruptNonMeleeSpells(true); - - m_creature->CastSpell(m_creature,SPELL_ETHEREAL_APPRENTICE,true); - if( m_creature->GetOwner() ) - ((Pet*)m_creature)->SetDuration(0); - CanEvade = true; - }else Apprentice_Timer -= diff; - - if( CanEvade ) - EnterEvadeMode(); - - DoMeleeAttackIfReady(); - } -}; - -CreatureAI* GetAI_mob_ethereal_beacon(Creature *_Creature) -{ - return new mob_ethereal_beaconAI (_Creature); -} - -void AddSC_boss_nexusprince_shaffar() -{ - Script *newscript; - - newscript = new Script; - newscript->Name="boss_nexusprince_shaffar"; - newscript->GetAI = GetAI_boss_nexusprince_shaffar; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="mob_ethereal_beacon"; - newscript->GetAI = GetAI_mob_ethereal_beacon; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_NexusPrince_Shaffar +SD%Complete: 80 +SDComment: Need more tuning of spell timers, it should not be as linear fight as current. Also should possibly find a better way to deal with his three initial beacons to make sure all aggro. +SDCategory: Auchindoun, Mana Tombs +EndScriptData */ + +/* ContentData +boss_nexusprince_shaffar +mob_ethereal_beacon +EndContentData */ + +#include "precompiled.h" + +#define SAY_INTRO "What is this? You must forgive me, but I was not expecting company. As you can see, we are somewhat preoccupied right now. But no matter. As I am a gracious host, I will tend to you... personally." +#define SOUND_INTRO 10539 + +#define SAY_AGGRO_1 "We have not yet been properly introduced." +#define SOUND_AGGRO_1 10541 +#define SAY_AGGRO_2 "An epic battle. How exciting!" +#define SOUND_AGGRO_2 10542 +#define SAY_AGGRO_3 "I have longed for a good adventure." +#define SOUND_AGGRO_3 10543 + +#define SAY_SLAY_1 "It has been... entertaining." +#define SOUND_SLAY_1 10544 +#define SAY_SLAY_2 "And now we part company." +#define SOUND_SLAY_2 10545 + +#define SAY_SUMMON "I have such fascinating things to show you." +#define SOUND_SUMMON 10540 + +#define SAY_DEAD "I must bid you... farewell." +#define SOUND_DEAD 10546 + +#define SPELL_BLINK 34605 +#define SPELL_FROSTBOLT 32364 +#define SPELL_FIREBALL 32363 +#define SPELL_FROSTNOVA 32365 + +#define SPELL_ETHEREAL_BEACON 32371 // Summon 18431 +#define SPELL_ETHEREAL_BEACON_VISUAL 32368 + +#define ENTRY_BEACON 18431 + +struct MANGOS_DLL_DECL boss_nexusprince_shaffarAI : public ScriptedAI +{ + boss_nexusprince_shaffarAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 Blink_Timer; + uint32 Beacon_Timer; + uint32 FireBall_Timer; + uint32 Frostbolt_Timer; + uint32 FrostNova_Timer; + + bool HasTaunted; + bool CanBlink; + + void Reset() + { + Blink_Timer = 1500; + Beacon_Timer = 10000; + FireBall_Timer = 8000; + Frostbolt_Timer = 4000; + FrostNova_Timer = 15000; + + HasTaunted = false; + CanBlink = false; + } + + void MoveInLineOfSight(Unit *who) + { + if( !m_creature->getVictim() && who->isTargetableForAttack() && ( m_creature->IsHostileTo( who )) && who->isInAccessablePlaceFor(m_creature) ) + { + if( !HasTaunted && m_creature->IsWithinDistInMap(who, 100.0) ) + { + DoYell(SAY_INTRO, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature,SOUND_INTRO); + HasTaunted = true; + } + + if (!m_creature->canFly() && m_creature->GetDistanceZ(who) > CREATURE_Z_ATTACK_RANGE) + return; + + float attackRadius = m_creature->GetAttackDistance(who); + if( m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->IsWithinLOSInMap(who) ) + { + DoStartAttackAndMovement(who); + who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); + + if (!InCombat) + { + Aggro(who); + InCombat = true; + } + } + } + } + + void Aggro(Unit *who) + { + switch(rand()%3) + { + case 0: + DoYell(SAY_AGGRO_1, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature,SOUND_AGGRO_1); + break; + case 1: + DoYell(SAY_AGGRO_2, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature,SOUND_AGGRO_2); + break; + case 2: + DoYell(SAY_AGGRO_3, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature,SOUND_AGGRO_3); + break; + } + } + + void JustSummoned(Creature *summoned) + { + if( summoned->GetEntry() == ENTRY_BEACON ) + { + summoned->CastSpell(summoned,SPELL_ETHEREAL_BEACON_VISUAL,false); + + if( Unit *target = SelectUnit(SELECT_TARGET_RANDOM,0) ) + summoned->AI()->AttackStart(target); + } + } + + void KilledUnit(Unit* victim) + { + switch(rand()%2) + { + case 0: + DoYell(SAY_SLAY_1, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature,SOUND_SLAY_1); + break; + case 1: + DoYell(SAY_SLAY_2, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature,SOUND_SLAY_2); + break; + } + } + + void JustDied(Unit* Killer) + { + DoYell(SAY_DEAD, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature,SOUND_DEAD); + } + + void UpdateAI(const uint32 diff) + { + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + if( FrostNova_Timer < diff ) + { + if( m_creature->IsNonMeleeSpellCasted(false) ) + m_creature->InterruptNonMeleeSpells(true); + + DoCast(m_creature,SPELL_FROSTNOVA); + FrostNova_Timer = 17500 + rand()%7500; + CanBlink = true; + }else FrostNova_Timer -= diff; + + if( Frostbolt_Timer < diff ) + { + DoCast(m_creature->getVictim(),SPELL_FROSTBOLT); + Frostbolt_Timer = 4500 + rand()%1500; + }else Frostbolt_Timer -= diff; + + if( FireBall_Timer < diff ) + { + DoCast(m_creature->getVictim(),SPELL_FIREBALL); + FireBall_Timer = 4500 + rand()%1500; + }else FireBall_Timer -= diff; + + if( CanBlink ) + { + if( Blink_Timer < diff ) + { + if( m_creature->IsNonMeleeSpellCasted(false) ) + m_creature->InterruptNonMeleeSpells(true); + + DoCast(m_creature,SPELL_BLINK); + Blink_Timer = 1000 + rand()%1500; + CanBlink = false; + }else Blink_Timer -= diff; + } + + if( Beacon_Timer < diff) + { + if( m_creature->IsNonMeleeSpellCasted(false) ) + m_creature->InterruptNonMeleeSpells(true); + + if( !urand(0,3) ) + { + DoYell(SAY_SUMMON, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature,SOUND_SUMMON); + } + DoCast(m_creature,SPELL_ETHEREAL_BEACON); + + Beacon_Timer = 10000; + }else Beacon_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; + +CreatureAI* GetAI_boss_nexusprince_shaffar(Creature *_Creature) +{ + return new boss_nexusprince_shaffarAI (_Creature); +} + +#define SPELL_ARCANE_BOLT 15254 +#define SPELL_ETHEREAL_APPRENTICE 32372 // Summon 18430 + +struct MANGOS_DLL_DECL mob_ethereal_beaconAI : public ScriptedAI +{ + mob_ethereal_beaconAI(Creature *c) : ScriptedAI(c) + { + HeroicMode = m_creature->GetMap()->IsHeroic(); + Reset(); + } + + bool HeroicMode; + bool CanEvade; + uint32 Apprentice_Timer; + uint32 ArcaneBolt_Timer; + + void Reset() + { + if( CanEvade ) + m_creature->SetVisibility(VISIBILITY_OFF); + + CanEvade = false; + Apprentice_Timer = (HeroicMode ? 10000 : 20000); + ArcaneBolt_Timer = 1000; + } + + void Aggro(Unit *who) + { + } + + void JustSummoned(Creature *summoned) + { + summoned->AI()->AttackStart(m_creature->getVictim()); + } + + void UpdateAI(const uint32 diff) + { + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + if( ArcaneBolt_Timer < diff ) + { + DoCast(m_creature->getVictim(),SPELL_ARCANE_BOLT); + ArcaneBolt_Timer = 2000 + rand()%2500; + }else ArcaneBolt_Timer -= diff; + + if( Apprentice_Timer < diff ) + { + if( m_creature->IsNonMeleeSpellCasted(false) ) + m_creature->InterruptNonMeleeSpells(true); + + m_creature->CastSpell(m_creature,SPELL_ETHEREAL_APPRENTICE,true); + if( m_creature->GetOwner() ) + ((Pet*)m_creature)->SetDuration(0); + CanEvade = true; + }else Apprentice_Timer -= diff; + + if( CanEvade ) + EnterEvadeMode(); + + DoMeleeAttackIfReady(); + } +}; + +CreatureAI* GetAI_mob_ethereal_beacon(Creature *_Creature) +{ + return new mob_ethereal_beaconAI (_Creature); +} + +void AddSC_boss_nexusprince_shaffar() +{ + Script *newscript; + + newscript = new Script; + newscript->Name="boss_nexusprince_shaffar"; + newscript->GetAI = GetAI_boss_nexusprince_shaffar; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="mob_ethereal_beacon"; + newscript->GetAI = GetAI_mob_ethereal_beacon; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/aunchindoun/mana_tombs/boss_pandemonius.cpp b/src/bindings/scripts/scripts/zone/aunchindoun/mana_tombs/boss_pandemonius.cpp index 25f26289e53..4b7d8907acb 100644 --- a/src/bindings/scripts/scripts/zone/aunchindoun/mana_tombs/boss_pandemonius.cpp +++ b/src/bindings/scripts/scripts/zone/aunchindoun/mana_tombs/boss_pandemonius.cpp @@ -1,159 +1,159 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Pandemonius -SD%Complete: 75 -SDComment: Not known how void blast is done (amount of rapid cast seems to be related to players in party). All mobs remaining in surrounding area should aggro when engaged. -SDCategory: Auchindoun, Mana Tombs -EndScriptData */ - -#include "precompiled.h" - -#define SAY_AGGRO_1 "I will feed on your soul." -#define SOUND_AGGRO_1 10561 -#define SAY_AGGRO_2 "So... full of life!" -#define SOUND_AGGRO_2 10562 -#define SAY_AGGRO_3 "Do not... resist." -#define SOUND_AGGRO_3 10563 - -#define SAY_KILL_1 "Yes! I am... empowered!" -#define SOUND_KILL_1 10564 -#define SAY_KILL_2 "More... I must have more!" -#define SOUND_KILL_2 10565 - -#define SAY_DEATH "To the void... once... more.." -#define SOUND_DEATH 10566 - -#define EMOTE_DARK_SHELL "shifts into the void..." - -#define SPELL_VOID_BLAST 32325 -#define H_SPELL_VOID_BLAST 38760 -#define SPELL_DARK_SHELL 32358 -#define H_SPELL_DARK_SHELL 38759 - -struct MANGOS_DLL_DECL boss_pandemoniusAI : public ScriptedAI -{ - boss_pandemoniusAI(Creature *c) : ScriptedAI(c) - { - HeroicMode = m_creature->GetMap()->IsHeroic(); - Reset(); - } - - bool HeroicMode; - uint32 VoidBlast_Timer; - uint32 DarkShell_Timer; - uint32 VoidBlast_Counter; - - void Reset() - { - VoidBlast_Timer = 30000; - DarkShell_Timer = 20000; - VoidBlast_Counter = 0; - } - - void JustDied(Unit* Killer) - { - DoYell(SAY_DEATH, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature,SOUND_DEATH); - } - - void KilledUnit(Unit* victim) - { - switch(rand()%2) - { - case 0: - DoYell(SAY_KILL_1, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature,SOUND_KILL_1); - break; - case 1: - DoYell(SAY_KILL_2, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature,SOUND_KILL_2); - break; - } - } - - void Aggro(Unit *who) - { - switch(rand()%3) - { - case 0: - DoYell(SAY_AGGRO_1, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature,SOUND_AGGRO_1); - break; - case 1: - DoYell(SAY_AGGRO_2, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature,SOUND_AGGRO_2); - break; - case 2: - DoYell(SAY_AGGRO_3, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature,SOUND_AGGRO_3); - break; - } - - } - - void UpdateAI(const uint32 diff) - { - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - if( VoidBlast_Timer < diff ) - { - if( Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0) ) - { - DoCast(target,HeroicMode ? H_SPELL_VOID_BLAST : SPELL_VOID_BLAST); - VoidBlast_Timer = 500; - ++VoidBlast_Counter; - } - - if( VoidBlast_Counter == 5 ) - { - VoidBlast_Timer = 25000+rand()%10000; - VoidBlast_Counter = 0; - } - }else VoidBlast_Timer -= diff; - - if( !VoidBlast_Counter ) - { - if( DarkShell_Timer < diff ) - { - if( m_creature->IsNonMeleeSpellCasted(false) ) - m_creature->InterruptNonMeleeSpells(true); - - DoTextEmote(EMOTE_DARK_SHELL,NULL,true); - DoCast(m_creature,HeroicMode ? H_SPELL_DARK_SHELL : SPELL_DARK_SHELL); - DarkShell_Timer = 20000; - }else DarkShell_Timer -= diff; - } - - DoMeleeAttackIfReady(); - } -}; - -CreatureAI* GetAI_boss_pandemonius(Creature *_Creature) -{ - return new boss_pandemoniusAI (_Creature); -} - -void AddSC_boss_pandemonius() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_pandemonius"; - newscript->GetAI = GetAI_boss_pandemonius; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Pandemonius +SD%Complete: 75 +SDComment: Not known how void blast is done (amount of rapid cast seems to be related to players in party). All mobs remaining in surrounding area should aggro when engaged. +SDCategory: Auchindoun, Mana Tombs +EndScriptData */ + +#include "precompiled.h" + +#define SAY_AGGRO_1 "I will feed on your soul." +#define SOUND_AGGRO_1 10561 +#define SAY_AGGRO_2 "So... full of life!" +#define SOUND_AGGRO_2 10562 +#define SAY_AGGRO_3 "Do not... resist." +#define SOUND_AGGRO_3 10563 + +#define SAY_KILL_1 "Yes! I am... empowered!" +#define SOUND_KILL_1 10564 +#define SAY_KILL_2 "More... I must have more!" +#define SOUND_KILL_2 10565 + +#define SAY_DEATH "To the void... once... more.." +#define SOUND_DEATH 10566 + +#define EMOTE_DARK_SHELL "shifts into the void..." + +#define SPELL_VOID_BLAST 32325 +#define H_SPELL_VOID_BLAST 38760 +#define SPELL_DARK_SHELL 32358 +#define H_SPELL_DARK_SHELL 38759 + +struct MANGOS_DLL_DECL boss_pandemoniusAI : public ScriptedAI +{ + boss_pandemoniusAI(Creature *c) : ScriptedAI(c) + { + HeroicMode = m_creature->GetMap()->IsHeroic(); + Reset(); + } + + bool HeroicMode; + uint32 VoidBlast_Timer; + uint32 DarkShell_Timer; + uint32 VoidBlast_Counter; + + void Reset() + { + VoidBlast_Timer = 30000; + DarkShell_Timer = 20000; + VoidBlast_Counter = 0; + } + + void JustDied(Unit* Killer) + { + DoYell(SAY_DEATH, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature,SOUND_DEATH); + } + + void KilledUnit(Unit* victim) + { + switch(rand()%2) + { + case 0: + DoYell(SAY_KILL_1, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature,SOUND_KILL_1); + break; + case 1: + DoYell(SAY_KILL_2, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature,SOUND_KILL_2); + break; + } + } + + void Aggro(Unit *who) + { + switch(rand()%3) + { + case 0: + DoYell(SAY_AGGRO_1, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature,SOUND_AGGRO_1); + break; + case 1: + DoYell(SAY_AGGRO_2, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature,SOUND_AGGRO_2); + break; + case 2: + DoYell(SAY_AGGRO_3, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature,SOUND_AGGRO_3); + break; + } + + } + + void UpdateAI(const uint32 diff) + { + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + if( VoidBlast_Timer < diff ) + { + if( Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0) ) + { + DoCast(target,HeroicMode ? H_SPELL_VOID_BLAST : SPELL_VOID_BLAST); + VoidBlast_Timer = 500; + ++VoidBlast_Counter; + } + + if( VoidBlast_Counter == 5 ) + { + VoidBlast_Timer = 25000+rand()%10000; + VoidBlast_Counter = 0; + } + }else VoidBlast_Timer -= diff; + + if( !VoidBlast_Counter ) + { + if( DarkShell_Timer < diff ) + { + if( m_creature->IsNonMeleeSpellCasted(false) ) + m_creature->InterruptNonMeleeSpells(true); + + DoTextEmote(EMOTE_DARK_SHELL,NULL,true); + DoCast(m_creature,HeroicMode ? H_SPELL_DARK_SHELL : SPELL_DARK_SHELL); + DarkShell_Timer = 20000; + }else DarkShell_Timer -= diff; + } + + DoMeleeAttackIfReady(); + } +}; + +CreatureAI* GetAI_boss_pandemonius(Creature *_Creature) +{ + return new boss_pandemoniusAI (_Creature); +} + +void AddSC_boss_pandemonius() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_pandemonius"; + newscript->GetAI = GetAI_boss_pandemonius; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/aunchindoun/sethekk_halls/boss_darkweaver_syth.cpp b/src/bindings/scripts/scripts/zone/aunchindoun/sethekk_halls/boss_darkweaver_syth.cpp index 2be88f661af..c08f3cc66fd 100644 --- a/src/bindings/scripts/scripts/zone/aunchindoun/sethekk_halls/boss_darkweaver_syth.cpp +++ b/src/bindings/scripts/scripts/zone/aunchindoun/sethekk_halls/boss_darkweaver_syth.cpp @@ -1,441 +1,441 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Darkweaver_Syth -SD%Complete: 85 -SDComment: Shock spells/times need more work. Heroic not implemented. -SDCategory: Auchindoun, Sethekk Halls -EndScriptData */ - -#include "precompiled.h" - -#define SAY_SUMMON "I have pets....of my own!" -#define SOUND_SUMMON 10502 - -#define SAY_AGGRO_1 "Hrrmm.. Time to.. hrrm.. make my move." -#define SOUND_AGGRO_1 10503 -#define SAY_AGGRO_2 "Nice pets..hrm.. Yes! " -#define SOUND_AGGRO_2 10504 -#define SAY_AGGRO_3 "Nice pets have.. weapons. No so....nice." -#define SOUND_AGGRO_3 10505 - -#define SAY_SLAY_1 "Death.. meeting life is.. " -#define SOUND_SLAY_1 10506 -#define SAY_SLAY_2 "Uhn.. Be free.." -#define SOUND_SLAY_2 10507 - -#define SAY_DEATH "No more life..hrm. No more pain. " -#define SOUND_DEATH 10508 - -#define SPELL_FROST_SHOCK 37865 -#define SPELL_FLAME_SHOCK 34354 -#define SPELL_SHADOW_SHOCK 30138 -#define SPELL_ARCANE_SHOCK 37132 - -#define SPELL_CHAIN_LIGHTNING 39945 - -#define SPELL_SUMMON_SYTH_FIRE 33537 // Spawns 19203 -#define SPELL_SUMMON_SYTH_ARCANE 33538 // Spawns 19205 -#define SPELL_SUMMON_SYTH_FROST 33539 // Spawns 19204 -#define SPELL_SUMMON_SYTH_SHADOW 33540 // Spawns 19206 - -#define SPELL_FLAME_BUFFET 33526 -#define H_SPELL_FLAME_BUFFET 38141 -#define SPELL_ARCANE_BUFFET 33527 -#define H_SPELL_ARCANE_BUFFET 38138 -#define SPELL_FROST_BUFFET 33528 -#define H_SPELL_FROST_BUFFET 38142 -#define SPELL_SHADOW_BUFFET 33529 -#define H_SPELL_SHADOW_BUFFET 38143 - -struct MANGOS_DLL_DECL boss_darkweaver_sythAI : public ScriptedAI -{ - boss_darkweaver_sythAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 flameshock_timer; - uint32 arcaneshock_timer; - uint32 frostshock_timer; - uint32 shadowshock_timer; - uint32 chainlightning_timer; - - bool summon90; - bool summon50; - bool summon10; - - void Reset() - { - flameshock_timer = 2000; - arcaneshock_timer = 4000; - frostshock_timer = 6000; - shadowshock_timer = 8000; - chainlightning_timer = 15000; - - summon90 = false; - summon50 = false; - summon10 = false; - } - - void Aggro(Unit *who) - { - switch(rand()%3) - { - case 0: - DoYell(SAY_AGGRO_1, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature,SOUND_AGGRO_1); - break; - case 1: - DoYell(SAY_AGGRO_2, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature,SOUND_AGGRO_2); - break; - case 2: - DoYell(SAY_AGGRO_3, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature,SOUND_AGGRO_3); - break; - } - } - - void JustDied(Unit* Killer) - { - DoYell(SAY_DEATH, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature,SOUND_DEATH); - } - - void KilledUnit(Unit* victim) - { - if (rand()%2) - return; - - switch(rand()%2) - { - case 0: - DoYell(SAY_SLAY_1, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature,SOUND_SLAY_1); - break; - case 1: - DoYell(SAY_SLAY_2, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature,SOUND_SLAY_2); - break; - } - } - - void JustSummoned(Creature *summoned) - { - if( Unit *target = SelectUnit(SELECT_TARGET_RANDOM,0) ) - summoned->AI()->AttackStart(target); - - } - - void SythSummoning() - { - DoYell(SAY_SUMMON, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature,SOUND_SUMMON); - - if( m_creature->IsNonMeleeSpellCasted(false) ) - m_creature->InterruptNonMeleeSpells(false); - - DoCast(m_creature,SPELL_SUMMON_SYTH_ARCANE,true); //front - DoCast(m_creature,SPELL_SUMMON_SYTH_FIRE,true); //back - DoCast(m_creature,SPELL_SUMMON_SYTH_FROST,true); //left - DoCast(m_creature,SPELL_SUMMON_SYTH_SHADOW,true); //right - } - - void UpdateAI(const uint32 diff) - { - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - if( ((m_creature->GetHealth()*100) / m_creature->GetMaxHealth() < 90) && !summon90) - { - SythSummoning(); - summon90 = true; - } - - if( ((m_creature->GetHealth()*100) / m_creature->GetMaxHealth() < 50) && !summon50) - { - SythSummoning(); - summon50 = true; - } - - if( ((m_creature->GetHealth()*100) / m_creature->GetMaxHealth() < 10) && !summon10) - { - SythSummoning(); - summon10 = true; - } - - if( flameshock_timer < diff ) - { - if( Unit *target = SelectUnit(SELECT_TARGET_RANDOM,0) ) - DoCast(target,SPELL_FLAME_SHOCK); - - flameshock_timer = 10000 + rand()%5000; - }else flameshock_timer -= diff; - - if( arcaneshock_timer < diff ) - { - if( Unit *target = SelectUnit(SELECT_TARGET_RANDOM,0) ) - DoCast(target,SPELL_ARCANE_SHOCK); - - arcaneshock_timer = 10000 + rand()%5000; - }else arcaneshock_timer -= diff; - - if( frostshock_timer < diff ) - { - if( Unit *target = SelectUnit(SELECT_TARGET_RANDOM,0) ) - DoCast(target,SPELL_FROST_SHOCK); - - frostshock_timer = 10000 + rand()%5000; - }else frostshock_timer -= diff; - - if( shadowshock_timer < diff ) - { - if( Unit *target = SelectUnit(SELECT_TARGET_RANDOM,0) ) - DoCast(target,SPELL_SHADOW_SHOCK); - - shadowshock_timer = 10000 + rand()%5000; - }else shadowshock_timer -= diff; - - if( chainlightning_timer < diff ) - { - if( Unit *target = SelectUnit(SELECT_TARGET_RANDOM,0) ) - DoCast(target,SPELL_CHAIN_LIGHTNING); - - chainlightning_timer = 25000; - }else chainlightning_timer -= diff; - - DoMeleeAttackIfReady(); - } -}; - -CreatureAI* GetAI_boss_darkweaver_syth(Creature *_Creature) -{ - return new boss_darkweaver_sythAI (_Creature); -} - -/* ELEMENTALS */ - -struct MANGOS_DLL_DECL mob_syth_fireAI : public ScriptedAI -{ - mob_syth_fireAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 flameshock_timer; - uint32 flamebuffet_timer; - - void Reset() - { - m_creature->ApplySpellImmune(0, IMMUNITY_SCHOOL, SPELL_SCHOOL_MASK_FIRE, true); - flameshock_timer = 2500; - flamebuffet_timer = 5000; - } - - void Aggro(Unit *who) { } - - void UpdateAI(const uint32 diff) - { - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - if(flameshock_timer < diff) - { - if( Unit *target = SelectUnit(SELECT_TARGET_RANDOM,0) ) - DoCast(target,SPELL_FLAME_SHOCK); - - flameshock_timer = 5000; - }else flameshock_timer -= diff; - - if(flamebuffet_timer < diff) - { - if( Unit *target = SelectUnit(SELECT_TARGET_RANDOM,0) ) - DoCast(target,SPELL_FLAME_BUFFET); - - flamebuffet_timer = 5000; - }else flamebuffet_timer -= diff; - - DoMeleeAttackIfReady(); - } -}; - -CreatureAI* GetAI_mob_syth_fire(Creature *_Creature) -{ - return new mob_syth_fireAI (_Creature); -} - -struct MANGOS_DLL_DECL mob_syth_arcaneAI : public ScriptedAI -{ - mob_syth_arcaneAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 arcaneshock_timer; - uint32 arcanebuffet_timer; - - void Reset() - { - m_creature->ApplySpellImmune(0, IMMUNITY_SCHOOL, SPELL_SCHOOL_MASK_ARCANE, true); - arcaneshock_timer = 2500; - arcanebuffet_timer = 5000; - } - - void Aggro(Unit *who) { } - - void UpdateAI(const uint32 diff) - { - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - if(arcaneshock_timer < diff) - { - if( Unit *target = SelectUnit(SELECT_TARGET_RANDOM,0) ) - DoCast(target,SPELL_ARCANE_SHOCK); - - arcaneshock_timer = 5000; - }else arcaneshock_timer -= diff; - - if(arcanebuffet_timer < diff) - { - if( Unit *target = SelectUnit(SELECT_TARGET_RANDOM,0) ) - DoCast(target,SPELL_ARCANE_BUFFET); - - arcanebuffet_timer = 5000; - }else arcanebuffet_timer -= diff; - - DoMeleeAttackIfReady(); - } -}; - -CreatureAI* GetAI_mob_syth_arcane(Creature *_Creature) -{ - return new mob_syth_arcaneAI (_Creature); -} - -struct MANGOS_DLL_DECL mob_syth_frostAI : public ScriptedAI -{ - mob_syth_frostAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 frostshock_timer; - uint32 frostbuffet_timer; - - void Reset() - { - m_creature->ApplySpellImmune(0, IMMUNITY_SCHOOL, SPELL_SCHOOL_MASK_FROST, true); - frostshock_timer = 2500; - frostbuffet_timer = 5000; - } - - void Aggro(Unit *who) { } - - void UpdateAI(const uint32 diff) - { - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - if(frostshock_timer < diff) - { - if( Unit *target = SelectUnit(SELECT_TARGET_RANDOM,0) ) - DoCast(target,SPELL_FROST_SHOCK); - - frostshock_timer = 5000; - }else frostshock_timer -= diff; - - if(frostbuffet_timer < diff) - { - if( Unit *target = SelectUnit(SELECT_TARGET_RANDOM,0) ) - DoCast(target,SPELL_FROST_BUFFET); - - frostbuffet_timer = 5000; - }else frostbuffet_timer -= diff; - - DoMeleeAttackIfReady(); - } -}; - -CreatureAI* GetAI_mob_syth_frost(Creature *_Creature) -{ - return new mob_syth_frostAI (_Creature); -} - -struct MANGOS_DLL_DECL mob_syth_shadowAI : public ScriptedAI -{ - mob_syth_shadowAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 shadowshock_timer; - uint32 shadowbuffet_timer; - - void Reset() - { - m_creature->ApplySpellImmune(0, IMMUNITY_SCHOOL, SPELL_SCHOOL_MASK_SHADOW, true); - shadowshock_timer = 2500; - shadowbuffet_timer = 5000; - } - - void Aggro(Unit *who) { } - - void UpdateAI(const uint32 diff) - { - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - if(shadowshock_timer < diff) - { - if( Unit *target = SelectUnit(SELECT_TARGET_RANDOM,0) ) - DoCast(target,SPELL_SHADOW_SHOCK); - - shadowshock_timer = 5000; - }else shadowshock_timer -= diff; - - if(shadowbuffet_timer < diff) - { - if( Unit *target = SelectUnit(SELECT_TARGET_RANDOM,0) ) - DoCast(target,SPELL_SHADOW_BUFFET); - - shadowbuffet_timer = 5000; - }else shadowbuffet_timer -= diff; - - DoMeleeAttackIfReady(); - } -}; - -CreatureAI* GetAI_mob_syth_shadow(Creature *_Creature) -{ - return new mob_syth_shadowAI (_Creature); -} - -void AddSC_boss_darkweaver_syth() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_darkweaver_syth"; - newscript->GetAI = GetAI_boss_darkweaver_syth; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="mob_syth_fire"; - newscript->GetAI = GetAI_mob_syth_arcane; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="mob_syth_arcane"; - newscript->GetAI = GetAI_mob_syth_arcane; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="mob_syth_frost"; - newscript->GetAI = GetAI_mob_syth_frost; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="mob_syth_shadow"; - newscript->GetAI = GetAI_mob_syth_shadow; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Darkweaver_Syth +SD%Complete: 85 +SDComment: Shock spells/times need more work. Heroic not implemented. +SDCategory: Auchindoun, Sethekk Halls +EndScriptData */ + +#include "precompiled.h" + +#define SAY_SUMMON "I have pets....of my own!" +#define SOUND_SUMMON 10502 + +#define SAY_AGGRO_1 "Hrrmm.. Time to.. hrrm.. make my move." +#define SOUND_AGGRO_1 10503 +#define SAY_AGGRO_2 "Nice pets..hrm.. Yes! " +#define SOUND_AGGRO_2 10504 +#define SAY_AGGRO_3 "Nice pets have.. weapons. No so....nice." +#define SOUND_AGGRO_3 10505 + +#define SAY_SLAY_1 "Death.. meeting life is.. " +#define SOUND_SLAY_1 10506 +#define SAY_SLAY_2 "Uhn.. Be free.." +#define SOUND_SLAY_2 10507 + +#define SAY_DEATH "No more life..hrm. No more pain. " +#define SOUND_DEATH 10508 + +#define SPELL_FROST_SHOCK 37865 +#define SPELL_FLAME_SHOCK 34354 +#define SPELL_SHADOW_SHOCK 30138 +#define SPELL_ARCANE_SHOCK 37132 + +#define SPELL_CHAIN_LIGHTNING 39945 + +#define SPELL_SUMMON_SYTH_FIRE 33537 // Spawns 19203 +#define SPELL_SUMMON_SYTH_ARCANE 33538 // Spawns 19205 +#define SPELL_SUMMON_SYTH_FROST 33539 // Spawns 19204 +#define SPELL_SUMMON_SYTH_SHADOW 33540 // Spawns 19206 + +#define SPELL_FLAME_BUFFET 33526 +#define H_SPELL_FLAME_BUFFET 38141 +#define SPELL_ARCANE_BUFFET 33527 +#define H_SPELL_ARCANE_BUFFET 38138 +#define SPELL_FROST_BUFFET 33528 +#define H_SPELL_FROST_BUFFET 38142 +#define SPELL_SHADOW_BUFFET 33529 +#define H_SPELL_SHADOW_BUFFET 38143 + +struct MANGOS_DLL_DECL boss_darkweaver_sythAI : public ScriptedAI +{ + boss_darkweaver_sythAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 flameshock_timer; + uint32 arcaneshock_timer; + uint32 frostshock_timer; + uint32 shadowshock_timer; + uint32 chainlightning_timer; + + bool summon90; + bool summon50; + bool summon10; + + void Reset() + { + flameshock_timer = 2000; + arcaneshock_timer = 4000; + frostshock_timer = 6000; + shadowshock_timer = 8000; + chainlightning_timer = 15000; + + summon90 = false; + summon50 = false; + summon10 = false; + } + + void Aggro(Unit *who) + { + switch(rand()%3) + { + case 0: + DoYell(SAY_AGGRO_1, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature,SOUND_AGGRO_1); + break; + case 1: + DoYell(SAY_AGGRO_2, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature,SOUND_AGGRO_2); + break; + case 2: + DoYell(SAY_AGGRO_3, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature,SOUND_AGGRO_3); + break; + } + } + + void JustDied(Unit* Killer) + { + DoYell(SAY_DEATH, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature,SOUND_DEATH); + } + + void KilledUnit(Unit* victim) + { + if (rand()%2) + return; + + switch(rand()%2) + { + case 0: + DoYell(SAY_SLAY_1, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature,SOUND_SLAY_1); + break; + case 1: + DoYell(SAY_SLAY_2, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature,SOUND_SLAY_2); + break; + } + } + + void JustSummoned(Creature *summoned) + { + if( Unit *target = SelectUnit(SELECT_TARGET_RANDOM,0) ) + summoned->AI()->AttackStart(target); + + } + + void SythSummoning() + { + DoYell(SAY_SUMMON, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature,SOUND_SUMMON); + + if( m_creature->IsNonMeleeSpellCasted(false) ) + m_creature->InterruptNonMeleeSpells(false); + + DoCast(m_creature,SPELL_SUMMON_SYTH_ARCANE,true); //front + DoCast(m_creature,SPELL_SUMMON_SYTH_FIRE,true); //back + DoCast(m_creature,SPELL_SUMMON_SYTH_FROST,true); //left + DoCast(m_creature,SPELL_SUMMON_SYTH_SHADOW,true); //right + } + + void UpdateAI(const uint32 diff) + { + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + if( ((m_creature->GetHealth()*100) / m_creature->GetMaxHealth() < 90) && !summon90) + { + SythSummoning(); + summon90 = true; + } + + if( ((m_creature->GetHealth()*100) / m_creature->GetMaxHealth() < 50) && !summon50) + { + SythSummoning(); + summon50 = true; + } + + if( ((m_creature->GetHealth()*100) / m_creature->GetMaxHealth() < 10) && !summon10) + { + SythSummoning(); + summon10 = true; + } + + if( flameshock_timer < diff ) + { + if( Unit *target = SelectUnit(SELECT_TARGET_RANDOM,0) ) + DoCast(target,SPELL_FLAME_SHOCK); + + flameshock_timer = 10000 + rand()%5000; + }else flameshock_timer -= diff; + + if( arcaneshock_timer < diff ) + { + if( Unit *target = SelectUnit(SELECT_TARGET_RANDOM,0) ) + DoCast(target,SPELL_ARCANE_SHOCK); + + arcaneshock_timer = 10000 + rand()%5000; + }else arcaneshock_timer -= diff; + + if( frostshock_timer < diff ) + { + if( Unit *target = SelectUnit(SELECT_TARGET_RANDOM,0) ) + DoCast(target,SPELL_FROST_SHOCK); + + frostshock_timer = 10000 + rand()%5000; + }else frostshock_timer -= diff; + + if( shadowshock_timer < diff ) + { + if( Unit *target = SelectUnit(SELECT_TARGET_RANDOM,0) ) + DoCast(target,SPELL_SHADOW_SHOCK); + + shadowshock_timer = 10000 + rand()%5000; + }else shadowshock_timer -= diff; + + if( chainlightning_timer < diff ) + { + if( Unit *target = SelectUnit(SELECT_TARGET_RANDOM,0) ) + DoCast(target,SPELL_CHAIN_LIGHTNING); + + chainlightning_timer = 25000; + }else chainlightning_timer -= diff; + + DoMeleeAttackIfReady(); + } +}; + +CreatureAI* GetAI_boss_darkweaver_syth(Creature *_Creature) +{ + return new boss_darkweaver_sythAI (_Creature); +} + +/* ELEMENTALS */ + +struct MANGOS_DLL_DECL mob_syth_fireAI : public ScriptedAI +{ + mob_syth_fireAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 flameshock_timer; + uint32 flamebuffet_timer; + + void Reset() + { + m_creature->ApplySpellImmune(0, IMMUNITY_SCHOOL, SPELL_SCHOOL_MASK_FIRE, true); + flameshock_timer = 2500; + flamebuffet_timer = 5000; + } + + void Aggro(Unit *who) { } + + void UpdateAI(const uint32 diff) + { + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + if(flameshock_timer < diff) + { + if( Unit *target = SelectUnit(SELECT_TARGET_RANDOM,0) ) + DoCast(target,SPELL_FLAME_SHOCK); + + flameshock_timer = 5000; + }else flameshock_timer -= diff; + + if(flamebuffet_timer < diff) + { + if( Unit *target = SelectUnit(SELECT_TARGET_RANDOM,0) ) + DoCast(target,SPELL_FLAME_BUFFET); + + flamebuffet_timer = 5000; + }else flamebuffet_timer -= diff; + + DoMeleeAttackIfReady(); + } +}; + +CreatureAI* GetAI_mob_syth_fire(Creature *_Creature) +{ + return new mob_syth_fireAI (_Creature); +} + +struct MANGOS_DLL_DECL mob_syth_arcaneAI : public ScriptedAI +{ + mob_syth_arcaneAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 arcaneshock_timer; + uint32 arcanebuffet_timer; + + void Reset() + { + m_creature->ApplySpellImmune(0, IMMUNITY_SCHOOL, SPELL_SCHOOL_MASK_ARCANE, true); + arcaneshock_timer = 2500; + arcanebuffet_timer = 5000; + } + + void Aggro(Unit *who) { } + + void UpdateAI(const uint32 diff) + { + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + if(arcaneshock_timer < diff) + { + if( Unit *target = SelectUnit(SELECT_TARGET_RANDOM,0) ) + DoCast(target,SPELL_ARCANE_SHOCK); + + arcaneshock_timer = 5000; + }else arcaneshock_timer -= diff; + + if(arcanebuffet_timer < diff) + { + if( Unit *target = SelectUnit(SELECT_TARGET_RANDOM,0) ) + DoCast(target,SPELL_ARCANE_BUFFET); + + arcanebuffet_timer = 5000; + }else arcanebuffet_timer -= diff; + + DoMeleeAttackIfReady(); + } +}; + +CreatureAI* GetAI_mob_syth_arcane(Creature *_Creature) +{ + return new mob_syth_arcaneAI (_Creature); +} + +struct MANGOS_DLL_DECL mob_syth_frostAI : public ScriptedAI +{ + mob_syth_frostAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 frostshock_timer; + uint32 frostbuffet_timer; + + void Reset() + { + m_creature->ApplySpellImmune(0, IMMUNITY_SCHOOL, SPELL_SCHOOL_MASK_FROST, true); + frostshock_timer = 2500; + frostbuffet_timer = 5000; + } + + void Aggro(Unit *who) { } + + void UpdateAI(const uint32 diff) + { + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + if(frostshock_timer < diff) + { + if( Unit *target = SelectUnit(SELECT_TARGET_RANDOM,0) ) + DoCast(target,SPELL_FROST_SHOCK); + + frostshock_timer = 5000; + }else frostshock_timer -= diff; + + if(frostbuffet_timer < diff) + { + if( Unit *target = SelectUnit(SELECT_TARGET_RANDOM,0) ) + DoCast(target,SPELL_FROST_BUFFET); + + frostbuffet_timer = 5000; + }else frostbuffet_timer -= diff; + + DoMeleeAttackIfReady(); + } +}; + +CreatureAI* GetAI_mob_syth_frost(Creature *_Creature) +{ + return new mob_syth_frostAI (_Creature); +} + +struct MANGOS_DLL_DECL mob_syth_shadowAI : public ScriptedAI +{ + mob_syth_shadowAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 shadowshock_timer; + uint32 shadowbuffet_timer; + + void Reset() + { + m_creature->ApplySpellImmune(0, IMMUNITY_SCHOOL, SPELL_SCHOOL_MASK_SHADOW, true); + shadowshock_timer = 2500; + shadowbuffet_timer = 5000; + } + + void Aggro(Unit *who) { } + + void UpdateAI(const uint32 diff) + { + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + if(shadowshock_timer < diff) + { + if( Unit *target = SelectUnit(SELECT_TARGET_RANDOM,0) ) + DoCast(target,SPELL_SHADOW_SHOCK); + + shadowshock_timer = 5000; + }else shadowshock_timer -= diff; + + if(shadowbuffet_timer < diff) + { + if( Unit *target = SelectUnit(SELECT_TARGET_RANDOM,0) ) + DoCast(target,SPELL_SHADOW_BUFFET); + + shadowbuffet_timer = 5000; + }else shadowbuffet_timer -= diff; + + DoMeleeAttackIfReady(); + } +}; + +CreatureAI* GetAI_mob_syth_shadow(Creature *_Creature) +{ + return new mob_syth_shadowAI (_Creature); +} + +void AddSC_boss_darkweaver_syth() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_darkweaver_syth"; + newscript->GetAI = GetAI_boss_darkweaver_syth; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="mob_syth_fire"; + newscript->GetAI = GetAI_mob_syth_arcane; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="mob_syth_arcane"; + newscript->GetAI = GetAI_mob_syth_arcane; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="mob_syth_frost"; + newscript->GetAI = GetAI_mob_syth_frost; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="mob_syth_shadow"; + newscript->GetAI = GetAI_mob_syth_shadow; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/aunchindoun/sethekk_halls/boss_tailonking_ikiss.cpp b/src/bindings/scripts/scripts/zone/aunchindoun/sethekk_halls/boss_tailonking_ikiss.cpp index 4168458685d..0effeedb469 100644 --- a/src/bindings/scripts/scripts/zone/aunchindoun/sethekk_halls/boss_tailonking_ikiss.cpp +++ b/src/bindings/scripts/scripts/zone/aunchindoun/sethekk_halls/boss_tailonking_ikiss.cpp @@ -1,256 +1,256 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Talon_King_Ikiss -SD%Complete: 80 -SDComment: Heroic supported. Some details missing, but most are spell related. -SDCategory: Auchindoun, Sethekk Halls -EndScriptData */ - -#include "precompiled.h" -#include "def_sethekk_halls.h" - -#define SAY_INTRO "..Trinkets yes pretty Trinkets....power, great power...power in Trinkets.." -#define SOUND_INTRO 10557 - -#define SAY_AGGRO_1 "You make war on Ikiss?.." -#define SOUND_AGGRO_1 10554 -#define SAY_AGGRO_2 "Ikiss cut you pretty....slice you. Yes!" -#define SOUND_AGGRO_2 10555 -#define SAY_AGGRO_3 "No escape for....for you" -#define SOUND_AGGRO_3 10556 - -#define SAY_SLAY_1 "You die....stay away from Trinkets" -#define SOUND_SLAY_1 10558 -#define SAY_SLAY_2 "" -#define SOUND_SLAY_2 10559 - -#define SAY_DEATH "Ikiss will not....die" -#define SOUND_DEATH 10560 - -#define EMOTE_ARCANE_EXP "begins to channel arcane energy..." - -#define SPELL_BLINK 38194 -#define SPELL_BLINK_TELEPORT 38203 -#define SPELL_MANA_SHIELD 38151 -#define SPELL_ARCANE_BUBBLE 9438 -#define H_SPELL_SLOW 35032 - -#define SPELL_POLYMORPH 38245 -#define H_SPELL_POLYMORPH 43309 - -#define SPELL_ARCANE_VOLLEY 35059 -#define H_SPELL_ARCANE_VOLLEY 40424 - -#define SPELL_ARCANE_EXPLOSION 38197 -#define H_SPELL_ARCANE_EXPLOSION 40425 - -struct MANGOS_DLL_DECL boss_talon_king_ikissAI : public ScriptedAI -{ - boss_talon_king_ikissAI(Creature *c) : ScriptedAI(c) - { - pInstance = ((ScriptedInstance*)c->GetInstanceData()); - Reset(); - } - - ScriptedInstance* pInstance; - - bool HeroicMode; - - uint32 ArcaneVolley_Timer; - uint32 Sheep_Timer; - uint32 Blink_Timer; - uint32 Slow_Timer; - - bool ManaShield; - bool Blink; - bool Intro; - - void Reset() - { - HeroicMode = m_creature->GetMap()->IsHeroic(); - - ArcaneVolley_Timer = 5000; - Sheep_Timer = 8000; - Blink_Timer = 35000; - Slow_Timer = 15000+rand()%15000; - Blink = false; - Intro = false; - ManaShield = false; - } - - void MoveInLineOfSight(Unit *who) - { - if( !m_creature->getVictim() && who->isTargetableForAttack() && ( m_creature->IsHostileTo( who )) && who->isInAccessablePlaceFor(m_creature) ) - { - if(!Intro && m_creature->IsWithinDistInMap(who, 100)) - { - Intro = true; - DoYell(SAY_INTRO, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature,SOUND_INTRO); - } - - if (m_creature->GetDistanceZ(who) > CREATURE_Z_ATTACK_RANGE) - return; - - float attackRadius = m_creature->GetAttackDistance(who); - if( m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->IsWithinLOSInMap(who) ) - { - DoStartAttackAndMovement(who); - who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); - - if (!InCombat) - { - Aggro(who); - InCombat = true; - } - } - } - } - - void Aggro(Unit *who) - { - switch(rand()%3) - { - case 0: - DoYell(SAY_AGGRO_1, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature,SOUND_AGGRO_1); - break; - - case 1: - DoYell(SAY_AGGRO_2, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature,SOUND_AGGRO_2); - break; - - case 2: - DoYell(SAY_AGGRO_3, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature,SOUND_AGGRO_3); - break; - } - } - - void JustDied(Unit* Killer) - { - DoYell(SAY_DEATH, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature,SOUND_DEATH); - - if( pInstance ) - pInstance->SetData(DATA_IKISSDOOREVENT, DONE); - } - - void KilledUnit(Unit* victim) - { - switch(rand()%2) - { - case 0: - DoYell(SAY_SLAY_1, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature,SOUND_SLAY_1); - break; - - case 1: - DoYell(SAY_SLAY_2, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature,SOUND_SLAY_2); - break; - } - } - - void UpdateAI(const uint32 diff) - { - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - if( Blink ) - { - DoCast(m_creature,HeroicMode ? H_SPELL_ARCANE_EXPLOSION : SPELL_ARCANE_EXPLOSION); - m_creature->CastSpell(m_creature,SPELL_ARCANE_BUBBLE,true); - Blink = false; - } - - if( ArcaneVolley_Timer < diff ) - { - DoCast(m_creature,HeroicMode ? H_SPELL_ARCANE_VOLLEY : SPELL_ARCANE_VOLLEY); - ArcaneVolley_Timer = 10000+rand()%5000; - }else ArcaneVolley_Timer -= diff; - - if( Sheep_Timer < diff ) - { - //second top aggro target in normal, random target in heroic correct? - Unit *target = NULL; - if( HeroicMode ? target = SelectUnit(SELECT_TARGET_RANDOM,0) : target = SelectUnit(SELECT_TARGET_TOPAGGRO,1) ) - DoCast(target,HeroicMode ? H_SPELL_POLYMORPH : SPELL_POLYMORPH); - Sheep_Timer = 15000+rand()%2500; - }else Sheep_Timer -= diff; - - //may not be correct time to cast - if( !ManaShield && ((m_creature->GetHealth()*100) / m_creature->GetMaxHealth() < 20) ) - { - DoCast(m_creature,SPELL_MANA_SHIELD); - ManaShield = true; - } - - if( HeroicMode ) - { - if( Slow_Timer < diff ) - { - DoCast(m_creature,H_SPELL_SLOW); - Slow_Timer = 15000+rand()%25000; - }else Slow_Timer -= diff; - } - - if( Blink_Timer < diff ) - { - DoTextEmote(EMOTE_ARCANE_EXP,NULL,true); - - if( Unit *target = SelectUnit(SELECT_TARGET_RANDOM,0) ) - { - if( m_creature->IsNonMeleeSpellCasted(false) ) - m_creature->InterruptNonMeleeSpells(false); - - //Spell doesn't work, but we use for visual effect at least - DoCast(target,SPELL_BLINK); - - float X = target->GetPositionX(); - float Y = target->GetPositionY(); - float Z = target->GetPositionZ(); - - m_creature->Relocate(X,Y,Z); - m_creature->SendMonsterMove(X, Y, Z, 0, 0, 0); - - DoCast(target,SPELL_BLINK_TELEPORT); - Blink = true; - } - Blink_Timer = 35000+rand()%5000; - }else Blink_Timer -= diff; - - if( !Blink ) - DoMeleeAttackIfReady(); - } -}; - -CreatureAI* GetAI_boss_talon_king_ikiss(Creature *_Creature) -{ - return new boss_talon_king_ikissAI (_Creature); -} - -void AddSC_boss_talon_king_ikiss() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_talon_king_ikiss"; - newscript->GetAI = GetAI_boss_talon_king_ikiss; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Talon_King_Ikiss +SD%Complete: 80 +SDComment: Heroic supported. Some details missing, but most are spell related. +SDCategory: Auchindoun, Sethekk Halls +EndScriptData */ + +#include "precompiled.h" +#include "def_sethekk_halls.h" + +#define SAY_INTRO "..Trinkets yes pretty Trinkets....power, great power...power in Trinkets.." +#define SOUND_INTRO 10557 + +#define SAY_AGGRO_1 "You make war on Ikiss?.." +#define SOUND_AGGRO_1 10554 +#define SAY_AGGRO_2 "Ikiss cut you pretty....slice you. Yes!" +#define SOUND_AGGRO_2 10555 +#define SAY_AGGRO_3 "No escape for....for you" +#define SOUND_AGGRO_3 10556 + +#define SAY_SLAY_1 "You die....stay away from Trinkets" +#define SOUND_SLAY_1 10558 +#define SAY_SLAY_2 "" +#define SOUND_SLAY_2 10559 + +#define SAY_DEATH "Ikiss will not....die" +#define SOUND_DEATH 10560 + +#define EMOTE_ARCANE_EXP "begins to channel arcane energy..." + +#define SPELL_BLINK 38194 +#define SPELL_BLINK_TELEPORT 38203 +#define SPELL_MANA_SHIELD 38151 +#define SPELL_ARCANE_BUBBLE 9438 +#define H_SPELL_SLOW 35032 + +#define SPELL_POLYMORPH 38245 +#define H_SPELL_POLYMORPH 43309 + +#define SPELL_ARCANE_VOLLEY 35059 +#define H_SPELL_ARCANE_VOLLEY 40424 + +#define SPELL_ARCANE_EXPLOSION 38197 +#define H_SPELL_ARCANE_EXPLOSION 40425 + +struct MANGOS_DLL_DECL boss_talon_king_ikissAI : public ScriptedAI +{ + boss_talon_king_ikissAI(Creature *c) : ScriptedAI(c) + { + pInstance = ((ScriptedInstance*)c->GetInstanceData()); + Reset(); + } + + ScriptedInstance* pInstance; + + bool HeroicMode; + + uint32 ArcaneVolley_Timer; + uint32 Sheep_Timer; + uint32 Blink_Timer; + uint32 Slow_Timer; + + bool ManaShield; + bool Blink; + bool Intro; + + void Reset() + { + HeroicMode = m_creature->GetMap()->IsHeroic(); + + ArcaneVolley_Timer = 5000; + Sheep_Timer = 8000; + Blink_Timer = 35000; + Slow_Timer = 15000+rand()%15000; + Blink = false; + Intro = false; + ManaShield = false; + } + + void MoveInLineOfSight(Unit *who) + { + if( !m_creature->getVictim() && who->isTargetableForAttack() && ( m_creature->IsHostileTo( who )) && who->isInAccessablePlaceFor(m_creature) ) + { + if(!Intro && m_creature->IsWithinDistInMap(who, 100)) + { + Intro = true; + DoYell(SAY_INTRO, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature,SOUND_INTRO); + } + + if (!m_creature->canFly() && m_creature->GetDistanceZ(who) > CREATURE_Z_ATTACK_RANGE) + return; + + float attackRadius = m_creature->GetAttackDistance(who); + if( m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->IsWithinLOSInMap(who) ) + { + DoStartAttackAndMovement(who); + who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); + + if (!InCombat) + { + Aggro(who); + InCombat = true; + } + } + } + } + + void Aggro(Unit *who) + { + switch(rand()%3) + { + case 0: + DoYell(SAY_AGGRO_1, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature,SOUND_AGGRO_1); + break; + + case 1: + DoYell(SAY_AGGRO_2, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature,SOUND_AGGRO_2); + break; + + case 2: + DoYell(SAY_AGGRO_3, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature,SOUND_AGGRO_3); + break; + } + } + + void JustDied(Unit* Killer) + { + DoYell(SAY_DEATH, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature,SOUND_DEATH); + + if( pInstance ) + pInstance->SetData(DATA_IKISSDOOREVENT, DONE); + } + + void KilledUnit(Unit* victim) + { + switch(rand()%2) + { + case 0: + DoYell(SAY_SLAY_1, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature,SOUND_SLAY_1); + break; + + case 1: + DoYell(SAY_SLAY_2, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature,SOUND_SLAY_2); + break; + } + } + + void UpdateAI(const uint32 diff) + { + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + if( Blink ) + { + DoCast(m_creature,HeroicMode ? H_SPELL_ARCANE_EXPLOSION : SPELL_ARCANE_EXPLOSION); + m_creature->CastSpell(m_creature,SPELL_ARCANE_BUBBLE,true); + Blink = false; + } + + if( ArcaneVolley_Timer < diff ) + { + DoCast(m_creature,HeroicMode ? H_SPELL_ARCANE_VOLLEY : SPELL_ARCANE_VOLLEY); + ArcaneVolley_Timer = 10000+rand()%5000; + }else ArcaneVolley_Timer -= diff; + + if( Sheep_Timer < diff ) + { + //second top aggro target in normal, random target in heroic correct? + Unit *target = NULL; + if( HeroicMode ? target = SelectUnit(SELECT_TARGET_RANDOM,0) : target = SelectUnit(SELECT_TARGET_TOPAGGRO,1) ) + DoCast(target,HeroicMode ? H_SPELL_POLYMORPH : SPELL_POLYMORPH); + Sheep_Timer = 15000+rand()%2500; + }else Sheep_Timer -= diff; + + //may not be correct time to cast + if( !ManaShield && ((m_creature->GetHealth()*100) / m_creature->GetMaxHealth() < 20) ) + { + DoCast(m_creature,SPELL_MANA_SHIELD); + ManaShield = true; + } + + if( HeroicMode ) + { + if( Slow_Timer < diff ) + { + DoCast(m_creature,H_SPELL_SLOW); + Slow_Timer = 15000+rand()%25000; + }else Slow_Timer -= diff; + } + + if( Blink_Timer < diff ) + { + DoTextEmote(EMOTE_ARCANE_EXP,NULL,true); + + if( Unit *target = SelectUnit(SELECT_TARGET_RANDOM,0) ) + { + if( m_creature->IsNonMeleeSpellCasted(false) ) + m_creature->InterruptNonMeleeSpells(false); + + //Spell doesn't work, but we use for visual effect at least + DoCast(target,SPELL_BLINK); + + float X = target->GetPositionX(); + float Y = target->GetPositionY(); + float Z = target->GetPositionZ(); + + m_creature->Relocate(X,Y,Z); + m_creature->SendMonsterMove(X, Y, Z, 0, 0, 0); + + DoCast(target,SPELL_BLINK_TELEPORT); + Blink = true; + } + Blink_Timer = 35000+rand()%5000; + }else Blink_Timer -= diff; + + if( !Blink ) + DoMeleeAttackIfReady(); + } +}; + +CreatureAI* GetAI_boss_talon_king_ikiss(Creature *_Creature) +{ + return new boss_talon_king_ikissAI (_Creature); +} + +void AddSC_boss_talon_king_ikiss() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_talon_king_ikiss"; + newscript->GetAI = GetAI_boss_talon_king_ikiss; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/aunchindoun/sethekk_halls/def_sethekk_halls.h b/src/bindings/scripts/scripts/zone/aunchindoun/sethekk_halls/def_sethekk_halls.h index f609ecac1f2..73aafca29f7 100644 --- a/src/bindings/scripts/scripts/zone/aunchindoun/sethekk_halls/def_sethekk_halls.h +++ b/src/bindings/scripts/scripts/zone/aunchindoun/sethekk_halls/def_sethekk_halls.h @@ -1,9 +1,9 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software licensed under GPL version 2 - * Please see the included DOCS/LICENSE.TXT for more information */ - -#ifndef DEF_SETHEKK_HALLS_H -#define DEF_SETHEKK_HALLS_H - -#define DATA_IKISSDOOREVENT 1 -#endif +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software licensed under GPL version 2 + * Please see the included DOCS/LICENSE.TXT for more information */ + +#ifndef DEF_SETHEKK_HALLS_H +#define DEF_SETHEKK_HALLS_H + +#define DATA_IKISSDOOREVENT 1 +#endif diff --git a/src/bindings/scripts/scripts/zone/aunchindoun/sethekk_halls/instance_sethekk_halls.cpp b/src/bindings/scripts/scripts/zone/aunchindoun/sethekk_halls/instance_sethekk_halls.cpp index 980717653c6..244fada32f7 100644 --- a/src/bindings/scripts/scripts/zone/aunchindoun/sethekk_halls/instance_sethekk_halls.cpp +++ b/src/bindings/scripts/scripts/zone/aunchindoun/sethekk_halls/instance_sethekk_halls.cpp @@ -1,74 +1,74 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Instance - Sethekk Halls -SD%Complete: 50 -SDComment: Instance Data for Sethekk Halls instance -SDCategory: Auchindoun, Sethekk Halls -EndScriptData */ - -#include "precompiled.h" -#include "def_sethekk_halls.h" - -#define IKISS_DOOR 177203 - -struct MANGOS_DLL_DECL instance_sethekk_halls : public ScriptedInstance -{ - instance_sethekk_halls(Map *Map) : ScriptedInstance(Map) {Initialize();}; - - GameObject *IkissDoor; - - void Initialize() - { - IkissDoor = NULL; - } - - void OnObjectCreate(GameObject *go) - { - switch(go->GetEntry()) - { - case IKISS_DOOR: - IkissDoor = go; - break; - } - } - - void SetData(uint32 type, uint32 data) - { - switch(type) - { - case DATA_IKISSDOOREVENT: - if( IkissDoor ) - IkissDoor->SetGoState(0); - break; - } - } -}; - -InstanceData* GetInstanceData_instance_sethekk_halls(Map* map) -{ - return new instance_sethekk_halls(map); -} - -void AddSC_instance_sethekk_halls() -{ - Script *newscript; - newscript = new Script; - newscript->Name = "instance_sethekk_halls"; - newscript->GetInstanceData = GetInstanceData_instance_sethekk_halls; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Instance - Sethekk Halls +SD%Complete: 50 +SDComment: Instance Data for Sethekk Halls instance +SDCategory: Auchindoun, Sethekk Halls +EndScriptData */ + +#include "precompiled.h" +#include "def_sethekk_halls.h" + +#define IKISS_DOOR 177203 + +struct MANGOS_DLL_DECL instance_sethekk_halls : public ScriptedInstance +{ + instance_sethekk_halls(Map *Map) : ScriptedInstance(Map) {Initialize();}; + + GameObject *IkissDoor; + + void Initialize() + { + IkissDoor = NULL; + } + + void OnObjectCreate(GameObject *go) + { + switch(go->GetEntry()) + { + case IKISS_DOOR: + IkissDoor = go; + break; + } + } + + void SetData(uint32 type, uint32 data) + { + switch(type) + { + case DATA_IKISSDOOREVENT: + if( IkissDoor ) + IkissDoor->SetGoState(0); + break; + } + } +}; + +InstanceData* GetInstanceData_instance_sethekk_halls(Map* map) +{ + return new instance_sethekk_halls(map); +} + +void AddSC_instance_sethekk_halls() +{ + Script *newscript; + newscript = new Script; + newscript->Name = "instance_sethekk_halls"; + newscript->GetInstanceData = GetInstanceData_instance_sethekk_halls; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/aunchindoun/shadow_labyrinth/boss_ambassador_hellmaw.cpp b/src/bindings/scripts/scripts/zone/aunchindoun/shadow_labyrinth/boss_ambassador_hellmaw.cpp index b575461dfaa..69d26ac8a75 100644 --- a/src/bindings/scripts/scripts/zone/aunchindoun/shadow_labyrinth/boss_ambassador_hellmaw.cpp +++ b/src/bindings/scripts/scripts/zone/aunchindoun/shadow_labyrinth/boss_ambassador_hellmaw.cpp @@ -1,223 +1,223 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Ambassador_Hellmaw -SD%Complete: 75 -SDComment: Waypoints after Intro not implemented. Enrage spell missing/not known -SDCategory: Auchindoun, Shadow Labyrinth -EndScriptData */ - -#include "precompiled.h" -#include "def_shadow_labyrinth.h" - -#define SAY_INTRO "Infidels have invaded the sanctuary! Sniveling pests...You have yet to learn the true meaning of agony!" -#define SOUND_INTRO 10473 - -#define SAY_AGGRO1 "Pathetic mortals! You will pay dearly!" -#define SOUND_AGGRO1 10475 -#define SAY_AGGRO2 "I will break you!" -#define SOUND_AGGRO2 10476 -#define SAY_AGGRO3 "Finally! Something to relieve the tedium!" -#define SOUND_AGGRO3 10477 - -#define SAY_HELP "Aid me, you fools, before it's too late!" -#define SOUND_HELP 10474 - -#define SAY_SLAY1 "Do you fear death?" -#define SOUND_SLAY1 10478 -#define SAY_SLAY2 "This is the part I enjoy most." -#define SOUND_SLAY2 10479 - -#define SAY_DEATH "Do not...grow...overconfident, mortal." -#define SOUND_DEATH 10480 - -#define SPELL_BANISH 30231 -#define SPELL_CORROSIVE_ACID 23313 -#define SPELL_FEAR 33547 -#define SPELL_ENRAGE 0 //need to find proper spell - -struct MANGOS_DLL_DECL boss_ambassador_hellmawAI : public ScriptedAI -{ - boss_ambassador_hellmawAI(Creature *c) : ScriptedAI(c) - { - pInstance = ((ScriptedInstance*)c->GetInstanceData()); - Reset(); - } - - ScriptedInstance* pInstance; - bool HeroicMode; - - uint32 EventCheck_Timer; - uint32 CorrosiveAcid_Timer; - uint32 Fear_Timer; - uint32 Enrage_Timer; - bool Intro; - bool IsBanished; - - void Reset() - { - HeroicMode = m_creature->GetMap()->IsHeroic(); - - EventCheck_Timer = 5000; - CorrosiveAcid_Timer = 25000; - Fear_Timer = 40000; - Enrage_Timer = 180000; - Intro = false; - IsBanished = false; - - if( pInstance ) - { - if( pInstance->GetData(TYPE_HELLMAW) == NOT_STARTED ) - { - DoCast(m_creature,SPELL_BANISH); - IsBanished = true; - } - else pInstance->SetData(TYPE_HELLMAW,FAIL); - - if( pInstance->GetData(TYPE_OVERSEER) == DONE ) - { - if( m_creature->HasAura(SPELL_BANISH,0) ) - m_creature->RemoveAurasDueToSpell(SPELL_BANISH); - Intro = true; - } - } - } - - void MovementInform(uint32 type, uint32 id) - { - if( type != POINT_MOTION_TYPE ) - return; - } - - void DoIntro() - { - DoYell(SAY_INTRO, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_INTRO); - - if( m_creature->HasAura(SPELL_BANISH,0) ) - m_creature->RemoveAurasDueToSpell(SPELL_BANISH); - - IsBanished = false; - Intro = true; - - if( pInstance ) - pInstance->SetData(TYPE_HELLMAW, IN_PROGRESS); - } - - void Aggro(Unit *who) - { - switch(rand()%3) - { - case 0: - DoYell(SAY_AGGRO1, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_AGGRO1); - break; - case 1: - DoYell(SAY_AGGRO2, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_AGGRO2); - break; - case 2: - DoYell(SAY_AGGRO3, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_AGGRO3); - break; - } - } - - void KilledUnit(Unit *victim) - { - switch(rand()%2) - { - case 0: - DoYell(SAY_SLAY1, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_SLAY1); - break; - case 1: - DoYell(SAY_SLAY2, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_SLAY2); - break; - } - } - - void JustDied(Unit *victim) - { - DoYell(SAY_DEATH, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_DEATH); - - if( pInstance ) - pInstance->SetData(TYPE_HELLMAW, DONE); - } - - void UpdateAI(const uint32 diff) - { - if( !Intro ) - { - if( EventCheck_Timer < diff ) - { - if( pInstance ) - { - if( pInstance->GetData(TYPE_OVERSEER) == DONE ) - DoIntro(); - } - EventCheck_Timer = 5000; - }else EventCheck_Timer -= diff; - } - - if( !InCombat && !IsBanished ) - { - //this is where we add MovePoint() - //DoWhine("I haz no mount!", LANG_UNIVERSAL, NULL); - } - - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - if( CorrosiveAcid_Timer < diff ) - { - DoCast(m_creature,SPELL_CORROSIVE_ACID); - CorrosiveAcid_Timer = 25000; - }else CorrosiveAcid_Timer -= diff; - - if( Fear_Timer < diff ) - { - DoCast(m_creature,SPELL_FEAR); - Fear_Timer = 35000; - }else Fear_Timer -= diff; - - /*if( HeroicMode ) - { - if( Enrage_Timer < diff ) - { - DoCast(m_creature,SPELL_ENRAGE); - }else Enrage_Timer -= diff; - }*/ - - DoMeleeAttackIfReady(); - } -}; -CreatureAI* GetAI_boss_ambassador_hellmaw(Creature *_Creature) -{ - return new boss_ambassador_hellmawAI (_Creature); -} - -void AddSC_boss_ambassador_hellmaw() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_ambassador_hellmaw"; - newscript->GetAI = GetAI_boss_ambassador_hellmaw; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Ambassador_Hellmaw +SD%Complete: 75 +SDComment: Waypoints after Intro not implemented. Enrage spell missing/not known +SDCategory: Auchindoun, Shadow Labyrinth +EndScriptData */ + +#include "precompiled.h" +#include "def_shadow_labyrinth.h" + +#define SAY_INTRO "Infidels have invaded the sanctuary! Sniveling pests...You have yet to learn the true meaning of agony!" +#define SOUND_INTRO 10473 + +#define SAY_AGGRO1 "Pathetic mortals! You will pay dearly!" +#define SOUND_AGGRO1 10475 +#define SAY_AGGRO2 "I will break you!" +#define SOUND_AGGRO2 10476 +#define SAY_AGGRO3 "Finally! Something to relieve the tedium!" +#define SOUND_AGGRO3 10477 + +#define SAY_HELP "Aid me, you fools, before it's too late!" +#define SOUND_HELP 10474 + +#define SAY_SLAY1 "Do you fear death?" +#define SOUND_SLAY1 10478 +#define SAY_SLAY2 "This is the part I enjoy most." +#define SOUND_SLAY2 10479 + +#define SAY_DEATH "Do not...grow...overconfident, mortal." +#define SOUND_DEATH 10480 + +#define SPELL_BANISH 30231 +#define SPELL_CORROSIVE_ACID 23313 +#define SPELL_FEAR 33547 +#define SPELL_ENRAGE 0 //need to find proper spell + +struct MANGOS_DLL_DECL boss_ambassador_hellmawAI : public ScriptedAI +{ + boss_ambassador_hellmawAI(Creature *c) : ScriptedAI(c) + { + pInstance = ((ScriptedInstance*)c->GetInstanceData()); + Reset(); + } + + ScriptedInstance* pInstance; + bool HeroicMode; + + uint32 EventCheck_Timer; + uint32 CorrosiveAcid_Timer; + uint32 Fear_Timer; + uint32 Enrage_Timer; + bool Intro; + bool IsBanished; + + void Reset() + { + HeroicMode = m_creature->GetMap()->IsHeroic(); + + EventCheck_Timer = 5000; + CorrosiveAcid_Timer = 25000; + Fear_Timer = 40000; + Enrage_Timer = 180000; + Intro = false; + IsBanished = false; + + if( pInstance ) + { + if( pInstance->GetData(TYPE_HELLMAW) == NOT_STARTED ) + { + DoCast(m_creature,SPELL_BANISH); + IsBanished = true; + } + else pInstance->SetData(TYPE_HELLMAW,FAIL); + + if( pInstance->GetData(TYPE_OVERSEER) == DONE ) + { + if( m_creature->HasAura(SPELL_BANISH,0) ) + m_creature->RemoveAurasDueToSpell(SPELL_BANISH); + Intro = true; + } + } + } + + void MovementInform(uint32 type, uint32 id) + { + if( type != POINT_MOTION_TYPE ) + return; + } + + void DoIntro() + { + DoYell(SAY_INTRO, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_INTRO); + + if( m_creature->HasAura(SPELL_BANISH,0) ) + m_creature->RemoveAurasDueToSpell(SPELL_BANISH); + + IsBanished = false; + Intro = true; + + if( pInstance ) + pInstance->SetData(TYPE_HELLMAW, IN_PROGRESS); + } + + void Aggro(Unit *who) + { + switch(rand()%3) + { + case 0: + DoYell(SAY_AGGRO1, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_AGGRO1); + break; + case 1: + DoYell(SAY_AGGRO2, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_AGGRO2); + break; + case 2: + DoYell(SAY_AGGRO3, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_AGGRO3); + break; + } + } + + void KilledUnit(Unit *victim) + { + switch(rand()%2) + { + case 0: + DoYell(SAY_SLAY1, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_SLAY1); + break; + case 1: + DoYell(SAY_SLAY2, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_SLAY2); + break; + } + } + + void JustDied(Unit *victim) + { + DoYell(SAY_DEATH, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_DEATH); + + if( pInstance ) + pInstance->SetData(TYPE_HELLMAW, DONE); + } + + void UpdateAI(const uint32 diff) + { + if( !Intro ) + { + if( EventCheck_Timer < diff ) + { + if( pInstance ) + { + if( pInstance->GetData(TYPE_OVERSEER) == DONE ) + DoIntro(); + } + EventCheck_Timer = 5000; + }else EventCheck_Timer -= diff; + } + + if( !InCombat && !IsBanished ) + { + //this is where we add MovePoint() + //DoWhine("I haz no mount!", LANG_UNIVERSAL, NULL); + } + + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + if( CorrosiveAcid_Timer < diff ) + { + DoCast(m_creature,SPELL_CORROSIVE_ACID); + CorrosiveAcid_Timer = 25000; + }else CorrosiveAcid_Timer -= diff; + + if( Fear_Timer < diff ) + { + DoCast(m_creature,SPELL_FEAR); + Fear_Timer = 35000; + }else Fear_Timer -= diff; + + /*if( HeroicMode ) + { + if( Enrage_Timer < diff ) + { + DoCast(m_creature,SPELL_ENRAGE); + }else Enrage_Timer -= diff; + }*/ + + DoMeleeAttackIfReady(); + } +}; +CreatureAI* GetAI_boss_ambassador_hellmaw(Creature *_Creature) +{ + return new boss_ambassador_hellmawAI (_Creature); +} + +void AddSC_boss_ambassador_hellmaw() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_ambassador_hellmaw"; + newscript->GetAI = GetAI_boss_ambassador_hellmaw; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/aunchindoun/shadow_labyrinth/boss_blackheart_the_inciter.cpp b/src/bindings/scripts/scripts/zone/aunchindoun/shadow_labyrinth/boss_blackheart_the_inciter.cpp index 0a8c446b15c..dab0343cad8 100644 --- a/src/bindings/scripts/scripts/zone/aunchindoun/shadow_labyrinth/boss_blackheart_the_inciter.cpp +++ b/src/bindings/scripts/scripts/zone/aunchindoun/shadow_labyrinth/boss_blackheart_the_inciter.cpp @@ -1,191 +1,191 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Blackheart_the_Inciter -SD%Complete: 75 -SDComment: Incite Chaos not functional since core lacks Mind Control support -SDCategory: Auchindoun, Shadow Labyrinth -EndScriptData */ - -#include "precompiled.h" -#include "def_shadow_labyrinth.h" - -#define SPELL_INCITE_CHAOS 33676 -#define SPELL_INCITE_CHAOS_B 33684 //debuff applied to each member of party -#define SPELL_CHARGE 33709 -#define SPELL_WAR_STOMP 33707 - -#define SAY_AGGRO1 "You be dead people!" -#define SAY_AGGRO2 "Time to kill!" -#define SAY_AGGRO3 "I see dead people!" -#define SAY_SLAY1 "No coming back for you!" -#define SAY_SLAY2 "Nice try!" -#define SAY_SLAY3 "Now you gone for good!" -#define SAY_DEATH "This...no...good.." - -#define SOUND_AGGRO1 10498 -#define SOUND_AGGRO2 10497 -#define SOUND_AGGRO3 10488 -#define SOUND_SLAY1 10489 -#define SOUND_SLAY2 10490 -#define SOUND_SLAY3 10499 -#define SOUND_DEATH 10491 - -struct MANGOS_DLL_DECL boss_blackheart_the_inciterAI : public ScriptedAI -{ - boss_blackheart_the_inciterAI(Creature *c) : ScriptedAI(c) - { - pInstance = ((ScriptedInstance*)c->GetInstanceData()); - Reset(); - } - - ScriptedInstance *pInstance; - - bool InciteChaos; - uint32 InciteChaos_Timer; - uint32 InciteChaosWait_Timer; - uint32 Charge_Timer; - uint32 Knockback_Timer; - - void Reset() - { - InciteChaos = false; - InciteChaos_Timer = 20000; - InciteChaosWait_Timer = 15000; - Charge_Timer = 5000; - Knockback_Timer = 15000; - - if( pInstance ) - pInstance->SetData(DATA_BLACKHEARTTHEINCITEREVENT, NOT_STARTED); - } - - void KilledUnit(Unit *victim) - { - switch(rand()%3) - { - case 0: - DoYell(SAY_SLAY1, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_SLAY1); - break; - case 1: - DoYell(SAY_SLAY2, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_SLAY2); - break; - case 2: - DoYell(SAY_SLAY3, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_SLAY3); - break; - } - } - - void JustDied(Unit *victim) - { - DoYell(SAY_DEATH, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_DEATH); - - if( pInstance ) - pInstance->SetData(DATA_BLACKHEARTTHEINCITEREVENT, DONE); - } - - void Aggro(Unit *who) - { - switch(rand()%3) - { - case 0: - DoYell(SAY_AGGRO1, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_AGGRO1); - break; - case 1: - DoYell(SAY_AGGRO2, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_AGGRO2); - break; - case 2: - DoYell(SAY_AGGRO3, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_AGGRO3); - break; - } - - if( pInstance ) - pInstance->SetData(DATA_BLACKHEARTTHEINCITEREVENT, IN_PROGRESS); - } - - void UpdateAI(const uint32 diff) - { - //Return since we have no target - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - if( InciteChaos ) - { - if( InciteChaosWait_Timer < diff ) - { - InciteChaos = false; - InciteChaosWait_Timer = 15000; - }else InciteChaosWait_Timer -= diff; - - return; - } - - if( InciteChaos_Timer < diff ) - { - DoCast(m_creature, SPELL_INCITE_CHAOS); - - std::list t_list = m_creature->getThreatManager().getThreatList(); - for( std::list::iterator itr = t_list.begin(); itr!= t_list.end(); ++itr ) - { - Unit* target = Unit::GetUnit(*m_creature, (*itr)->getUnitGuid()); - if( target && target->GetTypeId() == TYPEID_PLAYER ) - target->CastSpell(target,SPELL_INCITE_CHAOS_B,true); - } - - DoResetThreat(); - InciteChaos = true; - InciteChaos_Timer = 40000; - return; - }else InciteChaos_Timer -= diff; - - //Charge_Timer - if( Charge_Timer < diff ) - { - if( Unit *target = SelectUnit(SELECT_TARGET_RANDOM, 0) ) - DoCast(target, SPELL_CHARGE); - Charge_Timer = 25000; - }else Charge_Timer -= diff; - - //Knockback_Timer - if( Knockback_Timer < diff ) - { - DoCast(m_creature, SPELL_WAR_STOMP); - Knockback_Timer = 20000; - }else Knockback_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; -CreatureAI* GetAI_boss_blackheart_the_inciter(Creature *_Creature) -{ - return new boss_blackheart_the_inciterAI (_Creature); -} - -void AddSC_boss_blackheart_the_inciter() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_blackheart_the_inciter"; - newscript->GetAI = GetAI_boss_blackheart_the_inciter; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Blackheart_the_Inciter +SD%Complete: 75 +SDComment: Incite Chaos not functional since core lacks Mind Control support +SDCategory: Auchindoun, Shadow Labyrinth +EndScriptData */ + +#include "precompiled.h" +#include "def_shadow_labyrinth.h" + +#define SPELL_INCITE_CHAOS 33676 +#define SPELL_INCITE_CHAOS_B 33684 //debuff applied to each member of party +#define SPELL_CHARGE 33709 +#define SPELL_WAR_STOMP 33707 + +#define SAY_AGGRO1 "You be dead people!" +#define SAY_AGGRO2 "Time to kill!" +#define SAY_AGGRO3 "I see dead people!" +#define SAY_SLAY1 "No coming back for you!" +#define SAY_SLAY2 "Nice try!" +#define SAY_SLAY3 "Now you gone for good!" +#define SAY_DEATH "This...no...good.." + +#define SOUND_AGGRO1 10498 +#define SOUND_AGGRO2 10497 +#define SOUND_AGGRO3 10488 +#define SOUND_SLAY1 10489 +#define SOUND_SLAY2 10490 +#define SOUND_SLAY3 10499 +#define SOUND_DEATH 10491 + +struct MANGOS_DLL_DECL boss_blackheart_the_inciterAI : public ScriptedAI +{ + boss_blackheart_the_inciterAI(Creature *c) : ScriptedAI(c) + { + pInstance = ((ScriptedInstance*)c->GetInstanceData()); + Reset(); + } + + ScriptedInstance *pInstance; + + bool InciteChaos; + uint32 InciteChaos_Timer; + uint32 InciteChaosWait_Timer; + uint32 Charge_Timer; + uint32 Knockback_Timer; + + void Reset() + { + InciteChaos = false; + InciteChaos_Timer = 20000; + InciteChaosWait_Timer = 15000; + Charge_Timer = 5000; + Knockback_Timer = 15000; + + if( pInstance ) + pInstance->SetData(DATA_BLACKHEARTTHEINCITEREVENT, NOT_STARTED); + } + + void KilledUnit(Unit *victim) + { + switch(rand()%3) + { + case 0: + DoYell(SAY_SLAY1, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_SLAY1); + break; + case 1: + DoYell(SAY_SLAY2, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_SLAY2); + break; + case 2: + DoYell(SAY_SLAY3, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_SLAY3); + break; + } + } + + void JustDied(Unit *victim) + { + DoYell(SAY_DEATH, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_DEATH); + + if( pInstance ) + pInstance->SetData(DATA_BLACKHEARTTHEINCITEREVENT, DONE); + } + + void Aggro(Unit *who) + { + switch(rand()%3) + { + case 0: + DoYell(SAY_AGGRO1, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_AGGRO1); + break; + case 1: + DoYell(SAY_AGGRO2, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_AGGRO2); + break; + case 2: + DoYell(SAY_AGGRO3, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_AGGRO3); + break; + } + + if( pInstance ) + pInstance->SetData(DATA_BLACKHEARTTHEINCITEREVENT, IN_PROGRESS); + } + + void UpdateAI(const uint32 diff) + { + //Return since we have no target + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + if( InciteChaos ) + { + if( InciteChaosWait_Timer < diff ) + { + InciteChaos = false; + InciteChaosWait_Timer = 15000; + }else InciteChaosWait_Timer -= diff; + + return; + } + + if( InciteChaos_Timer < diff ) + { + DoCast(m_creature, SPELL_INCITE_CHAOS); + + std::list t_list = m_creature->getThreatManager().getThreatList(); + for( std::list::iterator itr = t_list.begin(); itr!= t_list.end(); ++itr ) + { + Unit* target = Unit::GetUnit(*m_creature, (*itr)->getUnitGuid()); + if( target && target->GetTypeId() == TYPEID_PLAYER ) + target->CastSpell(target,SPELL_INCITE_CHAOS_B,true); + } + + DoResetThreat(); + InciteChaos = true; + InciteChaos_Timer = 40000; + return; + }else InciteChaos_Timer -= diff; + + //Charge_Timer + if( Charge_Timer < diff ) + { + if( Unit *target = SelectUnit(SELECT_TARGET_RANDOM, 0) ) + DoCast(target, SPELL_CHARGE); + Charge_Timer = 25000; + }else Charge_Timer -= diff; + + //Knockback_Timer + if( Knockback_Timer < diff ) + { + DoCast(m_creature, SPELL_WAR_STOMP); + Knockback_Timer = 20000; + }else Knockback_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; +CreatureAI* GetAI_boss_blackheart_the_inciter(Creature *_Creature) +{ + return new boss_blackheart_the_inciterAI (_Creature); +} + +void AddSC_boss_blackheart_the_inciter() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_blackheart_the_inciter"; + newscript->GetAI = GetAI_boss_blackheart_the_inciter; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/aunchindoun/shadow_labyrinth/boss_grandmaster_vorpil.cpp b/src/bindings/scripts/scripts/zone/aunchindoun/shadow_labyrinth/boss_grandmaster_vorpil.cpp index 5e278c91fc5..4e1b791b9b6 100644 --- a/src/bindings/scripts/scripts/zone/aunchindoun/shadow_labyrinth/boss_grandmaster_vorpil.cpp +++ b/src/bindings/scripts/scripts/zone/aunchindoun/shadow_labyrinth/boss_grandmaster_vorpil.cpp @@ -1,294 +1,294 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Grandmaster_Vorpil -SD%Complete: 75 -SDComment: Despawn all summoned on death not implemented. Void Traveler effects not implemented. -SDCategory: Auchindoun, Shadow Labyrinth -EndScriptData */ - -#include "precompiled.h" -#include "def_shadow_labyrinth.h" - -#define SPELL_DRAW_SHADOWS 33563 -#define SPELL_VOID_PORTAL_A 33566 //spell only summon one unit, but we use it for the visual effect and summon the 4 other portals manual way(only one spell exist) -#define SPELL_VOID_PORTAL_VISUAL 33569 -#define SPELL_SHADOW_BOLT_VOLLEY 32963 -#define SPELL_SUMMON_VOIDWALKER_A 33582 -#define SPELL_SUMMON_VOIDWALKER_B 33583 -#define SPELL_SUMMON_VOIDWALKER_C 33584 -#define SPELL_SUMMON_VOIDWALKER_D 33585 -#define SPELL_SUMMON_VOIDWALKER_E 33586 -#define SPELL_RAIN_OF_FIRE 33617 -#define H_SPELL_RAIN_OF_FIRE 39363 -#define H_SPELL_BANISH 38791 - -#define SAY_INTRO "Keep your minds focused for the days of reckoning are close at hand. Soon, the destroyer of worlds will return to make good on his promise. Soon the destruction of all that is will begin!" -#define SAY_AGGRO1 "I'll make an offering of your blood!" -#define SAY_AGGRO2 "You'll be a fine example, for the others." -#define SAY_AGGRO3 "Good, a worthy sacrifice." -#define SAY_HELP "Come to my aid, heed your master now!" -#define SAY_SLAY1 "I serve with pride." -#define SAY_SLAY2 "Your death is for the greater cause!" -#define SAY_DEATH "I give my life... Gladly." - -#define SOUND_INTRO 10522 -#define SOUND_AGGRO1 10524 -#define SOUND_AGGRO2 10525 -#define SOUND_AGGRO3 10526 -#define SOUND_HELP 10523 -#define SOUND_SLAY1 10527 -#define SOUND_SLAY2 10528 -#define SOUND_DEATH 10529 - -#define ENTRY_VOID_PORTAL 19224 -#define ENTRY_VOID_TRAVELER 19226 - -#define LOCX -253.06f -#define LOCY -264.02f -#define LOCZ 17.08 - -struct MANGOS_DLL_DECL boss_grandmaster_vorpilAI : public ScriptedAI -{ - boss_grandmaster_vorpilAI(Creature *c) : ScriptedAI(c) - { - pInstance = ((ScriptedInstance*)c->GetInstanceData()); - Reset(); - } - - ScriptedInstance* pInstance; - bool HeroicMode; - - uint32 ShadowBoltVolley_Timer; - uint32 DrawShadows_Timer; - uint32 Teleport_Timer; - uint32 VoidTraveler_Timer; - uint32 Banish_Timer; - bool Intro; - bool Teleport; - - void Reset() - { - HeroicMode = m_creature->GetMap()->IsHeroic(); - - ShadowBoltVolley_Timer = 15000; - DrawShadows_Timer = 40000; - Teleport_Timer = 1000; - VoidTraveler_Timer = 20000; - Banish_Timer = 25000; - Intro = false; - Teleport = false; - - if( pInstance ) - pInstance->SetData(DATA_GRANDMASTERVORPILEVENT, NOT_STARTED); - } - - void MoveInLineOfSight(Unit *who) - { - if( !m_creature->getVictim() && who->isTargetableForAttack() && ( m_creature->IsHostileTo( who )) && who->isInAccessablePlaceFor(m_creature) ) - { - //not sure about right radius - if(!Intro && m_creature->IsWithinDistInMap(who, 50)) - { - DoYell(SAY_INTRO, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_INTRO); - DoCast(m_creature, SPELL_VOID_PORTAL_A,true); - m_creature->SummonCreature(ENTRY_VOID_PORTAL,-262.40,-229.57,17.08,0,TEMPSUMMON_CORPSE_DESPAWN,0); - m_creature->SummonCreature(ENTRY_VOID_PORTAL,-260.35,-297.56,17.08,0,TEMPSUMMON_CORPSE_DESPAWN,0); - m_creature->SummonCreature(ENTRY_VOID_PORTAL,-292.05,-270.37,12.68,0,TEMPSUMMON_CORPSE_DESPAWN,0); - m_creature->SummonCreature(ENTRY_VOID_PORTAL,-301.64,-255.97,12.68,0,TEMPSUMMON_CORPSE_DESPAWN,0); - Intro = true; - } - - if (m_creature->GetDistanceZ(who) > CREATURE_Z_ATTACK_RANGE) - return; - - float attackRadius = m_creature->GetAttackDistance(who); - if( m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->IsWithinLOSInMap(who) ) - { - DoStartAttackAndMovement(who); - who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); - - if (!InCombat) - { - Aggro(who); - InCombat = true; - } - } - } - } - - void Aggro(Unit *who) - { - switch(rand()%3) - { - case 0: - DoYell(SAY_AGGRO1, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_AGGRO1); - break; - case 1: - DoYell(SAY_AGGRO2, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_AGGRO2); - break; - case 2: - DoYell(SAY_AGGRO3, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_AGGRO3); - break; - } - - if( pInstance ) - pInstance->SetData(DATA_GRANDMASTERVORPILEVENT, IN_PROGRESS); - } - - void KilledUnit(Unit *victim) - { - switch(rand()%2) - { - case 0: - DoYell(SAY_SLAY1, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_SLAY1); - break; - case 1: - DoYell(SAY_SLAY2, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_SLAY2); - break; - } - } - - void JustSummoned(Creature *summoned) - { - if( summoned->GetEntry() == ENTRY_VOID_TRAVELER ) - { - summoned->GetMotionMaster()->MoveChase(m_creature); - summoned->SetSpeed(MOVE_WALK,0.8,true); - } - - if( summoned->GetEntry() == ENTRY_VOID_PORTAL ) - summoned->CastSpell(summoned,SPELL_VOID_PORTAL_VISUAL,true); - } - - void JustDied(Unit *victim) - { - DoYell(SAY_DEATH, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_DEATH); - - if( pInstance ) - pInstance->SetData(DATA_GRANDMASTERVORPILEVENT, DONE); - } - - void UpdateAI(const uint32 diff) - { - //Return since we have no target - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - if( Teleport ) - { - if( Teleport_Timer <= diff ) - { - m_creature->Relocate(LOCX,LOCY,LOCZ); - m_creature->SendMonsterMove(LOCX,LOCY,LOCZ,0,true,0); - - float ranX = LOCX; - float ranY = LOCY; - float ranZ = LOCZ; - - std::list t_list = m_creature->getThreatManager().getThreatList(); - for( std::list::iterator itr = t_list.begin(); itr!= t_list.end(); ++itr ) - { - Unit* target = Unit::GetUnit(*m_creature, (*itr)->getUnitGuid()); - if( target && target->GetTypeId() == TYPEID_PLAYER ) - { - target->GetRandomPoint(LOCX,LOCY,LOCZ,3.0,ranX,ranY,ranZ); - DoTeleportPlayer(target,ranX,ranY,ranZ,m_creature->GetAngle(m_creature->GetPositionX(),m_creature->GetPositionY())); - } - } - Teleport = false; - - if( HeroicMode ) DoCast(m_creature->getVictim(), H_SPELL_RAIN_OF_FIRE); - else DoCast(m_creature->getVictim(), SPELL_RAIN_OF_FIRE); - - Teleport_Timer = 1000; - }else Teleport_Timer -= diff; - } - - if( ShadowBoltVolley_Timer < diff ) - { - DoCast(m_creature->getVictim(), SPELL_SHADOW_BOLT_VOLLEY); - ShadowBoltVolley_Timer = 30000; - }else ShadowBoltVolley_Timer -= diff; - - if( DrawShadows_Timer < diff ) - { - DoCast(m_creature,SPELL_DRAW_SHADOWS); - DrawShadows_Timer = 35000; - Teleport = true; - }else DrawShadows_Timer -= diff; - - if( VoidTraveler_Timer < diff ) - { - DoYell(SAY_HELP, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_HELP); - - switch(rand()%5) - { - case 0: - DoCast(m_creature,SPELL_SUMMON_VOIDWALKER_A,true); - break; - case 1: - DoCast(m_creature,SPELL_SUMMON_VOIDWALKER_B,true); - break; - case 2: - DoCast(m_creature,SPELL_SUMMON_VOIDWALKER_C,true); - break; - case 3: - DoCast(m_creature,SPELL_SUMMON_VOIDWALKER_D,true); - break; - case 4: - DoCast(m_creature,SPELL_SUMMON_VOIDWALKER_E,true); - break; - } - //faster rate when below (X) health? - VoidTraveler_Timer = 35000; - }else VoidTraveler_Timer -= diff; - - if( HeroicMode ) - { - if( Banish_Timer < diff ) - { - if( Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 1) ) - DoCast(target,H_SPELL_BANISH); - Banish_Timer = 35000; - }else Banish_Timer -= diff; - } - - DoMeleeAttackIfReady(); - } -}; -CreatureAI* GetAI_boss_grandmaster_vorpil(Creature *_Creature) -{ - return new boss_grandmaster_vorpilAI (_Creature); -} - -void AddSC_boss_grandmaster_vorpil() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_grandmaster_vorpil"; - newscript->GetAI = GetAI_boss_grandmaster_vorpil; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Grandmaster_Vorpil +SD%Complete: 75 +SDComment: Despawn all summoned on death not implemented. Void Traveler effects not implemented. +SDCategory: Auchindoun, Shadow Labyrinth +EndScriptData */ + +#include "precompiled.h" +#include "def_shadow_labyrinth.h" + +#define SPELL_DRAW_SHADOWS 33563 +#define SPELL_VOID_PORTAL_A 33566 //spell only summon one unit, but we use it for the visual effect and summon the 4 other portals manual way(only one spell exist) +#define SPELL_VOID_PORTAL_VISUAL 33569 +#define SPELL_SHADOW_BOLT_VOLLEY 32963 +#define SPELL_SUMMON_VOIDWALKER_A 33582 +#define SPELL_SUMMON_VOIDWALKER_B 33583 +#define SPELL_SUMMON_VOIDWALKER_C 33584 +#define SPELL_SUMMON_VOIDWALKER_D 33585 +#define SPELL_SUMMON_VOIDWALKER_E 33586 +#define SPELL_RAIN_OF_FIRE 33617 +#define H_SPELL_RAIN_OF_FIRE 39363 +#define H_SPELL_BANISH 38791 + +#define SAY_INTRO "Keep your minds focused for the days of reckoning are close at hand. Soon, the destroyer of worlds will return to make good on his promise. Soon the destruction of all that is will begin!" +#define SAY_AGGRO1 "I'll make an offering of your blood!" +#define SAY_AGGRO2 "You'll be a fine example, for the others." +#define SAY_AGGRO3 "Good, a worthy sacrifice." +#define SAY_HELP "Come to my aid, heed your master now!" +#define SAY_SLAY1 "I serve with pride." +#define SAY_SLAY2 "Your death is for the greater cause!" +#define SAY_DEATH "I give my life... Gladly." + +#define SOUND_INTRO 10522 +#define SOUND_AGGRO1 10524 +#define SOUND_AGGRO2 10525 +#define SOUND_AGGRO3 10526 +#define SOUND_HELP 10523 +#define SOUND_SLAY1 10527 +#define SOUND_SLAY2 10528 +#define SOUND_DEATH 10529 + +#define ENTRY_VOID_PORTAL 19224 +#define ENTRY_VOID_TRAVELER 19226 + +#define LOCX -253.06f +#define LOCY -264.02f +#define LOCZ 17.08 + +struct MANGOS_DLL_DECL boss_grandmaster_vorpilAI : public ScriptedAI +{ + boss_grandmaster_vorpilAI(Creature *c) : ScriptedAI(c) + { + pInstance = ((ScriptedInstance*)c->GetInstanceData()); + Reset(); + } + + ScriptedInstance* pInstance; + bool HeroicMode; + + uint32 ShadowBoltVolley_Timer; + uint32 DrawShadows_Timer; + uint32 Teleport_Timer; + uint32 VoidTraveler_Timer; + uint32 Banish_Timer; + bool Intro; + bool Teleport; + + void Reset() + { + HeroicMode = m_creature->GetMap()->IsHeroic(); + + ShadowBoltVolley_Timer = 15000; + DrawShadows_Timer = 40000; + Teleport_Timer = 1000; + VoidTraveler_Timer = 20000; + Banish_Timer = 25000; + Intro = false; + Teleport = false; + + if( pInstance ) + pInstance->SetData(DATA_GRANDMASTERVORPILEVENT, NOT_STARTED); + } + + void MoveInLineOfSight(Unit *who) + { + if( !m_creature->getVictim() && who->isTargetableForAttack() && ( m_creature->IsHostileTo( who )) && who->isInAccessablePlaceFor(m_creature) ) + { + //not sure about right radius + if(!Intro && m_creature->IsWithinDistInMap(who, 50)) + { + DoYell(SAY_INTRO, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_INTRO); + DoCast(m_creature, SPELL_VOID_PORTAL_A,true); + m_creature->SummonCreature(ENTRY_VOID_PORTAL,-262.40,-229.57,17.08,0,TEMPSUMMON_CORPSE_DESPAWN,0); + m_creature->SummonCreature(ENTRY_VOID_PORTAL,-260.35,-297.56,17.08,0,TEMPSUMMON_CORPSE_DESPAWN,0); + m_creature->SummonCreature(ENTRY_VOID_PORTAL,-292.05,-270.37,12.68,0,TEMPSUMMON_CORPSE_DESPAWN,0); + m_creature->SummonCreature(ENTRY_VOID_PORTAL,-301.64,-255.97,12.68,0,TEMPSUMMON_CORPSE_DESPAWN,0); + Intro = true; + } + + if (!m_creature->canFly() && m_creature->GetDistanceZ(who) > CREATURE_Z_ATTACK_RANGE) + return; + + float attackRadius = m_creature->GetAttackDistance(who); + if( m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->IsWithinLOSInMap(who) ) + { + DoStartAttackAndMovement(who); + who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); + + if (!InCombat) + { + Aggro(who); + InCombat = true; + } + } + } + } + + void Aggro(Unit *who) + { + switch(rand()%3) + { + case 0: + DoYell(SAY_AGGRO1, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_AGGRO1); + break; + case 1: + DoYell(SAY_AGGRO2, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_AGGRO2); + break; + case 2: + DoYell(SAY_AGGRO3, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_AGGRO3); + break; + } + + if( pInstance ) + pInstance->SetData(DATA_GRANDMASTERVORPILEVENT, IN_PROGRESS); + } + + void KilledUnit(Unit *victim) + { + switch(rand()%2) + { + case 0: + DoYell(SAY_SLAY1, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_SLAY1); + break; + case 1: + DoYell(SAY_SLAY2, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_SLAY2); + break; + } + } + + void JustSummoned(Creature *summoned) + { + if( summoned->GetEntry() == ENTRY_VOID_TRAVELER ) + { + summoned->GetMotionMaster()->MoveChase(m_creature); + summoned->SetSpeed(MOVE_WALK,0.8,true); + } + + if( summoned->GetEntry() == ENTRY_VOID_PORTAL ) + summoned->CastSpell(summoned,SPELL_VOID_PORTAL_VISUAL,true); + } + + void JustDied(Unit *victim) + { + DoYell(SAY_DEATH, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_DEATH); + + if( pInstance ) + pInstance->SetData(DATA_GRANDMASTERVORPILEVENT, DONE); + } + + void UpdateAI(const uint32 diff) + { + //Return since we have no target + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + if( Teleport ) + { + if( Teleport_Timer <= diff ) + { + m_creature->Relocate(LOCX,LOCY,LOCZ); + m_creature->SendMonsterMove(LOCX,LOCY,LOCZ,0,true,0); + + float ranX = LOCX; + float ranY = LOCY; + float ranZ = LOCZ; + + std::list t_list = m_creature->getThreatManager().getThreatList(); + for( std::list::iterator itr = t_list.begin(); itr!= t_list.end(); ++itr ) + { + Unit* target = Unit::GetUnit(*m_creature, (*itr)->getUnitGuid()); + if( target && target->GetTypeId() == TYPEID_PLAYER ) + { + target->GetRandomPoint(LOCX,LOCY,LOCZ,3.0,ranX,ranY,ranZ); + DoTeleportPlayer(target,ranX,ranY,ranZ,m_creature->GetAngle(m_creature->GetPositionX(),m_creature->GetPositionY())); + } + } + Teleport = false; + + if( HeroicMode ) DoCast(m_creature->getVictim(), H_SPELL_RAIN_OF_FIRE); + else DoCast(m_creature->getVictim(), SPELL_RAIN_OF_FIRE); + + Teleport_Timer = 1000; + }else Teleport_Timer -= diff; + } + + if( ShadowBoltVolley_Timer < diff ) + { + DoCast(m_creature->getVictim(), SPELL_SHADOW_BOLT_VOLLEY); + ShadowBoltVolley_Timer = 30000; + }else ShadowBoltVolley_Timer -= diff; + + if( DrawShadows_Timer < diff ) + { + DoCast(m_creature,SPELL_DRAW_SHADOWS); + DrawShadows_Timer = 35000; + Teleport = true; + }else DrawShadows_Timer -= diff; + + if( VoidTraveler_Timer < diff ) + { + DoYell(SAY_HELP, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_HELP); + + switch(rand()%5) + { + case 0: + DoCast(m_creature,SPELL_SUMMON_VOIDWALKER_A,true); + break; + case 1: + DoCast(m_creature,SPELL_SUMMON_VOIDWALKER_B,true); + break; + case 2: + DoCast(m_creature,SPELL_SUMMON_VOIDWALKER_C,true); + break; + case 3: + DoCast(m_creature,SPELL_SUMMON_VOIDWALKER_D,true); + break; + case 4: + DoCast(m_creature,SPELL_SUMMON_VOIDWALKER_E,true); + break; + } + //faster rate when below (X) health? + VoidTraveler_Timer = 35000; + }else VoidTraveler_Timer -= diff; + + if( HeroicMode ) + { + if( Banish_Timer < diff ) + { + if( Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 1) ) + DoCast(target,H_SPELL_BANISH); + Banish_Timer = 35000; + }else Banish_Timer -= diff; + } + + DoMeleeAttackIfReady(); + } +}; +CreatureAI* GetAI_boss_grandmaster_vorpil(Creature *_Creature) +{ + return new boss_grandmaster_vorpilAI (_Creature); +} + +void AddSC_boss_grandmaster_vorpil() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_grandmaster_vorpil"; + newscript->GetAI = GetAI_boss_grandmaster_vorpil; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/aunchindoun/shadow_labyrinth/boss_murmur.cpp b/src/bindings/scripts/scripts/zone/aunchindoun/shadow_labyrinth/boss_murmur.cpp index 81aa6ee170d..9be5fbfdc99 100644 --- a/src/bindings/scripts/scripts/zone/aunchindoun/shadow_labyrinth/boss_murmur.cpp +++ b/src/bindings/scripts/scripts/zone/aunchindoun/shadow_labyrinth/boss_murmur.cpp @@ -1,192 +1,192 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Murmur -SD%Complete: 75 -SDComment: Database should have `RegenHealth`=0 to prevent regen. Also, his shockwave triggered after magnetic pull may be incorrect. Murmur's Touch does not work properly. -SDCategory: Auchindoun, Shadow Labyrinth -EndScriptData */ - -#include "precompiled.h" - -#define EMOTE_SONIC_BOOM "draws energy from the air." - -#define SPELL_MAGNETIC_PULL 33689 -#define SPELL_SONIC_BOOM_PRE 33923 -#define SPELL_SONIC_BOOM_CAST 38795 -#define SPELL_MURMURS_TOUCH 33711 -#define SPELL_RESONANCE 33657 -#define SPELL_SHOCKWAVE 33686 - -struct MANGOS_DLL_DECL boss_murmurAI : public ScriptedAI -{ - boss_murmurAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 SonicBoom_Timer; - uint32 MurmursTouch_Timer; - uint32 Resonance_Timer; - uint32 MagneticPull_Timer; - bool CanSonicBoom; - bool CanShockWave; - uint64 pTarget; - - void Reset() - { - SonicBoom_Timer = 30000; - MurmursTouch_Timer = 20000; - Resonance_Timer = 10000; - MagneticPull_Timer = 45000; - CanSonicBoom = false; - CanShockWave = false; - pTarget = 0; - - //database should have `RegenHealth`=0 to prevent regen - uint32 hp = m_creature->GetMaxHealth()*0.4; - if( hp ) - m_creature->SetHealth(hp); - } - - void Aggro(Unit *who) { } - - void AttackStart(Unit* who) - { - if (!who) - return; - - if (who->isTargetableForAttack()) - { - //Begin attack - DoStartAttackNoMovement(who); - - if (!InCombat) - { - Aggro(who); - InCombat = true; - } - } - } - - void MoveInLineOfSight(Unit* who) - { - if( !m_creature->getVictim() && who->isTargetableForAttack() && ( m_creature->IsHostileTo( who )) && who->isInAccessablePlaceFor(m_creature) ) - { - if (m_creature->GetDistanceZ(who) > CREATURE_Z_ATTACK_RANGE) - return; - - float attackRadius = m_creature->GetAttackDistance(who); - if(m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->IsWithinLOSInMap(who)) - { - DoStartAttackNoMovement(who); - who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); - - if (!InCombat) - { - Aggro(who); - InCombat = true; - } - } - } - } - - void UpdateAI(const uint32 diff) - { - //Return since we have no target - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - //SonicBoom_Timer - if(SonicBoom_Timer < diff) - { - if(CanSonicBoom) - { - DoCast(m_creature, SPELL_SONIC_BOOM_CAST,true); - CanSonicBoom = false; - SonicBoom_Timer = 30000; - } - else - { - DoTextEmote(EMOTE_SONIC_BOOM,NULL); - DoCast(m_creature,SPELL_SONIC_BOOM_PRE); - CanSonicBoom = true; - SonicBoom_Timer = 5000; - } - }else SonicBoom_Timer -= diff; - - //MurmursTouch_Timer - if(MurmursTouch_Timer < diff) - { - /*Unit* target = NULL; - target = SelectUnit(SELECT_TARGET_RANDOM,0); - if(target) - DoCast(target, SPELL_MURMURS_TOUCH);*/ - DoCast(m_creature, SPELL_MURMURS_TOUCH); - MurmursTouch_Timer = 30000; - }else MurmursTouch_Timer -= diff; - - //Resonance_Timer - if(Resonance_Timer < diff) - { - if( !m_creature->IsWithinDistInMap(m_creature->getVictim(), ATTACK_DISTANCE) ) - DoCast(m_creature->getVictim(), SPELL_RESONANCE); - Resonance_Timer = 5000; - }else Resonance_Timer -= diff; - - //MagneticPull_Timer - if(MagneticPull_Timer < diff) - { - if( !CanShockWave ) - { - if( Unit* temp = SelectUnit(SELECT_TARGET_RANDOM,0) ) - { - if( temp->GetTypeId() == TYPEID_PLAYER ) - { - DoCast(temp, SPELL_MAGNETIC_PULL); - pTarget = temp->GetGUID(); - CanShockWave = true; - } - MagneticPull_Timer = 2500; - } - } - else - { - if( Unit* target = Unit::GetUnit(*m_creature,pTarget) ) - target->CastSpell(target,SPELL_SHOCKWAVE,true); - - MagneticPull_Timer = 35000; - CanShockWave = false; - pTarget = 0; - } - }else MagneticPull_Timer -= diff; - - //no meele if preparing for sonic boom - if(!CanSonicBoom) - DoMeleeAttackIfReady(); - } -}; -CreatureAI* GetAI_boss_murmur(Creature *_Creature) -{ - return new boss_murmurAI (_Creature); -} - -void AddSC_boss_murmur() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_murmur"; - newscript->GetAI = GetAI_boss_murmur; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Murmur +SD%Complete: 75 +SDComment: Database should have `RegenHealth`=0 to prevent regen. Also, his shockwave triggered after magnetic pull may be incorrect. Murmur's Touch does not work properly. +SDCategory: Auchindoun, Shadow Labyrinth +EndScriptData */ + +#include "precompiled.h" + +#define EMOTE_SONIC_BOOM "draws energy from the air." + +#define SPELL_MAGNETIC_PULL 33689 +#define SPELL_SONIC_BOOM_PRE 33923 +#define SPELL_SONIC_BOOM_CAST 38795 +#define SPELL_MURMURS_TOUCH 33711 +#define SPELL_RESONANCE 33657 +#define SPELL_SHOCKWAVE 33686 + +struct MANGOS_DLL_DECL boss_murmurAI : public ScriptedAI +{ + boss_murmurAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 SonicBoom_Timer; + uint32 MurmursTouch_Timer; + uint32 Resonance_Timer; + uint32 MagneticPull_Timer; + bool CanSonicBoom; + bool CanShockWave; + uint64 pTarget; + + void Reset() + { + SonicBoom_Timer = 30000; + MurmursTouch_Timer = 20000; + Resonance_Timer = 10000; + MagneticPull_Timer = 45000; + CanSonicBoom = false; + CanShockWave = false; + pTarget = 0; + + //database should have `RegenHealth`=0 to prevent regen + uint32 hp = m_creature->GetMaxHealth()*0.4; + if( hp ) + m_creature->SetHealth(hp); + } + + void Aggro(Unit *who) { } + + void AttackStart(Unit* who) + { + if (!who) + return; + + if (who->isTargetableForAttack()) + { + //Begin attack + DoStartAttackNoMovement(who); + + if (!InCombat) + { + Aggro(who); + InCombat = true; + } + } + } + + void MoveInLineOfSight(Unit* who) + { + if( !m_creature->getVictim() && who->isTargetableForAttack() && ( m_creature->IsHostileTo( who )) && who->isInAccessablePlaceFor(m_creature) ) + { + if (!m_creature->canFly() && m_creature->GetDistanceZ(who) > CREATURE_Z_ATTACK_RANGE) + return; + + float attackRadius = m_creature->GetAttackDistance(who); + if(m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->IsWithinLOSInMap(who)) + { + DoStartAttackNoMovement(who); + who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); + + if (!InCombat) + { + Aggro(who); + InCombat = true; + } + } + } + } + + void UpdateAI(const uint32 diff) + { + //Return since we have no target + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + //SonicBoom_Timer + if(SonicBoom_Timer < diff) + { + if(CanSonicBoom) + { + DoCast(m_creature, SPELL_SONIC_BOOM_CAST,true); + CanSonicBoom = false; + SonicBoom_Timer = 30000; + } + else + { + DoTextEmote(EMOTE_SONIC_BOOM,NULL); + DoCast(m_creature,SPELL_SONIC_BOOM_PRE); + CanSonicBoom = true; + SonicBoom_Timer = 5000; + } + }else SonicBoom_Timer -= diff; + + //MurmursTouch_Timer + if(MurmursTouch_Timer < diff) + { + /*Unit* target = NULL; + target = SelectUnit(SELECT_TARGET_RANDOM,0); + if(target) + DoCast(target, SPELL_MURMURS_TOUCH);*/ + DoCast(m_creature, SPELL_MURMURS_TOUCH); + MurmursTouch_Timer = 30000; + }else MurmursTouch_Timer -= diff; + + //Resonance_Timer + if(Resonance_Timer < diff) + { + if( !m_creature->IsWithinDistInMap(m_creature->getVictim(), ATTACK_DISTANCE) ) + DoCast(m_creature->getVictim(), SPELL_RESONANCE); + Resonance_Timer = 5000; + }else Resonance_Timer -= diff; + + //MagneticPull_Timer + if(MagneticPull_Timer < diff) + { + if( !CanShockWave ) + { + if( Unit* temp = SelectUnit(SELECT_TARGET_RANDOM,0) ) + { + if( temp->GetTypeId() == TYPEID_PLAYER ) + { + DoCast(temp, SPELL_MAGNETIC_PULL); + pTarget = temp->GetGUID(); + CanShockWave = true; + } + MagneticPull_Timer = 2500; + } + } + else + { + if( Unit* target = Unit::GetUnit(*m_creature,pTarget) ) + target->CastSpell(target,SPELL_SHOCKWAVE,true); + + MagneticPull_Timer = 35000; + CanShockWave = false; + pTarget = 0; + } + }else MagneticPull_Timer -= diff; + + //no meele if preparing for sonic boom + if(!CanSonicBoom) + DoMeleeAttackIfReady(); + } +}; +CreatureAI* GetAI_boss_murmur(Creature *_Creature) +{ + return new boss_murmurAI (_Creature); +} + +void AddSC_boss_murmur() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_murmur"; + newscript->GetAI = GetAI_boss_murmur; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/aunchindoun/shadow_labyrinth/def_shadow_labyrinth.h b/src/bindings/scripts/scripts/zone/aunchindoun/shadow_labyrinth/def_shadow_labyrinth.h index 77b0387af16..1300c926c7d 100644 --- a/src/bindings/scripts/scripts/zone/aunchindoun/shadow_labyrinth/def_shadow_labyrinth.h +++ b/src/bindings/scripts/scripts/zone/aunchindoun/shadow_labyrinth/def_shadow_labyrinth.h @@ -1,13 +1,13 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software licensed under GPL version 2 - * Please see the included DOCS/LICENSE.TXT for more information */ - -#ifndef DEF_SHADOW_LABYRINTH_H -#define DEF_SHADOW_LABYRINTH_H - -#define TYPE_HELLMAW 1 -#define TYPE_OVERSEER 2 -#define DATA_BLACKHEARTTHEINCITEREVENT 3 -#define DATA_GRANDMASTERVORPILEVENT 4 -#define DATA_MURMUREVENT 5 -#endif +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software licensed under GPL version 2 + * Please see the included DOCS/LICENSE.TXT for more information */ + +#ifndef DEF_SHADOW_LABYRINTH_H +#define DEF_SHADOW_LABYRINTH_H + +#define TYPE_HELLMAW 1 +#define TYPE_OVERSEER 2 +#define DATA_BLACKHEARTTHEINCITEREVENT 3 +#define DATA_GRANDMASTERVORPILEVENT 4 +#define DATA_MURMUREVENT 5 +#endif diff --git a/src/bindings/scripts/scripts/zone/aunchindoun/shadow_labyrinth/instance_shadow_labyrinth.cpp b/src/bindings/scripts/scripts/zone/aunchindoun/shadow_labyrinth/instance_shadow_labyrinth.cpp index ea2c141b2e0..86a0ef45c88 100644 --- a/src/bindings/scripts/scripts/zone/aunchindoun/shadow_labyrinth/instance_shadow_labyrinth.cpp +++ b/src/bindings/scripts/scripts/zone/aunchindoun/shadow_labyrinth/instance_shadow_labyrinth.cpp @@ -1,168 +1,168 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Instance_Shadow_Labyrinth -SD%Complete: 85 -SDComment: Some cleanup left along with save -SDCategory: Auchindoun, Shadow Labyrinth -EndScriptData */ - -#include "precompiled.h" -#include "def_shadow_labyrinth.h" - -#define ENCOUNTERS 5 - -#define REFECTORY_DOOR 183296 //door opened when blackheart the inciter dies -#define SCREAMING_HALL_DOOR 183295 //door opened when grandmaster vorpil dies - -/* Shadow Labyrinth encounters: -1 - Ambassador Hellmaw event -2 - Blackheart the Inciter event -3 - Grandmaster Vorpil event -4 - Murmur event -*/ - -struct MANGOS_DLL_DECL instance_shadow_labyrinth : public ScriptedInstance -{ - instance_shadow_labyrinth(Map *Map) : ScriptedInstance(Map) {Initialize();}; - - uint32 Encounter[ENCOUNTERS]; - - GameObject *RefectoryDoor; - GameObject *ScreamingHallDoor; - uint64 GrandmasterVorpil; - uint32 FelOverseerCount; - - void Initialize() - { - RefectoryDoor = NULL; - ScreamingHallDoor = NULL; - GrandmasterVorpil = 0; - FelOverseerCount = 0; - - for(uint8 i = 0; i < ENCOUNTERS; i++) - Encounter[i] = false; - } - - bool IsEncounterInProgress() const - { - for(uint8 i = 0; i < ENCOUNTERS; i++) - if(Encounter[i]) return true; - - return false; - } - - void OnObjectCreate(GameObject *go) - { - switch(go->GetEntry()) - { - case REFECTORY_DOOR: - RefectoryDoor = go; - break; - case SCREAMING_HALL_DOOR: - ScreamingHallDoor = go; - break; - } - } - - void OnCreatureCreate(Creature *creature, uint32 creature_entry) - { - switch(creature_entry) - { - case 18732: - GrandmasterVorpil = creature->GetGUID(); - break; - case 18796: - ++FelOverseerCount; - debug_log("SD2: Shadow Labyrinth: counting %u Fel Overseers.",FelOverseerCount); - break; - } - } - - void SetData(uint32 type, uint32 data) - { - switch(type) - { - case TYPE_HELLMAW: - Encounter[0] = data; - break; - - case TYPE_OVERSEER: - if( data != DONE ) - error_log("SD2: Shadow Labyrinth: TYPE_OVERSEER did not expect other data than DONE"); - if( FelOverseerCount ) - { - --FelOverseerCount; - debug_log("SD2: Shadow Labyrinth: %u Fel Overseers left to kill.",FelOverseerCount); - } - if( FelOverseerCount == 0 ) - { - Encounter[1] = DONE; - debug_log("SD2: Shadow Labyrinth: TYPE_OVERSEER == DONE"); - } - break; - - case DATA_BLACKHEARTTHEINCITEREVENT: - if( data == DONE ) - { - if( RefectoryDoor ) - RefectoryDoor->UseDoorOrButton(); - } - Encounter[2] = data; - break; - - case DATA_GRANDMASTERVORPILEVENT: - if( data == DONE ) - { - if( ScreamingHallDoor ) - ScreamingHallDoor->UseDoorOrButton(); - } - Encounter[3] = data; - break; - - case DATA_MURMUREVENT: - Encounter[4] = data; - break; - } - } - - uint32 GetData(uint32 type) - { - switch( type ) - { - case TYPE_HELLMAW: - return Encounter[0]; - case TYPE_OVERSEER: - return Encounter[1]; - } - return false; - } -}; - -InstanceData* GetInstanceData_instance_shadow_labyrinth(Map* map) -{ - return new instance_shadow_labyrinth(map); -} - -void AddSC_instance_shadow_labyrinth() -{ - Script *newscript; - newscript = new Script; - newscript->Name = "instance_shadow_labyrinth"; - newscript->GetInstanceData = GetInstanceData_instance_shadow_labyrinth; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Instance_Shadow_Labyrinth +SD%Complete: 85 +SDComment: Some cleanup left along with save +SDCategory: Auchindoun, Shadow Labyrinth +EndScriptData */ + +#include "precompiled.h" +#include "def_shadow_labyrinth.h" + +#define ENCOUNTERS 5 + +#define REFECTORY_DOOR 183296 //door opened when blackheart the inciter dies +#define SCREAMING_HALL_DOOR 183295 //door opened when grandmaster vorpil dies + +/* Shadow Labyrinth encounters: +1 - Ambassador Hellmaw event +2 - Blackheart the Inciter event +3 - Grandmaster Vorpil event +4 - Murmur event +*/ + +struct MANGOS_DLL_DECL instance_shadow_labyrinth : public ScriptedInstance +{ + instance_shadow_labyrinth(Map *Map) : ScriptedInstance(Map) {Initialize();}; + + uint32 Encounter[ENCOUNTERS]; + + GameObject *RefectoryDoor; + GameObject *ScreamingHallDoor; + uint64 GrandmasterVorpil; + uint32 FelOverseerCount; + + void Initialize() + { + RefectoryDoor = NULL; + ScreamingHallDoor = NULL; + GrandmasterVorpil = 0; + FelOverseerCount = 0; + + for(uint8 i = 0; i < ENCOUNTERS; i++) + Encounter[i] = false; + } + + bool IsEncounterInProgress() const + { + for(uint8 i = 0; i < ENCOUNTERS; i++) + if(Encounter[i]) return true; + + return false; + } + + void OnObjectCreate(GameObject *go) + { + switch(go->GetEntry()) + { + case REFECTORY_DOOR: + RefectoryDoor = go; + break; + case SCREAMING_HALL_DOOR: + ScreamingHallDoor = go; + break; + } + } + + void OnCreatureCreate(Creature *creature, uint32 creature_entry) + { + switch(creature_entry) + { + case 18732: + GrandmasterVorpil = creature->GetGUID(); + break; + case 18796: + ++FelOverseerCount; + debug_log("SD2: Shadow Labyrinth: counting %u Fel Overseers.",FelOverseerCount); + break; + } + } + + void SetData(uint32 type, uint32 data) + { + switch(type) + { + case TYPE_HELLMAW: + Encounter[0] = data; + break; + + case TYPE_OVERSEER: + if( data != DONE ) + error_log("SD2: Shadow Labyrinth: TYPE_OVERSEER did not expect other data than DONE"); + if( FelOverseerCount ) + { + --FelOverseerCount; + debug_log("SD2: Shadow Labyrinth: %u Fel Overseers left to kill.",FelOverseerCount); + } + if( FelOverseerCount == 0 ) + { + Encounter[1] = DONE; + debug_log("SD2: Shadow Labyrinth: TYPE_OVERSEER == DONE"); + } + break; + + case DATA_BLACKHEARTTHEINCITEREVENT: + if( data == DONE ) + { + if( RefectoryDoor ) + RefectoryDoor->UseDoorOrButton(); + } + Encounter[2] = data; + break; + + case DATA_GRANDMASTERVORPILEVENT: + if( data == DONE ) + { + if( ScreamingHallDoor ) + ScreamingHallDoor->UseDoorOrButton(); + } + Encounter[3] = data; + break; + + case DATA_MURMUREVENT: + Encounter[4] = data; + break; + } + } + + uint32 GetData(uint32 type) + { + switch( type ) + { + case TYPE_HELLMAW: + return Encounter[0]; + case TYPE_OVERSEER: + return Encounter[1]; + } + return false; + } +}; + +InstanceData* GetInstanceData_instance_shadow_labyrinth(Map* map) +{ + return new instance_shadow_labyrinth(map); +} + +void AddSC_instance_shadow_labyrinth() +{ + Script *newscript; + newscript = new Script; + newscript->Name = "instance_shadow_labyrinth"; + newscript->GetInstanceData = GetInstanceData_instance_shadow_labyrinth; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/azshara/azshara.cpp b/src/bindings/scripts/scripts/zone/azshara/azshara.cpp index c892847bbc8..0f08d3d7592 100644 --- a/src/bindings/scripts/scripts/zone/azshara/azshara.cpp +++ b/src/bindings/scripts/scripts/zone/azshara/azshara.cpp @@ -1,164 +1,164 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Azshara -SD%Complete: 90 -SDComment: Quest support: 2744, 3141, 9364 -SDCategory: Azshara -EndScriptData */ - -/* ContentData -mobs_spitelashes -npc_loramus_thalipedes -EndContentData */ - -#include "precompiled.h" - -/*###### -## mobs_spitelashes -######*/ - -struct MANGOS_DLL_DECL mobs_spitelashesAI : public ScriptedAI -{ - mobs_spitelashesAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 morphtimer; - bool spellhit; - - void Reset() - { - morphtimer = 0; - spellhit = false; - } - - void Aggro(Unit *who) { } - - void SpellHit(Unit *Hitter, const SpellEntry *Spellkind) - { - if( !spellhit && - Hitter->GetTypeId() == TYPEID_PLAYER && - ((Player*)Hitter)->GetQuestStatus(9364) == QUEST_STATUS_INCOMPLETE && - (Spellkind->Id==118 || Spellkind->Id== 12824 || Spellkind->Id== 12825 || Spellkind->Id== 12826) ) - { - spellhit=true; - DoCast(m_creature,29124); //become a sheep - } - } - - void UpdateAI(const uint32 diff) - { - // we mustn't remove the creature in the same round in which we cast the summon spell, otherwise there will be no summons - if( spellhit && morphtimer>=5000 ) - { - m_creature->DealDamage(m_creature, m_creature->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); - m_creature->RemoveCorpse(); //you don't see any corpse on off. - EnterEvadeMode(); //spellhit will be set to false - } - // walk 5 seconds before summoning - if( spellhit && morphtimer<5000 ) - { - morphtimer+=diff; - if( morphtimer>=5000 ) - { - DoCast(m_creature,28406); //summon copies - DoCast(m_creature,6924); //visual explosion - } - } - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - //TODO: add abilities for the different creatures - DoMeleeAttackIfReady(); - } -}; -CreatureAI* GetAI_mobs_spitelashes(Creature *_Creature) -{ - return new mobs_spitelashesAI (_Creature); -} - -/*###### -## npc_loramus_thalipedes -######*/ - -bool GossipHello_npc_loramus_thalipedes(Player *player, Creature *_Creature) -{ - if (_Creature->isQuestGiver()) - player->PrepareQuestMenu( _Creature->GetGUID() ); - - if (player->GetQuestStatus(2744) == QUEST_STATUS_INCOMPLETE) - player->ADD_GOSSIP_ITEM( 0, "Can you help me?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); - - if (player->GetQuestStatus(3141) == QUEST_STATUS_INCOMPLETE) - player->ADD_GOSSIP_ITEM( 0, "Tell me your story", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2); - - player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); - - return true; -} - -bool GossipSelect_npc_loramus_thalipedes(Player *player, Creature *_Creature, uint32 sender, uint32 action) -{ - switch (action) - { - case GOSSIP_ACTION_INFO_DEF+1: - player->CLOSE_GOSSIP_MENU(); - player->AreaExploredOrEventHappens(2744); - break; - - case GOSSIP_ACTION_INFO_DEF+2: - player->ADD_GOSSIP_ITEM( 0, "Please continue", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 21); - player->SEND_GOSSIP_MENU(1813, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+21: - player->ADD_GOSSIP_ITEM( 0, "I do not understand", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 22); - player->SEND_GOSSIP_MENU(1814, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+22: - player->ADD_GOSSIP_ITEM( 0, "Indeed", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 23); - player->SEND_GOSSIP_MENU(1815, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+23: - player->ADD_GOSSIP_ITEM( 0, "I will do this with or your help, Loramus", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 24); - player->SEND_GOSSIP_MENU(1816, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+24: - player->ADD_GOSSIP_ITEM( 0, "Yes", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 25); - player->SEND_GOSSIP_MENU(1817, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+25: - player->CLOSE_GOSSIP_MENU(); - player->AreaExploredOrEventHappens(3141); - break; - } - return true; -} - -void AddSC_azshara() -{ - Script *newscript; - - newscript = new Script; - newscript->Name="mobs_spitelashes"; - newscript->GetAI = GetAI_mobs_spitelashes; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="npc_loramus_thalipedes"; - newscript->pGossipHello = &GossipHello_npc_loramus_thalipedes; - newscript->pGossipSelect = &GossipSelect_npc_loramus_thalipedes; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Azshara +SD%Complete: 90 +SDComment: Quest support: 2744, 3141, 9364 +SDCategory: Azshara +EndScriptData */ + +/* ContentData +mobs_spitelashes +npc_loramus_thalipedes +EndContentData */ + +#include "precompiled.h" + +/*###### +## mobs_spitelashes +######*/ + +struct MANGOS_DLL_DECL mobs_spitelashesAI : public ScriptedAI +{ + mobs_spitelashesAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 morphtimer; + bool spellhit; + + void Reset() + { + morphtimer = 0; + spellhit = false; + } + + void Aggro(Unit *who) { } + + void SpellHit(Unit *Hitter, const SpellEntry *Spellkind) + { + if( !spellhit && + Hitter->GetTypeId() == TYPEID_PLAYER && + ((Player*)Hitter)->GetQuestStatus(9364) == QUEST_STATUS_INCOMPLETE && + (Spellkind->Id==118 || Spellkind->Id== 12824 || Spellkind->Id== 12825 || Spellkind->Id== 12826) ) + { + spellhit=true; + DoCast(m_creature,29124); //become a sheep + } + } + + void UpdateAI(const uint32 diff) + { + // we mustn't remove the creature in the same round in which we cast the summon spell, otherwise there will be no summons + if( spellhit && morphtimer>=5000 ) + { + m_creature->DealDamage(m_creature, m_creature->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); + m_creature->RemoveCorpse(); //you don't see any corpse on off. + EnterEvadeMode(); //spellhit will be set to false + } + // walk 5 seconds before summoning + if( spellhit && morphtimer<5000 ) + { + morphtimer+=diff; + if( morphtimer>=5000 ) + { + DoCast(m_creature,28406); //summon copies + DoCast(m_creature,6924); //visual explosion + } + } + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + //TODO: add abilities for the different creatures + DoMeleeAttackIfReady(); + } +}; +CreatureAI* GetAI_mobs_spitelashes(Creature *_Creature) +{ + return new mobs_spitelashesAI (_Creature); +} + +/*###### +## npc_loramus_thalipedes +######*/ + +bool GossipHello_npc_loramus_thalipedes(Player *player, Creature *_Creature) +{ + if (_Creature->isQuestGiver()) + player->PrepareQuestMenu( _Creature->GetGUID() ); + + if (player->GetQuestStatus(2744) == QUEST_STATUS_INCOMPLETE) + player->ADD_GOSSIP_ITEM( 0, "Can you help me?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); + + if (player->GetQuestStatus(3141) == QUEST_STATUS_INCOMPLETE) + player->ADD_GOSSIP_ITEM( 0, "Tell me your story", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2); + + player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); + + return true; +} + +bool GossipSelect_npc_loramus_thalipedes(Player *player, Creature *_Creature, uint32 sender, uint32 action) +{ + switch (action) + { + case GOSSIP_ACTION_INFO_DEF+1: + player->CLOSE_GOSSIP_MENU(); + player->AreaExploredOrEventHappens(2744); + break; + + case GOSSIP_ACTION_INFO_DEF+2: + player->ADD_GOSSIP_ITEM( 0, "Please continue", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 21); + player->SEND_GOSSIP_MENU(1813, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+21: + player->ADD_GOSSIP_ITEM( 0, "I do not understand", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 22); + player->SEND_GOSSIP_MENU(1814, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+22: + player->ADD_GOSSIP_ITEM( 0, "Indeed", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 23); + player->SEND_GOSSIP_MENU(1815, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+23: + player->ADD_GOSSIP_ITEM( 0, "I will do this with or your help, Loramus", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 24); + player->SEND_GOSSIP_MENU(1816, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+24: + player->ADD_GOSSIP_ITEM( 0, "Yes", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 25); + player->SEND_GOSSIP_MENU(1817, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+25: + player->CLOSE_GOSSIP_MENU(); + player->AreaExploredOrEventHappens(3141); + break; + } + return true; +} + +void AddSC_azshara() +{ + Script *newscript; + + newscript = new Script; + newscript->Name="mobs_spitelashes"; + newscript->GetAI = GetAI_mobs_spitelashes; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="npc_loramus_thalipedes"; + newscript->pGossipHello = &GossipHello_npc_loramus_thalipedes; + newscript->pGossipSelect = &GossipSelect_npc_loramus_thalipedes; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/azshara/boss_azuregos.cpp b/src/bindings/scripts/scripts/zone/azshara/boss_azuregos.cpp index 5193fd841a1..550a25a3f75 100644 --- a/src/bindings/scripts/scripts/zone/azshara/boss_azuregos.cpp +++ b/src/bindings/scripts/scripts/zone/azshara/boss_azuregos.cpp @@ -1,153 +1,153 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Azuregos -SD%Complete: 90 -SDComment: Teleport not included, spell reflect not effecting dots (Core problem) -SDCategory: Azshara -EndScriptData */ - -#include "precompiled.h" - -#define SPELL_MARKOFFROST 23182 -#define SPELL_MANASTORM 21097 -#define SPELL_CHILL 21098 -#define SPELL_FROSTBREATH 21099 -#define SPELL_REFLECT 22067 //Old one was 30969 -#define SPELL_CLEAVE 8255 //Perhaps not right ID -#define SPELL_ENRAGE 23537 - -struct MANGOS_DLL_DECL boss_azuregosAI : public ScriptedAI -{ - boss_azuregosAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 MarkOfFrost_Timer; - uint32 ManaStorm_Timer; - uint32 Chill_Timer; - uint32 Breath_Timer; - uint32 Teleport_Timer; - uint32 Reflect_Timer; - uint32 Cleave_Timer; - uint32 Enrage_Timer; - bool Enraged; - - void Reset() - { - MarkOfFrost_Timer = 35000; - ManaStorm_Timer = 5000 + rand()%12000; - Chill_Timer = 10000 + rand()%20000; - Breath_Timer = 2000 + rand()%6000; - Teleport_Timer = 30000; - Reflect_Timer = 15000 + rand()%15000; - Cleave_Timer = 7000; - Enrage_Timer = 0; - Enraged = false; - } - - void Aggro(Unit *who) {} - - void UpdateAI(const uint32 diff) - { - //Return since we have no target - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - if(Teleport_Timer < diff) - { - std::list& m_threatlist = m_creature->getThreatManager().getThreatList(); - std::list::iterator i = m_threatlist.begin(); - for (i = m_threatlist.begin(); i!= m_threatlist.end();++i) - { - Unit* pUnit = Unit::GetUnit((*m_creature), (*i)->getUnitGuid()); - if(pUnit && (pUnit->GetTypeId() == TYPEID_PLAYER)) - { - DoTeleportPlayer(pUnit, m_creature->GetPositionX(), m_creature->GetPositionY(), m_creature->GetPositionZ()+3, pUnit->GetOrientation()); - } - } - - DoResetThreat(); - Teleport_Timer = 30000; - }else Teleport_Timer -= diff; - - // //MarkOfFrost_Timer - // if (MarkOfFrost_Timer < diff) - // { - // DoCast(m_creature->getVictim(),SPELL_MARKOFFROST); - // MarkOfFrost_Timer = 25000; - // }else MarkOfFrost_Timer -= diff; - - //Chill_Timer - if (Chill_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_CHILL); - Chill_Timer = 13000 + rand()%12000; - }else Chill_Timer -= diff; - - //Breath_Timer - if (Breath_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_FROSTBREATH); - Breath_Timer = 10000 + rand()%5000; - }else Breath_Timer -= diff; - - //ManaStorm_Timer - if (ManaStorm_Timer < diff) - { - Unit* target = NULL; - target = SelectUnit(SELECT_TARGET_RANDOM,0); - if (target) - DoCast(target,SPELL_MANASTORM); - ManaStorm_Timer = 7500 + rand()%5000; - }else ManaStorm_Timer -= diff; - - //Reflect_Timer - if (Reflect_Timer < diff) - { - DoCast(m_creature,SPELL_REFLECT); - Reflect_Timer = 20000 + rand()%15000; - }else Reflect_Timer -= diff; - - //Cleave_Timer - if (Cleave_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_CLEAVE); - Cleave_Timer = 7000; - }else Cleave_Timer -= diff; - - //Enrage_Timer - if (m_creature->GetHealth()*100 / m_creature->GetMaxHealth() < 26 && !Enraged) - { - DoCast(m_creature, SPELL_ENRAGE); - Enraged = true; - } - - DoMeleeAttackIfReady(); - } -}; -CreatureAI* GetAI_boss_azuregos(Creature *_Creature) -{ - return new boss_azuregosAI (_Creature); -} - -void AddSC_boss_azuregos() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_azuregos"; - newscript->GetAI = GetAI_boss_azuregos; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Azuregos +SD%Complete: 90 +SDComment: Teleport not included, spell reflect not effecting dots (Core problem) +SDCategory: Azshara +EndScriptData */ + +#include "precompiled.h" + +#define SPELL_MARKOFFROST 23182 +#define SPELL_MANASTORM 21097 +#define SPELL_CHILL 21098 +#define SPELL_FROSTBREATH 21099 +#define SPELL_REFLECT 22067 //Old one was 30969 +#define SPELL_CLEAVE 8255 //Perhaps not right ID +#define SPELL_ENRAGE 23537 + +struct MANGOS_DLL_DECL boss_azuregosAI : public ScriptedAI +{ + boss_azuregosAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 MarkOfFrost_Timer; + uint32 ManaStorm_Timer; + uint32 Chill_Timer; + uint32 Breath_Timer; + uint32 Teleport_Timer; + uint32 Reflect_Timer; + uint32 Cleave_Timer; + uint32 Enrage_Timer; + bool Enraged; + + void Reset() + { + MarkOfFrost_Timer = 35000; + ManaStorm_Timer = 5000 + rand()%12000; + Chill_Timer = 10000 + rand()%20000; + Breath_Timer = 2000 + rand()%6000; + Teleport_Timer = 30000; + Reflect_Timer = 15000 + rand()%15000; + Cleave_Timer = 7000; + Enrage_Timer = 0; + Enraged = false; + } + + void Aggro(Unit *who) {} + + void UpdateAI(const uint32 diff) + { + //Return since we have no target + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + if(Teleport_Timer < diff) + { + std::list& m_threatlist = m_creature->getThreatManager().getThreatList(); + std::list::iterator i = m_threatlist.begin(); + for (i = m_threatlist.begin(); i!= m_threatlist.end();++i) + { + Unit* pUnit = Unit::GetUnit((*m_creature), (*i)->getUnitGuid()); + if(pUnit && (pUnit->GetTypeId() == TYPEID_PLAYER)) + { + DoTeleportPlayer(pUnit, m_creature->GetPositionX(), m_creature->GetPositionY(), m_creature->GetPositionZ()+3, pUnit->GetOrientation()); + } + } + + DoResetThreat(); + Teleport_Timer = 30000; + }else Teleport_Timer -= diff; + + // //MarkOfFrost_Timer + // if (MarkOfFrost_Timer < diff) + // { + // DoCast(m_creature->getVictim(),SPELL_MARKOFFROST); + // MarkOfFrost_Timer = 25000; + // }else MarkOfFrost_Timer -= diff; + + //Chill_Timer + if (Chill_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_CHILL); + Chill_Timer = 13000 + rand()%12000; + }else Chill_Timer -= diff; + + //Breath_Timer + if (Breath_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_FROSTBREATH); + Breath_Timer = 10000 + rand()%5000; + }else Breath_Timer -= diff; + + //ManaStorm_Timer + if (ManaStorm_Timer < diff) + { + Unit* target = NULL; + target = SelectUnit(SELECT_TARGET_RANDOM,0); + if (target) + DoCast(target,SPELL_MANASTORM); + ManaStorm_Timer = 7500 + rand()%5000; + }else ManaStorm_Timer -= diff; + + //Reflect_Timer + if (Reflect_Timer < diff) + { + DoCast(m_creature,SPELL_REFLECT); + Reflect_Timer = 20000 + rand()%15000; + }else Reflect_Timer -= diff; + + //Cleave_Timer + if (Cleave_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_CLEAVE); + Cleave_Timer = 7000; + }else Cleave_Timer -= diff; + + //Enrage_Timer + if (m_creature->GetHealth()*100 / m_creature->GetMaxHealth() < 26 && !Enraged) + { + DoCast(m_creature, SPELL_ENRAGE); + Enraged = true; + } + + DoMeleeAttackIfReady(); + } +}; +CreatureAI* GetAI_boss_azuregos(Creature *_Creature) +{ + return new boss_azuregosAI (_Creature); +} + +void AddSC_boss_azuregos() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_azuregos"; + newscript->GetAI = GetAI_boss_azuregos; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/azuremyst_isle/azuremyst_isle.cpp b/src/bindings/scripts/scripts/zone/azuremyst_isle/azuremyst_isle.cpp index f1f68ff4ee3..3ec11ef1eb0 100644 --- a/src/bindings/scripts/scripts/zone/azuremyst_isle/azuremyst_isle.cpp +++ b/src/bindings/scripts/scripts/zone/azuremyst_isle/azuremyst_isle.cpp @@ -1,372 +1,372 @@ -/* Copyright (C) 2006,2007 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Azuremyst_Isle -SD%Complete: 75 -SDComment: Quest support: 9283, 9537, 9554(special flight path, proper model for mount missing). Injured Draenei cosmetic only -SDCategory: Azuremyst Isle -EndScriptData */ - -/* ContentData -npc_draenei_survivor -npc_engineer_spark_overgrind -npc_injured_draenei -npc_susurrus -EndContentData */ - -#include "precompiled.h" -#include - -/*###### -## npc_draenei_survivor -######*/ - -#define HEAL1 "The last thing I remember is the ship falling and us getting into the pods. I'll go see how I can help. Thank you!" -#define HEAL2 "$C, Where am I? Who are you? Oh no! What happened to the ship?." -#define HEAL3 "$C You saved me! I owe you a debt that I can never repay. I'll go see if I can help the others." -#define HEAL4 "Ugh... what is this place? Is that all that's left of the ship over there?" - -#define HELP1 "Oh, the pain..." -#define HELP2 "Everything hurts, Please make it stop..." -#define HELP3 "Ughhh... I hurt. Can you help me?" -#define HELP4 "I don't know if I can make it, please help me..." - -struct MANGOS_DLL_DECL npc_draenei_survivorAI : public ScriptedAI -{ - npc_draenei_survivorAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 UnSpawnTimer; - uint32 ResetlifeTimer; - uint32 SayingTimer; - uint32 HealSayTimer; - bool UnSpawn; - bool say; - bool HealSay; - bool isRun; - bool isMove; - - void Reset() - { - UnSpawnTimer = 2500; - ResetlifeTimer= 60000; - SayingTimer = 5000; - HealSayTimer = 6000; - say = false; - isRun = false; - isMove = false; - UnSpawn = false; - HealSay = false; - m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IN_COMBAT); - //cast red shining - m_creature->CastSpell(m_creature, 29152, false, NULL); - //set creature health - m_creature->SetHealth(int(m_creature->GetMaxHealth()*.1)); - m_creature->SetUInt32Value(UNIT_FIELD_BYTES_1, 3); - } - - void Aggro(Unit *who) {} - - void MoveInLineOfSight(Unit *who) //MoveInLineOfSight is called if creature could see you, updated all 100 ms - { - if (!who) - return; - - if(who->GetTypeId() == TYPEID_PLAYER && m_creature->IsFriendlyTo(who) && m_creature->IsWithinDistInMap(who, 15) && say && !isRun) - { - switch (rand()%4) //Random switch between 4 texts - { - case 0: - DoSay(HELP1, LANG_UNIVERSAL, NULL); - SayingTimer = 15000; - say = false; - break; - case 1: - DoSay(HELP2, LANG_UNIVERSAL, NULL); - SayingTimer = 15000; - say = false; - break; - case 2: - DoSay(HELP3, LANG_UNIVERSAL, NULL); - SayingTimer = 15000; - say = false; - break; - case 3: - DoSay(HELP4, LANG_UNIVERSAL, NULL); - SayingTimer = 15000; - say = false; - break; - } - } - else - { - isRun = false; - } - } - - void UpdateAI(const uint32 diff) //Is also called each ms for Creature AI Updates... - { - if (m_creature->GetHealth() > 50) - { - if(ResetlifeTimer < diff) - { - ResetlifeTimer = 60000; - m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IN_COMBAT); - //set creature health - m_creature->SetHealth(int(m_creature->GetMaxHealth()*.1)); - // ley down - m_creature->SetUInt32Value(UNIT_FIELD_BYTES_1,3); - } - else ResetlifeTimer -= diff; - } - - if(HealSay) - { - if (HealSayTimer < diff) - { - UnSpawn = true; - isRun = true; - isMove = true; - }else HealSayTimer -= diff; - } - - if(UnSpawn) - { - if(isMove) - { - m_creature->GetMotionMaster()->Clear(); - m_creature->GetMotionMaster()->MovePoint(0, -4115.053711f, -13754.831055f, 73.508949f); - isMove = false; - } - - if (UnSpawnTimer < diff) - { - m_creature->StopMoving(); - EnterEvadeMode(); - //set creature health - m_creature->SetHealth(int(m_creature->GetMaxHealth()*.1)); - - }else UnSpawnTimer -= diff; - } - - if(SayingTimer < diff) - { - say = true; - }else SayingTimer -= diff; - } - - void SpellHit(Unit *Hitter, const SpellEntry *Spellkind)//Called if you cast a spell and do some things if Specified spell is true! - { - if (Hitter && Spellkind->Id == 28880) - { - m_creature->SetUInt32Value(UNIT_FIELD_BYTES_1, 0); - m_creature->SetUInt32Value(UNIT_FIELD_FLAGS, UNIT_FLAG_CONFUSED); - m_creature->HandleEmoteCommand(ANIM_RISE); - switch (rand()%4) //This switch doesn't work at all, creature say nothing! - { - case 0: DoSay(HEAL1, LANG_UNIVERSAL, Hitter); break; - case 1: DoSay(HEAL2, LANG_UNIVERSAL, Hitter); break; - case 2: DoSay(HEAL3, LANG_UNIVERSAL, Hitter); break; - case 3: DoSay(HEAL4, LANG_UNIVERSAL, Hitter); break; - } - HealSay = true; - } - } -}; -CreatureAI* GetAI_npc_draenei_survivor(Creature *_Creature) -{ - return new npc_draenei_survivorAI (_Creature); -} - -/*###### -## npc_engineer_spark_overgrind -######*/ - -#define SAY_TEXT "Yes Master, all goes along as planned." -#define SAY_EMOTE "puts the shell to his ear." -#define GOSSIP_FIGHT "Traitor! You will be brought to justice!" -#define ATTACK_YELL "Now I cut you!" -#define SPELL_DYNAMITE 7978 - -struct MANGOS_DLL_DECL npc_engineer_spark_overgrindAI : public ScriptedAI -{ - npc_engineer_spark_overgrindAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 Dynamite_Timer; - uint32 Emote_Timer; - - void Reset() - { - Dynamite_Timer = 8000; - Emote_Timer = 120000 + rand()%30000; - m_creature->setFaction(875); - } - - void Aggro(Unit *who) { } - - void UpdateAI(const uint32 diff) - { - if( !InCombat ) - { - if (Emote_Timer < diff) - { - DoSay(SAY_TEXT,LANG_UNIVERSAL,NULL); - DoTextEmote(SAY_EMOTE,NULL); - Emote_Timer = 120000 + rand()%30000; - }else Emote_Timer -= diff; - } - - if(!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - if (Dynamite_Timer < diff) - { - DoCast(m_creature->getVictim(), SPELL_DYNAMITE); - Dynamite_Timer = 8000; - } else Dynamite_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; - -CreatureAI* GetAI_npc_engineer_spark_overgrind(Creature *_Creature) -{ - return new npc_engineer_spark_overgrindAI (_Creature); -} - -bool GossipHello_npc_engineer_spark_overgrind(Player *player, Creature *_Creature) -{ - if( player->GetQuestStatus(9537) == QUEST_STATUS_INCOMPLETE ) - player->ADD_GOSSIP_ITEM(0, GOSSIP_FIGHT, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF); - - player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); - return true; -} - -bool GossipSelect_npc_engineer_spark_overgrind(Player *player, Creature *_Creature, uint32 sender, uint32 action ) -{ - if( action == GOSSIP_ACTION_INFO_DEF ) - { - player->CLOSE_GOSSIP_MENU(); - _Creature->setFaction(14); - _Creature->Yell(ATTACK_YELL, LANG_UNIVERSAL, player->GetGUID()); - ((npc_engineer_spark_overgrindAI*)_Creature->AI())->AttackStart(player); - } - return true; -} - -/*###### -## npc_injured_draenei -######*/ - -struct MANGOS_DLL_DECL npc_injured_draeneiAI : public ScriptedAI -{ - npc_injured_draeneiAI(Creature *c) : ScriptedAI(c) {Reset();} - - void Reset() - { - m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IN_COMBAT); - m_creature->SetHealth(int(m_creature->GetMaxHealth()*.15)); - switch (rand()%2) - { - case 0: m_creature->SetUInt32Value(UNIT_FIELD_BYTES_1, 1); break; - case 1: m_creature->SetUInt32Value(UNIT_FIELD_BYTES_1, 3); break; - } - } - - void Aggro(Unit *who) {} - - void MoveInLineOfSight(Unit *who) - { - return; //ignore everyone around them (won't aggro anything) - } - - void UpdateAI(const uint32 diff) - { - return; - } - -}; -CreatureAI* GetAI_npc_injured_draenei(Creature *_Creature) -{ - return new npc_injured_draeneiAI (_Creature); -} - -/*###### -## npc_susurrus -######*/ - -bool GossipHello_npc_susurrus(Player *player, Creature *_Creature) -{ - if (_Creature->isQuestGiver()) - player->PrepareQuestMenu( _Creature->GetGUID() ); - - if (player->HasItemCount(23843,1,true)) - player->ADD_GOSSIP_ITEM(0, "I am ready.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF); - - player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); - - return true; -} - -bool GossipSelect_npc_susurrus(Player *player, Creature *_Creature, uint32 sender, uint32 action ) -{ - if (action == GOSSIP_ACTION_INFO_DEF) - { - player->CLOSE_GOSSIP_MENU(); - player->CastSpell(player,32474,true); //apparently correct spell, possible not correct place to cast, or correct caster - - std::vector nodes; - - nodes.resize(2); - nodes[0] = 92; //from susurrus - nodes[1] = 91; //end at exodar - player->ActivateTaxiPathTo(nodes,11686); //TaxiPath 506. Using invisible model, possible mangos must allow 0(from dbc) for cases like this. - } - return true; -} - -/*###### -## -######*/ - -void AddSC_azuremyst_isle() -{ - Script *newscript; - - newscript = new Script; - newscript->Name="npc_draenei_survivor"; - newscript->GetAI = GetAI_npc_draenei_survivor; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="npc_engineer_spark_overgrind"; - newscript->GetAI = GetAI_npc_engineer_spark_overgrind; - newscript->pGossipHello = &GossipHello_npc_engineer_spark_overgrind; - newscript->pGossipSelect = &GossipSelect_npc_engineer_spark_overgrind; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="npc_injured_draenei"; - newscript->GetAI = GetAI_npc_injured_draenei; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="npc_susurrus"; - newscript->pGossipHello = &GossipHello_npc_susurrus; - newscript->pGossipSelect = &GossipSelect_npc_susurrus; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006,2007 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Azuremyst_Isle +SD%Complete: 75 +SDComment: Quest support: 9283, 9537, 9554(special flight path, proper model for mount missing). Injured Draenei cosmetic only +SDCategory: Azuremyst Isle +EndScriptData */ + +/* ContentData +npc_draenei_survivor +npc_engineer_spark_overgrind +npc_injured_draenei +npc_susurrus +EndContentData */ + +#include "precompiled.h" +#include + +/*###### +## npc_draenei_survivor +######*/ + +#define HEAL1 "The last thing I remember is the ship falling and us getting into the pods. I'll go see how I can help. Thank you!" +#define HEAL2 "$C, Where am I? Who are you? Oh no! What happened to the ship?." +#define HEAL3 "$C You saved me! I owe you a debt that I can never repay. I'll go see if I can help the others." +#define HEAL4 "Ugh... what is this place? Is that all that's left of the ship over there?" + +#define HELP1 "Oh, the pain..." +#define HELP2 "Everything hurts, Please make it stop..." +#define HELP3 "Ughhh... I hurt. Can you help me?" +#define HELP4 "I don't know if I can make it, please help me..." + +struct MANGOS_DLL_DECL npc_draenei_survivorAI : public ScriptedAI +{ + npc_draenei_survivorAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 UnSpawnTimer; + uint32 ResetlifeTimer; + uint32 SayingTimer; + uint32 HealSayTimer; + bool UnSpawn; + bool say; + bool HealSay; + bool isRun; + bool isMove; + + void Reset() + { + UnSpawnTimer = 2500; + ResetlifeTimer= 60000; + SayingTimer = 5000; + HealSayTimer = 6000; + say = false; + isRun = false; + isMove = false; + UnSpawn = false; + HealSay = false; + m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IN_COMBAT); + //cast red shining + m_creature->CastSpell(m_creature, 29152, false, NULL); + //set creature health + m_creature->SetHealth(int(m_creature->GetMaxHealth()*.1)); + m_creature->SetUInt32Value(UNIT_FIELD_BYTES_1, 3); + } + + void Aggro(Unit *who) {} + + void MoveInLineOfSight(Unit *who) //MoveInLineOfSight is called if creature could see you, updated all 100 ms + { + if (!who) + return; + + if(who->GetTypeId() == TYPEID_PLAYER && m_creature->IsFriendlyTo(who) && m_creature->IsWithinDistInMap(who, 15) && say && !isRun) + { + switch (rand()%4) //Random switch between 4 texts + { + case 0: + DoSay(HELP1, LANG_UNIVERSAL, NULL); + SayingTimer = 15000; + say = false; + break; + case 1: + DoSay(HELP2, LANG_UNIVERSAL, NULL); + SayingTimer = 15000; + say = false; + break; + case 2: + DoSay(HELP3, LANG_UNIVERSAL, NULL); + SayingTimer = 15000; + say = false; + break; + case 3: + DoSay(HELP4, LANG_UNIVERSAL, NULL); + SayingTimer = 15000; + say = false; + break; + } + } + else + { + isRun = false; + } + } + + void UpdateAI(const uint32 diff) //Is also called each ms for Creature AI Updates... + { + if (m_creature->GetHealth() > 50) + { + if(ResetlifeTimer < diff) + { + ResetlifeTimer = 60000; + m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IN_COMBAT); + //set creature health + m_creature->SetHealth(int(m_creature->GetMaxHealth()*.1)); + // ley down + m_creature->SetUInt32Value(UNIT_FIELD_BYTES_1,3); + } + else ResetlifeTimer -= diff; + } + + if(HealSay) + { + if (HealSayTimer < diff) + { + UnSpawn = true; + isRun = true; + isMove = true; + }else HealSayTimer -= diff; + } + + if(UnSpawn) + { + if(isMove) + { + m_creature->GetMotionMaster()->Clear(); + m_creature->GetMotionMaster()->MovePoint(0, -4115.053711f, -13754.831055f, 73.508949f); + isMove = false; + } + + if (UnSpawnTimer < diff) + { + m_creature->StopMoving(); + EnterEvadeMode(); + //set creature health + m_creature->SetHealth(int(m_creature->GetMaxHealth()*.1)); + + }else UnSpawnTimer -= diff; + } + + if(SayingTimer < diff) + { + say = true; + }else SayingTimer -= diff; + } + + void SpellHit(Unit *Hitter, const SpellEntry *Spellkind)//Called if you cast a spell and do some things if Specified spell is true! + { + if (Hitter && Spellkind->Id == 28880) + { + m_creature->SetUInt32Value(UNIT_FIELD_BYTES_1, 0); + m_creature->SetUInt32Value(UNIT_FIELD_FLAGS, UNIT_FLAG_CONFUSED); + m_creature->HandleEmoteCommand(ANIM_RISE); + switch (rand()%4) //This switch doesn't work at all, creature say nothing! + { + case 0: DoSay(HEAL1, LANG_UNIVERSAL, Hitter); break; + case 1: DoSay(HEAL2, LANG_UNIVERSAL, Hitter); break; + case 2: DoSay(HEAL3, LANG_UNIVERSAL, Hitter); break; + case 3: DoSay(HEAL4, LANG_UNIVERSAL, Hitter); break; + } + HealSay = true; + } + } +}; +CreatureAI* GetAI_npc_draenei_survivor(Creature *_Creature) +{ + return new npc_draenei_survivorAI (_Creature); +} + +/*###### +## npc_engineer_spark_overgrind +######*/ + +#define SAY_TEXT "Yes Master, all goes along as planned." +#define SAY_EMOTE "puts the shell to his ear." +#define GOSSIP_FIGHT "Traitor! You will be brought to justice!" +#define ATTACK_YELL "Now I cut you!" +#define SPELL_DYNAMITE 7978 + +struct MANGOS_DLL_DECL npc_engineer_spark_overgrindAI : public ScriptedAI +{ + npc_engineer_spark_overgrindAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 Dynamite_Timer; + uint32 Emote_Timer; + + void Reset() + { + Dynamite_Timer = 8000; + Emote_Timer = 120000 + rand()%30000; + m_creature->setFaction(875); + } + + void Aggro(Unit *who) { } + + void UpdateAI(const uint32 diff) + { + if( !InCombat ) + { + if (Emote_Timer < diff) + { + DoSay(SAY_TEXT,LANG_UNIVERSAL,NULL); + DoTextEmote(SAY_EMOTE,NULL); + Emote_Timer = 120000 + rand()%30000; + }else Emote_Timer -= diff; + } + + if(!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + if (Dynamite_Timer < diff) + { + DoCast(m_creature->getVictim(), SPELL_DYNAMITE); + Dynamite_Timer = 8000; + } else Dynamite_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; + +CreatureAI* GetAI_npc_engineer_spark_overgrind(Creature *_Creature) +{ + return new npc_engineer_spark_overgrindAI (_Creature); +} + +bool GossipHello_npc_engineer_spark_overgrind(Player *player, Creature *_Creature) +{ + if( player->GetQuestStatus(9537) == QUEST_STATUS_INCOMPLETE ) + player->ADD_GOSSIP_ITEM(0, GOSSIP_FIGHT, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF); + + player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); + return true; +} + +bool GossipSelect_npc_engineer_spark_overgrind(Player *player, Creature *_Creature, uint32 sender, uint32 action ) +{ + if( action == GOSSIP_ACTION_INFO_DEF ) + { + player->CLOSE_GOSSIP_MENU(); + _Creature->setFaction(14); + _Creature->Yell(ATTACK_YELL, LANG_UNIVERSAL, player->GetGUID()); + ((npc_engineer_spark_overgrindAI*)_Creature->AI())->AttackStart(player); + } + return true; +} + +/*###### +## npc_injured_draenei +######*/ + +struct MANGOS_DLL_DECL npc_injured_draeneiAI : public ScriptedAI +{ + npc_injured_draeneiAI(Creature *c) : ScriptedAI(c) {Reset();} + + void Reset() + { + m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IN_COMBAT); + m_creature->SetHealth(int(m_creature->GetMaxHealth()*.15)); + switch (rand()%2) + { + case 0: m_creature->SetUInt32Value(UNIT_FIELD_BYTES_1, 1); break; + case 1: m_creature->SetUInt32Value(UNIT_FIELD_BYTES_1, 3); break; + } + } + + void Aggro(Unit *who) {} + + void MoveInLineOfSight(Unit *who) + { + return; //ignore everyone around them (won't aggro anything) + } + + void UpdateAI(const uint32 diff) + { + return; + } + +}; +CreatureAI* GetAI_npc_injured_draenei(Creature *_Creature) +{ + return new npc_injured_draeneiAI (_Creature); +} + +/*###### +## npc_susurrus +######*/ + +bool GossipHello_npc_susurrus(Player *player, Creature *_Creature) +{ + if (_Creature->isQuestGiver()) + player->PrepareQuestMenu( _Creature->GetGUID() ); + + if (player->HasItemCount(23843,1,true)) + player->ADD_GOSSIP_ITEM(0, "I am ready.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF); + + player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); + + return true; +} + +bool GossipSelect_npc_susurrus(Player *player, Creature *_Creature, uint32 sender, uint32 action ) +{ + if (action == GOSSIP_ACTION_INFO_DEF) + { + player->CLOSE_GOSSIP_MENU(); + player->CastSpell(player,32474,true); //apparently correct spell, possible not correct place to cast, or correct caster + + std::vector nodes; + + nodes.resize(2); + nodes[0] = 92; //from susurrus + nodes[1] = 91; //end at exodar + player->ActivateTaxiPathTo(nodes,11686); //TaxiPath 506. Using invisible model, possible mangos must allow 0(from dbc) for cases like this. + } + return true; +} + +/*###### +## +######*/ + +void AddSC_azuremyst_isle() +{ + Script *newscript; + + newscript = new Script; + newscript->Name="npc_draenei_survivor"; + newscript->GetAI = GetAI_npc_draenei_survivor; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="npc_engineer_spark_overgrind"; + newscript->GetAI = GetAI_npc_engineer_spark_overgrind; + newscript->pGossipHello = &GossipHello_npc_engineer_spark_overgrind; + newscript->pGossipSelect = &GossipSelect_npc_engineer_spark_overgrind; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="npc_injured_draenei"; + newscript->GetAI = GetAI_npc_injured_draenei; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="npc_susurrus"; + newscript->pGossipHello = &GossipHello_npc_susurrus; + newscript->pGossipSelect = &GossipSelect_npc_susurrus; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/barrens/the_barrens.cpp b/src/bindings/scripts/scripts/zone/barrens/the_barrens.cpp index b09dd9222de..b235bde66f0 100644 --- a/src/bindings/scripts/scripts/zone/barrens/the_barrens.cpp +++ b/src/bindings/scripts/scripts/zone/barrens/the_barrens.cpp @@ -1,189 +1,189 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: The_Barrens -SD%Complete: 90 -SDComment: Quest support: 2458, 4921, 6981 -SDCategory: Barrens -EndScriptData */ - -/* ContentData -npc_beaten_corpse -npc_sputtervalve -npc_taskmaster_fizzule remove hack when mangos implement feature/detect spell kind to not aggro -EndContentData */ - -#include "precompiled.h" - -/*###### -## npc_beaten_corpse -######*/ - -bool GossipHello_npc_beaten_corpse(Player *player, Creature *_Creature) -{ - if( player->GetQuestStatus(4921) == QUEST_STATUS_INCOMPLETE || player->GetQuestStatus(4921) == QUEST_STATUS_COMPLETE) - player->ADD_GOSSIP_ITEM(0,"Examine corpse in detail...",GOSSIP_SENDER_MAIN,GOSSIP_ACTION_INFO_DEF+1); - - player->SEND_GOSSIP_MENU(3557,_Creature->GetGUID()); - return true; -} - -bool GossipSelect_npc_beaten_corpse(Player *player, Creature *_Creature, uint32 sender, uint32 action ) -{ - if(action == GOSSIP_ACTION_INFO_DEF +1) - { - player->SEND_GOSSIP_MENU(3558,_Creature->GetGUID()); - player->KilledMonster( 10668,_Creature->GetGUID() ); - } - return true; -} - -/*###### -## npc_sputtervalve -######*/ - -bool GossipHello_npc_sputtervalve(Player *player, Creature *_Creature) -{ - if (_Creature->isQuestGiver()) - player->PrepareQuestMenu( _Creature->GetGUID() ); - - if( player->GetQuestStatus(6981) == QUEST_STATUS_INCOMPLETE) - player->ADD_GOSSIP_ITEM(0,"Can you tell me about this shard?",GOSSIP_SENDER_MAIN,GOSSIP_ACTION_INFO_DEF); - - player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(),_Creature->GetGUID()); - return true; -} - -bool GossipSelect_npc_sputtervalve(Player *player, Creature *_Creature, uint32 sender, uint32 action ) -{ - if(action == GOSSIP_ACTION_INFO_DEF) - { - player->SEND_GOSSIP_MENU(2013,_Creature->GetGUID()); - player->AreaExploredOrEventHappens(6981); - } - return true; -} - -/*###### -## npc_taskmaster_fizzule -######*/ - -//#define FACTION_HOSTILE_F 430 -#define FACTION_HOSTILE_F 16 -#define FACTION_FRIENDLY_F 35 - -#define SPELL_FLARE 10113 -#define SPELL_FOLLY 10137 - -struct MANGOS_DLL_DECL npc_taskmaster_fizzuleAI : public ScriptedAI -{ - npc_taskmaster_fizzuleAI(Creature* c) : ScriptedAI(c) { Reset(); } - - bool IsFriend; - uint32 Reset_Timer; - uint32 FlareCount; - - void Reset() - { - IsFriend = false; - Reset_Timer = 120000; - FlareCount = 0; - m_creature->setFaction(FACTION_HOSTILE_F); - m_creature->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER); - } - - //This is a hack. Spellcast will make creature aggro but that is not - //supposed to happen (mangos not implemented/not found way to detect this spell kind) - void DoUglyHack() - { - m_creature->RemoveAllAuras(); - m_creature->DeleteThreatList(); - m_creature->CombatStop(); - } - - void SpellHit(Unit *caster, const SpellEntry *spell) - { - if( spell->Id == SPELL_FLARE || spell->Id == SPELL_FOLLY ) - { - DoUglyHack(); - ++FlareCount; - if( FlareCount >= 2 ) - { - m_creature->setFaction(FACTION_FRIENDLY_F); - IsFriend = true; - } - } - } - - void Aggro(Unit* who) { } - - void UpdateAI(const uint32 diff) - { - if( IsFriend ) - { - if( Reset_Timer < diff ) - { - EnterEvadeMode(); - } else Reset_Timer -= diff; - } - - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - DoMeleeAttackIfReady(); - } -}; -CreatureAI* GetAI_npc_taskmaster_fizzule(Creature *_Creature) -{ - return new npc_taskmaster_fizzuleAI (_Creature); -} - -bool ReciveEmote_npc_taskmaster_fizzule(Player *player, Creature *_Creature, uint32 emote) -{ - if( emote == TEXTEMOTE_SALUTE ) - { - if( ((npc_taskmaster_fizzuleAI*)_Creature->AI())->FlareCount >= 2 ) - { - _Creature->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER); - _Creature->HandleEmoteCommand(EMOTE_ONESHOT_SALUTE); - } - } - return true; -} - -void AddSC_the_barrens() -{ - Script *newscript; - - newscript = new Script; - newscript->Name="npc_beaten_corpse"; - newscript->pGossipHello = &GossipHello_npc_beaten_corpse; - newscript->pGossipSelect = &GossipSelect_npc_beaten_corpse; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="npc_sputtervalve"; - newscript->pGossipHello = &GossipHello_npc_sputtervalve; - newscript->pGossipSelect = &GossipSelect_npc_sputtervalve; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="npc_taskmaster_fizzule"; - newscript->GetAI = GetAI_npc_taskmaster_fizzule; - newscript->pReceiveEmote = &ReciveEmote_npc_taskmaster_fizzule; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: The_Barrens +SD%Complete: 90 +SDComment: Quest support: 2458, 4921, 6981 +SDCategory: Barrens +EndScriptData */ + +/* ContentData +npc_beaten_corpse +npc_sputtervalve +npc_taskmaster_fizzule remove hack when mangos implement feature/detect spell kind to not aggro +EndContentData */ + +#include "precompiled.h" + +/*###### +## npc_beaten_corpse +######*/ + +bool GossipHello_npc_beaten_corpse(Player *player, Creature *_Creature) +{ + if( player->GetQuestStatus(4921) == QUEST_STATUS_INCOMPLETE || player->GetQuestStatus(4921) == QUEST_STATUS_COMPLETE) + player->ADD_GOSSIP_ITEM(0,"Examine corpse in detail...",GOSSIP_SENDER_MAIN,GOSSIP_ACTION_INFO_DEF+1); + + player->SEND_GOSSIP_MENU(3557,_Creature->GetGUID()); + return true; +} + +bool GossipSelect_npc_beaten_corpse(Player *player, Creature *_Creature, uint32 sender, uint32 action ) +{ + if(action == GOSSIP_ACTION_INFO_DEF +1) + { + player->SEND_GOSSIP_MENU(3558,_Creature->GetGUID()); + player->KilledMonster( 10668,_Creature->GetGUID() ); + } + return true; +} + +/*###### +## npc_sputtervalve +######*/ + +bool GossipHello_npc_sputtervalve(Player *player, Creature *_Creature) +{ + if (_Creature->isQuestGiver()) + player->PrepareQuestMenu( _Creature->GetGUID() ); + + if( player->GetQuestStatus(6981) == QUEST_STATUS_INCOMPLETE) + player->ADD_GOSSIP_ITEM(0,"Can you tell me about this shard?",GOSSIP_SENDER_MAIN,GOSSIP_ACTION_INFO_DEF); + + player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(),_Creature->GetGUID()); + return true; +} + +bool GossipSelect_npc_sputtervalve(Player *player, Creature *_Creature, uint32 sender, uint32 action ) +{ + if(action == GOSSIP_ACTION_INFO_DEF) + { + player->SEND_GOSSIP_MENU(2013,_Creature->GetGUID()); + player->AreaExploredOrEventHappens(6981); + } + return true; +} + +/*###### +## npc_taskmaster_fizzule +######*/ + +//#define FACTION_HOSTILE_F 430 +#define FACTION_HOSTILE_F 16 +#define FACTION_FRIENDLY_F 35 + +#define SPELL_FLARE 10113 +#define SPELL_FOLLY 10137 + +struct MANGOS_DLL_DECL npc_taskmaster_fizzuleAI : public ScriptedAI +{ + npc_taskmaster_fizzuleAI(Creature* c) : ScriptedAI(c) { Reset(); } + + bool IsFriend; + uint32 Reset_Timer; + uint32 FlareCount; + + void Reset() + { + IsFriend = false; + Reset_Timer = 120000; + FlareCount = 0; + m_creature->setFaction(FACTION_HOSTILE_F); + m_creature->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER); + } + + //This is a hack. Spellcast will make creature aggro but that is not + //supposed to happen (mangos not implemented/not found way to detect this spell kind) + void DoUglyHack() + { + m_creature->RemoveAllAuras(); + m_creature->DeleteThreatList(); + m_creature->CombatStop(); + } + + void SpellHit(Unit *caster, const SpellEntry *spell) + { + if( spell->Id == SPELL_FLARE || spell->Id == SPELL_FOLLY ) + { + DoUglyHack(); + ++FlareCount; + if( FlareCount >= 2 ) + { + m_creature->setFaction(FACTION_FRIENDLY_F); + IsFriend = true; + } + } + } + + void Aggro(Unit* who) { } + + void UpdateAI(const uint32 diff) + { + if( IsFriend ) + { + if( Reset_Timer < diff ) + { + EnterEvadeMode(); + } else Reset_Timer -= diff; + } + + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + DoMeleeAttackIfReady(); + } +}; +CreatureAI* GetAI_npc_taskmaster_fizzule(Creature *_Creature) +{ + return new npc_taskmaster_fizzuleAI (_Creature); +} + +bool ReciveEmote_npc_taskmaster_fizzule(Player *player, Creature *_Creature, uint32 emote) +{ + if( emote == TEXTEMOTE_SALUTE ) + { + if( ((npc_taskmaster_fizzuleAI*)_Creature->AI())->FlareCount >= 2 ) + { + _Creature->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER); + _Creature->HandleEmoteCommand(EMOTE_ONESHOT_SALUTE); + } + } + return true; +} + +void AddSC_the_barrens() +{ + Script *newscript; + + newscript = new Script; + newscript->Name="npc_beaten_corpse"; + newscript->pGossipHello = &GossipHello_npc_beaten_corpse; + newscript->pGossipSelect = &GossipSelect_npc_beaten_corpse; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="npc_sputtervalve"; + newscript->pGossipHello = &GossipHello_npc_sputtervalve; + newscript->pGossipSelect = &GossipSelect_npc_sputtervalve; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="npc_taskmaster_fizzule"; + newscript->GetAI = GetAI_npc_taskmaster_fizzule; + newscript->pReceiveEmote = &ReciveEmote_npc_taskmaster_fizzule; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/black_temple/black_temple.cpp b/src/bindings/scripts/scripts/zone/black_temple/black_temple.cpp index 137d87ed8a6..9f6c4d2500b 100644 --- a/src/bindings/scripts/scripts/zone/black_temple/black_temple.cpp +++ b/src/bindings/scripts/scripts/zone/black_temple/black_temple.cpp @@ -1,68 +1,68 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Black_Temple -SD%Complete: 95 -SDComment: Spirit of Olum: Player Teleporter to Seer Kanai Teleport after defeating Naj'entus and Supremus. TODO: Find proper gossip. -SDCategory: Black Temple -EndScriptData */ - -/* ContentData -npc_spirit_of_olum -EndContentData */ - -#include "precompiled.h" -#include "def_black_temple.h" - -/*### -# npc_spirit_of_olum -####*/ - -#define SPELL_TELEPORT 41566 // s41566 - Teleport to Ashtongue NPC's -#define GOSSIP_OLUM1 "Teleport me to the other Ashtongue Deathsworn" - -bool GossipHello_npc_spirit_of_olum(Player* player, Creature* _Creature) -{ - ScriptedInstance* pInstance = ((ScriptedInstance*)_Creature->GetInstanceData()); - - if(pInstance && (pInstance->GetData(DATA_SUPREMUSEVENT) >= DONE) && (pInstance->GetData(DATA_HIGHWARLORDNAJENTUSEVENT) >= DONE)) - player->ADD_GOSSIP_ITEM(0, GOSSIP_OLUM1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); - - player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); - return true; -} - -bool GossipSelect_npc_spirit_of_olum(Player* player, Creature* _Creature, uint32 sender, uint32 action) -{ - if(action == GOSSIP_ACTION_INFO_DEF + 1) - player->CLOSE_GOSSIP_MENU(); - - player->InterruptNonMeleeSpells(false); - player->CastSpell(player, SPELL_TELEPORT, false); - return true; -} - -void AddSC_black_temple() -{ - Script *newscript; - - newscript = new Script; - newscript->Name = "npc_spirit_of_olum"; - newscript->pGossipHello = GossipHello_npc_spirit_of_olum; - newscript->pGossipSelect = GossipSelect_npc_spirit_of_olum; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Black_Temple +SD%Complete: 95 +SDComment: Spirit of Olum: Player Teleporter to Seer Kanai Teleport after defeating Naj'entus and Supremus. TODO: Find proper gossip. +SDCategory: Black Temple +EndScriptData */ + +/* ContentData +npc_spirit_of_olum +EndContentData */ + +#include "precompiled.h" +#include "def_black_temple.h" + +/*### +# npc_spirit_of_olum +####*/ + +#define SPELL_TELEPORT 41566 // s41566 - Teleport to Ashtongue NPC's +#define GOSSIP_OLUM1 "Teleport me to the other Ashtongue Deathsworn" + +bool GossipHello_npc_spirit_of_olum(Player* player, Creature* _Creature) +{ + ScriptedInstance* pInstance = ((ScriptedInstance*)_Creature->GetInstanceData()); + + if(pInstance && (pInstance->GetData(DATA_SUPREMUSEVENT) >= DONE) && (pInstance->GetData(DATA_HIGHWARLORDNAJENTUSEVENT) >= DONE)) + player->ADD_GOSSIP_ITEM(0, GOSSIP_OLUM1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); + + player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); + return true; +} + +bool GossipSelect_npc_spirit_of_olum(Player* player, Creature* _Creature, uint32 sender, uint32 action) +{ + if(action == GOSSIP_ACTION_INFO_DEF + 1) + player->CLOSE_GOSSIP_MENU(); + + player->InterruptNonMeleeSpells(false); + player->CastSpell(player, SPELL_TELEPORT, false); + return true; +} + +void AddSC_black_temple() +{ + Script *newscript; + + newscript = new Script; + newscript->Name = "npc_spirit_of_olum"; + newscript->pGossipHello = GossipHello_npc_spirit_of_olum; + newscript->pGossipSelect = GossipSelect_npc_spirit_of_olum; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/black_temple/boss_bloodboil.cpp b/src/bindings/scripts/scripts/zone/black_temple/boss_bloodboil.cpp index fba3f7fc36d..40a97fbf6ee 100644 --- a/src/bindings/scripts/scripts/zone/black_temple/boss_bloodboil.cpp +++ b/src/bindings/scripts/scripts/zone/black_temple/boss_bloodboil.cpp @@ -1,365 +1,365 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Bloodboil -SD%Complete: 80 -SDComment: Bloodboil not working correctly, missing enrage -SDCategory: Black Temple -EndScriptData */ - -#include "precompiled.h" -#include "def_black_temple.h" - -//Spells -#define SPELL_ACID_GEYSER 40630 -#define SPELL_ACIDIC_WOUND 40481 -#define SPELL_ARCING_SMASH 40599 -#define SPELL_BLOODBOIL 42005 // This spell is AoE whereas it shouldn't be -#define SPELL_FEL_ACID 40508 -#define SPELL_FEL_RAGE_SELF 40594 -#define SPELL_FEL_RAGE_TARGET 40604 -#define SPELL_FEL_RAGE_2 40616 -#define SPELL_FEL_RAGE_3 41625 -#define SPELL_BEWILDERING_STRIKE 40491 -#define SPELL_EJECT1 40486 // 1000 Physical damage + knockback + script effect (should handle threat reduction I think) -#define SPELL_EJECT2 40597 // 1000 Physical damage + Stun (used in phase 2?) -#define SPELL_TAUNT_GURTOGG 40603 -#define SPELL_INSIGNIFIGANCE 40618 -#define SPELL_BERSERK 45078 - -//Speech'n'Sound -#define SAY_AGGRO "Horde will crush you!" -#define SOUND_AGGRO 11432 - -#define SAY_SLAY1 "Time to feast!" -#define SOUND_SLAY1 11433 - -#define SAY_SLAY2 "More! I want more!" -#define SOUND_SLAY2 11434 - -#define SAY_SPECIAL1 "Drink your blood! Eat your flesh!" -#define SOUND_SPECIAL1 11435 - -#define SAY_SPECIAL2 "I hunger!" -#define SOUND_SPECIAL2 11436 - -#define SAY_ENRAGE "I'll rip the meat from your bones!" -#define SOUND_ENRAGE 11437 - -#define SOUND_DEATH 11439 - -//This is used to sort the players by distance in preparation for the Bloodboil cast. -struct TargetDistanceOrder : public std::binary_function -{ - const Unit* MainTarget; - TargetDistanceOrder(const Unit* Target) : MainTarget(Target) {}; - // functor for operator ">" - bool operator()(const Unit* _Left, const Unit* _Right) const - { - return (MainTarget->GetDistance(_Left) > MainTarget->GetDistance(_Right)); - } -}; - -struct MANGOS_DLL_DECL boss_gurtogg_bloodboilAI : public ScriptedAI -{ - boss_gurtogg_bloodboilAI(Creature *c) : ScriptedAI(c) - { - pInstance = ((ScriptedInstance*)c->GetInstanceData()); - Reset(); - } - - ScriptedInstance* pInstance; - - uint64 TargetGUID; - - float TargetThreat; - - uint32 BloodboilTimer; - uint32 BloodboilCount; - uint32 AcidGeyserTimer; - uint32 AcidicWoundTimer; - uint32 ArcingSmashTimer; - uint32 EnrageTimer; - uint32 FelAcidTimer; - uint32 EjectTimer; - uint32 BewilderingStrikeTimer; - uint32 PhaseChangeTimer; - - bool Phase1; - - void Reset() - { - if(pInstance) - pInstance->SetData(DATA_GURTOGGBLOODBOILEVENT, NOT_STARTED); - - TargetGUID = 0; - - TargetThreat = 0; - - BloodboilTimer = 10000; - BloodboilCount = 0; - AcidGeyserTimer = 1000; - AcidicWoundTimer = 6000; - ArcingSmashTimer = 19000; - EnrageTimer = 600000; - FelAcidTimer = 25000; - EjectTimer = 10000; - BewilderingStrikeTimer = 15000; - PhaseChangeTimer = 60000; - - Phase1 = true; - } - - void Aggro(Unit *who) - { - DoZoneInCombat(); - DoYell(SAY_AGGRO,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature, SOUND_AGGRO); - if(pInstance) - pInstance->SetData(DATA_GURTOGGBLOODBOILEVENT, IN_PROGRESS); - } - - void KilledUnit(Unit *victim) - { - switch(rand()%2) - { - case 0: - DoYell(SAY_SLAY1,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature, SOUND_SLAY1); - break; - case 1: - DoYell(SAY_SLAY2,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature, SOUND_SLAY2); - break; - } - } - - void JustDied(Unit *victim) - { - if(pInstance) - pInstance->SetData(DATA_GURTOGGBLOODBOILEVENT, DONE); - - DoPlaySoundToSet(m_creature,SOUND_DEATH); - } - - // Note: This seems like a very complicated fix. The fix needs to be handled by the core, as implementation of limited-target AoE spells are still not limited. - void CastBloodboil() - { - // Get the Threat List - std::list m_threatlist = m_creature->getThreatManager().getThreatList(); - - if(!m_threatlist.size()) return; // He doesn't have anyone in his threatlist, useless to continue - - std::list targets; - std::list::iterator itr = m_threatlist.begin(); - for( ; itr!= m_threatlist.end(); ++itr) //store the threat list in a different container - { - Unit *target = Unit::GetUnit(*m_creature, (*itr)->getUnitGuid()); - //only on alive players - if(target && target->isAlive() && target->GetTypeId() == TYPEID_PLAYER ) - targets.push_back( target); - } - - //Sort the list of players - targets.sort(TargetDistanceOrder(m_creature)); - //Resize so we only get top 5 - targets.resize(5); - - //Aura each player in the targets list with Bloodboil. Aura code copied+pasted from Aura command in Level3.cpp - /*SpellEntry const *spellInfo = GetSpellStore()->LookupEntry( SPELL_BLOODBOIL ); - if(spellInfo) - { - for(std::list::iterator itr = targets.begin(); itr != targets.end(); ++itr) - { - Unit* target = *itr; - if(!target) return; - for(uint32 i = 0;i<3;i++) - { - uint8 eff = spellInfo->Effect[i]; - if (eff>=TOTAL_SPELL_EFFECTS) - continue; - - Aura *Aur = new Aura(spellInfo, i, NULL, target); - target->AddAura(Aur); - } - } - }*/ - } - - void RevertThreatOnTarget(uint64 guid) - { - Unit* pUnit = NULL; - pUnit = Unit::GetUnit((*m_creature), guid); - if(pUnit) - { - if(m_creature->getThreatManager().getThreat(pUnit)) - m_creature->getThreatManager().modifyThreatPercent(pUnit, -100); - if(TargetThreat) - m_creature->AddThreat(pUnit, TargetThreat); - } - } - - void UpdateAI(const uint32 diff) - { - if(!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - if(ArcingSmashTimer < diff) - { - DoCast(m_creature->getVictim(), SPELL_ARCING_SMASH); - ArcingSmashTimer = 10000; - }else ArcingSmashTimer -= diff; - - if(FelAcidTimer < diff) - { - DoCast(m_creature->getVictim(), SPELL_FEL_ACID); - FelAcidTimer = 25000; - }else FelAcidTimer -= diff; - - if(!m_creature->HasAura(SPELL_BERSERK, 0)) - if(EnrageTimer < diff) - { - DoCast(m_creature, SPELL_BERSERK); - DoYell(SAY_ENRAGE,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature, SOUND_ENRAGE); - }else EnrageTimer -= diff; - - if(Phase1) - { - if(BewilderingStrikeTimer < diff) - { - DoCast(m_creature->getVictim(), SPELL_BEWILDERING_STRIKE); - float mt_threat = m_creature->getThreatManager().getThreat(m_creature->getVictim()); - Unit* target = SelectUnit(SELECT_TARGET_TOPAGGRO, 1); - m_creature->AddThreat(target, mt_threat); - BewilderingStrikeTimer = 20000; - }else BewilderingStrikeTimer -= diff; - - if(EjectTimer < diff) - { - DoCast(m_creature->getVictim(), SPELL_EJECT1); - m_creature->getThreatManager().modifyThreatPercent(m_creature->getVictim(), -40); - EjectTimer = 15000; - }else EjectTimer -= diff; - - if(AcidicWoundTimer < diff) - { - DoCast(m_creature->getVictim(), SPELL_ACIDIC_WOUND); - AcidicWoundTimer = 10000; - }else AcidicWoundTimer -= diff; - - if(BloodboilTimer < diff) - { - if(BloodboilCount < 5) // Only cast it five times. - { - //CastBloodboil(); // Causes issues on windows, so is commented out. - DoCast(m_creature->getVictim(), SPELL_BLOODBOIL); - ++BloodboilCount; - BloodboilTimer = 10000*BloodboilCount; - } - }else BloodboilTimer -= diff; - } - - if(!Phase1) - { - if(AcidGeyserTimer < diff) - { - DoCast(m_creature->getVictim(), SPELL_ACID_GEYSER); - AcidGeyserTimer = 30000; - }else AcidGeyserTimer -= diff; - - if(EjectTimer < diff) - { - DoCast(m_creature->getVictim(), SPELL_EJECT2); - EjectTimer = 15000; - }else EjectTimer -= diff; - } - - if(PhaseChangeTimer < diff) - { - if(Phase1) - { - Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0); - if(target && target->isAlive()) - { - Phase1 = false; - - TargetThreat = m_creature->getThreatManager().getThreat(target); - TargetGUID = target->GetGUID(); - target->CastSpell(m_creature, SPELL_TAUNT_GURTOGG, true); - if(m_creature->getThreatManager().getThreat(target)) - m_creature->getThreatManager().modifyThreatPercent(target, -100); - m_creature->AddThreat(target, 50000000.0f); - // If VMaps are disabled, this spell can call the whole instance - DoCast(m_creature, SPELL_INSIGNIFIGANCE, true); - DoCast(target, SPELL_FEL_RAGE_TARGET, true); - DoCast(target,SPELL_FEL_RAGE_2, true); - /* These spells do not work, comment them out for now. - DoCast(target, SPELL_FEL_RAGE_2, true); - DoCast(target, SPELL_FEL_RAGE_3, true);*/ - - //Cast this without triggered so that it appears in combat logs and shows visual. - DoCast(m_creature, SPELL_FEL_RAGE_SELF); - - switch(rand()%2) - { - case 0: - DoYell(SAY_SPECIAL1,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature, SOUND_SPECIAL1); - break; - case 1: - DoYell(SAY_SPECIAL2,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature, SOUND_SPECIAL2); - break; - } - - AcidGeyserTimer = 1000; - PhaseChangeTimer = 30000; - } - }else // Encounter is a loop pretty much. Phase 1 -> Phase 2 -> Phase 1 -> Phase 2 till death or enrage - { - if(TargetGUID) - RevertThreatOnTarget(TargetGUID); - TargetGUID = 0; - Phase1 = true; - BloodboilTimer = 10000; - BloodboilCount = 0; - AcidicWoundTimer += 2000; - ArcingSmashTimer += 2000; - FelAcidTimer += 2000; - EjectTimer += 2000; - PhaseChangeTimer = 60000; - } - }else PhaseChangeTimer -= diff; - - DoMeleeAttackIfReady(); - } -}; - -CreatureAI* GetAI_boss_gurtogg_bloodboil(Creature *_Creature) -{ - return new boss_gurtogg_bloodboilAI (_Creature); -} - -void AddSC_boss_gurtogg_bloodboil() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_gurtogg_bloodboil"; - newscript->GetAI = GetAI_boss_gurtogg_bloodboil; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Bloodboil +SD%Complete: 80 +SDComment: Bloodboil not working correctly, missing enrage +SDCategory: Black Temple +EndScriptData */ + +#include "precompiled.h" +#include "def_black_temple.h" + +//Spells +#define SPELL_ACID_GEYSER 40630 +#define SPELL_ACIDIC_WOUND 40481 +#define SPELL_ARCING_SMASH 40599 +#define SPELL_BLOODBOIL 42005 // This spell is AoE whereas it shouldn't be +#define SPELL_FEL_ACID 40508 +#define SPELL_FEL_RAGE_SELF 40594 +#define SPELL_FEL_RAGE_TARGET 40604 +#define SPELL_FEL_RAGE_2 40616 +#define SPELL_FEL_RAGE_3 41625 +#define SPELL_BEWILDERING_STRIKE 40491 +#define SPELL_EJECT1 40486 // 1000 Physical damage + knockback + script effect (should handle threat reduction I think) +#define SPELL_EJECT2 40597 // 1000 Physical damage + Stun (used in phase 2?) +#define SPELL_TAUNT_GURTOGG 40603 +#define SPELL_INSIGNIFIGANCE 40618 +#define SPELL_BERSERK 45078 + +//Speech'n'Sound +#define SAY_AGGRO "Horde will crush you!" +#define SOUND_AGGRO 11432 + +#define SAY_SLAY1 "Time to feast!" +#define SOUND_SLAY1 11433 + +#define SAY_SLAY2 "More! I want more!" +#define SOUND_SLAY2 11434 + +#define SAY_SPECIAL1 "Drink your blood! Eat your flesh!" +#define SOUND_SPECIAL1 11435 + +#define SAY_SPECIAL2 "I hunger!" +#define SOUND_SPECIAL2 11436 + +#define SAY_ENRAGE "I'll rip the meat from your bones!" +#define SOUND_ENRAGE 11437 + +#define SOUND_DEATH 11439 + +//This is used to sort the players by distance in preparation for the Bloodboil cast. +struct TargetDistanceOrder : public std::binary_function +{ + const Unit* MainTarget; + TargetDistanceOrder(const Unit* Target) : MainTarget(Target) {}; + // functor for operator ">" + bool operator()(const Unit* _Left, const Unit* _Right) const + { + return (MainTarget->GetDistance(_Left) > MainTarget->GetDistance(_Right)); + } +}; + +struct MANGOS_DLL_DECL boss_gurtogg_bloodboilAI : public ScriptedAI +{ + boss_gurtogg_bloodboilAI(Creature *c) : ScriptedAI(c) + { + pInstance = ((ScriptedInstance*)c->GetInstanceData()); + Reset(); + } + + ScriptedInstance* pInstance; + + uint64 TargetGUID; + + float TargetThreat; + + uint32 BloodboilTimer; + uint32 BloodboilCount; + uint32 AcidGeyserTimer; + uint32 AcidicWoundTimer; + uint32 ArcingSmashTimer; + uint32 EnrageTimer; + uint32 FelAcidTimer; + uint32 EjectTimer; + uint32 BewilderingStrikeTimer; + uint32 PhaseChangeTimer; + + bool Phase1; + + void Reset() + { + if(pInstance) + pInstance->SetData(DATA_GURTOGGBLOODBOILEVENT, NOT_STARTED); + + TargetGUID = 0; + + TargetThreat = 0; + + BloodboilTimer = 10000; + BloodboilCount = 0; + AcidGeyserTimer = 1000; + AcidicWoundTimer = 6000; + ArcingSmashTimer = 19000; + EnrageTimer = 600000; + FelAcidTimer = 25000; + EjectTimer = 10000; + BewilderingStrikeTimer = 15000; + PhaseChangeTimer = 60000; + + Phase1 = true; + } + + void Aggro(Unit *who) + { + DoZoneInCombat(); + DoYell(SAY_AGGRO,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature, SOUND_AGGRO); + if(pInstance) + pInstance->SetData(DATA_GURTOGGBLOODBOILEVENT, IN_PROGRESS); + } + + void KilledUnit(Unit *victim) + { + switch(rand()%2) + { + case 0: + DoYell(SAY_SLAY1,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature, SOUND_SLAY1); + break; + case 1: + DoYell(SAY_SLAY2,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature, SOUND_SLAY2); + break; + } + } + + void JustDied(Unit *victim) + { + if(pInstance) + pInstance->SetData(DATA_GURTOGGBLOODBOILEVENT, DONE); + + DoPlaySoundToSet(m_creature,SOUND_DEATH); + } + + // Note: This seems like a very complicated fix. The fix needs to be handled by the core, as implementation of limited-target AoE spells are still not limited. + void CastBloodboil() + { + // Get the Threat List + std::list m_threatlist = m_creature->getThreatManager().getThreatList(); + + if(!m_threatlist.size()) return; // He doesn't have anyone in his threatlist, useless to continue + + std::list targets; + std::list::iterator itr = m_threatlist.begin(); + for( ; itr!= m_threatlist.end(); ++itr) //store the threat list in a different container + { + Unit *target = Unit::GetUnit(*m_creature, (*itr)->getUnitGuid()); + //only on alive players + if(target && target->isAlive() && target->GetTypeId() == TYPEID_PLAYER ) + targets.push_back( target); + } + + //Sort the list of players + targets.sort(TargetDistanceOrder(m_creature)); + //Resize so we only get top 5 + targets.resize(5); + + //Aura each player in the targets list with Bloodboil. Aura code copied+pasted from Aura command in Level3.cpp + /*SpellEntry const *spellInfo = GetSpellStore()->LookupEntry( SPELL_BLOODBOIL ); + if(spellInfo) + { + for(std::list::iterator itr = targets.begin(); itr != targets.end(); ++itr) + { + Unit* target = *itr; + if(!target) return; + for(uint32 i = 0;i<3;i++) + { + uint8 eff = spellInfo->Effect[i]; + if (eff>=TOTAL_SPELL_EFFECTS) + continue; + + Aura *Aur = new Aura(spellInfo, i, NULL, target); + target->AddAura(Aur); + } + } + }*/ + } + + void RevertThreatOnTarget(uint64 guid) + { + Unit* pUnit = NULL; + pUnit = Unit::GetUnit((*m_creature), guid); + if(pUnit) + { + if(m_creature->getThreatManager().getThreat(pUnit)) + m_creature->getThreatManager().modifyThreatPercent(pUnit, -100); + if(TargetThreat) + m_creature->AddThreat(pUnit, TargetThreat); + } + } + + void UpdateAI(const uint32 diff) + { + if(!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + if(ArcingSmashTimer < diff) + { + DoCast(m_creature->getVictim(), SPELL_ARCING_SMASH); + ArcingSmashTimer = 10000; + }else ArcingSmashTimer -= diff; + + if(FelAcidTimer < diff) + { + DoCast(m_creature->getVictim(), SPELL_FEL_ACID); + FelAcidTimer = 25000; + }else FelAcidTimer -= diff; + + if(!m_creature->HasAura(SPELL_BERSERK, 0)) + if(EnrageTimer < diff) + { + DoCast(m_creature, SPELL_BERSERK); + DoYell(SAY_ENRAGE,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature, SOUND_ENRAGE); + }else EnrageTimer -= diff; + + if(Phase1) + { + if(BewilderingStrikeTimer < diff) + { + DoCast(m_creature->getVictim(), SPELL_BEWILDERING_STRIKE); + float mt_threat = m_creature->getThreatManager().getThreat(m_creature->getVictim()); + Unit* target = SelectUnit(SELECT_TARGET_TOPAGGRO, 1); + m_creature->AddThreat(target, mt_threat); + BewilderingStrikeTimer = 20000; + }else BewilderingStrikeTimer -= diff; + + if(EjectTimer < diff) + { + DoCast(m_creature->getVictim(), SPELL_EJECT1); + m_creature->getThreatManager().modifyThreatPercent(m_creature->getVictim(), -40); + EjectTimer = 15000; + }else EjectTimer -= diff; + + if(AcidicWoundTimer < diff) + { + DoCast(m_creature->getVictim(), SPELL_ACIDIC_WOUND); + AcidicWoundTimer = 10000; + }else AcidicWoundTimer -= diff; + + if(BloodboilTimer < diff) + { + if(BloodboilCount < 5) // Only cast it five times. + { + //CastBloodboil(); // Causes issues on windows, so is commented out. + DoCast(m_creature->getVictim(), SPELL_BLOODBOIL); + ++BloodboilCount; + BloodboilTimer = 10000*BloodboilCount; + } + }else BloodboilTimer -= diff; + } + + if(!Phase1) + { + if(AcidGeyserTimer < diff) + { + DoCast(m_creature->getVictim(), SPELL_ACID_GEYSER); + AcidGeyserTimer = 30000; + }else AcidGeyserTimer -= diff; + + if(EjectTimer < diff) + { + DoCast(m_creature->getVictim(), SPELL_EJECT2); + EjectTimer = 15000; + }else EjectTimer -= diff; + } + + if(PhaseChangeTimer < diff) + { + if(Phase1) + { + Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0); + if(target && target->isAlive()) + { + Phase1 = false; + + TargetThreat = m_creature->getThreatManager().getThreat(target); + TargetGUID = target->GetGUID(); + target->CastSpell(m_creature, SPELL_TAUNT_GURTOGG, true); + if(m_creature->getThreatManager().getThreat(target)) + m_creature->getThreatManager().modifyThreatPercent(target, -100); + m_creature->AddThreat(target, 50000000.0f); + // If VMaps are disabled, this spell can call the whole instance + DoCast(m_creature, SPELL_INSIGNIFIGANCE, true); + DoCast(target, SPELL_FEL_RAGE_TARGET, true); + DoCast(target,SPELL_FEL_RAGE_2, true); + /* These spells do not work, comment them out for now. + DoCast(target, SPELL_FEL_RAGE_2, true); + DoCast(target, SPELL_FEL_RAGE_3, true);*/ + + //Cast this without triggered so that it appears in combat logs and shows visual. + DoCast(m_creature, SPELL_FEL_RAGE_SELF); + + switch(rand()%2) + { + case 0: + DoYell(SAY_SPECIAL1,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature, SOUND_SPECIAL1); + break; + case 1: + DoYell(SAY_SPECIAL2,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature, SOUND_SPECIAL2); + break; + } + + AcidGeyserTimer = 1000; + PhaseChangeTimer = 30000; + } + }else // Encounter is a loop pretty much. Phase 1 -> Phase 2 -> Phase 1 -> Phase 2 till death or enrage + { + if(TargetGUID) + RevertThreatOnTarget(TargetGUID); + TargetGUID = 0; + Phase1 = true; + BloodboilTimer = 10000; + BloodboilCount = 0; + AcidicWoundTimer += 2000; + ArcingSmashTimer += 2000; + FelAcidTimer += 2000; + EjectTimer += 2000; + PhaseChangeTimer = 60000; + } + }else PhaseChangeTimer -= diff; + + DoMeleeAttackIfReady(); + } +}; + +CreatureAI* GetAI_boss_gurtogg_bloodboil(Creature *_Creature) +{ + return new boss_gurtogg_bloodboilAI (_Creature); +} + +void AddSC_boss_gurtogg_bloodboil() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_gurtogg_bloodboil"; + newscript->GetAI = GetAI_boss_gurtogg_bloodboil; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/black_temple/boss_illidan.cpp b/src/bindings/scripts/scripts/zone/black_temple/boss_illidan.cpp index ecf8ad427be..fdf69035bd4 100644 --- a/src/bindings/scripts/scripts/zone/black_temple/boss_illidan.cpp +++ b/src/bindings/scripts/scripts/zone/black_temple/boss_illidan.cpp @@ -1,2465 +1,2468 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: boss_illidan_stormrage -SD%Complete: 90 -SDComment: -SDCategory: Black Temple -EndScriptData */ - -#include "precompiled.h" -#include "def_black_temple.h" -#include "WorldPacket.h" - -/************* Quotes and Sounds ***********************/ -// Gossip for when a player clicks Akama -#define GOSSIP_ITEM "We are ready to face Illidan" - -// Yells for/by Akama -#define SAY_AKAMA_BEWARE "Be wary friends, The Betrayer meditates in the court just beyond." -#define SOUND_AKAMA_BEWARE 11388 -#define SAY_AKAMA_MINION "Come, my minions. Deal with this traitor as he deserves!" -#define SOUND_AKAMA_MINION 11465 -#define SAY_AKAMA_LEAVE "I'll deal with these mongrels. Strike now, friends! Strike at the betrayer!" -#define SOUND_AKAMA_LEAVE 11390 - -// Self explanatory -#define SAY_KILL1 "Who shall be next to taste my blades?!" -#define SOUND_KILL1 11473 -#define SAY_KILL2 "This is too easy!" -#define SOUND_KILL2 11472 - -// I think I'll fly now and let my subordinates take you on -#define SAY_TAKEOFF "I will not be touched by rabble such as you!" -#define SOUND_TAKEOFF 11479 -#define SAY_SUMMONFLAMES "Behold the flames of Azzinoth!" -#define SOUND_SUMMONFLAMES 11480 - -// When casting Eye Blast. Demon Fire will be appear on places that he casts this -#define SAY_EYE_BLAST "Stare into the eyes of the Betrayer!" -#define SOUND_EYE_BLAST 11481 - -// kk, I go big, dark and demon on you. -#define SAY_MORPH "Behold the power... of the demon within!" -#define SOUND_MORPH 11475 - -// I KILL! -#define SAY_ENRAGE "You've wasted too much time mortals, now you shall fall!" -#define SOUND_ENRAGE 11474 - -/************** Spells *************/ -// Normal Form -#define SPELL_SHEAR 41032 // Reduces Max. Health by 60% for 7 seconds. Can stack 19 times. 1.5 second cast -#define SPELL_FLAME_CRASH 40832 // Summons an invis/unselect passive mob that has an aura of flame in a circle around him. -#define SPELL_DRAW_SOUL 40904 // 5k Shadow Damage in front of him. Heals Illidan for 100k health (script effect) -#define SPELL_PARASITIC_SHADOWFIEND 41917 // DoT of 3k Shadow every 2 seconds. Lasts 10 seconds. (Script effect: Summon 2 parasites once the debuff has ticked off) -#define SPELL_SUMMON_PARASITICS 41915 // Summons 2 Parasitic Shadowfiends on the target. It's supposed to be cast as soon as the Parasitic Shadowfiend debuff is gone, but the spells aren't linked :( -#define SPELL_AGONIZING_FLAMES 40932 // 4k fire damage initial to target and anyone w/i 5 yards. PHASE 3 ONLY -#define SPELL_ENRAGE 40683 // Increases damage by 50% and attack speed by 30%. 20 seconds, PHASE 5 ONLY -// Flying (Phase 2) -#define SPELL_THROW_GLAIVE 39635 // Throws a glaive on the ground -#define SPELL_THROW_GLAIVE2 39849 // Animation for the above spell -#define SPELL_GLAIVE_RETURNS 39873 // Glaive flies back to Illidan -#define SPELL_FIREBALL 40598 // 2.5k-3.5k damage in 10 yard radius. 2 second cast time. -#define SPELL_DARK_BARRAGE 40585 // 10 second channeled spell, 3k shadow damage per second. -// Demon Form -#define SPELL_DEMON_TRANSFORM_1 40511 // First phase of animations for transforming into Dark Illidan (fall to ground) -#define SPELL_DEMON_TRANSFORM_2 40398 // Second phase of animations (kneel) -#define SPELL_DEMON_TRANSFORM_3 40510 // Final phase of animations (stand up and roar) -#define SPELL_DEMON_FORM 40506 // Transforms into Demon Illidan. Has an Aura of Dread on him. -#define SPELL_SHADOW_BLAST 41078 // 8k - 11k Shadow Damage. Targets highest threat. Has a splash effect, damaging anyone in 20 yards of the target. -#define SPELL_FLAME_BURST 41126 // Hurls fire at entire raid for ~3.5k damage every 10 seconds. Resistable. (Does not work: Script effect) -#define SPELL_FLAME_BURST_EFFECT 41131 // The actual damage. Handled by core (41126 triggers 41131) -// Other Illidan spells -#define SPELL_KNEEL 39656 // Before beginning encounter, this is how he appears (talking to Wilson). -#define SPELL_SHADOW_PRISON 40647 // Illidan casts this spell to immobilize entire raid when he summons Maiev. -#define SPELL_DEATH 41220 // This spell doesn't do anything except stun Illidan and set him on his knees. -#define SPELL_BERSERK 45078 // Damage increased by 500%, attack speed by 150% - -// Non-Illidan spells -#define SPELL_AKAMA_DOOR_CHANNEL 41268 // Akama's channel spell on the door before the Temple Summit -#define SPELL_DEATHSWORN_DOOR_CHANNEL 41269 // Olum and Udalo's channel spell on the door before the Temple Summit -#define SPELL_AKAMA_DOOR_FAIL 41271 // Not sure where this is really used... -#define SPELL_HEALING_POTION 40535 // Akama uses this to heal himself to full. -#define SPELL_AZZINOTH_CHANNEL 39857 // Glaives cast it on Flames. Not sure if this is the right spell. -#define SPELL_SHADOW_DEMON_PASSIVE 41079 // Adds the "shadowform" aura to Shadow Demons. -#define SPELL_CONSUME_SOUL 41080 // Once the Shadow Demons reach their target, they use this to kill them -#define SPELL_PARALYZE 41083 // Shadow Demons cast this on their target -#define SPELL_PURPLE_BEAM 39123 // Purple Beam connecting Shadow Demon to their target -#define SPELL_CAGE_TRAP_DUMMY 40761 // Put this in DB for cage trap GO. -#define SPELL_EYE_BLAST_TRIGGER 40017 // This summons Demon Form every few seconds and deals ~20k damage in its radius -#define SPELL_EYE_BLAST 39908 // This does the blue flamey animation. -#define SPELL_FLAME_CRASH_EFFECT 40836 // Firey blue ring of circle that the other flame crash summons -#define SPELL_BLAZE_EFFECT 40610 // Green flame on the ground, triggers damage (5k) every few seconds -#define SPELL_BLAZE_SUMMON 40637 // Summons the Blaze creature -#define SPELL_DEMON_FIRE 40029 // Blue fire trail left by Eye Blast. Deals 2k per second if players stand on it. -#define SPELL_CAGED 40695 // Caged Trap triggers will cast this on Illidan if he is within 3 yards -#define SPELL_CAGE_TRAP_SUMMON 40694 // Summons a Cage Trap GO (bugged) on the ground along with a Cage Trap Disturb Trigger mob (working) -#define SPELL_CAGE_TRAP_BEAM 40713 // 8 Triggers on the ground in an octagon cast spells like this on Illidan 'caging him' -#define SPELL_FLAME_BLAST 40631 // Flames of Azzinoth use this. Frontal cone AoE 7k-9k damage. -#define SPELL_CHARGE 40602 // Flames of Azzinoth charges whoever is too far from them. They enrage after this. For simplicity, we'll use the same enrage as Illidan. -#define SPELL_TELEPORT_VISUAL 41232 // Teleport visual for Maiev -#define SPELL_SHADOWFIEND_PASSIVE 41913 // Passive aura for shadowfiends - -// Other defines -#define CENTER_X 676.740 -#define CENTER_Y 305.297 -#define CENTER_Z 353.192 - -/**** Creature Summon and Recognition IDs ****/ -enum CreatureEntry -{ - EMPTY = 0, - AKAMA = 22990, - ILLIDAN_STORMRAGE = 22917, - BLADE_OF_AZZINOTH = 22996, - FLAME_OF_AZZINOTH = 22997, - MAIEV_SHADOWSONG = 23197, - SHADOW_DEMON = 23375, - DEMON_FIRE = 23069, - FLAME_CRASH = 23336, - ILLIDAN_DOOR_TRIGGER = 23412, - SPIRIT_OF_OLUM = 23411, - SPIRIT_OF_UDALO = 23410, - ILLIDARI_ELITE = 23226, - PARASITIC_SHADOWFIEND = 23498, - CAGE_TRAP_TRIGGER = 23292, -}; - -/*** Phase Names ***/ -enum Phase -{ - PHASE_NORMAL = 1, - PHASE_FLIGHT = 2, - PHASE_NORMAL_2 = 3, - PHASE_DEMON = 4, - PHASE_NORMAL_MAIEV = 5, - PHASE_DEMON_SEQUENCE = 6, -}; - -struct Yells -{ - uint32 sound; - char* text; - uint32 creature, timer, emote; - bool Talk; -}; - -static Yells Conversation[]= -{ - {11463, "Akama... your duplicity is hardly surprising. I should have slaughtered you and your malformed brethren long ago.", ILLIDAN_STORMRAGE, 8000, 0, true}, - {0, NULL, ILLIDAN_STORMRAGE, 5000, 396, true}, - {11389, "We've come to end your reign, Illidan. My people and all of Outland shall be free!", AKAMA, 7000, 25, true}, - {0, NULL, AKAMA, 5000, 66, true}, - {11464, "Boldly said. But I remain unconvinced.", ILLIDAN_STORMRAGE, 8000, 396, true}, - {11380, "The time has come! The moment is at hand!", AKAMA, 3000, 22, true}, - {0, NULL, AKAMA, 2000, 15, true}, - {11466, "You are not prepared!", ILLIDAN_STORMRAGE, 3000, 406, true}, - {0, NULL, EMPTY, 1000, 0, true}, - {0, NULL, EMPTY, 0, 0, false}, - {11476, "Is this it, mortals? Is this all the fury you can muster?", ILLIDAN_STORMRAGE, 8000, 0, true}, - {11491, "Their fury pales before mine, Illidan. We have some unsettled business between us.", MAIEV_SHADOWSONG, 8000, 5, true}, - {11477, "Maiev... How is this even possible?", ILLIDAN_STORMRAGE, 7000, 1, true}, - {11492, "Ah... my long hunt is finally over. Today, Justice will be done!", MAIEV_SHADOWSONG, 8000, 15, true}, - {11470, "Feel the hatred of ten thousand years!", ILLIDAN_STORMRAGE, 1000, 0, false}, - {11496, "Ahh... It is finished. You are beaten.", MAIEV_SHADOWSONG, 6000, 0, true}, - { // Emote dead for now. Kill him later - 11478, "You have won... Maiev...but the huntress... is nothing...without the hunt... you... are nothing... without me..", ILLIDAN_STORMRAGE, 22000, 65, true - }, - {11497, "He is right. I feel nothing... I am nothing... Farewell, champions.", MAIEV_SHADOWSONG, 9000, 0, true}, - {11498, NULL, MAIEV_SHADOWSONG, 0, true}, - {11387, "The Light will fill these dismal halls once again. I swear it.", AKAMA, 8000, 0, true}, - {0, NULL, EMPTY, 1000, 0, false} -}; - -static Yells RandomTaunts[]= -{ - {11467, "I can feel your hatred.", ILLIDAN_STORMRAGE, 0, 0, false}, - {11468, "Give in to your fear!", ILLIDAN_STORMRAGE, 0, 0, false}, - {11469, "You know nothing of power!", ILLIDAN_STORMRAGE, 0, 0, false}, - {11471, "Such... arrogance!", ILLIDAN_STORMRAGE, 0, 0, false} -}; - -static Yells MaievTaunts[]= -{ - {11493, "That is for Naisha!", MAIEV_SHADOWSONG, 0, false}, - {11494, "Bleed as I have bled!", MAIEV_SHADOWSONG, 0, 0, false}, - {11495, "There shall be no prison for you this time!", MAIEV_SHADOWSONG, 0, 0, false}, - {11500, "Meet your end, demon!", MAIEV_SHADOWSONG, 0, 0, false} -}; - -struct Locations -{ - float x, y, z; - uint32 id; -}; - -static Locations GlaivePosition[]= -{ - {695.105, 305.303, 354.256}, - {659.338, 305.303, 354.256}, - {700.105, 305.303, 354.256}, - {664.338, 305.303, 354.256} -}; - -static Locations EyeBlast[]= -{ - {650.697, 320.128, 353.730}, - {652.799, 275.091, 353.367}, - {701.527, 273.815, 353.230}, - {709.865, 325.654, 353.322} -}; - -static Locations AkamaWP[]= -{ - { 770.01, 304.50, 312.29 }, // Bottom of the first stairs, at the doors - { 780.66, 304.50, 319.74 }, // Top of the first stairs - { 790.13, 319.68, 319.76 }, // Bottom of the second stairs (left from the entrance) - { 787.17, 347.38, 341.42 }, // Top of the second stairs - { 781.34, 350.31, 341.44 }, // Bottom of the third stairs - { 762.60, 361.06, 353.60 }, // Top of the third stairs - { 756.35, 360.52, 353.27 }, // Before the door-thingy - { 743.82, 342.21, 353.00 }, // Somewhere further - { 732.69, 305.13, 353.00 }, // In front of Illidan - { 738.11, 365.44, 353.00 }, // in front of the door-thingy (the other one!) - { 792.18, 366.62, 341.42 }, // Down the first flight of stairs - { 796.84, 304.89, 319.76 }, // Down the second flight of stairs - { 782.01, 304.55, 319.76 } // Final location - back at the initial gates. This is where he will fight the minions! -}; -// 755.762, 304.0747, 312.1769 -- This is where Akama should be spawned -static Locations SpiritSpawns[]= -{ - {755.5426, 309.9156, 312.2129, SPIRIT_OF_UDALO}, - {755.5426, 298.7923, 312.0834, SPIRIT_OF_OLUM} -}; - -struct WayPoints -{ - WayPoints(uint32 _id, float _x, float _y, float _z) - { - id = _id; - x = _x; - y = _y; - z = _z; - } - uint32 id; - float x, y, z; -}; - -struct Animation // For the demon transformation -{ - uint32 aura, unaura, timer, size, displayid, phase; - bool equip; -}; - -static Animation DemonTransformation[]= -{ - {SPELL_DEMON_TRANSFORM_1, 0, 1300, 0, 0, 6, true}, - {SPELL_DEMON_TRANSFORM_2, SPELL_DEMON_TRANSFORM_1, 4000, 0, 0, 6, true}, - {SPELL_DEMON_FORM, 0, 3000, 1073741824, 21322, 6, false}, - {SPELL_DEMON_TRANSFORM_3, SPELL_DEMON_TRANSFORM_2, 3500, 0, 0, 6, false}, - {0, 0, 0, 0, 0, 4, false}, - {SPELL_DEMON_TRANSFORM_1, 0, 1500, 0, 0, 6, false}, - {SPELL_DEMON_TRANSFORM_2, SPELL_DEMON_TRANSFORM_1, 4000, 0, 0, 6, false}, - {0, SPELL_DEMON_FORM, 3000, 1069547520, 21135, 6, false}, - {SPELL_DEMON_TRANSFORM_3, SPELL_DEMON_TRANSFORM_2, 3500, 0, 0, 6, true}, - {0, 0, 0, 0, 0, 8, true} -}; - -/**** Demon Fire will be used for Eye Blast. Illidan needs to have access to it's vars and functions, so we'll set it here ****/ -struct MANGOS_DLL_DECL demonfireAI : public ScriptedAI -{ - demonfireAI(Creature *c) : ScriptedAI(c) - { - pInstance = ((ScriptedInstance*)c->GetInstanceData()); - Reset(); - } - - ScriptedInstance* pInstance; - - uint64 IllidanGUID; - - bool IsTrigger; - - uint32 CheckTimer; - uint32 DemonFireTimer; - uint32 DespawnTimer; - - void Reset() - { - IllidanGUID = 0; - - IsTrigger = false; - - CheckTimer = 2000; - DemonFireTimer = 0; - DespawnTimer = 45000; - } - - void Aggro(Unit *who) {} - void AttackStart(Unit* who) { } - void MoveInLineOfSight(Unit *who){ } - - void UpdateAI(const uint32 diff) - { - if(IsTrigger) - return; - - m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - - if(CheckTimer < diff) - { - if(!IllidanGUID && pInstance) - { - IllidanGUID = pInstance->GetData64(DATA_ILLIDANSTORMRAGE); - if(IllidanGUID) - { - Unit* Illidan = Unit::GetUnit((*m_creature), IllidanGUID); - if(Illidan && !Illidan->HasUnitMovementFlag(MOVEMENTFLAG_LEVITATING)) - m_creature->setDeathState(JUST_DIED); - } - } - CheckTimer = 2000; - }else CheckTimer -= diff; - - if(DemonFireTimer < diff) - { - DoCast(m_creature, SPELL_DEMON_FIRE); - DemonFireTimer = 30000; - }else DemonFireTimer -= diff; - - if(DespawnTimer < diff) - m_creature->setDeathState(JUST_DIED); - else DespawnTimer -= diff; - - DoMeleeAttackIfReady(); - } -}; - -/******* Functions and vars for Akama's AI ******/ -struct MANGOS_DLL_SPEC npc_akama_illidanAI : public ScriptedAI -{ - npc_akama_illidanAI(Creature* c) : ScriptedAI(c) - { - pInstance = ((ScriptedInstance*)c->GetInstanceData()); - WayPointList.clear(); - Reset(); - } - - /* Instance Data */ - ScriptedInstance* pInstance; - - /* Timers */ - uint32 ChannelTimer; - uint32 TalkTimer; - uint32 WalkTimer; - uint32 SummonMinionTimer; - - /* GUIDs */ - uint64 IllidanGUID; - uint64 PlayerGUID; - uint64 SpiritGUID[2]; - uint64 ChannelGUID; - - bool IsTalking; - bool StartChanneling; - bool DoorOpen; - bool FightMinions; - bool IsReturningToIllidan; - bool IsWalking; - uint32 TalkCount; - uint32 ChannelCount; - - std::list WayPointList; - std::list::iterator WayPoint; - - void BeginEvent(uint64 PlayerGUID); - void Aggro(Unit *who) {} - - void Reset() - { - if(pInstance) - { - pInstance->SetData(DATA_ILLIDANSTORMRAGEEVENT, NOT_STARTED); - GameObject* Gate = GameObject::GetGameObject((*m_creature), pInstance->GetData64(DATA_GAMEOBJECT_ILLIDAN_GATE)); - if( Gate && !Gate->GetGoState() ) - Gate->SetGoState(1); // close door if already open (when raid wipes or something) - - for(uint8 i = DATA_GAMEOBJECT_ILLIDAN_DOOR_R; i < DATA_GAMEOBJECT_ILLIDAN_DOOR_L + 1; ++i) - { - GameObject* Door = GameObject::GetGameObject((*m_creature), pInstance->GetData64(i)); - if(Door) - Door->SetGoState(0); - } - } - - IllidanGUID = 0; - PlayerGUID = 0; - ChannelGUID = 0; - for(uint8 i = 0; i < 2; ++i) SpiritGUID[i] = 0; - - ChannelTimer = 0; - ChannelCount = 0; - SummonMinionTimer = 2000; - - WalkTimer = 0; - - TalkTimer = 0; - TalkCount = 0; - - KillAllElites(); - - IsReturningToIllidan = false; - FightMinions = false; - IsTalking = false; - StartChanneling = false; - DoorOpen = false; - - m_creature->SetUInt32Value(UNIT_NPC_FLAGS, 0); // Database sometimes has strange values.. - m_creature->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP); - m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); - m_creature->SetVisibility(VISIBILITY_ON); - } - - // Do not call reset in Akama's evade mode, as this will stop him from summoning minions after he kills the first bit - void EnterEvadeMode() - { - InCombat = false; - - m_creature->RemoveAllAuras(); - m_creature->DeleteThreatList(); - m_creature->CombatStop(); - } - - void KillAllElites() - { - std::list::iterator itr; - for(itr = m_creature->getThreatManager().getThreatList().begin(); itr != m_creature->getThreatManager().getThreatList().end(); ++itr) - { - Unit* pUnit = Unit::GetUnit((*m_creature), (*itr)->getUnitGuid()); - if(pUnit && (pUnit->GetTypeId() == TYPEID_UNIT) && (pUnit->GetEntry() == ILLIDARI_ELITE)) - pUnit->setDeathState(JUST_DIED); - } - } - - void ReturnToIllidan() - { - KillAllElites(); - InCombat = false; - FightMinions = false; - IsReturningToIllidan = true; - WayPoint = WayPointList.begin(); - m_creature->SetSpeed(MOVE_RUN, 2.0f); - m_creature->RemoveUnitMovementFlag(MOVEMENTFLAG_WALK_MODE); - IsWalking = true; - } - - void AddWaypoint(uint32 id, float x, float y, float z) - { - WayPoints AkamaWP(id, x, y, z); - WayPointList.push_back(AkamaWP); - } - - void DamageTaken(Unit *done_by, uint32 &damage) - { - if(damage > m_creature->GetHealth() && (done_by->GetGUID() != m_creature->GetGUID())) - { - damage = 0; - DoCast(m_creature, SPELL_HEALING_POTION); - } - } - - void BeginDoorEvent(Player* player) - { - if(!pInstance) - return; - - outstring_log("SD2: Akama - Door event initiated by player %s", player->GetName()); - PlayerGUID = player->GetGUID(); - - GameObject* Gate = GameObject::GetGameObject((*m_creature), pInstance->GetData64(DATA_GAMEOBJECT_ILLIDAN_GATE)); - if(Gate) - { - float x,y,z; - Gate->GetPosition(x, y, z); - Creature* Channel = m_creature->SummonCreature(ILLIDAN_DOOR_TRIGGER, x, y, z+5, 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 360000); - if(Channel) - { - ChannelGUID = Channel->GetGUID(); - // Invisible but spell visuals can still be seen. - Channel->SetUInt32Value(UNIT_FIELD_DISPLAYID, 11686); - Channel->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - float PosX, PosY, PosZ; - m_creature->GetPosition(PosX, PosY, PosZ); - for(uint8 i = 0; i < 2; ++i) - { - Creature* Spirit = m_creature->SummonCreature(SpiritSpawns[i].id, SpiritSpawns[i].x, SpiritSpawns[i].y, SpiritSpawns[i].z, 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 360000); - if(Spirit) - { - Spirit->SetVisibility(VISIBILITY_OFF); - SpiritGUID[i] = Spirit->GetGUID(); - } - } - StartChanneling = true; - m_creature->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP); - m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); - DoCast(Channel, SPELL_AKAMA_DOOR_FAIL); - } - } - } - - void MovementInform(uint32 type, uint32 id) - { - if(type != POINT_MOTION_TYPE || !IsWalking) - return; - - if(WayPoint->id != id) - return; - - switch(id) - { - case 6: - if(!IsReturningToIllidan) - { // open the doors that close the summit - for(uint32 i = DATA_GAMEOBJECT_ILLIDAN_DOOR_R; i < DATA_GAMEOBJECT_ILLIDAN_DOOR_L+1; ++i) - { - GameObject* Door = GameObject::GetGameObject((*m_creature), pInstance->GetData64(i)); - if(Door) - Door->SetGoState(0); - } - } - case 7: - if(IsReturningToIllidan) - { - IsWalking = false; - if(IllidanGUID) - { - Unit* Illidan = Unit::GetUnit((*m_creature), IllidanGUID); - if(Illidan) - { - float dx = Illidan->GetPositionX() + rand()%15; - float dy = Illidan->GetPositionY() + rand()%15; - m_creature->GetMotionMaster()->MovePoint(13, dx, dy, Illidan->GetPositionZ()); - m_creature->SetUInt64Value(UNIT_FIELD_TARGET, IllidanGUID); - } - } - } - break; - case 8: - m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); - if(!IsReturningToIllidan) - { - IsWalking = false; - BeginEvent(PlayerGUID); - } - break; - case 12: - IsWalking = false; - FightMinions = true; - m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); - break; - } - - ++WayPoint; - WalkTimer = 200; - } - - void DeleteFromThreatList() - { - if(!IllidanGUID) return; // If we do not have Illidan's GUID, do not proceed - // Create a pointer to Illidan - Creature* Illidan = ((Creature*)Unit::GetUnit((*m_creature), IllidanGUID)); - if(!Illidan) return; // No use to continue if Illidan does not exist - std::list::iterator itr = Illidan->getThreatManager().getThreatList().begin(); - for( ; itr != Illidan->getThreatManager().getThreatList().end(); ++itr) - { - // Loop through threatlist till our GUID is found in it. - if((*itr)->getUnitGuid() == m_creature->GetGUID()) - { - (*itr)->removeReference(); // Delete ourself from his threatlist. - return; // No need to continue anymore. - } - } - - // Now we delete our threatlist to prevent attacking anyone for now - m_creature->DeleteThreatList(); - } - - void UpdateAI(const uint32 diff) - { - if(IllidanGUID) - { - Creature* Illidan = ((Creature*)Unit::GetUnit((*m_creature), IllidanGUID)); - if(Illidan) - { - if(Illidan->IsInEvadeMode() && !m_creature->IsInEvadeMode()) - EnterEvadeMode(); - - if(((Illidan->GetHealth()*100 / Illidan->GetMaxHealth()) < 85) && InCombat && !FightMinions) - { - if(TalkTimer < diff) - { - switch(TalkCount) - { - case 0: - Illidan->Yell(SAY_AKAMA_MINION, LANG_UNIVERSAL, 0); - DoPlaySoundToSet(Illidan, SOUND_AKAMA_MINION); - TalkTimer = 8000; - TalkCount = 1; - break; - case 1: - DoYell(SAY_AKAMA_LEAVE, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_AKAMA_LEAVE); - TalkTimer = 3000; - TalkCount = 2; - break; - case 2: - IsTalking = true; - TalkTimer = 2000; - m_creature->RemoveAllAuras(); - m_creature->CombatStop(); - m_creature->AttackStop(); - m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); - TalkCount = 3; - break; - case 3: - DeleteFromThreatList(); - IsWalking = true; - WayPoint = WayPointList.begin(); - std::advance(WayPoint, 9); - m_creature->RemoveUnitMovementFlag(MOVEMENTFLAG_WALK_MODE); - break; - } - }else TalkTimer -= diff; - } - - if(((Illidan->GetHealth()*100 / Illidan->GetMaxHealth()) < 4) && !IsReturningToIllidan) - ReturnToIllidan(); - } - }else - { - if(pInstance) - IllidanGUID = pInstance->GetData64(DATA_ILLIDANSTORMRAGE); - } - - if(IsWalking && WalkTimer) - { - if(WalkTimer <= diff) - { - if(WayPoint == WayPointList.end()) - return; - m_creature->GetMotionMaster()->MovePoint(WayPoint->id, WayPoint->x, WayPoint->y,WayPoint->z); - WalkTimer = 0; - }else WalkTimer -= diff; - } - - if(StartChanneling) - { - if(ChannelTimer < diff) - { - switch(ChannelCount) - { - case 3: - if(!DoorOpen) - { - m_creature->InterruptNonMeleeSpells(true); - for(uint8 i = 0; i < 2; ++i) - { - if(SpiritGUID[i]) - { - Unit* Spirit = Unit::GetUnit((*m_creature), SpiritGUID[i]); - if(Spirit) - Spirit->InterruptNonMeleeSpells(true); - } - } - GameObject* Gate = GameObject::GetGameObject((*m_creature), pInstance->GetData64(DATA_GAMEOBJECT_ILLIDAN_GATE)); - if(Gate) - Gate->SetGoState(0); - ChannelCount++; - ChannelTimer = 5000; - } - break; - case 4: - m_creature->HandleEmoteCommand(EMOTE_ONESHOT_SALUTE); - ChannelTimer = 2000; - ChannelCount++; - break; - case 5: - DoYell(SAY_AKAMA_BEWARE, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_AKAMA_BEWARE); - if(ChannelGUID) - { - Unit* ChannelTarget = Unit::GetUnit((*m_creature), ChannelGUID); - if(ChannelTarget) - ChannelTarget->setDeathState(JUST_DIED); - } - for(uint8 i = 0; i < 2; ++i) - { - if(SpiritGUID[i]) - { - Unit* Spirit = Unit::GetUnit((*m_creature), SpiritGUID[i]); - if(Spirit) - Spirit->setDeathState(JUST_DIED); - } - } - ChannelTimer = 6000; - ChannelCount++; - break; - case 6: - StartChanneling = false; - if(WayPointList.empty()) - { - error_log("SD2: Akama has no waypoints to start with!"); - return; - } - - WayPoint = WayPointList.begin(); - m_creature->AddUnitMovementFlag(MOVEMENTFLAG_WALK_MODE); - m_creature->GetMotionMaster()->MovePoint(WayPoint->id, WayPoint->x, WayPoint->y, WayPoint->z); - IsWalking = true; - break; - default: - if(ChannelGUID) - { - Unit* Channel = Unit::GetUnit((*m_creature), ChannelGUID); - if(Channel) - { - m_creature->InterruptNonMeleeSpells(true); - - for(uint8 i = 0; i < 2; ++i) - { - if(SpiritGUID[i]) - { - Unit* Spirit = Unit::GetUnit((*m_creature), SpiritGUID[i]); - if(Spirit) - { - Spirit->InterruptNonMeleeSpells(true); - if(ChannelCount%2 == 0) - { - Spirit->CastSpell(Channel, SPELL_DEATHSWORN_DOOR_CHANNEL,false); - DoCast(Channel, SPELL_AKAMA_DOOR_CHANNEL); - } - else - { - if(Spirit->GetVisibility() == VISIBILITY_OFF) - Spirit->SetVisibility(VISIBILITY_ON); - } - } - } - } - if(ChannelCount < 3) - ChannelCount++; - ChannelTimer = 10000; - } - break; - } - } - }else ChannelTimer -= diff; - } - - if(FightMinions) - { - if(SummonMinionTimer < diff) - { - if(IllidanGUID) - { - Creature* Illidan = ((Creature*)Unit::GetUnit((*m_creature), IllidanGUID)); - if(!Illidan || Illidan->IsInEvadeMode()) - { - Reset(); - EnterEvadeMode(); - return; - } - } - - float x,y,z; - m_creature->GetPosition(x,y,z); - Creature* Elite = m_creature->SummonCreature(ILLIDARI_ELITE, x+rand()%10, y+rand()%10, z, 0, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 30000); - if(Elite) - { - Elite->AI()->AttackStart(m_creature); - Elite->AddThreat(m_creature, 1000000.0f); - AttackStart(Elite); - } - SummonMinionTimer = 10000 + rand()%6000; - }else SummonMinionTimer -= diff; - } - - // If we don't have a target, or is talking, or has run away, return - if(!m_creature->SelectHostilTarget() || !m_creature->getVictim()) return; - - DoMeleeAttackIfReady(); - } -}; - -/************* Custom check used for Agonizing Flames ***************/ -class AgonizingFlamesTargetCheck -{ - public: - AgonizingFlamesTargetCheck(Unit const* unit) : pUnit(unit) {} - bool operator() (Player* plr) - { - // Faster than square rooting - if(!plr->isGameMaster() && pUnit->GetDistance2d(plr) > 225) - return true; - - return false; - } - - private: - Unit const* pUnit; -}; - -/************************************** Illidan's AI ***************************************/ -struct MANGOS_DLL_SPEC boss_illidan_stormrageAI : public ScriptedAI -{ - boss_illidan_stormrageAI(Creature* c) : ScriptedAI(c) - { - pInstance = ((ScriptedInstance*)c->GetInstanceData()); - Reset(); - } - - /** Instance Data **/ - ScriptedInstance* pInstance; - - /** Generic **/ - bool IsTalking; - bool HasSummoned; - bool RefaceVictim; - bool InformAkama; - uint32 Phase; - uint32 GlobalTimer; - uint32 TalkCount; - uint32 DemonFormSequence; - - /** GUIDs **/ - uint64 FlameGUID[2]; - uint64 GlaiveGUID[2]; - uint64 AkamaGUID; - uint64 MaievGUID; - - /** Timers **/ - uint32 ShearTimer; - uint32 DrawSoulTimer; - uint32 FlameCrashTimer; - uint32 ParasiticShadowFiendTimer; - uint32 FireballTimer; - uint32 EyeBlastTimer; - uint32 DarkBarrageTimer; - uint32 SummonBladesTimer; // Animate summoning the Blades of Azzinoth in Phase 2 - uint32 SummonFlamesTimer; // Summon Flames of Azzinoth in Phase 2 - uint32 CheckFlamesTimer; // This is used to check the status of the Flames to see if we should begin entering Phase 3 or not. - uint32 RetrieveBladesTimer; // Animate retrieving the Blades of Azzinoth in Phase 2 -> 3 transition - uint32 LandTimer; // This is used at the end of phase 2 to signal Illidan landing after Flames are dead - uint32 AgonizingFlamesTimer; - uint32 ShadowBlastTimer; - uint32 FlameBurstTimer; - uint32 ShadowDemonTimer; - uint32 TalkTimer; - uint32 TransformTimer; - uint32 EnrageTimer; - uint32 CageTimer; - uint32 LayTrapTimer; - uint32 AnimationTimer; - uint32 TauntTimer; // This is used for his random yells - uint32 FaceVictimTimer; - uint32 BerserkTimer; - - void Reset() - { - Phase = PHASE_NORMAL; - - // Check if any flames/glaives are alive/existing. Kill if alive and set GUIDs to 0 - for(uint8 i = 0; i < 2; i++) - { - if(FlameGUID[i]) - { - Unit* Flame = Unit::GetUnit((*m_creature), FlameGUID[i]); - if(Flame) - Flame->setDeathState(JUST_DIED); - FlameGUID[i] = 0; - } - - if(GlaiveGUID[i]) - { - Unit* Glaive = Unit::GetUnit((*m_creature), GlaiveGUID[i]); - if(Glaive) - Glaive->setDeathState(JUST_DIED); - GlaiveGUID[i] = 0; - } - } - - if(AkamaGUID) - { - Creature* Akama = ((Creature*)Unit::GetUnit((*m_creature), AkamaGUID)); - if(Akama) - { - if(!Akama->isAlive()) - Akama->Respawn(); - ((npc_akama_illidanAI*)Akama->AI())->Reset(); - ((npc_akama_illidanAI*)Akama->AI())->EnterEvadeMode(); - Akama->GetMotionMaster()->MoveTargetedHome(); - } - } - - InformAkama = false; - RefaceVictim = false; - HasSummoned = false; - AkamaGUID = 0; - MaievGUID = 0; - - FaceVictimTimer = 1000; - BerserkTimer = 1500000; - GlobalTimer = 0; - DemonFormSequence = 0; - - /** Normal Form **/ - ShearTimer = 20000 + (rand()%11 * 1000); // 20 to 30 seconds - FlameCrashTimer = 30000; //30 seconds - ParasiticShadowFiendTimer = 25000; // 25 seconds - DrawSoulTimer = 50000; // 50 seconds - - /** Phase 2 **/ - SummonBladesTimer = 10000; - SummonFlamesTimer = 20000; // Phase 2 timers may be incorrect - FireballTimer = 5000; - DarkBarrageTimer = 45000; - EyeBlastTimer = 30000; - CheckFlamesTimer = 5000; - RetrieveBladesTimer = 5000; - LandTimer = 0; - - /** Phase 3+ **/ - AgonizingFlamesTimer = 35000; // Phase 3+ timers may be incorrect - ShadowBlastTimer = 3000; - FlameBurstTimer = 10000; - ShadowDemonTimer = 30000; - TransformTimer = 90000; - EnrageTimer = 40000; - CageTimer = 30000; - LayTrapTimer = CageTimer + 2000; - AnimationTimer = 0; - - TauntTimer = 30000; // This timer may be off. - - m_creature->SetUInt32Value(UNIT_FIELD_DISPLAYID, 21135); - m_creature->InterruptNonMeleeSpells(false); - m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); - m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - // Unequip warglaives if needed - m_creature->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_DISPLAY, 0); - m_creature->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_DISPLAY+1, 0); - m_creature->RemoveUnitMovementFlag(MOVEMENTFLAG_LEVITATING); - - IsTalking = false; - - TalkCount = 0; - TalkTimer = 0; - - if(pInstance) - pInstance->SetData(DATA_ILLIDANSTORMRAGEEVENT, NOT_STARTED); - } - - void Aggro(Unit *who) { DoZoneInCombat(); } - - void AttackStart(Unit *who) - { - if(!who || IsTalking || Phase == 2 || Phase == 4 || Phase == 6 || m_creature->HasAura(SPELL_KNEEL, 0)) - return; - - if (who->isTargetableForAttack() && who!= m_creature) - { - //Begin melee attack if we are within range - DoStartAttackAndMovement(who); - } - } - - void MoveInLineOfSight(Unit *who) - { - if (!who || m_creature->getVictim() || IsTalking || m_creature->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE)) - return; - - if (who->isTargetableForAttack() && who->isInAccessablePlaceFor(m_creature) && m_creature->IsHostileTo(who)) - { - float attackRadius = m_creature->GetAttackDistance(who); - if (m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->GetDistanceZ(who) <= CREATURE_Z_ATTACK_RANGE && m_creature->IsWithinLOSInMap(who)) - { - if(who->HasStealthAura()) - who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); - - DoStartAttackAndMovement(who); - } - } - } - - void JustDied(Unit *killer) - { - IsTalking = false; - TalkCount = 0; - TalkTimer = 0; - - m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - - if(!pInstance) - return; - // Completed - pInstance->SetData(DATA_ILLIDANSTORMRAGEEVENT, DONE); - - for(uint8 i = DATA_GAMEOBJECT_ILLIDAN_DOOR_R; i < DATA_GAMEOBJECT_ILLIDAN_DOOR_L + 1; ++i) - { - GameObject* Door = GameObject::GetGameObject((*m_creature), pInstance->GetData64(i)); - if(Door) - Door->SetGoState(0); // Open Doors - } - - } - - void KilledUnit(Unit *victim) - { - if(victim == m_creature) return; - - switch(rand()%2) - { - case 0: - DoYell(SAY_KILL1, LANG_UNIVERSAL, victim); - DoPlaySoundToSet(m_creature, SOUND_KILL1); - break; - case 1: - DoYell(SAY_KILL2, LANG_UNIVERSAL, victim); - DoPlaySoundToSet(m_creature, SOUND_KILL2); - break; - } - } - - void DamageTaken(Unit *done_by, uint32 &damage) - { - if(damage > m_creature->GetHealth()) // Don't let ourselves be slain before we do our death speech - { - damage = 0; - m_creature->SetHealth(m_creature->GetMaxHealth()/100); - } - } - - void Cast(Unit* victim, uint32 Spell, bool triggered = false) - { - if(!victim) - return; - - RefaceVictim = true; - m_creature->SetUInt64Value(UNIT_FIELD_TARGET, victim->GetGUID()); - m_creature->CastSpell(victim, Spell, triggered); - } - - /** This will handle the cast of eye blast **/ - void CastEyeBlast() - { - m_creature->InterruptNonMeleeSpells(false); - - DarkBarrageTimer += 10000; - - DoYell(SAY_EYE_BLAST, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_EYE_BLAST); - - uint32 initial = rand()%4; - uint32 final = 0; - if(initial < 3) - final = initial+1; - - float initial_X = EyeBlast[initial].x; - float initial_Y = EyeBlast[initial].y; - float initial_Z = EyeBlast[initial].z; - - float final_X = EyeBlast[final].x; - float final_Y = EyeBlast[final].y; - float final_Z = EyeBlast[final].z; - - for(uint8 i = 0; i < 2; ++i) - { - Creature* Trigger = NULL; - Trigger = m_creature->SummonCreature(DEMON_FIRE, initial_X, initial_Y, initial_Z, 0, TEMPSUMMON_TIMED_DESPAWN, 20000); - if(Trigger) - { - ((demonfireAI*)Trigger->AI())->IsTrigger = true; - Trigger->GetMotionMaster()->MovePoint(0, final_X, final_Y, final_Z); - - if(!i) - Trigger->CastSpell(Trigger, SPELL_EYE_BLAST_TRIGGER, true); - else - { - Trigger->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - m_creature->SetUInt64Value(UNIT_FIELD_TARGET, Trigger->GetGUID()); - DoCast(Trigger, SPELL_EYE_BLAST); - } - } - } - } - - // It's only cast on players that are greater than 15 yards away from Illidan. If no one is found, cast it on MT instead (since selecting someone in that 15 yard radius would cause the flames to hit the MT anyway). - void CastAgonizingFlames() - { - // We'll use grid searching for this, using a custom searcher that selects a player that is at a distance >15 yards - Player* target = NULL; - - CellPair pair(MaNGOS::ComputeCellPair(m_creature->GetPositionX(), m_creature->GetPositionY())); - Cell cell(pair); - cell.data.Part.reserved = ALL_DISTRICT; - cell.SetNoCreate(); - - AgonizingFlamesTargetCheck check(m_creature); - MaNGOS::PlayerSearcher searcher(target, check); - TypeContainerVisitor - , GridTypeMapContainer> visitor(searcher); - - CellLock cell_lock(cell, pair); - cell_lock->Visit(cell_lock, visitor, *(m_creature->GetMap())); - - if(target) - DoCast(target, SPELL_AGONIZING_FLAMES); - else - DoCast(m_creature->getVictim(), SPELL_AGONIZING_FLAMES); - } - - void Talk(uint32 count) - { - if(!m_creature->isAlive()) return; - uint32 sound = Conversation[count].sound; - char* text = NULL; - if(Conversation[count].text) - text = Conversation[count].text; - TalkTimer = Conversation[count].timer; - uint32 emote = Conversation[count].emote; - IsTalking = Conversation[count].Talk; - Creature* creature = NULL; - uint64 GUID = 0; - if(Conversation[count].creature == ILLIDAN_STORMRAGE) - creature = m_creature; - else if(Conversation[count].creature == AKAMA) - { - if(!AkamaGUID) - { - if(pInstance) - { - AkamaGUID = pInstance->GetData64(DATA_AKAMA); - if(!AkamaGUID) - return; - GUID = AkamaGUID; - } - } - else GUID = AkamaGUID; - } - else if(Conversation[count].creature == MAIEV_SHADOWSONG) - { - if(!MaievGUID) - return; - GUID = MaievGUID; - } - else if(Conversation[count].creature == EMPTY) // This is just for special cases without speech/sounds/emotes. - return; - - if(GUID) // Now we check if we actually specified a GUID, if so: - // we grab a pointer to that creature - creature = ((Creature*)Unit::GetUnit((*m_creature), GUID)); - - if(creature) - { - creature->HandleEmoteCommand(emote); // Make the creature do some animation! - if(text) - creature->Yell(text, LANG_UNIVERSAL, 0); // Have the creature yell out some text - if(sound) - DoPlaySoundToSet(creature, sound); // Play some sound on the creature - } - } - - void Move(float X, float Y, float Z, Creature* _Creature) - { - _Creature->GetMotionMaster()->MovePoint(0, X, Y, Z); - } - - void HandleDemonTransformAnimation(uint32 count) - { - uint32 unaura = DemonTransformation[count].unaura; - uint32 aura = DemonTransformation[count].aura; - uint32 displayid = DemonTransformation[count].displayid; - AnimationTimer = DemonTransformation[count].timer; - uint32 size = DemonTransformation[count].size; - - m_creature->InterruptNonMeleeSpells(false); - - if(DemonTransformation[count].phase != 8) - { - m_creature->GetMotionMaster()->Clear(); - m_creature->GetMotionMaster()->MoveIdle(); - } - - if(unaura) - m_creature->RemoveAurasDueToSpell(unaura); - - if(aura) - DoCast(m_creature, aura, true); - - if(displayid) - // It's morphin time! - m_creature->SetUInt32Value(UNIT_FIELD_DISPLAYID, displayid); - /*if(size) - m_creature->SetUInt32Value(OBJECT_FIELD_SCALE_X, size); // Let us grow! (or shrink)*/ - - if(DemonTransformation[count].equip) - { - // Requip warglaives if needed - m_creature->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_DISPLAY, 45479); - m_creature->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_DISPLAY+1, 45481); - } - else - { - // Unequip warglaives if needed - m_creature->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_DISPLAY, 0); - m_creature->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_DISPLAY+1, 0); - } - - if(DemonTransformation[count].phase != 8) - Phase = DemonTransformation[count].phase; // Set phase properly - else - { - // Refollow and attack our old victim - m_creature->GetMotionMaster()->MoveChase(m_creature->getVictim()); - if(MaievGUID) Phase = PHASE_NORMAL_MAIEV; // Depending on whether we summoned Maiev, we switch to either phase 5 or 3 - else Phase = PHASE_NORMAL_2; - } - - if(count == 7) - { - DoResetThreat(); - m_creature->RemoveAurasDueToSpell( SPELL_DEMON_FORM ); - } - else if(count == 4) - { - DoResetThreat(); - if(!m_creature->HasAura(SPELL_DEMON_FORM, 0)) - DoCast(m_creature, SPELL_DEMON_FORM, true); - } - } - - /** To reduce the amount of code in UpdateAI, we can seperate them into different functions and simply call them from UpdateAI **/ - void EnterPhase2() - { - DoYell(SAY_TAKEOFF, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_TAKEOFF); - - SummonBladesTimer = 10000; // Summon Glaives when this decrements - SummonFlamesTimer = 20000; // Summon Flames when this decrements - GlobalTimer += 20000; - LandTimer = 0; - Phase = PHASE_FLIGHT; - m_creature->RemoveAllAuras(); - m_creature->SetUInt64Value(UNIT_FIELD_TARGET, 0); - // So players don't shoot us down - m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); - // Animate our take off! - m_creature->HandleEmoteCommand(EMOTE_ONESHOT_LIFTOFF); - // We now hover! - m_creature->AddUnitMovementFlag(MOVEMENTFLAG_LEVITATING); - m_creature->GetMotionMaster()->MovePoint(0, CENTER_X, CENTER_Y, CENTER_Z); - for(uint8 i = 0; i < 2; ++i) - { - Creature* Glaive = m_creature->SummonCreature(BLADE_OF_AZZINOTH, GlaivePosition[i].x, GlaivePosition[i].y, GlaivePosition[i].z, 0, TEMPSUMMON_CORPSE_DESPAWN, 0); - if(Glaive) - { - GlaiveGUID[i] = Glaive->GetGUID(); // We need this to remove them later on - Glaive->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); - Glaive->SetVisibility(VISIBILITY_OFF); - Glaive->setFaction(m_creature->getFaction()); - } - } - } - - void SummonBladesOfAzzinoth() - { - m_creature->GetMotionMaster()->Clear(false); - - LandTimer = 0; - RetrieveBladesTimer = 0; - - DoCast(m_creature, SPELL_THROW_GLAIVE2); // Make it look like we're throwing the glaives on the ground - // We no longer wear the glaives! - m_creature->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_DISPLAY, 0); - // since they are now channeling the flames (or will be) - m_creature->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_DISPLAY+1, 0); - for(uint8 i = 0; i < 2; ++i) - { - Creature* Glaive = NULL; - Glaive = ((Creature*)Unit::GetUnit((*m_creature), GlaiveGUID[i])); - if(Glaive) - { - DoCast(Glaive, SPELL_THROW_GLAIVE, true); - Glaive->SetVisibility(VISIBILITY_ON); - } - } - } - - void SummonFlamesOfAzzinoth() - { - DoYell(SAY_SUMMONFLAMES, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_SUMMONFLAMES); - - for(uint8 i = 0; i < 2; ++i) - { - Creature* Flame = NULL; - Creature* Glaive = NULL; - Glaive = ((Creature*)Unit::GetUnit((*m_creature), GlaiveGUID[i])); - if(Glaive) - { - Flame = m_creature->SummonCreature(FLAME_OF_AZZINOTH, GlaivePosition[i+2].x, GlaivePosition[i+2].y, GlaivePosition[i+2].z, 0, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 5000); - if(Flame) - { - // Just in case the database has it as a different faction - Flame->setFaction(m_creature->getFaction()); - // Attack our target! - Flame->AI()->AttackStart(m_creature->getVictim()); - FlameGUID[i] = Flame->GetGUID(); // Record GUID in order to check if they're dead later on to move to the next phase - // Glaives do some random Beam type channel on it. - Glaive->CastSpell(Flame, SPELL_AZZINOTH_CHANNEL, true); - if(m_creature->getVictim()) - Flame->AI()->AttackStart(m_creature->getVictim()); - } - else - { - DoTextEmote("is unable to summon a Flame of Azzinoth.", NULL); - error_log("SD2 ERROR: Illidan Stormrage AI: Unable to summon Flame of Azzinoth (entry: 22997), please check your database"); - EnterEvadeMode(); - } - } - else - { - DoTextEmote("is unable to summon a Blade of Azzinoth.", NULL); - error_log("SD2 ERROR: Illidan Stormrage AI: Unable to summon Blade of Azzinoth (entry: 22996), please check your database"); - } - } - DoResetThreat(); // And now reset our threatlist - HasSummoned = true; - } - - void SummonMaiev() - { - TauntTimer += 4000; - GlobalTimer += 4000; - - m_creature->InterruptNonMeleeSpells(false); // Interrupt any of our spells - Creature* Maiev = NULL; // Summon Maiev near Illidan - Maiev = m_creature->SummonCreature(MAIEV_SHADOWSONG, m_creature->GetPositionX() + 10, m_creature->GetPositionY() + 5, m_creature->GetPositionZ()+2, 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 45000); - if(Maiev) - { - m_creature->GetMotionMaster()->Clear(false); // Stop moving, it's rude to walk and talk! - m_creature->GetMotionMaster()->MoveIdle(); - // Just in case someone is unaffected by Shadow Prison - m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); - DoCast(m_creature, SPELL_SHADOW_PRISON, true); - TalkCount = 10; - IsTalking = true; // We are now talking/ - Maiev->SetVisibility(VISIBILITY_OFF); // Leave her invisible until she has to talk - Maiev->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); - MaievGUID = Maiev->GetGUID(); - } - else // If Maiev cannot be summoned, reset the encounter and post some errors to the console. - { - EnterEvadeMode(); - DoTextEmote("is unable to summon Maiev Shadowsong and enter Phase 4. Resetting Encounter.", NULL); - error_log("SD2 ERROR: Unable to summon Maiev Shadowsong (entry: 23197). Check your database to see if you have the proper SQL for Maiev Shadowsong (entry: 23197)"); - } - } - - void InitializeDeath() - { - m_creature->RemoveAllAuras(); - DoCast(m_creature, SPELL_DEATH); // Animate his kneeling + stun him - // Don't let the players interrupt our talk! - m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); - m_creature->GetMotionMaster()->Clear(false); // No moving! - m_creature->GetMotionMaster()->MoveIdle(); - if(MaievGUID) - { - Creature* Maiev = ((Creature*)Unit::GetUnit((*m_creature), MaievGUID)); - if(Maiev) - { - Maiev->CombatStop(); // Maiev shouldn't do anything either. No point in her attacking us =] - Maiev->GetMotionMaster()->Clear(false); // Stop her from moving as well - Maiev->GetMotionMaster()->MoveIdle(); - float distance = 10.0f; - float dx = m_creature->GetPositionX() + (distance*cos(m_creature->GetOrientation())); - float dy = m_creature->GetPositionY() + (distance*sin(m_creature->GetOrientation())); - Maiev->Relocate(dx,dy,Maiev->GetPositionZ()); - Maiev->SendMonsterMove(dx,dy,Maiev->GetPositionZ(), 0, 0, 0); - Maiev->CastSpell(Maiev, SPELL_TELEPORT_VISUAL, true); - Maiev->SetUInt64Value(UNIT_FIELD_TARGET, m_creature->GetGUID()); - } - } - IsTalking = true; - TalkCount++; - } - - void UpdateAI(const uint32 diff) - { - /*** This section will handle the conversations ***/ - if(IsTalking) // Somewhat more efficient using a function rather than a long switch - { - if(TalkTimer < diff) - { - switch(TalkCount) // This is only for specialized cases - { - case 0: - // Time to stand up! - m_creature->RemoveAurasDueToSpell( SPELL_KNEEL ); - break; - case 8: - // Equip our warglaives! - m_creature->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_DISPLAY, 45479); - m_creature->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_DISPLAY+1, 45481); - m_creature->setFaction(14); // Hostile if we weren't before - break; - case 9: - if(AkamaGUID) - { - Creature* Akama = ((Creature*)Unit::GetUnit((*m_creature), AkamaGUID)); - if(Akama) - { - Akama->GetMotionMaster()->Clear(false); - // Akama runs to us! - Akama->GetMotionMaster()->MoveChase(m_creature); - m_creature->GetMotionMaster()->Clear(false); - // We run to Akama! - m_creature->GetMotionMaster()->MoveChase(Akama); - Akama->AddThreat(m_creature, 1000000.0f); - AttackStart(Akama); // Start attacking Akama - ((npc_akama_illidanAI*)Akama->AI())->IsTalking = false; - // Akama starts attacking us - ((npc_akama_illidanAI*)Akama->AI())->AttackStart(m_creature); - } - } - // We are now attackable! - m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); - break; - case 11: - if(MaievGUID) - { - Unit* Maiev = Unit::GetUnit((*m_creature), MaievGUID); - if(Maiev) - { - // Maiev is now visible - Maiev->SetVisibility(VISIBILITY_ON); - // onoz she looks like she teleported! - Maiev->CastSpell(Maiev, SPELL_TELEPORT_VISUAL, true); - // Have her face us - Maiev->SetUInt64Value(UNIT_FIELD_TARGET, m_creature->GetGUID()); - // Face her, so it's not rude =P - m_creature->SetUInt64Value(UNIT_FIELD_TARGET, Maiev->GetGUID()); - } - } - break; - case 14: - if(MaievGUID) - { - Creature* Maiev = ((Creature*)Unit::GetUnit((*m_creature), MaievGUID)); - if(Maiev) - { - Maiev->GetMotionMaster()->Clear(false); - Maiev->GetMotionMaster()->MoveChase(m_creature); - // Have Maiev add a lot of threat on us so that players don't pull her off if they damage her via AOE - Maiev->AddThreat(m_creature, 10000000.0f); - // Force Maiev to attack us. - Maiev->AI()->AttackStart(m_creature); - Maiev->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - } - } - m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); - m_creature->GetMotionMaster()->MoveChase(m_creature->getVictim()); - IsTalking = false; - FaceVictimTimer = 2000; - RefaceVictim = true; - break; - case 20: // Kill ourself. - if(MaievGUID) - { - Creature* Maiev = ((Creature*)Unit::GetUnit((*m_creature), MaievGUID)); - if(Maiev) // Make Maiev leave - { - Maiev->CastSpell(Maiev, SPELL_TELEPORT_VISUAL, true); - Maiev->setDeathState(JUST_DIED); - } - } - IsTalking = false; - if(m_creature->getVictim()) - m_creature->getVictim()->DealDamage(m_creature, m_creature->GetHealth(), NULL, DIRECT_DAMAGE,SPELL_SCHOOL_MASK_NORMAL, NULL, false); - else - // Now we kill ourself - m_creature->DealDamage(m_creature, m_creature->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); - break; - } - Talk(TalkCount); // This function does most of the talking - TalkCount++; - }else TalkTimer -= diff; - } - - // If we don't have a target, return. - if(!m_creature->SelectHostilTarget() || !m_creature->getVictim() || IsTalking) - return; - - // If we are 'caged', then we shouldn't do anything such as cast spells or transform into Demon Form. - if(m_creature->HasAura(SPELL_CAGED, 0)) - { - EnrageTimer = 40000; // Just so that he doesn't immediately enrage after he stops being caged. - CageTimer = 30000; - return; - } - - // Berserk Timer - flat 25 minutes - if(!m_creature->HasAura(SPELL_BERSERK, 0) && Phase != PHASE_DEMON_SEQUENCE) - if(BerserkTimer < diff) - { - DoYell(SAY_ENRAGE, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_ENRAGE); - DoCast(m_creature, SPELL_BERSERK, true); - }else BerserkTimer -= diff; - - if(RefaceVictim) - if(FaceVictimTimer < diff) - { - m_creature->SetUInt64Value(UNIT_FIELD_TARGET, m_creature->getVictim()->GetGUID()); - FaceVictimTimer = 1000; - RefaceVictim = false; - }else FaceVictimTimer -= diff; - - /** Signal to change to phase 2 **/ - if(((m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < 65) && (Phase == PHASE_NORMAL)) - EnterPhase2(); - - /** Signal to summon Maiev **/ - if(((m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < 30) && !MaievGUID && - ((Phase != PHASE_DEMON) || (Phase != PHASE_DEMON_SEQUENCE))) - SummonMaiev(); - - /** Time for the death speech **/ - if((m_creature->GetHealth()*100 / m_creature->GetMaxHealth() < 1) && (!IsTalking) && - ((Phase != PHASE_DEMON) || (Phase != PHASE_DEMON_SEQUENCE))) - InitializeDeath(); - - /***** Spells for Phase 1, 3 and 5 (Normal Form) ******/ - if(Phase == PHASE_NORMAL || Phase == PHASE_NORMAL_2 || Phase == PHASE_NORMAL_MAIEV) - { - if(TauntTimer < diff) // His random taunt/yell timer. - { - uint32 random = rand()%4; - char* yell = RandomTaunts[random].text; - uint32 soundid = RandomTaunts[random].sound; - if(yell) - DoYell(yell, LANG_UNIVERSAL, NULL); - if(soundid) - DoPlaySoundToSet(m_creature, soundid); - TauntTimer = 32000; - }else TauntTimer -= diff; - - if(GlobalTimer < diff) // Global Timer so that spells do not overlap. - { - if(ShearTimer < diff) - { - DoCast(m_creature->getVictim(), SPELL_SHEAR); - ShearTimer = 25000 + (rand()%16 * 1000); - GlobalTimer += 2000; - }else ShearTimer -= diff; - - if(FlameCrashTimer < diff) - { - // It spawns multiple flames sometimes. Therefore, we'll do this manually. - //DoCast(m_creature->getVictim(), SPELL_FLAME_CRASH); - DoSpawnCreature(FLAME_CRASH, 0, 0, 0, 0, TEMPSUMMON_TIMED_DESPAWN, 40000); - FlameCrashTimer = 35000; - GlobalTimer += 2000; - }else FlameCrashTimer -= diff; - - if(ParasiticShadowFiendTimer < diff) - { - Unit* target = NULL; - target = SelectUnit(SELECT_TARGET_RANDOM,1); - if(target && target->isAlive() && !target->HasAura(SPELL_PARASITIC_SHADOWFIEND, 0)) - { - Cast(target, SPELL_PARASITIC_SHADOWFIEND); - ParasiticShadowFiendTimer = 40000; - } - }else ParasiticShadowFiendTimer -= diff; - - if(DrawSoulTimer < diff) - { - DoCast(m_creature->getVictim(), SPELL_DRAW_SOUL); - DrawSoulTimer = 55000; - GlobalTimer += 3000; - }else DrawSoulTimer -= diff; - }else GlobalTimer -= diff; - - if(!IsTalking) - DoMeleeAttackIfReady(); - } - - /*** Phase 2 ***/ - if(Phase == PHASE_FLIGHT) - { - // Check if we have summoned or not. - if(!HasSummoned) - { - if(SummonBladesTimer) - if(SummonBladesTimer <= diff) - { - SummonBladesOfAzzinoth(); - SummonBladesTimer = 0; - }else SummonBladesTimer -= diff; - - if(SummonFlamesTimer < diff) - { - SummonFlamesOfAzzinoth(); - }else SummonFlamesTimer -= diff; - } - - if(!m_creature->GetMotionMaster()->empty() && (m_creature->GetMotionMaster()->GetCurrentMovementGeneratorType() != POINT_MOTION_TYPE)) - m_creature->GetMotionMaster()->Clear(false); - - if(HasSummoned) - { - if(CheckFlamesTimer) - if(CheckFlamesTimer <= diff) - { - // Check if flames are dead or non-existant. If so, set GUID to 0. - for(uint8 i = 0; i < 2; i++) - { - if(FlameGUID[i]) - { - Unit* Flame = NULL; - Flame = Unit::GetUnit((*m_creature), FlameGUID[i]); - - // If the flame dies, or somehow the pointer becomes invalid, reset GUID to 0. - if(!Flame || !Flame->isAlive()) - FlameGUID[i] = 0; - } - } - CheckFlamesTimer = 500; - }else CheckFlamesTimer -= diff; - - // If both flames are dead/non-existant, kill glaives and change to phase 3. - if(!FlameGUID[0] && !FlameGUID[1] && CheckFlamesTimer) - { - RetrieveBladesTimer = 5000; // Prepare for re-equipin! - CheckFlamesTimer = 0; - } - - if(RetrieveBladesTimer) - if(RetrieveBladesTimer <= diff) // Time to get back our glaives! - { - // Interrupt any spells we might be doing *cough* DArk Barrage *cough* - m_creature->InterruptNonMeleeSpells(false); - for(uint8 i = 0; i < 2; i++) - { - if(GlaiveGUID[i]) - { - Unit* Glaive = NULL; - Glaive = Unit::GetUnit((*m_creature), GlaiveGUID[i]); - if(Glaive) - { - // Make it look like the Glaive flies back up to us - Glaive->CastSpell(m_creature, SPELL_GLAIVE_RETURNS, true); - // Despawn the Glaive - Glaive->setDeathState(JUST_DIED); - } - GlaiveGUID[i] = 0; - } - } - // Re-equip our warblades! - m_creature->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_DISPLAY, 45479); - m_creature->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_DISPLAY+1, 45481); - LandTimer = 5000; // Prepare for landin'! - RetrieveBladesTimer = 0; - }else RetrieveBladesTimer -= diff; - - if(LandTimer) - { - if(LandTimer <= diff) // Time to land! - { - DoResetThreat(); - // anndddd touchdown! - m_creature->HandleEmoteCommand(EMOTE_ONESHOT_LAND); - m_creature->RemoveUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT + MOVEMENTFLAG_LEVITATING); - Phase = PHASE_NORMAL_2; - // We should let the raid fight us =) - m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); - m_creature->SetUInt64Value(UNIT_FIELD_TARGET, m_creature->getVictim()->GetGUID()); - // Chase our victim! - m_creature->GetMotionMaster()->MoveChase(m_creature->getVictim()); - }else LandTimer -= diff; - return; // Do not continue past this point if LandTimer is not 0 and we are in phase 2. - } - } - - if(GlobalTimer < diff) - { - if(FireballTimer < diff) - { - Cast(SelectUnit(SELECT_TARGET_RANDOM, 0), SPELL_FIREBALL); - FireballTimer = 5000; - }else FireballTimer -= diff; - - if(DarkBarrageTimer < diff) - { - m_creature->InterruptNonMeleeSpells(false); - DoCast(SelectUnit(SELECT_TARGET_RANDOM, 0), SPELL_DARK_BARRAGE); - DarkBarrageTimer = 35000; - GlobalTimer += 9000; - }else DarkBarrageTimer -= diff; - - if(EyeBlastTimer < diff) - { - CastEyeBlast(); - EyeBlastTimer = 30000; - }else EyeBlastTimer -= diff; - }else GlobalTimer -= diff; - } - - /** Phase 3,5 spells only**/ - if(Phase == PHASE_NORMAL_2 || Phase == PHASE_NORMAL_MAIEV) - { - if(GlobalTimer < diff) - { - if(AgonizingFlamesTimer < diff) - { - CastAgonizingFlames(); - AgonizingFlamesTimer = 60000; - }else AgonizingFlamesTimer -= diff; - }else GlobalTimer -= diff; - - if(TransformTimer < diff) - { - uint32 CurHealth = m_creature->GetHealth()*100 / m_creature->GetMaxHealth(); - // Prevent Illidan from morphing if less than 32% or 5%, as this may cause issues with the phase transition or death speech - if((CurHealth < 32 && !MaievGUID) || (CurHealth < 5)) - return; - - Phase = PHASE_DEMON_SEQUENCE; // Transform sequence - DemonFormSequence = 0; - AnimationTimer = 0; - DoYell(SAY_MORPH, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_MORPH); - TransformTimer = 60000; - FlameBurstTimer = 10000; - ShadowDemonTimer = 30000; - m_creature->GetMotionMaster()->Clear(false);// Stop moving - }else TransformTimer -= diff; - } - - /** Phase 4 spells only (Demon Form) **/ - if(Phase == PHASE_DEMON) - { - // Stop moving if we are by clearing movement generators. - if(!m_creature->GetMotionMaster()->empty()) - m_creature->GetMotionMaster()->Clear(false); - - if(TransformTimer < diff) - { - Phase = PHASE_DEMON_SEQUENCE; - DemonFormSequence = 5; - AnimationTimer = 100; - TransformTimer = 60000; - }else TransformTimer -= diff; - - if(ShadowDemonTimer < diff) - { - m_creature->InterruptNonMeleeSpells(false); - Creature* ShadowDemon = NULL; - for(uint8 i = 0; i < 4; i++) - { - Unit* target = NULL; - target = SelectUnit(SELECT_TARGET_RANDOM,0); - // only on players. - if(target && target->GetTypeId() == TYPEID_PLAYER) - { - ShadowDemon = DoSpawnCreature(SHADOW_DEMON, 0,0,0,0,TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN,25000); - if(ShadowDemon) - { - ShadowDemon->AddThreat(target, 5000000.0f); - ShadowDemon->AI()->AttackStart(target); - DoZoneInCombat(ShadowDemon); - } - } - } - ShadowDemonTimer = 60000; - }else ShadowDemonTimer -= diff; - - if(GlobalTimer < diff) - { - if(ShadowBlastTimer < diff) - { - Unit* target = SelectUnit(SELECT_TARGET_TOPAGGRO, 0); - if(target && target->isAlive()) - { - m_creature->SetUInt64Value(UNIT_FIELD_TARGET, target->GetGUID()); - DoCast(target, SPELL_SHADOW_BLAST); - ShadowBlastTimer = 4000; - GlobalTimer += 1500; - } - if(!m_creature->HasAura(SPELL_DEMON_FORM, 0)) - DoCast(m_creature, SPELL_DEMON_FORM, true); - }else ShadowBlastTimer -= diff; - - if(FlameBurstTimer < diff) - { - DoCast(m_creature, SPELL_FLAME_BURST); - FlameBurstTimer = 15000; - }else FlameBurstTimer -= diff; - }else GlobalTimer -= diff; - } - - /** Phase 5 timers. Enrage spell **/ - if(Phase == PHASE_NORMAL_MAIEV) - { - if(EnrageTimer < diff) - { - DoCast(m_creature, SPELL_ENRAGE); - EnrageTimer = 40000; - CageTimer = 30000; - TransformTimer += 10000; - }else EnrageTimer -= diff; - - // We'll handle Cage Trap in Illidan's script for simplicity's sake - if(CageTimer < diff) - { - if(MaievGUID) - { - Unit* Maiev = Unit::GetUnit((*m_creature), MaievGUID); - Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0); - if(!Maiev || !target || (target->GetTypeId() != TYPEID_PLAYER)) - return; - float X, Y, Z; - target->GetPosition(X, Y, Z); - Maiev->Relocate(X, Y, Z, Maiev->GetOrientation()); - // Make it look like she 'teleported' - Maiev->CastSpell(Maiev, SPELL_TELEPORT_VISUAL, true); - // summon the trap! - Maiev->CastSpell(Maiev, SPELL_CAGE_TRAP_SUMMON, false); - } - CageTimer = 15000; - }else CageTimer -= diff; - } - - if(Phase == PHASE_DEMON_SEQUENCE) // Demonic Transformation - { - if(AnimationTimer < diff) - { - HandleDemonTransformAnimation(DemonFormSequence); - DemonFormSequence++; - }else AnimationTimer -= diff; - } - } -}; - -/*********************** End of Illidan AI ******************************************/ - -void npc_akama_illidanAI::BeginEvent(uint64 PlayerGUID) -{ - debug_log("SD2: Akama - Illidan Introduction started. Illidan event properly begun."); - if(pInstance) - { - IllidanGUID = pInstance->GetData64(DATA_ILLIDANSTORMRAGE); - pInstance->SetData(DATA_ILLIDANSTORMRAGEEVENT, IN_PROGRESS); - } - - if(pInstance) - for(uint8 i = DATA_GAMEOBJECT_ILLIDAN_DOOR_R; i < DATA_GAMEOBJECT_ILLIDAN_DOOR_L+1; ++i) - { - GameObject* Door = GameObject::GetGameObject((*m_creature), pInstance->GetData64(i)); - if(Door) - Door->SetGoState(1); - } - - if(IllidanGUID) - { - m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); - Creature* Illidan = ((Creature*)Unit::GetUnit((*m_creature), IllidanGUID)); - if(Illidan) - { - Illidan->RemoveAurasDueToSpell(SPELL_KNEEL); // Time for Illidan to stand up. - // First line of Akama-Illidan convo - ((boss_illidan_stormrageAI*)Illidan->AI())->TalkCount = 0; - // Begin Talking - ((boss_illidan_stormrageAI*)Illidan->AI())->IsTalking = true; - ((boss_illidan_stormrageAI*)Illidan->AI())->AkamaGUID = m_creature->GetGUID(); - m_creature->SetUInt64Value(UNIT_FIELD_TARGET, Illidan->GetGUID()); - Illidan->SetUInt64Value(UNIT_FIELD_TARGET, m_creature->GetGUID()); - IsTalking = true; // Prevent Akama from starting to attack him - // Prevent players from talking again - m_creature->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP); - m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); - Illidan->GetMotionMaster()->Clear(false); - Illidan->GetMotionMaster()->MoveIdle(); - m_creature->GetMotionMaster()->Clear(false); - m_creature->GetMotionMaster()->MoveIdle(); - - if(PlayerGUID) - { - Unit* player = Unit::GetUnit((*m_creature), PlayerGUID); - if(player) - Illidan->AddThreat(player, 100.0f); - } - } - } -} - -bool GossipSelect_npc_akama_at_illidan(Player *player, Creature *_Creature, uint32 sender, uint32 action) -{ - if(action == GOSSIP_ACTION_INFO_DEF) // Time to begin the event - { - player->CLOSE_GOSSIP_MENU(); - ((npc_akama_illidanAI*)_Creature->AI())->BeginDoorEvent(player); - } - return true; -} - -bool GossipHello_npc_akama_at_illidan(Player *player, Creature *_Creature) -{ - player->ADD_GOSSIP_ITEM(0, GOSSIP_ITEM, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF); - player->SEND_GOSSIP_MENU(10465, _Creature->GetGUID()); - - return true; -} - -struct MANGOS_DLL_SPEC boss_maievAI : public ScriptedAI -{ - boss_maievAI(Creature *c) : ScriptedAI(c) - { - pInstance = ((ScriptedInstance*)c->GetInstanceData()); - Reset(); - }; - - uint32 TauntTimer; - uint64 IllidanGUID; - - ScriptedInstance* pInstance; - - void Reset() - { - TauntTimer = 12000; - IllidanGUID = 0; - } - - void Aggro(Unit *who) {} - - void UpdateAI(const uint32 diff) - { - if(!IllidanGUID) - { - if(pInstance) - IllidanGUID = pInstance->GetData64(DATA_ILLIDANSTORMRAGE); - }else - { - Creature* Illidan = NULL; - Illidan = ((Creature*)Unit::GetUnit((*m_creature), IllidanGUID)); - if(!Illidan || !Illidan->isAlive() || Illidan->IsInEvadeMode()) - { - m_creature->SetVisibility(VISIBILITY_OFF); - m_creature->DealDamage(m_creature, m_creature->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); - } - else if(Illidan && ((Illidan->GetHealth()*100 / Illidan->GetMaxHealth()) < 2)) - return; - } - - // Return if we don't have a target - if(!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - if(TauntTimer < diff) - { - uint32 random = rand()%4; - char* text = MaievTaunts[random].text; - uint32 sound = MaievTaunts[random].sound; - DoYell(text, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, sound); - TauntTimer = 22000 + rand()%21 * 1000; - }else TauntTimer -= diff; - - DoMeleeAttackIfReady(); - } -}; - -struct MANGOS_DLL_DECL cage_trap_triggerAI : public ScriptedAI -{ - cage_trap_triggerAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint64 IllidanGUID; - uint64 CageTrapGUID; - - uint32 DespawnTimer; - - bool Active; - bool SummonedBeams; - - void Reset() - { - IllidanGUID = 0; - CageTrapGUID = 0; - - Active = false; - SummonedBeams = false; - - DespawnTimer = 0; - - m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - } - - void Aggro(Unit *who){} - - void MoveInLineOfSight(Unit *who) - { - if(!Active) - return; - - if(who && (who->GetTypeId() != TYPEID_PLAYER)) - { - if(who->GetEntry() == ILLIDAN_STORMRAGE) // Check if who is Illidan - { - if(!IllidanGUID && m_creature->IsWithinDistInMap(who, 3) && !who->HasAura(SPELL_CAGED, 0)) - { - IllidanGUID = who->GetGUID(); - who->CastSpell(who, SPELL_CAGED, true); - DespawnTimer = 5000; - if(who->HasAura(SPELL_ENRAGE, 0)) - // Dispel his enrage - who->RemoveAurasDueToSpell(SPELL_ENRAGE); - - if(GameObject* CageTrap = GameObject::GetGameObject(*m_creature, CageTrapGUID)) - CageTrap->SetLootState(GO_JUST_DEACTIVATED); - } - } - } - } - - void UpdateAI(const uint32 diff) - { - if(DespawnTimer) - if(DespawnTimer < diff) - m_creature->DealDamage(m_creature, m_creature->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); - else DespawnTimer -= diff; - - //if(IllidanGUID && !SummonedBeams) - //{ - // if(Unit* Illidan = Unit::GetUnit(*m_creature, IllidanGUID) - // { - // //TODO: Find proper spells and properly apply 'caged' Illidan effect - // } - //} - } -}; - -bool GOHello_cage_trap(Player* plr, GameObject* go) -{ - float x, y, z; - plr->GetPosition(x, y, z); - - Creature* trigger = NULL; - - CellPair pair(MaNGOS::ComputeCellPair(x, y)); - Cell cell(pair); - cell.data.Part.reserved = ALL_DISTRICT; - cell.SetNoCreate(); - - // Grid search for nearest live creature of entry 23304 within 10 yards - MaNGOS::NearestCreatureEntryWithLiveStateInObjectRangeCheck check(*plr, 23304, true, 10); - MaNGOS::CreatureLastSearcher searcher(trigger, check); - - TypeContainerVisitor, GridTypeMapContainer> cSearcher(searcher); - - CellLock cell_lock(cell, pair); - cell_lock->Visit(cell_lock, cSearcher, *(plr->GetMap())); - - if(!trigger) - { - plr->GetSession()->SendNotification("SD2: Summon failed. This trap is now useless.", LANG_UNIVERSAL, 0); - error_log("SD2: Cage Trap- Unable to find trigger. This Cage Trap is now useless"); - return false; - } - - ((cage_trap_triggerAI*)trigger->AI())->Active = true; - go->SetGoState(0); - return true; -} - -//This is used to sort the players by distance in preparation for being charged by the flames. -struct TargetDistanceOrder : public std::binary_function -{ - const Unit* MainTarget; - TargetDistanceOrder(const Unit* Target) : MainTarget(Target) {}; - // functor for operator ">" - bool operator()(const Unit* _Left, const Unit* _Right) const - { - return (MainTarget->GetDistance(_Left) > MainTarget->GetDistance(_Right)); - } -}; - -struct MANGOS_DLL_DECL flame_of_azzinothAI : public ScriptedAI -{ - flame_of_azzinothAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 FlameBlastTimer; - uint32 SummonBlazeTimer; - uint32 ChargeTimer; - - void Reset() - { - FlameBlastTimer = 15000 + rand()%15000; - SummonBlazeTimer = 10000 + rand()%20000; - ChargeTimer = 5000; - } - - void Aggro(Unit *who) {} - - void Charge() - { - // Get the Threat List - std::list& m_threatlist = m_creature->getThreatManager().getThreatList(); - - if(!m_threatlist.size()) return; // He doesn't have anyone in his threatlist, useless to continue - - std::list targets; - std::list::iterator itr = m_threatlist.begin(); - for( ; itr!= m_threatlist.end(); ++itr) //store the threat list in a different container - { - Unit *target = Unit::GetUnit(*m_creature, (*itr)->getUnitGuid()); - //only on alive players - if(target && target->isAlive() && target->GetTypeId() == TYPEID_PLAYER ) - targets.push_back( target); - } - - //Sort the list of players - targets.sort(TargetDistanceOrder(m_creature)); - //Resize so we only get the furthest target - targets.resize(1); - - Unit* target = (*targets.begin()); - if(target && (!m_creature->IsWithinDistInMap(target, 40))) - { - DoCast(m_creature, SPELL_ENRAGE, true); - DoCast(target, SPELL_CHARGE); - } - } - - void UpdateAI(const uint32 diff) - { - // Return if we don't have a target - if(!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - if(FlameBlastTimer < diff) - { - DoCast(m_creature->getVictim(), SPELL_FLAME_BLAST); - FlameBlastTimer = 30000; - }else FlameBlastTimer -= diff; - - if(SummonBlazeTimer < diff) - { - DoCast(m_creature, SPELL_BLAZE_SUMMON); - SummonBlazeTimer = 30000 + rand()%20000; - }else SummonBlazeTimer -= diff; - - if(ChargeTimer < diff) - { - Charge(); - ChargeTimer = 5000; - }else ChargeTimer -= diff; - - DoMeleeAttackIfReady(); - } -}; - -struct MANGOS_DLL_DECL shadow_demonAI : public ScriptedAI -{ - shadow_demonAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint64 TargetGUID; - - void Reset() { TargetGUID = 0; } - - void Aggro(Unit *who) {} - - void JustDied(Unit *killer) - { - if(TargetGUID) - { - Unit* target = Unit::GetUnit((*m_creature), TargetGUID); - if(target) - target->RemoveAurasDueToSpell(SPELL_PARALYZE); - } - } - - void UpdateAI(const uint32 diff) - { - if(!m_creature->SelectHostilTarget() || !m_creature->getVictim()) return; - - // Only cast the below on players. - if(m_creature->getVictim()->GetTypeId() != TYPEID_PLAYER) return; - - if(!m_creature->getVictim()->HasAura(SPELL_PARALYZE, 0)) - { - TargetGUID = m_creature->getVictim()->GetGUID(); - m_creature->AddThreat(m_creature->getVictim(), 10000000.0f); - DoCast(m_creature, SPELL_SHADOW_DEMON_PASSIVE, true); - DoCast(m_creature->getVictim(), SPELL_PURPLE_BEAM, true); - DoCast(m_creature->getVictim(), SPELL_PARALYZE, true); - } - // Kill our target if we're very close. - if(m_creature->IsWithinDistInMap(m_creature->getVictim(), 3)) - DoCast(m_creature->getVictim(), SPELL_CONSUME_SOUL); - } -}; - -struct MANGOS_DLL_DECL flamecrashAI : public ScriptedAI -{ - flamecrashAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 FlameCrashTimer; - uint32 DespawnTimer; - - void Reset() - { - FlameCrashTimer = 3000 +rand()%5000; - DespawnTimer = 60000; - } - - void Aggro(Unit *who){ return; } - - void AttackStart(Unit *who) { } - - void MoveInLineOfSight(Unit *who){ } - - void UpdateAI(const uint32 diff) - { - if(FlameCrashTimer < diff) - { - DoCast(m_creature, SPELL_FLAME_CRASH_EFFECT); - FlameCrashTimer = 15000; - }else FlameCrashTimer -= diff; - - if(DespawnTimer < diff) - { - m_creature->SetVisibility(VISIBILITY_OFF); // So that players don't see the sparkly effect when we die. - m_creature->DealDamage(m_creature, m_creature->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); - }else DespawnTimer -= diff; - } -}; - -// Shadowfiends interact with Illidan, setting more targets in Illidan's hashmap -struct MANGOS_DLL_SPEC mob_parasitic_shadowfiendAI : public ScriptedAI -{ - mob_parasitic_shadowfiendAI(Creature* c) : ScriptedAI(c) - { - Reset(); - } - - void Reset() {} - - void Aggro(Unit* who) {} - - void DoMeleeAttackIfReady() - { - //If we are within range melee the target - if( m_creature->IsWithinDistInMap(m_creature->getVictim(), ATTACK_DISTANCE)) - { - //Make sure our attack is ready and we aren't currently casting - if( m_creature->isAttackReady() && !m_creature->IsNonMeleeSpellCasted(false)) - { - if(!m_creature->getVictim()->HasAura(SPELL_PARASITIC_SHADOWFIEND, 0)) - DoCast(m_creature->getVictim(), SPELL_PARASITIC_SHADOWFIEND, true); - m_creature->AttackerStateUpdate(m_creature->getVictim()); - m_creature->resetAttackTimer(); - } - } - } -}; - -struct MANGOS_DLL_DECL blazeAI : public ScriptedAI -{ - blazeAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 BlazeTimer; - uint32 DespawnTimer; - - void Reset() - { - BlazeTimer = 2000; - DespawnTimer = 15000; - } - - void Aggro(Unit *who){ } - - void AttackStart(Unit* who) { } - - void MoveInLineOfSight(Unit *who){ } - - void UpdateAI(const uint32 diff) - { - if(BlazeTimer < diff) - { - DoCast(m_creature, SPELL_BLAZE_EFFECT); - BlazeTimer = 15000; - }else BlazeTimer -= diff; - - if(DespawnTimer < diff) - { - m_creature->SetVisibility(VISIBILITY_OFF); - m_creature->DealDamage(m_creature, m_creature->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); - }else DespawnTimer -= diff; - } -}; - -struct MANGOS_DLL_DECL blade_of_azzinothAI : public ScriptedAI -{ - blade_of_azzinothAI(Creature* c) : ScriptedAI(c) { Reset(); } - - void Reset() {} - // Do-Nothing-But-Stand-There - void Aggro(Unit* who) { } - void AttackStart(Unit* who) { } - void MoveInLineOfSight(Unit* who) { } - -}; - -CreatureAI* GetAI_boss_illidan_stormrage(Creature *_Creature) -{ - return new boss_illidan_stormrageAI (_Creature); -} - -CreatureAI* GetAI_npc_akama_at_illidan(Creature *_Creature) -{ - npc_akama_illidanAI* Akama_AI = new npc_akama_illidanAI(_Creature); - - for(uint8 i = 0; i < 13; ++i) - Akama_AI->AddWaypoint(i, AkamaWP[i].x, AkamaWP[i].y, AkamaWP[i].z); - - return ((CreatureAI*)Akama_AI); -} - -CreatureAI* GetAI_boss_maiev(Creature *_Creature) -{ - return new boss_maievAI (_Creature); -} - -CreatureAI* GetAI_mob_flame_of_azzinoth(Creature *_Creature) -{ - return new flame_of_azzinothAI (_Creature); -} - -CreatureAI* GetAI_cage_trap_trigger(Creature *_Creature) -{ - return new cage_trap_triggerAI (_Creature); -} - -CreatureAI* GetAI_shadow_demon(Creature *_Creature) -{ - return new shadow_demonAI (_Creature); -} - -CreatureAI* GetAI_flamecrash(Creature *_Creature) -{ - return new flamecrashAI (_Creature); -} - -CreatureAI* GetAI_demonfire(Creature *_Creature) -{ - return new demonfireAI (_Creature); -} - -CreatureAI* GetAI_blaze(Creature *_Creature) -{ - return new blazeAI (_Creature); -} - -CreatureAI* GetAI_blade_of_azzinoth(Creature *_Creature) -{ - return new blade_of_azzinothAI (_Creature); -} - -CreatureAI* GetAI_parasitic_shadowfiend(Creature *_Creature) -{ - return new mob_parasitic_shadowfiendAI (_Creature); -} - -void AddSC_boss_illidan() -{ - Script* newscript; - - newscript = new Script; - newscript->Name = "boss_illidan_stormrage"; - newscript->GetAI = GetAI_boss_illidan_stormrage; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name = "npc_akama_illidan"; - newscript->GetAI = GetAI_npc_akama_at_illidan; - newscript->pGossipHello = GossipHello_npc_akama_at_illidan; - newscript->pGossipSelect = GossipSelect_npc_akama_at_illidan; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name = "boss_maiev_shadowsong"; - newscript->GetAI = GetAI_boss_maiev; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name = "mob_flame_of_azzinoth"; - newscript->GetAI = GetAI_mob_flame_of_azzinoth; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name = "mob_blade_of_azzinoth"; - newscript->GetAI = GetAI_blade_of_azzinoth; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name = "gameobject_cage_trap"; - newscript->pGOHello = GOHello_cage_trap; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="mob_cage_trap_trigger"; - newscript->GetAI = GetAI_cage_trap_trigger; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name = "mob_shadow_demon"; - newscript->GetAI = GetAI_shadow_demon; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="mob_flame_crash"; - newscript->GetAI = GetAI_flamecrash; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="mob_demon_fire"; - newscript->GetAI = GetAI_demonfire; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="mob_blaze"; - newscript->GetAI = GetAI_blaze; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name = "mob_parasitic_shadowfiend"; - newscript->GetAI = GetAI_parasitic_shadowfiend; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: boss_illidan_stormrage +SD%Complete: 90 +SDComment: +SDCategory: Black Temple +EndScriptData */ + +#include "precompiled.h" +#include "def_black_temple.h" +#include "WorldPacket.h" + +/************* Quotes and Sounds ***********************/ +// Gossip for when a player clicks Akama +#define GOSSIP_ITEM "We are ready to face Illidan" + +// Yells for/by Akama +#define SAY_AKAMA_BEWARE "Be wary friends, The Betrayer meditates in the court just beyond." +#define SOUND_AKAMA_BEWARE 11388 +#define SAY_AKAMA_MINION "Come, my minions. Deal with this traitor as he deserves!" +#define SOUND_AKAMA_MINION 11465 +#define SAY_AKAMA_LEAVE "I'll deal with these mongrels. Strike now, friends! Strike at the betrayer!" +#define SOUND_AKAMA_LEAVE 11390 + +// Self explanatory +#define SAY_KILL1 "Who shall be next to taste my blades?!" +#define SOUND_KILL1 11473 +#define SAY_KILL2 "This is too easy!" +#define SOUND_KILL2 11472 + +// I think I'll fly now and let my subordinates take you on +#define SAY_TAKEOFF "I will not be touched by rabble such as you!" +#define SOUND_TAKEOFF 11479 +#define SAY_SUMMONFLAMES "Behold the flames of Azzinoth!" +#define SOUND_SUMMONFLAMES 11480 + +// When casting Eye Blast. Demon Fire will be appear on places that he casts this +#define SAY_EYE_BLAST "Stare into the eyes of the Betrayer!" +#define SOUND_EYE_BLAST 11481 + +// kk, I go big, dark and demon on you. +#define SAY_MORPH "Behold the power... of the demon within!" +#define SOUND_MORPH 11475 + +// I KILL! +#define SAY_ENRAGE "You've wasted too much time mortals, now you shall fall!" +#define SOUND_ENRAGE 11474 + +/************** Spells *************/ +// Normal Form +#define SPELL_SHEAR 41032 // Reduces Max. Health by 60% for 7 seconds. Can stack 19 times. 1.5 second cast +#define SPELL_FLAME_CRASH 40832 // Summons an invis/unselect passive mob that has an aura of flame in a circle around him. +#define SPELL_DRAW_SOUL 40904 // 5k Shadow Damage in front of him. Heals Illidan for 100k health (script effect) +#define SPELL_PARASITIC_SHADOWFIEND 41917 // DoT of 3k Shadow every 2 seconds. Lasts 10 seconds. (Script effect: Summon 2 parasites once the debuff has ticked off) +#define SPELL_SUMMON_PARASITICS 41915 // Summons 2 Parasitic Shadowfiends on the target. It's supposed to be cast as soon as the Parasitic Shadowfiend debuff is gone, but the spells aren't linked :( +#define SPELL_AGONIZING_FLAMES 40932 // 4k fire damage initial to target and anyone w/i 5 yards. PHASE 3 ONLY +#define SPELL_ENRAGE 40683 // Increases damage by 50% and attack speed by 30%. 20 seconds, PHASE 5 ONLY +// Flying (Phase 2) +#define SPELL_THROW_GLAIVE 39635 // Throws a glaive on the ground +#define SPELL_THROW_GLAIVE2 39849 // Animation for the above spell +#define SPELL_GLAIVE_RETURNS 39873 // Glaive flies back to Illidan +#define SPELL_FIREBALL 40598 // 2.5k-3.5k damage in 10 yard radius. 2 second cast time. +#define SPELL_DARK_BARRAGE 40585 // 10 second channeled spell, 3k shadow damage per second. +// Demon Form +#define SPELL_DEMON_TRANSFORM_1 40511 // First phase of animations for transforming into Dark Illidan (fall to ground) +#define SPELL_DEMON_TRANSFORM_2 40398 // Second phase of animations (kneel) +#define SPELL_DEMON_TRANSFORM_3 40510 // Final phase of animations (stand up and roar) +#define SPELL_DEMON_FORM 40506 // Transforms into Demon Illidan. Has an Aura of Dread on him. +#define SPELL_SHADOW_BLAST 41078 // 8k - 11k Shadow Damage. Targets highest threat. Has a splash effect, damaging anyone in 20 yards of the target. +#define SPELL_FLAME_BURST 41126 // Hurls fire at entire raid for ~3.5k damage every 10 seconds. Resistable. (Does not work: Script effect) +#define SPELL_FLAME_BURST_EFFECT 41131 // The actual damage. Handled by core (41126 triggers 41131) +// Other Illidan spells +#define SPELL_KNEEL 39656 // Before beginning encounter, this is how he appears (talking to Wilson). +#define SPELL_SHADOW_PRISON 40647 // Illidan casts this spell to immobilize entire raid when he summons Maiev. +#define SPELL_DEATH 41220 // This spell doesn't do anything except stun Illidan and set him on his knees. +#define SPELL_BERSERK 45078 // Damage increased by 500%, attack speed by 150% + +// Non-Illidan spells +#define SPELL_AKAMA_DOOR_CHANNEL 41268 // Akama's channel spell on the door before the Temple Summit +#define SPELL_DEATHSWORN_DOOR_CHANNEL 41269 // Olum and Udalo's channel spell on the door before the Temple Summit +#define SPELL_AKAMA_DOOR_FAIL 41271 // Not sure where this is really used... +#define SPELL_HEALING_POTION 40535 // Akama uses this to heal himself to full. +#define SPELL_AZZINOTH_CHANNEL 39857 // Glaives cast it on Flames. Not sure if this is the right spell. +#define SPELL_SHADOW_DEMON_PASSIVE 41079 // Adds the "shadowform" aura to Shadow Demons. +#define SPELL_CONSUME_SOUL 41080 // Once the Shadow Demons reach their target, they use this to kill them +#define SPELL_PARALYZE 41083 // Shadow Demons cast this on their target +#define SPELL_PURPLE_BEAM 39123 // Purple Beam connecting Shadow Demon to their target +#define SPELL_CAGE_TRAP_DUMMY 40761 // Put this in DB for cage trap GO. +#define SPELL_EYE_BLAST_TRIGGER 40017 // This summons Demon Form every few seconds and deals ~20k damage in its radius +#define SPELL_EYE_BLAST 39908 // This does the blue flamey animation. +#define SPELL_FLAME_CRASH_EFFECT 40836 // Firey blue ring of circle that the other flame crash summons +#define SPELL_BLAZE_EFFECT 40610 // Green flame on the ground, triggers damage (5k) every few seconds +#define SPELL_BLAZE_SUMMON 40637 // Summons the Blaze creature +#define SPELL_DEMON_FIRE 40029 // Blue fire trail left by Eye Blast. Deals 2k per second if players stand on it. +#define SPELL_CAGED 40695 // Caged Trap triggers will cast this on Illidan if he is within 3 yards +#define SPELL_CAGE_TRAP_SUMMON 40694 // Summons a Cage Trap GO (bugged) on the ground along with a Cage Trap Disturb Trigger mob (working) +#define SPELL_CAGE_TRAP_BEAM 40713 // 8 Triggers on the ground in an octagon cast spells like this on Illidan 'caging him' +#define SPELL_FLAME_BLAST 40631 // Flames of Azzinoth use this. Frontal cone AoE 7k-9k damage. +#define SPELL_CHARGE 40602 // Flames of Azzinoth charges whoever is too far from them. They enrage after this. For simplicity, we'll use the same enrage as Illidan. +#define SPELL_TELEPORT_VISUAL 41232 // Teleport visual for Maiev +#define SPELL_SHADOWFIEND_PASSIVE 41913 // Passive aura for shadowfiends + +// Other defines +#define CENTER_X 676.740 +#define CENTER_Y 305.297 +#define CENTER_Z 353.192 + +/**** Creature Summon and Recognition IDs ****/ +enum CreatureEntry +{ + EMPTY = 0, + AKAMA = 22990, + ILLIDAN_STORMRAGE = 22917, + BLADE_OF_AZZINOTH = 22996, + FLAME_OF_AZZINOTH = 22997, + MAIEV_SHADOWSONG = 23197, + SHADOW_DEMON = 23375, + DEMON_FIRE = 23069, + FLAME_CRASH = 23336, + ILLIDAN_DOOR_TRIGGER = 23412, + SPIRIT_OF_OLUM = 23411, + SPIRIT_OF_UDALO = 23410, + ILLIDARI_ELITE = 23226, + PARASITIC_SHADOWFIEND = 23498, + CAGE_TRAP_TRIGGER = 23292, +}; + +/*** Phase Names ***/ +enum Phase +{ + PHASE_NORMAL = 1, + PHASE_FLIGHT = 2, + PHASE_NORMAL_2 = 3, + PHASE_DEMON = 4, + PHASE_NORMAL_MAIEV = 5, + PHASE_DEMON_SEQUENCE = 6, +}; + +struct Yells +{ + uint32 sound; + char* text; + uint32 creature, timer, emote; + bool Talk; +}; + +static Yells Conversation[]= +{ + {11463, "Akama... your duplicity is hardly surprising. I should have slaughtered you and your malformed brethren long ago.", ILLIDAN_STORMRAGE, 8000, 0, true}, + {0, NULL, ILLIDAN_STORMRAGE, 5000, 396, true}, + {11389, "We've come to end your reign, Illidan. My people and all of Outland shall be free!", AKAMA, 7000, 25, true}, + {0, NULL, AKAMA, 5000, 66, true}, + {11464, "Boldly said. But I remain unconvinced.", ILLIDAN_STORMRAGE, 8000, 396, true}, + {11380, "The time has come! The moment is at hand!", AKAMA, 3000, 22, true}, + {0, NULL, AKAMA, 2000, 15, true}, + {11466, "You are not prepared!", ILLIDAN_STORMRAGE, 3000, 406, true}, + {0, NULL, EMPTY, 1000, 0, true}, + {0, NULL, EMPTY, 0, 0, false}, + {11476, "Is this it, mortals? Is this all the fury you can muster?", ILLIDAN_STORMRAGE, 8000, 0, true}, + {11491, "Their fury pales before mine, Illidan. We have some unsettled business between us.", MAIEV_SHADOWSONG, 8000, 5, true}, + {11477, "Maiev... How is this even possible?", ILLIDAN_STORMRAGE, 7000, 1, true}, + {11492, "Ah... my long hunt is finally over. Today, Justice will be done!", MAIEV_SHADOWSONG, 8000, 15, true}, + {11470, "Feel the hatred of ten thousand years!", ILLIDAN_STORMRAGE, 1000, 0, false}, + {11496, "Ahh... It is finished. You are beaten.", MAIEV_SHADOWSONG, 6000, 0, true}, + { // Emote dead for now. Kill him later + 11478, "You have won... Maiev...but the huntress... is nothing...without the hunt... you... are nothing... without me..", ILLIDAN_STORMRAGE, 22000, 65, true + }, + {11497, "He is right. I feel nothing... I am nothing... Farewell, champions.", MAIEV_SHADOWSONG, 9000, 0, true}, + {11498, NULL, MAIEV_SHADOWSONG, 0, true}, + {11387, "The Light will fill these dismal halls once again. I swear it.", AKAMA, 8000, 0, true}, + {0, NULL, EMPTY, 1000, 0, false} +}; + +static Yells RandomTaunts[]= +{ + {11467, "I can feel your hatred.", ILLIDAN_STORMRAGE, 0, 0, false}, + {11468, "Give in to your fear!", ILLIDAN_STORMRAGE, 0, 0, false}, + {11469, "You know nothing of power!", ILLIDAN_STORMRAGE, 0, 0, false}, + {11471, "Such... arrogance!", ILLIDAN_STORMRAGE, 0, 0, false} +}; + +static Yells MaievTaunts[]= +{ + {11493, "That is for Naisha!", MAIEV_SHADOWSONG, 0, false}, + {11494, "Bleed as I have bled!", MAIEV_SHADOWSONG, 0, 0, false}, + {11495, "There shall be no prison for you this time!", MAIEV_SHADOWSONG, 0, 0, false}, + {11500, "Meet your end, demon!", MAIEV_SHADOWSONG, 0, 0, false} +}; + +struct Locations +{ + float x, y, z; + uint32 id; +}; + +static Locations GlaivePosition[]= +{ + {695.105, 305.303, 354.256}, + {659.338, 305.303, 354.256}, + {700.105, 305.303, 354.256}, + {664.338, 305.303, 354.256} +}; + +static Locations EyeBlast[]= +{ + {650.697, 320.128, 353.730}, + {652.799, 275.091, 353.367}, + {701.527, 273.815, 353.230}, + {709.865, 325.654, 353.322} +}; + +static Locations AkamaWP[]= +{ + { 770.01, 304.50, 312.29 }, // Bottom of the first stairs, at the doors + { 780.66, 304.50, 319.74 }, // Top of the first stairs + { 790.13, 319.68, 319.76 }, // Bottom of the second stairs (left from the entrance) + { 787.17, 347.38, 341.42 }, // Top of the second stairs + { 781.34, 350.31, 341.44 }, // Bottom of the third stairs + { 762.60, 361.06, 353.60 }, // Top of the third stairs + { 756.35, 360.52, 353.27 }, // Before the door-thingy + { 743.82, 342.21, 353.00 }, // Somewhere further + { 732.69, 305.13, 353.00 }, // In front of Illidan + { 738.11, 365.44, 353.00 }, // in front of the door-thingy (the other one!) + { 792.18, 366.62, 341.42 }, // Down the first flight of stairs + { 796.84, 304.89, 319.76 }, // Down the second flight of stairs + { 782.01, 304.55, 319.76 } // Final location - back at the initial gates. This is where he will fight the minions! +}; +// 755.762, 304.0747, 312.1769 -- This is where Akama should be spawned +static Locations SpiritSpawns[]= +{ + {755.5426, 309.9156, 312.2129, SPIRIT_OF_UDALO}, + {755.5426, 298.7923, 312.0834, SPIRIT_OF_OLUM} +}; + +struct WayPoints +{ + WayPoints(uint32 _id, float _x, float _y, float _z) + { + id = _id; + x = _x; + y = _y; + z = _z; + } + uint32 id; + float x, y, z; +}; + +struct Animation // For the demon transformation +{ + uint32 aura, unaura, timer, size, displayid, phase; + bool equip; +}; + +static Animation DemonTransformation[]= +{ + {SPELL_DEMON_TRANSFORM_1, 0, 1300, 0, 0, 6, true}, + {SPELL_DEMON_TRANSFORM_2, SPELL_DEMON_TRANSFORM_1, 4000, 0, 0, 6, true}, + {SPELL_DEMON_FORM, 0, 3000, 1073741824, 21322, 6, false}, + {SPELL_DEMON_TRANSFORM_3, SPELL_DEMON_TRANSFORM_2, 3500, 0, 0, 6, false}, + {0, 0, 0, 0, 0, 4, false}, + {SPELL_DEMON_TRANSFORM_1, 0, 1500, 0, 0, 6, false}, + {SPELL_DEMON_TRANSFORM_2, SPELL_DEMON_TRANSFORM_1, 4000, 0, 0, 6, false}, + {0, SPELL_DEMON_FORM, 3000, 1069547520, 21135, 6, false}, + {SPELL_DEMON_TRANSFORM_3, SPELL_DEMON_TRANSFORM_2, 3500, 0, 0, 6, true}, + {0, 0, 0, 0, 0, 8, true} +}; + +/**** Demon Fire will be used for Eye Blast. Illidan needs to have access to it's vars and functions, so we'll set it here ****/ +struct MANGOS_DLL_DECL demonfireAI : public ScriptedAI +{ + demonfireAI(Creature *c) : ScriptedAI(c) + { + pInstance = ((ScriptedInstance*)c->GetInstanceData()); + Reset(); + } + + ScriptedInstance* pInstance; + + uint64 IllidanGUID; + + bool IsTrigger; + + uint32 CheckTimer; + uint32 DemonFireTimer; + uint32 DespawnTimer; + + void Reset() + { + IllidanGUID = 0; + + IsTrigger = false; + + CheckTimer = 2000; + DemonFireTimer = 0; + DespawnTimer = 45000; + } + + void Aggro(Unit *who) {} + void AttackStart(Unit* who) { } + void MoveInLineOfSight(Unit *who){ } + + void UpdateAI(const uint32 diff) + { + if(IsTrigger) + return; + + m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + + if(CheckTimer < diff) + { + if(!IllidanGUID && pInstance) + { + IllidanGUID = pInstance->GetData64(DATA_ILLIDANSTORMRAGE); + if(IllidanGUID) + { + Unit* Illidan = Unit::GetUnit((*m_creature), IllidanGUID); + if(Illidan && !Illidan->HasUnitMovementFlag(MOVEMENTFLAG_LEVITATING)) + m_creature->setDeathState(JUST_DIED); + } + } + CheckTimer = 2000; + }else CheckTimer -= diff; + + if(DemonFireTimer < diff) + { + DoCast(m_creature, SPELL_DEMON_FIRE); + DemonFireTimer = 30000; + }else DemonFireTimer -= diff; + + if(DespawnTimer < diff) + m_creature->setDeathState(JUST_DIED); + else DespawnTimer -= diff; + + DoMeleeAttackIfReady(); + } +}; + +/******* Functions and vars for Akama's AI ******/ +struct MANGOS_DLL_SPEC npc_akama_illidanAI : public ScriptedAI +{ + npc_akama_illidanAI(Creature* c) : ScriptedAI(c) + { + pInstance = ((ScriptedInstance*)c->GetInstanceData()); + WayPointList.clear(); + Reset(); + } + + /* Instance Data */ + ScriptedInstance* pInstance; + + /* Timers */ + uint32 ChannelTimer; + uint32 TalkTimer; + uint32 WalkTimer; + uint32 SummonMinionTimer; + + /* GUIDs */ + uint64 IllidanGUID; + uint64 PlayerGUID; + uint64 SpiritGUID[2]; + uint64 ChannelGUID; + + bool IsTalking; + bool StartChanneling; + bool DoorOpen; + bool FightMinions; + bool IsReturningToIllidan; + bool IsWalking; + uint32 TalkCount; + uint32 ChannelCount; + + std::list WayPointList; + std::list::iterator WayPoint; + + void BeginEvent(uint64 PlayerGUID); + void Aggro(Unit *who) {} + + void Reset() + { + if(pInstance) + { + pInstance->SetData(DATA_ILLIDANSTORMRAGEEVENT, NOT_STARTED); + GameObject* Gate = GameObject::GetGameObject((*m_creature), pInstance->GetData64(DATA_GAMEOBJECT_ILLIDAN_GATE)); + if( Gate && !Gate->GetGoState() ) + Gate->SetGoState(1); // close door if already open (when raid wipes or something) + + for(uint8 i = DATA_GAMEOBJECT_ILLIDAN_DOOR_R; i < DATA_GAMEOBJECT_ILLIDAN_DOOR_L + 1; ++i) + { + GameObject* Door = GameObject::GetGameObject((*m_creature), pInstance->GetData64(i)); + if(Door) + Door->SetGoState(0); + } + } + + IllidanGUID = 0; + PlayerGUID = 0; + ChannelGUID = 0; + for(uint8 i = 0; i < 2; ++i) SpiritGUID[i] = 0; + + ChannelTimer = 0; + ChannelCount = 0; + SummonMinionTimer = 2000; + + WalkTimer = 0; + + TalkTimer = 0; + TalkCount = 0; + + KillAllElites(); + + IsReturningToIllidan = false; + FightMinions = false; + IsTalking = false; + StartChanneling = false; + DoorOpen = false; + + m_creature->SetUInt32Value(UNIT_NPC_FLAGS, 0); // Database sometimes has strange values.. + m_creature->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP); + m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + m_creature->SetVisibility(VISIBILITY_ON); + } + + // Do not call reset in Akama's evade mode, as this will stop him from summoning minions after he kills the first bit + void EnterEvadeMode() + { + InCombat = false; + + m_creature->RemoveAllAuras(); + m_creature->DeleteThreatList(); + m_creature->CombatStop(); + } + + void KillAllElites() + { + std::list::iterator itr; + for(itr = m_creature->getThreatManager().getThreatList().begin(); itr != m_creature->getThreatManager().getThreatList().end(); ++itr) + { + Unit* pUnit = Unit::GetUnit((*m_creature), (*itr)->getUnitGuid()); + if(pUnit && (pUnit->GetTypeId() == TYPEID_UNIT) && (pUnit->GetEntry() == ILLIDARI_ELITE)) + pUnit->setDeathState(JUST_DIED); + } + } + + void ReturnToIllidan() + { + KillAllElites(); + InCombat = false; + FightMinions = false; + IsReturningToIllidan = true; + WayPoint = WayPointList.begin(); + m_creature->SetSpeed(MOVE_RUN, 2.0f); + m_creature->RemoveUnitMovementFlag(MOVEMENTFLAG_WALK_MODE); + IsWalking = true; + } + + void AddWaypoint(uint32 id, float x, float y, float z) + { + WayPoints AkamaWP(id, x, y, z); + WayPointList.push_back(AkamaWP); + } + + void DamageTaken(Unit *done_by, uint32 &damage) + { + if(damage > m_creature->GetHealth() && (done_by->GetGUID() != m_creature->GetGUID())) + { + damage = 0; + DoCast(m_creature, SPELL_HEALING_POTION); + } + } + + void BeginDoorEvent(Player* player) + { + if(!pInstance) + return; + + outstring_log("SD2: Akama - Door event initiated by player %s", player->GetName()); + PlayerGUID = player->GetGUID(); + + GameObject* Gate = GameObject::GetGameObject((*m_creature), pInstance->GetData64(DATA_GAMEOBJECT_ILLIDAN_GATE)); + if(Gate) + { + float x,y,z; + Gate->GetPosition(x, y, z); + Creature* Channel = m_creature->SummonCreature(ILLIDAN_DOOR_TRIGGER, x, y, z+5, 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 360000); + if(Channel) + { + ChannelGUID = Channel->GetGUID(); + // Invisible but spell visuals can still be seen. + Channel->SetUInt32Value(UNIT_FIELD_DISPLAYID, 11686); + Channel->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + float PosX, PosY, PosZ; + m_creature->GetPosition(PosX, PosY, PosZ); + for(uint8 i = 0; i < 2; ++i) + { + Creature* Spirit = m_creature->SummonCreature(SpiritSpawns[i].id, SpiritSpawns[i].x, SpiritSpawns[i].y, SpiritSpawns[i].z, 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 360000); + if(Spirit) + { + Spirit->SetVisibility(VISIBILITY_OFF); + SpiritGUID[i] = Spirit->GetGUID(); + } + } + StartChanneling = true; + m_creature->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP); + m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + DoCast(Channel, SPELL_AKAMA_DOOR_FAIL); + } + } + } + + void MovementInform(uint32 type, uint32 id) + { + if(type != POINT_MOTION_TYPE || !IsWalking) + return; + + if(WayPoint->id != id) + return; + + switch(id) + { + case 6: + if(!IsReturningToIllidan) + { // open the doors that close the summit + for(uint32 i = DATA_GAMEOBJECT_ILLIDAN_DOOR_R; i < DATA_GAMEOBJECT_ILLIDAN_DOOR_L+1; ++i) + { + GameObject* Door = GameObject::GetGameObject((*m_creature), pInstance->GetData64(i)); + if(Door) + Door->SetGoState(0); + } + } + case 7: + if(IsReturningToIllidan) + { + IsWalking = false; + if(IllidanGUID) + { + Unit* Illidan = Unit::GetUnit((*m_creature), IllidanGUID); + if(Illidan) + { + float dx = Illidan->GetPositionX() + rand()%15; + float dy = Illidan->GetPositionY() + rand()%15; + m_creature->GetMotionMaster()->MovePoint(13, dx, dy, Illidan->GetPositionZ()); + m_creature->SetUInt64Value(UNIT_FIELD_TARGET, IllidanGUID); + } + } + } + break; + case 8: + m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + if(!IsReturningToIllidan) + { + IsWalking = false; + BeginEvent(PlayerGUID); + } + break; + case 12: + IsWalking = false; + FightMinions = true; + m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + break; + } + + ++WayPoint; + WalkTimer = 200; + } + + void DeleteFromThreatList() + { + if(!IllidanGUID) return; // If we do not have Illidan's GUID, do not proceed + // Create a pointer to Illidan + Creature* Illidan = ((Creature*)Unit::GetUnit((*m_creature), IllidanGUID)); + if(!Illidan) return; // No use to continue if Illidan does not exist + std::list::iterator itr = Illidan->getThreatManager().getThreatList().begin(); + for( ; itr != Illidan->getThreatManager().getThreatList().end(); ++itr) + { + // Loop through threatlist till our GUID is found in it. + if((*itr)->getUnitGuid() == m_creature->GetGUID()) + { + (*itr)->removeReference(); // Delete ourself from his threatlist. + return; // No need to continue anymore. + } + } + + // Now we delete our threatlist to prevent attacking anyone for now + m_creature->DeleteThreatList(); + } + + void UpdateAI(const uint32 diff) + { + if(IllidanGUID) + { + Creature* Illidan = ((Creature*)Unit::GetUnit((*m_creature), IllidanGUID)); + if(Illidan) + { + if(Illidan->IsInEvadeMode() && !m_creature->IsInEvadeMode()) + EnterEvadeMode(); + + if(((Illidan->GetHealth()*100 / Illidan->GetMaxHealth()) < 85) && InCombat && !FightMinions) + { + if(TalkTimer < diff) + { + switch(TalkCount) + { + case 0: + Illidan->Yell(SAY_AKAMA_MINION, LANG_UNIVERSAL, 0); + DoPlaySoundToSet(Illidan, SOUND_AKAMA_MINION); + TalkTimer = 8000; + TalkCount = 1; + break; + case 1: + DoYell(SAY_AKAMA_LEAVE, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_AKAMA_LEAVE); + TalkTimer = 3000; + TalkCount = 2; + break; + case 2: + IsTalking = true; + TalkTimer = 2000; + m_creature->RemoveAllAuras(); + m_creature->CombatStop(); + m_creature->AttackStop(); + m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + TalkCount = 3; + break; + case 3: + DeleteFromThreatList(); + IsWalking = true; + WayPoint = WayPointList.begin(); + std::advance(WayPoint, 9); + m_creature->RemoveUnitMovementFlag(MOVEMENTFLAG_WALK_MODE); + break; + } + }else TalkTimer -= diff; + } + + if(((Illidan->GetHealth()*100 / Illidan->GetMaxHealth()) < 4) && !IsReturningToIllidan) + ReturnToIllidan(); + } + }else + { + if(pInstance) + IllidanGUID = pInstance->GetData64(DATA_ILLIDANSTORMRAGE); + } + + if(IsWalking && WalkTimer) + { + if(WalkTimer <= diff) + { + if(WayPoint == WayPointList.end()) + return; + m_creature->GetMotionMaster()->MovePoint(WayPoint->id, WayPoint->x, WayPoint->y,WayPoint->z); + WalkTimer = 0; + }else WalkTimer -= diff; + } + + if(StartChanneling) + { + if(ChannelTimer < diff) + { + switch(ChannelCount) + { + case 3: + if(!DoorOpen) + { + m_creature->InterruptNonMeleeSpells(true); + for(uint8 i = 0; i < 2; ++i) + { + if(SpiritGUID[i]) + { + Unit* Spirit = Unit::GetUnit((*m_creature), SpiritGUID[i]); + if(Spirit) + Spirit->InterruptNonMeleeSpells(true); + } + } + GameObject* Gate = GameObject::GetGameObject((*m_creature), pInstance->GetData64(DATA_GAMEOBJECT_ILLIDAN_GATE)); + if(Gate) + Gate->SetGoState(0); + ChannelCount++; + ChannelTimer = 5000; + } + break; + case 4: + m_creature->HandleEmoteCommand(EMOTE_ONESHOT_SALUTE); + ChannelTimer = 2000; + ChannelCount++; + break; + case 5: + DoYell(SAY_AKAMA_BEWARE, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_AKAMA_BEWARE); + if(ChannelGUID) + { + Unit* ChannelTarget = Unit::GetUnit((*m_creature), ChannelGUID); + if(ChannelTarget) + ChannelTarget->setDeathState(JUST_DIED); + } + for(uint8 i = 0; i < 2; ++i) + { + if(SpiritGUID[i]) + { + Unit* Spirit = Unit::GetUnit((*m_creature), SpiritGUID[i]); + if(Spirit) + Spirit->setDeathState(JUST_DIED); + } + } + ChannelTimer = 6000; + ChannelCount++; + break; + case 6: + StartChanneling = false; + if(WayPointList.empty()) + { + error_log("SD2: Akama has no waypoints to start with!"); + return; + } + + WayPoint = WayPointList.begin(); + m_creature->AddUnitMovementFlag(MOVEMENTFLAG_WALK_MODE); + m_creature->GetMotionMaster()->MovePoint(WayPoint->id, WayPoint->x, WayPoint->y, WayPoint->z); + IsWalking = true; + break; + default: + if(ChannelGUID) + { + Unit* Channel = Unit::GetUnit((*m_creature), ChannelGUID); + if(Channel) + { + m_creature->InterruptNonMeleeSpells(true); + + for(uint8 i = 0; i < 2; ++i) + { + if(SpiritGUID[i]) + { + Unit* Spirit = Unit::GetUnit((*m_creature), SpiritGUID[i]); + if(Spirit) + { + Spirit->InterruptNonMeleeSpells(true); + if(ChannelCount%2 == 0) + { + Spirit->CastSpell(Channel, SPELL_DEATHSWORN_DOOR_CHANNEL,false); + DoCast(Channel, SPELL_AKAMA_DOOR_CHANNEL); + } + else + { + if(Spirit->GetVisibility() == VISIBILITY_OFF) + Spirit->SetVisibility(VISIBILITY_ON); + } + } + } + } + if(ChannelCount < 3) + ChannelCount++; + ChannelTimer = 10000; + } + break; + } + } + }else ChannelTimer -= diff; + } + + if(FightMinions) + { + if(SummonMinionTimer < diff) + { + if(IllidanGUID) + { + Creature* Illidan = ((Creature*)Unit::GetUnit((*m_creature), IllidanGUID)); + if(!Illidan || Illidan->IsInEvadeMode()) + { + Reset(); + EnterEvadeMode(); + return; + } + } + + float x,y,z; + m_creature->GetPosition(x,y,z); + Creature* Elite = m_creature->SummonCreature(ILLIDARI_ELITE, x+rand()%10, y+rand()%10, z, 0, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 30000); + if(Elite) + { + Elite->AI()->AttackStart(m_creature); + Elite->AddThreat(m_creature, 1000000.0f); + AttackStart(Elite); + } + SummonMinionTimer = 10000 + rand()%6000; + }else SummonMinionTimer -= diff; + } + + // If we don't have a target, or is talking, or has run away, return + if(!m_creature->SelectHostilTarget() || !m_creature->getVictim()) return; + + DoMeleeAttackIfReady(); + } +}; + +/************* Custom check used for Agonizing Flames ***************/ +class AgonizingFlamesTargetCheck +{ + public: + AgonizingFlamesTargetCheck(Unit const* unit) : pUnit(unit) {} + bool operator() (Player* plr) + { + // Faster than square rooting + if(!plr->isGameMaster() && pUnit->GetDistance2d(plr) > 225) + return true; + + return false; + } + + private: + Unit const* pUnit; +}; + +/************************************** Illidan's AI ***************************************/ +struct MANGOS_DLL_SPEC boss_illidan_stormrageAI : public ScriptedAI +{ + boss_illidan_stormrageAI(Creature* c) : ScriptedAI(c) + { + pInstance = ((ScriptedInstance*)c->GetInstanceData()); + Reset(); + } + + /** Instance Data **/ + ScriptedInstance* pInstance; + + /** Generic **/ + bool IsTalking; + bool HasSummoned; + bool RefaceVictim; + bool InformAkama; + uint32 Phase; + uint32 GlobalTimer; + uint32 TalkCount; + uint32 DemonFormSequence; + + /** GUIDs **/ + uint64 FlameGUID[2]; + uint64 GlaiveGUID[2]; + uint64 AkamaGUID; + uint64 MaievGUID; + + /** Timers **/ + uint32 ShearTimer; + uint32 DrawSoulTimer; + uint32 FlameCrashTimer; + uint32 ParasiticShadowFiendTimer; + uint32 FireballTimer; + uint32 EyeBlastTimer; + uint32 DarkBarrageTimer; + uint32 SummonBladesTimer; // Animate summoning the Blades of Azzinoth in Phase 2 + uint32 SummonFlamesTimer; // Summon Flames of Azzinoth in Phase 2 + uint32 CheckFlamesTimer; // This is used to check the status of the Flames to see if we should begin entering Phase 3 or not. + uint32 RetrieveBladesTimer; // Animate retrieving the Blades of Azzinoth in Phase 2 -> 3 transition + uint32 LandTimer; // This is used at the end of phase 2 to signal Illidan landing after Flames are dead + uint32 AgonizingFlamesTimer; + uint32 ShadowBlastTimer; + uint32 FlameBurstTimer; + uint32 ShadowDemonTimer; + uint32 TalkTimer; + uint32 TransformTimer; + uint32 EnrageTimer; + uint32 CageTimer; + uint32 LayTrapTimer; + uint32 AnimationTimer; + uint32 TauntTimer; // This is used for his random yells + uint32 FaceVictimTimer; + uint32 BerserkTimer; + + void Reset() + { + Phase = PHASE_NORMAL; + + // Check if any flames/glaives are alive/existing. Kill if alive and set GUIDs to 0 + for(uint8 i = 0; i < 2; i++) + { + if(FlameGUID[i]) + { + Unit* Flame = Unit::GetUnit((*m_creature), FlameGUID[i]); + if(Flame) + Flame->setDeathState(JUST_DIED); + FlameGUID[i] = 0; + } + + if(GlaiveGUID[i]) + { + Unit* Glaive = Unit::GetUnit((*m_creature), GlaiveGUID[i]); + if(Glaive) + Glaive->setDeathState(JUST_DIED); + GlaiveGUID[i] = 0; + } + } + + if(AkamaGUID) + { + Creature* Akama = ((Creature*)Unit::GetUnit((*m_creature), AkamaGUID)); + if(Akama) + { + if(!Akama->isAlive()) + Akama->Respawn(); + ((npc_akama_illidanAI*)Akama->AI())->Reset(); + ((npc_akama_illidanAI*)Akama->AI())->EnterEvadeMode(); + Akama->GetMotionMaster()->MoveTargetedHome(); + } + } + + InformAkama = false; + RefaceVictim = false; + HasSummoned = false; + AkamaGUID = 0; + MaievGUID = 0; + + FaceVictimTimer = 1000; + BerserkTimer = 1500000; + GlobalTimer = 0; + DemonFormSequence = 0; + + /** Normal Form **/ + ShearTimer = 20000 + (rand()%11 * 1000); // 20 to 30 seconds + FlameCrashTimer = 30000; //30 seconds + ParasiticShadowFiendTimer = 25000; // 25 seconds + DrawSoulTimer = 50000; // 50 seconds + + /** Phase 2 **/ + SummonBladesTimer = 10000; + SummonFlamesTimer = 20000; // Phase 2 timers may be incorrect + FireballTimer = 5000; + DarkBarrageTimer = 45000; + EyeBlastTimer = 30000; + CheckFlamesTimer = 5000; + RetrieveBladesTimer = 5000; + LandTimer = 0; + + /** Phase 3+ **/ + AgonizingFlamesTimer = 35000; // Phase 3+ timers may be incorrect + ShadowBlastTimer = 3000; + FlameBurstTimer = 10000; + ShadowDemonTimer = 30000; + TransformTimer = 90000; + EnrageTimer = 40000; + CageTimer = 30000; + LayTrapTimer = CageTimer + 2000; + AnimationTimer = 0; + + TauntTimer = 30000; // This timer may be off. + + m_creature->SetUInt32Value(UNIT_FIELD_DISPLAYID, 21135); + m_creature->InterruptNonMeleeSpells(false); + m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + // Unequip warglaives if needed + m_creature->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_DISPLAY, 0); + m_creature->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_DISPLAY+1, 0); + m_creature->RemoveUnitMovementFlag(MOVEMENTFLAG_LEVITATING); + + IsTalking = false; + + TalkCount = 0; + TalkTimer = 0; + + if(pInstance) + pInstance->SetData(DATA_ILLIDANSTORMRAGEEVENT, NOT_STARTED); + } + + void Aggro(Unit *who) { DoZoneInCombat(); } + + void AttackStart(Unit *who) + { + if(!who || IsTalking || Phase == 2 || Phase == 4 || Phase == 6 || m_creature->HasAura(SPELL_KNEEL, 0)) + return; + + if (who->isTargetableForAttack() && who!= m_creature) + { + //Begin melee attack if we are within range + DoStartAttackAndMovement(who); + } + } + + void MoveInLineOfSight(Unit *who) + { + if (!who || m_creature->getVictim() || IsTalking || m_creature->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE)) + return; + + if (who->isTargetableForAttack() && who->isInAccessablePlaceFor(m_creature) && m_creature->IsHostileTo(who)) + { + if (!m_creature->canFly() && m_creature->GetDistanceZ(who) > CREATURE_Z_ATTACK_RANGE) + return; + + float attackRadius = m_creature->GetAttackDistance(who); + if (m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->IsWithinLOSInMap(who)) + { + if(who->HasStealthAura()) + who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); + + DoStartAttackAndMovement(who); + } + } + } + + void JustDied(Unit *killer) + { + IsTalking = false; + TalkCount = 0; + TalkTimer = 0; + + m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + + if(!pInstance) + return; + // Completed + pInstance->SetData(DATA_ILLIDANSTORMRAGEEVENT, DONE); + + for(uint8 i = DATA_GAMEOBJECT_ILLIDAN_DOOR_R; i < DATA_GAMEOBJECT_ILLIDAN_DOOR_L + 1; ++i) + { + GameObject* Door = GameObject::GetGameObject((*m_creature), pInstance->GetData64(i)); + if(Door) + Door->SetGoState(0); // Open Doors + } + + } + + void KilledUnit(Unit *victim) + { + if(victim == m_creature) return; + + switch(rand()%2) + { + case 0: + DoYell(SAY_KILL1, LANG_UNIVERSAL, victim); + DoPlaySoundToSet(m_creature, SOUND_KILL1); + break; + case 1: + DoYell(SAY_KILL2, LANG_UNIVERSAL, victim); + DoPlaySoundToSet(m_creature, SOUND_KILL2); + break; + } + } + + void DamageTaken(Unit *done_by, uint32 &damage) + { + if(damage > m_creature->GetHealth()) // Don't let ourselves be slain before we do our death speech + { + damage = 0; + m_creature->SetHealth(m_creature->GetMaxHealth()/100); + } + } + + void Cast(Unit* victim, uint32 Spell, bool triggered = false) + { + if(!victim) + return; + + RefaceVictim = true; + m_creature->SetUInt64Value(UNIT_FIELD_TARGET, victim->GetGUID()); + m_creature->CastSpell(victim, Spell, triggered); + } + + /** This will handle the cast of eye blast **/ + void CastEyeBlast() + { + m_creature->InterruptNonMeleeSpells(false); + + DarkBarrageTimer += 10000; + + DoYell(SAY_EYE_BLAST, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_EYE_BLAST); + + uint32 initial = rand()%4; + uint32 final = 0; + if(initial < 3) + final = initial+1; + + float initial_X = EyeBlast[initial].x; + float initial_Y = EyeBlast[initial].y; + float initial_Z = EyeBlast[initial].z; + + float final_X = EyeBlast[final].x; + float final_Y = EyeBlast[final].y; + float final_Z = EyeBlast[final].z; + + for(uint8 i = 0; i < 2; ++i) + { + Creature* Trigger = NULL; + Trigger = m_creature->SummonCreature(DEMON_FIRE, initial_X, initial_Y, initial_Z, 0, TEMPSUMMON_TIMED_DESPAWN, 20000); + if(Trigger) + { + ((demonfireAI*)Trigger->AI())->IsTrigger = true; + Trigger->GetMotionMaster()->MovePoint(0, final_X, final_Y, final_Z); + + if(!i) + Trigger->CastSpell(Trigger, SPELL_EYE_BLAST_TRIGGER, true); + else + { + Trigger->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + m_creature->SetUInt64Value(UNIT_FIELD_TARGET, Trigger->GetGUID()); + DoCast(Trigger, SPELL_EYE_BLAST); + } + } + } + } + + // It's only cast on players that are greater than 15 yards away from Illidan. If no one is found, cast it on MT instead (since selecting someone in that 15 yard radius would cause the flames to hit the MT anyway). + void CastAgonizingFlames() + { + // We'll use grid searching for this, using a custom searcher that selects a player that is at a distance >15 yards + Player* target = NULL; + + CellPair pair(MaNGOS::ComputeCellPair(m_creature->GetPositionX(), m_creature->GetPositionY())); + Cell cell(pair); + cell.data.Part.reserved = ALL_DISTRICT; + cell.SetNoCreate(); + + AgonizingFlamesTargetCheck check(m_creature); + MaNGOS::PlayerSearcher searcher(target, check); + TypeContainerVisitor + , GridTypeMapContainer> visitor(searcher); + + CellLock cell_lock(cell, pair); + cell_lock->Visit(cell_lock, visitor, *(m_creature->GetMap())); + + if(target) + DoCast(target, SPELL_AGONIZING_FLAMES); + else + DoCast(m_creature->getVictim(), SPELL_AGONIZING_FLAMES); + } + + void Talk(uint32 count) + { + if(!m_creature->isAlive()) return; + uint32 sound = Conversation[count].sound; + char* text = NULL; + if(Conversation[count].text) + text = Conversation[count].text; + TalkTimer = Conversation[count].timer; + uint32 emote = Conversation[count].emote; + IsTalking = Conversation[count].Talk; + Creature* creature = NULL; + uint64 GUID = 0; + if(Conversation[count].creature == ILLIDAN_STORMRAGE) + creature = m_creature; + else if(Conversation[count].creature == AKAMA) + { + if(!AkamaGUID) + { + if(pInstance) + { + AkamaGUID = pInstance->GetData64(DATA_AKAMA); + if(!AkamaGUID) + return; + GUID = AkamaGUID; + } + } + else GUID = AkamaGUID; + } + else if(Conversation[count].creature == MAIEV_SHADOWSONG) + { + if(!MaievGUID) + return; + GUID = MaievGUID; + } + else if(Conversation[count].creature == EMPTY) // This is just for special cases without speech/sounds/emotes. + return; + + if(GUID) // Now we check if we actually specified a GUID, if so: + // we grab a pointer to that creature + creature = ((Creature*)Unit::GetUnit((*m_creature), GUID)); + + if(creature) + { + creature->HandleEmoteCommand(emote); // Make the creature do some animation! + if(text) + creature->Yell(text, LANG_UNIVERSAL, 0); // Have the creature yell out some text + if(sound) + DoPlaySoundToSet(creature, sound); // Play some sound on the creature + } + } + + void Move(float X, float Y, float Z, Creature* _Creature) + { + _Creature->GetMotionMaster()->MovePoint(0, X, Y, Z); + } + + void HandleDemonTransformAnimation(uint32 count) + { + uint32 unaura = DemonTransformation[count].unaura; + uint32 aura = DemonTransformation[count].aura; + uint32 displayid = DemonTransformation[count].displayid; + AnimationTimer = DemonTransformation[count].timer; + uint32 size = DemonTransformation[count].size; + + m_creature->InterruptNonMeleeSpells(false); + + if(DemonTransformation[count].phase != 8) + { + m_creature->GetMotionMaster()->Clear(); + m_creature->GetMotionMaster()->MoveIdle(); + } + + if(unaura) + m_creature->RemoveAurasDueToSpell(unaura); + + if(aura) + DoCast(m_creature, aura, true); + + if(displayid) + // It's morphin time! + m_creature->SetUInt32Value(UNIT_FIELD_DISPLAYID, displayid); + /*if(size) + m_creature->SetUInt32Value(OBJECT_FIELD_SCALE_X, size); // Let us grow! (or shrink)*/ + + if(DemonTransformation[count].equip) + { + // Requip warglaives if needed + m_creature->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_DISPLAY, 45479); + m_creature->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_DISPLAY+1, 45481); + } + else + { + // Unequip warglaives if needed + m_creature->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_DISPLAY, 0); + m_creature->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_DISPLAY+1, 0); + } + + if(DemonTransformation[count].phase != 8) + Phase = DemonTransformation[count].phase; // Set phase properly + else + { + // Refollow and attack our old victim + m_creature->GetMotionMaster()->MoveChase(m_creature->getVictim()); + if(MaievGUID) Phase = PHASE_NORMAL_MAIEV; // Depending on whether we summoned Maiev, we switch to either phase 5 or 3 + else Phase = PHASE_NORMAL_2; + } + + if(count == 7) + { + DoResetThreat(); + m_creature->RemoveAurasDueToSpell( SPELL_DEMON_FORM ); + } + else if(count == 4) + { + DoResetThreat(); + if(!m_creature->HasAura(SPELL_DEMON_FORM, 0)) + DoCast(m_creature, SPELL_DEMON_FORM, true); + } + } + + /** To reduce the amount of code in UpdateAI, we can seperate them into different functions and simply call them from UpdateAI **/ + void EnterPhase2() + { + DoYell(SAY_TAKEOFF, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_TAKEOFF); + + SummonBladesTimer = 10000; // Summon Glaives when this decrements + SummonFlamesTimer = 20000; // Summon Flames when this decrements + GlobalTimer += 20000; + LandTimer = 0; + Phase = PHASE_FLIGHT; + m_creature->RemoveAllAuras(); + m_creature->SetUInt64Value(UNIT_FIELD_TARGET, 0); + // So players don't shoot us down + m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + // Animate our take off! + m_creature->HandleEmoteCommand(EMOTE_ONESHOT_LIFTOFF); + // We now hover! + m_creature->AddUnitMovementFlag(MOVEMENTFLAG_LEVITATING); + m_creature->GetMotionMaster()->MovePoint(0, CENTER_X, CENTER_Y, CENTER_Z); + for(uint8 i = 0; i < 2; ++i) + { + Creature* Glaive = m_creature->SummonCreature(BLADE_OF_AZZINOTH, GlaivePosition[i].x, GlaivePosition[i].y, GlaivePosition[i].z, 0, TEMPSUMMON_CORPSE_DESPAWN, 0); + if(Glaive) + { + GlaiveGUID[i] = Glaive->GetGUID(); // We need this to remove them later on + Glaive->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + Glaive->SetVisibility(VISIBILITY_OFF); + Glaive->setFaction(m_creature->getFaction()); + } + } + } + + void SummonBladesOfAzzinoth() + { + m_creature->GetMotionMaster()->Clear(false); + + LandTimer = 0; + RetrieveBladesTimer = 0; + + DoCast(m_creature, SPELL_THROW_GLAIVE2); // Make it look like we're throwing the glaives on the ground + // We no longer wear the glaives! + m_creature->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_DISPLAY, 0); + // since they are now channeling the flames (or will be) + m_creature->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_DISPLAY+1, 0); + for(uint8 i = 0; i < 2; ++i) + { + Creature* Glaive = NULL; + Glaive = ((Creature*)Unit::GetUnit((*m_creature), GlaiveGUID[i])); + if(Glaive) + { + DoCast(Glaive, SPELL_THROW_GLAIVE, true); + Glaive->SetVisibility(VISIBILITY_ON); + } + } + } + + void SummonFlamesOfAzzinoth() + { + DoYell(SAY_SUMMONFLAMES, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_SUMMONFLAMES); + + for(uint8 i = 0; i < 2; ++i) + { + Creature* Flame = NULL; + Creature* Glaive = NULL; + Glaive = ((Creature*)Unit::GetUnit((*m_creature), GlaiveGUID[i])); + if(Glaive) + { + Flame = m_creature->SummonCreature(FLAME_OF_AZZINOTH, GlaivePosition[i+2].x, GlaivePosition[i+2].y, GlaivePosition[i+2].z, 0, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 5000); + if(Flame) + { + // Just in case the database has it as a different faction + Flame->setFaction(m_creature->getFaction()); + // Attack our target! + Flame->AI()->AttackStart(m_creature->getVictim()); + FlameGUID[i] = Flame->GetGUID(); // Record GUID in order to check if they're dead later on to move to the next phase + // Glaives do some random Beam type channel on it. + Glaive->CastSpell(Flame, SPELL_AZZINOTH_CHANNEL, true); + if(m_creature->getVictim()) + Flame->AI()->AttackStart(m_creature->getVictim()); + } + else + { + DoTextEmote("is unable to summon a Flame of Azzinoth.", NULL); + error_log("SD2 ERROR: Illidan Stormrage AI: Unable to summon Flame of Azzinoth (entry: 22997), please check your database"); + EnterEvadeMode(); + } + } + else + { + DoTextEmote("is unable to summon a Blade of Azzinoth.", NULL); + error_log("SD2 ERROR: Illidan Stormrage AI: Unable to summon Blade of Azzinoth (entry: 22996), please check your database"); + } + } + DoResetThreat(); // And now reset our threatlist + HasSummoned = true; + } + + void SummonMaiev() + { + TauntTimer += 4000; + GlobalTimer += 4000; + + m_creature->InterruptNonMeleeSpells(false); // Interrupt any of our spells + Creature* Maiev = NULL; // Summon Maiev near Illidan + Maiev = m_creature->SummonCreature(MAIEV_SHADOWSONG, m_creature->GetPositionX() + 10, m_creature->GetPositionY() + 5, m_creature->GetPositionZ()+2, 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 45000); + if(Maiev) + { + m_creature->GetMotionMaster()->Clear(false); // Stop moving, it's rude to walk and talk! + m_creature->GetMotionMaster()->MoveIdle(); + // Just in case someone is unaffected by Shadow Prison + m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + DoCast(m_creature, SPELL_SHADOW_PRISON, true); + TalkCount = 10; + IsTalking = true; // We are now talking/ + Maiev->SetVisibility(VISIBILITY_OFF); // Leave her invisible until she has to talk + Maiev->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + MaievGUID = Maiev->GetGUID(); + } + else // If Maiev cannot be summoned, reset the encounter and post some errors to the console. + { + EnterEvadeMode(); + DoTextEmote("is unable to summon Maiev Shadowsong and enter Phase 4. Resetting Encounter.", NULL); + error_log("SD2 ERROR: Unable to summon Maiev Shadowsong (entry: 23197). Check your database to see if you have the proper SQL for Maiev Shadowsong (entry: 23197)"); + } + } + + void InitializeDeath() + { + m_creature->RemoveAllAuras(); + DoCast(m_creature, SPELL_DEATH); // Animate his kneeling + stun him + // Don't let the players interrupt our talk! + m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + m_creature->GetMotionMaster()->Clear(false); // No moving! + m_creature->GetMotionMaster()->MoveIdle(); + if(MaievGUID) + { + Creature* Maiev = ((Creature*)Unit::GetUnit((*m_creature), MaievGUID)); + if(Maiev) + { + Maiev->CombatStop(); // Maiev shouldn't do anything either. No point in her attacking us =] + Maiev->GetMotionMaster()->Clear(false); // Stop her from moving as well + Maiev->GetMotionMaster()->MoveIdle(); + float distance = 10.0f; + float dx = m_creature->GetPositionX() + (distance*cos(m_creature->GetOrientation())); + float dy = m_creature->GetPositionY() + (distance*sin(m_creature->GetOrientation())); + Maiev->Relocate(dx,dy,Maiev->GetPositionZ()); + Maiev->SendMonsterMove(dx,dy,Maiev->GetPositionZ(), 0, 0, 0); + Maiev->CastSpell(Maiev, SPELL_TELEPORT_VISUAL, true); + Maiev->SetUInt64Value(UNIT_FIELD_TARGET, m_creature->GetGUID()); + } + } + IsTalking = true; + TalkCount++; + } + + void UpdateAI(const uint32 diff) + { + /*** This section will handle the conversations ***/ + if(IsTalking) // Somewhat more efficient using a function rather than a long switch + { + if(TalkTimer < diff) + { + switch(TalkCount) // This is only for specialized cases + { + case 0: + // Time to stand up! + m_creature->RemoveAurasDueToSpell( SPELL_KNEEL ); + break; + case 8: + // Equip our warglaives! + m_creature->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_DISPLAY, 45479); + m_creature->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_DISPLAY+1, 45481); + m_creature->setFaction(14); // Hostile if we weren't before + break; + case 9: + if(AkamaGUID) + { + Creature* Akama = ((Creature*)Unit::GetUnit((*m_creature), AkamaGUID)); + if(Akama) + { + Akama->GetMotionMaster()->Clear(false); + // Akama runs to us! + Akama->GetMotionMaster()->MoveChase(m_creature); + m_creature->GetMotionMaster()->Clear(false); + // We run to Akama! + m_creature->GetMotionMaster()->MoveChase(Akama); + Akama->AddThreat(m_creature, 1000000.0f); + AttackStart(Akama); // Start attacking Akama + ((npc_akama_illidanAI*)Akama->AI())->IsTalking = false; + // Akama starts attacking us + ((npc_akama_illidanAI*)Akama->AI())->AttackStart(m_creature); + } + } + // We are now attackable! + m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + break; + case 11: + if(MaievGUID) + { + Unit* Maiev = Unit::GetUnit((*m_creature), MaievGUID); + if(Maiev) + { + // Maiev is now visible + Maiev->SetVisibility(VISIBILITY_ON); + // onoz she looks like she teleported! + Maiev->CastSpell(Maiev, SPELL_TELEPORT_VISUAL, true); + // Have her face us + Maiev->SetUInt64Value(UNIT_FIELD_TARGET, m_creature->GetGUID()); + // Face her, so it's not rude =P + m_creature->SetUInt64Value(UNIT_FIELD_TARGET, Maiev->GetGUID()); + } + } + break; + case 14: + if(MaievGUID) + { + Creature* Maiev = ((Creature*)Unit::GetUnit((*m_creature), MaievGUID)); + if(Maiev) + { + Maiev->GetMotionMaster()->Clear(false); + Maiev->GetMotionMaster()->MoveChase(m_creature); + // Have Maiev add a lot of threat on us so that players don't pull her off if they damage her via AOE + Maiev->AddThreat(m_creature, 10000000.0f); + // Force Maiev to attack us. + Maiev->AI()->AttackStart(m_creature); + Maiev->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + } + } + m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + m_creature->GetMotionMaster()->MoveChase(m_creature->getVictim()); + IsTalking = false; + FaceVictimTimer = 2000; + RefaceVictim = true; + break; + case 20: // Kill ourself. + if(MaievGUID) + { + Creature* Maiev = ((Creature*)Unit::GetUnit((*m_creature), MaievGUID)); + if(Maiev) // Make Maiev leave + { + Maiev->CastSpell(Maiev, SPELL_TELEPORT_VISUAL, true); + Maiev->setDeathState(JUST_DIED); + } + } + IsTalking = false; + if(m_creature->getVictim()) + m_creature->getVictim()->DealDamage(m_creature, m_creature->GetHealth(), NULL, DIRECT_DAMAGE,SPELL_SCHOOL_MASK_NORMAL, NULL, false); + else + // Now we kill ourself + m_creature->DealDamage(m_creature, m_creature->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); + break; + } + Talk(TalkCount); // This function does most of the talking + TalkCount++; + }else TalkTimer -= diff; + } + + // If we don't have a target, return. + if(!m_creature->SelectHostilTarget() || !m_creature->getVictim() || IsTalking) + return; + + // If we are 'caged', then we shouldn't do anything such as cast spells or transform into Demon Form. + if(m_creature->HasAura(SPELL_CAGED, 0)) + { + EnrageTimer = 40000; // Just so that he doesn't immediately enrage after he stops being caged. + CageTimer = 30000; + return; + } + + // Berserk Timer - flat 25 minutes + if(!m_creature->HasAura(SPELL_BERSERK, 0) && Phase != PHASE_DEMON_SEQUENCE) + if(BerserkTimer < diff) + { + DoYell(SAY_ENRAGE, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_ENRAGE); + DoCast(m_creature, SPELL_BERSERK, true); + }else BerserkTimer -= diff; + + if(RefaceVictim) + if(FaceVictimTimer < diff) + { + m_creature->SetUInt64Value(UNIT_FIELD_TARGET, m_creature->getVictim()->GetGUID()); + FaceVictimTimer = 1000; + RefaceVictim = false; + }else FaceVictimTimer -= diff; + + /** Signal to change to phase 2 **/ + if(((m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < 65) && (Phase == PHASE_NORMAL)) + EnterPhase2(); + + /** Signal to summon Maiev **/ + if(((m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < 30) && !MaievGUID && + ((Phase != PHASE_DEMON) || (Phase != PHASE_DEMON_SEQUENCE))) + SummonMaiev(); + + /** Time for the death speech **/ + if((m_creature->GetHealth()*100 / m_creature->GetMaxHealth() < 1) && (!IsTalking) && + ((Phase != PHASE_DEMON) || (Phase != PHASE_DEMON_SEQUENCE))) + InitializeDeath(); + + /***** Spells for Phase 1, 3 and 5 (Normal Form) ******/ + if(Phase == PHASE_NORMAL || Phase == PHASE_NORMAL_2 || Phase == PHASE_NORMAL_MAIEV) + { + if(TauntTimer < diff) // His random taunt/yell timer. + { + uint32 random = rand()%4; + char* yell = RandomTaunts[random].text; + uint32 soundid = RandomTaunts[random].sound; + if(yell) + DoYell(yell, LANG_UNIVERSAL, NULL); + if(soundid) + DoPlaySoundToSet(m_creature, soundid); + TauntTimer = 32000; + }else TauntTimer -= diff; + + if(GlobalTimer < diff) // Global Timer so that spells do not overlap. + { + if(ShearTimer < diff) + { + DoCast(m_creature->getVictim(), SPELL_SHEAR); + ShearTimer = 25000 + (rand()%16 * 1000); + GlobalTimer += 2000; + }else ShearTimer -= diff; + + if(FlameCrashTimer < diff) + { + // It spawns multiple flames sometimes. Therefore, we'll do this manually. + //DoCast(m_creature->getVictim(), SPELL_FLAME_CRASH); + DoSpawnCreature(FLAME_CRASH, 0, 0, 0, 0, TEMPSUMMON_TIMED_DESPAWN, 40000); + FlameCrashTimer = 35000; + GlobalTimer += 2000; + }else FlameCrashTimer -= diff; + + if(ParasiticShadowFiendTimer < diff) + { + Unit* target = NULL; + target = SelectUnit(SELECT_TARGET_RANDOM,1); + if(target && target->isAlive() && !target->HasAura(SPELL_PARASITIC_SHADOWFIEND, 0)) + { + Cast(target, SPELL_PARASITIC_SHADOWFIEND); + ParasiticShadowFiendTimer = 40000; + } + }else ParasiticShadowFiendTimer -= diff; + + if(DrawSoulTimer < diff) + { + DoCast(m_creature->getVictim(), SPELL_DRAW_SOUL); + DrawSoulTimer = 55000; + GlobalTimer += 3000; + }else DrawSoulTimer -= diff; + }else GlobalTimer -= diff; + + if(!IsTalking) + DoMeleeAttackIfReady(); + } + + /*** Phase 2 ***/ + if(Phase == PHASE_FLIGHT) + { + // Check if we have summoned or not. + if(!HasSummoned) + { + if(SummonBladesTimer) + if(SummonBladesTimer <= diff) + { + SummonBladesOfAzzinoth(); + SummonBladesTimer = 0; + }else SummonBladesTimer -= diff; + + if(SummonFlamesTimer < diff) + { + SummonFlamesOfAzzinoth(); + }else SummonFlamesTimer -= diff; + } + + if(!m_creature->GetMotionMaster()->empty() && (m_creature->GetMotionMaster()->GetCurrentMovementGeneratorType() != POINT_MOTION_TYPE)) + m_creature->GetMotionMaster()->Clear(false); + + if(HasSummoned) + { + if(CheckFlamesTimer) + if(CheckFlamesTimer <= diff) + { + // Check if flames are dead or non-existant. If so, set GUID to 0. + for(uint8 i = 0; i < 2; i++) + { + if(FlameGUID[i]) + { + Unit* Flame = NULL; + Flame = Unit::GetUnit((*m_creature), FlameGUID[i]); + + // If the flame dies, or somehow the pointer becomes invalid, reset GUID to 0. + if(!Flame || !Flame->isAlive()) + FlameGUID[i] = 0; + } + } + CheckFlamesTimer = 500; + }else CheckFlamesTimer -= diff; + + // If both flames are dead/non-existant, kill glaives and change to phase 3. + if(!FlameGUID[0] && !FlameGUID[1] && CheckFlamesTimer) + { + RetrieveBladesTimer = 5000; // Prepare for re-equipin! + CheckFlamesTimer = 0; + } + + if(RetrieveBladesTimer) + if(RetrieveBladesTimer <= diff) // Time to get back our glaives! + { + // Interrupt any spells we might be doing *cough* DArk Barrage *cough* + m_creature->InterruptNonMeleeSpells(false); + for(uint8 i = 0; i < 2; i++) + { + if(GlaiveGUID[i]) + { + Unit* Glaive = NULL; + Glaive = Unit::GetUnit((*m_creature), GlaiveGUID[i]); + if(Glaive) + { + // Make it look like the Glaive flies back up to us + Glaive->CastSpell(m_creature, SPELL_GLAIVE_RETURNS, true); + // Despawn the Glaive + Glaive->setDeathState(JUST_DIED); + } + GlaiveGUID[i] = 0; + } + } + // Re-equip our warblades! + m_creature->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_DISPLAY, 45479); + m_creature->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_DISPLAY+1, 45481); + LandTimer = 5000; // Prepare for landin'! + RetrieveBladesTimer = 0; + }else RetrieveBladesTimer -= diff; + + if(LandTimer) + { + if(LandTimer <= diff) // Time to land! + { + DoResetThreat(); + // anndddd touchdown! + m_creature->HandleEmoteCommand(EMOTE_ONESHOT_LAND); + m_creature->RemoveUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT + MOVEMENTFLAG_LEVITATING); + Phase = PHASE_NORMAL_2; + // We should let the raid fight us =) + m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + m_creature->SetUInt64Value(UNIT_FIELD_TARGET, m_creature->getVictim()->GetGUID()); + // Chase our victim! + m_creature->GetMotionMaster()->MoveChase(m_creature->getVictim()); + }else LandTimer -= diff; + return; // Do not continue past this point if LandTimer is not 0 and we are in phase 2. + } + } + + if(GlobalTimer < diff) + { + if(FireballTimer < diff) + { + Cast(SelectUnit(SELECT_TARGET_RANDOM, 0), SPELL_FIREBALL); + FireballTimer = 5000; + }else FireballTimer -= diff; + + if(DarkBarrageTimer < diff) + { + m_creature->InterruptNonMeleeSpells(false); + DoCast(SelectUnit(SELECT_TARGET_RANDOM, 0), SPELL_DARK_BARRAGE); + DarkBarrageTimer = 35000; + GlobalTimer += 9000; + }else DarkBarrageTimer -= diff; + + if(EyeBlastTimer < diff) + { + CastEyeBlast(); + EyeBlastTimer = 30000; + }else EyeBlastTimer -= diff; + }else GlobalTimer -= diff; + } + + /** Phase 3,5 spells only**/ + if(Phase == PHASE_NORMAL_2 || Phase == PHASE_NORMAL_MAIEV) + { + if(GlobalTimer < diff) + { + if(AgonizingFlamesTimer < diff) + { + CastAgonizingFlames(); + AgonizingFlamesTimer = 60000; + }else AgonizingFlamesTimer -= diff; + }else GlobalTimer -= diff; + + if(TransformTimer < diff) + { + uint32 CurHealth = m_creature->GetHealth()*100 / m_creature->GetMaxHealth(); + // Prevent Illidan from morphing if less than 32% or 5%, as this may cause issues with the phase transition or death speech + if((CurHealth < 32 && !MaievGUID) || (CurHealth < 5)) + return; + + Phase = PHASE_DEMON_SEQUENCE; // Transform sequence + DemonFormSequence = 0; + AnimationTimer = 0; + DoYell(SAY_MORPH, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_MORPH); + TransformTimer = 60000; + FlameBurstTimer = 10000; + ShadowDemonTimer = 30000; + m_creature->GetMotionMaster()->Clear(false);// Stop moving + }else TransformTimer -= diff; + } + + /** Phase 4 spells only (Demon Form) **/ + if(Phase == PHASE_DEMON) + { + // Stop moving if we are by clearing movement generators. + if(!m_creature->GetMotionMaster()->empty()) + m_creature->GetMotionMaster()->Clear(false); + + if(TransformTimer < diff) + { + Phase = PHASE_DEMON_SEQUENCE; + DemonFormSequence = 5; + AnimationTimer = 100; + TransformTimer = 60000; + }else TransformTimer -= diff; + + if(ShadowDemonTimer < diff) + { + m_creature->InterruptNonMeleeSpells(false); + Creature* ShadowDemon = NULL; + for(uint8 i = 0; i < 4; i++) + { + Unit* target = NULL; + target = SelectUnit(SELECT_TARGET_RANDOM,0); + // only on players. + if(target && target->GetTypeId() == TYPEID_PLAYER) + { + ShadowDemon = DoSpawnCreature(SHADOW_DEMON, 0,0,0,0,TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN,25000); + if(ShadowDemon) + { + ShadowDemon->AddThreat(target, 5000000.0f); + ShadowDemon->AI()->AttackStart(target); + DoZoneInCombat(ShadowDemon); + } + } + } + ShadowDemonTimer = 60000; + }else ShadowDemonTimer -= diff; + + if(GlobalTimer < diff) + { + if(ShadowBlastTimer < diff) + { + Unit* target = SelectUnit(SELECT_TARGET_TOPAGGRO, 0); + if(target && target->isAlive()) + { + m_creature->SetUInt64Value(UNIT_FIELD_TARGET, target->GetGUID()); + DoCast(target, SPELL_SHADOW_BLAST); + ShadowBlastTimer = 4000; + GlobalTimer += 1500; + } + if(!m_creature->HasAura(SPELL_DEMON_FORM, 0)) + DoCast(m_creature, SPELL_DEMON_FORM, true); + }else ShadowBlastTimer -= diff; + + if(FlameBurstTimer < diff) + { + DoCast(m_creature, SPELL_FLAME_BURST); + FlameBurstTimer = 15000; + }else FlameBurstTimer -= diff; + }else GlobalTimer -= diff; + } + + /** Phase 5 timers. Enrage spell **/ + if(Phase == PHASE_NORMAL_MAIEV) + { + if(EnrageTimer < diff) + { + DoCast(m_creature, SPELL_ENRAGE); + EnrageTimer = 40000; + CageTimer = 30000; + TransformTimer += 10000; + }else EnrageTimer -= diff; + + // We'll handle Cage Trap in Illidan's script for simplicity's sake + if(CageTimer < diff) + { + if(MaievGUID) + { + Unit* Maiev = Unit::GetUnit((*m_creature), MaievGUID); + Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0); + if(!Maiev || !target || (target->GetTypeId() != TYPEID_PLAYER)) + return; + float X, Y, Z; + target->GetPosition(X, Y, Z); + Maiev->Relocate(X, Y, Z, Maiev->GetOrientation()); + // Make it look like she 'teleported' + Maiev->CastSpell(Maiev, SPELL_TELEPORT_VISUAL, true); + // summon the trap! + Maiev->CastSpell(Maiev, SPELL_CAGE_TRAP_SUMMON, false); + } + CageTimer = 15000; + }else CageTimer -= diff; + } + + if(Phase == PHASE_DEMON_SEQUENCE) // Demonic Transformation + { + if(AnimationTimer < diff) + { + HandleDemonTransformAnimation(DemonFormSequence); + DemonFormSequence++; + }else AnimationTimer -= diff; + } + } +}; + +/*********************** End of Illidan AI ******************************************/ + +void npc_akama_illidanAI::BeginEvent(uint64 PlayerGUID) +{ + debug_log("SD2: Akama - Illidan Introduction started. Illidan event properly begun."); + if(pInstance) + { + IllidanGUID = pInstance->GetData64(DATA_ILLIDANSTORMRAGE); + pInstance->SetData(DATA_ILLIDANSTORMRAGEEVENT, IN_PROGRESS); + } + + if(pInstance) + for(uint8 i = DATA_GAMEOBJECT_ILLIDAN_DOOR_R; i < DATA_GAMEOBJECT_ILLIDAN_DOOR_L+1; ++i) + { + GameObject* Door = GameObject::GetGameObject((*m_creature), pInstance->GetData64(i)); + if(Door) + Door->SetGoState(1); + } + + if(IllidanGUID) + { + m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + Creature* Illidan = ((Creature*)Unit::GetUnit((*m_creature), IllidanGUID)); + if(Illidan) + { + Illidan->RemoveAurasDueToSpell(SPELL_KNEEL); // Time for Illidan to stand up. + // First line of Akama-Illidan convo + ((boss_illidan_stormrageAI*)Illidan->AI())->TalkCount = 0; + // Begin Talking + ((boss_illidan_stormrageAI*)Illidan->AI())->IsTalking = true; + ((boss_illidan_stormrageAI*)Illidan->AI())->AkamaGUID = m_creature->GetGUID(); + m_creature->SetUInt64Value(UNIT_FIELD_TARGET, Illidan->GetGUID()); + Illidan->SetUInt64Value(UNIT_FIELD_TARGET, m_creature->GetGUID()); + IsTalking = true; // Prevent Akama from starting to attack him + // Prevent players from talking again + m_creature->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP); + m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + Illidan->GetMotionMaster()->Clear(false); + Illidan->GetMotionMaster()->MoveIdle(); + m_creature->GetMotionMaster()->Clear(false); + m_creature->GetMotionMaster()->MoveIdle(); + + if(PlayerGUID) + { + Unit* player = Unit::GetUnit((*m_creature), PlayerGUID); + if(player) + Illidan->AddThreat(player, 100.0f); + } + } + } +} + +bool GossipSelect_npc_akama_at_illidan(Player *player, Creature *_Creature, uint32 sender, uint32 action) +{ + if(action == GOSSIP_ACTION_INFO_DEF) // Time to begin the event + { + player->CLOSE_GOSSIP_MENU(); + ((npc_akama_illidanAI*)_Creature->AI())->BeginDoorEvent(player); + } + return true; +} + +bool GossipHello_npc_akama_at_illidan(Player *player, Creature *_Creature) +{ + player->ADD_GOSSIP_ITEM(0, GOSSIP_ITEM, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF); + player->SEND_GOSSIP_MENU(10465, _Creature->GetGUID()); + + return true; +} + +struct MANGOS_DLL_SPEC boss_maievAI : public ScriptedAI +{ + boss_maievAI(Creature *c) : ScriptedAI(c) + { + pInstance = ((ScriptedInstance*)c->GetInstanceData()); + Reset(); + }; + + uint32 TauntTimer; + uint64 IllidanGUID; + + ScriptedInstance* pInstance; + + void Reset() + { + TauntTimer = 12000; + IllidanGUID = 0; + } + + void Aggro(Unit *who) {} + + void UpdateAI(const uint32 diff) + { + if(!IllidanGUID) + { + if(pInstance) + IllidanGUID = pInstance->GetData64(DATA_ILLIDANSTORMRAGE); + }else + { + Creature* Illidan = NULL; + Illidan = ((Creature*)Unit::GetUnit((*m_creature), IllidanGUID)); + if(!Illidan || !Illidan->isAlive() || Illidan->IsInEvadeMode()) + { + m_creature->SetVisibility(VISIBILITY_OFF); + m_creature->DealDamage(m_creature, m_creature->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); + } + else if(Illidan && ((Illidan->GetHealth()*100 / Illidan->GetMaxHealth()) < 2)) + return; + } + + // Return if we don't have a target + if(!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + if(TauntTimer < diff) + { + uint32 random = rand()%4; + char* text = MaievTaunts[random].text; + uint32 sound = MaievTaunts[random].sound; + DoYell(text, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, sound); + TauntTimer = 22000 + rand()%21 * 1000; + }else TauntTimer -= diff; + + DoMeleeAttackIfReady(); + } +}; + +struct MANGOS_DLL_DECL cage_trap_triggerAI : public ScriptedAI +{ + cage_trap_triggerAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint64 IllidanGUID; + uint64 CageTrapGUID; + + uint32 DespawnTimer; + + bool Active; + bool SummonedBeams; + + void Reset() + { + IllidanGUID = 0; + CageTrapGUID = 0; + + Active = false; + SummonedBeams = false; + + DespawnTimer = 0; + + m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + } + + void Aggro(Unit *who){} + + void MoveInLineOfSight(Unit *who) + { + if(!Active) + return; + + if(who && (who->GetTypeId() != TYPEID_PLAYER)) + { + if(who->GetEntry() == ILLIDAN_STORMRAGE) // Check if who is Illidan + { + if(!IllidanGUID && m_creature->IsWithinDistInMap(who, 3) && !who->HasAura(SPELL_CAGED, 0)) + { + IllidanGUID = who->GetGUID(); + who->CastSpell(who, SPELL_CAGED, true); + DespawnTimer = 5000; + if(who->HasAura(SPELL_ENRAGE, 0)) + // Dispel his enrage + who->RemoveAurasDueToSpell(SPELL_ENRAGE); + + if(GameObject* CageTrap = GameObject::GetGameObject(*m_creature, CageTrapGUID)) + CageTrap->SetLootState(GO_JUST_DEACTIVATED); + } + } + } + } + + void UpdateAI(const uint32 diff) + { + if(DespawnTimer) + if(DespawnTimer < diff) + m_creature->DealDamage(m_creature, m_creature->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); + else DespawnTimer -= diff; + + //if(IllidanGUID && !SummonedBeams) + //{ + // if(Unit* Illidan = Unit::GetUnit(*m_creature, IllidanGUID) + // { + // //TODO: Find proper spells and properly apply 'caged' Illidan effect + // } + //} + } +}; + +bool GOHello_cage_trap(Player* plr, GameObject* go) +{ + float x, y, z; + plr->GetPosition(x, y, z); + + Creature* trigger = NULL; + + CellPair pair(MaNGOS::ComputeCellPair(x, y)); + Cell cell(pair); + cell.data.Part.reserved = ALL_DISTRICT; + cell.SetNoCreate(); + + // Grid search for nearest live creature of entry 23304 within 10 yards + MaNGOS::NearestCreatureEntryWithLiveStateInObjectRangeCheck check(*plr, 23304, true, 10); + MaNGOS::CreatureLastSearcher searcher(trigger, check); + + TypeContainerVisitor, GridTypeMapContainer> cSearcher(searcher); + + CellLock cell_lock(cell, pair); + cell_lock->Visit(cell_lock, cSearcher, *(plr->GetMap())); + + if(!trigger) + { + plr->GetSession()->SendNotification("SD2: Summon failed. This trap is now useless.", LANG_UNIVERSAL, 0); + error_log("SD2: Cage Trap- Unable to find trigger. This Cage Trap is now useless"); + return false; + } + + ((cage_trap_triggerAI*)trigger->AI())->Active = true; + go->SetGoState(0); + return true; +} + +//This is used to sort the players by distance in preparation for being charged by the flames. +struct TargetDistanceOrder : public std::binary_function +{ + const Unit* MainTarget; + TargetDistanceOrder(const Unit* Target) : MainTarget(Target) {}; + // functor for operator ">" + bool operator()(const Unit* _Left, const Unit* _Right) const + { + return (MainTarget->GetDistance(_Left) > MainTarget->GetDistance(_Right)); + } +}; + +struct MANGOS_DLL_DECL flame_of_azzinothAI : public ScriptedAI +{ + flame_of_azzinothAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 FlameBlastTimer; + uint32 SummonBlazeTimer; + uint32 ChargeTimer; + + void Reset() + { + FlameBlastTimer = 15000 + rand()%15000; + SummonBlazeTimer = 10000 + rand()%20000; + ChargeTimer = 5000; + } + + void Aggro(Unit *who) {} + + void Charge() + { + // Get the Threat List + std::list& m_threatlist = m_creature->getThreatManager().getThreatList(); + + if(!m_threatlist.size()) return; // He doesn't have anyone in his threatlist, useless to continue + + std::list targets; + std::list::iterator itr = m_threatlist.begin(); + for( ; itr!= m_threatlist.end(); ++itr) //store the threat list in a different container + { + Unit *target = Unit::GetUnit(*m_creature, (*itr)->getUnitGuid()); + //only on alive players + if(target && target->isAlive() && target->GetTypeId() == TYPEID_PLAYER ) + targets.push_back( target); + } + + //Sort the list of players + targets.sort(TargetDistanceOrder(m_creature)); + //Resize so we only get the furthest target + targets.resize(1); + + Unit* target = (*targets.begin()); + if(target && (!m_creature->IsWithinDistInMap(target, 40))) + { + DoCast(m_creature, SPELL_ENRAGE, true); + DoCast(target, SPELL_CHARGE); + } + } + + void UpdateAI(const uint32 diff) + { + // Return if we don't have a target + if(!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + if(FlameBlastTimer < diff) + { + DoCast(m_creature->getVictim(), SPELL_FLAME_BLAST); + FlameBlastTimer = 30000; + }else FlameBlastTimer -= diff; + + if(SummonBlazeTimer < diff) + { + DoCast(m_creature, SPELL_BLAZE_SUMMON); + SummonBlazeTimer = 30000 + rand()%20000; + }else SummonBlazeTimer -= diff; + + if(ChargeTimer < diff) + { + Charge(); + ChargeTimer = 5000; + }else ChargeTimer -= diff; + + DoMeleeAttackIfReady(); + } +}; + +struct MANGOS_DLL_DECL shadow_demonAI : public ScriptedAI +{ + shadow_demonAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint64 TargetGUID; + + void Reset() { TargetGUID = 0; } + + void Aggro(Unit *who) {} + + void JustDied(Unit *killer) + { + if(TargetGUID) + { + Unit* target = Unit::GetUnit((*m_creature), TargetGUID); + if(target) + target->RemoveAurasDueToSpell(SPELL_PARALYZE); + } + } + + void UpdateAI(const uint32 diff) + { + if(!m_creature->SelectHostilTarget() || !m_creature->getVictim()) return; + + // Only cast the below on players. + if(m_creature->getVictim()->GetTypeId() != TYPEID_PLAYER) return; + + if(!m_creature->getVictim()->HasAura(SPELL_PARALYZE, 0)) + { + TargetGUID = m_creature->getVictim()->GetGUID(); + m_creature->AddThreat(m_creature->getVictim(), 10000000.0f); + DoCast(m_creature, SPELL_SHADOW_DEMON_PASSIVE, true); + DoCast(m_creature->getVictim(), SPELL_PURPLE_BEAM, true); + DoCast(m_creature->getVictim(), SPELL_PARALYZE, true); + } + // Kill our target if we're very close. + if(m_creature->IsWithinDistInMap(m_creature->getVictim(), 3)) + DoCast(m_creature->getVictim(), SPELL_CONSUME_SOUL); + } +}; + +struct MANGOS_DLL_DECL flamecrashAI : public ScriptedAI +{ + flamecrashAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 FlameCrashTimer; + uint32 DespawnTimer; + + void Reset() + { + FlameCrashTimer = 3000 +rand()%5000; + DespawnTimer = 60000; + } + + void Aggro(Unit *who){ return; } + + void AttackStart(Unit *who) { } + + void MoveInLineOfSight(Unit *who){ } + + void UpdateAI(const uint32 diff) + { + if(FlameCrashTimer < diff) + { + DoCast(m_creature, SPELL_FLAME_CRASH_EFFECT); + FlameCrashTimer = 15000; + }else FlameCrashTimer -= diff; + + if(DespawnTimer < diff) + { + m_creature->SetVisibility(VISIBILITY_OFF); // So that players don't see the sparkly effect when we die. + m_creature->DealDamage(m_creature, m_creature->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); + }else DespawnTimer -= diff; + } +}; + +// Shadowfiends interact with Illidan, setting more targets in Illidan's hashmap +struct MANGOS_DLL_SPEC mob_parasitic_shadowfiendAI : public ScriptedAI +{ + mob_parasitic_shadowfiendAI(Creature* c) : ScriptedAI(c) + { + Reset(); + } + + void Reset() {} + + void Aggro(Unit* who) {} + + void DoMeleeAttackIfReady() + { + //If we are within range melee the target + if( m_creature->IsWithinDistInMap(m_creature->getVictim(), ATTACK_DISTANCE)) + { + //Make sure our attack is ready and we aren't currently casting + if( m_creature->isAttackReady() && !m_creature->IsNonMeleeSpellCasted(false)) + { + if(!m_creature->getVictim()->HasAura(SPELL_PARASITIC_SHADOWFIEND, 0)) + DoCast(m_creature->getVictim(), SPELL_PARASITIC_SHADOWFIEND, true); + m_creature->AttackerStateUpdate(m_creature->getVictim()); + m_creature->resetAttackTimer(); + } + } + } +}; + +struct MANGOS_DLL_DECL blazeAI : public ScriptedAI +{ + blazeAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 BlazeTimer; + uint32 DespawnTimer; + + void Reset() + { + BlazeTimer = 2000; + DespawnTimer = 15000; + } + + void Aggro(Unit *who){ } + + void AttackStart(Unit* who) { } + + void MoveInLineOfSight(Unit *who){ } + + void UpdateAI(const uint32 diff) + { + if(BlazeTimer < diff) + { + DoCast(m_creature, SPELL_BLAZE_EFFECT); + BlazeTimer = 15000; + }else BlazeTimer -= diff; + + if(DespawnTimer < diff) + { + m_creature->SetVisibility(VISIBILITY_OFF); + m_creature->DealDamage(m_creature, m_creature->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); + }else DespawnTimer -= diff; + } +}; + +struct MANGOS_DLL_DECL blade_of_azzinothAI : public ScriptedAI +{ + blade_of_azzinothAI(Creature* c) : ScriptedAI(c) { Reset(); } + + void Reset() {} + // Do-Nothing-But-Stand-There + void Aggro(Unit* who) { } + void AttackStart(Unit* who) { } + void MoveInLineOfSight(Unit* who) { } + +}; + +CreatureAI* GetAI_boss_illidan_stormrage(Creature *_Creature) +{ + return new boss_illidan_stormrageAI (_Creature); +} + +CreatureAI* GetAI_npc_akama_at_illidan(Creature *_Creature) +{ + npc_akama_illidanAI* Akama_AI = new npc_akama_illidanAI(_Creature); + + for(uint8 i = 0; i < 13; ++i) + Akama_AI->AddWaypoint(i, AkamaWP[i].x, AkamaWP[i].y, AkamaWP[i].z); + + return ((CreatureAI*)Akama_AI); +} + +CreatureAI* GetAI_boss_maiev(Creature *_Creature) +{ + return new boss_maievAI (_Creature); +} + +CreatureAI* GetAI_mob_flame_of_azzinoth(Creature *_Creature) +{ + return new flame_of_azzinothAI (_Creature); +} + +CreatureAI* GetAI_cage_trap_trigger(Creature *_Creature) +{ + return new cage_trap_triggerAI (_Creature); +} + +CreatureAI* GetAI_shadow_demon(Creature *_Creature) +{ + return new shadow_demonAI (_Creature); +} + +CreatureAI* GetAI_flamecrash(Creature *_Creature) +{ + return new flamecrashAI (_Creature); +} + +CreatureAI* GetAI_demonfire(Creature *_Creature) +{ + return new demonfireAI (_Creature); +} + +CreatureAI* GetAI_blaze(Creature *_Creature) +{ + return new blazeAI (_Creature); +} + +CreatureAI* GetAI_blade_of_azzinoth(Creature *_Creature) +{ + return new blade_of_azzinothAI (_Creature); +} + +CreatureAI* GetAI_parasitic_shadowfiend(Creature *_Creature) +{ + return new mob_parasitic_shadowfiendAI (_Creature); +} + +void AddSC_boss_illidan() +{ + Script* newscript; + + newscript = new Script; + newscript->Name = "boss_illidan_stormrage"; + newscript->GetAI = GetAI_boss_illidan_stormrage; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name = "npc_akama_illidan"; + newscript->GetAI = GetAI_npc_akama_at_illidan; + newscript->pGossipHello = GossipHello_npc_akama_at_illidan; + newscript->pGossipSelect = GossipSelect_npc_akama_at_illidan; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name = "boss_maiev_shadowsong"; + newscript->GetAI = GetAI_boss_maiev; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name = "mob_flame_of_azzinoth"; + newscript->GetAI = GetAI_mob_flame_of_azzinoth; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name = "mob_blade_of_azzinoth"; + newscript->GetAI = GetAI_blade_of_azzinoth; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name = "gameobject_cage_trap"; + newscript->pGOHello = GOHello_cage_trap; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="mob_cage_trap_trigger"; + newscript->GetAI = GetAI_cage_trap_trigger; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name = "mob_shadow_demon"; + newscript->GetAI = GetAI_shadow_demon; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="mob_flame_crash"; + newscript->GetAI = GetAI_flamecrash; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="mob_demon_fire"; + newscript->GetAI = GetAI_demonfire; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="mob_blaze"; + newscript->GetAI = GetAI_blaze; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name = "mob_parasitic_shadowfiend"; + newscript->GetAI = GetAI_parasitic_shadowfiend; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/black_temple/boss_mother_shahraz.cpp b/src/bindings/scripts/scripts/zone/black_temple/boss_mother_shahraz.cpp index 383e3b05656..c651c3a629a 100644 --- a/src/bindings/scripts/scripts/zone/black_temple/boss_mother_shahraz.cpp +++ b/src/bindings/scripts/scripts/zone/black_temple/boss_mother_shahraz.cpp @@ -1,353 +1,353 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Mother_Shahraz -SD%Complete: 80 -SDComment: Saber Lash missing, Fatal Attraction slightly incorrect; need to damage only if affected players are within range of each other -SDCategory: Black Temple -EndScriptData */ - -#include "precompiled.h" -#include "def_black_temple.h" - -//Spells -#define SPELL_BEAM_SINISTER 40859 -#define SPELL_BEAM_VILE 40860 -#define SPELL_BEAM_WICKED 40861 -#define SPELL_BEAM_SINFUL 40827 -#define SPELL_ATTRACTION 40871 -#define SPELL_SILENCING_SHRIEK 40823 -#define SPELL_ENRAGE 23537 -#define SPELL_SABER_LASH 43267 -#define SPELL_SABER_LASH_IMM 43690 -#define SPELL_TELEPORT_VISUAL 40869 -#define SPELL_BERSERK 45078 - -uint32 PrismaticAuras[]= -{ - 40880, // Shadow - 40882, // Fire - 40883, // Nature - 40891, // Arcane - 40896, // Frost - 40897, // Holy -}; - -//Speech'n'Sounds -#define SAY_TAUNT1 "You play, you pay." -#define SOUND_TAUNT1 11501 - -#define SAY_TAUNT2 "I'm not impressed." -#define SOUND_TAUNT2 11502 - -#define SAY_TAUNT3 "Enjoying yourselves?" -#define SOUND_TAUNT3 11503 - -#define SAY_AGGRO "So, business... Or pleasure?" -#define SOUND_AGGRO 11504 - -#define SAY_SPELL1 "You seem a little tense." -#define SOUND_SPELL1 11505 - -#define SAY_SPELL2 "Don't be shy." -#define SOUND_SPELL2 11506 - -#define SAY_SPELL3 "I'm all... yours." -#define SOUND_SPELL3 11507 - -#define SAY_SLAY1 "Easy come, easy go." -#define SOUND_SLAY1 11508 - -#define SAY_SLAY2 "So much for a happy ending." -#define SOUND_SLAY2 11509 - -#define SAY_ENRAGE "Stop toying with my emotions!" -#define SOUND_ENRAGE 11510 - -#define SAY_DEATH "I wasn't... finished." -#define SOUND_DEATH 11511 - -struct Locations -{ - float x,y,z; -}; - -static Locations TeleportPoint[]= -{ - {959.996, 212.576, 193.843}, - {932.537, 231.813, 193.838}, - {958.675, 254.767, 193.822}, - {946.955, 201.316, 192.535}, - {944.294, 149.676, 197.551}, - {930.548, 284.888, 193.367}, - {965.997, 278.398, 195.777} -}; - -struct MANGOS_DLL_DECL boss_shahrazAI : public ScriptedAI -{ - boss_shahrazAI(Creature *c) : ScriptedAI(c) - { - pInstance = ((ScriptedInstance*)c->GetInstanceData()); - Reset(); - } - - ScriptedInstance* pInstance; - - uint64 TargetGUID[3]; - uint32 BeamTimer; - uint32 BeamCount; - uint32 CurrentBeam; - uint32 PrismaticShieldTimer; - uint32 FatalAttractionTimer; - uint32 FatalAttractionExplodeTimer; - uint32 ShriekTimer; - uint32 RandomYellTimer; - uint32 EnrageTimer; - uint32 ExplosionCount; - - bool Enraged; - - void Reset() - { - if(pInstance) - pInstance->SetData(DATA_MOTHERSHAHRAZEVENT, NOT_STARTED); - - for(uint8 i = 0; i<3; i++) - TargetGUID[i] = 0; - - BeamTimer = 60000; // Timers may be incorrect - BeamCount = 0; - CurrentBeam = 0; // 0 - Sinister, 1 - Vile, 2 - Wicked, 3 - Sinful - PrismaticShieldTimer = 0; - FatalAttractionTimer = 60000; - FatalAttractionExplodeTimer = 70000; - ShriekTimer = 30000; - RandomYellTimer = 70000 + rand()%41 * 1000; - EnrageTimer = 600000; - ExplosionCount = 0; - - Enraged = false; - } - - void Aggro(Unit *who) - { - if(pInstance) - pInstance->SetData(DATA_MOTHERSHAHRAZEVENT, IN_PROGRESS); - - DoZoneInCombat(); - DoYell(SAY_AGGRO,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature, SOUND_AGGRO); - } - - void KilledUnit(Unit *victim) - { - switch(rand()%2) - { - case 0: - DoYell(SAY_SLAY1,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature, SOUND_SLAY1); - break; - case 1: - DoYell(SAY_SLAY2,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature, SOUND_SLAY2); - break; - } - } - - void JustDied(Unit *victim) - { - if(pInstance) - pInstance->SetData(DATA_MOTHERSHAHRAZEVENT, DONE); - - DoYell(SAY_DEATH, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature,SOUND_DEATH); - } - - void TeleportPlayers() - { - uint32 random = rand()%7; - float X = TeleportPoint[random].x; - float Y = TeleportPoint[random].y; - float Z = TeleportPoint[random].z; - for(uint8 i = 0; i < 3; i++) - { - Unit* pUnit = SelectUnit(SELECT_TARGET_RANDOM, 1); - if(pUnit && pUnit->isAlive() && (pUnit->GetTypeId() == TYPEID_PLAYER)) - { - TargetGUID[i] = pUnit->GetGUID(); - pUnit->CastSpell(pUnit, SPELL_TELEPORT_VISUAL, true); - DoTeleportPlayer(pUnit, X, Y, Z, pUnit->GetOrientation()); - } - } - } - - void UpdateAI(const uint32 diff) - { - if(!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - if(((m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < 10) && !Enraged) - { - Enraged = true; - DoCast(m_creature, SPELL_ENRAGE, true); - DoYell(SAY_ENRAGE, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_ENRAGE); - } - - //Randomly cast one beam. - if(BeamTimer < diff) - { - Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0); - if(!target || !target->isAlive()) - return; - - BeamTimer = 9000; - - switch(CurrentBeam) - { - case 0: - DoCast(target, SPELL_BEAM_SINISTER); - break; - case 1: - DoCast(target, SPELL_BEAM_VILE); - break; - case 2: - DoCast(target, SPELL_BEAM_WICKED); - break; - case 3: - DoCast(target, SPELL_BEAM_SINFUL); - break; - } - BeamCount++; - uint32 Beam = CurrentBeam; - if(BeamCount > 3) - while(CurrentBeam == Beam) - CurrentBeam = rand()%3; - - }else BeamTimer -= diff; - - // Random Prismatic Shield every 15 seconds. - if(PrismaticShieldTimer < diff) - { - uint32 random = rand()%6; - if(PrismaticAuras[random]) - DoCast(m_creature, PrismaticAuras[random]); - PrismaticShieldTimer = 15000; - }else PrismaticShieldTimer -= diff; - - // Select 3 random targets (can select same target more than once), teleport to a random location then make them cast explosions until they get away from each other. - if(FatalAttractionTimer < diff) - { - ExplosionCount = 0; - - TeleportPlayers(); - - switch(rand()%2) - { - case 0: - DoYell(SAY_SPELL2,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature, SOUND_SPELL2); - break; - case 1: - DoYell(SAY_SPELL3,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature, SOUND_SPELL3); - break; - } - FatalAttractionExplodeTimer = 2000; - FatalAttractionTimer = 40000 + rand()%31 * 1000; - }else FatalAttractionTimer -= diff; - - if(FatalAttractionExplodeTimer < diff) - { - // Just make them explode three times... they're supposed to keep exploding while they are in range, but it'll take too much code. I'll try to think of an efficient way for it later. - if(ExplosionCount < 3) - { - for(uint8 i = 0; i < 4; i++) - { - Unit* pUnit = NULL; - if(TargetGUID[i]) - { - pUnit = Unit::GetUnit((*m_creature), TargetGUID[i]); - if(pUnit) - pUnit->CastSpell(pUnit, SPELL_ATTRACTION, true); - TargetGUID[i] = 0; - } - } - - ExplosionCount++; - FatalAttractionExplodeTimer = 1000; - } - else - { - FatalAttractionExplodeTimer = FatalAttractionTimer + 2000; - ExplosionCount = 0; - } - }else FatalAttractionExplodeTimer -= diff; - - if(ShriekTimer < diff) - { - DoCast(m_creature->getVictim(), SPELL_SILENCING_SHRIEK); - ShriekTimer = 30000; - }else ShriekTimer -= diff; - - //Enrage - if(!m_creature->HasAura(SPELL_BERSERK, 0)) - if(EnrageTimer < diff) - { - DoCast(m_creature, SPELL_BERSERK); - DoYell(SAY_ENRAGE,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature, SOUND_ENRAGE); - }else EnrageTimer -= diff; - - //Random taunts - if(RandomYellTimer < diff) - { - switch(rand()%3) - { - case 0: - DoYell(SAY_TAUNT1,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature, SOUND_TAUNT1); - break; - case 1: - DoYell(SAY_TAUNT2,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature, SOUND_TAUNT2); - break; - case 2: - DoYell(SAY_TAUNT3,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature, SOUND_TAUNT3); - break; - } - RandomYellTimer = 60000 + rand()%91 * 1000; - }else RandomYellTimer -= diff; - - DoMeleeAttackIfReady(); - } -}; - -CreatureAI* GetAI_boss_shahraz(Creature *_Creature) -{ - return new boss_shahrazAI (_Creature); -} - -void AddSC_boss_mother_shahraz() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_mother_shahraz"; - newscript->GetAI = GetAI_boss_shahraz; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Mother_Shahraz +SD%Complete: 80 +SDComment: Saber Lash missing, Fatal Attraction slightly incorrect; need to damage only if affected players are within range of each other +SDCategory: Black Temple +EndScriptData */ + +#include "precompiled.h" +#include "def_black_temple.h" + +//Spells +#define SPELL_BEAM_SINISTER 40859 +#define SPELL_BEAM_VILE 40860 +#define SPELL_BEAM_WICKED 40861 +#define SPELL_BEAM_SINFUL 40827 +#define SPELL_ATTRACTION 40871 +#define SPELL_SILENCING_SHRIEK 40823 +#define SPELL_ENRAGE 23537 +#define SPELL_SABER_LASH 43267 +#define SPELL_SABER_LASH_IMM 43690 +#define SPELL_TELEPORT_VISUAL 40869 +#define SPELL_BERSERK 45078 + +uint32 PrismaticAuras[]= +{ + 40880, // Shadow + 40882, // Fire + 40883, // Nature + 40891, // Arcane + 40896, // Frost + 40897, // Holy +}; + +//Speech'n'Sounds +#define SAY_TAUNT1 "You play, you pay." +#define SOUND_TAUNT1 11501 + +#define SAY_TAUNT2 "I'm not impressed." +#define SOUND_TAUNT2 11502 + +#define SAY_TAUNT3 "Enjoying yourselves?" +#define SOUND_TAUNT3 11503 + +#define SAY_AGGRO "So, business... Or pleasure?" +#define SOUND_AGGRO 11504 + +#define SAY_SPELL1 "You seem a little tense." +#define SOUND_SPELL1 11505 + +#define SAY_SPELL2 "Don't be shy." +#define SOUND_SPELL2 11506 + +#define SAY_SPELL3 "I'm all... yours." +#define SOUND_SPELL3 11507 + +#define SAY_SLAY1 "Easy come, easy go." +#define SOUND_SLAY1 11508 + +#define SAY_SLAY2 "So much for a happy ending." +#define SOUND_SLAY2 11509 + +#define SAY_ENRAGE "Stop toying with my emotions!" +#define SOUND_ENRAGE 11510 + +#define SAY_DEATH "I wasn't... finished." +#define SOUND_DEATH 11511 + +struct Locations +{ + float x,y,z; +}; + +static Locations TeleportPoint[]= +{ + {959.996, 212.576, 193.843}, + {932.537, 231.813, 193.838}, + {958.675, 254.767, 193.822}, + {946.955, 201.316, 192.535}, + {944.294, 149.676, 197.551}, + {930.548, 284.888, 193.367}, + {965.997, 278.398, 195.777} +}; + +struct MANGOS_DLL_DECL boss_shahrazAI : public ScriptedAI +{ + boss_shahrazAI(Creature *c) : ScriptedAI(c) + { + pInstance = ((ScriptedInstance*)c->GetInstanceData()); + Reset(); + } + + ScriptedInstance* pInstance; + + uint64 TargetGUID[3]; + uint32 BeamTimer; + uint32 BeamCount; + uint32 CurrentBeam; + uint32 PrismaticShieldTimer; + uint32 FatalAttractionTimer; + uint32 FatalAttractionExplodeTimer; + uint32 ShriekTimer; + uint32 RandomYellTimer; + uint32 EnrageTimer; + uint32 ExplosionCount; + + bool Enraged; + + void Reset() + { + if(pInstance) + pInstance->SetData(DATA_MOTHERSHAHRAZEVENT, NOT_STARTED); + + for(uint8 i = 0; i<3; i++) + TargetGUID[i] = 0; + + BeamTimer = 60000; // Timers may be incorrect + BeamCount = 0; + CurrentBeam = 0; // 0 - Sinister, 1 - Vile, 2 - Wicked, 3 - Sinful + PrismaticShieldTimer = 0; + FatalAttractionTimer = 60000; + FatalAttractionExplodeTimer = 70000; + ShriekTimer = 30000; + RandomYellTimer = 70000 + rand()%41 * 1000; + EnrageTimer = 600000; + ExplosionCount = 0; + + Enraged = false; + } + + void Aggro(Unit *who) + { + if(pInstance) + pInstance->SetData(DATA_MOTHERSHAHRAZEVENT, IN_PROGRESS); + + DoZoneInCombat(); + DoYell(SAY_AGGRO,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature, SOUND_AGGRO); + } + + void KilledUnit(Unit *victim) + { + switch(rand()%2) + { + case 0: + DoYell(SAY_SLAY1,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature, SOUND_SLAY1); + break; + case 1: + DoYell(SAY_SLAY2,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature, SOUND_SLAY2); + break; + } + } + + void JustDied(Unit *victim) + { + if(pInstance) + pInstance->SetData(DATA_MOTHERSHAHRAZEVENT, DONE); + + DoYell(SAY_DEATH, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature,SOUND_DEATH); + } + + void TeleportPlayers() + { + uint32 random = rand()%7; + float X = TeleportPoint[random].x; + float Y = TeleportPoint[random].y; + float Z = TeleportPoint[random].z; + for(uint8 i = 0; i < 3; i++) + { + Unit* pUnit = SelectUnit(SELECT_TARGET_RANDOM, 1); + if(pUnit && pUnit->isAlive() && (pUnit->GetTypeId() == TYPEID_PLAYER)) + { + TargetGUID[i] = pUnit->GetGUID(); + pUnit->CastSpell(pUnit, SPELL_TELEPORT_VISUAL, true); + DoTeleportPlayer(pUnit, X, Y, Z, pUnit->GetOrientation()); + } + } + } + + void UpdateAI(const uint32 diff) + { + if(!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + if(((m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < 10) && !Enraged) + { + Enraged = true; + DoCast(m_creature, SPELL_ENRAGE, true); + DoYell(SAY_ENRAGE, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_ENRAGE); + } + + //Randomly cast one beam. + if(BeamTimer < diff) + { + Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0); + if(!target || !target->isAlive()) + return; + + BeamTimer = 9000; + + switch(CurrentBeam) + { + case 0: + DoCast(target, SPELL_BEAM_SINISTER); + break; + case 1: + DoCast(target, SPELL_BEAM_VILE); + break; + case 2: + DoCast(target, SPELL_BEAM_WICKED); + break; + case 3: + DoCast(target, SPELL_BEAM_SINFUL); + break; + } + BeamCount++; + uint32 Beam = CurrentBeam; + if(BeamCount > 3) + while(CurrentBeam == Beam) + CurrentBeam = rand()%3; + + }else BeamTimer -= diff; + + // Random Prismatic Shield every 15 seconds. + if(PrismaticShieldTimer < diff) + { + uint32 random = rand()%6; + if(PrismaticAuras[random]) + DoCast(m_creature, PrismaticAuras[random]); + PrismaticShieldTimer = 15000; + }else PrismaticShieldTimer -= diff; + + // Select 3 random targets (can select same target more than once), teleport to a random location then make them cast explosions until they get away from each other. + if(FatalAttractionTimer < diff) + { + ExplosionCount = 0; + + TeleportPlayers(); + + switch(rand()%2) + { + case 0: + DoYell(SAY_SPELL2,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature, SOUND_SPELL2); + break; + case 1: + DoYell(SAY_SPELL3,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature, SOUND_SPELL3); + break; + } + FatalAttractionExplodeTimer = 2000; + FatalAttractionTimer = 40000 + rand()%31 * 1000; + }else FatalAttractionTimer -= diff; + + if(FatalAttractionExplodeTimer < diff) + { + // Just make them explode three times... they're supposed to keep exploding while they are in range, but it'll take too much code. I'll try to think of an efficient way for it later. + if(ExplosionCount < 3) + { + for(uint8 i = 0; i < 4; i++) + { + Unit* pUnit = NULL; + if(TargetGUID[i]) + { + pUnit = Unit::GetUnit((*m_creature), TargetGUID[i]); + if(pUnit) + pUnit->CastSpell(pUnit, SPELL_ATTRACTION, true); + TargetGUID[i] = 0; + } + } + + ExplosionCount++; + FatalAttractionExplodeTimer = 1000; + } + else + { + FatalAttractionExplodeTimer = FatalAttractionTimer + 2000; + ExplosionCount = 0; + } + }else FatalAttractionExplodeTimer -= diff; + + if(ShriekTimer < diff) + { + DoCast(m_creature->getVictim(), SPELL_SILENCING_SHRIEK); + ShriekTimer = 30000; + }else ShriekTimer -= diff; + + //Enrage + if(!m_creature->HasAura(SPELL_BERSERK, 0)) + if(EnrageTimer < diff) + { + DoCast(m_creature, SPELL_BERSERK); + DoYell(SAY_ENRAGE,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature, SOUND_ENRAGE); + }else EnrageTimer -= diff; + + //Random taunts + if(RandomYellTimer < diff) + { + switch(rand()%3) + { + case 0: + DoYell(SAY_TAUNT1,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature, SOUND_TAUNT1); + break; + case 1: + DoYell(SAY_TAUNT2,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature, SOUND_TAUNT2); + break; + case 2: + DoYell(SAY_TAUNT3,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature, SOUND_TAUNT3); + break; + } + RandomYellTimer = 60000 + rand()%91 * 1000; + }else RandomYellTimer -= diff; + + DoMeleeAttackIfReady(); + } +}; + +CreatureAI* GetAI_boss_shahraz(Creature *_Creature) +{ + return new boss_shahrazAI (_Creature); +} + +void AddSC_boss_mother_shahraz() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_mother_shahraz"; + newscript->GetAI = GetAI_boss_shahraz; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/black_temple/boss_reliquary_of_souls.cpp b/src/bindings/scripts/scripts/zone/black_temple/boss_reliquary_of_souls.cpp index 19ba2784880..1a1037e5efe 100644 --- a/src/bindings/scripts/scripts/zone/black_temple/boss_reliquary_of_souls.cpp +++ b/src/bindings/scripts/scripts/zone/black_temple/boss_reliquary_of_souls.cpp @@ -1,1051 +1,1051 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Reliquary_of_Souls -SD%Complete: 90 -SDComment: Persistent Area Auras for each Essence (Aura of Suffering, Aura of Desire, Aura of Anger) requires core support. -SDCategory: Black Temple -EndScriptData */ - -#include "precompiled.h" -#include "def_black_temple.h" - -//Sound'n'speech -//Suffering -#define SUFF_SAY_FREED "Pain and suffering are all that await you!" -#define SUFF_SOUND_FREED 11415 -#define SUFF_SAY_AGGRO "Don't leave me alone!" -#define SUFF_SOUND_AGGRO 11416 -#define SUFF_SAY_SLAY1 "Look at what you make me do!" -#define SUFF_SOUND_SLAY1 11417 -#define SUFF_SAY_SLAY2 "I didn't ask for this!" -#define SUFF_SOUND_SLAY2 11418 -#define SUFF_SAY_SLAY3 "The pain is only beginning!" -#define SUFF_SOUND_SLAY3 11419 -#define SUFF_SAY_RECAP "I don't want to go back!" -#define SUFF_SOUND_RECAP 11420 -#define SUFF_SAY_AFTER "Now what do I do?" -#define SUFF_SOUND_AFTER 11421 - -//Desire -#define DESI_SAY_FREED "You can have anything you desire... for a price." -#define DESI_SOUND_FREED 11408 -#define DESI_SAY_SLAY1 "Fulfilment is at hand!" -#define DESI_SOUND_SLAY1 11409 -#define DESI_SAY_SLAY2 "Yes... you'll stay with us now..." -#define DESI_SOUND_SLAY2 11410 -#define DESI_SAY_SLAY3 "Your reach exceeds your grasp." -#define DESI_SOUND_SLAY3 11412 -#define DESI_SAY_SPEC "Be careful what you wish for..." -#define DESI_SOUND_SPEC 11411 -#define DESI_SAY_RECAP "I'll be waiting..." -#define DESI_SOUND_RECAP 11413 -#define DESI_SAY_AFTER "I won't be far..." -#define DESI_SOUND_AFTER 11414 - -//Anger -#define ANGER_SAY_FREED "Beware... I live." -#define ANGER_SOUND_FREED 11399 -#define ANGER_SAY_FREED2 "So... foolish." -#define ANGER_SOUND_FREED2 11400 -#define ANGER_SOUND_SLAY1 11401 -#define ANGER_SAY_SLAY2 "Enough. No more." -#define ANGER_SOUND_SLAY2 11402 -#define ANGER_SAY_SPEC "On your knees!" -#define ANGER_SOUND_SPEC 11403 -#define ANGER_SAY_BEFORE "Beware, coward." -#define ANGER_SOUND_BEFORE 11405 -#define ANGER_SAY_DEATH "I won't... be... ignored." -#define ANGER_SOUND_DEATH 11404 - -//Spells -#define AURA_OF_SUFFERING 41292 -#define AURA_OF_SUFFERING_ARMOR 42017 -#define ESSENCE_OF_SUFFERING_PASSIVE 41296 -#define SPELL_ENRAGE 41305 -#define SPELL_SOUL_DRAIN 41303 -#define SPELL_FIXATE 41295 - -#define AURA_OF_DESIRE 41350 -#define SPELL_RUNE_SHIELD 41431 -#define SPELL_DEADEN 41410 -#define SPELL_SOUL_SHOCK 41426 - -#define AURA_OF_ANGER 41337 -#define SPELL_SELF_SEETHE 41364 -#define SPELL_ENEMY_SEETHE 41520 -#define SPELL_SOUL_SCREAM 41545 -#define SPELL_SPITE 41377 - -#define ENSLAVED_SOUL_PASSIVE 41535 -#define SPELL_SOUL_RELEASE 41542 -#define SPELL_RESTORE_MANA 32848 -#define SPELL_RESTORE_HEALTH 25329 - -#define CREATURE_ENSLAVED_SOUL 23469 - -struct Position -{ - float x,y; -}; - -static Position Coords[]= -{ - {450.4, 212.3}, - {542.1, 212.3}, - {542.1, 168.3}, - {542.1, 137.4}, - {450.4, 137.4}, - {450.4, 168.3} -}; - -struct MANGOS_DLL_DECL npc_enslaved_soulAI : public ScriptedAI -{ - npc_enslaved_soulAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint64 ReliquaryGUID; - - void Reset() - { - ReliquaryGUID = 0; - } - - void Aggro(Unit* who) {} - - void DamageTaken(Unit *done_by, uint32 &damage) - { - if(damage >= m_creature->GetHealth()) - { - if(done_by->GetTypeId() == TYPEID_PLAYER) - { - done_by->CastSpell(done_by, SPELL_RESTORE_HEALTH, true); - if(done_by->GetMaxPower(POWER_MANA) > 0) - { - if((done_by->GetPower(POWER_MANA) / done_by->GetMaxPower(POWER_MANA)) < 70) - { - uint32 mana = done_by->GetPower(POWER_MANA) + (uint32)(done_by->GetMaxPower(POWER_MANA)*0.3); - done_by->SetPower(POWER_MANA, mana); - }else done_by->SetPower(POWER_MANA, done_by->GetMaxPower(POWER_MANA)); - } - } - DoCast(done_by, SPELL_SOUL_RELEASE); - } - } - - void JustDied(Unit *killer); -}; - -struct MANGOS_DLL_DECL boss_reliquary_of_soulsAI : public ScriptedAI -{ - boss_reliquary_of_soulsAI(Creature *c) : ScriptedAI(c) - { - pInstance = ((ScriptedInstance*)c->GetInstanceData()); - Reset(); - } - - ScriptedInstance* pInstance; - - uint64 SufferingGUID; - uint64 DesireGUID; - uint64 AngerGUID; - - uint32 SoulDeathCount; - // 0 = Out of Combat, 1 = Not started, 2 = Suffering, 3 = Souls, 4 = Desire, 5 = Souls, 6 = Anger - uint32 Phase; - uint32 SummonEssenceTimer; - uint32 DespawnEssenceTimer; - uint32 SoulCount; - uint32 SummonSoulTimer; - uint32 AnimationTimer; - - bool IsDead; - bool EndingPhase; - - void Reset() - { - if(pInstance) - pInstance->SetData(DATA_RELIQUARYOFSOULSEVENT, NOT_STARTED); - - DespawnEssences(); - - SufferingGUID = 0; - DesireGUID = 0; - AngerGUID = 0; - - SoulDeathCount = 0; - Phase = 0; - SummonEssenceTimer = 8000; - DespawnEssenceTimer = 2000; - SoulCount = 0; - SummonSoulTimer = 1000; - AnimationTimer = 8000; - - IsDead = false; - EndingPhase = false; - - m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - m_creature->SetUInt32Value(UNIT_NPC_EMOTESTATE,0); - m_creature->GetMotionMaster()->Clear(false); - } - - void Aggro(Unit* who) { } - - void AttackStart(Unit* who) { } - - void MoveInLineOfSight(Unit *who) - { - if (who->isTargetableForAttack() && who->isInAccessablePlaceFor(m_creature) && m_creature->IsHostileTo(who)) - { - float attackRadius = m_creature->GetAttackDistance(who); - if (m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->GetDistanceZ(who) <= CREATURE_Z_ATTACK_RANGE && m_creature->IsWithinLOSInMap(who)) - { - if(who->HasStealthAura()) - who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); - - if(!InCombat) - { - if(pInstance) - pInstance->SetData(DATA_RELIQUARYOFSOULSEVENT, IN_PROGRESS); - - Phase = 1; - // I R ANNNGRRRY! - m_creature->SetUInt32Value(UNIT_NPC_EMOTESTATE,375); - SummonEssenceTimer = 8000; - AnimationTimer = 5100; - m_creature->AddThreat(who, 1.0f); - - InCombat = true; - } - } - } - } - - void SummonSoul() - { - uint32 random = rand()%6; - float x = Coords[random].x; - float y = Coords[random].y; - Creature* Soul = m_creature->SummonCreature(CREATURE_ENSLAVED_SOUL, x, y, m_creature->GetPositionZ(), m_creature->GetOrientation(), TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 45000); - Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0); - if (target && Soul) - { - ((npc_enslaved_soulAI*)Soul->AI())->ReliquaryGUID = m_creature->GetGUID(); - Soul->CastSpell(Soul, ENSLAVED_SOUL_PASSIVE, true); - Soul->AddThreat(target, 1.0f); - SoulCount++; - } - } - - void MergeThreatList(Creature* target) - { - if(!target) return; - - std::list& m_threatlist = target->getThreatManager().getThreatList(); - std::list::iterator itr = m_threatlist.begin(); - for( ; itr != m_threatlist.end(); itr++) - { - Unit* pUnit = Unit::GetUnit((*m_creature), (*itr)->getUnitGuid()); - if(pUnit) - { - m_creature->AddThreat(pUnit, 1.0f); // This is so that we make sure the unit is in Reliquary's threat list before we reset the unit's threat. - m_creature->getThreatManager().modifyThreatPercent(pUnit, -100); - float threat = target->getThreatManager().getThreat(pUnit); - m_creature->AddThreat(pUnit, threat); // This makes it so that the unit has the same amount of threat in Reliquary's threatlist as in the target creature's (One of the Essences). - } - } - } - - void DespawnEssences() - { - // Despawn Essences - Unit* Essence = NULL; - if(SufferingGUID) - Essence = ((Creature*)Unit::GetUnit((*m_creature), SufferingGUID)); - else if(DesireGUID) - Essence = ((Creature*)Unit::GetUnit((*m_creature), DesireGUID)); - else if(AngerGUID) - Essence = ((Creature*)Unit::GetUnit((*m_creature), AngerGUID)); - if(Essence && Essence->isAlive()) - Essence->setDeathState(JUST_DIED); - } - - void JustDied(Unit* killer) - { - if(pInstance) - pInstance->SetData(DATA_RELIQUARYOFSOULSEVENT, DONE); - - InCombat = false; - } - - void UpdateAI(const uint32 diff) - { - if(!Phase) - return; - - // Reset if event is begun and we don't have a threatlist - if(Phase && m_creature->getThreatManager().getThreatList().empty()) - EnterEvadeMode(); - - if(Phase == 1) - { - if(AnimationTimer < diff) - { - // Release the cube - m_creature->SetUInt32Value(UNIT_NPC_EMOTESTATE,374); - AnimationTimer = 8300; - }else AnimationTimer -= diff; - - if(SummonEssenceTimer < diff) - { - // Ribs: open - m_creature->SetUInt32Value(UNIT_NPC_EMOTESTATE,373); - Creature* EssenceSuffering = NULL; - EssenceSuffering = m_creature->SummonCreature(23418, m_creature->GetPositionX(), m_creature->GetPositionY(), m_creature->GetPositionZ(), 1.57, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 10000); - - if(EssenceSuffering) - { - EssenceSuffering->Yell(SUFF_SAY_FREED, LANG_UNIVERSAL, 0); - DoPlaySoundToSet(m_creature, SUFF_SOUND_FREED); - Unit* target = SelectUnit(SELECT_TARGET_TOPAGGRO, 0); - if(target) - { - EssenceSuffering->AddThreat(target, 1.0f); - EssenceSuffering->AI()->AttackStart(target); - } - SufferingGUID = EssenceSuffering->GetGUID(); - } - - EndingPhase = false; - Phase = 2; - }else SummonEssenceTimer -= diff; - } - - if(Phase == 2) - { - if(SufferingGUID) - { - Creature* EssenceSuffering = NULL; - EssenceSuffering = ((Creature*)Unit::GetUnit((*m_creature), SufferingGUID)); - - if(!EssenceSuffering || (!EssenceSuffering->isAlive())) - EnterEvadeMode(); - - if(!EndingPhase) - { - if(EssenceSuffering) - { - if(EssenceSuffering->GetHealth() < (EssenceSuffering->GetMaxHealth()*0.1)) - { - MergeThreatList(EssenceSuffering); - EssenceSuffering->RemoveAllAuras(); - EssenceSuffering->DeleteThreatList(); - EssenceSuffering->GetMotionMaster()->MoveFollow(m_creature,0.0f,0.0f); - EssenceSuffering->Yell(SUFF_SAY_RECAP,LANG_UNIVERSAL,0); - DoPlaySoundToSet(m_creature, SUFF_SOUND_RECAP); - EssenceSuffering->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - DespawnEssenceTimer = 4000; - AnimationTimer = 2200; - EndingPhase = true; - } - } - } - - if((EndingPhase) && (EssenceSuffering) && (EssenceSuffering->isAlive())) - { - if(AnimationTimer < diff) - { - // Return - EssenceSuffering->SetUInt32Value(UNIT_NPC_EMOTESTATE,374); - AnimationTimer = 10000; - }else AnimationTimer -= diff; - - if(DespawnEssenceTimer < diff) - { - EssenceSuffering->DeleteThreatList(); - EssenceSuffering->Yell(SUFF_SAY_AFTER,LANG_UNIVERSAL,0); - DoPlaySoundToSet(m_creature, SUFF_SOUND_AFTER); - EssenceSuffering->SetUInt32Value(UNIT_FIELD_DISPLAYID, 11686); - EssenceSuffering->setFaction(35); - m_creature->SetUInt32Value(UNIT_NPC_EMOTESTATE,0); - SummonEssenceTimer = 20000; //60000; - AnimationTimer = 18200; //58100; - SoulDeathCount = 0; - SoulCount = 0; - SummonSoulTimer = 1000; - EndingPhase = false; - Phase = 3; - SufferingGUID = 0; - }else DespawnEssenceTimer -= diff; - } - } - } - - if(Phase == 3) - { - if(SoulCount < 36) - { - if(SummonSoulTimer < diff) - { - SummonSoul(); - SummonSoulTimer = 500; - }else SummonSoulTimer -= diff; - } - - if(SoulDeathCount >= SoulCount) - { - if(AnimationTimer < diff) - { - // Release the cube - m_creature->SetUInt32Value(UNIT_NPC_EMOTESTATE,374); - AnimationTimer = 10000; - }else AnimationTimer -= diff; - - if(SummonEssenceTimer < diff) - { - // Ribs: open - m_creature->SetUInt32Value(UNIT_NPC_EMOTESTATE,373); - Creature* EssenceDesire = NULL; - EssenceDesire = m_creature->SummonCreature(23419, m_creature->GetPositionX(), m_creature->GetPositionY(), m_creature->GetPositionZ(), 1.57, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 10000); - - if(EssenceDesire) - { - EssenceDesire->Yell(DESI_SAY_FREED, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, DESI_SOUND_FREED); - Unit* target = NULL; - target = SelectUnit(SELECT_TARGET_RANDOM, 0); - if(target) - { - EssenceDesire->AddThreat(target, 1.0f); - EssenceDesire->AI()->AttackStart(target); - } - DesireGUID = EssenceDesire->GetGUID(); - SoulDeathCount = 0; - } - - Phase = 4; - }else SummonEssenceTimer -= diff; - } - } - - if(Phase == 4) - { - if(DesireGUID) - { - Creature* EssenceDesire = NULL; - EssenceDesire = ((Creature*)Unit::GetUnit((*m_creature), DesireGUID)); - - if(!EssenceDesire || !EssenceDesire->isAlive()) - EnterEvadeMode(); - - if(!EndingPhase && EssenceDesire) - { - if(EssenceDesire->GetHealth() < (EssenceDesire->GetMaxHealth()*0.1)) - { - MergeThreatList(EssenceDesire); - EssenceDesire->GetMotionMaster()->MoveFollow(m_creature,0.0f,0.0f); - EssenceDesire->RemoveAllAuras(); - EssenceDesire->DeleteThreatList(); - EssenceDesire->Yell(DESI_SAY_RECAP,LANG_UNIVERSAL,0); - DoPlaySoundToSet(m_creature, DESI_SOUND_RECAP); - EssenceDesire->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - DespawnEssenceTimer = 4000; - AnimationTimer = 2200; - EndingPhase = true; - } - } - - if(EndingPhase && EssenceDesire) - { - if(EssenceDesire->isAlive()) - { - if(AnimationTimer < diff) - { - // Return - EssenceDesire->SetUInt32Value(UNIT_NPC_EMOTESTATE,374); - AnimationTimer = 10000; - }else AnimationTimer -= diff; - - if(DespawnEssenceTimer < diff) - { - EssenceDesire->DeleteThreatList(); - EssenceDesire->setFaction(35); - EssenceDesire->Yell(DESI_SAY_AFTER, LANG_UNIVERSAL, 0); - DoPlaySoundToSet(m_creature, DESI_SOUND_AFTER); - EssenceDesire->SetUInt32Value(UNIT_FIELD_DISPLAYID, 11686); - m_creature->SetUInt32Value(UNIT_NPC_EMOTESTATE,0); - SummonEssenceTimer = 20000; - AnimationTimer = 18200; - SoulDeathCount = 0; - SoulCount = 0; - SummonSoulTimer = 1000; - EndingPhase = false; - Phase = 5; - DesireGUID = 0; - }else DespawnEssenceTimer -= diff; - } - } - } - } - - if(Phase == 5) - { - if(SoulCount < 36) - { - if(SummonSoulTimer < diff) - { - SummonSoul(); - SummonSoulTimer = 500; - }else SummonSoulTimer -= diff; - } - - if(SoulDeathCount >= SoulCount) - { - if(AnimationTimer < diff) - { - // Release the cube - m_creature->SetUInt32Value(UNIT_NPC_EMOTESTATE,374); - AnimationTimer = 10000; - }else AnimationTimer -= diff; - - if(SummonEssenceTimer < diff) - { - // Ribs: open - m_creature->SetUInt32Value(UNIT_NPC_EMOTESTATE,373); - Creature* EssenceAnger = NULL; - EssenceAnger = m_creature->SummonCreature(23420, m_creature->GetPositionX(), m_creature->GetPositionY(), m_creature->GetPositionZ(), 1.57, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 45000); - - if(EssenceAnger) - { - Unit* target = SelectUnit(SELECT_TARGET_TOPAGGRO, 0); - if(target) - { - EssenceAnger->AddThreat(target, 1.0f); - EssenceAnger->AI()->AttackStart(target); - } - AngerGUID = EssenceAnger->GetGUID(); - DoPlaySoundToSet(m_creature, ANGER_SOUND_FREED); - EssenceAnger->Yell(ANGER_SAY_FREED, LANG_UNIVERSAL, 0); - SoulDeathCount = 0; - } - - Phase = 6; - }else SummonEssenceTimer -= diff; - } - } - - if(Phase == 6) - { - if(AngerGUID) - { - Creature* EssenceAnger = NULL; - EssenceAnger = ((Creature*)Unit::GetUnit((*m_creature), AngerGUID)); - - if(!EssenceAnger) - EnterEvadeMode(); - - if(m_creature->isAlive() && EssenceAnger) - { - if(!EssenceAnger->isAlive()) - { - AngerGUID = 0; - m_creature->DealDamage(m_creature, m_creature->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); - } - } - } - } - } -}; - -//This is used to sort the players by distance in preparation for the Fixate cast. -struct TargetDistanceOrder : public std::binary_function -{ - const Unit* MainTarget; - TargetDistanceOrder(const Unit* Target) : MainTarget(Target) {}; - // functor for operator "<" - bool operator()(const Unit* _Left, const Unit* _Right) const - { - return (MainTarget->GetDistance(_Left) < MainTarget->GetDistance(_Right)); - } -}; - -struct MANGOS_DLL_DECL boss_essence_of_sufferingAI : public ScriptedAI -{ - boss_essence_of_sufferingAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint64 StatAuraGUID; - - uint32 AggroYellTimer; - uint32 FixateTimer; - uint32 EnrageTimer; - uint32 SoulDrainTimer; - - void Reset() - { - StatAuraGUID = 0; - - AggroYellTimer = 5000; - FixateTimer = 5000; - EnrageTimer = 30000; - SoulDrainTimer = 150000; - } - - void DamageTaken(Unit *done_by, uint32 &damage) - { - if((damage >= m_creature->GetHealth()) && (done_by != m_creature)) - { - damage = 0; - // 10% of total health, signalling time to return - m_creature->SetHealth(m_creature->GetMaxHealth()/10); - if(StatAuraGUID) - { - Unit* pUnit = Unit::GetUnit((*m_creature), StatAuraGUID); - if(pUnit) - pUnit->RemoveAurasDueToSpell(AURA_OF_SUFFERING_ARMOR); - } - } - } - - void Aggro(Unit *who) - { - DoZoneInCombat(); - DoCast(who, AURA_OF_SUFFERING, true); - DoCast(m_creature, ESSENCE_OF_SUFFERING_PASSIVE, true); - } - - void KilledUnit(Unit *victim) - { - switch(rand()%3) - { - case 0: - DoYell(SUFF_SAY_SLAY1,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature, SUFF_SOUND_SLAY1); - break; - case 1: - DoYell(SUFF_SAY_SLAY2,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature, SUFF_SOUND_SLAY2); - break; - case 2: - DoYell(SUFF_SAY_SLAY3,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature, SUFF_SOUND_SLAY3); - break; - } - } - - void JustDied(Unit* killer) - { - } - - void CastFixate() - { - std::list& m_threatlist = m_creature->getThreatManager().getThreatList(); - if(m_threatlist.empty()) - return; // No point continuing if empty threatlist. - std::list targets; - std::list::iterator itr = m_threatlist.begin(); - for( ; itr != m_threatlist.end(); ++itr) - { - Unit* pUnit = Unit::GetUnit((*m_creature), (*itr)->getUnitGuid()); - // Only alive players - if(pUnit && pUnit->isAlive() && (pUnit->GetTypeId() == TYPEID_PLAYER)) - targets.push_back(pUnit); - } - if(targets.empty()) - return; // No targets added for some reason. No point continuing. - targets.sort(TargetDistanceOrder(m_creature)); // Sort players by distance. - targets.resize(1); // Only need closest target. - Unit* target = targets.front(); // Get the first target. - // Add threat equivalent to threat on victim. - m_creature->AddThreat(target, m_creature->getThreatManager().getThreat(m_creature->getVictim())); - DoCast(target, SPELL_FIXATE); - } - - void UpdateAI(const uint32 diff) - { - //Return since we have no target - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - if(m_creature->GetHealth() <= (m_creature->GetMaxHealth()*0.1)) - { - if(StatAuraGUID) - { - Unit* pUnit = NULL; - pUnit = Unit::GetUnit((*m_creature), StatAuraGUID); - if(pUnit) - pUnit->RemoveAurasDueToSpell(AURA_OF_SUFFERING_ARMOR); - } - } - - if(m_creature->GetHealth() <= (m_creature->GetMaxHealth()*0.1)) - { - if(m_creature->getVictim()) - m_creature->DeleteThreatList(); // Delete our threatlist if below 10% as we should no longer attack. - return; - } - - // Prevent overlapping yells - if(AggroYellTimer) - if(AggroYellTimer < diff) - { - DoYell(SUFF_SAY_AGGRO, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SUFF_SOUND_AGGRO); - AggroYellTimer = 0; - }else AggroYellTimer -= diff; - - //Supposed to be cast on nearest target - if(FixateTimer < diff) - { - CastFixate(); - FixateTimer = 5000; - }else FixateTimer -= diff; - - if(EnrageTimer < diff) - { - DoCast(m_creature, SPELL_ENRAGE); - EnrageTimer = 60000; - }else EnrageTimer -= diff; - - if(SoulDrainTimer < diff) - { - Unit* target = NULL; - target = SelectUnit(SELECT_TARGET_RANDOM, 0); - - if(target) - DoCast(target, SPELL_SOUL_DRAIN); - SoulDrainTimer = 60000; - }else SoulDrainTimer -= diff; - - DoMeleeAttackIfReady(); - } -}; -struct MANGOS_DLL_DECL boss_essence_of_desireAI : public ScriptedAI -{ - boss_essence_of_desireAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 AggroYellTimer; - uint32 RuneShieldTimer; - uint32 DeadenTimer; - uint32 SoulShockTimer; - - void Reset() - { - AggroYellTimer = 5000; - RuneShieldTimer = 60000; - DeadenTimer = 15000; - SoulShockTimer = 40000; - } - - void DamageTaken(Unit *done_by, uint32 &damage) - { - if((damage >= m_creature->GetHealth()) && (done_by != m_creature)) - { - damage = 0; - // 10% of total health, signalling time to return - m_creature->SetHealth(m_creature->GetMaxHealth()/10); - } - else - { - if(done_by && (done_by->GetTypeId() == TYPEID_PLAYER) && done_by->isAlive()) - done_by->DealDamage(done_by, damage/2, NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); - } - } - - void Aggro(Unit *who) { DoZoneInCombat(); } - - void KilledUnit(Unit *victim) - { - switch(rand()%3) - { - case 0: - DoYell(DESI_SAY_SLAY1,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature, DESI_SOUND_SLAY1); - break; - case 1: - DoYell(DESI_SAY_SLAY2,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature, DESI_SOUND_SLAY2); - break; - case 2: - DoYell(DESI_SAY_SLAY3,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature, DESI_SOUND_SLAY3); - break; - } - } - - void MoveInLineOfSight(Unit *who) - { - if (!who || m_creature->getVictim()) - return; - - if (who->isTargetableForAttack() && who->isInAccessablePlaceFor(m_creature) && m_creature->IsHostileTo(who)) - { - float attackRadius = m_creature->GetAttackDistance(who); - if (m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->GetDistanceZ(who) <= CREATURE_Z_ATTACK_RANGE && m_creature->IsWithinLOSInMap(who)) - { - if(who->HasStealthAura()) - who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); - - //Begin melee attack if we are within range - DoStartAttackAndMovement(who); - - if (!InCombat) - { - DoCast(who, AURA_OF_DESIRE); - } - } - } - } - - void UpdateAI(const uint32 diff) - { - //Return since we have no target - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - if(m_creature->GetHealth() <= (m_creature->GetMaxHealth()*0.1)) - { - if(m_creature->getVictim()) - m_creature->DeleteThreatList(); // Delete our threatlist if below 10% as we should no longer attack. - return; - } - - if(RuneShieldTimer < diff) - { - DoCast(m_creature, SPELL_RUNE_SHIELD); - RuneShieldTimer = 60000; - }else RuneShieldTimer -= diff; - - if(DeadenTimer < diff) - { - DoCast(m_creature->getVictim(), SPELL_DEADEN); - DeadenTimer = 30000 + rand()%30001; - }else DeadenTimer -= diff; - - if(SoulShockTimer < diff) - { - DoCast(m_creature->getVictim(), SPELL_SOUL_SHOCK); - SoulShockTimer = 40000; - if(rand()%2 == 0) - { - DoYell(DESI_SAY_SPEC,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature, DESI_SOUND_SPEC); - } - - }else SoulShockTimer -= diff; - - DoMeleeAttackIfReady(); - } -}; - -struct MANGOS_DLL_DECL boss_essence_of_angerAI : public ScriptedAI -{ - boss_essence_of_angerAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint64 AggroTargetGUID; - - uint32 AggroYellTimer; - uint32 CheckTankTimer; - uint32 SoulScreamTimer; - uint32 SpiteTimer; - - bool CheckedAggro; - - void Reset() - { - AggroTargetGUID = 0; - - AggroYellTimer = 5000; - CheckTankTimer = 5000; - SoulScreamTimer = 10000; - SpiteTimer = 30000; - - CheckedAggro = false; - } - - void Aggro(Unit *who) - { - DoZoneInCombat(); - DoCast(m_creature->getVictim(), AURA_OF_ANGER, true); - } - - void MoveInLineOfSight(Unit *who) - { - if (!who || m_creature->getVictim()) - return; - - if (who->isTargetableForAttack() && who->isInAccessablePlaceFor(m_creature) && m_creature->IsHostileTo(who)) - { - float attackRadius = m_creature->GetAttackDistance(who); - if (m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->GetDistanceZ(who) <= CREATURE_Z_ATTACK_RANGE && m_creature->IsWithinLOSInMap(who)) - { - if(who->HasStealthAura()) - who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); - - //Begin melee attack if we are within range - DoStartAttackAndMovement(who); - - if (!InCombat) - { - DoCast(who, AURA_OF_ANGER); - } - } - } - } - - void JustDied(Unit *victim) - { - DoYell(ANGER_SAY_DEATH, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature,ANGER_SOUND_DEATH); - } - - void KilledUnit(Unit *victim) - { - switch(rand()%2) - { - case 0: - DoPlaySoundToSet(m_creature, ANGER_SOUND_SLAY1); - break; - case 1: - DoYell(ANGER_SAY_SLAY2,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature, ANGER_SOUND_SLAY2); - break; - } - } - - void UpdateAI(const uint32 diff) - { - //Return since we have no target - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - if(!CheckedAggro) - { - AggroTargetGUID = m_creature->getVictim()->GetGUID(); - CheckedAggro = true; - } - - if(AggroYellTimer) - if(AggroYellTimer < diff) - { - DoYell(ANGER_SAY_FREED2,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature, ANGER_SOUND_FREED2); - AggroYellTimer = 0; - }else AggroYellTimer -= diff; - - if(CheckTankTimer < diff) - { - if(m_creature->getVictim()->GetGUID() != AggroTargetGUID) - { - DoYell(ANGER_SAY_BEFORE,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature, ANGER_SOUND_BEFORE); - DoCast(m_creature, SPELL_SELF_SEETHE); - DoCast(m_creature->getVictim(), SPELL_ENEMY_SEETHE, true); - AggroTargetGUID = m_creature->getVictim()->GetGUID(); - } - CheckTankTimer = 2000; - }else CheckTankTimer -= diff; - - if(SoulScreamTimer < diff) - { - DoCast(m_creature->getVictim(), SPELL_SOUL_SCREAM); - SoulScreamTimer = 10000; - }else SoulScreamTimer -= diff; - - if(SpiteTimer < diff) - { - for(uint8 i = 0; i < 4; i++) - { - Unit* target = NULL; - target = SelectUnit(SELECT_TARGET_RANDOM, 0); - - if(target) - DoCast(target, SPELL_SPITE); - - } - - SpiteTimer = 30000; - DoYell(ANGER_SAY_SPEC,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature, ANGER_SOUND_SPEC); - }else SpiteTimer -= diff; - - DoMeleeAttackIfReady(); - } -}; - -void npc_enslaved_soulAI::JustDied(Unit *killer) -{ - if(ReliquaryGUID) - { - Creature* Reliquary = ((Creature*)Unit::GetUnit((*m_creature), ReliquaryGUID)); - if(Reliquary) - ((boss_reliquary_of_soulsAI*)Reliquary->AI())->SoulDeathCount++; - } -} - -CreatureAI* GetAI_boss_reliquary_of_souls(Creature *_Creature) -{ - return new boss_reliquary_of_soulsAI (_Creature); -} - -CreatureAI* GetAI_boss_essence_of_suffering(Creature *_Creature) -{ - return new boss_essence_of_sufferingAI (_Creature); -} - -CreatureAI* GetAI_boss_essence_of_desire(Creature *_Creature) -{ - return new boss_essence_of_desireAI (_Creature); -} - -CreatureAI* GetAI_boss_essence_of_anger(Creature *_Creature) -{ - return new boss_essence_of_angerAI (_Creature); -} - -CreatureAI* GetAI_npc_enslaved_soul(Creature *_Creature) -{ - return new npc_enslaved_soulAI (_Creature); -} - -void AddSC_boss_reliquary_of_souls() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_reliquary_of_souls"; - newscript->GetAI = GetAI_boss_reliquary_of_souls; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="boss_essence_of_suffering"; - newscript->GetAI = GetAI_boss_essence_of_suffering; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="boss_essence_of_desire"; - newscript->GetAI = GetAI_boss_essence_of_desire; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="boss_essence_of_anger"; - newscript->GetAI = GetAI_boss_essence_of_anger; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="npc_enslaved_soul"; - newscript->GetAI = GetAI_npc_enslaved_soul; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Reliquary_of_Souls +SD%Complete: 90 +SDComment: Persistent Area Auras for each Essence (Aura of Suffering, Aura of Desire, Aura of Anger) requires core support. +SDCategory: Black Temple +EndScriptData */ + +#include "precompiled.h" +#include "def_black_temple.h" + +//Sound'n'speech +//Suffering +#define SUFF_SAY_FREED "Pain and suffering are all that await you!" +#define SUFF_SOUND_FREED 11415 +#define SUFF_SAY_AGGRO "Don't leave me alone!" +#define SUFF_SOUND_AGGRO 11416 +#define SUFF_SAY_SLAY1 "Look at what you make me do!" +#define SUFF_SOUND_SLAY1 11417 +#define SUFF_SAY_SLAY2 "I didn't ask for this!" +#define SUFF_SOUND_SLAY2 11418 +#define SUFF_SAY_SLAY3 "The pain is only beginning!" +#define SUFF_SOUND_SLAY3 11419 +#define SUFF_SAY_RECAP "I don't want to go back!" +#define SUFF_SOUND_RECAP 11420 +#define SUFF_SAY_AFTER "Now what do I do?" +#define SUFF_SOUND_AFTER 11421 + +//Desire +#define DESI_SAY_FREED "You can have anything you desire... for a price." +#define DESI_SOUND_FREED 11408 +#define DESI_SAY_SLAY1 "Fulfilment is at hand!" +#define DESI_SOUND_SLAY1 11409 +#define DESI_SAY_SLAY2 "Yes... you'll stay with us now..." +#define DESI_SOUND_SLAY2 11410 +#define DESI_SAY_SLAY3 "Your reach exceeds your grasp." +#define DESI_SOUND_SLAY3 11412 +#define DESI_SAY_SPEC "Be careful what you wish for..." +#define DESI_SOUND_SPEC 11411 +#define DESI_SAY_RECAP "I'll be waiting..." +#define DESI_SOUND_RECAP 11413 +#define DESI_SAY_AFTER "I won't be far..." +#define DESI_SOUND_AFTER 11414 + +//Anger +#define ANGER_SAY_FREED "Beware... I live." +#define ANGER_SOUND_FREED 11399 +#define ANGER_SAY_FREED2 "So... foolish." +#define ANGER_SOUND_FREED2 11400 +#define ANGER_SOUND_SLAY1 11401 +#define ANGER_SAY_SLAY2 "Enough. No more." +#define ANGER_SOUND_SLAY2 11402 +#define ANGER_SAY_SPEC "On your knees!" +#define ANGER_SOUND_SPEC 11403 +#define ANGER_SAY_BEFORE "Beware, coward." +#define ANGER_SOUND_BEFORE 11405 +#define ANGER_SAY_DEATH "I won't... be... ignored." +#define ANGER_SOUND_DEATH 11404 + +//Spells +#define AURA_OF_SUFFERING 41292 +#define AURA_OF_SUFFERING_ARMOR 42017 +#define ESSENCE_OF_SUFFERING_PASSIVE 41296 +#define SPELL_ENRAGE 41305 +#define SPELL_SOUL_DRAIN 41303 +#define SPELL_FIXATE 41295 + +#define AURA_OF_DESIRE 41350 +#define SPELL_RUNE_SHIELD 41431 +#define SPELL_DEADEN 41410 +#define SPELL_SOUL_SHOCK 41426 + +#define AURA_OF_ANGER 41337 +#define SPELL_SELF_SEETHE 41364 +#define SPELL_ENEMY_SEETHE 41520 +#define SPELL_SOUL_SCREAM 41545 +#define SPELL_SPITE 41377 + +#define ENSLAVED_SOUL_PASSIVE 41535 +#define SPELL_SOUL_RELEASE 41542 +#define SPELL_RESTORE_MANA 32848 +#define SPELL_RESTORE_HEALTH 25329 + +#define CREATURE_ENSLAVED_SOUL 23469 + +struct Position +{ + float x,y; +}; + +static Position Coords[]= +{ + {450.4, 212.3}, + {542.1, 212.3}, + {542.1, 168.3}, + {542.1, 137.4}, + {450.4, 137.4}, + {450.4, 168.3} +}; + +struct MANGOS_DLL_DECL npc_enslaved_soulAI : public ScriptedAI +{ + npc_enslaved_soulAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint64 ReliquaryGUID; + + void Reset() + { + ReliquaryGUID = 0; + } + + void Aggro(Unit* who) {} + + void DamageTaken(Unit *done_by, uint32 &damage) + { + if(damage >= m_creature->GetHealth()) + { + if(done_by->GetTypeId() == TYPEID_PLAYER) + { + done_by->CastSpell(done_by, SPELL_RESTORE_HEALTH, true); + if(done_by->GetMaxPower(POWER_MANA) > 0) + { + if((done_by->GetPower(POWER_MANA) / done_by->GetMaxPower(POWER_MANA)) < 70) + { + uint32 mana = done_by->GetPower(POWER_MANA) + (uint32)(done_by->GetMaxPower(POWER_MANA)*0.3); + done_by->SetPower(POWER_MANA, mana); + }else done_by->SetPower(POWER_MANA, done_by->GetMaxPower(POWER_MANA)); + } + } + DoCast(done_by, SPELL_SOUL_RELEASE); + } + } + + void JustDied(Unit *killer); +}; + +struct MANGOS_DLL_DECL boss_reliquary_of_soulsAI : public ScriptedAI +{ + boss_reliquary_of_soulsAI(Creature *c) : ScriptedAI(c) + { + pInstance = ((ScriptedInstance*)c->GetInstanceData()); + Reset(); + } + + ScriptedInstance* pInstance; + + uint64 SufferingGUID; + uint64 DesireGUID; + uint64 AngerGUID; + + uint32 SoulDeathCount; + // 0 = Out of Combat, 1 = Not started, 2 = Suffering, 3 = Souls, 4 = Desire, 5 = Souls, 6 = Anger + uint32 Phase; + uint32 SummonEssenceTimer; + uint32 DespawnEssenceTimer; + uint32 SoulCount; + uint32 SummonSoulTimer; + uint32 AnimationTimer; + + bool IsDead; + bool EndingPhase; + + void Reset() + { + if(pInstance) + pInstance->SetData(DATA_RELIQUARYOFSOULSEVENT, NOT_STARTED); + + DespawnEssences(); + + SufferingGUID = 0; + DesireGUID = 0; + AngerGUID = 0; + + SoulDeathCount = 0; + Phase = 0; + SummonEssenceTimer = 8000; + DespawnEssenceTimer = 2000; + SoulCount = 0; + SummonSoulTimer = 1000; + AnimationTimer = 8000; + + IsDead = false; + EndingPhase = false; + + m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + m_creature->SetUInt32Value(UNIT_NPC_EMOTESTATE,0); + m_creature->GetMotionMaster()->Clear(false); + } + + void Aggro(Unit* who) { } + + void AttackStart(Unit* who) { } + + void MoveInLineOfSight(Unit *who) + { + if (who->isTargetableForAttack() && who->isInAccessablePlaceFor(m_creature) && m_creature->IsHostileTo(who)) + { + float attackRadius = m_creature->GetAttackDistance(who); + if (m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->GetDistanceZ(who) <= CREATURE_Z_ATTACK_RANGE && m_creature->IsWithinLOSInMap(who)) + { + if(who->HasStealthAura()) + who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); + + if(!InCombat) + { + if(pInstance) + pInstance->SetData(DATA_RELIQUARYOFSOULSEVENT, IN_PROGRESS); + + Phase = 1; + // I R ANNNGRRRY! + m_creature->SetUInt32Value(UNIT_NPC_EMOTESTATE,375); + SummonEssenceTimer = 8000; + AnimationTimer = 5100; + m_creature->AddThreat(who, 1.0f); + + InCombat = true; + } + } + } + } + + void SummonSoul() + { + uint32 random = rand()%6; + float x = Coords[random].x; + float y = Coords[random].y; + Creature* Soul = m_creature->SummonCreature(CREATURE_ENSLAVED_SOUL, x, y, m_creature->GetPositionZ(), m_creature->GetOrientation(), TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 45000); + Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0); + if (target && Soul) + { + ((npc_enslaved_soulAI*)Soul->AI())->ReliquaryGUID = m_creature->GetGUID(); + Soul->CastSpell(Soul, ENSLAVED_SOUL_PASSIVE, true); + Soul->AddThreat(target, 1.0f); + SoulCount++; + } + } + + void MergeThreatList(Creature* target) + { + if(!target) return; + + std::list& m_threatlist = target->getThreatManager().getThreatList(); + std::list::iterator itr = m_threatlist.begin(); + for( ; itr != m_threatlist.end(); itr++) + { + Unit* pUnit = Unit::GetUnit((*m_creature), (*itr)->getUnitGuid()); + if(pUnit) + { + m_creature->AddThreat(pUnit, 1.0f); // This is so that we make sure the unit is in Reliquary's threat list before we reset the unit's threat. + m_creature->getThreatManager().modifyThreatPercent(pUnit, -100); + float threat = target->getThreatManager().getThreat(pUnit); + m_creature->AddThreat(pUnit, threat); // This makes it so that the unit has the same amount of threat in Reliquary's threatlist as in the target creature's (One of the Essences). + } + } + } + + void DespawnEssences() + { + // Despawn Essences + Unit* Essence = NULL; + if(SufferingGUID) + Essence = ((Creature*)Unit::GetUnit((*m_creature), SufferingGUID)); + else if(DesireGUID) + Essence = ((Creature*)Unit::GetUnit((*m_creature), DesireGUID)); + else if(AngerGUID) + Essence = ((Creature*)Unit::GetUnit((*m_creature), AngerGUID)); + if(Essence && Essence->isAlive()) + Essence->setDeathState(JUST_DIED); + } + + void JustDied(Unit* killer) + { + if(pInstance) + pInstance->SetData(DATA_RELIQUARYOFSOULSEVENT, DONE); + + InCombat = false; + } + + void UpdateAI(const uint32 diff) + { + if(!Phase) + return; + + // Reset if event is begun and we don't have a threatlist + if(Phase && m_creature->getThreatManager().getThreatList().empty()) + EnterEvadeMode(); + + if(Phase == 1) + { + if(AnimationTimer < diff) + { + // Release the cube + m_creature->SetUInt32Value(UNIT_NPC_EMOTESTATE,374); + AnimationTimer = 8300; + }else AnimationTimer -= diff; + + if(SummonEssenceTimer < diff) + { + // Ribs: open + m_creature->SetUInt32Value(UNIT_NPC_EMOTESTATE,373); + Creature* EssenceSuffering = NULL; + EssenceSuffering = m_creature->SummonCreature(23418, m_creature->GetPositionX(), m_creature->GetPositionY(), m_creature->GetPositionZ(), 1.57, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 10000); + + if(EssenceSuffering) + { + EssenceSuffering->Yell(SUFF_SAY_FREED, LANG_UNIVERSAL, 0); + DoPlaySoundToSet(m_creature, SUFF_SOUND_FREED); + Unit* target = SelectUnit(SELECT_TARGET_TOPAGGRO, 0); + if(target) + { + EssenceSuffering->AddThreat(target, 1.0f); + EssenceSuffering->AI()->AttackStart(target); + } + SufferingGUID = EssenceSuffering->GetGUID(); + } + + EndingPhase = false; + Phase = 2; + }else SummonEssenceTimer -= diff; + } + + if(Phase == 2) + { + if(SufferingGUID) + { + Creature* EssenceSuffering = NULL; + EssenceSuffering = ((Creature*)Unit::GetUnit((*m_creature), SufferingGUID)); + + if(!EssenceSuffering || (!EssenceSuffering->isAlive())) + EnterEvadeMode(); + + if(!EndingPhase) + { + if(EssenceSuffering) + { + if(EssenceSuffering->GetHealth() < (EssenceSuffering->GetMaxHealth()*0.1)) + { + MergeThreatList(EssenceSuffering); + EssenceSuffering->RemoveAllAuras(); + EssenceSuffering->DeleteThreatList(); + EssenceSuffering->GetMotionMaster()->MoveFollow(m_creature,0.0f,0.0f); + EssenceSuffering->Yell(SUFF_SAY_RECAP,LANG_UNIVERSAL,0); + DoPlaySoundToSet(m_creature, SUFF_SOUND_RECAP); + EssenceSuffering->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + DespawnEssenceTimer = 4000; + AnimationTimer = 2200; + EndingPhase = true; + } + } + } + + if((EndingPhase) && (EssenceSuffering) && (EssenceSuffering->isAlive())) + { + if(AnimationTimer < diff) + { + // Return + EssenceSuffering->SetUInt32Value(UNIT_NPC_EMOTESTATE,374); + AnimationTimer = 10000; + }else AnimationTimer -= diff; + + if(DespawnEssenceTimer < diff) + { + EssenceSuffering->DeleteThreatList(); + EssenceSuffering->Yell(SUFF_SAY_AFTER,LANG_UNIVERSAL,0); + DoPlaySoundToSet(m_creature, SUFF_SOUND_AFTER); + EssenceSuffering->SetUInt32Value(UNIT_FIELD_DISPLAYID, 11686); + EssenceSuffering->setFaction(35); + m_creature->SetUInt32Value(UNIT_NPC_EMOTESTATE,0); + SummonEssenceTimer = 20000; //60000; + AnimationTimer = 18200; //58100; + SoulDeathCount = 0; + SoulCount = 0; + SummonSoulTimer = 1000; + EndingPhase = false; + Phase = 3; + SufferingGUID = 0; + }else DespawnEssenceTimer -= diff; + } + } + } + + if(Phase == 3) + { + if(SoulCount < 36) + { + if(SummonSoulTimer < diff) + { + SummonSoul(); + SummonSoulTimer = 500; + }else SummonSoulTimer -= diff; + } + + if(SoulDeathCount >= SoulCount) + { + if(AnimationTimer < diff) + { + // Release the cube + m_creature->SetUInt32Value(UNIT_NPC_EMOTESTATE,374); + AnimationTimer = 10000; + }else AnimationTimer -= diff; + + if(SummonEssenceTimer < diff) + { + // Ribs: open + m_creature->SetUInt32Value(UNIT_NPC_EMOTESTATE,373); + Creature* EssenceDesire = NULL; + EssenceDesire = m_creature->SummonCreature(23419, m_creature->GetPositionX(), m_creature->GetPositionY(), m_creature->GetPositionZ(), 1.57, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 10000); + + if(EssenceDesire) + { + EssenceDesire->Yell(DESI_SAY_FREED, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, DESI_SOUND_FREED); + Unit* target = NULL; + target = SelectUnit(SELECT_TARGET_RANDOM, 0); + if(target) + { + EssenceDesire->AddThreat(target, 1.0f); + EssenceDesire->AI()->AttackStart(target); + } + DesireGUID = EssenceDesire->GetGUID(); + SoulDeathCount = 0; + } + + Phase = 4; + }else SummonEssenceTimer -= diff; + } + } + + if(Phase == 4) + { + if(DesireGUID) + { + Creature* EssenceDesire = NULL; + EssenceDesire = ((Creature*)Unit::GetUnit((*m_creature), DesireGUID)); + + if(!EssenceDesire || !EssenceDesire->isAlive()) + EnterEvadeMode(); + + if(!EndingPhase && EssenceDesire) + { + if(EssenceDesire->GetHealth() < (EssenceDesire->GetMaxHealth()*0.1)) + { + MergeThreatList(EssenceDesire); + EssenceDesire->GetMotionMaster()->MoveFollow(m_creature,0.0f,0.0f); + EssenceDesire->RemoveAllAuras(); + EssenceDesire->DeleteThreatList(); + EssenceDesire->Yell(DESI_SAY_RECAP,LANG_UNIVERSAL,0); + DoPlaySoundToSet(m_creature, DESI_SOUND_RECAP); + EssenceDesire->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + DespawnEssenceTimer = 4000; + AnimationTimer = 2200; + EndingPhase = true; + } + } + + if(EndingPhase && EssenceDesire) + { + if(EssenceDesire->isAlive()) + { + if(AnimationTimer < diff) + { + // Return + EssenceDesire->SetUInt32Value(UNIT_NPC_EMOTESTATE,374); + AnimationTimer = 10000; + }else AnimationTimer -= diff; + + if(DespawnEssenceTimer < diff) + { + EssenceDesire->DeleteThreatList(); + EssenceDesire->setFaction(35); + EssenceDesire->Yell(DESI_SAY_AFTER, LANG_UNIVERSAL, 0); + DoPlaySoundToSet(m_creature, DESI_SOUND_AFTER); + EssenceDesire->SetUInt32Value(UNIT_FIELD_DISPLAYID, 11686); + m_creature->SetUInt32Value(UNIT_NPC_EMOTESTATE,0); + SummonEssenceTimer = 20000; + AnimationTimer = 18200; + SoulDeathCount = 0; + SoulCount = 0; + SummonSoulTimer = 1000; + EndingPhase = false; + Phase = 5; + DesireGUID = 0; + }else DespawnEssenceTimer -= diff; + } + } + } + } + + if(Phase == 5) + { + if(SoulCount < 36) + { + if(SummonSoulTimer < diff) + { + SummonSoul(); + SummonSoulTimer = 500; + }else SummonSoulTimer -= diff; + } + + if(SoulDeathCount >= SoulCount) + { + if(AnimationTimer < diff) + { + // Release the cube + m_creature->SetUInt32Value(UNIT_NPC_EMOTESTATE,374); + AnimationTimer = 10000; + }else AnimationTimer -= diff; + + if(SummonEssenceTimer < diff) + { + // Ribs: open + m_creature->SetUInt32Value(UNIT_NPC_EMOTESTATE,373); + Creature* EssenceAnger = NULL; + EssenceAnger = m_creature->SummonCreature(23420, m_creature->GetPositionX(), m_creature->GetPositionY(), m_creature->GetPositionZ(), 1.57, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 45000); + + if(EssenceAnger) + { + Unit* target = SelectUnit(SELECT_TARGET_TOPAGGRO, 0); + if(target) + { + EssenceAnger->AddThreat(target, 1.0f); + EssenceAnger->AI()->AttackStart(target); + } + AngerGUID = EssenceAnger->GetGUID(); + DoPlaySoundToSet(m_creature, ANGER_SOUND_FREED); + EssenceAnger->Yell(ANGER_SAY_FREED, LANG_UNIVERSAL, 0); + SoulDeathCount = 0; + } + + Phase = 6; + }else SummonEssenceTimer -= diff; + } + } + + if(Phase == 6) + { + if(AngerGUID) + { + Creature* EssenceAnger = NULL; + EssenceAnger = ((Creature*)Unit::GetUnit((*m_creature), AngerGUID)); + + if(!EssenceAnger) + EnterEvadeMode(); + + if(m_creature->isAlive() && EssenceAnger) + { + if(!EssenceAnger->isAlive()) + { + AngerGUID = 0; + m_creature->DealDamage(m_creature, m_creature->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); + } + } + } + } + } +}; + +//This is used to sort the players by distance in preparation for the Fixate cast. +struct TargetDistanceOrder : public std::binary_function +{ + const Unit* MainTarget; + TargetDistanceOrder(const Unit* Target) : MainTarget(Target) {}; + // functor for operator "<" + bool operator()(const Unit* _Left, const Unit* _Right) const + { + return (MainTarget->GetDistance(_Left) < MainTarget->GetDistance(_Right)); + } +}; + +struct MANGOS_DLL_DECL boss_essence_of_sufferingAI : public ScriptedAI +{ + boss_essence_of_sufferingAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint64 StatAuraGUID; + + uint32 AggroYellTimer; + uint32 FixateTimer; + uint32 EnrageTimer; + uint32 SoulDrainTimer; + + void Reset() + { + StatAuraGUID = 0; + + AggroYellTimer = 5000; + FixateTimer = 5000; + EnrageTimer = 30000; + SoulDrainTimer = 150000; + } + + void DamageTaken(Unit *done_by, uint32 &damage) + { + if((damage >= m_creature->GetHealth()) && (done_by != m_creature)) + { + damage = 0; + // 10% of total health, signalling time to return + m_creature->SetHealth(m_creature->GetMaxHealth()/10); + if(StatAuraGUID) + { + Unit* pUnit = Unit::GetUnit((*m_creature), StatAuraGUID); + if(pUnit) + pUnit->RemoveAurasDueToSpell(AURA_OF_SUFFERING_ARMOR); + } + } + } + + void Aggro(Unit *who) + { + DoZoneInCombat(); + DoCast(who, AURA_OF_SUFFERING, true); + DoCast(m_creature, ESSENCE_OF_SUFFERING_PASSIVE, true); + } + + void KilledUnit(Unit *victim) + { + switch(rand()%3) + { + case 0: + DoYell(SUFF_SAY_SLAY1,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature, SUFF_SOUND_SLAY1); + break; + case 1: + DoYell(SUFF_SAY_SLAY2,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature, SUFF_SOUND_SLAY2); + break; + case 2: + DoYell(SUFF_SAY_SLAY3,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature, SUFF_SOUND_SLAY3); + break; + } + } + + void JustDied(Unit* killer) + { + } + + void CastFixate() + { + std::list& m_threatlist = m_creature->getThreatManager().getThreatList(); + if(m_threatlist.empty()) + return; // No point continuing if empty threatlist. + std::list targets; + std::list::iterator itr = m_threatlist.begin(); + for( ; itr != m_threatlist.end(); ++itr) + { + Unit* pUnit = Unit::GetUnit((*m_creature), (*itr)->getUnitGuid()); + // Only alive players + if(pUnit && pUnit->isAlive() && (pUnit->GetTypeId() == TYPEID_PLAYER)) + targets.push_back(pUnit); + } + if(targets.empty()) + return; // No targets added for some reason. No point continuing. + targets.sort(TargetDistanceOrder(m_creature)); // Sort players by distance. + targets.resize(1); // Only need closest target. + Unit* target = targets.front(); // Get the first target. + // Add threat equivalent to threat on victim. + m_creature->AddThreat(target, m_creature->getThreatManager().getThreat(m_creature->getVictim())); + DoCast(target, SPELL_FIXATE); + } + + void UpdateAI(const uint32 diff) + { + //Return since we have no target + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + if(m_creature->GetHealth() <= (m_creature->GetMaxHealth()*0.1)) + { + if(StatAuraGUID) + { + Unit* pUnit = NULL; + pUnit = Unit::GetUnit((*m_creature), StatAuraGUID); + if(pUnit) + pUnit->RemoveAurasDueToSpell(AURA_OF_SUFFERING_ARMOR); + } + } + + if(m_creature->GetHealth() <= (m_creature->GetMaxHealth()*0.1)) + { + if(m_creature->getVictim()) + m_creature->DeleteThreatList(); // Delete our threatlist if below 10% as we should no longer attack. + return; + } + + // Prevent overlapping yells + if(AggroYellTimer) + if(AggroYellTimer < diff) + { + DoYell(SUFF_SAY_AGGRO, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SUFF_SOUND_AGGRO); + AggroYellTimer = 0; + }else AggroYellTimer -= diff; + + //Supposed to be cast on nearest target + if(FixateTimer < diff) + { + CastFixate(); + FixateTimer = 5000; + }else FixateTimer -= diff; + + if(EnrageTimer < diff) + { + DoCast(m_creature, SPELL_ENRAGE); + EnrageTimer = 60000; + }else EnrageTimer -= diff; + + if(SoulDrainTimer < diff) + { + Unit* target = NULL; + target = SelectUnit(SELECT_TARGET_RANDOM, 0); + + if(target) + DoCast(target, SPELL_SOUL_DRAIN); + SoulDrainTimer = 60000; + }else SoulDrainTimer -= diff; + + DoMeleeAttackIfReady(); + } +}; +struct MANGOS_DLL_DECL boss_essence_of_desireAI : public ScriptedAI +{ + boss_essence_of_desireAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 AggroYellTimer; + uint32 RuneShieldTimer; + uint32 DeadenTimer; + uint32 SoulShockTimer; + + void Reset() + { + AggroYellTimer = 5000; + RuneShieldTimer = 60000; + DeadenTimer = 15000; + SoulShockTimer = 40000; + } + + void DamageTaken(Unit *done_by, uint32 &damage) + { + if((damage >= m_creature->GetHealth()) && (done_by != m_creature)) + { + damage = 0; + // 10% of total health, signalling time to return + m_creature->SetHealth(m_creature->GetMaxHealth()/10); + } + else + { + if(done_by && (done_by->GetTypeId() == TYPEID_PLAYER) && done_by->isAlive()) + done_by->DealDamage(done_by, damage/2, NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); + } + } + + void Aggro(Unit *who) { DoZoneInCombat(); } + + void KilledUnit(Unit *victim) + { + switch(rand()%3) + { + case 0: + DoYell(DESI_SAY_SLAY1,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature, DESI_SOUND_SLAY1); + break; + case 1: + DoYell(DESI_SAY_SLAY2,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature, DESI_SOUND_SLAY2); + break; + case 2: + DoYell(DESI_SAY_SLAY3,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature, DESI_SOUND_SLAY3); + break; + } + } + + void MoveInLineOfSight(Unit *who) + { + if (!who || m_creature->getVictim()) + return; + + if (who->isTargetableForAttack() && who->isInAccessablePlaceFor(m_creature) && m_creature->IsHostileTo(who)) + { + float attackRadius = m_creature->GetAttackDistance(who); + if (m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->GetDistanceZ(who) <= CREATURE_Z_ATTACK_RANGE && m_creature->IsWithinLOSInMap(who)) + { + if(who->HasStealthAura()) + who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); + + //Begin melee attack if we are within range + DoStartAttackAndMovement(who); + + if (!InCombat) + { + DoCast(who, AURA_OF_DESIRE); + } + } + } + } + + void UpdateAI(const uint32 diff) + { + //Return since we have no target + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + if(m_creature->GetHealth() <= (m_creature->GetMaxHealth()*0.1)) + { + if(m_creature->getVictim()) + m_creature->DeleteThreatList(); // Delete our threatlist if below 10% as we should no longer attack. + return; + } + + if(RuneShieldTimer < diff) + { + DoCast(m_creature, SPELL_RUNE_SHIELD); + RuneShieldTimer = 60000; + }else RuneShieldTimer -= diff; + + if(DeadenTimer < diff) + { + DoCast(m_creature->getVictim(), SPELL_DEADEN); + DeadenTimer = 30000 + rand()%30001; + }else DeadenTimer -= diff; + + if(SoulShockTimer < diff) + { + DoCast(m_creature->getVictim(), SPELL_SOUL_SHOCK); + SoulShockTimer = 40000; + if(rand()%2 == 0) + { + DoYell(DESI_SAY_SPEC,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature, DESI_SOUND_SPEC); + } + + }else SoulShockTimer -= diff; + + DoMeleeAttackIfReady(); + } +}; + +struct MANGOS_DLL_DECL boss_essence_of_angerAI : public ScriptedAI +{ + boss_essence_of_angerAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint64 AggroTargetGUID; + + uint32 AggroYellTimer; + uint32 CheckTankTimer; + uint32 SoulScreamTimer; + uint32 SpiteTimer; + + bool CheckedAggro; + + void Reset() + { + AggroTargetGUID = 0; + + AggroYellTimer = 5000; + CheckTankTimer = 5000; + SoulScreamTimer = 10000; + SpiteTimer = 30000; + + CheckedAggro = false; + } + + void Aggro(Unit *who) + { + DoZoneInCombat(); + DoCast(m_creature->getVictim(), AURA_OF_ANGER, true); + } + + void MoveInLineOfSight(Unit *who) + { + if (!who || m_creature->getVictim()) + return; + + if (who->isTargetableForAttack() && who->isInAccessablePlaceFor(m_creature) && m_creature->IsHostileTo(who)) + { + float attackRadius = m_creature->GetAttackDistance(who); + if (m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->GetDistanceZ(who) <= CREATURE_Z_ATTACK_RANGE && m_creature->IsWithinLOSInMap(who)) + { + if(who->HasStealthAura()) + who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); + + //Begin melee attack if we are within range + DoStartAttackAndMovement(who); + + if (!InCombat) + { + DoCast(who, AURA_OF_ANGER); + } + } + } + } + + void JustDied(Unit *victim) + { + DoYell(ANGER_SAY_DEATH, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature,ANGER_SOUND_DEATH); + } + + void KilledUnit(Unit *victim) + { + switch(rand()%2) + { + case 0: + DoPlaySoundToSet(m_creature, ANGER_SOUND_SLAY1); + break; + case 1: + DoYell(ANGER_SAY_SLAY2,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature, ANGER_SOUND_SLAY2); + break; + } + } + + void UpdateAI(const uint32 diff) + { + //Return since we have no target + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + if(!CheckedAggro) + { + AggroTargetGUID = m_creature->getVictim()->GetGUID(); + CheckedAggro = true; + } + + if(AggroYellTimer) + if(AggroYellTimer < diff) + { + DoYell(ANGER_SAY_FREED2,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature, ANGER_SOUND_FREED2); + AggroYellTimer = 0; + }else AggroYellTimer -= diff; + + if(CheckTankTimer < diff) + { + if(m_creature->getVictim()->GetGUID() != AggroTargetGUID) + { + DoYell(ANGER_SAY_BEFORE,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature, ANGER_SOUND_BEFORE); + DoCast(m_creature, SPELL_SELF_SEETHE); + DoCast(m_creature->getVictim(), SPELL_ENEMY_SEETHE, true); + AggroTargetGUID = m_creature->getVictim()->GetGUID(); + } + CheckTankTimer = 2000; + }else CheckTankTimer -= diff; + + if(SoulScreamTimer < diff) + { + DoCast(m_creature->getVictim(), SPELL_SOUL_SCREAM); + SoulScreamTimer = 10000; + }else SoulScreamTimer -= diff; + + if(SpiteTimer < diff) + { + for(uint8 i = 0; i < 4; i++) + { + Unit* target = NULL; + target = SelectUnit(SELECT_TARGET_RANDOM, 0); + + if(target) + DoCast(target, SPELL_SPITE); + + } + + SpiteTimer = 30000; + DoYell(ANGER_SAY_SPEC,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature, ANGER_SOUND_SPEC); + }else SpiteTimer -= diff; + + DoMeleeAttackIfReady(); + } +}; + +void npc_enslaved_soulAI::JustDied(Unit *killer) +{ + if(ReliquaryGUID) + { + Creature* Reliquary = ((Creature*)Unit::GetUnit((*m_creature), ReliquaryGUID)); + if(Reliquary) + ((boss_reliquary_of_soulsAI*)Reliquary->AI())->SoulDeathCount++; + } +} + +CreatureAI* GetAI_boss_reliquary_of_souls(Creature *_Creature) +{ + return new boss_reliquary_of_soulsAI (_Creature); +} + +CreatureAI* GetAI_boss_essence_of_suffering(Creature *_Creature) +{ + return new boss_essence_of_sufferingAI (_Creature); +} + +CreatureAI* GetAI_boss_essence_of_desire(Creature *_Creature) +{ + return new boss_essence_of_desireAI (_Creature); +} + +CreatureAI* GetAI_boss_essence_of_anger(Creature *_Creature) +{ + return new boss_essence_of_angerAI (_Creature); +} + +CreatureAI* GetAI_npc_enslaved_soul(Creature *_Creature) +{ + return new npc_enslaved_soulAI (_Creature); +} + +void AddSC_boss_reliquary_of_souls() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_reliquary_of_souls"; + newscript->GetAI = GetAI_boss_reliquary_of_souls; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="boss_essence_of_suffering"; + newscript->GetAI = GetAI_boss_essence_of_suffering; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="boss_essence_of_desire"; + newscript->GetAI = GetAI_boss_essence_of_desire; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="boss_essence_of_anger"; + newscript->GetAI = GetAI_boss_essence_of_anger; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="npc_enslaved_soul"; + newscript->GetAI = GetAI_npc_enslaved_soul; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/black_temple/boss_shade_of_akama.cpp b/src/bindings/scripts/scripts/zone/black_temple/boss_shade_of_akama.cpp index 2f1034e2c08..803c7f7863d 100644 --- a/src/bindings/scripts/scripts/zone/black_temple/boss_shade_of_akama.cpp +++ b/src/bindings/scripts/scripts/zone/black_temple/boss_shade_of_akama.cpp @@ -1,813 +1,813 @@ -/* Copyright (C) 2006,2007 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Shade_of_Akama -SD%Complete: 99 -SDComment: Seems to be complete. -SDCategory: Black Temple -EndScriptData */ - -#include "precompiled.h" -#include "def_black_temple.h" -#include "sc_grid_searchers.h" - -struct Location -{ - float x, y, o, z; -}; - -static Location ChannelerLocations[]= -{ - {463.161285, 401.219757, 3.141592}, - {457.377625, 391.227661, 2.106461}, - {446.012421, 391.227661, 1.071904}, - {439.533783, 401.219757, 0.000000}, - {446.012421, 411.211853, 5.210546}, - {457.377625, 411.211853, 4.177494} -}; - -static Location SpawnLocations[]= -{ - {498.652740, 461.728119, 0}, - {498.505003, 339.619324, 0} -}; - -static Location AkamaWP[]= -{ - {482.352448, 401.162720, 0, 112.783928}, - {469.597443, 402.264404, 0, 118.537910} -}; - -static Location BrokenCoords[]= -{ - {541.375916, 401.439575, M_PI, 112.783997}, // The place where Akama channels - {534.130005, 352.394531, 2.164150, 112.783737}, // Behind a 'pillar' which is behind the east alcove - {499.621185, 341.534729, 1.652856, 112.783730}, // East Alcove - {499.151093, 461.036438, 4.770888, 112.78370}, // West Alcove -}; - -static Location BrokenWP[]= -{ - {492.491638, 400.744690, 3.122336, 112.783737}, - {494.335724, 382.221771, 2.676230, 112.783737}, - {489.555939, 373.507202, 2.416263, 112.783737}, - {491.136353, 427.868774, 3.519748, 112.783737}, -}; - -// Locations -#define Z1 118.543144 -#define Z2 120.783768 -#define Z_SPAWN 113.537949 -#define AGGRO_X 482.793182 -#define AGGRO_Y 401.270172 -#define AGGRO_Z 112.783928 -#define AKAMA_X 514.583984 -#define AKAMA_Y 400.601013 -#define AKAMA_Z 112.783997 - -// Texts -#define SOUND_DEATH 11386 -#define SAY_DEATH "No! Not yet..." -#define SOUND_LOW_HEALTH 11385 -#define SAY_LOW_HEALTH "I will not last much longer..." - -// Ending cinematic text -#define SAY_FREE "Come out from the shadows! I've returned to lead you against our true enemy! Shed your chains and raise your weapons against your Illidari masters!" -#define SAY_BROKEN_FREE_01 "Hail our leader! Hail Akama!" -#define SAY_BROKEN_FREE_02 "Hail Akama!" - -// Gossips -#define GOSSIP_ITEM "We are ready to fight alongside you, Akama" - -// Spells -#define SPELL_VERTEX_SHADE_BLACK 39833 -#define SPELL_SHADE_SOUL_CHANNEL 40401 -#define SPELL_DESTRUCTIVE_POISON 40874 -#define SPELL_LIGHTNING_BOLT 42024 -#define SPELL_AKAMA_SOUL_CHANNEL 40447 -#define SPELL_AKAMA_SOUL_RETRIEVE 40902 -#define AKAMA_SOUL_EXPEL 40855 -#define SPELL_SHADE_SOUL_CHANNEL_2 40520 - -// Channeler entry -#define CREATURE_CHANNELER 23421 -#define CREATURE_SORCERER 23215 -#define CREATURE_DEFENDER 23216 -#define CREATURE_BROKEN 23319 - -const uint32 spawnEntries[4]= { 23523, 23318, 23524 }; - -struct MANGOS_DLL_DECL mob_ashtongue_channelerAI : public ScriptedAI -{ - mob_ashtongue_channelerAI(Creature* c) : ScriptedAI(c) { Reset(); } - - uint64 ShadeGUID; - - void Reset() { ShadeGUID = 0; } - void JustDied(Unit* killer); - void Aggro(Unit* who) {} - void AttackStart(Unit* who) {} - void MoveInLineOfSight(Unit* who) {} - void UpdateAI(const uint32 diff) {} -}; - -struct MANGOS_DLL_DECL mob_ashtongue_sorcererAI : public ScriptedAI -{ - mob_ashtongue_sorcererAI(Creature* c) : ScriptedAI(c) { Reset(); } - - uint64 ShadeGUID; - uint32 CheckTimer; - bool StartBanishing; - - void Reset() - { - StartBanishing = false; - CheckTimer = 5000; - ShadeGUID = 0; - } - - void JustDied(Unit* killer); - void Aggro(Unit* who) {} - void AttackStart(Unit* who) {} - void MoveInLineOfSight(Unit* who) {} - void UpdateAI(const uint32 diff) - { - if(StartBanishing) - return; - - if(CheckTimer < diff) - { - Unit* Shade = Unit::GetUnit((*m_creature), ShadeGUID); - if(Shade && Shade->isAlive() && m_creature->isAlive()) - { - if(m_creature->GetDistance2d(Shade) < 20) - { - m_creature->GetMotionMaster()->Clear(false); - m_creature->GetMotionMaster()->MoveIdle(); - DoCast(Shade, SPELL_SHADE_SOUL_CHANNEL, true); - DoCast(Shade, SPELL_SHADE_SOUL_CHANNEL_2, true); - - StartBanishing = true; - } - } - CheckTimer = 2000; - }else CheckTimer -= diff; - } -}; - -struct MANGOS_DLL_DECL boss_shade_of_akamaAI : public ScriptedAI -{ - boss_shade_of_akamaAI(Creature* c) : ScriptedAI(c) - { - pInstance = ((ScriptedInstance*)c->GetInstanceData()); - AkamaGUID = pInstance ? pInstance->GetData64(DATA_AKAMA_SHADE) : 0; - Reset(); - } - - ScriptedInstance* pInstance; - - std::list Channelers; - std::list Sorcerers; - uint64 AkamaGUID; - - uint32 SorcererCount; - uint32 DeathCount; - - uint32 ReduceHealthTimer; - uint32 SummonTimer; - uint32 ResetTimer; - uint32 DefenderTimer; // They are on a flat 15 second timer, independant of the other summon creature timer. - - bool IsBanished; - bool HasKilledAkama; - - void Reset() - { - FindChannelers(); - - if(!Channelers.empty()) - for(std::list::iterator itr = Channelers.begin(); itr != Channelers.end(); ++itr) - { - Creature* Channeler = NULL; - Channeler = ((Creature*)Unit::GetUnit(*m_creature, *itr)); - if(Channeler) - { - if(Channeler->isDead()) - { - Channeler->RemoveCorpse(); - Channeler->Respawn(); - } - Channeler->CastSpell(m_creature, SPELL_SHADE_SOUL_CHANNEL, true); - Channeler->CastSpell(m_creature, SPELL_SHADE_SOUL_CHANNEL_2, true); - Channeler->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - } - } - else error_log("SD2 ERROR: No Channelers are stored in the list. This encounter will not work properly"); - - if(!Sorcerers.empty()) - for(std::list::iterator itr = Sorcerers.begin(); itr != Sorcerers.end(); ++itr) - if(Creature* Sorcerer = ((Creature*)Unit::GetUnit(*m_creature, *itr))) - if(Sorcerer->isAlive()) - { - Sorcerer->SetVisibility(VISIBILITY_OFF); - Sorcerer->DealDamage(Sorcerer, Sorcerer->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); - } - - Sorcerers.clear(); - - if(Unit* Akama = Unit::GetUnit(*m_creature, AkamaGUID)) - Akama->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP); - - SorcererCount = 0; - DeathCount = 0; - - SummonTimer = 10000; - ReduceHealthTimer = 0; - ResetTimer = 60000; - DefenderTimer = 15000; - - IsBanished = true; - HasKilledAkama = false; - - m_creature->SetVisibility(VISIBILITY_ON); - m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - m_creature->GetMotionMaster()->Clear(); - m_creature->GetMotionMaster()->MoveIdle(); - m_creature->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_STATE_STUN); - - if(pInstance && m_creature->isAlive()) - pInstance->SetData(DATA_SHADEOFAKAMAEVENT, NOT_STARTED); - } - - void Aggro(Unit* who) { } - - void AttackStart(Unit* who) - { - if(!who || IsBanished) return; - - if(who->isTargetableForAttack() && who != m_creature) - DoStartAttackAndMovement(who); - } - - void MoveInLineOfSight(Unit* who) - { - if(IsBanished) return; - - ScriptedAI::MoveInLineOfSight(who); - } - - void IncrementDeathCount(uint64 guid = 0) // If guid is set, will remove it from list of sorcerer - { - debug_log("SD2: Increasing Death Count for Shade of Akama encounter"); - ++DeathCount; - m_creature->RemoveSingleAuraFromStack(SPELL_SHADE_SOUL_CHANNEL_2, 0); - if(guid) - { - if(Sorcerers.empty()) - error_log("SD2 ERROR: Shade of Akama - attempt to remove guid %u from Sorcerers list but list is already empty", guid); - else Sorcerers.remove(guid); - } - } - - void SummonCreature() - { - uint32 random = rand()%2; - float X = SpawnLocations[random].x; - float Y = SpawnLocations[random].y; - // max of 6 sorcerers can be summoned - if((rand()%3 == 0) && (DeathCount > 0) && (SorcererCount < 7)) - { - Creature* Sorcerer = m_creature->SummonCreature(CREATURE_SORCERER, X, Y, Z_SPAWN, 0, TEMPSUMMON_DEAD_DESPAWN, 0); - if(Sorcerer) - { - ((mob_ashtongue_sorcererAI*)Sorcerer->AI())->ShadeGUID = m_creature->GetGUID(); - Sorcerer->RemoveUnitMovementFlag(MOVEMENTFLAG_WALK_MODE); - Sorcerer->GetMotionMaster()->MovePoint(0, m_creature->GetPositionX(), m_creature->GetPositionY(), m_creature->GetPositionZ()); - Sorcerer->SetUInt64Value(UNIT_FIELD_TARGET, m_creature->GetGUID()); - Sorcerers.push_back(Sorcerer->GetGUID()); - --DeathCount; - ++SorcererCount; - } - } - else - { - for(uint8 i = 0; i < 3; ++i) - { - Creature* Spawn = m_creature->SummonCreature(spawnEntries[i], X, Y, Z_SPAWN, 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 25000); - if(Spawn) - { - Spawn->RemoveUnitMovementFlag(MOVEMENTFLAG_WALK_MODE); - Spawn->GetMotionMaster()->MovePoint(0, AGGRO_X, AGGRO_Y, AGGRO_Z); - } - } - } - } - - void FindChannelers() - { - CellPair pair(MaNGOS::ComputeCellPair(m_creature->GetPositionX(), m_creature->GetPositionY())); - Cell cell(pair); - cell.data.Part.reserved = ALL_DISTRICT; - cell.SetNoCreate(); - - std::list ChannelerList; - - AllCreaturesOfEntryInRange check(m_creature, CREATURE_CHANNELER, 50); - MaNGOS::CreatureListSearcher searcher(ChannelerList, check); - TypeContainerVisitor, GridTypeMapContainer> visitor(searcher); - - CellLock cell_lock(cell, pair); - cell_lock->Visit(cell_lock, visitor, *(m_creature->GetMap())); - - if(!ChannelerList.empty()) - { - Channelers.clear(); - for(std::list::iterator itr = ChannelerList.begin(); itr != ChannelerList.end(); ++itr) - { - ((mob_ashtongue_channelerAI*)(*itr)->AI())->ShadeGUID = m_creature->GetGUID(); - Channelers.push_back((*itr)->GetGUID()); - debug_log("SD2: Shade of Akama Grid Search found channeler %u. Adding to list", (*itr)->GetGUID()); - } - } - else error_log("SD2 ERROR: Grid Search was unable to find any channelers. Shade of Akama encounter will be buggy"); - } - - void SetSelectableChannelers() - { - if(Channelers.empty()) - { - error_log("SD2 ERROR: Channeler List is empty, Shade of Akama encounter will be buggy"); - return; - } - - for(std::list::iterator itr = Channelers.begin(); itr != Channelers.end(); ++itr) - if(Creature* Channeler = ((Creature*)Unit::GetUnit(*m_creature, *itr))) - Channeler->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - } - - void SetAkamaGUID(uint64 guid) { AkamaGUID = guid; } - - void UpdateAI(const uint32 diff) - { - if(!InCombat) - return; - - if(IsBanished) - { - // Akama is set in the threatlist so when we reset, we make sure that he is not included in our check - if(m_creature->getThreatManager().getThreatList().size() < 2) - EnterEvadeMode(); - - if(DefenderTimer < diff) - { - uint32 ran = rand()%2; - Creature* Defender = m_creature->SummonCreature(CREATURE_DEFENDER, SpawnLocations[ran].x, SpawnLocations[ran].y, Z_SPAWN, 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 25000); - if(Defender) - { - Defender->RemoveUnitMovementFlag(MOVEMENTFLAG_WALK_MODE); - bool move = true; - if(AkamaGUID) - { - if(Unit* Akama = Unit::GetUnit(*m_creature, AkamaGUID)) - { - float x, y, z; - Akama->GetPosition(x,y,z); - // They move towards AKama - Defender->GetMotionMaster()->MovePoint(0, x, y, z); - }else move = false; - }else move = false; - if(!move) - Defender->GetMotionMaster()->MovePoint(0, AKAMA_X, AKAMA_Y, AKAMA_Z); - } - DefenderTimer = 15000; - }else DefenderTimer -= diff; - - if(SummonTimer < diff) - { - SummonCreature(); - SummonTimer = 35000; - }else SummonTimer -= diff; - - if(DeathCount >= 6) - { - if(AkamaGUID) - { - Unit* Akama = Unit::GetUnit((*m_creature), AkamaGUID); - if(Akama && Akama->isAlive()) - { - IsBanished = false; - m_creature->GetMotionMaster()->Clear(false); - m_creature->GetMotionMaster()->MoveChase(Akama); - Akama->GetMotionMaster()->Clear(); - // Shade should move to Akama, not the other way around - Akama->GetMotionMaster()->MoveIdle(); - m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - // Crazy amount of threat - m_creature->AddThreat(Akama, 10000000.0f); - Akama->AddThreat(m_creature, 10000000.0f); - m_creature->Attack(Akama, true); - Akama->Attack(m_creature, true); - } - } - } - } - else // No longer banished, let's fight Akama now - { - if(ReduceHealthTimer < diff) - { - if(AkamaGUID) - { - Unit* Akama = Unit::GetUnit((*m_creature), AkamaGUID); - if(Akama && Akama->isAlive()) - { - //10 % less health every few seconds. - m_creature->DealDamage(Akama, Akama->GetMaxHealth()/10, NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); - ReduceHealthTimer = 12000; - } - else - { - HasKilledAkama = true; // Akama is dead or missing, we stop fighting and disappear - m_creature->SetVisibility(VISIBILITY_OFF); - m_creature->SetHealth(m_creature->GetMaxHealth()); - m_creature->RemoveAllAuras(); - m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - } - } - }else ReduceHealthTimer -= diff; - - if(HasKilledAkama) - { - if(ResetTimer < diff) - { - InCombat = false; - EnterEvadeMode(); // Reset a little while after killing Akama - } - else ResetTimer -= diff; - } - - DoMeleeAttackIfReady(); - } - } -}; - -void mob_ashtongue_channelerAI::JustDied(Unit* killer) -{ - Creature* Shade = ((Creature*)Unit::GetUnit((*m_creature), ShadeGUID)); - if(Shade && Shade->isAlive()) - ((boss_shade_of_akamaAI*)Shade->AI())->IncrementDeathCount(); - else error_log("SD2 ERROR: Channeler dead but unable to increment DeathCount for Shade of Akama."); -} - -void mob_ashtongue_sorcererAI::JustDied(Unit* killer) -{ - Creature* Shade = ((Creature*)Unit::GetUnit((*m_creature), ShadeGUID)); - if(Shade && Shade->isAlive()) - ((boss_shade_of_akamaAI*)Shade->AI())->IncrementDeathCount(m_creature->GetGUID()); - else error_log("SD2 ERROR: Sorcerer dead but unable to increment DeathCount for Shade of Akama."); -} - -struct MANGOS_DLL_DECL npc_akamaAI : public ScriptedAI -{ - npc_akamaAI(Creature* c) : ScriptedAI(c) - { - ShadeHasDied = false; - StartCombat = false; - pInstance = ((ScriptedInstance*)c->GetInstanceData()); - ShadeGUID = pInstance ? pInstance->GetData64(DATA_SHADEOFAKAMA) : 0; - Reset(); - } - - ScriptedInstance* pInstance; - - uint64 ShadeGUID; - - uint32 DestructivePoisonTimer; - uint32 LightningBoltTimer; - uint32 CheckTimer; - uint32 CastSoulRetrieveTimer; - uint32 SoulRetrieveTimer; - uint32 SummonBrokenTimer; - uint32 EndingTalkCount; - uint32 WayPointId; - uint32 BrokenSummonIndex; - - std::list BrokenList; - - bool EventBegun; - bool ShadeHasDied; - bool StartCombat; - bool HasYelledOnce; - - void Reset() - { - DestructivePoisonTimer = 15000; - LightningBoltTimer = 10000; - CheckTimer = 2000; - CastSoulRetrieveTimer = 0; - SoulRetrieveTimer = 0; - SummonBrokenTimer = 0; - EndingTalkCount = 0; - WayPointId = 0; - BrokenSummonIndex = 0; - - BrokenList.clear(); - - EventBegun = false; - HasYelledOnce = false; - - m_creature->SetUInt32Value(UNIT_NPC_FLAGS, 0); // Database sometimes has very very strange values - m_creature->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP); - } - - void Aggro(Unit* who) {} - - void BeginEvent(Player* pl) - { - if(!pInstance) - return; - - ShadeGUID = pInstance->GetData64(DATA_SHADEOFAKAMA); - if(!ShadeGUID) - return; - - Creature* Shade = ((Creature*)Unit::GetUnit((*m_creature), ShadeGUID)); - if(Shade) - { - pInstance->SetData(DATA_SHADEOFAKAMAEVENT, IN_PROGRESS); - // Prevent players from trying to restart event - m_creature->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP); - ((boss_shade_of_akamaAI*)Shade->AI())->SetAkamaGUID(m_creature->GetGUID()); - ((boss_shade_of_akamaAI*)Shade->AI())->SetSelectableChannelers(); - ((boss_shade_of_akamaAI*)Shade->AI())->InCombat = true; - Shade->AddThreat(m_creature, 1000000.0f); - Shade->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_STATE_NONE); - Shade->SetUInt64Value(UNIT_FIELD_TARGET, m_creature->GetGUID()); - if(pl) Shade->AddThreat(pl, 1.0f); - DoZoneInCombat(Shade); - EventBegun = true; - } - } - - void MovementInform(uint32 type, uint32 id) - { - if(type != POINT_MOTION_TYPE) - return; - - switch(id) - { - case 0: ++WayPointId; break; - - case 1: - if(Unit* Shade = Unit::GetUnit(*m_creature, ShadeGUID)) - { - m_creature->SetUInt64Value(UNIT_FIELD_TARGET, ShadeGUID); - DoCast(Shade, SPELL_AKAMA_SOUL_RETRIEVE); - EndingTalkCount = 0; - SoulRetrieveTimer = 16000; - } - break; - } - } - - void JustDied(Unit* killer) - { - DoYell(SAY_DEATH, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_DEATH); - } - - void UpdateAI(const uint32 diff) - { - if(!EventBegun) - return; - - if ((m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < 15 && !HasYelledOnce) - { - DoYell(SAY_LOW_HEALTH, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_LOW_HEALTH); - HasYelledOnce = true; - } - - if(ShadeGUID && !StartCombat) - { - Creature* Shade = ((Creature*)Unit::GetUnit((*m_creature), ShadeGUID)); - if(Shade && Shade->isAlive()) - { - if(((boss_shade_of_akamaAI*)Shade->AI())->IsBanished) - { - if(CastSoulRetrieveTimer < diff) - { - DoCast(Shade, SPELL_AKAMA_SOUL_CHANNEL); - CastSoulRetrieveTimer = 500; - }else CastSoulRetrieveTimer -= diff; - } - else - { - m_creature->InterruptNonMeleeSpells(false); - StartCombat = true; - } - } - } - - if(ShadeHasDied && (WayPointId == 1)) - { - if(pInstance) pInstance->SetData(DATA_SHADEOFAKAMAEVENT, DONE); - m_creature->GetMotionMaster()->MovePoint(WayPointId, AkamaWP[1].x, AkamaWP[1].y, AkamaWP[1].z); - ++WayPointId; - } - - if(!ShadeHasDied && StartCombat) - { - if(CheckTimer < diff) - { - if(ShadeGUID) - { - Unit* Shade = Unit::GetUnit((*m_creature), ShadeGUID); - if(Shade && !Shade->isAlive()) - { - ShadeHasDied = true; - WayPointId = 0; - m_creature->SetUnitMovementFlags(MOVEMENTFLAG_WALK_MODE); - m_creature->GetMotionMaster()->MovePoint(WayPointId, AkamaWP[0].x, AkamaWP[0].y, AkamaWP[0].z); - } - } - CheckTimer = 5000; - }else CheckTimer -= diff; - } - - if(SummonBrokenTimer && BrokenSummonIndex < 4) - if(SummonBrokenTimer <= diff) - { - for(uint8 i = 0; i < 4; ++i) - { - float x = BrokenCoords[BrokenSummonIndex].x + (i*5); - float y = BrokenCoords[BrokenSummonIndex].y + (1*5); - float z = BrokenCoords[BrokenSummonIndex].z; - float o = BrokenCoords[BrokenSummonIndex].o; - Creature* Broken = m_creature->SummonCreature(CREATURE_BROKEN, x, y, z, o, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 360000); - if(Broken) - { - float wx = BrokenWP[BrokenSummonIndex].x + (i*5); - float wy = BrokenWP[BrokenSummonIndex].y + (i*5); - float wz = BrokenWP[BrokenSummonIndex].z; - Broken->GetMotionMaster()->MovePoint(0, wx, wy, wz); - Broken->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); - BrokenList.push_back(Broken->GetGUID()); - } - } - ++BrokenSummonIndex; - SummonBrokenTimer = 1000; - }else SummonBrokenTimer -= diff; - - if(SoulRetrieveTimer) - if(SoulRetrieveTimer <= diff) - { - switch(EndingTalkCount) - { - case 0: - m_creature->HandleEmoteCommand(EMOTE_ONESHOT_ROAR); - ++EndingTalkCount; - SoulRetrieveTimer = 2000; - SummonBrokenTimer = 1; - case 1: - DoYell(SAY_FREE, LANG_UNIVERSAL, NULL); - ++EndingTalkCount; - SoulRetrieveTimer = 25000; - break; - case 2: - if(!BrokenList.empty()) - { - bool Yelled = false; - for(std::list::iterator itr = BrokenList.begin(); itr != BrokenList.end(); ++itr) - if(Unit* pUnit = Unit::GetUnit(*m_creature, *itr)) - { - if(!Yelled) - { - pUnit->MonsterYell(SAY_BROKEN_FREE_01, LANG_UNIVERSAL, 0); - Yelled = true; - } - pUnit->HandleEmoteCommand(EMOTE_ONESHOT_KNEEL); - } - } - ++EndingTalkCount; - SoulRetrieveTimer = 1500; - break; - case 3: - if(!BrokenList.empty()) - for(std::list::iterator itr = BrokenList.begin(); itr != BrokenList.end(); ++itr) - if(Unit* pUnit = Unit::GetUnit(*m_creature, *itr)) - // This is the incorrect spell, but can't seem to find the right one. - pUnit->CastSpell(pUnit, 39656, true); - ++EndingTalkCount; - SoulRetrieveTimer = 5000; - case 4: - if(!BrokenList.empty()) - for(std::list::iterator itr = BrokenList.begin(); itr != BrokenList.end(); ++itr) - if(Unit* pUnit = Unit::GetUnit((*m_creature), *itr)) - pUnit->MonsterYell(SAY_BROKEN_FREE_02, LANG_UNIVERSAL, 0); - SoulRetrieveTimer = 0; - break; - } - }else SoulRetrieveTimer -= diff; - - if(!m_creature->getVictim() || !m_creature->SelectHostilTarget()) - return; - - if(DestructivePoisonTimer < diff) - { - // SPELL_DESTRUCTIVE_POISON is self-cast only for some reason so we make our target cast it on itself - m_creature->getVictim()->CastSpell(m_creature->getVictim(), SPELL_DESTRUCTIVE_POISON, true); - DestructivePoisonTimer = 15000; - }else DestructivePoisonTimer -= diff; - - if(LightningBoltTimer < diff) - { - DoCast(m_creature->getVictim(), SPELL_LIGHTNING_BOLT); - LightningBoltTimer = 10000; - }else LightningBoltTimer -= diff; - - DoMeleeAttackIfReady(); - } -}; - -CreatureAI* GetAI_boss_shade_of_akama(Creature *_Creature) -{ - return new boss_shade_of_akamaAI (_Creature); -} - -CreatureAI* GetAI_mob_ashtongue_channeler(Creature *_Creature) -{ - return new mob_ashtongue_channelerAI (_Creature); -} - -CreatureAI* GetAI_mob_ashtongue_sorcerer(Creature *_Creature) -{ - return new mob_ashtongue_sorcererAI (_Creature); -} - -CreatureAI* GetAI_npc_akama_shade(Creature *_Creature) -{ - return new npc_akamaAI (_Creature); -} - -bool GossipSelect_npc_akama(Player *player, Creature *_Creature, uint32 sender, uint32 action ) -{ - if (action == GOSSIP_ACTION_INFO_DEF + 1) //Fight time - { - player->CLOSE_GOSSIP_MENU(); - ((npc_akamaAI*)_Creature->AI())->BeginEvent(player); - } - - return true; -} - -bool GossipHello_npc_akama(Player *player, Creature *_Creature) -{ - if(player->isAlive()) - { - player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); - player->SEND_GOSSIP_MENU(907, _Creature->GetGUID()); - } - - return true; -} - -void AddSC_boss_shade_of_akama() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_shade_of_akama"; - newscript->GetAI = GetAI_boss_shade_of_akama; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="mob_ashtongue_channeler"; - newscript->GetAI = GetAI_mob_ashtongue_channeler; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="mob_ashtongue_sorcerer"; - newscript->GetAI = GetAI_mob_ashtongue_sorcerer; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="npc_akama_shade"; - newscript->GetAI = GetAI_npc_akama_shade; - newscript->pGossipHello = &GossipHello_npc_akama; - newscript->pGossipSelect = &GossipSelect_npc_akama; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006,2007 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Shade_of_Akama +SD%Complete: 99 +SDComment: Seems to be complete. +SDCategory: Black Temple +EndScriptData */ + +#include "precompiled.h" +#include "def_black_temple.h" +#include "sc_grid_searchers.h" + +struct Location +{ + float x, y, o, z; +}; + +static Location ChannelerLocations[]= +{ + {463.161285, 401.219757, 3.141592}, + {457.377625, 391.227661, 2.106461}, + {446.012421, 391.227661, 1.071904}, + {439.533783, 401.219757, 0.000000}, + {446.012421, 411.211853, 5.210546}, + {457.377625, 411.211853, 4.177494} +}; + +static Location SpawnLocations[]= +{ + {498.652740, 461.728119, 0}, + {498.505003, 339.619324, 0} +}; + +static Location AkamaWP[]= +{ + {482.352448, 401.162720, 0, 112.783928}, + {469.597443, 402.264404, 0, 118.537910} +}; + +static Location BrokenCoords[]= +{ + {541.375916, 401.439575, M_PI, 112.783997}, // The place where Akama channels + {534.130005, 352.394531, 2.164150, 112.783737}, // Behind a 'pillar' which is behind the east alcove + {499.621185, 341.534729, 1.652856, 112.783730}, // East Alcove + {499.151093, 461.036438, 4.770888, 112.78370}, // West Alcove +}; + +static Location BrokenWP[]= +{ + {492.491638, 400.744690, 3.122336, 112.783737}, + {494.335724, 382.221771, 2.676230, 112.783737}, + {489.555939, 373.507202, 2.416263, 112.783737}, + {491.136353, 427.868774, 3.519748, 112.783737}, +}; + +// Locations +#define Z1 118.543144 +#define Z2 120.783768 +#define Z_SPAWN 113.537949 +#define AGGRO_X 482.793182 +#define AGGRO_Y 401.270172 +#define AGGRO_Z 112.783928 +#define AKAMA_X 514.583984 +#define AKAMA_Y 400.601013 +#define AKAMA_Z 112.783997 + +// Texts +#define SOUND_DEATH 11386 +#define SAY_DEATH "No! Not yet..." +#define SOUND_LOW_HEALTH 11385 +#define SAY_LOW_HEALTH "I will not last much longer..." + +// Ending cinematic text +#define SAY_FREE "Come out from the shadows! I've returned to lead you against our true enemy! Shed your chains and raise your weapons against your Illidari masters!" +#define SAY_BROKEN_FREE_01 "Hail our leader! Hail Akama!" +#define SAY_BROKEN_FREE_02 "Hail Akama!" + +// Gossips +#define GOSSIP_ITEM "We are ready to fight alongside you, Akama" + +// Spells +#define SPELL_VERTEX_SHADE_BLACK 39833 +#define SPELL_SHADE_SOUL_CHANNEL 40401 +#define SPELL_DESTRUCTIVE_POISON 40874 +#define SPELL_LIGHTNING_BOLT 42024 +#define SPELL_AKAMA_SOUL_CHANNEL 40447 +#define SPELL_AKAMA_SOUL_RETRIEVE 40902 +#define AKAMA_SOUL_EXPEL 40855 +#define SPELL_SHADE_SOUL_CHANNEL_2 40520 + +// Channeler entry +#define CREATURE_CHANNELER 23421 +#define CREATURE_SORCERER 23215 +#define CREATURE_DEFENDER 23216 +#define CREATURE_BROKEN 23319 + +const uint32 spawnEntries[4]= { 23523, 23318, 23524 }; + +struct MANGOS_DLL_DECL mob_ashtongue_channelerAI : public ScriptedAI +{ + mob_ashtongue_channelerAI(Creature* c) : ScriptedAI(c) { Reset(); } + + uint64 ShadeGUID; + + void Reset() { ShadeGUID = 0; } + void JustDied(Unit* killer); + void Aggro(Unit* who) {} + void AttackStart(Unit* who) {} + void MoveInLineOfSight(Unit* who) {} + void UpdateAI(const uint32 diff) {} +}; + +struct MANGOS_DLL_DECL mob_ashtongue_sorcererAI : public ScriptedAI +{ + mob_ashtongue_sorcererAI(Creature* c) : ScriptedAI(c) { Reset(); } + + uint64 ShadeGUID; + uint32 CheckTimer; + bool StartBanishing; + + void Reset() + { + StartBanishing = false; + CheckTimer = 5000; + ShadeGUID = 0; + } + + void JustDied(Unit* killer); + void Aggro(Unit* who) {} + void AttackStart(Unit* who) {} + void MoveInLineOfSight(Unit* who) {} + void UpdateAI(const uint32 diff) + { + if(StartBanishing) + return; + + if(CheckTimer < diff) + { + Unit* Shade = Unit::GetUnit((*m_creature), ShadeGUID); + if(Shade && Shade->isAlive() && m_creature->isAlive()) + { + if(m_creature->GetDistance2d(Shade) < 20) + { + m_creature->GetMotionMaster()->Clear(false); + m_creature->GetMotionMaster()->MoveIdle(); + DoCast(Shade, SPELL_SHADE_SOUL_CHANNEL, true); + DoCast(Shade, SPELL_SHADE_SOUL_CHANNEL_2, true); + + StartBanishing = true; + } + } + CheckTimer = 2000; + }else CheckTimer -= diff; + } +}; + +struct MANGOS_DLL_DECL boss_shade_of_akamaAI : public ScriptedAI +{ + boss_shade_of_akamaAI(Creature* c) : ScriptedAI(c) + { + pInstance = ((ScriptedInstance*)c->GetInstanceData()); + AkamaGUID = pInstance ? pInstance->GetData64(DATA_AKAMA_SHADE) : 0; + Reset(); + } + + ScriptedInstance* pInstance; + + std::list Channelers; + std::list Sorcerers; + uint64 AkamaGUID; + + uint32 SorcererCount; + uint32 DeathCount; + + uint32 ReduceHealthTimer; + uint32 SummonTimer; + uint32 ResetTimer; + uint32 DefenderTimer; // They are on a flat 15 second timer, independant of the other summon creature timer. + + bool IsBanished; + bool HasKilledAkama; + + void Reset() + { + FindChannelers(); + + if(!Channelers.empty()) + for(std::list::iterator itr = Channelers.begin(); itr != Channelers.end(); ++itr) + { + Creature* Channeler = NULL; + Channeler = ((Creature*)Unit::GetUnit(*m_creature, *itr)); + if(Channeler) + { + if(Channeler->isDead()) + { + Channeler->RemoveCorpse(); + Channeler->Respawn(); + } + Channeler->CastSpell(m_creature, SPELL_SHADE_SOUL_CHANNEL, true); + Channeler->CastSpell(m_creature, SPELL_SHADE_SOUL_CHANNEL_2, true); + Channeler->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + } + } + else error_log("SD2 ERROR: No Channelers are stored in the list. This encounter will not work properly"); + + if(!Sorcerers.empty()) + for(std::list::iterator itr = Sorcerers.begin(); itr != Sorcerers.end(); ++itr) + if(Creature* Sorcerer = ((Creature*)Unit::GetUnit(*m_creature, *itr))) + if(Sorcerer->isAlive()) + { + Sorcerer->SetVisibility(VISIBILITY_OFF); + Sorcerer->DealDamage(Sorcerer, Sorcerer->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); + } + + Sorcerers.clear(); + + if(Unit* Akama = Unit::GetUnit(*m_creature, AkamaGUID)) + Akama->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP); + + SorcererCount = 0; + DeathCount = 0; + + SummonTimer = 10000; + ReduceHealthTimer = 0; + ResetTimer = 60000; + DefenderTimer = 15000; + + IsBanished = true; + HasKilledAkama = false; + + m_creature->SetVisibility(VISIBILITY_ON); + m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + m_creature->GetMotionMaster()->Clear(); + m_creature->GetMotionMaster()->MoveIdle(); + m_creature->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_STATE_STUN); + + if(pInstance && m_creature->isAlive()) + pInstance->SetData(DATA_SHADEOFAKAMAEVENT, NOT_STARTED); + } + + void Aggro(Unit* who) { } + + void AttackStart(Unit* who) + { + if(!who || IsBanished) return; + + if(who->isTargetableForAttack() && who != m_creature) + DoStartAttackAndMovement(who); + } + + void MoveInLineOfSight(Unit* who) + { + if(IsBanished) return; + + ScriptedAI::MoveInLineOfSight(who); + } + + void IncrementDeathCount(uint64 guid = 0) // If guid is set, will remove it from list of sorcerer + { + debug_log("SD2: Increasing Death Count for Shade of Akama encounter"); + ++DeathCount; + m_creature->RemoveSingleAuraFromStack(SPELL_SHADE_SOUL_CHANNEL_2, 0); + if(guid) + { + if(Sorcerers.empty()) + error_log("SD2 ERROR: Shade of Akama - attempt to remove guid %u from Sorcerers list but list is already empty", guid); + else Sorcerers.remove(guid); + } + } + + void SummonCreature() + { + uint32 random = rand()%2; + float X = SpawnLocations[random].x; + float Y = SpawnLocations[random].y; + // max of 6 sorcerers can be summoned + if((rand()%3 == 0) && (DeathCount > 0) && (SorcererCount < 7)) + { + Creature* Sorcerer = m_creature->SummonCreature(CREATURE_SORCERER, X, Y, Z_SPAWN, 0, TEMPSUMMON_DEAD_DESPAWN, 0); + if(Sorcerer) + { + ((mob_ashtongue_sorcererAI*)Sorcerer->AI())->ShadeGUID = m_creature->GetGUID(); + Sorcerer->RemoveUnitMovementFlag(MOVEMENTFLAG_WALK_MODE); + Sorcerer->GetMotionMaster()->MovePoint(0, m_creature->GetPositionX(), m_creature->GetPositionY(), m_creature->GetPositionZ()); + Sorcerer->SetUInt64Value(UNIT_FIELD_TARGET, m_creature->GetGUID()); + Sorcerers.push_back(Sorcerer->GetGUID()); + --DeathCount; + ++SorcererCount; + } + } + else + { + for(uint8 i = 0; i < 3; ++i) + { + Creature* Spawn = m_creature->SummonCreature(spawnEntries[i], X, Y, Z_SPAWN, 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 25000); + if(Spawn) + { + Spawn->RemoveUnitMovementFlag(MOVEMENTFLAG_WALK_MODE); + Spawn->GetMotionMaster()->MovePoint(0, AGGRO_X, AGGRO_Y, AGGRO_Z); + } + } + } + } + + void FindChannelers() + { + CellPair pair(MaNGOS::ComputeCellPair(m_creature->GetPositionX(), m_creature->GetPositionY())); + Cell cell(pair); + cell.data.Part.reserved = ALL_DISTRICT; + cell.SetNoCreate(); + + std::list ChannelerList; + + AllCreaturesOfEntryInRange check(m_creature, CREATURE_CHANNELER, 50); + MaNGOS::CreatureListSearcher searcher(ChannelerList, check); + TypeContainerVisitor, GridTypeMapContainer> visitor(searcher); + + CellLock cell_lock(cell, pair); + cell_lock->Visit(cell_lock, visitor, *(m_creature->GetMap())); + + if(!ChannelerList.empty()) + { + Channelers.clear(); + for(std::list::iterator itr = ChannelerList.begin(); itr != ChannelerList.end(); ++itr) + { + ((mob_ashtongue_channelerAI*)(*itr)->AI())->ShadeGUID = m_creature->GetGUID(); + Channelers.push_back((*itr)->GetGUID()); + debug_log("SD2: Shade of Akama Grid Search found channeler %u. Adding to list", (*itr)->GetGUID()); + } + } + else error_log("SD2 ERROR: Grid Search was unable to find any channelers. Shade of Akama encounter will be buggy"); + } + + void SetSelectableChannelers() + { + if(Channelers.empty()) + { + error_log("SD2 ERROR: Channeler List is empty, Shade of Akama encounter will be buggy"); + return; + } + + for(std::list::iterator itr = Channelers.begin(); itr != Channelers.end(); ++itr) + if(Creature* Channeler = ((Creature*)Unit::GetUnit(*m_creature, *itr))) + Channeler->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + } + + void SetAkamaGUID(uint64 guid) { AkamaGUID = guid; } + + void UpdateAI(const uint32 diff) + { + if(!InCombat) + return; + + if(IsBanished) + { + // Akama is set in the threatlist so when we reset, we make sure that he is not included in our check + if(m_creature->getThreatManager().getThreatList().size() < 2) + EnterEvadeMode(); + + if(DefenderTimer < diff) + { + uint32 ran = rand()%2; + Creature* Defender = m_creature->SummonCreature(CREATURE_DEFENDER, SpawnLocations[ran].x, SpawnLocations[ran].y, Z_SPAWN, 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 25000); + if(Defender) + { + Defender->RemoveUnitMovementFlag(MOVEMENTFLAG_WALK_MODE); + bool move = true; + if(AkamaGUID) + { + if(Unit* Akama = Unit::GetUnit(*m_creature, AkamaGUID)) + { + float x, y, z; + Akama->GetPosition(x,y,z); + // They move towards AKama + Defender->GetMotionMaster()->MovePoint(0, x, y, z); + }else move = false; + }else move = false; + if(!move) + Defender->GetMotionMaster()->MovePoint(0, AKAMA_X, AKAMA_Y, AKAMA_Z); + } + DefenderTimer = 15000; + }else DefenderTimer -= diff; + + if(SummonTimer < diff) + { + SummonCreature(); + SummonTimer = 35000; + }else SummonTimer -= diff; + + if(DeathCount >= 6) + { + if(AkamaGUID) + { + Unit* Akama = Unit::GetUnit((*m_creature), AkamaGUID); + if(Akama && Akama->isAlive()) + { + IsBanished = false; + m_creature->GetMotionMaster()->Clear(false); + m_creature->GetMotionMaster()->MoveChase(Akama); + Akama->GetMotionMaster()->Clear(); + // Shade should move to Akama, not the other way around + Akama->GetMotionMaster()->MoveIdle(); + m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + // Crazy amount of threat + m_creature->AddThreat(Akama, 10000000.0f); + Akama->AddThreat(m_creature, 10000000.0f); + m_creature->Attack(Akama, true); + Akama->Attack(m_creature, true); + } + } + } + } + else // No longer banished, let's fight Akama now + { + if(ReduceHealthTimer < diff) + { + if(AkamaGUID) + { + Unit* Akama = Unit::GetUnit((*m_creature), AkamaGUID); + if(Akama && Akama->isAlive()) + { + //10 % less health every few seconds. + m_creature->DealDamage(Akama, Akama->GetMaxHealth()/10, NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); + ReduceHealthTimer = 12000; + } + else + { + HasKilledAkama = true; // Akama is dead or missing, we stop fighting and disappear + m_creature->SetVisibility(VISIBILITY_OFF); + m_creature->SetHealth(m_creature->GetMaxHealth()); + m_creature->RemoveAllAuras(); + m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + } + } + }else ReduceHealthTimer -= diff; + + if(HasKilledAkama) + { + if(ResetTimer < diff) + { + InCombat = false; + EnterEvadeMode(); // Reset a little while after killing Akama + } + else ResetTimer -= diff; + } + + DoMeleeAttackIfReady(); + } + } +}; + +void mob_ashtongue_channelerAI::JustDied(Unit* killer) +{ + Creature* Shade = ((Creature*)Unit::GetUnit((*m_creature), ShadeGUID)); + if(Shade && Shade->isAlive()) + ((boss_shade_of_akamaAI*)Shade->AI())->IncrementDeathCount(); + else error_log("SD2 ERROR: Channeler dead but unable to increment DeathCount for Shade of Akama."); +} + +void mob_ashtongue_sorcererAI::JustDied(Unit* killer) +{ + Creature* Shade = ((Creature*)Unit::GetUnit((*m_creature), ShadeGUID)); + if(Shade && Shade->isAlive()) + ((boss_shade_of_akamaAI*)Shade->AI())->IncrementDeathCount(m_creature->GetGUID()); + else error_log("SD2 ERROR: Sorcerer dead but unable to increment DeathCount for Shade of Akama."); +} + +struct MANGOS_DLL_DECL npc_akamaAI : public ScriptedAI +{ + npc_akamaAI(Creature* c) : ScriptedAI(c) + { + ShadeHasDied = false; + StartCombat = false; + pInstance = ((ScriptedInstance*)c->GetInstanceData()); + ShadeGUID = pInstance ? pInstance->GetData64(DATA_SHADEOFAKAMA) : 0; + Reset(); + } + + ScriptedInstance* pInstance; + + uint64 ShadeGUID; + + uint32 DestructivePoisonTimer; + uint32 LightningBoltTimer; + uint32 CheckTimer; + uint32 CastSoulRetrieveTimer; + uint32 SoulRetrieveTimer; + uint32 SummonBrokenTimer; + uint32 EndingTalkCount; + uint32 WayPointId; + uint32 BrokenSummonIndex; + + std::list BrokenList; + + bool EventBegun; + bool ShadeHasDied; + bool StartCombat; + bool HasYelledOnce; + + void Reset() + { + DestructivePoisonTimer = 15000; + LightningBoltTimer = 10000; + CheckTimer = 2000; + CastSoulRetrieveTimer = 0; + SoulRetrieveTimer = 0; + SummonBrokenTimer = 0; + EndingTalkCount = 0; + WayPointId = 0; + BrokenSummonIndex = 0; + + BrokenList.clear(); + + EventBegun = false; + HasYelledOnce = false; + + m_creature->SetUInt32Value(UNIT_NPC_FLAGS, 0); // Database sometimes has very very strange values + m_creature->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP); + } + + void Aggro(Unit* who) {} + + void BeginEvent(Player* pl) + { + if(!pInstance) + return; + + ShadeGUID = pInstance->GetData64(DATA_SHADEOFAKAMA); + if(!ShadeGUID) + return; + + Creature* Shade = ((Creature*)Unit::GetUnit((*m_creature), ShadeGUID)); + if(Shade) + { + pInstance->SetData(DATA_SHADEOFAKAMAEVENT, IN_PROGRESS); + // Prevent players from trying to restart event + m_creature->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP); + ((boss_shade_of_akamaAI*)Shade->AI())->SetAkamaGUID(m_creature->GetGUID()); + ((boss_shade_of_akamaAI*)Shade->AI())->SetSelectableChannelers(); + ((boss_shade_of_akamaAI*)Shade->AI())->InCombat = true; + Shade->AddThreat(m_creature, 1000000.0f); + Shade->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_STATE_NONE); + Shade->SetUInt64Value(UNIT_FIELD_TARGET, m_creature->GetGUID()); + if(pl) Shade->AddThreat(pl, 1.0f); + DoZoneInCombat(Shade); + EventBegun = true; + } + } + + void MovementInform(uint32 type, uint32 id) + { + if(type != POINT_MOTION_TYPE) + return; + + switch(id) + { + case 0: ++WayPointId; break; + + case 1: + if(Unit* Shade = Unit::GetUnit(*m_creature, ShadeGUID)) + { + m_creature->SetUInt64Value(UNIT_FIELD_TARGET, ShadeGUID); + DoCast(Shade, SPELL_AKAMA_SOUL_RETRIEVE); + EndingTalkCount = 0; + SoulRetrieveTimer = 16000; + } + break; + } + } + + void JustDied(Unit* killer) + { + DoYell(SAY_DEATH, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_DEATH); + } + + void UpdateAI(const uint32 diff) + { + if(!EventBegun) + return; + + if ((m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < 15 && !HasYelledOnce) + { + DoYell(SAY_LOW_HEALTH, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_LOW_HEALTH); + HasYelledOnce = true; + } + + if(ShadeGUID && !StartCombat) + { + Creature* Shade = ((Creature*)Unit::GetUnit((*m_creature), ShadeGUID)); + if(Shade && Shade->isAlive()) + { + if(((boss_shade_of_akamaAI*)Shade->AI())->IsBanished) + { + if(CastSoulRetrieveTimer < diff) + { + DoCast(Shade, SPELL_AKAMA_SOUL_CHANNEL); + CastSoulRetrieveTimer = 500; + }else CastSoulRetrieveTimer -= diff; + } + else + { + m_creature->InterruptNonMeleeSpells(false); + StartCombat = true; + } + } + } + + if(ShadeHasDied && (WayPointId == 1)) + { + if(pInstance) pInstance->SetData(DATA_SHADEOFAKAMAEVENT, DONE); + m_creature->GetMotionMaster()->MovePoint(WayPointId, AkamaWP[1].x, AkamaWP[1].y, AkamaWP[1].z); + ++WayPointId; + } + + if(!ShadeHasDied && StartCombat) + { + if(CheckTimer < diff) + { + if(ShadeGUID) + { + Unit* Shade = Unit::GetUnit((*m_creature), ShadeGUID); + if(Shade && !Shade->isAlive()) + { + ShadeHasDied = true; + WayPointId = 0; + m_creature->SetUnitMovementFlags(MOVEMENTFLAG_WALK_MODE); + m_creature->GetMotionMaster()->MovePoint(WayPointId, AkamaWP[0].x, AkamaWP[0].y, AkamaWP[0].z); + } + } + CheckTimer = 5000; + }else CheckTimer -= diff; + } + + if(SummonBrokenTimer && BrokenSummonIndex < 4) + if(SummonBrokenTimer <= diff) + { + for(uint8 i = 0; i < 4; ++i) + { + float x = BrokenCoords[BrokenSummonIndex].x + (i*5); + float y = BrokenCoords[BrokenSummonIndex].y + (1*5); + float z = BrokenCoords[BrokenSummonIndex].z; + float o = BrokenCoords[BrokenSummonIndex].o; + Creature* Broken = m_creature->SummonCreature(CREATURE_BROKEN, x, y, z, o, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 360000); + if(Broken) + { + float wx = BrokenWP[BrokenSummonIndex].x + (i*5); + float wy = BrokenWP[BrokenSummonIndex].y + (i*5); + float wz = BrokenWP[BrokenSummonIndex].z; + Broken->GetMotionMaster()->MovePoint(0, wx, wy, wz); + Broken->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + BrokenList.push_back(Broken->GetGUID()); + } + } + ++BrokenSummonIndex; + SummonBrokenTimer = 1000; + }else SummonBrokenTimer -= diff; + + if(SoulRetrieveTimer) + if(SoulRetrieveTimer <= diff) + { + switch(EndingTalkCount) + { + case 0: + m_creature->HandleEmoteCommand(EMOTE_ONESHOT_ROAR); + ++EndingTalkCount; + SoulRetrieveTimer = 2000; + SummonBrokenTimer = 1; + case 1: + DoYell(SAY_FREE, LANG_UNIVERSAL, NULL); + ++EndingTalkCount; + SoulRetrieveTimer = 25000; + break; + case 2: + if(!BrokenList.empty()) + { + bool Yelled = false; + for(std::list::iterator itr = BrokenList.begin(); itr != BrokenList.end(); ++itr) + if(Unit* pUnit = Unit::GetUnit(*m_creature, *itr)) + { + if(!Yelled) + { + pUnit->MonsterYell(SAY_BROKEN_FREE_01, LANG_UNIVERSAL, 0); + Yelled = true; + } + pUnit->HandleEmoteCommand(EMOTE_ONESHOT_KNEEL); + } + } + ++EndingTalkCount; + SoulRetrieveTimer = 1500; + break; + case 3: + if(!BrokenList.empty()) + for(std::list::iterator itr = BrokenList.begin(); itr != BrokenList.end(); ++itr) + if(Unit* pUnit = Unit::GetUnit(*m_creature, *itr)) + // This is the incorrect spell, but can't seem to find the right one. + pUnit->CastSpell(pUnit, 39656, true); + ++EndingTalkCount; + SoulRetrieveTimer = 5000; + case 4: + if(!BrokenList.empty()) + for(std::list::iterator itr = BrokenList.begin(); itr != BrokenList.end(); ++itr) + if(Unit* pUnit = Unit::GetUnit((*m_creature), *itr)) + pUnit->MonsterYell(SAY_BROKEN_FREE_02, LANG_UNIVERSAL, 0); + SoulRetrieveTimer = 0; + break; + } + }else SoulRetrieveTimer -= diff; + + if(!m_creature->getVictim() || !m_creature->SelectHostilTarget()) + return; + + if(DestructivePoisonTimer < diff) + { + // SPELL_DESTRUCTIVE_POISON is self-cast only for some reason so we make our target cast it on itself + m_creature->getVictim()->CastSpell(m_creature->getVictim(), SPELL_DESTRUCTIVE_POISON, true); + DestructivePoisonTimer = 15000; + }else DestructivePoisonTimer -= diff; + + if(LightningBoltTimer < diff) + { + DoCast(m_creature->getVictim(), SPELL_LIGHTNING_BOLT); + LightningBoltTimer = 10000; + }else LightningBoltTimer -= diff; + + DoMeleeAttackIfReady(); + } +}; + +CreatureAI* GetAI_boss_shade_of_akama(Creature *_Creature) +{ + return new boss_shade_of_akamaAI (_Creature); +} + +CreatureAI* GetAI_mob_ashtongue_channeler(Creature *_Creature) +{ + return new mob_ashtongue_channelerAI (_Creature); +} + +CreatureAI* GetAI_mob_ashtongue_sorcerer(Creature *_Creature) +{ + return new mob_ashtongue_sorcererAI (_Creature); +} + +CreatureAI* GetAI_npc_akama_shade(Creature *_Creature) +{ + return new npc_akamaAI (_Creature); +} + +bool GossipSelect_npc_akama(Player *player, Creature *_Creature, uint32 sender, uint32 action ) +{ + if (action == GOSSIP_ACTION_INFO_DEF + 1) //Fight time + { + player->CLOSE_GOSSIP_MENU(); + ((npc_akamaAI*)_Creature->AI())->BeginEvent(player); + } + + return true; +} + +bool GossipHello_npc_akama(Player *player, Creature *_Creature) +{ + if(player->isAlive()) + { + player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); + player->SEND_GOSSIP_MENU(907, _Creature->GetGUID()); + } + + return true; +} + +void AddSC_boss_shade_of_akama() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_shade_of_akama"; + newscript->GetAI = GetAI_boss_shade_of_akama; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="mob_ashtongue_channeler"; + newscript->GetAI = GetAI_mob_ashtongue_channeler; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="mob_ashtongue_sorcerer"; + newscript->GetAI = GetAI_mob_ashtongue_sorcerer; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="npc_akama_shade"; + newscript->GetAI = GetAI_npc_akama_shade; + newscript->pGossipHello = &GossipHello_npc_akama; + newscript->pGossipSelect = &GossipSelect_npc_akama; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/black_temple/boss_supremus.cpp b/src/bindings/scripts/scripts/zone/black_temple/boss_supremus.cpp index f3b06ea6940..acdc421ced4 100644 --- a/src/bindings/scripts/scripts/zone/black_temple/boss_supremus.cpp +++ b/src/bindings/scripts/scripts/zone/black_temple/boss_supremus.cpp @@ -1,406 +1,406 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Supremus -SD%Complete: 95 -SDComment: Need to implement doors. -SDCategory: Black Temple -EndScriptData */ - -#include "precompiled.h" -#include "def_black_temple.h" - -//Spells -#define SPELL_HURTFUL_STRIKE 41926 -#define SPELL_DEMON_FIRE 40029 -#define SPELL_MOLTEN_FLAME 40253 -#define SPELL_VOLCANIC_ERUPTION 40276 -#define SPELL_VOLCANIC_FIREBALL 40118 -#define SPELL_VOLCANIC_GEYSER 42055 -#define SPELL_MOLTEN_PUNCH 40126 -#define SPELL_BERSERK 45078 - -#define CREATURE_VOLCANO 23085 -#define CREATURE_STALKER 23095 - -struct MANGOS_DLL_DECL molten_flameAI : public ScriptedAI -{ - molten_flameAI(Creature *c) : ScriptedAI(c) - { - Reset(); - } - - uint64 SupremusGUID; - bool TargetLocked; - uint32 CheckTimer; - - void Reset() - { - SupremusGUID = 0; - TargetLocked = false; - - CheckTimer = 1000; - } - - void Aggro(Unit *who) {} - void AttackStart(Unit* who) {} - void MoveInLineOfSight(Unit *who) - { - if(TargetLocked) - return; // stop it from aggroing players who move in LOS if we have a target. - if(who && (who != m_creature) && (m_creature->IsWithinDistInMap(who, 10))) - StalkTarget(who); - } - - void SetSupremusGUID(uint64 GUID) { SupremusGUID = GUID; } - - void StalkTarget(Unit* target) - { - if(!target) return; - - m_creature->AddThreat(target, 50000000.0f); - m_creature->GetMotionMaster()->MoveChase(target); - DoCast(m_creature, SPELL_DEMON_FIRE, true); - // DoCast(m_creature, SPELL_MOLTEN_FLAME, true); // This spell damages self, so disabled for now - TargetLocked = true; - } - - void UpdateAI(const uint32 diff) - { - if (!m_creature->SelectHostilTarget()) - return; - - if(m_creature->getVictim() && m_creature->isAlive()) - { - if(CheckTimer < diff) - { - if(SupremusGUID) - { - Unit* Supremus = NULL; - Supremus = Unit::GetUnit((*m_creature), SupremusGUID); - if(Supremus && (!Supremus->isAlive())) - m_creature->DealDamage(m_creature, m_creature->GetHealth(), 0, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); - } - CheckTimer = 2000; - }else CheckTimer -= diff; - } - } -}; - -struct MANGOS_DLL_DECL npc_volcanoAI : public ScriptedAI -{ - npc_volcanoAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 CheckTimer; - uint64 SupremusGUID; - uint32 FireballTimer; - uint32 GeyserTimer; - - void Reset() - { - CheckTimer = 1000; - SupremusGUID = 0; - FireballTimer = 500; - GeyserTimer = 0; - } - - void Aggro(Unit *who) {} - void AttackStart(Unit* who) {} - void MoveInLineOfSight(Unit* who) {} - void SetSupremusGUID(uint64 guid) { SupremusGUID = guid; } - - void UpdateAI(const uint32 diff) - { - if(CheckTimer < diff) - { - if(SupremusGUID) - { - Unit* Supremus = NULL; - Supremus = Unit::GetUnit((*m_creature), SupremusGUID); - if(Supremus && (!Supremus->isAlive())) - m_creature->DealDamage(m_creature, m_creature->GetHealth(), 0, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); - } - CheckTimer = 2000; - }else CheckTimer -= diff; - - if(GeyserTimer < diff) - { - DoCast(m_creature, SPELL_VOLCANIC_GEYSER); - GeyserTimer = 18000; - }else GeyserTimer -= diff; - } -}; - -struct MANGOS_DLL_DECL boss_supremusAI : public ScriptedAI -{ - boss_supremusAI(Creature *c) : ScriptedAI(c) - { - pInstance = ((ScriptedInstance*)c->GetInstanceData()); - Reset(); - } - - ScriptedInstance* pInstance; - - uint32 SummonFlameTimer; - uint32 SwitchTargetTimer; - uint32 PhaseSwitchTimer; - uint32 SummonVolcanoTimer; - uint32 HurtfulStrikeTimer; - uint32 BerserkTimer; - - bool Phase1; - - void Reset() - { - if(pInstance) - { - if(m_creature->isAlive()) - { - pInstance->SetData(DATA_SUPREMUSEVENT, NOT_STARTED); - ToggleDoors(true); - } - else ToggleDoors(false); - } - - HurtfulStrikeTimer = 5000; - SummonFlameTimer = 20000; - SwitchTargetTimer = 90000; - PhaseSwitchTimer = 60000; - SummonVolcanoTimer = 5000; - BerserkTimer = 900000; // 15 minute enrage - - Phase1 = true; - } - - void Aggro(Unit *who) - { - DoZoneInCombat(); - - if(pInstance) - pInstance->SetData(DATA_SUPREMUSEVENT, IN_PROGRESS); - } - - void ToggleDoors(bool close) - { - if(GameObject* Doors = GameObject::GetGameObject(*m_creature, pInstance->GetData64(DATA_GAMEOBJECT_SUPREMUS_DOORS))) - { - if(close) Doors->SetGoState(1); // Closed - else Doors->SetGoState(0); // Open - } - } - - void JustDied(Unit *killer) - { - if(pInstance) - { - pInstance->SetData(DATA_SUPREMUSEVENT, DONE); - ToggleDoors(false); - } - } - - float CalculateRandomCoord(float initial) - { - float coord = 0; - - switch(rand()%2) - { - case 0: coord = initial + 20 + rand()%20; break; - case 1: coord = initial - 20 - rand()%20; break; - } - - return coord; - } - - Creature* SummonCreature(uint32 entry, Unit* target) - { - if(target && entry) - { - Creature* Summon = m_creature->SummonCreature(entry, CalculateRandomCoord(target->GetPositionX()), CalculateRandomCoord(target->GetPositionY()), target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN, 20000); - if(Summon) - { - Summon->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - Summon->setFaction(m_creature->getFaction()); - return Summon; - } - } - return NULL; - } - - Unit* CalculateHurtfulStrikeTarget() - { - uint32 health = 0; - Unit* target = NULL; - - std::list& m_threatlist = m_creature->getThreatManager().getThreatList(); - std::list::iterator i = m_threatlist.begin(); - for (i = m_threatlist.begin(); i!= m_threatlist.end();++i) - { - Unit* pUnit = Unit::GetUnit((*m_creature), (*i)->getUnitGuid()); - if(pUnit && m_creature->IsWithinDistInMap(pUnit, ATTACK_DISTANCE)) - { - if(pUnit->GetHealth() > health) - { - health = pUnit->GetHealth(); - target = pUnit; - } - } - } - - return target; - } - - void UpdateAI(const uint32 diff) - { - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - if(!m_creature->HasAura(SPELL_BERSERK, 0)) - if(BerserkTimer < diff) - DoCast(m_creature, SPELL_BERSERK); - else BerserkTimer -= diff; - - if(SummonFlameTimer < diff) - { - Unit* target = NULL; - target = SelectUnit(SELECT_TARGET_RANDOM, 1); - - if(!target) // someone is trying to solo, set target as current victim. - target = m_creature->getVictim(); - - if(target) - { - Creature* MoltenFlame = SummonCreature(CREATURE_STALKER, target); - if(MoltenFlame) - { - // Invisible model - MoltenFlame->SetUInt32Value(UNIT_FIELD_DISPLAYID, 11686); - ((molten_flameAI*)MoltenFlame->AI())->SetSupremusGUID(m_creature->GetGUID()); - ((molten_flameAI*)MoltenFlame->AI())->StalkTarget(target); - SummonFlameTimer = 20000; - } - } - }else SummonFlameTimer -= diff; - - if(Phase1) - { - if(HurtfulStrikeTimer < diff) - { - Unit* target = CalculateHurtfulStrikeTarget(); - if(target) - { - DoCast(target, SPELL_HURTFUL_STRIKE); - HurtfulStrikeTimer = 5000; - } - }else HurtfulStrikeTimer -= diff; - } - - if(!Phase1) - { - if(SwitchTargetTimer < diff) - { - Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0); - if(target) - { - DoResetThreat(); - m_creature->AddThreat(target, 5000000.0f); - DoTextEmote("acquires a new target!", NULL); - SwitchTargetTimer = 10000; - } - - }else SwitchTargetTimer -= diff; - - if(SummonVolcanoTimer < diff) - { - Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 1); - - if(!target) - target = m_creature->getVictim(); - - if(target) - { - Creature* Volcano = NULL; - Volcano = SummonCreature(CREATURE_VOLCANO, target); - - if(Volcano) - { - DoCast(target, SPELL_VOLCANIC_ERUPTION); - ((npc_volcanoAI*)Volcano->AI())->SetSupremusGUID(m_creature->GetGUID()); - } - - DoTextEmote("roars and the ground begins to crack open!", NULL); - SummonVolcanoTimer = 10000; - } - }else SummonVolcanoTimer -= diff; - } - - if(PhaseSwitchTimer < diff) - { - if(!Phase1) - { - Phase1 = true; - DoResetThreat(); - PhaseSwitchTimer = 60000; - m_creature->SetSpeed(MOVE_RUN, 1.0f); - } - else - { - Phase1 = false; - DoResetThreat(); - SwitchTargetTimer = 10000; - SummonVolcanoTimer = 2000; - PhaseSwitchTimer = 60000; - m_creature->SetSpeed(MOVE_RUN, 0.9f); - } - }else PhaseSwitchTimer -= diff; - - DoMeleeAttackIfReady(); - } -}; - -CreatureAI* GetAI_boss_supremus(Creature *_Creature) -{ - return new boss_supremusAI (_Creature); -} - -CreatureAI* GetAI_molten_flame(Creature *_Creature) -{ - return new molten_flameAI (_Creature); -} - -CreatureAI* GetAI_npc_volcano(Creature *_Creature) -{ - return new npc_volcanoAI (_Creature); -} - -void AddSC_boss_supremus() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_supremus"; - newscript->GetAI = GetAI_boss_supremus; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="molten_flame"; - newscript->GetAI = GetAI_molten_flame; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="npc_volcano"; - newscript->GetAI = GetAI_npc_volcano; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Supremus +SD%Complete: 95 +SDComment: Need to implement doors. +SDCategory: Black Temple +EndScriptData */ + +#include "precompiled.h" +#include "def_black_temple.h" + +//Spells +#define SPELL_HURTFUL_STRIKE 41926 +#define SPELL_DEMON_FIRE 40029 +#define SPELL_MOLTEN_FLAME 40253 +#define SPELL_VOLCANIC_ERUPTION 40276 +#define SPELL_VOLCANIC_FIREBALL 40118 +#define SPELL_VOLCANIC_GEYSER 42055 +#define SPELL_MOLTEN_PUNCH 40126 +#define SPELL_BERSERK 45078 + +#define CREATURE_VOLCANO 23085 +#define CREATURE_STALKER 23095 + +struct MANGOS_DLL_DECL molten_flameAI : public ScriptedAI +{ + molten_flameAI(Creature *c) : ScriptedAI(c) + { + Reset(); + } + + uint64 SupremusGUID; + bool TargetLocked; + uint32 CheckTimer; + + void Reset() + { + SupremusGUID = 0; + TargetLocked = false; + + CheckTimer = 1000; + } + + void Aggro(Unit *who) {} + void AttackStart(Unit* who) {} + void MoveInLineOfSight(Unit *who) + { + if(TargetLocked) + return; // stop it from aggroing players who move in LOS if we have a target. + if(who && (who != m_creature) && (m_creature->IsWithinDistInMap(who, 10))) + StalkTarget(who); + } + + void SetSupremusGUID(uint64 GUID) { SupremusGUID = GUID; } + + void StalkTarget(Unit* target) + { + if(!target) return; + + m_creature->AddThreat(target, 50000000.0f); + m_creature->GetMotionMaster()->MoveChase(target); + DoCast(m_creature, SPELL_DEMON_FIRE, true); + // DoCast(m_creature, SPELL_MOLTEN_FLAME, true); // This spell damages self, so disabled for now + TargetLocked = true; + } + + void UpdateAI(const uint32 diff) + { + if (!m_creature->SelectHostilTarget()) + return; + + if(m_creature->getVictim() && m_creature->isAlive()) + { + if(CheckTimer < diff) + { + if(SupremusGUID) + { + Unit* Supremus = NULL; + Supremus = Unit::GetUnit((*m_creature), SupremusGUID); + if(Supremus && (!Supremus->isAlive())) + m_creature->DealDamage(m_creature, m_creature->GetHealth(), 0, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); + } + CheckTimer = 2000; + }else CheckTimer -= diff; + } + } +}; + +struct MANGOS_DLL_DECL npc_volcanoAI : public ScriptedAI +{ + npc_volcanoAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 CheckTimer; + uint64 SupremusGUID; + uint32 FireballTimer; + uint32 GeyserTimer; + + void Reset() + { + CheckTimer = 1000; + SupremusGUID = 0; + FireballTimer = 500; + GeyserTimer = 0; + } + + void Aggro(Unit *who) {} + void AttackStart(Unit* who) {} + void MoveInLineOfSight(Unit* who) {} + void SetSupremusGUID(uint64 guid) { SupremusGUID = guid; } + + void UpdateAI(const uint32 diff) + { + if(CheckTimer < diff) + { + if(SupremusGUID) + { + Unit* Supremus = NULL; + Supremus = Unit::GetUnit((*m_creature), SupremusGUID); + if(Supremus && (!Supremus->isAlive())) + m_creature->DealDamage(m_creature, m_creature->GetHealth(), 0, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); + } + CheckTimer = 2000; + }else CheckTimer -= diff; + + if(GeyserTimer < diff) + { + DoCast(m_creature, SPELL_VOLCANIC_GEYSER); + GeyserTimer = 18000; + }else GeyserTimer -= diff; + } +}; + +struct MANGOS_DLL_DECL boss_supremusAI : public ScriptedAI +{ + boss_supremusAI(Creature *c) : ScriptedAI(c) + { + pInstance = ((ScriptedInstance*)c->GetInstanceData()); + Reset(); + } + + ScriptedInstance* pInstance; + + uint32 SummonFlameTimer; + uint32 SwitchTargetTimer; + uint32 PhaseSwitchTimer; + uint32 SummonVolcanoTimer; + uint32 HurtfulStrikeTimer; + uint32 BerserkTimer; + + bool Phase1; + + void Reset() + { + if(pInstance) + { + if(m_creature->isAlive()) + { + pInstance->SetData(DATA_SUPREMUSEVENT, NOT_STARTED); + ToggleDoors(true); + } + else ToggleDoors(false); + } + + HurtfulStrikeTimer = 5000; + SummonFlameTimer = 20000; + SwitchTargetTimer = 90000; + PhaseSwitchTimer = 60000; + SummonVolcanoTimer = 5000; + BerserkTimer = 900000; // 15 minute enrage + + Phase1 = true; + } + + void Aggro(Unit *who) + { + DoZoneInCombat(); + + if(pInstance) + pInstance->SetData(DATA_SUPREMUSEVENT, IN_PROGRESS); + } + + void ToggleDoors(bool close) + { + if(GameObject* Doors = GameObject::GetGameObject(*m_creature, pInstance->GetData64(DATA_GAMEOBJECT_SUPREMUS_DOORS))) + { + if(close) Doors->SetGoState(1); // Closed + else Doors->SetGoState(0); // Open + } + } + + void JustDied(Unit *killer) + { + if(pInstance) + { + pInstance->SetData(DATA_SUPREMUSEVENT, DONE); + ToggleDoors(false); + } + } + + float CalculateRandomCoord(float initial) + { + float coord = 0; + + switch(rand()%2) + { + case 0: coord = initial + 20 + rand()%20; break; + case 1: coord = initial - 20 - rand()%20; break; + } + + return coord; + } + + Creature* SummonCreature(uint32 entry, Unit* target) + { + if(target && entry) + { + Creature* Summon = m_creature->SummonCreature(entry, CalculateRandomCoord(target->GetPositionX()), CalculateRandomCoord(target->GetPositionY()), target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN, 20000); + if(Summon) + { + Summon->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + Summon->setFaction(m_creature->getFaction()); + return Summon; + } + } + return NULL; + } + + Unit* CalculateHurtfulStrikeTarget() + { + uint32 health = 0; + Unit* target = NULL; + + std::list& m_threatlist = m_creature->getThreatManager().getThreatList(); + std::list::iterator i = m_threatlist.begin(); + for (i = m_threatlist.begin(); i!= m_threatlist.end();++i) + { + Unit* pUnit = Unit::GetUnit((*m_creature), (*i)->getUnitGuid()); + if(pUnit && m_creature->IsWithinDistInMap(pUnit, ATTACK_DISTANCE)) + { + if(pUnit->GetHealth() > health) + { + health = pUnit->GetHealth(); + target = pUnit; + } + } + } + + return target; + } + + void UpdateAI(const uint32 diff) + { + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + if(!m_creature->HasAura(SPELL_BERSERK, 0)) + if(BerserkTimer < diff) + DoCast(m_creature, SPELL_BERSERK); + else BerserkTimer -= diff; + + if(SummonFlameTimer < diff) + { + Unit* target = NULL; + target = SelectUnit(SELECT_TARGET_RANDOM, 1); + + if(!target) // someone is trying to solo, set target as current victim. + target = m_creature->getVictim(); + + if(target) + { + Creature* MoltenFlame = SummonCreature(CREATURE_STALKER, target); + if(MoltenFlame) + { + // Invisible model + MoltenFlame->SetUInt32Value(UNIT_FIELD_DISPLAYID, 11686); + ((molten_flameAI*)MoltenFlame->AI())->SetSupremusGUID(m_creature->GetGUID()); + ((molten_flameAI*)MoltenFlame->AI())->StalkTarget(target); + SummonFlameTimer = 20000; + } + } + }else SummonFlameTimer -= diff; + + if(Phase1) + { + if(HurtfulStrikeTimer < diff) + { + Unit* target = CalculateHurtfulStrikeTarget(); + if(target) + { + DoCast(target, SPELL_HURTFUL_STRIKE); + HurtfulStrikeTimer = 5000; + } + }else HurtfulStrikeTimer -= diff; + } + + if(!Phase1) + { + if(SwitchTargetTimer < diff) + { + Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0); + if(target) + { + DoResetThreat(); + m_creature->AddThreat(target, 5000000.0f); + DoTextEmote("acquires a new target!", NULL); + SwitchTargetTimer = 10000; + } + + }else SwitchTargetTimer -= diff; + + if(SummonVolcanoTimer < diff) + { + Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 1); + + if(!target) + target = m_creature->getVictim(); + + if(target) + { + Creature* Volcano = NULL; + Volcano = SummonCreature(CREATURE_VOLCANO, target); + + if(Volcano) + { + DoCast(target, SPELL_VOLCANIC_ERUPTION); + ((npc_volcanoAI*)Volcano->AI())->SetSupremusGUID(m_creature->GetGUID()); + } + + DoTextEmote("roars and the ground begins to crack open!", NULL); + SummonVolcanoTimer = 10000; + } + }else SummonVolcanoTimer -= diff; + } + + if(PhaseSwitchTimer < diff) + { + if(!Phase1) + { + Phase1 = true; + DoResetThreat(); + PhaseSwitchTimer = 60000; + m_creature->SetSpeed(MOVE_RUN, 1.0f); + } + else + { + Phase1 = false; + DoResetThreat(); + SwitchTargetTimer = 10000; + SummonVolcanoTimer = 2000; + PhaseSwitchTimer = 60000; + m_creature->SetSpeed(MOVE_RUN, 0.9f); + } + }else PhaseSwitchTimer -= diff; + + DoMeleeAttackIfReady(); + } +}; + +CreatureAI* GetAI_boss_supremus(Creature *_Creature) +{ + return new boss_supremusAI (_Creature); +} + +CreatureAI* GetAI_molten_flame(Creature *_Creature) +{ + return new molten_flameAI (_Creature); +} + +CreatureAI* GetAI_npc_volcano(Creature *_Creature) +{ + return new npc_volcanoAI (_Creature); +} + +void AddSC_boss_supremus() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_supremus"; + newscript->GetAI = GetAI_boss_supremus; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="molten_flame"; + newscript->GetAI = GetAI_molten_flame; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="npc_volcano"; + newscript->GetAI = GetAI_npc_volcano; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/black_temple/boss_teron_gorefiend.cpp b/src/bindings/scripts/scripts/zone/black_temple/boss_teron_gorefiend.cpp index 9c1182cfd0e..e8ab3c6d490 100644 --- a/src/bindings/scripts/scripts/zone/black_temple/boss_teron_gorefiend.cpp +++ b/src/bindings/scripts/scripts/zone/black_temple/boss_teron_gorefiend.cpp @@ -1,589 +1,589 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Teron_Gorefiend -SD%Complete: 60 -SDComment: Requires Mind Control support for Ghosts. -SDCategory: Black Temple -EndScriptData */ - -#include "precompiled.h" -#include "def_black_temple.h" - -//Spells -#define SPELL_INCINERATE 40239 -#define SPELL_CRUSHING_SHADOWS 40243 -#define SPELL_SHADOWBOLT 40185 -#define SPELL_PASSIVE_SHADOWFORM 40326 -#define SPELL_SHADOW_OF_DEATH 40251 -#define SPELL_BERSERK 45078 - -#define SPELL_ATROPHY 40327 // Shadowy Constructs use this when they get within melee range of a player - -//Speech'n'sound -#define SAY_INTRO "I was the first, you know. For me, the wheel of death has spun many times. So much time has passed. I have a lot of catching up to do..." -#define SOUND_INTRO 11512 - -#define SAY_AGGRO "Vengeance is mine!" -#define SOUND_AGGRO 11513 - -#define SAY_SLAY1 "I have use for you!" -#define SOUND_SLAY1 11514 - -#define SAY_SLAY2 "It gets worse..." -#define SOUND_SLAY2 11515 - -#define SAY_SPELL1 "What are you afraid of?" -#define SOUND_SPELL1 11517 - -#define SAY_SPELL2 "Death... really isn't so bad." -#define SOUND_SPELL2 11516 - -#define SAY_SPECIAL1 "Give in!" -#define SOUND_SPECIAL1 11518 - -#define SAY_SPECIAL2 "I have something for you..." -#define SOUND_SPECIAL2 11519 - -#define SAY_ENRAGE "YOU WILL SHOW THE PROPER RESPECT!" -#define SOUND_ENRAGE 11520 - -#define SAY_DEATH "The wheel...spins...again...." -#define SOUND_DEATH 11521 - -#define CREATURE_DOOM_BLOSSOM 23123 -#define CREATURE_SHADOWY_CONSTRUCT 23111 - -struct MANGOS_DLL_DECL mob_doom_blossomAI : public ScriptedAI -{ - mob_doom_blossomAI(Creature *c) : ScriptedAI(c) - { - Reset(); - } - - uint32 CheckTeronTimer; - uint32 ShadowBoltTimer; - uint64 TeronGUID; - - void Reset() - { - CheckTeronTimer = 5000; - ShadowBoltTimer = 12000; - TeronGUID = 0; - } - - void Aggro(Unit *who) { } - void AttackStart(Unit* who) { } - void MoveInLineOfSight(Unit* who) { } - - void UpdateAI(const uint32 diff) - { - if(CheckTeronTimer < diff) - { - if(TeronGUID) - { - DoZoneInCombat(); - - Creature* Teron = ((Creature*)Unit::GetUnit((*m_creature), TeronGUID)); - if((Teron) && (!Teron->isAlive() || Teron->IsInEvadeMode())) - m_creature->DealDamage(m_creature, m_creature->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); - } - else - m_creature->DealDamage(m_creature, m_creature->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); - - CheckTeronTimer = 5000; - }else CheckTeronTimer -= diff; - - if(!m_creature->getVictim() || !m_creature->SelectHostilTarget()) - return; - - if(ShadowBoltTimer < diff) - { - DoCast(SelectUnit(SELECT_TARGET_RANDOM, 0), SPELL_SHADOWBOLT); - ShadowBoltTimer = 10000; - }else ShadowBoltTimer -= diff; - } - - void SetTeronGUID(uint64 guid){ TeronGUID = guid; } -}; - -//This is used to sort the players by distance for Constructs to see who to cast Atrophy on -struct TargetDistanceOrder : public std::binary_function -{ - const Unit* MainTarget; - TargetDistanceOrder(const Unit* Target) : MainTarget(Target) {}; - // functor for operator "<" - bool operator()(const Unit* _Left, const Unit* _Right) const - { - return (MainTarget->GetDistance(_Left) < MainTarget->GetDistance(_Right)); - } -}; - -struct MANGOS_DLL_DECL mob_shadowy_constructAI : public ScriptedAI -{ - mob_shadowy_constructAI(Creature* c) : ScriptedAI(c) - { - Reset(); - } - - uint64 GhostGUID; - uint64 TeronGUID; - - uint32 CheckPlayerTimer; - uint32 CheckTeronTimer; - - void Reset() - { - GhostGUID = 0; - TeronGUID = 0; - - CheckPlayerTimer = 2000; - CheckTeronTimer = 5000; - } - - void Aggro(Unit* who) { } - - void MoveInLineOfSight(Unit *who) - { - if(!who || (!who->isAlive()) || (who->GetGUID() == GhostGUID)) - return; - - if(who->isTargetableForAttack() && who->isInAccessablePlaceFor(m_creature) && m_creature->IsHostileTo(who)) - { - float attackRadius = m_creature->GetAttackDistance(who); - - if (m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->GetDistanceZ(who) <= CREATURE_Z_ATTACK_RANGE && m_creature->IsWithinLOSInMap(who)) - { - if(who->HasStealthAura()) - who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); - - m_creature->AddThreat(who, 1.0f); - } - } - } - -/* Comment it out for now. NOTE TO FUTURE DEV: UNCOMMENT THIS OUT ONLY AFTER MIND CONTROL IS IMPLEMENTED - void DamageTaken(Unit* done_by, uint32 &damage) - { - if(done_by->GetGUID() != GhostGUID) - damage = 0; // Only the ghost can deal damage. - } - */ - - void CheckPlayers() - { - std::list& m_threatlist = m_creature->getThreatManager().getThreatList(); - if(m_threatlist.empty()) - return; // No threat list. Don't continue. - std::list::iterator itr = m_threatlist.begin(); - std::list targets; - for( ; itr != m_threatlist.end(); ++itr) - { - Unit* pUnit = Unit::GetUnit((*m_creature), (*itr)->getUnitGuid()); - if(pUnit && pUnit->isAlive()) - targets.push_back(pUnit); - } - targets.sort(TargetDistanceOrder(m_creature)); - Unit* target = targets.front(); - if(target && m_creature->IsWithinDistInMap(target, m_creature->GetAttackDistance(target))) - { - DoCast(target, SPELL_ATROPHY); - m_creature->AI()->AttackStart(target); - } - } - - void UpdateAI(const uint32 diff) - { - if(CheckPlayerTimer < diff) - { - CheckPlayers(); - CheckPlayerTimer = 3000; - }else CheckPlayerTimer -= diff; - - if(CheckTeronTimer < diff) - { - Creature* Teron = ((Creature*)Unit::GetUnit((*m_creature), TeronGUID)); - if(!Teron || !Teron->isAlive() || Teron->IsInEvadeMode()) - m_creature->DealDamage(m_creature, m_creature->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); - - CheckTeronTimer = 5000; - }else CheckTeronTimer -= diff; - } -}; - -struct MANGOS_DLL_DECL boss_teron_gorefiendAI : public ScriptedAI -{ - boss_teron_gorefiendAI(Creature *c) : ScriptedAI(c) - { - pInstance = ((ScriptedInstance*)c->GetInstanceData()); - Reset(); - } - - ScriptedInstance* pInstance; - - uint32 IncinerateTimer; - uint32 SummonDoomBlossomTimer; - uint32 EnrageTimer; - uint32 CrushingShadowsTimer; - uint32 ShadowOfDeathTimer; - uint32 SummonShadowsTimer; - uint32 RandomYellTimer; - uint32 AggroTimer; - - uint64 AggroTargetGUID; - uint64 GhostGUID; // Player that gets killed by Shadow of Death and gets turned into a ghost - - bool Intro; - - void Reset() - { - if(pInstance) - pInstance->SetData(DATA_TERONGOREFIENDEVENT, NOT_STARTED); - - IncinerateTimer = 20000 + rand()%11000; - SummonDoomBlossomTimer = 12000; - EnrageTimer = 600000; - CrushingShadowsTimer = 22000; - SummonShadowsTimer = 60000; - RandomYellTimer = 50000; - - m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - // Start off unattackable so that the intro is done properly - m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); - - AggroTimer = 20000; - AggroTargetGUID = 0; - Intro = false; - } - - void Aggro(Unit *who) {} - - void MoveInLineOfSight(Unit *who) - { - if(!who || (!who->isAlive())) return; - - if(who->isTargetableForAttack() && who->isInAccessablePlaceFor(m_creature) && m_creature->IsHostileTo(who)) - { - float attackRadius = m_creature->GetAttackDistance(who); - - if (m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->GetDistanceZ(who) <= CREATURE_Z_ATTACK_RANGE && m_creature->IsWithinLOSInMap(who)) - { - if(who->HasStealthAura()) - who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); - - m_creature->AddThreat(who, 1.0f); - } - - if(!InCombat && !Intro && m_creature->IsWithinDistInMap(who, 200.0f) && (who->GetTypeId() == TYPEID_PLAYER)) - { - if(pInstance) - pInstance->SetData(DATA_TERONGOREFIENDEVENT, IN_PROGRESS); - - m_creature->GetMotionMaster()->Clear(false); - m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - DoYell(SAY_INTRO,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature, SOUND_INTRO); - m_creature->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_STATE_TALK); - AggroTargetGUID = who->GetGUID(); - Intro = true; - } - } - } - - void KilledUnit(Unit *victim) - { - switch(rand()%2) - { - case 0: - DoYell(SAY_SLAY1,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature, SOUND_SLAY1); - break; - case 1: - DoYell(SAY_SLAY2,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature, SOUND_SLAY2); - break; - } - } - - void JustDied(Unit *victim) - { - if(pInstance) - pInstance->SetData(DATA_TERONGOREFIENDEVENT, DONE); - - DoYell(SAY_DEATH,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_DEATH); - } - - float CalculateRandomLocation(float Loc, uint32 radius) - { - float coord = Loc; - switch(rand()%2) - { - case 0: - coord += rand()%radius; - break; - case 1: - coord -= rand()%radius; - break; - } - return coord; - } - - void SetThreatList(Creature* Blossom) - { - if(!Blossom) return; - - std::list& m_threatlist = m_creature->getThreatManager().getThreatList(); - std::list::iterator i = m_threatlist.begin(); - for(i = m_threatlist.begin(); i != m_threatlist.end(); i++) - { - Unit* pUnit = Unit::GetUnit((*m_creature), (*i)->getUnitGuid()); - if(pUnit && pUnit->isAlive()) - { - float threat = m_creature->getThreatManager().getThreat(pUnit); - Blossom->AddThreat(pUnit, threat); - } - } - } - - void MindControlGhost() - { - /************************************************************************/ - /** NOTE FOR FUTURE DEVELOPER: PROPERLY IMPLEMENT THE GHOST PORTION *****/ - /** ONLY AFTER MaNGOS FULLY IMPLEMENTS MIND CONTROL ABILITIES *****/ - /** THE CURRENT CODE IN THIS FUNCTION IS ONLY THE BEGINNING OF *****/ - /** WHAT IS FULLY NECESSARY FOR GOREFIEND TO BE 100% COMPLETE *****/ - /************************************************************************/ - - Unit* Ghost = NULL; - if(GhostGUID) - Ghost = Unit::GetUnit((*m_creature), GhostGUID); - if(Ghost && Ghost->isAlive() && Ghost->HasAura(SPELL_SHADOW_OF_DEATH, 0)) - { - /*float x,y,z; - Ghost->GetPosition(x,y,z); - Creature* control = m_creature->SummonCreature(CREATURE_GHOST, x, y, z, 0, TEMPSUMMON_TIMED_DESAWN, 30000); - if(control) - { - ((Player*)Ghost)->Possess(control); - Ghost->DealDamage(Ghost, Ghost->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, - false); - }*/ - for(uint8 i = 0; i < 4; ++i) - { - Creature* Construct = NULL; - float X = CalculateRandomLocation(Ghost->GetPositionX(), 10); - float Y = CalculateRandomLocation(Ghost->GetPositionY(), 10); - Construct = m_creature->SummonCreature(CREATURE_SHADOWY_CONSTRUCT, X, Y, Ghost->GetPositionZ(), 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 45000); - if(Construct) - { - Construct->CastSpell(Construct, SPELL_PASSIVE_SHADOWFORM, true); - SetThreatList(Construct); // Use same function as Doom Blossom to set Threat List. - ((mob_shadowy_constructAI*)Construct->AI())->GhostGUID = GhostGUID; - Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 1); - if(!target) // someone's trying to solo. - target = m_creature->getVictim(); - - if(target) - Construct->GetMotionMaster()->MoveChase(target); - } - } - } - } - - void UpdateAI(const uint32 diff) - { - if(Intro) - { - if(AggroTimer < diff) - { - m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); - DoYell(SAY_AGGRO, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_AGGRO); - m_creature->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_STATE_NONE); - Intro = false; - if(AggroTargetGUID) - { - Unit* pUnit = Unit::GetUnit((*m_creature), AggroTargetGUID); - if(pUnit) - { - m_creature->GetMotionMaster()->MoveChase(pUnit); - AttackStart(pUnit); - } - DoZoneInCombat(); - }else EnterEvadeMode(); - - }else AggroTimer -= diff; - } - - if(!m_creature->SelectHostilTarget() || !m_creature->getVictim() || Intro) - return; - - if(SummonShadowsTimer < diff) - { - //MindControlGhost(); - - for(uint8 i = 0; i < 2; ++i) - { - Creature* Shadow = NULL; - float X = CalculateRandomLocation(m_creature->GetPositionX(), 10); - Shadow = m_creature->SummonCreature(CREATURE_SHADOWY_CONSTRUCT, X, m_creature->GetPositionY(), m_creature->GetPositionZ(), 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 0); - if(Shadow) - { - Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 1); - if(!target) - target = m_creature->getVictim(); - - if(target) - Shadow->AI()->AttackStart(target); - } - } - SummonShadowsTimer = 60000; - }else SummonShadowsTimer -= diff; - - if(SummonDoomBlossomTimer < diff) - { - Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0); - if(target) - { - float X = CalculateRandomLocation(target->GetPositionX(), 20); - float Y = CalculateRandomLocation(target->GetPositionY(), 20); - Creature* DoomBlossom = m_creature->SummonCreature(CREATURE_DOOM_BLOSSOM, X, Y, target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 20000); - if(DoomBlossom) - { - DoomBlossom->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - DoomBlossom->setFaction(m_creature->getFaction()); - DoomBlossom->AddThreat(target, 1.0f); - ((mob_doom_blossomAI*)DoomBlossom->AI())->SetTeronGUID(m_creature->GetGUID()); - ((mob_doom_blossomAI*)DoomBlossom->AI())->InCombat = true; - SetThreatList(DoomBlossom); - SummonDoomBlossomTimer = 35000; - } - } - }else SummonDoomBlossomTimer -= diff; - - if(IncinerateTimer < diff) - { - Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 1); - if(!target) - target = m_creature->getVictim(); - - if(target) - { - switch(rand()%2) - { - case 0: - DoYell(SAY_SPECIAL1,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature, SOUND_SPECIAL1); - break; - case 1: - DoYell(SAY_SPECIAL2,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature, SOUND_SPECIAL2); - break; - } - DoCast(target, SPELL_INCINERATE); - IncinerateTimer = 20000 + rand()%31 * 1000; - } - }else IncinerateTimer -= diff; - - if(CrushingShadowsTimer < diff) - { - Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0); - if(target && target->isAlive()) - DoCast(target, SPELL_CRUSHING_SHADOWS); - CrushingShadowsTimer = 10000 + rand()%16 * 1000; - }else CrushingShadowsTimer -= diff; - - /*** NOTE FOR FUTURE DEV: UNCOMMENT BELOW ONLY IF MIND CONTROL IS FULLY IMPLEMENTED **/ - /*if(ShadowOfDeathTimer < diff) - { - Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 1); - - if(!target) - target = m_creature->getVictim(); - - if(target && target->isAlive() && target->GetTypeId() == TYPEID_PLAYER) - { - DoCast(target, SPELL_SHADOW_OF_DEATH); - GhostGUID = target->GetGUID(); - ShadowOfDeathTimer = 30000; - SummonShadowsTimer = 53000; // Make it VERY close but slightly less so that we can check if the aura is still on the player - } - }else ShadowOfDeathTimer -= diff;*/ - - if(RandomYellTimer < diff) - { - switch(rand()%2) - { - case 0: - DoYell(SAY_SPELL1,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature, SOUND_SPELL1); - break; - case 1: - DoYell(SAY_SPELL2,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature, SOUND_SPELL2); - break; - } - RandomYellTimer = 50000 + rand()%51 * 1000; - }else RandomYellTimer -= diff; - - if(!m_creature->HasAura(SPELL_BERSERK, 0)) - if(EnrageTimer < diff) - { - DoCast(m_creature, SPELL_BERSERK); - DoYell(SAY_ENRAGE,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature, SOUND_ENRAGE); - }else EnrageTimer -= diff; - - DoMeleeAttackIfReady(); - } -}; - -CreatureAI* GetAI_mob_doom_blossom(Creature *_Creature) -{ - return new mob_doom_blossomAI(_Creature); -} - -CreatureAI* GetAI_mob_shadowy_construct(Creature *_Creature) -{ - return new mob_shadowy_constructAI(_Creature); -} - -CreatureAI* GetAI_boss_teron_gorefiend(Creature *_Creature) -{ - return new boss_teron_gorefiendAI (_Creature); -} - -void AddSC_boss_teron_gorefiend() -{ - Script *newscript; - newscript = new Script; - newscript->Name = "mob_doom_blossom"; - newscript->GetAI = GetAI_mob_doom_blossom; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name = "mob_shadowy_construct"; - newscript->GetAI = GetAI_mob_shadowy_construct; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="boss_teron_gorefiend"; - newscript->GetAI = GetAI_boss_teron_gorefiend; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Teron_Gorefiend +SD%Complete: 60 +SDComment: Requires Mind Control support for Ghosts. +SDCategory: Black Temple +EndScriptData */ + +#include "precompiled.h" +#include "def_black_temple.h" + +//Spells +#define SPELL_INCINERATE 40239 +#define SPELL_CRUSHING_SHADOWS 40243 +#define SPELL_SHADOWBOLT 40185 +#define SPELL_PASSIVE_SHADOWFORM 40326 +#define SPELL_SHADOW_OF_DEATH 40251 +#define SPELL_BERSERK 45078 + +#define SPELL_ATROPHY 40327 // Shadowy Constructs use this when they get within melee range of a player + +//Speech'n'sound +#define SAY_INTRO "I was the first, you know. For me, the wheel of death has spun many times. So much time has passed. I have a lot of catching up to do..." +#define SOUND_INTRO 11512 + +#define SAY_AGGRO "Vengeance is mine!" +#define SOUND_AGGRO 11513 + +#define SAY_SLAY1 "I have use for you!" +#define SOUND_SLAY1 11514 + +#define SAY_SLAY2 "It gets worse..." +#define SOUND_SLAY2 11515 + +#define SAY_SPELL1 "What are you afraid of?" +#define SOUND_SPELL1 11517 + +#define SAY_SPELL2 "Death... really isn't so bad." +#define SOUND_SPELL2 11516 + +#define SAY_SPECIAL1 "Give in!" +#define SOUND_SPECIAL1 11518 + +#define SAY_SPECIAL2 "I have something for you..." +#define SOUND_SPECIAL2 11519 + +#define SAY_ENRAGE "YOU WILL SHOW THE PROPER RESPECT!" +#define SOUND_ENRAGE 11520 + +#define SAY_DEATH "The wheel...spins...again...." +#define SOUND_DEATH 11521 + +#define CREATURE_DOOM_BLOSSOM 23123 +#define CREATURE_SHADOWY_CONSTRUCT 23111 + +struct MANGOS_DLL_DECL mob_doom_blossomAI : public ScriptedAI +{ + mob_doom_blossomAI(Creature *c) : ScriptedAI(c) + { + Reset(); + } + + uint32 CheckTeronTimer; + uint32 ShadowBoltTimer; + uint64 TeronGUID; + + void Reset() + { + CheckTeronTimer = 5000; + ShadowBoltTimer = 12000; + TeronGUID = 0; + } + + void Aggro(Unit *who) { } + void AttackStart(Unit* who) { } + void MoveInLineOfSight(Unit* who) { } + + void UpdateAI(const uint32 diff) + { + if(CheckTeronTimer < diff) + { + if(TeronGUID) + { + DoZoneInCombat(); + + Creature* Teron = ((Creature*)Unit::GetUnit((*m_creature), TeronGUID)); + if((Teron) && (!Teron->isAlive() || Teron->IsInEvadeMode())) + m_creature->DealDamage(m_creature, m_creature->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); + } + else + m_creature->DealDamage(m_creature, m_creature->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); + + CheckTeronTimer = 5000; + }else CheckTeronTimer -= diff; + + if(!m_creature->getVictim() || !m_creature->SelectHostilTarget()) + return; + + if(ShadowBoltTimer < diff) + { + DoCast(SelectUnit(SELECT_TARGET_RANDOM, 0), SPELL_SHADOWBOLT); + ShadowBoltTimer = 10000; + }else ShadowBoltTimer -= diff; + } + + void SetTeronGUID(uint64 guid){ TeronGUID = guid; } +}; + +//This is used to sort the players by distance for Constructs to see who to cast Atrophy on +struct TargetDistanceOrder : public std::binary_function +{ + const Unit* MainTarget; + TargetDistanceOrder(const Unit* Target) : MainTarget(Target) {}; + // functor for operator "<" + bool operator()(const Unit* _Left, const Unit* _Right) const + { + return (MainTarget->GetDistance(_Left) < MainTarget->GetDistance(_Right)); + } +}; + +struct MANGOS_DLL_DECL mob_shadowy_constructAI : public ScriptedAI +{ + mob_shadowy_constructAI(Creature* c) : ScriptedAI(c) + { + Reset(); + } + + uint64 GhostGUID; + uint64 TeronGUID; + + uint32 CheckPlayerTimer; + uint32 CheckTeronTimer; + + void Reset() + { + GhostGUID = 0; + TeronGUID = 0; + + CheckPlayerTimer = 2000; + CheckTeronTimer = 5000; + } + + void Aggro(Unit* who) { } + + void MoveInLineOfSight(Unit *who) + { + if(!who || (!who->isAlive()) || (who->GetGUID() == GhostGUID)) + return; + + if(who->isTargetableForAttack() && who->isInAccessablePlaceFor(m_creature) && m_creature->IsHostileTo(who)) + { + float attackRadius = m_creature->GetAttackDistance(who); + + if (m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->GetDistanceZ(who) <= CREATURE_Z_ATTACK_RANGE && m_creature->IsWithinLOSInMap(who)) + { + if(who->HasStealthAura()) + who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); + + m_creature->AddThreat(who, 1.0f); + } + } + } + +/* Comment it out for now. NOTE TO FUTURE DEV: UNCOMMENT THIS OUT ONLY AFTER MIND CONTROL IS IMPLEMENTED + void DamageTaken(Unit* done_by, uint32 &damage) + { + if(done_by->GetGUID() != GhostGUID) + damage = 0; // Only the ghost can deal damage. + } + */ + + void CheckPlayers() + { + std::list& m_threatlist = m_creature->getThreatManager().getThreatList(); + if(m_threatlist.empty()) + return; // No threat list. Don't continue. + std::list::iterator itr = m_threatlist.begin(); + std::list targets; + for( ; itr != m_threatlist.end(); ++itr) + { + Unit* pUnit = Unit::GetUnit((*m_creature), (*itr)->getUnitGuid()); + if(pUnit && pUnit->isAlive()) + targets.push_back(pUnit); + } + targets.sort(TargetDistanceOrder(m_creature)); + Unit* target = targets.front(); + if(target && m_creature->IsWithinDistInMap(target, m_creature->GetAttackDistance(target))) + { + DoCast(target, SPELL_ATROPHY); + m_creature->AI()->AttackStart(target); + } + } + + void UpdateAI(const uint32 diff) + { + if(CheckPlayerTimer < diff) + { + CheckPlayers(); + CheckPlayerTimer = 3000; + }else CheckPlayerTimer -= diff; + + if(CheckTeronTimer < diff) + { + Creature* Teron = ((Creature*)Unit::GetUnit((*m_creature), TeronGUID)); + if(!Teron || !Teron->isAlive() || Teron->IsInEvadeMode()) + m_creature->DealDamage(m_creature, m_creature->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); + + CheckTeronTimer = 5000; + }else CheckTeronTimer -= diff; + } +}; + +struct MANGOS_DLL_DECL boss_teron_gorefiendAI : public ScriptedAI +{ + boss_teron_gorefiendAI(Creature *c) : ScriptedAI(c) + { + pInstance = ((ScriptedInstance*)c->GetInstanceData()); + Reset(); + } + + ScriptedInstance* pInstance; + + uint32 IncinerateTimer; + uint32 SummonDoomBlossomTimer; + uint32 EnrageTimer; + uint32 CrushingShadowsTimer; + uint32 ShadowOfDeathTimer; + uint32 SummonShadowsTimer; + uint32 RandomYellTimer; + uint32 AggroTimer; + + uint64 AggroTargetGUID; + uint64 GhostGUID; // Player that gets killed by Shadow of Death and gets turned into a ghost + + bool Intro; + + void Reset() + { + if(pInstance) + pInstance->SetData(DATA_TERONGOREFIENDEVENT, NOT_STARTED); + + IncinerateTimer = 20000 + rand()%11000; + SummonDoomBlossomTimer = 12000; + EnrageTimer = 600000; + CrushingShadowsTimer = 22000; + SummonShadowsTimer = 60000; + RandomYellTimer = 50000; + + m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + // Start off unattackable so that the intro is done properly + m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + + AggroTimer = 20000; + AggroTargetGUID = 0; + Intro = false; + } + + void Aggro(Unit *who) {} + + void MoveInLineOfSight(Unit *who) + { + if(!who || (!who->isAlive())) return; + + if(who->isTargetableForAttack() && who->isInAccessablePlaceFor(m_creature) && m_creature->IsHostileTo(who)) + { + float attackRadius = m_creature->GetAttackDistance(who); + + if (m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->GetDistanceZ(who) <= CREATURE_Z_ATTACK_RANGE && m_creature->IsWithinLOSInMap(who)) + { + if(who->HasStealthAura()) + who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); + + m_creature->AddThreat(who, 1.0f); + } + + if(!InCombat && !Intro && m_creature->IsWithinDistInMap(who, 200.0f) && (who->GetTypeId() == TYPEID_PLAYER)) + { + if(pInstance) + pInstance->SetData(DATA_TERONGOREFIENDEVENT, IN_PROGRESS); + + m_creature->GetMotionMaster()->Clear(false); + m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + DoYell(SAY_INTRO,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature, SOUND_INTRO); + m_creature->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_STATE_TALK); + AggroTargetGUID = who->GetGUID(); + Intro = true; + } + } + } + + void KilledUnit(Unit *victim) + { + switch(rand()%2) + { + case 0: + DoYell(SAY_SLAY1,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature, SOUND_SLAY1); + break; + case 1: + DoYell(SAY_SLAY2,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature, SOUND_SLAY2); + break; + } + } + + void JustDied(Unit *victim) + { + if(pInstance) + pInstance->SetData(DATA_TERONGOREFIENDEVENT, DONE); + + DoYell(SAY_DEATH,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_DEATH); + } + + float CalculateRandomLocation(float Loc, uint32 radius) + { + float coord = Loc; + switch(rand()%2) + { + case 0: + coord += rand()%radius; + break; + case 1: + coord -= rand()%radius; + break; + } + return coord; + } + + void SetThreatList(Creature* Blossom) + { + if(!Blossom) return; + + std::list& m_threatlist = m_creature->getThreatManager().getThreatList(); + std::list::iterator i = m_threatlist.begin(); + for(i = m_threatlist.begin(); i != m_threatlist.end(); i++) + { + Unit* pUnit = Unit::GetUnit((*m_creature), (*i)->getUnitGuid()); + if(pUnit && pUnit->isAlive()) + { + float threat = m_creature->getThreatManager().getThreat(pUnit); + Blossom->AddThreat(pUnit, threat); + } + } + } + + void MindControlGhost() + { + /************************************************************************/ + /** NOTE FOR FUTURE DEVELOPER: PROPERLY IMPLEMENT THE GHOST PORTION *****/ + /** ONLY AFTER MaNGOS FULLY IMPLEMENTS MIND CONTROL ABILITIES *****/ + /** THE CURRENT CODE IN THIS FUNCTION IS ONLY THE BEGINNING OF *****/ + /** WHAT IS FULLY NECESSARY FOR GOREFIEND TO BE 100% COMPLETE *****/ + /************************************************************************/ + + Unit* Ghost = NULL; + if(GhostGUID) + Ghost = Unit::GetUnit((*m_creature), GhostGUID); + if(Ghost && Ghost->isAlive() && Ghost->HasAura(SPELL_SHADOW_OF_DEATH, 0)) + { + /*float x,y,z; + Ghost->GetPosition(x,y,z); + Creature* control = m_creature->SummonCreature(CREATURE_GHOST, x, y, z, 0, TEMPSUMMON_TIMED_DESAWN, 30000); + if(control) + { + ((Player*)Ghost)->Possess(control); + Ghost->DealDamage(Ghost, Ghost->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, + false); + }*/ + for(uint8 i = 0; i < 4; ++i) + { + Creature* Construct = NULL; + float X = CalculateRandomLocation(Ghost->GetPositionX(), 10); + float Y = CalculateRandomLocation(Ghost->GetPositionY(), 10); + Construct = m_creature->SummonCreature(CREATURE_SHADOWY_CONSTRUCT, X, Y, Ghost->GetPositionZ(), 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 45000); + if(Construct) + { + Construct->CastSpell(Construct, SPELL_PASSIVE_SHADOWFORM, true); + SetThreatList(Construct); // Use same function as Doom Blossom to set Threat List. + ((mob_shadowy_constructAI*)Construct->AI())->GhostGUID = GhostGUID; + Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 1); + if(!target) // someone's trying to solo. + target = m_creature->getVictim(); + + if(target) + Construct->GetMotionMaster()->MoveChase(target); + } + } + } + } + + void UpdateAI(const uint32 diff) + { + if(Intro) + { + if(AggroTimer < diff) + { + m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + DoYell(SAY_AGGRO, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_AGGRO); + m_creature->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_STATE_NONE); + Intro = false; + if(AggroTargetGUID) + { + Unit* pUnit = Unit::GetUnit((*m_creature), AggroTargetGUID); + if(pUnit) + { + m_creature->GetMotionMaster()->MoveChase(pUnit); + AttackStart(pUnit); + } + DoZoneInCombat(); + }else EnterEvadeMode(); + + }else AggroTimer -= diff; + } + + if(!m_creature->SelectHostilTarget() || !m_creature->getVictim() || Intro) + return; + + if(SummonShadowsTimer < diff) + { + //MindControlGhost(); + + for(uint8 i = 0; i < 2; ++i) + { + Creature* Shadow = NULL; + float X = CalculateRandomLocation(m_creature->GetPositionX(), 10); + Shadow = m_creature->SummonCreature(CREATURE_SHADOWY_CONSTRUCT, X, m_creature->GetPositionY(), m_creature->GetPositionZ(), 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 0); + if(Shadow) + { + Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 1); + if(!target) + target = m_creature->getVictim(); + + if(target) + Shadow->AI()->AttackStart(target); + } + } + SummonShadowsTimer = 60000; + }else SummonShadowsTimer -= diff; + + if(SummonDoomBlossomTimer < diff) + { + Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0); + if(target) + { + float X = CalculateRandomLocation(target->GetPositionX(), 20); + float Y = CalculateRandomLocation(target->GetPositionY(), 20); + Creature* DoomBlossom = m_creature->SummonCreature(CREATURE_DOOM_BLOSSOM, X, Y, target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 20000); + if(DoomBlossom) + { + DoomBlossom->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + DoomBlossom->setFaction(m_creature->getFaction()); + DoomBlossom->AddThreat(target, 1.0f); + ((mob_doom_blossomAI*)DoomBlossom->AI())->SetTeronGUID(m_creature->GetGUID()); + ((mob_doom_blossomAI*)DoomBlossom->AI())->InCombat = true; + SetThreatList(DoomBlossom); + SummonDoomBlossomTimer = 35000; + } + } + }else SummonDoomBlossomTimer -= diff; + + if(IncinerateTimer < diff) + { + Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 1); + if(!target) + target = m_creature->getVictim(); + + if(target) + { + switch(rand()%2) + { + case 0: + DoYell(SAY_SPECIAL1,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature, SOUND_SPECIAL1); + break; + case 1: + DoYell(SAY_SPECIAL2,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature, SOUND_SPECIAL2); + break; + } + DoCast(target, SPELL_INCINERATE); + IncinerateTimer = 20000 + rand()%31 * 1000; + } + }else IncinerateTimer -= diff; + + if(CrushingShadowsTimer < diff) + { + Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0); + if(target && target->isAlive()) + DoCast(target, SPELL_CRUSHING_SHADOWS); + CrushingShadowsTimer = 10000 + rand()%16 * 1000; + }else CrushingShadowsTimer -= diff; + + /*** NOTE FOR FUTURE DEV: UNCOMMENT BELOW ONLY IF MIND CONTROL IS FULLY IMPLEMENTED **/ + /*if(ShadowOfDeathTimer < diff) + { + Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 1); + + if(!target) + target = m_creature->getVictim(); + + if(target && target->isAlive() && target->GetTypeId() == TYPEID_PLAYER) + { + DoCast(target, SPELL_SHADOW_OF_DEATH); + GhostGUID = target->GetGUID(); + ShadowOfDeathTimer = 30000; + SummonShadowsTimer = 53000; // Make it VERY close but slightly less so that we can check if the aura is still on the player + } + }else ShadowOfDeathTimer -= diff;*/ + + if(RandomYellTimer < diff) + { + switch(rand()%2) + { + case 0: + DoYell(SAY_SPELL1,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature, SOUND_SPELL1); + break; + case 1: + DoYell(SAY_SPELL2,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature, SOUND_SPELL2); + break; + } + RandomYellTimer = 50000 + rand()%51 * 1000; + }else RandomYellTimer -= diff; + + if(!m_creature->HasAura(SPELL_BERSERK, 0)) + if(EnrageTimer < diff) + { + DoCast(m_creature, SPELL_BERSERK); + DoYell(SAY_ENRAGE,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature, SOUND_ENRAGE); + }else EnrageTimer -= diff; + + DoMeleeAttackIfReady(); + } +}; + +CreatureAI* GetAI_mob_doom_blossom(Creature *_Creature) +{ + return new mob_doom_blossomAI(_Creature); +} + +CreatureAI* GetAI_mob_shadowy_construct(Creature *_Creature) +{ + return new mob_shadowy_constructAI(_Creature); +} + +CreatureAI* GetAI_boss_teron_gorefiend(Creature *_Creature) +{ + return new boss_teron_gorefiendAI (_Creature); +} + +void AddSC_boss_teron_gorefiend() +{ + Script *newscript; + newscript = new Script; + newscript->Name = "mob_doom_blossom"; + newscript->GetAI = GetAI_mob_doom_blossom; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name = "mob_shadowy_construct"; + newscript->GetAI = GetAI_mob_shadowy_construct; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="boss_teron_gorefiend"; + newscript->GetAI = GetAI_boss_teron_gorefiend; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/black_temple/boss_warlord_najentus.cpp b/src/bindings/scripts/scripts/zone/black_temple/boss_warlord_najentus.cpp index 93d27c3d0d1..39d00f62cd1 100644 --- a/src/bindings/scripts/scripts/zone/black_temple/boss_warlord_najentus.cpp +++ b/src/bindings/scripts/scripts/zone/black_temple/boss_warlord_najentus.cpp @@ -1,435 +1,435 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Warlord_Najentus -SD%Complete: 90 -SDComment: Using a creature workaround instead of a GO for Impaling Spine. -SDCategory: Black Temple -EndScriptData */ - -#include "precompiled.h" -#include "def_black_temple.h" - -//Aggro -#define SAY_AGGRO "You will die, in the name of Lady Vashj!" -#define SOUND_AGGRO 11450 - -//Needle (Random) -#define SAY_NEEDLE1 "Stick around!" -#define SOUND_NEEDLE1 11451 - -#define SAY_NEEDLE2 "I'll deal with you later!" -#define SOUND_NEEDLE2 11452 - -//Slay -#define SAY_SLAY1 "Your success was short lived!" -#define SOUND_SLAY1 11455 - -#define SAY_SLAY2 "Time for you to go!" -#define SOUND_SLAY2 11456 - -//Special -#define SAY_SPECIAL1 "Bel'anen dal'lorei!" -#define SOUND_SPECIAL1 11453 - -#define SAY_SPECIAL2 "Blood will flow!" -#define SOUND_SPECIAL2 11454 - -//Enrage -#define SAY_ENRAGE "My patience has ran out! Die, DIE!" -#define SOUND_ENRAGE 11458 - -//Death -#define SAY_DEATH "Lord Illidan will... crush you." -#define SOUND_DEATH 11459 - -//Spells -#define SPELL_CRASHINGWAVE 40100 -#define SPELL_NEEDLE_SPINE 39835 -#define SPELL_NEEDLE_AOE 39968 -#define SPELL_TIDAL_BURST 39878 -#define SPELL_TIDAL_SHIELD 39872 // Not going to use this since Hurl Spine doesn't dispel it. -#define SPELL_IMPALING_SPINE 39837 -#define SPELL_CREATE_NAJENTUS_SPINE 39956 -#define SPELL_HURL_SPINE 39948 -#define SPELL_SHIELD_VISUAL 37136 -#define SPELL_BERSERK 45078 - -#define DISPLAYID_SPINE 7362 - -struct MANGOS_DLL_DECL mob_najentus_spineAI : public ScriptedAI -{ - mob_najentus_spineAI(Creature *c) : ScriptedAI(c) - { - Reset(); - } - - uint64 SpineVictimGUID; - - void Reset() { SpineVictimGUID = 0; } - - void SetSpineVictimGUID(uint64 guid){ SpineVictimGUID = guid; } - - void JustDied(Unit *killer) - { - // Make the killer have the Najentus Spine item to pierce Tidal Shield - if(killer) - killer->CastSpell(killer, SPELL_CREATE_NAJENTUS_SPINE, true); - } - - void DamageTaken(Unit *done_by, uint32 &damage) - { - if(damage < m_creature->GetHealth()) return; - - // Remove the Impaling Spine DoT from whoever was affected - if(SpineVictimGUID) - { - Unit* victim = Unit::GetUnit((*m_creature), SpineVictimGUID); - if(victim && ((victim->HasAura(SPELL_IMPALING_SPINE, 0)) || (victim->HasAura(SPELL_IMPALING_SPINE, 1)) || (victim->HasAura(SPELL_IMPALING_SPINE, 2)))) - victim->RemoveAurasDueToSpell(SPELL_IMPALING_SPINE); - } - } - - void Aggro(Unit* who) {} - void AttackStart(Unit* who) {} - void MoveInLineOfSight(Unit* who) {} - void UpdateAI(const uint32 diff) {} -}; - -struct MANGOS_DLL_DECL boss_najentusAI : public ScriptedAI -{ - boss_najentusAI(Creature *c) : ScriptedAI(c) - { - pInstance = ((ScriptedInstance*)c->GetInstanceData()); - Reset(); - } - - ScriptedInstance* pInstance; - uint32 CrashingWaveTimer; - uint32 NeedleSpineTimer; - uint32 EnrageTimer; - uint32 SpecialYellTimer; - uint32 TidalShieldTimer; - uint32 ImpalingSpineTimer; - uint32 CheckTimer; // This timer checks if Najentus is Tidal Shielded and if so, regens health. If not, sets IsShielded to false - uint32 DispelShieldTimer; // This shield is only supposed to last 30 seconds, but the SPELL_SHIELD_VISUAL lasts forever - - uint64 SpineTargetGUID; - uint64 SpineGUID; - - bool IsShielded; - - void Reset() - { - IsShielded = false; - - CrashingWaveTimer = 28000; - NeedleSpineTimer = 10000; - EnrageTimer = 480000; - SpecialYellTimer = 45000 + (rand()%76)*1000; - TidalShieldTimer = 60000; - ImpalingSpineTimer = 45000; - CheckTimer = 2000; - DispelShieldTimer = 30000; - - SpineTargetGUID = 0; - SpineGUID = 0; - - if(pInstance) - { - if(m_creature->isAlive()) - { - pInstance->SetData(DATA_HIGHWARLORDNAJENTUSEVENT, NOT_STARTED); - ToggleGate(true); - } - else ToggleGate(false); - } - } - - void KilledUnit(Unit *victim) - { - switch(rand()%2) - { - case 0: - DoYell(SAY_SLAY1,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature, SOUND_SLAY1); - break; - case 1: - DoYell(SAY_SLAY2,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature, SOUND_SLAY2); - break; - } - } - - void JustDied(Unit *victim) - { - if(pInstance) - { - pInstance->SetData(DATA_HIGHWARLORDNAJENTUSEVENT, DONE); - ToggleGate(false); - } - - DoYell(SAY_DEATH, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature,SOUND_DEATH); - } - - void ToggleGate(bool close) - { - if(GameObject* Gate = GameObject::GetGameObject(*m_creature, pInstance->GetData64(DATA_GAMEOBJECT_NAJENTUS_GATE))) - if(close) Gate->SetGoState(0); // Closed - else Gate->SetGoState(2); // Opened - } - - void SpellHit(Unit *caster, const SpellEntry *spell) - { - if(IsShielded) - { - if(spell->Id == SPELL_HURL_SPINE) - { - if(m_creature->HasAura(SPELL_SHIELD_VISUAL, 0)) - m_creature->RemoveAurasDueToSpell(SPELL_SHIELD_VISUAL); - if(m_creature->HasAura(SPELL_TIDAL_SHIELD, 0)) - m_creature->RemoveAurasDueToSpell(SPELL_TIDAL_SHIELD); - DoCast(m_creature->getVictim(), SPELL_TIDAL_BURST); - IsShielded = false; - } - } - } - - void DamageTaken(Unit *done_by, uint32 &damage) - { - if(IsShielded) - damage = 0; - } - - void Aggro(Unit *who) - { - if(pInstance) - pInstance->SetData(DATA_HIGHWARLORDNAJENTUSEVENT, IN_PROGRESS); - - DoYell(SAY_AGGRO, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_AGGRO); - - DoZoneInCombat(); - } - - // This is a workaround since we cannot summon GameObjects at will. - // Instead, we create a custom creature on top of the player. - // When someone kills the creature, the killer gets the "Naj'entus Spine" item. - // This item is the only item that should be able to pierce Tidal Shield - void DoImpalingSpineWorkaround(Unit* target) - { - Creature* Spine = NULL; - Spine = m_creature->SummonCreature(500000, target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0, TEMPSUMMON_DEAD_DESPAWN, 10000); - if(Spine) - { - Spine->setFaction(m_creature->getFaction()); - ((mob_najentus_spineAI*)Spine->AI())->SetSpineVictimGUID(target->GetGUID()); - SpineTargetGUID = target->GetGUID(); - } - } - - bool RemoveImpalingSpine(uint64 guid) - { - if(!IsShielded || guid == SpineTargetGUID) return false; - - if(SpineTargetGUID) - { - Unit* target = Unit::GetUnit((*m_creature), SpineTargetGUID); - if(target && target->HasAura(SPELL_IMPALING_SPINE, 0)) - { - target->RemoveAurasDueToSpell(SPELL_IMPALING_SPINE); - return true; - } - } - - return false; - } - - void UpdateAI(const uint32 diff) - { - //Return since we have no target - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - if(CheckTimer < diff) - { - // if(m_creature->HasAura(SPELL_TIDAL_SHIELD, 0)) - if(m_creature->HasAura(SPELL_SHIELD_VISUAL, 0)) - m_creature->SetHealth(m_creature->GetHealth() + (m_creature->GetMaxHealth()/100)); - else - IsShielded = false; - - CheckTimer = 2000; - }else CheckTimer -= diff; - - if(IsShielded) - { - m_creature->GetMotionMaster()->Clear(false); - m_creature->GetMotionMaster()->MoveIdle(); - if(!m_creature->HasAura(SPELL_SHIELD_VISUAL, 0)) - DoCast(m_creature, SPELL_SHIELD_VISUAL); - if(DispelShieldTimer < diff) - { - m_creature->GetMotionMaster()->MoveChase(m_creature->getVictim()); - if(m_creature->HasAura(SPELL_SHIELD_VISUAL, 0)) - m_creature->RemoveAurasDueToSpell(SPELL_SHIELD_VISUAL); - IsShielded = false; - }else DispelShieldTimer -= diff; - - return; // Don't cast or do anything while Shielded - } - - // Crashing Wave - if(CrashingWaveTimer < diff) - { - DoCast(m_creature->getVictim(), SPELL_CRASHINGWAVE); - CrashingWaveTimer = 28500; - }else CrashingWaveTimer -= diff; - - if(!m_creature->HasAura(SPELL_BERSERK, 0)) - if(EnrageTimer < diff) - { - DoYell(SAY_ENRAGE, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_ENRAGE); - DoCast(m_creature, SPELL_BERSERK); - }else EnrageTimer -= diff; - - // Needle - if(NeedleSpineTimer < diff) - { - for(uint8 i = 0; i < 3; ++i) - { - Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 1); - if(!target) - target = m_creature->getVictim(); - - DoCast(target, SPELL_NEEDLE_AOE, true); - DoCast(target, SPELL_NEEDLE_SPINE); - } - - NeedleSpineTimer = 60000; - }else NeedleSpineTimer -= diff; - - if(SpecialYellTimer < diff) - { - switch(rand()%2) - { - case 0: - DoPlaySoundToSet(m_creature, SOUND_SPECIAL1); - break; - case 1: - DoYell(SAY_SPECIAL2, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_SPECIAL2); - break; - } - SpecialYellTimer = 25000 + (rand()%76)*1000; - }else SpecialYellTimer -= diff; - - if(ImpalingSpineTimer < diff) - { - Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 1); - if(!target) - target = m_creature->getVictim(); - - if(target && (target->GetTypeId() == TYPEID_PLAYER)) - { - DoCast(target, SPELL_IMPALING_SPINE); - //DoImpalingSpineWorkaround(target); - SpineTargetGUID = target->GetGUID(); - ImpalingSpineTimer = 45000; - - switch(rand()%2) - { - case 0: - DoYell(SAY_NEEDLE1, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_NEEDLE1); - break; - case 1: - DoYell(SAY_NEEDLE2, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_NEEDLE2); - break; - } - } - }else ImpalingSpineTimer -= diff; - - if(TidalShieldTimer < diff) - { - m_creature->InterruptNonMeleeSpells(false); - DoCast(m_creature, SPELL_SHIELD_VISUAL, true); - // DoCast(m_creature, SPELL_TIDAL_SHIELD); - m_creature->GetMotionMaster()->Clear(false); - m_creature->GetMotionMaster()->MoveIdle(); - IsShielded = true; - TidalShieldTimer = 60000; - CheckTimer = 2000; - DispelShieldTimer = 30000; - }else TidalShieldTimer -= diff; - - DoMeleeAttackIfReady(); - } -}; - -bool GOHello_go_najentus_spine(Player *player, GameObject* _GO) -{ - ScriptedInstance* pInstance = ((ScriptedInstance*)_GO->GetInstanceData()); - if(pInstance) - { - uint64 NajentusGUID = pInstance->GetData64(DATA_HIGHWARLORDNAJENTUS); - if(NajentusGUID) - { - Creature* Najentus = ((Creature*)Unit::GetUnit((*_GO), NajentusGUID)); - if(Najentus) - { - if(((boss_najentusAI*)Najentus->AI())->RemoveImpalingSpine(player->GetGUID())) - return true; - }else error_log("ERROR: Na'entus Spine GameObject unable to find Naj'entus"); - }else error_log("ERROR: Invalid GUID acquired for Naj'entus by Naj'entus Spine GameObject"); - } - else error_log("ERROR: Naj'entus Spine spawned in invalid instance or location"); - - return true; -} - -CreatureAI* GetAI_mob_najentus_spine(Creature *_Creature) -{ - return new mob_najentus_spineAI (_Creature); -} - -CreatureAI* GetAI_boss_najentus(Creature *_Creature) -{ - return new boss_najentusAI (_Creature); -} - -void AddSC_boss_najentus() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_najentus"; - newscript->GetAI = GetAI_boss_najentus; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name = "mob_najentus_spine"; - newscript->GetAI = GetAI_mob_najentus_spine; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name = "go_najentus_spine"; - newscript->pGOHello = &GOHello_go_najentus_spine; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Warlord_Najentus +SD%Complete: 90 +SDComment: Using a creature workaround instead of a GO for Impaling Spine. +SDCategory: Black Temple +EndScriptData */ + +#include "precompiled.h" +#include "def_black_temple.h" + +//Aggro +#define SAY_AGGRO "You will die, in the name of Lady Vashj!" +#define SOUND_AGGRO 11450 + +//Needle (Random) +#define SAY_NEEDLE1 "Stick around!" +#define SOUND_NEEDLE1 11451 + +#define SAY_NEEDLE2 "I'll deal with you later!" +#define SOUND_NEEDLE2 11452 + +//Slay +#define SAY_SLAY1 "Your success was short lived!" +#define SOUND_SLAY1 11455 + +#define SAY_SLAY2 "Time for you to go!" +#define SOUND_SLAY2 11456 + +//Special +#define SAY_SPECIAL1 "Bel'anen dal'lorei!" +#define SOUND_SPECIAL1 11453 + +#define SAY_SPECIAL2 "Blood will flow!" +#define SOUND_SPECIAL2 11454 + +//Enrage +#define SAY_ENRAGE "My patience has ran out! Die, DIE!" +#define SOUND_ENRAGE 11458 + +//Death +#define SAY_DEATH "Lord Illidan will... crush you." +#define SOUND_DEATH 11459 + +//Spells +#define SPELL_CRASHINGWAVE 40100 +#define SPELL_NEEDLE_SPINE 39835 +#define SPELL_NEEDLE_AOE 39968 +#define SPELL_TIDAL_BURST 39878 +#define SPELL_TIDAL_SHIELD 39872 // Not going to use this since Hurl Spine doesn't dispel it. +#define SPELL_IMPALING_SPINE 39837 +#define SPELL_CREATE_NAJENTUS_SPINE 39956 +#define SPELL_HURL_SPINE 39948 +#define SPELL_SHIELD_VISUAL 37136 +#define SPELL_BERSERK 45078 + +#define DISPLAYID_SPINE 7362 + +struct MANGOS_DLL_DECL mob_najentus_spineAI : public ScriptedAI +{ + mob_najentus_spineAI(Creature *c) : ScriptedAI(c) + { + Reset(); + } + + uint64 SpineVictimGUID; + + void Reset() { SpineVictimGUID = 0; } + + void SetSpineVictimGUID(uint64 guid){ SpineVictimGUID = guid; } + + void JustDied(Unit *killer) + { + // Make the killer have the Najentus Spine item to pierce Tidal Shield + if(killer) + killer->CastSpell(killer, SPELL_CREATE_NAJENTUS_SPINE, true); + } + + void DamageTaken(Unit *done_by, uint32 &damage) + { + if(damage < m_creature->GetHealth()) return; + + // Remove the Impaling Spine DoT from whoever was affected + if(SpineVictimGUID) + { + Unit* victim = Unit::GetUnit((*m_creature), SpineVictimGUID); + if(victim && ((victim->HasAura(SPELL_IMPALING_SPINE, 0)) || (victim->HasAura(SPELL_IMPALING_SPINE, 1)) || (victim->HasAura(SPELL_IMPALING_SPINE, 2)))) + victim->RemoveAurasDueToSpell(SPELL_IMPALING_SPINE); + } + } + + void Aggro(Unit* who) {} + void AttackStart(Unit* who) {} + void MoveInLineOfSight(Unit* who) {} + void UpdateAI(const uint32 diff) {} +}; + +struct MANGOS_DLL_DECL boss_najentusAI : public ScriptedAI +{ + boss_najentusAI(Creature *c) : ScriptedAI(c) + { + pInstance = ((ScriptedInstance*)c->GetInstanceData()); + Reset(); + } + + ScriptedInstance* pInstance; + uint32 CrashingWaveTimer; + uint32 NeedleSpineTimer; + uint32 EnrageTimer; + uint32 SpecialYellTimer; + uint32 TidalShieldTimer; + uint32 ImpalingSpineTimer; + uint32 CheckTimer; // This timer checks if Najentus is Tidal Shielded and if so, regens health. If not, sets IsShielded to false + uint32 DispelShieldTimer; // This shield is only supposed to last 30 seconds, but the SPELL_SHIELD_VISUAL lasts forever + + uint64 SpineTargetGUID; + uint64 SpineGUID; + + bool IsShielded; + + void Reset() + { + IsShielded = false; + + CrashingWaveTimer = 28000; + NeedleSpineTimer = 10000; + EnrageTimer = 480000; + SpecialYellTimer = 45000 + (rand()%76)*1000; + TidalShieldTimer = 60000; + ImpalingSpineTimer = 45000; + CheckTimer = 2000; + DispelShieldTimer = 30000; + + SpineTargetGUID = 0; + SpineGUID = 0; + + if(pInstance) + { + if(m_creature->isAlive()) + { + pInstance->SetData(DATA_HIGHWARLORDNAJENTUSEVENT, NOT_STARTED); + ToggleGate(true); + } + else ToggleGate(false); + } + } + + void KilledUnit(Unit *victim) + { + switch(rand()%2) + { + case 0: + DoYell(SAY_SLAY1,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature, SOUND_SLAY1); + break; + case 1: + DoYell(SAY_SLAY2,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature, SOUND_SLAY2); + break; + } + } + + void JustDied(Unit *victim) + { + if(pInstance) + { + pInstance->SetData(DATA_HIGHWARLORDNAJENTUSEVENT, DONE); + ToggleGate(false); + } + + DoYell(SAY_DEATH, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature,SOUND_DEATH); + } + + void ToggleGate(bool close) + { + if(GameObject* Gate = GameObject::GetGameObject(*m_creature, pInstance->GetData64(DATA_GAMEOBJECT_NAJENTUS_GATE))) + if(close) Gate->SetGoState(0); // Closed + else Gate->SetGoState(2); // Opened + } + + void SpellHit(Unit *caster, const SpellEntry *spell) + { + if(IsShielded) + { + if(spell->Id == SPELL_HURL_SPINE) + { + if(m_creature->HasAura(SPELL_SHIELD_VISUAL, 0)) + m_creature->RemoveAurasDueToSpell(SPELL_SHIELD_VISUAL); + if(m_creature->HasAura(SPELL_TIDAL_SHIELD, 0)) + m_creature->RemoveAurasDueToSpell(SPELL_TIDAL_SHIELD); + DoCast(m_creature->getVictim(), SPELL_TIDAL_BURST); + IsShielded = false; + } + } + } + + void DamageTaken(Unit *done_by, uint32 &damage) + { + if(IsShielded) + damage = 0; + } + + void Aggro(Unit *who) + { + if(pInstance) + pInstance->SetData(DATA_HIGHWARLORDNAJENTUSEVENT, IN_PROGRESS); + + DoYell(SAY_AGGRO, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_AGGRO); + + DoZoneInCombat(); + } + + // This is a workaround since we cannot summon GameObjects at will. + // Instead, we create a custom creature on top of the player. + // When someone kills the creature, the killer gets the "Naj'entus Spine" item. + // This item is the only item that should be able to pierce Tidal Shield + void DoImpalingSpineWorkaround(Unit* target) + { + Creature* Spine = NULL; + Spine = m_creature->SummonCreature(500000, target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0, TEMPSUMMON_DEAD_DESPAWN, 10000); + if(Spine) + { + Spine->setFaction(m_creature->getFaction()); + ((mob_najentus_spineAI*)Spine->AI())->SetSpineVictimGUID(target->GetGUID()); + SpineTargetGUID = target->GetGUID(); + } + } + + bool RemoveImpalingSpine(uint64 guid) + { + if(!IsShielded || guid == SpineTargetGUID) return false; + + if(SpineTargetGUID) + { + Unit* target = Unit::GetUnit((*m_creature), SpineTargetGUID); + if(target && target->HasAura(SPELL_IMPALING_SPINE, 0)) + { + target->RemoveAurasDueToSpell(SPELL_IMPALING_SPINE); + return true; + } + } + + return false; + } + + void UpdateAI(const uint32 diff) + { + //Return since we have no target + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + if(CheckTimer < diff) + { + // if(m_creature->HasAura(SPELL_TIDAL_SHIELD, 0)) + if(m_creature->HasAura(SPELL_SHIELD_VISUAL, 0)) + m_creature->SetHealth(m_creature->GetHealth() + (m_creature->GetMaxHealth()/100)); + else + IsShielded = false; + + CheckTimer = 2000; + }else CheckTimer -= diff; + + if(IsShielded) + { + m_creature->GetMotionMaster()->Clear(false); + m_creature->GetMotionMaster()->MoveIdle(); + if(!m_creature->HasAura(SPELL_SHIELD_VISUAL, 0)) + DoCast(m_creature, SPELL_SHIELD_VISUAL); + if(DispelShieldTimer < diff) + { + m_creature->GetMotionMaster()->MoveChase(m_creature->getVictim()); + if(m_creature->HasAura(SPELL_SHIELD_VISUAL, 0)) + m_creature->RemoveAurasDueToSpell(SPELL_SHIELD_VISUAL); + IsShielded = false; + }else DispelShieldTimer -= diff; + + return; // Don't cast or do anything while Shielded + } + + // Crashing Wave + if(CrashingWaveTimer < diff) + { + DoCast(m_creature->getVictim(), SPELL_CRASHINGWAVE); + CrashingWaveTimer = 28500; + }else CrashingWaveTimer -= diff; + + if(!m_creature->HasAura(SPELL_BERSERK, 0)) + if(EnrageTimer < diff) + { + DoYell(SAY_ENRAGE, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_ENRAGE); + DoCast(m_creature, SPELL_BERSERK); + }else EnrageTimer -= diff; + + // Needle + if(NeedleSpineTimer < diff) + { + for(uint8 i = 0; i < 3; ++i) + { + Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 1); + if(!target) + target = m_creature->getVictim(); + + DoCast(target, SPELL_NEEDLE_AOE, true); + DoCast(target, SPELL_NEEDLE_SPINE); + } + + NeedleSpineTimer = 60000; + }else NeedleSpineTimer -= diff; + + if(SpecialYellTimer < diff) + { + switch(rand()%2) + { + case 0: + DoPlaySoundToSet(m_creature, SOUND_SPECIAL1); + break; + case 1: + DoYell(SAY_SPECIAL2, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_SPECIAL2); + break; + } + SpecialYellTimer = 25000 + (rand()%76)*1000; + }else SpecialYellTimer -= diff; + + if(ImpalingSpineTimer < diff) + { + Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 1); + if(!target) + target = m_creature->getVictim(); + + if(target && (target->GetTypeId() == TYPEID_PLAYER)) + { + DoCast(target, SPELL_IMPALING_SPINE); + //DoImpalingSpineWorkaround(target); + SpineTargetGUID = target->GetGUID(); + ImpalingSpineTimer = 45000; + + switch(rand()%2) + { + case 0: + DoYell(SAY_NEEDLE1, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_NEEDLE1); + break; + case 1: + DoYell(SAY_NEEDLE2, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_NEEDLE2); + break; + } + } + }else ImpalingSpineTimer -= diff; + + if(TidalShieldTimer < diff) + { + m_creature->InterruptNonMeleeSpells(false); + DoCast(m_creature, SPELL_SHIELD_VISUAL, true); + // DoCast(m_creature, SPELL_TIDAL_SHIELD); + m_creature->GetMotionMaster()->Clear(false); + m_creature->GetMotionMaster()->MoveIdle(); + IsShielded = true; + TidalShieldTimer = 60000; + CheckTimer = 2000; + DispelShieldTimer = 30000; + }else TidalShieldTimer -= diff; + + DoMeleeAttackIfReady(); + } +}; + +bool GOHello_go_najentus_spine(Player *player, GameObject* _GO) +{ + ScriptedInstance* pInstance = ((ScriptedInstance*)_GO->GetInstanceData()); + if(pInstance) + { + uint64 NajentusGUID = pInstance->GetData64(DATA_HIGHWARLORDNAJENTUS); + if(NajentusGUID) + { + Creature* Najentus = ((Creature*)Unit::GetUnit((*_GO), NajentusGUID)); + if(Najentus) + { + if(((boss_najentusAI*)Najentus->AI())->RemoveImpalingSpine(player->GetGUID())) + return true; + }else error_log("ERROR: Na'entus Spine GameObject unable to find Naj'entus"); + }else error_log("ERROR: Invalid GUID acquired for Naj'entus by Naj'entus Spine GameObject"); + } + else error_log("ERROR: Naj'entus Spine spawned in invalid instance or location"); + + return true; +} + +CreatureAI* GetAI_mob_najentus_spine(Creature *_Creature) +{ + return new mob_najentus_spineAI (_Creature); +} + +CreatureAI* GetAI_boss_najentus(Creature *_Creature) +{ + return new boss_najentusAI (_Creature); +} + +void AddSC_boss_najentus() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_najentus"; + newscript->GetAI = GetAI_boss_najentus; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name = "mob_najentus_spine"; + newscript->GetAI = GetAI_mob_najentus_spine; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name = "go_najentus_spine"; + newscript->pGOHello = &GOHello_go_najentus_spine; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/black_temple/def_black_temple.h b/src/bindings/scripts/scripts/zone/black_temple/def_black_temple.h index 53e099f7835..3b48c6f7755 100644 --- a/src/bindings/scripts/scripts/zone/black_temple/def_black_temple.h +++ b/src/bindings/scripts/scripts/zone/black_temple/def_black_temple.h @@ -1,34 +1,34 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software licensed under GPL version 2 - * Please see the included DOCS/LICENSE.TXT for more information */ - -#ifndef DEF_BLACK_TEMPLE_H -#define DEF_BLACK_TEMPLE_H - -#define DATA_AKAMA 1 -#define DATA_AKAMA_SHADE 2 -#define DATA_GURTOGGBLOODBOILEVENT 3 -#define DATA_HIGHWARLORDNAJENTUS 4 -#define DATA_HIGHWARLORDNAJENTUSEVENT 5 -#define DATA_ILLIDANSTORMRAGE 6 -#define DATA_ILLIDANSTORMRAGEEVENT 7 -#define DATA_ILLIDARICOUNCILEVENT 8 -#define DATA_ILLIDARICOUNCIL 9 -#define DATA_LADYMALANDE 10 -#define DATA_HIGHNETHERMANCERZEREVOR 11 -#define DATA_GATHIOSTHESHATTERER 12 -#define DATA_VERASDARKSHADOW 13 -#define DATA_MOTHERSHAHRAZEVENT 14 -#define DATA_RELIQUARYOFSOULSEVENT 15 -#define DATA_SHADEOFAKAMA 16 -#define DATA_SHADEOFAKAMAEVENT 17 -#define DATA_SUPREMUS 18 -#define DATA_SUPREMUSEVENT 19 -#define DATA_TERONGOREFIENDEVENT 20 -#define DATA_GAMEOBJECT_NAJENTUS_GATE 21 -#define DATA_GAMEOBJECT_ILLIDAN_GATE 22 -#define DATA_GAMEOBJECT_ILLIDAN_DOOR_R 23 -#define DATA_GAMEOBJECT_ILLIDAN_DOOR_L 24 -#define DATA_GAMEOBJECT_SUPREMUS_DOORS 25 -#define DATA_BLOOD_ELF_COUNCIL_VOICE 26 -#endif +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software licensed under GPL version 2 + * Please see the included DOCS/LICENSE.TXT for more information */ + +#ifndef DEF_BLACK_TEMPLE_H +#define DEF_BLACK_TEMPLE_H + +#define DATA_AKAMA 1 +#define DATA_AKAMA_SHADE 2 +#define DATA_GURTOGGBLOODBOILEVENT 3 +#define DATA_HIGHWARLORDNAJENTUS 4 +#define DATA_HIGHWARLORDNAJENTUSEVENT 5 +#define DATA_ILLIDANSTORMRAGE 6 +#define DATA_ILLIDANSTORMRAGEEVENT 7 +#define DATA_ILLIDARICOUNCILEVENT 8 +#define DATA_ILLIDARICOUNCIL 9 +#define DATA_LADYMALANDE 10 +#define DATA_HIGHNETHERMANCERZEREVOR 11 +#define DATA_GATHIOSTHESHATTERER 12 +#define DATA_VERASDARKSHADOW 13 +#define DATA_MOTHERSHAHRAZEVENT 14 +#define DATA_RELIQUARYOFSOULSEVENT 15 +#define DATA_SHADEOFAKAMA 16 +#define DATA_SHADEOFAKAMAEVENT 17 +#define DATA_SUPREMUS 18 +#define DATA_SUPREMUSEVENT 19 +#define DATA_TERONGOREFIENDEVENT 20 +#define DATA_GAMEOBJECT_NAJENTUS_GATE 21 +#define DATA_GAMEOBJECT_ILLIDAN_GATE 22 +#define DATA_GAMEOBJECT_ILLIDAN_DOOR_R 23 +#define DATA_GAMEOBJECT_ILLIDAN_DOOR_L 24 +#define DATA_GAMEOBJECT_SUPREMUS_DOORS 25 +#define DATA_BLOOD_ELF_COUNCIL_VOICE 26 +#endif diff --git a/src/bindings/scripts/scripts/zone/black_temple/illidari_council.cpp b/src/bindings/scripts/scripts/zone/black_temple/illidari_council.cpp index 4169f1d764f..e080b5c4c61 100644 --- a/src/bindings/scripts/scripts/zone/black_temple/illidari_council.cpp +++ b/src/bindings/scripts/scripts/zone/black_temple/illidari_council.cpp @@ -1,885 +1,885 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Illidari_Council -SD%Complete: 95 -SDComment: Circle of Healing not working properly. -SDCategory: Black Temple -EndScriptData */ - -#include "precompiled.h" -#include "def_black_temple.h" - -// High Nethermancer Zerevor's spells -#define SPELL_FLAMESTRIKE 41481 -#define SPELL_BLIZZARD 41482 -#define SPELL_ARCANE_BOLT 41483 -#define SPELL_ARCANE_EXPLOSION 41524 -#define SPELL_DAMPEN_MAGIC 41478 - -// Lady Malande's spells -#define SPELL_EMPOWERED_SMITE 41471 -#define SPELL_CIRCLE_OF_HEALING 41455 -#define SPELL_REFLECTIVE_SHIELD 41475 -#define SPELL_DIVINE_WRATH 41472 -#define SPELL_HEAL_VISUAL 24171 - -// Gathios the Shatterer's spells -#define SPELL_BLESS_PROTECTION 41450 -#define SPELL_BLESS_SPELLWARD 41451 -#define SPELL_CONSECRATION 41541 -#define SPELL_HAMMER_OF_JUSTICE 41468 -#define SPELL_SEAL_OF_COMMAND 41469 -#define SPELL_SEAL_OF_BLOOD 41459 -#define SPELL_CHROMATIC_AURA 41453 -#define SPELL_DEVOTION_AURA 41452 - -// Veras Darkshadow's spells -#define SPELL_DEADLY_POISON 41485 -#define SPELL_ENVENOM 41487 -#define SPELL_VANISH 41479 - -#define SPELL_BERSERK 45078 - -//Speech'n'Sounds -#define SAY_GATH_AGGRO "I have better things to do!" -#define SOUND_GATH_AGGRO 11422 -#define SAY_GATH_SLAY "Selama am'oronor!" -#define SOUND_GATH_SLAY 11423 -#define SAY_GATH_COMNT "Well done!" -#define SOUND_GATH_COMNT 11424 -#define SAY_GATH_DEATH "Lord Illidan... I..." -#define SOUND_GATH_DEATH 11425 -#define SAY_GATH_SPECIAL1 "Enjoy your final moments!" -#define SOUND_GATH_SPECIAL1 11426 -#define SAY_GATH_SPECIAL2 "You are mine!" -#define SOUND_GATH_SPECIAL2 11427 - -#define SAY_MALA_AGGRO "Flee, or die!" -#define SOUND_MALA_AGGRO 11482 -#define SAY_MALA_SLAY "My work is done." -#define SOUND_MALA_SLAY 11483 -#define SAY_MALA_COMNT "As it should be!" -#define SOUND_MALA_COMNT 11484 -#define SAY_MALA_DEATH "Destiny... awaits." -#define SOUND_MALA_DEATH 11485 -#define SAY_MALA_SPECIAL1 "No second chances!" -#define SOUND_MALA_SPECIAL1 11486 -#define SAY_MALA_SPECIAL2 "I'm full of surprises!" -#define SOUND_MALA_SPECIAL2 11487 - -#define SAY_ZERE_AGGRO "Common... such a crude language. Bandal!" -#define SOUND_ZERE_AGGRO 11440 -#define SAY_ZERE_SLAY "Shorel'aran." -#define SOUND_ZERE_SLAY 11441 -#define SAY_ZERE_COMNT "Belesa menoor!" -#define SOUND_ZERE_COMNT 11442 -#define SAY_ZERE_DEATH "Diel ma'ahn... oreindel'o" -#define SOUND_ZERE_DEATH 11443 -#define SAY_ZERE_SPECIAL1 "Diel fin'al" -#define SOUND_ZERE_SPECIAL1 11444 -#define SAY_ZERE_SPECIAL2 "Sha'amoor ara mashal?" -#define SOUND_ZERE_SPECIAL2 11445 - -#define SAY_VERA_AGGRO "You wish to test me?" -#define SOUND_VERA_AGGRO 11524 -#define SAY_VERA_SLAY "Valiant effort!" -#define SOUND_VERA_SLAY 11525 -#define SAY_VERA_COMNT "A glorious kill!" -#define SOUND_VERA_COMNT 11526 -#define SAY_VERA_DEATH "You got lucky!" -#define SOUND_VERA_DEATH 11527 -#define SAY_VERA_SPECIAL1 "You're not caught up for this!" -#define SOUND_VERA_SPECIAL1 11528 -#define SAY_VERA_SPECIAL2 "Anar'alah belore!" -#define SOUND_VERA_SPECIAL2 11529 - -#define ERROR_INST_DATA "SD2 ERROR: Instance Data for Black Temple not set properly; Illidari Council event will not function properly." - -struct CouncilYells -{ - char* text; - uint32 soundId, timer; -}; - -static CouncilYells CouncilAggro[]= -{ - {"I have better things to do!", 11422, 5000}, // Gathios - {"You wish to test me?", 11524, 5500}, // Veras - {"Flee, or die!", 11482, 5000}, // Malande - {"Common... such a crude language. Bandal!", 11440, 0}, // Zerevor -}; - -// Need to get proper timers for this later -static CouncilYells CouncilEnrage[]= -{ - {"Enough games!", 11428, 2000}, // Gathios - {"You wish to kill me? Hahaha, you first!", 11530, 6000},//Veras - {"For Quel'Thalas! For the Sunwell!", 11488, 5000}, // Malande - {"Sha'amoor sine menoor!", 11446, 0}, // Zerevor -}; - -struct MANGOS_DLL_DECL mob_blood_elf_council_voice_triggerAI : public ScriptedAI -{ - mob_blood_elf_council_voice_triggerAI(Creature* c) : ScriptedAI(c) - { - for(uint8 i = 0; i < 4; ++i) - Council[i] = 0; - Reset(); - } - - uint64 Council[4]; - - uint32 EnrageTimer; - uint32 AggroYellTimer; - - uint8 YellCounter; // Serves as the counter for both the aggro and enrage yells - - bool EventStarted; - - void Reset() - { - EnrageTimer = 900000; // 15 minutes - AggroYellTimer = 500; - - YellCounter = 0; - - EventStarted = false; - } - - // finds and stores the GUIDs for each Council member using instance data system. - void LoadCouncilGUIDs() - { - if(ScriptedInstance* pInstance = ((ScriptedInstance*)m_creature->GetInstanceData())) - { - Council[0] = pInstance->GetData64(DATA_GATHIOSTHESHATTERER); - Council[1] = pInstance->GetData64(DATA_VERASDARKSHADOW); - Council[2] = pInstance->GetData64(DATA_LADYMALANDE); - Council[3] = pInstance->GetData64(DATA_HIGHNETHERMANCERZEREVOR); - } - else error_log(ERROR_INST_DATA); - } - - void Aggro(Unit* who) {} - - void AttackStart(Unit* who) {} - void MoveInLineOfSight(Unit* who) {} - - void UpdateAI(const uint32 diff) - { - if(!EventStarted) - return; - - if(YellCounter > 3) - return; - - if(AggroYellTimer) - if(AggroYellTimer <= diff) - { - if(Unit* pMember = Unit::GetUnit(*m_creature, Council[YellCounter])) - { - pMember->MonsterYell(CouncilAggro[YellCounter].text, LANG_UNIVERSAL, 0); - DoPlaySoundToSet(pMember, CouncilAggro[YellCounter].soundId); - AggroYellTimer = CouncilAggro[YellCounter].timer; - } - ++YellCounter; - if(YellCounter > 3) - YellCounter = 0; // Reuse for Enrage Yells - }else AggroYellTimer -= diff; - - if(EnrageTimer) - if(EnrageTimer <= diff) - { - if(Unit* pMember = Unit::GetUnit(*m_creature, Council[YellCounter])) - { - pMember->CastSpell(pMember, SPELL_BERSERK, true); - pMember->MonsterYell(CouncilEnrage[YellCounter].text, LANG_UNIVERSAL, 0); - DoPlaySoundToSet(pMember, CouncilEnrage[YellCounter].soundId); - EnrageTimer = CouncilEnrage[YellCounter].timer; - } - ++YellCounter; - }else EnrageTimer -= diff; - } -}; - -struct MANGOS_DLL_DECL mob_illidari_councilAI : public ScriptedAI -{ - mob_illidari_councilAI(Creature *c) : ScriptedAI(c) - { - pInstance = ((ScriptedInstance*)c->GetInstanceData()); - for(uint8 i = 0; i < 4; ++i) - Council[i] = 0; - - Reset(); - } - - ScriptedInstance* pInstance; - - uint64 Council[4]; - - uint32 CheckTimer; - uint32 EndEventTimer; - - uint8 DeathCount; - - bool EventBegun; - - void Reset() - { - CheckTimer = 2000; - EndEventTimer = 0; - - DeathCount = 0; - - Creature* pMember = NULL; - for(uint8 i = 0; i < 4; ++i) - { - if(pMember = ((Creature*)Unit::GetUnit((*m_creature), Council[i]))) - { - if(!pMember->isAlive()) - { - pMember->RemoveCorpse(); - pMember->Respawn(); - } - pMember->AI()->EnterEvadeMode(); - } - } - - if(pInstance) - { - pInstance->SetData(DATA_ILLIDARICOUNCILEVENT, NOT_STARTED); - if(Creature* VoiceTrigger = ((Creature*)Unit::GetUnit(*m_creature, pInstance->GetData64(DATA_BLOOD_ELF_COUNCIL_VOICE)))) - VoiceTrigger->AI()->EnterEvadeMode(); - } - - EventBegun = false; - - m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - m_creature->SetUInt32Value(UNIT_FIELD_DISPLAYID, 11686); - } - - void Aggro(Unit *who) {} - void AttackStart(Unit* who) {} - void MoveInLineOfSight(Unit* who) {} - - void StartEvent(Unit *target) - { - if(!pInstance) return; - - if(target && target->isAlive()) - { - Council[0] = pInstance->GetData64(DATA_GATHIOSTHESHATTERER); - Council[1] = pInstance->GetData64(DATA_HIGHNETHERMANCERZEREVOR); - Council[2] = pInstance->GetData64(DATA_LADYMALANDE); - Council[3] = pInstance->GetData64(DATA_VERASDARKSHADOW); - - // Start the event for the Voice Trigger - if(Creature* VoiceTrigger = ((Creature*)Unit::GetUnit(*m_creature, pInstance->GetData64(DATA_BLOOD_ELF_COUNCIL_VOICE)))) - { - ((mob_blood_elf_council_voice_triggerAI*)VoiceTrigger->AI())->LoadCouncilGUIDs(); - ((mob_blood_elf_council_voice_triggerAI*)VoiceTrigger->AI())->EventStarted = true; - } - - for(uint8 i = 0; i < 4; ++i) - { - Unit* Member = NULL; - if(Council[i]) - { - Member = Unit::GetUnit((*m_creature), Council[i]); - if(Member && Member->isAlive()) - Member->AddThreat(target, 1.0f); - } - } - - pInstance->SetData(DATA_ILLIDARICOUNCILEVENT, IN_PROGRESS); - - EventBegun = true; - } - } - - void UpdateAI(const uint32 diff) - { - if(!EventBegun) return; - - if(EndEventTimer) - if(EndEventTimer <= diff) - { - if(DeathCount > 3) - { - if(pInstance) - { - if(Creature* VoiceTrigger = ((Creature*)Unit::GetUnit(*m_creature, pInstance->GetData64(DATA_BLOOD_ELF_COUNCIL_VOICE)))) - VoiceTrigger->DealDamage(VoiceTrigger, VoiceTrigger->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); - pInstance->SetData(DATA_ILLIDARICOUNCILEVENT, DONE); - } - m_creature->DealDamage(m_creature, m_creature->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); - return; - } - - Creature* pMember = ((Creature*)Unit::GetUnit(*m_creature, Council[DeathCount])); - if(pMember && pMember->isAlive()) - pMember->DealDamage(pMember, pMember->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); - ++DeathCount; - EndEventTimer = 1500; - }else EndEventTimer -= diff; - - if(CheckTimer) - if(CheckTimer <= diff) - { - uint8 EvadeCheck = 0; - for(uint8 i = 0; i < 4; ++i) - { - if(Council[i]) - { - if(Creature* Member = ((Creature*)Unit::GetUnit((*m_creature), Council[i]))) - { - // This is the evade/death check. - if(Member->isAlive() && !Member->SelectHostilTarget()) - ++EvadeCheck; //If all members evade, we reset so that players can properly reset the event - else if(!Member->isAlive()) // If even one member dies, kill the rest, set instance data, and kill self. - { - EndEventTimer = 1000; - CheckTimer = 0; - return; - } - } - } - } - - if(EvadeCheck > 3) - Reset(); - - CheckTimer = 2000; - }else CheckTimer -= diff; - - } -}; - -struct MANGOS_DLL_DECL boss_illidari_councilAI : public ScriptedAI -{ - boss_illidari_councilAI(Creature* c) : ScriptedAI(c) - { - pInstance = ((ScriptedInstance*)c->GetInstanceData()); - for(uint8 i = 0; i < 4; ++i) - Council[i] = 0; - LoadedGUIDs = false; - } - - uint64 Council[4]; - - ScriptedInstance* pInstance; - - bool LoadedGUIDs; - - void Aggro(Unit* who) - { - if(pInstance) - { - Creature* Controller = ((Creature*)Unit::GetUnit(*m_creature, pInstance->GetData64(DATA_ILLIDARICOUNCIL))); - if(Controller) - ((mob_illidari_councilAI*)Controller->AI())->StartEvent(who); - } - else - { - error_log(ERROR_INST_DATA); - EnterEvadeMode(); - } - DoZoneInCombat(); - // Load GUIDs on first aggro because the creature guids are only set as the creatures are created in world- - // this means that for each creature, it will attempt to LoadGUIDs even though some of the other creatures are - // not in world, and thus have no GUID set in the instance data system. Putting it in aggro ensures that all the creatures - // have been loaded and have their GUIDs set in the instance data system. - if(!LoadedGUIDs) - LoadGUIDs(); - } - - void DamageTaken(Unit* done_by, uint32 &damage) - { - if(done_by == m_creature) - return; - - damage /= 4; - for(uint8 i = 0; i < 4; ++i) - { - if(Unit* pUnit = Unit::GetUnit(*m_creature, Council[i])) - if(pUnit != m_creature && damage < pUnit->GetHealth()) - pUnit->SetHealth(pUnit->GetHealth() - damage); - } - } - - void LoadGUIDs() - { - if(!pInstance) - { - error_log(ERROR_INST_DATA); - return; - } - - Council[0] = pInstance->GetData64(DATA_LADYMALANDE); - Council[1] = pInstance->GetData64(DATA_HIGHNETHERMANCERZEREVOR); - Council[2] = pInstance->GetData64(DATA_GATHIOSTHESHATTERER); - Council[3] = pInstance->GetData64(DATA_VERASDARKSHADOW); - - LoadedGUIDs = true; - } -}; - -struct MANGOS_DLL_DECL boss_gathios_the_shattererAI : public boss_illidari_councilAI -{ - boss_gathios_the_shattererAI(Creature *c) : boss_illidari_councilAI(c) { Reset(); } - - uint32 ConsecrationTimer; - uint32 HammerOfJusticeTimer; - uint32 SealTimer; - uint32 AuraTimer; - uint32 BlessingTimer; - - void Reset() - { - ConsecrationTimer = 40000; - HammerOfJusticeTimer = 10000; - SealTimer = 40000; - AuraTimer = 90000; - BlessingTimer = 60000; - } - - void KilledUnit(Unit *victim) - { - DoYell(SAY_GATH_SLAY,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature, SOUND_GATH_SLAY); - } - - void JustDied(Unit *victim) - { - DoYell(SAY_GATH_DEATH, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature,SOUND_GATH_DEATH); - } - - Unit* SelectCouncilMember() - { - Unit* pUnit = m_creature; - uint32 member = 0; // He chooses Lady Malande most often - - if(rand()%10 == 0) // But there is a chance he picks someone else. - member = urand(1, 3); - - if(member != 2) // No need to create another pointer to us using Unit::GetUnit - pUnit = Unit::GetUnit((*m_creature), Council[member]); - return pUnit; - } - - void CastAuraOnCouncil() - { - uint32 spellid = 0; - switch(rand()%2) - { - case 0: spellid = SPELL_DEVOTION_AURA; break; - case 1: spellid = SPELL_CHROMATIC_AURA; break; - } - for(uint8 i = 0; i < 4; ++i) - { - Unit* pUnit = Unit::GetUnit((*m_creature), Council[i]); - if(pUnit) - pUnit->CastSpell(pUnit, spellid, true, 0, 0, m_creature->GetGUID()); - } - } - - void UpdateAI(const uint32 diff) - { - if(!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - if(BlessingTimer < diff) - { - if(Unit* pUnit = SelectCouncilMember()) - { - switch(rand()%2) - { - case 0: DoCast(pUnit, SPELL_BLESS_SPELLWARD); break; - case 1: DoCast(pUnit, SPELL_BLESS_PROTECTION); break; - } - } - BlessingTimer = 60000; - }else BlessingTimer -= diff; - - if(ConsecrationTimer < diff) - { - DoCast(m_creature, SPELL_CONSECRATION); - ConsecrationTimer = 40000; - }else ConsecrationTimer -= diff; - - if(HammerOfJusticeTimer < diff) - { - if(Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0)) - { - // is in ~10-40 yd range - if(m_creature->GetDistance2d(target) > 10 && m_creature->GetDistance2d(target) < 40) - { - DoCast(target, SPELL_HAMMER_OF_JUSTICE); - HammerOfJusticeTimer = 20000; - } - } - }else HammerOfJusticeTimer -= diff; - - if(SealTimer < diff) - { - switch(rand()%2) - { - case 0: DoCast(m_creature, SPELL_SEAL_OF_COMMAND); break; - case 1: DoCast(m_creature, SPELL_SEAL_OF_BLOOD); break; - } - SealTimer = 40000; - }else SealTimer -= diff; - - if(AuraTimer < diff) - { - CastAuraOnCouncil(); - AuraTimer = 90000; - }else AuraTimer -= diff; - - DoMeleeAttackIfReady(); - } -}; - -struct MANGOS_DLL_DECL boss_high_nethermancer_zerevorAI : public boss_illidari_councilAI -{ - boss_high_nethermancer_zerevorAI(Creature *c) : boss_illidari_councilAI(c) { Reset(); } - - uint32 BlizzardTimer; - uint32 FlamestrikeTimer; - uint32 ArcaneBoltTimer; - uint32 DampenMagicTimer; - uint32 Cooldown; - uint32 ArcaneExplosionTimer; - - void Reset() - { - BlizzardTimer = 30000 + rand()%61 * 1000; - FlamestrikeTimer = 30000 + rand()%61 * 1000; - ArcaneBoltTimer = 10000; - DampenMagicTimer = 2000; - ArcaneExplosionTimer = 14000; - Cooldown = 0; - } - - void KilledUnit(Unit *victim) - { - DoYell(SAY_ZERE_SLAY,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature, SOUND_ZERE_SLAY); - } - - void JustDied(Unit *victim) - { - DoYell(SAY_ZERE_DEATH, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature,SOUND_ZERE_DEATH); - } - - void UpdateAI(const uint32 diff) - { - if(!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - if(Cooldown) - { - if(Cooldown < diff) Cooldown = 0; - else - { - Cooldown -= diff; - return; // Don't cast any other spells if global cooldown is still ticking - } - } - - if(DampenMagicTimer < diff) - { - DoCast(m_creature, SPELL_DAMPEN_MAGIC); - Cooldown = 1000; - DampenMagicTimer = 110000; // almost 2 minutes - ArcaneBoltTimer += 1000; // Give the Mage some time to spellsteal Dampen. - }else DampenMagicTimer -= diff; - - if(ArcaneExplosionTimer < diff) - { - DoCast(m_creature->getVictim(), SPELL_ARCANE_EXPLOSION); - Cooldown = 1000; - ArcaneExplosionTimer = 14000; - }else ArcaneExplosionTimer -= diff; - - if(ArcaneBoltTimer < diff) - { - DoCast(m_creature->getVictim(), SPELL_ARCANE_BOLT); - ArcaneBoltTimer = 3000; - Cooldown = 2000; - }else ArcaneBoltTimer -= diff; - - if(BlizzardTimer < diff) - { - if(Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0)) - { - DoCast(target, SPELL_BLIZZARD); - BlizzardTimer = 45000 + rand()%46 * 1000; - FlamestrikeTimer += 10000; - Cooldown = 1000; - } - }else BlizzardTimer -= diff; - - if(FlamestrikeTimer < diff) - { - if(Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0)) - { - DoCast(target, SPELL_FLAMESTRIKE); - FlamestrikeTimer = 55000 + rand()%46 * 1000; - BlizzardTimer += 10000; - Cooldown = 2000; - } - }else FlamestrikeTimer -= diff; - } -}; - -struct MANGOS_DLL_DECL boss_lady_malandeAI : public boss_illidari_councilAI -{ - boss_lady_malandeAI(Creature *c) : boss_illidari_councilAI(c) { Reset(); } - - uint32 EmpoweredSmiteTimer; - uint32 CircleOfHealingTimer; - uint32 DivineWrathTimer; - uint32 ReflectiveShieldTimer; - - void Reset() - { - EmpoweredSmiteTimer = 38000; - CircleOfHealingTimer = 20000; - DivineWrathTimer = 40000; - ReflectiveShieldTimer = 0; - } - - void KilledUnit(Unit *victim) - { - DoYell(SAY_MALA_SLAY,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature, SOUND_MALA_SLAY); - } - - void JustDied(Unit *victim) - { - DoYell(SAY_MALA_DEATH, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature,SOUND_MALA_DEATH); - } - - void UpdateAI(const uint32 diff) - { - if(!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - if(EmpoweredSmiteTimer < diff) - { - if(Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0)) - { - DoCast(target, SPELL_EMPOWERED_SMITE); - EmpoweredSmiteTimer = 38000; - } - }else EmpoweredSmiteTimer -= diff; - - if(CircleOfHealingTimer < diff) - { - //Currently bugged and puts Malande on the threatlist of the other council members. It also heals players. - //DoCast(m_creature, SPELL_CIRCLE_OF_HEALING); - CircleOfHealingTimer = 60000; - }else CircleOfHealingTimer -= diff; - - if(DivineWrathTimer < diff) - { - if(Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0)) - { - DoCast(target, SPELL_DIVINE_WRATH); - DivineWrathTimer = 40000 + rand()%41 * 1000; - } - }else DivineWrathTimer -= diff; - - if(ReflectiveShieldTimer < diff) - { - DoCast(m_creature, SPELL_REFLECTIVE_SHIELD); - ReflectiveShieldTimer = 65000; - }else ReflectiveShieldTimer -= diff; - - DoMeleeAttackIfReady(); - } -}; - -struct MANGOS_DLL_DECL boss_veras_darkshadowAI : public boss_illidari_councilAI -{ - boss_veras_darkshadowAI(Creature *c) : boss_illidari_councilAI(c) { Reset(); } - - uint64 EnvenomTargetGUID; - - uint32 DeadlyPoisonTimer; - uint32 VanishTimer; - uint32 AppearEnvenomTimer; - - bool HasVanished; - - void Reset() - { - EnvenomTargetGUID = 0; - - DeadlyPoisonTimer = 20000; - VanishTimer = 60000 + rand()%61 * 1000; - AppearEnvenomTimer = 150000; - - HasVanished = false; - m_creature->SetVisibility(VISIBILITY_ON); - m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - } - - void KilledUnit(Unit *victim) - { - DoYell(SAY_VERA_SLAY,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature, SOUND_VERA_SLAY); - } - - void JustDied(Unit *victim) - { - DoYell(SAY_VERA_DEATH, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature,SOUND_VERA_DEATH); - } - - void UpdateAI(const uint32 diff) - { - if(!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - if(!HasVanished) - { - if(DeadlyPoisonTimer < diff) - { - DoCast(m_creature->getVictim(), SPELL_DEADLY_POISON); - DeadlyPoisonTimer = 15000 + rand()%31 * 1000; - }else DeadlyPoisonTimer -= diff; - - if(AppearEnvenomTimer < diff) // Cast Envenom. This is cast 4 seconds after Vanish is over - { - DoCast(m_creature->getVictim(), SPELL_ENVENOM); - AppearEnvenomTimer = 90000; - }else AppearEnvenomTimer -= diff; - - if(VanishTimer < diff) // Disappear and stop attacking, but follow a random unit - { - if(Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0)) - { - VanishTimer = 30000; - AppearEnvenomTimer= 28000; - HasVanished = true; - m_creature->SetVisibility(VISIBILITY_OFF); - m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - DoResetThreat(); - // Chase a unit. Check before DoMeleeAttackIfReady prevents from attacking - m_creature->AddThreat(target, 500000.0f); - m_creature->GetMotionMaster()->MoveChase(target); - } - }else VanishTimer -= diff; - - DoMeleeAttackIfReady(); - } - else - { - if(VanishTimer < diff) // Become attackable and poison current target - { - Unit* target = m_creature->getVictim(); - DoCast(target, SPELL_DEADLY_POISON); - m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - DoResetThreat(); - m_creature->AddThreat(target, 3000.0f); // Make Veras attack his target for a while, he will cast Envenom 4 seconds after. - DeadlyPoisonTimer += 6000; - VanishTimer = 90000; - AppearEnvenomTimer = 4000; - HasVanished = false; - }else VanishTimer -= diff; - - if(AppearEnvenomTimer < diff) // Appear 2 seconds before becoming attackable (Shifting out of vanish) - { - m_creature->GetMotionMaster()->Clear(); - m_creature->GetMotionMaster()->MoveChase(m_creature->getVictim()); - m_creature->SetVisibility(VISIBILITY_ON); - AppearEnvenomTimer = 6000; - }else AppearEnvenomTimer -= diff; - } - } -}; - -CreatureAI* GetAI_mob_blood_elf_council_voice_trigger(Creature* c) -{ - return new mob_blood_elf_council_voice_triggerAI(c); -} - -CreatureAI* GetAI_mob_illidari_council(Creature *_Creature) -{ - return new mob_illidari_councilAI (_Creature); -} - -CreatureAI* GetAI_boss_gathios_the_shatterer(Creature *_Creature) -{ - return new boss_gathios_the_shattererAI (_Creature); -} - -CreatureAI* GetAI_boss_lady_malande(Creature *_Creature) -{ - return new boss_lady_malandeAI (_Creature); -} - -CreatureAI* GetAI_boss_veras_darkshadow(Creature *_Creature) -{ - return new boss_veras_darkshadowAI (_Creature); -} - -CreatureAI* GetAI_boss_high_nethermancer_zerevor(Creature *_Creature) -{ - return new boss_high_nethermancer_zerevorAI (_Creature); -} - -void AddSC_boss_illidari_council() -{ - Script *newscript; - - newscript = new Script; - newscript->Name="mob_illidari_council"; - newscript->GetAI = GetAI_mob_illidari_council; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name = "mob_blood_elf_council_voice_trigger"; - newscript->GetAI = GetAI_mob_blood_elf_council_voice_trigger; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="boss_gathios_the_shatterer"; - newscript->GetAI = GetAI_boss_gathios_the_shatterer; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="boss_lady_malande"; - newscript->GetAI = GetAI_boss_lady_malande; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="boss_veras_darkshadow"; - newscript->GetAI = GetAI_boss_veras_darkshadow; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="boss_high_nethermancer_zerevor"; - newscript->GetAI = GetAI_boss_high_nethermancer_zerevor; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Illidari_Council +SD%Complete: 95 +SDComment: Circle of Healing not working properly. +SDCategory: Black Temple +EndScriptData */ + +#include "precompiled.h" +#include "def_black_temple.h" + +// High Nethermancer Zerevor's spells +#define SPELL_FLAMESTRIKE 41481 +#define SPELL_BLIZZARD 41482 +#define SPELL_ARCANE_BOLT 41483 +#define SPELL_ARCANE_EXPLOSION 41524 +#define SPELL_DAMPEN_MAGIC 41478 + +// Lady Malande's spells +#define SPELL_EMPOWERED_SMITE 41471 +#define SPELL_CIRCLE_OF_HEALING 41455 +#define SPELL_REFLECTIVE_SHIELD 41475 +#define SPELL_DIVINE_WRATH 41472 +#define SPELL_HEAL_VISUAL 24171 + +// Gathios the Shatterer's spells +#define SPELL_BLESS_PROTECTION 41450 +#define SPELL_BLESS_SPELLWARD 41451 +#define SPELL_CONSECRATION 41541 +#define SPELL_HAMMER_OF_JUSTICE 41468 +#define SPELL_SEAL_OF_COMMAND 41469 +#define SPELL_SEAL_OF_BLOOD 41459 +#define SPELL_CHROMATIC_AURA 41453 +#define SPELL_DEVOTION_AURA 41452 + +// Veras Darkshadow's spells +#define SPELL_DEADLY_POISON 41485 +#define SPELL_ENVENOM 41487 +#define SPELL_VANISH 41479 + +#define SPELL_BERSERK 45078 + +//Speech'n'Sounds +#define SAY_GATH_AGGRO "I have better things to do!" +#define SOUND_GATH_AGGRO 11422 +#define SAY_GATH_SLAY "Selama am'oronor!" +#define SOUND_GATH_SLAY 11423 +#define SAY_GATH_COMNT "Well done!" +#define SOUND_GATH_COMNT 11424 +#define SAY_GATH_DEATH "Lord Illidan... I..." +#define SOUND_GATH_DEATH 11425 +#define SAY_GATH_SPECIAL1 "Enjoy your final moments!" +#define SOUND_GATH_SPECIAL1 11426 +#define SAY_GATH_SPECIAL2 "You are mine!" +#define SOUND_GATH_SPECIAL2 11427 + +#define SAY_MALA_AGGRO "Flee, or die!" +#define SOUND_MALA_AGGRO 11482 +#define SAY_MALA_SLAY "My work is done." +#define SOUND_MALA_SLAY 11483 +#define SAY_MALA_COMNT "As it should be!" +#define SOUND_MALA_COMNT 11484 +#define SAY_MALA_DEATH "Destiny... awaits." +#define SOUND_MALA_DEATH 11485 +#define SAY_MALA_SPECIAL1 "No second chances!" +#define SOUND_MALA_SPECIAL1 11486 +#define SAY_MALA_SPECIAL2 "I'm full of surprises!" +#define SOUND_MALA_SPECIAL2 11487 + +#define SAY_ZERE_AGGRO "Common... such a crude language. Bandal!" +#define SOUND_ZERE_AGGRO 11440 +#define SAY_ZERE_SLAY "Shorel'aran." +#define SOUND_ZERE_SLAY 11441 +#define SAY_ZERE_COMNT "Belesa menoor!" +#define SOUND_ZERE_COMNT 11442 +#define SAY_ZERE_DEATH "Diel ma'ahn... oreindel'o" +#define SOUND_ZERE_DEATH 11443 +#define SAY_ZERE_SPECIAL1 "Diel fin'al" +#define SOUND_ZERE_SPECIAL1 11444 +#define SAY_ZERE_SPECIAL2 "Sha'amoor ara mashal?" +#define SOUND_ZERE_SPECIAL2 11445 + +#define SAY_VERA_AGGRO "You wish to test me?" +#define SOUND_VERA_AGGRO 11524 +#define SAY_VERA_SLAY "Valiant effort!" +#define SOUND_VERA_SLAY 11525 +#define SAY_VERA_COMNT "A glorious kill!" +#define SOUND_VERA_COMNT 11526 +#define SAY_VERA_DEATH "You got lucky!" +#define SOUND_VERA_DEATH 11527 +#define SAY_VERA_SPECIAL1 "You're not caught up for this!" +#define SOUND_VERA_SPECIAL1 11528 +#define SAY_VERA_SPECIAL2 "Anar'alah belore!" +#define SOUND_VERA_SPECIAL2 11529 + +#define ERROR_INST_DATA "SD2 ERROR: Instance Data for Black Temple not set properly; Illidari Council event will not function properly." + +struct CouncilYells +{ + char* text; + uint32 soundId, timer; +}; + +static CouncilYells CouncilAggro[]= +{ + {"I have better things to do!", 11422, 5000}, // Gathios + {"You wish to test me?", 11524, 5500}, // Veras + {"Flee, or die!", 11482, 5000}, // Malande + {"Common... such a crude language. Bandal!", 11440, 0}, // Zerevor +}; + +// Need to get proper timers for this later +static CouncilYells CouncilEnrage[]= +{ + {"Enough games!", 11428, 2000}, // Gathios + {"You wish to kill me? Hahaha, you first!", 11530, 6000},//Veras + {"For Quel'Thalas! For the Sunwell!", 11488, 5000}, // Malande + {"Sha'amoor sine menoor!", 11446, 0}, // Zerevor +}; + +struct MANGOS_DLL_DECL mob_blood_elf_council_voice_triggerAI : public ScriptedAI +{ + mob_blood_elf_council_voice_triggerAI(Creature* c) : ScriptedAI(c) + { + for(uint8 i = 0; i < 4; ++i) + Council[i] = 0; + Reset(); + } + + uint64 Council[4]; + + uint32 EnrageTimer; + uint32 AggroYellTimer; + + uint8 YellCounter; // Serves as the counter for both the aggro and enrage yells + + bool EventStarted; + + void Reset() + { + EnrageTimer = 900000; // 15 minutes + AggroYellTimer = 500; + + YellCounter = 0; + + EventStarted = false; + } + + // finds and stores the GUIDs for each Council member using instance data system. + void LoadCouncilGUIDs() + { + if(ScriptedInstance* pInstance = ((ScriptedInstance*)m_creature->GetInstanceData())) + { + Council[0] = pInstance->GetData64(DATA_GATHIOSTHESHATTERER); + Council[1] = pInstance->GetData64(DATA_VERASDARKSHADOW); + Council[2] = pInstance->GetData64(DATA_LADYMALANDE); + Council[3] = pInstance->GetData64(DATA_HIGHNETHERMANCERZEREVOR); + } + else error_log(ERROR_INST_DATA); + } + + void Aggro(Unit* who) {} + + void AttackStart(Unit* who) {} + void MoveInLineOfSight(Unit* who) {} + + void UpdateAI(const uint32 diff) + { + if(!EventStarted) + return; + + if(YellCounter > 3) + return; + + if(AggroYellTimer) + if(AggroYellTimer <= diff) + { + if(Unit* pMember = Unit::GetUnit(*m_creature, Council[YellCounter])) + { + pMember->MonsterYell(CouncilAggro[YellCounter].text, LANG_UNIVERSAL, 0); + DoPlaySoundToSet(pMember, CouncilAggro[YellCounter].soundId); + AggroYellTimer = CouncilAggro[YellCounter].timer; + } + ++YellCounter; + if(YellCounter > 3) + YellCounter = 0; // Reuse for Enrage Yells + }else AggroYellTimer -= diff; + + if(EnrageTimer) + if(EnrageTimer <= diff) + { + if(Unit* pMember = Unit::GetUnit(*m_creature, Council[YellCounter])) + { + pMember->CastSpell(pMember, SPELL_BERSERK, true); + pMember->MonsterYell(CouncilEnrage[YellCounter].text, LANG_UNIVERSAL, 0); + DoPlaySoundToSet(pMember, CouncilEnrage[YellCounter].soundId); + EnrageTimer = CouncilEnrage[YellCounter].timer; + } + ++YellCounter; + }else EnrageTimer -= diff; + } +}; + +struct MANGOS_DLL_DECL mob_illidari_councilAI : public ScriptedAI +{ + mob_illidari_councilAI(Creature *c) : ScriptedAI(c) + { + pInstance = ((ScriptedInstance*)c->GetInstanceData()); + for(uint8 i = 0; i < 4; ++i) + Council[i] = 0; + + Reset(); + } + + ScriptedInstance* pInstance; + + uint64 Council[4]; + + uint32 CheckTimer; + uint32 EndEventTimer; + + uint8 DeathCount; + + bool EventBegun; + + void Reset() + { + CheckTimer = 2000; + EndEventTimer = 0; + + DeathCount = 0; + + Creature* pMember = NULL; + for(uint8 i = 0; i < 4; ++i) + { + if(pMember = ((Creature*)Unit::GetUnit((*m_creature), Council[i]))) + { + if(!pMember->isAlive()) + { + pMember->RemoveCorpse(); + pMember->Respawn(); + } + pMember->AI()->EnterEvadeMode(); + } + } + + if(pInstance) + { + pInstance->SetData(DATA_ILLIDARICOUNCILEVENT, NOT_STARTED); + if(Creature* VoiceTrigger = ((Creature*)Unit::GetUnit(*m_creature, pInstance->GetData64(DATA_BLOOD_ELF_COUNCIL_VOICE)))) + VoiceTrigger->AI()->EnterEvadeMode(); + } + + EventBegun = false; + + m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + m_creature->SetUInt32Value(UNIT_FIELD_DISPLAYID, 11686); + } + + void Aggro(Unit *who) {} + void AttackStart(Unit* who) {} + void MoveInLineOfSight(Unit* who) {} + + void StartEvent(Unit *target) + { + if(!pInstance) return; + + if(target && target->isAlive()) + { + Council[0] = pInstance->GetData64(DATA_GATHIOSTHESHATTERER); + Council[1] = pInstance->GetData64(DATA_HIGHNETHERMANCERZEREVOR); + Council[2] = pInstance->GetData64(DATA_LADYMALANDE); + Council[3] = pInstance->GetData64(DATA_VERASDARKSHADOW); + + // Start the event for the Voice Trigger + if(Creature* VoiceTrigger = ((Creature*)Unit::GetUnit(*m_creature, pInstance->GetData64(DATA_BLOOD_ELF_COUNCIL_VOICE)))) + { + ((mob_blood_elf_council_voice_triggerAI*)VoiceTrigger->AI())->LoadCouncilGUIDs(); + ((mob_blood_elf_council_voice_triggerAI*)VoiceTrigger->AI())->EventStarted = true; + } + + for(uint8 i = 0; i < 4; ++i) + { + Unit* Member = NULL; + if(Council[i]) + { + Member = Unit::GetUnit((*m_creature), Council[i]); + if(Member && Member->isAlive()) + Member->AddThreat(target, 1.0f); + } + } + + pInstance->SetData(DATA_ILLIDARICOUNCILEVENT, IN_PROGRESS); + + EventBegun = true; + } + } + + void UpdateAI(const uint32 diff) + { + if(!EventBegun) return; + + if(EndEventTimer) + if(EndEventTimer <= diff) + { + if(DeathCount > 3) + { + if(pInstance) + { + if(Creature* VoiceTrigger = ((Creature*)Unit::GetUnit(*m_creature, pInstance->GetData64(DATA_BLOOD_ELF_COUNCIL_VOICE)))) + VoiceTrigger->DealDamage(VoiceTrigger, VoiceTrigger->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); + pInstance->SetData(DATA_ILLIDARICOUNCILEVENT, DONE); + } + m_creature->DealDamage(m_creature, m_creature->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); + return; + } + + Creature* pMember = ((Creature*)Unit::GetUnit(*m_creature, Council[DeathCount])); + if(pMember && pMember->isAlive()) + pMember->DealDamage(pMember, pMember->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); + ++DeathCount; + EndEventTimer = 1500; + }else EndEventTimer -= diff; + + if(CheckTimer) + if(CheckTimer <= diff) + { + uint8 EvadeCheck = 0; + for(uint8 i = 0; i < 4; ++i) + { + if(Council[i]) + { + if(Creature* Member = ((Creature*)Unit::GetUnit((*m_creature), Council[i]))) + { + // This is the evade/death check. + if(Member->isAlive() && !Member->SelectHostilTarget()) + ++EvadeCheck; //If all members evade, we reset so that players can properly reset the event + else if(!Member->isAlive()) // If even one member dies, kill the rest, set instance data, and kill self. + { + EndEventTimer = 1000; + CheckTimer = 0; + return; + } + } + } + } + + if(EvadeCheck > 3) + Reset(); + + CheckTimer = 2000; + }else CheckTimer -= diff; + + } +}; + +struct MANGOS_DLL_DECL boss_illidari_councilAI : public ScriptedAI +{ + boss_illidari_councilAI(Creature* c) : ScriptedAI(c) + { + pInstance = ((ScriptedInstance*)c->GetInstanceData()); + for(uint8 i = 0; i < 4; ++i) + Council[i] = 0; + LoadedGUIDs = false; + } + + uint64 Council[4]; + + ScriptedInstance* pInstance; + + bool LoadedGUIDs; + + void Aggro(Unit* who) + { + if(pInstance) + { + Creature* Controller = ((Creature*)Unit::GetUnit(*m_creature, pInstance->GetData64(DATA_ILLIDARICOUNCIL))); + if(Controller) + ((mob_illidari_councilAI*)Controller->AI())->StartEvent(who); + } + else + { + error_log(ERROR_INST_DATA); + EnterEvadeMode(); + } + DoZoneInCombat(); + // Load GUIDs on first aggro because the creature guids are only set as the creatures are created in world- + // this means that for each creature, it will attempt to LoadGUIDs even though some of the other creatures are + // not in world, and thus have no GUID set in the instance data system. Putting it in aggro ensures that all the creatures + // have been loaded and have their GUIDs set in the instance data system. + if(!LoadedGUIDs) + LoadGUIDs(); + } + + void DamageTaken(Unit* done_by, uint32 &damage) + { + if(done_by == m_creature) + return; + + damage /= 4; + for(uint8 i = 0; i < 4; ++i) + { + if(Unit* pUnit = Unit::GetUnit(*m_creature, Council[i])) + if(pUnit != m_creature && damage < pUnit->GetHealth()) + pUnit->SetHealth(pUnit->GetHealth() - damage); + } + } + + void LoadGUIDs() + { + if(!pInstance) + { + error_log(ERROR_INST_DATA); + return; + } + + Council[0] = pInstance->GetData64(DATA_LADYMALANDE); + Council[1] = pInstance->GetData64(DATA_HIGHNETHERMANCERZEREVOR); + Council[2] = pInstance->GetData64(DATA_GATHIOSTHESHATTERER); + Council[3] = pInstance->GetData64(DATA_VERASDARKSHADOW); + + LoadedGUIDs = true; + } +}; + +struct MANGOS_DLL_DECL boss_gathios_the_shattererAI : public boss_illidari_councilAI +{ + boss_gathios_the_shattererAI(Creature *c) : boss_illidari_councilAI(c) { Reset(); } + + uint32 ConsecrationTimer; + uint32 HammerOfJusticeTimer; + uint32 SealTimer; + uint32 AuraTimer; + uint32 BlessingTimer; + + void Reset() + { + ConsecrationTimer = 40000; + HammerOfJusticeTimer = 10000; + SealTimer = 40000; + AuraTimer = 90000; + BlessingTimer = 60000; + } + + void KilledUnit(Unit *victim) + { + DoYell(SAY_GATH_SLAY,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature, SOUND_GATH_SLAY); + } + + void JustDied(Unit *victim) + { + DoYell(SAY_GATH_DEATH, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature,SOUND_GATH_DEATH); + } + + Unit* SelectCouncilMember() + { + Unit* pUnit = m_creature; + uint32 member = 0; // He chooses Lady Malande most often + + if(rand()%10 == 0) // But there is a chance he picks someone else. + member = urand(1, 3); + + if(member != 2) // No need to create another pointer to us using Unit::GetUnit + pUnit = Unit::GetUnit((*m_creature), Council[member]); + return pUnit; + } + + void CastAuraOnCouncil() + { + uint32 spellid = 0; + switch(rand()%2) + { + case 0: spellid = SPELL_DEVOTION_AURA; break; + case 1: spellid = SPELL_CHROMATIC_AURA; break; + } + for(uint8 i = 0; i < 4; ++i) + { + Unit* pUnit = Unit::GetUnit((*m_creature), Council[i]); + if(pUnit) + pUnit->CastSpell(pUnit, spellid, true, 0, 0, m_creature->GetGUID()); + } + } + + void UpdateAI(const uint32 diff) + { + if(!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + if(BlessingTimer < diff) + { + if(Unit* pUnit = SelectCouncilMember()) + { + switch(rand()%2) + { + case 0: DoCast(pUnit, SPELL_BLESS_SPELLWARD); break; + case 1: DoCast(pUnit, SPELL_BLESS_PROTECTION); break; + } + } + BlessingTimer = 60000; + }else BlessingTimer -= diff; + + if(ConsecrationTimer < diff) + { + DoCast(m_creature, SPELL_CONSECRATION); + ConsecrationTimer = 40000; + }else ConsecrationTimer -= diff; + + if(HammerOfJusticeTimer < diff) + { + if(Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0)) + { + // is in ~10-40 yd range + if(m_creature->GetDistance2d(target) > 10 && m_creature->GetDistance2d(target) < 40) + { + DoCast(target, SPELL_HAMMER_OF_JUSTICE); + HammerOfJusticeTimer = 20000; + } + } + }else HammerOfJusticeTimer -= diff; + + if(SealTimer < diff) + { + switch(rand()%2) + { + case 0: DoCast(m_creature, SPELL_SEAL_OF_COMMAND); break; + case 1: DoCast(m_creature, SPELL_SEAL_OF_BLOOD); break; + } + SealTimer = 40000; + }else SealTimer -= diff; + + if(AuraTimer < diff) + { + CastAuraOnCouncil(); + AuraTimer = 90000; + }else AuraTimer -= diff; + + DoMeleeAttackIfReady(); + } +}; + +struct MANGOS_DLL_DECL boss_high_nethermancer_zerevorAI : public boss_illidari_councilAI +{ + boss_high_nethermancer_zerevorAI(Creature *c) : boss_illidari_councilAI(c) { Reset(); } + + uint32 BlizzardTimer; + uint32 FlamestrikeTimer; + uint32 ArcaneBoltTimer; + uint32 DampenMagicTimer; + uint32 Cooldown; + uint32 ArcaneExplosionTimer; + + void Reset() + { + BlizzardTimer = 30000 + rand()%61 * 1000; + FlamestrikeTimer = 30000 + rand()%61 * 1000; + ArcaneBoltTimer = 10000; + DampenMagicTimer = 2000; + ArcaneExplosionTimer = 14000; + Cooldown = 0; + } + + void KilledUnit(Unit *victim) + { + DoYell(SAY_ZERE_SLAY,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature, SOUND_ZERE_SLAY); + } + + void JustDied(Unit *victim) + { + DoYell(SAY_ZERE_DEATH, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature,SOUND_ZERE_DEATH); + } + + void UpdateAI(const uint32 diff) + { + if(!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + if(Cooldown) + { + if(Cooldown < diff) Cooldown = 0; + else + { + Cooldown -= diff; + return; // Don't cast any other spells if global cooldown is still ticking + } + } + + if(DampenMagicTimer < diff) + { + DoCast(m_creature, SPELL_DAMPEN_MAGIC); + Cooldown = 1000; + DampenMagicTimer = 110000; // almost 2 minutes + ArcaneBoltTimer += 1000; // Give the Mage some time to spellsteal Dampen. + }else DampenMagicTimer -= diff; + + if(ArcaneExplosionTimer < diff) + { + DoCast(m_creature->getVictim(), SPELL_ARCANE_EXPLOSION); + Cooldown = 1000; + ArcaneExplosionTimer = 14000; + }else ArcaneExplosionTimer -= diff; + + if(ArcaneBoltTimer < diff) + { + DoCast(m_creature->getVictim(), SPELL_ARCANE_BOLT); + ArcaneBoltTimer = 3000; + Cooldown = 2000; + }else ArcaneBoltTimer -= diff; + + if(BlizzardTimer < diff) + { + if(Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0)) + { + DoCast(target, SPELL_BLIZZARD); + BlizzardTimer = 45000 + rand()%46 * 1000; + FlamestrikeTimer += 10000; + Cooldown = 1000; + } + }else BlizzardTimer -= diff; + + if(FlamestrikeTimer < diff) + { + if(Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0)) + { + DoCast(target, SPELL_FLAMESTRIKE); + FlamestrikeTimer = 55000 + rand()%46 * 1000; + BlizzardTimer += 10000; + Cooldown = 2000; + } + }else FlamestrikeTimer -= diff; + } +}; + +struct MANGOS_DLL_DECL boss_lady_malandeAI : public boss_illidari_councilAI +{ + boss_lady_malandeAI(Creature *c) : boss_illidari_councilAI(c) { Reset(); } + + uint32 EmpoweredSmiteTimer; + uint32 CircleOfHealingTimer; + uint32 DivineWrathTimer; + uint32 ReflectiveShieldTimer; + + void Reset() + { + EmpoweredSmiteTimer = 38000; + CircleOfHealingTimer = 20000; + DivineWrathTimer = 40000; + ReflectiveShieldTimer = 0; + } + + void KilledUnit(Unit *victim) + { + DoYell(SAY_MALA_SLAY,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature, SOUND_MALA_SLAY); + } + + void JustDied(Unit *victim) + { + DoYell(SAY_MALA_DEATH, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature,SOUND_MALA_DEATH); + } + + void UpdateAI(const uint32 diff) + { + if(!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + if(EmpoweredSmiteTimer < diff) + { + if(Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0)) + { + DoCast(target, SPELL_EMPOWERED_SMITE); + EmpoweredSmiteTimer = 38000; + } + }else EmpoweredSmiteTimer -= diff; + + if(CircleOfHealingTimer < diff) + { + //Currently bugged and puts Malande on the threatlist of the other council members. It also heals players. + //DoCast(m_creature, SPELL_CIRCLE_OF_HEALING); + CircleOfHealingTimer = 60000; + }else CircleOfHealingTimer -= diff; + + if(DivineWrathTimer < diff) + { + if(Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0)) + { + DoCast(target, SPELL_DIVINE_WRATH); + DivineWrathTimer = 40000 + rand()%41 * 1000; + } + }else DivineWrathTimer -= diff; + + if(ReflectiveShieldTimer < diff) + { + DoCast(m_creature, SPELL_REFLECTIVE_SHIELD); + ReflectiveShieldTimer = 65000; + }else ReflectiveShieldTimer -= diff; + + DoMeleeAttackIfReady(); + } +}; + +struct MANGOS_DLL_DECL boss_veras_darkshadowAI : public boss_illidari_councilAI +{ + boss_veras_darkshadowAI(Creature *c) : boss_illidari_councilAI(c) { Reset(); } + + uint64 EnvenomTargetGUID; + + uint32 DeadlyPoisonTimer; + uint32 VanishTimer; + uint32 AppearEnvenomTimer; + + bool HasVanished; + + void Reset() + { + EnvenomTargetGUID = 0; + + DeadlyPoisonTimer = 20000; + VanishTimer = 60000 + rand()%61 * 1000; + AppearEnvenomTimer = 150000; + + HasVanished = false; + m_creature->SetVisibility(VISIBILITY_ON); + m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + } + + void KilledUnit(Unit *victim) + { + DoYell(SAY_VERA_SLAY,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature, SOUND_VERA_SLAY); + } + + void JustDied(Unit *victim) + { + DoYell(SAY_VERA_DEATH, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature,SOUND_VERA_DEATH); + } + + void UpdateAI(const uint32 diff) + { + if(!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + if(!HasVanished) + { + if(DeadlyPoisonTimer < diff) + { + DoCast(m_creature->getVictim(), SPELL_DEADLY_POISON); + DeadlyPoisonTimer = 15000 + rand()%31 * 1000; + }else DeadlyPoisonTimer -= diff; + + if(AppearEnvenomTimer < diff) // Cast Envenom. This is cast 4 seconds after Vanish is over + { + DoCast(m_creature->getVictim(), SPELL_ENVENOM); + AppearEnvenomTimer = 90000; + }else AppearEnvenomTimer -= diff; + + if(VanishTimer < diff) // Disappear and stop attacking, but follow a random unit + { + if(Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0)) + { + VanishTimer = 30000; + AppearEnvenomTimer= 28000; + HasVanished = true; + m_creature->SetVisibility(VISIBILITY_OFF); + m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + DoResetThreat(); + // Chase a unit. Check before DoMeleeAttackIfReady prevents from attacking + m_creature->AddThreat(target, 500000.0f); + m_creature->GetMotionMaster()->MoveChase(target); + } + }else VanishTimer -= diff; + + DoMeleeAttackIfReady(); + } + else + { + if(VanishTimer < diff) // Become attackable and poison current target + { + Unit* target = m_creature->getVictim(); + DoCast(target, SPELL_DEADLY_POISON); + m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + DoResetThreat(); + m_creature->AddThreat(target, 3000.0f); // Make Veras attack his target for a while, he will cast Envenom 4 seconds after. + DeadlyPoisonTimer += 6000; + VanishTimer = 90000; + AppearEnvenomTimer = 4000; + HasVanished = false; + }else VanishTimer -= diff; + + if(AppearEnvenomTimer < diff) // Appear 2 seconds before becoming attackable (Shifting out of vanish) + { + m_creature->GetMotionMaster()->Clear(); + m_creature->GetMotionMaster()->MoveChase(m_creature->getVictim()); + m_creature->SetVisibility(VISIBILITY_ON); + AppearEnvenomTimer = 6000; + }else AppearEnvenomTimer -= diff; + } + } +}; + +CreatureAI* GetAI_mob_blood_elf_council_voice_trigger(Creature* c) +{ + return new mob_blood_elf_council_voice_triggerAI(c); +} + +CreatureAI* GetAI_mob_illidari_council(Creature *_Creature) +{ + return new mob_illidari_councilAI (_Creature); +} + +CreatureAI* GetAI_boss_gathios_the_shatterer(Creature *_Creature) +{ + return new boss_gathios_the_shattererAI (_Creature); +} + +CreatureAI* GetAI_boss_lady_malande(Creature *_Creature) +{ + return new boss_lady_malandeAI (_Creature); +} + +CreatureAI* GetAI_boss_veras_darkshadow(Creature *_Creature) +{ + return new boss_veras_darkshadowAI (_Creature); +} + +CreatureAI* GetAI_boss_high_nethermancer_zerevor(Creature *_Creature) +{ + return new boss_high_nethermancer_zerevorAI (_Creature); +} + +void AddSC_boss_illidari_council() +{ + Script *newscript; + + newscript = new Script; + newscript->Name="mob_illidari_council"; + newscript->GetAI = GetAI_mob_illidari_council; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name = "mob_blood_elf_council_voice_trigger"; + newscript->GetAI = GetAI_mob_blood_elf_council_voice_trigger; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="boss_gathios_the_shatterer"; + newscript->GetAI = GetAI_boss_gathios_the_shatterer; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="boss_lady_malande"; + newscript->GetAI = GetAI_boss_lady_malande; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="boss_veras_darkshadow"; + newscript->GetAI = GetAI_boss_veras_darkshadow; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="boss_high_nethermancer_zerevor"; + newscript->GetAI = GetAI_boss_high_nethermancer_zerevor; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/black_temple/instance_black_temple.cpp b/src/bindings/scripts/scripts/zone/black_temple/instance_black_temple.cpp index 3251c93cafa..07ad3b996fd 100644 --- a/src/bindings/scripts/scripts/zone/black_temple/instance_black_temple.cpp +++ b/src/bindings/scripts/scripts/zone/black_temple/instance_black_temple.cpp @@ -1,252 +1,252 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Instance_Black_Temple -SD%Complete: 100 -SDComment: Instance Data Scripts and functions to acquire mobs and set encounter status for use in various Black Temple Scripts -SDCategory: Black Temple -EndScriptData */ - -#include "precompiled.h" -#include "def_black_temple.h" - -#define ENCOUNTERS 9 - -/* Black Temple encounters: -0 - High Warlord Naj'entus event -1 - Supremus Event -2 - Shade of Akama Event -3 - Teron Gorefiend Event -4 - Gurtogg Bloodboil Event -5 - Reliquary Of Souls Event -6 - Mother Shahraz Event -7 - Illidari Council Event -8 - Illidan Stormrage Event -*/ - -struct MANGOS_DLL_DECL instance_black_temple : public ScriptedInstance -{ - instance_black_temple(Map *Map) : ScriptedInstance(Map) {Initialize();}; - - uint64 Najentus; - uint64 Akama; // This is the Akama that starts the Illidan encounter. - uint64 Akama_Shade; // This is the Akama that starts the Shade of Akama encounter. - uint64 ShadeOfAkama; - uint64 Supremus; - uint64 LadyMalande; - uint64 GathiosTheShatterer; - uint64 HighNethermancerZerevor; - uint64 VerasDarkshadow; - uint64 IllidariCouncil; - uint64 BloodElfCouncilVoice; - uint64 IllidanStormrage; - - uint64 NajentusGate; - uint64 MainTempleDoors; - uint64 IllidanGate; - uint64 IllidanDoor[2]; - - uint32 Encounters[ENCOUNTERS]; - - void Initialize() - { - Najentus = 0; - Akama = 0; - Akama_Shade = 0; - ShadeOfAkama = 0; - Supremus = 0; - LadyMalande = 0; - GathiosTheShatterer = 0; - HighNethermancerZerevor = 0; - VerasDarkshadow = 0; - IllidariCouncil = 0; - BloodElfCouncilVoice = 0; - IllidanStormrage = 0; - - NajentusGate = 0; - MainTempleDoors = 0; - IllidanGate = 0; - IllidanDoor[0] = 0; - IllidanDoor[1] = 0; - - for(uint8 i = 0; i < ENCOUNTERS; i++) - Encounters[i] = NOT_STARTED; - } - - bool IsEncounterInProgress() const - { - for(uint8 i = 0; i < ENCOUNTERS; i++) - if(Encounters[i] == IN_PROGRESS) return true; - - return false; - } - - void OnCreatureCreate(Creature *creature, uint32 creature_entry) - { - switch(creature_entry) - { - case 22887: Najentus = creature->GetGUID(); break; - case 23089: Akama = creature->GetGUID(); break; - case 22990: Akama_Shade = creature->GetGUID(); break; - case 22841: ShadeOfAkama = creature->GetGUID(); break; - case 22898: Supremus = creature->GetGUID(); break; - case 22917: IllidanStormrage = creature->GetGUID(); break; - case 22949: GathiosTheShatterer = creature->GetGUID(); break; - case 22950: HighNethermancerZerevor = creature->GetGUID(); break; - case 22951: LadyMalande = creature->GetGUID(); break; - case 22952: VerasDarkshadow = creature->GetGUID(); break; - case 23426: IllidariCouncil = creature->GetGUID(); break; - case 23499: BloodElfCouncilVoice = creature->GetGUID(); break; - } - } - - void OnObjectCreate(GameObject* go) - { - switch(go->GetEntry()) - { - case 185483: // Gate past Naj'entus (at the entrance to Supermoose's courtyards) - NajentusGate = go->GetGUID(); - break; - case 185882: // Main Temple Doors - right past Supermoose (Supremus) - MainTempleDoors = go->GetGUID(); - break; - case 185905: // Gate leading to Temple Summit - IllidanGate = go->GetGUID(); - break; - case 186261: // Right door at Temple Summit - IllidanDoor[0] = go->GetGUID(); - break; - case 186262: // Left door at Temple Summit - IllidanDoor[1] = go->GetGUID(); - break; - } - } - - uint64 GetData64(uint32 identifier) - { - switch(identifier) - { - case DATA_HIGHWARLORDNAJENTUS: return Najentus; - case DATA_AKAMA: return Akama; - case DATA_AKAMA_SHADE: return Akama_Shade; - case DATA_SHADEOFAKAMA: return ShadeOfAkama; - case DATA_SUPREMUS: return Supremus; - case DATA_ILLIDANSTORMRAGE: return IllidanStormrage; - case DATA_GATHIOSTHESHATTERER: return GathiosTheShatterer; - case DATA_HIGHNETHERMANCERZEREVOR: return HighNethermancerZerevor; - case DATA_LADYMALANDE: return LadyMalande; - case DATA_VERASDARKSHADOW: return VerasDarkshadow; - case DATA_ILLIDARICOUNCIL: return IllidariCouncil; - case DATA_GAMEOBJECT_NAJENTUS_GATE: return NajentusGate; - case DATA_GAMEOBJECT_ILLIDAN_GATE: return IllidanGate; - case DATA_GAMEOBJECT_ILLIDAN_DOOR_R: return IllidanDoor[0]; - case DATA_GAMEOBJECT_ILLIDAN_DOOR_L: return IllidanDoor[1]; - case DATA_GAMEOBJECT_SUPREMUS_DOORS: return MainTempleDoors; - case DATA_BLOOD_ELF_COUNCIL_VOICE: return BloodElfCouncilVoice; - } - - return 0; - } - - void SetData(uint32 type, uint32 data) - { - switch(type) - { - case DATA_HIGHWARLORDNAJENTUSEVENT: Encounters[0] = data; break; - case DATA_SUPREMUSEVENT: Encounters[1] = data; break; - case DATA_SHADEOFAKAMAEVENT: Encounters[2] = data; break; - case DATA_TERONGOREFIENDEVENT: Encounters[3] = data; break; - case DATA_GURTOGGBLOODBOILEVENT: Encounters[4] = data; break; - case DATA_RELIQUARYOFSOULSEVENT: Encounters[5] = data; break; - case DATA_MOTHERSHAHRAZEVENT: Encounters[6] = data; break; - case DATA_ILLIDARICOUNCILEVENT: Encounters[7] = data; break; - case DATA_ILLIDANSTORMRAGEEVENT: Encounters[8] = data; break; - } - - if(data == DONE) - SaveToDB(); - } - - uint32 GetData(uint32 type) - { - switch(type) - { - case DATA_HIGHWARLORDNAJENTUSEVENT: return Encounters[0]; - case DATA_SUPREMUSEVENT: return Encounters[1]; - case DATA_SHADEOFAKAMAEVENT: return Encounters[2]; - case DATA_TERONGOREFIENDEVENT: return Encounters[3]; - case DATA_GURTOGGBLOODBOILEVENT: return Encounters[4]; - case DATA_RELIQUARYOFSOULSEVENT: return Encounters[5]; - case DATA_MOTHERSHAHRAZEVENT: return Encounters[6]; - case DATA_ILLIDARICOUNCILEVENT: return Encounters[7]; - case DATA_ILLIDANSTORMRAGEEVENT: return Encounters[8]; - } - - return 0; - } - - const char* Save() - { - OUT_SAVE_INST_DATA; - std::ostringstream stream; - stream << Encounters[0] << " " << Encounters[1] << " " << Encounters[2] << " " - << Encounters[3] << " " << Encounters[4] << " " << Encounters[5] << " " - << Encounters[6] << " " << Encounters[7] << " " << Encounters[8]; - char* out = new char[stream.str().length() + 1]; - strcpy(out, stream.str().c_str()); - if(out) - { - OUT_SAVE_INST_DATA_COMPLETE; - return out; - } - - return NULL; - } - - void Load(const char* in) - { - if(!in) - { - OUT_LOAD_INST_DATA_FAIL; - return; - } - - OUT_LOAD_INST_DATA(in); - std::istringstream stream(in); - stream >> Encounters[0] >> Encounters[1] >> Encounters[2] >> Encounters[3] - >> Encounters[4] >> Encounters[5] >> Encounters[6] >> Encounters[7] - >> Encounters[8]; - for(uint8 i = 0; i < ENCOUNTERS; ++i) - if(Encounters[i] == IN_PROGRESS) // Do not load an encounter as "In Progress" - reset it instead. - Encounters[i] = NOT_STARTED; - OUT_LOAD_INST_DATA_COMPLETE; - } -}; - -InstanceData* GetInstanceData_instance_black_temple(Map* map) -{ - return new instance_black_temple(map); -} - -void AddSC_instance_black_temple() -{ - Script *newscript; - newscript = new Script; - newscript->Name = "instance_black_temple"; - newscript->GetInstanceData = GetInstanceData_instance_black_temple; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Instance_Black_Temple +SD%Complete: 100 +SDComment: Instance Data Scripts and functions to acquire mobs and set encounter status for use in various Black Temple Scripts +SDCategory: Black Temple +EndScriptData */ + +#include "precompiled.h" +#include "def_black_temple.h" + +#define ENCOUNTERS 9 + +/* Black Temple encounters: +0 - High Warlord Naj'entus event +1 - Supremus Event +2 - Shade of Akama Event +3 - Teron Gorefiend Event +4 - Gurtogg Bloodboil Event +5 - Reliquary Of Souls Event +6 - Mother Shahraz Event +7 - Illidari Council Event +8 - Illidan Stormrage Event +*/ + +struct MANGOS_DLL_DECL instance_black_temple : public ScriptedInstance +{ + instance_black_temple(Map *Map) : ScriptedInstance(Map) {Initialize();}; + + uint64 Najentus; + uint64 Akama; // This is the Akama that starts the Illidan encounter. + uint64 Akama_Shade; // This is the Akama that starts the Shade of Akama encounter. + uint64 ShadeOfAkama; + uint64 Supremus; + uint64 LadyMalande; + uint64 GathiosTheShatterer; + uint64 HighNethermancerZerevor; + uint64 VerasDarkshadow; + uint64 IllidariCouncil; + uint64 BloodElfCouncilVoice; + uint64 IllidanStormrage; + + uint64 NajentusGate; + uint64 MainTempleDoors; + uint64 IllidanGate; + uint64 IllidanDoor[2]; + + uint32 Encounters[ENCOUNTERS]; + + void Initialize() + { + Najentus = 0; + Akama = 0; + Akama_Shade = 0; + ShadeOfAkama = 0; + Supremus = 0; + LadyMalande = 0; + GathiosTheShatterer = 0; + HighNethermancerZerevor = 0; + VerasDarkshadow = 0; + IllidariCouncil = 0; + BloodElfCouncilVoice = 0; + IllidanStormrage = 0; + + NajentusGate = 0; + MainTempleDoors = 0; + IllidanGate = 0; + IllidanDoor[0] = 0; + IllidanDoor[1] = 0; + + for(uint8 i = 0; i < ENCOUNTERS; i++) + Encounters[i] = NOT_STARTED; + } + + bool IsEncounterInProgress() const + { + for(uint8 i = 0; i < ENCOUNTERS; i++) + if(Encounters[i] == IN_PROGRESS) return true; + + return false; + } + + void OnCreatureCreate(Creature *creature, uint32 creature_entry) + { + switch(creature_entry) + { + case 22887: Najentus = creature->GetGUID(); break; + case 23089: Akama = creature->GetGUID(); break; + case 22990: Akama_Shade = creature->GetGUID(); break; + case 22841: ShadeOfAkama = creature->GetGUID(); break; + case 22898: Supremus = creature->GetGUID(); break; + case 22917: IllidanStormrage = creature->GetGUID(); break; + case 22949: GathiosTheShatterer = creature->GetGUID(); break; + case 22950: HighNethermancerZerevor = creature->GetGUID(); break; + case 22951: LadyMalande = creature->GetGUID(); break; + case 22952: VerasDarkshadow = creature->GetGUID(); break; + case 23426: IllidariCouncil = creature->GetGUID(); break; + case 23499: BloodElfCouncilVoice = creature->GetGUID(); break; + } + } + + void OnObjectCreate(GameObject* go) + { + switch(go->GetEntry()) + { + case 185483: // Gate past Naj'entus (at the entrance to Supermoose's courtyards) + NajentusGate = go->GetGUID(); + break; + case 185882: // Main Temple Doors - right past Supermoose (Supremus) + MainTempleDoors = go->GetGUID(); + break; + case 185905: // Gate leading to Temple Summit + IllidanGate = go->GetGUID(); + break; + case 186261: // Right door at Temple Summit + IllidanDoor[0] = go->GetGUID(); + break; + case 186262: // Left door at Temple Summit + IllidanDoor[1] = go->GetGUID(); + break; + } + } + + uint64 GetData64(uint32 identifier) + { + switch(identifier) + { + case DATA_HIGHWARLORDNAJENTUS: return Najentus; + case DATA_AKAMA: return Akama; + case DATA_AKAMA_SHADE: return Akama_Shade; + case DATA_SHADEOFAKAMA: return ShadeOfAkama; + case DATA_SUPREMUS: return Supremus; + case DATA_ILLIDANSTORMRAGE: return IllidanStormrage; + case DATA_GATHIOSTHESHATTERER: return GathiosTheShatterer; + case DATA_HIGHNETHERMANCERZEREVOR: return HighNethermancerZerevor; + case DATA_LADYMALANDE: return LadyMalande; + case DATA_VERASDARKSHADOW: return VerasDarkshadow; + case DATA_ILLIDARICOUNCIL: return IllidariCouncil; + case DATA_GAMEOBJECT_NAJENTUS_GATE: return NajentusGate; + case DATA_GAMEOBJECT_ILLIDAN_GATE: return IllidanGate; + case DATA_GAMEOBJECT_ILLIDAN_DOOR_R: return IllidanDoor[0]; + case DATA_GAMEOBJECT_ILLIDAN_DOOR_L: return IllidanDoor[1]; + case DATA_GAMEOBJECT_SUPREMUS_DOORS: return MainTempleDoors; + case DATA_BLOOD_ELF_COUNCIL_VOICE: return BloodElfCouncilVoice; + } + + return 0; + } + + void SetData(uint32 type, uint32 data) + { + switch(type) + { + case DATA_HIGHWARLORDNAJENTUSEVENT: Encounters[0] = data; break; + case DATA_SUPREMUSEVENT: Encounters[1] = data; break; + case DATA_SHADEOFAKAMAEVENT: Encounters[2] = data; break; + case DATA_TERONGOREFIENDEVENT: Encounters[3] = data; break; + case DATA_GURTOGGBLOODBOILEVENT: Encounters[4] = data; break; + case DATA_RELIQUARYOFSOULSEVENT: Encounters[5] = data; break; + case DATA_MOTHERSHAHRAZEVENT: Encounters[6] = data; break; + case DATA_ILLIDARICOUNCILEVENT: Encounters[7] = data; break; + case DATA_ILLIDANSTORMRAGEEVENT: Encounters[8] = data; break; + } + + if(data == DONE) + SaveToDB(); + } + + uint32 GetData(uint32 type) + { + switch(type) + { + case DATA_HIGHWARLORDNAJENTUSEVENT: return Encounters[0]; + case DATA_SUPREMUSEVENT: return Encounters[1]; + case DATA_SHADEOFAKAMAEVENT: return Encounters[2]; + case DATA_TERONGOREFIENDEVENT: return Encounters[3]; + case DATA_GURTOGGBLOODBOILEVENT: return Encounters[4]; + case DATA_RELIQUARYOFSOULSEVENT: return Encounters[5]; + case DATA_MOTHERSHAHRAZEVENT: return Encounters[6]; + case DATA_ILLIDARICOUNCILEVENT: return Encounters[7]; + case DATA_ILLIDANSTORMRAGEEVENT: return Encounters[8]; + } + + return 0; + } + + const char* Save() + { + OUT_SAVE_INST_DATA; + std::ostringstream stream; + stream << Encounters[0] << " " << Encounters[1] << " " << Encounters[2] << " " + << Encounters[3] << " " << Encounters[4] << " " << Encounters[5] << " " + << Encounters[6] << " " << Encounters[7] << " " << Encounters[8]; + char* out = new char[stream.str().length() + 1]; + strcpy(out, stream.str().c_str()); + if(out) + { + OUT_SAVE_INST_DATA_COMPLETE; + return out; + } + + return NULL; + } + + void Load(const char* in) + { + if(!in) + { + OUT_LOAD_INST_DATA_FAIL; + return; + } + + OUT_LOAD_INST_DATA(in); + std::istringstream stream(in); + stream >> Encounters[0] >> Encounters[1] >> Encounters[2] >> Encounters[3] + >> Encounters[4] >> Encounters[5] >> Encounters[6] >> Encounters[7] + >> Encounters[8]; + for(uint8 i = 0; i < ENCOUNTERS; ++i) + if(Encounters[i] == IN_PROGRESS) // Do not load an encounter as "In Progress" - reset it instead. + Encounters[i] = NOT_STARTED; + OUT_LOAD_INST_DATA_COMPLETE; + } +}; + +InstanceData* GetInstanceData_instance_black_temple(Map* map) +{ + return new instance_black_temple(map); +} + +void AddSC_instance_black_temple() +{ + Script *newscript; + newscript = new Script; + newscript->Name = "instance_black_temple"; + newscript->GetInstanceData = GetInstanceData_instance_black_temple; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/blackrock_depths/blackrock_depths.cpp b/src/bindings/scripts/scripts/zone/blackrock_depths/blackrock_depths.cpp index b4b2b177f19..42409f1af35 100644 --- a/src/bindings/scripts/scripts/zone/blackrock_depths/blackrock_depths.cpp +++ b/src/bindings/scripts/scripts/zone/blackrock_depths/blackrock_depths.cpp @@ -1,237 +1,237 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Blackrock_Depths -SD%Complete: 95 -SDComment: Quest support: 4001, 4342, 7604. Vendor Lokhtos Darkbargainer. -SDCategory: Blackrock Depths -EndScriptData */ - -/* ContentData -mob_phalanx -npc_kharan_mighthammer -npc_lokhtos_darkbargainer -EndContentData */ - -#include "precompiled.h" - -/*###### -## mob_phalanx -######*/ - -#define SPELL_THUNDERCLAP 8732 -#define SPELL_FIREBALLVOLLEY 22425 -#define SPELL_MIGHTYBLOW 14099 - -struct MANGOS_DLL_DECL mob_phalanxAI : public ScriptedAI -{ - mob_phalanxAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 ThunderClap_Timer; - uint32 FireballVolley_Timer; - uint32 MightyBlow_Timer; - - void Reset() - { - ThunderClap_Timer = 12000; - FireballVolley_Timer =0; - MightyBlow_Timer = 15000; - } - - void Aggro(Unit *who) - { - } - - void UpdateAI(const uint32 diff) - { - //Return since we have no target - if(!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - //ThunderClap_Timer - if( ThunderClap_Timer < diff ) - { - DoCast(m_creature->getVictim(),SPELL_THUNDERCLAP); - ThunderClap_Timer = 10000; - }else ThunderClap_Timer -= diff; - - //FireballVolley_Timer - if( m_creature->GetHealth()*100 / m_creature->GetMaxHealth() < 51 ) - { - if (FireballVolley_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_FIREBALLVOLLEY); - FireballVolley_Timer = 15000; - }else FireballVolley_Timer -= diff; - } - - //MightyBlow_Timer - if( MightyBlow_Timer < diff ) - { - DoCast(m_creature->getVictim(),SPELL_MIGHTYBLOW); - MightyBlow_Timer = 10000; - }else MightyBlow_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; -CreatureAI* GetAI_mob_phalanx(Creature *_Creature) -{ - return new mob_phalanxAI (_Creature); -} - -/*###### -## npc_kharan_mighthammer -######*/ - -#define QUEST_4001 4001 -#define QUEST_4342 4342 - -bool GossipHello_npc_kharan_mighthammer(Player *player, Creature *_Creature) -{ - if( _Creature->isQuestGiver() ) - player->PrepareQuestMenu( _Creature->GetGUID() ); - - if( player->GetQuestStatus(QUEST_4001) == QUEST_STATUS_INCOMPLETE ) - player->ADD_GOSSIP_ITEM( 0, "I need to know where the princess are, Kharan!", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); - - if( player->GetQuestStatus(4342) == QUEST_STATUS_INCOMPLETE ) - player->ADD_GOSSIP_ITEM( 0, "All is not lost, Kharan!", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+3); - - if( player->GetTeam() == HORDE ) player->SEND_GOSSIP_MENU(2473, _Creature->GetGUID()); - if( player->GetTeam() == ALLIANCE ) player->SEND_GOSSIP_MENU(2474, _Creature->GetGUID()); - - return true; -} - -bool GossipSelect_npc_kharan_mighthammer(Player *player, Creature *_Creature, uint32 sender, uint32 action) -{ - switch (action) - { - case GOSSIP_ACTION_INFO_DEF+1: - player->ADD_GOSSIP_ITEM(0, "Gor'shak is my friend, you can trust me.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2); - player->SEND_GOSSIP_MENU(2475, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+2: - player->ADD_GOSSIP_ITEM(0, "Not enough, you need to tell me more.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+3); - player->SEND_GOSSIP_MENU(2476, _Creature->GetGUID()); - break; - - case GOSSIP_ACTION_INFO_DEF+3: - player->ADD_GOSSIP_ITEM(0, "So what happened?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+4); - player->SEND_GOSSIP_MENU(2477, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+4: - player->ADD_GOSSIP_ITEM(0, "Continue...", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+5); - player->SEND_GOSSIP_MENU(2478, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+5: - player->ADD_GOSSIP_ITEM(0, "So you suspect that someone on the inside was involved? That they were tipped off?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+6); - player->SEND_GOSSIP_MENU(2479, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+6: - player->ADD_GOSSIP_ITEM(0, "Continue with your story please.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+7); - player->SEND_GOSSIP_MENU(2480, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+7: - player->ADD_GOSSIP_ITEM(0, "Indeed.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+8); - player->SEND_GOSSIP_MENU(2481, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+8: - player->ADD_GOSSIP_ITEM(0, "The door is open, Kharan. You are a free man.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+9); - player->SEND_GOSSIP_MENU(2482, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+9: - player->CLOSE_GOSSIP_MENU(); - if( player->GetTeam() == HORDE ) player->AreaExploredOrEventHappens(QUEST_4001); - if( player->GetTeam() == ALLIANCE ) player->AreaExploredOrEventHappens(QUEST_4342); - break; - } - return true; -} - -/*###### -## npc_lokhtos_darkbargainer -######*/ - -#define ITEM_THRORIUM_BROTHERHOOD_CONTRACT 18628 -#define ITEM_SULFURON_INGOT 17203 -#define QUEST_A_BINDING_CONTRACT 7604 -#define SPELL_CREATE_THORIUM_BROTHERHOOD_CONTRACT_DND 23059 - -bool GossipHello_npc_lokhtos_darkbargainer(Player *player, Creature *_Creature) -{ - if (_Creature->isQuestGiver()) - player->PrepareQuestMenu( _Creature->GetGUID() ); - - if (_Creature->isVendor() && player->GetReputationRank(59) >= REP_FRIENDLY) - player->ADD_GOSSIP_ITEM( 1, "Show me what I have access to, Lothos.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_TRADE); - - if (player->GetQuestRewardStatus(QUEST_A_BINDING_CONTRACT) != 1 && - !player->HasItemCount(ITEM_THRORIUM_BROTHERHOOD_CONTRACT, 1, true) && - player->HasItemCount(ITEM_SULFURON_INGOT, 1)) - { - player->ADD_GOSSIP_ITEM(0, "Get Thorium Brotherhood Contract", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); - } - - if (player->GetReputationRank(59) < REP_FRIENDLY) - player->SEND_GOSSIP_MENU(3673, _Creature->GetGUID()); - else - player->SEND_GOSSIP_MENU(3677, _Creature->GetGUID()); - - return true; -} - -bool GossipSelect_npc_lokhtos_darkbargainer(Player *player, Creature *_Creature, uint32 sender, uint32 action ) -{ - if (action == GOSSIP_ACTION_INFO_DEF + 1) - { - player->CLOSE_GOSSIP_MENU(); - player->CastSpell(player, SPELL_CREATE_THORIUM_BROTHERHOOD_CONTRACT_DND, false); - } - if (action == GOSSIP_ACTION_TRADE) - { - player->SEND_VENDORLIST( _Creature->GetGUID() ); - } - return true; -} - -/*###### -## -######*/ - -void AddSC_blackrock_depths() -{ - Script *newscript; - - newscript = new Script; - newscript->Name="phalanx"; - newscript->GetAI = GetAI_mob_phalanx; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="npc_kharan_mighthammer"; - newscript->pGossipHello = &GossipHello_npc_kharan_mighthammer; - newscript->pGossipSelect = &GossipSelect_npc_kharan_mighthammer; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="npc_lokhtos_darkbargainer"; - newscript->pGossipHello = &GossipHello_npc_lokhtos_darkbargainer; - newscript->pGossipSelect = &GossipSelect_npc_lokhtos_darkbargainer; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Blackrock_Depths +SD%Complete: 95 +SDComment: Quest support: 4001, 4342, 7604. Vendor Lokhtos Darkbargainer. +SDCategory: Blackrock Depths +EndScriptData */ + +/* ContentData +mob_phalanx +npc_kharan_mighthammer +npc_lokhtos_darkbargainer +EndContentData */ + +#include "precompiled.h" + +/*###### +## mob_phalanx +######*/ + +#define SPELL_THUNDERCLAP 8732 +#define SPELL_FIREBALLVOLLEY 22425 +#define SPELL_MIGHTYBLOW 14099 + +struct MANGOS_DLL_DECL mob_phalanxAI : public ScriptedAI +{ + mob_phalanxAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 ThunderClap_Timer; + uint32 FireballVolley_Timer; + uint32 MightyBlow_Timer; + + void Reset() + { + ThunderClap_Timer = 12000; + FireballVolley_Timer =0; + MightyBlow_Timer = 15000; + } + + void Aggro(Unit *who) + { + } + + void UpdateAI(const uint32 diff) + { + //Return since we have no target + if(!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + //ThunderClap_Timer + if( ThunderClap_Timer < diff ) + { + DoCast(m_creature->getVictim(),SPELL_THUNDERCLAP); + ThunderClap_Timer = 10000; + }else ThunderClap_Timer -= diff; + + //FireballVolley_Timer + if( m_creature->GetHealth()*100 / m_creature->GetMaxHealth() < 51 ) + { + if (FireballVolley_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_FIREBALLVOLLEY); + FireballVolley_Timer = 15000; + }else FireballVolley_Timer -= diff; + } + + //MightyBlow_Timer + if( MightyBlow_Timer < diff ) + { + DoCast(m_creature->getVictim(),SPELL_MIGHTYBLOW); + MightyBlow_Timer = 10000; + }else MightyBlow_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; +CreatureAI* GetAI_mob_phalanx(Creature *_Creature) +{ + return new mob_phalanxAI (_Creature); +} + +/*###### +## npc_kharan_mighthammer +######*/ + +#define QUEST_4001 4001 +#define QUEST_4342 4342 + +bool GossipHello_npc_kharan_mighthammer(Player *player, Creature *_Creature) +{ + if( _Creature->isQuestGiver() ) + player->PrepareQuestMenu( _Creature->GetGUID() ); + + if( player->GetQuestStatus(QUEST_4001) == QUEST_STATUS_INCOMPLETE ) + player->ADD_GOSSIP_ITEM( 0, "I need to know where the princess are, Kharan!", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); + + if( player->GetQuestStatus(4342) == QUEST_STATUS_INCOMPLETE ) + player->ADD_GOSSIP_ITEM( 0, "All is not lost, Kharan!", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+3); + + if( player->GetTeam() == HORDE ) player->SEND_GOSSIP_MENU(2473, _Creature->GetGUID()); + if( player->GetTeam() == ALLIANCE ) player->SEND_GOSSIP_MENU(2474, _Creature->GetGUID()); + + return true; +} + +bool GossipSelect_npc_kharan_mighthammer(Player *player, Creature *_Creature, uint32 sender, uint32 action) +{ + switch (action) + { + case GOSSIP_ACTION_INFO_DEF+1: + player->ADD_GOSSIP_ITEM(0, "Gor'shak is my friend, you can trust me.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2); + player->SEND_GOSSIP_MENU(2475, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+2: + player->ADD_GOSSIP_ITEM(0, "Not enough, you need to tell me more.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+3); + player->SEND_GOSSIP_MENU(2476, _Creature->GetGUID()); + break; + + case GOSSIP_ACTION_INFO_DEF+3: + player->ADD_GOSSIP_ITEM(0, "So what happened?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+4); + player->SEND_GOSSIP_MENU(2477, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+4: + player->ADD_GOSSIP_ITEM(0, "Continue...", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+5); + player->SEND_GOSSIP_MENU(2478, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+5: + player->ADD_GOSSIP_ITEM(0, "So you suspect that someone on the inside was involved? That they were tipped off?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+6); + player->SEND_GOSSIP_MENU(2479, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+6: + player->ADD_GOSSIP_ITEM(0, "Continue with your story please.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+7); + player->SEND_GOSSIP_MENU(2480, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+7: + player->ADD_GOSSIP_ITEM(0, "Indeed.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+8); + player->SEND_GOSSIP_MENU(2481, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+8: + player->ADD_GOSSIP_ITEM(0, "The door is open, Kharan. You are a free man.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+9); + player->SEND_GOSSIP_MENU(2482, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+9: + player->CLOSE_GOSSIP_MENU(); + if( player->GetTeam() == HORDE ) player->AreaExploredOrEventHappens(QUEST_4001); + if( player->GetTeam() == ALLIANCE ) player->AreaExploredOrEventHappens(QUEST_4342); + break; + } + return true; +} + +/*###### +## npc_lokhtos_darkbargainer +######*/ + +#define ITEM_THRORIUM_BROTHERHOOD_CONTRACT 18628 +#define ITEM_SULFURON_INGOT 17203 +#define QUEST_A_BINDING_CONTRACT 7604 +#define SPELL_CREATE_THORIUM_BROTHERHOOD_CONTRACT_DND 23059 + +bool GossipHello_npc_lokhtos_darkbargainer(Player *player, Creature *_Creature) +{ + if (_Creature->isQuestGiver()) + player->PrepareQuestMenu( _Creature->GetGUID() ); + + if (_Creature->isVendor() && player->GetReputationRank(59) >= REP_FRIENDLY) + player->ADD_GOSSIP_ITEM( 1, "Show me what I have access to, Lothos.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_TRADE); + + if (player->GetQuestRewardStatus(QUEST_A_BINDING_CONTRACT) != 1 && + !player->HasItemCount(ITEM_THRORIUM_BROTHERHOOD_CONTRACT, 1, true) && + player->HasItemCount(ITEM_SULFURON_INGOT, 1)) + { + player->ADD_GOSSIP_ITEM(0, "Get Thorium Brotherhood Contract", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); + } + + if (player->GetReputationRank(59) < REP_FRIENDLY) + player->SEND_GOSSIP_MENU(3673, _Creature->GetGUID()); + else + player->SEND_GOSSIP_MENU(3677, _Creature->GetGUID()); + + return true; +} + +bool GossipSelect_npc_lokhtos_darkbargainer(Player *player, Creature *_Creature, uint32 sender, uint32 action ) +{ + if (action == GOSSIP_ACTION_INFO_DEF + 1) + { + player->CLOSE_GOSSIP_MENU(); + player->CastSpell(player, SPELL_CREATE_THORIUM_BROTHERHOOD_CONTRACT_DND, false); + } + if (action == GOSSIP_ACTION_TRADE) + { + player->SEND_VENDORLIST( _Creature->GetGUID() ); + } + return true; +} + +/*###### +## +######*/ + +void AddSC_blackrock_depths() +{ + Script *newscript; + + newscript = new Script; + newscript->Name="phalanx"; + newscript->GetAI = GetAI_mob_phalanx; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="npc_kharan_mighthammer"; + newscript->pGossipHello = &GossipHello_npc_kharan_mighthammer; + newscript->pGossipSelect = &GossipSelect_npc_kharan_mighthammer; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="npc_lokhtos_darkbargainer"; + newscript->pGossipHello = &GossipHello_npc_lokhtos_darkbargainer; + newscript->pGossipSelect = &GossipSelect_npc_lokhtos_darkbargainer; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/blackrock_depths/boss_ambassador_flamelash.cpp b/src/bindings/scripts/scripts/zone/blackrock_depths/boss_ambassador_flamelash.cpp index 613da72ef3a..1df93fa1c8f 100644 --- a/src/bindings/scripts/scripts/zone/blackrock_depths/boss_ambassador_flamelash.cpp +++ b/src/bindings/scripts/scripts/zone/blackrock_depths/boss_ambassador_flamelash.cpp @@ -1,106 +1,106 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Ambassador_Flamelash -SD%Complete: 100 -SDComment: -SDCategory: Blackrock Depths -EndScriptData */ - -#include "precompiled.h" - -#define SPELL_FIREBLAST 15573 - -struct MANGOS_DLL_DECL boss_ambassador_flamelashAI : public ScriptedAI -{ - boss_ambassador_flamelashAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 FireBlast_Timer; - uint32 Spirit_Timer; - int Rand; - int RandX; - int RandY; - Creature* Summoned; - - void Reset() - { - FireBlast_Timer = 2000; - Spirit_Timer = 24000; - } - - void Aggro(Unit *who) {} - - void SummonSpirits(Unit* victim) - { - Rand = rand()%10; - switch (rand()%2) - { - case 0: RandX -= Rand; break; - case 1: RandX += Rand; break; - } - Rand = 0; - Rand = rand()%10; - switch (rand()%2) - { - case 0: RandY -= Rand; break; - case 1: RandY += Rand; break; - } - Summoned = DoSpawnCreature(9178, RandX, RandY, 0, 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 60000); - if(Summoned) - ((CreatureAI*)Summoned->AI())->AttackStart(victim); - } - - void UpdateAI(const uint32 diff) - { - //Return since we have no target - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - //FireBlast_Timer - if (FireBlast_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_FIREBLAST); - FireBlast_Timer = 7000; - }else FireBlast_Timer -= diff; - - //Spirit_Timer - if (Spirit_Timer < diff) - { - SummonSpirits(m_creature->getVictim()); - SummonSpirits(m_creature->getVictim()); - SummonSpirits(m_creature->getVictim()); - SummonSpirits(m_creature->getVictim()); - - Spirit_Timer = 30000; - }else Spirit_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; -CreatureAI* GetAI_boss_ambassador_flamelash(Creature *_Creature) -{ - return new boss_ambassador_flamelashAI (_Creature); -} - -void AddSC_boss_ambassador_flamelash() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_ambassador_flamelash"; - newscript->GetAI = GetAI_boss_ambassador_flamelash; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Ambassador_Flamelash +SD%Complete: 100 +SDComment: +SDCategory: Blackrock Depths +EndScriptData */ + +#include "precompiled.h" + +#define SPELL_FIREBLAST 15573 + +struct MANGOS_DLL_DECL boss_ambassador_flamelashAI : public ScriptedAI +{ + boss_ambassador_flamelashAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 FireBlast_Timer; + uint32 Spirit_Timer; + int Rand; + int RandX; + int RandY; + Creature* Summoned; + + void Reset() + { + FireBlast_Timer = 2000; + Spirit_Timer = 24000; + } + + void Aggro(Unit *who) {} + + void SummonSpirits(Unit* victim) + { + Rand = rand()%10; + switch (rand()%2) + { + case 0: RandX -= Rand; break; + case 1: RandX += Rand; break; + } + Rand = 0; + Rand = rand()%10; + switch (rand()%2) + { + case 0: RandY -= Rand; break; + case 1: RandY += Rand; break; + } + Summoned = DoSpawnCreature(9178, RandX, RandY, 0, 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 60000); + if(Summoned) + ((CreatureAI*)Summoned->AI())->AttackStart(victim); + } + + void UpdateAI(const uint32 diff) + { + //Return since we have no target + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + //FireBlast_Timer + if (FireBlast_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_FIREBLAST); + FireBlast_Timer = 7000; + }else FireBlast_Timer -= diff; + + //Spirit_Timer + if (Spirit_Timer < diff) + { + SummonSpirits(m_creature->getVictim()); + SummonSpirits(m_creature->getVictim()); + SummonSpirits(m_creature->getVictim()); + SummonSpirits(m_creature->getVictim()); + + Spirit_Timer = 30000; + }else Spirit_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; +CreatureAI* GetAI_boss_ambassador_flamelash(Creature *_Creature) +{ + return new boss_ambassador_flamelashAI (_Creature); +} + +void AddSC_boss_ambassador_flamelash() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_ambassador_flamelash"; + newscript->GetAI = GetAI_boss_ambassador_flamelash; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/blackrock_depths/boss_angerrel.cpp b/src/bindings/scripts/scripts/zone/blackrock_depths/boss_angerrel.cpp index 98e382ae233..ccef8ab8428 100644 --- a/src/bindings/scripts/scripts/zone/blackrock_depths/boss_angerrel.cpp +++ b/src/bindings/scripts/scripts/zone/blackrock_depths/boss_angerrel.cpp @@ -1,91 +1,91 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Angerrel -SD%Complete: 100 -SDComment: -SDCategory: Blackrock Depths -EndScriptData */ - -#include "precompiled.h" - -#define SPELL_SUNDERARMOR 24317 -#define SPELL_SHIELDBLOCK 12169 -#define SPELL_STRIKE 15580 - -struct MANGOS_DLL_DECL boss_angerrelAI : public ScriptedAI -{ - boss_angerrelAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 SunderArmor_Timer; - uint32 ShieldBlock_Timer; - uint32 Strike_Timer; - - void Reset() - { - SunderArmor_Timer = 8000; - ShieldBlock_Timer = 15000; - Strike_Timer = 12000; - } - - void Aggro(Unit *who) - { - } - - void UpdateAI(const uint32 diff) - { - //Return since we have no target - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - //SunderArmor_Timer - if (SunderArmor_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_SUNDERARMOR); - SunderArmor_Timer = 28000; - }else SunderArmor_Timer -= diff; - - //ShieldBlock_Timer - if (ShieldBlock_Timer < diff) - { - DoCast(m_creature,SPELL_SHIELDBLOCK); - ShieldBlock_Timer = 25000; - }else ShieldBlock_Timer -= diff; - - //Strike_Timer - if (Strike_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_STRIKE); - Strike_Timer = 10000; - }else Strike_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; -CreatureAI* GetAI_boss_angerrel(Creature *_Creature) -{ - return new boss_angerrelAI (_Creature); -} - -void AddSC_boss_angerrel() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_angerrel"; - newscript->GetAI = GetAI_boss_angerrel; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Angerrel +SD%Complete: 100 +SDComment: +SDCategory: Blackrock Depths +EndScriptData */ + +#include "precompiled.h" + +#define SPELL_SUNDERARMOR 24317 +#define SPELL_SHIELDBLOCK 12169 +#define SPELL_STRIKE 15580 + +struct MANGOS_DLL_DECL boss_angerrelAI : public ScriptedAI +{ + boss_angerrelAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 SunderArmor_Timer; + uint32 ShieldBlock_Timer; + uint32 Strike_Timer; + + void Reset() + { + SunderArmor_Timer = 8000; + ShieldBlock_Timer = 15000; + Strike_Timer = 12000; + } + + void Aggro(Unit *who) + { + } + + void UpdateAI(const uint32 diff) + { + //Return since we have no target + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + //SunderArmor_Timer + if (SunderArmor_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_SUNDERARMOR); + SunderArmor_Timer = 28000; + }else SunderArmor_Timer -= diff; + + //ShieldBlock_Timer + if (ShieldBlock_Timer < diff) + { + DoCast(m_creature,SPELL_SHIELDBLOCK); + ShieldBlock_Timer = 25000; + }else ShieldBlock_Timer -= diff; + + //Strike_Timer + if (Strike_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_STRIKE); + Strike_Timer = 10000; + }else Strike_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; +CreatureAI* GetAI_boss_angerrel(Creature *_Creature) +{ + return new boss_angerrelAI (_Creature); +} + +void AddSC_boss_angerrel() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_angerrel"; + newscript->GetAI = GetAI_boss_angerrel; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/blackrock_depths/boss_anubshiah.cpp b/src/bindings/scripts/scripts/zone/blackrock_depths/boss_anubshiah.cpp index 1cf80bfc8ec..eb878e71b62 100644 --- a/src/bindings/scripts/scripts/zone/blackrock_depths/boss_anubshiah.cpp +++ b/src/bindings/scripts/scripts/zone/blackrock_depths/boss_anubshiah.cpp @@ -1,115 +1,115 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Anubshiah -SD%Complete: 100 -SDComment: -SDCategory: Blackrock Depths -EndScriptData */ - -#include "precompiled.h" - -#define SPELL_SHADOWBOLT 17228 -#define SPELL_CURSEOFTONGUES 15470 -#define SPELL_CURSEOFWEAKNESS 17227 -#define SPELL_DEMONARMOR 11735 -#define SPELL_ENVELOPINGWEB 15471 - -struct MANGOS_DLL_DECL boss_anubshiahAI : public ScriptedAI -{ - boss_anubshiahAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 ShadowBolt_Timer; - uint32 CurseOfTongues_Timer; - uint32 CurseOfWeakness_Timer; - uint32 DemonArmor_Timer; - uint32 EnvelopingWeb_Timer; - - void Reset() - { - ShadowBolt_Timer = 7000; - CurseOfTongues_Timer = 24000; - CurseOfWeakness_Timer = 12000; - DemonArmor_Timer = 3000; - EnvelopingWeb_Timer = 16000; - } - - void Aggro(Unit *who) - { - } - - void UpdateAI(const uint32 diff) - { - //Return since we have no target - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - //ShadowBolt_Timer - if (ShadowBolt_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_SHADOWBOLT); - ShadowBolt_Timer = 7000; - }else ShadowBolt_Timer -= diff; - - //CurseOfTongues_Timer - if (CurseOfTongues_Timer < diff) - { - Unit* target = NULL; - target = SelectUnit(SELECT_TARGET_RANDOM,0); - if (target) DoCast(target,SPELL_CURSEOFTONGUES); - CurseOfTongues_Timer = 18000; - }else CurseOfTongues_Timer -= diff; - - //CurseOfWeakness_Timer - if (CurseOfWeakness_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_CURSEOFWEAKNESS); - CurseOfWeakness_Timer = 45000; - }else CurseOfWeakness_Timer -= diff; - - //DemonArmor_Timer - if (DemonArmor_Timer < diff) - { - DoCast(m_creature,SPELL_DEMONARMOR); - DemonArmor_Timer = 300000; - }else DemonArmor_Timer -= diff; - - //EnvelopingWeb_Timer - if (EnvelopingWeb_Timer < diff) - { - Unit* target = NULL; - target = SelectUnit(SELECT_TARGET_RANDOM,0); - if (target) DoCast(target,SPELL_ENVELOPINGWEB); - EnvelopingWeb_Timer = 12000; - }else EnvelopingWeb_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; -CreatureAI* GetAI_boss_anubshiah(Creature *_Creature) -{ - return new boss_anubshiahAI (_Creature); -} - -void AddSC_boss_anubshiah() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_anubshiah"; - newscript->GetAI = GetAI_boss_anubshiah; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Anubshiah +SD%Complete: 100 +SDComment: +SDCategory: Blackrock Depths +EndScriptData */ + +#include "precompiled.h" + +#define SPELL_SHADOWBOLT 17228 +#define SPELL_CURSEOFTONGUES 15470 +#define SPELL_CURSEOFWEAKNESS 17227 +#define SPELL_DEMONARMOR 11735 +#define SPELL_ENVELOPINGWEB 15471 + +struct MANGOS_DLL_DECL boss_anubshiahAI : public ScriptedAI +{ + boss_anubshiahAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 ShadowBolt_Timer; + uint32 CurseOfTongues_Timer; + uint32 CurseOfWeakness_Timer; + uint32 DemonArmor_Timer; + uint32 EnvelopingWeb_Timer; + + void Reset() + { + ShadowBolt_Timer = 7000; + CurseOfTongues_Timer = 24000; + CurseOfWeakness_Timer = 12000; + DemonArmor_Timer = 3000; + EnvelopingWeb_Timer = 16000; + } + + void Aggro(Unit *who) + { + } + + void UpdateAI(const uint32 diff) + { + //Return since we have no target + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + //ShadowBolt_Timer + if (ShadowBolt_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_SHADOWBOLT); + ShadowBolt_Timer = 7000; + }else ShadowBolt_Timer -= diff; + + //CurseOfTongues_Timer + if (CurseOfTongues_Timer < diff) + { + Unit* target = NULL; + target = SelectUnit(SELECT_TARGET_RANDOM,0); + if (target) DoCast(target,SPELL_CURSEOFTONGUES); + CurseOfTongues_Timer = 18000; + }else CurseOfTongues_Timer -= diff; + + //CurseOfWeakness_Timer + if (CurseOfWeakness_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_CURSEOFWEAKNESS); + CurseOfWeakness_Timer = 45000; + }else CurseOfWeakness_Timer -= diff; + + //DemonArmor_Timer + if (DemonArmor_Timer < diff) + { + DoCast(m_creature,SPELL_DEMONARMOR); + DemonArmor_Timer = 300000; + }else DemonArmor_Timer -= diff; + + //EnvelopingWeb_Timer + if (EnvelopingWeb_Timer < diff) + { + Unit* target = NULL; + target = SelectUnit(SELECT_TARGET_RANDOM,0); + if (target) DoCast(target,SPELL_ENVELOPINGWEB); + EnvelopingWeb_Timer = 12000; + }else EnvelopingWeb_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; +CreatureAI* GetAI_boss_anubshiah(Creature *_Creature) +{ + return new boss_anubshiahAI (_Creature); +} + +void AddSC_boss_anubshiah() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_anubshiah"; + newscript->GetAI = GetAI_boss_anubshiah; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/blackrock_depths/boss_doomrel.cpp b/src/bindings/scripts/scripts/zone/blackrock_depths/boss_doomrel.cpp index 2f70b4ee14c..12904fd886f 100644 --- a/src/bindings/scripts/scripts/zone/blackrock_depths/boss_doomrel.cpp +++ b/src/bindings/scripts/scripts/zone/blackrock_depths/boss_doomrel.cpp @@ -1,139 +1,139 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Doomrel -SD%Complete: 100 -SDComment: -SDCategory: Blackrock Depths -EndScriptData */ - -#include "precompiled.h" - -#define SPELL_SHADOWBOLTVOLLEY 17228 -#define SPELL_IMMOLATE 15505 -#define SPELL_CURSEOFWEAKNESS 17227 -#define SPELL_DEMONARMOR 11735 - -struct MANGOS_DLL_DECL boss_doomrelAI : public ScriptedAI -{ - boss_doomrelAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 ShadowVolley_Timer; - uint32 Immolate_Timer; - uint32 CurseOfWeakness_Timer; - uint32 DemonArmor_Timer; - bool Voidwalkers; - int Rand; - int RandX; - int RandY; - Creature* Summoned; - - void Reset() - { - ShadowVolley_Timer = 10000; - Immolate_Timer = 18000; - CurseOfWeakness_Timer = 5000; - DemonArmor_Timer = 16000; - Voidwalkers = false; - } - - void Aggro(Unit *who) - { - } - - void SummonVoidwalkers(Unit* victim) - { - Rand = rand()%5; - switch (rand()%2) - { - case 0: RandX = 0 - Rand; break; - case 1: RandX = 0 + Rand; break; - } - Rand = 0; - Rand = rand()%5; - switch (rand()%2) - { - case 0: RandY = 0 - Rand; break; - case 1: RandY = 0 + Rand; break; - } - Rand = 0; - Summoned = DoSpawnCreature(16119, RandX, RandY, 0, 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 120000); - if(Summoned) - ((CreatureAI*)Summoned->AI())->AttackStart(victim); - } - - void UpdateAI(const uint32 diff) - { - //Return since we have no target - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - //ShadowVolley_Timer - if (ShadowVolley_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_SHADOWBOLTVOLLEY); - ShadowVolley_Timer = 12000; - }else ShadowVolley_Timer -= diff; - - //Immolate_Timer - if (Immolate_Timer < diff) - { - Unit* target = NULL; - target = SelectUnit(SELECT_TARGET_RANDOM,0); - if (target)DoCast(target,SPELL_IMMOLATE); - Immolate_Timer = 25000; - }else Immolate_Timer -= diff; - - //CurseOfWeakness_Timer - if (CurseOfWeakness_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_CURSEOFWEAKNESS); - CurseOfWeakness_Timer = 45000; - }else CurseOfWeakness_Timer -= diff; - - //DemonArmor_Timer - if (DemonArmor_Timer < diff) - { - DoCast(m_creature,SPELL_DEMONARMOR); - DemonArmor_Timer = 300000; - }else DemonArmor_Timer -= diff; - - //Summon Voidwalkers - if (!Voidwalkers && m_creature->GetHealth()*100 / m_creature->GetMaxHealth() < 51 ) - { - SummonVoidwalkers(m_creature->getVictim()); - SummonVoidwalkers(m_creature->getVictim()); - SummonVoidwalkers(m_creature->getVictim()); - Voidwalkers = true; - } - - DoMeleeAttackIfReady(); - } -}; -CreatureAI* GetAI_boss_doomrel(Creature *_Creature) -{ - return new boss_doomrelAI (_Creature); -} - -void AddSC_boss_doomrel() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_doomrel"; - newscript->GetAI = GetAI_boss_doomrel; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Doomrel +SD%Complete: 100 +SDComment: +SDCategory: Blackrock Depths +EndScriptData */ + +#include "precompiled.h" + +#define SPELL_SHADOWBOLTVOLLEY 17228 +#define SPELL_IMMOLATE 15505 +#define SPELL_CURSEOFWEAKNESS 17227 +#define SPELL_DEMONARMOR 11735 + +struct MANGOS_DLL_DECL boss_doomrelAI : public ScriptedAI +{ + boss_doomrelAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 ShadowVolley_Timer; + uint32 Immolate_Timer; + uint32 CurseOfWeakness_Timer; + uint32 DemonArmor_Timer; + bool Voidwalkers; + int Rand; + int RandX; + int RandY; + Creature* Summoned; + + void Reset() + { + ShadowVolley_Timer = 10000; + Immolate_Timer = 18000; + CurseOfWeakness_Timer = 5000; + DemonArmor_Timer = 16000; + Voidwalkers = false; + } + + void Aggro(Unit *who) + { + } + + void SummonVoidwalkers(Unit* victim) + { + Rand = rand()%5; + switch (rand()%2) + { + case 0: RandX = 0 - Rand; break; + case 1: RandX = 0 + Rand; break; + } + Rand = 0; + Rand = rand()%5; + switch (rand()%2) + { + case 0: RandY = 0 - Rand; break; + case 1: RandY = 0 + Rand; break; + } + Rand = 0; + Summoned = DoSpawnCreature(16119, RandX, RandY, 0, 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 120000); + if(Summoned) + ((CreatureAI*)Summoned->AI())->AttackStart(victim); + } + + void UpdateAI(const uint32 diff) + { + //Return since we have no target + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + //ShadowVolley_Timer + if (ShadowVolley_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_SHADOWBOLTVOLLEY); + ShadowVolley_Timer = 12000; + }else ShadowVolley_Timer -= diff; + + //Immolate_Timer + if (Immolate_Timer < diff) + { + Unit* target = NULL; + target = SelectUnit(SELECT_TARGET_RANDOM,0); + if (target)DoCast(target,SPELL_IMMOLATE); + Immolate_Timer = 25000; + }else Immolate_Timer -= diff; + + //CurseOfWeakness_Timer + if (CurseOfWeakness_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_CURSEOFWEAKNESS); + CurseOfWeakness_Timer = 45000; + }else CurseOfWeakness_Timer -= diff; + + //DemonArmor_Timer + if (DemonArmor_Timer < diff) + { + DoCast(m_creature,SPELL_DEMONARMOR); + DemonArmor_Timer = 300000; + }else DemonArmor_Timer -= diff; + + //Summon Voidwalkers + if (!Voidwalkers && m_creature->GetHealth()*100 / m_creature->GetMaxHealth() < 51 ) + { + SummonVoidwalkers(m_creature->getVictim()); + SummonVoidwalkers(m_creature->getVictim()); + SummonVoidwalkers(m_creature->getVictim()); + Voidwalkers = true; + } + + DoMeleeAttackIfReady(); + } +}; +CreatureAI* GetAI_boss_doomrel(Creature *_Creature) +{ + return new boss_doomrelAI (_Creature); +} + +void AddSC_boss_doomrel() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_doomrel"; + newscript->GetAI = GetAI_boss_doomrel; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/blackrock_depths/boss_doperel.cpp b/src/bindings/scripts/scripts/zone/blackrock_depths/boss_doperel.cpp index 3aae6cb1adf..0696fdd7f30 100644 --- a/src/bindings/scripts/scripts/zone/blackrock_depths/boss_doperel.cpp +++ b/src/bindings/scripts/scripts/zone/blackrock_depths/boss_doperel.cpp @@ -1,91 +1,91 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Doperel -SD%Complete: 100 -SDComment: -SDCategory: Blackrock Depths -EndScriptData */ - -#include "precompiled.h" - -#define SPELL_SINISTERSTRIKE 15581 -#define SPELL_BACKSTAB 15582 -#define SPELL_GOUGE 13579 - -struct MANGOS_DLL_DECL boss_doperelAI : public ScriptedAI -{ - boss_doperelAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 SinisterStrike_Timer; - uint32 BackStab_Timer; - uint32 Gouge_Timer; - - void Reset() - { - SinisterStrike_Timer = 8000; - BackStab_Timer = 12000; - Gouge_Timer = 6000; - } - - void Aggro(Unit *who) - { - } - - void UpdateAI(const uint32 diff) - { - //Return since we have no target - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - //SinisterStrike_Timer - if (SinisterStrike_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_SINISTERSTRIKE); - SinisterStrike_Timer = 7000; - }else SinisterStrike_Timer -= diff; - - //BackStab_Timer - if (BackStab_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_BACKSTAB); - BackStab_Timer = 6000; - }else BackStab_Timer -= diff; - - //Gouge_Timer - if (Gouge_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_GOUGE); - Gouge_Timer = 8000; - }else Gouge_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; -CreatureAI* GetAI_boss_doperel(Creature *_Creature) -{ - return new boss_doperelAI (_Creature); -} - -void AddSC_boss_doperel() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_doperel"; - newscript->GetAI = GetAI_boss_doperel; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Doperel +SD%Complete: 100 +SDComment: +SDCategory: Blackrock Depths +EndScriptData */ + +#include "precompiled.h" + +#define SPELL_SINISTERSTRIKE 15581 +#define SPELL_BACKSTAB 15582 +#define SPELL_GOUGE 13579 + +struct MANGOS_DLL_DECL boss_doperelAI : public ScriptedAI +{ + boss_doperelAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 SinisterStrike_Timer; + uint32 BackStab_Timer; + uint32 Gouge_Timer; + + void Reset() + { + SinisterStrike_Timer = 8000; + BackStab_Timer = 12000; + Gouge_Timer = 6000; + } + + void Aggro(Unit *who) + { + } + + void UpdateAI(const uint32 diff) + { + //Return since we have no target + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + //SinisterStrike_Timer + if (SinisterStrike_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_SINISTERSTRIKE); + SinisterStrike_Timer = 7000; + }else SinisterStrike_Timer -= diff; + + //BackStab_Timer + if (BackStab_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_BACKSTAB); + BackStab_Timer = 6000; + }else BackStab_Timer -= diff; + + //Gouge_Timer + if (Gouge_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_GOUGE); + Gouge_Timer = 8000; + }else Gouge_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; +CreatureAI* GetAI_boss_doperel(Creature *_Creature) +{ + return new boss_doperelAI (_Creature); +} + +void AddSC_boss_doperel() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_doperel"; + newscript->GetAI = GetAI_boss_doperel; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/blackrock_depths/boss_emperor_dagran_thaurissan.cpp b/src/bindings/scripts/scripts/zone/blackrock_depths/boss_emperor_dagran_thaurissan.cpp index cd03b6c1894..5c5c3ff9109 100644 --- a/src/bindings/scripts/scripts/zone/blackrock_depths/boss_emperor_dagran_thaurissan.cpp +++ b/src/bindings/scripts/scripts/zone/blackrock_depths/boss_emperor_dagran_thaurissan.cpp @@ -1,104 +1,104 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Emperor_Dagran_Thaurissan -SD%Complete: 99 -SDComment: -SDCategory: Blackrock Depths -EndScriptData */ - -#include "precompiled.h" - -#define SPELL_HANDOFTHAURISSAN 17492 -#define SPELL_AVATAROFFLAME 15636 - -#define SAY_AGGRO "Come to aid the Throne!" -#define SAY_SLAY "Hail to the king, baby!" - -struct MANGOS_DLL_DECL boss_draganthaurissanAI : public ScriptedAI -{ - boss_draganthaurissanAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 HandOfThaurissan_Timer; - uint32 AvatarOfFlame_Timer; - //uint32 Counter; - - void Reset() - { - HandOfThaurissan_Timer = 4000; - AvatarOfFlame_Timer = 25000; - //Counter= 0; - } - - void Aggro(Unit *who) - { - DoYell(SAY_AGGRO,LANG_UNIVERSAL,NULL); - } - - void KilledUnit(Unit* victim) - { - DoYell(SAY_SLAY, LANG_UNIVERSAL, NULL); - } - - void UpdateAI(const uint32 diff) - { - //Return since we have no target - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - if (HandOfThaurissan_Timer < diff) - { - Unit* target = NULL; - target = SelectUnit(SELECT_TARGET_RANDOM,0); - if (target) DoCast(target,SPELL_HANDOFTHAURISSAN); - - //3 Hands of Thaurissan will be casted - //if (Counter < 3) - //{ - // HandOfThaurissan_Timer = 1000; - // Counter++; - //} - //else - //{ - HandOfThaurissan_Timer = 5000; - //Counter=0; - //} - }else HandOfThaurissan_Timer -= diff; - - //AvatarOfFlame_Timer - if (AvatarOfFlame_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_AVATAROFFLAME); - AvatarOfFlame_Timer = 18000; - }else AvatarOfFlame_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; -CreatureAI* GetAI_boss_draganthaurissan(Creature *_Creature) -{ - return new boss_draganthaurissanAI (_Creature); -} - -void AddSC_boss_draganthaurissan() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_emperor_dagran_thaurissan"; - newscript->GetAI = GetAI_boss_draganthaurissan; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Emperor_Dagran_Thaurissan +SD%Complete: 99 +SDComment: +SDCategory: Blackrock Depths +EndScriptData */ + +#include "precompiled.h" + +#define SPELL_HANDOFTHAURISSAN 17492 +#define SPELL_AVATAROFFLAME 15636 + +#define SAY_AGGRO "Come to aid the Throne!" +#define SAY_SLAY "Hail to the king, baby!" + +struct MANGOS_DLL_DECL boss_draganthaurissanAI : public ScriptedAI +{ + boss_draganthaurissanAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 HandOfThaurissan_Timer; + uint32 AvatarOfFlame_Timer; + //uint32 Counter; + + void Reset() + { + HandOfThaurissan_Timer = 4000; + AvatarOfFlame_Timer = 25000; + //Counter= 0; + } + + void Aggro(Unit *who) + { + DoYell(SAY_AGGRO,LANG_UNIVERSAL,NULL); + } + + void KilledUnit(Unit* victim) + { + DoYell(SAY_SLAY, LANG_UNIVERSAL, NULL); + } + + void UpdateAI(const uint32 diff) + { + //Return since we have no target + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + if (HandOfThaurissan_Timer < diff) + { + Unit* target = NULL; + target = SelectUnit(SELECT_TARGET_RANDOM,0); + if (target) DoCast(target,SPELL_HANDOFTHAURISSAN); + + //3 Hands of Thaurissan will be casted + //if (Counter < 3) + //{ + // HandOfThaurissan_Timer = 1000; + // Counter++; + //} + //else + //{ + HandOfThaurissan_Timer = 5000; + //Counter=0; + //} + }else HandOfThaurissan_Timer -= diff; + + //AvatarOfFlame_Timer + if (AvatarOfFlame_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_AVATAROFFLAME); + AvatarOfFlame_Timer = 18000; + }else AvatarOfFlame_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; +CreatureAI* GetAI_boss_draganthaurissan(Creature *_Creature) +{ + return new boss_draganthaurissanAI (_Creature); +} + +void AddSC_boss_draganthaurissan() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_emperor_dagran_thaurissan"; + newscript->GetAI = GetAI_boss_draganthaurissan; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/blackrock_depths/boss_general_angerforge.cpp b/src/bindings/scripts/scripts/zone/blackrock_depths/boss_general_angerforge.cpp index 2d481bdaeb0..470f04f1935 100644 --- a/src/bindings/scripts/scripts/zone/blackrock_depths/boss_general_angerforge.cpp +++ b/src/bindings/scripts/scripts/zone/blackrock_depths/boss_general_angerforge.cpp @@ -1,167 +1,167 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_General_Angerforge -SD%Complete: 100 -SDComment: -SDCategory: Blackrock Depths -EndScriptData */ - -#include "precompiled.h" - -#define SPELL_MIGHTYBLOW 14099 -#define SPELL_HAMSTRING 9080 -#define SPELL_CLEAVE 20691 - -struct MANGOS_DLL_DECL boss_general_angerforgeAI : public ScriptedAI -{ - boss_general_angerforgeAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 MightyBlow_Timer; - uint32 HamString_Timer; - uint32 Cleave_Timer; - uint32 Adds_Timer; - bool Medics; - int Rand1; - int Rand1X; - int Rand1Y; - int Rand2; - int Rand2X; - int Rand2Y; - Creature* SummonedAdds; - Creature* SummonedMedics; - - void Reset() - { - MightyBlow_Timer = 8000; - HamString_Timer = 12000; - Cleave_Timer = 16000; - Adds_Timer = 0; - Medics = false; - } - - void Aggro(Unit *who) - { - } - - void SummonAdds(Unit* victim) - { - Rand1 = rand()%15; - switch (rand()%2) - { - case 0: Rand1X = 0 - Rand1; break; - case 1: Rand1X = 0 + Rand1; break; - } - Rand1 = 0; - Rand1 = rand()%15; - switch (rand()%2) - { - case 0: Rand1Y = 0 - Rand1; break; - case 1: Rand1Y = 0 + Rand1; break; - } - Rand1 = 0; - SummonedAdds = DoSpawnCreature(8901, Rand1X, Rand1Y, 0, 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 120000); - if(SummonedAdds) - ((CreatureAI*)SummonedAdds->AI())->AttackStart(victim); - } - - void SummonMedics(Unit* victim) - { - Rand2 = rand()%10; - switch (rand()%2) - { - case 0: Rand2X = 0 - Rand2; break; - case 1: Rand2X = 0 + Rand2; break; - } - Rand2 = 0; - Rand2 = rand()%10; - switch (rand()%2) - { - case 0: Rand2Y = 0 - Rand2; break; - case 1: Rand2Y = 0 + Rand2; break; - } - Rand2 = 0; - SummonedMedics = DoSpawnCreature(8894, Rand2X, Rand2Y, 0, 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 120000); - if(SummonedMedics) - ((CreatureAI*)SummonedMedics->AI())->AttackStart(victim); - } - - void UpdateAI(const uint32 diff) - { - //Return since we have no target - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - //MightyBlow_Timer - if (MightyBlow_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_MIGHTYBLOW); - MightyBlow_Timer = 18000; - }else MightyBlow_Timer -= diff; - - //HamString_Timer - if (HamString_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_HAMSTRING); - HamString_Timer = 15000; - }else HamString_Timer -= diff; - - //Cleave_Timer - if (Cleave_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_CLEAVE); - Cleave_Timer = 9000; - }else Cleave_Timer -= diff; - - //Adds_Timer - if ( m_creature->GetHealth()*100 / m_creature->GetMaxHealth() < 21 ) - { - if (Adds_Timer < diff) - { - // summon 3 Adds every 25s - SummonAdds(m_creature->getVictim()); - SummonAdds(m_creature->getVictim()); - SummonAdds(m_creature->getVictim()); - - Adds_Timer = 25000; - } else Adds_Timer -= diff; - } - - //Summon Medics - if ( !Medics && m_creature->GetHealth()*100 / m_creature->GetMaxHealth() < 21 ) - { - SummonMedics(m_creature->getVictim()); - SummonMedics(m_creature->getVictim()); - Medics = true; - } - - DoMeleeAttackIfReady(); - } -}; -CreatureAI* GetAI_boss_general_angerforge(Creature *_Creature) -{ - return new boss_general_angerforgeAI (_Creature); -} - -void AddSC_boss_general_angerforge() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_general_angerforge"; - newscript->GetAI = GetAI_boss_general_angerforge; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_General_Angerforge +SD%Complete: 100 +SDComment: +SDCategory: Blackrock Depths +EndScriptData */ + +#include "precompiled.h" + +#define SPELL_MIGHTYBLOW 14099 +#define SPELL_HAMSTRING 9080 +#define SPELL_CLEAVE 20691 + +struct MANGOS_DLL_DECL boss_general_angerforgeAI : public ScriptedAI +{ + boss_general_angerforgeAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 MightyBlow_Timer; + uint32 HamString_Timer; + uint32 Cleave_Timer; + uint32 Adds_Timer; + bool Medics; + int Rand1; + int Rand1X; + int Rand1Y; + int Rand2; + int Rand2X; + int Rand2Y; + Creature* SummonedAdds; + Creature* SummonedMedics; + + void Reset() + { + MightyBlow_Timer = 8000; + HamString_Timer = 12000; + Cleave_Timer = 16000; + Adds_Timer = 0; + Medics = false; + } + + void Aggro(Unit *who) + { + } + + void SummonAdds(Unit* victim) + { + Rand1 = rand()%15; + switch (rand()%2) + { + case 0: Rand1X = 0 - Rand1; break; + case 1: Rand1X = 0 + Rand1; break; + } + Rand1 = 0; + Rand1 = rand()%15; + switch (rand()%2) + { + case 0: Rand1Y = 0 - Rand1; break; + case 1: Rand1Y = 0 + Rand1; break; + } + Rand1 = 0; + SummonedAdds = DoSpawnCreature(8901, Rand1X, Rand1Y, 0, 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 120000); + if(SummonedAdds) + ((CreatureAI*)SummonedAdds->AI())->AttackStart(victim); + } + + void SummonMedics(Unit* victim) + { + Rand2 = rand()%10; + switch (rand()%2) + { + case 0: Rand2X = 0 - Rand2; break; + case 1: Rand2X = 0 + Rand2; break; + } + Rand2 = 0; + Rand2 = rand()%10; + switch (rand()%2) + { + case 0: Rand2Y = 0 - Rand2; break; + case 1: Rand2Y = 0 + Rand2; break; + } + Rand2 = 0; + SummonedMedics = DoSpawnCreature(8894, Rand2X, Rand2Y, 0, 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 120000); + if(SummonedMedics) + ((CreatureAI*)SummonedMedics->AI())->AttackStart(victim); + } + + void UpdateAI(const uint32 diff) + { + //Return since we have no target + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + //MightyBlow_Timer + if (MightyBlow_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_MIGHTYBLOW); + MightyBlow_Timer = 18000; + }else MightyBlow_Timer -= diff; + + //HamString_Timer + if (HamString_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_HAMSTRING); + HamString_Timer = 15000; + }else HamString_Timer -= diff; + + //Cleave_Timer + if (Cleave_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_CLEAVE); + Cleave_Timer = 9000; + }else Cleave_Timer -= diff; + + //Adds_Timer + if ( m_creature->GetHealth()*100 / m_creature->GetMaxHealth() < 21 ) + { + if (Adds_Timer < diff) + { + // summon 3 Adds every 25s + SummonAdds(m_creature->getVictim()); + SummonAdds(m_creature->getVictim()); + SummonAdds(m_creature->getVictim()); + + Adds_Timer = 25000; + } else Adds_Timer -= diff; + } + + //Summon Medics + if ( !Medics && m_creature->GetHealth()*100 / m_creature->GetMaxHealth() < 21 ) + { + SummonMedics(m_creature->getVictim()); + SummonMedics(m_creature->getVictim()); + Medics = true; + } + + DoMeleeAttackIfReady(); + } +}; +CreatureAI* GetAI_boss_general_angerforge(Creature *_Creature) +{ + return new boss_general_angerforgeAI (_Creature); +} + +void AddSC_boss_general_angerforge() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_general_angerforge"; + newscript->GetAI = GetAI_boss_general_angerforge; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/blackrock_depths/boss_gloomrel.cpp b/src/bindings/scripts/scripts/zone/blackrock_depths/boss_gloomrel.cpp index cb87855ee53..da40615d101 100644 --- a/src/bindings/scripts/scripts/zone/blackrock_depths/boss_gloomrel.cpp +++ b/src/bindings/scripts/scripts/zone/blackrock_depths/boss_gloomrel.cpp @@ -1,142 +1,142 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Gloomrel -SD%Complete: 80 -SDComment: Learning Smelt Dark Iron if tribute quest rewarded. Missing event and re-spawn GO Spectral Chalice -SDCategory: Blackrock Depths -EndScriptData */ - -#include "precompiled.h" - -#define SPELL_HAMSTRING 9080 -#define SPELL_CLEAVE 15579 -#define SPELL_MORTALSTRIKE 15708 - -struct MANGOS_DLL_DECL boss_gloomrelAI : public ScriptedAI -{ - boss_gloomrelAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 HamString_Timer; - uint32 Cleave_Timer; - uint32 MortalStrike_Timer; - - void Reset() - { - HamString_Timer = 19000; - Cleave_Timer = 6000; - MortalStrike_Timer = 10000; - - m_creature->setFaction(734); - } - - void Aggro(Unit *who) - { - } - - void UpdateAI(const uint32 diff) - { - //Return since we have no target - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - //HamString_Timer - if (HamString_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_HAMSTRING); - HamString_Timer = 14000; - }else HamString_Timer -= diff; - - //Cleave_Timer - if (Cleave_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_CLEAVE); - Cleave_Timer = 8000; - }else Cleave_Timer -= diff; - - //MortalStrike_Timer - if (MortalStrike_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_MORTALSTRIKE); - MortalStrike_Timer = 12000; - }else MortalStrike_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; -CreatureAI* GetAI_boss_gloomrel(Creature *_Creature) -{ - return new boss_gloomrelAI (_Creature); -} - -bool GossipHello_boss_gloomrel(Player *player, Creature *_Creature) -{ - if (player->GetQuestRewardStatus(4083) == 1 && player->GetSkillValue(SKILL_MINING) >= 230 && !player->HasSpell(14891) ) - player->ADD_GOSSIP_ITEM(0, "Teach me the art of smelting dark iron", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); - - if (player->GetQuestRewardStatus(4083) == 0 && player->GetSkillValue(SKILL_MINING) >= 230) - player->ADD_GOSSIP_ITEM(0, "I want to pay tribute", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2); - - player->ADD_GOSSIP_ITEM(0, "Challenge", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 3); - player->SEND_GOSSIP_MENU(2602, _Creature->GetGUID()); - - return true; -} - -bool GossipSelect_boss_gloomrel(Player *player, Creature *_Creature, uint32 sender, uint32 action ) -{ - switch (action) - { - case GOSSIP_ACTION_INFO_DEF+1: - player->ADD_GOSSIP_ITEM( 0, "Continue...", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 11); - player->SEND_GOSSIP_MENU(2606, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+11: - player->CLOSE_GOSSIP_MENU(); - _Creature->CastSpell(player, 14894, false); - break; - case GOSSIP_ACTION_INFO_DEF+2: - player->ADD_GOSSIP_ITEM( 0, "[PH] Continue...", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 22); - player->SEND_GOSSIP_MENU(2604, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+22: - player->CLOSE_GOSSIP_MENU(); - //re-spawn object here - break; - case GOSSIP_ACTION_INFO_DEF+3: - player->ADD_GOSSIP_ITEM( 0, "[PH] Continue...", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 33); - player->SEND_GOSSIP_MENU(2605, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+33: - player->CLOSE_GOSSIP_MENU(); - //start event here, below code just temporary - _Creature->setFaction(754); - break; - } - return true; -} - -void AddSC_boss_gloomrel() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_gloomrel"; - newscript->GetAI = GetAI_boss_gloomrel; - newscript->pGossipHello = &GossipHello_boss_gloomrel; - newscript->pGossipSelect = &GossipSelect_boss_gloomrel; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Gloomrel +SD%Complete: 80 +SDComment: Learning Smelt Dark Iron if tribute quest rewarded. Missing event and re-spawn GO Spectral Chalice +SDCategory: Blackrock Depths +EndScriptData */ + +#include "precompiled.h" + +#define SPELL_HAMSTRING 9080 +#define SPELL_CLEAVE 15579 +#define SPELL_MORTALSTRIKE 15708 + +struct MANGOS_DLL_DECL boss_gloomrelAI : public ScriptedAI +{ + boss_gloomrelAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 HamString_Timer; + uint32 Cleave_Timer; + uint32 MortalStrike_Timer; + + void Reset() + { + HamString_Timer = 19000; + Cleave_Timer = 6000; + MortalStrike_Timer = 10000; + + m_creature->setFaction(734); + } + + void Aggro(Unit *who) + { + } + + void UpdateAI(const uint32 diff) + { + //Return since we have no target + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + //HamString_Timer + if (HamString_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_HAMSTRING); + HamString_Timer = 14000; + }else HamString_Timer -= diff; + + //Cleave_Timer + if (Cleave_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_CLEAVE); + Cleave_Timer = 8000; + }else Cleave_Timer -= diff; + + //MortalStrike_Timer + if (MortalStrike_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_MORTALSTRIKE); + MortalStrike_Timer = 12000; + }else MortalStrike_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; +CreatureAI* GetAI_boss_gloomrel(Creature *_Creature) +{ + return new boss_gloomrelAI (_Creature); +} + +bool GossipHello_boss_gloomrel(Player *player, Creature *_Creature) +{ + if (player->GetQuestRewardStatus(4083) == 1 && player->GetSkillValue(SKILL_MINING) >= 230 && !player->HasSpell(14891) ) + player->ADD_GOSSIP_ITEM(0, "Teach me the art of smelting dark iron", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); + + if (player->GetQuestRewardStatus(4083) == 0 && player->GetSkillValue(SKILL_MINING) >= 230) + player->ADD_GOSSIP_ITEM(0, "I want to pay tribute", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2); + + player->ADD_GOSSIP_ITEM(0, "Challenge", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 3); + player->SEND_GOSSIP_MENU(2602, _Creature->GetGUID()); + + return true; +} + +bool GossipSelect_boss_gloomrel(Player *player, Creature *_Creature, uint32 sender, uint32 action ) +{ + switch (action) + { + case GOSSIP_ACTION_INFO_DEF+1: + player->ADD_GOSSIP_ITEM( 0, "Continue...", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 11); + player->SEND_GOSSIP_MENU(2606, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+11: + player->CLOSE_GOSSIP_MENU(); + _Creature->CastSpell(player, 14894, false); + break; + case GOSSIP_ACTION_INFO_DEF+2: + player->ADD_GOSSIP_ITEM( 0, "[PH] Continue...", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 22); + player->SEND_GOSSIP_MENU(2604, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+22: + player->CLOSE_GOSSIP_MENU(); + //re-spawn object here + break; + case GOSSIP_ACTION_INFO_DEF+3: + player->ADD_GOSSIP_ITEM( 0, "[PH] Continue...", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 33); + player->SEND_GOSSIP_MENU(2605, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+33: + player->CLOSE_GOSSIP_MENU(); + //start event here, below code just temporary + _Creature->setFaction(754); + break; + } + return true; +} + +void AddSC_boss_gloomrel() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_gloomrel"; + newscript->GetAI = GetAI_boss_gloomrel; + newscript->pGossipHello = &GossipHello_boss_gloomrel; + newscript->pGossipSelect = &GossipSelect_boss_gloomrel; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/blackrock_depths/boss_gorosh_the_dervish.cpp b/src/bindings/scripts/scripts/zone/blackrock_depths/boss_gorosh_the_dervish.cpp index df67093e61f..98f20a07222 100644 --- a/src/bindings/scripts/scripts/zone/blackrock_depths/boss_gorosh_the_dervish.cpp +++ b/src/bindings/scripts/scripts/zone/blackrock_depths/boss_gorosh_the_dervish.cpp @@ -1,81 +1,81 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Gorosh_the_Dervish -SD%Complete: 100 -SDComment: -SDCategory: Blackrock Depths -EndScriptData */ - -#include "precompiled.h" - -#define SPELL_WHIRLWIND 15589 -#define SPELL_MORTALSTRIKE 24573 - -struct MANGOS_DLL_DECL boss_gorosh_the_dervishAI : public ScriptedAI -{ - boss_gorosh_the_dervishAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 WhirlWind_Timer; - uint32 MortalStrike_Timer; - - void Reset() - { - WhirlWind_Timer = 12000; - MortalStrike_Timer = 22000; - } - - void Aggro(Unit *who) - { - } - - void UpdateAI(const uint32 diff) - { - //Return since we have no target - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - //WhirlWind_Timer - if (WhirlWind_Timer < diff) - { - DoCast(m_creature,SPELL_WHIRLWIND); - WhirlWind_Timer = 15000; - }else WhirlWind_Timer -= diff; - - //MortalStrike_Timer - if (MortalStrike_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_MORTALSTRIKE); - MortalStrike_Timer = 15000; - }else MortalStrike_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; -CreatureAI* GetAI_boss_gorosh_the_dervish(Creature *_Creature) -{ - return new boss_gorosh_the_dervishAI (_Creature); -} - -void AddSC_boss_gorosh_the_dervish() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_gorosh_the_dervish"; - newscript->GetAI = GetAI_boss_gorosh_the_dervish; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Gorosh_the_Dervish +SD%Complete: 100 +SDComment: +SDCategory: Blackrock Depths +EndScriptData */ + +#include "precompiled.h" + +#define SPELL_WHIRLWIND 15589 +#define SPELL_MORTALSTRIKE 24573 + +struct MANGOS_DLL_DECL boss_gorosh_the_dervishAI : public ScriptedAI +{ + boss_gorosh_the_dervishAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 WhirlWind_Timer; + uint32 MortalStrike_Timer; + + void Reset() + { + WhirlWind_Timer = 12000; + MortalStrike_Timer = 22000; + } + + void Aggro(Unit *who) + { + } + + void UpdateAI(const uint32 diff) + { + //Return since we have no target + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + //WhirlWind_Timer + if (WhirlWind_Timer < diff) + { + DoCast(m_creature,SPELL_WHIRLWIND); + WhirlWind_Timer = 15000; + }else WhirlWind_Timer -= diff; + + //MortalStrike_Timer + if (MortalStrike_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_MORTALSTRIKE); + MortalStrike_Timer = 15000; + }else MortalStrike_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; +CreatureAI* GetAI_boss_gorosh_the_dervish(Creature *_Creature) +{ + return new boss_gorosh_the_dervishAI (_Creature); +} + +void AddSC_boss_gorosh_the_dervish() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_gorosh_the_dervish"; + newscript->GetAI = GetAI_boss_gorosh_the_dervish; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/blackrock_depths/boss_grizzle.cpp b/src/bindings/scripts/scripts/zone/blackrock_depths/boss_grizzle.cpp index 7e248c2d17b..c859b3c1f0b 100644 --- a/src/bindings/scripts/scripts/zone/blackrock_depths/boss_grizzle.cpp +++ b/src/bindings/scripts/scripts/zone/blackrock_depths/boss_grizzle.cpp @@ -1,86 +1,86 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Grizzle -SD%Complete: 100 -SDComment: -SDCategory: Blackrock Depths -EndScriptData */ - -#include "precompiled.h" - -#define SPELL_GROUNDTREMOR 6524 -#define SPELL_FRENZY 28371 - -struct MANGOS_DLL_DECL boss_grizzleAI : public ScriptedAI -{ - boss_grizzleAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 GroundTremor_Timer; - uint32 Frenzy_Timer; - - void Reset() - { - GroundTremor_Timer = 12000; - Frenzy_Timer =0; - } - - void Aggro(Unit *who) - { - } - - void UpdateAI(const uint32 diff) - { - //Return since we have no target - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - //GroundTremor_Timer - if (GroundTremor_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_GROUNDTREMOR); - GroundTremor_Timer = 8000; - }else GroundTremor_Timer -= diff; - - //Frenzy_Timer - if ( m_creature->GetHealth()*100 / m_creature->GetMaxHealth() < 51 ) - { - if (Frenzy_Timer < diff) - { - DoCast(m_creature,SPELL_FRENZY); - DoTextEmote("goes into a killing frenzy!",NULL); - - Frenzy_Timer = 15000; - }else Frenzy_Timer -= diff; - } - - DoMeleeAttackIfReady(); - } -}; -CreatureAI* GetAI_boss_grizzle(Creature *_Creature) -{ - return new boss_grizzleAI (_Creature); -} - -void AddSC_boss_grizzle() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_grizzle"; - newscript->GetAI = GetAI_boss_grizzle; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Grizzle +SD%Complete: 100 +SDComment: +SDCategory: Blackrock Depths +EndScriptData */ + +#include "precompiled.h" + +#define SPELL_GROUNDTREMOR 6524 +#define SPELL_FRENZY 28371 + +struct MANGOS_DLL_DECL boss_grizzleAI : public ScriptedAI +{ + boss_grizzleAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 GroundTremor_Timer; + uint32 Frenzy_Timer; + + void Reset() + { + GroundTremor_Timer = 12000; + Frenzy_Timer =0; + } + + void Aggro(Unit *who) + { + } + + void UpdateAI(const uint32 diff) + { + //Return since we have no target + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + //GroundTremor_Timer + if (GroundTremor_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_GROUNDTREMOR); + GroundTremor_Timer = 8000; + }else GroundTremor_Timer -= diff; + + //Frenzy_Timer + if ( m_creature->GetHealth()*100 / m_creature->GetMaxHealth() < 51 ) + { + if (Frenzy_Timer < diff) + { + DoCast(m_creature,SPELL_FRENZY); + DoTextEmote("goes into a killing frenzy!",NULL); + + Frenzy_Timer = 15000; + }else Frenzy_Timer -= diff; + } + + DoMeleeAttackIfReady(); + } +}; +CreatureAI* GetAI_boss_grizzle(Creature *_Creature) +{ + return new boss_grizzleAI (_Creature); +} + +void AddSC_boss_grizzle() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_grizzle"; + newscript->GetAI = GetAI_boss_grizzle; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/blackrock_depths/boss_haterel.cpp b/src/bindings/scripts/scripts/zone/blackrock_depths/boss_haterel.cpp index 1392eb54943..35a97f0fd46 100644 --- a/src/bindings/scripts/scripts/zone/blackrock_depths/boss_haterel.cpp +++ b/src/bindings/scripts/scripts/zone/blackrock_depths/boss_haterel.cpp @@ -1,105 +1,105 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Haterel -SD%Complete: 100 -SDComment: -SDCategory: Blackrock Depths -EndScriptData */ - -#include "precompiled.h" - -#define SPELL_SHADOWBOLT 17483 //Not sure if right ID -#define SPELL_MANABURN 10876 -#define SPELL_SHADOWSHIELD 22417 -#define SPELL_STRIKE 15580 - -struct MANGOS_DLL_DECL boss_haterelAI : public ScriptedAI -{ - boss_haterelAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 ShadowBolt_Timer; - uint32 ManaBurn_Timer; - uint32 ShadowShield_Timer; - uint32 Strike_Timer; - - void Reset() - { - ShadowBolt_Timer = 15000; - ManaBurn_Timer = 3000; - ShadowShield_Timer = 8000; - Strike_Timer = 12000; - } - - void Aggro(Unit *who) - { - } - void UpdateAI(const uint32 diff) - { - //Return since we have no target - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - //ShadowBolt_Timer - if (ShadowBolt_Timer < diff) - { - Unit* target = NULL; - target = SelectUnit(SELECT_TARGET_RANDOM,0); - if (target) DoCast(target,SPELL_SHADOWBOLT); - ShadowBolt_Timer = 7000; - }else ShadowBolt_Timer -= diff; - - //ManaBurn_Timer - if (ManaBurn_Timer < diff) - { - Unit* target = NULL; - target = SelectUnit(SELECT_TARGET_RANDOM,0); - if (target) DoCast(target,SPELL_MANABURN); - ManaBurn_Timer = 13000; - }else ManaBurn_Timer -= diff; - - //ShadowShield_Timer - if (ShadowShield_Timer < diff) - { - DoCast(m_creature,SPELL_SHADOWSHIELD); - ShadowShield_Timer = 25000; - }else ShadowShield_Timer -= diff; - - //Strike_Timer - if (Strike_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_STRIKE); - Strike_Timer = 10000; - }else Strike_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; - -CreatureAI* GetAI_boss_haterel(Creature *_Creature) -{ - return new boss_haterelAI (_Creature); -} - -void AddSC_boss_haterel() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_haterel"; - newscript->GetAI = GetAI_boss_haterel; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Haterel +SD%Complete: 100 +SDComment: +SDCategory: Blackrock Depths +EndScriptData */ + +#include "precompiled.h" + +#define SPELL_SHADOWBOLT 17483 //Not sure if right ID +#define SPELL_MANABURN 10876 +#define SPELL_SHADOWSHIELD 22417 +#define SPELL_STRIKE 15580 + +struct MANGOS_DLL_DECL boss_haterelAI : public ScriptedAI +{ + boss_haterelAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 ShadowBolt_Timer; + uint32 ManaBurn_Timer; + uint32 ShadowShield_Timer; + uint32 Strike_Timer; + + void Reset() + { + ShadowBolt_Timer = 15000; + ManaBurn_Timer = 3000; + ShadowShield_Timer = 8000; + Strike_Timer = 12000; + } + + void Aggro(Unit *who) + { + } + void UpdateAI(const uint32 diff) + { + //Return since we have no target + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + //ShadowBolt_Timer + if (ShadowBolt_Timer < diff) + { + Unit* target = NULL; + target = SelectUnit(SELECT_TARGET_RANDOM,0); + if (target) DoCast(target,SPELL_SHADOWBOLT); + ShadowBolt_Timer = 7000; + }else ShadowBolt_Timer -= diff; + + //ManaBurn_Timer + if (ManaBurn_Timer < diff) + { + Unit* target = NULL; + target = SelectUnit(SELECT_TARGET_RANDOM,0); + if (target) DoCast(target,SPELL_MANABURN); + ManaBurn_Timer = 13000; + }else ManaBurn_Timer -= diff; + + //ShadowShield_Timer + if (ShadowShield_Timer < diff) + { + DoCast(m_creature,SPELL_SHADOWSHIELD); + ShadowShield_Timer = 25000; + }else ShadowShield_Timer -= diff; + + //Strike_Timer + if (Strike_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_STRIKE); + Strike_Timer = 10000; + }else Strike_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; + +CreatureAI* GetAI_boss_haterel(Creature *_Creature) +{ + return new boss_haterelAI (_Creature); +} + +void AddSC_boss_haterel() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_haterel"; + newscript->GetAI = GetAI_boss_haterel; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/blackrock_depths/boss_high_interrogator_gerstahn.cpp b/src/bindings/scripts/scripts/zone/blackrock_depths/boss_high_interrogator_gerstahn.cpp index c4393560d10..12c377ab791 100644 --- a/src/bindings/scripts/scripts/zone/blackrock_depths/boss_high_interrogator_gerstahn.cpp +++ b/src/bindings/scripts/scripts/zone/blackrock_depths/boss_high_interrogator_gerstahn.cpp @@ -1,105 +1,105 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_High_Interrogator_Gerstahn -SD%Complete: 100 -SDComment: -SDCategory: Blackrock Depths -EndScriptData */ - -#include "precompiled.h" - -#define SPELL_SHADOWWORDPAIN 10894 -#define SPELL_MANABURN 10876 -#define SPELL_PSYCHICSCREAM 8122 -#define SPELL_SHADOWSHIELD 22417 - -struct MANGOS_DLL_DECL boss_high_interrogator_gerstahnAI : public ScriptedAI -{ - boss_high_interrogator_gerstahnAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 ShadowWordPain_Timer; - uint32 ManaBurn_Timer; - uint32 PsychicScream_Timer; - uint32 ShadowShield_Timer; - - void Reset() - { - ShadowWordPain_Timer = 4000; - ManaBurn_Timer = 14000; - PsychicScream_Timer = 32000; - ShadowShield_Timer = 8000; - } - - void Aggro(Unit *who) - { - } - - void UpdateAI(const uint32 diff) - { - //Return since we have no target - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - //ShadowWordPain_Timer - if (ShadowWordPain_Timer < diff) - { - Unit* target = NULL; - target = SelectUnit(SELECT_TARGET_RANDOM,0); - if (target)DoCast(target,SPELL_SHADOWWORDPAIN); - ShadowWordPain_Timer = 7000; - }else ShadowWordPain_Timer -= diff; - - //ManaBurn_Timer - if (ManaBurn_Timer < diff) - { - Unit* target = NULL; - target = SelectUnit(SELECT_TARGET_RANDOM,0); - if (target)DoCast(target,SPELL_MANABURN); - ManaBurn_Timer = 10000; - }else ManaBurn_Timer -= diff; - - //PsychicScream_Timer - if (PsychicScream_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_PSYCHICSCREAM); - PsychicScream_Timer = 30000; - }else PsychicScream_Timer -= diff; - - //ShadowShield_Timer - if (ShadowShield_Timer < diff) - { - DoCast(m_creature,SPELL_SHADOWSHIELD); - ShadowShield_Timer = 25000; - }else ShadowShield_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; -CreatureAI* GetAI_boss_high_interrogator_gerstahn(Creature *_Creature) -{ - return new boss_high_interrogator_gerstahnAI (_Creature); -} - -void AddSC_boss_high_interrogator_gerstahn() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_high_interrogator_gerstahn"; - newscript->GetAI = GetAI_boss_high_interrogator_gerstahn; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_High_Interrogator_Gerstahn +SD%Complete: 100 +SDComment: +SDCategory: Blackrock Depths +EndScriptData */ + +#include "precompiled.h" + +#define SPELL_SHADOWWORDPAIN 10894 +#define SPELL_MANABURN 10876 +#define SPELL_PSYCHICSCREAM 8122 +#define SPELL_SHADOWSHIELD 22417 + +struct MANGOS_DLL_DECL boss_high_interrogator_gerstahnAI : public ScriptedAI +{ + boss_high_interrogator_gerstahnAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 ShadowWordPain_Timer; + uint32 ManaBurn_Timer; + uint32 PsychicScream_Timer; + uint32 ShadowShield_Timer; + + void Reset() + { + ShadowWordPain_Timer = 4000; + ManaBurn_Timer = 14000; + PsychicScream_Timer = 32000; + ShadowShield_Timer = 8000; + } + + void Aggro(Unit *who) + { + } + + void UpdateAI(const uint32 diff) + { + //Return since we have no target + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + //ShadowWordPain_Timer + if (ShadowWordPain_Timer < diff) + { + Unit* target = NULL; + target = SelectUnit(SELECT_TARGET_RANDOM,0); + if (target)DoCast(target,SPELL_SHADOWWORDPAIN); + ShadowWordPain_Timer = 7000; + }else ShadowWordPain_Timer -= diff; + + //ManaBurn_Timer + if (ManaBurn_Timer < diff) + { + Unit* target = NULL; + target = SelectUnit(SELECT_TARGET_RANDOM,0); + if (target)DoCast(target,SPELL_MANABURN); + ManaBurn_Timer = 10000; + }else ManaBurn_Timer -= diff; + + //PsychicScream_Timer + if (PsychicScream_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_PSYCHICSCREAM); + PsychicScream_Timer = 30000; + }else PsychicScream_Timer -= diff; + + //ShadowShield_Timer + if (ShadowShield_Timer < diff) + { + DoCast(m_creature,SPELL_SHADOWSHIELD); + ShadowShield_Timer = 25000; + }else ShadowShield_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; +CreatureAI* GetAI_boss_high_interrogator_gerstahn(Creature *_Creature) +{ + return new boss_high_interrogator_gerstahnAI (_Creature); +} + +void AddSC_boss_high_interrogator_gerstahn() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_high_interrogator_gerstahn"; + newscript->GetAI = GetAI_boss_high_interrogator_gerstahn; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/blackrock_depths/boss_magmus.cpp b/src/bindings/scripts/scripts/zone/blackrock_depths/boss_magmus.cpp index 62d2f6d8147..81f98559c1c 100644 --- a/src/bindings/scripts/scripts/zone/blackrock_depths/boss_magmus.cpp +++ b/src/bindings/scripts/scripts/zone/blackrock_depths/boss_magmus.cpp @@ -1,84 +1,84 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Magmus -SD%Complete: 100 -SDComment: -SDCategory: Blackrock Depths -EndScriptData */ - -#include "precompiled.h" - -#define SPELL_FIERYBURST 13900 -#define SPELL_WARSTOMP 24375 - -struct MANGOS_DLL_DECL boss_magmusAI : public ScriptedAI -{ - boss_magmusAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 FieryBurst_Timer; - uint32 WarStomp_Timer; - - void Reset() - { - FieryBurst_Timer = 5000; - WarStomp_Timer =0; - } - - void Aggro(Unit *who) - { - } - - void UpdateAI(const uint32 diff) - { - //Return since we have no target - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - //FieryBurst_Timer - if (FieryBurst_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_FIERYBURST); - FieryBurst_Timer = 6000; - }else FieryBurst_Timer -= diff; - - //WarStomp_Timer - if ( m_creature->GetHealth()*100 / m_creature->GetMaxHealth() < 51 ) - { - if (WarStomp_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_WARSTOMP); - WarStomp_Timer = 8000; - }else WarStomp_Timer -= diff; - } - - DoMeleeAttackIfReady(); - } -}; -CreatureAI* GetAI_boss_magmus(Creature *_Creature) -{ - return new boss_magmusAI (_Creature); -} - -void AddSC_boss_magmus() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_magmus"; - newscript->GetAI = GetAI_boss_magmus; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Magmus +SD%Complete: 100 +SDComment: +SDCategory: Blackrock Depths +EndScriptData */ + +#include "precompiled.h" + +#define SPELL_FIERYBURST 13900 +#define SPELL_WARSTOMP 24375 + +struct MANGOS_DLL_DECL boss_magmusAI : public ScriptedAI +{ + boss_magmusAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 FieryBurst_Timer; + uint32 WarStomp_Timer; + + void Reset() + { + FieryBurst_Timer = 5000; + WarStomp_Timer =0; + } + + void Aggro(Unit *who) + { + } + + void UpdateAI(const uint32 diff) + { + //Return since we have no target + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + //FieryBurst_Timer + if (FieryBurst_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_FIERYBURST); + FieryBurst_Timer = 6000; + }else FieryBurst_Timer -= diff; + + //WarStomp_Timer + if ( m_creature->GetHealth()*100 / m_creature->GetMaxHealth() < 51 ) + { + if (WarStomp_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_WARSTOMP); + WarStomp_Timer = 8000; + }else WarStomp_Timer -= diff; + } + + DoMeleeAttackIfReady(); + } +}; +CreatureAI* GetAI_boss_magmus(Creature *_Creature) +{ + return new boss_magmusAI (_Creature); +} + +void AddSC_boss_magmus() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_magmus"; + newscript->GetAI = GetAI_boss_magmus; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/blackrock_depths/boss_moira_bronzebeard.cpp b/src/bindings/scripts/scripts/zone/blackrock_depths/boss_moira_bronzebeard.cpp index b7dfadd385d..13129a0921c 100644 --- a/src/bindings/scripts/scripts/zone/blackrock_depths/boss_moira_bronzebeard.cpp +++ b/src/bindings/scripts/scripts/zone/blackrock_depths/boss_moira_bronzebeard.cpp @@ -1,99 +1,99 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Moira_Bronzbeard -SD%Complete: 90 -SDComment: Healing of Emperor NYI -SDCategory: Blackrock Depths -EndScriptData */ - -#include "precompiled.h" - -#define SPELL_HEAL 10917 -#define SPELL_RENEW 10929 -#define SPELL_SHIELD 10901 -#define SPELL_MINDBLAST 10947 -#define SPELL_SHADOWWORDPAIN 10894 -#define SPELL_SMITE 10934 - -struct MANGOS_DLL_DECL boss_moira_bronzebeardAI : public ScriptedAI -{ - boss_moira_bronzebeardAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 Heal_Timer; - uint32 MindBlast_Timer; - uint32 ShadowWordPain_Timer; - uint32 Smite_Timer; - Unit* PlayerHolder; - Unit* Target; - bool Heal; - - void Reset() - { - Target = NULL; - Heal_Timer = 12000; //These times are probably wrong - MindBlast_Timer = 16000; - ShadowWordPain_Timer = 2000; - Smite_Timer = 8000; - } - - void Aggro(Unit *who) - { - } - - void UpdateAI(const uint32 diff) - { - //Return since we have no target - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - //MindBlast_Timer - if (MindBlast_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_MINDBLAST); - MindBlast_Timer = 14000; - }else MindBlast_Timer -= diff; - - //ShadowWordPain_Timer - if (ShadowWordPain_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_SHADOWWORDPAIN); - ShadowWordPain_Timer = 18000; - }else ShadowWordPain_Timer -= diff; - - //Smite_Timer - if (Smite_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_SMITE); - Smite_Timer = 10000; - }else Smite_Timer -= diff; - - } -}; -CreatureAI* GetAI_boss_moira_bronzebeard(Creature *_Creature) -{ - return new boss_moira_bronzebeardAI (_Creature); -} - -void AddSC_boss_moira_bronzebeard() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_moira_bronzebeard"; - newscript->GetAI = GetAI_boss_moira_bronzebeard; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Moira_Bronzbeard +SD%Complete: 90 +SDComment: Healing of Emperor NYI +SDCategory: Blackrock Depths +EndScriptData */ + +#include "precompiled.h" + +#define SPELL_HEAL 10917 +#define SPELL_RENEW 10929 +#define SPELL_SHIELD 10901 +#define SPELL_MINDBLAST 10947 +#define SPELL_SHADOWWORDPAIN 10894 +#define SPELL_SMITE 10934 + +struct MANGOS_DLL_DECL boss_moira_bronzebeardAI : public ScriptedAI +{ + boss_moira_bronzebeardAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 Heal_Timer; + uint32 MindBlast_Timer; + uint32 ShadowWordPain_Timer; + uint32 Smite_Timer; + Unit* PlayerHolder; + Unit* Target; + bool Heal; + + void Reset() + { + Target = NULL; + Heal_Timer = 12000; //These times are probably wrong + MindBlast_Timer = 16000; + ShadowWordPain_Timer = 2000; + Smite_Timer = 8000; + } + + void Aggro(Unit *who) + { + } + + void UpdateAI(const uint32 diff) + { + //Return since we have no target + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + //MindBlast_Timer + if (MindBlast_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_MINDBLAST); + MindBlast_Timer = 14000; + }else MindBlast_Timer -= diff; + + //ShadowWordPain_Timer + if (ShadowWordPain_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_SHADOWWORDPAIN); + ShadowWordPain_Timer = 18000; + }else ShadowWordPain_Timer -= diff; + + //Smite_Timer + if (Smite_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_SMITE); + Smite_Timer = 10000; + }else Smite_Timer -= diff; + + } +}; +CreatureAI* GetAI_boss_moira_bronzebeard(Creature *_Creature) +{ + return new boss_moira_bronzebeardAI (_Creature); +} + +void AddSC_boss_moira_bronzebeard() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_moira_bronzebeard"; + newscript->GetAI = GetAI_boss_moira_bronzebeard; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/blackrock_depths/boss_seethrel.cpp b/src/bindings/scripts/scripts/zone/blackrock_depths/boss_seethrel.cpp index f1d703924fb..09552a28ca1 100644 --- a/src/bindings/scripts/scripts/zone/blackrock_depths/boss_seethrel.cpp +++ b/src/bindings/scripts/scripts/zone/blackrock_depths/boss_seethrel.cpp @@ -1,115 +1,115 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Seethrel -SD%Complete: 100 -SDComment: -SDCategory: Blackrock Depths -EndScriptData */ - -#include "precompiled.h" - -#define SPELL_FROSTBOLT 16799 -#define SPELL_FROSTARMOR 15784 //This is actually a buff he gives himself -#define SPELL_BLIZZARD 19099 -#define SPELL_FROSTNOVA 15063 -#define SPELL_FROSTWARD 15004 - -struct MANGOS_DLL_DECL boss_seethrelAI : public ScriptedAI -{ - boss_seethrelAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 FrostArmor_Timer; - uint32 Frostbolt_Timer; - uint32 Blizzard_Timer; - uint32 FrostNova_Timer; - uint32 FrostWard_Timer; - - void Reset() - { - FrostArmor_Timer = 2000; - Frostbolt_Timer = 6000; - Blizzard_Timer = 18000; - FrostNova_Timer = 12000; - FrostWard_Timer = 25000; - - m_creature->CastSpell(m_creature,SPELL_FROSTARMOR,true); - } - - void Aggro(Unit *who) - { - } - - void UpdateAI(const uint32 diff) - { - //Return since we have no target - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - //FrostArmor_Timer - if (FrostArmor_Timer < diff) - { - DoCast(m_creature, SPELL_FROSTARMOR); - FrostArmor_Timer = 180000; - }else FrostArmor_Timer -= diff; - - //Frostbolt_Timer - if (Frostbolt_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_FROSTBOLT); - Frostbolt_Timer = 15000; - }else Frostbolt_Timer -= diff; - - //Blizzard_Timer - if (Blizzard_Timer < diff) - { - Unit* target = NULL; - target = SelectUnit(SELECT_TARGET_RANDOM,0); - if (target) DoCast(target,SPELL_BLIZZARD); - Blizzard_Timer = 22000; - }else Blizzard_Timer -= diff; - - //FrostNova_Timer - if (FrostNova_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_FROSTNOVA); - FrostNova_Timer = 14000; - }else FrostNova_Timer -= diff; - - //FrostWard_Timer - if (FrostWard_Timer < diff) - { - DoCast(m_creature,SPELL_FROSTWARD); - FrostWard_Timer = 68000; - }else FrostWard_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; -CreatureAI* GetAI_boss_seethrel(Creature *_Creature) -{ - return new boss_seethrelAI (_Creature); -} - -void AddSC_boss_seethrel() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_seethrel"; - newscript->GetAI = GetAI_boss_seethrel; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Seethrel +SD%Complete: 100 +SDComment: +SDCategory: Blackrock Depths +EndScriptData */ + +#include "precompiled.h" + +#define SPELL_FROSTBOLT 16799 +#define SPELL_FROSTARMOR 15784 //This is actually a buff he gives himself +#define SPELL_BLIZZARD 19099 +#define SPELL_FROSTNOVA 15063 +#define SPELL_FROSTWARD 15004 + +struct MANGOS_DLL_DECL boss_seethrelAI : public ScriptedAI +{ + boss_seethrelAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 FrostArmor_Timer; + uint32 Frostbolt_Timer; + uint32 Blizzard_Timer; + uint32 FrostNova_Timer; + uint32 FrostWard_Timer; + + void Reset() + { + FrostArmor_Timer = 2000; + Frostbolt_Timer = 6000; + Blizzard_Timer = 18000; + FrostNova_Timer = 12000; + FrostWard_Timer = 25000; + + m_creature->CastSpell(m_creature,SPELL_FROSTARMOR,true); + } + + void Aggro(Unit *who) + { + } + + void UpdateAI(const uint32 diff) + { + //Return since we have no target + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + //FrostArmor_Timer + if (FrostArmor_Timer < diff) + { + DoCast(m_creature, SPELL_FROSTARMOR); + FrostArmor_Timer = 180000; + }else FrostArmor_Timer -= diff; + + //Frostbolt_Timer + if (Frostbolt_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_FROSTBOLT); + Frostbolt_Timer = 15000; + }else Frostbolt_Timer -= diff; + + //Blizzard_Timer + if (Blizzard_Timer < diff) + { + Unit* target = NULL; + target = SelectUnit(SELECT_TARGET_RANDOM,0); + if (target) DoCast(target,SPELL_BLIZZARD); + Blizzard_Timer = 22000; + }else Blizzard_Timer -= diff; + + //FrostNova_Timer + if (FrostNova_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_FROSTNOVA); + FrostNova_Timer = 14000; + }else FrostNova_Timer -= diff; + + //FrostWard_Timer + if (FrostWard_Timer < diff) + { + DoCast(m_creature,SPELL_FROSTWARD); + FrostWard_Timer = 68000; + }else FrostWard_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; +CreatureAI* GetAI_boss_seethrel(Creature *_Creature) +{ + return new boss_seethrelAI (_Creature); +} + +void AddSC_boss_seethrel() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_seethrel"; + newscript->GetAI = GetAI_boss_seethrel; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/blackrock_depths/boss_vilerel.cpp b/src/bindings/scripts/scripts/zone/blackrock_depths/boss_vilerel.cpp index 2c7508a0311..b2739617bf7 100644 --- a/src/bindings/scripts/scripts/zone/blackrock_depths/boss_vilerel.cpp +++ b/src/bindings/scripts/scripts/zone/blackrock_depths/boss_vilerel.cpp @@ -1,101 +1,101 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Vilerel -SD%Complete: 100 -SDComment: -SDCategory: Blackrock Depths -EndScriptData */ - -#include "precompiled.h" - -#define SPELL_MINDBLAST 15587 -#define SPELL_HEAL 15586 -#define SPELL_PRAYEROFHEALING 15585 -#define SPELL_SHIELD 10901 - -struct MANGOS_DLL_DECL boss_vilerelAI : public ScriptedAI -{ - boss_vilerelAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 MindBlast_Timer; - uint32 Heal_Timer; - uint32 PrayerOfHealing_Timer; - uint32 Shield_Timer; - - void Reset() - { - MindBlast_Timer = 10000; - Heal_Timer = 35000; - PrayerOfHealing_Timer = 25000; - Shield_Timer = 3000; - } - - void Aggro(Unit *who) - { - } - - void UpdateAI(const uint32 diff) - { - //Return since we have no target - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - //MindBlast_Timer - if (MindBlast_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_MINDBLAST); - MindBlast_Timer = 7000; - }else MindBlast_Timer -= diff; - - //Heal_Timer - if (Heal_Timer < diff) - { - DoCast(m_creature,SPELL_HEAL); - Heal_Timer = 20000; - }else Heal_Timer -= diff; - - //PrayerOfHealing_Timer - if (PrayerOfHealing_Timer < diff) - { - DoCast(m_creature,SPELL_PRAYEROFHEALING); - PrayerOfHealing_Timer = 30000; - }else PrayerOfHealing_Timer -= diff; - - //Shield_Timer - if (Shield_Timer < diff) - { - DoCast(m_creature,SPELL_SHIELD); - Shield_Timer = 30000; - }else Shield_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; -CreatureAI* GetAI_boss_vilerel(Creature *_Creature) -{ - return new boss_vilerelAI (_Creature); -} - -void AddSC_boss_vilerel() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_vilerel"; - newscript->GetAI = GetAI_boss_vilerel; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Vilerel +SD%Complete: 100 +SDComment: +SDCategory: Blackrock Depths +EndScriptData */ + +#include "precompiled.h" + +#define SPELL_MINDBLAST 15587 +#define SPELL_HEAL 15586 +#define SPELL_PRAYEROFHEALING 15585 +#define SPELL_SHIELD 10901 + +struct MANGOS_DLL_DECL boss_vilerelAI : public ScriptedAI +{ + boss_vilerelAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 MindBlast_Timer; + uint32 Heal_Timer; + uint32 PrayerOfHealing_Timer; + uint32 Shield_Timer; + + void Reset() + { + MindBlast_Timer = 10000; + Heal_Timer = 35000; + PrayerOfHealing_Timer = 25000; + Shield_Timer = 3000; + } + + void Aggro(Unit *who) + { + } + + void UpdateAI(const uint32 diff) + { + //Return since we have no target + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + //MindBlast_Timer + if (MindBlast_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_MINDBLAST); + MindBlast_Timer = 7000; + }else MindBlast_Timer -= diff; + + //Heal_Timer + if (Heal_Timer < diff) + { + DoCast(m_creature,SPELL_HEAL); + Heal_Timer = 20000; + }else Heal_Timer -= diff; + + //PrayerOfHealing_Timer + if (PrayerOfHealing_Timer < diff) + { + DoCast(m_creature,SPELL_PRAYEROFHEALING); + PrayerOfHealing_Timer = 30000; + }else PrayerOfHealing_Timer -= diff; + + //Shield_Timer + if (Shield_Timer < diff) + { + DoCast(m_creature,SPELL_SHIELD); + Shield_Timer = 30000; + }else Shield_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; +CreatureAI* GetAI_boss_vilerel(Creature *_Creature) +{ + return new boss_vilerelAI (_Creature); +} + +void AddSC_boss_vilerel() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_vilerel"; + newscript->GetAI = GetAI_boss_vilerel; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/blackrock_spire/boss_drakkisath.cpp b/src/bindings/scripts/scripts/zone/blackrock_spire/boss_drakkisath.cpp index a69334aeac8..830ae55dca8 100644 --- a/src/bindings/scripts/scripts/zone/blackrock_spire/boss_drakkisath.cpp +++ b/src/bindings/scripts/scripts/zone/blackrock_spire/boss_drakkisath.cpp @@ -1,101 +1,101 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Drakkisath -SD%Complete: 100 -SDComment: -SDCategory: Blackrock Spire -EndScriptData */ - -#include "precompiled.h" - -#define SPELL_FIRENOVA 23462 -#define SPELL_CLEAVE 20691 -#define SPELL_CONFLIGURATION 16805 -#define SPELL_THUNDERCLAP 15548 //Not sure if right ID. 23931 would be a harder possibility. - -struct MANGOS_DLL_DECL boss_drakkisathAI : public ScriptedAI -{ - boss_drakkisathAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 FireNova_Timer; - uint32 Cleave_Timer; - uint32 Confliguration_Timer; - uint32 Thunderclap_Timer; - - void Reset() - { - FireNova_Timer = 6000; - Cleave_Timer = 8000; - Confliguration_Timer = 15000; - Thunderclap_Timer = 17000; - } - - void Aggro(Unit *who) - { - } - - void UpdateAI(const uint32 diff) - { - //Return since we have no target - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - //FireNova_Timer - if (FireNova_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_FIRENOVA); - FireNova_Timer = 10000; - }else FireNova_Timer -= diff; - - //Cleave_Timer - if (Cleave_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_CLEAVE); - Cleave_Timer = 8000; - }else Cleave_Timer -= diff; - - //Confliguration_Timer - if (Confliguration_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_CONFLIGURATION); - Confliguration_Timer = 18000; - }else Confliguration_Timer -= diff; - - //Thunderclap_Timer - if (Thunderclap_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_THUNDERCLAP); - Thunderclap_Timer = 20000; - }else Thunderclap_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; -CreatureAI* GetAI_boss_drakkisath(Creature *_Creature) -{ - return new boss_drakkisathAI (_Creature); -} - -void AddSC_boss_drakkisath() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_drakkisath"; - newscript->GetAI = GetAI_boss_drakkisath; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Drakkisath +SD%Complete: 100 +SDComment: +SDCategory: Blackrock Spire +EndScriptData */ + +#include "precompiled.h" + +#define SPELL_FIRENOVA 23462 +#define SPELL_CLEAVE 20691 +#define SPELL_CONFLIGURATION 16805 +#define SPELL_THUNDERCLAP 15548 //Not sure if right ID. 23931 would be a harder possibility. + +struct MANGOS_DLL_DECL boss_drakkisathAI : public ScriptedAI +{ + boss_drakkisathAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 FireNova_Timer; + uint32 Cleave_Timer; + uint32 Confliguration_Timer; + uint32 Thunderclap_Timer; + + void Reset() + { + FireNova_Timer = 6000; + Cleave_Timer = 8000; + Confliguration_Timer = 15000; + Thunderclap_Timer = 17000; + } + + void Aggro(Unit *who) + { + } + + void UpdateAI(const uint32 diff) + { + //Return since we have no target + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + //FireNova_Timer + if (FireNova_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_FIRENOVA); + FireNova_Timer = 10000; + }else FireNova_Timer -= diff; + + //Cleave_Timer + if (Cleave_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_CLEAVE); + Cleave_Timer = 8000; + }else Cleave_Timer -= diff; + + //Confliguration_Timer + if (Confliguration_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_CONFLIGURATION); + Confliguration_Timer = 18000; + }else Confliguration_Timer -= diff; + + //Thunderclap_Timer + if (Thunderclap_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_THUNDERCLAP); + Thunderclap_Timer = 20000; + }else Thunderclap_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; +CreatureAI* GetAI_boss_drakkisath(Creature *_Creature) +{ + return new boss_drakkisathAI (_Creature); +} + +void AddSC_boss_drakkisath() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_drakkisath"; + newscript->GetAI = GetAI_boss_drakkisath; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/blackrock_spire/boss_gyth.cpp b/src/bindings/scripts/scripts/zone/blackrock_spire/boss_gyth.cpp index e2edaf7d07d..3bf3e6c922f 100644 --- a/src/bindings/scripts/scripts/zone/blackrock_spire/boss_gyth.cpp +++ b/src/bindings/scripts/scripts/zone/blackrock_spire/boss_gyth.cpp @@ -1,205 +1,205 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Gyth -SD%Complete: 100 -SDComment: -SDCategory: Blackrock Spire -EndScriptData */ - -#include "precompiled.h" - -#define SPELL_CORROSIVEACID 20667 -#define SPELL_FREEZE 18763 -#define SPELL_FLAMEBREATH 20712 - -struct MANGOS_DLL_DECL boss_gythAI : public ScriptedAI -{ - boss_gythAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 Aggro_Timer; - uint32 Dragons_Timer; - uint32 Orc_Timer; - uint32 CorrosiveAcid_Timer; - uint32 Freeze_Timer; - uint32 Flamebreath_Timer; - uint32 Line1Count; - uint32 Line2Count; - - bool Event; - bool SummonedDragons; - bool SummonedOrcs; - bool SummonedRend; - bool bAggro; - bool RootSelf; - Creature *SummonedCreature; - - void Reset() - { - Dragons_Timer = 3000; - Orc_Timer = 60000; - Aggro_Timer = 60000; - CorrosiveAcid_Timer = 8000; - Freeze_Timer = 11000; - Flamebreath_Timer = 4000; - Event = false; - SummonedDragons = false; - SummonedOrcs= false; - SummonedRend = false; - bAggro = false; - RootSelf = false; - - // how many times should the two lines of summoned creatures be spawned - // min 2 x 2, max 7 lines of attack in total - Line1Count = rand() % 4 + 2; - if (Line1Count < 5) - Line2Count = rand() % (5 - Line1Count) + 2; - else - Line2Count = 2; - - //Invisible for event start - m_creature->SetUInt32Value(UNIT_FIELD_DISPLAYID, 11686); - m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - } - - void Aggro(Unit *who) - { - } - - void SummonCreatureWithRandomTarget(uint32 creatureId) - { - Unit* Summoned = m_creature->SummonCreature(creatureId, m_creature->GetPositionX(), m_creature->GetPositionY(), m_creature->GetPositionZ(), 0, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 240000); - if (Summoned) - { - Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0); - if (target) - Summoned->AddThreat(target, 1.0f); - } - } - - void UpdateAI(const uint32 diff) - { - //char buf[200]; - - //Return since we have no target - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - if (!RootSelf) - { - //m_creature->m_canMove = true; - DoCast(m_creature, 33356); - RootSelf = true; - } - - if (!bAggro && Line1Count == 0 && Line2Count == 0) - { - if (Aggro_Timer < diff) - { - bAggro = true; - // Visible now! - m_creature->SetUInt32Value(UNIT_FIELD_DISPLAYID, 9723); - m_creature->setFaction(14); - m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - } else Aggro_Timer -= diff; - } - - // Summon Dragon pack. 2 Dragons and 3 Whelps - if (!bAggro && !SummonedRend && Line1Count > 0) - { - if (Dragons_Timer < diff) - { - SummonCreatureWithRandomTarget(10372); - SummonCreatureWithRandomTarget(10372); - SummonCreatureWithRandomTarget(10442); - SummonCreatureWithRandomTarget(10442); - SummonCreatureWithRandomTarget(10442); - Line1Count = Line1Count - 1; - Dragons_Timer = 60000; - } else Dragons_Timer -= diff; - } - - //Summon Orc pack. 1 Orc Handler 1 Elite Dragonkin and 3 Whelps - if (!bAggro && !SummonedRend && Line1Count == 0 && Line2Count > 0) - { - if (Orc_Timer < diff) - { - SummonCreatureWithRandomTarget(10447); - SummonCreatureWithRandomTarget(10317); - SummonCreatureWithRandomTarget(10442); - SummonCreatureWithRandomTarget(10442); - SummonCreatureWithRandomTarget(10442); - Line2Count = Line2Count - 1; - Orc_Timer = 60000; - } else Orc_Timer -= diff; - } - - // we take part in the fight - if (bAggro) - { - // CorrosiveAcid_Timer - if (CorrosiveAcid_Timer < diff) - { - DoCast(m_creature->getVictim(), SPELL_CORROSIVEACID); - CorrosiveAcid_Timer = 7000; - } else CorrosiveAcid_Timer -= diff; - - // Freeze_Timer - if (Freeze_Timer < diff) - { - DoCast(m_creature->getVictim(), SPELL_FREEZE); - Freeze_Timer = 16000; - } else Freeze_Timer -= diff; - - // Flamebreath_Timer - if (Flamebreath_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_FLAMEBREATH); - Flamebreath_Timer = 10500; - } else Flamebreath_Timer -= diff; - - //Summon Rend - if (!SummonedRend && m_creature->GetHealth()*100 / m_creature->GetMaxHealth() < 11 - && m_creature->GetHealth() > 0 ) - { - //summon Rend and Change model to normal Gyth - //Inturrupt any spell casting - m_creature->InterruptNonMeleeSpells(false); - //Gyth model - m_creature->SetUInt32Value(UNIT_FIELD_DISPLAYID, 9806); - m_creature->SummonCreature(10429, m_creature->GetPositionX(), m_creature->GetPositionY(), m_creature->GetPositionZ(), 0, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 900000); - SummonedRend = true; - } - - DoMeleeAttackIfReady(); - } // end if Aggro - } -}; - -CreatureAI* GetAI_boss_gyth(Creature *_Creature) -{ - return new boss_gythAI (_Creature); -} - -void AddSC_boss_gyth() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_gyth"; - newscript->GetAI = GetAI_boss_gyth; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Gyth +SD%Complete: 100 +SDComment: +SDCategory: Blackrock Spire +EndScriptData */ + +#include "precompiled.h" + +#define SPELL_CORROSIVEACID 20667 +#define SPELL_FREEZE 18763 +#define SPELL_FLAMEBREATH 20712 + +struct MANGOS_DLL_DECL boss_gythAI : public ScriptedAI +{ + boss_gythAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 Aggro_Timer; + uint32 Dragons_Timer; + uint32 Orc_Timer; + uint32 CorrosiveAcid_Timer; + uint32 Freeze_Timer; + uint32 Flamebreath_Timer; + uint32 Line1Count; + uint32 Line2Count; + + bool Event; + bool SummonedDragons; + bool SummonedOrcs; + bool SummonedRend; + bool bAggro; + bool RootSelf; + Creature *SummonedCreature; + + void Reset() + { + Dragons_Timer = 3000; + Orc_Timer = 60000; + Aggro_Timer = 60000; + CorrosiveAcid_Timer = 8000; + Freeze_Timer = 11000; + Flamebreath_Timer = 4000; + Event = false; + SummonedDragons = false; + SummonedOrcs= false; + SummonedRend = false; + bAggro = false; + RootSelf = false; + + // how many times should the two lines of summoned creatures be spawned + // min 2 x 2, max 7 lines of attack in total + Line1Count = rand() % 4 + 2; + if (Line1Count < 5) + Line2Count = rand() % (5 - Line1Count) + 2; + else + Line2Count = 2; + + //Invisible for event start + m_creature->SetUInt32Value(UNIT_FIELD_DISPLAYID, 11686); + m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + } + + void Aggro(Unit *who) + { + } + + void SummonCreatureWithRandomTarget(uint32 creatureId) + { + Unit* Summoned = m_creature->SummonCreature(creatureId, m_creature->GetPositionX(), m_creature->GetPositionY(), m_creature->GetPositionZ(), 0, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 240000); + if (Summoned) + { + Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0); + if (target) + Summoned->AddThreat(target, 1.0f); + } + } + + void UpdateAI(const uint32 diff) + { + //char buf[200]; + + //Return since we have no target + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + if (!RootSelf) + { + //m_creature->m_canMove = true; + DoCast(m_creature, 33356); + RootSelf = true; + } + + if (!bAggro && Line1Count == 0 && Line2Count == 0) + { + if (Aggro_Timer < diff) + { + bAggro = true; + // Visible now! + m_creature->SetUInt32Value(UNIT_FIELD_DISPLAYID, 9723); + m_creature->setFaction(14); + m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + } else Aggro_Timer -= diff; + } + + // Summon Dragon pack. 2 Dragons and 3 Whelps + if (!bAggro && !SummonedRend && Line1Count > 0) + { + if (Dragons_Timer < diff) + { + SummonCreatureWithRandomTarget(10372); + SummonCreatureWithRandomTarget(10372); + SummonCreatureWithRandomTarget(10442); + SummonCreatureWithRandomTarget(10442); + SummonCreatureWithRandomTarget(10442); + Line1Count = Line1Count - 1; + Dragons_Timer = 60000; + } else Dragons_Timer -= diff; + } + + //Summon Orc pack. 1 Orc Handler 1 Elite Dragonkin and 3 Whelps + if (!bAggro && !SummonedRend && Line1Count == 0 && Line2Count > 0) + { + if (Orc_Timer < diff) + { + SummonCreatureWithRandomTarget(10447); + SummonCreatureWithRandomTarget(10317); + SummonCreatureWithRandomTarget(10442); + SummonCreatureWithRandomTarget(10442); + SummonCreatureWithRandomTarget(10442); + Line2Count = Line2Count - 1; + Orc_Timer = 60000; + } else Orc_Timer -= diff; + } + + // we take part in the fight + if (bAggro) + { + // CorrosiveAcid_Timer + if (CorrosiveAcid_Timer < diff) + { + DoCast(m_creature->getVictim(), SPELL_CORROSIVEACID); + CorrosiveAcid_Timer = 7000; + } else CorrosiveAcid_Timer -= diff; + + // Freeze_Timer + if (Freeze_Timer < diff) + { + DoCast(m_creature->getVictim(), SPELL_FREEZE); + Freeze_Timer = 16000; + } else Freeze_Timer -= diff; + + // Flamebreath_Timer + if (Flamebreath_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_FLAMEBREATH); + Flamebreath_Timer = 10500; + } else Flamebreath_Timer -= diff; + + //Summon Rend + if (!SummonedRend && m_creature->GetHealth()*100 / m_creature->GetMaxHealth() < 11 + && m_creature->GetHealth() > 0 ) + { + //summon Rend and Change model to normal Gyth + //Inturrupt any spell casting + m_creature->InterruptNonMeleeSpells(false); + //Gyth model + m_creature->SetUInt32Value(UNIT_FIELD_DISPLAYID, 9806); + m_creature->SummonCreature(10429, m_creature->GetPositionX(), m_creature->GetPositionY(), m_creature->GetPositionZ(), 0, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 900000); + SummonedRend = true; + } + + DoMeleeAttackIfReady(); + } // end if Aggro + } +}; + +CreatureAI* GetAI_boss_gyth(Creature *_Creature) +{ + return new boss_gythAI (_Creature); +} + +void AddSC_boss_gyth() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_gyth"; + newscript->GetAI = GetAI_boss_gyth; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/blackrock_spire/boss_halycon.cpp b/src/bindings/scripts/scripts/zone/blackrock_spire/boss_halycon.cpp index 27509b43355..1effd8287e9 100644 --- a/src/bindings/scripts/scripts/zone/blackrock_spire/boss_halycon.cpp +++ b/src/bindings/scripts/scripts/zone/blackrock_spire/boss_halycon.cpp @@ -1,95 +1,95 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Halycon -SD%Complete: 100 -SDComment: -SDCategory: Blackrock Spire -EndScriptData */ - -#include "precompiled.h" - -#define SPELL_CROWDPUMMEL 10887 -#define SPELL_MIGHTYBLOW 14099 - -#define ADD_1X -169.839203 -#define ADD_1Y -324.961395 -#define ADD_1Z 64.401443 -#define ADD_1O 3.124724 - -struct MANGOS_DLL_DECL boss_halyconAI : public ScriptedAI -{ - boss_halyconAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 CrowdPummel_Timer; - uint32 MightyBlow_Timer; - bool Summoned; - - void Reset() - { - CrowdPummel_Timer = 8000; - MightyBlow_Timer = 14000; - Summoned = false; - } - - void Aggro(Unit *who) - { - } - - void UpdateAI(const uint32 diff) - { - //Return since we have no target - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - //CrowdPummel_Timer - if (CrowdPummel_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_CROWDPUMMEL); - CrowdPummel_Timer = 14000; - }else CrowdPummel_Timer -= diff; - - //MightyBlow_Timer - if (MightyBlow_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_MIGHTYBLOW); - MightyBlow_Timer = 10000; - }else MightyBlow_Timer -= diff; - - //Summon Gizrul - if ( !Summoned && m_creature->GetHealth()*100 / m_creature->GetMaxHealth() < 25 ) - { - m_creature->SummonCreature(10268,ADD_1X,ADD_1Y,ADD_1Z,ADD_1O,TEMPSUMMON_TIMED_DESPAWN,300000); - Summoned = true; - } - - DoMeleeAttackIfReady(); - } -}; -CreatureAI* GetAI_boss_halycon(Creature *_Creature) -{ - return new boss_halyconAI (_Creature); -} - -void AddSC_boss_halycon() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_halycon"; - newscript->GetAI = GetAI_boss_halycon; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Halycon +SD%Complete: 100 +SDComment: +SDCategory: Blackrock Spire +EndScriptData */ + +#include "precompiled.h" + +#define SPELL_CROWDPUMMEL 10887 +#define SPELL_MIGHTYBLOW 14099 + +#define ADD_1X -169.839203 +#define ADD_1Y -324.961395 +#define ADD_1Z 64.401443 +#define ADD_1O 3.124724 + +struct MANGOS_DLL_DECL boss_halyconAI : public ScriptedAI +{ + boss_halyconAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 CrowdPummel_Timer; + uint32 MightyBlow_Timer; + bool Summoned; + + void Reset() + { + CrowdPummel_Timer = 8000; + MightyBlow_Timer = 14000; + Summoned = false; + } + + void Aggro(Unit *who) + { + } + + void UpdateAI(const uint32 diff) + { + //Return since we have no target + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + //CrowdPummel_Timer + if (CrowdPummel_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_CROWDPUMMEL); + CrowdPummel_Timer = 14000; + }else CrowdPummel_Timer -= diff; + + //MightyBlow_Timer + if (MightyBlow_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_MIGHTYBLOW); + MightyBlow_Timer = 10000; + }else MightyBlow_Timer -= diff; + + //Summon Gizrul + if ( !Summoned && m_creature->GetHealth()*100 / m_creature->GetMaxHealth() < 25 ) + { + m_creature->SummonCreature(10268,ADD_1X,ADD_1Y,ADD_1Z,ADD_1O,TEMPSUMMON_TIMED_DESPAWN,300000); + Summoned = true; + } + + DoMeleeAttackIfReady(); + } +}; +CreatureAI* GetAI_boss_halycon(Creature *_Creature) +{ + return new boss_halyconAI (_Creature); +} + +void AddSC_boss_halycon() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_halycon"; + newscript->GetAI = GetAI_boss_halycon; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/blackrock_spire/boss_highlord_omokk.cpp b/src/bindings/scripts/scripts/zone/blackrock_spire/boss_highlord_omokk.cpp index b0fc6b3ac14..e0bde6bca00 100644 --- a/src/bindings/scripts/scripts/zone/blackrock_spire/boss_highlord_omokk.cpp +++ b/src/bindings/scripts/scripts/zone/blackrock_spire/boss_highlord_omokk.cpp @@ -1,131 +1,131 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Highlord_Omokk -SD%Complete: 100 -SDComment: -SDCategory: Blackrock Spire -EndScriptData */ - -#include "precompiled.h" - -#define SPELL_WARSTOMP 24375 -#define SPELL_CLEAVE 15579 -#define SPELL_STRIKE 18368 -#define SPELL_REND 18106 -#define SPELL_SUNDERARMOR 24317 -#define SPELL_KNOCKAWAY 20686 -#define SPELL_SLOW 22356 - -struct MANGOS_DLL_DECL boss_highlordomokkAI : public ScriptedAI -{ - boss_highlordomokkAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 WarStomp_Timer; - uint32 Cleave_Timer; - uint32 Strike_Timer; - uint32 Rend_Timer; - uint32 SunderArmor_Timer; - uint32 KnockAway_Timer; - uint32 Slow_Timer; - - void Reset() - { - WarStomp_Timer = 15000; - Cleave_Timer = 6000; - Strike_Timer = 10000; - Rend_Timer = 14000; - SunderArmor_Timer = 2000; - KnockAway_Timer = 18000; - Slow_Timer = 24000; - } - - void Aggro(Unit *who) - { - } - - void UpdateAI(const uint32 diff) - { - //Return since we have no target - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - //WarStomp_Timer - if (WarStomp_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_WARSTOMP); - WarStomp_Timer = 14000; - }else WarStomp_Timer -= diff; - - //Cleave_Timer - if (Cleave_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_CLEAVE); - Cleave_Timer = 8000; - }else Cleave_Timer -= diff; - - //Strike_Timer - if (Strike_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_STRIKE); - Strike_Timer = 10000; - }else Strike_Timer -= diff; - - //Rend_Timer - if (Rend_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_REND); - Rend_Timer = 18000; - }else Rend_Timer -= diff; - - //SunderArmor_Timer - if (SunderArmor_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_SUNDERARMOR); - SunderArmor_Timer = 25000; - }else SunderArmor_Timer -= diff; - - //KnockAway_Timer - if (KnockAway_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_KNOCKAWAY); - KnockAway_Timer = 12000; - }else KnockAway_Timer -= diff; - - //Slow_Timer - if (Slow_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_SLOW); - Slow_Timer = 18000; - }else Slow_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; -CreatureAI* GetAI_boss_highlordomokk(Creature *_Creature) -{ - return new boss_highlordomokkAI (_Creature); -} - -void AddSC_boss_highlordomokk() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_highlord_omokk"; - newscript->GetAI = GetAI_boss_highlordomokk; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Highlord_Omokk +SD%Complete: 100 +SDComment: +SDCategory: Blackrock Spire +EndScriptData */ + +#include "precompiled.h" + +#define SPELL_WARSTOMP 24375 +#define SPELL_CLEAVE 15579 +#define SPELL_STRIKE 18368 +#define SPELL_REND 18106 +#define SPELL_SUNDERARMOR 24317 +#define SPELL_KNOCKAWAY 20686 +#define SPELL_SLOW 22356 + +struct MANGOS_DLL_DECL boss_highlordomokkAI : public ScriptedAI +{ + boss_highlordomokkAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 WarStomp_Timer; + uint32 Cleave_Timer; + uint32 Strike_Timer; + uint32 Rend_Timer; + uint32 SunderArmor_Timer; + uint32 KnockAway_Timer; + uint32 Slow_Timer; + + void Reset() + { + WarStomp_Timer = 15000; + Cleave_Timer = 6000; + Strike_Timer = 10000; + Rend_Timer = 14000; + SunderArmor_Timer = 2000; + KnockAway_Timer = 18000; + Slow_Timer = 24000; + } + + void Aggro(Unit *who) + { + } + + void UpdateAI(const uint32 diff) + { + //Return since we have no target + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + //WarStomp_Timer + if (WarStomp_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_WARSTOMP); + WarStomp_Timer = 14000; + }else WarStomp_Timer -= diff; + + //Cleave_Timer + if (Cleave_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_CLEAVE); + Cleave_Timer = 8000; + }else Cleave_Timer -= diff; + + //Strike_Timer + if (Strike_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_STRIKE); + Strike_Timer = 10000; + }else Strike_Timer -= diff; + + //Rend_Timer + if (Rend_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_REND); + Rend_Timer = 18000; + }else Rend_Timer -= diff; + + //SunderArmor_Timer + if (SunderArmor_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_SUNDERARMOR); + SunderArmor_Timer = 25000; + }else SunderArmor_Timer -= diff; + + //KnockAway_Timer + if (KnockAway_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_KNOCKAWAY); + KnockAway_Timer = 12000; + }else KnockAway_Timer -= diff; + + //Slow_Timer + if (Slow_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_SLOW); + Slow_Timer = 18000; + }else Slow_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; +CreatureAI* GetAI_boss_highlordomokk(Creature *_Creature) +{ + return new boss_highlordomokkAI (_Creature); +} + +void AddSC_boss_highlordomokk() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_highlord_omokk"; + newscript->GetAI = GetAI_boss_highlordomokk; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/blackrock_spire/boss_mother_smolderweb.cpp b/src/bindings/scripts/scripts/zone/blackrock_spire/boss_mother_smolderweb.cpp index 04cef92dcc1..cd212627fe5 100644 --- a/src/bindings/scripts/scripts/zone/blackrock_spire/boss_mother_smolderweb.cpp +++ b/src/bindings/scripts/scripts/zone/blackrock_spire/boss_mother_smolderweb.cpp @@ -1,86 +1,86 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Mother_Smolderweb -SD%Complete: 100 -SDComment: Uncertain how often mother's milk is casted -SDCategory: Blackrock Spire -EndScriptData */ - -#include "precompiled.h" - -#define SPELL_CRYSTALIZE 16104 -#define SPELL_MOTHERSMILK 16468 -#define SPELL_SUMMON_SPIRE_SPIDERLING 16103 - -struct MANGOS_DLL_DECL boss_mothersmolderwebAI : public ScriptedAI -{ - boss_mothersmolderwebAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 Crystalize_Timer; - uint32 MothersMilk_Timer; - - void Reset() - { - Crystalize_Timer = 20000; - MothersMilk_Timer = 10000; - } - - void Aggro(Unit *who) { } - - void DamageTaken(Unit *done_by, uint32 &damage) - { - if( m_creature->GetHealth() <= damage ) - m_creature->CastSpell(m_creature,SPELL_SUMMON_SPIRE_SPIDERLING,true); - } - - void UpdateAI(const uint32 diff) - { - //Return since we have no target - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - //Crystalize_Timer - if( Crystalize_Timer < diff ) - { - DoCast(m_creature,SPELL_CRYSTALIZE); - Crystalize_Timer = 15000; - }else Crystalize_Timer -= diff; - - //MothersMilk_Timer - if( MothersMilk_Timer < diff ) - { - DoCast(m_creature,SPELL_MOTHERSMILK); - MothersMilk_Timer = 5000+rand()%7500; - }else MothersMilk_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; -CreatureAI* GetAI_boss_mothersmolderweb(Creature *_Creature) -{ - return new boss_mothersmolderwebAI (_Creature); -} - -void AddSC_boss_mothersmolderweb() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_mother_smolderweb"; - newscript->GetAI = GetAI_boss_mothersmolderweb; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Mother_Smolderweb +SD%Complete: 100 +SDComment: Uncertain how often mother's milk is casted +SDCategory: Blackrock Spire +EndScriptData */ + +#include "precompiled.h" + +#define SPELL_CRYSTALIZE 16104 +#define SPELL_MOTHERSMILK 16468 +#define SPELL_SUMMON_SPIRE_SPIDERLING 16103 + +struct MANGOS_DLL_DECL boss_mothersmolderwebAI : public ScriptedAI +{ + boss_mothersmolderwebAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 Crystalize_Timer; + uint32 MothersMilk_Timer; + + void Reset() + { + Crystalize_Timer = 20000; + MothersMilk_Timer = 10000; + } + + void Aggro(Unit *who) { } + + void DamageTaken(Unit *done_by, uint32 &damage) + { + if( m_creature->GetHealth() <= damage ) + m_creature->CastSpell(m_creature,SPELL_SUMMON_SPIRE_SPIDERLING,true); + } + + void UpdateAI(const uint32 diff) + { + //Return since we have no target + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + //Crystalize_Timer + if( Crystalize_Timer < diff ) + { + DoCast(m_creature,SPELL_CRYSTALIZE); + Crystalize_Timer = 15000; + }else Crystalize_Timer -= diff; + + //MothersMilk_Timer + if( MothersMilk_Timer < diff ) + { + DoCast(m_creature,SPELL_MOTHERSMILK); + MothersMilk_Timer = 5000+rand()%7500; + }else MothersMilk_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; +CreatureAI* GetAI_boss_mothersmolderweb(Creature *_Creature) +{ + return new boss_mothersmolderwebAI (_Creature); +} + +void AddSC_boss_mothersmolderweb() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_mother_smolderweb"; + newscript->GetAI = GetAI_boss_mothersmolderweb; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/blackrock_spire/boss_overlord_wyrmthalak.cpp b/src/bindings/scripts/scripts/zone/blackrock_spire/boss_overlord_wyrmthalak.cpp index 3eabd522ccc..33ab597f752 100644 --- a/src/bindings/scripts/scripts/zone/blackrock_spire/boss_overlord_wyrmthalak.cpp +++ b/src/bindings/scripts/scripts/zone/blackrock_spire/boss_overlord_wyrmthalak.cpp @@ -1,127 +1,127 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Overlord_Wyrmthalak -SD%Complete: 100 -SDComment: -SDCategory: Blackrock Spire -EndScriptData */ - -#include "precompiled.h" - -#define SPELL_BLASTWAVE 11130 -#define SPELL_SHOUT 23511 -#define SPELL_CLEAVE 20691 -#define SPELL_KNOCKAWAY 20686 - -#define ADD_1X -39.355381 -#define ADD_1Y -513.456482 -#define ADD_1Z 88.472046 -#define ADD_1O 4.679872 - -#define ADD_2X -49.875881 -#define ADD_2Y -511.896942 -#define ADD_2Z 88.195160 -#define ADD_2O 4.613114 - -struct MANGOS_DLL_DECL boss_overlordwyrmthalakAI : public ScriptedAI -{ - boss_overlordwyrmthalakAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 BlastWave_Timer; - uint32 Shout_Timer; - uint32 Cleave_Timer; - uint32 Knockaway_Timer; - bool Summoned; - Creature *SummonedCreature; - - void Reset() - { - BlastWave_Timer = 20000; - Shout_Timer = 2000; - Cleave_Timer = 6000; - Knockaway_Timer = 12000; - Summoned = false; - } - - void Aggro(Unit *who) - { - } - - void UpdateAI(const uint32 diff) - { - //Return since we have no target - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - //BlastWave_Timer - if (BlastWave_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_BLASTWAVE); - BlastWave_Timer = 20000; - }else BlastWave_Timer -= diff; - - //Shout_Timer - if (Shout_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_SHOUT); - Shout_Timer = 10000; - }else Shout_Timer -= diff; - - //Cleave_Timer - if (Cleave_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_CLEAVE); - Cleave_Timer = 7000; - }else Cleave_Timer -= diff; - - //Knockaway_Timer - if (Knockaway_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_KNOCKAWAY); - Knockaway_Timer = 14000; - }else Knockaway_Timer -= diff; - - //Summon two Beserks - if ( !Summoned && m_creature->GetHealth()*100 / m_creature->GetMaxHealth() < 51 ) - { - Unit* target = NULL; - target = SelectUnit(SELECT_TARGET_RANDOM,0); - - SummonedCreature = m_creature->SummonCreature(9216,ADD_1X,ADD_1Y,ADD_1Z,ADD_1O,TEMPSUMMON_TIMED_DESPAWN,300000); - ((CreatureAI*)SummonedCreature->AI())->AttackStart(target); - SummonedCreature = m_creature->SummonCreature(9268,ADD_2X,ADD_2Y,ADD_2Z,ADD_2O,TEMPSUMMON_TIMED_DESPAWN,300000); - ((CreatureAI*)SummonedCreature->AI())->AttackStart(target); - Summoned = true; - } - - DoMeleeAttackIfReady(); - } -}; -CreatureAI* GetAI_boss_overlordwyrmthalak(Creature *_Creature) -{ - return new boss_overlordwyrmthalakAI (_Creature); -} - -void AddSC_boss_overlordwyrmthalak() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_overlord_wyrmthalak"; - newscript->GetAI = GetAI_boss_overlordwyrmthalak; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Overlord_Wyrmthalak +SD%Complete: 100 +SDComment: +SDCategory: Blackrock Spire +EndScriptData */ + +#include "precompiled.h" + +#define SPELL_BLASTWAVE 11130 +#define SPELL_SHOUT 23511 +#define SPELL_CLEAVE 20691 +#define SPELL_KNOCKAWAY 20686 + +#define ADD_1X -39.355381 +#define ADD_1Y -513.456482 +#define ADD_1Z 88.472046 +#define ADD_1O 4.679872 + +#define ADD_2X -49.875881 +#define ADD_2Y -511.896942 +#define ADD_2Z 88.195160 +#define ADD_2O 4.613114 + +struct MANGOS_DLL_DECL boss_overlordwyrmthalakAI : public ScriptedAI +{ + boss_overlordwyrmthalakAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 BlastWave_Timer; + uint32 Shout_Timer; + uint32 Cleave_Timer; + uint32 Knockaway_Timer; + bool Summoned; + Creature *SummonedCreature; + + void Reset() + { + BlastWave_Timer = 20000; + Shout_Timer = 2000; + Cleave_Timer = 6000; + Knockaway_Timer = 12000; + Summoned = false; + } + + void Aggro(Unit *who) + { + } + + void UpdateAI(const uint32 diff) + { + //Return since we have no target + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + //BlastWave_Timer + if (BlastWave_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_BLASTWAVE); + BlastWave_Timer = 20000; + }else BlastWave_Timer -= diff; + + //Shout_Timer + if (Shout_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_SHOUT); + Shout_Timer = 10000; + }else Shout_Timer -= diff; + + //Cleave_Timer + if (Cleave_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_CLEAVE); + Cleave_Timer = 7000; + }else Cleave_Timer -= diff; + + //Knockaway_Timer + if (Knockaway_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_KNOCKAWAY); + Knockaway_Timer = 14000; + }else Knockaway_Timer -= diff; + + //Summon two Beserks + if ( !Summoned && m_creature->GetHealth()*100 / m_creature->GetMaxHealth() < 51 ) + { + Unit* target = NULL; + target = SelectUnit(SELECT_TARGET_RANDOM,0); + + SummonedCreature = m_creature->SummonCreature(9216,ADD_1X,ADD_1Y,ADD_1Z,ADD_1O,TEMPSUMMON_TIMED_DESPAWN,300000); + ((CreatureAI*)SummonedCreature->AI())->AttackStart(target); + SummonedCreature = m_creature->SummonCreature(9268,ADD_2X,ADD_2Y,ADD_2Z,ADD_2O,TEMPSUMMON_TIMED_DESPAWN,300000); + ((CreatureAI*)SummonedCreature->AI())->AttackStart(target); + Summoned = true; + } + + DoMeleeAttackIfReady(); + } +}; +CreatureAI* GetAI_boss_overlordwyrmthalak(Creature *_Creature) +{ + return new boss_overlordwyrmthalakAI (_Creature); +} + +void AddSC_boss_overlordwyrmthalak() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_overlord_wyrmthalak"; + newscript->GetAI = GetAI_boss_overlordwyrmthalak; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/blackrock_spire/boss_pyroguard_emberseer.cpp b/src/bindings/scripts/scripts/zone/blackrock_spire/boss_pyroguard_emberseer.cpp index 248ea48f9e0..b75c3fa1d8d 100644 --- a/src/bindings/scripts/scripts/zone/blackrock_spire/boss_pyroguard_emberseer.cpp +++ b/src/bindings/scripts/scripts/zone/blackrock_spire/boss_pyroguard_emberseer.cpp @@ -1,93 +1,93 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Pyroguard_Emberseer -SD%Complete: 100 -SDComment: Event to activate Emberseer NYI -SDCategory: Blackrock Spire -EndScriptData */ - -#include "precompiled.h" - -#define SPELL_FIRENOVA 23462 -#define SPELL_FLAMEBUFFET 23341 -#define SPELL_PYROBLAST 17274 - -struct MANGOS_DLL_DECL boss_pyroguard_emberseerAI : public ScriptedAI -{ - boss_pyroguard_emberseerAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 FireNova_Timer; - uint32 FlameBuffet_Timer; - uint32 PyroBlast_Timer; - - void Reset() - { - FireNova_Timer = 6000; - FlameBuffet_Timer = 3000; - PyroBlast_Timer = 14000; - } - - void Aggro(Unit *who) - { - } - - void UpdateAI(const uint32 diff) - { - //Return since we have no target - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - //FireNova_Timer - if (FireNova_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_FIRENOVA); - FireNova_Timer = 6000; - }else FireNova_Timer -= diff; - - //FlameBuffet_Timer - if (FlameBuffet_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_FLAMEBUFFET); - FlameBuffet_Timer = 14000; - }else FlameBuffet_Timer -= diff; - - //PyroBlast_Timer - if (PyroBlast_Timer < diff) - { - Unit* target = NULL; - target = SelectUnit(SELECT_TARGET_RANDOM,0); - if (target) DoCast(target,SPELL_PYROBLAST); - PyroBlast_Timer = 15000; - }else PyroBlast_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; -CreatureAI* GetAI_boss_pyroguard_emberseer(Creature *_Creature) -{ - return new boss_pyroguard_emberseerAI (_Creature); -} - -void AddSC_boss_pyroguard_emberseer() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_pyroguard_emberseer"; - newscript->GetAI = GetAI_boss_pyroguard_emberseer; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Pyroguard_Emberseer +SD%Complete: 100 +SDComment: Event to activate Emberseer NYI +SDCategory: Blackrock Spire +EndScriptData */ + +#include "precompiled.h" + +#define SPELL_FIRENOVA 23462 +#define SPELL_FLAMEBUFFET 23341 +#define SPELL_PYROBLAST 17274 + +struct MANGOS_DLL_DECL boss_pyroguard_emberseerAI : public ScriptedAI +{ + boss_pyroguard_emberseerAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 FireNova_Timer; + uint32 FlameBuffet_Timer; + uint32 PyroBlast_Timer; + + void Reset() + { + FireNova_Timer = 6000; + FlameBuffet_Timer = 3000; + PyroBlast_Timer = 14000; + } + + void Aggro(Unit *who) + { + } + + void UpdateAI(const uint32 diff) + { + //Return since we have no target + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + //FireNova_Timer + if (FireNova_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_FIRENOVA); + FireNova_Timer = 6000; + }else FireNova_Timer -= diff; + + //FlameBuffet_Timer + if (FlameBuffet_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_FLAMEBUFFET); + FlameBuffet_Timer = 14000; + }else FlameBuffet_Timer -= diff; + + //PyroBlast_Timer + if (PyroBlast_Timer < diff) + { + Unit* target = NULL; + target = SelectUnit(SELECT_TARGET_RANDOM,0); + if (target) DoCast(target,SPELL_PYROBLAST); + PyroBlast_Timer = 15000; + }else PyroBlast_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; +CreatureAI* GetAI_boss_pyroguard_emberseer(Creature *_Creature) +{ + return new boss_pyroguard_emberseerAI (_Creature); +} + +void AddSC_boss_pyroguard_emberseer() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_pyroguard_emberseer"; + newscript->GetAI = GetAI_boss_pyroguard_emberseer; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/blackrock_spire/boss_quartermaster_zigris.cpp b/src/bindings/scripts/scripts/zone/blackrock_spire/boss_quartermaster_zigris.cpp index 6955ae8ad71..fd0798337f6 100644 --- a/src/bindings/scripts/scripts/zone/blackrock_spire/boss_quartermaster_zigris.cpp +++ b/src/bindings/scripts/scripts/zone/blackrock_spire/boss_quartermaster_zigris.cpp @@ -1,85 +1,85 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Quartmaster_Zigris -SD%Complete: 100 -SDComment: Needs revision -SDCategory: Blackrock Spire -EndScriptData */ - -#include "precompiled.h" - -#define SPELL_SHOOT 16496 -#define SPELL_STUNBOMB 16497 -#define SPELL_HEALING_POTION 15504 -#define SPELL_HOOKEDNET 15609 - -struct MANGOS_DLL_DECL boss_quatermasterzigrisAI : public ScriptedAI -{ - boss_quatermasterzigrisAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 Shoot_Timer; - uint32 StunBomb_Timer; - //uint32 HelingPotion_Timer; - - void Reset() - { - Shoot_Timer = 1000; - StunBomb_Timer = 16000; - //HelingPotion_Timer = 25000; - } - - void Aggro(Unit *who) - { - } - - void UpdateAI(const uint32 diff) - { - //Return since we have no target - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - //Shoot_Timer - if (Shoot_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_SHOOT); - Shoot_Timer = 500; - }else Shoot_Timer -= diff; - - //StunBomb_Timer - if (StunBomb_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_STUNBOMB); - StunBomb_Timer = 14000; - }else StunBomb_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; -CreatureAI* GetAI_boss_quatermasterzigris(Creature *_Creature) -{ - return new boss_quatermasterzigrisAI (_Creature); -} - -void AddSC_boss_quatermasterzigris() -{ - Script *newscript; - newscript = new Script; - newscript->Name="quartermaster_zigris"; - newscript->GetAI = GetAI_boss_quatermasterzigris; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Quartmaster_Zigris +SD%Complete: 100 +SDComment: Needs revision +SDCategory: Blackrock Spire +EndScriptData */ + +#include "precompiled.h" + +#define SPELL_SHOOT 16496 +#define SPELL_STUNBOMB 16497 +#define SPELL_HEALING_POTION 15504 +#define SPELL_HOOKEDNET 15609 + +struct MANGOS_DLL_DECL boss_quatermasterzigrisAI : public ScriptedAI +{ + boss_quatermasterzigrisAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 Shoot_Timer; + uint32 StunBomb_Timer; + //uint32 HelingPotion_Timer; + + void Reset() + { + Shoot_Timer = 1000; + StunBomb_Timer = 16000; + //HelingPotion_Timer = 25000; + } + + void Aggro(Unit *who) + { + } + + void UpdateAI(const uint32 diff) + { + //Return since we have no target + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + //Shoot_Timer + if (Shoot_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_SHOOT); + Shoot_Timer = 500; + }else Shoot_Timer -= diff; + + //StunBomb_Timer + if (StunBomb_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_STUNBOMB); + StunBomb_Timer = 14000; + }else StunBomb_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; +CreatureAI* GetAI_boss_quatermasterzigris(Creature *_Creature) +{ + return new boss_quatermasterzigrisAI (_Creature); +} + +void AddSC_boss_quatermasterzigris() +{ + Script *newscript; + newscript = new Script; + newscript->Name="quartermaster_zigris"; + newscript->GetAI = GetAI_boss_quatermasterzigris; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/blackrock_spire/boss_rend_blackhand.cpp b/src/bindings/scripts/scripts/zone/blackrock_spire/boss_rend_blackhand.cpp index 679f92a06b6..f16f883761a 100644 --- a/src/bindings/scripts/scripts/zone/blackrock_spire/boss_rend_blackhand.cpp +++ b/src/bindings/scripts/scripts/zone/blackrock_spire/boss_rend_blackhand.cpp @@ -1,91 +1,91 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Rend_Blackhand -SD%Complete: 100 -SDComment: Intro event NYI -SDCategory: Blackrock Spire -EndScriptData */ - -#include "precompiled.h" - -#define SPELL_WHIRLWIND 26038 -#define SPELL_CLEAVE 20691 -#define SPELL_THUNDERCLAP 23931 //Not sure if he cast this spell - -struct MANGOS_DLL_DECL boss_rend_blackhandAI : public ScriptedAI -{ - boss_rend_blackhandAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 WhirlWind_Timer; - uint32 Cleave_Timer; - uint32 Thunderclap_Timer; - - void Reset() - { - WhirlWind_Timer = 20000; - Cleave_Timer = 5000; - Thunderclap_Timer = 9000; - } - - void Aggro(Unit *who) - { - } - - void UpdateAI(const uint32 diff) - { - //Return since we have no target - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - //WhirlWind_Timer - if (WhirlWind_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_WHIRLWIND); - WhirlWind_Timer = 18000; - }else WhirlWind_Timer -= diff; - - //Cleave_Timer - if (Cleave_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_CLEAVE); - Cleave_Timer = 10000; - }else Cleave_Timer -= diff; - - //Thunderclap_Timer - if (Thunderclap_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_THUNDERCLAP); - Thunderclap_Timer = 16000; - }else Thunderclap_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; -CreatureAI* GetAI_boss_rend_blackhand(Creature *_Creature) -{ - return new boss_rend_blackhandAI (_Creature); -} - -void AddSC_boss_rend_blackhand() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_rend_blackhand"; - newscript->GetAI = GetAI_boss_rend_blackhand; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Rend_Blackhand +SD%Complete: 100 +SDComment: Intro event NYI +SDCategory: Blackrock Spire +EndScriptData */ + +#include "precompiled.h" + +#define SPELL_WHIRLWIND 26038 +#define SPELL_CLEAVE 20691 +#define SPELL_THUNDERCLAP 23931 //Not sure if he cast this spell + +struct MANGOS_DLL_DECL boss_rend_blackhandAI : public ScriptedAI +{ + boss_rend_blackhandAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 WhirlWind_Timer; + uint32 Cleave_Timer; + uint32 Thunderclap_Timer; + + void Reset() + { + WhirlWind_Timer = 20000; + Cleave_Timer = 5000; + Thunderclap_Timer = 9000; + } + + void Aggro(Unit *who) + { + } + + void UpdateAI(const uint32 diff) + { + //Return since we have no target + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + //WhirlWind_Timer + if (WhirlWind_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_WHIRLWIND); + WhirlWind_Timer = 18000; + }else WhirlWind_Timer -= diff; + + //Cleave_Timer + if (Cleave_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_CLEAVE); + Cleave_Timer = 10000; + }else Cleave_Timer -= diff; + + //Thunderclap_Timer + if (Thunderclap_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_THUNDERCLAP); + Thunderclap_Timer = 16000; + }else Thunderclap_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; +CreatureAI* GetAI_boss_rend_blackhand(Creature *_Creature) +{ + return new boss_rend_blackhandAI (_Creature); +} + +void AddSC_boss_rend_blackhand() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_rend_blackhand"; + newscript->GetAI = GetAI_boss_rend_blackhand; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/blackrock_spire/boss_shadow_hunter_voshgajin.cpp b/src/bindings/scripts/scripts/zone/blackrock_spire/boss_shadow_hunter_voshgajin.cpp index bc43f2e223a..da7ef479f1d 100644 --- a/src/bindings/scripts/scripts/zone/blackrock_spire/boss_shadow_hunter_voshgajin.cpp +++ b/src/bindings/scripts/scripts/zone/blackrock_spire/boss_shadow_hunter_voshgajin.cpp @@ -1,95 +1,95 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Shadow_Hunter_Voshgajin -SD%Complete: 100 -SDComment: -SDCategory: Blackrock Spire -EndScriptData */ - -#include "precompiled.h" - -#define SPELL_CURSEOFBLOOD 24673 -#define SPELL_HEX 16708 -#define SPELL_CLEAVE 20691 - -struct MANGOS_DLL_DECL boss_shadowvoshAI : public ScriptedAI -{ - boss_shadowvoshAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 CurseOfBlood_Timer; - uint32 Hex_Timer; - uint32 Cleave_Timer; - - void Reset() - { - CurseOfBlood_Timer = 2000; - Hex_Timer = 8000; - Cleave_Timer = 14000; - - //m_creature->CastSpell(m_creature,SPELL_ICEARMOR,true); - } - - void Aggro(Unit *who) - { - } - - void UpdateAI(const uint32 diff) - { - //Return since we have no target - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - //CurseOfBlood_Timer - if (CurseOfBlood_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_CURSEOFBLOOD); - CurseOfBlood_Timer = 45000; - }else CurseOfBlood_Timer -= diff; - - //Hex_Timer - if (Hex_Timer < diff) - { - Unit* target = NULL; - target = SelectUnit(SELECT_TARGET_RANDOM,0); - if (target) DoCast(target,SPELL_HEX); - Hex_Timer = 15000; - }else Hex_Timer -= diff; - - //Cleave_Timer - if (Cleave_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_CLEAVE); - Cleave_Timer = 7000; - }else Cleave_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; -CreatureAI* GetAI_boss_shadowvosh(Creature *_Creature) -{ - return new boss_shadowvoshAI (_Creature); -} - -void AddSC_boss_shadowvosh() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_shadow_hunter_voshgajin"; - newscript->GetAI = GetAI_boss_shadowvosh; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Shadow_Hunter_Voshgajin +SD%Complete: 100 +SDComment: +SDCategory: Blackrock Spire +EndScriptData */ + +#include "precompiled.h" + +#define SPELL_CURSEOFBLOOD 24673 +#define SPELL_HEX 16708 +#define SPELL_CLEAVE 20691 + +struct MANGOS_DLL_DECL boss_shadowvoshAI : public ScriptedAI +{ + boss_shadowvoshAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 CurseOfBlood_Timer; + uint32 Hex_Timer; + uint32 Cleave_Timer; + + void Reset() + { + CurseOfBlood_Timer = 2000; + Hex_Timer = 8000; + Cleave_Timer = 14000; + + //m_creature->CastSpell(m_creature,SPELL_ICEARMOR,true); + } + + void Aggro(Unit *who) + { + } + + void UpdateAI(const uint32 diff) + { + //Return since we have no target + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + //CurseOfBlood_Timer + if (CurseOfBlood_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_CURSEOFBLOOD); + CurseOfBlood_Timer = 45000; + }else CurseOfBlood_Timer -= diff; + + //Hex_Timer + if (Hex_Timer < diff) + { + Unit* target = NULL; + target = SelectUnit(SELECT_TARGET_RANDOM,0); + if (target) DoCast(target,SPELL_HEX); + Hex_Timer = 15000; + }else Hex_Timer -= diff; + + //Cleave_Timer + if (Cleave_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_CLEAVE); + Cleave_Timer = 7000; + }else Cleave_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; +CreatureAI* GetAI_boss_shadowvosh(Creature *_Creature) +{ + return new boss_shadowvoshAI (_Creature); +} + +void AddSC_boss_shadowvosh() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_shadow_hunter_voshgajin"; + newscript->GetAI = GetAI_boss_shadowvosh; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/blackrock_spire/boss_the_beast.cpp b/src/bindings/scripts/scripts/zone/blackrock_spire/boss_the_beast.cpp index 93a30ecd204..25a44eab1bc 100644 --- a/src/bindings/scripts/scripts/zone/blackrock_spire/boss_the_beast.cpp +++ b/src/bindings/scripts/scripts/zone/blackrock_spire/boss_the_beast.cpp @@ -1,93 +1,93 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_The_Best -SD%Complete: 100 -SDComment: -SDCategory: Blackrock Spire -EndScriptData */ - -#include "precompiled.h" - -#define SPELL_FLAMEBREAK 16785 -#define SPELL_IMMOLATE 20294 -#define SPELL_TERRIFYINGROAR 14100 - -struct MANGOS_DLL_DECL boss_thebeastAI : public ScriptedAI -{ - boss_thebeastAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 Flamebreak_Timer; - uint32 Immolate_Timer; - uint32 TerrifyingRoar_Timer; - - void Reset() - { - Flamebreak_Timer = 12000; - Immolate_Timer = 3000; - TerrifyingRoar_Timer = 23000; - } - - void Aggro(Unit *who) - { - } - - void UpdateAI(const uint32 diff) - { - //Return since we have no target - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - //Flamebreak_Timer - if (Flamebreak_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_FLAMEBREAK); - Flamebreak_Timer = 10000; - }else Flamebreak_Timer -= diff; - - //Immolate_Timer - if (Immolate_Timer < diff) - { - Unit* target = NULL; - target = SelectUnit(SELECT_TARGET_RANDOM,0); - if (target) DoCast(target,SPELL_IMMOLATE); - Immolate_Timer = 8000; - }else Immolate_Timer -= diff; - - //TerrifyingRoar_Timer - if (TerrifyingRoar_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_TERRIFYINGROAR); - TerrifyingRoar_Timer = 20000; - }else TerrifyingRoar_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; -CreatureAI* GetAI_boss_thebeast(Creature *_Creature) -{ - return new boss_thebeastAI (_Creature); -} - -void AddSC_boss_thebeast() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_the_beast"; - newscript->GetAI = GetAI_boss_thebeast; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_The_Best +SD%Complete: 100 +SDComment: +SDCategory: Blackrock Spire +EndScriptData */ + +#include "precompiled.h" + +#define SPELL_FLAMEBREAK 16785 +#define SPELL_IMMOLATE 20294 +#define SPELL_TERRIFYINGROAR 14100 + +struct MANGOS_DLL_DECL boss_thebeastAI : public ScriptedAI +{ + boss_thebeastAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 Flamebreak_Timer; + uint32 Immolate_Timer; + uint32 TerrifyingRoar_Timer; + + void Reset() + { + Flamebreak_Timer = 12000; + Immolate_Timer = 3000; + TerrifyingRoar_Timer = 23000; + } + + void Aggro(Unit *who) + { + } + + void UpdateAI(const uint32 diff) + { + //Return since we have no target + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + //Flamebreak_Timer + if (Flamebreak_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_FLAMEBREAK); + Flamebreak_Timer = 10000; + }else Flamebreak_Timer -= diff; + + //Immolate_Timer + if (Immolate_Timer < diff) + { + Unit* target = NULL; + target = SelectUnit(SELECT_TARGET_RANDOM,0); + if (target) DoCast(target,SPELL_IMMOLATE); + Immolate_Timer = 8000; + }else Immolate_Timer -= diff; + + //TerrifyingRoar_Timer + if (TerrifyingRoar_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_TERRIFYINGROAR); + TerrifyingRoar_Timer = 20000; + }else TerrifyingRoar_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; +CreatureAI* GetAI_boss_thebeast(Creature *_Creature) +{ + return new boss_thebeastAI (_Creature); +} + +void AddSC_boss_thebeast() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_the_beast"; + newscript->GetAI = GetAI_boss_thebeast; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/blackrock_spire/boss_warmaster_voone.cpp b/src/bindings/scripts/scripts/zone/blackrock_spire/boss_warmaster_voone.cpp index 6621c4672a1..d1385ee9b15 100644 --- a/src/bindings/scripts/scripts/zone/blackrock_spire/boss_warmaster_voone.cpp +++ b/src/bindings/scripts/scripts/zone/blackrock_spire/boss_warmaster_voone.cpp @@ -1,121 +1,121 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Warmaster_Voone -SD%Complete: 100 -SDComment: -SDCategory: Blackrock Spire -EndScriptData */ - -#include "precompiled.h" - -#define SPELL_SNAPKICK 15618 -#define SPELL_CLEAVE 15579 -#define SPELL_UPPERCUT 10966 -#define SPELL_MORTALSTRIKE 16856 -#define SPELL_PUMMEL 15615 -#define SPELL_THROWAXE 16075 - -struct MANGOS_DLL_DECL boss_warmastervooneAI : public ScriptedAI -{ - boss_warmastervooneAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 Snapkick_Timer; - uint32 Cleave_Timer; - uint32 Uppercut_Timer; - uint32 MortalStrike_Timer; - uint32 Pummel_Timer; - uint32 ThrowAxe_Timer; - - void Reset() - { - Snapkick_Timer = 8000; - Cleave_Timer = 14000; - Uppercut_Timer = 20000; - MortalStrike_Timer = 12000; - Pummel_Timer = 32000; - ThrowAxe_Timer = 1000; - } - - void Aggro(Unit *who) - { - } - - void UpdateAI(const uint32 diff) - { - //Return since we have no target - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - //Snapkick_Timer - if (Snapkick_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_SNAPKICK); - Snapkick_Timer = 6000; - }else Snapkick_Timer -= diff; - - //Cleave_Timer - if (Cleave_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_CLEAVE); - Cleave_Timer = 12000; - }else Cleave_Timer -= diff; - - //Uppercut_Timer - if (Uppercut_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_UPPERCUT); - Uppercut_Timer = 14000; - }else Uppercut_Timer -= diff; - - //MortalStrike_Timer - if (MortalStrike_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_MORTALSTRIKE); - MortalStrike_Timer = 10000; - }else MortalStrike_Timer -= diff; - - //Pummel_Timer - if (Pummel_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_PUMMEL); - Pummel_Timer = 16000; - }else Pummel_Timer -= diff; - - //ThrowAxe_Timer - if (ThrowAxe_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_THROWAXE); - ThrowAxe_Timer = 8000; - }else ThrowAxe_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; -CreatureAI* GetAI_boss_warmastervoone(Creature *_Creature) -{ - return new boss_warmastervooneAI (_Creature); -} - -void AddSC_boss_warmastervoone() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_warmaster_voone"; - newscript->GetAI = GetAI_boss_warmastervoone; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Warmaster_Voone +SD%Complete: 100 +SDComment: +SDCategory: Blackrock Spire +EndScriptData */ + +#include "precompiled.h" + +#define SPELL_SNAPKICK 15618 +#define SPELL_CLEAVE 15579 +#define SPELL_UPPERCUT 10966 +#define SPELL_MORTALSTRIKE 16856 +#define SPELL_PUMMEL 15615 +#define SPELL_THROWAXE 16075 + +struct MANGOS_DLL_DECL boss_warmastervooneAI : public ScriptedAI +{ + boss_warmastervooneAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 Snapkick_Timer; + uint32 Cleave_Timer; + uint32 Uppercut_Timer; + uint32 MortalStrike_Timer; + uint32 Pummel_Timer; + uint32 ThrowAxe_Timer; + + void Reset() + { + Snapkick_Timer = 8000; + Cleave_Timer = 14000; + Uppercut_Timer = 20000; + MortalStrike_Timer = 12000; + Pummel_Timer = 32000; + ThrowAxe_Timer = 1000; + } + + void Aggro(Unit *who) + { + } + + void UpdateAI(const uint32 diff) + { + //Return since we have no target + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + //Snapkick_Timer + if (Snapkick_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_SNAPKICK); + Snapkick_Timer = 6000; + }else Snapkick_Timer -= diff; + + //Cleave_Timer + if (Cleave_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_CLEAVE); + Cleave_Timer = 12000; + }else Cleave_Timer -= diff; + + //Uppercut_Timer + if (Uppercut_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_UPPERCUT); + Uppercut_Timer = 14000; + }else Uppercut_Timer -= diff; + + //MortalStrike_Timer + if (MortalStrike_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_MORTALSTRIKE); + MortalStrike_Timer = 10000; + }else MortalStrike_Timer -= diff; + + //Pummel_Timer + if (Pummel_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_PUMMEL); + Pummel_Timer = 16000; + }else Pummel_Timer -= diff; + + //ThrowAxe_Timer + if (ThrowAxe_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_THROWAXE); + ThrowAxe_Timer = 8000; + }else ThrowAxe_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; +CreatureAI* GetAI_boss_warmastervoone(Creature *_Creature) +{ + return new boss_warmastervooneAI (_Creature); +} + +void AddSC_boss_warmastervoone() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_warmaster_voone"; + newscript->GetAI = GetAI_boss_warmastervoone; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/blackwing_lair/boss_broodlord_lashlayer.cpp b/src/bindings/scripts/scripts/zone/blackwing_lair/boss_broodlord_lashlayer.cpp index a1f3260550b..12ba8bedb7c 100644 --- a/src/bindings/scripts/scripts/zone/blackwing_lair/boss_broodlord_lashlayer.cpp +++ b/src/bindings/scripts/scripts/zone/blackwing_lair/boss_broodlord_lashlayer.cpp @@ -1,130 +1,130 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Broodlord_Lashlayer -SD%Complete: 100 -SDComment: -SDCategory: Blackwing Lair -EndScriptData */ - -#include "precompiled.h" - -#define SPELL_CLEAVE 26350 -#define SPELL_BLASTWAVE 23331 -#define SPELL_MORTALSTRIKE 24573 -#define SPELL_KNOCKBACK 25778 - -#define SAY_AGGRO "None of your kind should be here! You've doomed only yourselves!" -#define SAY_LEASH "Clever Mortals but I am not so easily lured away from my sanctum!" -#define SOUND_AGGRO 8286 -#define SOUND_LEASH 8287 - -struct MANGOS_DLL_DECL boss_broodlordAI : public ScriptedAI -{ - boss_broodlordAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 Cleave_Timer; - uint32 BlastWave_Timer; - uint32 MortalStrike_Timer; - uint32 KnockBack_Timer; - uint32 LeashCheck_Timer; - - void Reset() - { - Cleave_Timer = 8000; //These times are probably wrong - BlastWave_Timer = 12000; - MortalStrike_Timer = 20000; - KnockBack_Timer = 30000; - LeashCheck_Timer = 2000; - - m_creature->ApplySpellImmune(0, IMMUNITY_STATE, SPELL_AURA_MOD_TAUNT, true); - m_creature->ApplySpellImmune(1, IMMUNITY_EFFECT,SPELL_EFFECT_ATTACK_ME, true); - } - - void Aggro(Unit *who) - { - DoYell(SAY_AGGRO, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_AGGRO); - DoZoneInCombat(); - } - - void UpdateAI(const uint32 diff) - { - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - //LeashCheck_Timer - if (LeashCheck_Timer < diff) - { - float rx,ry,rz; - m_creature->GetRespawnCoord(rx, ry, rz); - float spawndist = m_creature->GetDistance(rx,ry,rz); - if ( spawndist > 250 ) - { - EnterEvadeMode(); - return; - } - LeashCheck_Timer = 2000; - }else LeashCheck_Timer -= diff; - - //Cleave_Timer - if (Cleave_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_CLEAVE); - Cleave_Timer = 7000; - }else Cleave_Timer -= diff; - - // BlastWave - if (BlastWave_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_BLASTWAVE); - BlastWave_Timer = 8000 + rand()%8000; - }else BlastWave_Timer -= diff; - - //MortalStrike_Timer - if (MortalStrike_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_MORTALSTRIKE); - MortalStrike_Timer = 25000 + rand()%10000; - }else MortalStrike_Timer -= diff; - - if (KnockBack_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_KNOCKBACK); - //Drop 50% aggro - if(m_creature->getThreatManager().getThreat(m_creature->getVictim())) - m_creature->getThreatManager().modifyThreatPercent(m_creature->getVictim(),-50); - - KnockBack_Timer = 15000 + rand()%15000; - }else KnockBack_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; -CreatureAI* GetAI_boss_broodlord(Creature *_Creature) -{ - return new boss_broodlordAI (_Creature); -} - -void AddSC_boss_broodlord() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_broodlord"; - newscript->GetAI = GetAI_boss_broodlord; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Broodlord_Lashlayer +SD%Complete: 100 +SDComment: +SDCategory: Blackwing Lair +EndScriptData */ + +#include "precompiled.h" + +#define SPELL_CLEAVE 26350 +#define SPELL_BLASTWAVE 23331 +#define SPELL_MORTALSTRIKE 24573 +#define SPELL_KNOCKBACK 25778 + +#define SAY_AGGRO "None of your kind should be here! You've doomed only yourselves!" +#define SAY_LEASH "Clever Mortals but I am not so easily lured away from my sanctum!" +#define SOUND_AGGRO 8286 +#define SOUND_LEASH 8287 + +struct MANGOS_DLL_DECL boss_broodlordAI : public ScriptedAI +{ + boss_broodlordAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 Cleave_Timer; + uint32 BlastWave_Timer; + uint32 MortalStrike_Timer; + uint32 KnockBack_Timer; + uint32 LeashCheck_Timer; + + void Reset() + { + Cleave_Timer = 8000; //These times are probably wrong + BlastWave_Timer = 12000; + MortalStrike_Timer = 20000; + KnockBack_Timer = 30000; + LeashCheck_Timer = 2000; + + m_creature->ApplySpellImmune(0, IMMUNITY_STATE, SPELL_AURA_MOD_TAUNT, true); + m_creature->ApplySpellImmune(1, IMMUNITY_EFFECT,SPELL_EFFECT_ATTACK_ME, true); + } + + void Aggro(Unit *who) + { + DoYell(SAY_AGGRO, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_AGGRO); + DoZoneInCombat(); + } + + void UpdateAI(const uint32 diff) + { + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + //LeashCheck_Timer + if (LeashCheck_Timer < diff) + { + float rx,ry,rz; + m_creature->GetRespawnCoord(rx, ry, rz); + float spawndist = m_creature->GetDistance(rx,ry,rz); + if ( spawndist > 250 ) + { + EnterEvadeMode(); + return; + } + LeashCheck_Timer = 2000; + }else LeashCheck_Timer -= diff; + + //Cleave_Timer + if (Cleave_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_CLEAVE); + Cleave_Timer = 7000; + }else Cleave_Timer -= diff; + + // BlastWave + if (BlastWave_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_BLASTWAVE); + BlastWave_Timer = 8000 + rand()%8000; + }else BlastWave_Timer -= diff; + + //MortalStrike_Timer + if (MortalStrike_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_MORTALSTRIKE); + MortalStrike_Timer = 25000 + rand()%10000; + }else MortalStrike_Timer -= diff; + + if (KnockBack_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_KNOCKBACK); + //Drop 50% aggro + if(m_creature->getThreatManager().getThreat(m_creature->getVictim())) + m_creature->getThreatManager().modifyThreatPercent(m_creature->getVictim(),-50); + + KnockBack_Timer = 15000 + rand()%15000; + }else KnockBack_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; +CreatureAI* GetAI_boss_broodlord(Creature *_Creature) +{ + return new boss_broodlordAI (_Creature); +} + +void AddSC_boss_broodlord() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_broodlord"; + newscript->GetAI = GetAI_boss_broodlord; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/blackwing_lair/boss_chromaggus.cpp b/src/bindings/scripts/scripts/zone/blackwing_lair/boss_chromaggus.cpp index db05dab31b6..c746e935aba 100644 --- a/src/bindings/scripts/scripts/zone/blackwing_lair/boss_chromaggus.cpp +++ b/src/bindings/scripts/scripts/zone/blackwing_lair/boss_chromaggus.cpp @@ -1,320 +1,320 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Chromaggus -SD%Complete: 95 -SDComment: Chromatic Mutation disabled due to lack of core support -SDCategory: Blackwing Lair -EndScriptData */ - -#include "precompiled.h" - -//These spells are actually called elemental shield -//What they do is decrease all damage by 75% then they increase -//One school of damage by 1100% -#define SPELL_FIRE_VURNALBILTY 22277 -#define SPELL_FROST_VURNALBILTY 22278 -#define SPELL_SHADOW_VURNALBILTY 22279 -#define SPELL_NATURE_VURNALBILTY 22280 -#define SPELL_ARCANE_VURNALBILTY 22281 - -#define EMOTE_FRENZY "goes into a killing frenzy!" -#define EMOTE_SHIMMER "flinches as its skin shimmers" - -#define SPELL_INCINERATE 23308 //Incinerate 23308,23309 -#define SPELL_TIMELAPSE 23310 //Time lapse 23310, 23311(old threat mod that was removed in 2.01) -#define SPELL_CORROSIVEACID 23313 //Corrosive Acid 23313, 23314 -#define SPELL_IGNITEFLESH 23315 //Ignite Flesh 23315,23316 -#define SPELL_FROSTBURN 23187 //Frost burn 23187, 23189 - -//Brood Affliction 23173 - Scripted Spell that cycles through all targets within 100 yards and has a chance to cast one of the afflictions on them -//Since Scripted spells arn't coded I'll just write a function that does the same thing - -#define SPELL_BROODAF_BLUE 23153 //Blue affliction 23153 -#define SPELL_BROODAF_BLACK 23154 //Black affliction 23154 -#define SPELL_BROODAF_RED 23155 //Red affliction 23155 (23168 on death) -#define SPELL_BROODAF_BRONZE 23170 //Bronze Affliction 23170 -#define SPELL_BROODAF_GREEN 23169 //Brood Affliction Green 23169 - -#define SPELL_CHROMATIC_MUT_1 23174 //Spell cast on player if they get all 5 debuffs - -#define SPELL_FRENZY 28371 //The frenzy spell may be wrong -#define SPELL_ENRAGE 28747 - -#define TEMP_MUTATE_WHISPER "[SD2 Debug] You would be mind controlled here!" - -struct MANGOS_DLL_DECL boss_chromaggusAI : public ScriptedAI -{ - boss_chromaggusAI(Creature *c) : ScriptedAI(c) - { - //Select the 2 breaths that we are going to use until despawned - //5 possiblities for the first breath, 4 for the second, 20 total possiblites - //This way we don't end up casting 2 of the same breath - //TL TL would be stupid - srand(time(NULL)); - switch (rand()%20) - { - //B1 - Incin - case 0: - Breath1_Spell = SPELL_INCINERATE; - Breath2_Spell = SPELL_TIMELAPSE; - break; - case 1: - Breath1_Spell = SPELL_INCINERATE; - Breath2_Spell = SPELL_CORROSIVEACID; - break; - case 2: - Breath1_Spell = SPELL_INCINERATE; - Breath2_Spell = SPELL_IGNITEFLESH; - break; - case 3: - Breath1_Spell = SPELL_INCINERATE; - Breath2_Spell = SPELL_FROSTBURN; - break; - - //B1 - TL - case 4: - Breath1_Spell = SPELL_TIMELAPSE; - Breath2_Spell = SPELL_INCINERATE; - break; - case 5: - Breath1_Spell = SPELL_TIMELAPSE; - Breath2_Spell = SPELL_CORROSIVEACID; - break; - case 6: - Breath1_Spell = SPELL_TIMELAPSE; - Breath2_Spell = SPELL_IGNITEFLESH; - break; - case 7: - Breath1_Spell = SPELL_TIMELAPSE; - Breath2_Spell = SPELL_FROSTBURN; - break; - - //B1 - Acid - case 8: - Breath1_Spell = SPELL_CORROSIVEACID; - Breath2_Spell = SPELL_INCINERATE; - break; - case 9: - Breath1_Spell = SPELL_CORROSIVEACID; - Breath2_Spell = SPELL_TIMELAPSE; - break; - case 10: - Breath1_Spell = SPELL_CORROSIVEACID; - Breath2_Spell = SPELL_IGNITEFLESH; - break; - case 11: - Breath1_Spell = SPELL_CORROSIVEACID; - Breath2_Spell = SPELL_FROSTBURN; - break; - - //B1 - Ignite - case 12: - Breath1_Spell = SPELL_IGNITEFLESH; - Breath2_Spell = SPELL_INCINERATE; - break; - case 13: - Breath1_Spell = SPELL_IGNITEFLESH; - Breath2_Spell = SPELL_CORROSIVEACID; - break; - case 14: - Breath1_Spell = SPELL_IGNITEFLESH; - Breath2_Spell = SPELL_TIMELAPSE; - break; - case 15: - Breath1_Spell = SPELL_IGNITEFLESH; - Breath2_Spell = SPELL_FROSTBURN; - break; - - //B1 - Frost - case 16: - Breath1_Spell = SPELL_FROSTBURN; - Breath2_Spell = SPELL_INCINERATE; - break; - case 17: - Breath1_Spell = SPELL_FROSTBURN; - Breath2_Spell = SPELL_TIMELAPSE; - break; - case 18: - Breath1_Spell = SPELL_FROSTBURN; - Breath2_Spell = SPELL_CORROSIVEACID; - break; - case 19: - Breath1_Spell = SPELL_FROSTBURN; - Breath2_Spell = SPELL_IGNITEFLESH; - break; - }; - - EnterEvadeMode(); - } - - uint32 Breath1_Spell; - uint32 Breath2_Spell; - uint32 CurrentVurln_Spell; - - uint32 Shimmer_Timer; - uint32 Breath1_Timer; - uint32 Breath2_Timer; - uint32 Affliction_Timer; - uint32 Frenzy_Timer; - bool Enraged; - - void Reset() - { - CurrentVurln_Spell = 0; //We use this to store our last vurlnability spell so we can remove it later - - Shimmer_Timer = 0; //Time till we change vurlnerabilites - Breath1_Timer = 30000; //First breath is 30 seconds - Breath2_Timer = 60000; //Second is 1 minute so that we can alternate - Affliction_Timer = 10000; //This is special - 5 seconds means that we cast this on 1 player every 5 sconds - Frenzy_Timer = 15000; - - Enraged = false; - } - - void Aggro(Unit *who) - { - } - - void UpdateAI(const uint32 diff) - { - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - //Shimmer_Timer Timer - if (Shimmer_Timer < diff) - { - //Remove old vurlnability spell - if (CurrentVurln_Spell) - m_creature->RemoveAurasDueToSpell(CurrentVurln_Spell); - - //Cast new random vurlnabilty on self - uint32 spell; - switch (rand()%5) - { - case 0: spell = SPELL_FIRE_VURNALBILTY; break; - case 1: spell = SPELL_FROST_VURNALBILTY; break; - case 2: spell = SPELL_SHADOW_VURNALBILTY; break; - case 3: spell = SPELL_NATURE_VURNALBILTY; break; - case 4: spell = SPELL_ARCANE_VURNALBILTY; break; - } - - DoCast(m_creature,spell); - CurrentVurln_Spell = spell; - - DoTextEmote(EMOTE_SHIMMER, NULL); - Shimmer_Timer = 45000; - }else Shimmer_Timer -= diff; - - //Breath1_Timer - if (Breath1_Timer < diff) - { - DoCast(m_creature->getVictim(),Breath1_Spell); - Breath1_Timer = 60000; - }else Breath1_Timer -= diff; - - //Breath2_Timer - if (Breath2_Timer < diff) - { - DoCast(m_creature->getVictim(),Breath2_Spell); - Breath2_Timer = 60000; - }else Breath2_Timer -= diff; - - //Affliction_Timer - if (Affliction_Timer < diff) - { - uint32 SpellAfflict = 0; - - switch (rand()%5) - { - case 0: SpellAfflict = SPELL_BROODAF_BLUE; break; - case 1: SpellAfflict = SPELL_BROODAF_BLACK; break; - case 2: SpellAfflict = SPELL_BROODAF_RED; break; - case 3: SpellAfflict = SPELL_BROODAF_BRONZE; break; - case 4: SpellAfflict = SPELL_BROODAF_GREEN; break; - } - - std::list::iterator i; - - for (i = m_creature->getThreatManager().getThreatList().begin();i != m_creature->getThreatManager().getThreatList().end(); ++i) - { - Unit* pUnit = NULL; - pUnit = Unit::GetUnit((*m_creature), (*i)->getUnitGuid()); - - if(pUnit) - { - //Cast affliction - DoCast(pUnit, SpellAfflict, true); - - //Chromatic mutation if target is effected by all afflictions - if (pUnit->HasAura(SPELL_BROODAF_BLUE,0) - && pUnit->HasAura(SPELL_BROODAF_BLACK,0) - && pUnit->HasAura(SPELL_BROODAF_RED,0) - && pUnit->HasAura(SPELL_BROODAF_BRONZE,0) - && pUnit->HasAura(SPELL_BROODAF_GREEN,0)) - { - //target->RemoveAllAuras(); - //DoCast(target,SPELL_CHROMATIC_MUT_1); - - //Chromatic mutation is causing issues - //Assuming it is caused by a lack of core support for Charm - //So instead we instant kill our target - - //WORKAROUND - if (pUnit->GetTypeId() == TYPEID_PLAYER) - { - DoWhisper(TEMP_MUTATE_WHISPER, pUnit); - pUnit->CastSpell(pUnit, 5, false); - } - } - } - } - - Affliction_Timer = 10000; - }else Affliction_Timer -= diff; - - //Frenzy_Timer - if (Frenzy_Timer < diff) - { - DoCast(m_creature,SPELL_FRENZY); - DoTextEmote(EMOTE_FRENZY,NULL); - Frenzy_Timer = 10000 + (rand() % 5000); - }else Frenzy_Timer -= diff; - - //Enrage if not already enraged and below 20% - if (!Enraged && (m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < 20) - { - DoCast(m_creature,SPELL_ENRAGE); - Enraged = true; - } - - DoMeleeAttackIfReady(); - } -}; -CreatureAI* GetAI_boss_chromaggus(Creature *_Creature) -{ - return new boss_chromaggusAI (_Creature); -} - -void AddSC_boss_chromaggus() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_chromaggus"; - newscript->GetAI = GetAI_boss_chromaggus; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Chromaggus +SD%Complete: 95 +SDComment: Chromatic Mutation disabled due to lack of core support +SDCategory: Blackwing Lair +EndScriptData */ + +#include "precompiled.h" + +//These spells are actually called elemental shield +//What they do is decrease all damage by 75% then they increase +//One school of damage by 1100% +#define SPELL_FIRE_VURNALBILTY 22277 +#define SPELL_FROST_VURNALBILTY 22278 +#define SPELL_SHADOW_VURNALBILTY 22279 +#define SPELL_NATURE_VURNALBILTY 22280 +#define SPELL_ARCANE_VURNALBILTY 22281 + +#define EMOTE_FRENZY "goes into a killing frenzy!" +#define EMOTE_SHIMMER "flinches as its skin shimmers" + +#define SPELL_INCINERATE 23308 //Incinerate 23308,23309 +#define SPELL_TIMELAPSE 23310 //Time lapse 23310, 23311(old threat mod that was removed in 2.01) +#define SPELL_CORROSIVEACID 23313 //Corrosive Acid 23313, 23314 +#define SPELL_IGNITEFLESH 23315 //Ignite Flesh 23315,23316 +#define SPELL_FROSTBURN 23187 //Frost burn 23187, 23189 + +//Brood Affliction 23173 - Scripted Spell that cycles through all targets within 100 yards and has a chance to cast one of the afflictions on them +//Since Scripted spells arn't coded I'll just write a function that does the same thing + +#define SPELL_BROODAF_BLUE 23153 //Blue affliction 23153 +#define SPELL_BROODAF_BLACK 23154 //Black affliction 23154 +#define SPELL_BROODAF_RED 23155 //Red affliction 23155 (23168 on death) +#define SPELL_BROODAF_BRONZE 23170 //Bronze Affliction 23170 +#define SPELL_BROODAF_GREEN 23169 //Brood Affliction Green 23169 + +#define SPELL_CHROMATIC_MUT_1 23174 //Spell cast on player if they get all 5 debuffs + +#define SPELL_FRENZY 28371 //The frenzy spell may be wrong +#define SPELL_ENRAGE 28747 + +#define TEMP_MUTATE_WHISPER "[SD2 Debug] You would be mind controlled here!" + +struct MANGOS_DLL_DECL boss_chromaggusAI : public ScriptedAI +{ + boss_chromaggusAI(Creature *c) : ScriptedAI(c) + { + //Select the 2 breaths that we are going to use until despawned + //5 possiblities for the first breath, 4 for the second, 20 total possiblites + //This way we don't end up casting 2 of the same breath + //TL TL would be stupid + srand(time(NULL)); + switch (rand()%20) + { + //B1 - Incin + case 0: + Breath1_Spell = SPELL_INCINERATE; + Breath2_Spell = SPELL_TIMELAPSE; + break; + case 1: + Breath1_Spell = SPELL_INCINERATE; + Breath2_Spell = SPELL_CORROSIVEACID; + break; + case 2: + Breath1_Spell = SPELL_INCINERATE; + Breath2_Spell = SPELL_IGNITEFLESH; + break; + case 3: + Breath1_Spell = SPELL_INCINERATE; + Breath2_Spell = SPELL_FROSTBURN; + break; + + //B1 - TL + case 4: + Breath1_Spell = SPELL_TIMELAPSE; + Breath2_Spell = SPELL_INCINERATE; + break; + case 5: + Breath1_Spell = SPELL_TIMELAPSE; + Breath2_Spell = SPELL_CORROSIVEACID; + break; + case 6: + Breath1_Spell = SPELL_TIMELAPSE; + Breath2_Spell = SPELL_IGNITEFLESH; + break; + case 7: + Breath1_Spell = SPELL_TIMELAPSE; + Breath2_Spell = SPELL_FROSTBURN; + break; + + //B1 - Acid + case 8: + Breath1_Spell = SPELL_CORROSIVEACID; + Breath2_Spell = SPELL_INCINERATE; + break; + case 9: + Breath1_Spell = SPELL_CORROSIVEACID; + Breath2_Spell = SPELL_TIMELAPSE; + break; + case 10: + Breath1_Spell = SPELL_CORROSIVEACID; + Breath2_Spell = SPELL_IGNITEFLESH; + break; + case 11: + Breath1_Spell = SPELL_CORROSIVEACID; + Breath2_Spell = SPELL_FROSTBURN; + break; + + //B1 - Ignite + case 12: + Breath1_Spell = SPELL_IGNITEFLESH; + Breath2_Spell = SPELL_INCINERATE; + break; + case 13: + Breath1_Spell = SPELL_IGNITEFLESH; + Breath2_Spell = SPELL_CORROSIVEACID; + break; + case 14: + Breath1_Spell = SPELL_IGNITEFLESH; + Breath2_Spell = SPELL_TIMELAPSE; + break; + case 15: + Breath1_Spell = SPELL_IGNITEFLESH; + Breath2_Spell = SPELL_FROSTBURN; + break; + + //B1 - Frost + case 16: + Breath1_Spell = SPELL_FROSTBURN; + Breath2_Spell = SPELL_INCINERATE; + break; + case 17: + Breath1_Spell = SPELL_FROSTBURN; + Breath2_Spell = SPELL_TIMELAPSE; + break; + case 18: + Breath1_Spell = SPELL_FROSTBURN; + Breath2_Spell = SPELL_CORROSIVEACID; + break; + case 19: + Breath1_Spell = SPELL_FROSTBURN; + Breath2_Spell = SPELL_IGNITEFLESH; + break; + }; + + EnterEvadeMode(); + } + + uint32 Breath1_Spell; + uint32 Breath2_Spell; + uint32 CurrentVurln_Spell; + + uint32 Shimmer_Timer; + uint32 Breath1_Timer; + uint32 Breath2_Timer; + uint32 Affliction_Timer; + uint32 Frenzy_Timer; + bool Enraged; + + void Reset() + { + CurrentVurln_Spell = 0; //We use this to store our last vurlnability spell so we can remove it later + + Shimmer_Timer = 0; //Time till we change vurlnerabilites + Breath1_Timer = 30000; //First breath is 30 seconds + Breath2_Timer = 60000; //Second is 1 minute so that we can alternate + Affliction_Timer = 10000; //This is special - 5 seconds means that we cast this on 1 player every 5 sconds + Frenzy_Timer = 15000; + + Enraged = false; + } + + void Aggro(Unit *who) + { + } + + void UpdateAI(const uint32 diff) + { + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + //Shimmer_Timer Timer + if (Shimmer_Timer < diff) + { + //Remove old vurlnability spell + if (CurrentVurln_Spell) + m_creature->RemoveAurasDueToSpell(CurrentVurln_Spell); + + //Cast new random vurlnabilty on self + uint32 spell; + switch (rand()%5) + { + case 0: spell = SPELL_FIRE_VURNALBILTY; break; + case 1: spell = SPELL_FROST_VURNALBILTY; break; + case 2: spell = SPELL_SHADOW_VURNALBILTY; break; + case 3: spell = SPELL_NATURE_VURNALBILTY; break; + case 4: spell = SPELL_ARCANE_VURNALBILTY; break; + } + + DoCast(m_creature,spell); + CurrentVurln_Spell = spell; + + DoTextEmote(EMOTE_SHIMMER, NULL); + Shimmer_Timer = 45000; + }else Shimmer_Timer -= diff; + + //Breath1_Timer + if (Breath1_Timer < diff) + { + DoCast(m_creature->getVictim(),Breath1_Spell); + Breath1_Timer = 60000; + }else Breath1_Timer -= diff; + + //Breath2_Timer + if (Breath2_Timer < diff) + { + DoCast(m_creature->getVictim(),Breath2_Spell); + Breath2_Timer = 60000; + }else Breath2_Timer -= diff; + + //Affliction_Timer + if (Affliction_Timer < diff) + { + uint32 SpellAfflict = 0; + + switch (rand()%5) + { + case 0: SpellAfflict = SPELL_BROODAF_BLUE; break; + case 1: SpellAfflict = SPELL_BROODAF_BLACK; break; + case 2: SpellAfflict = SPELL_BROODAF_RED; break; + case 3: SpellAfflict = SPELL_BROODAF_BRONZE; break; + case 4: SpellAfflict = SPELL_BROODAF_GREEN; break; + } + + std::list::iterator i; + + for (i = m_creature->getThreatManager().getThreatList().begin();i != m_creature->getThreatManager().getThreatList().end(); ++i) + { + Unit* pUnit = NULL; + pUnit = Unit::GetUnit((*m_creature), (*i)->getUnitGuid()); + + if(pUnit) + { + //Cast affliction + DoCast(pUnit, SpellAfflict, true); + + //Chromatic mutation if target is effected by all afflictions + if (pUnit->HasAura(SPELL_BROODAF_BLUE,0) + && pUnit->HasAura(SPELL_BROODAF_BLACK,0) + && pUnit->HasAura(SPELL_BROODAF_RED,0) + && pUnit->HasAura(SPELL_BROODAF_BRONZE,0) + && pUnit->HasAura(SPELL_BROODAF_GREEN,0)) + { + //target->RemoveAllAuras(); + //DoCast(target,SPELL_CHROMATIC_MUT_1); + + //Chromatic mutation is causing issues + //Assuming it is caused by a lack of core support for Charm + //So instead we instant kill our target + + //WORKAROUND + if (pUnit->GetTypeId() == TYPEID_PLAYER) + { + DoWhisper(TEMP_MUTATE_WHISPER, pUnit); + pUnit->CastSpell(pUnit, 5, false); + } + } + } + } + + Affliction_Timer = 10000; + }else Affliction_Timer -= diff; + + //Frenzy_Timer + if (Frenzy_Timer < diff) + { + DoCast(m_creature,SPELL_FRENZY); + DoTextEmote(EMOTE_FRENZY,NULL); + Frenzy_Timer = 10000 + (rand() % 5000); + }else Frenzy_Timer -= diff; + + //Enrage if not already enraged and below 20% + if (!Enraged && (m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < 20) + { + DoCast(m_creature,SPELL_ENRAGE); + Enraged = true; + } + + DoMeleeAttackIfReady(); + } +}; +CreatureAI* GetAI_boss_chromaggus(Creature *_Creature) +{ + return new boss_chromaggusAI (_Creature); +} + +void AddSC_boss_chromaggus() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_chromaggus"; + newscript->GetAI = GetAI_boss_chromaggus; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/blackwing_lair/boss_ebonroc.cpp b/src/bindings/scripts/scripts/zone/blackwing_lair/boss_ebonroc.cpp index 91d57238f01..6f98580d64f 100644 --- a/src/bindings/scripts/scripts/zone/blackwing_lair/boss_ebonroc.cpp +++ b/src/bindings/scripts/scripts/zone/blackwing_lair/boss_ebonroc.cpp @@ -1,103 +1,103 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Ebonroc -SD%Complete: 50 -SDComment: Shadow of Ebonroc needs core support -SDCategory: Blackwing Lair -EndScriptData */ - -#include "precompiled.h" - -#define SPELL_SHADOWFLAME 22539 -#define SPELL_WINGBUFFET 18500 -#define SPELL_SHADOWOFEBONROC 23340 -#define SPELL_HEAL 41386 //Thea Heal spell of his Shadow - -struct MANGOS_DLL_DECL boss_ebonrocAI : public ScriptedAI -{ - boss_ebonrocAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 ShadowFlame_Timer; - uint32 WingBuffet_Timer; - uint32 ShadowOfEbonroc_Timer; - uint32 Heal_Timer; - - void Reset() - { - ShadowFlame_Timer = 15000; //These times are probably wrong - WingBuffet_Timer = 30000; - ShadowOfEbonroc_Timer = 45000; - Heal_Timer = 1000; - } - - void Aggro(Unit *who) - { - DoZoneInCombat(); - } - - void UpdateAI(const uint32 diff) - { - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - //Shadowflame Timer - if (ShadowFlame_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_SHADOWFLAME); - ShadowFlame_Timer = 12000 + rand()%3000; - }else ShadowFlame_Timer -= diff; - - //Wing Buffet Timer - if (WingBuffet_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_WINGBUFFET); - WingBuffet_Timer = 25000; - }else WingBuffet_Timer -= diff; - - //Shadow of Ebonroc Timer - if (ShadowOfEbonroc_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_SHADOWOFEBONROC); - ShadowOfEbonroc_Timer = 25000 + rand()%10000; - }else ShadowOfEbonroc_Timer -= diff; - - if (m_creature->getVictim()->HasAura(SPELL_SHADOWOFEBONROC,0)) - { - if (Heal_Timer < diff) - { - DoCast(m_creature, SPELL_HEAL); - Heal_Timer = 1000 + rand()%2000; - }else Heal_Timer -= diff; - } - - DoMeleeAttackIfReady(); - } -}; -CreatureAI* GetAI_boss_ebonroc(Creature *_Creature) -{ - return new boss_ebonrocAI (_Creature); -} - -void AddSC_boss_ebonroc() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_ebonroc"; - newscript->GetAI = GetAI_boss_ebonroc; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Ebonroc +SD%Complete: 50 +SDComment: Shadow of Ebonroc needs core support +SDCategory: Blackwing Lair +EndScriptData */ + +#include "precompiled.h" + +#define SPELL_SHADOWFLAME 22539 +#define SPELL_WINGBUFFET 18500 +#define SPELL_SHADOWOFEBONROC 23340 +#define SPELL_HEAL 41386 //Thea Heal spell of his Shadow + +struct MANGOS_DLL_DECL boss_ebonrocAI : public ScriptedAI +{ + boss_ebonrocAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 ShadowFlame_Timer; + uint32 WingBuffet_Timer; + uint32 ShadowOfEbonroc_Timer; + uint32 Heal_Timer; + + void Reset() + { + ShadowFlame_Timer = 15000; //These times are probably wrong + WingBuffet_Timer = 30000; + ShadowOfEbonroc_Timer = 45000; + Heal_Timer = 1000; + } + + void Aggro(Unit *who) + { + DoZoneInCombat(); + } + + void UpdateAI(const uint32 diff) + { + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + //Shadowflame Timer + if (ShadowFlame_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_SHADOWFLAME); + ShadowFlame_Timer = 12000 + rand()%3000; + }else ShadowFlame_Timer -= diff; + + //Wing Buffet Timer + if (WingBuffet_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_WINGBUFFET); + WingBuffet_Timer = 25000; + }else WingBuffet_Timer -= diff; + + //Shadow of Ebonroc Timer + if (ShadowOfEbonroc_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_SHADOWOFEBONROC); + ShadowOfEbonroc_Timer = 25000 + rand()%10000; + }else ShadowOfEbonroc_Timer -= diff; + + if (m_creature->getVictim()->HasAura(SPELL_SHADOWOFEBONROC,0)) + { + if (Heal_Timer < diff) + { + DoCast(m_creature, SPELL_HEAL); + Heal_Timer = 1000 + rand()%2000; + }else Heal_Timer -= diff; + } + + DoMeleeAttackIfReady(); + } +}; +CreatureAI* GetAI_boss_ebonroc(Creature *_Creature) +{ + return new boss_ebonrocAI (_Creature); +} + +void AddSC_boss_ebonroc() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_ebonroc"; + newscript->GetAI = GetAI_boss_ebonroc; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/blackwing_lair/boss_firemaw.cpp b/src/bindings/scripts/scripts/zone/blackwing_lair/boss_firemaw.cpp index f4b7848a3bb..22ed8fd5ea6 100644 --- a/src/bindings/scripts/scripts/zone/blackwing_lair/boss_firemaw.cpp +++ b/src/bindings/scripts/scripts/zone/blackwing_lair/boss_firemaw.cpp @@ -1,94 +1,94 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Firemaw -SD%Complete: 100 -SDComment: -SDCategory: Blackwing Lair -EndScriptData */ - -#include "precompiled.h" - -#define SPELL_SHADOWFLAME 22539 -#define SPELL_WINGBUFFET 23339 -#define SPELL_FLAMEBUFFET 23341 - -struct MANGOS_DLL_DECL boss_firemawAI : public ScriptedAI -{ - boss_firemawAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 ShadowFlame_Timer; - uint32 WingBuffet_Timer; - uint32 FlameBuffet_Timer; - - void Reset() - { - ShadowFlame_Timer = 30000; //These times are probably wrong - WingBuffet_Timer = 24000; - FlameBuffet_Timer = 5000; - } - - void Aggro(Unit *who) - { - DoZoneInCombat(); - } - - void UpdateAI(const uint32 diff) - { - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - //ShadowFlame_Timer - if (ShadowFlame_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_SHADOWFLAME); - ShadowFlame_Timer = 15000 + rand()%3000; - }else ShadowFlame_Timer -= diff; - - //WingBuffet_Timer - if (WingBuffet_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_WINGBUFFET); - if(m_creature->getThreatManager().getThreat(m_creature->getVictim())) - m_creature->getThreatManager().modifyThreatPercent(m_creature->getVictim(),-75); - - WingBuffet_Timer = 25000; - }else WingBuffet_Timer -= diff; - - //FlameBuffet_Timer - if (FlameBuffet_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_FLAMEBUFFET); - FlameBuffet_Timer = 5000; - }else FlameBuffet_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; -CreatureAI* GetAI_boss_firemaw(Creature *_Creature) -{ - return new boss_firemawAI (_Creature); -} - -void AddSC_boss_firemaw() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_firemaw"; - newscript->GetAI = GetAI_boss_firemaw; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Firemaw +SD%Complete: 100 +SDComment: +SDCategory: Blackwing Lair +EndScriptData */ + +#include "precompiled.h" + +#define SPELL_SHADOWFLAME 22539 +#define SPELL_WINGBUFFET 23339 +#define SPELL_FLAMEBUFFET 23341 + +struct MANGOS_DLL_DECL boss_firemawAI : public ScriptedAI +{ + boss_firemawAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 ShadowFlame_Timer; + uint32 WingBuffet_Timer; + uint32 FlameBuffet_Timer; + + void Reset() + { + ShadowFlame_Timer = 30000; //These times are probably wrong + WingBuffet_Timer = 24000; + FlameBuffet_Timer = 5000; + } + + void Aggro(Unit *who) + { + DoZoneInCombat(); + } + + void UpdateAI(const uint32 diff) + { + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + //ShadowFlame_Timer + if (ShadowFlame_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_SHADOWFLAME); + ShadowFlame_Timer = 15000 + rand()%3000; + }else ShadowFlame_Timer -= diff; + + //WingBuffet_Timer + if (WingBuffet_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_WINGBUFFET); + if(m_creature->getThreatManager().getThreat(m_creature->getVictim())) + m_creature->getThreatManager().modifyThreatPercent(m_creature->getVictim(),-75); + + WingBuffet_Timer = 25000; + }else WingBuffet_Timer -= diff; + + //FlameBuffet_Timer + if (FlameBuffet_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_FLAMEBUFFET); + FlameBuffet_Timer = 5000; + }else FlameBuffet_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; +CreatureAI* GetAI_boss_firemaw(Creature *_Creature) +{ + return new boss_firemawAI (_Creature); +} + +void AddSC_boss_firemaw() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_firemaw"; + newscript->GetAI = GetAI_boss_firemaw; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/blackwing_lair/boss_flamegor.cpp b/src/bindings/scripts/scripts/zone/blackwing_lair/boss_flamegor.cpp index 5bc6531c45a..514f10651a7 100644 --- a/src/bindings/scripts/scripts/zone/blackwing_lair/boss_flamegor.cpp +++ b/src/bindings/scripts/scripts/zone/blackwing_lair/boss_flamegor.cpp @@ -1,94 +1,94 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Flamegor -SD%Complete: 100 -SDComment: -SDCategory: Blackwing Lair -EndScriptData */ - -#include "precompiled.h" - -#define SPELL_SHADOWFLAME 22539 -#define SPELL_WINGBUFFET 23339 -#define SPELL_FRENZY 23342 //This spell periodically triggers fire nova - -struct MANGOS_DLL_DECL boss_flamegorAI : public ScriptedAI -{ - boss_flamegorAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 ShadowFlame_Timer; - uint32 WingBuffet_Timer; - uint32 Frenzy_Timer; - - void Reset() - { - ShadowFlame_Timer = 21000; //These times are probably wrong - WingBuffet_Timer = 35000; - Frenzy_Timer = 10000; - } - - void Aggro(Unit *who) - { - DoZoneInCombat(); - } - - void UpdateAI(const uint32 diff) - { - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - //ShadowFlame_Timer - if (ShadowFlame_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_SHADOWFLAME); - ShadowFlame_Timer = 15000 + rand()%7000; - }else ShadowFlame_Timer -= diff; - - //WingBuffet_Timer - if (WingBuffet_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_WINGBUFFET); - if(m_creature->getThreatManager().getThreat(m_creature->getVictim())) - m_creature->getThreatManager().modifyThreatPercent(m_creature->getVictim(),-75); - - WingBuffet_Timer = 25000; - }else WingBuffet_Timer -= diff; - - //Frenzy_Timer - if (Frenzy_Timer < diff) - { - DoCast(m_creature,SPELL_FRENZY); - Frenzy_Timer = 8000 + (rand()%2000); - }else Frenzy_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; -CreatureAI* GetAI_boss_flamegor(Creature *_Creature) -{ - return new boss_flamegorAI (_Creature); -} - -void AddSC_boss_flamegor() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_flamegor"; - newscript->GetAI = GetAI_boss_flamegor; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Flamegor +SD%Complete: 100 +SDComment: +SDCategory: Blackwing Lair +EndScriptData */ + +#include "precompiled.h" + +#define SPELL_SHADOWFLAME 22539 +#define SPELL_WINGBUFFET 23339 +#define SPELL_FRENZY 23342 //This spell periodically triggers fire nova + +struct MANGOS_DLL_DECL boss_flamegorAI : public ScriptedAI +{ + boss_flamegorAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 ShadowFlame_Timer; + uint32 WingBuffet_Timer; + uint32 Frenzy_Timer; + + void Reset() + { + ShadowFlame_Timer = 21000; //These times are probably wrong + WingBuffet_Timer = 35000; + Frenzy_Timer = 10000; + } + + void Aggro(Unit *who) + { + DoZoneInCombat(); + } + + void UpdateAI(const uint32 diff) + { + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + //ShadowFlame_Timer + if (ShadowFlame_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_SHADOWFLAME); + ShadowFlame_Timer = 15000 + rand()%7000; + }else ShadowFlame_Timer -= diff; + + //WingBuffet_Timer + if (WingBuffet_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_WINGBUFFET); + if(m_creature->getThreatManager().getThreat(m_creature->getVictim())) + m_creature->getThreatManager().modifyThreatPercent(m_creature->getVictim(),-75); + + WingBuffet_Timer = 25000; + }else WingBuffet_Timer -= diff; + + //Frenzy_Timer + if (Frenzy_Timer < diff) + { + DoCast(m_creature,SPELL_FRENZY); + Frenzy_Timer = 8000 + (rand()%2000); + }else Frenzy_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; +CreatureAI* GetAI_boss_flamegor(Creature *_Creature) +{ + return new boss_flamegorAI (_Creature); +} + +void AddSC_boss_flamegor() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_flamegor"; + newscript->GetAI = GetAI_boss_flamegor; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/blackwing_lair/boss_nefarian.cpp b/src/bindings/scripts/scripts/zone/blackwing_lair/boss_nefarian.cpp index 31495b35d9d..c534b213e8d 100644 --- a/src/bindings/scripts/scripts/zone/blackwing_lair/boss_nefarian.cpp +++ b/src/bindings/scripts/scripts/zone/blackwing_lair/boss_nefarian.cpp @@ -1,250 +1,250 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Nefarian -SD%Complete: 100 -SDComment: Some issues with class calls effecting more than one class -SDCategory: Blackwing Lair -EndScriptData */ - -#include "precompiled.h" - -#define SAY_AGGRO "Well done, my minions. The mortals' courage begins to wane! Now, let's see how they contend with the true Lord of Blackrock Spire!" -#define SAY_DEATH "This cannot be! I am the Master here! You mortals are nothing to my kind! DO YOU HEAR? NOTHING!" -#define SAY_RAISE_SKELETONS "Impossible! Rise my minions! Serve your master once more!" -#define SAY_SHADOWFLAME "Burn, you wretches! Burn!" -#define SAY_SLAY "Worthless $N! Your friends will join you soon enough!" -#define SAY_XHEALTH "Enough! Now you vermin shall feel the force of my birthright, the fury of the earth itself." -#define SAY_GAMESBEGIN "Let the games begin!" -#define SAY_START "" - -#define SOUND_AGGRO 8288 -#define SOUND_DEATH 8292 -#define SOUND_RAISE_SKELETONS 8291 -#define SOUND_SHADOWFLAME 8290 -#define SOUND_SLAY 8293 -#define SOUND_XHEALTH 8289 -#define SOUND_GAMESBEGIN 8279 -#define SOUND_START 8280 - -#define SPELL_SHADOWFLAME_INITIAL 22972 -#define SPELL_SHADOWFLAME 22539 -#define SPELL_BELLOWINGROAR 22686 -#define SPELL_VEILOFSHADOW 7068 -#define SPELL_CLEAVE 20691 -#define SPELL_TAILLASH 23364 -#define SPELL_BONECONTRUST 23363 //23362, 23361 - -#define SPELL_MAGE 23410 //wild magic -#define SPELL_WARRIOR 23397 //beserk -#define SPELL_DRUID 23398 // cat form -#define SPELL_PRIEST 23401 // corrupted healing -#define SPELL_PALADIN 23418 //syphon blessing -#define SPELL_SHAMAN 23425 //totems -#define SPELL_WARLOCK 23427 //infernals -#define SPELL_HUNTER 23436 //bow broke -#define SPELL_ROGUE 23414 //Paralise - -#define SAY_MAGE "Mages too? You should be more careful when you play with magic..." -#define SAY_WARRIOR "Warriors, I know you can hit harder than that! Let's see it!" -#define SAY_DRUID "Druids and your silly shapeshifting. Let's see it in action!" -#define SAY_PRIEST "Priests! If you're going to keep healing like that, we might as well make it a little more interesting!" -#define SAY_PALADIN "Paladins, I've heard you have many lives. Show me." -#define SAY_SHAMAN "Shamans, show me what your totems can do!" -#define SAY_WARLOCK "Warlocks, you shouldn't be playing with magic you don't understand. See what happens?" -#define SAY_HUNTER "Hunters and your annoying pea-shooters!" -#define SAY_ROGUE "Rogues? Stop hiding and face me!" - -struct MANGOS_DLL_DECL boss_nefarianAI : public ScriptedAI -{ - boss_nefarianAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 ShadowFlame_Timer; - uint32 BellowingRoar_Timer; - uint32 VeilOfShadow_Timer; - uint32 Cleave_Timer; - uint32 TailLash_Timer; - uint32 ClassCall_Timer; - bool Phase3; - - void Reset() - { - ShadowFlame_Timer = 12000; //These times are probably wrong - BellowingRoar_Timer = 30000; - VeilOfShadow_Timer = 15000; - Cleave_Timer = 7000; - TailLash_Timer = 10000; - ClassCall_Timer = 35000; //35-40 seconds - Phase3 = false; - - m_creature->ApplySpellImmune(0, IMMUNITY_STATE, SPELL_AURA_MOD_TAUNT, true); - m_creature->ApplySpellImmune(1, IMMUNITY_EFFECT,SPELL_EFFECT_ATTACK_ME, true); - } - - void KilledUnit(Unit* Victim) - { - if (rand()%5) - return; - - DoYell(SAY_SLAY,LANG_UNIVERSAL,Victim); - DoPlaySoundToSet(m_creature, SOUND_SLAY); - } - - void JustDied(Unit* Killer) - { - DoYell(SAY_DEATH,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature, SOUND_DEATH); - } - - void Aggro(Unit *who) - { - switch (rand()%3) - { - case 0: - DoYell(SAY_XHEALTH,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_XHEALTH); - break; - case 1: - DoYell(SAY_AGGRO,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_AGGRO); - break; - case 2: - DoYell(SAY_SHADOWFLAME,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_SHADOWFLAME); - break; - } - - DoCast(who,SPELL_SHADOWFLAME_INITIAL); - DoZoneInCombat(); - } - - void UpdateAI(const uint32 diff) - { - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - //ShadowFlame_Timer - if (ShadowFlame_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_SHADOWFLAME); - ShadowFlame_Timer = 12000; - }else ShadowFlame_Timer -= diff; - - //BellowingRoar_Timer - if (BellowingRoar_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_BELLOWINGROAR); - BellowingRoar_Timer = 30000; - }else BellowingRoar_Timer -= diff; - - //VeilOfShadow_Timer - if (VeilOfShadow_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_VEILOFSHADOW); - VeilOfShadow_Timer = 15000; - }else VeilOfShadow_Timer -= diff; - - //Cleave_Timer - if (Cleave_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_CLEAVE); - Cleave_Timer = 7000; - }else Cleave_Timer -= diff; - - //TailLash_Timer - if (TailLash_Timer < diff) - { - //Cast NYI since we need a better check for behind target - //DoCast(m_creature->getVictim(),SPELL_TAILLASH); - - TailLash_Timer = 10000; - }else TailLash_Timer -= diff; - - //ClassCall_Timer - if (ClassCall_Timer < diff) - { - //Cast a random class call - //On official it is based on what classes are currently on the hostil list - //but we can't do that yet so just randomly call one - - switch (rand()%9) - { - case 0: - DoYell(SAY_MAGE,LANG_UNIVERSAL,NULL); - DoCast(m_creature,SPELL_MAGE); - break; - case 1: - DoYell(SAY_WARRIOR,LANG_UNIVERSAL,NULL); - DoCast(m_creature,SPELL_WARRIOR); - break; - case 2: - DoYell(SAY_DRUID,LANG_UNIVERSAL,NULL); - DoCast(m_creature,SPELL_DRUID); - break; - case 3: - DoYell(SAY_PRIEST,LANG_UNIVERSAL,NULL); - DoCast(m_creature,SPELL_PRIEST); - break; - case 4: - DoYell(SAY_PALADIN,LANG_UNIVERSAL,NULL); - DoCast(m_creature,SPELL_PALADIN); - break; - case 5: - DoYell(SAY_SHAMAN,LANG_UNIVERSAL,NULL); - DoCast(m_creature,SPELL_SHAMAN); - break; - case 6: - DoYell(SAY_WARLOCK,LANG_UNIVERSAL,NULL); - DoCast(m_creature,SPELL_WARLOCK); - break; - case 7: - DoYell(SAY_HUNTER,LANG_UNIVERSAL,NULL); - DoCast(m_creature,SPELL_HUNTER); - break; - case 8: - DoYell(SAY_ROGUE,LANG_UNIVERSAL,NULL); - DoCast(m_creature,SPELL_ROGUE); - break; - } - - ClassCall_Timer = 35000 + (rand() % 5000); - }else ClassCall_Timer -= diff; - - //Phase3 begins when we are below X health - if (!Phase3 && (m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < 20) - { - Phase3 = true; - DoYell(SAY_RAISE_SKELETONS,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_RAISE_SKELETONS); - } - - DoMeleeAttackIfReady(); - } -}; -CreatureAI* GetAI_boss_nefarian(Creature *_Creature) -{ - return new boss_nefarianAI (_Creature); -} - -void AddSC_boss_nefarian() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_nefarian"; - newscript->GetAI = GetAI_boss_nefarian; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Nefarian +SD%Complete: 100 +SDComment: Some issues with class calls effecting more than one class +SDCategory: Blackwing Lair +EndScriptData */ + +#include "precompiled.h" + +#define SAY_AGGRO "Well done, my minions. The mortals' courage begins to wane! Now, let's see how they contend with the true Lord of Blackrock Spire!" +#define SAY_DEATH "This cannot be! I am the Master here! You mortals are nothing to my kind! DO YOU HEAR? NOTHING!" +#define SAY_RAISE_SKELETONS "Impossible! Rise my minions! Serve your master once more!" +#define SAY_SHADOWFLAME "Burn, you wretches! Burn!" +#define SAY_SLAY "Worthless $N! Your friends will join you soon enough!" +#define SAY_XHEALTH "Enough! Now you vermin shall feel the force of my birthright, the fury of the earth itself." +#define SAY_GAMESBEGIN "Let the games begin!" +#define SAY_START "" + +#define SOUND_AGGRO 8288 +#define SOUND_DEATH 8292 +#define SOUND_RAISE_SKELETONS 8291 +#define SOUND_SHADOWFLAME 8290 +#define SOUND_SLAY 8293 +#define SOUND_XHEALTH 8289 +#define SOUND_GAMESBEGIN 8279 +#define SOUND_START 8280 + +#define SPELL_SHADOWFLAME_INITIAL 22972 +#define SPELL_SHADOWFLAME 22539 +#define SPELL_BELLOWINGROAR 22686 +#define SPELL_VEILOFSHADOW 7068 +#define SPELL_CLEAVE 20691 +#define SPELL_TAILLASH 23364 +#define SPELL_BONECONTRUST 23363 //23362, 23361 + +#define SPELL_MAGE 23410 //wild magic +#define SPELL_WARRIOR 23397 //beserk +#define SPELL_DRUID 23398 // cat form +#define SPELL_PRIEST 23401 // corrupted healing +#define SPELL_PALADIN 23418 //syphon blessing +#define SPELL_SHAMAN 23425 //totems +#define SPELL_WARLOCK 23427 //infernals +#define SPELL_HUNTER 23436 //bow broke +#define SPELL_ROGUE 23414 //Paralise + +#define SAY_MAGE "Mages too? You should be more careful when you play with magic..." +#define SAY_WARRIOR "Warriors, I know you can hit harder than that! Let's see it!" +#define SAY_DRUID "Druids and your silly shapeshifting. Let's see it in action!" +#define SAY_PRIEST "Priests! If you're going to keep healing like that, we might as well make it a little more interesting!" +#define SAY_PALADIN "Paladins, I've heard you have many lives. Show me." +#define SAY_SHAMAN "Shamans, show me what your totems can do!" +#define SAY_WARLOCK "Warlocks, you shouldn't be playing with magic you don't understand. See what happens?" +#define SAY_HUNTER "Hunters and your annoying pea-shooters!" +#define SAY_ROGUE "Rogues? Stop hiding and face me!" + +struct MANGOS_DLL_DECL boss_nefarianAI : public ScriptedAI +{ + boss_nefarianAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 ShadowFlame_Timer; + uint32 BellowingRoar_Timer; + uint32 VeilOfShadow_Timer; + uint32 Cleave_Timer; + uint32 TailLash_Timer; + uint32 ClassCall_Timer; + bool Phase3; + + void Reset() + { + ShadowFlame_Timer = 12000; //These times are probably wrong + BellowingRoar_Timer = 30000; + VeilOfShadow_Timer = 15000; + Cleave_Timer = 7000; + TailLash_Timer = 10000; + ClassCall_Timer = 35000; //35-40 seconds + Phase3 = false; + + m_creature->ApplySpellImmune(0, IMMUNITY_STATE, SPELL_AURA_MOD_TAUNT, true); + m_creature->ApplySpellImmune(1, IMMUNITY_EFFECT,SPELL_EFFECT_ATTACK_ME, true); + } + + void KilledUnit(Unit* Victim) + { + if (rand()%5) + return; + + DoYell(SAY_SLAY,LANG_UNIVERSAL,Victim); + DoPlaySoundToSet(m_creature, SOUND_SLAY); + } + + void JustDied(Unit* Killer) + { + DoYell(SAY_DEATH,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature, SOUND_DEATH); + } + + void Aggro(Unit *who) + { + switch (rand()%3) + { + case 0: + DoYell(SAY_XHEALTH,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_XHEALTH); + break; + case 1: + DoYell(SAY_AGGRO,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_AGGRO); + break; + case 2: + DoYell(SAY_SHADOWFLAME,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_SHADOWFLAME); + break; + } + + DoCast(who,SPELL_SHADOWFLAME_INITIAL); + DoZoneInCombat(); + } + + void UpdateAI(const uint32 diff) + { + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + //ShadowFlame_Timer + if (ShadowFlame_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_SHADOWFLAME); + ShadowFlame_Timer = 12000; + }else ShadowFlame_Timer -= diff; + + //BellowingRoar_Timer + if (BellowingRoar_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_BELLOWINGROAR); + BellowingRoar_Timer = 30000; + }else BellowingRoar_Timer -= diff; + + //VeilOfShadow_Timer + if (VeilOfShadow_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_VEILOFSHADOW); + VeilOfShadow_Timer = 15000; + }else VeilOfShadow_Timer -= diff; + + //Cleave_Timer + if (Cleave_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_CLEAVE); + Cleave_Timer = 7000; + }else Cleave_Timer -= diff; + + //TailLash_Timer + if (TailLash_Timer < diff) + { + //Cast NYI since we need a better check for behind target + //DoCast(m_creature->getVictim(),SPELL_TAILLASH); + + TailLash_Timer = 10000; + }else TailLash_Timer -= diff; + + //ClassCall_Timer + if (ClassCall_Timer < diff) + { + //Cast a random class call + //On official it is based on what classes are currently on the hostil list + //but we can't do that yet so just randomly call one + + switch (rand()%9) + { + case 0: + DoYell(SAY_MAGE,LANG_UNIVERSAL,NULL); + DoCast(m_creature,SPELL_MAGE); + break; + case 1: + DoYell(SAY_WARRIOR,LANG_UNIVERSAL,NULL); + DoCast(m_creature,SPELL_WARRIOR); + break; + case 2: + DoYell(SAY_DRUID,LANG_UNIVERSAL,NULL); + DoCast(m_creature,SPELL_DRUID); + break; + case 3: + DoYell(SAY_PRIEST,LANG_UNIVERSAL,NULL); + DoCast(m_creature,SPELL_PRIEST); + break; + case 4: + DoYell(SAY_PALADIN,LANG_UNIVERSAL,NULL); + DoCast(m_creature,SPELL_PALADIN); + break; + case 5: + DoYell(SAY_SHAMAN,LANG_UNIVERSAL,NULL); + DoCast(m_creature,SPELL_SHAMAN); + break; + case 6: + DoYell(SAY_WARLOCK,LANG_UNIVERSAL,NULL); + DoCast(m_creature,SPELL_WARLOCK); + break; + case 7: + DoYell(SAY_HUNTER,LANG_UNIVERSAL,NULL); + DoCast(m_creature,SPELL_HUNTER); + break; + case 8: + DoYell(SAY_ROGUE,LANG_UNIVERSAL,NULL); + DoCast(m_creature,SPELL_ROGUE); + break; + } + + ClassCall_Timer = 35000 + (rand() % 5000); + }else ClassCall_Timer -= diff; + + //Phase3 begins when we are below X health + if (!Phase3 && (m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < 20) + { + Phase3 = true; + DoYell(SAY_RAISE_SKELETONS,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_RAISE_SKELETONS); + } + + DoMeleeAttackIfReady(); + } +}; +CreatureAI* GetAI_boss_nefarian(Creature *_Creature) +{ + return new boss_nefarianAI (_Creature); +} + +void AddSC_boss_nefarian() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_nefarian"; + newscript->GetAI = GetAI_boss_nefarian; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/blackwing_lair/boss_razorgore.cpp b/src/bindings/scripts/scripts/zone/blackwing_lair/boss_razorgore.cpp index 78441b63888..203cf33491a 100644 --- a/src/bindings/scripts/scripts/zone/blackwing_lair/boss_razorgore.cpp +++ b/src/bindings/scripts/scripts/zone/blackwing_lair/boss_razorgore.cpp @@ -1,126 +1,126 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Razorgore -SD%Complete: 50 -SDComment: Needs additional review. Phase 1 NYI -SDCategory: Blackwing Lair -EndScriptData */ - -#include "precompiled.h" - -//Razorgore Phase 2 Script - -#define SAY_NPC_DEATH "If I fall into the abyss I'll take all of you mortals with me..." -#define SOUND_NPC_DEATH 8278 -#define SAY_EGGS_BREAK3 "No! Not another one! I'll have your heads for this atrocity." -#define SOUND_EGGS_BREAK3 8277 - -#define SPELL_CLEAVE 22540 -#define SPELL_WARSTOMP 24375 -#define SPELL_FIREBALLVOLLEY 22425 -#define SPELL_CONFLAGRATION 23023 - -struct MANGOS_DLL_DECL boss_razorgoreAI : public ScriptedAI -{ - boss_razorgoreAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 Cleave_Timer; - uint32 WarStomp_Timer; - uint32 FireballVolley_Timer; - uint32 Conflagration_Timer; - - void Reset() - { - Cleave_Timer = 15000; //These times are probably wrong - WarStomp_Timer = 35000; - FireballVolley_Timer = 7000; - Conflagration_Timer = 12000; - - m_creature->ApplySpellImmune(0, IMMUNITY_STATE, SPELL_AURA_MOD_TAUNT, true); - m_creature->ApplySpellImmune(1, IMMUNITY_EFFECT,SPELL_EFFECT_ATTACK_ME, true); - } - - void Aggro(Unit *who) - { - DoZoneInCombat(); - } - - void UpdateAI(const uint32 diff) - { - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - //Cleave_Timer - if (Cleave_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_CLEAVE); - Cleave_Timer = 7000 + rand()%3000; - }else Cleave_Timer -= diff; - - //WarStomp_Timer - if (WarStomp_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_WARSTOMP); - WarStomp_Timer = 15000 + rand()%10000; - }else WarStomp_Timer -= diff; - - //FireballVolley_Timer - if (FireballVolley_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_FIREBALLVOLLEY); - FireballVolley_Timer = 12000 + rand()%3000; - }else FireballVolley_Timer -= diff; - - //Conflagration_Timer - if (Conflagration_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_CONFLAGRATION); - //We will remove this threat reduction and add an aura check. - - //if(m_creature->getThreatManager().getThreat(m_creature->getVictim())) - //m_creature->getThreatManager().modifyThreatPercent(m_creature->getVictim(),-50); - - Conflagration_Timer = 12000; - }else Conflagration_Timer -= diff; - - // Aura Check. If the gamer is affected by confliguration we attack a random gamer. - if (m_creature->getVictim()->HasAura(SPELL_CONFLAGRATION,0)) - { - Unit* target = NULL; - target = SelectUnit(SELECT_TARGET_RANDOM,1); - if (target) - m_creature->TauntApply(target); - } - - DoMeleeAttackIfReady(); - } -}; - -CreatureAI* GetAI_boss_razorgore(Creature *_Creature) -{ - return new boss_razorgoreAI (_Creature); -} - -void AddSC_boss_razorgore() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_razorgore"; - newscript->GetAI = GetAI_boss_razorgore; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Razorgore +SD%Complete: 50 +SDComment: Needs additional review. Phase 1 NYI +SDCategory: Blackwing Lair +EndScriptData */ + +#include "precompiled.h" + +//Razorgore Phase 2 Script + +#define SAY_NPC_DEATH "If I fall into the abyss I'll take all of you mortals with me..." +#define SOUND_NPC_DEATH 8278 +#define SAY_EGGS_BREAK3 "No! Not another one! I'll have your heads for this atrocity." +#define SOUND_EGGS_BREAK3 8277 + +#define SPELL_CLEAVE 22540 +#define SPELL_WARSTOMP 24375 +#define SPELL_FIREBALLVOLLEY 22425 +#define SPELL_CONFLAGRATION 23023 + +struct MANGOS_DLL_DECL boss_razorgoreAI : public ScriptedAI +{ + boss_razorgoreAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 Cleave_Timer; + uint32 WarStomp_Timer; + uint32 FireballVolley_Timer; + uint32 Conflagration_Timer; + + void Reset() + { + Cleave_Timer = 15000; //These times are probably wrong + WarStomp_Timer = 35000; + FireballVolley_Timer = 7000; + Conflagration_Timer = 12000; + + m_creature->ApplySpellImmune(0, IMMUNITY_STATE, SPELL_AURA_MOD_TAUNT, true); + m_creature->ApplySpellImmune(1, IMMUNITY_EFFECT,SPELL_EFFECT_ATTACK_ME, true); + } + + void Aggro(Unit *who) + { + DoZoneInCombat(); + } + + void UpdateAI(const uint32 diff) + { + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + //Cleave_Timer + if (Cleave_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_CLEAVE); + Cleave_Timer = 7000 + rand()%3000; + }else Cleave_Timer -= diff; + + //WarStomp_Timer + if (WarStomp_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_WARSTOMP); + WarStomp_Timer = 15000 + rand()%10000; + }else WarStomp_Timer -= diff; + + //FireballVolley_Timer + if (FireballVolley_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_FIREBALLVOLLEY); + FireballVolley_Timer = 12000 + rand()%3000; + }else FireballVolley_Timer -= diff; + + //Conflagration_Timer + if (Conflagration_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_CONFLAGRATION); + //We will remove this threat reduction and add an aura check. + + //if(m_creature->getThreatManager().getThreat(m_creature->getVictim())) + //m_creature->getThreatManager().modifyThreatPercent(m_creature->getVictim(),-50); + + Conflagration_Timer = 12000; + }else Conflagration_Timer -= diff; + + // Aura Check. If the gamer is affected by confliguration we attack a random gamer. + if (m_creature->getVictim()->HasAura(SPELL_CONFLAGRATION,0)) + { + Unit* target = NULL; + target = SelectUnit(SELECT_TARGET_RANDOM,1); + if (target) + m_creature->TauntApply(target); + } + + DoMeleeAttackIfReady(); + } +}; + +CreatureAI* GetAI_boss_razorgore(Creature *_Creature) +{ + return new boss_razorgoreAI (_Creature); +} + +void AddSC_boss_razorgore() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_razorgore"; + newscript->GetAI = GetAI_boss_razorgore; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/blackwing_lair/boss_vaelastrasz.cpp b/src/bindings/scripts/scripts/zone/blackwing_lair/boss_vaelastrasz.cpp index 217eebfb852..f11de6487be 100644 --- a/src/bindings/scripts/scripts/zone/blackwing_lair/boss_vaelastrasz.cpp +++ b/src/bindings/scripts/scripts/zone/blackwing_lair/boss_vaelastrasz.cpp @@ -1,278 +1,278 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Vaelastrasz -SD%Complete: 75 -SDComment: Burning Adrenaline not correctly implemented in core -SDCategory: Blackwing Lair -EndScriptData */ - -#include "precompiled.h" - -#define SPELL_ESSENCEOFTHERED 23513 -#define SPELL_FLAMEBREATH 23461 -#define SPELL_FIRENOVA 23462 -#define SPELL_TAILSWIPE 15847 -#define SPELL_BURNINGADRENALINE 23620 -#define SPELL_CLEAVE 20684 //Chain cleave is most likely named something different and contains a dummy effect - -#define SAY_LINE1 "Too late...friends. Nefarius' corruption has taken hold. I cannot...control myself. " -#define SOUND_LINE1 8281 - -#define SAY_LINE2 "I beg you Mortals, flee! Flee before I lose all control. The Black Fire rages within my heart. I must release it!" -#define SOUND_LINE2 8282 - -#define SAY_LINE3 "FLAME! DEATH! DESTRUCTION! COWER MORTALS BEFORE THE WRATH OF LORD....NO! I MUST FIGHT THIS!" -#define SOUND_LINE3 8283 - -#define SAY_HALFLIFE "Nefarius' hate has made me stronger than ever before. You should have fled, while you could, mortals! The fury of Blackrock courses through my veins! " -#define SOUND_HALFLIFE 8285 - -#define SAY_KILLTARGET "Forgive me $N, your death only adds to my failure." -#define SOUND_KILLTARGET 8284 - -#define GOSSIP_ITEM "Start Event " - -struct MANGOS_DLL_DECL boss_vaelAI : public ScriptedAI -{ - boss_vaelAI(Creature *c) : ScriptedAI(c) - { - c->SetUInt32Value(UNIT_NPC_FLAGS,1); - c->setFaction(35); - c->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - Reset(); - } - - uint64 PlayerGUID; - uint32 SpeachTimer; - uint32 SpeachNum; - uint32 Cleave_Timer; - uint32 FlameBreath_Timer; - uint32 FireNova_Timer; - uint32 BurningAdrenalineCaster_Timer; - uint32 BurningAdrenalineTank_Timer; - uint32 TailSwipe_Timer; - bool HasYelled; - bool DoingSpeach; - - void Reset() - { - PlayerGUID = 0; - SpeachTimer = 0; - SpeachNum = 0; - Cleave_Timer = 8000; //These times are probably wrong - FlameBreath_Timer = 11000; - BurningAdrenalineCaster_Timer = 15000; - BurningAdrenalineTank_Timer = 45000; - FireNova_Timer = 5000; - TailSwipe_Timer = 20000; - HasYelled = false; - DoingSpeach = false; - - m_creature->ApplySpellImmune(0, IMMUNITY_STATE, SPELL_AURA_MOD_TAUNT, true); - m_creature->ApplySpellImmune(1, IMMUNITY_EFFECT,SPELL_EFFECT_ATTACK_ME, true); - } - - void BeginSpeach(Unit* target) - { - //Stand up and begin speach - PlayerGUID = target->GetGUID(); - - //10 seconds - DoYell(SAY_LINE1,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_LINE1); - SpeachTimer = 10000; - SpeachNum = 0; - DoingSpeach = true; - } - - void KilledUnit(Unit *victim) - { - if (rand()%5) - return; - - DoYell(SAY_KILLTARGET,LANG_UNIVERSAL,victim); - DoPlaySoundToSet(m_creature,SOUND_KILLTARGET); - } - - void Aggro(Unit *who) - { - DoCast(m_creature,SPELL_ESSENCEOFTHERED); - DoZoneInCombat(); - } - - void UpdateAI(const uint32 diff) - { - //Speach - if (DoingSpeach) - if (SpeachTimer < diff) - { - switch (SpeachNum) - { - case 0: - //16 seconds till next line - DoYell(SAY_LINE2,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_LINE2); - SpeachTimer = 16000; - SpeachNum++; - break; - - case 1: - //This one is actually 16 seconds but we only go to 10 seconds because he starts attacking after he says "I must fight this!" - DoYell(SAY_LINE3,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_LINE3); - SpeachTimer = 10000; - SpeachNum++; - break; - - case 2: - default: - m_creature->setFaction(103); - m_creature->SetHealth(int(m_creature->GetMaxHealth()*.3)); - if (PlayerGUID && Unit::GetUnit((*m_creature),PlayerGUID)) - { - DoStartAttackAndMovement(Unit::GetUnit((*m_creature),PlayerGUID)); - DoCast(m_creature,SPELL_ESSENCEOFTHERED); - } - - SpeachTimer = 0; - DoingSpeach = false; - break; - } - }else SpeachTimer -= diff; - - //Return since we have no target - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - // Yell if hp lower than 15% - if (m_creature->GetHealth()*100 / m_creature->GetMaxHealth() < 15 && !HasYelled) - { - //Say our dialog - DoYell(SAY_HALFLIFE,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_HALFLIFE); - HasYelled = true; - } - - //Cleave_Timer - if (Cleave_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_CLEAVE); - Cleave_Timer = 15000; - }else Cleave_Timer -= diff; - - //FlameBreath_Timer - if (FlameBreath_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_FLAMEBREATH); - FlameBreath_Timer = 4000 + rand()%4000; - }else FlameBreath_Timer -= diff; - - //BurningAdrenalineCaster_Timer - if (BurningAdrenalineCaster_Timer < diff) - { - Unit* target = NULL; - - int i = 0 ; - while (i < 3) // max 3 tries to get a random target with power_mana - { - ++i; - target = SelectUnit(SELECT_TARGET_RANDOM,1);//not aggro leader - if (target) - if (target->getPowerType() == POWER_MANA) - i=3; - } - if (target) // cast on self (see below) - target->CastSpell(target,SPELL_BURNINGADRENALINE,1); - - BurningAdrenalineCaster_Timer = 15000; - }else BurningAdrenalineCaster_Timer -= diff; - - //BurningAdrenalineTank_Timer - if (BurningAdrenalineTank_Timer < diff) - { - // have the victim cast the spell on himself otherwise the third effect aura will be applied - // to Vael instead of the player - - m_creature->getVictim()->CastSpell(m_creature->getVictim(),SPELL_BURNINGADRENALINE,1); - - BurningAdrenalineTank_Timer = 45000; - }else BurningAdrenalineTank_Timer -= diff; - - //FireNova_Timer - if (FireNova_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_FIRENOVA); - FireNova_Timer = 5000; - }else FireNova_Timer -= diff; - - //TailSwipe_Timer - if (TailSwipe_Timer < diff) - { - //Only cast if we are behind - /*if (!m_creature->HasInArc( M_PI, m_creature->getVictim())) - { - DoCast(m_creature->getVictim(),SPELL_TAILSWIPE); - }*/ - - TailSwipe_Timer = 20000; - }else TailSwipe_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; - -void SendDefaultMenu_boss_vael(Player *player, Creature *_Creature, uint32 action) -{ - if (action == GOSSIP_ACTION_INFO_DEF + 1) //Fight time - { - player->CLOSE_GOSSIP_MENU(); - ((boss_vaelAI*)_Creature->AI())->BeginSpeach((Unit*)player); - } -} - -bool GossipSelect_boss_vael(Player *player, Creature *_Creature, uint32 sender, uint32 action ) -{ - if (sender == GOSSIP_SENDER_MAIN) - SendDefaultMenu_boss_vael(player, _Creature, action); - - return true; -} - -bool GossipHello_boss_vael(Player *player, Creature *_Creature) -{ - player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); - player->SEND_GOSSIP_MENU(907,_Creature->GetGUID()); - - return true; -} - -CreatureAI* GetAI_boss_vael(Creature *_Creature) -{ - return new boss_vaelAI (_Creature); -} - -void AddSC_boss_vael() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_vaelastrasz"; - newscript->GetAI = GetAI_boss_vael; - newscript->pGossipHello = &GossipHello_boss_vael; - newscript->pGossipSelect = &GossipSelect_boss_vael; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Vaelastrasz +SD%Complete: 75 +SDComment: Burning Adrenaline not correctly implemented in core +SDCategory: Blackwing Lair +EndScriptData */ + +#include "precompiled.h" + +#define SPELL_ESSENCEOFTHERED 23513 +#define SPELL_FLAMEBREATH 23461 +#define SPELL_FIRENOVA 23462 +#define SPELL_TAILSWIPE 15847 +#define SPELL_BURNINGADRENALINE 23620 +#define SPELL_CLEAVE 20684 //Chain cleave is most likely named something different and contains a dummy effect + +#define SAY_LINE1 "Too late...friends. Nefarius' corruption has taken hold. I cannot...control myself. " +#define SOUND_LINE1 8281 + +#define SAY_LINE2 "I beg you Mortals, flee! Flee before I lose all control. The Black Fire rages within my heart. I must release it!" +#define SOUND_LINE2 8282 + +#define SAY_LINE3 "FLAME! DEATH! DESTRUCTION! COWER MORTALS BEFORE THE WRATH OF LORD....NO! I MUST FIGHT THIS!" +#define SOUND_LINE3 8283 + +#define SAY_HALFLIFE "Nefarius' hate has made me stronger than ever before. You should have fled, while you could, mortals! The fury of Blackrock courses through my veins! " +#define SOUND_HALFLIFE 8285 + +#define SAY_KILLTARGET "Forgive me $N, your death only adds to my failure." +#define SOUND_KILLTARGET 8284 + +#define GOSSIP_ITEM "Start Event " + +struct MANGOS_DLL_DECL boss_vaelAI : public ScriptedAI +{ + boss_vaelAI(Creature *c) : ScriptedAI(c) + { + c->SetUInt32Value(UNIT_NPC_FLAGS,1); + c->setFaction(35); + c->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + Reset(); + } + + uint64 PlayerGUID; + uint32 SpeachTimer; + uint32 SpeachNum; + uint32 Cleave_Timer; + uint32 FlameBreath_Timer; + uint32 FireNova_Timer; + uint32 BurningAdrenalineCaster_Timer; + uint32 BurningAdrenalineTank_Timer; + uint32 TailSwipe_Timer; + bool HasYelled; + bool DoingSpeach; + + void Reset() + { + PlayerGUID = 0; + SpeachTimer = 0; + SpeachNum = 0; + Cleave_Timer = 8000; //These times are probably wrong + FlameBreath_Timer = 11000; + BurningAdrenalineCaster_Timer = 15000; + BurningAdrenalineTank_Timer = 45000; + FireNova_Timer = 5000; + TailSwipe_Timer = 20000; + HasYelled = false; + DoingSpeach = false; + + m_creature->ApplySpellImmune(0, IMMUNITY_STATE, SPELL_AURA_MOD_TAUNT, true); + m_creature->ApplySpellImmune(1, IMMUNITY_EFFECT,SPELL_EFFECT_ATTACK_ME, true); + } + + void BeginSpeach(Unit* target) + { + //Stand up and begin speach + PlayerGUID = target->GetGUID(); + + //10 seconds + DoYell(SAY_LINE1,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_LINE1); + SpeachTimer = 10000; + SpeachNum = 0; + DoingSpeach = true; + } + + void KilledUnit(Unit *victim) + { + if (rand()%5) + return; + + DoYell(SAY_KILLTARGET,LANG_UNIVERSAL,victim); + DoPlaySoundToSet(m_creature,SOUND_KILLTARGET); + } + + void Aggro(Unit *who) + { + DoCast(m_creature,SPELL_ESSENCEOFTHERED); + DoZoneInCombat(); + } + + void UpdateAI(const uint32 diff) + { + //Speach + if (DoingSpeach) + if (SpeachTimer < diff) + { + switch (SpeachNum) + { + case 0: + //16 seconds till next line + DoYell(SAY_LINE2,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_LINE2); + SpeachTimer = 16000; + SpeachNum++; + break; + + case 1: + //This one is actually 16 seconds but we only go to 10 seconds because he starts attacking after he says "I must fight this!" + DoYell(SAY_LINE3,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_LINE3); + SpeachTimer = 10000; + SpeachNum++; + break; + + case 2: + default: + m_creature->setFaction(103); + m_creature->SetHealth(int(m_creature->GetMaxHealth()*.3)); + if (PlayerGUID && Unit::GetUnit((*m_creature),PlayerGUID)) + { + DoStartAttackAndMovement(Unit::GetUnit((*m_creature),PlayerGUID)); + DoCast(m_creature,SPELL_ESSENCEOFTHERED); + } + + SpeachTimer = 0; + DoingSpeach = false; + break; + } + }else SpeachTimer -= diff; + + //Return since we have no target + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + // Yell if hp lower than 15% + if (m_creature->GetHealth()*100 / m_creature->GetMaxHealth() < 15 && !HasYelled) + { + //Say our dialog + DoYell(SAY_HALFLIFE,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_HALFLIFE); + HasYelled = true; + } + + //Cleave_Timer + if (Cleave_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_CLEAVE); + Cleave_Timer = 15000; + }else Cleave_Timer -= diff; + + //FlameBreath_Timer + if (FlameBreath_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_FLAMEBREATH); + FlameBreath_Timer = 4000 + rand()%4000; + }else FlameBreath_Timer -= diff; + + //BurningAdrenalineCaster_Timer + if (BurningAdrenalineCaster_Timer < diff) + { + Unit* target = NULL; + + int i = 0 ; + while (i < 3) // max 3 tries to get a random target with power_mana + { + ++i; + target = SelectUnit(SELECT_TARGET_RANDOM,1);//not aggro leader + if (target) + if (target->getPowerType() == POWER_MANA) + i=3; + } + if (target) // cast on self (see below) + target->CastSpell(target,SPELL_BURNINGADRENALINE,1); + + BurningAdrenalineCaster_Timer = 15000; + }else BurningAdrenalineCaster_Timer -= diff; + + //BurningAdrenalineTank_Timer + if (BurningAdrenalineTank_Timer < diff) + { + // have the victim cast the spell on himself otherwise the third effect aura will be applied + // to Vael instead of the player + + m_creature->getVictim()->CastSpell(m_creature->getVictim(),SPELL_BURNINGADRENALINE,1); + + BurningAdrenalineTank_Timer = 45000; + }else BurningAdrenalineTank_Timer -= diff; + + //FireNova_Timer + if (FireNova_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_FIRENOVA); + FireNova_Timer = 5000; + }else FireNova_Timer -= diff; + + //TailSwipe_Timer + if (TailSwipe_Timer < diff) + { + //Only cast if we are behind + /*if (!m_creature->HasInArc( M_PI, m_creature->getVictim())) + { + DoCast(m_creature->getVictim(),SPELL_TAILSWIPE); + }*/ + + TailSwipe_Timer = 20000; + }else TailSwipe_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; + +void SendDefaultMenu_boss_vael(Player *player, Creature *_Creature, uint32 action) +{ + if (action == GOSSIP_ACTION_INFO_DEF + 1) //Fight time + { + player->CLOSE_GOSSIP_MENU(); + ((boss_vaelAI*)_Creature->AI())->BeginSpeach((Unit*)player); + } +} + +bool GossipSelect_boss_vael(Player *player, Creature *_Creature, uint32 sender, uint32 action ) +{ + if (sender == GOSSIP_SENDER_MAIN) + SendDefaultMenu_boss_vael(player, _Creature, action); + + return true; +} + +bool GossipHello_boss_vael(Player *player, Creature *_Creature) +{ + player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); + player->SEND_GOSSIP_MENU(907,_Creature->GetGUID()); + + return true; +} + +CreatureAI* GetAI_boss_vael(Creature *_Creature) +{ + return new boss_vaelAI (_Creature); +} + +void AddSC_boss_vael() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_vaelastrasz"; + newscript->GetAI = GetAI_boss_vael; + newscript->pGossipHello = &GossipHello_boss_vael; + newscript->pGossipSelect = &GossipSelect_boss_vael; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/blackwing_lair/boss_victor_nefarius.cpp b/src/bindings/scripts/scripts/zone/blackwing_lair/boss_victor_nefarius.cpp index 3870a247fa0..37bf475361b 100644 --- a/src/bindings/scripts/scripts/zone/blackwing_lair/boss_victor_nefarius.cpp +++ b/src/bindings/scripts/scripts/zone/blackwing_lair/boss_victor_nefarius.cpp @@ -1,399 +1,399 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Victor_Nefarius -SD%Complete: 75 -SDComment: Missing some text, Vael beginning event, and spawns Nef in wrong place -SDCategory: Blackwing Lair -EndScriptData */ - -#include "precompiled.h" - -#define SAY_GAMESBEGIN_1 "In this world where time is your enemy, it is my greatest ally. This grand game of life that you think you play in fact plays you. To that I say..." -#define SAY_GAMESBEGIN_2 "Let the games begin!" -#define SAY_VAEL_INTRO "" - -#define SOUND_GAMESBEGIN 8280 -#define SOUND_VAEL_INTRO 8279 - -#define GOSSIP_ITEM_1 "I've made no mistakes." -#define GOSSIP_ITEM_2 "You have lost your mind, Nefarius. You speak in riddles." -#define GOSSIP_ITEM_3 "Please do." - -#define CREATURE_BRONZE_DRAKANOID 14263 -#define CREATURE_BLUE_DRAKANOID 14261 -#define CREATURE_RED_DRAKANOID 14264 -#define CREATURE_GREEN_DRAKANOID 14262 -#define CREATURE_BLACK_DRAKANOID 14265 - -#define CREATURE_CHROMATIC_DRAKANOID 14302 - -#define CREATURE_NEFARIAN 11583 - -#define ADD_X1 -7591.151855 -#define ADD_X2 -7514.598633 -#define ADD_Y1 -1204.051880 -#define ADD_Y2 -1150.448853 -#define ADD_Z1 476.800476 -#define ADD_Z2 476.796570 - -#define NEF_X -7445 -#define NEF_Y -1332 -#define NEF_Z 536 - -#define HIDE_X -7592 -#define HIDE_Y -1264 -#define HIDE_Z 481 - -#define SPELL_SHADOWBOLT 21077 -#define SPELL_FEAR 26070 - -//This script is complicated -//Instead of morphing Victor Nefarius we will have him control phase 1 -//And then have him spawn "Nefarian" for phase 2 -//When phase 2 starts Victor Nefarius will go into hiding and stop attacking -//If Nefarian despawns because he killed the players then this guy will EnterEvadeMode -//and allow players to start the event over -//If nefarian dies then he will kill himself then he will kill himself in his hiding place -//To prevent players from doing the event twice - -struct MANGOS_DLL_DECL boss_victor_nefariusAI : public ScriptedAI -{ - boss_victor_nefariusAI(Creature *c) : ScriptedAI(c) - { - NefarianGUID = 0; - Reset(); - srand(time(NULL)); - switch (rand()%20) - { - case 0: - DrakType1 = CREATURE_BRONZE_DRAKANOID; - DrakType2 = CREATURE_BLUE_DRAKANOID; - break; - case 1: - DrakType1 = CREATURE_BRONZE_DRAKANOID; - DrakType2 = CREATURE_RED_DRAKANOID; - break; - case 2: - DrakType1 = CREATURE_BRONZE_DRAKANOID; - DrakType2 = CREATURE_GREEN_DRAKANOID; - break; - case 3: - DrakType1 = CREATURE_BRONZE_DRAKANOID; - DrakType2 = CREATURE_BLACK_DRAKANOID; - break; - case 4: - DrakType1 = CREATURE_BLUE_DRAKANOID; - DrakType2 = CREATURE_BRONZE_DRAKANOID; - break; - case 5: - DrakType1 = CREATURE_BLUE_DRAKANOID; - DrakType2 = CREATURE_RED_DRAKANOID; - break; - case 6: - DrakType1 = CREATURE_BLUE_DRAKANOID; - DrakType2 = CREATURE_GREEN_DRAKANOID; - break; - case 7: - DrakType1 = CREATURE_BLUE_DRAKANOID; - DrakType2 = CREATURE_BLACK_DRAKANOID; - break; - case 8: - DrakType1 = CREATURE_RED_DRAKANOID; - DrakType2 = CREATURE_BRONZE_DRAKANOID; - break; - case 9: - DrakType1 = CREATURE_RED_DRAKANOID; - DrakType2 = CREATURE_BLUE_DRAKANOID; - break; - case 10: - DrakType1 = CREATURE_RED_DRAKANOID; - DrakType2 = CREATURE_GREEN_DRAKANOID; - break; - case 11: - DrakType1 = CREATURE_RED_DRAKANOID; - DrakType2 = CREATURE_BLACK_DRAKANOID; - break; - case 12: - DrakType1 = CREATURE_GREEN_DRAKANOID; - DrakType2 = CREATURE_BRONZE_DRAKANOID; - break; - case 13: - DrakType1 = CREATURE_GREEN_DRAKANOID; - DrakType2 = CREATURE_BLUE_DRAKANOID; - break; - case 14: - DrakType1 = CREATURE_GREEN_DRAKANOID; - DrakType2 = CREATURE_RED_DRAKANOID; - break; - case 15: - DrakType1 = CREATURE_GREEN_DRAKANOID; - DrakType2 = CREATURE_BLACK_DRAKANOID; - break; - case 16: - DrakType1 = CREATURE_BLACK_DRAKANOID; - DrakType2 = CREATURE_BRONZE_DRAKANOID; - break; - case 17: - DrakType1 = CREATURE_BLACK_DRAKANOID; - DrakType2 = CREATURE_BLUE_DRAKANOID; - break; - case 18: - DrakType1 = CREATURE_BLACK_DRAKANOID; - DrakType2 = CREATURE_GREEN_DRAKANOID; - break; - case 19: - DrakType1 = CREATURE_BLACK_DRAKANOID; - DrakType2 = CREATURE_RED_DRAKANOID; - break; - } - } - - uint32 SpawnedAdds; - uint32 AddSpawnTimer; - uint32 ShadowBoltTimer; - uint32 FearTimer; - uint32 MindControlTimer; - uint32 ResetTimer; - uint32 DrakType1; - uint32 DrakType2; - uint64 NefarianGUID; - uint32 NefCheckTime; - - void Reset() - { - SpawnedAdds = 0; - AddSpawnTimer = 10000; - ShadowBoltTimer = 5000; - FearTimer = 8000; - ResetTimer = 900000; //On official it takes him 15 minutes(900 seconds) to reset. We are only doing 1 minute to make testing easier - NefarianGUID = 0; - NefCheckTime = 2000; - - m_creature->SetUInt32Value(UNIT_NPC_FLAGS,1); - m_creature->setFaction(35); - m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - } - - void BeginEvent(Player* target) - { - DoYell(SAY_GAMESBEGIN_2,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_GAMESBEGIN); - - //MaNGOS::Singleton::Instance().GetMap(m_creature->GetMapId(), m_creature)->GetPlayers().begin(); - /* - list ::iterator i = MapManager::Instance().GetMap(m_creature->GetMapId(), m_creature)->GetPlayers().begin(); - - for (i = MapManager::Instance().GetMap(m_creature->GetMapId(), m_creature)->GetPlayers().begin(); i != MapManager::Instance().GetMap(m_creature->GetMapId(), m_creature)->GetPlayers().end(); ++i) - { - AttackStart((*i)); - } - */ - m_creature->SetUInt32Value(UNIT_NPC_FLAGS,0); - m_creature->setFaction(103); - m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - AttackStart(target); - } - - void Aggro(Unit *who) - { - } - - void MoveInLineOfSight(Unit *who) - { - //We simply use this function to find players until we can use Map->GetPlayers() - - if (who && who->GetTypeId() == TYPEID_PLAYER && m_creature->IsHostileTo(who)) - { - //Add them to our threat list - m_creature->AddThreat(who,0.0f); - } - } - - void UpdateAI(const uint32 diff) - { - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - //Only do this if we haven't spawned nef yet - if (SpawnedAdds < 42) - { - //ShadowBoltTimer - if (ShadowBoltTimer < diff) - { - Unit* target = NULL; - target = SelectUnit(SELECT_TARGET_RANDOM,0); - if (target) - DoCast(target,SPELL_SHADOWBOLT); - - ShadowBoltTimer = 3000 + (rand()%7000); - }else ShadowBoltTimer -= diff; - - //FearTimer - if (FearTimer < diff) - { - Unit* target = NULL; - target = SelectUnit(SELECT_TARGET_RANDOM,0); - if (target) - DoCast(target,SPELL_FEAR); - - FearTimer = 10000 + (rand()%10000); - }else FearTimer -= diff; - - //Add spawning mechanism - if (AddSpawnTimer < diff) - { - //Spawn 2 random types of creatures at the 2 locations - uint32 CreatureID; - Creature* Spawned = NULL; - Unit* target = NULL; - - //1 in 3 chance it will be a chromatic - if (rand()%3 == 0) - CreatureID = CREATURE_CHROMATIC_DRAKANOID; - else CreatureID = DrakType1; - - SpawnedAdds++; - - //Spawn creature and force it to start attacking a random target - Spawned = m_creature->SummonCreature(CreatureID,ADD_X1,ADD_Y1,ADD_Z1,5.000,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,5000); - target = SelectUnit(SELECT_TARGET_RANDOM,0); - if (target && Spawned) - { - Spawned->AI()->AttackStart(target); - Spawned->setFaction(103); - } - - //1 in 3 chance it will be a chromatic - if (rand()%3 == 0) - CreatureID = CREATURE_CHROMATIC_DRAKANOID; - else CreatureID = DrakType2; - - SpawnedAdds++; - - target = NULL; - Spawned = NULL; - Spawned = m_creature->SummonCreature(CreatureID,ADD_X2,ADD_Y2,ADD_Z2,5.000,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,5000); - target = SelectUnit(SELECT_TARGET_RANDOM,0); - if (target && Spawned) - { - Spawned->AI()->AttackStart(target); - Spawned->setFaction(103); - } - - //Begin phase 2 by spawning Nefarian and what not - if (SpawnedAdds >= 42) - { - //Teleport Victor Nefarius way out of the map - //MapManager::Instance().GetMap(m_creature->GetMapId(), m_creature)->CreatureRelocation(m_creature,0,0,-5000,0); - - //Inturrupt any spell casting - m_creature->InterruptNonMeleeSpells(false); - - //Root self - DoCast(m_creature,33356); - - //Make super invis - DoCast(m_creature,8149); - - //Teleport self to a hiding spot (this causes errors in the mangos log but no real issues) - m_creature->Relocate(HIDE_X,HIDE_Y,HIDE_Z,0); - m_creature->SendMonsterMove(HIDE_X,HIDE_Y,HIDE_Z,0,true,0); - m_creature->addUnitState(UNIT_STAT_FLEEING); - - //Spawn nef and have him attack a random target - Creature* Nefarian = NULL; - Nefarian = m_creature->SummonCreature(CREATURE_NEFARIAN,NEF_X,NEF_Y,NEF_Z,0,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,120000); - target = NULL; - target = SelectUnit(SELECT_TARGET_RANDOM,0); - if (target && Nefarian) - { - Nefarian->AI()->AttackStart(target); - Nefarian->setFaction(103); - NefarianGUID = Nefarian->GetGUID(); - } - else DoYell("UNABLE TO SPAWN NEF PROPERLY",LANG_UNIVERSAL,NULL); - } - - AddSpawnTimer = 4000; - }else AddSpawnTimer -= diff; - } - else if (NefarianGUID) - { - if (NefCheckTime < diff) - { - Unit* Nefarian = NULL; - Nefarian = Unit::GetUnit((*m_creature),NefarianGUID); - - //If nef is dead then we die to so the players get out of combat - //and cannot repeat the event - if (!Nefarian || !Nefarian->isAlive()) - { - NefarianGUID = 0; - m_creature->DealDamage(m_creature, m_creature->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); - } - - NefCheckTime = 2000; - }else NefCheckTime -= diff; - } - } -}; - -CreatureAI* GetAI_boss_victor_nefarius(Creature *_Creature) -{ - return new boss_victor_nefariusAI (_Creature); -} - -bool GossipHello_boss_victor_nefarius(Player *player, Creature *_Creature) -{ - player->ADD_GOSSIP_ITEM(0, GOSSIP_ITEM_1 , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); - player->SEND_GOSSIP_MENU(7134,_Creature->GetGUID()); - return true; -} - -bool GossipSelect_boss_victor_nefarius(Player *player, Creature *_Creature, uint32 sender, uint32 action ) -{ - switch (action) - { - case GOSSIP_ACTION_INFO_DEF+1: - player->ADD_GOSSIP_ITEM(0, GOSSIP_ITEM_2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2); - player->SEND_GOSSIP_MENU(7198, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+2: - player->ADD_GOSSIP_ITEM(0, GOSSIP_ITEM_3, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+3); - player->SEND_GOSSIP_MENU(7199, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+3: - player->CLOSE_GOSSIP_MENU(); - _Creature->MonsterSay(SAY_GAMESBEGIN_1,LANG_UNIVERSAL,0); - ((boss_victor_nefariusAI*)_Creature->AI())->BeginEvent(player); - break; - } - return true; -} - -void AddSC_boss_victor_nefarius() -{ - Script *newscript; - - newscript = new Script; - newscript->Name="boss_victor_nefarius"; - newscript->GetAI = GetAI_boss_victor_nefarius; - newscript->pGossipHello = &GossipHello_boss_victor_nefarius; - newscript->pGossipSelect = &GossipSelect_boss_victor_nefarius; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Victor_Nefarius +SD%Complete: 75 +SDComment: Missing some text, Vael beginning event, and spawns Nef in wrong place +SDCategory: Blackwing Lair +EndScriptData */ + +#include "precompiled.h" + +#define SAY_GAMESBEGIN_1 "In this world where time is your enemy, it is my greatest ally. This grand game of life that you think you play in fact plays you. To that I say..." +#define SAY_GAMESBEGIN_2 "Let the games begin!" +#define SAY_VAEL_INTRO "" + +#define SOUND_GAMESBEGIN 8280 +#define SOUND_VAEL_INTRO 8279 + +#define GOSSIP_ITEM_1 "I've made no mistakes." +#define GOSSIP_ITEM_2 "You have lost your mind, Nefarius. You speak in riddles." +#define GOSSIP_ITEM_3 "Please do." + +#define CREATURE_BRONZE_DRAKANOID 14263 +#define CREATURE_BLUE_DRAKANOID 14261 +#define CREATURE_RED_DRAKANOID 14264 +#define CREATURE_GREEN_DRAKANOID 14262 +#define CREATURE_BLACK_DRAKANOID 14265 + +#define CREATURE_CHROMATIC_DRAKANOID 14302 + +#define CREATURE_NEFARIAN 11583 + +#define ADD_X1 -7591.151855 +#define ADD_X2 -7514.598633 +#define ADD_Y1 -1204.051880 +#define ADD_Y2 -1150.448853 +#define ADD_Z1 476.800476 +#define ADD_Z2 476.796570 + +#define NEF_X -7445 +#define NEF_Y -1332 +#define NEF_Z 536 + +#define HIDE_X -7592 +#define HIDE_Y -1264 +#define HIDE_Z 481 + +#define SPELL_SHADOWBOLT 21077 +#define SPELL_FEAR 26070 + +//This script is complicated +//Instead of morphing Victor Nefarius we will have him control phase 1 +//And then have him spawn "Nefarian" for phase 2 +//When phase 2 starts Victor Nefarius will go into hiding and stop attacking +//If Nefarian despawns because he killed the players then this guy will EnterEvadeMode +//and allow players to start the event over +//If nefarian dies then he will kill himself then he will kill himself in his hiding place +//To prevent players from doing the event twice + +struct MANGOS_DLL_DECL boss_victor_nefariusAI : public ScriptedAI +{ + boss_victor_nefariusAI(Creature *c) : ScriptedAI(c) + { + NefarianGUID = 0; + Reset(); + srand(time(NULL)); + switch (rand()%20) + { + case 0: + DrakType1 = CREATURE_BRONZE_DRAKANOID; + DrakType2 = CREATURE_BLUE_DRAKANOID; + break; + case 1: + DrakType1 = CREATURE_BRONZE_DRAKANOID; + DrakType2 = CREATURE_RED_DRAKANOID; + break; + case 2: + DrakType1 = CREATURE_BRONZE_DRAKANOID; + DrakType2 = CREATURE_GREEN_DRAKANOID; + break; + case 3: + DrakType1 = CREATURE_BRONZE_DRAKANOID; + DrakType2 = CREATURE_BLACK_DRAKANOID; + break; + case 4: + DrakType1 = CREATURE_BLUE_DRAKANOID; + DrakType2 = CREATURE_BRONZE_DRAKANOID; + break; + case 5: + DrakType1 = CREATURE_BLUE_DRAKANOID; + DrakType2 = CREATURE_RED_DRAKANOID; + break; + case 6: + DrakType1 = CREATURE_BLUE_DRAKANOID; + DrakType2 = CREATURE_GREEN_DRAKANOID; + break; + case 7: + DrakType1 = CREATURE_BLUE_DRAKANOID; + DrakType2 = CREATURE_BLACK_DRAKANOID; + break; + case 8: + DrakType1 = CREATURE_RED_DRAKANOID; + DrakType2 = CREATURE_BRONZE_DRAKANOID; + break; + case 9: + DrakType1 = CREATURE_RED_DRAKANOID; + DrakType2 = CREATURE_BLUE_DRAKANOID; + break; + case 10: + DrakType1 = CREATURE_RED_DRAKANOID; + DrakType2 = CREATURE_GREEN_DRAKANOID; + break; + case 11: + DrakType1 = CREATURE_RED_DRAKANOID; + DrakType2 = CREATURE_BLACK_DRAKANOID; + break; + case 12: + DrakType1 = CREATURE_GREEN_DRAKANOID; + DrakType2 = CREATURE_BRONZE_DRAKANOID; + break; + case 13: + DrakType1 = CREATURE_GREEN_DRAKANOID; + DrakType2 = CREATURE_BLUE_DRAKANOID; + break; + case 14: + DrakType1 = CREATURE_GREEN_DRAKANOID; + DrakType2 = CREATURE_RED_DRAKANOID; + break; + case 15: + DrakType1 = CREATURE_GREEN_DRAKANOID; + DrakType2 = CREATURE_BLACK_DRAKANOID; + break; + case 16: + DrakType1 = CREATURE_BLACK_DRAKANOID; + DrakType2 = CREATURE_BRONZE_DRAKANOID; + break; + case 17: + DrakType1 = CREATURE_BLACK_DRAKANOID; + DrakType2 = CREATURE_BLUE_DRAKANOID; + break; + case 18: + DrakType1 = CREATURE_BLACK_DRAKANOID; + DrakType2 = CREATURE_GREEN_DRAKANOID; + break; + case 19: + DrakType1 = CREATURE_BLACK_DRAKANOID; + DrakType2 = CREATURE_RED_DRAKANOID; + break; + } + } + + uint32 SpawnedAdds; + uint32 AddSpawnTimer; + uint32 ShadowBoltTimer; + uint32 FearTimer; + uint32 MindControlTimer; + uint32 ResetTimer; + uint32 DrakType1; + uint32 DrakType2; + uint64 NefarianGUID; + uint32 NefCheckTime; + + void Reset() + { + SpawnedAdds = 0; + AddSpawnTimer = 10000; + ShadowBoltTimer = 5000; + FearTimer = 8000; + ResetTimer = 900000; //On official it takes him 15 minutes(900 seconds) to reset. We are only doing 1 minute to make testing easier + NefarianGUID = 0; + NefCheckTime = 2000; + + m_creature->SetUInt32Value(UNIT_NPC_FLAGS,1); + m_creature->setFaction(35); + m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + } + + void BeginEvent(Player* target) + { + DoYell(SAY_GAMESBEGIN_2,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_GAMESBEGIN); + + //MaNGOS::Singleton::Instance().GetMap(m_creature->GetMapId(), m_creature)->GetPlayers().begin(); + /* + list ::iterator i = MapManager::Instance().GetMap(m_creature->GetMapId(), m_creature)->GetPlayers().begin(); + + for (i = MapManager::Instance().GetMap(m_creature->GetMapId(), m_creature)->GetPlayers().begin(); i != MapManager::Instance().GetMap(m_creature->GetMapId(), m_creature)->GetPlayers().end(); ++i) + { + AttackStart((*i)); + } + */ + m_creature->SetUInt32Value(UNIT_NPC_FLAGS,0); + m_creature->setFaction(103); + m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + AttackStart(target); + } + + void Aggro(Unit *who) + { + } + + void MoveInLineOfSight(Unit *who) + { + //We simply use this function to find players until we can use Map->GetPlayers() + + if (who && who->GetTypeId() == TYPEID_PLAYER && m_creature->IsHostileTo(who)) + { + //Add them to our threat list + m_creature->AddThreat(who,0.0f); + } + } + + void UpdateAI(const uint32 diff) + { + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + //Only do this if we haven't spawned nef yet + if (SpawnedAdds < 42) + { + //ShadowBoltTimer + if (ShadowBoltTimer < diff) + { + Unit* target = NULL; + target = SelectUnit(SELECT_TARGET_RANDOM,0); + if (target) + DoCast(target,SPELL_SHADOWBOLT); + + ShadowBoltTimer = 3000 + (rand()%7000); + }else ShadowBoltTimer -= diff; + + //FearTimer + if (FearTimer < diff) + { + Unit* target = NULL; + target = SelectUnit(SELECT_TARGET_RANDOM,0); + if (target) + DoCast(target,SPELL_FEAR); + + FearTimer = 10000 + (rand()%10000); + }else FearTimer -= diff; + + //Add spawning mechanism + if (AddSpawnTimer < diff) + { + //Spawn 2 random types of creatures at the 2 locations + uint32 CreatureID; + Creature* Spawned = NULL; + Unit* target = NULL; + + //1 in 3 chance it will be a chromatic + if (rand()%3 == 0) + CreatureID = CREATURE_CHROMATIC_DRAKANOID; + else CreatureID = DrakType1; + + SpawnedAdds++; + + //Spawn creature and force it to start attacking a random target + Spawned = m_creature->SummonCreature(CreatureID,ADD_X1,ADD_Y1,ADD_Z1,5.000,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,5000); + target = SelectUnit(SELECT_TARGET_RANDOM,0); + if (target && Spawned) + { + Spawned->AI()->AttackStart(target); + Spawned->setFaction(103); + } + + //1 in 3 chance it will be a chromatic + if (rand()%3 == 0) + CreatureID = CREATURE_CHROMATIC_DRAKANOID; + else CreatureID = DrakType2; + + SpawnedAdds++; + + target = NULL; + Spawned = NULL; + Spawned = m_creature->SummonCreature(CreatureID,ADD_X2,ADD_Y2,ADD_Z2,5.000,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,5000); + target = SelectUnit(SELECT_TARGET_RANDOM,0); + if (target && Spawned) + { + Spawned->AI()->AttackStart(target); + Spawned->setFaction(103); + } + + //Begin phase 2 by spawning Nefarian and what not + if (SpawnedAdds >= 42) + { + //Teleport Victor Nefarius way out of the map + //MapManager::Instance().GetMap(m_creature->GetMapId(), m_creature)->CreatureRelocation(m_creature,0,0,-5000,0); + + //Inturrupt any spell casting + m_creature->InterruptNonMeleeSpells(false); + + //Root self + DoCast(m_creature,33356); + + //Make super invis + DoCast(m_creature,8149); + + //Teleport self to a hiding spot (this causes errors in the mangos log but no real issues) + m_creature->Relocate(HIDE_X,HIDE_Y,HIDE_Z,0); + m_creature->SendMonsterMove(HIDE_X,HIDE_Y,HIDE_Z,0,true,0); + m_creature->addUnitState(UNIT_STAT_FLEEING); + + //Spawn nef and have him attack a random target + Creature* Nefarian = NULL; + Nefarian = m_creature->SummonCreature(CREATURE_NEFARIAN,NEF_X,NEF_Y,NEF_Z,0,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,120000); + target = NULL; + target = SelectUnit(SELECT_TARGET_RANDOM,0); + if (target && Nefarian) + { + Nefarian->AI()->AttackStart(target); + Nefarian->setFaction(103); + NefarianGUID = Nefarian->GetGUID(); + } + else DoYell("UNABLE TO SPAWN NEF PROPERLY",LANG_UNIVERSAL,NULL); + } + + AddSpawnTimer = 4000; + }else AddSpawnTimer -= diff; + } + else if (NefarianGUID) + { + if (NefCheckTime < diff) + { + Unit* Nefarian = NULL; + Nefarian = Unit::GetUnit((*m_creature),NefarianGUID); + + //If nef is dead then we die to so the players get out of combat + //and cannot repeat the event + if (!Nefarian || !Nefarian->isAlive()) + { + NefarianGUID = 0; + m_creature->DealDamage(m_creature, m_creature->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); + } + + NefCheckTime = 2000; + }else NefCheckTime -= diff; + } + } +}; + +CreatureAI* GetAI_boss_victor_nefarius(Creature *_Creature) +{ + return new boss_victor_nefariusAI (_Creature); +} + +bool GossipHello_boss_victor_nefarius(Player *player, Creature *_Creature) +{ + player->ADD_GOSSIP_ITEM(0, GOSSIP_ITEM_1 , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); + player->SEND_GOSSIP_MENU(7134,_Creature->GetGUID()); + return true; +} + +bool GossipSelect_boss_victor_nefarius(Player *player, Creature *_Creature, uint32 sender, uint32 action ) +{ + switch (action) + { + case GOSSIP_ACTION_INFO_DEF+1: + player->ADD_GOSSIP_ITEM(0, GOSSIP_ITEM_2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2); + player->SEND_GOSSIP_MENU(7198, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+2: + player->ADD_GOSSIP_ITEM(0, GOSSIP_ITEM_3, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+3); + player->SEND_GOSSIP_MENU(7199, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+3: + player->CLOSE_GOSSIP_MENU(); + _Creature->MonsterSay(SAY_GAMESBEGIN_1,LANG_UNIVERSAL,0); + ((boss_victor_nefariusAI*)_Creature->AI())->BeginEvent(player); + break; + } + return true; +} + +void AddSC_boss_victor_nefarius() +{ + Script *newscript; + + newscript = new Script; + newscript->Name="boss_victor_nefarius"; + newscript->GetAI = GetAI_boss_victor_nefarius; + newscript->pGossipHello = &GossipHello_boss_victor_nefarius; + newscript->pGossipSelect = &GossipSelect_boss_victor_nefarius; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/blackwing_lair/instance_blackwing_lair.cpp b/src/bindings/scripts/scripts/zone/blackwing_lair/instance_blackwing_lair.cpp index 7bdd3250442..e6c06bc739c 100644 --- a/src/bindings/scripts/scripts/zone/blackwing_lair/instance_blackwing_lair.cpp +++ b/src/bindings/scripts/scripts/zone/blackwing_lair/instance_blackwing_lair.cpp @@ -1,8 +1,8 @@ -/* ScriptData -SDName: Instance_Blackwing_Lair -SD%Complete: 0 -SDComment: -SDCategory: Blackwing Lair -EndScriptData */ - -#include "precompiled.h" +/* ScriptData +SDName: Instance_Blackwing_Lair +SD%Complete: 0 +SDComment: +SDCategory: Blackwing Lair +EndScriptData */ + +#include "precompiled.h" diff --git a/src/bindings/scripts/scripts/zone/blades_edge_mountains/blades_edge_mountains.cpp b/src/bindings/scripts/scripts/zone/blades_edge_mountains/blades_edge_mountains.cpp index c7cb250eab7..a2e66c9bf0f 100644 --- a/src/bindings/scripts/scripts/zone/blades_edge_mountains/blades_edge_mountains.cpp +++ b/src/bindings/scripts/scripts/zone/blades_edge_mountains/blades_edge_mountains.cpp @@ -1,441 +1,441 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Blades_Edge_Mountains -SD%Complete: 90 -SDComment: Quest support: 10503, 10504, 10556, 10609, 10682, 10980. Ogri'la->Skettis Flight. (npc_daranelle needs bit more work before consider complete) -SDCategory: Blade's Edge Mountains -EndScriptData */ - -/* ContentData -mobs_bladespire_ogre -mobs_nether_drake -npc_daranelle -npc_overseer_nuaar -npc_saikkal_the_elder -npc_skyguard_handler_irena -EndContentData */ - -#include "precompiled.h" - -/*###### -## mobs_bladespire_ogre -######*/ - -//TODO: add support for quest 10512 + creature abilities -struct MANGOS_DLL_DECL mobs_bladespire_ogreAI : public ScriptedAI -{ - mobs_bladespire_ogreAI(Creature *c) : ScriptedAI(c) {Reset();} - - void Reset() - { - } - - void Aggro(Unit* who) - { - } - - void JustDied(Unit* Killer) - { - if (Killer->GetTypeId() == TYPEID_PLAYER) - ((Player*)Killer)->KilledMonster(19995, m_creature->GetGUID()); - } -}; -CreatureAI* GetAI_mobs_bladespire_ogre(Creature *_Creature) -{ - return new mobs_bladespire_ogreAI (_Creature); -} - -/*###### -## mobs_nether_drake -######*/ - -#define SAY_NIHIL_1 "Muahahahaha! You fool! You've released me from my banishment in the interstices between space and time!" -#define SAY_NIHIL_2 "All of Draenor shall quick beneath my feet! I will destroy this world and reshape it in my image!" -#define SAY_NIHIL_3 "Where shall I begin? I cannot bother myself with a worm such as yourself. There is a world to be conquered!" -#define SAY_NIHIL_4 "No doubt the fools that banished me are long dead. I shall take wing survey my demense. Pray to whatever gods you hold dear that we do not meet again." -#define SAY_NIHIL_INTERRUPT "NOOOOooooooo!" - -#define ENTRY_WHELP 20021 -#define ENTRY_PROTO 21821 -#define ENTRY_ADOLE 21817 -#define ENTRY_MATUR 21820 -#define ENTRY_NIHIL 21823 - -#define SPELL_T_PHASE_MODULATOR 37573 - -#define SPELL_ARCANE_BLAST 38881 -#define SPELL_MANA_BURN 38884 -#define SPELL_INTANGIBLE_PRESENCE 36513 - -struct MANGOS_DLL_DECL mobs_nether_drakeAI : public ScriptedAI -{ - mobs_nether_drakeAI(Creature *c) : ScriptedAI(c) {Reset();} - - bool IsNihil; - uint32 NihilSpeech_Timer; - uint32 NihilSpeech_Phase; - - uint32 ArcaneBlast_Timer; - uint32 ManaBurn_Timer; - uint32 IntangiblePresence_Timer; - - void Reset() - { - NihilSpeech_Timer = 2000; - IsNihil = false; - if( m_creature->GetEntry() == ENTRY_NIHIL ) - { - m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); - IsNihil = true; - } - NihilSpeech_Phase = 1; - - ArcaneBlast_Timer = 7500; - ManaBurn_Timer = 10000; - IntangiblePresence_Timer = 15000; - } - - void Aggro(Unit* who) { } - - void SpellHit(Unit *caster, const SpellEntry *spell) - { - if( spell->Id == SPELL_T_PHASE_MODULATOR && caster->GetTypeId() == TYPEID_PLAYER ) - { - uint32 cEntry = 0; - - switch( m_creature->GetEntry() ) - { - case ENTRY_WHELP: - switch(rand()%4) - { - case 0: cEntry = ENTRY_PROTO; break; - case 1: cEntry = ENTRY_ADOLE; break; - case 2: cEntry = ENTRY_MATUR; break; - case 3: cEntry = ENTRY_NIHIL; break; - } - break; - case ENTRY_PROTO: - switch(rand()%3) - { - case 0: cEntry = ENTRY_ADOLE; break; - case 1: cEntry = ENTRY_MATUR; break; - case 2: cEntry = ENTRY_NIHIL; break; - } - break; - case ENTRY_ADOLE: - switch(rand()%3) - { - case 0: cEntry = ENTRY_PROTO; break; - case 1: cEntry = ENTRY_MATUR; break; - case 2: cEntry = ENTRY_NIHIL; break; - } - break; - case ENTRY_MATUR: - switch(rand()%3) - { - case 0: cEntry = ENTRY_PROTO; break; - case 1: cEntry = ENTRY_ADOLE; break; - case 2: cEntry = ENTRY_NIHIL; break; - } - break; - case ENTRY_NIHIL: - if( NihilSpeech_Phase ) - { - DoYell(SAY_NIHIL_INTERRUPT,LANG_UNIVERSAL,NULL); - IsNihil = false; - switch(rand()%3) - { - case 0: cEntry = ENTRY_PROTO; break; - case 1: cEntry = ENTRY_ADOLE; break; - case 2: cEntry = ENTRY_MATUR; break; - } - } - break; - } - - if( cEntry ) - { - m_creature->UpdateEntry(cEntry); - - if( cEntry == ENTRY_NIHIL ) - { - m_creature->InterruptNonMeleeSpells(true); - m_creature->RemoveAllAuras(); - m_creature->DeleteThreatList(); - m_creature->CombatStop(); - InCombat = false; - Reset(); - } - } - } - } - - void UpdateAI(const uint32 diff) - { - if( IsNihil ) - { - if( NihilSpeech_Phase ) - { - if(NihilSpeech_Timer <= diff) - { - switch( NihilSpeech_Phase ) - { - case 1: - DoSay(SAY_NIHIL_1,LANG_UNIVERSAL,NULL); - ++NihilSpeech_Phase; - break; - case 2: - DoSay(SAY_NIHIL_2,LANG_UNIVERSAL,NULL); - ++NihilSpeech_Phase; - break; - case 3: - DoSay(SAY_NIHIL_3,LANG_UNIVERSAL,NULL); - ++NihilSpeech_Phase; - break; - case 4: - DoSay(SAY_NIHIL_4,LANG_UNIVERSAL,NULL); - ++NihilSpeech_Phase; - break; - case 5: - m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - // + MOVEMENTFLAG_LEVITATING - m_creature->AddUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT); - //then take off to random location. creature is initially summoned, so don't bother do anything else. - m_creature->GetMotionMaster()->MovePoint(0, m_creature->GetPositionX()+100, m_creature->GetPositionY(), m_creature->GetPositionZ()+100); - NihilSpeech_Phase = 0; - break; - } - NihilSpeech_Timer = 5000; - }else NihilSpeech_Timer -=diff; - } - return; //anything below here is not interesting for Nihil, so skip it - } - - if( !m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - if( IntangiblePresence_Timer <= diff ) - { - DoCast(m_creature->getVictim(),SPELL_INTANGIBLE_PRESENCE); - IntangiblePresence_Timer = 15000+rand()%15000; - }else IntangiblePresence_Timer -= diff; - - if( ManaBurn_Timer <= diff ) - { - Unit* target = m_creature->getVictim(); - if( target && target->getPowerType() == POWER_MANA ) - DoCast(target,SPELL_MANA_BURN); - ManaBurn_Timer = 8000+rand()%8000; - }else ManaBurn_Timer -= diff; - - if( ArcaneBlast_Timer <= diff ) - { - DoCast(m_creature->getVictim(),SPELL_ARCANE_BLAST); - ArcaneBlast_Timer = 2500+rand()%5000; - }else ArcaneBlast_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; -CreatureAI* GetAI_mobs_nether_drake(Creature *_Creature) -{ - return new mobs_nether_drakeAI (_Creature); -} - -/*###### -## npc_daranelle -######*/ - -struct MANGOS_DLL_DECL npc_daranelleAI : public ScriptedAI -{ - npc_daranelleAI(Creature *c) : ScriptedAI(c) {Reset();} - - void Reset() - { - } - - void Aggro(Unit* who) - { - } - - void MoveInLineOfSight(Unit *who) - { - if (!who || m_creature->getVictim()) - return; - - if (who->GetTypeId() == TYPEID_PLAYER) - { - if(who->HasAura(36904,0)) - { - DoSay("Good $N, you are under the spell's influence. I must analyze it quickly, then we can talk.",LANG_COMMON,who); - //TODO: Move the below to updateAI and run if this statement == true - ((Player*)who)->KilledMonster(21511, m_creature->GetGUID()); - ((Player*)who)->RemoveAurasDueToSpell(36904); - } - } - - if (who->isTargetableForAttack() && who->isInAccessablePlaceFor(m_creature) && m_creature->IsHostileTo(who)) - { - float attackRadius = m_creature->GetAttackDistance(who); - if (m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->GetDistanceZ(who) <= CREATURE_Z_ATTACK_RANGE && m_creature->IsWithinLOSInMap(who)) - { - if(who->HasStealthAura()) - who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); - - //Begin melee attack if we are within range - DoStartAttackAndMovement(who); - } - } - } -}; - -CreatureAI* GetAI_npc_daranelle(Creature *_Creature) -{ - return new npc_daranelleAI (_Creature); -} - -/*###### -## npc_overseer_nuaar -######*/ - -bool GossipHello_npc_overseer_nuaar(Player *player, Creature *_Creature) -{ - if (player->GetQuestStatus(10682) == QUEST_STATUS_INCOMPLETE) - player->ADD_GOSSIP_ITEM( 0, "Overseer, I am here to negotiate on behalf of the Cenarion Expedition.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); - - player->SEND_GOSSIP_MENU(10532, _Creature->GetGUID()); - - return true; -} - -bool GossipSelect_npc_overseer_nuaar(Player *player, Creature *_Creature, uint32 sender, uint32 action) -{ - if (action == GOSSIP_ACTION_INFO_DEF+1) - { - player->SEND_GOSSIP_MENU(10533, _Creature->GetGUID()); - player->AreaExploredOrEventHappens(10682); - } - return true; -} - -/*###### -## npc_saikkal_the_elder -######*/ - -bool GossipHello_npc_saikkal_the_elder(Player *player, Creature *_Creature) -{ - if (player->GetQuestStatus(10980) == QUEST_STATUS_INCOMPLETE) - player->ADD_GOSSIP_ITEM( 0, "Yes... yes, it's me.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); - - player->SEND_GOSSIP_MENU(10794, _Creature->GetGUID()); - - return true; -} - -bool GossipSelect_npc_saikkal_the_elder(Player *player, Creature *_Creature, uint32 sender, uint32 action) -{ - switch (action) - { - case GOSSIP_ACTION_INFO_DEF+1: - player->ADD_GOSSIP_ITEM( 0, "Yes elder. Tell me more of the book.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2); - player->SEND_GOSSIP_MENU(10795, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+2: - player->TalkedToCreature(_Creature->GetEntry(), _Creature->GetGUID()); - player->SEND_GOSSIP_MENU(10796, _Creature->GetGUID()); - break; - } - return true; -} - -/*###### -## npc_skyguard_handler_irena -######*/ - -#define GOSSIP_SKYGUARD "Fly me to Skettis please" - -bool GossipHello_npc_skyguard_handler_irena(Player *player, Creature *_Creature ) -{ - if (_Creature->isQuestGiver()) - player->PrepareQuestMenu( _Creature->GetGUID() ); - - if (player->GetReputationRank(1031) >= REP_HONORED) - player->ADD_GOSSIP_ITEM( 2, GOSSIP_SKYGUARD, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); - - player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); - - return true; -} - -bool GossipSelect_npc_skyguard_handler_irena(Player *player, Creature *_Creature, uint32 sender, uint32 action ) -{ - if (action == GOSSIP_ACTION_INFO_DEF+1) - { - player->CLOSE_GOSSIP_MENU(); - - std::vector nodes; - - nodes.resize(2); - nodes[0] = 172; //from ogri'la - nodes[1] = 171; //end at skettis - player->ActivateTaxiPathTo(nodes); //TaxiPath 706 - } - return true; -} - -/*###### -## AddSC -######*/ - -void AddSC_blades_edge_mountains() -{ - Script *newscript; - - newscript = new Script; - newscript->Name="mobs_bladespire_ogre"; - newscript->GetAI = GetAI_mobs_bladespire_ogre; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="mobs_nether_drake"; - newscript->GetAI = GetAI_mobs_nether_drake; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="npc_daranelle"; - newscript->GetAI = GetAI_npc_daranelle; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="npc_overseer_nuaar"; - newscript->pGossipHello = &GossipHello_npc_overseer_nuaar; - newscript->pGossipSelect = &GossipSelect_npc_overseer_nuaar; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="npc_saikkal_the_elder"; - newscript->pGossipHello = &GossipHello_npc_saikkal_the_elder; - newscript->pGossipSelect = &GossipSelect_npc_saikkal_the_elder; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="npc_skyguard_handler_irena"; - newscript->pGossipHello = &GossipHello_npc_skyguard_handler_irena; - newscript->pGossipSelect = &GossipSelect_npc_skyguard_handler_irena; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Blades_Edge_Mountains +SD%Complete: 90 +SDComment: Quest support: 10503, 10504, 10556, 10609, 10682, 10980. Ogri'la->Skettis Flight. (npc_daranelle needs bit more work before consider complete) +SDCategory: Blade's Edge Mountains +EndScriptData */ + +/* ContentData +mobs_bladespire_ogre +mobs_nether_drake +npc_daranelle +npc_overseer_nuaar +npc_saikkal_the_elder +npc_skyguard_handler_irena +EndContentData */ + +#include "precompiled.h" + +/*###### +## mobs_bladespire_ogre +######*/ + +//TODO: add support for quest 10512 + creature abilities +struct MANGOS_DLL_DECL mobs_bladespire_ogreAI : public ScriptedAI +{ + mobs_bladespire_ogreAI(Creature *c) : ScriptedAI(c) {Reset();} + + void Reset() + { + } + + void Aggro(Unit* who) + { + } + + void JustDied(Unit* Killer) + { + if (Killer->GetTypeId() == TYPEID_PLAYER) + ((Player*)Killer)->KilledMonster(19995, m_creature->GetGUID()); + } +}; +CreatureAI* GetAI_mobs_bladespire_ogre(Creature *_Creature) +{ + return new mobs_bladespire_ogreAI (_Creature); +} + +/*###### +## mobs_nether_drake +######*/ + +#define SAY_NIHIL_1 "Muahahahaha! You fool! You've released me from my banishment in the interstices between space and time!" +#define SAY_NIHIL_2 "All of Draenor shall quick beneath my feet! I will destroy this world and reshape it in my image!" +#define SAY_NIHIL_3 "Where shall I begin? I cannot bother myself with a worm such as yourself. There is a world to be conquered!" +#define SAY_NIHIL_4 "No doubt the fools that banished me are long dead. I shall take wing survey my demense. Pray to whatever gods you hold dear that we do not meet again." +#define SAY_NIHIL_INTERRUPT "NOOOOooooooo!" + +#define ENTRY_WHELP 20021 +#define ENTRY_PROTO 21821 +#define ENTRY_ADOLE 21817 +#define ENTRY_MATUR 21820 +#define ENTRY_NIHIL 21823 + +#define SPELL_T_PHASE_MODULATOR 37573 + +#define SPELL_ARCANE_BLAST 38881 +#define SPELL_MANA_BURN 38884 +#define SPELL_INTANGIBLE_PRESENCE 36513 + +struct MANGOS_DLL_DECL mobs_nether_drakeAI : public ScriptedAI +{ + mobs_nether_drakeAI(Creature *c) : ScriptedAI(c) {Reset();} + + bool IsNihil; + uint32 NihilSpeech_Timer; + uint32 NihilSpeech_Phase; + + uint32 ArcaneBlast_Timer; + uint32 ManaBurn_Timer; + uint32 IntangiblePresence_Timer; + + void Reset() + { + NihilSpeech_Timer = 2000; + IsNihil = false; + if( m_creature->GetEntry() == ENTRY_NIHIL ) + { + m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + IsNihil = true; + } + NihilSpeech_Phase = 1; + + ArcaneBlast_Timer = 7500; + ManaBurn_Timer = 10000; + IntangiblePresence_Timer = 15000; + } + + void Aggro(Unit* who) { } + + void SpellHit(Unit *caster, const SpellEntry *spell) + { + if( spell->Id == SPELL_T_PHASE_MODULATOR && caster->GetTypeId() == TYPEID_PLAYER ) + { + uint32 cEntry = 0; + + switch( m_creature->GetEntry() ) + { + case ENTRY_WHELP: + switch(rand()%4) + { + case 0: cEntry = ENTRY_PROTO; break; + case 1: cEntry = ENTRY_ADOLE; break; + case 2: cEntry = ENTRY_MATUR; break; + case 3: cEntry = ENTRY_NIHIL; break; + } + break; + case ENTRY_PROTO: + switch(rand()%3) + { + case 0: cEntry = ENTRY_ADOLE; break; + case 1: cEntry = ENTRY_MATUR; break; + case 2: cEntry = ENTRY_NIHIL; break; + } + break; + case ENTRY_ADOLE: + switch(rand()%3) + { + case 0: cEntry = ENTRY_PROTO; break; + case 1: cEntry = ENTRY_MATUR; break; + case 2: cEntry = ENTRY_NIHIL; break; + } + break; + case ENTRY_MATUR: + switch(rand()%3) + { + case 0: cEntry = ENTRY_PROTO; break; + case 1: cEntry = ENTRY_ADOLE; break; + case 2: cEntry = ENTRY_NIHIL; break; + } + break; + case ENTRY_NIHIL: + if( NihilSpeech_Phase ) + { + DoYell(SAY_NIHIL_INTERRUPT,LANG_UNIVERSAL,NULL); + IsNihil = false; + switch(rand()%3) + { + case 0: cEntry = ENTRY_PROTO; break; + case 1: cEntry = ENTRY_ADOLE; break; + case 2: cEntry = ENTRY_MATUR; break; + } + } + break; + } + + if( cEntry ) + { + m_creature->UpdateEntry(cEntry); + + if( cEntry == ENTRY_NIHIL ) + { + m_creature->InterruptNonMeleeSpells(true); + m_creature->RemoveAllAuras(); + m_creature->DeleteThreatList(); + m_creature->CombatStop(); + InCombat = false; + Reset(); + } + } + } + } + + void UpdateAI(const uint32 diff) + { + if( IsNihil ) + { + if( NihilSpeech_Phase ) + { + if(NihilSpeech_Timer <= diff) + { + switch( NihilSpeech_Phase ) + { + case 1: + DoSay(SAY_NIHIL_1,LANG_UNIVERSAL,NULL); + ++NihilSpeech_Phase; + break; + case 2: + DoSay(SAY_NIHIL_2,LANG_UNIVERSAL,NULL); + ++NihilSpeech_Phase; + break; + case 3: + DoSay(SAY_NIHIL_3,LANG_UNIVERSAL,NULL); + ++NihilSpeech_Phase; + break; + case 4: + DoSay(SAY_NIHIL_4,LANG_UNIVERSAL,NULL); + ++NihilSpeech_Phase; + break; + case 5: + m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + // + MOVEMENTFLAG_LEVITATING + m_creature->AddUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT); + //then take off to random location. creature is initially summoned, so don't bother do anything else. + m_creature->GetMotionMaster()->MovePoint(0, m_creature->GetPositionX()+100, m_creature->GetPositionY(), m_creature->GetPositionZ()+100); + NihilSpeech_Phase = 0; + break; + } + NihilSpeech_Timer = 5000; + }else NihilSpeech_Timer -=diff; + } + return; //anything below here is not interesting for Nihil, so skip it + } + + if( !m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + if( IntangiblePresence_Timer <= diff ) + { + DoCast(m_creature->getVictim(),SPELL_INTANGIBLE_PRESENCE); + IntangiblePresence_Timer = 15000+rand()%15000; + }else IntangiblePresence_Timer -= diff; + + if( ManaBurn_Timer <= diff ) + { + Unit* target = m_creature->getVictim(); + if( target && target->getPowerType() == POWER_MANA ) + DoCast(target,SPELL_MANA_BURN); + ManaBurn_Timer = 8000+rand()%8000; + }else ManaBurn_Timer -= diff; + + if( ArcaneBlast_Timer <= diff ) + { + DoCast(m_creature->getVictim(),SPELL_ARCANE_BLAST); + ArcaneBlast_Timer = 2500+rand()%5000; + }else ArcaneBlast_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; +CreatureAI* GetAI_mobs_nether_drake(Creature *_Creature) +{ + return new mobs_nether_drakeAI (_Creature); +} + +/*###### +## npc_daranelle +######*/ + +struct MANGOS_DLL_DECL npc_daranelleAI : public ScriptedAI +{ + npc_daranelleAI(Creature *c) : ScriptedAI(c) {Reset();} + + void Reset() + { + } + + void Aggro(Unit* who) + { + } + + void MoveInLineOfSight(Unit *who) + { + if (who->GetTypeId() == TYPEID_PLAYER) + { + if(who->HasAura(36904,0)) + { + DoSay("Good $N, you are under the spell's influence. I must analyze it quickly, then we can talk.",LANG_COMMON,who); + //TODO: Move the below to updateAI and run if this statement == true + ((Player*)who)->KilledMonster(21511, m_creature->GetGUID()); + ((Player*)who)->RemoveAurasDueToSpell(36904); + } + } + + if (!m_creature->getVictim() && who->isTargetableForAttack() && who->isInAccessablePlaceFor(m_creature) && m_creature->IsHostileTo(who)) + { + if (!m_creature->canFly() && m_creature->GetDistanceZ(who) > CREATURE_Z_ATTACK_RANGE) + return; + + float attackRadius = m_creature->GetAttackDistance(who); + if (m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->IsWithinLOSInMap(who)) + { + if(who->HasStealthAura()) + who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); + + //Begin melee attack if we are within range + DoStartAttackAndMovement(who); + } + } + } +}; + +CreatureAI* GetAI_npc_daranelle(Creature *_Creature) +{ + return new npc_daranelleAI (_Creature); +} + +/*###### +## npc_overseer_nuaar +######*/ + +bool GossipHello_npc_overseer_nuaar(Player *player, Creature *_Creature) +{ + if (player->GetQuestStatus(10682) == QUEST_STATUS_INCOMPLETE) + player->ADD_GOSSIP_ITEM( 0, "Overseer, I am here to negotiate on behalf of the Cenarion Expedition.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); + + player->SEND_GOSSIP_MENU(10532, _Creature->GetGUID()); + + return true; +} + +bool GossipSelect_npc_overseer_nuaar(Player *player, Creature *_Creature, uint32 sender, uint32 action) +{ + if (action == GOSSIP_ACTION_INFO_DEF+1) + { + player->SEND_GOSSIP_MENU(10533, _Creature->GetGUID()); + player->AreaExploredOrEventHappens(10682); + } + return true; +} + +/*###### +## npc_saikkal_the_elder +######*/ + +bool GossipHello_npc_saikkal_the_elder(Player *player, Creature *_Creature) +{ + if (player->GetQuestStatus(10980) == QUEST_STATUS_INCOMPLETE) + player->ADD_GOSSIP_ITEM( 0, "Yes... yes, it's me.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); + + player->SEND_GOSSIP_MENU(10794, _Creature->GetGUID()); + + return true; +} + +bool GossipSelect_npc_saikkal_the_elder(Player *player, Creature *_Creature, uint32 sender, uint32 action) +{ + switch (action) + { + case GOSSIP_ACTION_INFO_DEF+1: + player->ADD_GOSSIP_ITEM( 0, "Yes elder. Tell me more of the book.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2); + player->SEND_GOSSIP_MENU(10795, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+2: + player->TalkedToCreature(_Creature->GetEntry(), _Creature->GetGUID()); + player->SEND_GOSSIP_MENU(10796, _Creature->GetGUID()); + break; + } + return true; +} + +/*###### +## npc_skyguard_handler_irena +######*/ + +#define GOSSIP_SKYGUARD "Fly me to Skettis please" + +bool GossipHello_npc_skyguard_handler_irena(Player *player, Creature *_Creature ) +{ + if (_Creature->isQuestGiver()) + player->PrepareQuestMenu( _Creature->GetGUID() ); + + if (player->GetReputationRank(1031) >= REP_HONORED) + player->ADD_GOSSIP_ITEM( 2, GOSSIP_SKYGUARD, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); + + player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); + + return true; +} + +bool GossipSelect_npc_skyguard_handler_irena(Player *player, Creature *_Creature, uint32 sender, uint32 action ) +{ + if (action == GOSSIP_ACTION_INFO_DEF+1) + { + player->CLOSE_GOSSIP_MENU(); + + std::vector nodes; + + nodes.resize(2); + nodes[0] = 172; //from ogri'la + nodes[1] = 171; //end at skettis + player->ActivateTaxiPathTo(nodes); //TaxiPath 706 + } + return true; +} + +/*###### +## AddSC +######*/ + +void AddSC_blades_edge_mountains() +{ + Script *newscript; + + newscript = new Script; + newscript->Name="mobs_bladespire_ogre"; + newscript->GetAI = GetAI_mobs_bladespire_ogre; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="mobs_nether_drake"; + newscript->GetAI = GetAI_mobs_nether_drake; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="npc_daranelle"; + newscript->GetAI = GetAI_npc_daranelle; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="npc_overseer_nuaar"; + newscript->pGossipHello = &GossipHello_npc_overseer_nuaar; + newscript->pGossipSelect = &GossipSelect_npc_overseer_nuaar; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="npc_saikkal_the_elder"; + newscript->pGossipHello = &GossipHello_npc_saikkal_the_elder; + newscript->pGossipSelect = &GossipSelect_npc_saikkal_the_elder; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="npc_skyguard_handler_irena"; + newscript->pGossipHello = &GossipHello_npc_skyguard_handler_irena; + newscript->pGossipSelect = &GossipSelect_npc_skyguard_handler_irena; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/blasted_lands/blasted_lands.cpp b/src/bindings/scripts/scripts/zone/blasted_lands/blasted_lands.cpp index 4c84994c5b6..84cd2aeb3c9 100644 --- a/src/bindings/scripts/scripts/zone/blasted_lands/blasted_lands.cpp +++ b/src/bindings/scripts/scripts/zone/blasted_lands/blasted_lands.cpp @@ -1,159 +1,159 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Blasted_Lands -SD%Complete: 90 -SDComment: Quest support: 2784, 2801, 3628. Missing some texts for Fallen Hero. Teleporter to Rise of the Defiler missing group support. -SDCategory: Blasted Lands -EndScriptData */ - -/* ContentData -npc_deathly_usher -npc_fallen_hero_of_horde -EndContentData */ - -#include "precompiled.h" - -/*###### -## npc_deathly_usher -######*/ - -#define GOSSIP_ITEM_USHER "I wish to to visit the Rise of the Defiler." - -#define SPELL_TELEPORT_SINGLE 12885 -#define SPELL_TELEPORT_SINGLE_IN_GROUP 13142 -#define SPELL_TELEPORT_GROUP 27686 - -bool GossipHello_npc_deathly_usher(Player *player, Creature *_Creature) -{ - if(player->GetQuestStatus(3628) == QUEST_STATUS_INCOMPLETE && player->HasItemCount(10757, 1)) - player->ADD_GOSSIP_ITEM(0, GOSSIP_ITEM_USHER, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF); - - player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); - - return true; -} - -bool GossipSelect_npc_deathly_usher(Player *player, Creature *_Creature, uint32 sender, uint32 action) -{ - if(action = GOSSIP_ACTION_INFO_DEF) - { - player->CLOSE_GOSSIP_MENU(); - _Creature->CastSpell(player, SPELL_TELEPORT_SINGLE, true); - } - - return true; -} - -/*###### -## npc_fallen_hero_of_horde -######*/ - -#define GOSSIP_ITEM_FALLEN "Continue..." - -#define GOSSIP_ITEM_FALLEN1 "What could be worse than death?" -#define GOSSIP_ITEM_FALLEN2 "Subordinates?" -#define GOSSIP_ITEM_FALLEN3 "What are the stones of binding?" -#define GOSSIP_ITEM_FALLEN4 "You can count on me, Hero" -#define GOSSIP_ITEM_FALLEN5 "I shall" - -bool GossipHello_npc_fallen_hero_of_horde(Player *player, Creature *_Creature) -{ - if (_Creature->isQuestGiver()) - player->PrepareQuestMenu( _Creature->GetGUID() ); - - if (player->GetQuestStatus(2784) == QUEST_STATUS_INCOMPLETE) - player->ADD_GOSSIP_ITEM( 0, "Why are you here?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); - - if (player->GetQuestStatus(2801) == QUEST_STATUS_INCOMPLETE && player->GetTeam() == HORDE) - player->ADD_GOSSIP_ITEM( 0, "Continue story...", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2); - - if (player->GetQuestStatus(2801) == QUEST_STATUS_INCOMPLETE && player->GetTeam() == ALLIANCE) - player->ADD_GOSSIP_ITEM( 0, "Why are you here?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); - - player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); - - return true; -} - -bool GossipSelect_npc_fallen_hero_of_horde(Player *player, Creature *_Creature, uint32 sender, uint32 action) -{ - switch (action) - { - case GOSSIP_ACTION_INFO_DEF+1: - player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM_FALLEN, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 11); - player->SEND_GOSSIP_MENU(1392, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+11: - player->SEND_GOSSIP_MENU(1411, _Creature->GetGUID()); - if (player->GetQuestStatus(2784) == QUEST_STATUS_INCOMPLETE) - player->AreaExploredOrEventHappens(2784); - if (player->GetTeam() == ALLIANCE) - { - player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM_FALLEN, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2); - player->SEND_GOSSIP_MENU(1411, _Creature->GetGUID()); - } - break; - - case GOSSIP_ACTION_INFO_DEF+2: - player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM_FALLEN, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 21); - player->SEND_GOSSIP_MENU(1451, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+21: - player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM_FALLEN1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 22); - player->SEND_GOSSIP_MENU(1452, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+22: - player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM_FALLEN2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 23); - player->SEND_GOSSIP_MENU(1453, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+23: - player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM_FALLEN3, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 24); - player->SEND_GOSSIP_MENU(1454, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+24: - player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM_FALLEN4, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 25); - player->SEND_GOSSIP_MENU(1455, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+25: - player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM_FALLEN5, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 26); - player->SEND_GOSSIP_MENU(1456, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+26: - player->CLOSE_GOSSIP_MENU(); - player->AreaExploredOrEventHappens(2801); - break; - } - return true; -} - -void AddSC_blasted_lands() -{ - Script *newscript; - - newscript = new Script; - newscript->Name="npc_deathly_usher"; - newscript->pGossipHello = &GossipHello_npc_deathly_usher; - newscript->pGossipSelect = &GossipSelect_npc_deathly_usher; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="npc_fallen_hero_of_horde"; - newscript->pGossipHello = &GossipHello_npc_fallen_hero_of_horde; - newscript->pGossipSelect = &GossipSelect_npc_fallen_hero_of_horde; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Blasted_Lands +SD%Complete: 90 +SDComment: Quest support: 2784, 2801, 3628. Missing some texts for Fallen Hero. Teleporter to Rise of the Defiler missing group support. +SDCategory: Blasted Lands +EndScriptData */ + +/* ContentData +npc_deathly_usher +npc_fallen_hero_of_horde +EndContentData */ + +#include "precompiled.h" + +/*###### +## npc_deathly_usher +######*/ + +#define GOSSIP_ITEM_USHER "I wish to to visit the Rise of the Defiler." + +#define SPELL_TELEPORT_SINGLE 12885 +#define SPELL_TELEPORT_SINGLE_IN_GROUP 13142 +#define SPELL_TELEPORT_GROUP 27686 + +bool GossipHello_npc_deathly_usher(Player *player, Creature *_Creature) +{ + if(player->GetQuestStatus(3628) == QUEST_STATUS_INCOMPLETE && player->HasItemCount(10757, 1)) + player->ADD_GOSSIP_ITEM(0, GOSSIP_ITEM_USHER, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF); + + player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); + + return true; +} + +bool GossipSelect_npc_deathly_usher(Player *player, Creature *_Creature, uint32 sender, uint32 action) +{ + if(action = GOSSIP_ACTION_INFO_DEF) + { + player->CLOSE_GOSSIP_MENU(); + _Creature->CastSpell(player, SPELL_TELEPORT_SINGLE, true); + } + + return true; +} + +/*###### +## npc_fallen_hero_of_horde +######*/ + +#define GOSSIP_ITEM_FALLEN "Continue..." + +#define GOSSIP_ITEM_FALLEN1 "What could be worse than death?" +#define GOSSIP_ITEM_FALLEN2 "Subordinates?" +#define GOSSIP_ITEM_FALLEN3 "What are the stones of binding?" +#define GOSSIP_ITEM_FALLEN4 "You can count on me, Hero" +#define GOSSIP_ITEM_FALLEN5 "I shall" + +bool GossipHello_npc_fallen_hero_of_horde(Player *player, Creature *_Creature) +{ + if (_Creature->isQuestGiver()) + player->PrepareQuestMenu( _Creature->GetGUID() ); + + if (player->GetQuestStatus(2784) == QUEST_STATUS_INCOMPLETE) + player->ADD_GOSSIP_ITEM( 0, "Why are you here?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); + + if (player->GetQuestStatus(2801) == QUEST_STATUS_INCOMPLETE && player->GetTeam() == HORDE) + player->ADD_GOSSIP_ITEM( 0, "Continue story...", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2); + + if (player->GetQuestStatus(2801) == QUEST_STATUS_INCOMPLETE && player->GetTeam() == ALLIANCE) + player->ADD_GOSSIP_ITEM( 0, "Why are you here?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); + + player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); + + return true; +} + +bool GossipSelect_npc_fallen_hero_of_horde(Player *player, Creature *_Creature, uint32 sender, uint32 action) +{ + switch (action) + { + case GOSSIP_ACTION_INFO_DEF+1: + player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM_FALLEN, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 11); + player->SEND_GOSSIP_MENU(1392, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+11: + player->SEND_GOSSIP_MENU(1411, _Creature->GetGUID()); + if (player->GetQuestStatus(2784) == QUEST_STATUS_INCOMPLETE) + player->AreaExploredOrEventHappens(2784); + if (player->GetTeam() == ALLIANCE) + { + player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM_FALLEN, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2); + player->SEND_GOSSIP_MENU(1411, _Creature->GetGUID()); + } + break; + + case GOSSIP_ACTION_INFO_DEF+2: + player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM_FALLEN, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 21); + player->SEND_GOSSIP_MENU(1451, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+21: + player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM_FALLEN1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 22); + player->SEND_GOSSIP_MENU(1452, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+22: + player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM_FALLEN2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 23); + player->SEND_GOSSIP_MENU(1453, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+23: + player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM_FALLEN3, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 24); + player->SEND_GOSSIP_MENU(1454, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+24: + player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM_FALLEN4, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 25); + player->SEND_GOSSIP_MENU(1455, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+25: + player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM_FALLEN5, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 26); + player->SEND_GOSSIP_MENU(1456, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+26: + player->CLOSE_GOSSIP_MENU(); + player->AreaExploredOrEventHappens(2801); + break; + } + return true; +} + +void AddSC_blasted_lands() +{ + Script *newscript; + + newscript = new Script; + newscript->Name="npc_deathly_usher"; + newscript->pGossipHello = &GossipHello_npc_deathly_usher; + newscript->pGossipSelect = &GossipSelect_npc_deathly_usher; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="npc_fallen_hero_of_horde"; + newscript->pGossipHello = &GossipHello_npc_fallen_hero_of_horde; + newscript->pGossipSelect = &GossipSelect_npc_fallen_hero_of_horde; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/blasted_lands/boss_kruul.cpp b/src/bindings/scripts/scripts/zone/blasted_lands/boss_kruul.cpp index fd8eb90ddf0..7843fb884e4 100644 --- a/src/bindings/scripts/scripts/zone/blasted_lands/boss_kruul.cpp +++ b/src/bindings/scripts/scripts/zone/blasted_lands/boss_kruul.cpp @@ -1,182 +1,182 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Kruul -SD%Complete: 100 -SDComment: Highlord Kruul are presumably no longer in-game on regular bases, however future events could bring him back. -SDCategory: Bosses -EndScriptData */ - -#include "precompiled.h" - -#define SPELL_SHADOWVOLLEY 21341 -#define SPELL_CLEAVE 20677 -#define SPELL_THUNDERCLAP 23931 -#define SPELL_TWISTEDREFLECTION 21063 -#define SPELL_VOIDBOLT 21066 -#define SPELL_RAGE 21340 -#define SPELL_CAPTURESOUL 21054 - -struct MANGOS_DLL_DECL boss_kruulAI : public ScriptedAI -{ - boss_kruulAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 ShadowVolley_Timer; - uint32 Cleave_Timer; - uint32 ThunderClap_Timer; - uint32 TwistedReflection_Timer; - uint32 VoidBolt_Timer; - uint32 Rage_Timer; - uint32 Hound_Timer; - int Rand; - int RandX; - int RandY; - Creature* Summoned; - - void Reset() - { - ShadowVolley_Timer = 10000; - Cleave_Timer = 14000; - ThunderClap_Timer = 20000; - TwistedReflection_Timer = 25000; - VoidBolt_Timer = 30000; - Rage_Timer = 60000; //Cast rage after 1 minute - Hound_Timer = 8000; - } - - void Aggro(Unit *who) - { - } - - void KilledUnit() - { - // When a player, pet or totem gets killed, Lord Kazzak casts this spell to instantly regenerate 70,000 health. - DoCast(m_creature,SPELL_CAPTURESOUL); - - } - - void SummonHounds(Unit* victim) - { - Rand = rand()%10; - switch (rand()%2) - { - case 0: RandX = 0 - Rand; break; - case 1: RandX = 0 + Rand; break; - } - Rand = 0; - Rand = rand()%10; - switch (rand()%2) - { - case 0: RandY = 0 - Rand; break; - case 1: RandY = 0 + Rand; break; - } - Rand = 0; - Summoned = DoSpawnCreature(19207, RandX, RandY, 0, 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 300000); - if(Summoned) - ((CreatureAI*)Summoned->AI())->AttackStart(victim); - } - - void UpdateAI(const uint32 diff) - { - //Return since we have no target - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - //ShadowVolley_Timer - if (ShadowVolley_Timer < diff) - { - if (rand()%100 < 46) - { - DoCast(m_creature->getVictim(),SPELL_SHADOWVOLLEY); - } - - ShadowVolley_Timer = 5000; - }else ShadowVolley_Timer -= diff; - - //Cleave_Timer - if (Cleave_Timer < diff) - { - if (rand()%100 < 50) - { - DoCast(m_creature->getVictim(),SPELL_CLEAVE); - } - - Cleave_Timer = 10000; - }else Cleave_Timer -= diff; - - //ThunderClap_Timer - if (ThunderClap_Timer < diff) - { - if (rand()%100 < 20) - { - DoCast(m_creature->getVictim(),SPELL_THUNDERCLAP); - } - - ThunderClap_Timer = 12000; - }else ThunderClap_Timer -= diff; - - //TwistedReflection_Timer - if (TwistedReflection_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_TWISTEDREFLECTION); - TwistedReflection_Timer = 30000; - }else TwistedReflection_Timer -= diff; - - //VoidBolt_Timer - if (VoidBolt_Timer < diff) - { - if (rand()%100 < 40) - { - DoCast(m_creature->getVictim(),SPELL_VOIDBOLT); - } - - VoidBolt_Timer = 18000; - }else VoidBolt_Timer -= diff; - - //Rage_Timer - if (Rage_Timer < diff) - { - DoCast(m_creature,SPELL_RAGE); - Rage_Timer = 70000; - }else Rage_Timer -= diff; - - //Hound_Timer - if (Hound_Timer < diff) - { - SummonHounds(m_creature->getVictim()); - SummonHounds(m_creature->getVictim()); - SummonHounds(m_creature->getVictim()); - - Hound_Timer = 45000; - }else Hound_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; -CreatureAI* GetAI_boss_kruul(Creature *_Creature) -{ - return new boss_kruulAI (_Creature); -} - -void AddSC_boss_kruul() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_kruul"; - newscript->GetAI = GetAI_boss_kruul; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Kruul +SD%Complete: 100 +SDComment: Highlord Kruul are presumably no longer in-game on regular bases, however future events could bring him back. +SDCategory: Bosses +EndScriptData */ + +#include "precompiled.h" + +#define SPELL_SHADOWVOLLEY 21341 +#define SPELL_CLEAVE 20677 +#define SPELL_THUNDERCLAP 23931 +#define SPELL_TWISTEDREFLECTION 21063 +#define SPELL_VOIDBOLT 21066 +#define SPELL_RAGE 21340 +#define SPELL_CAPTURESOUL 21054 + +struct MANGOS_DLL_DECL boss_kruulAI : public ScriptedAI +{ + boss_kruulAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 ShadowVolley_Timer; + uint32 Cleave_Timer; + uint32 ThunderClap_Timer; + uint32 TwistedReflection_Timer; + uint32 VoidBolt_Timer; + uint32 Rage_Timer; + uint32 Hound_Timer; + int Rand; + int RandX; + int RandY; + Creature* Summoned; + + void Reset() + { + ShadowVolley_Timer = 10000; + Cleave_Timer = 14000; + ThunderClap_Timer = 20000; + TwistedReflection_Timer = 25000; + VoidBolt_Timer = 30000; + Rage_Timer = 60000; //Cast rage after 1 minute + Hound_Timer = 8000; + } + + void Aggro(Unit *who) + { + } + + void KilledUnit() + { + // When a player, pet or totem gets killed, Lord Kazzak casts this spell to instantly regenerate 70,000 health. + DoCast(m_creature,SPELL_CAPTURESOUL); + + } + + void SummonHounds(Unit* victim) + { + Rand = rand()%10; + switch (rand()%2) + { + case 0: RandX = 0 - Rand; break; + case 1: RandX = 0 + Rand; break; + } + Rand = 0; + Rand = rand()%10; + switch (rand()%2) + { + case 0: RandY = 0 - Rand; break; + case 1: RandY = 0 + Rand; break; + } + Rand = 0; + Summoned = DoSpawnCreature(19207, RandX, RandY, 0, 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 300000); + if(Summoned) + ((CreatureAI*)Summoned->AI())->AttackStart(victim); + } + + void UpdateAI(const uint32 diff) + { + //Return since we have no target + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + //ShadowVolley_Timer + if (ShadowVolley_Timer < diff) + { + if (rand()%100 < 46) + { + DoCast(m_creature->getVictim(),SPELL_SHADOWVOLLEY); + } + + ShadowVolley_Timer = 5000; + }else ShadowVolley_Timer -= diff; + + //Cleave_Timer + if (Cleave_Timer < diff) + { + if (rand()%100 < 50) + { + DoCast(m_creature->getVictim(),SPELL_CLEAVE); + } + + Cleave_Timer = 10000; + }else Cleave_Timer -= diff; + + //ThunderClap_Timer + if (ThunderClap_Timer < diff) + { + if (rand()%100 < 20) + { + DoCast(m_creature->getVictim(),SPELL_THUNDERCLAP); + } + + ThunderClap_Timer = 12000; + }else ThunderClap_Timer -= diff; + + //TwistedReflection_Timer + if (TwistedReflection_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_TWISTEDREFLECTION); + TwistedReflection_Timer = 30000; + }else TwistedReflection_Timer -= diff; + + //VoidBolt_Timer + if (VoidBolt_Timer < diff) + { + if (rand()%100 < 40) + { + DoCast(m_creature->getVictim(),SPELL_VOIDBOLT); + } + + VoidBolt_Timer = 18000; + }else VoidBolt_Timer -= diff; + + //Rage_Timer + if (Rage_Timer < diff) + { + DoCast(m_creature,SPELL_RAGE); + Rage_Timer = 70000; + }else Rage_Timer -= diff; + + //Hound_Timer + if (Hound_Timer < diff) + { + SummonHounds(m_creature->getVictim()); + SummonHounds(m_creature->getVictim()); + SummonHounds(m_creature->getVictim()); + + Hound_Timer = 45000; + }else Hound_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; +CreatureAI* GetAI_boss_kruul(Creature *_Creature) +{ + return new boss_kruulAI (_Creature); +} + +void AddSC_boss_kruul() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_kruul"; + newscript->GetAI = GetAI_boss_kruul; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/bloodmyst_isle/bloodmyst_isle.cpp b/src/bindings/scripts/scripts/zone/bloodmyst_isle/bloodmyst_isle.cpp index 254d5082797..a12c8995e5d 100644 --- a/src/bindings/scripts/scripts/zone/bloodmyst_isle/bloodmyst_isle.cpp +++ b/src/bindings/scripts/scripts/zone/bloodmyst_isle/bloodmyst_isle.cpp @@ -1,141 +1,141 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Bloodmyst_Isle -SD%Complete: 80 -SDComment: Quest support: 9670, 9756(gossip items text needed). -SDCategory: Bloodmyst Isle -EndScriptData */ - -/* ContentData -mob_webbed_creature -npc_captured_sunhawk_agent -EndContentData */ - -#include "precompiled.h" - -/*###### -## mob_webbed_creature -######*/ - -//possible creatures to be spawned -const uint32 possibleSpawns[32] = {17322, 17661, 17496, 17522, 17340, 17352, 17333, 17524, 17654, 17348, 17339, 17345, 17359, 17353, 17336, 17550, 17330, 17701, 17321, 17680, 17325, 17320, 17683, 17342, 17715, 17334, 17341, 17338, 17337, 17346, 17344, 17327}; - -struct MANGOS_DLL_DECL mob_webbed_creatureAI : public ScriptedAI -{ - mob_webbed_creatureAI(Creature *c) : ScriptedAI(c) {Reset();} - - void Reset() - { - } - - void Aggro(Unit* who) - { - } - - void JustDied(Unit* Killer) - { - uint32 spawnCreatureID; - - switch(rand()%3) - { - case 0: - spawnCreatureID = 17681; - if (Killer->GetTypeId() == TYPEID_PLAYER) - ((Player*)Killer)->KilledMonster(spawnCreatureID, m_creature->GetGUID()); - break; - case 1: - case 2: - spawnCreatureID = possibleSpawns[rand()%31]; - break; - } - - if(spawnCreatureID) - DoSpawnCreature(spawnCreatureID,0,0,0,m_creature->GetOrientation(), TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 60000); - } -}; -CreatureAI* GetAI_mob_webbed_creature(Creature *_Creature) -{ - return new mob_webbed_creatureAI (_Creature); -} - -/*###### -## npc_captured_sunhawk_agent -######*/ - -#define C_SUNHAWK_TRIGGER 17974 - -bool GossipHello_npc_captured_sunhawk_agent(Player *player, Creature *_Creature) -{ - if (player->HasAura(31609,1) && player->GetQuestStatus(9756) == QUEST_STATUS_INCOMPLETE) - { - player->ADD_GOSSIP_ITEM( 0, "[PH] ", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); - player->SEND_GOSSIP_MENU(9136, _Creature->GetGUID()); - } - else - player->SEND_GOSSIP_MENU(9134, _Creature->GetGUID()); - - return true; -} - -bool GossipSelect_npc_captured_sunhawk_agent(Player *player, Creature *_Creature, uint32 sender, uint32 action) -{ - switch (action) - { - case GOSSIP_ACTION_INFO_DEF+1: - player->ADD_GOSSIP_ITEM( 0, "[PH] ", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2); - player->SEND_GOSSIP_MENU(9137, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+2: - player->ADD_GOSSIP_ITEM( 0, "[PH] ", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+3); - player->SEND_GOSSIP_MENU(9138, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+3: - player->ADD_GOSSIP_ITEM( 0, "[PH] ", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+4); - player->SEND_GOSSIP_MENU(9139, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+4: - player->ADD_GOSSIP_ITEM( 0, "[PH] ", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+5); - player->SEND_GOSSIP_MENU(9140, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+5: - player->ADD_GOSSIP_ITEM( 0, "[PH] ", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+6); - player->SEND_GOSSIP_MENU(9141, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+6: - player->CLOSE_GOSSIP_MENU(); - player->TalkedToCreature(C_SUNHAWK_TRIGGER, _Creature->GetGUID()); - break; - } - return true; -} - -void AddSC_bloodmyst_isle() -{ - Script *newscript; - - newscript = new Script; - newscript->Name="mob_webbed_creature"; - newscript->GetAI = GetAI_mob_webbed_creature; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="npc_captured_sunhawk_agent"; - newscript->pGossipHello = &GossipHello_npc_captured_sunhawk_agent; - newscript->pGossipSelect = &GossipSelect_npc_captured_sunhawk_agent; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Bloodmyst_Isle +SD%Complete: 80 +SDComment: Quest support: 9670, 9756(gossip items text needed). +SDCategory: Bloodmyst Isle +EndScriptData */ + +/* ContentData +mob_webbed_creature +npc_captured_sunhawk_agent +EndContentData */ + +#include "precompiled.h" + +/*###### +## mob_webbed_creature +######*/ + +//possible creatures to be spawned +const uint32 possibleSpawns[32] = {17322, 17661, 17496, 17522, 17340, 17352, 17333, 17524, 17654, 17348, 17339, 17345, 17359, 17353, 17336, 17550, 17330, 17701, 17321, 17680, 17325, 17320, 17683, 17342, 17715, 17334, 17341, 17338, 17337, 17346, 17344, 17327}; + +struct MANGOS_DLL_DECL mob_webbed_creatureAI : public ScriptedAI +{ + mob_webbed_creatureAI(Creature *c) : ScriptedAI(c) {Reset();} + + void Reset() + { + } + + void Aggro(Unit* who) + { + } + + void JustDied(Unit* Killer) + { + uint32 spawnCreatureID; + + switch(rand()%3) + { + case 0: + spawnCreatureID = 17681; + if (Killer->GetTypeId() == TYPEID_PLAYER) + ((Player*)Killer)->KilledMonster(spawnCreatureID, m_creature->GetGUID()); + break; + case 1: + case 2: + spawnCreatureID = possibleSpawns[rand()%31]; + break; + } + + if(spawnCreatureID) + DoSpawnCreature(spawnCreatureID,0,0,0,m_creature->GetOrientation(), TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 60000); + } +}; +CreatureAI* GetAI_mob_webbed_creature(Creature *_Creature) +{ + return new mob_webbed_creatureAI (_Creature); +} + +/*###### +## npc_captured_sunhawk_agent +######*/ + +#define C_SUNHAWK_TRIGGER 17974 + +bool GossipHello_npc_captured_sunhawk_agent(Player *player, Creature *_Creature) +{ + if (player->HasAura(31609,1) && player->GetQuestStatus(9756) == QUEST_STATUS_INCOMPLETE) + { + player->ADD_GOSSIP_ITEM( 0, "[PH] ", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); + player->SEND_GOSSIP_MENU(9136, _Creature->GetGUID()); + } + else + player->SEND_GOSSIP_MENU(9134, _Creature->GetGUID()); + + return true; +} + +bool GossipSelect_npc_captured_sunhawk_agent(Player *player, Creature *_Creature, uint32 sender, uint32 action) +{ + switch (action) + { + case GOSSIP_ACTION_INFO_DEF+1: + player->ADD_GOSSIP_ITEM( 0, "[PH] ", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2); + player->SEND_GOSSIP_MENU(9137, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+2: + player->ADD_GOSSIP_ITEM( 0, "[PH] ", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+3); + player->SEND_GOSSIP_MENU(9138, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+3: + player->ADD_GOSSIP_ITEM( 0, "[PH] ", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+4); + player->SEND_GOSSIP_MENU(9139, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+4: + player->ADD_GOSSIP_ITEM( 0, "[PH] ", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+5); + player->SEND_GOSSIP_MENU(9140, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+5: + player->ADD_GOSSIP_ITEM( 0, "[PH] ", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+6); + player->SEND_GOSSIP_MENU(9141, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+6: + player->CLOSE_GOSSIP_MENU(); + player->TalkedToCreature(C_SUNHAWK_TRIGGER, _Creature->GetGUID()); + break; + } + return true; +} + +void AddSC_bloodmyst_isle() +{ + Script *newscript; + + newscript = new Script; + newscript->Name="mob_webbed_creature"; + newscript->GetAI = GetAI_mob_webbed_creature; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="npc_captured_sunhawk_agent"; + newscript->pGossipHello = &GossipHello_npc_captured_sunhawk_agent; + newscript->pGossipSelect = &GossipSelect_npc_captured_sunhawk_agent; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/burning_steppes/burning_steppes.cpp b/src/bindings/scripts/scripts/zone/burning_steppes/burning_steppes.cpp index 0526163be56..42e33c67abc 100644 --- a/src/bindings/scripts/scripts/zone/burning_steppes/burning_steppes.cpp +++ b/src/bindings/scripts/scripts/zone/burning_steppes/burning_steppes.cpp @@ -1,157 +1,157 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Burning_Steppes -SD%Complete: 100 -SDComment: Quest support: 4224, 4866 -SDCategory: Burning Steppes -EndScriptData */ - -/* ContentData -npc_ragged_john -EndContentData */ - -#include "precompiled.h" - -/*###### -## npc_ragged_john -######*/ - -struct MANGOS_DLL_DECL npc_ragged_johnAI : public ScriptedAI -{ - npc_ragged_johnAI(Creature *c) : ScriptedAI(c) { Reset(); } - - void Reset() {} - - void MoveInLineOfSight(Unit *who) - { - if( who->HasAura(16468,0) ) - { - if( who->GetTypeId() == TYPEID_PLAYER && m_creature->IsWithinDistInMap(who, 15) && who->isInAccessablePlaceFor(m_creature) ) - { - DoCast(who,16472); - ((Player*)who)->AreaExploredOrEventHappens(4866); - } - } - - if( !m_creature->getVictim() && who->isTargetableForAttack() && ( m_creature->IsHostileTo( who )) && who->isInAccessablePlaceFor(m_creature) ) - { - if (m_creature->GetDistanceZ(who) > CREATURE_Z_ATTACK_RANGE) - return; - - float attackRadius = m_creature->GetAttackDistance(who); - if( m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->IsWithinLOSInMap(who) ) - { - DoStartAttackAndMovement(who); - who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); - - if (!InCombat) - { - Aggro(who); - InCombat = true; - } - } - } - } - - void Aggro(Unit *who) {} -}; - -CreatureAI* GetAI_npc_ragged_john(Creature *_Creature) -{ - return new npc_ragged_johnAI (_Creature); -} - -bool GossipHello_npc_ragged_john(Player *player, Creature *_Creature) -{ - if (_Creature->isQuestGiver()) - player->PrepareQuestMenu( _Creature->GetGUID() ); - - if (player->GetQuestStatus(4224) == QUEST_STATUS_INCOMPLETE) - player->ADD_GOSSIP_ITEM( 0, "Official buisness, John. I need some information about Marsha Windsor. Tell me about the last time you saw him.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF); - - player->SEND_GOSSIP_MENU(2713, _Creature->GetGUID()); - return true; -} - -bool GossipSelect_npc_ragged_john(Player *player, Creature *_Creature, uint32 sender, uint32 action) -{ - switch (action) - { - case GOSSIP_ACTION_INFO_DEF: - player->ADD_GOSSIP_ITEM( 0, "So what did you do?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); - player->SEND_GOSSIP_MENU(2714, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+1: - player->ADD_GOSSIP_ITEM( 0, "Start making sense, dwarf. I don't want to have anything to do with your cracker, your pappy, or any sort of 'discreditin'.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2); - player->SEND_GOSSIP_MENU(2715, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+2: - player->ADD_GOSSIP_ITEM( 0, "Ironfoe?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 3); - player->SEND_GOSSIP_MENU(2716, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+3: - player->ADD_GOSSIP_ITEM( 0, "Interesting... continue John.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 4); - player->SEND_GOSSIP_MENU(2717, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+4: - player->ADD_GOSSIP_ITEM( 0, "So that's how Windsor died...", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 5); - player->SEND_GOSSIP_MENU(2718, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+5: - player->ADD_GOSSIP_ITEM( 0, "So how did he die?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 6); - player->SEND_GOSSIP_MENU(2719, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+6: - player->ADD_GOSSIP_ITEM( 0, "Ok so where the hell is he? Wait a minute! Are you drunk?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 7); - player->SEND_GOSSIP_MENU(2720, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+7: - player->ADD_GOSSIP_ITEM( 0, "WHY is he in Blackrock Depths?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 8); - player->SEND_GOSSIP_MENU(2721, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+8: - player->ADD_GOSSIP_ITEM( 0, "300? So the Dark Irons killed him and dragged him into the Depths?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 9); - player->SEND_GOSSIP_MENU(2722, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+9: - player->ADD_GOSSIP_ITEM( 0, "Ahh... Ironfoe", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 10); - player->SEND_GOSSIP_MENU(2723, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+10: - player->ADD_GOSSIP_ITEM( 0, "Thanks, Ragged John. Your story was very uplifting and informative", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 11); - player->SEND_GOSSIP_MENU(2725, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+11: - player->CLOSE_GOSSIP_MENU(); - player->AreaExploredOrEventHappens(4224); - break; - } - return true; -} - -void AddSC_burning_steppes() -{ - Script *newscript; - - newscript = new Script; - newscript->Name="npc_ragged_john"; - newscript->GetAI = GetAI_npc_ragged_john; - newscript->pGossipHello = &GossipHello_npc_ragged_john; - newscript->pGossipSelect = &GossipSelect_npc_ragged_john; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Burning_Steppes +SD%Complete: 100 +SDComment: Quest support: 4224, 4866 +SDCategory: Burning Steppes +EndScriptData */ + +/* ContentData +npc_ragged_john +EndContentData */ + +#include "precompiled.h" + +/*###### +## npc_ragged_john +######*/ + +struct MANGOS_DLL_DECL npc_ragged_johnAI : public ScriptedAI +{ + npc_ragged_johnAI(Creature *c) : ScriptedAI(c) { Reset(); } + + void Reset() {} + + void MoveInLineOfSight(Unit *who) + { + if( who->HasAura(16468,0) ) + { + if( who->GetTypeId() == TYPEID_PLAYER && m_creature->IsWithinDistInMap(who, 15) && who->isInAccessablePlaceFor(m_creature) ) + { + DoCast(who,16472); + ((Player*)who)->AreaExploredOrEventHappens(4866); + } + } + + if( !m_creature->getVictim() && who->isTargetableForAttack() && ( m_creature->IsHostileTo( who )) && who->isInAccessablePlaceFor(m_creature) ) + { + if (!m_creature->canFly() && m_creature->GetDistanceZ(who) > CREATURE_Z_ATTACK_RANGE) + return; + + float attackRadius = m_creature->GetAttackDistance(who); + if( m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->IsWithinLOSInMap(who) ) + { + DoStartAttackAndMovement(who); + who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); + + if (!InCombat) + { + Aggro(who); + InCombat = true; + } + } + } + } + + void Aggro(Unit *who) {} +}; + +CreatureAI* GetAI_npc_ragged_john(Creature *_Creature) +{ + return new npc_ragged_johnAI (_Creature); +} + +bool GossipHello_npc_ragged_john(Player *player, Creature *_Creature) +{ + if (_Creature->isQuestGiver()) + player->PrepareQuestMenu( _Creature->GetGUID() ); + + if (player->GetQuestStatus(4224) == QUEST_STATUS_INCOMPLETE) + player->ADD_GOSSIP_ITEM( 0, "Official buisness, John. I need some information about Marsha Windsor. Tell me about the last time you saw him.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF); + + player->SEND_GOSSIP_MENU(2713, _Creature->GetGUID()); + return true; +} + +bool GossipSelect_npc_ragged_john(Player *player, Creature *_Creature, uint32 sender, uint32 action) +{ + switch (action) + { + case GOSSIP_ACTION_INFO_DEF: + player->ADD_GOSSIP_ITEM( 0, "So what did you do?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); + player->SEND_GOSSIP_MENU(2714, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+1: + player->ADD_GOSSIP_ITEM( 0, "Start making sense, dwarf. I don't want to have anything to do with your cracker, your pappy, or any sort of 'discreditin'.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2); + player->SEND_GOSSIP_MENU(2715, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+2: + player->ADD_GOSSIP_ITEM( 0, "Ironfoe?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 3); + player->SEND_GOSSIP_MENU(2716, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+3: + player->ADD_GOSSIP_ITEM( 0, "Interesting... continue John.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 4); + player->SEND_GOSSIP_MENU(2717, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+4: + player->ADD_GOSSIP_ITEM( 0, "So that's how Windsor died...", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 5); + player->SEND_GOSSIP_MENU(2718, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+5: + player->ADD_GOSSIP_ITEM( 0, "So how did he die?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 6); + player->SEND_GOSSIP_MENU(2719, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+6: + player->ADD_GOSSIP_ITEM( 0, "Ok so where the hell is he? Wait a minute! Are you drunk?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 7); + player->SEND_GOSSIP_MENU(2720, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+7: + player->ADD_GOSSIP_ITEM( 0, "WHY is he in Blackrock Depths?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 8); + player->SEND_GOSSIP_MENU(2721, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+8: + player->ADD_GOSSIP_ITEM( 0, "300? So the Dark Irons killed him and dragged him into the Depths?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 9); + player->SEND_GOSSIP_MENU(2722, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+9: + player->ADD_GOSSIP_ITEM( 0, "Ahh... Ironfoe", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 10); + player->SEND_GOSSIP_MENU(2723, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+10: + player->ADD_GOSSIP_ITEM( 0, "Thanks, Ragged John. Your story was very uplifting and informative", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 11); + player->SEND_GOSSIP_MENU(2725, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+11: + player->CLOSE_GOSSIP_MENU(); + player->AreaExploredOrEventHappens(4224); + break; + } + return true; +} + +void AddSC_burning_steppes() +{ + Script *newscript; + + newscript = new Script; + newscript->Name="npc_ragged_john"; + newscript->GetAI = GetAI_npc_ragged_john; + newscript->pGossipHello = &GossipHello_npc_ragged_john; + newscript->pGossipSelect = &GossipSelect_npc_ragged_john; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/caverns_of_time/dark_portal/boss_aeonus.cpp b/src/bindings/scripts/scripts/zone/caverns_of_time/dark_portal/boss_aeonus.cpp index 89e9ee31dfe..330fe6b8e08 100644 --- a/src/bindings/scripts/scripts/zone/caverns_of_time/dark_portal/boss_aeonus.cpp +++ b/src/bindings/scripts/scripts/zone/caverns_of_time/dark_portal/boss_aeonus.cpp @@ -1,137 +1,137 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Aeonus -SD%Complete: 100 -SDComment: -SDCategory: Caverns of Time, The Dark Portal -EndScriptData */ - -#include "precompiled.h" - -#define SAND_BREATH 31478 -#define TIME_STOP 31422 -#define FRENZY 19812 - -#define SAY_ENTER "The time has come to shatter this clockwork universe forever! Let us no longer be slaves of the hourglass! I warn you: those who do not embrace the greater path shall become victims of its passing!" -#define SAY_AGGRO "Let us see what fate lays in store..." -#define SAY_BANISH "Your time is up, slave of the past!" -#define SAY_SLAY1 "One less obstacle in our way!" -#define SAY_SLAY2 "No one can stop us! No one!" -#define SAY_DEATH "It is only a matter...of time." - -#define SOUND_ENTER 10400 -#define SOUND_AGGRO 10402 -#define SOUND_BANISH 10401 -#define SOUND_SLAY1 10403 -#define SOUND_SLAY2 10404 -#define SOUND_DEATH 10405 - -struct MANGOS_DLL_DECL boss_aeonusAI : public ScriptedAI -{ - boss_aeonusAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 SandBreath_Timer; - uint32 TimeStop_Timer; - uint32 Frenzy_Timer; - - void Reset() - { - SandBreath_Timer = 30000; - TimeStop_Timer = 40000; - Frenzy_Timer = 120000; - } - - void Aggro(Unit *who) - { - DoYell(SAY_AGGRO,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature, SOUND_AGGRO); - } - - void JustDied(Unit *victim) - { - //Just Died - DoYell(SAY_DEATH,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature, SOUND_DEATH); - } - - void KilledUnit(Unit *victim) - { - //Killed Unit - switch(rand()%2) - { - case 0: - DoYell(SAY_SLAY1,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature, SOUND_SLAY1); - break; - case 1: - DoYell(SAY_SLAY2,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature, SOUND_SLAY2); - break; - } - } - - void UpdateAI(const uint32 diff) - { - //Return since we have no target - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - //Sand Breath - if (SandBreath_Timer < diff) - { - Unit* target = NULL; - target = m_creature->getVictim(); - if (target) - DoCast(target, SAND_BREATH); - SandBreath_Timer = 30000; - }else SandBreath_Timer -= diff; - - //Time Stop - if (TimeStop_Timer < diff) - { - DoYell(SAY_BANISH, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_BANISH); - - DoCast(m_creature->getVictim(), TIME_STOP); - TimeStop_Timer = 40000; - }else TimeStop_Timer -= diff; - - //Frenzy - if (Frenzy_Timer < diff) - { - DoCast(m_creature, FRENZY); - Frenzy_Timer = 120000; - }else Frenzy_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; - -CreatureAI* GetAI_boss_aeonus(Creature *_Creature) -{ - return new boss_aeonusAI (_Creature); -} - -void AddSC_boss_aeonus() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_aeonus"; - newscript->GetAI = GetAI_boss_aeonus; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Aeonus +SD%Complete: 100 +SDComment: +SDCategory: Caverns of Time, The Dark Portal +EndScriptData */ + +#include "precompiled.h" + +#define SAND_BREATH 31478 +#define TIME_STOP 31422 +#define FRENZY 19812 + +#define SAY_ENTER "The time has come to shatter this clockwork universe forever! Let us no longer be slaves of the hourglass! I warn you: those who do not embrace the greater path shall become victims of its passing!" +#define SAY_AGGRO "Let us see what fate lays in store..." +#define SAY_BANISH "Your time is up, slave of the past!" +#define SAY_SLAY1 "One less obstacle in our way!" +#define SAY_SLAY2 "No one can stop us! No one!" +#define SAY_DEATH "It is only a matter...of time." + +#define SOUND_ENTER 10400 +#define SOUND_AGGRO 10402 +#define SOUND_BANISH 10401 +#define SOUND_SLAY1 10403 +#define SOUND_SLAY2 10404 +#define SOUND_DEATH 10405 + +struct MANGOS_DLL_DECL boss_aeonusAI : public ScriptedAI +{ + boss_aeonusAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 SandBreath_Timer; + uint32 TimeStop_Timer; + uint32 Frenzy_Timer; + + void Reset() + { + SandBreath_Timer = 30000; + TimeStop_Timer = 40000; + Frenzy_Timer = 120000; + } + + void Aggro(Unit *who) + { + DoYell(SAY_AGGRO,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature, SOUND_AGGRO); + } + + void JustDied(Unit *victim) + { + //Just Died + DoYell(SAY_DEATH,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature, SOUND_DEATH); + } + + void KilledUnit(Unit *victim) + { + //Killed Unit + switch(rand()%2) + { + case 0: + DoYell(SAY_SLAY1,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature, SOUND_SLAY1); + break; + case 1: + DoYell(SAY_SLAY2,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature, SOUND_SLAY2); + break; + } + } + + void UpdateAI(const uint32 diff) + { + //Return since we have no target + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + //Sand Breath + if (SandBreath_Timer < diff) + { + Unit* target = NULL; + target = m_creature->getVictim(); + if (target) + DoCast(target, SAND_BREATH); + SandBreath_Timer = 30000; + }else SandBreath_Timer -= diff; + + //Time Stop + if (TimeStop_Timer < diff) + { + DoYell(SAY_BANISH, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_BANISH); + + DoCast(m_creature->getVictim(), TIME_STOP); + TimeStop_Timer = 40000; + }else TimeStop_Timer -= diff; + + //Frenzy + if (Frenzy_Timer < diff) + { + DoCast(m_creature, FRENZY); + Frenzy_Timer = 120000; + }else Frenzy_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; + +CreatureAI* GetAI_boss_aeonus(Creature *_Creature) +{ + return new boss_aeonusAI (_Creature); +} + +void AddSC_boss_aeonus() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_aeonus"; + newscript->GetAI = GetAI_boss_aeonus; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/caverns_of_time/dark_portal/boss_chrono_lord_deja.cpp b/src/bindings/scripts/scripts/zone/caverns_of_time/dark_portal/boss_chrono_lord_deja.cpp index 1dcc7fcc5ee..4d958332bb8 100644 --- a/src/bindings/scripts/scripts/zone/caverns_of_time/dark_portal/boss_chrono_lord_deja.cpp +++ b/src/bindings/scripts/scripts/zone/caverns_of_time/dark_portal/boss_chrono_lord_deja.cpp @@ -1,124 +1,124 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Chrono_Lord_Deja -SD%Complete: 100 -SDComment: -SDCategory: Caverns of Time, The Dark Portal -EndScriptData */ - -#include "precompiled.h" - -#define ARCANE_BLAST 24857 -#define TIME_LAPSE 31467 -#define MAGNETIC_PULL 28337 //Not Implemented (Heroic mod) - -#define SAY_ENTER "Why do you aid the Magus? Just think of how many lives could be saved if the portal is never opened, if the resulting wars could be erased ..." -#define SAY_AGGRO "If you will not cease this foolish quest, then you will die!" -#define SAY_BANISH "You have outstayed your welcome, Timekeeper. Begone!" -#define SAY_SLAY1 "I told you it was a fool's quest!" -#define SAY_SLAY2 "Leaving so soon?" -#define SAY_DEATH "Time ... is on our side." - -#define SOUND_ENTER 10412 -#define SOUND_AGGRO 10414 -#define SOUND_BANISH 10413 -#define SOUND_SLAY1 10415 -#define SOUND_SLAY2 10416 -#define SOUND_DEATH 10417 - -struct MANGOS_DLL_DECL boss_chrono_lord_dejaAI : public ScriptedAI -{ - boss_chrono_lord_dejaAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 ArcaneBlast_Timer; - uint32 TimeLapse_Timer; - - void Reset() - { - ArcaneBlast_Timer = 20000; - TimeLapse_Timer = 15000; - } - - void Aggro(Unit *who) - { - DoYell(SAY_AGGRO, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_AGGRO); - - } - - void KilledUnit(Unit *victim) - { - switch(rand()%2) - { - case 0: - DoYell(SAY_SLAY1,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature, SOUND_SLAY1); - break; - case 1: - DoYell(SAY_SLAY2,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature, SOUND_SLAY2); - break; - } - } - - void JustDied(Unit *victim) - { - DoYell(SAY_DEATH,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature, SOUND_DEATH); - } - - void UpdateAI(const uint32 diff) - { - //Return since we have no target - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - //Arcane Blast - if (ArcaneBlast_Timer < diff) - { - DoCast(m_creature->getVictim(), ARCANE_BLAST); - ArcaneBlast_Timer = 20000+rand()%5000; - }else ArcaneBlast_Timer -= diff; - - //Time Lapse - if (TimeLapse_Timer < diff) - { - DoYell(SAY_BANISH, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_BANISH); - DoCast(m_creature, TIME_LAPSE); - TimeLapse_Timer = 15000+rand()%10000; - }else TimeLapse_Timer -= diff; - - DoMeleeAttackIfReady(); - - } -}; - -CreatureAI* GetAI_boss_chrono_lord_deja(Creature *_Creature) -{ - return new boss_chrono_lord_dejaAI (_Creature); -} - -void AddSC_boss_chrono_lord_deja() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_chrono_lord_deja"; - newscript->GetAI = GetAI_boss_chrono_lord_deja; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Chrono_Lord_Deja +SD%Complete: 100 +SDComment: +SDCategory: Caverns of Time, The Dark Portal +EndScriptData */ + +#include "precompiled.h" + +#define ARCANE_BLAST 24857 +#define TIME_LAPSE 31467 +#define MAGNETIC_PULL 28337 //Not Implemented (Heroic mod) + +#define SAY_ENTER "Why do you aid the Magus? Just think of how many lives could be saved if the portal is never opened, if the resulting wars could be erased ..." +#define SAY_AGGRO "If you will not cease this foolish quest, then you will die!" +#define SAY_BANISH "You have outstayed your welcome, Timekeeper. Begone!" +#define SAY_SLAY1 "I told you it was a fool's quest!" +#define SAY_SLAY2 "Leaving so soon?" +#define SAY_DEATH "Time ... is on our side." + +#define SOUND_ENTER 10412 +#define SOUND_AGGRO 10414 +#define SOUND_BANISH 10413 +#define SOUND_SLAY1 10415 +#define SOUND_SLAY2 10416 +#define SOUND_DEATH 10417 + +struct MANGOS_DLL_DECL boss_chrono_lord_dejaAI : public ScriptedAI +{ + boss_chrono_lord_dejaAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 ArcaneBlast_Timer; + uint32 TimeLapse_Timer; + + void Reset() + { + ArcaneBlast_Timer = 20000; + TimeLapse_Timer = 15000; + } + + void Aggro(Unit *who) + { + DoYell(SAY_AGGRO, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_AGGRO); + + } + + void KilledUnit(Unit *victim) + { + switch(rand()%2) + { + case 0: + DoYell(SAY_SLAY1,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature, SOUND_SLAY1); + break; + case 1: + DoYell(SAY_SLAY2,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature, SOUND_SLAY2); + break; + } + } + + void JustDied(Unit *victim) + { + DoYell(SAY_DEATH,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature, SOUND_DEATH); + } + + void UpdateAI(const uint32 diff) + { + //Return since we have no target + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + //Arcane Blast + if (ArcaneBlast_Timer < diff) + { + DoCast(m_creature->getVictim(), ARCANE_BLAST); + ArcaneBlast_Timer = 20000+rand()%5000; + }else ArcaneBlast_Timer -= diff; + + //Time Lapse + if (TimeLapse_Timer < diff) + { + DoYell(SAY_BANISH, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_BANISH); + DoCast(m_creature, TIME_LAPSE); + TimeLapse_Timer = 15000+rand()%10000; + }else TimeLapse_Timer -= diff; + + DoMeleeAttackIfReady(); + + } +}; + +CreatureAI* GetAI_boss_chrono_lord_deja(Creature *_Creature) +{ + return new boss_chrono_lord_dejaAI (_Creature); +} + +void AddSC_boss_chrono_lord_deja() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_chrono_lord_deja"; + newscript->GetAI = GetAI_boss_chrono_lord_deja; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/caverns_of_time/dark_portal/boss_temporus.cpp b/src/bindings/scripts/scripts/zone/caverns_of_time/dark_portal/boss_temporus.cpp index c95657634cf..958e1c33de6 100644 --- a/src/bindings/scripts/scripts/zone/caverns_of_time/dark_portal/boss_temporus.cpp +++ b/src/bindings/scripts/scripts/zone/caverns_of_time/dark_portal/boss_temporus.cpp @@ -1,166 +1,169 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Temporus -SD%Complete: 100 -SDComment: -SDCategory: Caverns of Time, The Dark Portal -EndScriptData */ - -#include "precompiled.h" - -#define SPELL_TAUNT 355 -#define SPELL_HASTE 31458 -#define SPELL_MORTAL_WOUND 28467 -#define SPELL_REFLECT 23920 //Not Implemented (Heroic mod) - -#define SAY_ENTER "Why do you persist? Surely you can see the futility of it all. It is not too late! You may still leave with your lives ..." -#define SAY_AGGRO "So be it ... you have been warned." -#define SAY_BANISH "Time... sands of time is run out for you." -#define SAY_SLAY1 "You should have left when you had the chance." -#define SAY_SLAY2 "Your days are done." -#define SAY_DEATH "My death means ... little." - -#define SOUND_ENTER 10442 -#define SOUND_AGGRO 10444 -#define SOUND_BANISH 10443 -#define SOUND_SLAY1 10445 -#define SOUND_SLAY2 10446 -#define SOUND_DEATH 10447 - -struct MANGOS_DLL_DECL boss_temporusAI : public ScriptedAI -{ - boss_temporusAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 Haste_Timer; - uint32 SpellReflection_Timer; - - void Reset() - { - Haste_Timer = 20000; - SpellReflection_Timer = 40000; - } - - void Aggro(Unit *who) - { - DoYell(SAY_AGGRO,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature, SOUND_AGGRO); - } - - void KilledUnit(Unit *victim) - { - switch(rand()%2) - { - case 0: - DoYell(SAY_SLAY1,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature, SOUND_SLAY1); - break; - case 1: - DoYell(SAY_SLAY2,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature, SOUND_SLAY2); - break; - } - } - - void JustDied(Unit *victim) - { - DoYell(SAY_DEATH,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature, SOUND_DEATH); - } - - void MoveInLineOfSight(Unit *who) - { - if (!who || m_creature->getVictim()) - return; - - //Despawn Time Keeper - if (who->GetTypeId() == TYPEID_UNIT) - { - if(((Creature*)who)->GetEntry() == 17918 && m_creature->IsWithinDistInMap(who,20)) - { - //This is the wrong yell & sound for despawning time keepers! - DoYell(SAY_ENTER, LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature, SOUND_ENTER); - - m_creature->DealDamage(who, who->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); - } - } - - if (who->isTargetableForAttack() && who->isInAccessablePlaceFor(m_creature) && m_creature->IsHostileTo(who)) - { - float attackRadius = m_creature->GetAttackDistance(who); - if (m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->GetDistanceZ(who) <= CREATURE_Z_ATTACK_RANGE && m_creature->IsWithinLOSInMap(who)) - { - if(who->HasStealthAura()) - who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); - - DoStartAttackAndMovement(who); - if (!InCombat) - { - DoYell(SAY_AGGRO, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_AGGRO); - } - } - } - } - - void UpdateAI(const uint32 diff) - { - //Return since we have no target - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - //Check if we have a current target - if( m_creature->getVictim() && m_creature->isAlive()) - { - - //Attack Haste - if (Haste_Timer < diff) - { - DoCast(m_creature, SPELL_HASTE); - Haste_Timer = 20000+rand()%5000; - }else Haste_Timer -= diff; - - //Spell Reflection - if (SpellReflection_Timer < diff) - { - DoYell(SAY_BANISH, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_BANISH); - - DoCast(m_creature, SPELL_REFLECT); - SpellReflection_Timer = 40000+rand()%10000; - }else SpellReflection_Timer -= diff; - - DoMeleeAttackIfReady(); - - } - } -}; - -CreatureAI* GetAI_boss_temporus(Creature *_Creature) -{ - return new boss_temporusAI (_Creature); -} - -void AddSC_boss_temporus() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_temporus"; - newscript->GetAI = GetAI_boss_temporus; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Temporus +SD%Complete: 100 +SDComment: +SDCategory: Caverns of Time, The Dark Portal +EndScriptData */ + +#include "precompiled.h" + +#define SPELL_TAUNT 355 +#define SPELL_HASTE 31458 +#define SPELL_MORTAL_WOUND 28467 +#define SPELL_REFLECT 23920 //Not Implemented (Heroic mod) + +#define SAY_ENTER "Why do you persist? Surely you can see the futility of it all. It is not too late! You may still leave with your lives ..." +#define SAY_AGGRO "So be it ... you have been warned." +#define SAY_BANISH "Time... sands of time is run out for you." +#define SAY_SLAY1 "You should have left when you had the chance." +#define SAY_SLAY2 "Your days are done." +#define SAY_DEATH "My death means ... little." + +#define SOUND_ENTER 10442 +#define SOUND_AGGRO 10444 +#define SOUND_BANISH 10443 +#define SOUND_SLAY1 10445 +#define SOUND_SLAY2 10446 +#define SOUND_DEATH 10447 + +struct MANGOS_DLL_DECL boss_temporusAI : public ScriptedAI +{ + boss_temporusAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 Haste_Timer; + uint32 SpellReflection_Timer; + + void Reset() + { + Haste_Timer = 20000; + SpellReflection_Timer = 40000; + } + + void Aggro(Unit *who) + { + DoYell(SAY_AGGRO,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature, SOUND_AGGRO); + } + + void KilledUnit(Unit *victim) + { + switch(rand()%2) + { + case 0: + DoYell(SAY_SLAY1,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature, SOUND_SLAY1); + break; + case 1: + DoYell(SAY_SLAY2,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature, SOUND_SLAY2); + break; + } + } + + void JustDied(Unit *victim) + { + DoYell(SAY_DEATH,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature, SOUND_DEATH); + } + + void MoveInLineOfSight(Unit *who) + { + if (!who || m_creature->getVictim()) + return; + + //Despawn Time Keeper + if (who->GetTypeId() == TYPEID_UNIT) + { + if(((Creature*)who)->GetEntry() == 17918 && m_creature->IsWithinDistInMap(who,20)) + { + //This is the wrong yell & sound for despawning time keepers! + DoYell(SAY_ENTER, LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature, SOUND_ENTER); + + m_creature->DealDamage(who, who->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); + } + } + + if (!m_creature->getVictim() && who->isTargetableForAttack() && who->isInAccessablePlaceFor(m_creature) && m_creature->IsHostileTo(who)) + { + if (!m_creature->canFly() && m_creature->GetDistanceZ(who) > CREATURE_Z_ATTACK_RANGE) + return; + + float attackRadius = m_creature->GetAttackDistance(who); + if (m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->IsWithinLOSInMap(who)) + { + if(who->HasStealthAura()) + who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); + + DoStartAttackAndMovement(who); + if (!InCombat) + { + DoYell(SAY_AGGRO, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_AGGRO); + } + } + } + } + + void UpdateAI(const uint32 diff) + { + //Return since we have no target + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + //Check if we have a current target + if( m_creature->getVictim() && m_creature->isAlive()) + { + + //Attack Haste + if (Haste_Timer < diff) + { + DoCast(m_creature, SPELL_HASTE); + Haste_Timer = 20000+rand()%5000; + }else Haste_Timer -= diff; + + //Spell Reflection + if (SpellReflection_Timer < diff) + { + DoYell(SAY_BANISH, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_BANISH); + + DoCast(m_creature, SPELL_REFLECT); + SpellReflection_Timer = 40000+rand()%10000; + }else SpellReflection_Timer -= diff; + + DoMeleeAttackIfReady(); + + } + } +}; + +CreatureAI* GetAI_boss_temporus(Creature *_Creature) +{ + return new boss_temporusAI (_Creature); +} + +void AddSC_boss_temporus() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_temporus"; + newscript->GetAI = GetAI_boss_temporus; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/caverns_of_time/hyjal/boss_archimonde.cpp b/src/bindings/scripts/scripts/zone/caverns_of_time/hyjal/boss_archimonde.cpp index d6e24a30a9a..686c4557768 100644 --- a/src/bindings/scripts/scripts/zone/caverns_of_time/hyjal/boss_archimonde.cpp +++ b/src/bindings/scripts/scripts/zone/caverns_of_time/hyjal/boss_archimonde.cpp @@ -1,788 +1,788 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Archimonde -SD%Complete: 95 -SDComment: Doomfires not completely offlike due to core limitations for random moving. -SDCategory: Caverns of Time, Mount Hyjal -EndScriptData */ - -#include "precompiled.h" -#include "def_hyjal.h" -#include "SpellAuras.h" - -#define SPELL_DENOUEMENT_WISP 32124 -#define SPELL_ANCIENT_SPARK 39349 -#define SPELL_PROTECTION_OF_ELUNE 38528 - -#define SPELL_DRAIN_WORLD_TREE 39140 -#define SPELL_DRAIN_WORLD_TREE_2 39141 - -#define SPELL_FINGER_OF_DEATH 31984 -#define SPELL_HAND_OF_DEATH 35354 -#define SPELL_AIR_BURST 32014 -#define SPELL_GRIP_OF_THE_LEGION 31972 -#define SPELL_DOOMFIRE_SPAWN 32074 -#define SPELL_DOOMFIRE_VISUAL 42344 // This is actually a Zul'Aman spell, but the proper Doomfire spell sometimes freezes the server if a player stands in it for too long -#define SPELL_DOOMFIRE_DAMAGE 31944 -#define SPELL_SOUL_CHARGE_YELLOW 32045 -#define SPELL_SOUL_CHARGE_GREEN 32051 -#define SPELL_SOUL_CHARGE_RED 32052 -#define SPELL_UNLEASH_SOUL_YELLOW 32054 -#define SPELL_UNLEASH_SOUL_GREEN 32057 -#define SPELL_UNLEASH_SOUL_RED 32053 -#define SPELL_FEAR 31970 - -#define SAY_AGGRO "Your resistance is insignificant!" -#define SOUND_AGGRO 10987 - -#define SAY_DOOMFIRE1 "This world will burn!" -#define SOUND_DOOMFIRE1 10990 - -#define SAY_DOOMFIRE2 "Manach sheek-thrish!" -#define SOUND_DOOMFIRE2 11041 - -#define SAY_AIR_BURST "A-kreesh!" -#define SOUND_AIR_BURST 10989 - -#define SAY_AIR_BURST2 "Away vermin!" -#define SOUND_AIR_BURST2 11043 - -#define SAY_SLAY1 "All creation will be devoured!" -#define SOUND_SLAY1 11044 - -#define SAY_SLAY2 "Your soul will languish for eternity." -#define SOUND_SLAY2 10991 - -#define SAY_SLAY3 "I am the coming of the end!" -#define SOUND_SLAY3 11045 - -#define SAY_UNK1 "You are mine now." -#define SOUND_UNK1 10988 - -#define SAY_UNK2 "Bow to my will." -#define SOUND_UNK2 11042 - -#define SAY_ENRAGE "At last it is here. Mourn and lament the passing of all you have ever known and all that would have been! Akmin-kurai!" -#define SOUND_ENRAGE 10993 - -#define SAY_DEATH "No, it cannot be! Nooo!" -#define SOUND_DEATH 10992 - -#define CREATURE_ARCHIMONDE 17968 -#define CREATURE_DOOMFIRE 18095 -#define CREATURE_DOOMFIRE_TARGETING 18104 -#define CREATURE_ANCIENT_WISP 17946 -#define CREATURE_CHANNEL_TARGET 22418 - -#define NORDRASSIL_X 5503.713 -#define NORDRASSIL_Y -3523.436 -#define NORDRASSIL_Z 1608.781 - -struct mob_ancient_wispAI : public ScriptedAI -{ - mob_ancient_wispAI(Creature* c) : ScriptedAI(c) - { - pInstance = ((ScriptedInstance*)c->GetInstanceData()); - Reset(); - } - - ScriptedInstance* pInstance; - uint64 ArchimondeGUID; - uint32 CheckTimer; - - void Reset() - { - ArchimondeGUID = 0; - CheckTimer = 1000; - - m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); - } - - void Aggro(Unit* who) {} - - void DamageTaken(Unit* done_by, uint32 &damage) { damage = 0; } - - void UpdateAI(const uint32 diff) - { - if(!ArchimondeGUID) - { - if(pInstance) - ArchimondeGUID = pInstance->GetData64(DATA_ARCHIMONDE); - } - - if(CheckTimer < diff) - { - if(ArchimondeGUID) - { - Unit* Archimonde = Unit::GetUnit((*m_creature), ArchimondeGUID); - if(Archimonde) - { - if((((Archimonde->GetHealth()*100) / Archimonde->GetMaxHealth()) < 2) || !Archimonde->isAlive()) - DoCast(m_creature, SPELL_DENOUEMENT_WISP); - else - DoCast(Archimonde, SPELL_ANCIENT_SPARK); - } - } - CheckTimer = 1000; - }else CheckTimer -= diff; - } -}; - -/* This script controls the Doomfire mob. Unlike the other Doomfire mob, this one does not stalk players. - Instead, this doomfire will simply stand in one place after spawning and deal damage to any players that - are within 3 yards. Another creature called Doomfire Targetting spawns this creature as well as stalks. */ -struct MANGOS_DLL_DECL mob_doomfireAI : public ScriptedAI -{ - mob_doomfireAI(Creature* c) : ScriptedAI(c) - { - Reset(); - } - - uint32 CheckTimer; - uint32 RefreshTimer; - - bool TargetSelected; - - uint64 ArchimondeGUID; - uint64 TargetGUID; - - void Reset() - { - CheckTimer = 5000; - RefreshTimer = 0; - - TargetSelected = false; - - ArchimondeGUID = 0; - TargetGUID = 0; - } - - void DamageTaken(Unit *done_by, uint32 &damage) { damage = 0; } - - void Aggro(Unit* who) { } - - void MoveInLineOfSight(Unit* who) - { - // Do not do anything if who does not exist, or we are refreshing our timer, or who is Doomfire, Archimonde or Doomfire targetting - if(!who || who == m_creature || RefreshTimer || who->GetEntry() == CREATURE_ANCIENT_WISP || - who->GetEntry() == CREATURE_ARCHIMONDE || who->GetEntry() == CREATURE_DOOMFIRE || - who->GetEntry() == CREATURE_DOOMFIRE_TARGETING || !who->isTargetableForAttack()) - return; - - if(m_creature->IsWithinDistInMap(who, 3)) - { - TargetSelected = true; - TargetGUID = who->GetGUID(); - RefreshTimer = 2000; - } - } - - void KilledUnit(Unit* victim) - { - bool suicide = true; - if(ArchimondeGUID) - { - Creature* Archimonde = ((Creature*)Unit::GetUnit((*m_creature), ArchimondeGUID)); - if(Archimonde && Archimonde->isAlive()) - { - suicide = false; - Archimonde->AI()->KilledUnit(victim); - } - } - - if(suicide) - m_creature->DealDamage(m_creature, m_creature->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); - } - - void UpdateAI(const uint32 diff) - { - if(RefreshTimer < diff) - RefreshTimer = 0; - else RefreshTimer -= diff; - - if(TargetSelected && TargetGUID) - { - Unit* target = Unit::GetUnit((*m_creature), TargetGUID); - if(target && target->isAlive()) - { - target->CastSpell(target, SPELL_DOOMFIRE_DAMAGE, true); - TargetGUID = 0; - TargetSelected = false; - } - } - - if(CheckTimer < diff) - { - if(ArchimondeGUID) - { - Unit* Archimonde = Unit::GetUnit((*m_creature), ArchimondeGUID); - if(!Archimonde || !Archimonde->isAlive()) - m_creature->DealDamage(m_creature, m_creature->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); - CheckTimer = 5000; - } - else m_creature->DealDamage(m_creature, m_creature->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); - }else CheckTimer -= diff; - } -}; - -/* This is the script for the Doomfire Targetting Mob. This mob simply follows players and/or travels in random directions and spawns the actual Doomfire which does damage to anyone that moves close. */ -struct MANGOS_DLL_DECL mob_doomfire_targettingAI : public ScriptedAI -{ - mob_doomfire_targettingAI(Creature* c) : ScriptedAI(c) - { - Reset(); - } - - uint32 ChangeTargetTimer; - uint32 SummonTimer; // This timer will serve as both a summon timer for the doomfire that does damage as well as to check on Archionde - - uint64 ArchimondeGUID; - - void Reset() - { - ChangeTargetTimer = 5000; - SummonTimer = 1000; - - ArchimondeGUID = 0; - } - - void Aggro(Unit* who) {} - - void MoveInLineOfSight(Unit* who) - { - // Do not do anything if who does not exist, or who is Doomfire, Archimonde or Doomfire targetting - if(!who || who == m_creature || who->GetEntry() == CREATURE_ARCHIMONDE - || who->GetEntry() == CREATURE_DOOMFIRE || who->GetEntry() == CREATURE_DOOMFIRE_TARGETING || !who->isTargetableForAttack()) - return; - - m_creature->AddThreat(who, 1.0f); - } - - void DamageTaken(Unit *done_by, uint32 &damage) { damage = 0; } - - void UpdateAI(const uint32 diff) - { - if(!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - if(SummonTimer < diff) - { - if(ArchimondeGUID) - { - Unit* Archimonde = Unit::GetUnit((*m_creature), ArchimondeGUID); - if(Archimonde && Archimonde->isAlive()) - { - Creature* Doomfire = DoSpawnCreature(CREATURE_DOOMFIRE, 0, 0, 2, 0, TEMPSUMMON_TIMED_DESPAWN, 30000); - if(Doomfire) - { - Doomfire->CastSpell(Doomfire, SPELL_DOOMFIRE_VISUAL, true); - ((mob_doomfireAI*)Doomfire->AI())->ArchimondeGUID = ArchimondeGUID; - Doomfire->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - } - SummonTimer = 500; - } - else - m_creature->DealDamage(m_creature, m_creature->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); - } - else - m_creature->DealDamage(m_creature, m_creature->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); - }else SummonTimer -= diff; - - if(ChangeTargetTimer < diff) - { - Unit* target = NULL; - switch(rand()%2) - { - case 0: // stalk player - target = SelectUnit(SELECT_TARGET_RANDOM, 1); - if(target && target->isAlive()) - { - m_creature->AddThreat(target, m_creature->getThreatManager().getThreat(m_creature->getVictim())); - m_creature->GetMotionMaster()->MoveChase(target); - } - break; - - case 1: // random location - float x = 0; - float y = 0; - float z = 0; - m_creature->GetRandomPoint(m_creature->GetPositionX(), m_creature->GetPositionY(), m_creature->GetPositionZ(), 40, x, y, z); - m_creature->GetMotionMaster()->MovePoint(0, x, y, z); - break; - } - ChangeTargetTimer = 5000; - }else ChangeTargetTimer -= diff; - } - -}; - -/* Finally, Archimonde's script. His script isn't extremely complex, most are simply spells on timers. - The only complicated aspect of the battle is Finger of Death and Doomfire, with Doomfire being the - hardest bit to code. Finger of Death is simply a distance check - if no one is in melee range, then - select a random target and cast the spell on them. However, if someone IS in melee range, and this - is NOT the main tank (creature's victim), then we aggro that player and they become the new victim. - For Doomfire, we summon a mob (Doomfire Targetting) that summons another mob (Doomfire every second) - Doomfire Targetting 'stalks' players whilst Doomfire damages player that are within range. */ - -// This is used to sort by distance in order to see who is the closest target, when checking for Finger of Death -struct TargetDistanceOrder : public std::binary_function -{ - const Unit* MainTarget; - TargetDistanceOrder(const Unit* Target) : MainTarget(Target) {}; - // functor for operator "<" - bool operator()(const Unit* _Left, const Unit* _Right) const - { - return (MainTarget->GetDistance(_Left) < MainTarget->GetDistance(_Right)); - } -}; - -struct MANGOS_DLL_DECL boss_archimondeAI : public ScriptedAI -{ - boss_archimondeAI(Creature *c) : ScriptedAI(c) - { - pInstance = ((ScriptedInstance*)c->GetInstanceData()); - Reset(); - } - - ScriptedInstance* pInstance; - - uint32 DrainNordrassilTimer; - uint32 FearTimer; - uint32 AirBurstTimer; - uint32 GripOfTheLegionTimer; - uint32 DoomfireTimer; - uint32 SoulChargeTimer; - uint32 SoulChargeCount; - uint32 MeleeRangeCheckTimer; - uint32 HandOfDeathTimer; - uint32 SummonWispTimer; - uint32 WispCount; - uint32 EnrageTimer; - uint32 CheckDistanceTimer; - - bool Enraged; - bool BelowTenPercent; - bool HasProtected; - bool IsChanneling; - - void Reset() - { - if(pInstance) - pInstance->SetData(DATA_ARCHIMONDEEVENT, NOT_STARTED); - - DrainNordrassilTimer = 0; - FearTimer = 40000; - AirBurstTimer = 30000; - GripOfTheLegionTimer = 5000 + rand()%20000; - DoomfireTimer = 20000; - SoulChargeTimer = 2000 + rand()%27000; - SoulChargeCount = 0; - MeleeRangeCheckTimer = 15000; - HandOfDeathTimer = 2000; - WispCount = 0; // When ~30 wisps are summoned, Archimonde dies - EnrageTimer = 600000; // 10 minutes - CheckDistanceTimer = 30000; // This checks if he's too close to the World Tree (75 yards from a point on the tree), if true then he will enrage - - Enraged = false; - BelowTenPercent = false; - HasProtected = false; - IsChanneling = false; - } - - void Aggro(Unit *who) - { - m_creature->InterruptSpell(CURRENT_CHANNELED_SPELL); - DoYell(SAY_AGGRO,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature, SOUND_AGGRO); - DoZoneInCombat(); - - if(pInstance) - pInstance->SetData(DATA_ARCHIMONDEEVENT, IN_PROGRESS); - } - - void KilledUnit(Unit *victim) - { - switch(rand()%2) - { - case 0: - DoYell(SAY_SLAY1,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature, SOUND_SLAY1); - break; - case 1: - DoYell(SAY_SLAY2,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature, SOUND_SLAY2); - break; - case 2: - DoYell(SAY_SLAY3,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature, SOUND_SLAY3); - break; - } - - if(victim && (victim->GetTypeId() == TYPEID_PLAYER)) - GainSoulCharge(((Player*)victim)); - } - - void GainSoulCharge(Player* victim) - { - switch(victim->getClass()) - { - case CLASS_PRIEST: - case CLASS_PALADIN: - case CLASS_WARLOCK: - victim->CastSpell(m_creature, SPELL_SOUL_CHARGE_RED, true); - break; - case CLASS_MAGE: - case CLASS_ROGUE: - case CLASS_WARRIOR: - victim->CastSpell(m_creature, SPELL_SOUL_CHARGE_YELLOW, true); - break; - case CLASS_DRUID: - case CLASS_SHAMAN: - case CLASS_HUNTER: - victim->CastSpell(m_creature, SPELL_SOUL_CHARGE_GREEN, true); - break; - } - - SoulChargeTimer = 2000 + rand()%28000; - ++SoulChargeCount; - } - - void JustDied(Unit *victim) - { - DoYell(SAY_DEATH, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature,SOUND_DEATH); - - if(pInstance) - pInstance->SetData(DATA_ARCHIMONDEEVENT, DONE); - } - - bool CanUseFingerOfDeath() - { - // First we check if our current victim is in melee range or not. - Unit* victim = m_creature->getVictim(); - if(victim && m_creature->IsWithinDistInMap(victim, m_creature->GetAttackDistance(victim))) - return false; - - std::list& m_threatlist = m_creature->getThreatManager().getThreatList(); - if(m_threatlist.empty()) - return false; - - std::list targets; - std::list::iterator itr = m_threatlist.begin(); - for( ; itr != m_threatlist.end(); ++itr) - { - Unit* pUnit = Unit::GetUnit((*m_creature), (*itr)->getUnitGuid()); - if(pUnit && pUnit->isAlive()) - targets.push_back(pUnit); - } - - if(targets.empty()) - return false; - - targets.sort(TargetDistanceOrder(m_creature)); - Unit* target = targets.front(); - if(target) - { - if(!m_creature->IsWithinDistInMap(target, m_creature->GetAttackDistance(target))) - return true; // Cast Finger of Death - else // This target is closest, he is our new tank - m_creature->AddThreat(target, m_creature->getThreatManager().getThreat(m_creature->getVictim())); - } - - return false; - } - - void SummonDoomfire(Unit* target) - { - Creature* Doomfire = DoSpawnCreature(CREATURE_DOOMFIRE_TARGETING, rand()%30, rand()%30, 0, 0, TEMPSUMMON_TIMED_DESPAWN, 30000); - if(Doomfire) - { - ((mob_doomfire_targettingAI*)Doomfire->AI())->ArchimondeGUID = m_creature->GetGUID(); - Doomfire->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - // Give Doomfire a taste of everyone in the threatlist = more targets to chase. - std::list::iterator itr; - for(itr = m_creature->getThreatManager().getThreatList().begin(); itr != m_creature->getThreatManager().getThreatList().end(); ++itr) - Doomfire->AddThreat(Unit::GetUnit(*m_creature, (*itr)->getUnitGuid()), 1.0f); - Doomfire->setFaction(m_creature->getFaction()); - DoCast(Doomfire, SPELL_DOOMFIRE_SPAWN); - Doomfire->CastSpell(Doomfire, SPELL_DOOMFIRE_VISUAL, true); - if(target) - Doomfire->AI()->AttackStart(target); - - if(rand()%2 == 0) - { - DoYell(SAY_DOOMFIRE1, LANG_UNIVERSAL, m_creature); - DoPlaySoundToSet(m_creature, SOUND_DOOMFIRE1); - }else - { - DoYell(SAY_DOOMFIRE2, LANG_UNIVERSAL, m_creature); - DoPlaySoundToSet(m_creature, SOUND_DOOMFIRE2); - } - } - } - - void UnleashSoulCharge() - { - m_creature->InterruptNonMeleeSpells(false); - bool HasCast = false; - uint32 chargeSpell = 0; - uint32 unleashSpell = 0; - switch(rand()%3) - { - case 0: - chargeSpell = SPELL_SOUL_CHARGE_RED; - unleashSpell = SPELL_UNLEASH_SOUL_RED; - break; - case 1: - chargeSpell = SPELL_SOUL_CHARGE_YELLOW; - unleashSpell = SPELL_UNLEASH_SOUL_YELLOW; - break; - case 2: - chargeSpell = SPELL_SOUL_CHARGE_GREEN; - unleashSpell = SPELL_UNLEASH_SOUL_GREEN; - break; - } - if(m_creature->HasAura(chargeSpell, 0)) - { - m_creature->RemoveSingleAuraFromStack(chargeSpell, 0); - DoCast(m_creature->getVictim(), unleashSpell); - HasCast = true; - SoulChargeCount--; - } - if(HasCast) - SoulChargeTimer = 2000 + rand()%28000; - } - - void UpdateAI(const uint32 diff) - { - if(!InCombat) - { - if(pInstance) - { - // Do not let the raid skip straight to Archimonde. Visible and hostile ONLY if Azagalor is finished. - if((pInstance->GetData(DATA_AZGALOREVENT) < DONE) && ((m_creature->GetVisibility() != VISIBILITY_OFF) || (m_creature->getFaction() != 35))) - { - m_creature->SetVisibility(VISIBILITY_OFF); - m_creature->setFaction(35); - } - else if((pInstance->GetData(DATA_AZGALOREVENT) >= DONE) && ((m_creature->GetVisibility() != VISIBILITY_ON) || (m_creature->getFaction() == 35))) - { - m_creature->setFaction(1720); - m_creature->SetVisibility(VISIBILITY_ON); - } - } - - if(DrainNordrassilTimer < diff) - { - if(!IsChanneling) - { - Creature* Nordrassil = m_creature->SummonCreature(CREATURE_CHANNEL_TARGET, NORDRASSIL_X, NORDRASSIL_Y, NORDRASSIL_Z, 0, TEMPSUMMON_TIMED_DESPAWN, 1200000); - if(Nordrassil) - { - Nordrassil->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - Nordrassil->SetUInt32Value(UNIT_FIELD_DISPLAYID, 11686); - DoCast(Nordrassil, SPELL_DRAIN_WORLD_TREE); - IsChanneling = true; - } - } - Creature* Nordrassil = m_creature->SummonCreature(CREATURE_CHANNEL_TARGET, NORDRASSIL_X, NORDRASSIL_Y, NORDRASSIL_Z, 0, TEMPSUMMON_TIMED_DESPAWN, 5000); - if(Nordrassil) - { - Nordrassil->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - Nordrassil->SetUInt32Value(UNIT_FIELD_DISPLAYID, 11686); - Nordrassil->CastSpell(m_creature, SPELL_DRAIN_WORLD_TREE_2, true); - DrainNordrassilTimer = 1000; - } - }else DrainNordrassilTimer -= diff; - } - - if(!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - if(((m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < 10) && !BelowTenPercent && !Enraged) - BelowTenPercent = true; - - if(!Enraged) - { - if(EnrageTimer < diff) - { - if((m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) > 10) - { - m_creature->GetMotionMaster()->Clear(false); - m_creature->GetMotionMaster()->MoveIdle(); - Enraged = true; - DoYell(SAY_ENRAGE, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_ENRAGE); - } - }else EnrageTimer -= diff; - - if(CheckDistanceTimer < diff) - { // To simplify the check, we simply summon a creature in the location and then check how far we are from the creature - Creature* Check = m_creature->SummonCreature(CREATURE_CHANNEL_TARGET, NORDRASSIL_X, NORDRASSIL_Y, NORDRASSIL_Z, 0, TEMPSUMMON_TIMED_DESPAWN, 2000); - if(Check) - { - Check->SetVisibility(VISIBILITY_OFF); - if(m_creature->IsWithinDistInMap(Check, 75)) - { - m_creature->GetMotionMaster()->Clear(false); - m_creature->GetMotionMaster()->MoveIdle(); - Enraged = true; - DoYell(SAY_ENRAGE, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_ENRAGE); - } - } - CheckDistanceTimer = 5000; - }else CheckDistanceTimer -= diff; - } - - if(BelowTenPercent) - { - if(!HasProtected) - { - m_creature->GetMotionMaster()->Clear(false); - m_creature->GetMotionMaster()->MoveIdle(); - DoCast(m_creature->getVictim(), SPELL_PROTECTION_OF_ELUNE); - HasProtected = true; - Enraged = true; - } - - if(SummonWispTimer < diff) - { - Creature* Wisp = DoSpawnCreature(CREATURE_ANCIENT_WISP, rand()%40, rand()%40, 0, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000); - if(Wisp) - { - Wisp->AI()->AttackStart(m_creature); - ((mob_ancient_wispAI*)Wisp->AI())->ArchimondeGUID = m_creature->GetGUID(); - } - SummonWispTimer = 1500; - ++WispCount; - }else SummonWispTimer -= diff; - - if(WispCount >= 30) - m_creature->DealDamage(m_creature, m_creature->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); - } - - if(Enraged) - { - if(HandOfDeathTimer < diff) - { - DoCast(m_creature->getVictim(), SPELL_HAND_OF_DEATH); - HandOfDeathTimer = 2000; - }else HandOfDeathTimer -= diff; - return; // Don't do anything after this point. - } - - if(SoulChargeCount) - { - if(SoulChargeTimer < diff) - UnleashSoulCharge(); - else SoulChargeTimer -= diff; - } - - if(GripOfTheLegionTimer < diff) - { - DoCast(SelectUnit(SELECT_TARGET_RANDOM, 0), SPELL_GRIP_OF_THE_LEGION); - GripOfTheLegionTimer = 5000 + rand()%20000; - }else GripOfTheLegionTimer -= diff; - - if(AirBurstTimer < diff) - { - if(rand()%2 == 0) - { - DoYell(SAY_AIR_BURST, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_AIR_BURST); - }else - { - DoYell(SAY_AIR_BURST2, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_AIR_BURST2); - } - - DoCast(SelectUnit(SELECT_TARGET_RANDOM, 0), SPELL_AIR_BURST); - AirBurstTimer = 25000 + rand()%15000; - }else AirBurstTimer -= diff; - - if(FearTimer < diff) - { - DoCast(m_creature->getVictim(), SPELL_FEAR); - FearTimer = 40000; - }else FearTimer -= diff; - - if(DoomfireTimer < diff) - { - SummonDoomfire(SelectUnit(SELECT_TARGET_RANDOM, 1)); - DoomfireTimer = 40000; - }else DoomfireTimer -= diff; - - if(MeleeRangeCheckTimer < diff) - { - if(CanUseFingerOfDeath()) - { - DoCast(SelectUnit(SELECT_TARGET_RANDOM, 0), SPELL_FINGER_OF_DEATH); - MeleeRangeCheckTimer = 1000; - } - - MeleeRangeCheckTimer = 5000; - }else MeleeRangeCheckTimer -= diff; - - DoMeleeAttackIfReady(); - } -}; - -CreatureAI* GetAI_boss_archimonde(Creature *_Creature) -{ - return new boss_archimondeAI (_Creature); -} - -CreatureAI* GetAI_mob_doomfire(Creature* _Creature) -{ - return new mob_doomfireAI(_Creature); -} - -CreatureAI* GetAI_mob_doomfire_targetting(Creature* _Creature) -{ - return new mob_doomfire_targettingAI(_Creature); -} - -CreatureAI* GetAI_mob_ancient_wisp(Creature* _Creature) -{ - return new mob_ancient_wispAI(_Creature); -} - -void AddSC_boss_archimonde() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_archimonde"; - newscript->GetAI = GetAI_boss_archimonde; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name = "mob_doomfire"; - newscript->GetAI = GetAI_mob_doomfire; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name = "mob_doomfire_targetting"; - newscript->GetAI = GetAI_mob_doomfire_targetting; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name = "mob_ancient_wisp"; - newscript->GetAI = GetAI_mob_ancient_wisp; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Archimonde +SD%Complete: 95 +SDComment: Doomfires not completely offlike due to core limitations for random moving. +SDCategory: Caverns of Time, Mount Hyjal +EndScriptData */ + +#include "precompiled.h" +#include "def_hyjal.h" +#include "SpellAuras.h" + +#define SPELL_DENOUEMENT_WISP 32124 +#define SPELL_ANCIENT_SPARK 39349 +#define SPELL_PROTECTION_OF_ELUNE 38528 + +#define SPELL_DRAIN_WORLD_TREE 39140 +#define SPELL_DRAIN_WORLD_TREE_2 39141 + +#define SPELL_FINGER_OF_DEATH 31984 +#define SPELL_HAND_OF_DEATH 35354 +#define SPELL_AIR_BURST 32014 +#define SPELL_GRIP_OF_THE_LEGION 31972 +#define SPELL_DOOMFIRE_SPAWN 32074 +#define SPELL_DOOMFIRE_VISUAL 42344 // This is actually a Zul'Aman spell, but the proper Doomfire spell sometimes freezes the server if a player stands in it for too long +#define SPELL_DOOMFIRE_DAMAGE 31944 +#define SPELL_SOUL_CHARGE_YELLOW 32045 +#define SPELL_SOUL_CHARGE_GREEN 32051 +#define SPELL_SOUL_CHARGE_RED 32052 +#define SPELL_UNLEASH_SOUL_YELLOW 32054 +#define SPELL_UNLEASH_SOUL_GREEN 32057 +#define SPELL_UNLEASH_SOUL_RED 32053 +#define SPELL_FEAR 31970 + +#define SAY_AGGRO "Your resistance is insignificant!" +#define SOUND_AGGRO 10987 + +#define SAY_DOOMFIRE1 "This world will burn!" +#define SOUND_DOOMFIRE1 10990 + +#define SAY_DOOMFIRE2 "Manach sheek-thrish!" +#define SOUND_DOOMFIRE2 11041 + +#define SAY_AIR_BURST "A-kreesh!" +#define SOUND_AIR_BURST 10989 + +#define SAY_AIR_BURST2 "Away vermin!" +#define SOUND_AIR_BURST2 11043 + +#define SAY_SLAY1 "All creation will be devoured!" +#define SOUND_SLAY1 11044 + +#define SAY_SLAY2 "Your soul will languish for eternity." +#define SOUND_SLAY2 10991 + +#define SAY_SLAY3 "I am the coming of the end!" +#define SOUND_SLAY3 11045 + +#define SAY_UNK1 "You are mine now." +#define SOUND_UNK1 10988 + +#define SAY_UNK2 "Bow to my will." +#define SOUND_UNK2 11042 + +#define SAY_ENRAGE "At last it is here. Mourn and lament the passing of all you have ever known and all that would have been! Akmin-kurai!" +#define SOUND_ENRAGE 10993 + +#define SAY_DEATH "No, it cannot be! Nooo!" +#define SOUND_DEATH 10992 + +#define CREATURE_ARCHIMONDE 17968 +#define CREATURE_DOOMFIRE 18095 +#define CREATURE_DOOMFIRE_TARGETING 18104 +#define CREATURE_ANCIENT_WISP 17946 +#define CREATURE_CHANNEL_TARGET 22418 + +#define NORDRASSIL_X 5503.713 +#define NORDRASSIL_Y -3523.436 +#define NORDRASSIL_Z 1608.781 + +struct mob_ancient_wispAI : public ScriptedAI +{ + mob_ancient_wispAI(Creature* c) : ScriptedAI(c) + { + pInstance = ((ScriptedInstance*)c->GetInstanceData()); + Reset(); + } + + ScriptedInstance* pInstance; + uint64 ArchimondeGUID; + uint32 CheckTimer; + + void Reset() + { + ArchimondeGUID = 0; + CheckTimer = 1000; + + m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + } + + void Aggro(Unit* who) {} + + void DamageTaken(Unit* done_by, uint32 &damage) { damage = 0; } + + void UpdateAI(const uint32 diff) + { + if(!ArchimondeGUID) + { + if(pInstance) + ArchimondeGUID = pInstance->GetData64(DATA_ARCHIMONDE); + } + + if(CheckTimer < diff) + { + if(ArchimondeGUID) + { + Unit* Archimonde = Unit::GetUnit((*m_creature), ArchimondeGUID); + if(Archimonde) + { + if((((Archimonde->GetHealth()*100) / Archimonde->GetMaxHealth()) < 2) || !Archimonde->isAlive()) + DoCast(m_creature, SPELL_DENOUEMENT_WISP); + else + DoCast(Archimonde, SPELL_ANCIENT_SPARK); + } + } + CheckTimer = 1000; + }else CheckTimer -= diff; + } +}; + +/* This script controls the Doomfire mob. Unlike the other Doomfire mob, this one does not stalk players. + Instead, this doomfire will simply stand in one place after spawning and deal damage to any players that + are within 3 yards. Another creature called Doomfire Targetting spawns this creature as well as stalks. */ +struct MANGOS_DLL_DECL mob_doomfireAI : public ScriptedAI +{ + mob_doomfireAI(Creature* c) : ScriptedAI(c) + { + Reset(); + } + + uint32 CheckTimer; + uint32 RefreshTimer; + + bool TargetSelected; + + uint64 ArchimondeGUID; + uint64 TargetGUID; + + void Reset() + { + CheckTimer = 5000; + RefreshTimer = 0; + + TargetSelected = false; + + ArchimondeGUID = 0; + TargetGUID = 0; + } + + void DamageTaken(Unit *done_by, uint32 &damage) { damage = 0; } + + void Aggro(Unit* who) { } + + void MoveInLineOfSight(Unit* who) + { + // Do not do anything if who does not exist, or we are refreshing our timer, or who is Doomfire, Archimonde or Doomfire targetting + if(!who || who == m_creature || RefreshTimer || who->GetEntry() == CREATURE_ANCIENT_WISP || + who->GetEntry() == CREATURE_ARCHIMONDE || who->GetEntry() == CREATURE_DOOMFIRE || + who->GetEntry() == CREATURE_DOOMFIRE_TARGETING || !who->isTargetableForAttack()) + return; + + if(m_creature->IsWithinDistInMap(who, 3)) + { + TargetSelected = true; + TargetGUID = who->GetGUID(); + RefreshTimer = 2000; + } + } + + void KilledUnit(Unit* victim) + { + bool suicide = true; + if(ArchimondeGUID) + { + Creature* Archimonde = ((Creature*)Unit::GetUnit((*m_creature), ArchimondeGUID)); + if(Archimonde && Archimonde->isAlive()) + { + suicide = false; + Archimonde->AI()->KilledUnit(victim); + } + } + + if(suicide) + m_creature->DealDamage(m_creature, m_creature->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); + } + + void UpdateAI(const uint32 diff) + { + if(RefreshTimer < diff) + RefreshTimer = 0; + else RefreshTimer -= diff; + + if(TargetSelected && TargetGUID) + { + Unit* target = Unit::GetUnit((*m_creature), TargetGUID); + if(target && target->isAlive()) + { + target->CastSpell(target, SPELL_DOOMFIRE_DAMAGE, true); + TargetGUID = 0; + TargetSelected = false; + } + } + + if(CheckTimer < diff) + { + if(ArchimondeGUID) + { + Unit* Archimonde = Unit::GetUnit((*m_creature), ArchimondeGUID); + if(!Archimonde || !Archimonde->isAlive()) + m_creature->DealDamage(m_creature, m_creature->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); + CheckTimer = 5000; + } + else m_creature->DealDamage(m_creature, m_creature->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); + }else CheckTimer -= diff; + } +}; + +/* This is the script for the Doomfire Targetting Mob. This mob simply follows players and/or travels in random directions and spawns the actual Doomfire which does damage to anyone that moves close. */ +struct MANGOS_DLL_DECL mob_doomfire_targettingAI : public ScriptedAI +{ + mob_doomfire_targettingAI(Creature* c) : ScriptedAI(c) + { + Reset(); + } + + uint32 ChangeTargetTimer; + uint32 SummonTimer; // This timer will serve as both a summon timer for the doomfire that does damage as well as to check on Archionde + + uint64 ArchimondeGUID; + + void Reset() + { + ChangeTargetTimer = 5000; + SummonTimer = 1000; + + ArchimondeGUID = 0; + } + + void Aggro(Unit* who) {} + + void MoveInLineOfSight(Unit* who) + { + // Do not do anything if who does not exist, or who is Doomfire, Archimonde or Doomfire targetting + if(!who || who == m_creature || who->GetEntry() == CREATURE_ARCHIMONDE + || who->GetEntry() == CREATURE_DOOMFIRE || who->GetEntry() == CREATURE_DOOMFIRE_TARGETING || !who->isTargetableForAttack()) + return; + + m_creature->AddThreat(who, 1.0f); + } + + void DamageTaken(Unit *done_by, uint32 &damage) { damage = 0; } + + void UpdateAI(const uint32 diff) + { + if(!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + if(SummonTimer < diff) + { + if(ArchimondeGUID) + { + Unit* Archimonde = Unit::GetUnit((*m_creature), ArchimondeGUID); + if(Archimonde && Archimonde->isAlive()) + { + Creature* Doomfire = DoSpawnCreature(CREATURE_DOOMFIRE, 0, 0, 2, 0, TEMPSUMMON_TIMED_DESPAWN, 30000); + if(Doomfire) + { + Doomfire->CastSpell(Doomfire, SPELL_DOOMFIRE_VISUAL, true); + ((mob_doomfireAI*)Doomfire->AI())->ArchimondeGUID = ArchimondeGUID; + Doomfire->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + } + SummonTimer = 500; + } + else + m_creature->DealDamage(m_creature, m_creature->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); + } + else + m_creature->DealDamage(m_creature, m_creature->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); + }else SummonTimer -= diff; + + if(ChangeTargetTimer < diff) + { + Unit* target = NULL; + switch(rand()%2) + { + case 0: // stalk player + target = SelectUnit(SELECT_TARGET_RANDOM, 1); + if(target && target->isAlive()) + { + m_creature->AddThreat(target, m_creature->getThreatManager().getThreat(m_creature->getVictim())); + m_creature->GetMotionMaster()->MoveChase(target); + } + break; + + case 1: // random location + float x = 0; + float y = 0; + float z = 0; + m_creature->GetRandomPoint(m_creature->GetPositionX(), m_creature->GetPositionY(), m_creature->GetPositionZ(), 40, x, y, z); + m_creature->GetMotionMaster()->MovePoint(0, x, y, z); + break; + } + ChangeTargetTimer = 5000; + }else ChangeTargetTimer -= diff; + } + +}; + +/* Finally, Archimonde's script. His script isn't extremely complex, most are simply spells on timers. + The only complicated aspect of the battle is Finger of Death and Doomfire, with Doomfire being the + hardest bit to code. Finger of Death is simply a distance check - if no one is in melee range, then + select a random target and cast the spell on them. However, if someone IS in melee range, and this + is NOT the main tank (creature's victim), then we aggro that player and they become the new victim. + For Doomfire, we summon a mob (Doomfire Targetting) that summons another mob (Doomfire every second) + Doomfire Targetting 'stalks' players whilst Doomfire damages player that are within range. */ + +// This is used to sort by distance in order to see who is the closest target, when checking for Finger of Death +struct TargetDistanceOrder : public std::binary_function +{ + const Unit* MainTarget; + TargetDistanceOrder(const Unit* Target) : MainTarget(Target) {}; + // functor for operator "<" + bool operator()(const Unit* _Left, const Unit* _Right) const + { + return (MainTarget->GetDistance(_Left) < MainTarget->GetDistance(_Right)); + } +}; + +struct MANGOS_DLL_DECL boss_archimondeAI : public ScriptedAI +{ + boss_archimondeAI(Creature *c) : ScriptedAI(c) + { + pInstance = ((ScriptedInstance*)c->GetInstanceData()); + Reset(); + } + + ScriptedInstance* pInstance; + + uint32 DrainNordrassilTimer; + uint32 FearTimer; + uint32 AirBurstTimer; + uint32 GripOfTheLegionTimer; + uint32 DoomfireTimer; + uint32 SoulChargeTimer; + uint32 SoulChargeCount; + uint32 MeleeRangeCheckTimer; + uint32 HandOfDeathTimer; + uint32 SummonWispTimer; + uint32 WispCount; + uint32 EnrageTimer; + uint32 CheckDistanceTimer; + + bool Enraged; + bool BelowTenPercent; + bool HasProtected; + bool IsChanneling; + + void Reset() + { + if(pInstance) + pInstance->SetData(DATA_ARCHIMONDEEVENT, NOT_STARTED); + + DrainNordrassilTimer = 0; + FearTimer = 40000; + AirBurstTimer = 30000; + GripOfTheLegionTimer = 5000 + rand()%20000; + DoomfireTimer = 20000; + SoulChargeTimer = 2000 + rand()%27000; + SoulChargeCount = 0; + MeleeRangeCheckTimer = 15000; + HandOfDeathTimer = 2000; + WispCount = 0; // When ~30 wisps are summoned, Archimonde dies + EnrageTimer = 600000; // 10 minutes + CheckDistanceTimer = 30000; // This checks if he's too close to the World Tree (75 yards from a point on the tree), if true then he will enrage + + Enraged = false; + BelowTenPercent = false; + HasProtected = false; + IsChanneling = false; + } + + void Aggro(Unit *who) + { + m_creature->InterruptSpell(CURRENT_CHANNELED_SPELL); + DoYell(SAY_AGGRO,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature, SOUND_AGGRO); + DoZoneInCombat(); + + if(pInstance) + pInstance->SetData(DATA_ARCHIMONDEEVENT, IN_PROGRESS); + } + + void KilledUnit(Unit *victim) + { + switch(rand()%2) + { + case 0: + DoYell(SAY_SLAY1,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature, SOUND_SLAY1); + break; + case 1: + DoYell(SAY_SLAY2,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature, SOUND_SLAY2); + break; + case 2: + DoYell(SAY_SLAY3,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature, SOUND_SLAY3); + break; + } + + if(victim && (victim->GetTypeId() == TYPEID_PLAYER)) + GainSoulCharge(((Player*)victim)); + } + + void GainSoulCharge(Player* victim) + { + switch(victim->getClass()) + { + case CLASS_PRIEST: + case CLASS_PALADIN: + case CLASS_WARLOCK: + victim->CastSpell(m_creature, SPELL_SOUL_CHARGE_RED, true); + break; + case CLASS_MAGE: + case CLASS_ROGUE: + case CLASS_WARRIOR: + victim->CastSpell(m_creature, SPELL_SOUL_CHARGE_YELLOW, true); + break; + case CLASS_DRUID: + case CLASS_SHAMAN: + case CLASS_HUNTER: + victim->CastSpell(m_creature, SPELL_SOUL_CHARGE_GREEN, true); + break; + } + + SoulChargeTimer = 2000 + rand()%28000; + ++SoulChargeCount; + } + + void JustDied(Unit *victim) + { + DoYell(SAY_DEATH, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature,SOUND_DEATH); + + if(pInstance) + pInstance->SetData(DATA_ARCHIMONDEEVENT, DONE); + } + + bool CanUseFingerOfDeath() + { + // First we check if our current victim is in melee range or not. + Unit* victim = m_creature->getVictim(); + if(victim && m_creature->IsWithinDistInMap(victim, m_creature->GetAttackDistance(victim))) + return false; + + std::list& m_threatlist = m_creature->getThreatManager().getThreatList(); + if(m_threatlist.empty()) + return false; + + std::list targets; + std::list::iterator itr = m_threatlist.begin(); + for( ; itr != m_threatlist.end(); ++itr) + { + Unit* pUnit = Unit::GetUnit((*m_creature), (*itr)->getUnitGuid()); + if(pUnit && pUnit->isAlive()) + targets.push_back(pUnit); + } + + if(targets.empty()) + return false; + + targets.sort(TargetDistanceOrder(m_creature)); + Unit* target = targets.front(); + if(target) + { + if(!m_creature->IsWithinDistInMap(target, m_creature->GetAttackDistance(target))) + return true; // Cast Finger of Death + else // This target is closest, he is our new tank + m_creature->AddThreat(target, m_creature->getThreatManager().getThreat(m_creature->getVictim())); + } + + return false; + } + + void SummonDoomfire(Unit* target) + { + Creature* Doomfire = DoSpawnCreature(CREATURE_DOOMFIRE_TARGETING, rand()%30, rand()%30, 0, 0, TEMPSUMMON_TIMED_DESPAWN, 30000); + if(Doomfire) + { + ((mob_doomfire_targettingAI*)Doomfire->AI())->ArchimondeGUID = m_creature->GetGUID(); + Doomfire->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + // Give Doomfire a taste of everyone in the threatlist = more targets to chase. + std::list::iterator itr; + for(itr = m_creature->getThreatManager().getThreatList().begin(); itr != m_creature->getThreatManager().getThreatList().end(); ++itr) + Doomfire->AddThreat(Unit::GetUnit(*m_creature, (*itr)->getUnitGuid()), 1.0f); + Doomfire->setFaction(m_creature->getFaction()); + DoCast(Doomfire, SPELL_DOOMFIRE_SPAWN); + Doomfire->CastSpell(Doomfire, SPELL_DOOMFIRE_VISUAL, true); + if(target) + Doomfire->AI()->AttackStart(target); + + if(rand()%2 == 0) + { + DoYell(SAY_DOOMFIRE1, LANG_UNIVERSAL, m_creature); + DoPlaySoundToSet(m_creature, SOUND_DOOMFIRE1); + }else + { + DoYell(SAY_DOOMFIRE2, LANG_UNIVERSAL, m_creature); + DoPlaySoundToSet(m_creature, SOUND_DOOMFIRE2); + } + } + } + + void UnleashSoulCharge() + { + m_creature->InterruptNonMeleeSpells(false); + bool HasCast = false; + uint32 chargeSpell = 0; + uint32 unleashSpell = 0; + switch(rand()%3) + { + case 0: + chargeSpell = SPELL_SOUL_CHARGE_RED; + unleashSpell = SPELL_UNLEASH_SOUL_RED; + break; + case 1: + chargeSpell = SPELL_SOUL_CHARGE_YELLOW; + unleashSpell = SPELL_UNLEASH_SOUL_YELLOW; + break; + case 2: + chargeSpell = SPELL_SOUL_CHARGE_GREEN; + unleashSpell = SPELL_UNLEASH_SOUL_GREEN; + break; + } + if(m_creature->HasAura(chargeSpell, 0)) + { + m_creature->RemoveSingleAuraFromStack(chargeSpell, 0); + DoCast(m_creature->getVictim(), unleashSpell); + HasCast = true; + SoulChargeCount--; + } + if(HasCast) + SoulChargeTimer = 2000 + rand()%28000; + } + + void UpdateAI(const uint32 diff) + { + if(!InCombat) + { + if(pInstance) + { + // Do not let the raid skip straight to Archimonde. Visible and hostile ONLY if Azagalor is finished. + if((pInstance->GetData(DATA_AZGALOREVENT) < DONE) && ((m_creature->GetVisibility() != VISIBILITY_OFF) || (m_creature->getFaction() != 35))) + { + m_creature->SetVisibility(VISIBILITY_OFF); + m_creature->setFaction(35); + } + else if((pInstance->GetData(DATA_AZGALOREVENT) >= DONE) && ((m_creature->GetVisibility() != VISIBILITY_ON) || (m_creature->getFaction() == 35))) + { + m_creature->setFaction(1720); + m_creature->SetVisibility(VISIBILITY_ON); + } + } + + if(DrainNordrassilTimer < diff) + { + if(!IsChanneling) + { + Creature* Nordrassil = m_creature->SummonCreature(CREATURE_CHANNEL_TARGET, NORDRASSIL_X, NORDRASSIL_Y, NORDRASSIL_Z, 0, TEMPSUMMON_TIMED_DESPAWN, 1200000); + if(Nordrassil) + { + Nordrassil->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + Nordrassil->SetUInt32Value(UNIT_FIELD_DISPLAYID, 11686); + DoCast(Nordrassil, SPELL_DRAIN_WORLD_TREE); + IsChanneling = true; + } + } + Creature* Nordrassil = m_creature->SummonCreature(CREATURE_CHANNEL_TARGET, NORDRASSIL_X, NORDRASSIL_Y, NORDRASSIL_Z, 0, TEMPSUMMON_TIMED_DESPAWN, 5000); + if(Nordrassil) + { + Nordrassil->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + Nordrassil->SetUInt32Value(UNIT_FIELD_DISPLAYID, 11686); + Nordrassil->CastSpell(m_creature, SPELL_DRAIN_WORLD_TREE_2, true); + DrainNordrassilTimer = 1000; + } + }else DrainNordrassilTimer -= diff; + } + + if(!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + if(((m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < 10) && !BelowTenPercent && !Enraged) + BelowTenPercent = true; + + if(!Enraged) + { + if(EnrageTimer < diff) + { + if((m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) > 10) + { + m_creature->GetMotionMaster()->Clear(false); + m_creature->GetMotionMaster()->MoveIdle(); + Enraged = true; + DoYell(SAY_ENRAGE, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_ENRAGE); + } + }else EnrageTimer -= diff; + + if(CheckDistanceTimer < diff) + { // To simplify the check, we simply summon a creature in the location and then check how far we are from the creature + Creature* Check = m_creature->SummonCreature(CREATURE_CHANNEL_TARGET, NORDRASSIL_X, NORDRASSIL_Y, NORDRASSIL_Z, 0, TEMPSUMMON_TIMED_DESPAWN, 2000); + if(Check) + { + Check->SetVisibility(VISIBILITY_OFF); + if(m_creature->IsWithinDistInMap(Check, 75)) + { + m_creature->GetMotionMaster()->Clear(false); + m_creature->GetMotionMaster()->MoveIdle(); + Enraged = true; + DoYell(SAY_ENRAGE, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_ENRAGE); + } + } + CheckDistanceTimer = 5000; + }else CheckDistanceTimer -= diff; + } + + if(BelowTenPercent) + { + if(!HasProtected) + { + m_creature->GetMotionMaster()->Clear(false); + m_creature->GetMotionMaster()->MoveIdle(); + DoCast(m_creature->getVictim(), SPELL_PROTECTION_OF_ELUNE); + HasProtected = true; + Enraged = true; + } + + if(SummonWispTimer < diff) + { + Creature* Wisp = DoSpawnCreature(CREATURE_ANCIENT_WISP, rand()%40, rand()%40, 0, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000); + if(Wisp) + { + Wisp->AI()->AttackStart(m_creature); + ((mob_ancient_wispAI*)Wisp->AI())->ArchimondeGUID = m_creature->GetGUID(); + } + SummonWispTimer = 1500; + ++WispCount; + }else SummonWispTimer -= diff; + + if(WispCount >= 30) + m_creature->DealDamage(m_creature, m_creature->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); + } + + if(Enraged) + { + if(HandOfDeathTimer < diff) + { + DoCast(m_creature->getVictim(), SPELL_HAND_OF_DEATH); + HandOfDeathTimer = 2000; + }else HandOfDeathTimer -= diff; + return; // Don't do anything after this point. + } + + if(SoulChargeCount) + { + if(SoulChargeTimer < diff) + UnleashSoulCharge(); + else SoulChargeTimer -= diff; + } + + if(GripOfTheLegionTimer < diff) + { + DoCast(SelectUnit(SELECT_TARGET_RANDOM, 0), SPELL_GRIP_OF_THE_LEGION); + GripOfTheLegionTimer = 5000 + rand()%20000; + }else GripOfTheLegionTimer -= diff; + + if(AirBurstTimer < diff) + { + if(rand()%2 == 0) + { + DoYell(SAY_AIR_BURST, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_AIR_BURST); + }else + { + DoYell(SAY_AIR_BURST2, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_AIR_BURST2); + } + + DoCast(SelectUnit(SELECT_TARGET_RANDOM, 0), SPELL_AIR_BURST); + AirBurstTimer = 25000 + rand()%15000; + }else AirBurstTimer -= diff; + + if(FearTimer < diff) + { + DoCast(m_creature->getVictim(), SPELL_FEAR); + FearTimer = 40000; + }else FearTimer -= diff; + + if(DoomfireTimer < diff) + { + SummonDoomfire(SelectUnit(SELECT_TARGET_RANDOM, 1)); + DoomfireTimer = 40000; + }else DoomfireTimer -= diff; + + if(MeleeRangeCheckTimer < diff) + { + if(CanUseFingerOfDeath()) + { + DoCast(SelectUnit(SELECT_TARGET_RANDOM, 0), SPELL_FINGER_OF_DEATH); + MeleeRangeCheckTimer = 1000; + } + + MeleeRangeCheckTimer = 5000; + }else MeleeRangeCheckTimer -= diff; + + DoMeleeAttackIfReady(); + } +}; + +CreatureAI* GetAI_boss_archimonde(Creature *_Creature) +{ + return new boss_archimondeAI (_Creature); +} + +CreatureAI* GetAI_mob_doomfire(Creature* _Creature) +{ + return new mob_doomfireAI(_Creature); +} + +CreatureAI* GetAI_mob_doomfire_targetting(Creature* _Creature) +{ + return new mob_doomfire_targettingAI(_Creature); +} + +CreatureAI* GetAI_mob_ancient_wisp(Creature* _Creature) +{ + return new mob_ancient_wispAI(_Creature); +} + +void AddSC_boss_archimonde() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_archimonde"; + newscript->GetAI = GetAI_boss_archimonde; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name = "mob_doomfire"; + newscript->GetAI = GetAI_mob_doomfire; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name = "mob_doomfire_targetting"; + newscript->GetAI = GetAI_mob_doomfire_targetting; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name = "mob_ancient_wisp"; + newscript->GetAI = GetAI_mob_ancient_wisp; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/caverns_of_time/hyjal/def_hyjal.h b/src/bindings/scripts/scripts/zone/caverns_of_time/hyjal/def_hyjal.h index 1e28156857f..ff8e3dd3eed 100644 --- a/src/bindings/scripts/scripts/zone/caverns_of_time/hyjal/def_hyjal.h +++ b/src/bindings/scripts/scripts/zone/caverns_of_time/hyjal/def_hyjal.h @@ -1,25 +1,25 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software licensed under GPL version 2 - * Please see the included DOCS/LICENSE.TXT for more information */ - -#ifndef DEF_HYJAL_H -#define DEF_HYJAL_H - -#define DATA_ANETHERON 1 -#define DATA_ANETHERONEVENT 2 -#define DATA_ARCHIMONDE 3 -#define DATA_ARCHIMONDEEVENT 4 -#define DATA_AZGALOR 5 -#define DATA_AZGALOREVENT 6 -#define DATA_JAINAPROUDMOORE 7 -#define DATA_KAZROGAL 8 -#define DATA_KAZROGALEVENT 9 -#define DATA_RAGEWINTERCHILL 10 -#define DATA_RAGEWINTERCHILLEVENT 11 -#define DATA_THRALL 12 -#define DATA_TYRANDEWHISPERWIND 13 -#define DATA_TRASH 14 -#define DATA_RESET_TRASH_COUNT 15 - -#define ERROR_INST_DATA "SD2: Instance data not set properly for Mount Hyjal. Encounters will be buggy" -#endif +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software licensed under GPL version 2 + * Please see the included DOCS/LICENSE.TXT for more information */ + +#ifndef DEF_HYJAL_H +#define DEF_HYJAL_H + +#define DATA_ANETHERON 1 +#define DATA_ANETHERONEVENT 2 +#define DATA_ARCHIMONDE 3 +#define DATA_ARCHIMONDEEVENT 4 +#define DATA_AZGALOR 5 +#define DATA_AZGALOREVENT 6 +#define DATA_JAINAPROUDMOORE 7 +#define DATA_KAZROGAL 8 +#define DATA_KAZROGALEVENT 9 +#define DATA_RAGEWINTERCHILL 10 +#define DATA_RAGEWINTERCHILLEVENT 11 +#define DATA_THRALL 12 +#define DATA_TYRANDEWHISPERWIND 13 +#define DATA_TRASH 14 +#define DATA_RESET_TRASH_COUNT 15 + +#define ERROR_INST_DATA "SD2: Instance data not set properly for Mount Hyjal. Encounters will be buggy" +#endif diff --git a/src/bindings/scripts/scripts/zone/caverns_of_time/hyjal/hyjal.cpp b/src/bindings/scripts/scripts/zone/caverns_of_time/hyjal/hyjal.cpp index 14dbdf62736..63410206531 100644 --- a/src/bindings/scripts/scripts/zone/caverns_of_time/hyjal/hyjal.cpp +++ b/src/bindings/scripts/scripts/zone/caverns_of_time/hyjal/hyjal.cpp @@ -1,217 +1,217 @@ -/* Copyright (C) 2006,2007 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Hyjal -SD%Complete: 100 -SDComment: -SDCategory: Caverns of Time, Mount Hyjal -EndScriptData */ - -/* ContentData -npc_jaina_proudmoore -npc_thrall -npc_tyrande_whisperwind -EndContentData */ - -#include "precompiled.h" -#include "hyjalAI.h" - -#define GOSSIP_ITEM_BEGIN_ALLY "We are ready to defend the Alliance base." -#define GOSSIP_ITEM_ANETHERON "The defenses are holding up; we can continue." -#define GOSSIP_ITEM_RETREAT "We can't keep this up. Let's retreat!" - -#define GOSSIP_ITEM_BEGIN_HORDE "We're here to help! The Alliance are overrun." -#define GOSSIP_ITEM_AZGALOR "We're okay so far. Let's do this!" - -CreatureAI* GetAI_npc_jaina_proudmoore(Creature *_Creature) -{ - hyjalAI* ai = new hyjalAI(_Creature); - - ai->Reset(); - ai->EnterEvadeMode(); - - ai->Spell[0].SpellId = SPELL_BLIZZARD; - ai->Spell[0].Cooldown = 15000 + rand()%20000; - ai->Spell[0].TargetType = TARGETTYPE_RANDOM; - - ai->Spell[1].SpellId = SPELL_PYROBLAST; - ai->Spell[1].Cooldown = 2000 + rand()%7000; - ai->Spell[1].TargetType = TARGETTYPE_RANDOM; - - ai->Spell[2].SpellId = SPELL_SUMMON_ELEMENTALS; - ai->Spell[2].Cooldown = 15000 + rand()%30000; - ai->Spell[2].TargetType = TARGETTYPE_SELF; - - return ai; -} - -bool GossipHello_npc_jaina_proudmoore(Player *player, Creature *_Creature) -{ - hyjalAI* ai = ((hyjalAI*)_Creature->AI()); - if(ai->EventBegun) - return false; - - uint32 RageEncounter = ai->GetInstanceData(DATA_RAGEWINTERCHILLEVENT); - uint32 AnetheronEncounter = ai->GetInstanceData(DATA_ANETHERONEVENT); - if(RageEncounter == NOT_STARTED) - player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM_BEGIN_ALLY, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); - else if(RageEncounter == DONE && AnetheronEncounter == NOT_STARTED) - player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM_ANETHERON, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2); - else if(RageEncounter == DONE && AnetheronEncounter == DONE) - player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM_RETREAT, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 3); - - if(player->isGameMaster()) - player->ADD_GOSSIP_ITEM(2, "[GM] Toggle Debug Timers", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 4); - - player->SEND_GOSSIP_MENU(907, _Creature->GetGUID()); - - return true; -} - -bool GossipSelect_npc_jaina_proudmoore(Player *player, Creature *_Creature, uint32 sender, uint32 action) -{ - player->PlayerTalkClass->GetGossipMenu(); - hyjalAI* ai = ((hyjalAI*)_Creature->AI()); - switch(action) - { - case GOSSIP_ACTION_INFO_DEF + 1: - ai->StartEvent(player); - break; - case GOSSIP_ACTION_INFO_DEF + 2: - ai->FirstBossDead = true; - ai->WaveCount = 9; - ai->StartEvent(player); - break; - case GOSSIP_ACTION_INFO_DEF + 3: - ai->Retreat(); - break; - case GOSSIP_ACTION_INFO_DEF + 4: - ai->Debug = !ai->Debug; - outstring_log("SD2 : HyjalAI - Debug mode has been toggled"); - break; - } - - return true; -} - -CreatureAI* GetAI_npc_thrall(Creature *_Creature) -{ - hyjalAI* ai = new hyjalAI(_Creature); - - ai->Reset(); - ai->EnterEvadeMode(); - - ai->Spell[0].SpellId = SPELL_CHAIN_LIGHTNING; - ai->Spell[0].Cooldown = 2000 + rand()%5000; - ai->Spell[0].TargetType = TARGETTYPE_VICTIM; - - ai->Spell[1].SpellId = SPELL_SUMMON_DIRE_WOLF; - ai->Spell[1].Cooldown = 6000 + rand()%35000; - ai->Spell[1].TargetType = TARGETTYPE_RANDOM; - - return ai; -} - -bool GossipHello_npc_thrall(Player *player, Creature *_Creature) -{ - hyjalAI* ai = ((hyjalAI*)_Creature->AI()); - uint32 AnetheronEvent = ai->GetInstanceData(DATA_ANETHERONEVENT); - if(AnetheronEvent >= DONE && !ai->EventBegun) // Only let them start the Horde phase if Anetheron is dead. - { - uint32 KazrogalEvent = ai->GetInstanceData(DATA_KAZROGALEVENT); - uint32 AzgalorEvent = ai->GetInstanceData(DATA_AZGALOREVENT); - if(KazrogalEvent == NOT_STARTED) - player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM_BEGIN_HORDE, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); - else if(KazrogalEvent == DONE && AzgalorEvent == NOT_STARTED) - player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM_AZGALOR, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2); - else if(AzgalorEvent == DONE) - player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM_RETREAT, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 3); - } - - if(player->isGameMaster()) - player->ADD_GOSSIP_ITEM(2, "[GM] Toggle Debug Timers", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 4); - - player->SEND_GOSSIP_MENU(907, _Creature->GetGUID()); - - return true; -} - -bool GossipSelect_npc_thrall(Player *player, Creature *_Creature, uint32 sender, uint32 action) -{ - player->PlayerTalkClass->GetGossipMenu(); - hyjalAI* ai = ((hyjalAI*)_Creature->AI()); - switch(action) - { - case GOSSIP_ACTION_INFO_DEF + 1: - ai->StartEvent(player); - break; - case GOSSIP_ACTION_INFO_DEF + 2: - ai->FirstBossDead = true; - ai->WaveCount = 9; - ai->StartEvent(player); - break; - case GOSSIP_ACTION_INFO_DEF + 3: - ai->Retreat(); - break; - case GOSSIP_ACTION_INFO_DEF + 4: - ai->Debug = !ai->Debug; - outstring_log("SD2 : HyjalAI - Debug mode has been toggled"); - break; - } - - return true; -} - -bool GossipHello_npc_tyrande_whisperwind(Player* player, Creature* _Creature) -{ - player->ADD_GOSSIP_ITEM(1, "Aid us in defending Nordrassil", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_TRADE); - player->SEND_GOSSIP_MENU(907, _Creature->GetGUID()); - return true; -} - -bool GossipSelect_npc_tyrande_whisperwind(Player *player, Creature *_Creature, uint32 sender, uint32 action) -{ - if(action == GOSSIP_ACTION_TRADE) - player->SEND_VENDORLIST( _Creature->GetGUID() ); - - return true; -} - -void AddSC_hyjal() -{ - Script *newscript; - - newscript = new Script; - newscript->Name = "npc_jaina_proudmoore"; - newscript->GetAI = GetAI_npc_jaina_proudmoore; - newscript->pGossipHello = &GossipHello_npc_jaina_proudmoore; - newscript->pGossipSelect = &GossipSelect_npc_jaina_proudmoore; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name = "npc_thrall"; - newscript->GetAI = GetAI_npc_thrall; - newscript->pGossipHello = &GossipHello_npc_thrall; - newscript->pGossipSelect = &GossipSelect_npc_thrall; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name = "npc_tyrande_whisperwind"; - newscript->pGossipHello = &GossipHello_npc_tyrande_whisperwind; - newscript->pGossipSelect = &GossipSelect_npc_tyrande_whisperwind; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006,2007 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Hyjal +SD%Complete: 100 +SDComment: +SDCategory: Caverns of Time, Mount Hyjal +EndScriptData */ + +/* ContentData +npc_jaina_proudmoore +npc_thrall +npc_tyrande_whisperwind +EndContentData */ + +#include "precompiled.h" +#include "hyjalAI.h" + +#define GOSSIP_ITEM_BEGIN_ALLY "We are ready to defend the Alliance base." +#define GOSSIP_ITEM_ANETHERON "The defenses are holding up; we can continue." +#define GOSSIP_ITEM_RETREAT "We can't keep this up. Let's retreat!" + +#define GOSSIP_ITEM_BEGIN_HORDE "We're here to help! The Alliance are overrun." +#define GOSSIP_ITEM_AZGALOR "We're okay so far. Let's do this!" + +CreatureAI* GetAI_npc_jaina_proudmoore(Creature *_Creature) +{ + hyjalAI* ai = new hyjalAI(_Creature); + + ai->Reset(); + ai->EnterEvadeMode(); + + ai->Spell[0].SpellId = SPELL_BLIZZARD; + ai->Spell[0].Cooldown = 15000 + rand()%20000; + ai->Spell[0].TargetType = TARGETTYPE_RANDOM; + + ai->Spell[1].SpellId = SPELL_PYROBLAST; + ai->Spell[1].Cooldown = 2000 + rand()%7000; + ai->Spell[1].TargetType = TARGETTYPE_RANDOM; + + ai->Spell[2].SpellId = SPELL_SUMMON_ELEMENTALS; + ai->Spell[2].Cooldown = 15000 + rand()%30000; + ai->Spell[2].TargetType = TARGETTYPE_SELF; + + return ai; +} + +bool GossipHello_npc_jaina_proudmoore(Player *player, Creature *_Creature) +{ + hyjalAI* ai = ((hyjalAI*)_Creature->AI()); + if(ai->EventBegun) + return false; + + uint32 RageEncounter = ai->GetInstanceData(DATA_RAGEWINTERCHILLEVENT); + uint32 AnetheronEncounter = ai->GetInstanceData(DATA_ANETHERONEVENT); + if(RageEncounter == NOT_STARTED) + player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM_BEGIN_ALLY, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); + else if(RageEncounter == DONE && AnetheronEncounter == NOT_STARTED) + player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM_ANETHERON, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2); + else if(RageEncounter == DONE && AnetheronEncounter == DONE) + player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM_RETREAT, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 3); + + if(player->isGameMaster()) + player->ADD_GOSSIP_ITEM(2, "[GM] Toggle Debug Timers", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 4); + + player->SEND_GOSSIP_MENU(907, _Creature->GetGUID()); + + return true; +} + +bool GossipSelect_npc_jaina_proudmoore(Player *player, Creature *_Creature, uint32 sender, uint32 action) +{ + player->PlayerTalkClass->GetGossipMenu(); + hyjalAI* ai = ((hyjalAI*)_Creature->AI()); + switch(action) + { + case GOSSIP_ACTION_INFO_DEF + 1: + ai->StartEvent(player); + break; + case GOSSIP_ACTION_INFO_DEF + 2: + ai->FirstBossDead = true; + ai->WaveCount = 9; + ai->StartEvent(player); + break; + case GOSSIP_ACTION_INFO_DEF + 3: + ai->Retreat(); + break; + case GOSSIP_ACTION_INFO_DEF + 4: + ai->Debug = !ai->Debug; + outstring_log("SD2 : HyjalAI - Debug mode has been toggled"); + break; + } + + return true; +} + +CreatureAI* GetAI_npc_thrall(Creature *_Creature) +{ + hyjalAI* ai = new hyjalAI(_Creature); + + ai->Reset(); + ai->EnterEvadeMode(); + + ai->Spell[0].SpellId = SPELL_CHAIN_LIGHTNING; + ai->Spell[0].Cooldown = 2000 + rand()%5000; + ai->Spell[0].TargetType = TARGETTYPE_VICTIM; + + ai->Spell[1].SpellId = SPELL_SUMMON_DIRE_WOLF; + ai->Spell[1].Cooldown = 6000 + rand()%35000; + ai->Spell[1].TargetType = TARGETTYPE_RANDOM; + + return ai; +} + +bool GossipHello_npc_thrall(Player *player, Creature *_Creature) +{ + hyjalAI* ai = ((hyjalAI*)_Creature->AI()); + uint32 AnetheronEvent = ai->GetInstanceData(DATA_ANETHERONEVENT); + if(AnetheronEvent >= DONE && !ai->EventBegun) // Only let them start the Horde phase if Anetheron is dead. + { + uint32 KazrogalEvent = ai->GetInstanceData(DATA_KAZROGALEVENT); + uint32 AzgalorEvent = ai->GetInstanceData(DATA_AZGALOREVENT); + if(KazrogalEvent == NOT_STARTED) + player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM_BEGIN_HORDE, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); + else if(KazrogalEvent == DONE && AzgalorEvent == NOT_STARTED) + player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM_AZGALOR, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2); + else if(AzgalorEvent == DONE) + player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM_RETREAT, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 3); + } + + if(player->isGameMaster()) + player->ADD_GOSSIP_ITEM(2, "[GM] Toggle Debug Timers", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 4); + + player->SEND_GOSSIP_MENU(907, _Creature->GetGUID()); + + return true; +} + +bool GossipSelect_npc_thrall(Player *player, Creature *_Creature, uint32 sender, uint32 action) +{ + player->PlayerTalkClass->GetGossipMenu(); + hyjalAI* ai = ((hyjalAI*)_Creature->AI()); + switch(action) + { + case GOSSIP_ACTION_INFO_DEF + 1: + ai->StartEvent(player); + break; + case GOSSIP_ACTION_INFO_DEF + 2: + ai->FirstBossDead = true; + ai->WaveCount = 9; + ai->StartEvent(player); + break; + case GOSSIP_ACTION_INFO_DEF + 3: + ai->Retreat(); + break; + case GOSSIP_ACTION_INFO_DEF + 4: + ai->Debug = !ai->Debug; + outstring_log("SD2 : HyjalAI - Debug mode has been toggled"); + break; + } + + return true; +} + +bool GossipHello_npc_tyrande_whisperwind(Player* player, Creature* _Creature) +{ + player->ADD_GOSSIP_ITEM(1, "Aid us in defending Nordrassil", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_TRADE); + player->SEND_GOSSIP_MENU(907, _Creature->GetGUID()); + return true; +} + +bool GossipSelect_npc_tyrande_whisperwind(Player *player, Creature *_Creature, uint32 sender, uint32 action) +{ + if(action == GOSSIP_ACTION_TRADE) + player->SEND_VENDORLIST( _Creature->GetGUID() ); + + return true; +} + +void AddSC_hyjal() +{ + Script *newscript; + + newscript = new Script; + newscript->Name = "npc_jaina_proudmoore"; + newscript->GetAI = GetAI_npc_jaina_proudmoore; + newscript->pGossipHello = &GossipHello_npc_jaina_proudmoore; + newscript->pGossipSelect = &GossipSelect_npc_jaina_proudmoore; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name = "npc_thrall"; + newscript->GetAI = GetAI_npc_thrall; + newscript->pGossipHello = &GossipHello_npc_thrall; + newscript->pGossipSelect = &GossipSelect_npc_thrall; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name = "npc_tyrande_whisperwind"; + newscript->pGossipHello = &GossipHello_npc_tyrande_whisperwind; + newscript->pGossipSelect = &GossipSelect_npc_tyrande_whisperwind; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/caverns_of_time/hyjal/hyjalAI.cpp b/src/bindings/scripts/scripts/zone/caverns_of_time/hyjal/hyjalAI.cpp index 0d18f0d9244..d1db61148e1 100644 --- a/src/bindings/scripts/scripts/zone/caverns_of_time/hyjal/hyjalAI.cpp +++ b/src/bindings/scripts/scripts/zone/caverns_of_time/hyjal/hyjalAI.cpp @@ -1,458 +1,458 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: HyjalAI -SD%Complete: 99 -SDComment: World Packet workaround for World States -SDCategory: Caverns of Time, Mount Hyjal -EndScriptData */ - -#include "precompiled.h" -#include "hyjalAI.h" -#include "WorldPacket.h" - -float AllianceBase[4][3]= // Locations for summoning waves in Alliance base -{ - {4979.010, -1709.134, 1339.674}, - {4969.123, -1705.904, 1341.363}, - {4970.260, -1698.546, 1341.200}, - {4975.262, -1698.239, 1341.427} -}; - -float HordeBase[4][3]= // Locations for summoning waves in Horde base -{ - {5554.399, -2581.419, 1480.820}, - {5538.996, -2577.742, 1479.790}, - {5565.642, -2565.666, 1481.635}, - {5547.218, -2574.589, 1479.194} -}; - -float AttackArea[2][3]= // used to inform the wave where to move and attack to -{ - { // Alliance - 5042.9189, -1776.2562, 1323.0621 - }, - { // Horde - 5510.4815, -2676.7112, 1480.4314 - } -}; - -hyjalAI::hyjalAI(Creature *c) : ScriptedAI(c) -{ - pInstance = ((ScriptedInstance*)c->GetInstanceData()); - Reset(); -} - -void hyjalAI::Reset() -{ - /** GUIDs **/ - PlayerGUID = 0; - BossGUID[0] = 0; - BossGUID[1] = 0; - - /** Timers **/ - NextWaveTimer = 10000; - CheckTimer = 0; - RetreatTimer = 1000; - - /** Misc **/ - WaveCount = 0; - - /** Set faction properly based on creature entry**/ - switch(m_creature->GetEntry()) - { - case 17772: - Faction = 0; - DoCast(m_creature, SPELL_BRILLIANCE_AURA, true); - break; - - case 17852: Faction = 1; break; - } - - /** Bools **/ - EventBegun = false; - FirstBossDead = false; - SecondBossDead = false; - Summon = false; - bRetreat = false; - - /** Flags **/ - m_creature->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP); - - /** Initialize spells **/ - memset(Spell, 0, sizeof(Spell)); - - /** Reset World States **/ - UpdateWorldState(WORLDSTATE_WAVES, 0); - UpdateWorldState(WORLDSTATE_ENEMY, 0); - UpdateWorldState(WORLDSTATE_ENEMYCOUNT, 0); - - /** Reset Instance Data for trash count **/ - if(pInstance) - pInstance->SetData(DATA_RESET_TRASH_COUNT, 0); - else error_log(ERROR_INST_DATA); - - /*** Visibility ***/ - m_creature->SetVisibility(VISIBILITY_ON); - - /** If Jaina evades, reset the visibility of all other creatures in the grid. **/ - if(CreatureList.empty()) - return; - - for(std::list::iterator itr = CreatureList.begin(); itr != CreatureList.end(); ++itr) - if(Creature* cr = ((Creature*)Unit::GetUnit(*m_creature, *itr))) - cr->SetVisibility(VISIBILITY_ON); - - CreatureList.clear(); -} - -void hyjalAI::EnterEvadeMode() -{ - m_creature->InterruptNonMeleeSpells(true); - m_creature->RemoveAllAuras(); - m_creature->DeleteThreatList(); - m_creature->CombatStop(); - m_creature->LoadCreaturesAddon(); - - if(m_creature->isAlive()) - m_creature->GetMotionMaster()->MoveTargetedHome(); - - InCombat = false; -} - -void hyjalAI::Aggro(Unit *who) -{ - for(uint8 i = 0; i < 2; ++i) - if(Spell[i].Cooldown) - SpellTimer[i] = Spell[i].Cooldown; - - Talk(ATTACKED); -} - -void hyjalAI::SummonCreature(uint32 entry, float Base[4][3]) -{ - uint32 random = rand()%4; - float SpawnLoc[3]; - float AttackLoc[3]; - - for(uint8 i = 0; i < 3; ++i) - { - SpawnLoc[i] = Base[random][i]; - AttackLoc[i] = AttackArea[Faction][i]; - } - - Creature* pCreature = m_creature->SummonCreature(entry, SpawnLoc[0], SpawnLoc[1], SpawnLoc[2], 0, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 120000); - if(pCreature) - { - ++EnemyCount; // Increment Enemy Count to be used in World States and instance script - - pCreature->RemoveUnitMovementFlag(MOVEMENTFLAG_WALK_MODE); - pCreature->GetMotionMaster()->MovePoint(0, AttackLoc[0],AttackLoc[1],AttackLoc[2]); - pCreature->AddThreat(m_creature, 1.0f); - DoZoneInCombat(pCreature); - - // Check if creature is a boss. - if(pCreature->GetCreatureInfo()->rank == 3) - { - if(!FirstBossDead) BossGUID[0] = pCreature->GetGUID(); - else BossGUID[1] = pCreature->GetGUID(); - CheckTimer = 5000; - } - } -} - -void hyjalAI::SummonNextWave(Wave wave[18], uint32 Count, float Base[4][3]) -{ - if(rand()%4 == 0) // 1 in 4 chance we give a rally yell. Not sure if the chance is Blizzlike. - Talk(RALLY); - - if(!pInstance) - { - error_log(ERROR_INST_DATA); - return; - } - - EnemyCount = pInstance->GetData(DATA_TRASH); - for(uint8 i = 0; i < 18; ++i) - { - if(wave[Count].Mob[i]) - SummonCreature(wave[Count].Mob[i], Base); - } - - if(!wave[Count].IsBoss) - { - uint32 stateValue = Count+1; - if(FirstBossDead) - stateValue -= 9; // Subtract 9 from it to give the proper wave number if we are greater than 8 - UpdateWorldState(WORLDSTATE_WAVES, stateValue); // Set world state to our current wave number - UpdateWorldState(WORLDSTATE_ENEMY, 1); - //UpdateWorldState(WORLDSTATE_ENEMYCOUNT, EnemyCount); // Let Instance Script handle this - pInstance->SetData(DATA_TRASH, EnemyCount); - if(!Debug) - NextWaveTimer = wave[Count].WaveTimer; - else - { - NextWaveTimer = 15000; - DoTextEmote(": Debug Mode is enabled. Next Wave in 15 seconds", NULL); - } - } - else - { - UpdateWorldState(WORLDSTATE_WAVES, 0); // Set world state for waves to 0 to disable it. - UpdateWorldState(WORLDSTATE_ENEMYCOUNT, 1); // Set World State for enemies invading to 1. - Summon = false; - } - CheckTimer = 5000; -} - -void hyjalAI::StartEvent(Player* player) -{ - if(!player) - return; - - Talk(BEGIN); - - EventBegun = true; - Summon = true; - - NextWaveTimer = 15000; - CheckTimer = 5000; - PlayerGUID = player->GetGUID(); - - m_creature->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP); - - UpdateWorldState(WORLDSTATE_WAVES, 0); - UpdateWorldState(WORLDSTATE_ENEMY, 0); - UpdateWorldState(WORLDSTATE_ENEMYCOUNT, 0); -} - -uint32 hyjalAI::GetInstanceData(uint32 Event) -{ - if(pInstance) - return pInstance->GetData(Event); - else error_log(ERROR_INST_DATA); - - return 0; -} - -void hyjalAI::Talk(uint32 id) -{ - std::list index; - for(uint8 i = 0; i < 10; i++) - { - if(Faction == 0) // Alliance - { - if(JainaQuotes[i].id == id) - index.push_back(i); - } - else if(Faction == 1) // Horde - { - if(ThrallQuotes[i].id == id) - index.push_back(i); - } - } - - if(index.empty()) - return; // No quotes found, no use to continue - - uint8 ind = *(index.begin()) + rand()%index.size(); - - char* Yell = NULL; - uint32 Sound = 0; - if(Faction == 0) // Alliance - { - Yell = JainaQuotes[ind].text; - Sound = JainaQuotes[ind].sound; - } - else if(Faction == 1) // Horde - { - Yell = ThrallQuotes[ind].text; - Sound = ThrallQuotes[ind].sound; - } - - if(Yell) - DoYell(Yell, LANG_UNIVERSAL, NULL); - if(Sound) - DoPlaySoundToSet(m_creature, Sound); -} - -// Slight workaround for now -void hyjalAI::UpdateWorldState(uint32 field, uint32 value) -{ - Map * map = m_creature->GetMap(); - if(!map->IsDungeon()) return; - - WorldPacket data(SMSG_UPDATE_WORLD_STATE, 8); - - data << field; - data << value; - - ((InstanceMap*)map)->SendToPlayers(&data); - - // TODO: Uncomment and remove everything above this line only when the core patch for this is accepted - //m_creature->GetMap()->UpdateWorldState(field, value); -} - -void hyjalAI::Retreat() -{ - CellPair pair(MaNGOS::ComputeCellPair(m_creature->GetPositionX(), m_creature->GetPositionY())); - Cell cell(pair); - cell.data.Part.reserved = ALL_DISTRICT; - cell.SetNoCreate(); - - // First get all creatures. - std::list creatures; - AllFriendlyCreaturesInGrid creature_check(m_creature); - MaNGOS::CreatureListSearcher creature_searcher(creatures, creature_check); - TypeContainerVisitor - , - GridTypeMapContainer> creature_visitor(creature_searcher); - - // Then get all Ancient Gem Veins. NOTE: Grid Search will only be able to find those in the grid. - std::list goList; - AllGameObjectsWithEntryInGrid go_check(185557); - MaNGOS::GameObjectListSearcher go_search(goList, go_check); - TypeContainerVisitor - , GridTypeMapContainer> go_visit(go_search); - - CellLock cell_lock(cell, pair); - // Get Creatures - cell_lock->Visit(cell_lock, creature_visitor, *(m_creature->GetMap())); - // Get GOs - cell_lock->Visit(cell_lock, go_visit, *(m_creature->GetMap())); - - CreatureList.clear(); - if(!creatures.empty()) - { - for(std::list::iterator itr = creatures.begin(); itr != creatures.end(); ++itr) - { - (*itr)->CastSpell(*itr, SPELL_TELEPORT_VISUAL, true); - CreatureList.push_back((*itr)->GetGUID()); - } - - DoCast(m_creature, SPELL_TELEPORT_VISUAL); - bRetreat = true; - RetreatTimer = 1000; - } - - if(!goList.empty()) - { - for(std::list::iterator itr = goList.begin(); itr != goList.end(); ++itr) - (*itr)->SetRespawnTime(5000); - } -} - -void hyjalAI::UpdateAI(const uint32 diff) -{ - if(bRetreat) - if(RetreatTimer < diff) - { - bRetreat = false; - if(CreatureList.empty()) - return; - - for(std::list::iterator itr = CreatureList.begin(); itr != CreatureList.end(); ++itr) - if(Unit* pUnit = Unit::GetUnit(*m_creature, *itr)) - pUnit->SetVisibility(VISIBILITY_OFF); - - m_creature->SetVisibility(VISIBILITY_OFF); - }else RetreatTimer -= diff; - - if(!EventBegun) - return; - - if(Summon) - { - if(pInstance && EnemyCount) - { - EnemyCount = pInstance->GetData(DATA_TRASH); - if(!EnemyCount) - NextWaveTimer = 5000; - } - - if(NextWaveTimer < diff) - { - if(Faction == 0) - SummonNextWave(AllianceWaves, WaveCount, AllianceBase); - else if(Faction == 1) - SummonNextWave(HordeWaves, WaveCount, HordeBase); - ++WaveCount; - }else NextWaveTimer -= diff; - } - - if(CheckTimer < diff) - { - for(uint8 i = 0; i < 2; ++i) - { - if(BossGUID[i]) - { - Unit* pUnit = Unit::GetUnit((*m_creature), BossGUID[i]); - if(pUnit && (!pUnit->isAlive())) - { - if(BossGUID[i] == BossGUID[0]) - { - Talk(INCOMING); - FirstBossDead = true; - } - else if(BossGUID[i] == BossGUID[1]) - { - Talk(SUCCESS); - SecondBossDead = true; - } - EventBegun = false; - CheckTimer = 0; - m_creature->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP); - BossGUID[i] = 0; - UpdateWorldState(WORLDSTATE_ENEMY, 0); // Reset world state for enemies to disable it - } - } - } - CheckTimer = 5000; - }else CheckTimer -= diff; - - if(!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - for(uint8 i = 0; i < 3; ++i) - { - if(Spell[i].SpellId) - { - if(SpellTimer[i] < diff) - { - if(m_creature->IsNonMeleeSpellCasted(false)) - m_creature->InterruptNonMeleeSpells(false); - - Unit* target = NULL; - - switch(Spell[i].TargetType) - { - case TARGETTYPE_SELF: target = m_creature; break; - case TARGETTYPE_RANDOM: target = SelectUnit(SELECT_TARGET_RANDOM, 0); break; - case TARGETTYPE_VICTIM: target = m_creature->getVictim(); break; - } - - if(target && target->isAlive()) - { - DoCast(target, Spell[i].SpellId); - SpellTimer[i] = Spell[i].Cooldown; - } - }else SpellTimer[i] -= diff; - } - } - - DoMeleeAttackIfReady(); -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: HyjalAI +SD%Complete: 99 +SDComment: World Packet workaround for World States +SDCategory: Caverns of Time, Mount Hyjal +EndScriptData */ + +#include "precompiled.h" +#include "hyjalAI.h" +#include "WorldPacket.h" + +float AllianceBase[4][3]= // Locations for summoning waves in Alliance base +{ + {4979.010, -1709.134, 1339.674}, + {4969.123, -1705.904, 1341.363}, + {4970.260, -1698.546, 1341.200}, + {4975.262, -1698.239, 1341.427} +}; + +float HordeBase[4][3]= // Locations for summoning waves in Horde base +{ + {5554.399, -2581.419, 1480.820}, + {5538.996, -2577.742, 1479.790}, + {5565.642, -2565.666, 1481.635}, + {5547.218, -2574.589, 1479.194} +}; + +float AttackArea[2][3]= // used to inform the wave where to move and attack to +{ + { // Alliance + 5042.9189, -1776.2562, 1323.0621 + }, + { // Horde + 5510.4815, -2676.7112, 1480.4314 + } +}; + +hyjalAI::hyjalAI(Creature *c) : ScriptedAI(c) +{ + pInstance = ((ScriptedInstance*)c->GetInstanceData()); + Reset(); +} + +void hyjalAI::Reset() +{ + /** GUIDs **/ + PlayerGUID = 0; + BossGUID[0] = 0; + BossGUID[1] = 0; + + /** Timers **/ + NextWaveTimer = 10000; + CheckTimer = 0; + RetreatTimer = 1000; + + /** Misc **/ + WaveCount = 0; + + /** Set faction properly based on creature entry**/ + switch(m_creature->GetEntry()) + { + case 17772: + Faction = 0; + DoCast(m_creature, SPELL_BRILLIANCE_AURA, true); + break; + + case 17852: Faction = 1; break; + } + + /** Bools **/ + EventBegun = false; + FirstBossDead = false; + SecondBossDead = false; + Summon = false; + bRetreat = false; + + /** Flags **/ + m_creature->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP); + + /** Initialize spells **/ + memset(Spell, 0, sizeof(Spell)); + + /** Reset World States **/ + UpdateWorldState(WORLDSTATE_WAVES, 0); + UpdateWorldState(WORLDSTATE_ENEMY, 0); + UpdateWorldState(WORLDSTATE_ENEMYCOUNT, 0); + + /** Reset Instance Data for trash count **/ + if(pInstance) + pInstance->SetData(DATA_RESET_TRASH_COUNT, 0); + else error_log(ERROR_INST_DATA); + + /*** Visibility ***/ + m_creature->SetVisibility(VISIBILITY_ON); + + /** If Jaina evades, reset the visibility of all other creatures in the grid. **/ + if(CreatureList.empty()) + return; + + for(std::list::iterator itr = CreatureList.begin(); itr != CreatureList.end(); ++itr) + if(Creature* cr = ((Creature*)Unit::GetUnit(*m_creature, *itr))) + cr->SetVisibility(VISIBILITY_ON); + + CreatureList.clear(); +} + +void hyjalAI::EnterEvadeMode() +{ + m_creature->InterruptNonMeleeSpells(true); + m_creature->RemoveAllAuras(); + m_creature->DeleteThreatList(); + m_creature->CombatStop(); + m_creature->LoadCreaturesAddon(); + + if(m_creature->isAlive()) + m_creature->GetMotionMaster()->MoveTargetedHome(); + + InCombat = false; +} + +void hyjalAI::Aggro(Unit *who) +{ + for(uint8 i = 0; i < 2; ++i) + if(Spell[i].Cooldown) + SpellTimer[i] = Spell[i].Cooldown; + + Talk(ATTACKED); +} + +void hyjalAI::SummonCreature(uint32 entry, float Base[4][3]) +{ + uint32 random = rand()%4; + float SpawnLoc[3]; + float AttackLoc[3]; + + for(uint8 i = 0; i < 3; ++i) + { + SpawnLoc[i] = Base[random][i]; + AttackLoc[i] = AttackArea[Faction][i]; + } + + Creature* pCreature = m_creature->SummonCreature(entry, SpawnLoc[0], SpawnLoc[1], SpawnLoc[2], 0, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 120000); + if(pCreature) + { + ++EnemyCount; // Increment Enemy Count to be used in World States and instance script + + pCreature->RemoveUnitMovementFlag(MOVEMENTFLAG_WALK_MODE); + pCreature->GetMotionMaster()->MovePoint(0, AttackLoc[0],AttackLoc[1],AttackLoc[2]); + pCreature->AddThreat(m_creature, 1.0f); + DoZoneInCombat(pCreature); + + // Check if creature is a boss. + if(pCreature->GetCreatureInfo()->rank == 3) + { + if(!FirstBossDead) BossGUID[0] = pCreature->GetGUID(); + else BossGUID[1] = pCreature->GetGUID(); + CheckTimer = 5000; + } + } +} + +void hyjalAI::SummonNextWave(Wave wave[18], uint32 Count, float Base[4][3]) +{ + if(rand()%4 == 0) // 1 in 4 chance we give a rally yell. Not sure if the chance is Blizzlike. + Talk(RALLY); + + if(!pInstance) + { + error_log(ERROR_INST_DATA); + return; + } + + EnemyCount = pInstance->GetData(DATA_TRASH); + for(uint8 i = 0; i < 18; ++i) + { + if(wave[Count].Mob[i]) + SummonCreature(wave[Count].Mob[i], Base); + } + + if(!wave[Count].IsBoss) + { + uint32 stateValue = Count+1; + if(FirstBossDead) + stateValue -= 9; // Subtract 9 from it to give the proper wave number if we are greater than 8 + UpdateWorldState(WORLDSTATE_WAVES, stateValue); // Set world state to our current wave number + UpdateWorldState(WORLDSTATE_ENEMY, 1); + //UpdateWorldState(WORLDSTATE_ENEMYCOUNT, EnemyCount); // Let Instance Script handle this + pInstance->SetData(DATA_TRASH, EnemyCount); + if(!Debug) + NextWaveTimer = wave[Count].WaveTimer; + else + { + NextWaveTimer = 15000; + DoTextEmote(": Debug Mode is enabled. Next Wave in 15 seconds", NULL); + } + } + else + { + UpdateWorldState(WORLDSTATE_WAVES, 0); // Set world state for waves to 0 to disable it. + UpdateWorldState(WORLDSTATE_ENEMYCOUNT, 1); // Set World State for enemies invading to 1. + Summon = false; + } + CheckTimer = 5000; +} + +void hyjalAI::StartEvent(Player* player) +{ + if(!player) + return; + + Talk(BEGIN); + + EventBegun = true; + Summon = true; + + NextWaveTimer = 15000; + CheckTimer = 5000; + PlayerGUID = player->GetGUID(); + + m_creature->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP); + + UpdateWorldState(WORLDSTATE_WAVES, 0); + UpdateWorldState(WORLDSTATE_ENEMY, 0); + UpdateWorldState(WORLDSTATE_ENEMYCOUNT, 0); +} + +uint32 hyjalAI::GetInstanceData(uint32 Event) +{ + if(pInstance) + return pInstance->GetData(Event); + else error_log(ERROR_INST_DATA); + + return 0; +} + +void hyjalAI::Talk(uint32 id) +{ + std::list index; + for(uint8 i = 0; i < 10; i++) + { + if(Faction == 0) // Alliance + { + if(JainaQuotes[i].id == id) + index.push_back(i); + } + else if(Faction == 1) // Horde + { + if(ThrallQuotes[i].id == id) + index.push_back(i); + } + } + + if(index.empty()) + return; // No quotes found, no use to continue + + uint8 ind = *(index.begin()) + rand()%index.size(); + + char* Yell = NULL; + uint32 Sound = 0; + if(Faction == 0) // Alliance + { + Yell = JainaQuotes[ind].text; + Sound = JainaQuotes[ind].sound; + } + else if(Faction == 1) // Horde + { + Yell = ThrallQuotes[ind].text; + Sound = ThrallQuotes[ind].sound; + } + + if(Yell) + DoYell(Yell, LANG_UNIVERSAL, NULL); + if(Sound) + DoPlaySoundToSet(m_creature, Sound); +} + +// Slight workaround for now +void hyjalAI::UpdateWorldState(uint32 field, uint32 value) +{ + Map * map = m_creature->GetMap(); + if(!map->IsDungeon()) return; + + WorldPacket data(SMSG_UPDATE_WORLD_STATE, 8); + + data << field; + data << value; + + ((InstanceMap*)map)->SendToPlayers(&data); + + // TODO: Uncomment and remove everything above this line only when the core patch for this is accepted + //m_creature->GetMap()->UpdateWorldState(field, value); +} + +void hyjalAI::Retreat() +{ + CellPair pair(MaNGOS::ComputeCellPair(m_creature->GetPositionX(), m_creature->GetPositionY())); + Cell cell(pair); + cell.data.Part.reserved = ALL_DISTRICT; + cell.SetNoCreate(); + + // First get all creatures. + std::list creatures; + AllFriendlyCreaturesInGrid creature_check(m_creature); + MaNGOS::CreatureListSearcher creature_searcher(creatures, creature_check); + TypeContainerVisitor + , + GridTypeMapContainer> creature_visitor(creature_searcher); + + // Then get all Ancient Gem Veins. NOTE: Grid Search will only be able to find those in the grid. + std::list goList; + AllGameObjectsWithEntryInGrid go_check(185557); + MaNGOS::GameObjectListSearcher go_search(goList, go_check); + TypeContainerVisitor + , GridTypeMapContainer> go_visit(go_search); + + CellLock cell_lock(cell, pair); + // Get Creatures + cell_lock->Visit(cell_lock, creature_visitor, *(m_creature->GetMap())); + // Get GOs + cell_lock->Visit(cell_lock, go_visit, *(m_creature->GetMap())); + + CreatureList.clear(); + if(!creatures.empty()) + { + for(std::list::iterator itr = creatures.begin(); itr != creatures.end(); ++itr) + { + (*itr)->CastSpell(*itr, SPELL_TELEPORT_VISUAL, true); + CreatureList.push_back((*itr)->GetGUID()); + } + + DoCast(m_creature, SPELL_TELEPORT_VISUAL); + bRetreat = true; + RetreatTimer = 1000; + } + + if(!goList.empty()) + { + for(std::list::iterator itr = goList.begin(); itr != goList.end(); ++itr) + (*itr)->SetRespawnTime(5000); + } +} + +void hyjalAI::UpdateAI(const uint32 diff) +{ + if(bRetreat) + if(RetreatTimer < diff) + { + bRetreat = false; + if(CreatureList.empty()) + return; + + for(std::list::iterator itr = CreatureList.begin(); itr != CreatureList.end(); ++itr) + if(Unit* pUnit = Unit::GetUnit(*m_creature, *itr)) + pUnit->SetVisibility(VISIBILITY_OFF); + + m_creature->SetVisibility(VISIBILITY_OFF); + }else RetreatTimer -= diff; + + if(!EventBegun) + return; + + if(Summon) + { + if(pInstance && EnemyCount) + { + EnemyCount = pInstance->GetData(DATA_TRASH); + if(!EnemyCount) + NextWaveTimer = 5000; + } + + if(NextWaveTimer < diff) + { + if(Faction == 0) + SummonNextWave(AllianceWaves, WaveCount, AllianceBase); + else if(Faction == 1) + SummonNextWave(HordeWaves, WaveCount, HordeBase); + ++WaveCount; + }else NextWaveTimer -= diff; + } + + if(CheckTimer < diff) + { + for(uint8 i = 0; i < 2; ++i) + { + if(BossGUID[i]) + { + Unit* pUnit = Unit::GetUnit((*m_creature), BossGUID[i]); + if(pUnit && (!pUnit->isAlive())) + { + if(BossGUID[i] == BossGUID[0]) + { + Talk(INCOMING); + FirstBossDead = true; + } + else if(BossGUID[i] == BossGUID[1]) + { + Talk(SUCCESS); + SecondBossDead = true; + } + EventBegun = false; + CheckTimer = 0; + m_creature->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP); + BossGUID[i] = 0; + UpdateWorldState(WORLDSTATE_ENEMY, 0); // Reset world state for enemies to disable it + } + } + } + CheckTimer = 5000; + }else CheckTimer -= diff; + + if(!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + for(uint8 i = 0; i < 3; ++i) + { + if(Spell[i].SpellId) + { + if(SpellTimer[i] < diff) + { + if(m_creature->IsNonMeleeSpellCasted(false)) + m_creature->InterruptNonMeleeSpells(false); + + Unit* target = NULL; + + switch(Spell[i].TargetType) + { + case TARGETTYPE_SELF: target = m_creature; break; + case TARGETTYPE_RANDOM: target = SelectUnit(SELECT_TARGET_RANDOM, 0); break; + case TARGETTYPE_VICTIM: target = m_creature->getVictim(); break; + } + + if(target && target->isAlive()) + { + DoCast(target, Spell[i].SpellId); + SpellTimer[i] = Spell[i].Cooldown; + } + }else SpellTimer[i] -= diff; + } + } + + DoMeleeAttackIfReady(); +} diff --git a/src/bindings/scripts/scripts/zone/caverns_of_time/hyjal/hyjalAI.h b/src/bindings/scripts/scripts/zone/caverns_of_time/hyjal/hyjalAI.h index 46be6a83879..83ca6c82ce4 100644 --- a/src/bindings/scripts/scripts/zone/caverns_of_time/hyjal/hyjalAI.h +++ b/src/bindings/scripts/scripts/zone/caverns_of_time/hyjal/hyjalAI.h @@ -1,286 +1,286 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software licensed under GPL version 2 - * Please see the included DOCS/LICENSE.TXT for more information */ - -#ifndef SC_HYJALAI_H -#define SC_HYJALAI_H - -#include "def_hyjal.h" - -// Trash Mobs summoned in waves -#define NECROMANCER 17899 -#define ABOMINATION 17898 -#define GHOUL 17895 -#define BANSHEE 17905 -#define CRYPT_FIEND 17897 -#define GARGOYLE 17906 -#define FROST_WYRM 17907 -#define GIANT_INFERNAL 17908 -#define FEL_STALKER 17916 - -// Bosses summoned after every 8 waves -#define RAGE_WINTERCHILL 17767 -#define ANETHERON 17808 -#define KAZROGAL 17888 -#define AZGALOR 17842 -#define ARCHIMONDE 17968 - -#define SPELL_TELEPORT_VISUAL 41232 - -#define WORLDSTATE_WAVES 2842 -#define WORLDSTATE_ENEMY 2453 -#define WORLDSTATE_ENEMYCOUNT 2454 - -/*** Spells for Jaina ***/ -#define SPELL_BRILLIANCE_AURA 31260 // The database must handle this spell via creature_addon -#define SPELL_BLIZZARD 31266 -#define SPELL_PYROBLAST 31263 -#define SPELL_SUMMON_ELEMENTALS 31264 - -/** Thrall spells **/ -#define SPELL_CHAIN_LIGHTNING 31330 -#define SPELL_SUMMON_DIRE_WOLF 31331 - -struct Wave -{ - uint32 Mob[18]; // Stores Creature Entries to be summoned in Waves - uint32 WaveTimer; // The timer before the next wave is summoned - bool IsBoss; // Simply used to inform the wave summoner that the next wave contains a boss to halt all waves after that -}; - -static Wave AllianceWaves[]= // Waves that will be summoned in the Alliance Base -{ - { // Wave 1 - GHOUL, GHOUL, GHOUL, GHOUL, GHOUL, GHOUL, GHOUL, GHOUL, GHOUL, GHOUL, 0, 0, 0, 0, 0, 0, 0, 0, 120000, false - }, - { // Wave 2 - GHOUL, GHOUL, GHOUL, GHOUL, GHOUL, GHOUL, GHOUL, GHOUL, GHOUL, GHOUL, CRYPT_FIEND, CRYPT_FIEND, 0, 0, 0, 0, 0, 0, 120000, false - }, - { // Wave 3 - GHOUL, GHOUL, GHOUL, GHOUL, GHOUL, GHOUL, CRYPT_FIEND, CRYPT_FIEND, CRYPT_FIEND, CRYPT_FIEND, CRYPT_FIEND, CRYPT_FIEND, 0, 0, 0, 0, 0, 0, 120000, false - }, - { // Wave 4 - GHOUL, GHOUL, GHOUL, GHOUL, GHOUL, GHOUL, CRYPT_FIEND, CRYPT_FIEND, CRYPT_FIEND, CRYPT_FIEND, NECROMANCER, NECROMANCER, 0, 0, 0, 0, 0, 0, 120000, false - }, - { // Wave 5 - GHOUL, GHOUL, CRYPT_FIEND, CRYPT_FIEND, CRYPT_FIEND, CRYPT_FIEND, CRYPT_FIEND, CRYPT_FIEND, NECROMANCER, NECROMANCER, NECROMANCER, NECROMANCER, 0, 0, 0, 0, 0, 0, 120000, false - }, - { // Wave 6 - GHOUL, GHOUL, GHOUL, GHOUL, GHOUL, GHOUL, ABOMINATION, ABOMINATION, ABOMINATION, ABOMINATION, ABOMINATION, ABOMINATION, ABOMINATION, 0, 0, 0, 0, 0, 120000, false - }, - { // Wave 7 - GHOUL, GHOUL, GHOUL, GHOUL, NECROMANCER, NECROMANCER, NECROMANCER, NECROMANCER, ABOMINATION, ABOMINATION, ABOMINATION, ABOMINATION, 0, 0, 0, 0, 0, 0, 120000, false - }, - { // Wave 8 - GHOUL, GHOUL, GHOUL, GHOUL, GHOUL, GHOUL, CRYPT_FIEND, CRYPT_FIEND, CRYPT_FIEND, CRYPT_FIEND, ABOMINATION, ABOMINATION, NECROMANCER, NECROMANCER, 0, 0, 0, 0, 180000, false - }, - { // All 8 Waves are summoned, summon Rage Winterchill, next few waves are for Anetheron - RAGE_WINTERCHILL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, true - }, - { // Wave 1 - GHOUL, GHOUL, GHOUL, GHOUL, GHOUL, GHOUL, GHOUL, GHOUL, GHOUL, GHOUL, 0, 0, 0, 0, 0, 0, 0, 0, 120000, false - }, - { // Wave 2 - GHOUL, GHOUL, GHOUL, GHOUL, GHOUL, GHOUL, GHOUL, GHOUL, ABOMINATION, ABOMINATION, ABOMINATION, ABOMINATION, 0, 0, 0, 0, 0, 0, 120000, false - }, - { // Wave 3 - GHOUL, GHOUL, GHOUL, GHOUL, CRYPT_FIEND, CRYPT_FIEND, CRYPT_FIEND, CRYPT_FIEND, NECROMANCER, NECROMANCER, NECROMANCER, NECROMANCER, 0, 0, 0, 0, 0, 0, 120000, false - }, - { // Wave 4 - GHOUL, GHOUL, GHOUL, GHOUL, CRYPT_FIEND, CRYPT_FIEND, CRYPT_FIEND, CRYPT_FIEND, BANSHEE, BANSHEE, BANSHEE, BANSHEE, 0, 0, 0, 0, 0, 0, 120000, false - }, - { // Wave 5 - CRYPT_FIEND, CRYPT_FIEND, CRYPT_FIEND, CRYPT_FIEND, CRYPT_FIEND, CRYPT_FIEND, NECROMANCER, NECROMANCER, BANSHEE, BANSHEE, BANSHEE, BANSHEE, 0, 0, 0, 0, 0, 0, 120000, false - }, - { // Wave 6 - GHOUL, GHOUL, GHOUL, GHOUL, GHOUL, GHOUL, ABOMINATION, ABOMINATION, NECROMANCER, NECROMANCER, NECROMANCER, NECROMANCER, 0, 0, 0, 0, 0, 0, 120000, false - }, - { // Wave 7 - CRYPT_FIEND, CRYPT_FIEND, CRYPT_FIEND, CRYPT_FIEND, BANSHEE, BANSHEE, BANSHEE, BANSHEE, ABOMINATION, ABOMINATION, ABOMINATION, ABOMINATION, 0, 0, 0, 0, 0, 0, 120000, false - }, - { // Wave 8 - GHOUL, GHOUL, GHOUL, ABOMINATION, ABOMINATION, ABOMINATION, ABOMINATION, CRYPT_FIEND, CRYPT_FIEND, CRYPT_FIEND, BANSHEE, BANSHEE, NECROMANCER, NECROMANCER, 0, 0, 0, 0, 180000, false - }, - { // All 8 Waves are summoned, summon Anatheron - ANETHERON, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, true - } -}; - -static Wave HordeWaves[]= // Waves that are summoned in the Horde base -{ - { // Wave 1 - GHOUL, GHOUL, GHOUL, GHOUL, ABOMINATION, ABOMINATION, ABOMINATION, ABOMINATION, BANSHEE, BANSHEE, NECROMANCER, NECROMANCER, 0, 0, 0, 0, 0, 0, 120000, false - }, - { // Wave 2 - GHOUL, GHOUL, GHOUL, GHOUL, GARGOYLE, GARGOYLE, GARGOYLE, GARGOYLE, GARGOYLE, GARGOYLE, GARGOYLE, GARGOYLE, GARGOYLE, GARGOYLE, 0, 0, 0, 0, 120000, false - }, - { // Wave 3 - GHOUL, GHOUL, GHOUL, GHOUL, CRYPT_FIEND, CRYPT_FIEND, CRYPT_FIEND, CRYPT_FIEND, CRYPT_FIEND, CRYPT_FIEND, NECROMANCER, NECROMANCER, NECROMANCER, NECROMANCER, 0, 0, 0, 0, 120000, false - }, - { // Wave 4 - CRYPT_FIEND, CRYPT_FIEND, CRYPT_FIEND, CRYPT_FIEND, CRYPT_FIEND, CRYPT_FIEND, GARGOYLE, GARGOYLE, GARGOYLE, GARGOYLE, GARGOYLE, GARGOYLE, NECROMANCER, NECROMANCER , 0, 0, 0, 0, 120000, false - }, - { // Wave 5 - GHOUL, GHOUL, CRYPT_FIEND, CRYPT_FIEND, CRYPT_FIEND, CRYPT_FIEND, CRYPT_FIEND, CRYPT_FIEND, NECROMANCER, NECROMANCER, NECROMANCER, NECROMANCER, 0, 0, 0, 0, 0, 0, 120000, false - }, - { // Wave 6 - GHOUL, GHOUL, GHOUL, GHOUL, GHOUL, GHOUL, ABOMINATION, ABOMINATION, ABOMINATION, ABOMINATION, ABOMINATION, ABOMINATION, NECROMANCER, NECROMANCER, NECROMANCER, FROST_WYRM, 0, 0, 120000, false - }, - { // Wave 7 - GHOUL, GHOUL, GHOUL, GHOUL, GHOUL, GHOUL, ABOMINATION, ABOMINATION, ABOMINATION, ABOMINATION, ABOMINATION, ABOMINATION, NECROMANCER, NECROMANCER, NECROMANCER, FROST_WYRM, 0, 0, 120000, false - }, - { // Wave 8 - GHOUL, GHOUL, GHOUL, GHOUL, GHOUL, GHOUL, CRYPT_FIEND, CRYPT_FIEND, ABOMINATION, ABOMINATION, ABOMINATION, ABOMINATION, ABOMINATION, ABOMINATION, NECROMANCER, NECROMANCER, BANSHEE, BANSHEE, 180000, false - }, - { // All 8 Waves are summoned, summon Kaz'Rogal, next few waves are for Azgalor - KAZROGAL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, true - }, - { // Wave 1 - ABOMINATION, ABOMINATION, ABOMINATION, ABOMINATION, ABOMINATION, ABOMINATION, NECROMANCER, NECROMANCER, NECROMANCER, NECROMANCER, NECROMANCER, NECROMANCER, 0, 0, 0, 0, 0, 0, 120000, false - }, - { // Wave 2 - GHOUL, GHOUL, GHOUL, GHOUL, GHOUL, FROST_WYRM, GARGOYLE, GARGOYLE, GARGOYLE, GARGOYLE, GARGOYLE, GARGOYLE, GARGOYLE, GARGOYLE, 0, 0, 0, 0, 120000, false - }, - { // Wave 3 - GHOUL, GHOUL, GHOUL, GHOUL, GHOUL, GHOUL, GIANT_INFERNAL, GIANT_INFERNAL, GIANT_INFERNAL, GIANT_INFERNAL, GIANT_INFERNAL, GIANT_INFERNAL, GIANT_INFERNAL, GIANT_INFERNAL, 0, 0, 0, 0, 120000, false - }, - { // Wave 4 - GIANT_INFERNAL, GIANT_INFERNAL, GIANT_INFERNAL, GIANT_INFERNAL, GIANT_INFERNAL, GIANT_INFERNAL, GIANT_INFERNAL, GIANT_INFERNAL, FEL_STALKER, FEL_STALKER, FEL_STALKER, FEL_STALKER, FEL_STALKER, FEL_STALKER, 0, 0, 0, 0, 120000, false - }, - { // Wave 5 - FEL_STALKER, FEL_STALKER, FEL_STALKER, FEL_STALKER, FEL_STALKER, FEL_STALKER, ABOMINATION, ABOMINATION, ABOMINATION, ABOMINATION, NECROMANCER, NECROMANCER, NECROMANCER, NECROMANCER, 0, 0, 0, 0, 120000, false - }, - { // Wave 6 - NECROMANCER, NECROMANCER, NECROMANCER, NECROMANCER, NECROMANCER, NECROMANCER, NECROMANCER, NECROMANCER, BANSHEE, BANSHEE, BANSHEE, BANSHEE, BANSHEE, BANSHEE, 0, 0, 0, 0, 120000, false - }, - { // Wave 7 - GHOUL, GHOUL, CRYPT_FIEND, CRYPT_FIEND, FEL_STALKER, FEL_STALKER, GIANT_INFERNAL, GIANT_INFERNAL, GIANT_INFERNAL, GIANT_INFERNAL, GIANT_INFERNAL, GIANT_INFERNAL, 0, 0, 0, 0, 0, 0, 120000, false - }, - { // Wave 8 - CRYPT_FIEND, CRYPT_FIEND, CRYPT_FIEND, CRYPT_FIEND, FEL_STALKER, FEL_STALKER, ABOMINATION, ABOMINATION, ABOMINATION, ABOMINATION, BANSHEE, BANSHEE, BANSHEE, BANSHEE, NECROMANCER, NECROMANCER, 0, 0, 180000, false - }, - { // All 8 Waves are summoned, summon Azgalor - AZGALOR, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, true - } -}; - -enum TargetType // Used in the spell cast system for the AI -{ - TARGETTYPE_SELF = 0, - TARGETTYPE_RANDOM = 1, - TARGETTYPE_VICTIM = 2, -}; - -struct Yells -{ - uint32 id; // Used to determine the type of yell (attack, rally, etc) - char* text; // The text to be yelled - uint32 sound; // Sound that corresponds to the text -}; - -enum YellId -{ - ATTACKED = 0, // Used when attacked and set in combat - BEGIN = 1, // Used when the event is begun - INCOMING = 2, // Used to warn the raid that another wave phase is coming - RALLY = 3, // Used to rally the raid and warn that the next wave has been summoned - FAILURE = 4, // Used when raid has failed (unsure where to place) - SUCCESS = 5, // Used when the raid has sucessfully defeated a wave phase - DEATH = 6, // Used on death -}; - -static Yells JainaQuotes[]= -{ - {ATTACKED, "I'm in jeopardy, help me if you can!", 11007}, - {ATTACKED, "They've broken through!", 11049}, - {INCOMING, "Stay alert! Another wave approaches.", 11008}, - {BEGIN, "Hold them back as long as possible", 11050}, - {RALLY, "Don't give up! We must prevail!", 11006}, - {RALLY, "We must hold strong!", 11051}, - {FAILURE, "We are lost. Fall back!", 11009}, - {SUCCESS, "We have won valuable time. Now we must pull back!", 11011}, - {DEATH, "I did... my best.", 11010}, -}; - -static Yells ThrallQuotes[]= -{ - {ATTACKED, "I will lie down for no one!", 11031}, - {ATTACKED, "Bring the fight to me and pay with your lives!", 11061}, - {INCOMING, "Make ready for another wave! LOK-TAR OGAR!", 11032}, - {BEGIN, "Do not give an inch of ground!", 11060}, - {RALLY, "Hold them back! Do not falter!", 11030}, - {RALLY, "Victory or death!", 11059}, - {RALLY, "Do not give an inch of ground!", 11060}, - {FAILURE, "It is over. Withdraw! We have failed.", 11033}, - {SUCCESS, "We have played our part and done well. It is up to the others now.", 11035}, - {DEATH, "Uraaa...", 11034}, -}; - -struct MANGOS_DLL_DECL hyjalAI : public ScriptedAI -{ - hyjalAI(Creature *c); - - void Reset(); // Generically used to reset our variables. Do *not* call in EnterEvadeMode as this may make problems if the raid is still in combat - - void EnterEvadeMode(); // Send creature back to spawn location and evade. - - void Aggro(Unit *who); // Used to reset cooldowns for our spells and to inform the raid that we're under attack - - void UpdateAI(const uint32 diff); // Called to summon waves, check for boss deaths and to cast our spells. - - void JustDied(Unit* killer) // Called on death, informs the raid that they have failed. - { - Talk(DEATH); - } - - void SetFaction(uint32 _faction) // Set the faction to either Alliance or Horde in Hyjal - { - Faction = _faction; - } - - void Retreat(); // "Teleport" (teleport visual + set invisible) all friendly creatures away from the base. - - void SummonCreature(uint32 entry, float Base[4][3]); // Summons a creature for that wave in that base - - // Summons the next wave, calls SummonCreature - void SummonNextWave(Wave wave[18], uint32 Count, float Base[4][3]); - - void StartEvent(Player* player); // Begins the event by gossip click - - uint32 GetInstanceData(uint32 Event); // Gets instance data for this instance, used to check if raid has gotten past a certain point and can access the next phase - - void Talk(uint32 id); // Searches for the appropriate yell and sound and uses it to inform the raid of various things - - void UpdateWorldState(uint32 field, uint32 value); // NYI: Requires core support. Updates the world state counter at the top of the UI. - public: - ScriptedInstance* pInstance; - - uint64 PlayerGUID; - uint64 BossGUID[2]; - - uint32 NextWaveTimer; - uint32 WaveCount; - uint32 CheckTimer; - uint32 Faction; - uint32 EnemyCount; - uint32 RetreatTimer; - - bool EventBegun; - bool FirstBossDead; - bool SecondBossDead; - bool Summon; - bool bRetreat; - bool Debug; - - struct Spell - { - uint32 SpellId; - uint32 Cooldown; - uint32 TargetType; - }Spell[3]; - - private: - uint32 SpellTimer[3]; - std::list CreatureList; -}; -#endif +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software licensed under GPL version 2 + * Please see the included DOCS/LICENSE.TXT for more information */ + +#ifndef SC_HYJALAI_H +#define SC_HYJALAI_H + +#include "def_hyjal.h" + +// Trash Mobs summoned in waves +#define NECROMANCER 17899 +#define ABOMINATION 17898 +#define GHOUL 17895 +#define BANSHEE 17905 +#define CRYPT_FIEND 17897 +#define GARGOYLE 17906 +#define FROST_WYRM 17907 +#define GIANT_INFERNAL 17908 +#define FEL_STALKER 17916 + +// Bosses summoned after every 8 waves +#define RAGE_WINTERCHILL 17767 +#define ANETHERON 17808 +#define KAZROGAL 17888 +#define AZGALOR 17842 +#define ARCHIMONDE 17968 + +#define SPELL_TELEPORT_VISUAL 41232 + +#define WORLDSTATE_WAVES 2842 +#define WORLDSTATE_ENEMY 2453 +#define WORLDSTATE_ENEMYCOUNT 2454 + +/*** Spells for Jaina ***/ +#define SPELL_BRILLIANCE_AURA 31260 // The database must handle this spell via creature_addon +#define SPELL_BLIZZARD 31266 +#define SPELL_PYROBLAST 31263 +#define SPELL_SUMMON_ELEMENTALS 31264 + +/** Thrall spells **/ +#define SPELL_CHAIN_LIGHTNING 31330 +#define SPELL_SUMMON_DIRE_WOLF 31331 + +struct Wave +{ + uint32 Mob[18]; // Stores Creature Entries to be summoned in Waves + uint32 WaveTimer; // The timer before the next wave is summoned + bool IsBoss; // Simply used to inform the wave summoner that the next wave contains a boss to halt all waves after that +}; + +static Wave AllianceWaves[]= // Waves that will be summoned in the Alliance Base +{ + { // Wave 1 + GHOUL, GHOUL, GHOUL, GHOUL, GHOUL, GHOUL, GHOUL, GHOUL, GHOUL, GHOUL, 0, 0, 0, 0, 0, 0, 0, 0, 120000, false + }, + { // Wave 2 + GHOUL, GHOUL, GHOUL, GHOUL, GHOUL, GHOUL, GHOUL, GHOUL, GHOUL, GHOUL, CRYPT_FIEND, CRYPT_FIEND, 0, 0, 0, 0, 0, 0, 120000, false + }, + { // Wave 3 + GHOUL, GHOUL, GHOUL, GHOUL, GHOUL, GHOUL, CRYPT_FIEND, CRYPT_FIEND, CRYPT_FIEND, CRYPT_FIEND, CRYPT_FIEND, CRYPT_FIEND, 0, 0, 0, 0, 0, 0, 120000, false + }, + { // Wave 4 + GHOUL, GHOUL, GHOUL, GHOUL, GHOUL, GHOUL, CRYPT_FIEND, CRYPT_FIEND, CRYPT_FIEND, CRYPT_FIEND, NECROMANCER, NECROMANCER, 0, 0, 0, 0, 0, 0, 120000, false + }, + { // Wave 5 + GHOUL, GHOUL, CRYPT_FIEND, CRYPT_FIEND, CRYPT_FIEND, CRYPT_FIEND, CRYPT_FIEND, CRYPT_FIEND, NECROMANCER, NECROMANCER, NECROMANCER, NECROMANCER, 0, 0, 0, 0, 0, 0, 120000, false + }, + { // Wave 6 + GHOUL, GHOUL, GHOUL, GHOUL, GHOUL, GHOUL, ABOMINATION, ABOMINATION, ABOMINATION, ABOMINATION, ABOMINATION, ABOMINATION, ABOMINATION, 0, 0, 0, 0, 0, 120000, false + }, + { // Wave 7 + GHOUL, GHOUL, GHOUL, GHOUL, NECROMANCER, NECROMANCER, NECROMANCER, NECROMANCER, ABOMINATION, ABOMINATION, ABOMINATION, ABOMINATION, 0, 0, 0, 0, 0, 0, 120000, false + }, + { // Wave 8 + GHOUL, GHOUL, GHOUL, GHOUL, GHOUL, GHOUL, CRYPT_FIEND, CRYPT_FIEND, CRYPT_FIEND, CRYPT_FIEND, ABOMINATION, ABOMINATION, NECROMANCER, NECROMANCER, 0, 0, 0, 0, 180000, false + }, + { // All 8 Waves are summoned, summon Rage Winterchill, next few waves are for Anetheron + RAGE_WINTERCHILL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, true + }, + { // Wave 1 + GHOUL, GHOUL, GHOUL, GHOUL, GHOUL, GHOUL, GHOUL, GHOUL, GHOUL, GHOUL, 0, 0, 0, 0, 0, 0, 0, 0, 120000, false + }, + { // Wave 2 + GHOUL, GHOUL, GHOUL, GHOUL, GHOUL, GHOUL, GHOUL, GHOUL, ABOMINATION, ABOMINATION, ABOMINATION, ABOMINATION, 0, 0, 0, 0, 0, 0, 120000, false + }, + { // Wave 3 + GHOUL, GHOUL, GHOUL, GHOUL, CRYPT_FIEND, CRYPT_FIEND, CRYPT_FIEND, CRYPT_FIEND, NECROMANCER, NECROMANCER, NECROMANCER, NECROMANCER, 0, 0, 0, 0, 0, 0, 120000, false + }, + { // Wave 4 + GHOUL, GHOUL, GHOUL, GHOUL, CRYPT_FIEND, CRYPT_FIEND, CRYPT_FIEND, CRYPT_FIEND, BANSHEE, BANSHEE, BANSHEE, BANSHEE, 0, 0, 0, 0, 0, 0, 120000, false + }, + { // Wave 5 + CRYPT_FIEND, CRYPT_FIEND, CRYPT_FIEND, CRYPT_FIEND, CRYPT_FIEND, CRYPT_FIEND, NECROMANCER, NECROMANCER, BANSHEE, BANSHEE, BANSHEE, BANSHEE, 0, 0, 0, 0, 0, 0, 120000, false + }, + { // Wave 6 + GHOUL, GHOUL, GHOUL, GHOUL, GHOUL, GHOUL, ABOMINATION, ABOMINATION, NECROMANCER, NECROMANCER, NECROMANCER, NECROMANCER, 0, 0, 0, 0, 0, 0, 120000, false + }, + { // Wave 7 + CRYPT_FIEND, CRYPT_FIEND, CRYPT_FIEND, CRYPT_FIEND, BANSHEE, BANSHEE, BANSHEE, BANSHEE, ABOMINATION, ABOMINATION, ABOMINATION, ABOMINATION, 0, 0, 0, 0, 0, 0, 120000, false + }, + { // Wave 8 + GHOUL, GHOUL, GHOUL, ABOMINATION, ABOMINATION, ABOMINATION, ABOMINATION, CRYPT_FIEND, CRYPT_FIEND, CRYPT_FIEND, BANSHEE, BANSHEE, NECROMANCER, NECROMANCER, 0, 0, 0, 0, 180000, false + }, + { // All 8 Waves are summoned, summon Anatheron + ANETHERON, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, true + } +}; + +static Wave HordeWaves[]= // Waves that are summoned in the Horde base +{ + { // Wave 1 + GHOUL, GHOUL, GHOUL, GHOUL, ABOMINATION, ABOMINATION, ABOMINATION, ABOMINATION, BANSHEE, BANSHEE, NECROMANCER, NECROMANCER, 0, 0, 0, 0, 0, 0, 120000, false + }, + { // Wave 2 + GHOUL, GHOUL, GHOUL, GHOUL, GARGOYLE, GARGOYLE, GARGOYLE, GARGOYLE, GARGOYLE, GARGOYLE, GARGOYLE, GARGOYLE, GARGOYLE, GARGOYLE, 0, 0, 0, 0, 120000, false + }, + { // Wave 3 + GHOUL, GHOUL, GHOUL, GHOUL, CRYPT_FIEND, CRYPT_FIEND, CRYPT_FIEND, CRYPT_FIEND, CRYPT_FIEND, CRYPT_FIEND, NECROMANCER, NECROMANCER, NECROMANCER, NECROMANCER, 0, 0, 0, 0, 120000, false + }, + { // Wave 4 + CRYPT_FIEND, CRYPT_FIEND, CRYPT_FIEND, CRYPT_FIEND, CRYPT_FIEND, CRYPT_FIEND, GARGOYLE, GARGOYLE, GARGOYLE, GARGOYLE, GARGOYLE, GARGOYLE, NECROMANCER, NECROMANCER , 0, 0, 0, 0, 120000, false + }, + { // Wave 5 + GHOUL, GHOUL, CRYPT_FIEND, CRYPT_FIEND, CRYPT_FIEND, CRYPT_FIEND, CRYPT_FIEND, CRYPT_FIEND, NECROMANCER, NECROMANCER, NECROMANCER, NECROMANCER, 0, 0, 0, 0, 0, 0, 120000, false + }, + { // Wave 6 + GHOUL, GHOUL, GHOUL, GHOUL, GHOUL, GHOUL, ABOMINATION, ABOMINATION, ABOMINATION, ABOMINATION, ABOMINATION, ABOMINATION, NECROMANCER, NECROMANCER, NECROMANCER, FROST_WYRM, 0, 0, 120000, false + }, + { // Wave 7 + GHOUL, GHOUL, GHOUL, GHOUL, GHOUL, GHOUL, ABOMINATION, ABOMINATION, ABOMINATION, ABOMINATION, ABOMINATION, ABOMINATION, NECROMANCER, NECROMANCER, NECROMANCER, FROST_WYRM, 0, 0, 120000, false + }, + { // Wave 8 + GHOUL, GHOUL, GHOUL, GHOUL, GHOUL, GHOUL, CRYPT_FIEND, CRYPT_FIEND, ABOMINATION, ABOMINATION, ABOMINATION, ABOMINATION, ABOMINATION, ABOMINATION, NECROMANCER, NECROMANCER, BANSHEE, BANSHEE, 180000, false + }, + { // All 8 Waves are summoned, summon Kaz'Rogal, next few waves are for Azgalor + KAZROGAL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, true + }, + { // Wave 1 + ABOMINATION, ABOMINATION, ABOMINATION, ABOMINATION, ABOMINATION, ABOMINATION, NECROMANCER, NECROMANCER, NECROMANCER, NECROMANCER, NECROMANCER, NECROMANCER, 0, 0, 0, 0, 0, 0, 120000, false + }, + { // Wave 2 + GHOUL, GHOUL, GHOUL, GHOUL, GHOUL, FROST_WYRM, GARGOYLE, GARGOYLE, GARGOYLE, GARGOYLE, GARGOYLE, GARGOYLE, GARGOYLE, GARGOYLE, 0, 0, 0, 0, 120000, false + }, + { // Wave 3 + GHOUL, GHOUL, GHOUL, GHOUL, GHOUL, GHOUL, GIANT_INFERNAL, GIANT_INFERNAL, GIANT_INFERNAL, GIANT_INFERNAL, GIANT_INFERNAL, GIANT_INFERNAL, GIANT_INFERNAL, GIANT_INFERNAL, 0, 0, 0, 0, 120000, false + }, + { // Wave 4 + GIANT_INFERNAL, GIANT_INFERNAL, GIANT_INFERNAL, GIANT_INFERNAL, GIANT_INFERNAL, GIANT_INFERNAL, GIANT_INFERNAL, GIANT_INFERNAL, FEL_STALKER, FEL_STALKER, FEL_STALKER, FEL_STALKER, FEL_STALKER, FEL_STALKER, 0, 0, 0, 0, 120000, false + }, + { // Wave 5 + FEL_STALKER, FEL_STALKER, FEL_STALKER, FEL_STALKER, FEL_STALKER, FEL_STALKER, ABOMINATION, ABOMINATION, ABOMINATION, ABOMINATION, NECROMANCER, NECROMANCER, NECROMANCER, NECROMANCER, 0, 0, 0, 0, 120000, false + }, + { // Wave 6 + NECROMANCER, NECROMANCER, NECROMANCER, NECROMANCER, NECROMANCER, NECROMANCER, NECROMANCER, NECROMANCER, BANSHEE, BANSHEE, BANSHEE, BANSHEE, BANSHEE, BANSHEE, 0, 0, 0, 0, 120000, false + }, + { // Wave 7 + GHOUL, GHOUL, CRYPT_FIEND, CRYPT_FIEND, FEL_STALKER, FEL_STALKER, GIANT_INFERNAL, GIANT_INFERNAL, GIANT_INFERNAL, GIANT_INFERNAL, GIANT_INFERNAL, GIANT_INFERNAL, 0, 0, 0, 0, 0, 0, 120000, false + }, + { // Wave 8 + CRYPT_FIEND, CRYPT_FIEND, CRYPT_FIEND, CRYPT_FIEND, FEL_STALKER, FEL_STALKER, ABOMINATION, ABOMINATION, ABOMINATION, ABOMINATION, BANSHEE, BANSHEE, BANSHEE, BANSHEE, NECROMANCER, NECROMANCER, 0, 0, 180000, false + }, + { // All 8 Waves are summoned, summon Azgalor + AZGALOR, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, true + } +}; + +enum TargetType // Used in the spell cast system for the AI +{ + TARGETTYPE_SELF = 0, + TARGETTYPE_RANDOM = 1, + TARGETTYPE_VICTIM = 2, +}; + +struct Yells +{ + uint32 id; // Used to determine the type of yell (attack, rally, etc) + char* text; // The text to be yelled + uint32 sound; // Sound that corresponds to the text +}; + +enum YellId +{ + ATTACKED = 0, // Used when attacked and set in combat + BEGIN = 1, // Used when the event is begun + INCOMING = 2, // Used to warn the raid that another wave phase is coming + RALLY = 3, // Used to rally the raid and warn that the next wave has been summoned + FAILURE = 4, // Used when raid has failed (unsure where to place) + SUCCESS = 5, // Used when the raid has sucessfully defeated a wave phase + DEATH = 6, // Used on death +}; + +static Yells JainaQuotes[]= +{ + {ATTACKED, "I'm in jeopardy, help me if you can!", 11007}, + {ATTACKED, "They've broken through!", 11049}, + {INCOMING, "Stay alert! Another wave approaches.", 11008}, + {BEGIN, "Hold them back as long as possible", 11050}, + {RALLY, "Don't give up! We must prevail!", 11006}, + {RALLY, "We must hold strong!", 11051}, + {FAILURE, "We are lost. Fall back!", 11009}, + {SUCCESS, "We have won valuable time. Now we must pull back!", 11011}, + {DEATH, "I did... my best.", 11010}, +}; + +static Yells ThrallQuotes[]= +{ + {ATTACKED, "I will lie down for no one!", 11031}, + {ATTACKED, "Bring the fight to me and pay with your lives!", 11061}, + {INCOMING, "Make ready for another wave! LOK-TAR OGAR!", 11032}, + {BEGIN, "Do not give an inch of ground!", 11060}, + {RALLY, "Hold them back! Do not falter!", 11030}, + {RALLY, "Victory or death!", 11059}, + {RALLY, "Do not give an inch of ground!", 11060}, + {FAILURE, "It is over. Withdraw! We have failed.", 11033}, + {SUCCESS, "We have played our part and done well. It is up to the others now.", 11035}, + {DEATH, "Uraaa...", 11034}, +}; + +struct MANGOS_DLL_DECL hyjalAI : public ScriptedAI +{ + hyjalAI(Creature *c); + + void Reset(); // Generically used to reset our variables. Do *not* call in EnterEvadeMode as this may make problems if the raid is still in combat + + void EnterEvadeMode(); // Send creature back to spawn location and evade. + + void Aggro(Unit *who); // Used to reset cooldowns for our spells and to inform the raid that we're under attack + + void UpdateAI(const uint32 diff); // Called to summon waves, check for boss deaths and to cast our spells. + + void JustDied(Unit* killer) // Called on death, informs the raid that they have failed. + { + Talk(DEATH); + } + + void SetFaction(uint32 _faction) // Set the faction to either Alliance or Horde in Hyjal + { + Faction = _faction; + } + + void Retreat(); // "Teleport" (teleport visual + set invisible) all friendly creatures away from the base. + + void SummonCreature(uint32 entry, float Base[4][3]); // Summons a creature for that wave in that base + + // Summons the next wave, calls SummonCreature + void SummonNextWave(Wave wave[18], uint32 Count, float Base[4][3]); + + void StartEvent(Player* player); // Begins the event by gossip click + + uint32 GetInstanceData(uint32 Event); // Gets instance data for this instance, used to check if raid has gotten past a certain point and can access the next phase + + void Talk(uint32 id); // Searches for the appropriate yell and sound and uses it to inform the raid of various things + + void UpdateWorldState(uint32 field, uint32 value); // NYI: Requires core support. Updates the world state counter at the top of the UI. + public: + ScriptedInstance* pInstance; + + uint64 PlayerGUID; + uint64 BossGUID[2]; + + uint32 NextWaveTimer; + uint32 WaveCount; + uint32 CheckTimer; + uint32 Faction; + uint32 EnemyCount; + uint32 RetreatTimer; + + bool EventBegun; + bool FirstBossDead; + bool SecondBossDead; + bool Summon; + bool bRetreat; + bool Debug; + + struct Spell + { + uint32 SpellId; + uint32 Cooldown; + uint32 TargetType; + }Spell[3]; + + private: + uint32 SpellTimer[3]; + std::list CreatureList; +}; +#endif diff --git a/src/bindings/scripts/scripts/zone/caverns_of_time/hyjal/instance_hyjal.cpp b/src/bindings/scripts/scripts/zone/caverns_of_time/hyjal/instance_hyjal.cpp index 796069ba81f..349a1e6efff 100644 --- a/src/bindings/scripts/scripts/zone/caverns_of_time/hyjal/instance_hyjal.cpp +++ b/src/bindings/scripts/scripts/zone/caverns_of_time/hyjal/instance_hyjal.cpp @@ -1,203 +1,203 @@ -/* Copyright (C) 2006,2007 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Instance_Mount_Hyjal -SD%Complete: 100 -SDComment: Instance Data Scripts and functions to acquire mobs and set encounter status for use in various Hyjal Scripts -SDCategory: Caverns of Time, Mount Hyjal -EndScriptData */ - -#include "precompiled.h" -#include "def_hyjal.h" -#include "WorldPacket.h" - -#define ENCOUNTERS 5 - -/* Battle of Mount Hyjal encounters: -0 - Rage Winterchill event -1 - Anetheron event -2 - Kaz'rogal event -3 - Azgalor event -4 - Archimonde event -*/ - -struct MANGOS_DLL_DECL instance_mount_hyjal : public ScriptedInstance -{ - instance_mount_hyjal(Map *Map) : ScriptedInstance(Map) {Initialize();}; - - uint64 RageWinterchill; - uint64 Anetheron; - uint64 Kazrogal; - uint64 Azgalor; - uint64 Archimonde; - uint64 JainaProudmoore; - uint64 Thrall; - uint64 TyrandeWhisperwind; - - uint32 Trash; - uint32 Encounters[ENCOUNTERS]; - - void Initialize() - { - RageWinterchill = 0; - Anetheron = 0; - Kazrogal = 0; - Azgalor = 0; - Archimonde = 0; - JainaProudmoore = 0; - Thrall = 0; - TyrandeWhisperwind = 0; - - Trash = 0; - for(uint8 i = 0; i < ENCOUNTERS; ++i) - Encounters[i] = NOT_STARTED; - } - - bool IsEncounterInProgress() const - { - for(uint8 i = 0; i < ENCOUNTERS; ++i) - if(Encounters[i] == IN_PROGRESS) return true; - - return false; - } - - void OnCreatureCreate(Creature *creature, uint32 creature_entry) - { - switch(creature_entry) - { - case 17767: RageWinterchill = creature->GetGUID(); break; - case 17808: Anetheron = creature->GetGUID(); break; - case 17888: Kazrogal = creature->GetGUID(); break; - case 17842: Azgalor = creature->GetGUID(); break; - case 17968: Archimonde = creature->GetGUID(); break; - case 17772: JainaProudmoore = creature->GetGUID(); break; - case 17852: Thrall = creature->GetGUID(); break; - case 17948: TyrandeWhisperwind = creature->GetGUID(); break; - } - } - - uint64 GetData64(uint32 identifier) - { - switch(identifier) - { - case DATA_RAGEWINTERCHILL: return RageWinterchill; - case DATA_ANETHERON: return Anetheron; - case DATA_KAZROGAL: return Kazrogal; - case DATA_AZGALOR: return Azgalor; - case DATA_ARCHIMONDE: return Archimonde; - case DATA_JAINAPROUDMOORE: return JainaProudmoore; - case DATA_THRALL: return Thrall; - case DATA_TYRANDEWHISPERWIND: return TyrandeWhisperwind; - } - - return 0; - } - - void SetData(uint32 type, uint32 data) - { - switch(type) - { - case DATA_RAGEWINTERCHILLEVENT: Encounters[0] = data; break; - case DATA_ANETHERONEVENT: Encounters[1] = data; break; - case DATA_KAZROGALEVENT: Encounters[2] = data; break; - case DATA_AZGALOREVENT: Encounters[3] = data; break; - case DATA_ARCHIMONDEEVENT: Encounters[4] = data; break; - case DATA_RESET_TRASH_COUNT: Trash = 0; break; - - case DATA_TRASH: - if(data) Trash = data; - else Trash--; - UpdateWorldState(2453, data); - break; - } - - if(data == DONE) - SaveToDB(); - } - - uint32 GetData(uint32 type) - { - switch(type) - { - case DATA_RAGEWINTERCHILLEVENT: return Encounters[0]; - case DATA_ANETHERONEVENT: return Encounters[1]; - case DATA_KAZROGALEVENT: return Encounters[2]; - case DATA_AZGALOREVENT: return Encounters[3]; - case DATA_ARCHIMONDEEVENT: return Encounters[4]; - case DATA_TRASH: return Trash; - } - return 0; - } - - void UpdateWorldState(uint32 field, uint32 value) - { - WorldPacket data(SMSG_UPDATE_WORLD_STATE, 8); - data << field; - data << value; - - ((InstanceMap*)instance)->SendToPlayers(&data); - } - - const char* Save() - { - OUT_SAVE_INST_DATA; - std::ostringstream stream; - stream << Encounters[0] << " " << Encounters[1] << " " - << Encounters[2] << " " << Encounters[3] << " " - << Encounters[4]; - char* out = new char[stream.str().length() + 1]; - strcpy(out, stream.str().c_str()); - if(out) - { - OUT_SAVE_INST_DATA_COMPLETE; - return out; - } - - return NULL; - } - - void Load(const char* load) - { - if(!load) - { - OUT_LOAD_INST_DATA_FAIL; - return; - } - - OUT_LOAD_INST_DATA(load); - std::istringstream stream; - stream >> Encounters[1] >> Encounters[2] >> Encounters[3] >> Encounters[4]; - for(uint8 i = 0; i < ENCOUNTERS; ++i) - if(Encounters[i] == IN_PROGRESS) // Do not load an encounter as IN_PROGRESS - reset it instead. - Encounters[i] = NOT_STARTED; - OUT_LOAD_INST_DATA_COMPLETE; - } -}; - -InstanceData* GetInstanceData_instance_mount_hyjal(Map* map) -{ - return new instance_mount_hyjal(map); -} - -void AddSC_instance_mount_hyjal() -{ - Script *newscript; - newscript = new Script; - newscript->Name = "instance_hyjal"; - newscript->GetInstanceData = GetInstanceData_instance_mount_hyjal; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006,2007 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Instance_Mount_Hyjal +SD%Complete: 100 +SDComment: Instance Data Scripts and functions to acquire mobs and set encounter status for use in various Hyjal Scripts +SDCategory: Caverns of Time, Mount Hyjal +EndScriptData */ + +#include "precompiled.h" +#include "def_hyjal.h" +#include "WorldPacket.h" + +#define ENCOUNTERS 5 + +/* Battle of Mount Hyjal encounters: +0 - Rage Winterchill event +1 - Anetheron event +2 - Kaz'rogal event +3 - Azgalor event +4 - Archimonde event +*/ + +struct MANGOS_DLL_DECL instance_mount_hyjal : public ScriptedInstance +{ + instance_mount_hyjal(Map *Map) : ScriptedInstance(Map) {Initialize();}; + + uint64 RageWinterchill; + uint64 Anetheron; + uint64 Kazrogal; + uint64 Azgalor; + uint64 Archimonde; + uint64 JainaProudmoore; + uint64 Thrall; + uint64 TyrandeWhisperwind; + + uint32 Trash; + uint32 Encounters[ENCOUNTERS]; + + void Initialize() + { + RageWinterchill = 0; + Anetheron = 0; + Kazrogal = 0; + Azgalor = 0; + Archimonde = 0; + JainaProudmoore = 0; + Thrall = 0; + TyrandeWhisperwind = 0; + + Trash = 0; + for(uint8 i = 0; i < ENCOUNTERS; ++i) + Encounters[i] = NOT_STARTED; + } + + bool IsEncounterInProgress() const + { + for(uint8 i = 0; i < ENCOUNTERS; ++i) + if(Encounters[i] == IN_PROGRESS) return true; + + return false; + } + + void OnCreatureCreate(Creature *creature, uint32 creature_entry) + { + switch(creature_entry) + { + case 17767: RageWinterchill = creature->GetGUID(); break; + case 17808: Anetheron = creature->GetGUID(); break; + case 17888: Kazrogal = creature->GetGUID(); break; + case 17842: Azgalor = creature->GetGUID(); break; + case 17968: Archimonde = creature->GetGUID(); break; + case 17772: JainaProudmoore = creature->GetGUID(); break; + case 17852: Thrall = creature->GetGUID(); break; + case 17948: TyrandeWhisperwind = creature->GetGUID(); break; + } + } + + uint64 GetData64(uint32 identifier) + { + switch(identifier) + { + case DATA_RAGEWINTERCHILL: return RageWinterchill; + case DATA_ANETHERON: return Anetheron; + case DATA_KAZROGAL: return Kazrogal; + case DATA_AZGALOR: return Azgalor; + case DATA_ARCHIMONDE: return Archimonde; + case DATA_JAINAPROUDMOORE: return JainaProudmoore; + case DATA_THRALL: return Thrall; + case DATA_TYRANDEWHISPERWIND: return TyrandeWhisperwind; + } + + return 0; + } + + void SetData(uint32 type, uint32 data) + { + switch(type) + { + case DATA_RAGEWINTERCHILLEVENT: Encounters[0] = data; break; + case DATA_ANETHERONEVENT: Encounters[1] = data; break; + case DATA_KAZROGALEVENT: Encounters[2] = data; break; + case DATA_AZGALOREVENT: Encounters[3] = data; break; + case DATA_ARCHIMONDEEVENT: Encounters[4] = data; break; + case DATA_RESET_TRASH_COUNT: Trash = 0; break; + + case DATA_TRASH: + if(data) Trash = data; + else Trash--; + UpdateWorldState(2453, data); + break; + } + + if(data == DONE) + SaveToDB(); + } + + uint32 GetData(uint32 type) + { + switch(type) + { + case DATA_RAGEWINTERCHILLEVENT: return Encounters[0]; + case DATA_ANETHERONEVENT: return Encounters[1]; + case DATA_KAZROGALEVENT: return Encounters[2]; + case DATA_AZGALOREVENT: return Encounters[3]; + case DATA_ARCHIMONDEEVENT: return Encounters[4]; + case DATA_TRASH: return Trash; + } + return 0; + } + + void UpdateWorldState(uint32 field, uint32 value) + { + WorldPacket data(SMSG_UPDATE_WORLD_STATE, 8); + data << field; + data << value; + + ((InstanceMap*)instance)->SendToPlayers(&data); + } + + const char* Save() + { + OUT_SAVE_INST_DATA; + std::ostringstream stream; + stream << Encounters[0] << " " << Encounters[1] << " " + << Encounters[2] << " " << Encounters[3] << " " + << Encounters[4]; + char* out = new char[stream.str().length() + 1]; + strcpy(out, stream.str().c_str()); + if(out) + { + OUT_SAVE_INST_DATA_COMPLETE; + return out; + } + + return NULL; + } + + void Load(const char* load) + { + if(!load) + { + OUT_LOAD_INST_DATA_FAIL; + return; + } + + OUT_LOAD_INST_DATA(load); + std::istringstream stream; + stream >> Encounters[1] >> Encounters[2] >> Encounters[3] >> Encounters[4]; + for(uint8 i = 0; i < ENCOUNTERS; ++i) + if(Encounters[i] == IN_PROGRESS) // Do not load an encounter as IN_PROGRESS - reset it instead. + Encounters[i] = NOT_STARTED; + OUT_LOAD_INST_DATA_COMPLETE; + } +}; + +InstanceData* GetInstanceData_instance_mount_hyjal(Map* map) +{ + return new instance_mount_hyjal(map); +} + +void AddSC_instance_mount_hyjal() +{ + Script *newscript; + newscript = new Script; + newscript->Name = "instance_hyjal"; + newscript->GetInstanceData = GetInstanceData_instance_mount_hyjal; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/caverns_of_time/old_hillsbrad/boss_captain_skarloc.cpp b/src/bindings/scripts/scripts/zone/caverns_of_time/old_hillsbrad/boss_captain_skarloc.cpp index 2dbb79b02a1..9882368a735 100644 --- a/src/bindings/scripts/scripts/zone/caverns_of_time/old_hillsbrad/boss_captain_skarloc.cpp +++ b/src/bindings/scripts/scripts/zone/caverns_of_time/old_hillsbrad/boss_captain_skarloc.cpp @@ -1,177 +1,177 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Captain_Skarloc -SD%Complete: 75 -SDComment: Missing adds, missing waypoints to move up to Thrall once spawned + speech before enter combat. -SDCategory: Caverns of Time, Old Hillsbrad Foothills -EndScriptData */ - -#include "precompiled.h" -#include "def_old_hillsbrad.h" - -#define HOLY_LIGHT 29562 -#define CLEANSE 39078 -#define HAMMER_OF_JUSTICE 13005 -#define HOLY_SHIELD 31904 -#define DEVOTION_AURA 41452 -#define CONSECRATION 41541 - -#define SAY_ENTER "Thrall! You didn't really think you would escape did you? You and your allies shall answer to Blackmoore - after I've had my fun!" -#define SAY_AGGRO1 "You're a slave. That's all you'll ever be.'" -#define SAY_AGGRO2 "I don't know what Blackmoore sees in you. For my money, you're just another ignorant savage!" -#define SAY_SLAY1 "Thrall will never be free!" -#define SAY_SLAY2 "Did you really think you would leave here alive?" -#define SAY_DEATH "Guards! Urgh..Guards..!'" - -#define SOUND_ENTER 10406 -#define SOUND_AGGRO1 10407 -#define SOUND_AGGRO2 10408 -#define SOUND_SLAY1 10409 -#define SOUND_SLAY2 10410 -#define SOUND_DEATH 10411 - -struct MANGOS_DLL_DECL boss_captain_skarlocAI : public ScriptedAI -{ - boss_captain_skarlocAI(Creature *c) : ScriptedAI(c) - { - pInstance = ((ScriptedInstance*)c->GetInstanceData()); - Reset(); - } - - ScriptedInstance *pInstance; - - uint32 Holy_Light_Timer; - uint32 Cleanse_Timer; - uint32 HammerOfJustice_Timer; - uint32 HolyShield_Timer; - uint32 DevotionAura_Timer; - uint32 Consecration_Timer; - - void Reset() - { - Holy_Light_Timer = 30000; - Cleanse_Timer = 10000; - HammerOfJustice_Timer = 60000; - HolyShield_Timer = 240000; - DevotionAura_Timer = 60000; - Consecration_Timer = 8000; - } - - void Aggro(Unit *who) - { - switch(rand()%2) - { - case 0: - DoYell(SAY_AGGRO1,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature, SOUND_AGGRO1); - break; - case 1: - DoYell(SAY_AGGRO2,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature, SOUND_AGGRO2); - break; - } - } - - void KilledUnit(Unit *victim) - { - switch(rand()%2) - { - case 0: - DoYell(SAY_SLAY1,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature, SOUND_SLAY1); - break; - case 1: - DoYell(SAY_SLAY2,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature, SOUND_SLAY2); - break; - } - } - - void JustDied(Unit *victim) - { - DoYell(SAY_DEATH,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature, SOUND_DEATH); - if( pInstance && pInstance->GetData(TYPE_THRALL_EVENT) == IN_PROGRESS ) - pInstance->SetData(TYPE_THRALL_PART1, DONE); - } - - void UpdateAI(const uint32 diff) - { - //Return since we have no target - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - //Holy_Light - if (Holy_Light_Timer < diff) - { - DoCast(m_creature, HOLY_LIGHT); - Holy_Light_Timer = 30000; - }else Holy_Light_Timer -= diff; - - //Cleanse - if(Cleanse_Timer < diff) - { - DoCast(m_creature, CLEANSE); - Cleanse_Timer = 10000 ; - } else Cleanse_Timer -= diff; - - //Hammer of Justice - if (HammerOfJustice_Timer < diff) - { - DoCast(m_creature->getVictim(), HAMMER_OF_JUSTICE); - HammerOfJustice_Timer = 60000; - }else HammerOfJustice_Timer -= diff; - - //Holy Shield - if (HolyShield_Timer < diff) - { - DoCast(m_creature,HOLY_SHIELD); - HolyShield_Timer = 240000; - }else HolyShield_Timer -= diff; - - //Devotion_Aura - if (DevotionAura_Timer < diff) - { - DoCast(m_creature,DEVOTION_AURA); - DevotionAura_Timer = 60000; - }else DevotionAura_Timer -= diff; - - //Consecration - if (Consecration_Timer < diff) - { - //DoCast(m_creature->getVictim(),CONSECRATION); - Consecration_Timer = 8000; - }else Consecration_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; - -CreatureAI* GetAI_boss_captain_skarloc(Creature *_Creature) -{ - return new boss_captain_skarlocAI (_Creature); -} - -void AddSC_boss_captain_skarloc() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_captain_skarloc"; - newscript->GetAI = GetAI_boss_captain_skarloc; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Captain_Skarloc +SD%Complete: 75 +SDComment: Missing adds, missing waypoints to move up to Thrall once spawned + speech before enter combat. +SDCategory: Caverns of Time, Old Hillsbrad Foothills +EndScriptData */ + +#include "precompiled.h" +#include "def_old_hillsbrad.h" + +#define HOLY_LIGHT 29562 +#define CLEANSE 39078 +#define HAMMER_OF_JUSTICE 13005 +#define HOLY_SHIELD 31904 +#define DEVOTION_AURA 41452 +#define CONSECRATION 41541 + +#define SAY_ENTER "Thrall! You didn't really think you would escape did you? You and your allies shall answer to Blackmoore - after I've had my fun!" +#define SAY_AGGRO1 "You're a slave. That's all you'll ever be.'" +#define SAY_AGGRO2 "I don't know what Blackmoore sees in you. For my money, you're just another ignorant savage!" +#define SAY_SLAY1 "Thrall will never be free!" +#define SAY_SLAY2 "Did you really think you would leave here alive?" +#define SAY_DEATH "Guards! Urgh..Guards..!'" + +#define SOUND_ENTER 10406 +#define SOUND_AGGRO1 10407 +#define SOUND_AGGRO2 10408 +#define SOUND_SLAY1 10409 +#define SOUND_SLAY2 10410 +#define SOUND_DEATH 10411 + +struct MANGOS_DLL_DECL boss_captain_skarlocAI : public ScriptedAI +{ + boss_captain_skarlocAI(Creature *c) : ScriptedAI(c) + { + pInstance = ((ScriptedInstance*)c->GetInstanceData()); + Reset(); + } + + ScriptedInstance *pInstance; + + uint32 Holy_Light_Timer; + uint32 Cleanse_Timer; + uint32 HammerOfJustice_Timer; + uint32 HolyShield_Timer; + uint32 DevotionAura_Timer; + uint32 Consecration_Timer; + + void Reset() + { + Holy_Light_Timer = 30000; + Cleanse_Timer = 10000; + HammerOfJustice_Timer = 60000; + HolyShield_Timer = 240000; + DevotionAura_Timer = 60000; + Consecration_Timer = 8000; + } + + void Aggro(Unit *who) + { + switch(rand()%2) + { + case 0: + DoYell(SAY_AGGRO1,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature, SOUND_AGGRO1); + break; + case 1: + DoYell(SAY_AGGRO2,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature, SOUND_AGGRO2); + break; + } + } + + void KilledUnit(Unit *victim) + { + switch(rand()%2) + { + case 0: + DoYell(SAY_SLAY1,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature, SOUND_SLAY1); + break; + case 1: + DoYell(SAY_SLAY2,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature, SOUND_SLAY2); + break; + } + } + + void JustDied(Unit *victim) + { + DoYell(SAY_DEATH,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature, SOUND_DEATH); + if( pInstance && pInstance->GetData(TYPE_THRALL_EVENT) == IN_PROGRESS ) + pInstance->SetData(TYPE_THRALL_PART1, DONE); + } + + void UpdateAI(const uint32 diff) + { + //Return since we have no target + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + //Holy_Light + if (Holy_Light_Timer < diff) + { + DoCast(m_creature, HOLY_LIGHT); + Holy_Light_Timer = 30000; + }else Holy_Light_Timer -= diff; + + //Cleanse + if(Cleanse_Timer < diff) + { + DoCast(m_creature, CLEANSE); + Cleanse_Timer = 10000 ; + } else Cleanse_Timer -= diff; + + //Hammer of Justice + if (HammerOfJustice_Timer < diff) + { + DoCast(m_creature->getVictim(), HAMMER_OF_JUSTICE); + HammerOfJustice_Timer = 60000; + }else HammerOfJustice_Timer -= diff; + + //Holy Shield + if (HolyShield_Timer < diff) + { + DoCast(m_creature,HOLY_SHIELD); + HolyShield_Timer = 240000; + }else HolyShield_Timer -= diff; + + //Devotion_Aura + if (DevotionAura_Timer < diff) + { + DoCast(m_creature,DEVOTION_AURA); + DevotionAura_Timer = 60000; + }else DevotionAura_Timer -= diff; + + //Consecration + if (Consecration_Timer < diff) + { + //DoCast(m_creature->getVictim(),CONSECRATION); + Consecration_Timer = 8000; + }else Consecration_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; + +CreatureAI* GetAI_boss_captain_skarloc(Creature *_Creature) +{ + return new boss_captain_skarlocAI (_Creature); +} + +void AddSC_boss_captain_skarloc() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_captain_skarloc"; + newscript->GetAI = GetAI_boss_captain_skarloc; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/caverns_of_time/old_hillsbrad/boss_epoch_hunter.cpp b/src/bindings/scripts/scripts/zone/caverns_of_time/old_hillsbrad/boss_epoch_hunter.cpp index bbcaec53407..0222a6c2955 100644 --- a/src/bindings/scripts/scripts/zone/caverns_of_time/old_hillsbrad/boss_epoch_hunter.cpp +++ b/src/bindings/scripts/scripts/zone/caverns_of_time/old_hillsbrad/boss_epoch_hunter.cpp @@ -1,183 +1,183 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Epoch_Hunter -SD%Complete: 60 -SDComment: Missing spawns pre-event, missing speech to be coordinated with rest of escort event. -SDCategory: Caverns of Time, Old Hillsbrad Foothills -EndScriptData */ - -#include "precompiled.h" -#include "def_old_hillsbrad.h" - -#define SAY_ENTER1 "Thrall! Come outside and face your fate!" -#define SOUND_ENTER1 10418 -#define SAY_ENTER2 "Taretha's life hangs in the balance. Surely you care for her. Surely you wish to save her..." -#define SOUND_ENTER2 10419 -#define SAY_ENTER3 "Ah, there you are. I had hoped to accomplish this with a bit of subtlety, but I suppose direct confrontation was inevitable. Your future, Thrall, must not come to pass and so...you and your troublesome friends must die!" -#define SOUND_ENTER3 10420 - -#define SAY_AGGRO1 "Enough! I will erase your very existence!" -#define SOUND_AGGRO1 10421 -#define SAY_AGGRO2 "You cannot fight fate!" -#define SOUND_AGGRO2 10422 - -#define SAY_SLAY1 "You are...irrelevant." -#define SOUND_SLAY1 10425 -#define SAY_SLAY2 "Thrall will remain a slave. Taretha will die. You have failed." -#define SOUND_SLAY2 10426 - -#define SAY_BREATH1 "Not so fast!" -#define SOUND_BREATH1 10423 -#define SAY_BREATH2 "Struggle as much as you like!" -#define SOUND_BREATH2 10424 - -#define SAY_DEATH "No!...The master... will not... be pleased." -#define SOUND_DEATH 10427 - -#define SPELL_SAND_BREATH 31914 -#define SPELL_IMPENDING_DEATH 31916 -#define SPELL_MAGIC_DISRUPTION_AURA 33834 -#define SPELL_WING_BUFFET 31475 - -struct MANGOS_DLL_DECL boss_epoch_hunterAI : public ScriptedAI -{ - boss_epoch_hunterAI(Creature *c) : ScriptedAI(c) - { - pInstance = ((ScriptedInstance*)c->GetInstanceData()); - Reset(); - } - - ScriptedInstance *pInstance; - - uint32 SandBreath_Timer; - uint32 ImpendingDeath_Timer; - uint32 WingBuffet_Timer; - uint32 Mda_Timer; - - void Reset() - { - SandBreath_Timer = 25000; - ImpendingDeath_Timer = 30000; - WingBuffet_Timer = 35000; - Mda_Timer = 40000; - } - - void Aggro(Unit *who) - { - switch(rand()%2) - { - case 0: - DoYell(SAY_AGGRO1,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature, SOUND_AGGRO1); - break; - case 1: - DoYell(SAY_AGGRO2,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature, SOUND_AGGRO2); - break; - } - } - - void KilledUnit(Unit *victim) - { - switch(rand()%2) - { - case 0: - DoYell(SAY_SLAY1,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature, SOUND_SLAY1); - break; - case 1: - DoYell(SAY_SLAY2,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature, SOUND_SLAY2); - break; - } - } - - void JustDied(Unit *victim) - { - DoYell(SAY_DEATH,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature, SOUND_DEATH); - - if( pInstance && pInstance->GetData(TYPE_THRALL_EVENT) == IN_PROGRESS ) - pInstance->SetData(TYPE_THRALL_PART4, DONE); - } - - void UpdateAI(const uint32 diff) - { - //Return since we have no target - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - //Sand Breath - if( SandBreath_Timer < diff ) - { - if( m_creature->IsNonMeleeSpellCasted(false) ) - m_creature->InterruptNonMeleeSpells(false); - - DoCast(m_creature->getVictim(),SPELL_SAND_BREATH); - - switch(rand()%2) - { - case 0: - DoYell(SAY_BREATH1,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature, SOUND_BREATH1); - break; - case 1: - DoYell(SAY_BREATH2,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature, SOUND_BREATH2); - break; - } - - SandBreath_Timer = 25000+rand()%5000; - }else SandBreath_Timer -= diff; - - if( ImpendingDeath_Timer < diff ) - { - DoCast(m_creature->getVictim(),SPELL_IMPENDING_DEATH); - ImpendingDeath_Timer = 30000+rand()%5000; - }else ImpendingDeath_Timer -= diff; - - if( WingBuffet_Timer < diff ) - { - if( Unit *target = SelectUnit(SELECT_TARGET_RANDOM,0) ) - DoCast(target,SPELL_WING_BUFFET); - WingBuffet_Timer = 25000+rand()%10000; - }else WingBuffet_Timer -= diff; - - if( Mda_Timer < diff ) - { - DoCast(m_creature,SPELL_MAGIC_DISRUPTION_AURA); - Mda_Timer = 15000; - }else Mda_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; - -CreatureAI* GetAI_boss_epoch_hunter(Creature *_Creature) -{ - return new boss_epoch_hunterAI (_Creature); -} - -void AddSC_boss_epoch_hunter() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_epoch_hunter"; - newscript->GetAI = GetAI_boss_epoch_hunter; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Epoch_Hunter +SD%Complete: 60 +SDComment: Missing spawns pre-event, missing speech to be coordinated with rest of escort event. +SDCategory: Caverns of Time, Old Hillsbrad Foothills +EndScriptData */ + +#include "precompiled.h" +#include "def_old_hillsbrad.h" + +#define SAY_ENTER1 "Thrall! Come outside and face your fate!" +#define SOUND_ENTER1 10418 +#define SAY_ENTER2 "Taretha's life hangs in the balance. Surely you care for her. Surely you wish to save her..." +#define SOUND_ENTER2 10419 +#define SAY_ENTER3 "Ah, there you are. I had hoped to accomplish this with a bit of subtlety, but I suppose direct confrontation was inevitable. Your future, Thrall, must not come to pass and so...you and your troublesome friends must die!" +#define SOUND_ENTER3 10420 + +#define SAY_AGGRO1 "Enough! I will erase your very existence!" +#define SOUND_AGGRO1 10421 +#define SAY_AGGRO2 "You cannot fight fate!" +#define SOUND_AGGRO2 10422 + +#define SAY_SLAY1 "You are...irrelevant." +#define SOUND_SLAY1 10425 +#define SAY_SLAY2 "Thrall will remain a slave. Taretha will die. You have failed." +#define SOUND_SLAY2 10426 + +#define SAY_BREATH1 "Not so fast!" +#define SOUND_BREATH1 10423 +#define SAY_BREATH2 "Struggle as much as you like!" +#define SOUND_BREATH2 10424 + +#define SAY_DEATH "No!...The master... will not... be pleased." +#define SOUND_DEATH 10427 + +#define SPELL_SAND_BREATH 31914 +#define SPELL_IMPENDING_DEATH 31916 +#define SPELL_MAGIC_DISRUPTION_AURA 33834 +#define SPELL_WING_BUFFET 31475 + +struct MANGOS_DLL_DECL boss_epoch_hunterAI : public ScriptedAI +{ + boss_epoch_hunterAI(Creature *c) : ScriptedAI(c) + { + pInstance = ((ScriptedInstance*)c->GetInstanceData()); + Reset(); + } + + ScriptedInstance *pInstance; + + uint32 SandBreath_Timer; + uint32 ImpendingDeath_Timer; + uint32 WingBuffet_Timer; + uint32 Mda_Timer; + + void Reset() + { + SandBreath_Timer = 25000; + ImpendingDeath_Timer = 30000; + WingBuffet_Timer = 35000; + Mda_Timer = 40000; + } + + void Aggro(Unit *who) + { + switch(rand()%2) + { + case 0: + DoYell(SAY_AGGRO1,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature, SOUND_AGGRO1); + break; + case 1: + DoYell(SAY_AGGRO2,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature, SOUND_AGGRO2); + break; + } + } + + void KilledUnit(Unit *victim) + { + switch(rand()%2) + { + case 0: + DoYell(SAY_SLAY1,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature, SOUND_SLAY1); + break; + case 1: + DoYell(SAY_SLAY2,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature, SOUND_SLAY2); + break; + } + } + + void JustDied(Unit *victim) + { + DoYell(SAY_DEATH,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature, SOUND_DEATH); + + if( pInstance && pInstance->GetData(TYPE_THRALL_EVENT) == IN_PROGRESS ) + pInstance->SetData(TYPE_THRALL_PART4, DONE); + } + + void UpdateAI(const uint32 diff) + { + //Return since we have no target + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + //Sand Breath + if( SandBreath_Timer < diff ) + { + if( m_creature->IsNonMeleeSpellCasted(false) ) + m_creature->InterruptNonMeleeSpells(false); + + DoCast(m_creature->getVictim(),SPELL_SAND_BREATH); + + switch(rand()%2) + { + case 0: + DoYell(SAY_BREATH1,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature, SOUND_BREATH1); + break; + case 1: + DoYell(SAY_BREATH2,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature, SOUND_BREATH2); + break; + } + + SandBreath_Timer = 25000+rand()%5000; + }else SandBreath_Timer -= diff; + + if( ImpendingDeath_Timer < diff ) + { + DoCast(m_creature->getVictim(),SPELL_IMPENDING_DEATH); + ImpendingDeath_Timer = 30000+rand()%5000; + }else ImpendingDeath_Timer -= diff; + + if( WingBuffet_Timer < diff ) + { + if( Unit *target = SelectUnit(SELECT_TARGET_RANDOM,0) ) + DoCast(target,SPELL_WING_BUFFET); + WingBuffet_Timer = 25000+rand()%10000; + }else WingBuffet_Timer -= diff; + + if( Mda_Timer < diff ) + { + DoCast(m_creature,SPELL_MAGIC_DISRUPTION_AURA); + Mda_Timer = 15000; + }else Mda_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; + +CreatureAI* GetAI_boss_epoch_hunter(Creature *_Creature) +{ + return new boss_epoch_hunterAI (_Creature); +} + +void AddSC_boss_epoch_hunter() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_epoch_hunter"; + newscript->GetAI = GetAI_boss_epoch_hunter; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/caverns_of_time/old_hillsbrad/boss_leutenant_drake.cpp b/src/bindings/scripts/scripts/zone/caverns_of_time/old_hillsbrad/boss_leutenant_drake.cpp index 5a6ccb7dc97..e70b52dfa43 100644 --- a/src/bindings/scripts/scripts/zone/caverns_of_time/old_hillsbrad/boss_leutenant_drake.cpp +++ b/src/bindings/scripts/scripts/zone/caverns_of_time/old_hillsbrad/boss_leutenant_drake.cpp @@ -1,246 +1,246 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Luetenant_Drake -SD%Complete: 70 -SDComment: Missing proper code for patrolling area after being spawned. Also script for GO (barrels)(missing mangos support) -SDCategory: Caverns of Time, Old Hillsbrad Foothills -EndScriptData */ - -#include "precompiled.h" -#include "def_old_hillsbrad.h" -#include "../../../npc/npc_escortAI.h" - -/*###### -## go_barrel_old_hillsbrad -######*/ - -#define QUEST_ENTRY_DIVERSION 10283 -#define LODGE_QUEST_TRIGGER 20155 - -bool GOHello_go_barrel_old_hillsbrad(Player *player, GameObject* _GO) -{ - ScriptedInstance* pInstance = ((ScriptedInstance*)_GO->GetInstanceData()); - - if( pInstance ) - { - if( pInstance->GetData(TYPE_BARREL_DIVERSION) != DONE ) - { - pInstance->SetData(TYPE_BARREL_DIVERSION, IN_PROGRESS); - } - else if( pInstance->GetData(TYPE_BARREL_DIVERSION) == DONE ) - { - player->SummonCreature(17848,2128.43,71.01,64.42,1.74,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,1200000); - if( player->GetQuestStatus(QUEST_ENTRY_DIVERSION) == QUEST_STATUS_INCOMPLETE ) - player->KilledMonster(LODGE_QUEST_TRIGGER,0); - } - } - return false; -} - -/*###### -## boss_lieutenant_drake -######*/ - -#define WHIRLWIND 40236 -#define FEAR 33789 -#define MORTAL_STRIKE 40220 -#define EXPLODIG_SHOUT 33792 - -#define SAY_ENTER1 "You there, fetch water quickly!" -#define SAY_ENTER2 "Get these flames out before they spread to the rest of the keep!" -#define SAY_ENTER3 "Hurry, damn you!" -#define SAY_AGGRO "I know what you're up to, and I mean to put an end to it, permanently!" -#define SAY_SLAY1 "No more middling for you." -#define SAY_SLAY2 "You will not interfere!" -#define SAY_MORTAL "Time to bleed!" -#define SAY_SHOUT "Run, you blasted cowards!" -#define SAY_DEATH "Thrall... must not... go free." - -#define SOUND_ENTER 10428 -#define SOUND_AGGRO 10429 -#define SOUND_SLAY1 10432 -#define SOUND_SLAY2 10433 -#define SOUND_MORTAL 10430 -#define SOUND_SHOUT 10431 -#define SOUND_DEATH 10434 - -struct Location -{ - uint32 wpId; - float x; - float y; - float z; -}; - -static Location DrakeWP[]= -{ - {0, 2125.84, 88.2535, 54.8830}, - {1, 2111.01, 93.8022, 52.6356}, - {2, 2106.70, 114.753, 53.1965}, - {3, 2107.76, 138.746, 52.5109}, - {4, 2114.83, 160.142, 52.4738}, - {5, 2125.24, 178.909, 52.7283}, - {6, 2151.02, 208.901, 53.1551}, - {7, 2177.00, 233.069, 52.4409}, - {8, 2190.71, 227.831, 53.2742}, - {9, 2178.14, 214.219, 53.0779}, - {10, 2154.99, 202.795, 52.6446}, - {11, 2132.00, 191.834, 52.5709}, - {12, 2117.59, 166.708, 52.7686}, - {13, 2093.61, 139.441, 52.7616}, - {14, 2086.29, 104.950, 52.9246}, - {15, 2094.23, 81.2788, 52.6946}, - {16, 2108.70, 85.3075, 53.3294}, - {17, 2125.50, 88.9481, 54.7953}, - {18, 2128.20, 70.9763, 64.4221} -}; - -struct MANGOS_DLL_DECL boss_lieutenant_drakeAI : public ScriptedAI -{ - boss_lieutenant_drakeAI(Creature *c) : ScriptedAI(c) {Reset();} - - bool CanPatrol; - uint32 wpId; - - uint32 Whirlwind_Timer; - uint32 Fear_Timer; - uint32 MortalStrike_Timer; - uint32 ExplodingShout_Timer; - - void Reset() - { - CanPatrol = true; - wpId = 0; - - Whirlwind_Timer = 20000; - Fear_Timer = 30000; - MortalStrike_Timer = 45000; - ExplodingShout_Timer = 25000; - } - - void Aggro(Unit *who) - { - DoYell(SAY_AGGRO,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature, SOUND_AGGRO); - } - - void KilledUnit(Unit *victim) - { - switch(rand()%2) - { - case 0: - DoYell(SAY_SLAY1,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature, SOUND_SLAY1); - break; - case 1: - DoYell(SAY_SLAY2,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature, SOUND_SLAY2); - break; - } - } - - void JustDied(Unit *victim) - { - DoYell(SAY_DEATH,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature, SOUND_DEATH); - } - - void UpdateAI(const uint32 diff) - { - //TODO: make this work - if( CanPatrol && wpId == 0 ) - { - m_creature->GetMotionMaster()->MovePoint(DrakeWP[0].wpId, DrakeWP[0].x, DrakeWP[0].y, DrakeWP[0].z); - wpId++; - } - - //Return since we have no target - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - //Whirlwind - if (Whirlwind_Timer < diff) - { - DoCast(m_creature->getVictim(), WHIRLWIND); - - Whirlwind_Timer = 20000+rand()%5000; - }else Whirlwind_Timer -= diff; - - //Fear - if (Fear_Timer < diff) - { - Unit* target = NULL; - target = SelectUnit(SELECT_TARGET_RANDOM, 0); - if (target) - DoCast(target, FEAR); - - Fear_Timer = 30000+rand()%10000; - }else Fear_Timer -= diff; - - //Mortal Strike - if (MortalStrike_Timer < diff) - { - DoYell(SAY_MORTAL, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_MORTAL); - - DoCast(m_creature->getVictim(), MORTAL_STRIKE); - - MortalStrike_Timer = 45000+rand()%5000; - }else MortalStrike_Timer -= diff; - - /* - //This only enabled on heroic? - //Exploding Shout - if (m_creature->IsHeroicCreature()) - { - if (ExplodingShout_Timer < diff) - { - Unit* target = NULL; - target = SelectUnit(SELECT_TARGET_RANDOM,0); - if (target) - DoYell(SAY_SHOUT, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_SHOUT); - DoCast(target,EXPLODING_SHOUT); - ExplodingShout_Timer = 25000+rand()%5000; - }else ExplodingShout_Timer -= diff; - } - */ - - DoMeleeAttackIfReady(); - } -}; - -CreatureAI* GetAI_boss_lieutenant_drake(Creature *_Creature) -{ - return new boss_lieutenant_drakeAI (_Creature); -} - -void AddSC_boss_lieutenant_drake() -{ - Script *newscript; - - newscript = new Script; - newscript->Name="go_barrel_old_hillsbrad"; - newscript->pGOHello = GOHello_go_barrel_old_hillsbrad; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="boss_lieutenant_drake"; - newscript->GetAI = GetAI_boss_lieutenant_drake; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Luetenant_Drake +SD%Complete: 70 +SDComment: Missing proper code for patrolling area after being spawned. Also script for GO (barrels)(missing mangos support) +SDCategory: Caverns of Time, Old Hillsbrad Foothills +EndScriptData */ + +#include "precompiled.h" +#include "def_old_hillsbrad.h" +#include "../../../npc/npc_escortAI.h" + +/*###### +## go_barrel_old_hillsbrad +######*/ + +#define QUEST_ENTRY_DIVERSION 10283 +#define LODGE_QUEST_TRIGGER 20155 + +bool GOHello_go_barrel_old_hillsbrad(Player *player, GameObject* _GO) +{ + ScriptedInstance* pInstance = ((ScriptedInstance*)_GO->GetInstanceData()); + + if( pInstance ) + { + if( pInstance->GetData(TYPE_BARREL_DIVERSION) != DONE ) + { + pInstance->SetData(TYPE_BARREL_DIVERSION, IN_PROGRESS); + } + else if( pInstance->GetData(TYPE_BARREL_DIVERSION) == DONE ) + { + player->SummonCreature(17848,2128.43,71.01,64.42,1.74,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,1200000); + if( player->GetQuestStatus(QUEST_ENTRY_DIVERSION) == QUEST_STATUS_INCOMPLETE ) + player->KilledMonster(LODGE_QUEST_TRIGGER,0); + } + } + return false; +} + +/*###### +## boss_lieutenant_drake +######*/ + +#define WHIRLWIND 40236 +#define FEAR 33789 +#define MORTAL_STRIKE 40220 +#define EXPLODIG_SHOUT 33792 + +#define SAY_ENTER1 "You there, fetch water quickly!" +#define SAY_ENTER2 "Get these flames out before they spread to the rest of the keep!" +#define SAY_ENTER3 "Hurry, damn you!" +#define SAY_AGGRO "I know what you're up to, and I mean to put an end to it, permanently!" +#define SAY_SLAY1 "No more middling for you." +#define SAY_SLAY2 "You will not interfere!" +#define SAY_MORTAL "Time to bleed!" +#define SAY_SHOUT "Run, you blasted cowards!" +#define SAY_DEATH "Thrall... must not... go free." + +#define SOUND_ENTER 10428 +#define SOUND_AGGRO 10429 +#define SOUND_SLAY1 10432 +#define SOUND_SLAY2 10433 +#define SOUND_MORTAL 10430 +#define SOUND_SHOUT 10431 +#define SOUND_DEATH 10434 + +struct Location +{ + uint32 wpId; + float x; + float y; + float z; +}; + +static Location DrakeWP[]= +{ + {0, 2125.84, 88.2535, 54.8830}, + {1, 2111.01, 93.8022, 52.6356}, + {2, 2106.70, 114.753, 53.1965}, + {3, 2107.76, 138.746, 52.5109}, + {4, 2114.83, 160.142, 52.4738}, + {5, 2125.24, 178.909, 52.7283}, + {6, 2151.02, 208.901, 53.1551}, + {7, 2177.00, 233.069, 52.4409}, + {8, 2190.71, 227.831, 53.2742}, + {9, 2178.14, 214.219, 53.0779}, + {10, 2154.99, 202.795, 52.6446}, + {11, 2132.00, 191.834, 52.5709}, + {12, 2117.59, 166.708, 52.7686}, + {13, 2093.61, 139.441, 52.7616}, + {14, 2086.29, 104.950, 52.9246}, + {15, 2094.23, 81.2788, 52.6946}, + {16, 2108.70, 85.3075, 53.3294}, + {17, 2125.50, 88.9481, 54.7953}, + {18, 2128.20, 70.9763, 64.4221} +}; + +struct MANGOS_DLL_DECL boss_lieutenant_drakeAI : public ScriptedAI +{ + boss_lieutenant_drakeAI(Creature *c) : ScriptedAI(c) {Reset();} + + bool CanPatrol; + uint32 wpId; + + uint32 Whirlwind_Timer; + uint32 Fear_Timer; + uint32 MortalStrike_Timer; + uint32 ExplodingShout_Timer; + + void Reset() + { + CanPatrol = true; + wpId = 0; + + Whirlwind_Timer = 20000; + Fear_Timer = 30000; + MortalStrike_Timer = 45000; + ExplodingShout_Timer = 25000; + } + + void Aggro(Unit *who) + { + DoYell(SAY_AGGRO,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature, SOUND_AGGRO); + } + + void KilledUnit(Unit *victim) + { + switch(rand()%2) + { + case 0: + DoYell(SAY_SLAY1,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature, SOUND_SLAY1); + break; + case 1: + DoYell(SAY_SLAY2,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature, SOUND_SLAY2); + break; + } + } + + void JustDied(Unit *victim) + { + DoYell(SAY_DEATH,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature, SOUND_DEATH); + } + + void UpdateAI(const uint32 diff) + { + //TODO: make this work + if( CanPatrol && wpId == 0 ) + { + m_creature->GetMotionMaster()->MovePoint(DrakeWP[0].wpId, DrakeWP[0].x, DrakeWP[0].y, DrakeWP[0].z); + wpId++; + } + + //Return since we have no target + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + //Whirlwind + if (Whirlwind_Timer < diff) + { + DoCast(m_creature->getVictim(), WHIRLWIND); + + Whirlwind_Timer = 20000+rand()%5000; + }else Whirlwind_Timer -= diff; + + //Fear + if (Fear_Timer < diff) + { + Unit* target = NULL; + target = SelectUnit(SELECT_TARGET_RANDOM, 0); + if (target) + DoCast(target, FEAR); + + Fear_Timer = 30000+rand()%10000; + }else Fear_Timer -= diff; + + //Mortal Strike + if (MortalStrike_Timer < diff) + { + DoYell(SAY_MORTAL, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_MORTAL); + + DoCast(m_creature->getVictim(), MORTAL_STRIKE); + + MortalStrike_Timer = 45000+rand()%5000; + }else MortalStrike_Timer -= diff; + + /* + //This only enabled on heroic? + //Exploding Shout + if (m_creature->IsHeroicCreature()) + { + if (ExplodingShout_Timer < diff) + { + Unit* target = NULL; + target = SelectUnit(SELECT_TARGET_RANDOM,0); + if (target) + DoYell(SAY_SHOUT, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_SHOUT); + DoCast(target,EXPLODING_SHOUT); + ExplodingShout_Timer = 25000+rand()%5000; + }else ExplodingShout_Timer -= diff; + } + */ + + DoMeleeAttackIfReady(); + } +}; + +CreatureAI* GetAI_boss_lieutenant_drake(Creature *_Creature) +{ + return new boss_lieutenant_drakeAI (_Creature); +} + +void AddSC_boss_lieutenant_drake() +{ + Script *newscript; + + newscript = new Script; + newscript->Name="go_barrel_old_hillsbrad"; + newscript->pGOHello = GOHello_go_barrel_old_hillsbrad; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="boss_lieutenant_drake"; + newscript->GetAI = GetAI_boss_lieutenant_drake; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/caverns_of_time/old_hillsbrad/def_old_hillsbrad.h b/src/bindings/scripts/scripts/zone/caverns_of_time/old_hillsbrad/def_old_hillsbrad.h index 8a230919bbc..4d82a179a93 100644 --- a/src/bindings/scripts/scripts/zone/caverns_of_time/old_hillsbrad/def_old_hillsbrad.h +++ b/src/bindings/scripts/scripts/zone/caverns_of_time/old_hillsbrad/def_old_hillsbrad.h @@ -1,16 +1,16 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software licensed under GPL version 2 - * Please see the included DOCS/LICENSE.TXT for more information */ - -#ifndef DEF_OLD_HILLSBRAD_H -#define DEF_OLD_HILLSBRAD_H - -#define TYPE_BARREL_DIVERSION 1 -#define TYPE_THRALL_EVENT 2 -#define TYPE_THRALL_PART1 3 -#define TYPE_THRALL_PART2 4 -#define TYPE_THRALL_PART3 5 -#define TYPE_THRALL_PART4 6 -#define DATA_THRALL 7 -#define DATA_TARETHA 8 -#endif +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software licensed under GPL version 2 + * Please see the included DOCS/LICENSE.TXT for more information */ + +#ifndef DEF_OLD_HILLSBRAD_H +#define DEF_OLD_HILLSBRAD_H + +#define TYPE_BARREL_DIVERSION 1 +#define TYPE_THRALL_EVENT 2 +#define TYPE_THRALL_PART1 3 +#define TYPE_THRALL_PART2 4 +#define TYPE_THRALL_PART3 5 +#define TYPE_THRALL_PART4 6 +#define DATA_THRALL 7 +#define DATA_TARETHA 8 +#endif diff --git a/src/bindings/scripts/scripts/zone/caverns_of_time/old_hillsbrad/instance_old_hillsbrad.cpp b/src/bindings/scripts/scripts/zone/caverns_of_time/old_hillsbrad/instance_old_hillsbrad.cpp index 57d78f5d98f..1ac0d03a3bb 100644 --- a/src/bindings/scripts/scripts/zone/caverns_of_time/old_hillsbrad/instance_old_hillsbrad.cpp +++ b/src/bindings/scripts/scripts/zone/caverns_of_time/old_hillsbrad/instance_old_hillsbrad.cpp @@ -1,178 +1,178 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Instance_Old_Hillsbrad -SD%Complete: 60 -SDComment: If thrall escort fail, all parts will reset. In future, save sub-parts and continue from last known. -SDCategory: Caverns of Time, Old Hillsbrad Foothills -EndScriptData */ - -/* --- UPDATE `gameobject_template` SET `ScriptName`='go_barrel_old_hillsbrad' WHERE `entry`=182589; -*/ - -#include "precompiled.h" -#include "def_old_hillsbrad.h" - -#define ENCOUNTERS 6 - -#define THRALL_ENTRY 17876 -#define TARETHA_ENTRY 18887 - -struct MANGOS_DLL_DECL instance_old_hillsbrad : public ScriptedInstance -{ - instance_old_hillsbrad(Map *Map) : ScriptedInstance(Map) {Initialize();}; - - uint32 Encounter[ENCOUNTERS]; - uint32 mBarrelCount; - uint32 mThrallEventCount; - - uint64 ThrallGUID; - uint64 TarethaGUID; - - void Initialize() - { - mBarrelCount = 0; - mThrallEventCount = 0; - ThrallGUID = 0; - TarethaGUID = 0; - - for(uint8 i = 0; i < ENCOUNTERS; i++) - Encounter[i] = NOT_STARTED; - } - - void OnCreatureCreate(Creature *creature, uint32 creature_entry) - { - switch(creature_entry) - { - case THRALL_ENTRY: - ThrallGUID = creature->GetGUID(); - break; - case TARETHA_ENTRY: - TarethaGUID = creature->GetGUID(); - break; - } - } - - void SetData(uint32 type, uint32 data) - { - switch(type) - { - case TYPE_BARREL_DIVERSION: - { - if( mBarrelCount < 5 ) - { - mBarrelCount++; - debug_log("SD2: go_barrel_old_hillsbrad count %u",mBarrelCount); - } - else if( mBarrelCount >= 5 ) - Encounter[0] = DONE; - break; - } - case TYPE_THRALL_EVENT: - { - if( data == FAIL ) - { - if( mThrallEventCount <= 20 ) - { - mThrallEventCount++; - Encounter[1] = NOT_STARTED; - debug_log("SD2: Thrall event failed %u times. Resetting all sub-events.",mThrallEventCount); - Encounter[2] = NOT_STARTED; - Encounter[3] = NOT_STARTED; - Encounter[4] = NOT_STARTED; - Encounter[5] = NOT_STARTED; - } - else if( mThrallEventCount > 20 ) - { - Encounter[1] = data; - Encounter[2] = data; - Encounter[3] = data; - Encounter[4] = data; - Encounter[5] = data; - debug_log("SD2: Thrall event failed %u times. Reset instance required.",mThrallEventCount); - } - } - else - Encounter[1] = data; - debug_log("SD2: Thrall escort event adjusted to data %u.",data); - break; - } - case TYPE_THRALL_PART1: - Encounter[2] = data; - debug_log("SD2: Thrall event part I adjusted to data %u.",data); - break; - case TYPE_THRALL_PART2: - Encounter[3] = data; - debug_log("SD2: Thrall event part II adjusted to data %u.",data); - break; - case TYPE_THRALL_PART3: - Encounter[4] = data; - debug_log("SD2: Thrall event part III adjusted to data %u.",data); - break; - case TYPE_THRALL_PART4: - Encounter[5] = data; - debug_log("SD2: Thrall event part IV adjusted to data %u.",data); - break; - } - } - - uint32 GetData(uint32 data) - { - switch(data) - { - case TYPE_BARREL_DIVERSION: - return Encounter[0]; - case TYPE_THRALL_EVENT: - return Encounter[1]; - case TYPE_THRALL_PART1: - return Encounter[2]; - case TYPE_THRALL_PART2: - return Encounter[3]; - case TYPE_THRALL_PART3: - return Encounter[4]; - case TYPE_THRALL_PART4: - return Encounter[5]; - } - return 0; - } - - uint64 GetData64(uint32 data) - { - switch(data) - { - case DATA_THRALL: - return ThrallGUID; - case DATA_TARETHA: - return TarethaGUID; - } - return 0; - } -}; -InstanceData* GetInstanceData_instance_old_hillsbrad(Map* map) -{ - return new instance_old_hillsbrad(map); -} - -void AddSC_instance_old_hillsbrad() -{ - Script *newscript; - newscript = new Script; - newscript->Name = "instance_old_hillsbrad"; - newscript->GetInstanceData = GetInstanceData_instance_old_hillsbrad; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Instance_Old_Hillsbrad +SD%Complete: 60 +SDComment: If thrall escort fail, all parts will reset. In future, save sub-parts and continue from last known. +SDCategory: Caverns of Time, Old Hillsbrad Foothills +EndScriptData */ + +/* +-- UPDATE `gameobject_template` SET `ScriptName`='go_barrel_old_hillsbrad' WHERE `entry`=182589; +*/ + +#include "precompiled.h" +#include "def_old_hillsbrad.h" + +#define ENCOUNTERS 6 + +#define THRALL_ENTRY 17876 +#define TARETHA_ENTRY 18887 + +struct MANGOS_DLL_DECL instance_old_hillsbrad : public ScriptedInstance +{ + instance_old_hillsbrad(Map *Map) : ScriptedInstance(Map) {Initialize();}; + + uint32 Encounter[ENCOUNTERS]; + uint32 mBarrelCount; + uint32 mThrallEventCount; + + uint64 ThrallGUID; + uint64 TarethaGUID; + + void Initialize() + { + mBarrelCount = 0; + mThrallEventCount = 0; + ThrallGUID = 0; + TarethaGUID = 0; + + for(uint8 i = 0; i < ENCOUNTERS; i++) + Encounter[i] = NOT_STARTED; + } + + void OnCreatureCreate(Creature *creature, uint32 creature_entry) + { + switch(creature_entry) + { + case THRALL_ENTRY: + ThrallGUID = creature->GetGUID(); + break; + case TARETHA_ENTRY: + TarethaGUID = creature->GetGUID(); + break; + } + } + + void SetData(uint32 type, uint32 data) + { + switch(type) + { + case TYPE_BARREL_DIVERSION: + { + if( mBarrelCount < 5 ) + { + mBarrelCount++; + debug_log("SD2: go_barrel_old_hillsbrad count %u",mBarrelCount); + } + else if( mBarrelCount >= 5 ) + Encounter[0] = DONE; + break; + } + case TYPE_THRALL_EVENT: + { + if( data == FAIL ) + { + if( mThrallEventCount <= 20 ) + { + mThrallEventCount++; + Encounter[1] = NOT_STARTED; + debug_log("SD2: Thrall event failed %u times. Resetting all sub-events.",mThrallEventCount); + Encounter[2] = NOT_STARTED; + Encounter[3] = NOT_STARTED; + Encounter[4] = NOT_STARTED; + Encounter[5] = NOT_STARTED; + } + else if( mThrallEventCount > 20 ) + { + Encounter[1] = data; + Encounter[2] = data; + Encounter[3] = data; + Encounter[4] = data; + Encounter[5] = data; + debug_log("SD2: Thrall event failed %u times. Reset instance required.",mThrallEventCount); + } + } + else + Encounter[1] = data; + debug_log("SD2: Thrall escort event adjusted to data %u.",data); + break; + } + case TYPE_THRALL_PART1: + Encounter[2] = data; + debug_log("SD2: Thrall event part I adjusted to data %u.",data); + break; + case TYPE_THRALL_PART2: + Encounter[3] = data; + debug_log("SD2: Thrall event part II adjusted to data %u.",data); + break; + case TYPE_THRALL_PART3: + Encounter[4] = data; + debug_log("SD2: Thrall event part III adjusted to data %u.",data); + break; + case TYPE_THRALL_PART4: + Encounter[5] = data; + debug_log("SD2: Thrall event part IV adjusted to data %u.",data); + break; + } + } + + uint32 GetData(uint32 data) + { + switch(data) + { + case TYPE_BARREL_DIVERSION: + return Encounter[0]; + case TYPE_THRALL_EVENT: + return Encounter[1]; + case TYPE_THRALL_PART1: + return Encounter[2]; + case TYPE_THRALL_PART2: + return Encounter[3]; + case TYPE_THRALL_PART3: + return Encounter[4]; + case TYPE_THRALL_PART4: + return Encounter[5]; + } + return 0; + } + + uint64 GetData64(uint32 data) + { + switch(data) + { + case DATA_THRALL: + return ThrallGUID; + case DATA_TARETHA: + return TarethaGUID; + } + return 0; + } +}; +InstanceData* GetInstanceData_instance_old_hillsbrad(Map* map) +{ + return new instance_old_hillsbrad(map); +} + +void AddSC_instance_old_hillsbrad() +{ + Script *newscript; + newscript = new Script; + newscript->Name = "instance_old_hillsbrad"; + newscript->GetInstanceData = GetInstanceData_instance_old_hillsbrad; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/caverns_of_time/old_hillsbrad/old_hillsbrad.cpp b/src/bindings/scripts/scripts/zone/caverns_of_time/old_hillsbrad/old_hillsbrad.cpp index a02715785fe..9a7c039b5d6 100644 --- a/src/bindings/scripts/scripts/zone/caverns_of_time/old_hillsbrad/old_hillsbrad.cpp +++ b/src/bindings/scripts/scripts/zone/caverns_of_time/old_hillsbrad/old_hillsbrad.cpp @@ -1,916 +1,916 @@ -/* Copyright (C) 2006,2007 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Old_Hillsbrad -SD%Complete: 40 -SDComment: All friendly NPC's. Thrall waypoints fairly complete, missing many details, but possible to complete escort. -SDCategory: Caverns of Time, Old Hillsbrad Foothills -EndScriptData */ - -/* ContentData -npc_brazen -npc_erozion -npc_thrall_old_hillsbrad -npc_taretha -EndContentData */ - -#include "precompiled.h" -#include "../../../npc/npc_escortAI.h" -#include "def_old_hillsbrad.h" - -#define QUEST_ENTRY_HILLSBRAD 10282 -#define QUEST_ENTRY_DIVERSION 10283 -#define QUEST_ENTRY_ESCAPE 10284 -#define QUEST_ENTRY_RETURN 10285 -#define ITEM_ENTRY_BOMBS 25853 - -/*###### -## npc_brazen -######*/ - -bool GossipHello_npc_brazen(Player *player, Creature *_Creature) -{ - player->ADD_GOSSIP_ITEM(0, "I am ready to go to Durnholde Keep.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); - player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); - return true; -} - -bool GossipSelect_npc_brazen(Player *player, Creature *_Creature, uint32 sender, uint32 action ) -{ - if (action == GOSSIP_ACTION_INFO_DEF+1) - { - if( !player->HasItemCount(ITEM_ENTRY_BOMBS,1) ) - player->SEND_GOSSIP_MENU(9780, _Creature->GetGUID()); - else - { - player->CLOSE_GOSSIP_MENU(); - - std::vector nodes; - - nodes.resize(2); - nodes[0] = 115; //from brazen - nodes[1] = 116; //end outside durnholde - player->ActivateTaxiPathTo(nodes); //TaxiPath 534 - } - } - return true; -} - -/*###### -## npc_erozion -######*/ - -bool GossipHello_npc_erozion(Player *player, Creature *_Creature) -{ - if( _Creature->isQuestGiver() ) - player->PrepareQuestMenu( _Creature->GetGUID() ); - - ScriptedInstance* pInstance = ((ScriptedInstance*)_Creature->GetInstanceData()); - if( pInstance && pInstance->GetData(TYPE_BARREL_DIVERSION) != DONE && !player->HasItemCount(ITEM_ENTRY_BOMBS,1) ) - player->ADD_GOSSIP_ITEM( 0, "I need a pack of Incendiary Bombs.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); - - if( !player->GetQuestRewardStatus(QUEST_ENTRY_RETURN) && player->GetQuestStatus(QUEST_ENTRY_RETURN) == QUEST_STATUS_COMPLETE ) - player->ADD_GOSSIP_ITEM( 0, "[PH] Teleport please, i'm tired.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2); - - player->SEND_GOSSIP_MENU(9778, _Creature->GetGUID()); - - return true; -} - -bool GossipSelect_npc_erozion(Player *player, Creature *_Creature, uint32 sender, uint32 action) -{ - if( action == GOSSIP_ACTION_INFO_DEF+1 ) - { - ItemPosCountVec dest; - uint8 msg = player->CanStoreNewItem( NULL_BAG, NULL_SLOT, dest, ITEM_ENTRY_BOMBS, 1, false); - if( msg == EQUIP_ERR_OK ) - { - player->StoreNewItem( dest, ITEM_ENTRY_BOMBS, 1, true); - } - player->SEND_GOSSIP_MENU(9515, _Creature->GetGUID()); - } - if( action == GOSSIP_ACTION_INFO_DEF+2 ) - { - player->CLOSE_GOSSIP_MENU(); - } - return true; -} - -/*###### -## npc_thrall_old_hillsbrad -######*/ - -#define SPEED_WALK (0.5f) -#define SPEED_RUN (1.0f) -#define SPEED_MOUNT (1.6f) - -#define THRALL_WEAPON_MODEL 22106 -#define THRALL_WEAPON_INFO 218169346 -#define THRALL_SHIELD_MODEL 18662 -#define THRALL_SHIELD_INFO 234948100 -#define THRALL_MODEL_UNEQUIPPED 17292 -#define THRALL_MODEL_EQUIPPED 18165 - -#define MOB_ENTRY_RIFLE 17820 -#define MOB_ENTRY_WARDEN 17833 -#define MOB_ENTRY_VETERAN 17860 -#define MOB_ENTRY_WATCHMAN 17814 -#define MOB_ENTRY_SENTRY 17815 - -#define MOB_ENTRY_BARN_GUARDSMAN 18092 -#define MOB_ENTRY_BARN_PROTECTOR 18093 -#define MOB_ENTRY_BARN_LOOKOUT 18094 - -#define MOB_ENTRY_CHURCH_GUARDSMAN 23175 -#define MOB_ENTRY_CHURCH_PROTECTOR 23179 -#define MOB_ENTRY_CHURCH_LOOKOUT 23177 - -#define MOB_ENTRY_INN_GUARDSMAN 23176 -#define MOB_ENTRY_INN_PROTECTOR 23180 -#define MOB_ENTRY_INN_LOOKOUT 23178 - -#define SKARLOC_MOUNT 18798 -#define SKARLOC_MOUNT_MODEL 18223 -#define EROZION_ENTRY 18723 - -#define GOSSIP_ID_START 9568 -#define GOSSIP_ID_SKARLOC1 9614 //I'm glad Taretha is alive. We now must find a way to free her... -#define GOSSIP_ITEM_SKARLOC1 "Taretha cannot see you, Thrall." -#define GOSSIP_ID_SKARLOC2 9579 //What do you mean by this? Is Taretha in danger? -#define GOSSIP_ITEM_SKARLOC2 "The situation is rather complicated, Thrall. It would be best for you to head into the mountains now, before more of Blackmoore's men show up. We'll make sure Taretha is safe." -#define GOSSIP_ID_SKARLOC3 9580 - -#define GOSSIP_ID_TARREN 9597 //tarren mill is beyond these trees -#define GOSSIP_ITEM_TARREN "We're ready, Thrall." - -#define GOSSIP_ID_COMPLETE 9578 //Thank you friends, I owe my freedom to you. Where is Taretha? I hoped to see her - -#define THRALL_START_EVENT_PART1 "Very well then. Let's go!" -#define SOUND_START_EVENT 10465 - -#define THRALL_SAY_ARMOR "As long as we're going with a new plan, I may aswell pick up a weapon and some armor." - -#define THRALL_SKARLOC_MEET "A rider approaches!" -#define SOUND_SKARLOC_MEET 10466 -#define THRALL_SKARLOC_TAUNT "I'll never be chained again!" -#define SOUND_SKARLOC_TAUNT 10467 - -#define THRALL_START_EVENT_PART2 "Very well. Tarren Mill lies just west of here. Since time is of the essence..." -#define SOUND_START_EVENT_PART2 10468 -#define THRALL_MOUNTS_UP "Let's ride!" -#define SOUND_MOUNTS_UP 10469 - -#define THRALL_CHURCH_END "Taretha must be in the inn. Let's go." -#define THRALL_MEET_TARETHA "Taretha! What foul magic is this?" - -#define THRALL_EPOCH_WONDER "Who or what was that?" -#define SOUND_EPOCH_WONDER 10470 -#define THRALL_EPOCH_KILL_TARETHA "No!" -#define SOUND_EPOCH_KILL_TARETHA 10471 - -#define THRALL_EVENT_COMPLETE "Goodbye, Taretha. I will never forget your kindness." -#define SOUND_EVENT_COMPLETE 10472 - -#define THRALL_RANDOM_LOW_HP1 "Things are looking grim..." -#define SOUND_RANDOM_LOW_HP1 10458 -#define THRALL_RANDOM_LOW_HP2 "I will fight to the last!" -#define SOUND_RANDOM_LOW_HP2 10459 - -#define THRALL_RANDOM_DIE1 "Taretha..." -#define SOUND_RANDOM_DIE1 10460 -#define THRALL_RANDOM_DIE2 "A good day...to die..." -#define SOUND_RANDOM_DIE2 10461 - -#define THRALL_RANDOM_AGGRO1 "I have earned my freedom!" -#define SOUND_RANDOM_AGGRO1 10448 -#define THRALL_RANDOM_AGGRO2 "This day is long overdue. Out of my way!" -#define SOUND_RANDOM_AGGRO2 10449 -#define THRALL_RANDOM_AGGRO3 "I am a slave no longer!" -#define SOUND_RANDOM_AGGRO3 10450 -#define THRALL_RANDOM_AGGRO4 "Blackmoore has much to answer for!" -#define SOUND_RANDOM_AGGRO4 10451 - -#define THRALL_RANDOM_KILL1 "You have forced my hand!" -#define SOUND_RANDOM_KILL1 10452 -#define THRALL_RANDOM_KILL2 "It should not have come to this!" -#define SOUND_RANDOM_KILL2 10453 -#define THRALL_RANDOM_KILL3 "I did not ask for this!" -#define SOUND_RANDOM_KILL3 10454 - -#define THRALL_LEAVE_COMBAT1 "I am truly in your debt, strangers." -#define SOUND_LEAVE_COMBAT1 10455 -#define THRALL_LEAVE_COMBAT2 "Thank you, strangers. You have given me hope." -#define SOUND_LEAVE_COMBAT2 10456 -#define THRALL_LEAVE_COMBAT3 "I will not waste this chance. I will seek out my destiny." -#define SOUND_LEAVE_COMBAT3 10457 - -struct MANGOS_DLL_DECL npc_thrall_old_hillsbradAI : public npc_escortAI -{ - npc_thrall_old_hillsbradAI(Creature *c) : npc_escortAI(c) - { - pInstance = ((ScriptedInstance*)c->GetInstanceData()); - Reset(); - } - - ScriptedInstance *pInstance; - Creature* sum; - uint64 TarethaGUID; - bool LowHp; - bool HadMount; - - void WaypointReached(uint32 i) - { - switch( i ) - { - case 8: - m_creature->AddUnitMovementFlag(MOVEMENTFLAG_WALK_MODE); - sum = m_creature->SummonCreature(18764,2181.87,112.46,89.45,0.26,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,5000); - if( sum ) sum->AI()->AttackStart(m_creature); - break; - case 9: - m_creature->AddUnitMovementFlag(MOVEMENTFLAG_WALK_MODE); - DoSay(THRALL_SAY_ARMOR, LANG_UNIVERSAL, NULL); - m_creature->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_DISPLAY, THRALL_WEAPON_MODEL); - m_creature->SetUInt32Value(UNIT_VIRTUAL_ITEM_INFO, THRALL_WEAPON_INFO); - m_creature->SetUInt32Value(UNIT_VIRTUAL_ITEM_INFO+1, 781); - m_creature->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_DISPLAY+1, THRALL_SHIELD_MODEL); - m_creature->SetUInt32Value(UNIT_VIRTUAL_ITEM_INFO+2, THRALL_SHIELD_INFO); - m_creature->SetUInt32Value(UNIT_VIRTUAL_ITEM_INFO+3, 1038); - break; - case 10: - m_creature->SetUInt32Value(UNIT_FIELD_DISPLAYID, THRALL_MODEL_EQUIPPED); - break; - case 11: - m_creature->RemoveUnitMovementFlag(MOVEMENTFLAG_WALK_MODE); - break; - case 15: - sum = m_creature->SummonCreature(MOB_ENTRY_RIFLE,2200.28,137.37,87.93,5.07,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,5000); - if( sum ) sum->AI()->AttackStart(m_creature); - sum = m_creature->SummonCreature(MOB_ENTRY_WARDEN,2197.44,131.83,87.93,0.78,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,5000); - if( sum ) sum->AI()->AttackStart(m_creature); - sum = m_creature->SummonCreature(MOB_ENTRY_VETERAN,2203.62,135.40,87.93,3.70,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,5000); - if( sum ) sum->AI()->AttackStart(m_creature); - sum = m_creature->SummonCreature(MOB_ENTRY_VETERAN,2200.75,130.13,87.93,1.48,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,5000); - if( sum ) sum->AI()->AttackStart(m_creature); - break; - case 21: - sum = m_creature->SummonCreature(MOB_ENTRY_RIFLE,2135.80,154.01,67.45,4.98,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,5000); - if( sum ) sum->AI()->AttackStart(m_creature); - sum = m_creature->SummonCreature(MOB_ENTRY_WARDEN,2144.36,151.87,67.74,4.46,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,5000); - if( sum ) sum->AI()->AttackStart(m_creature); - sum = m_creature->SummonCreature(MOB_ENTRY_VETERAN,2142.12,154.41,67.12,4.56,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,5000); - if( sum ) sum->AI()->AttackStart(m_creature); - sum = m_creature->SummonCreature(MOB_ENTRY_VETERAN,2138.08,155.38,67.24,4.60,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,5000); - if( sum ) sum->AI()->AttackStart(m_creature); - break; - case 25: - sum = m_creature->SummonCreature(MOB_ENTRY_RIFLE,2102.98,192.17,65.24,6.02,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,5000); - if( sum ) sum->AI()->AttackStart(m_creature); - sum = m_creature->SummonCreature(MOB_ENTRY_WARDEN,2108.48,198.75,65.18,5.15,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,5000); - if( sum ) sum->AI()->AttackStart(m_creature); - sum = m_creature->SummonCreature(MOB_ENTRY_VETERAN,2106.11,197.29,65.18,5.63,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,5000); - if( sum ) sum->AI()->AttackStart(m_creature); - sum = m_creature->SummonCreature(MOB_ENTRY_VETERAN,2104.18,194.82,65.18,5.75,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,5000); - if( sum ) sum->AI()->AttackStart(m_creature); - break; - case 29: - DoSay(THRALL_SKARLOC_MEET, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature,SOUND_SKARLOC_MEET); - sum = m_creature->SummonCreature(17862,2036.48,271.22,63.43,5.27,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,30000); - //temporary,skarloc should rather be triggered to walk up to thrall - if( sum ) sum->AI()->AttackStart(m_creature); - break; - case 30: - IsOnHold = true; - m_creature->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP); - m_creature->AddUnitMovementFlag(MOVEMENTFLAG_WALK_MODE); - break; - case 31: - DoSay(THRALL_MOUNTS_UP, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature,SOUND_MOUNTS_UP); - m_creature->HandleEmoteCommand(EMOTE_ONESHOT_TALK); - DoMount(); - break; - case 37: - //possibly regular patrollers? If so, remove this and let database handle them - sum = m_creature->SummonCreature(MOB_ENTRY_WATCHMAN,2124.26,522.16,56.87,3.99,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,5000); - if( sum ) sum->AI()->AttackStart(m_creature); - sum = m_creature->SummonCreature(MOB_ENTRY_WATCHMAN,2121.69,525.37,57.11,4.01,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,5000); - if( sum ) sum->AI()->AttackStart(m_creature); - sum = m_creature->SummonCreature(MOB_ENTRY_SENTRY,2124.65,524.55,56.63,3.98,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,5000); - if( sum ) sum->AI()->AttackStart(m_creature); - break; - case 59: - m_creature->SummonCreature(SKARLOC_MOUNT,2488.64,625.77,58.26,4.71,TEMPSUMMON_TIMED_DESPAWN,10000); - DoUnmount(); - HadMount = false; - break; - case 60: - m_creature->HandleEmoteCommand(EMOTE_ONESHOT_EXCLAMATION); - //make horsie run off - IsOnHold = true; - m_creature->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP); - if( pInstance ) - pInstance->SetData(TYPE_THRALL_PART2, DONE); - break; - case 64: - m_creature->AddUnitMovementFlag(MOVEMENTFLAG_WALK_MODE); - break; - case 68: - m_creature->SummonCreature(MOB_ENTRY_BARN_PROTECTOR,2500.22,692.60,55.50,2.84,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,5000); - m_creature->SummonCreature(MOB_ENTRY_BARN_LOOKOUT,2500.13,696.55,55.51,3.38,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,5000); - m_creature->SummonCreature(MOB_ENTRY_BARN_GUARDSMAN,2500.55,693.64,55.50,3.14,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,5000); - m_creature->SummonCreature(MOB_ENTRY_BARN_GUARDSMAN,2500.94,695.81,55.50,3.14,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,5000); - break; - case 71: - m_creature->RemoveUnitMovementFlag(MOVEMENTFLAG_WALK_MODE); - break; - case 81: - m_creature->AddUnitMovementFlag(MOVEMENTFLAG_WALK_MODE); - break; - case 83: - sum = m_creature->SummonCreature(MOB_ENTRY_CHURCH_PROTECTOR,2627.33,646.82,56.03,4.28,TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,5000); - if( sum ) sum->AI()->AttackStart(m_creature); - sum = m_creature->SummonCreature(MOB_ENTRY_CHURCH_LOOKOUT,2624.14,648.03,56.03,4.50,TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,5000); - if( sum ) sum->AI()->AttackStart(m_creature); - sum = m_creature->SummonCreature(MOB_ENTRY_CHURCH_GUARDSMAN,2625.32,649.60,56.03,4.38,TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,5000); - if( sum ) sum->AI()->AttackStart(m_creature); - sum = m_creature->SummonCreature(MOB_ENTRY_CHURCH_GUARDSMAN,2627.22,649.00,56.03,4.34,TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,5000); - if( sum ) sum->AI()->AttackStart(m_creature); - break; - case 84: - DoSay(THRALL_CHURCH_END, LANG_UNIVERSAL, NULL); - break; - case 91: - m_creature->AddUnitMovementFlag(MOVEMENTFLAG_WALK_MODE); - case 93: - sum = m_creature->SummonCreature(MOB_ENTRY_INN_PROTECTOR,2652.71,660.31,61.93,1.67,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,5000); - if( sum ) sum->AI()->AttackStart(m_creature); - sum = m_creature->SummonCreature(MOB_ENTRY_INN_LOOKOUT,2648.96,662.59,61.93,0.79,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,5000); - if( sum ) sum->AI()->AttackStart(m_creature); - sum = m_creature->SummonCreature(MOB_ENTRY_INN_GUARDSMAN,2657.36,662.34,61.93,2.68,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,5000); - if( sum ) sum->AI()->AttackStart(m_creature); - sum = m_creature->SummonCreature(MOB_ENTRY_INN_GUARDSMAN,2656.39,659.77,61.93,2.61,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,5000); - if( sum ) sum->AI()->AttackStart(m_creature); - break; - case 94: - m_creature->AddUnitMovementFlag(MOVEMENTFLAG_WALK_MODE); - //trigger taretha Say("Thrall, you escaped!") - break; - case 95: - DoSay(THRALL_MEET_TARETHA, LANG_UNIVERSAL, NULL); - if( pInstance ) - pInstance->SetData(TYPE_THRALL_PART3,DONE); - IsOnHold = true; - break; - case 96: - m_creature->HandleEmoteCommand(EMOTE_ONESHOT_TALK); - DoYell(THRALL_EPOCH_WONDER, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature,SOUND_EPOCH_WONDER); - break; - case 97: - m_creature->HandleEmoteCommand(EMOTE_ONESHOT_EXCLAMATION); - DoYell(THRALL_EPOCH_KILL_TARETHA, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature,SOUND_EPOCH_KILL_TARETHA); - m_creature->RemoveUnitMovementFlag(MOVEMENTFLAG_WALK_MODE); - break; - case 98: - //trigger epoch Yell("Thrall! Come outside and face your fate! ....") - break; - case 106: - { - //trigger taretha to run down outside - /*if( pInstance ) - uint64 TarethaGUID = pInstance->GetData64(DATA_TARETHA); - if( TarethaGUID ) - { - Creature* Taretha = ((Creature*)Unit::GetUnit((*m_creature), TarethaGUID)); - if( Taretha ) - ((npc_escortAI*)(Taretha->AI()))->Start(false, false, true, 0); - }*/ - - if( PlayerGUID ) - { - Unit* player = ((Creature*)Unit::GetUnit((*m_creature), PlayerGUID)); - if( player && player->GetTypeId() == TYPEID_PLAYER ) - ((Player*)player)->KilledMonster(20156,m_creature->GetGUID()); - } - - //alot will happen here, thrall and taretha talk, erozion appear at spot to explain - m_creature->SummonCreature(EROZION_ENTRY,2646.47,680.416,55.38,4.16,TEMPSUMMON_TIMED_DESPAWN,120000); - } - break; - } - } - - void Reset() - { - sum = NULL; - LowHp = false; - - if( HadMount ) - DoMount(); - - if( !IsBeingEscorted ) - { - DoUnmount(); - HadMount = false; - m_creature->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_DISPLAY, 0); - m_creature->SetUInt32Value(UNIT_VIRTUAL_ITEM_INFO, 0); - m_creature->SetUInt32Value(UNIT_VIRTUAL_ITEM_INFO+1, 0); - m_creature->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_DISPLAY+1, 0); - m_creature->SetUInt32Value(UNIT_VIRTUAL_ITEM_INFO+2, 0); - m_creature->SetUInt32Value(UNIT_VIRTUAL_ITEM_INFO+3, 0); - m_creature->SetUInt32Value(UNIT_FIELD_DISPLAYID, THRALL_MODEL_UNEQUIPPED); - } - if( IsBeingEscorted ) - { - switch(rand()%3) - { - case 0: - DoYell(THRALL_LEAVE_COMBAT1,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_LEAVE_COMBAT1); - break; - case 1: - DoYell(THRALL_LEAVE_COMBAT2,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_LEAVE_COMBAT2); - break; - case 2: - DoYell(THRALL_LEAVE_COMBAT3,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_LEAVE_COMBAT3); - break; - } - } - } - void StartWP() - { - m_creature->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP); - IsOnHold = false; - } - void DoMount() - { - m_creature->Mount(SKARLOC_MOUNT_MODEL); - m_creature->SetSpeed(MOVE_RUN,SPEED_MOUNT); - m_creature->RemoveUnitMovementFlag(MOVEMENTFLAG_WALK_MODE); - } - void DoUnmount() - { - m_creature->Unmount(); - m_creature->SetSpeed(MOVE_RUN,SPEED_RUN); - } - void Aggro(Unit* who) - { - switch(rand()%4) - { - case 0: - DoYell(THRALL_RANDOM_AGGRO1,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_RANDOM_AGGRO1); - break; - case 1: - DoYell(THRALL_RANDOM_AGGRO2,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_RANDOM_AGGRO2); - break; - case 2: - DoYell(THRALL_RANDOM_AGGRO3,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_RANDOM_AGGRO3); - break; - case 3: - DoYell(THRALL_RANDOM_AGGRO4,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_RANDOM_AGGRO4); - break; - } - if( m_creature->IsMounted() ) - { - DoUnmount(); - HadMount = true; - } - } - void KilledUnit(Unit *victim) - { - switch(rand()%3) - { - case 0: - DoYell(THRALL_RANDOM_KILL1,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_RANDOM_KILL1); - break; - case 1: - DoYell(THRALL_RANDOM_KILL2,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_RANDOM_KILL2); - break; - case 2: - DoYell(THRALL_RANDOM_KILL3,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_RANDOM_KILL3); - break; - } - } - void JustDied(Unit *slayer) - { - if(slayer == m_creature) // Don't do a yell if he kills self (if player goes too far or at the end). - return; - - switch(rand()%2) - { - case 0: - DoYell(THRALL_RANDOM_DIE1,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_RANDOM_DIE1); - break; - case 1: - DoYell(THRALL_RANDOM_DIE2,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_RANDOM_DIE2); - break; - } - if( pInstance ) - pInstance->SetData(TYPE_THRALL_EVENT,FAIL); - } - void UpdateAI(const uint32 diff) - { - npc_escortAI::UpdateAI(diff); - - if( InCombat && m_creature->getVictim() ) - { - //add his abilities'n-crap here - - if( !LowHp && ((m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < 20) ) - { - switch(rand()%2) - { - case 0: - DoYell(THRALL_RANDOM_LOW_HP1,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_RANDOM_LOW_HP1); - break; - case 1: - DoYell(THRALL_RANDOM_LOW_HP2,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_RANDOM_LOW_HP2); - break; - } - LowHp = true; - } - } - } -}; - -CreatureAI* GetAI_npc_thrall_old_hillsbrad(Creature *_Creature) -{ - npc_thrall_old_hillsbradAI* thrall_walkAI = new npc_thrall_old_hillsbradAI(_Creature); - - thrall_walkAI->AddWaypoint(0, 2230.91, 118.765, 82.2947,5000); - thrall_walkAI->AddWaypoint(1, 2230.33, 114.980, 82.2946); - thrall_walkAI->AddWaypoint(2, 2233.36, 111.057, 82.2996); - thrall_walkAI->AddWaypoint(3, 2231.17, 108.486, 82.6624); - thrall_walkAI->AddWaypoint(4, 2220.22, 114.605, 89.4264); - thrall_walkAI->AddWaypoint(5, 2215.23, 115.990, 89.4549); - thrall_walkAI->AddWaypoint(6, 2210.00, 106.849, 89.4549); - thrall_walkAI->AddWaypoint(7, 2205.66, 105.234, 89.4549); - //spawn armorer - thrall_walkAI->AddWaypoint(8, 2192.26, 112.618, 89.4549); - - //get weapon - thrall_walkAI->AddWaypoint(9, 2181.28, 118.612, 89.4549,8000); - //get armor - thrall_walkAI->AddWaypoint(10, 2181.62, 120.385, 89.4549,5000); - - thrall_walkAI->AddWaypoint(11, 2189.44, 113.922, 89.4549); - thrall_walkAI->AddWaypoint(12, 2195.63, 110.584, 89.4549); - thrall_walkAI->AddWaypoint(13, 2201.09, 115.115, 89.4549); - thrall_walkAI->AddWaypoint(14, 2204.34, 121.036, 89.4355); - //first ambush - thrall_walkAI->AddWaypoint(15, 2208.66, 129.127, 87.9560); - thrall_walkAI->AddWaypoint(16, 2193.09, 137.940, 88.2164); - thrall_walkAI->AddWaypoint(17, 2173.39, 149.064, 87.9227); - thrall_walkAI->AddWaypoint(18, 2164.25, 137.965, 85.0595); - thrall_walkAI->AddWaypoint(19, 2149.31, 125.645, 77.0858); - thrall_walkAI->AddWaypoint(20, 2142.78, 127.173, 75.5954); - //second ambush - thrall_walkAI->AddWaypoint(21, 2139.28, 133.952, 73.6386); - thrall_walkAI->AddWaypoint(22, 2139.54, 155.235, 67.1269); - thrall_walkAI->AddWaypoint(23, 2145.38, 167.551, 64.8974); - thrall_walkAI->AddWaypoint(24, 2134.28, 175.304, 67.9446); - thrall_walkAI->AddWaypoint(25, 2118.08, 187.387, 68.8141); - //third ambush - thrall_walkAI->AddWaypoint(26, 2105.88, 195.461, 65.1854); - thrall_walkAI->AddWaypoint(27, 2096.77, 196.939, 65.2117); - thrall_walkAI->AddWaypoint(28, 2083.90, 209.395, 64.8736); - //in front of keeps gate, meeting scarloc - thrall_walkAI->AddWaypoint(29, 2067.84, 224.376, 64.8022,30000); - - //ref point after skarloc fight - thrall_walkAI->AddWaypoint(30, 2055.40, 242.90, 63.3418); - - //mount up! - thrall_walkAI->AddWaypoint(31, 2039.20, 266.460, 63.0182,10000); - thrall_walkAI->AddWaypoint(32, 2011.77, 278.478, 65.3388); - thrall_walkAI->AddWaypoint(33, 2005.08, 289.676, 66.1179); - thrall_walkAI->AddWaypoint(34, 2033.11, 337.450, 66.0948); - thrall_walkAI->AddWaypoint(35, 2070.30, 416.208, 66.0893); - thrall_walkAI->AddWaypoint(36, 2086.76, 469.768, 65.9182); - //possible road ambush - thrall_walkAI->AddWaypoint(37, 2101.70, 497.955, 61.7881); - - thrall_walkAI->AddWaypoint(38, 2133.39, 530.933, 55.3700,5000); - thrall_walkAI->AddWaypoint(39, 2157.91, 559.635, 48.5157); - thrall_walkAI->AddWaypoint(40, 2167.34, 586.191, 42.4394); - thrall_walkAI->AddWaypoint(41, 2174.17, 637.643, 33.9002); - thrall_walkAI->AddWaypoint(42, 2179.31, 656.053, 34.723); - thrall_walkAI->AddWaypoint(43, 2183.65, 670.941, 34.0318); - thrall_walkAI->AddWaypoint(44, 2201.50, 668.616, 36.1236); - thrall_walkAI->AddWaypoint(45, 2221.56, 652.747, 36.6153); - thrall_walkAI->AddWaypoint(46, 2238.97, 640.125, 37.2214); - thrall_walkAI->AddWaypoint(47, 2251.17, 620.574, 40.1473); - thrall_walkAI->AddWaypoint(48, 2261.98, 595.303, 41.4117); - thrall_walkAI->AddWaypoint(49, 2278.67, 560.172, 38.9090); - thrall_walkAI->AddWaypoint(50, 2336.72, 528.327, 40.9369); - thrall_walkAI->AddWaypoint(51, 2381.04, 519.612, 37.7312); - thrall_walkAI->AddWaypoint(52, 2412.20, 515.425, 39.2068); - thrall_walkAI->AddWaypoint(53, 2452.39, 516.174, 42.9387); - thrall_walkAI->AddWaypoint(54, 2467.38, 539.389, 47.4992); - thrall_walkAI->AddWaypoint(55, 2470.70, 554.333, 46.6668); - thrall_walkAI->AddWaypoint(56, 2478.07, 575.321, 55.4549); - thrall_walkAI->AddWaypoint(57, 2480.00, 585.408, 56.6921); - thrall_walkAI->AddWaypoint(58, 2482.67, 608.817, 55.6643); - //demount - thrall_walkAI->AddWaypoint(59, 2485.62, 626.061, 58.0132,2000); - //scare the shit out of horse, so it'll run off - thrall_walkAI->AddWaypoint(60, 2486.91, 626.356, 58.0761); - - thrall_walkAI->AddWaypoint(61, 2488.58, 660.940, 57.3913); - thrall_walkAI->AddWaypoint(62, 2502.56, 686.059, 55.6252); - thrall_walkAI->AddWaypoint(63, 2502.08, 694.360, 55.5083); - thrall_walkAI->AddWaypoint(64, 2491.46, 694.321, 55.7163); - thrall_walkAI->AddWaypoint(65, 2491.10, 703.300, 55.7630); - thrall_walkAI->AddWaypoint(66, 2485.64, 702.992, 55.7917); - - thrall_walkAI->AddWaypoint(67, 2479.10, 695.291, 55.7901,10000); - //spawn mobs - thrall_walkAI->AddWaypoint(68, 2476.75, 693.689, 55.7960); - thrall_walkAI->AddWaypoint(69, 2475.39, 695.983, 55.8146); - thrall_walkAI->AddWaypoint(70, 2477.75, 694.473, 55.7945); - //meet mobs in doorway - thrall_walkAI->AddWaypoint(71, 2481.27, 697.747, 55.7910); - - thrall_walkAI->AddWaypoint(72, 2486.31, 703.131, 55.7861,5000); - thrall_walkAI->AddWaypoint(73, 2490.76, 703.511, 55.7662); - thrall_walkAI->AddWaypoint(74, 2491.30, 694.792, 55.7195); - thrall_walkAI->AddWaypoint(75, 2518.69, 693.876, 55.1383); - thrall_walkAI->AddWaypoint(76, 2531.33, 681.914, 55.1383); - thrall_walkAI->AddWaypoint(77, 2568.25, 682.654, 55.1778); - thrall_walkAI->AddWaypoint(78, 2589.61, 689.981, 55.1421); - thrall_walkAI->AddWaypoint(79, 2634.74, 679.833, 54.6613); - thrall_walkAI->AddWaypoint(80, 2630.41, 661.464, 54.2761); - thrall_walkAI->AddWaypoint(81, 2629.00, 656.982, 56.0651); - //stop in church - thrall_walkAI->AddWaypoint(82, 2620.84, 633.007, 56.0300,3000); - //summon - thrall_walkAI->AddWaypoint(83, 2622.99, 639.178, 56.0300); - - thrall_walkAI->AddWaypoint(84, 2628.73, 656.693, 56.0610,5000); - thrall_walkAI->AddWaypoint(85, 2630.34, 661.135, 54.2738); - thrall_walkAI->AddWaypoint(86, 2635.38, 672.243, 54.4508); - thrall_walkAI->AddWaypoint(87, 2644.13, 668.158, 55.3797); - thrall_walkAI->AddWaypoint(88, 2646.82, 666.740, 56.9898); - thrall_walkAI->AddWaypoint(89, 2658.22, 665.432, 57.1725); - thrall_walkAI->AddWaypoint(90, 2661.88, 674.849, 57.1725); - thrall_walkAI->AddWaypoint(91, 2656.23, 677.208, 57.1725); - - thrall_walkAI->AddWaypoint(92, 2652.28, 670.270, 61.9353); - //summon inn - thrall_walkAI->AddWaypoint(93, 2650.79, 664.290, 61.9302); - thrall_walkAI->AddWaypoint(94, 2658.19, 660.454, 61.9320,5000); - //speak with Taretha - thrall_walkAI->AddWaypoint(95, 2660.57, 659.173, 61.9370); - - //epoch calls - thrall_walkAI->AddWaypoint(96, 2658.19, 660.454, 61.9320,5000); - //taretha "dies" - thrall_walkAI->AddWaypoint(97, 2659.84, 659.482, 61.9361,5000); - - thrall_walkAI->AddWaypoint(98, 2654.28, 662.722, 61.9313); - thrall_walkAI->AddWaypoint(99, 2652.37, 670.561, 61.9368); - thrall_walkAI->AddWaypoint(100, 2656.05, 676.761, 57.1727); - thrall_walkAI->AddWaypoint(101, 2658.49, 677.166, 57.1727); - thrall_walkAI->AddWaypoint(102, 2659.28, 667.117, 57.1727); - thrall_walkAI->AddWaypoint(103, 2649.71, 665.387, 57.1727); - //he's outside inn here - thrall_walkAI->AddWaypoint(104, 2634.79, 672.964, 54.4577); - - //getting ready here, must start attack before 30secs up - thrall_walkAI->AddWaypoint(105, 2635.06, 673.892, 54.4713,30000); - - //ref point, will move here when all dead and meet Taretha - thrall_walkAI->AddWaypoint(106, 2634.79, 672.964, 54.4577,60000); - - //run off - thrall_walkAI->AddWaypoint(107, 2631.72, 665.629, 54.2923); - thrall_walkAI->AddWaypoint(108, 2647.40, 640.530, 55.7634); - - return (CreatureAI*)thrall_walkAI; -} - -bool GossipHello_npc_thrall_old_hillsbrad(Player *player, Creature *_Creature) -{ - if( _Creature->isQuestGiver() ) - player->PrepareQuestMenu( _Creature->GetGUID() ); - - ScriptedInstance* pInstance = ((ScriptedInstance*)_Creature->GetInstanceData()); - if( pInstance ) - { - //if( pInstance->GetData(TYPE_BARREL_DIVERSION) == DONE && pInstance->GetData(TYPE_THRALL_EVENT) == NOT_STARTED ) - if( pInstance->GetData(TYPE_THRALL_EVENT) == NOT_STARTED ) - { - player->ADD_GOSSIP_ITEM( 0, "[PH] Start walking.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); - player->SEND_GOSSIP_MENU(GOSSIP_ID_START, _Creature->GetGUID()); - } - if( pInstance->GetData(TYPE_THRALL_PART1) == DONE && !pInstance->GetData(TYPE_THRALL_PART2) ) - { - player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM_SKARLOC1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2); - player->SEND_GOSSIP_MENU(GOSSIP_ID_SKARLOC1, _Creature->GetGUID()); - } - if( pInstance->GetData(TYPE_THRALL_PART2) == DONE && !pInstance->GetData(TYPE_THRALL_PART3) ) - { - player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM_TARREN, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+3); - player->SEND_GOSSIP_MENU(GOSSIP_ID_TARREN, _Creature->GetGUID()); - } - } - return true; -} - -bool GossipSelect_npc_thrall_old_hillsbrad(Player *player, Creature *_Creature, uint32 sender, uint32 action) -{ - ScriptedInstance* pInstance = ((ScriptedInstance*)_Creature->GetInstanceData()); - switch( action ) - { - case GOSSIP_ACTION_INFO_DEF+1: - player->CLOSE_GOSSIP_MENU(); - pInstance->SetData(TYPE_THRALL_EVENT,IN_PROGRESS); - pInstance->SetData(TYPE_THRALL_PART1,IN_PROGRESS); - - _Creature->Say(THRALL_START_EVENT_PART1, LANG_UNIVERSAL, 0); - ((npc_thrall_old_hillsbradAI*)_Creature->AI())->DoPlaySoundToSet(_Creature,SOUND_START_EVENT); - - ((npc_escortAI*)(_Creature->AI()))->Start(true, true, true, player->GetGUID()); - break; - - case GOSSIP_ACTION_INFO_DEF+2: - player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM_SKARLOC2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+20); - player->SEND_GOSSIP_MENU(GOSSIP_ID_SKARLOC2, _Creature->GetGUID()); - break; - - case GOSSIP_ACTION_INFO_DEF+20: - player->SEND_GOSSIP_MENU(GOSSIP_ID_SKARLOC3, _Creature->GetGUID()); - _Creature->SummonCreature(SKARLOC_MOUNT,2038.81,270.26,63.20,5.41,TEMPSUMMON_TIMED_DESPAWN,12000); - pInstance->SetData(TYPE_THRALL_PART2,IN_PROGRESS); - - _Creature->Say(THRALL_START_EVENT_PART2, LANG_UNIVERSAL, 0); - ((npc_thrall_old_hillsbradAI*)_Creature->AI())->DoPlaySoundToSet(_Creature,SOUND_START_EVENT_PART2); - - ((npc_thrall_old_hillsbradAI*)_Creature->AI())->StartWP(); - break; - - case GOSSIP_ACTION_INFO_DEF+3: - player->CLOSE_GOSSIP_MENU(); - pInstance->SetData(TYPE_THRALL_PART3,IN_PROGRESS); - ((npc_thrall_old_hillsbradAI*)_Creature->AI())->StartWP(); - break; - } - return true; -} - -/*###### -## npc_taretha -######*/ - -#define GOSSIP_ID_EPOCH1 9610 //Thank you for helping Thrall escape, friends. Now I only hope -#define GOSSIP_ITEM_EPOCH1 "Strange wizard?" -#define GOSSIP_ID_EPOCH2 9613 //Yes, friends. This man was no wizard of -#define GOSSIP_ITEM_EPOCH2 "We'll get you out. Taretha. Don't worry. I doubt the wizard would wander too far away." - -#define TARETHA_FREE "I'm free! Thank you all!" - -struct MANGOS_DLL_DECL npc_tarethaAI : public npc_escortAI -{ - npc_tarethaAI(Creature *c) : npc_escortAI(c) - { - pInstance = ((ScriptedInstance*)c->GetInstanceData()); - Reset(); - } - - ScriptedInstance *pInstance; - - void WaypointReached(uint32 i) - { - switch( i ) - { - case 6: - m_creature->Say(TARETHA_FREE, LANG_UNIVERSAL, 0); - break; - case 7: - m_creature->HandleEmoteCommand(EMOTE_ONESHOT_CHEER); - break; - } - } - void Reset() {} - void Aggro(Unit* who) {} - -}; -CreatureAI* GetAI_npc_taretha(Creature *_Creature) -{ - npc_tarethaAI* taretha_walkAI = new npc_tarethaAI(_Creature); - - taretha_walkAI->AddWaypoint(0, 2650.06, 665.473, 61.9305); - taretha_walkAI->AddWaypoint(1, 2652.44, 670.761, 61.9370); - taretha_walkAI->AddWaypoint(2, 2655.96, 676.913, 57.1725); - taretha_walkAI->AddWaypoint(3, 2659.40, 677.317, 57.1725); - taretha_walkAI->AddWaypoint(4, 2651.75, 664.482, 57.1725); - taretha_walkAI->AddWaypoint(5, 2647.49, 666.595, 57.0824); - taretha_walkAI->AddWaypoint(6, 2644.37, 668.167, 55.4182); - taretha_walkAI->AddWaypoint(7, 2640.96, 669.890, 54.7567,60000); - - return (CreatureAI*)taretha_walkAI; -} - -bool GossipHello_npc_taretha(Player *player, Creature *_Creature) -{ - ScriptedInstance* pInstance = ((ScriptedInstance*)_Creature->GetInstanceData()); - if( pInstance && pInstance->GetData(TYPE_THRALL_PART3) == DONE && pInstance->GetData(TYPE_THRALL_PART4) == NOT_STARTED) - { - player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM_EPOCH1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); - player->SEND_GOSSIP_MENU(GOSSIP_ID_EPOCH1, _Creature->GetGUID()); - } - return true; -} - -bool GossipSelect_npc_taretha(Player *player, Creature *_Creature, uint32 sender, uint32 action) -{ - ScriptedInstance* pInstance = ((ScriptedInstance*)_Creature->GetInstanceData()); - if( action == GOSSIP_ACTION_INFO_DEF+1 ) - { - player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM_EPOCH2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2); - player->SEND_GOSSIP_MENU(GOSSIP_ID_EPOCH2, _Creature->GetGUID()); - } - if( action == GOSSIP_ACTION_INFO_DEF+2 ) - { - player->CLOSE_GOSSIP_MENU(); - - if( pInstance->GetData(TYPE_THRALL_EVENT) == IN_PROGRESS ) - { - pInstance->SetData(TYPE_THRALL_PART4,IN_PROGRESS); - _Creature->SummonCreature(18096,2639.13,698.55,65.43,4.59,TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,120000); - - uint64 ThrallGUID = pInstance->GetData64(DATA_THRALL); - if(ThrallGUID) - { - Creature* Thrall = ((Creature*)Unit::GetUnit((*_Creature), ThrallGUID)); - if(Thrall) - ((npc_thrall_old_hillsbradAI*)Thrall->AI())->StartWP(); - } - } - } - return true; -} - -/*###### -## AddSC -######*/ - -void AddSC_old_hillsbrad() -{ - Script *newscript; - - newscript = new Script; - newscript->Name="npc_brazen"; - newscript->pGossipHello = &GossipHello_npc_brazen; - newscript->pGossipSelect = &GossipSelect_npc_brazen; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="npc_erozion"; - newscript->pGossipHello = &GossipHello_npc_erozion; - newscript->pGossipSelect = &GossipSelect_npc_erozion; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="npc_thrall_old_hillsbrad"; - newscript->pGossipHello = &GossipHello_npc_thrall_old_hillsbrad; - newscript->pGossipSelect = &GossipSelect_npc_thrall_old_hillsbrad; - newscript->GetAI = GetAI_npc_thrall_old_hillsbrad; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="npc_taretha"; - newscript->pGossipHello = &GossipHello_npc_taretha; - newscript->pGossipSelect = &GossipSelect_npc_taretha; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006,2007 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Old_Hillsbrad +SD%Complete: 40 +SDComment: All friendly NPC's. Thrall waypoints fairly complete, missing many details, but possible to complete escort. +SDCategory: Caverns of Time, Old Hillsbrad Foothills +EndScriptData */ + +/* ContentData +npc_brazen +npc_erozion +npc_thrall_old_hillsbrad +npc_taretha +EndContentData */ + +#include "precompiled.h" +#include "../../../npc/npc_escortAI.h" +#include "def_old_hillsbrad.h" + +#define QUEST_ENTRY_HILLSBRAD 10282 +#define QUEST_ENTRY_DIVERSION 10283 +#define QUEST_ENTRY_ESCAPE 10284 +#define QUEST_ENTRY_RETURN 10285 +#define ITEM_ENTRY_BOMBS 25853 + +/*###### +## npc_brazen +######*/ + +bool GossipHello_npc_brazen(Player *player, Creature *_Creature) +{ + player->ADD_GOSSIP_ITEM(0, "I am ready to go to Durnholde Keep.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); + player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); + return true; +} + +bool GossipSelect_npc_brazen(Player *player, Creature *_Creature, uint32 sender, uint32 action ) +{ + if (action == GOSSIP_ACTION_INFO_DEF+1) + { + if( !player->HasItemCount(ITEM_ENTRY_BOMBS,1) ) + player->SEND_GOSSIP_MENU(9780, _Creature->GetGUID()); + else + { + player->CLOSE_GOSSIP_MENU(); + + std::vector nodes; + + nodes.resize(2); + nodes[0] = 115; //from brazen + nodes[1] = 116; //end outside durnholde + player->ActivateTaxiPathTo(nodes); //TaxiPath 534 + } + } + return true; +} + +/*###### +## npc_erozion +######*/ + +bool GossipHello_npc_erozion(Player *player, Creature *_Creature) +{ + if( _Creature->isQuestGiver() ) + player->PrepareQuestMenu( _Creature->GetGUID() ); + + ScriptedInstance* pInstance = ((ScriptedInstance*)_Creature->GetInstanceData()); + if( pInstance && pInstance->GetData(TYPE_BARREL_DIVERSION) != DONE && !player->HasItemCount(ITEM_ENTRY_BOMBS,1) ) + player->ADD_GOSSIP_ITEM( 0, "I need a pack of Incendiary Bombs.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); + + if( !player->GetQuestRewardStatus(QUEST_ENTRY_RETURN) && player->GetQuestStatus(QUEST_ENTRY_RETURN) == QUEST_STATUS_COMPLETE ) + player->ADD_GOSSIP_ITEM( 0, "[PH] Teleport please, i'm tired.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2); + + player->SEND_GOSSIP_MENU(9778, _Creature->GetGUID()); + + return true; +} + +bool GossipSelect_npc_erozion(Player *player, Creature *_Creature, uint32 sender, uint32 action) +{ + if( action == GOSSIP_ACTION_INFO_DEF+1 ) + { + ItemPosCountVec dest; + uint8 msg = player->CanStoreNewItem( NULL_BAG, NULL_SLOT, dest, ITEM_ENTRY_BOMBS, 1, false); + if( msg == EQUIP_ERR_OK ) + { + player->StoreNewItem( dest, ITEM_ENTRY_BOMBS, 1, true); + } + player->SEND_GOSSIP_MENU(9515, _Creature->GetGUID()); + } + if( action == GOSSIP_ACTION_INFO_DEF+2 ) + { + player->CLOSE_GOSSIP_MENU(); + } + return true; +} + +/*###### +## npc_thrall_old_hillsbrad +######*/ + +#define SPEED_WALK (0.5f) +#define SPEED_RUN (1.0f) +#define SPEED_MOUNT (1.6f) + +#define THRALL_WEAPON_MODEL 22106 +#define THRALL_WEAPON_INFO 218169346 +#define THRALL_SHIELD_MODEL 18662 +#define THRALL_SHIELD_INFO 234948100 +#define THRALL_MODEL_UNEQUIPPED 17292 +#define THRALL_MODEL_EQUIPPED 18165 + +#define MOB_ENTRY_RIFLE 17820 +#define MOB_ENTRY_WARDEN 17833 +#define MOB_ENTRY_VETERAN 17860 +#define MOB_ENTRY_WATCHMAN 17814 +#define MOB_ENTRY_SENTRY 17815 + +#define MOB_ENTRY_BARN_GUARDSMAN 18092 +#define MOB_ENTRY_BARN_PROTECTOR 18093 +#define MOB_ENTRY_BARN_LOOKOUT 18094 + +#define MOB_ENTRY_CHURCH_GUARDSMAN 23175 +#define MOB_ENTRY_CHURCH_PROTECTOR 23179 +#define MOB_ENTRY_CHURCH_LOOKOUT 23177 + +#define MOB_ENTRY_INN_GUARDSMAN 23176 +#define MOB_ENTRY_INN_PROTECTOR 23180 +#define MOB_ENTRY_INN_LOOKOUT 23178 + +#define SKARLOC_MOUNT 18798 +#define SKARLOC_MOUNT_MODEL 18223 +#define EROZION_ENTRY 18723 + +#define GOSSIP_ID_START 9568 +#define GOSSIP_ID_SKARLOC1 9614 //I'm glad Taretha is alive. We now must find a way to free her... +#define GOSSIP_ITEM_SKARLOC1 "Taretha cannot see you, Thrall." +#define GOSSIP_ID_SKARLOC2 9579 //What do you mean by this? Is Taretha in danger? +#define GOSSIP_ITEM_SKARLOC2 "The situation is rather complicated, Thrall. It would be best for you to head into the mountains now, before more of Blackmoore's men show up. We'll make sure Taretha is safe." +#define GOSSIP_ID_SKARLOC3 9580 + +#define GOSSIP_ID_TARREN 9597 //tarren mill is beyond these trees +#define GOSSIP_ITEM_TARREN "We're ready, Thrall." + +#define GOSSIP_ID_COMPLETE 9578 //Thank you friends, I owe my freedom to you. Where is Taretha? I hoped to see her + +#define THRALL_START_EVENT_PART1 "Very well then. Let's go!" +#define SOUND_START_EVENT 10465 + +#define THRALL_SAY_ARMOR "As long as we're going with a new plan, I may aswell pick up a weapon and some armor." + +#define THRALL_SKARLOC_MEET "A rider approaches!" +#define SOUND_SKARLOC_MEET 10466 +#define THRALL_SKARLOC_TAUNT "I'll never be chained again!" +#define SOUND_SKARLOC_TAUNT 10467 + +#define THRALL_START_EVENT_PART2 "Very well. Tarren Mill lies just west of here. Since time is of the essence..." +#define SOUND_START_EVENT_PART2 10468 +#define THRALL_MOUNTS_UP "Let's ride!" +#define SOUND_MOUNTS_UP 10469 + +#define THRALL_CHURCH_END "Taretha must be in the inn. Let's go." +#define THRALL_MEET_TARETHA "Taretha! What foul magic is this?" + +#define THRALL_EPOCH_WONDER "Who or what was that?" +#define SOUND_EPOCH_WONDER 10470 +#define THRALL_EPOCH_KILL_TARETHA "No!" +#define SOUND_EPOCH_KILL_TARETHA 10471 + +#define THRALL_EVENT_COMPLETE "Goodbye, Taretha. I will never forget your kindness." +#define SOUND_EVENT_COMPLETE 10472 + +#define THRALL_RANDOM_LOW_HP1 "Things are looking grim..." +#define SOUND_RANDOM_LOW_HP1 10458 +#define THRALL_RANDOM_LOW_HP2 "I will fight to the last!" +#define SOUND_RANDOM_LOW_HP2 10459 + +#define THRALL_RANDOM_DIE1 "Taretha..." +#define SOUND_RANDOM_DIE1 10460 +#define THRALL_RANDOM_DIE2 "A good day...to die..." +#define SOUND_RANDOM_DIE2 10461 + +#define THRALL_RANDOM_AGGRO1 "I have earned my freedom!" +#define SOUND_RANDOM_AGGRO1 10448 +#define THRALL_RANDOM_AGGRO2 "This day is long overdue. Out of my way!" +#define SOUND_RANDOM_AGGRO2 10449 +#define THRALL_RANDOM_AGGRO3 "I am a slave no longer!" +#define SOUND_RANDOM_AGGRO3 10450 +#define THRALL_RANDOM_AGGRO4 "Blackmoore has much to answer for!" +#define SOUND_RANDOM_AGGRO4 10451 + +#define THRALL_RANDOM_KILL1 "You have forced my hand!" +#define SOUND_RANDOM_KILL1 10452 +#define THRALL_RANDOM_KILL2 "It should not have come to this!" +#define SOUND_RANDOM_KILL2 10453 +#define THRALL_RANDOM_KILL3 "I did not ask for this!" +#define SOUND_RANDOM_KILL3 10454 + +#define THRALL_LEAVE_COMBAT1 "I am truly in your debt, strangers." +#define SOUND_LEAVE_COMBAT1 10455 +#define THRALL_LEAVE_COMBAT2 "Thank you, strangers. You have given me hope." +#define SOUND_LEAVE_COMBAT2 10456 +#define THRALL_LEAVE_COMBAT3 "I will not waste this chance. I will seek out my destiny." +#define SOUND_LEAVE_COMBAT3 10457 + +struct MANGOS_DLL_DECL npc_thrall_old_hillsbradAI : public npc_escortAI +{ + npc_thrall_old_hillsbradAI(Creature *c) : npc_escortAI(c) + { + pInstance = ((ScriptedInstance*)c->GetInstanceData()); + Reset(); + } + + ScriptedInstance *pInstance; + Creature* sum; + uint64 TarethaGUID; + bool LowHp; + bool HadMount; + + void WaypointReached(uint32 i) + { + switch( i ) + { + case 8: + m_creature->AddUnitMovementFlag(MOVEMENTFLAG_WALK_MODE); + sum = m_creature->SummonCreature(18764,2181.87,112.46,89.45,0.26,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,5000); + if( sum ) sum->AI()->AttackStart(m_creature); + break; + case 9: + m_creature->AddUnitMovementFlag(MOVEMENTFLAG_WALK_MODE); + DoSay(THRALL_SAY_ARMOR, LANG_UNIVERSAL, NULL); + m_creature->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_DISPLAY, THRALL_WEAPON_MODEL); + m_creature->SetUInt32Value(UNIT_VIRTUAL_ITEM_INFO, THRALL_WEAPON_INFO); + m_creature->SetUInt32Value(UNIT_VIRTUAL_ITEM_INFO+1, 781); + m_creature->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_DISPLAY+1, THRALL_SHIELD_MODEL); + m_creature->SetUInt32Value(UNIT_VIRTUAL_ITEM_INFO+2, THRALL_SHIELD_INFO); + m_creature->SetUInt32Value(UNIT_VIRTUAL_ITEM_INFO+3, 1038); + break; + case 10: + m_creature->SetUInt32Value(UNIT_FIELD_DISPLAYID, THRALL_MODEL_EQUIPPED); + break; + case 11: + m_creature->RemoveUnitMovementFlag(MOVEMENTFLAG_WALK_MODE); + break; + case 15: + sum = m_creature->SummonCreature(MOB_ENTRY_RIFLE,2200.28,137.37,87.93,5.07,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,5000); + if( sum ) sum->AI()->AttackStart(m_creature); + sum = m_creature->SummonCreature(MOB_ENTRY_WARDEN,2197.44,131.83,87.93,0.78,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,5000); + if( sum ) sum->AI()->AttackStart(m_creature); + sum = m_creature->SummonCreature(MOB_ENTRY_VETERAN,2203.62,135.40,87.93,3.70,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,5000); + if( sum ) sum->AI()->AttackStart(m_creature); + sum = m_creature->SummonCreature(MOB_ENTRY_VETERAN,2200.75,130.13,87.93,1.48,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,5000); + if( sum ) sum->AI()->AttackStart(m_creature); + break; + case 21: + sum = m_creature->SummonCreature(MOB_ENTRY_RIFLE,2135.80,154.01,67.45,4.98,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,5000); + if( sum ) sum->AI()->AttackStart(m_creature); + sum = m_creature->SummonCreature(MOB_ENTRY_WARDEN,2144.36,151.87,67.74,4.46,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,5000); + if( sum ) sum->AI()->AttackStart(m_creature); + sum = m_creature->SummonCreature(MOB_ENTRY_VETERAN,2142.12,154.41,67.12,4.56,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,5000); + if( sum ) sum->AI()->AttackStart(m_creature); + sum = m_creature->SummonCreature(MOB_ENTRY_VETERAN,2138.08,155.38,67.24,4.60,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,5000); + if( sum ) sum->AI()->AttackStart(m_creature); + break; + case 25: + sum = m_creature->SummonCreature(MOB_ENTRY_RIFLE,2102.98,192.17,65.24,6.02,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,5000); + if( sum ) sum->AI()->AttackStart(m_creature); + sum = m_creature->SummonCreature(MOB_ENTRY_WARDEN,2108.48,198.75,65.18,5.15,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,5000); + if( sum ) sum->AI()->AttackStart(m_creature); + sum = m_creature->SummonCreature(MOB_ENTRY_VETERAN,2106.11,197.29,65.18,5.63,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,5000); + if( sum ) sum->AI()->AttackStart(m_creature); + sum = m_creature->SummonCreature(MOB_ENTRY_VETERAN,2104.18,194.82,65.18,5.75,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,5000); + if( sum ) sum->AI()->AttackStart(m_creature); + break; + case 29: + DoSay(THRALL_SKARLOC_MEET, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature,SOUND_SKARLOC_MEET); + sum = m_creature->SummonCreature(17862,2036.48,271.22,63.43,5.27,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,30000); + //temporary,skarloc should rather be triggered to walk up to thrall + if( sum ) sum->AI()->AttackStart(m_creature); + break; + case 30: + IsOnHold = true; + m_creature->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP); + m_creature->AddUnitMovementFlag(MOVEMENTFLAG_WALK_MODE); + break; + case 31: + DoSay(THRALL_MOUNTS_UP, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature,SOUND_MOUNTS_UP); + m_creature->HandleEmoteCommand(EMOTE_ONESHOT_TALK); + DoMount(); + break; + case 37: + //possibly regular patrollers? If so, remove this and let database handle them + sum = m_creature->SummonCreature(MOB_ENTRY_WATCHMAN,2124.26,522.16,56.87,3.99,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,5000); + if( sum ) sum->AI()->AttackStart(m_creature); + sum = m_creature->SummonCreature(MOB_ENTRY_WATCHMAN,2121.69,525.37,57.11,4.01,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,5000); + if( sum ) sum->AI()->AttackStart(m_creature); + sum = m_creature->SummonCreature(MOB_ENTRY_SENTRY,2124.65,524.55,56.63,3.98,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,5000); + if( sum ) sum->AI()->AttackStart(m_creature); + break; + case 59: + m_creature->SummonCreature(SKARLOC_MOUNT,2488.64,625.77,58.26,4.71,TEMPSUMMON_TIMED_DESPAWN,10000); + DoUnmount(); + HadMount = false; + break; + case 60: + m_creature->HandleEmoteCommand(EMOTE_ONESHOT_EXCLAMATION); + //make horsie run off + IsOnHold = true; + m_creature->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP); + if( pInstance ) + pInstance->SetData(TYPE_THRALL_PART2, DONE); + break; + case 64: + m_creature->AddUnitMovementFlag(MOVEMENTFLAG_WALK_MODE); + break; + case 68: + m_creature->SummonCreature(MOB_ENTRY_BARN_PROTECTOR,2500.22,692.60,55.50,2.84,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,5000); + m_creature->SummonCreature(MOB_ENTRY_BARN_LOOKOUT,2500.13,696.55,55.51,3.38,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,5000); + m_creature->SummonCreature(MOB_ENTRY_BARN_GUARDSMAN,2500.55,693.64,55.50,3.14,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,5000); + m_creature->SummonCreature(MOB_ENTRY_BARN_GUARDSMAN,2500.94,695.81,55.50,3.14,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,5000); + break; + case 71: + m_creature->RemoveUnitMovementFlag(MOVEMENTFLAG_WALK_MODE); + break; + case 81: + m_creature->AddUnitMovementFlag(MOVEMENTFLAG_WALK_MODE); + break; + case 83: + sum = m_creature->SummonCreature(MOB_ENTRY_CHURCH_PROTECTOR,2627.33,646.82,56.03,4.28,TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,5000); + if( sum ) sum->AI()->AttackStart(m_creature); + sum = m_creature->SummonCreature(MOB_ENTRY_CHURCH_LOOKOUT,2624.14,648.03,56.03,4.50,TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,5000); + if( sum ) sum->AI()->AttackStart(m_creature); + sum = m_creature->SummonCreature(MOB_ENTRY_CHURCH_GUARDSMAN,2625.32,649.60,56.03,4.38,TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,5000); + if( sum ) sum->AI()->AttackStart(m_creature); + sum = m_creature->SummonCreature(MOB_ENTRY_CHURCH_GUARDSMAN,2627.22,649.00,56.03,4.34,TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,5000); + if( sum ) sum->AI()->AttackStart(m_creature); + break; + case 84: + DoSay(THRALL_CHURCH_END, LANG_UNIVERSAL, NULL); + break; + case 91: + m_creature->AddUnitMovementFlag(MOVEMENTFLAG_WALK_MODE); + case 93: + sum = m_creature->SummonCreature(MOB_ENTRY_INN_PROTECTOR,2652.71,660.31,61.93,1.67,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,5000); + if( sum ) sum->AI()->AttackStart(m_creature); + sum = m_creature->SummonCreature(MOB_ENTRY_INN_LOOKOUT,2648.96,662.59,61.93,0.79,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,5000); + if( sum ) sum->AI()->AttackStart(m_creature); + sum = m_creature->SummonCreature(MOB_ENTRY_INN_GUARDSMAN,2657.36,662.34,61.93,2.68,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,5000); + if( sum ) sum->AI()->AttackStart(m_creature); + sum = m_creature->SummonCreature(MOB_ENTRY_INN_GUARDSMAN,2656.39,659.77,61.93,2.61,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,5000); + if( sum ) sum->AI()->AttackStart(m_creature); + break; + case 94: + m_creature->AddUnitMovementFlag(MOVEMENTFLAG_WALK_MODE); + //trigger taretha Say("Thrall, you escaped!") + break; + case 95: + DoSay(THRALL_MEET_TARETHA, LANG_UNIVERSAL, NULL); + if( pInstance ) + pInstance->SetData(TYPE_THRALL_PART3,DONE); + IsOnHold = true; + break; + case 96: + m_creature->HandleEmoteCommand(EMOTE_ONESHOT_TALK); + DoYell(THRALL_EPOCH_WONDER, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature,SOUND_EPOCH_WONDER); + break; + case 97: + m_creature->HandleEmoteCommand(EMOTE_ONESHOT_EXCLAMATION); + DoYell(THRALL_EPOCH_KILL_TARETHA, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature,SOUND_EPOCH_KILL_TARETHA); + m_creature->RemoveUnitMovementFlag(MOVEMENTFLAG_WALK_MODE); + break; + case 98: + //trigger epoch Yell("Thrall! Come outside and face your fate! ....") + break; + case 106: + { + //trigger taretha to run down outside + /*if( pInstance ) + uint64 TarethaGUID = pInstance->GetData64(DATA_TARETHA); + if( TarethaGUID ) + { + Creature* Taretha = ((Creature*)Unit::GetUnit((*m_creature), TarethaGUID)); + if( Taretha ) + ((npc_escortAI*)(Taretha->AI()))->Start(false, false, true, 0); + }*/ + + if( PlayerGUID ) + { + Unit* player = ((Creature*)Unit::GetUnit((*m_creature), PlayerGUID)); + if( player && player->GetTypeId() == TYPEID_PLAYER ) + ((Player*)player)->KilledMonster(20156,m_creature->GetGUID()); + } + + //alot will happen here, thrall and taretha talk, erozion appear at spot to explain + m_creature->SummonCreature(EROZION_ENTRY,2646.47,680.416,55.38,4.16,TEMPSUMMON_TIMED_DESPAWN,120000); + } + break; + } + } + + void Reset() + { + sum = NULL; + LowHp = false; + + if( HadMount ) + DoMount(); + + if( !IsBeingEscorted ) + { + DoUnmount(); + HadMount = false; + m_creature->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_DISPLAY, 0); + m_creature->SetUInt32Value(UNIT_VIRTUAL_ITEM_INFO, 0); + m_creature->SetUInt32Value(UNIT_VIRTUAL_ITEM_INFO+1, 0); + m_creature->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_DISPLAY+1, 0); + m_creature->SetUInt32Value(UNIT_VIRTUAL_ITEM_INFO+2, 0); + m_creature->SetUInt32Value(UNIT_VIRTUAL_ITEM_INFO+3, 0); + m_creature->SetUInt32Value(UNIT_FIELD_DISPLAYID, THRALL_MODEL_UNEQUIPPED); + } + if( IsBeingEscorted ) + { + switch(rand()%3) + { + case 0: + DoYell(THRALL_LEAVE_COMBAT1,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_LEAVE_COMBAT1); + break; + case 1: + DoYell(THRALL_LEAVE_COMBAT2,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_LEAVE_COMBAT2); + break; + case 2: + DoYell(THRALL_LEAVE_COMBAT3,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_LEAVE_COMBAT3); + break; + } + } + } + void StartWP() + { + m_creature->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP); + IsOnHold = false; + } + void DoMount() + { + m_creature->Mount(SKARLOC_MOUNT_MODEL); + m_creature->SetSpeed(MOVE_RUN,SPEED_MOUNT); + m_creature->RemoveUnitMovementFlag(MOVEMENTFLAG_WALK_MODE); + } + void DoUnmount() + { + m_creature->Unmount(); + m_creature->SetSpeed(MOVE_RUN,SPEED_RUN); + } + void Aggro(Unit* who) + { + switch(rand()%4) + { + case 0: + DoYell(THRALL_RANDOM_AGGRO1,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_RANDOM_AGGRO1); + break; + case 1: + DoYell(THRALL_RANDOM_AGGRO2,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_RANDOM_AGGRO2); + break; + case 2: + DoYell(THRALL_RANDOM_AGGRO3,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_RANDOM_AGGRO3); + break; + case 3: + DoYell(THRALL_RANDOM_AGGRO4,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_RANDOM_AGGRO4); + break; + } + if( m_creature->IsMounted() ) + { + DoUnmount(); + HadMount = true; + } + } + void KilledUnit(Unit *victim) + { + switch(rand()%3) + { + case 0: + DoYell(THRALL_RANDOM_KILL1,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_RANDOM_KILL1); + break; + case 1: + DoYell(THRALL_RANDOM_KILL2,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_RANDOM_KILL2); + break; + case 2: + DoYell(THRALL_RANDOM_KILL3,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_RANDOM_KILL3); + break; + } + } + void JustDied(Unit *slayer) + { + if(slayer == m_creature) // Don't do a yell if he kills self (if player goes too far or at the end). + return; + + switch(rand()%2) + { + case 0: + DoYell(THRALL_RANDOM_DIE1,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_RANDOM_DIE1); + break; + case 1: + DoYell(THRALL_RANDOM_DIE2,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_RANDOM_DIE2); + break; + } + if( pInstance ) + pInstance->SetData(TYPE_THRALL_EVENT,FAIL); + } + void UpdateAI(const uint32 diff) + { + npc_escortAI::UpdateAI(diff); + + if( InCombat && m_creature->getVictim() ) + { + //add his abilities'n-crap here + + if( !LowHp && ((m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < 20) ) + { + switch(rand()%2) + { + case 0: + DoYell(THRALL_RANDOM_LOW_HP1,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_RANDOM_LOW_HP1); + break; + case 1: + DoYell(THRALL_RANDOM_LOW_HP2,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_RANDOM_LOW_HP2); + break; + } + LowHp = true; + } + } + } +}; + +CreatureAI* GetAI_npc_thrall_old_hillsbrad(Creature *_Creature) +{ + npc_thrall_old_hillsbradAI* thrall_walkAI = new npc_thrall_old_hillsbradAI(_Creature); + + thrall_walkAI->AddWaypoint(0, 2230.91, 118.765, 82.2947,5000); + thrall_walkAI->AddWaypoint(1, 2230.33, 114.980, 82.2946); + thrall_walkAI->AddWaypoint(2, 2233.36, 111.057, 82.2996); + thrall_walkAI->AddWaypoint(3, 2231.17, 108.486, 82.6624); + thrall_walkAI->AddWaypoint(4, 2220.22, 114.605, 89.4264); + thrall_walkAI->AddWaypoint(5, 2215.23, 115.990, 89.4549); + thrall_walkAI->AddWaypoint(6, 2210.00, 106.849, 89.4549); + thrall_walkAI->AddWaypoint(7, 2205.66, 105.234, 89.4549); + //spawn armorer + thrall_walkAI->AddWaypoint(8, 2192.26, 112.618, 89.4549); + + //get weapon + thrall_walkAI->AddWaypoint(9, 2181.28, 118.612, 89.4549,8000); + //get armor + thrall_walkAI->AddWaypoint(10, 2181.62, 120.385, 89.4549,5000); + + thrall_walkAI->AddWaypoint(11, 2189.44, 113.922, 89.4549); + thrall_walkAI->AddWaypoint(12, 2195.63, 110.584, 89.4549); + thrall_walkAI->AddWaypoint(13, 2201.09, 115.115, 89.4549); + thrall_walkAI->AddWaypoint(14, 2204.34, 121.036, 89.4355); + //first ambush + thrall_walkAI->AddWaypoint(15, 2208.66, 129.127, 87.9560); + thrall_walkAI->AddWaypoint(16, 2193.09, 137.940, 88.2164); + thrall_walkAI->AddWaypoint(17, 2173.39, 149.064, 87.9227); + thrall_walkAI->AddWaypoint(18, 2164.25, 137.965, 85.0595); + thrall_walkAI->AddWaypoint(19, 2149.31, 125.645, 77.0858); + thrall_walkAI->AddWaypoint(20, 2142.78, 127.173, 75.5954); + //second ambush + thrall_walkAI->AddWaypoint(21, 2139.28, 133.952, 73.6386); + thrall_walkAI->AddWaypoint(22, 2139.54, 155.235, 67.1269); + thrall_walkAI->AddWaypoint(23, 2145.38, 167.551, 64.8974); + thrall_walkAI->AddWaypoint(24, 2134.28, 175.304, 67.9446); + thrall_walkAI->AddWaypoint(25, 2118.08, 187.387, 68.8141); + //third ambush + thrall_walkAI->AddWaypoint(26, 2105.88, 195.461, 65.1854); + thrall_walkAI->AddWaypoint(27, 2096.77, 196.939, 65.2117); + thrall_walkAI->AddWaypoint(28, 2083.90, 209.395, 64.8736); + //in front of keeps gate, meeting scarloc + thrall_walkAI->AddWaypoint(29, 2067.84, 224.376, 64.8022,30000); + + //ref point after skarloc fight + thrall_walkAI->AddWaypoint(30, 2055.40, 242.90, 63.3418); + + //mount up! + thrall_walkAI->AddWaypoint(31, 2039.20, 266.460, 63.0182,10000); + thrall_walkAI->AddWaypoint(32, 2011.77, 278.478, 65.3388); + thrall_walkAI->AddWaypoint(33, 2005.08, 289.676, 66.1179); + thrall_walkAI->AddWaypoint(34, 2033.11, 337.450, 66.0948); + thrall_walkAI->AddWaypoint(35, 2070.30, 416.208, 66.0893); + thrall_walkAI->AddWaypoint(36, 2086.76, 469.768, 65.9182); + //possible road ambush + thrall_walkAI->AddWaypoint(37, 2101.70, 497.955, 61.7881); + + thrall_walkAI->AddWaypoint(38, 2133.39, 530.933, 55.3700,5000); + thrall_walkAI->AddWaypoint(39, 2157.91, 559.635, 48.5157); + thrall_walkAI->AddWaypoint(40, 2167.34, 586.191, 42.4394); + thrall_walkAI->AddWaypoint(41, 2174.17, 637.643, 33.9002); + thrall_walkAI->AddWaypoint(42, 2179.31, 656.053, 34.723); + thrall_walkAI->AddWaypoint(43, 2183.65, 670.941, 34.0318); + thrall_walkAI->AddWaypoint(44, 2201.50, 668.616, 36.1236); + thrall_walkAI->AddWaypoint(45, 2221.56, 652.747, 36.6153); + thrall_walkAI->AddWaypoint(46, 2238.97, 640.125, 37.2214); + thrall_walkAI->AddWaypoint(47, 2251.17, 620.574, 40.1473); + thrall_walkAI->AddWaypoint(48, 2261.98, 595.303, 41.4117); + thrall_walkAI->AddWaypoint(49, 2278.67, 560.172, 38.9090); + thrall_walkAI->AddWaypoint(50, 2336.72, 528.327, 40.9369); + thrall_walkAI->AddWaypoint(51, 2381.04, 519.612, 37.7312); + thrall_walkAI->AddWaypoint(52, 2412.20, 515.425, 39.2068); + thrall_walkAI->AddWaypoint(53, 2452.39, 516.174, 42.9387); + thrall_walkAI->AddWaypoint(54, 2467.38, 539.389, 47.4992); + thrall_walkAI->AddWaypoint(55, 2470.70, 554.333, 46.6668); + thrall_walkAI->AddWaypoint(56, 2478.07, 575.321, 55.4549); + thrall_walkAI->AddWaypoint(57, 2480.00, 585.408, 56.6921); + thrall_walkAI->AddWaypoint(58, 2482.67, 608.817, 55.6643); + //demount + thrall_walkAI->AddWaypoint(59, 2485.62, 626.061, 58.0132,2000); + //scare the shit out of horse, so it'll run off + thrall_walkAI->AddWaypoint(60, 2486.91, 626.356, 58.0761); + + thrall_walkAI->AddWaypoint(61, 2488.58, 660.940, 57.3913); + thrall_walkAI->AddWaypoint(62, 2502.56, 686.059, 55.6252); + thrall_walkAI->AddWaypoint(63, 2502.08, 694.360, 55.5083); + thrall_walkAI->AddWaypoint(64, 2491.46, 694.321, 55.7163); + thrall_walkAI->AddWaypoint(65, 2491.10, 703.300, 55.7630); + thrall_walkAI->AddWaypoint(66, 2485.64, 702.992, 55.7917); + + thrall_walkAI->AddWaypoint(67, 2479.10, 695.291, 55.7901,10000); + //spawn mobs + thrall_walkAI->AddWaypoint(68, 2476.75, 693.689, 55.7960); + thrall_walkAI->AddWaypoint(69, 2475.39, 695.983, 55.8146); + thrall_walkAI->AddWaypoint(70, 2477.75, 694.473, 55.7945); + //meet mobs in doorway + thrall_walkAI->AddWaypoint(71, 2481.27, 697.747, 55.7910); + + thrall_walkAI->AddWaypoint(72, 2486.31, 703.131, 55.7861,5000); + thrall_walkAI->AddWaypoint(73, 2490.76, 703.511, 55.7662); + thrall_walkAI->AddWaypoint(74, 2491.30, 694.792, 55.7195); + thrall_walkAI->AddWaypoint(75, 2518.69, 693.876, 55.1383); + thrall_walkAI->AddWaypoint(76, 2531.33, 681.914, 55.1383); + thrall_walkAI->AddWaypoint(77, 2568.25, 682.654, 55.1778); + thrall_walkAI->AddWaypoint(78, 2589.61, 689.981, 55.1421); + thrall_walkAI->AddWaypoint(79, 2634.74, 679.833, 54.6613); + thrall_walkAI->AddWaypoint(80, 2630.41, 661.464, 54.2761); + thrall_walkAI->AddWaypoint(81, 2629.00, 656.982, 56.0651); + //stop in church + thrall_walkAI->AddWaypoint(82, 2620.84, 633.007, 56.0300,3000); + //summon + thrall_walkAI->AddWaypoint(83, 2622.99, 639.178, 56.0300); + + thrall_walkAI->AddWaypoint(84, 2628.73, 656.693, 56.0610,5000); + thrall_walkAI->AddWaypoint(85, 2630.34, 661.135, 54.2738); + thrall_walkAI->AddWaypoint(86, 2635.38, 672.243, 54.4508); + thrall_walkAI->AddWaypoint(87, 2644.13, 668.158, 55.3797); + thrall_walkAI->AddWaypoint(88, 2646.82, 666.740, 56.9898); + thrall_walkAI->AddWaypoint(89, 2658.22, 665.432, 57.1725); + thrall_walkAI->AddWaypoint(90, 2661.88, 674.849, 57.1725); + thrall_walkAI->AddWaypoint(91, 2656.23, 677.208, 57.1725); + + thrall_walkAI->AddWaypoint(92, 2652.28, 670.270, 61.9353); + //summon inn + thrall_walkAI->AddWaypoint(93, 2650.79, 664.290, 61.9302); + thrall_walkAI->AddWaypoint(94, 2658.19, 660.454, 61.9320,5000); + //speak with Taretha + thrall_walkAI->AddWaypoint(95, 2660.57, 659.173, 61.9370); + + //epoch calls + thrall_walkAI->AddWaypoint(96, 2658.19, 660.454, 61.9320,5000); + //taretha "dies" + thrall_walkAI->AddWaypoint(97, 2659.84, 659.482, 61.9361,5000); + + thrall_walkAI->AddWaypoint(98, 2654.28, 662.722, 61.9313); + thrall_walkAI->AddWaypoint(99, 2652.37, 670.561, 61.9368); + thrall_walkAI->AddWaypoint(100, 2656.05, 676.761, 57.1727); + thrall_walkAI->AddWaypoint(101, 2658.49, 677.166, 57.1727); + thrall_walkAI->AddWaypoint(102, 2659.28, 667.117, 57.1727); + thrall_walkAI->AddWaypoint(103, 2649.71, 665.387, 57.1727); + //he's outside inn here + thrall_walkAI->AddWaypoint(104, 2634.79, 672.964, 54.4577); + + //getting ready here, must start attack before 30secs up + thrall_walkAI->AddWaypoint(105, 2635.06, 673.892, 54.4713,30000); + + //ref point, will move here when all dead and meet Taretha + thrall_walkAI->AddWaypoint(106, 2634.79, 672.964, 54.4577,60000); + + //run off + thrall_walkAI->AddWaypoint(107, 2631.72, 665.629, 54.2923); + thrall_walkAI->AddWaypoint(108, 2647.40, 640.530, 55.7634); + + return (CreatureAI*)thrall_walkAI; +} + +bool GossipHello_npc_thrall_old_hillsbrad(Player *player, Creature *_Creature) +{ + if( _Creature->isQuestGiver() ) + player->PrepareQuestMenu( _Creature->GetGUID() ); + + ScriptedInstance* pInstance = ((ScriptedInstance*)_Creature->GetInstanceData()); + if( pInstance ) + { + //if( pInstance->GetData(TYPE_BARREL_DIVERSION) == DONE && pInstance->GetData(TYPE_THRALL_EVENT) == NOT_STARTED ) + if( pInstance->GetData(TYPE_THRALL_EVENT) == NOT_STARTED ) + { + player->ADD_GOSSIP_ITEM( 0, "[PH] Start walking.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); + player->SEND_GOSSIP_MENU(GOSSIP_ID_START, _Creature->GetGUID()); + } + if( pInstance->GetData(TYPE_THRALL_PART1) == DONE && !pInstance->GetData(TYPE_THRALL_PART2) ) + { + player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM_SKARLOC1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2); + player->SEND_GOSSIP_MENU(GOSSIP_ID_SKARLOC1, _Creature->GetGUID()); + } + if( pInstance->GetData(TYPE_THRALL_PART2) == DONE && !pInstance->GetData(TYPE_THRALL_PART3) ) + { + player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM_TARREN, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+3); + player->SEND_GOSSIP_MENU(GOSSIP_ID_TARREN, _Creature->GetGUID()); + } + } + return true; +} + +bool GossipSelect_npc_thrall_old_hillsbrad(Player *player, Creature *_Creature, uint32 sender, uint32 action) +{ + ScriptedInstance* pInstance = ((ScriptedInstance*)_Creature->GetInstanceData()); + switch( action ) + { + case GOSSIP_ACTION_INFO_DEF+1: + player->CLOSE_GOSSIP_MENU(); + pInstance->SetData(TYPE_THRALL_EVENT,IN_PROGRESS); + pInstance->SetData(TYPE_THRALL_PART1,IN_PROGRESS); + + _Creature->Say(THRALL_START_EVENT_PART1, LANG_UNIVERSAL, 0); + ((npc_thrall_old_hillsbradAI*)_Creature->AI())->DoPlaySoundToSet(_Creature,SOUND_START_EVENT); + + ((npc_escortAI*)(_Creature->AI()))->Start(true, true, true, player->GetGUID()); + break; + + case GOSSIP_ACTION_INFO_DEF+2: + player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM_SKARLOC2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+20); + player->SEND_GOSSIP_MENU(GOSSIP_ID_SKARLOC2, _Creature->GetGUID()); + break; + + case GOSSIP_ACTION_INFO_DEF+20: + player->SEND_GOSSIP_MENU(GOSSIP_ID_SKARLOC3, _Creature->GetGUID()); + _Creature->SummonCreature(SKARLOC_MOUNT,2038.81,270.26,63.20,5.41,TEMPSUMMON_TIMED_DESPAWN,12000); + pInstance->SetData(TYPE_THRALL_PART2,IN_PROGRESS); + + _Creature->Say(THRALL_START_EVENT_PART2, LANG_UNIVERSAL, 0); + ((npc_thrall_old_hillsbradAI*)_Creature->AI())->DoPlaySoundToSet(_Creature,SOUND_START_EVENT_PART2); + + ((npc_thrall_old_hillsbradAI*)_Creature->AI())->StartWP(); + break; + + case GOSSIP_ACTION_INFO_DEF+3: + player->CLOSE_GOSSIP_MENU(); + pInstance->SetData(TYPE_THRALL_PART3,IN_PROGRESS); + ((npc_thrall_old_hillsbradAI*)_Creature->AI())->StartWP(); + break; + } + return true; +} + +/*###### +## npc_taretha +######*/ + +#define GOSSIP_ID_EPOCH1 9610 //Thank you for helping Thrall escape, friends. Now I only hope +#define GOSSIP_ITEM_EPOCH1 "Strange wizard?" +#define GOSSIP_ID_EPOCH2 9613 //Yes, friends. This man was no wizard of +#define GOSSIP_ITEM_EPOCH2 "We'll get you out. Taretha. Don't worry. I doubt the wizard would wander too far away." + +#define TARETHA_FREE "I'm free! Thank you all!" + +struct MANGOS_DLL_DECL npc_tarethaAI : public npc_escortAI +{ + npc_tarethaAI(Creature *c) : npc_escortAI(c) + { + pInstance = ((ScriptedInstance*)c->GetInstanceData()); + Reset(); + } + + ScriptedInstance *pInstance; + + void WaypointReached(uint32 i) + { + switch( i ) + { + case 6: + m_creature->Say(TARETHA_FREE, LANG_UNIVERSAL, 0); + break; + case 7: + m_creature->HandleEmoteCommand(EMOTE_ONESHOT_CHEER); + break; + } + } + void Reset() {} + void Aggro(Unit* who) {} + +}; +CreatureAI* GetAI_npc_taretha(Creature *_Creature) +{ + npc_tarethaAI* taretha_walkAI = new npc_tarethaAI(_Creature); + + taretha_walkAI->AddWaypoint(0, 2650.06, 665.473, 61.9305); + taretha_walkAI->AddWaypoint(1, 2652.44, 670.761, 61.9370); + taretha_walkAI->AddWaypoint(2, 2655.96, 676.913, 57.1725); + taretha_walkAI->AddWaypoint(3, 2659.40, 677.317, 57.1725); + taretha_walkAI->AddWaypoint(4, 2651.75, 664.482, 57.1725); + taretha_walkAI->AddWaypoint(5, 2647.49, 666.595, 57.0824); + taretha_walkAI->AddWaypoint(6, 2644.37, 668.167, 55.4182); + taretha_walkAI->AddWaypoint(7, 2640.96, 669.890, 54.7567,60000); + + return (CreatureAI*)taretha_walkAI; +} + +bool GossipHello_npc_taretha(Player *player, Creature *_Creature) +{ + ScriptedInstance* pInstance = ((ScriptedInstance*)_Creature->GetInstanceData()); + if( pInstance && pInstance->GetData(TYPE_THRALL_PART3) == DONE && pInstance->GetData(TYPE_THRALL_PART4) == NOT_STARTED) + { + player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM_EPOCH1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); + player->SEND_GOSSIP_MENU(GOSSIP_ID_EPOCH1, _Creature->GetGUID()); + } + return true; +} + +bool GossipSelect_npc_taretha(Player *player, Creature *_Creature, uint32 sender, uint32 action) +{ + ScriptedInstance* pInstance = ((ScriptedInstance*)_Creature->GetInstanceData()); + if( action == GOSSIP_ACTION_INFO_DEF+1 ) + { + player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM_EPOCH2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2); + player->SEND_GOSSIP_MENU(GOSSIP_ID_EPOCH2, _Creature->GetGUID()); + } + if( action == GOSSIP_ACTION_INFO_DEF+2 ) + { + player->CLOSE_GOSSIP_MENU(); + + if( pInstance->GetData(TYPE_THRALL_EVENT) == IN_PROGRESS ) + { + pInstance->SetData(TYPE_THRALL_PART4,IN_PROGRESS); + _Creature->SummonCreature(18096,2639.13,698.55,65.43,4.59,TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,120000); + + uint64 ThrallGUID = pInstance->GetData64(DATA_THRALL); + if(ThrallGUID) + { + Creature* Thrall = ((Creature*)Unit::GetUnit((*_Creature), ThrallGUID)); + if(Thrall) + ((npc_thrall_old_hillsbradAI*)Thrall->AI())->StartWP(); + } + } + } + return true; +} + +/*###### +## AddSC +######*/ + +void AddSC_old_hillsbrad() +{ + Script *newscript; + + newscript = new Script; + newscript->Name="npc_brazen"; + newscript->pGossipHello = &GossipHello_npc_brazen; + newscript->pGossipSelect = &GossipSelect_npc_brazen; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="npc_erozion"; + newscript->pGossipHello = &GossipHello_npc_erozion; + newscript->pGossipSelect = &GossipSelect_npc_erozion; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="npc_thrall_old_hillsbrad"; + newscript->pGossipHello = &GossipHello_npc_thrall_old_hillsbrad; + newscript->pGossipSelect = &GossipSelect_npc_thrall_old_hillsbrad; + newscript->GetAI = GetAI_npc_thrall_old_hillsbrad; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="npc_taretha"; + newscript->pGossipHello = &GossipHello_npc_taretha; + newscript->pGossipSelect = &GossipSelect_npc_taretha; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/boss_fathomlord_karathress.cpp b/src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/boss_fathomlord_karathress.cpp index d21c3836d00..c36ffd251d7 100644 --- a/src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/boss_fathomlord_karathress.cpp +++ b/src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/boss_fathomlord_karathress.cpp @@ -1,559 +1,559 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Fathomlord_Karathress -SD%Complete: 50 -SDComment: Missing Multishot, pet, Totems, Windfury, Whirlwind -SDCategory: Coilfang Resevoir, Serpent Shrine Cavern -EndScriptData */ - -#include "precompiled.h" -#include "def_serpent_shrine.h" - -//Karathress spells -#define SPELL_CATACLYSMIC_BOLT 38441 -#define SPELL_POWER_OF_SHARKKIS 38455 -#define SPELL_POWER_OF_TIDALVESS 38452 -#define SPELL_POWER_OF_CARIBDIS 38451 -#define SPELL_ENRAGE 24318 -//Sharkkis spells -#define SPELL_LEECHING_THROW 29436 -#define SPELL_THE_BEAST_WITHIN 38373 -//Tidalvess spells -#define SPELL_FROST_SHOCK 38234 -//Caribdis Spells -#define SPELL_WATER_BOLT_VOLLEY 38335 -#define SPELL_TIDAL_SURGE 38353 -#define SPELL_HEAL 41386 - -#define SAY_AGGRO "Guards, attention! We have visitors..." -#define SAY_SLAY1 "I am rid of you." -#define SAY_GAIN_ABILITY1 "I am more powerful than ever!" -#define SAY_GAIN_ABILITY2 "Go on, kill them! I'll be the better for it!" -#define SAY_GAIN_ABILITY3 "More knowledge, more power!" -#define SAY_DEATH "Her ... excellency ... awaits!" - -#define SOUND_AGGRO 11277 -#define SOUND_PLYR_ATTACK 11278 -#define SOUND_GAIN_ABILITY1 11279 -#define SOUND_GAIN_ABILITY2 11280 -#define SOUND_GAIN_ABILITY3 11281 -#define SOUND_SLAY1 11282 -#define SOUND_SLAY2 11283 -#define SOUND_SLAY3 11284 -#define SOUND_DEATH 11285 - -//entry and position for Seer Olum -#define SEER_OLUM 22820 -#define OLUM_X 446.78f -#define OLUM_Y -542.76f -#define OLUM_Z -7.54773f -#define OLUM_O 0.401581f - -//Fathom-Lord Karathress AI -struct MANGOS_DLL_DECL boss_fathomlord_karathressAI : public ScriptedAI -{ - boss_fathomlord_karathressAI(Creature *c) : ScriptedAI(c) - { - pInstance = ((ScriptedInstance*)c->GetInstanceData()); - Advisors[0] = 0; - Advisors[1] = 0; - Advisors[2] = 0; - Reset(); - } - - ScriptedInstance* pInstance; - - uint32 CataclysmicBolt_Timer; - uint32 Enrage_Timer; - - uint64 Advisors[3]; - - void Reset() - { - CataclysmicBolt_Timer = 10000; - Enrage_Timer = 600000; //10 minutes - - Creature* Advisor; - for(uint8 i = 0; i < 3; ++i) - if(Advisors[i]) - { - Advisor = ((Creature*)Unit::GetUnit(*m_creature, Advisors[i])); - if(Advisor) - { - if(Advisor->isAlive()) - { - Advisor->DealDamage(Advisor, Advisor->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); - Advisor->RemoveCorpse(); - Advisor->Respawn(); - } - Advisor->AI()->EnterEvadeMode(); - } - } - - if( pInstance ) - pInstance->SetData(DATA_KARATHRESSEVENT, NOT_STARTED); - } - - void EventSharkkisDeath() - { - DoPlaySoundToSet(m_creature, SOUND_GAIN_ABILITY1); - DoYell(SAY_GAIN_ABILITY1, LANG_UNIVERSAL, NULL); - DoCast(m_creature, SPELL_POWER_OF_SHARKKIS); - } - - void EventTidalvessDeath() - { - DoPlaySoundToSet(m_creature, SOUND_GAIN_ABILITY2); - DoYell(SAY_GAIN_ABILITY2, LANG_UNIVERSAL, NULL); - DoCast(m_creature, SPELL_POWER_OF_TIDALVESS); - } - - void EventCaribdisDeath() - { - DoPlaySoundToSet(m_creature, SOUND_GAIN_ABILITY3); - DoYell(SAY_GAIN_ABILITY3, LANG_UNIVERSAL, NULL); - DoCast(m_creature, SPELL_POWER_OF_CARIBDIS); - } - - void GetAdvisors() - { - if(!pInstance) - return; - - Advisors[0] = pInstance->GetData64(DATA_SHARKKIS); - Advisors[1] = pInstance->GetData64(DATA_TIDALVESS); - Advisors[2] = pInstance->GetData64(DATA_CARIBDIS); - } - - void StartEvent(Unit *who) - { - if(!pInstance) - return; - - GetAdvisors(); - - DoPlaySoundToSet(m_creature, SOUND_AGGRO); - DoYell(SAY_AGGRO, LANG_UNIVERSAL, NULL); - - pInstance->SetData64(DATA_KARATHRESSEVENT_STARTER, who->GetGUID()); - pInstance->SetData(DATA_KARATHRESSEVENT, IN_PROGRESS); - } - - void KilledUnit(Unit *victim) - { - switch(rand()%3) - { - case 0: - DoPlaySoundToSet(m_creature, SOUND_SLAY1); - DoYell(SAY_SLAY1, LANG_UNIVERSAL, NULL); - break; - case 1: - DoPlaySoundToSet(m_creature, SOUND_SLAY2); - break; - case 2: - DoPlaySoundToSet(m_creature, SOUND_SLAY3); - break; - } - } - - void JustDied(Unit *killer) - { - DoPlaySoundToSet(m_creature, SOUND_DEATH); - DoYell(SAY_DEATH, LANG_UNIVERSAL, NULL); - - if( pInstance ) - pInstance->SetData(DATA_FATHOMLORDKARATHRESSEVENT, NOT_STARTED); - - //support for quest 10944 - m_creature->SummonCreature(SEER_OLUM, OLUM_X, OLUM_Y, OLUM_Z, OLUM_O, TEMPSUMMON_TIMED_DESPAWN, 3600000); - } - - void Aggro(Unit *who) - { - StartEvent(who); - } - - void UpdateAI(const uint32 diff) - { - //Only if not incombat check if the event is started - if(!InCombat && pInstance && pInstance->GetData(DATA_KARATHRESSEVENT)) - { - Unit* target = Unit::GetUnit((*m_creature), pInstance->GetData64(DATA_KARATHRESSEVENT_STARTER)); - - if(target) - { - DoStartAttackAndMovement(target); - - GetAdvisors(); - - DoPlaySoundToSet(m_creature, SOUND_AGGRO); - DoYell(SAY_AGGRO, LANG_UNIVERSAL, NULL); - } - } - - //Return since we have no target - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - //someone evaded! - if(pInstance && !pInstance->GetData(DATA_KARATHRESSEVENT)) - EnterEvadeMode(); - - //CataclysmicBolt_Timer - if(CataclysmicBolt_Timer < diff) - { - //select a random unit other than the main tank - Unit *target = SelectUnit(SELECT_TARGET_RANDOM, 1); - - //if there aren't other units, cast on the tank - if(!target) - target = m_creature->getVictim(); - - int32 dmg = target->GetMaxHealth() / 2; - m_creature->CastCustomSpell(target, SPELL_CATACLYSMIC_BOLT, &dmg, NULL, NULL, false, NULL, NULL, m_creature->GetGUID()); - - CataclysmicBolt_Timer = 10000; - }else CataclysmicBolt_Timer -= diff; - - //Enrage_Timer - if(Enrage_Timer < diff) - { - DoCast(m_creature, SPELL_ENRAGE); - Enrage_Timer = 90000; - }else Enrage_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; - -//Fathom-Guard Sharkkis AI -struct MANGOS_DLL_DECL boss_fathomguard_sharkkisAI : public ScriptedAI -{ - boss_fathomguard_sharkkisAI(Creature *c) : ScriptedAI(c) - { - pInstance = ((ScriptedInstance*)c->GetInstanceData()); - Reset(); - } - - ScriptedInstance* pInstance; - - uint32 LeechingThrow_Timer; - uint32 TheBeastWithin_Timer; - - void Reset() - { - LeechingThrow_Timer = 20000; - TheBeastWithin_Timer = 30000; - - if( pInstance ) - pInstance->SetData(DATA_KARATHRESSEVENT, NOT_STARTED); - } - - void JustDied(Unit *victim) - { - if(pInstance) - { - Creature *Karathress = NULL; - Karathress = (Creature*)(Unit::GetUnit((*m_creature), pInstance->GetData64(DATA_KARATHRESS))); - - if(Karathress) - ((boss_fathomlord_karathressAI*)Karathress->AI())->EventSharkkisDeath(); - } - } - - void Aggro(Unit *who) - { - if(pInstance) - { - pInstance->SetData64(DATA_KARATHRESSEVENT_STARTER, who->GetGUID()); - pInstance->SetData(DATA_KARATHRESSEVENT, IN_PROGRESS); - } - } - - void UpdateAI(const uint32 diff) - { - //Only if not incombat check if the event is started - if(!InCombat && pInstance && pInstance->GetData(DATA_KARATHRESSEVENT)) - { - Unit* target = Unit::GetUnit((*m_creature), pInstance->GetData64(DATA_KARATHRESSEVENT_STARTER)); - - if(target) - { - DoStartAttackAndMovement(target); - } - } - - //Return since we have no target - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - //someone evaded! - if(pInstance && !pInstance->GetData(DATA_KARATHRESSEVENT)) - EnterEvadeMode(); - - //LeechingThrow_Timer - if(LeechingThrow_Timer < diff) - { - DoCast(m_creature->getVictim(), SPELL_LEECHING_THROW); - LeechingThrow_Timer = 20000; - }else LeechingThrow_Timer -= diff; - - //TheBeastWithin_Timer - if(TheBeastWithin_Timer < diff) - { - DoCast(m_creature, SPELL_THE_BEAST_WITHIN); - TheBeastWithin_Timer = 30000; - }else TheBeastWithin_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; - -//Fathom-Guard Tidalvess AI -struct MANGOS_DLL_DECL boss_fathomguard_tidalvessAI : public ScriptedAI -{ - boss_fathomguard_tidalvessAI(Creature *c) : ScriptedAI(c) - { - pInstance = ((ScriptedInstance*)c->GetInstanceData()); - Reset(); - } - - ScriptedInstance* pInstance; - - uint32 FrostShock_Timer; - - void Reset() - { - FrostShock_Timer = 25000; - - if( pInstance ) - pInstance->SetData(DATA_KARATHRESSEVENT, NOT_STARTED); - } - - void JustDied(Unit *victim) - { - if(pInstance) - { - Creature *Karathress = NULL; - Karathress = (Creature*)(Unit::GetUnit((*m_creature), pInstance->GetData64(DATA_KARATHRESS))); - - if(Karathress) - ((boss_fathomlord_karathressAI*)Karathress->AI())->EventTidalvessDeath(); - } - } - - void Aggro(Unit *who) - { - if(pInstance) - { - pInstance->SetData64(DATA_KARATHRESSEVENT_STARTER, who->GetGUID()); - pInstance->SetData(DATA_KARATHRESSEVENT, IN_PROGRESS); - } - } - - void UpdateAI(const uint32 diff) - { - //Only if not incombat check if the event is started - if(!InCombat && pInstance && pInstance->GetData(DATA_KARATHRESSEVENT)) - { - Unit* target = Unit::GetUnit((*m_creature), pInstance->GetData64(DATA_KARATHRESSEVENT_STARTER)); - - if(target) - { - DoStartAttackAndMovement(target); - } - } - - //Return since we have no target - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - //someone evaded! - if(pInstance && !pInstance->GetData(DATA_KARATHRESSEVENT)) - EnterEvadeMode(); - - //FrostShock_Timer - if(FrostShock_Timer < diff) - { - DoCast(m_creature->getVictim(), SPELL_FROST_SHOCK); - FrostShock_Timer = 25000+rand()%5000; - }else FrostShock_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; - -//Fathom-Guard Caribdis AI -struct MANGOS_DLL_DECL boss_fathomguard_caribdisAI : public ScriptedAI -{ - boss_fathomguard_caribdisAI(Creature *c) : ScriptedAI(c) - { - pInstance = ((ScriptedInstance*)c->GetInstanceData()); - Reset(); - } - - ScriptedInstance* pInstance; - - uint32 WaterBoltVolley_Timer; - uint32 TidalSurge_Timer; - uint32 Heal_Timer; - - void Reset() - { - WaterBoltVolley_Timer = 35000; - TidalSurge_Timer = 15000+rand()%5000; - Heal_Timer = 55000; - - if(pInstance) - pInstance->SetData(DATA_KARATHRESSEVENT, NOT_STARTED); - } - - void JustDied(Unit *victim) - { - if(pInstance) - { - Creature *Karathress = NULL; - Karathress = (Creature*)(Unit::GetUnit((*m_creature), pInstance->GetData64(DATA_KARATHRESS))); - - if(Karathress) - ((boss_fathomlord_karathressAI*)Karathress->AI())->EventCaribdisDeath(); - } - } - - void Aggro(Unit *who) - { - if(pInstance) - { - pInstance->SetData64(DATA_KARATHRESSEVENT_STARTER, who->GetGUID()); - pInstance->SetData(DATA_KARATHRESSEVENT, IN_PROGRESS); - } - } - - void UpdateAI(const uint32 diff) - { - //Only if not incombat check if the event is started - if(!InCombat && pInstance && pInstance->GetData(DATA_KARATHRESSEVENT)) - { - Unit* target = Unit::GetUnit((*m_creature), pInstance->GetData64(DATA_KARATHRESSEVENT_STARTER)); - - if(target) - { - DoStartAttackAndMovement(target); - } - } - - //Return since we have no target - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - //someone evaded! - if(pInstance && !pInstance->GetData(DATA_KARATHRESSEVENT)) - EnterEvadeMode(); - - //WaterBoltVolley_Timer - if(WaterBoltVolley_Timer < diff) - { - DoCast(m_creature->getVictim(), SPELL_WATER_BOLT_VOLLEY); - WaterBoltVolley_Timer = 30000; - }else WaterBoltVolley_Timer -= diff; - - //TidalSurge_Timer - if(TidalSurge_Timer < diff) - { - DoCast(m_creature->getVictim(), SPELL_TIDAL_SURGE); - TidalSurge_Timer = 15000+rand()%5000; - }else TidalSurge_Timer -= diff; - - //Heal_Timer - if(Heal_Timer < diff) - { - // It can be cast on any of the mobs - Unit *pUnit = NULL; - - if(pInstance) - { - switch(rand()%4) - { - case 0: - pUnit = Unit::GetUnit((*m_creature), pInstance->GetData64(DATA_KARATHRESS)); - break; - case 1: - pUnit = Unit::GetUnit((*m_creature), pInstance->GetData64(DATA_SHARKKIS)); - break; - case 2: - pUnit = Unit::GetUnit((*m_creature), pInstance->GetData64(DATA_TIDALVESS)); - break; - case 3: - pUnit = m_creature; - break; - } - }else pUnit = m_creature; - - if(pUnit && pUnit->isAlive()) - DoCast(pUnit, SPELL_HEAL); - - Heal_Timer = 60000; - }else Heal_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; - -CreatureAI* GetAI_boss_fathomlord_karathress(Creature *_Creature) -{ - return new boss_fathomlord_karathressAI (_Creature); -} - -CreatureAI* GetAI_boss_fathomguard_sharkkis(Creature *_Creature) -{ - return new boss_fathomguard_sharkkisAI (_Creature); -} - -CreatureAI* GetAI_boss_fathomguard_tidalvess(Creature *_Creature) -{ - return new boss_fathomguard_tidalvessAI (_Creature); -} - -CreatureAI* GetAI_boss_fathomguard_caribdis(Creature *_Creature) -{ - return new boss_fathomguard_caribdisAI (_Creature); -} - -void AddSC_boss_fathomlord_karathress() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_fathomlord_karathress"; - newscript->GetAI = GetAI_boss_fathomlord_karathress; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="boss_fathomguard_sharkkis"; - newscript->GetAI = GetAI_boss_fathomguard_sharkkis; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="boss_fathomguard_tidalvess"; - newscript->GetAI = GetAI_boss_fathomguard_tidalvess; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="boss_fathomguard_caribdis"; - newscript->GetAI = GetAI_boss_fathomguard_caribdis; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Fathomlord_Karathress +SD%Complete: 50 +SDComment: Missing Multishot, pet, Totems, Windfury, Whirlwind +SDCategory: Coilfang Resevoir, Serpent Shrine Cavern +EndScriptData */ + +#include "precompiled.h" +#include "def_serpent_shrine.h" + +//Karathress spells +#define SPELL_CATACLYSMIC_BOLT 38441 +#define SPELL_POWER_OF_SHARKKIS 38455 +#define SPELL_POWER_OF_TIDALVESS 38452 +#define SPELL_POWER_OF_CARIBDIS 38451 +#define SPELL_ENRAGE 24318 +//Sharkkis spells +#define SPELL_LEECHING_THROW 29436 +#define SPELL_THE_BEAST_WITHIN 38373 +//Tidalvess spells +#define SPELL_FROST_SHOCK 38234 +//Caribdis Spells +#define SPELL_WATER_BOLT_VOLLEY 38335 +#define SPELL_TIDAL_SURGE 38353 +#define SPELL_HEAL 41386 + +#define SAY_AGGRO "Guards, attention! We have visitors..." +#define SAY_SLAY1 "I am rid of you." +#define SAY_GAIN_ABILITY1 "I am more powerful than ever!" +#define SAY_GAIN_ABILITY2 "Go on, kill them! I'll be the better for it!" +#define SAY_GAIN_ABILITY3 "More knowledge, more power!" +#define SAY_DEATH "Her ... excellency ... awaits!" + +#define SOUND_AGGRO 11277 +#define SOUND_PLYR_ATTACK 11278 +#define SOUND_GAIN_ABILITY1 11279 +#define SOUND_GAIN_ABILITY2 11280 +#define SOUND_GAIN_ABILITY3 11281 +#define SOUND_SLAY1 11282 +#define SOUND_SLAY2 11283 +#define SOUND_SLAY3 11284 +#define SOUND_DEATH 11285 + +//entry and position for Seer Olum +#define SEER_OLUM 22820 +#define OLUM_X 446.78f +#define OLUM_Y -542.76f +#define OLUM_Z -7.54773f +#define OLUM_O 0.401581f + +//Fathom-Lord Karathress AI +struct MANGOS_DLL_DECL boss_fathomlord_karathressAI : public ScriptedAI +{ + boss_fathomlord_karathressAI(Creature *c) : ScriptedAI(c) + { + pInstance = ((ScriptedInstance*)c->GetInstanceData()); + Advisors[0] = 0; + Advisors[1] = 0; + Advisors[2] = 0; + Reset(); + } + + ScriptedInstance* pInstance; + + uint32 CataclysmicBolt_Timer; + uint32 Enrage_Timer; + + uint64 Advisors[3]; + + void Reset() + { + CataclysmicBolt_Timer = 10000; + Enrage_Timer = 600000; //10 minutes + + Creature* Advisor; + for(uint8 i = 0; i < 3; ++i) + if(Advisors[i]) + { + Advisor = ((Creature*)Unit::GetUnit(*m_creature, Advisors[i])); + if(Advisor) + { + if(Advisor->isAlive()) + { + Advisor->DealDamage(Advisor, Advisor->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); + Advisor->RemoveCorpse(); + Advisor->Respawn(); + } + Advisor->AI()->EnterEvadeMode(); + } + } + + if( pInstance ) + pInstance->SetData(DATA_KARATHRESSEVENT, NOT_STARTED); + } + + void EventSharkkisDeath() + { + DoPlaySoundToSet(m_creature, SOUND_GAIN_ABILITY1); + DoYell(SAY_GAIN_ABILITY1, LANG_UNIVERSAL, NULL); + DoCast(m_creature, SPELL_POWER_OF_SHARKKIS); + } + + void EventTidalvessDeath() + { + DoPlaySoundToSet(m_creature, SOUND_GAIN_ABILITY2); + DoYell(SAY_GAIN_ABILITY2, LANG_UNIVERSAL, NULL); + DoCast(m_creature, SPELL_POWER_OF_TIDALVESS); + } + + void EventCaribdisDeath() + { + DoPlaySoundToSet(m_creature, SOUND_GAIN_ABILITY3); + DoYell(SAY_GAIN_ABILITY3, LANG_UNIVERSAL, NULL); + DoCast(m_creature, SPELL_POWER_OF_CARIBDIS); + } + + void GetAdvisors() + { + if(!pInstance) + return; + + Advisors[0] = pInstance->GetData64(DATA_SHARKKIS); + Advisors[1] = pInstance->GetData64(DATA_TIDALVESS); + Advisors[2] = pInstance->GetData64(DATA_CARIBDIS); + } + + void StartEvent(Unit *who) + { + if(!pInstance) + return; + + GetAdvisors(); + + DoPlaySoundToSet(m_creature, SOUND_AGGRO); + DoYell(SAY_AGGRO, LANG_UNIVERSAL, NULL); + + pInstance->SetData64(DATA_KARATHRESSEVENT_STARTER, who->GetGUID()); + pInstance->SetData(DATA_KARATHRESSEVENT, IN_PROGRESS); + } + + void KilledUnit(Unit *victim) + { + switch(rand()%3) + { + case 0: + DoPlaySoundToSet(m_creature, SOUND_SLAY1); + DoYell(SAY_SLAY1, LANG_UNIVERSAL, NULL); + break; + case 1: + DoPlaySoundToSet(m_creature, SOUND_SLAY2); + break; + case 2: + DoPlaySoundToSet(m_creature, SOUND_SLAY3); + break; + } + } + + void JustDied(Unit *killer) + { + DoPlaySoundToSet(m_creature, SOUND_DEATH); + DoYell(SAY_DEATH, LANG_UNIVERSAL, NULL); + + if( pInstance ) + pInstance->SetData(DATA_FATHOMLORDKARATHRESSEVENT, NOT_STARTED); + + //support for quest 10944 + m_creature->SummonCreature(SEER_OLUM, OLUM_X, OLUM_Y, OLUM_Z, OLUM_O, TEMPSUMMON_TIMED_DESPAWN, 3600000); + } + + void Aggro(Unit *who) + { + StartEvent(who); + } + + void UpdateAI(const uint32 diff) + { + //Only if not incombat check if the event is started + if(!InCombat && pInstance && pInstance->GetData(DATA_KARATHRESSEVENT)) + { + Unit* target = Unit::GetUnit((*m_creature), pInstance->GetData64(DATA_KARATHRESSEVENT_STARTER)); + + if(target) + { + DoStartAttackAndMovement(target); + + GetAdvisors(); + + DoPlaySoundToSet(m_creature, SOUND_AGGRO); + DoYell(SAY_AGGRO, LANG_UNIVERSAL, NULL); + } + } + + //Return since we have no target + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + //someone evaded! + if(pInstance && !pInstance->GetData(DATA_KARATHRESSEVENT)) + EnterEvadeMode(); + + //CataclysmicBolt_Timer + if(CataclysmicBolt_Timer < diff) + { + //select a random unit other than the main tank + Unit *target = SelectUnit(SELECT_TARGET_RANDOM, 1); + + //if there aren't other units, cast on the tank + if(!target) + target = m_creature->getVictim(); + + int32 dmg = target->GetMaxHealth() / 2; + m_creature->CastCustomSpell(target, SPELL_CATACLYSMIC_BOLT, &dmg, NULL, NULL, false, NULL, NULL, m_creature->GetGUID()); + + CataclysmicBolt_Timer = 10000; + }else CataclysmicBolt_Timer -= diff; + + //Enrage_Timer + if(Enrage_Timer < diff) + { + DoCast(m_creature, SPELL_ENRAGE); + Enrage_Timer = 90000; + }else Enrage_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; + +//Fathom-Guard Sharkkis AI +struct MANGOS_DLL_DECL boss_fathomguard_sharkkisAI : public ScriptedAI +{ + boss_fathomguard_sharkkisAI(Creature *c) : ScriptedAI(c) + { + pInstance = ((ScriptedInstance*)c->GetInstanceData()); + Reset(); + } + + ScriptedInstance* pInstance; + + uint32 LeechingThrow_Timer; + uint32 TheBeastWithin_Timer; + + void Reset() + { + LeechingThrow_Timer = 20000; + TheBeastWithin_Timer = 30000; + + if( pInstance ) + pInstance->SetData(DATA_KARATHRESSEVENT, NOT_STARTED); + } + + void JustDied(Unit *victim) + { + if(pInstance) + { + Creature *Karathress = NULL; + Karathress = (Creature*)(Unit::GetUnit((*m_creature), pInstance->GetData64(DATA_KARATHRESS))); + + if(Karathress) + ((boss_fathomlord_karathressAI*)Karathress->AI())->EventSharkkisDeath(); + } + } + + void Aggro(Unit *who) + { + if(pInstance) + { + pInstance->SetData64(DATA_KARATHRESSEVENT_STARTER, who->GetGUID()); + pInstance->SetData(DATA_KARATHRESSEVENT, IN_PROGRESS); + } + } + + void UpdateAI(const uint32 diff) + { + //Only if not incombat check if the event is started + if(!InCombat && pInstance && pInstance->GetData(DATA_KARATHRESSEVENT)) + { + Unit* target = Unit::GetUnit((*m_creature), pInstance->GetData64(DATA_KARATHRESSEVENT_STARTER)); + + if(target) + { + DoStartAttackAndMovement(target); + } + } + + //Return since we have no target + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + //someone evaded! + if(pInstance && !pInstance->GetData(DATA_KARATHRESSEVENT)) + EnterEvadeMode(); + + //LeechingThrow_Timer + if(LeechingThrow_Timer < diff) + { + DoCast(m_creature->getVictim(), SPELL_LEECHING_THROW); + LeechingThrow_Timer = 20000; + }else LeechingThrow_Timer -= diff; + + //TheBeastWithin_Timer + if(TheBeastWithin_Timer < diff) + { + DoCast(m_creature, SPELL_THE_BEAST_WITHIN); + TheBeastWithin_Timer = 30000; + }else TheBeastWithin_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; + +//Fathom-Guard Tidalvess AI +struct MANGOS_DLL_DECL boss_fathomguard_tidalvessAI : public ScriptedAI +{ + boss_fathomguard_tidalvessAI(Creature *c) : ScriptedAI(c) + { + pInstance = ((ScriptedInstance*)c->GetInstanceData()); + Reset(); + } + + ScriptedInstance* pInstance; + + uint32 FrostShock_Timer; + + void Reset() + { + FrostShock_Timer = 25000; + + if( pInstance ) + pInstance->SetData(DATA_KARATHRESSEVENT, NOT_STARTED); + } + + void JustDied(Unit *victim) + { + if(pInstance) + { + Creature *Karathress = NULL; + Karathress = (Creature*)(Unit::GetUnit((*m_creature), pInstance->GetData64(DATA_KARATHRESS))); + + if(Karathress) + ((boss_fathomlord_karathressAI*)Karathress->AI())->EventTidalvessDeath(); + } + } + + void Aggro(Unit *who) + { + if(pInstance) + { + pInstance->SetData64(DATA_KARATHRESSEVENT_STARTER, who->GetGUID()); + pInstance->SetData(DATA_KARATHRESSEVENT, IN_PROGRESS); + } + } + + void UpdateAI(const uint32 diff) + { + //Only if not incombat check if the event is started + if(!InCombat && pInstance && pInstance->GetData(DATA_KARATHRESSEVENT)) + { + Unit* target = Unit::GetUnit((*m_creature), pInstance->GetData64(DATA_KARATHRESSEVENT_STARTER)); + + if(target) + { + DoStartAttackAndMovement(target); + } + } + + //Return since we have no target + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + //someone evaded! + if(pInstance && !pInstance->GetData(DATA_KARATHRESSEVENT)) + EnterEvadeMode(); + + //FrostShock_Timer + if(FrostShock_Timer < diff) + { + DoCast(m_creature->getVictim(), SPELL_FROST_SHOCK); + FrostShock_Timer = 25000+rand()%5000; + }else FrostShock_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; + +//Fathom-Guard Caribdis AI +struct MANGOS_DLL_DECL boss_fathomguard_caribdisAI : public ScriptedAI +{ + boss_fathomguard_caribdisAI(Creature *c) : ScriptedAI(c) + { + pInstance = ((ScriptedInstance*)c->GetInstanceData()); + Reset(); + } + + ScriptedInstance* pInstance; + + uint32 WaterBoltVolley_Timer; + uint32 TidalSurge_Timer; + uint32 Heal_Timer; + + void Reset() + { + WaterBoltVolley_Timer = 35000; + TidalSurge_Timer = 15000+rand()%5000; + Heal_Timer = 55000; + + if(pInstance) + pInstance->SetData(DATA_KARATHRESSEVENT, NOT_STARTED); + } + + void JustDied(Unit *victim) + { + if(pInstance) + { + Creature *Karathress = NULL; + Karathress = (Creature*)(Unit::GetUnit((*m_creature), pInstance->GetData64(DATA_KARATHRESS))); + + if(Karathress) + ((boss_fathomlord_karathressAI*)Karathress->AI())->EventCaribdisDeath(); + } + } + + void Aggro(Unit *who) + { + if(pInstance) + { + pInstance->SetData64(DATA_KARATHRESSEVENT_STARTER, who->GetGUID()); + pInstance->SetData(DATA_KARATHRESSEVENT, IN_PROGRESS); + } + } + + void UpdateAI(const uint32 diff) + { + //Only if not incombat check if the event is started + if(!InCombat && pInstance && pInstance->GetData(DATA_KARATHRESSEVENT)) + { + Unit* target = Unit::GetUnit((*m_creature), pInstance->GetData64(DATA_KARATHRESSEVENT_STARTER)); + + if(target) + { + DoStartAttackAndMovement(target); + } + } + + //Return since we have no target + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + //someone evaded! + if(pInstance && !pInstance->GetData(DATA_KARATHRESSEVENT)) + EnterEvadeMode(); + + //WaterBoltVolley_Timer + if(WaterBoltVolley_Timer < diff) + { + DoCast(m_creature->getVictim(), SPELL_WATER_BOLT_VOLLEY); + WaterBoltVolley_Timer = 30000; + }else WaterBoltVolley_Timer -= diff; + + //TidalSurge_Timer + if(TidalSurge_Timer < diff) + { + DoCast(m_creature->getVictim(), SPELL_TIDAL_SURGE); + TidalSurge_Timer = 15000+rand()%5000; + }else TidalSurge_Timer -= diff; + + //Heal_Timer + if(Heal_Timer < diff) + { + // It can be cast on any of the mobs + Unit *pUnit = NULL; + + if(pInstance) + { + switch(rand()%4) + { + case 0: + pUnit = Unit::GetUnit((*m_creature), pInstance->GetData64(DATA_KARATHRESS)); + break; + case 1: + pUnit = Unit::GetUnit((*m_creature), pInstance->GetData64(DATA_SHARKKIS)); + break; + case 2: + pUnit = Unit::GetUnit((*m_creature), pInstance->GetData64(DATA_TIDALVESS)); + break; + case 3: + pUnit = m_creature; + break; + } + }else pUnit = m_creature; + + if(pUnit && pUnit->isAlive()) + DoCast(pUnit, SPELL_HEAL); + + Heal_Timer = 60000; + }else Heal_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; + +CreatureAI* GetAI_boss_fathomlord_karathress(Creature *_Creature) +{ + return new boss_fathomlord_karathressAI (_Creature); +} + +CreatureAI* GetAI_boss_fathomguard_sharkkis(Creature *_Creature) +{ + return new boss_fathomguard_sharkkisAI (_Creature); +} + +CreatureAI* GetAI_boss_fathomguard_tidalvess(Creature *_Creature) +{ + return new boss_fathomguard_tidalvessAI (_Creature); +} + +CreatureAI* GetAI_boss_fathomguard_caribdis(Creature *_Creature) +{ + return new boss_fathomguard_caribdisAI (_Creature); +} + +void AddSC_boss_fathomlord_karathress() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_fathomlord_karathress"; + newscript->GetAI = GetAI_boss_fathomlord_karathress; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="boss_fathomguard_sharkkis"; + newscript->GetAI = GetAI_boss_fathomguard_sharkkis; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="boss_fathomguard_tidalvess"; + newscript->GetAI = GetAI_boss_fathomguard_tidalvess; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="boss_fathomguard_caribdis"; + newscript->GetAI = GetAI_boss_fathomguard_caribdis; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/boss_hydross_the_unstable.cpp b/src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/boss_hydross_the_unstable.cpp index d9bc9429d14..c1d3086a2e6 100644 --- a/src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/boss_hydross_the_unstable.cpp +++ b/src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/boss_hydross_the_unstable.cpp @@ -1,357 +1,357 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Hydross_The_Unstable -SD%Complete: 90 -SDComment: Some details and adjustments left to do, probably nothing major. Spawns may be spawned in different way/location. -SDCategory: Coilfang Resevoir, Serpent Shrine Cavern -EndScriptData */ - -#include "precompiled.h" -#include "def_serpent_shrine.h" - -#define SWITCH_RADIUS 18 - -#define MODEL_CORRUPT 20609 -#define MODEL_CLEAN 20162 - -#define SPELL_WATER_TOMB 38235 -#define SPELL_MARK_OF_HYDROSS1 38215 -#define SPELL_MARK_OF_HYDROSS2 38216 -#define SPELL_MARK_OF_HYDROSS3 38217 -#define SPELL_MARK_OF_HYDROSS4 38218 -#define SPELL_MARK_OF_HYDROSS5 38231 -#define SPELL_MARK_OF_HYDROSS6 40584 -#define SPELL_MARK_OF_CORRUPTION1 38219 -#define SPELL_MARK_OF_CORRUPTION2 38220 -#define SPELL_MARK_OF_CORRUPTION3 38221 -#define SPELL_MARK_OF_CORRUPTION4 38222 -#define SPELL_MARK_OF_CORRUPTION5 38230 -#define SPELL_MARK_OF_CORRUPTION6 40583 -#define SPELL_VILE_SLUDGE 38246 -#define SPELL_ENRAGE 27680 //this spell need verification -#define SPELL_SUMMON_WATER_ELEMENT 36459 //not in use yet(in use ever?) -#define SPELL_ELEMENTAL_SPAWNIN 25035 -//#define SPELL_BLUE_BEAM 38015 //channeled Hydross Beam Helper (not in use yet) - -#define ENTRY_PURE_SPAWN 22035 -#define ENTRY_TAINTED_SPAWN 22036 - -#define SAY_AGGRO "I cannot allow you to interfere!" -#define SAY_SWITCH_TO_CLEAN "Better, much better." -#define SAY_CLEAN_SLAY1 "They have forced me to this..." -#define SAY_CLEAN_SLAY2 "I have no choice." -#define SAY_CLEAN_DEATH "I am... released..." -#define SAY_SWITCH_TO_CORRUPT "Aaghh, the poison..." -#define SAY_CORRUPT_SLAY1 "I will purge you from this place." -#define SAY_CORRUPT_SLAY2 "You are no better than they!" -#define SAY_CORRUPT_DEATH "You are the disease, not I" - -#define SOUND_AGGRO 11289 -#define SOUND_SWITCH_TO_CLEAN 11290 -#define SOUND_CLEAN_SLAY1 11291 -#define SOUND_CLEAN_SLAY2 11292 -#define SOUND_CLEAN_DEATH 11293 -#define SOUND_SWITCH_TO_CORRUPT 11297 -#define SOUND_CORRUPT_SLAY1 11298 -#define SOUND_CORRUPT_SLAY2 11299 -#define SOUND_CORRUPT_DEATH 11300 - -#define HYDROSS_X -239.439 -#define HYDROSS_Y -363.481 - -#define SPAWN_X_DIFF1 6.934003 -#define SPAWN_Y_DIFF1 -11.255012 -#define SPAWN_X_DIFF2 -6.934003 -#define SPAWN_Y_DIFF2 11.255012 -#define SPAWN_X_DIFF3 -12.577011 -#define SPAWN_Y_DIFF3 -4.72702 -#define SPAWN_X_DIFF4 12.577011 -#define SPAWN_Y_DIFF4 4.72702 - -struct MANGOS_DLL_DECL boss_hydross_the_unstableAI : public ScriptedAI -{ - boss_hydross_the_unstableAI(Creature *c) : ScriptedAI(c) - { - pInstance = ((ScriptedInstance*)c->GetInstanceData()); - Reset(); - } - - ScriptedInstance* pInstance; - - uint32 PosCheck_Timer; - uint32 MarkOfHydross_Timer; - uint32 MarkOfCorruption_Timer; - uint32 WaterTomb_Timer; - uint32 VileSludge_Timer; - uint32 MarkOfHydross_Count; - uint32 MarkOfCorruption_Count; - uint32 EnrageTimer; - bool CorruptedForm; - - void Reset() - { - PosCheck_Timer = 2500; - MarkOfHydross_Timer = 15000; - MarkOfCorruption_Timer = 15000; - WaterTomb_Timer = 7000; - VileSludge_Timer = 7000; - MarkOfHydross_Count = 0; - MarkOfCorruption_Count = 0; - EnrageTimer = 600000; - - CorruptedForm = false; - m_creature->SetMeleeDamageSchool(SPELL_SCHOOL_FROST); - m_creature->ApplySpellImmune(0, IMMUNITY_SCHOOL, SPELL_SCHOOL_MASK_FROST, true); - m_creature->ApplySpellImmune(0, IMMUNITY_SCHOOL, SPELL_SCHOOL_MASK_NATURE, false); - - m_creature->SetUInt32Value(UNIT_FIELD_DISPLAYID, MODEL_CLEAN); - - if( pInstance ) - pInstance->SetData(DATA_HYDROSSTHEUNSTABLEEVENT, NOT_STARTED); - } - - void Aggro(Unit *who) - { - DoYell(SAY_AGGRO, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_AGGRO); - - if( pInstance ) - pInstance->SetData(DATA_HYDROSSTHEUNSTABLEEVENT, IN_PROGRESS); - } - - void KilledUnit(Unit *victim) - { - if(CorruptedForm) - switch(rand()%2) - { - case 0: - DoYell(SAY_CORRUPT_SLAY1, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_CORRUPT_SLAY1); - break; - case 1: - DoYell(SAY_CORRUPT_SLAY2, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_CORRUPT_SLAY2); - break; - } - else - { - switch(rand()%2) - { - case 0: - DoYell(SAY_CLEAN_SLAY1, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_CLEAN_SLAY1); - break; - case 1: - DoYell(SAY_CLEAN_SLAY2, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_CLEAN_SLAY2); - break; - } - } - } - - void JustSummoned(Creature* summoned) - { - if( summoned->GetEntry() == ENTRY_PURE_SPAWN ) - summoned->ApplySpellImmune(0, IMMUNITY_SCHOOL, SPELL_SCHOOL_MASK_FROST, true); - if( summoned->GetEntry() == ENTRY_TAINTED_SPAWN ) - summoned->ApplySpellImmune(0, IMMUNITY_SCHOOL, SPELL_SCHOOL_MASK_NATURE, true); - - summoned->CastSpell(summoned,SPELL_ELEMENTAL_SPAWNIN,true); - } - - void JustDied(Unit *victim) - { - if( CorruptedForm ) - { - DoYell(SAY_CORRUPT_DEATH, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_CORRUPT_DEATH); - } - else - { - DoYell(SAY_CLEAN_DEATH, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_CLEAN_DEATH); - } - - if( pInstance ) - pInstance->SetData(DATA_HYDROSSTHEUNSTABLEEVENT, NOT_STARTED); - } - - void UpdateAI(const uint32 diff) - { - //Return since we have no target - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - // corrupted form - if( CorruptedForm ) - { - //MarkOfCorruption_Timer - if( MarkOfCorruption_Timer < diff ) - { - if( MarkOfCorruption_Count <= 5 ) - { - uint32 mark_spell; - - switch(MarkOfCorruption_Count) - { - case 0: mark_spell = SPELL_MARK_OF_CORRUPTION1; break; - case 1: mark_spell = SPELL_MARK_OF_CORRUPTION2; break; - case 2: mark_spell = SPELL_MARK_OF_CORRUPTION3; break; - case 3: mark_spell = SPELL_MARK_OF_CORRUPTION4; break; - case 4: mark_spell = SPELL_MARK_OF_CORRUPTION5; break; - case 5: mark_spell = SPELL_MARK_OF_CORRUPTION6; break; - } - - DoCast(m_creature->getVictim(), mark_spell); - - if( MarkOfCorruption_Count < 5 ) - MarkOfCorruption_Count++; - } - - MarkOfCorruption_Timer = 15000; - }else MarkOfCorruption_Timer -= diff; - - //VileSludge_Timer - if( VileSludge_Timer < diff ) - { - Unit *target = SelectUnit(SELECT_TARGET_RANDOM, 0); - if( target ) - DoCast(target, SPELL_VILE_SLUDGE); - - VileSludge_Timer = 15000; - }else VileSludge_Timer -= diff; - - //PosCheck_Timer - if( PosCheck_Timer < diff ) - { - if( m_creature->GetDistance2d(HYDROSS_X, HYDROSS_Y) < SWITCH_RADIUS ) - { - // switch to clean form - m_creature->SetUInt32Value(UNIT_FIELD_DISPLAYID, MODEL_CLEAN); - CorruptedForm = false; - MarkOfHydross_Count = 0; - - DoYell(SAY_SWITCH_TO_CLEAN, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_SWITCH_TO_CLEAN); - DoResetThreat(); - - // spawn 4 adds - DoSpawnCreature(ENTRY_PURE_SPAWN, SPAWN_X_DIFF1, SPAWN_Y_DIFF1, 0, 0, TEMPSUMMON_CORPSE_DESPAWN, 0); - DoSpawnCreature(ENTRY_PURE_SPAWN, SPAWN_X_DIFF2, SPAWN_Y_DIFF2, 0, 0, TEMPSUMMON_CORPSE_DESPAWN, 0); - DoSpawnCreature(ENTRY_PURE_SPAWN, SPAWN_X_DIFF3, SPAWN_Y_DIFF3, 0, 0, TEMPSUMMON_CORPSE_DESPAWN, 0); - DoSpawnCreature(ENTRY_PURE_SPAWN, SPAWN_X_DIFF4, SPAWN_Y_DIFF4, 0, 0, TEMPSUMMON_CORPSE_DESPAWN, 0); - - m_creature->SetMeleeDamageSchool(SPELL_SCHOOL_FROST); - m_creature->ApplySpellImmune(0, IMMUNITY_SCHOOL, SPELL_SCHOOL_MASK_FROST, true); - m_creature->ApplySpellImmune(0, IMMUNITY_SCHOOL, SPELL_SCHOOL_MASK_NATURE, false); - } - - PosCheck_Timer = 2500; - }else PosCheck_Timer -=diff; - } - // clean form - else - { - //MarkOfHydross_Timer - if( MarkOfHydross_Timer < diff ) - { - if( MarkOfHydross_Count <= 5 ) - { - uint32 mark_spell; - - switch(MarkOfHydross_Count) - { - case 0: mark_spell = SPELL_MARK_OF_HYDROSS1; break; - case 1: mark_spell = SPELL_MARK_OF_HYDROSS2; break; - case 2: mark_spell = SPELL_MARK_OF_HYDROSS3; break; - case 3: mark_spell = SPELL_MARK_OF_HYDROSS4; break; - case 4: mark_spell = SPELL_MARK_OF_HYDROSS5; break; - case 5: mark_spell = SPELL_MARK_OF_HYDROSS6; break; - } - - DoCast(m_creature->getVictim(), mark_spell); - - if( MarkOfHydross_Count < 5 ) - MarkOfHydross_Count++; - } - - MarkOfHydross_Timer = 15000; - }else MarkOfHydross_Timer -= diff; - - //WaterTomb_Timer - if( WaterTomb_Timer < diff ) - { - Unit *target = SelectUnit(SELECT_TARGET_RANDOM, 0); - if( target ) - DoCast(target, SPELL_WATER_TOMB); - - WaterTomb_Timer = 7000; - }else WaterTomb_Timer -= diff; - - //PosCheck_Timer - if( PosCheck_Timer < diff ) - { - if( m_creature->GetDistance2d(HYDROSS_X, HYDROSS_Y) >= SWITCH_RADIUS ) - { - // switch to corrupted form - m_creature->SetUInt32Value(UNIT_FIELD_DISPLAYID, MODEL_CORRUPT); - MarkOfCorruption_Count = 0; - CorruptedForm = true; - - DoYell(SAY_SWITCH_TO_CORRUPT, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_SWITCH_TO_CORRUPT); - DoResetThreat(); - - // spawn 4 adds - DoSpawnCreature(ENTRY_TAINTED_SPAWN, SPAWN_X_DIFF1, SPAWN_Y_DIFF1, 0, 0, TEMPSUMMON_CORPSE_DESPAWN, 0); - DoSpawnCreature(ENTRY_TAINTED_SPAWN, SPAWN_X_DIFF2, SPAWN_Y_DIFF2, 0, 0, TEMPSUMMON_CORPSE_DESPAWN, 0); - DoSpawnCreature(ENTRY_TAINTED_SPAWN, SPAWN_X_DIFF3, SPAWN_Y_DIFF3, 0, 0, TEMPSUMMON_CORPSE_DESPAWN, 0); - DoSpawnCreature(ENTRY_TAINTED_SPAWN, SPAWN_X_DIFF4, SPAWN_Y_DIFF4, 0, 0, TEMPSUMMON_CORPSE_DESPAWN, 0); - - m_creature->SetMeleeDamageSchool(SPELL_SCHOOL_NATURE); - m_creature->ApplySpellImmune(0, IMMUNITY_SCHOOL, SPELL_SCHOOL_MASK_NATURE, true); - m_creature->ApplySpellImmune(0, IMMUNITY_SCHOOL, SPELL_SCHOOL_MASK_FROST, false); - } - - PosCheck_Timer = 2500; - }else PosCheck_Timer -=diff; - } - - //EnrageTimer - if( EnrageTimer < diff ) - { - DoCast(m_creature, SPELL_ENRAGE); - EnrageTimer = 60000; - }else EnrageTimer -= diff; - - DoMeleeAttackIfReady(); - } -}; -CreatureAI* GetAI_boss_hydross_the_unstable(Creature *_Creature) -{ - return new boss_hydross_the_unstableAI (_Creature); -} - -void AddSC_boss_hydross_the_unstable() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_hydross_the_unstable"; - newscript->GetAI = GetAI_boss_hydross_the_unstable; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Hydross_The_Unstable +SD%Complete: 90 +SDComment: Some details and adjustments left to do, probably nothing major. Spawns may be spawned in different way/location. +SDCategory: Coilfang Resevoir, Serpent Shrine Cavern +EndScriptData */ + +#include "precompiled.h" +#include "def_serpent_shrine.h" + +#define SWITCH_RADIUS 18 + +#define MODEL_CORRUPT 20609 +#define MODEL_CLEAN 20162 + +#define SPELL_WATER_TOMB 38235 +#define SPELL_MARK_OF_HYDROSS1 38215 +#define SPELL_MARK_OF_HYDROSS2 38216 +#define SPELL_MARK_OF_HYDROSS3 38217 +#define SPELL_MARK_OF_HYDROSS4 38218 +#define SPELL_MARK_OF_HYDROSS5 38231 +#define SPELL_MARK_OF_HYDROSS6 40584 +#define SPELL_MARK_OF_CORRUPTION1 38219 +#define SPELL_MARK_OF_CORRUPTION2 38220 +#define SPELL_MARK_OF_CORRUPTION3 38221 +#define SPELL_MARK_OF_CORRUPTION4 38222 +#define SPELL_MARK_OF_CORRUPTION5 38230 +#define SPELL_MARK_OF_CORRUPTION6 40583 +#define SPELL_VILE_SLUDGE 38246 +#define SPELL_ENRAGE 27680 //this spell need verification +#define SPELL_SUMMON_WATER_ELEMENT 36459 //not in use yet(in use ever?) +#define SPELL_ELEMENTAL_SPAWNIN 25035 +//#define SPELL_BLUE_BEAM 38015 //channeled Hydross Beam Helper (not in use yet) + +#define ENTRY_PURE_SPAWN 22035 +#define ENTRY_TAINTED_SPAWN 22036 + +#define SAY_AGGRO "I cannot allow you to interfere!" +#define SAY_SWITCH_TO_CLEAN "Better, much better." +#define SAY_CLEAN_SLAY1 "They have forced me to this..." +#define SAY_CLEAN_SLAY2 "I have no choice." +#define SAY_CLEAN_DEATH "I am... released..." +#define SAY_SWITCH_TO_CORRUPT "Aaghh, the poison..." +#define SAY_CORRUPT_SLAY1 "I will purge you from this place." +#define SAY_CORRUPT_SLAY2 "You are no better than they!" +#define SAY_CORRUPT_DEATH "You are the disease, not I" + +#define SOUND_AGGRO 11289 +#define SOUND_SWITCH_TO_CLEAN 11290 +#define SOUND_CLEAN_SLAY1 11291 +#define SOUND_CLEAN_SLAY2 11292 +#define SOUND_CLEAN_DEATH 11293 +#define SOUND_SWITCH_TO_CORRUPT 11297 +#define SOUND_CORRUPT_SLAY1 11298 +#define SOUND_CORRUPT_SLAY2 11299 +#define SOUND_CORRUPT_DEATH 11300 + +#define HYDROSS_X -239.439 +#define HYDROSS_Y -363.481 + +#define SPAWN_X_DIFF1 6.934003 +#define SPAWN_Y_DIFF1 -11.255012 +#define SPAWN_X_DIFF2 -6.934003 +#define SPAWN_Y_DIFF2 11.255012 +#define SPAWN_X_DIFF3 -12.577011 +#define SPAWN_Y_DIFF3 -4.72702 +#define SPAWN_X_DIFF4 12.577011 +#define SPAWN_Y_DIFF4 4.72702 + +struct MANGOS_DLL_DECL boss_hydross_the_unstableAI : public ScriptedAI +{ + boss_hydross_the_unstableAI(Creature *c) : ScriptedAI(c) + { + pInstance = ((ScriptedInstance*)c->GetInstanceData()); + Reset(); + } + + ScriptedInstance* pInstance; + + uint32 PosCheck_Timer; + uint32 MarkOfHydross_Timer; + uint32 MarkOfCorruption_Timer; + uint32 WaterTomb_Timer; + uint32 VileSludge_Timer; + uint32 MarkOfHydross_Count; + uint32 MarkOfCorruption_Count; + uint32 EnrageTimer; + bool CorruptedForm; + + void Reset() + { + PosCheck_Timer = 2500; + MarkOfHydross_Timer = 15000; + MarkOfCorruption_Timer = 15000; + WaterTomb_Timer = 7000; + VileSludge_Timer = 7000; + MarkOfHydross_Count = 0; + MarkOfCorruption_Count = 0; + EnrageTimer = 600000; + + CorruptedForm = false; + m_creature->SetMeleeDamageSchool(SPELL_SCHOOL_FROST); + m_creature->ApplySpellImmune(0, IMMUNITY_SCHOOL, SPELL_SCHOOL_MASK_FROST, true); + m_creature->ApplySpellImmune(0, IMMUNITY_SCHOOL, SPELL_SCHOOL_MASK_NATURE, false); + + m_creature->SetUInt32Value(UNIT_FIELD_DISPLAYID, MODEL_CLEAN); + + if( pInstance ) + pInstance->SetData(DATA_HYDROSSTHEUNSTABLEEVENT, NOT_STARTED); + } + + void Aggro(Unit *who) + { + DoYell(SAY_AGGRO, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_AGGRO); + + if( pInstance ) + pInstance->SetData(DATA_HYDROSSTHEUNSTABLEEVENT, IN_PROGRESS); + } + + void KilledUnit(Unit *victim) + { + if(CorruptedForm) + switch(rand()%2) + { + case 0: + DoYell(SAY_CORRUPT_SLAY1, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_CORRUPT_SLAY1); + break; + case 1: + DoYell(SAY_CORRUPT_SLAY2, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_CORRUPT_SLAY2); + break; + } + else + { + switch(rand()%2) + { + case 0: + DoYell(SAY_CLEAN_SLAY1, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_CLEAN_SLAY1); + break; + case 1: + DoYell(SAY_CLEAN_SLAY2, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_CLEAN_SLAY2); + break; + } + } + } + + void JustSummoned(Creature* summoned) + { + if( summoned->GetEntry() == ENTRY_PURE_SPAWN ) + summoned->ApplySpellImmune(0, IMMUNITY_SCHOOL, SPELL_SCHOOL_MASK_FROST, true); + if( summoned->GetEntry() == ENTRY_TAINTED_SPAWN ) + summoned->ApplySpellImmune(0, IMMUNITY_SCHOOL, SPELL_SCHOOL_MASK_NATURE, true); + + summoned->CastSpell(summoned,SPELL_ELEMENTAL_SPAWNIN,true); + } + + void JustDied(Unit *victim) + { + if( CorruptedForm ) + { + DoYell(SAY_CORRUPT_DEATH, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_CORRUPT_DEATH); + } + else + { + DoYell(SAY_CLEAN_DEATH, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_CLEAN_DEATH); + } + + if( pInstance ) + pInstance->SetData(DATA_HYDROSSTHEUNSTABLEEVENT, NOT_STARTED); + } + + void UpdateAI(const uint32 diff) + { + //Return since we have no target + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + // corrupted form + if( CorruptedForm ) + { + //MarkOfCorruption_Timer + if( MarkOfCorruption_Timer < diff ) + { + if( MarkOfCorruption_Count <= 5 ) + { + uint32 mark_spell; + + switch(MarkOfCorruption_Count) + { + case 0: mark_spell = SPELL_MARK_OF_CORRUPTION1; break; + case 1: mark_spell = SPELL_MARK_OF_CORRUPTION2; break; + case 2: mark_spell = SPELL_MARK_OF_CORRUPTION3; break; + case 3: mark_spell = SPELL_MARK_OF_CORRUPTION4; break; + case 4: mark_spell = SPELL_MARK_OF_CORRUPTION5; break; + case 5: mark_spell = SPELL_MARK_OF_CORRUPTION6; break; + } + + DoCast(m_creature->getVictim(), mark_spell); + + if( MarkOfCorruption_Count < 5 ) + MarkOfCorruption_Count++; + } + + MarkOfCorruption_Timer = 15000; + }else MarkOfCorruption_Timer -= diff; + + //VileSludge_Timer + if( VileSludge_Timer < diff ) + { + Unit *target = SelectUnit(SELECT_TARGET_RANDOM, 0); + if( target ) + DoCast(target, SPELL_VILE_SLUDGE); + + VileSludge_Timer = 15000; + }else VileSludge_Timer -= diff; + + //PosCheck_Timer + if( PosCheck_Timer < diff ) + { + if( m_creature->GetDistance2d(HYDROSS_X, HYDROSS_Y) < SWITCH_RADIUS ) + { + // switch to clean form + m_creature->SetUInt32Value(UNIT_FIELD_DISPLAYID, MODEL_CLEAN); + CorruptedForm = false; + MarkOfHydross_Count = 0; + + DoYell(SAY_SWITCH_TO_CLEAN, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_SWITCH_TO_CLEAN); + DoResetThreat(); + + // spawn 4 adds + DoSpawnCreature(ENTRY_PURE_SPAWN, SPAWN_X_DIFF1, SPAWN_Y_DIFF1, 0, 0, TEMPSUMMON_CORPSE_DESPAWN, 0); + DoSpawnCreature(ENTRY_PURE_SPAWN, SPAWN_X_DIFF2, SPAWN_Y_DIFF2, 0, 0, TEMPSUMMON_CORPSE_DESPAWN, 0); + DoSpawnCreature(ENTRY_PURE_SPAWN, SPAWN_X_DIFF3, SPAWN_Y_DIFF3, 0, 0, TEMPSUMMON_CORPSE_DESPAWN, 0); + DoSpawnCreature(ENTRY_PURE_SPAWN, SPAWN_X_DIFF4, SPAWN_Y_DIFF4, 0, 0, TEMPSUMMON_CORPSE_DESPAWN, 0); + + m_creature->SetMeleeDamageSchool(SPELL_SCHOOL_FROST); + m_creature->ApplySpellImmune(0, IMMUNITY_SCHOOL, SPELL_SCHOOL_MASK_FROST, true); + m_creature->ApplySpellImmune(0, IMMUNITY_SCHOOL, SPELL_SCHOOL_MASK_NATURE, false); + } + + PosCheck_Timer = 2500; + }else PosCheck_Timer -=diff; + } + // clean form + else + { + //MarkOfHydross_Timer + if( MarkOfHydross_Timer < diff ) + { + if( MarkOfHydross_Count <= 5 ) + { + uint32 mark_spell; + + switch(MarkOfHydross_Count) + { + case 0: mark_spell = SPELL_MARK_OF_HYDROSS1; break; + case 1: mark_spell = SPELL_MARK_OF_HYDROSS2; break; + case 2: mark_spell = SPELL_MARK_OF_HYDROSS3; break; + case 3: mark_spell = SPELL_MARK_OF_HYDROSS4; break; + case 4: mark_spell = SPELL_MARK_OF_HYDROSS5; break; + case 5: mark_spell = SPELL_MARK_OF_HYDROSS6; break; + } + + DoCast(m_creature->getVictim(), mark_spell); + + if( MarkOfHydross_Count < 5 ) + MarkOfHydross_Count++; + } + + MarkOfHydross_Timer = 15000; + }else MarkOfHydross_Timer -= diff; + + //WaterTomb_Timer + if( WaterTomb_Timer < diff ) + { + Unit *target = SelectUnit(SELECT_TARGET_RANDOM, 0); + if( target ) + DoCast(target, SPELL_WATER_TOMB); + + WaterTomb_Timer = 7000; + }else WaterTomb_Timer -= diff; + + //PosCheck_Timer + if( PosCheck_Timer < diff ) + { + if( m_creature->GetDistance2d(HYDROSS_X, HYDROSS_Y) >= SWITCH_RADIUS ) + { + // switch to corrupted form + m_creature->SetUInt32Value(UNIT_FIELD_DISPLAYID, MODEL_CORRUPT); + MarkOfCorruption_Count = 0; + CorruptedForm = true; + + DoYell(SAY_SWITCH_TO_CORRUPT, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_SWITCH_TO_CORRUPT); + DoResetThreat(); + + // spawn 4 adds + DoSpawnCreature(ENTRY_TAINTED_SPAWN, SPAWN_X_DIFF1, SPAWN_Y_DIFF1, 0, 0, TEMPSUMMON_CORPSE_DESPAWN, 0); + DoSpawnCreature(ENTRY_TAINTED_SPAWN, SPAWN_X_DIFF2, SPAWN_Y_DIFF2, 0, 0, TEMPSUMMON_CORPSE_DESPAWN, 0); + DoSpawnCreature(ENTRY_TAINTED_SPAWN, SPAWN_X_DIFF3, SPAWN_Y_DIFF3, 0, 0, TEMPSUMMON_CORPSE_DESPAWN, 0); + DoSpawnCreature(ENTRY_TAINTED_SPAWN, SPAWN_X_DIFF4, SPAWN_Y_DIFF4, 0, 0, TEMPSUMMON_CORPSE_DESPAWN, 0); + + m_creature->SetMeleeDamageSchool(SPELL_SCHOOL_NATURE); + m_creature->ApplySpellImmune(0, IMMUNITY_SCHOOL, SPELL_SCHOOL_MASK_NATURE, true); + m_creature->ApplySpellImmune(0, IMMUNITY_SCHOOL, SPELL_SCHOOL_MASK_FROST, false); + } + + PosCheck_Timer = 2500; + }else PosCheck_Timer -=diff; + } + + //EnrageTimer + if( EnrageTimer < diff ) + { + DoCast(m_creature, SPELL_ENRAGE); + EnrageTimer = 60000; + }else EnrageTimer -= diff; + + DoMeleeAttackIfReady(); + } +}; +CreatureAI* GetAI_boss_hydross_the_unstable(Creature *_Creature) +{ + return new boss_hydross_the_unstableAI (_Creature); +} + +void AddSC_boss_hydross_the_unstable() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_hydross_the_unstable"; + newscript->GetAI = GetAI_boss_hydross_the_unstable; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/boss_lady_vashj.cpp b/src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/boss_lady_vashj.cpp index b078c332251..204c391a266 100644 --- a/src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/boss_lady_vashj.cpp +++ b/src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/boss_lady_vashj.cpp @@ -1,940 +1,922 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA02111-1307USA - */ - -/* ScriptData -SDName: Boss_Lady_Vashj -SD%Complete: 99 -SDComment: Missing blizzlike Shield Generators coords -SDCategory: Coilfang Resevoir, Serpent Shrine Cavern -EndScriptData */ - -#include "precompiled.h" -#include "def_serpent_shrine.h" -#include "../../../creature/simple_ai.h" -#include "Item.h" -#include "Spell.h" - -#define SPELL_MULTI_SHOT 38310 -#define SPELL_SHOCK_BLAST 38509 -#define SPELL_ENTANGLE 38316 -#define SPELL_STATIC_CHARGE_TRIGGER 38280 -#define SPELL_FORKED_LIGHTNING 40088 -#define SPELL_SHOOT 40873 -#define SPELL_POISON_BOLT 40095 -#define SPELL_TOXIC_SPORES 38575 -#define SPELL_MAGIC_BARRIER 38112 - -#define SAY_INTRO "Water is life. It has become a rare commodity here in Outland. A commodity that we alone shall control. We are the Highborne, and the time has come at last for us to retake our rightful place in the world!" -#define SAY_AGGRO1 "I'll split you from stem to stern! " -#define SAY_AGGRO2 "Victory to Lord Illidan!" -#define SAY_AGGRO3 "I spit on you, surface filth!" -#define SAY_AGGRO4 "Death to the outsiders!" -#define SAY_PHASE1 "I did not wish to lower myself by engaging your kind, but you leave me little choice!" -#define SAY_PHASE2 "The time is now! Leave none standing!" -#define SAY_PHASE3 "You may want to take cover." -#define SAY_BOWSHOT1 "Straight to the heart!" -#define SAY_BOWSHOT2 "Seek your mark!" -#define SAY_SLAY1 "Your time ends now!" -#define SAY_SLAY2 "You have failed!" -#define SAY_DEATH "Lord Illidan, I... I am... sorry." - -#define SOUND_INTRO 11531 -#define SOUND_AGGRO1 11532 -#define SOUND_AGGRO2 11533 -#define SOUND_AGGRO3 11534 -#define SOUND_AGGRO4 11535 -#define SOUND_PHASE1 11538 -#define SOUND_PHASE2 11539 -#define SOUND_PHASE3 11540 -#define SOUND_BOWSHOT1 11536 -#define SOUND_BOWSHOT2 11537 -#define SOUND_SLAY1 11541 -#define SOUND_SLAY2 11542 -#define SOUND_DEATH 11544 - -#define MIDDLE_X 30.134 -#define MIDDLE_Y -923.65 -#define MIDDLE_Z 42.9 - -#define SPOREBAT_X 30.977156 -#define SPOREBAT_Y -925.297761 -#define SPOREBAT_Z 77.176567 -#define SPOREBAT_O 5.223932 - -#define SHIED_GENERATOR_CHANNEL 19870 -#define ENCHANTED_ELEMENTAL 21958 -#define TAINTED_ELEMENTAL 22009 -#define COILFANG_STRIDER 22056 -#define COILFANG_ELITE 22055 -#define FATHOM_SPOREBAT 22140 - -float ElementPos[8][4] = -{ - {8.3, -835.3, 21.9, 5}, - {53.4, -835.3, 21.9, 4.5}, - {96, -861.9, 21.8, 4}, - {96, -986.4, 21.4, 2.5}, - {54.4, -1010.6, 22, 1.8}, - {9.8, -1012, 21.7, 1.4}, - {-35, -987.6, 21.5, 0.8}, - {-58.9, -901.6, 21.5, 6} -}; - -float CoilfangElitePos[3][4] = -{ - {28.84, -923.28, 42.9, 6}, - {31.183281, -953.502625, 41.523602, 1.640957}, - {58.895180, -923.124268, 41.545307, 3.152848} -}; - -float CoilfangStriderPos[3][4] = -{ - {66.427010, -948.778503, 41.262245, 2.584220}, - {7.513962, -959.538208, 41.300422, 1.034629}, - {-12.843201, -907.798401, 41.239620, 6.087094} -}; - -float ShieldGeneratorChannelPos[4][4] = -{ - {49.6262, -902.181, 43.0975, 3.95683}, - {10.988, -901.616, 42.5371, 5.4373}, - {10.3859, -944.036, 42.5446, 0.779888}, - {49.3126, -943.398, 42.5501, 2.40174} -}; - -//Lady Vashj AI -struct MANGOS_DLL_DECL boss_lady_vashjAI : public ScriptedAI -{ - boss_lady_vashjAI (Creature *c) : ScriptedAI(c) - { - pInstance = ((ScriptedInstance*)c->GetInstanceData()); - Reset(); - } - - ScriptedInstance *pInstance; - - uint64 ShieldGeneratorChannel[4]; - - uint32 ShockBlast_Timer; - uint32 Entangle_Timer; - uint32 StaticCharge_Timer; - uint32 ForkedLightning_Timer; - uint32 Check_Timer; - uint32 EnchantedElemental_Timer; - uint32 TaintedElemental_Timer; - uint32 CoilfangElite_Timer; - uint32 CoilfangStrider_Timer; - uint32 SummonSporebat_Timer; - uint32 SummonSporebat_StaticTimer; - uint8 EnchantedElemental_Pos; - uint8 Phase; - - bool Entangle; - - void Reset() - { - ShockBlast_Timer = 1+rand()%60000; - Entangle_Timer = 30000; - StaticCharge_Timer = 10000+rand()%15000; - ForkedLightning_Timer = 2000; - Check_Timer = 1000; - EnchantedElemental_Timer = 5000; - TaintedElemental_Timer = 50000; - CoilfangElite_Timer = 45000+rand()%5000; - CoilfangStrider_Timer = 60000+rand()%10000; - SummonSporebat_Timer = 10000; - SummonSporebat_StaticTimer = 30000; - EnchantedElemental_Pos = 0; - Phase = 0; - - Entangle = false; - - if(pInstance) - pInstance->SetData(DATA_LADYVASHJEVENT, 0); - - ShieldGeneratorChannel[0] = 0; - ShieldGeneratorChannel[1] = 0; - ShieldGeneratorChannel[2] = 0; - ShieldGeneratorChannel[3] = 0; - - } - - //Called when a tainted elemental dies - void EventTaintedElementalDeath() - { - //the next will spawn 50 seconds after the previous one's death - if(TaintedElemental_Timer > 50000) - TaintedElemental_Timer = 50000; - } - - void KilledUnit(Unit *victim) - { - switch(rand()%2) - { - case 0: - DoYell(SAY_SLAY1, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_SLAY1); - break; - - case 1: - DoPlaySoundToSet(m_creature, SOUND_SLAY1); - DoYell(SAY_SLAY2, LANG_UNIVERSAL, NULL); - break; - } - } - - void JustDied(Unit *victim) - { - DoPlaySoundToSet(m_creature, SOUND_DEATH); - DoYell(SAY_DEATH, LANG_UNIVERSAL, NULL); - - if(pInstance) - pInstance->SetData(DATA_LADYVASHJEVENT, 0); - } - - void StartEvent() - { - switch(rand()%4) - { - case 0: - DoPlaySoundToSet(m_creature, SOUND_AGGRO1); - DoYell(SAY_AGGRO1, LANG_UNIVERSAL, NULL); - break; - case 1: - DoPlaySoundToSet(m_creature, SOUND_AGGRO2); - DoYell(SAY_AGGRO2, LANG_UNIVERSAL, NULL); - break; - case 2: - DoPlaySoundToSet(m_creature, SOUND_AGGRO3); - DoYell(SAY_AGGRO3, LANG_UNIVERSAL, NULL); - break; - case 3: - DoPlaySoundToSet(m_creature, SOUND_AGGRO4); - DoYell(SAY_AGGRO4, LANG_UNIVERSAL, NULL); - break; - } - - Phase = 1; - - if(pInstance) - pInstance->SetData(DATA_LADYVASHJEVENT, 1); - } - - void Aggro(Unit *who) - { - //Begin melee attack if we are within range - if(Phase != 2) - DoStartAttackAndMovement(who); - - StartEvent(); - } - - void CastShootOrMultishot() - { - switch(rand()%2) - { - case 0: - //Shoot - //Used in Phases 1 and 3 after Entangle or while having nobody in melee range. A shot that hits her target for 4097-5543 Physical damage. - DoCast(m_creature->getVictim(), SPELL_SHOOT); - break; - case 1: - //Multishot - //Used in Phases 1 and 3 after Entangle or while having nobody in melee range. A shot that hits 1 person and 4 people around him for 6475-7525 physical damage. - DoCast(m_creature->getVictim(), SPELL_MULTI_SHOT); - break; - } - - if(rand()%3) - { - switch(rand()%2) - { - case 0: - DoPlaySoundToSet(m_creature, SOUND_BOWSHOT1); - DoYell(SAY_BOWSHOT1, LANG_UNIVERSAL, NULL); - break; - case 1: - DoPlaySoundToSet(m_creature, SOUND_BOWSHOT2); - DoYell(SAY_BOWSHOT2, LANG_UNIVERSAL, NULL); - break; - } - } - } - - void UpdateAI(const uint32 diff) - { - //to prevent abuses during phase 2 - if(Phase == 2 && !m_creature->getVictim() && InCombat) - EnterEvadeMode(); - - //Return since we have no target - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - if(Phase == 1 || Phase == 3) - { - //ShockBlast_Timer - if (ShockBlast_Timer < diff) - { - //Shock Burst - //Randomly used in Phases 1 and 3 on Vashj's target, it's a Shock spell doing 8325-9675 nature damage and stunning the target for 5 seconds, during which she will not attack her target but switch to the next person on the aggro list. - DoCast(m_creature->getVictim(), SPELL_SHOCK_BLAST); - m_creature->TauntApply(m_creature->getVictim()); - - ShockBlast_Timer = 1000+rand()%14000; //random cooldown - }else ShockBlast_Timer -= diff; - - //StaticCharge_Timer - if(StaticCharge_Timer < diff) - { - //Static Charge - //Used on random people (only 1 person at any given time) in Phases 1 and 3, it's a debuff doing 2775 to 3225 Nature damage to the target and everybody in about 5 yards around it, every 1 seconds for 30 seconds. It can be removed by Cloak of Shadows, Iceblock, Divine Shield, etc, but not by Cleanse or Dispel Magic. - Unit *target = NULL; - target = SelectUnit(SELECT_TARGET_RANDOM, 0); - - if(target && !target->HasAura(SPELL_STATIC_CHARGE_TRIGGER, 0)) - //cast Static Charge every 2 seconds for 20 seconds - DoCast(target, SPELL_STATIC_CHARGE_TRIGGER); - - StaticCharge_Timer = 10000+rand()%20000; //blizzlike - }else StaticCharge_Timer -= diff; - - //Entangle_Timer - if (Entangle_Timer < diff) - { - if(!Entangle) - { - //Entangle - //Used in Phases 1 and 3, it casts Entangling Roots on everybody in a 15 yard radius of Vashj, immobilzing them for 10 seconds and dealing 500 damage every 2 seconds. It's not a magic effect so it cannot be dispelled, but is removed by various buffs such as Cloak of Shadows or Blessing of Freedom. - DoCast(m_creature->getVictim(), SPELL_ENTANGLE); - Entangle = true; - Entangle_Timer = 10000; - } - else - { - CastShootOrMultishot(); - Entangle = false; - Entangle_Timer = 20000+rand()%5000; - } - }else Entangle_Timer -= diff; - - //Phase 1 - if(Phase == 1) - { - //Start phase 2 - if ((m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < 70) - { - //Phase 2 begins when Vashj hits 70%. She will run to the middle of her platform and surround herself in a shield making her invulerable. - Phase = 2; - - m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); - m_creature->GetMotionMaster()->Clear(); - m_creature->Relocate(MIDDLE_X, MIDDLE_Y, MIDDLE_Z); - m_creature->SendMonsterMove(MIDDLE_X, MIDDLE_Y, MIDDLE_Z, 0, 0, 0); - - m_creature->RemoveAllAuras(); - // This needs an entry in spell_script_target - DoCast(m_creature, SPELL_MAGIC_BARRIER, true); - - Creature *pCreature; - for(uint8 i = 0; i < 4; i++) - { - pCreature = m_creature->SummonCreature(SHIED_GENERATOR_CHANNEL, ShieldGeneratorChannelPos[i][0], ShieldGeneratorChannelPos[i][1], ShieldGeneratorChannelPos[i][2], ShieldGeneratorChannelPos[i][3], TEMPSUMMON_CORPSE_DESPAWN, 0); - if (pCreature) - ShieldGeneratorChannel[i] = pCreature->GetGUID(); - } - - DoPlaySoundToSet(m_creature, SOUND_PHASE2); - DoYell(SAY_PHASE2, LANG_UNIVERSAL, NULL); - } - } - //Phase 3 - else - { - //SummonSporebat_Timer - if(SummonSporebat_Timer < diff) - { - Creature *Sporebat = NULL; - Sporebat = m_creature->SummonCreature(FATHOM_SPOREBAT, SPOREBAT_X, SPOREBAT_Y, SPOREBAT_Z, SPOREBAT_O, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000); - - if(Sporebat) - { - Unit *target = NULL; - target = SelectUnit(SELECT_TARGET_RANDOM, 0); - if(target) - Sporebat->AI()->AttackStart(target); - } - - //summon sporebats faster and faster - if(SummonSporebat_StaticTimer > 1000) - SummonSporebat_StaticTimer -= 1000; - - SummonSporebat_Timer = SummonSporebat_StaticTimer; - }else SummonSporebat_Timer -= diff; - } - - //Melee attack - DoMeleeAttackIfReady(); - - //Check_Timer - used to check if somebody is in melee range - if(Check_Timer < diff) - { - bool InMeleeRange = false; - Unit *target; - std::list t_list = m_creature->getThreatManager().getThreatList(); - for(std::list::iterator itr = t_list.begin(); itr!= t_list.end(); ++itr) - { - target = Unit::GetUnit(*m_creature, (*itr)->getUnitGuid()); - //if in melee range - if(target && target->IsWithinDistInMap(m_creature, 5)) - { - InMeleeRange = true; - break; - } - } - - //if nobody is in melee range - if(!InMeleeRange) - CastShootOrMultishot(); - - Check_Timer = 1000; - }else Check_Timer -= diff; - } - //Phase 2 - else - { - //ForkedLightning_Timer - if(ForkedLightning_Timer < diff) - { - //Forked Lightning - //Used constantly in Phase 2, it shoots out completely randomly targeted bolts of lightning which hit everybody in a roughtly 60 degree cone in front of Vashj for 2313-2687 nature damage. - Unit *target = NULL; - target = SelectUnit(SELECT_TARGET_RANDOM, 0); - - if(!target) - target = m_creature->getVictim(); - - DoCast(target, SPELL_FORKED_LIGHTNING); - - ForkedLightning_Timer = 2000+rand()%6000; //blizzlike - }else ForkedLightning_Timer -= diff; - - //EnchantedElemental_Timer - if(EnchantedElemental_Timer < diff) - { - Creature *Elemental; - Elemental = m_creature->SummonCreature(ENCHANTED_ELEMENTAL, ElementPos[EnchantedElemental_Pos][0], ElementPos[EnchantedElemental_Pos][1], ElementPos[EnchantedElemental_Pos][2], ElementPos[EnchantedElemental_Pos][3], TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 60000); - if(Elemental) - Elemental->GetMotionMaster()->MovePoint(0, m_creature->GetPositionX(), m_creature->GetPositionY(), m_creature->GetPositionZ()); - - if(EnchantedElemental_Pos == 7) - EnchantedElemental_Pos = 0; - else - EnchantedElemental_Pos++; - - EnchantedElemental_Timer = 10000+rand()%5000; - }else EnchantedElemental_Timer -= diff; - - //TaintedElemental_Timer - if(TaintedElemental_Timer < diff) - { - Creature *Tain_Elemental; - uint32 pos = rand()%8; - Tain_Elemental = m_creature->SummonCreature(TAINTED_ELEMENTAL, ElementPos[pos][0], ElementPos[pos][1], ElementPos[pos][2], ElementPos[pos][3], TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 60000); - if(Tain_Elemental) - { - Tain_Elemental->GetMotionMaster()->Clear(); - Tain_Elemental->GetMotionMaster()->MoveIdle(); - } - - TaintedElemental_Timer = 120000; - }else TaintedElemental_Timer -= diff; - - //CoilfangElite_Timer - if(CoilfangElite_Timer < diff) - { - Creature *CoilfangElite; - uint32 pos = rand()%3; - CoilfangElite = m_creature->SummonCreature(COILFANG_ELITE, CoilfangElitePos[pos][0], CoilfangElitePos[pos][1], CoilfangElitePos[pos][2], CoilfangElitePos[pos][3], TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 45000); - if(CoilfangElite) - { - Unit *target = NULL; - target = SelectUnit(SELECT_TARGET_RANDOM, 0); - if(target) - CoilfangElite->AI()->AttackStart(target); - } - - CoilfangElite_Timer = 45000+rand()%5000; //wowwiki says 50 seconds, bosskillers says 45 - }else CoilfangElite_Timer -= diff; - - //CoilfangStrider_Timer - if(CoilfangStrider_Timer < diff) - { - Creature *CoilfangStrider; - uint32 pos = rand()%3; - CoilfangStrider = m_creature->SummonCreature(COILFANG_STRIDER, CoilfangStriderPos[pos][0], CoilfangStriderPos[pos][1], CoilfangStriderPos[pos][2], CoilfangStriderPos[pos][3], TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000); - if(CoilfangStrider) - { - Unit *target = NULL; - target = SelectUnit(SELECT_TARGET_RANDOM, 0); - if(target) - CoilfangStrider->AI()->AttackStart(target); - } - - CoilfangStrider_Timer = 60000+rand()%10000; //wowwiki says 60 seconds, bosskillers says 60-70 - }else CoilfangStrider_Timer -= diff; - - //Check_Timer - if(Check_Timer < diff) - { - //Start Phase 3 - if(pInstance && pInstance->GetData(DATA_CANSTARTPHASE3)) - { - //set life 50% - m_creature->SetHealth(m_creature->GetMaxHealth()/2); - - m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); - m_creature->RemoveAurasDueToSpell(SPELL_MAGIC_BARRIER); - - DoPlaySoundToSet(m_creature, SOUND_PHASE3); - DoYell(SAY_PHASE3, LANG_UNIVERSAL, NULL); - - Phase = 3; - - //return to the tank - m_creature->GetMotionMaster()->MoveChase(m_creature->getVictim()); - } - Check_Timer = 1000; - }else Check_Timer -= diff; - } - } -}; - -//Enchanted Elemental -//If one of them reaches Vashj he will increase her damage done by 5%. -struct MANGOS_DLL_DECL mob_enchanted_elementalAI : public ScriptedAI -{ - mob_enchanted_elementalAI(Creature *c) : ScriptedAI(c) - { - pInstance = ((ScriptedInstance*)c->GetInstanceData()); - Reset(); - } - - ScriptedInstance *pInstance; - - uint32 Check_Timer; - uint32 Movement_Timer; - - void Reset() - { - Check_Timer = 5000; - Movement_Timer = 500; - } - - void Aggro(Unit *who) { return; } - - void MoveInLineOfSight(Unit *who) { return; } - - void UpdateAI(const uint32 diff) - { - //Check_Timer - if(Check_Timer < diff) - { - if(pInstance) - { - Unit *Vashj = NULL; - Vashj = Unit::GetUnit((*m_creature), pInstance->GetData64(DATA_LADYVASHJ)); - if(Vashj) - { - if(Vashj->IsWithinDistInMap(m_creature, 5)) - { - //increase lady vashj damage (+5%) - const CreatureInfo *cinfo = m_creature->GetCreatureInfo(); - Vashj->SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, (cinfo->mindmg +((cinfo->mindmg/100) * 5))); - Vashj->SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, (cinfo->maxdmg +((cinfo->maxdmg/100) * 5))); - m_creature->UpdateDamagePhysical(BASE_ATTACK); - - //call Unsummon() - m_creature->setDeathState(JUST_DIED); - } - else if(((boss_lady_vashjAI*)((Creature*)Vashj)->AI())->InCombat == false) - { - //call Unsummon() - m_creature->setDeathState(JUST_DIED); - } - } - } - else error_log("ERROR: Instance Data for Serpentshrine Caverns not set"); - Check_Timer = 1000; - }else Check_Timer -= diff; - } -}; - -//Tainted Elemental -//This mob has 7,900 life, doesn't move, and shoots Poison Bolts at one person anywhere in the area, doing 3,000 nature damage and placing a posion doing 2,000 damage every 2 seconds. He will switch targets often, or sometimes just hang on a single player, but there is nothing you can do about it except heal the damage and kill the Tainted Elemental -struct MANGOS_DLL_DECL mob_tainted_elementalAI : public ScriptedAI -{ - mob_tainted_elementalAI(Creature *c) : ScriptedAI(c) - { - pInstance = ((ScriptedInstance*)c->GetInstanceData()); - Reset(); - } - - ScriptedInstance *pInstance; - - uint32 PoisonBolt_Timer; - - void Reset() - { - PoisonBolt_Timer = 5000+rand()%5000; - } - - void JustDied(Unit *killer) - { - if(pInstance) - { - Creature *Vashj = NULL; - Vashj = (Creature*)(Unit::GetUnit((*m_creature), pInstance->GetData64(DATA_LADYVASHJ))); - - if(Vashj) - ((boss_lady_vashjAI*)Vashj->AI())->EventTaintedElementalDeath(); - } - } - - void Aggro(Unit *who) - { - } - - void MoveInLineOfSight(Unit *who) - { - if (!who || m_creature->getVictim()) - return; - - if (who->isTargetableForAttack() && who->isInAccessablePlaceFor(m_creature) && m_creature->IsHostileTo(who)) - { - float attackRadius = m_creature->GetAttackDistance(who); - if (m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->GetDistanceZ(who) <= CREATURE_Z_ATTACK_RANGE && m_creature->IsWithinLOSInMap(who)) - { - if(who->HasStealthAura()) - who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); - - m_creature->AddThreat(who, 0.1f); - } - } - } - - void UpdateAI(const uint32 diff) - { - //PoisonBolt_Timer - if(PoisonBolt_Timer < diff) - { - Unit *target = NULL; - target = SelectUnit(SELECT_TARGET_RANDOM, 0); - - if(target && target->IsWithinDistInMap(m_creature, 30)) - DoCast(target, SPELL_POISON_BOLT); - - PoisonBolt_Timer = 5000+rand()%5000; - }else PoisonBolt_Timer -= diff; - } -}; - -//Fathom Sporebat -//Toxic Spores: Used in Phase 3 by the Spore Bats, it creates a contaminated green patch of ground, dealing about 2775-3225 nature damage every second to anyone who stands in it. -struct MANGOS_DLL_DECL mob_fathom_sporebatAI : public ScriptedAI -{ - mob_fathom_sporebatAI(Creature *c) : ScriptedAI(c) - { - pInstance = ((ScriptedInstance*)c->GetInstanceData()); - Reset(); - } - - ScriptedInstance *pInstance; - - uint32 ToxicSpore_Timer; - uint32 Check_Timer; - - void Reset() - { - m_creature->setFaction(14); - ToxicSpore_Timer = 5000; - Check_Timer = 1000; - } - - void Aggro(Unit *who) {} - - void UpdateAI (const uint32 diff) - { - //Return since we have no target - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - //ToxicSpore_Timer - if(ToxicSpore_Timer < diff) - { - Unit *target = NULL; - target = SelectUnit(SELECT_TARGET_RANDOM, 0); - - //The Spores will hit you anywhere in the instance: underwater, at the elevator, at the entrance, wherever. - if(target) - DoCast(target, SPELL_TOXIC_SPORES); - - ToxicSpore_Timer = 20000+rand()%5000; - }else ToxicSpore_Timer -= diff; - - //Check_Timer - if(Check_Timer < diff) - { - if(pInstance) - { - //check if vashj is death - Unit *Vashj = NULL; - Vashj = Unit::GetUnit((*m_creature), pInstance->GetData64(DATA_LADYVASHJ)); - if(!Vashj || (Vashj && !Vashj->isAlive())) - { - //remove - m_creature->setDeathState(DEAD); - m_creature->RemoveCorpse(); - m_creature->setFaction(35); - } - } - - Check_Timer = 1000; - }else Check_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; - -//Coilfang Elite -//It's an elite Naga mob with 170,000 HP. It does about 5000 damage on plate, and has a nasty cleave hitting for about 7500 damage -CreatureAI* GetAI_mob_coilfang_elite(Creature *_Creature) -{ - SimpleAI* ai = new SimpleAI (_Creature); - - ai->Spell[0].Enabled = true; - ai->Spell[0].Spell_Id = 31345; //Cleave - ai->Spell[0].Cooldown = 15000; - ai->Spell[0].CooldownRandomAddition = 5000; - ai->Spell[0].First_Cast = 5000; - ai->Spell[0].Cast_Target_Type = CAST_HOSTILE_RANDOM; - - ai->EnterEvadeMode(); - - return ai; -} - -//Coilfang Strifer -//It hits plate for about 8000 damage, has a Mind Blast spell doing about 3000 shadow damage, and a Psychic Scream Aura, which fears everybody in a 8 yard range of it every 2-3 seconds , for 5 seconds and increasing their movement speed by 150% during the fear. -CreatureAI* GetAI_mob_coilfang_strider(Creature *_Creature) -{ - SimpleAI* ai = new SimpleAI (_Creature); - - ai->Spell[0].Enabled = true; - ai->Spell[0].Spell_Id = 41374; //Mind Blast - ai->Spell[0].Cooldown = 30000; - ai->Spell[0].CooldownRandomAddition = 10000; - ai->Spell[0].First_Cast = 8000; - ai->Spell[0].Cast_Target_Type = CAST_HOSTILE_TARGET; - - //Scream aura not implemented - - ai->EnterEvadeMode(); - - return ai; -} - -struct MANGOS_DLL_DECL mob_shield_generator_channelAI : public ScriptedAI -{ - mob_shield_generator_channelAI(Creature *c) : ScriptedAI(c) - { - pInstance = ((ScriptedInstance*)c->GetInstanceData()); - Reset(); - } - - ScriptedInstance *pInstance; - - uint32 Check_Timer; - bool Channeled; - - void Reset() - { - Check_Timer = 1000; - Channeled = false; - //invisible - m_creature->SetUInt32Value(UNIT_FIELD_DISPLAYID , 11686); - m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - } - - void Aggro(Unit *who) { return; } - - void MoveInLineOfSight(Unit *who) { return; } - - void UpdateAI (const uint32 diff) - { - if(!pInstance) - return; - - if(!Channeled) - { - Unit *Vashj = NULL; - Vashj = Unit::GetUnit((*m_creature), pInstance->GetData64(DATA_LADYVASHJ)); - - if(Vashj && Vashj->isAlive()) - { - //start visual channel - m_creature->SetUInt64Value(UNIT_FIELD_CHANNEL_OBJECT, Vashj->GetGUID()); - m_creature->SetUInt32Value(UNIT_CHANNEL_SPELL, SPELL_MAGIC_BARRIER); - Channeled = true; - } - } - } -}; - -bool ItemUse_item_tainted_core(Player *player, Item* _Item, SpellCastTargets const& targets) -{ - ScriptedInstance *pInstance = ((ScriptedInstance*)player->GetInstanceData()); - - if(!pInstance) - { - player->GetSession()->SendNotification("ERROR: Instance script not initialized. Notify your administrator."); - error_log("ERROR: Lady Vashj Tainted Core: Instance Script Not Initialized"); - return true; - } - - Creature *Vashj = NULL; - Vashj = (Creature*)(Unit::GetUnit((*player), pInstance->GetData64(DATA_LADYVASHJ))); - if(Vashj && ((boss_lady_vashjAI*)Vashj->AI())->Phase == 2) - { - if(targets.getGOTarget() && targets.getGOTarget()->GetTypeId()==TYPEID_GAMEOBJECT) - { - uint32 identifier; - uint8 channel_identifier; - switch(targets.getGOTarget()->GetEntry()) - { - case 185052: - identifier = DATA_SHIELDGENERATOR1; - channel_identifier = 0; - break; - case 185053: - identifier = DATA_SHIELDGENERATOR2; - channel_identifier = 1; - break; - case 185051: - identifier = DATA_SHIELDGENERATOR3; - channel_identifier = 2; - break; - case 185054: - identifier = DATA_SHIELDGENERATOR4; - channel_identifier = 3; - break; - default: - return true; - break; - } - - if(pInstance->GetData(identifier)) - { - player->GetSession()->SendNotification("Already deactivated"); - return true; - } - - //get and remove channel - Unit *Channel = NULL; - Channel = Unit::GetUnit((*Vashj), ((boss_lady_vashjAI*)Vashj->AI())->ShieldGeneratorChannel[channel_identifier]); - if(Channel) - { - //call Unsummon() - Channel->setDeathState(JUST_DIED); - } - - pInstance->SetData(identifier, 1); - - //remove this item - player->DestroyItemCount(31088, 1, true); - } - } - return true; -} - -CreatureAI* GetAI_boss_lady_vashj(Creature *_Creature) -{ - return new boss_lady_vashjAI (_Creature); -} - -CreatureAI* GetAI_mob_enchanted_elemental(Creature *_Creature) -{ - return new mob_enchanted_elementalAI (_Creature); -} - -CreatureAI* GetAI_mob_tainted_elemental(Creature *_Creature) -{ - return new mob_tainted_elementalAI (_Creature); -} - -CreatureAI* GetAI_mob_fathom_sporebat(Creature *_Creature) -{ - return new mob_fathom_sporebatAI (_Creature); -} - -CreatureAI* GetAI_mob_shield_generator_channel(Creature *_Creature) -{ - return new mob_shield_generator_channelAI (_Creature); -} - -void AddSC_boss_lady_vashj() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_lady_vashj"; - newscript->GetAI = GetAI_boss_lady_vashj; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="mob_enchanted_elemental"; - newscript->GetAI = GetAI_mob_enchanted_elemental; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="mob_tainted_elemental"; - newscript->GetAI = GetAI_mob_tainted_elemental; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="mob_fathom_sporebat"; - newscript->GetAI = GetAI_mob_fathom_sporebat; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="mob_coilfang_elite"; - newscript->GetAI = GetAI_mob_coilfang_elite; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="mob_coilfang_strider"; - newscript->GetAI = GetAI_mob_coilfang_strider; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="mob_shield_generator_channel"; - newscript->GetAI = GetAI_mob_shield_generator_channel; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="item_tainted_core"; - newscript->pItemUse = ItemUse_item_tainted_core; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA02111-1307USA + */ + +/* ScriptData +SDName: Boss_Lady_Vashj +SD%Complete: 99 +SDComment: Missing blizzlike Shield Generators coords +SDCategory: Coilfang Resevoir, Serpent Shrine Cavern +EndScriptData */ + +#include "precompiled.h" +#include "def_serpent_shrine.h" +#include "../../../creature/simple_ai.h" +#include "Item.h" +#include "Spell.h" + +#define SPELL_MULTI_SHOT 38310 +#define SPELL_SHOCK_BLAST 38509 +#define SPELL_ENTANGLE 38316 +#define SPELL_STATIC_CHARGE_TRIGGER 38280 +#define SPELL_FORKED_LIGHTNING 40088 +#define SPELL_SHOOT 40873 +#define SPELL_POISON_BOLT 40095 +#define SPELL_TOXIC_SPORES 38575 +#define SPELL_MAGIC_BARRIER 38112 + +#define SAY_INTRO "Water is life. It has become a rare commodity here in Outland. A commodity that we alone shall control. We are the Highborne, and the time has come at last for us to retake our rightful place in the world!" +#define SAY_AGGRO1 "I'll split you from stem to stern! " +#define SAY_AGGRO2 "Victory to Lord Illidan!" +#define SAY_AGGRO3 "I spit on you, surface filth!" +#define SAY_AGGRO4 "Death to the outsiders!" +#define SAY_PHASE1 "I did not wish to lower myself by engaging your kind, but you leave me little choice!" +#define SAY_PHASE2 "The time is now! Leave none standing!" +#define SAY_PHASE3 "You may want to take cover." +#define SAY_BOWSHOT1 "Straight to the heart!" +#define SAY_BOWSHOT2 "Seek your mark!" +#define SAY_SLAY1 "Your time ends now!" +#define SAY_SLAY2 "You have failed!" +#define SAY_DEATH "Lord Illidan, I... I am... sorry." + +#define SOUND_INTRO 11531 +#define SOUND_AGGRO1 11532 +#define SOUND_AGGRO2 11533 +#define SOUND_AGGRO3 11534 +#define SOUND_AGGRO4 11535 +#define SOUND_PHASE1 11538 +#define SOUND_PHASE2 11539 +#define SOUND_PHASE3 11540 +#define SOUND_BOWSHOT1 11536 +#define SOUND_BOWSHOT2 11537 +#define SOUND_SLAY1 11541 +#define SOUND_SLAY2 11542 +#define SOUND_DEATH 11544 + +#define MIDDLE_X 30.134 +#define MIDDLE_Y -923.65 +#define MIDDLE_Z 42.9 + +#define SPOREBAT_X 30.977156 +#define SPOREBAT_Y -925.297761 +#define SPOREBAT_Z 77.176567 +#define SPOREBAT_O 5.223932 + +#define SHIED_GENERATOR_CHANNEL 19870 +#define ENCHANTED_ELEMENTAL 21958 +#define TAINTED_ELEMENTAL 22009 +#define COILFANG_STRIDER 22056 +#define COILFANG_ELITE 22055 +#define FATHOM_SPOREBAT 22140 + +float ElementPos[8][4] = +{ + {8.3, -835.3, 21.9, 5}, + {53.4, -835.3, 21.9, 4.5}, + {96, -861.9, 21.8, 4}, + {96, -986.4, 21.4, 2.5}, + {54.4, -1010.6, 22, 1.8}, + {9.8, -1012, 21.7, 1.4}, + {-35, -987.6, 21.5, 0.8}, + {-58.9, -901.6, 21.5, 6} +}; + +float CoilfangElitePos[3][4] = +{ + {28.84, -923.28, 42.9, 6}, + {31.183281, -953.502625, 41.523602, 1.640957}, + {58.895180, -923.124268, 41.545307, 3.152848} +}; + +float CoilfangStriderPos[3][4] = +{ + {66.427010, -948.778503, 41.262245, 2.584220}, + {7.513962, -959.538208, 41.300422, 1.034629}, + {-12.843201, -907.798401, 41.239620, 6.087094} +}; + +float ShieldGeneratorChannelPos[4][4] = +{ + {49.6262, -902.181, 43.0975, 3.95683}, + {10.988, -901.616, 42.5371, 5.4373}, + {10.3859, -944.036, 42.5446, 0.779888}, + {49.3126, -943.398, 42.5501, 2.40174} +}; + +//Lady Vashj AI +struct MANGOS_DLL_DECL boss_lady_vashjAI : public ScriptedAI +{ + boss_lady_vashjAI (Creature *c) : ScriptedAI(c) + { + pInstance = ((ScriptedInstance*)c->GetInstanceData()); + Reset(); + } + + ScriptedInstance *pInstance; + + uint64 ShieldGeneratorChannel[4]; + + uint32 ShockBlast_Timer; + uint32 Entangle_Timer; + uint32 StaticCharge_Timer; + uint32 ForkedLightning_Timer; + uint32 Check_Timer; + uint32 EnchantedElemental_Timer; + uint32 TaintedElemental_Timer; + uint32 CoilfangElite_Timer; + uint32 CoilfangStrider_Timer; + uint32 SummonSporebat_Timer; + uint32 SummonSporebat_StaticTimer; + uint8 EnchantedElemental_Pos; + uint8 Phase; + + bool Entangle; + + void Reset() + { + ShockBlast_Timer = 1+rand()%60000; + Entangle_Timer = 30000; + StaticCharge_Timer = 10000+rand()%15000; + ForkedLightning_Timer = 2000; + Check_Timer = 1000; + EnchantedElemental_Timer = 5000; + TaintedElemental_Timer = 50000; + CoilfangElite_Timer = 45000+rand()%5000; + CoilfangStrider_Timer = 60000+rand()%10000; + SummonSporebat_Timer = 10000; + SummonSporebat_StaticTimer = 30000; + EnchantedElemental_Pos = 0; + Phase = 0; + + Entangle = false; + + if(pInstance) + pInstance->SetData(DATA_LADYVASHJEVENT, 0); + + ShieldGeneratorChannel[0] = 0; + ShieldGeneratorChannel[1] = 0; + ShieldGeneratorChannel[2] = 0; + ShieldGeneratorChannel[3] = 0; + + } + + //Called when a tainted elemental dies + void EventTaintedElementalDeath() + { + //the next will spawn 50 seconds after the previous one's death + if(TaintedElemental_Timer > 50000) + TaintedElemental_Timer = 50000; + } + + void KilledUnit(Unit *victim) + { + switch(rand()%2) + { + case 0: + DoYell(SAY_SLAY1, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_SLAY1); + break; + + case 1: + DoPlaySoundToSet(m_creature, SOUND_SLAY1); + DoYell(SAY_SLAY2, LANG_UNIVERSAL, NULL); + break; + } + } + + void JustDied(Unit *victim) + { + DoPlaySoundToSet(m_creature, SOUND_DEATH); + DoYell(SAY_DEATH, LANG_UNIVERSAL, NULL); + + if(pInstance) + pInstance->SetData(DATA_LADYVASHJEVENT, 0); + } + + void StartEvent() + { + switch(rand()%4) + { + case 0: + DoPlaySoundToSet(m_creature, SOUND_AGGRO1); + DoYell(SAY_AGGRO1, LANG_UNIVERSAL, NULL); + break; + case 1: + DoPlaySoundToSet(m_creature, SOUND_AGGRO2); + DoYell(SAY_AGGRO2, LANG_UNIVERSAL, NULL); + break; + case 2: + DoPlaySoundToSet(m_creature, SOUND_AGGRO3); + DoYell(SAY_AGGRO3, LANG_UNIVERSAL, NULL); + break; + case 3: + DoPlaySoundToSet(m_creature, SOUND_AGGRO4); + DoYell(SAY_AGGRO4, LANG_UNIVERSAL, NULL); + break; + } + + Phase = 1; + + if(pInstance) + pInstance->SetData(DATA_LADYVASHJEVENT, 1); + } + + void Aggro(Unit *who) + { + //Begin melee attack if we are within range + if(Phase != 2) + DoStartAttackAndMovement(who); + + StartEvent(); + } + + void CastShootOrMultishot() + { + switch(rand()%2) + { + case 0: + //Shoot + //Used in Phases 1 and 3 after Entangle or while having nobody in melee range. A shot that hits her target for 4097-5543 Physical damage. + DoCast(m_creature->getVictim(), SPELL_SHOOT); + break; + case 1: + //Multishot + //Used in Phases 1 and 3 after Entangle or while having nobody in melee range. A shot that hits 1 person and 4 people around him for 6475-7525 physical damage. + DoCast(m_creature->getVictim(), SPELL_MULTI_SHOT); + break; + } + + if(rand()%3) + { + switch(rand()%2) + { + case 0: + DoPlaySoundToSet(m_creature, SOUND_BOWSHOT1); + DoYell(SAY_BOWSHOT1, LANG_UNIVERSAL, NULL); + break; + case 1: + DoPlaySoundToSet(m_creature, SOUND_BOWSHOT2); + DoYell(SAY_BOWSHOT2, LANG_UNIVERSAL, NULL); + break; + } + } + } + + void UpdateAI(const uint32 diff) + { + //to prevent abuses during phase 2 + if(Phase == 2 && !m_creature->getVictim() && InCombat) + EnterEvadeMode(); + + //Return since we have no target + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + if(Phase == 1 || Phase == 3) + { + //ShockBlast_Timer + if (ShockBlast_Timer < diff) + { + //Shock Burst + //Randomly used in Phases 1 and 3 on Vashj's target, it's a Shock spell doing 8325-9675 nature damage and stunning the target for 5 seconds, during which she will not attack her target but switch to the next person on the aggro list. + DoCast(m_creature->getVictim(), SPELL_SHOCK_BLAST); + m_creature->TauntApply(m_creature->getVictim()); + + ShockBlast_Timer = 1000+rand()%14000; //random cooldown + }else ShockBlast_Timer -= diff; + + //StaticCharge_Timer + if(StaticCharge_Timer < diff) + { + //Static Charge + //Used on random people (only 1 person at any given time) in Phases 1 and 3, it's a debuff doing 2775 to 3225 Nature damage to the target and everybody in about 5 yards around it, every 1 seconds for 30 seconds. It can be removed by Cloak of Shadows, Iceblock, Divine Shield, etc, but not by Cleanse or Dispel Magic. + Unit *target = NULL; + target = SelectUnit(SELECT_TARGET_RANDOM, 0); + + if(target && !target->HasAura(SPELL_STATIC_CHARGE_TRIGGER, 0)) + //cast Static Charge every 2 seconds for 20 seconds + DoCast(target, SPELL_STATIC_CHARGE_TRIGGER); + + StaticCharge_Timer = 10000+rand()%20000; //blizzlike + }else StaticCharge_Timer -= diff; + + //Entangle_Timer + if (Entangle_Timer < diff) + { + if(!Entangle) + { + //Entangle + //Used in Phases 1 and 3, it casts Entangling Roots on everybody in a 15 yard radius of Vashj, immobilzing them for 10 seconds and dealing 500 damage every 2 seconds. It's not a magic effect so it cannot be dispelled, but is removed by various buffs such as Cloak of Shadows or Blessing of Freedom. + DoCast(m_creature->getVictim(), SPELL_ENTANGLE); + Entangle = true; + Entangle_Timer = 10000; + } + else + { + CastShootOrMultishot(); + Entangle = false; + Entangle_Timer = 20000+rand()%5000; + } + }else Entangle_Timer -= diff; + + //Phase 1 + if(Phase == 1) + { + //Start phase 2 + if ((m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < 70) + { + //Phase 2 begins when Vashj hits 70%. She will run to the middle of her platform and surround herself in a shield making her invulerable. + Phase = 2; + + m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + m_creature->GetMotionMaster()->Clear(); + m_creature->Relocate(MIDDLE_X, MIDDLE_Y, MIDDLE_Z); + m_creature->SendMonsterMove(MIDDLE_X, MIDDLE_Y, MIDDLE_Z, 0, 0, 0); + + m_creature->RemoveAllAuras(); + // This needs an entry in spell_script_target + DoCast(m_creature, SPELL_MAGIC_BARRIER, true); + + Creature *pCreature; + for(uint8 i = 0; i < 4; i++) + { + pCreature = m_creature->SummonCreature(SHIED_GENERATOR_CHANNEL, ShieldGeneratorChannelPos[i][0], ShieldGeneratorChannelPos[i][1], ShieldGeneratorChannelPos[i][2], ShieldGeneratorChannelPos[i][3], TEMPSUMMON_CORPSE_DESPAWN, 0); + if (pCreature) + ShieldGeneratorChannel[i] = pCreature->GetGUID(); + } + + DoPlaySoundToSet(m_creature, SOUND_PHASE2); + DoYell(SAY_PHASE2, LANG_UNIVERSAL, NULL); + } + } + //Phase 3 + else + { + //SummonSporebat_Timer + if(SummonSporebat_Timer < diff) + { + Creature *Sporebat = NULL; + Sporebat = m_creature->SummonCreature(FATHOM_SPOREBAT, SPOREBAT_X, SPOREBAT_Y, SPOREBAT_Z, SPOREBAT_O, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000); + + if(Sporebat) + { + Unit *target = NULL; + target = SelectUnit(SELECT_TARGET_RANDOM, 0); + if(target) + Sporebat->AI()->AttackStart(target); + } + + //summon sporebats faster and faster + if(SummonSporebat_StaticTimer > 1000) + SummonSporebat_StaticTimer -= 1000; + + SummonSporebat_Timer = SummonSporebat_StaticTimer; + }else SummonSporebat_Timer -= diff; + } + + //Melee attack + DoMeleeAttackIfReady(); + + //Check_Timer - used to check if somebody is in melee range + if(Check_Timer < diff) + { + bool InMeleeRange = false; + Unit *target; + std::list t_list = m_creature->getThreatManager().getThreatList(); + for(std::list::iterator itr = t_list.begin(); itr!= t_list.end(); ++itr) + { + target = Unit::GetUnit(*m_creature, (*itr)->getUnitGuid()); + //if in melee range + if(target && target->IsWithinDistInMap(m_creature, 5)) + { + InMeleeRange = true; + break; + } + } + + //if nobody is in melee range + if(!InMeleeRange) + CastShootOrMultishot(); + + Check_Timer = 1000; + }else Check_Timer -= diff; + } + //Phase 2 + else + { + //ForkedLightning_Timer + if(ForkedLightning_Timer < diff) + { + //Forked Lightning + //Used constantly in Phase 2, it shoots out completely randomly targeted bolts of lightning which hit everybody in a roughtly 60 degree cone in front of Vashj for 2313-2687 nature damage. + Unit *target = NULL; + target = SelectUnit(SELECT_TARGET_RANDOM, 0); + + if(!target) + target = m_creature->getVictim(); + + DoCast(target, SPELL_FORKED_LIGHTNING); + + ForkedLightning_Timer = 2000+rand()%6000; //blizzlike + }else ForkedLightning_Timer -= diff; + + //EnchantedElemental_Timer + if(EnchantedElemental_Timer < diff) + { + Creature *Elemental; + Elemental = m_creature->SummonCreature(ENCHANTED_ELEMENTAL, ElementPos[EnchantedElemental_Pos][0], ElementPos[EnchantedElemental_Pos][1], ElementPos[EnchantedElemental_Pos][2], ElementPos[EnchantedElemental_Pos][3], TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 60000); + if(Elemental) + Elemental->GetMotionMaster()->MovePoint(0, m_creature->GetPositionX(), m_creature->GetPositionY(), m_creature->GetPositionZ()); + + if(EnchantedElemental_Pos == 7) + EnchantedElemental_Pos = 0; + else + EnchantedElemental_Pos++; + + EnchantedElemental_Timer = 10000+rand()%5000; + }else EnchantedElemental_Timer -= diff; + + //TaintedElemental_Timer + if(TaintedElemental_Timer < diff) + { + Creature *Tain_Elemental; + uint32 pos = rand()%8; + Tain_Elemental = m_creature->SummonCreature(TAINTED_ELEMENTAL, ElementPos[pos][0], ElementPos[pos][1], ElementPos[pos][2], ElementPos[pos][3], TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 60000); + if(Tain_Elemental) + { + Tain_Elemental->GetMotionMaster()->Clear(); + Tain_Elemental->GetMotionMaster()->MoveIdle(); + } + + TaintedElemental_Timer = 120000; + }else TaintedElemental_Timer -= diff; + + //CoilfangElite_Timer + if(CoilfangElite_Timer < diff) + { + Creature *CoilfangElite; + uint32 pos = rand()%3; + CoilfangElite = m_creature->SummonCreature(COILFANG_ELITE, CoilfangElitePos[pos][0], CoilfangElitePos[pos][1], CoilfangElitePos[pos][2], CoilfangElitePos[pos][3], TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 45000); + if(CoilfangElite) + { + Unit *target = NULL; + target = SelectUnit(SELECT_TARGET_RANDOM, 0); + if(target) + CoilfangElite->AI()->AttackStart(target); + } + + CoilfangElite_Timer = 45000+rand()%5000; //wowwiki says 50 seconds, bosskillers says 45 + }else CoilfangElite_Timer -= diff; + + //CoilfangStrider_Timer + if(CoilfangStrider_Timer < diff) + { + Creature *CoilfangStrider; + uint32 pos = rand()%3; + CoilfangStrider = m_creature->SummonCreature(COILFANG_STRIDER, CoilfangStriderPos[pos][0], CoilfangStriderPos[pos][1], CoilfangStriderPos[pos][2], CoilfangStriderPos[pos][3], TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000); + if(CoilfangStrider) + { + Unit *target = NULL; + target = SelectUnit(SELECT_TARGET_RANDOM, 0); + if(target) + CoilfangStrider->AI()->AttackStart(target); + } + + CoilfangStrider_Timer = 60000+rand()%10000; //wowwiki says 60 seconds, bosskillers says 60-70 + }else CoilfangStrider_Timer -= diff; + + //Check_Timer + if(Check_Timer < diff) + { + //Start Phase 3 + if(pInstance && pInstance->GetData(DATA_CANSTARTPHASE3)) + { + //set life 50% + m_creature->SetHealth(m_creature->GetMaxHealth()/2); + + m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + m_creature->RemoveAurasDueToSpell(SPELL_MAGIC_BARRIER); + + DoPlaySoundToSet(m_creature, SOUND_PHASE3); + DoYell(SAY_PHASE3, LANG_UNIVERSAL, NULL); + + Phase = 3; + + //return to the tank + m_creature->GetMotionMaster()->MoveChase(m_creature->getVictim()); + } + Check_Timer = 1000; + }else Check_Timer -= diff; + } + } +}; + +//Enchanted Elemental +//If one of them reaches Vashj he will increase her damage done by 5%. +struct MANGOS_DLL_DECL mob_enchanted_elementalAI : public ScriptedAI +{ + mob_enchanted_elementalAI(Creature *c) : ScriptedAI(c) + { + pInstance = ((ScriptedInstance*)c->GetInstanceData()); + Reset(); + } + + ScriptedInstance *pInstance; + + uint32 Check_Timer; + uint32 Movement_Timer; + + void Reset() + { + Check_Timer = 5000; + Movement_Timer = 500; + } + + void Aggro(Unit *who) { return; } + + void MoveInLineOfSight(Unit *who) { return; } + + void UpdateAI(const uint32 diff) + { + //Check_Timer + if(Check_Timer < diff) + { + if(pInstance) + { + Unit *Vashj = NULL; + Vashj = Unit::GetUnit((*m_creature), pInstance->GetData64(DATA_LADYVASHJ)); + if(Vashj) + { + if(Vashj->IsWithinDistInMap(m_creature, 5)) + { + //increase lady vashj damage (+5%) + const CreatureInfo *cinfo = m_creature->GetCreatureInfo(); + Vashj->SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, (cinfo->mindmg +((cinfo->mindmg/100) * 5))); + Vashj->SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, (cinfo->maxdmg +((cinfo->maxdmg/100) * 5))); + m_creature->UpdateDamagePhysical(BASE_ATTACK); + + //call Unsummon() + m_creature->setDeathState(JUST_DIED); + } + else if(((boss_lady_vashjAI*)((Creature*)Vashj)->AI())->InCombat == false) + { + //call Unsummon() + m_creature->setDeathState(JUST_DIED); + } + } + } + else error_log("ERROR: Instance Data for Serpentshrine Caverns not set"); + Check_Timer = 1000; + }else Check_Timer -= diff; + } +}; + +//Tainted Elemental +//This mob has 7,900 life, doesn't move, and shoots Poison Bolts at one person anywhere in the area, doing 3,000 nature damage and placing a posion doing 2,000 damage every 2 seconds. He will switch targets often, or sometimes just hang on a single player, but there is nothing you can do about it except heal the damage and kill the Tainted Elemental +struct MANGOS_DLL_DECL mob_tainted_elementalAI : public ScriptedAI +{ + mob_tainted_elementalAI(Creature *c) : ScriptedAI(c) + { + pInstance = ((ScriptedInstance*)c->GetInstanceData()); + Reset(); + } + + ScriptedInstance *pInstance; + + uint32 PoisonBolt_Timer; + + void Reset() + { + PoisonBolt_Timer = 5000+rand()%5000; + } + + void JustDied(Unit *killer) + { + if(pInstance) + { + Creature *Vashj = NULL; + Vashj = (Creature*)(Unit::GetUnit((*m_creature), pInstance->GetData64(DATA_LADYVASHJ))); + + if(Vashj) + ((boss_lady_vashjAI*)Vashj->AI())->EventTaintedElementalDeath(); + } + } + + void Aggro(Unit *who) + { + } + + void UpdateAI(const uint32 diff) + { + //PoisonBolt_Timer + if(PoisonBolt_Timer < diff) + { + Unit *target = NULL; + target = SelectUnit(SELECT_TARGET_RANDOM, 0); + + if(target && target->IsWithinDistInMap(m_creature, 30)) + DoCast(target, SPELL_POISON_BOLT); + + PoisonBolt_Timer = 5000+rand()%5000; + }else PoisonBolt_Timer -= diff; + } +}; + +//Fathom Sporebat +//Toxic Spores: Used in Phase 3 by the Spore Bats, it creates a contaminated green patch of ground, dealing about 2775-3225 nature damage every second to anyone who stands in it. +struct MANGOS_DLL_DECL mob_fathom_sporebatAI : public ScriptedAI +{ + mob_fathom_sporebatAI(Creature *c) : ScriptedAI(c) + { + pInstance = ((ScriptedInstance*)c->GetInstanceData()); + Reset(); + } + + ScriptedInstance *pInstance; + + uint32 ToxicSpore_Timer; + uint32 Check_Timer; + + void Reset() + { + m_creature->setFaction(14); + ToxicSpore_Timer = 5000; + Check_Timer = 1000; + } + + void Aggro(Unit *who) {} + + void UpdateAI (const uint32 diff) + { + //Return since we have no target + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + //ToxicSpore_Timer + if(ToxicSpore_Timer < diff) + { + Unit *target = NULL; + target = SelectUnit(SELECT_TARGET_RANDOM, 0); + + //The Spores will hit you anywhere in the instance: underwater, at the elevator, at the entrance, wherever. + if(target) + DoCast(target, SPELL_TOXIC_SPORES); + + ToxicSpore_Timer = 20000+rand()%5000; + }else ToxicSpore_Timer -= diff; + + //Check_Timer + if(Check_Timer < diff) + { + if(pInstance) + { + //check if vashj is death + Unit *Vashj = NULL; + Vashj = Unit::GetUnit((*m_creature), pInstance->GetData64(DATA_LADYVASHJ)); + if(!Vashj || (Vashj && !Vashj->isAlive())) + { + //remove + m_creature->setDeathState(DEAD); + m_creature->RemoveCorpse(); + m_creature->setFaction(35); + } + } + + Check_Timer = 1000; + }else Check_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; + +//Coilfang Elite +//It's an elite Naga mob with 170,000 HP. It does about 5000 damage on plate, and has a nasty cleave hitting for about 7500 damage +CreatureAI* GetAI_mob_coilfang_elite(Creature *_Creature) +{ + SimpleAI* ai = new SimpleAI (_Creature); + + ai->Spell[0].Enabled = true; + ai->Spell[0].Spell_Id = 31345; //Cleave + ai->Spell[0].Cooldown = 15000; + ai->Spell[0].CooldownRandomAddition = 5000; + ai->Spell[0].First_Cast = 5000; + ai->Spell[0].Cast_Target_Type = CAST_HOSTILE_RANDOM; + + ai->EnterEvadeMode(); + + return ai; +} + +//Coilfang Strifer +//It hits plate for about 8000 damage, has a Mind Blast spell doing about 3000 shadow damage, and a Psychic Scream Aura, which fears everybody in a 8 yard range of it every 2-3 seconds , for 5 seconds and increasing their movement speed by 150% during the fear. +CreatureAI* GetAI_mob_coilfang_strider(Creature *_Creature) +{ + SimpleAI* ai = new SimpleAI (_Creature); + + ai->Spell[0].Enabled = true; + ai->Spell[0].Spell_Id = 41374; //Mind Blast + ai->Spell[0].Cooldown = 30000; + ai->Spell[0].CooldownRandomAddition = 10000; + ai->Spell[0].First_Cast = 8000; + ai->Spell[0].Cast_Target_Type = CAST_HOSTILE_TARGET; + + //Scream aura not implemented + + ai->EnterEvadeMode(); + + return ai; +} + +struct MANGOS_DLL_DECL mob_shield_generator_channelAI : public ScriptedAI +{ + mob_shield_generator_channelAI(Creature *c) : ScriptedAI(c) + { + pInstance = ((ScriptedInstance*)c->GetInstanceData()); + Reset(); + } + + ScriptedInstance *pInstance; + + uint32 Check_Timer; + bool Channeled; + + void Reset() + { + Check_Timer = 1000; + Channeled = false; + //invisible + m_creature->SetUInt32Value(UNIT_FIELD_DISPLAYID , 11686); + m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + } + + void Aggro(Unit *who) { return; } + + void MoveInLineOfSight(Unit *who) { return; } + + void UpdateAI (const uint32 diff) + { + if(!pInstance) + return; + + if(!Channeled) + { + Unit *Vashj = NULL; + Vashj = Unit::GetUnit((*m_creature), pInstance->GetData64(DATA_LADYVASHJ)); + + if(Vashj && Vashj->isAlive()) + { + //start visual channel + m_creature->SetUInt64Value(UNIT_FIELD_CHANNEL_OBJECT, Vashj->GetGUID()); + m_creature->SetUInt32Value(UNIT_CHANNEL_SPELL, SPELL_MAGIC_BARRIER); + Channeled = true; + } + } + } +}; + +bool ItemUse_item_tainted_core(Player *player, Item* _Item, SpellCastTargets const& targets) +{ + ScriptedInstance *pInstance = ((ScriptedInstance*)player->GetInstanceData()); + + if(!pInstance) + { + player->GetSession()->SendNotification("ERROR: Instance script not initialized. Notify your administrator."); + error_log("ERROR: Lady Vashj Tainted Core: Instance Script Not Initialized"); + return true; + } + + Creature *Vashj = NULL; + Vashj = (Creature*)(Unit::GetUnit((*player), pInstance->GetData64(DATA_LADYVASHJ))); + if(Vashj && ((boss_lady_vashjAI*)Vashj->AI())->Phase == 2) + { + if(targets.getGOTarget() && targets.getGOTarget()->GetTypeId()==TYPEID_GAMEOBJECT) + { + uint32 identifier; + uint8 channel_identifier; + switch(targets.getGOTarget()->GetEntry()) + { + case 185052: + identifier = DATA_SHIELDGENERATOR1; + channel_identifier = 0; + break; + case 185053: + identifier = DATA_SHIELDGENERATOR2; + channel_identifier = 1; + break; + case 185051: + identifier = DATA_SHIELDGENERATOR3; + channel_identifier = 2; + break; + case 185054: + identifier = DATA_SHIELDGENERATOR4; + channel_identifier = 3; + break; + default: + return true; + break; + } + + if(pInstance->GetData(identifier)) + { + player->GetSession()->SendNotification("Already deactivated"); + return true; + } + + //get and remove channel + Unit *Channel = NULL; + Channel = Unit::GetUnit((*Vashj), ((boss_lady_vashjAI*)Vashj->AI())->ShieldGeneratorChannel[channel_identifier]); + if(Channel) + { + //call Unsummon() + Channel->setDeathState(JUST_DIED); + } + + pInstance->SetData(identifier, 1); + + //remove this item + player->DestroyItemCount(31088, 1, true); + } + } + return true; +} + +CreatureAI* GetAI_boss_lady_vashj(Creature *_Creature) +{ + return new boss_lady_vashjAI (_Creature); +} + +CreatureAI* GetAI_mob_enchanted_elemental(Creature *_Creature) +{ + return new mob_enchanted_elementalAI (_Creature); +} + +CreatureAI* GetAI_mob_tainted_elemental(Creature *_Creature) +{ + return new mob_tainted_elementalAI (_Creature); +} + +CreatureAI* GetAI_mob_fathom_sporebat(Creature *_Creature) +{ + return new mob_fathom_sporebatAI (_Creature); +} + +CreatureAI* GetAI_mob_shield_generator_channel(Creature *_Creature) +{ + return new mob_shield_generator_channelAI (_Creature); +} + +void AddSC_boss_lady_vashj() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_lady_vashj"; + newscript->GetAI = GetAI_boss_lady_vashj; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="mob_enchanted_elemental"; + newscript->GetAI = GetAI_mob_enchanted_elemental; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="mob_tainted_elemental"; + newscript->GetAI = GetAI_mob_tainted_elemental; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="mob_fathom_sporebat"; + newscript->GetAI = GetAI_mob_fathom_sporebat; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="mob_coilfang_elite"; + newscript->GetAI = GetAI_mob_coilfang_elite; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="mob_coilfang_strider"; + newscript->GetAI = GetAI_mob_coilfang_strider; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="mob_shield_generator_channel"; + newscript->GetAI = GetAI_mob_shield_generator_channel; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="item_tainted_core"; + newscript->pItemUse = ItemUse_item_tainted_core; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/boss_leotheras_the_blind.cpp b/src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/boss_leotheras_the_blind.cpp index ea54e5ffcab..e689da4c585 100644 --- a/src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/boss_leotheras_the_blind.cpp +++ b/src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/boss_leotheras_the_blind.cpp @@ -1,359 +1,338 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Leotheras_The_Blind -SD%Complete: 50 -SDComment: Missing Inner Demons -SDCategory: Coilfang Resevoir, Serpent Shrine Cavern -EndScriptData */ - -#include "precompiled.h" -#include "def_serpent_shrine.h" - -#define SPELL_WHIRLWIND 40653 -#define SPELL_CHAOS_BLAST 37675 -//#define SPELL_INSIDIOUS_WHISPER 37676 // useless - dummy effect that can't be implemented - -#define SAY_AGGRO "Finally my banishment ends!" -#define SAY_SWITCH_TO_DEMON "Be gone trifling elf. I'm in control now." -#define SAY_INNER_DEMONS "We all have our demons..." -#define SAY_DEMON_SLAY1 "I have no equal." -#define SAY_DEMON_SLAY2 "Perish, mortal." -#define SAY_DEMON_SLAY3 "Yes, YES! Ahahah!" -#define SAY_NIGHTELF_SLAY1 "Kill! KILL!" -#define SAY_NIGHTELF_SLAY2 "That's right! Yes!" -#define SAY_NIGHTELF_SLAY3 "Who's the master now?" -#define SAY_FINAL_FORM "No! NO! What have you done?! I am the master, do you hear me? I... aaghh... Can't... contain him..." -#define SAY_FREE "At last I am liberated. It has been too long since I have tasted true freedom!" -#define SAY_DEATH "You cannot kill me! Fools, I'll be back! I'll... aarghh..." - -#define SOUND_AGGRO 11312 -#define SOUND_SWITCH_TO_DEMON 11304 -#define SOUND_INNER_DEMONS 11305 -#define SOUND_DEMON_SLAY1 11306 -#define SOUND_DEMON_SLAY2 11307 -#define SOUND_DEMON_SLAY3 11308 -#define SOUND_NIGHTELF_SLAY1 11314 -#define SOUND_NIGHTELF_SLAY2 11315 -#define SOUND_NIGHTELF_SLAY3 11316 -#define SOUND_FINAL_FORM 11313 -#define SOUND_FREE 11309 -#define SOUND_DEATH 11317 - -#define MODEL_DEMON 14555 -#define MODEL_NIGHTELF 20514 - -#define DEMON_FORM 21845 - -//Original Leotheras the Blind AI -struct MANGOS_DLL_DECL boss_leotheras_the_blindAI : public ScriptedAI -{ - boss_leotheras_the_blindAI(Creature *c) : ScriptedAI(c) - { - pInstance = (c->GetInstanceData()) ? ((ScriptedInstance*)c->GetInstanceData()) : NULL; - Demon = 0; - Reset(); - } - - ScriptedInstance *pInstance; - - uint32 Whirlwind_Timer; - uint32 ChaosBlast_Timer; - uint32 Switch_Timer; - - bool DemonForm; - bool IsFinalForm; - - uint64 Demon; - - void Reset() - { - Whirlwind_Timer = 20000; - ChaosBlast_Timer = 1000; - Switch_Timer = 45000; - - DemonForm = false; - IsFinalForm = false; - - m_creature->SetUInt32Value(UNIT_FIELD_DISPLAYID, MODEL_NIGHTELF); - - if(pInstance) - pInstance->SetData(DATA_LEOTHERASTHEBLINDEVENT, 0); - } - - void StartEvent() - { - DoYell(SAY_AGGRO, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_AGGRO); - - if(pInstance) - pInstance->SetData(DATA_LEOTHERASTHEBLINDEVENT, 1); - } - - void KilledUnit(Unit *victim) - { - if(victim->GetTypeId() != TYPEID_PLAYER) - return; - - if(DemonForm) - switch(rand()%3) - { - case 0: - DoYell(SAY_DEMON_SLAY1, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_DEMON_SLAY1); - break; - case 1: - DoYell(SAY_DEMON_SLAY2, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_DEMON_SLAY2); - break; - case 2: - DoYell(SAY_DEMON_SLAY3, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_DEMON_SLAY3); - break; - } - else - switch(rand()%3) - { - case 0: - DoYell(SAY_NIGHTELF_SLAY1, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_NIGHTELF_SLAY1); - break; - case 1: - DoYell(SAY_NIGHTELF_SLAY2, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_NIGHTELF_SLAY2); - break; - case 2: - DoYell(SAY_NIGHTELF_SLAY3, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_NIGHTELF_SLAY3); - break; - } - } - - void JustDied(Unit *victim) - { - DoYell(SAY_DEATH, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_DEATH); - - //despawn copy - if(Demon) - { - Unit *pUnit = NULL; - pUnit = Unit::GetUnit((*m_creature), Demon); - - if(pUnit) - pUnit->DealDamage(pUnit, pUnit->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); - } - - if(pInstance) - pInstance->SetData(DATA_LEOTHERASTHEBLINDEVENT, 0); - } - - void Aggro(Unit *who) - { - StartEvent(); - } - - void UpdateAI(const uint32 diff) - { - //Return since we have no target - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - if(!DemonForm) - { - //Whirlwind_Timer - if(Whirlwind_Timer < diff) - { - DoCast(m_creature, SPELL_WHIRLWIND); - Whirlwind_Timer = 25000; - }else Whirlwind_Timer -= diff; - - //Switch_Timer - if(!IsFinalForm) - if(Switch_Timer < diff) - { - //switch to demon form - m_creature->SetUInt32Value(UNIT_FIELD_DISPLAYID, MODEL_DEMON); - DoYell(SAY_SWITCH_TO_DEMON, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_SWITCH_TO_DEMON); - DemonForm = true; - - Switch_Timer = 60000; - }else Switch_Timer -= diff; - - DoMeleeAttackIfReady(); - } - else - { - //ChaosBlast_Timer - if(ChaosBlast_Timer < diff) - { - DoCast(m_creature->getVictim(), SPELL_CHAOS_BLAST); - ChaosBlast_Timer = 1500; - }else ChaosBlast_Timer -= diff; - - //Switch_Timer - if(Switch_Timer < diff) - { - //switch to nightelf form - m_creature->SetUInt32Value(UNIT_FIELD_DISPLAYID, MODEL_NIGHTELF); - DemonForm = false; - - Switch_Timer = 45000; - }else Switch_Timer -= diff; - } - - if(!IsFinalForm && (m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < 15) - { - //at this point he divides himself in two parts - Creature *Copy = NULL; - Copy = DoSpawnCreature(DEMON_FORM, 0, 0, 0, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000); - - if(Copy) - { - Demon = Copy->GetGUID(); - Copy->AI()->AttackStart(m_creature->getVictim()); - } - - //set nightelf final form - IsFinalForm = true; - DemonForm = false; - - DoYell(SAY_FINAL_FORM, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_FINAL_FORM); - - m_creature->SetUInt32Value(UNIT_FIELD_DISPLAYID, MODEL_NIGHTELF); - } - } -}; - -//Leotheras the Blind Demon Form AI -struct MANGOS_DLL_DECL boss_leotheras_the_blind_demonformAI : public ScriptedAI -{ - boss_leotheras_the_blind_demonformAI(Creature *c) : ScriptedAI(c) - { - Reset(); - } - - uint32 ChaosBlast_Timer; - - void Reset() - { - ChaosBlast_Timer = 1000; - } - - void StartEvent() - { - DoYell(SAY_FREE, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_FREE); - } - - void KilledUnit(Unit *victim) - { - if(victim->GetTypeId() != TYPEID_PLAYER) - return; - - switch(rand()%3) - { - case 0: - DoYell(SAY_DEMON_SLAY1, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_DEMON_SLAY1); - break; - case 1: - DoYell(SAY_DEMON_SLAY2, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_DEMON_SLAY2); - break; - case 2: - DoYell(SAY_DEMON_SLAY3, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_DEMON_SLAY3); - break; - } - } - - void JustDied(Unit *victim) - { - //invisibility (blizzlike, at the end of the fight he doesn't die, he disappears) - m_creature->CastSpell(m_creature, 8149, true); - } - - void Aggro(Unit *who) - { - StartEvent(); - } - - void MoveInLineOfSight(Unit *who) - { - if (!who || m_creature->getVictim()) - return; - - if (who->isTargetableForAttack() && who->isInAccessablePlaceFor(m_creature) && m_creature->IsHostileTo(who)) - { - float attackRadius = m_creature->GetAttackDistance(who); - if (m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->GetDistanceZ(who) <= CREATURE_Z_ATTACK_RANGE && m_creature->IsWithinLOSInMap(who)) - { - if(who->HasStealthAura()) - who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); - - DoStartAttackAndMovement(who); - - if(!InCombat) - StartEvent(); - } - } - } - - void UpdateAI(const uint32 diff) - { - //Return since we have no target - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - //ChaosBlast_Timer - if(ChaosBlast_Timer < diff) - { - DoCast(m_creature->getVictim(), SPELL_CHAOS_BLAST); - ChaosBlast_Timer = 1500; - }else ChaosBlast_Timer -= diff; - - //Do NOT deal any melee damage to the target. - } -}; - -CreatureAI* GetAI_boss_leotheras_the_blind(Creature *_Creature) -{ - return new boss_leotheras_the_blindAI (_Creature); -} - -CreatureAI* GetAI_boss_leotheras_the_blind_demonform(Creature *_Creature) -{ - return new boss_leotheras_the_blind_demonformAI (_Creature); -} - -void AddSC_boss_leotheras_the_blind() -{ - Script *newscript; - - newscript = new Script; - newscript->Name="boss_leotheras_the_blind"; - newscript->GetAI = GetAI_boss_leotheras_the_blind; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="boss_leotheras_the_blind_demonform"; - newscript->GetAI = GetAI_boss_leotheras_the_blind_demonform; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Leotheras_The_Blind +SD%Complete: 50 +SDComment: Missing Inner Demons +SDCategory: Coilfang Resevoir, Serpent Shrine Cavern +EndScriptData */ + +#include "precompiled.h" +#include "def_serpent_shrine.h" + +#define SPELL_WHIRLWIND 40653 +#define SPELL_CHAOS_BLAST 37675 +//#define SPELL_INSIDIOUS_WHISPER 37676 // useless - dummy effect that can't be implemented + +#define SAY_AGGRO "Finally my banishment ends!" +#define SAY_SWITCH_TO_DEMON "Be gone trifling elf. I'm in control now." +#define SAY_INNER_DEMONS "We all have our demons..." +#define SAY_DEMON_SLAY1 "I have no equal." +#define SAY_DEMON_SLAY2 "Perish, mortal." +#define SAY_DEMON_SLAY3 "Yes, YES! Ahahah!" +#define SAY_NIGHTELF_SLAY1 "Kill! KILL!" +#define SAY_NIGHTELF_SLAY2 "That's right! Yes!" +#define SAY_NIGHTELF_SLAY3 "Who's the master now?" +#define SAY_FINAL_FORM "No! NO! What have you done?! I am the master, do you hear me? I... aaghh... Can't... contain him..." +#define SAY_FREE "At last I am liberated. It has been too long since I have tasted true freedom!" +#define SAY_DEATH "You cannot kill me! Fools, I'll be back! I'll... aarghh..." + +#define SOUND_AGGRO 11312 +#define SOUND_SWITCH_TO_DEMON 11304 +#define SOUND_INNER_DEMONS 11305 +#define SOUND_DEMON_SLAY1 11306 +#define SOUND_DEMON_SLAY2 11307 +#define SOUND_DEMON_SLAY3 11308 +#define SOUND_NIGHTELF_SLAY1 11314 +#define SOUND_NIGHTELF_SLAY2 11315 +#define SOUND_NIGHTELF_SLAY3 11316 +#define SOUND_FINAL_FORM 11313 +#define SOUND_FREE 11309 +#define SOUND_DEATH 11317 + +#define MODEL_DEMON 14555 +#define MODEL_NIGHTELF 20514 + +#define DEMON_FORM 21845 + +//Original Leotheras the Blind AI +struct MANGOS_DLL_DECL boss_leotheras_the_blindAI : public ScriptedAI +{ + boss_leotheras_the_blindAI(Creature *c) : ScriptedAI(c) + { + pInstance = (c->GetInstanceData()) ? ((ScriptedInstance*)c->GetInstanceData()) : NULL; + Demon = 0; + Reset(); + } + + ScriptedInstance *pInstance; + + uint32 Whirlwind_Timer; + uint32 ChaosBlast_Timer; + uint32 Switch_Timer; + + bool DemonForm; + bool IsFinalForm; + + uint64 Demon; + + void Reset() + { + Whirlwind_Timer = 20000; + ChaosBlast_Timer = 1000; + Switch_Timer = 45000; + + DemonForm = false; + IsFinalForm = false; + + m_creature->SetUInt32Value(UNIT_FIELD_DISPLAYID, MODEL_NIGHTELF); + + if(pInstance) + pInstance->SetData(DATA_LEOTHERASTHEBLINDEVENT, 0); + } + + void StartEvent() + { + DoYell(SAY_AGGRO, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_AGGRO); + + if(pInstance) + pInstance->SetData(DATA_LEOTHERASTHEBLINDEVENT, 1); + } + + void KilledUnit(Unit *victim) + { + if(victim->GetTypeId() != TYPEID_PLAYER) + return; + + if(DemonForm) + switch(rand()%3) + { + case 0: + DoYell(SAY_DEMON_SLAY1, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_DEMON_SLAY1); + break; + case 1: + DoYell(SAY_DEMON_SLAY2, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_DEMON_SLAY2); + break; + case 2: + DoYell(SAY_DEMON_SLAY3, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_DEMON_SLAY3); + break; + } + else + switch(rand()%3) + { + case 0: + DoYell(SAY_NIGHTELF_SLAY1, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_NIGHTELF_SLAY1); + break; + case 1: + DoYell(SAY_NIGHTELF_SLAY2, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_NIGHTELF_SLAY2); + break; + case 2: + DoYell(SAY_NIGHTELF_SLAY3, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_NIGHTELF_SLAY3); + break; + } + } + + void JustDied(Unit *victim) + { + DoYell(SAY_DEATH, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_DEATH); + + //despawn copy + if(Demon) + { + Unit *pUnit = NULL; + pUnit = Unit::GetUnit((*m_creature), Demon); + + if(pUnit) + pUnit->DealDamage(pUnit, pUnit->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); + } + + if(pInstance) + pInstance->SetData(DATA_LEOTHERASTHEBLINDEVENT, 0); + } + + void Aggro(Unit *who) + { + StartEvent(); + } + + void UpdateAI(const uint32 diff) + { + //Return since we have no target + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + if(!DemonForm) + { + //Whirlwind_Timer + if(Whirlwind_Timer < diff) + { + DoCast(m_creature, SPELL_WHIRLWIND); + Whirlwind_Timer = 25000; + }else Whirlwind_Timer -= diff; + + //Switch_Timer + if(!IsFinalForm) + if(Switch_Timer < diff) + { + //switch to demon form + m_creature->SetUInt32Value(UNIT_FIELD_DISPLAYID, MODEL_DEMON); + DoYell(SAY_SWITCH_TO_DEMON, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_SWITCH_TO_DEMON); + DemonForm = true; + + Switch_Timer = 60000; + }else Switch_Timer -= diff; + + DoMeleeAttackIfReady(); + } + else + { + //ChaosBlast_Timer + if(ChaosBlast_Timer < diff) + { + DoCast(m_creature->getVictim(), SPELL_CHAOS_BLAST); + ChaosBlast_Timer = 1500; + }else ChaosBlast_Timer -= diff; + + //Switch_Timer + if(Switch_Timer < diff) + { + //switch to nightelf form + m_creature->SetUInt32Value(UNIT_FIELD_DISPLAYID, MODEL_NIGHTELF); + DemonForm = false; + + Switch_Timer = 45000; + }else Switch_Timer -= diff; + } + + if(!IsFinalForm && (m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < 15) + { + //at this point he divides himself in two parts + Creature *Copy = NULL; + Copy = DoSpawnCreature(DEMON_FORM, 0, 0, 0, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000); + + if(Copy) + { + Demon = Copy->GetGUID(); + Copy->AI()->AttackStart(m_creature->getVictim()); + } + + //set nightelf final form + IsFinalForm = true; + DemonForm = false; + + DoYell(SAY_FINAL_FORM, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_FINAL_FORM); + + m_creature->SetUInt32Value(UNIT_FIELD_DISPLAYID, MODEL_NIGHTELF); + } + } +}; + +//Leotheras the Blind Demon Form AI +struct MANGOS_DLL_DECL boss_leotheras_the_blind_demonformAI : public ScriptedAI +{ + boss_leotheras_the_blind_demonformAI(Creature *c) : ScriptedAI(c) + { + Reset(); + } + + uint32 ChaosBlast_Timer; + + void Reset() + { + ChaosBlast_Timer = 1000; + } + + void StartEvent() + { + DoYell(SAY_FREE, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_FREE); + } + + void KilledUnit(Unit *victim) + { + if(victim->GetTypeId() != TYPEID_PLAYER) + return; + + switch(rand()%3) + { + case 0: + DoYell(SAY_DEMON_SLAY1, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_DEMON_SLAY1); + break; + case 1: + DoYell(SAY_DEMON_SLAY2, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_DEMON_SLAY2); + break; + case 2: + DoYell(SAY_DEMON_SLAY3, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_DEMON_SLAY3); + break; + } + } + + void JustDied(Unit *victim) + { + //invisibility (blizzlike, at the end of the fight he doesn't die, he disappears) + m_creature->CastSpell(m_creature, 8149, true); + } + + void Aggro(Unit *who) + { + StartEvent(); + } + + void UpdateAI(const uint32 diff) + { + //Return since we have no target + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + //ChaosBlast_Timer + if(ChaosBlast_Timer < diff) + { + DoCast(m_creature->getVictim(), SPELL_CHAOS_BLAST); + ChaosBlast_Timer = 1500; + }else ChaosBlast_Timer -= diff; + + //Do NOT deal any melee damage to the target. + } +}; + +CreatureAI* GetAI_boss_leotheras_the_blind(Creature *_Creature) +{ + return new boss_leotheras_the_blindAI (_Creature); +} + +CreatureAI* GetAI_boss_leotheras_the_blind_demonform(Creature *_Creature) +{ + return new boss_leotheras_the_blind_demonformAI (_Creature); +} + +void AddSC_boss_leotheras_the_blind() +{ + Script *newscript; + + newscript = new Script; + newscript->Name="boss_leotheras_the_blind"; + newscript->GetAI = GetAI_boss_leotheras_the_blind; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="boss_leotheras_the_blind_demonform"; + newscript->GetAI = GetAI_boss_leotheras_the_blind_demonform; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/boss_morogrim_tidewalker.cpp b/src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/boss_morogrim_tidewalker.cpp index 27ebaf4bd7e..9283c30fe72 100644 --- a/src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/boss_morogrim_tidewalker.cpp +++ b/src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/boss_morogrim_tidewalker.cpp @@ -1,406 +1,406 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -/* ScriptData -SDName: Boss_Morogrim_Tidewalker -SD%Complete: 90 -SDComment: Water globules don't explode properly -SDCategory: Coilfang Resevoir, Serpent Shrine Cavern -EndScriptData */ - -#include "precompiled.h" -#include "def_serpent_shrine.h" - -#define SPELL_TIDAL_WAVE 37730 -#define SPELL_WATERY_GRAVE 38049 -#define SPELL_EARTHQUAKE 37764 -#define SPELL_WATERY_GRAVE_EXPLOSION 37852 - -#define SAY_AGGRO "Flood of the deep, take you!" -#define SAY_SUMMON1 "By the Tides, kill them at once!" -#define SAY_SUMMON2 "Destroy them my subjects!" -#define SAY_SLAY1 "It is done!" -#define SAY_SLAY2 "Strugging only makes it worse." -#define SAY_SLAY3 "Only the strong survive." -#define SAY_SUMMON_BUBL1 "There is nowhere to hide!" -#define SAY_SUMMON_BUBL2 "Soon it will be finished!" -#define SAY_DEATH "Great... currents of... Ageon." - -#define SOUND_AGGRO 11321 -#define SOUND_SUMMON1 11322 -#define SOUND_SUMMON2 11323 -#define SOUND_SLAY1 11326 -#define SOUND_SLAY2 11327 -#define SOUND_SLAY3 11328 -#define SOUND_SUMMON_BUBL1 11324 -#define SOUND_SUMMON_BUBL2 11325 -#define SOUND_DEATH 11329 - -#define WATERY_GRAVE_X1 334.64 -#define WATERY_GRAVE_Y1 -728.89 -#define WATERY_GRAVE_Z1 -14.42 -#define WATERY_GRAVE_X2 365.51 -#define WATERY_GRAVE_Y2 -737.14 -#define WATERY_GRAVE_Z2 -14.44 -#define WATERY_GRAVE_X3 366.19 -#define WATERY_GRAVE_Y3 -709.59 -#define WATERY_GRAVE_Z3 -14.36 -#define WATERY_GRAVE_X4 372.93 -#define WATERY_GRAVE_Y4 -690.96 -#define WATERY_GRAVE_Z4 -14.44 - -#define EMOTE_WATERY_GRAVE "sends his enemies to their watery graves!" -#define EMOTE_EARTHQUAKE "The violent earthquake has alerted nearby murlocs!" -#define EMOTE_WATERY_GLOBULES "summons Watery Globules!" - -#define WATER_GLOBULE 21913 -#define TIDEWALKER_LURKER 21920 - -//Morogrim Tidewalker AI -struct MANGOS_DLL_DECL boss_morogrim_tidewalkerAI : public ScriptedAI -{ - boss_morogrim_tidewalkerAI(Creature *c) : ScriptedAI(c) - { - pInstance = ((ScriptedInstance*)c->GetInstanceData()); - Reset(); - } - - ScriptedInstance* pInstance; - - uint32 TidalWave_Timer; - uint32 WateryGrave_Timer; - uint32 Earthquake_Timer; - uint32 WateryGlobules_Timer; - - bool Earthquake; - bool Phase2; - - void Reset() - { - TidalWave_Timer = 10000; - WateryGrave_Timer = 30000; - Earthquake_Timer = 40000; - WateryGlobules_Timer = 0; - - Earthquake = false; - Phase2 = false; - - if(pInstance) - pInstance->SetData(DATA_MOROGRIMTIDEWALKEREVENT, NOT_STARTED); - } - - void StartEvent() - { - DoPlaySoundToSet(m_creature, SOUND_AGGRO); - DoYell(SAY_AGGRO, LANG_UNIVERSAL, NULL); - - if(pInstance) - pInstance->SetData(DATA_MOROGRIMTIDEWALKEREVENT, IN_PROGRESS); - } - - void KilledUnit(Unit *victim) - { - switch(rand()%3) - { - case 0: - DoPlaySoundToSet(m_creature, SOUND_SLAY1); - DoYell(SAY_SLAY1, LANG_UNIVERSAL, NULL); - break; - - case 1: - DoPlaySoundToSet(m_creature, SOUND_SLAY2); - DoYell(SAY_SLAY2, LANG_UNIVERSAL, NULL); - break; - - case 2: - DoPlaySoundToSet(m_creature, SOUND_SLAY3); - DoYell(SAY_SLAY3, LANG_UNIVERSAL, NULL); - break; - } - } - - void JustDied(Unit *victim) - { - DoPlaySoundToSet(m_creature, SOUND_DEATH); - DoYell(SAY_DEATH, LANG_UNIVERSAL, NULL); - - if(pInstance) - pInstance->SetData(DATA_MOROGRIMTIDEWALKEREVENT, NOT_STARTED); - } - - void Aggro(Unit *who) { StartEvent(); } - - void ApplyWateryGrave(Unit *player, uint8 pos) - { - float x, y, z; - - switch(pos) - { - case 0: - x = WATERY_GRAVE_X1; - y = WATERY_GRAVE_Y1; - z = WATERY_GRAVE_Z1; - break; - - case 1: - x = WATERY_GRAVE_X2; - y = WATERY_GRAVE_Y2; - z = WATERY_GRAVE_Z2; - break; - - case 2: - x = WATERY_GRAVE_X3; - y = WATERY_GRAVE_Y3; - z = WATERY_GRAVE_Z3; - break; - - case 3: - x = WATERY_GRAVE_X4; - y = WATERY_GRAVE_Y4; - z = WATERY_GRAVE_Z4; - break; - } - - DoTeleportPlayer(player, x, y, z+1, player->GetOrientation()); - DoCast(player, SPELL_WATERY_GRAVE); - } - - void SummonMurloc(float x, float y, float z) - { - Creature *Summoned; - - Summoned = m_creature->SummonCreature(TIDEWALKER_LURKER, x, y, z, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000); - if(Summoned) - { - Unit *target = NULL; - target = SelectUnit(SELECT_TARGET_RANDOM, 0); - if(target) - Summoned->AI()->AttackStart(target); - } - } - - void SummonWaterGlobule(float x, float y, float z) - { - Creature *Globule; - - Globule = m_creature->SummonCreature(WATER_GLOBULE, x, y, z, 0, TEMPSUMMON_TIMED_DESPAWN, 30000); //they despawn after 30 seconds - if(Globule) - { - Unit *target = NULL; - target = SelectUnit(SELECT_TARGET_RANDOM, 0); - if(target) - Globule->AI()->AttackStart(target); - } - } - - void UpdateAI(const uint32 diff) - { - //Return since we have no target - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - //Earthquake_Timer - if(Earthquake_Timer < diff) - { - if(!Earthquake) - { - DoCast(m_creature->getVictim(), SPELL_EARTHQUAKE); - Earthquake = true; - Earthquake_Timer = 10000; - } - else - { - switch(rand()%2) - { - case 0: - DoPlaySoundToSet(m_creature, SOUND_SUMMON1); - DoYell(SAY_SUMMON1, LANG_UNIVERSAL, NULL); - break; - - case 1: - DoPlaySoundToSet(m_creature, SOUND_SUMMON2); - DoYell(SAY_SUMMON2, LANG_UNIVERSAL, NULL); - break; - } - - //north - SummonMurloc(486.10, -723.64, -7.14); - SummonMurloc(482.58, -723.78, -7.14); - SummonMurloc(479.38, -723.91, -7.14); - SummonMurloc(476.03, -723.86, -7.14); - SummonMurloc(472.69, -723.69, -7.14); - SummonMurloc(469.04, -723.63, -7.14); - - //south - SummonMurloc(311.63, -725.04, -13.15); - SummonMurloc(307.81, -725.34, -13.15); - SummonMurloc(303.91, -725.64, -13.06); - SummonMurloc(300.23, -726, -11.89); - SummonMurloc(296.82, -726.33, -10.82); - SummonMurloc(293.64, -726.64, -9.81); - - DoTextEmote(EMOTE_EARTHQUAKE, NULL); - - Earthquake = false; - Earthquake_Timer = 40000+rand()%5000; - } - }else Earthquake_Timer -= diff; - - //TidalWave_Timer - if(TidalWave_Timer < diff) - { - DoCast(m_creature->getVictim(), SPELL_TIDAL_WAVE); - TidalWave_Timer = 20000; - }else TidalWave_Timer -= diff; - - if(!Phase2) - { - //WateryGrave_Timer - if(WateryGrave_Timer < diff) - { - //Teleport 4 players under the waterfalls - Unit *target; - for(uint8 i = 0; i < 4; i++) - { - target = SelectUnit(SELECT_TARGET_RANDOM, 1); - if(target && (target->GetTypeId() == TYPEID_PLAYER) && !target->HasAura(SPELL_WATERY_GRAVE, 0) && target->IsWithinDistInMap(m_creature, 50)) - ApplyWateryGrave(target, i); - } - - switch(rand()%2) - { - case 0: - DoPlaySoundToSet(m_creature, SOUND_SUMMON_BUBL1); - DoYell(SAY_SUMMON_BUBL1, LANG_UNIVERSAL, NULL); - break; - - case 1: - DoPlaySoundToSet(m_creature, SOUND_SUMMON_BUBL2); - DoYell(SAY_SUMMON_BUBL2, LANG_UNIVERSAL, NULL); - break; - - case 2: - break; - } - - DoTextEmote(EMOTE_WATERY_GRAVE, NULL); - - WateryGrave_Timer = 30000; - }else WateryGrave_Timer -= diff; - - //Start Phase2 - if((m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < 25) - Phase2 = true; - } - else - { - //WateryGlobules_Timer - if(WateryGlobules_Timer < diff) - { - SummonWaterGlobule(WATERY_GRAVE_X1, WATERY_GRAVE_Y1, WATERY_GRAVE_Z1); - SummonWaterGlobule(WATERY_GRAVE_X2, WATERY_GRAVE_Y2, WATERY_GRAVE_Z2); - SummonWaterGlobule(WATERY_GRAVE_X3, WATERY_GRAVE_Y3, WATERY_GRAVE_Z3); - SummonWaterGlobule(WATERY_GRAVE_X4, WATERY_GRAVE_Y4, WATERY_GRAVE_Z4); - - DoTextEmote(EMOTE_WATERY_GLOBULES, NULL); - - WateryGlobules_Timer = 25000; - }else WateryGlobules_Timer -= diff; - } - - DoMeleeAttackIfReady(); - } -}; - -//Water Globule AI -struct MANGOS_DLL_DECL mob_water_globuleAI : public ScriptedAI -{ - mob_water_globuleAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 Check_Timer; - - void Reset() - { - Check_Timer = 1000; - - m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - m_creature->setFaction(14); - } - - void Aggro(Unit *who) {} - - void MoveInLineOfSight(Unit *who) - { - if (!who || m_creature->getVictim()) - return; - - if (who->isTargetableForAttack() && who->isInAccessablePlaceFor(m_creature) && m_creature->IsHostileTo(who)) - { - //no attack radius check - it attacks the first target that moves in his los - if(who->HasStealthAura()) - who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); - - DoStartAttackAndMovement(who); - } - } - - void UpdateAI(const uint32 diff) - { - //Return since we have no target - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - if(Check_Timer < diff) - { - if(m_creature->IsWithinDistInMap(m_creature->getVictim(), 5)) - { - uint32 damage = 4000+rand()%2000; - m_creature->DealDamage(m_creature->getVictim(), damage, NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_FROST, NULL, false); - - //despawn - m_creature->DealDamage(m_creature, m_creature->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); - } - Check_Timer = 500; - }else Check_Timer -= diff; - - //do NOT deal any melee damage to the target. - } -}; - -CreatureAI* GetAI_boss_morogrim_tidewalker(Creature *_Creature) -{ - return new boss_morogrim_tidewalkerAI (_Creature); -} -CreatureAI* GetAI_mob_water_globule(Creature *_Creature) -{ - return new mob_water_globuleAI (_Creature); -} - -void AddSC_boss_morogrim_tidewalker() -{ - Script *newscript; - - newscript = new Script; - newscript->Name="boss_morogrim_tidewalker"; - newscript->GetAI = GetAI_boss_morogrim_tidewalker; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="mob_water_globule"; - newscript->GetAI = GetAI_mob_water_globule; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +/* ScriptData +SDName: Boss_Morogrim_Tidewalker +SD%Complete: 90 +SDComment: Water globules don't explode properly +SDCategory: Coilfang Resevoir, Serpent Shrine Cavern +EndScriptData */ + +#include "precompiled.h" +#include "def_serpent_shrine.h" + +#define SPELL_TIDAL_WAVE 37730 +#define SPELL_WATERY_GRAVE 38049 +#define SPELL_EARTHQUAKE 37764 +#define SPELL_WATERY_GRAVE_EXPLOSION 37852 + +#define SAY_AGGRO "Flood of the deep, take you!" +#define SAY_SUMMON1 "By the Tides, kill them at once!" +#define SAY_SUMMON2 "Destroy them my subjects!" +#define SAY_SLAY1 "It is done!" +#define SAY_SLAY2 "Strugging only makes it worse." +#define SAY_SLAY3 "Only the strong survive." +#define SAY_SUMMON_BUBL1 "There is nowhere to hide!" +#define SAY_SUMMON_BUBL2 "Soon it will be finished!" +#define SAY_DEATH "Great... currents of... Ageon." + +#define SOUND_AGGRO 11321 +#define SOUND_SUMMON1 11322 +#define SOUND_SUMMON2 11323 +#define SOUND_SLAY1 11326 +#define SOUND_SLAY2 11327 +#define SOUND_SLAY3 11328 +#define SOUND_SUMMON_BUBL1 11324 +#define SOUND_SUMMON_BUBL2 11325 +#define SOUND_DEATH 11329 + +#define WATERY_GRAVE_X1 334.64 +#define WATERY_GRAVE_Y1 -728.89 +#define WATERY_GRAVE_Z1 -14.42 +#define WATERY_GRAVE_X2 365.51 +#define WATERY_GRAVE_Y2 -737.14 +#define WATERY_GRAVE_Z2 -14.44 +#define WATERY_GRAVE_X3 366.19 +#define WATERY_GRAVE_Y3 -709.59 +#define WATERY_GRAVE_Z3 -14.36 +#define WATERY_GRAVE_X4 372.93 +#define WATERY_GRAVE_Y4 -690.96 +#define WATERY_GRAVE_Z4 -14.44 + +#define EMOTE_WATERY_GRAVE "sends his enemies to their watery graves!" +#define EMOTE_EARTHQUAKE "The violent earthquake has alerted nearby murlocs!" +#define EMOTE_WATERY_GLOBULES "summons Watery Globules!" + +#define WATER_GLOBULE 21913 +#define TIDEWALKER_LURKER 21920 + +//Morogrim Tidewalker AI +struct MANGOS_DLL_DECL boss_morogrim_tidewalkerAI : public ScriptedAI +{ + boss_morogrim_tidewalkerAI(Creature *c) : ScriptedAI(c) + { + pInstance = ((ScriptedInstance*)c->GetInstanceData()); + Reset(); + } + + ScriptedInstance* pInstance; + + uint32 TidalWave_Timer; + uint32 WateryGrave_Timer; + uint32 Earthquake_Timer; + uint32 WateryGlobules_Timer; + + bool Earthquake; + bool Phase2; + + void Reset() + { + TidalWave_Timer = 10000; + WateryGrave_Timer = 30000; + Earthquake_Timer = 40000; + WateryGlobules_Timer = 0; + + Earthquake = false; + Phase2 = false; + + if(pInstance) + pInstance->SetData(DATA_MOROGRIMTIDEWALKEREVENT, NOT_STARTED); + } + + void StartEvent() + { + DoPlaySoundToSet(m_creature, SOUND_AGGRO); + DoYell(SAY_AGGRO, LANG_UNIVERSAL, NULL); + + if(pInstance) + pInstance->SetData(DATA_MOROGRIMTIDEWALKEREVENT, IN_PROGRESS); + } + + void KilledUnit(Unit *victim) + { + switch(rand()%3) + { + case 0: + DoPlaySoundToSet(m_creature, SOUND_SLAY1); + DoYell(SAY_SLAY1, LANG_UNIVERSAL, NULL); + break; + + case 1: + DoPlaySoundToSet(m_creature, SOUND_SLAY2); + DoYell(SAY_SLAY2, LANG_UNIVERSAL, NULL); + break; + + case 2: + DoPlaySoundToSet(m_creature, SOUND_SLAY3); + DoYell(SAY_SLAY3, LANG_UNIVERSAL, NULL); + break; + } + } + + void JustDied(Unit *victim) + { + DoPlaySoundToSet(m_creature, SOUND_DEATH); + DoYell(SAY_DEATH, LANG_UNIVERSAL, NULL); + + if(pInstance) + pInstance->SetData(DATA_MOROGRIMTIDEWALKEREVENT, NOT_STARTED); + } + + void Aggro(Unit *who) { StartEvent(); } + + void ApplyWateryGrave(Unit *player, uint8 pos) + { + float x, y, z; + + switch(pos) + { + case 0: + x = WATERY_GRAVE_X1; + y = WATERY_GRAVE_Y1; + z = WATERY_GRAVE_Z1; + break; + + case 1: + x = WATERY_GRAVE_X2; + y = WATERY_GRAVE_Y2; + z = WATERY_GRAVE_Z2; + break; + + case 2: + x = WATERY_GRAVE_X3; + y = WATERY_GRAVE_Y3; + z = WATERY_GRAVE_Z3; + break; + + case 3: + x = WATERY_GRAVE_X4; + y = WATERY_GRAVE_Y4; + z = WATERY_GRAVE_Z4; + break; + } + + DoTeleportPlayer(player, x, y, z+1, player->GetOrientation()); + DoCast(player, SPELL_WATERY_GRAVE); + } + + void SummonMurloc(float x, float y, float z) + { + Creature *Summoned; + + Summoned = m_creature->SummonCreature(TIDEWALKER_LURKER, x, y, z, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000); + if(Summoned) + { + Unit *target = NULL; + target = SelectUnit(SELECT_TARGET_RANDOM, 0); + if(target) + Summoned->AI()->AttackStart(target); + } + } + + void SummonWaterGlobule(float x, float y, float z) + { + Creature *Globule; + + Globule = m_creature->SummonCreature(WATER_GLOBULE, x, y, z, 0, TEMPSUMMON_TIMED_DESPAWN, 30000); //they despawn after 30 seconds + if(Globule) + { + Unit *target = NULL; + target = SelectUnit(SELECT_TARGET_RANDOM, 0); + if(target) + Globule->AI()->AttackStart(target); + } + } + + void UpdateAI(const uint32 diff) + { + //Return since we have no target + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + //Earthquake_Timer + if(Earthquake_Timer < diff) + { + if(!Earthquake) + { + DoCast(m_creature->getVictim(), SPELL_EARTHQUAKE); + Earthquake = true; + Earthquake_Timer = 10000; + } + else + { + switch(rand()%2) + { + case 0: + DoPlaySoundToSet(m_creature, SOUND_SUMMON1); + DoYell(SAY_SUMMON1, LANG_UNIVERSAL, NULL); + break; + + case 1: + DoPlaySoundToSet(m_creature, SOUND_SUMMON2); + DoYell(SAY_SUMMON2, LANG_UNIVERSAL, NULL); + break; + } + + //north + SummonMurloc(486.10, -723.64, -7.14); + SummonMurloc(482.58, -723.78, -7.14); + SummonMurloc(479.38, -723.91, -7.14); + SummonMurloc(476.03, -723.86, -7.14); + SummonMurloc(472.69, -723.69, -7.14); + SummonMurloc(469.04, -723.63, -7.14); + + //south + SummonMurloc(311.63, -725.04, -13.15); + SummonMurloc(307.81, -725.34, -13.15); + SummonMurloc(303.91, -725.64, -13.06); + SummonMurloc(300.23, -726, -11.89); + SummonMurloc(296.82, -726.33, -10.82); + SummonMurloc(293.64, -726.64, -9.81); + + DoTextEmote(EMOTE_EARTHQUAKE, NULL); + + Earthquake = false; + Earthquake_Timer = 40000+rand()%5000; + } + }else Earthquake_Timer -= diff; + + //TidalWave_Timer + if(TidalWave_Timer < diff) + { + DoCast(m_creature->getVictim(), SPELL_TIDAL_WAVE); + TidalWave_Timer = 20000; + }else TidalWave_Timer -= diff; + + if(!Phase2) + { + //WateryGrave_Timer + if(WateryGrave_Timer < diff) + { + //Teleport 4 players under the waterfalls + Unit *target; + for(uint8 i = 0; i < 4; i++) + { + target = SelectUnit(SELECT_TARGET_RANDOM, 1); + if(target && (target->GetTypeId() == TYPEID_PLAYER) && !target->HasAura(SPELL_WATERY_GRAVE, 0) && target->IsWithinDistInMap(m_creature, 50)) + ApplyWateryGrave(target, i); + } + + switch(rand()%2) + { + case 0: + DoPlaySoundToSet(m_creature, SOUND_SUMMON_BUBL1); + DoYell(SAY_SUMMON_BUBL1, LANG_UNIVERSAL, NULL); + break; + + case 1: + DoPlaySoundToSet(m_creature, SOUND_SUMMON_BUBL2); + DoYell(SAY_SUMMON_BUBL2, LANG_UNIVERSAL, NULL); + break; + + case 2: + break; + } + + DoTextEmote(EMOTE_WATERY_GRAVE, NULL); + + WateryGrave_Timer = 30000; + }else WateryGrave_Timer -= diff; + + //Start Phase2 + if((m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < 25) + Phase2 = true; + } + else + { + //WateryGlobules_Timer + if(WateryGlobules_Timer < diff) + { + SummonWaterGlobule(WATERY_GRAVE_X1, WATERY_GRAVE_Y1, WATERY_GRAVE_Z1); + SummonWaterGlobule(WATERY_GRAVE_X2, WATERY_GRAVE_Y2, WATERY_GRAVE_Z2); + SummonWaterGlobule(WATERY_GRAVE_X3, WATERY_GRAVE_Y3, WATERY_GRAVE_Z3); + SummonWaterGlobule(WATERY_GRAVE_X4, WATERY_GRAVE_Y4, WATERY_GRAVE_Z4); + + DoTextEmote(EMOTE_WATERY_GLOBULES, NULL); + + WateryGlobules_Timer = 25000; + }else WateryGlobules_Timer -= diff; + } + + DoMeleeAttackIfReady(); + } +}; + +//Water Globule AI +struct MANGOS_DLL_DECL mob_water_globuleAI : public ScriptedAI +{ + mob_water_globuleAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 Check_Timer; + + void Reset() + { + Check_Timer = 1000; + + m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + m_creature->setFaction(14); + } + + void Aggro(Unit *who) {} + + void MoveInLineOfSight(Unit *who) + { + if (!who || m_creature->getVictim()) + return; + + if (who->isTargetableForAttack() && who->isInAccessablePlaceFor(m_creature) && m_creature->IsHostileTo(who)) + { + //no attack radius check - it attacks the first target that moves in his los + if(who->HasStealthAura()) + who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); + + DoStartAttackAndMovement(who); + } + } + + void UpdateAI(const uint32 diff) + { + //Return since we have no target + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + if(Check_Timer < diff) + { + if(m_creature->IsWithinDistInMap(m_creature->getVictim(), 5)) + { + uint32 damage = 4000+rand()%2000; + m_creature->DealDamage(m_creature->getVictim(), damage, NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_FROST, NULL, false); + + //despawn + m_creature->DealDamage(m_creature, m_creature->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); + } + Check_Timer = 500; + }else Check_Timer -= diff; + + //do NOT deal any melee damage to the target. + } +}; + +CreatureAI* GetAI_boss_morogrim_tidewalker(Creature *_Creature) +{ + return new boss_morogrim_tidewalkerAI (_Creature); +} +CreatureAI* GetAI_mob_water_globule(Creature *_Creature) +{ + return new mob_water_globuleAI (_Creature); +} + +void AddSC_boss_morogrim_tidewalker() +{ + Script *newscript; + + newscript = new Script; + newscript->Name="boss_morogrim_tidewalker"; + newscript->GetAI = GetAI_boss_morogrim_tidewalker; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="mob_water_globule"; + newscript->GetAI = GetAI_mob_water_globule; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/def_serpent_shrine.h b/src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/def_serpent_shrine.h index 21d76d6854a..52b8a88ebc3 100644 --- a/src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/def_serpent_shrine.h +++ b/src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/def_serpent_shrine.h @@ -1,26 +1,26 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software licensed under GPL version 2 - * Please see the included DOCS/LICENSE.TXT for more information */ - -#ifndef DEF_SERPENT_SHRINE_H -#define DEF_SERPENT_SHRINE_H - -#define DATA_CANSTARTPHASE3 1 -#define DATA_CARIBDIS 2 -#define DATA_HYDROSSTHEUNSTABLEEVENT 3 -#define DATA_KARATHRESS 4 -#define DATA_KARATHRESSEVENT 5 -#define DATA_KARATHRESSEVENT_STARTER 6 -#define DATA_LADYVASHJ 7 -#define DATA_LADYVASHJEVENT 8 -#define DATA_LEOTHERASTHEBLINDEVENT 9 -#define DATA_MOROGRIMTIDEWALKEREVENT 10 -#define DATA_SHARKKIS 11 -#define DATA_SHIELDGENERATOR1 12 -#define DATA_SHIELDGENERATOR2 13 -#define DATA_SHIELDGENERATOR3 14 -#define DATA_SHIELDGENERATOR4 15 -#define DATA_THELURKERBELOWEVENT 16 -#define DATA_TIDALVESS 17 -#define DATA_FATHOMLORDKARATHRESSEVENT 18 -#endif +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software licensed under GPL version 2 + * Please see the included DOCS/LICENSE.TXT for more information */ + +#ifndef DEF_SERPENT_SHRINE_H +#define DEF_SERPENT_SHRINE_H + +#define DATA_CANSTARTPHASE3 1 +#define DATA_CARIBDIS 2 +#define DATA_HYDROSSTHEUNSTABLEEVENT 3 +#define DATA_KARATHRESS 4 +#define DATA_KARATHRESSEVENT 5 +#define DATA_KARATHRESSEVENT_STARTER 6 +#define DATA_LADYVASHJ 7 +#define DATA_LADYVASHJEVENT 8 +#define DATA_LEOTHERASTHEBLINDEVENT 9 +#define DATA_MOROGRIMTIDEWALKEREVENT 10 +#define DATA_SHARKKIS 11 +#define DATA_SHIELDGENERATOR1 12 +#define DATA_SHIELDGENERATOR2 13 +#define DATA_SHIELDGENERATOR3 14 +#define DATA_SHIELDGENERATOR4 15 +#define DATA_THELURKERBELOWEVENT 16 +#define DATA_TIDALVESS 17 +#define DATA_FATHOMLORDKARATHRESSEVENT 18 +#endif diff --git a/src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/instance_serpent_shrine.cpp b/src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/instance_serpent_shrine.cpp index d1a90449abf..4dcfbc9189d 100644 --- a/src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/instance_serpent_shrine.cpp +++ b/src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/instance_serpent_shrine.cpp @@ -1,227 +1,227 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Instance_Serpent_Shrine -SD%Complete: 0 -SDComment: VERIFY SCRIPT -SDCategory: Coilfang Resevoir, Serpent Shrine Cavern -EndScriptData */ - -#include "precompiled.h" -#include "def_serpent_shrine.h" - -#define ENCOUNTERS 6 - -/* Serpentshrine cavern encounters: -0 - Hydross The Unstable event -1 - Leotheras The Blind Event -2 - The Lurker Below Event -3 - Fathom-Lord Karathress Event -4 - Morogrim Tidewalker Event -5 - Lady Vashj Event -*/ - -struct MANGOS_DLL_DECL instance_serpentshrine_cavern : public ScriptedInstance -{ - instance_serpentshrine_cavern(Map *Map) : ScriptedInstance(Map) {Initialize();}; - - uint64 Sharkkis; - uint64 Tidalvess; - uint64 Caribdis; - uint64 LadyVashj; - uint64 Karathress; - uint64 KarathressEvent_Starter; - - bool ShieldGeneratorDeactivated[4]; - - bool Encounters[ENCOUNTERS]; - - void Initialize() - { - Sharkkis = 0; - Tidalvess = 0; - Caribdis = 0; - LadyVashj = 0; - Karathress = 0; - KarathressEvent_Starter = 0; - - ShieldGeneratorDeactivated[0] = false; - ShieldGeneratorDeactivated[1] = false; - ShieldGeneratorDeactivated[2] = false; - ShieldGeneratorDeactivated[3] = false; - - for(uint8 i = 0; i < ENCOUNTERS; i++) - Encounters[i] = false; - } - - bool IsEncounterInProgress() const - { - for(uint8 i = 0; i < ENCOUNTERS; i++) - if(Encounters[i]) return true; - - return false; - } - - void OnCreatureCreate(Creature *creature, uint32 creature_entry) - { - switch(creature_entry) - { - case 21212: LadyVashj = creature->GetGUID(); break; - case 21214: Karathress = creature->GetGUID(); break; - case 21966: Sharkkis = creature->GetGUID(); break; - case 21965: Tidalvess = creature->GetGUID(); break; - case 21964: Caribdis = creature->GetGUID(); break; - } - } - - void SetData64(uint32 type, uint64 data) - { - if(type == DATA_KARATHRESSEVENT_STARTER) - KarathressEvent_Starter = data; - } - - uint64 GetData64(uint32 identifier) - { - switch(identifier) - { - case DATA_SHARKKIS: - return Sharkkis; - case DATA_TIDALVESS: - return Tidalvess; - case DATA_CARIBDIS: - return Caribdis; - case DATA_LADYVASHJ: - return LadyVashj; - case DATA_KARATHRESS: - return Karathress; - case DATA_KARATHRESSEVENT_STARTER: - return KarathressEvent_Starter; - } - return 0; - } - - void SetData(uint32 type, uint32 data) - { - switch(type) - { - case DATA_HYDROSSTHEUNSTABLEEVENT: - Encounters[0] = (data) ? true : false; - break; - - case DATA_LEOTHERASTHEBLINDEVENT: - Encounters[1] = (data) ? true : false; - break; - - case DATA_THELURKERBELOWEVENT: - Encounters[2] = (data) ? true : false; - break; - - case DATA_KARATHRESSEVENT: - Encounters[3] = (data) ? true : false; - break; - - case DATA_MOROGRIMTIDEWALKEREVENT: - Encounters[4] = (data) ? true : false; - break; - //Lady Vashj - case DATA_LADYVASHJEVENT: - if(data == 0) - { - ShieldGeneratorDeactivated[0] = false; - ShieldGeneratorDeactivated[1] = false; - ShieldGeneratorDeactivated[2] = false; - ShieldGeneratorDeactivated[3] = false; - } - Encounters[5] = (data) ? true : false; - break; - - case DATA_SHIELDGENERATOR1: - ShieldGeneratorDeactivated[0] = (data) ? true : false; - break; - - case DATA_SHIELDGENERATOR2: - ShieldGeneratorDeactivated[1] = (data) ? true : false; - break; - - case DATA_SHIELDGENERATOR3: - ShieldGeneratorDeactivated[2] = (data) ? true : false; - break; - - case DATA_SHIELDGENERATOR4: - ShieldGeneratorDeactivated[3] = (data) ? true : false; - break; - } - } - - uint32 GetData(uint32 type) - { - switch(type) - { - case DATA_HYDROSSTHEUNSTABLEEVENT: - return Encounters[0]; - - case DATA_LEOTHERASTHEBLINDEVENT: - return Encounters[1]; - - case DATA_THELURKERBELOWEVENT: - return Encounters[2]; - - case DATA_KARATHRESSEVENT: - return Encounters[3]; - - case DATA_MOROGRIMTIDEWALKEREVENT: - return Encounters[4]; - - //Lady Vashj - case DATA_LADYVASHJEVENT: - return Encounters[5]; - - case DATA_SHIELDGENERATOR1: - return ShieldGeneratorDeactivated[0]; - - case DATA_SHIELDGENERATOR2: - return ShieldGeneratorDeactivated[1]; - - case DATA_SHIELDGENERATOR3: - return ShieldGeneratorDeactivated[2]; - - case DATA_SHIELDGENERATOR4: - return ShieldGeneratorDeactivated[3]; - - case DATA_CANSTARTPHASE3: - if(ShieldGeneratorDeactivated[0] && ShieldGeneratorDeactivated[1] && ShieldGeneratorDeactivated[2] && ShieldGeneratorDeactivated[3]) - return 1; - break; - } - - return 0; - } -}; - -InstanceData* GetInstanceData_instance_serpentshrine_cavern(Map* map) -{ - return new instance_serpentshrine_cavern(map); -} - -void AddSC_instance_serpentshrine_cavern() -{ - Script *newscript; - newscript = new Script; - newscript->Name = "instance_serpent_shrine"; - newscript->GetInstanceData = GetInstanceData_instance_serpentshrine_cavern; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Instance_Serpent_Shrine +SD%Complete: 0 +SDComment: VERIFY SCRIPT +SDCategory: Coilfang Resevoir, Serpent Shrine Cavern +EndScriptData */ + +#include "precompiled.h" +#include "def_serpent_shrine.h" + +#define ENCOUNTERS 6 + +/* Serpentshrine cavern encounters: +0 - Hydross The Unstable event +1 - Leotheras The Blind Event +2 - The Lurker Below Event +3 - Fathom-Lord Karathress Event +4 - Morogrim Tidewalker Event +5 - Lady Vashj Event +*/ + +struct MANGOS_DLL_DECL instance_serpentshrine_cavern : public ScriptedInstance +{ + instance_serpentshrine_cavern(Map *Map) : ScriptedInstance(Map) {Initialize();}; + + uint64 Sharkkis; + uint64 Tidalvess; + uint64 Caribdis; + uint64 LadyVashj; + uint64 Karathress; + uint64 KarathressEvent_Starter; + + bool ShieldGeneratorDeactivated[4]; + + bool Encounters[ENCOUNTERS]; + + void Initialize() + { + Sharkkis = 0; + Tidalvess = 0; + Caribdis = 0; + LadyVashj = 0; + Karathress = 0; + KarathressEvent_Starter = 0; + + ShieldGeneratorDeactivated[0] = false; + ShieldGeneratorDeactivated[1] = false; + ShieldGeneratorDeactivated[2] = false; + ShieldGeneratorDeactivated[3] = false; + + for(uint8 i = 0; i < ENCOUNTERS; i++) + Encounters[i] = false; + } + + bool IsEncounterInProgress() const + { + for(uint8 i = 0; i < ENCOUNTERS; i++) + if(Encounters[i]) return true; + + return false; + } + + void OnCreatureCreate(Creature *creature, uint32 creature_entry) + { + switch(creature_entry) + { + case 21212: LadyVashj = creature->GetGUID(); break; + case 21214: Karathress = creature->GetGUID(); break; + case 21966: Sharkkis = creature->GetGUID(); break; + case 21965: Tidalvess = creature->GetGUID(); break; + case 21964: Caribdis = creature->GetGUID(); break; + } + } + + void SetData64(uint32 type, uint64 data) + { + if(type == DATA_KARATHRESSEVENT_STARTER) + KarathressEvent_Starter = data; + } + + uint64 GetData64(uint32 identifier) + { + switch(identifier) + { + case DATA_SHARKKIS: + return Sharkkis; + case DATA_TIDALVESS: + return Tidalvess; + case DATA_CARIBDIS: + return Caribdis; + case DATA_LADYVASHJ: + return LadyVashj; + case DATA_KARATHRESS: + return Karathress; + case DATA_KARATHRESSEVENT_STARTER: + return KarathressEvent_Starter; + } + return 0; + } + + void SetData(uint32 type, uint32 data) + { + switch(type) + { + case DATA_HYDROSSTHEUNSTABLEEVENT: + Encounters[0] = (data) ? true : false; + break; + + case DATA_LEOTHERASTHEBLINDEVENT: + Encounters[1] = (data) ? true : false; + break; + + case DATA_THELURKERBELOWEVENT: + Encounters[2] = (data) ? true : false; + break; + + case DATA_KARATHRESSEVENT: + Encounters[3] = (data) ? true : false; + break; + + case DATA_MOROGRIMTIDEWALKEREVENT: + Encounters[4] = (data) ? true : false; + break; + //Lady Vashj + case DATA_LADYVASHJEVENT: + if(data == 0) + { + ShieldGeneratorDeactivated[0] = false; + ShieldGeneratorDeactivated[1] = false; + ShieldGeneratorDeactivated[2] = false; + ShieldGeneratorDeactivated[3] = false; + } + Encounters[5] = (data) ? true : false; + break; + + case DATA_SHIELDGENERATOR1: + ShieldGeneratorDeactivated[0] = (data) ? true : false; + break; + + case DATA_SHIELDGENERATOR2: + ShieldGeneratorDeactivated[1] = (data) ? true : false; + break; + + case DATA_SHIELDGENERATOR3: + ShieldGeneratorDeactivated[2] = (data) ? true : false; + break; + + case DATA_SHIELDGENERATOR4: + ShieldGeneratorDeactivated[3] = (data) ? true : false; + break; + } + } + + uint32 GetData(uint32 type) + { + switch(type) + { + case DATA_HYDROSSTHEUNSTABLEEVENT: + return Encounters[0]; + + case DATA_LEOTHERASTHEBLINDEVENT: + return Encounters[1]; + + case DATA_THELURKERBELOWEVENT: + return Encounters[2]; + + case DATA_KARATHRESSEVENT: + return Encounters[3]; + + case DATA_MOROGRIMTIDEWALKEREVENT: + return Encounters[4]; + + //Lady Vashj + case DATA_LADYVASHJEVENT: + return Encounters[5]; + + case DATA_SHIELDGENERATOR1: + return ShieldGeneratorDeactivated[0]; + + case DATA_SHIELDGENERATOR2: + return ShieldGeneratorDeactivated[1]; + + case DATA_SHIELDGENERATOR3: + return ShieldGeneratorDeactivated[2]; + + case DATA_SHIELDGENERATOR4: + return ShieldGeneratorDeactivated[3]; + + case DATA_CANSTARTPHASE3: + if(ShieldGeneratorDeactivated[0] && ShieldGeneratorDeactivated[1] && ShieldGeneratorDeactivated[2] && ShieldGeneratorDeactivated[3]) + return 1; + break; + } + + return 0; + } +}; + +InstanceData* GetInstanceData_instance_serpentshrine_cavern(Map* map) +{ + return new instance_serpentshrine_cavern(map); +} + +void AddSC_instance_serpentshrine_cavern() +{ + Script *newscript; + newscript = new Script; + newscript->Name = "instance_serpent_shrine"; + newscript->GetInstanceData = GetInstanceData_instance_serpentshrine_cavern; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/coilfang_resevoir/slave_pens/boss_rokmar.cpp b/src/bindings/scripts/scripts/zone/coilfang_resevoir/slave_pens/boss_rokmar.cpp index 7d0e9d72822..97a18c1e245 100644 --- a/src/bindings/scripts/scripts/zone/coilfang_resevoir/slave_pens/boss_rokmar.cpp +++ b/src/bindings/scripts/scripts/zone/coilfang_resevoir/slave_pens/boss_rokmar.cpp @@ -1,65 +1,65 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Rokmar -SD%Complete: 100 -SDComment: -SDCategory: Coilfang Resevoir, Slave Pens -EndScriptData */ - -#include "../../../creature/simple_ai.h" - -#define SPELL_WATTER_SPIT 40086 -#define SPELL_GRIEVOUS_WOUND 31956 -#define SPELL_ENSARING_MOSS 31948 - -CreatureAI* GetAI_boss_rokmar_the_crackler(Creature *_Creature) -{ - SimpleAI* ai = new SimpleAI (_Creature); - - //Watter Spit - ai->Spell[0].Enabled = true; - ai->Spell[0].Spell_Id = SPELL_WATTER_SPIT; - ai->Spell[0].Cooldown = 15000; - ai->Spell[0].First_Cast = 15000; - ai->Spell[0].Cast_Target_Type = CAST_HOSTILE_TARGET; - - //Grievous Wound - ai->Spell[1].Enabled = true; - ai->Spell[1].Spell_Id = SPELL_GRIEVOUS_WOUND; - ai->Spell[1].Cooldown = 25000; - ai->Spell[1].First_Cast = 15000; - ai->Spell[1].Cast_Target_Type = CAST_HOSTILE_TARGET; - - //Ensaring Moss - ai->Spell[2].Enabled = true; - ai->Spell[2].Spell_Id = SPELL_ENSARING_MOSS; - ai->Spell[2].Cooldown = 15000 + (rand()%10000); - ai->Spell[2].First_Cast = 25000; - ai->Spell[2].Cast_Target_Type = CAST_HOSTILE_TARGET; - - return ai; -} - -void AddSC_boss_rokmar_the_crackler() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_rokmar_the_crackler"; - newscript->GetAI = GetAI_boss_rokmar_the_crackler; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Rokmar +SD%Complete: 100 +SDComment: +SDCategory: Coilfang Resevoir, Slave Pens +EndScriptData */ + +#include "../../../creature/simple_ai.h" + +#define SPELL_WATTER_SPIT 40086 +#define SPELL_GRIEVOUS_WOUND 31956 +#define SPELL_ENSARING_MOSS 31948 + +CreatureAI* GetAI_boss_rokmar_the_crackler(Creature *_Creature) +{ + SimpleAI* ai = new SimpleAI (_Creature); + + //Watter Spit + ai->Spell[0].Enabled = true; + ai->Spell[0].Spell_Id = SPELL_WATTER_SPIT; + ai->Spell[0].Cooldown = 15000; + ai->Spell[0].First_Cast = 15000; + ai->Spell[0].Cast_Target_Type = CAST_HOSTILE_TARGET; + + //Grievous Wound + ai->Spell[1].Enabled = true; + ai->Spell[1].Spell_Id = SPELL_GRIEVOUS_WOUND; + ai->Spell[1].Cooldown = 25000; + ai->Spell[1].First_Cast = 15000; + ai->Spell[1].Cast_Target_Type = CAST_HOSTILE_TARGET; + + //Ensaring Moss + ai->Spell[2].Enabled = true; + ai->Spell[2].Spell_Id = SPELL_ENSARING_MOSS; + ai->Spell[2].Cooldown = 15000 + (rand()%10000); + ai->Spell[2].First_Cast = 25000; + ai->Spell[2].Cast_Target_Type = CAST_HOSTILE_TARGET; + + return ai; +} + +void AddSC_boss_rokmar_the_crackler() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_rokmar_the_crackler"; + newscript->GetAI = GetAI_boss_rokmar_the_crackler; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/coilfang_resevoir/steam_vault/boss_hydromancer_thespia.cpp b/src/bindings/scripts/scripts/zone/coilfang_resevoir/steam_vault/boss_hydromancer_thespia.cpp index 74fb09726c7..d1c02f0140a 100644 --- a/src/bindings/scripts/scripts/zone/coilfang_resevoir/steam_vault/boss_hydromancer_thespia.cpp +++ b/src/bindings/scripts/scripts/zone/coilfang_resevoir/steam_vault/boss_hydromancer_thespia.cpp @@ -1,223 +1,223 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Hydromancer_Thespia -SD%Complete: 80 -SDComment: Normal/heroic mode: to be tested. Needs additional adjustments (when instance script is adjusted) -SDCategory: Coilfang Resevoir, The Steamvault -EndScriptData */ - -/* ContentData -boss_hydromancer_thespia -mob_coilfang_waterelemental -EndContentData */ - -#include "precompiled.h" -#include "def_steam_vault.h" - -#define SAY_SUMMON "Surge forth my pets!" -#define SOUND_SUMMON 10360 - -#define SAY_AGGRO_1 "The depths will consume you!" -#define SOUND_AGGRO_1 10361 -#define SAY_AGGRO_2 "Meet your doom, surface dwellers!" -#define SOUND_AGGRO_2 10362 -#define SAY_AGGRO_3 "You will drown in blood!" -#define SOUND_AGGRO_3 10363 - -#define SAY_SLAY_1 "To the depths of oblivion with you!" -#define SOUND_SLAY_1 10364 -#define SAY_SLAY_2 "For my lady and master!" -#define SOUND_SLAY_2 10365 - -#define SAY_DEAD "Our matron will be.. the end of.. you.." -#define SOUND_DEAD 10366 - -#define SPELL_LIGHTNING_CLOUD 25033 -#define SPELL_LUNG_BURST 31481 -#define SPELL_ENVELOPING_WINDS 31718 - -struct MANGOS_DLL_DECL boss_thespiaAI : public ScriptedAI -{ - boss_thespiaAI(Creature *c) : ScriptedAI(c) - { - pInstance = ((ScriptedInstance*)c->GetInstanceData()); - Reset(); - } - - ScriptedInstance *pInstance; - bool HeroicMode; - - uint32 LightningCloud_Timer; - uint32 LungBurst_Timer; - uint32 EnvelopingWinds_Timer; - - void Reset() - { - HeroicMode = m_creature->GetMap()->IsHeroic(); - - LightningCloud_Timer = 28000; - LungBurst_Timer = 7000; - EnvelopingWinds_Timer = 9000; - - if( pInstance ) pInstance->SetData(TYPE_HYDROMANCER_THESPIA, NOT_STARTED); - } - - void JustDied(Unit* Killer) - { - DoYell(SAY_DEAD, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature,SOUND_DEAD); - - if( pInstance ) pInstance->SetData(TYPE_HYDROMANCER_THESPIA, DONE); - } - - void KilledUnit(Unit* victim) - { - switch(rand()%2) - { - case 0: - DoYell(SAY_SLAY_1, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature,SOUND_SLAY_1); - break; - case 1: - DoYell(SAY_SLAY_2, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature,SOUND_SLAY_2); - break; - } - } - - void Aggro(Unit *who) - { - switch(rand()%3) - { - case 0: - DoYell(SAY_AGGRO_1, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature,SOUND_AGGRO_1); - break; - case 1: - DoYell(SAY_AGGRO_2, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature,SOUND_AGGRO_2); - break; - case 2: - DoYell(SAY_AGGRO_3, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature,SOUND_AGGRO_3); - break; - } - - if( pInstance ) pInstance->SetData(TYPE_HYDROMANCER_THESPIA, IN_PROGRESS); - } - - void UpdateAI(const uint32 diff) - { - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - //LightningCloud_Timer - if( LightningCloud_Timer < diff ) - { - //cast twice in Heroic mode - if( Unit* target = SelectUnit(SELECT_TARGET_RANDOM,0) ) - DoCast(target, SPELL_LIGHTNING_CLOUD); - if( HeroicMode ) - if( Unit* target = SelectUnit(SELECT_TARGET_RANDOM,0) ) - DoCast(target, SPELL_LIGHTNING_CLOUD); - LightningCloud_Timer = 28000; - }else LightningCloud_Timer -=diff; - - //LungBurst_Timer - if( LungBurst_Timer < diff ) - { - if( Unit* target = SelectUnit(SELECT_TARGET_RANDOM,0) ) - DoCast(target, SPELL_LUNG_BURST); - LungBurst_Timer = 10000+rand()%5000; - }else LungBurst_Timer -=diff; - - //EnvelopingWinds_Timer - if( EnvelopingWinds_Timer < diff ) - { - //cast twice in Heroic mode - if( Unit* target = SelectUnit(SELECT_TARGET_RANDOM,0) ) - DoCast(target, SPELL_ENVELOPING_WINDS); - if( HeroicMode ) - if( Unit* target = SelectUnit(SELECT_TARGET_RANDOM,0) ) - DoCast(target, SPELL_ENVELOPING_WINDS); - EnvelopingWinds_Timer = 10000+rand()%5000; - }else EnvelopingWinds_Timer -=diff; - - DoMeleeAttackIfReady(); - } -}; - -#define SPELL_WATER_BOLT_VOLLEY 34449 -#define H_SPELL_WATER_BOLT_VOLLEY 37924 - -struct MANGOS_DLL_DECL mob_coilfang_waterelementalAI : public ScriptedAI -{ - mob_coilfang_waterelementalAI(Creature *c) : ScriptedAI(c) {Reset();} - - bool HeroicMode; - uint32 WaterBoltVolley_Timer; - - void Reset() - { - HeroicMode = m_creature->GetMap()->IsHeroic(); - WaterBoltVolley_Timer = 3000+rand()%3000; - } - - void Aggro(Unit *who) { } - - void UpdateAI(const uint32 diff) - { - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - if( WaterBoltVolley_Timer < diff ) - { - if( HeroicMode ) DoCast(m_creature,H_SPELL_WATER_BOLT_VOLLEY); - else DoCast(m_creature,SPELL_WATER_BOLT_VOLLEY); - - WaterBoltVolley_Timer = 10000+rand()%5000; - }else WaterBoltVolley_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; - -CreatureAI* GetAI_boss_thespiaAI(Creature *_Creature) -{ - return new boss_thespiaAI (_Creature); -} - -CreatureAI* GetAI_mob_coilfang_waterelementalAI(Creature *_Creature) -{ - return new mob_coilfang_waterelementalAI (_Creature); -} - -void AddSC_boss_hydromancer_thespia() -{ - Script *newscript; - - newscript = new Script; - newscript->Name="boss_hydromancer_thespia"; - newscript->GetAI = GetAI_boss_thespiaAI; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="mob_coilfang_waterelemental"; - newscript->GetAI = GetAI_mob_coilfang_waterelementalAI; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Hydromancer_Thespia +SD%Complete: 80 +SDComment: Normal/heroic mode: to be tested. Needs additional adjustments (when instance script is adjusted) +SDCategory: Coilfang Resevoir, The Steamvault +EndScriptData */ + +/* ContentData +boss_hydromancer_thespia +mob_coilfang_waterelemental +EndContentData */ + +#include "precompiled.h" +#include "def_steam_vault.h" + +#define SAY_SUMMON "Surge forth my pets!" +#define SOUND_SUMMON 10360 + +#define SAY_AGGRO_1 "The depths will consume you!" +#define SOUND_AGGRO_1 10361 +#define SAY_AGGRO_2 "Meet your doom, surface dwellers!" +#define SOUND_AGGRO_2 10362 +#define SAY_AGGRO_3 "You will drown in blood!" +#define SOUND_AGGRO_3 10363 + +#define SAY_SLAY_1 "To the depths of oblivion with you!" +#define SOUND_SLAY_1 10364 +#define SAY_SLAY_2 "For my lady and master!" +#define SOUND_SLAY_2 10365 + +#define SAY_DEAD "Our matron will be.. the end of.. you.." +#define SOUND_DEAD 10366 + +#define SPELL_LIGHTNING_CLOUD 25033 +#define SPELL_LUNG_BURST 31481 +#define SPELL_ENVELOPING_WINDS 31718 + +struct MANGOS_DLL_DECL boss_thespiaAI : public ScriptedAI +{ + boss_thespiaAI(Creature *c) : ScriptedAI(c) + { + pInstance = ((ScriptedInstance*)c->GetInstanceData()); + Reset(); + } + + ScriptedInstance *pInstance; + bool HeroicMode; + + uint32 LightningCloud_Timer; + uint32 LungBurst_Timer; + uint32 EnvelopingWinds_Timer; + + void Reset() + { + HeroicMode = m_creature->GetMap()->IsHeroic(); + + LightningCloud_Timer = 28000; + LungBurst_Timer = 7000; + EnvelopingWinds_Timer = 9000; + + if( pInstance ) pInstance->SetData(TYPE_HYDROMANCER_THESPIA, NOT_STARTED); + } + + void JustDied(Unit* Killer) + { + DoYell(SAY_DEAD, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature,SOUND_DEAD); + + if( pInstance ) pInstance->SetData(TYPE_HYDROMANCER_THESPIA, DONE); + } + + void KilledUnit(Unit* victim) + { + switch(rand()%2) + { + case 0: + DoYell(SAY_SLAY_1, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature,SOUND_SLAY_1); + break; + case 1: + DoYell(SAY_SLAY_2, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature,SOUND_SLAY_2); + break; + } + } + + void Aggro(Unit *who) + { + switch(rand()%3) + { + case 0: + DoYell(SAY_AGGRO_1, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature,SOUND_AGGRO_1); + break; + case 1: + DoYell(SAY_AGGRO_2, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature,SOUND_AGGRO_2); + break; + case 2: + DoYell(SAY_AGGRO_3, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature,SOUND_AGGRO_3); + break; + } + + if( pInstance ) pInstance->SetData(TYPE_HYDROMANCER_THESPIA, IN_PROGRESS); + } + + void UpdateAI(const uint32 diff) + { + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + //LightningCloud_Timer + if( LightningCloud_Timer < diff ) + { + //cast twice in Heroic mode + if( Unit* target = SelectUnit(SELECT_TARGET_RANDOM,0) ) + DoCast(target, SPELL_LIGHTNING_CLOUD); + if( HeroicMode ) + if( Unit* target = SelectUnit(SELECT_TARGET_RANDOM,0) ) + DoCast(target, SPELL_LIGHTNING_CLOUD); + LightningCloud_Timer = 28000; + }else LightningCloud_Timer -=diff; + + //LungBurst_Timer + if( LungBurst_Timer < diff ) + { + if( Unit* target = SelectUnit(SELECT_TARGET_RANDOM,0) ) + DoCast(target, SPELL_LUNG_BURST); + LungBurst_Timer = 10000+rand()%5000; + }else LungBurst_Timer -=diff; + + //EnvelopingWinds_Timer + if( EnvelopingWinds_Timer < diff ) + { + //cast twice in Heroic mode + if( Unit* target = SelectUnit(SELECT_TARGET_RANDOM,0) ) + DoCast(target, SPELL_ENVELOPING_WINDS); + if( HeroicMode ) + if( Unit* target = SelectUnit(SELECT_TARGET_RANDOM,0) ) + DoCast(target, SPELL_ENVELOPING_WINDS); + EnvelopingWinds_Timer = 10000+rand()%5000; + }else EnvelopingWinds_Timer -=diff; + + DoMeleeAttackIfReady(); + } +}; + +#define SPELL_WATER_BOLT_VOLLEY 34449 +#define H_SPELL_WATER_BOLT_VOLLEY 37924 + +struct MANGOS_DLL_DECL mob_coilfang_waterelementalAI : public ScriptedAI +{ + mob_coilfang_waterelementalAI(Creature *c) : ScriptedAI(c) {Reset();} + + bool HeroicMode; + uint32 WaterBoltVolley_Timer; + + void Reset() + { + HeroicMode = m_creature->GetMap()->IsHeroic(); + WaterBoltVolley_Timer = 3000+rand()%3000; + } + + void Aggro(Unit *who) { } + + void UpdateAI(const uint32 diff) + { + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + if( WaterBoltVolley_Timer < diff ) + { + if( HeroicMode ) DoCast(m_creature,H_SPELL_WATER_BOLT_VOLLEY); + else DoCast(m_creature,SPELL_WATER_BOLT_VOLLEY); + + WaterBoltVolley_Timer = 10000+rand()%5000; + }else WaterBoltVolley_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; + +CreatureAI* GetAI_boss_thespiaAI(Creature *_Creature) +{ + return new boss_thespiaAI (_Creature); +} + +CreatureAI* GetAI_mob_coilfang_waterelementalAI(Creature *_Creature) +{ + return new mob_coilfang_waterelementalAI (_Creature); +} + +void AddSC_boss_hydromancer_thespia() +{ + Script *newscript; + + newscript = new Script; + newscript->Name="boss_hydromancer_thespia"; + newscript->GetAI = GetAI_boss_thespiaAI; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="mob_coilfang_waterelemental"; + newscript->GetAI = GetAI_mob_coilfang_waterelementalAI; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/coilfang_resevoir/steam_vault/boss_mekgineer_steamrigger.cpp b/src/bindings/scripts/scripts/zone/coilfang_resevoir/steam_vault/boss_mekgineer_steamrigger.cpp index 83177d88fa2..c88da0f7e65 100644 --- a/src/bindings/scripts/scripts/zone/coilfang_resevoir/steam_vault/boss_mekgineer_steamrigger.cpp +++ b/src/bindings/scripts/scripts/zone/coilfang_resevoir/steam_vault/boss_mekgineer_steamrigger.cpp @@ -1,297 +1,297 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Mekgineer_Steamrigger -SD%Complete: 60 -SDComment: Mechanics' interrrupt heal doesn't work very well, also a proper movement needs to be implemented -> summon further away and move towards target to repair. -SDCategory: Coilfang Resevoir, The Steamvault -EndScriptData */ - -/* ContentData -boss_mekgineer_steamrigger -mob_steamrigger_mechanic -EndContentData */ - -#include "precompiled.h" -#include "def_steam_vault.h" - -#define SAY_MECHANICS "I'm bringin' the pain!" -#define SOUND_MECHANICS 10367 - -#define SAY_AGGRO_1 "You're in for a world of hurt!" -#define SOUND_AGGRO_1 10368 -#define SAY_AGGRO_2 "Eat hot metal, scumbag!" -#define SOUND_AGGRO_2 10369 -#define SAY_AGGRO_3 "I'll come over there!" -#define SOUND_AGGRO_3 10370 -#define SAY_AGGRO_4 "I'm bringin' the pain!" -#define SOUND_AGGRO_4 10371 - -#define SAY_SLAY_1 "You just got served, punk!" -#define SOUND_SLAY_1 10372 -#define SAY_SLAY_2 "I own you!" -#define SOUND_SLAY_2 10373 -#define SAY_SLAY_3 "Have fun dyin', cupcake!" -#define SOUND_SLAY_3 10374 - -#define SAY_DEATH "Mommy!" -#define SOUND_DEATH 10375 - -#define SPELL_SUPER_SHRINK_RAY 31485 -#define SPELL_SAW_BLADE 31486 -#define SPELL_ELECTRIFIED_NET 35107 -#define H_SPELL_ENRAGE 1 //corrent enrage spell not known - -#define ENTRY_STREAMRIGGER_MECHANIC 17951 - -struct MANGOS_DLL_DECL boss_mekgineer_steamriggerAI : public ScriptedAI -{ - boss_mekgineer_steamriggerAI(Creature *c) : ScriptedAI(c) - { - pInstance = ((ScriptedInstance*)c->GetInstanceData()); - Reset(); - } - - ScriptedInstance *pInstance; - - uint32 Shrink_Timer; - uint32 Saw_Blade_Timer; - uint32 Electrified_Net_Timer; - bool Summon75; - bool Summon50; - bool Summon25; - - void Reset() - { - Shrink_Timer = 20000; - Saw_Blade_Timer = 15000; - Electrified_Net_Timer = 10000; - - Summon75 = false; - Summon50 = false; - Summon25 = false; - - if( pInstance ) pInstance->SetData(TYPE_MEKGINEER_STEAMRIGGER, NOT_STARTED); - } - - void JustDied(Unit* Killer) - { - DoYell(SAY_DEATH, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature,SOUND_DEATH); - - if( pInstance ) pInstance->SetData(TYPE_MEKGINEER_STEAMRIGGER, DONE); - } - - void KilledUnit(Unit* victim) - { - switch(rand()%3) - { - case 0: - DoYell(SAY_SLAY_1, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature,SOUND_SLAY_1); - break; - case 1: - DoYell(SAY_SLAY_2, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature,SOUND_SLAY_2); - break; - case 2: - DoYell(SAY_SLAY_3, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature,SOUND_SLAY_3); - break; - } - } - - void Aggro(Unit *who) - { - switch(rand()%3) - { - case 0: - DoYell(SAY_AGGRO_1, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature,SOUND_AGGRO_1); - break; - case 1: - DoYell(SAY_AGGRO_2, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature,SOUND_AGGRO_2); - break; - case 2: - DoYell(SAY_AGGRO_3, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature,SOUND_AGGRO_3); - break; - } - - if( pInstance ) pInstance->SetData(TYPE_MEKGINEER_STEAMRIGGER, IN_PROGRESS); - } - - //no known summon spells exist - void SummonMechanichs() - { - DoYell(SAY_MECHANICS, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature,SOUND_MECHANICS); - - DoSpawnCreature(ENTRY_STREAMRIGGER_MECHANIC,5,5,0,0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 240000); - DoSpawnCreature(ENTRY_STREAMRIGGER_MECHANIC,-5,5,0,0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 240000); - DoSpawnCreature(ENTRY_STREAMRIGGER_MECHANIC,-5,-5,0,0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 240000); - - if( rand()%2 ) - DoSpawnCreature(ENTRY_STREAMRIGGER_MECHANIC,5,-7,0,0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 240000); - if( rand()%2 ) - DoSpawnCreature(ENTRY_STREAMRIGGER_MECHANIC,7,-5,0,0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 240000); - } - - void UpdateAI(const uint32 diff) - { - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - if( Shrink_Timer < diff ) - { - DoCast(m_creature->getVictim(),SPELL_SUPER_SHRINK_RAY); - Shrink_Timer = 20000; - }else Shrink_Timer -= diff; - - if( Saw_Blade_Timer < diff ) - { - if( Unit* target = SelectUnit(SELECT_TARGET_RANDOM,1) ) DoCast(target,SPELL_SAW_BLADE); - else DoCast(m_creature->getVictim(),SPELL_SAW_BLADE); - Saw_Blade_Timer = 15000; - } else Saw_Blade_Timer -= diff; - - if( Electrified_Net_Timer < diff ) - { - DoCast(m_creature->getVictim(),SPELL_ELECTRIFIED_NET); - Electrified_Net_Timer = 10000; - } - else Electrified_Net_Timer -= diff; - - if( !Summon75 ) - if( (m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < 75 ) - { - SummonMechanichs(); - Summon75 = true; - } - if( !Summon50 ) - if( (m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < 50 ) - { - SummonMechanichs(); - Summon50 = true; - } - if( !Summon25 ) - if( (m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < 25 ) - { - SummonMechanichs(); - Summon25 = true; - } - - DoMeleeAttackIfReady(); - } -}; - -CreatureAI* GetAI_boss_mekgineer_steamrigger(Creature *_Creature) -{ - return new boss_mekgineer_steamriggerAI (_Creature); -} - -#define SPELL_DISPEL_MAGIC 17201 -#define SPELL_REPAIR 31532 -#define H_SPELL_REPAIR 37936 - -#define MAX_REPAIR_RANGE (13.0f) //we should be at least at this range for repair -#define MIN_REPAIR_RANGE (7.0f) //we can stop movement at this range to repair but not required - -struct MANGOS_DLL_DECL mob_steamrigger_mechanicAI : public ScriptedAI -{ - mob_steamrigger_mechanicAI(Creature *c) : ScriptedAI(c) - { - pInstance = ((ScriptedInstance*)c->GetInstanceData()); - Reset(); - } - - ScriptedInstance* pInstance; - - uint32 Repair_Timer; - bool HeroicMode; - - void Reset() - { - HeroicMode = m_creature->GetMap()->IsHeroic(); - Repair_Timer = 2000; - } - - void MoveInLineOfSight(Unit* who) - { - //react only if attacked - return; - } - - void Aggro(Unit *who) { } - - void UpdateAI(const uint32 diff) - { - if( Repair_Timer < diff ) - { - if( pInstance && pInstance->GetData64(DATA_MEKGINEERSTEAMRIGGER) && pInstance->GetData(TYPE_MEKGINEER_STEAMRIGGER) == IN_PROGRESS) - { - if( Unit* pMekgineer = Unit::GetUnit((*m_creature), pInstance->GetData64(DATA_MEKGINEERSTEAMRIGGER)) ) - { - if( m_creature->IsWithinDistInMap(pMekgineer, MAX_REPAIR_RANGE) ) - { - //are we already channeling? Doesn't work very well, find better check? - if( !m_creature->GetUInt32Value(UNIT_CHANNEL_SPELL) ) - { - //m_creature->GetMotionMaster()->MovementExpired(); - //m_creature->GetMotionMaster()->MoveIdle(); - - if( HeroicMode ) DoCast(m_creature,H_SPELL_REPAIR,true); - else DoCast(m_creature,SPELL_REPAIR,true); - } - Repair_Timer = 5000; - } - else - { - //m_creature->GetMotionMaster()->MovementExpired(); - //m_creature->GetMotionMaster()->MoveFollow(pMekgineer,0,0); - } - } - }else Repair_Timer = 5000; - }else Repair_Timer -= diff; - - if( !m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - DoMeleeAttackIfReady(); - } -}; - -CreatureAI* GetAI_mob_steamrigger_mechanic(Creature *_Creature) -{ - return new mob_steamrigger_mechanicAI (_Creature); -} - -void AddSC_boss_mekgineer_steamrigger() -{ - Script *newscript; - - newscript = new Script; - newscript->Name="boss_mekgineer_steamrigger"; - newscript->GetAI = GetAI_boss_mekgineer_steamrigger; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="mob_steamrigger_mechanic"; - newscript->GetAI = GetAI_mob_steamrigger_mechanic; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Mekgineer_Steamrigger +SD%Complete: 60 +SDComment: Mechanics' interrrupt heal doesn't work very well, also a proper movement needs to be implemented -> summon further away and move towards target to repair. +SDCategory: Coilfang Resevoir, The Steamvault +EndScriptData */ + +/* ContentData +boss_mekgineer_steamrigger +mob_steamrigger_mechanic +EndContentData */ + +#include "precompiled.h" +#include "def_steam_vault.h" + +#define SAY_MECHANICS "I'm bringin' the pain!" +#define SOUND_MECHANICS 10367 + +#define SAY_AGGRO_1 "You're in for a world of hurt!" +#define SOUND_AGGRO_1 10368 +#define SAY_AGGRO_2 "Eat hot metal, scumbag!" +#define SOUND_AGGRO_2 10369 +#define SAY_AGGRO_3 "I'll come over there!" +#define SOUND_AGGRO_3 10370 +#define SAY_AGGRO_4 "I'm bringin' the pain!" +#define SOUND_AGGRO_4 10371 + +#define SAY_SLAY_1 "You just got served, punk!" +#define SOUND_SLAY_1 10372 +#define SAY_SLAY_2 "I own you!" +#define SOUND_SLAY_2 10373 +#define SAY_SLAY_3 "Have fun dyin', cupcake!" +#define SOUND_SLAY_3 10374 + +#define SAY_DEATH "Mommy!" +#define SOUND_DEATH 10375 + +#define SPELL_SUPER_SHRINK_RAY 31485 +#define SPELL_SAW_BLADE 31486 +#define SPELL_ELECTRIFIED_NET 35107 +#define H_SPELL_ENRAGE 1 //corrent enrage spell not known + +#define ENTRY_STREAMRIGGER_MECHANIC 17951 + +struct MANGOS_DLL_DECL boss_mekgineer_steamriggerAI : public ScriptedAI +{ + boss_mekgineer_steamriggerAI(Creature *c) : ScriptedAI(c) + { + pInstance = ((ScriptedInstance*)c->GetInstanceData()); + Reset(); + } + + ScriptedInstance *pInstance; + + uint32 Shrink_Timer; + uint32 Saw_Blade_Timer; + uint32 Electrified_Net_Timer; + bool Summon75; + bool Summon50; + bool Summon25; + + void Reset() + { + Shrink_Timer = 20000; + Saw_Blade_Timer = 15000; + Electrified_Net_Timer = 10000; + + Summon75 = false; + Summon50 = false; + Summon25 = false; + + if( pInstance ) pInstance->SetData(TYPE_MEKGINEER_STEAMRIGGER, NOT_STARTED); + } + + void JustDied(Unit* Killer) + { + DoYell(SAY_DEATH, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature,SOUND_DEATH); + + if( pInstance ) pInstance->SetData(TYPE_MEKGINEER_STEAMRIGGER, DONE); + } + + void KilledUnit(Unit* victim) + { + switch(rand()%3) + { + case 0: + DoYell(SAY_SLAY_1, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature,SOUND_SLAY_1); + break; + case 1: + DoYell(SAY_SLAY_2, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature,SOUND_SLAY_2); + break; + case 2: + DoYell(SAY_SLAY_3, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature,SOUND_SLAY_3); + break; + } + } + + void Aggro(Unit *who) + { + switch(rand()%3) + { + case 0: + DoYell(SAY_AGGRO_1, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature,SOUND_AGGRO_1); + break; + case 1: + DoYell(SAY_AGGRO_2, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature,SOUND_AGGRO_2); + break; + case 2: + DoYell(SAY_AGGRO_3, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature,SOUND_AGGRO_3); + break; + } + + if( pInstance ) pInstance->SetData(TYPE_MEKGINEER_STEAMRIGGER, IN_PROGRESS); + } + + //no known summon spells exist + void SummonMechanichs() + { + DoYell(SAY_MECHANICS, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature,SOUND_MECHANICS); + + DoSpawnCreature(ENTRY_STREAMRIGGER_MECHANIC,5,5,0,0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 240000); + DoSpawnCreature(ENTRY_STREAMRIGGER_MECHANIC,-5,5,0,0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 240000); + DoSpawnCreature(ENTRY_STREAMRIGGER_MECHANIC,-5,-5,0,0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 240000); + + if( rand()%2 ) + DoSpawnCreature(ENTRY_STREAMRIGGER_MECHANIC,5,-7,0,0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 240000); + if( rand()%2 ) + DoSpawnCreature(ENTRY_STREAMRIGGER_MECHANIC,7,-5,0,0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 240000); + } + + void UpdateAI(const uint32 diff) + { + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + if( Shrink_Timer < diff ) + { + DoCast(m_creature->getVictim(),SPELL_SUPER_SHRINK_RAY); + Shrink_Timer = 20000; + }else Shrink_Timer -= diff; + + if( Saw_Blade_Timer < diff ) + { + if( Unit* target = SelectUnit(SELECT_TARGET_RANDOM,1) ) DoCast(target,SPELL_SAW_BLADE); + else DoCast(m_creature->getVictim(),SPELL_SAW_BLADE); + Saw_Blade_Timer = 15000; + } else Saw_Blade_Timer -= diff; + + if( Electrified_Net_Timer < diff ) + { + DoCast(m_creature->getVictim(),SPELL_ELECTRIFIED_NET); + Electrified_Net_Timer = 10000; + } + else Electrified_Net_Timer -= diff; + + if( !Summon75 ) + if( (m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < 75 ) + { + SummonMechanichs(); + Summon75 = true; + } + if( !Summon50 ) + if( (m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < 50 ) + { + SummonMechanichs(); + Summon50 = true; + } + if( !Summon25 ) + if( (m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < 25 ) + { + SummonMechanichs(); + Summon25 = true; + } + + DoMeleeAttackIfReady(); + } +}; + +CreatureAI* GetAI_boss_mekgineer_steamrigger(Creature *_Creature) +{ + return new boss_mekgineer_steamriggerAI (_Creature); +} + +#define SPELL_DISPEL_MAGIC 17201 +#define SPELL_REPAIR 31532 +#define H_SPELL_REPAIR 37936 + +#define MAX_REPAIR_RANGE (13.0f) //we should be at least at this range for repair +#define MIN_REPAIR_RANGE (7.0f) //we can stop movement at this range to repair but not required + +struct MANGOS_DLL_DECL mob_steamrigger_mechanicAI : public ScriptedAI +{ + mob_steamrigger_mechanicAI(Creature *c) : ScriptedAI(c) + { + pInstance = ((ScriptedInstance*)c->GetInstanceData()); + Reset(); + } + + ScriptedInstance* pInstance; + + uint32 Repair_Timer; + bool HeroicMode; + + void Reset() + { + HeroicMode = m_creature->GetMap()->IsHeroic(); + Repair_Timer = 2000; + } + + void MoveInLineOfSight(Unit* who) + { + //react only if attacked + return; + } + + void Aggro(Unit *who) { } + + void UpdateAI(const uint32 diff) + { + if( Repair_Timer < diff ) + { + if( pInstance && pInstance->GetData64(DATA_MEKGINEERSTEAMRIGGER) && pInstance->GetData(TYPE_MEKGINEER_STEAMRIGGER) == IN_PROGRESS) + { + if( Unit* pMekgineer = Unit::GetUnit((*m_creature), pInstance->GetData64(DATA_MEKGINEERSTEAMRIGGER)) ) + { + if( m_creature->IsWithinDistInMap(pMekgineer, MAX_REPAIR_RANGE) ) + { + //are we already channeling? Doesn't work very well, find better check? + if( !m_creature->GetUInt32Value(UNIT_CHANNEL_SPELL) ) + { + //m_creature->GetMotionMaster()->MovementExpired(); + //m_creature->GetMotionMaster()->MoveIdle(); + + if( HeroicMode ) DoCast(m_creature,H_SPELL_REPAIR,true); + else DoCast(m_creature,SPELL_REPAIR,true); + } + Repair_Timer = 5000; + } + else + { + //m_creature->GetMotionMaster()->MovementExpired(); + //m_creature->GetMotionMaster()->MoveFollow(pMekgineer,0,0); + } + } + }else Repair_Timer = 5000; + }else Repair_Timer -= diff; + + if( !m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + DoMeleeAttackIfReady(); + } +}; + +CreatureAI* GetAI_mob_steamrigger_mechanic(Creature *_Creature) +{ + return new mob_steamrigger_mechanicAI (_Creature); +} + +void AddSC_boss_mekgineer_steamrigger() +{ + Script *newscript; + + newscript = new Script; + newscript->Name="boss_mekgineer_steamrigger"; + newscript->GetAI = GetAI_boss_mekgineer_steamrigger; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="mob_steamrigger_mechanic"; + newscript->GetAI = GetAI_mob_steamrigger_mechanic; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/coilfang_resevoir/steam_vault/boss_warlord_kalithresh.cpp b/src/bindings/scripts/scripts/zone/coilfang_resevoir/steam_vault/boss_warlord_kalithresh.cpp index 49172341514..c5987d6d11c 100644 --- a/src/bindings/scripts/scripts/zone/coilfang_resevoir/steam_vault/boss_warlord_kalithresh.cpp +++ b/src/bindings/scripts/scripts/zone/coilfang_resevoir/steam_vault/boss_warlord_kalithresh.cpp @@ -1,255 +1,255 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Warlord_Kalithres -SD%Complete: 65 -SDComment: Contains workarounds regarding warlord's rage spells not acting as expected. Both scripts here require review and fine tuning. -SDCategory: Coilfang Resevoir, The Steamvault -EndScriptData */ - -#include "precompiled.h" -#include "def_steam_vault.h" - -#define SAY_INTRO "You deem yourselves worthy simply because you bested my guards? Our work here will not be compromised!" -#define SOUND_INTRO 10390 - -#define SAY_REGEN "This is not nearly over..." -#define SOUND_REGEN 10391 - -#define SAY_AGGRO1 "Your head will roll!" -#define SOUND_AGGRO1 10392 -#define SAY_AGGRO2 "I despise all of your kind!" -#define SOUND_AGGRO2 10393 -#define SAY_AGGRO3 "Ba'ahntha sol'dorei!" -#define SOUND_AGGRO3 10394 - -#define SAY_SLAY1 "Scram, surface filth!" -#define SOUND_SLAY1 10395 -#define SAY_SLAY2 "Ah ha ha ha ha ha ha!" -#define SOUND_SLAY2 10396 - -#define SAY_DEATH "For her Excellency... for... Vashj!" -#define SOUND_DEATH 10397 - -#define SPELL_SPELL_REFLECTION 31534 -#define SPELL_IMPALE 39061 -#define SPELL_WARLORDS_RAGE 37081 -#define SPELL_WARLORDS_RAGE_NAGA 31543 - -#define SPELL_WARLORDS_RAGE_PROC 36453 - -struct MANGOS_DLL_DECL mob_naga_distillerAI : public ScriptedAI -{ - mob_naga_distillerAI(Creature *c) : ScriptedAI(c) - { - pInstance = ((ScriptedInstance*)c->GetInstanceData()); - Reset(); - } - - ScriptedInstance *pInstance; - - void Reset() - { - m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); - - //hack, due to really weird spell behaviour :( - if( pInstance ) - if( pInstance->GetData(TYPE_DISTILLER) == IN_PROGRESS ) - { - m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); - } - } - - void Aggro(Unit *who) { } - - void StartRageGen(Unit *caster) - { - m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); - DoCast(m_creature,SPELL_WARLORDS_RAGE_NAGA,true); - if( pInstance ) pInstance->SetData(TYPE_DISTILLER,IN_PROGRESS); - } - - void DamageTaken(Unit *done_by, uint32 &damage) - { - if( m_creature->GetHealth() <= damage ) - if( pInstance ) pInstance->SetData(TYPE_DISTILLER,DONE); - } -}; - -struct MANGOS_DLL_DECL boss_warlord_kalithreshAI : public ScriptedAI -{ - boss_warlord_kalithreshAI(Creature *c) : ScriptedAI(c) - { - pInstance = ((ScriptedInstance*)c->GetInstanceData()); - Reset(); - } - - ScriptedInstance *pInstance; - - uint32 Reflection_Timer; - uint32 Impale_Timer; - uint32 Rage_Timer; - bool CanRage; - - void Reset() - { - Reflection_Timer = 10000; - Impale_Timer = 30000; - Rage_Timer = 45000; - CanRage = false; - - if( pInstance ) pInstance->SetData(TYPE_WARLORD_KALITHRESH, NOT_STARTED); - } - - void Aggro(Unit *who) - { - switch(rand()%3) - { - case 0: - DoYell(SAY_AGGRO1, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature,SOUND_AGGRO1); - break; - case 1: - DoYell(SAY_AGGRO2, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature,SOUND_AGGRO2); - break; - case 2: - DoYell(SAY_AGGRO3, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature,SOUND_AGGRO3); - break; - } - - if( pInstance ) pInstance->SetData(TYPE_WARLORD_KALITHRESH, IN_PROGRESS); - } - - void KilledUnit(Unit* victim) - { - switch(rand()%2) - { - case 0: - DoYell(SAY_SLAY1, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(victim, SOUND_SLAY1); - break; - case 1: - DoYell(SAY_SLAY2, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(victim, SOUND_SLAY2); - break; - } - } - - Creature* SelectCreatureInGrid(uint32 entry, float range) - { - Creature* pCreature = NULL; - - CellPair pair(MaNGOS::ComputeCellPair(m_creature->GetPositionX(), m_creature->GetPositionY())); - Cell cell(pair); - cell.data.Part.reserved = ALL_DISTRICT; - cell.SetNoCreate(); - - MaNGOS::NearestCreatureEntryWithLiveStateInObjectRangeCheck creature_check(*m_creature, entry, true, range); - MaNGOS::CreatureLastSearcher searcher(pCreature, creature_check); - - TypeContainerVisitor, GridTypeMapContainer> creature_searcher(searcher); - - CellLock cell_lock(cell, pair); - cell_lock->Visit(cell_lock, creature_searcher,*(m_creature->GetMap())); - - return pCreature; - } - - void SpellHit(Unit *caster, const SpellEntry *spell) - { - //hack :( - if( spell->Id == SPELL_WARLORDS_RAGE_PROC ) - if( pInstance ) - if( pInstance->GetData(TYPE_DISTILLER) == DONE ) - m_creature->RemoveAurasDueToSpell(SPELL_WARLORDS_RAGE_PROC); - } - - void JustDied(Unit* Killer) - { - DoYell(SAY_DEATH, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_DEATH); - - if( pInstance ) pInstance->SetData(TYPE_WARLORD_KALITHRESH, DONE); - } - - void UpdateAI(const uint32 diff) - { - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - if( Rage_Timer < diff ) - { - Creature* distiller = SelectCreatureInGrid(17954, 100); - if( distiller ) - { - DoYell(SAY_REGEN, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature,SOUND_REGEN); - DoCast(m_creature,SPELL_WARLORDS_RAGE); - ((mob_naga_distillerAI*)distiller->AI())->StartRageGen(m_creature); - } - Rage_Timer = 45000; - }else Rage_Timer -= diff; - - //Reflection_Timer - if( Reflection_Timer < diff ) - { - DoCast(m_creature, SPELL_SPELL_REFLECTION); - Reflection_Timer = 20000+rand()%5000; - }else Reflection_Timer -= diff; - - //Impale_Timer - if( Impale_Timer < diff ) - { - if( Unit* target = SelectUnit(SELECT_TARGET_RANDOM,0) ) - DoCast(target,SPELL_IMPALE); - - Impale_Timer = 7500+rand()%5000; - }else Impale_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; - -CreatureAI* GetAI_mob_naga_distiller(Creature *_Creature) -{ - return new mob_naga_distillerAI (_Creature); -} - -CreatureAI* GetAI_boss_warlord_kalithresh(Creature *_Creature) -{ - return new boss_warlord_kalithreshAI (_Creature); -} - -void AddSC_boss_warlord_kalithresh() -{ - Script *newscript; - - newscript = new Script; - newscript->Name="mob_naga_distiller"; - newscript->GetAI = GetAI_mob_naga_distiller; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="boss_warlord_kalithresh"; - newscript->GetAI = GetAI_boss_warlord_kalithresh; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Warlord_Kalithres +SD%Complete: 65 +SDComment: Contains workarounds regarding warlord's rage spells not acting as expected. Both scripts here require review and fine tuning. +SDCategory: Coilfang Resevoir, The Steamvault +EndScriptData */ + +#include "precompiled.h" +#include "def_steam_vault.h" + +#define SAY_INTRO "You deem yourselves worthy simply because you bested my guards? Our work here will not be compromised!" +#define SOUND_INTRO 10390 + +#define SAY_REGEN "This is not nearly over..." +#define SOUND_REGEN 10391 + +#define SAY_AGGRO1 "Your head will roll!" +#define SOUND_AGGRO1 10392 +#define SAY_AGGRO2 "I despise all of your kind!" +#define SOUND_AGGRO2 10393 +#define SAY_AGGRO3 "Ba'ahntha sol'dorei!" +#define SOUND_AGGRO3 10394 + +#define SAY_SLAY1 "Scram, surface filth!" +#define SOUND_SLAY1 10395 +#define SAY_SLAY2 "Ah ha ha ha ha ha ha!" +#define SOUND_SLAY2 10396 + +#define SAY_DEATH "For her Excellency... for... Vashj!" +#define SOUND_DEATH 10397 + +#define SPELL_SPELL_REFLECTION 31534 +#define SPELL_IMPALE 39061 +#define SPELL_WARLORDS_RAGE 37081 +#define SPELL_WARLORDS_RAGE_NAGA 31543 + +#define SPELL_WARLORDS_RAGE_PROC 36453 + +struct MANGOS_DLL_DECL mob_naga_distillerAI : public ScriptedAI +{ + mob_naga_distillerAI(Creature *c) : ScriptedAI(c) + { + pInstance = ((ScriptedInstance*)c->GetInstanceData()); + Reset(); + } + + ScriptedInstance *pInstance; + + void Reset() + { + m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + + //hack, due to really weird spell behaviour :( + if( pInstance ) + if( pInstance->GetData(TYPE_DISTILLER) == IN_PROGRESS ) + { + m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + } + } + + void Aggro(Unit *who) { } + + void StartRageGen(Unit *caster) + { + m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + DoCast(m_creature,SPELL_WARLORDS_RAGE_NAGA,true); + if( pInstance ) pInstance->SetData(TYPE_DISTILLER,IN_PROGRESS); + } + + void DamageTaken(Unit *done_by, uint32 &damage) + { + if( m_creature->GetHealth() <= damage ) + if( pInstance ) pInstance->SetData(TYPE_DISTILLER,DONE); + } +}; + +struct MANGOS_DLL_DECL boss_warlord_kalithreshAI : public ScriptedAI +{ + boss_warlord_kalithreshAI(Creature *c) : ScriptedAI(c) + { + pInstance = ((ScriptedInstance*)c->GetInstanceData()); + Reset(); + } + + ScriptedInstance *pInstance; + + uint32 Reflection_Timer; + uint32 Impale_Timer; + uint32 Rage_Timer; + bool CanRage; + + void Reset() + { + Reflection_Timer = 10000; + Impale_Timer = 30000; + Rage_Timer = 45000; + CanRage = false; + + if( pInstance ) pInstance->SetData(TYPE_WARLORD_KALITHRESH, NOT_STARTED); + } + + void Aggro(Unit *who) + { + switch(rand()%3) + { + case 0: + DoYell(SAY_AGGRO1, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature,SOUND_AGGRO1); + break; + case 1: + DoYell(SAY_AGGRO2, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature,SOUND_AGGRO2); + break; + case 2: + DoYell(SAY_AGGRO3, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature,SOUND_AGGRO3); + break; + } + + if( pInstance ) pInstance->SetData(TYPE_WARLORD_KALITHRESH, IN_PROGRESS); + } + + void KilledUnit(Unit* victim) + { + switch(rand()%2) + { + case 0: + DoYell(SAY_SLAY1, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(victim, SOUND_SLAY1); + break; + case 1: + DoYell(SAY_SLAY2, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(victim, SOUND_SLAY2); + break; + } + } + + Creature* SelectCreatureInGrid(uint32 entry, float range) + { + Creature* pCreature = NULL; + + CellPair pair(MaNGOS::ComputeCellPair(m_creature->GetPositionX(), m_creature->GetPositionY())); + Cell cell(pair); + cell.data.Part.reserved = ALL_DISTRICT; + cell.SetNoCreate(); + + MaNGOS::NearestCreatureEntryWithLiveStateInObjectRangeCheck creature_check(*m_creature, entry, true, range); + MaNGOS::CreatureLastSearcher searcher(pCreature, creature_check); + + TypeContainerVisitor, GridTypeMapContainer> creature_searcher(searcher); + + CellLock cell_lock(cell, pair); + cell_lock->Visit(cell_lock, creature_searcher,*(m_creature->GetMap())); + + return pCreature; + } + + void SpellHit(Unit *caster, const SpellEntry *spell) + { + //hack :( + if( spell->Id == SPELL_WARLORDS_RAGE_PROC ) + if( pInstance ) + if( pInstance->GetData(TYPE_DISTILLER) == DONE ) + m_creature->RemoveAurasDueToSpell(SPELL_WARLORDS_RAGE_PROC); + } + + void JustDied(Unit* Killer) + { + DoYell(SAY_DEATH, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_DEATH); + + if( pInstance ) pInstance->SetData(TYPE_WARLORD_KALITHRESH, DONE); + } + + void UpdateAI(const uint32 diff) + { + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + if( Rage_Timer < diff ) + { + Creature* distiller = SelectCreatureInGrid(17954, 100); + if( distiller ) + { + DoYell(SAY_REGEN, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature,SOUND_REGEN); + DoCast(m_creature,SPELL_WARLORDS_RAGE); + ((mob_naga_distillerAI*)distiller->AI())->StartRageGen(m_creature); + } + Rage_Timer = 45000; + }else Rage_Timer -= diff; + + //Reflection_Timer + if( Reflection_Timer < diff ) + { + DoCast(m_creature, SPELL_SPELL_REFLECTION); + Reflection_Timer = 20000+rand()%5000; + }else Reflection_Timer -= diff; + + //Impale_Timer + if( Impale_Timer < diff ) + { + if( Unit* target = SelectUnit(SELECT_TARGET_RANDOM,0) ) + DoCast(target,SPELL_IMPALE); + + Impale_Timer = 7500+rand()%5000; + }else Impale_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; + +CreatureAI* GetAI_mob_naga_distiller(Creature *_Creature) +{ + return new mob_naga_distillerAI (_Creature); +} + +CreatureAI* GetAI_boss_warlord_kalithresh(Creature *_Creature) +{ + return new boss_warlord_kalithreshAI (_Creature); +} + +void AddSC_boss_warlord_kalithresh() +{ + Script *newscript; + + newscript = new Script; + newscript->Name="mob_naga_distiller"; + newscript->GetAI = GetAI_mob_naga_distiller; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="boss_warlord_kalithresh"; + newscript->GetAI = GetAI_boss_warlord_kalithresh; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/coilfang_resevoir/steam_vault/def_steam_vault.h b/src/bindings/scripts/scripts/zone/coilfang_resevoir/steam_vault/def_steam_vault.h index 0f8ae80fe2c..2841ed84fa5 100644 --- a/src/bindings/scripts/scripts/zone/coilfang_resevoir/steam_vault/def_steam_vault.h +++ b/src/bindings/scripts/scripts/zone/coilfang_resevoir/steam_vault/def_steam_vault.h @@ -1,16 +1,16 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software licensed under GPL version 2 - * Please see the included DOCS/LICENSE.TXT for more information */ - -#ifndef DEF_STEAM_VAULT_H -#define DEF_STEAM_VAULT_H - -#define TYPE_HYDROMANCER_THESPIA 1 -#define TYPE_MEKGINEER_STEAMRIGGER 2 -#define TYPE_WARLORD_KALITHRESH 3 -#define TYPE_DISTILLER 4 - -#define DATA_MEKGINEERSTEAMRIGGER 5 -#define DATA_KALITRESH 6 -#define DATA_THESPIA 7 -#endif +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software licensed under GPL version 2 + * Please see the included DOCS/LICENSE.TXT for more information */ + +#ifndef DEF_STEAM_VAULT_H +#define DEF_STEAM_VAULT_H + +#define TYPE_HYDROMANCER_THESPIA 1 +#define TYPE_MEKGINEER_STEAMRIGGER 2 +#define TYPE_WARLORD_KALITHRESH 3 +#define TYPE_DISTILLER 4 + +#define DATA_MEKGINEERSTEAMRIGGER 5 +#define DATA_KALITRESH 6 +#define DATA_THESPIA 7 +#endif diff --git a/src/bindings/scripts/scripts/zone/coilfang_resevoir/steam_vault/instance_steam_vault.cpp b/src/bindings/scripts/scripts/zone/coilfang_resevoir/steam_vault/instance_steam_vault.cpp index 0e524f3d4b8..cdb28a910ed 100644 --- a/src/bindings/scripts/scripts/zone/coilfang_resevoir/steam_vault/instance_steam_vault.cpp +++ b/src/bindings/scripts/scripts/zone/coilfang_resevoir/steam_vault/instance_steam_vault.cpp @@ -1,170 +1,170 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Instance_Steam_Vault -SD%Complete: 60 -SDComment: Workaround for opening of Main Chamber door. Mangos does not support scripting of Gameobject as this instance require. -SDCategory: Coilfang Resevoir, The Steamvault -EndScriptData */ - -#include "precompiled.h" -#include "def_steam_vault.h" - -#define ENCOUNTERS 4 - -#define MAIN_CHAMBERS_DOOR 183049 //door opened when hydromancer and mekgineer are died -#define ACCESS_PANEL_HYDRO 184125 -#define ACCESS_PANEL_MEK 184126 - -/* Steam Vaults encounters: -1 - Hydromancer Thespia Event -2 - Mekgineer Steamrigger Event -3 - Warlord Kalithresh Event -*/ - -struct MANGOS_DLL_DECL instance_steam_vault : public ScriptedInstance -{ - instance_steam_vault(Map *Map) : ScriptedInstance(Map) {Initialize();}; - - uint64 ThespiaGUID; - uint64 MekgineerGUID; - uint64 KalithreshGUID; - uint32 Encounter[ENCOUNTERS]; - - bool IsHydromancerDead, IsMekgineerDead; - GameObject *MainChambersDoor; - GameObject *AccessPanelHydro; - GameObject *AccessPanelMek; - - void Initialize() - { - ThespiaGUID = 0; - MekgineerGUID = 0; - KalithreshGUID = 0; - IsHydromancerDead = false; - IsMekgineerDead = false; - MainChambersDoor = NULL; - AccessPanelHydro = NULL; - AccessPanelMek = NULL; - - for(uint8 i = 0; i < ENCOUNTERS; i++) - Encounter[i] = false; - } - - bool IsEncounterInProgress() const - { - for(uint8 i = 0; i < ENCOUNTERS; i++) - if( Encounter[i] ) return true; - - return false; - } - - void OnCreatureCreate(Creature *creature, uint32 creature_entry) - { - switch(creature_entry) - { - case 17797: ThespiaGUID = creature->GetGUID(); break; - case 17796: MekgineerGUID = creature->GetGUID(); break; - case 17798: KalithreshGUID = creature->GetGUID(); break; - } - } - - void OnObjectCreate(GameObject *go) - { - switch(go->GetEntry()) - { - case MAIN_CHAMBERS_DOOR: MainChambersDoor = go; break; - case ACCESS_PANEL_HYDRO: AccessPanelHydro = go; break; - case ACCESS_PANEL_MEK: AccessPanelMek = go; break; - } - } - - void SetData(uint32 type, uint32 data) - { - switch(type) - { - case TYPE_HYDROMANCER_THESPIA: - if(data == DONE) - { - IsHydromancerDead = true; - if( IsMekgineerDead && MainChambersDoor ) - MainChambersDoor->SetGoState(0); - } - Encounter[0] = data; - break; - case TYPE_MEKGINEER_STEAMRIGGER: - if(data == DONE) - { - IsMekgineerDead = true; - if( IsHydromancerDead && MainChambersDoor ) - MainChambersDoor->SetGoState(0); - } - Encounter[1] = data; - break; - case TYPE_WARLORD_KALITHRESH: - Encounter[2] = data; - break; - case TYPE_DISTILLER: - Encounter[3] = data; - break; - } - } - - uint32 GetData(uint32 type) - { - switch(type) - { - case TYPE_HYDROMANCER_THESPIA: - return Encounter[0]; - case TYPE_MEKGINEER_STEAMRIGGER: - return Encounter[1]; - case TYPE_WARLORD_KALITHRESH: - return Encounter[2]; - case TYPE_DISTILLER: - return Encounter[3]; - } - return 0; - } - - uint64 GetData64(uint32 data) - { - switch(data) - { - case DATA_THESPIA: - return ThespiaGUID; - case DATA_MEKGINEERSTEAMRIGGER: - return MekgineerGUID; - case DATA_KALITRESH: - return KalithreshGUID; - } - return 0; - } -}; - -InstanceData* GetInstanceData_instance_steam_vault(Map* map) -{ - return new instance_steam_vault(map); -} - -void AddSC_instance_steam_vault() -{ - Script *newscript; - newscript = new Script; - newscript->Name = "instance_steam_vault"; - newscript->GetInstanceData = GetInstanceData_instance_steam_vault; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Instance_Steam_Vault +SD%Complete: 60 +SDComment: Workaround for opening of Main Chamber door. Mangos does not support scripting of Gameobject as this instance require. +SDCategory: Coilfang Resevoir, The Steamvault +EndScriptData */ + +#include "precompiled.h" +#include "def_steam_vault.h" + +#define ENCOUNTERS 4 + +#define MAIN_CHAMBERS_DOOR 183049 //door opened when hydromancer and mekgineer are died +#define ACCESS_PANEL_HYDRO 184125 +#define ACCESS_PANEL_MEK 184126 + +/* Steam Vaults encounters: +1 - Hydromancer Thespia Event +2 - Mekgineer Steamrigger Event +3 - Warlord Kalithresh Event +*/ + +struct MANGOS_DLL_DECL instance_steam_vault : public ScriptedInstance +{ + instance_steam_vault(Map *Map) : ScriptedInstance(Map) {Initialize();}; + + uint64 ThespiaGUID; + uint64 MekgineerGUID; + uint64 KalithreshGUID; + uint32 Encounter[ENCOUNTERS]; + + bool IsHydromancerDead, IsMekgineerDead; + GameObject *MainChambersDoor; + GameObject *AccessPanelHydro; + GameObject *AccessPanelMek; + + void Initialize() + { + ThespiaGUID = 0; + MekgineerGUID = 0; + KalithreshGUID = 0; + IsHydromancerDead = false; + IsMekgineerDead = false; + MainChambersDoor = NULL; + AccessPanelHydro = NULL; + AccessPanelMek = NULL; + + for(uint8 i = 0; i < ENCOUNTERS; i++) + Encounter[i] = false; + } + + bool IsEncounterInProgress() const + { + for(uint8 i = 0; i < ENCOUNTERS; i++) + if( Encounter[i] ) return true; + + return false; + } + + void OnCreatureCreate(Creature *creature, uint32 creature_entry) + { + switch(creature_entry) + { + case 17797: ThespiaGUID = creature->GetGUID(); break; + case 17796: MekgineerGUID = creature->GetGUID(); break; + case 17798: KalithreshGUID = creature->GetGUID(); break; + } + } + + void OnObjectCreate(GameObject *go) + { + switch(go->GetEntry()) + { + case MAIN_CHAMBERS_DOOR: MainChambersDoor = go; break; + case ACCESS_PANEL_HYDRO: AccessPanelHydro = go; break; + case ACCESS_PANEL_MEK: AccessPanelMek = go; break; + } + } + + void SetData(uint32 type, uint32 data) + { + switch(type) + { + case TYPE_HYDROMANCER_THESPIA: + if(data == DONE) + { + IsHydromancerDead = true; + if( IsMekgineerDead && MainChambersDoor ) + MainChambersDoor->SetGoState(0); + } + Encounter[0] = data; + break; + case TYPE_MEKGINEER_STEAMRIGGER: + if(data == DONE) + { + IsMekgineerDead = true; + if( IsHydromancerDead && MainChambersDoor ) + MainChambersDoor->SetGoState(0); + } + Encounter[1] = data; + break; + case TYPE_WARLORD_KALITHRESH: + Encounter[2] = data; + break; + case TYPE_DISTILLER: + Encounter[3] = data; + break; + } + } + + uint32 GetData(uint32 type) + { + switch(type) + { + case TYPE_HYDROMANCER_THESPIA: + return Encounter[0]; + case TYPE_MEKGINEER_STEAMRIGGER: + return Encounter[1]; + case TYPE_WARLORD_KALITHRESH: + return Encounter[2]; + case TYPE_DISTILLER: + return Encounter[3]; + } + return 0; + } + + uint64 GetData64(uint32 data) + { + switch(data) + { + case DATA_THESPIA: + return ThespiaGUID; + case DATA_MEKGINEERSTEAMRIGGER: + return MekgineerGUID; + case DATA_KALITRESH: + return KalithreshGUID; + } + return 0; + } +}; + +InstanceData* GetInstanceData_instance_steam_vault(Map* map) +{ + return new instance_steam_vault(map); +} + +void AddSC_instance_steam_vault() +{ + Script *newscript; + newscript = new Script; + newscript->Name = "instance_steam_vault"; + newscript->GetInstanceData = GetInstanceData_instance_steam_vault; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/coilfang_resevoir/underbog/boss_ghazan.cpp b/src/bindings/scripts/scripts/zone/coilfang_resevoir/underbog/boss_ghazan.cpp index 6bb2635fa7b..81ca43b26f3 100644 --- a/src/bindings/scripts/scripts/zone/coilfang_resevoir/underbog/boss_ghazan.cpp +++ b/src/bindings/scripts/scripts/zone/coilfang_resevoir/underbog/boss_ghazan.cpp @@ -1,78 +1,78 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Ghazan -SD%Complete: 100 -SDComment: -SDCategory: Coilfang Resevoir, Underbog -EndScriptData */ - -#include "../../../creature/simple_ai.h" - -/* ---== Ghaz'an ==-- -*Acid Spit - 34290; timer: 8sec -*Enrage - 20% hp; 40683 -*Tail Sweep - 34267; timer: ~10sec -*Acid Breath - 34268; timer: 5sec -*/ - -CreatureAI* GetAI_boss_ghazan(Creature *_Creature) -{ - SimpleAI* ai = new SimpleAI (_Creature); - - // Acid Spit - 34290; timer: 8sec - ai->Spell[0].Enabled = true; - ai->Spell[0].Spell_Id = 34290; - ai->Spell[0].Cooldown = 8000; - ai->Spell[0].First_Cast = 8000; - ai->Spell[0].Cast_Target_Type = CAST_SELF; - - // Acid Breath - 34268; timer: 5sec - ai->Spell[1].Enabled = true; - ai->Spell[1].Spell_Id = 34268; - ai->Spell[1].Cooldown = 5000; - ai->Spell[1].First_Cast = 5000; - ai->Spell[1].Cast_Target_Type = CAST_SELF; - - // Tail Sweep - 34267 - ai->Spell[2].Enabled = true; - ai->Spell[2].Spell_Id = 34267; - ai->Spell[2].Cooldown = 10000; - ai->Spell[2].First_Cast = 10000; - ai->Spell[2].Cast_Target_Type = CAST_SELF; - - // Enrage - 20% hp; 40683 - ai->Spell[3].Enabled = true; - ai->Spell[3].Spell_Id = 40683; - ai->Spell[3].Cooldown = -1; - ai->Spell[3].First_Cast = -80; - ai->Spell[3].Cast_Target_Type = CAST_SELF; - - ai->EnterEvadeMode(); - - return ai; -} - -void AddSC_boss_ghazan() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_ghazan"; - newscript->GetAI = GetAI_boss_ghazan; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Ghazan +SD%Complete: 100 +SDComment: +SDCategory: Coilfang Resevoir, Underbog +EndScriptData */ + +#include "../../../creature/simple_ai.h" + +/* +--== Ghaz'an ==-- +*Acid Spit - 34290; timer: 8sec +*Enrage - 20% hp; 40683 +*Tail Sweep - 34267; timer: ~10sec +*Acid Breath - 34268; timer: 5sec +*/ + +CreatureAI* GetAI_boss_ghazan(Creature *_Creature) +{ + SimpleAI* ai = new SimpleAI (_Creature); + + // Acid Spit - 34290; timer: 8sec + ai->Spell[0].Enabled = true; + ai->Spell[0].Spell_Id = 34290; + ai->Spell[0].Cooldown = 8000; + ai->Spell[0].First_Cast = 8000; + ai->Spell[0].Cast_Target_Type = CAST_SELF; + + // Acid Breath - 34268; timer: 5sec + ai->Spell[1].Enabled = true; + ai->Spell[1].Spell_Id = 34268; + ai->Spell[1].Cooldown = 5000; + ai->Spell[1].First_Cast = 5000; + ai->Spell[1].Cast_Target_Type = CAST_SELF; + + // Tail Sweep - 34267 + ai->Spell[2].Enabled = true; + ai->Spell[2].Spell_Id = 34267; + ai->Spell[2].Cooldown = 10000; + ai->Spell[2].First_Cast = 10000; + ai->Spell[2].Cast_Target_Type = CAST_SELF; + + // Enrage - 20% hp; 40683 + ai->Spell[3].Enabled = true; + ai->Spell[3].Spell_Id = 40683; + ai->Spell[3].Cooldown = -1; + ai->Spell[3].First_Cast = -80; + ai->Spell[3].Cast_Target_Type = CAST_SELF; + + ai->EnterEvadeMode(); + + return ai; +} + +void AddSC_boss_ghazan() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_ghazan"; + newscript->GetAI = GetAI_boss_ghazan; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/coilfang_resevoir/underbog/boss_hungarfen.cpp b/src/bindings/scripts/scripts/zone/coilfang_resevoir/underbog/boss_hungarfen.cpp index 663db35a946..d55fbcd2652 100644 --- a/src/bindings/scripts/scripts/zone/coilfang_resevoir/underbog/boss_hungarfen.cpp +++ b/src/bindings/scripts/scripts/zone/coilfang_resevoir/underbog/boss_hungarfen.cpp @@ -1,156 +1,156 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Hungarfen -SD%Complete: 95 -SDComment: Need confirmation if spell data are same in both modes. Summons should have faster rate in heroic -SDCategory: Coilfang Resevoir, Underbog -EndScriptData */ - -#include "precompiled.h" - -#define SPELL_FOUL_SPORES 31673 -#define SPELL_ACID_GEYSER 38739 - -struct MANGOS_DLL_DECL boss_hungarfenAI : public ScriptedAI -{ - boss_hungarfenAI(Creature *c) : ScriptedAI(c) - { - HeroicMode = m_creature->GetMap()->IsHeroic(); - Reset(); - } - - bool HeroicMode; - bool Root; - uint32 Mushroom_Timer; - uint32 AcidGeyser_Timer; - - void Reset() - { - Root = false; - Mushroom_Timer = 5000; // 1 mushroom after 5s, then one per 10s. This should be different in heroic mode - AcidGeyser_Timer = 10000; - } - - void Aggro(Unit *who) - { - } - - void UpdateAI(const uint32 diff) - { - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - if( (m_creature->GetHealth()*100) / m_creature->GetMaxHealth() <= 20 ) - { - if( !Root ) - { - DoCast(m_creature,SPELL_FOUL_SPORES); - Root = true; - } - } - - if( Mushroom_Timer < diff ) - { - if( Unit *target = SelectUnit(SELECT_TARGET_RANDOM,0) ) - m_creature->SummonCreature(17990, target->GetPositionX()+(rand()%8), target->GetPositionY()+(rand()%8), target->GetPositionZ(), (rand()%5), TEMPSUMMON_TIMED_DESPAWN, 22000); - else - m_creature->SummonCreature(17990, m_creature->GetPositionX()+(rand()%8), m_creature->GetPositionY()+(rand()%8), m_creature->GetPositionZ(), (rand()%5), TEMPSUMMON_TIMED_DESPAWN, 22000); - - Mushroom_Timer = 10000; - }else Mushroom_Timer -= diff; - - if( AcidGeyser_Timer < diff ) - { - if( Unit *target = SelectUnit(SELECT_TARGET_RANDOM,0) ) - DoCast(target,SPELL_ACID_GEYSER); - AcidGeyser_Timer = 10000+rand()%7500; - }else AcidGeyser_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; -CreatureAI* GetAI_boss_hungarfen(Creature *_Creature) -{ - return new boss_hungarfenAI (_Creature); -} - -#define SPELL_SPORE_CLOUD 34168 -#define SPELL_PUTRID_MUSHROOM 31690 -#define SPELL_GROW 31698 - -struct MANGOS_DLL_DECL mob_underbog_mushroomAI : public ScriptedAI -{ - mob_underbog_mushroomAI(Creature *c) : ScriptedAI(c) { Reset(); } - - bool Stop; - uint32 Grow_Timer; - uint32 Shrink_Timer; - - void Reset() - { - Stop = false; - Grow_Timer = 0; - Shrink_Timer = 20000; - - DoCast(m_creature,SPELL_PUTRID_MUSHROOM,true); - DoCast(m_creature,SPELL_SPORE_CLOUD,true); - } - - void MoveInLineOfSight(Unit *who) { return; } - - void AttackStart(Unit* who) { return; } - - void Aggro(Unit* who) { } - - void UpdateAI(const uint32 diff) - { - if( Stop ) - return; - - if( Grow_Timer <= diff ) - { - DoCast(m_creature,SPELL_GROW); - Grow_Timer = 3000; - }else Grow_Timer -= diff; - - if( Shrink_Timer <= diff ) - { - m_creature->RemoveAurasDueToSpell(SPELL_GROW); - Stop = true; - }else Shrink_Timer -= diff; - } -}; -CreatureAI* GetAI_mob_underbog_mushroom(Creature *_Creature) -{ - return new mob_underbog_mushroomAI (_Creature); -} - -void AddSC_boss_hungarfen() -{ - Script *newscript; - - newscript = new Script; - newscript->Name="boss_hungarfen"; - newscript->GetAI = GetAI_boss_hungarfen; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="mob_underbog_mushroom"; - newscript->GetAI = GetAI_mob_underbog_mushroom; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Hungarfen +SD%Complete: 95 +SDComment: Need confirmation if spell data are same in both modes. Summons should have faster rate in heroic +SDCategory: Coilfang Resevoir, Underbog +EndScriptData */ + +#include "precompiled.h" + +#define SPELL_FOUL_SPORES 31673 +#define SPELL_ACID_GEYSER 38739 + +struct MANGOS_DLL_DECL boss_hungarfenAI : public ScriptedAI +{ + boss_hungarfenAI(Creature *c) : ScriptedAI(c) + { + HeroicMode = m_creature->GetMap()->IsHeroic(); + Reset(); + } + + bool HeroicMode; + bool Root; + uint32 Mushroom_Timer; + uint32 AcidGeyser_Timer; + + void Reset() + { + Root = false; + Mushroom_Timer = 5000; // 1 mushroom after 5s, then one per 10s. This should be different in heroic mode + AcidGeyser_Timer = 10000; + } + + void Aggro(Unit *who) + { + } + + void UpdateAI(const uint32 diff) + { + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + if( (m_creature->GetHealth()*100) / m_creature->GetMaxHealth() <= 20 ) + { + if( !Root ) + { + DoCast(m_creature,SPELL_FOUL_SPORES); + Root = true; + } + } + + if( Mushroom_Timer < diff ) + { + if( Unit *target = SelectUnit(SELECT_TARGET_RANDOM,0) ) + m_creature->SummonCreature(17990, target->GetPositionX()+(rand()%8), target->GetPositionY()+(rand()%8), target->GetPositionZ(), (rand()%5), TEMPSUMMON_TIMED_DESPAWN, 22000); + else + m_creature->SummonCreature(17990, m_creature->GetPositionX()+(rand()%8), m_creature->GetPositionY()+(rand()%8), m_creature->GetPositionZ(), (rand()%5), TEMPSUMMON_TIMED_DESPAWN, 22000); + + Mushroom_Timer = 10000; + }else Mushroom_Timer -= diff; + + if( AcidGeyser_Timer < diff ) + { + if( Unit *target = SelectUnit(SELECT_TARGET_RANDOM,0) ) + DoCast(target,SPELL_ACID_GEYSER); + AcidGeyser_Timer = 10000+rand()%7500; + }else AcidGeyser_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; +CreatureAI* GetAI_boss_hungarfen(Creature *_Creature) +{ + return new boss_hungarfenAI (_Creature); +} + +#define SPELL_SPORE_CLOUD 34168 +#define SPELL_PUTRID_MUSHROOM 31690 +#define SPELL_GROW 31698 + +struct MANGOS_DLL_DECL mob_underbog_mushroomAI : public ScriptedAI +{ + mob_underbog_mushroomAI(Creature *c) : ScriptedAI(c) { Reset(); } + + bool Stop; + uint32 Grow_Timer; + uint32 Shrink_Timer; + + void Reset() + { + Stop = false; + Grow_Timer = 0; + Shrink_Timer = 20000; + + DoCast(m_creature,SPELL_PUTRID_MUSHROOM,true); + DoCast(m_creature,SPELL_SPORE_CLOUD,true); + } + + void MoveInLineOfSight(Unit *who) { return; } + + void AttackStart(Unit* who) { return; } + + void Aggro(Unit* who) { } + + void UpdateAI(const uint32 diff) + { + if( Stop ) + return; + + if( Grow_Timer <= diff ) + { + DoCast(m_creature,SPELL_GROW); + Grow_Timer = 3000; + }else Grow_Timer -= diff; + + if( Shrink_Timer <= diff ) + { + m_creature->RemoveAurasDueToSpell(SPELL_GROW); + Stop = true; + }else Shrink_Timer -= diff; + } +}; +CreatureAI* GetAI_mob_underbog_mushroom(Creature *_Creature) +{ + return new mob_underbog_mushroomAI (_Creature); +} + +void AddSC_boss_hungarfen() +{ + Script *newscript; + + newscript = new Script; + newscript->Name="boss_hungarfen"; + newscript->GetAI = GetAI_boss_hungarfen; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="mob_underbog_mushroom"; + newscript->GetAI = GetAI_mob_underbog_mushroom; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/darkshore/darkshore.cpp b/src/bindings/scripts/scripts/zone/darkshore/darkshore.cpp index 02acd88a491..2a0ed0187f7 100644 --- a/src/bindings/scripts/scripts/zone/darkshore/darkshore.cpp +++ b/src/bindings/scripts/scripts/zone/darkshore/darkshore.cpp @@ -1,24 +1,24 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Darkshore -SD%Complete: 0 -SDComment: Placeholder -SDCategory: Darkshore -EndScriptData */ - -#include "precompiled.h" +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Darkshore +SD%Complete: 0 +SDComment: Placeholder +SDCategory: Darkshore +EndScriptData */ + +#include "precompiled.h" diff --git a/src/bindings/scripts/scripts/zone/deadmines/deadmines.cpp b/src/bindings/scripts/scripts/zone/deadmines/deadmines.cpp index 535d8c86410..0b3325d6e84 100644 --- a/src/bindings/scripts/scripts/zone/deadmines/deadmines.cpp +++ b/src/bindings/scripts/scripts/zone/deadmines/deadmines.cpp @@ -1,24 +1,24 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Deadmines -SD%Complete: 0 -SDComment: Placeholder -SDCategory: Deadmines -EndScriptData */ - -#include "precompiled.h" +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Deadmines +SD%Complete: 0 +SDComment: Placeholder +SDCategory: Deadmines +EndScriptData */ + +#include "precompiled.h" diff --git a/src/bindings/scripts/scripts/zone/deadmines/instance_deadmines.cpp b/src/bindings/scripts/scripts/zone/deadmines/instance_deadmines.cpp index d97db663273..e2d386beda0 100644 --- a/src/bindings/scripts/scripts/zone/deadmines/instance_deadmines.cpp +++ b/src/bindings/scripts/scripts/zone/deadmines/instance_deadmines.cpp @@ -1,22 +1,22 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Instance_Deadmines -SD%Complete: 0 -SDComment: Placeholder -SDCategory: Deadmines -EndScriptData */ +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Instance_Deadmines +SD%Complete: 0 +SDComment: Placeholder +SDCategory: Deadmines +EndScriptData */ diff --git a/src/bindings/scripts/scripts/zone/dun_morogh/dun_morogh.cpp b/src/bindings/scripts/scripts/zone/dun_morogh/dun_morogh.cpp index d584dc0690e..58136ceae9f 100644 --- a/src/bindings/scripts/scripts/zone/dun_morogh/dun_morogh.cpp +++ b/src/bindings/scripts/scripts/zone/dun_morogh/dun_morogh.cpp @@ -1,98 +1,98 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Dun_Morogh -SD%Complete: 50 -SDComment: Quest support: 1783 -SDCategory: Dun Morogh -EndScriptData */ - -/* ContentData -npc_narm_faulk -EndContentData */ - -#include "precompiled.h" - -/*###### -## npc_narm_faulk -######*/ - -#define SAY_HEAL "Thank you, dear Paladin, you just saved my life." - -struct MANGOS_DLL_DECL npc_narm_faulkAI : public ScriptedAI -{ - uint32 lifeTimer; - bool spellHit; - - npc_narm_faulkAI(Creature *c) : ScriptedAI(c) {Reset();} - - void Reset() - { - lifeTimer = 120000; - m_creature->SetUInt32Value(UNIT_DYNAMIC_FLAGS, 32); - m_creature->SetUInt32Value(UNIT_FIELD_BYTES_1,7); // lay down - spellHit = false; - } - - void Aggro(Unit *who) - { - } - - void MoveInLineOfSight(Unit *who) - { - return; - } - - void UpdateAI(const uint32 diff) - { - if (!m_creature->GetUInt32Value(UNIT_FIELD_BYTES_1)) - { - if(lifeTimer < diff) - m_creature->AI()->EnterEvadeMode(); - else - lifeTimer -= diff; - } - } - - void SpellHit(Unit *Hitter, const SpellEntry *Spellkind) - { - if(Spellkind->Id == 8593 && !spellHit) - { - DoCast(m_creature,32343); - m_creature->SetUInt32Value(UNIT_FIELD_BYTES_1,0); - m_creature->SetUInt32Value(UNIT_DYNAMIC_FLAGS, 0); - //m_creature->RemoveAllAuras(); - DoSay(SAY_HEAL,LANG_COMMON,NULL); - spellHit = true; - } - } - -}; -CreatureAI* GetAI_npc_narm_faulk(Creature *_Creature) -{ - return new npc_narm_faulkAI (_Creature); -} - -void AddSC_dun_morogh() -{ - Script *newscript; - - newscript = new Script; - newscript->Name="npc_narm_faulk"; - newscript->GetAI = GetAI_npc_narm_faulk; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Dun_Morogh +SD%Complete: 50 +SDComment: Quest support: 1783 +SDCategory: Dun Morogh +EndScriptData */ + +/* ContentData +npc_narm_faulk +EndContentData */ + +#include "precompiled.h" + +/*###### +## npc_narm_faulk +######*/ + +#define SAY_HEAL "Thank you, dear Paladin, you just saved my life." + +struct MANGOS_DLL_DECL npc_narm_faulkAI : public ScriptedAI +{ + uint32 lifeTimer; + bool spellHit; + + npc_narm_faulkAI(Creature *c) : ScriptedAI(c) {Reset();} + + void Reset() + { + lifeTimer = 120000; + m_creature->SetUInt32Value(UNIT_DYNAMIC_FLAGS, 32); + m_creature->SetUInt32Value(UNIT_FIELD_BYTES_1,7); // lay down + spellHit = false; + } + + void Aggro(Unit *who) + { + } + + void MoveInLineOfSight(Unit *who) + { + return; + } + + void UpdateAI(const uint32 diff) + { + if (!m_creature->GetUInt32Value(UNIT_FIELD_BYTES_1)) + { + if(lifeTimer < diff) + m_creature->AI()->EnterEvadeMode(); + else + lifeTimer -= diff; + } + } + + void SpellHit(Unit *Hitter, const SpellEntry *Spellkind) + { + if(Spellkind->Id == 8593 && !spellHit) + { + DoCast(m_creature,32343); + m_creature->SetUInt32Value(UNIT_FIELD_BYTES_1,0); + m_creature->SetUInt32Value(UNIT_DYNAMIC_FLAGS, 0); + //m_creature->RemoveAllAuras(); + DoSay(SAY_HEAL,LANG_COMMON,NULL); + spellHit = true; + } + } + +}; +CreatureAI* GetAI_npc_narm_faulk(Creature *_Creature) +{ + return new npc_narm_faulkAI (_Creature); +} + +void AddSC_dun_morogh() +{ + Script *newscript; + + newscript = new Script; + newscript->Name="npc_narm_faulk"; + newscript->GetAI = GetAI_npc_narm_faulk; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/dustwallow_marsh/dustwallow_marsh.cpp b/src/bindings/scripts/scripts/zone/dustwallow_marsh/dustwallow_marsh.cpp index a29dda1c811..d63a8a8c948 100644 --- a/src/bindings/scripts/scripts/zone/dustwallow_marsh/dustwallow_marsh.cpp +++ b/src/bindings/scripts/scripts/zone/dustwallow_marsh/dustwallow_marsh.cpp @@ -1,231 +1,231 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Dustwallow_Marsh -SD%Complete: 95 -SDComment: Quest support: 11180, 558, 11126. Vendor Nat Pagle -SDCategory: Dustwallow Marsh -EndScriptData */ - -/* ContentData -mobs_risen_husk_spirit -npc_restless_apparition -npc_deserter_agitator -npc_lady_jaina_proudmoore -npc_nat_pagle -EndContentData */ - -#include "precompiled.h" - -/*###### -## mobs_risen_husk_spirit -######*/ - -#define SPELL_SUMMON_RESTLESS_APPARITION 42511 -#define SPELL_CONSUME_FLESH 37933 //Risen Husk -#define SPELL_INTANGIBLE_PRESENCE 43127 //Risen Spirit - -struct MANGOS_DLL_DECL mobs_risen_husk_spiritAI : public ScriptedAI -{ - mobs_risen_husk_spiritAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 ConsumeFlesh_Timer; - uint32 IntangiblePresence_Timer; - - void Reset() - { - ConsumeFlesh_Timer = 10000; - IntangiblePresence_Timer = 5000; - } - - void Aggro(Unit* who) { } - - void DamageTaken(Unit *done_by, uint32 &damage) - { - if( done_by->GetTypeId() == TYPEID_PLAYER ) - if( damage >= m_creature->GetHealth() && ((Player*)done_by)->GetQuestStatus(11180) == QUEST_STATUS_INCOMPLETE ) - m_creature->CastSpell(done_by,SPELL_SUMMON_RESTLESS_APPARITION,false); - } - - void UpdateAI(const uint32 diff) - { - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - if( ConsumeFlesh_Timer < diff ) - { - if( m_creature->GetEntry() == 23555 ) - DoCast(m_creature->getVictim(),SPELL_CONSUME_FLESH); - ConsumeFlesh_Timer = 15000; - } else ConsumeFlesh_Timer -= diff; - - if( IntangiblePresence_Timer < diff ) - { - if( m_creature->GetEntry() == 23554 ) - DoCast(m_creature->getVictim(),SPELL_INTANGIBLE_PRESENCE); - IntangiblePresence_Timer = 20000; - } else IntangiblePresence_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; -CreatureAI* GetAI_mobs_risen_husk_spirit(Creature *_Creature) -{ - return new mobs_risen_husk_spiritAI (_Creature); -} - -/*###### -## npc_restless_apparition -######*/ - -bool GossipHello_npc_restless_apparition(Player *player, Creature *_Creature) -{ - player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); - - player->TalkedToCreature(_Creature->GetEntry(), _Creature->GetGUID()); - _Creature->SetInt32Value(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - - return true; -} - -/*###### -## npc_deserter_agitator -######*/ - -struct MANGOS_DLL_DECL npc_deserter_agitatorAI : public ScriptedAI -{ - npc_deserter_agitatorAI(Creature *c) : ScriptedAI(c) {Reset();} - - void Reset() - { - m_creature->setFaction(894); - } - - void Aggro(Unit* who) {} -}; - -CreatureAI* GetAI_npc_deserter_agitator(Creature *_Creature) -{ - return new npc_deserter_agitatorAI (_Creature); -} - -bool GossipHello_npc_deserter_agitator(Player *player, Creature *_Creature) -{ - if (player->GetQuestStatus(11126) == QUEST_STATUS_INCOMPLETE) - { - _Creature->setFaction(1883); - player->TalkedToCreature(_Creature->GetEntry(), _Creature->GetGUID()); - } - else - player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); - - return true; -} - -/*###### -## npc_lady_jaina_proudmoore -######*/ - -#define GOSSIP_ITEM_JAINA "I know this is rather silly but i have a young ward who is a bit shy and would like your autograph." - -bool GossipHello_npc_lady_jaina_proudmoore(Player *player, Creature *_Creature) -{ - if (_Creature->isQuestGiver()) - player->PrepareQuestMenu( _Creature->GetGUID() ); - - if( player->GetQuestStatus(558) == QUEST_STATUS_INCOMPLETE ) - player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM_JAINA, GOSSIP_SENDER_MAIN, GOSSIP_SENDER_INFO ); - - player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); - - return true; -} - -bool GossipSelect_npc_lady_jaina_proudmoore(Player *player, Creature *_Creature, uint32 sender, uint32 action ) -{ - if( action == GOSSIP_SENDER_INFO ) - { - player->SEND_GOSSIP_MENU( 7012, _Creature->GetGUID() ); - player->CastSpell( player, 23122, false); - } - return true; -} - -/*###### -## npc_nat_pagle -######*/ - -bool GossipHello_npc_nat_pagle(Player *player, Creature *_Creature) -{ - if(_Creature->isQuestGiver()) - player->PrepareQuestMenu( _Creature->GetGUID() ); - - if(_Creature->isVendor() && player->GetQuestRewardStatus(8227)) - { - player->ADD_GOSSIP_ITEM(1, GOSSIP_TEXT_BROWSE_GOODS, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_TRADE); - player->SEND_GOSSIP_MENU( 7640, _Creature->GetGUID() ); - } - else - player->SEND_GOSSIP_MENU( 7638, _Creature->GetGUID() ); - - return true; -} - -bool GossipSelect_npc_nat_pagle(Player *player, Creature *_Creature, uint32 sender, uint32 action) -{ - if(action == GOSSIP_ACTION_TRADE) - player->SEND_VENDORLIST( _Creature->GetGUID() ); - - return true; -} - -/*###### -## -######*/ - -void AddSC_dustwallow_marsh() -{ - Script *newscript; - - newscript = new Script; - newscript->Name="mobs_risen_husk_spirit"; - newscript->GetAI = GetAI_mobs_risen_husk_spirit; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="npc_restless_apparition"; - newscript->pGossipHello = &GossipHello_npc_restless_apparition; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="npc_deserter_agitator"; - newscript->GetAI = GetAI_npc_deserter_agitator; - newscript->pGossipHello = &GossipHello_npc_deserter_agitator; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="npc_lady_jaina_proudmoore"; - newscript->pGossipHello = &GossipHello_npc_lady_jaina_proudmoore; - newscript->pGossipSelect = &GossipSelect_npc_lady_jaina_proudmoore; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="npc_nat_pagle"; - newscript->pGossipHello = &GossipHello_npc_nat_pagle; - newscript->pGossipSelect = &GossipSelect_npc_nat_pagle; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Dustwallow_Marsh +SD%Complete: 95 +SDComment: Quest support: 11180, 558, 11126. Vendor Nat Pagle +SDCategory: Dustwallow Marsh +EndScriptData */ + +/* ContentData +mobs_risen_husk_spirit +npc_restless_apparition +npc_deserter_agitator +npc_lady_jaina_proudmoore +npc_nat_pagle +EndContentData */ + +#include "precompiled.h" + +/*###### +## mobs_risen_husk_spirit +######*/ + +#define SPELL_SUMMON_RESTLESS_APPARITION 42511 +#define SPELL_CONSUME_FLESH 37933 //Risen Husk +#define SPELL_INTANGIBLE_PRESENCE 43127 //Risen Spirit + +struct MANGOS_DLL_DECL mobs_risen_husk_spiritAI : public ScriptedAI +{ + mobs_risen_husk_spiritAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 ConsumeFlesh_Timer; + uint32 IntangiblePresence_Timer; + + void Reset() + { + ConsumeFlesh_Timer = 10000; + IntangiblePresence_Timer = 5000; + } + + void Aggro(Unit* who) { } + + void DamageTaken(Unit *done_by, uint32 &damage) + { + if( done_by->GetTypeId() == TYPEID_PLAYER ) + if( damage >= m_creature->GetHealth() && ((Player*)done_by)->GetQuestStatus(11180) == QUEST_STATUS_INCOMPLETE ) + m_creature->CastSpell(done_by,SPELL_SUMMON_RESTLESS_APPARITION,false); + } + + void UpdateAI(const uint32 diff) + { + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + if( ConsumeFlesh_Timer < diff ) + { + if( m_creature->GetEntry() == 23555 ) + DoCast(m_creature->getVictim(),SPELL_CONSUME_FLESH); + ConsumeFlesh_Timer = 15000; + } else ConsumeFlesh_Timer -= diff; + + if( IntangiblePresence_Timer < diff ) + { + if( m_creature->GetEntry() == 23554 ) + DoCast(m_creature->getVictim(),SPELL_INTANGIBLE_PRESENCE); + IntangiblePresence_Timer = 20000; + } else IntangiblePresence_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; +CreatureAI* GetAI_mobs_risen_husk_spirit(Creature *_Creature) +{ + return new mobs_risen_husk_spiritAI (_Creature); +} + +/*###### +## npc_restless_apparition +######*/ + +bool GossipHello_npc_restless_apparition(Player *player, Creature *_Creature) +{ + player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); + + player->TalkedToCreature(_Creature->GetEntry(), _Creature->GetGUID()); + _Creature->SetInt32Value(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + + return true; +} + +/*###### +## npc_deserter_agitator +######*/ + +struct MANGOS_DLL_DECL npc_deserter_agitatorAI : public ScriptedAI +{ + npc_deserter_agitatorAI(Creature *c) : ScriptedAI(c) {Reset();} + + void Reset() + { + m_creature->setFaction(894); + } + + void Aggro(Unit* who) {} +}; + +CreatureAI* GetAI_npc_deserter_agitator(Creature *_Creature) +{ + return new npc_deserter_agitatorAI (_Creature); +} + +bool GossipHello_npc_deserter_agitator(Player *player, Creature *_Creature) +{ + if (player->GetQuestStatus(11126) == QUEST_STATUS_INCOMPLETE) + { + _Creature->setFaction(1883); + player->TalkedToCreature(_Creature->GetEntry(), _Creature->GetGUID()); + } + else + player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); + + return true; +} + +/*###### +## npc_lady_jaina_proudmoore +######*/ + +#define GOSSIP_ITEM_JAINA "I know this is rather silly but i have a young ward who is a bit shy and would like your autograph." + +bool GossipHello_npc_lady_jaina_proudmoore(Player *player, Creature *_Creature) +{ + if (_Creature->isQuestGiver()) + player->PrepareQuestMenu( _Creature->GetGUID() ); + + if( player->GetQuestStatus(558) == QUEST_STATUS_INCOMPLETE ) + player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM_JAINA, GOSSIP_SENDER_MAIN, GOSSIP_SENDER_INFO ); + + player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); + + return true; +} + +bool GossipSelect_npc_lady_jaina_proudmoore(Player *player, Creature *_Creature, uint32 sender, uint32 action ) +{ + if( action == GOSSIP_SENDER_INFO ) + { + player->SEND_GOSSIP_MENU( 7012, _Creature->GetGUID() ); + player->CastSpell( player, 23122, false); + } + return true; +} + +/*###### +## npc_nat_pagle +######*/ + +bool GossipHello_npc_nat_pagle(Player *player, Creature *_Creature) +{ + if(_Creature->isQuestGiver()) + player->PrepareQuestMenu( _Creature->GetGUID() ); + + if(_Creature->isVendor() && player->GetQuestRewardStatus(8227)) + { + player->ADD_GOSSIP_ITEM(1, GOSSIP_TEXT_BROWSE_GOODS, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_TRADE); + player->SEND_GOSSIP_MENU( 7640, _Creature->GetGUID() ); + } + else + player->SEND_GOSSIP_MENU( 7638, _Creature->GetGUID() ); + + return true; +} + +bool GossipSelect_npc_nat_pagle(Player *player, Creature *_Creature, uint32 sender, uint32 action) +{ + if(action == GOSSIP_ACTION_TRADE) + player->SEND_VENDORLIST( _Creature->GetGUID() ); + + return true; +} + +/*###### +## +######*/ + +void AddSC_dustwallow_marsh() +{ + Script *newscript; + + newscript = new Script; + newscript->Name="mobs_risen_husk_spirit"; + newscript->GetAI = GetAI_mobs_risen_husk_spirit; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="npc_restless_apparition"; + newscript->pGossipHello = &GossipHello_npc_restless_apparition; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="npc_deserter_agitator"; + newscript->GetAI = GetAI_npc_deserter_agitator; + newscript->pGossipHello = &GossipHello_npc_deserter_agitator; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="npc_lady_jaina_proudmoore"; + newscript->pGossipHello = &GossipHello_npc_lady_jaina_proudmoore; + newscript->pGossipSelect = &GossipSelect_npc_lady_jaina_proudmoore; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="npc_nat_pagle"; + newscript->pGossipHello = &GossipHello_npc_nat_pagle; + newscript->pGossipSelect = &GossipSelect_npc_nat_pagle; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/eastern_plaguelands/eastern_plaguelands.cpp b/src/bindings/scripts/scripts/zone/eastern_plaguelands/eastern_plaguelands.cpp index aa7ae7b2879..e0b2067b145 100644 --- a/src/bindings/scripts/scripts/zone/eastern_plaguelands/eastern_plaguelands.cpp +++ b/src/bindings/scripts/scripts/zone/eastern_plaguelands/eastern_plaguelands.cpp @@ -1,180 +1,180 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Eastern_Plaguelands -SD%Complete: 100 -SDComment: Quest support: 5211, 5742. Special vendor Augustus the Touched -SDCategory: Eastern Plaguelands -EndScriptData */ - -/* ContentData -mobs_ghoul_flayer -npc_augustus_the_touched -npc_darrowshire_spirit -npc_tirion_fordring -EndContentData */ - -#include "precompiled.h" - -//id8530 - cannibal ghoul -//id8531 - gibbering ghoul -//id8532 - diseased flayer - -struct MANGOS_DLL_DECL mobs_ghoul_flayerAI : public ScriptedAI -{ - mobs_ghoul_flayerAI(Creature *c) : ScriptedAI(c) {Reset();} - - void Reset() { } - - void Aggro(Unit* who) { } - - void JustDied(Unit* Killer) - { - if( Killer->GetTypeId() == TYPEID_PLAYER ) - DoSpawnCreature(11064,0,0,0,0,TEMPSUMMON_TIMED_DESPAWN,60000); - } - -}; - -CreatureAI* GetAI_mobs_ghoul_flayer(Creature *_Creature) -{ - return new mobs_ghoul_flayerAI (_Creature); -} - -/*###### -## npc_augustus_the_touched -######*/ - -bool GossipHello_npc_augustus_the_touched(Player *player, Creature *_Creature) -{ - if( _Creature->isQuestGiver() ) - player->PrepareQuestMenu( _Creature->GetGUID() ); - - if( _Creature->isVendor() && player->GetQuestRewardStatus(6164) ) - player->ADD_GOSSIP_ITEM(1, GOSSIP_TEXT_BROWSE_GOODS, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_TRADE); - - player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(),_Creature->GetGUID()); - return true; -} - -bool GossipSelect_npc_augustus_the_touched(Player *player, Creature *_Creature, uint32 sender, uint32 action ) -{ - if( action == GOSSIP_ACTION_TRADE ) - player->SEND_VENDORLIST( _Creature->GetGUID() ); - return true; -} - -/*###### -## npc_darrowshire_spirit -######*/ - -#define SPELL_SPIRIT_SPAWNIN 17321 - -struct MANGOS_DLL_DECL npc_darrowshire_spiritAI : public ScriptedAI -{ - npc_darrowshire_spiritAI(Creature *c) : ScriptedAI(c) {Reset();} - - void Reset() - { - DoCast(m_creature,SPELL_SPIRIT_SPAWNIN); - m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - } - - void Aggro(Unit *who) { } - -}; -CreatureAI* GetAI_npc_darrowshire_spirit(Creature *_Creature) -{ - return new npc_darrowshire_spiritAI (_Creature); -} - -bool GossipHello_npc_darrowshire_spirit(Player *player, Creature *_Creature) -{ - player->SEND_GOSSIP_MENU(3873,_Creature->GetGUID()); - player->TalkedToCreature(_Creature->GetEntry(), _Creature->GetGUID()); - _Creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - return true; -} - -/*###### -## npc_tirion_fordring -######*/ - -bool GossipHello_npc_tirion_fordring(Player *player, Creature *_Creature) -{ - if (_Creature->isQuestGiver()) - player->PrepareQuestMenu( _Creature->GetGUID() ); - - if (player->GetQuestStatus(5742) == QUEST_STATUS_INCOMPLETE && player->getStandState() == PLAYER_STATE_SIT ) - player->ADD_GOSSIP_ITEM( 0, "I am ready to hear your tale, Tirion.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); - - player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); - - return true; -} - -bool GossipSelect_npc_tirion_fordring(Player *player, Creature *_Creature, uint32 sender, uint32 action) -{ - switch (action) - { - case GOSSIP_ACTION_INFO_DEF+1: - player->ADD_GOSSIP_ITEM( 0, "Thank you, Tirion. What of your identity?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2); - player->SEND_GOSSIP_MENU(4493, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+2: - player->ADD_GOSSIP_ITEM( 0, "That is terrible.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 3); - player->SEND_GOSSIP_MENU(4494, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+3: - player->ADD_GOSSIP_ITEM( 0, "I will, Tirion.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 4); - player->SEND_GOSSIP_MENU(4495, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+4: - player->CLOSE_GOSSIP_MENU(); - player->AreaExploredOrEventHappens(5742); - break; - } - return true; -} - -void AddSC_eastern_plaguelands() -{ - Script *newscript; - - newscript = new Script; - newscript->Name="mobs_ghoul_flayer"; - newscript->GetAI = GetAI_mobs_ghoul_flayer; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="npc_augustus_the_touched"; - newscript->pGossipHello = &GossipHello_npc_augustus_the_touched; - newscript->pGossipSelect = &GossipSelect_npc_augustus_the_touched; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="npc_darrowshire_spirit"; - newscript->GetAI = GetAI_npc_darrowshire_spirit; - newscript->pGossipHello = &GossipHello_npc_darrowshire_spirit; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="npc_tirion_fordring"; - newscript->pGossipHello = &GossipHello_npc_tirion_fordring; - newscript->pGossipSelect = &GossipSelect_npc_tirion_fordring; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Eastern_Plaguelands +SD%Complete: 100 +SDComment: Quest support: 5211, 5742. Special vendor Augustus the Touched +SDCategory: Eastern Plaguelands +EndScriptData */ + +/* ContentData +mobs_ghoul_flayer +npc_augustus_the_touched +npc_darrowshire_spirit +npc_tirion_fordring +EndContentData */ + +#include "precompiled.h" + +//id8530 - cannibal ghoul +//id8531 - gibbering ghoul +//id8532 - diseased flayer + +struct MANGOS_DLL_DECL mobs_ghoul_flayerAI : public ScriptedAI +{ + mobs_ghoul_flayerAI(Creature *c) : ScriptedAI(c) {Reset();} + + void Reset() { } + + void Aggro(Unit* who) { } + + void JustDied(Unit* Killer) + { + if( Killer->GetTypeId() == TYPEID_PLAYER ) + DoSpawnCreature(11064,0,0,0,0,TEMPSUMMON_TIMED_DESPAWN,60000); + } + +}; + +CreatureAI* GetAI_mobs_ghoul_flayer(Creature *_Creature) +{ + return new mobs_ghoul_flayerAI (_Creature); +} + +/*###### +## npc_augustus_the_touched +######*/ + +bool GossipHello_npc_augustus_the_touched(Player *player, Creature *_Creature) +{ + if( _Creature->isQuestGiver() ) + player->PrepareQuestMenu( _Creature->GetGUID() ); + + if( _Creature->isVendor() && player->GetQuestRewardStatus(6164) ) + player->ADD_GOSSIP_ITEM(1, GOSSIP_TEXT_BROWSE_GOODS, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_TRADE); + + player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(),_Creature->GetGUID()); + return true; +} + +bool GossipSelect_npc_augustus_the_touched(Player *player, Creature *_Creature, uint32 sender, uint32 action ) +{ + if( action == GOSSIP_ACTION_TRADE ) + player->SEND_VENDORLIST( _Creature->GetGUID() ); + return true; +} + +/*###### +## npc_darrowshire_spirit +######*/ + +#define SPELL_SPIRIT_SPAWNIN 17321 + +struct MANGOS_DLL_DECL npc_darrowshire_spiritAI : public ScriptedAI +{ + npc_darrowshire_spiritAI(Creature *c) : ScriptedAI(c) {Reset();} + + void Reset() + { + DoCast(m_creature,SPELL_SPIRIT_SPAWNIN); + m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + } + + void Aggro(Unit *who) { } + +}; +CreatureAI* GetAI_npc_darrowshire_spirit(Creature *_Creature) +{ + return new npc_darrowshire_spiritAI (_Creature); +} + +bool GossipHello_npc_darrowshire_spirit(Player *player, Creature *_Creature) +{ + player->SEND_GOSSIP_MENU(3873,_Creature->GetGUID()); + player->TalkedToCreature(_Creature->GetEntry(), _Creature->GetGUID()); + _Creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + return true; +} + +/*###### +## npc_tirion_fordring +######*/ + +bool GossipHello_npc_tirion_fordring(Player *player, Creature *_Creature) +{ + if (_Creature->isQuestGiver()) + player->PrepareQuestMenu( _Creature->GetGUID() ); + + if (player->GetQuestStatus(5742) == QUEST_STATUS_INCOMPLETE && player->getStandState() == PLAYER_STATE_SIT ) + player->ADD_GOSSIP_ITEM( 0, "I am ready to hear your tale, Tirion.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); + + player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); + + return true; +} + +bool GossipSelect_npc_tirion_fordring(Player *player, Creature *_Creature, uint32 sender, uint32 action) +{ + switch (action) + { + case GOSSIP_ACTION_INFO_DEF+1: + player->ADD_GOSSIP_ITEM( 0, "Thank you, Tirion. What of your identity?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2); + player->SEND_GOSSIP_MENU(4493, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+2: + player->ADD_GOSSIP_ITEM( 0, "That is terrible.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 3); + player->SEND_GOSSIP_MENU(4494, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+3: + player->ADD_GOSSIP_ITEM( 0, "I will, Tirion.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 4); + player->SEND_GOSSIP_MENU(4495, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+4: + player->CLOSE_GOSSIP_MENU(); + player->AreaExploredOrEventHappens(5742); + break; + } + return true; +} + +void AddSC_eastern_plaguelands() +{ + Script *newscript; + + newscript = new Script; + newscript->Name="mobs_ghoul_flayer"; + newscript->GetAI = GetAI_mobs_ghoul_flayer; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="npc_augustus_the_touched"; + newscript->pGossipHello = &GossipHello_npc_augustus_the_touched; + newscript->pGossipSelect = &GossipSelect_npc_augustus_the_touched; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="npc_darrowshire_spirit"; + newscript->GetAI = GetAI_npc_darrowshire_spirit; + newscript->pGossipHello = &GossipHello_npc_darrowshire_spirit; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="npc_tirion_fordring"; + newscript->pGossipHello = &GossipHello_npc_tirion_fordring; + newscript->pGossipSelect = &GossipSelect_npc_tirion_fordring; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/elwynn_forest/elwynn_forest.cpp b/src/bindings/scripts/scripts/zone/elwynn_forest/elwynn_forest.cpp index 0fc754f91c6..7d2c22e6381 100644 --- a/src/bindings/scripts/scripts/zone/elwynn_forest/elwynn_forest.cpp +++ b/src/bindings/scripts/scripts/zone/elwynn_forest/elwynn_forest.cpp @@ -1,98 +1,98 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Elwynn_Forest -SD%Complete: 50 -SDComment: Quest support: 1786 -SDCategory: Elwynn Forest -EndScriptData */ - -/* ContentData -npc_henze_faulk -EndContentData */ - -#include "precompiled.h" - -/*###### -## npc_henze_faulk -######*/ - -#define SAY_HEAL "Thank you, dear Paladin, you just saved my life." - -struct MANGOS_DLL_DECL npc_henze_faulkAI : public ScriptedAI -{ - uint32 lifeTimer; - bool spellHit; - - npc_henze_faulkAI(Creature *c) : ScriptedAI(c) {Reset();} - - void Reset() - { - lifeTimer = 120000; - m_creature->SetUInt32Value(UNIT_DYNAMIC_FLAGS, 32); - m_creature->SetUInt32Value(UNIT_FIELD_BYTES_1,7); // lay down - spellHit = false; - } - - void Aggro(Unit *who) - { - } - - void MoveInLineOfSight(Unit *who) - { - return; - } - - void UpdateAI(const uint32 diff) - { - if (!m_creature->GetUInt32Value(UNIT_FIELD_BYTES_1)) - { - if(lifeTimer < diff) - m_creature->AI()->EnterEvadeMode(); - else - lifeTimer -= diff; - } - } - - void SpellHit(Unit *Hitter, const SpellEntry *Spellkind) - { - if(Spellkind->Id == 8593 && !spellHit) - { - DoCast(m_creature,32343); - m_creature->SetUInt32Value(UNIT_FIELD_BYTES_1,0); - m_creature->SetUInt32Value(UNIT_DYNAMIC_FLAGS, 0); - //m_creature->RemoveAllAuras(); - DoSay(SAY_HEAL,LANG_COMMON,NULL); - spellHit = true; - } - } - -}; -CreatureAI* GetAI_npc_henze_faulk(Creature *_Creature) -{ - return new npc_henze_faulkAI (_Creature); -} - -void AddSC_elwynn_forest() -{ - Script *newscript; - - newscript = new Script; - newscript->Name="npc_henze_faulk"; - newscript->GetAI = GetAI_npc_henze_faulk; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Elwynn_Forest +SD%Complete: 50 +SDComment: Quest support: 1786 +SDCategory: Elwynn Forest +EndScriptData */ + +/* ContentData +npc_henze_faulk +EndContentData */ + +#include "precompiled.h" + +/*###### +## npc_henze_faulk +######*/ + +#define SAY_HEAL "Thank you, dear Paladin, you just saved my life." + +struct MANGOS_DLL_DECL npc_henze_faulkAI : public ScriptedAI +{ + uint32 lifeTimer; + bool spellHit; + + npc_henze_faulkAI(Creature *c) : ScriptedAI(c) {Reset();} + + void Reset() + { + lifeTimer = 120000; + m_creature->SetUInt32Value(UNIT_DYNAMIC_FLAGS, 32); + m_creature->SetUInt32Value(UNIT_FIELD_BYTES_1,7); // lay down + spellHit = false; + } + + void Aggro(Unit *who) + { + } + + void MoveInLineOfSight(Unit *who) + { + return; + } + + void UpdateAI(const uint32 diff) + { + if (!m_creature->GetUInt32Value(UNIT_FIELD_BYTES_1)) + { + if(lifeTimer < diff) + m_creature->AI()->EnterEvadeMode(); + else + lifeTimer -= diff; + } + } + + void SpellHit(Unit *Hitter, const SpellEntry *Spellkind) + { + if(Spellkind->Id == 8593 && !spellHit) + { + DoCast(m_creature,32343); + m_creature->SetUInt32Value(UNIT_FIELD_BYTES_1,0); + m_creature->SetUInt32Value(UNIT_DYNAMIC_FLAGS, 0); + //m_creature->RemoveAllAuras(); + DoSay(SAY_HEAL,LANG_COMMON,NULL); + spellHit = true; + } + } + +}; +CreatureAI* GetAI_npc_henze_faulk(Creature *_Creature) +{ + return new npc_henze_faulkAI (_Creature); +} + +void AddSC_elwynn_forest() +{ + Script *newscript; + + newscript = new Script; + newscript->Name="npc_henze_faulk"; + newscript->GetAI = GetAI_npc_henze_faulk; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/eversong_woods/eversong_woods.cpp b/src/bindings/scripts/scripts/zone/eversong_woods/eversong_woods.cpp index aab21ed5cb3..12931cb52e7 100644 --- a/src/bindings/scripts/scripts/zone/eversong_woods/eversong_woods.cpp +++ b/src/bindings/scripts/scripts/zone/eversong_woods/eversong_woods.cpp @@ -1,163 +1,163 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Eversong_Woods -SD%Complete: 100 -SDComment: Quest support: 8346, 8483 -SDCategory: Eversong Woods -EndScriptData */ - -/* ContentData -mobs_mana_tapped -npc_prospector_anvilward -EndContentData */ - -#include "precompiled.h" -#include "../../npc/npc_escortAI.h" - -/*###### -## mobs_mana_tapped -######*/ - -struct MANGOS_DLL_DECL mobs_mana_tappedAI : public ScriptedAI -{ - mobs_mana_tappedAI(Creature *c) : ScriptedAI(c) {Reset();} - - void Reset() { } - - void Aggro(Unit *who) { } - - void SpellHit(Unit *caster, const SpellEntry *spell) - { - if( caster->GetTypeId() == TYPEID_PLAYER) - if( ((Player*)caster)->GetQuestStatus(8346) == QUEST_STATUS_INCOMPLETE && !((Player*)caster)->GetReqKillOrCastCurrentCount(8346, m_creature->GetEntry()) && spell->Id == 28734) - ((Player*)caster)->CastedCreatureOrGO(15468, m_creature->GetGUID(), spell->Id); - return; - } -}; -CreatureAI* GetAI_mobs_mana_tapped(Creature *_Creature) -{ - return new mobs_mana_tappedAI (_Creature); -} - -/*###### -## npc_prospector_anvilward -######*/ - -#define QUEST_THE_DWARVEN_SPY 8483 - -struct MANGOS_DLL_DECL npc_prospector_anvilwardAI : public npc_escortAI -{ - // CreatureAI functions - npc_prospector_anvilwardAI(Creature *c) : npc_escortAI(c) {Reset();} - - // Pure Virtual Functions - void WaypointReached(uint32 i) - { - switch (i) - { - case 0: - m_creature->Say("Very well. Let's see what you have to show me, $N.", LANG_UNIVERSAL, PlayerGUID); - break; - case 5: - m_creature->Say("What manner of trick is this, $R? If you seek to ambush me, I warn you I will not go down quietly!", LANG_UNIVERSAL, PlayerGUID); - break; - case 6: - m_creature->setFaction(24); - break; - } - } - - void Aggro(Unit* who) { } - - void Reset() - { - //Default npc faction - m_creature->setFaction(35); - } - - void JustDied(Unit* killer) - { - //Default npc faction - m_creature->setFaction(35); - } - - void UpdateAI(const uint32 diff) - { - npc_escortAI::UpdateAI(diff); //Must update npc_escortAI - - } -}; - -CreatureAI* GetAI_npc_prospector_anvilward(Creature *_Creature) -{ - npc_prospector_anvilwardAI* thisAI = new npc_prospector_anvilwardAI(_Creature); - - thisAI->AddWaypoint(0, 9294.78, -6682.51, 22.42); - thisAI->AddWaypoint(1, 9298.27, -6667.99, 22.42); - thisAI->AddWaypoint(2, 9309.63, -6658.84, 22.43); - thisAI->AddWaypoint(3, 9304.43, -6649.31, 26.46); - thisAI->AddWaypoint(4, 9298.83, -6648.00, 28.61); - thisAI->AddWaypoint(5, 9291.06, -6653.46, 31.83,2500); - thisAI->AddWaypoint(6, 9289.08, -6660.17, 31.85,5000); - thisAI->AddWaypoint(7, 9291.06, -6653.46, 31.83); - - return (CreatureAI*)thisAI; -} - -bool GossipHello_npc_prospector_anvilward(Player *player, Creature *_Creature) -{ - if( player->GetQuestStatus(QUEST_THE_DWARVEN_SPY) == QUEST_STATUS_INCOMPLETE ) - player->ADD_GOSSIP_ITEM(0, "I need a moment of your time, sir.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); - - player->SEND_GOSSIP_MENU(8239, _Creature->GetGUID()); - return true; -} - -bool GossipSelect_npc_prospector_anvilward(Player *player, Creature *_Creature, uint32 sender, uint32 action ) -{ - switch(action) - { - case GOSSIP_ACTION_INFO_DEF+1: - player->ADD_GOSSIP_ITEM( 0, "Why... yes, of course. I've something to show you right inside this building, Mr. Anvilward.",GOSSIP_SENDER_MAIN,GOSSIP_ACTION_INFO_DEF+2); - player->SEND_GOSSIP_MENU(8240, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+2: - player->CLOSE_GOSSIP_MENU(); - //attack,defend,walk - ((npc_escortAI*)(_Creature->AI()))->Start(true, true, false, player->GetGUID()); - break; - } - return true; -} - -void AddSC_eversong_woods() -{ - Script *newscript; - - newscript = new Script; - newscript->Name="mobs_mana_tapped"; - newscript->GetAI = GetAI_mobs_mana_tapped; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name= "npc_prospector_anvilward"; - newscript->GetAI = GetAI_npc_prospector_anvilward; - newscript->pGossipHello = &GossipHello_npc_prospector_anvilward; - newscript->pGossipSelect = &GossipSelect_npc_prospector_anvilward; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Eversong_Woods +SD%Complete: 100 +SDComment: Quest support: 8346, 8483 +SDCategory: Eversong Woods +EndScriptData */ + +/* ContentData +mobs_mana_tapped +npc_prospector_anvilward +EndContentData */ + +#include "precompiled.h" +#include "../../npc/npc_escortAI.h" + +/*###### +## mobs_mana_tapped +######*/ + +struct MANGOS_DLL_DECL mobs_mana_tappedAI : public ScriptedAI +{ + mobs_mana_tappedAI(Creature *c) : ScriptedAI(c) {Reset();} + + void Reset() { } + + void Aggro(Unit *who) { } + + void SpellHit(Unit *caster, const SpellEntry *spell) + { + if( caster->GetTypeId() == TYPEID_PLAYER) + if( ((Player*)caster)->GetQuestStatus(8346) == QUEST_STATUS_INCOMPLETE && !((Player*)caster)->GetReqKillOrCastCurrentCount(8346, m_creature->GetEntry()) && spell->Id == 28734) + ((Player*)caster)->CastedCreatureOrGO(15468, m_creature->GetGUID(), spell->Id); + return; + } +}; +CreatureAI* GetAI_mobs_mana_tapped(Creature *_Creature) +{ + return new mobs_mana_tappedAI (_Creature); +} + +/*###### +## npc_prospector_anvilward +######*/ + +#define QUEST_THE_DWARVEN_SPY 8483 + +struct MANGOS_DLL_DECL npc_prospector_anvilwardAI : public npc_escortAI +{ + // CreatureAI functions + npc_prospector_anvilwardAI(Creature *c) : npc_escortAI(c) {Reset();} + + // Pure Virtual Functions + void WaypointReached(uint32 i) + { + switch (i) + { + case 0: + m_creature->Say("Very well. Let's see what you have to show me, $N.", LANG_UNIVERSAL, PlayerGUID); + break; + case 5: + m_creature->Say("What manner of trick is this, $R? If you seek to ambush me, I warn you I will not go down quietly!", LANG_UNIVERSAL, PlayerGUID); + break; + case 6: + m_creature->setFaction(24); + break; + } + } + + void Aggro(Unit* who) { } + + void Reset() + { + //Default npc faction + m_creature->setFaction(35); + } + + void JustDied(Unit* killer) + { + //Default npc faction + m_creature->setFaction(35); + } + + void UpdateAI(const uint32 diff) + { + npc_escortAI::UpdateAI(diff); //Must update npc_escortAI + + } +}; + +CreatureAI* GetAI_npc_prospector_anvilward(Creature *_Creature) +{ + npc_prospector_anvilwardAI* thisAI = new npc_prospector_anvilwardAI(_Creature); + + thisAI->AddWaypoint(0, 9294.78, -6682.51, 22.42); + thisAI->AddWaypoint(1, 9298.27, -6667.99, 22.42); + thisAI->AddWaypoint(2, 9309.63, -6658.84, 22.43); + thisAI->AddWaypoint(3, 9304.43, -6649.31, 26.46); + thisAI->AddWaypoint(4, 9298.83, -6648.00, 28.61); + thisAI->AddWaypoint(5, 9291.06, -6653.46, 31.83,2500); + thisAI->AddWaypoint(6, 9289.08, -6660.17, 31.85,5000); + thisAI->AddWaypoint(7, 9291.06, -6653.46, 31.83); + + return (CreatureAI*)thisAI; +} + +bool GossipHello_npc_prospector_anvilward(Player *player, Creature *_Creature) +{ + if( player->GetQuestStatus(QUEST_THE_DWARVEN_SPY) == QUEST_STATUS_INCOMPLETE ) + player->ADD_GOSSIP_ITEM(0, "I need a moment of your time, sir.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); + + player->SEND_GOSSIP_MENU(8239, _Creature->GetGUID()); + return true; +} + +bool GossipSelect_npc_prospector_anvilward(Player *player, Creature *_Creature, uint32 sender, uint32 action ) +{ + switch(action) + { + case GOSSIP_ACTION_INFO_DEF+1: + player->ADD_GOSSIP_ITEM( 0, "Why... yes, of course. I've something to show you right inside this building, Mr. Anvilward.",GOSSIP_SENDER_MAIN,GOSSIP_ACTION_INFO_DEF+2); + player->SEND_GOSSIP_MENU(8240, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+2: + player->CLOSE_GOSSIP_MENU(); + //attack,defend,walk + ((npc_escortAI*)(_Creature->AI()))->Start(true, true, false, player->GetGUID()); + break; + } + return true; +} + +void AddSC_eversong_woods() +{ + Script *newscript; + + newscript = new Script; + newscript->Name="mobs_mana_tapped"; + newscript->GetAI = GetAI_mobs_mana_tapped; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name= "npc_prospector_anvilward"; + newscript->GetAI = GetAI_npc_prospector_anvilward; + newscript->pGossipHello = &GossipHello_npc_prospector_anvilward; + newscript->pGossipSelect = &GossipSelect_npc_prospector_anvilward; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/felwood/felwood.cpp b/src/bindings/scripts/scripts/zone/felwood/felwood.cpp index 4e8b6e3cdc3..f0f0a081859 100644 --- a/src/bindings/scripts/scripts/zone/felwood/felwood.cpp +++ b/src/bindings/scripts/scripts/zone/felwood/felwood.cpp @@ -1,89 +1,89 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Felwood -SD%Complete: 95 -SDComment: Quest support: related to 4101&4102 (To obtain Cenarion Beacon) -SDCategory: Felwood -EndScriptData */ - -/* ContentData -npcs_riverbreeze_and_silversky -EndContentData */ - -#include "precompiled.h" - -/*###### -## npcs_riverbreeze_and_silversky -######*/ - -#define GOSSIP_ITEM_BEACON "Please make me a Cenarion Beacon" - -bool GossipHello_npcs_riverbreeze_and_silversky(Player *player, Creature *_Creature) -{ - uint32 eCreature = _Creature->GetEntry(); - - if( _Creature->isQuestGiver() ) - player->PrepareQuestMenu( _Creature->GetGUID() ); - - if( eCreature==9528 ) - { - if( player->GetQuestRewardStatus(4101) ) - { - player->ADD_GOSSIP_ITEM(0, GOSSIP_ITEM_BEACON, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); - player->SEND_GOSSIP_MENU(2848, _Creature->GetGUID()); - }else if( player->GetTeam()==HORDE ) - player->SEND_GOSSIP_MENU(2845, _Creature->GetGUID()); - else - player->SEND_GOSSIP_MENU(2844, _Creature->GetGUID()); - } - - if( eCreature==9529 ) - { - if( player->GetQuestRewardStatus(4102) ) - { - player->ADD_GOSSIP_ITEM(0, GOSSIP_ITEM_BEACON, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); - player->SEND_GOSSIP_MENU(2849, _Creature->GetGUID()); - }else if( player->GetTeam()==ALLIANCE ) - player->SEND_GOSSIP_MENU(2843, _Creature->GetGUID()); - else - player->SEND_GOSSIP_MENU(2842, _Creature->GetGUID()); - } - - return true; -} - -bool GossipSelect_npcs_riverbreeze_and_silversky(Player *player, Creature *_Creature, uint32 sender, uint32 action) -{ - if( action==GOSSIP_ACTION_INFO_DEF+1 ) - { - player->CLOSE_GOSSIP_MENU(); - _Creature->CastSpell(player, 15120, false); - } - return true; -} - -void AddSC_felwood() -{ - Script *newscript; - - newscript = new Script; - newscript->Name="npcs_riverbreeze_and_silversky"; - newscript->pGossipHello = &GossipHello_npcs_riverbreeze_and_silversky; - newscript->pGossipSelect = &GossipSelect_npcs_riverbreeze_and_silversky; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Felwood +SD%Complete: 95 +SDComment: Quest support: related to 4101&4102 (To obtain Cenarion Beacon) +SDCategory: Felwood +EndScriptData */ + +/* ContentData +npcs_riverbreeze_and_silversky +EndContentData */ + +#include "precompiled.h" + +/*###### +## npcs_riverbreeze_and_silversky +######*/ + +#define GOSSIP_ITEM_BEACON "Please make me a Cenarion Beacon" + +bool GossipHello_npcs_riverbreeze_and_silversky(Player *player, Creature *_Creature) +{ + uint32 eCreature = _Creature->GetEntry(); + + if( _Creature->isQuestGiver() ) + player->PrepareQuestMenu( _Creature->GetGUID() ); + + if( eCreature==9528 ) + { + if( player->GetQuestRewardStatus(4101) ) + { + player->ADD_GOSSIP_ITEM(0, GOSSIP_ITEM_BEACON, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); + player->SEND_GOSSIP_MENU(2848, _Creature->GetGUID()); + }else if( player->GetTeam()==HORDE ) + player->SEND_GOSSIP_MENU(2845, _Creature->GetGUID()); + else + player->SEND_GOSSIP_MENU(2844, _Creature->GetGUID()); + } + + if( eCreature==9529 ) + { + if( player->GetQuestRewardStatus(4102) ) + { + player->ADD_GOSSIP_ITEM(0, GOSSIP_ITEM_BEACON, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); + player->SEND_GOSSIP_MENU(2849, _Creature->GetGUID()); + }else if( player->GetTeam()==ALLIANCE ) + player->SEND_GOSSIP_MENU(2843, _Creature->GetGUID()); + else + player->SEND_GOSSIP_MENU(2842, _Creature->GetGUID()); + } + + return true; +} + +bool GossipSelect_npcs_riverbreeze_and_silversky(Player *player, Creature *_Creature, uint32 sender, uint32 action) +{ + if( action==GOSSIP_ACTION_INFO_DEF+1 ) + { + player->CLOSE_GOSSIP_MENU(); + _Creature->CastSpell(player, 15120, false); + } + return true; +} + +void AddSC_felwood() +{ + Script *newscript; + + newscript = new Script; + newscript->Name="npcs_riverbreeze_and_silversky"; + newscript->pGossipHello = &GossipHello_npcs_riverbreeze_and_silversky; + newscript->pGossipSelect = &GossipSelect_npcs_riverbreeze_and_silversky; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/feralas/feralas.cpp b/src/bindings/scripts/scripts/zone/feralas/feralas.cpp index ef886eadc65..a5062ebc21f 100644 --- a/src/bindings/scripts/scripts/zone/feralas/feralas.cpp +++ b/src/bindings/scripts/scripts/zone/feralas/feralas.cpp @@ -1,85 +1,85 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Feralas -SD%Complete: 100 -SDComment: Quest support: 3520. Special vendor Gregan Brewspewer -SDCategory: Feralas -EndScriptData */ - -#include "precompiled.h" - -/*###### -## npc_gregan_brewspewer -######*/ - -bool GossipHello_npc_gregan_brewspewer(Player *player, Creature *_Creature) -{ - if( _Creature->isQuestGiver() ) - player->PrepareQuestMenu( _Creature->GetGUID() ); - - if( _Creature->isVendor() && player->GetQuestStatus(3909) == QUEST_STATUS_INCOMPLETE ) - player->ADD_GOSSIP_ITEM(0, "Buy somethin', will ya?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); - - player->SEND_GOSSIP_MENU(2433,_Creature->GetGUID()); - return true; -} - -bool GossipSelect_npc_gregan_brewspewer(Player *player, Creature *_Creature, uint32 sender, uint32 action ) -{ - if( action == GOSSIP_ACTION_INFO_DEF+1 ) - { - player->ADD_GOSSIP_ITEM(1, GOSSIP_TEXT_BROWSE_GOODS, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_TRADE); - player->SEND_GOSSIP_MENU(2434,_Creature->GetGUID()); - } - if( action == GOSSIP_ACTION_TRADE ) - player->SEND_VENDORLIST( _Creature->GetGUID() ); - return true; -} - -/*###### -## npc_screecher_spirit -######*/ - -bool GossipHello_npc_screecher_spirit(Player *player, Creature *_Creature) -{ - player->SEND_GOSSIP_MENU(2039,_Creature->GetGUID() ); - player->TalkedToCreature(_Creature->GetEntry(), _Creature->GetGUID()); - _Creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - - return true; -} - -/*###### -## AddSC -######*/ - -void AddSC_feralas() -{ - Script *newscript; - - newscript = new Script; - newscript->Name="npc_gregan_brewspewer"; - newscript->pGossipHello = &GossipHello_npc_gregan_brewspewer; - newscript->pGossipSelect = &GossipSelect_npc_gregan_brewspewer; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="npc_screecher_spirit"; - newscript->pGossipHello = &GossipHello_npc_screecher_spirit; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Feralas +SD%Complete: 100 +SDComment: Quest support: 3520. Special vendor Gregan Brewspewer +SDCategory: Feralas +EndScriptData */ + +#include "precompiled.h" + +/*###### +## npc_gregan_brewspewer +######*/ + +bool GossipHello_npc_gregan_brewspewer(Player *player, Creature *_Creature) +{ + if( _Creature->isQuestGiver() ) + player->PrepareQuestMenu( _Creature->GetGUID() ); + + if( _Creature->isVendor() && player->GetQuestStatus(3909) == QUEST_STATUS_INCOMPLETE ) + player->ADD_GOSSIP_ITEM(0, "Buy somethin', will ya?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); + + player->SEND_GOSSIP_MENU(2433,_Creature->GetGUID()); + return true; +} + +bool GossipSelect_npc_gregan_brewspewer(Player *player, Creature *_Creature, uint32 sender, uint32 action ) +{ + if( action == GOSSIP_ACTION_INFO_DEF+1 ) + { + player->ADD_GOSSIP_ITEM(1, GOSSIP_TEXT_BROWSE_GOODS, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_TRADE); + player->SEND_GOSSIP_MENU(2434,_Creature->GetGUID()); + } + if( action == GOSSIP_ACTION_TRADE ) + player->SEND_VENDORLIST( _Creature->GetGUID() ); + return true; +} + +/*###### +## npc_screecher_spirit +######*/ + +bool GossipHello_npc_screecher_spirit(Player *player, Creature *_Creature) +{ + player->SEND_GOSSIP_MENU(2039,_Creature->GetGUID() ); + player->TalkedToCreature(_Creature->GetEntry(), _Creature->GetGUID()); + _Creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + + return true; +} + +/*###### +## AddSC +######*/ + +void AddSC_feralas() +{ + Script *newscript; + + newscript = new Script; + newscript->Name="npc_gregan_brewspewer"; + newscript->pGossipHello = &GossipHello_npc_gregan_brewspewer; + newscript->pGossipSelect = &GossipSelect_npc_gregan_brewspewer; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="npc_screecher_spirit"; + newscript->pGossipHello = &GossipHello_npc_screecher_spirit; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/ghostlands/ghostlands.cpp b/src/bindings/scripts/scripts/zone/ghostlands/ghostlands.cpp index 759da44db12..bceb03da348 100644 --- a/src/bindings/scripts/scripts/zone/ghostlands/ghostlands.cpp +++ b/src/bindings/scripts/scripts/zone/ghostlands/ghostlands.cpp @@ -1,134 +1,134 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Ghostlands -SD%Complete: 100 -SDComment: Quest support: 9692. Obtain Budd's Guise of Zul'aman. Vendor Rathis Tomber -SDCategory: Ghostlands -EndScriptData */ - -/* ContentData -npc_blood_knight_dawnstar -npc_budd_nedreck -npc_rathis_tomber -EndContentData */ - -#include "precompiled.h" - -/*###### -## npc_blood_knight_dawnstar -######*/ - -bool GossipHello_npc_blood_knight_dawnstar(Player *player, Creature *_Creature) -{ - if (player->GetQuestStatus(9692) == QUEST_STATUS_INCOMPLETE && !player->HasItemCount(24226,1,true)) - player->ADD_GOSSIP_ITEM( 0, "Take Blood Knight Insignia", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); - - player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); - - return true; -} - -bool GossipSelect_npc_blood_knight_dawnstar(Player *player, Creature *_Creature, uint32 sender, uint32 action) -{ - if (action == GOSSIP_ACTION_INFO_DEF+1) - { - ItemPosCountVec dest; - uint8 msg = player->CanStoreNewItem( NULL_BAG, NULL_SLOT, dest, 24226, 1, false); - if( msg == EQUIP_ERR_OK ) - { - player->StoreNewItem( dest, 24226, 1, true); - player->PlayerTalkClass->ClearMenus(); - } - } - return true; -} - -/*###### -## npc_budd_nedreck -######*/ - -bool GossipHello_npc_budd_nedreck(Player *player, Creature *_Creature) -{ - if( _Creature->isQuestGiver()) - player->PrepareQuestMenu( _Creature->GetGUID() ); - - if( player->GetQuestStatus(11166) == QUEST_STATUS_INCOMPLETE) - player->ADD_GOSSIP_ITEM(0,"You gave the crew disguises?",GOSSIP_SENDER_MAIN,GOSSIP_ACTION_INFO_DEF); - - player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(),_Creature->GetGUID()); - return true; -} - -bool GossipSelect_npc_budd_nedreck(Player *player, Creature *_Creature, uint32 sender, uint32 action ) -{ - if( action==GOSSIP_ACTION_INFO_DEF ) - { - player->CLOSE_GOSSIP_MENU(); - _Creature->CastSpell(player, 42540, false); - } - return true; -} - -/*###### -## npc_rathis_tomber -######*/ - -bool GossipHello_npc_rathis_tomber(Player *player, Creature *_Creature) -{ - if( _Creature->isQuestGiver() ) - player->PrepareQuestMenu( _Creature->GetGUID() ); - - if( _Creature->isVendor() && player->GetQuestRewardStatus(9152) ) - { - player->ADD_GOSSIP_ITEM(1, GOSSIP_TEXT_BROWSE_GOODS, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_TRADE); - player->SEND_GOSSIP_MENU(8432,_Creature->GetGUID()); - }else - player->SEND_GOSSIP_MENU(8431,_Creature->GetGUID()); - - return true; -} - -bool GossipSelect_npc_rathis_tomber(Player *player, Creature *_Creature, uint32 sender, uint32 action ) -{ - if( action == GOSSIP_ACTION_TRADE ) - player->SEND_VENDORLIST( _Creature->GetGUID() ); - return true; -} - -void AddSC_ghostlands() -{ - Script *newscript; - - newscript = new Script; - newscript->Name="npc_blood_knight_dawnstar"; - newscript->pGossipHello = &GossipHello_npc_blood_knight_dawnstar; - newscript->pGossipSelect = &GossipSelect_npc_blood_knight_dawnstar; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="npc_budd_nedreck"; - newscript->pGossipHello = &GossipHello_npc_budd_nedreck; - newscript->pGossipSelect = &GossipSelect_npc_budd_nedreck; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="npc_rathis_tomber"; - newscript->pGossipHello = &GossipHello_npc_rathis_tomber; - newscript->pGossipSelect = &GossipSelect_npc_rathis_tomber; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Ghostlands +SD%Complete: 100 +SDComment: Quest support: 9692. Obtain Budd's Guise of Zul'aman. Vendor Rathis Tomber +SDCategory: Ghostlands +EndScriptData */ + +/* ContentData +npc_blood_knight_dawnstar +npc_budd_nedreck +npc_rathis_tomber +EndContentData */ + +#include "precompiled.h" + +/*###### +## npc_blood_knight_dawnstar +######*/ + +bool GossipHello_npc_blood_knight_dawnstar(Player *player, Creature *_Creature) +{ + if (player->GetQuestStatus(9692) == QUEST_STATUS_INCOMPLETE && !player->HasItemCount(24226,1,true)) + player->ADD_GOSSIP_ITEM( 0, "Take Blood Knight Insignia", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); + + player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); + + return true; +} + +bool GossipSelect_npc_blood_knight_dawnstar(Player *player, Creature *_Creature, uint32 sender, uint32 action) +{ + if (action == GOSSIP_ACTION_INFO_DEF+1) + { + ItemPosCountVec dest; + uint8 msg = player->CanStoreNewItem( NULL_BAG, NULL_SLOT, dest, 24226, 1, false); + if( msg == EQUIP_ERR_OK ) + { + player->StoreNewItem( dest, 24226, 1, true); + player->PlayerTalkClass->ClearMenus(); + } + } + return true; +} + +/*###### +## npc_budd_nedreck +######*/ + +bool GossipHello_npc_budd_nedreck(Player *player, Creature *_Creature) +{ + if( _Creature->isQuestGiver()) + player->PrepareQuestMenu( _Creature->GetGUID() ); + + if( player->GetQuestStatus(11166) == QUEST_STATUS_INCOMPLETE) + player->ADD_GOSSIP_ITEM(0,"You gave the crew disguises?",GOSSIP_SENDER_MAIN,GOSSIP_ACTION_INFO_DEF); + + player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(),_Creature->GetGUID()); + return true; +} + +bool GossipSelect_npc_budd_nedreck(Player *player, Creature *_Creature, uint32 sender, uint32 action ) +{ + if( action==GOSSIP_ACTION_INFO_DEF ) + { + player->CLOSE_GOSSIP_MENU(); + _Creature->CastSpell(player, 42540, false); + } + return true; +} + +/*###### +## npc_rathis_tomber +######*/ + +bool GossipHello_npc_rathis_tomber(Player *player, Creature *_Creature) +{ + if( _Creature->isQuestGiver() ) + player->PrepareQuestMenu( _Creature->GetGUID() ); + + if( _Creature->isVendor() && player->GetQuestRewardStatus(9152) ) + { + player->ADD_GOSSIP_ITEM(1, GOSSIP_TEXT_BROWSE_GOODS, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_TRADE); + player->SEND_GOSSIP_MENU(8432,_Creature->GetGUID()); + }else + player->SEND_GOSSIP_MENU(8431,_Creature->GetGUID()); + + return true; +} + +bool GossipSelect_npc_rathis_tomber(Player *player, Creature *_Creature, uint32 sender, uint32 action ) +{ + if( action == GOSSIP_ACTION_TRADE ) + player->SEND_VENDORLIST( _Creature->GetGUID() ); + return true; +} + +void AddSC_ghostlands() +{ + Script *newscript; + + newscript = new Script; + newscript->Name="npc_blood_knight_dawnstar"; + newscript->pGossipHello = &GossipHello_npc_blood_knight_dawnstar; + newscript->pGossipSelect = &GossipSelect_npc_blood_knight_dawnstar; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="npc_budd_nedreck"; + newscript->pGossipHello = &GossipHello_npc_budd_nedreck; + newscript->pGossipSelect = &GossipSelect_npc_budd_nedreck; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="npc_rathis_tomber"; + newscript->pGossipHello = &GossipHello_npc_rathis_tomber; + newscript->pGossipSelect = &GossipSelect_npc_rathis_tomber; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/gruuls_lair/boss_gruul.cpp b/src/bindings/scripts/scripts/zone/gruuls_lair/boss_gruul.cpp index d43ac25f08c..90974ccc360 100644 --- a/src/bindings/scripts/scripts/zone/gruuls_lair/boss_gruul.cpp +++ b/src/bindings/scripts/scripts/zone/gruuls_lair/boss_gruul.cpp @@ -1,281 +1,281 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Gruul -SD%Complete: 25 -SDComment: Ground Slam seriously messed up due to core problem -SDCategory: Gruul's Lair -EndScriptData */ - -#include "precompiled.h" -#include "def_gruuls_lair.h" - -#define SPELL_GROWTH 36300 -#define SPELL_CAVE_IN 36240 -#define SPELL_GROUND_SLAM 33525 // AoE Ground Slam applying Ground Slam to everyone with a script effect (most likely the knock back, we can code it to a set knockback) -#define SPELL_SHATTER_EFFECT 33671 -#define SPELL_HURTFUL_STRIKE 33813 -#define SPELL_REVERBERATION 36297 //AoE Silence -#define SPELL_GRONN_LORDS_GRASP 33572 //Already handled in GroundSlam -#define SPELL_STONED 33652 //-- Spell is self cast -#define SPELL_SHATTER 33654 -#define SPELL_MAGNETIC_PULL 28337 -#define SPELL_KNOCK_BACK 24199 //Knockback spell until correct implementation is made - -#define EMOTE_GROW "grows in size!" -#define SAY_AGGRO "Come.... and die." - -struct MANGOS_DLL_DECL boss_gruulAI : public ScriptedAI -{ - boss_gruulAI(Creature *c) : ScriptedAI(c) { Reset(); } - - ScriptedInstance *pInstance; - - uint32 Growth_Timer; - uint32 CaveIn_Timer; - uint32 GroundSlamTimer; - uint32 GroundSlamStage; - uint32 PerformingGroundSlam; - uint32 HurtfulStrike_Timer; - uint32 Reverberation_Timer; - - void Reset() - { - pInstance = (ScriptedInstance*)m_creature->GetInstanceData(); - - Growth_Timer= 30000; - CaveIn_Timer= 40000; - GroundSlamTimer= 35000; - GroundSlamStage= 0; - PerformingGroundSlam= false; - HurtfulStrike_Timer= 8000; - Reverberation_Timer= 60000+45000; - - if(pInstance) - pInstance->SetData(DATA_GRUULEVENT, 0); - } - - void JustDied(Unit* Killer) - { - if(pInstance) - pInstance->SetData(DATA_GRUULEVENT, 1); - } - - void Aggro(Unit *who) - { - - DoYell(SAY_AGGRO,LANG_UNIVERSAL,NULL); - - if(pInstance) - pInstance->SetData(DATA_GRUULEVENT, 1); - } - - void UpdateAI(const uint32 diff) - { - //Return since we have no target - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - // Growth - // Gruul can cast this spell up to 30 times - if (Growth_Timer < diff) - { - DoCast(m_creature,SPELL_GROWTH); - DoTextEmote(EMOTE_GROW,NULL); - Growth_Timer = 30000; - }else Growth_Timer -= diff; - - if(PerformingGroundSlam) - { - if(GroundSlamTimer < diff) - { - switch(GroundSlamStage) - { - case 0: - { - //Begin the whole ordeal - std::list& m_threatlist = m_creature->getThreatManager().getThreatList(); - - std::vector knockback_targets; - - //First limit the list to only players - for(std::list::iterator itr = m_threatlist.begin(); itr!= m_threatlist.end(); ++itr) - { - Unit *target = Unit::GetUnit(*m_creature, (*itr)->getUnitGuid()); - - if(target && target->GetTypeId() == TYPEID_PLAYER) - knockback_targets.push_back(target); - } - - //Now to totally disoriend those players - for(std::vector::iterator itr = knockback_targets.begin(); itr!= knockback_targets.end(); ++itr) - { - Unit *target = *itr; - Unit *target2 = *(knockback_targets.begin() + rand()%knockback_targets.size()); - - if(target && target2) - { - switch(rand()%2) - { - case 0: target2->CastSpell(target, SPELL_MAGNETIC_PULL, true, NULL, NULL, m_creature->GetGUID()); break; - case 1: target2->CastSpell(target, SPELL_KNOCK_BACK, true, NULL, NULL, m_creature->GetGUID()); break; - } - } - } - - GroundSlamTimer = 7000; - } break; - - case 1: - { - //Players are going to get stoned - std::list& m_threatlist = m_creature->getThreatManager().getThreatList(); - - for(std::list::iterator itr = m_threatlist.begin(); itr!= m_threatlist.end(); ++itr) - { - Unit *target = Unit::GetUnit(*m_creature, (*itr)->getUnitGuid()); - - if(target) - { - target->RemoveAurasDueToSpell(SPELL_GRONN_LORDS_GRASP); - target->CastSpell(target, SPELL_STONED, true, NULL, NULL, m_creature->GetGUID()); - } - } - - GroundSlamTimer = 5000; - - } break; - - case 2: - { - //The dummy shatter spell is cast - DoCast(m_creature, SPELL_SHATTER); - - GroundSlamTimer = 1000; - - } break; - - case 3: - { - //Shatter takes effect - std::list& m_threatlist = m_creature->getThreatManager().getThreatList(); - - for(std::list::iterator itr = m_threatlist.begin(); itr!= m_threatlist.end(); ++itr) - { - Unit *target = Unit::GetUnit(*m_creature, (*itr)->getUnitGuid()); - - if(target) - { - target->RemoveAurasDueToSpell(SPELL_STONED); - - if(target->GetTypeId() == TYPEID_PLAYER) - target->CastSpell(target, SPELL_SHATTER_EFFECT, false, NULL, NULL, m_creature->GetGUID()); - } - - } - - m_creature->GetMotionMaster()->Clear(); - - Unit *victim = m_creature->getVictim(); - if(victim) - { - m_creature->GetMotionMaster()->MoveChase(victim); - m_creature->SetUInt64Value(UNIT_FIELD_TARGET, victim->GetGUID()); - } - - PerformingGroundSlam = false; - - GroundSlamTimer =120000; - HurtfulStrike_Timer= 8000; - if(Reverberation_Timer < 10000) //Give a little time to the players to undo the damage from shatter - Reverberation_Timer += 10000; - - } break; - } - - GroundSlamStage++; - } - else - GroundSlamTimer-=diff; - } - else - { - // Hurtful Strike - if (HurtfulStrike_Timer < diff) - { - Unit* target = NULL; - target = SelectUnit(SELECT_TARGET_TOPAGGRO,1); - - if (target && m_creature->IsWithinDistInMap(m_creature->getVictim(), ATTACK_DISTANCE)) - DoCast(target,SPELL_HURTFUL_STRIKE); - else - DoCast(m_creature->getVictim(),SPELL_HURTFUL_STRIKE); - - HurtfulStrike_Timer= 8000; - }else HurtfulStrike_Timer -= diff; - - // Reverberation - if (Reverberation_Timer < diff) - { - m_creature->CastSpell(m_creature->getVictim(), SPELL_REVERBERATION, true); - - Reverberation_Timer = 30000; - }else Reverberation_Timer -= diff; - - // Cave In - if (CaveIn_Timer < diff) - { - Unit* target = NULL; - target = SelectUnit(SELECT_TARGET_RANDOM,0); - - if(target) - DoCast(target,SPELL_CAVE_IN); - - CaveIn_Timer = 20000; - }else CaveIn_Timer -= diff; - - // Ground Slam, Gronn Lord's Grasp, Stoned, Shatter - if (GroundSlamTimer < diff) - { - m_creature->GetMotionMaster()->Clear(); - m_creature->GetMotionMaster()->MoveIdle(); - m_creature->SetUInt64Value(UNIT_FIELD_TARGET, 0); - - PerformingGroundSlam= true; - GroundSlamTimer = 0; - GroundSlamStage = 0; - DoCast(m_creature->getVictim(), SPELL_GROUND_SLAM); - } else GroundSlamTimer -=diff; - - DoMeleeAttackIfReady(); - } - } -}; - -CreatureAI* GetAI_boss_gruul(Creature *_Creature) -{ - return new boss_gruulAI (_Creature); -} - -void AddSC_boss_gruul() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_gruul"; - newscript->GetAI = GetAI_boss_gruul; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Gruul +SD%Complete: 25 +SDComment: Ground Slam seriously messed up due to core problem +SDCategory: Gruul's Lair +EndScriptData */ + +#include "precompiled.h" +#include "def_gruuls_lair.h" + +#define SPELL_GROWTH 36300 +#define SPELL_CAVE_IN 36240 +#define SPELL_GROUND_SLAM 33525 // AoE Ground Slam applying Ground Slam to everyone with a script effect (most likely the knock back, we can code it to a set knockback) +#define SPELL_SHATTER_EFFECT 33671 +#define SPELL_HURTFUL_STRIKE 33813 +#define SPELL_REVERBERATION 36297 //AoE Silence +#define SPELL_GRONN_LORDS_GRASP 33572 //Already handled in GroundSlam +#define SPELL_STONED 33652 //-- Spell is self cast +#define SPELL_SHATTER 33654 +#define SPELL_MAGNETIC_PULL 28337 +#define SPELL_KNOCK_BACK 24199 //Knockback spell until correct implementation is made + +#define EMOTE_GROW "grows in size!" +#define SAY_AGGRO "Come.... and die." + +struct MANGOS_DLL_DECL boss_gruulAI : public ScriptedAI +{ + boss_gruulAI(Creature *c) : ScriptedAI(c) { Reset(); } + + ScriptedInstance *pInstance; + + uint32 Growth_Timer; + uint32 CaveIn_Timer; + uint32 GroundSlamTimer; + uint32 GroundSlamStage; + uint32 PerformingGroundSlam; + uint32 HurtfulStrike_Timer; + uint32 Reverberation_Timer; + + void Reset() + { + pInstance = (ScriptedInstance*)m_creature->GetInstanceData(); + + Growth_Timer= 30000; + CaveIn_Timer= 40000; + GroundSlamTimer= 35000; + GroundSlamStage= 0; + PerformingGroundSlam= false; + HurtfulStrike_Timer= 8000; + Reverberation_Timer= 60000+45000; + + if(pInstance) + pInstance->SetData(DATA_GRUULEVENT, 0); + } + + void JustDied(Unit* Killer) + { + if(pInstance) + pInstance->SetData(DATA_GRUULEVENT, 1); + } + + void Aggro(Unit *who) + { + + DoYell(SAY_AGGRO,LANG_UNIVERSAL,NULL); + + if(pInstance) + pInstance->SetData(DATA_GRUULEVENT, 1); + } + + void UpdateAI(const uint32 diff) + { + //Return since we have no target + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + // Growth + // Gruul can cast this spell up to 30 times + if (Growth_Timer < diff) + { + DoCast(m_creature,SPELL_GROWTH); + DoTextEmote(EMOTE_GROW,NULL); + Growth_Timer = 30000; + }else Growth_Timer -= diff; + + if(PerformingGroundSlam) + { + if(GroundSlamTimer < diff) + { + switch(GroundSlamStage) + { + case 0: + { + //Begin the whole ordeal + std::list& m_threatlist = m_creature->getThreatManager().getThreatList(); + + std::vector knockback_targets; + + //First limit the list to only players + for(std::list::iterator itr = m_threatlist.begin(); itr!= m_threatlist.end(); ++itr) + { + Unit *target = Unit::GetUnit(*m_creature, (*itr)->getUnitGuid()); + + if(target && target->GetTypeId() == TYPEID_PLAYER) + knockback_targets.push_back(target); + } + + //Now to totally disoriend those players + for(std::vector::iterator itr = knockback_targets.begin(); itr!= knockback_targets.end(); ++itr) + { + Unit *target = *itr; + Unit *target2 = *(knockback_targets.begin() + rand()%knockback_targets.size()); + + if(target && target2) + { + switch(rand()%2) + { + case 0: target2->CastSpell(target, SPELL_MAGNETIC_PULL, true, NULL, NULL, m_creature->GetGUID()); break; + case 1: target2->CastSpell(target, SPELL_KNOCK_BACK, true, NULL, NULL, m_creature->GetGUID()); break; + } + } + } + + GroundSlamTimer = 7000; + } break; + + case 1: + { + //Players are going to get stoned + std::list& m_threatlist = m_creature->getThreatManager().getThreatList(); + + for(std::list::iterator itr = m_threatlist.begin(); itr!= m_threatlist.end(); ++itr) + { + Unit *target = Unit::GetUnit(*m_creature, (*itr)->getUnitGuid()); + + if(target) + { + target->RemoveAurasDueToSpell(SPELL_GRONN_LORDS_GRASP); + target->CastSpell(target, SPELL_STONED, true, NULL, NULL, m_creature->GetGUID()); + } + } + + GroundSlamTimer = 5000; + + } break; + + case 2: + { + //The dummy shatter spell is cast + DoCast(m_creature, SPELL_SHATTER); + + GroundSlamTimer = 1000; + + } break; + + case 3: + { + //Shatter takes effect + std::list& m_threatlist = m_creature->getThreatManager().getThreatList(); + + for(std::list::iterator itr = m_threatlist.begin(); itr!= m_threatlist.end(); ++itr) + { + Unit *target = Unit::GetUnit(*m_creature, (*itr)->getUnitGuid()); + + if(target) + { + target->RemoveAurasDueToSpell(SPELL_STONED); + + if(target->GetTypeId() == TYPEID_PLAYER) + target->CastSpell(target, SPELL_SHATTER_EFFECT, false, NULL, NULL, m_creature->GetGUID()); + } + + } + + m_creature->GetMotionMaster()->Clear(); + + Unit *victim = m_creature->getVictim(); + if(victim) + { + m_creature->GetMotionMaster()->MoveChase(victim); + m_creature->SetUInt64Value(UNIT_FIELD_TARGET, victim->GetGUID()); + } + + PerformingGroundSlam = false; + + GroundSlamTimer =120000; + HurtfulStrike_Timer= 8000; + if(Reverberation_Timer < 10000) //Give a little time to the players to undo the damage from shatter + Reverberation_Timer += 10000; + + } break; + } + + GroundSlamStage++; + } + else + GroundSlamTimer-=diff; + } + else + { + // Hurtful Strike + if (HurtfulStrike_Timer < diff) + { + Unit* target = NULL; + target = SelectUnit(SELECT_TARGET_TOPAGGRO,1); + + if (target && m_creature->IsWithinDistInMap(m_creature->getVictim(), ATTACK_DISTANCE)) + DoCast(target,SPELL_HURTFUL_STRIKE); + else + DoCast(m_creature->getVictim(),SPELL_HURTFUL_STRIKE); + + HurtfulStrike_Timer= 8000; + }else HurtfulStrike_Timer -= diff; + + // Reverberation + if (Reverberation_Timer < diff) + { + m_creature->CastSpell(m_creature->getVictim(), SPELL_REVERBERATION, true); + + Reverberation_Timer = 30000; + }else Reverberation_Timer -= diff; + + // Cave In + if (CaveIn_Timer < diff) + { + Unit* target = NULL; + target = SelectUnit(SELECT_TARGET_RANDOM,0); + + if(target) + DoCast(target,SPELL_CAVE_IN); + + CaveIn_Timer = 20000; + }else CaveIn_Timer -= diff; + + // Ground Slam, Gronn Lord's Grasp, Stoned, Shatter + if (GroundSlamTimer < diff) + { + m_creature->GetMotionMaster()->Clear(); + m_creature->GetMotionMaster()->MoveIdle(); + m_creature->SetUInt64Value(UNIT_FIELD_TARGET, 0); + + PerformingGroundSlam= true; + GroundSlamTimer = 0; + GroundSlamStage = 0; + DoCast(m_creature->getVictim(), SPELL_GROUND_SLAM); + } else GroundSlamTimer -=diff; + + DoMeleeAttackIfReady(); + } + } +}; + +CreatureAI* GetAI_boss_gruul(Creature *_Creature) +{ + return new boss_gruulAI (_Creature); +} + +void AddSC_boss_gruul() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_gruul"; + newscript->GetAI = GetAI_boss_gruul; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/gruuls_lair/boss_high_king_maulgar.cpp b/src/bindings/scripts/scripts/zone/gruuls_lair/boss_high_king_maulgar.cpp index e69a46104d3..59edbd5a05b 100644 --- a/src/bindings/scripts/scripts/zone/gruuls_lair/boss_high_king_maulgar.cpp +++ b/src/bindings/scripts/scripts/zone/gruuls_lair/boss_high_king_maulgar.cpp @@ -1,687 +1,687 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_High_King_Maulgar -SD%Complete: 80 -SDComment: Verify that the script is working properly -SDCategory: Gruul's Lair -EndScriptData */ - -#include "precompiled.h" -#include "def_gruuls_lair.h" - -#define SOUND_AGGRO 11367 //"Gronn are the real power in outland." - -#define SOUND_ENRAGE 11368 //"You will not defeat the hand of Gruul!" - -#define SOUND_OGRE_DEATH1 11369 //"You won't kill next one so easy!" -#define SOUND_OGRE_DEATH2 11370 //"Pah! Does not prove anything!" -#define SOUND_OGRE_DEATH3 11371 //"I'm not afraid of you." -#define SOUND_OGRE_DEATH4 11372 //"Good, now you fight me!" - -#define SOUND_SLAY1 11373 //"You not so tough afterall!" -#define SOUND_SLAY2 11374 //"Aha ha ha ha!" -#define SOUND_SLAY3 11375 //"Mulgar is king!" - -#define SOUND_DEATH 11376 //"Gruul ...will crush you..." - -// High King Maulgar -#define SPELL_ARCING_SMASH 39144 -#define SPELL_MIGHTY_BLOW 33230 -#define SPELL_WHIRLWIND 33238 -#define SPELL_ENRAGE 34970 - -// Council spells -#define SPELL_DARK_DECAY 33129 -#define SPELL_GREATER_POLYMORPH 33173 -#define SPELL_LIGHTNING_BOLT 36152 -#define SPELL_ARCANE_SHOCK 33175 -#define SPELL_ARCANE_EXPLOSION 33237 -#define SPELL_GREATER_PW_SHIELD 33147 -#define SPELL_HEAL 33144 -#define SPELL_GREATER_FIREBALL 33051 -#define SPELL_SPELLSHIELD 33054 -#define SPELL_BLAST_WAVE 33061 - -//High King Maulgar AI -struct MANGOS_DLL_DECL boss_high_king_maulgarAI : public ScriptedAI -{ - boss_high_king_maulgarAI(Creature *c) : ScriptedAI(c) - { - pInstance = ((ScriptedInstance*)c->GetInstanceData()); - for(uint8 i = 0; i < 4; ++i) - Council[i] = 0; - Reset(); - } - - ScriptedInstance* pInstance; - - uint32 ArcingSmash_Timer; - uint32 MightyBlow_Timer; - uint32 Whirlwind_Timer; - uint32 Charging_Timer; - - bool Phase2; - - uint64 Council[4]; - - void Reset() - { - ArcingSmash_Timer = 10000; - MightyBlow_Timer = 40000; - Whirlwind_Timer = 30000; - Charging_Timer = 0; - Phase2 = false; - - Creature *pCreature = NULL; - for(uint8 i = 0; i < 4; i++) - { - if(Council[i]) - { - pCreature = (Creature*)(Unit::GetUnit((*m_creature), Council[i])); - if(pCreature && !pCreature->isAlive()) - { - pCreature->Respawn(); - pCreature->AI()->EnterEvadeMode(); - } - } - } - - //reset encounter - if (pInstance) - pInstance->SetData(DATA_MAULGAREVENT, 0); - } - - void KilledUnit() - { - switch(rand()%2) - { - case 0: DoPlaySoundToSet(m_creature, SOUND_SLAY1); break; - case 1: DoPlaySoundToSet(m_creature, SOUND_SLAY2); break; - case 2: DoPlaySoundToSet(m_creature, SOUND_SLAY3); break; - } - } - - void JustDied(Unit* Killer) - { - DoPlaySoundToSet(m_creature, SOUND_DEATH); - - if (pInstance) - pInstance->SetData(DATA_MAULGAREVENT, 0); - } - - void Aggro(Unit *who) { StartEvent(who); } - - void GetCouncil() - { - //get council member's guid to respawn them if needed - Council[0] = pInstance->GetData64(DATA_KIGGLERTHECRAZED); - Council[1] = pInstance->GetData64(DATA_BLINDEYETHESEER); - Council[2] = pInstance->GetData64(DATA_OLMTHESUMMONER); - Council[3] = pInstance->GetData64(DATA_KROSHFIREHAND); - } - - void StartEvent(Unit *who) - { - if(!pInstance) - return; - - GetCouncil(); - - DoPlaySoundToSet(m_creature, SOUND_AGGRO); - - pInstance->SetData64(DATA_MAULGAREVENT_TANK, who->GetGUID()); - pInstance->SetData(DATA_MAULGAREVENT, 1); - } - - void UpdateAI(const uint32 diff) - { - //Only if not incombat check if the event is started - if(!InCombat && pInstance && pInstance->GetData(DATA_MAULGAREVENT)) - { - Unit* target = Unit::GetUnit((*m_creature), pInstance->GetData64(DATA_MAULGAREVENT_TANK)); - - if(target) - { - DoStartAttackAndMovement(target); - - GetCouncil(); - - DoPlaySoundToSet(m_creature, SOUND_AGGRO); - } - } - - //Return since we have no target - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - //someone evaded! - if(pInstance && !pInstance->GetData(DATA_MAULGAREVENT)) - EnterEvadeMode(); - - //ArcingSmash_Timer - if (ArcingSmash_Timer < diff) - { - DoCast(m_creature->getVictim(), SPELL_ARCING_SMASH); - ArcingSmash_Timer = 10000; - }else ArcingSmash_Timer -= diff; - - //Whirlwind_Timer - if (Whirlwind_Timer < diff) - { - DoCast(m_creature->getVictim(), SPELL_WHIRLWIND); - Whirlwind_Timer = 55000; - }else Whirlwind_Timer -= diff; - - //MightyBlow_Timer - if (MightyBlow_Timer < diff) - { - DoCast(m_creature->getVictim(), SPELL_MIGHTY_BLOW); - MightyBlow_Timer = 30000+rand()%10000; - }else MightyBlow_Timer -= diff; - - //Entering Phase 2 - if(!Phase2 && (m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < 50) - { - Phase2 = true; - DoPlaySoundToSet(m_creature, SOUND_ENRAGE); - } - - if(Phase2) - { - //Charging_Timer - if(Charging_Timer < diff) - { - Unit* target = NULL; - target = SelectUnit(SELECT_TARGET_RANDOM, 0); - if(target) - DoStartAttackAndMovement(target); - - Charging_Timer = 20000; - }else Charging_Timer -= diff; - } - - DoMeleeAttackIfReady(); - } -}; - -//Olm The Summoner AI -struct MANGOS_DLL_DECL boss_olm_the_summonerAI : public ScriptedAI -{ - boss_olm_the_summonerAI(Creature *c) : ScriptedAI(c) - { - pInstance = ((ScriptedInstance*)c->GetInstanceData()); - Reset(); - } - - uint32 DarkDecay_Timer; - uint32 Summon_Timer; - - ScriptedInstance* pInstance; - - void Reset() - { - DarkDecay_Timer = 10000; - Summon_Timer = 15000; - - //reset encounter - if (pInstance) - pInstance->SetData(DATA_MAULGAREVENT, 0); - } - - void Aggro(Unit *who) - { - if(pInstance) - { - pInstance->SetData64(DATA_MAULGAREVENT_TANK, who->GetGUID()); - pInstance->SetData(DATA_MAULGAREVENT, 1); - } - } - - float DoCalculateRandomLocation() - { - float Loc; - float Rand = rand()%8; - - switch(rand()%2) - { - case 0: Loc = 0 + Rand; break; - case 1: Loc = 0 - Rand; break; - } - return Loc; - } - - void UpdateAI(const uint32 diff) - { - //Only if not incombat check if the event is started - if(!InCombat && pInstance && pInstance->GetData(DATA_MAULGAREVENT)) - { - Unit* target = Unit::GetUnit((*m_creature), pInstance->GetData64(DATA_MAULGAREVENT_TANK)); - - if(target) - { - DoStartAttackAndMovement(target); - } - } - - //Return since we have no target - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - //someone evaded! - if(pInstance && !pInstance->GetData(DATA_MAULGAREVENT)) - EnterEvadeMode(); - - //DarkDecay_Timer - if(DarkDecay_Timer < diff) - { - DoCast(m_creature->getVictim(), SPELL_DARK_DECAY); - DarkDecay_Timer = 20000; - }else DarkDecay_Timer -= diff; - - //Summon_Timer - if(Summon_Timer < diff) - { - Creature *Add = NULL; - Add = DoSpawnCreature(18847, DoCalculateRandomLocation(), DoCalculateRandomLocation(), 0, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000); - Summon_Timer = 30000; - }else Summon_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; - -//Kiggler The Crazed AI -struct MANGOS_DLL_DECL boss_kiggler_the_crazedAI : public ScriptedAI -{ - boss_kiggler_the_crazedAI(Creature *c) : ScriptedAI(c) - { - pInstance = ((ScriptedInstance*)c->GetInstanceData()); - Reset(); - } - - uint32 GreatherPolymorph_Timer; - uint32 LightningBolt_Timer; - uint32 ArcaneShock_Timer; - uint32 ArcaneExplosion_Timer; - - ScriptedInstance* pInstance; - - void Reset() - { - GreatherPolymorph_Timer = 5000; - LightningBolt_Timer = 10000; - ArcaneShock_Timer = 20000; - ArcaneExplosion_Timer = 30000; - - //reset encounter - if (pInstance) - pInstance->SetData(DATA_MAULGAREVENT, 0); - } - - void Aggro(Unit *who) - { - if(pInstance) - { - pInstance->SetData64(DATA_MAULGAREVENT_TANK, who->GetGUID()); - pInstance->SetData(DATA_MAULGAREVENT, 1); - } - } - - void MoveInLineOfSight(Unit *who) - { - if (!who || m_creature->getVictim()) - return; - - if (who->isTargetableForAttack() && who->isInAccessablePlaceFor(m_creature) && m_creature->IsHostileTo(who)) - { - float attackRadius = m_creature->GetAttackDistance(who); - if (m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->GetDistanceZ(who) <= CREATURE_Z_ATTACK_RANGE && m_creature->IsWithinLOSInMap(who)) - { - if(who->HasStealthAura()) - who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); - - if(!InCombat) - { - DoStartAttackAndMovement(who); - if(pInstance) - { - pInstance->SetData64(DATA_MAULGAREVENT_TANK, who->GetGUID()); - pInstance->SetData(DATA_MAULGAREVENT, 1); - } - } - } - } - } - - void UpdateAI(const uint32 diff) - { - //Only if not incombat check if the event is started - if(!InCombat && pInstance && pInstance->GetData(DATA_MAULGAREVENT)) - { - Unit* target = Unit::GetUnit((*m_creature), pInstance->GetData64(DATA_MAULGAREVENT_TANK)); - - if(target) - { - DoStartAttackAndMovement(target); - } - } - - //Return since we have no target - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - //someone evaded! - if(pInstance && !pInstance->GetData(DATA_MAULGAREVENT)) - EnterEvadeMode(); - - //GreaterPolymorph_Timer / disabled: it makes you fall under the texture / if you've got vmaps feel free to uncomment this - /*if(GreaterPolymorph_Timer < diff) - { - Unit *target = SelectUnit(SELECT_TARGET_RANDOM, 0); - if(target) - DoCast(target, SPELL_GREATER_POLYMORPH); - - GreaterPolymorph_Timer = 20000; - }else GreaterPolymorph_Timer -= diff;*/ - - //LightningBolt_Timer - if(LightningBolt_Timer < diff) - { - DoCast(m_creature->getVictim(), SPELL_LIGHTNING_BOLT); - LightningBolt_Timer = 15000; - }else LightningBolt_Timer -= diff; - - //ArcaneShock_Timer - if(ArcaneShock_Timer < diff) - { - DoCast(m_creature->getVictim(), SPELL_ARCANE_SHOCK); - ArcaneShock_Timer = 20000; - }else ArcaneShock_Timer -= diff; - - //ArcaneExplosion_Timer - if(ArcaneExplosion_Timer < diff) - { - DoCast(m_creature->getVictim(), SPELL_ARCANE_EXPLOSION); - ArcaneExplosion_Timer = 30000; - }else ArcaneExplosion_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; - -//Blindeye The Seer AI -struct MANGOS_DLL_DECL boss_blindeye_the_seerAI : public ScriptedAI -{ - boss_blindeye_the_seerAI(Creature *c) : ScriptedAI(c) - { - pInstance = ((ScriptedInstance*)c->GetInstanceData()); - Reset(); - } - - uint32 GreaterPowerWordShield_Timer; - uint32 Heal_Timer; - - ScriptedInstance* pInstance; - - void Reset() - { - GreaterPowerWordShield_Timer = 5000; - Heal_Timer = 30000; - - //reset encounter - if (pInstance) - pInstance->SetData(DATA_MAULGAREVENT, 0); - } - - void Aggro(Unit *who) - { - if(pInstance) - { - pInstance->SetData64(DATA_MAULGAREVENT_TANK, who->GetGUID()); - pInstance->SetData(DATA_MAULGAREVENT, 1); - } - } - - void MoveInLineOfSight(Unit *who) - { - if (!who || m_creature->getVictim()) - return; - - if (who->isTargetableForAttack() && who->isInAccessablePlaceFor(m_creature) && m_creature->IsHostileTo(who)) - { - float attackRadius = m_creature->GetAttackDistance(who); - if (m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->GetDistanceZ(who) <= CREATURE_Z_ATTACK_RANGE && m_creature->IsWithinLOSInMap(who)) - { - if(who->HasStealthAura()) - who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); - - if(!InCombat) - { - DoStartAttackAndMovement(who); - if(pInstance) - { - pInstance->SetData64(DATA_MAULGAREVENT_TANK, who->GetGUID()); - pInstance->SetData(DATA_MAULGAREVENT, 1); - } - } - } - } - } - - void UpdateAI(const uint32 diff) - { - //Only if not incombat check if the event is started - if(!InCombat && pInstance && pInstance->GetData(DATA_MAULGAREVENT)) - { - Unit* target = Unit::GetUnit((*m_creature), pInstance->GetData64(DATA_MAULGAREVENT_TANK)); - - if(target) - { - DoStartAttackAndMovement(target); - } - } - - //Return since we have no target - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - //someone evaded! - if(pInstance && !pInstance->GetData(DATA_MAULGAREVENT)) - EnterEvadeMode(); - - //GreaterPowerWordShield_Timer - if(GreaterPowerWordShield_Timer < diff) - { - DoCast(m_creature, SPELL_GREATER_PW_SHIELD); - GreaterPowerWordShield_Timer = 40000; - }else GreaterPowerWordShield_Timer -= diff; - - //Heal_Timer - if(Heal_Timer < diff) - { - DoCast(m_creature, SPELL_HEAL); - Heal_Timer = 60000; - }else Heal_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; - -//Krosh Firehand AI -struct MANGOS_DLL_DECL boss_krosh_firehandAI : public ScriptedAI -{ - boss_krosh_firehandAI(Creature *c) : ScriptedAI(c) - { - pInstance = ((ScriptedInstance*)c->GetInstanceData()); - Reset(); - } - - uint32 GreaterFireball_Timer; - uint32 SpellShield_Timer; - uint32 BlastWave_Timer; - - ScriptedInstance* pInstance; - - void Reset() - { - GreaterFireball_Timer = 1000; - SpellShield_Timer = 5000; - BlastWave_Timer = 20000; - - //reset encounter - if (pInstance) - pInstance->SetData(DATA_MAULGAREVENT, 0); - } - - void Aggro(Unit *who) - { - if(pInstance) - { - pInstance->SetData64(DATA_MAULGAREVENT_TANK, who->GetGUID()); - pInstance->SetData(DATA_MAULGAREVENT, 1); - } - } - - void MoveInLineOfSight(Unit *who) - { - if (!who || m_creature->getVictim()) - return; - - if (who->isTargetableForAttack() && who->isInAccessablePlaceFor(m_creature) && m_creature->IsHostileTo(who)) - { - float attackRadius = m_creature->GetAttackDistance(who); - if (m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->GetDistanceZ(who) <= CREATURE_Z_ATTACK_RANGE && m_creature->IsWithinLOSInMap(who)) - { - if(who->HasStealthAura()) - who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); - - if(!InCombat) - { - DoStartAttackAndMovement(who); - if(pInstance) - { - pInstance->SetData64(DATA_MAULGAREVENT_TANK, who->GetGUID()); - pInstance->SetData(DATA_MAULGAREVENT, 1); - } - } - } - } - } - - void UpdateAI(const uint32 diff) - { - //Only if not incombat check if the event is started - if(!InCombat && pInstance && pInstance->GetData(DATA_MAULGAREVENT)) - { - Unit* target = Unit::GetUnit((*m_creature), pInstance->GetData64(DATA_MAULGAREVENT_TANK)); - - if(target) - { - DoStartAttackAndMovement(target); - } - } - - //Return since we have no target - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - //someone evaded! - if(pInstance && !pInstance->GetData(DATA_MAULGAREVENT)) - EnterEvadeMode(); - - //GreaterFireball_Timer - if(GreaterFireball_Timer < diff) - { - DoCast(m_creature->getVictim(), SPELL_GREATER_FIREBALL); - GreaterFireball_Timer = 2000; - }else GreaterFireball_Timer -= diff; - - //SpellShield_Timer - if(SpellShield_Timer < diff) - { - m_creature->InterruptNonMeleeSpells(false); - DoCast(m_creature->getVictim(), SPELL_SPELLSHIELD); - SpellShield_Timer = 30000; - }else SpellShield_Timer -= diff; - - //BlastWave_Timer - if(BlastWave_Timer < diff) - { - m_creature->InterruptNonMeleeSpells(false); - DoCast(m_creature->getVictim(), SPELL_BLAST_WAVE); - BlastWave_Timer = 60000; - }else BlastWave_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; - -CreatureAI* GetAI_boss_high_king_maulgar(Creature *_Creature) -{ - return new boss_high_king_maulgarAI (_Creature); -} - -CreatureAI* GetAI_boss_olm_the_summoner(Creature *_Creature) -{ - return new boss_olm_the_summonerAI (_Creature); -} - -CreatureAI *GetAI_boss_kiggler_the_crazed(Creature *_Creature) -{ - return new boss_kiggler_the_crazedAI (_Creature); -} - -CreatureAI *GetAI_boss_blindeye_the_seer(Creature *_Creature) -{ - return new boss_blindeye_the_seerAI (_Creature); -} - -CreatureAI *GetAI_boss_krosh_firehand(Creature *_Creature) -{ - return new boss_krosh_firehandAI (_Creature); -} - -void AddSC_boss_high_king_maulgar() -{ - Script *newscript; - - newscript = new Script; - newscript->Name="boss_high_king_maulgar"; - newscript->GetAI = GetAI_boss_high_king_maulgar; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="boss_kiggler_the_crazed"; - newscript->GetAI = GetAI_boss_kiggler_the_crazed; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="boss_blindeye_the_seer"; - newscript->GetAI = GetAI_boss_blindeye_the_seer; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="boss_olm_the_summoner"; - newscript->GetAI = GetAI_boss_olm_the_summoner; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="boss_krosh_firehand"; - newscript->GetAI = GetAI_boss_krosh_firehand; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_High_King_Maulgar +SD%Complete: 80 +SDComment: Verify that the script is working properly +SDCategory: Gruul's Lair +EndScriptData */ + +#include "precompiled.h" +#include "def_gruuls_lair.h" + +#define SOUND_AGGRO 11367 //"Gronn are the real power in outland." + +#define SOUND_ENRAGE 11368 //"You will not defeat the hand of Gruul!" + +#define SOUND_OGRE_DEATH1 11369 //"You won't kill next one so easy!" +#define SOUND_OGRE_DEATH2 11370 //"Pah! Does not prove anything!" +#define SOUND_OGRE_DEATH3 11371 //"I'm not afraid of you." +#define SOUND_OGRE_DEATH4 11372 //"Good, now you fight me!" + +#define SOUND_SLAY1 11373 //"You not so tough afterall!" +#define SOUND_SLAY2 11374 //"Aha ha ha ha!" +#define SOUND_SLAY3 11375 //"Mulgar is king!" + +#define SOUND_DEATH 11376 //"Gruul ...will crush you..." + +// High King Maulgar +#define SPELL_ARCING_SMASH 39144 +#define SPELL_MIGHTY_BLOW 33230 +#define SPELL_WHIRLWIND 33238 +#define SPELL_ENRAGE 34970 + +// Council spells +#define SPELL_DARK_DECAY 33129 +#define SPELL_GREATER_POLYMORPH 33173 +#define SPELL_LIGHTNING_BOLT 36152 +#define SPELL_ARCANE_SHOCK 33175 +#define SPELL_ARCANE_EXPLOSION 33237 +#define SPELL_GREATER_PW_SHIELD 33147 +#define SPELL_HEAL 33144 +#define SPELL_GREATER_FIREBALL 33051 +#define SPELL_SPELLSHIELD 33054 +#define SPELL_BLAST_WAVE 33061 + +//High King Maulgar AI +struct MANGOS_DLL_DECL boss_high_king_maulgarAI : public ScriptedAI +{ + boss_high_king_maulgarAI(Creature *c) : ScriptedAI(c) + { + pInstance = ((ScriptedInstance*)c->GetInstanceData()); + for(uint8 i = 0; i < 4; ++i) + Council[i] = 0; + Reset(); + } + + ScriptedInstance* pInstance; + + uint32 ArcingSmash_Timer; + uint32 MightyBlow_Timer; + uint32 Whirlwind_Timer; + uint32 Charging_Timer; + + bool Phase2; + + uint64 Council[4]; + + void Reset() + { + ArcingSmash_Timer = 10000; + MightyBlow_Timer = 40000; + Whirlwind_Timer = 30000; + Charging_Timer = 0; + Phase2 = false; + + Creature *pCreature = NULL; + for(uint8 i = 0; i < 4; i++) + { + if(Council[i]) + { + pCreature = (Creature*)(Unit::GetUnit((*m_creature), Council[i])); + if(pCreature && !pCreature->isAlive()) + { + pCreature->Respawn(); + pCreature->AI()->EnterEvadeMode(); + } + } + } + + //reset encounter + if (pInstance) + pInstance->SetData(DATA_MAULGAREVENT, 0); + } + + void KilledUnit() + { + switch(rand()%2) + { + case 0: DoPlaySoundToSet(m_creature, SOUND_SLAY1); break; + case 1: DoPlaySoundToSet(m_creature, SOUND_SLAY2); break; + case 2: DoPlaySoundToSet(m_creature, SOUND_SLAY3); break; + } + } + + void JustDied(Unit* Killer) + { + DoPlaySoundToSet(m_creature, SOUND_DEATH); + + if (pInstance) + pInstance->SetData(DATA_MAULGAREVENT, 0); + } + + void Aggro(Unit *who) { StartEvent(who); } + + void GetCouncil() + { + //get council member's guid to respawn them if needed + Council[0] = pInstance->GetData64(DATA_KIGGLERTHECRAZED); + Council[1] = pInstance->GetData64(DATA_BLINDEYETHESEER); + Council[2] = pInstance->GetData64(DATA_OLMTHESUMMONER); + Council[3] = pInstance->GetData64(DATA_KROSHFIREHAND); + } + + void StartEvent(Unit *who) + { + if(!pInstance) + return; + + GetCouncil(); + + DoPlaySoundToSet(m_creature, SOUND_AGGRO); + + pInstance->SetData64(DATA_MAULGAREVENT_TANK, who->GetGUID()); + pInstance->SetData(DATA_MAULGAREVENT, 1); + } + + void UpdateAI(const uint32 diff) + { + //Only if not incombat check if the event is started + if(!InCombat && pInstance && pInstance->GetData(DATA_MAULGAREVENT)) + { + Unit* target = Unit::GetUnit((*m_creature), pInstance->GetData64(DATA_MAULGAREVENT_TANK)); + + if(target) + { + DoStartAttackAndMovement(target); + + GetCouncil(); + + DoPlaySoundToSet(m_creature, SOUND_AGGRO); + } + } + + //Return since we have no target + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + //someone evaded! + if(pInstance && !pInstance->GetData(DATA_MAULGAREVENT)) + EnterEvadeMode(); + + //ArcingSmash_Timer + if (ArcingSmash_Timer < diff) + { + DoCast(m_creature->getVictim(), SPELL_ARCING_SMASH); + ArcingSmash_Timer = 10000; + }else ArcingSmash_Timer -= diff; + + //Whirlwind_Timer + if (Whirlwind_Timer < diff) + { + DoCast(m_creature->getVictim(), SPELL_WHIRLWIND); + Whirlwind_Timer = 55000; + }else Whirlwind_Timer -= diff; + + //MightyBlow_Timer + if (MightyBlow_Timer < diff) + { + DoCast(m_creature->getVictim(), SPELL_MIGHTY_BLOW); + MightyBlow_Timer = 30000+rand()%10000; + }else MightyBlow_Timer -= diff; + + //Entering Phase 2 + if(!Phase2 && (m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < 50) + { + Phase2 = true; + DoPlaySoundToSet(m_creature, SOUND_ENRAGE); + } + + if(Phase2) + { + //Charging_Timer + if(Charging_Timer < diff) + { + Unit* target = NULL; + target = SelectUnit(SELECT_TARGET_RANDOM, 0); + if(target) + DoStartAttackAndMovement(target); + + Charging_Timer = 20000; + }else Charging_Timer -= diff; + } + + DoMeleeAttackIfReady(); + } +}; + +//Olm The Summoner AI +struct MANGOS_DLL_DECL boss_olm_the_summonerAI : public ScriptedAI +{ + boss_olm_the_summonerAI(Creature *c) : ScriptedAI(c) + { + pInstance = ((ScriptedInstance*)c->GetInstanceData()); + Reset(); + } + + uint32 DarkDecay_Timer; + uint32 Summon_Timer; + + ScriptedInstance* pInstance; + + void Reset() + { + DarkDecay_Timer = 10000; + Summon_Timer = 15000; + + //reset encounter + if (pInstance) + pInstance->SetData(DATA_MAULGAREVENT, 0); + } + + void Aggro(Unit *who) + { + if(pInstance) + { + pInstance->SetData64(DATA_MAULGAREVENT_TANK, who->GetGUID()); + pInstance->SetData(DATA_MAULGAREVENT, 1); + } + } + + float DoCalculateRandomLocation() + { + float Loc; + float Rand = rand()%8; + + switch(rand()%2) + { + case 0: Loc = 0 + Rand; break; + case 1: Loc = 0 - Rand; break; + } + return Loc; + } + + void UpdateAI(const uint32 diff) + { + //Only if not incombat check if the event is started + if(!InCombat && pInstance && pInstance->GetData(DATA_MAULGAREVENT)) + { + Unit* target = Unit::GetUnit((*m_creature), pInstance->GetData64(DATA_MAULGAREVENT_TANK)); + + if(target) + { + DoStartAttackAndMovement(target); + } + } + + //Return since we have no target + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + //someone evaded! + if(pInstance && !pInstance->GetData(DATA_MAULGAREVENT)) + EnterEvadeMode(); + + //DarkDecay_Timer + if(DarkDecay_Timer < diff) + { + DoCast(m_creature->getVictim(), SPELL_DARK_DECAY); + DarkDecay_Timer = 20000; + }else DarkDecay_Timer -= diff; + + //Summon_Timer + if(Summon_Timer < diff) + { + Creature *Add = NULL; + Add = DoSpawnCreature(18847, DoCalculateRandomLocation(), DoCalculateRandomLocation(), 0, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000); + Summon_Timer = 30000; + }else Summon_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; + +//Kiggler The Crazed AI +struct MANGOS_DLL_DECL boss_kiggler_the_crazedAI : public ScriptedAI +{ + boss_kiggler_the_crazedAI(Creature *c) : ScriptedAI(c) + { + pInstance = ((ScriptedInstance*)c->GetInstanceData()); + Reset(); + } + + uint32 GreatherPolymorph_Timer; + uint32 LightningBolt_Timer; + uint32 ArcaneShock_Timer; + uint32 ArcaneExplosion_Timer; + + ScriptedInstance* pInstance; + + void Reset() + { + GreatherPolymorph_Timer = 5000; + LightningBolt_Timer = 10000; + ArcaneShock_Timer = 20000; + ArcaneExplosion_Timer = 30000; + + //reset encounter + if (pInstance) + pInstance->SetData(DATA_MAULGAREVENT, 0); + } + + void Aggro(Unit *who) + { + if(pInstance) + { + pInstance->SetData64(DATA_MAULGAREVENT_TANK, who->GetGUID()); + pInstance->SetData(DATA_MAULGAREVENT, 1); + } + } + + void MoveInLineOfSight(Unit *who) + { + if (!m_creature->getVictim() && who->isTargetableForAttack() && who->isInAccessablePlaceFor(m_creature) && m_creature->IsHostileTo(who)) + { + if (!m_creature->canFly() && m_creature->GetDistanceZ(who) > CREATURE_Z_ATTACK_RANGE) + return; + + float attackRadius = m_creature->GetAttackDistance(who); + if (m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->IsWithinLOSInMap(who)) + { + if(who->HasStealthAura()) + who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); + + if(!InCombat) + { + DoStartAttackAndMovement(who); + if(pInstance) + { + pInstance->SetData64(DATA_MAULGAREVENT_TANK, who->GetGUID()); + pInstance->SetData(DATA_MAULGAREVENT, 1); + } + } + } + } + } + + void UpdateAI(const uint32 diff) + { + //Only if not incombat check if the event is started + if(!InCombat && pInstance && pInstance->GetData(DATA_MAULGAREVENT)) + { + Unit* target = Unit::GetUnit((*m_creature), pInstance->GetData64(DATA_MAULGAREVENT_TANK)); + + if(target) + { + DoStartAttackAndMovement(target); + } + } + + //Return since we have no target + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + //someone evaded! + if(pInstance && !pInstance->GetData(DATA_MAULGAREVENT)) + EnterEvadeMode(); + + //GreaterPolymorph_Timer / disabled: it makes you fall under the texture / if you've got vmaps feel free to uncomment this + /*if(GreaterPolymorph_Timer < diff) + { + Unit *target = SelectUnit(SELECT_TARGET_RANDOM, 0); + if(target) + DoCast(target, SPELL_GREATER_POLYMORPH); + + GreaterPolymorph_Timer = 20000; + }else GreaterPolymorph_Timer -= diff;*/ + + //LightningBolt_Timer + if(LightningBolt_Timer < diff) + { + DoCast(m_creature->getVictim(), SPELL_LIGHTNING_BOLT); + LightningBolt_Timer = 15000; + }else LightningBolt_Timer -= diff; + + //ArcaneShock_Timer + if(ArcaneShock_Timer < diff) + { + DoCast(m_creature->getVictim(), SPELL_ARCANE_SHOCK); + ArcaneShock_Timer = 20000; + }else ArcaneShock_Timer -= diff; + + //ArcaneExplosion_Timer + if(ArcaneExplosion_Timer < diff) + { + DoCast(m_creature->getVictim(), SPELL_ARCANE_EXPLOSION); + ArcaneExplosion_Timer = 30000; + }else ArcaneExplosion_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; + +//Blindeye The Seer AI +struct MANGOS_DLL_DECL boss_blindeye_the_seerAI : public ScriptedAI +{ + boss_blindeye_the_seerAI(Creature *c) : ScriptedAI(c) + { + pInstance = ((ScriptedInstance*)c->GetInstanceData()); + Reset(); + } + + uint32 GreaterPowerWordShield_Timer; + uint32 Heal_Timer; + + ScriptedInstance* pInstance; + + void Reset() + { + GreaterPowerWordShield_Timer = 5000; + Heal_Timer = 30000; + + //reset encounter + if (pInstance) + pInstance->SetData(DATA_MAULGAREVENT, 0); + } + + void Aggro(Unit *who) + { + if(pInstance) + { + pInstance->SetData64(DATA_MAULGAREVENT_TANK, who->GetGUID()); + pInstance->SetData(DATA_MAULGAREVENT, 1); + } + } + + void MoveInLineOfSight(Unit *who) + { + if (!m_creature->getVictim() && who->isTargetableForAttack() && who->isInAccessablePlaceFor(m_creature) && m_creature->IsHostileTo(who)) + { + if (!m_creature->canFly() && m_creature->GetDistanceZ(who) > CREATURE_Z_ATTACK_RANGE) + return; + + float attackRadius = m_creature->GetAttackDistance(who); + if (m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->IsWithinLOSInMap(who)) + { + if(who->HasStealthAura()) + who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); + + if(!InCombat) + { + DoStartAttackAndMovement(who); + if(pInstance) + { + pInstance->SetData64(DATA_MAULGAREVENT_TANK, who->GetGUID()); + pInstance->SetData(DATA_MAULGAREVENT, 1); + } + } + } + } + } + + void UpdateAI(const uint32 diff) + { + //Only if not incombat check if the event is started + if(!InCombat && pInstance && pInstance->GetData(DATA_MAULGAREVENT)) + { + Unit* target = Unit::GetUnit((*m_creature), pInstance->GetData64(DATA_MAULGAREVENT_TANK)); + + if(target) + { + DoStartAttackAndMovement(target); + } + } + + //Return since we have no target + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + //someone evaded! + if(pInstance && !pInstance->GetData(DATA_MAULGAREVENT)) + EnterEvadeMode(); + + //GreaterPowerWordShield_Timer + if(GreaterPowerWordShield_Timer < diff) + { + DoCast(m_creature, SPELL_GREATER_PW_SHIELD); + GreaterPowerWordShield_Timer = 40000; + }else GreaterPowerWordShield_Timer -= diff; + + //Heal_Timer + if(Heal_Timer < diff) + { + DoCast(m_creature, SPELL_HEAL); + Heal_Timer = 60000; + }else Heal_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; + +//Krosh Firehand AI +struct MANGOS_DLL_DECL boss_krosh_firehandAI : public ScriptedAI +{ + boss_krosh_firehandAI(Creature *c) : ScriptedAI(c) + { + pInstance = ((ScriptedInstance*)c->GetInstanceData()); + Reset(); + } + + uint32 GreaterFireball_Timer; + uint32 SpellShield_Timer; + uint32 BlastWave_Timer; + + ScriptedInstance* pInstance; + + void Reset() + { + GreaterFireball_Timer = 1000; + SpellShield_Timer = 5000; + BlastWave_Timer = 20000; + + //reset encounter + if (pInstance) + pInstance->SetData(DATA_MAULGAREVENT, 0); + } + + void Aggro(Unit *who) + { + if(pInstance) + { + pInstance->SetData64(DATA_MAULGAREVENT_TANK, who->GetGUID()); + pInstance->SetData(DATA_MAULGAREVENT, 1); + } + } + + void MoveInLineOfSight(Unit *who) + { + if (!m_creature->getVictim() && who->isTargetableForAttack() && who->isInAccessablePlaceFor(m_creature) && m_creature->IsHostileTo(who)) + { + if (!m_creature->canFly() && m_creature->GetDistanceZ(who) > CREATURE_Z_ATTACK_RANGE) + return; + + float attackRadius = m_creature->GetAttackDistance(who); + if (m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->IsWithinLOSInMap(who)) + { + if(who->HasStealthAura()) + who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); + + if(!InCombat) + { + DoStartAttackAndMovement(who); + if(pInstance) + { + pInstance->SetData64(DATA_MAULGAREVENT_TANK, who->GetGUID()); + pInstance->SetData(DATA_MAULGAREVENT, 1); + } + } + } + } + } + + void UpdateAI(const uint32 diff) + { + //Only if not incombat check if the event is started + if(!InCombat && pInstance && pInstance->GetData(DATA_MAULGAREVENT)) + { + Unit* target = Unit::GetUnit((*m_creature), pInstance->GetData64(DATA_MAULGAREVENT_TANK)); + + if(target) + { + DoStartAttackAndMovement(target); + } + } + + //Return since we have no target + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + //someone evaded! + if(pInstance && !pInstance->GetData(DATA_MAULGAREVENT)) + EnterEvadeMode(); + + //GreaterFireball_Timer + if(GreaterFireball_Timer < diff) + { + DoCast(m_creature->getVictim(), SPELL_GREATER_FIREBALL); + GreaterFireball_Timer = 2000; + }else GreaterFireball_Timer -= diff; + + //SpellShield_Timer + if(SpellShield_Timer < diff) + { + m_creature->InterruptNonMeleeSpells(false); + DoCast(m_creature->getVictim(), SPELL_SPELLSHIELD); + SpellShield_Timer = 30000; + }else SpellShield_Timer -= diff; + + //BlastWave_Timer + if(BlastWave_Timer < diff) + { + m_creature->InterruptNonMeleeSpells(false); + DoCast(m_creature->getVictim(), SPELL_BLAST_WAVE); + BlastWave_Timer = 60000; + }else BlastWave_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; + +CreatureAI* GetAI_boss_high_king_maulgar(Creature *_Creature) +{ + return new boss_high_king_maulgarAI (_Creature); +} + +CreatureAI* GetAI_boss_olm_the_summoner(Creature *_Creature) +{ + return new boss_olm_the_summonerAI (_Creature); +} + +CreatureAI *GetAI_boss_kiggler_the_crazed(Creature *_Creature) +{ + return new boss_kiggler_the_crazedAI (_Creature); +} + +CreatureAI *GetAI_boss_blindeye_the_seer(Creature *_Creature) +{ + return new boss_blindeye_the_seerAI (_Creature); +} + +CreatureAI *GetAI_boss_krosh_firehand(Creature *_Creature) +{ + return new boss_krosh_firehandAI (_Creature); +} + +void AddSC_boss_high_king_maulgar() +{ + Script *newscript; + + newscript = new Script; + newscript->Name="boss_high_king_maulgar"; + newscript->GetAI = GetAI_boss_high_king_maulgar; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="boss_kiggler_the_crazed"; + newscript->GetAI = GetAI_boss_kiggler_the_crazed; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="boss_blindeye_the_seer"; + newscript->GetAI = GetAI_boss_blindeye_the_seer; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="boss_olm_the_summoner"; + newscript->GetAI = GetAI_boss_olm_the_summoner; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="boss_krosh_firehand"; + newscript->GetAI = GetAI_boss_krosh_firehand; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/gruuls_lair/def_gruuls_lair.h b/src/bindings/scripts/scripts/zone/gruuls_lair/def_gruuls_lair.h index e2d780dabda..4c432a8f5d5 100644 --- a/src/bindings/scripts/scripts/zone/gruuls_lair/def_gruuls_lair.h +++ b/src/bindings/scripts/scripts/zone/gruuls_lair/def_gruuls_lair.h @@ -1,15 +1,15 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software licensed under GPL version 2 - * Please see the included DOCS/LICENSE.TXT for more information */ - -#ifndef DEF_GRUULS_LAIR_H -#define DEF_GRUULS_LAIR_H - -#define DATA_BLINDEYETHESEER 1 -#define DATA_GRUULEVENT 2 -#define DATA_KIGGLERTHECRAZED 3 -#define DATA_KROSHFIREHAND 4 -#define DATA_MAULGAREVENT 5 -#define DATA_MAULGAREVENT_TANK 6 -#define DATA_OLMTHESUMMONER 7 -#endif +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software licensed under GPL version 2 + * Please see the included DOCS/LICENSE.TXT for more information */ + +#ifndef DEF_GRUULS_LAIR_H +#define DEF_GRUULS_LAIR_H + +#define DATA_BLINDEYETHESEER 1 +#define DATA_GRUULEVENT 2 +#define DATA_KIGGLERTHECRAZED 3 +#define DATA_KROSHFIREHAND 4 +#define DATA_MAULGAREVENT 5 +#define DATA_MAULGAREVENT_TANK 6 +#define DATA_OLMTHESUMMONER 7 +#endif diff --git a/src/bindings/scripts/scripts/zone/gruuls_lair/instance_gruuls_lair.cpp b/src/bindings/scripts/scripts/zone/gruuls_lair/instance_gruuls_lair.cpp index 158af022905..055bf9c7e16 100644 --- a/src/bindings/scripts/scripts/zone/gruuls_lair/instance_gruuls_lair.cpp +++ b/src/bindings/scripts/scripts/zone/gruuls_lair/instance_gruuls_lair.cpp @@ -1,139 +1,139 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Instance_Gruuls_Lair -SD%Complete: 100 -SDComment: -SDCategory: Gruul's Lair -EndScriptData */ - -#include "precompiled.h" -#include "def_gruuls_lair.h" - -#define ENCOUNTERS 2 - -/* Gruuls Lair encounters: -1 - High King Maulgar event -2 - Gruul event -*/ - -struct MANGOS_DLL_DECL instance_gruuls_lair : public ScriptedInstance -{ - instance_gruuls_lair(Map *Map) : ScriptedInstance(Map) {Initialize();}; - - bool Encounters[ENCOUNTERS]; - - uint64 MaulgarEvent_Tank; - uint64 KigglerTheCrazed; - uint64 BlindeyeTheSeer; - uint64 OlmTheSummoner; - uint64 KroshFirehand; - - void Initialize() - { - MaulgarEvent_Tank = 0; - KigglerTheCrazed = 0; - BlindeyeTheSeer = 0; - OlmTheSummoner = 0; - KroshFirehand = 0; - - for(uint8 i = 0; i < ENCOUNTERS; i++) - Encounters[i] = false; - } - - bool IsEncounterInProgress() const - { - for(uint8 i = 0; i < ENCOUNTERS; i++) - if(Encounters[i]) return true; - - return false; - } - - void OnCreatureCreate(Creature *creature, uint32 creature_entry) - { - switch(creature_entry) - { - case 18835: KigglerTheCrazed = creature->GetGUID(); break; - case 18836: BlindeyeTheSeer = creature->GetGUID(); break; - case 18834: OlmTheSummoner = creature->GetGUID(); break; - case 18832: KroshFirehand = creature->GetGUID(); break; - } - } - - void SetData64(uint32 type, uint64 data) - { - if(type == DATA_MAULGAREVENT_TANK) - MaulgarEvent_Tank = data; - } - - uint64 GetData64(uint32 identifier) - { - switch(identifier) - { - case DATA_MAULGAREVENT_TANK: - return MaulgarEvent_Tank; - case DATA_KIGGLERTHECRAZED: - return KigglerTheCrazed; - case DATA_BLINDEYETHESEER: - return BlindeyeTheSeer; - case DATA_OLMTHESUMMONER: - return OlmTheSummoner; - case DATA_KROSHFIREHAND: - return KroshFirehand; - } - return 0; - } - - void SetData(uint32 type, uint32 data) - { - switch(type) - { - case DATA_MAULGAREVENT: - Encounters[0] = (data) ? true : false; - break; - case DATA_GRUULEVENT: - Encounters[1] = (data) ? true : false; - break; - } - } - - uint32 GetData(uint32 type) - { - switch(type) - { - case DATA_MAULGAREVENT: - return Encounters[0]; - case DATA_GRUULEVENT: - return Encounters[1]; - } - return 0; - } -}; - -InstanceData* GetInstanceData_instance_gruuls_lair(Map* map) -{ - return new instance_gruuls_lair(map); -} - -void AddSC_instance_gruuls_lair() -{ - Script *newscript; - newscript = new Script; - newscript->Name = "instance_gruuls_lair"; - newscript->GetInstanceData = GetInstanceData_instance_gruuls_lair; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Instance_Gruuls_Lair +SD%Complete: 100 +SDComment: +SDCategory: Gruul's Lair +EndScriptData */ + +#include "precompiled.h" +#include "def_gruuls_lair.h" + +#define ENCOUNTERS 2 + +/* Gruuls Lair encounters: +1 - High King Maulgar event +2 - Gruul event +*/ + +struct MANGOS_DLL_DECL instance_gruuls_lair : public ScriptedInstance +{ + instance_gruuls_lair(Map *Map) : ScriptedInstance(Map) {Initialize();}; + + bool Encounters[ENCOUNTERS]; + + uint64 MaulgarEvent_Tank; + uint64 KigglerTheCrazed; + uint64 BlindeyeTheSeer; + uint64 OlmTheSummoner; + uint64 KroshFirehand; + + void Initialize() + { + MaulgarEvent_Tank = 0; + KigglerTheCrazed = 0; + BlindeyeTheSeer = 0; + OlmTheSummoner = 0; + KroshFirehand = 0; + + for(uint8 i = 0; i < ENCOUNTERS; i++) + Encounters[i] = false; + } + + bool IsEncounterInProgress() const + { + for(uint8 i = 0; i < ENCOUNTERS; i++) + if(Encounters[i]) return true; + + return false; + } + + void OnCreatureCreate(Creature *creature, uint32 creature_entry) + { + switch(creature_entry) + { + case 18835: KigglerTheCrazed = creature->GetGUID(); break; + case 18836: BlindeyeTheSeer = creature->GetGUID(); break; + case 18834: OlmTheSummoner = creature->GetGUID(); break; + case 18832: KroshFirehand = creature->GetGUID(); break; + } + } + + void SetData64(uint32 type, uint64 data) + { + if(type == DATA_MAULGAREVENT_TANK) + MaulgarEvent_Tank = data; + } + + uint64 GetData64(uint32 identifier) + { + switch(identifier) + { + case DATA_MAULGAREVENT_TANK: + return MaulgarEvent_Tank; + case DATA_KIGGLERTHECRAZED: + return KigglerTheCrazed; + case DATA_BLINDEYETHESEER: + return BlindeyeTheSeer; + case DATA_OLMTHESUMMONER: + return OlmTheSummoner; + case DATA_KROSHFIREHAND: + return KroshFirehand; + } + return 0; + } + + void SetData(uint32 type, uint32 data) + { + switch(type) + { + case DATA_MAULGAREVENT: + Encounters[0] = (data) ? true : false; + break; + case DATA_GRUULEVENT: + Encounters[1] = (data) ? true : false; + break; + } + } + + uint32 GetData(uint32 type) + { + switch(type) + { + case DATA_MAULGAREVENT: + return Encounters[0]; + case DATA_GRUULEVENT: + return Encounters[1]; + } + return 0; + } +}; + +InstanceData* GetInstanceData_instance_gruuls_lair(Map* map) +{ + return new instance_gruuls_lair(map); +} + +void AddSC_instance_gruuls_lair() +{ + Script *newscript; + newscript = new Script; + newscript->Name = "instance_gruuls_lair"; + newscript->GetInstanceData = GetInstanceData_instance_gruuls_lair; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/hellfire_citadel/blood_furnace/boss_broggok.cpp b/src/bindings/scripts/scripts/zone/hellfire_citadel/blood_furnace/boss_broggok.cpp index 86c300ff57a..2d0e6d1706c 100644 --- a/src/bindings/scripts/scripts/zone/hellfire_citadel/blood_furnace/boss_broggok.cpp +++ b/src/bindings/scripts/scripts/zone/hellfire_citadel/blood_furnace/boss_broggok.cpp @@ -1,132 +1,132 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Broggok -SD%Complete: 100 -SDComment: -SDCategory: Hellfire Citadel, Blood Furnace -EndScriptData */ - -#include "precompiled.h" - -#define SPELL_SLIME_SPRAY 30913 -#define SPELL_POISON_CLOUD 30916 -#define SPELL_POISON_BOLT 30917 - -#define SPELL_POISON 30914 - -#define SAY_AGGRO "Come intruders...." - -struct MANGOS_DLL_DECL boss_broggokAI : public ScriptedAI -{ - boss_broggokAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 AcidSpray_Timer; - uint32 PoisonSpawn_Timer; - uint32 PoisonBolt_Timer; - - void Reset() - { - AcidSpray_Timer = 10000; - PoisonSpawn_Timer = 5000; - PoisonBolt_Timer = 7000; - } - - void Aggro(Unit *who) - { - DoYell(SAY_AGGRO, LANG_UNIVERSAL, NULL); - } - - void UpdateAI(const uint32 diff) - { - - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - if(AcidSpray_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_SLIME_SPRAY); - AcidSpray_Timer = 4000+rand()%8000; - }else AcidSpray_Timer -=diff; - - if(PoisonBolt_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_POISON_BOLT); - PoisonBolt_Timer = 4000+rand()%8000; - }else PoisonBolt_Timer -=diff; - - if(PoisonSpawn_Timer < diff) - { - DoCast(m_creature,SPELL_POISON_CLOUD); - PoisonSpawn_Timer = 20000; - }else PoisonSpawn_Timer -=diff; - - DoMeleeAttackIfReady(); - } -}; - -struct MANGOS_DLL_DECL mob_broggok_poisoncloudAI : public ScriptedAI -{ - mob_broggok_poisoncloudAI(Creature *c) : ScriptedAI(c) {Reset();} - - bool Start; - - void Reset() - { - Start = false; - } - - void Aggro(Unit* who) - { - } - - void UpdateAI(const uint32 diff) - { - if(!Start) - { - m_creature->SetUInt32Value(UNIT_NPC_FLAGS,0); - m_creature->setFaction(45); - m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - Start = true; - DoCast(m_creature,SPELL_POISON); - } - } -}; - -CreatureAI* GetAI_boss_broggokAI(Creature *_Creature) -{ - return new boss_broggokAI (_Creature); -} - -CreatureAI* GetAI_mob_broggok_poisoncloudAI(Creature *_Creature) -{ - return new mob_broggok_poisoncloudAI (_Creature); -} - -void AddSC_boss_broggok() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_broggok"; - newscript->GetAI = GetAI_boss_broggokAI; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="mob_broggok_poisoncloud"; - newscript->GetAI = GetAI_mob_broggok_poisoncloudAI; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Broggok +SD%Complete: 100 +SDComment: +SDCategory: Hellfire Citadel, Blood Furnace +EndScriptData */ + +#include "precompiled.h" + +#define SPELL_SLIME_SPRAY 30913 +#define SPELL_POISON_CLOUD 30916 +#define SPELL_POISON_BOLT 30917 + +#define SPELL_POISON 30914 + +#define SAY_AGGRO "Come intruders...." + +struct MANGOS_DLL_DECL boss_broggokAI : public ScriptedAI +{ + boss_broggokAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 AcidSpray_Timer; + uint32 PoisonSpawn_Timer; + uint32 PoisonBolt_Timer; + + void Reset() + { + AcidSpray_Timer = 10000; + PoisonSpawn_Timer = 5000; + PoisonBolt_Timer = 7000; + } + + void Aggro(Unit *who) + { + DoYell(SAY_AGGRO, LANG_UNIVERSAL, NULL); + } + + void UpdateAI(const uint32 diff) + { + + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + if(AcidSpray_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_SLIME_SPRAY); + AcidSpray_Timer = 4000+rand()%8000; + }else AcidSpray_Timer -=diff; + + if(PoisonBolt_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_POISON_BOLT); + PoisonBolt_Timer = 4000+rand()%8000; + }else PoisonBolt_Timer -=diff; + + if(PoisonSpawn_Timer < diff) + { + DoCast(m_creature,SPELL_POISON_CLOUD); + PoisonSpawn_Timer = 20000; + }else PoisonSpawn_Timer -=diff; + + DoMeleeAttackIfReady(); + } +}; + +struct MANGOS_DLL_DECL mob_broggok_poisoncloudAI : public ScriptedAI +{ + mob_broggok_poisoncloudAI(Creature *c) : ScriptedAI(c) {Reset();} + + bool Start; + + void Reset() + { + Start = false; + } + + void Aggro(Unit* who) + { + } + + void UpdateAI(const uint32 diff) + { + if(!Start) + { + m_creature->SetUInt32Value(UNIT_NPC_FLAGS,0); + m_creature->setFaction(45); + m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + Start = true; + DoCast(m_creature,SPELL_POISON); + } + } +}; + +CreatureAI* GetAI_boss_broggokAI(Creature *_Creature) +{ + return new boss_broggokAI (_Creature); +} + +CreatureAI* GetAI_mob_broggok_poisoncloudAI(Creature *_Creature) +{ + return new mob_broggok_poisoncloudAI (_Creature); +} + +void AddSC_boss_broggok() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_broggok"; + newscript->GetAI = GetAI_boss_broggokAI; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="mob_broggok_poisoncloud"; + newscript->GetAI = GetAI_mob_broggok_poisoncloudAI; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/hellfire_citadel/blood_furnace/boss_kelidan_the_breaker.cpp b/src/bindings/scripts/scripts/zone/hellfire_citadel/blood_furnace/boss_kelidan_the_breaker.cpp index bf77b23d0b3..17980f595f6 100644 --- a/src/bindings/scripts/scripts/zone/hellfire_citadel/blood_furnace/boss_kelidan_the_breaker.cpp +++ b/src/bindings/scripts/scripts/zone/hellfire_citadel/blood_furnace/boss_kelidan_the_breaker.cpp @@ -1,253 +1,253 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Kelidan_The_Breaker -SD%Complete: 60 -SDComment: Event with channeleres vs. boss not implemented yet -SDCategory: Hellfire Citadel, Blood Furnace -EndScriptData */ - -/* ContentData -boss_kelidan_the_breaker -mob_shadowmoon_channeler -EndContentData */ - -#include "precompiled.h" - -#define SAY_WAKE "Who dares interrupt... What is this? What have you done? You ruin everything!" -#define SOUND_WAKE 10164 - -#define SAY_ADD_AGGRO_1 "You mustn't let him loose!" -#define SOUND_ADD_AGGRO_1 10166 -#define SAY_ADD_AGGRO_2 "Ignorant whelps!" -#define SOUND_ADD_AGGRO_2 10167 -#define SAY_ADD_AGGRO_3 "You fools! He'll kill us all!" -#define SOUND_ADD_AGGRO_3 10168 - -#define SAY_KILL_1 "Just as you deserve!" -#define SOUND_KILL_1 10169 -#define SAY_KILL_2 "Your friends will soon be joining you." -#define SOUND_KILL_2 10170 - -#define SAY_NOVA "Closer... Come closer.. and burn!" -#define SOUND_NOVA 10165 - -#define SAY_DIE "Good luck... you'll need it.." -#define SOUND_DIE 10171 - -#define SPELL_CORRUPTION 30938 - -#define SPELL_FIRE_NOVA 33775 -#define H_SPELL_FIRE_NOVA 37371 - -#define SPELL_SHADOW_BOLT_VOLLEY 17228 -#define H_SPELL_SHADOW_BOLT_VOLLEY 40070 - -#define SPELL_BURNING_NOVA 30940 -#define SPELL_VORTEX 37370 - -struct MANGOS_DLL_DECL boss_kelidan_the_breakerAI : public ScriptedAI -{ - boss_kelidan_the_breakerAI(Creature *c) : ScriptedAI(c) - { - pInstance = ((ScriptedInstance*)c->GetInstanceData()); - HeroicMode = m_creature->GetMap()->IsHeroic(); - Reset(); - } - - ScriptedInstance* pInstance; - bool HeroicMode; - - uint32 ShadowVolley_Timer; - uint32 BurningNova_Timer; - uint32 Firenova_Timer; - uint32 Corruption_Timer; - bool Firenova; - - void Reset() - { - ShadowVolley_Timer = 1000; - BurningNova_Timer = 15000; - Corruption_Timer = 5000; - Firenova = false; - } - - void Aggro(Unit *who) - { - DoYell(SAY_WAKE, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature,SOUND_WAKE); - } - - void KilledUnit(Unit* victim) - { - if (rand()%2) - return; - - switch(rand()%2) - { - case 0: - DoYell(SAY_KILL_1, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature,SOUND_KILL_1); - break; - case 1: - DoYell(SAY_KILL_2, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature,SOUND_KILL_2); - break; - } - } - - void JustDied(Unit* Killer) - { - DoYell(SAY_DIE,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_DIE); - } - - void UpdateAI(const uint32 diff) - { - if( !m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - if( Firenova ) - { - if( Firenova_Timer < diff ) - { - DoCast(m_creature,HeroicMode ? H_SPELL_FIRE_NOVA : SPELL_FIRE_NOVA); - Firenova = false; - ShadowVolley_Timer = 2000; - }else Firenova_Timer -=diff; - - return; - } - - if( ShadowVolley_Timer < diff ) - { - DoCast(m_creature,HeroicMode ? H_SPELL_SHADOW_BOLT_VOLLEY : SPELL_SHADOW_BOLT_VOLLEY); - ShadowVolley_Timer = 5000+rand()%8000; - }else ShadowVolley_Timer -=diff; - - if( Corruption_Timer < diff ) - { - DoCast(m_creature,SPELL_CORRUPTION); - Corruption_Timer = 30000+rand()%20000; - }else Corruption_Timer -=diff; - - if( BurningNova_Timer < diff ) - { - if( m_creature->IsNonMeleeSpellCasted(false) ) - m_creature->InterruptNonMeleeSpells(true); - - DoYell(SAY_NOVA, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature,SOUND_NOVA); - - if( HeroicMode ) - DoCast(m_creature,SPELL_VORTEX); - - DoCast(m_creature,SPELL_BURNING_NOVA); - - BurningNova_Timer = 20000+rand()%8000; - Firenova_Timer= 5000; - Firenova = true; - }else BurningNova_Timer -=diff; - - DoMeleeAttackIfReady(); - } -}; - -CreatureAI* GetAI_boss_kelidan_the_breaker(Creature *_Creature) -{ - return new boss_kelidan_the_breakerAI (_Creature); -} - -/*###### -## mob_shadowmoon_channeler -######*/ - -#define SPELL_SHADOW_BOLT 12739 -#define H_SPELL_SHADOW_BOLT 15472 - -#define SPELL_MARK_OF_SHADOW 30937 - -#define SPELL_CHANNELING 0 //initial spell channeling boss/each other not known - //when engaged all channelers must stop, trigger yell (SAY_ADD_AGGRO_*), and engage. - -struct MANGOS_DLL_DECL mob_shadowmoon_channelerAI : public ScriptedAI -{ - mob_shadowmoon_channelerAI(Creature *c) : ScriptedAI(c) - { - pInstance = ((ScriptedInstance*)c->GetInstanceData()); - HeroicMode = m_creature->GetMap()->IsHeroic(); - Reset(); - } - - ScriptedInstance* pInstance; - bool HeroicMode; - - uint32 ShadowBolt_Timer; - uint32 MarkOfShadow_Timer; - - void Reset() - { - ShadowBolt_Timer = 1000+rand()%1000; - MarkOfShadow_Timer = 5000+rand()%2000; - } - - void Aggro(Unit* who) - { - //trigger boss to yell - } - - void UpdateAI(const uint32 diff) - { - if( !m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - if( MarkOfShadow_Timer < diff ) - { - if( Unit *target = SelectUnit(SELECT_TARGET_RANDOM, 0) ) - DoCast(target,SPELL_MARK_OF_SHADOW); - MarkOfShadow_Timer = 15000+rand()%5000; - }else MarkOfShadow_Timer -=diff; - - if( ShadowBolt_Timer < diff ) - { - DoCast(m_creature->getVictim(),HeroicMode ? H_SPELL_SHADOW_BOLT : SPELL_SHADOW_BOLT); - ShadowBolt_Timer = 5000+rand()%1000; - }else ShadowBolt_Timer -=diff; - - DoMeleeAttackIfReady(); - } -}; - -CreatureAI* GetAI_mob_shadowmoon_channeler(Creature *_Creature) -{ - return new mob_shadowmoon_channelerAI (_Creature); -} - -void AddSC_boss_kelidan_the_breaker() -{ - Script *newscript; - - newscript = new Script; - newscript->Name="boss_kelidan_the_breaker"; - newscript->GetAI = GetAI_boss_kelidan_the_breaker; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="mob_shadowmoon_channeler"; - newscript->GetAI = GetAI_mob_shadowmoon_channeler; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Kelidan_The_Breaker +SD%Complete: 60 +SDComment: Event with channeleres vs. boss not implemented yet +SDCategory: Hellfire Citadel, Blood Furnace +EndScriptData */ + +/* ContentData +boss_kelidan_the_breaker +mob_shadowmoon_channeler +EndContentData */ + +#include "precompiled.h" + +#define SAY_WAKE "Who dares interrupt... What is this? What have you done? You ruin everything!" +#define SOUND_WAKE 10164 + +#define SAY_ADD_AGGRO_1 "You mustn't let him loose!" +#define SOUND_ADD_AGGRO_1 10166 +#define SAY_ADD_AGGRO_2 "Ignorant whelps!" +#define SOUND_ADD_AGGRO_2 10167 +#define SAY_ADD_AGGRO_3 "You fools! He'll kill us all!" +#define SOUND_ADD_AGGRO_3 10168 + +#define SAY_KILL_1 "Just as you deserve!" +#define SOUND_KILL_1 10169 +#define SAY_KILL_2 "Your friends will soon be joining you." +#define SOUND_KILL_2 10170 + +#define SAY_NOVA "Closer... Come closer.. and burn!" +#define SOUND_NOVA 10165 + +#define SAY_DIE "Good luck... you'll need it.." +#define SOUND_DIE 10171 + +#define SPELL_CORRUPTION 30938 + +#define SPELL_FIRE_NOVA 33775 +#define H_SPELL_FIRE_NOVA 37371 + +#define SPELL_SHADOW_BOLT_VOLLEY 17228 +#define H_SPELL_SHADOW_BOLT_VOLLEY 40070 + +#define SPELL_BURNING_NOVA 30940 +#define SPELL_VORTEX 37370 + +struct MANGOS_DLL_DECL boss_kelidan_the_breakerAI : public ScriptedAI +{ + boss_kelidan_the_breakerAI(Creature *c) : ScriptedAI(c) + { + pInstance = ((ScriptedInstance*)c->GetInstanceData()); + HeroicMode = m_creature->GetMap()->IsHeroic(); + Reset(); + } + + ScriptedInstance* pInstance; + bool HeroicMode; + + uint32 ShadowVolley_Timer; + uint32 BurningNova_Timer; + uint32 Firenova_Timer; + uint32 Corruption_Timer; + bool Firenova; + + void Reset() + { + ShadowVolley_Timer = 1000; + BurningNova_Timer = 15000; + Corruption_Timer = 5000; + Firenova = false; + } + + void Aggro(Unit *who) + { + DoYell(SAY_WAKE, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature,SOUND_WAKE); + } + + void KilledUnit(Unit* victim) + { + if (rand()%2) + return; + + switch(rand()%2) + { + case 0: + DoYell(SAY_KILL_1, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature,SOUND_KILL_1); + break; + case 1: + DoYell(SAY_KILL_2, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature,SOUND_KILL_2); + break; + } + } + + void JustDied(Unit* Killer) + { + DoYell(SAY_DIE,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_DIE); + } + + void UpdateAI(const uint32 diff) + { + if( !m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + if( Firenova ) + { + if( Firenova_Timer < diff ) + { + DoCast(m_creature,HeroicMode ? H_SPELL_FIRE_NOVA : SPELL_FIRE_NOVA); + Firenova = false; + ShadowVolley_Timer = 2000; + }else Firenova_Timer -=diff; + + return; + } + + if( ShadowVolley_Timer < diff ) + { + DoCast(m_creature,HeroicMode ? H_SPELL_SHADOW_BOLT_VOLLEY : SPELL_SHADOW_BOLT_VOLLEY); + ShadowVolley_Timer = 5000+rand()%8000; + }else ShadowVolley_Timer -=diff; + + if( Corruption_Timer < diff ) + { + DoCast(m_creature,SPELL_CORRUPTION); + Corruption_Timer = 30000+rand()%20000; + }else Corruption_Timer -=diff; + + if( BurningNova_Timer < diff ) + { + if( m_creature->IsNonMeleeSpellCasted(false) ) + m_creature->InterruptNonMeleeSpells(true); + + DoYell(SAY_NOVA, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature,SOUND_NOVA); + + if( HeroicMode ) + DoCast(m_creature,SPELL_VORTEX); + + DoCast(m_creature,SPELL_BURNING_NOVA); + + BurningNova_Timer = 20000+rand()%8000; + Firenova_Timer= 5000; + Firenova = true; + }else BurningNova_Timer -=diff; + + DoMeleeAttackIfReady(); + } +}; + +CreatureAI* GetAI_boss_kelidan_the_breaker(Creature *_Creature) +{ + return new boss_kelidan_the_breakerAI (_Creature); +} + +/*###### +## mob_shadowmoon_channeler +######*/ + +#define SPELL_SHADOW_BOLT 12739 +#define H_SPELL_SHADOW_BOLT 15472 + +#define SPELL_MARK_OF_SHADOW 30937 + +#define SPELL_CHANNELING 0 //initial spell channeling boss/each other not known + //when engaged all channelers must stop, trigger yell (SAY_ADD_AGGRO_*), and engage. + +struct MANGOS_DLL_DECL mob_shadowmoon_channelerAI : public ScriptedAI +{ + mob_shadowmoon_channelerAI(Creature *c) : ScriptedAI(c) + { + pInstance = ((ScriptedInstance*)c->GetInstanceData()); + HeroicMode = m_creature->GetMap()->IsHeroic(); + Reset(); + } + + ScriptedInstance* pInstance; + bool HeroicMode; + + uint32 ShadowBolt_Timer; + uint32 MarkOfShadow_Timer; + + void Reset() + { + ShadowBolt_Timer = 1000+rand()%1000; + MarkOfShadow_Timer = 5000+rand()%2000; + } + + void Aggro(Unit* who) + { + //trigger boss to yell + } + + void UpdateAI(const uint32 diff) + { + if( !m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + if( MarkOfShadow_Timer < diff ) + { + if( Unit *target = SelectUnit(SELECT_TARGET_RANDOM, 0) ) + DoCast(target,SPELL_MARK_OF_SHADOW); + MarkOfShadow_Timer = 15000+rand()%5000; + }else MarkOfShadow_Timer -=diff; + + if( ShadowBolt_Timer < diff ) + { + DoCast(m_creature->getVictim(),HeroicMode ? H_SPELL_SHADOW_BOLT : SPELL_SHADOW_BOLT); + ShadowBolt_Timer = 5000+rand()%1000; + }else ShadowBolt_Timer -=diff; + + DoMeleeAttackIfReady(); + } +}; + +CreatureAI* GetAI_mob_shadowmoon_channeler(Creature *_Creature) +{ + return new mob_shadowmoon_channelerAI (_Creature); +} + +void AddSC_boss_kelidan_the_breaker() +{ + Script *newscript; + + newscript = new Script; + newscript->Name="boss_kelidan_the_breaker"; + newscript->GetAI = GetAI_boss_kelidan_the_breaker; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="mob_shadowmoon_channeler"; + newscript->GetAI = GetAI_mob_shadowmoon_channeler; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/hellfire_citadel/blood_furnace/boss_the_maker.cpp b/src/bindings/scripts/scripts/zone/hellfire_citadel/blood_furnace/boss_the_maker.cpp index fa5d22e33d1..29e11e7ba91 100644 --- a/src/bindings/scripts/scripts/zone/hellfire_citadel/blood_furnace/boss_the_maker.cpp +++ b/src/bindings/scripts/scripts/zone/hellfire_citadel/blood_furnace/boss_the_maker.cpp @@ -1,160 +1,160 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_The_Maker -SD%Complete: 80 -SDComment: Mind control no support -SDCategory: Hellfire Citadel, Blood Furnace -EndScriptData */ - -#include "precompiled.h" - -#define SPELL_ACID_SPRAY 38153 // heroic 38973 ??? 38153 -#define SPELL_EXPLODING_BREAKER 30925 -#define SPELL_KNOCKDOWN 20276 -#define SPELL_DOMINATION 25772 // ??? - -#define SAY_KILL_1 "Let's see what I can make of you." -#define SOUND_KILL_1 10289 -#define SAY_KILL_2 "It is pointless to resist." -#define SOUND_KILL_2 10290 - -#define SAY_AGGRO_1 "My work must not be interrupted." -#define SOUND_AGGRO_1 10286 -#define SAY_AGGRO_2 "Perhaps I can find a use for you." -#define SOUND_AGGRO_2 10287 -#define SAY_AGGRO_3 "Anger... Hate... These are tools I can use." -#define SOUND_AGGRO_3 10288 - -#define SAY_DIE "Stay away from... me." -#define SOUND_DIE 10291 - -struct MANGOS_DLL_DECL boss_the_makerAI : public ScriptedAI -{ - boss_the_makerAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 AcidSpray_Timer; - uint32 ExplodingBreaker_Timer; - uint32 Domination_Timer; - uint32 Knockdown_Timer; - - void Reset() - { - AcidSpray_Timer = 10000; - ExplodingBreaker_Timer = 4000; - Domination_Timer = 120000; - Knockdown_Timer = 6000; - } - - void Aggro(Unit *who) - { - switch(rand()%3) - { - case 0: - DoYell(SAY_AGGRO_1, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature,SOUND_AGGRO_1); - break; - case 1: - DoYell(SAY_AGGRO_2, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature,SOUND_AGGRO_2); - break; - case 2: - DoYell(SAY_AGGRO_3, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature,SOUND_AGGRO_3); - break; - } - } - - void KilledUnit(Unit* victim) - { - if (rand()%5) - return; - - switch(rand()%2) - { - case 0: - DoYell(SAY_KILL_1, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature,SOUND_KILL_1); - break; - case 1: - DoYell(SAY_KILL_2, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature,SOUND_KILL_2); - break; - } - } - - void JustDied(Unit* Killer) - { - DoYell(SAY_DIE,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_DIE); - } - - void UpdateAI(const uint32 diff) - { - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - if(AcidSpray_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_ACID_SPRAY); - AcidSpray_Timer = 16000+rand()%8000; - }else AcidSpray_Timer -=diff; - - if(ExplodingBreaker_Timer < diff) - { - Unit* target; - target = SelectUnit(SELECT_TARGET_RANDOM,0); - - DoCast(target,SPELL_EXPLODING_BREAKER); - ExplodingBreaker_Timer = 4000+rand()%8000; - }else ExplodingBreaker_Timer -=diff; - - /* // Disabled until Core Support for mind control - if(domination_timer_timer < diff) - { - Unit* target; - target = SelectUnit(SELECT_TARGET_RANDOM,0); - - DoCast(target,SPELL_DOMINATION); - - domination_timer = 120000; - }else domination_timer -=diff; - */ - - if(Knockdown_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_KNOCKDOWN); - Knockdown_Timer = 4000+rand()%8000; - }else Knockdown_Timer -=diff; - - DoMeleeAttackIfReady(); - } -}; - -CreatureAI* GetAI_boss_the_makerAI(Creature *_Creature) -{ - return new boss_the_makerAI (_Creature); -} - -void AddSC_boss_the_maker() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_the_maker"; - newscript->GetAI = GetAI_boss_the_makerAI; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_The_Maker +SD%Complete: 80 +SDComment: Mind control no support +SDCategory: Hellfire Citadel, Blood Furnace +EndScriptData */ + +#include "precompiled.h" + +#define SPELL_ACID_SPRAY 38153 // heroic 38973 ??? 38153 +#define SPELL_EXPLODING_BREAKER 30925 +#define SPELL_KNOCKDOWN 20276 +#define SPELL_DOMINATION 25772 // ??? + +#define SAY_KILL_1 "Let's see what I can make of you." +#define SOUND_KILL_1 10289 +#define SAY_KILL_2 "It is pointless to resist." +#define SOUND_KILL_2 10290 + +#define SAY_AGGRO_1 "My work must not be interrupted." +#define SOUND_AGGRO_1 10286 +#define SAY_AGGRO_2 "Perhaps I can find a use for you." +#define SOUND_AGGRO_2 10287 +#define SAY_AGGRO_3 "Anger... Hate... These are tools I can use." +#define SOUND_AGGRO_3 10288 + +#define SAY_DIE "Stay away from... me." +#define SOUND_DIE 10291 + +struct MANGOS_DLL_DECL boss_the_makerAI : public ScriptedAI +{ + boss_the_makerAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 AcidSpray_Timer; + uint32 ExplodingBreaker_Timer; + uint32 Domination_Timer; + uint32 Knockdown_Timer; + + void Reset() + { + AcidSpray_Timer = 10000; + ExplodingBreaker_Timer = 4000; + Domination_Timer = 120000; + Knockdown_Timer = 6000; + } + + void Aggro(Unit *who) + { + switch(rand()%3) + { + case 0: + DoYell(SAY_AGGRO_1, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature,SOUND_AGGRO_1); + break; + case 1: + DoYell(SAY_AGGRO_2, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature,SOUND_AGGRO_2); + break; + case 2: + DoYell(SAY_AGGRO_3, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature,SOUND_AGGRO_3); + break; + } + } + + void KilledUnit(Unit* victim) + { + if (rand()%5) + return; + + switch(rand()%2) + { + case 0: + DoYell(SAY_KILL_1, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature,SOUND_KILL_1); + break; + case 1: + DoYell(SAY_KILL_2, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature,SOUND_KILL_2); + break; + } + } + + void JustDied(Unit* Killer) + { + DoYell(SAY_DIE,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_DIE); + } + + void UpdateAI(const uint32 diff) + { + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + if(AcidSpray_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_ACID_SPRAY); + AcidSpray_Timer = 16000+rand()%8000; + }else AcidSpray_Timer -=diff; + + if(ExplodingBreaker_Timer < diff) + { + Unit* target; + target = SelectUnit(SELECT_TARGET_RANDOM,0); + + DoCast(target,SPELL_EXPLODING_BREAKER); + ExplodingBreaker_Timer = 4000+rand()%8000; + }else ExplodingBreaker_Timer -=diff; + + /* // Disabled until Core Support for mind control + if(domination_timer_timer < diff) + { + Unit* target; + target = SelectUnit(SELECT_TARGET_RANDOM,0); + + DoCast(target,SPELL_DOMINATION); + + domination_timer = 120000; + }else domination_timer -=diff; + */ + + if(Knockdown_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_KNOCKDOWN); + Knockdown_Timer = 4000+rand()%8000; + }else Knockdown_Timer -=diff; + + DoMeleeAttackIfReady(); + } +}; + +CreatureAI* GetAI_boss_the_makerAI(Creature *_Creature) +{ + return new boss_the_makerAI (_Creature); +} + +void AddSC_boss_the_maker() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_the_maker"; + newscript->GetAI = GetAI_boss_the_makerAI; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/hellfire_citadel/hellfire_ramparts/boss_omor_the_unscarred.cpp b/src/bindings/scripts/scripts/zone/hellfire_citadel/hellfire_ramparts/boss_omor_the_unscarred.cpp index 970a1774683..37eb692fa84 100644 --- a/src/bindings/scripts/scripts/zone/hellfire_citadel/hellfire_ramparts/boss_omor_the_unscarred.cpp +++ b/src/bindings/scripts/scripts/zone/hellfire_citadel/hellfire_ramparts/boss_omor_the_unscarred.cpp @@ -1,277 +1,279 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Omar_The_Unscarred -SD%Complete: 90 -SDComment: Normal/Heroic support: both, to be tested. Temporary solution for orbital/shadow whip-ability. Needs more core support before making it more proper. -SDCategory: Hellfire Citadel, Hellfire Ramparts -EndScriptData */ - -#include "precompiled.h" - -#define SPELL_ORBITAL_STRIKE 30637 -#define SPELL_SHADOW_WHIP 30638 -#define SPELL_TREACHEROUS_AURA 30695 -#define H_SPELL_BANE_OF_TREACHERY 37566 -#define SPELL_DEMONIC_SHIELD 31901 -#define SPELL_SHADOW_BOLT 30686 -#define H_SPELL_SHADOW_BOLT 39297 -#define SPELL_SUMMON_FIENDISH_HOUND 30707 - -#define SAY_AGGRO_1 "You dare stand against me?!" -#define SOUND_AGGRO_1 10280 -#define SAY_AGGRO_2 "I will not be defeated!" -#define SOUND_AGGRO_2 10279 -#define SAY_AGGRO_3 "Your insolence will be your death." -#define SOUND_AGGRO_3 10281 - -#define SAY_SUMMON "Achor-she-ki! Feast my pet! Eat your fill!" -#define SOUND_SUMMON 10277 - -#define SAY_CURSE "A-Kreesh!" -#define SOUND_CURSE 10278 - -#define SAY_KILL_1 "Die, weakling!" -#define SOUND_KILL_1 10282 - -#define SAY_DIE "It is... not over." -#define SOUND_DIE 10284 - -#define SAY_WIPE "I am victorious!" -#define SOUND_WIPE 10283 - -struct MANGOS_DLL_DECL boss_omor_the_unscarredAI : public ScriptedAI -{ - boss_omor_the_unscarredAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 OrbitalStrike_Timer; - uint32 ShadowWhip_Timer; - uint32 Aura_Timer; - uint32 DemonicShield_Timer; - uint32 Shadowbolt_Timer; - uint32 Summon_Timer; - uint32 SummonedCount; - uint64 playerGUID; - bool CanPullBack; - bool HeroicMode; - - void Reset() - { - HeroicMode = m_creature->GetMap()->IsHeroic(); - - DoYell(SAY_WIPE,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_WIPE); - - OrbitalStrike_Timer = 25000; - ShadowWhip_Timer = 2000; - Aura_Timer = 10000; - DemonicShield_Timer = 1000; - Shadowbolt_Timer = 2000; - Summon_Timer = 10000; - SummonedCount = 0; - playerGUID = 0; - CanPullBack = false; - } - - void Aggro(Unit *who) - { - switch(rand()%3) - { - case 0: - DoYell(SAY_AGGRO_1, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature,SOUND_AGGRO_1); - break; - case 1: - DoYell(SAY_AGGRO_2, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature,SOUND_AGGRO_2); - break; - case 2: - DoYell(SAY_AGGRO_3, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature,SOUND_AGGRO_3); - break; - } - } - - void AttackStart(Unit* who) - { - if (!who) - return; - - if (who->isTargetableForAttack()) - { - DoStartAttackNoMovement(who); - - if (!InCombat) - { - Aggro(who); - InCombat = true; - } - } - } - - void MoveInLineOfSight(Unit* who) - { - if( !m_creature->getVictim() && who->isTargetableForAttack() && ( m_creature->IsHostileTo( who )) && who->isInAccessablePlaceFor(m_creature) ) - { - if (m_creature->GetDistanceZ(who) > CREATURE_Z_ATTACK_RANGE) - return; - - float attackRadius = m_creature->GetAttackDistance(who); - if(m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->IsWithinLOSInMap(who)) - { - DoStartAttackNoMovement(who); - who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); - - if (!InCombat) - { - Aggro(who); - InCombat = true; - } - } - } - } - - void KilledUnit(Unit* victim) - { - if (rand()%2) - return; - - DoYell(SAY_KILL_1,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_KILL_1); - } - - void JustSummoned(Creature* summoned) - { - DoYell(SAY_SUMMON,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_SUMMON); - - if( Unit* random = SelectUnit(SELECT_TARGET_RANDOM,0) ) - summoned->AI()->AttackStart(random); - - ++SummonedCount; - } - - void JustDied(Unit* Killer) - { - DoYell(SAY_DIE,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_DIE); - } - - void UpdateAI(const uint32 diff) - { - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - //only two may be wrong, perhaps increase timer and spawn periodically instead. - if( SummonedCount < 2 ) - { - if( Summon_Timer < diff ) - { - m_creature->InterruptNonMeleeSpells(false); - DoCast(m_creature,SPELL_SUMMON_FIENDISH_HOUND); - Summon_Timer = 15000+rand()%15000; - }else Summon_Timer -= diff; - } - - if( CanPullBack ) - { - if( ShadowWhip_Timer < diff ) - { - if( Unit* temp = Unit::GetUnit(*m_creature,playerGUID) ) - { - //if unit dosen't have this flag, then no pulling back (script will attempt cast, even if orbital strike was resisted) - if( temp->HasUnitMovementFlag(MOVEMENTFLAG_FALLING) ) - { - m_creature->InterruptNonMeleeSpells(false); - DoCast(temp,SPELL_SHADOW_WHIP); - } - } - playerGUID = 0; - ShadowWhip_Timer = 2000; - CanPullBack = false; - }else ShadowWhip_Timer -= diff; - } - else if( OrbitalStrike_Timer < diff ) - { - Unit* temp = NULL; - if( m_creature->IsWithinDistInMap(m_creature->getVictim(), ATTACK_DISTANCE) ) - temp = m_creature->getVictim(); - else temp = SelectUnit(SELECT_TARGET_RANDOM,0); - - if( temp && temp->GetTypeId() == TYPEID_PLAYER ) - { - DoCast(temp,SPELL_ORBITAL_STRIKE); - OrbitalStrike_Timer = 14000+rand()%2000; - playerGUID = temp->GetGUID(); - if( playerGUID ) - CanPullBack = true; - } - }else OrbitalStrike_Timer -= diff; - - if( (m_creature->GetHealth()*100) / m_creature->GetMaxHealth() < 20 ) - { - if( DemonicShield_Timer < diff ) - { - DoCast(m_creature,SPELL_DEMONIC_SHIELD); - DemonicShield_Timer = 15000; - }else DemonicShield_Timer -= diff; - } - - if( Aura_Timer < diff ) - { - DoYell(SAY_CURSE,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_CURSE); - - if( Unit* target = SelectUnit(SELECT_TARGET_RANDOM,0) ) - { - if( HeroicMode ) DoCast(target,H_SPELL_BANE_OF_TREACHERY); - else DoCast(target,SPELL_TREACHEROUS_AURA); - - Aura_Timer = 8000+rand()%8000; - } - }else Aura_Timer -= diff; - - if( Shadowbolt_Timer < diff ) - { - if( Unit* target = SelectUnit(SELECT_TARGET_RANDOM,0) ) - { - if( target ) - target = m_creature->getVictim(); - - if( HeroicMode ) DoCast(target,H_SPELL_SHADOW_BOLT); - else DoCast(target,SPELL_SHADOW_BOLT); - - Shadowbolt_Timer = 4000+rand()%2500; - } - }else Shadowbolt_Timer -= diff; - } -}; - -CreatureAI* GetAI_boss_omor_the_unscarredAI(Creature *_Creature) -{ - return new boss_omor_the_unscarredAI (_Creature); -} - -void AddSC_boss_omor_the_unscarred() -{ - Script *newscript; - - newscript = new Script; - newscript->Name="boss_omor_the_unscarred"; - newscript->GetAI = GetAI_boss_omor_the_unscarredAI; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Omar_The_Unscarred +SD%Complete: 90 +SDComment: Normal/Heroic support: both, to be tested. Temporary solution for orbital/shadow whip-ability. Needs more core support before making it more proper. +SDCategory: Hellfire Citadel, Hellfire Ramparts +EndScriptData */ + +#include "precompiled.h" + +#define SPELL_ORBITAL_STRIKE 30637 +#define SPELL_SHADOW_WHIP 30638 +#define SPELL_TREACHEROUS_AURA 30695 +#define H_SPELL_BANE_OF_TREACHERY 37566 +#define SPELL_DEMONIC_SHIELD 31901 +#define SPELL_SHADOW_BOLT 30686 +#define H_SPELL_SHADOW_BOLT 39297 +#define SPELL_SUMMON_FIENDISH_HOUND 30707 + +#define SAY_AGGRO_1 "You dare stand against me?!" +#define SOUND_AGGRO_1 10280 +#define SAY_AGGRO_2 "I will not be defeated!" +#define SOUND_AGGRO_2 10279 +#define SAY_AGGRO_3 "Your insolence will be your death." +#define SOUND_AGGRO_3 10281 + +#define SAY_SUMMON "Achor-she-ki! Feast my pet! Eat your fill!" +#define SOUND_SUMMON 10277 + +#define SAY_CURSE "A-Kreesh!" +#define SOUND_CURSE 10278 + +#define SAY_KILL_1 "Die, weakling!" +#define SOUND_KILL_1 10282 + +#define SAY_DIE "It is... not over." +#define SOUND_DIE 10284 + +#define SAY_WIPE "I am victorious!" +#define SOUND_WIPE 10283 + +struct MANGOS_DLL_DECL boss_omor_the_unscarredAI : public ScriptedAI +{ + boss_omor_the_unscarredAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 OrbitalStrike_Timer; + uint32 ShadowWhip_Timer; + uint32 Aura_Timer; + uint32 DemonicShield_Timer; + uint32 Shadowbolt_Timer; + uint32 Summon_Timer; + uint32 SummonedCount; + uint64 playerGUID; + bool CanPullBack; + bool HeroicMode; + + void Reset() + { + HeroicMode = m_creature->GetMap()->IsHeroic(); + + DoYell(SAY_WIPE,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_WIPE); + + OrbitalStrike_Timer = 25000; + ShadowWhip_Timer = 2000; + Aura_Timer = 10000; + DemonicShield_Timer = 1000; + Shadowbolt_Timer = 2000; + Summon_Timer = 10000; + SummonedCount = 0; + playerGUID = 0; + CanPullBack = false; + } + + void Aggro(Unit *who) + { + switch(rand()%3) + { + case 0: + DoYell(SAY_AGGRO_1, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature,SOUND_AGGRO_1); + break; + case 1: + DoYell(SAY_AGGRO_2, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature,SOUND_AGGRO_2); + break; + case 2: + DoYell(SAY_AGGRO_3, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature,SOUND_AGGRO_3); + break; + } + } + + void AttackStart(Unit* who) + { + if (!who) + return; + + if (who->isTargetableForAttack()) + { + DoStartAttackNoMovement(who); + + if (!InCombat) + { + Aggro(who); + InCombat = true; + } + } + } + + void MoveInLineOfSight(Unit* who) + { + if( !m_creature->getVictim() && who->isTargetableForAttack() && ( m_creature->IsHostileTo( who )) && who->isInAccessablePlaceFor(m_creature) ) + { + if (!m_creature->canFly() && m_creature->GetDistanceZ(who) > CREATURE_Z_ATTACK_RANGE) + return; + + float attackRadius = m_creature->GetAttackDistance(who); + if(m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->IsWithinLOSInMap(who)) + { + DoStartAttackNoMovement(who); + who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); + + if (!InCombat) + { + Aggro(who); + InCombat = true; + } + } + } + } + + void KilledUnit(Unit* victim) + { + if (rand()%2) + return; + + DoYell(SAY_KILL_1,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_KILL_1); + } + + void JustSummoned(Creature* summoned) + { + DoYell(SAY_SUMMON,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_SUMMON); + + if( Unit* random = SelectUnit(SELECT_TARGET_RANDOM,0) ) + summoned->AI()->AttackStart(random); + + ++SummonedCount; + } + + void JustDied(Unit* Killer) + { + DoYell(SAY_DIE,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_DIE); + } + + void UpdateAI(const uint32 diff) + { + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + //only two may be wrong, perhaps increase timer and spawn periodically instead. + if( SummonedCount < 2 ) + { + if( Summon_Timer < diff ) + { + m_creature->InterruptNonMeleeSpells(false); + DoCast(m_creature,SPELL_SUMMON_FIENDISH_HOUND); + Summon_Timer = 15000+rand()%15000; + }else Summon_Timer -= diff; + } + + if( CanPullBack ) + { + if( ShadowWhip_Timer < diff ) + { + if( Unit* temp = Unit::GetUnit(*m_creature,playerGUID) ) + { + //if unit dosen't have this flag, then no pulling back (script will attempt cast, even if orbital strike was resisted) + if( temp->HasUnitMovementFlag(MOVEMENTFLAG_FALLING) ) + { + m_creature->InterruptNonMeleeSpells(false); + DoCast(temp,SPELL_SHADOW_WHIP); + } + } + playerGUID = 0; + ShadowWhip_Timer = 2000; + CanPullBack = false; + }else ShadowWhip_Timer -= diff; + } + else if( OrbitalStrike_Timer < diff ) + { + Unit* temp = NULL; + if( m_creature->IsWithinDistInMap(m_creature->getVictim(), ATTACK_DISTANCE) ) + temp = m_creature->getVictim(); + else temp = SelectUnit(SELECT_TARGET_RANDOM,0); + + if( temp && temp->GetTypeId() == TYPEID_PLAYER ) + { + DoCast(temp,SPELL_ORBITAL_STRIKE); + OrbitalStrike_Timer = 14000+rand()%2000; + playerGUID = temp->GetGUID(); + if( playerGUID ) + CanPullBack = true; + } + }else OrbitalStrike_Timer -= diff; + + if( (m_creature->GetHealth()*100) / m_creature->GetMaxHealth() < 20 ) + { + if( DemonicShield_Timer < diff ) + { + DoCast(m_creature,SPELL_DEMONIC_SHIELD); + DemonicShield_Timer = 15000; + }else DemonicShield_Timer -= diff; + } + + if( Aura_Timer < diff ) + { + DoYell(SAY_CURSE,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_CURSE); + + if( Unit* target = SelectUnit(SELECT_TARGET_RANDOM,0) ) + { + if( HeroicMode ) DoCast(target,H_SPELL_BANE_OF_TREACHERY); + else DoCast(target,SPELL_TREACHEROUS_AURA); + + Aura_Timer = 8000+rand()%8000; + } + }else Aura_Timer -= diff; + + if( Shadowbolt_Timer < diff ) + { + if( Unit* target = SelectUnit(SELECT_TARGET_RANDOM,0) ) + { + if( target ) + target = m_creature->getVictim(); + + if( HeroicMode ) DoCast(target,H_SPELL_SHADOW_BOLT); + else DoCast(target,SPELL_SHADOW_BOLT); + + Shadowbolt_Timer = 4000+rand()%2500; + } + }else Shadowbolt_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; + +CreatureAI* GetAI_boss_omor_the_unscarredAI(Creature *_Creature) +{ + return new boss_omor_the_unscarredAI (_Creature); +} + +void AddSC_boss_omor_the_unscarred() +{ + Script *newscript; + + newscript = new Script; + newscript->Name="boss_omor_the_unscarred"; + newscript->GetAI = GetAI_boss_omor_the_unscarredAI; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/hellfire_citadel/hellfire_ramparts/boss_watchkeeper_gargolmar.cpp b/src/bindings/scripts/scripts/zone/hellfire_citadel/hellfire_ramparts/boss_watchkeeper_gargolmar.cpp index 247af6545fd..f44c384911a 100644 --- a/src/bindings/scripts/scripts/zone/hellfire_citadel/hellfire_ramparts/boss_watchkeeper_gargolmar.cpp +++ b/src/bindings/scripts/scripts/zone/hellfire_citadel/hellfire_ramparts/boss_watchkeeper_gargolmar.cpp @@ -1,200 +1,200 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Watchkeeper_Gargolmar -SD%Complete: 80 -SDComment: Normal/Heroic support: both, to be tested. Missing adds to heal him. Surge should be used on target furthest away, not random. -SDCategory: Hellfire Citadel, Hellfire Ramparts -EndScriptData */ - -#include "precompiled.h" - -#define SAY_HEAL "Heal me! QUICKLY!" -#define SOUND_HEAL 10329 - -#define SAY_SURGE "Back off, pup!" -#define SOUND_SURGE 10330 - -#define SAY_TAUNT "Do you smell that? Fresh meat has somehow breached our citadel. Be wary of any intruders." - -#define SAY_AGGRO_1 "What have we here...?" -#define SOUND_AGGRO_1 10331 -#define SAY_AGGRO_2 "Heh... this may hurt a little." -#define SOUND_AGGRO_2 10332 -#define SAY_AGGRO_3 "I'm gonna enjoy this." -#define SOUND_AGGRO_3 10333 - -#define SAY_KILL_1 "Say farewell!" -#define SOUND_KILL_1 10334 -#define SAY_KILL_2 "Much too easy..." -#define SOUND_KILL_2 10335 - -#define SOUND_DIE 10336 - -#define SPELL_MORTAL_WOUND 30641 -#define H_SPELL_MORTAL_WOUND 36814 -#define SPELL_SURGE 34645 -#define SPELL_RETALIATION 22857 - -struct MANGOS_DLL_DECL boss_watchkeeper_gargolmarAI : public ScriptedAI -{ - boss_watchkeeper_gargolmarAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 Surge_Timer; - uint32 MortalWound_Timer; - uint32 Retaliation_Timer; - - bool HasTaunted; - bool YelledForHeal; - bool HeroicMode; - - void Reset() - { - HeroicMode = m_creature->GetMap()->IsHeroic(); - - Surge_Timer = 5000; - MortalWound_Timer = 4000; - Retaliation_Timer = 0; - - HasTaunted = false; - YelledForHeal = false; - } - - void Aggro(Unit *who) - { - switch(rand()%3) - { - case 0: - DoYell(SAY_AGGRO_1, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature,SOUND_AGGRO_1); - break; - case 1: - DoYell(SAY_AGGRO_2, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature,SOUND_AGGRO_2); - break; - case 2: - DoYell(SAY_AGGRO_3, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature,SOUND_AGGRO_3); - break; - } - } - - void MoveInLineOfSight(Unit* who) - { - if( !m_creature->getVictim() && who->isTargetableForAttack() && ( m_creature->IsHostileTo( who )) && who->isInAccessablePlaceFor(m_creature) ) - { - if (m_creature->GetDistanceZ(who) > CREATURE_Z_ATTACK_RANGE) - return; - - float attackRadius = m_creature->GetAttackDistance(who); - if(m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->IsWithinLOSInMap(who)) - { - DoStartAttackAndMovement(who); - who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); - - if (!InCombat) - { - Aggro(who); - InCombat = true; - } - } - else if (!HasTaunted && m_creature->IsWithinDistInMap(who, 60.0f)) - { - DoYell(SAY_TAUNT, LANG_UNIVERSAL, NULL); - HasTaunted = true; - } - } - } - - void KilledUnit(Unit* victim) - { - switch(rand()%2) - { - case 0: - DoYell(SAY_KILL_1, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature,SOUND_KILL_1); - break; - case 1: - DoYell(SAY_KILL_2, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature,SOUND_KILL_2); - break; - } - } - - void JustDied(Unit* Killer) - { - DoPlaySoundToSet(m_creature,SOUND_DIE); - } - - void UpdateAI(const uint32 diff) - { - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - if( MortalWound_Timer < diff ) - { - if( HeroicMode ) DoCast(m_creature->getVictim(),H_SPELL_MORTAL_WOUND); - else DoCast(m_creature->getVictim(),SPELL_MORTAL_WOUND); - - MortalWound_Timer = 5000+rand()%8000; - }else MortalWound_Timer -= diff; - - if( Surge_Timer < diff ) - { - DoYell(SAY_SURGE, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature,SOUND_SURGE); - - if( Unit* target = SelectUnit(SELECT_TARGET_RANDOM,0) ) - DoCast(target,SPELL_SURGE); - - Surge_Timer = 5000+rand()%8000; - }else Surge_Timer -= diff; - - if((m_creature->GetHealth()*100) / m_creature->GetMaxHealth() < 20) - { - if( Retaliation_Timer < diff ) - { - DoCast(m_creature,SPELL_RETALIATION); - Retaliation_Timer = 30000; - }else Retaliation_Timer -= diff; - } - - if( !YelledForHeal ) - if((m_creature->GetHealth()*100) / m_creature->GetMaxHealth() < 40) - { - DoYell(SAY_HEAL, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature,SOUND_HEAL); - YelledForHeal = true; - } - - DoMeleeAttackIfReady(); - } -}; - -CreatureAI* GetAI_boss_watchkeeper_gargolmarAI(Creature *_Creature) -{ - return new boss_watchkeeper_gargolmarAI (_Creature); -} - -void AddSC_boss_watchkeeper_gargolmar() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_watchkeeper_gargolmar"; - newscript->GetAI = GetAI_boss_watchkeeper_gargolmarAI; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Watchkeeper_Gargolmar +SD%Complete: 80 +SDComment: Normal/Heroic support: both, to be tested. Missing adds to heal him. Surge should be used on target furthest away, not random. +SDCategory: Hellfire Citadel, Hellfire Ramparts +EndScriptData */ + +#include "precompiled.h" + +#define SAY_HEAL "Heal me! QUICKLY!" +#define SOUND_HEAL 10329 + +#define SAY_SURGE "Back off, pup!" +#define SOUND_SURGE 10330 + +#define SAY_TAUNT "Do you smell that? Fresh meat has somehow breached our citadel. Be wary of any intruders." + +#define SAY_AGGRO_1 "What have we here...?" +#define SOUND_AGGRO_1 10331 +#define SAY_AGGRO_2 "Heh... this may hurt a little." +#define SOUND_AGGRO_2 10332 +#define SAY_AGGRO_3 "I'm gonna enjoy this." +#define SOUND_AGGRO_3 10333 + +#define SAY_KILL_1 "Say farewell!" +#define SOUND_KILL_1 10334 +#define SAY_KILL_2 "Much too easy..." +#define SOUND_KILL_2 10335 + +#define SOUND_DIE 10336 + +#define SPELL_MORTAL_WOUND 30641 +#define H_SPELL_MORTAL_WOUND 36814 +#define SPELL_SURGE 34645 +#define SPELL_RETALIATION 22857 + +struct MANGOS_DLL_DECL boss_watchkeeper_gargolmarAI : public ScriptedAI +{ + boss_watchkeeper_gargolmarAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 Surge_Timer; + uint32 MortalWound_Timer; + uint32 Retaliation_Timer; + + bool HasTaunted; + bool YelledForHeal; + bool HeroicMode; + + void Reset() + { + HeroicMode = m_creature->GetMap()->IsHeroic(); + + Surge_Timer = 5000; + MortalWound_Timer = 4000; + Retaliation_Timer = 0; + + HasTaunted = false; + YelledForHeal = false; + } + + void Aggro(Unit *who) + { + switch(rand()%3) + { + case 0: + DoYell(SAY_AGGRO_1, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature,SOUND_AGGRO_1); + break; + case 1: + DoYell(SAY_AGGRO_2, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature,SOUND_AGGRO_2); + break; + case 2: + DoYell(SAY_AGGRO_3, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature,SOUND_AGGRO_3); + break; + } + } + + void MoveInLineOfSight(Unit* who) + { + if( !m_creature->getVictim() && who->isTargetableForAttack() && ( m_creature->IsHostileTo( who )) && who->isInAccessablePlaceFor(m_creature) ) + { + if (!m_creature->canFly() && m_creature->GetDistanceZ(who) > CREATURE_Z_ATTACK_RANGE) + return; + + float attackRadius = m_creature->GetAttackDistance(who); + if(m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->IsWithinLOSInMap(who)) + { + DoStartAttackAndMovement(who); + who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); + + if (!InCombat) + { + Aggro(who); + InCombat = true; + } + } + else if (!HasTaunted && m_creature->IsWithinDistInMap(who, 60.0f)) + { + DoYell(SAY_TAUNT, LANG_UNIVERSAL, NULL); + HasTaunted = true; + } + } + } + + void KilledUnit(Unit* victim) + { + switch(rand()%2) + { + case 0: + DoYell(SAY_KILL_1, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature,SOUND_KILL_1); + break; + case 1: + DoYell(SAY_KILL_2, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature,SOUND_KILL_2); + break; + } + } + + void JustDied(Unit* Killer) + { + DoPlaySoundToSet(m_creature,SOUND_DIE); + } + + void UpdateAI(const uint32 diff) + { + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + if( MortalWound_Timer < diff ) + { + if( HeroicMode ) DoCast(m_creature->getVictim(),H_SPELL_MORTAL_WOUND); + else DoCast(m_creature->getVictim(),SPELL_MORTAL_WOUND); + + MortalWound_Timer = 5000+rand()%8000; + }else MortalWound_Timer -= diff; + + if( Surge_Timer < diff ) + { + DoYell(SAY_SURGE, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature,SOUND_SURGE); + + if( Unit* target = SelectUnit(SELECT_TARGET_RANDOM,0) ) + DoCast(target,SPELL_SURGE); + + Surge_Timer = 5000+rand()%8000; + }else Surge_Timer -= diff; + + if((m_creature->GetHealth()*100) / m_creature->GetMaxHealth() < 20) + { + if( Retaliation_Timer < diff ) + { + DoCast(m_creature,SPELL_RETALIATION); + Retaliation_Timer = 30000; + }else Retaliation_Timer -= diff; + } + + if( !YelledForHeal ) + if((m_creature->GetHealth()*100) / m_creature->GetMaxHealth() < 40) + { + DoYell(SAY_HEAL, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature,SOUND_HEAL); + YelledForHeal = true; + } + + DoMeleeAttackIfReady(); + } +}; + +CreatureAI* GetAI_boss_watchkeeper_gargolmarAI(Creature *_Creature) +{ + return new boss_watchkeeper_gargolmarAI (_Creature); +} + +void AddSC_boss_watchkeeper_gargolmar() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_watchkeeper_gargolmar"; + newscript->GetAI = GetAI_boss_watchkeeper_gargolmarAI; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/hellfire_citadel/magtheridons_lair/boss_magtheridon.cpp b/src/bindings/scripts/scripts/zone/hellfire_citadel/magtheridons_lair/boss_magtheridon.cpp index 32da6416b79..69a7b86c078 100644 --- a/src/bindings/scripts/scripts/zone/hellfire_citadel/magtheridons_lair/boss_magtheridon.cpp +++ b/src/bindings/scripts/scripts/zone/hellfire_citadel/magtheridons_lair/boss_magtheridon.cpp @@ -1,437 +1,437 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Magtheridon -SD%Complete: 60 -SDComment: In Development -SDCategory: Hellfire Citadel, Magtheridon's lair -EndScriptData */ - -#include "precompiled.h" -#include "def_magtheridons_lair.h" -#include "WorldPacket.h" - -//Phase 2 Spells -#define SPELL_QUAKE_PROC 30571 -#define SPELL_QUAKE 30576 //must be cast with 30561 as the proc spell -#define SPELL_BLASTNOVA 30616 -#define SPELL_CLEAVE 30619 -#define SPELL_BERSERK 27680 -#define SPELL_DEBRIS 30631 -#define SPELL_CAMERA_SHAKE 36455 - -//Banish -#define SPELL_SHADOW_CAGE 30205 - -//Player version of the banish -#define SPELL_SHADOW_CAGE_2 30168 - -//Spell that is cast on players from the cube -#define SPELL_SHADOW_GRASP 30410 -#define SPELL_SHADOW_GRASP_UKN 30166 -#define SPELL_SHADOW_GRASP_VIS 30207 - -//Dialog -#define SAY_AGGRO "Thank you for releasing me. Now...die!" -#define SOUND_AGGRO 10254 - -#define SAY_BANISH "Not again...NOT AGAIN!" -#define SOUND_BANISH 10256 - -#define SAY_FREED "I...am...UNLEASHED!!!" -#define SOUND_FREED 10253 - -#define SAY_CHAMBER_DESTROY "I will not be taken so easily. Let the walls of this prison tremble...and FALL!!!" -#define SOUND_CHAMBER_DESTROY 10257 - -#define SAY_PLAYER_KILLED "Did you think me weak? Soft? Who is the weak one now?!" -#define SOUND_PLAYER_KILLED 10255 - -#define SAY_DEATH "The Legion...will consume you...all...." -#define SOUND_DEATH 10258 - -#define EMOTE_BERSERK "becomes enraged!" -#define EMOTE_BLASTNOVA "begins to cast Blast Nova!" -#define EMOTE_BEGIN "%s's bonds begin to weaken!" - -//Spawned objects -#define SPELL_COLLAPSE 34233 //This spell casted by the "cave in" type object - -#define SPELL_CONFLAGERATION 35840 //Actually casted by a creature or object spawned on the ground - -//Cubes -#define SPELL_MIND_EXHAUSTIOIN 30509 //Casted by the cubes when channeling ends - -//Channeler spells -//#define MOB_HELLFIRE_CHANNELLER 17256 - -#define SPELL_SOUL_TRANSFER 30531 -#define SPELL_SHADOW_BOLT_VOLLEY 30510 -#define SPELL_DARK_MENDING 30528 -#define SPELL_HELLFIRE_CHANNELING 31059 -#define SPELL_HELLFIRE_CAST_VISUAL 24207 -#define SPELL_FEAR 39176 - -#define SPELL_BURNING_ABYSSAL 30511 - -// Unkown sounds -uint32 RandomSound[] = {10247, 10248, 10249, 10250, 10251, 10252}; - -struct MANGOS_DLL_DECL boss_magtheridonAI : public ScriptedAI -{ - boss_magtheridonAI(Creature *c) : ScriptedAI(c) - { - pInst = (ScriptedInstance*)m_creature->GetInstanceData(); - Reset(); - } - - ScriptedInstance* pInst; - - uint32 Phase1_Timer; - uint32 Cleave_Timer; - uint32 BlastNova_Timer; - uint32 Quake_Timer; - uint32 QuakePhase; - uint32 Collapse_Timer; - uint32 Berserk_Timer; - bool Banished; - bool Phase3; - - uint32 RandChat_Timer; - - void Reset() - { - RandChat_Timer = 90000; - - Phase1_Timer = 0; - Cleave_Timer = 15000; - Berserk_Timer = 1200000; //20 minutes - BlastNova_Timer = 60000; - Quake_Timer = 40000; - QuakePhase = 0; - Collapse_Timer = 0; - Banished = false; - - m_creature->setFaction(35); - m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); - m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - m_creature->CastSpell(m_creature, SPELL_SHADOW_CAGE, false); - - if(pInst) - pInst->SetData(DATA_MAGTHERIDON_EVENT_ENDED, false); - } - - void KilledUnit(Unit* victim) - { - DoYell(SAY_PLAYER_KILLED, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_PLAYER_KILLED); - } - - void JustDied(Unit* Killer) - { - DoYell(SAY_DEATH,LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_DEATH); - } - - void Aggro(Unit *who) {} - - void MoveInLineOfSight(Unit* who) {} - - void UpdateAI(const uint32 diff) - { - if (!InCombat && !Phase1_Timer) - if (RandChat_Timer < diff) - { - DoPlaySoundToSet(m_creature, RandomSound[rand()%5]); - - RandChat_Timer = 90000; - }else RandChat_Timer -= diff; - - if (!InCombat && !Phase1_Timer && pInst && pInst->GetData64(DATA_EVENT_STARTER)) - { - //Unbanish self after 2 minutes - Phase1_Timer = 120000; - DoTextEmote(EMOTE_BEGIN, NULL); - return; - } - - //Phase timer - if (Phase1_Timer) - if (Phase1_Timer <= diff) - { - m_creature->setFaction(14); - m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); - m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - - DoYell(SAY_FREED, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_FREED); - m_creature->RemoveAurasDueToSpell(SPELL_SHADOW_CAGE); - AttackStart(Unit::GetUnit(*m_creature, pInst->GetData64(DATA_EVENT_STARTER))); - - Phase1_Timer = 0; - }else - { - if (!Unit::GetUnit(*m_creature, pInst->GetData64(DATA_EVENT_STARTER))) - { - Phase1_Timer = 0; - return; - } - - Phase1_Timer -= diff; - return; - } - - //Return since we have no target - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - //Interrupt Blast Nova - if (m_creature->HasAura(SPELL_SHADOW_GRASP_VIS, 0) && m_creature->HasAura(SPELL_BLASTNOVA, 0) && !Banished) - { - DoYell(SAY_BANISH, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_BANISH); - m_creature->RemoveAurasDueToSpell(SPELL_BLASTNOVA); - m_creature->InterruptNonMeleeSpells(false); - DoCast(m_creature, SPELL_SHADOW_CAGE_2); - Banished = true; - } - - if (Banished && !m_creature->HasAura(SPELL_SHADOW_GRASP_VIS, 0)) - { - Banished = false; - m_creature->RemoveAurasDueToSpell(SPELL_SHADOW_CAGE_2); - } - - //Berserk_Timer - if (Berserk_Timer < diff) - { - DoCast(m_creature, SPELL_BERSERK); - DoTextEmote(EMOTE_BERSERK, NULL); - - Berserk_Timer = 300000; - }else Berserk_Timer -= diff; - - //Cleave_Timer - if (Cleave_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_CLEAVE); - Cleave_Timer = 10000; - }else Cleave_Timer -= diff; - - //Quake_Timer - if (Quake_Timer < diff) - { - int32 i = SPELL_QUAKE_PROC; - m_creature->CastCustomSpell(m_creature, SPELL_QUAKE, &i, 0, 0, false); - - Quake_Timer = 40000; - }else Quake_Timer -= diff; - - //BlastNova_Timer - if (BlastNova_Timer < diff) - { - //Inturrupt Quake if it is casting - m_creature->InterruptNonMeleeSpells(false); - - DoTextEmote(EMOTE_BLASTNOVA, NULL); - DoCast(m_creature, SPELL_BLASTNOVA); - - BlastNova_Timer = 40000; - }else BlastNova_Timer -= diff; - - //Phase3 if not already enraged and below 30% - if (!Phase3 && (m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < 30) - { - Phase3 = true; - - DoYell(SAY_CHAMBER_DESTROY, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_CHAMBER_DESTROY); - } - - //Melee - DoMeleeAttackIfReady(); - } -}; - -struct MANGOS_DLL_DECL mob_hellfire_channelerAI : public ScriptedAI -{ - mob_hellfire_channelerAI(Creature *c) : ScriptedAI(c) - { - pInst = (ScriptedInstance*)m_creature->GetInstanceData(); - Reset(); - } - - ScriptedInstance* pInst; - - uint32 ShadowBoltVolley_Timer; - uint32 DarkMending_Timer; - uint32 Fear_Timer; - uint32 Infernal_Timer; - - bool InfernalSpawned; - - void Reset() - { - ShadowBoltVolley_Timer = 8000 + rand()%2000; - DarkMending_Timer = 30000; - Fear_Timer = 15000 + rand()%5000; - Infernal_Timer = 20000 + rand()%5000; - - InfernalSpawned = false; - - //Suprisingly this works very well, but only if the channelers are spawned after magtheridon - DoCast(m_creature, SPELL_SHADOW_GRASP_VIS); - if(pInst) - pInst->SetData(DATA_MAGTHERIDON_EVENT_ENDED, false); - } - - void Aggro(Unit *who) - { - m_creature->InterruptNonMeleeSpells(false); - - if(!pInst || pInst->GetData64(DATA_EVENT_STARTER)) - return; - - pInst->SetData64(DATA_EVENT_STARTER, who->GetGUID()); - pInst->SetData(DATA_MAGTHERIDON_EVENT_STARTED, true); - } - - void MoveInLineOfSight(Unit*) - { - } - - void UpdateAI(const uint32 diff) - { - if (!InCombat && pInst && pInst->GetData64(DATA_EVENT_STARTER)) - { - m_creature->InterruptNonMeleeSpells(false); - AttackStart(Unit::GetUnit(*m_creature, pInst->GetData64(DATA_EVENT_STARTER))); - return; - } - - //Return since we have no target - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - //Shadow bolt volley - if (ShadowBoltVolley_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_SHADOW_BOLT_VOLLEY); - - ShadowBoltVolley_Timer = 10000 + (rand()%10000); - }else ShadowBoltVolley_Timer -= diff; - - //Dark Mending - if (DarkMending_Timer < diff) - { - if ((m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < 50) - { - //Cast on ourselves if we are lower then lowest hp friendly unit - /*if (pLowestHPTarget && LowestHP < m_creature->GetHealth()) - DoCast(pLowestHPTarget, SPELL_DARK_MENDING); - else*/ - DoCast(m_creature, SPELL_DARK_MENDING); - } - - DarkMending_Timer = 10000 + (rand() % 10000); - }else DarkMending_Timer -= diff; - - //Fear - if (Fear_Timer < diff) - { - Unit* target = NULL; - target = SelectUnit(SELECT_TARGET_RANDOM, 1); - - if (target) - DoCast(target,SPELL_FEAR); - - Fear_Timer = 25000 + (rand()%15000); - }else Fear_Timer -= diff; - - //Infernal spawning - if (!InfernalSpawned && Infernal_Timer < diff) - { - Unit* target = NULL; - target = SelectUnit(SELECT_TARGET_RANDOM, 0); - - if (target) - DoCast(target, SPELL_BURNING_ABYSSAL); - - InfernalSpawned = true; - }else Infernal_Timer -= diff; - - DoMeleeAttackIfReady(); - } - -}; - -//Manticron Cube -bool GOHello_go_Manticron_Cube(Player *player, GameObject* _GO) -{ - ScriptedInstance* pInst = (ScriptedInstance*)_GO->GetInstanceData(); - - Unit* pUnit = NULL; - if(pInst) - pUnit = Unit::GetUnit(*_GO, pInst->GetData64(DATA_MAGTHERIDON)); - else - { - _GO->TextEmote("Manticron Cube: NO INSTANCE", 0); - return true; - } - - if (!pUnit || !pUnit->isAlive() || !player) - { - _GO->TextEmote("Mantricon Cube: NO TARGET", 0); - return true; - } - - player->InterruptNonMeleeSpells(false); - player->CastSpell(pUnit, SPELL_SHADOW_GRASP, true); - player->CastSpell(pUnit, SPELL_SHADOW_GRASP_VIS, false); - - _GO->Say("Mantricon Cube Clicked", LANG_UNIVERSAL, 0); - return true; -} - -CreatureAI* GetAI_boss_magtheridon(Creature *_Creature) -{ - return new boss_magtheridonAI (_Creature); -} - -CreatureAI* GetAI_mob_hellfire_channeler(Creature *_Creature) -{ - return new mob_hellfire_channelerAI (_Creature); -} - -void AddSC_boss_magtheridon() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_magtheridon"; - newscript->GetAI = GetAI_boss_magtheridon; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="mob_hellfire_channeler"; - newscript->GetAI = GetAI_mob_hellfire_channeler; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="go_manticron_cube"; - newscript->pGOHello = &GOHello_go_Manticron_Cube; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Magtheridon +SD%Complete: 60 +SDComment: In Development +SDCategory: Hellfire Citadel, Magtheridon's lair +EndScriptData */ + +#include "precompiled.h" +#include "def_magtheridons_lair.h" +#include "WorldPacket.h" + +//Phase 2 Spells +#define SPELL_QUAKE_PROC 30571 +#define SPELL_QUAKE 30576 //must be cast with 30561 as the proc spell +#define SPELL_BLASTNOVA 30616 +#define SPELL_CLEAVE 30619 +#define SPELL_BERSERK 27680 +#define SPELL_DEBRIS 30631 +#define SPELL_CAMERA_SHAKE 36455 + +//Banish +#define SPELL_SHADOW_CAGE 30205 + +//Player version of the banish +#define SPELL_SHADOW_CAGE_2 30168 + +//Spell that is cast on players from the cube +#define SPELL_SHADOW_GRASP 30410 +#define SPELL_SHADOW_GRASP_UKN 30166 +#define SPELL_SHADOW_GRASP_VIS 30207 + +//Dialog +#define SAY_AGGRO "Thank you for releasing me. Now...die!" +#define SOUND_AGGRO 10254 + +#define SAY_BANISH "Not again...NOT AGAIN!" +#define SOUND_BANISH 10256 + +#define SAY_FREED "I...am...UNLEASHED!!!" +#define SOUND_FREED 10253 + +#define SAY_CHAMBER_DESTROY "I will not be taken so easily. Let the walls of this prison tremble...and FALL!!!" +#define SOUND_CHAMBER_DESTROY 10257 + +#define SAY_PLAYER_KILLED "Did you think me weak? Soft? Who is the weak one now?!" +#define SOUND_PLAYER_KILLED 10255 + +#define SAY_DEATH "The Legion...will consume you...all...." +#define SOUND_DEATH 10258 + +#define EMOTE_BERSERK "becomes enraged!" +#define EMOTE_BLASTNOVA "begins to cast Blast Nova!" +#define EMOTE_BEGIN "%s's bonds begin to weaken!" + +//Spawned objects +#define SPELL_COLLAPSE 34233 //This spell casted by the "cave in" type object + +#define SPELL_CONFLAGERATION 35840 //Actually casted by a creature or object spawned on the ground + +//Cubes +#define SPELL_MIND_EXHAUSTIOIN 30509 //Casted by the cubes when channeling ends + +//Channeler spells +//#define MOB_HELLFIRE_CHANNELLER 17256 + +#define SPELL_SOUL_TRANSFER 30531 +#define SPELL_SHADOW_BOLT_VOLLEY 30510 +#define SPELL_DARK_MENDING 30528 +#define SPELL_HELLFIRE_CHANNELING 31059 +#define SPELL_HELLFIRE_CAST_VISUAL 24207 +#define SPELL_FEAR 39176 + +#define SPELL_BURNING_ABYSSAL 30511 + +// Unkown sounds +uint32 RandomSound[] = {10247, 10248, 10249, 10250, 10251, 10252}; + +struct MANGOS_DLL_DECL boss_magtheridonAI : public ScriptedAI +{ + boss_magtheridonAI(Creature *c) : ScriptedAI(c) + { + pInst = (ScriptedInstance*)m_creature->GetInstanceData(); + Reset(); + } + + ScriptedInstance* pInst; + + uint32 Phase1_Timer; + uint32 Cleave_Timer; + uint32 BlastNova_Timer; + uint32 Quake_Timer; + uint32 QuakePhase; + uint32 Collapse_Timer; + uint32 Berserk_Timer; + bool Banished; + bool Phase3; + + uint32 RandChat_Timer; + + void Reset() + { + RandChat_Timer = 90000; + + Phase1_Timer = 0; + Cleave_Timer = 15000; + Berserk_Timer = 1200000; //20 minutes + BlastNova_Timer = 60000; + Quake_Timer = 40000; + QuakePhase = 0; + Collapse_Timer = 0; + Banished = false; + + m_creature->setFaction(35); + m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + m_creature->CastSpell(m_creature, SPELL_SHADOW_CAGE, false); + + if(pInst) + pInst->SetData(DATA_MAGTHERIDON_EVENT_ENDED, false); + } + + void KilledUnit(Unit* victim) + { + DoYell(SAY_PLAYER_KILLED, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_PLAYER_KILLED); + } + + void JustDied(Unit* Killer) + { + DoYell(SAY_DEATH,LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_DEATH); + } + + void Aggro(Unit *who) {} + + void MoveInLineOfSight(Unit* who) {} + + void UpdateAI(const uint32 diff) + { + if (!InCombat && !Phase1_Timer) + if (RandChat_Timer < diff) + { + DoPlaySoundToSet(m_creature, RandomSound[rand()%5]); + + RandChat_Timer = 90000; + }else RandChat_Timer -= diff; + + if (!InCombat && !Phase1_Timer && pInst && pInst->GetData64(DATA_EVENT_STARTER)) + { + //Unbanish self after 2 minutes + Phase1_Timer = 120000; + DoTextEmote(EMOTE_BEGIN, NULL); + return; + } + + //Phase timer + if (Phase1_Timer) + if (Phase1_Timer <= diff) + { + m_creature->setFaction(14); + m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + + DoYell(SAY_FREED, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_FREED); + m_creature->RemoveAurasDueToSpell(SPELL_SHADOW_CAGE); + AttackStart(Unit::GetUnit(*m_creature, pInst->GetData64(DATA_EVENT_STARTER))); + + Phase1_Timer = 0; + }else + { + if (!Unit::GetUnit(*m_creature, pInst->GetData64(DATA_EVENT_STARTER))) + { + Phase1_Timer = 0; + return; + } + + Phase1_Timer -= diff; + return; + } + + //Return since we have no target + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + //Interrupt Blast Nova + if (m_creature->HasAura(SPELL_SHADOW_GRASP_VIS, 0) && m_creature->HasAura(SPELL_BLASTNOVA, 0) && !Banished) + { + DoYell(SAY_BANISH, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_BANISH); + m_creature->RemoveAurasDueToSpell(SPELL_BLASTNOVA); + m_creature->InterruptNonMeleeSpells(false); + DoCast(m_creature, SPELL_SHADOW_CAGE_2); + Banished = true; + } + + if (Banished && !m_creature->HasAura(SPELL_SHADOW_GRASP_VIS, 0)) + { + Banished = false; + m_creature->RemoveAurasDueToSpell(SPELL_SHADOW_CAGE_2); + } + + //Berserk_Timer + if (Berserk_Timer < diff) + { + DoCast(m_creature, SPELL_BERSERK); + DoTextEmote(EMOTE_BERSERK, NULL); + + Berserk_Timer = 300000; + }else Berserk_Timer -= diff; + + //Cleave_Timer + if (Cleave_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_CLEAVE); + Cleave_Timer = 10000; + }else Cleave_Timer -= diff; + + //Quake_Timer + if (Quake_Timer < diff) + { + int32 i = SPELL_QUAKE_PROC; + m_creature->CastCustomSpell(m_creature, SPELL_QUAKE, &i, 0, 0, false); + + Quake_Timer = 40000; + }else Quake_Timer -= diff; + + //BlastNova_Timer + if (BlastNova_Timer < diff) + { + //Inturrupt Quake if it is casting + m_creature->InterruptNonMeleeSpells(false); + + DoTextEmote(EMOTE_BLASTNOVA, NULL); + DoCast(m_creature, SPELL_BLASTNOVA); + + BlastNova_Timer = 40000; + }else BlastNova_Timer -= diff; + + //Phase3 if not already enraged and below 30% + if (!Phase3 && (m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < 30) + { + Phase3 = true; + + DoYell(SAY_CHAMBER_DESTROY, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_CHAMBER_DESTROY); + } + + //Melee + DoMeleeAttackIfReady(); + } +}; + +struct MANGOS_DLL_DECL mob_hellfire_channelerAI : public ScriptedAI +{ + mob_hellfire_channelerAI(Creature *c) : ScriptedAI(c) + { + pInst = (ScriptedInstance*)m_creature->GetInstanceData(); + Reset(); + } + + ScriptedInstance* pInst; + + uint32 ShadowBoltVolley_Timer; + uint32 DarkMending_Timer; + uint32 Fear_Timer; + uint32 Infernal_Timer; + + bool InfernalSpawned; + + void Reset() + { + ShadowBoltVolley_Timer = 8000 + rand()%2000; + DarkMending_Timer = 30000; + Fear_Timer = 15000 + rand()%5000; + Infernal_Timer = 20000 + rand()%5000; + + InfernalSpawned = false; + + //Suprisingly this works very well, but only if the channelers are spawned after magtheridon + DoCast(m_creature, SPELL_SHADOW_GRASP_VIS); + if(pInst) + pInst->SetData(DATA_MAGTHERIDON_EVENT_ENDED, false); + } + + void Aggro(Unit *who) + { + m_creature->InterruptNonMeleeSpells(false); + + if(!pInst || pInst->GetData64(DATA_EVENT_STARTER)) + return; + + pInst->SetData64(DATA_EVENT_STARTER, who->GetGUID()); + pInst->SetData(DATA_MAGTHERIDON_EVENT_STARTED, true); + } + + void MoveInLineOfSight(Unit*) + { + } + + void UpdateAI(const uint32 diff) + { + if (!InCombat && pInst && pInst->GetData64(DATA_EVENT_STARTER)) + { + m_creature->InterruptNonMeleeSpells(false); + AttackStart(Unit::GetUnit(*m_creature, pInst->GetData64(DATA_EVENT_STARTER))); + return; + } + + //Return since we have no target + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + //Shadow bolt volley + if (ShadowBoltVolley_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_SHADOW_BOLT_VOLLEY); + + ShadowBoltVolley_Timer = 10000 + (rand()%10000); + }else ShadowBoltVolley_Timer -= diff; + + //Dark Mending + if (DarkMending_Timer < diff) + { + if ((m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < 50) + { + //Cast on ourselves if we are lower then lowest hp friendly unit + /*if (pLowestHPTarget && LowestHP < m_creature->GetHealth()) + DoCast(pLowestHPTarget, SPELL_DARK_MENDING); + else*/ + DoCast(m_creature, SPELL_DARK_MENDING); + } + + DarkMending_Timer = 10000 + (rand() % 10000); + }else DarkMending_Timer -= diff; + + //Fear + if (Fear_Timer < diff) + { + Unit* target = NULL; + target = SelectUnit(SELECT_TARGET_RANDOM, 1); + + if (target) + DoCast(target,SPELL_FEAR); + + Fear_Timer = 25000 + (rand()%15000); + }else Fear_Timer -= diff; + + //Infernal spawning + if (!InfernalSpawned && Infernal_Timer < diff) + { + Unit* target = NULL; + target = SelectUnit(SELECT_TARGET_RANDOM, 0); + + if (target) + DoCast(target, SPELL_BURNING_ABYSSAL); + + InfernalSpawned = true; + }else Infernal_Timer -= diff; + + DoMeleeAttackIfReady(); + } + +}; + +//Manticron Cube +bool GOHello_go_Manticron_Cube(Player *player, GameObject* _GO) +{ + ScriptedInstance* pInst = (ScriptedInstance*)_GO->GetInstanceData(); + + Unit* pUnit = NULL; + if(pInst) + pUnit = Unit::GetUnit(*_GO, pInst->GetData64(DATA_MAGTHERIDON)); + else + { + _GO->TextEmote("Manticron Cube: NO INSTANCE", 0); + return true; + } + + if (!pUnit || !pUnit->isAlive() || !player) + { + _GO->TextEmote("Mantricon Cube: NO TARGET", 0); + return true; + } + + player->InterruptNonMeleeSpells(false); + player->CastSpell(pUnit, SPELL_SHADOW_GRASP, true); + player->CastSpell(pUnit, SPELL_SHADOW_GRASP_VIS, false); + + _GO->Say("Mantricon Cube Clicked", LANG_UNIVERSAL, 0); + return true; +} + +CreatureAI* GetAI_boss_magtheridon(Creature *_Creature) +{ + return new boss_magtheridonAI (_Creature); +} + +CreatureAI* GetAI_mob_hellfire_channeler(Creature *_Creature) +{ + return new mob_hellfire_channelerAI (_Creature); +} + +void AddSC_boss_magtheridon() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_magtheridon"; + newscript->GetAI = GetAI_boss_magtheridon; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="mob_hellfire_channeler"; + newscript->GetAI = GetAI_mob_hellfire_channeler; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="go_manticron_cube"; + newscript->pGOHello = &GOHello_go_Manticron_Cube; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/hellfire_citadel/magtheridons_lair/def_magtheridons_lair.h b/src/bindings/scripts/scripts/zone/hellfire_citadel/magtheridons_lair/def_magtheridons_lair.h index dab98703c15..3001a964c34 100644 --- a/src/bindings/scripts/scripts/zone/hellfire_citadel/magtheridons_lair/def_magtheridons_lair.h +++ b/src/bindings/scripts/scripts/zone/hellfire_citadel/magtheridons_lair/def_magtheridons_lair.h @@ -1,13 +1,13 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software licensed under GPL version 2 - * Please see the included DOCS/LICENSE.TXT for more information */ - -#ifndef DEF_MAGTHERIDONS_LAIR_H -#define DEF_MAGTHERIDONS_LAIR_H - -#define DATA_EVENT_STARTER 1 -#define DATA_MAGTHERIDON 2 -#define DATA_MAGTHERIDON_EVENT_ENDED 3 -#define DATA_MAGTHERIDON_EVENT_STARTED 4 -#define DATA_MAGTHERIDON_EVENT_STATUS 5 -#endif +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software licensed under GPL version 2 + * Please see the included DOCS/LICENSE.TXT for more information */ + +#ifndef DEF_MAGTHERIDONS_LAIR_H +#define DEF_MAGTHERIDONS_LAIR_H + +#define DATA_EVENT_STARTER 1 +#define DATA_MAGTHERIDON 2 +#define DATA_MAGTHERIDON_EVENT_ENDED 3 +#define DATA_MAGTHERIDON_EVENT_STARTED 4 +#define DATA_MAGTHERIDON_EVENT_STATUS 5 +#endif diff --git a/src/bindings/scripts/scripts/zone/hellfire_citadel/magtheridons_lair/instance_magtheridons_lair.cpp b/src/bindings/scripts/scripts/zone/hellfire_citadel/magtheridons_lair/instance_magtheridons_lair.cpp index 91ce5ce453c..63a6f02f9a1 100644 --- a/src/bindings/scripts/scripts/zone/hellfire_citadel/magtheridons_lair/instance_magtheridons_lair.cpp +++ b/src/bindings/scripts/scripts/zone/hellfire_citadel/magtheridons_lair/instance_magtheridons_lair.cpp @@ -1,116 +1,116 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Instance_Magtheridons_Lair -SD%Complete: 100 -SDComment: -SDCategory: Hellfire Citadel, Magtheridon's lair -EndScriptData */ - -#include "precompiled.h" -#include "def_magtheridons_lair.h" - -struct MANGOS_DLL_DECL instance_magtheridons_lair : public ScriptedInstance -{ - instance_magtheridons_lair(Map *Map) : ScriptedInstance(Map) {Initialize();}; - - bool EncounterInProgress; - uint64 Magtheridon; - uint64 EventStarter; - - void Initialize() - { - Magtheridon = 0; - EventStarter = 0; - EncounterInProgress = false; - } - - bool IsEncounterInProgress() const - { - return EncounterInProgress; - } - - void OnCreatureCreate(Creature *creature, uint32 creature_entry) - { - if (creature_entry == 17257) - Magtheridon = creature->GetGUID(); - } - - uint64 GetData64(uint32 identifier) - { - switch(identifier) - { - case DATA_MAGTHERIDON: - return Magtheridon; - - case DATA_EVENT_STARTER: - return EventStarter; - } - return 0; - } - - void SetData64(uint32 identifier, uint64 guid) - { - switch(identifier) - { - case DATA_MAGTHERIDON: - Magtheridon = guid; - break; - - case DATA_EVENT_STARTER: - EventStarter = guid; - break; - } - } - - void SetData(uint32 type, uint32 data) - { - switch(type) - { - case DATA_MAGTHERIDON_EVENT_STARTED: - EncounterInProgress = true; - break; - - case DATA_MAGTHERIDON_EVENT_ENDED: - EncounterInProgress = false; - EventStarter = 0; - break; - } - } - - uint32 GetData(uint32 type) - { - if(type == DATA_MAGTHERIDON_EVENT_STATUS) - return EncounterInProgress; - - return 0; - } -}; - -InstanceData* GetInstanceData_instance_magtheridons_lair(Map* map) -{ - return new instance_magtheridons_lair(map); -} - -void AddSC_instance_magtheridons_lair() -{ - Script *newscript; - newscript = new Script; - newscript->Name = "instance_magtheridons_lair"; - newscript->GetInstanceData = GetInstanceData_instance_magtheridons_lair; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Instance_Magtheridons_Lair +SD%Complete: 100 +SDComment: +SDCategory: Hellfire Citadel, Magtheridon's lair +EndScriptData */ + +#include "precompiled.h" +#include "def_magtheridons_lair.h" + +struct MANGOS_DLL_DECL instance_magtheridons_lair : public ScriptedInstance +{ + instance_magtheridons_lair(Map *Map) : ScriptedInstance(Map) {Initialize();}; + + bool EncounterInProgress; + uint64 Magtheridon; + uint64 EventStarter; + + void Initialize() + { + Magtheridon = 0; + EventStarter = 0; + EncounterInProgress = false; + } + + bool IsEncounterInProgress() const + { + return EncounterInProgress; + } + + void OnCreatureCreate(Creature *creature, uint32 creature_entry) + { + if (creature_entry == 17257) + Magtheridon = creature->GetGUID(); + } + + uint64 GetData64(uint32 identifier) + { + switch(identifier) + { + case DATA_MAGTHERIDON: + return Magtheridon; + + case DATA_EVENT_STARTER: + return EventStarter; + } + return 0; + } + + void SetData64(uint32 identifier, uint64 guid) + { + switch(identifier) + { + case DATA_MAGTHERIDON: + Magtheridon = guid; + break; + + case DATA_EVENT_STARTER: + EventStarter = guid; + break; + } + } + + void SetData(uint32 type, uint32 data) + { + switch(type) + { + case DATA_MAGTHERIDON_EVENT_STARTED: + EncounterInProgress = true; + break; + + case DATA_MAGTHERIDON_EVENT_ENDED: + EncounterInProgress = false; + EventStarter = 0; + break; + } + } + + uint32 GetData(uint32 type) + { + if(type == DATA_MAGTHERIDON_EVENT_STATUS) + return EncounterInProgress; + + return 0; + } +}; + +InstanceData* GetInstanceData_instance_magtheridons_lair(Map* map) +{ + return new instance_magtheridons_lair(map); +} + +void AddSC_instance_magtheridons_lair() +{ + Script *newscript; + newscript = new Script; + newscript->Name = "instance_magtheridons_lair"; + newscript->GetInstanceData = GetInstanceData_instance_magtheridons_lair; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/hellfire_citadel/shattered_halls/boss_nethekurse.cpp b/src/bindings/scripts/scripts/zone/hellfire_citadel/shattered_halls/boss_nethekurse.cpp index fa2619cc8fc..286913c8881 100644 --- a/src/bindings/scripts/scripts/zone/hellfire_citadel/shattered_halls/boss_nethekurse.cpp +++ b/src/bindings/scripts/scripts/zone/hellfire_citadel/shattered_halls/boss_nethekurse.cpp @@ -1,505 +1,505 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Grand_Warlock_Nethekurse -SD%Complete: 75 -SDComment: encounter not fully complete. missing part where boss kill minions. -SDCategory: Hellfire Citadel, Shattered Halls -EndScriptData */ - -/* ContentData -boss_grand_warlock_nethekurse -mob_fel_orc_convert -mob_lesser_shadow_fissure -EndContentData */ - -#include "precompiled.h" -#include "def_shattered_halls.h" - -struct Say -{ - const char* text; - uint32 sound; -}; - -#define SAY_INTRO "You wish to fight us all at once? This should be amusing!" -#define SOUND_INTRO 10262 - -static Say PeonAttacked[]= -{ - {"You can have that one. I no longer need him.", 10263}, - {"Yes, beat him mercilessly. His skull is a thick as an ogres.", 10264}, - {"Don't waste your time on that one. He's weak!", 10265}, - {"You want him? Very well, take him!", 10266}, -}; -static Say PeonDies[]= -{ - {"One pitiful wretch down. Go on, take another one.", 10267}, - {"Ahh, what a waste... Next!", 10268}, - {"I was going to kill him anyway!", 10269}, - {"Thank you for saving me the trouble! Now it's my turn to have some fun...", 10270}, -}; - -#define SAY_TAUNT_1 "Beg for your pittyfull life!" -#define SOUND_TAUNT_1 10259 -#define SAY_TAUNT_2 "Run covad, ruun!" -#define SOUND_TAUNT_2 10260 -#define SAY_TAUNT_3 "Your pain amuses me." -#define SOUND_TAUNT_3 10261 - -#define SAY_AGGRO_1 "I'm already bored." -#define SOUND_AGGRO_1 10271 -#define SAY_AGGRO_2 "Come on! ... Show me a real fight." -#define SOUND_AGGRO_2 10272 -#define SAY_AGGRO_3 "I had more fun torturing the peons." -#define SOUND_AGGRO_3 10273 - -#define SAY_SLAY_1 "You Loose." -#define SOUND_SLAY_1 10274 -#define SAY_SLAY_2 "Ohh! Just die." -#define SOUND_SLAY_2 10275 - -#define SAY_DIE "What a ... a shame." -#define SOUND_DIE 10276 - -#define SPELL_DEATH_COIL 30500 -#define SPELL_DARK_SPIN 30502 // core bug spell attack caster :D -#define SPELL_SHADOW_FISSURE 30496 // Summon the ShadowFissure NPC - -#define SPELL_SHADOW_CLEAVE 30495 -#define H_SPELL_SHADOW_SLAM 35953 - -#define SPELL_HEMORRHAGE 30478 - -#define SPELL_CONSUMPTION 30497 -#define SPELL_TEMPORARY_VISUAL 39312 // this is wrong, a temporary solution. spell consumption already has the purple visual, but doesn't display as it should - -struct MANGOS_DLL_DECL boss_grand_warlock_nethekurseAI : public ScriptedAI -{ - boss_grand_warlock_nethekurseAI(Creature *c) : ScriptedAI(c) - { - pInstance = ((ScriptedInstance*)c->GetInstanceData()); - Reset(); - } - - ScriptedInstance* pInstance; - - bool HeroicMode; - bool IntroOnce; - bool IsIntroEvent; - bool IsMainEvent; - bool SpinOnce; - //bool HasTaunted; - bool Phase; - - uint32 PeonEngagedCount; - uint32 PeonKilledCount; - - uint32 IntroEvent_Timer; - uint32 DeathCoil_Timer; - uint32 ShadowFissure_Timer; - uint32 Cleave_Timer; - - void Reset() - { - m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); - - HeroicMode = m_creature->GetMap()->IsHeroic(); - IsIntroEvent = false; - IntroOnce = false; - IsMainEvent = false; - //HasTaunted = false; - SpinOnce = false; - Phase = false; - - PeonEngagedCount = 0; - PeonKilledCount = 0; - - IntroEvent_Timer = 90000; //how long before getting bored and kills his minions? - DeathCoil_Timer = 20000; - ShadowFissure_Timer = 8000; - Cleave_Timer = 5000; - } - - void DoYellForPeonAggro() - { - if( PeonEngagedCount >= 4 ) - return; - - DoYell(PeonAttacked[PeonEngagedCount].text, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, PeonAttacked[PeonEngagedCount].sound); - ++PeonEngagedCount; - } - - void DoYellForPeonDeath() - { - if( PeonKilledCount >= 4 ) - return; - - DoYell(PeonDies[PeonKilledCount].text, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, PeonDies[PeonKilledCount].sound); - ++PeonKilledCount; - - if( PeonKilledCount == 4 ) - { - IsIntroEvent = false; - IsMainEvent = true; - m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); - } - } - - void DoTauntPeons() - { - switch(rand()%3) - { - case 0: - DoPlaySoundToSet(m_creature,SOUND_TAUNT_1); - DoYell(SAY_TAUNT_1,LANG_UNIVERSAL,NULL); - break; - case 1: - DoPlaySoundToSet(m_creature,SOUND_TAUNT_2); - DoYell(SAY_TAUNT_2,LANG_UNIVERSAL,NULL); - break; - case 2: - DoPlaySoundToSet(m_creature,SOUND_TAUNT_3); - DoYell(SAY_TAUNT_3,LANG_UNIVERSAL,NULL); - break; - } - - //TODO: kill the peons first - IsIntroEvent = false; - PeonEngagedCount = 4; - PeonKilledCount = 4; - IsMainEvent = true; - m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); - } - - void AttackStart(Unit* who) - { - if ( IsIntroEvent || !IsMainEvent ) - return; - - if( who->isTargetableForAttack() ) - { - if( Phase ) DoStartAttackNoMovement(who); - else DoStartAttackAndMovement(who); - - if( !InCombat ) - { - Aggro(who); - InCombat = true; - } - } - } - - void MoveInLineOfSight(Unit *who) - { - if( !m_creature->getVictim() && who->isTargetableForAttack() && ( m_creature->IsHostileTo( who )) && who->isInAccessablePlaceFor(m_creature) ) - { - if( !IntroOnce && m_creature->IsWithinDistInMap(who, 75) ) - { - DoYell(SAY_INTRO, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_INTRO); - IntroOnce = true; - IsIntroEvent = true; - - if( pInstance ) - pInstance->SetData(TYPE_NETHEKURSE,IN_PROGRESS); - } - - if( m_creature->GetDistanceZ(who) > CREATURE_Z_ATTACK_RANGE ) - return; - - if( IsIntroEvent || !IsMainEvent ) - return; - - float attackRadius = m_creature->GetAttackDistance(who); - if( m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->IsWithinLOSInMap(who) ) - { - if( Phase ) DoStartAttackNoMovement(who); - else DoStartAttackAndMovement(who); - - who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); - - if( !InCombat ) - { - Aggro(who); - InCombat = true; - } - } - } - } - - void Aggro(Unit *who) - { - switch(rand()%3) - { - case 0: - DoPlaySoundToSet(m_creature,SOUND_AGGRO_1); - DoYell(SAY_AGGRO_1,LANG_UNIVERSAL,NULL); - break; - case 1: - DoPlaySoundToSet(m_creature,SOUND_AGGRO_2); - DoYell(SAY_AGGRO_2,LANG_UNIVERSAL,NULL); - break; - case 2: - DoPlaySoundToSet(m_creature,SOUND_AGGRO_3); - DoYell(SAY_AGGRO_3,LANG_UNIVERSAL,NULL); - break; - } - } - - void JustSummoned(Creature *summoned) - { - summoned->setFaction(14); - summoned->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); - summoned->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - } - - void KilledUnit(Unit* victim) - { - switch(rand()%2) - { - case 0: - DoPlaySoundToSet(m_creature,SOUND_SLAY_1); - DoYell(SAY_SLAY_1,LANG_UNIVERSAL,NULL); - break; - case 1: - DoPlaySoundToSet(m_creature,SOUND_SLAY_2); - DoYell(SAY_SLAY_2,LANG_UNIVERSAL,NULL); - break; - } - } - - void JustDied(Unit* Killer) - { - DoPlaySoundToSet(m_creature,SOUND_DIE); - DoYell(SAY_DIE,LANG_UNIVERSAL,NULL); - - if( !pInstance ) - return; - - pInstance->SetData(TYPE_NETHEKURSE,DONE); - - if( pInstance->GetData64(DATA_NETHEKURSE_DOOR) ) - { - if( GameObject *Door = GameObject::GetGameObject(*m_creature,pInstance->GetData64(DATA_NETHEKURSE_DOOR)) ) - Door->SetGoState(0); - } - } - - void UpdateAI(const uint32 diff) - { - if( IsIntroEvent ) - { - if( !pInstance ) - return; - - if( pInstance->GetData(TYPE_NETHEKURSE) == IN_PROGRESS ) - { - if( IntroEvent_Timer < diff ) - { - DoTauntPeons(); - }else IntroEvent_Timer -= diff; - } - } - - if( !m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - if( !IsMainEvent ) - return; - - if( Phase ) - { - if( !SpinOnce ) - { - DoCast(m_creature->getVictim(),SPELL_DARK_SPIN); - SpinOnce = true; - } - - if( Cleave_Timer < diff ) - { - DoCast(m_creature->getVictim(),(HeroicMode ? H_SPELL_SHADOW_SLAM : SPELL_SHADOW_CLEAVE)); - Cleave_Timer = 6000+rand()%2500; - }else Cleave_Timer -= diff; - } - else - { - if( ShadowFissure_Timer < diff ) - { - if( Unit *target = SelectUnit(SELECT_TARGET_RANDOM,0) ) - DoCast(target,SPELL_SHADOW_FISSURE); - ShadowFissure_Timer = 7500+rand()%7500; - }else ShadowFissure_Timer -= diff; - - if( DeathCoil_Timer < diff ) - { - if( Unit *target = SelectUnit(SELECT_TARGET_RANDOM,0) ) - DoCast(target,SPELL_DEATH_COIL); - DeathCoil_Timer = 15000+rand()%5000; - }else DeathCoil_Timer -= diff; - - if( (m_creature->GetHealth()*100) / m_creature->GetMaxHealth() <= 20 ) - Phase = true; - - DoMeleeAttackIfReady(); - } - } -}; - -struct MANGOS_DLL_DECL mob_fel_orc_convertAI : public ScriptedAI -{ - mob_fel_orc_convertAI(Creature *c) : ScriptedAI(c) - { - pInstance = ((ScriptedInstance*)c->GetInstanceData()); - Reset(); - } - - ScriptedInstance* pInstance; - uint32 Hemorrhage_Timer; - - void Reset() - { - m_creature->SetNoCallAssistence(true); //we don't want any assistance (WE R HEROZ!) - Hemorrhage_Timer = 3000; - } - - void MoveInLineOfSight(Unit *who) - { - return; - } - - void Aggro(Unit* who) - { - if( pInstance ) - { - if( pInstance->GetData64(DATA_NETHEKURSE) ) - { - Creature *pKurse = (Creature*)Unit::GetUnit(*m_creature,pInstance->GetData64(DATA_NETHEKURSE)); - if( pKurse ) - ((boss_grand_warlock_nethekurseAI*)pKurse->AI())->DoYellForPeonAggro(); - } - - if( pInstance->GetData(TYPE_NETHEKURSE) == IN_PROGRESS ) - return; - else pInstance->SetData(TYPE_NETHEKURSE,IN_PROGRESS); - } - } - - void JustDied(Unit* Killer) - { - if( pInstance ) - { - if( pInstance->GetData64(DATA_NETHEKURSE) ) - { - Creature *pKurse = (Creature*)Unit::GetUnit(*m_creature,pInstance->GetData64(DATA_NETHEKURSE)); - if( pKurse ) - ((boss_grand_warlock_nethekurseAI*)pKurse->AI())->DoYellForPeonDeath(); - } - } - } - - void UpdateAI(const uint32 diff) - { - if( !m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - if( Hemorrhage_Timer < diff ) - { - DoCast(m_creature->getVictim(),SPELL_HEMORRHAGE); - Hemorrhage_Timer = 15000; - }else Hemorrhage_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; - -//NOTE: this creature are also summoned by other spells, for different creatures -struct MANGOS_DLL_DECL mob_lesser_shadow_fissureAI : public ScriptedAI -{ - mob_lesser_shadow_fissureAI(Creature *c) : ScriptedAI(c) {Reset();} - - bool Start; - uint32 Stop_Timer; - - void Reset() - { - Start = false; - Stop_Timer = 30000; - } - - void Aggro(Unit* who) { } - - void MoveInLineOfSight(Unit *who) { return; } - - void AttackStart(Unit* who) { return; } - - void UpdateAI(const uint32 diff) - { - if( !Start ) - { - //triggered spell of consumption does not properly show it's SpellVisual, hack it a bit - m_creature->CastSpell(m_creature,SPELL_TEMPORARY_VISUAL,true); - m_creature->CastSpell(m_creature,SPELL_CONSUMPTION,false); - Start = true; - } - - if( Stop_Timer < diff) - { - m_creature->setDeathState(JUST_DIED); - m_creature->SetHealth(0); - m_creature->CombatStop(); - m_creature->DeleteThreatList(); - }else Stop_Timer -= diff; - } -}; - -CreatureAI* GetAI_boss_grand_warlock_nethekurse(Creature *_Creature) -{ - return new boss_grand_warlock_nethekurseAI (_Creature); -} - -CreatureAI* GetAI_mob_fel_orc_convert(Creature *_Creature) -{ - return new mob_fel_orc_convertAI (_Creature); -} - -CreatureAI* GetAI_mob_lesser_shadow_fissure(Creature *_Creature) -{ - return new mob_lesser_shadow_fissureAI (_Creature); -} - -void AddSC_boss_grand_warlock_nethekurse() -{ - Script *newscript; - - newscript = new Script; - newscript->Name="boss_grand_warlock_nethekurse"; - newscript->GetAI = GetAI_boss_grand_warlock_nethekurse; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="mob_fel_orc_convert"; - newscript->GetAI = GetAI_mob_fel_orc_convert; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="mob_lesser_shadow_fissure"; - newscript->GetAI = GetAI_mob_lesser_shadow_fissure; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Grand_Warlock_Nethekurse +SD%Complete: 75 +SDComment: encounter not fully complete. missing part where boss kill minions. +SDCategory: Hellfire Citadel, Shattered Halls +EndScriptData */ + +/* ContentData +boss_grand_warlock_nethekurse +mob_fel_orc_convert +mob_lesser_shadow_fissure +EndContentData */ + +#include "precompiled.h" +#include "def_shattered_halls.h" + +struct Say +{ + const char* text; + uint32 sound; +}; + +#define SAY_INTRO "You wish to fight us all at once? This should be amusing!" +#define SOUND_INTRO 10262 + +static Say PeonAttacked[]= +{ + {"You can have that one. I no longer need him.", 10263}, + {"Yes, beat him mercilessly. His skull is a thick as an ogres.", 10264}, + {"Don't waste your time on that one. He's weak!", 10265}, + {"You want him? Very well, take him!", 10266}, +}; +static Say PeonDies[]= +{ + {"One pitiful wretch down. Go on, take another one.", 10267}, + {"Ahh, what a waste... Next!", 10268}, + {"I was going to kill him anyway!", 10269}, + {"Thank you for saving me the trouble! Now it's my turn to have some fun...", 10270}, +}; + +#define SAY_TAUNT_1 "Beg for your pittyfull life!" +#define SOUND_TAUNT_1 10259 +#define SAY_TAUNT_2 "Run covad, ruun!" +#define SOUND_TAUNT_2 10260 +#define SAY_TAUNT_3 "Your pain amuses me." +#define SOUND_TAUNT_3 10261 + +#define SAY_AGGRO_1 "I'm already bored." +#define SOUND_AGGRO_1 10271 +#define SAY_AGGRO_2 "Come on! ... Show me a real fight." +#define SOUND_AGGRO_2 10272 +#define SAY_AGGRO_3 "I had more fun torturing the peons." +#define SOUND_AGGRO_3 10273 + +#define SAY_SLAY_1 "You Loose." +#define SOUND_SLAY_1 10274 +#define SAY_SLAY_2 "Ohh! Just die." +#define SOUND_SLAY_2 10275 + +#define SAY_DIE "What a ... a shame." +#define SOUND_DIE 10276 + +#define SPELL_DEATH_COIL 30500 +#define SPELL_DARK_SPIN 30502 // core bug spell attack caster :D +#define SPELL_SHADOW_FISSURE 30496 // Summon the ShadowFissure NPC + +#define SPELL_SHADOW_CLEAVE 30495 +#define H_SPELL_SHADOW_SLAM 35953 + +#define SPELL_HEMORRHAGE 30478 + +#define SPELL_CONSUMPTION 30497 +#define SPELL_TEMPORARY_VISUAL 39312 // this is wrong, a temporary solution. spell consumption already has the purple visual, but doesn't display as it should + +struct MANGOS_DLL_DECL boss_grand_warlock_nethekurseAI : public ScriptedAI +{ + boss_grand_warlock_nethekurseAI(Creature *c) : ScriptedAI(c) + { + pInstance = ((ScriptedInstance*)c->GetInstanceData()); + Reset(); + } + + ScriptedInstance* pInstance; + + bool HeroicMode; + bool IntroOnce; + bool IsIntroEvent; + bool IsMainEvent; + bool SpinOnce; + //bool HasTaunted; + bool Phase; + + uint32 PeonEngagedCount; + uint32 PeonKilledCount; + + uint32 IntroEvent_Timer; + uint32 DeathCoil_Timer; + uint32 ShadowFissure_Timer; + uint32 Cleave_Timer; + + void Reset() + { + m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + + HeroicMode = m_creature->GetMap()->IsHeroic(); + IsIntroEvent = false; + IntroOnce = false; + IsMainEvent = false; + //HasTaunted = false; + SpinOnce = false; + Phase = false; + + PeonEngagedCount = 0; + PeonKilledCount = 0; + + IntroEvent_Timer = 90000; //how long before getting bored and kills his minions? + DeathCoil_Timer = 20000; + ShadowFissure_Timer = 8000; + Cleave_Timer = 5000; + } + + void DoYellForPeonAggro() + { + if( PeonEngagedCount >= 4 ) + return; + + DoYell(PeonAttacked[PeonEngagedCount].text, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, PeonAttacked[PeonEngagedCount].sound); + ++PeonEngagedCount; + } + + void DoYellForPeonDeath() + { + if( PeonKilledCount >= 4 ) + return; + + DoYell(PeonDies[PeonKilledCount].text, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, PeonDies[PeonKilledCount].sound); + ++PeonKilledCount; + + if( PeonKilledCount == 4 ) + { + IsIntroEvent = false; + IsMainEvent = true; + m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + } + } + + void DoTauntPeons() + { + switch(rand()%3) + { + case 0: + DoPlaySoundToSet(m_creature,SOUND_TAUNT_1); + DoYell(SAY_TAUNT_1,LANG_UNIVERSAL,NULL); + break; + case 1: + DoPlaySoundToSet(m_creature,SOUND_TAUNT_2); + DoYell(SAY_TAUNT_2,LANG_UNIVERSAL,NULL); + break; + case 2: + DoPlaySoundToSet(m_creature,SOUND_TAUNT_3); + DoYell(SAY_TAUNT_3,LANG_UNIVERSAL,NULL); + break; + } + + //TODO: kill the peons first + IsIntroEvent = false; + PeonEngagedCount = 4; + PeonKilledCount = 4; + IsMainEvent = true; + m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + } + + void AttackStart(Unit* who) + { + if ( IsIntroEvent || !IsMainEvent ) + return; + + if( who->isTargetableForAttack() ) + { + if( Phase ) DoStartAttackNoMovement(who); + else DoStartAttackAndMovement(who); + + if( !InCombat ) + { + Aggro(who); + InCombat = true; + } + } + } + + void MoveInLineOfSight(Unit *who) + { + if( !m_creature->getVictim() && who->isTargetableForAttack() && ( m_creature->IsHostileTo( who )) && who->isInAccessablePlaceFor(m_creature) ) + { + if( !IntroOnce && m_creature->IsWithinDistInMap(who, 75) ) + { + DoYell(SAY_INTRO, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_INTRO); + IntroOnce = true; + IsIntroEvent = true; + + if( pInstance ) + pInstance->SetData(TYPE_NETHEKURSE,IN_PROGRESS); + } + + if(!m_creature->canFly() && m_creature->GetDistanceZ(who) > CREATURE_Z_ATTACK_RANGE ) + return; + + if( IsIntroEvent || !IsMainEvent ) + return; + + float attackRadius = m_creature->GetAttackDistance(who); + if( m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->IsWithinLOSInMap(who) ) + { + if( Phase ) DoStartAttackNoMovement(who); + else DoStartAttackAndMovement(who); + + who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); + + if( !InCombat ) + { + Aggro(who); + InCombat = true; + } + } + } + } + + void Aggro(Unit *who) + { + switch(rand()%3) + { + case 0: + DoPlaySoundToSet(m_creature,SOUND_AGGRO_1); + DoYell(SAY_AGGRO_1,LANG_UNIVERSAL,NULL); + break; + case 1: + DoPlaySoundToSet(m_creature,SOUND_AGGRO_2); + DoYell(SAY_AGGRO_2,LANG_UNIVERSAL,NULL); + break; + case 2: + DoPlaySoundToSet(m_creature,SOUND_AGGRO_3); + DoYell(SAY_AGGRO_3,LANG_UNIVERSAL,NULL); + break; + } + } + + void JustSummoned(Creature *summoned) + { + summoned->setFaction(14); + summoned->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + summoned->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + } + + void KilledUnit(Unit* victim) + { + switch(rand()%2) + { + case 0: + DoPlaySoundToSet(m_creature,SOUND_SLAY_1); + DoYell(SAY_SLAY_1,LANG_UNIVERSAL,NULL); + break; + case 1: + DoPlaySoundToSet(m_creature,SOUND_SLAY_2); + DoYell(SAY_SLAY_2,LANG_UNIVERSAL,NULL); + break; + } + } + + void JustDied(Unit* Killer) + { + DoPlaySoundToSet(m_creature,SOUND_DIE); + DoYell(SAY_DIE,LANG_UNIVERSAL,NULL); + + if( !pInstance ) + return; + + pInstance->SetData(TYPE_NETHEKURSE,DONE); + + if( pInstance->GetData64(DATA_NETHEKURSE_DOOR) ) + { + if( GameObject *Door = GameObject::GetGameObject(*m_creature,pInstance->GetData64(DATA_NETHEKURSE_DOOR)) ) + Door->SetGoState(0); + } + } + + void UpdateAI(const uint32 diff) + { + if( IsIntroEvent ) + { + if( !pInstance ) + return; + + if( pInstance->GetData(TYPE_NETHEKURSE) == IN_PROGRESS ) + { + if( IntroEvent_Timer < diff ) + { + DoTauntPeons(); + }else IntroEvent_Timer -= diff; + } + } + + if( !m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + if( !IsMainEvent ) + return; + + if( Phase ) + { + if( !SpinOnce ) + { + DoCast(m_creature->getVictim(),SPELL_DARK_SPIN); + SpinOnce = true; + } + + if( Cleave_Timer < diff ) + { + DoCast(m_creature->getVictim(),(HeroicMode ? H_SPELL_SHADOW_SLAM : SPELL_SHADOW_CLEAVE)); + Cleave_Timer = 6000+rand()%2500; + }else Cleave_Timer -= diff; + } + else + { + if( ShadowFissure_Timer < diff ) + { + if( Unit *target = SelectUnit(SELECT_TARGET_RANDOM,0) ) + DoCast(target,SPELL_SHADOW_FISSURE); + ShadowFissure_Timer = 7500+rand()%7500; + }else ShadowFissure_Timer -= diff; + + if( DeathCoil_Timer < diff ) + { + if( Unit *target = SelectUnit(SELECT_TARGET_RANDOM,0) ) + DoCast(target,SPELL_DEATH_COIL); + DeathCoil_Timer = 15000+rand()%5000; + }else DeathCoil_Timer -= diff; + + if( (m_creature->GetHealth()*100) / m_creature->GetMaxHealth() <= 20 ) + Phase = true; + + DoMeleeAttackIfReady(); + } + } +}; + +struct MANGOS_DLL_DECL mob_fel_orc_convertAI : public ScriptedAI +{ + mob_fel_orc_convertAI(Creature *c) : ScriptedAI(c) + { + pInstance = ((ScriptedInstance*)c->GetInstanceData()); + Reset(); + } + + ScriptedInstance* pInstance; + uint32 Hemorrhage_Timer; + + void Reset() + { + m_creature->SetNoCallAssistence(true); //we don't want any assistance (WE R HEROZ!) + Hemorrhage_Timer = 3000; + } + + void MoveInLineOfSight(Unit *who) + { + return; + } + + void Aggro(Unit* who) + { + if( pInstance ) + { + if( pInstance->GetData64(DATA_NETHEKURSE) ) + { + Creature *pKurse = (Creature*)Unit::GetUnit(*m_creature,pInstance->GetData64(DATA_NETHEKURSE)); + if( pKurse ) + ((boss_grand_warlock_nethekurseAI*)pKurse->AI())->DoYellForPeonAggro(); + } + + if( pInstance->GetData(TYPE_NETHEKURSE) == IN_PROGRESS ) + return; + else pInstance->SetData(TYPE_NETHEKURSE,IN_PROGRESS); + } + } + + void JustDied(Unit* Killer) + { + if( pInstance ) + { + if( pInstance->GetData64(DATA_NETHEKURSE) ) + { + Creature *pKurse = (Creature*)Unit::GetUnit(*m_creature,pInstance->GetData64(DATA_NETHEKURSE)); + if( pKurse ) + ((boss_grand_warlock_nethekurseAI*)pKurse->AI())->DoYellForPeonDeath(); + } + } + } + + void UpdateAI(const uint32 diff) + { + if( !m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + if( Hemorrhage_Timer < diff ) + { + DoCast(m_creature->getVictim(),SPELL_HEMORRHAGE); + Hemorrhage_Timer = 15000; + }else Hemorrhage_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; + +//NOTE: this creature are also summoned by other spells, for different creatures +struct MANGOS_DLL_DECL mob_lesser_shadow_fissureAI : public ScriptedAI +{ + mob_lesser_shadow_fissureAI(Creature *c) : ScriptedAI(c) {Reset();} + + bool Start; + uint32 Stop_Timer; + + void Reset() + { + Start = false; + Stop_Timer = 30000; + } + + void Aggro(Unit* who) { } + + void MoveInLineOfSight(Unit *who) { return; } + + void AttackStart(Unit* who) { return; } + + void UpdateAI(const uint32 diff) + { + if( !Start ) + { + //triggered spell of consumption does not properly show it's SpellVisual, hack it a bit + m_creature->CastSpell(m_creature,SPELL_TEMPORARY_VISUAL,true); + m_creature->CastSpell(m_creature,SPELL_CONSUMPTION,false); + Start = true; + } + + if( Stop_Timer < diff) + { + m_creature->setDeathState(JUST_DIED); + m_creature->SetHealth(0); + m_creature->CombatStop(); + m_creature->DeleteThreatList(); + }else Stop_Timer -= diff; + } +}; + +CreatureAI* GetAI_boss_grand_warlock_nethekurse(Creature *_Creature) +{ + return new boss_grand_warlock_nethekurseAI (_Creature); +} + +CreatureAI* GetAI_mob_fel_orc_convert(Creature *_Creature) +{ + return new mob_fel_orc_convertAI (_Creature); +} + +CreatureAI* GetAI_mob_lesser_shadow_fissure(Creature *_Creature) +{ + return new mob_lesser_shadow_fissureAI (_Creature); +} + +void AddSC_boss_grand_warlock_nethekurse() +{ + Script *newscript; + + newscript = new Script; + newscript->Name="boss_grand_warlock_nethekurse"; + newscript->GetAI = GetAI_boss_grand_warlock_nethekurse; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="mob_fel_orc_convert"; + newscript->GetAI = GetAI_mob_fel_orc_convert; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="mob_lesser_shadow_fissure"; + newscript->GetAI = GetAI_mob_lesser_shadow_fissure; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/hellfire_citadel/shattered_halls/boss_warbringer_omrogg.cpp b/src/bindings/scripts/scripts/zone/hellfire_citadel/shattered_halls/boss_warbringer_omrogg.cpp index 96b4e6f29a0..81d9f6c5348 100644 --- a/src/bindings/scripts/scripts/zone/hellfire_citadel/shattered_halls/boss_warbringer_omrogg.cpp +++ b/src/bindings/scripts/scripts/zone/hellfire_citadel/shattered_halls/boss_warbringer_omrogg.cpp @@ -1,414 +1,414 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Warbringer_Omrogg -SD%Complete: 85 -SDComment: Heroic enabled. Spell timing may need additional tweaks -SDCategory: Hellfire Citadel, Shattered Halls -EndScriptData */ - -/* ContentData -mob_omrogg_heads -boss_warbringer_omrogg -EndContentData */ - -#include "precompiled.h" -#include "def_shattered_halls.h" - -#define ENTRY_LEFT_HEAD 19523 -#define ENTRY_RIGHT_HEAD 19524 - -struct Yell -{ - const char* text; - uint32 sound; - uint32 creature; -}; - -static Yell GoCombat[]= -{ - {"Smash!", 10306, ENTRY_LEFT_HEAD}, - {"If you nice me let you live.", 10308, ENTRY_LEFT_HEAD}, - {"Me hungry!", 10309, ENTRY_LEFT_HEAD}, -}; -static Yell GoCombatDelay[]= -{ - {"Why don't you let me do the talking?", 10317, ENTRY_RIGHT_HEAD}, - {"No, we will NOT let you live!", 10318, ENTRY_RIGHT_HEAD}, - {"You always hungry. That why we so fat!", 10319, ENTRY_RIGHT_HEAD}, -}; - -static Yell Threat[]= -{ - {"You stay here. Me go kill someone else!", 10303, ENTRY_LEFT_HEAD}, - {"What are you doing!", 10315, ENTRY_RIGHT_HEAD}, - {"Me kill someone else...", 10302, ENTRY_LEFT_HEAD}, - {"Me not like this one...",10300, ENTRY_LEFT_HEAD}, -}; -static Yell ThreatDelay1[]= -{ - {"That's not funny!", 10314, ENTRY_RIGHT_HEAD}, - {"Me get bored...", 10305, ENTRY_LEFT_HEAD}, - {"I'm not done yet, idiot!", 10313, ENTRY_RIGHT_HEAD}, - {"Hey you numbskull!", 10312, ENTRY_RIGHT_HEAD}, -}; -static Yell ThreatDelay2[]= -{ - {"Ha ha ha.", 10304, ENTRY_LEFT_HEAD}, - {"Whhy! He almost dead!", 10316, ENTRY_RIGHT_HEAD}, - {"H'ey...", 10307, ENTRY_LEFT_HEAD}, - {"We kill his friend!", 10301, ENTRY_LEFT_HEAD}, -}; - -static Yell Killing[]= -{ - {"This one die easy!", 10310, ENTRY_LEFT_HEAD}, - {"I'm tired. You kill next one!", 10320, ENTRY_RIGHT_HEAD}, -}; -static Yell KillingDelay[]= -{ - {"That's because I do all the hard work!", 10321, ENTRY_RIGHT_HEAD}, - {"SD2 script error, should not see this.", 0, ENTRY_LEFT_HEAD}, -}; - -#define EMOTE_ENRAGE "enrages" - -#define YELL_DIE_L "This all...your fault!" -#define SOUND_DIE_L 10311 -#define YELL_DIE_R "I...hate...you..." -#define SOUND_DIE_R 10322 - -#define SPELL_BLAST_WAVE 30600 -#define SPELL_FEAR 30584 -#define SPELL_THUNDERCLAP 30633 - -#define SPELL_BURNING_MAUL 30598 -#define H_SPELL_BURNING_MAUL 36056 - -struct MANGOS_DLL_DECL mob_omrogg_headsAI : public ScriptedAI -{ - mob_omrogg_headsAI(Creature *c) : ScriptedAI(c) { Reset(); } - - bool DeathYell; - uint32 Death_Timer; - - void Reset() {} - void Aggro(Unit* who) { } - - void DoDeathYell() - { - Death_Timer = 4000; - DeathYell = true; - } - - void UpdateAI(const uint32 diff) - { - if( !DeathYell ) - return; - - if( Death_Timer < diff ) - { - DoYell(YELL_DIE_R,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature, SOUND_DIE_R); - DeathYell = false; - }else Death_Timer -= diff; - } -}; - -struct MANGOS_DLL_DECL boss_warbringer_omroggAI : public ScriptedAI -{ - boss_warbringer_omroggAI(Creature *c) : ScriptedAI(c) - { - pInstance = ((ScriptedInstance*)c->GetInstanceData()); - HeroicMode = m_creature->GetMap()->IsHeroic(); - Reset(); - } - - ScriptedInstance* pInstance; - - uint64 LeftHead; - uint64 RightHead; - int iaggro; - int ithreat; - int ikilling; - - bool HeroicMode; - bool AggroYell; - bool ThreatYell; - bool ThreatYell2; - bool KillingYell; - - uint32 Delay_Timer; - uint32 BlastWave_Timer; - uint32 BlastCount; - uint32 Fear_Timer; - uint32 BurningMaul_Timer; - uint32 ThunderClap_Timer; - uint32 ResetThreat_Timer; - - void Reset() - { - m_creature->ApplySpellImmune(0, IMMUNITY_STATE, SPELL_AURA_MOD_TAUNT, true); - m_creature->ApplySpellImmune(0, IMMUNITY_EFFECT,SPELL_EFFECT_ATTACK_ME, true); - - LeftHead = 0; - RightHead = 0; - - AggroYell = false; - ThreatYell = false; - ThreatYell2 = false; - KillingYell = false; - - Delay_Timer = 4000; - BlastWave_Timer = 0; - BlastCount = 0; - Fear_Timer = 8000; - BurningMaul_Timer = 25000; - ThunderClap_Timer = 15000; - ResetThreat_Timer = 30000; - - if( pInstance ) - pInstance->SetData(TYPE_OMROGG, NOT_STARTED); //End boss can use this later. O'mrogg must be defeated(DONE) or he will come to aid. - } - - void DoYellForThreat() - { - if( LeftHead && RightHead ) - { - Unit *Left = Unit::GetUnit(*m_creature,LeftHead); - Unit *Right = Unit::GetUnit(*m_creature,RightHead); - - if( !Left && !Right ) - return; - - ithreat = rand()%4; - - Unit *source = (Left->GetEntry() == Threat[ithreat].creature ? Left : Right); - - source->MonsterYell(Threat[ithreat].text, LANG_UNIVERSAL, 0); - DoPlaySoundToSet(source, Threat[ithreat].sound); - - Delay_Timer = 3500; - ThreatYell = true; - } - } - - void Aggro(Unit *who) - { - DoSpawnCreature(ENTRY_LEFT_HEAD,0,0,0,0,TEMPSUMMON_TIMED_DESPAWN,1800000); - DoSpawnCreature(ENTRY_RIGHT_HEAD,0,0,0,0,TEMPSUMMON_TIMED_DESPAWN,1800000); - - if( Unit *Left = Unit::GetUnit(*m_creature,LeftHead) ) - { - iaggro = rand()%3; - - Left->MonsterYell(GoCombat[iaggro].text, LANG_UNIVERSAL, 0); - DoPlaySoundToSet(Left, GoCombat[iaggro].sound); - - Delay_Timer = 3500; - AggroYell = true; - } - if( pInstance ) - pInstance->SetData(TYPE_OMROGG, IN_PROGRESS); - } - - void JustSummoned(Creature *summoned) - { - if( summoned->GetEntry() == ENTRY_LEFT_HEAD ) - LeftHead = summoned->GetGUID(); - - if( summoned->GetEntry() == ENTRY_RIGHT_HEAD ) - RightHead = summoned->GetGUID(); - - //summoned->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); - //summoned->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - summoned->SetVisibility(VISIBILITY_OFF); - } - - void KilledUnit(Unit* victim) - { - if( LeftHead && RightHead ) - { - Unit *Left = Unit::GetUnit(*m_creature,LeftHead); - Unit *Right = Unit::GetUnit(*m_creature,RightHead); - - if( !Left && !Right ) - return; - - ikilling = rand()%2; - - Unit *source = (Left->GetEntry() == Killing[ikilling].creature ? Left : Right); - - switch(ikilling) - { - case 0: - source->MonsterYell(Killing[ikilling].text, LANG_UNIVERSAL, 0); - DoPlaySoundToSet(source, Killing[ikilling].sound); - Delay_Timer = 3500; - KillingYell = true; - break; - case 1: - source->MonsterYell(Killing[ikilling].text, LANG_UNIVERSAL, 0); - DoPlaySoundToSet(source, Killing[ikilling].sound); - KillingYell = false; - break; - } - } - } - - void JustDied(Unit* Killer) - { - if( LeftHead && RightHead ) - { - Unit *Left = Unit::GetUnit(*m_creature,LeftHead); - Unit *Right = Unit::GetUnit(*m_creature,RightHead); - - if( !Left && !Right ) - return; - - Left->MonsterYell(YELL_DIE_L, LANG_UNIVERSAL, 0); - DoPlaySoundToSet(Left,SOUND_DIE_L); - - ((mob_omrogg_headsAI*)((Creature*)Right)->AI())->DoDeathYell(); - } - if( pInstance ) - pInstance->SetData(TYPE_OMROGG, DONE); - } - - void UpdateAI(const uint32 diff) - { - if( Delay_Timer < diff ) - { - Delay_Timer = 3500; - - if( !LeftHead && !RightHead ) - return; - - Unit *Left = Unit::GetUnit(*m_creature,LeftHead); - Unit *Right = Unit::GetUnit(*m_creature,RightHead); - - if( !Left && !Right ) - return; - - if( AggroYell ) - { - Right->MonsterYell(GoCombatDelay[iaggro].text, LANG_UNIVERSAL, 0); - DoPlaySoundToSet(Right, GoCombatDelay[iaggro].sound); - AggroYell = false; - } - - if( ThreatYell2 ) - { - Unit *source = (Left->GetEntry() == ThreatDelay2[ithreat].creature ? Left : Right); - - source->MonsterYell(ThreatDelay2[ithreat].text, LANG_UNIVERSAL, 0); - DoPlaySoundToSet(source, ThreatDelay2[ithreat].sound); - ThreatYell2 = false; - } - - if( ThreatYell ) - { - Unit *source = (Left->GetEntry() == ThreatDelay1[ithreat].creature ? Left : Right); - - source->MonsterYell(ThreatDelay1[ithreat].text, LANG_UNIVERSAL, 0); - DoPlaySoundToSet(source, ThreatDelay1[ithreat].sound); - ThreatYell = false; - ThreatYell2 = true; - } - - if( KillingYell ) - { - Unit *source = (Left->GetEntry() == KillingDelay[ikilling].creature ? Left : Right); - - source->MonsterYell(KillingDelay[ikilling].text, LANG_UNIVERSAL, 0); - DoPlaySoundToSet(source, KillingDelay[ikilling].sound); - KillingYell = false; - } - }else Delay_Timer -= diff; - - if( !m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - if( BlastCount && BlastWave_Timer <= diff ) - { - DoCast(m_creature,SPELL_BLAST_WAVE); - BlastWave_Timer = 5000; - ++BlastCount; - if( BlastCount == 3 ) - BlastCount = 0; - }else BlastWave_Timer -= diff; - - if( BurningMaul_Timer < diff ) - { - DoTextEmote(EMOTE_ENRAGE,NULL); - DoCast(m_creature,HeroicMode ? H_SPELL_BURNING_MAUL : SPELL_BURNING_MAUL); - BurningMaul_Timer = 40000; - BlastWave_Timer = 16000; - BlastCount = 1; - }else BurningMaul_Timer -= diff; - - if( ResetThreat_Timer < diff ) - { - if( Unit *target = SelectUnit(SELECT_TARGET_RANDOM,0) ) - { - DoYellForThreat(); - DoResetThreat(); - m_creature->AddThreat(target, 0.0f); - } - ResetThreat_Timer = 35000+rand()%10000; - }else ResetThreat_Timer -= diff; - - if( Fear_Timer < diff ) - { - DoCast(m_creature,SPELL_FEAR); - Fear_Timer = 15000+rand()%25000; - }else Fear_Timer -= diff; - - if( ThunderClap_Timer < diff ) - { - DoCast(m_creature,SPELL_THUNDERCLAP); - ThunderClap_Timer = 25000+rand()%15000; - }else ThunderClap_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; - -CreatureAI* GetAI_boss_warbringer_omrogg(Creature *_Creature) -{ - return new boss_warbringer_omroggAI (_Creature); -} - -CreatureAI* GetAI_mob_omrogg_heads(Creature *_Creature) -{ - return new mob_omrogg_headsAI (_Creature); -} - -void AddSC_boss_warbringer_omrogg() -{ - Script *newscript; - - newscript = new Script; - newscript->Name="boss_warbringer_omrogg"; - newscript->GetAI = GetAI_boss_warbringer_omrogg; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="mob_omrogg_heads"; - newscript->GetAI = GetAI_mob_omrogg_heads; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Warbringer_Omrogg +SD%Complete: 85 +SDComment: Heroic enabled. Spell timing may need additional tweaks +SDCategory: Hellfire Citadel, Shattered Halls +EndScriptData */ + +/* ContentData +mob_omrogg_heads +boss_warbringer_omrogg +EndContentData */ + +#include "precompiled.h" +#include "def_shattered_halls.h" + +#define ENTRY_LEFT_HEAD 19523 +#define ENTRY_RIGHT_HEAD 19524 + +struct Yell +{ + const char* text; + uint32 sound; + uint32 creature; +}; + +static Yell GoCombat[]= +{ + {"Smash!", 10306, ENTRY_LEFT_HEAD}, + {"If you nice me let you live.", 10308, ENTRY_LEFT_HEAD}, + {"Me hungry!", 10309, ENTRY_LEFT_HEAD}, +}; +static Yell GoCombatDelay[]= +{ + {"Why don't you let me do the talking?", 10317, ENTRY_RIGHT_HEAD}, + {"No, we will NOT let you live!", 10318, ENTRY_RIGHT_HEAD}, + {"You always hungry. That why we so fat!", 10319, ENTRY_RIGHT_HEAD}, +}; + +static Yell Threat[]= +{ + {"You stay here. Me go kill someone else!", 10303, ENTRY_LEFT_HEAD}, + {"What are you doing!", 10315, ENTRY_RIGHT_HEAD}, + {"Me kill someone else...", 10302, ENTRY_LEFT_HEAD}, + {"Me not like this one...",10300, ENTRY_LEFT_HEAD}, +}; +static Yell ThreatDelay1[]= +{ + {"That's not funny!", 10314, ENTRY_RIGHT_HEAD}, + {"Me get bored...", 10305, ENTRY_LEFT_HEAD}, + {"I'm not done yet, idiot!", 10313, ENTRY_RIGHT_HEAD}, + {"Hey you numbskull!", 10312, ENTRY_RIGHT_HEAD}, +}; +static Yell ThreatDelay2[]= +{ + {"Ha ha ha.", 10304, ENTRY_LEFT_HEAD}, + {"Whhy! He almost dead!", 10316, ENTRY_RIGHT_HEAD}, + {"H'ey...", 10307, ENTRY_LEFT_HEAD}, + {"We kill his friend!", 10301, ENTRY_LEFT_HEAD}, +}; + +static Yell Killing[]= +{ + {"This one die easy!", 10310, ENTRY_LEFT_HEAD}, + {"I'm tired. You kill next one!", 10320, ENTRY_RIGHT_HEAD}, +}; +static Yell KillingDelay[]= +{ + {"That's because I do all the hard work!", 10321, ENTRY_RIGHT_HEAD}, + {"SD2 script error, should not see this.", 0, ENTRY_LEFT_HEAD}, +}; + +#define EMOTE_ENRAGE "enrages" + +#define YELL_DIE_L "This all...your fault!" +#define SOUND_DIE_L 10311 +#define YELL_DIE_R "I...hate...you..." +#define SOUND_DIE_R 10322 + +#define SPELL_BLAST_WAVE 30600 +#define SPELL_FEAR 30584 +#define SPELL_THUNDERCLAP 30633 + +#define SPELL_BURNING_MAUL 30598 +#define H_SPELL_BURNING_MAUL 36056 + +struct MANGOS_DLL_DECL mob_omrogg_headsAI : public ScriptedAI +{ + mob_omrogg_headsAI(Creature *c) : ScriptedAI(c) { Reset(); } + + bool DeathYell; + uint32 Death_Timer; + + void Reset() {} + void Aggro(Unit* who) { } + + void DoDeathYell() + { + Death_Timer = 4000; + DeathYell = true; + } + + void UpdateAI(const uint32 diff) + { + if( !DeathYell ) + return; + + if( Death_Timer < diff ) + { + DoYell(YELL_DIE_R,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature, SOUND_DIE_R); + DeathYell = false; + }else Death_Timer -= diff; + } +}; + +struct MANGOS_DLL_DECL boss_warbringer_omroggAI : public ScriptedAI +{ + boss_warbringer_omroggAI(Creature *c) : ScriptedAI(c) + { + pInstance = ((ScriptedInstance*)c->GetInstanceData()); + HeroicMode = m_creature->GetMap()->IsHeroic(); + Reset(); + } + + ScriptedInstance* pInstance; + + uint64 LeftHead; + uint64 RightHead; + int iaggro; + int ithreat; + int ikilling; + + bool HeroicMode; + bool AggroYell; + bool ThreatYell; + bool ThreatYell2; + bool KillingYell; + + uint32 Delay_Timer; + uint32 BlastWave_Timer; + uint32 BlastCount; + uint32 Fear_Timer; + uint32 BurningMaul_Timer; + uint32 ThunderClap_Timer; + uint32 ResetThreat_Timer; + + void Reset() + { + m_creature->ApplySpellImmune(0, IMMUNITY_STATE, SPELL_AURA_MOD_TAUNT, true); + m_creature->ApplySpellImmune(0, IMMUNITY_EFFECT,SPELL_EFFECT_ATTACK_ME, true); + + LeftHead = 0; + RightHead = 0; + + AggroYell = false; + ThreatYell = false; + ThreatYell2 = false; + KillingYell = false; + + Delay_Timer = 4000; + BlastWave_Timer = 0; + BlastCount = 0; + Fear_Timer = 8000; + BurningMaul_Timer = 25000; + ThunderClap_Timer = 15000; + ResetThreat_Timer = 30000; + + if( pInstance ) + pInstance->SetData(TYPE_OMROGG, NOT_STARTED); //End boss can use this later. O'mrogg must be defeated(DONE) or he will come to aid. + } + + void DoYellForThreat() + { + if( LeftHead && RightHead ) + { + Unit *Left = Unit::GetUnit(*m_creature,LeftHead); + Unit *Right = Unit::GetUnit(*m_creature,RightHead); + + if( !Left && !Right ) + return; + + ithreat = rand()%4; + + Unit *source = (Left->GetEntry() == Threat[ithreat].creature ? Left : Right); + + source->MonsterYell(Threat[ithreat].text, LANG_UNIVERSAL, 0); + DoPlaySoundToSet(source, Threat[ithreat].sound); + + Delay_Timer = 3500; + ThreatYell = true; + } + } + + void Aggro(Unit *who) + { + DoSpawnCreature(ENTRY_LEFT_HEAD,0,0,0,0,TEMPSUMMON_TIMED_DESPAWN,1800000); + DoSpawnCreature(ENTRY_RIGHT_HEAD,0,0,0,0,TEMPSUMMON_TIMED_DESPAWN,1800000); + + if( Unit *Left = Unit::GetUnit(*m_creature,LeftHead) ) + { + iaggro = rand()%3; + + Left->MonsterYell(GoCombat[iaggro].text, LANG_UNIVERSAL, 0); + DoPlaySoundToSet(Left, GoCombat[iaggro].sound); + + Delay_Timer = 3500; + AggroYell = true; + } + if( pInstance ) + pInstance->SetData(TYPE_OMROGG, IN_PROGRESS); + } + + void JustSummoned(Creature *summoned) + { + if( summoned->GetEntry() == ENTRY_LEFT_HEAD ) + LeftHead = summoned->GetGUID(); + + if( summoned->GetEntry() == ENTRY_RIGHT_HEAD ) + RightHead = summoned->GetGUID(); + + //summoned->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + //summoned->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + summoned->SetVisibility(VISIBILITY_OFF); + } + + void KilledUnit(Unit* victim) + { + if( LeftHead && RightHead ) + { + Unit *Left = Unit::GetUnit(*m_creature,LeftHead); + Unit *Right = Unit::GetUnit(*m_creature,RightHead); + + if( !Left && !Right ) + return; + + ikilling = rand()%2; + + Unit *source = (Left->GetEntry() == Killing[ikilling].creature ? Left : Right); + + switch(ikilling) + { + case 0: + source->MonsterYell(Killing[ikilling].text, LANG_UNIVERSAL, 0); + DoPlaySoundToSet(source, Killing[ikilling].sound); + Delay_Timer = 3500; + KillingYell = true; + break; + case 1: + source->MonsterYell(Killing[ikilling].text, LANG_UNIVERSAL, 0); + DoPlaySoundToSet(source, Killing[ikilling].sound); + KillingYell = false; + break; + } + } + } + + void JustDied(Unit* Killer) + { + if( LeftHead && RightHead ) + { + Unit *Left = Unit::GetUnit(*m_creature,LeftHead); + Unit *Right = Unit::GetUnit(*m_creature,RightHead); + + if( !Left && !Right ) + return; + + Left->MonsterYell(YELL_DIE_L, LANG_UNIVERSAL, 0); + DoPlaySoundToSet(Left,SOUND_DIE_L); + + ((mob_omrogg_headsAI*)((Creature*)Right)->AI())->DoDeathYell(); + } + if( pInstance ) + pInstance->SetData(TYPE_OMROGG, DONE); + } + + void UpdateAI(const uint32 diff) + { + if( Delay_Timer < diff ) + { + Delay_Timer = 3500; + + if( !LeftHead && !RightHead ) + return; + + Unit *Left = Unit::GetUnit(*m_creature,LeftHead); + Unit *Right = Unit::GetUnit(*m_creature,RightHead); + + if( !Left && !Right ) + return; + + if( AggroYell ) + { + Right->MonsterYell(GoCombatDelay[iaggro].text, LANG_UNIVERSAL, 0); + DoPlaySoundToSet(Right, GoCombatDelay[iaggro].sound); + AggroYell = false; + } + + if( ThreatYell2 ) + { + Unit *source = (Left->GetEntry() == ThreatDelay2[ithreat].creature ? Left : Right); + + source->MonsterYell(ThreatDelay2[ithreat].text, LANG_UNIVERSAL, 0); + DoPlaySoundToSet(source, ThreatDelay2[ithreat].sound); + ThreatYell2 = false; + } + + if( ThreatYell ) + { + Unit *source = (Left->GetEntry() == ThreatDelay1[ithreat].creature ? Left : Right); + + source->MonsterYell(ThreatDelay1[ithreat].text, LANG_UNIVERSAL, 0); + DoPlaySoundToSet(source, ThreatDelay1[ithreat].sound); + ThreatYell = false; + ThreatYell2 = true; + } + + if( KillingYell ) + { + Unit *source = (Left->GetEntry() == KillingDelay[ikilling].creature ? Left : Right); + + source->MonsterYell(KillingDelay[ikilling].text, LANG_UNIVERSAL, 0); + DoPlaySoundToSet(source, KillingDelay[ikilling].sound); + KillingYell = false; + } + }else Delay_Timer -= diff; + + if( !m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + if( BlastCount && BlastWave_Timer <= diff ) + { + DoCast(m_creature,SPELL_BLAST_WAVE); + BlastWave_Timer = 5000; + ++BlastCount; + if( BlastCount == 3 ) + BlastCount = 0; + }else BlastWave_Timer -= diff; + + if( BurningMaul_Timer < diff ) + { + DoTextEmote(EMOTE_ENRAGE,NULL); + DoCast(m_creature,HeroicMode ? H_SPELL_BURNING_MAUL : SPELL_BURNING_MAUL); + BurningMaul_Timer = 40000; + BlastWave_Timer = 16000; + BlastCount = 1; + }else BurningMaul_Timer -= diff; + + if( ResetThreat_Timer < diff ) + { + if( Unit *target = SelectUnit(SELECT_TARGET_RANDOM,0) ) + { + DoYellForThreat(); + DoResetThreat(); + m_creature->AddThreat(target, 0.0f); + } + ResetThreat_Timer = 35000+rand()%10000; + }else ResetThreat_Timer -= diff; + + if( Fear_Timer < diff ) + { + DoCast(m_creature,SPELL_FEAR); + Fear_Timer = 15000+rand()%25000; + }else Fear_Timer -= diff; + + if( ThunderClap_Timer < diff ) + { + DoCast(m_creature,SPELL_THUNDERCLAP); + ThunderClap_Timer = 25000+rand()%15000; + }else ThunderClap_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; + +CreatureAI* GetAI_boss_warbringer_omrogg(Creature *_Creature) +{ + return new boss_warbringer_omroggAI (_Creature); +} + +CreatureAI* GetAI_mob_omrogg_heads(Creature *_Creature) +{ + return new mob_omrogg_headsAI (_Creature); +} + +void AddSC_boss_warbringer_omrogg() +{ + Script *newscript; + + newscript = new Script; + newscript->Name="boss_warbringer_omrogg"; + newscript->GetAI = GetAI_boss_warbringer_omrogg; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="mob_omrogg_heads"; + newscript->GetAI = GetAI_mob_omrogg_heads; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/hellfire_citadel/shattered_halls/def_shattered_halls.h b/src/bindings/scripts/scripts/zone/hellfire_citadel/shattered_halls/def_shattered_halls.h index 602564d32f0..e7eef878481 100644 --- a/src/bindings/scripts/scripts/zone/hellfire_citadel/shattered_halls/def_shattered_halls.h +++ b/src/bindings/scripts/scripts/zone/hellfire_citadel/shattered_halls/def_shattered_halls.h @@ -1,13 +1,13 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software licensed under GPL version 2 - * Please see the included DOCS/LICENSE.TXT for more information */ - -#ifndef DEF_SHATTERED_H -#define DEF_SHATTERED_H - -#define TYPE_NETHEKURSE 1 -#define DATA_NETHEKURSE 2 -#define DATA_NETHEKURSE_DOOR 3 - -#define TYPE_OMROGG 4 -#endif +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software licensed under GPL version 2 + * Please see the included DOCS/LICENSE.TXT for more information */ + +#ifndef DEF_SHATTERED_H +#define DEF_SHATTERED_H + +#define TYPE_NETHEKURSE 1 +#define DATA_NETHEKURSE 2 +#define DATA_NETHEKURSE_DOOR 3 + +#define TYPE_OMROGG 4 +#endif diff --git a/src/bindings/scripts/scripts/zone/hellfire_citadel/shattered_halls/instance_shattered_halls.cpp b/src/bindings/scripts/scripts/zone/hellfire_citadel/shattered_halls/instance_shattered_halls.cpp index 8d068a4bb40..8015101d41f 100644 --- a/src/bindings/scripts/scripts/zone/hellfire_citadel/shattered_halls/instance_shattered_halls.cpp +++ b/src/bindings/scripts/scripts/zone/hellfire_citadel/shattered_halls/instance_shattered_halls.cpp @@ -1,114 +1,114 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Instance_Shattered_Halls -SD%Complete: 50 -SDComment: currently missing info about door. instance not complete -SDCategory: Hellfire Citadel, Shattered Halls -EndScriptData */ - -#include "precompiled.h" -#include "def_shattered_halls.h" - -#define ENCOUNTERS 2 - -#define DOOR_NETHEKURSE 1 - -struct MANGOS_DLL_DECL instance_shattered_halls : public ScriptedInstance -{ - instance_shattered_halls(Map *Map) : ScriptedInstance(Map) {Initialize();}; - - uint32 Encounter[ENCOUNTERS]; - uint64 nethekurseGUID; - uint64 nethekurseDoorGUID; - - void Initialize() - { - nethekurseGUID = 0; - nethekurseDoorGUID = 0; - - for(uint8 i = 0; i < ENCOUNTERS; i++) - Encounter[i] = NOT_STARTED; - } - - void OnObjectCreate(GameObject *go) - { - switch( go->GetEntry() ) - { - case DOOR_NETHEKURSE: nethekurseDoorGUID = go->GetGUID(); break; - } - } - - void OnCreatureCreate(Creature *creature, uint32 creature_entry) - { - switch( creature_entry ) - { - case 16807: nethekurseGUID = creature->GetGUID(); break; - } - } - - void SetData(uint32 type, uint32 data) - { - switch( type ) - { - case TYPE_NETHEKURSE: - Encounter[0] = data; - break; - case TYPE_OMROGG: - Encounter[1] = data; - break; - } - } - - uint32 GetData(uint32 type) - { - switch( type ) - { - case TYPE_NETHEKURSE: - return Encounter[0]; - case TYPE_OMROGG: - return Encounter[1]; - } - return 0; - } - - uint64 GetData64(uint32 data) - { - switch(data) - { - case DATA_NETHEKURSE: - return nethekurseGUID; - case DATA_NETHEKURSE_DOOR: - return nethekurseDoorGUID; - } - return 0; - } -}; - -InstanceData* GetInstanceData_instance_shattered_halls(Map* map) -{ - return new instance_shattered_halls(map); -} - -void AddSC_instance_shattered_halls() -{ - Script *newscript; - newscript = new Script; - newscript->Name = "instance_shattered_halls"; - newscript->GetInstanceData = GetInstanceData_instance_shattered_halls; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Instance_Shattered_Halls +SD%Complete: 50 +SDComment: currently missing info about door. instance not complete +SDCategory: Hellfire Citadel, Shattered Halls +EndScriptData */ + +#include "precompiled.h" +#include "def_shattered_halls.h" + +#define ENCOUNTERS 2 + +#define DOOR_NETHEKURSE 1 + +struct MANGOS_DLL_DECL instance_shattered_halls : public ScriptedInstance +{ + instance_shattered_halls(Map *Map) : ScriptedInstance(Map) {Initialize();}; + + uint32 Encounter[ENCOUNTERS]; + uint64 nethekurseGUID; + uint64 nethekurseDoorGUID; + + void Initialize() + { + nethekurseGUID = 0; + nethekurseDoorGUID = 0; + + for(uint8 i = 0; i < ENCOUNTERS; i++) + Encounter[i] = NOT_STARTED; + } + + void OnObjectCreate(GameObject *go) + { + switch( go->GetEntry() ) + { + case DOOR_NETHEKURSE: nethekurseDoorGUID = go->GetGUID(); break; + } + } + + void OnCreatureCreate(Creature *creature, uint32 creature_entry) + { + switch( creature_entry ) + { + case 16807: nethekurseGUID = creature->GetGUID(); break; + } + } + + void SetData(uint32 type, uint32 data) + { + switch( type ) + { + case TYPE_NETHEKURSE: + Encounter[0] = data; + break; + case TYPE_OMROGG: + Encounter[1] = data; + break; + } + } + + uint32 GetData(uint32 type) + { + switch( type ) + { + case TYPE_NETHEKURSE: + return Encounter[0]; + case TYPE_OMROGG: + return Encounter[1]; + } + return 0; + } + + uint64 GetData64(uint32 data) + { + switch(data) + { + case DATA_NETHEKURSE: + return nethekurseGUID; + case DATA_NETHEKURSE_DOOR: + return nethekurseDoorGUID; + } + return 0; + } +}; + +InstanceData* GetInstanceData_instance_shattered_halls(Map* map) +{ + return new instance_shattered_halls(map); +} + +void AddSC_instance_shattered_halls() +{ + Script *newscript; + newscript = new Script; + newscript->Name = "instance_shattered_halls"; + newscript->GetInstanceData = GetInstanceData_instance_shattered_halls; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/hellfire_peninsula/boss_doomlord_kazzak.cpp b/src/bindings/scripts/scripts/zone/hellfire_peninsula/boss_doomlord_kazzak.cpp index ccb36f9f350..e70f233a12e 100644 --- a/src/bindings/scripts/scripts/zone/hellfire_peninsula/boss_doomlord_kazzak.cpp +++ b/src/bindings/scripts/scripts/zone/hellfire_peninsula/boss_doomlord_kazzak.cpp @@ -1,141 +1,141 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Doomlord_Kazzak -SD%Complete: 70 -SDComment: Using incorrect spell for Mark of Kazzak -SDCategory: Hellfire Peninsula -EndScriptData */ - -#include "precompiled.h" - -#define SPELL_SHADOWVOLLEY 32963 -#define SPELL_CLEAVE 31779 -#define SPELL_THUNDERCLAP 36706 -#define SPELL_VOIDBOLT 39329 -#define SPELL_MARKOFKAZZAK 32960 -#define SPELL_ENRAGE 32964 -#define SPELL_CAPTURESOUL 32966 -#define SPELL_TWISTEDREFLECTION 21063 - -struct MANGOS_DLL_DECL boss_doomlordkazzakAI : public ScriptedAI -{ - boss_doomlordkazzakAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 ShadowVolley_Timer; - uint32 Cleave_Timer; - uint32 ThunderClap_Timer; - uint32 VoidBolt_Timer; - uint32 MarkOfKazzak_Timer; - uint32 Enrage_Timer; - uint32 Twisted_Reflection_Timer; - - void Reset() - { - ShadowVolley_Timer = 8000 + rand()%4000; - Cleave_Timer = 7000; - ThunderClap_Timer = 16000 + rand()%4000; - VoidBolt_Timer = 30000; - MarkOfKazzak_Timer = 25000; - Enrage_Timer = 60000; - Twisted_Reflection_Timer = 33000; // Timer may be incorrect - } - - void Aggro(Unit *who) {} - - void KilledUnit(Unit* victim) - { - // When Kazzak kills a player (not pets/totems), he regens some health - if(victim->GetTypeId() == TYPEID_PLAYER) - DoCast(m_creature,SPELL_CAPTURESOUL); - } - - void UpdateAI(const uint32 diff) - { - //Return since we have no target - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - //ShadowVolley_Timer - if (ShadowVolley_Timer < diff) - { - DoCast(m_creature->getVictim(), SPELL_SHADOWVOLLEY); - ShadowVolley_Timer = 4000 + rand()%2000; - }else ShadowVolley_Timer -= diff; - - //Cleave_Timer - if (Cleave_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_CLEAVE); - Cleave_Timer = 8000 + rand()%4000; - }else Cleave_Timer -= diff; - - //ThunderClap_Timer - if (ThunderClap_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_THUNDERCLAP); - ThunderClap_Timer = 10000 + rand()%4000; - }else ThunderClap_Timer -= diff; - - //VoidBolt_Timer - if (VoidBolt_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_VOIDBOLT); - VoidBolt_Timer = 15000 + rand()%3000; - }else VoidBolt_Timer -= diff; - - //MarkOfKazzak_Timer - if (MarkOfKazzak_Timer < diff) - { - Unit* victim = SelectUnit(SELECT_TARGET_RANDOM, 0); - if(victim->GetPower(POWER_MANA)) - { - DoCast(victim, SPELL_MARKOFKAZZAK); - MarkOfKazzak_Timer = 20000; - } - }else MarkOfKazzak_Timer -= diff; - - //Enrage_Timer - if (Enrage_Timer < diff) - { - DoCast(m_creature,SPELL_ENRAGE); - Enrage_Timer = 30000; - }else Enrage_Timer -= diff; - - if(Twisted_Reflection_Timer < diff) - { - DoCast(SelectUnit(SELECT_TARGET_RANDOM, 0), SPELL_TWISTEDREFLECTION); - Twisted_Reflection_Timer = 15000; - }else Twisted_Reflection_Timer -= diff; - - DoMeleeAttackIfReady(); - } - -}; -CreatureAI* GetAI_boss_doomlordkazzak(Creature *_Creature) -{ - return new boss_doomlordkazzakAI (_Creature); -} - -void AddSC_boss_doomlordkazzak() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_doomlord_kazzak"; - newscript->GetAI = GetAI_boss_doomlordkazzak; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Doomlord_Kazzak +SD%Complete: 70 +SDComment: Using incorrect spell for Mark of Kazzak +SDCategory: Hellfire Peninsula +EndScriptData */ + +#include "precompiled.h" + +#define SPELL_SHADOWVOLLEY 32963 +#define SPELL_CLEAVE 31779 +#define SPELL_THUNDERCLAP 36706 +#define SPELL_VOIDBOLT 39329 +#define SPELL_MARKOFKAZZAK 32960 +#define SPELL_ENRAGE 32964 +#define SPELL_CAPTURESOUL 32966 +#define SPELL_TWISTEDREFLECTION 21063 + +struct MANGOS_DLL_DECL boss_doomlordkazzakAI : public ScriptedAI +{ + boss_doomlordkazzakAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 ShadowVolley_Timer; + uint32 Cleave_Timer; + uint32 ThunderClap_Timer; + uint32 VoidBolt_Timer; + uint32 MarkOfKazzak_Timer; + uint32 Enrage_Timer; + uint32 Twisted_Reflection_Timer; + + void Reset() + { + ShadowVolley_Timer = 8000 + rand()%4000; + Cleave_Timer = 7000; + ThunderClap_Timer = 16000 + rand()%4000; + VoidBolt_Timer = 30000; + MarkOfKazzak_Timer = 25000; + Enrage_Timer = 60000; + Twisted_Reflection_Timer = 33000; // Timer may be incorrect + } + + void Aggro(Unit *who) {} + + void KilledUnit(Unit* victim) + { + // When Kazzak kills a player (not pets/totems), he regens some health + if(victim->GetTypeId() == TYPEID_PLAYER) + DoCast(m_creature,SPELL_CAPTURESOUL); + } + + void UpdateAI(const uint32 diff) + { + //Return since we have no target + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + //ShadowVolley_Timer + if (ShadowVolley_Timer < diff) + { + DoCast(m_creature->getVictim(), SPELL_SHADOWVOLLEY); + ShadowVolley_Timer = 4000 + rand()%2000; + }else ShadowVolley_Timer -= diff; + + //Cleave_Timer + if (Cleave_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_CLEAVE); + Cleave_Timer = 8000 + rand()%4000; + }else Cleave_Timer -= diff; + + //ThunderClap_Timer + if (ThunderClap_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_THUNDERCLAP); + ThunderClap_Timer = 10000 + rand()%4000; + }else ThunderClap_Timer -= diff; + + //VoidBolt_Timer + if (VoidBolt_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_VOIDBOLT); + VoidBolt_Timer = 15000 + rand()%3000; + }else VoidBolt_Timer -= diff; + + //MarkOfKazzak_Timer + if (MarkOfKazzak_Timer < diff) + { + Unit* victim = SelectUnit(SELECT_TARGET_RANDOM, 0); + if(victim->GetPower(POWER_MANA)) + { + DoCast(victim, SPELL_MARKOFKAZZAK); + MarkOfKazzak_Timer = 20000; + } + }else MarkOfKazzak_Timer -= diff; + + //Enrage_Timer + if (Enrage_Timer < diff) + { + DoCast(m_creature,SPELL_ENRAGE); + Enrage_Timer = 30000; + }else Enrage_Timer -= diff; + + if(Twisted_Reflection_Timer < diff) + { + DoCast(SelectUnit(SELECT_TARGET_RANDOM, 0), SPELL_TWISTEDREFLECTION); + Twisted_Reflection_Timer = 15000; + }else Twisted_Reflection_Timer -= diff; + + DoMeleeAttackIfReady(); + } + +}; +CreatureAI* GetAI_boss_doomlordkazzak(Creature *_Creature) +{ + return new boss_doomlordkazzakAI (_Creature); +} + +void AddSC_boss_doomlordkazzak() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_doomlord_kazzak"; + newscript->GetAI = GetAI_boss_doomlordkazzak; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/hellfire_peninsula/hellfire_peninsula.cpp b/src/bindings/scripts/scripts/zone/hellfire_peninsula/hellfire_peninsula.cpp index ceedce42ea2..4123884d462 100644 --- a/src/bindings/scripts/scripts/zone/hellfire_peninsula/hellfire_peninsula.cpp +++ b/src/bindings/scripts/scripts/zone/hellfire_peninsula/hellfire_peninsula.cpp @@ -1,187 +1,187 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Hellfire_Peninsula -SD%Complete: 100 -SDComment: Quest support: 10129, 10146, 10162, 10163, 10340, 10346, 10347, 10382 (Special flight paths) -SDCategory: Hellfire Peninsula -EndScriptData */ - -/* ContentData -npc_wing_commander_dabiree -npc_gryphoneer_windbellow -npc_wing_commander_brack -EndContentData */ - -#include "precompiled.h" - -/*###### -## npc_wing_commander_dabiree -######*/ - -#define GOSSIP_ITEM1_DAB "Fly me to Murketh and Shaadraz Gateways" -#define GOSSIP_ITEM2_DAB "Fly me to Shatter Point" - -bool GossipHello_npc_wing_commander_dabiree(Player *player, Creature *_Creature) -{ - if (_Creature->isQuestGiver()) - player->PrepareQuestMenu( _Creature->GetGUID() ); - - //Mission: The Murketh and Shaadraz Gateways - if (player->GetQuestStatus(10146) == QUEST_STATUS_INCOMPLETE) - player->ADD_GOSSIP_ITEM(2, GOSSIP_ITEM1_DAB, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); - - //Shatter Point - if (!player->GetQuestRewardStatus(10340)) - player->ADD_GOSSIP_ITEM(2, GOSSIP_ITEM2_DAB, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2); - - player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); - - return true; -} - -bool GossipSelect_npc_wing_commander_dabiree(Player *player, Creature *_Creature, uint32 sender, uint32 action ) -{ - if (action == GOSSIP_ACTION_INFO_DEF + 1) - { - player->CLOSE_GOSSIP_MENU(); - player->CastSpell(player,33768,true); //TaxiPath 585 (Gateways Murket and Shaadraz) - } - if (action == GOSSIP_ACTION_INFO_DEF + 2) - { - player->CLOSE_GOSSIP_MENU(); - player->CastSpell(player,35069,true); //TaxiPath 612 (Taxi - Hellfire Peninsula - Expedition Point to Shatter Point) - } - return true; -} - -/*###### -## npc_gryphoneer_windbellow -######*/ - -#define GOSSIP_ITEM1_WIN "Fly me to The Abyssal Shelf" -#define GOSSIP_ITEM2_WIN "Fly me to Honor Point" - -bool GossipHello_npc_gryphoneer_windbellow(Player *player, Creature *_Creature) -{ - if (_Creature->isQuestGiver()) - player->PrepareQuestMenu( _Creature->GetGUID() ); - - //Mission: The Abyssal Shelf || Return to the Abyssal Shelf - if (player->GetQuestStatus(10163) == QUEST_STATUS_INCOMPLETE || player->GetQuestStatus(10346) == QUEST_STATUS_INCOMPLETE) - player->ADD_GOSSIP_ITEM(2, GOSSIP_ITEM1_WIN, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); - - //Go to the Front - if (player->GetQuestStatus(10382) != QUEST_STATUS_NONE && !player->GetQuestRewardStatus(10382)) - player->ADD_GOSSIP_ITEM(2, GOSSIP_ITEM2_WIN, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2); - - player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); - - return true; -} - -bool GossipSelect_npc_gryphoneer_windbellow(Player *player, Creature *_Creature, uint32 sender, uint32 action ) -{ - if (action == GOSSIP_ACTION_INFO_DEF + 1) - { - player->CLOSE_GOSSIP_MENU(); - player->CastSpell(player,33899,true); //TaxiPath 589 (Aerial Assault Flight (Alliance)) - } - if (action == GOSSIP_ACTION_INFO_DEF + 2) - { - player->CLOSE_GOSSIP_MENU(); - player->CastSpell(player,35065,true); //TaxiPath 607 (Taxi - Hellfire Peninsula - Shatter Point to Beach Head) - } - return true; -} - -/*###### -## npc_wing_commander_brack -######*/ - -#define GOSSIP_ITEM1_BRA "Fly me to Murketh and Shaadraz Gateways" -#define GOSSIP_ITEM2_BRA "Fly me to The Abyssal Shelf" -#define GOSSIP_ITEM3_BRA "Fly me to Spinebreaker Post" - -bool GossipHello_npc_wing_commander_brack(Player *player, Creature *_Creature) -{ - if (_Creature->isQuestGiver()) - player->PrepareQuestMenu( _Creature->GetGUID() ); - - //Mission: The Murketh and Shaadraz Gateways - if (player->GetQuestStatus(10129) == QUEST_STATUS_INCOMPLETE) - player->ADD_GOSSIP_ITEM(2, GOSSIP_ITEM1_BRA, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); - - //Mission: The Abyssal Shelf || Return to the Abyssal Shelf - if (player->GetQuestStatus(10162) == QUEST_STATUS_INCOMPLETE || player->GetQuestStatus(10347) == QUEST_STATUS_INCOMPLETE) - player->ADD_GOSSIP_ITEM(2, GOSSIP_ITEM2_BRA, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2); - - //Spinebreaker Post - if (player->GetQuestStatus(10242) == QUEST_STATUS_COMPLETE && !player->GetQuestRewardStatus(10242)) - player->ADD_GOSSIP_ITEM(2, GOSSIP_ITEM3_BRA, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 3); - - player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); - - return true; -} - -bool GossipSelect_npc_wing_commander_brack(Player *player, Creature *_Creature, uint32 sender, uint32 action ) -{ - if (action == GOSSIP_ACTION_INFO_DEF + 1) - { - player->CLOSE_GOSSIP_MENU(); - player->CastSpell(player,33659,true); //TaxiPath 584 (Gateways Murket and Shaadraz) - } - if (action == GOSSIP_ACTION_INFO_DEF + 2) - { - player->CLOSE_GOSSIP_MENU(); - player->CastSpell(player,33825,true); //TaxiPath 587 (Aerial Assault Flight (Horde)) - } - if (action == GOSSIP_ACTION_INFO_DEF + 3) - { - player->CLOSE_GOSSIP_MENU(); - player->CastSpell(player,34578,true); //TaxiPath 604 (Taxi - Reaver's Fall to Spinebreaker Ridge) - } - return true; -} - -/*###### -## -######*/ - -void AddSC_hellfire_peninsula() -{ - Script *newscript; - - newscript = new Script; - newscript->Name="npc_wing_commander_dabiree"; - newscript->pGossipHello = &GossipHello_npc_wing_commander_dabiree; - newscript->pGossipSelect = &GossipSelect_npc_wing_commander_dabiree; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="npc_gryphoneer_windbellow"; - newscript->pGossipHello = &GossipHello_npc_gryphoneer_windbellow; - newscript->pGossipSelect = &GossipSelect_npc_gryphoneer_windbellow; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="npc_wing_commander_brack"; - newscript->pGossipHello = &GossipHello_npc_wing_commander_brack; - newscript->pGossipSelect = &GossipSelect_npc_wing_commander_brack; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Hellfire_Peninsula +SD%Complete: 100 +SDComment: Quest support: 10129, 10146, 10162, 10163, 10340, 10346, 10347, 10382 (Special flight paths) +SDCategory: Hellfire Peninsula +EndScriptData */ + +/* ContentData +npc_wing_commander_dabiree +npc_gryphoneer_windbellow +npc_wing_commander_brack +EndContentData */ + +#include "precompiled.h" + +/*###### +## npc_wing_commander_dabiree +######*/ + +#define GOSSIP_ITEM1_DAB "Fly me to Murketh and Shaadraz Gateways" +#define GOSSIP_ITEM2_DAB "Fly me to Shatter Point" + +bool GossipHello_npc_wing_commander_dabiree(Player *player, Creature *_Creature) +{ + if (_Creature->isQuestGiver()) + player->PrepareQuestMenu( _Creature->GetGUID() ); + + //Mission: The Murketh and Shaadraz Gateways + if (player->GetQuestStatus(10146) == QUEST_STATUS_INCOMPLETE) + player->ADD_GOSSIP_ITEM(2, GOSSIP_ITEM1_DAB, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); + + //Shatter Point + if (!player->GetQuestRewardStatus(10340)) + player->ADD_GOSSIP_ITEM(2, GOSSIP_ITEM2_DAB, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2); + + player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); + + return true; +} + +bool GossipSelect_npc_wing_commander_dabiree(Player *player, Creature *_Creature, uint32 sender, uint32 action ) +{ + if (action == GOSSIP_ACTION_INFO_DEF + 1) + { + player->CLOSE_GOSSIP_MENU(); + player->CastSpell(player,33768,true); //TaxiPath 585 (Gateways Murket and Shaadraz) + } + if (action == GOSSIP_ACTION_INFO_DEF + 2) + { + player->CLOSE_GOSSIP_MENU(); + player->CastSpell(player,35069,true); //TaxiPath 612 (Taxi - Hellfire Peninsula - Expedition Point to Shatter Point) + } + return true; +} + +/*###### +## npc_gryphoneer_windbellow +######*/ + +#define GOSSIP_ITEM1_WIN "Fly me to The Abyssal Shelf" +#define GOSSIP_ITEM2_WIN "Fly me to Honor Point" + +bool GossipHello_npc_gryphoneer_windbellow(Player *player, Creature *_Creature) +{ + if (_Creature->isQuestGiver()) + player->PrepareQuestMenu( _Creature->GetGUID() ); + + //Mission: The Abyssal Shelf || Return to the Abyssal Shelf + if (player->GetQuestStatus(10163) == QUEST_STATUS_INCOMPLETE || player->GetQuestStatus(10346) == QUEST_STATUS_INCOMPLETE) + player->ADD_GOSSIP_ITEM(2, GOSSIP_ITEM1_WIN, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); + + //Go to the Front + if (player->GetQuestStatus(10382) != QUEST_STATUS_NONE && !player->GetQuestRewardStatus(10382)) + player->ADD_GOSSIP_ITEM(2, GOSSIP_ITEM2_WIN, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2); + + player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); + + return true; +} + +bool GossipSelect_npc_gryphoneer_windbellow(Player *player, Creature *_Creature, uint32 sender, uint32 action ) +{ + if (action == GOSSIP_ACTION_INFO_DEF + 1) + { + player->CLOSE_GOSSIP_MENU(); + player->CastSpell(player,33899,true); //TaxiPath 589 (Aerial Assault Flight (Alliance)) + } + if (action == GOSSIP_ACTION_INFO_DEF + 2) + { + player->CLOSE_GOSSIP_MENU(); + player->CastSpell(player,35065,true); //TaxiPath 607 (Taxi - Hellfire Peninsula - Shatter Point to Beach Head) + } + return true; +} + +/*###### +## npc_wing_commander_brack +######*/ + +#define GOSSIP_ITEM1_BRA "Fly me to Murketh and Shaadraz Gateways" +#define GOSSIP_ITEM2_BRA "Fly me to The Abyssal Shelf" +#define GOSSIP_ITEM3_BRA "Fly me to Spinebreaker Post" + +bool GossipHello_npc_wing_commander_brack(Player *player, Creature *_Creature) +{ + if (_Creature->isQuestGiver()) + player->PrepareQuestMenu( _Creature->GetGUID() ); + + //Mission: The Murketh and Shaadraz Gateways + if (player->GetQuestStatus(10129) == QUEST_STATUS_INCOMPLETE) + player->ADD_GOSSIP_ITEM(2, GOSSIP_ITEM1_BRA, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); + + //Mission: The Abyssal Shelf || Return to the Abyssal Shelf + if (player->GetQuestStatus(10162) == QUEST_STATUS_INCOMPLETE || player->GetQuestStatus(10347) == QUEST_STATUS_INCOMPLETE) + player->ADD_GOSSIP_ITEM(2, GOSSIP_ITEM2_BRA, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2); + + //Spinebreaker Post + if (player->GetQuestStatus(10242) == QUEST_STATUS_COMPLETE && !player->GetQuestRewardStatus(10242)) + player->ADD_GOSSIP_ITEM(2, GOSSIP_ITEM3_BRA, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 3); + + player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); + + return true; +} + +bool GossipSelect_npc_wing_commander_brack(Player *player, Creature *_Creature, uint32 sender, uint32 action ) +{ + if (action == GOSSIP_ACTION_INFO_DEF + 1) + { + player->CLOSE_GOSSIP_MENU(); + player->CastSpell(player,33659,true); //TaxiPath 584 (Gateways Murket and Shaadraz) + } + if (action == GOSSIP_ACTION_INFO_DEF + 2) + { + player->CLOSE_GOSSIP_MENU(); + player->CastSpell(player,33825,true); //TaxiPath 587 (Aerial Assault Flight (Horde)) + } + if (action == GOSSIP_ACTION_INFO_DEF + 3) + { + player->CLOSE_GOSSIP_MENU(); + player->CastSpell(player,34578,true); //TaxiPath 604 (Taxi - Reaver's Fall to Spinebreaker Ridge) + } + return true; +} + +/*###### +## +######*/ + +void AddSC_hellfire_peninsula() +{ + Script *newscript; + + newscript = new Script; + newscript->Name="npc_wing_commander_dabiree"; + newscript->pGossipHello = &GossipHello_npc_wing_commander_dabiree; + newscript->pGossipSelect = &GossipSelect_npc_wing_commander_dabiree; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="npc_gryphoneer_windbellow"; + newscript->pGossipHello = &GossipHello_npc_gryphoneer_windbellow; + newscript->pGossipSelect = &GossipSelect_npc_gryphoneer_windbellow; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="npc_wing_commander_brack"; + newscript->pGossipHello = &GossipHello_npc_wing_commander_brack; + newscript->pGossipSelect = &GossipSelect_npc_wing_commander_brack; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/ironforge/ironforge.cpp b/src/bindings/scripts/scripts/zone/ironforge/ironforge.cpp index 5ba9e4b3ae1..ff4d0cd6cc2 100644 --- a/src/bindings/scripts/scripts/zone/ironforge/ironforge.cpp +++ b/src/bindings/scripts/scripts/zone/ironforge/ironforge.cpp @@ -1,93 +1,93 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Ironforge -SD%Complete: 100 -SDComment: Quest support: 3702 -SDCategory: Ironforge -EndScriptData */ - -/* ContentData -npc_royal_historian_archesonus -EndContentData */ - -#include "precompiled.h" - -/*###### -## npc_royal_historian_archesonus -######*/ - -#define GOSSIP_ITEM_ROYAL "I am ready to listen" -#define GOSSIP_ITEM_ROYAL_1 "That is tragic. How did this happen?" -#define GOSSIP_ITEM_ROYAL_2 "Interesting, continue please." -#define GOSSIP_ITEM_ROYAL_3 "Unbelievable! How dare they??" -#define GOSSIP_ITEM_ROYAL_4 "Of course I will help!" - -bool GossipHello_npc_royal_historian_archesonus(Player *player, Creature *_Creature) -{ - if (_Creature->isQuestGiver()) - player->PrepareQuestMenu( _Creature->GetGUID() ); - - if (player->GetQuestStatus(3702) == QUEST_STATUS_INCOMPLETE) - { - player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM_ROYAL, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF); - player->SEND_GOSSIP_MENU(2235, _Creature->GetGUID()); - } - else - player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); - - return true; -} - -bool GossipSelect_npc_royal_historian_archesonus(Player *player, Creature *_Creature, uint32 sender, uint32 action) -{ - switch (action) - { - case GOSSIP_ACTION_INFO_DEF: - player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM_ROYAL_1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); - player->SEND_GOSSIP_MENU(2236, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+1: - player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM_ROYAL_2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2); - player->SEND_GOSSIP_MENU(2237, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+2: - player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM_ROYAL_3, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 3); - player->SEND_GOSSIP_MENU(2238, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+3: - player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM_ROYAL_4, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 4); - player->SEND_GOSSIP_MENU(2239, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+4: - player->CLOSE_GOSSIP_MENU(); - player->AreaExploredOrEventHappens(3702); - break; - } - return true; -} - -void AddSC_ironforge() -{ - Script *newscript; - - newscript = new Script; - newscript->Name="npc_royal_historian_archesonus"; - newscript->pGossipHello = &GossipHello_npc_royal_historian_archesonus; - newscript->pGossipSelect = &GossipSelect_npc_royal_historian_archesonus; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Ironforge +SD%Complete: 100 +SDComment: Quest support: 3702 +SDCategory: Ironforge +EndScriptData */ + +/* ContentData +npc_royal_historian_archesonus +EndContentData */ + +#include "precompiled.h" + +/*###### +## npc_royal_historian_archesonus +######*/ + +#define GOSSIP_ITEM_ROYAL "I am ready to listen" +#define GOSSIP_ITEM_ROYAL_1 "That is tragic. How did this happen?" +#define GOSSIP_ITEM_ROYAL_2 "Interesting, continue please." +#define GOSSIP_ITEM_ROYAL_3 "Unbelievable! How dare they??" +#define GOSSIP_ITEM_ROYAL_4 "Of course I will help!" + +bool GossipHello_npc_royal_historian_archesonus(Player *player, Creature *_Creature) +{ + if (_Creature->isQuestGiver()) + player->PrepareQuestMenu( _Creature->GetGUID() ); + + if (player->GetQuestStatus(3702) == QUEST_STATUS_INCOMPLETE) + { + player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM_ROYAL, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF); + player->SEND_GOSSIP_MENU(2235, _Creature->GetGUID()); + } + else + player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); + + return true; +} + +bool GossipSelect_npc_royal_historian_archesonus(Player *player, Creature *_Creature, uint32 sender, uint32 action) +{ + switch (action) + { + case GOSSIP_ACTION_INFO_DEF: + player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM_ROYAL_1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); + player->SEND_GOSSIP_MENU(2236, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+1: + player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM_ROYAL_2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2); + player->SEND_GOSSIP_MENU(2237, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+2: + player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM_ROYAL_3, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 3); + player->SEND_GOSSIP_MENU(2238, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+3: + player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM_ROYAL_4, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 4); + player->SEND_GOSSIP_MENU(2239, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+4: + player->CLOSE_GOSSIP_MENU(); + player->AreaExploredOrEventHappens(3702); + break; + } + return true; +} + +void AddSC_ironforge() +{ + Script *newscript; + + newscript = new Script; + newscript->Name="npc_royal_historian_archesonus"; + newscript->pGossipHello = &GossipHello_npc_royal_historian_archesonus; + newscript->pGossipSelect = &GossipSelect_npc_royal_historian_archesonus; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/isle_of_queldanas/isle_of_queldanas.cpp b/src/bindings/scripts/scripts/zone/isle_of_queldanas/isle_of_queldanas.cpp index 06baf994a18..732183f3a48 100644 --- a/src/bindings/scripts/scripts/zone/isle_of_queldanas/isle_of_queldanas.cpp +++ b/src/bindings/scripts/scripts/zone/isle_of_queldanas/isle_of_queldanas.cpp @@ -1,155 +1,155 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Isle_of_Queldanas -SD%Complete: 100 -SDComment: Quest support: 11524, 11525, 11532, 11533, 11542, 11543 -SDCategory: Isle Of Quel'Danas -EndScriptData */ - -/* ContentData -npc_ayren_cloudbreaker -npc_converted_sentry -npc_unrestrained_dragonhawk -EndContentData */ - -#include "precompiled.h" - -/*###### -## npc_ayren_cloudbreaker -######*/ - -bool GossipHello_npc_ayren_cloudbreaker(Player *player, Creature *_Creature) -{ - if( player->GetQuestStatus(11532) == QUEST_STATUS_INCOMPLETE || player->GetQuestStatus(11533) == QUEST_STATUS_INCOMPLETE) - player->ADD_GOSSIP_ITEM(0,"Speaking of action, I've been ordered to undertake an air strike.",GOSSIP_SENDER_MAIN,GOSSIP_ACTION_INFO_DEF+1); - - if( player->GetQuestStatus(11542) == QUEST_STATUS_INCOMPLETE || player->GetQuestStatus(11543) == QUEST_STATUS_INCOMPLETE) - player->ADD_GOSSIP_ITEM(0,"I need to intercept the Dawnblade reinforcements.",GOSSIP_SENDER_MAIN,GOSSIP_ACTION_INFO_DEF+2); - - player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(),_Creature->GetGUID()); - return true; -} - -bool GossipSelect_npc_ayren_cloudbreaker(Player *player, Creature *_Creature, uint32 sender, uint32 action ) -{ - if (action == GOSSIP_ACTION_INFO_DEF+1) - { - player->CLOSE_GOSSIP_MENU(); - player->CastSpell(player,45071,true); //TaxiPath 779 - } - if (action == GOSSIP_ACTION_INFO_DEF+2) - { - player->CLOSE_GOSSIP_MENU(); - player->CastSpell(player,45113,true); //TaxiPath 784 - } - return true; -} - -/*###### -## npc_converted_sentry -######*/ - -#define SAY_CONVERTED_1 "Deployment sucessful. Trespassers will be neutralized." -#define SAY_CONVERTED_2 "Objective acquired. Initiating security routines." - -#define SPELL_CONVERT_CREDIT 45009 - -struct MANGOS_DLL_DECL npc_converted_sentryAI : public ScriptedAI -{ - npc_converted_sentryAI(Creature *c) : ScriptedAI(c) { Reset(); } - - bool Credit; - uint32 Timer; - - void Reset() - { - Credit = false; - Timer = 2500; - } - - void MoveInLineOfSight(Unit *who) - { return; } - void Aggro(Unit* who) - { } - - void UpdateAI(const uint32 diff) - { - if( !Credit ) - { - if( Timer <= diff ) - { - uint32 i = urand(1,2); - if( i=1 ) DoSay(SAY_CONVERTED_1,LANG_UNIVERSAL,NULL); - else DoSay(SAY_CONVERTED_2,LANG_UNIVERSAL,NULL); - - DoCast(m_creature,SPELL_CONVERT_CREDIT); - ((Pet*)m_creature)->SetDuration(7500); - Credit = true; - }else Timer -= diff; - } - } -}; -CreatureAI* GetAI_npc_converted_sentry(Creature *_Creature) -{ - return new npc_converted_sentryAI (_Creature); -} - -/*###### -## npc_unrestrained_dragonhawk -######*/ - -bool GossipHello_npc_unrestrained_dragonhawk(Player *player, Creature *_Creature) -{ - if( player->GetQuestStatus(11542) == QUEST_STATUS_COMPLETE || player->GetQuestStatus(11543) == QUEST_STATUS_COMPLETE ) - player->ADD_GOSSIP_ITEM(0,"",GOSSIP_SENDER_MAIN,GOSSIP_ACTION_INFO_DEF+1); - - player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(),_Creature->GetGUID()); - return true; -} - -bool GossipSelect_npc_unrestrained_dragonhawk(Player *player, Creature *_Creature, uint32 sender, uint32 action ) -{ - if (action == GOSSIP_ACTION_INFO_DEF+1) - { - player->CLOSE_GOSSIP_MENU(); - player->CastSpell(player,45353,true); //TaxiPath 788 - } - return true; -} - -void AddSC_isle_of_queldanas() -{ - Script *newscript; - - newscript = new Script; - newscript->Name="npc_ayren_cloudbreaker"; - newscript->pGossipHello = &GossipHello_npc_ayren_cloudbreaker; - newscript->pGossipSelect = &GossipSelect_npc_ayren_cloudbreaker; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="npc_converted_sentry"; - newscript->GetAI = GetAI_npc_converted_sentry; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="npc_unrestrained_dragonhawk"; - newscript->pGossipHello = &GossipHello_npc_unrestrained_dragonhawk; - newscript->pGossipSelect = &GossipSelect_npc_unrestrained_dragonhawk; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Isle_of_Queldanas +SD%Complete: 100 +SDComment: Quest support: 11524, 11525, 11532, 11533, 11542, 11543 +SDCategory: Isle Of Quel'Danas +EndScriptData */ + +/* ContentData +npc_ayren_cloudbreaker +npc_converted_sentry +npc_unrestrained_dragonhawk +EndContentData */ + +#include "precompiled.h" + +/*###### +## npc_ayren_cloudbreaker +######*/ + +bool GossipHello_npc_ayren_cloudbreaker(Player *player, Creature *_Creature) +{ + if( player->GetQuestStatus(11532) == QUEST_STATUS_INCOMPLETE || player->GetQuestStatus(11533) == QUEST_STATUS_INCOMPLETE) + player->ADD_GOSSIP_ITEM(0,"Speaking of action, I've been ordered to undertake an air strike.",GOSSIP_SENDER_MAIN,GOSSIP_ACTION_INFO_DEF+1); + + if( player->GetQuestStatus(11542) == QUEST_STATUS_INCOMPLETE || player->GetQuestStatus(11543) == QUEST_STATUS_INCOMPLETE) + player->ADD_GOSSIP_ITEM(0,"I need to intercept the Dawnblade reinforcements.",GOSSIP_SENDER_MAIN,GOSSIP_ACTION_INFO_DEF+2); + + player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(),_Creature->GetGUID()); + return true; +} + +bool GossipSelect_npc_ayren_cloudbreaker(Player *player, Creature *_Creature, uint32 sender, uint32 action ) +{ + if (action == GOSSIP_ACTION_INFO_DEF+1) + { + player->CLOSE_GOSSIP_MENU(); + player->CastSpell(player,45071,true); //TaxiPath 779 + } + if (action == GOSSIP_ACTION_INFO_DEF+2) + { + player->CLOSE_GOSSIP_MENU(); + player->CastSpell(player,45113,true); //TaxiPath 784 + } + return true; +} + +/*###### +## npc_converted_sentry +######*/ + +#define SAY_CONVERTED_1 "Deployment sucessful. Trespassers will be neutralized." +#define SAY_CONVERTED_2 "Objective acquired. Initiating security routines." + +#define SPELL_CONVERT_CREDIT 45009 + +struct MANGOS_DLL_DECL npc_converted_sentryAI : public ScriptedAI +{ + npc_converted_sentryAI(Creature *c) : ScriptedAI(c) { Reset(); } + + bool Credit; + uint32 Timer; + + void Reset() + { + Credit = false; + Timer = 2500; + } + + void MoveInLineOfSight(Unit *who) + { return; } + void Aggro(Unit* who) + { } + + void UpdateAI(const uint32 diff) + { + if( !Credit ) + { + if( Timer <= diff ) + { + uint32 i = urand(1,2); + if( i=1 ) DoSay(SAY_CONVERTED_1,LANG_UNIVERSAL,NULL); + else DoSay(SAY_CONVERTED_2,LANG_UNIVERSAL,NULL); + + DoCast(m_creature,SPELL_CONVERT_CREDIT); + ((Pet*)m_creature)->SetDuration(7500); + Credit = true; + }else Timer -= diff; + } + } +}; +CreatureAI* GetAI_npc_converted_sentry(Creature *_Creature) +{ + return new npc_converted_sentryAI (_Creature); +} + +/*###### +## npc_unrestrained_dragonhawk +######*/ + +bool GossipHello_npc_unrestrained_dragonhawk(Player *player, Creature *_Creature) +{ + if( player->GetQuestStatus(11542) == QUEST_STATUS_COMPLETE || player->GetQuestStatus(11543) == QUEST_STATUS_COMPLETE ) + player->ADD_GOSSIP_ITEM(0,"",GOSSIP_SENDER_MAIN,GOSSIP_ACTION_INFO_DEF+1); + + player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(),_Creature->GetGUID()); + return true; +} + +bool GossipSelect_npc_unrestrained_dragonhawk(Player *player, Creature *_Creature, uint32 sender, uint32 action ) +{ + if (action == GOSSIP_ACTION_INFO_DEF+1) + { + player->CLOSE_GOSSIP_MENU(); + player->CastSpell(player,45353,true); //TaxiPath 788 + } + return true; +} + +void AddSC_isle_of_queldanas() +{ + Script *newscript; + + newscript = new Script; + newscript->Name="npc_ayren_cloudbreaker"; + newscript->pGossipHello = &GossipHello_npc_ayren_cloudbreaker; + newscript->pGossipSelect = &GossipSelect_npc_ayren_cloudbreaker; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="npc_converted_sentry"; + newscript->GetAI = GetAI_npc_converted_sentry; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="npc_unrestrained_dragonhawk"; + newscript->pGossipHello = &GossipHello_npc_unrestrained_dragonhawk; + newscript->pGossipSelect = &GossipSelect_npc_unrestrained_dragonhawk; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/karazhan/boss_curator.cpp b/src/bindings/scripts/scripts/zone/karazhan/boss_curator.cpp index b7c4af8dded..b6d04295399 100644 --- a/src/bindings/scripts/scripts/zone/karazhan/boss_curator.cpp +++ b/src/bindings/scripts/scripts/zone/karazhan/boss_curator.cpp @@ -1,200 +1,200 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Curator -SD%Complete: 100 -SDComment: Evocation may cause client crash (Core related) -SDCategory: Karazhan -EndScriptData */ - -#include "precompiled.h" - -#define SAY_AGGRO "The Menagerie is for guests only." -#define SOUND_AGGRO 9183 - -#define SAY_SUMMON1 "Gallery rules will be strictly enforced." -#define SOUND_SUMMON1 9188 - -#define SAY_SUMMON2 "This curator is equipped for gallery protection." -#define SOUND_SUMMON2 9309 - -#define SAY_EVOCATE "Your request cannot be processed." -#define SOUND_EVOCATE 9186 - -#define SAY_ENRAGE "Failure to comply will result in offensive action." -#define SOUND_ENRAGE 9185 - -#define SAY_KILL1 "Do not touch the displays." -#define SOUND_KILL1 9187 - -#define SAY_KILL2 "You are not a guest." -#define SOUND_KILL2 9308 - -#define SAY_DEATH "This Curator is no longer op... er... ation... al." -#define SOUND_DEATH 9184 - -//Flare spell info -#define SPELL_ASTRAL_FLARE_PASSIVE 30234 -#define SPELL_ASTRAL_FLARE_NE 30236 -#define SPELL_ASTRAL_FLARE_NW 30239 -#define SPELL_ASTRAL_FLARE_SE 30240 -#define SPELL_ASTRAL_FLARE_SW 30241 - -//Curator spell info -#define SPELL_HATEFUL_BOLT 30383 -#define SPELL_EVOCATION 30254 -#define SPELL_ENRAGE 28131 -#define SPELL_BERSERK 26662 - -struct MANGOS_DLL_DECL boss_curatorAI : public ScriptedAI -{ - boss_curatorAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 AddTimer; - uint32 HatefulBoltTimer; - uint32 BerserkTimer; - - bool Enraged; - bool Evocating; - - void Reset() - { - AddTimer = 10000; - HatefulBoltTimer = 15000; // This time is probably wrong - BerserkTimer = 720000; //12 minutes - Enraged = false; - Evocating = false; - } - - void KilledUnit(Unit *victim) - { - switch(rand()%2) - { - case 0: - DoYell(SAY_KILL1, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(victim, SOUND_KILL1); - break; - case 1: - DoYell(SAY_KILL2, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(victim, SOUND_KILL2); - break; - } - } - - void JustDied(Unit *victim) - { - DoYell(SAY_DEATH, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(NULL, SOUND_DEATH); - } - - void Aggro(Unit *who) - { - DoYell(SAY_AGGRO, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_AGGRO); - } - - void UpdateAI(const uint32 diff) - { - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - if (Evocating && !m_creature->HasAura(SPELL_EVOCATION, 0)) - Evocating = false; - - if(m_creature->GetPower(POWER_MANA) <= 1000 && !Evocating) - { - DoYell(SAY_EVOCATE, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_EVOCATE); - m_creature->InterruptNonMeleeSpells(false); - DoCast(m_creature, SPELL_EVOCATION); - Evocating = true; - } - - if(!Enraged && !Evocating) - { - if(AddTimer < diff) - { - //Summon Astral Flare - Creature* AstralFlare = DoSpawnCreature(17096, 0, 0, 0, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000); - Unit* target = NULL; - target = SelectUnit(SELECT_TARGET_RANDOM, 0); - - if (AstralFlare && target) - { - AstralFlare->CastSpell(AstralFlare, SPELL_ASTRAL_FLARE_PASSIVE, false); - AstralFlare->AI()->AttackStart(target); - } - - //Reduce Mana by 10% - int32 mana = (int32)(0.1f*(m_creature->GetMaxPower(POWER_MANA))); - m_creature->ModifyPower(POWER_MANA, -mana); - switch(rand()%4) - { - case 0: - DoYell(SAY_SUMMON1, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_SUMMON1); - break; - case 1: - DoYell(SAY_SUMMON2, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_SUMMON2); - break; - } - AddTimer = 10000; - }else AddTimer -= diff; - - if(HatefulBoltTimer < diff) - { - Unit* target = NULL; - target = SelectUnit(SELECT_TARGET_TOPAGGRO, 1); - DoCast(target, SPELL_HATEFUL_BOLT); - - HatefulBoltTimer = 15000; - }else HatefulBoltTimer -= diff; - - if(m_creature->GetHealth()*100 / m_creature->GetMaxHealth() < 15) - { - Enraged = true; - DoCast(m_creature, SPELL_ENRAGE); - DoYell(SAY_ENRAGE, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_ENRAGE); - } - } - - if(BerserkTimer < diff) - { - DoCast(m_creature, SPELL_BERSERK); - DoYell(SAY_ENRAGE, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_ENRAGE); - }else BerserkTimer -= diff; - - DoMeleeAttackIfReady(); - } -}; - -CreatureAI* GetAI_boss_curator(Creature *_Creature) -{ - return new boss_curatorAI (_Creature); -} - -void AddSC_boss_curator() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_curator"; - newscript->GetAI = GetAI_boss_curator; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Curator +SD%Complete: 100 +SDComment: Evocation may cause client crash (Core related) +SDCategory: Karazhan +EndScriptData */ + +#include "precompiled.h" + +#define SAY_AGGRO "The Menagerie is for guests only." +#define SOUND_AGGRO 9183 + +#define SAY_SUMMON1 "Gallery rules will be strictly enforced." +#define SOUND_SUMMON1 9188 + +#define SAY_SUMMON2 "This curator is equipped for gallery protection." +#define SOUND_SUMMON2 9309 + +#define SAY_EVOCATE "Your request cannot be processed." +#define SOUND_EVOCATE 9186 + +#define SAY_ENRAGE "Failure to comply will result in offensive action." +#define SOUND_ENRAGE 9185 + +#define SAY_KILL1 "Do not touch the displays." +#define SOUND_KILL1 9187 + +#define SAY_KILL2 "You are not a guest." +#define SOUND_KILL2 9308 + +#define SAY_DEATH "This Curator is no longer op... er... ation... al." +#define SOUND_DEATH 9184 + +//Flare spell info +#define SPELL_ASTRAL_FLARE_PASSIVE 30234 +#define SPELL_ASTRAL_FLARE_NE 30236 +#define SPELL_ASTRAL_FLARE_NW 30239 +#define SPELL_ASTRAL_FLARE_SE 30240 +#define SPELL_ASTRAL_FLARE_SW 30241 + +//Curator spell info +#define SPELL_HATEFUL_BOLT 30383 +#define SPELL_EVOCATION 30254 +#define SPELL_ENRAGE 28131 +#define SPELL_BERSERK 26662 + +struct MANGOS_DLL_DECL boss_curatorAI : public ScriptedAI +{ + boss_curatorAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 AddTimer; + uint32 HatefulBoltTimer; + uint32 BerserkTimer; + + bool Enraged; + bool Evocating; + + void Reset() + { + AddTimer = 10000; + HatefulBoltTimer = 15000; // This time is probably wrong + BerserkTimer = 720000; //12 minutes + Enraged = false; + Evocating = false; + } + + void KilledUnit(Unit *victim) + { + switch(rand()%2) + { + case 0: + DoYell(SAY_KILL1, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(victim, SOUND_KILL1); + break; + case 1: + DoYell(SAY_KILL2, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(victim, SOUND_KILL2); + break; + } + } + + void JustDied(Unit *victim) + { + DoYell(SAY_DEATH, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(NULL, SOUND_DEATH); + } + + void Aggro(Unit *who) + { + DoYell(SAY_AGGRO, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_AGGRO); + } + + void UpdateAI(const uint32 diff) + { + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + if (Evocating && !m_creature->HasAura(SPELL_EVOCATION, 0)) + Evocating = false; + + if(m_creature->GetPower(POWER_MANA) <= 1000 && !Evocating) + { + DoYell(SAY_EVOCATE, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_EVOCATE); + m_creature->InterruptNonMeleeSpells(false); + DoCast(m_creature, SPELL_EVOCATION); + Evocating = true; + } + + if(!Enraged && !Evocating) + { + if(AddTimer < diff) + { + //Summon Astral Flare + Creature* AstralFlare = DoSpawnCreature(17096, 0, 0, 0, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000); + Unit* target = NULL; + target = SelectUnit(SELECT_TARGET_RANDOM, 0); + + if (AstralFlare && target) + { + AstralFlare->CastSpell(AstralFlare, SPELL_ASTRAL_FLARE_PASSIVE, false); + AstralFlare->AI()->AttackStart(target); + } + + //Reduce Mana by 10% + int32 mana = (int32)(0.1f*(m_creature->GetMaxPower(POWER_MANA))); + m_creature->ModifyPower(POWER_MANA, -mana); + switch(rand()%4) + { + case 0: + DoYell(SAY_SUMMON1, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_SUMMON1); + break; + case 1: + DoYell(SAY_SUMMON2, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_SUMMON2); + break; + } + AddTimer = 10000; + }else AddTimer -= diff; + + if(HatefulBoltTimer < diff) + { + Unit* target = NULL; + target = SelectUnit(SELECT_TARGET_TOPAGGRO, 1); + DoCast(target, SPELL_HATEFUL_BOLT); + + HatefulBoltTimer = 15000; + }else HatefulBoltTimer -= diff; + + if(m_creature->GetHealth()*100 / m_creature->GetMaxHealth() < 15) + { + Enraged = true; + DoCast(m_creature, SPELL_ENRAGE); + DoYell(SAY_ENRAGE, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_ENRAGE); + } + } + + if(BerserkTimer < diff) + { + DoCast(m_creature, SPELL_BERSERK); + DoYell(SAY_ENRAGE, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_ENRAGE); + }else BerserkTimer -= diff; + + DoMeleeAttackIfReady(); + } +}; + +CreatureAI* GetAI_boss_curator(Creature *_Creature) +{ + return new boss_curatorAI (_Creature); +} + +void AddSC_boss_curator() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_curator"; + newscript->GetAI = GetAI_boss_curator; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/karazhan/boss_maiden_of_virtue.cpp b/src/bindings/scripts/scripts/zone/karazhan/boss_maiden_of_virtue.cpp index 45ee19c7999..53befd38365 100644 --- a/src/bindings/scripts/scripts/zone/karazhan/boss_maiden_of_virtue.cpp +++ b/src/bindings/scripts/scripts/zone/karazhan/boss_maiden_of_virtue.cpp @@ -1,176 +1,176 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Maiden_of_Virtue -SD%Complete: 100 -SDComment: -SDCategory: Karazhan -EndScriptData */ - -#include "precompiled.h" - -#define SPELL_REPENTANCE 29511 -#define SPELL_HOLYFIRE 29522 -#define SPELL_HOLYWRATH 32445 -#define SPELL_HOLYGROUND 29512 - -#define SAY_AGGRO "Your behavior will not be tolerated!" -#define SAY_SLAY1 "Ah ah ah..." -#define SAY_SLAY2 "This is for the best." -#define SAY_SLAY3 "Impure thoughts lead to profane actions." -#define SAY_REPENTANCE1 "Cast out your corrupt thoughts." -#define SAY_REPENTANCE2 "Your impurity must be cleansed." -#define SAY_DEATH "Death comes. Will your conscience be clear?" - -#define SOUND_AGGRO 9204 -#define SOUND_SLAY1 9207 -#define SOUND_SLAY2 9312 -#define SOUND_SLAY3 9311 -#define SOUND_REPENTANCE1 9313 -#define SOUND_REPENTANCE2 9208 -#define SOUND_DEATH 9206 - -struct MANGOS_DLL_DECL boss_maiden_of_virtueAI : public ScriptedAI -{ - boss_maiden_of_virtueAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 Repentance_Timer; - uint32 Holyfire_Timer; - uint32 Holywrath_Timer; - uint32 Holyground_Timer; - - void Reset() - { - Repentance_Timer = 30000+(rand()%15000); - Holyfire_Timer = 8000+(rand()%17000); - Holywrath_Timer = 20000+(rand()%10000); - Holyground_Timer = 3000; - } - - void KilledUnit(Unit* Victim) - { - if(rand()%2) return; - - switch(rand()%3) - { - case 0: - DoYell(SAY_SLAY1,LANG_UNIVERSAL,Victim); - DoPlaySoundToSet(m_creature, SOUND_SLAY1); - break; - case 1: - DoYell(SAY_SLAY2,LANG_UNIVERSAL,Victim); - DoPlaySoundToSet(m_creature, SOUND_SLAY2); - break; - case 2: - DoYell(SAY_SLAY3,LANG_UNIVERSAL,Victim); - DoPlaySoundToSet(m_creature, SOUND_SLAY3); - break; - } - } - - void JustDied(Unit* Killer) - { - DoYell(SAY_DEATH,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature, SOUND_DEATH); - } - - void Aggro(Unit *who) - { - DoYell(SAY_AGGRO, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_AGGRO); - } - - void UpdateAI(const uint32 diff) - { - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - if (Holyground_Timer < diff) - { - DoCast(m_creature, SPELL_HOLYGROUND, true); //Triggered so it doesn't interrupt her at all - Holyground_Timer = 3000; - }else Holyground_Timer -= diff; - - if (Repentance_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_REPENTANCE); - - switch(rand()%2) - { - case 0: - DoYell(SAY_REPENTANCE1,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature, SOUND_REPENTANCE1); - break; - case 1: - DoYell(SAY_REPENTANCE2,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature, SOUND_REPENTANCE2); - break; - } - Repentance_Timer = 30000 + rand()%15000; //A little randomness on that spell - }else Repentance_Timer -= diff; - - if (Holyfire_Timer < diff) - { - //Time for an omgwtfpwn code to make maiden cast holy fire only on units outside the holy ground's 18 yard range - Unit* target = NULL; - std::list t_list = m_creature->getThreatManager().getThreatList(); - std::vector target_list; - for(std::list::iterator itr = t_list.begin(); itr!= t_list.end(); ++itr) - { - target = Unit::GetUnit(*m_creature, (*itr)->getUnitGuid()); - if(target && target->GetDistance2d(m_creature) > 12 ) - target_list.push_back(target); - target = NULL; - } - if(target_list.size()) - target = *(target_list.begin()+rand()%target_list.size()); - - DoCast(target,SPELL_HOLYFIRE); - - Holyfire_Timer = 8000 + rand()%17000; //Anywhere from 8 to 25 seconds, good luck having several of those in a row! - }else Holyfire_Timer -= diff; - - if (Holywrath_Timer < diff) - { - Unit* target = NULL; - target = SelectUnit(SELECT_TARGET_RANDOM,0); - - if (target) - { - DoCast(target,SPELL_HOLYWRATH); - Holywrath_Timer = 20000+(rand()%10000); //20-30 secs sounds nice - } - }else Holywrath_Timer -= diff; - - DoMeleeAttackIfReady(); - } - -}; - -CreatureAI* GetAI_boss_maiden_of_virtue(Creature *_Creature) -{ - return new boss_maiden_of_virtueAI (_Creature); -} - -void AddSC_boss_maiden_of_virtue() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_maiden_of_virtue"; - newscript->GetAI = GetAI_boss_maiden_of_virtue; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Maiden_of_Virtue +SD%Complete: 100 +SDComment: +SDCategory: Karazhan +EndScriptData */ + +#include "precompiled.h" + +#define SPELL_REPENTANCE 29511 +#define SPELL_HOLYFIRE 29522 +#define SPELL_HOLYWRATH 32445 +#define SPELL_HOLYGROUND 29512 + +#define SAY_AGGRO "Your behavior will not be tolerated!" +#define SAY_SLAY1 "Ah ah ah..." +#define SAY_SLAY2 "This is for the best." +#define SAY_SLAY3 "Impure thoughts lead to profane actions." +#define SAY_REPENTANCE1 "Cast out your corrupt thoughts." +#define SAY_REPENTANCE2 "Your impurity must be cleansed." +#define SAY_DEATH "Death comes. Will your conscience be clear?" + +#define SOUND_AGGRO 9204 +#define SOUND_SLAY1 9207 +#define SOUND_SLAY2 9312 +#define SOUND_SLAY3 9311 +#define SOUND_REPENTANCE1 9313 +#define SOUND_REPENTANCE2 9208 +#define SOUND_DEATH 9206 + +struct MANGOS_DLL_DECL boss_maiden_of_virtueAI : public ScriptedAI +{ + boss_maiden_of_virtueAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 Repentance_Timer; + uint32 Holyfire_Timer; + uint32 Holywrath_Timer; + uint32 Holyground_Timer; + + void Reset() + { + Repentance_Timer = 30000+(rand()%15000); + Holyfire_Timer = 8000+(rand()%17000); + Holywrath_Timer = 20000+(rand()%10000); + Holyground_Timer = 3000; + } + + void KilledUnit(Unit* Victim) + { + if(rand()%2) return; + + switch(rand()%3) + { + case 0: + DoYell(SAY_SLAY1,LANG_UNIVERSAL,Victim); + DoPlaySoundToSet(m_creature, SOUND_SLAY1); + break; + case 1: + DoYell(SAY_SLAY2,LANG_UNIVERSAL,Victim); + DoPlaySoundToSet(m_creature, SOUND_SLAY2); + break; + case 2: + DoYell(SAY_SLAY3,LANG_UNIVERSAL,Victim); + DoPlaySoundToSet(m_creature, SOUND_SLAY3); + break; + } + } + + void JustDied(Unit* Killer) + { + DoYell(SAY_DEATH,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature, SOUND_DEATH); + } + + void Aggro(Unit *who) + { + DoYell(SAY_AGGRO, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_AGGRO); + } + + void UpdateAI(const uint32 diff) + { + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + if (Holyground_Timer < diff) + { + DoCast(m_creature, SPELL_HOLYGROUND, true); //Triggered so it doesn't interrupt her at all + Holyground_Timer = 3000; + }else Holyground_Timer -= diff; + + if (Repentance_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_REPENTANCE); + + switch(rand()%2) + { + case 0: + DoYell(SAY_REPENTANCE1,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature, SOUND_REPENTANCE1); + break; + case 1: + DoYell(SAY_REPENTANCE2,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature, SOUND_REPENTANCE2); + break; + } + Repentance_Timer = 30000 + rand()%15000; //A little randomness on that spell + }else Repentance_Timer -= diff; + + if (Holyfire_Timer < diff) + { + //Time for an omgwtfpwn code to make maiden cast holy fire only on units outside the holy ground's 18 yard range + Unit* target = NULL; + std::list t_list = m_creature->getThreatManager().getThreatList(); + std::vector target_list; + for(std::list::iterator itr = t_list.begin(); itr!= t_list.end(); ++itr) + { + target = Unit::GetUnit(*m_creature, (*itr)->getUnitGuid()); + if(target && target->GetDistance2d(m_creature) > 12 ) + target_list.push_back(target); + target = NULL; + } + if(target_list.size()) + target = *(target_list.begin()+rand()%target_list.size()); + + DoCast(target,SPELL_HOLYFIRE); + + Holyfire_Timer = 8000 + rand()%17000; //Anywhere from 8 to 25 seconds, good luck having several of those in a row! + }else Holyfire_Timer -= diff; + + if (Holywrath_Timer < diff) + { + Unit* target = NULL; + target = SelectUnit(SELECT_TARGET_RANDOM,0); + + if (target) + { + DoCast(target,SPELL_HOLYWRATH); + Holywrath_Timer = 20000+(rand()%10000); //20-30 secs sounds nice + } + }else Holywrath_Timer -= diff; + + DoMeleeAttackIfReady(); + } + +}; + +CreatureAI* GetAI_boss_maiden_of_virtue(Creature *_Creature) +{ + return new boss_maiden_of_virtueAI (_Creature); +} + +void AddSC_boss_maiden_of_virtue() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_maiden_of_virtue"; + newscript->GetAI = GetAI_boss_maiden_of_virtue; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/karazhan/boss_midnight.cpp b/src/bindings/scripts/scripts/zone/karazhan/boss_midnight.cpp index d70c25d15db..eb9c3b9ab72 100644 --- a/src/bindings/scripts/scripts/zone/karazhan/boss_midnight.cpp +++ b/src/bindings/scripts/scripts/zone/karazhan/boss_midnight.cpp @@ -1,371 +1,371 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Midnight -SD%Complete: 100 -SDComment: -SDCategory: Karazhan -EndScriptData */ - -#include "precompiled.h" - -#define SAY_MIDNIGHT_KILL "Well done Midnight!" -#define SOUND_MIDNIGHT_KILL 9173 - -#define SAY_APPEAR1 "Cowards! Wretches!" -#define SOUND_APPEAR1 9167 -#define SAY_APPEAR2 "Who dares attack the steed of the Huntsman?" -#define SOUND_APPEAR2 9298 -#define SAY_APPEAR3 "Perhaps you would rather test yourselves against a more formidable opponent?! " -#define SOUND_APPEAR3 9299 - -#define SAY_MOUNT "Come, Midnight, let\'s disperse this petty rabble! " -#define SOUND_MOUNT 9168 - -#define SAY_KILL1 "It was... inevitable." -#define SOUND_KILL1 9169 -#define SAY_KILL2 "Another trophy to add to my collection!" -#define SOUND_KILL2 9300 - -#define SAY_DISARMED "Weapons are merely a convenience for a warrior of my skill!" -#define SOUND_DISARMED 9166 - -#define SAY_DEATH "I always knew... someday I would become... the hunted." -#define SOUND_DEATH 9165 - -#define SAY_RANDOM1 "Such easy sport." -#define SOUND_RANDOM1 9170 -#define SAY_RANDOM2 "Amateurs! Do not think you can best me! I kill for a living." -#define SOUND_RANDOM2 9304 - -#define SPELL_SHADOWCLEAVE 29832 -#define SPELL_INTANGIBLE_PRESENCE 29833 -#define SPELL_BERSERKER_CHARGE 26561 //Only when mounted - -#define MOUNTED_DISPLAYID 16040 - -//Attumen (TODO: Use the summoning spell instead of creature id. It works , but is not convenient for us) -#define SUMMON_ATTUMEN 15550 - -struct MANGOS_DLL_DECL boss_midnightAI : public ScriptedAI -{ - boss_midnightAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint64 Attumen; - uint8 Phase; - uint32 Mount_Timer; - - void Reset() - { - Phase = 1; - Attumen = 0; - Mount_Timer = 0; - - m_creature->SetVisibility(VISIBILITY_ON); - } - - void Aggro(Unit* who) {} - - void KilledUnit(Unit *victim) - { - if(Phase == 2) - { - Unit *pUnit = Unit::GetUnit(*m_creature, Attumen); - if(pUnit) - { - pUnit->MonsterYell(SAY_MIDNIGHT_KILL, LANG_UNIVERSAL, 0); - DoPlaySoundToSet(pUnit, SOUND_MIDNIGHT_KILL); - } - } - } - - void UpdateAI(const uint32 diff) - { - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - if(Phase == 1 && (m_creature->GetHealth()*100)/m_creature->GetMaxHealth() < 95) - { - Phase = 2; - Creature *pAttumen = DoSpawnCreature(SUMMON_ATTUMEN, 0, 0, 0, 0, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 45000); - if(pAttumen) - { - Attumen = pAttumen->GetGUID(); - pAttumen->AI()->AttackStart(m_creature->getVictim()); - SetMidnight(pAttumen, m_creature->GetGUID()); - switch(rand()%3) - { - case 0: - pAttumen->Yell(SAY_APPEAR1, LANG_UNIVERSAL, 0); - DoPlaySoundToSet(m_creature, SOUND_APPEAR1); - break; - case 1: - pAttumen->Yell(SAY_APPEAR2, LANG_UNIVERSAL, 0); - DoPlaySoundToSet(m_creature, SOUND_APPEAR2); - break; - case 2: - pAttumen->Yell(SAY_APPEAR3, LANG_UNIVERSAL, 0); - DoPlaySoundToSet(m_creature, SOUND_APPEAR3); - break; - } - } - } - else if(Phase == 2 && (m_creature->GetHealth()*100)/m_creature->GetMaxHealth() < 25) - { - Unit *pAttumen = Unit::GetUnit(*m_creature, Attumen); - if(pAttumen) - Mount(pAttumen); - } - else if(Phase ==3) - { - if(Mount_Timer) - if(Mount_Timer <= diff) - { - Mount_Timer = 0; - m_creature->SetVisibility(VISIBILITY_OFF); - m_creature->GetMotionMaster()->MoveIdle(); - Unit *pAttumen = Unit::GetUnit(*m_creature, Attumen); - if(pAttumen) - { - pAttumen->SetUInt32Value(UNIT_FIELD_DISPLAYID, MOUNTED_DISPLAYID); - pAttumen->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); - if(pAttumen->getVictim()) - { - pAttumen->GetMotionMaster()->MoveChase(pAttumen->getVictim()); - pAttumen->SetUInt64Value(UNIT_FIELD_TARGET, pAttumen->getVictim()->GetGUID()); - } - pAttumen->SetFloatValue(OBJECT_FIELD_SCALE_X,1); - } - } else Mount_Timer -= diff; - } - - if(Phase != 3) - DoMeleeAttackIfReady(); - } - - void Mount(Unit *pAttumen) - { - DoPlaySoundToSet(pAttumen, SOUND_MOUNT); - pAttumen->MonsterYell(SAY_MOUNT, LANG_UNIVERSAL, 0); - Phase = 3; - m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); - pAttumen->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); - float angle = m_creature->GetAngle(pAttumen); - float distance = m_creature->GetDistance2d(pAttumen); - float newX = m_creature->GetPositionX() + cos(angle)*(distance/2) ; - float newY = m_creature->GetPositionY() + sin(angle)*(distance/2) ; - float newZ = 50; - //m_creature->Relocate(newX,newY,newZ,angle); - //m_creature->SendMonsterMove(newX, newY, newZ, 0, true, 1000); - m_creature->GetMotionMaster()->Clear(); - m_creature->GetMotionMaster()->MovePoint(0, newX, newY, newZ); - distance += 10; - newX = m_creature->GetPositionX() + cos(angle)*(distance/2) ; - newY = m_creature->GetPositionY() + sin(angle)*(distance/2) ; - pAttumen->GetMotionMaster()->Clear(); - pAttumen->GetMotionMaster()->MovePoint(0, newX, newY, newZ); - //pAttumen->Relocate(newX,newY,newZ,-angle); - //pAttumen->SendMonsterMove(newX, newY, newZ, 0, true, 1000); - Mount_Timer = 1000; - } - - void SetMidnight(Creature *, uint64); //Below .. -}; - -CreatureAI* GetAI_boss_midnight(Creature *_Creature) -{ - return new boss_midnightAI(_Creature); -} - -struct MANGOS_DLL_DECL boss_attumenAI : public ScriptedAI -{ - boss_attumenAI(Creature *c) : ScriptedAI(c) - { - Reset(); - Phase = 1; - - CleaveTimer = 10000 + (rand()%6)*1000; - CurseTimer = 30000; - RandomYellTimer = 30000 + (rand()%31)*1000; //Occasionally yell - ChargeTimer = 20000; - ResetTimer = 0; - } - - uint64 Midnight; - uint8 Phase; - uint32 CleaveTimer; - uint32 CurseTimer; - uint32 RandomYellTimer; - uint32 ChargeTimer; //only when mounted - uint32 ResetTimer; - - void Reset() - { - ResetTimer = 2000; - } - - void Aggro(Unit* who) {} - - void KilledUnit(Unit *victim) - { - switch(rand()%2) - { - case 0: - DoYell(SAY_KILL1,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature, SOUND_KILL1); - case 1: - DoYell(SAY_KILL2,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature, SOUND_KILL2); - } - } - - void JustDied(Unit *victim) - { - DoYell(SAY_DEATH, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature,SOUND_DEATH); - Unit *pMidnight = Unit::GetUnit(*m_creature, Midnight); - if(pMidnight) - { - pMidnight->DealDamage(pMidnight, pMidnight->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); - } - } - - void UpdateAI(const uint32 diff) - { - if(ResetTimer) - if(ResetTimer <= diff) - { - ResetTimer = 0; - Unit *pMidnight = Unit::GetUnit(*m_creature, Midnight); - if(pMidnight) - { - pMidnight->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); - pMidnight->SetVisibility(VISIBILITY_ON); - } - Midnight = 0; - - m_creature->SetVisibility(VISIBILITY_OFF); - m_creature->DealDamage(m_creature, m_creature->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); - } - else ResetTimer -= diff; - - //Return since we have no target - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - if(m_creature->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE )) - return; - - if(CleaveTimer < diff) - { - Unit *target = m_creature->getVictim(); - DoCast(target, SPELL_SHADOWCLEAVE); - CleaveTimer = 10000 + (rand()%6)*1000; - } else CleaveTimer -= diff; - - if(CurseTimer < diff) - { - DoCast(m_creature->getVictim(), SPELL_INTANGIBLE_PRESENCE); - CurseTimer = 30000; - } else CurseTimer -= diff; - - if(RandomYellTimer < diff) - { - switch(rand()%2) - { - case 0: - DoYell(SAY_RANDOM1, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_RANDOM1); - break; - case 1: - DoYell(SAY_RANDOM2, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_RANDOM2); - break; - } - RandomYellTimer = 30000 + (rand()%31)*1000; - } else RandomYellTimer -= diff; - - if(m_creature->GetUInt32Value(UNIT_FIELD_DISPLAYID) == MOUNTED_DISPLAYID) - { - if(ChargeTimer < diff) - { - Unit *target; - std::list t_list = m_creature->getThreatManager().getThreatList(); - std::vector target_list; - for(std::list::iterator itr = t_list.begin(); itr!= t_list.end(); ++itr) - { - target = Unit::GetUnit(*m_creature, (*itr)->getUnitGuid()); - if(target && target->GetDistance2d(m_creature) > 5) - target_list.push_back(target); - target = NULL; - } - if(target_list.size()) - target = *(target_list.begin()+rand()%target_list.size()); - - DoCast(target, SPELL_BERSERKER_CHARGE); - ChargeTimer = 20000; - } else ChargeTimer -= diff; - } - else - { - if( (m_creature->GetHealth()*100)/m_creature->GetMaxHealth() < 25) - { - Creature *pMidnight = (Creature*)Unit::GetUnit(*m_creature, Midnight); - if(pMidnight && pMidnight->GetTypeId() == TYPEID_UNIT) - { - ((boss_midnightAI*)(pMidnight->AI()))->Mount(m_creature); - m_creature->SetHealth(pMidnight->GetHealth()); - } - } - } - - DoMeleeAttackIfReady(); - } - - void SpellHit(Unit *source, const SpellEntry *spell) - { - if(spell->Mechanic == MECHANIC_DISARM) - { - DoYell(SAY_DISARMED, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_DISARMED); - } - } -}; - -void boss_midnightAI::SetMidnight(Creature *pAttumen, uint64 value) -{ - ((boss_attumenAI*)pAttumen->AI())->Midnight = value; -} - -CreatureAI* GetAI_boss_attumen(Creature *_Creature) -{ - return new boss_attumenAI (_Creature); -} - -void AddSC_boss_attumen() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_attumen"; - newscript->GetAI = GetAI_boss_attumen; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="boss_midnight"; - newscript->GetAI = GetAI_boss_midnight; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Midnight +SD%Complete: 100 +SDComment: +SDCategory: Karazhan +EndScriptData */ + +#include "precompiled.h" + +#define SAY_MIDNIGHT_KILL "Well done Midnight!" +#define SOUND_MIDNIGHT_KILL 9173 + +#define SAY_APPEAR1 "Cowards! Wretches!" +#define SOUND_APPEAR1 9167 +#define SAY_APPEAR2 "Who dares attack the steed of the Huntsman?" +#define SOUND_APPEAR2 9298 +#define SAY_APPEAR3 "Perhaps you would rather test yourselves against a more formidable opponent?! " +#define SOUND_APPEAR3 9299 + +#define SAY_MOUNT "Come, Midnight, let\'s disperse this petty rabble! " +#define SOUND_MOUNT 9168 + +#define SAY_KILL1 "It was... inevitable." +#define SOUND_KILL1 9169 +#define SAY_KILL2 "Another trophy to add to my collection!" +#define SOUND_KILL2 9300 + +#define SAY_DISARMED "Weapons are merely a convenience for a warrior of my skill!" +#define SOUND_DISARMED 9166 + +#define SAY_DEATH "I always knew... someday I would become... the hunted." +#define SOUND_DEATH 9165 + +#define SAY_RANDOM1 "Such easy sport." +#define SOUND_RANDOM1 9170 +#define SAY_RANDOM2 "Amateurs! Do not think you can best me! I kill for a living." +#define SOUND_RANDOM2 9304 + +#define SPELL_SHADOWCLEAVE 29832 +#define SPELL_INTANGIBLE_PRESENCE 29833 +#define SPELL_BERSERKER_CHARGE 26561 //Only when mounted + +#define MOUNTED_DISPLAYID 16040 + +//Attumen (TODO: Use the summoning spell instead of creature id. It works , but is not convenient for us) +#define SUMMON_ATTUMEN 15550 + +struct MANGOS_DLL_DECL boss_midnightAI : public ScriptedAI +{ + boss_midnightAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint64 Attumen; + uint8 Phase; + uint32 Mount_Timer; + + void Reset() + { + Phase = 1; + Attumen = 0; + Mount_Timer = 0; + + m_creature->SetVisibility(VISIBILITY_ON); + } + + void Aggro(Unit* who) {} + + void KilledUnit(Unit *victim) + { + if(Phase == 2) + { + Unit *pUnit = Unit::GetUnit(*m_creature, Attumen); + if(pUnit) + { + pUnit->MonsterYell(SAY_MIDNIGHT_KILL, LANG_UNIVERSAL, 0); + DoPlaySoundToSet(pUnit, SOUND_MIDNIGHT_KILL); + } + } + } + + void UpdateAI(const uint32 diff) + { + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + if(Phase == 1 && (m_creature->GetHealth()*100)/m_creature->GetMaxHealth() < 95) + { + Phase = 2; + Creature *pAttumen = DoSpawnCreature(SUMMON_ATTUMEN, 0, 0, 0, 0, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 45000); + if(pAttumen) + { + Attumen = pAttumen->GetGUID(); + pAttumen->AI()->AttackStart(m_creature->getVictim()); + SetMidnight(pAttumen, m_creature->GetGUID()); + switch(rand()%3) + { + case 0: + pAttumen->Yell(SAY_APPEAR1, LANG_UNIVERSAL, 0); + DoPlaySoundToSet(m_creature, SOUND_APPEAR1); + break; + case 1: + pAttumen->Yell(SAY_APPEAR2, LANG_UNIVERSAL, 0); + DoPlaySoundToSet(m_creature, SOUND_APPEAR2); + break; + case 2: + pAttumen->Yell(SAY_APPEAR3, LANG_UNIVERSAL, 0); + DoPlaySoundToSet(m_creature, SOUND_APPEAR3); + break; + } + } + } + else if(Phase == 2 && (m_creature->GetHealth()*100)/m_creature->GetMaxHealth() < 25) + { + Unit *pAttumen = Unit::GetUnit(*m_creature, Attumen); + if(pAttumen) + Mount(pAttumen); + } + else if(Phase ==3) + { + if(Mount_Timer) + if(Mount_Timer <= diff) + { + Mount_Timer = 0; + m_creature->SetVisibility(VISIBILITY_OFF); + m_creature->GetMotionMaster()->MoveIdle(); + Unit *pAttumen = Unit::GetUnit(*m_creature, Attumen); + if(pAttumen) + { + pAttumen->SetUInt32Value(UNIT_FIELD_DISPLAYID, MOUNTED_DISPLAYID); + pAttumen->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + if(pAttumen->getVictim()) + { + pAttumen->GetMotionMaster()->MoveChase(pAttumen->getVictim()); + pAttumen->SetUInt64Value(UNIT_FIELD_TARGET, pAttumen->getVictim()->GetGUID()); + } + pAttumen->SetFloatValue(OBJECT_FIELD_SCALE_X,1); + } + } else Mount_Timer -= diff; + } + + if(Phase != 3) + DoMeleeAttackIfReady(); + } + + void Mount(Unit *pAttumen) + { + DoPlaySoundToSet(pAttumen, SOUND_MOUNT); + pAttumen->MonsterYell(SAY_MOUNT, LANG_UNIVERSAL, 0); + Phase = 3; + m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + pAttumen->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + float angle = m_creature->GetAngle(pAttumen); + float distance = m_creature->GetDistance2d(pAttumen); + float newX = m_creature->GetPositionX() + cos(angle)*(distance/2) ; + float newY = m_creature->GetPositionY() + sin(angle)*(distance/2) ; + float newZ = 50; + //m_creature->Relocate(newX,newY,newZ,angle); + //m_creature->SendMonsterMove(newX, newY, newZ, 0, true, 1000); + m_creature->GetMotionMaster()->Clear(); + m_creature->GetMotionMaster()->MovePoint(0, newX, newY, newZ); + distance += 10; + newX = m_creature->GetPositionX() + cos(angle)*(distance/2) ; + newY = m_creature->GetPositionY() + sin(angle)*(distance/2) ; + pAttumen->GetMotionMaster()->Clear(); + pAttumen->GetMotionMaster()->MovePoint(0, newX, newY, newZ); + //pAttumen->Relocate(newX,newY,newZ,-angle); + //pAttumen->SendMonsterMove(newX, newY, newZ, 0, true, 1000); + Mount_Timer = 1000; + } + + void SetMidnight(Creature *, uint64); //Below .. +}; + +CreatureAI* GetAI_boss_midnight(Creature *_Creature) +{ + return new boss_midnightAI(_Creature); +} + +struct MANGOS_DLL_DECL boss_attumenAI : public ScriptedAI +{ + boss_attumenAI(Creature *c) : ScriptedAI(c) + { + Reset(); + Phase = 1; + + CleaveTimer = 10000 + (rand()%6)*1000; + CurseTimer = 30000; + RandomYellTimer = 30000 + (rand()%31)*1000; //Occasionally yell + ChargeTimer = 20000; + ResetTimer = 0; + } + + uint64 Midnight; + uint8 Phase; + uint32 CleaveTimer; + uint32 CurseTimer; + uint32 RandomYellTimer; + uint32 ChargeTimer; //only when mounted + uint32 ResetTimer; + + void Reset() + { + ResetTimer = 2000; + } + + void Aggro(Unit* who) {} + + void KilledUnit(Unit *victim) + { + switch(rand()%2) + { + case 0: + DoYell(SAY_KILL1,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature, SOUND_KILL1); + case 1: + DoYell(SAY_KILL2,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature, SOUND_KILL2); + } + } + + void JustDied(Unit *victim) + { + DoYell(SAY_DEATH, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature,SOUND_DEATH); + Unit *pMidnight = Unit::GetUnit(*m_creature, Midnight); + if(pMidnight) + { + pMidnight->DealDamage(pMidnight, pMidnight->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); + } + } + + void UpdateAI(const uint32 diff) + { + if(ResetTimer) + if(ResetTimer <= diff) + { + ResetTimer = 0; + Unit *pMidnight = Unit::GetUnit(*m_creature, Midnight); + if(pMidnight) + { + pMidnight->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + pMidnight->SetVisibility(VISIBILITY_ON); + } + Midnight = 0; + + m_creature->SetVisibility(VISIBILITY_OFF); + m_creature->DealDamage(m_creature, m_creature->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); + } + else ResetTimer -= diff; + + //Return since we have no target + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + if(m_creature->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE )) + return; + + if(CleaveTimer < diff) + { + Unit *target = m_creature->getVictim(); + DoCast(target, SPELL_SHADOWCLEAVE); + CleaveTimer = 10000 + (rand()%6)*1000; + } else CleaveTimer -= diff; + + if(CurseTimer < diff) + { + DoCast(m_creature->getVictim(), SPELL_INTANGIBLE_PRESENCE); + CurseTimer = 30000; + } else CurseTimer -= diff; + + if(RandomYellTimer < diff) + { + switch(rand()%2) + { + case 0: + DoYell(SAY_RANDOM1, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_RANDOM1); + break; + case 1: + DoYell(SAY_RANDOM2, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_RANDOM2); + break; + } + RandomYellTimer = 30000 + (rand()%31)*1000; + } else RandomYellTimer -= diff; + + if(m_creature->GetUInt32Value(UNIT_FIELD_DISPLAYID) == MOUNTED_DISPLAYID) + { + if(ChargeTimer < diff) + { + Unit *target; + std::list t_list = m_creature->getThreatManager().getThreatList(); + std::vector target_list; + for(std::list::iterator itr = t_list.begin(); itr!= t_list.end(); ++itr) + { + target = Unit::GetUnit(*m_creature, (*itr)->getUnitGuid()); + if(target && target->GetDistance2d(m_creature) > 5) + target_list.push_back(target); + target = NULL; + } + if(target_list.size()) + target = *(target_list.begin()+rand()%target_list.size()); + + DoCast(target, SPELL_BERSERKER_CHARGE); + ChargeTimer = 20000; + } else ChargeTimer -= diff; + } + else + { + if( (m_creature->GetHealth()*100)/m_creature->GetMaxHealth() < 25) + { + Creature *pMidnight = (Creature*)Unit::GetUnit(*m_creature, Midnight); + if(pMidnight && pMidnight->GetTypeId() == TYPEID_UNIT) + { + ((boss_midnightAI*)(pMidnight->AI()))->Mount(m_creature); + m_creature->SetHealth(pMidnight->GetHealth()); + } + } + } + + DoMeleeAttackIfReady(); + } + + void SpellHit(Unit *source, const SpellEntry *spell) + { + if(spell->Mechanic == MECHANIC_DISARM) + { + DoYell(SAY_DISARMED, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_DISARMED); + } + } +}; + +void boss_midnightAI::SetMidnight(Creature *pAttumen, uint64 value) +{ + ((boss_attumenAI*)pAttumen->AI())->Midnight = value; +} + +CreatureAI* GetAI_boss_attumen(Creature *_Creature) +{ + return new boss_attumenAI (_Creature); +} + +void AddSC_boss_attumen() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_attumen"; + newscript->GetAI = GetAI_boss_attumen; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="boss_midnight"; + newscript->GetAI = GetAI_boss_midnight; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/karazhan/boss_moroes.cpp b/src/bindings/scripts/scripts/zone/karazhan/boss_moroes.cpp index 538de015315..1e90ff0c8a7 100644 --- a/src/bindings/scripts/scripts/zone/karazhan/boss_moroes.cpp +++ b/src/bindings/scripts/scripts/zone/karazhan/boss_moroes.cpp @@ -1,868 +1,868 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Moroes -SD%Complete: 100 -SDComment: -SDCategory: Karazhan -EndScriptData */ - -#include "precompiled.h" -#include "def_karazhan.h" - -#define SAY_AGGRO "Hmm, unannounced visitors? Preparations must be made." -#define SOUND_AGGRO 9211 - -#define SAY_SPECIAL_1 "Now, where was I? Oh yes..." -#define SOUND_SPECIAL_1 9215 - -#define SAY_SPECIAL_2 "You rang?" -#define SOUND_SPECIAL_2 9316 - -#define SAY_KILL_1 "One more for dinner this evening" -#define SOUND_KILL_1 9214 - -#define SAY_KILL_2 "Time... Never enough time." -#define SOUND_KILL_2 9314 - -#define SAY_KILL_3 "I've gone and made a mess." -#define SOUND_KILL_3 9315 - -#define SAY_DEATH "How terribly clumsy of me..." -#define SOUND_DEATH 9213 - -#define SPELL_VANISH 24699 -#define SPELL_GARROTE 37066 -#define SPELL_BLIND 34654 -#define SPELL_GOUGE 28456 -#define SPELL_ENRAGE 37023 - -#define ORIENT 4.5784 -#define POS_Z 81.73 - -float Locations[4][2]= -{ - {-10976.2793, -1878.1736}, - {-10979.7587, -1877.8706}, - {-10985.6650, -1877.2458}, - {-10989.1367, -1876.8309}, -}; - -const uint32 Adds[6]= -{ - 17007, - 19872, - 19873, - 19874, - 19875, - 19876, -}; - -struct MANGOS_DLL_DECL boss_moroesAI : public ScriptedAI -{ - boss_moroesAI(Creature *c) : ScriptedAI(c) - { - FirstTime = true; - pInstance = ((ScriptedInstance*)c->GetInstanceData()); - Reset(); - } - - ScriptedInstance *pInstance; - - uint64 AddGUID[4]; - - uint32 Vanish_Timer; - uint32 Blind_Timer; - uint32 Gouge_Timer; - uint32 Wait_Timer; - uint32 CheckAdds_Timer; - uint32 AddId[4]; - - bool FirstTime; - bool InVanish; - bool Enrage; - - void Reset() - { - Vanish_Timer = 30000; - Blind_Timer = 35000; - Gouge_Timer = 23000; - Wait_Timer = 0; - CheckAdds_Timer = 5000; - - Enrage = false; - InVanish = false; - - SpawnAdds(); - - m_creature->setFaction(16); - m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); - - if(pInstance) - pInstance->SetData(DATA_MOROES_EVENT, NOT_STARTED); - } - - void StartEvent() - { - if(!pInstance) - return; - - if(pInstance) - pInstance->SetData(DATA_MOROES_EVENT, IN_PROGRESS); - } - - void Aggro(Unit* who) - { - StartEvent(); - - DoYell(SAY_AGGRO, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_AGGRO); - AddsAttack(); - } - - void KilledUnit(Unit* victim) - { - switch (rand()%3) - { - case 0: - DoYell(SAY_KILL_1, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_KILL_1); - break; - case 1: - DoYell(SAY_KILL_2, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_KILL_2); - break; - case 2: - DoYell(SAY_KILL_3, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_KILL_3); - break; - } - } - - void JustDied(Unit* victim) - { - DoYell(SAY_DEATH, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_DEATH); - - if(pInstance) - pInstance->SetData(DATA_MOROES_EVENT, DONE); - - DeSpawnAdds(); - } - - uint8 CheckAdd(uint64 guid) - { - Unit* pUnit = Unit::GetUnit((*m_creature), guid); - if(pUnit) - { - if(!pUnit->isAlive()) - return 1; // Exists but is dead - else - return 2; // Exists and is alive - } - - return 0; // Does not exist - } - - void SpawnAdds() - { - Creature *pCreature = NULL; - - if(FirstTime) - { - std::vector AddList; - - for(uint8 i = 0; i < 6; ++i) - AddList.push_back(Adds[i]); - - while(AddList.size() > 4) - AddList.erase((AddList.begin())+(rand()%AddList.size())); - - uint8 j = 0; - for(std::vector::iterator itr = AddList.begin(); itr != AddList.end(); ++itr) - { - uint32 entry = *itr; - - pCreature = m_creature->SummonCreature(entry, Locations[j][0], Locations[j][1], POS_Z, ORIENT, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 10000); - if(pCreature) - { - AddGUID[j] = pCreature->GetGUID(); - AddId[j] = entry; - } - ++j; - } - - FirstTime = false; - } - else - { - for(uint8 i = 0; i < 5; ++i) - { - switch(CheckAdd(AddGUID[i])) - { - case 0: - pCreature = m_creature->SummonCreature(AddId[i], Locations[i][0], Locations[i][1], POS_Z, ORIENT, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 10000); - if(pCreature) - AddGUID[i] = pCreature->GetGUID(); - break; - case 1: - pCreature = ((Creature*)Unit::GetUnit((*m_creature), AddGUID[i])); - if(pCreature) - { - pCreature->Respawn(); - pCreature->AI()->EnterEvadeMode(); - } - break; - case 2: - pCreature = ((Creature*)Unit::GetUnit((*m_creature), AddGUID[i])); - if(!pCreature->IsInEvadeMode()) - pCreature->AI()->EnterEvadeMode(); - break; - } - } - } - } - - void DeSpawnAdds() - { - for(uint8 i = 0; i < 4 ; ++i) - { - Unit* Temp = NULL; - if(AddGUID[i]) - { - Temp = Unit::GetUnit((*m_creature),AddGUID[i]); - if(Temp && Temp->isAlive()) - Temp->DealDamage(Temp, Temp->GetMaxHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); - } - } - } - - void AddsAttack() - { - for(uint8 i = 0; i < 4; ++i) - { - Unit* Temp = NULL; - if(AddGUID[i]) - { - Temp = Unit::GetUnit((*m_creature),AddGUID[i]); - if(Temp && Temp->isAlive()) - ((Creature*)Temp)->AI()->AttackStart(m_creature->getVictim()); - else - EnterEvadeMode(); - } - } - } - - void UpdateAI(const uint32 diff) - { - if(!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - if(pInstance && !pInstance->GetData(DATA_MOROES_EVENT)) - EnterEvadeMode(); - - if(!Enrage && m_creature->GetHealth()*100 / m_creature->GetMaxHealth() < 30) - { - DoCast(m_creature, SPELL_ENRAGE); - Enrage = true; - } - - if(CheckAdds_Timer < diff) - { - for(uint8 i = 0; i < 4; ++i) - { - Unit* Temp = NULL; - if(AddGUID[i]) - { - Temp = Unit::GetUnit((*m_creature),AddGUID[i]); - if(Temp && Temp->isAlive()) - if(!Temp->SelectHostilTarget() || !Temp->getVictim() ) - ((Creature*)Temp)->AI()->AttackStart(m_creature->getVictim()); - } - } - CheckAdds_Timer = 5000; - }else CheckAdds_Timer -= diff; - - //Cast Vanish, then Garrote random victim - if(Vanish_Timer < diff) - { - m_creature->setFaction(35); - m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); - DoCast(m_creature, SPELL_VANISH); - InVanish = true; - Vanish_Timer = 30000; - Wait_Timer = 5000; - }else Vanish_Timer -= diff; - - if(InVanish) - { - if(Wait_Timer < diff) - { - switch(rand()%2) - { - case 0: - DoYell(SAY_SPECIAL_1, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_SPECIAL_1); - break; - case 1: - DoYell(SAY_SPECIAL_2, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_SPECIAL_2); - break; - } - - Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0); - if(target) - target->CastSpell(target, SPELL_GARROTE,true); - - m_creature->setFaction(16); - m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); - m_creature->AI()->AttackStart(m_creature->getVictim()); - InVanish = false; - }else Wait_Timer -= diff; - } - - //Blind highest aggro, and attack second highest - if(Gouge_Timer < diff) - { - DoCast(m_creature->getVictim(), SPELL_GOUGE); - if(m_creature->getThreatManager().getThreat(m_creature->getVictim())) - m_creature->getThreatManager().modifyThreatPercent(m_creature->getVictim(),-100); - Gouge_Timer = 40000; - }else Gouge_Timer -= diff; - - if(Blind_Timer < diff) - { - Unit* target = NULL; - std::list t_list = m_creature->getThreatManager().getThreatList(); - - if(t_list.empty()) - return; - - std::vector target_list; - for(std::list::iterator itr = t_list.begin(); itr!= t_list.end(); ++itr) - { - target = Unit::GetUnit(*m_creature, (*itr)->getUnitGuid()); - if(target && target->GetDistance2d(m_creature) < 5) - target_list.push_back(target); - } - if(target_list.size()) - target = *(target_list.begin()+rand()%target_list.size()); - - if(target) - DoCast(target, SPELL_BLIND); - - Blind_Timer = 40000; - }else Blind_Timer -= diff; - - if(!InVanish) - DoMeleeAttackIfReady(); - } -}; - -struct MANGOS_DLL_DECL boss_moroes_guestAI : public ScriptedAI -{ - ScriptedInstance* pInstance; - - uint64 GuestGUID[4]; - - boss_moroes_guestAI(Creature* c) : ScriptedAI(c) - { - for(uint8 i = 0; i < 4; ++i) - GuestGUID[i] = 0; - - pInstance = ((ScriptedInstance*)c->GetInstanceData()); - Reset(); - } - - void Reset() - { - if(pInstance) - pInstance->SetData(DATA_MOROES_EVENT, NOT_STARTED); - } - - void Aggro(Unit* who) {} - - void AcquireGUID() - { - if(!pInstance) - return; - - GuestGUID[0] = pInstance->GetData64(DATA_MOROES); - Creature* Moroes = ((Creature*)Unit::GetUnit((*m_creature), GuestGUID[0])); - if(Moroes) - { - for(uint8 i = 0; i < 3; ++i) - { - uint64 GUID = ((boss_moroesAI*)Moroes->AI())->AddGUID[i]; - if(GUID && GUID != m_creature->GetGUID()) - GuestGUID[i+1] = GUID; - } - } - } - - Unit* SelectTarget() - { - uint64 TempGUID = GuestGUID[rand()%5]; - if(TempGUID) - { - Unit* pUnit = Unit::GetUnit((*m_creature), TempGUID); - if(pUnit && pUnit->isAlive()) - return pUnit; - } - - return m_creature; - } - - void UpdateAI(const uint32 diff) - { - if(pInstance && !pInstance->GetData(DATA_MOROES_EVENT)) - EnterEvadeMode(); - - DoMeleeAttackIfReady(); - } -}; - -#define SPELL_MANABURN 29405 -#define SPELL_MINDFLY 29570 -#define SPELL_SWPAIN 34441 -#define SPELL_SHADOWFORM 29406 - -struct MANGOS_DLL_DECL boss_baroness_dorothea_millstipeAI : public boss_moroes_guestAI -{ - //Shadow Priest - boss_baroness_dorothea_millstipeAI(Creature *c) : boss_moroes_guestAI(c) {} - - uint32 ManaBurn_Timer; - uint32 MindFlay_Timer; - uint32 ShadowWordPain_Timer; - - void Reset() - { - ManaBurn_Timer = 7000; - MindFlay_Timer = 1000; - ShadowWordPain_Timer = 6000; - - DoCast(m_creature,SPELL_SHADOWFORM, true); - - boss_moroes_guestAI::Reset(); - } - - void UpdateAI(const uint32 diff) - { - if(!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - boss_moroes_guestAI::UpdateAI(diff); - - if(MindFlay_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_MINDFLY); - MindFlay_Timer = 12000; //3sec channeled - }else MindFlay_Timer -= diff; - - if(ManaBurn_Timer < diff) - { - Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0); - if(target && (target->getPowerType() == POWER_MANA)) - DoCast(target,SPELL_MANABURN); - ManaBurn_Timer = 5000; //3 sec cast - }else ManaBurn_Timer -= diff; - - if(ShadowWordPain_Timer < diff) - { - Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0); - if(target) - { - DoCast(target,SPELL_SWPAIN); - ShadowWordPain_Timer = 7000; - } - }else ShadowWordPain_Timer -= diff; - } -}; - -#define SPELL_HAMMEROFJUSTICE 13005 -#define SPELL_JUDGEMENTOFCOMMAND 29386 -#define SPELL_SEALOFCOMMAND 29385 - -struct MANGOS_DLL_DECL boss_baron_rafe_dreugerAI : public boss_moroes_guestAI -{ - //Retr Pally - boss_baron_rafe_dreugerAI(Creature *c) : boss_moroes_guestAI(c){} - - uint32 HammerOfJustice_Timer; - uint32 SealOfCommand_Timer; - uint32 JudgementOfCommand_Timer; - - void Reset() - { - HammerOfJustice_Timer = 1000; - SealOfCommand_Timer = 7000; - JudgementOfCommand_Timer = SealOfCommand_Timer + 29000; - - boss_moroes_guestAI::Reset(); - } - - void UpdateAI(const uint32 diff) - { - if(!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - boss_moroes_guestAI::UpdateAI(diff); - - if(SealOfCommand_Timer < diff) - { - DoCast(m_creature,SPELL_SEALOFCOMMAND); - SealOfCommand_Timer = 32000; - JudgementOfCommand_Timer = 29000; - }else SealOfCommand_Timer -= diff; - - if(JudgementOfCommand_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_JUDGEMENTOFCOMMAND); - JudgementOfCommand_Timer = SealOfCommand_Timer + 29000; - }else JudgementOfCommand_Timer -= diff; - - if(HammerOfJustice_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_HAMMEROFJUSTICE); - HammerOfJustice_Timer = 12000; - }else HammerOfJustice_Timer -= diff; - } -}; - -#define SPELL_DISPELMAGIC 15090 //Self or other guest+Moroes -#define SPELL_GREATERHEAL 29564 //Self or other guest+Moroes -#define SPELL_HOLYFIRE 29563 -#define SPELL_PWSHIELD 29408 - -struct MANGOS_DLL_DECL boss_lady_catriona_von_indiAI : public boss_moroes_guestAI -{ - //Holy Priest - boss_lady_catriona_von_indiAI(Creature *c) : boss_moroes_guestAI(c) {} - - uint32 DispelMagic_Timer; - uint32 GreaterHeal_Timer; - uint32 HolyFire_Timer; - uint32 PowerWordShield_Timer; - - void Reset() - { - DispelMagic_Timer = 11000; - GreaterHeal_Timer = 1500; - HolyFire_Timer = 5000; - PowerWordShield_Timer = 1000; - - AcquireGUID(); - - boss_moroes_guestAI::Reset(); - } - - void UpdateAI(const uint32 diff) - { - if(!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - boss_moroes_guestAI::UpdateAI(diff); - - if(PowerWordShield_Timer < diff) - { - DoCast(m_creature,SPELL_PWSHIELD); - PowerWordShield_Timer = 15000; - }else PowerWordShield_Timer -= diff; - - if(GreaterHeal_Timer < diff) - { - Unit* target = SelectTarget(); - - DoCast(target, SPELL_GREATERHEAL); - GreaterHeal_Timer = 17000; - }else GreaterHeal_Timer -= diff; - - if(HolyFire_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_HOLYFIRE); - HolyFire_Timer = 22000; - }else HolyFire_Timer -= diff; - - if(DispelMagic_Timer < diff) - { - if(rand()%2) - { - Unit* target = SelectTarget(); - - DoCast(target, SPELL_DISPELMAGIC); - } - else - DoCast(SelectUnit(SELECT_TARGET_RANDOM, 0), SPELL_DISPELMAGIC); - - DispelMagic_Timer = 25000; - }else DispelMagic_Timer -= diff; - } -}; - -#define SPELL_CLEANSE 29380 //Self or other guest+Moroes -#define SPELL_GREATERBLESSOFMIGHT 29381 //Self or other guest+Moroes -#define SPELL_HOLYLIGHT 29562 //Self or other guest+Moroes -#define SPELL_DIVINESHIELD 41367 - -struct MANGOS_DLL_DECL boss_lady_keira_berrybuckAI : public boss_moroes_guestAI -{ - //Holy Pally - boss_lady_keira_berrybuckAI(Creature *c) : boss_moroes_guestAI(c) {} - - uint32 Cleanse_Timer; - uint32 GreaterBless_Timer; - uint32 HolyLight_Timer; - uint32 DivineShield_Timer; - - void Reset() - { - Cleanse_Timer = 13000; - GreaterBless_Timer = 1000; - HolyLight_Timer = 7000; - DivineShield_Timer = 31000; - - AcquireGUID(); - - boss_moroes_guestAI::Reset(); - } - - void UpdateAI(const uint32 diff) - { - if(!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - boss_moroes_guestAI::UpdateAI(diff); - - if(DivineShield_Timer < diff) - { - DoCast(m_creature,SPELL_DIVINESHIELD); - DivineShield_Timer = 31000; - }else DivineShield_Timer -= diff; - - if(HolyLight_Timer < diff) - { - Unit* target = SelectTarget(); - - DoCast(target, SPELL_HOLYLIGHT); - HolyLight_Timer = 10000; - }else HolyLight_Timer -= diff; - - if(GreaterBless_Timer < diff) - { - Unit* target = SelectTarget(); - - DoCast(target, SPELL_GREATERBLESSOFMIGHT); - - GreaterBless_Timer = 50000; - }else GreaterBless_Timer -= diff; - - if(Cleanse_Timer < diff) - { - Unit* target = SelectTarget(); - - DoCast(target, SPELL_CLEANSE); - - Cleanse_Timer = 10000; - }else Cleanse_Timer -= diff; - } -}; - -#define SPELL_HAMSTRING 9080 -#define SPELL_MORTALSTRIKE 29572 -#define SPELL_WHIRLWIND 29573 - -struct MANGOS_DLL_DECL boss_lord_robin_darisAI : public boss_moroes_guestAI -{ - //Arms Warr - boss_lord_robin_darisAI(Creature *c) : boss_moroes_guestAI(c) {} - - uint32 Hamstring_Timer; - uint32 MortalStrike_Timer; - uint32 WhirlWind_Timer; - - void Reset() - { - Hamstring_Timer = 7000; - MortalStrike_Timer = 10000; - WhirlWind_Timer = 21000; - - boss_moroes_guestAI::Reset(); - } - - void UpdateAI(const uint32 diff) - { - if(!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - boss_moroes_guestAI::UpdateAI(diff); - - if(Hamstring_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_HAMSTRING); - Hamstring_Timer = 12000; - }else Hamstring_Timer -= diff; - - if(MortalStrike_Timer < diff) - { - DoCast(m_creature->getVictim(), SPELL_MORTALSTRIKE); - MortalStrike_Timer = 18000; - }else MortalStrike_Timer -= diff; - - if(WhirlWind_Timer < diff) - { - DoCast(m_creature,SPELL_WHIRLWIND); - WhirlWind_Timer = 21000; - }else WhirlWind_Timer -= diff; - } -}; - -#define SPELL_DISARM 8379 -#define SPELL_HEROICSTRIKE 29567 -#define SPELL_SHIELDBASH 11972 -#define SPELL_SHIELDWALL 29390 - -struct MANGOS_DLL_DECL boss_lord_crispin_ferenceAI : public boss_moroes_guestAI -{ - //Arms Warr - boss_lord_crispin_ferenceAI(Creature *c) : boss_moroes_guestAI(c) {} - - uint32 Disarm_Timer; - uint32 HeroicStrike_Timer; - uint32 ShieldBash_Timer; - uint32 ShieldWall_Timer; - - void Reset() - { - Disarm_Timer = 6000; - HeroicStrike_Timer = 10000; - ShieldBash_Timer = 8000; - ShieldWall_Timer = 4000; - - boss_moroes_guestAI::Reset(); - } - - void UpdateAI(const uint32 diff) - { - if(!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - boss_moroes_guestAI::UpdateAI(diff); - - if(Disarm_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_DISARM); - Disarm_Timer = 12000; - }else Disarm_Timer -= diff; - - if(HeroicStrike_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_HEROICSTRIKE); - HeroicStrike_Timer = 10000; - }else HeroicStrike_Timer -= diff; - - if(ShieldBash_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_SHIELDBASH); - ShieldBash_Timer = 13000; - }else ShieldBash_Timer -= diff; - - if(ShieldWall_Timer < diff) - { - DoCast(m_creature,SPELL_SHIELDWALL); - ShieldWall_Timer = 21000; - }else ShieldWall_Timer -= diff; - } -}; - -CreatureAI* GetAI_boss_moroes(Creature *_Creature) -{ - return new boss_moroesAI (_Creature); -} - -CreatureAI* GetAI_baroness_dorothea_millstipe(Creature *_Creature) -{ - return new boss_baroness_dorothea_millstipeAI (_Creature); -} - -CreatureAI* GetAI_baron_rafe_dreuger(Creature *_Creature) -{ - return new boss_baron_rafe_dreugerAI (_Creature); -} - -CreatureAI* GetAI_lady_catriona_von_indi(Creature *_Creature) -{ - return new boss_lady_catriona_von_indiAI (_Creature); -} - -CreatureAI* GetAI_lady_keira_berrybuck(Creature *_Creature) -{ - return new boss_lady_keira_berrybuckAI (_Creature); -} - -CreatureAI* GetAI_lord_robin_daris(Creature *_Creature) -{ - return new boss_lord_robin_darisAI (_Creature); -} - -CreatureAI* GetAI_lord_crispin_ference(Creature *_Creature) -{ - return new boss_lord_crispin_ferenceAI (_Creature); -} - -void AddSC_boss_moroes() -{ - Script *newscript; - - newscript = new Script; - newscript->Name="boss_moroes"; - newscript->GetAI = GetAI_boss_moroes; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="boss_baroness_dorothea_millstipe"; - newscript->GetAI = GetAI_baroness_dorothea_millstipe; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="boss_baron_rafe_dreuger"; - newscript->GetAI = GetAI_baron_rafe_dreuger; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="boss_lady_catriona_von_indi"; - newscript->GetAI = GetAI_lady_catriona_von_indi; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="boss_lady_keira_berrybuck"; - newscript->GetAI = GetAI_lady_keira_berrybuck; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="boss_lord_robin_daris"; - newscript->GetAI = GetAI_lord_robin_daris; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="boss_lord_crispin_ference"; - newscript->GetAI = GetAI_lord_crispin_ference; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Moroes +SD%Complete: 100 +SDComment: +SDCategory: Karazhan +EndScriptData */ + +#include "precompiled.h" +#include "def_karazhan.h" + +#define SAY_AGGRO "Hmm, unannounced visitors? Preparations must be made." +#define SOUND_AGGRO 9211 + +#define SAY_SPECIAL_1 "Now, where was I? Oh yes..." +#define SOUND_SPECIAL_1 9215 + +#define SAY_SPECIAL_2 "You rang?" +#define SOUND_SPECIAL_2 9316 + +#define SAY_KILL_1 "One more for dinner this evening" +#define SOUND_KILL_1 9214 + +#define SAY_KILL_2 "Time... Never enough time." +#define SOUND_KILL_2 9314 + +#define SAY_KILL_3 "I've gone and made a mess." +#define SOUND_KILL_3 9315 + +#define SAY_DEATH "How terribly clumsy of me..." +#define SOUND_DEATH 9213 + +#define SPELL_VANISH 24699 +#define SPELL_GARROTE 37066 +#define SPELL_BLIND 34654 +#define SPELL_GOUGE 28456 +#define SPELL_ENRAGE 37023 + +#define ORIENT 4.5784 +#define POS_Z 81.73 + +float Locations[4][2]= +{ + {-10976.2793, -1878.1736}, + {-10979.7587, -1877.8706}, + {-10985.6650, -1877.2458}, + {-10989.1367, -1876.8309}, +}; + +const uint32 Adds[6]= +{ + 17007, + 19872, + 19873, + 19874, + 19875, + 19876, +}; + +struct MANGOS_DLL_DECL boss_moroesAI : public ScriptedAI +{ + boss_moroesAI(Creature *c) : ScriptedAI(c) + { + FirstTime = true; + pInstance = ((ScriptedInstance*)c->GetInstanceData()); + Reset(); + } + + ScriptedInstance *pInstance; + + uint64 AddGUID[4]; + + uint32 Vanish_Timer; + uint32 Blind_Timer; + uint32 Gouge_Timer; + uint32 Wait_Timer; + uint32 CheckAdds_Timer; + uint32 AddId[4]; + + bool FirstTime; + bool InVanish; + bool Enrage; + + void Reset() + { + Vanish_Timer = 30000; + Blind_Timer = 35000; + Gouge_Timer = 23000; + Wait_Timer = 0; + CheckAdds_Timer = 5000; + + Enrage = false; + InVanish = false; + + SpawnAdds(); + + m_creature->setFaction(16); + m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + + if(pInstance) + pInstance->SetData(DATA_MOROES_EVENT, NOT_STARTED); + } + + void StartEvent() + { + if(!pInstance) + return; + + if(pInstance) + pInstance->SetData(DATA_MOROES_EVENT, IN_PROGRESS); + } + + void Aggro(Unit* who) + { + StartEvent(); + + DoYell(SAY_AGGRO, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_AGGRO); + AddsAttack(); + } + + void KilledUnit(Unit* victim) + { + switch (rand()%3) + { + case 0: + DoYell(SAY_KILL_1, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_KILL_1); + break; + case 1: + DoYell(SAY_KILL_2, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_KILL_2); + break; + case 2: + DoYell(SAY_KILL_3, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_KILL_3); + break; + } + } + + void JustDied(Unit* victim) + { + DoYell(SAY_DEATH, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_DEATH); + + if(pInstance) + pInstance->SetData(DATA_MOROES_EVENT, DONE); + + DeSpawnAdds(); + } + + uint8 CheckAdd(uint64 guid) + { + Unit* pUnit = Unit::GetUnit((*m_creature), guid); + if(pUnit) + { + if(!pUnit->isAlive()) + return 1; // Exists but is dead + else + return 2; // Exists and is alive + } + + return 0; // Does not exist + } + + void SpawnAdds() + { + Creature *pCreature = NULL; + + if(FirstTime) + { + std::vector AddList; + + for(uint8 i = 0; i < 6; ++i) + AddList.push_back(Adds[i]); + + while(AddList.size() > 4) + AddList.erase((AddList.begin())+(rand()%AddList.size())); + + uint8 i = 0; + for(std::vector::iterator itr = AddList.begin(); itr != AddList.end(); ++itr) + { + uint32 entry = *itr; + + pCreature = m_creature->SummonCreature(entry, Locations[i][0], Locations[i][1], POS_Z, ORIENT, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 10000); + if(pCreature) + { + AddGUID[i] = pCreature->GetGUID(); + AddId[i] = entry; + } + ++i; + } + + FirstTime = false; + } + else + { + for(uint8 i = 0; i < 5; ++i) + { + switch(CheckAdd(AddGUID[i])) + { + case 0: + pCreature = m_creature->SummonCreature(AddId[i], Locations[i][0], Locations[i][1], POS_Z, ORIENT, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 10000); + if(pCreature) + AddGUID[i] = pCreature->GetGUID(); + break; + case 1: + pCreature = ((Creature*)Unit::GetUnit((*m_creature), AddGUID[i])); + if(pCreature) + { + pCreature->Respawn(); + pCreature->AI()->EnterEvadeMode(); + } + break; + case 2: + pCreature = ((Creature*)Unit::GetUnit((*m_creature), AddGUID[i])); + if(!pCreature->IsInEvadeMode()) + pCreature->AI()->EnterEvadeMode(); + break; + } + } + } + } + + void DeSpawnAdds() + { + for(uint8 i = 0; i < 4 ; ++i) + { + Unit* Temp = NULL; + if(AddGUID[i]) + { + Temp = Unit::GetUnit((*m_creature),AddGUID[i]); + if(Temp && Temp->isAlive()) + Temp->DealDamage(Temp, Temp->GetMaxHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); + } + } + } + + void AddsAttack() + { + for(uint8 i = 0; i < 4; ++i) + { + Unit* Temp = NULL; + if(AddGUID[i]) + { + Temp = Unit::GetUnit((*m_creature),AddGUID[i]); + if(Temp && Temp->isAlive()) + ((Creature*)Temp)->AI()->AttackStart(m_creature->getVictim()); + else + EnterEvadeMode(); + } + } + } + + void UpdateAI(const uint32 diff) + { + if(!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + if(pInstance && !pInstance->GetData(DATA_MOROES_EVENT)) + EnterEvadeMode(); + + if(!Enrage && m_creature->GetHealth()*100 / m_creature->GetMaxHealth() < 30) + { + DoCast(m_creature, SPELL_ENRAGE); + Enrage = true; + } + + if(CheckAdds_Timer < diff) + { + for(uint8 i = 0; i < 4; ++i) + { + Unit* Temp = NULL; + if(AddGUID[i]) + { + Temp = Unit::GetUnit((*m_creature),AddGUID[i]); + if(Temp && Temp->isAlive()) + if(!Temp->SelectHostilTarget() || !Temp->getVictim() ) + ((Creature*)Temp)->AI()->AttackStart(m_creature->getVictim()); + } + } + CheckAdds_Timer = 5000; + }else CheckAdds_Timer -= diff; + + //Cast Vanish, then Garrote random victim + if(Vanish_Timer < diff) + { + m_creature->setFaction(35); + m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + DoCast(m_creature, SPELL_VANISH); + InVanish = true; + Vanish_Timer = 30000; + Wait_Timer = 5000; + }else Vanish_Timer -= diff; + + if(InVanish) + { + if(Wait_Timer < diff) + { + switch(rand()%2) + { + case 0: + DoYell(SAY_SPECIAL_1, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_SPECIAL_1); + break; + case 1: + DoYell(SAY_SPECIAL_2, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_SPECIAL_2); + break; + } + + Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0); + if(target) + target->CastSpell(target, SPELL_GARROTE,true); + + m_creature->setFaction(16); + m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + m_creature->AI()->AttackStart(m_creature->getVictim()); + InVanish = false; + }else Wait_Timer -= diff; + } + + //Blind highest aggro, and attack second highest + if(Gouge_Timer < diff) + { + DoCast(m_creature->getVictim(), SPELL_GOUGE); + if(m_creature->getThreatManager().getThreat(m_creature->getVictim())) + m_creature->getThreatManager().modifyThreatPercent(m_creature->getVictim(),-100); + Gouge_Timer = 40000; + }else Gouge_Timer -= diff; + + if(Blind_Timer < diff) + { + Unit* target = NULL; + std::list t_list = m_creature->getThreatManager().getThreatList(); + + if(t_list.empty()) + return; + + std::vector target_list; + for(std::list::iterator itr = t_list.begin(); itr!= t_list.end(); ++itr) + { + target = Unit::GetUnit(*m_creature, (*itr)->getUnitGuid()); + if(target && target->GetDistance2d(m_creature) < 5) + target_list.push_back(target); + } + if(target_list.size()) + target = *(target_list.begin()+rand()%target_list.size()); + + if(target) + DoCast(target, SPELL_BLIND); + + Blind_Timer = 40000; + }else Blind_Timer -= diff; + + if(!InVanish) + DoMeleeAttackIfReady(); + } +}; + +struct MANGOS_DLL_DECL boss_moroes_guestAI : public ScriptedAI +{ + ScriptedInstance* pInstance; + + uint64 GuestGUID[4]; + + boss_moroes_guestAI(Creature* c) : ScriptedAI(c) + { + for(uint8 i = 0; i < 4; ++i) + GuestGUID[i] = 0; + + pInstance = ((ScriptedInstance*)c->GetInstanceData()); + Reset(); + } + + void Reset() + { + if(pInstance) + pInstance->SetData(DATA_MOROES_EVENT, NOT_STARTED); + } + + void Aggro(Unit* who) {} + + void AcquireGUID() + { + if(!pInstance) + return; + + GuestGUID[0] = pInstance->GetData64(DATA_MOROES); + Creature* Moroes = ((Creature*)Unit::GetUnit((*m_creature), GuestGUID[0])); + if(Moroes) + { + for(uint8 i = 0; i < 3; ++i) + { + uint64 GUID = ((boss_moroesAI*)Moroes->AI())->AddGUID[i]; + if(GUID && GUID != m_creature->GetGUID()) + GuestGUID[i+1] = GUID; + } + } + } + + Unit* SelectTarget() + { + uint64 TempGUID = GuestGUID[rand()%5]; + if(TempGUID) + { + Unit* pUnit = Unit::GetUnit((*m_creature), TempGUID); + if(pUnit && pUnit->isAlive()) + return pUnit; + } + + return m_creature; + } + + void UpdateAI(const uint32 diff) + { + if(pInstance && !pInstance->GetData(DATA_MOROES_EVENT)) + EnterEvadeMode(); + + DoMeleeAttackIfReady(); + } +}; + +#define SPELL_MANABURN 29405 +#define SPELL_MINDFLY 29570 +#define SPELL_SWPAIN 34441 +#define SPELL_SHADOWFORM 29406 + +struct MANGOS_DLL_DECL boss_baroness_dorothea_millstipeAI : public boss_moroes_guestAI +{ + //Shadow Priest + boss_baroness_dorothea_millstipeAI(Creature *c) : boss_moroes_guestAI(c) {} + + uint32 ManaBurn_Timer; + uint32 MindFlay_Timer; + uint32 ShadowWordPain_Timer; + + void Reset() + { + ManaBurn_Timer = 7000; + MindFlay_Timer = 1000; + ShadowWordPain_Timer = 6000; + + DoCast(m_creature,SPELL_SHADOWFORM, true); + + boss_moroes_guestAI::Reset(); + } + + void UpdateAI(const uint32 diff) + { + if(!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + boss_moroes_guestAI::UpdateAI(diff); + + if(MindFlay_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_MINDFLY); + MindFlay_Timer = 12000; //3sec channeled + }else MindFlay_Timer -= diff; + + if(ManaBurn_Timer < diff) + { + Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0); + if(target && (target->getPowerType() == POWER_MANA)) + DoCast(target,SPELL_MANABURN); + ManaBurn_Timer = 5000; //3 sec cast + }else ManaBurn_Timer -= diff; + + if(ShadowWordPain_Timer < diff) + { + Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0); + if(target) + { + DoCast(target,SPELL_SWPAIN); + ShadowWordPain_Timer = 7000; + } + }else ShadowWordPain_Timer -= diff; + } +}; + +#define SPELL_HAMMEROFJUSTICE 13005 +#define SPELL_JUDGEMENTOFCOMMAND 29386 +#define SPELL_SEALOFCOMMAND 29385 + +struct MANGOS_DLL_DECL boss_baron_rafe_dreugerAI : public boss_moroes_guestAI +{ + //Retr Pally + boss_baron_rafe_dreugerAI(Creature *c) : boss_moroes_guestAI(c){} + + uint32 HammerOfJustice_Timer; + uint32 SealOfCommand_Timer; + uint32 JudgementOfCommand_Timer; + + void Reset() + { + HammerOfJustice_Timer = 1000; + SealOfCommand_Timer = 7000; + JudgementOfCommand_Timer = SealOfCommand_Timer + 29000; + + boss_moroes_guestAI::Reset(); + } + + void UpdateAI(const uint32 diff) + { + if(!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + boss_moroes_guestAI::UpdateAI(diff); + + if(SealOfCommand_Timer < diff) + { + DoCast(m_creature,SPELL_SEALOFCOMMAND); + SealOfCommand_Timer = 32000; + JudgementOfCommand_Timer = 29000; + }else SealOfCommand_Timer -= diff; + + if(JudgementOfCommand_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_JUDGEMENTOFCOMMAND); + JudgementOfCommand_Timer = SealOfCommand_Timer + 29000; + }else JudgementOfCommand_Timer -= diff; + + if(HammerOfJustice_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_HAMMEROFJUSTICE); + HammerOfJustice_Timer = 12000; + }else HammerOfJustice_Timer -= diff; + } +}; + +#define SPELL_DISPELMAGIC 15090 //Self or other guest+Moroes +#define SPELL_GREATERHEAL 29564 //Self or other guest+Moroes +#define SPELL_HOLYFIRE 29563 +#define SPELL_PWSHIELD 29408 + +struct MANGOS_DLL_DECL boss_lady_catriona_von_indiAI : public boss_moroes_guestAI +{ + //Holy Priest + boss_lady_catriona_von_indiAI(Creature *c) : boss_moroes_guestAI(c) {} + + uint32 DispelMagic_Timer; + uint32 GreaterHeal_Timer; + uint32 HolyFire_Timer; + uint32 PowerWordShield_Timer; + + void Reset() + { + DispelMagic_Timer = 11000; + GreaterHeal_Timer = 1500; + HolyFire_Timer = 5000; + PowerWordShield_Timer = 1000; + + AcquireGUID(); + + boss_moroes_guestAI::Reset(); + } + + void UpdateAI(const uint32 diff) + { + if(!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + boss_moroes_guestAI::UpdateAI(diff); + + if(PowerWordShield_Timer < diff) + { + DoCast(m_creature,SPELL_PWSHIELD); + PowerWordShield_Timer = 15000; + }else PowerWordShield_Timer -= diff; + + if(GreaterHeal_Timer < diff) + { + Unit* target = SelectTarget(); + + DoCast(target, SPELL_GREATERHEAL); + GreaterHeal_Timer = 17000; + }else GreaterHeal_Timer -= diff; + + if(HolyFire_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_HOLYFIRE); + HolyFire_Timer = 22000; + }else HolyFire_Timer -= diff; + + if(DispelMagic_Timer < diff) + { + if(rand()%2) + { + Unit* target = SelectTarget(); + + DoCast(target, SPELL_DISPELMAGIC); + } + else + DoCast(SelectUnit(SELECT_TARGET_RANDOM, 0), SPELL_DISPELMAGIC); + + DispelMagic_Timer = 25000; + }else DispelMagic_Timer -= diff; + } +}; + +#define SPELL_CLEANSE 29380 //Self or other guest+Moroes +#define SPELL_GREATERBLESSOFMIGHT 29381 //Self or other guest+Moroes +#define SPELL_HOLYLIGHT 29562 //Self or other guest+Moroes +#define SPELL_DIVINESHIELD 41367 + +struct MANGOS_DLL_DECL boss_lady_keira_berrybuckAI : public boss_moroes_guestAI +{ + //Holy Pally + boss_lady_keira_berrybuckAI(Creature *c) : boss_moroes_guestAI(c) {} + + uint32 Cleanse_Timer; + uint32 GreaterBless_Timer; + uint32 HolyLight_Timer; + uint32 DivineShield_Timer; + + void Reset() + { + Cleanse_Timer = 13000; + GreaterBless_Timer = 1000; + HolyLight_Timer = 7000; + DivineShield_Timer = 31000; + + AcquireGUID(); + + boss_moroes_guestAI::Reset(); + } + + void UpdateAI(const uint32 diff) + { + if(!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + boss_moroes_guestAI::UpdateAI(diff); + + if(DivineShield_Timer < diff) + { + DoCast(m_creature,SPELL_DIVINESHIELD); + DivineShield_Timer = 31000; + }else DivineShield_Timer -= diff; + + if(HolyLight_Timer < diff) + { + Unit* target = SelectTarget(); + + DoCast(target, SPELL_HOLYLIGHT); + HolyLight_Timer = 10000; + }else HolyLight_Timer -= diff; + + if(GreaterBless_Timer < diff) + { + Unit* target = SelectTarget(); + + DoCast(target, SPELL_GREATERBLESSOFMIGHT); + + GreaterBless_Timer = 50000; + }else GreaterBless_Timer -= diff; + + if(Cleanse_Timer < diff) + { + Unit* target = SelectTarget(); + + DoCast(target, SPELL_CLEANSE); + + Cleanse_Timer = 10000; + }else Cleanse_Timer -= diff; + } +}; + +#define SPELL_HAMSTRING 9080 +#define SPELL_MORTALSTRIKE 29572 +#define SPELL_WHIRLWIND 29573 + +struct MANGOS_DLL_DECL boss_lord_robin_darisAI : public boss_moroes_guestAI +{ + //Arms Warr + boss_lord_robin_darisAI(Creature *c) : boss_moroes_guestAI(c) {} + + uint32 Hamstring_Timer; + uint32 MortalStrike_Timer; + uint32 WhirlWind_Timer; + + void Reset() + { + Hamstring_Timer = 7000; + MortalStrike_Timer = 10000; + WhirlWind_Timer = 21000; + + boss_moroes_guestAI::Reset(); + } + + void UpdateAI(const uint32 diff) + { + if(!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + boss_moroes_guestAI::UpdateAI(diff); + + if(Hamstring_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_HAMSTRING); + Hamstring_Timer = 12000; + }else Hamstring_Timer -= diff; + + if(MortalStrike_Timer < diff) + { + DoCast(m_creature->getVictim(), SPELL_MORTALSTRIKE); + MortalStrike_Timer = 18000; + }else MortalStrike_Timer -= diff; + + if(WhirlWind_Timer < diff) + { + DoCast(m_creature,SPELL_WHIRLWIND); + WhirlWind_Timer = 21000; + }else WhirlWind_Timer -= diff; + } +}; + +#define SPELL_DISARM 8379 +#define SPELL_HEROICSTRIKE 29567 +#define SPELL_SHIELDBASH 11972 +#define SPELL_SHIELDWALL 29390 + +struct MANGOS_DLL_DECL boss_lord_crispin_ferenceAI : public boss_moroes_guestAI +{ + //Arms Warr + boss_lord_crispin_ferenceAI(Creature *c) : boss_moroes_guestAI(c) {} + + uint32 Disarm_Timer; + uint32 HeroicStrike_Timer; + uint32 ShieldBash_Timer; + uint32 ShieldWall_Timer; + + void Reset() + { + Disarm_Timer = 6000; + HeroicStrike_Timer = 10000; + ShieldBash_Timer = 8000; + ShieldWall_Timer = 4000; + + boss_moroes_guestAI::Reset(); + } + + void UpdateAI(const uint32 diff) + { + if(!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + boss_moroes_guestAI::UpdateAI(diff); + + if(Disarm_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_DISARM); + Disarm_Timer = 12000; + }else Disarm_Timer -= diff; + + if(HeroicStrike_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_HEROICSTRIKE); + HeroicStrike_Timer = 10000; + }else HeroicStrike_Timer -= diff; + + if(ShieldBash_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_SHIELDBASH); + ShieldBash_Timer = 13000; + }else ShieldBash_Timer -= diff; + + if(ShieldWall_Timer < diff) + { + DoCast(m_creature,SPELL_SHIELDWALL); + ShieldWall_Timer = 21000; + }else ShieldWall_Timer -= diff; + } +}; + +CreatureAI* GetAI_boss_moroes(Creature *_Creature) +{ + return new boss_moroesAI (_Creature); +} + +CreatureAI* GetAI_baroness_dorothea_millstipe(Creature *_Creature) +{ + return new boss_baroness_dorothea_millstipeAI (_Creature); +} + +CreatureAI* GetAI_baron_rafe_dreuger(Creature *_Creature) +{ + return new boss_baron_rafe_dreugerAI (_Creature); +} + +CreatureAI* GetAI_lady_catriona_von_indi(Creature *_Creature) +{ + return new boss_lady_catriona_von_indiAI (_Creature); +} + +CreatureAI* GetAI_lady_keira_berrybuck(Creature *_Creature) +{ + return new boss_lady_keira_berrybuckAI (_Creature); +} + +CreatureAI* GetAI_lord_robin_daris(Creature *_Creature) +{ + return new boss_lord_robin_darisAI (_Creature); +} + +CreatureAI* GetAI_lord_crispin_ference(Creature *_Creature) +{ + return new boss_lord_crispin_ferenceAI (_Creature); +} + +void AddSC_boss_moroes() +{ + Script *newscript; + + newscript = new Script; + newscript->Name="boss_moroes"; + newscript->GetAI = GetAI_boss_moroes; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="boss_baroness_dorothea_millstipe"; + newscript->GetAI = GetAI_baroness_dorothea_millstipe; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="boss_baron_rafe_dreuger"; + newscript->GetAI = GetAI_baron_rafe_dreuger; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="boss_lady_catriona_von_indi"; + newscript->GetAI = GetAI_lady_catriona_von_indi; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="boss_lady_keira_berrybuck"; + newscript->GetAI = GetAI_lady_keira_berrybuck; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="boss_lord_robin_daris"; + newscript->GetAI = GetAI_lord_robin_daris; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="boss_lord_crispin_ference"; + newscript->GetAI = GetAI_lord_crispin_ference; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/karazhan/boss_netherspite.cpp b/src/bindings/scripts/scripts/zone/karazhan/boss_netherspite.cpp index dfddad46aff..079ce619ab9 100644 --- a/src/bindings/scripts/scripts/zone/karazhan/boss_netherspite.cpp +++ b/src/bindings/scripts/scripts/zone/karazhan/boss_netherspite.cpp @@ -1,37 +1,37 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Netherspite -SD%Complete: 0 -SDComment: Place Holder -SDCategory: Karazhan -EndScriptData */ - -#include "precompiled.h" - -#define SPELL_NETHERBURN_AURA 30522 -#define SPELL_VOIDZONE 37014 //Probably won't work -#define SPELL_BERSERK 26662 -#define SPELL_NETHERBREATH 36631 - -//Beams (no idea how these are going to work in Mangos) -#define SPELL_DOMINANCE_ENEMY 30423 -#define SPELL_DOMINANCE_SELF 30468 -#define SPELL_PERSEVERANCE_ENEMY 30421 -#define SPELL_PERSEVERANCE_SELF 30466 -#define SPELL_SERENITY_ENEMY 30422 -#define SPELL_SERENITY_SELF 30467 +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Netherspite +SD%Complete: 0 +SDComment: Place Holder +SDCategory: Karazhan +EndScriptData */ + +#include "precompiled.h" + +#define SPELL_NETHERBURN_AURA 30522 +#define SPELL_VOIDZONE 37014 //Probably won't work +#define SPELL_BERSERK 26662 +#define SPELL_NETHERBREATH 36631 + +//Beams (no idea how these are going to work in Mangos) +#define SPELL_DOMINANCE_ENEMY 30423 +#define SPELL_DOMINANCE_SELF 30468 +#define SPELL_PERSEVERANCE_ENEMY 30421 +#define SPELL_PERSEVERANCE_SELF 30466 +#define SPELL_SERENITY_ENEMY 30422 +#define SPELL_SERENITY_SELF 30467 diff --git a/src/bindings/scripts/scripts/zone/karazhan/boss_nightbane.cpp b/src/bindings/scripts/scripts/zone/karazhan/boss_nightbane.cpp index 8b84df3a7fd..d29e7a2a6f4 100644 --- a/src/bindings/scripts/scripts/zone/karazhan/boss_nightbane.cpp +++ b/src/bindings/scripts/scripts/zone/karazhan/boss_nightbane.cpp @@ -1,33 +1,33 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Nightbane -SD%Complete: 0 -SDComment: Place holder -SDCategory: Karazhan -EndScriptData */ - -#include "precompiled.h" - -#define SPELL_BELLOWING_ROAR 39427 -#define SPELL_CHARRED_EARTH 30129 //Also 30209 (Target Charred Earth) triggers this -#define SPELL_DISTRACTING_ASH 30130 -#define SPELL_SMOLDERING_BREATH 30210 -#define SPELL_TAIL_SWEEP 25653 -#define SPELL_RAIN_OF_BONES 37098 -#define SPELL_SMOKING_BLAST 37057 -#define SPELL_FIREBALL_BARRAGE 30282 +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Nightbane +SD%Complete: 0 +SDComment: Place holder +SDCategory: Karazhan +EndScriptData */ + +#include "precompiled.h" + +#define SPELL_BELLOWING_ROAR 39427 +#define SPELL_CHARRED_EARTH 30129 //Also 30209 (Target Charred Earth) triggers this +#define SPELL_DISTRACTING_ASH 30130 +#define SPELL_SMOLDERING_BREATH 30210 +#define SPELL_TAIL_SWEEP 25653 +#define SPELL_RAIN_OF_BONES 37098 +#define SPELL_SMOKING_BLAST 37057 +#define SPELL_FIREBALL_BARRAGE 30282 diff --git a/src/bindings/scripts/scripts/zone/karazhan/boss_prince_malchezaar.cpp b/src/bindings/scripts/scripts/zone/karazhan/boss_prince_malchezaar.cpp index 842321cfbff..b9f24610e8c 100644 --- a/src/bindings/scripts/scripts/zone/karazhan/boss_prince_malchezaar.cpp +++ b/src/bindings/scripts/scripts/zone/karazhan/boss_prince_malchezaar.cpp @@ -1,646 +1,646 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Prince_Malchezzar -SD%Complete: 100 -SDComment: -SDCategory: Karazhan -EndScriptData */ - -#include "precompiled.h" - -#define SAY_AGGRO "Madness has brought you here to me. I shall be your undoing!" -#define SOUND_AGGRO 9218 -#define SAY_SUMMON1 "You face not Malchezaar alone, but the legions I command!" -#define SOUND_SUMMON1 9322 -#define SAY_SUMMON2 "All realities, all dimensions are open to me!" -#define SOUND_SUMMON2 9224 -#define SAY_PHASE2 "Simple fools! Time is the fire in which you'll burn!" -#define SOUND_PHASE2 9220 -#define SAY_PHASE3 "How can you hope to withstand against such overwhelming power?" -#define SOUND_PHASE3 9321 -#define SAY_PDEATH1 "You are, but a plaything, unfit even to amuse." -#define SOUND_PDEATH1 9319 -#define SAY_PDEATH2 "Your greed, your foolishness has brought you to this end." -#define SOUND_PDEATH2 9318 -#define SAY_PDEATH3 "Surely you did not think you could win." -#define SOUND_PDEATH3 9222 -#define SAY_DEATH "I refuse to concede defeat. I am a prince of the Eredar! I am..." -#define SOUND_DEATH 9221 - -// 19 Coordinates for Infernal spawns -struct InfernalPoint -{ - float x,y; -}; - -#define INFERNAL_Z 275.5 - -static InfernalPoint InfernalPoints[] = -{ - {-10922.8, -1985.2}, - {-10916.2, -1996.2}, - {-10932.2, -2008.1}, - {-10948.8, -2022.1}, - {-10958.7, -1997.7}, - {-10971.5, -1997.5}, - {-10990.8, -1995.1}, - {-10989.8, -1976.5}, - {-10971.6, -1973.0}, - {-10955.5, -1974.0}, - {-10939.6, -1969.8}, - {-10958.0, -1952.2}, - {-10941.7, -1954.8}, - {-10943.1, -1988.5}, - {-10948.8, -2005.1}, - {-10984.0, -2019.3}, - {-10932.8, -1979.6}, - {-10932.8, -1979.6}, - {-10935.7, -1996.0} -}; - -#define TOTAL_INFERNAL_POINTS 19 - -//Enfeeble is supposed to reduce hp to 1 and then heal player back to full when it ends -//Along with reducing healing and regen while enfeebled to 0% -//This spell effect will only reduce healing - -#define SPELL_ENFEEBLE 30843 //Enfeeble during phase 1 and 2 -#define SPELL_ENFEEBLE_EFFECT 41624 - -#define SPELL_SHADOWNOVA 30852 //Shadownova used during all phases -#define SPELL_SW_PAIN 30854 //Shadow word pain during phase 1 and 3 (different targeting rules though) -#define SPELL_THRASH_PASSIVE 12787 //Extra attack chance during phase 2 -#define SPELL_SUNDER_ARMOR 30901 //Sunder armor during phase 2 -#define SPELL_THRASH_AURA 3417 //Passive proc chance for thrash -#define SPELL_EQUIP_AXES 30857 //Visual for axe equiping -#define SPELL_AMPLIFY_DAMAGE 12738 //Amplifiy during phase 3 -#define SPELL_HELLFIRE 30859 //Infenals' hellfire aura -#define NETHERSPITE_INFERNAL 17646 //The netherspite infernal creature -#define MALCHEZARS_AXE 17650 //Malchezar's axes (creatures), summoned during phase 3 - -#define INFERNAL_MODEL_INVISIBLE 11686 //Infernal Effects -#define SPELL_INFERNAL_RELAY 30834 - -#define AXE_EQUIP_MODEL 40066 //Axes info -#define AXE_EQUIP_INFO 33448898 - -//---------Infernal code first -struct MANGOS_DLL_DECL netherspite_infernalAI : public ScriptedAI -{ - netherspite_infernalAI(Creature *c) : ScriptedAI(c) , - malchezaar(0), HellfireTimer(0), CleanupTimer(0), point(NULL) {Reset();} - - uint32 HellfireTimer; - uint32 CleanupTimer; - uint32 malchezaar; - InfernalPoint *point; - - void Reset() {} - void Aggro(Unit *who) {} - void MoveInLineOfSight(Unit *who) {} - - void UpdateAI(const uint32 diff) - { - if(HellfireTimer) - if(HellfireTimer <= diff) - { - DoCast(m_creature, SPELL_HELLFIRE); - HellfireTimer = 0; - } - else HellfireTimer -= diff; - - if(CleanupTimer) - if(CleanupTimer <= diff) - { - Cleanup(); - CleanupTimer = 0; - } else CleanupTimer -= diff; - } - - void KilledUnit(Unit *who) - { - Unit *pMalchezaar = Unit::GetUnit(*m_creature, malchezaar); - if(pMalchezaar) - ((Creature*)pMalchezaar)->AI()->KilledUnit(who); - } - - void SpellHit(Unit *who, const SpellEntry *spell) - { - if(spell->Id == SPELL_INFERNAL_RELAY) - { - m_creature->SetUInt32Value(UNIT_FIELD_DISPLAYID, m_creature->GetUInt32Value(UNIT_FIELD_NATIVEDISPLAYID)); - m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - HellfireTimer = 4000; - CleanupTimer = 170000; - } - } - - void DamageTaken(Unit *done_by, uint32 &damage) - { - if(done_by->GetGUID() != malchezaar) - damage = 0; - } - - void Cleanup(); //below ... -}; - -struct MANGOS_DLL_DECL boss_malchezaarAI : public ScriptedAI -{ - boss_malchezaarAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 EnfeebleTimer; - uint32 EnfeebleResetTimer; - uint32 ShadowNovaTimer; - uint32 SWPainTimer; - uint32 SunderArmorTimer; - uint32 AmplifyDamageTimer; - uint32 InfernalTimer; - uint32 AxesTargetSwitchTimer; - uint32 InfernalCleanupTimer; - - std::vector infernals; - std::vector positions; - - uint64 axes[2]; - uint64 enfeeble_targets[5]; - uint64 enfeeble_health[5]; - - uint32 phase; - - void Reset() - { - AxesCleanup(); - ClearWeapons(); - InfernalCleanup(); - positions.clear(); - - for(int i =0; i < 5; ++i) - enfeeble_targets[i] = 0; - - for(int i = 0; i < TOTAL_INFERNAL_POINTS; ++i) - positions.push_back(&InfernalPoints[i]); - - EnfeebleTimer = 30000; - EnfeebleResetTimer = 38000; - ShadowNovaTimer = 35000; - SWPainTimer = 20000; - AmplifyDamageTimer = 10000; - InfernalTimer = 45000; - InfernalCleanupTimer = 47000; - AxesTargetSwitchTimer = 7500 + rand()%12500; - phase = 1; - } - - void KilledUnit(Unit *victim) - { - switch(rand()%3) - { - case 0: - DoYell(SAY_PDEATH1, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(victim, SOUND_PDEATH1); - break; - case 1: - DoYell(SAY_PDEATH2, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(victim, SOUND_PDEATH2); - break; - case 2: - DoYell(SAY_PDEATH3, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(victim, SOUND_PDEATH3); - break; - } - } - - void JustDied(Unit *victim) - { - DoYell(SAY_DEATH, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_DEATH); - - AxesCleanup(); - ClearWeapons(); - InfernalCleanup(); - positions.clear(); - - for(int i = 0; i < TOTAL_INFERNAL_POINTS; ++i) - positions.push_back(&InfernalPoints[i]); - } - - void Aggro(Unit *who) - { - DoYell(SAY_AGGRO, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_AGGRO); - } - - void InfernalCleanup() - { - //Infernal Cleanup - for(std::vector::iterator itr = infernals.begin(); itr!= infernals.end(); ++itr) - { - Unit *pInfernal = Unit::GetUnit(*m_creature, *itr); - if(pInfernal && pInfernal->isAlive()) - { - pInfernal->SetVisibility(VISIBILITY_OFF); - pInfernal->setDeathState(JUST_DIED); - } - } - infernals.clear(); - } - - void AxesCleanup() - { - for(int i=0; i<2;++i) - { - Unit *axe = Unit::GetUnit(*m_creature, axes[i]); - if(axe && axe->isAlive()) - axe->DealDamage(axe, axe->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); - axes[i] = 0; - } - } - - void ClearWeapons() - { - m_creature->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_DISPLAY, 0); - m_creature->SetUInt32Value(UNIT_VIRTUAL_ITEM_INFO, 0); - - m_creature->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_DISPLAY+1, 0); - m_creature->SetUInt32Value(UNIT_VIRTUAL_ITEM_INFO+2, 0); - - //damage - const CreatureInfo *cinfo = m_creature->GetCreatureInfo(); - m_creature->SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, cinfo->mindmg); - m_creature->SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, cinfo->maxdmg); - m_creature->UpdateDamagePhysical(BASE_ATTACK); - } - - void EnfeebleHealthEffect() - { - const SpellEntry *info = GetSpellStore()->LookupEntry(SPELL_ENFEEBLE_EFFECT); - if(!info) - return; - - std::list t_list = m_creature->getThreatManager().getThreatList(); - std::vector targets; - - if(!t_list.size()) - return; - - //begin + 1 , so we don't target the one with the highest threat - std::list::iterator itr = t_list.begin(); - std::advance(itr, 1); - for( ; itr!= t_list.end(); ++itr) //store the threat list in a different container - { - Unit *target = Unit::GetUnit(*m_creature, (*itr)->getUnitGuid()); - //only on alive players - if(target && target->isAlive() && target->GetTypeId() == TYPEID_PLAYER ) - targets.push_back( target); - } - - //cut down to size if we have more than 5 targets - while(targets.size() > 5) - targets.erase(targets.begin()+rand()%targets.size()); - - int i = 0; - for(std::vector::iterator itr = targets.begin(); itr!= targets.end(); ++itr, ++i) - { - Unit *target = *itr; - if(target) - { - enfeeble_targets[i] = target->GetGUID(); - enfeeble_health[i] = target->GetHealth(); - - target->CastSpell(target, SPELL_ENFEEBLE, true, 0, 0, m_creature->GetGUID()); - target->SetHealth(1); - } - } - - } - - void EnfeebleResetHealth() - { - for(int i = 0; i < 5; ++i) - { - Unit *target = Unit::GetUnit(*m_creature, enfeeble_targets[i]); - if(target && target->isAlive()) - target->SetHealth(enfeeble_health[i]); - enfeeble_targets[i] = 0; - enfeeble_health[i] = 0; - } - } - - void SummonInfernal(const uint32 diff) - { - InfernalPoint *point = NULL; - float posX,posY,posZ; - if( (m_creature->GetMapId() != 532) || positions.empty()) - { - m_creature->GetRandomPoint(m_creature->GetPositionX(), m_creature->GetPositionY(), m_creature->GetPositionZ(), 60, posX, posY, posZ); - } - else - { - std::vector::iterator itr = positions.begin()+rand()%positions.size(); - point = *itr; - positions.erase(itr); - - posX = point->x; - posY = point->y; - posZ = INFERNAL_Z; - } - - Creature *Infernal = m_creature->SummonCreature(NETHERSPITE_INFERNAL, posX, posY, posZ, 0, TEMPSUMMON_TIMED_DESPAWN, 180000); - - if (Infernal) - { - Infernal->SetUInt32Value(UNIT_FIELD_DISPLAYID, INFERNAL_MODEL_INVISIBLE); - Infernal->setFaction(m_creature->getFaction()); - if(point) - ((netherspite_infernalAI*)Infernal->AI())->point=point; - ((netherspite_infernalAI*)Infernal->AI())->malchezaar=m_creature->GetGUID(); - - infernals.push_back(Infernal->GetGUID()); - DoCast(Infernal, SPELL_INFERNAL_RELAY); - } - - switch(rand()%2) - { - case 0: - DoYell(SAY_SUMMON1, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_SUMMON1); - break; - case 1: - DoYell(SAY_SUMMON2, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_SUMMON2); - break; - } - } - - void UpdateAI(const uint32 diff) - { - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - if(EnfeebleResetTimer) - if(EnfeebleResetTimer <= diff) //Let's not forget to reset that - { - EnfeebleResetHealth(); - EnfeebleResetTimer=0; - }else EnfeebleResetTimer -= diff; - - if(m_creature->hasUnitState(UNIT_STAT_STUNDED)) //While shifting to phase 2 malchezaar stuns himself - return; - - if(m_creature->GetUInt64Value(UNIT_FIELD_TARGET)!=m_creature->getVictim()->GetGUID()) - m_creature->SetUInt64Value(UNIT_FIELD_TARGET, m_creature->getVictim()->GetGUID()); - - if(phase == 1) - { - if( (m_creature->GetHealth()*100) / m_creature->GetMaxHealth() < 60) - { - m_creature->InterruptNonMeleeSpells(false); - - phase = 2; - - //animation - DoCast(m_creature, SPELL_EQUIP_AXES); - - //text - DoYell(SAY_PHASE2, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_PHASE2); - - //passive thrash aura - m_creature->CastSpell(m_creature, SPELL_THRASH_AURA, true); - - //models - m_creature->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_DISPLAY, AXE_EQUIP_MODEL); - m_creature->SetUInt32Value(UNIT_VIRTUAL_ITEM_INFO, AXE_EQUIP_INFO); - - m_creature->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_DISPLAY+1, AXE_EQUIP_MODEL); - m_creature->SetUInt32Value(UNIT_VIRTUAL_ITEM_INFO+2, AXE_EQUIP_INFO); - - //damage - const CreatureInfo *cinfo = m_creature->GetCreatureInfo(); - m_creature->SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, 2*cinfo->mindmg); - m_creature->SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, 2*cinfo->maxdmg); - m_creature->UpdateDamagePhysical(BASE_ATTACK); - - m_creature->SetBaseWeaponDamage(OFF_ATTACK, MINDAMAGE, cinfo->mindmg); - m_creature->SetBaseWeaponDamage(OFF_ATTACK, MAXDAMAGE, cinfo->maxdmg); - //Sigh, updating only works on main attack , do it manually .... - m_creature->SetFloatValue(UNIT_FIELD_MINOFFHANDDAMAGE, cinfo->mindmg); - m_creature->SetFloatValue(UNIT_FIELD_MAXOFFHANDDAMAGE, cinfo->maxdmg); - - m_creature->SetAttackTime(OFF_ATTACK, (((uint32)m_creature->GetAttackTime(BASE_ATTACK)/1.5))); - } - } - else if(phase == 2) - { - if( (m_creature->GetHealth()*100) / m_creature->GetMaxHealth() < 30) - { - InfernalTimer = 15000; - - phase = 3; - - ClearWeapons(); - - //remove thrash - m_creature->RemoveAurasDueToSpell(SPELL_THRASH_AURA); - - DoYell(SAY_PHASE3, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_PHASE3); - - Unit *target = SelectUnit(SELECT_TARGET_RANDOM, 0); - for(uint32 i=0; i<2; ++i) - { - Creature *axe = m_creature->SummonCreature(MALCHEZARS_AXE, m_creature->GetPositionX(), m_creature->GetPositionY(), m_creature->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 1000); - if(axe) - { - axe->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_DISPLAY, AXE_EQUIP_MODEL); - axe->SetUInt32Value(UNIT_VIRTUAL_ITEM_INFO, AXE_EQUIP_INFO); - - axe->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - axe->setFaction(m_creature->getFaction()); - axes[i] = axe->GetGUID(); - if(target) - { - axe->AI()->AttackStart(target); - // axe->getThreatManager().tauntApply(target); //Taunt Apply and fade out does not work properly - // So we'll use a hack to add a lot of threat to our target - axe->AddThreat(target, 10000000.0f); - } - } - } - - if(ShadowNovaTimer > 35000) - ShadowNovaTimer = EnfeebleTimer + 5000; - - return; - } - - if(SunderArmorTimer < diff) - { - DoCast(m_creature->getVictim(), SPELL_SUNDER_ARMOR); - SunderArmorTimer = 15000; - - }else SunderArmorTimer -= diff; - } - else - { - if(AxesTargetSwitchTimer < diff) - { - AxesTargetSwitchTimer = 7500 + rand()%12500 ; - - Unit *target = SelectUnit(SELECT_TARGET_RANDOM, 0); - if(target) - { - for(int i = 0; i < 2; ++i) - { - Unit *axe = Unit::GetUnit(*m_creature, axes[i]); - if(axe) - { - float threat = 1000000.0f; - if(axe->getVictim() && m_creature->getThreatManager().getThreat(axe->getVictim())) - { - threat = axe->getThreatManager().getThreat(axe->getVictim()); - axe->getThreatManager().modifyThreatPercent(axe->getVictim(), -100); - } - if(target) - axe->AddThreat(target, threat); - //axe->getThreatManager().tauntFadeOut(axe->getVictim()); - //axe->getThreatManager().tauntApply(target); - } - } - } - } else AxesTargetSwitchTimer -= diff; - - if(AmplifyDamageTimer < diff) - { - DoCast(SelectUnit(SELECT_TARGET_RANDOM, 0), SPELL_AMPLIFY_DAMAGE); - AmplifyDamageTimer = 20000 + rand()%10000; - }else AmplifyDamageTimer -= diff; - } - - //Time for global and double timers - if(InfernalTimer < diff) - { - SummonInfernal(diff); - InfernalTimer = phase == 3 ? 15000 : 45000; //15 secs in phase 3, 45 otherwise - }else InfernalTimer -= diff; - - if(ShadowNovaTimer < diff) - { - DoCast(m_creature->getVictim(), SPELL_SHADOWNOVA); - ShadowNovaTimer = phase == 3 ? 35000 : -1; - }else ShadowNovaTimer -= diff; - - if(phase != 2) - { - if(SWPainTimer < diff) - { - Unit *target; - if(phase == 1) - target = m_creature->getVictim(); // the tank - else //anyone but the tank - target = SelectUnit(SELECT_TARGET_RANDOM, 1); - - DoCast(target, SPELL_SW_PAIN); - SWPainTimer = 20000; - }else SWPainTimer -= diff; - } - - if(phase != 3) - { - if(EnfeebleTimer < diff) - { - EnfeebleHealthEffect(); - EnfeebleTimer = 30000; - ShadowNovaTimer = 5000; - EnfeebleResetTimer = 9000; - }else EnfeebleTimer -= diff; - } - - if(phase==2) - DoMeleeAttacksIfReady(); - else - DoMeleeAttackIfReady(); - } - - void DoMeleeAttacksIfReady() - { - if( m_creature->IsWithinDistInMap(m_creature->getVictim(), ATTACK_DISTANCE) && !m_creature->IsNonMeleeSpellCasted(false)) - { - //Check for base attack - if( m_creature->isAttackReady()) - { - m_creature->AttackerStateUpdate(m_creature->getVictim()); - m_creature->resetAttackTimer(); - } - //Check for offhand attack - if( m_creature->isAttackReady(OFF_ATTACK)) - { - m_creature->AttackerStateUpdate(m_creature->getVictim(), OFF_ATTACK); - m_creature->resetAttackTimer(OFF_ATTACK); - } - } - } - - void Cleanup(Creature *infernal, InfernalPoint *point) - { - for(std::vector::iterator itr = infernals.begin(); itr!= infernals.end(); ++itr) - if(*itr == infernal->GetGUID()) - { - infernals.erase(itr); - break; - } - - positions.push_back(point); - } -}; - -void netherspite_infernalAI::Cleanup() -{ - Unit *pMalchezaar = Unit::GetUnit(*m_creature, malchezaar); - - if(pMalchezaar && pMalchezaar->isAlive()) - ((boss_malchezaarAI*)((Creature*)pMalchezaar)->AI())->Cleanup(m_creature, point); -} - -CreatureAI* GetAI_netherspite_infernal(Creature *_Creature) -{ - return new netherspite_infernalAI (_Creature); -} - -CreatureAI* GetAI_boss_malchezaar(Creature *_Creature) -{ - return new boss_malchezaarAI (_Creature); -} - -void AddSC_netherspite_infernal() -{ - Script *newscript; - newscript = new Script; - newscript->Name="netherspite_infernal"; - newscript->GetAI = GetAI_netherspite_infernal; - m_scripts[nrscripts++] = newscript; -} - -void AddSC_boss_malchezaar() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_malchezaar"; - newscript->GetAI = GetAI_boss_malchezaar; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Prince_Malchezzar +SD%Complete: 100 +SDComment: +SDCategory: Karazhan +EndScriptData */ + +#include "precompiled.h" + +#define SAY_AGGRO "Madness has brought you here to me. I shall be your undoing!" +#define SOUND_AGGRO 9218 +#define SAY_SUMMON1 "You face not Malchezaar alone, but the legions I command!" +#define SOUND_SUMMON1 9322 +#define SAY_SUMMON2 "All realities, all dimensions are open to me!" +#define SOUND_SUMMON2 9224 +#define SAY_PHASE2 "Simple fools! Time is the fire in which you'll burn!" +#define SOUND_PHASE2 9220 +#define SAY_PHASE3 "How can you hope to withstand against such overwhelming power?" +#define SOUND_PHASE3 9321 +#define SAY_PDEATH1 "You are, but a plaything, unfit even to amuse." +#define SOUND_PDEATH1 9319 +#define SAY_PDEATH2 "Your greed, your foolishness has brought you to this end." +#define SOUND_PDEATH2 9318 +#define SAY_PDEATH3 "Surely you did not think you could win." +#define SOUND_PDEATH3 9222 +#define SAY_DEATH "I refuse to concede defeat. I am a prince of the Eredar! I am..." +#define SOUND_DEATH 9221 + +// 19 Coordinates for Infernal spawns +struct InfernalPoint +{ + float x,y; +}; + +#define INFERNAL_Z 275.5 + +static InfernalPoint InfernalPoints[] = +{ + {-10922.8, -1985.2}, + {-10916.2, -1996.2}, + {-10932.2, -2008.1}, + {-10948.8, -2022.1}, + {-10958.7, -1997.7}, + {-10971.5, -1997.5}, + {-10990.8, -1995.1}, + {-10989.8, -1976.5}, + {-10971.6, -1973.0}, + {-10955.5, -1974.0}, + {-10939.6, -1969.8}, + {-10958.0, -1952.2}, + {-10941.7, -1954.8}, + {-10943.1, -1988.5}, + {-10948.8, -2005.1}, + {-10984.0, -2019.3}, + {-10932.8, -1979.6}, + {-10932.8, -1979.6}, + {-10935.7, -1996.0} +}; + +#define TOTAL_INFERNAL_POINTS 19 + +//Enfeeble is supposed to reduce hp to 1 and then heal player back to full when it ends +//Along with reducing healing and regen while enfeebled to 0% +//This spell effect will only reduce healing + +#define SPELL_ENFEEBLE 30843 //Enfeeble during phase 1 and 2 +#define SPELL_ENFEEBLE_EFFECT 41624 + +#define SPELL_SHADOWNOVA 30852 //Shadownova used during all phases +#define SPELL_SW_PAIN 30854 //Shadow word pain during phase 1 and 3 (different targeting rules though) +#define SPELL_THRASH_PASSIVE 12787 //Extra attack chance during phase 2 +#define SPELL_SUNDER_ARMOR 30901 //Sunder armor during phase 2 +#define SPELL_THRASH_AURA 3417 //Passive proc chance for thrash +#define SPELL_EQUIP_AXES 30857 //Visual for axe equiping +#define SPELL_AMPLIFY_DAMAGE 12738 //Amplifiy during phase 3 +#define SPELL_HELLFIRE 30859 //Infenals' hellfire aura +#define NETHERSPITE_INFERNAL 17646 //The netherspite infernal creature +#define MALCHEZARS_AXE 17650 //Malchezar's axes (creatures), summoned during phase 3 + +#define INFERNAL_MODEL_INVISIBLE 11686 //Infernal Effects +#define SPELL_INFERNAL_RELAY 30834 + +#define AXE_EQUIP_MODEL 40066 //Axes info +#define AXE_EQUIP_INFO 33448898 + +//---------Infernal code first +struct MANGOS_DLL_DECL netherspite_infernalAI : public ScriptedAI +{ + netherspite_infernalAI(Creature *c) : ScriptedAI(c) , + malchezaar(0), HellfireTimer(0), CleanupTimer(0), point(NULL) {Reset();} + + uint32 HellfireTimer; + uint32 CleanupTimer; + uint32 malchezaar; + InfernalPoint *point; + + void Reset() {} + void Aggro(Unit *who) {} + void MoveInLineOfSight(Unit *who) {} + + void UpdateAI(const uint32 diff) + { + if(HellfireTimer) + if(HellfireTimer <= diff) + { + DoCast(m_creature, SPELL_HELLFIRE); + HellfireTimer = 0; + } + else HellfireTimer -= diff; + + if(CleanupTimer) + if(CleanupTimer <= diff) + { + Cleanup(); + CleanupTimer = 0; + } else CleanupTimer -= diff; + } + + void KilledUnit(Unit *who) + { + Unit *pMalchezaar = Unit::GetUnit(*m_creature, malchezaar); + if(pMalchezaar) + ((Creature*)pMalchezaar)->AI()->KilledUnit(who); + } + + void SpellHit(Unit *who, const SpellEntry *spell) + { + if(spell->Id == SPELL_INFERNAL_RELAY) + { + m_creature->SetUInt32Value(UNIT_FIELD_DISPLAYID, m_creature->GetUInt32Value(UNIT_FIELD_NATIVEDISPLAYID)); + m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + HellfireTimer = 4000; + CleanupTimer = 170000; + } + } + + void DamageTaken(Unit *done_by, uint32 &damage) + { + if(done_by->GetGUID() != malchezaar) + damage = 0; + } + + void Cleanup(); //below ... +}; + +struct MANGOS_DLL_DECL boss_malchezaarAI : public ScriptedAI +{ + boss_malchezaarAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 EnfeebleTimer; + uint32 EnfeebleResetTimer; + uint32 ShadowNovaTimer; + uint32 SWPainTimer; + uint32 SunderArmorTimer; + uint32 AmplifyDamageTimer; + uint32 InfernalTimer; + uint32 AxesTargetSwitchTimer; + uint32 InfernalCleanupTimer; + + std::vector infernals; + std::vector positions; + + uint64 axes[2]; + uint64 enfeeble_targets[5]; + uint64 enfeeble_health[5]; + + uint32 phase; + + void Reset() + { + AxesCleanup(); + ClearWeapons(); + InfernalCleanup(); + positions.clear(); + + for(int i =0; i < 5; ++i) + enfeeble_targets[i] = 0; + + for(int i = 0; i < TOTAL_INFERNAL_POINTS; ++i) + positions.push_back(&InfernalPoints[i]); + + EnfeebleTimer = 30000; + EnfeebleResetTimer = 38000; + ShadowNovaTimer = 35000; + SWPainTimer = 20000; + AmplifyDamageTimer = 10000; + InfernalTimer = 45000; + InfernalCleanupTimer = 47000; + AxesTargetSwitchTimer = 7500 + rand()%12500; + phase = 1; + } + + void KilledUnit(Unit *victim) + { + switch(rand()%3) + { + case 0: + DoYell(SAY_PDEATH1, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(victim, SOUND_PDEATH1); + break; + case 1: + DoYell(SAY_PDEATH2, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(victim, SOUND_PDEATH2); + break; + case 2: + DoYell(SAY_PDEATH3, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(victim, SOUND_PDEATH3); + break; + } + } + + void JustDied(Unit *victim) + { + DoYell(SAY_DEATH, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_DEATH); + + AxesCleanup(); + ClearWeapons(); + InfernalCleanup(); + positions.clear(); + + for(int i = 0; i < TOTAL_INFERNAL_POINTS; ++i) + positions.push_back(&InfernalPoints[i]); + } + + void Aggro(Unit *who) + { + DoYell(SAY_AGGRO, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_AGGRO); + } + + void InfernalCleanup() + { + //Infernal Cleanup + for(std::vector::iterator itr = infernals.begin(); itr!= infernals.end(); ++itr) + { + Unit *pInfernal = Unit::GetUnit(*m_creature, *itr); + if(pInfernal && pInfernal->isAlive()) + { + pInfernal->SetVisibility(VISIBILITY_OFF); + pInfernal->setDeathState(JUST_DIED); + } + } + infernals.clear(); + } + + void AxesCleanup() + { + for(int i=0; i<2;++i) + { + Unit *axe = Unit::GetUnit(*m_creature, axes[i]); + if(axe && axe->isAlive()) + axe->DealDamage(axe, axe->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); + axes[i] = 0; + } + } + + void ClearWeapons() + { + m_creature->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_DISPLAY, 0); + m_creature->SetUInt32Value(UNIT_VIRTUAL_ITEM_INFO, 0); + + m_creature->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_DISPLAY+1, 0); + m_creature->SetUInt32Value(UNIT_VIRTUAL_ITEM_INFO+2, 0); + + //damage + const CreatureInfo *cinfo = m_creature->GetCreatureInfo(); + m_creature->SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, cinfo->mindmg); + m_creature->SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, cinfo->maxdmg); + m_creature->UpdateDamagePhysical(BASE_ATTACK); + } + + void EnfeebleHealthEffect() + { + const SpellEntry *info = GetSpellStore()->LookupEntry(SPELL_ENFEEBLE_EFFECT); + if(!info) + return; + + std::list t_list = m_creature->getThreatManager().getThreatList(); + std::vector targets; + + if(!t_list.size()) + return; + + //begin + 1 , so we don't target the one with the highest threat + std::list::iterator itr = t_list.begin(); + std::advance(itr, 1); + for( ; itr!= t_list.end(); ++itr) //store the threat list in a different container + { + Unit *target = Unit::GetUnit(*m_creature, (*itr)->getUnitGuid()); + //only on alive players + if(target && target->isAlive() && target->GetTypeId() == TYPEID_PLAYER ) + targets.push_back( target); + } + + //cut down to size if we have more than 5 targets + while(targets.size() > 5) + targets.erase(targets.begin()+rand()%targets.size()); + + int i = 0; + for(std::vector::iterator itr = targets.begin(); itr!= targets.end(); ++itr, ++i) + { + Unit *target = *itr; + if(target) + { + enfeeble_targets[i] = target->GetGUID(); + enfeeble_health[i] = target->GetHealth(); + + target->CastSpell(target, SPELL_ENFEEBLE, true, 0, 0, m_creature->GetGUID()); + target->SetHealth(1); + } + } + + } + + void EnfeebleResetHealth() + { + for(int i = 0; i < 5; ++i) + { + Unit *target = Unit::GetUnit(*m_creature, enfeeble_targets[i]); + if(target && target->isAlive()) + target->SetHealth(enfeeble_health[i]); + enfeeble_targets[i] = 0; + enfeeble_health[i] = 0; + } + } + + void SummonInfernal(const uint32 diff) + { + InfernalPoint *point = NULL; + float posX,posY,posZ; + if( (m_creature->GetMapId() != 532) || positions.empty()) + { + m_creature->GetRandomPoint(m_creature->GetPositionX(), m_creature->GetPositionY(), m_creature->GetPositionZ(), 60, posX, posY, posZ); + } + else + { + std::vector::iterator itr = positions.begin()+rand()%positions.size(); + point = *itr; + positions.erase(itr); + + posX = point->x; + posY = point->y; + posZ = INFERNAL_Z; + } + + Creature *Infernal = m_creature->SummonCreature(NETHERSPITE_INFERNAL, posX, posY, posZ, 0, TEMPSUMMON_TIMED_DESPAWN, 180000); + + if (Infernal) + { + Infernal->SetUInt32Value(UNIT_FIELD_DISPLAYID, INFERNAL_MODEL_INVISIBLE); + Infernal->setFaction(m_creature->getFaction()); + if(point) + ((netherspite_infernalAI*)Infernal->AI())->point=point; + ((netherspite_infernalAI*)Infernal->AI())->malchezaar=m_creature->GetGUID(); + + infernals.push_back(Infernal->GetGUID()); + DoCast(Infernal, SPELL_INFERNAL_RELAY); + } + + switch(rand()%2) + { + case 0: + DoYell(SAY_SUMMON1, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_SUMMON1); + break; + case 1: + DoYell(SAY_SUMMON2, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_SUMMON2); + break; + } + } + + void UpdateAI(const uint32 diff) + { + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + if(EnfeebleResetTimer) + if(EnfeebleResetTimer <= diff) //Let's not forget to reset that + { + EnfeebleResetHealth(); + EnfeebleResetTimer=0; + }else EnfeebleResetTimer -= diff; + + if(m_creature->hasUnitState(UNIT_STAT_STUNDED)) //While shifting to phase 2 malchezaar stuns himself + return; + + if(m_creature->GetUInt64Value(UNIT_FIELD_TARGET)!=m_creature->getVictim()->GetGUID()) + m_creature->SetUInt64Value(UNIT_FIELD_TARGET, m_creature->getVictim()->GetGUID()); + + if(phase == 1) + { + if( (m_creature->GetHealth()*100) / m_creature->GetMaxHealth() < 60) + { + m_creature->InterruptNonMeleeSpells(false); + + phase = 2; + + //animation + DoCast(m_creature, SPELL_EQUIP_AXES); + + //text + DoYell(SAY_PHASE2, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_PHASE2); + + //passive thrash aura + m_creature->CastSpell(m_creature, SPELL_THRASH_AURA, true); + + //models + m_creature->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_DISPLAY, AXE_EQUIP_MODEL); + m_creature->SetUInt32Value(UNIT_VIRTUAL_ITEM_INFO, AXE_EQUIP_INFO); + + m_creature->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_DISPLAY+1, AXE_EQUIP_MODEL); + m_creature->SetUInt32Value(UNIT_VIRTUAL_ITEM_INFO+2, AXE_EQUIP_INFO); + + //damage + const CreatureInfo *cinfo = m_creature->GetCreatureInfo(); + m_creature->SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, 2*cinfo->mindmg); + m_creature->SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, 2*cinfo->maxdmg); + m_creature->UpdateDamagePhysical(BASE_ATTACK); + + m_creature->SetBaseWeaponDamage(OFF_ATTACK, MINDAMAGE, cinfo->mindmg); + m_creature->SetBaseWeaponDamage(OFF_ATTACK, MAXDAMAGE, cinfo->maxdmg); + //Sigh, updating only works on main attack , do it manually .... + m_creature->SetFloatValue(UNIT_FIELD_MINOFFHANDDAMAGE, cinfo->mindmg); + m_creature->SetFloatValue(UNIT_FIELD_MAXOFFHANDDAMAGE, cinfo->maxdmg); + + m_creature->SetAttackTime(OFF_ATTACK, (((uint32)m_creature->GetAttackTime(BASE_ATTACK)/1.5))); + } + } + else if(phase == 2) + { + if( (m_creature->GetHealth()*100) / m_creature->GetMaxHealth() < 30) + { + InfernalTimer = 15000; + + phase = 3; + + ClearWeapons(); + + //remove thrash + m_creature->RemoveAurasDueToSpell(SPELL_THRASH_AURA); + + DoYell(SAY_PHASE3, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_PHASE3); + + Unit *target = SelectUnit(SELECT_TARGET_RANDOM, 0); + for(uint32 i=0; i<2; ++i) + { + Creature *axe = m_creature->SummonCreature(MALCHEZARS_AXE, m_creature->GetPositionX(), m_creature->GetPositionY(), m_creature->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 1000); + if(axe) + { + axe->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_DISPLAY, AXE_EQUIP_MODEL); + axe->SetUInt32Value(UNIT_VIRTUAL_ITEM_INFO, AXE_EQUIP_INFO); + + axe->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + axe->setFaction(m_creature->getFaction()); + axes[i] = axe->GetGUID(); + if(target) + { + axe->AI()->AttackStart(target); + // axe->getThreatManager().tauntApply(target); //Taunt Apply and fade out does not work properly + // So we'll use a hack to add a lot of threat to our target + axe->AddThreat(target, 10000000.0f); + } + } + } + + if(ShadowNovaTimer > 35000) + ShadowNovaTimer = EnfeebleTimer + 5000; + + return; + } + + if(SunderArmorTimer < diff) + { + DoCast(m_creature->getVictim(), SPELL_SUNDER_ARMOR); + SunderArmorTimer = 15000; + + }else SunderArmorTimer -= diff; + } + else + { + if(AxesTargetSwitchTimer < diff) + { + AxesTargetSwitchTimer = 7500 + rand()%12500 ; + + Unit *target = SelectUnit(SELECT_TARGET_RANDOM, 0); + if(target) + { + for(int i = 0; i < 2; ++i) + { + Unit *axe = Unit::GetUnit(*m_creature, axes[i]); + if(axe) + { + float threat = 1000000.0f; + if(axe->getVictim() && m_creature->getThreatManager().getThreat(axe->getVictim())) + { + threat = axe->getThreatManager().getThreat(axe->getVictim()); + axe->getThreatManager().modifyThreatPercent(axe->getVictim(), -100); + } + if(target) + axe->AddThreat(target, threat); + //axe->getThreatManager().tauntFadeOut(axe->getVictim()); + //axe->getThreatManager().tauntApply(target); + } + } + } + } else AxesTargetSwitchTimer -= diff; + + if(AmplifyDamageTimer < diff) + { + DoCast(SelectUnit(SELECT_TARGET_RANDOM, 0), SPELL_AMPLIFY_DAMAGE); + AmplifyDamageTimer = 20000 + rand()%10000; + }else AmplifyDamageTimer -= diff; + } + + //Time for global and double timers + if(InfernalTimer < diff) + { + SummonInfernal(diff); + InfernalTimer = phase == 3 ? 15000 : 45000; //15 secs in phase 3, 45 otherwise + }else InfernalTimer -= diff; + + if(ShadowNovaTimer < diff) + { + DoCast(m_creature->getVictim(), SPELL_SHADOWNOVA); + ShadowNovaTimer = phase == 3 ? 35000 : -1; + }else ShadowNovaTimer -= diff; + + if(phase != 2) + { + if(SWPainTimer < diff) + { + Unit *target; + if(phase == 1) + target = m_creature->getVictim(); // the tank + else //anyone but the tank + target = SelectUnit(SELECT_TARGET_RANDOM, 1); + + DoCast(target, SPELL_SW_PAIN); + SWPainTimer = 20000; + }else SWPainTimer -= diff; + } + + if(phase != 3) + { + if(EnfeebleTimer < diff) + { + EnfeebleHealthEffect(); + EnfeebleTimer = 30000; + ShadowNovaTimer = 5000; + EnfeebleResetTimer = 9000; + }else EnfeebleTimer -= diff; + } + + if(phase==2) + DoMeleeAttacksIfReady(); + else + DoMeleeAttackIfReady(); + } + + void DoMeleeAttacksIfReady() + { + if( m_creature->IsWithinDistInMap(m_creature->getVictim(), ATTACK_DISTANCE) && !m_creature->IsNonMeleeSpellCasted(false)) + { + //Check for base attack + if( m_creature->isAttackReady()) + { + m_creature->AttackerStateUpdate(m_creature->getVictim()); + m_creature->resetAttackTimer(); + } + //Check for offhand attack + if( m_creature->isAttackReady(OFF_ATTACK)) + { + m_creature->AttackerStateUpdate(m_creature->getVictim(), OFF_ATTACK); + m_creature->resetAttackTimer(OFF_ATTACK); + } + } + } + + void Cleanup(Creature *infernal, InfernalPoint *point) + { + for(std::vector::iterator itr = infernals.begin(); itr!= infernals.end(); ++itr) + if(*itr == infernal->GetGUID()) + { + infernals.erase(itr); + break; + } + + positions.push_back(point); + } +}; + +void netherspite_infernalAI::Cleanup() +{ + Unit *pMalchezaar = Unit::GetUnit(*m_creature, malchezaar); + + if(pMalchezaar && pMalchezaar->isAlive()) + ((boss_malchezaarAI*)((Creature*)pMalchezaar)->AI())->Cleanup(m_creature, point); +} + +CreatureAI* GetAI_netherspite_infernal(Creature *_Creature) +{ + return new netherspite_infernalAI (_Creature); +} + +CreatureAI* GetAI_boss_malchezaar(Creature *_Creature) +{ + return new boss_malchezaarAI (_Creature); +} + +void AddSC_netherspite_infernal() +{ + Script *newscript; + newscript = new Script; + newscript->Name="netherspite_infernal"; + newscript->GetAI = GetAI_netherspite_infernal; + m_scripts[nrscripts++] = newscript; +} + +void AddSC_boss_malchezaar() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_malchezaar"; + newscript->GetAI = GetAI_boss_malchezaar; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/karazhan/boss_shade_of_aran.cpp b/src/bindings/scripts/scripts/zone/karazhan/boss_shade_of_aran.cpp index c90620f04a7..f3733c955c1 100644 --- a/src/bindings/scripts/scripts/zone/karazhan/boss_shade_of_aran.cpp +++ b/src/bindings/scripts/scripts/zone/karazhan/boss_shade_of_aran.cpp @@ -1,673 +1,673 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Shade_of_Aran -SD%Complete: 95 -SDComment: Flame wreath missing cast animation, mods won't triggere. Drinking may cause client crash (core related) -SDCategory: Karazhan -EndScriptData */ - -#include "precompiled.h" -#include "../../creature/simple_ai.h" -#include "def_karazhan.h" -#include "GameObject.h" - -//Aggro -#define SAY_AGGRO1 "Please, no more. My son... he's gone mad!" -#define SOUND_AGGRO1 9241 - -#define SAY_AGGRO2 "I'll not be tortured again!" -#define SOUND_AGGRO2 9323 - -#define SAY_AGGRO3 "Who are you? What do you want? Stay away from me!" -#define SOUND_AGGRO3 9324 - -//Flame Wreath -#define SAY_FLAMEWREATH1 "I'll show you this beaten dog still has some teeth!" -#define SOUND_FLAMEWREATH1 9245 -#define SAY_FLAMEWREATH2 "Burn you hellish fiends!" -#define SOUND_FLAMEWREATH2 9326 - -//Blizzard -#define SAY_BLIZZARD1 "I'll freeze you all!" -#define SOUND_BLIZZARD1 9246 -#define SAY_BLIZZARD2 "Back to the cold dark with you!" -#define SOUND_BLIZZARD2 9327 - -//Arcane Explosion -#define SAY_EXPLOSION1 "Yes, yes, my son is quite powerful... but I have powers of my own!" -#define SOUND_EXPLOSION1 9242 -#define SAY_EXPLOSION2 "I am not some simple jester! I am Nielas Aran!" -#define SOUND_EXPLOSION2 9325 - -//Low Mana / AoE Pyroblast -#define SAY_DRINK "Surely you would not deny an old man a replenishing drink? No, no I thought not." -#define SOUND_DRINK 9248 - -//Summon Water Elementals -#define SAY_ELEMENTALS "I'm not finished yet! No, I have a few more tricks up me sleeve." -#define SOUND_ELEMENTALS 9251 - -//Player Death -#define SAY_KILL1 "I want this nightmare to be over!" -#define SOUND_KILL1 9250 - -#define SAY_KILL2 "Torment me no more!" -#define SOUND_KILL2 9328 - -//Time over -#define SAY_TIMEOVER "You've wasted enough of my time. Let these games be finished!" -#define SOUND_TIMEOVER 9247 - -//Aran's death -#define SAY_DEATH "At last... The nightmare is.. over..." -#define SOUND_DEATH 9244 - -//Atiesh is equipped by a raid member -#define SAY_ATIESH "Where did you get that?! Did HE send you?!" -#define SOUND_ATIESH 9249 - -//Spells -#define SPELL_FROSTBOLT 29954 -#define SPELL_FIREBALL 29953 -#define SPELL_ARCMISSLE 29955 -#define SPELL_CHAINSOFICE 29991 -#define SPELL_DRAGONSBREATH 29964 -#define SPELL_MASSSLOW 30035 -#define SPELL_FLAME_WREATH 29946 -#define SPELL_AOE_CS 29961 -#define SPELL_PLAYERPULL 32265 -#define SPELL_AEXPLOSION 29973 -#define SPELL_MASS_POLY 29963 -#define SPELL_BLINK_CENTER 29967 -#define SPELL_ELEMENTALS 29962 -#define SPELL_CONJURE 29975 -#define SPELL_DRINK 30024 -#define SPELL_POTION 32453 -#define SPELL_AOE_PYROBLAST 29978 - -//Creature Spells -#define SPELL_CIRCULAR_BLIZZARD 29951 //29952 is the REAL circular blizzard that leaves persistant blizzards that last for 10 seconds -#define SPELL_WATERBOLT 31012 -#define SPELL_SHADOW_PYRO 29978 - -//Creatures -#define CREATURE_WATER_ELEMENTAL 17167 -#define CREATURE_SHADOW_OF_ARAN 18254 -#define CREATURE_ARAN_BLIZZARD 17161 - -enum SuperSpell -{ - SUPER_FLAME = 0, - SUPER_BLIZZARD, - SUPER_AE, -}; - -struct MANGOS_DLL_DECL boss_aranAI : public ScriptedAI -{ - boss_aranAI(Creature *c) : ScriptedAI(c) - { - pInstance = ((ScriptedInstance*)c->GetInstanceData()); - Reset(); - } - - ScriptedInstance* pInstance; - - uint32 SecondarySpellTimer; - uint32 NormalCastTimer; - uint32 SuperCastTimer; - uint32 BerserkTimer; - uint32 CloseDoorTimer; // Don't close the door right on aggro in case some people are still entering. - - uint8 LastSuperSpell; - - uint32 FlameWreathTimer; - uint32 FlameWreathCheckTime; - uint64 FlameWreathTarget[3]; - float FWTargPosX[3]; - float FWTargPosY[3]; - - uint32 CurrentNormalSpell; - uint32 ArcaneCooldown; - uint32 FireCooldown; - uint32 FrostCooldown; - - uint32 DrinkInturruptTimer; - - bool ElementalsSpawned; - bool Drinking; - bool DrinkInturrupted; - - void Reset() - { - SecondarySpellTimer = 5000; - NormalCastTimer = 0; - SuperCastTimer = 35000; - BerserkTimer = 720000; - CloseDoorTimer = 15000; - - LastSuperSpell = rand()%3; - - FlameWreathTimer = 0; - FlameWreathCheckTime = 0; - - CurrentNormalSpell = 0; - ArcaneCooldown = 0; - FireCooldown = 0; - FrostCooldown = 0; - - DrinkInturruptTimer = 10000; - - ElementalsSpawned = false; - Drinking = false; - DrinkInturrupted = false; - - if(pInstance) - { - // Not in progress - pInstance->SetData(DATA_SHADEOFARAN_EVENT, NOT_STARTED); - - if(GameObject* Door = GameObject::GetGameObject(*m_creature, pInstance->GetData64(DATA_GAMEOBJECT_LIBRARY_DOOR))) - Door->SetGoState(0); - } - } - - void KilledUnit(Unit *victim) - { - switch(rand()%2) - { - case 0: - DoYell(SAY_KILL1, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(victim, SOUND_KILL1); - break; - case 1: - DoYell(SAY_KILL2, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(victim, SOUND_KILL2); - break; - } - } - - void JustDied(Unit *victim) - { - DoYell(SAY_DEATH, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(NULL, SOUND_DEATH); - - if(pInstance) - { - pInstance->SetData(DATA_SHADEOFARAN_EVENT, DONE); - if(GameObject* Door = GameObject::GetGameObject(*m_creature, pInstance->GetData64(DATA_GAMEOBJECT_LIBRARY_DOOR))) - Door->SetGoState(0); - } - } - - void Aggro(Unit *who) - { - switch(rand()%3) - { - case 0: - DoYell(SAY_AGGRO1, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_AGGRO1); - break; - case 1: - DoYell(SAY_AGGRO2, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_AGGRO2); - break; - case 2: - DoYell(SAY_AGGRO3, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_AGGRO3); - break; - } - - if(pInstance) - pInstance->SetData(DATA_SHADEOFARAN_EVENT, IN_PROGRESS); - } - - void FlameWreathEffect() - { - std::vector targets; - std::list t_list = m_creature->getThreatManager().getThreatList(); - - if(!t_list.size()) - return; - - //store the threat list in a different container - for(std::list::iterator itr = t_list.begin(); itr!= t_list.end(); ++itr) - { - Unit *target = Unit::GetUnit(*m_creature, (*itr)->getUnitGuid()); - //only on alive players - if(target && target->isAlive() && target->GetTypeId() == TYPEID_PLAYER ) - targets.push_back( target); - } - - //cut down to size if we have more than 3 targets - while(targets.size() > 3) - targets.erase(targets.begin()+rand()%targets.size()); - - uint32 i = 0; - for(std::vector::iterator itr = targets.begin(); itr!= targets.end(); ++itr) - { - if(*itr) - { - FlameWreathTarget[i] = (*itr)->GetGUID(); - FWTargPosX[i] = (*itr)->GetPositionX(); - FWTargPosY[i] = (*itr)->GetPositionY(); - m_creature->CastSpell((*itr), SPELL_FLAME_WREATH, true); - i++; - } - } - } - - void UpdateAI(const uint32 diff) - { - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - if(CloseDoorTimer) - if(CloseDoorTimer <= diff) - { - if(pInstance) - if(GameObject* Door = GameObject::GetGameObject(*m_creature, pInstance->GetData64(DATA_GAMEOBJECT_LIBRARY_DOOR))) - Door->SetGoState(1); - CloseDoorTimer = 0; - } - else CloseDoorTimer -= diff; - - //Cooldowns for casts - if (ArcaneCooldown) - if (ArcaneCooldown >= diff) - ArcaneCooldown -= diff; - else ArcaneCooldown = 0; - - if (FireCooldown) - if (FireCooldown >= diff) - FireCooldown -= diff; - else FireCooldown = 0; - - if (FrostCooldown) - if (FrostCooldown >= diff) - FrostCooldown -= diff; - else FrostCooldown = 0; - - if(!Drinking && m_creature->GetMaxPower(POWER_MANA) && (m_creature->GetPower(POWER_MANA)*100 / m_creature->GetMaxPower(POWER_MANA)) < 20) - { - Drinking = true; - m_creature->InterruptNonMeleeSpells(false); - - DoYell(SAY_DRINK, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_DRINK); - - if (!DrinkInturrupted) - { - m_creature->CastSpell(m_creature, SPELL_MASS_POLY, true); - m_creature->CastSpell(m_creature, SPELL_CONJURE, false); - m_creature->CastSpell(m_creature, SPELL_DRINK, false); - //Sitting down - m_creature->SetUInt32Value(UNIT_FIELD_BYTES_1, 1); - DrinkInturruptTimer = 10000; - } - } - - //Drink Inturrupt - if (Drinking && DrinkInturrupted) - { - Drinking = false; - m_creature->RemoveAurasDueToSpell(SPELL_DRINK); - m_creature->SetUInt32Value(UNIT_FIELD_BYTES_1, 0); - m_creature->SetPower(POWER_MANA, m_creature->GetMaxPower(POWER_MANA)-32000); - m_creature->CastSpell(m_creature, SPELL_POTION, false); - } - - //Drink Inturrupt Timer - if (Drinking && !DrinkInturrupted) - if (DrinkInturruptTimer >= diff) - DrinkInturruptTimer -= diff; - else - { - m_creature->SetUInt32Value(UNIT_FIELD_BYTES_1, 0); - m_creature->CastSpell(m_creature, SPELL_POTION, true); - m_creature->CastSpell(m_creature, SPELL_AOE_PYROBLAST, false); - DrinkInturrupted = true; - Drinking = false; - } - - //Don't execute any more code if we are drinking - if (Drinking) - return; - - //Normal casts - if(NormalCastTimer < diff) - { - if (!m_creature->IsNonMeleeSpellCasted(false)) - { - Unit* target = NULL; - target = SelectUnit(SELECT_TARGET_RANDOM, 0); - if (!target) - return; - - uint32 Spells[3]; - uint8 AvailableSpells = 0; - - //Check for what spells are not on cooldown - if (!ArcaneCooldown) - { - Spells[AvailableSpells] = SPELL_ARCMISSLE; - AvailableSpells++; - } - if (!FireCooldown) - { - Spells[AvailableSpells] = SPELL_FIREBALL; - AvailableSpells++; - } - if (!FrostCooldown) - { - Spells[AvailableSpells] = SPELL_FROSTBOLT; - AvailableSpells++; - } - - //If no available spells wait 1 second and try again - if (AvailableSpells) - { - CurrentNormalSpell = Spells[rand() % AvailableSpells]; - DoCast(target, CurrentNormalSpell); - } - } - NormalCastTimer = 1000; - }else NormalCastTimer -= diff; - - if(SecondarySpellTimer < diff) - { - switch (rand()%2) - { - - case 0: - DoCast(m_creature, SPELL_AOE_CS); - break; - case 1: - Unit* pUnit; - pUnit = SelectUnit(SELECT_TARGET_RANDOM, 0); - if (pUnit) - DoCast(pUnit, SPELL_CHAINSOFICE); - break; - } - SecondarySpellTimer = 5000 + (rand()%15000); - }else SecondarySpellTimer -= diff; - - if(SuperCastTimer < diff) - { - uint8 Available[2]; - - switch (LastSuperSpell) - { - case SUPER_AE: - Available[0] = SUPER_FLAME; - Available[1] = SUPER_BLIZZARD; - break; - case SUPER_FLAME: - Available[0] = SUPER_AE; - Available[1] = SUPER_BLIZZARD; - break; - case SUPER_BLIZZARD: - Available[0] = SUPER_FLAME; - Available[1] = SUPER_AE; - break; - } - - LastSuperSpell = Available[rand()%2]; - - switch (LastSuperSpell) - { - case SUPER_AE: - - if (rand()%2) - { - DoYell(SAY_EXPLOSION1, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_EXPLOSION1); - }else - { - DoYell(SAY_EXPLOSION2, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_EXPLOSION2); - } - - m_creature->CastSpell(m_creature, SPELL_BLINK_CENTER, true); - m_creature->CastSpell(m_creature, SPELL_PLAYERPULL, true); - m_creature->CastSpell(m_creature, SPELL_MASSSLOW, true); - m_creature->CastSpell(m_creature, SPELL_AEXPLOSION, false); - break; - - case SUPER_FLAME: - if (rand()%2) - { - DoYell(SAY_FLAMEWREATH1, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_FLAMEWREATH1); - }else - { - DoYell(SAY_FLAMEWREATH2, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_FLAMEWREATH2); - } - - FlameWreathTimer = 20000; - FlameWreathCheckTime = 500; - - FlameWreathTarget[0] = 0; - FlameWreathTarget[1] = 0; - FlameWreathTarget[2] = 0; - - FlameWreathEffect(); - break; - - case SUPER_BLIZZARD: - - if (rand()%2) - { - DoYell(SAY_BLIZZARD1, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_BLIZZARD1); - }else - { - DoYell(SAY_BLIZZARD2, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_BLIZZARD2); - } - - Creature* Spawn = NULL; - Spawn = DoSpawnCreature(CREATURE_ARAN_BLIZZARD, 0, 0, 0, 0, TEMPSUMMON_TIMED_DESPAWN, 25000); - if (Spawn) - { - Spawn->setFaction(m_creature->getFaction()); - Spawn->CastSpell(Spawn, SPELL_CIRCULAR_BLIZZARD, false); - } - break; - } - - SuperCastTimer = 35000 + (rand()%5000); - }else SuperCastTimer -= diff; - - if(!ElementalsSpawned && m_creature->GetHealth()*100 / m_creature->GetMaxHealth() < 40) - { - ElementalsSpawned = true; - - for (uint32 i = 0; i < 4; i++) - { - Creature* pUnit = DoSpawnCreature(CREATURE_WATER_ELEMENTAL, 0, 0, 0, 0, TEMPSUMMON_TIMED_DESPAWN, 90000); - if (pUnit) - { - pUnit->Attack(m_creature->getVictim(), true); - pUnit->setFaction(m_creature->getFaction()); - } - } - - DoYell(SAY_ELEMENTALS, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_ELEMENTALS); - } - - if(BerserkTimer < diff) - { - for (uint32 i = 0; i < 5; i++) - { - Creature* pUnit = DoSpawnCreature(CREATURE_SHADOW_OF_ARAN, 0, 0, 0, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000); - if (pUnit) - { - pUnit->Attack(m_creature->getVictim(), true); - pUnit->setFaction(m_creature->getFaction()); - } - } - - DoYell(SAY_TIMEOVER, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_TIMEOVER); - - BerserkTimer = 60000; - }else BerserkTimer -= diff; - - //Flame Wreath check - if (FlameWreathTimer) - { - if (FlameWreathTimer >= diff) - FlameWreathTimer -= diff; - else FlameWreathTimer = 0; - - if (FlameWreathCheckTime < diff) - { - for (uint32 i = 0; i < 3; i++) - { - if (!FlameWreathTarget[i]) - continue; - - Unit* pUnit = Unit::GetUnit(*m_creature, FlameWreathTarget[i]); - if (pUnit && pUnit->GetDistance2d(FWTargPosX[i], FWTargPosY[i]) > 3) - { - pUnit->CastSpell(pUnit, 20476, true, 0, 0, m_creature->GetGUID()); - pUnit->CastSpell(pUnit, 11027, true); - FlameWreathTarget[i] = 0; - } - } - FlameWreathCheckTime = 500; - }else FlameWreathCheckTime -= diff; - } - - if (ArcaneCooldown && FireCooldown && FrostCooldown) - DoMeleeAttackIfReady(); - } - - void DamageTaken(Unit* pAttacker, uint32 &damage) - { - if (!DrinkInturrupted && Drinking && damage) - DrinkInturrupted = true; - } - - void SpellHit(Unit* pAttacker, const SpellEntry* Spell) - { - //We only care about inturrupt effects and only if they are durring a spell currently being casted - if ((Spell->Effect[0]!=SPELL_EFFECT_INTERRUPT_CAST && - Spell->Effect[1]!=SPELL_EFFECT_INTERRUPT_CAST && - Spell->Effect[2]!=SPELL_EFFECT_INTERRUPT_CAST) || !m_creature->IsNonMeleeSpellCasted(false)) - return; - - //Inturrupt effect - m_creature->InterruptNonMeleeSpells(false); - - //Normally we would set the cooldown equal to the spell duration - //but we do not have access to the DurationStore - - switch (CurrentNormalSpell) - { - case SPELL_ARCMISSLE: - ArcaneCooldown = 5000; - break; - case SPELL_FIREBALL: - FireCooldown = 5000; - break; - case SPELL_FROSTBOLT: - FrostCooldown = 5000; - break; - } - } -}; - -struct MANGOS_DLL_DECL water_elementalAI : public ScriptedAI -{ - water_elementalAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 CastTimer; - - void Reset() - { - CastTimer = 2000 + (rand()%3000); - } - - void Aggro(Unit* who) {} - - void UpdateAI(const uint32 diff) - { - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - if(CastTimer < diff) - { - DoCast(m_creature->getVictim(), SPELL_WATERBOLT); - CastTimer = 2000 + (rand()%3000); - }else CastTimer -= diff; - } -}; - -CreatureAI* GetAI_boss_aran(Creature *_Creature) -{ - return new boss_aranAI (_Creature); -} - -CreatureAI* GetAI_water_elemental(Creature *_Creature) -{ - return new water_elementalAI (_Creature); -} - -// CONVERT TO ACID -CreatureAI* GetAI_shadow_of_aran(Creature *_Creature) -{ - outstring_log("SD2: Convert simpleAI script for Creature Entry %u to ACID", _Creature->GetEntry()); - SimpleAI* ai = new SimpleAI (_Creature); - - ai->Spell[0].Enabled = true; - ai->Spell[0].Spell_Id = SPELL_SHADOW_PYRO; - ai->Spell[0].Cooldown = 5000; - ai->Spell[0].First_Cast = 1000; - ai->Spell[0].Cast_Target_Type = CAST_HOSTILE_TARGET; - - ai->EnterEvadeMode(); - - return ai; -} - -void AddSC_boss_shade_of_aran() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_shade_of_aran"; - newscript->GetAI = GetAI_boss_aran; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="mob_shadow_of_aran"; - newscript->GetAI = GetAI_shadow_of_aran; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="mob_aran_elemental"; - newscript->GetAI = GetAI_water_elemental; - m_scripts[nrscripts++] = newscript; - - //newscript = new Script; - //newscript->Name="mob_aran_blizzard"; - //newscript->GetAI = GetAI_boss_aran; - //m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Shade_of_Aran +SD%Complete: 95 +SDComment: Flame wreath missing cast animation, mods won't triggere. Drinking may cause client crash (core related) +SDCategory: Karazhan +EndScriptData */ + +#include "precompiled.h" +#include "../../creature/simple_ai.h" +#include "def_karazhan.h" +#include "GameObject.h" + +//Aggro +#define SAY_AGGRO1 "Please, no more. My son... he's gone mad!" +#define SOUND_AGGRO1 9241 + +#define SAY_AGGRO2 "I'll not be tortured again!" +#define SOUND_AGGRO2 9323 + +#define SAY_AGGRO3 "Who are you? What do you want? Stay away from me!" +#define SOUND_AGGRO3 9324 + +//Flame Wreath +#define SAY_FLAMEWREATH1 "I'll show you this beaten dog still has some teeth!" +#define SOUND_FLAMEWREATH1 9245 +#define SAY_FLAMEWREATH2 "Burn you hellish fiends!" +#define SOUND_FLAMEWREATH2 9326 + +//Blizzard +#define SAY_BLIZZARD1 "I'll freeze you all!" +#define SOUND_BLIZZARD1 9246 +#define SAY_BLIZZARD2 "Back to the cold dark with you!" +#define SOUND_BLIZZARD2 9327 + +//Arcane Explosion +#define SAY_EXPLOSION1 "Yes, yes, my son is quite powerful... but I have powers of my own!" +#define SOUND_EXPLOSION1 9242 +#define SAY_EXPLOSION2 "I am not some simple jester! I am Nielas Aran!" +#define SOUND_EXPLOSION2 9325 + +//Low Mana / AoE Pyroblast +#define SAY_DRINK "Surely you would not deny an old man a replenishing drink? No, no I thought not." +#define SOUND_DRINK 9248 + +//Summon Water Elementals +#define SAY_ELEMENTALS "I'm not finished yet! No, I have a few more tricks up me sleeve." +#define SOUND_ELEMENTALS 9251 + +//Player Death +#define SAY_KILL1 "I want this nightmare to be over!" +#define SOUND_KILL1 9250 + +#define SAY_KILL2 "Torment me no more!" +#define SOUND_KILL2 9328 + +//Time over +#define SAY_TIMEOVER "You've wasted enough of my time. Let these games be finished!" +#define SOUND_TIMEOVER 9247 + +//Aran's death +#define SAY_DEATH "At last... The nightmare is.. over..." +#define SOUND_DEATH 9244 + +//Atiesh is equipped by a raid member +#define SAY_ATIESH "Where did you get that?! Did HE send you?!" +#define SOUND_ATIESH 9249 + +//Spells +#define SPELL_FROSTBOLT 29954 +#define SPELL_FIREBALL 29953 +#define SPELL_ARCMISSLE 29955 +#define SPELL_CHAINSOFICE 29991 +#define SPELL_DRAGONSBREATH 29964 +#define SPELL_MASSSLOW 30035 +#define SPELL_FLAME_WREATH 29946 +#define SPELL_AOE_CS 29961 +#define SPELL_PLAYERPULL 32265 +#define SPELL_AEXPLOSION 29973 +#define SPELL_MASS_POLY 29963 +#define SPELL_BLINK_CENTER 29967 +#define SPELL_ELEMENTALS 29962 +#define SPELL_CONJURE 29975 +#define SPELL_DRINK 30024 +#define SPELL_POTION 32453 +#define SPELL_AOE_PYROBLAST 29978 + +//Creature Spells +#define SPELL_CIRCULAR_BLIZZARD 29951 //29952 is the REAL circular blizzard that leaves persistant blizzards that last for 10 seconds +#define SPELL_WATERBOLT 31012 +#define SPELL_SHADOW_PYRO 29978 + +//Creatures +#define CREATURE_WATER_ELEMENTAL 17167 +#define CREATURE_SHADOW_OF_ARAN 18254 +#define CREATURE_ARAN_BLIZZARD 17161 + +enum SuperSpell +{ + SUPER_FLAME = 0, + SUPER_BLIZZARD, + SUPER_AE, +}; + +struct MANGOS_DLL_DECL boss_aranAI : public ScriptedAI +{ + boss_aranAI(Creature *c) : ScriptedAI(c) + { + pInstance = ((ScriptedInstance*)c->GetInstanceData()); + Reset(); + } + + ScriptedInstance* pInstance; + + uint32 SecondarySpellTimer; + uint32 NormalCastTimer; + uint32 SuperCastTimer; + uint32 BerserkTimer; + uint32 CloseDoorTimer; // Don't close the door right on aggro in case some people are still entering. + + uint8 LastSuperSpell; + + uint32 FlameWreathTimer; + uint32 FlameWreathCheckTime; + uint64 FlameWreathTarget[3]; + float FWTargPosX[3]; + float FWTargPosY[3]; + + uint32 CurrentNormalSpell; + uint32 ArcaneCooldown; + uint32 FireCooldown; + uint32 FrostCooldown; + + uint32 DrinkInturruptTimer; + + bool ElementalsSpawned; + bool Drinking; + bool DrinkInturrupted; + + void Reset() + { + SecondarySpellTimer = 5000; + NormalCastTimer = 0; + SuperCastTimer = 35000; + BerserkTimer = 720000; + CloseDoorTimer = 15000; + + LastSuperSpell = rand()%3; + + FlameWreathTimer = 0; + FlameWreathCheckTime = 0; + + CurrentNormalSpell = 0; + ArcaneCooldown = 0; + FireCooldown = 0; + FrostCooldown = 0; + + DrinkInturruptTimer = 10000; + + ElementalsSpawned = false; + Drinking = false; + DrinkInturrupted = false; + + if(pInstance) + { + // Not in progress + pInstance->SetData(DATA_SHADEOFARAN_EVENT, NOT_STARTED); + + if(GameObject* Door = GameObject::GetGameObject(*m_creature, pInstance->GetData64(DATA_GAMEOBJECT_LIBRARY_DOOR))) + Door->SetGoState(0); + } + } + + void KilledUnit(Unit *victim) + { + switch(rand()%2) + { + case 0: + DoYell(SAY_KILL1, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(victim, SOUND_KILL1); + break; + case 1: + DoYell(SAY_KILL2, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(victim, SOUND_KILL2); + break; + } + } + + void JustDied(Unit *victim) + { + DoYell(SAY_DEATH, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(NULL, SOUND_DEATH); + + if(pInstance) + { + pInstance->SetData(DATA_SHADEOFARAN_EVENT, DONE); + if(GameObject* Door = GameObject::GetGameObject(*m_creature, pInstance->GetData64(DATA_GAMEOBJECT_LIBRARY_DOOR))) + Door->SetGoState(0); + } + } + + void Aggro(Unit *who) + { + switch(rand()%3) + { + case 0: + DoYell(SAY_AGGRO1, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_AGGRO1); + break; + case 1: + DoYell(SAY_AGGRO2, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_AGGRO2); + break; + case 2: + DoYell(SAY_AGGRO3, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_AGGRO3); + break; + } + + if(pInstance) + pInstance->SetData(DATA_SHADEOFARAN_EVENT, IN_PROGRESS); + } + + void FlameWreathEffect() + { + std::vector targets; + std::list t_list = m_creature->getThreatManager().getThreatList(); + + if(!t_list.size()) + return; + + //store the threat list in a different container + for(std::list::iterator itr = t_list.begin(); itr!= t_list.end(); ++itr) + { + Unit *target = Unit::GetUnit(*m_creature, (*itr)->getUnitGuid()); + //only on alive players + if(target && target->isAlive() && target->GetTypeId() == TYPEID_PLAYER ) + targets.push_back( target); + } + + //cut down to size if we have more than 3 targets + while(targets.size() > 3) + targets.erase(targets.begin()+rand()%targets.size()); + + uint32 i = 0; + for(std::vector::iterator itr = targets.begin(); itr!= targets.end(); ++itr) + { + if(*itr) + { + FlameWreathTarget[i] = (*itr)->GetGUID(); + FWTargPosX[i] = (*itr)->GetPositionX(); + FWTargPosY[i] = (*itr)->GetPositionY(); + m_creature->CastSpell((*itr), SPELL_FLAME_WREATH, true); + i++; + } + } + } + + void UpdateAI(const uint32 diff) + { + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + if(CloseDoorTimer) + if(CloseDoorTimer <= diff) + { + if(pInstance) + if(GameObject* Door = GameObject::GetGameObject(*m_creature, pInstance->GetData64(DATA_GAMEOBJECT_LIBRARY_DOOR))) + Door->SetGoState(1); + CloseDoorTimer = 0; + } + else CloseDoorTimer -= diff; + + //Cooldowns for casts + if (ArcaneCooldown) + if (ArcaneCooldown >= diff) + ArcaneCooldown -= diff; + else ArcaneCooldown = 0; + + if (FireCooldown) + if (FireCooldown >= diff) + FireCooldown -= diff; + else FireCooldown = 0; + + if (FrostCooldown) + if (FrostCooldown >= diff) + FrostCooldown -= diff; + else FrostCooldown = 0; + + if(!Drinking && m_creature->GetMaxPower(POWER_MANA) && (m_creature->GetPower(POWER_MANA)*100 / m_creature->GetMaxPower(POWER_MANA)) < 20) + { + Drinking = true; + m_creature->InterruptNonMeleeSpells(false); + + DoYell(SAY_DRINK, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_DRINK); + + if (!DrinkInturrupted) + { + m_creature->CastSpell(m_creature, SPELL_MASS_POLY, true); + m_creature->CastSpell(m_creature, SPELL_CONJURE, false); + m_creature->CastSpell(m_creature, SPELL_DRINK, false); + //Sitting down + m_creature->SetUInt32Value(UNIT_FIELD_BYTES_1, 1); + DrinkInturruptTimer = 10000; + } + } + + //Drink Inturrupt + if (Drinking && DrinkInturrupted) + { + Drinking = false; + m_creature->RemoveAurasDueToSpell(SPELL_DRINK); + m_creature->SetUInt32Value(UNIT_FIELD_BYTES_1, 0); + m_creature->SetPower(POWER_MANA, m_creature->GetMaxPower(POWER_MANA)-32000); + m_creature->CastSpell(m_creature, SPELL_POTION, false); + } + + //Drink Inturrupt Timer + if (Drinking && !DrinkInturrupted) + if (DrinkInturruptTimer >= diff) + DrinkInturruptTimer -= diff; + else + { + m_creature->SetUInt32Value(UNIT_FIELD_BYTES_1, 0); + m_creature->CastSpell(m_creature, SPELL_POTION, true); + m_creature->CastSpell(m_creature, SPELL_AOE_PYROBLAST, false); + DrinkInturrupted = true; + Drinking = false; + } + + //Don't execute any more code if we are drinking + if (Drinking) + return; + + //Normal casts + if(NormalCastTimer < diff) + { + if (!m_creature->IsNonMeleeSpellCasted(false)) + { + Unit* target = NULL; + target = SelectUnit(SELECT_TARGET_RANDOM, 0); + if (!target) + return; + + uint32 Spells[3]; + uint8 AvailableSpells = 0; + + //Check for what spells are not on cooldown + if (!ArcaneCooldown) + { + Spells[AvailableSpells] = SPELL_ARCMISSLE; + AvailableSpells++; + } + if (!FireCooldown) + { + Spells[AvailableSpells] = SPELL_FIREBALL; + AvailableSpells++; + } + if (!FrostCooldown) + { + Spells[AvailableSpells] = SPELL_FROSTBOLT; + AvailableSpells++; + } + + //If no available spells wait 1 second and try again + if (AvailableSpells) + { + CurrentNormalSpell = Spells[rand() % AvailableSpells]; + DoCast(target, CurrentNormalSpell); + } + } + NormalCastTimer = 1000; + }else NormalCastTimer -= diff; + + if(SecondarySpellTimer < diff) + { + switch (rand()%2) + { + + case 0: + DoCast(m_creature, SPELL_AOE_CS); + break; + case 1: + Unit* pUnit; + pUnit = SelectUnit(SELECT_TARGET_RANDOM, 0); + if (pUnit) + DoCast(pUnit, SPELL_CHAINSOFICE); + break; + } + SecondarySpellTimer = 5000 + (rand()%15000); + }else SecondarySpellTimer -= diff; + + if(SuperCastTimer < diff) + { + uint8 Available[2]; + + switch (LastSuperSpell) + { + case SUPER_AE: + Available[0] = SUPER_FLAME; + Available[1] = SUPER_BLIZZARD; + break; + case SUPER_FLAME: + Available[0] = SUPER_AE; + Available[1] = SUPER_BLIZZARD; + break; + case SUPER_BLIZZARD: + Available[0] = SUPER_FLAME; + Available[1] = SUPER_AE; + break; + } + + LastSuperSpell = Available[rand()%2]; + + switch (LastSuperSpell) + { + case SUPER_AE: + + if (rand()%2) + { + DoYell(SAY_EXPLOSION1, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_EXPLOSION1); + }else + { + DoYell(SAY_EXPLOSION2, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_EXPLOSION2); + } + + m_creature->CastSpell(m_creature, SPELL_BLINK_CENTER, true); + m_creature->CastSpell(m_creature, SPELL_PLAYERPULL, true); + m_creature->CastSpell(m_creature, SPELL_MASSSLOW, true); + m_creature->CastSpell(m_creature, SPELL_AEXPLOSION, false); + break; + + case SUPER_FLAME: + if (rand()%2) + { + DoYell(SAY_FLAMEWREATH1, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_FLAMEWREATH1); + }else + { + DoYell(SAY_FLAMEWREATH2, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_FLAMEWREATH2); + } + + FlameWreathTimer = 20000; + FlameWreathCheckTime = 500; + + FlameWreathTarget[0] = 0; + FlameWreathTarget[1] = 0; + FlameWreathTarget[2] = 0; + + FlameWreathEffect(); + break; + + case SUPER_BLIZZARD: + + if (rand()%2) + { + DoYell(SAY_BLIZZARD1, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_BLIZZARD1); + }else + { + DoYell(SAY_BLIZZARD2, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_BLIZZARD2); + } + + Creature* Spawn = NULL; + Spawn = DoSpawnCreature(CREATURE_ARAN_BLIZZARD, 0, 0, 0, 0, TEMPSUMMON_TIMED_DESPAWN, 25000); + if (Spawn) + { + Spawn->setFaction(m_creature->getFaction()); + Spawn->CastSpell(Spawn, SPELL_CIRCULAR_BLIZZARD, false); + } + break; + } + + SuperCastTimer = 35000 + (rand()%5000); + }else SuperCastTimer -= diff; + + if(!ElementalsSpawned && m_creature->GetHealth()*100 / m_creature->GetMaxHealth() < 40) + { + ElementalsSpawned = true; + + for (uint32 i = 0; i < 4; i++) + { + Creature* pUnit = DoSpawnCreature(CREATURE_WATER_ELEMENTAL, 0, 0, 0, 0, TEMPSUMMON_TIMED_DESPAWN, 90000); + if (pUnit) + { + pUnit->Attack(m_creature->getVictim(), true); + pUnit->setFaction(m_creature->getFaction()); + } + } + + DoYell(SAY_ELEMENTALS, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_ELEMENTALS); + } + + if(BerserkTimer < diff) + { + for (uint32 i = 0; i < 5; i++) + { + Creature* pUnit = DoSpawnCreature(CREATURE_SHADOW_OF_ARAN, 0, 0, 0, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000); + if (pUnit) + { + pUnit->Attack(m_creature->getVictim(), true); + pUnit->setFaction(m_creature->getFaction()); + } + } + + DoYell(SAY_TIMEOVER, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_TIMEOVER); + + BerserkTimer = 60000; + }else BerserkTimer -= diff; + + //Flame Wreath check + if (FlameWreathTimer) + { + if (FlameWreathTimer >= diff) + FlameWreathTimer -= diff; + else FlameWreathTimer = 0; + + if (FlameWreathCheckTime < diff) + { + for (uint32 i = 0; i < 3; i++) + { + if (!FlameWreathTarget[i]) + continue; + + Unit* pUnit = Unit::GetUnit(*m_creature, FlameWreathTarget[i]); + if (pUnit && pUnit->GetDistance2d(FWTargPosX[i], FWTargPosY[i]) > 3) + { + pUnit->CastSpell(pUnit, 20476, true, 0, 0, m_creature->GetGUID()); + pUnit->CastSpell(pUnit, 11027, true); + FlameWreathTarget[i] = 0; + } + } + FlameWreathCheckTime = 500; + }else FlameWreathCheckTime -= diff; + } + + if (ArcaneCooldown && FireCooldown && FrostCooldown) + DoMeleeAttackIfReady(); + } + + void DamageTaken(Unit* pAttacker, uint32 &damage) + { + if (!DrinkInturrupted && Drinking && damage) + DrinkInturrupted = true; + } + + void SpellHit(Unit* pAttacker, const SpellEntry* Spell) + { + //We only care about inturrupt effects and only if they are durring a spell currently being casted + if ((Spell->Effect[0]!=SPELL_EFFECT_INTERRUPT_CAST && + Spell->Effect[1]!=SPELL_EFFECT_INTERRUPT_CAST && + Spell->Effect[2]!=SPELL_EFFECT_INTERRUPT_CAST) || !m_creature->IsNonMeleeSpellCasted(false)) + return; + + //Inturrupt effect + m_creature->InterruptNonMeleeSpells(false); + + //Normally we would set the cooldown equal to the spell duration + //but we do not have access to the DurationStore + + switch (CurrentNormalSpell) + { + case SPELL_ARCMISSLE: + ArcaneCooldown = 5000; + break; + case SPELL_FIREBALL: + FireCooldown = 5000; + break; + case SPELL_FROSTBOLT: + FrostCooldown = 5000; + break; + } + } +}; + +struct MANGOS_DLL_DECL water_elementalAI : public ScriptedAI +{ + water_elementalAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 CastTimer; + + void Reset() + { + CastTimer = 2000 + (rand()%3000); + } + + void Aggro(Unit* who) {} + + void UpdateAI(const uint32 diff) + { + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + if(CastTimer < diff) + { + DoCast(m_creature->getVictim(), SPELL_WATERBOLT); + CastTimer = 2000 + (rand()%3000); + }else CastTimer -= diff; + } +}; + +CreatureAI* GetAI_boss_aran(Creature *_Creature) +{ + return new boss_aranAI (_Creature); +} + +CreatureAI* GetAI_water_elemental(Creature *_Creature) +{ + return new water_elementalAI (_Creature); +} + +// CONVERT TO ACID +CreatureAI* GetAI_shadow_of_aran(Creature *_Creature) +{ + outstring_log("SD2: Convert simpleAI script for Creature Entry %u to ACID", _Creature->GetEntry()); + SimpleAI* ai = new SimpleAI (_Creature); + + ai->Spell[0].Enabled = true; + ai->Spell[0].Spell_Id = SPELL_SHADOW_PYRO; + ai->Spell[0].Cooldown = 5000; + ai->Spell[0].First_Cast = 1000; + ai->Spell[0].Cast_Target_Type = CAST_HOSTILE_TARGET; + + ai->EnterEvadeMode(); + + return ai; +} + +void AddSC_boss_shade_of_aran() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_shade_of_aran"; + newscript->GetAI = GetAI_boss_aran; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="mob_shadow_of_aran"; + newscript->GetAI = GetAI_shadow_of_aran; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="mob_aran_elemental"; + newscript->GetAI = GetAI_water_elemental; + m_scripts[nrscripts++] = newscript; + + //newscript = new Script; + //newscript->Name="mob_aran_blizzard"; + //newscript->GetAI = GetAI_boss_aran; + //m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/karazhan/boss_terestian_illhoof.cpp b/src/bindings/scripts/scripts/zone/karazhan/boss_terestian_illhoof.cpp index 2fa5b3860a0..771d839925f 100644 --- a/src/bindings/scripts/scripts/zone/karazhan/boss_terestian_illhoof.cpp +++ b/src/bindings/scripts/scripts/zone/karazhan/boss_terestian_illhoof.cpp @@ -1,454 +1,454 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Terestian_Illhoof -SD%Complete: 100 -SDComment: Complete! -SDCategory: Karazhan -EndScriptData */ - -#include "precompiled.h" -#include "def_karazhan.h" - -#define SPELL_SUMMON_DEMONCHAINS 30120 // Summons demonic chains that maintain the ritual of sacrifice. -#define SPELL_DEMON_CHAINS 30206 // Instant - Visual Effect -#define SPELL_ENRAGE 23537 // Increases the caster's attack speed by 50% and the Physical damage it deals by 219 to 281 for 10 min. -#define SPELL_SHADOW_BOLT 30055 // Hurls a bolt of dark magic at an enemy, inflicting Shadow damage. -#define SPELL_SACRIFICE 30115 // Teleports and adds the debuff -#define SPELL_BERSERK 32965 // Increases attack speed by 75%. Periodically casts Shadow Bolt Volley. - -#define SPELL_FIREBOLT 18086 // Blasts a target for 150 Fire damage. - -#define SPELL_BROKEN_PACT 30065 // All damage taken increased by 25%. -#define SPELL_AMPLIFY_FLAMES 30053 // Increases the Fire damage taken by an enemy by 500 for 25 sec. -#define SPELL_FIREBOLT 18086 // Blasts a target for 150 Fire damage. - -#define SAY_SLAY1 "Your blood will anoint my circle." -#define SOUND_SLAY1 9264 -#define SAY_SLAY2 "The great one will be pleased." -#define SOUND_SLAY2 9329 - -#define SAY_DEATH "My life, is yours. Oh great one." -#define SOUND_DEATH 9262 - -#define SAY_AGGRO "Ah, you're just in time. The rituals are about to begin." -#define SOUND_AGGRO 9260 - -#define SAY_SACRIFICE1 "Please, accept this humble offering, oh great one." -#define SOUND_SACRIFICE1 9263 -#define SAY_SACRIFICE2 "Let the sacrifice serve his testament to my fealty." -#define SOUND_SACRIFICE2 9330 - -#define SAY_SUMMON1 "Come, you dwellers in the dark. Rally to my call!" -#define SOUND_SUMMON1 9265 -#define SAY_SUMMON2 "Gather, my pets. There is plenty for all." -#define SOUND_SUMMON2 9331 - -#define CREATURE_DEMONCHAINS 17248 -#define CREATURE_FIENDISHIMP 17267 -#define CREATURE_PORTAL 17265 - -#define SACRIFICE_X -11240.599 -#define SACRIFICE_Y -1694.2700 -#define SACRIFICE_Z 179.720007 - -#define PORTAL_Z 179.434 - -float PortalLocations[2][2]= -{ - {-11249.6933, -1704.61023}, - {-11242.1160, -1713.33325}, -}; - -struct MANGOS_DLL_DECL mob_kilrekAI : public ScriptedAI -{ - mob_kilrekAI(Creature *c) : ScriptedAI(c) - { - pInstance = ((ScriptedInstance*)c->GetInstanceData()); - Reset(); - } - - ScriptedInstance* pInstance; - - uint64 TerestianGUID; - - uint32 AmplifyTimer; - - void Reset() - { - TerestianGUID = 0; - - AmplifyTimer = 0; - } - - void Aggro(Unit *who) - { - if(!pInstance) - { - ERROR_INST_DATA(m_creature); - return; - } - - Creature* Terestian = ((Creature*)Unit::GetUnit(*m_creature, pInstance->GetData64(DATA_TERESTIAN))); - if(Terestian && (!Terestian->SelectHostilTarget() && !Terestian->getVictim())) - Terestian->AddThreat(who, 1.0f); - } - - void JustDied(Unit* Killer) - { - if(pInstance) - { - uint64 TerestianGUID = pInstance->GetData64(DATA_TERESTIAN); - if(TerestianGUID) - { - Unit* Terestian = Unit::GetUnit((*m_creature), TerestianGUID); - if(Terestian && Terestian->isAlive()) - DoCast(Terestian, SPELL_BROKEN_PACT, true); - } - }else ERROR_INST_DATA(m_creature); - } - - void UpdateAI(const uint32 diff) - { - //Return since we have no target - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - if (AmplifyTimer < diff) - { - m_creature->InterruptNonMeleeSpells(false); - DoCast(m_creature->getVictim(),SPELL_AMPLIFY_FLAMES); - - AmplifyTimer = 20000; - }else AmplifyTimer -= diff; - - //Chain cast - if (!m_creature->IsNonMeleeSpellCasted(false) && m_creature->IsWithinDistInMap(m_creature->getVictim(), 30)) - DoCast(m_creature->getVictim(),SPELL_FIREBOLT); - else DoMeleeAttackIfReady(); - } -}; - -struct MANGOS_DLL_DECL mob_demon_chainAI : public ScriptedAI -{ - mob_demon_chainAI(Creature *c) : ScriptedAI(c) - { - Reset(); - } - - uint64 SacrificeGUID; - - void Reset() - { - SacrificeGUID = 0; - } - - void Aggro(Unit* who) {} - void AttackStart(Unit* who) {} - void MoveInLineOfSight(Unit* who) {} - - void JustDied(Unit *killer) - { - if(SacrificeGUID) - { - Unit* Sacrifice = Unit::GetUnit((*m_creature),SacrificeGUID); - if(Sacrifice) - Sacrifice->RemoveAurasDueToSpell(SPELL_SACRIFICE); - } - } -}; - -struct MANGOS_DLL_DECL boss_terestianAI : public ScriptedAI -{ - boss_terestianAI(Creature *c) : ScriptedAI(c) - { - pInstance = ((ScriptedInstance*)c->GetInstanceData()); - Reset(); - } - - ScriptedInstance *pInstance; - - uint64 KilrekGUID; - uint64 PortalGUID[2]; - - uint32 CheckKilrekTimer; - uint32 SacrificeTimer; - uint32 ShadowboltTimer; - uint32 SummonTimer; - uint32 BerserkTimer; - - bool SummonKilrek; - bool SummonedPortals; - bool Berserk; - - void Reset() - { - for(uint8 i = 0; i < 2; ++i) - { - if(PortalGUID[i]) - { - Unit* Portal = Unit::GetUnit((*m_creature), PortalGUID[i]); - if(Portal) - Portal->DealDamage(Portal, Portal->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); - - PortalGUID[i] = 0; - } - } - - CheckKilrekTimer = 5000; - SacrificeTimer = 30000; - ShadowboltTimer = 5000; - SummonTimer = 10000; - BerserkTimer = 600000; - - SummonedPortals = false; - Berserk = false; - - if(pInstance) - pInstance->SetData(DATA_TERESTIAN_EVENT, NOT_STARTED); - } - - void Aggro(Unit* who) - { - DoYell(SAY_AGGRO, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_AGGRO); - - if(pInstance) - { - // Put Kil'rek in combat against our target so players don't skip him - Creature* Kilrek = ((Creature*)Unit::GetUnit(*m_creature, pInstance->GetData64(DATA_KILREK))); - if(Kilrek && (!Kilrek->SelectHostilTarget() && !Kilrek->getVictim())) - Kilrek->AddThreat(who, 1.0f); - - pInstance->SetData(DATA_TERESTIAN_EVENT, IN_PROGRESS); - }else ERROR_INST_DATA(m_creature); - } - - void KilledUnit(Unit *victim) - { - switch(rand()%2) - { - case 0: - DoYell(SAY_SLAY1, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_SLAY1); - break; - case 1: - DoYell(SAY_SLAY2, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_SLAY2); - break; - } - } - - void JustDied(Unit *killer) - { - for(uint8 i = 0; i < 2; ++i) - { - if(PortalGUID[i]) - { - Unit* Portal = Unit::GetUnit((*m_creature), PortalGUID[i]); - if(Portal) - Portal->DealDamage(Portal, Portal->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); - - PortalGUID[i] = 0; - } - } - - DoYell(SAY_DEATH, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_DEATH); - - if(pInstance) - pInstance->SetData(DATA_TERESTIAN_EVENT, DONE); - } - - void UpdateAI(const uint32 diff) - { - if(!m_creature->getVictim() && !m_creature->SelectHostilTarget()) - return; - - if(CheckKilrekTimer < diff) - { - CheckKilrekTimer = 5000; - - if(pInstance) - uint64 KilrekGUID = pInstance->GetData64(DATA_KILREK); - else ERROR_INST_DATA(m_creature); - - Creature* Kilrek = ((Creature*)Unit::GetUnit((*m_creature), KilrekGUID)); - if(SummonKilrek && Kilrek) - { - Kilrek->Respawn(); - Kilrek->AI()->AttackStart(m_creature->getVictim()); - - SummonKilrek = false; - } - - if(!Kilrek || !Kilrek->isAlive()) - { - SummonKilrek = true; - CheckKilrekTimer = 45000; - } - }else CheckKilrekTimer -= diff; - - if(SacrificeTimer < diff) - { - Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 1); - if(target && target->isAlive() && target->GetTypeId() == TYPEID_PLAYER) - { - DoCast(target, SPELL_SACRIFICE, true); - Creature* Chains = m_creature->SummonCreature(CREATURE_DEMONCHAINS, SACRIFICE_X, SACRIFICE_Y, SACRIFICE_Z, 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 21000); - if(Chains) - { - ((mob_demon_chainAI*)Chains->AI())->SacrificeGUID = target->GetGUID(); - Chains->CastSpell(Chains, SPELL_DEMON_CHAINS, true); - switch(rand()%2) - { - case 0: - DoYell(SAY_SACRIFICE1, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_SACRIFICE1); - break; - case 1: - DoYell(SAY_SACRIFICE2, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_SACRIFICE2); - break; - } - SacrificeTimer = 30000; - } - } - }else SacrificeTimer -= diff; - - if(ShadowboltTimer < diff) - { - DoCast(SelectUnit(SELECT_TARGET_TOPAGGRO, 0), SPELL_SHADOW_BOLT); - ShadowboltTimer = 10000; - }else ShadowboltTimer -= diff; - - if(SummonTimer < diff) - { - if(!SummonedPortals) - { - for(uint8 i = 0; i < 2; ++i) - { - Creature* Portal = m_creature->SummonCreature(CREATURE_PORTAL, PortalLocations[i][0], PortalLocations[i][1], PORTAL_Z, 0, TEMPSUMMON_CORPSE_DESPAWN, 0); - if(Portal) - PortalGUID[i] = Portal->GetGUID(); - } - SummonedPortals = true; - switch(rand()%2) - { - case 0: - DoYell(SAY_SUMMON1, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_SUMMON1); - break; - case 1: - DoYell(SAY_SUMMON2, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_SUMMON2); - break; - } - } - uint32 random = rand()%2; - Creature* Imp = m_creature->SummonCreature(CREATURE_FIENDISHIMP, PortalLocations[random][0], PortalLocations[random][1], PORTAL_Z, 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 15000); - if(Imp) - { - Imp->AddThreat(m_creature->getVictim(), 1.0f); - Imp->AI()->AttackStart(SelectUnit(SELECT_TARGET_RANDOM, 1)); - } - SummonTimer = 5000; - }else SummonTimer -= diff; - - if(!Berserk) - if(BerserkTimer < diff) - { - DoCast(m_creature, SPELL_BERSERK); - Berserk = true; - }else BerserkTimer -= diff; - - DoMeleeAttackIfReady(); - } -}; - -struct MANGOS_DLL_DECL mob_karazhan_impAI : public ScriptedAI -{ - mob_karazhan_impAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 FireboltTimer; - - void Reset() - { - FireboltTimer = 3000; - } - - void Aggro(Unit *who) {} - - void UpdateAI(const uint32 diff) - { - //Return since we have no target - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - if(FireboltTimer < diff) - { - DoCast(m_creature->getVictim(), SPELL_FIREBOLT); - FireboltTimer = 1500; - }else FireboltTimer -= diff; - - DoMeleeAttackIfReady(); - } -}; - -CreatureAI* GetAI_mob_kilrek(Creature *_Creature) -{ - return new mob_kilrekAI (_Creature); -} - -CreatureAI* GetAI_mob_karazhan_imp(Creature *_Creature) -{ - return new mob_karazhan_impAI (_Creature); -} - -CreatureAI* GetAI_mob_demon_chain(Creature *_Creature) -{ - return new mob_demon_chainAI(_Creature); -} - -CreatureAI* GetAI_boss_terestian_illhoof(Creature *_Creature) -{ - return new boss_terestianAI (_Creature); -} - -void AddSC_boss_terestian_illhoof() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_terestian_illhoof"; - newscript->GetAI = GetAI_boss_terestian_illhoof; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="mob_karazhan_imp"; - newscript->GetAI = GetAI_mob_karazhan_imp; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="mob_kilrek"; - newscript->GetAI = GetAI_mob_kilrek; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name = "mob_demon_chain"; - newscript->GetAI = GetAI_mob_demon_chain; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Terestian_Illhoof +SD%Complete: 100 +SDComment: Complete! +SDCategory: Karazhan +EndScriptData */ + +#include "precompiled.h" +#include "def_karazhan.h" + +#define SPELL_SUMMON_DEMONCHAINS 30120 // Summons demonic chains that maintain the ritual of sacrifice. +#define SPELL_DEMON_CHAINS 30206 // Instant - Visual Effect +#define SPELL_ENRAGE 23537 // Increases the caster's attack speed by 50% and the Physical damage it deals by 219 to 281 for 10 min. +#define SPELL_SHADOW_BOLT 30055 // Hurls a bolt of dark magic at an enemy, inflicting Shadow damage. +#define SPELL_SACRIFICE 30115 // Teleports and adds the debuff +#define SPELL_BERSERK 32965 // Increases attack speed by 75%. Periodically casts Shadow Bolt Volley. + +#define SPELL_FIREBOLT 18086 // Blasts a target for 150 Fire damage. + +#define SPELL_BROKEN_PACT 30065 // All damage taken increased by 25%. +#define SPELL_AMPLIFY_FLAMES 30053 // Increases the Fire damage taken by an enemy by 500 for 25 sec. +#define SPELL_FIREBOLT 18086 // Blasts a target for 150 Fire damage. + +#define SAY_SLAY1 "Your blood will anoint my circle." +#define SOUND_SLAY1 9264 +#define SAY_SLAY2 "The great one will be pleased." +#define SOUND_SLAY2 9329 + +#define SAY_DEATH "My life, is yours. Oh great one." +#define SOUND_DEATH 9262 + +#define SAY_AGGRO "Ah, you're just in time. The rituals are about to begin." +#define SOUND_AGGRO 9260 + +#define SAY_SACRIFICE1 "Please, accept this humble offering, oh great one." +#define SOUND_SACRIFICE1 9263 +#define SAY_SACRIFICE2 "Let the sacrifice serve his testament to my fealty." +#define SOUND_SACRIFICE2 9330 + +#define SAY_SUMMON1 "Come, you dwellers in the dark. Rally to my call!" +#define SOUND_SUMMON1 9265 +#define SAY_SUMMON2 "Gather, my pets. There is plenty for all." +#define SOUND_SUMMON2 9331 + +#define CREATURE_DEMONCHAINS 17248 +#define CREATURE_FIENDISHIMP 17267 +#define CREATURE_PORTAL 17265 + +#define SACRIFICE_X -11240.599 +#define SACRIFICE_Y -1694.2700 +#define SACRIFICE_Z 179.720007 + +#define PORTAL_Z 179.434 + +float PortalLocations[2][2]= +{ + {-11249.6933, -1704.61023}, + {-11242.1160, -1713.33325}, +}; + +struct MANGOS_DLL_DECL mob_kilrekAI : public ScriptedAI +{ + mob_kilrekAI(Creature *c) : ScriptedAI(c) + { + pInstance = ((ScriptedInstance*)c->GetInstanceData()); + Reset(); + } + + ScriptedInstance* pInstance; + + uint64 TerestianGUID; + + uint32 AmplifyTimer; + + void Reset() + { + TerestianGUID = 0; + + AmplifyTimer = 0; + } + + void Aggro(Unit *who) + { + if(!pInstance) + { + ERROR_INST_DATA(m_creature); + return; + } + + Creature* Terestian = ((Creature*)Unit::GetUnit(*m_creature, pInstance->GetData64(DATA_TERESTIAN))); + if(Terestian && (!Terestian->SelectHostilTarget() && !Terestian->getVictim())) + Terestian->AddThreat(who, 1.0f); + } + + void JustDied(Unit* Killer) + { + if(pInstance) + { + uint64 TerestianGUID = pInstance->GetData64(DATA_TERESTIAN); + if(TerestianGUID) + { + Unit* Terestian = Unit::GetUnit((*m_creature), TerestianGUID); + if(Terestian && Terestian->isAlive()) + DoCast(Terestian, SPELL_BROKEN_PACT, true); + } + }else ERROR_INST_DATA(m_creature); + } + + void UpdateAI(const uint32 diff) + { + //Return since we have no target + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + if (AmplifyTimer < diff) + { + m_creature->InterruptNonMeleeSpells(false); + DoCast(m_creature->getVictim(),SPELL_AMPLIFY_FLAMES); + + AmplifyTimer = 20000; + }else AmplifyTimer -= diff; + + //Chain cast + if (!m_creature->IsNonMeleeSpellCasted(false) && m_creature->IsWithinDistInMap(m_creature->getVictim(), 30)) + DoCast(m_creature->getVictim(),SPELL_FIREBOLT); + else DoMeleeAttackIfReady(); + } +}; + +struct MANGOS_DLL_DECL mob_demon_chainAI : public ScriptedAI +{ + mob_demon_chainAI(Creature *c) : ScriptedAI(c) + { + Reset(); + } + + uint64 SacrificeGUID; + + void Reset() + { + SacrificeGUID = 0; + } + + void Aggro(Unit* who) {} + void AttackStart(Unit* who) {} + void MoveInLineOfSight(Unit* who) {} + + void JustDied(Unit *killer) + { + if(SacrificeGUID) + { + Unit* Sacrifice = Unit::GetUnit((*m_creature),SacrificeGUID); + if(Sacrifice) + Sacrifice->RemoveAurasDueToSpell(SPELL_SACRIFICE); + } + } +}; + +struct MANGOS_DLL_DECL boss_terestianAI : public ScriptedAI +{ + boss_terestianAI(Creature *c) : ScriptedAI(c) + { + pInstance = ((ScriptedInstance*)c->GetInstanceData()); + Reset(); + } + + ScriptedInstance *pInstance; + + uint64 KilrekGUID; + uint64 PortalGUID[2]; + + uint32 CheckKilrekTimer; + uint32 SacrificeTimer; + uint32 ShadowboltTimer; + uint32 SummonTimer; + uint32 BerserkTimer; + + bool SummonKilrek; + bool SummonedPortals; + bool Berserk; + + void Reset() + { + for(uint8 i = 0; i < 2; ++i) + { + if(PortalGUID[i]) + { + Unit* Portal = Unit::GetUnit((*m_creature), PortalGUID[i]); + if(Portal) + Portal->DealDamage(Portal, Portal->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); + + PortalGUID[i] = 0; + } + } + + CheckKilrekTimer = 5000; + SacrificeTimer = 30000; + ShadowboltTimer = 5000; + SummonTimer = 10000; + BerserkTimer = 600000; + + SummonedPortals = false; + Berserk = false; + + if(pInstance) + pInstance->SetData(DATA_TERESTIAN_EVENT, NOT_STARTED); + } + + void Aggro(Unit* who) + { + DoYell(SAY_AGGRO, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_AGGRO); + + if(pInstance) + { + // Put Kil'rek in combat against our target so players don't skip him + Creature* Kilrek = ((Creature*)Unit::GetUnit(*m_creature, pInstance->GetData64(DATA_KILREK))); + if(Kilrek && (!Kilrek->SelectHostilTarget() && !Kilrek->getVictim())) + Kilrek->AddThreat(who, 1.0f); + + pInstance->SetData(DATA_TERESTIAN_EVENT, IN_PROGRESS); + }else ERROR_INST_DATA(m_creature); + } + + void KilledUnit(Unit *victim) + { + switch(rand()%2) + { + case 0: + DoYell(SAY_SLAY1, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_SLAY1); + break; + case 1: + DoYell(SAY_SLAY2, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_SLAY2); + break; + } + } + + void JustDied(Unit *killer) + { + for(uint8 i = 0; i < 2; ++i) + { + if(PortalGUID[i]) + { + Unit* Portal = Unit::GetUnit((*m_creature), PortalGUID[i]); + if(Portal) + Portal->DealDamage(Portal, Portal->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); + + PortalGUID[i] = 0; + } + } + + DoYell(SAY_DEATH, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_DEATH); + + if(pInstance) + pInstance->SetData(DATA_TERESTIAN_EVENT, DONE); + } + + void UpdateAI(const uint32 diff) + { + if(!m_creature->getVictim() && !m_creature->SelectHostilTarget()) + return; + + if(CheckKilrekTimer < diff) + { + CheckKilrekTimer = 5000; + + if(pInstance) + uint64 KilrekGUID = pInstance->GetData64(DATA_KILREK); + else ERROR_INST_DATA(m_creature); + + Creature* Kilrek = ((Creature*)Unit::GetUnit((*m_creature), KilrekGUID)); + if(SummonKilrek && Kilrek) + { + Kilrek->Respawn(); + Kilrek->AI()->AttackStart(m_creature->getVictim()); + + SummonKilrek = false; + } + + if(!Kilrek || !Kilrek->isAlive()) + { + SummonKilrek = true; + CheckKilrekTimer = 45000; + } + }else CheckKilrekTimer -= diff; + + if(SacrificeTimer < diff) + { + Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 1); + if(target && target->isAlive() && target->GetTypeId() == TYPEID_PLAYER) + { + DoCast(target, SPELL_SACRIFICE, true); + Creature* Chains = m_creature->SummonCreature(CREATURE_DEMONCHAINS, SACRIFICE_X, SACRIFICE_Y, SACRIFICE_Z, 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 21000); + if(Chains) + { + ((mob_demon_chainAI*)Chains->AI())->SacrificeGUID = target->GetGUID(); + Chains->CastSpell(Chains, SPELL_DEMON_CHAINS, true); + switch(rand()%2) + { + case 0: + DoYell(SAY_SACRIFICE1, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_SACRIFICE1); + break; + case 1: + DoYell(SAY_SACRIFICE2, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_SACRIFICE2); + break; + } + SacrificeTimer = 30000; + } + } + }else SacrificeTimer -= diff; + + if(ShadowboltTimer < diff) + { + DoCast(SelectUnit(SELECT_TARGET_TOPAGGRO, 0), SPELL_SHADOW_BOLT); + ShadowboltTimer = 10000; + }else ShadowboltTimer -= diff; + + if(SummonTimer < diff) + { + if(!SummonedPortals) + { + for(uint8 i = 0; i < 2; ++i) + { + Creature* Portal = m_creature->SummonCreature(CREATURE_PORTAL, PortalLocations[i][0], PortalLocations[i][1], PORTAL_Z, 0, TEMPSUMMON_CORPSE_DESPAWN, 0); + if(Portal) + PortalGUID[i] = Portal->GetGUID(); + } + SummonedPortals = true; + switch(rand()%2) + { + case 0: + DoYell(SAY_SUMMON1, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_SUMMON1); + break; + case 1: + DoYell(SAY_SUMMON2, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_SUMMON2); + break; + } + } + uint32 random = rand()%2; + Creature* Imp = m_creature->SummonCreature(CREATURE_FIENDISHIMP, PortalLocations[random][0], PortalLocations[random][1], PORTAL_Z, 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 15000); + if(Imp) + { + Imp->AddThreat(m_creature->getVictim(), 1.0f); + Imp->AI()->AttackStart(SelectUnit(SELECT_TARGET_RANDOM, 1)); + } + SummonTimer = 5000; + }else SummonTimer -= diff; + + if(!Berserk) + if(BerserkTimer < diff) + { + DoCast(m_creature, SPELL_BERSERK); + Berserk = true; + }else BerserkTimer -= diff; + + DoMeleeAttackIfReady(); + } +}; + +struct MANGOS_DLL_DECL mob_karazhan_impAI : public ScriptedAI +{ + mob_karazhan_impAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 FireboltTimer; + + void Reset() + { + FireboltTimer = 3000; + } + + void Aggro(Unit *who) {} + + void UpdateAI(const uint32 diff) + { + //Return since we have no target + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + if(FireboltTimer < diff) + { + DoCast(m_creature->getVictim(), SPELL_FIREBOLT); + FireboltTimer = 1500; + }else FireboltTimer -= diff; + + DoMeleeAttackIfReady(); + } +}; + +CreatureAI* GetAI_mob_kilrek(Creature *_Creature) +{ + return new mob_kilrekAI (_Creature); +} + +CreatureAI* GetAI_mob_karazhan_imp(Creature *_Creature) +{ + return new mob_karazhan_impAI (_Creature); +} + +CreatureAI* GetAI_mob_demon_chain(Creature *_Creature) +{ + return new mob_demon_chainAI(_Creature); +} + +CreatureAI* GetAI_boss_terestian_illhoof(Creature *_Creature) +{ + return new boss_terestianAI (_Creature); +} + +void AddSC_boss_terestian_illhoof() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_terestian_illhoof"; + newscript->GetAI = GetAI_boss_terestian_illhoof; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="mob_karazhan_imp"; + newscript->GetAI = GetAI_mob_karazhan_imp; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="mob_kilrek"; + newscript->GetAI = GetAI_mob_kilrek; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name = "mob_demon_chain"; + newscript->GetAI = GetAI_mob_demon_chain; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/karazhan/bosses_opera.cpp b/src/bindings/scripts/scripts/zone/karazhan/bosses_opera.cpp index 3caedb2dafa..2cd3f9d3c56 100644 --- a/src/bindings/scripts/scripts/zone/karazhan/bosses_opera.cpp +++ b/src/bindings/scripts/scripts/zone/karazhan/bosses_opera.cpp @@ -1,1471 +1,1471 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Bosses_Opera -SD%Complete: 90 -SDComment: Oz, Hood, and RAJ event implemented. RAJ event requires more testing. -SDCategory: Karazhan -EndScriptData */ - -#include "precompiled.h" -#include "def_karazhan.h" - -/***********************************/ -/*** OPERA WIZARD OF OZ EVENT *****/ -/*********************************/ - -/**** Spells ****/ -// Dorothee -#define SPELL_WATERBOLT 31012 -#define SPELL_SCREAM 31013 -#define SPELL_SUMMONTITO 31014 - -// Tito -#define SPELL_YIPPING 31015 - -// Strawman -#define SPELL_BRAIN_BASH 31046 -#define SPELL_BRAIN_WIPE 31069 -#define SPELL_BURNING_STRAW 31075 - -// Tinhead -#define SPELL_CLEAVE 31043 -#define SPELL_RUST 31086 - -// Roar -#define SPELL_MANGLE 31041 -#define SPELL_SHRED 31042 -#define SPELL_FRIGHTENED_SCREAM 31013 - -// Crone -#define SPELL_CHAIN_LIGHTNING 32337 - -// Cyclone -#define SPELL_KNOCKBACK 32334 -#define SPELL_CYCLONE_VISUAL 32332 - -/** Creature Entries **/ -#define CREATURE_TITO 17548 -#define CREATURE_CYCLONE 18412 -#define CREATURE_CRONE 18168 - -/***** Speech and Sound *****/ -#define SAY_DOROTHEE_DEATH "Oh at last, at last. I can go home." -#define SOUND_DOROTHEE_DEATH 9190 -#define SAY_DOROTHEE_SUMMON "Don't let them hurt us, Tito! Oh, you won't, will you?" -#define SOUND_DOROTHEE_SUMMON 9191 -#define SAY_DOROTHEE_TITO_DEATH "Tito, oh Tito, no!" -#define SOUND_DOROTHEE_TITO_DEATH 9192 -#define SAY_DOROTHEE_AGGRO "Oh dear, we simply must find a way home! The old wizard could be our only hope! Strawman, Roar, Tinhead, will you... wait! Oh golly, look! We have visitors!" -#define SOUND_DOROTHEE_AGGRO 9195 - -#define SAY_ROAR_AGGRO "Wanna fight? Huh? Do ya? C'mon, I'll fight you with both claws behind my back!" -#define SOUND_ROAR_AGGRO 9227 -#define SAY_ROAR_DEATH "You didn't have to go and do that." -#define SOUND_ROAR_DEATH 9229 -#define SAY_ROAR_SLAY "I think I'm going to go take fourty winks" -#define SOUND_ROAR_SLAY 9230 - -#define SAY_STRAWMAN_AGGRO "Now what should I do with you? I simply can't make up my mind." -#define SOUND_STRAWMAN_AGGRO 9254 -#define SAY_STRAWMAN_DEATH "Don't let them make a mattress... out of me." -#define SOUND_STRAWMAN_DEATH 9256 -#define SAY_STRAWMAN_SLAY "I guess I'm not a failure after all." -#define SOUND_STRAWMAN_SLAY 9257 - -#define SAY_TINHEAD_AGGRO "I could really use a heart. Say, can I have yours?" -#define SOUND_TINHEAD_AGGRO 9268 -#define SAY_TINHEAD_DEATH "Back to being an old rustbucket." -#define SOUND_TINHEAD_DEATH 9270 -#define SAY_TINHEAD_SLAY "Guess I'm not so rusty, after all." -#define SOUND_TINHEAD_SLAY 9271 - -#define SAY_CRONE_AGGRO "Woe to each and every one of you my pretties!" -#define SOUND_CRONE_AGGRO 9179 -#define SAY_CRONE_AGGRO2 "It will all be over soon!" -#define SOUND_CRONE_AGGRO2 9307 -#define SAY_CRONE_DEATH "How could you? What a cruel, cruel world!" -#define SOUND_CRONE_DEATH 9178 -#define SAY_CRONE_SLAY "Fixed you, didn't I?" -#define SOUND_CRONE_SLAY 9180 - -void SummonCroneIfReady(ScriptedInstance* pInstance, Creature *_Creature) -{ - pInstance->SetData(DATA_OPERA_OZ_DEATHCOUNT, 0); // Increment DeathCount - if(pInstance->GetData(DATA_OPERA_OZ_DEATHCOUNT) == 4) - { - Creature* Crone = _Creature->SummonCreature(CREATURE_CRONE, -10891.96, -1755.95, _Creature->GetPositionZ(), 4.64, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 30000); - if(Crone) - { - if(_Creature->getVictim()) - Crone->AI()->AttackStart(_Creature->getVictim()); - - Crone->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); - } - } -}; - -struct MANGOS_DLL_DECL boss_dorotheeAI : public ScriptedAI -{ - boss_dorotheeAI(Creature* c) : ScriptedAI(c) - { - pInstance = ((ScriptedInstance*)c->GetInstanceData()); - Reset(); - } - - ScriptedInstance* pInstance; - - uint32 AggroTimer; - - uint32 WaterBoltTimer; - uint32 FearTimer; - uint32 SummonTitoTimer; - - bool SummonedTito; - bool TitoDied; - bool InCombat; - - void Reset() - { - AggroTimer = 500; - - WaterBoltTimer = 5000; - FearTimer = 15000; - SummonTitoTimer = 47500; - - SummonedTito = false; - TitoDied = false; - InCombat = false; - } - - void Aggro(Unit* who) - { - DoYell(SAY_DOROTHEE_AGGRO, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_DOROTHEE_AGGRO); - } - - void SummonTito(); // See below - - void JustDied(Unit* killer) - { - DoYell(SAY_DOROTHEE_DEATH, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_DOROTHEE_DEATH); - - if(pInstance) - SummonCroneIfReady(pInstance, m_creature); - } - - void AttackStart(Unit* who) - { - if(m_creature->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE)) - return; - - ScriptedAI::AttackStart(who); - } - - void MoveInLineOfSight(Unit* who) - { - if(m_creature->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE)) - return; - - ScriptedAI::MoveInLineOfSight(who); - } - - void UpdateAI(const uint32 diff) - { - if(AggroTimer) - if(AggroTimer <= diff) - { - m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); - AggroTimer = 0; - }else AggroTimer -= diff; - - if(!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - if(WaterBoltTimer < diff) - { - DoCast(SelectUnit(SELECT_TARGET_RANDOM, 0), SPELL_WATERBOLT); - WaterBoltTimer = TitoDied ? 1500 : 5000; - }else WaterBoltTimer -= diff; - - if(FearTimer < diff) - { - DoCast(m_creature->getVictim(), SPELL_SCREAM); - FearTimer = 30000; - }else FearTimer -= diff; - - if(!SummonedTito) - { - if(SummonTitoTimer < diff) - SummonTito(); - else SummonTitoTimer -= diff; - } - - DoMeleeAttackIfReady(); - } -}; - -struct MANGOS_DLL_DECL mob_titoAI : public ScriptedAI -{ - mob_titoAI(Creature* c) : ScriptedAI(c) - { - Reset(); - } - - uint64 DorotheeGUID; - - uint32 YipTimer; - - void Reset() - { - DorotheeGUID = 0; - - YipTimer = 10000; - } - - void Aggro(Unit* who) {} - - void JustDied(Unit* killer) - { - if(DorotheeGUID) - { - Creature* Dorothee = ((Creature*)Unit::GetUnit((*m_creature), DorotheeGUID)); - if(Dorothee && Dorothee->isAlive()) - { - ((boss_dorotheeAI*)Dorothee->AI())->TitoDied = true; - Dorothee->MonsterYell(SAY_DOROTHEE_TITO_DEATH, LANG_UNIVERSAL, 0); - DoPlaySoundToSet(Dorothee, SOUND_DOROTHEE_TITO_DEATH); - } - } - } - - void UpdateAI(const uint32 diff) - { - if(!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - if(YipTimer < diff) - { - DoCast(m_creature->getVictim(), SPELL_YIPPING); - YipTimer = 10000; - }else YipTimer -= diff; - - DoMeleeAttackIfReady(); - } -}; - -void boss_dorotheeAI::SummonTito() -{ - Creature* Tito = DoSpawnCreature(CREATURE_TITO, 0, 0, 0, 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 45000); - if(Tito) - { - DoYell(SAY_DOROTHEE_SUMMON, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_DOROTHEE_SUMMON); - ((mob_titoAI*)Tito->AI())->DorotheeGUID = m_creature->GetGUID(); - Tito->AI()->AttackStart(m_creature->getVictim()); - SummonedTito = true; - TitoDied = false; - } -} - -struct MANGOS_DLL_DECL boss_strawmanAI : public ScriptedAI -{ - boss_strawmanAI(Creature* c) : ScriptedAI(c) - { - pInstance = ((ScriptedInstance*)c->GetInstanceData()); - Reset(); - } - - ScriptedInstance* pInstance; - - uint32 AggroTimer; - uint32 BrainBashTimer; - uint32 BrainWipeTimer; - - void Reset() - { - AggroTimer = 13000; - BrainBashTimer = 5000; - BrainWipeTimer = 7000; - } - - void AttackStart(Unit* who) - { - if(m_creature->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE)) - return; - - ScriptedAI::AttackStart(who); - } - - void MoveInLineOfSight(Unit* who) - { - if(m_creature->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE)) - return; - - ScriptedAI::MoveInLineOfSight(who); - } - - void Aggro(Unit* who) - { - DoYell(SAY_STRAWMAN_AGGRO, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_STRAWMAN_AGGRO); - } - - void SpellHit(Unit* caster, const SpellEntry *Spell) - { - if((Spell->SchoolMask == SPELL_SCHOOL_MASK_FIRE) && (!(rand()%10))) - DoCast(m_creature, SPELL_BURNING_STRAW, true); - } - - void JustDied(Unit* killer) - { - DoYell(SAY_STRAWMAN_DEATH, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_STRAWMAN_DEATH); - - if(pInstance) - SummonCroneIfReady(pInstance, m_creature); - } - - void KilledUnit(Unit* victim) - { - DoYell(SAY_STRAWMAN_SLAY, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_STRAWMAN_SLAY); - } - - void UpdateAI(const uint32 diff) - { - if(AggroTimer) - if(AggroTimer <= diff) - { - m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); - AggroTimer = 0; - }else AggroTimer -= diff; - - if(!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - if(BrainBashTimer < diff) - { - DoCast(m_creature->getVictim(), SPELL_BRAIN_BASH); - BrainBashTimer = 15000; - }else BrainBashTimer -= diff; - - if(BrainWipeTimer < diff) - { - DoCast(SelectUnit(SELECT_TARGET_RANDOM, 0), SPELL_BRAIN_WIPE); - BrainWipeTimer = 20000; - }else BrainWipeTimer -= diff; - - DoMeleeAttackIfReady(); - } -}; - -struct MANGOS_DLL_DECL boss_tinheadAI : public ScriptedAI -{ - boss_tinheadAI(Creature* c) : ScriptedAI(c) - { - pInstance = ((ScriptedInstance*)c->GetInstanceData()); - Reset(); - } - - ScriptedInstance* pInstance; - - uint32 AggroTimer; - uint32 CleaveTimer; - uint32 RustTimer; - - uint8 RustCount; - - void Reset() - { - AggroTimer = 15000; - CleaveTimer = 5000; - RustTimer = 30000; - - RustCount = 0; - } - - void Aggro(Unit* who) - { - DoYell(SAY_TINHEAD_AGGRO, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_TINHEAD_AGGRO); - } - - void AttackStart(Unit* who) - { - if(m_creature->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE)) - return; - - ScriptedAI::AttackStart(who); - } - - void MoveInLineOfSight(Unit* who) - { - if(m_creature->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE)) - return; - - ScriptedAI::MoveInLineOfSight(who); - } - - void JustDied(Unit* killer) - { - DoYell(SAY_TINHEAD_DEATH, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_TINHEAD_DEATH); - - if(pInstance) - SummonCroneIfReady(pInstance, m_creature); - } - - void KilledUnit(Unit* victim) - { - DoYell(SAY_TINHEAD_SLAY, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_TINHEAD_SLAY); - } - - void UpdateAI(const uint32 diff) - { - if(AggroTimer) - if(AggroTimer < diff) - { - m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); - AggroTimer = 0; - }else AggroTimer -= diff; - - if(!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - if(CleaveTimer < diff) - { - DoCast(m_creature->getVictim(), SPELL_CLEAVE); - CleaveTimer = 5000; - }else CleaveTimer -= diff; - - if(RustCount < 8) - { - if(RustTimer < diff) - { - RustCount++; - DoTextEmote("begins to rust", NULL); - DoCast(m_creature, SPELL_RUST); - RustTimer = 6000; - }else RustTimer -= diff; - } - - DoMeleeAttackIfReady(); - } -}; - -struct MANGOS_DLL_DECL boss_roarAI : public ScriptedAI -{ - boss_roarAI(Creature* c) : ScriptedAI(c) - { - pInstance = ((ScriptedInstance*)c->GetInstanceData()); - Reset(); - } - - ScriptedInstance* pInstance; - - uint32 AggroTimer; - uint32 MangleTimer; - uint32 ShredTimer; - uint32 ScreamTimer; - - void Reset() - { - AggroTimer = 20000; - MangleTimer = 5000; - ShredTimer = 10000; - ScreamTimer = 15000; - } - - void MoveInLineOfSight(Unit* who) - { - if(m_creature->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE)) - return; - - ScriptedAI::MoveInLineOfSight(who); - } - - void AttackStart(Unit* who) - { - if(m_creature->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE)) - return; - - ScriptedAI::AttackStart(who); - } - - void Aggro(Unit* who) - { - DoYell(SAY_ROAR_AGGRO, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_ROAR_AGGRO); - } - - void JustDied(Unit* killer) - { - DoYell(SAY_ROAR_DEATH, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_ROAR_DEATH); - - if(pInstance) - SummonCroneIfReady(pInstance, m_creature); - } - - void KilledUnit(Unit* victim) - { - DoYell(SAY_ROAR_SLAY, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_ROAR_SLAY); - } - - void UpdateAI(const uint32 diff) - { - if(AggroTimer) - if(AggroTimer <= diff) - { - m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); - AggroTimer = 0; - }else AggroTimer -= diff; - - if(!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - if(MangleTimer < diff) - { - DoCast(m_creature->getVictim(), SPELL_MANGLE); - MangleTimer = 5000 + rand()%3000; - }else MangleTimer -= diff; - - if(ShredTimer < diff) - { - DoCast(m_creature->getVictim(), SPELL_SHRED); - ShredTimer = 10000 + rand()%5000; - }else ShredTimer -= diff; - - if(ScreamTimer < diff) - { - DoCast(m_creature->getVictim(), SPELL_FRIGHTENED_SCREAM); - ScreamTimer = 20000 + rand()%10000; - }else ScreamTimer -= diff; - - DoMeleeAttackIfReady(); - } -}; - -struct MANGOS_DLL_DECL boss_croneAI : public ScriptedAI -{ - boss_croneAI(Creature* c) : ScriptedAI(c) - { - pInstance = ((ScriptedInstance*)c->GetInstanceData()); - Reset(); - } - - ScriptedInstance* pInstance; - - uint32 CycloneTimer; - uint32 ChainLightningTimer; - - void Reset() - { - CycloneTimer = 30000; - ChainLightningTimer = 10000; - } - - void Aggro(Unit* who) - { - switch(rand()%2) - { - case 0: - DoYell(SAY_CRONE_AGGRO, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_CRONE_AGGRO); - break; - case 1: - DoYell(SAY_CRONE_AGGRO2, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_CRONE_AGGRO2); - break; - } - m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); - } - - void JustDied(Unit* killer) - { - DoYell(SAY_CRONE_DEATH, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_CRONE_DEATH); - - if(pInstance) - { - pInstance->SetData(DATA_OPERA_EVENT, DONE); - GameObject* Door = GameObject::GetGameObject((*m_creature), pInstance->GetData64(DATA_GAMEOBJECT_STAGEDOORRIGHT)); - if(Door) - Door->UseDoorOrButton(); - } - } - - void UpdateAI(const uint32 diff) - { - if(!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - if(m_creature->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE)) - m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); - - if(CycloneTimer < diff) - { - Creature* Cyclone = DoSpawnCreature(CREATURE_CYCLONE, rand()%10, rand()%10, 0, 0, TEMPSUMMON_TIMED_DESPAWN, 15000); - if(Cyclone) - Cyclone->CastSpell(Cyclone, SPELL_CYCLONE_VISUAL, true); - CycloneTimer = 30000; - }else CycloneTimer -= diff; - - if(ChainLightningTimer < diff) - { - DoCast(m_creature->getVictim(), SPELL_CHAIN_LIGHTNING); - ChainLightningTimer = 15000; - }else ChainLightningTimer -= diff; - - DoMeleeAttackIfReady(); - } -}; - -struct MANGOS_DLL_DECL mob_cycloneAI : public ScriptedAI -{ - mob_cycloneAI(Creature* c) : ScriptedAI(c) - { - Reset(); - } - - uint32 MoveTimer; - - void Reset() - { - MoveTimer = 1000; - } - - void Aggro(Unit* who) {} - - void MoveInLineOfSight(Unit* who) - { - } - - void UpdateAI(const uint32 diff) - { - if(!m_creature->HasAura(SPELL_KNOCKBACK, 0)) - DoCast(m_creature, SPELL_KNOCKBACK, true); - - if(MoveTimer < diff) - { - float x,y,z; - m_creature->GetPosition(x,y,z); - float PosX, PosY, PosZ; - m_creature->GetRandomPoint(x,y,z,10, PosX, PosY, PosZ); - m_creature->GetMotionMaster()->MovePoint(0, PosX, PosY, PosZ); - MoveTimer = 5000 + rand()%3000; - }else MoveTimer -= diff; - } -}; - -CreatureAI* GetAI_boss_dorothee(Creature* _Creature) -{ - return new boss_dorotheeAI(_Creature); -} - -CreatureAI* GetAI_boss_strawman(Creature* _Creature) -{ - return new boss_strawmanAI(_Creature); -} - -CreatureAI* GetAI_boss_tinhead(Creature* _Creature) -{ - return new boss_tinheadAI(_Creature); -} - -CreatureAI* GetAI_boss_roar(Creature* _Creature) -{ - return new boss_roarAI(_Creature); -} - -CreatureAI* GetAI_boss_crone(Creature* _Creature) -{ - return new boss_croneAI(_Creature); -} - -CreatureAI* GetAI_mob_tito(Creature* _Creature) -{ - return new mob_titoAI(_Creature); -} - -CreatureAI* GetAI_mob_cyclone(Creature* _Creature) -{ - return new mob_cycloneAI(_Creature); -} - -/**************************************/ -/**** Opera Red Riding Hood Event ****/ -/************************************/ - -#define GOSSIP_GRANDMA "What phat lewtz you have grandmother?" - -/**** Spells For The Wolf ****/ -#define SPELL_LITTLE_RED_RIDING_HOOD 30768 -#define SPELL_TERRIFYING_HOWL 30752 -#define SPELL_WIDE_SWIPE 30761 - -/**** Yells for the Wolf ****/ -#define SAY_WOLF_AGGRO "All the better to own you with!" -#define SOUND_WOLF_AGGRO 9276 -#define SOUND_WOLF_DEATH 9275 // No speech -#define SAY_WOLF_SLAY "Mmmm... delicious." -#define SOUND_WOLF_SLAY 9277 -#define SAY_WOLF_HOOD "Run away little girl, run away!" -#define SOUND_WOLF_HOOD 9278 - -/**** The Wolf's Entry ****/ -#define CREATURE_BIG_BAD_WOLF 17521 - -bool GossipHello_npc_grandmother(Player* player, Creature* _Creature) -{ - player->ADD_GOSSIP_ITEM(0, GOSSIP_GRANDMA, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF); - player->SEND_GOSSIP_MENU(8990, _Creature->GetGUID()); - - return true; -} - -bool GossipSelect_npc_grandmother(Player* player, Creature* _Creature, uint32 sender, uint32 action) -{ - if(action == GOSSIP_ACTION_INFO_DEF) - { - _Creature->SetVisibility(VISIBILITY_OFF); - float x,y,z; - _Creature->GetPosition(x,y,z); - Creature* BigBadWolf = _Creature->SummonCreature(CREATURE_BIG_BAD_WOLF, x, y, z, 0, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 30000); - if(BigBadWolf) - { - BigBadWolf->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); - BigBadWolf->AI()->AttackStart(player); - } - - _Creature->setDeathState(JUST_DIED); - } - - return true; -} - -struct MANGOS_DLL_DECL boss_bigbadwolfAI : public ScriptedAI -{ - boss_bigbadwolfAI(Creature* c) : ScriptedAI(c) - { - pInstance = ((ScriptedInstance*)c->GetInstanceData()); - Reset(); - } - - ScriptedInstance* pInstance; - - uint32 ChaseTimer; - uint32 FearTimer; - uint32 SwipeTimer; - - uint64 HoodGUID; - float TempThreat; - - bool IsChasing; - - void Reset() - { - ChaseTimer = 30000; - FearTimer = 25000 + rand()%10000; - SwipeTimer = 5000; - - HoodGUID = 0; - TempThreat = 0; - - IsChasing = false; - } - - void Aggro(Unit* who) - { - DoYell(SAY_WOLF_AGGRO, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_WOLF_AGGRO); - } - - void JustDied(Unit* killer) - { - DoPlaySoundToSet(m_creature, SOUND_WOLF_DEATH); - - if(pInstance) - { - pInstance->SetData(DATA_OPERA_EVENT, DONE); - GameObject* Door = GameObject::GetGameObject((*m_creature), pInstance->GetData64(DATA_GAMEOBJECT_STAGEDOORRIGHT)); - if(Door) - Door->UseDoorOrButton(); - } - } - - void UpdateAI(const uint32 diff) - { - if(!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - DoMeleeAttackIfReady(); - - if(ChaseTimer < diff) - { - if(!IsChasing) - { - Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0); - if(target && target->GetTypeId() == TYPEID_PLAYER) - { - DoYell(SAY_WOLF_HOOD, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_WOLF_HOOD); - - DoCast(target, SPELL_LITTLE_RED_RIDING_HOOD, true); - TempThreat = m_creature->getThreatManager().getThreat(target); - if(TempThreat) - m_creature->getThreatManager().modifyThreatPercent(target, -100); - HoodGUID = target->GetGUID(); - m_creature->AddThreat(target, 1000000.0f); - ChaseTimer = 20000; - IsChasing = true; - } - } - else - { - IsChasing = false; - Unit* target = Unit::GetUnit((*m_creature), HoodGUID); - if(target) - { - HoodGUID = 0; - if(m_creature->getThreatManager().getThreat(target)) - m_creature->getThreatManager().modifyThreatPercent(target, -100); - m_creature->AddThreat(target, TempThreat); - TempThreat = 0; - } - - ChaseTimer = 40000; - } - }else ChaseTimer -= diff; - - if(IsChasing) - return; - - if(FearTimer < diff) - { - DoCast(m_creature->getVictim(), SPELL_TERRIFYING_HOWL); - FearTimer = 25000 + rand()%35000; - }else FearTimer -= diff; - - if(SwipeTimer < diff) - { - DoCast(m_creature->getVictim(), SPELL_WIDE_SWIPE); - SwipeTimer = 25000 + rand()%5000; - }else SwipeTimer -= diff; - - } -}; - -CreatureAI* GetAI_boss_bigbadwolf(Creature* _Creature) -{ - return new boss_bigbadwolfAI(_Creature); -} - -/**********************************************/ -/******** Opera Romeo and Juliet Event *******/ -/********************************************/ - -/***** Spells For Julianne *****/ -#define SPELL_BLINDING_PASSION 30890 -#define SPELL_DEVOTION 30887 -#define SPELL_ETERNAL_AFFECTION 30878 -#define SPELL_POWERFUL_ATTRACTION 30889 -#define SPELL_DRINK_POISON 30907 - -/***** Spells For Romulo ****/ -#define SPELL_BACKWARD_LUNGE 30815 -#define SPELL_DARING 30841 -#define SPELL_DEADLY_SWATHE 30817 -#define SPELL_POISON_THRUST 30822 - -/**** Other Misc. Spells ****/ -#define SPELL_UNDYING_LOVE 30951 -#define SPELL_RES_VISUAL 24171 - -/**** Speech and Text *****/ -/****** Julianne *******/ -#define SAY_JULIANNE_AGGRO "What devil art thou, that dost torment me thus?" -#define SOUND_JULIANNE_AGGRO 9196 -#define SAY_JULIANNE_ENTER "Where is my lord? Where is my Romulo?" -#define SOUND_JULIANNE_ENTER 9199 -#define SAY_JULIANNE_DEATH01 "Romulo, I come! Oh... this do I drink to thee!" -#define SOUND_JULIANNE_DEATH01 9198 -#define SAY_JULIANNE_DEATH02 "Where is my Lord? Where is my Romulo? Ohh, happy dagger! This is thy sheath! There rust, and let me die!" -#define SOUND_JULIANNE_DEATH02 9310 -#define SAY_JULIANNE_RESURRECT "Come, gentle night; and give me back my Romulo!" -#define SOUND_JULIANNE_RESURRECT 9200 -#define SAY_JULIANNE_SLAY "Parting is such sweet sorrow." -#define SOUND_JULIANNE_SLAY 9201 - -/****** Romulo *******/ -#define SAY_ROMULO_AGGRO "Wilt thou provoke me? Then have at thee, boy!" -#define SOUND_ROMULO_AGGRO 9233 -#define SAY_ROMULO_DEATH "Thou smilest... upon the stroke that... murders me." -#define SOUND_ROMULO_DEATH 9235 -#define SAY_ROMULO_ENTER "This day's black fate on more days doth depend. This but begins the woe. Others must end." -#define SOUND_ROMULO_ENTER 9236 -#define SAY_ROMULO_RESURRECT "Thou detestable maw, thou womb of death; I enforce thy rotten jaws to open!" -#define SOUND_ROMULO_RESURRECT 9237 -#define SAY_ROMULO_SLAY "How well my comfort is revived by this!" -#define SOUND_ROMULO_SLAY 9238 - -/*** Misc. Information ****/ -#define CREATURE_ROMULO 17533 -#define ROMULO_X -10900 -#define ROMULO_Y -1758 - -enum RAJPhase -{ - PHASE_JULIANNE = 0, - PHASE_ROMULO = 1, - PHASE_BOTH = 2, -}; - -void PretendToDie(Creature* _Creature) -{ - _Creature->InterruptNonMeleeSpells(false); - _Creature->SetHealth(0); - _Creature->StopMoving(); - _Creature->ClearComboPointHolders(); - _Creature->RemoveAllAurasOnDeath(); - _Creature->ModifyAuraState(AURA_STATE_HEALTHLESS_20_PERCENT, false); - _Creature->ModifyAuraState(AURA_STATE_HEALTHLESS_35_PERCENT, false); - _Creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - _Creature->ClearAllReactives(); - _Creature->SetUInt64Value(UNIT_FIELD_TARGET,0); - _Creature->GetMotionMaster()->Clear(); - _Creature->GetMotionMaster()->MoveIdle(); - _Creature->SetUInt32Value(UNIT_FIELD_BYTES_1,PLAYER_STATE_DEAD); -}; - -void Resurrect(Creature* target) -{ - target->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - target->SetHealth(target->GetMaxHealth()); - target->SetUInt32Value(UNIT_FIELD_BYTES_1, 0); - target->CastSpell(target, SPELL_RES_VISUAL, true); - if(target->getVictim()) - { - target->SetUInt64Value(UNIT_FIELD_TARGET, target->getVictim()->GetGUID()); - target->GetMotionMaster()->MoveChase(target->getVictim()); - target->AI()->AttackStart(target->getVictim()); - } -}; - -struct MANGOS_DLL_DECL boss_julianneAI : public ScriptedAI -{ - boss_julianneAI(Creature* c) : ScriptedAI(c) - { - pInstance = ((ScriptedInstance*)c->GetInstanceData()); - EntryYellTimer = 1000; - AggroYellTimer = 10000; - Reset(); - } - - ScriptedInstance* pInstance; - - uint64 RomuloGUID; - - uint32 Phase; - - uint32 EntryYellTimer; - uint32 AggroYellTimer; - uint32 BlindingPassionTimer; - uint32 DevotionTimer; - uint32 EternalAffectionTimer; - uint32 PowerfulAttractionTimer; - uint32 SummonRomuloTimer; - uint32 ResurrectTimer; - - bool IsFakingDeath; - bool SummonedRomulo; - bool RomuloDead; - - void Reset() - { - if(RomuloGUID) - { - if(Unit* Romulo = Unit::GetUnit(*m_creature, RomuloGUID)) - { - Romulo->SetVisibility(VISIBILITY_OFF); - Romulo->DealDamage(Romulo, Romulo->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); - } - - RomuloGUID = 0; - } - - Phase = PHASE_JULIANNE; - - BlindingPassionTimer = 30000; - DevotionTimer = 15000; - EternalAffectionTimer = 25000; - PowerfulAttractionTimer = 5000; - - if(IsFakingDeath) - Resurrect(m_creature); - - IsFakingDeath = false; - SummonedRomulo = false; - RomuloDead = false; - } - - void Aggro(Unit* who) {} - - void AttackStart(Unit* who) - { - if(m_creature->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE)) - return; - - ScriptedAI::AttackStart(who); - } - - void MoveInLineOfSight(Unit* who) - { - if(m_creature->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE)) - return; - - ScriptedAI::MoveInLineOfSight(who); - } - - void DamageTaken(Unit* done_by, uint32 &damage); - - void JustDied(Unit* killer) - { - DoYell(SAY_JULIANNE_DEATH02, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_JULIANNE_DEATH02); - - if(pInstance) - { - pInstance->SetData(DATA_OPERA_EVENT, DONE); - GameObject* Door = GameObject::GetGameObject((*m_creature), pInstance->GetData64(DATA_GAMEOBJECT_STAGEDOORRIGHT)); - if(Door) - Door->UseDoorOrButton(); - } - } - - void KilledUnit(Unit* victim) - { - DoYell(SAY_JULIANNE_SLAY, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_JULIANNE_SLAY); - } - - void UpdateAI(const uint32 diff); -}; - -struct MANGOS_DLL_DECL boss_romuloAI : public ScriptedAI -{ - boss_romuloAI(Creature* c) : ScriptedAI(c) - { - Reset(); - EntryYellTimer = 8000; - AggroYellTimer = 15000; - } - - uint64 JulianneGUID; - - uint32 Phase; - - uint32 EntryYellTimer; - uint32 AggroYellTimer; - uint32 BackwardLungeTimer; - uint32 DaringTimer; - uint32 DeadlySwatheTimer; - uint32 PoisonThrustTimer; - uint32 ResurrectTimer; - - bool JulianneDead; - bool IsFakingDeath; - - void Reset() - { - JulianneGUID = 0; - - Phase = PHASE_ROMULO; - - BackwardLungeTimer = 15000; - DaringTimer = 20000; - DeadlySwatheTimer = 25000; - PoisonThrustTimer = 10000; - - if(IsFakingDeath) - Resurrect(m_creature); - - IsFakingDeath = false; - JulianneDead = false; - } - - void DamageTaken(Unit* done_by, uint32 &damage); - - void Aggro(Unit* who) - { - DoYell(SAY_ROMULO_AGGRO, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_ROMULO_AGGRO); - if(JulianneGUID) - { - Creature* Julianne = ((Creature*)Unit::GetUnit((*m_creature), JulianneGUID)); - if(Julianne && Julianne->getVictim()) - { - m_creature->AddThreat(Julianne->getVictim(), 1.0f); - DoStartAttackAndMovement(Julianne->getVictim()); - } - } - } - - void MoveInLineOfSight(Unit* who) - { - if(m_creature->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE)) - return; - - ScriptedAI::MoveInLineOfSight(who); - } - - void JustDied(Unit* killer) - { - DoYell(SAY_ROMULO_DEATH, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_ROMULO_DEATH); - } - - void KilledUnit(Unit* victim) - { - DoYell(SAY_ROMULO_SLAY, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_ROMULO_SLAY); - } - - void UpdateAI(const uint32 diff); -}; - -void boss_julianneAI::DamageTaken(Unit* done_by, uint32 &damage) -{ - if(damage < m_creature->GetHealth() || done_by == m_creature || done_by->GetGUID() == RomuloGUID) - return; - - if(Phase == PHASE_JULIANNE) - { - DoYell(SAY_JULIANNE_DEATH01, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_JULIANNE_DEATH01); - m_creature->InterruptNonMeleeSpells(true); - DoCast(m_creature, SPELL_DRINK_POISON); - PretendToDie(m_creature); - Phase = PHASE_ROMULO; - damage = 0; - IsFakingDeath = true; - SummonRomuloTimer = 10000; - return; - } - - if(!IsFakingDeath) - { - Creature* Romulo = ((Creature*)Unit::GetUnit((*m_creature), RomuloGUID)); - if(Romulo && Romulo->isAlive() && !((boss_romuloAI*)Romulo->AI())->IsFakingDeath) - { - ((boss_romuloAI*)Romulo->AI())->ResurrectTimer = 10000; - ((boss_romuloAI*)Romulo->AI())->JulianneDead = true; - } - else - { - m_creature->DealDamage(m_creature, m_creature->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); - m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - if(Romulo) - { - Romulo->DealDamage(Romulo, Romulo->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); - Romulo->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - } - - JustDied(done_by); - } - - IsFakingDeath = true; - PretendToDie(m_creature); - damage = 0; - } - else - damage = 0; -} - -void boss_romuloAI::DamageTaken(Unit* done_by, uint32 &damage) -{ - if(damage < m_creature->GetHealth() || done_by == m_creature || done_by->GetGUID() == JulianneGUID) - return; - - if(!IsFakingDeath) - { - IsFakingDeath = true; - PretendToDie(m_creature); - - if(Phase == PHASE_BOTH) - { - Creature* Julianne = ((Creature*)Unit::GetUnit((*m_creature), JulianneGUID)); - if(Julianne && Julianne->isAlive() && !((boss_julianneAI*)Julianne->AI())->IsFakingDeath) - { - ((boss_julianneAI*)Julianne->AI())->ResurrectTimer = 10000; - ((boss_julianneAI*)Julianne->AI())->RomuloDead = true; - } - else - { - m_creature->DealDamage(m_creature, m_creature->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); - m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - if(Julianne) - { - Julianne->DealDamage(Julianne, Julianne->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); - Julianne->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - } - JustDied(done_by); - } - } - else - { - Creature* Julianne = ((Creature*)Unit::GetUnit((*m_creature), JulianneGUID)); - if(Julianne) - { - Resurrect(Julianne); - m_creature->SetHealth(m_creature->GetMaxHealth()); - ((boss_julianneAI*)Julianne->AI())->ResurrectTimer = 4000; - ((boss_julianneAI*)Julianne->AI())->RomuloDead = true; - ((boss_julianneAI*)Julianne->AI())->Phase = PHASE_BOTH; - ((boss_julianneAI*)Julianne->AI())->IsFakingDeath = false; - } - Phase = PHASE_BOTH; - } - - damage = 0; - } - - if(IsFakingDeath) damage = 0; -} - -void boss_julianneAI::UpdateAI(const uint32 diff) -{ - if(EntryYellTimer) - if(EntryYellTimer < diff) - { - DoYell(SAY_JULIANNE_ENTER, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_JULIANNE_ENTER); - m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); - EntryYellTimer = 0; - }else EntryYellTimer -= diff; - - if(AggroYellTimer) - if(AggroYellTimer < diff) - { - DoYell(SAY_JULIANNE_AGGRO, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_JULIANNE_AGGRO); - AggroYellTimer = 0; - }else AggroYellTimer -= diff; - - if(Phase == PHASE_ROMULO && !SummonedRomulo) - { - if(SummonRomuloTimer < diff) - { - Creature* Romulo = m_creature->SummonCreature(CREATURE_ROMULO, ROMULO_X, ROMULO_Y, m_creature->GetPositionZ(), 0, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 45000); - if(Romulo) - { - RomuloGUID = Romulo->GetGUID(); - ((boss_romuloAI*)Romulo->AI())->JulianneGUID = m_creature->GetGUID(); - ((boss_romuloAI*)Romulo->AI())->Phase = PHASE_ROMULO; - if(m_creature->getVictim()) - { - Romulo->AI()->AttackStart(m_creature->getVictim()); - Romulo->AddThreat(m_creature->getVictim(), 50.0f); - } - DoZoneInCombat(Romulo); - } - SummonedRomulo = true; - }else SummonRomuloTimer -= diff; - } - - if(!m_creature->SelectHostilTarget() || !m_creature->getVictim() ||IsFakingDeath) - return; - - if(RomuloDead) - if(ResurrectTimer < diff) - { - Creature* Romulo = ((Creature*)Unit::GetUnit((*m_creature), RomuloGUID)); - if(Romulo && ((boss_romuloAI*)Romulo->AI())->IsFakingDeath) - { - DoYell(SAY_JULIANNE_RESURRECT, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_JULIANNE_RESURRECT); - Resurrect(Romulo); - ((boss_romuloAI*)Romulo->AI())->IsFakingDeath = false; - ResurrectTimer = 10000; - } - RomuloDead = false; - }else ResurrectTimer -= diff; - - if(BlindingPassionTimer < diff) - { - DoCast(SelectUnit(SELECT_TARGET_RANDOM, 0), SPELL_BLINDING_PASSION); - BlindingPassionTimer = 30000 + rand()%15000; - }else BlindingPassionTimer -= diff; - - if(DevotionTimer < diff) - { - DoCast(m_creature, SPELL_DEVOTION); - DevotionTimer = 15000 + rand()%30000; - }else DevotionTimer -= diff; - - if(PowerfulAttractionTimer < diff) - { - DoCast(SelectUnit(SELECT_TARGET_RANDOM, 0), SPELL_POWERFUL_ATTRACTION); - PowerfulAttractionTimer = 5000 + rand()%25000; - }else PowerfulAttractionTimer -= diff; - - if(EternalAffectionTimer < diff) - { - if(rand()%2 == 1 && SummonedRomulo) - { - Creature* Romulo = ((Creature*)Unit::GetUnit((*m_creature), RomuloGUID)); - if(Romulo && Romulo->isAlive() && !((boss_romuloAI*)Romulo->AI())->IsFakingDeath) - DoCast(Romulo, SPELL_ETERNAL_AFFECTION); - else - return; - } - else DoCast(m_creature, SPELL_ETERNAL_AFFECTION); - - EternalAffectionTimer = 45000 + rand()%15000; - }else EternalAffectionTimer -= diff; - - DoMeleeAttackIfReady(); -} - -void boss_romuloAI::UpdateAI(const uint32 diff) -{ - if(!m_creature->SelectHostilTarget() || !m_creature->getVictim() || IsFakingDeath) - return; - - if(JulianneDead) - if(ResurrectTimer < diff) - { - Creature* Julianne = ((Creature*)Unit::GetUnit((*m_creature), JulianneGUID)); - if(Julianne && ((boss_julianneAI*)Julianne->AI())->IsFakingDeath) - { - DoYell(SAY_ROMULO_RESURRECT, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_ROMULO_RESURRECT); - Resurrect(Julianne); - ((boss_julianneAI*)Julianne->AI())->IsFakingDeath = false; - ResurrectTimer = 10000; - } - JulianneDead = false; - }else ResurrectTimer -= diff; - - if(BackwardLungeTimer < diff) - { - Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 1); - if(target && !m_creature->HasInArc(M_PI, target)) - { - DoCast(target, SPELL_BACKWARD_LUNGE); - BackwardLungeTimer = 15000 + rand()%15000; - } - }else BackwardLungeTimer -= diff; - - if(DaringTimer < diff) - { - DoCast(m_creature, SPELL_DARING); - DaringTimer = 20000 + rand()%20000; - }else DaringTimer -= diff; - - if(DeadlySwatheTimer < diff) - { - DoCast(SelectUnit(SELECT_TARGET_RANDOM, 0), SPELL_DEADLY_SWATHE); - DeadlySwatheTimer = 15000 + rand()%10000; - }else DeadlySwatheTimer -= diff; - - if(PoisonThrustTimer < diff) - { - DoCast(m_creature->getVictim(), SPELL_POISON_THRUST); - PoisonThrustTimer = 10000 + rand()%10000; - }else PoisonThrustTimer -= diff; - - DoMeleeAttackIfReady(); -} - -CreatureAI* GetAI_boss_julianne(Creature* _Creature) -{ - return new boss_julianneAI(_Creature); -} - -CreatureAI* GetAI_boss_romulo(Creature* _Creature) -{ - return new boss_romuloAI(_Creature); -} - -void AddSC_bosses_opera() -{ - Script* newscript; - - // Oz - newscript = new Script; - newscript->GetAI = GetAI_boss_dorothee; - newscript->Name = "boss_dorothee"; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->GetAI = GetAI_boss_strawman; - newscript->Name = "boss_strawman"; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->GetAI = GetAI_boss_tinhead; - newscript->Name = "boss_tinhead"; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->GetAI = GetAI_boss_roar; - newscript->Name = "boss_roar"; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->GetAI = GetAI_boss_crone; - newscript->Name = "boss_crone"; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->GetAI = GetAI_mob_tito; - newscript->Name = "mob_tito"; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->GetAI = GetAI_mob_cyclone; - newscript->Name = "mob_cyclone"; - m_scripts[nrscripts++] = newscript; - - // Hood - newscript = new Script; - newscript->pGossipHello = GossipHello_npc_grandmother; - newscript->pGossipSelect = GossipSelect_npc_grandmother; - newscript->Name = "npc_grandmother"; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->GetAI = GetAI_boss_bigbadwolf; - newscript->Name = "boss_bigbadwolf"; - m_scripts[nrscripts++] = newscript; - - // Romeo And Juliet - newscript = new Script; - newscript->GetAI = GetAI_boss_julianne; - newscript->Name = "boss_julianne"; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->GetAI = GetAI_boss_romulo; - newscript->Name = "boss_romulo"; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Bosses_Opera +SD%Complete: 90 +SDComment: Oz, Hood, and RAJ event implemented. RAJ event requires more testing. +SDCategory: Karazhan +EndScriptData */ + +#include "precompiled.h" +#include "def_karazhan.h" + +/***********************************/ +/*** OPERA WIZARD OF OZ EVENT *****/ +/*********************************/ + +/**** Spells ****/ +// Dorothee +#define SPELL_WATERBOLT 31012 +#define SPELL_SCREAM 31013 +#define SPELL_SUMMONTITO 31014 + +// Tito +#define SPELL_YIPPING 31015 + +// Strawman +#define SPELL_BRAIN_BASH 31046 +#define SPELL_BRAIN_WIPE 31069 +#define SPELL_BURNING_STRAW 31075 + +// Tinhead +#define SPELL_CLEAVE 31043 +#define SPELL_RUST 31086 + +// Roar +#define SPELL_MANGLE 31041 +#define SPELL_SHRED 31042 +#define SPELL_FRIGHTENED_SCREAM 31013 + +// Crone +#define SPELL_CHAIN_LIGHTNING 32337 + +// Cyclone +#define SPELL_KNOCKBACK 32334 +#define SPELL_CYCLONE_VISUAL 32332 + +/** Creature Entries **/ +#define CREATURE_TITO 17548 +#define CREATURE_CYCLONE 18412 +#define CREATURE_CRONE 18168 + +/***** Speech and Sound *****/ +#define SAY_DOROTHEE_DEATH "Oh at last, at last. I can go home." +#define SOUND_DOROTHEE_DEATH 9190 +#define SAY_DOROTHEE_SUMMON "Don't let them hurt us, Tito! Oh, you won't, will you?" +#define SOUND_DOROTHEE_SUMMON 9191 +#define SAY_DOROTHEE_TITO_DEATH "Tito, oh Tito, no!" +#define SOUND_DOROTHEE_TITO_DEATH 9192 +#define SAY_DOROTHEE_AGGRO "Oh dear, we simply must find a way home! The old wizard could be our only hope! Strawman, Roar, Tinhead, will you... wait! Oh golly, look! We have visitors!" +#define SOUND_DOROTHEE_AGGRO 9195 + +#define SAY_ROAR_AGGRO "Wanna fight? Huh? Do ya? C'mon, I'll fight you with both claws behind my back!" +#define SOUND_ROAR_AGGRO 9227 +#define SAY_ROAR_DEATH "You didn't have to go and do that." +#define SOUND_ROAR_DEATH 9229 +#define SAY_ROAR_SLAY "I think I'm going to go take fourty winks" +#define SOUND_ROAR_SLAY 9230 + +#define SAY_STRAWMAN_AGGRO "Now what should I do with you? I simply can't make up my mind." +#define SOUND_STRAWMAN_AGGRO 9254 +#define SAY_STRAWMAN_DEATH "Don't let them make a mattress... out of me." +#define SOUND_STRAWMAN_DEATH 9256 +#define SAY_STRAWMAN_SLAY "I guess I'm not a failure after all." +#define SOUND_STRAWMAN_SLAY 9257 + +#define SAY_TINHEAD_AGGRO "I could really use a heart. Say, can I have yours?" +#define SOUND_TINHEAD_AGGRO 9268 +#define SAY_TINHEAD_DEATH "Back to being an old rustbucket." +#define SOUND_TINHEAD_DEATH 9270 +#define SAY_TINHEAD_SLAY "Guess I'm not so rusty, after all." +#define SOUND_TINHEAD_SLAY 9271 + +#define SAY_CRONE_AGGRO "Woe to each and every one of you my pretties!" +#define SOUND_CRONE_AGGRO 9179 +#define SAY_CRONE_AGGRO2 "It will all be over soon!" +#define SOUND_CRONE_AGGRO2 9307 +#define SAY_CRONE_DEATH "How could you? What a cruel, cruel world!" +#define SOUND_CRONE_DEATH 9178 +#define SAY_CRONE_SLAY "Fixed you, didn't I?" +#define SOUND_CRONE_SLAY 9180 + +void SummonCroneIfReady(ScriptedInstance* pInstance, Creature *_Creature) +{ + pInstance->SetData(DATA_OPERA_OZ_DEATHCOUNT, 0); // Increment DeathCount + if(pInstance->GetData(DATA_OPERA_OZ_DEATHCOUNT) == 4) + { + Creature* Crone = _Creature->SummonCreature(CREATURE_CRONE, -10891.96, -1755.95, _Creature->GetPositionZ(), 4.64, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 30000); + if(Crone) + { + if(_Creature->getVictim()) + Crone->AI()->AttackStart(_Creature->getVictim()); + + Crone->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + } + } +}; + +struct MANGOS_DLL_DECL boss_dorotheeAI : public ScriptedAI +{ + boss_dorotheeAI(Creature* c) : ScriptedAI(c) + { + pInstance = ((ScriptedInstance*)c->GetInstanceData()); + Reset(); + } + + ScriptedInstance* pInstance; + + uint32 AggroTimer; + + uint32 WaterBoltTimer; + uint32 FearTimer; + uint32 SummonTitoTimer; + + bool SummonedTito; + bool TitoDied; + bool InCombat; + + void Reset() + { + AggroTimer = 500; + + WaterBoltTimer = 5000; + FearTimer = 15000; + SummonTitoTimer = 47500; + + SummonedTito = false; + TitoDied = false; + InCombat = false; + } + + void Aggro(Unit* who) + { + DoYell(SAY_DOROTHEE_AGGRO, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_DOROTHEE_AGGRO); + } + + void SummonTito(); // See below + + void JustDied(Unit* killer) + { + DoYell(SAY_DOROTHEE_DEATH, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_DOROTHEE_DEATH); + + if(pInstance) + SummonCroneIfReady(pInstance, m_creature); + } + + void AttackStart(Unit* who) + { + if(m_creature->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE)) + return; + + ScriptedAI::AttackStart(who); + } + + void MoveInLineOfSight(Unit* who) + { + if(m_creature->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE)) + return; + + ScriptedAI::MoveInLineOfSight(who); + } + + void UpdateAI(const uint32 diff) + { + if(AggroTimer) + if(AggroTimer <= diff) + { + m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + AggroTimer = 0; + }else AggroTimer -= diff; + + if(!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + if(WaterBoltTimer < diff) + { + DoCast(SelectUnit(SELECT_TARGET_RANDOM, 0), SPELL_WATERBOLT); + WaterBoltTimer = TitoDied ? 1500 : 5000; + }else WaterBoltTimer -= diff; + + if(FearTimer < diff) + { + DoCast(m_creature->getVictim(), SPELL_SCREAM); + FearTimer = 30000; + }else FearTimer -= diff; + + if(!SummonedTito) + { + if(SummonTitoTimer < diff) + SummonTito(); + else SummonTitoTimer -= diff; + } + + DoMeleeAttackIfReady(); + } +}; + +struct MANGOS_DLL_DECL mob_titoAI : public ScriptedAI +{ + mob_titoAI(Creature* c) : ScriptedAI(c) + { + Reset(); + } + + uint64 DorotheeGUID; + + uint32 YipTimer; + + void Reset() + { + DorotheeGUID = 0; + + YipTimer = 10000; + } + + void Aggro(Unit* who) {} + + void JustDied(Unit* killer) + { + if(DorotheeGUID) + { + Creature* Dorothee = ((Creature*)Unit::GetUnit((*m_creature), DorotheeGUID)); + if(Dorothee && Dorothee->isAlive()) + { + ((boss_dorotheeAI*)Dorothee->AI())->TitoDied = true; + Dorothee->MonsterYell(SAY_DOROTHEE_TITO_DEATH, LANG_UNIVERSAL, 0); + DoPlaySoundToSet(Dorothee, SOUND_DOROTHEE_TITO_DEATH); + } + } + } + + void UpdateAI(const uint32 diff) + { + if(!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + if(YipTimer < diff) + { + DoCast(m_creature->getVictim(), SPELL_YIPPING); + YipTimer = 10000; + }else YipTimer -= diff; + + DoMeleeAttackIfReady(); + } +}; + +void boss_dorotheeAI::SummonTito() +{ + Creature* Tito = DoSpawnCreature(CREATURE_TITO, 0, 0, 0, 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 45000); + if(Tito) + { + DoYell(SAY_DOROTHEE_SUMMON, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_DOROTHEE_SUMMON); + ((mob_titoAI*)Tito->AI())->DorotheeGUID = m_creature->GetGUID(); + Tito->AI()->AttackStart(m_creature->getVictim()); + SummonedTito = true; + TitoDied = false; + } +} + +struct MANGOS_DLL_DECL boss_strawmanAI : public ScriptedAI +{ + boss_strawmanAI(Creature* c) : ScriptedAI(c) + { + pInstance = ((ScriptedInstance*)c->GetInstanceData()); + Reset(); + } + + ScriptedInstance* pInstance; + + uint32 AggroTimer; + uint32 BrainBashTimer; + uint32 BrainWipeTimer; + + void Reset() + { + AggroTimer = 13000; + BrainBashTimer = 5000; + BrainWipeTimer = 7000; + } + + void AttackStart(Unit* who) + { + if(m_creature->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE)) + return; + + ScriptedAI::AttackStart(who); + } + + void MoveInLineOfSight(Unit* who) + { + if(m_creature->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE)) + return; + + ScriptedAI::MoveInLineOfSight(who); + } + + void Aggro(Unit* who) + { + DoYell(SAY_STRAWMAN_AGGRO, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_STRAWMAN_AGGRO); + } + + void SpellHit(Unit* caster, const SpellEntry *Spell) + { + if((Spell->SchoolMask == SPELL_SCHOOL_MASK_FIRE) && (!(rand()%10))) + DoCast(m_creature, SPELL_BURNING_STRAW, true); + } + + void JustDied(Unit* killer) + { + DoYell(SAY_STRAWMAN_DEATH, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_STRAWMAN_DEATH); + + if(pInstance) + SummonCroneIfReady(pInstance, m_creature); + } + + void KilledUnit(Unit* victim) + { + DoYell(SAY_STRAWMAN_SLAY, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_STRAWMAN_SLAY); + } + + void UpdateAI(const uint32 diff) + { + if(AggroTimer) + if(AggroTimer <= diff) + { + m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + AggroTimer = 0; + }else AggroTimer -= diff; + + if(!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + if(BrainBashTimer < diff) + { + DoCast(m_creature->getVictim(), SPELL_BRAIN_BASH); + BrainBashTimer = 15000; + }else BrainBashTimer -= diff; + + if(BrainWipeTimer < diff) + { + DoCast(SelectUnit(SELECT_TARGET_RANDOM, 0), SPELL_BRAIN_WIPE); + BrainWipeTimer = 20000; + }else BrainWipeTimer -= diff; + + DoMeleeAttackIfReady(); + } +}; + +struct MANGOS_DLL_DECL boss_tinheadAI : public ScriptedAI +{ + boss_tinheadAI(Creature* c) : ScriptedAI(c) + { + pInstance = ((ScriptedInstance*)c->GetInstanceData()); + Reset(); + } + + ScriptedInstance* pInstance; + + uint32 AggroTimer; + uint32 CleaveTimer; + uint32 RustTimer; + + uint8 RustCount; + + void Reset() + { + AggroTimer = 15000; + CleaveTimer = 5000; + RustTimer = 30000; + + RustCount = 0; + } + + void Aggro(Unit* who) + { + DoYell(SAY_TINHEAD_AGGRO, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_TINHEAD_AGGRO); + } + + void AttackStart(Unit* who) + { + if(m_creature->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE)) + return; + + ScriptedAI::AttackStart(who); + } + + void MoveInLineOfSight(Unit* who) + { + if(m_creature->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE)) + return; + + ScriptedAI::MoveInLineOfSight(who); + } + + void JustDied(Unit* killer) + { + DoYell(SAY_TINHEAD_DEATH, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_TINHEAD_DEATH); + + if(pInstance) + SummonCroneIfReady(pInstance, m_creature); + } + + void KilledUnit(Unit* victim) + { + DoYell(SAY_TINHEAD_SLAY, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_TINHEAD_SLAY); + } + + void UpdateAI(const uint32 diff) + { + if(AggroTimer) + if(AggroTimer < diff) + { + m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + AggroTimer = 0; + }else AggroTimer -= diff; + + if(!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + if(CleaveTimer < diff) + { + DoCast(m_creature->getVictim(), SPELL_CLEAVE); + CleaveTimer = 5000; + }else CleaveTimer -= diff; + + if(RustCount < 8) + { + if(RustTimer < diff) + { + RustCount++; + DoTextEmote("begins to rust", NULL); + DoCast(m_creature, SPELL_RUST); + RustTimer = 6000; + }else RustTimer -= diff; + } + + DoMeleeAttackIfReady(); + } +}; + +struct MANGOS_DLL_DECL boss_roarAI : public ScriptedAI +{ + boss_roarAI(Creature* c) : ScriptedAI(c) + { + pInstance = ((ScriptedInstance*)c->GetInstanceData()); + Reset(); + } + + ScriptedInstance* pInstance; + + uint32 AggroTimer; + uint32 MangleTimer; + uint32 ShredTimer; + uint32 ScreamTimer; + + void Reset() + { + AggroTimer = 20000; + MangleTimer = 5000; + ShredTimer = 10000; + ScreamTimer = 15000; + } + + void MoveInLineOfSight(Unit* who) + { + if(m_creature->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE)) + return; + + ScriptedAI::MoveInLineOfSight(who); + } + + void AttackStart(Unit* who) + { + if(m_creature->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE)) + return; + + ScriptedAI::AttackStart(who); + } + + void Aggro(Unit* who) + { + DoYell(SAY_ROAR_AGGRO, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_ROAR_AGGRO); + } + + void JustDied(Unit* killer) + { + DoYell(SAY_ROAR_DEATH, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_ROAR_DEATH); + + if(pInstance) + SummonCroneIfReady(pInstance, m_creature); + } + + void KilledUnit(Unit* victim) + { + DoYell(SAY_ROAR_SLAY, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_ROAR_SLAY); + } + + void UpdateAI(const uint32 diff) + { + if(AggroTimer) + if(AggroTimer <= diff) + { + m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + AggroTimer = 0; + }else AggroTimer -= diff; + + if(!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + if(MangleTimer < diff) + { + DoCast(m_creature->getVictim(), SPELL_MANGLE); + MangleTimer = 5000 + rand()%3000; + }else MangleTimer -= diff; + + if(ShredTimer < diff) + { + DoCast(m_creature->getVictim(), SPELL_SHRED); + ShredTimer = 10000 + rand()%5000; + }else ShredTimer -= diff; + + if(ScreamTimer < diff) + { + DoCast(m_creature->getVictim(), SPELL_FRIGHTENED_SCREAM); + ScreamTimer = 20000 + rand()%10000; + }else ScreamTimer -= diff; + + DoMeleeAttackIfReady(); + } +}; + +struct MANGOS_DLL_DECL boss_croneAI : public ScriptedAI +{ + boss_croneAI(Creature* c) : ScriptedAI(c) + { + pInstance = ((ScriptedInstance*)c->GetInstanceData()); + Reset(); + } + + ScriptedInstance* pInstance; + + uint32 CycloneTimer; + uint32 ChainLightningTimer; + + void Reset() + { + CycloneTimer = 30000; + ChainLightningTimer = 10000; + } + + void Aggro(Unit* who) + { + switch(rand()%2) + { + case 0: + DoYell(SAY_CRONE_AGGRO, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_CRONE_AGGRO); + break; + case 1: + DoYell(SAY_CRONE_AGGRO2, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_CRONE_AGGRO2); + break; + } + m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + } + + void JustDied(Unit* killer) + { + DoYell(SAY_CRONE_DEATH, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_CRONE_DEATH); + + if(pInstance) + { + pInstance->SetData(DATA_OPERA_EVENT, DONE); + GameObject* Door = GameObject::GetGameObject((*m_creature), pInstance->GetData64(DATA_GAMEOBJECT_STAGEDOORRIGHT)); + if(Door) + Door->UseDoorOrButton(); + } + } + + void UpdateAI(const uint32 diff) + { + if(!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + if(m_creature->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE)) + m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + + if(CycloneTimer < diff) + { + Creature* Cyclone = DoSpawnCreature(CREATURE_CYCLONE, rand()%10, rand()%10, 0, 0, TEMPSUMMON_TIMED_DESPAWN, 15000); + if(Cyclone) + Cyclone->CastSpell(Cyclone, SPELL_CYCLONE_VISUAL, true); + CycloneTimer = 30000; + }else CycloneTimer -= diff; + + if(ChainLightningTimer < diff) + { + DoCast(m_creature->getVictim(), SPELL_CHAIN_LIGHTNING); + ChainLightningTimer = 15000; + }else ChainLightningTimer -= diff; + + DoMeleeAttackIfReady(); + } +}; + +struct MANGOS_DLL_DECL mob_cycloneAI : public ScriptedAI +{ + mob_cycloneAI(Creature* c) : ScriptedAI(c) + { + Reset(); + } + + uint32 MoveTimer; + + void Reset() + { + MoveTimer = 1000; + } + + void Aggro(Unit* who) {} + + void MoveInLineOfSight(Unit* who) + { + } + + void UpdateAI(const uint32 diff) + { + if(!m_creature->HasAura(SPELL_KNOCKBACK, 0)) + DoCast(m_creature, SPELL_KNOCKBACK, true); + + if(MoveTimer < diff) + { + float x,y,z; + m_creature->GetPosition(x,y,z); + float PosX, PosY, PosZ; + m_creature->GetRandomPoint(x,y,z,10, PosX, PosY, PosZ); + m_creature->GetMotionMaster()->MovePoint(0, PosX, PosY, PosZ); + MoveTimer = 5000 + rand()%3000; + }else MoveTimer -= diff; + } +}; + +CreatureAI* GetAI_boss_dorothee(Creature* _Creature) +{ + return new boss_dorotheeAI(_Creature); +} + +CreatureAI* GetAI_boss_strawman(Creature* _Creature) +{ + return new boss_strawmanAI(_Creature); +} + +CreatureAI* GetAI_boss_tinhead(Creature* _Creature) +{ + return new boss_tinheadAI(_Creature); +} + +CreatureAI* GetAI_boss_roar(Creature* _Creature) +{ + return new boss_roarAI(_Creature); +} + +CreatureAI* GetAI_boss_crone(Creature* _Creature) +{ + return new boss_croneAI(_Creature); +} + +CreatureAI* GetAI_mob_tito(Creature* _Creature) +{ + return new mob_titoAI(_Creature); +} + +CreatureAI* GetAI_mob_cyclone(Creature* _Creature) +{ + return new mob_cycloneAI(_Creature); +} + +/**************************************/ +/**** Opera Red Riding Hood Event ****/ +/************************************/ + +#define GOSSIP_GRANDMA "What phat lewtz you have grandmother?" + +/**** Spells For The Wolf ****/ +#define SPELL_LITTLE_RED_RIDING_HOOD 30768 +#define SPELL_TERRIFYING_HOWL 30752 +#define SPELL_WIDE_SWIPE 30761 + +/**** Yells for the Wolf ****/ +#define SAY_WOLF_AGGRO "All the better to own you with!" +#define SOUND_WOLF_AGGRO 9276 +#define SOUND_WOLF_DEATH 9275 // No speech +#define SAY_WOLF_SLAY "Mmmm... delicious." +#define SOUND_WOLF_SLAY 9277 +#define SAY_WOLF_HOOD "Run away little girl, run away!" +#define SOUND_WOLF_HOOD 9278 + +/**** The Wolf's Entry ****/ +#define CREATURE_BIG_BAD_WOLF 17521 + +bool GossipHello_npc_grandmother(Player* player, Creature* _Creature) +{ + player->ADD_GOSSIP_ITEM(0, GOSSIP_GRANDMA, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF); + player->SEND_GOSSIP_MENU(8990, _Creature->GetGUID()); + + return true; +} + +bool GossipSelect_npc_grandmother(Player* player, Creature* _Creature, uint32 sender, uint32 action) +{ + if(action == GOSSIP_ACTION_INFO_DEF) + { + _Creature->SetVisibility(VISIBILITY_OFF); + float x,y,z; + _Creature->GetPosition(x,y,z); + Creature* BigBadWolf = _Creature->SummonCreature(CREATURE_BIG_BAD_WOLF, x, y, z, 0, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 30000); + if(BigBadWolf) + { + BigBadWolf->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + BigBadWolf->AI()->AttackStart(player); + } + + _Creature->setDeathState(JUST_DIED); + } + + return true; +} + +struct MANGOS_DLL_DECL boss_bigbadwolfAI : public ScriptedAI +{ + boss_bigbadwolfAI(Creature* c) : ScriptedAI(c) + { + pInstance = ((ScriptedInstance*)c->GetInstanceData()); + Reset(); + } + + ScriptedInstance* pInstance; + + uint32 ChaseTimer; + uint32 FearTimer; + uint32 SwipeTimer; + + uint64 HoodGUID; + float TempThreat; + + bool IsChasing; + + void Reset() + { + ChaseTimer = 30000; + FearTimer = 25000 + rand()%10000; + SwipeTimer = 5000; + + HoodGUID = 0; + TempThreat = 0; + + IsChasing = false; + } + + void Aggro(Unit* who) + { + DoYell(SAY_WOLF_AGGRO, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_WOLF_AGGRO); + } + + void JustDied(Unit* killer) + { + DoPlaySoundToSet(m_creature, SOUND_WOLF_DEATH); + + if(pInstance) + { + pInstance->SetData(DATA_OPERA_EVENT, DONE); + GameObject* Door = GameObject::GetGameObject((*m_creature), pInstance->GetData64(DATA_GAMEOBJECT_STAGEDOORRIGHT)); + if(Door) + Door->UseDoorOrButton(); + } + } + + void UpdateAI(const uint32 diff) + { + if(!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + DoMeleeAttackIfReady(); + + if(ChaseTimer < diff) + { + if(!IsChasing) + { + Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0); + if(target && target->GetTypeId() == TYPEID_PLAYER) + { + DoYell(SAY_WOLF_HOOD, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_WOLF_HOOD); + + DoCast(target, SPELL_LITTLE_RED_RIDING_HOOD, true); + TempThreat = m_creature->getThreatManager().getThreat(target); + if(TempThreat) + m_creature->getThreatManager().modifyThreatPercent(target, -100); + HoodGUID = target->GetGUID(); + m_creature->AddThreat(target, 1000000.0f); + ChaseTimer = 20000; + IsChasing = true; + } + } + else + { + IsChasing = false; + Unit* target = Unit::GetUnit((*m_creature), HoodGUID); + if(target) + { + HoodGUID = 0; + if(m_creature->getThreatManager().getThreat(target)) + m_creature->getThreatManager().modifyThreatPercent(target, -100); + m_creature->AddThreat(target, TempThreat); + TempThreat = 0; + } + + ChaseTimer = 40000; + } + }else ChaseTimer -= diff; + + if(IsChasing) + return; + + if(FearTimer < diff) + { + DoCast(m_creature->getVictim(), SPELL_TERRIFYING_HOWL); + FearTimer = 25000 + rand()%35000; + }else FearTimer -= diff; + + if(SwipeTimer < diff) + { + DoCast(m_creature->getVictim(), SPELL_WIDE_SWIPE); + SwipeTimer = 25000 + rand()%5000; + }else SwipeTimer -= diff; + + } +}; + +CreatureAI* GetAI_boss_bigbadwolf(Creature* _Creature) +{ + return new boss_bigbadwolfAI(_Creature); +} + +/**********************************************/ +/******** Opera Romeo and Juliet Event *******/ +/********************************************/ + +/***** Spells For Julianne *****/ +#define SPELL_BLINDING_PASSION 30890 +#define SPELL_DEVOTION 30887 +#define SPELL_ETERNAL_AFFECTION 30878 +#define SPELL_POWERFUL_ATTRACTION 30889 +#define SPELL_DRINK_POISON 30907 + +/***** Spells For Romulo ****/ +#define SPELL_BACKWARD_LUNGE 30815 +#define SPELL_DARING 30841 +#define SPELL_DEADLY_SWATHE 30817 +#define SPELL_POISON_THRUST 30822 + +/**** Other Misc. Spells ****/ +#define SPELL_UNDYING_LOVE 30951 +#define SPELL_RES_VISUAL 24171 + +/**** Speech and Text *****/ +/****** Julianne *******/ +#define SAY_JULIANNE_AGGRO "What devil art thou, that dost torment me thus?" +#define SOUND_JULIANNE_AGGRO 9196 +#define SAY_JULIANNE_ENTER "Where is my lord? Where is my Romulo?" +#define SOUND_JULIANNE_ENTER 9199 +#define SAY_JULIANNE_DEATH01 "Romulo, I come! Oh... this do I drink to thee!" +#define SOUND_JULIANNE_DEATH01 9198 +#define SAY_JULIANNE_DEATH02 "Where is my Lord? Where is my Romulo? Ohh, happy dagger! This is thy sheath! There rust, and let me die!" +#define SOUND_JULIANNE_DEATH02 9310 +#define SAY_JULIANNE_RESURRECT "Come, gentle night; and give me back my Romulo!" +#define SOUND_JULIANNE_RESURRECT 9200 +#define SAY_JULIANNE_SLAY "Parting is such sweet sorrow." +#define SOUND_JULIANNE_SLAY 9201 + +/****** Romulo *******/ +#define SAY_ROMULO_AGGRO "Wilt thou provoke me? Then have at thee, boy!" +#define SOUND_ROMULO_AGGRO 9233 +#define SAY_ROMULO_DEATH "Thou smilest... upon the stroke that... murders me." +#define SOUND_ROMULO_DEATH 9235 +#define SAY_ROMULO_ENTER "This day's black fate on more days doth depend. This but begins the woe. Others must end." +#define SOUND_ROMULO_ENTER 9236 +#define SAY_ROMULO_RESURRECT "Thou detestable maw, thou womb of death; I enforce thy rotten jaws to open!" +#define SOUND_ROMULO_RESURRECT 9237 +#define SAY_ROMULO_SLAY "How well my comfort is revived by this!" +#define SOUND_ROMULO_SLAY 9238 + +/*** Misc. Information ****/ +#define CREATURE_ROMULO 17533 +#define ROMULO_X -10900 +#define ROMULO_Y -1758 + +enum RAJPhase +{ + PHASE_JULIANNE = 0, + PHASE_ROMULO = 1, + PHASE_BOTH = 2, +}; + +void PretendToDie(Creature* _Creature) +{ + _Creature->InterruptNonMeleeSpells(false); + _Creature->SetHealth(0); + _Creature->StopMoving(); + _Creature->ClearComboPointHolders(); + _Creature->RemoveAllAurasOnDeath(); + _Creature->ModifyAuraState(AURA_STATE_HEALTHLESS_20_PERCENT, false); + _Creature->ModifyAuraState(AURA_STATE_HEALTHLESS_35_PERCENT, false); + _Creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + _Creature->ClearAllReactives(); + _Creature->SetUInt64Value(UNIT_FIELD_TARGET,0); + _Creature->GetMotionMaster()->Clear(); + _Creature->GetMotionMaster()->MoveIdle(); + _Creature->SetUInt32Value(UNIT_FIELD_BYTES_1,PLAYER_STATE_DEAD); +}; + +void Resurrect(Creature* target) +{ + target->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + target->SetHealth(target->GetMaxHealth()); + target->SetUInt32Value(UNIT_FIELD_BYTES_1, 0); + target->CastSpell(target, SPELL_RES_VISUAL, true); + if(target->getVictim()) + { + target->SetUInt64Value(UNIT_FIELD_TARGET, target->getVictim()->GetGUID()); + target->GetMotionMaster()->MoveChase(target->getVictim()); + target->AI()->AttackStart(target->getVictim()); + } +}; + +struct MANGOS_DLL_DECL boss_julianneAI : public ScriptedAI +{ + boss_julianneAI(Creature* c) : ScriptedAI(c) + { + pInstance = ((ScriptedInstance*)c->GetInstanceData()); + EntryYellTimer = 1000; + AggroYellTimer = 10000; + Reset(); + } + + ScriptedInstance* pInstance; + + uint64 RomuloGUID; + + uint32 Phase; + + uint32 EntryYellTimer; + uint32 AggroYellTimer; + uint32 BlindingPassionTimer; + uint32 DevotionTimer; + uint32 EternalAffectionTimer; + uint32 PowerfulAttractionTimer; + uint32 SummonRomuloTimer; + uint32 ResurrectTimer; + + bool IsFakingDeath; + bool SummonedRomulo; + bool RomuloDead; + + void Reset() + { + if(RomuloGUID) + { + if(Unit* Romulo = Unit::GetUnit(*m_creature, RomuloGUID)) + { + Romulo->SetVisibility(VISIBILITY_OFF); + Romulo->DealDamage(Romulo, Romulo->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); + } + + RomuloGUID = 0; + } + + Phase = PHASE_JULIANNE; + + BlindingPassionTimer = 30000; + DevotionTimer = 15000; + EternalAffectionTimer = 25000; + PowerfulAttractionTimer = 5000; + + if(IsFakingDeath) + Resurrect(m_creature); + + IsFakingDeath = false; + SummonedRomulo = false; + RomuloDead = false; + } + + void Aggro(Unit* who) {} + + void AttackStart(Unit* who) + { + if(m_creature->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE)) + return; + + ScriptedAI::AttackStart(who); + } + + void MoveInLineOfSight(Unit* who) + { + if(m_creature->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE)) + return; + + ScriptedAI::MoveInLineOfSight(who); + } + + void DamageTaken(Unit* done_by, uint32 &damage); + + void JustDied(Unit* killer) + { + DoYell(SAY_JULIANNE_DEATH02, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_JULIANNE_DEATH02); + + if(pInstance) + { + pInstance->SetData(DATA_OPERA_EVENT, DONE); + GameObject* Door = GameObject::GetGameObject((*m_creature), pInstance->GetData64(DATA_GAMEOBJECT_STAGEDOORRIGHT)); + if(Door) + Door->UseDoorOrButton(); + } + } + + void KilledUnit(Unit* victim) + { + DoYell(SAY_JULIANNE_SLAY, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_JULIANNE_SLAY); + } + + void UpdateAI(const uint32 diff); +}; + +struct MANGOS_DLL_DECL boss_romuloAI : public ScriptedAI +{ + boss_romuloAI(Creature* c) : ScriptedAI(c) + { + Reset(); + EntryYellTimer = 8000; + AggroYellTimer = 15000; + } + + uint64 JulianneGUID; + + uint32 Phase; + + uint32 EntryYellTimer; + uint32 AggroYellTimer; + uint32 BackwardLungeTimer; + uint32 DaringTimer; + uint32 DeadlySwatheTimer; + uint32 PoisonThrustTimer; + uint32 ResurrectTimer; + + bool JulianneDead; + bool IsFakingDeath; + + void Reset() + { + JulianneGUID = 0; + + Phase = PHASE_ROMULO; + + BackwardLungeTimer = 15000; + DaringTimer = 20000; + DeadlySwatheTimer = 25000; + PoisonThrustTimer = 10000; + + if(IsFakingDeath) + Resurrect(m_creature); + + IsFakingDeath = false; + JulianneDead = false; + } + + void DamageTaken(Unit* done_by, uint32 &damage); + + void Aggro(Unit* who) + { + DoYell(SAY_ROMULO_AGGRO, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_ROMULO_AGGRO); + if(JulianneGUID) + { + Creature* Julianne = ((Creature*)Unit::GetUnit((*m_creature), JulianneGUID)); + if(Julianne && Julianne->getVictim()) + { + m_creature->AddThreat(Julianne->getVictim(), 1.0f); + DoStartAttackAndMovement(Julianne->getVictim()); + } + } + } + + void MoveInLineOfSight(Unit* who) + { + if(m_creature->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE)) + return; + + ScriptedAI::MoveInLineOfSight(who); + } + + void JustDied(Unit* killer) + { + DoYell(SAY_ROMULO_DEATH, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_ROMULO_DEATH); + } + + void KilledUnit(Unit* victim) + { + DoYell(SAY_ROMULO_SLAY, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_ROMULO_SLAY); + } + + void UpdateAI(const uint32 diff); +}; + +void boss_julianneAI::DamageTaken(Unit* done_by, uint32 &damage) +{ + if(damage < m_creature->GetHealth() || done_by == m_creature || done_by->GetGUID() == RomuloGUID) + return; + + if(Phase == PHASE_JULIANNE) + { + DoYell(SAY_JULIANNE_DEATH01, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_JULIANNE_DEATH01); + m_creature->InterruptNonMeleeSpells(true); + DoCast(m_creature, SPELL_DRINK_POISON); + PretendToDie(m_creature); + Phase = PHASE_ROMULO; + damage = 0; + IsFakingDeath = true; + SummonRomuloTimer = 10000; + return; + } + + if(!IsFakingDeath) + { + Creature* Romulo = ((Creature*)Unit::GetUnit((*m_creature), RomuloGUID)); + if(Romulo && Romulo->isAlive() && !((boss_romuloAI*)Romulo->AI())->IsFakingDeath) + { + ((boss_romuloAI*)Romulo->AI())->ResurrectTimer = 10000; + ((boss_romuloAI*)Romulo->AI())->JulianneDead = true; + } + else + { + m_creature->DealDamage(m_creature, m_creature->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); + m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + if(Romulo) + { + Romulo->DealDamage(Romulo, Romulo->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); + Romulo->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + } + + JustDied(done_by); + } + + IsFakingDeath = true; + PretendToDie(m_creature); + damage = 0; + } + else + damage = 0; +} + +void boss_romuloAI::DamageTaken(Unit* done_by, uint32 &damage) +{ + if(damage < m_creature->GetHealth() || done_by == m_creature || done_by->GetGUID() == JulianneGUID) + return; + + if(!IsFakingDeath) + { + IsFakingDeath = true; + PretendToDie(m_creature); + + if(Phase == PHASE_BOTH) + { + Creature* Julianne = ((Creature*)Unit::GetUnit((*m_creature), JulianneGUID)); + if(Julianne && Julianne->isAlive() && !((boss_julianneAI*)Julianne->AI())->IsFakingDeath) + { + ((boss_julianneAI*)Julianne->AI())->ResurrectTimer = 10000; + ((boss_julianneAI*)Julianne->AI())->RomuloDead = true; + } + else + { + m_creature->DealDamage(m_creature, m_creature->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); + m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + if(Julianne) + { + Julianne->DealDamage(Julianne, Julianne->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); + Julianne->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + } + JustDied(done_by); + } + } + else + { + Creature* Julianne = ((Creature*)Unit::GetUnit((*m_creature), JulianneGUID)); + if(Julianne) + { + Resurrect(Julianne); + m_creature->SetHealth(m_creature->GetMaxHealth()); + ((boss_julianneAI*)Julianne->AI())->ResurrectTimer = 4000; + ((boss_julianneAI*)Julianne->AI())->RomuloDead = true; + ((boss_julianneAI*)Julianne->AI())->Phase = PHASE_BOTH; + ((boss_julianneAI*)Julianne->AI())->IsFakingDeath = false; + } + Phase = PHASE_BOTH; + } + + damage = 0; + } + + if(IsFakingDeath) damage = 0; +} + +void boss_julianneAI::UpdateAI(const uint32 diff) +{ + if(EntryYellTimer) + if(EntryYellTimer < diff) + { + DoYell(SAY_JULIANNE_ENTER, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_JULIANNE_ENTER); + m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + EntryYellTimer = 0; + }else EntryYellTimer -= diff; + + if(AggroYellTimer) + if(AggroYellTimer < diff) + { + DoYell(SAY_JULIANNE_AGGRO, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_JULIANNE_AGGRO); + AggroYellTimer = 0; + }else AggroYellTimer -= diff; + + if(Phase == PHASE_ROMULO && !SummonedRomulo) + { + if(SummonRomuloTimer < diff) + { + Creature* Romulo = m_creature->SummonCreature(CREATURE_ROMULO, ROMULO_X, ROMULO_Y, m_creature->GetPositionZ(), 0, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 45000); + if(Romulo) + { + RomuloGUID = Romulo->GetGUID(); + ((boss_romuloAI*)Romulo->AI())->JulianneGUID = m_creature->GetGUID(); + ((boss_romuloAI*)Romulo->AI())->Phase = PHASE_ROMULO; + if(m_creature->getVictim()) + { + Romulo->AI()->AttackStart(m_creature->getVictim()); + Romulo->AddThreat(m_creature->getVictim(), 50.0f); + } + DoZoneInCombat(Romulo); + } + SummonedRomulo = true; + }else SummonRomuloTimer -= diff; + } + + if(!m_creature->SelectHostilTarget() || !m_creature->getVictim() ||IsFakingDeath) + return; + + if(RomuloDead) + if(ResurrectTimer < diff) + { + Creature* Romulo = ((Creature*)Unit::GetUnit((*m_creature), RomuloGUID)); + if(Romulo && ((boss_romuloAI*)Romulo->AI())->IsFakingDeath) + { + DoYell(SAY_JULIANNE_RESURRECT, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_JULIANNE_RESURRECT); + Resurrect(Romulo); + ((boss_romuloAI*)Romulo->AI())->IsFakingDeath = false; + ResurrectTimer = 10000; + } + RomuloDead = false; + }else ResurrectTimer -= diff; + + if(BlindingPassionTimer < diff) + { + DoCast(SelectUnit(SELECT_TARGET_RANDOM, 0), SPELL_BLINDING_PASSION); + BlindingPassionTimer = 30000 + rand()%15000; + }else BlindingPassionTimer -= diff; + + if(DevotionTimer < diff) + { + DoCast(m_creature, SPELL_DEVOTION); + DevotionTimer = 15000 + rand()%30000; + }else DevotionTimer -= diff; + + if(PowerfulAttractionTimer < diff) + { + DoCast(SelectUnit(SELECT_TARGET_RANDOM, 0), SPELL_POWERFUL_ATTRACTION); + PowerfulAttractionTimer = 5000 + rand()%25000; + }else PowerfulAttractionTimer -= diff; + + if(EternalAffectionTimer < diff) + { + if(rand()%2 == 1 && SummonedRomulo) + { + Creature* Romulo = ((Creature*)Unit::GetUnit((*m_creature), RomuloGUID)); + if(Romulo && Romulo->isAlive() && !((boss_romuloAI*)Romulo->AI())->IsFakingDeath) + DoCast(Romulo, SPELL_ETERNAL_AFFECTION); + else + return; + } + else DoCast(m_creature, SPELL_ETERNAL_AFFECTION); + + EternalAffectionTimer = 45000 + rand()%15000; + }else EternalAffectionTimer -= diff; + + DoMeleeAttackIfReady(); +} + +void boss_romuloAI::UpdateAI(const uint32 diff) +{ + if(!m_creature->SelectHostilTarget() || !m_creature->getVictim() || IsFakingDeath) + return; + + if(JulianneDead) + if(ResurrectTimer < diff) + { + Creature* Julianne = ((Creature*)Unit::GetUnit((*m_creature), JulianneGUID)); + if(Julianne && ((boss_julianneAI*)Julianne->AI())->IsFakingDeath) + { + DoYell(SAY_ROMULO_RESURRECT, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_ROMULO_RESURRECT); + Resurrect(Julianne); + ((boss_julianneAI*)Julianne->AI())->IsFakingDeath = false; + ResurrectTimer = 10000; + } + JulianneDead = false; + }else ResurrectTimer -= diff; + + if(BackwardLungeTimer < diff) + { + Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 1); + if(target && !m_creature->HasInArc(M_PI, target)) + { + DoCast(target, SPELL_BACKWARD_LUNGE); + BackwardLungeTimer = 15000 + rand()%15000; + } + }else BackwardLungeTimer -= diff; + + if(DaringTimer < diff) + { + DoCast(m_creature, SPELL_DARING); + DaringTimer = 20000 + rand()%20000; + }else DaringTimer -= diff; + + if(DeadlySwatheTimer < diff) + { + DoCast(SelectUnit(SELECT_TARGET_RANDOM, 0), SPELL_DEADLY_SWATHE); + DeadlySwatheTimer = 15000 + rand()%10000; + }else DeadlySwatheTimer -= diff; + + if(PoisonThrustTimer < diff) + { + DoCast(m_creature->getVictim(), SPELL_POISON_THRUST); + PoisonThrustTimer = 10000 + rand()%10000; + }else PoisonThrustTimer -= diff; + + DoMeleeAttackIfReady(); +} + +CreatureAI* GetAI_boss_julianne(Creature* _Creature) +{ + return new boss_julianneAI(_Creature); +} + +CreatureAI* GetAI_boss_romulo(Creature* _Creature) +{ + return new boss_romuloAI(_Creature); +} + +void AddSC_bosses_opera() +{ + Script* newscript; + + // Oz + newscript = new Script; + newscript->GetAI = GetAI_boss_dorothee; + newscript->Name = "boss_dorothee"; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->GetAI = GetAI_boss_strawman; + newscript->Name = "boss_strawman"; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->GetAI = GetAI_boss_tinhead; + newscript->Name = "boss_tinhead"; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->GetAI = GetAI_boss_roar; + newscript->Name = "boss_roar"; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->GetAI = GetAI_boss_crone; + newscript->Name = "boss_crone"; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->GetAI = GetAI_mob_tito; + newscript->Name = "mob_tito"; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->GetAI = GetAI_mob_cyclone; + newscript->Name = "mob_cyclone"; + m_scripts[nrscripts++] = newscript; + + // Hood + newscript = new Script; + newscript->pGossipHello = GossipHello_npc_grandmother; + newscript->pGossipSelect = GossipSelect_npc_grandmother; + newscript->Name = "npc_grandmother"; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->GetAI = GetAI_boss_bigbadwolf; + newscript->Name = "boss_bigbadwolf"; + m_scripts[nrscripts++] = newscript; + + // Romeo And Juliet + newscript = new Script; + newscript->GetAI = GetAI_boss_julianne; + newscript->Name = "boss_julianne"; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->GetAI = GetAI_boss_romulo; + newscript->Name = "boss_romulo"; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/karazhan/def_karazhan.h b/src/bindings/scripts/scripts/zone/karazhan/def_karazhan.h index 938c0131b9c..86db3e86f6d 100644 --- a/src/bindings/scripts/scripts/zone/karazhan/def_karazhan.h +++ b/src/bindings/scripts/scripts/zone/karazhan/def_karazhan.h @@ -1,40 +1,40 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software licensed under GPL version 2 - * Please see the included DOCS/LICENSE.TXT for more information */ - -#ifndef DEF_KARAZHAN_H -#define DEF_KARAZHAN_H - -#define DATA_ATTUMEN_EVENT 1 -#define DATA_MOROES_EVENT 2 -#define DATA_MAIDENOFVIRTUE_EVENT 3 -#define DATA_OPTIONAL_BOSS_EVENT 4 -#define DATA_OPERA_EVENT 5 -#define DATA_CURATOR_EVENT 6 -#define DATA_SHADEOFARAN_EVENT 7 -#define DATA_TERESTIAN_EVENT 8 -#define DATA_NETHERSPITE_EVENT 9 -#define DATA_CHESS_EVENT 10 -#define DATA_MALCHEZZAR_EVENT 11 -#define DATA_NETHERBANE_EVENT 12 -#define DATA_OPERA_PERFORMANCE 13 -#define DATA_OPERA_OZ_DEATHCOUNT 14 -#define DATA_KILREK 15 -#define DATA_TERESTIAN 16 -#define DATA_MOROES 17 -#define DATA_GAMEOBJECT_CURTAINS 18 -#define DATA_GAMEOBJECT_STAGEDOORLEFT 19 -#define DATA_GAMEOBJECT_STAGEDOORRIGHT 20 -#define DATA_GAMEOBJECT_LIBRARY_DOOR 21 -#define DATA_GAMEOBJECT_MASSIVE_DOOR 22 -#define DATA_GAMEOBJECT_NETHER_DOOR 23 -#define DATA_GAMEOBJECT_GAME_DOOR 24 -#define DATA_GAMEOBJECT_GAME_EXIT_DOOR 25 - -// Opera Performances -#define EVENT_OZ 1 -#define EVENT_HOOD 2 -#define EVENT_RAJ 3 - -#define ERROR_INST_DATA(a) error_log("SD2: Instance Data for Karazhan not set properly. Encounter for Creature Entry %u may not work properly.", a->GetEntry()); -#endif +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software licensed under GPL version 2 + * Please see the included DOCS/LICENSE.TXT for more information */ + +#ifndef DEF_KARAZHAN_H +#define DEF_KARAZHAN_H + +#define DATA_ATTUMEN_EVENT 1 +#define DATA_MOROES_EVENT 2 +#define DATA_MAIDENOFVIRTUE_EVENT 3 +#define DATA_OPTIONAL_BOSS_EVENT 4 +#define DATA_OPERA_EVENT 5 +#define DATA_CURATOR_EVENT 6 +#define DATA_SHADEOFARAN_EVENT 7 +#define DATA_TERESTIAN_EVENT 8 +#define DATA_NETHERSPITE_EVENT 9 +#define DATA_CHESS_EVENT 10 +#define DATA_MALCHEZZAR_EVENT 11 +#define DATA_NETHERBANE_EVENT 12 +#define DATA_OPERA_PERFORMANCE 13 +#define DATA_OPERA_OZ_DEATHCOUNT 14 +#define DATA_KILREK 15 +#define DATA_TERESTIAN 16 +#define DATA_MOROES 17 +#define DATA_GAMEOBJECT_CURTAINS 18 +#define DATA_GAMEOBJECT_STAGEDOORLEFT 19 +#define DATA_GAMEOBJECT_STAGEDOORRIGHT 20 +#define DATA_GAMEOBJECT_LIBRARY_DOOR 21 +#define DATA_GAMEOBJECT_MASSIVE_DOOR 22 +#define DATA_GAMEOBJECT_NETHER_DOOR 23 +#define DATA_GAMEOBJECT_GAME_DOOR 24 +#define DATA_GAMEOBJECT_GAME_EXIT_DOOR 25 + +// Opera Performances +#define EVENT_OZ 1 +#define EVENT_HOOD 2 +#define EVENT_RAJ 3 + +#define ERROR_INST_DATA(a) error_log("SD2: Instance Data for Karazhan not set properly. Encounter for Creature Entry %u may not work properly.", a->GetEntry()); +#endif diff --git a/src/bindings/scripts/scripts/zone/karazhan/instance_karazhan.cpp b/src/bindings/scripts/scripts/zone/karazhan/instance_karazhan.cpp index f7b2be1978f..88a11739651 100644 --- a/src/bindings/scripts/scripts/zone/karazhan/instance_karazhan.cpp +++ b/src/bindings/scripts/scripts/zone/karazhan/instance_karazhan.cpp @@ -1,253 +1,253 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Instance_Karazhan -SD%Complete: 70 -SDComment: Instance Script for Karazhan to help in various encounters. TODO: GameObject visibility for Opera event. -SDCategory: Karazhan -EndScriptData */ - -#include "precompiled.h" -#include "def_karazhan.h" - -#define ENCOUNTERS 11 - -/* -0 - Attumen + Midnight (optional) -1 - Moroes -2 - Maiden of Virtue (optional) -3 - Hyakiss the Lurker / Rokad the Ravager / Shadikith the Glider -4 - Opera Event -5 - Curator -6 - Shade of Aran (optional) -7 - Terestian Illhoof (optional) -8 - Netherspite (optional) -9 - Chess Event -10 - Prince Malchezzar -11 - Netherbane -*/ -struct MANGOS_DLL_DECL instance_karazhan : public ScriptedInstance -{ - instance_karazhan(Map* map) : ScriptedInstance(map) - { - Initialize(); - } - - uint32 Encounters[ENCOUNTERS]; - - uint32 OperaEvent; // 0 - OZ, 1 - HOOD, 2 - RAJ - uint32 OzDeathCount; - - uint64 CurtainGUID; - uint64 StageDoorLeftGUID; - uint64 StageDoorRightGUID; - uint64 KilrekGUID; - uint64 TerestianGUID; - uint64 MoroesGUID; - uint64 LibraryDoor; // Door at Shade of Aran - uint64 MassiveDoor; // Door at Netherspite - uint64 GamesmansDoor; // Door before Chess - uint64 GamesmansExitDoor; // Door after Chess - uint64 NetherspaceDoor; // Door at Malchezaar - - void Initialize() - { - for (uint8 i = 0; i < ENCOUNTERS; ++i) - Encounters[i] = NOT_STARTED; - - OperaEvent = rand()%3; // This never gets altered. - OzDeathCount = 0; - - CurtainGUID = 0; - StageDoorLeftGUID = 0; - StageDoorRightGUID = 0; - - KilrekGUID = 0; - TerestianGUID = 0; - MoroesGUID = 0; - - LibraryDoor = 0; - MassiveDoor = 0; - GamesmansDoor = 0; - GamesmansExitDoor = 0; - NetherspaceDoor = 0; - } - - bool IsEncounterInProgress() const - { - for (uint8 i = 0; i < ENCOUNTERS; ++i) - if (Encounters[i] == IN_PROGRESS) return true; - - return false; - } - - uint32 GetData(uint32 identifier) - { - switch (identifier) - { - case DATA_ATTUMEN_EVENT: return Encounters[0]; - case DATA_MOROES_EVENT: return Encounters[1]; - case DATA_MAIDENOFVIRTUE_EVENT: return Encounters[2]; - case DATA_OPTIONAL_BOSS_EVENT: return Encounters[3]; - case DATA_OPERA_EVENT: return Encounters[4]; - case DATA_CURATOR_EVENT: return Encounters[5]; - case DATA_SHADEOFARAN_EVENT: return Encounters[6]; - case DATA_TERESTIAN_EVENT: return Encounters[7]; - case DATA_NETHERSPITE_EVENT: return Encounters[8]; - case DATA_CHESS_EVENT: return Encounters[9]; - case DATA_MALCHEZZAR_EVENT: return Encounters[10]; - case DATA_NETHERBANE_EVENT: return Encounters[11]; - case DATA_OPERA_PERFORMANCE: return OperaEvent; - case DATA_OPERA_OZ_DEATHCOUNT: return OzDeathCount; - } - - return 0; - } - - void OnCreatureCreate(Creature *creature, uint32 entry) - { - switch (entry) - { - case 17229: KilrekGUID = creature->GetGUID(); break; - case 15688: TerestianGUID = creature->GetGUID(); break; - case 15687: MoroesGUID = creature->GetGUID(); break; - } - } - - uint64 GetData64(uint32 identifier) - { - switch (identifier) - { - case DATA_KILREK: return KilrekGUID; - case DATA_TERESTIAN: return TerestianGUID; - case DATA_MOROES: return MoroesGUID; - case DATA_GAMEOBJECT_STAGEDOORLEFT: return StageDoorLeftGUID; - case DATA_GAMEOBJECT_STAGEDOORRIGHT: return StageDoorRightGUID; - case DATA_GAMEOBJECT_CURTAINS: return CurtainGUID; - case DATA_GAMEOBJECT_LIBRARY_DOOR: return LibraryDoor; - case DATA_GAMEOBJECT_MASSIVE_DOOR: return MassiveDoor; - case DATA_GAMEOBJECT_GAME_DOOR: return GamesmansDoor; - case DATA_GAMEOBJECT_GAME_EXIT_DOOR: return GamesmansExitDoor; - case DATA_GAMEOBJECT_NETHER_DOOR: return NetherspaceDoor; - } - - return 0; - } - - void SetData(uint32 identifier, uint32 data) - { - switch (identifier) - { - case DATA_ATTUMEN_EVENT: Encounters[0] = data; break; - case DATA_MOROES_EVENT: Encounters[1] = data; break; - case DATA_MAIDENOFVIRTUE_EVENT: Encounters[2] = data; break; - case DATA_OPTIONAL_BOSS_EVENT: Encounters[3] = data; break; - case DATA_OPERA_EVENT: Encounters[4] = data; break; - case DATA_CURATOR_EVENT: Encounters[5] = data; break; - case DATA_SHADEOFARAN_EVENT: Encounters[6] = data; break; - case DATA_TERESTIAN_EVENT: Encounters[7] = data; break; - case DATA_NETHERSPITE_EVENT: Encounters[8] = data; break; - case DATA_CHESS_EVENT: Encounters[9] = data; break; - case DATA_MALCHEZZAR_EVENT: Encounters[10] = data; break; - case DATA_NETHERBANE_EVENT: Encounters[11] = data; break; - - case DATA_OPERA_OZ_DEATHCOUNT: ++OzDeathCount; break; - } - - if(data == DONE) - SaveToDB(); - } - - void OnObjectCreate(GameObject* go) - { - switch(go->GetEntry()) - { - case 183932: CurtainGUID = go->GetGUID(); break; - case 184278: StageDoorLeftGUID = go->GetGUID(); break; - case 184279: StageDoorRightGUID = go->GetGUID(); break; - case 184517: LibraryDoor = go->GetGUID(); break; - case 185521: MassiveDoor = go->GetGUID(); break; - case 184276: GamesmansDoor = go->GetGUID(); break; - case 184277: GamesmansExitDoor = go->GetGUID(); break; - case 185134: NetherspaceDoor = go->GetGUID(); break; - } - - switch(OperaEvent) - { - //TODO: Set Object visibilities for Opera based on performance - case EVENT_OZ: - break; - - case EVENT_HOOD: - break; - - case EVENT_RAJ: - break; - } - } - - const char* Save() - { - OUT_SAVE_INST_DATA; - std::ostringstream stream; - stream << Encounters[0] << " " << Encounters[1] << " " << Encounters[2] << " " << Encounters[3] << " " - << Encounters[4] << " " << Encounters[5] << " " << Encounters[6] << " " << Encounters[7] << " " - << Encounters[8] << " " << Encounters[9] << " " << Encounters[10]; - char* out = new char[stream.str().length() + 1]; - strcpy(out, stream.str().c_str()); - if(out) - { - OUT_SAVE_INST_DATA_COMPLETE; - return out; - } - - return NULL; - } - - void Load(const char* in) - { - if(!in) - { - OUT_LOAD_INST_DATA_FAIL; - return; - } - - OUT_LOAD_INST_DATA(in); - std::istringstream stream(in); - stream >> Encounters[0] >> Encounters[1] >> Encounters[2] >> Encounters[3] - >> Encounters[4] >> Encounters[5] >> Encounters[6] >> Encounters[7] - >> Encounters[8] >> Encounters[9] >> Encounters[10]; - for(uint8 i = 0; i < ENCOUNTERS; ++i) - if(Encounters[i] == IN_PROGRESS) // Do not load an encounter as "In Progress" - reset it instead. - Encounters[i] = NOT_STARTED; - OUT_LOAD_INST_DATA_COMPLETE; - } -}; - -InstanceData* GetInstanceData_instance_karazhan(Map* map) -{ - return new instance_karazhan(map); -} - -void AddSC_instance_karazhan() -{ - Script *newscript; - newscript = new Script; - newscript->Name = "instance_karazhan"; - newscript->GetInstanceData = GetInstanceData_instance_karazhan; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Instance_Karazhan +SD%Complete: 70 +SDComment: Instance Script for Karazhan to help in various encounters. TODO: GameObject visibility for Opera event. +SDCategory: Karazhan +EndScriptData */ + +#include "precompiled.h" +#include "def_karazhan.h" + +#define ENCOUNTERS 11 + +/* +0 - Attumen + Midnight (optional) +1 - Moroes +2 - Maiden of Virtue (optional) +3 - Hyakiss the Lurker / Rokad the Ravager / Shadikith the Glider +4 - Opera Event +5 - Curator +6 - Shade of Aran (optional) +7 - Terestian Illhoof (optional) +8 - Netherspite (optional) +9 - Chess Event +10 - Prince Malchezzar +11 - Netherbane +*/ +struct MANGOS_DLL_DECL instance_karazhan : public ScriptedInstance +{ + instance_karazhan(Map* map) : ScriptedInstance(map) + { + Initialize(); + } + + uint32 Encounters[ENCOUNTERS]; + + uint32 OperaEvent; // 0 - OZ, 1 - HOOD, 2 - RAJ + uint32 OzDeathCount; + + uint64 CurtainGUID; + uint64 StageDoorLeftGUID; + uint64 StageDoorRightGUID; + uint64 KilrekGUID; + uint64 TerestianGUID; + uint64 MoroesGUID; + uint64 LibraryDoor; // Door at Shade of Aran + uint64 MassiveDoor; // Door at Netherspite + uint64 GamesmansDoor; // Door before Chess + uint64 GamesmansExitDoor; // Door after Chess + uint64 NetherspaceDoor; // Door at Malchezaar + + void Initialize() + { + for (uint8 i = 0; i < ENCOUNTERS; ++i) + Encounters[i] = NOT_STARTED; + + OperaEvent = rand()%3; // This never gets altered. + OzDeathCount = 0; + + CurtainGUID = 0; + StageDoorLeftGUID = 0; + StageDoorRightGUID = 0; + + KilrekGUID = 0; + TerestianGUID = 0; + MoroesGUID = 0; + + LibraryDoor = 0; + MassiveDoor = 0; + GamesmansDoor = 0; + GamesmansExitDoor = 0; + NetherspaceDoor = 0; + } + + bool IsEncounterInProgress() const + { + for (uint8 i = 0; i < ENCOUNTERS; ++i) + if (Encounters[i] == IN_PROGRESS) return true; + + return false; + } + + uint32 GetData(uint32 identifier) + { + switch (identifier) + { + case DATA_ATTUMEN_EVENT: return Encounters[0]; + case DATA_MOROES_EVENT: return Encounters[1]; + case DATA_MAIDENOFVIRTUE_EVENT: return Encounters[2]; + case DATA_OPTIONAL_BOSS_EVENT: return Encounters[3]; + case DATA_OPERA_EVENT: return Encounters[4]; + case DATA_CURATOR_EVENT: return Encounters[5]; + case DATA_SHADEOFARAN_EVENT: return Encounters[6]; + case DATA_TERESTIAN_EVENT: return Encounters[7]; + case DATA_NETHERSPITE_EVENT: return Encounters[8]; + case DATA_CHESS_EVENT: return Encounters[9]; + case DATA_MALCHEZZAR_EVENT: return Encounters[10]; + case DATA_NETHERBANE_EVENT: return Encounters[11]; + case DATA_OPERA_PERFORMANCE: return OperaEvent; + case DATA_OPERA_OZ_DEATHCOUNT: return OzDeathCount; + } + + return 0; + } + + void OnCreatureCreate(Creature *creature, uint32 entry) + { + switch (entry) + { + case 17229: KilrekGUID = creature->GetGUID(); break; + case 15688: TerestianGUID = creature->GetGUID(); break; + case 15687: MoroesGUID = creature->GetGUID(); break; + } + } + + uint64 GetData64(uint32 identifier) + { + switch (identifier) + { + case DATA_KILREK: return KilrekGUID; + case DATA_TERESTIAN: return TerestianGUID; + case DATA_MOROES: return MoroesGUID; + case DATA_GAMEOBJECT_STAGEDOORLEFT: return StageDoorLeftGUID; + case DATA_GAMEOBJECT_STAGEDOORRIGHT: return StageDoorRightGUID; + case DATA_GAMEOBJECT_CURTAINS: return CurtainGUID; + case DATA_GAMEOBJECT_LIBRARY_DOOR: return LibraryDoor; + case DATA_GAMEOBJECT_MASSIVE_DOOR: return MassiveDoor; + case DATA_GAMEOBJECT_GAME_DOOR: return GamesmansDoor; + case DATA_GAMEOBJECT_GAME_EXIT_DOOR: return GamesmansExitDoor; + case DATA_GAMEOBJECT_NETHER_DOOR: return NetherspaceDoor; + } + + return 0; + } + + void SetData(uint32 identifier, uint32 data) + { + switch (identifier) + { + case DATA_ATTUMEN_EVENT: Encounters[0] = data; break; + case DATA_MOROES_EVENT: Encounters[1] = data; break; + case DATA_MAIDENOFVIRTUE_EVENT: Encounters[2] = data; break; + case DATA_OPTIONAL_BOSS_EVENT: Encounters[3] = data; break; + case DATA_OPERA_EVENT: Encounters[4] = data; break; + case DATA_CURATOR_EVENT: Encounters[5] = data; break; + case DATA_SHADEOFARAN_EVENT: Encounters[6] = data; break; + case DATA_TERESTIAN_EVENT: Encounters[7] = data; break; + case DATA_NETHERSPITE_EVENT: Encounters[8] = data; break; + case DATA_CHESS_EVENT: Encounters[9] = data; break; + case DATA_MALCHEZZAR_EVENT: Encounters[10] = data; break; + case DATA_NETHERBANE_EVENT: Encounters[11] = data; break; + + case DATA_OPERA_OZ_DEATHCOUNT: ++OzDeathCount; break; + } + + if(data == DONE) + SaveToDB(); + } + + void OnObjectCreate(GameObject* go) + { + switch(go->GetEntry()) + { + case 183932: CurtainGUID = go->GetGUID(); break; + case 184278: StageDoorLeftGUID = go->GetGUID(); break; + case 184279: StageDoorRightGUID = go->GetGUID(); break; + case 184517: LibraryDoor = go->GetGUID(); break; + case 185521: MassiveDoor = go->GetGUID(); break; + case 184276: GamesmansDoor = go->GetGUID(); break; + case 184277: GamesmansExitDoor = go->GetGUID(); break; + case 185134: NetherspaceDoor = go->GetGUID(); break; + } + + switch(OperaEvent) + { + //TODO: Set Object visibilities for Opera based on performance + case EVENT_OZ: + break; + + case EVENT_HOOD: + break; + + case EVENT_RAJ: + break; + } + } + + const char* Save() + { + OUT_SAVE_INST_DATA; + std::ostringstream stream; + stream << Encounters[0] << " " << Encounters[1] << " " << Encounters[2] << " " << Encounters[3] << " " + << Encounters[4] << " " << Encounters[5] << " " << Encounters[6] << " " << Encounters[7] << " " + << Encounters[8] << " " << Encounters[9] << " " << Encounters[10]; + char* out = new char[stream.str().length() + 1]; + strcpy(out, stream.str().c_str()); + if(out) + { + OUT_SAVE_INST_DATA_COMPLETE; + return out; + } + + return NULL; + } + + void Load(const char* in) + { + if(!in) + { + OUT_LOAD_INST_DATA_FAIL; + return; + } + + OUT_LOAD_INST_DATA(in); + std::istringstream stream(in); + stream >> Encounters[0] >> Encounters[1] >> Encounters[2] >> Encounters[3] + >> Encounters[4] >> Encounters[5] >> Encounters[6] >> Encounters[7] + >> Encounters[8] >> Encounters[9] >> Encounters[10]; + for(uint8 i = 0; i < ENCOUNTERS; ++i) + if(Encounters[i] == IN_PROGRESS) // Do not load an encounter as "In Progress" - reset it instead. + Encounters[i] = NOT_STARTED; + OUT_LOAD_INST_DATA_COMPLETE; + } +}; + +InstanceData* GetInstanceData_instance_karazhan(Map* map) +{ + return new instance_karazhan(map); +} + +void AddSC_instance_karazhan() +{ + Script *newscript; + newscript = new Script; + newscript->Name = "instance_karazhan"; + newscript->GetInstanceData = GetInstanceData_instance_karazhan; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/karazhan/karazhan.cpp b/src/bindings/scripts/scripts/zone/karazhan/karazhan.cpp index b12c3280f58..b7b4e8a6b9a 100644 --- a/src/bindings/scripts/scripts/zone/karazhan/karazhan.cpp +++ b/src/bindings/scripts/scripts/zone/karazhan/karazhan.cpp @@ -1,470 +1,470 @@ -/* Copyright (C) 2006,2007 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Karazhan -SD%Complete: 100 -SDComment: Support for Barnes (Opera controller) and Berthold (Doorman). -SDCategory: Karazhan -EndScriptData */ - -/* ContentData -npc_barnes -npc_berthold -EndContentData */ - -#include "precompiled.h" -#include "def_karazhan.h" -#include "../../npc/npc_escortAI.h" - -/*###### -# npc_barnesAI -######*/ - -#define GOSSIP_READY "I'm not an actor." - -#define SAY_READY "Splendid, I'm going to get the audience ready. Break a leg!" -#define SAY_OZ_INTRO1 "Finally, everything is in place. Are you ready for your big stage debut?" -#define OZ_GOSSIP1 "I'm not an actor." -#define SAY_OZ_INTRO2 "Don't worry, you'll be fine. You look like a natural!" -#define OZ_GOSSIP2 "Ok, I'll give it a try, then." - -#define SAY_RAJ_INTRO1 "The romantic plays are really tough, but you'll do better this time. You have TALENT. Ready?" -#define RAJ_GOSSIP1 "I've never been more ready." - -struct Dialogue -{ - char* text; - uint32 soundid, timer; -}; - -static Dialogue OzDialogue[]= -{ - {"Welcome Ladies and Gentlemen, to this evening's presentation!", 9174, 6000}, - {"Tonight we plumb the depths of the human soul as we join a lost, lonely girl trying desperately -- with the help of her loyal companions -- to find her way home!", 9338, 18000}, - {"But she is pursued... by a wicked malevolent crone!", 9339, 9000}, - {"Will she survive? Will she prevail? Only time will tell. And now ... on with the show!", 9340, 15000} -}; - -static Dialogue HoodDialogue[]= -{ - {"Good evening, Ladies and Gentlemen! Welcome to this evening's presentation!", 9175, 6000}, - {"Tonight, things are not what they seem. For tonight, your eyes may not be trusted", 9335, 10000}, - {"Take for instance, this quiet, elderly woman, waiting for a visit from her granddaughter. Surely there is nothing to fear from this sweet, grey-haired, old lady.", 9336, 14000}, - {"But don't let me pull the wool over your eyes. See for yourself what lies beneath those covers! And now... on with the show!", 9337, 15000} -}; - -static Dialogue RAJDialogue[]= -{ - {"Welcome, Ladies and Gentlemen, to this evening's presentation!", 9176, 5000}, - {"Tonight, we explore a tale of forbidden love!", 9341, 7000}, - {"But beware, for not all love stories end happily, as you may find out. Sometimes, love pricks like a thorn.", 9342, 14000}, - {"But don't take it from me, see for yourself what tragedy lies ahead when the paths of star-crossed lovers meet. And now...on with the show!", 9343, 14000} -}; - -// Entries and spawn locations for creatures in Oz event -float Spawns[6][2]= -{ - {17535, -10896}, // Dorothee - {17546, -10891}, // Roar - {17547, -10884}, // Tinhead - {17543, -10902}, // Strawman - {17603, -10892}, // Grandmother - {17534, -10900}, // Julianne -}; - -float StageLocations[6][2]= -{ - {-10866.711, -1779.816}, // Open door, begin walking (0) - {-10894.917, -1775.467}, // (1) - {-10896.044, -1782.619}, // Begin Speech after this (2) - {-10894.917, -1775.467}, // Resume walking (back to spawn point now) after speech (3) - {-10866.711, -1779.816}, // (4) - {-10866.700, -1781.030} // Summon mobs, open curtains, close door (5) -}; - -#define CREATURE_SPOTLIGHT 19525 - -#define SPELL_SPOTLIGHT 25824 -#define SPELL_TUXEDO 32616 - -#define SPAWN_Z 90.5 -#define SPAWN_Y -1758 -#define SPAWN_O 4.738 - -struct MANGOS_DLL_DECL npc_barnesAI : public npc_escortAI -{ - npc_barnesAI(Creature* c) : npc_escortAI(c) - { - RaidWiped = false; - pInstance = ((ScriptedInstance*)c->GetInstanceData()); - Reset(); - } - - ScriptedInstance* pInstance; - - uint64 SpotlightGUID; - - uint32 TalkCount; - uint32 TalkTimer; - uint32 CurtainTimer; - uint32 WipeTimer; - uint32 Event; - - bool PerformanceReady; - bool RaidWiped; - bool IsTalking; - - void Reset() - { - TalkCount = 0; - TalkTimer = 2000; - CurtainTimer = 5000; - WipeTimer = 5000; - - PerformanceReady = false; - IsTalking = false; - - if(pInstance) - { - pInstance->SetData(DATA_OPERA_EVENT, NOT_STARTED); - - Event = pInstance->GetData(DATA_OPERA_PERFORMANCE); - - GameObject* Door = GameObject::GetGameObject((*m_creature), pInstance->GetData64(DATA_GAMEOBJECT_STAGEDOORLEFT)); - if(Door) - Door->SetGoState(1); - - GameObject* Curtain = GameObject::GetGameObject((*m_creature), pInstance->GetData64(DATA_GAMEOBJECT_CURTAINS)); - if(Curtain) - Curtain->SetGoState(1); - } - } - - void Aggro(Unit* who) {} - - void WaypointReached(uint32 i) - { - switch(i) - { - case 2: - IsBeingEscorted = false; - TalkCount = 0; - IsTalking = true; - - float x,y,z; - m_creature->GetPosition(x, y, z); - Creature* Spotlight; - Spotlight = m_creature->SummonCreature(CREATURE_SPOTLIGHT, x, y, z, 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 50000); - if(Spotlight) - { - Spotlight->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - Spotlight->CastSpell(Spotlight, SPELL_SPOTLIGHT, false); - SpotlightGUID = Spotlight->GetGUID(); - } - break; - - case 5: - if(pInstance) - { - GameObject* Door = GameObject::GetGameObject((*m_creature), pInstance->GetData64(DATA_GAMEOBJECT_STAGEDOORLEFT)); - if(Door) - Door->SetGoState(1); - } - IsBeingEscorted = false; - PerformanceReady = true; - break; - } - } - - void Talk(uint32 count) - { - char* text = NULL; - uint32 sound = 0; - - switch(Event) - { - case EVENT_OZ: - if(OzDialogue[count].text) - text = OzDialogue[count].text; - if(OzDialogue[count].soundid) - sound = OzDialogue[count].soundid; - if(OzDialogue[count].timer) - TalkTimer = OzDialogue[count].timer; - break; - - case EVENT_HOOD: - if(HoodDialogue[count].text) - text = HoodDialogue[count].text; - if(HoodDialogue[count].soundid) - sound = HoodDialogue[count].soundid; - if(HoodDialogue[count].timer) - TalkTimer = HoodDialogue[count].timer; - break; - - case EVENT_RAJ: - if(RAJDialogue[count].text) - text = RAJDialogue[count].text; - if(RAJDialogue[count].soundid) - sound = RAJDialogue[count].soundid; - if(RAJDialogue[count].timer) - TalkTimer = RAJDialogue[count].timer; - break; - } - - if(text) - DoYell(text, LANG_UNIVERSAL, 0); - if(sound) - DoPlaySoundToSet(m_creature, sound); - } - - void UpdateAI(const uint32 diff) - { - npc_escortAI::UpdateAI(diff); - - if(IsTalking) - { - if(TalkTimer < diff) - { - if(TalkCount > 3) - { - Unit* Spotlight = Unit::GetUnit((*m_creature), SpotlightGUID); - if(Spotlight) - { - Spotlight->RemoveAllAuras(); - Spotlight->SetVisibility(VISIBILITY_OFF); - } - - m_creature->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_STATE_STAND); - IsTalking = false; - IsBeingEscorted = true; - return; - } - - m_creature->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_STATE_TALK); - Talk(TalkCount); - ++TalkCount; - } - else TalkTimer -= diff; - } - - if(PerformanceReady) - { - if(CurtainTimer) - if(CurtainTimer <= diff) - { - PrepareEncounter(); - - if(!pInstance) - return; - - GameObject* Curtain = GameObject::GetGameObject((*m_creature), pInstance->GetData64(DATA_GAMEOBJECT_CURTAINS)); - if(Curtain) - Curtain->SetGoState(0); - - CurtainTimer = 0; - }else CurtainTimer -= diff; - - if(!RaidWiped) - { - if(WipeTimer < diff) - { - Map *map = m_creature->GetMap(); - if(!map->IsDungeon()) return; - - InstanceMap::PlayerList const &PlayerList = ((InstanceMap*)map)->GetPlayers(); - if(PlayerList.empty()) - return; - - RaidWiped = true; - for(InstanceMap::PlayerList::const_iterator i = PlayerList.begin();i != PlayerList.end(); ++i) - { - if((*i)->isAlive() && !(*i)->isGameMaster()) - { - RaidWiped = false; - break; - } - } - - if(RaidWiped) - { - RaidWiped = true; - EnterEvadeMode(); - } - - WipeTimer = 15000; - }else WipeTimer -= diff; - } - - } - - if(!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - DoMeleeAttackIfReady(); - } - - void StartEvent() - { - if(!pInstance) - return; - - pInstance->SetData(DATA_OPERA_EVENT, IN_PROGRESS); - - GameObject* Door = GameObject::GetGameObject((*m_creature), pInstance->GetData64(DATA_GAMEOBJECT_STAGEDOORLEFT)); - if(Door) - Door->SetGoState(0); - - m_creature->CastSpell(m_creature, SPELL_TUXEDO, true); - m_creature->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP); - - Start(false, false, false); - } - - void PrepareEncounter() - { - debug_log("SD2: Barnes Opera Event - Introduction complete - preparing encounter %d", Event); - uint8 index = 0; - uint8 count = 0; - switch(Event) - { - case EVENT_OZ: - index = 0; - count = 4; - break; - - case EVENT_HOOD: - index = 4; - count = index+1; - break; - - case EVENT_RAJ: - index = 5; - count = index+1; - break; - } - - for( ; index < count; ++index) - { - uint32 entry = ((uint32)Spawns[index][0]); - float PosX = Spawns[index][1]; - Creature* pCreature = m_creature->SummonCreature(entry, PosX, SPAWN_Y, SPAWN_Z, SPAWN_O, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 120000); - if(pCreature) - { - // In case database has bad flags - pCreature->SetUInt32Value(UNIT_FIELD_FLAGS, 0); - pCreature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); - } - } - - CurtainTimer = 10000; - PerformanceReady = true; - RaidWiped = false; - } -}; - -CreatureAI* GetAI_npc_barnesAI(Creature* _Creature) -{ - npc_barnesAI* Barnes_AI = new npc_barnesAI(_Creature); - - for(uint8 i = 0; i < 6; ++i) - Barnes_AI->AddWaypoint(i, StageLocations[i][0], StageLocations[i][1], 90.465); - - return ((CreatureAI*)Barnes_AI); -} - -bool GossipHello_npc_barnes(Player* player, Creature* _Creature) -{ - // Check for death of Moroes. - ScriptedInstance* pInstance = ((ScriptedInstance*)_Creature->GetInstanceData()); - if(pInstance && (pInstance->GetData(DATA_MOROES_EVENT) >= DONE)) - { - player->ADD_GOSSIP_ITEM(0, OZ_GOSSIP1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); - - if(!((npc_barnesAI*)_Creature->AI())->RaidWiped) - player->SEND_GOSSIP_MENU(8970, _Creature->GetGUID()); - else - player->SEND_GOSSIP_MENU(8975, _Creature->GetGUID()); - } - else - player->SEND_GOSSIP_MENU(8978, _Creature->GetGUID()); - - return true; -} - -bool GossipSelect_npc_barnes(Player *player, Creature *_Creature, uint32 sender, uint32 action) -{ - switch(action) - { - case GOSSIP_ACTION_INFO_DEF+1: - player->ADD_GOSSIP_ITEM(0, OZ_GOSSIP2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2); - player->SEND_GOSSIP_MENU(8971, _Creature->GetGUID()); - break; - - case GOSSIP_ACTION_INFO_DEF+2: - player->CLOSE_GOSSIP_MENU(); - ((npc_barnesAI*)_Creature->AI())->StartEvent(); - break; - } - - return true; -} - -/*### -# npc_berthold -####*/ - -#define SPELL_TELEPORT 39567 - -#define GOSSIP_ITEM_TELEPORT "Teleport me to the Guardian's Library" - -bool GossipHello_npc_berthold(Player* player, Creature* _Creature) -{ - ScriptedInstance* pInstance = ((ScriptedInstance*)_Creature->GetInstanceData()); - // Check if Shade of Aran is dead or not - if(pInstance && (pInstance->GetData(DATA_SHADEOFARAN_EVENT) >= DONE)) - player->ADD_GOSSIP_ITEM(0, GOSSIP_ITEM_TELEPORT, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); - - player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); - return true; -} - -bool GossipSelect_npc_berthold(Player* player, Creature* _Creature, uint32 sender, uint32 action) -{ - if(action == GOSSIP_ACTION_INFO_DEF + 1) - player->CastSpell(player, SPELL_TELEPORT, true); - - player->CLOSE_GOSSIP_MENU(); - return true; -} - -void AddSC_karazhan() -{ - Script* newscript; - - newscript = new Script; - newscript->GetAI = GetAI_npc_barnesAI; - newscript->Name = "npc_barnes"; - newscript->pGossipHello = GossipHello_npc_barnes; - newscript->pGossipSelect = GossipSelect_npc_barnes; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name = "npc_berthold"; - newscript->pGossipHello = GossipHello_npc_berthold; - newscript->pGossipSelect = GossipSelect_npc_berthold; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006,2007 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Karazhan +SD%Complete: 100 +SDComment: Support for Barnes (Opera controller) and Berthold (Doorman). +SDCategory: Karazhan +EndScriptData */ + +/* ContentData +npc_barnes +npc_berthold +EndContentData */ + +#include "precompiled.h" +#include "def_karazhan.h" +#include "../../npc/npc_escortAI.h" + +/*###### +# npc_barnesAI +######*/ + +#define GOSSIP_READY "I'm not an actor." + +#define SAY_READY "Splendid, I'm going to get the audience ready. Break a leg!" +#define SAY_OZ_INTRO1 "Finally, everything is in place. Are you ready for your big stage debut?" +#define OZ_GOSSIP1 "I'm not an actor." +#define SAY_OZ_INTRO2 "Don't worry, you'll be fine. You look like a natural!" +#define OZ_GOSSIP2 "Ok, I'll give it a try, then." + +#define SAY_RAJ_INTRO1 "The romantic plays are really tough, but you'll do better this time. You have TALENT. Ready?" +#define RAJ_GOSSIP1 "I've never been more ready." + +struct Dialogue +{ + char* text; + uint32 soundid, timer; +}; + +static Dialogue OzDialogue[]= +{ + {"Welcome Ladies and Gentlemen, to this evening's presentation!", 9174, 6000}, + {"Tonight we plumb the depths of the human soul as we join a lost, lonely girl trying desperately -- with the help of her loyal companions -- to find her way home!", 9338, 18000}, + {"But she is pursued... by a wicked malevolent crone!", 9339, 9000}, + {"Will she survive? Will she prevail? Only time will tell. And now ... on with the show!", 9340, 15000} +}; + +static Dialogue HoodDialogue[]= +{ + {"Good evening, Ladies and Gentlemen! Welcome to this evening's presentation!", 9175, 6000}, + {"Tonight, things are not what they seem. For tonight, your eyes may not be trusted", 9335, 10000}, + {"Take for instance, this quiet, elderly woman, waiting for a visit from her granddaughter. Surely there is nothing to fear from this sweet, grey-haired, old lady.", 9336, 14000}, + {"But don't let me pull the wool over your eyes. See for yourself what lies beneath those covers! And now... on with the show!", 9337, 15000} +}; + +static Dialogue RAJDialogue[]= +{ + {"Welcome, Ladies and Gentlemen, to this evening's presentation!", 9176, 5000}, + {"Tonight, we explore a tale of forbidden love!", 9341, 7000}, + {"But beware, for not all love stories end happily, as you may find out. Sometimes, love pricks like a thorn.", 9342, 14000}, + {"But don't take it from me, see for yourself what tragedy lies ahead when the paths of star-crossed lovers meet. And now...on with the show!", 9343, 14000} +}; + +// Entries and spawn locations for creatures in Oz event +float Spawns[6][2]= +{ + {17535, -10896}, // Dorothee + {17546, -10891}, // Roar + {17547, -10884}, // Tinhead + {17543, -10902}, // Strawman + {17603, -10892}, // Grandmother + {17534, -10900}, // Julianne +}; + +float StageLocations[6][2]= +{ + {-10866.711, -1779.816}, // Open door, begin walking (0) + {-10894.917, -1775.467}, // (1) + {-10896.044, -1782.619}, // Begin Speech after this (2) + {-10894.917, -1775.467}, // Resume walking (back to spawn point now) after speech (3) + {-10866.711, -1779.816}, // (4) + {-10866.700, -1781.030} // Summon mobs, open curtains, close door (5) +}; + +#define CREATURE_SPOTLIGHT 19525 + +#define SPELL_SPOTLIGHT 25824 +#define SPELL_TUXEDO 32616 + +#define SPAWN_Z 90.5 +#define SPAWN_Y -1758 +#define SPAWN_O 4.738 + +struct MANGOS_DLL_DECL npc_barnesAI : public npc_escortAI +{ + npc_barnesAI(Creature* c) : npc_escortAI(c) + { + RaidWiped = false; + pInstance = ((ScriptedInstance*)c->GetInstanceData()); + Reset(); + } + + ScriptedInstance* pInstance; + + uint64 SpotlightGUID; + + uint32 TalkCount; + uint32 TalkTimer; + uint32 CurtainTimer; + uint32 WipeTimer; + uint32 Event; + + bool PerformanceReady; + bool RaidWiped; + bool IsTalking; + + void Reset() + { + TalkCount = 0; + TalkTimer = 2000; + CurtainTimer = 5000; + WipeTimer = 5000; + + PerformanceReady = false; + IsTalking = false; + + if(pInstance) + { + pInstance->SetData(DATA_OPERA_EVENT, NOT_STARTED); + + Event = pInstance->GetData(DATA_OPERA_PERFORMANCE); + + GameObject* Door = GameObject::GetGameObject((*m_creature), pInstance->GetData64(DATA_GAMEOBJECT_STAGEDOORLEFT)); + if(Door) + Door->SetGoState(1); + + GameObject* Curtain = GameObject::GetGameObject((*m_creature), pInstance->GetData64(DATA_GAMEOBJECT_CURTAINS)); + if(Curtain) + Curtain->SetGoState(1); + } + } + + void Aggro(Unit* who) {} + + void WaypointReached(uint32 i) + { + switch(i) + { + case 2: + IsBeingEscorted = false; + TalkCount = 0; + IsTalking = true; + + float x,y,z; + m_creature->GetPosition(x, y, z); + Creature* Spotlight; + Spotlight = m_creature->SummonCreature(CREATURE_SPOTLIGHT, x, y, z, 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 50000); + if(Spotlight) + { + Spotlight->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + Spotlight->CastSpell(Spotlight, SPELL_SPOTLIGHT, false); + SpotlightGUID = Spotlight->GetGUID(); + } + break; + + case 5: + if(pInstance) + { + GameObject* Door = GameObject::GetGameObject((*m_creature), pInstance->GetData64(DATA_GAMEOBJECT_STAGEDOORLEFT)); + if(Door) + Door->SetGoState(1); + } + IsBeingEscorted = false; + PerformanceReady = true; + break; + } + } + + void Talk(uint32 count) + { + char* text = NULL; + uint32 sound = 0; + + switch(Event) + { + case EVENT_OZ: + if(OzDialogue[count].text) + text = OzDialogue[count].text; + if(OzDialogue[count].soundid) + sound = OzDialogue[count].soundid; + if(OzDialogue[count].timer) + TalkTimer = OzDialogue[count].timer; + break; + + case EVENT_HOOD: + if(HoodDialogue[count].text) + text = HoodDialogue[count].text; + if(HoodDialogue[count].soundid) + sound = HoodDialogue[count].soundid; + if(HoodDialogue[count].timer) + TalkTimer = HoodDialogue[count].timer; + break; + + case EVENT_RAJ: + if(RAJDialogue[count].text) + text = RAJDialogue[count].text; + if(RAJDialogue[count].soundid) + sound = RAJDialogue[count].soundid; + if(RAJDialogue[count].timer) + TalkTimer = RAJDialogue[count].timer; + break; + } + + if(text) + DoYell(text, LANG_UNIVERSAL, 0); + if(sound) + DoPlaySoundToSet(m_creature, sound); + } + + void UpdateAI(const uint32 diff) + { + npc_escortAI::UpdateAI(diff); + + if(IsTalking) + { + if(TalkTimer < diff) + { + if(TalkCount > 3) + { + Unit* Spotlight = Unit::GetUnit((*m_creature), SpotlightGUID); + if(Spotlight) + { + Spotlight->RemoveAllAuras(); + Spotlight->SetVisibility(VISIBILITY_OFF); + } + + m_creature->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_STATE_STAND); + IsTalking = false; + IsBeingEscorted = true; + return; + } + + m_creature->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_STATE_TALK); + Talk(TalkCount); + ++TalkCount; + } + else TalkTimer -= diff; + } + + if(PerformanceReady) + { + if(CurtainTimer) + if(CurtainTimer <= diff) + { + PrepareEncounter(); + + if(!pInstance) + return; + + GameObject* Curtain = GameObject::GetGameObject((*m_creature), pInstance->GetData64(DATA_GAMEOBJECT_CURTAINS)); + if(Curtain) + Curtain->SetGoState(0); + + CurtainTimer = 0; + }else CurtainTimer -= diff; + + if(!RaidWiped) + { + if(WipeTimer < diff) + { + Map *map = m_creature->GetMap(); + if(!map->IsDungeon()) return; + + InstanceMap::PlayerList const &PlayerList = ((InstanceMap*)map)->GetPlayers(); + if(PlayerList.empty()) + return; + + RaidWiped = true; + for(InstanceMap::PlayerList::const_iterator i = PlayerList.begin();i != PlayerList.end(); ++i) + { + if((*i)->isAlive() && !(*i)->isGameMaster()) + { + RaidWiped = false; + break; + } + } + + if(RaidWiped) + { + RaidWiped = true; + EnterEvadeMode(); + } + + WipeTimer = 15000; + }else WipeTimer -= diff; + } + + } + + if(!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + DoMeleeAttackIfReady(); + } + + void StartEvent() + { + if(!pInstance) + return; + + pInstance->SetData(DATA_OPERA_EVENT, IN_PROGRESS); + + GameObject* Door = GameObject::GetGameObject((*m_creature), pInstance->GetData64(DATA_GAMEOBJECT_STAGEDOORLEFT)); + if(Door) + Door->SetGoState(0); + + m_creature->CastSpell(m_creature, SPELL_TUXEDO, true); + m_creature->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP); + + Start(false, false, false); + } + + void PrepareEncounter() + { + debug_log("SD2: Barnes Opera Event - Introduction complete - preparing encounter %d", Event); + uint8 index = 0; + uint8 count = 0; + switch(Event) + { + case EVENT_OZ: + index = 0; + count = 4; + break; + + case EVENT_HOOD: + index = 4; + count = index+1; + break; + + case EVENT_RAJ: + index = 5; + count = index+1; + break; + } + + for( ; index < count; ++index) + { + uint32 entry = ((uint32)Spawns[index][0]); + float PosX = Spawns[index][1]; + Creature* pCreature = m_creature->SummonCreature(entry, PosX, SPAWN_Y, SPAWN_Z, SPAWN_O, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 120000); + if(pCreature) + { + // In case database has bad flags + pCreature->SetUInt32Value(UNIT_FIELD_FLAGS, 0); + pCreature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + } + } + + CurtainTimer = 10000; + PerformanceReady = true; + RaidWiped = false; + } +}; + +CreatureAI* GetAI_npc_barnesAI(Creature* _Creature) +{ + npc_barnesAI* Barnes_AI = new npc_barnesAI(_Creature); + + for(uint8 i = 0; i < 6; ++i) + Barnes_AI->AddWaypoint(i, StageLocations[i][0], StageLocations[i][1], 90.465); + + return ((CreatureAI*)Barnes_AI); +} + +bool GossipHello_npc_barnes(Player* player, Creature* _Creature) +{ + // Check for death of Moroes. + ScriptedInstance* pInstance = ((ScriptedInstance*)_Creature->GetInstanceData()); + if(pInstance && (pInstance->GetData(DATA_MOROES_EVENT) >= DONE)) + { + player->ADD_GOSSIP_ITEM(0, OZ_GOSSIP1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); + + if(!((npc_barnesAI*)_Creature->AI())->RaidWiped) + player->SEND_GOSSIP_MENU(8970, _Creature->GetGUID()); + else + player->SEND_GOSSIP_MENU(8975, _Creature->GetGUID()); + } + else + player->SEND_GOSSIP_MENU(8978, _Creature->GetGUID()); + + return true; +} + +bool GossipSelect_npc_barnes(Player *player, Creature *_Creature, uint32 sender, uint32 action) +{ + switch(action) + { + case GOSSIP_ACTION_INFO_DEF+1: + player->ADD_GOSSIP_ITEM(0, OZ_GOSSIP2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2); + player->SEND_GOSSIP_MENU(8971, _Creature->GetGUID()); + break; + + case GOSSIP_ACTION_INFO_DEF+2: + player->CLOSE_GOSSIP_MENU(); + ((npc_barnesAI*)_Creature->AI())->StartEvent(); + break; + } + + return true; +} + +/*### +# npc_berthold +####*/ + +#define SPELL_TELEPORT 39567 + +#define GOSSIP_ITEM_TELEPORT "Teleport me to the Guardian's Library" + +bool GossipHello_npc_berthold(Player* player, Creature* _Creature) +{ + ScriptedInstance* pInstance = ((ScriptedInstance*)_Creature->GetInstanceData()); + // Check if Shade of Aran is dead or not + if(pInstance && (pInstance->GetData(DATA_SHADEOFARAN_EVENT) >= DONE)) + player->ADD_GOSSIP_ITEM(0, GOSSIP_ITEM_TELEPORT, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); + + player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); + return true; +} + +bool GossipSelect_npc_berthold(Player* player, Creature* _Creature, uint32 sender, uint32 action) +{ + if(action == GOSSIP_ACTION_INFO_DEF + 1) + player->CastSpell(player, SPELL_TELEPORT, true); + + player->CLOSE_GOSSIP_MENU(); + return true; +} + +void AddSC_karazhan() +{ + Script* newscript; + + newscript = new Script; + newscript->GetAI = GetAI_npc_barnesAI; + newscript->Name = "npc_barnes"; + newscript->pGossipHello = GossipHello_npc_barnes; + newscript->pGossipSelect = GossipSelect_npc_barnes; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name = "npc_berthold"; + newscript->pGossipHello = GossipHello_npc_berthold; + newscript->pGossipSelect = GossipSelect_npc_berthold; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/loch_modan/loch_modan.cpp b/src/bindings/scripts/scripts/zone/loch_modan/loch_modan.cpp index af335dba05f..929f0b3e92d 100644 --- a/src/bindings/scripts/scripts/zone/loch_modan/loch_modan.cpp +++ b/src/bindings/scripts/scripts/zone/loch_modan/loch_modan.cpp @@ -1,91 +1,91 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Loch_Modan -SD%Complete: 100 -SDComment: Quest support: 3181 (only to argue with pebblebitty to get to searing gorge, before quest rewarded) -SDCategory: Loch Modan -EndScriptData */ - -/* ContentData -npc_mountaineer_pebblebitty -EndContentData */ - -#include "precompiled.h" - -/*###### -## npc_mountaineer_pebblebitty -######*/ - -bool GossipHello_npc_mountaineer_pebblebitty(Player *player, Creature *_Creature) -{ - if (_Creature->isQuestGiver()) - player->PrepareQuestMenu( _Creature->GetGUID() ); - - if (!player->GetQuestRewardStatus(3181) == 1) - player->ADD_GOSSIP_ITEM( 0, "Open the gate please, i need to get to Searing Gorge", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); - - player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); - - return true; -} - -bool GossipSelect_npc_mountaineer_pebblebitty(Player *player, Creature *_Creature, uint32 sender, uint32 action) -{ - switch (action) - { - case GOSSIP_ACTION_INFO_DEF+1: - player->ADD_GOSSIP_ITEM( 0, "But i need to get there, now open the gate!", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2); - player->SEND_GOSSIP_MENU(1833, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+2: - player->ADD_GOSSIP_ITEM( 0, "Ok, so what is this other way?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 3); - player->SEND_GOSSIP_MENU(1834, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+3: - player->ADD_GOSSIP_ITEM( 0, "Doesn't matter, i'm invulnerable.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 4); - player->SEND_GOSSIP_MENU(1835, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+4: - player->ADD_GOSSIP_ITEM( 0, "Yes...", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 5); - player->SEND_GOSSIP_MENU(1836, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+5: - player->ADD_GOSSIP_ITEM( 0, "Ok, i'll try to remember that.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 6); - player->SEND_GOSSIP_MENU(1837, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+6: - player->ADD_GOSSIP_ITEM( 0, "A key? Ok!", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 7); - player->SEND_GOSSIP_MENU(1838, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+7: - player->CLOSE_GOSSIP_MENU(); - break; - } - return true; -} - -void AddSC_loch_modan() -{ - Script *newscript; - - newscript = new Script; - newscript->Name="npc_mountaineer_pebblebitty"; - newscript->pGossipHello = &GossipHello_npc_mountaineer_pebblebitty; - newscript->pGossipSelect = &GossipSelect_npc_mountaineer_pebblebitty; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Loch_Modan +SD%Complete: 100 +SDComment: Quest support: 3181 (only to argue with pebblebitty to get to searing gorge, before quest rewarded) +SDCategory: Loch Modan +EndScriptData */ + +/* ContentData +npc_mountaineer_pebblebitty +EndContentData */ + +#include "precompiled.h" + +/*###### +## npc_mountaineer_pebblebitty +######*/ + +bool GossipHello_npc_mountaineer_pebblebitty(Player *player, Creature *_Creature) +{ + if (_Creature->isQuestGiver()) + player->PrepareQuestMenu( _Creature->GetGUID() ); + + if (!player->GetQuestRewardStatus(3181) == 1) + player->ADD_GOSSIP_ITEM( 0, "Open the gate please, i need to get to Searing Gorge", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); + + player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); + + return true; +} + +bool GossipSelect_npc_mountaineer_pebblebitty(Player *player, Creature *_Creature, uint32 sender, uint32 action) +{ + switch (action) + { + case GOSSIP_ACTION_INFO_DEF+1: + player->ADD_GOSSIP_ITEM( 0, "But i need to get there, now open the gate!", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2); + player->SEND_GOSSIP_MENU(1833, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+2: + player->ADD_GOSSIP_ITEM( 0, "Ok, so what is this other way?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 3); + player->SEND_GOSSIP_MENU(1834, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+3: + player->ADD_GOSSIP_ITEM( 0, "Doesn't matter, i'm invulnerable.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 4); + player->SEND_GOSSIP_MENU(1835, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+4: + player->ADD_GOSSIP_ITEM( 0, "Yes...", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 5); + player->SEND_GOSSIP_MENU(1836, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+5: + player->ADD_GOSSIP_ITEM( 0, "Ok, i'll try to remember that.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 6); + player->SEND_GOSSIP_MENU(1837, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+6: + player->ADD_GOSSIP_ITEM( 0, "A key? Ok!", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 7); + player->SEND_GOSSIP_MENU(1838, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+7: + player->CLOSE_GOSSIP_MENU(); + break; + } + return true; +} + +void AddSC_loch_modan() +{ + Script *newscript; + + newscript = new Script; + newscript->Name="npc_mountaineer_pebblebitty"; + newscript->pGossipHello = &GossipHello_npc_mountaineer_pebblebitty; + newscript->pGossipSelect = &GossipSelect_npc_mountaineer_pebblebitty; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/magisters_terrace/boss_felblood_kaelthas.cpp b/src/bindings/scripts/scripts/zone/magisters_terrace/boss_felblood_kaelthas.cpp index 5783d1ac441..0b448dbb047 100644 --- a/src/bindings/scripts/scripts/zone/magisters_terrace/boss_felblood_kaelthas.cpp +++ b/src/bindings/scripts/scripts/zone/magisters_terrace/boss_felblood_kaelthas.cpp @@ -1,591 +1,591 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: boss_felblood_kaelthas -SD%Complete: 80 -SDComment: Normal and Heroic Support. Issues: Arcane Spheres do not initially follow targets. TODO: Convert Phoenix to ACID. -SDCategory: Magisters' Terrace -EndScriptData */ - -#include "precompiled.h" -#include "def_magisters_terrace.h" -#include "WorldPacket.h" - -/*** Spells ***/ - -// Phase 1 spells - -#define SPELL_FIREBALL_NORMAL 44189 // Deals 2700-3300 damage at current target -#define SPELL_FIREBALL_HEROIC 46164 // 4950-6050 - -#define SPELL_PHOENIX 44194 // Summons a phoenix (Doesn't work?) -#define SPELL_PHOENIX_BURN 44198 // A spell Phoenix uses to damage everything around - -#define SPELL_FLAMESTRIKE1_NORMAL 44190 // Damage part -#define SPELL_FLAMESTRIKE1_HEROIC 46163 // Heroic damage part -#define SPELL_FLAMESTRIKE2 44191 // Flamestrike indicator before the damage -#define SPELL_FLAMESTRIKE3 44192 // Summons the trigger + animation (projectile) - -#define SPELL_SHOCK_BARRIER 46165 // Heroic only; 10k damage shield, followed by Pyroblast -#define SPELL_PYROBLAST 36819 // Heroic only; 45-55k fire damage - -// Phase 2 spells - -#define SPELL_GRAVITY_LAPSE_INITIAL 44224 // Cast at the beginning of every Gravity Lapse -#define SPELL_GRAVITY_LAPSE_CHANNEL 44251 // Channeled; blue beam animation to every enemy in range -#define SPELL_TELEPORT_CENTER 44218 // Should teleport people to the center. Requires DB entry in spell_target_position. -#define SPELL_GRAVITY_LAPSE_FLY 44227 // Hastens flyspeed and allows flying for 1 minute. For some reason removes 44226. -#define SPELL_GRAVITY_LAPSE_DOT 44226 // Knocks up in the air and applies a 300 DPS DoT. -#define SPELL_ARCANE_SPHERE_PASSIVE 44263 // Passive auras on Arcane Spheres -#define SPELL_POWER_FEEDBACK 44233 // Stuns him, making him take 50% more damage for 10 seconds. Cast after Gravity Lapse - -/*** Creatures ***/ -#define CREATURE_PHOENIX 24674 -#define CREATURE_PHOENIX_EGG 24675 -#define CREATURE_ARCANE_SPHERE 24708 - -/*** Dialogues ***/ -#define SAY_AGGRO "Don't look so smug! I know what you're thinking, but Tempest Keep was merely a set back. Did you honestly believe I would trust the future to some blind, half-night elf mongrel? Oh no, he was merely an instrument, a stepping stone to a much larger plan! It has all led to this, and this time, you will not interfere!" -#define SOUND_AGGRO 12413 // This yell should be done when the room is cleared. For now, set it as aggro yell. - -#define SAY_PHOENIX "Vengeance burns!" -#define SOUND_PHOENIX 12415 - -#define SAY_FLAMESTRIKE "Felomin ashal!" -#define SOUND_FLAMESTRIKE 12417 - -#define SAY_GRAVITY_LAPSE "I'll turn your world... upside... down..." -#define SOUND_GRAVITY_LAPSE 12418 - -#define SAY_TIRED "Master... grant me strength." -#define SOUND_TIRED 12419 - -#define SAY_RECAST_GRAVITY "Do not... get too comfortable." -#define SOUND_RECAST_GRAVITY 12420 - -#define SAY_DEATH "My demise accomplishes nothing! The Master will have you! You will drown in your own blood! This world shall burn! Aaaghh!" -#define SOUND_DEATH 12421 - -/** Locations **/ -float KaelLocations[3][2]= -{ - {148.744659, 181.377426}, - {140.823883, 195.403046}, - {156.574188, 195.650482}, -}; -#define LOCATION_Z -16.727455 - -struct MANGOS_DLL_DECL boss_felblood_kaelthasAI : public ScriptedAI -{ - boss_felblood_kaelthasAI(Creature* c) : ScriptedAI(c) - { - pInstance = ((ScriptedInstance*)c->GetInstanceData()); - Reset(); - Heroic = c->GetMap()->IsHeroic() ? true : false; - } - - ScriptedInstance* pInstance; - - uint32 FireballTimer; - uint32 PhoenixTimer; - uint32 FlameStrikeTimer; - uint32 CombatPulseTimer; - - //Heroic only - uint32 PyroblastTimer; - - uint32 GravityLapseTimer; - uint32 GravityLapsePhase; - // 0 = No Gravity Lapse - // 1 = Casting Gravity Lapse visual - // 2 = Teleported people to self - // 3 = Knocked people up in the air - // 4 = Applied an aura that allows them to fly, channeling visual, relased Arcane Orbs. - - bool FirstGravityLapse; - bool Heroic; - - uint8 Phase; - // 0 = Not started - // 1 = Fireball; Summon Phoenix; Flamestrike - // 2 = Gravity Lapses - - void Reset() - { - // TODO: Timers - FireballTimer = 0; - PhoenixTimer = 30000; - FlameStrikeTimer = 25000; - CombatPulseTimer = 0; - - PyroblastTimer = 60000; - - GravityLapseTimer = 0; - GravityLapsePhase = 0; - - FirstGravityLapse = true; - - Phase = 0; - - if(pInstance) - pInstance->SetData(DATA_KAELTHAS_EVENT, 0); - } - - void JustDied(Unit *killer) - { - DoYell(SAY_DEATH,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_DEATH); - } - - void DamageTaken(Unit* done_by, uint32 &damage) - { - if(damage > m_creature->GetHealth()) - RemoveGravityLapse(); // Remove Gravity Lapse so that players fall to ground if they kill him when in air. - } - - void Aggro(Unit *who) - { - DoYell(SAY_AGGRO,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_AGGRO); - } - - void SetThreatList(Creature* SummonedUnit) - { - if(!SummonedUnit) return; - - std::list& m_threatlist = m_creature->getThreatManager().getThreatList(); - std::list::iterator i = m_threatlist.begin(); - for(i = m_threatlist.begin(); i != m_threatlist.end(); i++) - { - Unit* pUnit = Unit::GetUnit((*m_creature), (*i)->getUnitGuid()); - if(pUnit && pUnit->isAlive()) - { - float threat = m_creature->getThreatManager().getThreat(pUnit); - SummonedUnit->AddThreat(pUnit, threat); - } - } - } - - void TeleportPlayersToSelf() - { - float x = KaelLocations[0][0]; - float y = KaelLocations[0][1]; - m_creature->Relocate(x, y, LOCATION_Z, 0); - //m_creature->SendMonsterMove(x, y, LOCATION_Z, 0, 0, 0); // causes some issues... - std::list::iterator i = m_creature->getThreatManager().getThreatList().begin(); - for (i = m_creature->getThreatManager().getThreatList().begin(); i!= m_creature->getThreatManager().getThreatList().end();++i) - { - Unit* pUnit = Unit::GetUnit((*m_creature), (*i)->getUnitGuid()); - if(pUnit && (pUnit->GetTypeId() == TYPEID_PLAYER)) - pUnit->CastSpell(pUnit, SPELL_TELEPORT_CENTER, true); - } - DoCast(m_creature, SPELL_TELEPORT_CENTER, true); - } - - void CastGravityLapseKnockUp() - { - std::list::iterator i = m_creature->getThreatManager().getThreatList().begin(); - for (i = m_creature->getThreatManager().getThreatList().begin(); i!= m_creature->getThreatManager().getThreatList().end();++i) - { - Unit* pUnit = Unit::GetUnit((*m_creature), (*i)->getUnitGuid()); - if(pUnit && (pUnit->GetTypeId() == TYPEID_PLAYER)) - // Knockback into the air - pUnit->CastSpell(pUnit, SPELL_GRAVITY_LAPSE_DOT, true, 0, 0, m_creature->GetGUID()); - } - } - - void CastGravityLapseFly() // Use Fly Packet hack for now as players can't cast "fly" spells unless in map 530. Has to be done a while after they get knocked into the air... - { - std::list::iterator i = m_creature->getThreatManager().getThreatList().begin(); - for (i = m_creature->getThreatManager().getThreatList().begin(); i!= m_creature->getThreatManager().getThreatList().end();++i) - { - Unit* pUnit = Unit::GetUnit((*m_creature), (*i)->getUnitGuid()); - if(pUnit && (pUnit->GetTypeId() == TYPEID_PLAYER)) - { - // Also needs an exception in spell system. - pUnit->CastSpell(pUnit, SPELL_GRAVITY_LAPSE_FLY, true, 0, 0, m_creature->GetGUID()); - // Use packet hack - WorldPacket data(12); - data.SetOpcode(SMSG_MOVE_SET_CAN_FLY); - data.append(pUnit->GetPackGUID()); - data << uint32(0); - pUnit->SendMessageToSet(&data, true); - } - } - } - - void RemoveGravityLapse() - { - std::list::iterator i = m_creature->getThreatManager().getThreatList().begin(); - for (i = m_creature->getThreatManager().getThreatList().begin(); i!= m_creature->getThreatManager().getThreatList().end();++i) - { - Unit* pUnit = Unit::GetUnit((*m_creature), (*i)->getUnitGuid()); - if(pUnit && (pUnit->GetTypeId() == TYPEID_PLAYER)) - { - pUnit->RemoveAurasDueToSpell(SPELL_GRAVITY_LAPSE_FLY); - pUnit->RemoveAurasDueToSpell(SPELL_GRAVITY_LAPSE_DOT); - WorldPacket data(12); - data.SetOpcode(SMSG_MOVE_UNSET_CAN_FLY); - data.append(pUnit->GetPackGUID()); - data << uint32(0); - pUnit->SendMessageToSet(&data, true); - } - } - } - - void UpdateAI(const uint32 diff) - { - if(!m_creature->getVictim() && !m_creature->SelectHostilTarget()) - return; - - switch(Phase) - { - case 0: - { - // *Heroic mode only: - if(Heroic) - if(PyroblastTimer < diff) - { - DoCast(m_creature, SPELL_SHOCK_BARRIER, true); - DoCast(m_creature->getVictim(), SPELL_PYROBLAST); - PyroblastTimer = 60000; - }else PyroblastTimer -= diff; - - if(FireballTimer < diff) - { - // *Normal/Heroic mode support - if(Heroic) DoCast(m_creature->getVictim(), SPELL_FIREBALL_HEROIC); - else DoCast(m_creature->getVictim(), SPELL_FIREBALL_NORMAL); - FireballTimer = 2000 + rand()%4000; - }else FireballTimer -= diff; - - if(PhoenixTimer < diff) - { - uint32 random = rand()%2 + 1; - float x = KaelLocations[random][0]; - float y = KaelLocations[random][1]; - Creature* Phoenix = m_creature->SummonCreature(CREATURE_PHOENIX, x, y, LOCATION_Z, 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 60000); - if(Phoenix) - { - Phoenix->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE + UNIT_FLAG_NON_ATTACKABLE); - SetThreatList(Phoenix); - } - - DoYell(SAY_PHOENIX, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature,SOUND_PHOENIX); - - PhoenixTimer = 40000; - }else PhoenixTimer -= diff; - - if(FlameStrikeTimer < diff) - { - Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0); - if(target) - { - DoCast(target, SPELL_FLAMESTRIKE3, true); - FlameStrikeTimer = 20000 + rand()%5000; - - DoYell(SAY_FLAMESTRIKE, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_FLAMESTRIKE); - } - }else FlameStrikeTimer -= diff; - - // Below 50% - if(m_creature->GetMaxHealth() * 0.5 > m_creature->GetHealth()) - { - m_creature->ApplySpellImmune(0, IMMUNITY_EFFECT, SPELL_EFFECT_INTERRUPT_CAST, true); - m_creature->StopMoving(); - m_creature->GetMotionMaster()->Clear(); - m_creature->GetMotionMaster()->MoveIdle(); - GravityLapseTimer = 0; - GravityLapsePhase = 0; - Phase = 1; - } - DoMeleeAttackIfReady(); - } - break; - - case 1: - { - if(GravityLapseTimer < diff) - { - switch(GravityLapsePhase) - { - case 0: - if(FirstGravityLapse) // Different yells at 50%, and at every following Gravity Lapse - { - DoYell(SAY_GRAVITY_LAPSE,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_GRAVITY_LAPSE); - FirstGravityLapse = false; - if(pInstance) - { - GameObject* KaelLeft = GameObject::GetGameObject(*m_creature, pInstance->GetData64(DATA_KAEL_STATUE_LEFT)); - if(KaelLeft) KaelLeft->SetGoState(0); - GameObject* KaelRight = GameObject::GetGameObject(*m_creature, pInstance->GetData64(DATA_KAEL_STATUE_RIGHT)); - if(KaelRight) KaelRight->SetGoState(0); - } - }else - { - DoYell(SAY_RECAST_GRAVITY,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_RECAST_GRAVITY); - } - DoCast(m_creature, SPELL_GRAVITY_LAPSE_INITIAL); - GravityLapseTimer = 2000 + diff;// Don't interrupt the visual spell - GravityLapsePhase = 1; - break; - - case 1: - TeleportPlayersToSelf(); - GravityLapseTimer = 1000; - GravityLapsePhase = 2; - break; - - case 2: - CastGravityLapseKnockUp(); - GravityLapseTimer = 1000; - GravityLapsePhase = 3; - break; - - case 3: - CastGravityLapseFly(); - GravityLapseTimer = 30000; - GravityLapsePhase = 4; - for(uint8 i = 0; i < 3; ++i) - { - Creature* Orb = DoSpawnCreature(CREATURE_ARCANE_SPHERE, 5, 5, 0, 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 30000); - if(Orb) SetThreatList(Orb); - } - DoCast(m_creature, SPELL_GRAVITY_LAPSE_CHANNEL); - break; - - case 4: - m_creature->InterruptNonMeleeSpells(false); - DoYell(SAY_TIRED,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_TIRED); - DoCast(m_creature, SPELL_POWER_FEEDBACK); - RemoveGravityLapse(); - GravityLapseTimer = 10000; - GravityLapsePhase = 0; - break; - } - }else GravityLapseTimer -= diff; - } - break; - } - } -}; - -struct MANGOS_DLL_DECL mob_felkael_flamestrikeAI : public ScriptedAI -{ - mob_felkael_flamestrikeAI(Creature *c) : ScriptedAI(c) - { - Reset(); - Heroic = c->GetMap()->IsHeroic() ? true : false; - } - - uint32 FlameStrikeTimer; - bool Heroic; - - void Reset() - { - FlameStrikeTimer = 5000; - - m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - m_creature->setFaction(14); - - DoCast(m_creature, SPELL_FLAMESTRIKE2, true); - } - - void Aggro(Unit *who) {} - void MoveInLineOfSight(Unit *who) {} - void UpdateAI(const uint32 diff) - { - if(FlameStrikeTimer < diff) - { - // *Normal/Heroic mode support - if(Heroic) DoCast(m_creature, SPELL_FLAMESTRIKE1_HEROIC, true); - else DoCast(m_creature, SPELL_FLAMESTRIKE1_NORMAL, true); - m_creature->DealDamage(m_creature, m_creature->GetMaxHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); - }else FlameStrikeTimer -= diff; - } -}; - -struct MANGOS_DLL_DECL mob_felkael_phoenixAI : public ScriptedAI -{ - mob_felkael_phoenixAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 BurnTimer; - - void Reset() - { - m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE + UNIT_FLAG_NON_ATTACKABLE); - BurnTimer = 2000; - } - - void Aggro(Unit* who) {} - - void JustDied(Unit* slayer) - { - DoSpawnCreature(CREATURE_PHOENIX_EGG, 0, 0, 0, 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 45000); - } - - void UpdateAI(const uint32 diff) - { - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - if (BurnTimer < diff) - { - DoCast(m_creature->getVictim(), SPELL_PHOENIX_BURN); - BurnTimer = 2000; - }else BurnTimer -= diff; - - DoMeleeAttackIfReady(); - } -}; - -struct MANGOS_DLL_DECL mob_felkael_phoenix_eggAI : public ScriptedAI -{ - mob_felkael_phoenix_eggAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 HatchTimer; - - void Reset() { HatchTimer = 15000; } - - void Aggro(Unit* who) {} - void MoveInLineOfSight(Unit* who) {} - - void UpdateAI(const uint32 diff) - { - if(HatchTimer < diff) - { - DoSpawnCreature(CREATURE_PHOENIX, 0, 0, 0, 0, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 60000); - m_creature->DealDamage(m_creature, m_creature->GetMaxHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); - }else HatchTimer -= diff; - } -}; - -struct MANGOS_DLL_DECL mob_arcane_sphereAI : public ScriptedAI -{ - mob_arcane_sphereAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 DespawnTimer; - uint32 ChangeTargetTimer; - - bool TargetLocked; - - void Reset() - { - DespawnTimer = 30000; - ChangeTargetTimer = 5000; - TargetLocked = false; - - m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - m_creature->setFaction(14); - DoCast(m_creature, SPELL_ARCANE_SPHERE_PASSIVE, true); - } - - void MoveInLineOfSight(Unit* who) - { - if(TargetLocked) - return; - if(who && who->IsHostileTo(m_creature) && (m_creature->IsWithinDistInMap(who, 25))) - StalkTarget(who); - } - - void Aggro(Unit* who) {} - - void StalkTarget(Unit* target) - { - if(!target) - return; - - m_creature->GetMotionMaster()->MoveChase(target); - TargetLocked = true; - } - - void UpdateAI(const uint32 diff) - { - if(DespawnTimer < diff) - m_creature->DealDamage(m_creature, m_creature->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); - else DespawnTimer -= diff; - - if(!m_creature->getVictim() || !m_creature->SelectHostilTarget()) - return; - - if(ChangeTargetTimer < diff) - { - TargetLocked = false; - ChangeTargetTimer = 10000; - }else ChangeTargetTimer -= diff; - } -}; - -CreatureAI* GetAI_boss_felblood_kaelthas(Creature* c) -{ - return new boss_felblood_kaelthasAI(c); -} - -CreatureAI* GetAI_mob_arcane_sphere(Creature* c) -{ - return new mob_arcane_sphereAI(c); -} - -CreatureAI* GetAI_mob_felkael_phoenix(Creature* c) -{ - return new mob_felkael_phoenixAI(c); -} - -CreatureAI* GetAI_mob_felkael_phoenix_egg(Creature* c) -{ - return new mob_felkael_phoenix_eggAI(c); -} - -CreatureAI* GetAI_mob_felkael_flamestrike(Creature* c) -{ - return new mob_felkael_flamestrikeAI(c); -} - -void AddSC_boss_felblood_kaelthas() -{ - Script *newscript; - - newscript = new Script; - newscript->Name = "boss_felblood_kaelthas"; - newscript->GetAI = GetAI_boss_felblood_kaelthas; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name = "mob_arcane_sphere"; - newscript->GetAI = GetAI_mob_arcane_sphere; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="mob_felkael_phoenix"; - newscript->GetAI = GetAI_mob_felkael_phoenix; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="mob_felkael_phoenix_egg"; - newscript->GetAI = GetAI_mob_felkael_phoenix_egg; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="mob_felkael_flamestrike"; - newscript->GetAI = GetAI_mob_felkael_flamestrike; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: boss_felblood_kaelthas +SD%Complete: 80 +SDComment: Normal and Heroic Support. Issues: Arcane Spheres do not initially follow targets. TODO: Convert Phoenix to ACID. +SDCategory: Magisters' Terrace +EndScriptData */ + +#include "precompiled.h" +#include "def_magisters_terrace.h" +#include "WorldPacket.h" + +/*** Spells ***/ + +// Phase 1 spells + +#define SPELL_FIREBALL_NORMAL 44189 // Deals 2700-3300 damage at current target +#define SPELL_FIREBALL_HEROIC 46164 // 4950-6050 + +#define SPELL_PHOENIX 44194 // Summons a phoenix (Doesn't work?) +#define SPELL_PHOENIX_BURN 44198 // A spell Phoenix uses to damage everything around + +#define SPELL_FLAMESTRIKE1_NORMAL 44190 // Damage part +#define SPELL_FLAMESTRIKE1_HEROIC 46163 // Heroic damage part +#define SPELL_FLAMESTRIKE2 44191 // Flamestrike indicator before the damage +#define SPELL_FLAMESTRIKE3 44192 // Summons the trigger + animation (projectile) + +#define SPELL_SHOCK_BARRIER 46165 // Heroic only; 10k damage shield, followed by Pyroblast +#define SPELL_PYROBLAST 36819 // Heroic only; 45-55k fire damage + +// Phase 2 spells + +#define SPELL_GRAVITY_LAPSE_INITIAL 44224 // Cast at the beginning of every Gravity Lapse +#define SPELL_GRAVITY_LAPSE_CHANNEL 44251 // Channeled; blue beam animation to every enemy in range +#define SPELL_TELEPORT_CENTER 44218 // Should teleport people to the center. Requires DB entry in spell_target_position. +#define SPELL_GRAVITY_LAPSE_FLY 44227 // Hastens flyspeed and allows flying for 1 minute. For some reason removes 44226. +#define SPELL_GRAVITY_LAPSE_DOT 44226 // Knocks up in the air and applies a 300 DPS DoT. +#define SPELL_ARCANE_SPHERE_PASSIVE 44263 // Passive auras on Arcane Spheres +#define SPELL_POWER_FEEDBACK 44233 // Stuns him, making him take 50% more damage for 10 seconds. Cast after Gravity Lapse + +/*** Creatures ***/ +#define CREATURE_PHOENIX 24674 +#define CREATURE_PHOENIX_EGG 24675 +#define CREATURE_ARCANE_SPHERE 24708 + +/*** Dialogues ***/ +#define SAY_AGGRO "Don't look so smug! I know what you're thinking, but Tempest Keep was merely a set back. Did you honestly believe I would trust the future to some blind, half-night elf mongrel? Oh no, he was merely an instrument, a stepping stone to a much larger plan! It has all led to this, and this time, you will not interfere!" +#define SOUND_AGGRO 12413 // This yell should be done when the room is cleared. For now, set it as aggro yell. + +#define SAY_PHOENIX "Vengeance burns!" +#define SOUND_PHOENIX 12415 + +#define SAY_FLAMESTRIKE "Felomin ashal!" +#define SOUND_FLAMESTRIKE 12417 + +#define SAY_GRAVITY_LAPSE "I'll turn your world... upside... down..." +#define SOUND_GRAVITY_LAPSE 12418 + +#define SAY_TIRED "Master... grant me strength." +#define SOUND_TIRED 12419 + +#define SAY_RECAST_GRAVITY "Do not... get too comfortable." +#define SOUND_RECAST_GRAVITY 12420 + +#define SAY_DEATH "My demise accomplishes nothing! The Master will have you! You will drown in your own blood! This world shall burn! Aaaghh!" +#define SOUND_DEATH 12421 + +/** Locations **/ +float KaelLocations[3][2]= +{ + {148.744659, 181.377426}, + {140.823883, 195.403046}, + {156.574188, 195.650482}, +}; +#define LOCATION_Z -16.727455 + +struct MANGOS_DLL_DECL boss_felblood_kaelthasAI : public ScriptedAI +{ + boss_felblood_kaelthasAI(Creature* c) : ScriptedAI(c) + { + pInstance = ((ScriptedInstance*)c->GetInstanceData()); + Reset(); + Heroic = c->GetMap()->IsHeroic() ? true : false; + } + + ScriptedInstance* pInstance; + + uint32 FireballTimer; + uint32 PhoenixTimer; + uint32 FlameStrikeTimer; + uint32 CombatPulseTimer; + + //Heroic only + uint32 PyroblastTimer; + + uint32 GravityLapseTimer; + uint32 GravityLapsePhase; + // 0 = No Gravity Lapse + // 1 = Casting Gravity Lapse visual + // 2 = Teleported people to self + // 3 = Knocked people up in the air + // 4 = Applied an aura that allows them to fly, channeling visual, relased Arcane Orbs. + + bool FirstGravityLapse; + bool Heroic; + + uint8 Phase; + // 0 = Not started + // 1 = Fireball; Summon Phoenix; Flamestrike + // 2 = Gravity Lapses + + void Reset() + { + // TODO: Timers + FireballTimer = 0; + PhoenixTimer = 30000; + FlameStrikeTimer = 25000; + CombatPulseTimer = 0; + + PyroblastTimer = 60000; + + GravityLapseTimer = 0; + GravityLapsePhase = 0; + + FirstGravityLapse = true; + + Phase = 0; + + if(pInstance) + pInstance->SetData(DATA_KAELTHAS_EVENT, 0); + } + + void JustDied(Unit *killer) + { + DoYell(SAY_DEATH,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_DEATH); + } + + void DamageTaken(Unit* done_by, uint32 &damage) + { + if(damage > m_creature->GetHealth()) + RemoveGravityLapse(); // Remove Gravity Lapse so that players fall to ground if they kill him when in air. + } + + void Aggro(Unit *who) + { + DoYell(SAY_AGGRO,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_AGGRO); + } + + void SetThreatList(Creature* SummonedUnit) + { + if(!SummonedUnit) return; + + std::list& m_threatlist = m_creature->getThreatManager().getThreatList(); + std::list::iterator i = m_threatlist.begin(); + for(i = m_threatlist.begin(); i != m_threatlist.end(); i++) + { + Unit* pUnit = Unit::GetUnit((*m_creature), (*i)->getUnitGuid()); + if(pUnit && pUnit->isAlive()) + { + float threat = m_creature->getThreatManager().getThreat(pUnit); + SummonedUnit->AddThreat(pUnit, threat); + } + } + } + + void TeleportPlayersToSelf() + { + float x = KaelLocations[0][0]; + float y = KaelLocations[0][1]; + m_creature->Relocate(x, y, LOCATION_Z, 0); + //m_creature->SendMonsterMove(x, y, LOCATION_Z, 0, 0, 0); // causes some issues... + std::list::iterator i = m_creature->getThreatManager().getThreatList().begin(); + for (i = m_creature->getThreatManager().getThreatList().begin(); i!= m_creature->getThreatManager().getThreatList().end();++i) + { + Unit* pUnit = Unit::GetUnit((*m_creature), (*i)->getUnitGuid()); + if(pUnit && (pUnit->GetTypeId() == TYPEID_PLAYER)) + pUnit->CastSpell(pUnit, SPELL_TELEPORT_CENTER, true); + } + DoCast(m_creature, SPELL_TELEPORT_CENTER, true); + } + + void CastGravityLapseKnockUp() + { + std::list::iterator i = m_creature->getThreatManager().getThreatList().begin(); + for (i = m_creature->getThreatManager().getThreatList().begin(); i!= m_creature->getThreatManager().getThreatList().end();++i) + { + Unit* pUnit = Unit::GetUnit((*m_creature), (*i)->getUnitGuid()); + if(pUnit && (pUnit->GetTypeId() == TYPEID_PLAYER)) + // Knockback into the air + pUnit->CastSpell(pUnit, SPELL_GRAVITY_LAPSE_DOT, true, 0, 0, m_creature->GetGUID()); + } + } + + void CastGravityLapseFly() // Use Fly Packet hack for now as players can't cast "fly" spells unless in map 530. Has to be done a while after they get knocked into the air... + { + std::list::iterator i = m_creature->getThreatManager().getThreatList().begin(); + for (i = m_creature->getThreatManager().getThreatList().begin(); i!= m_creature->getThreatManager().getThreatList().end();++i) + { + Unit* pUnit = Unit::GetUnit((*m_creature), (*i)->getUnitGuid()); + if(pUnit && (pUnit->GetTypeId() == TYPEID_PLAYER)) + { + // Also needs an exception in spell system. + pUnit->CastSpell(pUnit, SPELL_GRAVITY_LAPSE_FLY, true, 0, 0, m_creature->GetGUID()); + // Use packet hack + WorldPacket data(12); + data.SetOpcode(SMSG_MOVE_SET_CAN_FLY); + data.append(pUnit->GetPackGUID()); + data << uint32(0); + pUnit->SendMessageToSet(&data, true); + } + } + } + + void RemoveGravityLapse() + { + std::list::iterator i = m_creature->getThreatManager().getThreatList().begin(); + for (i = m_creature->getThreatManager().getThreatList().begin(); i!= m_creature->getThreatManager().getThreatList().end();++i) + { + Unit* pUnit = Unit::GetUnit((*m_creature), (*i)->getUnitGuid()); + if(pUnit && (pUnit->GetTypeId() == TYPEID_PLAYER)) + { + pUnit->RemoveAurasDueToSpell(SPELL_GRAVITY_LAPSE_FLY); + pUnit->RemoveAurasDueToSpell(SPELL_GRAVITY_LAPSE_DOT); + WorldPacket data(12); + data.SetOpcode(SMSG_MOVE_UNSET_CAN_FLY); + data.append(pUnit->GetPackGUID()); + data << uint32(0); + pUnit->SendMessageToSet(&data, true); + } + } + } + + void UpdateAI(const uint32 diff) + { + if(!m_creature->getVictim() && !m_creature->SelectHostilTarget()) + return; + + switch(Phase) + { + case 0: + { + // *Heroic mode only: + if(Heroic) + if(PyroblastTimer < diff) + { + DoCast(m_creature, SPELL_SHOCK_BARRIER, true); + DoCast(m_creature->getVictim(), SPELL_PYROBLAST); + PyroblastTimer = 60000; + }else PyroblastTimer -= diff; + + if(FireballTimer < diff) + { + // *Normal/Heroic mode support + if(Heroic) DoCast(m_creature->getVictim(), SPELL_FIREBALL_HEROIC); + else DoCast(m_creature->getVictim(), SPELL_FIREBALL_NORMAL); + FireballTimer = 2000 + rand()%4000; + }else FireballTimer -= diff; + + if(PhoenixTimer < diff) + { + uint32 random = rand()%2 + 1; + float x = KaelLocations[random][0]; + float y = KaelLocations[random][1]; + Creature* Phoenix = m_creature->SummonCreature(CREATURE_PHOENIX, x, y, LOCATION_Z, 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 60000); + if(Phoenix) + { + Phoenix->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE + UNIT_FLAG_NON_ATTACKABLE); + SetThreatList(Phoenix); + } + + DoYell(SAY_PHOENIX, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature,SOUND_PHOENIX); + + PhoenixTimer = 40000; + }else PhoenixTimer -= diff; + + if(FlameStrikeTimer < diff) + { + Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0); + if(target) + { + DoCast(target, SPELL_FLAMESTRIKE3, true); + FlameStrikeTimer = 20000 + rand()%5000; + + DoYell(SAY_FLAMESTRIKE, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_FLAMESTRIKE); + } + }else FlameStrikeTimer -= diff; + + // Below 50% + if(m_creature->GetMaxHealth() * 0.5 > m_creature->GetHealth()) + { + m_creature->ApplySpellImmune(0, IMMUNITY_EFFECT, SPELL_EFFECT_INTERRUPT_CAST, true); + m_creature->StopMoving(); + m_creature->GetMotionMaster()->Clear(); + m_creature->GetMotionMaster()->MoveIdle(); + GravityLapseTimer = 0; + GravityLapsePhase = 0; + Phase = 1; + } + DoMeleeAttackIfReady(); + } + break; + + case 1: + { + if(GravityLapseTimer < diff) + { + switch(GravityLapsePhase) + { + case 0: + if(FirstGravityLapse) // Different yells at 50%, and at every following Gravity Lapse + { + DoYell(SAY_GRAVITY_LAPSE,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_GRAVITY_LAPSE); + FirstGravityLapse = false; + if(pInstance) + { + GameObject* KaelLeft = GameObject::GetGameObject(*m_creature, pInstance->GetData64(DATA_KAEL_STATUE_LEFT)); + if(KaelLeft) KaelLeft->SetGoState(0); + GameObject* KaelRight = GameObject::GetGameObject(*m_creature, pInstance->GetData64(DATA_KAEL_STATUE_RIGHT)); + if(KaelRight) KaelRight->SetGoState(0); + } + }else + { + DoYell(SAY_RECAST_GRAVITY,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_RECAST_GRAVITY); + } + DoCast(m_creature, SPELL_GRAVITY_LAPSE_INITIAL); + GravityLapseTimer = 2000 + diff;// Don't interrupt the visual spell + GravityLapsePhase = 1; + break; + + case 1: + TeleportPlayersToSelf(); + GravityLapseTimer = 1000; + GravityLapsePhase = 2; + break; + + case 2: + CastGravityLapseKnockUp(); + GravityLapseTimer = 1000; + GravityLapsePhase = 3; + break; + + case 3: + CastGravityLapseFly(); + GravityLapseTimer = 30000; + GravityLapsePhase = 4; + for(uint8 i = 0; i < 3; ++i) + { + Creature* Orb = DoSpawnCreature(CREATURE_ARCANE_SPHERE, 5, 5, 0, 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 30000); + if(Orb) SetThreatList(Orb); + } + DoCast(m_creature, SPELL_GRAVITY_LAPSE_CHANNEL); + break; + + case 4: + m_creature->InterruptNonMeleeSpells(false); + DoYell(SAY_TIRED,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_TIRED); + DoCast(m_creature, SPELL_POWER_FEEDBACK); + RemoveGravityLapse(); + GravityLapseTimer = 10000; + GravityLapsePhase = 0; + break; + } + }else GravityLapseTimer -= diff; + } + break; + } + } +}; + +struct MANGOS_DLL_DECL mob_felkael_flamestrikeAI : public ScriptedAI +{ + mob_felkael_flamestrikeAI(Creature *c) : ScriptedAI(c) + { + Reset(); + Heroic = c->GetMap()->IsHeroic() ? true : false; + } + + uint32 FlameStrikeTimer; + bool Heroic; + + void Reset() + { + FlameStrikeTimer = 5000; + + m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + m_creature->setFaction(14); + + DoCast(m_creature, SPELL_FLAMESTRIKE2, true); + } + + void Aggro(Unit *who) {} + void MoveInLineOfSight(Unit *who) {} + void UpdateAI(const uint32 diff) + { + if(FlameStrikeTimer < diff) + { + // *Normal/Heroic mode support + if(Heroic) DoCast(m_creature, SPELL_FLAMESTRIKE1_HEROIC, true); + else DoCast(m_creature, SPELL_FLAMESTRIKE1_NORMAL, true); + m_creature->DealDamage(m_creature, m_creature->GetMaxHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); + }else FlameStrikeTimer -= diff; + } +}; + +struct MANGOS_DLL_DECL mob_felkael_phoenixAI : public ScriptedAI +{ + mob_felkael_phoenixAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 BurnTimer; + + void Reset() + { + m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE + UNIT_FLAG_NON_ATTACKABLE); + BurnTimer = 2000; + } + + void Aggro(Unit* who) {} + + void JustDied(Unit* slayer) + { + DoSpawnCreature(CREATURE_PHOENIX_EGG, 0, 0, 0, 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 45000); + } + + void UpdateAI(const uint32 diff) + { + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + if (BurnTimer < diff) + { + DoCast(m_creature->getVictim(), SPELL_PHOENIX_BURN); + BurnTimer = 2000; + }else BurnTimer -= diff; + + DoMeleeAttackIfReady(); + } +}; + +struct MANGOS_DLL_DECL mob_felkael_phoenix_eggAI : public ScriptedAI +{ + mob_felkael_phoenix_eggAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 HatchTimer; + + void Reset() { HatchTimer = 15000; } + + void Aggro(Unit* who) {} + void MoveInLineOfSight(Unit* who) {} + + void UpdateAI(const uint32 diff) + { + if(HatchTimer < diff) + { + DoSpawnCreature(CREATURE_PHOENIX, 0, 0, 0, 0, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 60000); + m_creature->DealDamage(m_creature, m_creature->GetMaxHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); + }else HatchTimer -= diff; + } +}; + +struct MANGOS_DLL_DECL mob_arcane_sphereAI : public ScriptedAI +{ + mob_arcane_sphereAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 DespawnTimer; + uint32 ChangeTargetTimer; + + bool TargetLocked; + + void Reset() + { + DespawnTimer = 30000; + ChangeTargetTimer = 5000; + TargetLocked = false; + + m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + m_creature->setFaction(14); + DoCast(m_creature, SPELL_ARCANE_SPHERE_PASSIVE, true); + } + + void MoveInLineOfSight(Unit* who) + { + if(TargetLocked) + return; + if(who && who->IsHostileTo(m_creature) && (m_creature->IsWithinDistInMap(who, 25))) + StalkTarget(who); + } + + void Aggro(Unit* who) {} + + void StalkTarget(Unit* target) + { + if(!target) + return; + + m_creature->GetMotionMaster()->MoveChase(target); + TargetLocked = true; + } + + void UpdateAI(const uint32 diff) + { + if(DespawnTimer < diff) + m_creature->DealDamage(m_creature, m_creature->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); + else DespawnTimer -= diff; + + if(!m_creature->getVictim() || !m_creature->SelectHostilTarget()) + return; + + if(ChangeTargetTimer < diff) + { + TargetLocked = false; + ChangeTargetTimer = 10000; + }else ChangeTargetTimer -= diff; + } +}; + +CreatureAI* GetAI_boss_felblood_kaelthas(Creature* c) +{ + return new boss_felblood_kaelthasAI(c); +} + +CreatureAI* GetAI_mob_arcane_sphere(Creature* c) +{ + return new mob_arcane_sphereAI(c); +} + +CreatureAI* GetAI_mob_felkael_phoenix(Creature* c) +{ + return new mob_felkael_phoenixAI(c); +} + +CreatureAI* GetAI_mob_felkael_phoenix_egg(Creature* c) +{ + return new mob_felkael_phoenix_eggAI(c); +} + +CreatureAI* GetAI_mob_felkael_flamestrike(Creature* c) +{ + return new mob_felkael_flamestrikeAI(c); +} + +void AddSC_boss_felblood_kaelthas() +{ + Script *newscript; + + newscript = new Script; + newscript->Name = "boss_felblood_kaelthas"; + newscript->GetAI = GetAI_boss_felblood_kaelthas; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name = "mob_arcane_sphere"; + newscript->GetAI = GetAI_mob_arcane_sphere; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="mob_felkael_phoenix"; + newscript->GetAI = GetAI_mob_felkael_phoenix; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="mob_felkael_phoenix_egg"; + newscript->GetAI = GetAI_mob_felkael_phoenix_egg; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="mob_felkael_flamestrike"; + newscript->GetAI = GetAI_mob_felkael_flamestrike; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/magisters_terrace/boss_priestess_delrissa.cpp b/src/bindings/scripts/scripts/zone/magisters_terrace/boss_priestess_delrissa.cpp index 94b13cd5cd5..a37069542cc 100644 --- a/src/bindings/scripts/scripts/zone/magisters_terrace/boss_priestess_delrissa.cpp +++ b/src/bindings/scripts/scripts/zone/magisters_terrace/boss_priestess_delrissa.cpp @@ -1,1367 +1,1367 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Priestess_Delrissa -SD%Complete: 45 -SDComment: No Heroic support yet. Needs further testing. Several scripts for pets disabled, not seem to require any special script. -SDCategory: Magister's Terrace -EndScriptData */ - -#include "precompiled.h" -#include "def_magisters_terrace.h" - -#define SAY_AGGRO "Annihilate them!" -#define SOUND_AGGRO 12395 - -struct Speech -{ - const char* text; - uint32 sound; -}; - -static Speech LackeyDeath[]= -{ - {"Oh, the horror.", 12398}, - {"Well, aren't you lucky?", 12400}, - {"Now I'm getting annoyed.", 12401}, - {"Lackies be damned! I'll finish you myself!", 12403}, -}; - -static Speech PlayerDeath[]= -{ - {"I call that a good start.", 12405}, - {"I could have sworn there were more of you.", 12407}, - {"Not really much of a group, anymore, is it?", 12409}, - {"One is such a lonely number", 12410}, - {"It's been a kick, really", 12411}, -}; - -#define SAY_DEATH "Not what I had... planned..." -#define SOUND_DEATH 12397 - -#define SPELL_DISPEL_MAGIC 27609 -#define SPELL_FLASH_HEAL 17843 -#define SPELL_SW_PAIN_NORMAL 14032 -#define SPELL_SW_PAIN_HEROIC 15654 -#define SPELL_SHIELD 44291 -#define SPELL_RENEW_NORMAL 44174 -#define SPELL_RENEW_HEROIC 46192 - -#define ORIENT 4.98 -#define POS_Z -19.9215 - -float LackeyLocations[4][2]= -{ - {123.77, 17.6007}, - {131.731, 15.0827}, - {121.563, 15.6213}, - {129.988, 17.2355}, -}; - -const uint32 AddEntry[8]= -{ - 24557, //Kagani Nightstrike - 24558, //Elris Duskhallow - 24554, //Eramas Brightblaze - 24561, //Yazzaj - 24559, //Warlord Salaris - 24555, //Garaxxas - 24553, //Apoko - 24556, //Zelfan -}; - -struct Add -{ - Add(uint32 _entry, uint64 _guid) - { - entry = _entry; - guid = _guid; - } - - uint32 entry; - uint64 guid; -}; - -struct MANGOS_DLL_DECL boss_priestess_delrissaAI : public ScriptedAI -{ - boss_priestess_delrissaAI(Creature* c) : ScriptedAI(c) - { - pInstance = ((ScriptedInstance*)c->GetInstanceData()); - Adds.clear(); - Reset(); - SummonAdds(); - Heroic = c->GetMap()->IsHeroic(); - } - - ScriptedInstance* pInstance; - - std::vector Adds; - - uint8 LackeysKilled; - uint8 PlayersKilled; - - uint32 HealTimer; - uint32 RenewTimer; - uint32 ShieldTimer; - uint32 SWPainTimer; - uint32 DispelTimer; - - uint32 CombatPulseTimer; // Periodically puts all players in the instance in combat - - bool Heroic; - - void Reset() - { - LackeysKilled = 0; - PlayersKilled = 0; - - HealTimer = 15000; - RenewTimer = 10000; - ShieldTimer = 2000; - SWPainTimer = 5000; - DispelTimer = 7500; - - CombatPulseTimer = 5000; - - CheckAdds(); - - if(pInstance) - { - pInstance->SetData(DATA_DELRISSA_EVENT, NOT_STARTED); - pInstance->SetData(DATA_DELRISSA_DEATH_COUNT, 0); - } - else error_log(ERROR_INST_DATA); - } - - void Aggro(Unit* who) - { - DoYell(SAY_AGGRO, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_AGGRO); - - for(uint8 i = 0; i < Adds.size(); ++i) - if(Unit* pAdd = Unit::GetUnit(*m_creature, Adds[i]->guid)) - pAdd->AddThreat(who, 1.0f); - } - - void SummonAdds() - { - std::vector AddList; - for(uint8 i = 0; i < 8; ++i) - AddList.push_back(AddEntry[i]); - - while(AddList.size() > 4) - AddList.erase(AddList.begin() + rand()%AddList.size()); - - for(uint8 i = 0; i < AddList.size(); ++i) - { - Creature* pAdd = m_creature->SummonCreature(AddList[i], LackeyLocations[i][0], LackeyLocations[i][1], POS_Z, ORIENT, TEMPSUMMON_DEAD_DESPAWN, 0); - if(pAdd) - { - Add* nAdd = new Add(AddList[i], pAdd->GetGUID()); - Adds.push_back(nAdd); - } - } - } - - void CheckAdds() - { - if(Adds.empty()) - return; - - for(uint8 i = 0; i < Adds.size(); ++i) - { - bool resummon = true; - Creature* pAdd = ((Creature*)Unit::GetUnit(*m_creature, Adds[i]->guid)); - if(pAdd && pAdd->isAlive()) - { - pAdd->AI()->EnterEvadeMode(); // Force them out of combat and reset if they are in combat. - resummon = false; - } - if(resummon) - { - pAdd = m_creature->SummonCreature(Adds[i]->entry, LackeyLocations[i][0], LackeyLocations[i][1], POS_Z, ORIENT, TEMPSUMMON_DEAD_DESPAWN, 0); - Add* nAdd = new Add(Adds[i]->entry, pAdd->GetGUID()); - Adds.erase(Adds.begin() + i); - Adds.push_back(nAdd); - } - } - } - - void KilledUnit(Unit* victim) - { - if(victim->GetTypeId() != TYPEID_PLAYER) - return; - - DoYell(PlayerDeath[PlayersKilled].text, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, PlayerDeath[PlayersKilled].sound); - if( PlayersKilled < 4 ) - ++PlayersKilled; - } - - void KilledLackey() - { - DoYell(LackeyDeath[LackeysKilled].text, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, LackeyDeath[LackeysKilled].sound); - if( LackeysKilled < 3 ) - ++LackeysKilled; - } - - void JustDied(Unit* killer) - { - DoYell(SAY_DEATH, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_DEATH); - - CheckLootable(); - - if(!pInstance) - { - error_log(ERROR_INST_DATA); - return; - } - - pInstance->SetData(DATA_DELRISSA_DEATH_COUNT, 1); - pInstance->SetData(DATA_DELRISSA_EVENT, DONE); - if(GameObject* Door = GameObject::GetGameObject(*m_creature, pInstance->GetData64(DATA_DELRISSA_DOOR))) - Door->SetGoState(0); - } - - void CheckLootable() - { - if(LackeysKilled > 4) - m_creature->SetFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE); - else - m_creature->RemoveFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE); - } - - void UpdateAI(const uint32 diff) - { - if(!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - if(HealTimer < diff) - { - uint32 health = m_creature->GetHealth(); - Unit* target = m_creature; - for(uint8 i = 0; i < Adds.size(); ++i) - if(Unit* pAdd = Unit::GetUnit(*m_creature, Adds[i]->guid)) - if(pAdd->isAlive() && pAdd->GetHealth() < health) - target = pAdd; - - DoCast(target, SPELL_FLASH_HEAL); - HealTimer = 15000; - }else HealTimer -= diff; - - if(RenewTimer < diff) - { - Unit* target = m_creature; - if(rand()%2 == 1) - { - std::vector::iterator itr = Adds.begin() + rand()%Adds.size(); - Unit* pAdd = Unit::GetUnit(*m_creature, (*itr)->guid); - if(pAdd && pAdd->isAlive()) - target = pAdd; - } - DoCast(target,Heroic ? SPELL_RENEW_HEROIC : SPELL_RENEW_NORMAL); - RenewTimer = 5000; - }else RenewTimer -= diff; - - if(ShieldTimer < diff) - { - Unit* target = m_creature; - if(rand()%2 == 1) - { - std::vector::iterator itr = Adds.begin() + rand()%Adds.size(); - if(Unit* pAdd = Unit::GetUnit(*m_creature, (*itr)->guid)) - if(!pAdd->HasAura(SPELL_SHIELD, 0) && pAdd->isAlive()) - target = pAdd; - } - DoCast(target, SPELL_SHIELD); - ShieldTimer = 7500; - }else ShieldTimer -= diff; - - if(DispelTimer < diff) - { - Unit* target = NULL; - bool friendly = false; - if(rand()%2 == 1) - target = SelectUnit(SELECT_TARGET_RANDOM, 0); - else - { - friendly = true; - if(rand()%2 == 1) - target = m_creature; - else - { - std::vector::iterator itr = Adds.begin() + rand()%Adds.size(); - Unit* pAdd = Unit::GetUnit(*m_creature, (*itr)->guid); - if(pAdd && pAdd->isAlive()) - target = pAdd; - } - } - if(target) - { - DoCast(target, SPELL_DISPEL_MAGIC); - DispelTimer = 12000; - } - }else DispelTimer -= diff; - - if(SWPainTimer < diff) - { - DoCast(SelectUnit(SELECT_TARGET_RANDOM, 0),Heroic ? SPELL_SW_PAIN_HEROIC : SPELL_SW_PAIN_NORMAL); - SWPainTimer = 10000; - }else SWPainTimer -= diff; - - /* - if(CombatPulseTimer < diff) - { - DoZoneInCombat(); - for(uint8 i = 0; i < Adds.size(); ++i) - { - if(Unit* pAdd = Unit::GetUnit(*m_creature, Add[i]->guid)) - if(pAdd->isAlive()) - DoZoneInCombat(pAdd); - } - - CombatPulseTimer = 10000; - }else CombatPulseTimer -= diff;*/ - - DoMeleeAttackIfReady(); - } -}; - -#define SPELL_HEALING_POTION 15503 - -struct MANGOS_DLL_DECL boss_priestess_guestAI : public ScriptedAI -{ - boss_priestess_guestAI(Creature* c) : ScriptedAI(c) - { - Group.clear(); - pInstance = ((ScriptedInstance*)c->GetInstanceData()); - Reset(); - AcquireGUIDs(); - } - - ScriptedInstance* pInstance; - - std::vector Group; - - uint32 ResetThreatTimer; - - bool UsedPotion; - - void Reset() - { - UsedPotion = false; - - ResetThreatTimer = 5000 + rand()%15000; // These guys like to switch targets often, and are not meant to be tanked. - } - - void Aggro(Unit* who) {} - - void JustDied(Unit* killer) - { - if(!pInstance) - { - error_log(ERROR_INST_DATA); - return; - } - - Creature* Delrissa = ((Creature*)Unit::GetUnit(*m_creature, pInstance->GetData64(DATA_DELRISSA))); - if(Delrissa) - { - ((boss_priestess_delrissaAI*)Delrissa->AI())->KilledLackey(); - if(!Delrissa->isAlive() && pInstance->GetData(DATA_DELRISSA_DEATH_COUNT) > 3) - ((boss_priestess_delrissaAI*)Delrissa->AI())->CheckLootable(); - - pInstance->SetData(DATA_DELRISSA_DEATH_COUNT, 1); - } - } - - void KilledUnit(Unit* victim) - { - if(!pInstance) - { - error_log(ERROR_INST_DATA); - return; - } - - Creature* Delrissa = ((Creature*)Unit::GetUnit(*m_creature, pInstance->GetData64(DATA_DELRISSA))); - if(Delrissa) - Delrissa->AI()->KilledUnit(victim); - } - - void AcquireGUIDs() - { - if(!pInstance) - { - error_log(ERROR_INST_DATA); - return; - } - - Creature* Delrissa = ((Creature*)Unit::GetUnit(*m_creature, pInstance->GetData64(DATA_DELRISSA))); - if(Delrissa) - { - Group = ((boss_priestess_delrissaAI*)Delrissa->AI())->Adds; - Add* dAdd = new Add(Delrissa->GetEntry(), Delrissa->GetGUID()); - Group.push_back(dAdd); - } - } - - void UpdateAI(const uint32 diff) - { - if(((m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < 25) && !UsedPotion) - { - DoCast(m_creature, SPELL_HEALING_POTION, true); - UsedPotion = true; - } - - if(ResetThreatTimer < diff) - { - DoResetThreat(); - ResetThreatTimer = 5000 + rand()%15000; - }else ResetThreatTimer -= diff; - } -}; - -#define SPELL_KIDNEY_SHOT 27615 -#define SPELL_GOUGE 12540 -#define SPELL_KICK 27613 -#define SPELL_VANISH 44290 -#define SPELL_BACKSTAB 15657 -#define SPELL_EVISCERATE 27611 - -struct MANGOS_DLL_DECL boss_kagani_nightstrikeAI : public boss_priestess_guestAI -{ - //Rogue - boss_kagani_nightstrikeAI(Creature *c) : boss_priestess_guestAI(c) {} - - uint32 Gouge_Timer; - uint32 Kick_Timer; - uint32 Vanish_Timer; - uint32 Eviscerate_Timer; - uint32 Wait_Timer; - bool InVanish; - - void Reset() - { - Gouge_Timer = 5500; - Kick_Timer = 7000; - Vanish_Timer = 2000; - Eviscerate_Timer = 6000; - Wait_Timer = 5000; - InVanish = false; - m_creature->SetVisibility(VISIBILITY_ON); - - boss_priestess_guestAI::Reset(); - } - - void UpdateAI(const uint32 diff) - { - if(!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - boss_priestess_guestAI::UpdateAI(diff); - - if(Vanish_Timer < diff) - { - m_creature->SetVisibility(VISIBILITY_OFF); // ...? Hacklike - DoCast(m_creature, SPELL_VANISH); - InVanish = true; - Vanish_Timer = 30000; - Wait_Timer = 10000; - DoResetThreat(); - m_creature->AddThreat(SelectUnit(SELECT_TARGET_RANDOM, 0), 1000.0f); - }else Vanish_Timer -= diff; - - if(InVanish) - if(Wait_Timer < diff) - { - DoCast(m_creature->getVictim(), SPELL_BACKSTAB, true); - DoCast(m_creature->getVictim(), SPELL_KIDNEY_SHOT, true); - m_creature->SetVisibility(VISIBILITY_ON); // ...? Hacklike - InVanish = false; - }else Wait_Timer -= diff; - - if(Gouge_Timer < diff) - { - DoCast(m_creature->getVictim(), SPELL_GOUGE); - m_creature->getThreatManager().modifyThreatPercent(m_creature->getVictim(),-100); - Gouge_Timer = 5500; - }else Gouge_Timer -= diff; - - if(Kick_Timer < diff) - { - DoCast(m_creature->getVictim(), SPELL_KICK); - Kick_Timer = 7000; - }else Kick_Timer -= diff; - - if(Eviscerate_Timer < diff) - { - DoCast(m_creature->getVictim(), SPELL_EVISCERATE); - Eviscerate_Timer = 4000; - }else Eviscerate_Timer -= diff; - - if(!InVanish) - DoMeleeAttackIfReady(); - } -}; - -#define SPELL_IMMOLATE 44267 -#define SPELL_SHADOW_BOLT 12471 -#define SPELL_SEED_OF_CORRUPTION 44141 -#define SPELL_CURSE_OF_AGONY 14875 -#define SPELL_FEAR 38595 -#define SPELL_IMP_FIREBALL 44164 -#define SPELL_SUMMON_IMP 44163 - -//#define CREATURE_IMP 44163 -//#define CREATURE_FIZZLE 24656 - -/*struct MANGOS_DLL_DECL mob_fizzleAI : public ScriptedAI -{ - mob_fizzleAI(Creature *c) : ScriptedAI(c) - { - Reset(); - } - - uint64 EllrisGUID; - uint32 Firebal_Timer; - - void Reset() { EllrisGUID = 0; } - - void KilledUnit(Unit* victim); - void JustDied(Unit* killer); - - void Aggro(Unit* who){} - - void UpdateAI(const uint32 diff) - { - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - //Chain cast - if (!m_creature->IsNonMeleeSpellCasted(false)) - DoCast(m_creature->getVictim(),SPELL_IMP_FIREBALL); - else DoMeleeAttackIfReady(); - } -};*/ - -struct MANGOS_DLL_DECL boss_ellris_duskhallowAI : public boss_priestess_guestAI -{ - //Warlock - boss_ellris_duskhallowAI(Creature *c) : boss_priestess_guestAI(c) - { - } - - bool HasSummonedImp; - - uint32 Immolate_Timer; - uint32 Shadow_Bolt_Timer; - uint32 Seed_of_Corruption_Timer; - uint32 Curse_of_Agony_Timer; - uint32 Fear_Timer; - - void Reset() - { - //HasSummonedImp = false; - - Immolate_Timer = 6000; - Shadow_Bolt_Timer = 3000; - Seed_of_Corruption_Timer = 2000; - Curse_of_Agony_Timer = 1000; - Fear_Timer = 10000; - - boss_priestess_guestAI::Reset(); - } - - void JustDied(Unit* killer) - { - boss_priestess_guestAI::JustDied(killer); - } - - void UpdateAI(const uint32 diff) - { - if(!HasSummonedImp) - { - //Imp will not despawn unless it's killed, even if owner dies, this is correct way. - DoCast(m_creature,SPELL_SUMMON_IMP); - HasSummonedImp = true; - } - - if(!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - boss_priestess_guestAI::UpdateAI(diff); - - if(Immolate_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_IMMOLATE); - Immolate_Timer = 6000; - }else Immolate_Timer -= diff; - - if(Shadow_Bolt_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_SHADOW_BOLT); - Shadow_Bolt_Timer = 5000; - }else Shadow_Bolt_Timer -= diff; - - if(Seed_of_Corruption_Timer < diff) - { - DoCast(SelectUnit(SELECT_TARGET_RANDOM, 0), SPELL_SEED_OF_CORRUPTION); - Seed_of_Corruption_Timer = 10000; - }else Seed_of_Corruption_Timer -= diff; - - if(Curse_of_Agony_Timer < diff) - { - DoCast(SelectUnit(SELECT_TARGET_RANDOM, 0), SPELL_CURSE_OF_AGONY); - Curse_of_Agony_Timer = 13000; - }else Curse_of_Agony_Timer -= diff; - - if(Fear_Timer < diff) - { - DoCast(SelectUnit(SELECT_TARGET_RANDOM, 0), SPELL_FEAR); - Fear_Timer = 10000; - }else Fear_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; - -/*void mob_fizzleAI::JustDied(Unit* killer) -{ - if(Creature* Ellris = ((Creature*)Unit::GetUnit(*m_creature, EllrisGUID))) - ((boss_ellris_duskhallowAI*)Ellris->AI())->ImpGUID = 0; -} - -void mob_fizzleAI::KilledUnit(Unit* victim) -{ - if(Creature* Ellris = ((Creature*)Unit::GetUnit(*m_creature, EllrisGUID))) - ((boss_ellris_duskhallowAI*)Ellris->AI())->KilledUnit(victim); -}*/ - -#define SPELL_KNOCKDOWN 11428 -#define SPELL_SNAP_KICK 46182 - -struct MANGOS_DLL_DECL boss_eramas_brightblazeAI : public boss_priestess_guestAI -{ - //Monk - boss_eramas_brightblazeAI(Creature *c) : boss_priestess_guestAI(c) {} - - uint32 Knockdown_Timer; - uint32 Snap_Kick_Timer; - - void Reset() - { - Knockdown_Timer = 6000; - Snap_Kick_Timer = 4500; - - boss_priestess_guestAI::Reset(); - } - - void UpdateAI(const uint32 diff) - { - if(!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - boss_priestess_guestAI::UpdateAI(diff); - - if(Knockdown_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_KNOCKDOWN); - Knockdown_Timer = 6000; - }else Knockdown_Timer -= diff; - - if(Snap_Kick_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_SNAP_KICK); - Snap_Kick_Timer = 4500; - }else Snap_Kick_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; - -#define SPELL_POLYMORPH 13323 -#define SPELL_ICE_BLOCK 27619 -#define SPELL_BLIZZARD 44178 -#define SPELL_ICE_LANCE 46194 -#define SPELL_CONE_OF_COLD 38384 -#define SPELL_FROSTBOLT 15043 -#define SPELL_BLINK 14514 - -struct MANGOS_DLL_DECL boss_yazzaiAI : public boss_priestess_guestAI -{ - //Mage - boss_yazzaiAI(Creature *c) : boss_priestess_guestAI(c) {} - - bool HasIceBlocked; - - uint32 Polymorph_Timer; - uint32 Ice_Block_Timer; - uint32 Wait_Timer; - uint32 Blizzard_Timer; - uint32 Ice_Lance_Timer; - uint32 Cone_of_Cold_Timer; - uint32 Frostbolt_Timer; - uint32 Blink_Timer; - - void Reset() - { - HasIceBlocked = false; - - Polymorph_Timer = 1000; - Ice_Block_Timer = 20000; - Wait_Timer = 10000; - Blizzard_Timer = 8000; - Ice_Lance_Timer = 12000; - Cone_of_Cold_Timer = 10000; - Frostbolt_Timer = 3000; - Blink_Timer = 8000; - - boss_priestess_guestAI::Reset(); - } - - void UpdateAI(const uint32 diff) - { - if(!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - boss_priestess_guestAI::UpdateAI(diff); - - if(Polymorph_Timer < diff) - { - Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0); - if(target) - { - DoCast(target, SPELL_POLYMORPH); - m_creature->getThreatManager().modifyThreatPercent(target,-100); - Polymorph_Timer = 20000; - } - }else Polymorph_Timer -= diff; - - if(((m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < 35) && !HasIceBlocked) - { - DoCast(m_creature, SPELL_ICE_BLOCK); - HasIceBlocked = true; - } - - if(Blizzard_Timer < diff) - { - DoCast(SelectUnit(SELECT_TARGET_RANDOM, 0), SPELL_BLIZZARD); - Blizzard_Timer = 8000; - }else Blizzard_Timer -= diff; - - if(Ice_Lance_Timer < diff) - { - DoCast(m_creature->getVictim(), SPELL_ICE_LANCE); - Ice_Lance_Timer = 12000; - }else Ice_Lance_Timer -= diff; - - if(Cone_of_Cold_Timer < diff) - { - DoCast(m_creature->getVictim(), SPELL_CONE_OF_COLD); - Cone_of_Cold_Timer = 10000; - }else Cone_of_Cold_Timer -= diff; - - if(Frostbolt_Timer < diff) - { - DoCast(m_creature->getVictim(), SPELL_FROSTBOLT); - Frostbolt_Timer = 8000; - }else Frostbolt_Timer -= diff; - - if(Blink_Timer < diff) - { - bool InMeleeRange = false; - std::list& t_list = m_creature->getThreatManager().getThreatList(); - for(std::list::iterator itr = t_list.begin(); itr!= t_list.end(); ++itr) - { - if(Unit* target = Unit::GetUnit(*m_creature, (*itr)->getUnitGuid())) - //if in melee range - if (target->IsWithinDistInMap(m_creature, 5)) - { - InMeleeRange = true; - break; - } - } - //if anybody is in melee range than escape by blink - if(InMeleeRange) - DoCast(m_creature, SPELL_BLINK); - - Blink_Timer = 8000; - }else Blink_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; - -#define SPELL_INTERCEPT_STUN 27577 -#define SPELL_DISARM 27581 -#define SPELL_PIERCING_HOWL 23600 -#define SPELL_FRIGHTENING_SHOUT 19134 -#define SPELL_HAMSTRING 27584 -#define SPELL_BATTLE_SHOUT 27578 -#define SPELL_MORTAL_STRIKE 44268 - -struct MANGOS_DLL_DECL boss_warlord_salarisAI : public boss_priestess_guestAI -{ - //Warrior - boss_warlord_salarisAI(Creature *c) : boss_priestess_guestAI(c) {} - - uint32 Intercept_Stun_Timer; - uint32 Disarm_Timer; - uint32 Piercing_Howl_Timer; - uint32 Frightening_Shout_Timer; - uint32 Hamstring_Timer; - uint32 Mortal_Strike_Timer; - - void Reset() - { - Intercept_Stun_Timer = 500; - Disarm_Timer = 6000; - Piercing_Howl_Timer = 10000; - Frightening_Shout_Timer = 18000; - Hamstring_Timer = 4500; - Mortal_Strike_Timer = 8000; - DoCast(m_creature, SPELL_BATTLE_SHOUT); - boss_priestess_guestAI::Reset(); - } - - void Aggro(Unit* who) - { - DoCast(m_creature, SPELL_BATTLE_SHOUT); - } - - void UpdateAI(const uint32 diff) - { - if(!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - boss_priestess_guestAI::UpdateAI(diff); - - if(Intercept_Stun_Timer < diff) - { - bool InMeleeRange = false; - std::list& t_list = m_creature->getThreatManager().getThreatList(); - for(std::list::iterator itr = t_list.begin(); itr!= t_list.end(); ++itr) - { - if(Unit* target = Unit::GetUnit(*m_creature, (*itr)->getUnitGuid())) - //if in melee range - if (target->IsWithinDistInMap(m_creature, 5)) - { - InMeleeRange = true; - break; - } - } - //if nobody is in melee range than try to use Intercept - if(!InMeleeRange) - DoCast(SelectUnit(SELECT_TARGET_RANDOM, 0), SPELL_INTERCEPT_STUN); - Intercept_Stun_Timer = 10000; - }else Intercept_Stun_Timer -= diff; - - if(Disarm_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_DISARM); - Disarm_Timer = 6000; - }else Disarm_Timer -= diff; - - if(Hamstring_Timer < diff) - { - DoCast(m_creature->getVictim(), SPELL_HAMSTRING); - Hamstring_Timer = 4500; - }else Hamstring_Timer -= diff; - - if(Mortal_Strike_Timer < diff) - { - DoCast(m_creature->getVictim(), SPELL_MORTAL_STRIKE); - Mortal_Strike_Timer = 4500; - }else Mortal_Strike_Timer -= diff; - - if(Piercing_Howl_Timer < diff) - { - DoCast(m_creature->getVictim(), SPELL_PIERCING_HOWL); - Piercing_Howl_Timer = 10000; - }else Piercing_Howl_Timer -= diff; - - if(Frightening_Shout_Timer < diff) - { - DoCast(m_creature->getVictim(), SPELL_FRIGHTENING_SHOUT); - Frightening_Shout_Timer = 18000; - }else Frightening_Shout_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; - -#define SPELL_AIMED_SHOT 44271 -#define SPELL_SHOOT 15620 -#define SPELL_CONCUSSIVE_SHOT 27634 -#define TRIGGER_CONCUSSIVE_SHOT 19410 -#define SPELL_MULTI_SHOT 31942 -#define SPELL_WING_CLIP 44286 -#define SPELL_FREEZING_TRAP 44136 - -#define CREATURE_SLIVER 24552 - -/*struct MANGOS_DLL_DECL mob_sliverAI : public ScriptedAI -{ - mob_sliverAI(Creature *c) : ScriptedAI(c) - { - Reset(); - } - - uint64 GaraxxasGUID; - - void Reset() { GaraxxasGUID = 0; } - - void KilledUnit(Unit* victim); - void JustDied(Unit* killer); - - void Aggro(Unit* who){} - -};*/ - -struct MANGOS_DLL_DECL boss_garaxxasAI : public boss_priestess_guestAI -{ - //Hunter - boss_garaxxasAI(Creature *c) : boss_priestess_guestAI(c) {} - - //uint64 SliverGUID; - bool HasSummonedSliver; - - uint32 Aimed_Shot_Timer; - uint32 Shoot_Timer; - uint32 Concussive_Shot_Timer; - uint32 Multi_Shot_Timer; - uint32 Wing_Clip_Timer; - uint32 Freezing_Trap_Timer; - - void Reset() - { - //SliverGUID = 0; - //HasSummonedSliver = false; - - Aimed_Shot_Timer = 6000; - Shoot_Timer = 2500; - Concussive_Shot_Timer = 8000; - Multi_Shot_Timer = 10000; - Wing_Clip_Timer = 4000; - Freezing_Trap_Timer = 15000; - - boss_priestess_guestAI::Reset(); - } - - void JustDied(Unit* killer) - { - boss_priestess_guestAI::JustDied(killer); - } - - void UpdateAI(const uint32 diff) - { - if(!HasSummonedSliver) - { - Creature* Sliver = m_creature->SummonCreature(CREATURE_SLIVER, 0, 0, 0, 0, TEMPSUMMON_CORPSE_DESPAWN, 0); - if(Sliver) - { - //((mob_sliverAI*)Sliver->AI())->GaraxxasGUID = m_creature->GetGUID(); - //SliverGUID = Sliver->GetGUID(); - HasSummonedSliver = true; - } - } - - if(!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - boss_priestess_guestAI::UpdateAI(diff); - - if(m_creature->IsWithinDistInMap(m_creature->getVictim(), 5)) - { - if(Wing_Clip_Timer < diff) - { - DoCast(m_creature->getVictim(), SPELL_WING_CLIP); - Wing_Clip_Timer = 4000; - }else Wing_Clip_Timer -= diff; - - if(Freezing_Trap_Timer < diff) - { - DoCast(m_creature->getVictim(), SPELL_FREEZING_TRAP); - m_creature->getThreatManager().modifyThreatPercent(m_creature->getVictim(),-100); - Freezing_Trap_Timer = 30000; - }else Freezing_Trap_Timer -= diff; - - if(!m_creature->getVictim()->hasUnitState(UNIT_STAT_STUNDED | UNIT_STAT_ROOT | UNIT_STAT_CONFUSED | UNIT_STAT_DISTRACTED)) - DoMeleeAttackIfReady(); - }else - { - if(Concussive_Shot_Timer < diff) - { - DoCast(m_creature->getVictim(), SPELL_CONCUSSIVE_SHOT); - Concussive_Shot_Timer = 8000; - }else Concussive_Shot_Timer -= diff; - - if(Multi_Shot_Timer < diff) - { - DoCast(m_creature->getVictim(), SPELL_MULTI_SHOT); - Multi_Shot_Timer = 10000; - }else Multi_Shot_Timer -= diff; - - if(Aimed_Shot_Timer < diff) - { - DoCast(m_creature->getVictim(), SPELL_AIMED_SHOT); - Aimed_Shot_Timer = 6000; - }else Aimed_Shot_Timer -= diff; - - if(Shoot_Timer < diff) - { - DoCast(m_creature->getVictim(), SPELL_SHOOT); - Shoot_Timer = 2500; - }else Shoot_Timer -= diff; - } - } -}; - -/*void mob_sliverAI::JustDied(Unit* killer) -{ - if(Creature* Garaxxas = ((Creature*)Unit::GetUnit(*m_creature, GaraxxasGUID))) - ((boss_garaxxasAI*)Garaxxas->AI())->SliverGUID = 0; -} - -void mob_sliverAI::KilledUnit(Unit* victim) -{ - if(Creature* Garaxxas = ((Creature*)Unit::GetUnit(*m_creature, GaraxxasGUID))) - ((boss_garaxxasAI*)Garaxxas->AI())->KilledUnit(victim); -}*/ - -#define SPELL_WINDFURY_TOTEM 27621 -#define SPELL_WAR_STOMP 46026 -#define SPELL_PURGE 27626 -#define SPELL_LESSER_HEALING_WAVE 44256 -#define SPELL_FROST_SHOCK 21401 -#define SPELL_FIRE_NOVA_TOTEM 44257 -#define SPELL_EARTHBIND_TOTEM 15786 - -struct MANGOS_DLL_DECL boss_apokoAI : public boss_priestess_guestAI -{ - //Shaman - boss_apokoAI(Creature *c) : boss_priestess_guestAI(c) {} - - uint32 Totem_Timer; - uint8 Totem_Amount; - uint32 War_Stomp_Timer; - uint32 Purge_Timer; - uint32 Healing_Wave_Timer; - uint32 Frost_Shock_Timer; - - void Reset() - { - Totem_Timer = 2000; - Totem_Amount = 1; - War_Stomp_Timer = 10000; - Purge_Timer = 8000; - Healing_Wave_Timer = 5000; - Frost_Shock_Timer = 7000; - - boss_priestess_guestAI::Reset(); - } - - void UpdateAI(const uint32 diff) - { - if(!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - boss_priestess_guestAI::UpdateAI(diff); - - if(Totem_Timer < diff) - { - switch(rand()%3) - { - case 0: - DoCast(m_creature, SPELL_WINDFURY_TOTEM); - break; - case 1: - DoCast(m_creature, SPELL_FIRE_NOVA_TOTEM); - break; - case 2: - DoCast(m_creature, SPELL_EARTHBIND_TOTEM); - break; - } - ++Totem_Amount; - Totem_Timer = Totem_Amount*2000; - }else Totem_Timer -= diff; - - if(War_Stomp_Timer < diff) - { - DoCast(m_creature, SPELL_WAR_STOMP); - War_Stomp_Timer = 10000; - }else War_Stomp_Timer -= diff; - - if(Purge_Timer < diff) - { - DoCast(SelectUnit(SELECT_TARGET_RANDOM, 0), SPELL_PURGE); - Purge_Timer = 15000; - }else Purge_Timer -= diff; - - if(Frost_Shock_Timer < diff) - { - DoCast(m_creature->getVictim(), SPELL_FROST_SHOCK); - Frost_Shock_Timer = 7000; - }else Frost_Shock_Timer -= diff; - - if(Healing_Wave_Timer < diff) - { - // std::vector::iterator itr = Group.begin() + rand()%Group.size(); - // uint64 guid = (*itr)->guid; - // if(guid) - // { - // Unit* pAdd = Unit::GetUnit(*m_creature, (*itr)->guid); - // if(pAdd && pAdd->isAlive()) - // { - DoCast(m_creature, SPELL_LESSER_HEALING_WAVE); - Healing_Wave_Timer = 5000; - // } - // } - }else Healing_Wave_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; - -#define SPELL_GOBLIN_DRAGON_GUN 44272 -#define SPELL_ROCKET_LAUNCH 44137 -#define SPELL_RECOMBOBULATE 44274 -#define SPELL_HIGH_EXPLOSIVE_SHEEP 44276 -#define SPELL_FEL_IRON_BOMB 46024 -#define SPELL_SHEEP_EXPLOSION 44279 - -#define CREATURE_EXPLOSIVE_SHEEP 24715 - -struct MANGOS_DLL_DECL boss_zelfanAI : public boss_priestess_guestAI -{ - //Engineer - boss_zelfanAI(Creature *c) : boss_priestess_guestAI(c) {} - - uint32 Goblin_Dragon_Gun_Timer; - uint32 Rocket_Launch_Timer; - uint32 Recombobulate_Timer; - uint32 High_Explosive_Sheep_Timer; - uint32 Fel_Iron_Bomb_Timer; - - void Reset() - { - Goblin_Dragon_Gun_Timer = 20000; - Rocket_Launch_Timer = 7000; - Recombobulate_Timer = 4000; - High_Explosive_Sheep_Timer = 10000; - Fel_Iron_Bomb_Timer = 15000; - - boss_priestess_guestAI::Reset(); - } - - void UpdateAI(const uint32 diff) - { - if(!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - boss_priestess_guestAI::UpdateAI(diff); - - if(Goblin_Dragon_Gun_Timer < diff) - { - DoCast(m_creature->getVictim(), SPELL_GOBLIN_DRAGON_GUN); - Goblin_Dragon_Gun_Timer = 10000; - }else Goblin_Dragon_Gun_Timer -= diff; - - if(Rocket_Launch_Timer < diff) - { - DoCast(m_creature->getVictim(), SPELL_ROCKET_LAUNCH); - Rocket_Launch_Timer = 9000; - }else Rocket_Launch_Timer -= diff; - - if(Fel_Iron_Bomb_Timer < diff) - { - DoCast(m_creature->getVictim(), SPELL_FEL_IRON_BOMB); - Fel_Iron_Bomb_Timer = 15000; - }else Fel_Iron_Bomb_Timer -= diff; - - if(Recombobulate_Timer < diff) - { - for(uint8 i = 0; i < Group.size(); ++i) - if(Unit* pAdd = Unit::GetUnit(*m_creature, Group[i]->guid)) - if(pAdd->IsPolymorphed()) - { - DoCast(pAdd, SPELL_RECOMBOBULATE); - break; - } - }else Recombobulate_Timer -= diff; - - if(High_Explosive_Sheep_Timer < diff) - { - DoCast(m_creature, SPELL_HIGH_EXPLOSIVE_SHEEP); - High_Explosive_Sheep_Timer = 65000; - }else High_Explosive_Sheep_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; - -//struct MANGOS_DLL_DECL mob_high_explosive_sheepAI : public ScriptedAI -//{ -// mob_high_explosive_sheepAI(Creature *c) : ScriptedAI(c) {Reset();} -// -// uint32 Explosion_Timer; -// -// void Reset() -// { -// Explosion_Timer = 60000; -// } -// -// void JustDied(Unit *Killer){} -// -// void Aggro(Unit *who){} -// -// void UpdateAI(const uint32 diff) -// { -// if(Explosion_Timer < diff) -// { -// DoCast(m_creature->getVictim(), SPELL_SHEEP_EXPLOSION); -// }else -// Explosion_Timer -= diff; -// } -//}; - -/*CreatureAI* GetAI_mob_sliver(Creature *_Creature) -{ - return new mob_sliverAI (_Creature); -};*/ - -//CreatureAI* GetAI_mob_high_explosive_sheep(Creature *_Creature) -//{ -// return new mob_high_explosive_sheepAI (_Creature); -//}; - -/*CreatureAI* GetAI_mob_fizzle(Creature *_Creature) -{ - return new mob_fizzleAI (_Creature); -};*/ - -CreatureAI* GetAI_boss_priestess_delrissa(Creature *_Creature) -{ - return new boss_priestess_delrissaAI (_Creature); -} - -CreatureAI* GetAI_boss_kagani_nightstrike(Creature *_Creature) -{ - return new boss_kagani_nightstrikeAI (_Creature); -} - -CreatureAI* GetAI_ellris_duskhallow(Creature *_Creature) -{ - return new boss_ellris_duskhallowAI (_Creature); -} - -CreatureAI* GetAI_eramas_brightblaze(Creature *_Creature) -{ - return new boss_eramas_brightblazeAI (_Creature); -} - -CreatureAI* GetAI_yazzai(Creature *_Creature) -{ - return new boss_yazzaiAI (_Creature); -} - -CreatureAI* GetAI_warlord_salaris(Creature *_Creature) -{ - return new boss_warlord_salarisAI (_Creature); -} - -CreatureAI* GetAI_garaxxas(Creature *_Creature) -{ - return new boss_garaxxasAI (_Creature); -} - -CreatureAI* GetAI_apoko(Creature *_Creature) -{ - return new boss_apokoAI (_Creature); -} - -CreatureAI* GetAI_zelfan(Creature *_Creature) -{ - return new boss_zelfanAI (_Creature); -} - -void AddSC_boss_priestess_delrissa() -{ - Script *newscript; - - newscript = new Script; - newscript->Name="boss_priestess_delrissa"; - newscript->GetAI = GetAI_boss_priestess_delrissa; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="boss_kagani_nightstrike"; - newscript->GetAI = GetAI_boss_kagani_nightstrike; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="boss_ellris_duskhallow"; - newscript->GetAI = GetAI_ellris_duskhallow; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="boss_eramas_brightblaze"; - newscript->GetAI = GetAI_eramas_brightblaze; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="boss_yazzai"; - newscript->GetAI = GetAI_yazzai; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="boss_warlord_salaris"; - newscript->GetAI = GetAI_warlord_salaris; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="boss_garaxxas"; - newscript->GetAI = GetAI_garaxxas; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="boss_apoko"; - newscript->GetAI = GetAI_apoko; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="boss_zelfan"; - newscript->GetAI = GetAI_zelfan; - m_scripts[nrscripts++] = newscript; - - /*newscript = new Script; - newscript->Name="mob_high_explosive_sheep"; - newscript->GetAI = GetAI_mob_high_explosive_sheep; - m_scripts[nrscripts++] = newscript;*/ - - /*newscript = new Script; - newscript->Name="mob_fizzle"; - newscript->GetAI = GetAI_mob_fizzle; - m_scripts[nrscripts++] = newscript;*/ - - /*newscript = new Script; - newscript->Name="mob_sliver"; - newscript->GetAI = GetAI_mob_sliver; - m_scripts[nrscripts++] = newscript;*/ -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Priestess_Delrissa +SD%Complete: 45 +SDComment: No Heroic support yet. Needs further testing. Several scripts for pets disabled, not seem to require any special script. +SDCategory: Magister's Terrace +EndScriptData */ + +#include "precompiled.h" +#include "def_magisters_terrace.h" + +#define SAY_AGGRO "Annihilate them!" +#define SOUND_AGGRO 12395 + +struct Speech +{ + const char* text; + uint32 sound; +}; + +static Speech LackeyDeath[]= +{ + {"Oh, the horror.", 12398}, + {"Well, aren't you lucky?", 12400}, + {"Now I'm getting annoyed.", 12401}, + {"Lackies be damned! I'll finish you myself!", 12403}, +}; + +static Speech PlayerDeath[]= +{ + {"I call that a good start.", 12405}, + {"I could have sworn there were more of you.", 12407}, + {"Not really much of a group, anymore, is it?", 12409}, + {"One is such a lonely number", 12410}, + {"It's been a kick, really", 12411}, +}; + +#define SAY_DEATH "Not what I had... planned..." +#define SOUND_DEATH 12397 + +#define SPELL_DISPEL_MAGIC 27609 +#define SPELL_FLASH_HEAL 17843 +#define SPELL_SW_PAIN_NORMAL 14032 +#define SPELL_SW_PAIN_HEROIC 15654 +#define SPELL_SHIELD 44291 +#define SPELL_RENEW_NORMAL 44174 +#define SPELL_RENEW_HEROIC 46192 + +#define ORIENT 4.98 +#define POS_Z -19.9215 + +float LackeyLocations[4][2]= +{ + {123.77, 17.6007}, + {131.731, 15.0827}, + {121.563, 15.6213}, + {129.988, 17.2355}, +}; + +const uint32 AddEntry[8]= +{ + 24557, //Kagani Nightstrike + 24558, //Elris Duskhallow + 24554, //Eramas Brightblaze + 24561, //Yazzaj + 24559, //Warlord Salaris + 24555, //Garaxxas + 24553, //Apoko + 24556, //Zelfan +}; + +struct Add +{ + Add(uint32 _entry, uint64 _guid) + { + entry = _entry; + guid = _guid; + } + + uint32 entry; + uint64 guid; +}; + +struct MANGOS_DLL_DECL boss_priestess_delrissaAI : public ScriptedAI +{ + boss_priestess_delrissaAI(Creature* c) : ScriptedAI(c) + { + pInstance = ((ScriptedInstance*)c->GetInstanceData()); + Adds.clear(); + Reset(); + SummonAdds(); + Heroic = c->GetMap()->IsHeroic(); + } + + ScriptedInstance* pInstance; + + std::vector Adds; + + uint8 LackeysKilled; + uint8 PlayersKilled; + + uint32 HealTimer; + uint32 RenewTimer; + uint32 ShieldTimer; + uint32 SWPainTimer; + uint32 DispelTimer; + + uint32 CombatPulseTimer; // Periodically puts all players in the instance in combat + + bool Heroic; + + void Reset() + { + LackeysKilled = 0; + PlayersKilled = 0; + + HealTimer = 15000; + RenewTimer = 10000; + ShieldTimer = 2000; + SWPainTimer = 5000; + DispelTimer = 7500; + + CombatPulseTimer = 5000; + + CheckAdds(); + + if(pInstance) + { + pInstance->SetData(DATA_DELRISSA_EVENT, NOT_STARTED); + pInstance->SetData(DATA_DELRISSA_DEATH_COUNT, 0); + } + else error_log(ERROR_INST_DATA); + } + + void Aggro(Unit* who) + { + DoYell(SAY_AGGRO, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_AGGRO); + + for(uint8 i = 0; i < Adds.size(); ++i) + if(Unit* pAdd = Unit::GetUnit(*m_creature, Adds[i]->guid)) + pAdd->AddThreat(who, 1.0f); + } + + void SummonAdds() + { + std::vector AddList; + for(uint8 i = 0; i < 8; ++i) + AddList.push_back(AddEntry[i]); + + while(AddList.size() > 4) + AddList.erase(AddList.begin() + rand()%AddList.size()); + + for(uint8 i = 0; i < AddList.size(); ++i) + { + Creature* pAdd = m_creature->SummonCreature(AddList[i], LackeyLocations[i][0], LackeyLocations[i][1], POS_Z, ORIENT, TEMPSUMMON_DEAD_DESPAWN, 0); + if(pAdd) + { + Add* nAdd = new Add(AddList[i], pAdd->GetGUID()); + Adds.push_back(nAdd); + } + } + } + + void CheckAdds() + { + if(Adds.empty()) + return; + + for(uint8 i = 0; i < Adds.size(); ++i) + { + bool resummon = true; + Creature* pAdd = ((Creature*)Unit::GetUnit(*m_creature, Adds[i]->guid)); + if(pAdd && pAdd->isAlive()) + { + pAdd->AI()->EnterEvadeMode(); // Force them out of combat and reset if they are in combat. + resummon = false; + } + if(resummon) + { + pAdd = m_creature->SummonCreature(Adds[i]->entry, LackeyLocations[i][0], LackeyLocations[i][1], POS_Z, ORIENT, TEMPSUMMON_DEAD_DESPAWN, 0); + Add* nAdd = new Add(Adds[i]->entry, pAdd->GetGUID()); + Adds.erase(Adds.begin() + i); + Adds.push_back(nAdd); + } + } + } + + void KilledUnit(Unit* victim) + { + if(victim->GetTypeId() != TYPEID_PLAYER) + return; + + DoYell(PlayerDeath[PlayersKilled].text, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, PlayerDeath[PlayersKilled].sound); + if( PlayersKilled < 4 ) + ++PlayersKilled; + } + + void KilledLackey() + { + DoYell(LackeyDeath[LackeysKilled].text, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, LackeyDeath[LackeysKilled].sound); + if( LackeysKilled < 3 ) + ++LackeysKilled; + } + + void JustDied(Unit* killer) + { + DoYell(SAY_DEATH, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_DEATH); + + CheckLootable(); + + if(!pInstance) + { + error_log(ERROR_INST_DATA); + return; + } + + pInstance->SetData(DATA_DELRISSA_DEATH_COUNT, 1); + pInstance->SetData(DATA_DELRISSA_EVENT, DONE); + if(GameObject* Door = GameObject::GetGameObject(*m_creature, pInstance->GetData64(DATA_DELRISSA_DOOR))) + Door->SetGoState(0); + } + + void CheckLootable() + { + if(LackeysKilled > 4) + m_creature->SetFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE); + else + m_creature->RemoveFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE); + } + + void UpdateAI(const uint32 diff) + { + if(!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + if(HealTimer < diff) + { + uint32 health = m_creature->GetHealth(); + Unit* target = m_creature; + for(uint8 i = 0; i < Adds.size(); ++i) + if(Unit* pAdd = Unit::GetUnit(*m_creature, Adds[i]->guid)) + if(pAdd->isAlive() && pAdd->GetHealth() < health) + target = pAdd; + + DoCast(target, SPELL_FLASH_HEAL); + HealTimer = 15000; + }else HealTimer -= diff; + + if(RenewTimer < diff) + { + Unit* target = m_creature; + if(rand()%2 == 1) + { + std::vector::iterator itr = Adds.begin() + rand()%Adds.size(); + Unit* pAdd = Unit::GetUnit(*m_creature, (*itr)->guid); + if(pAdd && pAdd->isAlive()) + target = pAdd; + } + DoCast(target,Heroic ? SPELL_RENEW_HEROIC : SPELL_RENEW_NORMAL); + RenewTimer = 5000; + }else RenewTimer -= diff; + + if(ShieldTimer < diff) + { + Unit* target = m_creature; + if(rand()%2 == 1) + { + std::vector::iterator itr = Adds.begin() + rand()%Adds.size(); + if(Unit* pAdd = Unit::GetUnit(*m_creature, (*itr)->guid)) + if(!pAdd->HasAura(SPELL_SHIELD, 0) && pAdd->isAlive()) + target = pAdd; + } + DoCast(target, SPELL_SHIELD); + ShieldTimer = 7500; + }else ShieldTimer -= diff; + + if(DispelTimer < diff) + { + Unit* target = NULL; + bool friendly = false; + if(rand()%2 == 1) + target = SelectUnit(SELECT_TARGET_RANDOM, 0); + else + { + friendly = true; + if(rand()%2 == 1) + target = m_creature; + else + { + std::vector::iterator itr = Adds.begin() + rand()%Adds.size(); + Unit* pAdd = Unit::GetUnit(*m_creature, (*itr)->guid); + if(pAdd && pAdd->isAlive()) + target = pAdd; + } + } + if(target) + { + DoCast(target, SPELL_DISPEL_MAGIC); + DispelTimer = 12000; + } + }else DispelTimer -= diff; + + if(SWPainTimer < diff) + { + DoCast(SelectUnit(SELECT_TARGET_RANDOM, 0),Heroic ? SPELL_SW_PAIN_HEROIC : SPELL_SW_PAIN_NORMAL); + SWPainTimer = 10000; + }else SWPainTimer -= diff; + + /* + if(CombatPulseTimer < diff) + { + DoZoneInCombat(); + for(uint8 i = 0; i < Adds.size(); ++i) + { + if(Unit* pAdd = Unit::GetUnit(*m_creature, Add[i]->guid)) + if(pAdd->isAlive()) + DoZoneInCombat(pAdd); + } + + CombatPulseTimer = 10000; + }else CombatPulseTimer -= diff;*/ + + DoMeleeAttackIfReady(); + } +}; + +#define SPELL_HEALING_POTION 15503 + +struct MANGOS_DLL_DECL boss_priestess_guestAI : public ScriptedAI +{ + boss_priestess_guestAI(Creature* c) : ScriptedAI(c) + { + Group.clear(); + pInstance = ((ScriptedInstance*)c->GetInstanceData()); + Reset(); + AcquireGUIDs(); + } + + ScriptedInstance* pInstance; + + std::vector Group; + + uint32 ResetThreatTimer; + + bool UsedPotion; + + void Reset() + { + UsedPotion = false; + + ResetThreatTimer = 5000 + rand()%15000; // These guys like to switch targets often, and are not meant to be tanked. + } + + void Aggro(Unit* who) {} + + void JustDied(Unit* killer) + { + if(!pInstance) + { + error_log(ERROR_INST_DATA); + return; + } + + Creature* Delrissa = ((Creature*)Unit::GetUnit(*m_creature, pInstance->GetData64(DATA_DELRISSA))); + if(Delrissa) + { + ((boss_priestess_delrissaAI*)Delrissa->AI())->KilledLackey(); + if(!Delrissa->isAlive() && pInstance->GetData(DATA_DELRISSA_DEATH_COUNT) > 3) + ((boss_priestess_delrissaAI*)Delrissa->AI())->CheckLootable(); + + pInstance->SetData(DATA_DELRISSA_DEATH_COUNT, 1); + } + } + + void KilledUnit(Unit* victim) + { + if(!pInstance) + { + error_log(ERROR_INST_DATA); + return; + } + + Creature* Delrissa = ((Creature*)Unit::GetUnit(*m_creature, pInstance->GetData64(DATA_DELRISSA))); + if(Delrissa) + Delrissa->AI()->KilledUnit(victim); + } + + void AcquireGUIDs() + { + if(!pInstance) + { + error_log(ERROR_INST_DATA); + return; + } + + Creature* Delrissa = ((Creature*)Unit::GetUnit(*m_creature, pInstance->GetData64(DATA_DELRISSA))); + if(Delrissa) + { + Group = ((boss_priestess_delrissaAI*)Delrissa->AI())->Adds; + Add* dAdd = new Add(Delrissa->GetEntry(), Delrissa->GetGUID()); + Group.push_back(dAdd); + } + } + + void UpdateAI(const uint32 diff) + { + if(((m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < 25) && !UsedPotion) + { + DoCast(m_creature, SPELL_HEALING_POTION, true); + UsedPotion = true; + } + + if(ResetThreatTimer < diff) + { + DoResetThreat(); + ResetThreatTimer = 5000 + rand()%15000; + }else ResetThreatTimer -= diff; + } +}; + +#define SPELL_KIDNEY_SHOT 27615 +#define SPELL_GOUGE 12540 +#define SPELL_KICK 27613 +#define SPELL_VANISH 44290 +#define SPELL_BACKSTAB 15657 +#define SPELL_EVISCERATE 27611 + +struct MANGOS_DLL_DECL boss_kagani_nightstrikeAI : public boss_priestess_guestAI +{ + //Rogue + boss_kagani_nightstrikeAI(Creature *c) : boss_priestess_guestAI(c) {} + + uint32 Gouge_Timer; + uint32 Kick_Timer; + uint32 Vanish_Timer; + uint32 Eviscerate_Timer; + uint32 Wait_Timer; + bool InVanish; + + void Reset() + { + Gouge_Timer = 5500; + Kick_Timer = 7000; + Vanish_Timer = 2000; + Eviscerate_Timer = 6000; + Wait_Timer = 5000; + InVanish = false; + m_creature->SetVisibility(VISIBILITY_ON); + + boss_priestess_guestAI::Reset(); + } + + void UpdateAI(const uint32 diff) + { + if(!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + boss_priestess_guestAI::UpdateAI(diff); + + if(Vanish_Timer < diff) + { + m_creature->SetVisibility(VISIBILITY_OFF); // ...? Hacklike + DoCast(m_creature, SPELL_VANISH); + InVanish = true; + Vanish_Timer = 30000; + Wait_Timer = 10000; + DoResetThreat(); + m_creature->AddThreat(SelectUnit(SELECT_TARGET_RANDOM, 0), 1000.0f); + }else Vanish_Timer -= diff; + + if(InVanish) + if(Wait_Timer < diff) + { + DoCast(m_creature->getVictim(), SPELL_BACKSTAB, true); + DoCast(m_creature->getVictim(), SPELL_KIDNEY_SHOT, true); + m_creature->SetVisibility(VISIBILITY_ON); // ...? Hacklike + InVanish = false; + }else Wait_Timer -= diff; + + if(Gouge_Timer < diff) + { + DoCast(m_creature->getVictim(), SPELL_GOUGE); + m_creature->getThreatManager().modifyThreatPercent(m_creature->getVictim(),-100); + Gouge_Timer = 5500; + }else Gouge_Timer -= diff; + + if(Kick_Timer < diff) + { + DoCast(m_creature->getVictim(), SPELL_KICK); + Kick_Timer = 7000; + }else Kick_Timer -= diff; + + if(Eviscerate_Timer < diff) + { + DoCast(m_creature->getVictim(), SPELL_EVISCERATE); + Eviscerate_Timer = 4000; + }else Eviscerate_Timer -= diff; + + if(!InVanish) + DoMeleeAttackIfReady(); + } +}; + +#define SPELL_IMMOLATE 44267 +#define SPELL_SHADOW_BOLT 12471 +#define SPELL_SEED_OF_CORRUPTION 44141 +#define SPELL_CURSE_OF_AGONY 14875 +#define SPELL_FEAR 38595 +#define SPELL_IMP_FIREBALL 44164 +#define SPELL_SUMMON_IMP 44163 + +//#define CREATURE_IMP 44163 +//#define CREATURE_FIZZLE 24656 + +/*struct MANGOS_DLL_DECL mob_fizzleAI : public ScriptedAI +{ + mob_fizzleAI(Creature *c) : ScriptedAI(c) + { + Reset(); + } + + uint64 EllrisGUID; + uint32 Firebal_Timer; + + void Reset() { EllrisGUID = 0; } + + void KilledUnit(Unit* victim); + void JustDied(Unit* killer); + + void Aggro(Unit* who){} + + void UpdateAI(const uint32 diff) + { + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + //Chain cast + if (!m_creature->IsNonMeleeSpellCasted(false)) + DoCast(m_creature->getVictim(),SPELL_IMP_FIREBALL); + else DoMeleeAttackIfReady(); + } +};*/ + +struct MANGOS_DLL_DECL boss_ellris_duskhallowAI : public boss_priestess_guestAI +{ + //Warlock + boss_ellris_duskhallowAI(Creature *c) : boss_priestess_guestAI(c) + { + } + + bool HasSummonedImp; + + uint32 Immolate_Timer; + uint32 Shadow_Bolt_Timer; + uint32 Seed_of_Corruption_Timer; + uint32 Curse_of_Agony_Timer; + uint32 Fear_Timer; + + void Reset() + { + //HasSummonedImp = false; + + Immolate_Timer = 6000; + Shadow_Bolt_Timer = 3000; + Seed_of_Corruption_Timer = 2000; + Curse_of_Agony_Timer = 1000; + Fear_Timer = 10000; + + boss_priestess_guestAI::Reset(); + } + + void JustDied(Unit* killer) + { + boss_priestess_guestAI::JustDied(killer); + } + + void UpdateAI(const uint32 diff) + { + if(!HasSummonedImp) + { + //Imp will not despawn unless it's killed, even if owner dies, this is correct way. + DoCast(m_creature,SPELL_SUMMON_IMP); + HasSummonedImp = true; + } + + if(!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + boss_priestess_guestAI::UpdateAI(diff); + + if(Immolate_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_IMMOLATE); + Immolate_Timer = 6000; + }else Immolate_Timer -= diff; + + if(Shadow_Bolt_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_SHADOW_BOLT); + Shadow_Bolt_Timer = 5000; + }else Shadow_Bolt_Timer -= diff; + + if(Seed_of_Corruption_Timer < diff) + { + DoCast(SelectUnit(SELECT_TARGET_RANDOM, 0), SPELL_SEED_OF_CORRUPTION); + Seed_of_Corruption_Timer = 10000; + }else Seed_of_Corruption_Timer -= diff; + + if(Curse_of_Agony_Timer < diff) + { + DoCast(SelectUnit(SELECT_TARGET_RANDOM, 0), SPELL_CURSE_OF_AGONY); + Curse_of_Agony_Timer = 13000; + }else Curse_of_Agony_Timer -= diff; + + if(Fear_Timer < diff) + { + DoCast(SelectUnit(SELECT_TARGET_RANDOM, 0), SPELL_FEAR); + Fear_Timer = 10000; + }else Fear_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; + +/*void mob_fizzleAI::JustDied(Unit* killer) +{ + if(Creature* Ellris = ((Creature*)Unit::GetUnit(*m_creature, EllrisGUID))) + ((boss_ellris_duskhallowAI*)Ellris->AI())->ImpGUID = 0; +} + +void mob_fizzleAI::KilledUnit(Unit* victim) +{ + if(Creature* Ellris = ((Creature*)Unit::GetUnit(*m_creature, EllrisGUID))) + ((boss_ellris_duskhallowAI*)Ellris->AI())->KilledUnit(victim); +}*/ + +#define SPELL_KNOCKDOWN 11428 +#define SPELL_SNAP_KICK 46182 + +struct MANGOS_DLL_DECL boss_eramas_brightblazeAI : public boss_priestess_guestAI +{ + //Monk + boss_eramas_brightblazeAI(Creature *c) : boss_priestess_guestAI(c) {} + + uint32 Knockdown_Timer; + uint32 Snap_Kick_Timer; + + void Reset() + { + Knockdown_Timer = 6000; + Snap_Kick_Timer = 4500; + + boss_priestess_guestAI::Reset(); + } + + void UpdateAI(const uint32 diff) + { + if(!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + boss_priestess_guestAI::UpdateAI(diff); + + if(Knockdown_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_KNOCKDOWN); + Knockdown_Timer = 6000; + }else Knockdown_Timer -= diff; + + if(Snap_Kick_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_SNAP_KICK); + Snap_Kick_Timer = 4500; + }else Snap_Kick_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; + +#define SPELL_POLYMORPH 13323 +#define SPELL_ICE_BLOCK 27619 +#define SPELL_BLIZZARD 44178 +#define SPELL_ICE_LANCE 46194 +#define SPELL_CONE_OF_COLD 38384 +#define SPELL_FROSTBOLT 15043 +#define SPELL_BLINK 14514 + +struct MANGOS_DLL_DECL boss_yazzaiAI : public boss_priestess_guestAI +{ + //Mage + boss_yazzaiAI(Creature *c) : boss_priestess_guestAI(c) {} + + bool HasIceBlocked; + + uint32 Polymorph_Timer; + uint32 Ice_Block_Timer; + uint32 Wait_Timer; + uint32 Blizzard_Timer; + uint32 Ice_Lance_Timer; + uint32 Cone_of_Cold_Timer; + uint32 Frostbolt_Timer; + uint32 Blink_Timer; + + void Reset() + { + HasIceBlocked = false; + + Polymorph_Timer = 1000; + Ice_Block_Timer = 20000; + Wait_Timer = 10000; + Blizzard_Timer = 8000; + Ice_Lance_Timer = 12000; + Cone_of_Cold_Timer = 10000; + Frostbolt_Timer = 3000; + Blink_Timer = 8000; + + boss_priestess_guestAI::Reset(); + } + + void UpdateAI(const uint32 diff) + { + if(!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + boss_priestess_guestAI::UpdateAI(diff); + + if(Polymorph_Timer < diff) + { + Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0); + if(target) + { + DoCast(target, SPELL_POLYMORPH); + m_creature->getThreatManager().modifyThreatPercent(target,-100); + Polymorph_Timer = 20000; + } + }else Polymorph_Timer -= diff; + + if(((m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < 35) && !HasIceBlocked) + { + DoCast(m_creature, SPELL_ICE_BLOCK); + HasIceBlocked = true; + } + + if(Blizzard_Timer < diff) + { + DoCast(SelectUnit(SELECT_TARGET_RANDOM, 0), SPELL_BLIZZARD); + Blizzard_Timer = 8000; + }else Blizzard_Timer -= diff; + + if(Ice_Lance_Timer < diff) + { + DoCast(m_creature->getVictim(), SPELL_ICE_LANCE); + Ice_Lance_Timer = 12000; + }else Ice_Lance_Timer -= diff; + + if(Cone_of_Cold_Timer < diff) + { + DoCast(m_creature->getVictim(), SPELL_CONE_OF_COLD); + Cone_of_Cold_Timer = 10000; + }else Cone_of_Cold_Timer -= diff; + + if(Frostbolt_Timer < diff) + { + DoCast(m_creature->getVictim(), SPELL_FROSTBOLT); + Frostbolt_Timer = 8000; + }else Frostbolt_Timer -= diff; + + if(Blink_Timer < diff) + { + bool InMeleeRange = false; + std::list& t_list = m_creature->getThreatManager().getThreatList(); + for(std::list::iterator itr = t_list.begin(); itr!= t_list.end(); ++itr) + { + if(Unit* target = Unit::GetUnit(*m_creature, (*itr)->getUnitGuid())) + //if in melee range + if (target->IsWithinDistInMap(m_creature, 5)) + { + InMeleeRange = true; + break; + } + } + //if anybody is in melee range than escape by blink + if(InMeleeRange) + DoCast(m_creature, SPELL_BLINK); + + Blink_Timer = 8000; + }else Blink_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; + +#define SPELL_INTERCEPT_STUN 27577 +#define SPELL_DISARM 27581 +#define SPELL_PIERCING_HOWL 23600 +#define SPELL_FRIGHTENING_SHOUT 19134 +#define SPELL_HAMSTRING 27584 +#define SPELL_BATTLE_SHOUT 27578 +#define SPELL_MORTAL_STRIKE 44268 + +struct MANGOS_DLL_DECL boss_warlord_salarisAI : public boss_priestess_guestAI +{ + //Warrior + boss_warlord_salarisAI(Creature *c) : boss_priestess_guestAI(c) {} + + uint32 Intercept_Stun_Timer; + uint32 Disarm_Timer; + uint32 Piercing_Howl_Timer; + uint32 Frightening_Shout_Timer; + uint32 Hamstring_Timer; + uint32 Mortal_Strike_Timer; + + void Reset() + { + Intercept_Stun_Timer = 500; + Disarm_Timer = 6000; + Piercing_Howl_Timer = 10000; + Frightening_Shout_Timer = 18000; + Hamstring_Timer = 4500; + Mortal_Strike_Timer = 8000; + DoCast(m_creature, SPELL_BATTLE_SHOUT); + boss_priestess_guestAI::Reset(); + } + + void Aggro(Unit* who) + { + DoCast(m_creature, SPELL_BATTLE_SHOUT); + } + + void UpdateAI(const uint32 diff) + { + if(!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + boss_priestess_guestAI::UpdateAI(diff); + + if(Intercept_Stun_Timer < diff) + { + bool InMeleeRange = false; + std::list& t_list = m_creature->getThreatManager().getThreatList(); + for(std::list::iterator itr = t_list.begin(); itr!= t_list.end(); ++itr) + { + if(Unit* target = Unit::GetUnit(*m_creature, (*itr)->getUnitGuid())) + //if in melee range + if (target->IsWithinDistInMap(m_creature, 5)) + { + InMeleeRange = true; + break; + } + } + //if nobody is in melee range than try to use Intercept + if(!InMeleeRange) + DoCast(SelectUnit(SELECT_TARGET_RANDOM, 0), SPELL_INTERCEPT_STUN); + Intercept_Stun_Timer = 10000; + }else Intercept_Stun_Timer -= diff; + + if(Disarm_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_DISARM); + Disarm_Timer = 6000; + }else Disarm_Timer -= diff; + + if(Hamstring_Timer < diff) + { + DoCast(m_creature->getVictim(), SPELL_HAMSTRING); + Hamstring_Timer = 4500; + }else Hamstring_Timer -= diff; + + if(Mortal_Strike_Timer < diff) + { + DoCast(m_creature->getVictim(), SPELL_MORTAL_STRIKE); + Mortal_Strike_Timer = 4500; + }else Mortal_Strike_Timer -= diff; + + if(Piercing_Howl_Timer < diff) + { + DoCast(m_creature->getVictim(), SPELL_PIERCING_HOWL); + Piercing_Howl_Timer = 10000; + }else Piercing_Howl_Timer -= diff; + + if(Frightening_Shout_Timer < diff) + { + DoCast(m_creature->getVictim(), SPELL_FRIGHTENING_SHOUT); + Frightening_Shout_Timer = 18000; + }else Frightening_Shout_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; + +#define SPELL_AIMED_SHOT 44271 +#define SPELL_SHOOT 15620 +#define SPELL_CONCUSSIVE_SHOT 27634 +#define TRIGGER_CONCUSSIVE_SHOT 19410 +#define SPELL_MULTI_SHOT 31942 +#define SPELL_WING_CLIP 44286 +#define SPELL_FREEZING_TRAP 44136 + +#define CREATURE_SLIVER 24552 + +/*struct MANGOS_DLL_DECL mob_sliverAI : public ScriptedAI +{ + mob_sliverAI(Creature *c) : ScriptedAI(c) + { + Reset(); + } + + uint64 GaraxxasGUID; + + void Reset() { GaraxxasGUID = 0; } + + void KilledUnit(Unit* victim); + void JustDied(Unit* killer); + + void Aggro(Unit* who){} + +};*/ + +struct MANGOS_DLL_DECL boss_garaxxasAI : public boss_priestess_guestAI +{ + //Hunter + boss_garaxxasAI(Creature *c) : boss_priestess_guestAI(c) {} + + //uint64 SliverGUID; + bool HasSummonedSliver; + + uint32 Aimed_Shot_Timer; + uint32 Shoot_Timer; + uint32 Concussive_Shot_Timer; + uint32 Multi_Shot_Timer; + uint32 Wing_Clip_Timer; + uint32 Freezing_Trap_Timer; + + void Reset() + { + //SliverGUID = 0; + //HasSummonedSliver = false; + + Aimed_Shot_Timer = 6000; + Shoot_Timer = 2500; + Concussive_Shot_Timer = 8000; + Multi_Shot_Timer = 10000; + Wing_Clip_Timer = 4000; + Freezing_Trap_Timer = 15000; + + boss_priestess_guestAI::Reset(); + } + + void JustDied(Unit* killer) + { + boss_priestess_guestAI::JustDied(killer); + } + + void UpdateAI(const uint32 diff) + { + if(!HasSummonedSliver) + { + Creature* Sliver = m_creature->SummonCreature(CREATURE_SLIVER, 0, 0, 0, 0, TEMPSUMMON_CORPSE_DESPAWN, 0); + if(Sliver) + { + //((mob_sliverAI*)Sliver->AI())->GaraxxasGUID = m_creature->GetGUID(); + //SliverGUID = Sliver->GetGUID(); + HasSummonedSliver = true; + } + } + + if(!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + boss_priestess_guestAI::UpdateAI(diff); + + if(m_creature->IsWithinDistInMap(m_creature->getVictim(), 5)) + { + if(Wing_Clip_Timer < diff) + { + DoCast(m_creature->getVictim(), SPELL_WING_CLIP); + Wing_Clip_Timer = 4000; + }else Wing_Clip_Timer -= diff; + + if(Freezing_Trap_Timer < diff) + { + DoCast(m_creature->getVictim(), SPELL_FREEZING_TRAP); + m_creature->getThreatManager().modifyThreatPercent(m_creature->getVictim(),-100); + Freezing_Trap_Timer = 30000; + }else Freezing_Trap_Timer -= diff; + + if(!m_creature->getVictim()->hasUnitState(UNIT_STAT_STUNDED | UNIT_STAT_ROOT | UNIT_STAT_CONFUSED | UNIT_STAT_DISTRACTED)) + DoMeleeAttackIfReady(); + }else + { + if(Concussive_Shot_Timer < diff) + { + DoCast(m_creature->getVictim(), SPELL_CONCUSSIVE_SHOT); + Concussive_Shot_Timer = 8000; + }else Concussive_Shot_Timer -= diff; + + if(Multi_Shot_Timer < diff) + { + DoCast(m_creature->getVictim(), SPELL_MULTI_SHOT); + Multi_Shot_Timer = 10000; + }else Multi_Shot_Timer -= diff; + + if(Aimed_Shot_Timer < diff) + { + DoCast(m_creature->getVictim(), SPELL_AIMED_SHOT); + Aimed_Shot_Timer = 6000; + }else Aimed_Shot_Timer -= diff; + + if(Shoot_Timer < diff) + { + DoCast(m_creature->getVictim(), SPELL_SHOOT); + Shoot_Timer = 2500; + }else Shoot_Timer -= diff; + } + } +}; + +/*void mob_sliverAI::JustDied(Unit* killer) +{ + if(Creature* Garaxxas = ((Creature*)Unit::GetUnit(*m_creature, GaraxxasGUID))) + ((boss_garaxxasAI*)Garaxxas->AI())->SliverGUID = 0; +} + +void mob_sliverAI::KilledUnit(Unit* victim) +{ + if(Creature* Garaxxas = ((Creature*)Unit::GetUnit(*m_creature, GaraxxasGUID))) + ((boss_garaxxasAI*)Garaxxas->AI())->KilledUnit(victim); +}*/ + +#define SPELL_WINDFURY_TOTEM 27621 +#define SPELL_WAR_STOMP 46026 +#define SPELL_PURGE 27626 +#define SPELL_LESSER_HEALING_WAVE 44256 +#define SPELL_FROST_SHOCK 21401 +#define SPELL_FIRE_NOVA_TOTEM 44257 +#define SPELL_EARTHBIND_TOTEM 15786 + +struct MANGOS_DLL_DECL boss_apokoAI : public boss_priestess_guestAI +{ + //Shaman + boss_apokoAI(Creature *c) : boss_priestess_guestAI(c) {} + + uint32 Totem_Timer; + uint8 Totem_Amount; + uint32 War_Stomp_Timer; + uint32 Purge_Timer; + uint32 Healing_Wave_Timer; + uint32 Frost_Shock_Timer; + + void Reset() + { + Totem_Timer = 2000; + Totem_Amount = 1; + War_Stomp_Timer = 10000; + Purge_Timer = 8000; + Healing_Wave_Timer = 5000; + Frost_Shock_Timer = 7000; + + boss_priestess_guestAI::Reset(); + } + + void UpdateAI(const uint32 diff) + { + if(!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + boss_priestess_guestAI::UpdateAI(diff); + + if(Totem_Timer < diff) + { + switch(rand()%3) + { + case 0: + DoCast(m_creature, SPELL_WINDFURY_TOTEM); + break; + case 1: + DoCast(m_creature, SPELL_FIRE_NOVA_TOTEM); + break; + case 2: + DoCast(m_creature, SPELL_EARTHBIND_TOTEM); + break; + } + ++Totem_Amount; + Totem_Timer = Totem_Amount*2000; + }else Totem_Timer -= diff; + + if(War_Stomp_Timer < diff) + { + DoCast(m_creature, SPELL_WAR_STOMP); + War_Stomp_Timer = 10000; + }else War_Stomp_Timer -= diff; + + if(Purge_Timer < diff) + { + DoCast(SelectUnit(SELECT_TARGET_RANDOM, 0), SPELL_PURGE); + Purge_Timer = 15000; + }else Purge_Timer -= diff; + + if(Frost_Shock_Timer < diff) + { + DoCast(m_creature->getVictim(), SPELL_FROST_SHOCK); + Frost_Shock_Timer = 7000; + }else Frost_Shock_Timer -= diff; + + if(Healing_Wave_Timer < diff) + { + // std::vector::iterator itr = Group.begin() + rand()%Group.size(); + // uint64 guid = (*itr)->guid; + // if(guid) + // { + // Unit* pAdd = Unit::GetUnit(*m_creature, (*itr)->guid); + // if(pAdd && pAdd->isAlive()) + // { + DoCast(m_creature, SPELL_LESSER_HEALING_WAVE); + Healing_Wave_Timer = 5000; + // } + // } + }else Healing_Wave_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; + +#define SPELL_GOBLIN_DRAGON_GUN 44272 +#define SPELL_ROCKET_LAUNCH 44137 +#define SPELL_RECOMBOBULATE 44274 +#define SPELL_HIGH_EXPLOSIVE_SHEEP 44276 +#define SPELL_FEL_IRON_BOMB 46024 +#define SPELL_SHEEP_EXPLOSION 44279 + +#define CREATURE_EXPLOSIVE_SHEEP 24715 + +struct MANGOS_DLL_DECL boss_zelfanAI : public boss_priestess_guestAI +{ + //Engineer + boss_zelfanAI(Creature *c) : boss_priestess_guestAI(c) {} + + uint32 Goblin_Dragon_Gun_Timer; + uint32 Rocket_Launch_Timer; + uint32 Recombobulate_Timer; + uint32 High_Explosive_Sheep_Timer; + uint32 Fel_Iron_Bomb_Timer; + + void Reset() + { + Goblin_Dragon_Gun_Timer = 20000; + Rocket_Launch_Timer = 7000; + Recombobulate_Timer = 4000; + High_Explosive_Sheep_Timer = 10000; + Fel_Iron_Bomb_Timer = 15000; + + boss_priestess_guestAI::Reset(); + } + + void UpdateAI(const uint32 diff) + { + if(!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + boss_priestess_guestAI::UpdateAI(diff); + + if(Goblin_Dragon_Gun_Timer < diff) + { + DoCast(m_creature->getVictim(), SPELL_GOBLIN_DRAGON_GUN); + Goblin_Dragon_Gun_Timer = 10000; + }else Goblin_Dragon_Gun_Timer -= diff; + + if(Rocket_Launch_Timer < diff) + { + DoCast(m_creature->getVictim(), SPELL_ROCKET_LAUNCH); + Rocket_Launch_Timer = 9000; + }else Rocket_Launch_Timer -= diff; + + if(Fel_Iron_Bomb_Timer < diff) + { + DoCast(m_creature->getVictim(), SPELL_FEL_IRON_BOMB); + Fel_Iron_Bomb_Timer = 15000; + }else Fel_Iron_Bomb_Timer -= diff; + + if(Recombobulate_Timer < diff) + { + for(uint8 i = 0; i < Group.size(); ++i) + if(Unit* pAdd = Unit::GetUnit(*m_creature, Group[i]->guid)) + if(pAdd->IsPolymorphed()) + { + DoCast(pAdd, SPELL_RECOMBOBULATE); + break; + } + }else Recombobulate_Timer -= diff; + + if(High_Explosive_Sheep_Timer < diff) + { + DoCast(m_creature, SPELL_HIGH_EXPLOSIVE_SHEEP); + High_Explosive_Sheep_Timer = 65000; + }else High_Explosive_Sheep_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; + +//struct MANGOS_DLL_DECL mob_high_explosive_sheepAI : public ScriptedAI +//{ +// mob_high_explosive_sheepAI(Creature *c) : ScriptedAI(c) {Reset();} +// +// uint32 Explosion_Timer; +// +// void Reset() +// { +// Explosion_Timer = 60000; +// } +// +// void JustDied(Unit *Killer){} +// +// void Aggro(Unit *who){} +// +// void UpdateAI(const uint32 diff) +// { +// if(Explosion_Timer < diff) +// { +// DoCast(m_creature->getVictim(), SPELL_SHEEP_EXPLOSION); +// }else +// Explosion_Timer -= diff; +// } +//}; + +/*CreatureAI* GetAI_mob_sliver(Creature *_Creature) +{ + return new mob_sliverAI (_Creature); +};*/ + +//CreatureAI* GetAI_mob_high_explosive_sheep(Creature *_Creature) +//{ +// return new mob_high_explosive_sheepAI (_Creature); +//}; + +/*CreatureAI* GetAI_mob_fizzle(Creature *_Creature) +{ + return new mob_fizzleAI (_Creature); +};*/ + +CreatureAI* GetAI_boss_priestess_delrissa(Creature *_Creature) +{ + return new boss_priestess_delrissaAI (_Creature); +} + +CreatureAI* GetAI_boss_kagani_nightstrike(Creature *_Creature) +{ + return new boss_kagani_nightstrikeAI (_Creature); +} + +CreatureAI* GetAI_ellris_duskhallow(Creature *_Creature) +{ + return new boss_ellris_duskhallowAI (_Creature); +} + +CreatureAI* GetAI_eramas_brightblaze(Creature *_Creature) +{ + return new boss_eramas_brightblazeAI (_Creature); +} + +CreatureAI* GetAI_yazzai(Creature *_Creature) +{ + return new boss_yazzaiAI (_Creature); +} + +CreatureAI* GetAI_warlord_salaris(Creature *_Creature) +{ + return new boss_warlord_salarisAI (_Creature); +} + +CreatureAI* GetAI_garaxxas(Creature *_Creature) +{ + return new boss_garaxxasAI (_Creature); +} + +CreatureAI* GetAI_apoko(Creature *_Creature) +{ + return new boss_apokoAI (_Creature); +} + +CreatureAI* GetAI_zelfan(Creature *_Creature) +{ + return new boss_zelfanAI (_Creature); +} + +void AddSC_boss_priestess_delrissa() +{ + Script *newscript; + + newscript = new Script; + newscript->Name="boss_priestess_delrissa"; + newscript->GetAI = GetAI_boss_priestess_delrissa; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="boss_kagani_nightstrike"; + newscript->GetAI = GetAI_boss_kagani_nightstrike; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="boss_ellris_duskhallow"; + newscript->GetAI = GetAI_ellris_duskhallow; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="boss_eramas_brightblaze"; + newscript->GetAI = GetAI_eramas_brightblaze; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="boss_yazzai"; + newscript->GetAI = GetAI_yazzai; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="boss_warlord_salaris"; + newscript->GetAI = GetAI_warlord_salaris; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="boss_garaxxas"; + newscript->GetAI = GetAI_garaxxas; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="boss_apoko"; + newscript->GetAI = GetAI_apoko; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="boss_zelfan"; + newscript->GetAI = GetAI_zelfan; + m_scripts[nrscripts++] = newscript; + + /*newscript = new Script; + newscript->Name="mob_high_explosive_sheep"; + newscript->GetAI = GetAI_mob_high_explosive_sheep; + m_scripts[nrscripts++] = newscript;*/ + + /*newscript = new Script; + newscript->Name="mob_fizzle"; + newscript->GetAI = GetAI_mob_fizzle; + m_scripts[nrscripts++] = newscript;*/ + + /*newscript = new Script; + newscript->Name="mob_sliver"; + newscript->GetAI = GetAI_mob_sliver; + m_scripts[nrscripts++] = newscript;*/ +} diff --git a/src/bindings/scripts/scripts/zone/magisters_terrace/boss_selin_fireheart.cpp b/src/bindings/scripts/scripts/zone/magisters_terrace/boss_selin_fireheart.cpp index 76d4faed15f..6f1da25f220 100644 --- a/src/bindings/scripts/scripts/zone/magisters_terrace/boss_selin_fireheart.cpp +++ b/src/bindings/scripts/scripts/zone/magisters_terrace/boss_selin_fireheart.cpp @@ -1,385 +1,385 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Selin_Fireheart -SD%Complete: 99 -SDComment: Heroic and Normal Support. Needs further testing. -SDCategory: Magister's Terrace -EndScriptData */ - -#include "precompiled.h" -#include "def_magisters_terrace.h" - -#define SAY_AGGRO "You only waste my time!" -#define SOUND_AGGRO 12378 - -#define SAY_ENERGY "My hunger knows no bounds! " -#define SOUND_ENERGY 12381 - -#define SAY_EMPOWERED "Yes! I am a god!" -#define SOUND_EMPOWERED 12382 - -#define SAY_KILL_1 "Enough distractions!" -#define SOUND_KILL_1 12388 - -#define SAY_KILL_2 "I am invincible!" -#define SOUND_KILL_2 12385 - -#define SAY_DEATH "No! More... I must have more!" -#define SOUND_DEATH 12383 - -//Crystal efect spells -#define SPELL_FEL_CRYSTAL_COSMETIC 44374 -#define SPELL_FEL_CRYSTAL_DUMMY 44329 -#define SPELL_FEL_CRYSTAL_VISUAL 44355 -#define SPELL_MANA_RAGE 44320 // This spell triggers 44321, which changes scale and regens mana Requires an entry in spell_script_target - -//Selin's spells -#define SPELL_DRAIN_LIFE 44294 -#define SPELL_FEL_EXPLOSION 44314 - -#define SPELL_DRAIN_MANA 46153 // Heroic only - -#define CRYSTALS_NUMBER 5 -#define DATA_CRYSTALS 6 - -#define CREATURE_FEL_CRYSTAL 24722 - -struct MANGOS_DLL_DECL boss_selin_fireheartAI : public ScriptedAI -{ - boss_selin_fireheartAI(Creature* c) : ScriptedAI(c) - { - pInstance = ((ScriptedInstance*)c->GetInstanceData()); - - Crystals.clear(); - // GUIDs per instance is static, so we only need to load them once. - if(pInstance) - { - uint32 size = pInstance->GetData(DATA_FEL_CRYSTAL_SIZE); - for(uint8 i = 0; i < size; ++i) - { - uint64 guid = pInstance->GetData64(DATA_FEL_CRYSTAL); - outstring_log("Selin: Adding Fel Crystal %u to list", guid); - Crystals.push_back(guid); - } - } - Reset(); - Heroic = c->GetMap()->IsHeroic() ? true : false; - } - - ScriptedInstance* pInstance; - - std::list Crystals; - - uint32 DrainLifeTimer; - uint32 DrainManaTimer; - uint32 FelExplosionTimer; - uint32 DrainCrystalTimer; - uint32 EmpowerTimer; - - bool IsDraining; - bool DrainingCrystal; - bool Heroic; - uint64 CrystalGUID; // This will help us create a pointer to the crystal we are draining. We store GUIDs, never units in case unit is deleted/offline (offline if player of course). - - void Reset() - { - if(pInstance) - { - //for(uint8 i = 0; i < CRYSTALS_NUMBER; ++i) - for(std::list::iterator itr = Crystals.begin(); itr != Crystals.end(); ++itr) - { - //Unit* pUnit = Unit::GetUnit(*m_creature, FelCrystals[i]); - Unit* pUnit = Unit::GetUnit(*m_creature, *itr); - if(pUnit) - { - if(!pUnit->isAlive()) - ((Creature*)pUnit)->Respawn(); // Let MaNGOS handle setting death state, etc. - - // Only need to set unselectable flag. You can't attack unselectable units so non_attackable flag is not necessary here. - pUnit->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - } - } - - GameObject* Door = GameObject::GetGameObject(*m_creature, pInstance->GetData64(DATA_SELIN_ENCOUNTER_DOOR)); - if(Door) - Door->SetGoState(0); // Close the door. Open it only in JustDied. - - // Set Inst data for encounter - pInstance->SetData(DATA_SELIN_EVENT, NOT_STARTED); - }else error_log(ERROR_INST_DATA); - - DrainLifeTimer = 3000 + rand()%4000; - DrainManaTimer = DrainLifeTimer + 5000; - FelExplosionTimer = 2100; - DrainCrystalTimer = 10000 + rand()%5000; - DrainCrystalTimer = 20000 + rand()%5000; - EmpowerTimer = 10000; - - IsDraining = false; - DrainingCrystal = false; - CrystalGUID = 0; - } - - void SelectNearestCrystal() - { - if(Crystals.empty()) - return; - - float ShortestDistance = 0; - CrystalGUID = 0; - Unit* pCrystal = NULL; - Unit* CrystalChosen = NULL; - //for(uint8 i = 0; i < CRYSTALS_NUMBER; ++i) - for(std::list::iterator itr = Crystals.begin(); itr != Crystals.end(); ++itr) - { - pCrystal = NULL; - //pCrystal = Unit::GetUnit(*m_creature, FelCrystals[i]); - pCrystal = Unit::GetUnit(*m_creature, *itr); - if(pCrystal && pCrystal->isAlive()) - { - if(!ShortestDistance || (ShortestDistance > m_creature->GetDistance2d(pCrystal))) - { - ShortestDistance = m_creature->GetDistance2d(pCrystal); - CrystalGUID = pCrystal->GetGUID(); - CrystalChosen = pCrystal; // Store a copy of pCrystal so we don't need to recreate a pointer to closest crystal for the movement and yell. - } - } - } - if(CrystalChosen) - { - DoYell(SAY_ENERGY, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_ENERGY); - CrystalChosen->CastSpell(CrystalChosen, SPELL_FEL_CRYSTAL_COSMETIC, true); - - float x, y, z; // coords that we move to, close to the crystal. - CrystalChosen->GetClosePoint(x, y, z, m_creature->GetObjectSize(), CONTACT_DISTANCE); - - m_creature->RemoveUnitMovementFlag(MOVEMENTFLAG_WALK_MODE); - m_creature->GetMotionMaster()->MovePoint(1, x, y, z); - DrainingCrystal = true; - } - } - - void ShatterRemainingCrystals() - { - if(Crystals.empty()) - return; - - //for(uint8 i = 0; i < CRYSTALS_NUMBER; ++i) - for(std::list::iterator itr = Crystals.begin(); itr != Crystals.end(); ++itr) - { - //Creature* pCrystal = ((Creature*)Unit::GetUnit(*m_creature, FelCrystals[i])); - Creature* pCrystal = ((Creature*)Unit::GetUnit(*m_creature, *itr)); - if(pCrystal && pCrystal->isAlive()) - pCrystal->DealDamage(pCrystal, pCrystal->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); - } - } - - void Aggro(Unit* who) - { - DoYell(SAY_AGGRO, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_AGGRO); - } - - void KilledUnit(Unit* victim) - { - switch(rand()%2) - { - case 0: - DoYell(SAY_KILL_1, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_KILL_1); - break; - case 1: - DoYell(SAY_KILL_2, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_KILL_2); - break; - } - } - - void MovementInform(uint32 type, uint32 id) - { - if(type == POINT_MOTION_TYPE && id == 1) - { - Unit* CrystalChosen = Unit::GetUnit(*m_creature, CrystalGUID); - if(CrystalChosen && CrystalChosen->isAlive()) - { - // Make the crystal attackable - // We also remove NON_ATTACKABLE in case the database has it set. - CrystalChosen->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE + UNIT_FLAG_NOT_SELECTABLE); - CrystalChosen->CastSpell(m_creature, SPELL_MANA_RAGE, true); - IsDraining = true; - } - else - { - // Make an error message in case something weird happened here - error_log("SD2: Selin Fireheart unable to drain crystal as the crystal is either dead or despawned"); - DrainingCrystal = false; - } - } - } - - void JustDied(Unit* killer) - { - DoYell(SAY_DEATH, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_DEATH); - - if(!pInstance) - { - error_log(ERROR_INST_DATA); - return; - } - - pInstance->SetData(DATA_SELIN_EVENT, DONE); // Encounter complete! - GameObject* EncounterDoor = GameObject::GetGameObject((*m_creature), pInstance->GetData64(DATA_SELIN_ENCOUNTER_DOOR)); - if(EncounterDoor) - EncounterDoor->SetGoState(1); // Open the door - - ShatterRemainingCrystals(); - } - - void UpdateAI(const uint32 diff) - { - if(!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - if(!DrainingCrystal) - { - uint32 maxPowerMana = m_creature->GetMaxPower(POWER_MANA); - if( maxPowerMana && ((m_creature->GetPower(POWER_MANA)*100 / maxPowerMana) < 10) ) - { - if( DrainLifeTimer < diff ) - { - DoCast(SelectUnit(SELECT_TARGET_RANDOM, 0), SPELL_DRAIN_LIFE); - DrainLifeTimer = 10000; - }else DrainLifeTimer -= diff; - - // Heroic only - if( Heroic ) - { - if( DrainManaTimer < diff ) - { - DoCast(SelectUnit(SELECT_TARGET_RANDOM, 0), SPELL_DRAIN_MANA); - DrainManaTimer = 10000; - }else DrainManaTimer -= diff; - } - } - - if( FelExplosionTimer < diff ) - { - if(!m_creature->IsNonMeleeSpellCasted(false)) - { - DoCast(m_creature, SPELL_FEL_EXPLOSION); - FelExplosionTimer = 2000; - } - }else FelExplosionTimer -= diff; - - // If below 10% mana, start recharging - maxPowerMana = m_creature->GetMaxPower(POWER_MANA); - if( maxPowerMana && ((m_creature->GetPower(POWER_MANA)*100 / maxPowerMana) < 10) ) - { - if(DrainCrystalTimer < diff) - { - SelectNearestCrystal(); - if(Heroic) DrainCrystalTimer = 10000 + rand()%5000; - else DrainCrystalTimer = 20000 + rand()%5000; - }else DrainCrystalTimer -= diff; - } - - }else - { - if(IsDraining) - if(EmpowerTimer < diff) - { - IsDraining = false; - DrainingCrystal = false; - DoYell(SAY_EMPOWERED, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_EMPOWERED); - Unit* CrystalChosen = Unit::GetUnit(*m_creature, CrystalGUID); - if(CrystalChosen && CrystalChosen->isAlive()) - // Use Deal Damage to kill it, not setDeathState. - CrystalChosen->DealDamage(CrystalChosen, CrystalChosen->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); - - CrystalGUID = 0; - - m_creature->GetMotionMaster()->Clear(); - m_creature->GetMotionMaster()->MoveChase(m_creature->getVictim()); - }else EmpowerTimer -= diff; - } - - DoMeleeAttackIfReady(); // No need to check if we are draining crystal here, as the spell has a stun. - } -}; - -CreatureAI* GetAI_boss_selin_fireheart(Creature *_Creature) -{ - return new boss_selin_fireheartAI (_Creature); -}; - -struct MANGOS_DLL_DECL mob_fel_crystalAI : public ScriptedAI -{ - mob_fel_crystalAI(Creature *c) : ScriptedAI(c) { Reset(); } - - void Reset() {} - void Aggro(Unit* who) {} - void AttackStart(Unit* who) {} - void MoveInLineOfSight(Unit* who) {} - void UpdateAI(const uint32 diff) {} - - void JustDied(Unit* killer) - { - if(ScriptedInstance* pInstance = ((ScriptedInstance*)m_creature->GetInstanceData())) - { - Creature* Selin = ((Creature*)Unit::GetUnit(*m_creature, pInstance->GetData64(DATA_SELIN))); - if(Selin && Selin->isAlive()) - { - if(((boss_selin_fireheartAI*)Selin->AI())->CrystalGUID == m_creature->GetGUID()) - { - // Set this to false if we are the creature that Selin is draining so his AI flows properly - ((boss_selin_fireheartAI*)Selin->AI())->DrainingCrystal = false; - ((boss_selin_fireheartAI*)Selin->AI())->IsDraining = false; - ((boss_selin_fireheartAI*)Selin->AI())->EmpowerTimer = 10000; - if(Selin->getVictim()) - { - Selin->AI()->AttackStart(Selin->getVictim()); - Selin->GetMotionMaster()->MoveChase(Selin->getVictim()); - } - } - } - }else error_log(ERROR_INST_DATA); - } -}; - -CreatureAI* GetAI_mob_fel_crystal(Creature *_Creature) -{ - return new mob_fel_crystalAI (_Creature); -}; - -void AddSC_boss_selin_fireheart() -{ - Script *newscript; - - newscript = new Script; - newscript->Name="boss_selin_fireheart"; - newscript->GetAI = GetAI_boss_selin_fireheart; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="mob_fel_crystal"; - newscript->GetAI = GetAI_mob_fel_crystal; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Selin_Fireheart +SD%Complete: 99 +SDComment: Heroic and Normal Support. Needs further testing. +SDCategory: Magister's Terrace +EndScriptData */ + +#include "precompiled.h" +#include "def_magisters_terrace.h" + +#define SAY_AGGRO "You only waste my time!" +#define SOUND_AGGRO 12378 + +#define SAY_ENERGY "My hunger knows no bounds! " +#define SOUND_ENERGY 12381 + +#define SAY_EMPOWERED "Yes! I am a god!" +#define SOUND_EMPOWERED 12382 + +#define SAY_KILL_1 "Enough distractions!" +#define SOUND_KILL_1 12388 + +#define SAY_KILL_2 "I am invincible!" +#define SOUND_KILL_2 12385 + +#define SAY_DEATH "No! More... I must have more!" +#define SOUND_DEATH 12383 + +//Crystal efect spells +#define SPELL_FEL_CRYSTAL_COSMETIC 44374 +#define SPELL_FEL_CRYSTAL_DUMMY 44329 +#define SPELL_FEL_CRYSTAL_VISUAL 44355 +#define SPELL_MANA_RAGE 44320 // This spell triggers 44321, which changes scale and regens mana Requires an entry in spell_script_target + +//Selin's spells +#define SPELL_DRAIN_LIFE 44294 +#define SPELL_FEL_EXPLOSION 44314 + +#define SPELL_DRAIN_MANA 46153 // Heroic only + +#define CRYSTALS_NUMBER 5 +#define DATA_CRYSTALS 6 + +#define CREATURE_FEL_CRYSTAL 24722 + +struct MANGOS_DLL_DECL boss_selin_fireheartAI : public ScriptedAI +{ + boss_selin_fireheartAI(Creature* c) : ScriptedAI(c) + { + pInstance = ((ScriptedInstance*)c->GetInstanceData()); + + Crystals.clear(); + // GUIDs per instance is static, so we only need to load them once. + if(pInstance) + { + uint32 size = pInstance->GetData(DATA_FEL_CRYSTAL_SIZE); + for(uint8 i = 0; i < size; ++i) + { + uint64 guid = pInstance->GetData64(DATA_FEL_CRYSTAL); + outstring_log("Selin: Adding Fel Crystal %u to list", guid); + Crystals.push_back(guid); + } + } + Reset(); + Heroic = c->GetMap()->IsHeroic() ? true : false; + } + + ScriptedInstance* pInstance; + + std::list Crystals; + + uint32 DrainLifeTimer; + uint32 DrainManaTimer; + uint32 FelExplosionTimer; + uint32 DrainCrystalTimer; + uint32 EmpowerTimer; + + bool IsDraining; + bool DrainingCrystal; + bool Heroic; + uint64 CrystalGUID; // This will help us create a pointer to the crystal we are draining. We store GUIDs, never units in case unit is deleted/offline (offline if player of course). + + void Reset() + { + if(pInstance) + { + //for(uint8 i = 0; i < CRYSTALS_NUMBER; ++i) + for(std::list::iterator itr = Crystals.begin(); itr != Crystals.end(); ++itr) + { + //Unit* pUnit = Unit::GetUnit(*m_creature, FelCrystals[i]); + Unit* pUnit = Unit::GetUnit(*m_creature, *itr); + if(pUnit) + { + if(!pUnit->isAlive()) + ((Creature*)pUnit)->Respawn(); // Let MaNGOS handle setting death state, etc. + + // Only need to set unselectable flag. You can't attack unselectable units so non_attackable flag is not necessary here. + pUnit->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + } + } + + GameObject* Door = GameObject::GetGameObject(*m_creature, pInstance->GetData64(DATA_SELIN_ENCOUNTER_DOOR)); + if(Door) + Door->SetGoState(0); // Close the door. Open it only in JustDied. + + // Set Inst data for encounter + pInstance->SetData(DATA_SELIN_EVENT, NOT_STARTED); + }else error_log(ERROR_INST_DATA); + + DrainLifeTimer = 3000 + rand()%4000; + DrainManaTimer = DrainLifeTimer + 5000; + FelExplosionTimer = 2100; + DrainCrystalTimer = 10000 + rand()%5000; + DrainCrystalTimer = 20000 + rand()%5000; + EmpowerTimer = 10000; + + IsDraining = false; + DrainingCrystal = false; + CrystalGUID = 0; + } + + void SelectNearestCrystal() + { + if(Crystals.empty()) + return; + + float ShortestDistance = 0; + CrystalGUID = 0; + Unit* pCrystal = NULL; + Unit* CrystalChosen = NULL; + //for(uint8 i = 0; i < CRYSTALS_NUMBER; ++i) + for(std::list::iterator itr = Crystals.begin(); itr != Crystals.end(); ++itr) + { + pCrystal = NULL; + //pCrystal = Unit::GetUnit(*m_creature, FelCrystals[i]); + pCrystal = Unit::GetUnit(*m_creature, *itr); + if(pCrystal && pCrystal->isAlive()) + { + if(!ShortestDistance || (ShortestDistance > m_creature->GetDistance2d(pCrystal))) + { + ShortestDistance = m_creature->GetDistance2d(pCrystal); + CrystalGUID = pCrystal->GetGUID(); + CrystalChosen = pCrystal; // Store a copy of pCrystal so we don't need to recreate a pointer to closest crystal for the movement and yell. + } + } + } + if(CrystalChosen) + { + DoYell(SAY_ENERGY, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_ENERGY); + CrystalChosen->CastSpell(CrystalChosen, SPELL_FEL_CRYSTAL_COSMETIC, true); + + float x, y, z; // coords that we move to, close to the crystal. + CrystalChosen->GetClosePoint(x, y, z, m_creature->GetObjectSize(), CONTACT_DISTANCE); + + m_creature->RemoveUnitMovementFlag(MOVEMENTFLAG_WALK_MODE); + m_creature->GetMotionMaster()->MovePoint(1, x, y, z); + DrainingCrystal = true; + } + } + + void ShatterRemainingCrystals() + { + if(Crystals.empty()) + return; + + //for(uint8 i = 0; i < CRYSTALS_NUMBER; ++i) + for(std::list::iterator itr = Crystals.begin(); itr != Crystals.end(); ++itr) + { + //Creature* pCrystal = ((Creature*)Unit::GetUnit(*m_creature, FelCrystals[i])); + Creature* pCrystal = ((Creature*)Unit::GetUnit(*m_creature, *itr)); + if(pCrystal && pCrystal->isAlive()) + pCrystal->DealDamage(pCrystal, pCrystal->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); + } + } + + void Aggro(Unit* who) + { + DoYell(SAY_AGGRO, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_AGGRO); + } + + void KilledUnit(Unit* victim) + { + switch(rand()%2) + { + case 0: + DoYell(SAY_KILL_1, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_KILL_1); + break; + case 1: + DoYell(SAY_KILL_2, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_KILL_2); + break; + } + } + + void MovementInform(uint32 type, uint32 id) + { + if(type == POINT_MOTION_TYPE && id == 1) + { + Unit* CrystalChosen = Unit::GetUnit(*m_creature, CrystalGUID); + if(CrystalChosen && CrystalChosen->isAlive()) + { + // Make the crystal attackable + // We also remove NON_ATTACKABLE in case the database has it set. + CrystalChosen->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE + UNIT_FLAG_NOT_SELECTABLE); + CrystalChosen->CastSpell(m_creature, SPELL_MANA_RAGE, true); + IsDraining = true; + } + else + { + // Make an error message in case something weird happened here + error_log("SD2: Selin Fireheart unable to drain crystal as the crystal is either dead or despawned"); + DrainingCrystal = false; + } + } + } + + void JustDied(Unit* killer) + { + DoYell(SAY_DEATH, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_DEATH); + + if(!pInstance) + { + error_log(ERROR_INST_DATA); + return; + } + + pInstance->SetData(DATA_SELIN_EVENT, DONE); // Encounter complete! + GameObject* EncounterDoor = GameObject::GetGameObject((*m_creature), pInstance->GetData64(DATA_SELIN_ENCOUNTER_DOOR)); + if(EncounterDoor) + EncounterDoor->SetGoState(1); // Open the door + + ShatterRemainingCrystals(); + } + + void UpdateAI(const uint32 diff) + { + if(!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + if(!DrainingCrystal) + { + uint32 maxPowerMana = m_creature->GetMaxPower(POWER_MANA); + if( maxPowerMana && ((m_creature->GetPower(POWER_MANA)*100 / maxPowerMana) < 10) ) + { + if( DrainLifeTimer < diff ) + { + DoCast(SelectUnit(SELECT_TARGET_RANDOM, 0), SPELL_DRAIN_LIFE); + DrainLifeTimer = 10000; + }else DrainLifeTimer -= diff; + + // Heroic only + if( Heroic ) + { + if( DrainManaTimer < diff ) + { + DoCast(SelectUnit(SELECT_TARGET_RANDOM, 0), SPELL_DRAIN_MANA); + DrainManaTimer = 10000; + }else DrainManaTimer -= diff; + } + } + + if( FelExplosionTimer < diff ) + { + if(!m_creature->IsNonMeleeSpellCasted(false)) + { + DoCast(m_creature, SPELL_FEL_EXPLOSION); + FelExplosionTimer = 2000; + } + }else FelExplosionTimer -= diff; + + // If below 10% mana, start recharging + maxPowerMana = m_creature->GetMaxPower(POWER_MANA); + if( maxPowerMana && ((m_creature->GetPower(POWER_MANA)*100 / maxPowerMana) < 10) ) + { + if(DrainCrystalTimer < diff) + { + SelectNearestCrystal(); + if(Heroic) DrainCrystalTimer = 10000 + rand()%5000; + else DrainCrystalTimer = 20000 + rand()%5000; + }else DrainCrystalTimer -= diff; + } + + }else + { + if(IsDraining) + if(EmpowerTimer < diff) + { + IsDraining = false; + DrainingCrystal = false; + DoYell(SAY_EMPOWERED, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_EMPOWERED); + Unit* CrystalChosen = Unit::GetUnit(*m_creature, CrystalGUID); + if(CrystalChosen && CrystalChosen->isAlive()) + // Use Deal Damage to kill it, not setDeathState. + CrystalChosen->DealDamage(CrystalChosen, CrystalChosen->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); + + CrystalGUID = 0; + + m_creature->GetMotionMaster()->Clear(); + m_creature->GetMotionMaster()->MoveChase(m_creature->getVictim()); + }else EmpowerTimer -= diff; + } + + DoMeleeAttackIfReady(); // No need to check if we are draining crystal here, as the spell has a stun. + } +}; + +CreatureAI* GetAI_boss_selin_fireheart(Creature *_Creature) +{ + return new boss_selin_fireheartAI (_Creature); +}; + +struct MANGOS_DLL_DECL mob_fel_crystalAI : public ScriptedAI +{ + mob_fel_crystalAI(Creature *c) : ScriptedAI(c) { Reset(); } + + void Reset() {} + void Aggro(Unit* who) {} + void AttackStart(Unit* who) {} + void MoveInLineOfSight(Unit* who) {} + void UpdateAI(const uint32 diff) {} + + void JustDied(Unit* killer) + { + if(ScriptedInstance* pInstance = ((ScriptedInstance*)m_creature->GetInstanceData())) + { + Creature* Selin = ((Creature*)Unit::GetUnit(*m_creature, pInstance->GetData64(DATA_SELIN))); + if(Selin && Selin->isAlive()) + { + if(((boss_selin_fireheartAI*)Selin->AI())->CrystalGUID == m_creature->GetGUID()) + { + // Set this to false if we are the creature that Selin is draining so his AI flows properly + ((boss_selin_fireheartAI*)Selin->AI())->DrainingCrystal = false; + ((boss_selin_fireheartAI*)Selin->AI())->IsDraining = false; + ((boss_selin_fireheartAI*)Selin->AI())->EmpowerTimer = 10000; + if(Selin->getVictim()) + { + Selin->AI()->AttackStart(Selin->getVictim()); + Selin->GetMotionMaster()->MoveChase(Selin->getVictim()); + } + } + } + }else error_log(ERROR_INST_DATA); + } +}; + +CreatureAI* GetAI_mob_fel_crystal(Creature *_Creature) +{ + return new mob_fel_crystalAI (_Creature); +}; + +void AddSC_boss_selin_fireheart() +{ + Script *newscript; + + newscript = new Script; + newscript->Name="boss_selin_fireheart"; + newscript->GetAI = GetAI_boss_selin_fireheart; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="mob_fel_crystal"; + newscript->GetAI = GetAI_mob_fel_crystal; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/magisters_terrace/boss_vexallus.cpp b/src/bindings/scripts/scripts/zone/magisters_terrace/boss_vexallus.cpp index e815bde5cf2..11bf2668d9d 100644 --- a/src/bindings/scripts/scripts/zone/magisters_terrace/boss_vexallus.cpp +++ b/src/bindings/scripts/scripts/zone/magisters_terrace/boss_vexallus.cpp @@ -1,233 +1,233 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Vexallus -SD%Complete: 90 -SDComment: Heroic and Normal support. Needs further testing. -SDCategory: Magister's Terrace -EndScriptData */ - -#include "precompiled.h" -#include "def_magisters_terrace.h" - -#define SAY_AGGRO "Drain...life..." -#define SOUND_AGGRO 12389 - -#define SAY_ENERGY "Un...con...tainable." -#define SOUND_ENERGY 12392 - -#define SAY_OVERLOAD "Un...leash..." -#define SOUND_OVERLOAD 12390 - -#define SAY_KILL "Con...sume." -#define SOUND_KILL 12393 - -#define SAY_DEATH "What...happen...ed." - -//Pure energy spell info -#define SPELL_ENERGY_BOLT 44342 -#define SPELL_ENERGY_FEEDBACK 44335 - -//Vexallus spell info -#define SPELL_CHAIN_LIGHTNING 44318 -#define SPELL_SUMMON_PURE_ENERGY 44322 //not-working, this script summon this creatures without this spell -#define SPELL_OVERLOAD 44353 -#define SPELL_ARCANE_SHOCK 44319 - -//Creatures -#define CREATURE_PURE_ENERGY 24745 - -struct MANGOS_DLL_DECL boss_vexallusAI : public ScriptedAI -{ - boss_vexallusAI(Creature *c) : ScriptedAI(c) - { - pInstance = ((ScriptedInstance*)c->GetInstanceData()); - Reset(); - Heroic = c->GetMap()->IsHeroic() ? true : false; - } - - ScriptedInstance* pInstance; - - uint32 ChainLightningTimer; - uint32 ArcaneShockTimer; - uint32 OverloadTimer; - uint32 SpawnAddInterval; - uint32 AlreadySpawnedAmount; - bool Enraged; - bool Heroic; - - void Reset() - { - ChainLightningTimer = 10000; - ArcaneShockTimer = 8000; - OverloadTimer = 2200; - SpawnAddInterval = 15; - AlreadySpawnedAmount = 0; - - Enraged = false; - - if(pInstance) - pInstance->SetData(DATA_VEXALLUS_EVENT, NOT_STARTED); - } - - void KilledUnit(Unit *victim) - { - DoYell(SAY_KILL, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(victim, SOUND_KILL); - } - - void JustDied(Unit *victim) - { - DoYell(SAY_DEATH, LANG_UNIVERSAL, NULL); - if (pInstance) - { - pInstance->SetData(DATA_VEXALLUS_EVENT, DONE); - - GameObject* Door = NULL; - Door = GameObject::GetGameObject((*m_creature), pInstance->GetData64(DATA_VEXALLUS_DOOR)); - if(Door) - Door->SetGoState(0); - } - } - - void Aggro(Unit *who) - { - DoYell(SAY_AGGRO, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_AGGRO); - if (pInstance) - pInstance->SetData(DATA_VEXALLUS_EVENT, IN_PROGRESS); - } - - void UpdateAI(const uint32 diff) - { - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - if(m_creature->GetHealth()*100 / m_creature->GetMaxHealth() < 11) - { - Enraged = true; - } - - if(!Enraged) - { - //used for check, when Vexallus cast adds 85%, 70%, 55%, 40%, 25% - if ((m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < (100-(SpawnAddInterval*(AlreadySpawnedAmount+1)))) - { - DoYell(SAY_ENERGY, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_ENERGY); - Creature* PureEnergyCreature = NULL; - PureEnergyCreature = DoSpawnCreature(CREATURE_PURE_ENERGY, 0, 0, 0, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000); - Unit* target = NULL; - target = SelectUnit(SELECT_TARGET_RANDOM, 0); - if (PureEnergyCreature && target) - PureEnergyCreature->AI()->AttackStart(target); - - if(Heroic) // *Heroic mode only - he summons two instead of one. - { - PureEnergyCreature = DoSpawnCreature(CREATURE_PURE_ENERGY, 0, 0, 0, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000); - target = SelectUnit(SELECT_TARGET_RANDOM, 0); - if (PureEnergyCreature && target) - PureEnergyCreature->AI()->AttackStart(target); - } - - ++AlreadySpawnedAmount; - }; - - if(ChainLightningTimer < diff) - { - Unit* target = NULL; - target = SelectUnit(SELECT_TARGET_RANDOM, 0); - DoCast(target, SPELL_CHAIN_LIGHTNING); - ChainLightningTimer = 10000; - }else ChainLightningTimer -= diff; - - if(ArcaneShockTimer < diff) - { - Unit* target = NULL; - target = SelectUnit(SELECT_TARGET_RANDOM, 0); - DoCast(target, SPELL_ARCANE_SHOCK); - ArcaneShockTimer = 8000; - }else ArcaneShockTimer -= diff; - }else - { - if(OverloadTimer < diff) - { - Unit* target = NULL; - target = SelectUnit(SELECT_TARGET_RANDOM, 0); - DoCast(target, SPELL_OVERLOAD); - OverloadTimer = 2200; - }else OverloadTimer -= diff; - } - DoMeleeAttackIfReady(); - } -}; - -CreatureAI* GetAI_boss_vexallus(Creature *_Creature) -{ - return new boss_vexallusAI (_Creature); -}; - -struct MANGOS_DLL_DECL mob_pure_energyAI : public ScriptedAI -{ - mob_pure_energyAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 EnergyBoltTimer; - - void Reset() - { - EnergyBoltTimer = 1700; - } - - void JustDied(Unit* slayer) - { - slayer->CastSpell(slayer, SPELL_ENERGY_FEEDBACK, true, 0, 0, m_creature->GetGUID()); - } - - void Aggro(Unit *who){} - - void UpdateAI(const uint32 diff) - { - if(!m_creature->getVictim() || !m_creature->SelectHostilTarget()) - return; - - if(EnergyBoltTimer < diff) - { - DoCast(m_creature->getVictim(), SPELL_ENERGY_BOLT); - EnergyBoltTimer = 1700; - }else EnergyBoltTimer -= diff; - } -}; - -CreatureAI* GetAI_mob_pure_energy(Creature *_Creature) -{ - return new mob_pure_energyAI (_Creature); -}; - -void AddSC_boss_vexallus() -{ - Script *newscript; - - newscript = new Script; - newscript->Name="boss_vexallus"; - newscript->GetAI = GetAI_boss_vexallus; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="mob_pure_energy"; - newscript->GetAI = GetAI_mob_pure_energy; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Vexallus +SD%Complete: 90 +SDComment: Heroic and Normal support. Needs further testing. +SDCategory: Magister's Terrace +EndScriptData */ + +#include "precompiled.h" +#include "def_magisters_terrace.h" + +#define SAY_AGGRO "Drain...life..." +#define SOUND_AGGRO 12389 + +#define SAY_ENERGY "Un...con...tainable." +#define SOUND_ENERGY 12392 + +#define SAY_OVERLOAD "Un...leash..." +#define SOUND_OVERLOAD 12390 + +#define SAY_KILL "Con...sume." +#define SOUND_KILL 12393 + +#define SAY_DEATH "What...happen...ed." + +//Pure energy spell info +#define SPELL_ENERGY_BOLT 44342 +#define SPELL_ENERGY_FEEDBACK 44335 + +//Vexallus spell info +#define SPELL_CHAIN_LIGHTNING 44318 +#define SPELL_SUMMON_PURE_ENERGY 44322 //not-working, this script summon this creatures without this spell +#define SPELL_OVERLOAD 44353 +#define SPELL_ARCANE_SHOCK 44319 + +//Creatures +#define CREATURE_PURE_ENERGY 24745 + +struct MANGOS_DLL_DECL boss_vexallusAI : public ScriptedAI +{ + boss_vexallusAI(Creature *c) : ScriptedAI(c) + { + pInstance = ((ScriptedInstance*)c->GetInstanceData()); + Reset(); + Heroic = c->GetMap()->IsHeroic() ? true : false; + } + + ScriptedInstance* pInstance; + + uint32 ChainLightningTimer; + uint32 ArcaneShockTimer; + uint32 OverloadTimer; + uint32 SpawnAddInterval; + uint32 AlreadySpawnedAmount; + bool Enraged; + bool Heroic; + + void Reset() + { + ChainLightningTimer = 10000; + ArcaneShockTimer = 8000; + OverloadTimer = 2200; + SpawnAddInterval = 15; + AlreadySpawnedAmount = 0; + + Enraged = false; + + if(pInstance) + pInstance->SetData(DATA_VEXALLUS_EVENT, NOT_STARTED); + } + + void KilledUnit(Unit *victim) + { + DoYell(SAY_KILL, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(victim, SOUND_KILL); + } + + void JustDied(Unit *victim) + { + DoYell(SAY_DEATH, LANG_UNIVERSAL, NULL); + if (pInstance) + { + pInstance->SetData(DATA_VEXALLUS_EVENT, DONE); + + GameObject* Door = NULL; + Door = GameObject::GetGameObject((*m_creature), pInstance->GetData64(DATA_VEXALLUS_DOOR)); + if(Door) + Door->SetGoState(0); + } + } + + void Aggro(Unit *who) + { + DoYell(SAY_AGGRO, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_AGGRO); + if (pInstance) + pInstance->SetData(DATA_VEXALLUS_EVENT, IN_PROGRESS); + } + + void UpdateAI(const uint32 diff) + { + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + if(m_creature->GetHealth()*100 / m_creature->GetMaxHealth() < 11) + { + Enraged = true; + } + + if(!Enraged) + { + //used for check, when Vexallus cast adds 85%, 70%, 55%, 40%, 25% + if ((m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < (100-(SpawnAddInterval*(AlreadySpawnedAmount+1)))) + { + DoYell(SAY_ENERGY, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_ENERGY); + Creature* PureEnergyCreature = NULL; + PureEnergyCreature = DoSpawnCreature(CREATURE_PURE_ENERGY, 0, 0, 0, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000); + Unit* target = NULL; + target = SelectUnit(SELECT_TARGET_RANDOM, 0); + if (PureEnergyCreature && target) + PureEnergyCreature->AI()->AttackStart(target); + + if(Heroic) // *Heroic mode only - he summons two instead of one. + { + PureEnergyCreature = DoSpawnCreature(CREATURE_PURE_ENERGY, 0, 0, 0, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000); + target = SelectUnit(SELECT_TARGET_RANDOM, 0); + if (PureEnergyCreature && target) + PureEnergyCreature->AI()->AttackStart(target); + } + + ++AlreadySpawnedAmount; + }; + + if(ChainLightningTimer < diff) + { + Unit* target = NULL; + target = SelectUnit(SELECT_TARGET_RANDOM, 0); + DoCast(target, SPELL_CHAIN_LIGHTNING); + ChainLightningTimer = 10000; + }else ChainLightningTimer -= diff; + + if(ArcaneShockTimer < diff) + { + Unit* target = NULL; + target = SelectUnit(SELECT_TARGET_RANDOM, 0); + DoCast(target, SPELL_ARCANE_SHOCK); + ArcaneShockTimer = 8000; + }else ArcaneShockTimer -= diff; + }else + { + if(OverloadTimer < diff) + { + Unit* target = NULL; + target = SelectUnit(SELECT_TARGET_RANDOM, 0); + DoCast(target, SPELL_OVERLOAD); + OverloadTimer = 2200; + }else OverloadTimer -= diff; + } + DoMeleeAttackIfReady(); + } +}; + +CreatureAI* GetAI_boss_vexallus(Creature *_Creature) +{ + return new boss_vexallusAI (_Creature); +}; + +struct MANGOS_DLL_DECL mob_pure_energyAI : public ScriptedAI +{ + mob_pure_energyAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 EnergyBoltTimer; + + void Reset() + { + EnergyBoltTimer = 1700; + } + + void JustDied(Unit* slayer) + { + slayer->CastSpell(slayer, SPELL_ENERGY_FEEDBACK, true, 0, 0, m_creature->GetGUID()); + } + + void Aggro(Unit *who){} + + void UpdateAI(const uint32 diff) + { + if(!m_creature->getVictim() || !m_creature->SelectHostilTarget()) + return; + + if(EnergyBoltTimer < diff) + { + DoCast(m_creature->getVictim(), SPELL_ENERGY_BOLT); + EnergyBoltTimer = 1700; + }else EnergyBoltTimer -= diff; + } +}; + +CreatureAI* GetAI_mob_pure_energy(Creature *_Creature) +{ + return new mob_pure_energyAI (_Creature); +}; + +void AddSC_boss_vexallus() +{ + Script *newscript; + + newscript = new Script; + newscript->Name="boss_vexallus"; + newscript->GetAI = GetAI_boss_vexallus; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="mob_pure_energy"; + newscript->GetAI = GetAI_mob_pure_energy; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/magisters_terrace/def_magisters_terrace.h b/src/bindings/scripts/scripts/zone/magisters_terrace/def_magisters_terrace.h index d064a50cc13..ed5aa46366a 100644 --- a/src/bindings/scripts/scripts/zone/magisters_terrace/def_magisters_terrace.h +++ b/src/bindings/scripts/scripts/zone/magisters_terrace/def_magisters_terrace.h @@ -1,29 +1,29 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software licensed under GPL version 2 - * Please see the included DOCS/LICENSE.TXT for more information */ - -#ifndef DEF_MAGISTERS_TERRACE_H -#define DEF_MAGISTERS_TERRACE_H - -#define DATA_SELIN_EVENT 1 -#define DATA_VEXALLUS_EVENT 2 -#define DATA_DELRISSA_EVENT 3 -#define DATA_KAELTHAS_EVENT 4 - -#define DATA_SELIN 5 -#define DATA_FEL_CRYSTAL 6 -#define DATA_FEL_CRYSTAL_SIZE 7 - -#define DATA_VEXALLUS_DOOR 8 -#define DATA_SELIN_DOOR 9 -#define DATA_DELRISSA 10 -#define DATA_DELRISSA_DOOR 11 -#define DATA_SELIN_ENCOUNTER_DOOR 12 - -#define DATA_KAEL_STATUE_LEFT 13 -#define DATA_KAEL_STATUE_RIGHT 14 - -#define DATA_DELRISSA_DEATH_COUNT 15 - -#define ERROR_INST_DATA "SD2 Error: Instance Data not set properly for Magister's Terrace instance (map 585). Encounters will be buggy." -#endif +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software licensed under GPL version 2 + * Please see the included DOCS/LICENSE.TXT for more information */ + +#ifndef DEF_MAGISTERS_TERRACE_H +#define DEF_MAGISTERS_TERRACE_H + +#define DATA_SELIN_EVENT 1 +#define DATA_VEXALLUS_EVENT 2 +#define DATA_DELRISSA_EVENT 3 +#define DATA_KAELTHAS_EVENT 4 + +#define DATA_SELIN 5 +#define DATA_FEL_CRYSTAL 6 +#define DATA_FEL_CRYSTAL_SIZE 7 + +#define DATA_VEXALLUS_DOOR 8 +#define DATA_SELIN_DOOR 9 +#define DATA_DELRISSA 10 +#define DATA_DELRISSA_DOOR 11 +#define DATA_SELIN_ENCOUNTER_DOOR 12 + +#define DATA_KAEL_STATUE_LEFT 13 +#define DATA_KAEL_STATUE_RIGHT 14 + +#define DATA_DELRISSA_DEATH_COUNT 15 + +#define ERROR_INST_DATA "SD2 Error: Instance Data not set properly for Magister's Terrace instance (map 585). Encounters will be buggy." +#endif diff --git a/src/bindings/scripts/scripts/zone/magisters_terrace/instance_magisters_terrace.cpp b/src/bindings/scripts/scripts/zone/magisters_terrace/instance_magisters_terrace.cpp index 39efb41ebbb..b0d3e90f645 100644 --- a/src/bindings/scripts/scripts/zone/magisters_terrace/instance_magisters_terrace.cpp +++ b/src/bindings/scripts/scripts/zone/magisters_terrace/instance_magisters_terrace.cpp @@ -1,195 +1,195 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Instance_Magisters_Terrace -SD%Complete: 100 -SDComment: Designed only for Selin Fireheart -SDCategory: Magister's Terrace -EndScriptData */ - -#include "precompiled.h" -#include "def_magisters_terrace.h" - -#define NUMBER_OF_ENCOUNTERS 4 - -/* -0 - Selin Fireheart -1 - Vexallus -2 - Priestess Delrissa -3 - Kael'thas Sunstrider -*/ - -struct MANGOS_DLL_DECL instance_magisters_terrace : public ScriptedInstance -{ - instance_magisters_terrace(Map* map) : ScriptedInstance(map) - { - Initialize(); - } - - uint32 Encounters[NUMBER_OF_ENCOUNTERS]; - uint32 DelrissaDeathCount; - - std::list FelCrystals; - std::list::iterator CrystalItr; - - uint64 SelinGUID; - uint64 DelrissaGUID; - uint64 VexallusDoorGUID; - uint64 SelinDoorGUID; - uint64 SelinEncounterDoorGUID; - uint64 DelrissaDoorGUID; - uint64 KaelStatue[2]; - - bool InitializedItr; - - void Initialize() - { - for(uint8 i = 0; i < NUMBER_OF_ENCOUNTERS; i++) - Encounters[i] = NOT_STARTED; - - FelCrystals.clear(); - - DelrissaDeathCount = 0; - - SelinGUID = 0; - DelrissaGUID = 0; - VexallusDoorGUID = 0; - SelinDoorGUID = 0; - SelinEncounterDoorGUID = 0; - DelrissaDoorGUID = 0; - KaelStatue[0] = 0; - KaelStatue[1] = 0; - - InitializedItr = false; - } - - bool IsEncounterInProgress() const - { - for(uint8 i = 0; i < NUMBER_OF_ENCOUNTERS; i++) - if(Encounters[i] == IN_PROGRESS) - return true; - return false; - } - - uint32 GetData(uint32 identifier) - { - switch(identifier) - { - case DATA_SELIN_EVENT: return Encounters[0]; - case DATA_VEXALLUS_EVENT: return Encounters[1]; - case DATA_DELRISSA_EVENT: return Encounters[2]; - case DATA_KAELTHAS_EVENT: return Encounters[3]; - case DATA_DELRISSA_DEATH_COUNT: return DelrissaDeathCount; - case DATA_FEL_CRYSTAL_SIZE: return FelCrystals.size(); - } - return 0; - } - - void SetData(uint32 identifier, uint32 data) - { - switch(identifier) - { - case DATA_SELIN_EVENT: Encounters[0] = data; break; - case DATA_VEXALLUS_EVENT: Encounters[1] = data; break; - case DATA_DELRISSA_EVENT: Encounters[2] = data; break; - case DATA_KAELTHAS_EVENT: Encounters[3] = data; break; - - case DATA_DELRISSA_DEATH_COUNT: - if(data) ++DelrissaDeathCount; - else DelrissaDeathCount = 0; - } - } - - void OnCreatureCreate(Creature *creature, uint32 entry) - { - switch(entry) - { - case 24723: - SelinGUID = creature->GetGUID(); - break; - case 24560: - DelrissaGUID = creature->GetGUID(); - break; - case 24722: - FelCrystals.push_back(creature->GetGUID()); - break; - } - } - - uint64 GetData64(uint32 identifier) - { - switch(identifier) - { - case DATA_SELIN: return SelinGUID; - case DATA_DELRISSA: return DelrissaGUID; - case DATA_VEXALLUS_DOOR: return VexallusDoorGUID; - case DATA_SELIN_DOOR: return SelinDoorGUID; - case DATA_SELIN_ENCOUNTER_DOOR: return SelinEncounterDoorGUID; - case DATA_DELRISSA_DOOR: return DelrissaDoorGUID; - case DATA_KAEL_STATUE_LEFT: return KaelStatue[0]; - case DATA_KAEL_STATUE_RIGHT: return KaelStatue[1]; - - case DATA_FEL_CRYSTAL: - { - if(FelCrystals.empty()) - { - error_log("SD2: Magisters Terrace: No Fel Crystals loaded in Inst Data"); - return 0; - } - - if(!InitializedItr) - { - CrystalItr = FelCrystals.begin(); - InitializedItr = true; - } - - uint64 guid = *CrystalItr; - ++CrystalItr; - return guid; - } - } - return 0; - } - - void OnObjectCreate(GameObject* go) - { - switch(go->GetEntry()) - { - case 187896: VexallusDoorGUID = go->GetGUID(); break; - case 187979: SelinDoorGUID = go->GetGUID(); break; - case 188118: SelinEncounterDoorGUID = go->GetGUID(); break; - case 187770: DelrissaDoorGUID = go->GetGUID(); break; - case 188165: KaelStatue[0] = go->GetGUID(); break; - case 188166: KaelStatue[1] = go->GetGUID(); break; - } - } -}; - -InstanceData* GetInstanceData_instance_magisters_terrace(Map* map) -{ - return new instance_magisters_terrace(map); -} - -void AddSC_instance_magisters_terrace() -{ - Script *newscript; - - newscript = new Script; - newscript->Name = "instance_magisters_terrace"; - newscript->GetInstanceData = GetInstanceData_instance_magisters_terrace; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Instance_Magisters_Terrace +SD%Complete: 100 +SDComment: Designed only for Selin Fireheart +SDCategory: Magister's Terrace +EndScriptData */ + +#include "precompiled.h" +#include "def_magisters_terrace.h" + +#define NUMBER_OF_ENCOUNTERS 4 + +/* +0 - Selin Fireheart +1 - Vexallus +2 - Priestess Delrissa +3 - Kael'thas Sunstrider +*/ + +struct MANGOS_DLL_DECL instance_magisters_terrace : public ScriptedInstance +{ + instance_magisters_terrace(Map* map) : ScriptedInstance(map) + { + Initialize(); + } + + uint32 Encounters[NUMBER_OF_ENCOUNTERS]; + uint32 DelrissaDeathCount; + + std::list FelCrystals; + std::list::iterator CrystalItr; + + uint64 SelinGUID; + uint64 DelrissaGUID; + uint64 VexallusDoorGUID; + uint64 SelinDoorGUID; + uint64 SelinEncounterDoorGUID; + uint64 DelrissaDoorGUID; + uint64 KaelStatue[2]; + + bool InitializedItr; + + void Initialize() + { + for(uint8 i = 0; i < NUMBER_OF_ENCOUNTERS; i++) + Encounters[i] = NOT_STARTED; + + FelCrystals.clear(); + + DelrissaDeathCount = 0; + + SelinGUID = 0; + DelrissaGUID = 0; + VexallusDoorGUID = 0; + SelinDoorGUID = 0; + SelinEncounterDoorGUID = 0; + DelrissaDoorGUID = 0; + KaelStatue[0] = 0; + KaelStatue[1] = 0; + + InitializedItr = false; + } + + bool IsEncounterInProgress() const + { + for(uint8 i = 0; i < NUMBER_OF_ENCOUNTERS; i++) + if(Encounters[i] == IN_PROGRESS) + return true; + return false; + } + + uint32 GetData(uint32 identifier) + { + switch(identifier) + { + case DATA_SELIN_EVENT: return Encounters[0]; + case DATA_VEXALLUS_EVENT: return Encounters[1]; + case DATA_DELRISSA_EVENT: return Encounters[2]; + case DATA_KAELTHAS_EVENT: return Encounters[3]; + case DATA_DELRISSA_DEATH_COUNT: return DelrissaDeathCount; + case DATA_FEL_CRYSTAL_SIZE: return FelCrystals.size(); + } + return 0; + } + + void SetData(uint32 identifier, uint32 data) + { + switch(identifier) + { + case DATA_SELIN_EVENT: Encounters[0] = data; break; + case DATA_VEXALLUS_EVENT: Encounters[1] = data; break; + case DATA_DELRISSA_EVENT: Encounters[2] = data; break; + case DATA_KAELTHAS_EVENT: Encounters[3] = data; break; + + case DATA_DELRISSA_DEATH_COUNT: + if(data) ++DelrissaDeathCount; + else DelrissaDeathCount = 0; + } + } + + void OnCreatureCreate(Creature *creature, uint32 entry) + { + switch(entry) + { + case 24723: + SelinGUID = creature->GetGUID(); + break; + case 24560: + DelrissaGUID = creature->GetGUID(); + break; + case 24722: + FelCrystals.push_back(creature->GetGUID()); + break; + } + } + + uint64 GetData64(uint32 identifier) + { + switch(identifier) + { + case DATA_SELIN: return SelinGUID; + case DATA_DELRISSA: return DelrissaGUID; + case DATA_VEXALLUS_DOOR: return VexallusDoorGUID; + case DATA_SELIN_DOOR: return SelinDoorGUID; + case DATA_SELIN_ENCOUNTER_DOOR: return SelinEncounterDoorGUID; + case DATA_DELRISSA_DOOR: return DelrissaDoorGUID; + case DATA_KAEL_STATUE_LEFT: return KaelStatue[0]; + case DATA_KAEL_STATUE_RIGHT: return KaelStatue[1]; + + case DATA_FEL_CRYSTAL: + { + if(FelCrystals.empty()) + { + error_log("SD2: Magisters Terrace: No Fel Crystals loaded in Inst Data"); + return 0; + } + + if(!InitializedItr) + { + CrystalItr = FelCrystals.begin(); + InitializedItr = true; + } + + uint64 guid = *CrystalItr; + ++CrystalItr; + return guid; + } + } + return 0; + } + + void OnObjectCreate(GameObject* go) + { + switch(go->GetEntry()) + { + case 187896: VexallusDoorGUID = go->GetGUID(); break; + case 187979: SelinDoorGUID = go->GetGUID(); break; + case 188118: SelinEncounterDoorGUID = go->GetGUID(); break; + case 187770: DelrissaDoorGUID = go->GetGUID(); break; + case 188165: KaelStatue[0] = go->GetGUID(); break; + case 188166: KaelStatue[1] = go->GetGUID(); break; + } + } +}; + +InstanceData* GetInstanceData_instance_magisters_terrace(Map* map) +{ + return new instance_magisters_terrace(map); +} + +void AddSC_instance_magisters_terrace() +{ + Script *newscript; + + newscript = new Script; + newscript->Name = "instance_magisters_terrace"; + newscript->GetInstanceData = GetInstanceData_instance_magisters_terrace; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/maraudon/boss_celebras_the_cursed.cpp b/src/bindings/scripts/scripts/zone/maraudon/boss_celebras_the_cursed.cpp index 6f3b92f5e5b..a9c15a49e50 100644 --- a/src/bindings/scripts/scripts/zone/maraudon/boss_celebras_the_cursed.cpp +++ b/src/bindings/scripts/scripts/zone/maraudon/boss_celebras_the_cursed.cpp @@ -1,97 +1,97 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Celebras_the_Cursed -SD%Complete: 100 -SDComment: -SDCategory: Maraudon -EndScriptData */ - -#include "precompiled.h" - -#define SPELL_WRATH 21807 -#define SPELL_ENTANGLINGROOTS 12747 -#define SPELL_CORRUPT_FORCES 21968 - -struct MANGOS_DLL_DECL celebras_the_cursedAI : public ScriptedAI -{ - celebras_the_cursedAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 Wrath_Timer; - uint32 EntanglingRoots_Timer; - uint32 CorruptForces_Timer; - - void Reset() - { - Wrath_Timer = 8000; - EntanglingRoots_Timer = 2000; - CorruptForces_Timer = 30000; - } - - void Aggro(Unit *who) { } - - void JustDied(Unit* Killer) - { - m_creature->SummonCreature(13716, m_creature->GetPositionX(), m_creature->GetPositionY(), m_creature->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN, 600000); - } - - void UpdateAI(const uint32 diff) - { - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - //Wrath - if (Wrath_Timer < diff) - { - Unit* target = NULL; - target = SelectUnit(SELECT_TARGET_RANDOM,0); - if( target ) - DoCast(target,SPELL_WRATH); - Wrath_Timer = 8000; - }else Wrath_Timer -= diff; - - //EntanglingRoots - if (EntanglingRoots_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_ENTANGLINGROOTS); - EntanglingRoots_Timer = 20000; - }else EntanglingRoots_Timer -= diff; - - //CorruptForces - if (CorruptForces_Timer < diff) - { - m_creature->InterruptNonMeleeSpells(false); - DoCast(m_creature,SPELL_CORRUPT_FORCES); - CorruptForces_Timer = 20000; - }else CorruptForces_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; -CreatureAI* GetAI_celebras_the_cursed(Creature *_Creature) -{ - return new celebras_the_cursedAI (_Creature); -} - -void AddSC_boss_celebras_the_cursed() -{ - Script *newscript; - newscript = new Script; - newscript->Name="celebras_the_cursed"; - newscript->GetAI = GetAI_celebras_the_cursed; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Celebras_the_Cursed +SD%Complete: 100 +SDComment: +SDCategory: Maraudon +EndScriptData */ + +#include "precompiled.h" + +#define SPELL_WRATH 21807 +#define SPELL_ENTANGLINGROOTS 12747 +#define SPELL_CORRUPT_FORCES 21968 + +struct MANGOS_DLL_DECL celebras_the_cursedAI : public ScriptedAI +{ + celebras_the_cursedAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 Wrath_Timer; + uint32 EntanglingRoots_Timer; + uint32 CorruptForces_Timer; + + void Reset() + { + Wrath_Timer = 8000; + EntanglingRoots_Timer = 2000; + CorruptForces_Timer = 30000; + } + + void Aggro(Unit *who) { } + + void JustDied(Unit* Killer) + { + m_creature->SummonCreature(13716, m_creature->GetPositionX(), m_creature->GetPositionY(), m_creature->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN, 600000); + } + + void UpdateAI(const uint32 diff) + { + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + //Wrath + if (Wrath_Timer < diff) + { + Unit* target = NULL; + target = SelectUnit(SELECT_TARGET_RANDOM,0); + if( target ) + DoCast(target,SPELL_WRATH); + Wrath_Timer = 8000; + }else Wrath_Timer -= diff; + + //EntanglingRoots + if (EntanglingRoots_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_ENTANGLINGROOTS); + EntanglingRoots_Timer = 20000; + }else EntanglingRoots_Timer -= diff; + + //CorruptForces + if (CorruptForces_Timer < diff) + { + m_creature->InterruptNonMeleeSpells(false); + DoCast(m_creature,SPELL_CORRUPT_FORCES); + CorruptForces_Timer = 20000; + }else CorruptForces_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; +CreatureAI* GetAI_celebras_the_cursed(Creature *_Creature) +{ + return new celebras_the_cursedAI (_Creature); +} + +void AddSC_boss_celebras_the_cursed() +{ + Script *newscript; + newscript = new Script; + newscript->Name="celebras_the_cursed"; + newscript->GetAI = GetAI_celebras_the_cursed; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/maraudon/boss_landslide.cpp b/src/bindings/scripts/scripts/zone/maraudon/boss_landslide.cpp index 466f35dbba7..f9df4b26523 100644 --- a/src/bindings/scripts/scripts/zone/maraudon/boss_landslide.cpp +++ b/src/bindings/scripts/scripts/zone/maraudon/boss_landslide.cpp @@ -1,94 +1,94 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Landslide -SD%Complete: 100 -SDComment: -SDCategory: Maraudon -EndScriptData */ - -#include "precompiled.h" - -#define SPELL_KNOCKAWAY 18670 -#define SPELL_TRAMPLE 5568 -#define SPELL_LANDSLIDE 21808 - -struct MANGOS_DLL_DECL boss_landslideAI : public ScriptedAI -{ - boss_landslideAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 KnockAway_Timer; - uint32 Trample_Timer; - uint32 Landslide_Timer; - - void Reset() - { - KnockAway_Timer = 8000; - Trample_Timer = 2000; - Landslide_Timer = 0; - } - - void Aggro(Unit *who) - { - } - - void UpdateAI(const uint32 diff) - { - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - //KnockAway_Timer - if (KnockAway_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_KNOCKAWAY); - KnockAway_Timer = 15000; - }else KnockAway_Timer -= diff; - - //Trample_Timer - if (Trample_Timer < diff) - { - DoCast(m_creature,SPELL_TRAMPLE); - Trample_Timer = 8000; - }else Trample_Timer -= diff; - - //Landslide - if ( m_creature->GetHealth()*100 / m_creature->GetMaxHealth() < 50 ) - { - if (Landslide_Timer < diff) - { - m_creature->InterruptNonMeleeSpells(false); - DoCast(m_creature,SPELL_LANDSLIDE); - Landslide_Timer = 60000; - } else Landslide_Timer -= diff; - } - - DoMeleeAttackIfReady(); - } -}; -CreatureAI* GetAI_boss_landslide(Creature *_Creature) -{ - return new boss_landslideAI (_Creature); -} - -void AddSC_boss_landslide() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_landslide"; - newscript->GetAI = GetAI_boss_landslide; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Landslide +SD%Complete: 100 +SDComment: +SDCategory: Maraudon +EndScriptData */ + +#include "precompiled.h" + +#define SPELL_KNOCKAWAY 18670 +#define SPELL_TRAMPLE 5568 +#define SPELL_LANDSLIDE 21808 + +struct MANGOS_DLL_DECL boss_landslideAI : public ScriptedAI +{ + boss_landslideAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 KnockAway_Timer; + uint32 Trample_Timer; + uint32 Landslide_Timer; + + void Reset() + { + KnockAway_Timer = 8000; + Trample_Timer = 2000; + Landslide_Timer = 0; + } + + void Aggro(Unit *who) + { + } + + void UpdateAI(const uint32 diff) + { + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + //KnockAway_Timer + if (KnockAway_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_KNOCKAWAY); + KnockAway_Timer = 15000; + }else KnockAway_Timer -= diff; + + //Trample_Timer + if (Trample_Timer < diff) + { + DoCast(m_creature,SPELL_TRAMPLE); + Trample_Timer = 8000; + }else Trample_Timer -= diff; + + //Landslide + if ( m_creature->GetHealth()*100 / m_creature->GetMaxHealth() < 50 ) + { + if (Landslide_Timer < diff) + { + m_creature->InterruptNonMeleeSpells(false); + DoCast(m_creature,SPELL_LANDSLIDE); + Landslide_Timer = 60000; + } else Landslide_Timer -= diff; + } + + DoMeleeAttackIfReady(); + } +}; +CreatureAI* GetAI_boss_landslide(Creature *_Creature) +{ + return new boss_landslideAI (_Creature); +} + +void AddSC_boss_landslide() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_landslide"; + newscript->GetAI = GetAI_boss_landslide; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/maraudon/boss_noxxion.cpp b/src/bindings/scripts/scripts/zone/maraudon/boss_noxxion.cpp index b7bd6cc62fb..35a39e04dee 100644 --- a/src/bindings/scripts/scripts/zone/maraudon/boss_noxxion.cpp +++ b/src/bindings/scripts/scripts/zone/maraudon/boss_noxxion.cpp @@ -1,149 +1,149 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Noxxion -SD%Complete: 100 -SDComment: -SDCategory: Maraudon -EndScriptData */ - -#include "precompiled.h" - -#define SPELL_TOXICVOLLEY 21687 -#define SPELL_UPPERCUT 22916 - -struct MANGOS_DLL_DECL boss_noxxionAI : public ScriptedAI -{ - boss_noxxionAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 ToxicVolley_Timer; - uint32 Uppercut_Timer; - uint32 Adds_Timer; - uint32 Invisible_Timer; - bool Invisible; - int Rand; - int RandX; - int RandY; - Creature* Summoned; - - void Reset() - { - ToxicVolley_Timer = 7000; - Uppercut_Timer = 16000; - Adds_Timer = 19000; - Invisible_Timer = 15000; //Too much too low? - Invisible = false; - } - - void Aggro(Unit *who) - { - } - - void SummonAdds(Unit* victim) - { - Rand = rand()%8; - switch (rand()%2) - { - case 0: RandX = 0 - Rand; break; - case 1: RandX = 0 + Rand; break; - } - Rand = 0; - Rand = rand()%8; - switch (rand()%2) - { - case 0: RandY = 0 - Rand; break; - case 1: RandY = 0 + Rand; break; - } - Rand = 0; - Summoned = DoSpawnCreature(13456, RandX, RandY, 0, 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 90000); - if(Summoned) - ((CreatureAI*)Summoned->AI())->AttackStart(victim); - } - - void UpdateAI(const uint32 diff) - { - if (Invisible && Invisible_Timer < diff) - { - //Become visible again - m_creature->setFaction(14); - m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - //Noxxion model - m_creature->SetUInt32Value(UNIT_FIELD_DISPLAYID,11172); - Invisible = false; - //m_creature->m_canMove = true; - } else if (Invisible) - { - Invisible_Timer -= diff; - //Do nothing while invisible - return; - } - - //Return since we have no target - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - //ToxicVolley_Timer - if (ToxicVolley_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_TOXICVOLLEY); - ToxicVolley_Timer = 9000; - }else ToxicVolley_Timer -= diff; - - //Uppercut_Timer - if (Uppercut_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_UPPERCUT); - Uppercut_Timer = 12000; - }else Uppercut_Timer -= diff; - - //Adds_Timer - if (!Invisible && Adds_Timer < diff) - { - //Inturrupt any spell casting - //m_creature->m_canMove = true; - m_creature->InterruptNonMeleeSpells(false); - m_creature->setFaction(35); - m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - // Invisible Model - m_creature->SetUInt32Value(UNIT_FIELD_DISPLAYID,11686); - SummonAdds(m_creature->getVictim()); - SummonAdds(m_creature->getVictim()); - SummonAdds(m_creature->getVictim()); - SummonAdds(m_creature->getVictim()); - SummonAdds(m_creature->getVictim()); - Invisible = true; - Invisible_Timer = 15000; - - Adds_Timer = 40000; - }else Adds_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; -CreatureAI* GetAI_boss_noxxion(Creature *_Creature) -{ - return new boss_noxxionAI (_Creature); -} - -void AddSC_boss_noxxion() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_noxxion"; - newscript->GetAI = GetAI_boss_noxxion; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Noxxion +SD%Complete: 100 +SDComment: +SDCategory: Maraudon +EndScriptData */ + +#include "precompiled.h" + +#define SPELL_TOXICVOLLEY 21687 +#define SPELL_UPPERCUT 22916 + +struct MANGOS_DLL_DECL boss_noxxionAI : public ScriptedAI +{ + boss_noxxionAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 ToxicVolley_Timer; + uint32 Uppercut_Timer; + uint32 Adds_Timer; + uint32 Invisible_Timer; + bool Invisible; + int Rand; + int RandX; + int RandY; + Creature* Summoned; + + void Reset() + { + ToxicVolley_Timer = 7000; + Uppercut_Timer = 16000; + Adds_Timer = 19000; + Invisible_Timer = 15000; //Too much too low? + Invisible = false; + } + + void Aggro(Unit *who) + { + } + + void SummonAdds(Unit* victim) + { + Rand = rand()%8; + switch (rand()%2) + { + case 0: RandX = 0 - Rand; break; + case 1: RandX = 0 + Rand; break; + } + Rand = 0; + Rand = rand()%8; + switch (rand()%2) + { + case 0: RandY = 0 - Rand; break; + case 1: RandY = 0 + Rand; break; + } + Rand = 0; + Summoned = DoSpawnCreature(13456, RandX, RandY, 0, 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 90000); + if(Summoned) + ((CreatureAI*)Summoned->AI())->AttackStart(victim); + } + + void UpdateAI(const uint32 diff) + { + if (Invisible && Invisible_Timer < diff) + { + //Become visible again + m_creature->setFaction(14); + m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + //Noxxion model + m_creature->SetUInt32Value(UNIT_FIELD_DISPLAYID,11172); + Invisible = false; + //m_creature->m_canMove = true; + } else if (Invisible) + { + Invisible_Timer -= diff; + //Do nothing while invisible + return; + } + + //Return since we have no target + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + //ToxicVolley_Timer + if (ToxicVolley_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_TOXICVOLLEY); + ToxicVolley_Timer = 9000; + }else ToxicVolley_Timer -= diff; + + //Uppercut_Timer + if (Uppercut_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_UPPERCUT); + Uppercut_Timer = 12000; + }else Uppercut_Timer -= diff; + + //Adds_Timer + if (!Invisible && Adds_Timer < diff) + { + //Inturrupt any spell casting + //m_creature->m_canMove = true; + m_creature->InterruptNonMeleeSpells(false); + m_creature->setFaction(35); + m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + // Invisible Model + m_creature->SetUInt32Value(UNIT_FIELD_DISPLAYID,11686); + SummonAdds(m_creature->getVictim()); + SummonAdds(m_creature->getVictim()); + SummonAdds(m_creature->getVictim()); + SummonAdds(m_creature->getVictim()); + SummonAdds(m_creature->getVictim()); + Invisible = true; + Invisible_Timer = 15000; + + Adds_Timer = 40000; + }else Adds_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; +CreatureAI* GetAI_boss_noxxion(Creature *_Creature) +{ + return new boss_noxxionAI (_Creature); +} + +void AddSC_boss_noxxion() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_noxxion"; + newscript->GetAI = GetAI_boss_noxxion; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/maraudon/boss_princess_theradras.cpp b/src/bindings/scripts/scripts/zone/maraudon/boss_princess_theradras.cpp index 64215234ee5..8a6c77c8410 100644 --- a/src/bindings/scripts/scripts/zone/maraudon/boss_princess_theradras.cpp +++ b/src/bindings/scripts/scripts/zone/maraudon/boss_princess_theradras.cpp @@ -1,108 +1,108 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Princess_Theradras -SD%Complete: 100 -SDComment: -SDCategory: Maraudon -EndScriptData */ - -#include "precompiled.h" - -#define SPELL_DUSTFIELD 21909 -#define SPELL_BOULDER 21832 -#define SPELL_THRASH 3391 -#define SPELL_REPULSIVEGAZE 21869 - -struct MANGOS_DLL_DECL boss_ptheradrasAI : public ScriptedAI -{ - boss_ptheradrasAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 Dustfield_Timer; - uint32 Boulder_Timer; - uint32 Thrash_Timer; - uint32 RepulsiveGaze_Timer; - - void Reset() - { - Dustfield_Timer = 8000; - Boulder_Timer = 2000; - Thrash_Timer = 5000; - RepulsiveGaze_Timer = 23000; - } - - void Aggro(Unit *who) - { - } - - void JustDied(Unit* Killer) - { - m_creature->SummonCreature(12238,28.067,61.875,-123.405,4.67,TEMPSUMMON_TIMED_DESPAWN,600000); - } - - void UpdateAI(const uint32 diff) - { - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - //Dustfield_Timer - if (Dustfield_Timer < diff) - { - DoCast(m_creature,SPELL_DUSTFIELD); - Dustfield_Timer = 14000; - }else Dustfield_Timer -= diff; - - //Boulder_Timer - if (Boulder_Timer < diff) - { - Unit* target = NULL; - target = SelectUnit(SELECT_TARGET_RANDOM,0); - if( target ) - DoCast(target,SPELL_BOULDER); - Boulder_Timer = 10000; - }else Boulder_Timer -= diff; - - //RepulsiveGaze_Timer - if (RepulsiveGaze_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_REPULSIVEGAZE); - RepulsiveGaze_Timer = 20000; - }else RepulsiveGaze_Timer -= diff; - - //Thrash_Timer - if (Thrash_Timer < diff) - { - DoCast(m_creature,SPELL_THRASH); - Thrash_Timer = 18000; - }else Thrash_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; -CreatureAI* GetAI_boss_ptheradras(Creature *_Creature) -{ - return new boss_ptheradrasAI (_Creature); -} - -void AddSC_boss_ptheradras() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_princess_theradras"; - newscript->GetAI = GetAI_boss_ptheradras; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Princess_Theradras +SD%Complete: 100 +SDComment: +SDCategory: Maraudon +EndScriptData */ + +#include "precompiled.h" + +#define SPELL_DUSTFIELD 21909 +#define SPELL_BOULDER 21832 +#define SPELL_THRASH 3391 +#define SPELL_REPULSIVEGAZE 21869 + +struct MANGOS_DLL_DECL boss_ptheradrasAI : public ScriptedAI +{ + boss_ptheradrasAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 Dustfield_Timer; + uint32 Boulder_Timer; + uint32 Thrash_Timer; + uint32 RepulsiveGaze_Timer; + + void Reset() + { + Dustfield_Timer = 8000; + Boulder_Timer = 2000; + Thrash_Timer = 5000; + RepulsiveGaze_Timer = 23000; + } + + void Aggro(Unit *who) + { + } + + void JustDied(Unit* Killer) + { + m_creature->SummonCreature(12238,28.067,61.875,-123.405,4.67,TEMPSUMMON_TIMED_DESPAWN,600000); + } + + void UpdateAI(const uint32 diff) + { + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + //Dustfield_Timer + if (Dustfield_Timer < diff) + { + DoCast(m_creature,SPELL_DUSTFIELD); + Dustfield_Timer = 14000; + }else Dustfield_Timer -= diff; + + //Boulder_Timer + if (Boulder_Timer < diff) + { + Unit* target = NULL; + target = SelectUnit(SELECT_TARGET_RANDOM,0); + if( target ) + DoCast(target,SPELL_BOULDER); + Boulder_Timer = 10000; + }else Boulder_Timer -= diff; + + //RepulsiveGaze_Timer + if (RepulsiveGaze_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_REPULSIVEGAZE); + RepulsiveGaze_Timer = 20000; + }else RepulsiveGaze_Timer -= diff; + + //Thrash_Timer + if (Thrash_Timer < diff) + { + DoCast(m_creature,SPELL_THRASH); + Thrash_Timer = 18000; + }else Thrash_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; +CreatureAI* GetAI_boss_ptheradras(Creature *_Creature) +{ + return new boss_ptheradrasAI (_Creature); +} + +void AddSC_boss_ptheradras() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_princess_theradras"; + newscript->GetAI = GetAI_boss_ptheradras; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/molten_core/boss_baron_geddon.cpp b/src/bindings/scripts/scripts/zone/molten_core/boss_baron_geddon.cpp index 075ec15da19..f13dc0ece43 100644 --- a/src/bindings/scripts/scripts/zone/molten_core/boss_baron_geddon.cpp +++ b/src/bindings/scripts/scripts/zone/molten_core/boss_baron_geddon.cpp @@ -1,105 +1,105 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Baron_Geddon -SD%Complete: 100 -SDComment: -SDCategory: Molten Core -EndScriptData */ - -#include "precompiled.h" - -#define SPELL_INFERNO 19695 -#define SPELL_IGNITEMANA 19659 -#define SPELL_LIVINGBOMB 20475 -#define SPELL_ARMAGEDDOM 20479 - -struct MANGOS_DLL_DECL boss_baron_geddonAI : public ScriptedAI -{ - boss_baron_geddonAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 Inferno_Timer; - uint32 IgniteMana_Timer; - uint32 LivingBomb_Timer; - - void Reset() - { - Inferno_Timer = 45000; //These times are probably wrong - IgniteMana_Timer = 30000; - LivingBomb_Timer = 35000; - } - - void Aggro(Unit *who) - { - } - - void UpdateAI(const uint32 diff) - { - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - //If we are <2% hp cast Armageddom - if ( m_creature->GetHealth()*100 / m_creature->GetMaxHealth() <= 2 && !m_creature->IsNonMeleeSpellCasted(false)) - { - DoCast(m_creature,SPELL_ARMAGEDDOM); - DoTextEmote("performs one last service for Ragnaros.",NULL); - return; - } - - //Inferno_Timer - if (Inferno_Timer < diff) - { - DoCast(m_creature,SPELL_INFERNO); - Inferno_Timer = 45000; - }else Inferno_Timer -= diff; - - //IgniteMana_Timer - if (IgniteMana_Timer < diff) - { - Unit* target = NULL; - target = SelectUnit(SELECT_TARGET_RANDOM,0); - if (target) DoCast(target,SPELL_IGNITEMANA); - - IgniteMana_Timer = 30000; - }else IgniteMana_Timer -= diff; - - //LivingBomb_Timer - if (LivingBomb_Timer < diff) - { - Unit* target = NULL; - target = SelectUnit(SELECT_TARGET_RANDOM,0); - if (target) DoCast(target,SPELL_LIVINGBOMB); - - LivingBomb_Timer = 35000; - }else LivingBomb_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; -CreatureAI* GetAI_boss_baron_geddon(Creature *_Creature) -{ - return new boss_baron_geddonAI (_Creature); -} - -void AddSC_boss_baron_geddon() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_baron_geddon"; - newscript->GetAI = GetAI_boss_baron_geddon; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Baron_Geddon +SD%Complete: 100 +SDComment: +SDCategory: Molten Core +EndScriptData */ + +#include "precompiled.h" + +#define SPELL_INFERNO 19695 +#define SPELL_IGNITEMANA 19659 +#define SPELL_LIVINGBOMB 20475 +#define SPELL_ARMAGEDDOM 20479 + +struct MANGOS_DLL_DECL boss_baron_geddonAI : public ScriptedAI +{ + boss_baron_geddonAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 Inferno_Timer; + uint32 IgniteMana_Timer; + uint32 LivingBomb_Timer; + + void Reset() + { + Inferno_Timer = 45000; //These times are probably wrong + IgniteMana_Timer = 30000; + LivingBomb_Timer = 35000; + } + + void Aggro(Unit *who) + { + } + + void UpdateAI(const uint32 diff) + { + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + //If we are <2% hp cast Armageddom + if ( m_creature->GetHealth()*100 / m_creature->GetMaxHealth() <= 2 && !m_creature->IsNonMeleeSpellCasted(false)) + { + DoCast(m_creature,SPELL_ARMAGEDDOM); + DoTextEmote("performs one last service for Ragnaros.",NULL); + return; + } + + //Inferno_Timer + if (Inferno_Timer < diff) + { + DoCast(m_creature,SPELL_INFERNO); + Inferno_Timer = 45000; + }else Inferno_Timer -= diff; + + //IgniteMana_Timer + if (IgniteMana_Timer < diff) + { + Unit* target = NULL; + target = SelectUnit(SELECT_TARGET_RANDOM,0); + if (target) DoCast(target,SPELL_IGNITEMANA); + + IgniteMana_Timer = 30000; + }else IgniteMana_Timer -= diff; + + //LivingBomb_Timer + if (LivingBomb_Timer < diff) + { + Unit* target = NULL; + target = SelectUnit(SELECT_TARGET_RANDOM,0); + if (target) DoCast(target,SPELL_LIVINGBOMB); + + LivingBomb_Timer = 35000; + }else LivingBomb_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; +CreatureAI* GetAI_boss_baron_geddon(Creature *_Creature) +{ + return new boss_baron_geddonAI (_Creature); +} + +void AddSC_boss_baron_geddon() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_baron_geddon"; + newscript->GetAI = GetAI_boss_baron_geddon; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/molten_core/boss_garr.cpp b/src/bindings/scripts/scripts/zone/molten_core/boss_garr.cpp index 82696672654..cf02f19303d 100644 --- a/src/bindings/scripts/scripts/zone/molten_core/boss_garr.cpp +++ b/src/bindings/scripts/scripts/zone/molten_core/boss_garr.cpp @@ -1,168 +1,149 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Garr -SD%Complete: 50 -SDComment: Adds NYI -SDCategory: Molten Core -EndScriptData */ - -#include "precompiled.h" - -// Garr spells -#define SPELL_ANTIMAGICPULSE 19492 -#define SPELL_MAGMASHACKLES 19496 -#define SPELL_ENRAGE 19516 //Stacking enrage (stacks to 10 times) - -//Add spells -#define SPELL_ERUPTION 19497 -#define SPELL_IMMOLATE 20294 - -struct MANGOS_DLL_DECL boss_garrAI : public ScriptedAI -{ - boss_garrAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 AntiMagicPulse_Timer; - uint32 MagmaShackles_Timer; - uint32 CheckAdds_Timer; - uint64 Add[8]; - bool Enraged[8]; - - void Reset() - { - AntiMagicPulse_Timer = 25000; //These times are probably wrong - MagmaShackles_Timer = 15000; - CheckAdds_Timer = 2000; - } - - void Aggro(Unit *who) - { - } - - void UpdateAI(const uint32 diff) - { - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - //AntiMagicPulse_Timer - if (AntiMagicPulse_Timer < diff) - { - DoCast(m_creature,SPELL_ANTIMAGICPULSE); - AntiMagicPulse_Timer = 10000 + rand()%5000; - }else AntiMagicPulse_Timer -= diff; - - //MagmaShackles_Timer - if (MagmaShackles_Timer < diff) - { - DoCast(m_creature,SPELL_MAGMASHACKLES); - MagmaShackles_Timer = 8000 + rand()%4000; - }else MagmaShackles_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; - -struct MANGOS_DLL_DECL mob_fireswornAI : public ScriptedAI -{ - mob_fireswornAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 Immolate_Timer; - - void Reset() - { - Immolate_Timer = 4000; //These times are probably wrong - - //m_creature->RemoveAllAuras(); - //m_creature->DeleteThreatList(); - //m_creature->CombatStop(); - //DoGoHome(); - } - - void Aggro(Unit *who) - { - } - - void MoveInLineOfSight(Unit *who) - { - if (!who || m_creature->getVictim()) - return; - - if (who->isTargetableForAttack() && who->isInAccessablePlaceFor(m_creature) && m_creature->IsHostileTo(who)) - { - float attackRadius = m_creature->GetAttackDistance(who); - if (m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->GetDistanceZ(who) <= CREATURE_Z_ATTACK_RANGE && m_creature->IsWithinLOSInMap(who)) - { - if(who->HasStealthAura()) - who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); - - DoStartAttackAndMovement(who); - - } - } - } - - void UpdateAI(const uint32 diff) - { - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - //Immolate_Timer - if (Immolate_Timer < diff) - { - Unit* target = NULL; - target = SelectUnit(SELECT_TARGET_RANDOM,0); - if (target) - DoCast(target,SPELL_IMMOLATE); - - Immolate_Timer = 5000 + rand()%5000; - }else Immolate_Timer -= diff; - - //Cast Erruption and let them die - if (m_creature->GetHealth() <= m_creature->GetMaxHealth() * 0.10) - { - DoCast(m_creature->getVictim(),SPELL_ERUPTION); - m_creature->setDeathState(JUST_DIED); - m_creature->RemoveCorpse(); - } - - DoMeleeAttackIfReady(); - } -}; -CreatureAI* GetAI_boss_garr(Creature *_Creature) -{ - return new boss_garrAI (_Creature); -} - -CreatureAI* GetAI_mob_firesworn(Creature *_Creature) -{ - return new mob_fireswornAI (_Creature); -} - -void AddSC_boss_garr() -{ - Script *newscript; - - newscript = new Script; - newscript->Name="boss_garr"; - newscript->GetAI = GetAI_boss_garr; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="mob_firesworn"; - newscript->GetAI = GetAI_mob_firesworn; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Garr +SD%Complete: 50 +SDComment: Adds NYI +SDCategory: Molten Core +EndScriptData */ + +#include "precompiled.h" + +// Garr spells +#define SPELL_ANTIMAGICPULSE 19492 +#define SPELL_MAGMASHACKLES 19496 +#define SPELL_ENRAGE 19516 //Stacking enrage (stacks to 10 times) + +//Add spells +#define SPELL_ERUPTION 19497 +#define SPELL_IMMOLATE 20294 + +struct MANGOS_DLL_DECL boss_garrAI : public ScriptedAI +{ + boss_garrAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 AntiMagicPulse_Timer; + uint32 MagmaShackles_Timer; + uint32 CheckAdds_Timer; + uint64 Add[8]; + bool Enraged[8]; + + void Reset() + { + AntiMagicPulse_Timer = 25000; //These times are probably wrong + MagmaShackles_Timer = 15000; + CheckAdds_Timer = 2000; + } + + void Aggro(Unit *who) + { + } + + void UpdateAI(const uint32 diff) + { + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + //AntiMagicPulse_Timer + if (AntiMagicPulse_Timer < diff) + { + DoCast(m_creature,SPELL_ANTIMAGICPULSE); + AntiMagicPulse_Timer = 10000 + rand()%5000; + }else AntiMagicPulse_Timer -= diff; + + //MagmaShackles_Timer + if (MagmaShackles_Timer < diff) + { + DoCast(m_creature,SPELL_MAGMASHACKLES); + MagmaShackles_Timer = 8000 + rand()%4000; + }else MagmaShackles_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; + +struct MANGOS_DLL_DECL mob_fireswornAI : public ScriptedAI +{ + mob_fireswornAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 Immolate_Timer; + + void Reset() + { + Immolate_Timer = 4000; //These times are probably wrong + + //m_creature->RemoveAllAuras(); + //m_creature->DeleteThreatList(); + //m_creature->CombatStop(); + //DoGoHome(); + } + + void Aggro(Unit *who) + { + } + + void UpdateAI(const uint32 diff) + { + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + //Immolate_Timer + if (Immolate_Timer < diff) + { + Unit* target = NULL; + target = SelectUnit(SELECT_TARGET_RANDOM,0); + if (target) + DoCast(target,SPELL_IMMOLATE); + + Immolate_Timer = 5000 + rand()%5000; + }else Immolate_Timer -= diff; + + //Cast Erruption and let them die + if (m_creature->GetHealth() <= m_creature->GetMaxHealth() * 0.10) + { + DoCast(m_creature->getVictim(),SPELL_ERUPTION); + m_creature->setDeathState(JUST_DIED); + m_creature->RemoveCorpse(); + } + + DoMeleeAttackIfReady(); + } +}; +CreatureAI* GetAI_boss_garr(Creature *_Creature) +{ + return new boss_garrAI (_Creature); +} + +CreatureAI* GetAI_mob_firesworn(Creature *_Creature) +{ + return new mob_fireswornAI (_Creature); +} + +void AddSC_boss_garr() +{ + Script *newscript; + + newscript = new Script; + newscript->Name="boss_garr"; + newscript->GetAI = GetAI_boss_garr; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="mob_firesworn"; + newscript->GetAI = GetAI_mob_firesworn; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/molten_core/boss_gehennas.cpp b/src/bindings/scripts/scripts/zone/molten_core/boss_gehennas.cpp index 96c02e77ea1..4f1a6afe71d 100644 --- a/src/bindings/scripts/scripts/zone/molten_core/boss_gehennas.cpp +++ b/src/bindings/scripts/scripts/zone/molten_core/boss_gehennas.cpp @@ -1,91 +1,91 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Gehennas -SD%Complete: 90 -SDComment: Adds MC NYI -SDCategory: Molten Core -EndScriptData */ - -#include "precompiled.h" - -#define SPELL_SHADOWBOLT 19728 -#define SPELL_RAINOFFIRE 19717 -#define SPELL_GEHENNASCURSE 19716 - -struct MANGOS_DLL_DECL boss_gehennasAI : public ScriptedAI -{ - boss_gehennasAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 ShadowBolt_Timer; - uint32 RainOfFire_Timer; - uint32 GehennasCurse_Timer; - - void Reset() - { - ShadowBolt_Timer = 6000; - RainOfFire_Timer = 10000; - GehennasCurse_Timer = 12000; - } - - void Aggro(Unit *who) { } - - void UpdateAI(const uint32 diff) - { - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - //ShadowBolt_Timer - if (ShadowBolt_Timer < diff) - { - if( Unit* bTarget = SelectUnit(SELECT_TARGET_RANDOM,1) ) - DoCast(bTarget,SPELL_SHADOWBOLT); - ShadowBolt_Timer = 7000; - }else ShadowBolt_Timer -= diff; - - //RainOfFire_Timer - if (RainOfFire_Timer < diff) - { - if( Unit* target = SelectUnit(SELECT_TARGET_RANDOM,0) ) - DoCast(target,SPELL_RAINOFFIRE); - - RainOfFire_Timer = 4000 + rand()%8000; - }else RainOfFire_Timer -= diff; - - //GehennasCurse_Timer - if (GehennasCurse_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_GEHENNASCURSE); - GehennasCurse_Timer = 22000 + rand()%8000; - }else GehennasCurse_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; -CreatureAI* GetAI_boss_gehennas(Creature *_Creature) -{ - return new boss_gehennasAI (_Creature); -} - -void AddSC_boss_gehennas() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_gehennas"; - newscript->GetAI = GetAI_boss_gehennas; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Gehennas +SD%Complete: 90 +SDComment: Adds MC NYI +SDCategory: Molten Core +EndScriptData */ + +#include "precompiled.h" + +#define SPELL_SHADOWBOLT 19728 +#define SPELL_RAINOFFIRE 19717 +#define SPELL_GEHENNASCURSE 19716 + +struct MANGOS_DLL_DECL boss_gehennasAI : public ScriptedAI +{ + boss_gehennasAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 ShadowBolt_Timer; + uint32 RainOfFire_Timer; + uint32 GehennasCurse_Timer; + + void Reset() + { + ShadowBolt_Timer = 6000; + RainOfFire_Timer = 10000; + GehennasCurse_Timer = 12000; + } + + void Aggro(Unit *who) { } + + void UpdateAI(const uint32 diff) + { + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + //ShadowBolt_Timer + if (ShadowBolt_Timer < diff) + { + if( Unit* bTarget = SelectUnit(SELECT_TARGET_RANDOM,1) ) + DoCast(bTarget,SPELL_SHADOWBOLT); + ShadowBolt_Timer = 7000; + }else ShadowBolt_Timer -= diff; + + //RainOfFire_Timer + if (RainOfFire_Timer < diff) + { + if( Unit* target = SelectUnit(SELECT_TARGET_RANDOM,0) ) + DoCast(target,SPELL_RAINOFFIRE); + + RainOfFire_Timer = 4000 + rand()%8000; + }else RainOfFire_Timer -= diff; + + //GehennasCurse_Timer + if (GehennasCurse_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_GEHENNASCURSE); + GehennasCurse_Timer = 22000 + rand()%8000; + }else GehennasCurse_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; +CreatureAI* GetAI_boss_gehennas(Creature *_Creature) +{ + return new boss_gehennasAI (_Creature); +} + +void AddSC_boss_gehennas() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_gehennas"; + newscript->GetAI = GetAI_boss_gehennas; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/molten_core/boss_golemagg.cpp b/src/bindings/scripts/scripts/zone/molten_core/boss_golemagg.cpp index 08bb85201ca..008b87d21d1 100644 --- a/src/bindings/scripts/scripts/zone/molten_core/boss_golemagg.cpp +++ b/src/bindings/scripts/scripts/zone/molten_core/boss_golemagg.cpp @@ -1,219 +1,201 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Golemagg -SD%Complete: 90 -SDComment: -SDCategory: Molten Core -EndScriptData */ - -#include "precompiled.h" -#include "def_molten_core.h" - -#define SPELL_MAGMASPLASH 13879 -#define SPELL_PYROBLAST 20228 -#define SPELL_EARTHQUAKE 19798 -#define SPELL_ENRAGE 19953 -#define SPELL_BUFF 20553 - -//-- CoreRager Spells -- -#define SPELL_MANGLE 19820 -#define SPELL_AEGIS 20620 //This is self casted whenever we are below 50% - -#define EMOTE_AEGIS "refuses to die while its master is in trouble" - -struct MANGOS_DLL_DECL boss_golemaggAI : public ScriptedAI -{ - boss_golemaggAI(Creature *c) : ScriptedAI(c) - { - pInstance = (c->GetInstanceData()) ? ((ScriptedInstance*)c->GetInstanceData()) : NULL; - Reset(); - } - - uint32 Pyroblast_Timer; - uint32 EarthQuake_Timer; - uint32 Enrage_Timer; - uint32 Buff_Timer; - ScriptedInstance *pInstance; - - void Reset() - { - Pyroblast_Timer = 7000; //These times are probably wrong - EarthQuake_Timer = 3000; - Buff_Timer = 2500; - Enrage_Timer = 0; - - m_creature->CastSpell(m_creature,SPELL_MAGMASPLASH,true); - } - - void Aggro(Unit *who) - { - } - - void JustDied(Unit* Killer) - { - ScriptedInstance *pInstance = (m_creature->GetInstanceData()) ? ((ScriptedInstance*)m_creature->GetInstanceData()) : NULL; - if(pInstance) - pInstance->SetData(DATA_GOLEMAGG_DEATH, 0); - } - void UpdateAI(const uint32 diff) - { - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - //Pyroblast_Timer - if (Pyroblast_Timer < diff) - { - Unit* target = NULL; - target = SelectUnit(SELECT_TARGET_RANDOM,0); - if (target) DoCast(target,SPELL_PYROBLAST); - - Pyroblast_Timer = 7000; - }else Pyroblast_Timer -= diff; - - //Enrage_Timer - if ( m_creature->GetHealth()*100 / m_creature->GetMaxHealth() < 11 ) - { - if (Enrage_Timer < diff) - { - DoCast(m_creature,SPELL_ENRAGE); - Enrage_Timer = 62000; - }else Enrage_Timer -= diff; - } - - //EarthQuake_Timer - if ( m_creature->GetHealth()*100 / m_creature->GetMaxHealth() < 11 ) - { - if (EarthQuake_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_EARTHQUAKE); - EarthQuake_Timer = 3000; - }else EarthQuake_Timer -= diff; - } - - //Casting Buff for Coreragers. Spell is not working right. Players get the buff... - // if(Buff_Timer < diff) - // { - // DoCast(m_creature, SPELL_BUFF); - // Buff_Timer = 2500; - // }else Buff_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; - -struct MANGOS_DLL_DECL mob_core_ragerAI : public ScriptedAI -{ - mob_core_ragerAI(Creature *c) : ScriptedAI(c) - { - pInstance = (c->GetInstanceData()) ? ((ScriptedInstance*)c->GetInstanceData()) : NULL; - Reset(); - } - - uint32 Mangle_Timer; - uint32 Check_Timer; - ScriptedInstance *pInstance; - - void Reset() - { - Mangle_Timer = 7000; //These times are probably wrong - Check_Timer = 1000; - } - - void Aggro(Unit *who) - { - } - - void MoveInLineOfSight(Unit *who) - { - if (!who || m_creature->getVictim()) - return; - - if (who->isTargetableForAttack() && who->isInAccessablePlaceFor(m_creature) && m_creature->IsHostileTo(who)) - { - float attackRadius = m_creature->GetAttackDistance(who); - if (m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->GetDistanceZ(who) <= CREATURE_Z_ATTACK_RANGE && m_creature->IsWithinLOSInMap(who)) - { - if(who->HasStealthAura()) - who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); - - DoStartAttackAndMovement(who); - } - } - } - - void UpdateAI(const uint32 diff) - { - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - //Mangle_Timer - if (Mangle_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_MANGLE); - Mangle_Timer = 10000; - }else Mangle_Timer -= diff; - - //Cast AEGIS - if ( m_creature->GetHealth()*100 / m_creature->GetMaxHealth() < 50 ) - { - DoCast(m_creature,SPELL_AEGIS); - DoTextEmote(EMOTE_AEGIS, NULL); - } - - //Check_Timer - if(Check_Timer < diff) - { - if(pInstance) - { - Unit *pGolemagg = Unit::GetUnit((*m_creature), pInstance->GetData64(DATA_GOLEMAGG)); - if(!pGolemagg || !pGolemagg->isAlive()) - { - m_creature->DealDamage(m_creature, m_creature->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, true); - } - } - - Check_Timer = 1000; - }else Check_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; -CreatureAI* GetAI_boss_golemagg(Creature *_Creature) -{ - return new boss_golemaggAI (_Creature); -} - -CreatureAI* GetAI_mob_core_rager(Creature *_Creature) -{ - return new mob_core_ragerAI (_Creature); -} - -void AddSC_boss_golemagg() -{ - Script *newscript; - - newscript = new Script; - newscript->Name="boss_golemagg"; - newscript->GetAI = GetAI_boss_golemagg; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="mob_core_rager"; - newscript->GetAI = GetAI_mob_core_rager; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Golemagg +SD%Complete: 90 +SDComment: +SDCategory: Molten Core +EndScriptData */ + +#include "precompiled.h" +#include "def_molten_core.h" + +#define SPELL_MAGMASPLASH 13879 +#define SPELL_PYROBLAST 20228 +#define SPELL_EARTHQUAKE 19798 +#define SPELL_ENRAGE 19953 +#define SPELL_BUFF 20553 + +//-- CoreRager Spells -- +#define SPELL_MANGLE 19820 +#define SPELL_AEGIS 20620 //This is self casted whenever we are below 50% + +#define EMOTE_AEGIS "refuses to die while its master is in trouble" + +struct MANGOS_DLL_DECL boss_golemaggAI : public ScriptedAI +{ + boss_golemaggAI(Creature *c) : ScriptedAI(c) + { + pInstance = (c->GetInstanceData()) ? ((ScriptedInstance*)c->GetInstanceData()) : NULL; + Reset(); + } + + uint32 Pyroblast_Timer; + uint32 EarthQuake_Timer; + uint32 Enrage_Timer; + uint32 Buff_Timer; + ScriptedInstance *pInstance; + + void Reset() + { + Pyroblast_Timer = 7000; //These times are probably wrong + EarthQuake_Timer = 3000; + Buff_Timer = 2500; + Enrage_Timer = 0; + + m_creature->CastSpell(m_creature,SPELL_MAGMASPLASH,true); + } + + void Aggro(Unit *who) + { + } + + void JustDied(Unit* Killer) + { + ScriptedInstance *pInstance = (m_creature->GetInstanceData()) ? ((ScriptedInstance*)m_creature->GetInstanceData()) : NULL; + if(pInstance) + pInstance->SetData(DATA_GOLEMAGG_DEATH, 0); + } + void UpdateAI(const uint32 diff) + { + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + //Pyroblast_Timer + if (Pyroblast_Timer < diff) + { + Unit* target = NULL; + target = SelectUnit(SELECT_TARGET_RANDOM,0); + if (target) DoCast(target,SPELL_PYROBLAST); + + Pyroblast_Timer = 7000; + }else Pyroblast_Timer -= diff; + + //Enrage_Timer + if ( m_creature->GetHealth()*100 / m_creature->GetMaxHealth() < 11 ) + { + if (Enrage_Timer < diff) + { + DoCast(m_creature,SPELL_ENRAGE); + Enrage_Timer = 62000; + }else Enrage_Timer -= diff; + } + + //EarthQuake_Timer + if ( m_creature->GetHealth()*100 / m_creature->GetMaxHealth() < 11 ) + { + if (EarthQuake_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_EARTHQUAKE); + EarthQuake_Timer = 3000; + }else EarthQuake_Timer -= diff; + } + + //Casting Buff for Coreragers. Spell is not working right. Players get the buff... + // if(Buff_Timer < diff) + // { + // DoCast(m_creature, SPELL_BUFF); + // Buff_Timer = 2500; + // }else Buff_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; + +struct MANGOS_DLL_DECL mob_core_ragerAI : public ScriptedAI +{ + mob_core_ragerAI(Creature *c) : ScriptedAI(c) + { + pInstance = (c->GetInstanceData()) ? ((ScriptedInstance*)c->GetInstanceData()) : NULL; + Reset(); + } + + uint32 Mangle_Timer; + uint32 Check_Timer; + ScriptedInstance *pInstance; + + void Reset() + { + Mangle_Timer = 7000; //These times are probably wrong + Check_Timer = 1000; + } + + void Aggro(Unit *who) + { + } + + void UpdateAI(const uint32 diff) + { + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + //Mangle_Timer + if (Mangle_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_MANGLE); + Mangle_Timer = 10000; + }else Mangle_Timer -= diff; + + //Cast AEGIS + if ( m_creature->GetHealth()*100 / m_creature->GetMaxHealth() < 50 ) + { + DoCast(m_creature,SPELL_AEGIS); + DoTextEmote(EMOTE_AEGIS, NULL); + } + + //Check_Timer + if(Check_Timer < diff) + { + if(pInstance) + { + Unit *pGolemagg = Unit::GetUnit((*m_creature), pInstance->GetData64(DATA_GOLEMAGG)); + if(!pGolemagg || !pGolemagg->isAlive()) + { + m_creature->DealDamage(m_creature, m_creature->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, true); + } + } + + Check_Timer = 1000; + }else Check_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; +CreatureAI* GetAI_boss_golemagg(Creature *_Creature) +{ + return new boss_golemaggAI (_Creature); +} + +CreatureAI* GetAI_mob_core_rager(Creature *_Creature) +{ + return new mob_core_ragerAI (_Creature); +} + +void AddSC_boss_golemagg() +{ + Script *newscript; + + newscript = new Script; + newscript->Name="boss_golemagg"; + newscript->GetAI = GetAI_boss_golemagg; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="mob_core_rager"; + newscript->GetAI = GetAI_mob_core_rager; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/molten_core/boss_lucifron.cpp b/src/bindings/scripts/scripts/zone/molten_core/boss_lucifron.cpp index c0083fe1a7f..e28f8fa5441 100644 --- a/src/bindings/scripts/scripts/zone/molten_core/boss_lucifron.cpp +++ b/src/bindings/scripts/scripts/zone/molten_core/boss_lucifron.cpp @@ -1,90 +1,90 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Lucifron -SD%Complete: 100 -SDComment: -SDCategory: Molten Core -EndScriptData */ - -#include "precompiled.h" - -#define SPELL_IMPENDINGDOOM 19702 -#define SPELL_LUCIFRONCURSE 19703 -#define SPELL_SHADOWSHOCK 20603 - -struct MANGOS_DLL_DECL boss_lucifronAI : public ScriptedAI -{ - boss_lucifronAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 ImpendingDoom_Timer; - uint32 LucifronCurse_Timer; - uint32 ShadowShock_Timer; - - void Reset() - { - ImpendingDoom_Timer = 10000; //Initial cast after 10 seconds so the debuffs alternate - LucifronCurse_Timer = 20000; //Initial cast after 20 seconds - ShadowShock_Timer = 6000; //6 seconds - } - - void Aggro(Unit *who) - { - } - - void UpdateAI(const uint32 diff) - { - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - //Impending doom timer - if (ImpendingDoom_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_IMPENDINGDOOM); - ImpendingDoom_Timer = 20000; - }else ImpendingDoom_Timer -= diff; - - //Lucifron's curse timer - if (LucifronCurse_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_LUCIFRONCURSE); - LucifronCurse_Timer = 15000; - }else LucifronCurse_Timer -= diff; - - //Shadowshock - if (ShadowShock_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_SHADOWSHOCK); - ShadowShock_Timer = 6000; - }else ShadowShock_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; -CreatureAI* GetAI_boss_lucifron(Creature *_Creature) -{ - return new boss_lucifronAI (_Creature); -} - -void AddSC_boss_lucifron() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_lucifron"; - newscript->GetAI = GetAI_boss_lucifron; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Lucifron +SD%Complete: 100 +SDComment: +SDCategory: Molten Core +EndScriptData */ + +#include "precompiled.h" + +#define SPELL_IMPENDINGDOOM 19702 +#define SPELL_LUCIFRONCURSE 19703 +#define SPELL_SHADOWSHOCK 20603 + +struct MANGOS_DLL_DECL boss_lucifronAI : public ScriptedAI +{ + boss_lucifronAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 ImpendingDoom_Timer; + uint32 LucifronCurse_Timer; + uint32 ShadowShock_Timer; + + void Reset() + { + ImpendingDoom_Timer = 10000; //Initial cast after 10 seconds so the debuffs alternate + LucifronCurse_Timer = 20000; //Initial cast after 20 seconds + ShadowShock_Timer = 6000; //6 seconds + } + + void Aggro(Unit *who) + { + } + + void UpdateAI(const uint32 diff) + { + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + //Impending doom timer + if (ImpendingDoom_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_IMPENDINGDOOM); + ImpendingDoom_Timer = 20000; + }else ImpendingDoom_Timer -= diff; + + //Lucifron's curse timer + if (LucifronCurse_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_LUCIFRONCURSE); + LucifronCurse_Timer = 15000; + }else LucifronCurse_Timer -= diff; + + //Shadowshock + if (ShadowShock_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_SHADOWSHOCK); + ShadowShock_Timer = 6000; + }else ShadowShock_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; +CreatureAI* GetAI_boss_lucifron(Creature *_Creature) +{ + return new boss_lucifronAI (_Creature); +} + +void AddSC_boss_lucifron() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_lucifron"; + newscript->GetAI = GetAI_boss_lucifron; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/molten_core/boss_magmadar.cpp b/src/bindings/scripts/scripts/zone/molten_core/boss_magmadar.cpp index 1d2d9fa1617..e78c6bb1b32 100644 --- a/src/bindings/scripts/scripts/zone/molten_core/boss_magmadar.cpp +++ b/src/bindings/scripts/scripts/zone/molten_core/boss_magmadar.cpp @@ -1,97 +1,97 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Magmadar -SD%Complete: 75 -SDComment: Conflag on ground nyi, fear causes issues without VMAPs -SDCategory: Molten Core -EndScriptData */ - -#include "precompiled.h" - -#define SPELL_FRENZY 19451 -#define SPELL_MAGMASPIT 19449 //This is actually a buff he gives himself -#define SPELL_PANIC 19408 -#define SPELL_LAVABOMB 19411 //This calls a dummy server side effect that isn't implemented yet -#define SPELL_LAVABOMB_ALT 19428 //This is the spell that the lava bomb casts - -struct MANGOS_DLL_DECL boss_magmadarAI : public ScriptedAI -{ - boss_magmadarAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 Frenzy_Timer; - uint32 Panic_Timer; - uint32 Lavabomb_Timer; - - void Reset() - { - Frenzy_Timer = 30000; - Panic_Timer = 20000; - Lavabomb_Timer = 12000; - - m_creature->CastSpell(m_creature,SPELL_MAGMASPIT,true); - } - - void Aggro(Unit *who) - { - } - - void UpdateAI(const uint32 diff) - { - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - //Frenzy_Timer - if (Frenzy_Timer < diff) - { - DoTextEmote("goes into a killing frenzy!",NULL); - DoCast(m_creature,SPELL_FRENZY); - Frenzy_Timer = 15000; - }else Frenzy_Timer -= diff; - - //Panic_Timer - if (Panic_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_PANIC); - Panic_Timer = 35000; - }else Panic_Timer -= diff; - - //Lavabomb_Timer - if (Lavabomb_Timer < diff) - { - if( Unit* target = SelectUnit(SELECT_TARGET_RANDOM,0) ) - DoCast(target,SPELL_LAVABOMB_ALT); - - Lavabomb_Timer = 12000; - }else Lavabomb_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; -CreatureAI* GetAI_boss_magmadar(Creature *_Creature) -{ - return new boss_magmadarAI (_Creature); -} - -void AddSC_boss_magmadar() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_magmadar"; - newscript->GetAI = GetAI_boss_magmadar; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Magmadar +SD%Complete: 75 +SDComment: Conflag on ground nyi, fear causes issues without VMAPs +SDCategory: Molten Core +EndScriptData */ + +#include "precompiled.h" + +#define SPELL_FRENZY 19451 +#define SPELL_MAGMASPIT 19449 //This is actually a buff he gives himself +#define SPELL_PANIC 19408 +#define SPELL_LAVABOMB 19411 //This calls a dummy server side effect that isn't implemented yet +#define SPELL_LAVABOMB_ALT 19428 //This is the spell that the lava bomb casts + +struct MANGOS_DLL_DECL boss_magmadarAI : public ScriptedAI +{ + boss_magmadarAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 Frenzy_Timer; + uint32 Panic_Timer; + uint32 Lavabomb_Timer; + + void Reset() + { + Frenzy_Timer = 30000; + Panic_Timer = 20000; + Lavabomb_Timer = 12000; + + m_creature->CastSpell(m_creature,SPELL_MAGMASPIT,true); + } + + void Aggro(Unit *who) + { + } + + void UpdateAI(const uint32 diff) + { + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + //Frenzy_Timer + if (Frenzy_Timer < diff) + { + DoTextEmote("goes into a killing frenzy!",NULL); + DoCast(m_creature,SPELL_FRENZY); + Frenzy_Timer = 15000; + }else Frenzy_Timer -= diff; + + //Panic_Timer + if (Panic_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_PANIC); + Panic_Timer = 35000; + }else Panic_Timer -= diff; + + //Lavabomb_Timer + if (Lavabomb_Timer < diff) + { + if( Unit* target = SelectUnit(SELECT_TARGET_RANDOM,0) ) + DoCast(target,SPELL_LAVABOMB_ALT); + + Lavabomb_Timer = 12000; + }else Lavabomb_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; +CreatureAI* GetAI_boss_magmadar(Creature *_Creature) +{ + return new boss_magmadarAI (_Creature); +} + +void AddSC_boss_magmadar() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_magmadar"; + newscript->GetAI = GetAI_boss_magmadar; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/molten_core/boss_majordomo_executus.cpp b/src/bindings/scripts/scripts/zone/molten_core/boss_majordomo_executus.cpp index 8c7129eb691..82924040538 100644 --- a/src/bindings/scripts/scripts/zone/molten_core/boss_majordomo_executus.cpp +++ b/src/bindings/scripts/scripts/zone/molten_core/boss_majordomo_executus.cpp @@ -1,133 +1,133 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_MajorDomo_Executus -SD%Complete: 30 -SDComment: Correct spawning and Event NYI -SDCategory: Molten Core -EndScriptData */ - -#include "precompiled.h" - -#define SPELL_MAGICREFLECTION 20619 -#define SPELL_DAMAGEREFLECTION 21075 -#define SPELL_BLASTWAVE 20229 -#define SPELL_AEGIS 20620 //This is self casted whenever we are below 50% - -#define SAY_AGGRO "Reckless mortals, none may challenge the sons of the living flame!" -#define SOUND_AGGRO 8035 - -#define SAY_SPAWN "The runes of warding have been destroyed! Hunt down the infedels my bretheren." -#define SOUND_SPAWN 8039 - -#define SAY_DEFEAT "Impossible! Stay your attack mortals! I submitt! I submitt! Brashly you have come to rest the secrets of the living flame. You will soon regret the recklessness of your quest. I go now to summon the lord whos house this is. Should you seek an audiance with him your paltry lives will surly be forfit. Nevertheless seek out his lair if you dare!" -#define SOUND_DEFEAT 8038 - -#define SAY_KILL "Ashes to Ashes!" -#define SOUND_KILL 8037 - -#define SAY_SPECIAL "Burn mortals! Burn for this transgression!" -#define SOUND_SPECIAL 8036 - -#define SAY_SUMMON "Behold Ragnaros, the Firelord! He who was ancient when this world was young! Bow before him, mortals! Bow before your ending!" -#define SOUND_SUMMON 8040 - -#define SAY_ARRIVAL1 "These mortal infidels, my lord! They have invaded your sanctum, and seek to steal your secrets!" -#define SOUND_ARRIVAL1 8041 - -struct MANGOS_DLL_DECL boss_majordomoAI : public ScriptedAI -{ - boss_majordomoAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 MagicReflection_Timer; - uint32 DamageReflection_Timer; - uint32 Blastwave_Timer; - - void Reset() - { - MagicReflection_Timer = 30000; //Damage reflection first so we alternate - DamageReflection_Timer = 15000; - Blastwave_Timer = 10000; - } - - void KilledUnit(Unit* victim) - { - if (rand()%5) - return; - - DoYell(SAY_KILL,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_KILL); - } - - void Aggro(Unit *who) - { - DoYell(SAY_AGGRO,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_AGGRO); - } - - void UpdateAI(const uint32 diff) - { - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - //Cast Ageis if less than 50% hp - if (m_creature->GetHealth()*100 / m_creature->GetMaxHealth() < 50) - { - DoCast(m_creature,SPELL_AEGIS); - } - - //MagicReflection_Timer - // if (MagicReflection_Timer < diff) - // { - // DoCast(m_creature, SPELL_MAGICREFLECTION); - - //60 seconds until we should cast this agian - // MagicReflection_Timer = 30000; - // }else MagicReflection_Timer -= diff; - - //DamageReflection_Timer - // if (DamageReflection_Timer < diff) - // { - // DoCast(m_creature, SPELL_DAMAGEREFLECTION); - - //60 seconds until we should cast this agian - // DamageReflection_Timer = 30000; - // }else DamageReflection_Timer -= diff; - - //Blastwave_Timer - if (Blastwave_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_BLASTWAVE); - Blastwave_Timer = 10000; - }else Blastwave_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; -CreatureAI* GetAI_boss_majordomo(Creature *_Creature) -{ - return new boss_majordomoAI (_Creature); -} - -void AddSC_boss_majordomo() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_majordomo"; - newscript->GetAI = GetAI_boss_majordomo; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_MajorDomo_Executus +SD%Complete: 30 +SDComment: Correct spawning and Event NYI +SDCategory: Molten Core +EndScriptData */ + +#include "precompiled.h" + +#define SPELL_MAGICREFLECTION 20619 +#define SPELL_DAMAGEREFLECTION 21075 +#define SPELL_BLASTWAVE 20229 +#define SPELL_AEGIS 20620 //This is self casted whenever we are below 50% + +#define SAY_AGGRO "Reckless mortals, none may challenge the sons of the living flame!" +#define SOUND_AGGRO 8035 + +#define SAY_SPAWN "The runes of warding have been destroyed! Hunt down the infedels my bretheren." +#define SOUND_SPAWN 8039 + +#define SAY_DEFEAT "Impossible! Stay your attack mortals! I submitt! I submitt! Brashly you have come to rest the secrets of the living flame. You will soon regret the recklessness of your quest. I go now to summon the lord whos house this is. Should you seek an audiance with him your paltry lives will surly be forfit. Nevertheless seek out his lair if you dare!" +#define SOUND_DEFEAT 8038 + +#define SAY_KILL "Ashes to Ashes!" +#define SOUND_KILL 8037 + +#define SAY_SPECIAL "Burn mortals! Burn for this transgression!" +#define SOUND_SPECIAL 8036 + +#define SAY_SUMMON "Behold Ragnaros, the Firelord! He who was ancient when this world was young! Bow before him, mortals! Bow before your ending!" +#define SOUND_SUMMON 8040 + +#define SAY_ARRIVAL1 "These mortal infidels, my lord! They have invaded your sanctum, and seek to steal your secrets!" +#define SOUND_ARRIVAL1 8041 + +struct MANGOS_DLL_DECL boss_majordomoAI : public ScriptedAI +{ + boss_majordomoAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 MagicReflection_Timer; + uint32 DamageReflection_Timer; + uint32 Blastwave_Timer; + + void Reset() + { + MagicReflection_Timer = 30000; //Damage reflection first so we alternate + DamageReflection_Timer = 15000; + Blastwave_Timer = 10000; + } + + void KilledUnit(Unit* victim) + { + if (rand()%5) + return; + + DoYell(SAY_KILL,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_KILL); + } + + void Aggro(Unit *who) + { + DoYell(SAY_AGGRO,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_AGGRO); + } + + void UpdateAI(const uint32 diff) + { + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + //Cast Ageis if less than 50% hp + if (m_creature->GetHealth()*100 / m_creature->GetMaxHealth() < 50) + { + DoCast(m_creature,SPELL_AEGIS); + } + + //MagicReflection_Timer + // if (MagicReflection_Timer < diff) + // { + // DoCast(m_creature, SPELL_MAGICREFLECTION); + + //60 seconds until we should cast this agian + // MagicReflection_Timer = 30000; + // }else MagicReflection_Timer -= diff; + + //DamageReflection_Timer + // if (DamageReflection_Timer < diff) + // { + // DoCast(m_creature, SPELL_DAMAGEREFLECTION); + + //60 seconds until we should cast this agian + // DamageReflection_Timer = 30000; + // }else DamageReflection_Timer -= diff; + + //Blastwave_Timer + if (Blastwave_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_BLASTWAVE); + Blastwave_Timer = 10000; + }else Blastwave_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; +CreatureAI* GetAI_boss_majordomo(Creature *_Creature) +{ + return new boss_majordomoAI (_Creature); +} + +void AddSC_boss_majordomo() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_majordomo"; + newscript->GetAI = GetAI_boss_majordomo; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/molten_core/boss_ragnaros.cpp b/src/bindings/scripts/scripts/zone/molten_core/boss_ragnaros.cpp index 3a043987cca..03918c238a2 100644 --- a/src/bindings/scripts/scripts/zone/molten_core/boss_ragnaros.cpp +++ b/src/bindings/scripts/scripts/zone/molten_core/boss_ragnaros.cpp @@ -1,317 +1,317 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Ragnaros -SD%Complete: 75 -SDComment: Intro Dialog and event NYI -SDCategory: Molten Core -EndScriptData */ - -#include "precompiled.h" - -#define SPELL_HANDOFRAGNAROS 19780 -#define SPELL_WRATHOFRAGNAROS 20566 -#define SPELL_LAVABURST 21158 - -#define SPELL_MAGMABURST 20565 //Ranged attack - -#define SPELL_SONSOFFLAME_DUMMY 21108 //Server side effect -#define SPELL_RAGSUBMERGE 21107 //Stealth aura -#define SPELL_RAGEMERGE 20568 -#define SPELL_MELTWEAPON 21388 -#define SPELL_ELEMENTALFIRE 20564 -#define SPELL_ERRUPTION 17731 - -#define SAY_ARRIVAL_1 "TOO SOON! YOU HAVE AWAKENED ME TOO SOON, EXECUTUS! WHAT IS THE MEANING OF THIS INTRUSION?" -#define SAY_ARRIVAL_3 "FOOL! YOU ALLOWED THESE INSECTS TO RUN RAMPANT THROUGH THE HALLOWED CORE, AND NOW YOU LEAD THEM TO MY VERY LAIR? YOU HAVE FAILED ME, EXECUTUS! JUSTICE SHALL BE MET, INDEED!" -#define SAY_ARRIVAL_5 "NOW FOR YOU, INSECTS. BOLDLY YOU SAUGHT THE POWER OF RAGNAROS NOW YOU SHALL SEE IT FIRST HAND." -#define SAY_REINFORCEMENTS1 "COME FORTH, MY SERVANTS! DEFEND YOUR MASTER!" -#define SAY_REINFORCEMENTS2 "YOU CANNOT DEFEAT THE LIVING FLAME! COME YOU MINIONS OF FIRE! COME FORTH YOU CREATURES OF HATE! YOUR MASTER CALLS!" -#define SAY_HAND "BY FIRE BE PURGED!" -#define SAY_WRATH "TASTE THE FLAMES OF SULFURON!" -#define SAY_KILL "DIE INSECT!" -#define SAY_MAGMABURST "MY PATIENCE IS DWINDILING! COME NATS TO YOUR DEATH!" - -#define SOUND_ARRIVAL_1 8043 -#define SOUND_ARRIVAL_3 8044 -#define SOUND_ARRIVAL_5 8045 -#define SOUND_REINFORCEMENTS1 8049 -#define SOUND_REINFORCEMENTS2 8050 -#define SOUND_HAND 8046 -#define SOUND_WRATH 8047 -#define SOUND_KILL 8051 -#define SOUND_MAGMABURST 8048 - -#define ADD_1X 848.740356 -#define ADD_1Y -816.103455 -#define ADD_1Z -229.74327 -#define ADD_1O 2.615287 - -#define ADD_2X 852.560791 -#define ADD_2Y -849.861511 -#define ADD_2Z -228.560974 -#define ADD_2O 2.836073 - -#define ADD_3X 808.710632 -#define ADD_3Y -852.845764 -#define ADD_3Z -227.914963 -#define ADD_3O 0.964207 - -#define ADD_4X 786.597107 -#define ADD_4Y -821.132874 -#define ADD_4Z -226.350128 -#define ADD_4O 0.949377 - -#define ADD_5X 796.219116 -#define ADD_5Y -800.948059 -#define ADD_5Z -226.010361 -#define ADD_5O 0.560603 - -#define ADD_6X 821.602539 -#define ADD_6Y -782.744109 -#define ADD_6Z -226.023575 -#define ADD_6O 6.157440 - -#define ADD_7X 844.924744 -#define ADD_7Y -769.453735 -#define ADD_7Z -225.521698 -#define ADD_7O 4.4539958 - -#define ADD_8X 839.823364 -#define ADD_8Y -810.869385 -#define ADD_8Z -229.683182 -#define ADD_8O 4.693108 - -struct MANGOS_DLL_DECL boss_ragnarosAI : public Scripted_NoMovementAI -{ - boss_ragnarosAI(Creature *c) : Scripted_NoMovementAI(c) {Reset();} - - uint32 WrathOfRagnaros_Timer; - uint32 HandOfRagnaros_Timer; - uint32 LavaBurst_Timer; - uint32 MagmaBurst_Timer; - uint32 ElementalFire_Timer; - uint32 Erruption_Timer; - uint32 Submerge_Timer; - uint32 Attack_Timer; - Creature *Summoned; - bool HasYelledMagmaBurst; - bool HasSubmergedOnce; - bool WasBanished; - bool HasAura; - - void Reset() - { - WrathOfRagnaros_Timer = 30000; - HandOfRagnaros_Timer = 25000; - LavaBurst_Timer = 10000; - MagmaBurst_Timer = 2000; - Erruption_Timer = 15000; - ElementalFire_Timer = 3000; - Submerge_Timer = 180000; - Attack_Timer = 90000; - HasYelledMagmaBurst = false; - HasSubmergedOnce = false; - WasBanished = false; - - m_creature->CastSpell(m_creature,SPELL_MELTWEAPON,true); - HasAura = true; - } - - void KilledUnit(Unit* victim) - { - if (rand()%5) - return; - - DoYell(SAY_KILL, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_KILL); - } - - void Aggro(Unit *who) - { - DoYell(SAY_ARRIVAL_5,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_ARRIVAL_5); - } - - void UpdateAI(const uint32 diff) - { - if (WasBanished && Attack_Timer < diff) - { - //Become unbanished again - m_creature->setFaction(14); - m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - DoCast(m_creature,SPELL_RAGEMERGE); - WasBanished = false; - } else if (WasBanished) - { - Attack_Timer -= diff; - //Do nothing while banished - return; - } - - //Return since we have no target - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - //WrathOfRagnaros_Timer - if (WrathOfRagnaros_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_WRATHOFRAGNAROS); - - if (rand()%2 == 0) - { - DoYell(SAY_WRATH,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_WRATH); - } - - WrathOfRagnaros_Timer = 30000; - }else WrathOfRagnaros_Timer -= diff; - - //HandOfRagnaros_Timer - if (HandOfRagnaros_Timer < diff) - { - DoCast(m_creature,SPELL_HANDOFRAGNAROS); - - if (rand()%2==0) - { - DoYell(SAY_HAND,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_HAND); - } - - HandOfRagnaros_Timer = 25000; - }else HandOfRagnaros_Timer -= diff; - - //LavaBurst_Timer - if (LavaBurst_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_LAVABURST); - LavaBurst_Timer = 10000; - }else LavaBurst_Timer -= diff; - - //Erruption_Timer - if (LavaBurst_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_ERRUPTION); - Erruption_Timer = 20000 + rand()%25000; - }else Erruption_Timer -= diff; - - //ElementalFire_Timer - if (ElementalFire_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_ELEMENTALFIRE); - ElementalFire_Timer = 10000 + rand()%4000; - }else ElementalFire_Timer -= diff; - - //Submerge_Timer - if (!WasBanished && Submerge_Timer < diff) - { - //Creature spawning and ragnaros becomming unattackable - //is not very well supported in the core - //so added normaly spawning and banish workaround and attack again after 90 secs. - - m_creature->InterruptNonMeleeSpells(false); - //Root self - DoCast(m_creature,23973); - m_creature->setFaction(35); - m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - m_creature->HandleEmoteCommand(EMOTE_ONESHOT_SUBMERGE); - - Unit* target = NULL; - target = SelectUnit(SELECT_TARGET_RANDOM,0); - - if (!HasSubmergedOnce) - { - DoYell(SAY_REINFORCEMENTS1,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_REINFORCEMENTS1); - - // summon 10 elementals - Unit* target = NULL; - for(int i = 0; i < 9;i++) - { - target = SelectUnit(SELECT_TARGET_RANDOM,0); - Summoned = m_creature->SummonCreature(12143,target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(),0,TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN,900000); - ((CreatureAI*)Summoned->AI())->AttackStart(target); - } - - HasSubmergedOnce = true; - WasBanished = true; - DoCast(m_creature,SPELL_RAGSUBMERGE); - Attack_Timer = 90000; - - }else - { - DoYell(SAY_REINFORCEMENTS2,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_REINFORCEMENTS2); - - Unit* target = NULL; - for(int i = 0; i < 9;i++) - { - target = SelectUnit(SELECT_TARGET_RANDOM,0); - Summoned = m_creature->SummonCreature(12143,target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(),0,TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN,900000); - ((CreatureAI*)Summoned->AI())->AttackStart(target); - } - - WasBanished = true; - DoCast(m_creature,SPELL_RAGSUBMERGE); - Attack_Timer = 90000; - } - - Submerge_Timer = 180000; - }else Submerge_Timer -= diff; - - //If we are within range melee the target - if( m_creature->IsWithinDistInMap(m_creature->getVictim(), ATTACK_DISTANCE)) - { - //Make sure our attack is ready and we arn't currently casting - if( m_creature->isAttackReady() && !m_creature->IsNonMeleeSpellCasted(false)) - { - m_creature->AttackerStateUpdate(m_creature->getVictim()); - m_creature->resetAttackTimer(); - } - }else - { - //MagmaBurst_Timer - if (MagmaBurst_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_MAGMABURST); - - if (!HasYelledMagmaBurst) - { - //Say our dialog - DoYell(SAY_MAGMABURST,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_MAGMABURST); - HasYelledMagmaBurst = true; - } - - MagmaBurst_Timer = 2500; - }else MagmaBurst_Timer -= diff; - } - } -}; -CreatureAI* GetAI_boss_ragnaros(Creature *_Creature) -{ - return new boss_ragnarosAI (_Creature); -} - -void AddSC_boss_ragnaros() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_ragnaros"; - newscript->GetAI = GetAI_boss_ragnaros; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Ragnaros +SD%Complete: 75 +SDComment: Intro Dialog and event NYI +SDCategory: Molten Core +EndScriptData */ + +#include "precompiled.h" + +#define SPELL_HANDOFRAGNAROS 19780 +#define SPELL_WRATHOFRAGNAROS 20566 +#define SPELL_LAVABURST 21158 + +#define SPELL_MAGMABURST 20565 //Ranged attack + +#define SPELL_SONSOFFLAME_DUMMY 21108 //Server side effect +#define SPELL_RAGSUBMERGE 21107 //Stealth aura +#define SPELL_RAGEMERGE 20568 +#define SPELL_MELTWEAPON 21388 +#define SPELL_ELEMENTALFIRE 20564 +#define SPELL_ERRUPTION 17731 + +#define SAY_ARRIVAL_1 "TOO SOON! YOU HAVE AWAKENED ME TOO SOON, EXECUTUS! WHAT IS THE MEANING OF THIS INTRUSION?" +#define SAY_ARRIVAL_3 "FOOL! YOU ALLOWED THESE INSECTS TO RUN RAMPANT THROUGH THE HALLOWED CORE, AND NOW YOU LEAD THEM TO MY VERY LAIR? YOU HAVE FAILED ME, EXECUTUS! JUSTICE SHALL BE MET, INDEED!" +#define SAY_ARRIVAL_5 "NOW FOR YOU, INSECTS. BOLDLY YOU SAUGHT THE POWER OF RAGNAROS NOW YOU SHALL SEE IT FIRST HAND." +#define SAY_REINFORCEMENTS1 "COME FORTH, MY SERVANTS! DEFEND YOUR MASTER!" +#define SAY_REINFORCEMENTS2 "YOU CANNOT DEFEAT THE LIVING FLAME! COME YOU MINIONS OF FIRE! COME FORTH YOU CREATURES OF HATE! YOUR MASTER CALLS!" +#define SAY_HAND "BY FIRE BE PURGED!" +#define SAY_WRATH "TASTE THE FLAMES OF SULFURON!" +#define SAY_KILL "DIE INSECT!" +#define SAY_MAGMABURST "MY PATIENCE IS DWINDILING! COME NATS TO YOUR DEATH!" + +#define SOUND_ARRIVAL_1 8043 +#define SOUND_ARRIVAL_3 8044 +#define SOUND_ARRIVAL_5 8045 +#define SOUND_REINFORCEMENTS1 8049 +#define SOUND_REINFORCEMENTS2 8050 +#define SOUND_HAND 8046 +#define SOUND_WRATH 8047 +#define SOUND_KILL 8051 +#define SOUND_MAGMABURST 8048 + +#define ADD_1X 848.740356 +#define ADD_1Y -816.103455 +#define ADD_1Z -229.74327 +#define ADD_1O 2.615287 + +#define ADD_2X 852.560791 +#define ADD_2Y -849.861511 +#define ADD_2Z -228.560974 +#define ADD_2O 2.836073 + +#define ADD_3X 808.710632 +#define ADD_3Y -852.845764 +#define ADD_3Z -227.914963 +#define ADD_3O 0.964207 + +#define ADD_4X 786.597107 +#define ADD_4Y -821.132874 +#define ADD_4Z -226.350128 +#define ADD_4O 0.949377 + +#define ADD_5X 796.219116 +#define ADD_5Y -800.948059 +#define ADD_5Z -226.010361 +#define ADD_5O 0.560603 + +#define ADD_6X 821.602539 +#define ADD_6Y -782.744109 +#define ADD_6Z -226.023575 +#define ADD_6O 6.157440 + +#define ADD_7X 844.924744 +#define ADD_7Y -769.453735 +#define ADD_7Z -225.521698 +#define ADD_7O 4.4539958 + +#define ADD_8X 839.823364 +#define ADD_8Y -810.869385 +#define ADD_8Z -229.683182 +#define ADD_8O 4.693108 + +struct MANGOS_DLL_DECL boss_ragnarosAI : public Scripted_NoMovementAI +{ + boss_ragnarosAI(Creature *c) : Scripted_NoMovementAI(c) {Reset();} + + uint32 WrathOfRagnaros_Timer; + uint32 HandOfRagnaros_Timer; + uint32 LavaBurst_Timer; + uint32 MagmaBurst_Timer; + uint32 ElementalFire_Timer; + uint32 Erruption_Timer; + uint32 Submerge_Timer; + uint32 Attack_Timer; + Creature *Summoned; + bool HasYelledMagmaBurst; + bool HasSubmergedOnce; + bool WasBanished; + bool HasAura; + + void Reset() + { + WrathOfRagnaros_Timer = 30000; + HandOfRagnaros_Timer = 25000; + LavaBurst_Timer = 10000; + MagmaBurst_Timer = 2000; + Erruption_Timer = 15000; + ElementalFire_Timer = 3000; + Submerge_Timer = 180000; + Attack_Timer = 90000; + HasYelledMagmaBurst = false; + HasSubmergedOnce = false; + WasBanished = false; + + m_creature->CastSpell(m_creature,SPELL_MELTWEAPON,true); + HasAura = true; + } + + void KilledUnit(Unit* victim) + { + if (rand()%5) + return; + + DoYell(SAY_KILL, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_KILL); + } + + void Aggro(Unit *who) + { + DoYell(SAY_ARRIVAL_5,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_ARRIVAL_5); + } + + void UpdateAI(const uint32 diff) + { + if (WasBanished && Attack_Timer < diff) + { + //Become unbanished again + m_creature->setFaction(14); + m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + DoCast(m_creature,SPELL_RAGEMERGE); + WasBanished = false; + } else if (WasBanished) + { + Attack_Timer -= diff; + //Do nothing while banished + return; + } + + //Return since we have no target + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + //WrathOfRagnaros_Timer + if (WrathOfRagnaros_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_WRATHOFRAGNAROS); + + if (rand()%2 == 0) + { + DoYell(SAY_WRATH,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_WRATH); + } + + WrathOfRagnaros_Timer = 30000; + }else WrathOfRagnaros_Timer -= diff; + + //HandOfRagnaros_Timer + if (HandOfRagnaros_Timer < diff) + { + DoCast(m_creature,SPELL_HANDOFRAGNAROS); + + if (rand()%2==0) + { + DoYell(SAY_HAND,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_HAND); + } + + HandOfRagnaros_Timer = 25000; + }else HandOfRagnaros_Timer -= diff; + + //LavaBurst_Timer + if (LavaBurst_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_LAVABURST); + LavaBurst_Timer = 10000; + }else LavaBurst_Timer -= diff; + + //Erruption_Timer + if (LavaBurst_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_ERRUPTION); + Erruption_Timer = 20000 + rand()%25000; + }else Erruption_Timer -= diff; + + //ElementalFire_Timer + if (ElementalFire_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_ELEMENTALFIRE); + ElementalFire_Timer = 10000 + rand()%4000; + }else ElementalFire_Timer -= diff; + + //Submerge_Timer + if (!WasBanished && Submerge_Timer < diff) + { + //Creature spawning and ragnaros becomming unattackable + //is not very well supported in the core + //so added normaly spawning and banish workaround and attack again after 90 secs. + + m_creature->InterruptNonMeleeSpells(false); + //Root self + DoCast(m_creature,23973); + m_creature->setFaction(35); + m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + m_creature->HandleEmoteCommand(EMOTE_ONESHOT_SUBMERGE); + + Unit* target = NULL; + target = SelectUnit(SELECT_TARGET_RANDOM,0); + + if (!HasSubmergedOnce) + { + DoYell(SAY_REINFORCEMENTS1,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_REINFORCEMENTS1); + + // summon 10 elementals + Unit* target = NULL; + for(int i = 0; i < 9;i++) + { + target = SelectUnit(SELECT_TARGET_RANDOM,0); + Summoned = m_creature->SummonCreature(12143,target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(),0,TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN,900000); + ((CreatureAI*)Summoned->AI())->AttackStart(target); + } + + HasSubmergedOnce = true; + WasBanished = true; + DoCast(m_creature,SPELL_RAGSUBMERGE); + Attack_Timer = 90000; + + }else + { + DoYell(SAY_REINFORCEMENTS2,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_REINFORCEMENTS2); + + Unit* target = NULL; + for(int i = 0; i < 9;i++) + { + target = SelectUnit(SELECT_TARGET_RANDOM,0); + Summoned = m_creature->SummonCreature(12143,target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(),0,TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN,900000); + ((CreatureAI*)Summoned->AI())->AttackStart(target); + } + + WasBanished = true; + DoCast(m_creature,SPELL_RAGSUBMERGE); + Attack_Timer = 90000; + } + + Submerge_Timer = 180000; + }else Submerge_Timer -= diff; + + //If we are within range melee the target + if( m_creature->IsWithinDistInMap(m_creature->getVictim(), ATTACK_DISTANCE)) + { + //Make sure our attack is ready and we arn't currently casting + if( m_creature->isAttackReady() && !m_creature->IsNonMeleeSpellCasted(false)) + { + m_creature->AttackerStateUpdate(m_creature->getVictim()); + m_creature->resetAttackTimer(); + } + }else + { + //MagmaBurst_Timer + if (MagmaBurst_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_MAGMABURST); + + if (!HasYelledMagmaBurst) + { + //Say our dialog + DoYell(SAY_MAGMABURST,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_MAGMABURST); + HasYelledMagmaBurst = true; + } + + MagmaBurst_Timer = 2500; + }else MagmaBurst_Timer -= diff; + } + } +}; +CreatureAI* GetAI_boss_ragnaros(Creature *_Creature) +{ + return new boss_ragnarosAI (_Creature); +} + +void AddSC_boss_ragnaros() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_ragnaros"; + newscript->GetAI = GetAI_boss_ragnaros; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/molten_core/boss_shazzrah.cpp b/src/bindings/scripts/scripts/zone/molten_core/boss_shazzrah.cpp index 5c8746b2567..e3876b79ecc 100644 --- a/src/bindings/scripts/scripts/zone/molten_core/boss_shazzrah.cpp +++ b/src/bindings/scripts/scripts/zone/molten_core/boss_shazzrah.cpp @@ -1,121 +1,121 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Shazzrah -SD%Complete: 75 -SDComment: Teleport NYI -SDCategory: Molten Core -EndScriptData */ - -#include "precompiled.h" - -#define SPELL_ARCANEEXPLOSION 19712 -#define SPELL_SHAZZRAHCURSE 19713 -#define SPELL_DEADENMAGIC 19714 -#define SPELL_COUNTERSPELL 19715 - -struct MANGOS_DLL_DECL boss_shazzrahAI : public ScriptedAI -{ - boss_shazzrahAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 ArcaneExplosion_Timer; - uint32 ShazzrahCurse_Timer; - uint32 DeadenMagic_Timer; - uint32 Countspell_Timer; - uint32 Blink_Timer; - - void Reset() - { - ArcaneExplosion_Timer = 6000; //These times are probably wrong - ShazzrahCurse_Timer = 10000; - DeadenMagic_Timer = 24000; - Countspell_Timer = 15000; - Blink_Timer = 30000; - } - - void Aggro(Unit *who) - { - } - - void UpdateAI(const uint32 diff) - { - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - //ArcaneExplosion_Timer - if (ArcaneExplosion_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_ARCANEEXPLOSION); - ArcaneExplosion_Timer = 5000 + rand()%4000; - }else ArcaneExplosion_Timer -= diff; - - //ShazzrahCurse_Timer - if (ShazzrahCurse_Timer < diff) - { - Unit* target = NULL; - target = SelectUnit(SELECT_TARGET_RANDOM,0); - if (target) DoCast(target,SPELL_SHAZZRAHCURSE); - - ShazzrahCurse_Timer = 25000 + rand()%5000; - }else ShazzrahCurse_Timer -= diff; - - //DeadenMagic_Timer - if (DeadenMagic_Timer < diff) - { - DoCast(m_creature,SPELL_DEADENMAGIC); - DeadenMagic_Timer = 35000; - }else DeadenMagic_Timer -= diff; - - //Countspell_Timer - if (Countspell_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_COUNTERSPELL); - Countspell_Timer = 16000 + rand()%4000; - }else Countspell_Timer -= diff; - - //Blink_Timer - if (Blink_Timer < diff) - { - // Teleporting him to a random gamer and casting Arcane Explosion after that. - // Blink is not working cause of LoS System we need to do this hardcoded. - Unit* target = NULL; - target = SelectUnit(SELECT_TARGET_RANDOM,0); - - m_creature->Relocate(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(),0); - m_creature->SendMonsterMove(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(),0,true,0); - DoCast(target,SPELL_ARCANEEXPLOSION); - DoResetThreat(); - - Blink_Timer = 45000; - }else Blink_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; -CreatureAI* GetAI_boss_shazzrah(Creature *_Creature) -{ - return new boss_shazzrahAI (_Creature); -} - -void AddSC_boss_shazzrah() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_shazzrah"; - newscript->GetAI = GetAI_boss_shazzrah; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Shazzrah +SD%Complete: 75 +SDComment: Teleport NYI +SDCategory: Molten Core +EndScriptData */ + +#include "precompiled.h" + +#define SPELL_ARCANEEXPLOSION 19712 +#define SPELL_SHAZZRAHCURSE 19713 +#define SPELL_DEADENMAGIC 19714 +#define SPELL_COUNTERSPELL 19715 + +struct MANGOS_DLL_DECL boss_shazzrahAI : public ScriptedAI +{ + boss_shazzrahAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 ArcaneExplosion_Timer; + uint32 ShazzrahCurse_Timer; + uint32 DeadenMagic_Timer; + uint32 Countspell_Timer; + uint32 Blink_Timer; + + void Reset() + { + ArcaneExplosion_Timer = 6000; //These times are probably wrong + ShazzrahCurse_Timer = 10000; + DeadenMagic_Timer = 24000; + Countspell_Timer = 15000; + Blink_Timer = 30000; + } + + void Aggro(Unit *who) + { + } + + void UpdateAI(const uint32 diff) + { + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + //ArcaneExplosion_Timer + if (ArcaneExplosion_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_ARCANEEXPLOSION); + ArcaneExplosion_Timer = 5000 + rand()%4000; + }else ArcaneExplosion_Timer -= diff; + + //ShazzrahCurse_Timer + if (ShazzrahCurse_Timer < diff) + { + Unit* target = NULL; + target = SelectUnit(SELECT_TARGET_RANDOM,0); + if (target) DoCast(target,SPELL_SHAZZRAHCURSE); + + ShazzrahCurse_Timer = 25000 + rand()%5000; + }else ShazzrahCurse_Timer -= diff; + + //DeadenMagic_Timer + if (DeadenMagic_Timer < diff) + { + DoCast(m_creature,SPELL_DEADENMAGIC); + DeadenMagic_Timer = 35000; + }else DeadenMagic_Timer -= diff; + + //Countspell_Timer + if (Countspell_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_COUNTERSPELL); + Countspell_Timer = 16000 + rand()%4000; + }else Countspell_Timer -= diff; + + //Blink_Timer + if (Blink_Timer < diff) + { + // Teleporting him to a random gamer and casting Arcane Explosion after that. + // Blink is not working cause of LoS System we need to do this hardcoded. + Unit* target = NULL; + target = SelectUnit(SELECT_TARGET_RANDOM,0); + + m_creature->Relocate(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(),0); + m_creature->SendMonsterMove(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(),0,true,0); + DoCast(target,SPELL_ARCANEEXPLOSION); + DoResetThreat(); + + Blink_Timer = 45000; + }else Blink_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; +CreatureAI* GetAI_boss_shazzrah(Creature *_Creature) +{ + return new boss_shazzrahAI (_Creature); +} + +void AddSC_boss_shazzrah() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_shazzrah"; + newscript->GetAI = GetAI_boss_shazzrah; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/molten_core/boss_sulfuron_harbinger.cpp b/src/bindings/scripts/scripts/zone/molten_core/boss_sulfuron_harbinger.cpp index fd4affaa570..7b03c2da7a4 100644 --- a/src/bindings/scripts/scripts/zone/molten_core/boss_sulfuron_harbinger.cpp +++ b/src/bindings/scripts/scripts/zone/molten_core/boss_sulfuron_harbinger.cpp @@ -1,215 +1,215 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Sulfuron_Harbringer -SD%Complete: 80 -SDComment: Adds NYI -SDCategory: Molten Core -EndScriptData */ - -#include "precompiled.h" -#include "def_molten_core.h" - -#define SPELL_DARKSTRIKE 19777 -#define SPELL_DEMORALIZINGSHOUT 19778 -#define SPELL_INSPIRE 19779 -#define SPELL_KNOCKDOWN 19780 -#define SPELL_FLAMESPEAR 19781 - -//Adds Spells -#define SPELL_HEAL 19775 -#define SPELL_SHADOWWORDPAIN 19776 -#define SPELL_IMMOLATE 20294 - -struct MANGOS_DLL_DECL boss_sulfuronAI : public ScriptedAI -{ - boss_sulfuronAI(Creature *c) : ScriptedAI(c) - { - pInstance = (c->GetInstanceData()) ? ((ScriptedInstance*)c->GetInstanceData()) : NULL; - Reset(); - } - - uint32 Darkstrike_Timer; - uint32 DemoralizingShout_Timer; - uint32 Inspire_Timer; - uint32 Knockdown_Timer; - uint32 Flamespear_Timer; - ScriptedInstance *pInstance; - - void Reset() - { - Darkstrike_Timer=10000; //These times are probably wrong - DemoralizingShout_Timer = 15000; - Inspire_Timer = 13000; - Knockdown_Timer = 6000; - Flamespear_Timer = 2000; - } - - void Aggro(Unit *who) - { - } - - void UpdateAI(const uint32 diff) - { - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - //DemoralizingShout_Timer - if (DemoralizingShout_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_DEMORALIZINGSHOUT); - DemoralizingShout_Timer = 15000 + rand()%5000; - }else DemoralizingShout_Timer -= diff; - - //Inspire_Timer - if (Inspire_Timer < diff) - { - Creature* target = NULL; - std::list pList = DoFindFriendlyMissingBuff(45.0f,SPELL_INSPIRE); - if (!pList.empty()) - { - std::list::iterator i = pList.begin(); - advance(i, (rand()%pList.size())); - target = (*i); - } - - if (target) - DoCast(target,SPELL_INSPIRE); - - DoCast(m_creature,SPELL_INSPIRE); - - Inspire_Timer = 20000 + rand()%6000; - }else Inspire_Timer -= diff; - - //Knockdown_Timer - if (Knockdown_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_KNOCKDOWN); - Knockdown_Timer = 12000 + rand()%3000; - }else Knockdown_Timer -= diff; - - //Flamespear_Timer - if (Flamespear_Timer < diff) - { - Unit* target = NULL; - target = SelectUnit(SELECT_TARGET_RANDOM,0); - if (target) DoCast(target,SPELL_FLAMESPEAR); - - Flamespear_Timer = 12000 + rand()%4000; - }else Flamespear_Timer -= diff; - - //DarkStrike_Timer - if (Darkstrike_Timer < diff) - { - DoCast(m_creature, SPELL_DARKSTRIKE); - Darkstrike_Timer = 15000 + rand()%3000; - }else Darkstrike_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; - -struct MANGOS_DLL_DECL mob_flamewaker_priestAI : public ScriptedAI -{ - mob_flamewaker_priestAI(Creature *c) : ScriptedAI(c) - { - pInstance = (c->GetInstanceData()) ? ((ScriptedInstance*)c->GetInstanceData()) : NULL; - Reset(); - } - - uint32 Heal_Timer; - uint32 ShadowWordPain_Timer; - uint32 Immolate_Timer; - - ScriptedInstance *pInstance; - - void Reset() - { - Heal_Timer = 15000+rand()%15000; - ShadowWordPain_Timer = 2000; - Immolate_Timer = 8000; - } - - void Aggro(Unit *who) - { - } - - void UpdateAI(const uint32 diff) - { - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - //Casting Heal to Sulfuron or other Guards. - if(Heal_Timer < diff) - { - Unit* pUnit = DoSelectLowestHpFriendly(60.0f, 1); - if (!pUnit) - return; - - DoCast(pUnit, SPELL_HEAL); - - Heal_Timer = 15000+rand()%5000; - }else Heal_Timer -= diff; - - //ShadowWordPain_Timer - if (ShadowWordPain_Timer < diff) - { - Unit* target = NULL; - target = SelectUnit(SELECT_TARGET_RANDOM,0); - if (target) DoCast(target,SPELL_SHADOWWORDPAIN); - - ShadowWordPain_Timer = 18000+rand()%8000; - }else ShadowWordPain_Timer -= diff; - - //Immolate_Timer - if (Immolate_Timer < diff) - { - Unit* target = NULL; - target = SelectUnit(SELECT_TARGET_RANDOM,0); - if (target) DoCast(target,SPELL_IMMOLATE); - - Immolate_Timer = 15000+rand()%10000; - }else Immolate_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; - -CreatureAI* GetAI_boss_sulfuron(Creature *_Creature) -{ - return new boss_sulfuronAI (_Creature); -} - -CreatureAI* GetAI_mob_flamewaker_priest(Creature *_Creature) -{ - return new mob_flamewaker_priestAI (_Creature); -} - -void AddSC_boss_sulfuron() -{ - Script *newscript; - - newscript = new Script; - newscript->Name="boss_sulfuron"; - newscript->GetAI = GetAI_boss_sulfuron; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="mob_flamewaker_priest"; - newscript->GetAI = GetAI_mob_flamewaker_priest; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Sulfuron_Harbringer +SD%Complete: 80 +SDComment: Adds NYI +SDCategory: Molten Core +EndScriptData */ + +#include "precompiled.h" +#include "def_molten_core.h" + +#define SPELL_DARKSTRIKE 19777 +#define SPELL_DEMORALIZINGSHOUT 19778 +#define SPELL_INSPIRE 19779 +#define SPELL_KNOCKDOWN 19780 +#define SPELL_FLAMESPEAR 19781 + +//Adds Spells +#define SPELL_HEAL 19775 +#define SPELL_SHADOWWORDPAIN 19776 +#define SPELL_IMMOLATE 20294 + +struct MANGOS_DLL_DECL boss_sulfuronAI : public ScriptedAI +{ + boss_sulfuronAI(Creature *c) : ScriptedAI(c) + { + pInstance = (c->GetInstanceData()) ? ((ScriptedInstance*)c->GetInstanceData()) : NULL; + Reset(); + } + + uint32 Darkstrike_Timer; + uint32 DemoralizingShout_Timer; + uint32 Inspire_Timer; + uint32 Knockdown_Timer; + uint32 Flamespear_Timer; + ScriptedInstance *pInstance; + + void Reset() + { + Darkstrike_Timer=10000; //These times are probably wrong + DemoralizingShout_Timer = 15000; + Inspire_Timer = 13000; + Knockdown_Timer = 6000; + Flamespear_Timer = 2000; + } + + void Aggro(Unit *who) + { + } + + void UpdateAI(const uint32 diff) + { + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + //DemoralizingShout_Timer + if (DemoralizingShout_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_DEMORALIZINGSHOUT); + DemoralizingShout_Timer = 15000 + rand()%5000; + }else DemoralizingShout_Timer -= diff; + + //Inspire_Timer + if (Inspire_Timer < diff) + { + Creature* target = NULL; + std::list pList = DoFindFriendlyMissingBuff(45.0f,SPELL_INSPIRE); + if (!pList.empty()) + { + std::list::iterator i = pList.begin(); + advance(i, (rand()%pList.size())); + target = (*i); + } + + if (target) + DoCast(target,SPELL_INSPIRE); + + DoCast(m_creature,SPELL_INSPIRE); + + Inspire_Timer = 20000 + rand()%6000; + }else Inspire_Timer -= diff; + + //Knockdown_Timer + if (Knockdown_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_KNOCKDOWN); + Knockdown_Timer = 12000 + rand()%3000; + }else Knockdown_Timer -= diff; + + //Flamespear_Timer + if (Flamespear_Timer < diff) + { + Unit* target = NULL; + target = SelectUnit(SELECT_TARGET_RANDOM,0); + if (target) DoCast(target,SPELL_FLAMESPEAR); + + Flamespear_Timer = 12000 + rand()%4000; + }else Flamespear_Timer -= diff; + + //DarkStrike_Timer + if (Darkstrike_Timer < diff) + { + DoCast(m_creature, SPELL_DARKSTRIKE); + Darkstrike_Timer = 15000 + rand()%3000; + }else Darkstrike_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; + +struct MANGOS_DLL_DECL mob_flamewaker_priestAI : public ScriptedAI +{ + mob_flamewaker_priestAI(Creature *c) : ScriptedAI(c) + { + pInstance = (c->GetInstanceData()) ? ((ScriptedInstance*)c->GetInstanceData()) : NULL; + Reset(); + } + + uint32 Heal_Timer; + uint32 ShadowWordPain_Timer; + uint32 Immolate_Timer; + + ScriptedInstance *pInstance; + + void Reset() + { + Heal_Timer = 15000+rand()%15000; + ShadowWordPain_Timer = 2000; + Immolate_Timer = 8000; + } + + void Aggro(Unit *who) + { + } + + void UpdateAI(const uint32 diff) + { + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + //Casting Heal to Sulfuron or other Guards. + if(Heal_Timer < diff) + { + Unit* pUnit = DoSelectLowestHpFriendly(60.0f, 1); + if (!pUnit) + return; + + DoCast(pUnit, SPELL_HEAL); + + Heal_Timer = 15000+rand()%5000; + }else Heal_Timer -= diff; + + //ShadowWordPain_Timer + if (ShadowWordPain_Timer < diff) + { + Unit* target = NULL; + target = SelectUnit(SELECT_TARGET_RANDOM,0); + if (target) DoCast(target,SPELL_SHADOWWORDPAIN); + + ShadowWordPain_Timer = 18000+rand()%8000; + }else ShadowWordPain_Timer -= diff; + + //Immolate_Timer + if (Immolate_Timer < diff) + { + Unit* target = NULL; + target = SelectUnit(SELECT_TARGET_RANDOM,0); + if (target) DoCast(target,SPELL_IMMOLATE); + + Immolate_Timer = 15000+rand()%10000; + }else Immolate_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; + +CreatureAI* GetAI_boss_sulfuron(Creature *_Creature) +{ + return new boss_sulfuronAI (_Creature); +} + +CreatureAI* GetAI_mob_flamewaker_priest(Creature *_Creature) +{ + return new mob_flamewaker_priestAI (_Creature); +} + +void AddSC_boss_sulfuron() +{ + Script *newscript; + + newscript = new Script; + newscript->Name="boss_sulfuron"; + newscript->GetAI = GetAI_boss_sulfuron; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="mob_flamewaker_priest"; + newscript->GetAI = GetAI_mob_flamewaker_priest; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/molten_core/def_molten_core.h b/src/bindings/scripts/scripts/zone/molten_core/def_molten_core.h index 584adce0d31..793bedb3ca8 100644 --- a/src/bindings/scripts/scripts/zone/molten_core/def_molten_core.h +++ b/src/bindings/scripts/scripts/zone/molten_core/def_molten_core.h @@ -1,21 +1,21 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software licensed under GPL version 2 - * Please see the included DOCS/LICENSE.TXT for more information */ - -#ifndef DEF_MOLTEN_CORE_H -#define DEF_MOLTEN_CORE_H - -#define DATA_FLAMEWAKERPRIEST 1 -#define DATA_GARRISDEAD 2 -#define DATA_GEDDONISDEAD 3 -#define DATA_GEHENNASISDEAD 4 -#define DATA_GOLEMAGGISDEAD 5 -#define DATA_GOLEMAGG_DEATH 6 -#define DATA_LUCIFRONISDEAD 7 -#define DATA_MAGMADARISDEAD 8 -#define DATA_MAJORDOMOISDEAD 9 -#define DATA_SHAZZRAHISDEAD 10 -#define DATA_SULFURON 11 -#define DATA_SULFURONISDEAD 12 -#define DATA_GOLEMAGG 13 -#endif +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software licensed under GPL version 2 + * Please see the included DOCS/LICENSE.TXT for more information */ + +#ifndef DEF_MOLTEN_CORE_H +#define DEF_MOLTEN_CORE_H + +#define DATA_FLAMEWAKERPRIEST 1 +#define DATA_GARRISDEAD 2 +#define DATA_GEDDONISDEAD 3 +#define DATA_GEHENNASISDEAD 4 +#define DATA_GOLEMAGGISDEAD 5 +#define DATA_GOLEMAGG_DEATH 6 +#define DATA_LUCIFRONISDEAD 7 +#define DATA_MAGMADARISDEAD 8 +#define DATA_MAJORDOMOISDEAD 9 +#define DATA_SHAZZRAHISDEAD 10 +#define DATA_SULFURON 11 +#define DATA_SULFURONISDEAD 12 +#define DATA_GOLEMAGG 13 +#endif diff --git a/src/bindings/scripts/scripts/zone/molten_core/instance_molten_core.cpp b/src/bindings/scripts/scripts/zone/molten_core/instance_molten_core.cpp index 60521aa5f9c..53a291affcd 100644 --- a/src/bindings/scripts/scripts/zone/molten_core/instance_molten_core.cpp +++ b/src/bindings/scripts/scripts/zone/molten_core/instance_molten_core.cpp @@ -1,260 +1,260 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Instance_Molten_Core -SD%Complete: 0 -SDComment: Place Holder -SDCategory: Molten Core -EndScriptData */ - -#include "precompiled.h" -#include "def_molten_core.h" - -#define ID_LUCIFRON 12118 -#define ID_MAGMADAR 11982 -#define ID_GEHENNAS 12259 -#define ID_GARR 12057 -#define ID_GEDDON 12056 -#define ID_SHAZZRAH 12264 -#define ID_GOLEMAGG 11988 -#define ID_SULFURON 12098 -#define ID_DOMO 12018 -#define ID_RAGNAROS 11502 -#define ID_FLAMEWAKERPRIEST 11662 - -class MANGOS_DLL_SPEC instance_molten_core : public ScriptedInstance -{ - public: - - instance_molten_core(Map *map) : ScriptedInstance(map) {} - - uint64 Lucifron, Magmadar, Gehennas, Garr, Geddon, Shazzrah, Sulfuron, Golemagg, Domo, Ragnaros, FlamewakerPriest; - uint64 RuneGUID[8]; - - //If all Bosses are dead. - bool IsBossDied[9]; - - uint32 CheckTimer; - - //On creation, NOT load. - void Initialize() - { - //Clear all GUIDs - Lucifron = 0; - Magmadar = 0; - Gehennas = 0; - Garr = 0; - Geddon = 0; - Shazzrah = 0; - Sulfuron = 0; - Golemagg = 0; - Domo = 0; - Ragnaros = 0; - FlamewakerPriest = 0; - - RuneGUID[0] = 0; - RuneGUID[1] = 0; - RuneGUID[2] = 0; - RuneGUID[3] = 0; - RuneGUID[4] = 0; - RuneGUID[5] = 0; - RuneGUID[6] = 0; - RuneGUID[7] = 0; - - IsBossDied[0] = false; - IsBossDied[1] = false; - IsBossDied[2] = false; - IsBossDied[3] = false; - IsBossDied[4] = false; - IsBossDied[5] = false; - IsBossDied[6] = false; - - IsBossDied[7] = false; - IsBossDied[8] = false; - - CheckTimer = 10000; - } - //Called every map update - void Update(uint32 diff) - { - - if (CheckTimer < diff) - { - //Check if all bosses are dead and activate Major Domo - - }else CheckTimer -= diff; - - } - - //Used by the map's CanEnter function. - //This is to prevent players from entering during boss encounters. - bool IsEncounterInProgress() const - { - return false; - }; - - //Called when a gameobject is created - void OnObjectCreate(GameObject *obj) - { - //Still searching for the individual rune ids. - //Currently they don't exist within most databases and are hard to find on websites - } - - //called on creature creation - void OnCreatureCreate(Creature *creature, uint32 creature_entry) - { - //Store specific creatures based on entry id - switch (creature_entry) - { - case ID_LUCIFRON: - Lucifron = creature->GetGUID(); - break; - - case ID_MAGMADAR: - Magmadar = creature->GetGUID(); - break; - - case ID_GEHENNAS: - Gehennas = creature->GetGUID(); - break; - - case ID_GARR: - Garr = creature->GetGUID(); - break; - - case ID_GEDDON: - Geddon = creature->GetGUID(); - break; - - case ID_SHAZZRAH: - Shazzrah = creature->GetGUID(); - break; - - case ID_SULFURON: - Sulfuron = creature->GetGUID(); - break; - - case ID_GOLEMAGG: - Golemagg = creature->GetGUID(); - break; - - case ID_DOMO: - Domo = creature->GetGUID(); - break; - - case ID_RAGNAROS: - Ragnaros = creature->GetGUID(); - break; - - case ID_FLAMEWAKERPRIEST: - FlamewakerPriest = creature->GetGUID(); - break; - - default: - return; - } - } - - uint64 GetData64 (uint32 identifier) - { - switch(identifier) - { - case DATA_SULFURON: - return Sulfuron; - case DATA_GOLEMAGG: - return Sulfuron; - - case DATA_FLAMEWAKERPRIEST: - return FlamewakerPriest; - } - - return 0; - } // end GetData64 - - uint32 GetData(uint32 type) - { - switch(type) - { - case DATA_LUCIFRONISDEAD: - if(IsBossDied[0]) - return 1; - break; - - case DATA_MAGMADARISDEAD: - if(IsBossDied[1]) - return 1; - break; - - case DATA_GEHENNASISDEAD: - if(IsBossDied[2]) - return 1; - break; - - case DATA_GARRISDEAD: - if(IsBossDied[3]) - return 1; - break; - - case DATA_GEDDONISDEAD: - if(IsBossDied[4]) - return 1; - break; - - case DATA_SHAZZRAHISDEAD: - if(IsBossDied[5]) - return 1; - break; - - case DATA_SULFURONISDEAD: - if(IsBossDied[6]) - return 1; - break; - - case DATA_GOLEMAGGISDEAD: - if(IsBossDied[7]) - return 1; - break; - - case DATA_MAJORDOMOISDEAD: - if(IsBossDied[8]) - return 1; - break; - } - - return 0; - } - - void SetData(uint32 type, uint32 data) - { - if(type == DATA_GOLEMAGG_DEATH) - IsBossDied[7] = true; - } -}; - -InstanceData* GetInstance_instance_molten_core(Map *_Map) -{ - return new instance_molten_core (_Map); -} - -void AddSC_instance_molten_core() -{ - Script *newscript; - newscript = new Script; - newscript->Name="instance_molten_core"; - newscript->GetInstanceData = &GetInstance_instance_molten_core; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Instance_Molten_Core +SD%Complete: 0 +SDComment: Place Holder +SDCategory: Molten Core +EndScriptData */ + +#include "precompiled.h" +#include "def_molten_core.h" + +#define ID_LUCIFRON 12118 +#define ID_MAGMADAR 11982 +#define ID_GEHENNAS 12259 +#define ID_GARR 12057 +#define ID_GEDDON 12056 +#define ID_SHAZZRAH 12264 +#define ID_GOLEMAGG 11988 +#define ID_SULFURON 12098 +#define ID_DOMO 12018 +#define ID_RAGNAROS 11502 +#define ID_FLAMEWAKERPRIEST 11662 + +class MANGOS_DLL_SPEC instance_molten_core : public ScriptedInstance +{ + public: + + instance_molten_core(Map *map) : ScriptedInstance(map) {} + + uint64 Lucifron, Magmadar, Gehennas, Garr, Geddon, Shazzrah, Sulfuron, Golemagg, Domo, Ragnaros, FlamewakerPriest; + uint64 RuneGUID[8]; + + //If all Bosses are dead. + bool IsBossDied[9]; + + uint32 CheckTimer; + + //On creation, NOT load. + void Initialize() + { + //Clear all GUIDs + Lucifron = 0; + Magmadar = 0; + Gehennas = 0; + Garr = 0; + Geddon = 0; + Shazzrah = 0; + Sulfuron = 0; + Golemagg = 0; + Domo = 0; + Ragnaros = 0; + FlamewakerPriest = 0; + + RuneGUID[0] = 0; + RuneGUID[1] = 0; + RuneGUID[2] = 0; + RuneGUID[3] = 0; + RuneGUID[4] = 0; + RuneGUID[5] = 0; + RuneGUID[6] = 0; + RuneGUID[7] = 0; + + IsBossDied[0] = false; + IsBossDied[1] = false; + IsBossDied[2] = false; + IsBossDied[3] = false; + IsBossDied[4] = false; + IsBossDied[5] = false; + IsBossDied[6] = false; + + IsBossDied[7] = false; + IsBossDied[8] = false; + + CheckTimer = 10000; + } + //Called every map update + void Update(uint32 diff) + { + + if (CheckTimer < diff) + { + //Check if all bosses are dead and activate Major Domo + + }else CheckTimer -= diff; + + } + + //Used by the map's CanEnter function. + //This is to prevent players from entering during boss encounters. + bool IsEncounterInProgress() const + { + return false; + }; + + //Called when a gameobject is created + void OnObjectCreate(GameObject *obj) + { + //Still searching for the individual rune ids. + //Currently they don't exist within most databases and are hard to find on websites + } + + //called on creature creation + void OnCreatureCreate(Creature *creature, uint32 creature_entry) + { + //Store specific creatures based on entry id + switch (creature_entry) + { + case ID_LUCIFRON: + Lucifron = creature->GetGUID(); + break; + + case ID_MAGMADAR: + Magmadar = creature->GetGUID(); + break; + + case ID_GEHENNAS: + Gehennas = creature->GetGUID(); + break; + + case ID_GARR: + Garr = creature->GetGUID(); + break; + + case ID_GEDDON: + Geddon = creature->GetGUID(); + break; + + case ID_SHAZZRAH: + Shazzrah = creature->GetGUID(); + break; + + case ID_SULFURON: + Sulfuron = creature->GetGUID(); + break; + + case ID_GOLEMAGG: + Golemagg = creature->GetGUID(); + break; + + case ID_DOMO: + Domo = creature->GetGUID(); + break; + + case ID_RAGNAROS: + Ragnaros = creature->GetGUID(); + break; + + case ID_FLAMEWAKERPRIEST: + FlamewakerPriest = creature->GetGUID(); + break; + + default: + return; + } + } + + uint64 GetData64 (uint32 identifier) + { + switch(identifier) + { + case DATA_SULFURON: + return Sulfuron; + case DATA_GOLEMAGG: + return Sulfuron; + + case DATA_FLAMEWAKERPRIEST: + return FlamewakerPriest; + } + + return 0; + } // end GetData64 + + uint32 GetData(uint32 type) + { + switch(type) + { + case DATA_LUCIFRONISDEAD: + if(IsBossDied[0]) + return 1; + break; + + case DATA_MAGMADARISDEAD: + if(IsBossDied[1]) + return 1; + break; + + case DATA_GEHENNASISDEAD: + if(IsBossDied[2]) + return 1; + break; + + case DATA_GARRISDEAD: + if(IsBossDied[3]) + return 1; + break; + + case DATA_GEDDONISDEAD: + if(IsBossDied[4]) + return 1; + break; + + case DATA_SHAZZRAHISDEAD: + if(IsBossDied[5]) + return 1; + break; + + case DATA_SULFURONISDEAD: + if(IsBossDied[6]) + return 1; + break; + + case DATA_GOLEMAGGISDEAD: + if(IsBossDied[7]) + return 1; + break; + + case DATA_MAJORDOMOISDEAD: + if(IsBossDied[8]) + return 1; + break; + } + + return 0; + } + + void SetData(uint32 type, uint32 data) + { + if(type == DATA_GOLEMAGG_DEATH) + IsBossDied[7] = true; + } +}; + +InstanceData* GetInstance_instance_molten_core(Map *_Map) +{ + return new instance_molten_core (_Map); +} + +void AddSC_instance_molten_core() +{ + Script *newscript; + newscript = new Script; + newscript->Name="instance_molten_core"; + newscript->GetInstanceData = &GetInstance_instance_molten_core; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/molten_core/molten_core.cpp b/src/bindings/scripts/scripts/zone/molten_core/molten_core.cpp index c2aab542828..4e406090577 100644 --- a/src/bindings/scripts/scripts/zone/molten_core/molten_core.cpp +++ b/src/bindings/scripts/scripts/zone/molten_core/molten_core.cpp @@ -1,88 +1,88 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Molten_Core -SD%Complete: 100 -SDComment: -SDCategory: Molten Core -EndScriptData */ - -/* ContentData -mob_ancient_core_hound -EndContentData */ - -#include "precompiled.h" -#include "../../creature/simple_ai.h" - -#define SPELL_CONE_OF_FIRE 19630 -#define SPELL_BITE 19771 - -//Random Debuff (each hound has only one of these) -#define SPELL_GROUND_STOMP 19364 -#define SPELL_ANCIENT_DREAD 19365 -#define SPELL_CAUTERIZING_FLAMES 19366 -#define SPELL_WITHERING_HEAT 19367 -#define SPELL_ANCIENT_DESPAIR 19369 -#define SPELL_ANCIENT_HYSTERIA 19372 - -CreatureAI* GetAI_mob_ancient_core_hound(Creature *_Creature) -{ - SimpleAI *ai = new SimpleAI(_Creature); - - ai->Spell[0].Enabled = true; - ai->Spell[0].Spell_Id = SPELL_CONE_OF_FIRE; - ai->Spell[0].Cooldown = 7000; - ai->Spell[0].First_Cast = 10000; - ai->Spell[0].Cast_Target_Type = CAST_HOSTILE_TARGET; - - uint32 RandDebuff; - switch(rand()%6) - { - case 0 : RandDebuff = SPELL_GROUND_STOMP; break; - case 1 : RandDebuff = SPELL_ANCIENT_DREAD; break; - case 2 : RandDebuff = SPELL_CAUTERIZING_FLAMES; break; - case 3 : RandDebuff = SPELL_WITHERING_HEAT; break; - case 4 : RandDebuff = SPELL_ANCIENT_DESPAIR; break; - case 5 : RandDebuff = SPELL_ANCIENT_HYSTERIA; break; - } - - ai->Spell[1].Enabled = true; - ai->Spell[1].Spell_Id = RandDebuff; - ai->Spell[1].Cooldown = 24000; - ai->Spell[1].First_Cast = 15000; - ai->Spell[1].Cast_Target_Type = CAST_HOSTILE_TARGET; - - ai->Spell[2].Enabled = true; - ai->Spell[2].Spell_Id = SPELL_BITE; - ai->Spell[2].Cooldown = 6000; - ai->Spell[2].First_Cast = 4000; - ai->Spell[2].Cast_Target_Type = CAST_HOSTILE_TARGET; - - ai->EnterEvadeMode(); - - return ai; -} - -void AddSC_molten_core() -{ - Script *newscript; - - newscript = new Script; - newscript->Name="mob_ancient_core_hound"; - newscript->GetAI = GetAI_mob_ancient_core_hound; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Molten_Core +SD%Complete: 100 +SDComment: +SDCategory: Molten Core +EndScriptData */ + +/* ContentData +mob_ancient_core_hound +EndContentData */ + +#include "precompiled.h" +#include "../../creature/simple_ai.h" + +#define SPELL_CONE_OF_FIRE 19630 +#define SPELL_BITE 19771 + +//Random Debuff (each hound has only one of these) +#define SPELL_GROUND_STOMP 19364 +#define SPELL_ANCIENT_DREAD 19365 +#define SPELL_CAUTERIZING_FLAMES 19366 +#define SPELL_WITHERING_HEAT 19367 +#define SPELL_ANCIENT_DESPAIR 19369 +#define SPELL_ANCIENT_HYSTERIA 19372 + +CreatureAI* GetAI_mob_ancient_core_hound(Creature *_Creature) +{ + SimpleAI *ai = new SimpleAI(_Creature); + + ai->Spell[0].Enabled = true; + ai->Spell[0].Spell_Id = SPELL_CONE_OF_FIRE; + ai->Spell[0].Cooldown = 7000; + ai->Spell[0].First_Cast = 10000; + ai->Spell[0].Cast_Target_Type = CAST_HOSTILE_TARGET; + + uint32 RandDebuff; + switch(rand()%6) + { + case 0 : RandDebuff = SPELL_GROUND_STOMP; break; + case 1 : RandDebuff = SPELL_ANCIENT_DREAD; break; + case 2 : RandDebuff = SPELL_CAUTERIZING_FLAMES; break; + case 3 : RandDebuff = SPELL_WITHERING_HEAT; break; + case 4 : RandDebuff = SPELL_ANCIENT_DESPAIR; break; + case 5 : RandDebuff = SPELL_ANCIENT_HYSTERIA; break; + } + + ai->Spell[1].Enabled = true; + ai->Spell[1].Spell_Id = RandDebuff; + ai->Spell[1].Cooldown = 24000; + ai->Spell[1].First_Cast = 15000; + ai->Spell[1].Cast_Target_Type = CAST_HOSTILE_TARGET; + + ai->Spell[2].Enabled = true; + ai->Spell[2].Spell_Id = SPELL_BITE; + ai->Spell[2].Cooldown = 6000; + ai->Spell[2].First_Cast = 4000; + ai->Spell[2].Cast_Target_Type = CAST_HOSTILE_TARGET; + + ai->EnterEvadeMode(); + + return ai; +} + +void AddSC_molten_core() +{ + Script *newscript; + + newscript = new Script; + newscript->Name="mob_ancient_core_hound"; + newscript->GetAI = GetAI_mob_ancient_core_hound; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/moonglade/moonglade.cpp b/src/bindings/scripts/scripts/zone/moonglade/moonglade.cpp index d88aadf04ab..34803d14aec 100644 --- a/src/bindings/scripts/scripts/zone/moonglade/moonglade.cpp +++ b/src/bindings/scripts/scripts/zone/moonglade/moonglade.cpp @@ -1,217 +1,217 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Moonglade -SD%Complete: 100 -SDComment: Quest support: 30, 272, 5929, 5930. Special Flight Paths for Druid class. -SDCategory: Moonglade -EndScriptData */ - -/* ContentData -npc_bunthen_plainswind -npc_great_bear_spirit -npc_silva_filnaveth -EndContentData */ - -#include "precompiled.h" - -/*###### -## npc_bunthen_plainswind -######*/ - -bool GossipHello_npc_bunthen_plainswind(Player *player, Creature *_Creature) -{ - if(player->getClass() != CLASS_DRUID) - player->SEND_GOSSIP_MENU(4916,_Creature->GetGUID()); - else if(player->GetTeam() != HORDE) - { - if(player->GetQuestStatus(272) == QUEST_STATUS_INCOMPLETE) - player->ADD_GOSSIP_ITEM( 0, "Do you know where I can find Half Pendant of Aquatic Endurance?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2); - - player->SEND_GOSSIP_MENU(4917,_Creature->GetGUID()); - } - else if(player->getClass() == CLASS_DRUID && player->GetTeam() == HORDE) - { - player->ADD_GOSSIP_ITEM( 0, "I'd like to fly to Thunder Bluff.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); - - if(player->GetQuestStatus(30) == QUEST_STATUS_INCOMPLETE) - player->ADD_GOSSIP_ITEM( 0, "Do you know where I can find Half Pendant of Aquatic Endurance?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 3); - - player->SEND_GOSSIP_MENU(4918,_Creature->GetGUID()); - } - return true; -} - -bool GossipSelect_npc_bunthen_plainswind(Player *player, Creature *_Creature, uint32 sender, uint32 action ) -{ - switch(action) - { - case GOSSIP_ACTION_INFO_DEF + 1: - { - player->CLOSE_GOSSIP_MENU(); - if (player->getClass() == CLASS_DRUID && player->GetTeam() == HORDE) - { - std::vector nodes; - - nodes.resize(2); - nodes[0] = 63; // Nighthaven, Moonglade - nodes[1] = 22; // Thunder Bluff, Mulgore - player->ActivateTaxiPathTo(nodes); - } - break; - } - case GOSSIP_ACTION_INFO_DEF + 2: - player->SEND_GOSSIP_MENU(5373,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 3: - player->SEND_GOSSIP_MENU(5376,_Creature->GetGUID()); - break; - } - return true; -} - -/*###### -## npc_great_bear_spirit -######*/ - -#define GOSSIP_BEAR1 "What do you represent, spirit?" -#define GOSSIP_BEAR2 "I seek to understand the importance of strength of the body." -#define GOSSIP_BEAR3 "I seek to understand the importance of strength of the heart." -#define GOSSIP_BEAR4 "I have heard your words, Great Bear Spirit, and I understand. I now seek your blessings to fully learn the way of the Claw." - -bool GossipHello_npc_great_bear_spirit(Player *player, Creature *_Creature) -{ - //ally or horde quest - if (player->GetQuestStatus(5929) == QUEST_STATUS_INCOMPLETE || player->GetQuestStatus(5930) == QUEST_STATUS_INCOMPLETE) - { - player->ADD_GOSSIP_ITEM( 0, GOSSIP_BEAR1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF); - player->SEND_GOSSIP_MENU(4719, _Creature->GetGUID()); - } - else - player->SEND_GOSSIP_MENU(4718, _Creature->GetGUID()); - - return true; -} - -bool GossipSelect_npc_great_bear_spirit(Player *player, Creature *_Creature, uint32 sender, uint32 action ) -{ - switch (action) - { - case GOSSIP_ACTION_INFO_DEF: - player->ADD_GOSSIP_ITEM( 0, GOSSIP_BEAR2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); - player->SEND_GOSSIP_MENU(4721, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 1: - player->ADD_GOSSIP_ITEM( 0, GOSSIP_BEAR3, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2); - player->SEND_GOSSIP_MENU(4733, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 2: - player->ADD_GOSSIP_ITEM( 0, GOSSIP_BEAR4, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 3); - player->SEND_GOSSIP_MENU(4734, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 3: - player->SEND_GOSSIP_MENU(4735, _Creature->GetGUID()); - if (player->GetQuestStatus(5929)==QUEST_STATUS_INCOMPLETE) - player->AreaExploredOrEventHappens(5929); - if (player->GetQuestStatus(5930)==QUEST_STATUS_INCOMPLETE) - player->AreaExploredOrEventHappens(5930); - break; - } - return true; -} - -/*###### -## npc_silva_filnaveth -######*/ - -bool GossipHello_npc_silva_filnaveth(Player *player, Creature *_Creature) -{ - if(player->getClass() != CLASS_DRUID) - player->SEND_GOSSIP_MENU(4913,_Creature->GetGUID()); - else if(player->GetTeam() != ALLIANCE) - { - if(player->GetQuestStatus(30) == QUEST_STATUS_INCOMPLETE) - player->ADD_GOSSIP_ITEM( 0, "Do you know where I can find Half Pendant of Aquatic Agility?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2); - - player->SEND_GOSSIP_MENU(4915,_Creature->GetGUID()); - } - else if(player->getClass() == CLASS_DRUID && player->GetTeam() == ALLIANCE) - { - player->ADD_GOSSIP_ITEM( 0, "I'd like to fly to Rut'theran Village.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); - - if(player->GetQuestStatus(272) == QUEST_STATUS_INCOMPLETE) - player->ADD_GOSSIP_ITEM( 0, "Do you know where I can find Half Pendant of Aquatic Agility?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 3); - - player->SEND_GOSSIP_MENU(4914,_Creature->GetGUID()); - } - return true; -} - -bool GossipSelect_npc_silva_filnaveth(Player *player, Creature *_Creature, uint32 sender, uint32 action ) -{ - switch(action) - { - case GOSSIP_ACTION_INFO_DEF + 1: - { - player->CLOSE_GOSSIP_MENU(); - if (player->getClass() == CLASS_DRUID && player->GetTeam() == ALLIANCE) - { - std::vector nodes; - - nodes.resize(2); - nodes[0] = 62; // Nighthaven, Moonglade - nodes[1] = 27; // Rut'theran Village, Teldrassil - player->ActivateTaxiPathTo(nodes); - } - break; - } - case GOSSIP_ACTION_INFO_DEF + 2: - player->SEND_GOSSIP_MENU(5374,_Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 3: - player->SEND_GOSSIP_MENU(5375,_Creature->GetGUID()); - break; - } - return true; -} - -/*###### -## -######*/ - -void AddSC_moonglade() -{ - Script *newscript; - - newscript = new Script; - newscript->Name="npc_bunthen_plainswind"; - newscript->pGossipHello = &GossipHello_npc_bunthen_plainswind; - newscript->pGossipSelect = &GossipSelect_npc_bunthen_plainswind; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="npc_great_bear_spirit"; - newscript->pGossipHello = &GossipHello_npc_great_bear_spirit; - newscript->pGossipSelect = &GossipSelect_npc_great_bear_spirit; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="npc_silva_filnaveth"; - newscript->pGossipHello = &GossipHello_npc_silva_filnaveth; - newscript->pGossipSelect = &GossipSelect_npc_silva_filnaveth; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Moonglade +SD%Complete: 100 +SDComment: Quest support: 30, 272, 5929, 5930. Special Flight Paths for Druid class. +SDCategory: Moonglade +EndScriptData */ + +/* ContentData +npc_bunthen_plainswind +npc_great_bear_spirit +npc_silva_filnaveth +EndContentData */ + +#include "precompiled.h" + +/*###### +## npc_bunthen_plainswind +######*/ + +bool GossipHello_npc_bunthen_plainswind(Player *player, Creature *_Creature) +{ + if(player->getClass() != CLASS_DRUID) + player->SEND_GOSSIP_MENU(4916,_Creature->GetGUID()); + else if(player->GetTeam() != HORDE) + { + if(player->GetQuestStatus(272) == QUEST_STATUS_INCOMPLETE) + player->ADD_GOSSIP_ITEM( 0, "Do you know where I can find Half Pendant of Aquatic Endurance?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2); + + player->SEND_GOSSIP_MENU(4917,_Creature->GetGUID()); + } + else if(player->getClass() == CLASS_DRUID && player->GetTeam() == HORDE) + { + player->ADD_GOSSIP_ITEM( 0, "I'd like to fly to Thunder Bluff.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); + + if(player->GetQuestStatus(30) == QUEST_STATUS_INCOMPLETE) + player->ADD_GOSSIP_ITEM( 0, "Do you know where I can find Half Pendant of Aquatic Endurance?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 3); + + player->SEND_GOSSIP_MENU(4918,_Creature->GetGUID()); + } + return true; +} + +bool GossipSelect_npc_bunthen_plainswind(Player *player, Creature *_Creature, uint32 sender, uint32 action ) +{ + switch(action) + { + case GOSSIP_ACTION_INFO_DEF + 1: + { + player->CLOSE_GOSSIP_MENU(); + if (player->getClass() == CLASS_DRUID && player->GetTeam() == HORDE) + { + std::vector nodes; + + nodes.resize(2); + nodes[0] = 63; // Nighthaven, Moonglade + nodes[1] = 22; // Thunder Bluff, Mulgore + player->ActivateTaxiPathTo(nodes); + } + break; + } + case GOSSIP_ACTION_INFO_DEF + 2: + player->SEND_GOSSIP_MENU(5373,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 3: + player->SEND_GOSSIP_MENU(5376,_Creature->GetGUID()); + break; + } + return true; +} + +/*###### +## npc_great_bear_spirit +######*/ + +#define GOSSIP_BEAR1 "What do you represent, spirit?" +#define GOSSIP_BEAR2 "I seek to understand the importance of strength of the body." +#define GOSSIP_BEAR3 "I seek to understand the importance of strength of the heart." +#define GOSSIP_BEAR4 "I have heard your words, Great Bear Spirit, and I understand. I now seek your blessings to fully learn the way of the Claw." + +bool GossipHello_npc_great_bear_spirit(Player *player, Creature *_Creature) +{ + //ally or horde quest + if (player->GetQuestStatus(5929) == QUEST_STATUS_INCOMPLETE || player->GetQuestStatus(5930) == QUEST_STATUS_INCOMPLETE) + { + player->ADD_GOSSIP_ITEM( 0, GOSSIP_BEAR1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF); + player->SEND_GOSSIP_MENU(4719, _Creature->GetGUID()); + } + else + player->SEND_GOSSIP_MENU(4718, _Creature->GetGUID()); + + return true; +} + +bool GossipSelect_npc_great_bear_spirit(Player *player, Creature *_Creature, uint32 sender, uint32 action ) +{ + switch (action) + { + case GOSSIP_ACTION_INFO_DEF: + player->ADD_GOSSIP_ITEM( 0, GOSSIP_BEAR2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); + player->SEND_GOSSIP_MENU(4721, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 1: + player->ADD_GOSSIP_ITEM( 0, GOSSIP_BEAR3, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2); + player->SEND_GOSSIP_MENU(4733, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 2: + player->ADD_GOSSIP_ITEM( 0, GOSSIP_BEAR4, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 3); + player->SEND_GOSSIP_MENU(4734, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 3: + player->SEND_GOSSIP_MENU(4735, _Creature->GetGUID()); + if (player->GetQuestStatus(5929)==QUEST_STATUS_INCOMPLETE) + player->AreaExploredOrEventHappens(5929); + if (player->GetQuestStatus(5930)==QUEST_STATUS_INCOMPLETE) + player->AreaExploredOrEventHappens(5930); + break; + } + return true; +} + +/*###### +## npc_silva_filnaveth +######*/ + +bool GossipHello_npc_silva_filnaveth(Player *player, Creature *_Creature) +{ + if(player->getClass() != CLASS_DRUID) + player->SEND_GOSSIP_MENU(4913,_Creature->GetGUID()); + else if(player->GetTeam() != ALLIANCE) + { + if(player->GetQuestStatus(30) == QUEST_STATUS_INCOMPLETE) + player->ADD_GOSSIP_ITEM( 0, "Do you know where I can find Half Pendant of Aquatic Agility?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2); + + player->SEND_GOSSIP_MENU(4915,_Creature->GetGUID()); + } + else if(player->getClass() == CLASS_DRUID && player->GetTeam() == ALLIANCE) + { + player->ADD_GOSSIP_ITEM( 0, "I'd like to fly to Rut'theran Village.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); + + if(player->GetQuestStatus(272) == QUEST_STATUS_INCOMPLETE) + player->ADD_GOSSIP_ITEM( 0, "Do you know where I can find Half Pendant of Aquatic Agility?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 3); + + player->SEND_GOSSIP_MENU(4914,_Creature->GetGUID()); + } + return true; +} + +bool GossipSelect_npc_silva_filnaveth(Player *player, Creature *_Creature, uint32 sender, uint32 action ) +{ + switch(action) + { + case GOSSIP_ACTION_INFO_DEF + 1: + { + player->CLOSE_GOSSIP_MENU(); + if (player->getClass() == CLASS_DRUID && player->GetTeam() == ALLIANCE) + { + std::vector nodes; + + nodes.resize(2); + nodes[0] = 62; // Nighthaven, Moonglade + nodes[1] = 27; // Rut'theran Village, Teldrassil + player->ActivateTaxiPathTo(nodes); + } + break; + } + case GOSSIP_ACTION_INFO_DEF + 2: + player->SEND_GOSSIP_MENU(5374,_Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 3: + player->SEND_GOSSIP_MENU(5375,_Creature->GetGUID()); + break; + } + return true; +} + +/*###### +## +######*/ + +void AddSC_moonglade() +{ + Script *newscript; + + newscript = new Script; + newscript->Name="npc_bunthen_plainswind"; + newscript->pGossipHello = &GossipHello_npc_bunthen_plainswind; + newscript->pGossipSelect = &GossipSelect_npc_bunthen_plainswind; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="npc_great_bear_spirit"; + newscript->pGossipHello = &GossipHello_npc_great_bear_spirit; + newscript->pGossipSelect = &GossipSelect_npc_great_bear_spirit; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="npc_silva_filnaveth"; + newscript->pGossipHello = &GossipHello_npc_silva_filnaveth; + newscript->pGossipSelect = &GossipSelect_npc_silva_filnaveth; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/mulgore/mulgore.cpp b/src/bindings/scripts/scripts/zone/mulgore/mulgore.cpp index 5e10e3500cb..3c7ca5d4b88 100644 --- a/src/bindings/scripts/scripts/zone/mulgore/mulgore.cpp +++ b/src/bindings/scripts/scripts/zone/mulgore/mulgore.cpp @@ -1,64 +1,64 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Mulgore -SD%Complete: 100 -SDComment: Skorn Whitecloud: Just a story if not rewarded for quest -SDCategory: Mulgore -EndScriptData */ - -/* ContentData -npc_skorn_whitecloud -EndContentData */ - -#include "precompiled.h" - -/*###### -# npc_skorn_whitecloud -######*/ - -bool GossipHello_npc_skorn_whitecloud(Player *player, Creature *_Creature) -{ - if (_Creature->isQuestGiver()) - player->PrepareQuestMenu( _Creature->GetGUID() ); - - if (!player->GetQuestRewardStatus(770)) - player->ADD_GOSSIP_ITEM( 0, "Tell me a story, Skorn.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF ); - - player->SEND_GOSSIP_MENU(522,_Creature->GetGUID()); - - return true; -} - -bool GossipSelect_npc_skorn_whitecloud(Player *player, Creature *_Creature, uint32 sender, uint32 action ) -{ - if (action == GOSSIP_ACTION_INFO_DEF) - player->SEND_GOSSIP_MENU(523,_Creature->GetGUID()); - - return true; -} - -void AddSC_mulgore() -{ - Script *newscript; - - newscript = new Script; - newscript->Name="npc_skorn_whitecloud"; - newscript->pGossipHello = &GossipHello_npc_skorn_whitecloud; - newscript->pGossipSelect = &GossipSelect_npc_skorn_whitecloud; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Mulgore +SD%Complete: 100 +SDComment: Skorn Whitecloud: Just a story if not rewarded for quest +SDCategory: Mulgore +EndScriptData */ + +/* ContentData +npc_skorn_whitecloud +EndContentData */ + +#include "precompiled.h" + +/*###### +# npc_skorn_whitecloud +######*/ + +bool GossipHello_npc_skorn_whitecloud(Player *player, Creature *_Creature) +{ + if (_Creature->isQuestGiver()) + player->PrepareQuestMenu( _Creature->GetGUID() ); + + if (!player->GetQuestRewardStatus(770)) + player->ADD_GOSSIP_ITEM( 0, "Tell me a story, Skorn.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF ); + + player->SEND_GOSSIP_MENU(522,_Creature->GetGUID()); + + return true; +} + +bool GossipSelect_npc_skorn_whitecloud(Player *player, Creature *_Creature, uint32 sender, uint32 action ) +{ + if (action == GOSSIP_ACTION_INFO_DEF) + player->SEND_GOSSIP_MENU(523,_Creature->GetGUID()); + + return true; +} + +void AddSC_mulgore() +{ + Script *newscript; + + newscript = new Script; + newscript->Name="npc_skorn_whitecloud"; + newscript->pGossipHello = &GossipHello_npc_skorn_whitecloud; + newscript->pGossipSelect = &GossipSelect_npc_skorn_whitecloud; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/nagrand/nagrand.cpp b/src/bindings/scripts/scripts/zone/nagrand/nagrand.cpp index 2713d2b2d94..e2baa602b21 100644 --- a/src/bindings/scripts/scripts/zone/nagrand/nagrand.cpp +++ b/src/bindings/scripts/scripts/zone/nagrand/nagrand.cpp @@ -1,568 +1,568 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Nagrand -SD%Complete: 90 -SDComment: Quest support: 9849, 9918, 9874, 9991, 10107, 10108, 10044, 10172, 10646, 10085. TextId's unknown for altruis_the_sufferer and greatmother_geyah (npc_text) -SDCategory: Nagrand -EndScriptData */ - -/* ContentData -mob_shattered_rumbler -mob_lump -mob_sunspring_villager -npc_altruis_the_sufferer -npc_greatmother_geyah -npc_lantresor_of_the_blade -npc_creditmarker_visit_with_ancestors -EndContentData */ - -#include "precompiled.h" - -/*###### -## mob_shattered_rumbler - this should be done with ACID -######*/ - -struct MANGOS_DLL_DECL mob_shattered_rumblerAI : public ScriptedAI -{ - bool Spawn; - - mob_shattered_rumblerAI(Creature *c) : ScriptedAI(c) {Reset();} - - void Reset() - { - Spawn = false; - } - - void Aggro(Unit* who) {} - - void SpellHit(Unit *Hitter, const SpellEntry *Spellkind) - { - if(Spellkind->Id == 32001 && !Spawn) - { - float x = m_creature->GetPositionX(); - float y = m_creature->GetPositionY(); - float z = m_creature->GetPositionZ(); - - Hitter->SummonCreature(18181,x+(0.7 * (rand()%30)),y+(rand()%5),z,0,TEMPSUMMON_CORPSE_TIMED_DESPAWN,60000); - Hitter->SummonCreature(18181,x+(rand()%5),y-(rand()%5),z,0,TEMPSUMMON_CORPSE_TIMED_DESPAWN,60000); - Hitter->SummonCreature(18181,x-(rand()%5),y+(0.5 *(rand()%60)),z,0,TEMPSUMMON_CORPSE_TIMED_DESPAWN,60000); - m_creature->setDeathState(CORPSE); - Spawn = true; - } - return; - } -}; -CreatureAI* GetAI_mob_shattered_rumbler(Creature *_Creature) -{ - return new mob_shattered_rumblerAI (_Creature); -} - -/*###### -## mob_lump -######*/ - -#define SPELL_VISUAL_SLEEP 16093 -#define SPELL_SPEAR_THROW 32248 - -#define LUMP_SAY0 "In Nagrand, food hunt ogre!" -#define LUMP_SAY1 "You taste good with maybe a little salt and pepper." - -#define LUMP_DEFEAT "OK, OK! Lump give up!" - -struct MANGOS_DLL_DECL mob_lumpAI : public ScriptedAI -{ - mob_lumpAI(Creature *c) : ScriptedAI(c) - { - bReset = false; - Reset(); - } - - uint32 Reset_Timer; - uint32 Spear_Throw_Timer; - bool bReset; - - void Reset() - { - Reset_Timer = 60000; - Spear_Throw_Timer = 2000; - - m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); - } - - void DamageTaken(Unit *done_by, uint32 & damage) - { - if (done_by->GetTypeId() == TYPEID_PLAYER && (m_creature->GetHealth() - damage)*100 / m_creature->GetMaxHealth() < 30) - { - if (!bReset && ((Player*)done_by)->GetQuestStatus(9918) == QUEST_STATUS_INCOMPLETE) - { - //Take 0 damage - damage = 0; - - ((Player*)done_by)->AttackStop(); - m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); - m_creature->RemoveAllAuras(); - m_creature->DeleteThreatList(); - m_creature->CombatStop(); - m_creature->setFaction(1080); //friendly - m_creature->SetUInt32Value(UNIT_FIELD_BYTES_1, PLAYER_STATE_SIT); - m_creature->Say(LUMP_DEFEAT, LANG_UNIVERSAL, 0); - - bReset = true; - } - } - } - - void Aggro(Unit *who) - { - if (m_creature->HasAura(SPELL_VISUAL_SLEEP,0)) - m_creature->RemoveAura(SPELL_VISUAL_SLEEP,0); - - if (!m_creature->IsStandState()) - m_creature->SetUInt32Value(UNIT_FIELD_BYTES_1, PLAYER_STATE_NONE); - - switch(rand()%2) - { - case 0: - DoSay(LUMP_SAY0,LANG_UNIVERSAL,NULL); - break; - case 1: - DoSay(LUMP_SAY1,LANG_UNIVERSAL,NULL); - break; - } - } - - void UpdateAI(const uint32 diff) - { - //check if we waiting for a reset - if (bReset) - { - if (Reset_Timer < diff) - { - EnterEvadeMode(); - bReset = false; - m_creature->setFaction(1711); //hostile - } - else Reset_Timer -= diff; - } - - //Return since we have no target - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - //Spear_Throw_Timer - if (Spear_Throw_Timer < diff) - { - DoCast(m_creature->getVictim(), SPELL_SPEAR_THROW); - Spear_Throw_Timer = 20000; - }else Spear_Throw_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; - -CreatureAI* GetAI_mob_lump(Creature *_creature) -{ - return new mob_lumpAI(_creature); -} - -bool GossipHello_mob_lump(Player *player, Creature *_Creature) -{ - if (player->GetQuestStatus(9918) == QUEST_STATUS_INCOMPLETE) - player->ADD_GOSSIP_ITEM( 0, "I need answers, ogre!", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF); - - player->SEND_GOSSIP_MENU(9352, _Creature->GetGUID()); - - return true; -} - -bool GossipSelect_mob_lump(Player *player, Creature *_Creature, uint32 sender, uint32 action) -{ - switch (action) - { - case GOSSIP_ACTION_INFO_DEF: - player->ADD_GOSSIP_ITEM( 0, "Why are Boulderfist out this far? You know that this is Kurenai territory.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); - player->SEND_GOSSIP_MENU(9353, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+1: - player->ADD_GOSSIP_ITEM( 0, "And you think you can just eat anything you want? You're obviously trying to eat the Broken of Telaar.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2); - player->SEND_GOSSIP_MENU(9354, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+2: - player->ADD_GOSSIP_ITEM( 0, "This means war, Lump! War I say!", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 3); - player->SEND_GOSSIP_MENU(9355, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+3: - player->SEND_GOSSIP_MENU(9356, _Creature->GetGUID()); - player->TalkedToCreature(18354, _Creature->GetGUID()); - break; - } - return true; -} - -/*#### -# mob_sunspring_villager - should be done with ACID -####*/ - -struct MANGOS_DLL_DECL mob_sunspring_villagerAI : public ScriptedAI -{ - mob_sunspring_villagerAI(Creature *c) : ScriptedAI(c) {Reset();} - - void Reset() - { - m_creature->SetUInt32Value(UNIT_DYNAMIC_FLAGS, 32); - m_creature->SetUInt32Value(UNIT_FIELD_BYTES_1,7); // lay down - } - - void Aggro(Unit *who) {} - - void SpellHit(Unit *caster, const SpellEntry *spell) - { - if(spell->Id == 32146) - { - m_creature->DealDamage(m_creature, m_creature->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); - m_creature->RemoveCorpse(); - } - } -}; -CreatureAI* GetAI_mob_sunspring_villager(Creature *_Creature) -{ - return new mob_sunspring_villagerAI (_Creature); -} - -/*###### -## npc_altruis_the_sufferer -######*/ - -bool GossipHello_npc_altruis_the_sufferer(Player *player, Creature *_Creature) -{ - if (_Creature->isQuestGiver()) - player->PrepareQuestMenu( _Creature->GetGUID() ); - - //gossip before obtaining Survey the Land - if ( player->GetQuestStatus(9991) == QUEST_STATUS_NONE ) - player->ADD_GOSSIP_ITEM( 0, "I see twisted steel and smell sundered earth.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+10); - - //gossip when Survey the Land is incomplete (technically, after the flight) - if (player->GetQuestStatus(9991) == QUEST_STATUS_INCOMPLETE) - player->ADD_GOSSIP_ITEM( 0, "Well...?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+20); - - //wowwiki.com/Varedis - if (player->GetQuestStatus(10646) == QUEST_STATUS_INCOMPLETE) - player->ADD_GOSSIP_ITEM( 0, "[PH] Story about Illidan's Pupil", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+30); - - player->SEND_GOSSIP_MENU(9419, _Creature->GetGUID()); - - return true; -} - -bool GossipSelect_npc_altruis_the_sufferer(Player *player, Creature *_Creature, uint32 sender, uint32 action) -{ - switch (action) - { - case GOSSIP_ACTION_INFO_DEF+10: - player->ADD_GOSSIP_ITEM( 0, "Legion?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 11); - player->SEND_GOSSIP_MENU(9420, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+11: - player->ADD_GOSSIP_ITEM( 0, "And now?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 12); - player->SEND_GOSSIP_MENU(9421, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+12: - player->ADD_GOSSIP_ITEM( 0, "How do you see them now?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 13); - player->SEND_GOSSIP_MENU(9422, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+13: - player->ADD_GOSSIP_ITEM( 0, "Forge camps?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 14); - player->SEND_GOSSIP_MENU(9423, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+14: - player->SEND_GOSSIP_MENU(9424, _Creature->GetGUID()); - break; - - case GOSSIP_ACTION_INFO_DEF+20: - player->ADD_GOSSIP_ITEM( 0, "Ok.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 21); - player->SEND_GOSSIP_MENU(9427, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+21: - player->CLOSE_GOSSIP_MENU(); - player->AreaExploredOrEventHappens(9991); - break; - - case GOSSIP_ACTION_INFO_DEF+30: - player->ADD_GOSSIP_ITEM( 0, "[PH] Story done", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 31); - player->SEND_GOSSIP_MENU(384, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+31: - player->CLOSE_GOSSIP_MENU(); - player->AreaExploredOrEventHappens(10646); - break; - } - return true; -} - -bool QuestAccept_npc_altruis_the_sufferer(Player *player, Creature *creature, Quest const *quest ) -{ - if ( !player->GetQuestRewardStatus(9991) ) //Survey the Land, q-id 9991 - { - player->CLOSE_GOSSIP_MENU(); - - std::vector nodes; - - nodes.resize(2); - nodes[0] = 113; //from - nodes[1] = 114; //end at - player->ActivateTaxiPathTo(nodes); //TaxiPath 532 - } - return true; -} - -/*###### -## npc_greatmother_geyah -######*/ - -//all the textId's for the below is unknown, but i do believe the gossip item texts are proper. -bool GossipHello_npc_greatmother_geyah(Player *player, Creature *_Creature) -{ - if (_Creature->isQuestGiver()) - player->PrepareQuestMenu( _Creature->GetGUID() ); - - if (player->GetQuestStatus(10044) == QUEST_STATUS_INCOMPLETE) - { - player->ADD_GOSSIP_ITEM( 0, "Hello, Greatmother. Garrosh told me that you wanted to speak with me.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); - player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(),_Creature->GetGUID()); - } - else if (player->GetQuestStatus(10172) == QUEST_STATUS_INCOMPLETE) - { - player->ADD_GOSSIP_ITEM( 0, "Garrosh is beyond redemption, Greatmother. I fear that in helping the Mag'har, I have convinced Garrosh that he is unfit to lead.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 10); - player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(),_Creature->GetGUID()); - } - else - - player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(),_Creature->GetGUID()); - - return true; -} - -bool GossipSelect_npc_greatmother_geyah(Player *player, Creature *_Creature, uint32 sender, uint32 action) -{ - switch (action) - { - case GOSSIP_ACTION_INFO_DEF + 1: - player->ADD_GOSSIP_ITEM( 0, "You raised all of the orcs here, Greatmother?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2); - player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 2: - player->ADD_GOSSIP_ITEM( 0, "Do you believe that?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 3); - player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 3: - player->ADD_GOSSIP_ITEM( 0, "What can be done? I have tried many different things. I have done my best to help the people of Nagrand. Each time I have approached Garrosh, he has dismissed me.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 4); - player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 4: - player->ADD_GOSSIP_ITEM( 0, "Left? How can you choose to leave?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 5); - player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 5: - player->ADD_GOSSIP_ITEM( 0, "What is this duty?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 6); - player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 6: - player->ADD_GOSSIP_ITEM( 0, "Is there anything I can do for you, Greatmother?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 7); - player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 7: - player->AreaExploredOrEventHappens(10044); - player->CLOSE_GOSSIP_MENU(); - break; - - case GOSSIP_ACTION_INFO_DEF + 10: - player->ADD_GOSSIP_ITEM( 0, "I have done all that I could, Greatmother. I thank you for your kind words.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 11); - player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 11: - player->ADD_GOSSIP_ITEM( 0, "Greatmother, you are the mother of Durotan?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 12); - player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 12: - player->ADD_GOSSIP_ITEM( 0, "Greatmother, I never had the honor. Durotan died long before my time, but his heroics are known to all on my world. The orcs of Azeroth reside in a place known as Durotar, named after your son. And ... (You take a moment to breathe and think through what you are about to tell the Greatmother.)", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 13); - player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 13: - player->ADD_GOSSIP_ITEM( 0, "It is my Warchief, Greatmother. The leader of my people. From my world. He ... He is the son of Durotan. He is your grandchild.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 14); - player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 14: - player->ADD_GOSSIP_ITEM( 0, "I will return to Azeroth at once, Greatmother.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 15); - player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 15: - player->AreaExploredOrEventHappens(10172); - player->CLOSE_GOSSIP_MENU(); - break; - } - return true; -} - -/*###### -## npc_lantresor_of_the_blade -######*/ - -bool GossipHello_npc_lantresor_of_the_blade(Player *player, Creature *_Creature) -{ - if (_Creature->isQuestGiver()) - player->PrepareQuestMenu( _Creature->GetGUID() ); - - if (player->GetQuestStatus(10107) == QUEST_STATUS_INCOMPLETE || player->GetQuestStatus(10108) == QUEST_STATUS_INCOMPLETE) - player->ADD_GOSSIP_ITEM( 0, "I have killed many of your ogres, Lantresor. I have no fear.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF); - - player->SEND_GOSSIP_MENU(9361, _Creature->GetGUID()); - - return true; -} - -bool GossipSelect_npc_lantresor_of_the_blade(Player *player, Creature *_Creature, uint32 sender, uint32 action) -{ - switch (action) - { - case GOSSIP_ACTION_INFO_DEF: - player->ADD_GOSSIP_ITEM( 0, "Should I know? You look like an orc to me.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); - player->SEND_GOSSIP_MENU(9362, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+1: - player->ADD_GOSSIP_ITEM( 0, "And the other half?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2); - player->SEND_GOSSIP_MENU(9363, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+2: - player->ADD_GOSSIP_ITEM( 0, "I have heard of your kind, but I never thought to see the day when I would meet a half-breed.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 3); - player->SEND_GOSSIP_MENU(9364, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+3: - player->ADD_GOSSIP_ITEM( 0, "My apologies. I did not mean to offend. I am here on behalf of my people.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 4); - player->SEND_GOSSIP_MENU(9365, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+4: - player->ADD_GOSSIP_ITEM( 0, "My people ask that you pull back your Boulderfist ogres and cease all attacks on our territories. In return, we will also pull back our forces.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 5); - player->SEND_GOSSIP_MENU(9366, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+5: - player->ADD_GOSSIP_ITEM( 0, "We will fight you until the end, then, Lantresor. We will not stand idly by as you pillage our towns and kill our people.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 6); - player->SEND_GOSSIP_MENU(9367, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+6: - player->ADD_GOSSIP_ITEM( 0, "What do I need to do?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 7); - player->SEND_GOSSIP_MENU(9368, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+7: - player->SEND_GOSSIP_MENU(9369, _Creature->GetGUID()); - if (player->GetQuestStatus(10107) == QUEST_STATUS_INCOMPLETE) - player->AreaExploredOrEventHappens(10107); - if (player->GetQuestStatus(10108) == QUEST_STATUS_INCOMPLETE) - player->AreaExploredOrEventHappens(10108); - break; - } - return true; -} - -/*###### -## npc_creditmarker_visist_with_ancestors (Quest 10085) -######*/ - -struct MANGOS_DLL_DECL npc_creditmarker_visit_with_ancestorsAI : public ScriptedAI -{ - npc_creditmarker_visit_with_ancestorsAI(Creature* c) : ScriptedAI(c) { Reset(); } - - void Reset() {} - - void Aggro(Unit* who) {} - - void MoveInLineOfSight(Unit *who) - { - if(!who) - return; - - if(who->GetTypeId() == TYPEID_PLAYER) - { - if(((Player*)who)->GetQuestStatus(10085) == QUEST_STATUS_INCOMPLETE) - { - uint32 creditMarkerId = m_creature->GetEntry(); - if((creditMarkerId >= 18840) && (creditMarkerId <= 18843)) - { - // 18840: Sunspring, 18841: Laughing, 18842: Garadar, 18843: Bleeding - if(!((Player*)who)->GetReqKillOrCastCurrentCount(10085, creditMarkerId)) - ((Player*)who)->KilledMonster(creditMarkerId, m_creature->GetGUID()); - } - } - } - } -}; - -CreatureAI* GetAI_npc_creditmarker_visit_with_ancestors(Creature *_Creature) -{ - return new npc_creditmarker_visit_with_ancestorsAI (_Creature); -} - -/*###### -## AddSC -######*/ - -void AddSC_nagrand() -{ - Script *newscript; - - newscript = new Script; - newscript->Name="mob_shattered_rumbler"; - newscript->GetAI = GetAI_mob_shattered_rumbler; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="mob_lump"; - newscript->GetAI = GetAI_mob_lump; - newscript->pGossipHello = &GossipHello_mob_lump; - newscript->pGossipSelect = &GossipSelect_mob_lump; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="mob_sunspring_villager"; - newscript->GetAI = GetAI_mob_sunspring_villager; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="npc_altruis_the_sufferer"; - newscript->pGossipHello = &GossipHello_npc_altruis_the_sufferer; - newscript->pGossipSelect = &GossipSelect_npc_altruis_the_sufferer; - newscript->pQuestAccept = &QuestAccept_npc_altruis_the_sufferer; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="npc_greatmother_geyah"; - newscript->pGossipHello = &GossipHello_npc_greatmother_geyah; - newscript->pGossipSelect = &GossipSelect_npc_greatmother_geyah; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="npc_lantresor_of_the_blade"; - newscript->pGossipHello = &GossipHello_npc_lantresor_of_the_blade; - newscript->pGossipSelect = &GossipSelect_npc_lantresor_of_the_blade; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="npc_creditmarker_visit_with_ancestors"; - newscript->GetAI = GetAI_npc_creditmarker_visit_with_ancestors; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Nagrand +SD%Complete: 90 +SDComment: Quest support: 9849, 9918, 9874, 9991, 10107, 10108, 10044, 10172, 10646, 10085. TextId's unknown for altruis_the_sufferer and greatmother_geyah (npc_text) +SDCategory: Nagrand +EndScriptData */ + +/* ContentData +mob_shattered_rumbler +mob_lump +mob_sunspring_villager +npc_altruis_the_sufferer +npc_greatmother_geyah +npc_lantresor_of_the_blade +npc_creditmarker_visit_with_ancestors +EndContentData */ + +#include "precompiled.h" + +/*###### +## mob_shattered_rumbler - this should be done with ACID +######*/ + +struct MANGOS_DLL_DECL mob_shattered_rumblerAI : public ScriptedAI +{ + bool Spawn; + + mob_shattered_rumblerAI(Creature *c) : ScriptedAI(c) {Reset();} + + void Reset() + { + Spawn = false; + } + + void Aggro(Unit* who) {} + + void SpellHit(Unit *Hitter, const SpellEntry *Spellkind) + { + if(Spellkind->Id == 32001 && !Spawn) + { + float x = m_creature->GetPositionX(); + float y = m_creature->GetPositionY(); + float z = m_creature->GetPositionZ(); + + Hitter->SummonCreature(18181,x+(0.7 * (rand()%30)),y+(rand()%5),z,0,TEMPSUMMON_CORPSE_TIMED_DESPAWN,60000); + Hitter->SummonCreature(18181,x+(rand()%5),y-(rand()%5),z,0,TEMPSUMMON_CORPSE_TIMED_DESPAWN,60000); + Hitter->SummonCreature(18181,x-(rand()%5),y+(0.5 *(rand()%60)),z,0,TEMPSUMMON_CORPSE_TIMED_DESPAWN,60000); + m_creature->setDeathState(CORPSE); + Spawn = true; + } + return; + } +}; +CreatureAI* GetAI_mob_shattered_rumbler(Creature *_Creature) +{ + return new mob_shattered_rumblerAI (_Creature); +} + +/*###### +## mob_lump +######*/ + +#define SPELL_VISUAL_SLEEP 16093 +#define SPELL_SPEAR_THROW 32248 + +#define LUMP_SAY0 "In Nagrand, food hunt ogre!" +#define LUMP_SAY1 "You taste good with maybe a little salt and pepper." + +#define LUMP_DEFEAT "OK, OK! Lump give up!" + +struct MANGOS_DLL_DECL mob_lumpAI : public ScriptedAI +{ + mob_lumpAI(Creature *c) : ScriptedAI(c) + { + bReset = false; + Reset(); + } + + uint32 Reset_Timer; + uint32 Spear_Throw_Timer; + bool bReset; + + void Reset() + { + Reset_Timer = 60000; + Spear_Throw_Timer = 2000; + + m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + } + + void DamageTaken(Unit *done_by, uint32 & damage) + { + if (done_by->GetTypeId() == TYPEID_PLAYER && (m_creature->GetHealth() - damage)*100 / m_creature->GetMaxHealth() < 30) + { + if (!bReset && ((Player*)done_by)->GetQuestStatus(9918) == QUEST_STATUS_INCOMPLETE) + { + //Take 0 damage + damage = 0; + + ((Player*)done_by)->AttackStop(); + m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + m_creature->RemoveAllAuras(); + m_creature->DeleteThreatList(); + m_creature->CombatStop(); + m_creature->setFaction(1080); //friendly + m_creature->SetUInt32Value(UNIT_FIELD_BYTES_1, PLAYER_STATE_SIT); + m_creature->Say(LUMP_DEFEAT, LANG_UNIVERSAL, 0); + + bReset = true; + } + } + } + + void Aggro(Unit *who) + { + if (m_creature->HasAura(SPELL_VISUAL_SLEEP,0)) + m_creature->RemoveAura(SPELL_VISUAL_SLEEP,0); + + if (!m_creature->IsStandState()) + m_creature->SetUInt32Value(UNIT_FIELD_BYTES_1, PLAYER_STATE_NONE); + + switch(rand()%2) + { + case 0: + DoSay(LUMP_SAY0,LANG_UNIVERSAL,NULL); + break; + case 1: + DoSay(LUMP_SAY1,LANG_UNIVERSAL,NULL); + break; + } + } + + void UpdateAI(const uint32 diff) + { + //check if we waiting for a reset + if (bReset) + { + if (Reset_Timer < diff) + { + EnterEvadeMode(); + bReset = false; + m_creature->setFaction(1711); //hostile + } + else Reset_Timer -= diff; + } + + //Return since we have no target + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + //Spear_Throw_Timer + if (Spear_Throw_Timer < diff) + { + DoCast(m_creature->getVictim(), SPELL_SPEAR_THROW); + Spear_Throw_Timer = 20000; + }else Spear_Throw_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; + +CreatureAI* GetAI_mob_lump(Creature *_creature) +{ + return new mob_lumpAI(_creature); +} + +bool GossipHello_mob_lump(Player *player, Creature *_Creature) +{ + if (player->GetQuestStatus(9918) == QUEST_STATUS_INCOMPLETE) + player->ADD_GOSSIP_ITEM( 0, "I need answers, ogre!", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF); + + player->SEND_GOSSIP_MENU(9352, _Creature->GetGUID()); + + return true; +} + +bool GossipSelect_mob_lump(Player *player, Creature *_Creature, uint32 sender, uint32 action) +{ + switch (action) + { + case GOSSIP_ACTION_INFO_DEF: + player->ADD_GOSSIP_ITEM( 0, "Why are Boulderfist out this far? You know that this is Kurenai territory.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); + player->SEND_GOSSIP_MENU(9353, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+1: + player->ADD_GOSSIP_ITEM( 0, "And you think you can just eat anything you want? You're obviously trying to eat the Broken of Telaar.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2); + player->SEND_GOSSIP_MENU(9354, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+2: + player->ADD_GOSSIP_ITEM( 0, "This means war, Lump! War I say!", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 3); + player->SEND_GOSSIP_MENU(9355, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+3: + player->SEND_GOSSIP_MENU(9356, _Creature->GetGUID()); + player->TalkedToCreature(18354, _Creature->GetGUID()); + break; + } + return true; +} + +/*#### +# mob_sunspring_villager - should be done with ACID +####*/ + +struct MANGOS_DLL_DECL mob_sunspring_villagerAI : public ScriptedAI +{ + mob_sunspring_villagerAI(Creature *c) : ScriptedAI(c) {Reset();} + + void Reset() + { + m_creature->SetUInt32Value(UNIT_DYNAMIC_FLAGS, 32); + m_creature->SetUInt32Value(UNIT_FIELD_BYTES_1,7); // lay down + } + + void Aggro(Unit *who) {} + + void SpellHit(Unit *caster, const SpellEntry *spell) + { + if(spell->Id == 32146) + { + m_creature->DealDamage(m_creature, m_creature->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); + m_creature->RemoveCorpse(); + } + } +}; +CreatureAI* GetAI_mob_sunspring_villager(Creature *_Creature) +{ + return new mob_sunspring_villagerAI (_Creature); +} + +/*###### +## npc_altruis_the_sufferer +######*/ + +bool GossipHello_npc_altruis_the_sufferer(Player *player, Creature *_Creature) +{ + if (_Creature->isQuestGiver()) + player->PrepareQuestMenu( _Creature->GetGUID() ); + + //gossip before obtaining Survey the Land + if ( player->GetQuestStatus(9991) == QUEST_STATUS_NONE ) + player->ADD_GOSSIP_ITEM( 0, "I see twisted steel and smell sundered earth.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+10); + + //gossip when Survey the Land is incomplete (technically, after the flight) + if (player->GetQuestStatus(9991) == QUEST_STATUS_INCOMPLETE) + player->ADD_GOSSIP_ITEM( 0, "Well...?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+20); + + //wowwiki.com/Varedis + if (player->GetQuestStatus(10646) == QUEST_STATUS_INCOMPLETE) + player->ADD_GOSSIP_ITEM( 0, "[PH] Story about Illidan's Pupil", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+30); + + player->SEND_GOSSIP_MENU(9419, _Creature->GetGUID()); + + return true; +} + +bool GossipSelect_npc_altruis_the_sufferer(Player *player, Creature *_Creature, uint32 sender, uint32 action) +{ + switch (action) + { + case GOSSIP_ACTION_INFO_DEF+10: + player->ADD_GOSSIP_ITEM( 0, "Legion?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 11); + player->SEND_GOSSIP_MENU(9420, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+11: + player->ADD_GOSSIP_ITEM( 0, "And now?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 12); + player->SEND_GOSSIP_MENU(9421, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+12: + player->ADD_GOSSIP_ITEM( 0, "How do you see them now?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 13); + player->SEND_GOSSIP_MENU(9422, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+13: + player->ADD_GOSSIP_ITEM( 0, "Forge camps?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 14); + player->SEND_GOSSIP_MENU(9423, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+14: + player->SEND_GOSSIP_MENU(9424, _Creature->GetGUID()); + break; + + case GOSSIP_ACTION_INFO_DEF+20: + player->ADD_GOSSIP_ITEM( 0, "Ok.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 21); + player->SEND_GOSSIP_MENU(9427, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+21: + player->CLOSE_GOSSIP_MENU(); + player->AreaExploredOrEventHappens(9991); + break; + + case GOSSIP_ACTION_INFO_DEF+30: + player->ADD_GOSSIP_ITEM( 0, "[PH] Story done", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 31); + player->SEND_GOSSIP_MENU(384, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+31: + player->CLOSE_GOSSIP_MENU(); + player->AreaExploredOrEventHappens(10646); + break; + } + return true; +} + +bool QuestAccept_npc_altruis_the_sufferer(Player *player, Creature *creature, Quest const *quest ) +{ + if ( !player->GetQuestRewardStatus(9991) ) //Survey the Land, q-id 9991 + { + player->CLOSE_GOSSIP_MENU(); + + std::vector nodes; + + nodes.resize(2); + nodes[0] = 113; //from + nodes[1] = 114; //end at + player->ActivateTaxiPathTo(nodes); //TaxiPath 532 + } + return true; +} + +/*###### +## npc_greatmother_geyah +######*/ + +//all the textId's for the below is unknown, but i do believe the gossip item texts are proper. +bool GossipHello_npc_greatmother_geyah(Player *player, Creature *_Creature) +{ + if (_Creature->isQuestGiver()) + player->PrepareQuestMenu( _Creature->GetGUID() ); + + if (player->GetQuestStatus(10044) == QUEST_STATUS_INCOMPLETE) + { + player->ADD_GOSSIP_ITEM( 0, "Hello, Greatmother. Garrosh told me that you wanted to speak with me.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); + player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(),_Creature->GetGUID()); + } + else if (player->GetQuestStatus(10172) == QUEST_STATUS_INCOMPLETE) + { + player->ADD_GOSSIP_ITEM( 0, "Garrosh is beyond redemption, Greatmother. I fear that in helping the Mag'har, I have convinced Garrosh that he is unfit to lead.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 10); + player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(),_Creature->GetGUID()); + } + else + + player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(),_Creature->GetGUID()); + + return true; +} + +bool GossipSelect_npc_greatmother_geyah(Player *player, Creature *_Creature, uint32 sender, uint32 action) +{ + switch (action) + { + case GOSSIP_ACTION_INFO_DEF + 1: + player->ADD_GOSSIP_ITEM( 0, "You raised all of the orcs here, Greatmother?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2); + player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 2: + player->ADD_GOSSIP_ITEM( 0, "Do you believe that?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 3); + player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 3: + player->ADD_GOSSIP_ITEM( 0, "What can be done? I have tried many different things. I have done my best to help the people of Nagrand. Each time I have approached Garrosh, he has dismissed me.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 4); + player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 4: + player->ADD_GOSSIP_ITEM( 0, "Left? How can you choose to leave?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 5); + player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 5: + player->ADD_GOSSIP_ITEM( 0, "What is this duty?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 6); + player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 6: + player->ADD_GOSSIP_ITEM( 0, "Is there anything I can do for you, Greatmother?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 7); + player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 7: + player->AreaExploredOrEventHappens(10044); + player->CLOSE_GOSSIP_MENU(); + break; + + case GOSSIP_ACTION_INFO_DEF + 10: + player->ADD_GOSSIP_ITEM( 0, "I have done all that I could, Greatmother. I thank you for your kind words.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 11); + player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 11: + player->ADD_GOSSIP_ITEM( 0, "Greatmother, you are the mother of Durotan?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 12); + player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 12: + player->ADD_GOSSIP_ITEM( 0, "Greatmother, I never had the honor. Durotan died long before my time, but his heroics are known to all on my world. The orcs of Azeroth reside in a place known as Durotar, named after your son. And ... (You take a moment to breathe and think through what you are about to tell the Greatmother.)", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 13); + player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 13: + player->ADD_GOSSIP_ITEM( 0, "It is my Warchief, Greatmother. The leader of my people. From my world. He ... He is the son of Durotan. He is your grandchild.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 14); + player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 14: + player->ADD_GOSSIP_ITEM( 0, "I will return to Azeroth at once, Greatmother.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 15); + player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 15: + player->AreaExploredOrEventHappens(10172); + player->CLOSE_GOSSIP_MENU(); + break; + } + return true; +} + +/*###### +## npc_lantresor_of_the_blade +######*/ + +bool GossipHello_npc_lantresor_of_the_blade(Player *player, Creature *_Creature) +{ + if (_Creature->isQuestGiver()) + player->PrepareQuestMenu( _Creature->GetGUID() ); + + if (player->GetQuestStatus(10107) == QUEST_STATUS_INCOMPLETE || player->GetQuestStatus(10108) == QUEST_STATUS_INCOMPLETE) + player->ADD_GOSSIP_ITEM( 0, "I have killed many of your ogres, Lantresor. I have no fear.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF); + + player->SEND_GOSSIP_MENU(9361, _Creature->GetGUID()); + + return true; +} + +bool GossipSelect_npc_lantresor_of_the_blade(Player *player, Creature *_Creature, uint32 sender, uint32 action) +{ + switch (action) + { + case GOSSIP_ACTION_INFO_DEF: + player->ADD_GOSSIP_ITEM( 0, "Should I know? You look like an orc to me.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); + player->SEND_GOSSIP_MENU(9362, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+1: + player->ADD_GOSSIP_ITEM( 0, "And the other half?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2); + player->SEND_GOSSIP_MENU(9363, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+2: + player->ADD_GOSSIP_ITEM( 0, "I have heard of your kind, but I never thought to see the day when I would meet a half-breed.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 3); + player->SEND_GOSSIP_MENU(9364, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+3: + player->ADD_GOSSIP_ITEM( 0, "My apologies. I did not mean to offend. I am here on behalf of my people.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 4); + player->SEND_GOSSIP_MENU(9365, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+4: + player->ADD_GOSSIP_ITEM( 0, "My people ask that you pull back your Boulderfist ogres and cease all attacks on our territories. In return, we will also pull back our forces.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 5); + player->SEND_GOSSIP_MENU(9366, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+5: + player->ADD_GOSSIP_ITEM( 0, "We will fight you until the end, then, Lantresor. We will not stand idly by as you pillage our towns and kill our people.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 6); + player->SEND_GOSSIP_MENU(9367, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+6: + player->ADD_GOSSIP_ITEM( 0, "What do I need to do?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 7); + player->SEND_GOSSIP_MENU(9368, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+7: + player->SEND_GOSSIP_MENU(9369, _Creature->GetGUID()); + if (player->GetQuestStatus(10107) == QUEST_STATUS_INCOMPLETE) + player->AreaExploredOrEventHappens(10107); + if (player->GetQuestStatus(10108) == QUEST_STATUS_INCOMPLETE) + player->AreaExploredOrEventHappens(10108); + break; + } + return true; +} + +/*###### +## npc_creditmarker_visist_with_ancestors (Quest 10085) +######*/ + +struct MANGOS_DLL_DECL npc_creditmarker_visit_with_ancestorsAI : public ScriptedAI +{ + npc_creditmarker_visit_with_ancestorsAI(Creature* c) : ScriptedAI(c) { Reset(); } + + void Reset() {} + + void Aggro(Unit* who) {} + + void MoveInLineOfSight(Unit *who) + { + if(!who) + return; + + if(who->GetTypeId() == TYPEID_PLAYER) + { + if(((Player*)who)->GetQuestStatus(10085) == QUEST_STATUS_INCOMPLETE) + { + uint32 creditMarkerId = m_creature->GetEntry(); + if((creditMarkerId >= 18840) && (creditMarkerId <= 18843)) + { + // 18840: Sunspring, 18841: Laughing, 18842: Garadar, 18843: Bleeding + if(!((Player*)who)->GetReqKillOrCastCurrentCount(10085, creditMarkerId)) + ((Player*)who)->KilledMonster(creditMarkerId, m_creature->GetGUID()); + } + } + } + } +}; + +CreatureAI* GetAI_npc_creditmarker_visit_with_ancestors(Creature *_Creature) +{ + return new npc_creditmarker_visit_with_ancestorsAI (_Creature); +} + +/*###### +## AddSC +######*/ + +void AddSC_nagrand() +{ + Script *newscript; + + newscript = new Script; + newscript->Name="mob_shattered_rumbler"; + newscript->GetAI = GetAI_mob_shattered_rumbler; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="mob_lump"; + newscript->GetAI = GetAI_mob_lump; + newscript->pGossipHello = &GossipHello_mob_lump; + newscript->pGossipSelect = &GossipSelect_mob_lump; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="mob_sunspring_villager"; + newscript->GetAI = GetAI_mob_sunspring_villager; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="npc_altruis_the_sufferer"; + newscript->pGossipHello = &GossipHello_npc_altruis_the_sufferer; + newscript->pGossipSelect = &GossipSelect_npc_altruis_the_sufferer; + newscript->pQuestAccept = &QuestAccept_npc_altruis_the_sufferer; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="npc_greatmother_geyah"; + newscript->pGossipHello = &GossipHello_npc_greatmother_geyah; + newscript->pGossipSelect = &GossipSelect_npc_greatmother_geyah; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="npc_lantresor_of_the_blade"; + newscript->pGossipHello = &GossipHello_npc_lantresor_of_the_blade; + newscript->pGossipSelect = &GossipSelect_npc_lantresor_of_the_blade; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="npc_creditmarker_visit_with_ancestors"; + newscript->GetAI = GetAI_npc_creditmarker_visit_with_ancestors; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/naxxramas/boss_anubrekhan.cpp b/src/bindings/scripts/scripts/zone/naxxramas/boss_anubrekhan.cpp index d2dbd710cc9..be8562f8986 100644 --- a/src/bindings/scripts/scripts/zone/naxxramas/boss_anubrekhan.cpp +++ b/src/bindings/scripts/scripts/zone/naxxramas/boss_anubrekhan.cpp @@ -1,215 +1,215 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Anubrekhan -SD%Complete: 100 -SDComment: -SDCategory: Naxxramas -EndScriptData */ - -#include "precompiled.h" - -#define SAY_AGGRO1 "Just a little taste..." -#define SAY_AGGRO2 "There is no way out." -#define SAY_AGGRO3 "Yes, Run! It makes the blood pump faster!" -#define SAY_GREET "Ahh... welcome to my parlor" -#define SAY_TAUNT1 "I hear little hearts beating. Yesss... beating faster now. Soon the beating will stop." -#define SAY_TAUNT2 "Where to go? What to do? So many choices that all end in pain, end in death." -#define SAY_TAUNT3 "Which one shall I eat first? So difficult to choose... the all smell so delicious." -#define SAY_TAUNT4 "Closer now... tasty morsels. I've been too long without food. Without blood to drink." -#define SAY_SLAY "Shh... it will all be over soon." - -#define SOUND_AGGRO1 8785 -#define SOUND_AGGRO2 8786 -#define SOUND_AGGRO3 8787 -#define SOUND_GREET 8788 -#define SOUND_TAUNT1 8790 -#define SOUND_TAUNT2 8791 -#define SOUND_TAUNT3 8792 -#define SOUND_TAUNT4 8793 -#define SOUND_SLAY 8789 - -#define SPELL_IMPALE 28783 //May be wrong spell id. Causes more dmg than I expect -#define SPELL_LOCUSTSWARM 28785 //This is a self buff that triggers the dmg debuff -#define SPELL_SUMMONGUARD 29508 //Summons 1 crypt guard at targeted location - -#define SPELL_SELF_SPAWN_5 29105 //This spawns 5 corpse scarabs ontop of us (most likely the player casts this on death) -#define SPELL_SELF_SPAWN_10 28864 //This is used by the crypt guards when they die - -struct MANGOS_DLL_DECL boss_anubrekhanAI : public ScriptedAI -{ - boss_anubrekhanAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 Impale_Timer; - uint32 LocustSwarm_Timer; - uint32 Summon_Timer; - bool HasTaunted; - - void Reset() - { - Impale_Timer = 15000; //15 seconds - LocustSwarm_Timer = 80000 + (rand()%40000); //Random time between 80 seconds and 2 minutes for initial cast - Summon_Timer = LocustSwarm_Timer + 45000; //45 seconds after initial locust swarm - } - - void KilledUnit(Unit* Victim) - { - //Force the player to spawn corpse scarabs via spell - Victim->CastSpell(Victim, SPELL_SELF_SPAWN_5, true); - - if (rand()%5) - return; - - DoYell(SAY_SLAY, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_SLAY); - } - - void Aggro(Unit *who) - { - switch(rand()%3) - { - case 0: - DoYell(SAY_AGGRO1, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_AGGRO1); - break; - case 1: - DoYell(SAY_AGGRO2, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_AGGRO2); - break; - case 2: - DoYell(SAY_AGGRO3, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_AGGRO3); - break; - } - } - - void MoveInLineOfSight(Unit *who) - { - if (!who || m_creature->getVictim()) - return; - - if (who->isTargetableForAttack() && who->isInAccessablePlaceFor(m_creature) && m_creature->IsHostileTo(who)) - { - float attackRadius = m_creature->GetAttackDistance(who); - if (m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->GetDistanceZ(who) <= CREATURE_Z_ATTACK_RANGE && m_creature->IsWithinLOSInMap(who)) - { - if(who->HasStealthAura()) - who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); - - //Begin melee attack if we are within range - DoStartAttackAndMovement(who); - - if (!InCombat) - { - switch(rand()%3) - { - case 0: - DoYell(SAY_AGGRO1, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_AGGRO1); - break; - case 1: - DoYell(SAY_AGGRO2, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_AGGRO2); - break; - case 2: - DoYell(SAY_AGGRO3, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_AGGRO3); - break; - } - } - } - else if (!HasTaunted && m_creature->IsWithinDistInMap(who, 60.0f)) - { - switch(rand()%5) - { - case 0: - DoYell(SAY_TAUNT1, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_TAUNT1); - break; - case 1: - DoYell(SAY_TAUNT2, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_TAUNT2); - break; - case 2: - DoYell(SAY_TAUNT3, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_TAUNT3); - break; - case 3: - DoYell(SAY_TAUNT4, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_TAUNT4); - break; - case 4: - DoYell(SAY_GREET, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_GREET); - break; - } - HasTaunted = true; - } - } - } - - void UpdateAI(const uint32 diff) - { - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - //Impale_Timer - if (Impale_Timer < diff) - { - //Cast Impale on a random target - //Do NOT cast it when we are afflicted by locust swarm - if (!m_creature->HasAura(SPELL_LOCUSTSWARM,1)) - { - Unit* target = NULL; - - target = SelectUnit(SELECT_TARGET_RANDOM,0); - if (target)DoCast(target,SPELL_IMPALE); - } - - Impale_Timer = 15000; - }else Impale_Timer -= diff; - - //LocustSwarm_Timer - if (LocustSwarm_Timer < diff) - { - DoCast(m_creature, SPELL_LOCUSTSWARM); - LocustSwarm_Timer = 90000; - }else LocustSwarm_Timer -= diff; - - //Summon_Timer - if (Summon_Timer < diff) - { - DoCast(m_creature, SPELL_SUMMONGUARD); - Summon_Timer = 45000; - }else Summon_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; -CreatureAI* GetAI_boss_anubrekhan(Creature *_Creature) -{ - return new boss_anubrekhanAI (_Creature); -} - -void AddSC_boss_anubrekhan() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_anubrekhan"; - newscript->GetAI = GetAI_boss_anubrekhan; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Anubrekhan +SD%Complete: 100 +SDComment: +SDCategory: Naxxramas +EndScriptData */ + +#include "precompiled.h" + +#define SAY_AGGRO1 "Just a little taste..." +#define SAY_AGGRO2 "There is no way out." +#define SAY_AGGRO3 "Yes, Run! It makes the blood pump faster!" +#define SAY_GREET "Ahh... welcome to my parlor" +#define SAY_TAUNT1 "I hear little hearts beating. Yesss... beating faster now. Soon the beating will stop." +#define SAY_TAUNT2 "Where to go? What to do? So many choices that all end in pain, end in death." +#define SAY_TAUNT3 "Which one shall I eat first? So difficult to choose... the all smell so delicious." +#define SAY_TAUNT4 "Closer now... tasty morsels. I've been too long without food. Without blood to drink." +#define SAY_SLAY "Shh... it will all be over soon." + +#define SOUND_AGGRO1 8785 +#define SOUND_AGGRO2 8786 +#define SOUND_AGGRO3 8787 +#define SOUND_GREET 8788 +#define SOUND_TAUNT1 8790 +#define SOUND_TAUNT2 8791 +#define SOUND_TAUNT3 8792 +#define SOUND_TAUNT4 8793 +#define SOUND_SLAY 8789 + +#define SPELL_IMPALE 28783 //May be wrong spell id. Causes more dmg than I expect +#define SPELL_LOCUSTSWARM 28785 //This is a self buff that triggers the dmg debuff +#define SPELL_SUMMONGUARD 29508 //Summons 1 crypt guard at targeted location + +#define SPELL_SELF_SPAWN_5 29105 //This spawns 5 corpse scarabs ontop of us (most likely the player casts this on death) +#define SPELL_SELF_SPAWN_10 28864 //This is used by the crypt guards when they die + +struct MANGOS_DLL_DECL boss_anubrekhanAI : public ScriptedAI +{ + boss_anubrekhanAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 Impale_Timer; + uint32 LocustSwarm_Timer; + uint32 Summon_Timer; + bool HasTaunted; + + void Reset() + { + Impale_Timer = 15000; //15 seconds + LocustSwarm_Timer = 80000 + (rand()%40000); //Random time between 80 seconds and 2 minutes for initial cast + Summon_Timer = LocustSwarm_Timer + 45000; //45 seconds after initial locust swarm + } + + void KilledUnit(Unit* Victim) + { + //Force the player to spawn corpse scarabs via spell + Victim->CastSpell(Victim, SPELL_SELF_SPAWN_5, true); + + if (rand()%5) + return; + + DoYell(SAY_SLAY, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_SLAY); + } + + void Aggro(Unit *who) + { + switch(rand()%3) + { + case 0: + DoYell(SAY_AGGRO1, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_AGGRO1); + break; + case 1: + DoYell(SAY_AGGRO2, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_AGGRO2); + break; + case 2: + DoYell(SAY_AGGRO3, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_AGGRO3); + break; + } + } + + void MoveInLineOfSight(Unit *who) + { + if (!m_creature->getVictim() && who->isTargetableForAttack() && who->isInAccessablePlaceFor(m_creature) && m_creature->IsHostileTo(who)) + { + if (!m_creature->canFly() && m_creature->GetDistanceZ(who) > CREATURE_Z_ATTACK_RANGE) + return; + + float attackRadius = m_creature->GetAttackDistance(who); + if (m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->IsWithinLOSInMap(who)) + { + if(who->HasStealthAura()) + who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); + + //Begin melee attack if we are within range + DoStartAttackAndMovement(who); + + if (!InCombat) + { + switch(rand()%3) + { + case 0: + DoYell(SAY_AGGRO1, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_AGGRO1); + break; + case 1: + DoYell(SAY_AGGRO2, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_AGGRO2); + break; + case 2: + DoYell(SAY_AGGRO3, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_AGGRO3); + break; + } + } + } + else if (!HasTaunted && m_creature->IsWithinDistInMap(who, 60.0f)) + { + switch(rand()%5) + { + case 0: + DoYell(SAY_TAUNT1, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_TAUNT1); + break; + case 1: + DoYell(SAY_TAUNT2, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_TAUNT2); + break; + case 2: + DoYell(SAY_TAUNT3, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_TAUNT3); + break; + case 3: + DoYell(SAY_TAUNT4, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_TAUNT4); + break; + case 4: + DoYell(SAY_GREET, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_GREET); + break; + } + HasTaunted = true; + } + } + } + + void UpdateAI(const uint32 diff) + { + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + //Impale_Timer + if (Impale_Timer < diff) + { + //Cast Impale on a random target + //Do NOT cast it when we are afflicted by locust swarm + if (!m_creature->HasAura(SPELL_LOCUSTSWARM,1)) + { + Unit* target = NULL; + + target = SelectUnit(SELECT_TARGET_RANDOM,0); + if (target)DoCast(target,SPELL_IMPALE); + } + + Impale_Timer = 15000; + }else Impale_Timer -= diff; + + //LocustSwarm_Timer + if (LocustSwarm_Timer < diff) + { + DoCast(m_creature, SPELL_LOCUSTSWARM); + LocustSwarm_Timer = 90000; + }else LocustSwarm_Timer -= diff; + + //Summon_Timer + if (Summon_Timer < diff) + { + DoCast(m_creature, SPELL_SUMMONGUARD); + Summon_Timer = 45000; + }else Summon_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; +CreatureAI* GetAI_boss_anubrekhan(Creature *_Creature) +{ + return new boss_anubrekhanAI (_Creature); +} + +void AddSC_boss_anubrekhan() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_anubrekhan"; + newscript->GetAI = GetAI_boss_anubrekhan; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/naxxramas/boss_faerlina.cpp b/src/bindings/scripts/scripts/zone/naxxramas/boss_faerlina.cpp index 3faf9ad9634..6dd6faa906f 100644 --- a/src/bindings/scripts/scripts/zone/naxxramas/boss_faerlina.cpp +++ b/src/bindings/scripts/scripts/zone/naxxramas/boss_faerlina.cpp @@ -1,202 +1,202 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Faerlina -SD%Complete: 50 -SDComment: Without Mindcontrol boss cannot be defeated -SDCategory: Naxxramas -EndScriptData */ - -#include "precompiled.h" - -#define SAY_GREET "Your old lives, your mortal desires, mean nothing. You are acolytes of the master now, and you will serve the cause without question! The greatest glory is to die in the master's service!" -#define SAY_AGGRO1 "Slay them in the master's name!" -#define SAY_AGGRO2 "You cannot hide from me!" -#define SAY_AGGRO3 "Kneel before me, worm!" -#define SAY_AGGRO4 "Run while you still can!" -#define SAY_SLAY1 "You have failed!" -#define SAY_SLAY2 "Pathetic wretch!" -#define SAY_DEATH "The master... will avenge me!" -#define SAY_RANDOM_AGGRO "???" - -#define SOUND_GREET 8799 -#define SOUND_AGGRO1 8794 -#define SOUND_AGGRO2 8795 -#define SOUND_AGGRO3 8796 -#define SOUND_AGGRO4 8797 -#define SOUND_SLAY1 8800 -#define SOUND_SLAY2 8801 -#define SOUND_DEATH 8798 -#define SOUND_RANDOM_AGGRO 8955 - -#define SPELL_POSIONBOLT_VOLLEY 28796 -#define SPELL_RAINOFFIRE 28794 //Not sure if targeted AoEs work if casted directly upon a player -#define SPELL_ENRAGE 26527 - -struct MANGOS_DLL_DECL boss_faerlinaAI : public ScriptedAI -{ - boss_faerlinaAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 PoisonBoltVolley_Timer; - uint32 RainOfFire_Timer; - uint32 Enrage_Timer; - bool HasTaunted; - - void Reset() - { - PoisonBoltVolley_Timer = 8000; - RainOfFire_Timer = 16000; - Enrage_Timer = 60000; - HasTaunted = false; - } - - void Aggro(Unit *who) - { - switch (rand()%4) - { - case 0: - DoYell(SAY_AGGRO1,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_AGGRO1); - break; - case 1: - DoYell(SAY_AGGRO2,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_AGGRO2); - break; - case 2: - DoYell(SAY_AGGRO3,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_AGGRO3); - break; - case 3: - DoYell(SAY_AGGRO4,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_AGGRO4); - break; - } - } - - void MoveInLineOfSight(Unit *who) - { - if (!who || m_creature->getVictim()) - return; - - if (who->isTargetableForAttack() && who->isInAccessablePlaceFor(m_creature) && m_creature->IsHostileTo(who)) - { - float attackRadius = m_creature->GetAttackDistance(who); - if (m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->GetDistanceZ(who) <= CREATURE_Z_ATTACK_RANGE) - { - if(who->HasStealthAura()) - who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); - - DoStartAttackAndMovement(who); - //Say our dialog on initial aggro - if (!InCombat) - { - switch (rand()%4) - { - case 0: - DoYell(SAY_AGGRO1,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_AGGRO1); - break; - case 1: - DoYell(SAY_AGGRO2,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_AGGRO2); - break; - case 2: - DoYell(SAY_AGGRO3,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_AGGRO3); - break; - case 3: - DoYell(SAY_AGGRO4,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_AGGRO4); - break; - } - } - } - else if (!HasTaunted && m_creature->IsWithinDistInMap(who, 60.0f)) - { - DoYell(SAY_GREET, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature,SOUND_GREET); - HasTaunted = true; - } - } - } - - void KilledUnit(Unit* victim) - { - switch (rand()%2) - { - case 0: - DoYell(SAY_SLAY1,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_SLAY1); - break; - case 1: - DoYell(SAY_SLAY2,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_SLAY2); - break; - } - } - - void JustDied(Unit* Killer) - { - DoYell(SAY_DEATH,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_DEATH); - } - - void UpdateAI(const uint32 diff) - { - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - //PoisonBoltVolley_Timer - if (PoisonBoltVolley_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_POSIONBOLT_VOLLEY); - PoisonBoltVolley_Timer = 11000; - }else PoisonBoltVolley_Timer -= diff; - - //RainOfFire_Timer - if (RainOfFire_Timer < diff) - { - Unit* target = NULL; - target = SelectUnit(SELECT_TARGET_RANDOM,0); - if (target) DoCast(target,SPELL_RAINOFFIRE); - - RainOfFire_Timer = 16000; - }else RainOfFire_Timer -= diff; - - //Enrage_Timer - if (Enrage_Timer < diff) - { - DoCast(m_creature,SPELL_ENRAGE); - Enrage_Timer = 61000; - }else Enrage_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; -CreatureAI* GetAI_boss_faerlina(Creature *_Creature) -{ - return new boss_faerlinaAI (_Creature); -} - -void AddSC_boss_faerlina() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_faerlina"; - newscript->GetAI = GetAI_boss_faerlina; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Faerlina +SD%Complete: 50 +SDComment: Without Mindcontrol boss cannot be defeated +SDCategory: Naxxramas +EndScriptData */ + +#include "precompiled.h" + +#define SAY_GREET "Your old lives, your mortal desires, mean nothing. You are acolytes of the master now, and you will serve the cause without question! The greatest glory is to die in the master's service!" +#define SAY_AGGRO1 "Slay them in the master's name!" +#define SAY_AGGRO2 "You cannot hide from me!" +#define SAY_AGGRO3 "Kneel before me, worm!" +#define SAY_AGGRO4 "Run while you still can!" +#define SAY_SLAY1 "You have failed!" +#define SAY_SLAY2 "Pathetic wretch!" +#define SAY_DEATH "The master... will avenge me!" +#define SAY_RANDOM_AGGRO "???" + +#define SOUND_GREET 8799 +#define SOUND_AGGRO1 8794 +#define SOUND_AGGRO2 8795 +#define SOUND_AGGRO3 8796 +#define SOUND_AGGRO4 8797 +#define SOUND_SLAY1 8800 +#define SOUND_SLAY2 8801 +#define SOUND_DEATH 8798 +#define SOUND_RANDOM_AGGRO 8955 + +#define SPELL_POSIONBOLT_VOLLEY 28796 +#define SPELL_RAINOFFIRE 28794 //Not sure if targeted AoEs work if casted directly upon a player +#define SPELL_ENRAGE 26527 + +struct MANGOS_DLL_DECL boss_faerlinaAI : public ScriptedAI +{ + boss_faerlinaAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 PoisonBoltVolley_Timer; + uint32 RainOfFire_Timer; + uint32 Enrage_Timer; + bool HasTaunted; + + void Reset() + { + PoisonBoltVolley_Timer = 8000; + RainOfFire_Timer = 16000; + Enrage_Timer = 60000; + HasTaunted = false; + } + + void Aggro(Unit *who) + { + switch (rand()%4) + { + case 0: + DoYell(SAY_AGGRO1,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_AGGRO1); + break; + case 1: + DoYell(SAY_AGGRO2,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_AGGRO2); + break; + case 2: + DoYell(SAY_AGGRO3,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_AGGRO3); + break; + case 3: + DoYell(SAY_AGGRO4,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_AGGRO4); + break; + } + } + + void MoveInLineOfSight(Unit *who) + { + if (!m_creature->getVictim() && who->isTargetableForAttack() && who->isInAccessablePlaceFor(m_creature) && m_creature->IsHostileTo(who)) + { + if (!m_creature->canFly() && m_creature->GetDistanceZ(who) > CREATURE_Z_ATTACK_RANGE) + return; + + float attackRadius = m_creature->GetAttackDistance(who); + if (m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->IsWithinLOSInMap(who)) + { + if(who->HasStealthAura()) + who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); + + DoStartAttackAndMovement(who); + //Say our dialog on initial aggro + if (!InCombat) + { + switch (rand()%4) + { + case 0: + DoYell(SAY_AGGRO1,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_AGGRO1); + break; + case 1: + DoYell(SAY_AGGRO2,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_AGGRO2); + break; + case 2: + DoYell(SAY_AGGRO3,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_AGGRO3); + break; + case 3: + DoYell(SAY_AGGRO4,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_AGGRO4); + break; + } + } + } + else if (!HasTaunted && m_creature->IsWithinDistInMap(who, 60.0f)) + { + DoYell(SAY_GREET, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature,SOUND_GREET); + HasTaunted = true; + } + } + } + + void KilledUnit(Unit* victim) + { + switch (rand()%2) + { + case 0: + DoYell(SAY_SLAY1,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_SLAY1); + break; + case 1: + DoYell(SAY_SLAY2,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_SLAY2); + break; + } + } + + void JustDied(Unit* Killer) + { + DoYell(SAY_DEATH,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_DEATH); + } + + void UpdateAI(const uint32 diff) + { + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + //PoisonBoltVolley_Timer + if (PoisonBoltVolley_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_POSIONBOLT_VOLLEY); + PoisonBoltVolley_Timer = 11000; + }else PoisonBoltVolley_Timer -= diff; + + //RainOfFire_Timer + if (RainOfFire_Timer < diff) + { + Unit* target = NULL; + target = SelectUnit(SELECT_TARGET_RANDOM,0); + if (target) DoCast(target,SPELL_RAINOFFIRE); + + RainOfFire_Timer = 16000; + }else RainOfFire_Timer -= diff; + + //Enrage_Timer + if (Enrage_Timer < diff) + { + DoCast(m_creature,SPELL_ENRAGE); + Enrage_Timer = 61000; + }else Enrage_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; +CreatureAI* GetAI_boss_faerlina(Creature *_Creature) +{ + return new boss_faerlinaAI (_Creature); +} + +void AddSC_boss_faerlina() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_faerlina"; + newscript->GetAI = GetAI_boss_faerlina; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/naxxramas/boss_feugen.cpp b/src/bindings/scripts/scripts/zone/naxxramas/boss_feugen.cpp index fd03b1757f5..facfa2e29fc 100644 --- a/src/bindings/scripts/scripts/zone/naxxramas/boss_feugen.cpp +++ b/src/bindings/scripts/scripts/zone/naxxramas/boss_feugen.cpp @@ -1,33 +1,33 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Feugen -SD%Complete: 0 -SDComment: Merge with Thaddius -SDCategory: Naxxramas -EndScriptData */ - -//Feugen -//8801 aggro Feed you to master! -//8804 slay Feugen make master happy! -//8803 death No... more... Feugen... - -#include "precompiled.h" - -#define SPELL_WARSTOMP 28125 -#define SPELL_MANABURN 28135 -#define SPELL_CHAIN_LIGHTNING 28900 +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Feugen +SD%Complete: 0 +SDComment: Merge with Thaddius +SDCategory: Naxxramas +EndScriptData */ + +//Feugen +//8801 aggro Feed you to master! +//8804 slay Feugen make master happy! +//8803 death No... more... Feugen... + +#include "precompiled.h" + +#define SPELL_WARSTOMP 28125 +#define SPELL_MANABURN 28135 +#define SPELL_CHAIN_LIGHTNING 28900 diff --git a/src/bindings/scripts/scripts/zone/naxxramas/boss_gluth.cpp b/src/bindings/scripts/scripts/zone/naxxramas/boss_gluth.cpp index 72b9b6628de..4008d21f635 100644 --- a/src/bindings/scripts/scripts/zone/naxxramas/boss_gluth.cpp +++ b/src/bindings/scripts/scripts/zone/naxxramas/boss_gluth.cpp @@ -1,174 +1,174 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Gluth -SD%Complete: 100 -SDComment: -SDCategory: Naxxramas -EndScriptData */ - -#include "precompiled.h" - -#define SPELL_MORTALWOUND 25646 -#define SPELL_DECIMATE 28374 -#define SPELL_TERRIFYINGROAR 29685 -#define SPELL_FRENZY 19812 -#define SPELL_ENRAGE 28747 - -#define ADD_1X 3269.590 -#define ADD_1Y -3161.287 -#define ADD_1Z 297.423 - -#define ADD_2X 3277.797 -#define ADD_2Y -3170.352 -#define ADD_2Z 297.423 - -#define ADD_3X 3267.049 -#define ADD_3Y -3172.820 -#define ADD_3Z 297.423 - -#define ADD_4X 3252.157 -#define ADD_4Y -3132.135 -#define ADD_4Z 297.423 - -#define ADD_5X 3259.990 -#define ADD_5Y -3126.590 -#define ADD_5Z 297.423 - -#define ADD_6X 3259.815 -#define ADD_6Y -3137.576 -#define ADD_6Z 297.423 - -#define ADD_7X 3308.030 -#define ADD_7Y -3132.135 -#define ADD_7Z 297.423 - -#define ADD_8X 3303.046 -#define ADD_8Y -3180.682 -#define ADD_8Z 297.423 - -#define ADD_9X 3313.283 -#define ADD_9Y -3180.766 -#define ADD_9Z 297.423 - -struct MANGOS_DLL_DECL boss_gluthAI : public ScriptedAI -{ - boss_gluthAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 MortalWound_Timer; - uint32 Decimate_Timer; - uint32 TerrifyingRoar_Timer; - uint32 Frenzy_Timer; - uint32 Enrage_Timer; - uint32 Summon_Timer; - - void Reset() - { - MortalWound_Timer = 8000; - Decimate_Timer = 100000; - TerrifyingRoar_Timer = 21000; - Frenzy_Timer = 15000; - Enrage_Timer = 304000; - Summon_Timer = 10000; - } - - void Aggro(Unit *who) - { - } - - void UpdateAI(const uint32 diff) - { - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - //MortalWound_Timer - if (MortalWound_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_MORTALWOUND); - MortalWound_Timer = 10000; - }else MortalWound_Timer -= diff; - - //Decimate_Timer - if (Decimate_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_DECIMATE); - Decimate_Timer = 100000; - }else Decimate_Timer -= diff; - - //TerrifyingRoar_Timer - if (TerrifyingRoar_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_TERRIFYINGROAR); - TerrifyingRoar_Timer = 20000; - }else TerrifyingRoar_Timer -= diff; - - //Frenzy_Timer - if (Frenzy_Timer < diff) - { - DoCast(m_creature,SPELL_FRENZY); - Frenzy_Timer = 10500; - }else Frenzy_Timer -= diff; - - //Enrage_Timer - if (Enrage_Timer < diff) - { - DoCast(m_creature,SPELL_ENRAGE); - Enrage_Timer = 61000; - }else Enrage_Timer -= diff; - - //Summon_Timer - if (Summon_Timer < diff) - { - Unit* target = NULL; - Unit* SummonedZombies = NULL; - - SummonedZombies = m_creature->SummonCreature(16360,ADD_1X,ADD_1Y,ADD_1Z,0,TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,80000); - SummonedZombies = m_creature->SummonCreature(16360,ADD_2X,ADD_2Y,ADD_2Z,0,TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,80000); - SummonedZombies = m_creature->SummonCreature(16360,ADD_3X,ADD_3Y,ADD_3Z,0,TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,80000); - SummonedZombies = m_creature->SummonCreature(16360,ADD_4X,ADD_4Y,ADD_4Z,0,TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,80000); - SummonedZombies = m_creature->SummonCreature(16360,ADD_5X,ADD_5Y,ADD_5Z,0,TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,80000); - SummonedZombies = m_creature->SummonCreature(16360,ADD_6X,ADD_6Y,ADD_6Z,0,TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,80000); - SummonedZombies = m_creature->SummonCreature(16360,ADD_7X,ADD_7Y,ADD_7Z,0,TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,80000); - SummonedZombies = m_creature->SummonCreature(16360,ADD_8X,ADD_8Y,ADD_8Z,0,TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,80000); - SummonedZombies = m_creature->SummonCreature(16360,ADD_9X,ADD_9Y,ADD_9Z,0,TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,80000); - - if (SummonedZombies) - { - target = SelectUnit(SELECT_TARGET_RANDOM,0); - if (target) - SummonedZombies->AddThreat(target,1.0f); - } - - Summon_Timer = 28000; - } else Summon_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; -CreatureAI* GetAI_boss_gluth(Creature *_Creature) -{ - return new boss_gluthAI (_Creature); -} - -void AddSC_boss_gluth() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_gluth"; - newscript->GetAI = GetAI_boss_gluth; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Gluth +SD%Complete: 100 +SDComment: +SDCategory: Naxxramas +EndScriptData */ + +#include "precompiled.h" + +#define SPELL_MORTALWOUND 25646 +#define SPELL_DECIMATE 28374 +#define SPELL_TERRIFYINGROAR 29685 +#define SPELL_FRENZY 19812 +#define SPELL_ENRAGE 28747 + +#define ADD_1X 3269.590 +#define ADD_1Y -3161.287 +#define ADD_1Z 297.423 + +#define ADD_2X 3277.797 +#define ADD_2Y -3170.352 +#define ADD_2Z 297.423 + +#define ADD_3X 3267.049 +#define ADD_3Y -3172.820 +#define ADD_3Z 297.423 + +#define ADD_4X 3252.157 +#define ADD_4Y -3132.135 +#define ADD_4Z 297.423 + +#define ADD_5X 3259.990 +#define ADD_5Y -3126.590 +#define ADD_5Z 297.423 + +#define ADD_6X 3259.815 +#define ADD_6Y -3137.576 +#define ADD_6Z 297.423 + +#define ADD_7X 3308.030 +#define ADD_7Y -3132.135 +#define ADD_7Z 297.423 + +#define ADD_8X 3303.046 +#define ADD_8Y -3180.682 +#define ADD_8Z 297.423 + +#define ADD_9X 3313.283 +#define ADD_9Y -3180.766 +#define ADD_9Z 297.423 + +struct MANGOS_DLL_DECL boss_gluthAI : public ScriptedAI +{ + boss_gluthAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 MortalWound_Timer; + uint32 Decimate_Timer; + uint32 TerrifyingRoar_Timer; + uint32 Frenzy_Timer; + uint32 Enrage_Timer; + uint32 Summon_Timer; + + void Reset() + { + MortalWound_Timer = 8000; + Decimate_Timer = 100000; + TerrifyingRoar_Timer = 21000; + Frenzy_Timer = 15000; + Enrage_Timer = 304000; + Summon_Timer = 10000; + } + + void Aggro(Unit *who) + { + } + + void UpdateAI(const uint32 diff) + { + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + //MortalWound_Timer + if (MortalWound_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_MORTALWOUND); + MortalWound_Timer = 10000; + }else MortalWound_Timer -= diff; + + //Decimate_Timer + if (Decimate_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_DECIMATE); + Decimate_Timer = 100000; + }else Decimate_Timer -= diff; + + //TerrifyingRoar_Timer + if (TerrifyingRoar_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_TERRIFYINGROAR); + TerrifyingRoar_Timer = 20000; + }else TerrifyingRoar_Timer -= diff; + + //Frenzy_Timer + if (Frenzy_Timer < diff) + { + DoCast(m_creature,SPELL_FRENZY); + Frenzy_Timer = 10500; + }else Frenzy_Timer -= diff; + + //Enrage_Timer + if (Enrage_Timer < diff) + { + DoCast(m_creature,SPELL_ENRAGE); + Enrage_Timer = 61000; + }else Enrage_Timer -= diff; + + //Summon_Timer + if (Summon_Timer < diff) + { + Unit* target = NULL; + Unit* SummonedZombies = NULL; + + SummonedZombies = m_creature->SummonCreature(16360,ADD_1X,ADD_1Y,ADD_1Z,0,TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,80000); + SummonedZombies = m_creature->SummonCreature(16360,ADD_2X,ADD_2Y,ADD_2Z,0,TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,80000); + SummonedZombies = m_creature->SummonCreature(16360,ADD_3X,ADD_3Y,ADD_3Z,0,TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,80000); + SummonedZombies = m_creature->SummonCreature(16360,ADD_4X,ADD_4Y,ADD_4Z,0,TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,80000); + SummonedZombies = m_creature->SummonCreature(16360,ADD_5X,ADD_5Y,ADD_5Z,0,TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,80000); + SummonedZombies = m_creature->SummonCreature(16360,ADD_6X,ADD_6Y,ADD_6Z,0,TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,80000); + SummonedZombies = m_creature->SummonCreature(16360,ADD_7X,ADD_7Y,ADD_7Z,0,TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,80000); + SummonedZombies = m_creature->SummonCreature(16360,ADD_8X,ADD_8Y,ADD_8Z,0,TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,80000); + SummonedZombies = m_creature->SummonCreature(16360,ADD_9X,ADD_9Y,ADD_9Z,0,TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,80000); + + if (SummonedZombies) + { + target = SelectUnit(SELECT_TARGET_RANDOM,0); + if (target) + SummonedZombies->AddThreat(target,1.0f); + } + + Summon_Timer = 28000; + } else Summon_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; +CreatureAI* GetAI_boss_gluth(Creature *_Creature) +{ + return new boss_gluthAI (_Creature); +} + +void AddSC_boss_gluth() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_gluth"; + newscript->GetAI = GetAI_boss_gluth; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/naxxramas/boss_gothik.cpp b/src/bindings/scripts/scripts/zone/naxxramas/boss_gothik.cpp index 3be2727fe16..dcbe8d9b2d3 100644 --- a/src/bindings/scripts/scripts/zone/naxxramas/boss_gothik.cpp +++ b/src/bindings/scripts/scripts/zone/naxxramas/boss_gothik.cpp @@ -1,62 +1,62 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Gothik -SD%Complete: 0 -SDComment: Placeholder -SDCategory: Naxxramas -EndScriptData */ - -//Gothik -//8806 spch - Foolishly you have sought your own demise. Brazenly you have disregarded powers beyond your understanding. You have fought hard to invade the realm of the harvester. Now there is only one way out - to walk the lonely path of the damned. -//8808 tlpt - I have waited long enough! Now, you face the harvester of souls! -//8806 slay - Death is the only escape. -//8805 death - I... am... undone! - -#include "precompiled.h" - -//Gothik -#define SPELL_HARVESTSOUL 28679 -#define SPELL_SHADOWBOLT 19729 - -//Unrelenting Trainee -#define SPELL_EAGLECLAW 30285 -#define SPELL_KNOCKDOWN_PASSIVE 6961 - -//Unrelenting Deathknight -#define SPELL_CHARGE 22120 -#define SPELL_SHADOW_MARK 27825 - -//Unrelenting Rider -#define SPELL_UNHOLY_AURA 28340 -#define SPELL_SHADOWBOLT 19729 //Search thru targets and find those who have the SHADOW_MARK to cast this on - -//Spectral Trainee -#define SPELL_ARCANE_EXPLOSION 27989 - -//Spectral Deathknight -#define SPELL_WHIRLWIND 28334 -#define SPELL_SUNDER_ARMOR 25051 //cannot find sunder that reduces armor by 2950 -#define SPELL_CLEAVE 20677 -#define SPELL_MANA_BURN 17631 - -//Spectral Rider -#define SPELL_LIFEDRAIN 24300 -//USES SAME UNHOLY AURA AS UNRELENTING RIDER - -//Spectral Horse -#define SPELL_STOMP 27993 +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Gothik +SD%Complete: 0 +SDComment: Placeholder +SDCategory: Naxxramas +EndScriptData */ + +//Gothik +//8806 spch - Foolishly you have sought your own demise. Brazenly you have disregarded powers beyond your understanding. You have fought hard to invade the realm of the harvester. Now there is only one way out - to walk the lonely path of the damned. +//8808 tlpt - I have waited long enough! Now, you face the harvester of souls! +//8806 slay - Death is the only escape. +//8805 death - I... am... undone! + +#include "precompiled.h" + +//Gothik +#define SPELL_HARVESTSOUL 28679 +#define SPELL_SHADOWBOLT 19729 + +//Unrelenting Trainee +#define SPELL_EAGLECLAW 30285 +#define SPELL_KNOCKDOWN_PASSIVE 6961 + +//Unrelenting Deathknight +#define SPELL_CHARGE 22120 +#define SPELL_SHADOW_MARK 27825 + +//Unrelenting Rider +#define SPELL_UNHOLY_AURA 28340 +#define SPELL_SHADOWBOLT 19729 //Search thru targets and find those who have the SHADOW_MARK to cast this on + +//Spectral Trainee +#define SPELL_ARCANE_EXPLOSION 27989 + +//Spectral Deathknight +#define SPELL_WHIRLWIND 28334 +#define SPELL_SUNDER_ARMOR 25051 //cannot find sunder that reduces armor by 2950 +#define SPELL_CLEAVE 20677 +#define SPELL_MANA_BURN 17631 + +//Spectral Rider +#define SPELL_LIFEDRAIN 24300 +//USES SAME UNHOLY AURA AS UNRELENTING RIDER + +//Spectral Horse +#define SPELL_STOMP 27993 diff --git a/src/bindings/scripts/scripts/zone/naxxramas/boss_grobbulus.cpp b/src/bindings/scripts/scripts/zone/naxxramas/boss_grobbulus.cpp index cbe7657ed57..22cc93e89b1 100644 --- a/src/bindings/scripts/scripts/zone/naxxramas/boss_grobbulus.cpp +++ b/src/bindings/scripts/scripts/zone/naxxramas/boss_grobbulus.cpp @@ -1,30 +1,30 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Grobbulus -SD%Complete: 0 -SDComment: Place holder -SDCategory: Naxxramas -EndScriptData */ - -/*Poison Cloud 26590 -Slime Spray 28157 -Fallout slime 28218 -Mutating Injection 28169 -Enrages 26527*/ - -#include "precompiled.h" +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Grobbulus +SD%Complete: 0 +SDComment: Place holder +SDCategory: Naxxramas +EndScriptData */ + +/*Poison Cloud 26590 +Slime Spray 28157 +Fallout slime 28218 +Mutating Injection 28169 +Enrages 26527*/ + +#include "precompiled.h" diff --git a/src/bindings/scripts/scripts/zone/naxxramas/boss_heigan.cpp b/src/bindings/scripts/scripts/zone/naxxramas/boss_heigan.cpp index 147eae49e22..e8a1e78a883 100644 --- a/src/bindings/scripts/scripts/zone/naxxramas/boss_heigan.cpp +++ b/src/bindings/scripts/scripts/zone/naxxramas/boss_heigan.cpp @@ -1,46 +1,46 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Heigan -SD%Complete: 0 -SDComment: Place Holder -SDCategory: Naxxramas -EndScriptData */ - -//Lotheb or Heigan? -//8825 aggro1 - You are mine now! -//8826 aggro2 - I see you! -//8827 aggro3 - You...are next! -//8828 death - -//8829 slay - close your eyes... sleep -//8830 taunt1 - The races of the world will perish. It is only a matter of time. -//8831 taunt2 - I see endless suffering, I see torment, I see rage. I see... everything! -//8832 taunt3 - Soon... the world will tremble! -//8833 taunt4 - The end is upon you. -//8834 taunt5 - Hungry worms will feast on your rotten flesh! - -#include "precompiled.h" - -//Spell used by floor peices to cause damage to players -#define SPELL_ERUPTION 29371 - -//Spells by boss -#define SPELL_WILT 23772 -#define SPELL_FEAVER 29998 - -//Spell by eye stalks -#define SPELL_MIND_FLAY 26143 +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Heigan +SD%Complete: 0 +SDComment: Place Holder +SDCategory: Naxxramas +EndScriptData */ + +//Lotheb or Heigan? +//8825 aggro1 - You are mine now! +//8826 aggro2 - I see you! +//8827 aggro3 - You...are next! +//8828 death - +//8829 slay - close your eyes... sleep +//8830 taunt1 - The races of the world will perish. It is only a matter of time. +//8831 taunt2 - I see endless suffering, I see torment, I see rage. I see... everything! +//8832 taunt3 - Soon... the world will tremble! +//8833 taunt4 - The end is upon you. +//8834 taunt5 - Hungry worms will feast on your rotten flesh! + +#include "precompiled.h" + +//Spell used by floor peices to cause damage to players +#define SPELL_ERUPTION 29371 + +//Spells by boss +#define SPELL_WILT 23772 +#define SPELL_FEAVER 29998 + +//Spell by eye stalks +#define SPELL_MIND_FLAY 26143 diff --git a/src/bindings/scripts/scripts/zone/naxxramas/boss_highlord_mograine.cpp b/src/bindings/scripts/scripts/zone/naxxramas/boss_highlord_mograine.cpp index 0641d6d66a3..912d769a202 100644 --- a/src/bindings/scripts/scripts/zone/naxxramas/boss_highlord_mograine.cpp +++ b/src/bindings/scripts/scripts/zone/naxxramas/boss_highlord_mograine.cpp @@ -1,178 +1,178 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Highlord_Mograine -SD%Complete: 100 -SDComment: -SDCategory: Naxxramas -EndScriptData */ - -#include "precompiled.h" - -//All horsemen -#define SPELL_SHIELDWALL 29061 -#define SPELL_BESERK 26662 - -// highlord mograine -#define SPELL_MARK_OF_MOGRAINE 28834 -#define SPELL_RIGHTEOUS_FIRE 28882 // Applied as a 25% chance on melee hit to proc. m_creature->GetVictim() - -#define SAY_TAUNT1 "Enough prattling. Let them come! We shall grind their bones to dust." -#define SAY_TAUNT2 "Conserve your anger! Harness your rage! You will all have outlets for your frustration soon enough." -#define SAY_TAUNT3 "Life is meaningless. It is in death that we are truly tested." -#define SAY_AGGRO1 "You seek death?" -#define SAY_AGGRO2 "None shall pass!" -#define SAY_AGGRO3 "Be still!" -#define SAY_SLAY1 "You will find no peace in death." -#define SAY_SLAY2 "The master's will is done." -#define SAY_SPECIAL "Bow to the might of the Highlord!" -#define SAY_DEATH "I... am... released! Perhaps it's not too late to - noo! I need... more time..." - -#define SOUND_TAUNT1 8842 -#define SOUND_TAUNT2 8843 -#define SOUND_TAUNT3 8844 -#define SOUND_AGGRO1 8835 -#define SOUND_AGGRO2 8836 -#define SOUND_AGGRO3 8837 -#define SOUND_SLAY1 8839 -#define SOUND_SLAY2 8840 -#define SOUND_SPECIAL 8841 -#define SOUND_DEATH 8838 - -#define SPIRIT_OF_MOGRAINE 16775 - -struct MANGOS_DLL_DECL boss_highlord_mograineAI : public ScriptedAI -{ - boss_highlord_mograineAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 Mark_Timer; - uint32 RighteousFire_Timer; - bool ShieldWall1; - bool ShieldWall2; - - void Reset() - { - Mark_Timer = 20000; // First Horsemen Mark is applied at 20 sec. - RighteousFire_Timer = 2000; // applied approx 1 out of 4 attacks - ShieldWall1 = true; - ShieldWall2 = true; - } - - void InitialYell() - { - if(!InCombat) - { - switch(rand()%3) - { - case 0: - DoYell(SAY_AGGRO1,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_AGGRO1); - break; - case 1: - DoYell(SAY_AGGRO2,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_AGGRO2); - break; - case 2: - DoYell(SAY_AGGRO3,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_AGGRO3); - break; - } - } - } - - void KilledUnit() - { - switch(rand()%2) - { - case 0: - DoYell(SAY_SLAY1,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_SLAY1); - break; - case 1: - DoYell(SAY_SLAY2,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_SLAY2); - break; - } - } - - void JustDied(Unit* Killer) - { - DoYell(SAY_DEATH,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature, SOUND_DEATH); - } - - void Aggro(Unit *who) - { - InitialYell(); - } - - void UpdateAI(const uint32 diff) - { - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - // Mark of Mograine - if(Mark_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_MARK_OF_MOGRAINE); - Mark_Timer = 12000; - }else Mark_Timer -= diff; - - // Shield Wall - All 4 horsemen will shield wall at 50% hp and 20% hp for 20 seconds - if(ShieldWall1 && (m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < 50) - { - if(ShieldWall1) - { - DoCast(m_creature,SPELL_SHIELDWALL); - ShieldWall1 = false; - } - } - if(ShieldWall2 && (m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < 20) - { - if(ShieldWall2) - { - DoCast(m_creature,SPELL_SHIELDWALL); - ShieldWall2 = false; - } - } - - // Righteous Fire - if(RighteousFire_Timer < diff) - { - if(rand()%4 == 1) // 1/4 - { - DoCast(m_creature->getVictim(),SPELL_RIGHTEOUS_FIRE); - } - RighteousFire_Timer = 2000; - }else RighteousFire_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; -CreatureAI* GetAI_boss_highlord_mograine(Creature *_Creature) -{ - return new boss_highlord_mograineAI (_Creature); -} - -void AddSC_boss_highlord_mograine() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_highlord_mograine"; - newscript->GetAI = GetAI_boss_highlord_mograine; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Highlord_Mograine +SD%Complete: 100 +SDComment: +SDCategory: Naxxramas +EndScriptData */ + +#include "precompiled.h" + +//All horsemen +#define SPELL_SHIELDWALL 29061 +#define SPELL_BESERK 26662 + +// highlord mograine +#define SPELL_MARK_OF_MOGRAINE 28834 +#define SPELL_RIGHTEOUS_FIRE 28882 // Applied as a 25% chance on melee hit to proc. m_creature->GetVictim() + +#define SAY_TAUNT1 "Enough prattling. Let them come! We shall grind their bones to dust." +#define SAY_TAUNT2 "Conserve your anger! Harness your rage! You will all have outlets for your frustration soon enough." +#define SAY_TAUNT3 "Life is meaningless. It is in death that we are truly tested." +#define SAY_AGGRO1 "You seek death?" +#define SAY_AGGRO2 "None shall pass!" +#define SAY_AGGRO3 "Be still!" +#define SAY_SLAY1 "You will find no peace in death." +#define SAY_SLAY2 "The master's will is done." +#define SAY_SPECIAL "Bow to the might of the Highlord!" +#define SAY_DEATH "I... am... released! Perhaps it's not too late to - noo! I need... more time..." + +#define SOUND_TAUNT1 8842 +#define SOUND_TAUNT2 8843 +#define SOUND_TAUNT3 8844 +#define SOUND_AGGRO1 8835 +#define SOUND_AGGRO2 8836 +#define SOUND_AGGRO3 8837 +#define SOUND_SLAY1 8839 +#define SOUND_SLAY2 8840 +#define SOUND_SPECIAL 8841 +#define SOUND_DEATH 8838 + +#define SPIRIT_OF_MOGRAINE 16775 + +struct MANGOS_DLL_DECL boss_highlord_mograineAI : public ScriptedAI +{ + boss_highlord_mograineAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 Mark_Timer; + uint32 RighteousFire_Timer; + bool ShieldWall1; + bool ShieldWall2; + + void Reset() + { + Mark_Timer = 20000; // First Horsemen Mark is applied at 20 sec. + RighteousFire_Timer = 2000; // applied approx 1 out of 4 attacks + ShieldWall1 = true; + ShieldWall2 = true; + } + + void InitialYell() + { + if(!InCombat) + { + switch(rand()%3) + { + case 0: + DoYell(SAY_AGGRO1,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_AGGRO1); + break; + case 1: + DoYell(SAY_AGGRO2,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_AGGRO2); + break; + case 2: + DoYell(SAY_AGGRO3,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_AGGRO3); + break; + } + } + } + + void KilledUnit() + { + switch(rand()%2) + { + case 0: + DoYell(SAY_SLAY1,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_SLAY1); + break; + case 1: + DoYell(SAY_SLAY2,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_SLAY2); + break; + } + } + + void JustDied(Unit* Killer) + { + DoYell(SAY_DEATH,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature, SOUND_DEATH); + } + + void Aggro(Unit *who) + { + InitialYell(); + } + + void UpdateAI(const uint32 diff) + { + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + // Mark of Mograine + if(Mark_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_MARK_OF_MOGRAINE); + Mark_Timer = 12000; + }else Mark_Timer -= diff; + + // Shield Wall - All 4 horsemen will shield wall at 50% hp and 20% hp for 20 seconds + if(ShieldWall1 && (m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < 50) + { + if(ShieldWall1) + { + DoCast(m_creature,SPELL_SHIELDWALL); + ShieldWall1 = false; + } + } + if(ShieldWall2 && (m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < 20) + { + if(ShieldWall2) + { + DoCast(m_creature,SPELL_SHIELDWALL); + ShieldWall2 = false; + } + } + + // Righteous Fire + if(RighteousFire_Timer < diff) + { + if(rand()%4 == 1) // 1/4 + { + DoCast(m_creature->getVictim(),SPELL_RIGHTEOUS_FIRE); + } + RighteousFire_Timer = 2000; + }else RighteousFire_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; +CreatureAI* GetAI_boss_highlord_mograine(Creature *_Creature) +{ + return new boss_highlord_mograineAI (_Creature); +} + +void AddSC_boss_highlord_mograine() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_highlord_mograine"; + newscript->GetAI = GetAI_boss_highlord_mograine; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/naxxramas/boss_kelthuzad.cpp b/src/bindings/scripts/scripts/zone/naxxramas/boss_kelthuzad.cpp index 4f8e2e9470f..27c10592b97 100644 --- a/src/bindings/scripts/scripts/zone/naxxramas/boss_kelthuzad.cpp +++ b/src/bindings/scripts/scripts/zone/naxxramas/boss_kelthuzad.cpp @@ -1,542 +1,542 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_KelThuzud -SD%Complete: 0 -SDComment: VERIFY SCRIPT -SDCategory: Naxxramas -EndScriptData */ - -#include "precompiled.h" - -//***THIS SCRIPTS IS UNDER DEVELOPMENT*** -/* -DATA. -This script has been made with info taken from wowwikki... so there are things wrong... -like spell timers and Says. Also there's another major problem as there is no aggroed list -I cannot make Kel'thuzad to target specific party members, that is needed for spells like -Mana Detonation... so what I'm doing untill now is just to cast everything on my main aggroed -target. Sorry for him. -Another bug is that there are spells that are actually NOT working... I have to implement -them first. -Need DISPELL efect -I also don't know the emotes -*/ - -//Kel'thuzad. Still don't know where to use these... -//Dialog -//8878 dialog01 - Our preparations continue as planned, master. -//8881 lich_naxx_dialog01 - It is good that you serve me so faithfully. Soon, all will serve the Lich King and in the end, you shall be rewarded...so long as you do not falter. -//8879 dialog02 - I see no complications... Wait... What is this? -//8882 lich_naxx_dialog03 - Your security measures have failed! See to this interruption immediately! -//8880 dialog03 - Yes, master! -//Bigglesworth death -//No!!! A curse upon you, interlopers! The armies of the Lich King will hunt you down. You will not escape your fate... -//slay -//8818 - -//common needed defines -#define NAXXRAMAS_MAP 533 -//Positional defines -#define ADDX_LEFT_FAR 3783.272705 -#define ADDY_LEFT_FAR -5062.697266 -#define ADDZ_LEFT_FAR 143.711203 -#define ADDO_LEFT_FAR 3.617599 - -#define ADDX_LEFT_MIDDLE 3730.291260 -#define ADDY_LEFT_MIDDLE -5027.239258 -#define ADDZ_LEFT_MIDDLE 143.956909 -#define ADDO_LEFT_MIDDLE 4.461900 - -#define ADDX_LEFT_NEAR 3683.868652 -#define ADDY_LEFT_NEAR -5057.281250 -#define ADDZ_LEFT_NEAR 143.183884 -#define ADDO_LEFT_NEAR 5.237086 - -#define ADDX_RIGHT_FAR 3759.355225 -#define ADDY_RIGHT_FAR -5174.128418 -#define ADDZ_RIGHT_FAR 143.802383 -#define ADDO_RIGHT_FAR 2.170104 - -#define ADDX_RIGHT_MIDDLE 370.724365 -#define ADDY_RIGHT_MIDDLE -5185.123047 -#define ADDZ_RIGHT_MIDDLE 143.928024 -#define ADDO_RIGHT_MIDDLE 1.309310 - -#define ADDX_RIGHT_NEAR 3665.121094 -#define ADDY_RIGHT_NEAR -5138.679199 -#define ADDZ_RIGHT_NEAR 143.183212 -#define ADDO_RIGHT_NEAR 0.604023 - -#define WALKX_LEFT_FAR 3754.431396 -#define WALKY_LEFT_FAR -5080.727734 -#define WALKZ_LEFT_FAR 142.036316 -#define WALKO_LEFT_FAR 3.736189 - -#define WALKX_LEFT_MIDDLE 3724.396484 -#define WALKY_LEFT_MIDDLE -5061.330566 -#define WALKZ_LEFT_MIDDLE 142.032700 -#define WALKO_LEFT_MIDDLE 4.564785 - -#define WALKX_LEFT_NEAR 3687.158424 -#define WALKY_LEFT_NEAR -5076.834473 -#define WALKZ_LEFT_NEAR 142.017319 -#define WALKO_LEFT_NEAR 5.237086 - -#define WALKX_RIGHT_FAR 3687.571777 -#define WALKY_RIGHT_FAR -5126.831055 -#define WALKZ_RIGHT_FAR 142.017807 -#define WALKO_RIGHT_FAR 0.604023 - -#define WALKX_RIGHT_MIDDLE 3707.990733 -#define WALKY_RIGHT_MIDDLE -5151.450195 -#define WALKZ_RIGHT_MIDDLE 142.032562 -#define WALKO_RIGHT_MIDDLE 1.376855 - -#define WALKX_RIGHT_NEAR 3739.500000 -#define WALKY_RIGHT_NEAR -5141.883989 -#define WALKZ_RIGHT_NEAR 142.0141130 -#define WALKO_RIGHT_NEAR 2.121412 - -//spells to be casted -#define SPELL_FROST_BOLT 28478 -#define SPELL_FROST_BOLT_NOVA 28479 -#define SPELL_CHAINS_OF_KELTHUZAD 28410 -#define SPELL_MANA_DETONATION 27819 -#define SPELL_SHADOW_FISURE 27810 -#define SPELL_FROST_BLAST 27808 - -//On Aggro -#define SAY_ARRIVAL1 "PRAY FOR MERCY!" -#define SOUND_ARRIVAL1 8809 -#define SAY_ARRIVAL3 "SCREAM YOR DYING BREATH!" -#define SOUND_ARRIVAL3 8810 -#define SAY_ARRIVAL5 "THE END IS UPON YOU!" -#define SOUND_ARRIVAL5 8811 - -//On Summon -#define SAY_REINFORCEMENTS1 "MINIONS, SERVANTS, SOLDIERS OF THE COLD DARK, OBEY THE CALL OF KEL'THUZAD!" -#define SOUND_REINFORCEMENTS1 8819 -#define SAY_REINFORCEMENTS2 "MASTER, I REQUIRE AID!" -#define SOUND_REINFORCEMENTS2 8816 -#define SAY_LICH_NAXX_SUMMON "VERY WELL. WARRIORS OF THE FROZEN WASTES RISE UP!. I COMMAND YOU TO FIGHT, KILL AND DIE AND DIE FOR YOUR MASTER! LET NONE SURVIVE!" -#define SOUND_LICH_NAXX_SUMMON 8824 - -//Random 1/4 taunt said when player enters 300 yards -#define SAY_TAUNT01 "WHO DARES VIOLATE THE SACTITY OF MY DOMAIN? BE WARNED, ALL WHO TRASPASS HERE ARE DOOMED" -#define SOUND_TAUNT01 8820 -#define SAY_TAUNT02 "FOOLS, YOU THINK YOURSELVES TRIUMPHANT? YOU HAVE ONLY TAKEN ONE STEP CLOSER TO THE ABYSS!" -#define SOUND_TAUNT02 8821 -#define SAY_TAUNT03 "I GROW TIRED OF THESE GAMES. PROCEED, AND I WILL BANISH YOUR SOULS TO OBLIVION!" -#define SOUND_TAUNT03 8822 -#define SAY_TAUNT04 "YOU HAVE NO IDEA WHAT HORRORS LIE AHEAD. YOU HAVE SEEN NOTHING! THE FROZEN HEART OF NAXXRAMAS AWAITS YOU!" -#define SOUND_TAUNT04 8823 - -//On kill unit -#define SAY_SLAY "THE DARK VOID AWAITS YOU!" -#define SOUND_SLAY 8817 - -//Specials -#define SAY_FROST "I WILL FREEZE THE BLOOD IN YOUR VEINS!" -#define SOUND_FROST 8815 -#define SAY_CHAIN1 "YOUR SOUL IS BOUND TO ME NOW!" -#define SOUND_CHAIN1 8812 -#define SAY_CHAIN2 "THERE WILL BE NO ESCAPE!" -#define SOUND_CHAIN2 8813 -#define SAY_SPECIAL1 "YOUR PETTY MAGICS ARE NO CHALLENGE TO THE MIGTH OF THE SCOURGE" -#define SOUND_SPECIAL1 9088 -#define SAY_SPECIAL2 "ENOUGH! I GROW TIRED OF THESE DISTRACTIONS!" -#define SOUND_SPECIAL2 9090 -#define SAY_DISPEL "FOOLS, YOU HAVE SPREAD YOUR POWERS TOO THIN. BE FREE, MY MINIONS!" -#define SOUND_DISPEL 9089 - -//On death -#define SAY_DEATH "DO NOT REJOICE... YOUR VICTORY IS A HOLLOW ONE... FOR I SHALL RETURN WITH POWERS BEYOND YOUR IMAGINING!" -#define SOUND_DEATH 8814 - -struct MANGOS_DLL_DECL boss_kelthuzadAI : public ScriptedAI -{ - boss_kelthuzadAI(Creature* c) : ScriptedAI(c) - { - GuardiansOfIcecrown[0] = 0; - GuardiansOfIcecrown[1] = 0; - GuardiansOfIcecrown[2] = 0; - GuardiansOfIcecrown[3] = 0; - GuardiansOfIcecrown[4] = 0; - GuardiansOfIcecrown_Count = 0; - Reset(); - } - - uint64 GuardiansOfIcecrown[5]; - uint32 GuardiansOfIcecrown_Count; - uint32 GuardiansOfIcecrown_Timer; - uint32 FrostBolt_Timer; - uint32 FrostBoltNova_Timer; - uint32 ChainsOfKelthuzad_Timer; - uint32 ManaDetonation_Timer; - uint32 ShadowFisure_Timer; - uint32 FrostBlast_Timer; - uint32 ChainsOfKelthuzad_Targets; - uint32 Phase1_Timer; - bool Phase2; - bool Phase3; - - void Reset() - { - FrostBolt_Timer = (rand()%60)*1000; //It won't be more than a minute without cast it - FrostBoltNova_Timer = 15000; //Cast every 15 seconds - ChainsOfKelthuzad_Timer = (rand()%30+30)*1000; //Cast no sooner than once every 30 seconds - ManaDetonation_Timer = 20000; //Seems to cast about every 20 seconds - ShadowFisure_Timer = 25000; //25 seconds - FrostBlast_Timer = (rand()%30+30)*1000; //Random time between 30-60 seconds - GuardiansOfIcecrown_Timer = 5000; //5 seconds for summoning each Guardian of Icecrown in phase 3 - - for(int i=0; i<5; i++) - if(GuardiansOfIcecrown[i]) - { - //delete creature - Unit* pUnit = Unit::GetUnit((*m_creature), GuardiansOfIcecrown[i]); - if (pUnit && pUnit->isAlive()) - pUnit->DealDamage(pUnit, pUnit->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); - GuardiansOfIcecrown[i] = 0; - } - - Phase1_Timer = 310000; //Phase 1 lasts 5 minutes and 10 seconds - Phase2 = false; - Phase3 = false; - } - - void KilledUnit() - { - if (rand()%5) - return; - - DoYell(SAY_SLAY, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_SLAY); - } - - void JustDied(Unit* Killer) - { - DoYell(SAY_DEATH,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_DEATH); - for(int i=0; i<5; i++) - if(GuardiansOfIcecrown[i]) - { - Unit* pUnit = Unit::GetUnit((*m_creature), GuardiansOfIcecrown[i]); - if (!pUnit || !pUnit->isAlive()) - continue; - - pUnit->CombatStop(); - float Walk_Pos_X; - float Walk_Pos_Y; - float Walk_Pos_Z; - switch(rand()%6) - { - case 0: - Walk_Pos_X = ADDX_LEFT_FAR; - Walk_Pos_Y = ADDY_LEFT_FAR; - Walk_Pos_Z = ADDZ_LEFT_FAR; - break; - case 1: - Walk_Pos_X = ADDX_LEFT_MIDDLE; - Walk_Pos_Y = ADDY_LEFT_MIDDLE; - Walk_Pos_Z = ADDZ_LEFT_MIDDLE; - break; - case 2: - Walk_Pos_X = ADDX_LEFT_NEAR; - Walk_Pos_Y = ADDY_LEFT_NEAR; - Walk_Pos_Z = ADDZ_LEFT_NEAR; - break; - case 3: - Walk_Pos_X = ADDX_RIGHT_FAR; - Walk_Pos_Y = ADDY_RIGHT_FAR; - Walk_Pos_Z = ADDZ_RIGHT_FAR; - break; - case 4: - Walk_Pos_X = ADDX_RIGHT_MIDDLE; - Walk_Pos_Y = ADDY_RIGHT_MIDDLE; - Walk_Pos_Z = ADDZ_RIGHT_MIDDLE; - break; - case 5: - Walk_Pos_X = ADDX_RIGHT_NEAR; - Walk_Pos_Y = ADDY_RIGHT_NEAR; - Walk_Pos_Z = ADDZ_RIGHT_NEAR; - break; - } - pUnit->SendMonsterMoveWithSpeed(Walk_Pos_X, Walk_Pos_Y, Walk_Pos_Z,MOVEMENTFLAG_WALK_MODE); - } - } - - void SayInitialAggro() //randomly select 1 of 3 say for aggro - { - switch(rand()%3) - { - case 0: - DoYell(SAY_ARRIVAL1,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_ARRIVAL1); - break; - case 1: - DoYell(SAY_ARRIVAL3,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_ARRIVAL3); - break; - case 2: - DoYell(SAY_ARRIVAL5,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_ARRIVAL5); - break; - } - } - - void Aggro(Unit* who) - { - switch(rand()%3) - { - case 0: - DoYell(SAY_ARRIVAL1,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_ARRIVAL1); - break; - case 1: - DoYell(SAY_ARRIVAL3,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_ARRIVAL3); - break; - case 2: - DoYell(SAY_ARRIVAL5,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_ARRIVAL5); - break; - } - } - - void UpdateAI(const uint32 diff) - { - if(!m_creature->SelectHostilTarget()) - return; - - if(m_creature->getVictim() && m_creature->isAlive()) - { - //Check for Frost Bolt - if(FrostBolt_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_FROST_BOLT); - - if(rand()%2 == 0) - { - DoYell(SAY_FROST,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_FROST); - } - //Cast again on time - FrostBolt_Timer = (rand()%60)*1000; - } - else FrostBolt_Timer -= diff; - - //Check for Frost Bolt Nova - if(FrostBoltNova_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_FROST_BOLT_NOVA); - - if(rand()%2 == 0) - { - DoYell(SAY_FROST,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_FROST); - } - - FrostBoltNova_Timer = 15000; - } - else FrostBoltNova_Timer -= diff; - - //Check for Chains Of Kelthuzad - if(ChainsOfKelthuzad_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_CHAINS_OF_KELTHUZAD); - - if(rand()%2 == 0) - if(rand()%2 == 0) - { - DoYell(SAY_CHAIN1,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_CHAIN1); - } - else - { - DoYell(SAY_CHAIN2,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_CHAIN2); - } - - //cast again on time - ChainsOfKelthuzad_Timer = (rand()%30+30)*1000; - } - else ChainsOfKelthuzad_Timer -= diff; - - //Check for Mana Detonation - if(ManaDetonation_Timer < diff) - { - //time to cast - //DoCast(m_creature->getVictim(),SPELL_MANA_DETONATION); - - if(rand()%2 == 0) - { - DoYell(SAY_SPECIAL1,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_SPECIAL1); - } - ManaDetonation_Timer = 20000; - } - else ManaDetonation_Timer -= diff; - - //Check for Shadow Fissure - if(ShadowFisure_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_SHADOW_FISURE); - - if(rand()%2 == 0) - { - DoYell(SAY_SPECIAL2,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_SPECIAL2); - } - - ShadowFisure_Timer = 25000; - } - else ShadowFisure_Timer -= diff; - - //Check for Frost Blast - if(FrostBlast_Timer < diff) - { - //time to cast - //DoCast(m_creature->getVictim(),SPELL_FROST_BLAST); - - if(rand()%2 == 0) - { - DoYell(SAY_FROST,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_FROST); - } - - FrostBlast_Timer = (rand()%30+30)*1000; - } - else FrostBlast_Timer -= diff; - - //start phase 3 when we are 40% health - if(!Phase3 && (m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < 40) - { - Phase3 = true; - switch(rand()%2) - { - case 1: - DoYell(SAY_REINFORCEMENTS1,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_REINFORCEMENTS1); - break; - case 2: - DoYell(SAY_REINFORCEMENTS2,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_REINFORCEMENTS2); - break; - } - //here Lich King should respond to KelThuzad but I don't know which creature to make talk - //so for now just make Kelthuzad says it. - DoPlaySoundToSet(m_creature,SOUND_LICH_NAXX_SUMMON); - } - - if(Phase3 && (GuardiansOfIcecrown_Count < 5)) - if(GuardiansOfIcecrown_Timer < diff) - { - //Summon a Guardian of Icecrown in a random alcove (Creature # 16441) - //uint32 TimeToWalk; - Unit* pUnit = NULL; - float Walk_Pos_X; - float Walk_Pos_Y; - float Walk_Pos_Z; - switch(rand()%6) - { - case 0: - pUnit = m_creature->SummonCreature(16441,ADDX_LEFT_FAR,ADDY_LEFT_FAR,ADDZ_LEFT_FAR,ADDO_LEFT_FAR,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,1000); - //Setting walk position - Walk_Pos_X = WALKX_LEFT_FAR; - Walk_Pos_Y = WALKY_LEFT_FAR; - Walk_Pos_Z = WALKZ_LEFT_FAR; - break; - case 1: - pUnit = m_creature->SummonCreature(16441,ADDX_LEFT_MIDDLE,ADDY_LEFT_MIDDLE,ADDZ_LEFT_MIDDLE,ADDO_LEFT_MIDDLE,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,1000); - //Start moving guardian towards the center of the room - Walk_Pos_X = WALKX_LEFT_MIDDLE; - Walk_Pos_Y = WALKY_LEFT_MIDDLE; - Walk_Pos_Z = WALKZ_LEFT_MIDDLE; - break; - case 2: - pUnit = m_creature->SummonCreature(16441,ADDX_LEFT_NEAR,ADDY_LEFT_NEAR,ADDZ_LEFT_NEAR,ADDO_LEFT_NEAR,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,1000); - //Start moving guardian towards the center of the room - Walk_Pos_X = WALKX_LEFT_NEAR; - Walk_Pos_Y = WALKY_LEFT_NEAR; - Walk_Pos_Z = WALKZ_LEFT_NEAR; - break; - case 3: - - pUnit = m_creature->SummonCreature(16441,ADDX_RIGHT_FAR,ADDY_RIGHT_FAR,ADDZ_RIGHT_FAR,ADDO_RIGHT_FAR,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,1000); - //Start moving guardian towards the center of the room - Walk_Pos_X = WALKX_RIGHT_FAR; - Walk_Pos_Y = WALKY_RIGHT_FAR; - Walk_Pos_Z = WALKZ_RIGHT_FAR; - break; - case 4: - pUnit = m_creature->SummonCreature(16441,ADDX_RIGHT_MIDDLE,ADDY_RIGHT_MIDDLE,ADDZ_RIGHT_MIDDLE,ADDO_RIGHT_MIDDLE,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,1000); - //Start moving guardian towards the center of the room - Walk_Pos_X = WALKX_RIGHT_MIDDLE; - Walk_Pos_Y = WALKY_RIGHT_MIDDLE; - Walk_Pos_Z = WALKZ_RIGHT_MIDDLE; - break; - case 5: - pUnit = m_creature->SummonCreature(16441,ADDX_RIGHT_NEAR,ADDY_RIGHT_NEAR,ADDZ_RIGHT_NEAR,ADDO_RIGHT_NEAR,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,1000); - //Start moving guardian towards the center of the room - Walk_Pos_X = WALKX_RIGHT_NEAR; - Walk_Pos_Y = WALKY_RIGHT_NEAR; - Walk_Pos_Z = WALKZ_RIGHT_NEAR; - break; - } - - if (pUnit) - { - //if we find no one to figth walk to the center - if(!pUnit->isInCombat()) - pUnit->SendMonsterMoveWithSpeed(Walk_Pos_X,Walk_Pos_Y,Walk_Pos_Z,MOVEMENTFLAG_WALK_MODE); - - //Safe storing of creatures - GuardiansOfIcecrown[GuardiansOfIcecrown_Count] = pUnit->GetGUID(); - - //Update guardian count - GuardiansOfIcecrown_Count++; - - } - //5 seconds until summoning next guardian - GuardiansOfIcecrown_Timer = 5000; - } - else GuardiansOfIcecrown_Timer -= diff; - - DoMeleeAttackIfReady(); - } - } -}; - -CreatureAI* GetAI_boss_kelthuzadAI(Creature *_Creature) -{ - return new boss_kelthuzadAI (_Creature); -} - -void AddSC_boss_kelthuzad() -{ - //This script is disabled until it has been throughly tested - - /* - Script *newscript; - newscript = new Script; - newscript->Name="boss_kelthuzad"; - newscript->GetAI = GetAI_boss_kelthuzadAI; - m_scripts[nrscripts++] = newscript; - */ -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_KelThuzud +SD%Complete: 0 +SDComment: VERIFY SCRIPT +SDCategory: Naxxramas +EndScriptData */ + +#include "precompiled.h" + +//***THIS SCRIPTS IS UNDER DEVELOPMENT*** +/* +DATA. +This script has been made with info taken from wowwikki... so there are things wrong... +like spell timers and Says. Also there's another major problem as there is no aggroed list +I cannot make Kel'thuzad to target specific party members, that is needed for spells like +Mana Detonation... so what I'm doing untill now is just to cast everything on my main aggroed +target. Sorry for him. +Another bug is that there are spells that are actually NOT working... I have to implement +them first. +Need DISPELL efect +I also don't know the emotes +*/ + +//Kel'thuzad. Still don't know where to use these... +//Dialog +//8878 dialog01 - Our preparations continue as planned, master. +//8881 lich_naxx_dialog01 - It is good that you serve me so faithfully. Soon, all will serve the Lich King and in the end, you shall be rewarded...so long as you do not falter. +//8879 dialog02 - I see no complications... Wait... What is this? +//8882 lich_naxx_dialog03 - Your security measures have failed! See to this interruption immediately! +//8880 dialog03 - Yes, master! +//Bigglesworth death +//No!!! A curse upon you, interlopers! The armies of the Lich King will hunt you down. You will not escape your fate... +//slay +//8818 + +//common needed defines +#define NAXXRAMAS_MAP 533 +//Positional defines +#define ADDX_LEFT_FAR 3783.272705 +#define ADDY_LEFT_FAR -5062.697266 +#define ADDZ_LEFT_FAR 143.711203 +#define ADDO_LEFT_FAR 3.617599 + +#define ADDX_LEFT_MIDDLE 3730.291260 +#define ADDY_LEFT_MIDDLE -5027.239258 +#define ADDZ_LEFT_MIDDLE 143.956909 +#define ADDO_LEFT_MIDDLE 4.461900 + +#define ADDX_LEFT_NEAR 3683.868652 +#define ADDY_LEFT_NEAR -5057.281250 +#define ADDZ_LEFT_NEAR 143.183884 +#define ADDO_LEFT_NEAR 5.237086 + +#define ADDX_RIGHT_FAR 3759.355225 +#define ADDY_RIGHT_FAR -5174.128418 +#define ADDZ_RIGHT_FAR 143.802383 +#define ADDO_RIGHT_FAR 2.170104 + +#define ADDX_RIGHT_MIDDLE 370.724365 +#define ADDY_RIGHT_MIDDLE -5185.123047 +#define ADDZ_RIGHT_MIDDLE 143.928024 +#define ADDO_RIGHT_MIDDLE 1.309310 + +#define ADDX_RIGHT_NEAR 3665.121094 +#define ADDY_RIGHT_NEAR -5138.679199 +#define ADDZ_RIGHT_NEAR 143.183212 +#define ADDO_RIGHT_NEAR 0.604023 + +#define WALKX_LEFT_FAR 3754.431396 +#define WALKY_LEFT_FAR -5080.727734 +#define WALKZ_LEFT_FAR 142.036316 +#define WALKO_LEFT_FAR 3.736189 + +#define WALKX_LEFT_MIDDLE 3724.396484 +#define WALKY_LEFT_MIDDLE -5061.330566 +#define WALKZ_LEFT_MIDDLE 142.032700 +#define WALKO_LEFT_MIDDLE 4.564785 + +#define WALKX_LEFT_NEAR 3687.158424 +#define WALKY_LEFT_NEAR -5076.834473 +#define WALKZ_LEFT_NEAR 142.017319 +#define WALKO_LEFT_NEAR 5.237086 + +#define WALKX_RIGHT_FAR 3687.571777 +#define WALKY_RIGHT_FAR -5126.831055 +#define WALKZ_RIGHT_FAR 142.017807 +#define WALKO_RIGHT_FAR 0.604023 + +#define WALKX_RIGHT_MIDDLE 3707.990733 +#define WALKY_RIGHT_MIDDLE -5151.450195 +#define WALKZ_RIGHT_MIDDLE 142.032562 +#define WALKO_RIGHT_MIDDLE 1.376855 + +#define WALKX_RIGHT_NEAR 3739.500000 +#define WALKY_RIGHT_NEAR -5141.883989 +#define WALKZ_RIGHT_NEAR 142.0141130 +#define WALKO_RIGHT_NEAR 2.121412 + +//spells to be casted +#define SPELL_FROST_BOLT 28478 +#define SPELL_FROST_BOLT_NOVA 28479 +#define SPELL_CHAINS_OF_KELTHUZAD 28410 +#define SPELL_MANA_DETONATION 27819 +#define SPELL_SHADOW_FISURE 27810 +#define SPELL_FROST_BLAST 27808 + +//On Aggro +#define SAY_ARRIVAL1 "PRAY FOR MERCY!" +#define SOUND_ARRIVAL1 8809 +#define SAY_ARRIVAL3 "SCREAM YOR DYING BREATH!" +#define SOUND_ARRIVAL3 8810 +#define SAY_ARRIVAL5 "THE END IS UPON YOU!" +#define SOUND_ARRIVAL5 8811 + +//On Summon +#define SAY_REINFORCEMENTS1 "MINIONS, SERVANTS, SOLDIERS OF THE COLD DARK, OBEY THE CALL OF KEL'THUZAD!" +#define SOUND_REINFORCEMENTS1 8819 +#define SAY_REINFORCEMENTS2 "MASTER, I REQUIRE AID!" +#define SOUND_REINFORCEMENTS2 8816 +#define SAY_LICH_NAXX_SUMMON "VERY WELL. WARRIORS OF THE FROZEN WASTES RISE UP!. I COMMAND YOU TO FIGHT, KILL AND DIE AND DIE FOR YOUR MASTER! LET NONE SURVIVE!" +#define SOUND_LICH_NAXX_SUMMON 8824 + +//Random 1/4 taunt said when player enters 300 yards +#define SAY_TAUNT01 "WHO DARES VIOLATE THE SACTITY OF MY DOMAIN? BE WARNED, ALL WHO TRASPASS HERE ARE DOOMED" +#define SOUND_TAUNT01 8820 +#define SAY_TAUNT02 "FOOLS, YOU THINK YOURSELVES TRIUMPHANT? YOU HAVE ONLY TAKEN ONE STEP CLOSER TO THE ABYSS!" +#define SOUND_TAUNT02 8821 +#define SAY_TAUNT03 "I GROW TIRED OF THESE GAMES. PROCEED, AND I WILL BANISH YOUR SOULS TO OBLIVION!" +#define SOUND_TAUNT03 8822 +#define SAY_TAUNT04 "YOU HAVE NO IDEA WHAT HORRORS LIE AHEAD. YOU HAVE SEEN NOTHING! THE FROZEN HEART OF NAXXRAMAS AWAITS YOU!" +#define SOUND_TAUNT04 8823 + +//On kill unit +#define SAY_SLAY "THE DARK VOID AWAITS YOU!" +#define SOUND_SLAY 8817 + +//Specials +#define SAY_FROST "I WILL FREEZE THE BLOOD IN YOUR VEINS!" +#define SOUND_FROST 8815 +#define SAY_CHAIN1 "YOUR SOUL IS BOUND TO ME NOW!" +#define SOUND_CHAIN1 8812 +#define SAY_CHAIN2 "THERE WILL BE NO ESCAPE!" +#define SOUND_CHAIN2 8813 +#define SAY_SPECIAL1 "YOUR PETTY MAGICS ARE NO CHALLENGE TO THE MIGTH OF THE SCOURGE" +#define SOUND_SPECIAL1 9088 +#define SAY_SPECIAL2 "ENOUGH! I GROW TIRED OF THESE DISTRACTIONS!" +#define SOUND_SPECIAL2 9090 +#define SAY_DISPEL "FOOLS, YOU HAVE SPREAD YOUR POWERS TOO THIN. BE FREE, MY MINIONS!" +#define SOUND_DISPEL 9089 + +//On death +#define SAY_DEATH "DO NOT REJOICE... YOUR VICTORY IS A HOLLOW ONE... FOR I SHALL RETURN WITH POWERS BEYOND YOUR IMAGINING!" +#define SOUND_DEATH 8814 + +struct MANGOS_DLL_DECL boss_kelthuzadAI : public ScriptedAI +{ + boss_kelthuzadAI(Creature* c) : ScriptedAI(c) + { + GuardiansOfIcecrown[0] = 0; + GuardiansOfIcecrown[1] = 0; + GuardiansOfIcecrown[2] = 0; + GuardiansOfIcecrown[3] = 0; + GuardiansOfIcecrown[4] = 0; + GuardiansOfIcecrown_Count = 0; + Reset(); + } + + uint64 GuardiansOfIcecrown[5]; + uint32 GuardiansOfIcecrown_Count; + uint32 GuardiansOfIcecrown_Timer; + uint32 FrostBolt_Timer; + uint32 FrostBoltNova_Timer; + uint32 ChainsOfKelthuzad_Timer; + uint32 ManaDetonation_Timer; + uint32 ShadowFisure_Timer; + uint32 FrostBlast_Timer; + uint32 ChainsOfKelthuzad_Targets; + uint32 Phase1_Timer; + bool Phase2; + bool Phase3; + + void Reset() + { + FrostBolt_Timer = (rand()%60)*1000; //It won't be more than a minute without cast it + FrostBoltNova_Timer = 15000; //Cast every 15 seconds + ChainsOfKelthuzad_Timer = (rand()%30+30)*1000; //Cast no sooner than once every 30 seconds + ManaDetonation_Timer = 20000; //Seems to cast about every 20 seconds + ShadowFisure_Timer = 25000; //25 seconds + FrostBlast_Timer = (rand()%30+30)*1000; //Random time between 30-60 seconds + GuardiansOfIcecrown_Timer = 5000; //5 seconds for summoning each Guardian of Icecrown in phase 3 + + for(int i=0; i<5; i++) + if(GuardiansOfIcecrown[i]) + { + //delete creature + Unit* pUnit = Unit::GetUnit((*m_creature), GuardiansOfIcecrown[i]); + if (pUnit && pUnit->isAlive()) + pUnit->DealDamage(pUnit, pUnit->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); + GuardiansOfIcecrown[i] = 0; + } + + Phase1_Timer = 310000; //Phase 1 lasts 5 minutes and 10 seconds + Phase2 = false; + Phase3 = false; + } + + void KilledUnit() + { + if (rand()%5) + return; + + DoYell(SAY_SLAY, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_SLAY); + } + + void JustDied(Unit* Killer) + { + DoYell(SAY_DEATH,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_DEATH); + for(int i=0; i<5; i++) + if(GuardiansOfIcecrown[i]) + { + Unit* pUnit = Unit::GetUnit((*m_creature), GuardiansOfIcecrown[i]); + if (!pUnit || !pUnit->isAlive()) + continue; + + pUnit->CombatStop(); + float Walk_Pos_X; + float Walk_Pos_Y; + float Walk_Pos_Z; + switch(rand()%6) + { + case 0: + Walk_Pos_X = ADDX_LEFT_FAR; + Walk_Pos_Y = ADDY_LEFT_FAR; + Walk_Pos_Z = ADDZ_LEFT_FAR; + break; + case 1: + Walk_Pos_X = ADDX_LEFT_MIDDLE; + Walk_Pos_Y = ADDY_LEFT_MIDDLE; + Walk_Pos_Z = ADDZ_LEFT_MIDDLE; + break; + case 2: + Walk_Pos_X = ADDX_LEFT_NEAR; + Walk_Pos_Y = ADDY_LEFT_NEAR; + Walk_Pos_Z = ADDZ_LEFT_NEAR; + break; + case 3: + Walk_Pos_X = ADDX_RIGHT_FAR; + Walk_Pos_Y = ADDY_RIGHT_FAR; + Walk_Pos_Z = ADDZ_RIGHT_FAR; + break; + case 4: + Walk_Pos_X = ADDX_RIGHT_MIDDLE; + Walk_Pos_Y = ADDY_RIGHT_MIDDLE; + Walk_Pos_Z = ADDZ_RIGHT_MIDDLE; + break; + case 5: + Walk_Pos_X = ADDX_RIGHT_NEAR; + Walk_Pos_Y = ADDY_RIGHT_NEAR; + Walk_Pos_Z = ADDZ_RIGHT_NEAR; + break; + } + pUnit->SendMonsterMoveWithSpeed(Walk_Pos_X, Walk_Pos_Y, Walk_Pos_Z,MOVEMENTFLAG_WALK_MODE); + } + } + + void SayInitialAggro() //randomly select 1 of 3 say for aggro + { + switch(rand()%3) + { + case 0: + DoYell(SAY_ARRIVAL1,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_ARRIVAL1); + break; + case 1: + DoYell(SAY_ARRIVAL3,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_ARRIVAL3); + break; + case 2: + DoYell(SAY_ARRIVAL5,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_ARRIVAL5); + break; + } + } + + void Aggro(Unit* who) + { + switch(rand()%3) + { + case 0: + DoYell(SAY_ARRIVAL1,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_ARRIVAL1); + break; + case 1: + DoYell(SAY_ARRIVAL3,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_ARRIVAL3); + break; + case 2: + DoYell(SAY_ARRIVAL5,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_ARRIVAL5); + break; + } + } + + void UpdateAI(const uint32 diff) + { + if(!m_creature->SelectHostilTarget()) + return; + + if(m_creature->getVictim() && m_creature->isAlive()) + { + //Check for Frost Bolt + if(FrostBolt_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_FROST_BOLT); + + if(rand()%2 == 0) + { + DoYell(SAY_FROST,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_FROST); + } + //Cast again on time + FrostBolt_Timer = (rand()%60)*1000; + } + else FrostBolt_Timer -= diff; + + //Check for Frost Bolt Nova + if(FrostBoltNova_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_FROST_BOLT_NOVA); + + if(rand()%2 == 0) + { + DoYell(SAY_FROST,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_FROST); + } + + FrostBoltNova_Timer = 15000; + } + else FrostBoltNova_Timer -= diff; + + //Check for Chains Of Kelthuzad + if(ChainsOfKelthuzad_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_CHAINS_OF_KELTHUZAD); + + if(rand()%2 == 0) + if(rand()%2 == 0) + { + DoYell(SAY_CHAIN1,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_CHAIN1); + } + else + { + DoYell(SAY_CHAIN2,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_CHAIN2); + } + + //cast again on time + ChainsOfKelthuzad_Timer = (rand()%30+30)*1000; + } + else ChainsOfKelthuzad_Timer -= diff; + + //Check for Mana Detonation + if(ManaDetonation_Timer < diff) + { + //time to cast + //DoCast(m_creature->getVictim(),SPELL_MANA_DETONATION); + + if(rand()%2 == 0) + { + DoYell(SAY_SPECIAL1,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_SPECIAL1); + } + ManaDetonation_Timer = 20000; + } + else ManaDetonation_Timer -= diff; + + //Check for Shadow Fissure + if(ShadowFisure_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_SHADOW_FISURE); + + if(rand()%2 == 0) + { + DoYell(SAY_SPECIAL2,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_SPECIAL2); + } + + ShadowFisure_Timer = 25000; + } + else ShadowFisure_Timer -= diff; + + //Check for Frost Blast + if(FrostBlast_Timer < diff) + { + //time to cast + //DoCast(m_creature->getVictim(),SPELL_FROST_BLAST); + + if(rand()%2 == 0) + { + DoYell(SAY_FROST,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_FROST); + } + + FrostBlast_Timer = (rand()%30+30)*1000; + } + else FrostBlast_Timer -= diff; + + //start phase 3 when we are 40% health + if(!Phase3 && (m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < 40) + { + Phase3 = true; + switch(rand()%2) + { + case 1: + DoYell(SAY_REINFORCEMENTS1,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_REINFORCEMENTS1); + break; + case 2: + DoYell(SAY_REINFORCEMENTS2,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_REINFORCEMENTS2); + break; + } + //here Lich King should respond to KelThuzad but I don't know which creature to make talk + //so for now just make Kelthuzad says it. + DoPlaySoundToSet(m_creature,SOUND_LICH_NAXX_SUMMON); + } + + if(Phase3 && (GuardiansOfIcecrown_Count < 5)) + if(GuardiansOfIcecrown_Timer < diff) + { + //Summon a Guardian of Icecrown in a random alcove (Creature # 16441) + //uint32 TimeToWalk; + Unit* pUnit = NULL; + float Walk_Pos_X; + float Walk_Pos_Y; + float Walk_Pos_Z; + switch(rand()%6) + { + case 0: + pUnit = m_creature->SummonCreature(16441,ADDX_LEFT_FAR,ADDY_LEFT_FAR,ADDZ_LEFT_FAR,ADDO_LEFT_FAR,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,1000); + //Setting walk position + Walk_Pos_X = WALKX_LEFT_FAR; + Walk_Pos_Y = WALKY_LEFT_FAR; + Walk_Pos_Z = WALKZ_LEFT_FAR; + break; + case 1: + pUnit = m_creature->SummonCreature(16441,ADDX_LEFT_MIDDLE,ADDY_LEFT_MIDDLE,ADDZ_LEFT_MIDDLE,ADDO_LEFT_MIDDLE,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,1000); + //Start moving guardian towards the center of the room + Walk_Pos_X = WALKX_LEFT_MIDDLE; + Walk_Pos_Y = WALKY_LEFT_MIDDLE; + Walk_Pos_Z = WALKZ_LEFT_MIDDLE; + break; + case 2: + pUnit = m_creature->SummonCreature(16441,ADDX_LEFT_NEAR,ADDY_LEFT_NEAR,ADDZ_LEFT_NEAR,ADDO_LEFT_NEAR,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,1000); + //Start moving guardian towards the center of the room + Walk_Pos_X = WALKX_LEFT_NEAR; + Walk_Pos_Y = WALKY_LEFT_NEAR; + Walk_Pos_Z = WALKZ_LEFT_NEAR; + break; + case 3: + + pUnit = m_creature->SummonCreature(16441,ADDX_RIGHT_FAR,ADDY_RIGHT_FAR,ADDZ_RIGHT_FAR,ADDO_RIGHT_FAR,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,1000); + //Start moving guardian towards the center of the room + Walk_Pos_X = WALKX_RIGHT_FAR; + Walk_Pos_Y = WALKY_RIGHT_FAR; + Walk_Pos_Z = WALKZ_RIGHT_FAR; + break; + case 4: + pUnit = m_creature->SummonCreature(16441,ADDX_RIGHT_MIDDLE,ADDY_RIGHT_MIDDLE,ADDZ_RIGHT_MIDDLE,ADDO_RIGHT_MIDDLE,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,1000); + //Start moving guardian towards the center of the room + Walk_Pos_X = WALKX_RIGHT_MIDDLE; + Walk_Pos_Y = WALKY_RIGHT_MIDDLE; + Walk_Pos_Z = WALKZ_RIGHT_MIDDLE; + break; + case 5: + pUnit = m_creature->SummonCreature(16441,ADDX_RIGHT_NEAR,ADDY_RIGHT_NEAR,ADDZ_RIGHT_NEAR,ADDO_RIGHT_NEAR,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,1000); + //Start moving guardian towards the center of the room + Walk_Pos_X = WALKX_RIGHT_NEAR; + Walk_Pos_Y = WALKY_RIGHT_NEAR; + Walk_Pos_Z = WALKZ_RIGHT_NEAR; + break; + } + + if (pUnit) + { + //if we find no one to figth walk to the center + if(!pUnit->isInCombat()) + pUnit->SendMonsterMoveWithSpeed(Walk_Pos_X,Walk_Pos_Y,Walk_Pos_Z,MOVEMENTFLAG_WALK_MODE); + + //Safe storing of creatures + GuardiansOfIcecrown[GuardiansOfIcecrown_Count] = pUnit->GetGUID(); + + //Update guardian count + GuardiansOfIcecrown_Count++; + + } + //5 seconds until summoning next guardian + GuardiansOfIcecrown_Timer = 5000; + } + else GuardiansOfIcecrown_Timer -= diff; + + DoMeleeAttackIfReady(); + } + } +}; + +CreatureAI* GetAI_boss_kelthuzadAI(Creature *_Creature) +{ + return new boss_kelthuzadAI (_Creature); +} + +void AddSC_boss_kelthuzad() +{ + //This script is disabled until it has been throughly tested + + /* + Script *newscript; + newscript = new Script; + newscript->Name="boss_kelthuzad"; + newscript->GetAI = GetAI_boss_kelthuzadAI; + m_scripts[nrscripts++] = newscript; + */ +} diff --git a/src/bindings/scripts/scripts/zone/naxxramas/boss_lady_blaumeux.cpp b/src/bindings/scripts/scripts/zone/naxxramas/boss_lady_blaumeux.cpp index 6946e962aae..932e2e00cdf 100644 --- a/src/bindings/scripts/scripts/zone/naxxramas/boss_lady_blaumeux.cpp +++ b/src/bindings/scripts/scripts/zone/naxxramas/boss_lady_blaumeux.cpp @@ -1,147 +1,147 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Lady_Blaumeux -SD%Complete: 100 -SDComment: -SDCategory: Naxxramas -EndScriptData */ - -#include "precompiled.h" - -//All horsemen -#define SPELL_SHIELDWALL 29061 -#define SPELL_BESERK 26662 - -// lady blaumeux -#define SPELL_MARK_OF_BLAUMEUX 28833 -#define SPELL_VOIDZONE 28863 - -#define SAY_AGGRO "Defend youself!" -#define SAY_TAUNT1 "Come, Zeliek, do not drive them out. Not before we've had our fun." -#define SAY_TAUNT2 "I do hope they stay alive long enough for me to... introduce myself." -#define SAY_TAUNT3 "The first kill goes to me! Anyone care to wager?" -#define SAY_SPECIAL "Your life is mine!" -#define SAY_SLAY "Who's next?" -#define SAY_DEATH "Tou... che!" - -#define SOUND_AGGRO 8892 -#define SOUND_TAUNT1 8896 -#define SOUND_TAUNT2 8897 -#define SOUND_TAUNT3 8898 -#define SOUND_SPECIAL 8895 -#define SOUND_SLAY 8894 -#define SOUND_DEATH 8893 - -#define SPIRIT_OF_BLAUMEUX 16776 - -struct MANGOS_DLL_DECL boss_lady_blaumeuxAI : public ScriptedAI -{ - boss_lady_blaumeuxAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 Mark_Timer; - uint32 VoidZone_Timer; - bool ShieldWall1; - bool ShieldWall2; - - void Reset() - { - Mark_Timer = 20000; // First Horsemen Mark is applied at 20 sec. - VoidZone_Timer = 12000; // right - ShieldWall1 = true; - ShieldWall2 = true; - } - - void InitialYell() - { - if(!InCombat) - { - DoYell(SAY_AGGRO,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_AGGRO); - } - } - - void KilledUnit() - { - DoYell(SAY_SLAY,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_SLAY); - } - - void JustDied(Unit* Killer) - { - DoYell(SAY_DEATH,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_DEATH); - } - - void Aggro(Unit *who) - { - InitialYell(); - } - - void UpdateAI(const uint32 diff) - { - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - // Mark of Blaumeux - if(Mark_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_MARK_OF_BLAUMEUX); - Mark_Timer = 12000; - }else Mark_Timer -= diff; - - // Shield Wall - All 4 horsemen will shield wall at 50% hp and 20% hp for 20 seconds - if(ShieldWall1 && (m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < 50) - { - if(ShieldWall1) - { - DoCast(m_creature,SPELL_SHIELDWALL); - ShieldWall1 = false; - } - } - if(ShieldWall2 && (m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < 20) - { - if(ShieldWall2) - { - DoCast(m_creature,SPELL_SHIELDWALL); - ShieldWall2 = false; - } - } - - // Void Zone - if(VoidZone_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_VOIDZONE); - VoidZone_Timer = 12000; - }else VoidZone_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; -CreatureAI* GetAI_boss_lady_blaumeux(Creature *_Creature) -{ - return new boss_lady_blaumeuxAI (_Creature); -} - -void AddSC_boss_lady_blaumeux() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_lady_blaumeux"; - newscript->GetAI = GetAI_boss_lady_blaumeux; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Lady_Blaumeux +SD%Complete: 100 +SDComment: +SDCategory: Naxxramas +EndScriptData */ + +#include "precompiled.h" + +//All horsemen +#define SPELL_SHIELDWALL 29061 +#define SPELL_BESERK 26662 + +// lady blaumeux +#define SPELL_MARK_OF_BLAUMEUX 28833 +#define SPELL_VOIDZONE 28863 + +#define SAY_AGGRO "Defend youself!" +#define SAY_TAUNT1 "Come, Zeliek, do not drive them out. Not before we've had our fun." +#define SAY_TAUNT2 "I do hope they stay alive long enough for me to... introduce myself." +#define SAY_TAUNT3 "The first kill goes to me! Anyone care to wager?" +#define SAY_SPECIAL "Your life is mine!" +#define SAY_SLAY "Who's next?" +#define SAY_DEATH "Tou... che!" + +#define SOUND_AGGRO 8892 +#define SOUND_TAUNT1 8896 +#define SOUND_TAUNT2 8897 +#define SOUND_TAUNT3 8898 +#define SOUND_SPECIAL 8895 +#define SOUND_SLAY 8894 +#define SOUND_DEATH 8893 + +#define SPIRIT_OF_BLAUMEUX 16776 + +struct MANGOS_DLL_DECL boss_lady_blaumeuxAI : public ScriptedAI +{ + boss_lady_blaumeuxAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 Mark_Timer; + uint32 VoidZone_Timer; + bool ShieldWall1; + bool ShieldWall2; + + void Reset() + { + Mark_Timer = 20000; // First Horsemen Mark is applied at 20 sec. + VoidZone_Timer = 12000; // right + ShieldWall1 = true; + ShieldWall2 = true; + } + + void InitialYell() + { + if(!InCombat) + { + DoYell(SAY_AGGRO,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_AGGRO); + } + } + + void KilledUnit() + { + DoYell(SAY_SLAY,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_SLAY); + } + + void JustDied(Unit* Killer) + { + DoYell(SAY_DEATH,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_DEATH); + } + + void Aggro(Unit *who) + { + InitialYell(); + } + + void UpdateAI(const uint32 diff) + { + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + // Mark of Blaumeux + if(Mark_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_MARK_OF_BLAUMEUX); + Mark_Timer = 12000; + }else Mark_Timer -= diff; + + // Shield Wall - All 4 horsemen will shield wall at 50% hp and 20% hp for 20 seconds + if(ShieldWall1 && (m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < 50) + { + if(ShieldWall1) + { + DoCast(m_creature,SPELL_SHIELDWALL); + ShieldWall1 = false; + } + } + if(ShieldWall2 && (m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < 20) + { + if(ShieldWall2) + { + DoCast(m_creature,SPELL_SHIELDWALL); + ShieldWall2 = false; + } + } + + // Void Zone + if(VoidZone_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_VOIDZONE); + VoidZone_Timer = 12000; + }else VoidZone_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; +CreatureAI* GetAI_boss_lady_blaumeux(Creature *_Creature) +{ + return new boss_lady_blaumeuxAI (_Creature); +} + +void AddSC_boss_lady_blaumeux() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_lady_blaumeux"; + newscript->GetAI = GetAI_boss_lady_blaumeux; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/naxxramas/boss_loatheb.cpp b/src/bindings/scripts/scripts/zone/naxxramas/boss_loatheb.cpp index cc4390ceb8e..1c759fdba49 100644 --- a/src/bindings/scripts/scripts/zone/naxxramas/boss_loatheb.cpp +++ b/src/bindings/scripts/scripts/zone/naxxramas/boss_loatheb.cpp @@ -1,216 +1,216 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Loatheb -SD%Complete: 100 -SDComment: -SDCategory: Naxxramas -EndScriptData */ - -#include "precompiled.h" - -#define SAY_AGGRO1 "You are mine now!" -#define SAY_AGGRO2 "I see you!" -#define SAY_AGGRO3 "You...are next!" -#define SAY_SLAY1 "Close your eyes... sleep!" -#define SAY_SLAY2 "The races of the world will perish. It is only a matter of time." -#define SAY_SLAY3 "I see endless suffering, I see torment, I see rage. I see... everything!" -#define SAY_SLAY4 "Soon... the world will tremble!" -#define SAY_SLAY5 "The end is upon you." -#define SAY_SLAY6 "Hungry worms will feast on your rotten flesh!" -#define SAY_DEATH "" - -#define SOUND_AGGRO1 8825 -#define SOUND_AGGRO2 8826 -#define SOUND_AGGRO3 8827 -#define SOUND_SLAY1 8829 -#define SOUND_SLAY2 8830 -#define SOUND_SLAY3 8831 -#define SOUND_SLAY4 8832 -#define SOUND_SLAY5 8833 -#define SOUND_SLAY6 8834 -#define SOUND_DEATH 8828 - -#define SPELL_CORRUPTED_MIND 29198 -#define SPELL_POISON_AURA 29865 -#define SPELL_INEVITABLE_DOOM 29204 -#define SPELL_REMOVE_CURSE 30281 - -#define ADD_1X 2957.040 -#define ADD_1Y -3997.590 -#define ADD_1Z 274.280 - -#define ADD_2X 2909.130 -#define ADD_2Y -4042.970 -#define ADD_2Z 274.280 - -#define ADD_3X 2861.102 -#define ADD_3Y -3997.901 -#define ADD_3Z 274.280 - -struct MANGOS_DLL_DECL boss_loathebAI : public ScriptedAI -{ - boss_loathebAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 CorruptedMind_Timer; - uint32 PoisonAura_Timer; - uint32 InevitableDoom_Timer; - uint32 InevitableDoom5mins_Timer; - uint32 RemoveCurse_Timer; - uint32 Summon_Timer; - - void Reset() - { - CorruptedMind_Timer = 4000; - PoisonAura_Timer = 2500; - InevitableDoom_Timer = 120000; - InevitableDoom5mins_Timer = 300000; - RemoveCurse_Timer = 30000; - Summon_Timer = 8000; - } - - void Aggro(Unit *who) - { - switch (rand()%3) - { - case 0: - DoYell(SAY_AGGRO1,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_AGGRO1); - break; - case 1: - DoYell(SAY_AGGRO2,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_AGGRO2); - break; - case 2: - DoYell(SAY_AGGRO3,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_AGGRO3); - break; - } - } - - void KilledUnit(Unit* victim) - { - switch (rand()%6) - { - case 0: - DoYell(SAY_SLAY1,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_SLAY1); - break; - case 1: - DoYell(SAY_SLAY2,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_SLAY2); - break; - case 2: - DoYell(SAY_SLAY3,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_SLAY3); - break; - case 3: - DoYell(SAY_SLAY4,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_SLAY4); - break; - case 4: - DoYell(SAY_SLAY5,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_SLAY5); - break; - case 5: - DoYell(SAY_SLAY6,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_SLAY6); - break; - } - } - - void JustDied(Unit* Killer) - { - DoYell(SAY_DEATH,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_DEATH); - } - - void UpdateAI(const uint32 diff) - { - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - //CorruptedMind_Timer - if (CorruptedMind_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_CORRUPTED_MIND); - CorruptedMind_Timer = 62000; - }else CorruptedMind_Timer -= diff; - - //PoisonAura_Timer - if (PoisonAura_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_POISON_AURA); - PoisonAura_Timer = 60000; - }else PoisonAura_Timer -= diff; - - //InevitableDoom_Timer - if (InevitableDoom_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_INEVITABLE_DOOM); - InevitableDoom_Timer = 120000; - }else InevitableDoom_Timer -= diff; - - //InevitableDoom5mins_Timer - if (InevitableDoom5mins_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_INEVITABLE_DOOM); - InevitableDoom5mins_Timer = 15000; - }else InevitableDoom5mins_Timer -= diff; - - //RemoveCurse_Timer - if (RemoveCurse_Timer < diff) - { - DoCast(m_creature,SPELL_REMOVE_CURSE); - RemoveCurse_Timer = 30000; - }else RemoveCurse_Timer -= diff; - - //Summon_Timer - if (Summon_Timer < diff) - { - Unit* target = NULL; - Unit* SummonedSpores = NULL; - - SummonedSpores = m_creature->SummonCreature(16286,ADD_1X,ADD_1Y,ADD_1Z,0,TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,80000); - SummonedSpores = m_creature->SummonCreature(16286,ADD_2X,ADD_2Y,ADD_2Z,0,TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,80000); - SummonedSpores = m_creature->SummonCreature(16286,ADD_3X,ADD_3Y,ADD_3Z,0,TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,80000); - if (SummonedSpores) - { - target = SelectUnit(SELECT_TARGET_RANDOM,0); - if (target) - SummonedSpores->AddThreat(target,1.0f); - } - - Summon_Timer = 28000; - } else Summon_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; -CreatureAI* GetAI_boss_loatheb(Creature *_Creature) -{ - return new boss_loathebAI (_Creature); -} - -void AddSC_boss_loatheb() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_loatheb"; - newscript->GetAI = GetAI_boss_loatheb; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Loatheb +SD%Complete: 100 +SDComment: +SDCategory: Naxxramas +EndScriptData */ + +#include "precompiled.h" + +#define SAY_AGGRO1 "You are mine now!" +#define SAY_AGGRO2 "I see you!" +#define SAY_AGGRO3 "You...are next!" +#define SAY_SLAY1 "Close your eyes... sleep!" +#define SAY_SLAY2 "The races of the world will perish. It is only a matter of time." +#define SAY_SLAY3 "I see endless suffering, I see torment, I see rage. I see... everything!" +#define SAY_SLAY4 "Soon... the world will tremble!" +#define SAY_SLAY5 "The end is upon you." +#define SAY_SLAY6 "Hungry worms will feast on your rotten flesh!" +#define SAY_DEATH "" + +#define SOUND_AGGRO1 8825 +#define SOUND_AGGRO2 8826 +#define SOUND_AGGRO3 8827 +#define SOUND_SLAY1 8829 +#define SOUND_SLAY2 8830 +#define SOUND_SLAY3 8831 +#define SOUND_SLAY4 8832 +#define SOUND_SLAY5 8833 +#define SOUND_SLAY6 8834 +#define SOUND_DEATH 8828 + +#define SPELL_CORRUPTED_MIND 29198 +#define SPELL_POISON_AURA 29865 +#define SPELL_INEVITABLE_DOOM 29204 +#define SPELL_REMOVE_CURSE 30281 + +#define ADD_1X 2957.040 +#define ADD_1Y -3997.590 +#define ADD_1Z 274.280 + +#define ADD_2X 2909.130 +#define ADD_2Y -4042.970 +#define ADD_2Z 274.280 + +#define ADD_3X 2861.102 +#define ADD_3Y -3997.901 +#define ADD_3Z 274.280 + +struct MANGOS_DLL_DECL boss_loathebAI : public ScriptedAI +{ + boss_loathebAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 CorruptedMind_Timer; + uint32 PoisonAura_Timer; + uint32 InevitableDoom_Timer; + uint32 InevitableDoom5mins_Timer; + uint32 RemoveCurse_Timer; + uint32 Summon_Timer; + + void Reset() + { + CorruptedMind_Timer = 4000; + PoisonAura_Timer = 2500; + InevitableDoom_Timer = 120000; + InevitableDoom5mins_Timer = 300000; + RemoveCurse_Timer = 30000; + Summon_Timer = 8000; + } + + void Aggro(Unit *who) + { + switch (rand()%3) + { + case 0: + DoYell(SAY_AGGRO1,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_AGGRO1); + break; + case 1: + DoYell(SAY_AGGRO2,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_AGGRO2); + break; + case 2: + DoYell(SAY_AGGRO3,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_AGGRO3); + break; + } + } + + void KilledUnit(Unit* victim) + { + switch (rand()%6) + { + case 0: + DoYell(SAY_SLAY1,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_SLAY1); + break; + case 1: + DoYell(SAY_SLAY2,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_SLAY2); + break; + case 2: + DoYell(SAY_SLAY3,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_SLAY3); + break; + case 3: + DoYell(SAY_SLAY4,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_SLAY4); + break; + case 4: + DoYell(SAY_SLAY5,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_SLAY5); + break; + case 5: + DoYell(SAY_SLAY6,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_SLAY6); + break; + } + } + + void JustDied(Unit* Killer) + { + DoYell(SAY_DEATH,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_DEATH); + } + + void UpdateAI(const uint32 diff) + { + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + //CorruptedMind_Timer + if (CorruptedMind_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_CORRUPTED_MIND); + CorruptedMind_Timer = 62000; + }else CorruptedMind_Timer -= diff; + + //PoisonAura_Timer + if (PoisonAura_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_POISON_AURA); + PoisonAura_Timer = 60000; + }else PoisonAura_Timer -= diff; + + //InevitableDoom_Timer + if (InevitableDoom_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_INEVITABLE_DOOM); + InevitableDoom_Timer = 120000; + }else InevitableDoom_Timer -= diff; + + //InevitableDoom5mins_Timer + if (InevitableDoom5mins_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_INEVITABLE_DOOM); + InevitableDoom5mins_Timer = 15000; + }else InevitableDoom5mins_Timer -= diff; + + //RemoveCurse_Timer + if (RemoveCurse_Timer < diff) + { + DoCast(m_creature,SPELL_REMOVE_CURSE); + RemoveCurse_Timer = 30000; + }else RemoveCurse_Timer -= diff; + + //Summon_Timer + if (Summon_Timer < diff) + { + Unit* target = NULL; + Unit* SummonedSpores = NULL; + + SummonedSpores = m_creature->SummonCreature(16286,ADD_1X,ADD_1Y,ADD_1Z,0,TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,80000); + SummonedSpores = m_creature->SummonCreature(16286,ADD_2X,ADD_2Y,ADD_2Z,0,TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,80000); + SummonedSpores = m_creature->SummonCreature(16286,ADD_3X,ADD_3Y,ADD_3Z,0,TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,80000); + if (SummonedSpores) + { + target = SelectUnit(SELECT_TARGET_RANDOM,0); + if (target) + SummonedSpores->AddThreat(target,1.0f); + } + + Summon_Timer = 28000; + } else Summon_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; +CreatureAI* GetAI_boss_loatheb(Creature *_Creature) +{ + return new boss_loathebAI (_Creature); +} + +void AddSC_boss_loatheb() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_loatheb"; + newscript->GetAI = GetAI_boss_loatheb; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/naxxramas/boss_maexxna.cpp b/src/bindings/scripts/scripts/zone/naxxramas/boss_maexxna.cpp index bd10cff23a0..3388ac97f71 100644 --- a/src/bindings/scripts/scripts/zone/naxxramas/boss_maexxna.cpp +++ b/src/bindings/scripts/scripts/zone/naxxramas/boss_maexxna.cpp @@ -1,246 +1,246 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Maexxna -SD%Complete: 80 -SDComment: -SDCategory: Naxxramas -EndScriptData */ - -#include "precompiled.h" - -#define SPELL_WEBTRAP 28622 //Spell is normally used by the webtrap on the wall NOT by Maexxna -#define SPELL_WEBSPRAY 29484 -#define SPELL_POISONSHOCK 28741 -#define SPELL_NECROTICPOISON 28776 -#define SPELL_ENRAGE 28747 -#define SPELL_SUMMON_SPIDERLING 29434 - -#define LOC_X1 3546.796 -#define LOC_Y1 -3869.082 -#define LOC_Z1 296.450 - -#define LOC_X2 3531.271 -#define LOC_Y2 -3847.424 -#define LOC_Z2 299.450 - -#define LOC_X3 3497.067 -#define LOC_Y3 -3843.384 -#define LOC_Z3 302.384 - -struct MANGOS_DLL_DECL mob_webwrapAI : public ScriptedAI -{ - mob_webwrapAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint64 victimGUID; - - void Reset() - { - victimGUID = 0; - } - - void SetVictim(Unit* victim) - { - if(victim) - { - victimGUID = victim->GetGUID(); - victim->CastSpell(victim, SPELL_WEBTRAP, true); - } - } - - void DamageTaken(Unit *done_by, uint32 &damage) - { - if(damage > m_creature->GetHealth()) - { - if(victimGUID) - { - Unit* victim = NULL; - victim = Unit::GetUnit((*m_creature), victimGUID); - victim->RemoveAurasDueToSpell(SPELL_WEBTRAP); - } - } - } - - void Aggro(Unit *who) - { - } - - void MoveInLineOfSight(Unit *who) - { - } - - void UpdateAI(const uint32 diff) - { - } -}; - -struct MANGOS_DLL_DECL boss_maexxnaAI : public ScriptedAI -{ - boss_maexxnaAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 WebTrap_Timer; - uint32 WebSpray_Timer; - uint32 PoisonShock_Timer; - uint32 NecroticPoison_Timer; - uint32 SummonSpiderling_Timer; - bool Enraged; - - void Reset() - { - WebTrap_Timer = 20000; //20 sec init, 40 sec normal - WebSpray_Timer = 40000; //40 seconds - PoisonShock_Timer = 20000; //20 seconds - NecroticPoison_Timer = 30000; //30 seconds - SummonSpiderling_Timer = 30000; //30 sec init, 40 sec normal - Enraged = false; - } - - void Aggro(Unit *who) - { - } - - void DoCastWebWrap() - { - std::list t_list = m_creature->getThreatManager().getThreatList(); - std::vector targets; - - //This spell doesn't work if we only have 1 player on threat list - if(t_list.size() < 2) - return; - - //begin + 1 , so we don't target the one with the highest threat - std::list::iterator itr = t_list.begin(); - std::advance(itr, 1); - for( ; itr!= t_list.end(); ++itr) //store the threat list in a different container - { - Unit *target = Unit::GetUnit(*m_creature, (*itr)->getUnitGuid()); - //only on alive players - if(target && target->isAlive() && target->GetTypeId() == TYPEID_PLAYER ) - targets.push_back( target); - } - - while(targets.size() > 3) - //cut down to size if we have more than 3 targets - targets.erase(targets.begin()+rand()%targets.size()); - - int i = 0; - for(std::vector::iterator itr = targets.begin(); itr!= targets.end(); ++itr, ++i) - { - // Teleport the 3 targets to a location on the wall and summon a Web Wrap on them - Unit *target = *itr; - Creature* Wrap = NULL; - if(target) - { - switch(i) - { - case 0: - DoTeleportPlayer(target, LOC_X1, LOC_Y1, LOC_Z1, target->GetOrientation()); - Wrap = m_creature->SummonCreature(16486, LOC_X1, LOC_Y1, LOC_Z1, 0, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 120000); - break; - case 1: - DoTeleportPlayer(target, LOC_X2, LOC_Y2, LOC_Z2, target->GetOrientation()); - Wrap = m_creature->SummonCreature(16486, LOC_X2, LOC_Y2, LOC_Z2, 0, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 120000); - break; - case 2: - DoTeleportPlayer(target, LOC_X3, LOC_Y3, LOC_Z3, target->GetOrientation()); - Wrap = m_creature->SummonCreature(16486, LOC_X3, LOC_Y3, LOC_Z3, 0, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 120000); - break; - } - if(Wrap) - { - Wrap->setFaction(m_creature->getFaction()); - ((mob_webwrapAI*)Wrap->AI())->SetVictim(target); - } - } - } - } - - void UpdateAI(const uint32 diff) - { - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - //WebTrap_Timer - if (WebTrap_Timer < diff) - { - DoCastWebWrap(); - WebTrap_Timer = 40000; - }else WebTrap_Timer -= diff; - - //WebSpray_Timer - if (WebSpray_Timer < diff) - { - DoCast(m_creature->getVictim(), SPELL_WEBSPRAY); - WebSpray_Timer = 40000; - }else WebSpray_Timer -= diff; - - //PoisonShock_Timer - if (PoisonShock_Timer < diff) - { - DoCast(m_creature->getVictim(), SPELL_POISONSHOCK); - PoisonShock_Timer = 20000; - }else PoisonShock_Timer -= diff; - - //NecroticPoison_Timer - if (NecroticPoison_Timer < diff) - { - DoCast(m_creature->getVictim(), SPELL_NECROTICPOISON); - NecroticPoison_Timer = 30000; - }else NecroticPoison_Timer -= diff; - - //SummonSpiderling_Timer - if (SummonSpiderling_Timer < diff) - { - DoCast(m_creature, SPELL_SUMMON_SPIDERLING); - SummonSpiderling_Timer = 40000; - }else SummonSpiderling_Timer -= diff; - - //Enrage if not already enraged and below 30% - if (!Enraged && (m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < 30) - { - DoCast(m_creature,SPELL_ENRAGE); - Enraged = true; - } - - DoMeleeAttackIfReady(); - } -}; - -CreatureAI* GetAI_mob_webwrap(Creature* _Creature) -{ - return new mob_webwrapAI (_Creature); -} - -CreatureAI* GetAI_boss_maexxna(Creature *_Creature) -{ - return new boss_maexxnaAI (_Creature); -} - -void AddSC_boss_maexxna() -{ - Script *newscript; - - newscript = new Script; - newscript->Name="boss_maexxna"; - newscript->GetAI = GetAI_boss_maexxna; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="mob_webwrap"; - newscript->GetAI = GetAI_mob_webwrap; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Maexxna +SD%Complete: 80 +SDComment: +SDCategory: Naxxramas +EndScriptData */ + +#include "precompiled.h" + +#define SPELL_WEBTRAP 28622 //Spell is normally used by the webtrap on the wall NOT by Maexxna +#define SPELL_WEBSPRAY 29484 +#define SPELL_POISONSHOCK 28741 +#define SPELL_NECROTICPOISON 28776 +#define SPELL_ENRAGE 28747 +#define SPELL_SUMMON_SPIDERLING 29434 + +#define LOC_X1 3546.796 +#define LOC_Y1 -3869.082 +#define LOC_Z1 296.450 + +#define LOC_X2 3531.271 +#define LOC_Y2 -3847.424 +#define LOC_Z2 299.450 + +#define LOC_X3 3497.067 +#define LOC_Y3 -3843.384 +#define LOC_Z3 302.384 + +struct MANGOS_DLL_DECL mob_webwrapAI : public ScriptedAI +{ + mob_webwrapAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint64 victimGUID; + + void Reset() + { + victimGUID = 0; + } + + void SetVictim(Unit* victim) + { + if(victim) + { + victimGUID = victim->GetGUID(); + victim->CastSpell(victim, SPELL_WEBTRAP, true); + } + } + + void DamageTaken(Unit *done_by, uint32 &damage) + { + if(damage > m_creature->GetHealth()) + { + if(victimGUID) + { + Unit* victim = NULL; + victim = Unit::GetUnit((*m_creature), victimGUID); + victim->RemoveAurasDueToSpell(SPELL_WEBTRAP); + } + } + } + + void Aggro(Unit *who) + { + } + + void MoveInLineOfSight(Unit *who) + { + } + + void UpdateAI(const uint32 diff) + { + } +}; + +struct MANGOS_DLL_DECL boss_maexxnaAI : public ScriptedAI +{ + boss_maexxnaAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 WebTrap_Timer; + uint32 WebSpray_Timer; + uint32 PoisonShock_Timer; + uint32 NecroticPoison_Timer; + uint32 SummonSpiderling_Timer; + bool Enraged; + + void Reset() + { + WebTrap_Timer = 20000; //20 sec init, 40 sec normal + WebSpray_Timer = 40000; //40 seconds + PoisonShock_Timer = 20000; //20 seconds + NecroticPoison_Timer = 30000; //30 seconds + SummonSpiderling_Timer = 30000; //30 sec init, 40 sec normal + Enraged = false; + } + + void Aggro(Unit *who) + { + } + + void DoCastWebWrap() + { + std::list t_list = m_creature->getThreatManager().getThreatList(); + std::vector targets; + + //This spell doesn't work if we only have 1 player on threat list + if(t_list.size() < 2) + return; + + //begin + 1 , so we don't target the one with the highest threat + std::list::iterator itr = t_list.begin(); + std::advance(itr, 1); + for( ; itr!= t_list.end(); ++itr) //store the threat list in a different container + { + Unit *target = Unit::GetUnit(*m_creature, (*itr)->getUnitGuid()); + //only on alive players + if(target && target->isAlive() && target->GetTypeId() == TYPEID_PLAYER ) + targets.push_back( target); + } + + while(targets.size() > 3) + //cut down to size if we have more than 3 targets + targets.erase(targets.begin()+rand()%targets.size()); + + int i = 0; + for(std::vector::iterator itr = targets.begin(); itr!= targets.end(); ++itr, ++i) + { + // Teleport the 3 targets to a location on the wall and summon a Web Wrap on them + Unit *target = *itr; + Creature* Wrap = NULL; + if(target) + { + switch(i) + { + case 0: + DoTeleportPlayer(target, LOC_X1, LOC_Y1, LOC_Z1, target->GetOrientation()); + Wrap = m_creature->SummonCreature(16486, LOC_X1, LOC_Y1, LOC_Z1, 0, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 120000); + break; + case 1: + DoTeleportPlayer(target, LOC_X2, LOC_Y2, LOC_Z2, target->GetOrientation()); + Wrap = m_creature->SummonCreature(16486, LOC_X2, LOC_Y2, LOC_Z2, 0, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 120000); + break; + case 2: + DoTeleportPlayer(target, LOC_X3, LOC_Y3, LOC_Z3, target->GetOrientation()); + Wrap = m_creature->SummonCreature(16486, LOC_X3, LOC_Y3, LOC_Z3, 0, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 120000); + break; + } + if(Wrap) + { + Wrap->setFaction(m_creature->getFaction()); + ((mob_webwrapAI*)Wrap->AI())->SetVictim(target); + } + } + } + } + + void UpdateAI(const uint32 diff) + { + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + //WebTrap_Timer + if (WebTrap_Timer < diff) + { + DoCastWebWrap(); + WebTrap_Timer = 40000; + }else WebTrap_Timer -= diff; + + //WebSpray_Timer + if (WebSpray_Timer < diff) + { + DoCast(m_creature->getVictim(), SPELL_WEBSPRAY); + WebSpray_Timer = 40000; + }else WebSpray_Timer -= diff; + + //PoisonShock_Timer + if (PoisonShock_Timer < diff) + { + DoCast(m_creature->getVictim(), SPELL_POISONSHOCK); + PoisonShock_Timer = 20000; + }else PoisonShock_Timer -= diff; + + //NecroticPoison_Timer + if (NecroticPoison_Timer < diff) + { + DoCast(m_creature->getVictim(), SPELL_NECROTICPOISON); + NecroticPoison_Timer = 30000; + }else NecroticPoison_Timer -= diff; + + //SummonSpiderling_Timer + if (SummonSpiderling_Timer < diff) + { + DoCast(m_creature, SPELL_SUMMON_SPIDERLING); + SummonSpiderling_Timer = 40000; + }else SummonSpiderling_Timer -= diff; + + //Enrage if not already enraged and below 30% + if (!Enraged && (m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < 30) + { + DoCast(m_creature,SPELL_ENRAGE); + Enraged = true; + } + + DoMeleeAttackIfReady(); + } +}; + +CreatureAI* GetAI_mob_webwrap(Creature* _Creature) +{ + return new mob_webwrapAI (_Creature); +} + +CreatureAI* GetAI_boss_maexxna(Creature *_Creature) +{ + return new boss_maexxnaAI (_Creature); +} + +void AddSC_boss_maexxna() +{ + Script *newscript; + + newscript = new Script; + newscript->Name="boss_maexxna"; + newscript->GetAI = GetAI_boss_maexxna; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="mob_webwrap"; + newscript->GetAI = GetAI_mob_webwrap; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/naxxramas/boss_noth.cpp b/src/bindings/scripts/scripts/zone/naxxramas/boss_noth.cpp index 1682344bf91..ada9ab75a91 100644 --- a/src/bindings/scripts/scripts/zone/naxxramas/boss_noth.cpp +++ b/src/bindings/scripts/scripts/zone/naxxramas/boss_noth.cpp @@ -1,180 +1,180 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Noth -SD%Complete: 40 -SDComment: Missing Balcony stage -SDCategory: Naxxramas -EndScriptData */ - -#include "precompiled.h" - -#define SAY_AGGRO1 "Glory to the master!" -#define SAY_AGGRO2 "Your life is forfeit!" -#define SAY_AGGRO3 "Die, trespasser!" -#define SAY_SUMMON "Rise, my soldiers! Rise and fight once more!" -#define SAY_SLAY1 "My task is done!" -#define SAY_SLAY2 "Breathe no more!" -#define SAY_DEATH "I will serve the master... in... death!" -#define SOUND_AGGRO1 8845 -#define SOUND_AGGRO2 8846 -#define SOUND_AGGRO3 8847 -#define SOUND_SUMMON 8851 -#define SOUND_SLAY1 8849 -#define SOUND_SLAY2 8850 -#define SOUND_DEATH 8848 - -// Teleport position of Noth on his balcony -#define TELE_X 2631.370 -#define TELE_Y -3529.680 -#define TELE_Z 274.040 -#define TELE_O 6.277 - -#define SPELL_BLINK 29211 -#define SPELL_CRIPPLE 29212 -#define SPELL_CURSEPLAGUEBRINGER 28213 -#define SPELL_WRATHPLAGUEBRINGER 28214 - -// IMPORTANT: BALCONY TELEPORT NOT ADDED YET! WILL BE ADDED SOON! - -struct MANGOS_DLL_DECL boss_nothAI : public ScriptedAI -{ - boss_nothAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 Blink_Timer; - uint32 Curse_Timer; - uint32 Wrath_Timer; - uint32 Summon_Timer; - - void Reset() - { - Blink_Timer = 25000; - Curse_Timer = 4000; - Wrath_Timer = 9000; - Summon_Timer = 12000; - } - - void Aggro(Unit *who) - { - switch (rand()%3) - { - case 0: - DoYell(SAY_AGGRO1,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_AGGRO1); - break; - case 1: - DoYell(SAY_AGGRO2,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_AGGRO2); - break; - case 2: - DoYell(SAY_AGGRO3,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_AGGRO3); - break; - } - } - - void KilledUnit(Unit* victim) - { - switch (rand()%2) - { - case 0: - DoYell(SAY_SLAY1,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_SLAY1); - break; - case 1: - DoYell(SAY_SLAY2,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_SLAY2); - break; - } - } - - void JustDied(Unit* Killer) - { - DoYell(SAY_DEATH,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_DEATH); - } - - void UpdateAI(const uint32 diff) - { - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - //Blink_Timer - if (Blink_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_CRIPPLE); - DoCast(m_creature,SPELL_BLINK); - - Blink_Timer = 25000; - }else Blink_Timer -= diff; - - //Curse_Timer - if (Curse_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_CURSEPLAGUEBRINGER); - Curse_Timer = 28000; - }else Curse_Timer -= diff; - - //Wrath_Timer - if (Wrath_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_WRATHPLAGUEBRINGER); - Wrath_Timer = 18000; - }else Wrath_Timer -= diff; - - //Summon_Timer - if (Summon_Timer < diff) - { - DoYell(SAY_SUMMON,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_SUMMON); - - Unit* target = NULL; - Unit* SummonedSkeletons = NULL; - - SummonedSkeletons = m_creature->SummonCreature(16984,2684.804,-3502.517,261.313,0,TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,80000); - SummonedSkeletons = m_creature->SummonCreature(16984,2684.804,-3502.517,261.313,0,TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,80000); - SummonedSkeletons = m_creature->SummonCreature(16984,2684.804,-3502.517,261.313,0,TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,80000); - SummonedSkeletons = m_creature->SummonCreature(16984,2684.804,-3502.517,261.313,0,TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,80000); - SummonedSkeletons = m_creature->SummonCreature(16984,2684.804,-3502.517,261.313,0,TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,80000); - SummonedSkeletons = m_creature->SummonCreature(16984,2684.804,-3502.517,261.313,0,TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,80000); - - if (SummonedSkeletons) - { - target = SelectUnit(SELECT_TARGET_RANDOM,0); - if (target) - SummonedSkeletons->AddThreat(target,1.0f); - } - - Summon_Timer = 30500; - } else Summon_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; -CreatureAI* GetAI_boss_noth(Creature *_Creature) -{ - return new boss_nothAI (_Creature); -} - -void AddSC_boss_noth() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_noth"; - newscript->GetAI = GetAI_boss_noth; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Noth +SD%Complete: 40 +SDComment: Missing Balcony stage +SDCategory: Naxxramas +EndScriptData */ + +#include "precompiled.h" + +#define SAY_AGGRO1 "Glory to the master!" +#define SAY_AGGRO2 "Your life is forfeit!" +#define SAY_AGGRO3 "Die, trespasser!" +#define SAY_SUMMON "Rise, my soldiers! Rise and fight once more!" +#define SAY_SLAY1 "My task is done!" +#define SAY_SLAY2 "Breathe no more!" +#define SAY_DEATH "I will serve the master... in... death!" +#define SOUND_AGGRO1 8845 +#define SOUND_AGGRO2 8846 +#define SOUND_AGGRO3 8847 +#define SOUND_SUMMON 8851 +#define SOUND_SLAY1 8849 +#define SOUND_SLAY2 8850 +#define SOUND_DEATH 8848 + +// Teleport position of Noth on his balcony +#define TELE_X 2631.370 +#define TELE_Y -3529.680 +#define TELE_Z 274.040 +#define TELE_O 6.277 + +#define SPELL_BLINK 29211 +#define SPELL_CRIPPLE 29212 +#define SPELL_CURSEPLAGUEBRINGER 28213 +#define SPELL_WRATHPLAGUEBRINGER 28214 + +// IMPORTANT: BALCONY TELEPORT NOT ADDED YET! WILL BE ADDED SOON! + +struct MANGOS_DLL_DECL boss_nothAI : public ScriptedAI +{ + boss_nothAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 Blink_Timer; + uint32 Curse_Timer; + uint32 Wrath_Timer; + uint32 Summon_Timer; + + void Reset() + { + Blink_Timer = 25000; + Curse_Timer = 4000; + Wrath_Timer = 9000; + Summon_Timer = 12000; + } + + void Aggro(Unit *who) + { + switch (rand()%3) + { + case 0: + DoYell(SAY_AGGRO1,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_AGGRO1); + break; + case 1: + DoYell(SAY_AGGRO2,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_AGGRO2); + break; + case 2: + DoYell(SAY_AGGRO3,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_AGGRO3); + break; + } + } + + void KilledUnit(Unit* victim) + { + switch (rand()%2) + { + case 0: + DoYell(SAY_SLAY1,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_SLAY1); + break; + case 1: + DoYell(SAY_SLAY2,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_SLAY2); + break; + } + } + + void JustDied(Unit* Killer) + { + DoYell(SAY_DEATH,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_DEATH); + } + + void UpdateAI(const uint32 diff) + { + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + //Blink_Timer + if (Blink_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_CRIPPLE); + DoCast(m_creature,SPELL_BLINK); + + Blink_Timer = 25000; + }else Blink_Timer -= diff; + + //Curse_Timer + if (Curse_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_CURSEPLAGUEBRINGER); + Curse_Timer = 28000; + }else Curse_Timer -= diff; + + //Wrath_Timer + if (Wrath_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_WRATHPLAGUEBRINGER); + Wrath_Timer = 18000; + }else Wrath_Timer -= diff; + + //Summon_Timer + if (Summon_Timer < diff) + { + DoYell(SAY_SUMMON,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_SUMMON); + + Unit* target = NULL; + Unit* SummonedSkeletons = NULL; + + SummonedSkeletons = m_creature->SummonCreature(16984,2684.804,-3502.517,261.313,0,TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,80000); + SummonedSkeletons = m_creature->SummonCreature(16984,2684.804,-3502.517,261.313,0,TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,80000); + SummonedSkeletons = m_creature->SummonCreature(16984,2684.804,-3502.517,261.313,0,TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,80000); + SummonedSkeletons = m_creature->SummonCreature(16984,2684.804,-3502.517,261.313,0,TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,80000); + SummonedSkeletons = m_creature->SummonCreature(16984,2684.804,-3502.517,261.313,0,TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,80000); + SummonedSkeletons = m_creature->SummonCreature(16984,2684.804,-3502.517,261.313,0,TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,80000); + + if (SummonedSkeletons) + { + target = SelectUnit(SELECT_TARGET_RANDOM,0); + if (target) + SummonedSkeletons->AddThreat(target,1.0f); + } + + Summon_Timer = 30500; + } else Summon_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; +CreatureAI* GetAI_boss_noth(Creature *_Creature) +{ + return new boss_nothAI (_Creature); +} + +void AddSC_boss_noth() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_noth"; + newscript->GetAI = GetAI_boss_noth; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/naxxramas/boss_patchwerk.cpp b/src/bindings/scripts/scripts/zone/naxxramas/boss_patchwerk.cpp index d8a8f73fd69..7fc0461c630 100644 --- a/src/bindings/scripts/scripts/zone/naxxramas/boss_patchwerk.cpp +++ b/src/bindings/scripts/scripts/zone/naxxramas/boss_patchwerk.cpp @@ -1,160 +1,160 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Patchwerk -SD%Complete: 100 -SDComment: Some issues with hateful strike inturrupting the melee swing timer. Probably core issue. -SDCategory: Naxxramas -EndScriptData */ - -#include "precompiled.h" - -#define SAY_AGGRO1 "Patchwerk want to play!" -#define SAY_AGGRO2 "Kel'Thuzad make Patchwerk his Avatar of War!" -#define SAY_SLAY "No more play?" -#define SAY_DEATH "What happened to... Patch..." - -#define SOUND_AGGRO1 8909 -#define SOUND_AGGRO2 8910 -#define SOUND_SLAY 8912 -#define SOUND_DEATH 8911 - -#define EMOTE_BERSERK "Patchwerk goes into a berserker rage!" -#define EMOTE_ENRAGE "Patchwerk becomes enraged!" - -#define SPELL_HATEFULSTRIKE 28308 -#define SPELL_ENRAGE 29691 -#define SPELL_BERSERK 27680 -#define SPELL_SLIMEBOLT 32309 - -struct MANGOS_DLL_DECL boss_patchwerkAI : public ScriptedAI -{ - boss_patchwerkAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 HatefullStrike_Timer; - uint32 Enrage_Timer; - uint32 Slimebolt_Timer; - bool Enraged; - - void Reset() - { - HatefullStrike_Timer = 1200; //1.2 seconds - Enrage_Timer = 420000; //7 minutes 420,000 - Slimebolt_Timer = 450000; //7.5 minutes 450,000 - Enraged = false; - } - - void KilledUnit(Unit* Victim) - { - if (rand()%5) - return; - - DoYell(SAY_SLAY, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_SLAY); - } - - void JustDied(Unit* Killer) - { - DoYell(SAY_DEATH, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_DEATH); - } - - void Aggro(Unit *who) - { - if (rand()%2) - { - DoYell(SAY_AGGRO1, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_AGGRO1); - } - else - { - DoYell(SAY_AGGRO2, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_AGGRO2); - } - } - - void UpdateAI(const uint32 diff) - { - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - //HatefullStrike_Timer - if (HatefullStrike_Timer < diff) - { - //Cast Hateful strike on the player with the highest - //amount of HP within melee distance - uint32 MostHP = 0; - Unit* pMostHPTarget = NULL; - Unit* pTemp = NULL; - std::list::iterator i = m_creature->getThreatManager().getThreatList().begin(); - - for (i = m_creature->getThreatManager().getThreatList().begin(); i!=m_creature->getThreatManager().getThreatList().end(); ++i) - { - pTemp = Unit::GetUnit((*m_creature),(*i)->getUnitGuid()); - if (pTemp && pTemp->isAlive() && pTemp->GetHealth() > MostHP && m_creature->GetDistance2d(pTemp) < 5) - { - MostHP = pTemp->GetHealth(); - pMostHPTarget = pTemp; - } - } - - if (pMostHPTarget) - DoCast(pMostHPTarget, SPELL_HATEFULSTRIKE); - - HatefullStrike_Timer = 1200; - }else HatefullStrike_Timer -= diff; - - //Enrage_Timer - if (Enrage_Timer < diff) - { - DoCast(m_creature, SPELL_BERSERK); - DoTextEmote(EMOTE_BERSERK, m_creature->getVictim()); - - Enrage_Timer = 300000; - }else Enrage_Timer -= diff; - - //Slimebolt_Timer - if (Slimebolt_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_SLIMEBOLT); - Slimebolt_Timer = 5000; - }else Slimebolt_Timer -= diff; - - //Enrage if not already enraged and below 5% - if (!Enraged && (m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < 5) - { - DoCast(m_creature,SPELL_ENRAGE); - DoTextEmote(EMOTE_ENRAGE,NULL); - Enraged = true; - } - - DoMeleeAttackIfReady(); - } -}; -CreatureAI* GetAI_boss_patchwerk(Creature *_Creature) -{ - return new boss_patchwerkAI (_Creature); -} - -void AddSC_boss_patchwerk() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_patchwerk"; - newscript->GetAI = GetAI_boss_patchwerk; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Patchwerk +SD%Complete: 100 +SDComment: Some issues with hateful strike inturrupting the melee swing timer. Probably core issue. +SDCategory: Naxxramas +EndScriptData */ + +#include "precompiled.h" + +#define SAY_AGGRO1 "Patchwerk want to play!" +#define SAY_AGGRO2 "Kel'Thuzad make Patchwerk his Avatar of War!" +#define SAY_SLAY "No more play?" +#define SAY_DEATH "What happened to... Patch..." + +#define SOUND_AGGRO1 8909 +#define SOUND_AGGRO2 8910 +#define SOUND_SLAY 8912 +#define SOUND_DEATH 8911 + +#define EMOTE_BERSERK "Patchwerk goes into a berserker rage!" +#define EMOTE_ENRAGE "Patchwerk becomes enraged!" + +#define SPELL_HATEFULSTRIKE 28308 +#define SPELL_ENRAGE 29691 +#define SPELL_BERSERK 27680 +#define SPELL_SLIMEBOLT 32309 + +struct MANGOS_DLL_DECL boss_patchwerkAI : public ScriptedAI +{ + boss_patchwerkAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 HatefullStrike_Timer; + uint32 Enrage_Timer; + uint32 Slimebolt_Timer; + bool Enraged; + + void Reset() + { + HatefullStrike_Timer = 1200; //1.2 seconds + Enrage_Timer = 420000; //7 minutes 420,000 + Slimebolt_Timer = 450000; //7.5 minutes 450,000 + Enraged = false; + } + + void KilledUnit(Unit* Victim) + { + if (rand()%5) + return; + + DoYell(SAY_SLAY, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_SLAY); + } + + void JustDied(Unit* Killer) + { + DoYell(SAY_DEATH, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_DEATH); + } + + void Aggro(Unit *who) + { + if (rand()%2) + { + DoYell(SAY_AGGRO1, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_AGGRO1); + } + else + { + DoYell(SAY_AGGRO2, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_AGGRO2); + } + } + + void UpdateAI(const uint32 diff) + { + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + //HatefullStrike_Timer + if (HatefullStrike_Timer < diff) + { + //Cast Hateful strike on the player with the highest + //amount of HP within melee distance + uint32 MostHP = 0; + Unit* pMostHPTarget = NULL; + Unit* pTemp = NULL; + std::list::iterator i = m_creature->getThreatManager().getThreatList().begin(); + + for (i = m_creature->getThreatManager().getThreatList().begin(); i!=m_creature->getThreatManager().getThreatList().end(); ++i) + { + pTemp = Unit::GetUnit((*m_creature),(*i)->getUnitGuid()); + if (pTemp && pTemp->isAlive() && pTemp->GetHealth() > MostHP && m_creature->GetDistance2d(pTemp) < 5) + { + MostHP = pTemp->GetHealth(); + pMostHPTarget = pTemp; + } + } + + if (pMostHPTarget) + DoCast(pMostHPTarget, SPELL_HATEFULSTRIKE); + + HatefullStrike_Timer = 1200; + }else HatefullStrike_Timer -= diff; + + //Enrage_Timer + if (Enrage_Timer < diff) + { + DoCast(m_creature, SPELL_BERSERK); + DoTextEmote(EMOTE_BERSERK, m_creature->getVictim()); + + Enrage_Timer = 300000; + }else Enrage_Timer -= diff; + + //Slimebolt_Timer + if (Slimebolt_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_SLIMEBOLT); + Slimebolt_Timer = 5000; + }else Slimebolt_Timer -= diff; + + //Enrage if not already enraged and below 5% + if (!Enraged && (m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < 5) + { + DoCast(m_creature,SPELL_ENRAGE); + DoTextEmote(EMOTE_ENRAGE,NULL); + Enraged = true; + } + + DoMeleeAttackIfReady(); + } +}; +CreatureAI* GetAI_boss_patchwerk(Creature *_Creature) +{ + return new boss_patchwerkAI (_Creature); +} + +void AddSC_boss_patchwerk() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_patchwerk"; + newscript->GetAI = GetAI_boss_patchwerk; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/naxxramas/boss_razuvious.cpp b/src/bindings/scripts/scripts/zone/naxxramas/boss_razuvious.cpp index 707ec574076..d193b7224c5 100644 --- a/src/bindings/scripts/scripts/zone/naxxramas/boss_razuvious.cpp +++ b/src/bindings/scripts/scripts/zone/naxxramas/boss_razuvious.cpp @@ -1,167 +1,167 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Razuvious -SD%Complete: 50 -SDComment: Missing adds and event is impossible without Mind Control -SDCategory: Naxxramas -EndScriptData */ - -#include "precompiled.h" - -//Razuvious - NO TEXT sound only -//8852 aggro01 - Hah hah, I'm just getting warmed up! -//8853 aggro02 Stand and fight! -//8854 aggro03 Show me what you've got! -//8861 slay1 - You should've stayed home! -//8863 slay2- -//8858 cmmnd3 - You disappoint me, students! -//8855 cmmnd1 - Do as I taught you! -//8856 cmmnd2 - Show them no mercy! -//8859 cmmnd4 - The time for practice is over! Show me what you've learned! -//8861 Sweep the leg! Do you have a problem with that? -//8860 death - An honorable... death... -//8947 - Aggro Mixed? - ? - -#define SOUND_AGGRO1 8852 -#define SOUND_AGGRO2 8853 -#define SOUND_AGGRO3 8854 -#define SOUND_SLAY1 8861 -#define SOUND_SLAY2 8863 -#define SOUND_COMMND1 8855 -#define SOUND_COMMND2 8856 -#define SOUND_COMMND3 8858 -#define SOUND_COMMND4 8859 -#define SOUND_COMMND5 8861 -#define SOUND_DEATH 8860 -#define SOUND_AGGROMIX 8847 - -#define SPELL_UNBALANCINGSTRIKE 26613 -#define SPELL_DISRUPTINGSHOUT 29107 - -struct MANGOS_DLL_DECL boss_razuviousAI : public ScriptedAI -{ - boss_razuviousAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 UnbalancingStrike_Timer; - uint32 DisruptingShout_Timer; - uint32 CommandSound_Timer; - - void Reset() - { - UnbalancingStrike_Timer = 30000; //30 seconds - DisruptingShout_Timer = 25000; //25 seconds - CommandSound_Timer = 40000; //40 seconds - } - - void KilledUnit(Unit* Victim) - { - if (rand()%3) - return; - - switch (rand()%2) - { - case 0: - DoPlaySoundToSet(m_creature, SOUND_SLAY1); - break; - case 1: - DoPlaySoundToSet(m_creature, SOUND_SLAY2); - break; - } - } - - void JustDied(Unit* Killer) - { - DoPlaySoundToSet(m_creature, SOUND_DEATH); - } - - void Aggro(Unit *who) - { - switch (rand()%3) - { - case 0: - DoPlaySoundToSet(m_creature, SOUND_AGGRO1); - break; - case 1: - DoPlaySoundToSet(m_creature, SOUND_AGGRO2); - break; - case 2: - DoPlaySoundToSet(m_creature, SOUND_AGGRO3); - break; - } - } - - void UpdateAI(const uint32 diff) - { - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - //UnbalancingStrike_Timer - if (UnbalancingStrike_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_UNBALANCINGSTRIKE); - UnbalancingStrike_Timer = 30000; - }else UnbalancingStrike_Timer -= diff; - - //DisruptingShout_Timer - if (DisruptingShout_Timer < diff) - { - DoCast(m_creature->getVictim(), SPELL_DISRUPTINGSHOUT); - DisruptingShout_Timer = 25000; - }else DisruptingShout_Timer -= diff; - - //CommandSound_Timer - if (CommandSound_Timer < diff) - { - switch (rand()%5) - { - case 0: - DoPlaySoundToSet(m_creature, SOUND_COMMND1); - break; - case 1: - DoPlaySoundToSet(m_creature, SOUND_COMMND2); - break; - case 2: - DoPlaySoundToSet(m_creature, SOUND_COMMND3); - break; - case 3: - DoPlaySoundToSet(m_creature, SOUND_COMMND4); - break; - case 4: - DoPlaySoundToSet(m_creature, SOUND_COMMND5); - break; - } - - CommandSound_Timer = 40000; - }else CommandSound_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; -CreatureAI* GetAI_boss_razuvious(Creature *_Creature) -{ - return new boss_razuviousAI (_Creature); -} - -void AddSC_boss_razuvious() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_razuvious"; - newscript->GetAI = GetAI_boss_razuvious; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Razuvious +SD%Complete: 50 +SDComment: Missing adds and event is impossible without Mind Control +SDCategory: Naxxramas +EndScriptData */ + +#include "precompiled.h" + +//Razuvious - NO TEXT sound only +//8852 aggro01 - Hah hah, I'm just getting warmed up! +//8853 aggro02 Stand and fight! +//8854 aggro03 Show me what you've got! +//8861 slay1 - You should've stayed home! +//8863 slay2- +//8858 cmmnd3 - You disappoint me, students! +//8855 cmmnd1 - Do as I taught you! +//8856 cmmnd2 - Show them no mercy! +//8859 cmmnd4 - The time for practice is over! Show me what you've learned! +//8861 Sweep the leg! Do you have a problem with that? +//8860 death - An honorable... death... +//8947 - Aggro Mixed? - ? + +#define SOUND_AGGRO1 8852 +#define SOUND_AGGRO2 8853 +#define SOUND_AGGRO3 8854 +#define SOUND_SLAY1 8861 +#define SOUND_SLAY2 8863 +#define SOUND_COMMND1 8855 +#define SOUND_COMMND2 8856 +#define SOUND_COMMND3 8858 +#define SOUND_COMMND4 8859 +#define SOUND_COMMND5 8861 +#define SOUND_DEATH 8860 +#define SOUND_AGGROMIX 8847 + +#define SPELL_UNBALANCINGSTRIKE 26613 +#define SPELL_DISRUPTINGSHOUT 29107 + +struct MANGOS_DLL_DECL boss_razuviousAI : public ScriptedAI +{ + boss_razuviousAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 UnbalancingStrike_Timer; + uint32 DisruptingShout_Timer; + uint32 CommandSound_Timer; + + void Reset() + { + UnbalancingStrike_Timer = 30000; //30 seconds + DisruptingShout_Timer = 25000; //25 seconds + CommandSound_Timer = 40000; //40 seconds + } + + void KilledUnit(Unit* Victim) + { + if (rand()%3) + return; + + switch (rand()%2) + { + case 0: + DoPlaySoundToSet(m_creature, SOUND_SLAY1); + break; + case 1: + DoPlaySoundToSet(m_creature, SOUND_SLAY2); + break; + } + } + + void JustDied(Unit* Killer) + { + DoPlaySoundToSet(m_creature, SOUND_DEATH); + } + + void Aggro(Unit *who) + { + switch (rand()%3) + { + case 0: + DoPlaySoundToSet(m_creature, SOUND_AGGRO1); + break; + case 1: + DoPlaySoundToSet(m_creature, SOUND_AGGRO2); + break; + case 2: + DoPlaySoundToSet(m_creature, SOUND_AGGRO3); + break; + } + } + + void UpdateAI(const uint32 diff) + { + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + //UnbalancingStrike_Timer + if (UnbalancingStrike_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_UNBALANCINGSTRIKE); + UnbalancingStrike_Timer = 30000; + }else UnbalancingStrike_Timer -= diff; + + //DisruptingShout_Timer + if (DisruptingShout_Timer < diff) + { + DoCast(m_creature->getVictim(), SPELL_DISRUPTINGSHOUT); + DisruptingShout_Timer = 25000; + }else DisruptingShout_Timer -= diff; + + //CommandSound_Timer + if (CommandSound_Timer < diff) + { + switch (rand()%5) + { + case 0: + DoPlaySoundToSet(m_creature, SOUND_COMMND1); + break; + case 1: + DoPlaySoundToSet(m_creature, SOUND_COMMND2); + break; + case 2: + DoPlaySoundToSet(m_creature, SOUND_COMMND3); + break; + case 3: + DoPlaySoundToSet(m_creature, SOUND_COMMND4); + break; + case 4: + DoPlaySoundToSet(m_creature, SOUND_COMMND5); + break; + } + + CommandSound_Timer = 40000; + }else CommandSound_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; +CreatureAI* GetAI_boss_razuvious(Creature *_Creature) +{ + return new boss_razuviousAI (_Creature); +} + +void AddSC_boss_razuvious() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_razuvious"; + newscript->GetAI = GetAI_boss_razuvious; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/naxxramas/boss_sapphiron.cpp b/src/bindings/scripts/scripts/zone/naxxramas/boss_sapphiron.cpp index f27375f2835..0dd190bab7c 100644 --- a/src/bindings/scripts/scripts/zone/naxxramas/boss_sapphiron.cpp +++ b/src/bindings/scripts/scripts/zone/naxxramas/boss_sapphiron.cpp @@ -1,199 +1,199 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Sapphiron -SD%Complete: 0 -SDComment: Place Holder -SDCategory: Naxxramas -EndScriptData */ - -#include "precompiled.h" - -#define SPELL_ICEBOLT 28522 -#define SPELL_FROST_BREATH 29318 -#define SPELL_FROST_AURA 28531 -#define SPELL_LIFE_DRAIN 28542 -#define SPELL_BLIZZARD 28547 -#define SPELL_BESERK 26662 - -struct MANGOS_DLL_DECL boss_sapphironAI : public ScriptedAI -{ - boss_sapphironAI(Creature* c) : ScriptedAI(c) - { - Reset(); - } - - uint32 Icebolt_Count; - uint32 Icebolt_Timer; - uint32 FrostBreath_Timer; - uint32 FrostAura_Timer; - uint32 LifeDrain_Timer; - uint32 Blizzard_Timer; - uint32 Fly_Timer; - uint32 Fly2_Timer; - uint32 Beserk_Timer; - uint32 phase; - bool landoff; - uint32 land_Timer; - - void Reset() - { - FrostAura_Timer = 2000; - LifeDrain_Timer = 24000; - Blizzard_Timer = 20000; - Fly_Timer = 45000; - Icebolt_Timer = 4000; - land_Timer = 2000; - Beserk_Timer = 0; - phase = 1; - Icebolt_Count = 0; - landoff = false; - - //m_creature->ApplySpellMod(SPELL_FROST_AURA, SPELLMOD_DURATION, -1); - } - - void Aggro(Unit *who) - { - } - - void UpdateAI(const uint32 diff) - { - if(!m_creature->SelectHostilTarget()) - return; - - if(m_creature->getVictim() && m_creature->isAlive()) - { - if(phase == 1) - { - if(FrostAura_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_FROST_AURA); - FrostAura_Timer = 5000; - }else FrostAura_Timer -= diff; - - if(LifeDrain_Timer < diff) - { - Unit* target = NULL; - target = SelectUnit(SELECT_TARGET_RANDOM,0); - - DoCast(target,SPELL_LIFE_DRAIN); - LifeDrain_Timer = 24000; - }else LifeDrain_Timer -= diff; - - if(Blizzard_Timer < diff) - { - Unit* target = NULL; - target = SelectUnit(SELECT_TARGET_RANDOM,0); - - DoCast(target,SPELL_BLIZZARD); - Blizzard_Timer = 20000; - }else Blizzard_Timer -= diff; - - if (m_creature->GetHealth()*100 / m_creature->GetMaxHealth() > 10) - { - if(Fly_Timer < diff) - { - phase = 2; - m_creature->InterruptNonMeleeSpells(false); - m_creature->HandleEmoteCommand(EMOTE_ONESHOT_LIFTOFF); - (*m_creature).GetMotionMaster()->Clear(false); - (*m_creature).GetMotionMaster()->MoveIdle(); - DoCast(m_creature,11010); - m_creature->SetHover(true); - DoCast(m_creature,18430); - Icebolt_Timer = 4000; - Icebolt_Count = 0; - landoff = false; - }else Fly_Timer -= diff; - } - - if (phase == 2) - { - if(Icebolt_Timer < diff && Icebolt_Count < 5) - { - Unit* target = NULL; - - target = SelectUnit(SELECT_TARGET_RANDOM,0); - - DoCast(target,SPELL_ICEBOLT); - Icebolt_Count ++; - Icebolt_Timer = 4000; - }else Icebolt_Timer -= diff; - - if(Icebolt_Count == 5 && !landoff) - { - if(FrostBreath_Timer < diff ) - { - DoTextEmote("takes a deep breath...",NULL); - DoCast(m_creature->getVictim(),SPELL_FROST_BREATH); - land_Timer = 2000; - landoff = true; - FrostBreath_Timer = 6000; - }else FrostBreath_Timer -= diff; - } - - if(landoff) - { - if(land_Timer < diff) - { - phase = 1; - m_creature->HandleEmoteCommand(EMOTE_ONESHOT_LAND); - m_creature->SetHover(false); - (*m_creature).GetMotionMaster()->Clear(false); - (*m_creature).GetMotionMaster()->MoveChase(m_creature->getVictim()); - Fly_Timer = 67000; - }else land_Timer -= diff; - } - - } - - if ((m_creature->GetHealth()*100) / m_creature->GetMaxHealth() < 11) - { - if (Beserk_Timer < diff) - { - DoTextEmote("enrages!",NULL); - DoCast(m_creature,SPELL_BESERK); - Beserk_Timer = 300000; - }else Beserk_Timer -= diff; - } - - if( phase!=2 && m_creature->getVictim() && m_creature->IsWithinDistInMap(m_creature->getVictim(), ATTACK_DISTANCE)) - { - if( m_creature->isAttackReady() ) - { - m_creature->AttackerStateUpdate(m_creature->getVictim()); - m_creature->resetAttackTimer(); - } - } - } - } - } -}; - -CreatureAI* GetAI_boss_sapphiron(Creature *_Creature) -{ - return new boss_sapphironAI (_Creature); -} - -void AddSC_boss_sapphiron() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_sapphiron"; - newscript->GetAI = GetAI_boss_sapphiron; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Sapphiron +SD%Complete: 0 +SDComment: Place Holder +SDCategory: Naxxramas +EndScriptData */ + +#include "precompiled.h" + +#define SPELL_ICEBOLT 28522 +#define SPELL_FROST_BREATH 29318 +#define SPELL_FROST_AURA 28531 +#define SPELL_LIFE_DRAIN 28542 +#define SPELL_BLIZZARD 28547 +#define SPELL_BESERK 26662 + +struct MANGOS_DLL_DECL boss_sapphironAI : public ScriptedAI +{ + boss_sapphironAI(Creature* c) : ScriptedAI(c) + { + Reset(); + } + + uint32 Icebolt_Count; + uint32 Icebolt_Timer; + uint32 FrostBreath_Timer; + uint32 FrostAura_Timer; + uint32 LifeDrain_Timer; + uint32 Blizzard_Timer; + uint32 Fly_Timer; + uint32 Fly2_Timer; + uint32 Beserk_Timer; + uint32 phase; + bool landoff; + uint32 land_Timer; + + void Reset() + { + FrostAura_Timer = 2000; + LifeDrain_Timer = 24000; + Blizzard_Timer = 20000; + Fly_Timer = 45000; + Icebolt_Timer = 4000; + land_Timer = 2000; + Beserk_Timer = 0; + phase = 1; + Icebolt_Count = 0; + landoff = false; + + //m_creature->ApplySpellMod(SPELL_FROST_AURA, SPELLMOD_DURATION, -1); + } + + void Aggro(Unit *who) + { + } + + void UpdateAI(const uint32 diff) + { + if(!m_creature->SelectHostilTarget()) + return; + + if(m_creature->getVictim() && m_creature->isAlive()) + { + if(phase == 1) + { + if(FrostAura_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_FROST_AURA); + FrostAura_Timer = 5000; + }else FrostAura_Timer -= diff; + + if(LifeDrain_Timer < diff) + { + Unit* target = NULL; + target = SelectUnit(SELECT_TARGET_RANDOM,0); + + DoCast(target,SPELL_LIFE_DRAIN); + LifeDrain_Timer = 24000; + }else LifeDrain_Timer -= diff; + + if(Blizzard_Timer < diff) + { + Unit* target = NULL; + target = SelectUnit(SELECT_TARGET_RANDOM,0); + + DoCast(target,SPELL_BLIZZARD); + Blizzard_Timer = 20000; + }else Blizzard_Timer -= diff; + + if (m_creature->GetHealth()*100 / m_creature->GetMaxHealth() > 10) + { + if(Fly_Timer < diff) + { + phase = 2; + m_creature->InterruptNonMeleeSpells(false); + m_creature->HandleEmoteCommand(EMOTE_ONESHOT_LIFTOFF); + (*m_creature).GetMotionMaster()->Clear(false); + (*m_creature).GetMotionMaster()->MoveIdle(); + DoCast(m_creature,11010); + m_creature->SetHover(true); + DoCast(m_creature,18430); + Icebolt_Timer = 4000; + Icebolt_Count = 0; + landoff = false; + }else Fly_Timer -= diff; + } + + if (phase == 2) + { + if(Icebolt_Timer < diff && Icebolt_Count < 5) + { + Unit* target = NULL; + + target = SelectUnit(SELECT_TARGET_RANDOM,0); + + DoCast(target,SPELL_ICEBOLT); + Icebolt_Count ++; + Icebolt_Timer = 4000; + }else Icebolt_Timer -= diff; + + if(Icebolt_Count == 5 && !landoff) + { + if(FrostBreath_Timer < diff ) + { + DoTextEmote("takes a deep breath...",NULL); + DoCast(m_creature->getVictim(),SPELL_FROST_BREATH); + land_Timer = 2000; + landoff = true; + FrostBreath_Timer = 6000; + }else FrostBreath_Timer -= diff; + } + + if(landoff) + { + if(land_Timer < diff) + { + phase = 1; + m_creature->HandleEmoteCommand(EMOTE_ONESHOT_LAND); + m_creature->SetHover(false); + (*m_creature).GetMotionMaster()->Clear(false); + (*m_creature).GetMotionMaster()->MoveChase(m_creature->getVictim()); + Fly_Timer = 67000; + }else land_Timer -= diff; + } + + } + + if ((m_creature->GetHealth()*100) / m_creature->GetMaxHealth() < 11) + { + if (Beserk_Timer < diff) + { + DoTextEmote("enrages!",NULL); + DoCast(m_creature,SPELL_BESERK); + Beserk_Timer = 300000; + }else Beserk_Timer -= diff; + } + + if( phase!=2 && m_creature->getVictim() && m_creature->IsWithinDistInMap(m_creature->getVictim(), ATTACK_DISTANCE)) + { + if( m_creature->isAttackReady() ) + { + m_creature->AttackerStateUpdate(m_creature->getVictim()); + m_creature->resetAttackTimer(); + } + } + } + } + } +}; + +CreatureAI* GetAI_boss_sapphiron(Creature *_Creature) +{ + return new boss_sapphironAI (_Creature); +} + +void AddSC_boss_sapphiron() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_sapphiron"; + newscript->GetAI = GetAI_boss_sapphiron; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/naxxramas/boss_sir_zeliek.cpp b/src/bindings/scripts/scripts/zone/naxxramas/boss_sir_zeliek.cpp index 717e84ca984..9bd006b1a85 100644 --- a/src/bindings/scripts/scripts/zone/naxxramas/boss_sir_zeliek.cpp +++ b/src/bindings/scripts/scripts/zone/naxxramas/boss_sir_zeliek.cpp @@ -1,146 +1,146 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Sir_Zeliek -SD%Complete: 100 -SDComment: -SDCategory: Naxxramas -EndScriptData */ - -#include "precompiled.h" - -//All horsemen -#define SPELL_SHIELDWALL 29061 -#define SPELL_BESERK 26662 - -// sir zeliek -#define SPELL_MARK_OF_ZELIEK 28835 -#define SPELL_HOLY_WRATH 28883 - -#define SAY_AGGRO "Flee, before it's too late!" -#define SAY_TAUNT1 "Invaders, cease this foolish venture at once! Turn away while you still can!" -#define SAY_TAUNT2 "Perhaps they will come to their senses, and run away as fast as they can!" -#define SAY_TAUNT3 "Do not continue! Turn back while there's still time!" -#define SAY_SPECIAL "I- I have no choice but to obey!" -#define SAY_SLAY "Forgive me!" -#define SAY_DEATH "It is... as it should be." - -#define SOUND_AGGRO 8913 -#define SOUND_TAUNT1 8917 -#define SOUND_TAUNT2 8918 -#define SOUND_TAUNT3 8919 -#define SOUND_SPECIAl 8916 -#define SOUND_SLAY 8915 -#define SOUND_DEATH 8914 - -struct MANGOS_DLL_DECL boss_sir_zeliekAI : public ScriptedAI -{ - boss_sir_zeliekAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 Mark_Timer; - uint32 HolyWrath_Timer; - bool ShieldWall1; - bool ShieldWall2; - - void Reset() - { - Mark_Timer = 20000; // First Horsemen Mark is applied at 20 sec. - HolyWrath_Timer = 12000; // right - ShieldWall1 = true; - ShieldWall2 = true; - } - - void InitialYell() - { - if(!InCombat) - { - DoYell(SAY_AGGRO,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_AGGRO); - } - } - - void KilledUnit() - { - DoYell(SAY_SLAY,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_SLAY); - } - - void JustDied(Unit* Killer) - { - DoYell(SAY_DEATH,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature, SOUND_DEATH); - } - - void Aggro(Unit *who) - { - InitialYell(); - } - - void UpdateAI(const uint32 diff) - { - //Return since we have no target - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - // Mark of Zeliek - if(Mark_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_MARK_OF_ZELIEK); - Mark_Timer = 12000; - }else Mark_Timer -= diff; - - // Shield Wall - All 4 horsemen will shield wall at 50% hp and 20% hp for 20 seconds - if(ShieldWall1 && (m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < 50) - { - if(ShieldWall1) - { - DoCast(m_creature,SPELL_SHIELDWALL); - ShieldWall1 = false; - } - } - if(ShieldWall2 && (m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < 20) - { - if(ShieldWall2) - { - DoCast(m_creature,SPELL_SHIELDWALL); - ShieldWall2 = false; - } - } - - // Holy Wrath - if(HolyWrath_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_HOLY_WRATH); - HolyWrath_Timer = 12000; - }else HolyWrath_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; -CreatureAI* GetAI_boss_sir_zeliek(Creature *_Creature) -{ - return new boss_sir_zeliekAI (_Creature); -} - -void AddSC_boss_sir_zeliek() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_sir_zeliek"; - newscript->GetAI = GetAI_boss_sir_zeliek; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Sir_Zeliek +SD%Complete: 100 +SDComment: +SDCategory: Naxxramas +EndScriptData */ + +#include "precompiled.h" + +//All horsemen +#define SPELL_SHIELDWALL 29061 +#define SPELL_BESERK 26662 + +// sir zeliek +#define SPELL_MARK_OF_ZELIEK 28835 +#define SPELL_HOLY_WRATH 28883 + +#define SAY_AGGRO "Flee, before it's too late!" +#define SAY_TAUNT1 "Invaders, cease this foolish venture at once! Turn away while you still can!" +#define SAY_TAUNT2 "Perhaps they will come to their senses, and run away as fast as they can!" +#define SAY_TAUNT3 "Do not continue! Turn back while there's still time!" +#define SAY_SPECIAL "I- I have no choice but to obey!" +#define SAY_SLAY "Forgive me!" +#define SAY_DEATH "It is... as it should be." + +#define SOUND_AGGRO 8913 +#define SOUND_TAUNT1 8917 +#define SOUND_TAUNT2 8918 +#define SOUND_TAUNT3 8919 +#define SOUND_SPECIAl 8916 +#define SOUND_SLAY 8915 +#define SOUND_DEATH 8914 + +struct MANGOS_DLL_DECL boss_sir_zeliekAI : public ScriptedAI +{ + boss_sir_zeliekAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 Mark_Timer; + uint32 HolyWrath_Timer; + bool ShieldWall1; + bool ShieldWall2; + + void Reset() + { + Mark_Timer = 20000; // First Horsemen Mark is applied at 20 sec. + HolyWrath_Timer = 12000; // right + ShieldWall1 = true; + ShieldWall2 = true; + } + + void InitialYell() + { + if(!InCombat) + { + DoYell(SAY_AGGRO,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_AGGRO); + } + } + + void KilledUnit() + { + DoYell(SAY_SLAY,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_SLAY); + } + + void JustDied(Unit* Killer) + { + DoYell(SAY_DEATH,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature, SOUND_DEATH); + } + + void Aggro(Unit *who) + { + InitialYell(); + } + + void UpdateAI(const uint32 diff) + { + //Return since we have no target + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + // Mark of Zeliek + if(Mark_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_MARK_OF_ZELIEK); + Mark_Timer = 12000; + }else Mark_Timer -= diff; + + // Shield Wall - All 4 horsemen will shield wall at 50% hp and 20% hp for 20 seconds + if(ShieldWall1 && (m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < 50) + { + if(ShieldWall1) + { + DoCast(m_creature,SPELL_SHIELDWALL); + ShieldWall1 = false; + } + } + if(ShieldWall2 && (m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < 20) + { + if(ShieldWall2) + { + DoCast(m_creature,SPELL_SHIELDWALL); + ShieldWall2 = false; + } + } + + // Holy Wrath + if(HolyWrath_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_HOLY_WRATH); + HolyWrath_Timer = 12000; + }else HolyWrath_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; +CreatureAI* GetAI_boss_sir_zeliek(Creature *_Creature) +{ + return new boss_sir_zeliekAI (_Creature); +} + +void AddSC_boss_sir_zeliek() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_sir_zeliek"; + newscript->GetAI = GetAI_boss_sir_zeliek; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/naxxramas/boss_stalagg.cpp b/src/bindings/scripts/scripts/zone/naxxramas/boss_stalagg.cpp index 53b46122f24..44ca7aa7a47 100644 --- a/src/bindings/scripts/scripts/zone/naxxramas/boss_stalagg.cpp +++ b/src/bindings/scripts/scripts/zone/naxxramas/boss_stalagg.cpp @@ -1,35 +1,35 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Stalagg -SD%Complete: 0 -SDComment: Merge with Thaddius -SDCategory: Naxxramas -EndScriptData */ - -#include "precompiled.h" - -//Stalagg -//8864 aggro - Stalagg crush you! -//8866 slay - Stalagg Kill! -//8865 death - Master save me... - -#define SPELL_WARSTOMP 28125 -#define SPELL_POWERSURGE 28134 -#define SPELL_CHAIN_LIGHTNING 28900 - -//Not sure how to "force" crushing blows or to knock tank to the opposite platform +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Stalagg +SD%Complete: 0 +SDComment: Merge with Thaddius +SDCategory: Naxxramas +EndScriptData */ + +#include "precompiled.h" + +//Stalagg +//8864 aggro - Stalagg crush you! +//8866 slay - Stalagg Kill! +//8865 death - Master save me... + +#define SPELL_WARSTOMP 28125 +#define SPELL_POWERSURGE 28134 +#define SPELL_CHAIN_LIGHTNING 28900 + +//Not sure how to "force" crushing blows or to knock tank to the opposite platform diff --git a/src/bindings/scripts/scripts/zone/naxxramas/boss_thaddius.cpp b/src/bindings/scripts/scripts/zone/naxxramas/boss_thaddius.cpp index 0bd59cfa0e2..0ca03f67eb0 100644 --- a/src/bindings/scripts/scripts/zone/naxxramas/boss_thaddius.cpp +++ b/src/bindings/scripts/scripts/zone/naxxramas/boss_thaddius.cpp @@ -1,49 +1,49 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Thaddius -SD%Complete: 0 -SDComment: Merge Feugen & Stalagg with this script -SDCategory: Naxxramas -EndScriptData */ - -#include "precompiled.h" - -//Thaddus -//8873 Lamnt01 - Pleeease! -//8874 Lamnt02 - Stop, make it stop! -//8875 Lamnt03 - Help me! Save me! -//8876 Lamnt04 - Please, nooo! -//8872 greet - You are too late... I... must... OBEY! -//8867 aggro1 - KILL! -//8868 aggro2 - EAT YOUR BONES! -//8869 aggro3 - BREAK YOU! -//8871 elect - Now YOU feel pain! -//8877 slay - You die now! -//8870 die - Thank... you... - -#define SPELL_BALL_LIGHTNING 28299 - -#define SPELL_CHARGE_POSITIVE_DMGBUFF 29659 -#define SPELL_CHARGE_POSITIVE_NEARDMG 28059 - -#define SPELL_CHARGE_NEGATIVE_DMGBUFF 29660 -#define SPELL_CHARGE_NEGATIVE_NEARDMG 28084 - -#define SPELL_CHAIN_LIGHTNING 28900 - -#define SPELL_BESERK 26662 +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Thaddius +SD%Complete: 0 +SDComment: Merge Feugen & Stalagg with this script +SDCategory: Naxxramas +EndScriptData */ + +#include "precompiled.h" + +//Thaddus +//8873 Lamnt01 - Pleeease! +//8874 Lamnt02 - Stop, make it stop! +//8875 Lamnt03 - Help me! Save me! +//8876 Lamnt04 - Please, nooo! +//8872 greet - You are too late... I... must... OBEY! +//8867 aggro1 - KILL! +//8868 aggro2 - EAT YOUR BONES! +//8869 aggro3 - BREAK YOU! +//8871 elect - Now YOU feel pain! +//8877 slay - You die now! +//8870 die - Thank... you... + +#define SPELL_BALL_LIGHTNING 28299 + +#define SPELL_CHARGE_POSITIVE_DMGBUFF 29659 +#define SPELL_CHARGE_POSITIVE_NEARDMG 28059 + +#define SPELL_CHARGE_NEGATIVE_DMGBUFF 29660 +#define SPELL_CHARGE_NEGATIVE_NEARDMG 28084 + +#define SPELL_CHAIN_LIGHTNING 28900 + +#define SPELL_BESERK 26662 diff --git a/src/bindings/scripts/scripts/zone/naxxramas/boss_thane_korthazz.cpp b/src/bindings/scripts/scripts/zone/naxxramas/boss_thane_korthazz.cpp index af2010fb3d9..beb1b23d8c7 100644 --- a/src/bindings/scripts/scripts/zone/naxxramas/boss_thane_korthazz.cpp +++ b/src/bindings/scripts/scripts/zone/naxxramas/boss_thane_korthazz.cpp @@ -1,147 +1,147 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Thane_Korthazz -SD%Complete: 100 -SDComment: -SDCategory: Naxxramas -EndScriptData */ - -#include "precompiled.h" - -//All horsemen -#define SPELL_SHIELDWALL 29061 -#define SPELL_BESERK 26662 - -// thane korthazz -#define SPELL_MARK_OF_KORTHAZZ 28832 -#define SPELL_METEOR 26558 // m_creature->getVictim() auto-area spell but with a core problem - -#define SAY_AGGRO "Come out and fight, ye wee ninny!" -#define SAY_TAUNT1 "To arms, ye roustabouts! We've got company!" -#define SAY_TAUNT2 "I heard about enough of yer sniveling. Shut yer fly trap 'afore I shut it for ye!" -#define SAY_TAUNT3 "I'm gonna enjoy killin' these slack-jawed daffodils!" -#define SAY_SLAY "Next time, bring more friends!" -#define SAY_SPECIAl "I like my meat extra crispy!" -#define SAY_DEATH "What a bloody waste this is!" - -#define SOUND_AGGRO 8899 -#define SOUND_TAUNT1 8903 -#define SOUND_TAUNT2 8904 -#define SOUND_TAUNT3 8905 -#define SOUND_SLAY 8901 -#define SOUND_SPECIAL 8902 -#define SOUND_DEATH 8900 - -#define SPIRIT_OF_KORTHAZZ 16778 - -struct MANGOS_DLL_DECL boss_thane_korthazzAI : public ScriptedAI -{ - boss_thane_korthazzAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 Mark_Timer; - uint32 Meteor_Timer; - bool ShieldWall1; - bool ShieldWall2; - - void Reset() - { - Mark_Timer = 20000; // First Horsemen Mark is applied at 20 sec. - Meteor_Timer = 30000; // wrong - ShieldWall1 = true; - ShieldWall2 = true; - } - - void InitialYell() - { - if(!InCombat) - { - DoYell(SAY_AGGRO,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_AGGRO); - } - } - - void KilledUnit() - { - DoYell(SAY_SLAY,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_SLAY); - } - - void JustDied(Unit* Killer) - { - DoYell(SAY_DEATH,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature, SOUND_DEATH); - } - - void Aggro(Unit *who) - { - InitialYell(); - } - - void UpdateAI(const uint32 diff) - { - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - // Mark of Korthazz - if(Mark_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_MARK_OF_KORTHAZZ); - Mark_Timer = 12000; - }else Mark_Timer -= diff; - - // Shield Wall - All 4 horsemen will shield wall at 50% hp and 20% hp for 20 seconds - if(ShieldWall1 && (m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < 50) - { - if(ShieldWall1) - { - DoCast(m_creature,SPELL_SHIELDWALL); - ShieldWall1 = false; - } - } - if(ShieldWall2 && (m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < 20) - { - if(ShieldWall2) - { - DoCast(m_creature,SPELL_SHIELDWALL); - ShieldWall2 = false; - } - } - - // Meteor - if(Meteor_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_METEOR); - Meteor_Timer = 20000; // wrong - }else Meteor_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; -CreatureAI* GetAI_boss_thane_korthazz(Creature *_Creature) -{ - return new boss_thane_korthazzAI (_Creature); -} - -void AddSC_boss_thane_korthazz() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_thane_korthazz"; - newscript->GetAI = GetAI_boss_thane_korthazz; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Thane_Korthazz +SD%Complete: 100 +SDComment: +SDCategory: Naxxramas +EndScriptData */ + +#include "precompiled.h" + +//All horsemen +#define SPELL_SHIELDWALL 29061 +#define SPELL_BESERK 26662 + +// thane korthazz +#define SPELL_MARK_OF_KORTHAZZ 28832 +#define SPELL_METEOR 26558 // m_creature->getVictim() auto-area spell but with a core problem + +#define SAY_AGGRO "Come out and fight, ye wee ninny!" +#define SAY_TAUNT1 "To arms, ye roustabouts! We've got company!" +#define SAY_TAUNT2 "I heard about enough of yer sniveling. Shut yer fly trap 'afore I shut it for ye!" +#define SAY_TAUNT3 "I'm gonna enjoy killin' these slack-jawed daffodils!" +#define SAY_SLAY "Next time, bring more friends!" +#define SAY_SPECIAl "I like my meat extra crispy!" +#define SAY_DEATH "What a bloody waste this is!" + +#define SOUND_AGGRO 8899 +#define SOUND_TAUNT1 8903 +#define SOUND_TAUNT2 8904 +#define SOUND_TAUNT3 8905 +#define SOUND_SLAY 8901 +#define SOUND_SPECIAL 8902 +#define SOUND_DEATH 8900 + +#define SPIRIT_OF_KORTHAZZ 16778 + +struct MANGOS_DLL_DECL boss_thane_korthazzAI : public ScriptedAI +{ + boss_thane_korthazzAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 Mark_Timer; + uint32 Meteor_Timer; + bool ShieldWall1; + bool ShieldWall2; + + void Reset() + { + Mark_Timer = 20000; // First Horsemen Mark is applied at 20 sec. + Meteor_Timer = 30000; // wrong + ShieldWall1 = true; + ShieldWall2 = true; + } + + void InitialYell() + { + if(!InCombat) + { + DoYell(SAY_AGGRO,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_AGGRO); + } + } + + void KilledUnit() + { + DoYell(SAY_SLAY,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_SLAY); + } + + void JustDied(Unit* Killer) + { + DoYell(SAY_DEATH,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature, SOUND_DEATH); + } + + void Aggro(Unit *who) + { + InitialYell(); + } + + void UpdateAI(const uint32 diff) + { + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + // Mark of Korthazz + if(Mark_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_MARK_OF_KORTHAZZ); + Mark_Timer = 12000; + }else Mark_Timer -= diff; + + // Shield Wall - All 4 horsemen will shield wall at 50% hp and 20% hp for 20 seconds + if(ShieldWall1 && (m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < 50) + { + if(ShieldWall1) + { + DoCast(m_creature,SPELL_SHIELDWALL); + ShieldWall1 = false; + } + } + if(ShieldWall2 && (m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < 20) + { + if(ShieldWall2) + { + DoCast(m_creature,SPELL_SHIELDWALL); + ShieldWall2 = false; + } + } + + // Meteor + if(Meteor_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_METEOR); + Meteor_Timer = 20000; // wrong + }else Meteor_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; +CreatureAI* GetAI_boss_thane_korthazz(Creature *_Creature) +{ + return new boss_thane_korthazzAI (_Creature); +} + +void AddSC_boss_thane_korthazz() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_thane_korthazz"; + newscript->GetAI = GetAI_boss_thane_korthazz; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/naxxramas/instance_naxxramas.cpp b/src/bindings/scripts/scripts/zone/naxxramas/instance_naxxramas.cpp index 655d1e07a88..c799613d744 100644 --- a/src/bindings/scripts/scripts/zone/naxxramas/instance_naxxramas.cpp +++ b/src/bindings/scripts/scripts/zone/naxxramas/instance_naxxramas.cpp @@ -1,24 +1,24 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Instance_Naxxramas -SD%Complete: 0 -SDComment: Place holder -SDCategory: Naxxramas -EndScriptData */ - -#include "precompiled.h" +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Instance_Naxxramas +SD%Complete: 0 +SDComment: Place holder +SDCategory: Naxxramas +EndScriptData */ + +#include "precompiled.h" diff --git a/src/bindings/scripts/scripts/zone/netherstorm/netherstorm.cpp b/src/bindings/scripts/scripts/zone/netherstorm/netherstorm.cpp index 4b41574908f..bb92a16ad25 100644 --- a/src/bindings/scripts/scripts/zone/netherstorm/netherstorm.cpp +++ b/src/bindings/scripts/scripts/zone/netherstorm/netherstorm.cpp @@ -1,423 +1,423 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Netherstorm -SD%Complete: 75 -SDComment: Quest support: 10438, 10652 (special flight paths), 10299,10321,10322,10323,10329,10330,10338,10365(Shutting Down Manaforge) -SDCategory: Netherstorm -EndScriptData */ - -/* ContentData -npc_manaforge_control_console -go_manaforge_control_console -npc_protectorate_nether_drake -npc_veronia -EndContentData */ - -#include "precompiled.h" - -/*###### -## npc_manaforge_control_console -######*/ - -#define EMOTE_START "Warning! Emergency shutdown process initiated by $N. Shutdown will complete in two minutes." -#define EMOTE_60 "Emergency shutdown will complete in one minute." -#define EMOTE_30 "Emergency shutdown will complete in thirty seconds." -#define EMOTE_10 "Emergency shutdown will complete in ten seconds." -#define EMOTE_COMPLETE "Emergency shutdown complete." -#define EMOTE_ABORT "Emergency shutdown aborted." - -#define ENTRY_BNAAR_C_CONSOLE 20209 -#define ENTRY_CORUU_C_CONSOLE 20417 -#define ENTRY_DURO_C_CONSOLE 20418 -#define ENTRY_ARA_C_CONSOLE 20440 - -#define ENTRY_SUNFURY_TECH 20218 -#define ENTRY_SUNFURY_PROT 20436 - -#define ENTRY_ARA_TECH 20438 -#define ENTRY_ARA_ENGI 20439 -#define ENTRY_ARA_GORKLONN 20460 - -#define SPELL_DISABLE_VISUAL 35031 -#define SPELL_INTERRUPT_1 35016 //ACID mobs should cast this -#define SPELL_INTERRUPT_2 35176 //ACID mobs should cast this (Manaforge Ara-version) - -struct MANGOS_DLL_DECL npc_manaforge_control_consoleAI : public ScriptedAI -{ - npc_manaforge_control_consoleAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 Event_Timer; - uint32 Wave_Timer; - uint32 Phase; - bool Wave; - uint64 someplayer; - uint64 goConsole; - Creature* add; - - void Reset() - { - Event_Timer = 3000; - Wave_Timer = 0; - Phase = 1; - Wave = false; - someplayer = 0; - goConsole = 0; - Creature* add = NULL; - } - - void Aggro(Unit *who) { return; } - - /*void SpellHit(Unit *caster, const SpellEntry *spell) - { - //we have no way of telling the creature was hit by spell -> got aura applied after 10-12 seconds - //then no way for the mobs to actually stop the shutdown as intended. - if( spell->Id == SPELL_INTERRUPT_1 ) - DoSay("Silence! I kill you!",LANG_UNIVERSAL, NULL); - }*/ - - void JustDied(Unit* killer) - { - DoTextEmote(EMOTE_ABORT, NULL); - - if( someplayer ) - { - Unit* p = Unit::GetUnit((*m_creature),someplayer); - if( p && p->GetTypeId() == TYPEID_PLAYER ) - { - switch( m_creature->GetEntry() ) - { - case ENTRY_BNAAR_C_CONSOLE: - ((Player*)p)->FailQuest(10299); - ((Player*)p)->FailQuest(10329); - break; - case ENTRY_CORUU_C_CONSOLE: - ((Player*)p)->FailQuest(10321); - ((Player*)p)->FailQuest(10330); - break; - case ENTRY_DURO_C_CONSOLE: - ((Player*)p)->FailQuest(10322); - ((Player*)p)->FailQuest(10338); - break; - case ENTRY_ARA_C_CONSOLE: - ((Player*)p)->FailQuest(10323); - ((Player*)p)->FailQuest(10365); - break; - } - } - } - - if( goConsole ) - { - if( GameObject* go = GameObject::GetGameObject((*m_creature),goConsole) ) - go->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_IN_USE); - } - } - - void DoWaveSpawnForCreature(Creature *creature) - { - switch( creature->GetEntry() ) - { - case ENTRY_BNAAR_C_CONSOLE: - if( rand()%2 ) - { - add = m_creature->SummonCreature(ENTRY_SUNFURY_TECH,2933.68,4162.55,164.00,1.60,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 120000); - if( add ) add->GetMotionMaster()->MovePoint(0,2927.36,4212.97,164.00); - } - else - { - add = m_creature->SummonCreature(ENTRY_SUNFURY_TECH,2927.36,4212.97,164.00,4.94,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 120000); - if( add ) add->GetMotionMaster()->MovePoint(0,2933.68,4162.55,164.00); - } - Wave_Timer = 30000; - break; - case ENTRY_CORUU_C_CONSOLE: - add = m_creature->SummonCreature(ENTRY_SUNFURY_TECH,2445.21,2765.26,134.49,3.93,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 120000); - if( add ) add->GetMotionMaster()->MovePoint(0,2424.21,2740.15,133.81); - add = m_creature->SummonCreature(ENTRY_SUNFURY_TECH,2429.86,2731.85,134.53,1.31,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 120000); - if( add ) add->GetMotionMaster()->MovePoint(0,2435.37,2766.04,133.81); - Wave_Timer = 20000; - break; - case ENTRY_DURO_C_CONSOLE: - add = m_creature->SummonCreature(ENTRY_SUNFURY_TECH,2986.80,2205.36,165.37,3.74,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 120000); - if( add ) add->GetMotionMaster()->MovePoint(0,2985.15,2197.32,164.79); - add = m_creature->SummonCreature(ENTRY_SUNFURY_TECH,2952.91,2191.20,165.32,0.22,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 120000); - if( add ) add->GetMotionMaster()->MovePoint(0,2060.01,2185.27,164.67); - Wave_Timer = 15000; - break; - case ENTRY_ARA_C_CONSOLE: - if( rand()%2 ) - { - add = m_creature->SummonCreature(ENTRY_ARA_TECH,4035.11,4038.97,194.27,2.57,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 120000); - if( add ) add->GetMotionMaster()->MovePoint(0,4003.42,4040.19,193.49); - add = m_creature->SummonCreature(ENTRY_ARA_TECH,4033.66,4036.79,194.28,2.57,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 120000); - if( add ) add->GetMotionMaster()->MovePoint(0,4003.42,4040.19,193.49); - add = m_creature->SummonCreature(ENTRY_ARA_TECH,4037.13,4037.30,194.23,2.57,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 120000); - if( add ) add->GetMotionMaster()->MovePoint(0,4003.42,4040.19,193.49); - } - else - { - add = m_creature->SummonCreature(ENTRY_ARA_TECH,3099.59,4049.30,194.22,0.05,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 120000); - if( add ) add->GetMotionMaster()->MovePoint(0,4028.01,4035.17,193.59); - add = m_creature->SummonCreature(ENTRY_ARA_TECH,3999.72,4046.75,194.22,0.05,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 120000); - if( add ) add->GetMotionMaster()->MovePoint(0,4028.01,4035.17,193.59); - add = m_creature->SummonCreature(ENTRY_ARA_TECH,3996.81,4048.26,194.22,0.05,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 120000); - if( add ) add->GetMotionMaster()->MovePoint(0,4028.01,4035.17,193.59); - } - Wave_Timer = 15000; - break; - } - } - void DoFinalSpawnForCreature(Creature *creature) - { - switch( creature->GetEntry() ) - { - case ENTRY_BNAAR_C_CONSOLE: - add = m_creature->SummonCreature(ENTRY_SUNFURY_TECH,2946.52,4201.42,163.47,3.54,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 120000); - if( add ) add->GetMotionMaster()->MovePoint(0,2927.49,4192.81,163.00); - break; - case ENTRY_CORUU_C_CONSOLE: - add = m_creature->SummonCreature(ENTRY_SUNFURY_TECH,2453.88,2737.85,133.27,2.59,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 120000); - if( add ) add->GetMotionMaster()->MovePoint(0,2433.96,2751.53,133.85); - add = m_creature->SummonCreature(ENTRY_SUNFURY_TECH,2441.62,2735.32,134.49,1.97,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 120000); - if( add ) add->GetMotionMaster()->MovePoint(0,2433.96,2751.53,133.85); - add = m_creature->SummonCreature(ENTRY_SUNFURY_TECH,2450.73,2754.50,134.49,3.29,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 120000); - if( add ) add->GetMotionMaster()->MovePoint(0,2433.96,2751.53,133.85); - break; - case ENTRY_DURO_C_CONSOLE: - add = m_creature->SummonCreature(ENTRY_SUNFURY_TECH,2956.18,2202.85,165.32,5.45,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 120000); - if( add ) add->GetMotionMaster()->MovePoint(0,2972.27,2193.22,164.48); - add = m_creature->SummonCreature(ENTRY_SUNFURY_TECH,2975.30,2211.50,165.32,4.55,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 120000); - if( add ) add->GetMotionMaster()->MovePoint(0,2972.27,2193.22,164.48); - add = m_creature->SummonCreature(ENTRY_SUNFURY_PROT,2965.02,2217.45,164.16,4.96,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 120000); - if( add ) add->GetMotionMaster()->MovePoint(0,2972.27,2193.22,164.48); - break; - case ENTRY_ARA_C_CONSOLE: - add = m_creature->SummonCreature(ENTRY_ARA_ENGI,3994.51,4020.46,192.18,0.91,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 120000); - if( add ) add->GetMotionMaster()->MovePoint(0,4008.35,4035.04,192.70); - add = m_creature->SummonCreature(ENTRY_ARA_GORKLONN,4021.56,4059.35,193.59,4.44,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 120000); - if( add ) add->GetMotionMaster()->MovePoint(0,4016.62,4039.89,193.46); - break; - } - } - - void UpdateAI(const uint32 diff) - { - if( Event_Timer < diff ) - { - switch(Phase) - { - case 1: - if( someplayer ) - { - Unit* u = Unit::GetUnit((*m_creature),someplayer); - if( u && u->GetTypeId() == TYPEID_PLAYER ) DoTextEmote(EMOTE_START, u); - } - Event_Timer = 60000; - Wave = true; - ++Phase; - break; - case 2: - DoTextEmote(EMOTE_60, NULL); - Event_Timer = 30000; - ++Phase; - break; - case 3: - DoTextEmote(EMOTE_30, NULL); - Event_Timer = 20000; - DoFinalSpawnForCreature(m_creature); - ++Phase; - break; - case 4: - DoTextEmote(EMOTE_10, NULL); - Event_Timer = 10000; - Wave = false; - ++Phase; - break; - case 5: - DoTextEmote(EMOTE_COMPLETE, NULL); - if( someplayer ) - { - Unit* u = Unit::GetUnit((*m_creature),someplayer); - if( u && u->GetTypeId() == TYPEID_PLAYER ) - ((Player*)u)->KilledMonster(m_creature->GetEntry(),m_creature->GetGUID()); - DoCast(m_creature,SPELL_DISABLE_VISUAL); - } - if( goConsole ) - { - if( GameObject* go = GameObject::GetGameObject((*m_creature),goConsole) ) - go->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_IN_USE); - } - ++Phase; - break; - default: - break; - } - } else Event_Timer -= diff; - - if( Wave ) - { - if( Wave_Timer < diff ) - { - DoWaveSpawnForCreature(m_creature); - } else Wave_Timer -= diff; - } - } -}; -CreatureAI* GetAI_npc_manaforge_control_console(Creature *_Creature) -{ - return new npc_manaforge_control_consoleAI (_Creature); -} - -/*###### -## go_manaforge_control_console -######*/ - -//TODO: clean up this workaround when mangos adds support to do it properly (with gossip selections instead of instant summon) -bool GOHello_go_manaforge_control_console(Player *player, GameObject* _GO) -{ - if (_GO->GetGoType() == GAMEOBJECT_TYPE_QUESTGIVER) - { - player->PrepareQuestMenu(_GO->GetGUID()); - player->SendPreparedQuest(_GO->GetGUID()); - } - - Creature* manaforge; - manaforge = NULL; - - switch( _GO->GetAreaId() ) - { - case 3726: //b'naar - if( (player->GetQuestStatus(10299) == QUEST_STATUS_INCOMPLETE || player->GetQuestStatus(10329) == QUEST_STATUS_INCOMPLETE) && - player->HasItemCount(29366,1)) - manaforge = player->SummonCreature(ENTRY_BNAAR_C_CONSOLE,2918.95,4189.98,161.88,0.34,TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN,125000); - break; - case 3730: //coruu - if( (player->GetQuestStatus(10321) == QUEST_STATUS_INCOMPLETE || player->GetQuestStatus(10330) == QUEST_STATUS_INCOMPLETE) && - player->HasItemCount(29396,1)) - manaforge = player->SummonCreature(ENTRY_CORUU_C_CONSOLE,2426.77,2750.38,133.24,2.14,TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN,125000); - break; - case 3734: //duro - if( (player->GetQuestStatus(10322) == QUEST_STATUS_INCOMPLETE || player->GetQuestStatus(10338) == QUEST_STATUS_INCOMPLETE) && - player->HasItemCount(29397,1)) - manaforge = player->SummonCreature(ENTRY_DURO_C_CONSOLE,2976.48,2183.29,163.20,1.85,TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN,125000); - break; - case 3722: //ara - if( (player->GetQuestStatus(10323) == QUEST_STATUS_INCOMPLETE || player->GetQuestStatus(10365) == QUEST_STATUS_INCOMPLETE) && - player->HasItemCount(29411,1)) - manaforge = player->SummonCreature(ENTRY_ARA_C_CONSOLE,4013.71,4028.76,192.10,1.25,TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN,125000); - break; - } - - if( manaforge ) - { - ((npc_manaforge_control_consoleAI*)manaforge->AI())->someplayer = player->GetGUID(); - ((npc_manaforge_control_consoleAI*)manaforge->AI())->goConsole = _GO->GetGUID(); - _GO->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_IN_USE); - } - return true; -} - -/*###### -## npc_protectorate_nether_drake -######*/ - -bool GossipHello_npc_protectorate_nether_drake(Player *player, Creature *_Creature) -{ - //On Nethery Wings - if (player->GetQuestStatus(10438) == QUEST_STATUS_INCOMPLETE && player->HasItemCount(29778,1) ) - player->ADD_GOSSIP_ITEM(0, "Fly me to Ultris", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); - - player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); - - return true; -} - -bool GossipSelect_npc_protectorate_nether_drake(Player *player, Creature *_Creature, uint32 sender, uint32 action ) -{ - if (action == GOSSIP_ACTION_INFO_DEF+1) - { - player->CLOSE_GOSSIP_MENU(); - - std::vector nodes; - - nodes.resize(2); - nodes[0] = 152; //from drake - nodes[1] = 153; //end at drake - player->ActivateTaxiPathTo(nodes); //TaxiPath 627 (possibly 627+628(152->153->154->155) ) - } - return true; -} - -/*###### -## npc_veronia -######*/ - -bool GossipHello_npc_veronia(Player *player, Creature *_Creature) -{ - if (_Creature->isQuestGiver()) - player->PrepareQuestMenu( _Creature->GetGUID() ); - - //Behind Enemy Lines - if (player->GetQuestStatus(10652) && !player->GetQuestRewardStatus(10652)) - player->ADD_GOSSIP_ITEM(0, "Fly me to Manaforge Coruu please", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF); - - player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); - - return true; -} - -bool GossipSelect_npc_veronia(Player *player, Creature *_Creature, uint32 sender, uint32 action ) -{ - if (action == GOSSIP_ACTION_INFO_DEF) - { - player->CLOSE_GOSSIP_MENU(); - player->CastSpell(player,34905,true); //TaxiPath 606 - } - return true; -} - -/*###### -## -######*/ - -void AddSC_netherstorm() -{ - Script *newscript; - - newscript = new Script; - newscript->Name="go_manaforge_control_console"; - newscript->pGOHello = &GOHello_go_manaforge_control_console; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="npc_manaforge_control_console"; - newscript->GetAI = GetAI_npc_manaforge_control_console; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="npc_protectorate_nether_drake"; - newscript->pGossipHello = &GossipHello_npc_protectorate_nether_drake; - newscript->pGossipSelect = &GossipSelect_npc_protectorate_nether_drake; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="npc_veronia"; - newscript->pGossipHello = &GossipHello_npc_veronia; - newscript->pGossipSelect = &GossipSelect_npc_veronia; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Netherstorm +SD%Complete: 75 +SDComment: Quest support: 10438, 10652 (special flight paths), 10299,10321,10322,10323,10329,10330,10338,10365(Shutting Down Manaforge) +SDCategory: Netherstorm +EndScriptData */ + +/* ContentData +npc_manaforge_control_console +go_manaforge_control_console +npc_protectorate_nether_drake +npc_veronia +EndContentData */ + +#include "precompiled.h" + +/*###### +## npc_manaforge_control_console +######*/ + +#define EMOTE_START "Warning! Emergency shutdown process initiated by $N. Shutdown will complete in two minutes." +#define EMOTE_60 "Emergency shutdown will complete in one minute." +#define EMOTE_30 "Emergency shutdown will complete in thirty seconds." +#define EMOTE_10 "Emergency shutdown will complete in ten seconds." +#define EMOTE_COMPLETE "Emergency shutdown complete." +#define EMOTE_ABORT "Emergency shutdown aborted." + +#define ENTRY_BNAAR_C_CONSOLE 20209 +#define ENTRY_CORUU_C_CONSOLE 20417 +#define ENTRY_DURO_C_CONSOLE 20418 +#define ENTRY_ARA_C_CONSOLE 20440 + +#define ENTRY_SUNFURY_TECH 20218 +#define ENTRY_SUNFURY_PROT 20436 + +#define ENTRY_ARA_TECH 20438 +#define ENTRY_ARA_ENGI 20439 +#define ENTRY_ARA_GORKLONN 20460 + +#define SPELL_DISABLE_VISUAL 35031 +#define SPELL_INTERRUPT_1 35016 //ACID mobs should cast this +#define SPELL_INTERRUPT_2 35176 //ACID mobs should cast this (Manaforge Ara-version) + +struct MANGOS_DLL_DECL npc_manaforge_control_consoleAI : public ScriptedAI +{ + npc_manaforge_control_consoleAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 Event_Timer; + uint32 Wave_Timer; + uint32 Phase; + bool Wave; + uint64 someplayer; + uint64 goConsole; + Creature* add; + + void Reset() + { + Event_Timer = 3000; + Wave_Timer = 0; + Phase = 1; + Wave = false; + someplayer = 0; + goConsole = 0; + Creature* add = NULL; + } + + void Aggro(Unit *who) { return; } + + /*void SpellHit(Unit *caster, const SpellEntry *spell) + { + //we have no way of telling the creature was hit by spell -> got aura applied after 10-12 seconds + //then no way for the mobs to actually stop the shutdown as intended. + if( spell->Id == SPELL_INTERRUPT_1 ) + DoSay("Silence! I kill you!",LANG_UNIVERSAL, NULL); + }*/ + + void JustDied(Unit* killer) + { + DoTextEmote(EMOTE_ABORT, NULL); + + if( someplayer ) + { + Unit* p = Unit::GetUnit((*m_creature),someplayer); + if( p && p->GetTypeId() == TYPEID_PLAYER ) + { + switch( m_creature->GetEntry() ) + { + case ENTRY_BNAAR_C_CONSOLE: + ((Player*)p)->FailQuest(10299); + ((Player*)p)->FailQuest(10329); + break; + case ENTRY_CORUU_C_CONSOLE: + ((Player*)p)->FailQuest(10321); + ((Player*)p)->FailQuest(10330); + break; + case ENTRY_DURO_C_CONSOLE: + ((Player*)p)->FailQuest(10322); + ((Player*)p)->FailQuest(10338); + break; + case ENTRY_ARA_C_CONSOLE: + ((Player*)p)->FailQuest(10323); + ((Player*)p)->FailQuest(10365); + break; + } + } + } + + if( goConsole ) + { + if( GameObject* go = GameObject::GetGameObject((*m_creature),goConsole) ) + go->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_IN_USE); + } + } + + void DoWaveSpawnForCreature(Creature *creature) + { + switch( creature->GetEntry() ) + { + case ENTRY_BNAAR_C_CONSOLE: + if( rand()%2 ) + { + add = m_creature->SummonCreature(ENTRY_SUNFURY_TECH,2933.68,4162.55,164.00,1.60,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 120000); + if( add ) add->GetMotionMaster()->MovePoint(0,2927.36,4212.97,164.00); + } + else + { + add = m_creature->SummonCreature(ENTRY_SUNFURY_TECH,2927.36,4212.97,164.00,4.94,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 120000); + if( add ) add->GetMotionMaster()->MovePoint(0,2933.68,4162.55,164.00); + } + Wave_Timer = 30000; + break; + case ENTRY_CORUU_C_CONSOLE: + add = m_creature->SummonCreature(ENTRY_SUNFURY_TECH,2445.21,2765.26,134.49,3.93,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 120000); + if( add ) add->GetMotionMaster()->MovePoint(0,2424.21,2740.15,133.81); + add = m_creature->SummonCreature(ENTRY_SUNFURY_TECH,2429.86,2731.85,134.53,1.31,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 120000); + if( add ) add->GetMotionMaster()->MovePoint(0,2435.37,2766.04,133.81); + Wave_Timer = 20000; + break; + case ENTRY_DURO_C_CONSOLE: + add = m_creature->SummonCreature(ENTRY_SUNFURY_TECH,2986.80,2205.36,165.37,3.74,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 120000); + if( add ) add->GetMotionMaster()->MovePoint(0,2985.15,2197.32,164.79); + add = m_creature->SummonCreature(ENTRY_SUNFURY_TECH,2952.91,2191.20,165.32,0.22,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 120000); + if( add ) add->GetMotionMaster()->MovePoint(0,2060.01,2185.27,164.67); + Wave_Timer = 15000; + break; + case ENTRY_ARA_C_CONSOLE: + if( rand()%2 ) + { + add = m_creature->SummonCreature(ENTRY_ARA_TECH,4035.11,4038.97,194.27,2.57,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 120000); + if( add ) add->GetMotionMaster()->MovePoint(0,4003.42,4040.19,193.49); + add = m_creature->SummonCreature(ENTRY_ARA_TECH,4033.66,4036.79,194.28,2.57,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 120000); + if( add ) add->GetMotionMaster()->MovePoint(0,4003.42,4040.19,193.49); + add = m_creature->SummonCreature(ENTRY_ARA_TECH,4037.13,4037.30,194.23,2.57,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 120000); + if( add ) add->GetMotionMaster()->MovePoint(0,4003.42,4040.19,193.49); + } + else + { + add = m_creature->SummonCreature(ENTRY_ARA_TECH,3099.59,4049.30,194.22,0.05,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 120000); + if( add ) add->GetMotionMaster()->MovePoint(0,4028.01,4035.17,193.59); + add = m_creature->SummonCreature(ENTRY_ARA_TECH,3999.72,4046.75,194.22,0.05,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 120000); + if( add ) add->GetMotionMaster()->MovePoint(0,4028.01,4035.17,193.59); + add = m_creature->SummonCreature(ENTRY_ARA_TECH,3996.81,4048.26,194.22,0.05,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 120000); + if( add ) add->GetMotionMaster()->MovePoint(0,4028.01,4035.17,193.59); + } + Wave_Timer = 15000; + break; + } + } + void DoFinalSpawnForCreature(Creature *creature) + { + switch( creature->GetEntry() ) + { + case ENTRY_BNAAR_C_CONSOLE: + add = m_creature->SummonCreature(ENTRY_SUNFURY_TECH,2946.52,4201.42,163.47,3.54,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 120000); + if( add ) add->GetMotionMaster()->MovePoint(0,2927.49,4192.81,163.00); + break; + case ENTRY_CORUU_C_CONSOLE: + add = m_creature->SummonCreature(ENTRY_SUNFURY_TECH,2453.88,2737.85,133.27,2.59,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 120000); + if( add ) add->GetMotionMaster()->MovePoint(0,2433.96,2751.53,133.85); + add = m_creature->SummonCreature(ENTRY_SUNFURY_TECH,2441.62,2735.32,134.49,1.97,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 120000); + if( add ) add->GetMotionMaster()->MovePoint(0,2433.96,2751.53,133.85); + add = m_creature->SummonCreature(ENTRY_SUNFURY_TECH,2450.73,2754.50,134.49,3.29,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 120000); + if( add ) add->GetMotionMaster()->MovePoint(0,2433.96,2751.53,133.85); + break; + case ENTRY_DURO_C_CONSOLE: + add = m_creature->SummonCreature(ENTRY_SUNFURY_TECH,2956.18,2202.85,165.32,5.45,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 120000); + if( add ) add->GetMotionMaster()->MovePoint(0,2972.27,2193.22,164.48); + add = m_creature->SummonCreature(ENTRY_SUNFURY_TECH,2975.30,2211.50,165.32,4.55,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 120000); + if( add ) add->GetMotionMaster()->MovePoint(0,2972.27,2193.22,164.48); + add = m_creature->SummonCreature(ENTRY_SUNFURY_PROT,2965.02,2217.45,164.16,4.96,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 120000); + if( add ) add->GetMotionMaster()->MovePoint(0,2972.27,2193.22,164.48); + break; + case ENTRY_ARA_C_CONSOLE: + add = m_creature->SummonCreature(ENTRY_ARA_ENGI,3994.51,4020.46,192.18,0.91,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 120000); + if( add ) add->GetMotionMaster()->MovePoint(0,4008.35,4035.04,192.70); + add = m_creature->SummonCreature(ENTRY_ARA_GORKLONN,4021.56,4059.35,193.59,4.44,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 120000); + if( add ) add->GetMotionMaster()->MovePoint(0,4016.62,4039.89,193.46); + break; + } + } + + void UpdateAI(const uint32 diff) + { + if( Event_Timer < diff ) + { + switch(Phase) + { + case 1: + if( someplayer ) + { + Unit* u = Unit::GetUnit((*m_creature),someplayer); + if( u && u->GetTypeId() == TYPEID_PLAYER ) DoTextEmote(EMOTE_START, u); + } + Event_Timer = 60000; + Wave = true; + ++Phase; + break; + case 2: + DoTextEmote(EMOTE_60, NULL); + Event_Timer = 30000; + ++Phase; + break; + case 3: + DoTextEmote(EMOTE_30, NULL); + Event_Timer = 20000; + DoFinalSpawnForCreature(m_creature); + ++Phase; + break; + case 4: + DoTextEmote(EMOTE_10, NULL); + Event_Timer = 10000; + Wave = false; + ++Phase; + break; + case 5: + DoTextEmote(EMOTE_COMPLETE, NULL); + if( someplayer ) + { + Unit* u = Unit::GetUnit((*m_creature),someplayer); + if( u && u->GetTypeId() == TYPEID_PLAYER ) + ((Player*)u)->KilledMonster(m_creature->GetEntry(),m_creature->GetGUID()); + DoCast(m_creature,SPELL_DISABLE_VISUAL); + } + if( goConsole ) + { + if( GameObject* go = GameObject::GetGameObject((*m_creature),goConsole) ) + go->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_IN_USE); + } + ++Phase; + break; + default: + break; + } + } else Event_Timer -= diff; + + if( Wave ) + { + if( Wave_Timer < diff ) + { + DoWaveSpawnForCreature(m_creature); + } else Wave_Timer -= diff; + } + } +}; +CreatureAI* GetAI_npc_manaforge_control_console(Creature *_Creature) +{ + return new npc_manaforge_control_consoleAI (_Creature); +} + +/*###### +## go_manaforge_control_console +######*/ + +//TODO: clean up this workaround when mangos adds support to do it properly (with gossip selections instead of instant summon) +bool GOHello_go_manaforge_control_console(Player *player, GameObject* _GO) +{ + if (_GO->GetGoType() == GAMEOBJECT_TYPE_QUESTGIVER) + { + player->PrepareQuestMenu(_GO->GetGUID()); + player->SendPreparedQuest(_GO->GetGUID()); + } + + Creature* manaforge; + manaforge = NULL; + + switch( _GO->GetAreaId() ) + { + case 3726: //b'naar + if( (player->GetQuestStatus(10299) == QUEST_STATUS_INCOMPLETE || player->GetQuestStatus(10329) == QUEST_STATUS_INCOMPLETE) && + player->HasItemCount(29366,1)) + manaforge = player->SummonCreature(ENTRY_BNAAR_C_CONSOLE,2918.95,4189.98,161.88,0.34,TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN,125000); + break; + case 3730: //coruu + if( (player->GetQuestStatus(10321) == QUEST_STATUS_INCOMPLETE || player->GetQuestStatus(10330) == QUEST_STATUS_INCOMPLETE) && + player->HasItemCount(29396,1)) + manaforge = player->SummonCreature(ENTRY_CORUU_C_CONSOLE,2426.77,2750.38,133.24,2.14,TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN,125000); + break; + case 3734: //duro + if( (player->GetQuestStatus(10322) == QUEST_STATUS_INCOMPLETE || player->GetQuestStatus(10338) == QUEST_STATUS_INCOMPLETE) && + player->HasItemCount(29397,1)) + manaforge = player->SummonCreature(ENTRY_DURO_C_CONSOLE,2976.48,2183.29,163.20,1.85,TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN,125000); + break; + case 3722: //ara + if( (player->GetQuestStatus(10323) == QUEST_STATUS_INCOMPLETE || player->GetQuestStatus(10365) == QUEST_STATUS_INCOMPLETE) && + player->HasItemCount(29411,1)) + manaforge = player->SummonCreature(ENTRY_ARA_C_CONSOLE,4013.71,4028.76,192.10,1.25,TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN,125000); + break; + } + + if( manaforge ) + { + ((npc_manaforge_control_consoleAI*)manaforge->AI())->someplayer = player->GetGUID(); + ((npc_manaforge_control_consoleAI*)manaforge->AI())->goConsole = _GO->GetGUID(); + _GO->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_IN_USE); + } + return true; +} + +/*###### +## npc_protectorate_nether_drake +######*/ + +bool GossipHello_npc_protectorate_nether_drake(Player *player, Creature *_Creature) +{ + //On Nethery Wings + if (player->GetQuestStatus(10438) == QUEST_STATUS_INCOMPLETE && player->HasItemCount(29778,1) ) + player->ADD_GOSSIP_ITEM(0, "Fly me to Ultris", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); + + player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); + + return true; +} + +bool GossipSelect_npc_protectorate_nether_drake(Player *player, Creature *_Creature, uint32 sender, uint32 action ) +{ + if (action == GOSSIP_ACTION_INFO_DEF+1) + { + player->CLOSE_GOSSIP_MENU(); + + std::vector nodes; + + nodes.resize(2); + nodes[0] = 152; //from drake + nodes[1] = 153; //end at drake + player->ActivateTaxiPathTo(nodes); //TaxiPath 627 (possibly 627+628(152->153->154->155) ) + } + return true; +} + +/*###### +## npc_veronia +######*/ + +bool GossipHello_npc_veronia(Player *player, Creature *_Creature) +{ + if (_Creature->isQuestGiver()) + player->PrepareQuestMenu( _Creature->GetGUID() ); + + //Behind Enemy Lines + if (player->GetQuestStatus(10652) && !player->GetQuestRewardStatus(10652)) + player->ADD_GOSSIP_ITEM(0, "Fly me to Manaforge Coruu please", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF); + + player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); + + return true; +} + +bool GossipSelect_npc_veronia(Player *player, Creature *_Creature, uint32 sender, uint32 action ) +{ + if (action == GOSSIP_ACTION_INFO_DEF) + { + player->CLOSE_GOSSIP_MENU(); + player->CastSpell(player,34905,true); //TaxiPath 606 + } + return true; +} + +/*###### +## +######*/ + +void AddSC_netherstorm() +{ + Script *newscript; + + newscript = new Script; + newscript->Name="go_manaforge_control_console"; + newscript->pGOHello = &GOHello_go_manaforge_control_console; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="npc_manaforge_control_console"; + newscript->GetAI = GetAI_npc_manaforge_control_console; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="npc_protectorate_nether_drake"; + newscript->pGossipHello = &GossipHello_npc_protectorate_nether_drake; + newscript->pGossipSelect = &GossipSelect_npc_protectorate_nether_drake; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="npc_veronia"; + newscript->pGossipHello = &GossipHello_npc_veronia; + newscript->pGossipSelect = &GossipSelect_npc_veronia; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/onyxias_lair/boss_onyxia.cpp b/src/bindings/scripts/scripts/zone/onyxias_lair/boss_onyxia.cpp index 87ee5b8b0cc..1c8ff67436f 100644 --- a/src/bindings/scripts/scripts/zone/onyxias_lair/boss_onyxia.cpp +++ b/src/bindings/scripts/scripts/zone/onyxias_lair/boss_onyxia.cpp @@ -1,229 +1,229 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Onyxia -SD%Complete: 50 -SDComment: Phase 2 has many errors. Recommend Rewrite of entire script. -SDCategory: Onyxia's Lair -EndScriptData */ - -#include "precompiled.h" - -#define SPELL_WINGBUFFET 18500 -#define SPELL_FLAMEBREATH 18435 -#define SPELL_CLEAVE 19983 -#define SPELL_TAILSWEEP 15847 -#define SPELL_KNOCK_AWAY 19633 - -#define SPELL_ENGULFINGFLAMES 20019 -#define SPELL_DEEPBREATH 23461 -#define SPELL_FIREBALL 18392 - -#define SPELL_BELLOWINGROAR 18431 -#define SPELL_HEATED_GROUND 22191 - -#define SPELL_SUMMONWHELP 17646 - -#define SAY_AGGRO "How fortuitous. Usually, I must leave my lair to feed." -#define SAY_KILL "Learn your place mortal!" -#define SAY_PHASE_2_TRANS "This meaningless exertion bores me. I'll incinerate you from above!" -#define SAY_PHASE_3_TRANS "It seems you'll need another lesson!" -#define EMOTE_BREATH "takes a deep breath..." - -static float MovementLocations[7][3]= -{ - {-65.8444, -213.809, -60.2985}, - {22.87639, -217.152, -60.0548}, - {-33.5561, -182.682, -60.9457}, - {-31.4963, -250.123, -60.1278}, - {-2.78999, -181.431, -60.8962}, - {-54.9415, -232.242, -60.5555}, - {10.56655, -241.478, -60.9426}, -}; - -static float SpawnLocations[4][3]= -{ - {-30.127, -254.463, -89.440}, - {-30.817, -177.106, -89.258}, - {14.480, -241.560, -85.6300}, - {17.372, -190.840, -85.2810}, -}; - -#define CREATURE_WHELP 11262 - -struct MANGOS_DLL_DECL boss_onyxiaAI : public ScriptedAI -{ - boss_onyxiaAI(Creature* c) : ScriptedAI(c) {Reset();} - - uint32 Phase; - - uint32 FlameBreathTimer; - uint32 CleaveTimer; - uint32 TailSweepTimer; - uint32 MovementTimer; - uint32 EngulfingFlamesTimer; - uint32 SummonWhelpsTimer; - uint32 BellowingRoarTimer; - uint32 WingBuffetTimer; - - void Reset() - { - Phase = 1; - - FlameBreathTimer = 20000; - TailSweepTimer = 2000; - CleaveTimer = 15000; - MovementTimer = 5000; - EngulfingFlamesTimer = 15000; - SummonWhelpsTimer = 45000; - BellowingRoarTimer = 30000; - WingBuffetTimer = 17000; - } - - void Aggro(Unit* who) - { - DoYell(SAY_AGGRO, LANG_UNIVERSAL, NULL); - } - - void KilledUnit(Unit *victim) - { - DoYell(SAY_KILL, LANG_UNIVERSAL, NULL); - } - - void UpdateAI(const uint32 diff) - { - if(!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - if(((m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < 60) && (Phase == 1)) - { - Phase = 2; - m_creature->HandleEmoteCommand(EMOTE_ONESHOT_LIFTOFF); - m_creature->AddUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT + MOVEMENTFLAG_LEVITATING); - m_creature->GetMotionMaster()->Clear(false); - m_creature->GetMotionMaster()->MoveIdle(); - DoYell(SAY_PHASE_2_TRANS, LANG_UNIVERSAL, NULL); - } - - if(((m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < 40) && (Phase == 2)) - { - Phase = 3; - m_creature->RemoveUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT + MOVEMENTFLAG_LEVITATING); - m_creature->HandleEmoteCommand(EMOTE_ONESHOT_LAND); - DoYell(SAY_PHASE_3_TRANS, LANG_UNIVERSAL, NULL); - } - - if(Phase == 1 || Phase == 3) - { - if(FlameBreathTimer < diff) - { - DoCast(m_creature->getVictim(), SPELL_FLAMEBREATH); - FlameBreathTimer = 15000; - }else FlameBreathTimer -= diff; - - if(TailSweepTimer < diff) - { - Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 1); - if(target && !m_creature->HasInArc(M_PI, target)) - DoCast(target, SPELL_TAILSWEEP); - - TailSweepTimer = 10000; - }else TailSweepTimer -= diff; - - if(CleaveTimer < diff) - { - DoCast(m_creature->getVictim(), SPELL_CLEAVE); - CleaveTimer = 10000; - }else CleaveTimer -= diff; - - if(WingBuffetTimer < diff) - { - DoCast(m_creature->getVictim(), SPELL_WINGBUFFET); - WingBuffetTimer = 7000 + ((rand()%8)*1000); - }else WingBuffetTimer -= diff; - - DoMeleeAttackIfReady(); - } - - if(Phase == 2) - { - if(!m_creature->isHover()) - { - m_creature->HandleEmoteCommand(EMOTE_ONESHOT_LIFTOFF); - m_creature->SetHover(true); - } - - if(!m_creature->GetMotionMaster()->empty() && (m_creature->GetMotionMaster()->GetCurrentMovementGeneratorType() != POINT_MOTION_TYPE)) - m_creature->GetMotionMaster()->Clear(false); - - if(MovementTimer < diff) - { - uint32 random = rand()%8; - if(random < 7) - m_creature->GetMotionMaster()->MovePoint(0, MovementLocations[random][0], MovementLocations[random][1], MovementLocations[random][2]); - else - { - DoTextEmote(EMOTE_BREATH, NULL); - DoCast(m_creature->getVictim(), SPELL_DEEPBREATH); - } - MovementTimer = 25000; - }else MovementTimer -= diff; - - if(EngulfingFlamesTimer < diff) - { - DoCast(SelectUnit(SELECT_TARGET_RANDOM, 0), SPELL_ENGULFINGFLAMES); - EngulfingFlamesTimer = 10000; - }else EngulfingFlamesTimer -= diff; - - if(SummonWhelpsTimer < diff) - { - uint32 max = rand()%20; - for(uint8 i = 0; i < max; ++i) - { - uint8 random = rand()%4; - Creature* Whelp = m_creature->SummonCreature(CREATURE_WHELP, SpawnLocations[random][0], SpawnLocations[random][1], SpawnLocations[random][2], 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 30000); - if(Whelp) - Whelp->AI()->AttackStart(SelectUnit(SELECT_TARGET_RANDOM, 0)); - } - SummonWhelpsTimer = 45000; - }else SummonWhelpsTimer -= diff; - } - - if(Phase == 3) - { - if(BellowingRoarTimer < diff) - { - DoCast(m_creature->getVictim(), SPELL_BELLOWINGROAR); - BellowingRoarTimer = 30000; - }else BellowingRoarTimer -= diff; - } - } -}; - -CreatureAI* GetAI_boss_onyxiaAI(Creature *_Creature) -{ - return new boss_onyxiaAI (_Creature); -} - -void AddSC_boss_onyxia() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_onyxia"; - newscript->GetAI = GetAI_boss_onyxiaAI; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Onyxia +SD%Complete: 50 +SDComment: Phase 2 has many errors. Recommend Rewrite of entire script. +SDCategory: Onyxia's Lair +EndScriptData */ + +#include "precompiled.h" + +#define SPELL_WINGBUFFET 18500 +#define SPELL_FLAMEBREATH 18435 +#define SPELL_CLEAVE 19983 +#define SPELL_TAILSWEEP 15847 +#define SPELL_KNOCK_AWAY 19633 + +#define SPELL_ENGULFINGFLAMES 20019 +#define SPELL_DEEPBREATH 23461 +#define SPELL_FIREBALL 18392 + +#define SPELL_BELLOWINGROAR 18431 +#define SPELL_HEATED_GROUND 22191 + +#define SPELL_SUMMONWHELP 17646 + +#define SAY_AGGRO "How fortuitous. Usually, I must leave my lair to feed." +#define SAY_KILL "Learn your place mortal!" +#define SAY_PHASE_2_TRANS "This meaningless exertion bores me. I'll incinerate you from above!" +#define SAY_PHASE_3_TRANS "It seems you'll need another lesson!" +#define EMOTE_BREATH "takes a deep breath..." + +static float MovementLocations[7][3]= +{ + {-65.8444, -213.809, -60.2985}, + {22.87639, -217.152, -60.0548}, + {-33.5561, -182.682, -60.9457}, + {-31.4963, -250.123, -60.1278}, + {-2.78999, -181.431, -60.8962}, + {-54.9415, -232.242, -60.5555}, + {10.56655, -241.478, -60.9426}, +}; + +static float SpawnLocations[4][3]= +{ + {-30.127, -254.463, -89.440}, + {-30.817, -177.106, -89.258}, + {14.480, -241.560, -85.6300}, + {17.372, -190.840, -85.2810}, +}; + +#define CREATURE_WHELP 11262 + +struct MANGOS_DLL_DECL boss_onyxiaAI : public ScriptedAI +{ + boss_onyxiaAI(Creature* c) : ScriptedAI(c) {Reset();} + + uint32 Phase; + + uint32 FlameBreathTimer; + uint32 CleaveTimer; + uint32 TailSweepTimer; + uint32 MovementTimer; + uint32 EngulfingFlamesTimer; + uint32 SummonWhelpsTimer; + uint32 BellowingRoarTimer; + uint32 WingBuffetTimer; + + void Reset() + { + Phase = 1; + + FlameBreathTimer = 20000; + TailSweepTimer = 2000; + CleaveTimer = 15000; + MovementTimer = 5000; + EngulfingFlamesTimer = 15000; + SummonWhelpsTimer = 45000; + BellowingRoarTimer = 30000; + WingBuffetTimer = 17000; + } + + void Aggro(Unit* who) + { + DoYell(SAY_AGGRO, LANG_UNIVERSAL, NULL); + } + + void KilledUnit(Unit *victim) + { + DoYell(SAY_KILL, LANG_UNIVERSAL, NULL); + } + + void UpdateAI(const uint32 diff) + { + if(!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + if(((m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < 60) && (Phase == 1)) + { + Phase = 2; + m_creature->HandleEmoteCommand(EMOTE_ONESHOT_LIFTOFF); + m_creature->AddUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT + MOVEMENTFLAG_LEVITATING); + m_creature->GetMotionMaster()->Clear(false); + m_creature->GetMotionMaster()->MoveIdle(); + DoYell(SAY_PHASE_2_TRANS, LANG_UNIVERSAL, NULL); + } + + if(((m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < 40) && (Phase == 2)) + { + Phase = 3; + m_creature->RemoveUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT + MOVEMENTFLAG_LEVITATING); + m_creature->HandleEmoteCommand(EMOTE_ONESHOT_LAND); + DoYell(SAY_PHASE_3_TRANS, LANG_UNIVERSAL, NULL); + } + + if(Phase == 1 || Phase == 3) + { + if(FlameBreathTimer < diff) + { + DoCast(m_creature->getVictim(), SPELL_FLAMEBREATH); + FlameBreathTimer = 15000; + }else FlameBreathTimer -= diff; + + if(TailSweepTimer < diff) + { + Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 1); + if(target && !m_creature->HasInArc(M_PI, target)) + DoCast(target, SPELL_TAILSWEEP); + + TailSweepTimer = 10000; + }else TailSweepTimer -= diff; + + if(CleaveTimer < diff) + { + DoCast(m_creature->getVictim(), SPELL_CLEAVE); + CleaveTimer = 10000; + }else CleaveTimer -= diff; + + if(WingBuffetTimer < diff) + { + DoCast(m_creature->getVictim(), SPELL_WINGBUFFET); + WingBuffetTimer = 7000 + ((rand()%8)*1000); + }else WingBuffetTimer -= diff; + + DoMeleeAttackIfReady(); + } + + if(Phase == 2) + { + if(!m_creature->isHover()) + { + m_creature->HandleEmoteCommand(EMOTE_ONESHOT_LIFTOFF); + m_creature->SetHover(true); + } + + if(!m_creature->GetMotionMaster()->empty() && (m_creature->GetMotionMaster()->GetCurrentMovementGeneratorType() != POINT_MOTION_TYPE)) + m_creature->GetMotionMaster()->Clear(false); + + if(MovementTimer < diff) + { + uint32 random = rand()%8; + if(random < 7) + m_creature->GetMotionMaster()->MovePoint(0, MovementLocations[random][0], MovementLocations[random][1], MovementLocations[random][2]); + else + { + DoTextEmote(EMOTE_BREATH, NULL); + DoCast(m_creature->getVictim(), SPELL_DEEPBREATH); + } + MovementTimer = 25000; + }else MovementTimer -= diff; + + if(EngulfingFlamesTimer < diff) + { + DoCast(SelectUnit(SELECT_TARGET_RANDOM, 0), SPELL_ENGULFINGFLAMES); + EngulfingFlamesTimer = 10000; + }else EngulfingFlamesTimer -= diff; + + if(SummonWhelpsTimer < diff) + { + uint32 max = rand()%20; + for(uint8 i = 0; i < max; ++i) + { + uint8 random = rand()%4; + Creature* Whelp = m_creature->SummonCreature(CREATURE_WHELP, SpawnLocations[random][0], SpawnLocations[random][1], SpawnLocations[random][2], 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 30000); + if(Whelp) + Whelp->AI()->AttackStart(SelectUnit(SELECT_TARGET_RANDOM, 0)); + } + SummonWhelpsTimer = 45000; + }else SummonWhelpsTimer -= diff; + } + + if(Phase == 3) + { + if(BellowingRoarTimer < diff) + { + DoCast(m_creature->getVictim(), SPELL_BELLOWINGROAR); + BellowingRoarTimer = 30000; + }else BellowingRoarTimer -= diff; + } + } +}; + +CreatureAI* GetAI_boss_onyxiaAI(Creature *_Creature) +{ + return new boss_onyxiaAI (_Creature); +} + +void AddSC_boss_onyxia() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_onyxia"; + newscript->GetAI = GetAI_boss_onyxiaAI; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/orgrimmar/orgrimmar.cpp b/src/bindings/scripts/scripts/zone/orgrimmar/orgrimmar.cpp index 9840f7711dc..c14aceaf121 100644 --- a/src/bindings/scripts/scripts/zone/orgrimmar/orgrimmar.cpp +++ b/src/bindings/scripts/scripts/zone/orgrimmar/orgrimmar.cpp @@ -1,265 +1,265 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Orgrimmar -SD%Complete: 100 -SDComment: Quest support: 2460, 5727, 6566 -SDCategory: Orgrimmar -EndScriptData */ - -/* ContentData -npc_neeru_fireblade npc_text + gossip options text missing -npc_shenthul -npc_thrall_warchief -EndContentData */ - -#include "precompiled.h" - -/*###### -## npc_neeru_fireblade -######*/ - -#define QUEST_5727 5727 - -bool GossipHello_npc_neeru_fireblade(Player *player, Creature *_Creature) -{ - if (_Creature->isQuestGiver()) - player->PrepareQuestMenu( _Creature->GetGUID() ); - - if (player->GetQuestStatus(QUEST_5727) == QUEST_STATUS_INCOMPLETE) - player->ADD_GOSSIP_ITEM(0, "You may speak frankly, Neeru...", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); - - player->SEND_GOSSIP_MENU(4513, _Creature->GetGUID()); - return true; -} - -bool GossipSelect_npc_neeru_fireblade(Player *player, Creature *_Creature, uint32 sender, uint32 action) -{ - switch (action) - { - case GOSSIP_ACTION_INFO_DEF+1: - player->ADD_GOSSIP_ITEM(0, "[PH] ...", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2); - player->SEND_GOSSIP_MENU(4513, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+2: - player->CLOSE_GOSSIP_MENU(); - player->AreaExploredOrEventHappens(QUEST_5727); - break; - } - return true; -} - -/*###### -## npc_shenthul -######*/ - -#define QUEST_2460 2460 - -struct MANGOS_DLL_DECL npc_shenthulAI : public ScriptedAI -{ - npc_shenthulAI(Creature* c) : ScriptedAI(c) { Reset(); } - - bool CanTalk; - bool CanEmote; - uint32 Salute_Timer; - uint32 Reset_Timer; - uint64 playerGUID; - - void Reset() - { - CanTalk = false; - CanEmote = false; - Salute_Timer = 6000; - Reset_Timer = 0; - playerGUID = 0; - } - - void Aggro(Unit* who) { } - - void UpdateAI(const uint32 diff) - { - if( CanEmote ) - if( Reset_Timer < diff ) - { - if( Unit* temp = Unit::GetUnit((*m_creature),playerGUID) ) - if( temp->GetTypeId() == TYPEID_PLAYER ) - ((Player*)temp)->FailQuest(QUEST_2460); - Reset(); - } else Reset_Timer -= diff; - - if( CanTalk && !CanEmote ) - if( Salute_Timer < diff ) - { - m_creature->HandleEmoteCommand(EMOTE_ONESHOT_SALUTE); - CanEmote = true; - Reset_Timer = 60000; - } else Salute_Timer -= diff; - - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - DoMeleeAttackIfReady(); - } -}; -CreatureAI* GetAI_npc_shenthul(Creature *_Creature) -{ - return new npc_shenthulAI (_Creature); -} - -bool QuestAccept_npc_shenthul(Player* player, Creature* creature, Quest const* quest) -{ - if( quest->GetQuestId() == QUEST_2460 ) - { - ((npc_shenthulAI*)creature->AI())->CanTalk = true; - ((npc_shenthulAI*)creature->AI())->playerGUID = player->GetGUID(); - } - return true; -} - -bool ReciveEmote_npc_shenthul(Player *player, Creature *_Creature, uint32 emote) -{ - if( emote == TEXTEMOTE_SALUTE && player->GetQuestStatus(QUEST_2460) == QUEST_STATUS_INCOMPLETE ) - if( ((npc_shenthulAI*)_Creature->AI())->CanEmote ) - { - player->AreaExploredOrEventHappens(QUEST_2460); - ((npc_shenthulAI*)_Creature->AI())->Reset(); - } - return true; -} - -/*###### -## npc_thrall_warchief -######*/ - -#define QUEST_6566 6566 - -#define SPELL_CHAIN_LIGHTNING 16033 -#define SPELL_SHOCK 16034 - -//TODO: verify abilities/timers -struct MANGOS_DLL_DECL npc_thrall_warchiefAI : public ScriptedAI -{ - npc_thrall_warchiefAI(Creature* c) : ScriptedAI(c) { Reset(); } - - uint32 ChainLightning_Timer; - uint32 Shock_Timer; - - void Reset() - { - ChainLightning_Timer = 2000; - Shock_Timer = 8000; - } - - void Aggro(Unit *who) {} - - void UpdateAI(const uint32 diff) - { - if(!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - if( ChainLightning_Timer < diff ) - { - DoCast(m_creature->getVictim(),SPELL_CHAIN_LIGHTNING); - ChainLightning_Timer = 9000; - }else ChainLightning_Timer -= diff; - - if( Shock_Timer < diff ) - { - DoCast(m_creature->getVictim(),SPELL_SHOCK); - Shock_Timer = 15000; - }else Shock_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; -CreatureAI* GetAI_npc_thrall_warchief(Creature *_Creature) -{ - return new npc_thrall_warchiefAI (_Creature); -} - -bool GossipHello_npc_thrall_warchief(Player *player, Creature *_Creature) -{ - if (_Creature->isQuestGiver()) - player->PrepareQuestMenu( _Creature->GetGUID() ); - - if (player->GetQuestStatus(QUEST_6566) == QUEST_STATUS_INCOMPLETE) - player->ADD_GOSSIP_ITEM(0, "Please share your wisdom with me, Warchief.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); - - player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); - return true; -} - -bool GossipSelect_npc_thrall_warchief(Player *player, Creature *_Creature, uint32 sender, uint32 action) -{ - switch (action) - { - case GOSSIP_ACTION_INFO_DEF+1: - player->ADD_GOSSIP_ITEM(0, "What discoveries?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2); - player->SEND_GOSSIP_MENU(5733, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+2: - player->ADD_GOSSIP_ITEM(0, "Usurper?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+3); - player->SEND_GOSSIP_MENU(5734, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+3: - player->ADD_GOSSIP_ITEM(0, "With all due respect, Warchief - why not allow them to be destroyed? Does this not strengthen our position?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+4); - player->SEND_GOSSIP_MENU(5735, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+4: - player->ADD_GOSSIP_ITEM(0, "I... I did not think of it that way, Warchief.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+5); - player->SEND_GOSSIP_MENU(5736, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+5: - player->ADD_GOSSIP_ITEM(0, "I live only to serve, Warchief! My life is empty and meaningless without your guidance.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+6); - player->SEND_GOSSIP_MENU(5737, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+6: - player->ADD_GOSSIP_ITEM(0, "Of course, Warchief!", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+7); - player->SEND_GOSSIP_MENU(5738, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+7: - player->CLOSE_GOSSIP_MENU(); - player->AreaExploredOrEventHappens(QUEST_6566); - break; - } - return true; -} - -void AddSC_orgrimmar() -{ - Script *newscript; - - newscript = new Script; - newscript->Name="npc_neeru_fireblade"; - newscript->pGossipHello = &GossipHello_npc_neeru_fireblade; - newscript->pGossipSelect = &GossipSelect_npc_neeru_fireblade; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="npc_shenthul"; - newscript->GetAI = GetAI_npc_shenthul; - newscript->pQuestAccept = &QuestAccept_npc_shenthul; - newscript->pReceiveEmote = &ReciveEmote_npc_shenthul; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="npc_thrall_warchief"; - newscript->GetAI = GetAI_npc_thrall_warchief; - newscript->pGossipHello = &GossipHello_npc_thrall_warchief; - newscript->pGossipSelect = &GossipSelect_npc_thrall_warchief; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Orgrimmar +SD%Complete: 100 +SDComment: Quest support: 2460, 5727, 6566 +SDCategory: Orgrimmar +EndScriptData */ + +/* ContentData +npc_neeru_fireblade npc_text + gossip options text missing +npc_shenthul +npc_thrall_warchief +EndContentData */ + +#include "precompiled.h" + +/*###### +## npc_neeru_fireblade +######*/ + +#define QUEST_5727 5727 + +bool GossipHello_npc_neeru_fireblade(Player *player, Creature *_Creature) +{ + if (_Creature->isQuestGiver()) + player->PrepareQuestMenu( _Creature->GetGUID() ); + + if (player->GetQuestStatus(QUEST_5727) == QUEST_STATUS_INCOMPLETE) + player->ADD_GOSSIP_ITEM(0, "You may speak frankly, Neeru...", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); + + player->SEND_GOSSIP_MENU(4513, _Creature->GetGUID()); + return true; +} + +bool GossipSelect_npc_neeru_fireblade(Player *player, Creature *_Creature, uint32 sender, uint32 action) +{ + switch (action) + { + case GOSSIP_ACTION_INFO_DEF+1: + player->ADD_GOSSIP_ITEM(0, "[PH] ...", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2); + player->SEND_GOSSIP_MENU(4513, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+2: + player->CLOSE_GOSSIP_MENU(); + player->AreaExploredOrEventHappens(QUEST_5727); + break; + } + return true; +} + +/*###### +## npc_shenthul +######*/ + +#define QUEST_2460 2460 + +struct MANGOS_DLL_DECL npc_shenthulAI : public ScriptedAI +{ + npc_shenthulAI(Creature* c) : ScriptedAI(c) { Reset(); } + + bool CanTalk; + bool CanEmote; + uint32 Salute_Timer; + uint32 Reset_Timer; + uint64 playerGUID; + + void Reset() + { + CanTalk = false; + CanEmote = false; + Salute_Timer = 6000; + Reset_Timer = 0; + playerGUID = 0; + } + + void Aggro(Unit* who) { } + + void UpdateAI(const uint32 diff) + { + if( CanEmote ) + if( Reset_Timer < diff ) + { + if( Unit* temp = Unit::GetUnit((*m_creature),playerGUID) ) + if( temp->GetTypeId() == TYPEID_PLAYER ) + ((Player*)temp)->FailQuest(QUEST_2460); + Reset(); + } else Reset_Timer -= diff; + + if( CanTalk && !CanEmote ) + if( Salute_Timer < diff ) + { + m_creature->HandleEmoteCommand(EMOTE_ONESHOT_SALUTE); + CanEmote = true; + Reset_Timer = 60000; + } else Salute_Timer -= diff; + + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + DoMeleeAttackIfReady(); + } +}; +CreatureAI* GetAI_npc_shenthul(Creature *_Creature) +{ + return new npc_shenthulAI (_Creature); +} + +bool QuestAccept_npc_shenthul(Player* player, Creature* creature, Quest const* quest) +{ + if( quest->GetQuestId() == QUEST_2460 ) + { + ((npc_shenthulAI*)creature->AI())->CanTalk = true; + ((npc_shenthulAI*)creature->AI())->playerGUID = player->GetGUID(); + } + return true; +} + +bool ReciveEmote_npc_shenthul(Player *player, Creature *_Creature, uint32 emote) +{ + if( emote == TEXTEMOTE_SALUTE && player->GetQuestStatus(QUEST_2460) == QUEST_STATUS_INCOMPLETE ) + if( ((npc_shenthulAI*)_Creature->AI())->CanEmote ) + { + player->AreaExploredOrEventHappens(QUEST_2460); + ((npc_shenthulAI*)_Creature->AI())->Reset(); + } + return true; +} + +/*###### +## npc_thrall_warchief +######*/ + +#define QUEST_6566 6566 + +#define SPELL_CHAIN_LIGHTNING 16033 +#define SPELL_SHOCK 16034 + +//TODO: verify abilities/timers +struct MANGOS_DLL_DECL npc_thrall_warchiefAI : public ScriptedAI +{ + npc_thrall_warchiefAI(Creature* c) : ScriptedAI(c) { Reset(); } + + uint32 ChainLightning_Timer; + uint32 Shock_Timer; + + void Reset() + { + ChainLightning_Timer = 2000; + Shock_Timer = 8000; + } + + void Aggro(Unit *who) {} + + void UpdateAI(const uint32 diff) + { + if(!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + if( ChainLightning_Timer < diff ) + { + DoCast(m_creature->getVictim(),SPELL_CHAIN_LIGHTNING); + ChainLightning_Timer = 9000; + }else ChainLightning_Timer -= diff; + + if( Shock_Timer < diff ) + { + DoCast(m_creature->getVictim(),SPELL_SHOCK); + Shock_Timer = 15000; + }else Shock_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; +CreatureAI* GetAI_npc_thrall_warchief(Creature *_Creature) +{ + return new npc_thrall_warchiefAI (_Creature); +} + +bool GossipHello_npc_thrall_warchief(Player *player, Creature *_Creature) +{ + if (_Creature->isQuestGiver()) + player->PrepareQuestMenu( _Creature->GetGUID() ); + + if (player->GetQuestStatus(QUEST_6566) == QUEST_STATUS_INCOMPLETE) + player->ADD_GOSSIP_ITEM(0, "Please share your wisdom with me, Warchief.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); + + player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); + return true; +} + +bool GossipSelect_npc_thrall_warchief(Player *player, Creature *_Creature, uint32 sender, uint32 action) +{ + switch (action) + { + case GOSSIP_ACTION_INFO_DEF+1: + player->ADD_GOSSIP_ITEM(0, "What discoveries?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2); + player->SEND_GOSSIP_MENU(5733, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+2: + player->ADD_GOSSIP_ITEM(0, "Usurper?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+3); + player->SEND_GOSSIP_MENU(5734, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+3: + player->ADD_GOSSIP_ITEM(0, "With all due respect, Warchief - why not allow them to be destroyed? Does this not strengthen our position?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+4); + player->SEND_GOSSIP_MENU(5735, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+4: + player->ADD_GOSSIP_ITEM(0, "I... I did not think of it that way, Warchief.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+5); + player->SEND_GOSSIP_MENU(5736, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+5: + player->ADD_GOSSIP_ITEM(0, "I live only to serve, Warchief! My life is empty and meaningless without your guidance.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+6); + player->SEND_GOSSIP_MENU(5737, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+6: + player->ADD_GOSSIP_ITEM(0, "Of course, Warchief!", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+7); + player->SEND_GOSSIP_MENU(5738, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+7: + player->CLOSE_GOSSIP_MENU(); + player->AreaExploredOrEventHappens(QUEST_6566); + break; + } + return true; +} + +void AddSC_orgrimmar() +{ + Script *newscript; + + newscript = new Script; + newscript->Name="npc_neeru_fireblade"; + newscript->pGossipHello = &GossipHello_npc_neeru_fireblade; + newscript->pGossipSelect = &GossipSelect_npc_neeru_fireblade; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="npc_shenthul"; + newscript->GetAI = GetAI_npc_shenthul; + newscript->pQuestAccept = &QuestAccept_npc_shenthul; + newscript->pReceiveEmote = &ReciveEmote_npc_shenthul; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="npc_thrall_warchief"; + newscript->GetAI = GetAI_npc_thrall_warchief; + newscript->pGossipHello = &GossipHello_npc_thrall_warchief; + newscript->pGossipSelect = &GossipSelect_npc_thrall_warchief; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/razorfen_downs/boss_amnennar_the_coldbringer.cpp b/src/bindings/scripts/scripts/zone/razorfen_downs/boss_amnennar_the_coldbringer.cpp index d25781c0ca6..a7cdf773e63 100644 --- a/src/bindings/scripts/scripts/zone/razorfen_downs/boss_amnennar_the_coldbringer.cpp +++ b/src/bindings/scripts/scripts/zone/razorfen_downs/boss_amnennar_the_coldbringer.cpp @@ -1,140 +1,140 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Amnennar_the_coldbringer -SD%Complete: 100 -SDComment: -SDCategory: Razorfen Downs -EndScriptData */ - -#include "precompiled.h" - -#define SAY_0 "You'll never leave this place... alive." -#define SAY_1 "Come, spirits, attend your master." -#define SAY_SLAY "Too...easy!" -#define SOUND_AGGRO 5825 -#define SOUND_SLAY 5826 -#define SOUND_SUMMON 5829 - -#define SPELL_AMNENNARSWRATH 13009 -#define SPELL_FROSTBOLT 10179 - -struct MANGOS_DLL_DECL boss_amnennar_the_coldbringerAI : public ScriptedAI -{ - boss_amnennar_the_coldbringerAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 AmnenarsWrath_Timer; - uint32 FrostBolt_Timer; - bool Spectrals; - int Rand; - int RandX; - int RandY; - Creature* Summoned; - - void Reset() - { - AmnenarsWrath_Timer = 8000; - FrostBolt_Timer = 1000; - Spectrals = false; - } - - void Aggro(Unit *who) - { - DoYell(SAY_0,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_AGGRO); - } - - void KilledUnit() - { - DoYell(SAY_SLAY, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_SLAY); - } - - void SummonSpectrals(Unit* victim) - { - Rand = rand()%5; - switch (rand()%2) - { - case 0: RandX = 0 - Rand; break; - case 1: RandX = 0 + Rand; break; - } - Rand = 0; - Rand = rand()%5; - switch (rand()%2) - { - case 0: RandY = 0 - Rand; break; - case 1: RandY = 0 + Rand; break; - } - Rand = 0; - Summoned = DoSpawnCreature(8585, RandX, RandY, 0, 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 60000); - if(Summoned) - ((CreatureAI*)Summoned->AI())->AttackStart(victim); - } - - void UpdateAI(const uint32 diff) - { - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - //AmnenarsWrath_Timer - if (AmnenarsWrath_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_AMNENNARSWRATH); - AmnenarsWrath_Timer = 12000; - } else AmnenarsWrath_Timer -= diff; - - //FrostBolt_Timer - if (FrostBolt_Timer < diff) - { - Unit* target = NULL; - target = SelectUnit(SELECT_TARGET_RANDOM,0); - if (target) DoCast(target,SPELL_FROSTBOLT); - - FrostBolt_Timer = 8000; - } else FrostBolt_Timer -= diff; - - if ( !Spectrals && m_creature->GetHealth()*100 / m_creature->GetMaxHealth() < 50 ) - { - DoYell(SAY_1, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_SUMMON); - - Unit* target = NULL; - target = SelectUnit(SELECT_TARGET_RANDOM,0); - - SummonSpectrals(target); - SummonSpectrals(target); - SummonSpectrals(target); - Spectrals = true; - } - - DoMeleeAttackIfReady(); - } -}; - -CreatureAI* GetAI_boss_amnennar_the_coldbringer(Creature *_Creature) -{ - return new boss_amnennar_the_coldbringerAI (_Creature); -} - -void AddSC_boss_amnennar_the_coldbringer() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_amnennar_the_coldbringer"; - newscript->GetAI = GetAI_boss_amnennar_the_coldbringer; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Amnennar_the_coldbringer +SD%Complete: 100 +SDComment: +SDCategory: Razorfen Downs +EndScriptData */ + +#include "precompiled.h" + +#define SAY_0 "You'll never leave this place... alive." +#define SAY_1 "Come, spirits, attend your master." +#define SAY_SLAY "Too...easy!" +#define SOUND_AGGRO 5825 +#define SOUND_SLAY 5826 +#define SOUND_SUMMON 5829 + +#define SPELL_AMNENNARSWRATH 13009 +#define SPELL_FROSTBOLT 10179 + +struct MANGOS_DLL_DECL boss_amnennar_the_coldbringerAI : public ScriptedAI +{ + boss_amnennar_the_coldbringerAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 AmnenarsWrath_Timer; + uint32 FrostBolt_Timer; + bool Spectrals; + int Rand; + int RandX; + int RandY; + Creature* Summoned; + + void Reset() + { + AmnenarsWrath_Timer = 8000; + FrostBolt_Timer = 1000; + Spectrals = false; + } + + void Aggro(Unit *who) + { + DoYell(SAY_0,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_AGGRO); + } + + void KilledUnit() + { + DoYell(SAY_SLAY, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_SLAY); + } + + void SummonSpectrals(Unit* victim) + { + Rand = rand()%5; + switch (rand()%2) + { + case 0: RandX = 0 - Rand; break; + case 1: RandX = 0 + Rand; break; + } + Rand = 0; + Rand = rand()%5; + switch (rand()%2) + { + case 0: RandY = 0 - Rand; break; + case 1: RandY = 0 + Rand; break; + } + Rand = 0; + Summoned = DoSpawnCreature(8585, RandX, RandY, 0, 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 60000); + if(Summoned) + ((CreatureAI*)Summoned->AI())->AttackStart(victim); + } + + void UpdateAI(const uint32 diff) + { + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + //AmnenarsWrath_Timer + if (AmnenarsWrath_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_AMNENNARSWRATH); + AmnenarsWrath_Timer = 12000; + } else AmnenarsWrath_Timer -= diff; + + //FrostBolt_Timer + if (FrostBolt_Timer < diff) + { + Unit* target = NULL; + target = SelectUnit(SELECT_TARGET_RANDOM,0); + if (target) DoCast(target,SPELL_FROSTBOLT); + + FrostBolt_Timer = 8000; + } else FrostBolt_Timer -= diff; + + if ( !Spectrals && m_creature->GetHealth()*100 / m_creature->GetMaxHealth() < 50 ) + { + DoYell(SAY_1, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_SUMMON); + + Unit* target = NULL; + target = SelectUnit(SELECT_TARGET_RANDOM,0); + + SummonSpectrals(target); + SummonSpectrals(target); + SummonSpectrals(target); + Spectrals = true; + } + + DoMeleeAttackIfReady(); + } +}; + +CreatureAI* GetAI_boss_amnennar_the_coldbringer(Creature *_Creature) +{ + return new boss_amnennar_the_coldbringerAI (_Creature); +} + +void AddSC_boss_amnennar_the_coldbringer() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_amnennar_the_coldbringer"; + newscript->GetAI = GetAI_boss_amnennar_the_coldbringer; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/ruins_of_ahnqiraj/boss_ayamiss.cpp b/src/bindings/scripts/scripts/zone/ruins_of_ahnqiraj/boss_ayamiss.cpp index f448351d255..d1e0990c27a 100644 --- a/src/bindings/scripts/scripts/zone/ruins_of_ahnqiraj/boss_ayamiss.cpp +++ b/src/bindings/scripts/scripts/zone/ruins_of_ahnqiraj/boss_ayamiss.cpp @@ -1,107 +1,107 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Ayamiss -SD%Complete: 50 -SDComment: VERIFY SCRIPT -SDCategory: Ruins of Ahn'Qiraj -EndScriptData */ - -#include "precompiled.h" - -/* -To do: -make him fly from 70-100% -*/ - -#define SPELL_STINGERSPRAY 25749 -#define SPELL_POISONSTINGER 25748 //only used in phase1 -#define SPELL_SUMMONSWARMER 25844 //might be 25708 -// #define SPELL_PARALYZE 23414 doesnt work correct (core) - -struct MANGOS_DLL_DECL boss_ayamissAI : public ScriptedAI -{ - boss_ayamissAI(Creature *c) : ScriptedAI(c) {Reset();} - - Unit *pTarget; - uint32 STINGERSPRAY_Timer; - uint32 POISONSTINGER_Timer; - uint32 SUMMONSWARMER_Timer; - uint32 phase; - - void Reset() - { - pTarget = NULL; - STINGERSPRAY_Timer = 30000; - POISONSTINGER_Timer = 30000; - SUMMONSWARMER_Timer = 60000; - phase=1; - } - - void Aggro(Unit *who) - { - pTarget = who; - } - - void UpdateAI(const uint32 diff) - { - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - //If he is 70% start phase 2 - if (phase==1 && m_creature->GetHealth()*100 / m_creature->GetMaxHealth() <= 70 && !m_creature->IsNonMeleeSpellCasted(false)) - { - phase=2; - } - - //STINGERSPRAY_Timer (only in phase2) - if (phase==2 && STINGERSPRAY_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_STINGERSPRAY); - STINGERSPRAY_Timer = 30000; - }else STINGERSPRAY_Timer -= diff; - - //POISONSTINGER_Timer (only in phase1) - if (phase==1 && POISONSTINGER_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_POISONSTINGER); - POISONSTINGER_Timer = 30000; - }else POISONSTINGER_Timer -= diff; - - //SUMMONSWARMER_Timer (only in phase1) - if (SUMMONSWARMER_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_SUMMONSWARMER); - SUMMONSWARMER_Timer = 60000; - }else SUMMONSWARMER_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; -CreatureAI* GetAI_boss_ayamiss(Creature *_Creature) -{ - return new boss_ayamissAI (_Creature); -} - -void AddSC_boss_ayamiss() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_ayamiss"; - newscript->GetAI = GetAI_boss_ayamiss; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Ayamiss +SD%Complete: 50 +SDComment: VERIFY SCRIPT +SDCategory: Ruins of Ahn'Qiraj +EndScriptData */ + +#include "precompiled.h" + +/* +To do: +make him fly from 70-100% +*/ + +#define SPELL_STINGERSPRAY 25749 +#define SPELL_POISONSTINGER 25748 //only used in phase1 +#define SPELL_SUMMONSWARMER 25844 //might be 25708 +// #define SPELL_PARALYZE 23414 doesnt work correct (core) + +struct MANGOS_DLL_DECL boss_ayamissAI : public ScriptedAI +{ + boss_ayamissAI(Creature *c) : ScriptedAI(c) {Reset();} + + Unit *pTarget; + uint32 STINGERSPRAY_Timer; + uint32 POISONSTINGER_Timer; + uint32 SUMMONSWARMER_Timer; + uint32 phase; + + void Reset() + { + pTarget = NULL; + STINGERSPRAY_Timer = 30000; + POISONSTINGER_Timer = 30000; + SUMMONSWARMER_Timer = 60000; + phase=1; + } + + void Aggro(Unit *who) + { + pTarget = who; + } + + void UpdateAI(const uint32 diff) + { + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + //If he is 70% start phase 2 + if (phase==1 && m_creature->GetHealth()*100 / m_creature->GetMaxHealth() <= 70 && !m_creature->IsNonMeleeSpellCasted(false)) + { + phase=2; + } + + //STINGERSPRAY_Timer (only in phase2) + if (phase==2 && STINGERSPRAY_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_STINGERSPRAY); + STINGERSPRAY_Timer = 30000; + }else STINGERSPRAY_Timer -= diff; + + //POISONSTINGER_Timer (only in phase1) + if (phase==1 && POISONSTINGER_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_POISONSTINGER); + POISONSTINGER_Timer = 30000; + }else POISONSTINGER_Timer -= diff; + + //SUMMONSWARMER_Timer (only in phase1) + if (SUMMONSWARMER_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_SUMMONSWARMER); + SUMMONSWARMER_Timer = 60000; + }else SUMMONSWARMER_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; +CreatureAI* GetAI_boss_ayamiss(Creature *_Creature) +{ + return new boss_ayamissAI (_Creature); +} + +void AddSC_boss_ayamiss() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_ayamiss"; + newscript->GetAI = GetAI_boss_ayamiss; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/ruins_of_ahnqiraj/boss_buru.cpp b/src/bindings/scripts/scripts/zone/ruins_of_ahnqiraj/boss_buru.cpp index 65bec030fe9..e2e16fdbbd3 100644 --- a/src/bindings/scripts/scripts/zone/ruins_of_ahnqiraj/boss_buru.cpp +++ b/src/bindings/scripts/scripts/zone/ruins_of_ahnqiraj/boss_buru.cpp @@ -1,24 +1,24 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Buru -SD%Complete: 0 -SDComment: Place Holder -SDCategory: Ruins of Ahn'Qiraj -EndScriptData */ - -#include "precompiled.h" +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Buru +SD%Complete: 0 +SDComment: Place Holder +SDCategory: Ruins of Ahn'Qiraj +EndScriptData */ + +#include "precompiled.h" diff --git a/src/bindings/scripts/scripts/zone/ruins_of_ahnqiraj/boss_kurinnaxx.cpp b/src/bindings/scripts/scripts/zone/ruins_of_ahnqiraj/boss_kurinnaxx.cpp index 8b7411dbaa3..65651f436e8 100644 --- a/src/bindings/scripts/scripts/zone/ruins_of_ahnqiraj/boss_kurinnaxx.cpp +++ b/src/bindings/scripts/scripts/zone/ruins_of_ahnqiraj/boss_kurinnaxx.cpp @@ -1,93 +1,93 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Kurinnaxx -SD%Complete: 100 -SDComment: VERIFY SCRIPT AND SQL -SDCategory: Ruins of Ahn'Qiraj -EndScriptData */ - -#include "precompiled.h" - -#define SPELL_MORTALWOUND 25646 -#define SPELL_SANDTRAP 25656 -#define SPELL_ENRAGE 28798 - -struct MANGOS_DLL_DECL boss_kurinnaxxAI : public ScriptedAI -{ - boss_kurinnaxxAI(Creature *c) : ScriptedAI(c) {Reset();} - - Unit *pTarget; - uint32 MORTALWOUND_Timer; - uint32 SANDTRAP_Timer; - uint32 i; - - void Reset() - { - i=0; - pTarget = NULL; - MORTALWOUND_Timer = 30000; - SANDTRAP_Timer = 30000; - } - - void Aggro(Unit *who) - { - pTarget = who; - } - - void UpdateAI(const uint32 diff) - { - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - //If we are <30% cast enrage - if (i==0 && m_creature->GetHealth()*100 / m_creature->GetMaxHealth() <= 30 && !m_creature->IsNonMeleeSpellCasted(false)) - { - i=1; - DoCast(m_creature->getVictim(),SPELL_ENRAGE); - } - - //MORTALWOUND_Timer - if (MORTALWOUND_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_MORTALWOUND); - MORTALWOUND_Timer = 30000; - }else MORTALWOUND_Timer -= diff; - - //SANDTRAP_Timer - if (SANDTRAP_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_SANDTRAP); - SANDTRAP_Timer = 30000; - }else SANDTRAP_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; -CreatureAI* GetAI_boss_kurinnaxx(Creature *_Creature) -{ - return new boss_kurinnaxxAI (_Creature); -} - -void AddSC_boss_kurinnaxx() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_kurinnaxx"; - newscript->GetAI = GetAI_boss_kurinnaxx; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Kurinnaxx +SD%Complete: 100 +SDComment: VERIFY SCRIPT AND SQL +SDCategory: Ruins of Ahn'Qiraj +EndScriptData */ + +#include "precompiled.h" + +#define SPELL_MORTALWOUND 25646 +#define SPELL_SANDTRAP 25656 +#define SPELL_ENRAGE 28798 + +struct MANGOS_DLL_DECL boss_kurinnaxxAI : public ScriptedAI +{ + boss_kurinnaxxAI(Creature *c) : ScriptedAI(c) {Reset();} + + Unit *pTarget; + uint32 MORTALWOUND_Timer; + uint32 SANDTRAP_Timer; + uint32 i; + + void Reset() + { + i=0; + pTarget = NULL; + MORTALWOUND_Timer = 30000; + SANDTRAP_Timer = 30000; + } + + void Aggro(Unit *who) + { + pTarget = who; + } + + void UpdateAI(const uint32 diff) + { + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + //If we are <30% cast enrage + if (i==0 && m_creature->GetHealth()*100 / m_creature->GetMaxHealth() <= 30 && !m_creature->IsNonMeleeSpellCasted(false)) + { + i=1; + DoCast(m_creature->getVictim(),SPELL_ENRAGE); + } + + //MORTALWOUND_Timer + if (MORTALWOUND_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_MORTALWOUND); + MORTALWOUND_Timer = 30000; + }else MORTALWOUND_Timer -= diff; + + //SANDTRAP_Timer + if (SANDTRAP_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_SANDTRAP); + SANDTRAP_Timer = 30000; + }else SANDTRAP_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; +CreatureAI* GetAI_boss_kurinnaxx(Creature *_Creature) +{ + return new boss_kurinnaxxAI (_Creature); +} + +void AddSC_boss_kurinnaxx() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_kurinnaxx"; + newscript->GetAI = GetAI_boss_kurinnaxx; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/ruins_of_ahnqiraj/boss_moam.cpp b/src/bindings/scripts/scripts/zone/ruins_of_ahnqiraj/boss_moam.cpp index 42d30bb4eca..56b6ae18137 100644 --- a/src/bindings/scripts/scripts/zone/ruins_of_ahnqiraj/boss_moam.cpp +++ b/src/bindings/scripts/scripts/zone/ruins_of_ahnqiraj/boss_moam.cpp @@ -1,117 +1,117 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Moam -SD%Complete: 100 -SDComment: VERIFY SCRIPT AND SQL -SDCategory: Ruins of Ahn'Qiraj -EndScriptData */ - -#include "precompiled.h" - -#define SPELL_TRAMPLE 15550 -#define SPELL_DRAINMANA 27256 -#define SPELL_ARCANEERUPTION 25672 -#define SPELL_SUMMONMANA 25681 -#define SPELL_GRDRSLEEP 24360 //Greater Dreamless Sleep - -#define SAY_MANA "moam bristles with energy!" - -struct MANGOS_DLL_DECL boss_moamAI : public ScriptedAI -{ - boss_moamAI(Creature *c) : ScriptedAI(c) {Reset();} - - Unit *pTarget; - uint32 TRAMPLE_Timer; - uint32 DRAINMANA_Timer; - uint32 SUMMONMANA_Timer; - uint32 i; - uint32 j; - - void Reset() - { - i=0; - j=0; - pTarget = NULL; - TRAMPLE_Timer = 30000; - DRAINMANA_Timer = 30000; - } - - void Aggro(Unit *who) - { - pTarget = who; - } - - void UpdateAI(const uint32 diff) - { - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - //If we are 100%MANA cast Arcane Erruption - //if (j==1 && m_creature->GetMana()*100 / m_creature->GetMaxMana() == 100 && !m_creature->IsNonMeleeSpellCasted(false)) - { - DoCast(m_creature->getVictim(),SPELL_ARCANEERUPTION); - DoYell(SAY_MANA,LANG_UNIVERSAL,NULL); - } - - //If we are <50%HP cast MANA FIEND (Summon Mana) and Sleep - //if (i==0 && m_creature->GetHealth()*100 / m_creature->GetMaxHealth() <= 50 && !m_creature->IsNonMeleeSpellCasted(false)) - { - i=1; - DoCast(m_creature->getVictim(),SPELL_SUMMONMANA); - DoCast(m_creature->getVictim(),SPELL_GRDRSLEEP); - } - - //SUMMONMANA_Timer - if (i==1 && SUMMONMANA_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_SUMMONMANA); - SUMMONMANA_Timer = 90000; - }else SUMMONMANA_Timer -= diff; - - //TRAMPLE_Timer - if (TRAMPLE_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_TRAMPLE); - j=1; - - TRAMPLE_Timer = 30000; - }else TRAMPLE_Timer -= diff; - - //DRAINMANA_Timer - if (DRAINMANA_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_DRAINMANA); - DRAINMANA_Timer = 30000; - }else DRAINMANA_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; -CreatureAI* GetAI_boss_moam(Creature *_Creature) -{ - return new boss_moamAI (_Creature); -} - -void AddSC_boss_moam() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_moam"; - newscript->GetAI = GetAI_boss_moam; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Moam +SD%Complete: 100 +SDComment: VERIFY SCRIPT AND SQL +SDCategory: Ruins of Ahn'Qiraj +EndScriptData */ + +#include "precompiled.h" + +#define SPELL_TRAMPLE 15550 +#define SPELL_DRAINMANA 27256 +#define SPELL_ARCANEERUPTION 25672 +#define SPELL_SUMMONMANA 25681 +#define SPELL_GRDRSLEEP 24360 //Greater Dreamless Sleep + +#define SAY_MANA "moam bristles with energy!" + +struct MANGOS_DLL_DECL boss_moamAI : public ScriptedAI +{ + boss_moamAI(Creature *c) : ScriptedAI(c) {Reset();} + + Unit *pTarget; + uint32 TRAMPLE_Timer; + uint32 DRAINMANA_Timer; + uint32 SUMMONMANA_Timer; + uint32 i; + uint32 j; + + void Reset() + { + i=0; + j=0; + pTarget = NULL; + TRAMPLE_Timer = 30000; + DRAINMANA_Timer = 30000; + } + + void Aggro(Unit *who) + { + pTarget = who; + } + + void UpdateAI(const uint32 diff) + { + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + //If we are 100%MANA cast Arcane Erruption + //if (j==1 && m_creature->GetMana()*100 / m_creature->GetMaxMana() == 100 && !m_creature->IsNonMeleeSpellCasted(false)) + { + DoCast(m_creature->getVictim(),SPELL_ARCANEERUPTION); + DoYell(SAY_MANA,LANG_UNIVERSAL,NULL); + } + + //If we are <50%HP cast MANA FIEND (Summon Mana) and Sleep + //if (i==0 && m_creature->GetHealth()*100 / m_creature->GetMaxHealth() <= 50 && !m_creature->IsNonMeleeSpellCasted(false)) + { + i=1; + DoCast(m_creature->getVictim(),SPELL_SUMMONMANA); + DoCast(m_creature->getVictim(),SPELL_GRDRSLEEP); + } + + //SUMMONMANA_Timer + if (i==1 && SUMMONMANA_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_SUMMONMANA); + SUMMONMANA_Timer = 90000; + }else SUMMONMANA_Timer -= diff; + + //TRAMPLE_Timer + if (TRAMPLE_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_TRAMPLE); + j=1; + + TRAMPLE_Timer = 30000; + }else TRAMPLE_Timer -= diff; + + //DRAINMANA_Timer + if (DRAINMANA_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_DRAINMANA); + DRAINMANA_Timer = 30000; + }else DRAINMANA_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; +CreatureAI* GetAI_boss_moam(Creature *_Creature) +{ + return new boss_moamAI (_Creature); +} + +void AddSC_boss_moam() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_moam"; + newscript->GetAI = GetAI_boss_moam; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/ruins_of_ahnqiraj/boss_ossirian.cpp b/src/bindings/scripts/scripts/zone/ruins_of_ahnqiraj/boss_ossirian.cpp index a2a04673925..fadf80992a4 100644 --- a/src/bindings/scripts/scripts/zone/ruins_of_ahnqiraj/boss_ossirian.cpp +++ b/src/bindings/scripts/scripts/zone/ruins_of_ahnqiraj/boss_ossirian.cpp @@ -1,36 +1,36 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Ossirian -SD%Complete: 0 -SDComment: Place holder -SDCategory: Ruins of Ahn'Qiraj -EndScriptData */ - -#include "precompiled.h" - -//Ossirian -//8593 I am rejuvinated! -//8594 I have... failed -//8595 My powers are renewed! -//8596 My powers return! -//8597 Protect the city at all costs! -//8598 Sands of the desert rise and block out the sun! -//8599 The walls have been breached! -//8600 To your posts. Defend the city. -//8601 Tresspassers will be terminated. -//8602 You are terminated. +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Ossirian +SD%Complete: 0 +SDComment: Place holder +SDCategory: Ruins of Ahn'Qiraj +EndScriptData */ + +#include "precompiled.h" + +//Ossirian +//8593 I am rejuvinated! +//8594 I have... failed +//8595 My powers are renewed! +//8596 My powers return! +//8597 Protect the city at all costs! +//8598 Sands of the desert rise and block out the sun! +//8599 The walls have been breached! +//8600 To your posts. Defend the city. +//8601 Tresspassers will be terminated. +//8602 You are terminated. diff --git a/src/bindings/scripts/scripts/zone/ruins_of_ahnqiraj/boss_rajaxx.cpp b/src/bindings/scripts/scripts/zone/ruins_of_ahnqiraj/boss_rajaxx.cpp index 3daff71f58a..574449784e5 100644 --- a/src/bindings/scripts/scripts/zone/ruins_of_ahnqiraj/boss_rajaxx.cpp +++ b/src/bindings/scripts/scripts/zone/ruins_of_ahnqiraj/boss_rajaxx.cpp @@ -1,42 +1,42 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Rajaxx -SD%Complete: 0 -SDComment: Place Holder -SDCategory: Ruins of Ahn'Qiraj -EndScriptData */ - -#include "precompiled.h" - -//Rajaxx -//8603 Attack and make them pay dearly! -//8604 Breath your last! -//8605 Crush them! Drive them out! -//8606 Do not hesitate! Destroy them! -//8613 Warriors! Captians! Continue the fight... -//8614 You are not worth my time $N! -//8612 The time of our retribution is at hand! Let darkness reign in the hearts of our enemies! -//8610 No longer will we wait behind barred doors and walls of stone! No longer will our vengeance be denied! The dragons themselves will tremble before our wrath! -//8608 Fear is for the enemy! Fear and death! -//8611 Staghelm will whimper and beg for his life, just as his whelp of a son did! One thousand years of injustice will end this day! -//8607 Fandral! Your time has come! Go and hide in the Emerald Dream and pray we never find you! -//8609 Impudent fool! I will kill you myself! - -//Andorov - no sound -//"Remember, Rajaxx, when I said I'd kill you last? I lied..." -//"They come now. Try not to get yourself killed, young blood." +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Rajaxx +SD%Complete: 0 +SDComment: Place Holder +SDCategory: Ruins of Ahn'Qiraj +EndScriptData */ + +#include "precompiled.h" + +//Rajaxx +//8603 Attack and make them pay dearly! +//8604 Breath your last! +//8605 Crush them! Drive them out! +//8606 Do not hesitate! Destroy them! +//8613 Warriors! Captians! Continue the fight... +//8614 You are not worth my time $N! +//8612 The time of our retribution is at hand! Let darkness reign in the hearts of our enemies! +//8610 No longer will we wait behind barred doors and walls of stone! No longer will our vengeance be denied! The dragons themselves will tremble before our wrath! +//8608 Fear is for the enemy! Fear and death! +//8611 Staghelm will whimper and beg for his life, just as his whelp of a son did! One thousand years of injustice will end this day! +//8607 Fandral! Your time has come! Go and hide in the Emerald Dream and pray we never find you! +//8609 Impudent fool! I will kill you myself! + +//Andorov - no sound +//"Remember, Rajaxx, when I said I'd kill you last? I lied..." +//"They come now. Try not to get yourself killed, young blood." diff --git a/src/bindings/scripts/scripts/zone/ruins_of_ahnqiraj/instance_ruins_of_ahnqiraj.cpp b/src/bindings/scripts/scripts/zone/ruins_of_ahnqiraj/instance_ruins_of_ahnqiraj.cpp index a2bddd52efe..a4e0ebf17d4 100644 --- a/src/bindings/scripts/scripts/zone/ruins_of_ahnqiraj/instance_ruins_of_ahnqiraj.cpp +++ b/src/bindings/scripts/scripts/zone/ruins_of_ahnqiraj/instance_ruins_of_ahnqiraj.cpp @@ -1,24 +1,24 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Instance_Ruins_of_Ahnqiraj -SD%Complete: 0 -SDComment: Place holder -SDCategory: Ruins of Ahn'Qiraj -EndScriptData */ - -#include "precompiled.h" +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Instance_Ruins_of_Ahnqiraj +SD%Complete: 0 +SDComment: Place holder +SDCategory: Ruins of Ahn'Qiraj +EndScriptData */ + +#include "precompiled.h" diff --git a/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_arcanist_doan.cpp b/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_arcanist_doan.cpp index 3a6a3526269..ebd9895d0aa 100644 --- a/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_arcanist_doan.cpp +++ b/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_arcanist_doan.cpp @@ -1,171 +1,171 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Arcanist_Doan -SD%Complete: 100 -SDComment: -SDCategory: Scarlet Monastery -EndScriptData */ - -#include "precompiled.h" - -#define SPELL_POLYMORPH 12826 -#define SPELL_AOESILENCE 8988 -#define SPELL_ARCANEEXPLOSION3 8438 -#define SPELL_ARCANEEXPLOSION4 8439 -#define SPELL_FIREAOE 9435 -#define SPELL_BLINK 1953 -#define SPELL_FIREBALL 21162 -#define SPELL_MANASHIELD4 10191 -#define SPELL_ARCANEBUBBLE 9438 - -#define SAY_AGGRO "You will not defile these mysteries!" -#define SAY_SPECIALAE "Burn in righteous fire!" - -#define SOUND_AGGRO 5842 -#define SOUND_SPECIALAE 5843 - -struct MANGOS_DLL_DECL boss_arcanist_doanAI : public ScriptedAI -{ - boss_arcanist_doanAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 FullAOE_Timer; - uint32 Polymorph_Timer; - uint32 Yell_Timer; - uint32 ArcaneBubble_Timer; - uint32 AoESilence_Timer; - uint32 ArcaneExplosion3_Timer; - uint32 ArcaneExplosion4_Timer; - uint32 Blink_Timer; - uint32 Fireball_Timer; - uint32 ManaShield4_Timer; - - void Reset() - { - FullAOE_Timer = 5000; - Polymorph_Timer = 1; - Yell_Timer = 2000; - ArcaneBubble_Timer = 3000; - AoESilence_Timer = 20000; - ArcaneExplosion3_Timer = 10000; - ArcaneExplosion4_Timer = 10000; - Blink_Timer = 40000; - Fireball_Timer = 6000; - ManaShield4_Timer = 70000; - } - - void Aggro(Unit *who) - { - DoYell(SAY_AGGRO,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_AGGRO); - } - - void UpdateAI(const uint32 diff) - { - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - //If we are <50% hp cast Arcane Bubble and start casting SPECIAL FIRE AOE - if (m_creature->GetHealth()*100 / m_creature->GetMaxHealth() <= 50 && !m_creature->IsNonMeleeSpellCasted(false)) - { - if (Polymorph_Timer < diff) - { - Unit* target = NULL; - - target = SelectUnit(SELECT_TARGET_RANDOM,0); - if (target)DoCast(target,SPELL_POLYMORPH); - Polymorph_Timer = 40000; - }else Polymorph_Timer -= diff; - - if (Yell_Timer < diff) - { - DoYell(SAY_SPECIALAE,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_SPECIALAE); - Yell_Timer = 40000; - }else Yell_Timer -= diff; - - if (ArcaneBubble_Timer < diff) - { - DoCast(m_creature,SPELL_ARCANEBUBBLE); - ArcaneBubble_Timer = 40000; - }else ArcaneBubble_Timer -= diff; - - if (FullAOE_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_FIREAOE); - FullAOE_Timer = 40000; - }else FullAOE_Timer -= diff; - } - - //AoESilence_Timer - if (AoESilence_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_AOESILENCE); - AoESilence_Timer = 30000; - }else AoESilence_Timer -= diff; - - //ArcaneExplosion3_Timer - if (ArcaneExplosion3_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_ARCANEEXPLOSION3); - ArcaneExplosion3_Timer = 8000; - }else ArcaneExplosion3_Timer -= diff; - - //ArcaneExplosion4_Timer - if (ArcaneExplosion4_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_ARCANEEXPLOSION4); - ArcaneExplosion4_Timer = 10000; - }else ArcaneExplosion4_Timer -= diff; - - //Blink_Timer - if (Blink_Timer < diff) - { - DoCast(m_creature,SPELL_BLINK); - Blink_Timer = 30000; - }else Blink_Timer -= diff; - - //Fireball_Timer - if (Fireball_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_FIREBALL); - Fireball_Timer = 12000; - }else Fireball_Timer -= diff; - - //ManaShiled4_Timer - if (ManaShield4_Timer < diff) - { - DoCast(m_creature,SPELL_MANASHIELD4); - ManaShield4_Timer = 70000; - }else ManaShield4_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; -CreatureAI* GetAI_boss_arcanist_doan(Creature *_Creature) -{ - return new boss_arcanist_doanAI (_Creature); -} - -void AddSC_boss_arcanist_doan() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_arcanist_doan"; - newscript->GetAI = GetAI_boss_arcanist_doan; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Arcanist_Doan +SD%Complete: 100 +SDComment: +SDCategory: Scarlet Monastery +EndScriptData */ + +#include "precompiled.h" + +#define SPELL_POLYMORPH 12826 +#define SPELL_AOESILENCE 8988 +#define SPELL_ARCANEEXPLOSION3 8438 +#define SPELL_ARCANEEXPLOSION4 8439 +#define SPELL_FIREAOE 9435 +#define SPELL_BLINK 1953 +#define SPELL_FIREBALL 21162 +#define SPELL_MANASHIELD4 10191 +#define SPELL_ARCANEBUBBLE 9438 + +#define SAY_AGGRO "You will not defile these mysteries!" +#define SAY_SPECIALAE "Burn in righteous fire!" + +#define SOUND_AGGRO 5842 +#define SOUND_SPECIALAE 5843 + +struct MANGOS_DLL_DECL boss_arcanist_doanAI : public ScriptedAI +{ + boss_arcanist_doanAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 FullAOE_Timer; + uint32 Polymorph_Timer; + uint32 Yell_Timer; + uint32 ArcaneBubble_Timer; + uint32 AoESilence_Timer; + uint32 ArcaneExplosion3_Timer; + uint32 ArcaneExplosion4_Timer; + uint32 Blink_Timer; + uint32 Fireball_Timer; + uint32 ManaShield4_Timer; + + void Reset() + { + FullAOE_Timer = 5000; + Polymorph_Timer = 1; + Yell_Timer = 2000; + ArcaneBubble_Timer = 3000; + AoESilence_Timer = 20000; + ArcaneExplosion3_Timer = 10000; + ArcaneExplosion4_Timer = 10000; + Blink_Timer = 40000; + Fireball_Timer = 6000; + ManaShield4_Timer = 70000; + } + + void Aggro(Unit *who) + { + DoYell(SAY_AGGRO,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_AGGRO); + } + + void UpdateAI(const uint32 diff) + { + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + //If we are <50% hp cast Arcane Bubble and start casting SPECIAL FIRE AOE + if (m_creature->GetHealth()*100 / m_creature->GetMaxHealth() <= 50 && !m_creature->IsNonMeleeSpellCasted(false)) + { + if (Polymorph_Timer < diff) + { + Unit* target = NULL; + + target = SelectUnit(SELECT_TARGET_RANDOM,0); + if (target)DoCast(target,SPELL_POLYMORPH); + Polymorph_Timer = 40000; + }else Polymorph_Timer -= diff; + + if (Yell_Timer < diff) + { + DoYell(SAY_SPECIALAE,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_SPECIALAE); + Yell_Timer = 40000; + }else Yell_Timer -= diff; + + if (ArcaneBubble_Timer < diff) + { + DoCast(m_creature,SPELL_ARCANEBUBBLE); + ArcaneBubble_Timer = 40000; + }else ArcaneBubble_Timer -= diff; + + if (FullAOE_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_FIREAOE); + FullAOE_Timer = 40000; + }else FullAOE_Timer -= diff; + } + + //AoESilence_Timer + if (AoESilence_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_AOESILENCE); + AoESilence_Timer = 30000; + }else AoESilence_Timer -= diff; + + //ArcaneExplosion3_Timer + if (ArcaneExplosion3_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_ARCANEEXPLOSION3); + ArcaneExplosion3_Timer = 8000; + }else ArcaneExplosion3_Timer -= diff; + + //ArcaneExplosion4_Timer + if (ArcaneExplosion4_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_ARCANEEXPLOSION4); + ArcaneExplosion4_Timer = 10000; + }else ArcaneExplosion4_Timer -= diff; + + //Blink_Timer + if (Blink_Timer < diff) + { + DoCast(m_creature,SPELL_BLINK); + Blink_Timer = 30000; + }else Blink_Timer -= diff; + + //Fireball_Timer + if (Fireball_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_FIREBALL); + Fireball_Timer = 12000; + }else Fireball_Timer -= diff; + + //ManaShiled4_Timer + if (ManaShield4_Timer < diff) + { + DoCast(m_creature,SPELL_MANASHIELD4); + ManaShield4_Timer = 70000; + }else ManaShield4_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; +CreatureAI* GetAI_boss_arcanist_doan(Creature *_Creature) +{ + return new boss_arcanist_doanAI (_Creature); +} + +void AddSC_boss_arcanist_doan() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_arcanist_doan"; + newscript->GetAI = GetAI_boss_arcanist_doan; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_azshir_the_sleepless.cpp b/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_azshir_the_sleepless.cpp index d975cb3d192..0db96caaf5c 100644 --- a/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_azshir_the_sleepless.cpp +++ b/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_azshir_the_sleepless.cpp @@ -1,97 +1,97 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Azshir_the_Sleepless -SD%Complete: 80 -SDComment: -SDCategory: Scarlet Monastery -EndScriptData */ - -#include "precompiled.h" - -#define SPELL_CALLOFTHEGRAVE 17831 -#define SPELL_TERRIFY 7399 -#define SPELL_SOULSIPHON 7290 - -struct MANGOS_DLL_DECL boss_azshir_the_sleeplessAI : public ScriptedAI -{ - boss_azshir_the_sleeplessAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 SoulSiphon_Timer; - uint32 CallOftheGrave_Timer; - uint32 Terrify_Timer; - - void Reset() - { - SoulSiphon_Timer = 1; - CallOftheGrave_Timer = 30000; - Terrify_Timer = 20000; - } - - void Aggro(Unit *who) - { - } - - void UpdateAI(const uint32 diff) - { - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - //If we are <50% hp cast Soul Siphon rank 1 - if ( m_creature->GetHealth()*100 / m_creature->GetMaxHealth() <= 50 && !m_creature->IsNonMeleeSpellCasted(false)) - { - //SoulSiphon_Timer - if (SoulSiphon_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_SOULSIPHON); - return; - - SoulSiphon_Timer = 20000; - }else SoulSiphon_Timer -= diff; - } - - //CallOfTheGrave_Timer - if (CallOftheGrave_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_CALLOFTHEGRAVE); - CallOftheGrave_Timer = 30000; - }else CallOftheGrave_Timer -= diff; - - //Terrify_Timer - if (Terrify_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_TERRIFY); - Terrify_Timer = 20000; - }else Terrify_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; - -CreatureAI* GetAI_boss_azshir_the_sleepless(Creature *_Creature) -{ - return new boss_azshir_the_sleeplessAI (_Creature); -} - -void AddSC_boss_azshir_the_sleepless() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_azshir_the_sleepless"; - newscript->GetAI = GetAI_boss_azshir_the_sleepless; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Azshir_the_Sleepless +SD%Complete: 80 +SDComment: +SDCategory: Scarlet Monastery +EndScriptData */ + +#include "precompiled.h" + +#define SPELL_CALLOFTHEGRAVE 17831 +#define SPELL_TERRIFY 7399 +#define SPELL_SOULSIPHON 7290 + +struct MANGOS_DLL_DECL boss_azshir_the_sleeplessAI : public ScriptedAI +{ + boss_azshir_the_sleeplessAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 SoulSiphon_Timer; + uint32 CallOftheGrave_Timer; + uint32 Terrify_Timer; + + void Reset() + { + SoulSiphon_Timer = 1; + CallOftheGrave_Timer = 30000; + Terrify_Timer = 20000; + } + + void Aggro(Unit *who) + { + } + + void UpdateAI(const uint32 diff) + { + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + //If we are <50% hp cast Soul Siphon rank 1 + if ( m_creature->GetHealth()*100 / m_creature->GetMaxHealth() <= 50 && !m_creature->IsNonMeleeSpellCasted(false)) + { + //SoulSiphon_Timer + if (SoulSiphon_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_SOULSIPHON); + return; + + SoulSiphon_Timer = 20000; + }else SoulSiphon_Timer -= diff; + } + + //CallOfTheGrave_Timer + if (CallOftheGrave_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_CALLOFTHEGRAVE); + CallOftheGrave_Timer = 30000; + }else CallOftheGrave_Timer -= diff; + + //Terrify_Timer + if (Terrify_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_TERRIFY); + Terrify_Timer = 20000; + }else Terrify_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; + +CreatureAI* GetAI_boss_azshir_the_sleepless(Creature *_Creature) +{ + return new boss_azshir_the_sleeplessAI (_Creature); +} + +void AddSC_boss_azshir_the_sleepless() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_azshir_the_sleepless"; + newscript->GetAI = GetAI_boss_azshir_the_sleepless; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_bloodmage_thalnos.cpp b/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_bloodmage_thalnos.cpp index a130df0fa56..8d0bd53da57 100644 --- a/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_bloodmage_thalnos.cpp +++ b/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_bloodmage_thalnos.cpp @@ -1,136 +1,136 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Bloodmage_Thalnos -SD%Complete: 100 -SDComment: -SDCategory: Scarlet Monastery -EndScriptData */ - -#include "precompiled.h" - -#define SPELL_FROSTNOVA2 865 -#define SPELL_FLAMESHOCK3 8053 -#define SPELL_SHADOWBOLT5 1106 -#define SPELL_FLAMESPIKE 8814 -#define SPELL_FIRENOVA 16079 - -#define SAY_AGGRO "We hunger for vengeance." -#define SAY_HEALTH "No rest... for the angry dead!" -#define SAY_DEATH "More... More souls!" - -#define SOUND_AGGRO 5844 -#define SOUND_HEALTH 5846 -#define SOUND_DEATH 5845 - -struct MANGOS_DLL_DECL boss_bloodmage_thalnosAI : public ScriptedAI -{ - boss_bloodmage_thalnosAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 FrostNova2_Timer; - uint32 FlameShock3_Timer; - uint32 ShadowBolt5_Timer; - uint32 FlameSpike_Timer; - uint32 FireNova_Timer; - uint32 Yell_Timer; - - void Reset() - { - Yell_Timer = 1; - FrostNova2_Timer = 10000; - FlameShock3_Timer = 15000; - ShadowBolt5_Timer = 20000; - FlameSpike_Timer = 20000; - FireNova_Timer = 10000; - } - - void Aggro(Unit *who) - { - DoYell(SAY_AGGRO,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_AGGRO); - } - - void UpdateAI(const uint32 diff) - { - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - //If we are <35% hp - if ( m_creature->GetHealth()*100 / m_creature->GetMaxHealth() <= 35) - { - Yell_Timer -= diff; - - if (Yell_Timer < diff) - { - DoYell(SAY_HEALTH,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_HEALTH); - Yell_Timer = 900000; - } - } - - //FrostNova2_Timer - if (FrostNova2_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_FROSTNOVA2); - FrostNova2_Timer = 10000; - }else FrostNova2_Timer -= diff; - - //FlameShock3_Timer - if (FlameShock3_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_FLAMESHOCK3); - FlameShock3_Timer = 15000; - }else FlameShock3_Timer -= diff; - - //ShadowBolt5_Timer - if (ShadowBolt5_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_SHADOWBOLT5); - ShadowBolt5_Timer = 20000; - }else ShadowBolt5_Timer -= diff; - - //FlameSpike_Timer - if (FlameSpike_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_FLAMESPIKE); - FlameSpike_Timer = 30000; - }else FlameSpike_Timer -= diff; - - //FireNova_Timer - if (FireNova_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_FIRENOVA); - FireNova_Timer = 20000; - }else FireNova_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; - -CreatureAI* GetAI_boss_bloodmage_thalnos(Creature *_Creature) -{ - return new boss_bloodmage_thalnosAI (_Creature); -} - -void AddSC_boss_bloodmage_thalnos() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_bloodmage_thalnos"; - newscript->GetAI = GetAI_boss_bloodmage_thalnos; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Bloodmage_Thalnos +SD%Complete: 100 +SDComment: +SDCategory: Scarlet Monastery +EndScriptData */ + +#include "precompiled.h" + +#define SPELL_FROSTNOVA2 865 +#define SPELL_FLAMESHOCK3 8053 +#define SPELL_SHADOWBOLT5 1106 +#define SPELL_FLAMESPIKE 8814 +#define SPELL_FIRENOVA 16079 + +#define SAY_AGGRO "We hunger for vengeance." +#define SAY_HEALTH "No rest... for the angry dead!" +#define SAY_DEATH "More... More souls!" + +#define SOUND_AGGRO 5844 +#define SOUND_HEALTH 5846 +#define SOUND_DEATH 5845 + +struct MANGOS_DLL_DECL boss_bloodmage_thalnosAI : public ScriptedAI +{ + boss_bloodmage_thalnosAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 FrostNova2_Timer; + uint32 FlameShock3_Timer; + uint32 ShadowBolt5_Timer; + uint32 FlameSpike_Timer; + uint32 FireNova_Timer; + uint32 Yell_Timer; + + void Reset() + { + Yell_Timer = 1; + FrostNova2_Timer = 10000; + FlameShock3_Timer = 15000; + ShadowBolt5_Timer = 20000; + FlameSpike_Timer = 20000; + FireNova_Timer = 10000; + } + + void Aggro(Unit *who) + { + DoYell(SAY_AGGRO,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_AGGRO); + } + + void UpdateAI(const uint32 diff) + { + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + //If we are <35% hp + if ( m_creature->GetHealth()*100 / m_creature->GetMaxHealth() <= 35) + { + Yell_Timer -= diff; + + if (Yell_Timer < diff) + { + DoYell(SAY_HEALTH,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_HEALTH); + Yell_Timer = 900000; + } + } + + //FrostNova2_Timer + if (FrostNova2_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_FROSTNOVA2); + FrostNova2_Timer = 10000; + }else FrostNova2_Timer -= diff; + + //FlameShock3_Timer + if (FlameShock3_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_FLAMESHOCK3); + FlameShock3_Timer = 15000; + }else FlameShock3_Timer -= diff; + + //ShadowBolt5_Timer + if (ShadowBolt5_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_SHADOWBOLT5); + ShadowBolt5_Timer = 20000; + }else ShadowBolt5_Timer -= diff; + + //FlameSpike_Timer + if (FlameSpike_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_FLAMESPIKE); + FlameSpike_Timer = 30000; + }else FlameSpike_Timer -= diff; + + //FireNova_Timer + if (FireNova_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_FIRENOVA); + FireNova_Timer = 20000; + }else FireNova_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; + +CreatureAI* GetAI_boss_bloodmage_thalnos(Creature *_Creature) +{ + return new boss_bloodmage_thalnosAI (_Creature); +} + +void AddSC_boss_bloodmage_thalnos() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_bloodmage_thalnos"; + newscript->GetAI = GetAI_boss_bloodmage_thalnos; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_herod.cpp b/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_herod.cpp index ea4cdc52e03..7a39603184a 100644 --- a/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_herod.cpp +++ b/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_herod.cpp @@ -1,197 +1,197 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Herod -SD%Complete: 90 -SDComment: Missing adds spawn at death -SDCategory: Scarlet Monastery -EndScriptData */ - -#include "precompiled.h" - -#define SPELL_RUSHINGCHARGE 32021 -#define SPELL_RUSHINGCHARGE1 6268 - -#define SPELL_CLEAVE 11608 -#define SPELL_WHIRLWIND 8989 -#define SPELL_SUNDERARMOR 16145 -#define SPELL_REND 21949 -#define SPELL_THUNDERCLAP 15588 -#define SPELL_SLAM 11430 -#define SPELL_BERSERKERSTANCE 2458 -#define SPELL_ENRAGE 28747 -#define SPELL_FIREBALL11 10151 -#define SPELL_CONEOFCOLD5 10161 - -#define SAY_AGGRO "Ah, I have been waiting for a real challenge!" -#define SAY_WHIRLWIND "Blades of Light!" -#define SAY_ENRAGE "Light, give me strength!" -#define SAY_DEATH "Hah, is that all?" - -#define SOUND_AGGRO 5830 -#define SOUND_WHIRLWIND 5832 -#define SOUND_ENRAGE 5833 -#define SOUND_DEATH 5831 - -struct MANGOS_DLL_DECL boss_herodAI : public ScriptedAI -{ - boss_herodAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 Yell_Timer; - uint32 Enrage_Timer; - uint32 Cleave_Timer; - uint32 Whirlwind_Timer; - uint32 SunderArmor_Timer; - uint32 Rend_Timer; - uint32 ThunderClap_Timer; - uint32 Slam_Timer; - uint32 Fireball11_Timer; - uint32 ConeOfCold5_Timer; - - void Reset() - { - Yell_Timer = 58000; - Whirlwind_Timer = 60000; - Enrage_Timer = 0; - Cleave_Timer = 15000; - SunderArmor_Timer = 40000; - Rend_Timer = 25000; - ThunderClap_Timer = 25000; - Slam_Timer = 20000; - Fireball11_Timer = 30000; - ConeOfCold5_Timer = 40000; - } - - void Aggro(Unit *who) - { - DoYell(SAY_AGGRO,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_AGGRO); - - //Activate Berserker Stance - DoCast(m_creature,SPELL_BERSERKERSTANCE); - - //Switch between 2 different charge methods - switch (rand()%2) - { - case 0: - DoCast(m_creature,SPELL_RUSHINGCHARGE); - break; - case 1: - DoCast(m_creature,SPELL_RUSHINGCHARGE1); - break; - } - } - - void UpdateAI(const uint32 diff) - { - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - //If we are <10% hp goes Enraged - if ( m_creature->GetHealth()*100 / m_creature->GetMaxHealth() <= 10 && !m_creature->IsNonMeleeSpellCasted(false) && Enrage_Timer < diff) - { - DoYell(SAY_ENRAGE,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_ENRAGE); - - DoCast(m_creature,SPELL_ENRAGE); - - //Shouldn't cast this agian - Enrage_Timer = diff; - } - - //Cleave_Timer - if (Cleave_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_CLEAVE); - Cleave_Timer = 15000; - }else Cleave_Timer -= diff; - - //Yelling and Whirlwind casting - if (Yell_Timer < diff) - { - //Say Whirlwind monologe - DoYell(SAY_WHIRLWIND,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_WHIRLWIND); - - Yell_Timer = 30000; - }else Yell_Timer -= diff; - - if (Whirlwind_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_WHIRLWIND); - Whirlwind_Timer = 30000; - }else Whirlwind_Timer -= diff; - - //SunderArmor_Timer - if (SunderArmor_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_SUNDERARMOR); - SunderArmor_Timer = 40000; - }else SunderArmor_Timer -= diff; - - //Rend_Timer - if (Rend_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_REND); - Rend_Timer = 25000; - }else Rend_Timer -= diff; - - //ThunderClap_Timer - if (ThunderClap_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_THUNDERCLAP); - ThunderClap_Timer = 20000; - }else ThunderClap_Timer -= diff; - - //Slam_Timer - if (Slam_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_SLAM); - Slam_Timer = 20000; - }else Slam_Timer -= diff; - - //Fireball11_Timer - if (Fireball11_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_FIREBALL11); - Fireball11_Timer = 30000; - }else Fireball11_Timer -= diff; - - //ConeOfCold5_Timer - if (ConeOfCold5_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_CONEOFCOLD5); - ConeOfCold5_Timer = 40000; - }else ConeOfCold5_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; - -CreatureAI* GetAI_boss_herod(Creature *_Creature) -{ - return new boss_herodAI (_Creature); -} - -void AddSC_boss_herod() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_herod"; - newscript->GetAI = GetAI_boss_herod; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Herod +SD%Complete: 90 +SDComment: Missing adds spawn at death +SDCategory: Scarlet Monastery +EndScriptData */ + +#include "precompiled.h" + +#define SPELL_RUSHINGCHARGE 32021 +#define SPELL_RUSHINGCHARGE1 6268 + +#define SPELL_CLEAVE 11608 +#define SPELL_WHIRLWIND 8989 +#define SPELL_SUNDERARMOR 16145 +#define SPELL_REND 21949 +#define SPELL_THUNDERCLAP 15588 +#define SPELL_SLAM 11430 +#define SPELL_BERSERKERSTANCE 2458 +#define SPELL_ENRAGE 28747 +#define SPELL_FIREBALL11 10151 +#define SPELL_CONEOFCOLD5 10161 + +#define SAY_AGGRO "Ah, I have been waiting for a real challenge!" +#define SAY_WHIRLWIND "Blades of Light!" +#define SAY_ENRAGE "Light, give me strength!" +#define SAY_DEATH "Hah, is that all?" + +#define SOUND_AGGRO 5830 +#define SOUND_WHIRLWIND 5832 +#define SOUND_ENRAGE 5833 +#define SOUND_DEATH 5831 + +struct MANGOS_DLL_DECL boss_herodAI : public ScriptedAI +{ + boss_herodAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 Yell_Timer; + uint32 Enrage_Timer; + uint32 Cleave_Timer; + uint32 Whirlwind_Timer; + uint32 SunderArmor_Timer; + uint32 Rend_Timer; + uint32 ThunderClap_Timer; + uint32 Slam_Timer; + uint32 Fireball11_Timer; + uint32 ConeOfCold5_Timer; + + void Reset() + { + Yell_Timer = 58000; + Whirlwind_Timer = 60000; + Enrage_Timer = 0; + Cleave_Timer = 15000; + SunderArmor_Timer = 40000; + Rend_Timer = 25000; + ThunderClap_Timer = 25000; + Slam_Timer = 20000; + Fireball11_Timer = 30000; + ConeOfCold5_Timer = 40000; + } + + void Aggro(Unit *who) + { + DoYell(SAY_AGGRO,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_AGGRO); + + //Activate Berserker Stance + DoCast(m_creature,SPELL_BERSERKERSTANCE); + + //Switch between 2 different charge methods + switch (rand()%2) + { + case 0: + DoCast(m_creature,SPELL_RUSHINGCHARGE); + break; + case 1: + DoCast(m_creature,SPELL_RUSHINGCHARGE1); + break; + } + } + + void UpdateAI(const uint32 diff) + { + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + //If we are <10% hp goes Enraged + if ( m_creature->GetHealth()*100 / m_creature->GetMaxHealth() <= 10 && !m_creature->IsNonMeleeSpellCasted(false) && Enrage_Timer < diff) + { + DoYell(SAY_ENRAGE,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_ENRAGE); + + DoCast(m_creature,SPELL_ENRAGE); + + //Shouldn't cast this agian + Enrage_Timer = diff; + } + + //Cleave_Timer + if (Cleave_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_CLEAVE); + Cleave_Timer = 15000; + }else Cleave_Timer -= diff; + + //Yelling and Whirlwind casting + if (Yell_Timer < diff) + { + //Say Whirlwind monologe + DoYell(SAY_WHIRLWIND,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_WHIRLWIND); + + Yell_Timer = 30000; + }else Yell_Timer -= diff; + + if (Whirlwind_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_WHIRLWIND); + Whirlwind_Timer = 30000; + }else Whirlwind_Timer -= diff; + + //SunderArmor_Timer + if (SunderArmor_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_SUNDERARMOR); + SunderArmor_Timer = 40000; + }else SunderArmor_Timer -= diff; + + //Rend_Timer + if (Rend_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_REND); + Rend_Timer = 25000; + }else Rend_Timer -= diff; + + //ThunderClap_Timer + if (ThunderClap_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_THUNDERCLAP); + ThunderClap_Timer = 20000; + }else ThunderClap_Timer -= diff; + + //Slam_Timer + if (Slam_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_SLAM); + Slam_Timer = 20000; + }else Slam_Timer -= diff; + + //Fireball11_Timer + if (Fireball11_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_FIREBALL11); + Fireball11_Timer = 30000; + }else Fireball11_Timer -= diff; + + //ConeOfCold5_Timer + if (ConeOfCold5_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_CONEOFCOLD5); + ConeOfCold5_Timer = 40000; + }else ConeOfCold5_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; + +CreatureAI* GetAI_boss_herod(Creature *_Creature) +{ + return new boss_herodAI (_Creature); +} + +void AddSC_boss_herod() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_herod"; + newscript->GetAI = GetAI_boss_herod; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_high_inquisitor_fairbanks.cpp b/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_high_inquisitor_fairbanks.cpp index 2817b50eb4c..1edb1a6210f 100644 --- a/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_high_inquisitor_fairbanks.cpp +++ b/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_high_inquisitor_fairbanks.cpp @@ -1,132 +1,132 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_High_Inquisitor_Faribanks -SD%Complete: 100 -SDComment: -SDCategory: Scarlet Monastery -EndScriptData */ - -#include "precompiled.h" - -#define SPELL_SLEEP2 1090 -#define SPELL_CURSEOFBLOOD 16098 -#define SPELL_SMITE 6060 -#define SPELL_SHADOWWORDPAIN 2767 -#define SPELL_FLASHHEAL4 9474 -#define SPELL_RENEW6 6078 -#define SPELL_DEVOURINGPLAGUE3 19277 -#define SPELL_MINDBLAST5 8105 - -struct MANGOS_DLL_DECL boss_high_inquisitor_fairbanksAI : public ScriptedAI -{ - boss_high_inquisitor_fairbanksAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 Healing_Timer; - uint32 Sleep2_Timer; - uint32 Smite_Timer; - uint32 ShadowWordPain_Timer; - uint32 CurseOfBlood_Timer; - uint32 DevouringPlague3_Timer; - uint32 MindBlast5_Timer; - - void Reset() - { - Healing_Timer = 300; - Sleep2_Timer = 45000; - Smite_Timer = 30000; - ShadowWordPain_Timer = 30000; - CurseOfBlood_Timer = 45000; - DevouringPlague3_Timer = 60000; - MindBlast5_Timer = 20000; - } - - void Aggro(Unit *who) - { - } - - void UpdateAI(const uint32 diff) - { - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - //If we are <45% hp cast Renew rank 6 or Flash heal rank 4 - if ( m_creature->GetHealth()*100 / m_creature->GetMaxHealth() <= 45 && !m_creature->IsNonMeleeSpellCasted(false) && Healing_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_RENEW6 || SPELL_FLASHHEAL4); - Healing_Timer = 30000; - }else Healing_Timer -= diff; - - //Sleep2_Timer - if (Sleep2_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_SLEEP2); - Sleep2_Timer = 45000; - }else Sleep2_Timer -= diff; - - //Smite_Timer - if (Smite_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_SMITE); - Smite_Timer = 20000; - }else Smite_Timer -= diff; - - //ShadowWordPain_Timer - if (ShadowWordPain_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_SHADOWWORDPAIN); - ShadowWordPain_Timer = 30000; - }else ShadowWordPain_Timer -= diff; - - //CurseOfBlood_Timer - if (CurseOfBlood_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_CURSEOFBLOOD); - CurseOfBlood_Timer = 25000; - }else CurseOfBlood_Timer -= diff; - - //DevouringPlague3_Timer - if (DevouringPlague3_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_DEVOURINGPLAGUE3); - DevouringPlague3_Timer = 35000; - }else DevouringPlague3_Timer -= diff; - - //MindBlast5_Timer - if (MindBlast5_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_MINDBLAST5); - MindBlast5_Timer = 30000; - }else MindBlast5_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; - -CreatureAI* GetAI_boss_high_inquisitor_fairbanks(Creature *_Creature) -{ - return new boss_high_inquisitor_fairbanksAI (_Creature); -} - -void AddSC_boss_high_inquisitor_fairbanks() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_high_inquisitor_fairbanks"; - newscript->GetAI = GetAI_boss_high_inquisitor_fairbanks; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_High_Inquisitor_Faribanks +SD%Complete: 100 +SDComment: +SDCategory: Scarlet Monastery +EndScriptData */ + +#include "precompiled.h" + +#define SPELL_SLEEP2 1090 +#define SPELL_CURSEOFBLOOD 16098 +#define SPELL_SMITE 6060 +#define SPELL_SHADOWWORDPAIN 2767 +#define SPELL_FLASHHEAL4 9474 +#define SPELL_RENEW6 6078 +#define SPELL_DEVOURINGPLAGUE3 19277 +#define SPELL_MINDBLAST5 8105 + +struct MANGOS_DLL_DECL boss_high_inquisitor_fairbanksAI : public ScriptedAI +{ + boss_high_inquisitor_fairbanksAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 Healing_Timer; + uint32 Sleep2_Timer; + uint32 Smite_Timer; + uint32 ShadowWordPain_Timer; + uint32 CurseOfBlood_Timer; + uint32 DevouringPlague3_Timer; + uint32 MindBlast5_Timer; + + void Reset() + { + Healing_Timer = 300; + Sleep2_Timer = 45000; + Smite_Timer = 30000; + ShadowWordPain_Timer = 30000; + CurseOfBlood_Timer = 45000; + DevouringPlague3_Timer = 60000; + MindBlast5_Timer = 20000; + } + + void Aggro(Unit *who) + { + } + + void UpdateAI(const uint32 diff) + { + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + //If we are <45% hp cast Renew rank 6 or Flash heal rank 4 + if ( m_creature->GetHealth()*100 / m_creature->GetMaxHealth() <= 45 && !m_creature->IsNonMeleeSpellCasted(false) && Healing_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_RENEW6 || SPELL_FLASHHEAL4); + Healing_Timer = 30000; + }else Healing_Timer -= diff; + + //Sleep2_Timer + if (Sleep2_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_SLEEP2); + Sleep2_Timer = 45000; + }else Sleep2_Timer -= diff; + + //Smite_Timer + if (Smite_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_SMITE); + Smite_Timer = 20000; + }else Smite_Timer -= diff; + + //ShadowWordPain_Timer + if (ShadowWordPain_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_SHADOWWORDPAIN); + ShadowWordPain_Timer = 30000; + }else ShadowWordPain_Timer -= diff; + + //CurseOfBlood_Timer + if (CurseOfBlood_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_CURSEOFBLOOD); + CurseOfBlood_Timer = 25000; + }else CurseOfBlood_Timer -= diff; + + //DevouringPlague3_Timer + if (DevouringPlague3_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_DEVOURINGPLAGUE3); + DevouringPlague3_Timer = 35000; + }else DevouringPlague3_Timer -= diff; + + //MindBlast5_Timer + if (MindBlast5_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_MINDBLAST5); + MindBlast5_Timer = 30000; + }else MindBlast5_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; + +CreatureAI* GetAI_boss_high_inquisitor_fairbanks(Creature *_Creature) +{ + return new boss_high_inquisitor_fairbanksAI (_Creature); +} + +void AddSC_boss_high_inquisitor_fairbanks() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_high_inquisitor_fairbanks"; + newscript->GetAI = GetAI_boss_high_inquisitor_fairbanks; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_high_inquisitor_whitemane.cpp b/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_high_inquisitor_whitemane.cpp index 3a7c03a03b4..1da3ef99b86 100644 --- a/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_high_inquisitor_whitemane.cpp +++ b/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_high_inquisitor_whitemane.cpp @@ -1,177 +1,177 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_High_Inquistor_Whitmane -SD%Complete: 50 -SDComment: Missing connection with commander mograine -SDCategory: Scarlet Monastery -EndScriptData */ - -#include "precompiled.h" - -#define SPELL_DEEPSLEEP 9256 -#define SPELL_SCARLETRESURRECTION 9232 - -#define SPELL_CRUSADERSTRIKE 17281 -#define SPELL_HAMMEROFJUSTICE 13005 -#define SPELL_HOLYSMITE6 9481 -#define SPELL_HOLYFIRE5 15265 -#define SPELL_MINDBLAST6 8106 - -#define SPELL_POWERWORDSHIELD 6065 - -#define SPELL_RENEW 6078 -#define SPELL_FLASHHEAL6 10916 - -#define SAY_AGGRO "There is no escape for you. The Crusade shall destroy all who carry the Scourge's taint." -#define SAY_SPAWN "What, Mograine has fallen? You shall pay for this treachery! " -#define SAY_RES "Arise, my champion!" -#define SAY_DEATH "The Light has spoken!" - -//#define SOUND_AGGRO -#define SOUND_RES 5840 -#define SOUND_SPAWN 5838 -#define SOUND_DEATH 5839 - -struct MANGOS_DLL_DECL boss_high_inquisitor_whitemaneAI : public ScriptedAI -{ - boss_high_inquisitor_whitemaneAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 Healing_Timer; - uint32 Renew_Timer; - uint32 PowerWordShield_Timer; - uint32 CrusaderStrike_Timer; - uint32 HammerOfJustice_Timer; - uint32 HolySmite6_Timer; - uint32 HolyFire5_Timer; - uint32 MindBlast6_Timer; - - void Reset() - { - Healing_Timer = 0; - Renew_Timer= 0; - PowerWordShield_Timer = 2000; - CrusaderStrike_Timer = 12000; - HammerOfJustice_Timer = 18000; - HolySmite6_Timer = 10000; - HolyFire5_Timer = 20000; - MindBlast6_Timer = 6000; - } - - void Aggro(Unit *who) - { - DoYell(SAY_AGGRO,LANG_UNIVERSAL,NULL); - } - - void UpdateAI(const uint32 diff) - { - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - /* - //This is going to be a routine to make the resurrection event... - if (m_creature->isAlive && m_creature->isAlive) - { - m_creature->Relocate(1163.113370,1398.856812,32.527786,3.171014); - - DoYell(SAY_SPAWN,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_SPAWN); - DoCast(m_creature->getVictim(),SPELL_DEEPSLEEP); - DoCast(m-creature->GetGUID(51117),SPELL_SCARLETRESURRECTION) - } - */ - - //If we are <75% hp cast healing spells at self and Mograine - if ( m_creature->GetHealth()*100 / m_creature->GetMaxHealth() <= 75 ) - { - if (Healing_Timer < diff) - { - DoCast(m_creature,SPELL_FLASHHEAL6); - return; - - //22-32 seconds until we should cast this agian - Healing_Timer = 22000 + rand()%10000; - }else Healing_Timer -= diff; - } - - if ( m_creature->GetHealth()*100 / m_creature->GetMaxHealth() <= 30) - { - if (Renew_Timer < diff) - { - DoCast(m_creature,SPELL_RENEW); - Renew_Timer = 30000; - }else Renew_Timer -= diff; - } - - //PowerWordShield_Timer - if (PowerWordShield_Timer < diff) - { - DoCast(m_creature,SPELL_POWERWORDSHIELD); - PowerWordShield_Timer = 25000; - }else PowerWordShield_Timer -= diff; - - //CrusaderStrike_Timer - if (CrusaderStrike_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_CRUSADERSTRIKE); - CrusaderStrike_Timer = 15000; - }else CrusaderStrike_Timer -= diff; - - //HammerOfJustice_Timer - if (HammerOfJustice_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_HAMMEROFJUSTICE); - HammerOfJustice_Timer = 12000; - }else HammerOfJustice_Timer -= diff; - - //HolySmite6_Timer - if (HolySmite6_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_HOLYSMITE6); - HolySmite6_Timer = 10000; - }else HolySmite6_Timer -= diff; - - //HolyFire5_Timer - if (HolyFire5_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_HOLYFIRE5); - HolyFire5_Timer = 15000; - }else HolyFire5_Timer -= diff; - - //MindBlast6_Timer - if (MindBlast6_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_MINDBLAST6); - MindBlast6_Timer = 8000; - }else MindBlast6_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; -CreatureAI* GetAI_boss_high_inquisitor_whitemane(Creature *_Creature) -{ - return new boss_high_inquisitor_whitemaneAI (_Creature); -} - -void AddSC_boss_high_inquisitor_whitemane() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_high_inquisitor_whitemane"; - newscript->GetAI = GetAI_boss_high_inquisitor_whitemane; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_High_Inquistor_Whitmane +SD%Complete: 50 +SDComment: Missing connection with commander mograine +SDCategory: Scarlet Monastery +EndScriptData */ + +#include "precompiled.h" + +#define SPELL_DEEPSLEEP 9256 +#define SPELL_SCARLETRESURRECTION 9232 + +#define SPELL_CRUSADERSTRIKE 17281 +#define SPELL_HAMMEROFJUSTICE 13005 +#define SPELL_HOLYSMITE6 9481 +#define SPELL_HOLYFIRE5 15265 +#define SPELL_MINDBLAST6 8106 + +#define SPELL_POWERWORDSHIELD 6065 + +#define SPELL_RENEW 6078 +#define SPELL_FLASHHEAL6 10916 + +#define SAY_AGGRO "There is no escape for you. The Crusade shall destroy all who carry the Scourge's taint." +#define SAY_SPAWN "What, Mograine has fallen? You shall pay for this treachery! " +#define SAY_RES "Arise, my champion!" +#define SAY_DEATH "The Light has spoken!" + +//#define SOUND_AGGRO +#define SOUND_RES 5840 +#define SOUND_SPAWN 5838 +#define SOUND_DEATH 5839 + +struct MANGOS_DLL_DECL boss_high_inquisitor_whitemaneAI : public ScriptedAI +{ + boss_high_inquisitor_whitemaneAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 Healing_Timer; + uint32 Renew_Timer; + uint32 PowerWordShield_Timer; + uint32 CrusaderStrike_Timer; + uint32 HammerOfJustice_Timer; + uint32 HolySmite6_Timer; + uint32 HolyFire5_Timer; + uint32 MindBlast6_Timer; + + void Reset() + { + Healing_Timer = 0; + Renew_Timer= 0; + PowerWordShield_Timer = 2000; + CrusaderStrike_Timer = 12000; + HammerOfJustice_Timer = 18000; + HolySmite6_Timer = 10000; + HolyFire5_Timer = 20000; + MindBlast6_Timer = 6000; + } + + void Aggro(Unit *who) + { + DoYell(SAY_AGGRO,LANG_UNIVERSAL,NULL); + } + + void UpdateAI(const uint32 diff) + { + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + /* + //This is going to be a routine to make the resurrection event... + if (m_creature->isAlive && m_creature->isAlive) + { + m_creature->Relocate(1163.113370,1398.856812,32.527786,3.171014); + + DoYell(SAY_SPAWN,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_SPAWN); + DoCast(m_creature->getVictim(),SPELL_DEEPSLEEP); + DoCast(m-creature->GetGUID(51117),SPELL_SCARLETRESURRECTION) + } + */ + + //If we are <75% hp cast healing spells at self and Mograine + if ( m_creature->GetHealth()*100 / m_creature->GetMaxHealth() <= 75 ) + { + if (Healing_Timer < diff) + { + DoCast(m_creature,SPELL_FLASHHEAL6); + return; + + //22-32 seconds until we should cast this agian + Healing_Timer = 22000 + rand()%10000; + }else Healing_Timer -= diff; + } + + if ( m_creature->GetHealth()*100 / m_creature->GetMaxHealth() <= 30) + { + if (Renew_Timer < diff) + { + DoCast(m_creature,SPELL_RENEW); + Renew_Timer = 30000; + }else Renew_Timer -= diff; + } + + //PowerWordShield_Timer + if (PowerWordShield_Timer < diff) + { + DoCast(m_creature,SPELL_POWERWORDSHIELD); + PowerWordShield_Timer = 25000; + }else PowerWordShield_Timer -= diff; + + //CrusaderStrike_Timer + if (CrusaderStrike_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_CRUSADERSTRIKE); + CrusaderStrike_Timer = 15000; + }else CrusaderStrike_Timer -= diff; + + //HammerOfJustice_Timer + if (HammerOfJustice_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_HAMMEROFJUSTICE); + HammerOfJustice_Timer = 12000; + }else HammerOfJustice_Timer -= diff; + + //HolySmite6_Timer + if (HolySmite6_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_HOLYSMITE6); + HolySmite6_Timer = 10000; + }else HolySmite6_Timer -= diff; + + //HolyFire5_Timer + if (HolyFire5_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_HOLYFIRE5); + HolyFire5_Timer = 15000; + }else HolyFire5_Timer -= diff; + + //MindBlast6_Timer + if (MindBlast6_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_MINDBLAST6); + MindBlast6_Timer = 8000; + }else MindBlast6_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; +CreatureAI* GetAI_boss_high_inquisitor_whitemane(Creature *_Creature) +{ + return new boss_high_inquisitor_whitemaneAI (_Creature); +} + +void AddSC_boss_high_inquisitor_whitemane() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_high_inquisitor_whitemane"; + newscript->GetAI = GetAI_boss_high_inquisitor_whitemane; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_houndmaster_loksey.cpp b/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_houndmaster_loksey.cpp index 342424eed2f..de0fc7537d9 100644 --- a/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_houndmaster_loksey.cpp +++ b/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_houndmaster_loksey.cpp @@ -1,78 +1,78 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Houndmaster_Loksey -SD%Complete: 100 -SDComment: -SDCategory: Scarlet Monastery -EndScriptData */ - -#include "precompiled.h" - -#define SPELL_SUMMONSCARLETHOUND 17164 -#define SPELL_ENRAGE 28747 - -#define SAY_AGGRO "Release the hounds!" -#define SOUND_AGGRO 5841 - -struct MANGOS_DLL_DECL boss_houndmaster_lokseyAI : public ScriptedAI -{ - boss_houndmaster_lokseyAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 Enrage_Timer; - - void Reset() - { - Enrage_Timer = 6000000; - } - - void Aggro(Unit *who) - { - DoYell(SAY_AGGRO,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_AGGRO); - - DoCast(m_creature,SPELL_SUMMONSCARLETHOUND); - } - - void UpdateAI(const uint32 diff) - { - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - //If we are <10% hp cast healing spells at self and Mograine - if ( m_creature->GetHealth()*100 / m_creature->GetMaxHealth() <= 10 && !m_creature->IsNonMeleeSpellCasted(false) && Enrage_Timer < diff) - { - DoCast(m_creature,SPELL_ENRAGE); - Enrage_Timer = 900000; - }else Enrage_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; -CreatureAI* GetAI_boss_houndmaster_loksey(Creature *_Creature) -{ - return new boss_houndmaster_lokseyAI (_Creature); -} - -void AddSC_boss_houndmaster_loksey() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_houndmaster_loksey"; - newscript->GetAI = GetAI_boss_houndmaster_loksey; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Houndmaster_Loksey +SD%Complete: 100 +SDComment: +SDCategory: Scarlet Monastery +EndScriptData */ + +#include "precompiled.h" + +#define SPELL_SUMMONSCARLETHOUND 17164 +#define SPELL_ENRAGE 28747 + +#define SAY_AGGRO "Release the hounds!" +#define SOUND_AGGRO 5841 + +struct MANGOS_DLL_DECL boss_houndmaster_lokseyAI : public ScriptedAI +{ + boss_houndmaster_lokseyAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 Enrage_Timer; + + void Reset() + { + Enrage_Timer = 6000000; + } + + void Aggro(Unit *who) + { + DoYell(SAY_AGGRO,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_AGGRO); + + DoCast(m_creature,SPELL_SUMMONSCARLETHOUND); + } + + void UpdateAI(const uint32 diff) + { + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + //If we are <10% hp cast healing spells at self and Mograine + if ( m_creature->GetHealth()*100 / m_creature->GetMaxHealth() <= 10 && !m_creature->IsNonMeleeSpellCasted(false) && Enrage_Timer < diff) + { + DoCast(m_creature,SPELL_ENRAGE); + Enrage_Timer = 900000; + }else Enrage_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; +CreatureAI* GetAI_boss_houndmaster_loksey(Creature *_Creature) +{ + return new boss_houndmaster_lokseyAI (_Creature); +} + +void AddSC_boss_houndmaster_loksey() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_houndmaster_loksey"; + newscript->GetAI = GetAI_boss_houndmaster_loksey; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_interrogator_vishas.cpp b/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_interrogator_vishas.cpp index c21eef4b458..4bfe70c94a9 100644 --- a/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_interrogator_vishas.cpp +++ b/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_interrogator_vishas.cpp @@ -1,113 +1,113 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Interrogator_Vishas -SD%Complete: 100 -SDComment: -SDCategory: Scarlet Monastery -EndScriptData */ - -#include "precompiled.h" - -#define SPELL_POWERWORDSHIELD 6065 - -#define SAY_AGGRO "Tell me... tell me everything!" -#define SAY_HEALTH1 "Naughty secrets" -#define SAY_HEALTH2 "I'll rip the secrets from your flesh!" -#define SAY_DEATH "Purged by pain!" - -#define SOUND_AGGRO 5847 -#define SOUND_HEALTH1 5849 -#define SOUND_HEALTH2 5850 -#define SOUND_DEATH 5848 - -struct MANGOS_DLL_DECL boss_interrogator_vishasAI : public ScriptedAI -{ - boss_interrogator_vishasAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 Yell_Timer; - uint32 PowerWordShield_Timer; - - void Reset() - { - Yell_Timer = 6000000; - PowerWordShield_Timer = 60000; - } - - void Aggro(Unit *who) - { - DoYell(SAY_AGGRO,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_AGGRO); - } - - void UpdateAI(const uint32 diff) - { - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - //If we are low on hp Do sayings - if ( m_creature->GetHealth()*100 / m_creature->GetMaxHealth() <= 60 && !m_creature->IsNonMeleeSpellCasted(false)) - { - //Yell_Timer - if (Yell_Timer < diff) - { - DoYell(SAY_HEALTH1,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_HEALTH1); - return; - - //60 seconds until we should cast this agian - Yell_Timer = 60000; - }else Yell_Timer -= diff; - } - - if ( m_creature->GetHealth()*100 / m_creature->GetMaxHealth() <= 30 && !m_creature->IsNonMeleeSpellCasted(false)) - { - //Yell_Timer - if (Yell_Timer < diff) - { - DoYell(SAY_HEALTH2,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_HEALTH2); - return; - - //60 seconds until we should cast this agian - Yell_Timer = 6000000; - }else Yell_Timer -= diff; - } - - //PowerWordShield_Timer - if (PowerWordShield_Timer < diff) - { - DoCast(m_creature,SPELL_POWERWORDSHIELD); - PowerWordShield_Timer = 60000; - }else PowerWordShield_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; -CreatureAI* GetAI_boss_interrogator_vishas(Creature *_Creature) -{ - return new boss_interrogator_vishasAI (_Creature); -} - -void AddSC_boss_interrogator_vishas() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_interrogator_vishas"; - newscript->GetAI = GetAI_boss_interrogator_vishas; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Interrogator_Vishas +SD%Complete: 100 +SDComment: +SDCategory: Scarlet Monastery +EndScriptData */ + +#include "precompiled.h" + +#define SPELL_POWERWORDSHIELD 6065 + +#define SAY_AGGRO "Tell me... tell me everything!" +#define SAY_HEALTH1 "Naughty secrets" +#define SAY_HEALTH2 "I'll rip the secrets from your flesh!" +#define SAY_DEATH "Purged by pain!" + +#define SOUND_AGGRO 5847 +#define SOUND_HEALTH1 5849 +#define SOUND_HEALTH2 5850 +#define SOUND_DEATH 5848 + +struct MANGOS_DLL_DECL boss_interrogator_vishasAI : public ScriptedAI +{ + boss_interrogator_vishasAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 Yell_Timer; + uint32 PowerWordShield_Timer; + + void Reset() + { + Yell_Timer = 6000000; + PowerWordShield_Timer = 60000; + } + + void Aggro(Unit *who) + { + DoYell(SAY_AGGRO,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_AGGRO); + } + + void UpdateAI(const uint32 diff) + { + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + //If we are low on hp Do sayings + if ( m_creature->GetHealth()*100 / m_creature->GetMaxHealth() <= 60 && !m_creature->IsNonMeleeSpellCasted(false)) + { + //Yell_Timer + if (Yell_Timer < diff) + { + DoYell(SAY_HEALTH1,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_HEALTH1); + return; + + //60 seconds until we should cast this agian + Yell_Timer = 60000; + }else Yell_Timer -= diff; + } + + if ( m_creature->GetHealth()*100 / m_creature->GetMaxHealth() <= 30 && !m_creature->IsNonMeleeSpellCasted(false)) + { + //Yell_Timer + if (Yell_Timer < diff) + { + DoYell(SAY_HEALTH2,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_HEALTH2); + return; + + //60 seconds until we should cast this agian + Yell_Timer = 6000000; + }else Yell_Timer -= diff; + } + + //PowerWordShield_Timer + if (PowerWordShield_Timer < diff) + { + DoCast(m_creature,SPELL_POWERWORDSHIELD); + PowerWordShield_Timer = 60000; + }else PowerWordShield_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; +CreatureAI* GetAI_boss_interrogator_vishas(Creature *_Creature) +{ + return new boss_interrogator_vishasAI (_Creature); +} + +void AddSC_boss_interrogator_vishas() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_interrogator_vishas"; + newscript->GetAI = GetAI_boss_interrogator_vishas; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_scarlet_commander_mograine.cpp b/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_scarlet_commander_mograine.cpp index 6bdcda14913..2b5692b123b 100644 --- a/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_scarlet_commander_mograine.cpp +++ b/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_scarlet_commander_mograine.cpp @@ -1,160 +1,160 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Scarlet_Commander_Mograine -SD%Complete: 100 -SDComment: Missing revive -SDCategory: Scarlet Monastery -EndScriptData */ - -#include "precompiled.h" - -#define SPELL_DIVINESHIELD2 1020 -#define SPELL_CRUSADERSTRIKE5 35395 -#define SPELL_HAMMEROFJUSTICE3 5589 -#define SPELL_HOLYLIGHT6 3472 -#define SPELL_CONSECRATION3 20922 -#define SPELL_BLESSINGOFWISDOM 1044 -#define SPELL_RETRIBUTIONAURA3 10299 -#define SPELL_BLESSINGOFPROTECTION3 10278 -#define SPELL_FLASHHEAL6 10916 - -#define SAY_AGGRO "Infidels! They must be purified!" -#define SAY_RES "At your side, milady!" -#define SAY_DEATH "Unworthy!" - -#define SOUND_AGGRO 5835 -#define SOUND_RES 5837 -#define SOUND_DEATH 5836 - -struct MANGOS_DLL_DECL boss_scarlet_commander_mograineAI : public ScriptedAI -{ - boss_scarlet_commander_mograineAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 Heal_Timer; - uint32 DivineShield2_Timer; - uint32 CrusaderStrike5_Timer; - uint32 HammerOfJustice3_Timer; - uint32 Consecration3_Timer; - uint32 BlessingOfWisdom_Timer; - uint32 BlessingOfProtection3_Timer; - - void Reset() - { - Heal_Timer = 80000; - DivineShield2_Timer = 60000; - CrusaderStrike5_Timer = 20000; - HammerOfJustice3_Timer = 80000; - Consecration3_Timer = 30000; - BlessingOfWisdom_Timer = 45000; - BlessingOfProtection3_Timer = 45000; - } - - void Aggro(Unit *who) - { - DoYell(SAY_AGGRO,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_AGGRO); - DoCast(m_creature,SPELL_RETRIBUTIONAURA3); - } - - void UpdateAI(const uint32 diff) - { - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - //If we are <50% hp cast Arcane Bubble and start casting SPECIAL Arcane Explosion - if ( m_creature->GetHealth()*100 / m_creature->GetMaxHealth() <= 50 && !m_creature->IsNonMeleeSpellCasted(false)) - { - //heal_Timer - if (Heal_Timer < diff) - { - //Switch between 2 different charge methods - switch (rand()%2) - { - case 0: - DoCast(m_creature,SPELL_HOLYLIGHT6); - break; - case 1: - DoCast(m_creature,SPELL_FLASHHEAL6); - break; - } - return; - - //60 seconds until we should cast this agian - Heal_Timer = 60000; - }else Heal_Timer -= diff; - } - - //DivineShield2_Timer - if (DivineShield2_Timer < diff) - { - DoCast(m_creature,SPELL_DIVINESHIELD2); - DivineShield2_Timer = 60000; - }else DivineShield2_Timer -= diff; - - //CrusaderStrike5_Timer - if (CrusaderStrike5_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_CRUSADERSTRIKE5); - CrusaderStrike5_Timer = 20000; - }else CrusaderStrike5_Timer -= diff; - - //HammerOfJustice3_Timer - if (HammerOfJustice3_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_HAMMEROFJUSTICE3); - HammerOfJustice3_Timer = 30000; - }else HammerOfJustice3_Timer -= diff; - - //Consecration3_Timer - if (Consecration3_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_CONSECRATION3); - Consecration3_Timer = 20000; - }else Consecration3_Timer -= diff; - - //BlessingOfWisdom_Timer - if (BlessingOfWisdom_Timer < diff) - { - DoCast(m_creature,SPELL_BLESSINGOFWISDOM); - BlessingOfWisdom_Timer = 45000; - }else BlessingOfWisdom_Timer -= diff; - - //BlessingOfProtection3_Timer - if (BlessingOfProtection3_Timer < diff) - { - DoCast(m_creature,SPELL_BLESSINGOFPROTECTION3); - BlessingOfProtection3_Timer = 50000; - }else BlessingOfProtection3_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; - -CreatureAI* GetAI_boss_scarlet_commander_mograine(Creature *_Creature) -{ - return new boss_scarlet_commander_mograineAI (_Creature); -} - -void AddSC_boss_scarlet_commander_mograine() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_scarlet_commander_mograine"; - newscript->GetAI = GetAI_boss_scarlet_commander_mograine; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Scarlet_Commander_Mograine +SD%Complete: 100 +SDComment: Missing revive +SDCategory: Scarlet Monastery +EndScriptData */ + +#include "precompiled.h" + +#define SPELL_DIVINESHIELD2 1020 +#define SPELL_CRUSADERSTRIKE5 35395 +#define SPELL_HAMMEROFJUSTICE3 5589 +#define SPELL_HOLYLIGHT6 3472 +#define SPELL_CONSECRATION3 20922 +#define SPELL_BLESSINGOFWISDOM 1044 +#define SPELL_RETRIBUTIONAURA3 10299 +#define SPELL_BLESSINGOFPROTECTION3 10278 +#define SPELL_FLASHHEAL6 10916 + +#define SAY_AGGRO "Infidels! They must be purified!" +#define SAY_RES "At your side, milady!" +#define SAY_DEATH "Unworthy!" + +#define SOUND_AGGRO 5835 +#define SOUND_RES 5837 +#define SOUND_DEATH 5836 + +struct MANGOS_DLL_DECL boss_scarlet_commander_mograineAI : public ScriptedAI +{ + boss_scarlet_commander_mograineAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 Heal_Timer; + uint32 DivineShield2_Timer; + uint32 CrusaderStrike5_Timer; + uint32 HammerOfJustice3_Timer; + uint32 Consecration3_Timer; + uint32 BlessingOfWisdom_Timer; + uint32 BlessingOfProtection3_Timer; + + void Reset() + { + Heal_Timer = 80000; + DivineShield2_Timer = 60000; + CrusaderStrike5_Timer = 20000; + HammerOfJustice3_Timer = 80000; + Consecration3_Timer = 30000; + BlessingOfWisdom_Timer = 45000; + BlessingOfProtection3_Timer = 45000; + } + + void Aggro(Unit *who) + { + DoYell(SAY_AGGRO,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_AGGRO); + DoCast(m_creature,SPELL_RETRIBUTIONAURA3); + } + + void UpdateAI(const uint32 diff) + { + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + //If we are <50% hp cast Arcane Bubble and start casting SPECIAL Arcane Explosion + if ( m_creature->GetHealth()*100 / m_creature->GetMaxHealth() <= 50 && !m_creature->IsNonMeleeSpellCasted(false)) + { + //heal_Timer + if (Heal_Timer < diff) + { + //Switch between 2 different charge methods + switch (rand()%2) + { + case 0: + DoCast(m_creature,SPELL_HOLYLIGHT6); + break; + case 1: + DoCast(m_creature,SPELL_FLASHHEAL6); + break; + } + return; + + //60 seconds until we should cast this agian + Heal_Timer = 60000; + }else Heal_Timer -= diff; + } + + //DivineShield2_Timer + if (DivineShield2_Timer < diff) + { + DoCast(m_creature,SPELL_DIVINESHIELD2); + DivineShield2_Timer = 60000; + }else DivineShield2_Timer -= diff; + + //CrusaderStrike5_Timer + if (CrusaderStrike5_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_CRUSADERSTRIKE5); + CrusaderStrike5_Timer = 20000; + }else CrusaderStrike5_Timer -= diff; + + //HammerOfJustice3_Timer + if (HammerOfJustice3_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_HAMMEROFJUSTICE3); + HammerOfJustice3_Timer = 30000; + }else HammerOfJustice3_Timer -= diff; + + //Consecration3_Timer + if (Consecration3_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_CONSECRATION3); + Consecration3_Timer = 20000; + }else Consecration3_Timer -= diff; + + //BlessingOfWisdom_Timer + if (BlessingOfWisdom_Timer < diff) + { + DoCast(m_creature,SPELL_BLESSINGOFWISDOM); + BlessingOfWisdom_Timer = 45000; + }else BlessingOfWisdom_Timer -= diff; + + //BlessingOfProtection3_Timer + if (BlessingOfProtection3_Timer < diff) + { + DoCast(m_creature,SPELL_BLESSINGOFPROTECTION3); + BlessingOfProtection3_Timer = 50000; + }else BlessingOfProtection3_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; + +CreatureAI* GetAI_boss_scarlet_commander_mograine(Creature *_Creature) +{ + return new boss_scarlet_commander_mograineAI (_Creature); +} + +void AddSC_boss_scarlet_commander_mograine() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_scarlet_commander_mograine"; + newscript->GetAI = GetAI_boss_scarlet_commander_mograine; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_scorn.cpp b/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_scorn.cpp index abfda1462ca..2ce8db28680 100644 --- a/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_scorn.cpp +++ b/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_scorn.cpp @@ -1,100 +1,100 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Scorn -SD%Complete: 100 -SDComment: -SDCategory: Scarlet Monastery -EndScriptData */ - -#include "precompiled.h" - -#define SPELL_LICHSLAP 28873 -#define SPELL_FROSTBOLTVOLLEY 8398 -#define SPELL_MINDFLAY 17313 -#define SPELL_FROSTNOVA 15531 - -struct MANGOS_DLL_DECL boss_scornAI : public ScriptedAI -{ - boss_scornAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 LichSlap_Timer; - uint32 FrostboltVolley_Timer; - uint32 MindFlay_Timer; - uint32 FrostNova_Timer; - - void Reset() - { - LichSlap_Timer = 45000; - FrostboltVolley_Timer = 30000; - MindFlay_Timer = 30000; - FrostNova_Timer = 30000; - } - - void Aggro(Unit *who) - { - } - - void UpdateAI(const uint32 diff) - { - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - //LichSlap_Timer - if (LichSlap_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_LICHSLAP); - LichSlap_Timer = 45000; - }else LichSlap_Timer -= diff; - - //FrostboltVolley_Timer - if (FrostboltVolley_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_FROSTBOLTVOLLEY); - FrostboltVolley_Timer = 20000; - }else FrostboltVolley_Timer -= diff; - - //MindFlay_Timer - if (MindFlay_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_MINDFLAY); - MindFlay_Timer = 20000; - }else MindFlay_Timer -= diff; - - //FrostNova_Timer - if (FrostNova_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_FROSTNOVA); - FrostNova_Timer = 15000; - }else FrostNova_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; -CreatureAI* GetAI_boss_scorn(Creature *_Creature) -{ - return new boss_scornAI (_Creature); -} - -void AddSC_boss_scorn() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_scorn"; - newscript->GetAI = GetAI_boss_scorn; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Scorn +SD%Complete: 100 +SDComment: +SDCategory: Scarlet Monastery +EndScriptData */ + +#include "precompiled.h" + +#define SPELL_LICHSLAP 28873 +#define SPELL_FROSTBOLTVOLLEY 8398 +#define SPELL_MINDFLAY 17313 +#define SPELL_FROSTNOVA 15531 + +struct MANGOS_DLL_DECL boss_scornAI : public ScriptedAI +{ + boss_scornAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 LichSlap_Timer; + uint32 FrostboltVolley_Timer; + uint32 MindFlay_Timer; + uint32 FrostNova_Timer; + + void Reset() + { + LichSlap_Timer = 45000; + FrostboltVolley_Timer = 30000; + MindFlay_Timer = 30000; + FrostNova_Timer = 30000; + } + + void Aggro(Unit *who) + { + } + + void UpdateAI(const uint32 diff) + { + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + //LichSlap_Timer + if (LichSlap_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_LICHSLAP); + LichSlap_Timer = 45000; + }else LichSlap_Timer -= diff; + + //FrostboltVolley_Timer + if (FrostboltVolley_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_FROSTBOLTVOLLEY); + FrostboltVolley_Timer = 20000; + }else FrostboltVolley_Timer -= diff; + + //MindFlay_Timer + if (MindFlay_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_MINDFLAY); + MindFlay_Timer = 20000; + }else MindFlay_Timer -= diff; + + //FrostNova_Timer + if (FrostNova_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_FROSTNOVA); + FrostNova_Timer = 15000; + }else FrostNova_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; +CreatureAI* GetAI_boss_scorn(Creature *_Creature) +{ + return new boss_scornAI (_Creature); +} + +void AddSC_boss_scorn() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_scorn"; + newscript->GetAI = GetAI_boss_scorn; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/scholomance/boss_darkmaster_gandling.cpp b/src/bindings/scripts/scripts/zone/scholomance/boss_darkmaster_gandling.cpp index bb4c17f3425..a3e8527db2b 100644 --- a/src/bindings/scripts/scripts/zone/scholomance/boss_darkmaster_gandling.cpp +++ b/src/bindings/scripts/scripts/zone/scholomance/boss_darkmaster_gandling.cpp @@ -1,192 +1,192 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Darkmaster_Gandling -SD%Complete: 99 -SDComment: Doors missing in instance script. -SDCategory: Scholomance -EndScriptData */ - -#include "precompiled.h" - -#define SPELL_ARCANEMISSILES 22272 -#define SPELL_SHADOWSHIELD 22417 //Not right ID. But 12040 is wrong either. -#define SPELL_CURSE 18702 - -#define ADD_1X 170.205 -#define ADD_1Y 99.413 -#define ADD_1Z 104.733 -#define ADD_1O 3.16 - -#define ADD_2X 170.813 -#define ADD_2Y 97.857 -#define ADD_2Z 104.713 -#define ADD_2O 3.16 - -#define ADD_3X 170.720 -#define ADD_3Y 100.900 -#define ADD_3Z 104.739 -#define ADD_3O 3.16 - -#define ADD_4X 171.866 -#define ADD_4Y 99.373 -#define ADD_4Z 104.732 -#define ADD_4O 3.16 - -struct MANGOS_DLL_DECL boss_darkmaster_gandlingAI : public ScriptedAI -{ - boss_darkmaster_gandlingAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 ArcaneMissiles_Timer; - uint32 ShadowShield_Timer; - uint32 Curse_Timer; - uint32 Teleport_Timer; - Creature *Summoned; - - void Reset() - { - ArcaneMissiles_Timer = 4500; - ShadowShield_Timer = 12000; - Curse_Timer = 2000; - Teleport_Timer = 16000; - } - - void Aggro(Unit *who) - { - } - - void UpdateAI(const uint32 diff) - { - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - //ArcaneMissiles_Timer - if (ArcaneMissiles_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_ARCANEMISSILES); - ArcaneMissiles_Timer = 8000; - }else ArcaneMissiles_Timer -= diff; - - //ShadowShield_Timer - if (ShadowShield_Timer < diff) - { - DoCast(m_creature,SPELL_SHADOWSHIELD); - ShadowShield_Timer = 14000 + rand()%14000; - }else ShadowShield_Timer -= diff; - - //Curse_Timer - if (Curse_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_CURSE); - Curse_Timer = 15000 + rand()%12000; - }else Curse_Timer -= diff; - - //Teleporting Random Target to one of the six pre boss rooms and spawn 3-4 skeletons near the gamer. - //We will only telport if gandling has more than 3% of hp so teleported gamers can always loot. - if ( m_creature->GetHealth()*100 / m_creature->GetMaxHealth() > 3 ) - { - if(Teleport_Timer < diff) - { - Unit* target = NULL; - target = SelectUnit(SELECT_TARGET_RANDOM,0); - if (target && target->GetTypeId() == TYPEID_PLAYER) - { - if(m_creature->getThreatManager().getThreat(target)) - m_creature->getThreatManager().modifyThreatPercent(target, -100); - - switch(rand()%6) - { - case 0: - DoTeleportPlayer(target, 250.0696,0.3921,84.8408,3.149); - Summoned = m_creature->SummonCreature(16119,254.2325,0.3417,84.8407,0,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,10000); - ((CreatureAI*)Summoned->AI())->AttackStart(target); - Summoned = m_creature->SummonCreature(16119,257.7133,4.0226,84.8407,0,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,10000); - ((CreatureAI*)Summoned->AI())->AttackStart(target); - Summoned = m_creature->SummonCreature(16119,258.6702,-2.60656,84.8407,0,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,10000); - ((CreatureAI*)Summoned->AI())->AttackStart(target); - break; - case 1: - DoTeleportPlayer(target, 181.4220,-91.9481,84.8410,1.608); - Summoned = m_creature->SummonCreature(16119,184.0519,-73.5649,84.8407,0,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,10000); - ((CreatureAI*)Summoned->AI())->AttackStart(target); - Summoned = m_creature->SummonCreature(16119,179.5951,-73.7045,84.8407,0,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,10000); - ((CreatureAI*)Summoned->AI())->AttackStart(target); - Summoned = m_creature->SummonCreature(16119,180.6452,-78.2143,84.8407,0,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,10000); - ((CreatureAI*)Summoned->AI())->AttackStart(target); - Summoned = m_creature->SummonCreature(16119,283.2274,-78.1518,84.8407,0,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,10000); - ((CreatureAI*)Summoned->AI())->AttackStart(target); - break; - case 2: - DoTeleportPlayer(target, 95.1547,-1.8173,85.2289,0.043); - Summoned = m_creature->SummonCreature(16119,100.9404,-1.8016,85.2289,0,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,10000); - ((CreatureAI*)Summoned->AI())->AttackStart(target); - Summoned = m_creature->SummonCreature(16119,101.3729,0.4882,85.2289,0,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,10000); - ((CreatureAI*)Summoned->AI())->AttackStart(target); - Summoned = m_creature->SummonCreature(16119,101.4596,-4.4740,85.2289,0,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,10000); - ((CreatureAI*)Summoned->AI())->AttackStart(target); - break; - case 3: - DoTeleportPlayer(target, 250.0696,0.3921,72.6722,3.149); - Summoned = m_creature->SummonCreature(16119,240.34481,0.7368,72.6722,0,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,10000); - ((CreatureAI*)Summoned->AI())->AttackStart(target); - Summoned = m_creature->SummonCreature(16119,240.3633,-2.9520,72.6722,0,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,10000); - ((CreatureAI*)Summoned->AI())->AttackStart(target); - Summoned = m_creature->SummonCreature(16119,240.6702,3.34949,72.6722,0,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,10000); - ((CreatureAI*)Summoned->AI())->AttackStart(target); - break; - case 4: - DoTeleportPlayer(target, 181.4220,-91.9481,70.7734,1.608); - Summoned = m_creature->SummonCreature(16119,184.0519,-73.5649,70.7734,0,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,10000); - ((CreatureAI*)Summoned->AI())->AttackStart(target); - Summoned = m_creature->SummonCreature(16119,179.5951,-73.7045,70.7734,0,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,10000); - ((CreatureAI*)Summoned->AI())->AttackStart(target); - Summoned = m_creature->SummonCreature(16119,180.6452,-78.2143,70.7734,0,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,10000); - ((CreatureAI*)Summoned->AI())->AttackStart(target); - Summoned = m_creature->SummonCreature(16119,283.2274,-78.1518,70.7734,0,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,10000); - ((CreatureAI*)Summoned->AI())->AttackStart(target); - break; - case 5: - DoTeleportPlayer(target, 106.1541,-1.8994,75.3663,0.043); - Summoned = m_creature->SummonCreature(16119,115.3945,-1.5555,75.3663,0,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,10000); - ((CreatureAI*)Summoned->AI())->AttackStart(target); - Summoned = m_creature->SummonCreature(16119,257.7133,1.8066,75.3663,0,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,10000); - ((CreatureAI*)Summoned->AI())->AttackStart(target); - Summoned = m_creature->SummonCreature(16119,258.6702,-5.1001,75.3663,0,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,10000); - ((CreatureAI*)Summoned->AI())->AttackStart(target); - break; - } - } - Teleport_Timer = 20000 + rand()%15000; - }else Teleport_Timer -= diff; - } - - DoMeleeAttackIfReady(); - } -}; -CreatureAI* GetAI_boss_darkmaster_gandling(Creature *_Creature) -{ - return new boss_darkmaster_gandlingAI (_Creature); -} - -void AddSC_boss_darkmaster_gandling() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_darkmaster_gandling"; - newscript->GetAI = GetAI_boss_darkmaster_gandling; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Darkmaster_Gandling +SD%Complete: 99 +SDComment: Doors missing in instance script. +SDCategory: Scholomance +EndScriptData */ + +#include "precompiled.h" + +#define SPELL_ARCANEMISSILES 22272 +#define SPELL_SHADOWSHIELD 22417 //Not right ID. But 12040 is wrong either. +#define SPELL_CURSE 18702 + +#define ADD_1X 170.205 +#define ADD_1Y 99.413 +#define ADD_1Z 104.733 +#define ADD_1O 3.16 + +#define ADD_2X 170.813 +#define ADD_2Y 97.857 +#define ADD_2Z 104.713 +#define ADD_2O 3.16 + +#define ADD_3X 170.720 +#define ADD_3Y 100.900 +#define ADD_3Z 104.739 +#define ADD_3O 3.16 + +#define ADD_4X 171.866 +#define ADD_4Y 99.373 +#define ADD_4Z 104.732 +#define ADD_4O 3.16 + +struct MANGOS_DLL_DECL boss_darkmaster_gandlingAI : public ScriptedAI +{ + boss_darkmaster_gandlingAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 ArcaneMissiles_Timer; + uint32 ShadowShield_Timer; + uint32 Curse_Timer; + uint32 Teleport_Timer; + Creature *Summoned; + + void Reset() + { + ArcaneMissiles_Timer = 4500; + ShadowShield_Timer = 12000; + Curse_Timer = 2000; + Teleport_Timer = 16000; + } + + void Aggro(Unit *who) + { + } + + void UpdateAI(const uint32 diff) + { + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + //ArcaneMissiles_Timer + if (ArcaneMissiles_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_ARCANEMISSILES); + ArcaneMissiles_Timer = 8000; + }else ArcaneMissiles_Timer -= diff; + + //ShadowShield_Timer + if (ShadowShield_Timer < diff) + { + DoCast(m_creature,SPELL_SHADOWSHIELD); + ShadowShield_Timer = 14000 + rand()%14000; + }else ShadowShield_Timer -= diff; + + //Curse_Timer + if (Curse_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_CURSE); + Curse_Timer = 15000 + rand()%12000; + }else Curse_Timer -= diff; + + //Teleporting Random Target to one of the six pre boss rooms and spawn 3-4 skeletons near the gamer. + //We will only telport if gandling has more than 3% of hp so teleported gamers can always loot. + if ( m_creature->GetHealth()*100 / m_creature->GetMaxHealth() > 3 ) + { + if(Teleport_Timer < diff) + { + Unit* target = NULL; + target = SelectUnit(SELECT_TARGET_RANDOM,0); + if (target && target->GetTypeId() == TYPEID_PLAYER) + { + if(m_creature->getThreatManager().getThreat(target)) + m_creature->getThreatManager().modifyThreatPercent(target, -100); + + switch(rand()%6) + { + case 0: + DoTeleportPlayer(target, 250.0696,0.3921,84.8408,3.149); + Summoned = m_creature->SummonCreature(16119,254.2325,0.3417,84.8407,0,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,10000); + ((CreatureAI*)Summoned->AI())->AttackStart(target); + Summoned = m_creature->SummonCreature(16119,257.7133,4.0226,84.8407,0,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,10000); + ((CreatureAI*)Summoned->AI())->AttackStart(target); + Summoned = m_creature->SummonCreature(16119,258.6702,-2.60656,84.8407,0,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,10000); + ((CreatureAI*)Summoned->AI())->AttackStart(target); + break; + case 1: + DoTeleportPlayer(target, 181.4220,-91.9481,84.8410,1.608); + Summoned = m_creature->SummonCreature(16119,184.0519,-73.5649,84.8407,0,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,10000); + ((CreatureAI*)Summoned->AI())->AttackStart(target); + Summoned = m_creature->SummonCreature(16119,179.5951,-73.7045,84.8407,0,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,10000); + ((CreatureAI*)Summoned->AI())->AttackStart(target); + Summoned = m_creature->SummonCreature(16119,180.6452,-78.2143,84.8407,0,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,10000); + ((CreatureAI*)Summoned->AI())->AttackStart(target); + Summoned = m_creature->SummonCreature(16119,283.2274,-78.1518,84.8407,0,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,10000); + ((CreatureAI*)Summoned->AI())->AttackStart(target); + break; + case 2: + DoTeleportPlayer(target, 95.1547,-1.8173,85.2289,0.043); + Summoned = m_creature->SummonCreature(16119,100.9404,-1.8016,85.2289,0,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,10000); + ((CreatureAI*)Summoned->AI())->AttackStart(target); + Summoned = m_creature->SummonCreature(16119,101.3729,0.4882,85.2289,0,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,10000); + ((CreatureAI*)Summoned->AI())->AttackStart(target); + Summoned = m_creature->SummonCreature(16119,101.4596,-4.4740,85.2289,0,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,10000); + ((CreatureAI*)Summoned->AI())->AttackStart(target); + break; + case 3: + DoTeleportPlayer(target, 250.0696,0.3921,72.6722,3.149); + Summoned = m_creature->SummonCreature(16119,240.34481,0.7368,72.6722,0,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,10000); + ((CreatureAI*)Summoned->AI())->AttackStart(target); + Summoned = m_creature->SummonCreature(16119,240.3633,-2.9520,72.6722,0,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,10000); + ((CreatureAI*)Summoned->AI())->AttackStart(target); + Summoned = m_creature->SummonCreature(16119,240.6702,3.34949,72.6722,0,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,10000); + ((CreatureAI*)Summoned->AI())->AttackStart(target); + break; + case 4: + DoTeleportPlayer(target, 181.4220,-91.9481,70.7734,1.608); + Summoned = m_creature->SummonCreature(16119,184.0519,-73.5649,70.7734,0,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,10000); + ((CreatureAI*)Summoned->AI())->AttackStart(target); + Summoned = m_creature->SummonCreature(16119,179.5951,-73.7045,70.7734,0,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,10000); + ((CreatureAI*)Summoned->AI())->AttackStart(target); + Summoned = m_creature->SummonCreature(16119,180.6452,-78.2143,70.7734,0,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,10000); + ((CreatureAI*)Summoned->AI())->AttackStart(target); + Summoned = m_creature->SummonCreature(16119,283.2274,-78.1518,70.7734,0,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,10000); + ((CreatureAI*)Summoned->AI())->AttackStart(target); + break; + case 5: + DoTeleportPlayer(target, 106.1541,-1.8994,75.3663,0.043); + Summoned = m_creature->SummonCreature(16119,115.3945,-1.5555,75.3663,0,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,10000); + ((CreatureAI*)Summoned->AI())->AttackStart(target); + Summoned = m_creature->SummonCreature(16119,257.7133,1.8066,75.3663,0,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,10000); + ((CreatureAI*)Summoned->AI())->AttackStart(target); + Summoned = m_creature->SummonCreature(16119,258.6702,-5.1001,75.3663,0,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,10000); + ((CreatureAI*)Summoned->AI())->AttackStart(target); + break; + } + } + Teleport_Timer = 20000 + rand()%15000; + }else Teleport_Timer -= diff; + } + + DoMeleeAttackIfReady(); + } +}; +CreatureAI* GetAI_boss_darkmaster_gandling(Creature *_Creature) +{ + return new boss_darkmaster_gandlingAI (_Creature); +} + +void AddSC_boss_darkmaster_gandling() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_darkmaster_gandling"; + newscript->GetAI = GetAI_boss_darkmaster_gandling; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/scholomance/boss_death_knight_darkreaver.cpp b/src/bindings/scripts/scripts/zone/scholomance/boss_death_knight_darkreaver.cpp index 344ab9840d9..46fdc01e76c 100644 --- a/src/bindings/scripts/scripts/zone/scholomance/boss_death_knight_darkreaver.cpp +++ b/src/bindings/scripts/scripts/zone/scholomance/boss_death_knight_darkreaver.cpp @@ -1,59 +1,59 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Death_knight_darkreaver -SD%Complete: 100 -SDComment: -SDCategory: Scholomance -EndScriptData */ - -#include "precompiled.h" - -struct MANGOS_DLL_DECL boss_death_knight_darkreaverAI : public ScriptedAI -{ - boss_death_knight_darkreaverAI(Creature *c) : ScriptedAI(c) {Reset();} - - void Reset() - { - } - - void DamageTaken(Unit *done_by, uint32 &damage) - { - if (m_creature->GetHealth() <= damage) - { - m_creature->CastSpell(m_creature,23261,true); //Summon Darkreaver's Fallen Charger - } - } - - void Aggro(Unit *who) - { - } -}; -CreatureAI* GetAI_boss_death_knight_darkreaver(Creature *_Creature) -{ - return new boss_death_knight_darkreaverAI (_Creature); -} - -void AddSC_boss_death_knight_darkreaver() -{ - Script *newscript; - - newscript = new Script; - newscript->Name="boss_death_knight_darkreaver"; - newscript->GetAI = GetAI_boss_death_knight_darkreaver; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Death_knight_darkreaver +SD%Complete: 100 +SDComment: +SDCategory: Scholomance +EndScriptData */ + +#include "precompiled.h" + +struct MANGOS_DLL_DECL boss_death_knight_darkreaverAI : public ScriptedAI +{ + boss_death_knight_darkreaverAI(Creature *c) : ScriptedAI(c) {Reset();} + + void Reset() + { + } + + void DamageTaken(Unit *done_by, uint32 &damage) + { + if (m_creature->GetHealth() <= damage) + { + m_creature->CastSpell(m_creature,23261,true); //Summon Darkreaver's Fallen Charger + } + } + + void Aggro(Unit *who) + { + } +}; +CreatureAI* GetAI_boss_death_knight_darkreaver(Creature *_Creature) +{ + return new boss_death_knight_darkreaverAI (_Creature); +} + +void AddSC_boss_death_knight_darkreaver() +{ + Script *newscript; + + newscript = new Script; + newscript->Name="boss_death_knight_darkreaver"; + newscript->GetAI = GetAI_boss_death_knight_darkreaver; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/scholomance/boss_doctor_theolen_krastinov.cpp b/src/bindings/scripts/scripts/zone/scholomance/boss_doctor_theolen_krastinov.cpp index 4dd663fbc5f..8fc33e2cef7 100644 --- a/src/bindings/scripts/scripts/zone/scholomance/boss_doctor_theolen_krastinov.cpp +++ b/src/bindings/scripts/scripts/zone/scholomance/boss_doctor_theolen_krastinov.cpp @@ -1,108 +1,108 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Doctor_Theolen_Krastinov -SD%Complete: 100 -SDComment: -SDCategory: Scholomance -EndScriptData */ - -#include "precompiled.h" -#include "def_scholomance.h" - -#define SPELL_REND 18106 -#define SPELL_CLEAVE 15584 -#define SPELL_FRENZY 28371 - -struct MANGOS_DLL_DECL boss_theolenkrastinovAI : public ScriptedAI -{ - boss_theolenkrastinovAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 Rend_Timer; - uint32 Cleave_Timer; - uint32 Frenzy_Timer; - - void Reset() - { - Rend_Timer = 8000; - Cleave_Timer = 9000; - Frenzy_Timer =0; - } - - void JustDied(Unit *killer) - { - ScriptedInstance *pInstance = (m_creature->GetInstanceData()) ? ((ScriptedInstance*)m_creature->GetInstanceData()) : NULL; - if(pInstance) - { - pInstance->SetData(DATA_DOCTORTHEOLENKRASTINOV_DEATH, 0); - - if(pInstance->GetData(DATA_CANSPAWNGANDLING)) - m_creature->SummonCreature(1853, 180.73, -9.43856, 75.507, 1.61399, TEMPSUMMON_DEAD_DESPAWN, 0); - } - } - - void Aggro(Unit *who) - { - } - - void UpdateAI(const uint32 diff) - { - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - //Rend_Timer - if (Rend_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_REND); - Rend_Timer = 10000; - }else Rend_Timer -= diff; - - //Cleave_Timer - if (Cleave_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_CLEAVE); - Cleave_Timer = 10000; - }else Cleave_Timer -= diff; - - //Frenzy_Timer - if ( m_creature->GetHealth()*100 / m_creature->GetMaxHealth() < 26 ) - { - if (Frenzy_Timer < diff) - { - DoCast(m_creature,SPELL_FRENZY); - DoTextEmote("goes into a killing frenzy!",NULL); - - Frenzy_Timer = 8000; - }else Frenzy_Timer -= diff; - } - - DoMeleeAttackIfReady(); - } -}; -CreatureAI* GetAI_boss_theolenkrastinov(Creature *_Creature) -{ - return new boss_theolenkrastinovAI (_Creature); -} - -void AddSC_boss_theolenkrastinov() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_doctor_theolen_krastinov"; - newscript->GetAI = GetAI_boss_theolenkrastinov; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Doctor_Theolen_Krastinov +SD%Complete: 100 +SDComment: +SDCategory: Scholomance +EndScriptData */ + +#include "precompiled.h" +#include "def_scholomance.h" + +#define SPELL_REND 18106 +#define SPELL_CLEAVE 15584 +#define SPELL_FRENZY 28371 + +struct MANGOS_DLL_DECL boss_theolenkrastinovAI : public ScriptedAI +{ + boss_theolenkrastinovAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 Rend_Timer; + uint32 Cleave_Timer; + uint32 Frenzy_Timer; + + void Reset() + { + Rend_Timer = 8000; + Cleave_Timer = 9000; + Frenzy_Timer =0; + } + + void JustDied(Unit *killer) + { + ScriptedInstance *pInstance = (m_creature->GetInstanceData()) ? ((ScriptedInstance*)m_creature->GetInstanceData()) : NULL; + if(pInstance) + { + pInstance->SetData(DATA_DOCTORTHEOLENKRASTINOV_DEATH, 0); + + if(pInstance->GetData(DATA_CANSPAWNGANDLING)) + m_creature->SummonCreature(1853, 180.73, -9.43856, 75.507, 1.61399, TEMPSUMMON_DEAD_DESPAWN, 0); + } + } + + void Aggro(Unit *who) + { + } + + void UpdateAI(const uint32 diff) + { + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + //Rend_Timer + if (Rend_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_REND); + Rend_Timer = 10000; + }else Rend_Timer -= diff; + + //Cleave_Timer + if (Cleave_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_CLEAVE); + Cleave_Timer = 10000; + }else Cleave_Timer -= diff; + + //Frenzy_Timer + if ( m_creature->GetHealth()*100 / m_creature->GetMaxHealth() < 26 ) + { + if (Frenzy_Timer < diff) + { + DoCast(m_creature,SPELL_FRENZY); + DoTextEmote("goes into a killing frenzy!",NULL); + + Frenzy_Timer = 8000; + }else Frenzy_Timer -= diff; + } + + DoMeleeAttackIfReady(); + } +}; +CreatureAI* GetAI_boss_theolenkrastinov(Creature *_Creature) +{ + return new boss_theolenkrastinovAI (_Creature); +} + +void AddSC_boss_theolenkrastinov() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_doctor_theolen_krastinov"; + newscript->GetAI = GetAI_boss_theolenkrastinov; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/scholomance/boss_illucia_barov.cpp b/src/bindings/scripts/scripts/zone/scholomance/boss_illucia_barov.cpp index 1a45b7e2697..f4d797a8887 100644 --- a/src/bindings/scripts/scripts/zone/scholomance/boss_illucia_barov.cpp +++ b/src/bindings/scripts/scripts/zone/scholomance/boss_illucia_barov.cpp @@ -1,116 +1,116 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Illucia_Barov -SD%Complete: 100 -SDComment: -SDCategory: Scholomance -EndScriptData */ - -#include "precompiled.h" -#include "def_scholomance.h" - -#define SPELL_CURSEOFAGONY 18671 -#define SPELL_SHADOWSHOCK 20603 -#define SPELL_SILENCE 15487 -#define SPELL_FEAR 6215 - -struct MANGOS_DLL_DECL boss_illuciabarovAI : public ScriptedAI -{ - boss_illuciabarovAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 CurseOfAgony_Timer; - uint32 ShadowShock_Timer; - uint32 Silence_Timer; - uint32 Fear_Timer; - - void Reset() - { - CurseOfAgony_Timer = 18000; - ShadowShock_Timer = 9000; - Silence_Timer = 5000; - Fear_Timer = 30000; - } - - void JustDied(Unit *killer) - { - ScriptedInstance *pInstance = (m_creature->GetInstanceData()) ? ((ScriptedInstance*)m_creature->GetInstanceData()) : NULL; - if(pInstance) - { - pInstance->SetData(DATA_LADYILLUCIABAROV_DEATH, 0); - - if(pInstance->GetData(DATA_CANSPAWNGANDLING)) - m_creature->SummonCreature(1853, 180.73, -9.43856, 75.507, 1.61399, TEMPSUMMON_DEAD_DESPAWN, 0); - } - } - - void Aggro(Unit *who) - { - } - - void UpdateAI(const uint32 diff) - { - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - //CurseOfAgony_Timer - if (CurseOfAgony_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_CURSEOFAGONY); - CurseOfAgony_Timer = 30000; - }else CurseOfAgony_Timer -= diff; - - //ShadowShock_Timer - if (ShadowShock_Timer < diff) - { - Unit* target = NULL; - target = SelectUnit(SELECT_TARGET_RANDOM,0); - if (target) DoCast(target,SPELL_SHADOWSHOCK); - - ShadowShock_Timer = 12000; - }else ShadowShock_Timer -= diff; - - //Silence_Timer - if (Silence_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_SILENCE); - Silence_Timer = 14000; - }else Silence_Timer -= diff; - - //Fear_Timer - if (Fear_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_FEAR); - Fear_Timer = 30000; - }else Fear_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; -CreatureAI* GetAI_boss_illuciabarov(Creature *_Creature) -{ - return new boss_illuciabarovAI (_Creature); -} - -void AddSC_boss_illuciabarov() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_illucia_barov"; - newscript->GetAI = GetAI_boss_illuciabarov; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Illucia_Barov +SD%Complete: 100 +SDComment: +SDCategory: Scholomance +EndScriptData */ + +#include "precompiled.h" +#include "def_scholomance.h" + +#define SPELL_CURSEOFAGONY 18671 +#define SPELL_SHADOWSHOCK 20603 +#define SPELL_SILENCE 15487 +#define SPELL_FEAR 6215 + +struct MANGOS_DLL_DECL boss_illuciabarovAI : public ScriptedAI +{ + boss_illuciabarovAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 CurseOfAgony_Timer; + uint32 ShadowShock_Timer; + uint32 Silence_Timer; + uint32 Fear_Timer; + + void Reset() + { + CurseOfAgony_Timer = 18000; + ShadowShock_Timer = 9000; + Silence_Timer = 5000; + Fear_Timer = 30000; + } + + void JustDied(Unit *killer) + { + ScriptedInstance *pInstance = (m_creature->GetInstanceData()) ? ((ScriptedInstance*)m_creature->GetInstanceData()) : NULL; + if(pInstance) + { + pInstance->SetData(DATA_LADYILLUCIABAROV_DEATH, 0); + + if(pInstance->GetData(DATA_CANSPAWNGANDLING)) + m_creature->SummonCreature(1853, 180.73, -9.43856, 75.507, 1.61399, TEMPSUMMON_DEAD_DESPAWN, 0); + } + } + + void Aggro(Unit *who) + { + } + + void UpdateAI(const uint32 diff) + { + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + //CurseOfAgony_Timer + if (CurseOfAgony_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_CURSEOFAGONY); + CurseOfAgony_Timer = 30000; + }else CurseOfAgony_Timer -= diff; + + //ShadowShock_Timer + if (ShadowShock_Timer < diff) + { + Unit* target = NULL; + target = SelectUnit(SELECT_TARGET_RANDOM,0); + if (target) DoCast(target,SPELL_SHADOWSHOCK); + + ShadowShock_Timer = 12000; + }else ShadowShock_Timer -= diff; + + //Silence_Timer + if (Silence_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_SILENCE); + Silence_Timer = 14000; + }else Silence_Timer -= diff; + + //Fear_Timer + if (Fear_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_FEAR); + Fear_Timer = 30000; + }else Fear_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; +CreatureAI* GetAI_boss_illuciabarov(Creature *_Creature) +{ + return new boss_illuciabarovAI (_Creature); +} + +void AddSC_boss_illuciabarov() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_illucia_barov"; + newscript->GetAI = GetAI_boss_illuciabarov; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/scholomance/boss_instructor_malicia.cpp b/src/bindings/scripts/scripts/zone/scholomance/boss_instructor_malicia.cpp index 9d2dbc174d5..78a40f46448 100644 --- a/src/bindings/scripts/scripts/zone/scholomance/boss_instructor_malicia.cpp +++ b/src/bindings/scripts/scripts/zone/scholomance/boss_instructor_malicia.cpp @@ -1,152 +1,152 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_instructormalicia -SD%Complete: 100 -SDComment: -SDCategory: Scholomance -EndScriptData */ - -#include "precompiled.h" -#include "def_scholomance.h" - -#define SPELL_CALLOFGRAVES 17831 -#define SPELL_CORRUPTION 11672 -#define SPELL_FLASHHEAL 10917 -#define SPELL_RENEW 10929 -#define SPELL_HEALINGTOUCH 9889 - -struct MANGOS_DLL_DECL boss_instructormaliciaAI : public ScriptedAI -{ - boss_instructormaliciaAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 CallOfGraves_Timer; - uint32 Corruption_Timer; - uint32 FlashHeal_Timer; - uint32 Renew_Timer; - uint32 HealingTouch_Timer; - uint32 FlashCounter; - uint32 TouchCounter; - - void Reset() - { - CallOfGraves_Timer = 4000; - Corruption_Timer = 8000; - FlashHeal_Timer = 38000; - Renew_Timer = 32000; - HealingTouch_Timer = 45000; - FlashCounter = 0; - TouchCounter = 0; - } - - void JustDied(Unit *killer) - { - ScriptedInstance *pInstance = (m_creature->GetInstanceData()) ? ((ScriptedInstance*)m_creature->GetInstanceData()) : NULL; - if(pInstance) - { - pInstance->SetData(DATA_INSTRUCTORMALICIA_DEATH, 0); - - if(pInstance->GetData(DATA_CANSPAWNGANDLING)) - m_creature->SummonCreature(1853, 180.73, -9.43856, 75.507, 1.61399, TEMPSUMMON_DEAD_DESPAWN, 0); - } - } - - void Aggro(Unit *who) - { - } - - void UpdateAI(const uint32 diff) - { - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - //CallOfGraves_Timer - if (CallOfGraves_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_CALLOFGRAVES); - CallOfGraves_Timer = 65000; - }else CallOfGraves_Timer -= diff; - - //Corruption_Timer - if (Corruption_Timer < diff) - { - Unit* target = NULL; - target = SelectUnit(SELECT_TARGET_RANDOM,0); - if (target) DoCast(target,SPELL_CORRUPTION); - - Corruption_Timer = 24000; - }else Corruption_Timer -= diff; - - //Renew_Timer - if (Renew_Timer < diff) - { - DoCast(m_creature, SPELL_RENEW); - Renew_Timer = 10000; - }else Renew_Timer -= diff; - - //FlashHeal_Timer - if (FlashHeal_Timer < diff) - { - DoCast(m_creature,SPELL_FLASHHEAL); - - //5 Flashheals will be casted - if (FlashCounter < 2) - { - FlashHeal_Timer = 5000; - FlashCounter++; - } - else - { - FlashCounter=0; - FlashHeal_Timer = 30000; - } - }else FlashHeal_Timer -= diff; - - //HealingTouch_Timer - if (HealingTouch_Timer < diff) - { - DoCast(m_creature,SPELL_HEALINGTOUCH); - - //3 Healingtouchs will be casted - if (HealingTouch_Timer < 2) - { - HealingTouch_Timer = 5500; - TouchCounter++; - } - else - { - TouchCounter=0; - HealingTouch_Timer = 30000; - } - }else HealingTouch_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; -CreatureAI* GetAI_boss_instructormalicia(Creature *_Creature) -{ - return new boss_instructormaliciaAI (_Creature); -} - -void AddSC_boss_instructormalicia() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_instructor_malicia"; - newscript->GetAI = GetAI_boss_instructormalicia; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_instructormalicia +SD%Complete: 100 +SDComment: +SDCategory: Scholomance +EndScriptData */ + +#include "precompiled.h" +#include "def_scholomance.h" + +#define SPELL_CALLOFGRAVES 17831 +#define SPELL_CORRUPTION 11672 +#define SPELL_FLASHHEAL 10917 +#define SPELL_RENEW 10929 +#define SPELL_HEALINGTOUCH 9889 + +struct MANGOS_DLL_DECL boss_instructormaliciaAI : public ScriptedAI +{ + boss_instructormaliciaAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 CallOfGraves_Timer; + uint32 Corruption_Timer; + uint32 FlashHeal_Timer; + uint32 Renew_Timer; + uint32 HealingTouch_Timer; + uint32 FlashCounter; + uint32 TouchCounter; + + void Reset() + { + CallOfGraves_Timer = 4000; + Corruption_Timer = 8000; + FlashHeal_Timer = 38000; + Renew_Timer = 32000; + HealingTouch_Timer = 45000; + FlashCounter = 0; + TouchCounter = 0; + } + + void JustDied(Unit *killer) + { + ScriptedInstance *pInstance = (m_creature->GetInstanceData()) ? ((ScriptedInstance*)m_creature->GetInstanceData()) : NULL; + if(pInstance) + { + pInstance->SetData(DATA_INSTRUCTORMALICIA_DEATH, 0); + + if(pInstance->GetData(DATA_CANSPAWNGANDLING)) + m_creature->SummonCreature(1853, 180.73, -9.43856, 75.507, 1.61399, TEMPSUMMON_DEAD_DESPAWN, 0); + } + } + + void Aggro(Unit *who) + { + } + + void UpdateAI(const uint32 diff) + { + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + //CallOfGraves_Timer + if (CallOfGraves_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_CALLOFGRAVES); + CallOfGraves_Timer = 65000; + }else CallOfGraves_Timer -= diff; + + //Corruption_Timer + if (Corruption_Timer < diff) + { + Unit* target = NULL; + target = SelectUnit(SELECT_TARGET_RANDOM,0); + if (target) DoCast(target,SPELL_CORRUPTION); + + Corruption_Timer = 24000; + }else Corruption_Timer -= diff; + + //Renew_Timer + if (Renew_Timer < diff) + { + DoCast(m_creature, SPELL_RENEW); + Renew_Timer = 10000; + }else Renew_Timer -= diff; + + //FlashHeal_Timer + if (FlashHeal_Timer < diff) + { + DoCast(m_creature,SPELL_FLASHHEAL); + + //5 Flashheals will be casted + if (FlashCounter < 2) + { + FlashHeal_Timer = 5000; + FlashCounter++; + } + else + { + FlashCounter=0; + FlashHeal_Timer = 30000; + } + }else FlashHeal_Timer -= diff; + + //HealingTouch_Timer + if (HealingTouch_Timer < diff) + { + DoCast(m_creature,SPELL_HEALINGTOUCH); + + //3 Healingtouchs will be casted + if (HealingTouch_Timer < 2) + { + HealingTouch_Timer = 5500; + TouchCounter++; + } + else + { + TouchCounter=0; + HealingTouch_Timer = 30000; + } + }else HealingTouch_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; +CreatureAI* GetAI_boss_instructormalicia(Creature *_Creature) +{ + return new boss_instructormaliciaAI (_Creature); +} + +void AddSC_boss_instructormalicia() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_instructor_malicia"; + newscript->GetAI = GetAI_boss_instructormalicia; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/scholomance/boss_jandice_barov.cpp b/src/bindings/scripts/scripts/zone/scholomance/boss_jandice_barov.cpp index 05eaba72a3f..69f35357937 100644 --- a/src/bindings/scripts/scripts/zone/scholomance/boss_jandice_barov.cpp +++ b/src/bindings/scripts/scripts/zone/scholomance/boss_jandice_barov.cpp @@ -1,226 +1,208 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_jandicebarov -SD%Complete: 100 -SDComment: -SDCategory: Scholomance -EndScriptData */ - -#include "precompiled.h" - -#define SPELL_CURSEOFBLOOD 24673 -//#define SPELL_ILLUSION 17773 - -//Spells of Illusion of Jandice Barov -#define SPELL_CLEAVE 15584 - -struct MANGOS_DLL_DECL boss_jandicebarovAI : public ScriptedAI -{ - boss_jandicebarovAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 CurseOfBlood_Timer; - uint32 Illusion_Timer; - //uint32 Illusioncounter; - uint32 Invisible_Timer; - bool Invisible; - int Rand; - int RandX; - int RandY; - Creature* Summoned; - - void Reset() - { - CurseOfBlood_Timer = 15000; - Illusion_Timer = 30000; - Invisible_Timer = 3000; //Too much too low? - Invisible = false; - } - - void Aggro(Unit *who) - { - } - - void SummonIllusions(Unit* victim) - { - Rand = rand()%10; - switch (rand()%2) - { - case 0: RandX = 0 - Rand; break; - case 1: RandX = 0 + Rand; break; - } - Rand = 0; - Rand = rand()%10; - switch (rand()%2) - { - case 0: RandY = 0 - Rand; break; - case 1: RandY = 0 + Rand; break; - } - Rand = 0; - Summoned = DoSpawnCreature(11439, RandX, RandY, 0, 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 60000); - if(Summoned) - ((CreatureAI*)Summoned->AI())->AttackStart(victim); - } - - void UpdateAI(const uint32 diff) - { - if (Invisible && Invisible_Timer < diff) - { - //Become visible again - m_creature->setFaction(14); - m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - //Jandice Model - m_creature->SetUInt32Value(UNIT_FIELD_DISPLAYID,11073); - Invisible = false; - } else if (Invisible) - { - Invisible_Timer -= diff; - //Do nothing while invisible - return; - } - - //Return since we have no target - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - //CurseOfBlood_Timer - if (CurseOfBlood_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_CURSEOFBLOOD); - CurseOfBlood_Timer = 30000; - }else CurseOfBlood_Timer -= diff; - - //Illusion_Timer - if (!Invisible && Illusion_Timer < diff) - { - //Inturrupt any spell casting - m_creature->InterruptNonMeleeSpells(false); - m_creature->setFaction(35); - m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - // Invisible Model - m_creature->SetUInt32Value(UNIT_FIELD_DISPLAYID,11686); - - //Summon 10 Illusions attacking random gamers - Unit* target = NULL; - for(int i = 0; i < 10;i++) - { - target = SelectUnit(SELECT_TARGET_RANDOM,0); - SummonIllusions(target); - } - Invisible = true; - Invisible_Timer = 3000; - - Illusion_Timer = 25000; - }else Illusion_Timer -= diff; - - // //Illusion_Timer - // if (Illusion_Timer < diff) - // { - // //Cast - // DoCast(m_creature->getVictim(),SPELL_ILLUSION); - // - // //3 Illusion will be summoned - // if (Illusioncounter < 3) - // { - // Illusion_Timer = 500; - // Illusioncounter++; - // } - // else { - // Illusion_Timer = 15000; - // Illusioncounter=0; - // } - // - // }else Illusion_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; - -// Illusion of Jandice Barov Script - -struct MANGOS_DLL_DECL mob_illusionofjandicebarovAI : public ScriptedAI -{ - mob_illusionofjandicebarovAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 Cleave_Timer; - - void Reset() - { - Cleave_Timer = 4000; - } - - void Aggro(Unit *who) - { - } - - void MoveInLineOfSight(Unit *who) - { - if (!who || m_creature->getVictim()) - return; - - if (who->isTargetableForAttack() && who->isInAccessablePlaceFor(m_creature) && m_creature->IsHostileTo(who)) - { - float attackRadius = m_creature->GetAttackDistance(who); - if (m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->GetDistanceZ(who) <= CREATURE_Z_ATTACK_RANGE && m_creature->IsWithinLOSInMap(who)) - { - if(who->HasStealthAura()) - who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); - - DoStartAttackAndMovement(who); - } - } - } - - void UpdateAI(const uint32 diff) - { - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - //Cleave_Timer - if (Cleave_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_CLEAVE); - Cleave_Timer = 5000 + rand()%3000; - }else Cleave_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; - -CreatureAI* GetAI_boss_jandicebarov(Creature *_Creature) -{ - return new boss_jandicebarovAI (_Creature); -} - -CreatureAI* GetAI_mob_illusionofjandicebarov(Creature *_Creature) -{ - return new mob_illusionofjandicebarovAI (_Creature); -} - -void AddSC_boss_jandicebarov() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_jandice_barov"; - newscript->GetAI = GetAI_boss_jandicebarov; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="mob_illusionofjandicebarov"; - newscript->GetAI = GetAI_mob_illusionofjandicebarov; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_jandicebarov +SD%Complete: 100 +SDComment: +SDCategory: Scholomance +EndScriptData */ + +#include "precompiled.h" + +#define SPELL_CURSEOFBLOOD 24673 +//#define SPELL_ILLUSION 17773 + +//Spells of Illusion of Jandice Barov +#define SPELL_CLEAVE 15584 + +struct MANGOS_DLL_DECL boss_jandicebarovAI : public ScriptedAI +{ + boss_jandicebarovAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 CurseOfBlood_Timer; + uint32 Illusion_Timer; + //uint32 Illusioncounter; + uint32 Invisible_Timer; + bool Invisible; + int Rand; + int RandX; + int RandY; + Creature* Summoned; + + void Reset() + { + CurseOfBlood_Timer = 15000; + Illusion_Timer = 30000; + Invisible_Timer = 3000; //Too much too low? + Invisible = false; + } + + void Aggro(Unit *who) + { + } + + void SummonIllusions(Unit* victim) + { + Rand = rand()%10; + switch (rand()%2) + { + case 0: RandX = 0 - Rand; break; + case 1: RandX = 0 + Rand; break; + } + Rand = 0; + Rand = rand()%10; + switch (rand()%2) + { + case 0: RandY = 0 - Rand; break; + case 1: RandY = 0 + Rand; break; + } + Rand = 0; + Summoned = DoSpawnCreature(11439, RandX, RandY, 0, 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 60000); + if(Summoned) + ((CreatureAI*)Summoned->AI())->AttackStart(victim); + } + + void UpdateAI(const uint32 diff) + { + if (Invisible && Invisible_Timer < diff) + { + //Become visible again + m_creature->setFaction(14); + m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + //Jandice Model + m_creature->SetUInt32Value(UNIT_FIELD_DISPLAYID,11073); + Invisible = false; + } else if (Invisible) + { + Invisible_Timer -= diff; + //Do nothing while invisible + return; + } + + //Return since we have no target + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + //CurseOfBlood_Timer + if (CurseOfBlood_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_CURSEOFBLOOD); + CurseOfBlood_Timer = 30000; + }else CurseOfBlood_Timer -= diff; + + //Illusion_Timer + if (!Invisible && Illusion_Timer < diff) + { + //Inturrupt any spell casting + m_creature->InterruptNonMeleeSpells(false); + m_creature->setFaction(35); + m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + // Invisible Model + m_creature->SetUInt32Value(UNIT_FIELD_DISPLAYID,11686); + + //Summon 10 Illusions attacking random gamers + Unit* target = NULL; + for(int i = 0; i < 10;i++) + { + target = SelectUnit(SELECT_TARGET_RANDOM,0); + SummonIllusions(target); + } + Invisible = true; + Invisible_Timer = 3000; + + Illusion_Timer = 25000; + }else Illusion_Timer -= diff; + + // //Illusion_Timer + // if (Illusion_Timer < diff) + // { + // //Cast + // DoCast(m_creature->getVictim(),SPELL_ILLUSION); + // + // //3 Illusion will be summoned + // if (Illusioncounter < 3) + // { + // Illusion_Timer = 500; + // Illusioncounter++; + // } + // else { + // Illusion_Timer = 15000; + // Illusioncounter=0; + // } + // + // }else Illusion_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; + +// Illusion of Jandice Barov Script + +struct MANGOS_DLL_DECL mob_illusionofjandicebarovAI : public ScriptedAI +{ + mob_illusionofjandicebarovAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 Cleave_Timer; + + void Reset() + { + Cleave_Timer = 4000; + } + + void Aggro(Unit *who) + { + } + + void UpdateAI(const uint32 diff) + { + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + //Cleave_Timer + if (Cleave_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_CLEAVE); + Cleave_Timer = 5000 + rand()%3000; + }else Cleave_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; + +CreatureAI* GetAI_boss_jandicebarov(Creature *_Creature) +{ + return new boss_jandicebarovAI (_Creature); +} + +CreatureAI* GetAI_mob_illusionofjandicebarov(Creature *_Creature) +{ + return new mob_illusionofjandicebarovAI (_Creature); +} + +void AddSC_boss_jandicebarov() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_jandice_barov"; + newscript->GetAI = GetAI_boss_jandicebarov; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="mob_illusionofjandicebarov"; + newscript->GetAI = GetAI_mob_illusionofjandicebarov; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/scholomance/boss_kormok.cpp b/src/bindings/scripts/scripts/zone/scholomance/boss_kormok.cpp index c9fb3c3a260..e0a837ef82a 100644 --- a/src/bindings/scripts/scripts/zone/scholomance/boss_kormok.cpp +++ b/src/bindings/scripts/scripts/zone/scholomance/boss_kormok.cpp @@ -1,155 +1,155 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Kormok -SD%Complete: 100 -SDComment: -SDCategory: Scholomance -EndScriptData */ - -#include "precompiled.h" - -#define SPELL_SHADOWBOLTVOLLEY 20741 -#define SPELL_BONESHIELD 27688 - -struct MANGOS_DLL_DECL boss_kormokAI : public ScriptedAI -{ - boss_kormokAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 ShadowVolley_Timer; - uint32 BoneShield_Timer; - uint32 Minion_Timer; - uint32 Mage_Timer; - bool Mages; - int Rand1; - int Rand1X; - int Rand1Y; - int Rand2; - int Rand2X; - int Rand2Y; - Creature* SummonedMinions; - Creature* SummonedMages; - - void Reset() - { - ShadowVolley_Timer = 10000; - BoneShield_Timer = 2000; - Minion_Timer = 15000; - Mage_Timer = 0; - Mages = false; - } - - void Aggro(Unit *who) - { - } - - void SummonMinion(Unit* victim) - { - Rand1 = rand()%8; - switch (rand()%2) - { - case 0: Rand1X = 0 - Rand1; break; - case 1: Rand1X = 0 + Rand1; break; - } - Rand1 = 0; - Rand1 = rand()%8; - switch (rand()%2) - { - case 0: Rand1Y = 0 - Rand1; break; - case 1: Rand1Y = 0 + Rand1; break; - } - Rand1 = 0; - SummonedMinions = DoSpawnCreature(16119, Rand1X, Rand1Y, 0, 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 120000); - ((CreatureAI*)SummonedMinions->AI())->AttackStart(victim); - } - - void SummonMages(Unit* victim) - { - Rand2 = rand()%10; - switch (rand()%2) - { - case 0: Rand2X = 0 - Rand2; break; - case 1: Rand2X = 0 + Rand2; break; - } - Rand2 = 0; - Rand2 = rand()%10; - switch (rand()%2) - { - case 0: Rand2Y = 0 - Rand2; break; - case 1: Rand2Y = 0 + Rand2; break; - } - Rand2 = 0; - SummonedMages = DoSpawnCreature(16120, Rand2X, Rand2Y, 0, 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 120000); - ((CreatureAI*)SummonedMages->AI())->AttackStart(victim); - } - - void UpdateAI(const uint32 diff) - { - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - //ShadowVolley_Timer - if (ShadowVolley_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_SHADOWBOLTVOLLEY); - ShadowVolley_Timer = 15000; - }else ShadowVolley_Timer -= diff; - - //BoneShield_Timer - if (BoneShield_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_BONESHIELD); - BoneShield_Timer = 45000; - }else BoneShield_Timer -= diff; - - //Minion_Timer - if (Minion_Timer < diff) - { - //Cast - SummonMinion(m_creature->getVictim()); - SummonMinion(m_creature->getVictim()); - SummonMinion(m_creature->getVictim()); - SummonMinion(m_creature->getVictim()); - - Minion_Timer = 12000; - }else Minion_Timer -= diff; - - //Summon 2 Bone Mages - if ( !Mages && m_creature->GetHealth()*100 / m_creature->GetMaxHealth() < 26 ) - { - //Cast - SummonMages(m_creature->getVictim()); - SummonMages(m_creature->getVictim()); - Mages = true; - } - - DoMeleeAttackIfReady(); - } -}; -CreatureAI* GetAI_boss_kormok(Creature *_Creature) -{ - return new boss_kormokAI (_Creature); -} - -void AddSC_boss_kormok() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_kormok"; - newscript->GetAI = GetAI_boss_kormok; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Kormok +SD%Complete: 100 +SDComment: +SDCategory: Scholomance +EndScriptData */ + +#include "precompiled.h" + +#define SPELL_SHADOWBOLTVOLLEY 20741 +#define SPELL_BONESHIELD 27688 + +struct MANGOS_DLL_DECL boss_kormokAI : public ScriptedAI +{ + boss_kormokAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 ShadowVolley_Timer; + uint32 BoneShield_Timer; + uint32 Minion_Timer; + uint32 Mage_Timer; + bool Mages; + int Rand1; + int Rand1X; + int Rand1Y; + int Rand2; + int Rand2X; + int Rand2Y; + Creature* SummonedMinions; + Creature* SummonedMages; + + void Reset() + { + ShadowVolley_Timer = 10000; + BoneShield_Timer = 2000; + Minion_Timer = 15000; + Mage_Timer = 0; + Mages = false; + } + + void Aggro(Unit *who) + { + } + + void SummonMinion(Unit* victim) + { + Rand1 = rand()%8; + switch (rand()%2) + { + case 0: Rand1X = 0 - Rand1; break; + case 1: Rand1X = 0 + Rand1; break; + } + Rand1 = 0; + Rand1 = rand()%8; + switch (rand()%2) + { + case 0: Rand1Y = 0 - Rand1; break; + case 1: Rand1Y = 0 + Rand1; break; + } + Rand1 = 0; + SummonedMinions = DoSpawnCreature(16119, Rand1X, Rand1Y, 0, 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 120000); + ((CreatureAI*)SummonedMinions->AI())->AttackStart(victim); + } + + void SummonMages(Unit* victim) + { + Rand2 = rand()%10; + switch (rand()%2) + { + case 0: Rand2X = 0 - Rand2; break; + case 1: Rand2X = 0 + Rand2; break; + } + Rand2 = 0; + Rand2 = rand()%10; + switch (rand()%2) + { + case 0: Rand2Y = 0 - Rand2; break; + case 1: Rand2Y = 0 + Rand2; break; + } + Rand2 = 0; + SummonedMages = DoSpawnCreature(16120, Rand2X, Rand2Y, 0, 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 120000); + ((CreatureAI*)SummonedMages->AI())->AttackStart(victim); + } + + void UpdateAI(const uint32 diff) + { + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + //ShadowVolley_Timer + if (ShadowVolley_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_SHADOWBOLTVOLLEY); + ShadowVolley_Timer = 15000; + }else ShadowVolley_Timer -= diff; + + //BoneShield_Timer + if (BoneShield_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_BONESHIELD); + BoneShield_Timer = 45000; + }else BoneShield_Timer -= diff; + + //Minion_Timer + if (Minion_Timer < diff) + { + //Cast + SummonMinion(m_creature->getVictim()); + SummonMinion(m_creature->getVictim()); + SummonMinion(m_creature->getVictim()); + SummonMinion(m_creature->getVictim()); + + Minion_Timer = 12000; + }else Minion_Timer -= diff; + + //Summon 2 Bone Mages + if ( !Mages && m_creature->GetHealth()*100 / m_creature->GetMaxHealth() < 26 ) + { + //Cast + SummonMages(m_creature->getVictim()); + SummonMages(m_creature->getVictim()); + Mages = true; + } + + DoMeleeAttackIfReady(); + } +}; +CreatureAI* GetAI_boss_kormok(Creature *_Creature) +{ + return new boss_kormokAI (_Creature); +} + +void AddSC_boss_kormok() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_kormok"; + newscript->GetAI = GetAI_boss_kormok; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/scholomance/boss_lord_alexei_barov.cpp b/src/bindings/scripts/scripts/zone/scholomance/boss_lord_alexei_barov.cpp index 65601ff3ee3..a7a6d29b3d7 100644 --- a/src/bindings/scripts/scripts/zone/scholomance/boss_lord_alexei_barov.cpp +++ b/src/bindings/scripts/scripts/zone/scholomance/boss_lord_alexei_barov.cpp @@ -1,98 +1,98 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Lord_Alexei_Barov -SD%Complete: 100 -SDComment: aura applied/defined in database -SDCategory: Scholomance -EndScriptData */ - -#include "precompiled.h" -#include "def_scholomance.h" - -#define SPELL_IMMOLATE 20294 // Old ID was 15570 -#define SPELL_VEILOFSHADOW 17820 - -struct MANGOS_DLL_DECL boss_lordalexeibarovAI : public ScriptedAI -{ - boss_lordalexeibarovAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 Immolate_Timer; - uint32 VeilofShadow_Timer; - - void Reset() - { - Immolate_Timer = 7000; - VeilofShadow_Timer = 15000; - - m_creature->LoadCreaturesAddon(); - } - - void JustDied(Unit *killer) - { - ScriptedInstance *pInstance = (m_creature->GetInstanceData()) ? ((ScriptedInstance*)m_creature->GetInstanceData()) : NULL; - if(pInstance) - { - pInstance->SetData(DATA_LORDALEXEIBAROV_DEATH, 0); - - if(pInstance->GetData(DATA_CANSPAWNGANDLING)) - m_creature->SummonCreature(1853, 180.73, -9.43856, 75.507, 1.61399, TEMPSUMMON_DEAD_DESPAWN, 0); - } - } - - void Aggro(Unit *who) - { - } - - void UpdateAI(const uint32 diff) - { - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - //Immolate_Timer - if (Immolate_Timer < diff) - { - Unit* target = NULL; - target = SelectUnit(SELECT_TARGET_RANDOM,0); - if (target) DoCast(target,SPELL_IMMOLATE); - - Immolate_Timer = 12000; - }else Immolate_Timer -= diff; - - //VeilofShadow_Timer - if (VeilofShadow_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_VEILOFSHADOW); - VeilofShadow_Timer = 20000; - }else VeilofShadow_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; -CreatureAI* GetAI_boss_lordalexeibarov(Creature *_Creature) -{ - return new boss_lordalexeibarovAI (_Creature); -} - -void AddSC_boss_lordalexeibarov() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_lord_alexei_barov"; - newscript->GetAI = GetAI_boss_lordalexeibarov; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Lord_Alexei_Barov +SD%Complete: 100 +SDComment: aura applied/defined in database +SDCategory: Scholomance +EndScriptData */ + +#include "precompiled.h" +#include "def_scholomance.h" + +#define SPELL_IMMOLATE 20294 // Old ID was 15570 +#define SPELL_VEILOFSHADOW 17820 + +struct MANGOS_DLL_DECL boss_lordalexeibarovAI : public ScriptedAI +{ + boss_lordalexeibarovAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 Immolate_Timer; + uint32 VeilofShadow_Timer; + + void Reset() + { + Immolate_Timer = 7000; + VeilofShadow_Timer = 15000; + + m_creature->LoadCreaturesAddon(); + } + + void JustDied(Unit *killer) + { + ScriptedInstance *pInstance = (m_creature->GetInstanceData()) ? ((ScriptedInstance*)m_creature->GetInstanceData()) : NULL; + if(pInstance) + { + pInstance->SetData(DATA_LORDALEXEIBAROV_DEATH, 0); + + if(pInstance->GetData(DATA_CANSPAWNGANDLING)) + m_creature->SummonCreature(1853, 180.73, -9.43856, 75.507, 1.61399, TEMPSUMMON_DEAD_DESPAWN, 0); + } + } + + void Aggro(Unit *who) + { + } + + void UpdateAI(const uint32 diff) + { + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + //Immolate_Timer + if (Immolate_Timer < diff) + { + Unit* target = NULL; + target = SelectUnit(SELECT_TARGET_RANDOM,0); + if (target) DoCast(target,SPELL_IMMOLATE); + + Immolate_Timer = 12000; + }else Immolate_Timer -= diff; + + //VeilofShadow_Timer + if (VeilofShadow_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_VEILOFSHADOW); + VeilofShadow_Timer = 20000; + }else VeilofShadow_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; +CreatureAI* GetAI_boss_lordalexeibarov(Creature *_Creature) +{ + return new boss_lordalexeibarovAI (_Creature); +} + +void AddSC_boss_lordalexeibarov() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_lord_alexei_barov"; + newscript->GetAI = GetAI_boss_lordalexeibarov; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/scholomance/boss_lorekeeper_polkelt.cpp b/src/bindings/scripts/scripts/zone/scholomance/boss_lorekeeper_polkelt.cpp index c1d6929ddfa..019cbb2b9a0 100644 --- a/src/bindings/scripts/scripts/zone/scholomance/boss_lorekeeper_polkelt.cpp +++ b/src/bindings/scripts/scripts/zone/scholomance/boss_lorekeeper_polkelt.cpp @@ -1,113 +1,113 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Lorekeeper_Polkelt -SD%Complete: 100 -SDComment: -SDCategory: Scholomance -EndScriptData */ - -#include "precompiled.h" -#include "def_scholomance.h" - -#define SPELL_VOLATILEINFECTION 24928 -#define SPELL_DARKPLAGUE 18270 -#define SPELL_CORROSIVEACID 23313 -#define SPELL_NOXIOUSCATALYST 18151 - -struct MANGOS_DLL_DECL boss_lorekeeperpolkeltAI : public ScriptedAI -{ - boss_lorekeeperpolkeltAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 VolatileInfection_Timer; - uint32 Darkplague_Timer; - uint32 CorrosiveAcid_Timer; - uint32 NoxiousCatalyst_Timer; - - void Reset() - { - VolatileInfection_Timer = 38000; - Darkplague_Timer = 8000; - CorrosiveAcid_Timer = 45000; - NoxiousCatalyst_Timer = 35000; - } - - void JustDied(Unit *killer) - { - ScriptedInstance *pInstance = (m_creature->GetInstanceData()) ? ((ScriptedInstance*)m_creature->GetInstanceData()) : NULL; - if(pInstance) - { - pInstance->SetData(DATA_LOREKEEPERPOLKELT_DEATH, 0); - - if(pInstance->GetData(DATA_CANSPAWNGANDLING)) - m_creature->SummonCreature(1853, 180.73, -9.43856, 75.507, 1.61399, TEMPSUMMON_DEAD_DESPAWN, 0); - } - } - - void Aggro(Unit *who) - { - } - - void UpdateAI(const uint32 diff) - { - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - //VolatileInfection_Timer - if (VolatileInfection_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_VOLATILEINFECTION); - VolatileInfection_Timer = 32000; - }else VolatileInfection_Timer -= diff; - - //Darkplague_Timer - if (Darkplague_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_DARKPLAGUE); - Darkplague_Timer = 8000; - }else Darkplague_Timer -= diff; - - //CorrosiveAcid_Timer - if (CorrosiveAcid_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_CORROSIVEACID); - CorrosiveAcid_Timer = 25000; - }else CorrosiveAcid_Timer -= diff; - - //NoxiousCatalyst_Timer - if (NoxiousCatalyst_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_NOXIOUSCATALYST); - NoxiousCatalyst_Timer = 38000; - }else NoxiousCatalyst_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; -CreatureAI* GetAI_boss_lorekeeperpolkelt(Creature *_Creature) -{ - return new boss_lorekeeperpolkeltAI (_Creature); -} - -void AddSC_boss_lorekeeperpolkelt() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_lorekeeper_polkelt"; - newscript->GetAI = GetAI_boss_lorekeeperpolkelt; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Lorekeeper_Polkelt +SD%Complete: 100 +SDComment: +SDCategory: Scholomance +EndScriptData */ + +#include "precompiled.h" +#include "def_scholomance.h" + +#define SPELL_VOLATILEINFECTION 24928 +#define SPELL_DARKPLAGUE 18270 +#define SPELL_CORROSIVEACID 23313 +#define SPELL_NOXIOUSCATALYST 18151 + +struct MANGOS_DLL_DECL boss_lorekeeperpolkeltAI : public ScriptedAI +{ + boss_lorekeeperpolkeltAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 VolatileInfection_Timer; + uint32 Darkplague_Timer; + uint32 CorrosiveAcid_Timer; + uint32 NoxiousCatalyst_Timer; + + void Reset() + { + VolatileInfection_Timer = 38000; + Darkplague_Timer = 8000; + CorrosiveAcid_Timer = 45000; + NoxiousCatalyst_Timer = 35000; + } + + void JustDied(Unit *killer) + { + ScriptedInstance *pInstance = (m_creature->GetInstanceData()) ? ((ScriptedInstance*)m_creature->GetInstanceData()) : NULL; + if(pInstance) + { + pInstance->SetData(DATA_LOREKEEPERPOLKELT_DEATH, 0); + + if(pInstance->GetData(DATA_CANSPAWNGANDLING)) + m_creature->SummonCreature(1853, 180.73, -9.43856, 75.507, 1.61399, TEMPSUMMON_DEAD_DESPAWN, 0); + } + } + + void Aggro(Unit *who) + { + } + + void UpdateAI(const uint32 diff) + { + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + //VolatileInfection_Timer + if (VolatileInfection_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_VOLATILEINFECTION); + VolatileInfection_Timer = 32000; + }else VolatileInfection_Timer -= diff; + + //Darkplague_Timer + if (Darkplague_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_DARKPLAGUE); + Darkplague_Timer = 8000; + }else Darkplague_Timer -= diff; + + //CorrosiveAcid_Timer + if (CorrosiveAcid_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_CORROSIVEACID); + CorrosiveAcid_Timer = 25000; + }else CorrosiveAcid_Timer -= diff; + + //NoxiousCatalyst_Timer + if (NoxiousCatalyst_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_NOXIOUSCATALYST); + NoxiousCatalyst_Timer = 38000; + }else NoxiousCatalyst_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; +CreatureAI* GetAI_boss_lorekeeperpolkelt(Creature *_Creature) +{ + return new boss_lorekeeperpolkeltAI (_Creature); +} + +void AddSC_boss_lorekeeperpolkelt() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_lorekeeper_polkelt"; + newscript->GetAI = GetAI_boss_lorekeeperpolkelt; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/scholomance/boss_ras_frostwhisper.cpp b/src/bindings/scripts/scripts/zone/scholomance/boss_ras_frostwhisper.cpp index f8d9e6a66b8..1ee23c92e76 100644 --- a/src/bindings/scripts/scripts/zone/scholomance/boss_ras_frostwhisper.cpp +++ b/src/bindings/scripts/scripts/zone/scholomance/boss_ras_frostwhisper.cpp @@ -1,125 +1,125 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Ras_Frostwhisper -SD%Complete: 100 -SDComment: -SDCategory: Scholomance -EndScriptData */ - -#include "precompiled.h" - -#define SPELL_FROSTBOLT 21369 -#define SPELL_ICEARMOR 18100 //This is actually a buff he gives himself -#define SPELL_FREEZE 18763 -#define SPELL_FEAR 26070 -#define SPELL_CHILLNOVA 18099 -#define SPELL_FROSTVOLLEY 8398 - -struct MANGOS_DLL_DECL boss_rasfrostAI : public ScriptedAI -{ - boss_rasfrostAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 IceArmor_Timer; - uint32 Frostbolt_Timer; - uint32 Freeze_Timer; - uint32 Fear_Timer; - uint32 ChillNova_Timer; - uint32 FrostVolley_Timer; - - void Reset() - { - IceArmor_Timer = 2000; - Frostbolt_Timer = 8000; - ChillNova_Timer = 12000; - Freeze_Timer = 18000; - FrostVolley_Timer = 24000; - Fear_Timer = 45000; - - m_creature->CastSpell(m_creature,SPELL_ICEARMOR,true); - } - - void Aggro(Unit *who) - { - } - - void UpdateAI(const uint32 diff) - { - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - //IceArmor_Timer - if (IceArmor_Timer < diff) - { - DoCast(m_creature, SPELL_ICEARMOR); - IceArmor_Timer = 180000; - }else IceArmor_Timer -= diff; - - //Frostbolt_Timer - if (Frostbolt_Timer < diff) - { - Unit* target = NULL; - target = SelectUnit(SELECT_TARGET_RANDOM,0); - if (target) DoCast(target,SPELL_FROSTBOLT); - - Frostbolt_Timer = 8000; - }else Frostbolt_Timer -= diff; - - //Freeze_Timer - if (Freeze_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_FREEZE); - Freeze_Timer = 24000; - }else Freeze_Timer -= diff; - - //Fear_Timer - if (Fear_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_FEAR); - Fear_Timer = 30000; - }else Fear_Timer -= diff; - - //ChillNova_Timer - if (ChillNova_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_CHILLNOVA); - ChillNova_Timer = 14000; - }else ChillNova_Timer -= diff; - - //FrostVolley_Timer - if (FrostVolley_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_FROSTVOLLEY); - FrostVolley_Timer = 15000; - }else FrostVolley_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; -CreatureAI* GetAI_boss_rasfrost(Creature *_Creature) -{ - return new boss_rasfrostAI (_Creature); -} - -void AddSC_boss_rasfrost() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_boss_ras_frostwhisper"; - newscript->GetAI = GetAI_boss_rasfrost; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Ras_Frostwhisper +SD%Complete: 100 +SDComment: +SDCategory: Scholomance +EndScriptData */ + +#include "precompiled.h" + +#define SPELL_FROSTBOLT 21369 +#define SPELL_ICEARMOR 18100 //This is actually a buff he gives himself +#define SPELL_FREEZE 18763 +#define SPELL_FEAR 26070 +#define SPELL_CHILLNOVA 18099 +#define SPELL_FROSTVOLLEY 8398 + +struct MANGOS_DLL_DECL boss_rasfrostAI : public ScriptedAI +{ + boss_rasfrostAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 IceArmor_Timer; + uint32 Frostbolt_Timer; + uint32 Freeze_Timer; + uint32 Fear_Timer; + uint32 ChillNova_Timer; + uint32 FrostVolley_Timer; + + void Reset() + { + IceArmor_Timer = 2000; + Frostbolt_Timer = 8000; + ChillNova_Timer = 12000; + Freeze_Timer = 18000; + FrostVolley_Timer = 24000; + Fear_Timer = 45000; + + m_creature->CastSpell(m_creature,SPELL_ICEARMOR,true); + } + + void Aggro(Unit *who) + { + } + + void UpdateAI(const uint32 diff) + { + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + //IceArmor_Timer + if (IceArmor_Timer < diff) + { + DoCast(m_creature, SPELL_ICEARMOR); + IceArmor_Timer = 180000; + }else IceArmor_Timer -= diff; + + //Frostbolt_Timer + if (Frostbolt_Timer < diff) + { + Unit* target = NULL; + target = SelectUnit(SELECT_TARGET_RANDOM,0); + if (target) DoCast(target,SPELL_FROSTBOLT); + + Frostbolt_Timer = 8000; + }else Frostbolt_Timer -= diff; + + //Freeze_Timer + if (Freeze_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_FREEZE); + Freeze_Timer = 24000; + }else Freeze_Timer -= diff; + + //Fear_Timer + if (Fear_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_FEAR); + Fear_Timer = 30000; + }else Fear_Timer -= diff; + + //ChillNova_Timer + if (ChillNova_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_CHILLNOVA); + ChillNova_Timer = 14000; + }else ChillNova_Timer -= diff; + + //FrostVolley_Timer + if (FrostVolley_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_FROSTVOLLEY); + FrostVolley_Timer = 15000; + }else FrostVolley_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; +CreatureAI* GetAI_boss_rasfrost(Creature *_Creature) +{ + return new boss_rasfrostAI (_Creature); +} + +void AddSC_boss_rasfrost() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_boss_ras_frostwhisper"; + newscript->GetAI = GetAI_boss_rasfrost; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/scholomance/boss_the_ravenian.cpp b/src/bindings/scripts/scripts/zone/scholomance/boss_the_ravenian.cpp index ae833b8cc1c..b1afb78a56e 100644 --- a/src/bindings/scripts/scripts/zone/scholomance/boss_the_ravenian.cpp +++ b/src/bindings/scripts/scripts/zone/scholomance/boss_the_ravenian.cpp @@ -1,118 +1,118 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_the_ravenian -SD%Complete: 100 -SDComment: -SDCategory: Scholomance -EndScriptData */ - -#include "precompiled.h" -#include "def_scholomance.h" - -#define SPELL_TRAMPLE 15550 -#define SPELL_CLEAVE 20691 -#define SPELL_SUNDERINCLEAVE 25174 -#define SPELL_KNOCKAWAY 10101 - -#define SAY_AGGRO1 "Mine! Mine! Mine! Gizlock is the ruler of this domain! You shall never reveal my presence!" - -struct MANGOS_DLL_DECL boss_theravenianAI : public ScriptedAI -{ - boss_theravenianAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 Trample_Timer; - uint32 Cleave_Timer; - uint32 SunderingCleave_Timer; - uint32 KnockAway_Timer; - bool HasYelled; - - void Reset() - { - Trample_Timer = 24000; - Cleave_Timer = 15000; - SunderingCleave_Timer = 40000; - KnockAway_Timer = 32000; - HasYelled = false; - } - - void JustDied(Unit *killer) - { - ScriptedInstance *pInstance = (m_creature->GetInstanceData()) ? ((ScriptedInstance*)m_creature->GetInstanceData()) : NULL; - if(pInstance) - { - pInstance->SetData(DATA_THERAVENIAN_DEATH, 0); - - if(pInstance->GetData(DATA_CANSPAWNGANDLING)) - m_creature->SummonCreature(1853, 180.73, -9.43856, 75.507, 1.61399, TEMPSUMMON_DEAD_DESPAWN, 0); - } - } - - void Aggro(Unit *who) - { - DoYell(SAY_AGGRO1, LANG_UNIVERSAL, NULL); - } - - void UpdateAI(const uint32 diff) - { - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - //Trample_Timer - if (Trample_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_TRAMPLE); - Trample_Timer = 10000; - }else Trample_Timer -= diff; - - //Cleave_Timer - if (Cleave_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_CLEAVE); - Cleave_Timer = 7000; - }else Cleave_Timer -= diff; - - //SunderingCleave_Timer - if (SunderingCleave_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_SUNDERINCLEAVE); - SunderingCleave_Timer = 20000; - }else SunderingCleave_Timer -= diff; - - //KnockAway_Timer - if (KnockAway_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_KNOCKAWAY); - KnockAway_Timer = 12000; - }else KnockAway_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; -CreatureAI* GetAI_boss_theravenian(Creature *_Creature) -{ - return new boss_theravenianAI (_Creature); -} - -void AddSC_boss_theravenian() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_the_ravenian"; - newscript->GetAI = GetAI_boss_theravenian; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_the_ravenian +SD%Complete: 100 +SDComment: +SDCategory: Scholomance +EndScriptData */ + +#include "precompiled.h" +#include "def_scholomance.h" + +#define SPELL_TRAMPLE 15550 +#define SPELL_CLEAVE 20691 +#define SPELL_SUNDERINCLEAVE 25174 +#define SPELL_KNOCKAWAY 10101 + +#define SAY_AGGRO1 "Mine! Mine! Mine! Gizlock is the ruler of this domain! You shall never reveal my presence!" + +struct MANGOS_DLL_DECL boss_theravenianAI : public ScriptedAI +{ + boss_theravenianAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 Trample_Timer; + uint32 Cleave_Timer; + uint32 SunderingCleave_Timer; + uint32 KnockAway_Timer; + bool HasYelled; + + void Reset() + { + Trample_Timer = 24000; + Cleave_Timer = 15000; + SunderingCleave_Timer = 40000; + KnockAway_Timer = 32000; + HasYelled = false; + } + + void JustDied(Unit *killer) + { + ScriptedInstance *pInstance = (m_creature->GetInstanceData()) ? ((ScriptedInstance*)m_creature->GetInstanceData()) : NULL; + if(pInstance) + { + pInstance->SetData(DATA_THERAVENIAN_DEATH, 0); + + if(pInstance->GetData(DATA_CANSPAWNGANDLING)) + m_creature->SummonCreature(1853, 180.73, -9.43856, 75.507, 1.61399, TEMPSUMMON_DEAD_DESPAWN, 0); + } + } + + void Aggro(Unit *who) + { + DoYell(SAY_AGGRO1, LANG_UNIVERSAL, NULL); + } + + void UpdateAI(const uint32 diff) + { + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + //Trample_Timer + if (Trample_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_TRAMPLE); + Trample_Timer = 10000; + }else Trample_Timer -= diff; + + //Cleave_Timer + if (Cleave_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_CLEAVE); + Cleave_Timer = 7000; + }else Cleave_Timer -= diff; + + //SunderingCleave_Timer + if (SunderingCleave_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_SUNDERINCLEAVE); + SunderingCleave_Timer = 20000; + }else SunderingCleave_Timer -= diff; + + //KnockAway_Timer + if (KnockAway_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_KNOCKAWAY); + KnockAway_Timer = 12000; + }else KnockAway_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; +CreatureAI* GetAI_boss_theravenian(Creature *_Creature) +{ + return new boss_theravenianAI (_Creature); +} + +void AddSC_boss_theravenian() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_the_ravenian"; + newscript->GetAI = GetAI_boss_theravenian; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/scholomance/boss_vectus.cpp b/src/bindings/scripts/scripts/zone/scholomance/boss_vectus.cpp index d6808efaf8a..91c57763d09 100644 --- a/src/bindings/scripts/scripts/zone/scholomance/boss_vectus.cpp +++ b/src/bindings/scripts/scripts/zone/scholomance/boss_vectus.cpp @@ -1,95 +1,95 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Vectus -SD%Complete: 100 -SDComment: -SDCategory: Scholomance -EndScriptData */ - -#include "precompiled.h" - -#define SPELL_FIRESHIELD 19626 -#define SPELL_BLASTWAVE 13021 -#define SPELL_FRENZY 28371 - -struct MANGOS_DLL_DECL boss_vectusAI : public ScriptedAI -{ - boss_vectusAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 FireShield_Timer; - uint32 BlastWave_Timer; - uint32 Frenzy_Timer; - - void Reset() - { - FireShield_Timer = 2000; - BlastWave_Timer = 14000; - Frenzy_Timer = 0; - } - - void Aggro(Unit *who) - { - } - - void UpdateAI(const uint32 diff) - { - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - //FireShield_Timer - if (FireShield_Timer < diff) - { - DoCast(m_creature, SPELL_FIRESHIELD); - FireShield_Timer = 90000; - }else FireShield_Timer -= diff; - - //BlastWave_Timer - if (BlastWave_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_BLASTWAVE); - BlastWave_Timer = 12000; - }else BlastWave_Timer -= diff; - - //Frenzy_Timer - if ( m_creature->GetHealth()*100 / m_creature->GetMaxHealth() < 25 ) - { - if (Frenzy_Timer < diff) - { - DoCast(m_creature,SPELL_FRENZY); - DoTextEmote("goes into a killing frenzy!",NULL); - - Frenzy_Timer = 24000; - }else Frenzy_Timer -= diff; - } - - DoMeleeAttackIfReady(); - } -}; -CreatureAI* GetAI_boss_vectus(Creature *_Creature) -{ - return new boss_vectusAI (_Creature); -} - -void AddSC_boss_vectus() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_vectus"; - newscript->GetAI = GetAI_boss_vectus; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Vectus +SD%Complete: 100 +SDComment: +SDCategory: Scholomance +EndScriptData */ + +#include "precompiled.h" + +#define SPELL_FIRESHIELD 19626 +#define SPELL_BLASTWAVE 13021 +#define SPELL_FRENZY 28371 + +struct MANGOS_DLL_DECL boss_vectusAI : public ScriptedAI +{ + boss_vectusAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 FireShield_Timer; + uint32 BlastWave_Timer; + uint32 Frenzy_Timer; + + void Reset() + { + FireShield_Timer = 2000; + BlastWave_Timer = 14000; + Frenzy_Timer = 0; + } + + void Aggro(Unit *who) + { + } + + void UpdateAI(const uint32 diff) + { + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + //FireShield_Timer + if (FireShield_Timer < diff) + { + DoCast(m_creature, SPELL_FIRESHIELD); + FireShield_Timer = 90000; + }else FireShield_Timer -= diff; + + //BlastWave_Timer + if (BlastWave_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_BLASTWAVE); + BlastWave_Timer = 12000; + }else BlastWave_Timer -= diff; + + //Frenzy_Timer + if ( m_creature->GetHealth()*100 / m_creature->GetMaxHealth() < 25 ) + { + if (Frenzy_Timer < diff) + { + DoCast(m_creature,SPELL_FRENZY); + DoTextEmote("goes into a killing frenzy!",NULL); + + Frenzy_Timer = 24000; + }else Frenzy_Timer -= diff; + } + + DoMeleeAttackIfReady(); + } +}; +CreatureAI* GetAI_boss_vectus(Creature *_Creature) +{ + return new boss_vectusAI (_Creature); +} + +void AddSC_boss_vectus() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_vectus"; + newscript->GetAI = GetAI_boss_vectus; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/scholomance/def_scholomance.h b/src/bindings/scripts/scripts/zone/scholomance/def_scholomance.h index a4023315e01..cbeab113b85 100644 --- a/src/bindings/scripts/scripts/zone/scholomance/def_scholomance.h +++ b/src/bindings/scripts/scripts/zone/scholomance/def_scholomance.h @@ -1,15 +1,15 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software licensed under GPL version 2 - * Please see the included DOCS/LICENSE.TXT for more information */ - -#ifndef DEF_SCHOLOMANCE_H -#define DEF_SCHOLOMANCE_H - -#define DATA_CANSPAWNGANDLING 1 -#define DATA_DOCTORTHEOLENKRASTINOV_DEATH 2 -#define DATA_INSTRUCTORMALICIA_DEATH 3 -#define DATA_LADYILLUCIABAROV_DEATH 4 -#define DATA_LORDALEXEIBAROV_DEATH 5 -#define DATA_LOREKEEPERPOLKELT_DEATH 6 -#define DATA_THERAVENIAN_DEATH 7 -#endif +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software licensed under GPL version 2 + * Please see the included DOCS/LICENSE.TXT for more information */ + +#ifndef DEF_SCHOLOMANCE_H +#define DEF_SCHOLOMANCE_H + +#define DATA_CANSPAWNGANDLING 1 +#define DATA_DOCTORTHEOLENKRASTINOV_DEATH 2 +#define DATA_INSTRUCTORMALICIA_DEATH 3 +#define DATA_LADYILLUCIABAROV_DEATH 4 +#define DATA_LORDALEXEIBAROV_DEATH 5 +#define DATA_LOREKEEPERPOLKELT_DEATH 6 +#define DATA_THERAVENIAN_DEATH 7 +#endif diff --git a/src/bindings/scripts/scripts/zone/scholomance/instance_scholomance.cpp b/src/bindings/scripts/scripts/zone/scholomance/instance_scholomance.cpp index 7084635493c..c8e6f17f8c0 100644 --- a/src/bindings/scripts/scripts/zone/scholomance/instance_scholomance.cpp +++ b/src/bindings/scripts/scripts/zone/scholomance/instance_scholomance.cpp @@ -1,102 +1,102 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Instance_Scholomance -SD%Complete: 100 -SDComment: -SDCategory: Scholomance -EndScriptData */ - -#include "precompiled.h" -#include "def_scholomance.h" - -struct MANGOS_DLL_DECL instance_scholomance : public ScriptedInstance -{ - instance_scholomance(Map *Map) : ScriptedInstance(Map) {Initialize();}; - - //Lord Alexei Barov, Doctor Theolen Krastinov, The Ravenian, Lorekeeper Polkelt, Instructor Malicia and the Lady Illucia Barov. - bool IsBossDied[6]; - - void Initialize() - { - IsBossDied[0] = false; - IsBossDied[1] = false; - IsBossDied[2] = false; - IsBossDied[3] = false; - IsBossDied[4] = false; - IsBossDied[5] = false; - } - - bool IsEncounterInProgress() const - { - //not active in scholomance - return false; - } - - uint32 GetData(uint32 type) - { - if(type == DATA_CANSPAWNGANDLING) - if(IsBossDied[0] && IsBossDied[1] && IsBossDied[2] && IsBossDied[3] && IsBossDied[4] && IsBossDied[5]) - return 1; - - return 0; - } - - void SetData(uint32 type, uint32 data) - { - switch(type) - { - case DATA_LORDALEXEIBAROV_DEATH: - IsBossDied[0] = true; - break; - - case DATA_DOCTORTHEOLENKRASTINOV_DEATH: - IsBossDied[1] = true; - break; - - case DATA_THERAVENIAN_DEATH: - IsBossDied[2] = true; - break; - - case DATA_LOREKEEPERPOLKELT_DEATH: - IsBossDied[3] = true; - break; - - case DATA_INSTRUCTORMALICIA_DEATH: - IsBossDied[4] = true; - break; - - case DATA_LADYILLUCIABAROV_DEATH: - IsBossDied[5] = true; - break; - } - } -}; - -InstanceData* GetInstanceData_instance_scholomance(Map* map) -{ - return new instance_scholomance(map); -} - -void AddSC_instance_scholomance() -{ - Script *newscript; - newscript = new Script; - newscript->Name = "instance_scholomance"; - newscript->GetInstanceData = GetInstanceData_instance_scholomance; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Instance_Scholomance +SD%Complete: 100 +SDComment: +SDCategory: Scholomance +EndScriptData */ + +#include "precompiled.h" +#include "def_scholomance.h" + +struct MANGOS_DLL_DECL instance_scholomance : public ScriptedInstance +{ + instance_scholomance(Map *Map) : ScriptedInstance(Map) {Initialize();}; + + //Lord Alexei Barov, Doctor Theolen Krastinov, The Ravenian, Lorekeeper Polkelt, Instructor Malicia and the Lady Illucia Barov. + bool IsBossDied[6]; + + void Initialize() + { + IsBossDied[0] = false; + IsBossDied[1] = false; + IsBossDied[2] = false; + IsBossDied[3] = false; + IsBossDied[4] = false; + IsBossDied[5] = false; + } + + bool IsEncounterInProgress() const + { + //not active in scholomance + return false; + } + + uint32 GetData(uint32 type) + { + if(type == DATA_CANSPAWNGANDLING) + if(IsBossDied[0] && IsBossDied[1] && IsBossDied[2] && IsBossDied[3] && IsBossDied[4] && IsBossDied[5]) + return 1; + + return 0; + } + + void SetData(uint32 type, uint32 data) + { + switch(type) + { + case DATA_LORDALEXEIBAROV_DEATH: + IsBossDied[0] = true; + break; + + case DATA_DOCTORTHEOLENKRASTINOV_DEATH: + IsBossDied[1] = true; + break; + + case DATA_THERAVENIAN_DEATH: + IsBossDied[2] = true; + break; + + case DATA_LOREKEEPERPOLKELT_DEATH: + IsBossDied[3] = true; + break; + + case DATA_INSTRUCTORMALICIA_DEATH: + IsBossDied[4] = true; + break; + + case DATA_LADYILLUCIABAROV_DEATH: + IsBossDied[5] = true; + break; + } + } +}; + +InstanceData* GetInstanceData_instance_scholomance(Map* map) +{ + return new instance_scholomance(map); +} + +void AddSC_instance_scholomance() +{ + Script *newscript; + newscript = new Script; + newscript->Name = "instance_scholomance"; + newscript->GetInstanceData = GetInstanceData_instance_scholomance; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/searing_gorge/searing_gorge.cpp b/src/bindings/scripts/scripts/zone/searing_gorge/searing_gorge.cpp index 6834cd8a078..4d2264f8fd7 100644 --- a/src/bindings/scripts/scripts/zone/searing_gorge/searing_gorge.cpp +++ b/src/bindings/scripts/scripts/zone/searing_gorge/searing_gorge.cpp @@ -1,159 +1,159 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Searing_Gorge -SD%Complete: 80 -SDComment: Quest support: 3377, 3441 (More accurate info on Kalaran needed). Lothos Riftwaker teleport to Molten Core. -SDCategory: Searing Gorge -EndScriptData */ - -/* ContentData -npc_kalaran_windblade -npc_lothos_riftwaker -npc_zamael_lunthistle -EndContentData */ - -#include "precompiled.h" - -/*###### -## npc_kalaran_windblade -######*/ - -bool GossipHello_npc_kalaran_windblade(Player *player, Creature *_Creature) -{ - if (_Creature->isQuestGiver()) - player->PrepareQuestMenu( _Creature->GetGUID() ); - - if (player->GetQuestStatus(3441) == QUEST_STATUS_INCOMPLETE) - player->ADD_GOSSIP_ITEM( 0, "Tell me what drives this vengance?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF); - - player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); - - return true; -} - -bool GossipSelect_npc_kalaran_windblade(Player *player, Creature *_Creature, uint32 sender, uint32 action) -{ - switch (action) - { - case GOSSIP_ACTION_INFO_DEF: - player->ADD_GOSSIP_ITEM( 0, "Continue please", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); - player->SEND_GOSSIP_MENU(1954, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+1: - player->ADD_GOSSIP_ITEM( 0, "Let me confer with my colleagues", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2); - player->SEND_GOSSIP_MENU(1955, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+2: - player->CLOSE_GOSSIP_MENU(); - player->AreaExploredOrEventHappens(3441); - break; - } - return true; -} - -/*###### -## npc_lothos_riftwaker -######*/ - -bool GossipHello_npc_lothos_riftwaker(Player *player, Creature *_Creature) -{ - if (_Creature->isQuestGiver()) - player->PrepareQuestMenu( _Creature->GetGUID() ); - - if (player->GetQuestRewardStatus(7487) || player->GetQuestRewardStatus(7848)) - player->ADD_GOSSIP_ITEM(0, "Teleport me to the Molten Core", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); - - player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); - - return true; -} - -bool GossipSelect_npc_lothos_riftwaker(Player *player, Creature *_Creature, uint32 sender, uint32 action ) -{ - if (action == GOSSIP_ACTION_INFO_DEF + 1) - { - player->CLOSE_GOSSIP_MENU(); - player->TeleportTo(409, 1096, -467, -104.6, 3.64); - } - - return true; -} - -/*###### -## npc_zamael_lunthistle -######*/ - -bool GossipHello_npc_zamael_lunthistle(Player *player, Creature *_Creature) -{ - if (_Creature->isQuestGiver()) - player->PrepareQuestMenu( _Creature->GetGUID() ); - - if (player->GetQuestStatus(3377) == QUEST_STATUS_INCOMPLETE) - player->ADD_GOSSIP_ITEM( 0, "Tell me your story", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF); - - player->SEND_GOSSIP_MENU(1920, _Creature->GetGUID()); - - return true; -} - -bool GossipSelect_npc_zamael_lunthistle(Player *player, Creature *_Creature, uint32 sender, uint32 action) -{ - switch (action) - { - case GOSSIP_ACTION_INFO_DEF: - player->ADD_GOSSIP_ITEM( 0, "Please continue...", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); - player->SEND_GOSSIP_MENU(1921, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+1: - player->ADD_GOSSIP_ITEM( 0, "Goodbye", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2); - player->SEND_GOSSIP_MENU(1922, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+2: - player->CLOSE_GOSSIP_MENU(); - player->AreaExploredOrEventHappens(3377); - break; - } - return true; -} - -/*###### -## -######*/ - -void AddSC_searing_gorge() -{ - Script *newscript; - - newscript = new Script; - newscript->Name="npc_kalaran_windblade"; - newscript->pGossipHello = &GossipHello_npc_kalaran_windblade; - newscript->pGossipSelect = &GossipSelect_npc_kalaran_windblade; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="npc_lothos_riftwaker"; - newscript->pGossipHello = &GossipHello_npc_lothos_riftwaker; - newscript->pGossipSelect = &GossipSelect_npc_lothos_riftwaker; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="npc_zamael_lunthistle"; - newscript->pGossipHello = &GossipHello_npc_zamael_lunthistle; - newscript->pGossipSelect = &GossipSelect_npc_zamael_lunthistle; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Searing_Gorge +SD%Complete: 80 +SDComment: Quest support: 3377, 3441 (More accurate info on Kalaran needed). Lothos Riftwaker teleport to Molten Core. +SDCategory: Searing Gorge +EndScriptData */ + +/* ContentData +npc_kalaran_windblade +npc_lothos_riftwaker +npc_zamael_lunthistle +EndContentData */ + +#include "precompiled.h" + +/*###### +## npc_kalaran_windblade +######*/ + +bool GossipHello_npc_kalaran_windblade(Player *player, Creature *_Creature) +{ + if (_Creature->isQuestGiver()) + player->PrepareQuestMenu( _Creature->GetGUID() ); + + if (player->GetQuestStatus(3441) == QUEST_STATUS_INCOMPLETE) + player->ADD_GOSSIP_ITEM( 0, "Tell me what drives this vengance?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF); + + player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); + + return true; +} + +bool GossipSelect_npc_kalaran_windblade(Player *player, Creature *_Creature, uint32 sender, uint32 action) +{ + switch (action) + { + case GOSSIP_ACTION_INFO_DEF: + player->ADD_GOSSIP_ITEM( 0, "Continue please", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); + player->SEND_GOSSIP_MENU(1954, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+1: + player->ADD_GOSSIP_ITEM( 0, "Let me confer with my colleagues", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2); + player->SEND_GOSSIP_MENU(1955, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+2: + player->CLOSE_GOSSIP_MENU(); + player->AreaExploredOrEventHappens(3441); + break; + } + return true; +} + +/*###### +## npc_lothos_riftwaker +######*/ + +bool GossipHello_npc_lothos_riftwaker(Player *player, Creature *_Creature) +{ + if (_Creature->isQuestGiver()) + player->PrepareQuestMenu( _Creature->GetGUID() ); + + if (player->GetQuestRewardStatus(7487) || player->GetQuestRewardStatus(7848)) + player->ADD_GOSSIP_ITEM(0, "Teleport me to the Molten Core", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); + + player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); + + return true; +} + +bool GossipSelect_npc_lothos_riftwaker(Player *player, Creature *_Creature, uint32 sender, uint32 action ) +{ + if (action == GOSSIP_ACTION_INFO_DEF + 1) + { + player->CLOSE_GOSSIP_MENU(); + player->TeleportTo(409, 1096, -467, -104.6, 3.64); + } + + return true; +} + +/*###### +## npc_zamael_lunthistle +######*/ + +bool GossipHello_npc_zamael_lunthistle(Player *player, Creature *_Creature) +{ + if (_Creature->isQuestGiver()) + player->PrepareQuestMenu( _Creature->GetGUID() ); + + if (player->GetQuestStatus(3377) == QUEST_STATUS_INCOMPLETE) + player->ADD_GOSSIP_ITEM( 0, "Tell me your story", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF); + + player->SEND_GOSSIP_MENU(1920, _Creature->GetGUID()); + + return true; +} + +bool GossipSelect_npc_zamael_lunthistle(Player *player, Creature *_Creature, uint32 sender, uint32 action) +{ + switch (action) + { + case GOSSIP_ACTION_INFO_DEF: + player->ADD_GOSSIP_ITEM( 0, "Please continue...", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); + player->SEND_GOSSIP_MENU(1921, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+1: + player->ADD_GOSSIP_ITEM( 0, "Goodbye", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2); + player->SEND_GOSSIP_MENU(1922, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+2: + player->CLOSE_GOSSIP_MENU(); + player->AreaExploredOrEventHappens(3377); + break; + } + return true; +} + +/*###### +## +######*/ + +void AddSC_searing_gorge() +{ + Script *newscript; + + newscript = new Script; + newscript->Name="npc_kalaran_windblade"; + newscript->pGossipHello = &GossipHello_npc_kalaran_windblade; + newscript->pGossipSelect = &GossipSelect_npc_kalaran_windblade; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="npc_lothos_riftwaker"; + newscript->pGossipHello = &GossipHello_npc_lothos_riftwaker; + newscript->pGossipSelect = &GossipSelect_npc_lothos_riftwaker; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="npc_zamael_lunthistle"; + newscript->pGossipHello = &GossipHello_npc_zamael_lunthistle; + newscript->pGossipSelect = &GossipSelect_npc_zamael_lunthistle; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/shadowfang_keep/def_shadowfang_keep.h b/src/bindings/scripts/scripts/zone/shadowfang_keep/def_shadowfang_keep.h index 7ece07f0231..b49e7623257 100644 --- a/src/bindings/scripts/scripts/zone/shadowfang_keep/def_shadowfang_keep.h +++ b/src/bindings/scripts/scripts/zone/shadowfang_keep/def_shadowfang_keep.h @@ -1,12 +1,12 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software licensed under GPL version 2 - * Please see the included DOCS/LICENSE.TXT for more information */ - -#ifndef DEF_SHADOWFANG_H -#define DEF_SHADOWFANG_H - -#define TYPE_FREE_NPC 1 -#define TYPE_RETHILGORE 2 -#define TYPE_FENRUS 3 -#define TYPE_NANDOS 4 -#endif +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software licensed under GPL version 2 + * Please see the included DOCS/LICENSE.TXT for more information */ + +#ifndef DEF_SHADOWFANG_H +#define DEF_SHADOWFANG_H + +#define TYPE_FREE_NPC 1 +#define TYPE_RETHILGORE 2 +#define TYPE_FENRUS 3 +#define TYPE_NANDOS 4 +#endif diff --git a/src/bindings/scripts/scripts/zone/shadowfang_keep/instance_shadowfang_keep.cpp b/src/bindings/scripts/scripts/zone/shadowfang_keep/instance_shadowfang_keep.cpp index 5e4ce0b3267..8051d3dd57f 100644 --- a/src/bindings/scripts/scripts/zone/shadowfang_keep/instance_shadowfang_keep.cpp +++ b/src/bindings/scripts/scripts/zone/shadowfang_keep/instance_shadowfang_keep.cpp @@ -1,152 +1,152 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Instance_Shadowfang_Keep -SD%Complete: 75 -SDComment: TODO: check what other parts would require additional code (ex: make sure door are in open state if boss dead) -SDCategory: Shadowfang Keep -EndScriptData */ - -#include "precompiled.h" -#include "def_shadowfang_keep.h" - -#define ENCOUNTERS 4 - -//#define ENTRY_BOSS_RETHILGORE 3914 -//#define ENTRY_BOSS_FENRUS 4274 -//#define ENTRY_BOSS_NANDOS 3927 - -#define ENTRY_COURTYARD_DOOR 18895 //door to open when talking to NPC's -#define ENTRY_SORCERER_DOOR 18972 //door to open when Fenrus the Devourer -#define ENTRY_ARUGAL_DOOR 18971 //door to open when Wolf Master Nandos - -struct MANGOS_DLL_DECL instance_shadowfang_keep : public ScriptedInstance -{ - instance_shadowfang_keep(Map *Map) : ScriptedInstance(Map) {Initialize();}; - - uint32 Encounter[ENCOUNTERS]; - - /*uint64 RethilgoreGUID; - uint64 FenrusGUID; - uint64 NandosGUID;*/ - - GameObject *DoorCourtyard; - GameObject *DoorSorcerer; - GameObject *DoorArugal; - - void Initialize() - { - /*RethilgoreGUID = 0; - FenrusGUID = 0; - NandosGUID = 0;*/ - - DoorCourtyard = NULL; - DoorSorcerer = NULL; - DoorArugal = NULL; - } - - void OnObjectCreate(GameObject *go) - { - switch(go->GetEntry()) - { - case ENTRY_COURTYARD_DOOR: DoorCourtyard = go; break; - case ENTRY_SORCERER_DOOR: DoorSorcerer = go; break; - case ENTRY_ARUGAL_DOOR: DoorArugal = go; break; - } - } - - /*void OnCreatureCreate(Creature *creature, uint32 creature_entry) - { - switch(creature_entry) - { - case ENTRY_BOSS_RETHILGORE: - RethilgoreGUID = creature->GetGUID(); - break; - case ENTRY_BOSS_FENRUS: - FenrusGUID = creature->GetGUID(); - break; - case ENTRY_BOSS_NANDOS: - NandosGUID = creature->GetGUID(); - break; - } - }*/ - - void SetData(uint32 type, uint32 data) - { - switch(type) - { - case TYPE_FREE_NPC: - if(data == DONE) - { - if(DoorCourtyard) - DoorCourtyard->UseDoorOrButton(); - } - Encounter[0] = data; - break; - case TYPE_RETHILGORE: - Encounter[1] = data; - break; - case TYPE_FENRUS: - if(data == DONE) - { - if(DoorSorcerer) - DoorSorcerer->UseDoorOrButton(); - } - Encounter[2] = data; - break; - case TYPE_NANDOS: - if(data == DONE) - { - if(DoorArugal) - DoorArugal->UseDoorOrButton(); - } - Encounter[3] = data; - break; - } - } - - uint32 GetData(uint32 type) - { - switch(type) - { - case TYPE_FREE_NPC: - return Encounter[0]; - case TYPE_RETHILGORE: - return Encounter[1]; - case TYPE_FENRUS: - return Encounter[2]; - case TYPE_NANDOS: - return Encounter[3]; - } - return 0; - } - -}; - -InstanceData* GetInstanceData_instance_shadowfang_keep(Map* map) -{ - return new instance_shadowfang_keep(map); -} - -void AddSC_instance_shadowfang_keep() -{ - Script *newscript; - newscript = new Script; - newscript->Name = "instance_shadowfang_keep"; - newscript->GetInstanceData = GetInstanceData_instance_shadowfang_keep; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Instance_Shadowfang_Keep +SD%Complete: 75 +SDComment: TODO: check what other parts would require additional code (ex: make sure door are in open state if boss dead) +SDCategory: Shadowfang Keep +EndScriptData */ + +#include "precompiled.h" +#include "def_shadowfang_keep.h" + +#define ENCOUNTERS 4 + +//#define ENTRY_BOSS_RETHILGORE 3914 +//#define ENTRY_BOSS_FENRUS 4274 +//#define ENTRY_BOSS_NANDOS 3927 + +#define ENTRY_COURTYARD_DOOR 18895 //door to open when talking to NPC's +#define ENTRY_SORCERER_DOOR 18972 //door to open when Fenrus the Devourer +#define ENTRY_ARUGAL_DOOR 18971 //door to open when Wolf Master Nandos + +struct MANGOS_DLL_DECL instance_shadowfang_keep : public ScriptedInstance +{ + instance_shadowfang_keep(Map *Map) : ScriptedInstance(Map) {Initialize();}; + + uint32 Encounter[ENCOUNTERS]; + + /*uint64 RethilgoreGUID; + uint64 FenrusGUID; + uint64 NandosGUID;*/ + + GameObject *DoorCourtyard; + GameObject *DoorSorcerer; + GameObject *DoorArugal; + + void Initialize() + { + /*RethilgoreGUID = 0; + FenrusGUID = 0; + NandosGUID = 0;*/ + + DoorCourtyard = NULL; + DoorSorcerer = NULL; + DoorArugal = NULL; + } + + void OnObjectCreate(GameObject *go) + { + switch(go->GetEntry()) + { + case ENTRY_COURTYARD_DOOR: DoorCourtyard = go; break; + case ENTRY_SORCERER_DOOR: DoorSorcerer = go; break; + case ENTRY_ARUGAL_DOOR: DoorArugal = go; break; + } + } + + /*void OnCreatureCreate(Creature *creature, uint32 creature_entry) + { + switch(creature_entry) + { + case ENTRY_BOSS_RETHILGORE: + RethilgoreGUID = creature->GetGUID(); + break; + case ENTRY_BOSS_FENRUS: + FenrusGUID = creature->GetGUID(); + break; + case ENTRY_BOSS_NANDOS: + NandosGUID = creature->GetGUID(); + break; + } + }*/ + + void SetData(uint32 type, uint32 data) + { + switch(type) + { + case TYPE_FREE_NPC: + if(data == DONE) + { + if(DoorCourtyard) + DoorCourtyard->UseDoorOrButton(); + } + Encounter[0] = data; + break; + case TYPE_RETHILGORE: + Encounter[1] = data; + break; + case TYPE_FENRUS: + if(data == DONE) + { + if(DoorSorcerer) + DoorSorcerer->UseDoorOrButton(); + } + Encounter[2] = data; + break; + case TYPE_NANDOS: + if(data == DONE) + { + if(DoorArugal) + DoorArugal->UseDoorOrButton(); + } + Encounter[3] = data; + break; + } + } + + uint32 GetData(uint32 type) + { + switch(type) + { + case TYPE_FREE_NPC: + return Encounter[0]; + case TYPE_RETHILGORE: + return Encounter[1]; + case TYPE_FENRUS: + return Encounter[2]; + case TYPE_NANDOS: + return Encounter[3]; + } + return 0; + } + +}; + +InstanceData* GetInstanceData_instance_shadowfang_keep(Map* map) +{ + return new instance_shadowfang_keep(map); +} + +void AddSC_instance_shadowfang_keep() +{ + Script *newscript; + newscript = new Script; + newscript->Name = "instance_shadowfang_keep"; + newscript->GetInstanceData = GetInstanceData_instance_shadowfang_keep; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/shadowfang_keep/shadowfang_keep.cpp b/src/bindings/scripts/scripts/zone/shadowfang_keep/shadowfang_keep.cpp index 172a0907a79..587986c6556 100644 --- a/src/bindings/scripts/scripts/zone/shadowfang_keep/shadowfang_keep.cpp +++ b/src/bindings/scripts/scripts/zone/shadowfang_keep/shadowfang_keep.cpp @@ -1,117 +1,117 @@ -/* Copyright (C) 2006,2007 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Shadowfang_Keep -SD%Complete: 75 -SDComment: npc_shadowfang_prisoner using escortAI for movement to door. Might need additional code in case being attacked. Add proper texts/say(). -SDCategory: Shadowfang Keep -EndScriptData */ - -/* ContentData -npc_shadowfang_prisoner -EndContentData */ - -#include "precompiled.h" -#include "../../npc/npc_escortAI.h" -#include "def_shadowfang_keep.h" - -/*###### -## npc_shadowfang_prisoner -######*/ - -struct MANGOS_DLL_DECL npc_shadowfang_prisonerAI : public npc_escortAI -{ - npc_shadowfang_prisonerAI(Creature *c) : npc_escortAI(c) - { - pInstance = ((ScriptedInstance*)c->GetInstanceData()); - Reset(); - } - - ScriptedInstance *pInstance; - - void WaypointReached(uint32 i) - { - if( pInstance && i == 6) - { - m_creature->HandleEmoteCommand(EMOTE_ONESHOT_TALK); - m_creature->Say("Thanks for freeing me, I'll open this door for you, then I will get out of here.", LANG_UNIVERSAL, 0); - pInstance->SetData(TYPE_FREE_NPC, DONE); - } - } - - void Reset() {} - void Aggro(Unit* who) {} -}; - -CreatureAI* GetAI_npc_shadowfang_prisoner(Creature *_Creature) -{ - npc_shadowfang_prisonerAI* prisonerAI = new npc_shadowfang_prisonerAI(_Creature); - - uint32 eCreature = _Creature->GetEntry(); - - if( eCreature==3849) //adamant - prisonerAI->AddWaypoint(0, -254.47, 2117.48, 81.17); - if( eCreature==3850) //ashcrombe - prisonerAI->AddWaypoint(0, -252.35, 2126.71, 81.17); - - prisonerAI->AddWaypoint(1, -253.63, 2131.27, 81.28); - prisonerAI->AddWaypoint(2, -249.66, 2142.45, 87.01); - prisonerAI->AddWaypoint(3, -248.08, 2143.68, 87.01); - prisonerAI->AddWaypoint(4, -238.87, 2139.93, 87.01); - prisonerAI->AddWaypoint(5, -235.47, 2149.18, 90.59); - prisonerAI->AddWaypoint(6, -239.89, 2156.06, 90.62, 20000); - - return (CreatureAI*)prisonerAI; -} - -bool GossipHello_npc_shadowfang_prisoner(Player *player, Creature *_Creature) -{ - ScriptedInstance* pInstance = ((ScriptedInstance*)_Creature->GetInstanceData()); - - if( pInstance && !pInstance->GetData(TYPE_FREE_NPC) && pInstance->GetData(TYPE_RETHILGORE) == DONE ) - player->ADD_GOSSIP_ITEM( 0, "Thanks, I'll follow you to the door.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); - - player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); - - return true; -} - -bool GossipSelect_npc_shadowfang_prisoner(Player *player, Creature *_Creature, uint32 sender, uint32 action) -{ - if (action == GOSSIP_ACTION_INFO_DEF+1) - { - player->CLOSE_GOSSIP_MENU(); - ((npc_escortAI*)(_Creature->AI()))->Start(false, false, false, player->GetGUID()); - } - return true; -} - -/*###### -## AddSC -######*/ - -void AddSC_shadowfang_keep() -{ - Script *newscript; - - newscript = new Script; - newscript->Name="npc_shadowfang_prisoner"; - newscript->pGossipHello = &GossipHello_npc_shadowfang_prisoner; - newscript->pGossipSelect = &GossipSelect_npc_shadowfang_prisoner; - newscript->GetAI = GetAI_npc_shadowfang_prisoner; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006,2007 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Shadowfang_Keep +SD%Complete: 75 +SDComment: npc_shadowfang_prisoner using escortAI for movement to door. Might need additional code in case being attacked. Add proper texts/say(). +SDCategory: Shadowfang Keep +EndScriptData */ + +/* ContentData +npc_shadowfang_prisoner +EndContentData */ + +#include "precompiled.h" +#include "../../npc/npc_escortAI.h" +#include "def_shadowfang_keep.h" + +/*###### +## npc_shadowfang_prisoner +######*/ + +struct MANGOS_DLL_DECL npc_shadowfang_prisonerAI : public npc_escortAI +{ + npc_shadowfang_prisonerAI(Creature *c) : npc_escortAI(c) + { + pInstance = ((ScriptedInstance*)c->GetInstanceData()); + Reset(); + } + + ScriptedInstance *pInstance; + + void WaypointReached(uint32 i) + { + if( pInstance && i == 6) + { + m_creature->HandleEmoteCommand(EMOTE_ONESHOT_TALK); + m_creature->Say("Thanks for freeing me, I'll open this door for you, then I will get out of here.", LANG_UNIVERSAL, 0); + pInstance->SetData(TYPE_FREE_NPC, DONE); + } + } + + void Reset() {} + void Aggro(Unit* who) {} +}; + +CreatureAI* GetAI_npc_shadowfang_prisoner(Creature *_Creature) +{ + npc_shadowfang_prisonerAI* prisonerAI = new npc_shadowfang_prisonerAI(_Creature); + + uint32 eCreature = _Creature->GetEntry(); + + if( eCreature==3849) //adamant + prisonerAI->AddWaypoint(0, -254.47, 2117.48, 81.17); + if( eCreature==3850) //ashcrombe + prisonerAI->AddWaypoint(0, -252.35, 2126.71, 81.17); + + prisonerAI->AddWaypoint(1, -253.63, 2131.27, 81.28); + prisonerAI->AddWaypoint(2, -249.66, 2142.45, 87.01); + prisonerAI->AddWaypoint(3, -248.08, 2143.68, 87.01); + prisonerAI->AddWaypoint(4, -238.87, 2139.93, 87.01); + prisonerAI->AddWaypoint(5, -235.47, 2149.18, 90.59); + prisonerAI->AddWaypoint(6, -239.89, 2156.06, 90.62, 20000); + + return (CreatureAI*)prisonerAI; +} + +bool GossipHello_npc_shadowfang_prisoner(Player *player, Creature *_Creature) +{ + ScriptedInstance* pInstance = ((ScriptedInstance*)_Creature->GetInstanceData()); + + if( pInstance && !pInstance->GetData(TYPE_FREE_NPC) && pInstance->GetData(TYPE_RETHILGORE) == DONE ) + player->ADD_GOSSIP_ITEM( 0, "Thanks, I'll follow you to the door.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); + + player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); + + return true; +} + +bool GossipSelect_npc_shadowfang_prisoner(Player *player, Creature *_Creature, uint32 sender, uint32 action) +{ + if (action == GOSSIP_ACTION_INFO_DEF+1) + { + player->CLOSE_GOSSIP_MENU(); + ((npc_escortAI*)(_Creature->AI()))->Start(false, false, false, player->GetGUID()); + } + return true; +} + +/*###### +## AddSC +######*/ + +void AddSC_shadowfang_keep() +{ + Script *newscript; + + newscript = new Script; + newscript->Name="npc_shadowfang_prisoner"; + newscript->pGossipHello = &GossipHello_npc_shadowfang_prisoner; + newscript->pGossipSelect = &GossipSelect_npc_shadowfang_prisoner; + newscript->GetAI = GetAI_npc_shadowfang_prisoner; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/shadowmoon_valley/boss_doomwalker.cpp b/src/bindings/scripts/scripts/zone/shadowmoon_valley/boss_doomwalker.cpp index 1960d9f9cc1..fdfac7f9ece 100644 --- a/src/bindings/scripts/scripts/zone/shadowmoon_valley/boss_doomwalker.cpp +++ b/src/bindings/scripts/scripts/zone/shadowmoon_valley/boss_doomwalker.cpp @@ -1,211 +1,211 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Doomwalker -SD%Complete: 100 -SDComment: -SDCategory: Shadowmoon Valley -EndScriptData */ - -#include "precompiled.h" - -//-------------------------------------- -//Spells -#define SPELL_SUNDER_ARMOR 30901 - -#define SPELL_CHAIN_LIGHTNING 33665 - -#define SPELL_OVERRUN 32636 -#define SAY_OVERRUN_1 "Trajectory locked." -#define SOUND_OVERRUN_1 11347 -#define SAY_OVERRUN_2 "Engage maximum speed." -#define SOUND_OVERRUN_2 11348 - -#define SPELL_ENRAGE 34624 - -#define SPELL_MARK_DEATH 37128 - -#define SPELL_EARTHQUAKE 32686 -#define SAY_EARTHQUAKE_1 "Tectonic disruption commencing." -#define SOUND_EARTHQUAKE_1 11345 -#define SAY_EARTHQUAKE_2 "Magnitude set. Release." -#define SOUND_EARTHQUAKE_2 11346 - -#define SAY_AGGRO "Do not proceed. You will be eliminated!" -#define SOUND_AGGRO 11344 - -#define SAY_SLAY_1 "Threat level zero." -#define SOUND_SLAY_1 11349 -#define SAY_SLAY_2 "Directive accomplished." -#define SOUND_SLAY_2 11350 -#define SAY_SLAY_3 "Target exterminated." -#define SOUND_SLAY_3 11351 - -#define SAY_DEATH "System failure in five... four..." -#define SOUND_DEATH 11352 - -struct MANGOS_DLL_DECL boss_doomwalkerAI : public ScriptedAI -{ - boss_doomwalkerAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 Chain_Timer; - uint32 Enrage_Timer; - uint32 Overrun_Timer; - uint32 Quake_Timer; - uint32 Armor_Timer; - - bool InEnrage; - - void Reset() - { - Enrage_Timer = 0; - Armor_Timer = 10000; - Chain_Timer = 20000; - Quake_Timer = 60000; - Overrun_Timer = 120000; - - InEnrage = false; - } - - void KilledUnit(Unit* Victim) - { - if(rand()%5) - return; - - switch(rand()%3) - { - case 0: - DoYell(SAY_SLAY_1, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_SLAY_1); - break; - case 1: - DoYell(SAY_SLAY_2, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_SLAY_2); - break; - case 2: - DoYell(SAY_SLAY_3, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_SLAY_3); - break; - } - } - - void JustDied(Unit* Killer) - { - DoYell(SAY_DEATH, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_DEATH); - } - - void Aggro(Unit *who) - { - DoYell(SAY_AGGRO, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_AGGRO); - } - - void UpdateAI(const uint32 diff) - { - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - if (m_creature->IsWithinDistInMap(m_creature->getVictim(), ATTACK_DISTANCE)) - { - //when hp <= 20% gain enrage - if (((m_creature->GetHealth()*100)/ m_creature->GetMaxHealth()) <= 20) - { - if(Enrage_Timer < diff) - { - DoCast(m_creature,SPELL_ENRAGE); - Enrage_Timer = 6000; - InEnrage = true; - }else Enrage_Timer -= diff; - } - - //Spell Overrun - if (Overrun_Timer < diff) - { - switch(rand()%2) - { - case 0: - DoYell(SAY_OVERRUN_1, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_OVERRUN_1); - break; - case 1: - DoYell(SAY_OVERRUN_2, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_OVERRUN_2); - break; - } - DoCast(m_creature->getVictim(),SPELL_OVERRUN); - Overrun_Timer = (30 + rand()% 40) * 1000; //30-70sec cooldown - - }else Overrun_Timer -= diff; - - //Spell Earthquake - if (Quake_Timer < diff) - { - if (rand()%2) - return; - - switch(rand()%2) - { - case 0: - DoYell(SAY_EARTHQUAKE_1, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_EARTHQUAKE_1); - break; - case 1: - DoYell(SAY_EARTHQUAKE_2, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_EARTHQUAKE_2); - break; - } - if(InEnrage) - { - m_creature->RemoveAura(SPELL_ENRAGE, 0);//remove enrage before casting earthquake because enrage + earthquake = 16000dmg over 8sec and all dead - } - DoCast(m_creature,SPELL_EARTHQUAKE); - Quake_Timer = (70 + rand()% 30) * 1000; //70-100sec cooldown - }else Quake_Timer -= diff; - - //Spell Chain Lightning - if (Chain_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_CHAIN_LIGHTNING); - Chain_Timer = (50 + rand()% 50) * 1000; //50-100sec cooldown - }else Chain_Timer -= diff; - - //Spell Sunder Armor - if (Armor_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_SUNDER_ARMOR); - Armor_Timer = (15 + rand()% 7) * 1000; //15-23sec cooldown about 70 proc to stack - }else Armor_Timer -= diff; - - DoMeleeAttackIfReady(); - } - } -}; - -CreatureAI* GetAI_boss_doomwalker(Creature *_Creature) -{ - return new boss_doomwalkerAI (_Creature); -} - -void AddSC_boss_doomwalker() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_doomwalker"; - newscript->GetAI = GetAI_boss_doomwalker; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Doomwalker +SD%Complete: 100 +SDComment: +SDCategory: Shadowmoon Valley +EndScriptData */ + +#include "precompiled.h" + +//-------------------------------------- +//Spells +#define SPELL_SUNDER_ARMOR 30901 + +#define SPELL_CHAIN_LIGHTNING 33665 + +#define SPELL_OVERRUN 32636 +#define SAY_OVERRUN_1 "Trajectory locked." +#define SOUND_OVERRUN_1 11347 +#define SAY_OVERRUN_2 "Engage maximum speed." +#define SOUND_OVERRUN_2 11348 + +#define SPELL_ENRAGE 34624 + +#define SPELL_MARK_DEATH 37128 + +#define SPELL_EARTHQUAKE 32686 +#define SAY_EARTHQUAKE_1 "Tectonic disruption commencing." +#define SOUND_EARTHQUAKE_1 11345 +#define SAY_EARTHQUAKE_2 "Magnitude set. Release." +#define SOUND_EARTHQUAKE_2 11346 + +#define SAY_AGGRO "Do not proceed. You will be eliminated!" +#define SOUND_AGGRO 11344 + +#define SAY_SLAY_1 "Threat level zero." +#define SOUND_SLAY_1 11349 +#define SAY_SLAY_2 "Directive accomplished." +#define SOUND_SLAY_2 11350 +#define SAY_SLAY_3 "Target exterminated." +#define SOUND_SLAY_3 11351 + +#define SAY_DEATH "System failure in five... four..." +#define SOUND_DEATH 11352 + +struct MANGOS_DLL_DECL boss_doomwalkerAI : public ScriptedAI +{ + boss_doomwalkerAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 Chain_Timer; + uint32 Enrage_Timer; + uint32 Overrun_Timer; + uint32 Quake_Timer; + uint32 Armor_Timer; + + bool InEnrage; + + void Reset() + { + Enrage_Timer = 0; + Armor_Timer = 10000; + Chain_Timer = 20000; + Quake_Timer = 60000; + Overrun_Timer = 120000; + + InEnrage = false; + } + + void KilledUnit(Unit* Victim) + { + if(rand()%5) + return; + + switch(rand()%3) + { + case 0: + DoYell(SAY_SLAY_1, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_SLAY_1); + break; + case 1: + DoYell(SAY_SLAY_2, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_SLAY_2); + break; + case 2: + DoYell(SAY_SLAY_3, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_SLAY_3); + break; + } + } + + void JustDied(Unit* Killer) + { + DoYell(SAY_DEATH, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_DEATH); + } + + void Aggro(Unit *who) + { + DoYell(SAY_AGGRO, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_AGGRO); + } + + void UpdateAI(const uint32 diff) + { + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + if (m_creature->IsWithinDistInMap(m_creature->getVictim(), ATTACK_DISTANCE)) + { + //when hp <= 20% gain enrage + if (((m_creature->GetHealth()*100)/ m_creature->GetMaxHealth()) <= 20) + { + if(Enrage_Timer < diff) + { + DoCast(m_creature,SPELL_ENRAGE); + Enrage_Timer = 6000; + InEnrage = true; + }else Enrage_Timer -= diff; + } + + //Spell Overrun + if (Overrun_Timer < diff) + { + switch(rand()%2) + { + case 0: + DoYell(SAY_OVERRUN_1, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_OVERRUN_1); + break; + case 1: + DoYell(SAY_OVERRUN_2, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_OVERRUN_2); + break; + } + DoCast(m_creature->getVictim(),SPELL_OVERRUN); + Overrun_Timer = (30 + rand()% 40) * 1000; //30-70sec cooldown + + }else Overrun_Timer -= diff; + + //Spell Earthquake + if (Quake_Timer < diff) + { + if (rand()%2) + return; + + switch(rand()%2) + { + case 0: + DoYell(SAY_EARTHQUAKE_1, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_EARTHQUAKE_1); + break; + case 1: + DoYell(SAY_EARTHQUAKE_2, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_EARTHQUAKE_2); + break; + } + if(InEnrage) + { + m_creature->RemoveAura(SPELL_ENRAGE, 0);//remove enrage before casting earthquake because enrage + earthquake = 16000dmg over 8sec and all dead + } + DoCast(m_creature,SPELL_EARTHQUAKE); + Quake_Timer = (70 + rand()% 30) * 1000; //70-100sec cooldown + }else Quake_Timer -= diff; + + //Spell Chain Lightning + if (Chain_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_CHAIN_LIGHTNING); + Chain_Timer = (50 + rand()% 50) * 1000; //50-100sec cooldown + }else Chain_Timer -= diff; + + //Spell Sunder Armor + if (Armor_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_SUNDER_ARMOR); + Armor_Timer = (15 + rand()% 7) * 1000; //15-23sec cooldown about 70 proc to stack + }else Armor_Timer -= diff; + + DoMeleeAttackIfReady(); + } + } +}; + +CreatureAI* GetAI_boss_doomwalker(Creature *_Creature) +{ + return new boss_doomwalkerAI (_Creature); +} + +void AddSC_boss_doomwalker() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_doomwalker"; + newscript->GetAI = GetAI_boss_doomwalker; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/shadowmoon_valley/shadowmoon_valley.cpp b/src/bindings/scripts/scripts/zone/shadowmoon_valley/shadowmoon_valley.cpp index d75d50c666b..c2d5f6dfecc 100644 --- a/src/bindings/scripts/scripts/zone/shadowmoon_valley/shadowmoon_valley.cpp +++ b/src/bindings/scripts/scripts/zone/shadowmoon_valley/shadowmoon_valley.cpp @@ -1,748 +1,748 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Shadowmoon_Valley -SD%Complete: 100 -SDComment: Quest support: 10519, 10583, 10601, 10814, 10804, 10854, 11082. Vendor Drake Dealer Hurlunk. Teleporter TO Invasion Point: Cataclysm -SDCategory: Shadowmoon Valley -EndScriptData */ - -/* ContentData -mob_mature_netherwing_drake -mob_enslaved_netherwing_drake -npc_drake_dealer_hurlunk -npc_invis_legion_teleporter -npcs_flanis_swiftwing_and_kagrosh -npc_murkblood_overseer -npc_neltharaku -npc_karynaku -npc_oronok_tornheart -EndContentData */ - -#include "precompiled.h" - -/*##### -# mob_mature_netherwing_drake -#####*/ - -#define SPELL_PLACE_CARCASS 38439 -#define SPELL_JUST_EATEN 38502 -#define SPELL_NETHER_BREATH 38467 - -#define SAY_JUST_EATEN "Thank you, mortal." - -struct MANGOS_DLL_DECL mob_mature_netherwing_drakeAI : public ScriptedAI -{ - mob_mature_netherwing_drakeAI(Creature* c) : ScriptedAI(c) - { - Reset(); - PlayerGUID = 0; - } - - uint64 PlayerGUID; - - bool IsEating; - bool Evade; - - uint32 ResetTimer; - uint32 CastTimer; - uint32 EatTimer; - - void Reset() - { - IsEating = false; - Evade = false; - - ResetTimer = 120000; - EatTimer = 5000; - CastTimer = 5000; - } - - void Aggro(Unit* who) { } - - void MoveInLineOfSight(Unit* who) - { - if(m_creature->GetMotionMaster()->GetCurrentMovementGeneratorType() == POINT_MOTION_TYPE) - return; - - ScriptedAI::MoveInLineOfSight(who); - } - - void SpellHit(Unit* caster, const SpellEntry* spell) - { - if(!caster) - return; - - if(caster->GetTypeId() == TYPEID_PLAYER && spell->Id == SPELL_PLACE_CARCASS && !m_creature->HasAura(SPELL_JUST_EATEN, 0) && !PlayerGUID) - { - float PlayerX, PlayerY, PlayerZ; - caster->GetClosePoint(PlayerX, PlayerY, PlayerZ, m_creature->GetObjectSize()); - m_creature->AddUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT + MOVEMENTFLAG_LEVITATING); - m_creature->GetMotionMaster()->MovePoint(1, PlayerX, PlayerY, PlayerZ); - PlayerGUID = caster->GetGUID(); - } - } - - void MovementInform(uint32 type, uint32 id) - { - if(type != POINT_MOTION_TYPE) - return; - - if(id == 1) - { - IsEating = true; - EatTimer = 5000; - m_creature->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_ONESHOT_ATTACKUNARMED); - m_creature->RemoveUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT + MOVEMENTFLAG_LEVITATING); - } - } - - void UpdateAI(const uint32 diff) - { - if(IsEating) - if(EatTimer < diff) - { - IsEating = false; - DoCast(m_creature, SPELL_JUST_EATEN); - m_creature->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_ONESHOT_NONE); - DoSay(SAY_JUST_EATEN, LANG_DRACONIC, NULL); - if(PlayerGUID) - { - Player* plr = ((Player*)Unit::GetUnit((*m_creature), PlayerGUID)); - if(plr && plr->GetQuestStatus(10804) == QUEST_STATUS_INCOMPLETE) - { - plr->KilledMonster(22131, m_creature->GetGUID()); - Evade = true; - PlayerGUID = 0; - } - } - }else EatTimer -= diff; - - if(Evade) - if(ResetTimer < diff) - EnterEvadeMode(); - else ResetTimer -= diff; - - if(!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - if(CastTimer < diff) - { - DoCast(m_creature->getVictim(), SPELL_NETHER_BREATH); - CastTimer = 5000; - }else CastTimer -= diff; - - DoMeleeAttackIfReady(); - } -}; - -CreatureAI* GetAI_mob_mature_netherwing_drake(Creature *_creature) -{ - return new mob_mature_netherwing_drakeAI(_creature); -} - -/*### -# mob_enslaved_netherwing_drake -####*/ - -#define FACTION_DEFAULT 62 -#define FACTION_FRIENDLY 1840 // Not sure if this is correct, it was taken off of Mordenai. - -#define SPELL_HIT_FORCE_OF_NELTHARAKU 38762 -#define SPELL_FORCE_OF_NELTHARAKU 38775 - -#define CREATURE_DRAGONMAW_SUBJUGATOR 21718 -#define CREATURE_ESCAPE_DUMMY 22317 - -struct MANGOS_DLL_DECL mob_enslaved_netherwing_drakeAI : public ScriptedAI -{ - mob_enslaved_netherwing_drakeAI(Creature* c) : ScriptedAI(c) - { - Reset(); - PlayerGUID = 0; - Tapped = false; - } - - uint64 PlayerGUID; - uint32 FlyTimer; - bool Tapped; - - void Reset() - { - if(!Tapped) - m_creature->setFaction(FACTION_DEFAULT); - - FlyTimer = 10000; - m_creature->RemoveUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT + MOVEMENTFLAG_LEVITATING); - m_creature->SetVisibility(VISIBILITY_ON); - } - - void Aggro(Unit* who) { } - - Creature* SelectCreatureInGrid(uint32 entry, float range) - { - Creature* pCreature = NULL; - - // Time for some omg mind blowing code to search for creature - CellPair pair(MaNGOS::ComputeCellPair(m_creature->GetPositionX(), m_creature->GetPositionY())); - Cell cell(pair); - cell.data.Part.reserved = ALL_DISTRICT; - cell.SetNoCreate(); - - MaNGOS::NearestCreatureEntryWithLiveStateInObjectRangeCheck creature_check(*m_creature, entry, true, range); - MaNGOS::CreatureLastSearcher searcher(pCreature, creature_check); - - TypeContainerVisitor, GridTypeMapContainer> creature_searcher(searcher); - - CellLock cell_lock(cell, pair); - cell_lock->Visit(cell_lock, creature_searcher,*(m_creature->GetMap())); - - return pCreature; - } - - void SpellHit(Unit* caster, const SpellEntry* spell) - { - if(!caster) - return; - - if(caster->GetTypeId() == TYPEID_PLAYER && spell->Id == SPELL_HIT_FORCE_OF_NELTHARAKU && !Tapped) - { - Tapped = true; - PlayerGUID = caster->GetGUID(); - - m_creature->setFaction(FACTION_FRIENDLY); - DoCast(caster, SPELL_FORCE_OF_NELTHARAKU, true); - - Creature* Dragonmaw = SelectCreatureInGrid(CREATURE_DRAGONMAW_SUBJUGATOR, 50); - - if(Dragonmaw) - { - m_creature->AddThreat(Dragonmaw, 100000.0f); - AttackStart(Dragonmaw); - } - - HostilReference* ref = m_creature->getThreatManager().getOnlineContainer().getReferenceByTarget(caster); - if(ref) - ref->removeReference(); - } - } - - void MovementInform(uint32 type, uint32 id) - { - if(type != POINT_MOTION_TYPE) - return; - - if(id == 1) - { - if(PlayerGUID) - { - Unit* plr = Unit::GetUnit((*m_creature), PlayerGUID); - if(plr) - DoCast(plr, SPELL_FORCE_OF_NELTHARAKU, true); - - PlayerGUID = 0; - } - m_creature->SetVisibility(VISIBILITY_OFF); - m_creature->RemoveUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT + MOVEMENTFLAG_LEVITATING); - m_creature->DealDamage(m_creature, m_creature->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); - m_creature->RemoveCorpse(); - } - } - - void UpdateAI(const uint32 diff) - { - if(!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - { - if(Tapped) - if(FlyTimer < diff) - { - Tapped = false; - if(PlayerGUID) - { - Player* plr = ((Player*)Unit::GetUnit((*m_creature), PlayerGUID)); - if(plr && plr->GetQuestStatus(10854) == QUEST_STATUS_INCOMPLETE) - { - plr->KilledMonster(22316, m_creature->GetGUID()); - /* - float x,y,z; - m_creature->GetPosition(x,y,z); - - float dx,dy,dz; - m_creature->GetRandomPoint(x, y, z, 20, dx, dy, dz); - dz += 20; // so it's in the air, not ground*/ - - float dx, dy, dz; - - Creature* EscapeDummy = SelectCreatureInGrid(CREATURE_ESCAPE_DUMMY, 30); - if(EscapeDummy) - EscapeDummy->GetPosition(dx, dy, dz); - else - { - m_creature->GetRandomPoint(m_creature->GetPositionX(), m_creature->GetPositionY(), m_creature->GetPositionZ(), 20, dx, dy, dz); - dz += 25; - } - - m_creature->AddUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT + MOVEMENTFLAG_LEVITATING); - m_creature->GetMotionMaster()->MovePoint(1, dx, dy, dz); - } - } - }else FlyTimer -= diff; - return; - } - - DoMeleeAttackIfReady(); - } -}; - -CreatureAI* GetAI_mob_enslaved_netherwing_drake(Creature* _Creature) -{ - return new mob_enslaved_netherwing_drakeAI(_Creature); -} - -/*##### -# mob_dragonmaw_peon -#####*/ - -struct MANGOS_DLL_DECL mob_dragonmaw_peonAI : public ScriptedAI -{ - mob_dragonmaw_peonAI(Creature* c) : ScriptedAI(c) - { - Reset(); - } - - uint64 PlayerGUID; - bool Tapped; - uint32 PoisonTimer; - - void Reset() - { - PlayerGUID = 0; - Tapped = false; - PoisonTimer = 0; - } - - void Aggro(Unit* who) { } - - void SpellHit(Unit* caster, const SpellEntry* spell) - { - if(!caster) - return; - - if(caster->GetTypeId() == TYPEID_PLAYER && spell->Id == 40468 && !Tapped) - { - PlayerGUID = caster->GetGUID(); - - Tapped = true; - float x, y, z; - caster->GetClosePoint(x, y, z, m_creature->GetObjectSize()); - - m_creature->RemoveUnitMovementFlag(MOVEMENTFLAG_WALK_MODE); - m_creature->GetMotionMaster()->MovePoint(1, x, y, z); - } - } - - void MovementInform(uint32 type, uint32 id) - { - if(type != POINT_MOTION_TYPE) - return; - - if(id) - { - m_creature->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_ONESHOT_EAT); - PoisonTimer = 15000; - } - } - - void UpdateAI(const uint32 diff) - { - if(PoisonTimer) - if(PoisonTimer <= diff) - { - if(PlayerGUID) - { - Player* plr = ((Player*)Unit::GetUnit((*m_creature), PlayerGUID)); - if(plr && plr->GetQuestStatus(11020) == QUEST_STATUS_INCOMPLETE) - plr->KilledMonster(23209, m_creature->GetGUID()); - } - PoisonTimer = 0; - m_creature->DealDamage(m_creature, m_creature->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); - }else PoisonTimer -= diff; - } -}; - -/*###### -## npc_drake_dealer_hurlunk -######*/ - -bool GossipHello_npc_drake_dealer_hurlunk(Player *player, Creature *_Creature) -{ - if (_Creature->isVendor() && player->GetReputationRank(1015) == REP_EXALTED) - player->ADD_GOSSIP_ITEM(1, GOSSIP_TEXT_BROWSE_GOODS, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_TRADE); - - player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); - - return true; -} - -bool GossipSelect_npc_drake_dealer_hurlunk(Player *player, Creature *_Creature, uint32 sender, uint32 action) -{ - if (action == GOSSIP_ACTION_TRADE) - player->SEND_VENDORLIST( _Creature->GetGUID() ); - - return true; -} - -/*###### -## npc_invis_legion_teleporter -######*/ - -#define SPELL_TELE_A_TO 37387 -#define SPELL_TELE_H_TO 37389 - -struct MANGOS_DLL_DECL npc_invis_legion_teleporterAI : public ScriptedAI -{ - npc_invis_legion_teleporterAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint64 PlayerGuid; - uint32 TeleTimer; - - void Reset() - { - PlayerGuid=0; - TeleTimer = 5000; - } - - void Aggro(Unit* who) - { - } - - void MoveInLineOfSight(Unit *who) - { - if (!who || who->GetTypeId() != TYPEID_PLAYER) - return; - - if(who->GetTypeId() == TYPEID_PLAYER && m_creature->GetDistance(who)<4) - { - if (who->isAlive() || !who->isInCombat()) - PlayerGuid = who->GetGUID(); - } - } - - void UpdateAI(const uint32 diff) - { - if(TeleTimer < diff) - { - if(PlayerGuid) - { - Player* player = ((Player*)Unit::GetUnit((*m_creature), PlayerGuid)); - - if(m_creature->GetDistance(player)<3) - { - if(player->GetTeam()== ALLIANCE && player->GetQuestRewardStatus(10589)) - player->CastSpell(player,SPELL_TELE_A_TO,false); - if(player->GetTeam()== HORDE && player->GetQuestRewardStatus(10604)) - player->CastSpell(player,SPELL_TELE_H_TO,false); - } - PlayerGuid=0; - } - TeleTimer = 5000; - }else TeleTimer -= diff; - } -}; -CreatureAI* GetAI_npc_invis_legion_teleporter(Creature *_Creature) -{ - return new npc_invis_legion_teleporterAI (_Creature); -} - -/*###### -## npc_flanis_swiftwing_and_kagrosh -######*/ - -bool GossipHello_npcs_flanis_swiftwing_and_kagrosh(Player *player, Creature *_Creature) -{ - if (player->GetQuestStatus(10583) == QUEST_STATUS_INCOMPLETE && !player->HasItemCount(30658,1,true)) - player->ADD_GOSSIP_ITEM( 0, "Take Flanis's Pack", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); - if (player->GetQuestStatus(10601) == QUEST_STATUS_INCOMPLETE && !player->HasItemCount(30659,1,true)) - player->ADD_GOSSIP_ITEM( 0, "Take Kagrosh's Pack", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2); - - player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); - - return true; -} - -bool GossipSelect_npcs_flanis_swiftwing_and_kagrosh(Player *player, Creature *_Creature, uint32 sender, uint32 action) -{ - if (action == GOSSIP_ACTION_INFO_DEF+1) - { - ItemPosCountVec dest; - uint8 msg = player->CanStoreNewItem( NULL_BAG, NULL_SLOT, dest, 30658, 1, false); - if( msg == EQUIP_ERR_OK ) - { - player->StoreNewItem( dest, 30658, 1, true); - player->PlayerTalkClass->ClearMenus(); - } - } - if (action == GOSSIP_ACTION_INFO_DEF+2) - { - ItemPosCountVec dest; - uint8 msg = player->CanStoreNewItem( NULL_BAG, NULL_SLOT, dest, 30659, 1, false); - if( msg == EQUIP_ERR_OK ) - { - player->StoreNewItem( dest, 30659, 1, true); - player->PlayerTalkClass->ClearMenus(); - } - } - return true; -} - -/*###### -## npc_murkblood_overseer -######*/ - -#define QUEST_11082 11082 - -bool GossipHello_npc_murkblood_overseer(Player *player, Creature *_Creature) -{ - if (player->GetQuestStatus(QUEST_11082) == QUEST_STATUS_INCOMPLETE) - player->ADD_GOSSIP_ITEM( 0, "I am here for you, overseer.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); - - player->SEND_GOSSIP_MENU(10940, _Creature->GetGUID()); - return true; -} - -bool GossipSelect_npc_murkblood_overseer(Player *player, Creature *_Creature, uint32 sender, uint32 action) -{ - switch (action) - { - case GOSSIP_ACTION_INFO_DEF+1: - player->ADD_GOSSIP_ITEM(0, "How dare you question an overseer of the Dragonmaw!", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2); - //correct id not known - player->SEND_GOSSIP_MENU(10940, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+2: - player->ADD_GOSSIP_ITEM(0, "Who speaks of me? What are you talking about, broken?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+3); - //correct id not known - player->SEND_GOSSIP_MENU(10940, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+3: - player->ADD_GOSSIP_ITEM(0, "Continue please.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+4); - //correct id not known - player->SEND_GOSSIP_MENU(10940, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+4: - player->ADD_GOSSIP_ITEM(0, "Who are these bidders?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+5); - //correct id not known - player->SEND_GOSSIP_MENU(10940, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+5: - player->ADD_GOSSIP_ITEM(0, "Well... yes.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+6); - //correct id not known - player->SEND_GOSSIP_MENU(10940, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+6: - //correct id not known - player->SEND_GOSSIP_MENU(10940, _Creature->GetGUID()); - _Creature->CastSpell(player,41121,false); - player->AreaExploredOrEventHappens(QUEST_11082); - break; - } - return true; -} - -/*###### -## npc_neltharaku -######*/ - -bool GossipHello_npc_neltharaku(Player *player, Creature *_Creature) -{ - if (_Creature->isQuestGiver()) - player->PrepareQuestMenu( _Creature->GetGUID() ); - - if (player->GetQuestStatus(10814) == QUEST_STATUS_INCOMPLETE) - player->ADD_GOSSIP_ITEM( 0, "I am listening, dragon", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); - - player->SEND_GOSSIP_MENU(10613, _Creature->GetGUID()); - - return true; -} - -bool GossipSelect_npc_neltharaku(Player *player, Creature *_Creature, uint32 sender, uint32 action) -{ - switch (action) - { - case GOSSIP_ACTION_INFO_DEF+1: - player->ADD_GOSSIP_ITEM( 0, "But you are dragons! How could orcs do this to you?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2); - player->SEND_GOSSIP_MENU(10614, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+2: - player->ADD_GOSSIP_ITEM( 0, "Your mate?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+3); - player->SEND_GOSSIP_MENU(10615, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+3: - player->ADD_GOSSIP_ITEM( 0, "I have battled many beasts, dragon. I will help you.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+4); - player->SEND_GOSSIP_MENU(10616, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+4: - player->CLOSE_GOSSIP_MENU(); - player->AreaExploredOrEventHappens(10814); - break; - } - return true; -} - -/*###### -## npc_oronok -######*/ - -#define GOSSIP_ORONOK1 "I am ready to hear your story, Oronok." -#define GOSSIP_ORONOK2 "How do I find the cipher?" -#define GOSSIP_ORONOK3 "How do you know all of this?" -#define GOSSIP_ORONOK4 "Yet what? What is it, Oronok?" -#define GOSSIP_ORONOK5 "Continue, please." -#define GOSSIP_ORONOK6 "So what of the cipher now? And your boys?" -#define GOSSIP_ORONOK7 "I will find your boys and the cipher, Oronok." - -bool GossipHello_npc_oronok_tornheart(Player *player, Creature *_Creature) -{ - if (_Creature->isQuestGiver()) - player->PrepareQuestMenu( _Creature->GetGUID() ); - if (_Creature->isVendor()) - player->ADD_GOSSIP_ITEM(1, GOSSIP_TEXT_BROWSE_GOODS, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_TRADE); - - if (player->GetQuestStatus(10519) == QUEST_STATUS_INCOMPLETE) - { - player->ADD_GOSSIP_ITEM( 0, GOSSIP_ORONOK1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF); - player->SEND_GOSSIP_MENU(10312, _Creature->GetGUID()); - }else - player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); - - return true; -} - -bool GossipSelect_npc_oronok_tornheart(Player *player, Creature *_Creature, uint32 sender, uint32 action) -{ - switch (action) - { - case GOSSIP_ACTION_TRADE: - player->SEND_VENDORLIST( _Creature->GetGUID() ); - break; - case GOSSIP_ACTION_INFO_DEF: - player->ADD_GOSSIP_ITEM( 0, GOSSIP_ORONOK2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); - player->SEND_GOSSIP_MENU(10313, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+1: - player->ADD_GOSSIP_ITEM( 0, GOSSIP_ORONOK3, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2); - player->SEND_GOSSIP_MENU(10314, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+2: - player->ADD_GOSSIP_ITEM( 0, GOSSIP_ORONOK4, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+3); - player->SEND_GOSSIP_MENU(10315, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+3: - player->ADD_GOSSIP_ITEM( 0, GOSSIP_ORONOK5, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+4); - player->SEND_GOSSIP_MENU(10316, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+4: - player->ADD_GOSSIP_ITEM( 0, GOSSIP_ORONOK6, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+5); - player->SEND_GOSSIP_MENU(10317, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+5: - player->ADD_GOSSIP_ITEM( 0, GOSSIP_ORONOK7, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+6); - player->SEND_GOSSIP_MENU(10318, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+6: - player->CLOSE_GOSSIP_MENU(); - player->AreaExploredOrEventHappens(10519); - break; - } - return true; -} - -/*#### -# npc_karynaku -####*/ - -bool QuestAccept_npc_karynaku(Player* player, Creature* creature, Quest const* quest) -{ - if(quest->GetQuestId() == 10870) // Ally of the Netherwing - { - std::vector nodes; - - nodes.resize(2); - nodes[0] = 161; // From Karynaku - nodes[1] = 162; // To Mordenai - error_log("SD2: Player %s started quest 10870 which has disabled taxi node, need to be fixed in core", player->GetName()); - //player->ActivateTaxiPathTo(nodes, 20811); - } - - return true; -} - -void AddSC_shadowmoon_valley() -{ - Script *newscript; - - newscript = new Script; - newscript->Name = "mob_mature_netherwing_drake"; - newscript->GetAI = GetAI_mob_mature_netherwing_drake; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name = "mob_enslaved_netherwing_drake"; - newscript->GetAI = GetAI_mob_enslaved_netherwing_drake; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="npc_drake_dealer_hurlunk"; - newscript->pGossipHello = &GossipHello_npc_drake_dealer_hurlunk; - newscript->pGossipSelect = &GossipSelect_npc_drake_dealer_hurlunk; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="npc_invis_legion_teleporter"; - newscript->GetAI = GetAI_npc_invis_legion_teleporter; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="npcs_flanis_swiftwing_and_kagrosh"; - newscript->pGossipHello = &GossipHello_npcs_flanis_swiftwing_and_kagrosh; - newscript->pGossipSelect = &GossipSelect_npcs_flanis_swiftwing_and_kagrosh; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="npc_murkblood_overseer"; - newscript->pGossipHello = &GossipHello_npc_murkblood_overseer; - newscript->pGossipSelect = &GossipSelect_npc_murkblood_overseer; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="npc_neltharaku"; - newscript->pGossipHello = &GossipHello_npc_neltharaku; - newscript->pGossipSelect = &GossipSelect_npc_neltharaku; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name = "npc_karynaku"; - newscript->pQuestAccept = &QuestAccept_npc_karynaku; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="npc_oronok_tornheart"; - newscript->pGossipHello = &GossipHello_npc_oronok_tornheart; - newscript->pGossipSelect = &GossipSelect_npc_oronok_tornheart; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Shadowmoon_Valley +SD%Complete: 100 +SDComment: Quest support: 10519, 10583, 10601, 10814, 10804, 10854, 11082. Vendor Drake Dealer Hurlunk. Teleporter TO Invasion Point: Cataclysm +SDCategory: Shadowmoon Valley +EndScriptData */ + +/* ContentData +mob_mature_netherwing_drake +mob_enslaved_netherwing_drake +npc_drake_dealer_hurlunk +npc_invis_legion_teleporter +npcs_flanis_swiftwing_and_kagrosh +npc_murkblood_overseer +npc_neltharaku +npc_karynaku +npc_oronok_tornheart +EndContentData */ + +#include "precompiled.h" + +/*##### +# mob_mature_netherwing_drake +#####*/ + +#define SPELL_PLACE_CARCASS 38439 +#define SPELL_JUST_EATEN 38502 +#define SPELL_NETHER_BREATH 38467 + +#define SAY_JUST_EATEN "Thank you, mortal." + +struct MANGOS_DLL_DECL mob_mature_netherwing_drakeAI : public ScriptedAI +{ + mob_mature_netherwing_drakeAI(Creature* c) : ScriptedAI(c) + { + Reset(); + PlayerGUID = 0; + } + + uint64 PlayerGUID; + + bool IsEating; + bool Evade; + + uint32 ResetTimer; + uint32 CastTimer; + uint32 EatTimer; + + void Reset() + { + IsEating = false; + Evade = false; + + ResetTimer = 120000; + EatTimer = 5000; + CastTimer = 5000; + } + + void Aggro(Unit* who) { } + + void MoveInLineOfSight(Unit* who) + { + if(m_creature->GetMotionMaster()->GetCurrentMovementGeneratorType() == POINT_MOTION_TYPE) + return; + + ScriptedAI::MoveInLineOfSight(who); + } + + void SpellHit(Unit* caster, const SpellEntry* spell) + { + if(!caster) + return; + + if(caster->GetTypeId() == TYPEID_PLAYER && spell->Id == SPELL_PLACE_CARCASS && !m_creature->HasAura(SPELL_JUST_EATEN, 0) && !PlayerGUID) + { + float PlayerX, PlayerY, PlayerZ; + caster->GetClosePoint(PlayerX, PlayerY, PlayerZ, m_creature->GetObjectSize()); + m_creature->AddUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT + MOVEMENTFLAG_LEVITATING); + m_creature->GetMotionMaster()->MovePoint(1, PlayerX, PlayerY, PlayerZ); + PlayerGUID = caster->GetGUID(); + } + } + + void MovementInform(uint32 type, uint32 id) + { + if(type != POINT_MOTION_TYPE) + return; + + if(id == 1) + { + IsEating = true; + EatTimer = 5000; + m_creature->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_ONESHOT_ATTACKUNARMED); + m_creature->RemoveUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT + MOVEMENTFLAG_LEVITATING); + } + } + + void UpdateAI(const uint32 diff) + { + if(IsEating) + if(EatTimer < diff) + { + IsEating = false; + DoCast(m_creature, SPELL_JUST_EATEN); + m_creature->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_ONESHOT_NONE); + DoSay(SAY_JUST_EATEN, LANG_DRACONIC, NULL); + if(PlayerGUID) + { + Player* plr = ((Player*)Unit::GetUnit((*m_creature), PlayerGUID)); + if(plr && plr->GetQuestStatus(10804) == QUEST_STATUS_INCOMPLETE) + { + plr->KilledMonster(22131, m_creature->GetGUID()); + Evade = true; + PlayerGUID = 0; + } + } + }else EatTimer -= diff; + + if(Evade) + if(ResetTimer < diff) + EnterEvadeMode(); + else ResetTimer -= diff; + + if(!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + if(CastTimer < diff) + { + DoCast(m_creature->getVictim(), SPELL_NETHER_BREATH); + CastTimer = 5000; + }else CastTimer -= diff; + + DoMeleeAttackIfReady(); + } +}; + +CreatureAI* GetAI_mob_mature_netherwing_drake(Creature *_creature) +{ + return new mob_mature_netherwing_drakeAI(_creature); +} + +/*### +# mob_enslaved_netherwing_drake +####*/ + +#define FACTION_DEFAULT 62 +#define FACTION_FRIENDLY 1840 // Not sure if this is correct, it was taken off of Mordenai. + +#define SPELL_HIT_FORCE_OF_NELTHARAKU 38762 +#define SPELL_FORCE_OF_NELTHARAKU 38775 + +#define CREATURE_DRAGONMAW_SUBJUGATOR 21718 +#define CREATURE_ESCAPE_DUMMY 22317 + +struct MANGOS_DLL_DECL mob_enslaved_netherwing_drakeAI : public ScriptedAI +{ + mob_enslaved_netherwing_drakeAI(Creature* c) : ScriptedAI(c) + { + Reset(); + PlayerGUID = 0; + Tapped = false; + } + + uint64 PlayerGUID; + uint32 FlyTimer; + bool Tapped; + + void Reset() + { + if(!Tapped) + m_creature->setFaction(FACTION_DEFAULT); + + FlyTimer = 10000; + m_creature->RemoveUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT + MOVEMENTFLAG_LEVITATING); + m_creature->SetVisibility(VISIBILITY_ON); + } + + void Aggro(Unit* who) { } + + Creature* SelectCreatureInGrid(uint32 entry, float range) + { + Creature* pCreature = NULL; + + // Time for some omg mind blowing code to search for creature + CellPair pair(MaNGOS::ComputeCellPair(m_creature->GetPositionX(), m_creature->GetPositionY())); + Cell cell(pair); + cell.data.Part.reserved = ALL_DISTRICT; + cell.SetNoCreate(); + + MaNGOS::NearestCreatureEntryWithLiveStateInObjectRangeCheck creature_check(*m_creature, entry, true, range); + MaNGOS::CreatureLastSearcher searcher(pCreature, creature_check); + + TypeContainerVisitor, GridTypeMapContainer> creature_searcher(searcher); + + CellLock cell_lock(cell, pair); + cell_lock->Visit(cell_lock, creature_searcher,*(m_creature->GetMap())); + + return pCreature; + } + + void SpellHit(Unit* caster, const SpellEntry* spell) + { + if(!caster) + return; + + if(caster->GetTypeId() == TYPEID_PLAYER && spell->Id == SPELL_HIT_FORCE_OF_NELTHARAKU && !Tapped) + { + Tapped = true; + PlayerGUID = caster->GetGUID(); + + m_creature->setFaction(FACTION_FRIENDLY); + DoCast(caster, SPELL_FORCE_OF_NELTHARAKU, true); + + Creature* Dragonmaw = SelectCreatureInGrid(CREATURE_DRAGONMAW_SUBJUGATOR, 50); + + if(Dragonmaw) + { + m_creature->AddThreat(Dragonmaw, 100000.0f); + AttackStart(Dragonmaw); + } + + HostilReference* ref = m_creature->getThreatManager().getOnlineContainer().getReferenceByTarget(caster); + if(ref) + ref->removeReference(); + } + } + + void MovementInform(uint32 type, uint32 id) + { + if(type != POINT_MOTION_TYPE) + return; + + if(id == 1) + { + if(PlayerGUID) + { + Unit* plr = Unit::GetUnit((*m_creature), PlayerGUID); + if(plr) + DoCast(plr, SPELL_FORCE_OF_NELTHARAKU, true); + + PlayerGUID = 0; + } + m_creature->SetVisibility(VISIBILITY_OFF); + m_creature->RemoveUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT + MOVEMENTFLAG_LEVITATING); + m_creature->DealDamage(m_creature, m_creature->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); + m_creature->RemoveCorpse(); + } + } + + void UpdateAI(const uint32 diff) + { + if(!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + { + if(Tapped) + if(FlyTimer < diff) + { + Tapped = false; + if(PlayerGUID) + { + Player* plr = ((Player*)Unit::GetUnit((*m_creature), PlayerGUID)); + if(plr && plr->GetQuestStatus(10854) == QUEST_STATUS_INCOMPLETE) + { + plr->KilledMonster(22316, m_creature->GetGUID()); + /* + float x,y,z; + m_creature->GetPosition(x,y,z); + + float dx,dy,dz; + m_creature->GetRandomPoint(x, y, z, 20, dx, dy, dz); + dz += 20; // so it's in the air, not ground*/ + + float dx, dy, dz; + + Creature* EscapeDummy = SelectCreatureInGrid(CREATURE_ESCAPE_DUMMY, 30); + if(EscapeDummy) + EscapeDummy->GetPosition(dx, dy, dz); + else + { + m_creature->GetRandomPoint(m_creature->GetPositionX(), m_creature->GetPositionY(), m_creature->GetPositionZ(), 20, dx, dy, dz); + dz += 25; + } + + m_creature->AddUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT + MOVEMENTFLAG_LEVITATING); + m_creature->GetMotionMaster()->MovePoint(1, dx, dy, dz); + } + } + }else FlyTimer -= diff; + return; + } + + DoMeleeAttackIfReady(); + } +}; + +CreatureAI* GetAI_mob_enslaved_netherwing_drake(Creature* _Creature) +{ + return new mob_enslaved_netherwing_drakeAI(_Creature); +} + +/*##### +# mob_dragonmaw_peon +#####*/ + +struct MANGOS_DLL_DECL mob_dragonmaw_peonAI : public ScriptedAI +{ + mob_dragonmaw_peonAI(Creature* c) : ScriptedAI(c) + { + Reset(); + } + + uint64 PlayerGUID; + bool Tapped; + uint32 PoisonTimer; + + void Reset() + { + PlayerGUID = 0; + Tapped = false; + PoisonTimer = 0; + } + + void Aggro(Unit* who) { } + + void SpellHit(Unit* caster, const SpellEntry* spell) + { + if(!caster) + return; + + if(caster->GetTypeId() == TYPEID_PLAYER && spell->Id == 40468 && !Tapped) + { + PlayerGUID = caster->GetGUID(); + + Tapped = true; + float x, y, z; + caster->GetClosePoint(x, y, z, m_creature->GetObjectSize()); + + m_creature->RemoveUnitMovementFlag(MOVEMENTFLAG_WALK_MODE); + m_creature->GetMotionMaster()->MovePoint(1, x, y, z); + } + } + + void MovementInform(uint32 type, uint32 id) + { + if(type != POINT_MOTION_TYPE) + return; + + if(id) + { + m_creature->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_ONESHOT_EAT); + PoisonTimer = 15000; + } + } + + void UpdateAI(const uint32 diff) + { + if(PoisonTimer) + if(PoisonTimer <= diff) + { + if(PlayerGUID) + { + Player* plr = ((Player*)Unit::GetUnit((*m_creature), PlayerGUID)); + if(plr && plr->GetQuestStatus(11020) == QUEST_STATUS_INCOMPLETE) + plr->KilledMonster(23209, m_creature->GetGUID()); + } + PoisonTimer = 0; + m_creature->DealDamage(m_creature, m_creature->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); + }else PoisonTimer -= diff; + } +}; + +/*###### +## npc_drake_dealer_hurlunk +######*/ + +bool GossipHello_npc_drake_dealer_hurlunk(Player *player, Creature *_Creature) +{ + if (_Creature->isVendor() && player->GetReputationRank(1015) == REP_EXALTED) + player->ADD_GOSSIP_ITEM(1, GOSSIP_TEXT_BROWSE_GOODS, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_TRADE); + + player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); + + return true; +} + +bool GossipSelect_npc_drake_dealer_hurlunk(Player *player, Creature *_Creature, uint32 sender, uint32 action) +{ + if (action == GOSSIP_ACTION_TRADE) + player->SEND_VENDORLIST( _Creature->GetGUID() ); + + return true; +} + +/*###### +## npc_invis_legion_teleporter +######*/ + +#define SPELL_TELE_A_TO 37387 +#define SPELL_TELE_H_TO 37389 + +struct MANGOS_DLL_DECL npc_invis_legion_teleporterAI : public ScriptedAI +{ + npc_invis_legion_teleporterAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint64 PlayerGuid; + uint32 TeleTimer; + + void Reset() + { + PlayerGuid=0; + TeleTimer = 5000; + } + + void Aggro(Unit* who) + { + } + + void MoveInLineOfSight(Unit *who) + { + if (!who || who->GetTypeId() != TYPEID_PLAYER) + return; + + if(who->GetTypeId() == TYPEID_PLAYER && m_creature->GetDistance(who)<4) + { + if (who->isAlive() || !who->isInCombat()) + PlayerGuid = who->GetGUID(); + } + } + + void UpdateAI(const uint32 diff) + { + if(TeleTimer < diff) + { + if(PlayerGuid) + { + Player* player = ((Player*)Unit::GetUnit((*m_creature), PlayerGuid)); + + if(m_creature->GetDistance(player)<3) + { + if(player->GetTeam()== ALLIANCE && player->GetQuestRewardStatus(10589)) + player->CastSpell(player,SPELL_TELE_A_TO,false); + if(player->GetTeam()== HORDE && player->GetQuestRewardStatus(10604)) + player->CastSpell(player,SPELL_TELE_H_TO,false); + } + PlayerGuid=0; + } + TeleTimer = 5000; + }else TeleTimer -= diff; + } +}; +CreatureAI* GetAI_npc_invis_legion_teleporter(Creature *_Creature) +{ + return new npc_invis_legion_teleporterAI (_Creature); +} + +/*###### +## npc_flanis_swiftwing_and_kagrosh +######*/ + +bool GossipHello_npcs_flanis_swiftwing_and_kagrosh(Player *player, Creature *_Creature) +{ + if (player->GetQuestStatus(10583) == QUEST_STATUS_INCOMPLETE && !player->HasItemCount(30658,1,true)) + player->ADD_GOSSIP_ITEM( 0, "Take Flanis's Pack", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); + if (player->GetQuestStatus(10601) == QUEST_STATUS_INCOMPLETE && !player->HasItemCount(30659,1,true)) + player->ADD_GOSSIP_ITEM( 0, "Take Kagrosh's Pack", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2); + + player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); + + return true; +} + +bool GossipSelect_npcs_flanis_swiftwing_and_kagrosh(Player *player, Creature *_Creature, uint32 sender, uint32 action) +{ + if (action == GOSSIP_ACTION_INFO_DEF+1) + { + ItemPosCountVec dest; + uint8 msg = player->CanStoreNewItem( NULL_BAG, NULL_SLOT, dest, 30658, 1, false); + if( msg == EQUIP_ERR_OK ) + { + player->StoreNewItem( dest, 30658, 1, true); + player->PlayerTalkClass->ClearMenus(); + } + } + if (action == GOSSIP_ACTION_INFO_DEF+2) + { + ItemPosCountVec dest; + uint8 msg = player->CanStoreNewItem( NULL_BAG, NULL_SLOT, dest, 30659, 1, false); + if( msg == EQUIP_ERR_OK ) + { + player->StoreNewItem( dest, 30659, 1, true); + player->PlayerTalkClass->ClearMenus(); + } + } + return true; +} + +/*###### +## npc_murkblood_overseer +######*/ + +#define QUEST_11082 11082 + +bool GossipHello_npc_murkblood_overseer(Player *player, Creature *_Creature) +{ + if (player->GetQuestStatus(QUEST_11082) == QUEST_STATUS_INCOMPLETE) + player->ADD_GOSSIP_ITEM( 0, "I am here for you, overseer.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); + + player->SEND_GOSSIP_MENU(10940, _Creature->GetGUID()); + return true; +} + +bool GossipSelect_npc_murkblood_overseer(Player *player, Creature *_Creature, uint32 sender, uint32 action) +{ + switch (action) + { + case GOSSIP_ACTION_INFO_DEF+1: + player->ADD_GOSSIP_ITEM(0, "How dare you question an overseer of the Dragonmaw!", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2); + //correct id not known + player->SEND_GOSSIP_MENU(10940, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+2: + player->ADD_GOSSIP_ITEM(0, "Who speaks of me? What are you talking about, broken?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+3); + //correct id not known + player->SEND_GOSSIP_MENU(10940, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+3: + player->ADD_GOSSIP_ITEM(0, "Continue please.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+4); + //correct id not known + player->SEND_GOSSIP_MENU(10940, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+4: + player->ADD_GOSSIP_ITEM(0, "Who are these bidders?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+5); + //correct id not known + player->SEND_GOSSIP_MENU(10940, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+5: + player->ADD_GOSSIP_ITEM(0, "Well... yes.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+6); + //correct id not known + player->SEND_GOSSIP_MENU(10940, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+6: + //correct id not known + player->SEND_GOSSIP_MENU(10940, _Creature->GetGUID()); + _Creature->CastSpell(player,41121,false); + player->AreaExploredOrEventHappens(QUEST_11082); + break; + } + return true; +} + +/*###### +## npc_neltharaku +######*/ + +bool GossipHello_npc_neltharaku(Player *player, Creature *_Creature) +{ + if (_Creature->isQuestGiver()) + player->PrepareQuestMenu( _Creature->GetGUID() ); + + if (player->GetQuestStatus(10814) == QUEST_STATUS_INCOMPLETE) + player->ADD_GOSSIP_ITEM( 0, "I am listening, dragon", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); + + player->SEND_GOSSIP_MENU(10613, _Creature->GetGUID()); + + return true; +} + +bool GossipSelect_npc_neltharaku(Player *player, Creature *_Creature, uint32 sender, uint32 action) +{ + switch (action) + { + case GOSSIP_ACTION_INFO_DEF+1: + player->ADD_GOSSIP_ITEM( 0, "But you are dragons! How could orcs do this to you?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2); + player->SEND_GOSSIP_MENU(10614, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+2: + player->ADD_GOSSIP_ITEM( 0, "Your mate?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+3); + player->SEND_GOSSIP_MENU(10615, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+3: + player->ADD_GOSSIP_ITEM( 0, "I have battled many beasts, dragon. I will help you.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+4); + player->SEND_GOSSIP_MENU(10616, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+4: + player->CLOSE_GOSSIP_MENU(); + player->AreaExploredOrEventHappens(10814); + break; + } + return true; +} + +/*###### +## npc_oronok +######*/ + +#define GOSSIP_ORONOK1 "I am ready to hear your story, Oronok." +#define GOSSIP_ORONOK2 "How do I find the cipher?" +#define GOSSIP_ORONOK3 "How do you know all of this?" +#define GOSSIP_ORONOK4 "Yet what? What is it, Oronok?" +#define GOSSIP_ORONOK5 "Continue, please." +#define GOSSIP_ORONOK6 "So what of the cipher now? And your boys?" +#define GOSSIP_ORONOK7 "I will find your boys and the cipher, Oronok." + +bool GossipHello_npc_oronok_tornheart(Player *player, Creature *_Creature) +{ + if (_Creature->isQuestGiver()) + player->PrepareQuestMenu( _Creature->GetGUID() ); + if (_Creature->isVendor()) + player->ADD_GOSSIP_ITEM(1, GOSSIP_TEXT_BROWSE_GOODS, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_TRADE); + + if (player->GetQuestStatus(10519) == QUEST_STATUS_INCOMPLETE) + { + player->ADD_GOSSIP_ITEM( 0, GOSSIP_ORONOK1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF); + player->SEND_GOSSIP_MENU(10312, _Creature->GetGUID()); + }else + player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); + + return true; +} + +bool GossipSelect_npc_oronok_tornheart(Player *player, Creature *_Creature, uint32 sender, uint32 action) +{ + switch (action) + { + case GOSSIP_ACTION_TRADE: + player->SEND_VENDORLIST( _Creature->GetGUID() ); + break; + case GOSSIP_ACTION_INFO_DEF: + player->ADD_GOSSIP_ITEM( 0, GOSSIP_ORONOK2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); + player->SEND_GOSSIP_MENU(10313, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+1: + player->ADD_GOSSIP_ITEM( 0, GOSSIP_ORONOK3, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2); + player->SEND_GOSSIP_MENU(10314, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+2: + player->ADD_GOSSIP_ITEM( 0, GOSSIP_ORONOK4, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+3); + player->SEND_GOSSIP_MENU(10315, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+3: + player->ADD_GOSSIP_ITEM( 0, GOSSIP_ORONOK5, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+4); + player->SEND_GOSSIP_MENU(10316, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+4: + player->ADD_GOSSIP_ITEM( 0, GOSSIP_ORONOK6, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+5); + player->SEND_GOSSIP_MENU(10317, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+5: + player->ADD_GOSSIP_ITEM( 0, GOSSIP_ORONOK7, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+6); + player->SEND_GOSSIP_MENU(10318, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+6: + player->CLOSE_GOSSIP_MENU(); + player->AreaExploredOrEventHappens(10519); + break; + } + return true; +} + +/*#### +# npc_karynaku +####*/ + +bool QuestAccept_npc_karynaku(Player* player, Creature* creature, Quest const* quest) +{ + if(quest->GetQuestId() == 10870) // Ally of the Netherwing + { + std::vector nodes; + + nodes.resize(2); + nodes[0] = 161; // From Karynaku + nodes[1] = 162; // To Mordenai + error_log("SD2: Player %s started quest 10870 which has disabled taxi node, need to be fixed in core", player->GetName()); + //player->ActivateTaxiPathTo(nodes, 20811); + } + + return true; +} + +void AddSC_shadowmoon_valley() +{ + Script *newscript; + + newscript = new Script; + newscript->Name = "mob_mature_netherwing_drake"; + newscript->GetAI = GetAI_mob_mature_netherwing_drake; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name = "mob_enslaved_netherwing_drake"; + newscript->GetAI = GetAI_mob_enslaved_netherwing_drake; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="npc_drake_dealer_hurlunk"; + newscript->pGossipHello = &GossipHello_npc_drake_dealer_hurlunk; + newscript->pGossipSelect = &GossipSelect_npc_drake_dealer_hurlunk; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="npc_invis_legion_teleporter"; + newscript->GetAI = GetAI_npc_invis_legion_teleporter; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="npcs_flanis_swiftwing_and_kagrosh"; + newscript->pGossipHello = &GossipHello_npcs_flanis_swiftwing_and_kagrosh; + newscript->pGossipSelect = &GossipSelect_npcs_flanis_swiftwing_and_kagrosh; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="npc_murkblood_overseer"; + newscript->pGossipHello = &GossipHello_npc_murkblood_overseer; + newscript->pGossipSelect = &GossipSelect_npc_murkblood_overseer; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="npc_neltharaku"; + newscript->pGossipHello = &GossipHello_npc_neltharaku; + newscript->pGossipSelect = &GossipSelect_npc_neltharaku; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name = "npc_karynaku"; + newscript->pQuestAccept = &QuestAccept_npc_karynaku; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="npc_oronok_tornheart"; + newscript->pGossipHello = &GossipHello_npc_oronok_tornheart; + newscript->pGossipSelect = &GossipSelect_npc_oronok_tornheart; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/shattrath/shattrath_city.cpp b/src/bindings/scripts/scripts/zone/shattrath/shattrath_city.cpp index 8ad5a6e6321..c731edf08fe 100644 --- a/src/bindings/scripts/scripts/zone/shattrath/shattrath_city.cpp +++ b/src/bindings/scripts/scripts/zone/shattrath/shattrath_city.cpp @@ -1,268 +1,268 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Shattrath_City -SD%Complete: 100 -SDComment: Quest support: 10004, 10009. Flask vendors, Teleport to Caverns of Time -SDCategory: Shattrath City -EndScriptData */ - -/* ContentData -npc_raliq_the_drunk -npc_salsalabim -npc_shattrathflaskvendors -npc_zephyr -EndContentData */ - -#include "precompiled.h" - -/*###### -## npc_raliq_the_drunk -######*/ - -#define GOSSIP_RALIQ "You owe Sim'salabim money. Hand them over or die!" - -#define FACTION_HOSTILE_RD 45 -#define FACTION_FRIENDLY_RD 35 - -#define SPELL_UPPERCUT 10966 - -struct MANGOS_DLL_DECL npc_raliq_the_drunkAI : public ScriptedAI -{ - npc_raliq_the_drunkAI(Creature* c) : ScriptedAI(c) { Reset(); } - - uint32 Uppercut_Timer; - - void Reset() - { - Uppercut_Timer = 5000; - m_creature->setFaction(FACTION_FRIENDLY_RD); - } - - void Aggro(Unit *who) {} - - void UpdateAI(const uint32 diff) - { - if(!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - if( Uppercut_Timer < diff ) - { - DoCast(m_creature->getVictim(),SPELL_UPPERCUT); - Uppercut_Timer = 15000; - }else Uppercut_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; -CreatureAI* GetAI_npc_raliq_the_drunk(Creature *_Creature) -{ - return new npc_raliq_the_drunkAI (_Creature); -} - -bool GossipHello_npc_raliq_the_drunk(Player *player, Creature *_Creature ) -{ - if( player->GetQuestStatus(10009) == QUEST_STATUS_INCOMPLETE ) - player->ADD_GOSSIP_ITEM(1, GOSSIP_RALIQ, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); - - player->SEND_GOSSIP_MENU(9440, _Creature->GetGUID()); - return true; -} - -bool GossipSelect_npc_raliq_the_drunk(Player *player, Creature *_Creature, uint32 sender, uint32 action ) -{ - if( action == GOSSIP_ACTION_INFO_DEF+1 ) - { - player->CLOSE_GOSSIP_MENU(); - _Creature->setFaction(FACTION_HOSTILE_RD); - ((npc_raliq_the_drunkAI*)_Creature->AI())->AttackStart(player); - } - return true; -} - -/*###### -# npc_salsalabim -######*/ - -#define FACTION_HOSTILE_SA 90 -#define FACTION_FRIENDLY_SA 35 -#define QUEST_10004 10004 - -#define SPELL_MAGNETIC_PULL 31705 - -struct MANGOS_DLL_DECL npc_salsalabimAI : public ScriptedAI -{ - npc_salsalabimAI(Creature* c) : ScriptedAI(c) { Reset(); } - - uint32 MagneticPull_Timer; - - void Reset() - { - MagneticPull_Timer = 15000; - m_creature->setFaction(FACTION_FRIENDLY_SA); - } - - void Aggro(Unit *who) {} - - void DamageTaken(Unit *done_by, uint32 &damage) - { - if( done_by->GetTypeId() == TYPEID_PLAYER ) - if( (m_creature->GetHealth()-damage)*100 / m_creature->GetMaxHealth() < 20 ) - { - ((Player*)done_by)->GroupEventHappens(QUEST_10004,m_creature); - damage = 0; - EnterEvadeMode(); - } - } - - void UpdateAI(const uint32 diff) - { - if(!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - if( MagneticPull_Timer < diff ) - { - DoCast(m_creature->getVictim(),SPELL_MAGNETIC_PULL); - MagneticPull_Timer = 15000; - }else MagneticPull_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; -CreatureAI* GetAI_npc_salsalabim(Creature *_Creature) -{ - return new npc_salsalabimAI (_Creature); -} - -bool GossipHello_npc_salsalabim(Player *player, Creature *_Creature) -{ - if( player->GetQuestStatus(QUEST_10004) == QUEST_STATUS_INCOMPLETE ) - { - _Creature->setFaction(FACTION_HOSTILE_SA); - ((npc_salsalabimAI*)_Creature->AI())->AttackStart(player); - } - else - { - if( _Creature->isQuestGiver() ) - player->PrepareQuestMenu( _Creature->GetGUID() ); - player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); - } - return true; -} - -/* -################################################## -Shattrath City Flask Vendors provides flasks to people exalted with 3 factions: -Haldor the Compulsive -Arcanist Xorith -Both sell special flasks for use in Outlands 25man raids only, -purchasable for one Mark of Illidari each -Purchase requires exalted reputation with Scryers/Aldor, Cenarion Expedition and The Sha'tar -################################################## -*/ - -bool GossipHello_npc_shattrathflaskvendors(Player *player, Creature *_Creature) -{ - if(_Creature->GetEntry() == 23484) - { - // Aldor vendor - if( _Creature->isVendor() && (player->GetReputationRank(932) == REP_EXALTED) && (player->GetReputationRank(935) == REP_EXALTED) && (player->GetReputationRank(942) == REP_EXALTED) ) - { - player->ADD_GOSSIP_ITEM(1, GOSSIP_TEXT_BROWSE_GOODS, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_TRADE); - player->SEND_GOSSIP_MENU(11085, _Creature->GetGUID()); - } - else - { - player->SEND_GOSSIP_MENU(11083, _Creature->GetGUID()); - } - } - - if(_Creature->GetEntry() == 23483) - { - // Scryers vendor - if( _Creature->isVendor() && (player->GetReputationRank(934) == REP_EXALTED) && (player->GetReputationRank(935) == REP_EXALTED) && (player->GetReputationRank(942) == REP_EXALTED) ) - { - player->ADD_GOSSIP_ITEM(1, GOSSIP_TEXT_BROWSE_GOODS, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_TRADE); - player->SEND_GOSSIP_MENU(11085, _Creature->GetGUID()); - } - else - { - player->SEND_GOSSIP_MENU(11084, _Creature->GetGUID()); - } - } - - return true; -} - -bool GossipSelect_npc_shattrathflaskvendors(Player *player, Creature *_Creature, uint32 sender, uint32 action) -{ - if( action == GOSSIP_ACTION_TRADE ) - player->SEND_VENDORLIST( _Creature->GetGUID() ); - - return true; -} - -/*###### -# npc_zephyr -######*/ - -bool GossipHello_npc_zephyr(Player *player, Creature *_Creature) -{ - if( player->GetReputationRank(989) >= REP_REVERED ) - player->ADD_GOSSIP_ITEM(0, "Take me to the Caverns of Time.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); - - player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); - - return true; -} - -bool GossipSelect_npc_zephyr(Player *player, Creature *_Creature, uint32 sender, uint32 action) -{ - if( action == GOSSIP_ACTION_INFO_DEF+1 ) - player->CastSpell(player,37778,false); - - return true; -} - -void AddSC_shattrath_city() -{ - Script *newscript; - - newscript = new Script; - newscript->Name="npc_raliq_the_drunk"; - newscript->pGossipHello = &GossipHello_npc_raliq_the_drunk; - newscript->pGossipSelect = &GossipSelect_npc_raliq_the_drunk; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="npc_salsalabim"; - newscript->GetAI = GetAI_npc_salsalabim; - newscript->pGossipHello = &GossipHello_npc_salsalabim; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="npc_shattrathflaskvendors"; - newscript->pGossipHello = &GossipHello_npc_shattrathflaskvendors; - newscript->pGossipSelect = &GossipSelect_npc_shattrathflaskvendors; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="npc_zephyr"; - newscript->pGossipHello = &GossipHello_npc_zephyr; - newscript->pGossipSelect = &GossipSelect_npc_zephyr; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Shattrath_City +SD%Complete: 100 +SDComment: Quest support: 10004, 10009. Flask vendors, Teleport to Caverns of Time +SDCategory: Shattrath City +EndScriptData */ + +/* ContentData +npc_raliq_the_drunk +npc_salsalabim +npc_shattrathflaskvendors +npc_zephyr +EndContentData */ + +#include "precompiled.h" + +/*###### +## npc_raliq_the_drunk +######*/ + +#define GOSSIP_RALIQ "You owe Sim'salabim money. Hand them over or die!" + +#define FACTION_HOSTILE_RD 45 +#define FACTION_FRIENDLY_RD 35 + +#define SPELL_UPPERCUT 10966 + +struct MANGOS_DLL_DECL npc_raliq_the_drunkAI : public ScriptedAI +{ + npc_raliq_the_drunkAI(Creature* c) : ScriptedAI(c) { Reset(); } + + uint32 Uppercut_Timer; + + void Reset() + { + Uppercut_Timer = 5000; + m_creature->setFaction(FACTION_FRIENDLY_RD); + } + + void Aggro(Unit *who) {} + + void UpdateAI(const uint32 diff) + { + if(!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + if( Uppercut_Timer < diff ) + { + DoCast(m_creature->getVictim(),SPELL_UPPERCUT); + Uppercut_Timer = 15000; + }else Uppercut_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; +CreatureAI* GetAI_npc_raliq_the_drunk(Creature *_Creature) +{ + return new npc_raliq_the_drunkAI (_Creature); +} + +bool GossipHello_npc_raliq_the_drunk(Player *player, Creature *_Creature ) +{ + if( player->GetQuestStatus(10009) == QUEST_STATUS_INCOMPLETE ) + player->ADD_GOSSIP_ITEM(1, GOSSIP_RALIQ, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); + + player->SEND_GOSSIP_MENU(9440, _Creature->GetGUID()); + return true; +} + +bool GossipSelect_npc_raliq_the_drunk(Player *player, Creature *_Creature, uint32 sender, uint32 action ) +{ + if( action == GOSSIP_ACTION_INFO_DEF+1 ) + { + player->CLOSE_GOSSIP_MENU(); + _Creature->setFaction(FACTION_HOSTILE_RD); + ((npc_raliq_the_drunkAI*)_Creature->AI())->AttackStart(player); + } + return true; +} + +/*###### +# npc_salsalabim +######*/ + +#define FACTION_HOSTILE_SA 90 +#define FACTION_FRIENDLY_SA 35 +#define QUEST_10004 10004 + +#define SPELL_MAGNETIC_PULL 31705 + +struct MANGOS_DLL_DECL npc_salsalabimAI : public ScriptedAI +{ + npc_salsalabimAI(Creature* c) : ScriptedAI(c) { Reset(); } + + uint32 MagneticPull_Timer; + + void Reset() + { + MagneticPull_Timer = 15000; + m_creature->setFaction(FACTION_FRIENDLY_SA); + } + + void Aggro(Unit *who) {} + + void DamageTaken(Unit *done_by, uint32 &damage) + { + if( done_by->GetTypeId() == TYPEID_PLAYER ) + if( (m_creature->GetHealth()-damage)*100 / m_creature->GetMaxHealth() < 20 ) + { + ((Player*)done_by)->GroupEventHappens(QUEST_10004,m_creature); + damage = 0; + EnterEvadeMode(); + } + } + + void UpdateAI(const uint32 diff) + { + if(!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + if( MagneticPull_Timer < diff ) + { + DoCast(m_creature->getVictim(),SPELL_MAGNETIC_PULL); + MagneticPull_Timer = 15000; + }else MagneticPull_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; +CreatureAI* GetAI_npc_salsalabim(Creature *_Creature) +{ + return new npc_salsalabimAI (_Creature); +} + +bool GossipHello_npc_salsalabim(Player *player, Creature *_Creature) +{ + if( player->GetQuestStatus(QUEST_10004) == QUEST_STATUS_INCOMPLETE ) + { + _Creature->setFaction(FACTION_HOSTILE_SA); + ((npc_salsalabimAI*)_Creature->AI())->AttackStart(player); + } + else + { + if( _Creature->isQuestGiver() ) + player->PrepareQuestMenu( _Creature->GetGUID() ); + player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); + } + return true; +} + +/* +################################################## +Shattrath City Flask Vendors provides flasks to people exalted with 3 factions: +Haldor the Compulsive +Arcanist Xorith +Both sell special flasks for use in Outlands 25man raids only, +purchasable for one Mark of Illidari each +Purchase requires exalted reputation with Scryers/Aldor, Cenarion Expedition and The Sha'tar +################################################## +*/ + +bool GossipHello_npc_shattrathflaskvendors(Player *player, Creature *_Creature) +{ + if(_Creature->GetEntry() == 23484) + { + // Aldor vendor + if( _Creature->isVendor() && (player->GetReputationRank(932) == REP_EXALTED) && (player->GetReputationRank(935) == REP_EXALTED) && (player->GetReputationRank(942) == REP_EXALTED) ) + { + player->ADD_GOSSIP_ITEM(1, GOSSIP_TEXT_BROWSE_GOODS, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_TRADE); + player->SEND_GOSSIP_MENU(11085, _Creature->GetGUID()); + } + else + { + player->SEND_GOSSIP_MENU(11083, _Creature->GetGUID()); + } + } + + if(_Creature->GetEntry() == 23483) + { + // Scryers vendor + if( _Creature->isVendor() && (player->GetReputationRank(934) == REP_EXALTED) && (player->GetReputationRank(935) == REP_EXALTED) && (player->GetReputationRank(942) == REP_EXALTED) ) + { + player->ADD_GOSSIP_ITEM(1, GOSSIP_TEXT_BROWSE_GOODS, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_TRADE); + player->SEND_GOSSIP_MENU(11085, _Creature->GetGUID()); + } + else + { + player->SEND_GOSSIP_MENU(11084, _Creature->GetGUID()); + } + } + + return true; +} + +bool GossipSelect_npc_shattrathflaskvendors(Player *player, Creature *_Creature, uint32 sender, uint32 action) +{ + if( action == GOSSIP_ACTION_TRADE ) + player->SEND_VENDORLIST( _Creature->GetGUID() ); + + return true; +} + +/*###### +# npc_zephyr +######*/ + +bool GossipHello_npc_zephyr(Player *player, Creature *_Creature) +{ + if( player->GetReputationRank(989) >= REP_REVERED ) + player->ADD_GOSSIP_ITEM(0, "Take me to the Caverns of Time.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); + + player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); + + return true; +} + +bool GossipSelect_npc_zephyr(Player *player, Creature *_Creature, uint32 sender, uint32 action) +{ + if( action == GOSSIP_ACTION_INFO_DEF+1 ) + player->CastSpell(player,37778,false); + + return true; +} + +void AddSC_shattrath_city() +{ + Script *newscript; + + newscript = new Script; + newscript->Name="npc_raliq_the_drunk"; + newscript->pGossipHello = &GossipHello_npc_raliq_the_drunk; + newscript->pGossipSelect = &GossipSelect_npc_raliq_the_drunk; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="npc_salsalabim"; + newscript->GetAI = GetAI_npc_salsalabim; + newscript->pGossipHello = &GossipHello_npc_salsalabim; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="npc_shattrathflaskvendors"; + newscript->pGossipHello = &GossipHello_npc_shattrathflaskvendors; + newscript->pGossipSelect = &GossipSelect_npc_shattrathflaskvendors; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="npc_zephyr"; + newscript->pGossipHello = &GossipHello_npc_zephyr; + newscript->pGossipSelect = &GossipSelect_npc_zephyr; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/silithus/silithus.cpp b/src/bindings/scripts/scripts/zone/silithus/silithus.cpp index 8b7681d0557..fec0619509d 100644 --- a/src/bindings/scripts/scripts/zone/silithus/silithus.cpp +++ b/src/bindings/scripts/scripts/zone/silithus/silithus.cpp @@ -1,149 +1,149 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Silithus -SD%Complete: 100 -SDComment: Quest support: 8304. -SDCategory: Silithus -EndScriptData */ - -/* ContentData -npcs_rutgar_and_frankal -EndContentData */ - -#include "precompiled.h" - -/*### -## npcs_rutgar_and_frankal -###*/ - -//gossip item text best guess -#define GOSSIP_ITEM1 "I seek information about Natalia" - -#define GOSSIP_ITEM2 "That sounds dangerous!" -#define GOSSIP_ITEM3 "What did you do?" -#define GOSSIP_ITEM4 "Who?" -#define GOSSIP_ITEM5 "Women do that. What did she demand?" -#define GOSSIP_ITEM6 "What do you mean?" -#define GOSSIP_ITEM7 "What happened next?" - -#define GOSSIP_ITEM11 "Yes, please continue" -#define GOSSIP_ITEM12 "What language?" -#define GOSSIP_ITEM13 "The Priestess attacked you?!" -#define GOSSIP_ITEM14 "I should ask the monkey about this" -#define GOSSIP_ITEM15 "Then what..." - -//trigger creatures to kill -#define TRIGGER_RUTGAR 15222 -#define TRIGGER_FRANKAL 15221 - -bool GossipHello_npcs_rutgar_and_frankal(Player *player, Creature *_Creature) -{ - if (_Creature->isQuestGiver()) - player->PrepareQuestMenu( _Creature->GetGUID() ); - - if (player->GetQuestStatus(8304) == QUEST_STATUS_INCOMPLETE && - _Creature->GetEntry() == 15170 && - !player->GetReqKillOrCastCurrentCount(8304, TRIGGER_RUTGAR )) - player->ADD_GOSSIP_ITEM(0, GOSSIP_ITEM1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF); - - if (player->GetQuestStatus(8304) == QUEST_STATUS_INCOMPLETE && - _Creature->GetEntry() == 15171 && - player->GetReqKillOrCastCurrentCount(8304, TRIGGER_RUTGAR )) - player->ADD_GOSSIP_ITEM(0, GOSSIP_ITEM1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+9); - - player->SEND_GOSSIP_MENU(7754, _Creature->GetGUID()); - - return true; -} - -bool GossipSelect_npcs_rutgar_and_frankal(Player *player, Creature *_Creature, uint32 sender, uint32 action ) -{ - switch (action) - { - case GOSSIP_ACTION_INFO_DEF: - player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); - player->SEND_GOSSIP_MENU(7755, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 1: - player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM3, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2); - player->SEND_GOSSIP_MENU(7756, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 2: - player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM4, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 3); - player->SEND_GOSSIP_MENU(7757, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 3: - player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM5, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 4); - player->SEND_GOSSIP_MENU(7758, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 4: - player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM6, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 5); - player->SEND_GOSSIP_MENU(7759, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 5: - player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM7, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 6); - player->SEND_GOSSIP_MENU(7760, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 6: - player->SEND_GOSSIP_MENU(7761, _Creature->GetGUID()); - //'kill' our trigger to update quest status - player->KilledMonster( TRIGGER_RUTGAR, _Creature->GetGUID() ); - break; - - case GOSSIP_ACTION_INFO_DEF + 9: - player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM11, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 11); - player->SEND_GOSSIP_MENU(7762, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 10: - player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM12, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 11); - player->SEND_GOSSIP_MENU(7763, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 11: - player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM13, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 12); - player->SEND_GOSSIP_MENU(7764, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 12: - player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM14, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 13); - player->SEND_GOSSIP_MENU(7765, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 13: - player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM15, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 14); - player->SEND_GOSSIP_MENU(7766, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 14: - player->SEND_GOSSIP_MENU(7767, _Creature->GetGUID()); - //'kill' our trigger to update quest status - player->KilledMonster( TRIGGER_FRANKAL, _Creature->GetGUID() ); - break; - } - return true; -} - -/*### -## -####*/ - -void AddSC_silithus() -{ - Script *newscript; - newscript = new Script; - newscript->Name="npcs_rutgar_and_frankal"; - newscript->pGossipHello = &GossipHello_npcs_rutgar_and_frankal; - newscript->pGossipSelect = &GossipSelect_npcs_rutgar_and_frankal; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Silithus +SD%Complete: 100 +SDComment: Quest support: 8304. +SDCategory: Silithus +EndScriptData */ + +/* ContentData +npcs_rutgar_and_frankal +EndContentData */ + +#include "precompiled.h" + +/*### +## npcs_rutgar_and_frankal +###*/ + +//gossip item text best guess +#define GOSSIP_ITEM1 "I seek information about Natalia" + +#define GOSSIP_ITEM2 "That sounds dangerous!" +#define GOSSIP_ITEM3 "What did you do?" +#define GOSSIP_ITEM4 "Who?" +#define GOSSIP_ITEM5 "Women do that. What did she demand?" +#define GOSSIP_ITEM6 "What do you mean?" +#define GOSSIP_ITEM7 "What happened next?" + +#define GOSSIP_ITEM11 "Yes, please continue" +#define GOSSIP_ITEM12 "What language?" +#define GOSSIP_ITEM13 "The Priestess attacked you?!" +#define GOSSIP_ITEM14 "I should ask the monkey about this" +#define GOSSIP_ITEM15 "Then what..." + +//trigger creatures to kill +#define TRIGGER_RUTGAR 15222 +#define TRIGGER_FRANKAL 15221 + +bool GossipHello_npcs_rutgar_and_frankal(Player *player, Creature *_Creature) +{ + if (_Creature->isQuestGiver()) + player->PrepareQuestMenu( _Creature->GetGUID() ); + + if (player->GetQuestStatus(8304) == QUEST_STATUS_INCOMPLETE && + _Creature->GetEntry() == 15170 && + !player->GetReqKillOrCastCurrentCount(8304, TRIGGER_RUTGAR )) + player->ADD_GOSSIP_ITEM(0, GOSSIP_ITEM1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF); + + if (player->GetQuestStatus(8304) == QUEST_STATUS_INCOMPLETE && + _Creature->GetEntry() == 15171 && + player->GetReqKillOrCastCurrentCount(8304, TRIGGER_RUTGAR )) + player->ADD_GOSSIP_ITEM(0, GOSSIP_ITEM1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+9); + + player->SEND_GOSSIP_MENU(7754, _Creature->GetGUID()); + + return true; +} + +bool GossipSelect_npcs_rutgar_and_frankal(Player *player, Creature *_Creature, uint32 sender, uint32 action ) +{ + switch (action) + { + case GOSSIP_ACTION_INFO_DEF: + player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); + player->SEND_GOSSIP_MENU(7755, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 1: + player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM3, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2); + player->SEND_GOSSIP_MENU(7756, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 2: + player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM4, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 3); + player->SEND_GOSSIP_MENU(7757, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 3: + player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM5, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 4); + player->SEND_GOSSIP_MENU(7758, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 4: + player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM6, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 5); + player->SEND_GOSSIP_MENU(7759, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 5: + player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM7, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 6); + player->SEND_GOSSIP_MENU(7760, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 6: + player->SEND_GOSSIP_MENU(7761, _Creature->GetGUID()); + //'kill' our trigger to update quest status + player->KilledMonster( TRIGGER_RUTGAR, _Creature->GetGUID() ); + break; + + case GOSSIP_ACTION_INFO_DEF + 9: + player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM11, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 11); + player->SEND_GOSSIP_MENU(7762, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 10: + player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM12, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 11); + player->SEND_GOSSIP_MENU(7763, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 11: + player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM13, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 12); + player->SEND_GOSSIP_MENU(7764, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 12: + player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM14, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 13); + player->SEND_GOSSIP_MENU(7765, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 13: + player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM15, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 14); + player->SEND_GOSSIP_MENU(7766, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 14: + player->SEND_GOSSIP_MENU(7767, _Creature->GetGUID()); + //'kill' our trigger to update quest status + player->KilledMonster( TRIGGER_FRANKAL, _Creature->GetGUID() ); + break; + } + return true; +} + +/*### +## +####*/ + +void AddSC_silithus() +{ + Script *newscript; + newscript = new Script; + newscript->Name="npcs_rutgar_and_frankal"; + newscript->pGossipHello = &GossipHello_npcs_rutgar_and_frankal; + newscript->pGossipSelect = &GossipSelect_npcs_rutgar_and_frankal; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/silvermoon/silvermoon_city.cpp b/src/bindings/scripts/scripts/zone/silvermoon/silvermoon_city.cpp index 1a237eefde0..11fcbbcfc5d 100644 --- a/src/bindings/scripts/scripts/zone/silvermoon/silvermoon_city.cpp +++ b/src/bindings/scripts/scripts/zone/silvermoon/silvermoon_city.cpp @@ -1,103 +1,103 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Silvermoon_City -SD%Complete: 100 -SDComment: Quest support: 9685 -SDCategory: Silvermoon City -EndScriptData */ - -/* ContentData -npc_blood_knight_stillblade -EndContentData */ - -#include "precompiled.h" - -/*####### -# npc_blood_knight_stillblade -#######*/ - -#define SAY_HEAL "Thank you, dear Paladin, you just saved my life." - -#define QUEST_REDEEMING_THE_DEAD 9685 -#define SPELL_SHIMMERING_VESSEL 31225 -#define SPELL_REVIVE_SELF 32343 - -struct MANGOS_DLL_DECL npc_blood_knight_stillbladeAI : public ScriptedAI -{ - npc_blood_knight_stillbladeAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 lifeTimer; - bool spellHit; - - void Reset() - { - lifeTimer = 120000; - m_creature->SetUInt32Value(UNIT_DYNAMIC_FLAGS, 32); - m_creature->SetUInt32Value(UNIT_FIELD_BYTES_1,7); // lay down - spellHit = false; - } - - void Aggro(Unit *who) - { - } - - void MoveInLineOfSight(Unit *who) - { - return; - } - - void UpdateAI(const uint32 diff) - { - if (!m_creature->GetUInt32Value(UNIT_FIELD_BYTES_1)) - { - if(lifeTimer < diff) - m_creature->AI()->EnterEvadeMode(); - else - lifeTimer -= diff; - } - } - - void SpellHit(Unit *Hitter, const SpellEntry *Spellkind) - { - if((Spellkind->Id == SPELL_SHIMMERING_VESSEL) && !spellHit && - (Hitter->GetTypeId() == TYPEID_PLAYER) && (((Player*)Hitter)->IsActiveQuest(QUEST_REDEEMING_THE_DEAD))) - { - ((Player*)Hitter)->AreaExploredOrEventHappens(QUEST_REDEEMING_THE_DEAD); - DoCast(m_creature,SPELL_REVIVE_SELF); - m_creature->SetUInt32Value(UNIT_FIELD_BYTES_1,0); - m_creature->SetUInt32Value(UNIT_DYNAMIC_FLAGS, 0); - //m_creature->RemoveAllAuras(); - DoSay(SAY_HEAL,LANG_COMMON,NULL); - spellHit = true; - } - } -}; - -CreatureAI* GetAI_npc_blood_knight_stillblade(Creature *_Creature) -{ - return new npc_blood_knight_stillbladeAI (_Creature); -} - -void AddSC_silvermoon_city() -{ - Script *newscript; - newscript = new Script; - newscript->Name="npc_blood_knight_stillblade"; - newscript->GetAI = GetAI_npc_blood_knight_stillblade; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Silvermoon_City +SD%Complete: 100 +SDComment: Quest support: 9685 +SDCategory: Silvermoon City +EndScriptData */ + +/* ContentData +npc_blood_knight_stillblade +EndContentData */ + +#include "precompiled.h" + +/*####### +# npc_blood_knight_stillblade +#######*/ + +#define SAY_HEAL "Thank you, dear Paladin, you just saved my life." + +#define QUEST_REDEEMING_THE_DEAD 9685 +#define SPELL_SHIMMERING_VESSEL 31225 +#define SPELL_REVIVE_SELF 32343 + +struct MANGOS_DLL_DECL npc_blood_knight_stillbladeAI : public ScriptedAI +{ + npc_blood_knight_stillbladeAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 lifeTimer; + bool spellHit; + + void Reset() + { + lifeTimer = 120000; + m_creature->SetUInt32Value(UNIT_DYNAMIC_FLAGS, 32); + m_creature->SetUInt32Value(UNIT_FIELD_BYTES_1,7); // lay down + spellHit = false; + } + + void Aggro(Unit *who) + { + } + + void MoveInLineOfSight(Unit *who) + { + return; + } + + void UpdateAI(const uint32 diff) + { + if (!m_creature->GetUInt32Value(UNIT_FIELD_BYTES_1)) + { + if(lifeTimer < diff) + m_creature->AI()->EnterEvadeMode(); + else + lifeTimer -= diff; + } + } + + void SpellHit(Unit *Hitter, const SpellEntry *Spellkind) + { + if((Spellkind->Id == SPELL_SHIMMERING_VESSEL) && !spellHit && + (Hitter->GetTypeId() == TYPEID_PLAYER) && (((Player*)Hitter)->IsActiveQuest(QUEST_REDEEMING_THE_DEAD))) + { + ((Player*)Hitter)->AreaExploredOrEventHappens(QUEST_REDEEMING_THE_DEAD); + DoCast(m_creature,SPELL_REVIVE_SELF); + m_creature->SetUInt32Value(UNIT_FIELD_BYTES_1,0); + m_creature->SetUInt32Value(UNIT_DYNAMIC_FLAGS, 0); + //m_creature->RemoveAllAuras(); + DoSay(SAY_HEAL,LANG_COMMON,NULL); + spellHit = true; + } + } +}; + +CreatureAI* GetAI_npc_blood_knight_stillblade(Creature *_Creature) +{ + return new npc_blood_knight_stillbladeAI (_Creature); +} + +void AddSC_silvermoon_city() +{ + Script *newscript; + newscript = new Script; + newscript->Name="npc_blood_knight_stillblade"; + newscript->GetAI = GetAI_npc_blood_knight_stillblade; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/silverpine_forest/silverpine_forest.cpp b/src/bindings/scripts/scripts/zone/silverpine_forest/silverpine_forest.cpp index 87c346d58b4..9652afcdcee 100644 --- a/src/bindings/scripts/scripts/zone/silverpine_forest/silverpine_forest.cpp +++ b/src/bindings/scripts/scripts/zone/silverpine_forest/silverpine_forest.cpp @@ -1,100 +1,100 @@ -/* Copyright (C) 2006,2007 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Silverpine_Forest -SD%Complete: 100 -SDComment: Quest support: 1886 -SDCategory: Silverpine Forest -EndScriptData */ - -/* ContentData -npc_astor_hadren -EndContentData */ - -#include "precompiled.h" - -/*###### -## npc_astor_hadren -######*/ - -struct MANGOS_DLL_DECL npc_astor_hadrenAI : public ScriptedAI -{ - npc_astor_hadrenAI(Creature *c) : ScriptedAI(c) {Reset();} - - void Reset() - { - m_creature->setFaction(68); - } - - void Aggro(Unit* who) - { - } - - void JustDied(Unit *who) - { - m_creature->setFaction(68); - } -}; - -CreatureAI* GetAI_npc_astor_hadren(Creature *_creature) -{ - return new npc_astor_hadrenAI(_creature); -} - -bool GossipHello_npc_astor_hadren(Player *player, Creature *_Creature) -{ - if (player->GetQuestStatus(1886) == QUEST_STATUS_INCOMPLETE) - player->ADD_GOSSIP_ITEM( 0, "You're Astor Hadren, right?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); - - player->SEND_GOSSIP_MENU(623, _Creature->GetGUID()); - - return true; -} - -bool GossipSelect_npc_astor_hadren(Player *player, Creature *_Creature, uint32 sender, uint32 action) -{ - switch (action) - { - case GOSSIP_ACTION_INFO_DEF + 1: - player->ADD_GOSSIP_ITEM( 0, "You've got something I need, Astor. And I'll be taking it now.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2); - player->SEND_GOSSIP_MENU(624, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 2: - player->CLOSE_GOSSIP_MENU(); - _Creature->setFaction(21); - if(player) - ((npc_astor_hadrenAI*)_Creature->AI())->AttackStart(player); - break; - } - return true; -} - -/*###### -## AddSC -######*/ - -void AddSC_silverpine_forest() -{ - Script *newscript; - - newscript = new Script; - newscript->Name="npc_astor_hadren"; - newscript->pGossipHello = &GossipHello_npc_astor_hadren; - newscript->pGossipSelect = &GossipSelect_npc_astor_hadren; - newscript->GetAI = GetAI_npc_astor_hadren; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006,2007 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Silverpine_Forest +SD%Complete: 100 +SDComment: Quest support: 1886 +SDCategory: Silverpine Forest +EndScriptData */ + +/* ContentData +npc_astor_hadren +EndContentData */ + +#include "precompiled.h" + +/*###### +## npc_astor_hadren +######*/ + +struct MANGOS_DLL_DECL npc_astor_hadrenAI : public ScriptedAI +{ + npc_astor_hadrenAI(Creature *c) : ScriptedAI(c) {Reset();} + + void Reset() + { + m_creature->setFaction(68); + } + + void Aggro(Unit* who) + { + } + + void JustDied(Unit *who) + { + m_creature->setFaction(68); + } +}; + +CreatureAI* GetAI_npc_astor_hadren(Creature *_creature) +{ + return new npc_astor_hadrenAI(_creature); +} + +bool GossipHello_npc_astor_hadren(Player *player, Creature *_Creature) +{ + if (player->GetQuestStatus(1886) == QUEST_STATUS_INCOMPLETE) + player->ADD_GOSSIP_ITEM( 0, "You're Astor Hadren, right?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); + + player->SEND_GOSSIP_MENU(623, _Creature->GetGUID()); + + return true; +} + +bool GossipSelect_npc_astor_hadren(Player *player, Creature *_Creature, uint32 sender, uint32 action) +{ + switch (action) + { + case GOSSIP_ACTION_INFO_DEF + 1: + player->ADD_GOSSIP_ITEM( 0, "You've got something I need, Astor. And I'll be taking it now.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2); + player->SEND_GOSSIP_MENU(624, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 2: + player->CLOSE_GOSSIP_MENU(); + _Creature->setFaction(21); + if(player) + ((npc_astor_hadrenAI*)_Creature->AI())->AttackStart(player); + break; + } + return true; +} + +/*###### +## AddSC +######*/ + +void AddSC_silverpine_forest() +{ + Script *newscript; + + newscript = new Script; + newscript->Name="npc_astor_hadren"; + newscript->pGossipHello = &GossipHello_npc_astor_hadren; + newscript->pGossipSelect = &GossipSelect_npc_astor_hadren; + newscript->GetAI = GetAI_npc_astor_hadren; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/stonetalon_mountains/stonetalon_mountains.cpp b/src/bindings/scripts/scripts/zone/stonetalon_mountains/stonetalon_mountains.cpp index 652af2fe802..8ec72e61a92 100644 --- a/src/bindings/scripts/scripts/zone/stonetalon_mountains/stonetalon_mountains.cpp +++ b/src/bindings/scripts/scripts/zone/stonetalon_mountains/stonetalon_mountains.cpp @@ -1,80 +1,80 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Stonetalon_Mountains -SD%Complete: 95 -SDComment: Quest support: 6627 (Braug Dimspirits questions/'answers' might have more to it, need more info) -SDCategory: Stonetalon Mountains -EndScriptData */ - -#include "precompiled.h" - -/*###### -## npc_braug_dimspirit -######*/ - -bool GossipHello_npc_braug_dimspirit(Player *player, Creature *_Creature) -{ - if (_Creature->isQuestGiver()) - player->PrepareQuestMenu( _Creature->GetGUID() ); - - if (player->GetQuestStatus(6627) == QUEST_STATUS_INCOMPLETE) - { - player->ADD_GOSSIP_ITEM( 0, "Ysera", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); - player->ADD_GOSSIP_ITEM( 0, "Neltharion", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2); - player->ADD_GOSSIP_ITEM( 0, "Nozdormu", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); - player->ADD_GOSSIP_ITEM( 0, "Alexstrasza", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); - player->ADD_GOSSIP_ITEM( 0, "Malygos", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); - - player->SEND_GOSSIP_MENU(5820, _Creature->GetGUID()); - } - else - player->SEND_GOSSIP_MENU(5819, _Creature->GetGUID()); - - return true; -} - -bool GossipSelect_npc_braug_dimspirit(Player *player, Creature *_Creature, uint32 sender, uint32 action) -{ - if (action == GOSSIP_ACTION_INFO_DEF+1) - { - player->CLOSE_GOSSIP_MENU(); - _Creature->CastSpell(player,6766,false); - - } - if (action == GOSSIP_ACTION_INFO_DEF+2) - { - player->CLOSE_GOSSIP_MENU(); - player->AreaExploredOrEventHappens(6627); - } - return true; -} - -/*###### -## AddSC -######*/ - -void AddSC_stonetalon_mountains() -{ - Script *newscript; - - newscript = new Script; - newscript->Name="npc_braug_dimspirit"; - newscript->pGossipHello = &GossipHello_npc_braug_dimspirit; - newscript->pGossipSelect = &GossipSelect_npc_braug_dimspirit; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Stonetalon_Mountains +SD%Complete: 95 +SDComment: Quest support: 6627 (Braug Dimspirits questions/'answers' might have more to it, need more info) +SDCategory: Stonetalon Mountains +EndScriptData */ + +#include "precompiled.h" + +/*###### +## npc_braug_dimspirit +######*/ + +bool GossipHello_npc_braug_dimspirit(Player *player, Creature *_Creature) +{ + if (_Creature->isQuestGiver()) + player->PrepareQuestMenu( _Creature->GetGUID() ); + + if (player->GetQuestStatus(6627) == QUEST_STATUS_INCOMPLETE) + { + player->ADD_GOSSIP_ITEM( 0, "Ysera", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); + player->ADD_GOSSIP_ITEM( 0, "Neltharion", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2); + player->ADD_GOSSIP_ITEM( 0, "Nozdormu", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); + player->ADD_GOSSIP_ITEM( 0, "Alexstrasza", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); + player->ADD_GOSSIP_ITEM( 0, "Malygos", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); + + player->SEND_GOSSIP_MENU(5820, _Creature->GetGUID()); + } + else + player->SEND_GOSSIP_MENU(5819, _Creature->GetGUID()); + + return true; +} + +bool GossipSelect_npc_braug_dimspirit(Player *player, Creature *_Creature, uint32 sender, uint32 action) +{ + if (action == GOSSIP_ACTION_INFO_DEF+1) + { + player->CLOSE_GOSSIP_MENU(); + _Creature->CastSpell(player,6766,false); + + } + if (action == GOSSIP_ACTION_INFO_DEF+2) + { + player->CLOSE_GOSSIP_MENU(); + player->AreaExploredOrEventHappens(6627); + } + return true; +} + +/*###### +## AddSC +######*/ + +void AddSC_stonetalon_mountains() +{ + Script *newscript; + + newscript = new Script; + newscript->Name="npc_braug_dimspirit"; + newscript->pGossipHello = &GossipHello_npc_braug_dimspirit; + newscript->pGossipSelect = &GossipSelect_npc_braug_dimspirit; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/stormwind/stormwind_city.cpp b/src/bindings/scripts/scripts/zone/stormwind/stormwind_city.cpp index 0821a424cc4..a0546651de9 100644 --- a/src/bindings/scripts/scripts/zone/stormwind/stormwind_city.cpp +++ b/src/bindings/scripts/scripts/zone/stormwind/stormwind_city.cpp @@ -1,272 +1,272 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Stormwind_City -SD%Complete: 100 -SDComment: Quest support: 1640, 1447, 4185, 11223 (DB support required for spell 42711). Receive emote General Marcus -SDCategory: Stormwind City -EndScriptData */ - -/* ContentData -npc_archmage_malin -npc_bartleby -npc_dashel_stonefist -npc_general_marcus_jonathan -npc_lady_katrana_prestor -EndContentData */ - -#include "precompiled.h" - -/*###### -## npc_archmage_malin -######*/ - -#define GOSSIP_ITEM_MALIN "Can you send me to Theramore? I have an urgent message for Lady Jaina from Highlord Bolvar." - -bool GossipHello_npc_archmage_malin(Player *player, Creature *_Creature) -{ - if(_Creature->isQuestGiver()) - player->PrepareQuestMenu( _Creature->GetGUID() ); - - if(player->GetQuestStatus(11223) == QUEST_STATUS_COMPLETE && !player->GetQuestRewardStatus(11223)) - player->ADD_GOSSIP_ITEM(0, GOSSIP_ITEM_MALIN, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF); - - player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); - - return true; -} - -bool GossipSelect_npc_archmage_malin(Player *player, Creature *_Creature, uint32 sender, uint32 action) -{ - if(action = GOSSIP_ACTION_INFO_DEF) - { - player->CLOSE_GOSSIP_MENU(); - _Creature->CastSpell(player, 42711, true); - } - - return true; -} - -/*###### -## npc_bartleby -######*/ - -struct MANGOS_DLL_DECL npc_bartlebyAI : public ScriptedAI -{ - npc_bartlebyAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint64 PlayerGUID; - - void Reset() - { - m_creature->setFaction(11); - m_creature->setEmoteState(7); - - PlayerGUID = 0; - } - - void JustDied(Unit *who) - { - m_creature->setFaction(11); - } - - void DamageTaken(Unit *done_by, uint32 & damage) - { - if(damage > m_creature->GetHealth() || ((m_creature->GetHealth() - damage)*100 / m_creature->GetMaxHealth() < 15)) - { - //Take 0 damage - damage = 0; - - if (done_by->GetTypeId() == TYPEID_PLAYER && done_by->GetGUID() == PlayerGUID) - { - ((Player*)done_by)->AttackStop(); - ((Player*)done_by)->AreaExploredOrEventHappens(1640); - } - m_creature->CombatStop(); - EnterEvadeMode(); - } - } - - void Aggro(Unit *who) {} -}; - -bool QuestAccept_npc_bartleby(Player *player, Creature *_Creature, Quest const *_Quest) -{ - if(_Quest->GetQuestId() == 1640) - { - _Creature->setFaction(168); - ((npc_bartlebyAI*)_Creature->AI())->PlayerGUID = player->GetGUID(); - ((npc_bartlebyAI*)_Creature->AI())->AttackStart(player); - } - return true; -} - -CreatureAI* GetAI_npc_bartleby(Creature *_creature) -{ - return new npc_bartlebyAI(_creature); -} - -/*###### -## npc_dashel_stonefist -######*/ - -struct MANGOS_DLL_DECL npc_dashel_stonefistAI : public ScriptedAI -{ - npc_dashel_stonefistAI(Creature *c) : ScriptedAI(c) {Reset();} - - void Reset() - { - m_creature->setFaction(11); - m_creature->setEmoteState(7); - } - - void DamageTaken(Unit *done_by, uint32 & damage) - { - if((damage > m_creature->GetHealth()) || (m_creature->GetHealth() - damage)*100 / m_creature->GetMaxHealth() < 15) - { - //Take 0 damage - damage = 0; - - if (done_by->GetTypeId() == TYPEID_PLAYER) - { - ((Player*)done_by)->AttackStop(); - ((Player*)done_by)->AreaExploredOrEventHappens(1447); - } - //m_creature->CombatStop(); - EnterEvadeMode(); - } - AttackedBy(done_by); - } - - void Aggro(Unit *who) {} -}; - -bool QuestAccept_npc_dashel_stonefist(Player *player, Creature *_Creature, Quest const *_Quest) -{ - if(_Quest->GetQuestId() == 1447) - { - _Creature->setFaction(168); - ((npc_dashel_stonefistAI*)_Creature->AI())->AttackStart(player); - } - return true; -} - -CreatureAI* GetAI_npc_dashel_stonefist(Creature *_creature) -{ - return new npc_dashel_stonefistAI(_creature); -} - -/*###### -## npc_general_marcus_jonathan -######*/ - -bool ReceiveEmote_npc_general_marcus_jonathan(Player *player, Creature *_Creature, uint32 emote) -{ - if(player->GetTeam() == ALLIANCE) - { - if (emote == TEXTEMOTE_SALUTE) - { - _Creature->SetOrientation(_Creature->GetAngle(player)); - _Creature->HandleEmoteCommand(EMOTE_ONESHOT_SALUTE); - } - if (emote == TEXTEMOTE_WAVE) - { - _Creature->MonsterSay("Greetings citizen",LANG_COMMON,0); - } - } - return true; -} - -/*###### -## npc_lady_katrana_prestor -######*/ - -#define GOSSIP_ITEM_KAT_1 "Pardon the intrusion, Lady Prestor, but Highlord Bolvar suggested that I seek your advice." -#define GOSSIP_ITEM_KAT_2 "My apologies, Lady Prestor." -#define GOSSIP_ITEM_KAT_3 "Begging your pardon, Lady Prestor. That was not my intent." -#define GOSSIP_ITEM_KAT_4 "Thank you for your time, Lady Prestor." - -bool GossipHello_npc_lady_katrana_prestor(Player *player, Creature *_Creature) -{ - if (_Creature->isQuestGiver()) - player->PrepareQuestMenu( _Creature->GetGUID() ); - - if (player->GetQuestStatus(4185) == QUEST_STATUS_INCOMPLETE) - player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM_KAT_1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF); - - player->SEND_GOSSIP_MENU(2693, _Creature->GetGUID()); - - return true; -} - -bool GossipSelect_npc_lady_katrana_prestor(Player *player, Creature *_Creature, uint32 sender, uint32 action) -{ - switch (action) - { - case GOSSIP_ACTION_INFO_DEF: - player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM_KAT_2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); - player->SEND_GOSSIP_MENU(2694, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+1: - player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM_KAT_3, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2); - player->SEND_GOSSIP_MENU(2695, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+2: - player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM_KAT_4, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 3); - player->SEND_GOSSIP_MENU(2696, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+3: - player->CLOSE_GOSSIP_MENU(); - player->AreaExploredOrEventHappens(4185); - break; - } - return true; -} - -void AddSC_stormwind_city() -{ - Script *newscript; - - newscript = new Script; - newscript->Name="npc_archmage_malin"; - newscript->pGossipHello = &GossipHello_npc_archmage_malin; - newscript->pGossipSelect = &GossipSelect_npc_archmage_malin; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name = "npc_bartleby"; - newscript->GetAI = GetAI_npc_bartleby; - newscript->pQuestAccept = &QuestAccept_npc_bartleby; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name = "npc_dashel_stonefist"; - newscript->GetAI = GetAI_npc_dashel_stonefist; - newscript->pQuestAccept = &QuestAccept_npc_dashel_stonefist; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name = "npc_general_marcus_jonathan"; - newscript->pReceiveEmote = &ReceiveEmote_npc_general_marcus_jonathan; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="npc_lady_katrana_prestor"; - newscript->pGossipHello = &GossipHello_npc_lady_katrana_prestor; - newscript->pGossipSelect = &GossipSelect_npc_lady_katrana_prestor; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Stormwind_City +SD%Complete: 100 +SDComment: Quest support: 1640, 1447, 4185, 11223 (DB support required for spell 42711). Receive emote General Marcus +SDCategory: Stormwind City +EndScriptData */ + +/* ContentData +npc_archmage_malin +npc_bartleby +npc_dashel_stonefist +npc_general_marcus_jonathan +npc_lady_katrana_prestor +EndContentData */ + +#include "precompiled.h" + +/*###### +## npc_archmage_malin +######*/ + +#define GOSSIP_ITEM_MALIN "Can you send me to Theramore? I have an urgent message for Lady Jaina from Highlord Bolvar." + +bool GossipHello_npc_archmage_malin(Player *player, Creature *_Creature) +{ + if(_Creature->isQuestGiver()) + player->PrepareQuestMenu( _Creature->GetGUID() ); + + if(player->GetQuestStatus(11223) == QUEST_STATUS_COMPLETE && !player->GetQuestRewardStatus(11223)) + player->ADD_GOSSIP_ITEM(0, GOSSIP_ITEM_MALIN, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF); + + player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); + + return true; +} + +bool GossipSelect_npc_archmage_malin(Player *player, Creature *_Creature, uint32 sender, uint32 action) +{ + if(action = GOSSIP_ACTION_INFO_DEF) + { + player->CLOSE_GOSSIP_MENU(); + _Creature->CastSpell(player, 42711, true); + } + + return true; +} + +/*###### +## npc_bartleby +######*/ + +struct MANGOS_DLL_DECL npc_bartlebyAI : public ScriptedAI +{ + npc_bartlebyAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint64 PlayerGUID; + + void Reset() + { + m_creature->setFaction(11); + m_creature->setEmoteState(7); + + PlayerGUID = 0; + } + + void JustDied(Unit *who) + { + m_creature->setFaction(11); + } + + void DamageTaken(Unit *done_by, uint32 & damage) + { + if(damage > m_creature->GetHealth() || ((m_creature->GetHealth() - damage)*100 / m_creature->GetMaxHealth() < 15)) + { + //Take 0 damage + damage = 0; + + if (done_by->GetTypeId() == TYPEID_PLAYER && done_by->GetGUID() == PlayerGUID) + { + ((Player*)done_by)->AttackStop(); + ((Player*)done_by)->AreaExploredOrEventHappens(1640); + } + m_creature->CombatStop(); + EnterEvadeMode(); + } + } + + void Aggro(Unit *who) {} +}; + +bool QuestAccept_npc_bartleby(Player *player, Creature *_Creature, Quest const *_Quest) +{ + if(_Quest->GetQuestId() == 1640) + { + _Creature->setFaction(168); + ((npc_bartlebyAI*)_Creature->AI())->PlayerGUID = player->GetGUID(); + ((npc_bartlebyAI*)_Creature->AI())->AttackStart(player); + } + return true; +} + +CreatureAI* GetAI_npc_bartleby(Creature *_creature) +{ + return new npc_bartlebyAI(_creature); +} + +/*###### +## npc_dashel_stonefist +######*/ + +struct MANGOS_DLL_DECL npc_dashel_stonefistAI : public ScriptedAI +{ + npc_dashel_stonefistAI(Creature *c) : ScriptedAI(c) {Reset();} + + void Reset() + { + m_creature->setFaction(11); + m_creature->setEmoteState(7); + } + + void DamageTaken(Unit *done_by, uint32 & damage) + { + if((damage > m_creature->GetHealth()) || (m_creature->GetHealth() - damage)*100 / m_creature->GetMaxHealth() < 15) + { + //Take 0 damage + damage = 0; + + if (done_by->GetTypeId() == TYPEID_PLAYER) + { + ((Player*)done_by)->AttackStop(); + ((Player*)done_by)->AreaExploredOrEventHappens(1447); + } + //m_creature->CombatStop(); + EnterEvadeMode(); + } + AttackedBy(done_by); + } + + void Aggro(Unit *who) {} +}; + +bool QuestAccept_npc_dashel_stonefist(Player *player, Creature *_Creature, Quest const *_Quest) +{ + if(_Quest->GetQuestId() == 1447) + { + _Creature->setFaction(168); + ((npc_dashel_stonefistAI*)_Creature->AI())->AttackStart(player); + } + return true; +} + +CreatureAI* GetAI_npc_dashel_stonefist(Creature *_creature) +{ + return new npc_dashel_stonefistAI(_creature); +} + +/*###### +## npc_general_marcus_jonathan +######*/ + +bool ReceiveEmote_npc_general_marcus_jonathan(Player *player, Creature *_Creature, uint32 emote) +{ + if(player->GetTeam() == ALLIANCE) + { + if (emote == TEXTEMOTE_SALUTE) + { + _Creature->SetOrientation(_Creature->GetAngle(player)); + _Creature->HandleEmoteCommand(EMOTE_ONESHOT_SALUTE); + } + if (emote == TEXTEMOTE_WAVE) + { + _Creature->MonsterSay("Greetings citizen",LANG_COMMON,0); + } + } + return true; +} + +/*###### +## npc_lady_katrana_prestor +######*/ + +#define GOSSIP_ITEM_KAT_1 "Pardon the intrusion, Lady Prestor, but Highlord Bolvar suggested that I seek your advice." +#define GOSSIP_ITEM_KAT_2 "My apologies, Lady Prestor." +#define GOSSIP_ITEM_KAT_3 "Begging your pardon, Lady Prestor. That was not my intent." +#define GOSSIP_ITEM_KAT_4 "Thank you for your time, Lady Prestor." + +bool GossipHello_npc_lady_katrana_prestor(Player *player, Creature *_Creature) +{ + if (_Creature->isQuestGiver()) + player->PrepareQuestMenu( _Creature->GetGUID() ); + + if (player->GetQuestStatus(4185) == QUEST_STATUS_INCOMPLETE) + player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM_KAT_1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF); + + player->SEND_GOSSIP_MENU(2693, _Creature->GetGUID()); + + return true; +} + +bool GossipSelect_npc_lady_katrana_prestor(Player *player, Creature *_Creature, uint32 sender, uint32 action) +{ + switch (action) + { + case GOSSIP_ACTION_INFO_DEF: + player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM_KAT_2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); + player->SEND_GOSSIP_MENU(2694, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+1: + player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM_KAT_3, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2); + player->SEND_GOSSIP_MENU(2695, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+2: + player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM_KAT_4, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 3); + player->SEND_GOSSIP_MENU(2696, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+3: + player->CLOSE_GOSSIP_MENU(); + player->AreaExploredOrEventHappens(4185); + break; + } + return true; +} + +void AddSC_stormwind_city() +{ + Script *newscript; + + newscript = new Script; + newscript->Name="npc_archmage_malin"; + newscript->pGossipHello = &GossipHello_npc_archmage_malin; + newscript->pGossipSelect = &GossipSelect_npc_archmage_malin; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name = "npc_bartleby"; + newscript->GetAI = GetAI_npc_bartleby; + newscript->pQuestAccept = &QuestAccept_npc_bartleby; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name = "npc_dashel_stonefist"; + newscript->GetAI = GetAI_npc_dashel_stonefist; + newscript->pQuestAccept = &QuestAccept_npc_dashel_stonefist; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name = "npc_general_marcus_jonathan"; + newscript->pReceiveEmote = &ReceiveEmote_npc_general_marcus_jonathan; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="npc_lady_katrana_prestor"; + newscript->pGossipHello = &GossipHello_npc_lady_katrana_prestor; + newscript->pGossipSelect = &GossipSelect_npc_lady_katrana_prestor; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/stranglethorn_vale/stranglethorn_vale.cpp b/src/bindings/scripts/scripts/zone/stranglethorn_vale/stranglethorn_vale.cpp index 35fda2c6f1c..09075f16348 100644 --- a/src/bindings/scripts/scripts/zone/stranglethorn_vale/stranglethorn_vale.cpp +++ b/src/bindings/scripts/scripts/zone/stranglethorn_vale/stranglethorn_vale.cpp @@ -1,107 +1,107 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Stranglethorn_Vale -SD%Complete: 100 -SDComment: Quest support: 592 -SDCategory: Stranglethorn Vale -EndScriptData */ - -/* ContentData -mob_yenniku -EndContentData */ - -#include "precompiled.h" - -/*###### -## mob_yenniku -######*/ - -struct MANGOS_DLL_DECL mob_yennikuAI : public ScriptedAI -{ - mob_yennikuAI(Creature *c) : ScriptedAI(c) - { - bReset = false; - Reset(); - } - - uint32 Reset_Timer; - bool bReset; - - void Reset() - { - Reset_Timer = 0; - m_creature->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_STATE_NONE); - } - - void SpellHit(Unit *caster, const SpellEntry *spell) - { - if (caster->GetTypeId() == TYPEID_PLAYER) - { - //Yenniku's Release - if(!bReset && ((Player*)caster)->GetQuestStatus(592) == QUEST_STATUS_INCOMPLETE && spell->Id == 3607) - { - m_creature->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_STATE_STUN); - m_creature->CombatStop(); //stop combat - m_creature->DeleteThreatList(); //unsure of this - m_creature->setFaction(83); //horde generic - - bReset = true; - Reset_Timer = 60000; - } - } - return; - } - - void Aggro(Unit *who) {} - - void UpdateAI(const uint32 diff) - { - if (bReset) - if(Reset_Timer < diff) - { - EnterEvadeMode(); - bReset = false; - m_creature->setFaction(28); //troll, bloodscalp - } - else Reset_Timer -= diff; - - //Return since we have no target - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - DoMeleeAttackIfReady(); - } -}; -CreatureAI* GetAI_mob_yenniku(Creature *_Creature) -{ - return new mob_yennikuAI (_Creature); -} - -/*###### -## -######*/ - -void AddSC_stranglethorn_vale() -{ - Script *newscript; - - newscript = new Script; - newscript->Name = "mob_yenniku"; - newscript->GetAI = GetAI_mob_yenniku; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Stranglethorn_Vale +SD%Complete: 100 +SDComment: Quest support: 592 +SDCategory: Stranglethorn Vale +EndScriptData */ + +/* ContentData +mob_yenniku +EndContentData */ + +#include "precompiled.h" + +/*###### +## mob_yenniku +######*/ + +struct MANGOS_DLL_DECL mob_yennikuAI : public ScriptedAI +{ + mob_yennikuAI(Creature *c) : ScriptedAI(c) + { + bReset = false; + Reset(); + } + + uint32 Reset_Timer; + bool bReset; + + void Reset() + { + Reset_Timer = 0; + m_creature->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_STATE_NONE); + } + + void SpellHit(Unit *caster, const SpellEntry *spell) + { + if (caster->GetTypeId() == TYPEID_PLAYER) + { + //Yenniku's Release + if(!bReset && ((Player*)caster)->GetQuestStatus(592) == QUEST_STATUS_INCOMPLETE && spell->Id == 3607) + { + m_creature->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_STATE_STUN); + m_creature->CombatStop(); //stop combat + m_creature->DeleteThreatList(); //unsure of this + m_creature->setFaction(83); //horde generic + + bReset = true; + Reset_Timer = 60000; + } + } + return; + } + + void Aggro(Unit *who) {} + + void UpdateAI(const uint32 diff) + { + if (bReset) + if(Reset_Timer < diff) + { + EnterEvadeMode(); + bReset = false; + m_creature->setFaction(28); //troll, bloodscalp + } + else Reset_Timer -= diff; + + //Return since we have no target + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + DoMeleeAttackIfReady(); + } +}; +CreatureAI* GetAI_mob_yenniku(Creature *_Creature) +{ + return new mob_yennikuAI (_Creature); +} + +/*###### +## +######*/ + +void AddSC_stranglethorn_vale() +{ + Script *newscript; + + newscript = new Script; + newscript->Name = "mob_yenniku"; + newscript->GetAI = GetAI_mob_yenniku; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/stratholme/boss_baron_rivendare.cpp b/src/bindings/scripts/scripts/zone/stratholme/boss_baron_rivendare.cpp index 6355588e7b8..13be5b04365 100644 --- a/src/bindings/scripts/scripts/zone/stratholme/boss_baron_rivendare.cpp +++ b/src/bindings/scripts/scripts/zone/stratholme/boss_baron_rivendare.cpp @@ -1,215 +1,215 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -/* ScriptData -SDName: boss_baron_rivendare -SD%Complete: 100 -SDComment: aura applied/defined in database -SDCategory: Stratholme -EndScriptData */ - -#include "precompiled.h" - -#define SAY_0 "Intruders! More pawns of the Argent Dawn, no doubt. I already count one of their number among my prisoners. Withdraw from my domain before she is executed!" -#define SAY_1 "You're still here? Your foolishness is amusing! The Argent Dawn wench needn't suffer in vain. Leave at once and she shall be spared!" -#define SAY_2 "I shall take great pleasure in taking this poor wretch's life! It's not too late, she needn't suffer in vain. Turn back and her death shall be merciful!" -#define SAY_3 "May this prisoner's death serve as a warning. None shall defy the Scourge and live!" -#define SAY_4 "So you see fit to toy with the Lich King's creations? Ramstein, be sure to give the intruders a proper greeting." -#define SAY_5 "Time to take matters into my own hands. Come. Enter my domain and challenge the might of the Scourge!" - -#define ADD_1X 4017.403809 -#define ADD_1Y -3339.703369 -#define ADD_1Z 115.057655 -#define ADD_1O 5.487860 - -#define ADD_2X 4013.189209 -#define ADD_2Y -3351.808350 -#define ADD_2Z 115.052254 -#define ADD_2O 0.134280 - -#define ADD_3X 4017.738037 -#define ADD_3Y -3363.478016 -#define ADD_3Z 115.057274 -#define ADD_3O 0.723313 - -#define ADD_4X 4048.877197 -#define ADD_4Y -3363.223633 -#define ADD_4Z 115.054253 -#define ADD_4O 3.627735 - -#define ADD_5X 4051.777588 -#define ADD_5Y -3350.893311 -#define ADD_5Z 115.055351 -#define ADD_5O 3.066176 - -#define ADD_6X 4048.375977 -#define ADD_6Y -3339.966309 -#define ADD_6Z 115.055222 -#define ADD_6O 2.457497 - -#define SPELL_SHADOWBOLT 18164 -#define SPELL_CLEAVE 15584 -#define SPELL_MORTALSTRIKE 13737 - -// spell 17473 should trigger -> 17471 - -//#define SPELL_RAISEDEAD 17475 -//#define SPELL_DEATHPACT 17698 -//#define SPELL_SUMMONSKELETONS 17274 - -struct MANGOS_DLL_DECL boss_baron_rivendareAI : public ScriptedAI -{ - boss_baron_rivendareAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 ShadowBolt_Timer; - uint32 Cleave_Timer; - uint32 MortalStrike_Timer; - // uint32 RaiseDead_Timer; - uint32 SummonSkeletons_Timer; - Creature *Summoned; - - void Reset() - { - ShadowBolt_Timer = 5000; - Cleave_Timer = 8000; - MortalStrike_Timer = 12000; - // RaiseDead_Timer = 30000; - SummonSkeletons_Timer = 34000; - - m_creature->LoadCreaturesAddon(); - } - - void Aggro(Unit *who) - { - switch (rand()%6) - { - case 0: - DoYell(SAY_0,LANG_UNIVERSAL,NULL); - break; - case 1: - DoYell(SAY_1,LANG_UNIVERSAL,NULL); - break; - case 2: - DoYell(SAY_2,LANG_UNIVERSAL,NULL); - break; - case 3: - DoYell(SAY_3,LANG_UNIVERSAL,NULL); - break; - case 4: - DoYell(SAY_4,LANG_UNIVERSAL,NULL); - break; - case 5: - DoYell(SAY_5,LANG_UNIVERSAL,NULL); - break; - } - } - - void UpdateAI(const uint32 diff) - { - //Return since we have no target - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - //ShadowBolt - if (ShadowBolt_Timer < diff) - { - //Cast - if (rand()%100 < 70) //70% chance to cast - { - DoCast(m_creature->getVictim(),SPELL_SHADOWBOLT); - } - //10 seconds until we should cast this again - ShadowBolt_Timer = 10000; - }else ShadowBolt_Timer -= diff; - - //Cleave - if (Cleave_Timer < diff) - { - //Cast - if (rand()%100 < 55) //55% chance to cast - { - DoCast(m_creature->getVictim(),SPELL_CLEAVE); - } - //13 seconds until we should cast this again - Cleave_Timer = 12000; - }else Cleave_Timer -= diff; - - //MortalStrike - if (MortalStrike_Timer < diff) - { - //Cast - if (rand()%100 < 30) //30% chance to cast - { - DoCast(m_creature->getVictim(),SPELL_MORTALSTRIKE); - } - //16 seconds until we should cast this again - MortalStrike_Timer = 16000; - }else MortalStrike_Timer -= diff; - - //RaiseDead - // if (RaiseDead_Timer < diff) - // { - //Cast - // DoCast(m_creature,SPELL_RAISEDEAD); - // DoSay("summon triggered",LANG_UNIVERSAL,NULL); //just a checkpoint - //45 seconds until we should cast this again - // RaiseDead_Timer = 45000; - // }else RaiseDead_Timer -= diff; - - //SummonSkeletons - //Creature* Unit::SummonCreature(uint32 id, float x, float y, float z, float ang,TempSummonType spwtype,uint32 despwtime); - - if (SummonSkeletons_Timer < diff) - { - Unit* target = NULL; - target = SelectUnit(SELECT_TARGET_RANDOM,0); - - //Cast - Summoned = m_creature->SummonCreature(11197,ADD_1X,ADD_1Y,ADD_1Z,ADD_1O,TEMPSUMMON_TIMED_DESPAWN,29000); - ((CreatureAI*)Summoned->AI())->AttackStart(target); - Summoned = m_creature->SummonCreature(11197,ADD_2X,ADD_2Y,ADD_2Z,ADD_2O,TEMPSUMMON_TIMED_DESPAWN,29000); - ((CreatureAI*)Summoned->AI())->AttackStart(target); - Summoned = m_creature->SummonCreature(11197,ADD_3X,ADD_3Y,ADD_3Z,ADD_3O,TEMPSUMMON_TIMED_DESPAWN,29000); - ((CreatureAI*)Summoned->AI())->AttackStart(target); - Summoned = m_creature->SummonCreature(11197,ADD_4X,ADD_4Y,ADD_4Z,ADD_4O,TEMPSUMMON_TIMED_DESPAWN,29000); - ((CreatureAI*)Summoned->AI())->AttackStart(target); - Summoned = m_creature->SummonCreature(11197,ADD_5X,ADD_5Y,ADD_5Z,ADD_5O,TEMPSUMMON_TIMED_DESPAWN,29000); - ((CreatureAI*)Summoned->AI())->AttackStart(target); - Summoned = m_creature->SummonCreature(11197,ADD_6X,ADD_6Y,ADD_6Z,ADD_6O,TEMPSUMMON_TIMED_DESPAWN,29000); - ((CreatureAI*)Summoned->AI())->AttackStart(target); - - //34 seconds until we should cast this again - SummonSkeletons_Timer = 40000; - }else SummonSkeletons_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; - -CreatureAI* GetAI_boss_baron_rivendare(Creature *_Creature) -{ - return new boss_baron_rivendareAI (_Creature); -} - - -void AddSC_boss_baron_rivendare() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_baron_rivendare"; - newscript->GetAI = GetAI_boss_baron_rivendare; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +/* ScriptData +SDName: boss_baron_rivendare +SD%Complete: 100 +SDComment: aura applied/defined in database +SDCategory: Stratholme +EndScriptData */ + +#include "precompiled.h" + +#define SAY_0 "Intruders! More pawns of the Argent Dawn, no doubt. I already count one of their number among my prisoners. Withdraw from my domain before she is executed!" +#define SAY_1 "You're still here? Your foolishness is amusing! The Argent Dawn wench needn't suffer in vain. Leave at once and she shall be spared!" +#define SAY_2 "I shall take great pleasure in taking this poor wretch's life! It's not too late, she needn't suffer in vain. Turn back and her death shall be merciful!" +#define SAY_3 "May this prisoner's death serve as a warning. None shall defy the Scourge and live!" +#define SAY_4 "So you see fit to toy with the Lich King's creations? Ramstein, be sure to give the intruders a proper greeting." +#define SAY_5 "Time to take matters into my own hands. Come. Enter my domain and challenge the might of the Scourge!" + +#define ADD_1X 4017.403809 +#define ADD_1Y -3339.703369 +#define ADD_1Z 115.057655 +#define ADD_1O 5.487860 + +#define ADD_2X 4013.189209 +#define ADD_2Y -3351.808350 +#define ADD_2Z 115.052254 +#define ADD_2O 0.134280 + +#define ADD_3X 4017.738037 +#define ADD_3Y -3363.478016 +#define ADD_3Z 115.057274 +#define ADD_3O 0.723313 + +#define ADD_4X 4048.877197 +#define ADD_4Y -3363.223633 +#define ADD_4Z 115.054253 +#define ADD_4O 3.627735 + +#define ADD_5X 4051.777588 +#define ADD_5Y -3350.893311 +#define ADD_5Z 115.055351 +#define ADD_5O 3.066176 + +#define ADD_6X 4048.375977 +#define ADD_6Y -3339.966309 +#define ADD_6Z 115.055222 +#define ADD_6O 2.457497 + +#define SPELL_SHADOWBOLT 18164 +#define SPELL_CLEAVE 15584 +#define SPELL_MORTALSTRIKE 13737 + +// spell 17473 should trigger -> 17471 + +//#define SPELL_RAISEDEAD 17475 +//#define SPELL_DEATHPACT 17698 +//#define SPELL_SUMMONSKELETONS 17274 + +struct MANGOS_DLL_DECL boss_baron_rivendareAI : public ScriptedAI +{ + boss_baron_rivendareAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 ShadowBolt_Timer; + uint32 Cleave_Timer; + uint32 MortalStrike_Timer; + // uint32 RaiseDead_Timer; + uint32 SummonSkeletons_Timer; + Creature *Summoned; + + void Reset() + { + ShadowBolt_Timer = 5000; + Cleave_Timer = 8000; + MortalStrike_Timer = 12000; + // RaiseDead_Timer = 30000; + SummonSkeletons_Timer = 34000; + + m_creature->LoadCreaturesAddon(); + } + + void Aggro(Unit *who) + { + switch (rand()%6) + { + case 0: + DoYell(SAY_0,LANG_UNIVERSAL,NULL); + break; + case 1: + DoYell(SAY_1,LANG_UNIVERSAL,NULL); + break; + case 2: + DoYell(SAY_2,LANG_UNIVERSAL,NULL); + break; + case 3: + DoYell(SAY_3,LANG_UNIVERSAL,NULL); + break; + case 4: + DoYell(SAY_4,LANG_UNIVERSAL,NULL); + break; + case 5: + DoYell(SAY_5,LANG_UNIVERSAL,NULL); + break; + } + } + + void UpdateAI(const uint32 diff) + { + //Return since we have no target + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + //ShadowBolt + if (ShadowBolt_Timer < diff) + { + //Cast + if (rand()%100 < 70) //70% chance to cast + { + DoCast(m_creature->getVictim(),SPELL_SHADOWBOLT); + } + //10 seconds until we should cast this again + ShadowBolt_Timer = 10000; + }else ShadowBolt_Timer -= diff; + + //Cleave + if (Cleave_Timer < diff) + { + //Cast + if (rand()%100 < 55) //55% chance to cast + { + DoCast(m_creature->getVictim(),SPELL_CLEAVE); + } + //13 seconds until we should cast this again + Cleave_Timer = 12000; + }else Cleave_Timer -= diff; + + //MortalStrike + if (MortalStrike_Timer < diff) + { + //Cast + if (rand()%100 < 30) //30% chance to cast + { + DoCast(m_creature->getVictim(),SPELL_MORTALSTRIKE); + } + //16 seconds until we should cast this again + MortalStrike_Timer = 16000; + }else MortalStrike_Timer -= diff; + + //RaiseDead + // if (RaiseDead_Timer < diff) + // { + //Cast + // DoCast(m_creature,SPELL_RAISEDEAD); + // DoSay("summon triggered",LANG_UNIVERSAL,NULL); //just a checkpoint + //45 seconds until we should cast this again + // RaiseDead_Timer = 45000; + // }else RaiseDead_Timer -= diff; + + //SummonSkeletons + //Creature* Unit::SummonCreature(uint32 id, float x, float y, float z, float ang,TempSummonType spwtype,uint32 despwtime); + + if (SummonSkeletons_Timer < diff) + { + Unit* target = NULL; + target = SelectUnit(SELECT_TARGET_RANDOM,0); + + //Cast + Summoned = m_creature->SummonCreature(11197,ADD_1X,ADD_1Y,ADD_1Z,ADD_1O,TEMPSUMMON_TIMED_DESPAWN,29000); + ((CreatureAI*)Summoned->AI())->AttackStart(target); + Summoned = m_creature->SummonCreature(11197,ADD_2X,ADD_2Y,ADD_2Z,ADD_2O,TEMPSUMMON_TIMED_DESPAWN,29000); + ((CreatureAI*)Summoned->AI())->AttackStart(target); + Summoned = m_creature->SummonCreature(11197,ADD_3X,ADD_3Y,ADD_3Z,ADD_3O,TEMPSUMMON_TIMED_DESPAWN,29000); + ((CreatureAI*)Summoned->AI())->AttackStart(target); + Summoned = m_creature->SummonCreature(11197,ADD_4X,ADD_4Y,ADD_4Z,ADD_4O,TEMPSUMMON_TIMED_DESPAWN,29000); + ((CreatureAI*)Summoned->AI())->AttackStart(target); + Summoned = m_creature->SummonCreature(11197,ADD_5X,ADD_5Y,ADD_5Z,ADD_5O,TEMPSUMMON_TIMED_DESPAWN,29000); + ((CreatureAI*)Summoned->AI())->AttackStart(target); + Summoned = m_creature->SummonCreature(11197,ADD_6X,ADD_6Y,ADD_6Z,ADD_6O,TEMPSUMMON_TIMED_DESPAWN,29000); + ((CreatureAI*)Summoned->AI())->AttackStart(target); + + //34 seconds until we should cast this again + SummonSkeletons_Timer = 40000; + }else SummonSkeletons_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; + +CreatureAI* GetAI_boss_baron_rivendare(Creature *_Creature) +{ + return new boss_baron_rivendareAI (_Creature); +} + + +void AddSC_boss_baron_rivendare() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_baron_rivendare"; + newscript->GetAI = GetAI_boss_baron_rivendare; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/stratholme/boss_baroness_anastari.cpp b/src/bindings/scripts/scripts/zone/stratholme/boss_baroness_anastari.cpp index 79284eb5a26..1667375dd78 100644 --- a/src/bindings/scripts/scripts/zone/stratholme/boss_baroness_anastari.cpp +++ b/src/bindings/scripts/scripts/zone/stratholme/boss_baroness_anastari.cpp @@ -1,124 +1,124 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -/* ScriptData -SDName: boss_baroness_anastari -SD%Complete: 90 -SDComment: MC disabled -SDCategory: Stratholme -EndScriptData */ - -#include "precompiled.h" - -#define SPELL_BANSHEEWAIL 16565 -#define SPELL_BANSHEECURSE 16867 -#define SPELL_SILENCE 18327 -//#define SPELL_POSSESS 17244 - -struct MANGOS_DLL_DECL boss_baroness_anastariAI : public ScriptedAI -{ - boss_baroness_anastariAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 BansheeWail_Timer; - uint32 BansheeCurse_Timer; - uint32 Silence_Timer; - //uint32 Possess_Timer; - - void Reset() - { - BansheeWail_Timer = 1000; - BansheeCurse_Timer = 11000; - Silence_Timer = 13000; - //Possess_Timer = 35000; - } - - void Aggro(Unit *who) - { - } - void UpdateAI(const uint32 diff) - { - //Return since we have no target - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - //BansheeWail - if (BansheeWail_Timer < diff) - { - //Cast - if (rand()%100 < 95) //95% chance to cast - { - DoCast(m_creature->getVictim(),SPELL_BANSHEEWAIL); - } - //4 seconds until we should cast this again - BansheeWail_Timer = 4000; - }else BansheeWail_Timer -= diff; - - //BansheeCurse - if (BansheeCurse_Timer < diff) - { - //Cast - if (rand()%100 < 75) //75% chance to cast - { - DoCast(m_creature->getVictim(),SPELL_BANSHEECURSE); - } - //18 seconds until we should cast this again - BansheeCurse_Timer = 18000; - }else BansheeCurse_Timer -= diff; - - //Silence - if (Silence_Timer < diff) - { - //Cast - if (rand()%100 < 80) //80% chance to cast - { - DoCast(m_creature->getVictim(),SPELL_SILENCE); - } - //13 seconds until we should cast this again - Silence_Timer = 13000; - }else Silence_Timer -= diff; - - //Possess - /* if (Possess_Timer < diff) - { - //Cast - if (rand()%100 < 65) //65% chance to cast - { - Unit* target = NULL; - target = SelectUnit(SELECT_TARGET_RANDOM,0); - if (target)DoCast(target,SPELL_POSSESS); - } - //50 seconds until we should cast this again - Possess_Timer = 50000; - }else Possess_Timer -= diff; - */ - - DoMeleeAttackIfReady(); - } -}; -CreatureAI* GetAI_boss_baroness_anastari(Creature *_Creature) -{ - return new boss_baroness_anastariAI (_Creature); -} - - -void AddSC_boss_baroness_anastari() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_baroness_anastari"; - newscript->GetAI = GetAI_boss_baroness_anastari; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +/* ScriptData +SDName: boss_baroness_anastari +SD%Complete: 90 +SDComment: MC disabled +SDCategory: Stratholme +EndScriptData */ + +#include "precompiled.h" + +#define SPELL_BANSHEEWAIL 16565 +#define SPELL_BANSHEECURSE 16867 +#define SPELL_SILENCE 18327 +//#define SPELL_POSSESS 17244 + +struct MANGOS_DLL_DECL boss_baroness_anastariAI : public ScriptedAI +{ + boss_baroness_anastariAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 BansheeWail_Timer; + uint32 BansheeCurse_Timer; + uint32 Silence_Timer; + //uint32 Possess_Timer; + + void Reset() + { + BansheeWail_Timer = 1000; + BansheeCurse_Timer = 11000; + Silence_Timer = 13000; + //Possess_Timer = 35000; + } + + void Aggro(Unit *who) + { + } + void UpdateAI(const uint32 diff) + { + //Return since we have no target + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + //BansheeWail + if (BansheeWail_Timer < diff) + { + //Cast + if (rand()%100 < 95) //95% chance to cast + { + DoCast(m_creature->getVictim(),SPELL_BANSHEEWAIL); + } + //4 seconds until we should cast this again + BansheeWail_Timer = 4000; + }else BansheeWail_Timer -= diff; + + //BansheeCurse + if (BansheeCurse_Timer < diff) + { + //Cast + if (rand()%100 < 75) //75% chance to cast + { + DoCast(m_creature->getVictim(),SPELL_BANSHEECURSE); + } + //18 seconds until we should cast this again + BansheeCurse_Timer = 18000; + }else BansheeCurse_Timer -= diff; + + //Silence + if (Silence_Timer < diff) + { + //Cast + if (rand()%100 < 80) //80% chance to cast + { + DoCast(m_creature->getVictim(),SPELL_SILENCE); + } + //13 seconds until we should cast this again + Silence_Timer = 13000; + }else Silence_Timer -= diff; + + //Possess + /* if (Possess_Timer < diff) + { + //Cast + if (rand()%100 < 65) //65% chance to cast + { + Unit* target = NULL; + target = SelectUnit(SELECT_TARGET_RANDOM,0); + if (target)DoCast(target,SPELL_POSSESS); + } + //50 seconds until we should cast this again + Possess_Timer = 50000; + }else Possess_Timer -= diff; + */ + + DoMeleeAttackIfReady(); + } +}; +CreatureAI* GetAI_boss_baroness_anastari(Creature *_Creature) +{ + return new boss_baroness_anastariAI (_Creature); +} + + +void AddSC_boss_baroness_anastari() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_baroness_anastari"; + newscript->GetAI = GetAI_boss_baroness_anastari; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/stratholme/boss_cannon_master_willey.cpp b/src/bindings/scripts/scripts/zone/stratholme/boss_cannon_master_willey.cpp index 91d4b4fd397..91b6da1fc56 100644 --- a/src/bindings/scripts/scripts/zone/stratholme/boss_cannon_master_willey.cpp +++ b/src/bindings/scripts/scripts/zone/stratholme/boss_cannon_master_willey.cpp @@ -1,221 +1,221 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -/* ScriptData -SDName: boss_cannon_master_willey -SD%Complete: 100 -SDComment: -SDCategory: Stratholme -EndScriptData */ - -#include "precompiled.h" - -//front, left -#define ADD_1X 3553.851807 -#define ADD_1Y -2945.885986 -#define ADD_1Z 125.001015 -#define ADD_1O 0.592007 -//front, right -#define ADD_2X 3559.206299 -#define ADD_2Y -2952.929932 -#define ADD_2Z 125.001015 -#define ADD_2O 0.592007 -//mid, left -#define ADD_3X 3552.417480 -#define ADD_3Y -2948.667236 -#define ADD_3Z 125.001015 -#define ADD_3O 0.592007 -//mid, right -#define ADD_4X 3555.651855 -#define ADD_4Y -2953.519043 -#define ADD_4Z 125.001015 -#define ADD_4O 0.592007 -//back, left -#define ADD_5X 3547.927246 -#define ADD_5Y -2950.977295 -#define ADD_5Z 125.001015 -#define ADD_5O 0.592007 -//back, mid -#define ADD_6X 3553.094697 -#define ADD_6Y -2952.123291 -#define ADD_6Z 125.001015 -#define ADD_6O 0.592007 -//back, right -#define ADD_7X 3552.727539 -#define ADD_7Y -2957.776123 -#define ADD_7Z 125.001015 -#define ADD_7O 0.592007 -//behind, left -#define ADD_8X 3547.156250 -#define ADD_8Y -2953.162354 -#define ADD_8Z 125.001015 -#define ADD_8O 0.592007 -//behind, right -#define ADD_9X 3550.202148 -#define ADD_9Y -2957.437744 -#define ADD_9Z 125.001015 -#define ADD_9O 0.592007 - -#define SPELL_KNOCKAWAY 10101 -#define SPELL_PUMMEL 15615 -#define SPELL_SHOOT 20463 -//#define SPELL_SUMMONCRIMSONRIFLEMAN 17279 - -struct MANGOS_DLL_DECL boss_cannon_master_willeyAI : public ScriptedAI -{ - boss_cannon_master_willeyAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 KnockAway_Timer; - uint32 Pummel_Timer; - uint32 Shoot_Timer; - uint32 SummonRifleman_Timer; - - void Reset() - { - Shoot_Timer = 1000; - Pummel_Timer = 7000; - KnockAway_Timer = 11000; - SummonRifleman_Timer = 15000; - } - - void JustDied(Unit* Victim) - { - m_creature->SummonCreature(11054,ADD_1X,ADD_1Y,ADD_1Z,ADD_1O,TEMPSUMMON_TIMED_DESPAWN,240000); - m_creature->SummonCreature(11054,ADD_2X,ADD_2Y,ADD_2Z,ADD_2O,TEMPSUMMON_TIMED_DESPAWN,240000); - m_creature->SummonCreature(11054,ADD_3X,ADD_3Y,ADD_3Z,ADD_3O,TEMPSUMMON_TIMED_DESPAWN,240000); - m_creature->SummonCreature(11054,ADD_4X,ADD_4Y,ADD_4Z,ADD_4O,TEMPSUMMON_TIMED_DESPAWN,240000); - m_creature->SummonCreature(11054,ADD_5X,ADD_5Y,ADD_5Z,ADD_5O,TEMPSUMMON_TIMED_DESPAWN,240000); - m_creature->SummonCreature(11054,ADD_7X,ADD_7Y,ADD_7Z,ADD_7O,TEMPSUMMON_TIMED_DESPAWN,240000); - m_creature->SummonCreature(11054,ADD_9X,ADD_9Y,ADD_9Z,ADD_9O,TEMPSUMMON_TIMED_DESPAWN,240000); - } - - void Aggro(Unit *who) - { - } - - - void UpdateAI(const uint32 diff) - { - //Return since we have no target - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - //Pummel - if (Pummel_Timer < diff) - { - //Cast - if (rand()%100 < 90) //90% chance to cast - { - DoCast(m_creature->getVictim(),SPELL_PUMMEL); - } - //12 seconds until we should cast this again - Pummel_Timer = 12000; - }else Pummel_Timer -= diff; - - //KnockAway - if (KnockAway_Timer < diff) - { - //Cast - if (rand()%100 < 80) //80% chance to cast - { - DoCast(m_creature->getVictim(),SPELL_KNOCKAWAY); - } - //14 seconds until we should cast this again - KnockAway_Timer = 14000; - }else KnockAway_Timer -= diff; - - //Shoot - if (Shoot_Timer < diff) - { - //Cast - DoCast(m_creature->getVictim(),SPELL_SHOOT); - //1 seconds until we should cast this again - Shoot_Timer = 1000; - }else Shoot_Timer -= diff; - - //SummonRifleman - if (SummonRifleman_Timer < diff) - { - //Cast - switch (rand()%9) - { - case 0: - m_creature->SummonCreature(11054,ADD_1X,ADD_1Y,ADD_1Z,ADD_1O,TEMPSUMMON_TIMED_DESPAWN,240000); - m_creature->SummonCreature(11054,ADD_2X,ADD_2Y,ADD_2Z,ADD_2O,TEMPSUMMON_TIMED_DESPAWN,240000); - m_creature->SummonCreature(11054,ADD_4X,ADD_4Y,ADD_4Z,ADD_4O,TEMPSUMMON_TIMED_DESPAWN,240000); - break; - case 1: - m_creature->SummonCreature(11054,ADD_2X,ADD_2Y,ADD_2Z,ADD_2O,TEMPSUMMON_TIMED_DESPAWN,240000); - m_creature->SummonCreature(11054,ADD_3X,ADD_3Y,ADD_3Z,ADD_3O,TEMPSUMMON_TIMED_DESPAWN,240000); - m_creature->SummonCreature(11054,ADD_5X,ADD_5Y,ADD_5Z,ADD_5O,TEMPSUMMON_TIMED_DESPAWN,240000); - break; - case 2: - m_creature->SummonCreature(11054,ADD_3X,ADD_3Y,ADD_3Z,ADD_3O,TEMPSUMMON_TIMED_DESPAWN,240000); - m_creature->SummonCreature(11054,ADD_4X,ADD_4Y,ADD_4Z,ADD_4O,TEMPSUMMON_TIMED_DESPAWN,240000); - m_creature->SummonCreature(11054,ADD_6X,ADD_6Y,ADD_6Z,ADD_6O,TEMPSUMMON_TIMED_DESPAWN,240000); - break; - case 3: - m_creature->SummonCreature(11054,ADD_4X,ADD_4Y,ADD_4Z,ADD_4O,TEMPSUMMON_TIMED_DESPAWN,240000); - m_creature->SummonCreature(11054,ADD_5X,ADD_5Y,ADD_5Z,ADD_5O,TEMPSUMMON_TIMED_DESPAWN,240000); - m_creature->SummonCreature(11054,ADD_7X,ADD_7Y,ADD_7Z,ADD_7O,TEMPSUMMON_TIMED_DESPAWN,240000); - break; - case 4: - m_creature->SummonCreature(11054,ADD_5X,ADD_5Y,ADD_5Z,ADD_5O,TEMPSUMMON_TIMED_DESPAWN,240000); - m_creature->SummonCreature(11054,ADD_6X,ADD_6Y,ADD_6Z,ADD_6O,TEMPSUMMON_TIMED_DESPAWN,240000); - m_creature->SummonCreature(11054,ADD_8X,ADD_8Y,ADD_8Z,ADD_8O,TEMPSUMMON_TIMED_DESPAWN,240000); - break; - case 5: - m_creature->SummonCreature(11054,ADD_6X,ADD_6Y,ADD_6Z,ADD_6O,TEMPSUMMON_TIMED_DESPAWN,240000); - m_creature->SummonCreature(11054,ADD_7X,ADD_7Y,ADD_7Z,ADD_7O,TEMPSUMMON_TIMED_DESPAWN,240000); - m_creature->SummonCreature(11054,ADD_9X,ADD_9Y,ADD_9Z,ADD_9O,TEMPSUMMON_TIMED_DESPAWN,240000); - break; - case 6: - m_creature->SummonCreature(11054,ADD_7X,ADD_7Y,ADD_7Z,ADD_7O,TEMPSUMMON_TIMED_DESPAWN,240000); - m_creature->SummonCreature(11054,ADD_8X,ADD_8Y,ADD_8Z,ADD_8O,TEMPSUMMON_TIMED_DESPAWN,240000); - m_creature->SummonCreature(11054,ADD_1X,ADD_1Y,ADD_1Z,ADD_1O,TEMPSUMMON_TIMED_DESPAWN,240000); - break; - case 7: - m_creature->SummonCreature(11054,ADD_8X,ADD_8Y,ADD_8Z,ADD_8O,TEMPSUMMON_TIMED_DESPAWN,240000); - m_creature->SummonCreature(11054,ADD_9X,ADD_9Y,ADD_9Z,ADD_9O,TEMPSUMMON_TIMED_DESPAWN,240000); - m_creature->SummonCreature(11054,ADD_2X,ADD_2Y,ADD_2Z,ADD_2O,TEMPSUMMON_TIMED_DESPAWN,240000); - break; - case 8: - m_creature->SummonCreature(11054,ADD_9X,ADD_9Y,ADD_9Z,ADD_9O,TEMPSUMMON_TIMED_DESPAWN,240000); - m_creature->SummonCreature(11054,ADD_1X,ADD_1Y,ADD_1Z,ADD_1O,TEMPSUMMON_TIMED_DESPAWN,240000); - m_creature->SummonCreature(11054,ADD_3X,ADD_3Y,ADD_3Z,ADD_3O,TEMPSUMMON_TIMED_DESPAWN,240000); - break; - } - //30 seconds until we should cast this again - SummonRifleman_Timer = 30000; - }else SummonRifleman_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; -CreatureAI* GetAI_boss_cannon_master_willey(Creature *_Creature) -{ - return new boss_cannon_master_willeyAI (_Creature); -} - - -void AddSC_boss_cannon_master_willey() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_cannon_master_willey"; - newscript->GetAI = GetAI_boss_cannon_master_willey; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +/* ScriptData +SDName: boss_cannon_master_willey +SD%Complete: 100 +SDComment: +SDCategory: Stratholme +EndScriptData */ + +#include "precompiled.h" + +//front, left +#define ADD_1X 3553.851807 +#define ADD_1Y -2945.885986 +#define ADD_1Z 125.001015 +#define ADD_1O 0.592007 +//front, right +#define ADD_2X 3559.206299 +#define ADD_2Y -2952.929932 +#define ADD_2Z 125.001015 +#define ADD_2O 0.592007 +//mid, left +#define ADD_3X 3552.417480 +#define ADD_3Y -2948.667236 +#define ADD_3Z 125.001015 +#define ADD_3O 0.592007 +//mid, right +#define ADD_4X 3555.651855 +#define ADD_4Y -2953.519043 +#define ADD_4Z 125.001015 +#define ADD_4O 0.592007 +//back, left +#define ADD_5X 3547.927246 +#define ADD_5Y -2950.977295 +#define ADD_5Z 125.001015 +#define ADD_5O 0.592007 +//back, mid +#define ADD_6X 3553.094697 +#define ADD_6Y -2952.123291 +#define ADD_6Z 125.001015 +#define ADD_6O 0.592007 +//back, right +#define ADD_7X 3552.727539 +#define ADD_7Y -2957.776123 +#define ADD_7Z 125.001015 +#define ADD_7O 0.592007 +//behind, left +#define ADD_8X 3547.156250 +#define ADD_8Y -2953.162354 +#define ADD_8Z 125.001015 +#define ADD_8O 0.592007 +//behind, right +#define ADD_9X 3550.202148 +#define ADD_9Y -2957.437744 +#define ADD_9Z 125.001015 +#define ADD_9O 0.592007 + +#define SPELL_KNOCKAWAY 10101 +#define SPELL_PUMMEL 15615 +#define SPELL_SHOOT 20463 +//#define SPELL_SUMMONCRIMSONRIFLEMAN 17279 + +struct MANGOS_DLL_DECL boss_cannon_master_willeyAI : public ScriptedAI +{ + boss_cannon_master_willeyAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 KnockAway_Timer; + uint32 Pummel_Timer; + uint32 Shoot_Timer; + uint32 SummonRifleman_Timer; + + void Reset() + { + Shoot_Timer = 1000; + Pummel_Timer = 7000; + KnockAway_Timer = 11000; + SummonRifleman_Timer = 15000; + } + + void JustDied(Unit* Victim) + { + m_creature->SummonCreature(11054,ADD_1X,ADD_1Y,ADD_1Z,ADD_1O,TEMPSUMMON_TIMED_DESPAWN,240000); + m_creature->SummonCreature(11054,ADD_2X,ADD_2Y,ADD_2Z,ADD_2O,TEMPSUMMON_TIMED_DESPAWN,240000); + m_creature->SummonCreature(11054,ADD_3X,ADD_3Y,ADD_3Z,ADD_3O,TEMPSUMMON_TIMED_DESPAWN,240000); + m_creature->SummonCreature(11054,ADD_4X,ADD_4Y,ADD_4Z,ADD_4O,TEMPSUMMON_TIMED_DESPAWN,240000); + m_creature->SummonCreature(11054,ADD_5X,ADD_5Y,ADD_5Z,ADD_5O,TEMPSUMMON_TIMED_DESPAWN,240000); + m_creature->SummonCreature(11054,ADD_7X,ADD_7Y,ADD_7Z,ADD_7O,TEMPSUMMON_TIMED_DESPAWN,240000); + m_creature->SummonCreature(11054,ADD_9X,ADD_9Y,ADD_9Z,ADD_9O,TEMPSUMMON_TIMED_DESPAWN,240000); + } + + void Aggro(Unit *who) + { + } + + + void UpdateAI(const uint32 diff) + { + //Return since we have no target + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + //Pummel + if (Pummel_Timer < diff) + { + //Cast + if (rand()%100 < 90) //90% chance to cast + { + DoCast(m_creature->getVictim(),SPELL_PUMMEL); + } + //12 seconds until we should cast this again + Pummel_Timer = 12000; + }else Pummel_Timer -= diff; + + //KnockAway + if (KnockAway_Timer < diff) + { + //Cast + if (rand()%100 < 80) //80% chance to cast + { + DoCast(m_creature->getVictim(),SPELL_KNOCKAWAY); + } + //14 seconds until we should cast this again + KnockAway_Timer = 14000; + }else KnockAway_Timer -= diff; + + //Shoot + if (Shoot_Timer < diff) + { + //Cast + DoCast(m_creature->getVictim(),SPELL_SHOOT); + //1 seconds until we should cast this again + Shoot_Timer = 1000; + }else Shoot_Timer -= diff; + + //SummonRifleman + if (SummonRifleman_Timer < diff) + { + //Cast + switch (rand()%9) + { + case 0: + m_creature->SummonCreature(11054,ADD_1X,ADD_1Y,ADD_1Z,ADD_1O,TEMPSUMMON_TIMED_DESPAWN,240000); + m_creature->SummonCreature(11054,ADD_2X,ADD_2Y,ADD_2Z,ADD_2O,TEMPSUMMON_TIMED_DESPAWN,240000); + m_creature->SummonCreature(11054,ADD_4X,ADD_4Y,ADD_4Z,ADD_4O,TEMPSUMMON_TIMED_DESPAWN,240000); + break; + case 1: + m_creature->SummonCreature(11054,ADD_2X,ADD_2Y,ADD_2Z,ADD_2O,TEMPSUMMON_TIMED_DESPAWN,240000); + m_creature->SummonCreature(11054,ADD_3X,ADD_3Y,ADD_3Z,ADD_3O,TEMPSUMMON_TIMED_DESPAWN,240000); + m_creature->SummonCreature(11054,ADD_5X,ADD_5Y,ADD_5Z,ADD_5O,TEMPSUMMON_TIMED_DESPAWN,240000); + break; + case 2: + m_creature->SummonCreature(11054,ADD_3X,ADD_3Y,ADD_3Z,ADD_3O,TEMPSUMMON_TIMED_DESPAWN,240000); + m_creature->SummonCreature(11054,ADD_4X,ADD_4Y,ADD_4Z,ADD_4O,TEMPSUMMON_TIMED_DESPAWN,240000); + m_creature->SummonCreature(11054,ADD_6X,ADD_6Y,ADD_6Z,ADD_6O,TEMPSUMMON_TIMED_DESPAWN,240000); + break; + case 3: + m_creature->SummonCreature(11054,ADD_4X,ADD_4Y,ADD_4Z,ADD_4O,TEMPSUMMON_TIMED_DESPAWN,240000); + m_creature->SummonCreature(11054,ADD_5X,ADD_5Y,ADD_5Z,ADD_5O,TEMPSUMMON_TIMED_DESPAWN,240000); + m_creature->SummonCreature(11054,ADD_7X,ADD_7Y,ADD_7Z,ADD_7O,TEMPSUMMON_TIMED_DESPAWN,240000); + break; + case 4: + m_creature->SummonCreature(11054,ADD_5X,ADD_5Y,ADD_5Z,ADD_5O,TEMPSUMMON_TIMED_DESPAWN,240000); + m_creature->SummonCreature(11054,ADD_6X,ADD_6Y,ADD_6Z,ADD_6O,TEMPSUMMON_TIMED_DESPAWN,240000); + m_creature->SummonCreature(11054,ADD_8X,ADD_8Y,ADD_8Z,ADD_8O,TEMPSUMMON_TIMED_DESPAWN,240000); + break; + case 5: + m_creature->SummonCreature(11054,ADD_6X,ADD_6Y,ADD_6Z,ADD_6O,TEMPSUMMON_TIMED_DESPAWN,240000); + m_creature->SummonCreature(11054,ADD_7X,ADD_7Y,ADD_7Z,ADD_7O,TEMPSUMMON_TIMED_DESPAWN,240000); + m_creature->SummonCreature(11054,ADD_9X,ADD_9Y,ADD_9Z,ADD_9O,TEMPSUMMON_TIMED_DESPAWN,240000); + break; + case 6: + m_creature->SummonCreature(11054,ADD_7X,ADD_7Y,ADD_7Z,ADD_7O,TEMPSUMMON_TIMED_DESPAWN,240000); + m_creature->SummonCreature(11054,ADD_8X,ADD_8Y,ADD_8Z,ADD_8O,TEMPSUMMON_TIMED_DESPAWN,240000); + m_creature->SummonCreature(11054,ADD_1X,ADD_1Y,ADD_1Z,ADD_1O,TEMPSUMMON_TIMED_DESPAWN,240000); + break; + case 7: + m_creature->SummonCreature(11054,ADD_8X,ADD_8Y,ADD_8Z,ADD_8O,TEMPSUMMON_TIMED_DESPAWN,240000); + m_creature->SummonCreature(11054,ADD_9X,ADD_9Y,ADD_9Z,ADD_9O,TEMPSUMMON_TIMED_DESPAWN,240000); + m_creature->SummonCreature(11054,ADD_2X,ADD_2Y,ADD_2Z,ADD_2O,TEMPSUMMON_TIMED_DESPAWN,240000); + break; + case 8: + m_creature->SummonCreature(11054,ADD_9X,ADD_9Y,ADD_9Z,ADD_9O,TEMPSUMMON_TIMED_DESPAWN,240000); + m_creature->SummonCreature(11054,ADD_1X,ADD_1Y,ADD_1Z,ADD_1O,TEMPSUMMON_TIMED_DESPAWN,240000); + m_creature->SummonCreature(11054,ADD_3X,ADD_3Y,ADD_3Z,ADD_3O,TEMPSUMMON_TIMED_DESPAWN,240000); + break; + } + //30 seconds until we should cast this again + SummonRifleman_Timer = 30000; + }else SummonRifleman_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; +CreatureAI* GetAI_boss_cannon_master_willey(Creature *_Creature) +{ + return new boss_cannon_master_willeyAI (_Creature); +} + + +void AddSC_boss_cannon_master_willey() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_cannon_master_willey"; + newscript->GetAI = GetAI_boss_cannon_master_willey; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/stratholme/boss_dathrohan_balnazzar.cpp b/src/bindings/scripts/scripts/zone/stratholme/boss_dathrohan_balnazzar.cpp index 0db8cff8141..30669e8c008 100644 --- a/src/bindings/scripts/scripts/zone/stratholme/boss_dathrohan_balnazzar.cpp +++ b/src/bindings/scripts/scripts/zone/stratholme/boss_dathrohan_balnazzar.cpp @@ -1,316 +1,316 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -/* ScriptData -SDName: boss_darhrohan_balnazzar -SD%Complete: 100 -SDComment: CHECK SQL -SDCategory: Stratholme -EndScriptData */ - -#include "precompiled.h" - -//Dathrohan spells -#define SPELL_CRUSADERSHAMMER 17286 //AOE stun -#define SPELL_CRUSADERSTRIKE 17281 -#define SPELL_MINDBLAST 17287 -#define SPELL_HOLYSTRIKE 17284 //weapon dmg +3 -#define SPELL_DAZED 1604 - -//Transform -#define SPELL_BALNAZZARTRANSFORM 17288 //restore full HP/mana, trigger spell Balnazzar Transform Stun - -//Balnazzar spells -#define SPELL_SHADOWSHOCK 20603 //AOE 740-860dmg -#define SPELL_PSYCHICSCREAM 15398 //One target, might want to make a code selecting random target -#define SPELL_DEEPSLEEP 24777 //AOE, ten sec -#define SPELL_SHADOWBOLTVOLLEY 20741 //AOE, 255-345dmg -//#define SPELL_MINDCONTROL 15690 //core support needed - -//Summon -//G1 front, left -#define ADD_1X 3444.156250 -#define ADD_1Y -3090.626709 -#define ADD_1Z 135.002319 -#define ADD_1O 2.240888 -//G1 front, right -#define ADD_2X 3449.123535 -#define ADD_2Y -3087.009766 -#define ADD_2Z 135.002319 -#define ADD_2O 2.240888 -//G1 back left -#define ADD_3X 3446.246826 -#define ADD_3Y -3093.466309 -#define ADD_3Z 135.002319 -#define ADD_3O 2.240888 -//G1 back, right -#define ADD_4X 3451.160889 -#define ADD_4Y -3089.904785 -#define ADD_4Z 135.002136 -#define ADD_4O 2.240888 -//G2 front, left -#define ADD_5X 3457.995117 -#define ADD_5Y -3080.916504 -#define ADD_5Z 135.002319 -#define ADD_5O 3.784981 -//G2 front, right -#define ADD_6X 3454.302490 -#define ADD_6Y -3076.330566 -#define ADD_6Z 135.002319 -#define ADD_6O 3.784981 -//G2 back left -#define ADD_7X 3460.975098 -#define ADD_7Y -3078.901367 -#define ADD_7Z 135.002319 -#define ADD_7O 3.784981 -//G2 back, right -#define ADD_8X 3457.338867 -#define ADD_8Y -3073.979004 -#define ADD_8Z 135.002319 -#define ADD_8O 3.784981 - -struct MANGOS_DLL_DECL boss_dathrohan_balnazzarAI : public ScriptedAI -{ - boss_dathrohan_balnazzarAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 CrusadersHammer_Timer; - uint32 CrusaderStrike_Timer; - uint32 MindBlast_Timer; - uint32 HolyStrike_Timer; - uint32 Dazed_Timer; - uint32 ShadowShock_Timer; - uint32 PsychicScream_Timer; - uint32 DeepSleep_Timer; - uint32 ShadowBoltVolley_Timer; - // uint32 MindControl_Timer; - bool Transformed; - - void Reset() - { - CrusadersHammer_Timer = 8000; - CrusaderStrike_Timer = 14000; - MindBlast_Timer = 17000; - HolyStrike_Timer = 18000; - Dazed_Timer = 23000; - ShadowShock_Timer = 4000; - PsychicScream_Timer = 16000; - DeepSleep_Timer = 20000; - ShadowBoltVolley_Timer = 9000; - // MindControl_Timer = 10000; - Transformed = false; - - m_creature->SetUInt32Value(UNIT_FIELD_DISPLAYID,10545); - m_creature->SetFloatValue(OBJECT_FIELD_SCALE_X, 1.00f); - - } - - void JustDied(Unit* Victim) - { - m_creature->SummonCreature(10698,ADD_1X,ADD_1Y,ADD_1Z,ADD_1O,TEMPSUMMON_TIMED_DESPAWN,240000); - m_creature->SummonCreature(10698,ADD_2X,ADD_2Y,ADD_2Z,ADD_2O,TEMPSUMMON_TIMED_DESPAWN,240000); - m_creature->SummonCreature(10698,ADD_3X,ADD_3Y,ADD_3Z,ADD_3O,TEMPSUMMON_TIMED_DESPAWN,240000); - m_creature->SummonCreature(10698,ADD_4X,ADD_4Y,ADD_4Z,ADD_4O,TEMPSUMMON_TIMED_DESPAWN,240000); - m_creature->SummonCreature(10698,ADD_5X,ADD_5Y,ADD_5Z,ADD_5O,TEMPSUMMON_TIMED_DESPAWN,240000); - m_creature->SummonCreature(10698,ADD_6X,ADD_6Y,ADD_6Z,ADD_6O,TEMPSUMMON_TIMED_DESPAWN,240000); - m_creature->SummonCreature(10698,ADD_7X,ADD_7Y,ADD_7Z,ADD_7O,TEMPSUMMON_TIMED_DESPAWN,240000); - m_creature->SummonCreature(10698,ADD_8X,ADD_8Y,ADD_8Z,ADD_8O,TEMPSUMMON_TIMED_DESPAWN,240000); - } - - void Aggro(Unit *who) - { - } - - void UpdateAI(const uint32 diff) - { - //Return since we have no target - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - //START NOT TRANSFORMED - if (!Transformed) - { - //CrusadersHammer - if (CrusadersHammer_Timer < diff && !m_creature->IsNonMeleeSpellCasted(false)) - { - //Cast - if (rand()%100 < 75) //50% chance to cast - { - DoCast(m_creature->getVictim(),SPELL_CRUSADERSHAMMER); - } - //15 seconds until we should cast this again - CrusadersHammer_Timer = 12000; - }else CrusadersHammer_Timer -= diff; - - //CrusaderStrike - if (CrusaderStrike_Timer < diff && !m_creature->IsNonMeleeSpellCasted(false)) - { - //Cast - if (rand()%100 < 60) //50% chance to cast - { - DoCast(m_creature->getVictim(),SPELL_CRUSADERSTRIKE); - } - //15 seconds until we should cast this again - CrusaderStrike_Timer = 15000; - }else CrusaderStrike_Timer -= diff; - - //MindBlast - if (MindBlast_Timer < diff && !m_creature->IsNonMeleeSpellCasted(false)) - { - //Cast - if (rand()%100 < 70) //70% chance to cast - { - DoCast(m_creature->getVictim(),SPELL_MINDBLAST); - } - //15 seconds until we should cast this again - MindBlast_Timer = 10000; - }else MindBlast_Timer -= diff; - - //HolyStrike - if (HolyStrike_Timer < diff && !m_creature->IsNonMeleeSpellCasted(false)) - { - //Cast - if (rand()%100 < 50) //50% chance to cast - { - DoCast(m_creature->getVictim(),SPELL_HOLYSTRIKE); - } - //15 seconds until we should cast this again - HolyStrike_Timer = 15000; - }else HolyStrike_Timer -= diff; - - //Dazed - if (Dazed_Timer < diff && !m_creature->IsNonMeleeSpellCasted(false)) - { - //Cast - if (rand()%100 < 50) //50% chance to cast - { - DoCast(m_creature->getVictim(),SPELL_DAZED); - } - //15 seconds until we should cast this again - Dazed_Timer = 15000; - }else Dazed_Timer -= diff; - - //BalnazzarTransform - if (m_creature->GetHealth()*100 / m_creature->GetMaxHealth() < 40) - { - //Cast - DoCast(m_creature,SPELL_BALNAZZARTRANSFORM); //restore hp, mana and stun - m_creature->SetUInt32Value(UNIT_FIELD_DISPLAYID,10691); //then change disaply id - m_creature->SetFloatValue(OBJECT_FIELD_SCALE_X, 3.00f); //then, change size - Transformed = true; - } - - //START ELSE TRANSFORMED - } else { - - - //MindBlast - if (MindBlast_Timer < diff && !m_creature->IsNonMeleeSpellCasted(false)) - { - //Cast - if (rand()%100 < 60) //70% chance to cast - { - DoCast(m_creature->getVictim(),SPELL_MINDBLAST); - } - //15 seconds until we should cast this again - MindBlast_Timer = 10000; - }else MindBlast_Timer -= diff; - - //ShadowShock - if (ShadowShock_Timer < diff) - { - //Cast - if (rand()%100 < 80) //80% chance to cast - { - DoCast(m_creature->getVictim(),SPELL_SHADOWSHOCK); - } - //15 seconds until we should cast this again - ShadowShock_Timer = 11000; - }else ShadowShock_Timer -= diff; - - //PsychicScream - if (PsychicScream_Timer < diff) - { - //Cast - if (rand()%100 < 60) //60% chance to cast - { - DoCast(m_creature->getVictim(),SPELL_PSYCHICSCREAM); - if(m_creature->getThreatManager().getThreat(m_creature->getVictim())) - m_creature->getThreatManager().modifyThreatPercent(m_creature->getVictim(),-50); - } - //15 seconds until we should cast this again - PsychicScream_Timer = 20000; - }else PsychicScream_Timer -= diff; - - //DeepSleep - if (DeepSleep_Timer < diff) - { - //Cast - if (rand()%100 < 55) //55% chance to cast - { - //Cast - Unit* target = NULL; - - target = SelectUnit(SELECT_TARGET_RANDOM,0); - if (target) - DoCast(target,SPELL_DEEPSLEEP); - } - //15 seconds until we should cast this again - DeepSleep_Timer = 15000; - }else DeepSleep_Timer -= diff; - - //ShadowBoltVolley - if (ShadowBoltVolley_Timer < diff) - { - //Cast - if (rand()%100 < 75) //75% chance to cast - { - DoCast(m_creature->getVictim(),SPELL_SHADOWBOLTVOLLEY); - } - //15 seconds until we should cast this again - ShadowBoltVolley_Timer = 13000; - }else ShadowBoltVolley_Timer -= diff; - - //MindControl - // if (MindControl_Timer < diff) - // { - //Cast - // if (rand()%100 < 50) //50% chance to cast - // { - // DoCast(m_creature->getVictim(),SPELL_MINDCONTROL); - // } - //15 seconds until we should cast this again - // MindControl_Timer = 15000; - // }else MindControl_Timer -= diff; - - //END ELSE TRANSFORMED - } - - DoMeleeAttackIfReady(); - } -}; -CreatureAI* GetAI_boss_dathrohan_balnazzar(Creature *_Creature) -{ - return new boss_dathrohan_balnazzarAI (_Creature); -} - -void AddSC_boss_dathrohan_balnazzar() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_dathrohan_balnazzar"; - newscript->GetAI = GetAI_boss_dathrohan_balnazzar; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +/* ScriptData +SDName: boss_darhrohan_balnazzar +SD%Complete: 100 +SDComment: CHECK SQL +SDCategory: Stratholme +EndScriptData */ + +#include "precompiled.h" + +//Dathrohan spells +#define SPELL_CRUSADERSHAMMER 17286 //AOE stun +#define SPELL_CRUSADERSTRIKE 17281 +#define SPELL_MINDBLAST 17287 +#define SPELL_HOLYSTRIKE 17284 //weapon dmg +3 +#define SPELL_DAZED 1604 + +//Transform +#define SPELL_BALNAZZARTRANSFORM 17288 //restore full HP/mana, trigger spell Balnazzar Transform Stun + +//Balnazzar spells +#define SPELL_SHADOWSHOCK 20603 //AOE 740-860dmg +#define SPELL_PSYCHICSCREAM 15398 //One target, might want to make a code selecting random target +#define SPELL_DEEPSLEEP 24777 //AOE, ten sec +#define SPELL_SHADOWBOLTVOLLEY 20741 //AOE, 255-345dmg +//#define SPELL_MINDCONTROL 15690 //core support needed + +//Summon +//G1 front, left +#define ADD_1X 3444.156250 +#define ADD_1Y -3090.626709 +#define ADD_1Z 135.002319 +#define ADD_1O 2.240888 +//G1 front, right +#define ADD_2X 3449.123535 +#define ADD_2Y -3087.009766 +#define ADD_2Z 135.002319 +#define ADD_2O 2.240888 +//G1 back left +#define ADD_3X 3446.246826 +#define ADD_3Y -3093.466309 +#define ADD_3Z 135.002319 +#define ADD_3O 2.240888 +//G1 back, right +#define ADD_4X 3451.160889 +#define ADD_4Y -3089.904785 +#define ADD_4Z 135.002136 +#define ADD_4O 2.240888 +//G2 front, left +#define ADD_5X 3457.995117 +#define ADD_5Y -3080.916504 +#define ADD_5Z 135.002319 +#define ADD_5O 3.784981 +//G2 front, right +#define ADD_6X 3454.302490 +#define ADD_6Y -3076.330566 +#define ADD_6Z 135.002319 +#define ADD_6O 3.784981 +//G2 back left +#define ADD_7X 3460.975098 +#define ADD_7Y -3078.901367 +#define ADD_7Z 135.002319 +#define ADD_7O 3.784981 +//G2 back, right +#define ADD_8X 3457.338867 +#define ADD_8Y -3073.979004 +#define ADD_8Z 135.002319 +#define ADD_8O 3.784981 + +struct MANGOS_DLL_DECL boss_dathrohan_balnazzarAI : public ScriptedAI +{ + boss_dathrohan_balnazzarAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 CrusadersHammer_Timer; + uint32 CrusaderStrike_Timer; + uint32 MindBlast_Timer; + uint32 HolyStrike_Timer; + uint32 Dazed_Timer; + uint32 ShadowShock_Timer; + uint32 PsychicScream_Timer; + uint32 DeepSleep_Timer; + uint32 ShadowBoltVolley_Timer; + // uint32 MindControl_Timer; + bool Transformed; + + void Reset() + { + CrusadersHammer_Timer = 8000; + CrusaderStrike_Timer = 14000; + MindBlast_Timer = 17000; + HolyStrike_Timer = 18000; + Dazed_Timer = 23000; + ShadowShock_Timer = 4000; + PsychicScream_Timer = 16000; + DeepSleep_Timer = 20000; + ShadowBoltVolley_Timer = 9000; + // MindControl_Timer = 10000; + Transformed = false; + + m_creature->SetUInt32Value(UNIT_FIELD_DISPLAYID,10545); + m_creature->SetFloatValue(OBJECT_FIELD_SCALE_X, 1.00f); + + } + + void JustDied(Unit* Victim) + { + m_creature->SummonCreature(10698,ADD_1X,ADD_1Y,ADD_1Z,ADD_1O,TEMPSUMMON_TIMED_DESPAWN,240000); + m_creature->SummonCreature(10698,ADD_2X,ADD_2Y,ADD_2Z,ADD_2O,TEMPSUMMON_TIMED_DESPAWN,240000); + m_creature->SummonCreature(10698,ADD_3X,ADD_3Y,ADD_3Z,ADD_3O,TEMPSUMMON_TIMED_DESPAWN,240000); + m_creature->SummonCreature(10698,ADD_4X,ADD_4Y,ADD_4Z,ADD_4O,TEMPSUMMON_TIMED_DESPAWN,240000); + m_creature->SummonCreature(10698,ADD_5X,ADD_5Y,ADD_5Z,ADD_5O,TEMPSUMMON_TIMED_DESPAWN,240000); + m_creature->SummonCreature(10698,ADD_6X,ADD_6Y,ADD_6Z,ADD_6O,TEMPSUMMON_TIMED_DESPAWN,240000); + m_creature->SummonCreature(10698,ADD_7X,ADD_7Y,ADD_7Z,ADD_7O,TEMPSUMMON_TIMED_DESPAWN,240000); + m_creature->SummonCreature(10698,ADD_8X,ADD_8Y,ADD_8Z,ADD_8O,TEMPSUMMON_TIMED_DESPAWN,240000); + } + + void Aggro(Unit *who) + { + } + + void UpdateAI(const uint32 diff) + { + //Return since we have no target + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + //START NOT TRANSFORMED + if (!Transformed) + { + //CrusadersHammer + if (CrusadersHammer_Timer < diff && !m_creature->IsNonMeleeSpellCasted(false)) + { + //Cast + if (rand()%100 < 75) //50% chance to cast + { + DoCast(m_creature->getVictim(),SPELL_CRUSADERSHAMMER); + } + //15 seconds until we should cast this again + CrusadersHammer_Timer = 12000; + }else CrusadersHammer_Timer -= diff; + + //CrusaderStrike + if (CrusaderStrike_Timer < diff && !m_creature->IsNonMeleeSpellCasted(false)) + { + //Cast + if (rand()%100 < 60) //50% chance to cast + { + DoCast(m_creature->getVictim(),SPELL_CRUSADERSTRIKE); + } + //15 seconds until we should cast this again + CrusaderStrike_Timer = 15000; + }else CrusaderStrike_Timer -= diff; + + //MindBlast + if (MindBlast_Timer < diff && !m_creature->IsNonMeleeSpellCasted(false)) + { + //Cast + if (rand()%100 < 70) //70% chance to cast + { + DoCast(m_creature->getVictim(),SPELL_MINDBLAST); + } + //15 seconds until we should cast this again + MindBlast_Timer = 10000; + }else MindBlast_Timer -= diff; + + //HolyStrike + if (HolyStrike_Timer < diff && !m_creature->IsNonMeleeSpellCasted(false)) + { + //Cast + if (rand()%100 < 50) //50% chance to cast + { + DoCast(m_creature->getVictim(),SPELL_HOLYSTRIKE); + } + //15 seconds until we should cast this again + HolyStrike_Timer = 15000; + }else HolyStrike_Timer -= diff; + + //Dazed + if (Dazed_Timer < diff && !m_creature->IsNonMeleeSpellCasted(false)) + { + //Cast + if (rand()%100 < 50) //50% chance to cast + { + DoCast(m_creature->getVictim(),SPELL_DAZED); + } + //15 seconds until we should cast this again + Dazed_Timer = 15000; + }else Dazed_Timer -= diff; + + //BalnazzarTransform + if (m_creature->GetHealth()*100 / m_creature->GetMaxHealth() < 40) + { + //Cast + DoCast(m_creature,SPELL_BALNAZZARTRANSFORM); //restore hp, mana and stun + m_creature->SetUInt32Value(UNIT_FIELD_DISPLAYID,10691); //then change disaply id + m_creature->SetFloatValue(OBJECT_FIELD_SCALE_X, 3.00f); //then, change size + Transformed = true; + } + + //START ELSE TRANSFORMED + } else { + + + //MindBlast + if (MindBlast_Timer < diff && !m_creature->IsNonMeleeSpellCasted(false)) + { + //Cast + if (rand()%100 < 60) //70% chance to cast + { + DoCast(m_creature->getVictim(),SPELL_MINDBLAST); + } + //15 seconds until we should cast this again + MindBlast_Timer = 10000; + }else MindBlast_Timer -= diff; + + //ShadowShock + if (ShadowShock_Timer < diff) + { + //Cast + if (rand()%100 < 80) //80% chance to cast + { + DoCast(m_creature->getVictim(),SPELL_SHADOWSHOCK); + } + //15 seconds until we should cast this again + ShadowShock_Timer = 11000; + }else ShadowShock_Timer -= diff; + + //PsychicScream + if (PsychicScream_Timer < diff) + { + //Cast + if (rand()%100 < 60) //60% chance to cast + { + DoCast(m_creature->getVictim(),SPELL_PSYCHICSCREAM); + if(m_creature->getThreatManager().getThreat(m_creature->getVictim())) + m_creature->getThreatManager().modifyThreatPercent(m_creature->getVictim(),-50); + } + //15 seconds until we should cast this again + PsychicScream_Timer = 20000; + }else PsychicScream_Timer -= diff; + + //DeepSleep + if (DeepSleep_Timer < diff) + { + //Cast + if (rand()%100 < 55) //55% chance to cast + { + //Cast + Unit* target = NULL; + + target = SelectUnit(SELECT_TARGET_RANDOM,0); + if (target) + DoCast(target,SPELL_DEEPSLEEP); + } + //15 seconds until we should cast this again + DeepSleep_Timer = 15000; + }else DeepSleep_Timer -= diff; + + //ShadowBoltVolley + if (ShadowBoltVolley_Timer < diff) + { + //Cast + if (rand()%100 < 75) //75% chance to cast + { + DoCast(m_creature->getVictim(),SPELL_SHADOWBOLTVOLLEY); + } + //15 seconds until we should cast this again + ShadowBoltVolley_Timer = 13000; + }else ShadowBoltVolley_Timer -= diff; + + //MindControl + // if (MindControl_Timer < diff) + // { + //Cast + // if (rand()%100 < 50) //50% chance to cast + // { + // DoCast(m_creature->getVictim(),SPELL_MINDCONTROL); + // } + //15 seconds until we should cast this again + // MindControl_Timer = 15000; + // }else MindControl_Timer -= diff; + + //END ELSE TRANSFORMED + } + + DoMeleeAttackIfReady(); + } +}; +CreatureAI* GetAI_boss_dathrohan_balnazzar(Creature *_Creature) +{ + return new boss_dathrohan_balnazzarAI (_Creature); +} + +void AddSC_boss_dathrohan_balnazzar() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_dathrohan_balnazzar"; + newscript->GetAI = GetAI_boss_dathrohan_balnazzar; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/stratholme/boss_magistrate_barthilas.cpp b/src/bindings/scripts/scripts/zone/stratholme/boss_magistrate_barthilas.cpp index aceb05b1614..7011c8451c1 100644 --- a/src/bindings/scripts/scripts/zone/stratholme/boss_magistrate_barthilas.cpp +++ b/src/bindings/scripts/scripts/zone/stratholme/boss_magistrate_barthilas.cpp @@ -1,114 +1,114 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -/* ScriptData -SDName: boss_magistrate_barthilas -SD%Complete: 100 -SDComment: -SDCategory: Stratholme -EndScriptData */ - -#include "precompiled.h" - -#define SPELL_DRAININGBLOW 16793 -#define SPELL_CROWDPUMMEL 10887 -#define SPELL_MIGHTYBLOW 14099 -#define SPELL_DAZED 1604 - -struct MANGOS_DLL_DECL boss_magistrate_barthilasAI : public ScriptedAI -{ - boss_magistrate_barthilasAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 DrainingBlow_Timer; - uint32 CrowdPummel_Timer; - uint32 MightyBlow_Timer; - uint32 Dazed_Timer; - - void Reset() - { - DrainingBlow_Timer = 4000; - CrowdPummel_Timer = 13000; - MightyBlow_Timer = 11000; - Dazed_Timer = 7000; - } - - void Aggro(Unit *who) - { - } - - void UpdateAI(const uint32 diff) - { - //Return since we have no target - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - //DrainingBlow - if (DrainingBlow_Timer < diff) - { - //Cast - DoCast(m_creature->getVictim(),SPELL_DRAININGBLOW); - - //4 seconds until we should cast this again - DrainingBlow_Timer = 4000; - }else DrainingBlow_Timer -= diff; - - //CrowdPummel - if (CrowdPummel_Timer < diff) - { - //Cast - DoCast(m_creature->getVictim(),SPELL_CROWDPUMMEL); - - //13 seconds until we should cast this agian - CrowdPummel_Timer = 13000; - }else CrowdPummel_Timer -= diff; - - //MightyBlow - if (MightyBlow_Timer < diff) - { - //Cast - DoCast(m_creature->getVictim(),SPELL_MIGHTYBLOW); - - //11 seconds until we should cast this again - MightyBlow_Timer = 11000; - }else MightyBlow_Timer -= diff; - - //Dazed - if (Dazed_Timer < diff) - { - //Cast - DoCast(m_creature->getVictim(),SPELL_DAZED); - - //20 seconds until we should cast this again - Dazed_Timer = 20000; - }else Dazed_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; -CreatureAI* GetAI_boss_magistrate_barthilas(Creature *_Creature) -{ - return new boss_magistrate_barthilasAI (_Creature); -} - - -void AddSC_boss_magistrate_barthilas() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_magistrate_barthilas"; - newscript->GetAI = GetAI_boss_magistrate_barthilas; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +/* ScriptData +SDName: boss_magistrate_barthilas +SD%Complete: 100 +SDComment: +SDCategory: Stratholme +EndScriptData */ + +#include "precompiled.h" + +#define SPELL_DRAININGBLOW 16793 +#define SPELL_CROWDPUMMEL 10887 +#define SPELL_MIGHTYBLOW 14099 +#define SPELL_DAZED 1604 + +struct MANGOS_DLL_DECL boss_magistrate_barthilasAI : public ScriptedAI +{ + boss_magistrate_barthilasAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 DrainingBlow_Timer; + uint32 CrowdPummel_Timer; + uint32 MightyBlow_Timer; + uint32 Dazed_Timer; + + void Reset() + { + DrainingBlow_Timer = 4000; + CrowdPummel_Timer = 13000; + MightyBlow_Timer = 11000; + Dazed_Timer = 7000; + } + + void Aggro(Unit *who) + { + } + + void UpdateAI(const uint32 diff) + { + //Return since we have no target + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + //DrainingBlow + if (DrainingBlow_Timer < diff) + { + //Cast + DoCast(m_creature->getVictim(),SPELL_DRAININGBLOW); + + //4 seconds until we should cast this again + DrainingBlow_Timer = 4000; + }else DrainingBlow_Timer -= diff; + + //CrowdPummel + if (CrowdPummel_Timer < diff) + { + //Cast + DoCast(m_creature->getVictim(),SPELL_CROWDPUMMEL); + + //13 seconds until we should cast this agian + CrowdPummel_Timer = 13000; + }else CrowdPummel_Timer -= diff; + + //MightyBlow + if (MightyBlow_Timer < diff) + { + //Cast + DoCast(m_creature->getVictim(),SPELL_MIGHTYBLOW); + + //11 seconds until we should cast this again + MightyBlow_Timer = 11000; + }else MightyBlow_Timer -= diff; + + //Dazed + if (Dazed_Timer < diff) + { + //Cast + DoCast(m_creature->getVictim(),SPELL_DAZED); + + //20 seconds until we should cast this again + Dazed_Timer = 20000; + }else Dazed_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; +CreatureAI* GetAI_boss_magistrate_barthilas(Creature *_Creature) +{ + return new boss_magistrate_barthilasAI (_Creature); +} + + +void AddSC_boss_magistrate_barthilas() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_magistrate_barthilas"; + newscript->GetAI = GetAI_boss_magistrate_barthilas; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/stratholme/boss_maleki_the_pallid.cpp b/src/bindings/scripts/scripts/zone/stratholme/boss_maleki_the_pallid.cpp index 6c3c75e9bc6..d5535071f26 100644 --- a/src/bindings/scripts/scripts/zone/stratholme/boss_maleki_the_pallid.cpp +++ b/src/bindings/scripts/scripts/zone/stratholme/boss_maleki_the_pallid.cpp @@ -1,119 +1,119 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -/* ScriptData -SDName: boss_maleki_the_pallid -SD%Complete: 100 -SDComment: -SDCategory: Stratholme -EndScriptData */ - -#include "precompiled.h" - -#define SPELL_FROSTNOVA 22645 -#define SPELL_FROSTBOLT 17503 -#define SPELL_DRAINLIFE 20743 -#define SPELL_ICETOMB 16869 - -struct MANGOS_DLL_DECL boss_maleki_the_pallidAI : public ScriptedAI -{ - boss_maleki_the_pallidAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 FrostNova_Timer; - uint32 Frostbolt_Timer; - uint32 IceTomb_Timer; - uint32 DrainLife_Timer; - - void Reset() - { - FrostNova_Timer = 11000; - Frostbolt_Timer = 1000; - IceTomb_Timer = 16000; - DrainLife_Timer = 31000; - } - - void Aggro(Unit *who) - { - } - - void UpdateAI(const uint32 diff) - { - //Return since we have no target - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - //FrostNova - if (FrostNova_Timer < diff) - { - //Cast - DoCast(m_creature->getVictim(),SPELL_FROSTNOVA); - //23 seconds until we should cast this again - FrostNova_Timer = 23000; - }else FrostNova_Timer -= diff; - - //Frostbolt - if (Frostbolt_Timer < diff) - { - //Cast - if (rand()%100 < 90) //90% chance to cast - { - DoCast(m_creature->getVictim(),SPELL_FROSTBOLT); - } - //3.5 seconds until we should cast this again - Frostbolt_Timer = 3500; - }else Frostbolt_Timer -= diff; - - //IceTomb - if (IceTomb_Timer < diff) - { - //Cast - if (rand()%100 < 65) //65% chance to cast - { - DoCast(m_creature->getVictim(),SPELL_ICETOMB); - } - //28 seconds until we should cast this again - IceTomb_Timer = 28000; - }else IceTomb_Timer -= diff; - - //DrainLife - if (DrainLife_Timer < diff) - { - //Cast - if (rand()%100 < 55) //55% chance to cast - { - DoCast(m_creature->getVictim(),SPELL_DRAINLIFE); - } - //31 seconds until we should cast this again - DrainLife_Timer = 31000; - }else DrainLife_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; -CreatureAI* GetAI_boss_maleki_the_pallid(Creature *_Creature) -{ - return new boss_maleki_the_pallidAI (_Creature); -} - - -void AddSC_boss_maleki_the_pallid() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_maleki_the_pallid"; - newscript->GetAI = GetAI_boss_maleki_the_pallid; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +/* ScriptData +SDName: boss_maleki_the_pallid +SD%Complete: 100 +SDComment: +SDCategory: Stratholme +EndScriptData */ + +#include "precompiled.h" + +#define SPELL_FROSTNOVA 22645 +#define SPELL_FROSTBOLT 17503 +#define SPELL_DRAINLIFE 20743 +#define SPELL_ICETOMB 16869 + +struct MANGOS_DLL_DECL boss_maleki_the_pallidAI : public ScriptedAI +{ + boss_maleki_the_pallidAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 FrostNova_Timer; + uint32 Frostbolt_Timer; + uint32 IceTomb_Timer; + uint32 DrainLife_Timer; + + void Reset() + { + FrostNova_Timer = 11000; + Frostbolt_Timer = 1000; + IceTomb_Timer = 16000; + DrainLife_Timer = 31000; + } + + void Aggro(Unit *who) + { + } + + void UpdateAI(const uint32 diff) + { + //Return since we have no target + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + //FrostNova + if (FrostNova_Timer < diff) + { + //Cast + DoCast(m_creature->getVictim(),SPELL_FROSTNOVA); + //23 seconds until we should cast this again + FrostNova_Timer = 23000; + }else FrostNova_Timer -= diff; + + //Frostbolt + if (Frostbolt_Timer < diff) + { + //Cast + if (rand()%100 < 90) //90% chance to cast + { + DoCast(m_creature->getVictim(),SPELL_FROSTBOLT); + } + //3.5 seconds until we should cast this again + Frostbolt_Timer = 3500; + }else Frostbolt_Timer -= diff; + + //IceTomb + if (IceTomb_Timer < diff) + { + //Cast + if (rand()%100 < 65) //65% chance to cast + { + DoCast(m_creature->getVictim(),SPELL_ICETOMB); + } + //28 seconds until we should cast this again + IceTomb_Timer = 28000; + }else IceTomb_Timer -= diff; + + //DrainLife + if (DrainLife_Timer < diff) + { + //Cast + if (rand()%100 < 55) //55% chance to cast + { + DoCast(m_creature->getVictim(),SPELL_DRAINLIFE); + } + //31 seconds until we should cast this again + DrainLife_Timer = 31000; + }else DrainLife_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; +CreatureAI* GetAI_boss_maleki_the_pallid(Creature *_Creature) +{ + return new boss_maleki_the_pallidAI (_Creature); +} + + +void AddSC_boss_maleki_the_pallid() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_maleki_the_pallid"; + newscript->GetAI = GetAI_boss_maleki_the_pallid; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/stratholme/boss_nerubenkan.cpp b/src/bindings/scripts/scripts/zone/stratholme/boss_nerubenkan.cpp index 59bd632836c..273c2f60961 100644 --- a/src/bindings/scripts/scripts/zone/stratholme/boss_nerubenkan.cpp +++ b/src/bindings/scripts/scripts/zone/stratholme/boss_nerubenkan.cpp @@ -1,138 +1,138 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -/* ScriptData -SDName: boss_nerubenkan -SD%Complete: 100 -SDComment: -SDCategory: Stratholme -EndScriptData */ - -#include "precompiled.h" - -#define SPELL_ENCASINGWEBS 4962 -#define SPELL_PIERCEARMOR 6016 -#define SPELL_VIRULENTPOISON 16427 -//#define SPELL_RAISEUNDEADSCARAB 17235 - -struct MANGOS_DLL_DECL boss_nerubenkanAI : public ScriptedAI -{ - boss_nerubenkanAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 EncasingWebs_Timer; - uint32 PierceArmor_Timer; - uint32 VirulentPoison_Timer; - uint32 RaiseUndeadScarab_Timer; - int Rand; - int RandX; - int RandY; - Creature* Summoned; - - void Reset() - { - VirulentPoison_Timer = 3000; - EncasingWebs_Timer = 7000; - PierceArmor_Timer = 19000; - RaiseUndeadScarab_Timer = 11000; - } - - void Aggro(Unit *who) - { - } - - void RaiseUndeadScarab(Unit* victim) - { - Rand = rand()%10; - switch (rand()%2) - { - case 0: RandX = 0 - Rand; break; - case 1: RandX = 0 + Rand; break; - } - Rand = 0; - Rand = rand()%10; - switch (rand()%2) - { - case 0: RandY = 0 - Rand; break; - case 1: RandY = 0 + Rand; break; - } - Rand = 0; - Summoned = DoSpawnCreature(10876, RandX, RandY, 0, 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 180000); - if(Summoned) - ((CreatureAI*)Summoned->AI())->AttackStart(victim); - } - - void UpdateAI(const uint32 diff) - { - //Return since we have no target - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - //EncasingWebs - if (EncasingWebs_Timer < diff) - { - //Cast - DoCast(m_creature->getVictim(),SPELL_ENCASINGWEBS); - //30 seconds until we should cast this again - EncasingWebs_Timer = 30000; - }else EncasingWebs_Timer -= diff; - - //PierceArmor - if (PierceArmor_Timer < diff) - { - //Cast - if (rand()%100 < 75) //75% chance to cast - { - DoCast(m_creature->getVictim(),SPELL_PIERCEARMOR); - } - //35 seconds until we should cast this again - PierceArmor_Timer = 35000; - }else PierceArmor_Timer -= diff; - - //VirulentPoison - if (VirulentPoison_Timer < diff) - { - //Cast - DoCast(m_creature->getVictim(),SPELL_VIRULENTPOISON); - //20 seconds until we should cast this again - VirulentPoison_Timer = 20000; - }else VirulentPoison_Timer -= diff; - - //RaiseUndeadScarab - if (RaiseUndeadScarab_Timer < diff) - { - //Cast - RaiseUndeadScarab(m_creature->getVictim()); - //16 seconds until we should cast this again - RaiseUndeadScarab_Timer = 16000; - }else RaiseUndeadScarab_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; -CreatureAI* GetAI_boss_nerubenkan(Creature *_Creature) -{ - return new boss_nerubenkanAI (_Creature); -} - - -void AddSC_boss_nerubenkan() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_nerubenkan"; - newscript->GetAI = GetAI_boss_nerubenkan; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +/* ScriptData +SDName: boss_nerubenkan +SD%Complete: 100 +SDComment: +SDCategory: Stratholme +EndScriptData */ + +#include "precompiled.h" + +#define SPELL_ENCASINGWEBS 4962 +#define SPELL_PIERCEARMOR 6016 +#define SPELL_VIRULENTPOISON 16427 +//#define SPELL_RAISEUNDEADSCARAB 17235 + +struct MANGOS_DLL_DECL boss_nerubenkanAI : public ScriptedAI +{ + boss_nerubenkanAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 EncasingWebs_Timer; + uint32 PierceArmor_Timer; + uint32 VirulentPoison_Timer; + uint32 RaiseUndeadScarab_Timer; + int Rand; + int RandX; + int RandY; + Creature* Summoned; + + void Reset() + { + VirulentPoison_Timer = 3000; + EncasingWebs_Timer = 7000; + PierceArmor_Timer = 19000; + RaiseUndeadScarab_Timer = 11000; + } + + void Aggro(Unit *who) + { + } + + void RaiseUndeadScarab(Unit* victim) + { + Rand = rand()%10; + switch (rand()%2) + { + case 0: RandX = 0 - Rand; break; + case 1: RandX = 0 + Rand; break; + } + Rand = 0; + Rand = rand()%10; + switch (rand()%2) + { + case 0: RandY = 0 - Rand; break; + case 1: RandY = 0 + Rand; break; + } + Rand = 0; + Summoned = DoSpawnCreature(10876, RandX, RandY, 0, 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 180000); + if(Summoned) + ((CreatureAI*)Summoned->AI())->AttackStart(victim); + } + + void UpdateAI(const uint32 diff) + { + //Return since we have no target + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + //EncasingWebs + if (EncasingWebs_Timer < diff) + { + //Cast + DoCast(m_creature->getVictim(),SPELL_ENCASINGWEBS); + //30 seconds until we should cast this again + EncasingWebs_Timer = 30000; + }else EncasingWebs_Timer -= diff; + + //PierceArmor + if (PierceArmor_Timer < diff) + { + //Cast + if (rand()%100 < 75) //75% chance to cast + { + DoCast(m_creature->getVictim(),SPELL_PIERCEARMOR); + } + //35 seconds until we should cast this again + PierceArmor_Timer = 35000; + }else PierceArmor_Timer -= diff; + + //VirulentPoison + if (VirulentPoison_Timer < diff) + { + //Cast + DoCast(m_creature->getVictim(),SPELL_VIRULENTPOISON); + //20 seconds until we should cast this again + VirulentPoison_Timer = 20000; + }else VirulentPoison_Timer -= diff; + + //RaiseUndeadScarab + if (RaiseUndeadScarab_Timer < diff) + { + //Cast + RaiseUndeadScarab(m_creature->getVictim()); + //16 seconds until we should cast this again + RaiseUndeadScarab_Timer = 16000; + }else RaiseUndeadScarab_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; +CreatureAI* GetAI_boss_nerubenkan(Creature *_Creature) +{ + return new boss_nerubenkanAI (_Creature); +} + + +void AddSC_boss_nerubenkan() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_nerubenkan"; + newscript->GetAI = GetAI_boss_nerubenkan; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/stratholme/boss_order_of_silver_hand.cpp b/src/bindings/scripts/scripts/zone/stratholme/boss_order_of_silver_hand.cpp index 9da5b48e55c..685d523a12e 100644 --- a/src/bindings/scripts/scripts/zone/stratholme/boss_order_of_silver_hand.cpp +++ b/src/bindings/scripts/scripts/zone/stratholme/boss_order_of_silver_hand.cpp @@ -1,161 +1,161 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -/* ScriptData -SDName: Boss_Silver_Hand_Bosses -SD%Complete: 40 -SDComment: Basic script to have support for Horde paladin epic mount (quest 9737). All 5 members of Order of the Silver Hand running this script (least for now) -SDCategory: Stratholme -EndScriptData */ - -#include "precompiled.h" -#include "def_stratholme.h" - -/*##### -# Additional: -# Although this is a working solution, the correct would be in addition to check if Aurius is dead. -# Once player extinguish the eternal flame (cast spell 31497->start event 11206) Aurius should become hostile. -# Once Aurius is defeated, he should be the one summoning the ghosts. -#####*/ - -#define SH_GREGOR 17910 -#define SH_CATHELA 17911 -#define SH_NEMAS 17912 -#define SH_AELMAR 17913 -#define SH_VICAR 17914 -#define SH_QUEST_CREDIT 17915 - -#define SPELL_HOLY_LIGHT 25263 -#define SPELL_DIVINE_SHIELD 13874 - -struct MANGOS_DLL_DECL boss_silver_hand_bossesAI : public ScriptedAI -{ - boss_silver_hand_bossesAI(Creature* c) : ScriptedAI(c) - { - pInstance = ((ScriptedInstance*)c->GetInstanceData()); - Reset(); - } - - ScriptedInstance *pInstance; - - uint32 HolyLight_Timer; - uint32 DivineShield_Timer; - - void Reset() - { - HolyLight_Timer = 20000; - DivineShield_Timer = 20000; - - if(pInstance) - { - switch(m_creature->GetEntry()) - { - case SH_AELMAR: - pInstance->SetData(TYPE_SH_AELMAR, 0); - break; - case SH_CATHELA: - pInstance->SetData(TYPE_SH_CATHELA, 0); - break; - case SH_GREGOR: - pInstance->SetData(TYPE_SH_GREGOR, 0); - break; - case SH_NEMAS: - pInstance->SetData(TYPE_SH_NEMAS, 0); - break; - case SH_VICAR: - pInstance->SetData(TYPE_SH_VICAR, 0); - break; - } - } - } - - void Aggro(Unit* who) - { - } - - void JustDied(Unit* Killer) - { - if(pInstance) - { - switch(m_creature->GetEntry()) - { - case SH_AELMAR: - pInstance->SetData(TYPE_SH_AELMAR, 2); - break; - case SH_CATHELA: - pInstance->SetData(TYPE_SH_CATHELA, 2); - break; - case SH_GREGOR: - pInstance->SetData(TYPE_SH_GREGOR, 2); - break; - case SH_NEMAS: - pInstance->SetData(TYPE_SH_NEMAS, 2); - break; - case SH_VICAR: - pInstance->SetData(TYPE_SH_VICAR, 2); - break; - } - if(pInstance->GetData(TYPE_SH_QUEST) && Killer->GetTypeId() == TYPEID_PLAYER) - ((Player*)Killer)->KilledMonster(SH_QUEST_CREDIT,m_creature->GetGUID()); - } - } - - void UpdateAI(const uint32 diff) - { - //Return since we have no target - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - if (HolyLight_Timer < diff) - { - if (m_creature->GetHealth()*5 < m_creature->GetMaxHealth()) - { - DoCast(m_creature, SPELL_HOLY_LIGHT); - HolyLight_Timer = 20000; - } - }else HolyLight_Timer -= diff; - - if (DivineShield_Timer < diff) - { - if (m_creature->GetHealth()*20 < m_creature->GetMaxHealth()) - { - DoCast(m_creature, SPELL_DIVINE_SHIELD); - DivineShield_Timer = 40000; - } - }else DivineShield_Timer -= diff; - - DoMeleeAttackIfReady(); - } - -}; -CreatureAI* GetAI_boss_silver_hand_bossesAI(Creature *_Creature) -{ - return new boss_silver_hand_bossesAI (_Creature); -} - -/*##### -# -#####*/ - -void AddSC_boss_order_of_silver_hand() -{ - Script *newscript; - - newscript = new Script; - newscript->Name="boss_silver_hand_bosses"; - newscript->GetAI = GetAI_boss_silver_hand_bossesAI; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +/* ScriptData +SDName: Boss_Silver_Hand_Bosses +SD%Complete: 40 +SDComment: Basic script to have support for Horde paladin epic mount (quest 9737). All 5 members of Order of the Silver Hand running this script (least for now) +SDCategory: Stratholme +EndScriptData */ + +#include "precompiled.h" +#include "def_stratholme.h" + +/*##### +# Additional: +# Although this is a working solution, the correct would be in addition to check if Aurius is dead. +# Once player extinguish the eternal flame (cast spell 31497->start event 11206) Aurius should become hostile. +# Once Aurius is defeated, he should be the one summoning the ghosts. +#####*/ + +#define SH_GREGOR 17910 +#define SH_CATHELA 17911 +#define SH_NEMAS 17912 +#define SH_AELMAR 17913 +#define SH_VICAR 17914 +#define SH_QUEST_CREDIT 17915 + +#define SPELL_HOLY_LIGHT 25263 +#define SPELL_DIVINE_SHIELD 13874 + +struct MANGOS_DLL_DECL boss_silver_hand_bossesAI : public ScriptedAI +{ + boss_silver_hand_bossesAI(Creature* c) : ScriptedAI(c) + { + pInstance = ((ScriptedInstance*)c->GetInstanceData()); + Reset(); + } + + ScriptedInstance *pInstance; + + uint32 HolyLight_Timer; + uint32 DivineShield_Timer; + + void Reset() + { + HolyLight_Timer = 20000; + DivineShield_Timer = 20000; + + if(pInstance) + { + switch(m_creature->GetEntry()) + { + case SH_AELMAR: + pInstance->SetData(TYPE_SH_AELMAR, 0); + break; + case SH_CATHELA: + pInstance->SetData(TYPE_SH_CATHELA, 0); + break; + case SH_GREGOR: + pInstance->SetData(TYPE_SH_GREGOR, 0); + break; + case SH_NEMAS: + pInstance->SetData(TYPE_SH_NEMAS, 0); + break; + case SH_VICAR: + pInstance->SetData(TYPE_SH_VICAR, 0); + break; + } + } + } + + void Aggro(Unit* who) + { + } + + void JustDied(Unit* Killer) + { + if(pInstance) + { + switch(m_creature->GetEntry()) + { + case SH_AELMAR: + pInstance->SetData(TYPE_SH_AELMAR, 2); + break; + case SH_CATHELA: + pInstance->SetData(TYPE_SH_CATHELA, 2); + break; + case SH_GREGOR: + pInstance->SetData(TYPE_SH_GREGOR, 2); + break; + case SH_NEMAS: + pInstance->SetData(TYPE_SH_NEMAS, 2); + break; + case SH_VICAR: + pInstance->SetData(TYPE_SH_VICAR, 2); + break; + } + if(pInstance->GetData(TYPE_SH_QUEST) && Killer->GetTypeId() == TYPEID_PLAYER) + ((Player*)Killer)->KilledMonster(SH_QUEST_CREDIT,m_creature->GetGUID()); + } + } + + void UpdateAI(const uint32 diff) + { + //Return since we have no target + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + if (HolyLight_Timer < diff) + { + if (m_creature->GetHealth()*5 < m_creature->GetMaxHealth()) + { + DoCast(m_creature, SPELL_HOLY_LIGHT); + HolyLight_Timer = 20000; + } + }else HolyLight_Timer -= diff; + + if (DivineShield_Timer < diff) + { + if (m_creature->GetHealth()*20 < m_creature->GetMaxHealth()) + { + DoCast(m_creature, SPELL_DIVINE_SHIELD); + DivineShield_Timer = 40000; + } + }else DivineShield_Timer -= diff; + + DoMeleeAttackIfReady(); + } + +}; +CreatureAI* GetAI_boss_silver_hand_bossesAI(Creature *_Creature) +{ + return new boss_silver_hand_bossesAI (_Creature); +} + +/*##### +# +#####*/ + +void AddSC_boss_order_of_silver_hand() +{ + Script *newscript; + + newscript = new Script; + newscript->Name="boss_silver_hand_bosses"; + newscript->GetAI = GetAI_boss_silver_hand_bossesAI; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/stratholme/boss_postmaster_malown.cpp b/src/bindings/scripts/scripts/zone/stratholme/boss_postmaster_malown.cpp index c303207101d..f8ba61c42ed 100644 --- a/src/bindings/scripts/scripts/zone/stratholme/boss_postmaster_malown.cpp +++ b/src/bindings/scripts/scripts/zone/stratholme/boss_postmaster_malown.cpp @@ -1,144 +1,144 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -/* ScriptData -SDName: boss_postmaster_malown -SD%Complete: 50 -SDComment: -SDCategory: Stratholme -EndScriptData */ - -#include "precompiled.h" - -//Spell ID to summon this guy is 24627 "Summon Postmaster Malown" -//He should be spawned along with three other elites once the third postbox has been opened - -#define SAY_MALOWNED "You just got MALOWNED!" - -#define SPELL_WAILINGDEAD 7713 -#define SPELL_BACKHAND 6253 -#define SPELL_CURSEOFWEAKNESS 8552 -#define SPELL_CURSEOFTONGUES 12889 -#define SPELL_CALLOFTHEGRAVE 17831 - -struct MANGOS_DLL_DECL boss_postmaster_malownAI : public ScriptedAI -{ - boss_postmaster_malownAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 WailingDead_Timer; - uint32 Backhand_Timer; - uint32 CurseOfWeakness_Timer; - uint32 CurseOfTongues_Timer; - uint32 CallOfTheGrave_Timer; - bool HasYelled; - - void Reset() - { - WailingDead_Timer = 19000; //lasts 6 sec - Backhand_Timer = 8000; //2 sec stun - CurseOfWeakness_Timer = 20000; //lasts 2 mins - CurseOfTongues_Timer = 22000; - CallOfTheGrave_Timer = 25000; - HasYelled = false; - } - - void Aggro(Unit *who) - { - } - - void UpdateAI(const uint32 diff) - { - //Return since we have no target - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - //WailingDead - if (WailingDead_Timer < diff) - { - //Cast - if (rand()%100 < 65) //65% chance to cast - { - DoCast(m_creature->getVictim(),SPELL_WAILINGDEAD); - } - //19 seconds until we should cast this again - WailingDead_Timer = 19000; - }else WailingDead_Timer -= diff; - - //Backhand - if (Backhand_Timer < diff) - { - //Cast - if (rand()%100 < 45) //45% chance to cast - { - DoCast(m_creature->getVictim(),SPELL_BACKHAND); - } - //8 seconds until we should cast this again - Backhand_Timer = 8000; - }else Backhand_Timer -= diff; - - //CurseOfWeakness - if (CurseOfWeakness_Timer < diff) - { - //Cast - if (rand()%100 < 3) //3% chance to cast - { - DoCast(m_creature->getVictim(),SPELL_CURSEOFWEAKNESS); - } - //20 seconds until we should cast this again - CurseOfWeakness_Timer = 20000; - }else CurseOfWeakness_Timer -= diff; - - //CurseOfTongues - if (CurseOfTongues_Timer < diff) - { - //Cast - if (rand()%100 < 3) //3% chance to cast - { - DoCast(m_creature->getVictim(),SPELL_CURSEOFTONGUES); - } - //22 seconds until we should cast this again - CurseOfTongues_Timer = 22000; - }else CurseOfTongues_Timer -= diff; - - //CallOfTheGrave - if (CallOfTheGrave_Timer < diff) - { - //Cast - if (rand()%100 < 5) //5% chance to cast - { - DoCast(m_creature->getVictim(),SPELL_CALLOFTHEGRAVE); - } - //25 seconds until we should cast this again - CallOfTheGrave_Timer = 25000; - }else CallOfTheGrave_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; -CreatureAI* GetAI_boss_postmaster_malown(Creature *_Creature) -{ - return new boss_postmaster_malownAI (_Creature); -} - - -void AddSC_boss_postmaster_malown() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_postmaster_malown"; - newscript->GetAI = GetAI_boss_postmaster_malown; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +/* ScriptData +SDName: boss_postmaster_malown +SD%Complete: 50 +SDComment: +SDCategory: Stratholme +EndScriptData */ + +#include "precompiled.h" + +//Spell ID to summon this guy is 24627 "Summon Postmaster Malown" +//He should be spawned along with three other elites once the third postbox has been opened + +#define SAY_MALOWNED "You just got MALOWNED!" + +#define SPELL_WAILINGDEAD 7713 +#define SPELL_BACKHAND 6253 +#define SPELL_CURSEOFWEAKNESS 8552 +#define SPELL_CURSEOFTONGUES 12889 +#define SPELL_CALLOFTHEGRAVE 17831 + +struct MANGOS_DLL_DECL boss_postmaster_malownAI : public ScriptedAI +{ + boss_postmaster_malownAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 WailingDead_Timer; + uint32 Backhand_Timer; + uint32 CurseOfWeakness_Timer; + uint32 CurseOfTongues_Timer; + uint32 CallOfTheGrave_Timer; + bool HasYelled; + + void Reset() + { + WailingDead_Timer = 19000; //lasts 6 sec + Backhand_Timer = 8000; //2 sec stun + CurseOfWeakness_Timer = 20000; //lasts 2 mins + CurseOfTongues_Timer = 22000; + CallOfTheGrave_Timer = 25000; + HasYelled = false; + } + + void Aggro(Unit *who) + { + } + + void UpdateAI(const uint32 diff) + { + //Return since we have no target + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + //WailingDead + if (WailingDead_Timer < diff) + { + //Cast + if (rand()%100 < 65) //65% chance to cast + { + DoCast(m_creature->getVictim(),SPELL_WAILINGDEAD); + } + //19 seconds until we should cast this again + WailingDead_Timer = 19000; + }else WailingDead_Timer -= diff; + + //Backhand + if (Backhand_Timer < diff) + { + //Cast + if (rand()%100 < 45) //45% chance to cast + { + DoCast(m_creature->getVictim(),SPELL_BACKHAND); + } + //8 seconds until we should cast this again + Backhand_Timer = 8000; + }else Backhand_Timer -= diff; + + //CurseOfWeakness + if (CurseOfWeakness_Timer < diff) + { + //Cast + if (rand()%100 < 3) //3% chance to cast + { + DoCast(m_creature->getVictim(),SPELL_CURSEOFWEAKNESS); + } + //20 seconds until we should cast this again + CurseOfWeakness_Timer = 20000; + }else CurseOfWeakness_Timer -= diff; + + //CurseOfTongues + if (CurseOfTongues_Timer < diff) + { + //Cast + if (rand()%100 < 3) //3% chance to cast + { + DoCast(m_creature->getVictim(),SPELL_CURSEOFTONGUES); + } + //22 seconds until we should cast this again + CurseOfTongues_Timer = 22000; + }else CurseOfTongues_Timer -= diff; + + //CallOfTheGrave + if (CallOfTheGrave_Timer < diff) + { + //Cast + if (rand()%100 < 5) //5% chance to cast + { + DoCast(m_creature->getVictim(),SPELL_CALLOFTHEGRAVE); + } + //25 seconds until we should cast this again + CallOfTheGrave_Timer = 25000; + }else CallOfTheGrave_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; +CreatureAI* GetAI_boss_postmaster_malown(Creature *_Creature) +{ + return new boss_postmaster_malownAI (_Creature); +} + + +void AddSC_boss_postmaster_malown() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_postmaster_malown"; + newscript->GetAI = GetAI_boss_postmaster_malown; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/stratholme/boss_ramstein_the_gorger.cpp b/src/bindings/scripts/scripts/zone/stratholme/boss_ramstein_the_gorger.cpp index 7b175f5b9ff..8e482024cd2 100644 --- a/src/bindings/scripts/scripts/zone/stratholme/boss_ramstein_the_gorger.cpp +++ b/src/bindings/scripts/scripts/zone/stratholme/boss_ramstein_the_gorger.cpp @@ -1,92 +1,92 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -/* ScriptData -SDName: boss_ramstein_the_gorger -SD%Complete: 100 -SDComment: -SDCategory: Stratholme -EndScriptData */ - -#include "precompiled.h" - -#define SPELL_TRAMPLE 15550 -#define SPELL_KNOCKOUT 17307 - -struct MANGOS_DLL_DECL boss_ramstein_the_gorgerAI : public ScriptedAI -{ - boss_ramstein_the_gorgerAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 Trample_Timer; - uint32 Knockout_Timer; - - void Reset() - { - Trample_Timer = 3000; - Knockout_Timer = 12000; - } - - void Aggro(Unit *who) - { - } - - void UpdateAI(const uint32 diff) - { - //Return since we have no target - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - //Trample - if (Trample_Timer < diff) - { - //Cast - if (rand()%100 < 75) //75% chance to cast - { - DoCast(m_creature->getVictim(),SPELL_TRAMPLE); - } - //7 seconds until we should cast this again - Trample_Timer = 7000; - }else Trample_Timer -= diff; - - //Knockout - if (Knockout_Timer < diff) - { - //Cast - if (rand()%100 < 70) //70% chance to cast - { - DoCast(m_creature->getVictim(),SPELL_KNOCKOUT); - } - //10 seconds until we should cast this again - Knockout_Timer = 10000; - }else Knockout_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; -CreatureAI* GetAI_boss_ramstein_the_gorger(Creature *_Creature) -{ - return new boss_ramstein_the_gorgerAI (_Creature); -} - - -void AddSC_boss_ramstein_the_gorger() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_ramstein_the_gorger"; - newscript->GetAI = GetAI_boss_ramstein_the_gorger; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +/* ScriptData +SDName: boss_ramstein_the_gorger +SD%Complete: 100 +SDComment: +SDCategory: Stratholme +EndScriptData */ + +#include "precompiled.h" + +#define SPELL_TRAMPLE 15550 +#define SPELL_KNOCKOUT 17307 + +struct MANGOS_DLL_DECL boss_ramstein_the_gorgerAI : public ScriptedAI +{ + boss_ramstein_the_gorgerAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 Trample_Timer; + uint32 Knockout_Timer; + + void Reset() + { + Trample_Timer = 3000; + Knockout_Timer = 12000; + } + + void Aggro(Unit *who) + { + } + + void UpdateAI(const uint32 diff) + { + //Return since we have no target + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + //Trample + if (Trample_Timer < diff) + { + //Cast + if (rand()%100 < 75) //75% chance to cast + { + DoCast(m_creature->getVictim(),SPELL_TRAMPLE); + } + //7 seconds until we should cast this again + Trample_Timer = 7000; + }else Trample_Timer -= diff; + + //Knockout + if (Knockout_Timer < diff) + { + //Cast + if (rand()%100 < 70) //70% chance to cast + { + DoCast(m_creature->getVictim(),SPELL_KNOCKOUT); + } + //10 seconds until we should cast this again + Knockout_Timer = 10000; + }else Knockout_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; +CreatureAI* GetAI_boss_ramstein_the_gorger(Creature *_Creature) +{ + return new boss_ramstein_the_gorgerAI (_Creature); +} + + +void AddSC_boss_ramstein_the_gorger() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_ramstein_the_gorger"; + newscript->GetAI = GetAI_boss_ramstein_the_gorger; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/stratholme/boss_timmy_the_cruel.cpp b/src/bindings/scripts/scripts/zone/stratholme/boss_timmy_the_cruel.cpp index 1fc4eedc5f5..a4ca4cd6a7d 100644 --- a/src/bindings/scripts/scripts/zone/stratholme/boss_timmy_the_cruel.cpp +++ b/src/bindings/scripts/scripts/zone/stratholme/boss_timmy_the_cruel.cpp @@ -1,103 +1,103 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -/* ScriptData -SDName: boss_timmy_the_cruel -SD%Complete: 100 -SDComment: -SDCategory: Stratholme -EndScriptData */ - -#include "precompiled.h" - -#define SAY_SPAWN "TIMMY!" - -#define SPELL_RAVENOUSCLAW 17470 - -struct MANGOS_DLL_DECL boss_timmy_the_cruelAI : public ScriptedAI -{ - boss_timmy_the_cruelAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 RavenousClaw_Timer; - bool HasYelled; - - void Reset() - { - RavenousClaw_Timer = 10000; - HasYelled = false; - } - - void Aggro(Unit *who) - { - } - - void MoveInLineOfSight(Unit *who) - { - if (!who || m_creature->getVictim()) - return; - - if (who->isTargetableForAttack() && who->isInAccessablePlaceFor(m_creature) && m_creature->IsHostileTo(who)) - { - float attackRadius = m_creature->GetAttackDistance(who); - if (m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->GetDistanceZ(who) <= CREATURE_Z_ATTACK_RANGE && m_creature->IsWithinLOSInMap(who)) - { - if(who->HasStealthAura()) - who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); - - if (!HasYelled) - { - DoYell(SAY_SPAWN,LANG_UNIVERSAL,NULL); - HasYelled = true; - } - - //Begin melee attack if we are within range - DoStartAttackAndMovement(who); - } - } - } - - void UpdateAI(const uint32 diff) - { - //Return since we have no target - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - //RavenousClaw - if (RavenousClaw_Timer < diff) - { - //Cast - DoCast(m_creature->getVictim(),SPELL_RAVENOUSCLAW); - //15 seconds until we should cast this again - RavenousClaw_Timer = 15000; - }else RavenousClaw_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; -CreatureAI* GetAI_boss_timmy_the_cruel(Creature *_Creature) -{ - return new boss_timmy_the_cruelAI (_Creature); -} - - -void AddSC_boss_timmy_the_cruel() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_timmy_the_cruel"; - newscript->GetAI = GetAI_boss_timmy_the_cruel; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +/* ScriptData +SDName: boss_timmy_the_cruel +SD%Complete: 100 +SDComment: +SDCategory: Stratholme +EndScriptData */ + +#include "precompiled.h" + +#define SAY_SPAWN "TIMMY!" + +#define SPELL_RAVENOUSCLAW 17470 + +struct MANGOS_DLL_DECL boss_timmy_the_cruelAI : public ScriptedAI +{ + boss_timmy_the_cruelAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 RavenousClaw_Timer; + bool HasYelled; + + void Reset() + { + RavenousClaw_Timer = 10000; + HasYelled = false; + } + + void Aggro(Unit *who) + { + } + + void MoveInLineOfSight(Unit *who) + { + if (!who || m_creature->getVictim()) + return; + + if (who->isTargetableForAttack() && who->isInAccessablePlaceFor(m_creature) && m_creature->IsHostileTo(who)) + { + float attackRadius = m_creature->GetAttackDistance(who); + if (m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->GetDistanceZ(who) <= CREATURE_Z_ATTACK_RANGE && m_creature->IsWithinLOSInMap(who)) + { + if(who->HasStealthAura()) + who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); + + if (!HasYelled) + { + DoYell(SAY_SPAWN,LANG_UNIVERSAL,NULL); + HasYelled = true; + } + + //Begin melee attack if we are within range + DoStartAttackAndMovement(who); + } + } + } + + void UpdateAI(const uint32 diff) + { + //Return since we have no target + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + //RavenousClaw + if (RavenousClaw_Timer < diff) + { + //Cast + DoCast(m_creature->getVictim(),SPELL_RAVENOUSCLAW); + //15 seconds until we should cast this again + RavenousClaw_Timer = 15000; + }else RavenousClaw_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; +CreatureAI* GetAI_boss_timmy_the_cruel(Creature *_Creature) +{ + return new boss_timmy_the_cruelAI (_Creature); +} + + +void AddSC_boss_timmy_the_cruel() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_timmy_the_cruel"; + newscript->GetAI = GetAI_boss_timmy_the_cruel; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/stratholme/def_stratholme.h b/src/bindings/scripts/scripts/zone/stratholme/def_stratholme.h index 27c181a77f5..26283d7b0fd 100644 --- a/src/bindings/scripts/scripts/zone/stratholme/def_stratholme.h +++ b/src/bindings/scripts/scripts/zone/stratholme/def_stratholme.h @@ -1,14 +1,14 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 -* This program is free software licensed under GPL version 2 -* Please see the included DOCS/LICENSE.TXT for more information */ - -#ifndef DEF_STRATHOLME_H -#define DEF_STRATHOLME_H - -#define TYPE_SH_AELMAR 1 -#define TYPE_SH_CATHELA 2 -#define TYPE_SH_GREGOR 3 -#define TYPE_SH_NEMAS 4 -#define TYPE_SH_VICAR 5 -#define TYPE_SH_QUEST 6 -#endif +/* Copyright (C) 2006 - 2008 ScriptDev2 +* This program is free software licensed under GPL version 2 +* Please see the included DOCS/LICENSE.TXT for more information */ + +#ifndef DEF_STRATHOLME_H +#define DEF_STRATHOLME_H + +#define TYPE_SH_AELMAR 1 +#define TYPE_SH_CATHELA 2 +#define TYPE_SH_GREGOR 3 +#define TYPE_SH_NEMAS 4 +#define TYPE_SH_VICAR 5 +#define TYPE_SH_QUEST 6 +#endif diff --git a/src/bindings/scripts/scripts/zone/stratholme/instance_stratholme.cpp b/src/bindings/scripts/scripts/zone/stratholme/instance_stratholme.cpp index 8277d6e043a..bd93cc9ca75 100644 --- a/src/bindings/scripts/scripts/zone/stratholme/instance_stratholme.cpp +++ b/src/bindings/scripts/scripts/zone/stratholme/instance_stratholme.cpp @@ -1,77 +1,77 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -/* ScriptData -SDName: instance_stratholme -SD%Complete: 100 -SDComment: -SDCategory: Stratholme -EndScriptData */ - -#include "precompiled.h" -#include "def_stratholme.h" - -struct MANGOS_DLL_DECL instance_stratholme : public ScriptedInstance -{ - instance_stratholme(Map *Map) : ScriptedInstance(Map) {Initialize();}; - - bool IsSilverHandDead[5]; - - void SetData(uint32 type, uint32 data) - { - switch(type) - { - case TYPE_SH_AELMAR: - IsSilverHandDead[0] = (data) ? true : false; - break; - case TYPE_SH_CATHELA: - IsSilverHandDead[1] = (data) ? true : false; - break; - case TYPE_SH_GREGOR: - IsSilverHandDead[2] = (data) ? true : false; - break; - case TYPE_SH_NEMAS: - IsSilverHandDead[3] = (data) ? true : false; - break; - case TYPE_SH_VICAR: - IsSilverHandDead[4] = (data) ? true : false; - break; - } - } - - uint32 GetData(uint32 type) - { - if(type == TYPE_SH_QUEST) - if(IsSilverHandDead[0] && IsSilverHandDead[1] && IsSilverHandDead[2] && IsSilverHandDead[3] && IsSilverHandDead[4]) - return true; - - return false; - } -}; - -InstanceData* GetInstanceData_instance_stratholme(Map* map) -{ - return new instance_stratholme(map); -} - -void AddSC_instance_stratholme() -{ - Script *newscript; - newscript = new Script; - newscript->Name = "instance_stratholme"; - newscript->GetInstanceData = GetInstanceData_instance_stratholme; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +/* ScriptData +SDName: instance_stratholme +SD%Complete: 100 +SDComment: +SDCategory: Stratholme +EndScriptData */ + +#include "precompiled.h" +#include "def_stratholme.h" + +struct MANGOS_DLL_DECL instance_stratholme : public ScriptedInstance +{ + instance_stratholme(Map *Map) : ScriptedInstance(Map) {Initialize();}; + + bool IsSilverHandDead[5]; + + void SetData(uint32 type, uint32 data) + { + switch(type) + { + case TYPE_SH_AELMAR: + IsSilverHandDead[0] = (data) ? true : false; + break; + case TYPE_SH_CATHELA: + IsSilverHandDead[1] = (data) ? true : false; + break; + case TYPE_SH_GREGOR: + IsSilverHandDead[2] = (data) ? true : false; + break; + case TYPE_SH_NEMAS: + IsSilverHandDead[3] = (data) ? true : false; + break; + case TYPE_SH_VICAR: + IsSilverHandDead[4] = (data) ? true : false; + break; + } + } + + uint32 GetData(uint32 type) + { + if(type == TYPE_SH_QUEST) + if(IsSilverHandDead[0] && IsSilverHandDead[1] && IsSilverHandDead[2] && IsSilverHandDead[3] && IsSilverHandDead[4]) + return true; + + return false; + } +}; + +InstanceData* GetInstanceData_instance_stratholme(Map* map) +{ + return new instance_stratholme(map); +} + +void AddSC_instance_stratholme() +{ + Script *newscript; + newscript = new Script; + newscript->Name = "instance_stratholme"; + newscript->GetInstanceData = GetInstanceData_instance_stratholme; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/stratholme/stratholme.cpp b/src/bindings/scripts/scripts/zone/stratholme/stratholme.cpp index 33e88bc04be..d5f7fc85831 100644 --- a/src/bindings/scripts/scripts/zone/stratholme/stratholme.cpp +++ b/src/bindings/scripts/scripts/zone/stratholme/stratholme.cpp @@ -1,335 +1,335 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -/* ScriptData -SDName: Stratholme -SD%Complete: 100 -SDComment: trash mobs for strat. Simple AI mobs converted to EAI (except Mindless Skeleton and Thuzadin Acolyte) -SDCategory: Stratholme -EndScriptData */ - -#include "precompiled.h" -#include "../../creature/simple_ai.h" - -/*###### -## mob_freed_soul -######*/ - -//Possibly more of these quotes around. -#define SAY_ZAPPED0 "Thanks to Egan" -#define SAY_ZAPPED1 "Rivendare must die" -#define SAY_ZAPPED2 "Who you gonna call?" -#define SAY_ZAPPED3 "Don't cross those beams!" - -struct MANGOS_DLL_DECL mob_freed_soulAI : public ScriptedAI -{ - mob_freed_soulAI(Creature *c) : ScriptedAI(c) {Reset();} - - void Reset() - { - - switch (rand()%4) - { - case 0: - DoSay(SAY_ZAPPED0,LANG_UNIVERSAL,NULL); - break; - case 1: - DoSay(SAY_ZAPPED1,LANG_UNIVERSAL,NULL); - break; - case 2: - DoSay(SAY_ZAPPED2,LANG_UNIVERSAL,NULL); - break; - case 3: - DoSay(SAY_ZAPPED3,LANG_UNIVERSAL,NULL); - break; - } - } - - void Aggro(Unit* who) - { - } -}; -CreatureAI* GetAI_mob_freed_soul(Creature *_Creature) -{ - return new mob_freed_soulAI (_Creature); -} -/*###### -## mob_restless_soul -######*/ - -struct MANGOS_DLL_DECL mob_restless_soulAI : public ScriptedAI -{ - mob_restless_soulAI(Creature *c) : ScriptedAI(c) {Reset();} - - Unit* PlayerHolder; - uint32 Die_Timer; - bool OkToDie; - - void Reset() - { - Die_Timer = 10000; - OkToDie = false; - - PlayerHolder = NULL; - } - - void Aggro(Unit* who) - { - } - - void SummonFreedSoul(Unit* victim) - { - int Rand; - int RandX; - int RandY; - - Rand = rand()%1; - switch (rand()%2) - { - case 0: RandX = 0 - Rand; break; - case 1: RandX = 0 + Rand; break; - } - Rand = 0; - Rand = rand()%1; - switch (rand()%2) - { - case 0: RandY = 0 - Rand; break; - case 1: RandY = 0 + Rand; break; - } - Rand = 0; - DoSpawnCreature(11136, RandX, RandY, 0, 0, TEMPSUMMON_TIMED_DESPAWN, 300000); - } - - void SpellHit(Unit *caster, const SpellEntry *spell) - { - if (caster->GetTypeId() == TYPEID_PLAYER) - { - if(!PlayerHolder && !OkToDie && spell->Id == 17368 && ((Player*)caster)->GetQuestStatus(5282) == QUEST_STATUS_INCOMPLETE) - { - PlayerHolder = caster; - OkToDie = true; - Die_Timer = 5000; - } - } - return; - } - - void JustDied(Unit* Killer) - { - if (Killer->GetTypeId() == TYPEID_PLAYER) - { - //check quest status - if(PlayerHolder == ((Player*)Killer) && ((Player*)Killer)->GetQuestStatus(5282) == QUEST_STATUS_INCOMPLETE) - { - SummonFreedSoul(m_creature->getVictim()); - } - } - } - - void UpdateAI(const uint32 diff) - { - if (PlayerHolder && OkToDie && Die_Timer < diff) - { - PlayerHolder->DealDamage(m_creature, m_creature->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); - } - else Die_Timer -= diff; - - return; - } -}; -CreatureAI* GetAI_mob_restless_soul(Creature *_Creature) -{ - return new mob_restless_soulAI (_Creature); -} - -/*###### -## mobs_spectral_ghostly_citizen -######*/ - -struct MANGOS_DLL_DECL mobs_spectral_ghostly_citizenAI : public ScriptedAI -{ - mobs_spectral_ghostly_citizenAI(Creature *c) : ScriptedAI(c) {Reset();} - - Unit* PlayerHolder; - uint32 Die_Timer; - bool OkToDie; - - void Reset() - { - Die_Timer = 5000; - OkToDie = false; - PlayerHolder = NULL; - } - - void Aggro(Unit* who) - { - } - - void SummonRestlessSoul(Unit* victim) - { - int Rand; - int RandX; - int RandY; - - Rand = rand()%7; - switch (rand()%2) - { - case 0: RandX = 0 - Rand; break; - case 1: RandX = 0 + Rand; break; - } - Rand = 0; - Rand = rand()%7; - switch (rand()%2) - { - case 0: RandY = 0 - Rand; break; - case 1: RandY = 0 + Rand; break; - } - Rand = 0; - DoSpawnCreature(11122, RandX, RandY, 0, 0, TEMPSUMMON_CORPSE_DESPAWN, 600000); - } - - void SpellHit(Unit *caster, const SpellEntry *spell) - { - if (caster->GetTypeId() == TYPEID_PLAYER) - { - if(!PlayerHolder && !OkToDie && spell->Id == 17368 && ((Player*)caster)->GetQuestStatus(5282) == QUEST_STATUS_INCOMPLETE) - { - PlayerHolder = caster; - OkToDie = true; - Die_Timer = 5000; - } - } - return; - } - - void JustDied(Unit* Killer) - { - if (Killer->GetTypeId() == TYPEID_PLAYER) - { - //check quest status - if(PlayerHolder == ((Player*)Killer) && ((Player*)Killer)->GetQuestStatus(5282) == QUEST_STATUS_INCOMPLETE) - { - SummonRestlessSoul(m_creature->getVictim()); //always one - if (rand()%100 < 90) SummonRestlessSoul(m_creature->getVictim()); //90% a second - if (rand()%100 < 50) SummonRestlessSoul(m_creature->getVictim()); //50% a third - if (rand()%100 < 30) SummonRestlessSoul(m_creature->getVictim()); //30% a fourth - } - } - } - - void UpdateAI(const uint32 diff) - { - if (PlayerHolder && OkToDie && Die_Timer < diff) - { - PlayerHolder->DealDamage(m_creature, m_creature->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); - } - else Die_Timer -= diff; - - //Return since we have no target - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - DoMeleeAttackIfReady(); - } -}; -CreatureAI* GetAI_mobs_spectral_ghostly_citizen(Creature *_Creature) -{ - return new mobs_spectral_ghostly_citizenAI (_Creature); -} -bool ReciveEmote_mobs_spectral_ghostly_citizen(Player *player, Creature *_Creature, uint32 emote) -{ - _Creature->HandleEmoteCommand(emote); - - if (emote == TEXTEMOTE_DANCE) - ((mobs_spectral_ghostly_citizenAI*)_Creature->AI())->EnterEvadeMode(); - - return true; -} - -/*###### -## mob_mindless_skeleton -######*/ - -CreatureAI* GetAI_mob_mindless_skeleton(Creature *_Creature) -{ - SimpleAI* ai = new SimpleAI (_Creature); - - //dazed - ai->Spell[0].Enabled = true; - ai->Spell[0].Spell_Id = 13496; - ai->Spell[0].Cooldown = 15000; - ai->Spell[0].First_Cast = 3000; - ai->Spell[0].Cast_Target_Type = CAST_HOSTILE_TARGET; - - ai->EnterEvadeMode(); - - return ai; -} - -/*###### -## mob_thuzadin_acolyte -######*/ - -CreatureAI* GetAI_mob_thuzadin_acolyte(Creature *_Creature) -{ - SimpleAI* ai = new SimpleAI (_Creature); - - //dazed - ai->Spell[0].Enabled = true; - ai->Spell[0].Spell_Id = 13496; - ai->Spell[0].Cooldown = 15000; - ai->Spell[0].First_Cast = 1000; - ai->Spell[0].Cast_Target_Type = CAST_HOSTILE_TARGET; - - ai->EnterEvadeMode(); - - return ai; -} - -/*###### -## -######*/ - -void AddSC_stratholme() -{ - Script *newscript; - - newscript = new Script; - newscript->Name="mob_freed_soul"; - newscript->GetAI = GetAI_mob_freed_soul; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="mob_restless_soul"; - newscript->GetAI = GetAI_mob_restless_soul; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="mobs_spectral_ghostly_citizen"; - newscript->GetAI = GetAI_mobs_spectral_ghostly_citizen; - newscript->pReceiveEmote = &ReciveEmote_mobs_spectral_ghostly_citizen; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="mob_mindless_skeleton"; - newscript->GetAI = GetAI_mob_mindless_skeleton; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="mob_thuzadin_acolyte"; - newscript->GetAI = GetAI_mob_thuzadin_acolyte; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +/* ScriptData +SDName: Stratholme +SD%Complete: 100 +SDComment: trash mobs for strat. Simple AI mobs converted to EAI (except Mindless Skeleton and Thuzadin Acolyte) +SDCategory: Stratholme +EndScriptData */ + +#include "precompiled.h" +#include "../../creature/simple_ai.h" + +/*###### +## mob_freed_soul +######*/ + +//Possibly more of these quotes around. +#define SAY_ZAPPED0 "Thanks to Egan" +#define SAY_ZAPPED1 "Rivendare must die" +#define SAY_ZAPPED2 "Who you gonna call?" +#define SAY_ZAPPED3 "Don't cross those beams!" + +struct MANGOS_DLL_DECL mob_freed_soulAI : public ScriptedAI +{ + mob_freed_soulAI(Creature *c) : ScriptedAI(c) {Reset();} + + void Reset() + { + + switch (rand()%4) + { + case 0: + DoSay(SAY_ZAPPED0,LANG_UNIVERSAL,NULL); + break; + case 1: + DoSay(SAY_ZAPPED1,LANG_UNIVERSAL,NULL); + break; + case 2: + DoSay(SAY_ZAPPED2,LANG_UNIVERSAL,NULL); + break; + case 3: + DoSay(SAY_ZAPPED3,LANG_UNIVERSAL,NULL); + break; + } + } + + void Aggro(Unit* who) + { + } +}; +CreatureAI* GetAI_mob_freed_soul(Creature *_Creature) +{ + return new mob_freed_soulAI (_Creature); +} +/*###### +## mob_restless_soul +######*/ + +struct MANGOS_DLL_DECL mob_restless_soulAI : public ScriptedAI +{ + mob_restless_soulAI(Creature *c) : ScriptedAI(c) {Reset();} + + Unit* PlayerHolder; + uint32 Die_Timer; + bool OkToDie; + + void Reset() + { + Die_Timer = 10000; + OkToDie = false; + + PlayerHolder = NULL; + } + + void Aggro(Unit* who) + { + } + + void SummonFreedSoul(Unit* victim) + { + int Rand; + int RandX; + int RandY; + + Rand = rand()%1; + switch (rand()%2) + { + case 0: RandX = 0 - Rand; break; + case 1: RandX = 0 + Rand; break; + } + Rand = 0; + Rand = rand()%1; + switch (rand()%2) + { + case 0: RandY = 0 - Rand; break; + case 1: RandY = 0 + Rand; break; + } + Rand = 0; + DoSpawnCreature(11136, RandX, RandY, 0, 0, TEMPSUMMON_TIMED_DESPAWN, 300000); + } + + void SpellHit(Unit *caster, const SpellEntry *spell) + { + if (caster->GetTypeId() == TYPEID_PLAYER) + { + if(!PlayerHolder && !OkToDie && spell->Id == 17368 && ((Player*)caster)->GetQuestStatus(5282) == QUEST_STATUS_INCOMPLETE) + { + PlayerHolder = caster; + OkToDie = true; + Die_Timer = 5000; + } + } + return; + } + + void JustDied(Unit* Killer) + { + if (Killer->GetTypeId() == TYPEID_PLAYER) + { + //check quest status + if(PlayerHolder == ((Player*)Killer) && ((Player*)Killer)->GetQuestStatus(5282) == QUEST_STATUS_INCOMPLETE) + { + SummonFreedSoul(m_creature->getVictim()); + } + } + } + + void UpdateAI(const uint32 diff) + { + if (PlayerHolder && OkToDie && Die_Timer < diff) + { + PlayerHolder->DealDamage(m_creature, m_creature->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); + } + else Die_Timer -= diff; + + return; + } +}; +CreatureAI* GetAI_mob_restless_soul(Creature *_Creature) +{ + return new mob_restless_soulAI (_Creature); +} + +/*###### +## mobs_spectral_ghostly_citizen +######*/ + +struct MANGOS_DLL_DECL mobs_spectral_ghostly_citizenAI : public ScriptedAI +{ + mobs_spectral_ghostly_citizenAI(Creature *c) : ScriptedAI(c) {Reset();} + + Unit* PlayerHolder; + uint32 Die_Timer; + bool OkToDie; + + void Reset() + { + Die_Timer = 5000; + OkToDie = false; + PlayerHolder = NULL; + } + + void Aggro(Unit* who) + { + } + + void SummonRestlessSoul(Unit* victim) + { + int Rand; + int RandX; + int RandY; + + Rand = rand()%7; + switch (rand()%2) + { + case 0: RandX = 0 - Rand; break; + case 1: RandX = 0 + Rand; break; + } + Rand = 0; + Rand = rand()%7; + switch (rand()%2) + { + case 0: RandY = 0 - Rand; break; + case 1: RandY = 0 + Rand; break; + } + Rand = 0; + DoSpawnCreature(11122, RandX, RandY, 0, 0, TEMPSUMMON_CORPSE_DESPAWN, 600000); + } + + void SpellHit(Unit *caster, const SpellEntry *spell) + { + if (caster->GetTypeId() == TYPEID_PLAYER) + { + if(!PlayerHolder && !OkToDie && spell->Id == 17368 && ((Player*)caster)->GetQuestStatus(5282) == QUEST_STATUS_INCOMPLETE) + { + PlayerHolder = caster; + OkToDie = true; + Die_Timer = 5000; + } + } + return; + } + + void JustDied(Unit* Killer) + { + if (Killer->GetTypeId() == TYPEID_PLAYER) + { + //check quest status + if(PlayerHolder == ((Player*)Killer) && ((Player*)Killer)->GetQuestStatus(5282) == QUEST_STATUS_INCOMPLETE) + { + SummonRestlessSoul(m_creature->getVictim()); //always one + if (rand()%100 < 90) SummonRestlessSoul(m_creature->getVictim()); //90% a second + if (rand()%100 < 50) SummonRestlessSoul(m_creature->getVictim()); //50% a third + if (rand()%100 < 30) SummonRestlessSoul(m_creature->getVictim()); //30% a fourth + } + } + } + + void UpdateAI(const uint32 diff) + { + if (PlayerHolder && OkToDie && Die_Timer < diff) + { + PlayerHolder->DealDamage(m_creature, m_creature->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); + } + else Die_Timer -= diff; + + //Return since we have no target + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + DoMeleeAttackIfReady(); + } +}; +CreatureAI* GetAI_mobs_spectral_ghostly_citizen(Creature *_Creature) +{ + return new mobs_spectral_ghostly_citizenAI (_Creature); +} +bool ReciveEmote_mobs_spectral_ghostly_citizen(Player *player, Creature *_Creature, uint32 emote) +{ + _Creature->HandleEmoteCommand(emote); + + if (emote == TEXTEMOTE_DANCE) + ((mobs_spectral_ghostly_citizenAI*)_Creature->AI())->EnterEvadeMode(); + + return true; +} + +/*###### +## mob_mindless_skeleton +######*/ + +CreatureAI* GetAI_mob_mindless_skeleton(Creature *_Creature) +{ + SimpleAI* ai = new SimpleAI (_Creature); + + //dazed + ai->Spell[0].Enabled = true; + ai->Spell[0].Spell_Id = 13496; + ai->Spell[0].Cooldown = 15000; + ai->Spell[0].First_Cast = 3000; + ai->Spell[0].Cast_Target_Type = CAST_HOSTILE_TARGET; + + ai->EnterEvadeMode(); + + return ai; +} + +/*###### +## mob_thuzadin_acolyte +######*/ + +CreatureAI* GetAI_mob_thuzadin_acolyte(Creature *_Creature) +{ + SimpleAI* ai = new SimpleAI (_Creature); + + //dazed + ai->Spell[0].Enabled = true; + ai->Spell[0].Spell_Id = 13496; + ai->Spell[0].Cooldown = 15000; + ai->Spell[0].First_Cast = 1000; + ai->Spell[0].Cast_Target_Type = CAST_HOSTILE_TARGET; + + ai->EnterEvadeMode(); + + return ai; +} + +/*###### +## +######*/ + +void AddSC_stratholme() +{ + Script *newscript; + + newscript = new Script; + newscript->Name="mob_freed_soul"; + newscript->GetAI = GetAI_mob_freed_soul; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="mob_restless_soul"; + newscript->GetAI = GetAI_mob_restless_soul; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="mobs_spectral_ghostly_citizen"; + newscript->GetAI = GetAI_mobs_spectral_ghostly_citizen; + newscript->pReceiveEmote = &ReciveEmote_mobs_spectral_ghostly_citizen; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="mob_mindless_skeleton"; + newscript->GetAI = GetAI_mob_mindless_skeleton; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="mob_thuzadin_acolyte"; + newscript->GetAI = GetAI_mob_thuzadin_acolyte; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/sunwell_plateau/boss_brutallus.cpp b/src/bindings/scripts/scripts/zone/sunwell_plateau/boss_brutallus.cpp index 36a8238cf45..fdd57ce1ac7 100644 --- a/src/bindings/scripts/scripts/zone/sunwell_plateau/boss_brutallus.cpp +++ b/src/bindings/scripts/scripts/zone/sunwell_plateau/boss_brutallus.cpp @@ -1,188 +1,188 @@ -/* Copyright © 2006,2007 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Brutallus -SD%Complete: 80 -SDComment: Needs intro. Talk to the dragon. -EndScriptData */ - -#include "precompiled.h" -#include "def_sunwell_plateau.h" - -// Yells and Sounds used by boss. -#define YELL_AGGRO "Ahh! More lambs to the slaughter!" -#define SOUND_AGGRO 12463 - -#define YELL_BERSERK "So much for a real challenge... Die!" -#define SOUND_BERSERK 12470 - -#define YELL_KILL1 "Perish, insect!" -#define SOUND_KILL1 12464 - -#define YELL_KILL2 "You are meat!" -#define SOUND_KILL2 12465 - -#define YELL_KILL3 "Too easy!" -#define SOUND_KILL3 12466 - -#define YELL_CHARGE "I will crush you!" //I think it use this for stomp. No? -#define SOUND_CHARGE 12460 - -#define YELL_DEATH "Gah! Well done... Now... this gets... interesting..." -#define SOUND_DEATH 12471 - -#define YELL_LOVE1 "Bring the fight to me!" -#define SOUND_LOVE1 12467 - -#define YELL_LOVE2 "Another day, another glorious battle!" -#define SOUND_LOVE2 12468 - -#define YELL_LOVE3 "I live for this!" -#define SOUND_LOVE3 12469 - -// Boss spells. -#define METEOR_SLASH 45150 -#define BURN 46394 -#define STOMP 45185 -#define BERSERK 26662 - -struct MANGOS_DLL_DECL boss_brutallusAI : public ScriptedAI -{ - boss_brutallusAI(Creature *c) : ScriptedAI(c) { Reset(); } - - uint32 SlashTimer; - uint32 BurnTimer; - uint32 StompTimer; - uint32 BerserkTimer; - uint32 LoveTimer; - - void Reset() - { - SlashTimer = 11000; - StompTimer = 30000; - BurnTimer = 60000; - BerserkTimer = 360000; - LoveTimer = 10000 + rand()%7000; - } - - void Aggro(Unit *who) - { - DoYell(YELL_AGGRO, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_AGGRO); - } - - void KilledUnit(Unit* victim) - { - switch(rand()%3) - { - case 0: - DoYell(YELL_KILL1,LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_KILL1); - break; - case 1: - DoYell(YELL_KILL2,LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_KILL2); - break; - case 2: - DoYell(YELL_KILL3,LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_KILL3); - break; - } - } - - void JustDied(Unit* Killer) - { - DoYell(YELL_DEATH,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature, SOUND_DEATH); - } - - void UpdateAI(const uint32 diff) - { - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - if(LoveTimer < diff) - { - switch(rand()%3) - { - case 0: - DoYell(YELL_LOVE1,LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_LOVE1); - break; - case 1: - DoYell(YELL_LOVE2,LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_LOVE2); - break; - case 2: - DoYell(YELL_LOVE3,LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_LOVE3); - break; - } - LoveTimer = 15000 + rand()%8000; - }else LoveTimer -= diff; - - if(SlashTimer < diff) - { - DoCast(m_creature->getVictim(),METEOR_SLASH); - SlashTimer = 11000; - }else SlashTimer -= diff; - - if(StompTimer < diff) - { - DoYell(YELL_CHARGE,LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_CHARGE); - Unit *Target = m_creature->getVictim(); - DoCast(Target,STOMP); - if(Target->HasAura(45151,0)) Target->RemoveAura(45151,0); - StompTimer = 30000; - }else StompTimer -= diff; - - if(BurnTimer < diff) - { - Unit *target = SelectUnit(SELECT_TARGET_RANDOM, 0); - DoCast(target,BURN); - BurnTimer = 60000; - } - else BurnTimer -= diff; - - DoMeleeAttackIfReady(); - - if(BerserkTimer < diff) - { - DoYell(YELL_BERSERK,LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_BERSERK); - DoCast(m_creature,BERSERK); - BerserkTimer = 20000; - } - else BerserkTimer -= diff; - } - -}; - -CreatureAI* GetAI_boss_brutallus(Creature *_Creature) -{ - return new boss_brutallusAI (_Creature); -} - -void AddSC_boss_brutallus() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_brutallus"; - newscript->GetAI = GetAI_boss_brutallus; - m_scripts[nrscripts++] = newscript; -} +/* Copyright © 2006,2007 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Brutallus +SD%Complete: 80 +SDComment: Needs intro. Talk to the dragon. +EndScriptData */ + +#include "precompiled.h" +#include "def_sunwell_plateau.h" + +// Yells and Sounds used by boss. +#define YELL_AGGRO "Ahh! More lambs to the slaughter!" +#define SOUND_AGGRO 12463 + +#define YELL_BERSERK "So much for a real challenge... Die!" +#define SOUND_BERSERK 12470 + +#define YELL_KILL1 "Perish, insect!" +#define SOUND_KILL1 12464 + +#define YELL_KILL2 "You are meat!" +#define SOUND_KILL2 12465 + +#define YELL_KILL3 "Too easy!" +#define SOUND_KILL3 12466 + +#define YELL_CHARGE "I will crush you!" //I think it use this for stomp. No? +#define SOUND_CHARGE 12460 + +#define YELL_DEATH "Gah! Well done... Now... this gets... interesting..." +#define SOUND_DEATH 12471 + +#define YELL_LOVE1 "Bring the fight to me!" +#define SOUND_LOVE1 12467 + +#define YELL_LOVE2 "Another day, another glorious battle!" +#define SOUND_LOVE2 12468 + +#define YELL_LOVE3 "I live for this!" +#define SOUND_LOVE3 12469 + +// Boss spells. +#define METEOR_SLASH 45150 +#define BURN 46394 +#define STOMP 45185 +#define BERSERK 26662 + +struct MANGOS_DLL_DECL boss_brutallusAI : public ScriptedAI +{ + boss_brutallusAI(Creature *c) : ScriptedAI(c) { Reset(); } + + uint32 SlashTimer; + uint32 BurnTimer; + uint32 StompTimer; + uint32 BerserkTimer; + uint32 LoveTimer; + + void Reset() + { + SlashTimer = 11000; + StompTimer = 30000; + BurnTimer = 60000; + BerserkTimer = 360000; + LoveTimer = 10000 + rand()%7000; + } + + void Aggro(Unit *who) + { + DoYell(YELL_AGGRO, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_AGGRO); + } + + void KilledUnit(Unit* victim) + { + switch(rand()%3) + { + case 0: + DoYell(YELL_KILL1,LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_KILL1); + break; + case 1: + DoYell(YELL_KILL2,LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_KILL2); + break; + case 2: + DoYell(YELL_KILL3,LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_KILL3); + break; + } + } + + void JustDied(Unit* Killer) + { + DoYell(YELL_DEATH,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature, SOUND_DEATH); + } + + void UpdateAI(const uint32 diff) + { + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + if(LoveTimer < diff) + { + switch(rand()%3) + { + case 0: + DoYell(YELL_LOVE1,LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_LOVE1); + break; + case 1: + DoYell(YELL_LOVE2,LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_LOVE2); + break; + case 2: + DoYell(YELL_LOVE3,LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_LOVE3); + break; + } + LoveTimer = 15000 + rand()%8000; + }else LoveTimer -= diff; + + if(SlashTimer < diff) + { + DoCast(m_creature->getVictim(),METEOR_SLASH); + SlashTimer = 11000; + }else SlashTimer -= diff; + + if(StompTimer < diff) + { + DoYell(YELL_CHARGE,LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_CHARGE); + Unit *Target = m_creature->getVictim(); + DoCast(Target,STOMP); + if(Target->HasAura(45151,0)) Target->RemoveAura(45151,0); + StompTimer = 30000; + }else StompTimer -= diff; + + if(BurnTimer < diff) + { + Unit *target = SelectUnit(SELECT_TARGET_RANDOM, 0); + DoCast(target,BURN); + BurnTimer = 60000; + } + else BurnTimer -= diff; + + DoMeleeAttackIfReady(); + + if(BerserkTimer < diff) + { + DoYell(YELL_BERSERK,LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_BERSERK); + DoCast(m_creature,BERSERK); + BerserkTimer = 20000; + } + else BerserkTimer -= diff; + } + +}; + +CreatureAI* GetAI_boss_brutallus(Creature *_Creature) +{ + return new boss_brutallusAI (_Creature); +} + +void AddSC_boss_brutallus() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_brutallus"; + newscript->GetAI = GetAI_boss_brutallus; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/sunwell_plateau/boss_kalecgos.cpp b/src/bindings/scripts/scripts/zone/sunwell_plateau/boss_kalecgos.cpp index 6b35c91ac58..15fc4efd936 100644 --- a/src/bindings/scripts/scripts/zone/sunwell_plateau/boss_kalecgos.cpp +++ b/src/bindings/scripts/scripts/zone/sunwell_plateau/boss_kalecgos.cpp @@ -1,657 +1,657 @@ -/* Copyright ? 2006,2007 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Kalecgos -SD%Complete: 0 -SDComment: VERIFY SCRIPT -SDCategory: Sunwell Plateau -EndScriptData */ - -#include "precompiled.h" -#include "WorldPacket.h" -#include "def_sunwell_plateau.h" - -#define SAY_KALECGOS_AGGRO "Aggh! No longer will I be a slave to Malygos! Challenge me and you will be destroyed!" -#define SOUND_KALECGOS_AGGRO 12422 -#define SAY_KALECGOS_SPELL1 "I will purge you!" -#define SOUND_KALECGOS_SPELL1 12423 -#define SAY_KALECGOS_SPELL2 "Your pain has only begun!" -#define SOUND_KALECGOS_SPELL2 12424 -#define SAY_KALECGOS_SLAY1 "In the name of Kil'jaeden!" -#define SOUND_KALECGOS_SLAY1 12425 -#define SAY_KALECGOS_SLAY2 "You were warned!" -#define SOUND_KALECGOS_SLAY2 12426 -#define SAY_KALECGOS_ENRAGE "My awakening is complete! You shall all perish!" -#define SOUND_KALECGOS_ENRAGE 12427 - -#define SAY_SATH_AGGRO "There will be no reprieve. My work here is nearly finished." -#define SOUND_SATH_AGGRO 12451 -#define SAY_SATH_DEATH "I'm... never on... the losing... side..." -#define SOUND_SATH_DEATH 12452 -#define SAY_SATH_SPELL1 "Your misery is my delight!" -#define SOUND_SATH_SPELL1 12453 -#define SAY_SATH_SPELL2 "I will watch you bleed!" -#define SOUND_SATH_SPELL2 12454 -#define SAY_SATH_SLAY1 "Pitious mortal!" -#define SOUND_SATH_SLAY1 12455 -#define SAY_SATH_SLAY2 "Haven't you heard? I always win!" -#define SOUND_SATH_SLAY2 12456 -#define SAY_SATH_ENRAGE "I have toyed with you long enough!" -#define SOUND_SATH_ENRAGE 12457 - -#define SAY_KALEC_AGGRO "I need... your help... Cannot... resist him... much longer..." -#define SOUND_KALEC_AGGRO 12428 -#define SAY_KALEC_NEAR_DEATH "Aaahhh! Help me, before I lose my mind!" -#define SOUND_KALEC_NEAR_DEATH 12429 - //??? -#define SAY_KALEC_NEAR_DEATH2 "Hurry! There is not much of me left!" -#define SOUND_KALEC_NEAR_DEATH2 12430 -#define SAY_KALEC_PLRWIN "I am forever in your debt. Once we have triumphed over Kil'jaeden, this entire world will be in your debt as well." -#define SOUND_KALEC_PLRWIN 12431 - -#define SPELL_SPECTRAL_EXHAUSTION 44867 -#define SPELL_TELEPORT_SPECTRAL_REALM 46019 -#define SPELL_SPECTRAL_REALM 46021 - -#define NOTIFY_SPECTRALLY_EXHAUSTED "Your body is too exhausted to travel to the Spectral Realm." -#define ERROR_INST_DATA "SD2: Instance Data not set properly for Sunwell Plateau. Kalecgos Encounter will be buggy." -#define ERROR_INST_DATA_PLR "SD2 ERROR: Instance Data not set properly for Sunwell Plateau. Please report this to your administrator." -#define ERROR_UNABLE_TO_TELEPORT "SD2: Unable to select target for Spectral Blast. Threatlist has too few players." -#define ERROR_MISSING_TELEPORT_GUID "SD2: [Kalecgos] Invalid TeleportTargetGUID. Unable to teleport player." -#define ERROR_KALECGOS_NOT_FOUND "SD2: Unable to create pointer to Kalecgos from Sathrovarr." - -#define KALECGOS_ARENA_X 1704.34 -#define KALECGOS_ARENA_Y 928.17 -#define KALECGOS_ARENA_Z 53.08 - -/*** Kalecgos ****/ -#define SPELL_SPECTRAL_BLAST 44866 -#define SPELL_ARCANE_BUFFET 45018 -#define SPELL_FROST_BREATH 44799 -#define SPELL_HEROIC_STRIKE 45026 -#define SPELL_REVITALIZE 45027 -#define SPELL_TAIL_LASH 45122 -#define SPELL_TRANSFORM_KALEC 45027 -#define SPELL_CRAZED_RAGE 44806 -uint32 WildMagic[]= { 44978, 45001, 45002, 45004, 45006, 45010 }; - -/*** Sathrovarr ***/ -#define SPELL_CORRUPTING_STRIKE 45029 -#define SPELL_CURSE_OF_BOUNDLESS_AGONY 45032 -#define SPELL_SHADOW_BOLT_VOLLEY 45031 - -/*** Misc ***/ -#define SPELL_BANISH 44836 - -void TeleportToInnerVeil(Player* plr) -{ - if(plr->HasAura(SPELL_SPECTRAL_EXHAUSTION, 0)) - { - plr->GetSession()->SendNotification(NOTIFY_SPECTRALLY_EXHAUSTED); - return; - } - - ScriptedInstance* pInstance = ((ScriptedInstance*)plr->GetInstanceData()); - if(!pInstance) - { - error_log(ERROR_INST_DATA); - plr->GetSession()->SendNotification(ERROR_INST_DATA_PLR); - return; - } - - pInstance->SetData64(DATA_PLAYER_SPECTRAL_REALM, plr->GetGUID()); - // Remove the player from Kalecgos' Threat List - Creature* Kalecgos = ((Creature*)Unit::GetUnit(*plr, pInstance->GetData64(DATA_KALECGOS_DRAGON))); - if(Kalecgos) - { - HostilReference* ref = Kalecgos->getThreatManager().getOnlineContainer().getReferenceByTarget(plr); - if(ref) - ref->removeReference(); - } - - // Add the player to Sathrovarr's Threat List - Creature* Sathrovarr = ((Creature*)Unit::GetUnit(*plr, pInstance->GetData64(DATA_SATHROVARR))); - if(Sathrovarr) - Sathrovarr->AddThreat(plr, 1.0f); - - // Make them able to see Sathrovarr (he's invisible for some reason). Also, when this buff wears off, they get teleported back to Normal Realm (this is handled by Instance Script) - plr->CastSpell(plr, SPELL_SPECTRAL_REALM, true); - plr->CastSpell(plr, SPELL_TELEPORT_SPECTRAL_REALM, true); -} - -bool GOHello_GO_Spectral_Portal(Player* plr, GameObject* go) -{ - TeleportToInnerVeil(plr); - - return true; -} - -struct MANGOS_DLL_DECL boss_kalecgosAI : public ScriptedAI -{ - boss_kalecgosAI(Creature* c) : ScriptedAI(c) - { - pInstance = ((ScriptedInstance*)c->GetInstanceData()); - Reset(); - } - - ScriptedInstance* pInstance; - - uint64 TeleportTargetGUID; - - uint32 ArcaneBuffetTimer; - uint32 FrostBreathTimer; - uint32 WildMagicTimer; - uint32 SpectralBlastTimer; - uint32 SpectralTeleportTimer; - uint32 ForceFieldTimer; - uint32 ExitTimer; - - bool LockedArena; - bool Uncorrupted; - bool Banished; - bool Checked; - bool Enraged; - - void Reset() - { - TeleportTargetGUID = 0; - - // TODO: Fix timers - ArcaneBuffetTimer = 8000; - FrostBreathTimer = 24000; - WildMagicTimer = 18000; - SpectralBlastTimer = 30000; - SpectralTeleportTimer = SpectralBlastTimer + 2000; - - ForceFieldTimer = 20000; - ExitTimer = 0; - - LockedArena = false; - Uncorrupted = false; - Banished = false; - Checked = false; - Enraged = false; - - // Reset Sathrovarr too - if(pInstance) - if(Creature* Sath = ((Creature*)Unit::GetUnit(*m_creature, pInstance->GetData64(DATA_SATHROVARR)))) - Sath->AI()->EnterEvadeMode(); - } - - void Aggro(Unit* who) - { - DoYell(SAY_KALECGOS_AGGRO, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_KALECGOS_AGGRO); - - if(pInstance) - pInstance->SetData(DATA_KALECGOS_EVENT, IN_PROGRESS); - } - - void DamageTaken(Unit* done_by, uint32 &damage) - { - if(damage > m_creature->GetHealth() && done_by != m_creature) - { - if(!Uncorrupted) - { - damage = 0; - Banished = true; - DoCast(m_creature, SPELL_BANISH, true); - m_creature->GetMotionMaster()->MoveIdle(); - } - else - { - damage = 0; - BeginOutro(); - } - } - } - - void KilledUnit(Unit* victim) - { - switch(rand()%2) - { - case 0: - DoYell(SAY_KALECGOS_SLAY1,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_KALECGOS_SLAY1); - break; - case 1: - DoYell(SAY_KALECGOS_SLAY2,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_KALECGOS_SLAY2); - break; - } - } - - void BeginOutro() - { - debug_log("SD2: KALEC: Beginning Outro"); - - if(!pInstance) - { - error_log(ERROR_INST_DATA); - return; - } - - Unit* Sathrovarr = Unit::GetUnit(*m_creature, pInstance->GetData64(DATA_SATHROVARR)); - if(Sathrovarr) - { - Sathrovarr->DealDamage(Sathrovarr, Sathrovarr->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); - - Sathrovarr->Relocate(KALECGOS_ARENA_X, KALECGOS_ARENA_Y, KALECGOS_ARENA_Z); - Sathrovarr->SendMonsterMove(KALECGOS_ARENA_X, KALECGOS_ARENA_Y, KALECGOS_ARENA_Z, 0, 0, 0); - } - - Creature* Kalec = ((Creature*)Unit::GetUnit(*m_creature, pInstance->GetData64(DATA_KALECGOS_HUMAN))); - if(Kalec) - { - Kalec->DeleteThreatList(); - Kalec->SetVisibility(VISIBILITY_OFF); - } - - m_creature->GetMotionMaster()->MoveIdle(); - m_creature->setFaction(35); - } - - void MovementInform(uint32 type, uint32 id) - { - if(type != POINT_MOTION_TYPE) - return; - - if(id) - { - if(pInstance) - { - GameObject* ForceField = GameObject::GetGameObject(*m_creature, pInstance->GetData64(DATA_GO_FORCEFIELD)); - if(ForceField) - ForceField->SetGoState(1); - - pInstance->SetData(DATA_KALECGOS_EVENT, DONE); - } - else error_log(ERROR_INST_DATA); - - m_creature->SetVisibility(VISIBILITY_OFF); - m_creature->DealDamage(m_creature, m_creature->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); - } - } - - void UpdateAI(const uint32 diff) - { - if(!m_creature->getVictim() || !m_creature->SelectHostilTarget() || Banished) - return; - - if(((m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < 10) && !Enraged) - { - Unit* Sathrovarr = Unit::GetUnit(*m_creature, pInstance->GetData64(DATA_SATHROVARR)); - if(Sathrovarr) - Sathrovarr->CastSpell(Sathrovarr, SPELL_CRAZED_RAGE, true); - DoCast(m_creature, SPELL_CRAZED_RAGE, true); - Enraged = true; - } - - if(((m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < 1) && !Checked) - { - Checked = true; - - if(!Uncorrupted) - { - Banished = true; - DoCast(m_creature, SPELL_BANISH, true); - m_creature->GetMotionMaster()->MoveIdle(); - } - else - BeginOutro(); - } - - if(ExitTimer) - if(ExitTimer <= diff) - { - debug_log("SD2: KALEC: Exiting the arena"); - DoYell(SAY_KALEC_PLRWIN, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_KALEC_PLRWIN); - m_creature->AddUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT + MOVEMENTFLAG_LEVITATING); - float x, y, z; - float iniX, iniY, iniZ; - m_creature->GetPosition(iniX, iniY, iniZ); - m_creature->GetRandomPoint(iniX, iniY, iniZ, 30, x, y, z); - z = 70; - m_creature->GetMotionMaster()->MovePoint(1, x, y, z); - }else ExitTimer -= diff; - - if(!LockedArena) - if(ForceFieldTimer < diff) - { - if(pInstance) - { - GameObject* ForceField = GameObject::GetGameObject((*m_creature), pInstance->GetData64(DATA_GO_FORCEFIELD)); - if(ForceField) - ForceField->SetUInt32Value(GAMEOBJECT_STATE, 0); - - LockedArena = true; - }else error_log(ERROR_INST_DATA); - }else ForceFieldTimer -= diff; - - if(ArcaneBuffetTimer < diff) - { - if(rand()%3 == 0) - { - DoYell(SAY_KALECGOS_SPELL1, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_KALECGOS_SPELL1); - } - DoCast(m_creature->getVictim(), SPELL_ARCANE_BUFFET); - ArcaneBuffetTimer = 20000; - }else ArcaneBuffetTimer -= diff; - - if(FrostBreathTimer < diff) - { - if(rand()%2 == 0) - { - DoYell(SAY_KALECGOS_SPELL2, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_KALECGOS_SPELL2); - } - DoCast(m_creature->getVictim(), SPELL_FROST_BREATH); - FrostBreathTimer = 25000; - }else FrostBreathTimer -= diff; - - if(WildMagicTimer < diff) - { - DoCast(m_creature->getVictim(), WildMagic[rand()%6]); - WildMagicTimer = 19000; - }else WildMagicTimer -= diff; - - if(SpectralBlastTimer < diff) - { - if(Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 1)) - { - TeleportTargetGUID = target->GetGUID(); - m_creature->SetUInt64Value(UNIT_FIELD_TARGET, TeleportTargetGUID); - SpectralBlastTimer = 30000; - SpectralTeleportTimer = 2000; - } - }else SpectralBlastTimer -= diff; - - if(SpectralTeleportTimer < diff) - { - if(TeleportTargetGUID) - { - Unit* pUnit = Unit::GetUnit((*m_creature), TeleportTargetGUID); - if(pUnit) - { - pUnit->CastSpell(pUnit, SPELL_SPECTRAL_BLAST, true); - TeleportToInnerVeil((Player*)pUnit); - } - else error_log(ERROR_MISSING_TELEPORT_GUID); - } - else error_log(ERROR_MISSING_TELEPORT_GUID); - - m_creature->SetUInt64Value(UNIT_FIELD_TARGET, m_creature->getVictim()->GetGUID()); - TeleportTargetGUID = 0; - SpectralTeleportTimer = SpectralBlastTimer + 2000; - - }else SpectralTeleportTimer -= diff; - - if(!Banished) DoMeleeAttackIfReady(); - } -}; - -struct MANGOS_DLL_DECL boss_sathrovarrAI : public ScriptedAI -{ - boss_sathrovarrAI(Creature* c) : ScriptedAI(c) - { - pInstance = ((ScriptedInstance*)c->GetInstanceData()); - Reset(); - } - - ScriptedInstance* pInstance; - - uint32 CorruptingStrikeTimer; - uint32 CurseOfBoundlessAgonyTimer; - uint32 ShadowBoltVolleyTimer; - bool Banished; - bool Enraged; - - void Reset() - { - // FIXME: Timers - CorruptingStrikeTimer = 5000; - CurseOfBoundlessAgonyTimer = 15000; - ShadowBoltVolleyTimer = 10000; - - Banished = false; - Enraged = false; - - DoCast(m_creature, SPELL_SPECTRAL_REALM, true); - } - - void Aggro(Unit* who) - { - DoYell(SAY_SATH_AGGRO, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_SATH_AGGRO); - - Creature* Kalec = ((Creature*)Unit::GetUnit(*m_creature, pInstance->GetData64(DATA_KALECGOS_HUMAN))); - if(Kalec) - { - m_creature->AddThreat(Kalec, 10000000.0f); - Kalec->AddThreat(m_creature, 10000000.0f); - } - } - - void DamageTaken(Unit* done_by, uint32 &damage) - { - if(damage > m_creature->GetHealth()) - { - damage = 0; - DoCast(m_creature, SPELL_BANISH, true); - Banished = true; - - DoYell(SAY_SATH_DEATH, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_SATH_DEATH); - - if(!pInstance) - { - error_log(ERROR_INST_DATA); - return; - } - - pInstance->SetData(DATA_SET_SPECTRAL_CHECK, 5000); - - Creature* Kalecgos = ((Creature*)Unit::GetUnit((*m_creature), pInstance->GetData64(DATA_KALECGOS_DRAGON))); - if(Kalecgos) - { - ((boss_kalecgosAI*)Kalecgos->AI())->Checked = false; - ((boss_kalecgosAI*)Kalecgos->AI())->Uncorrupted = true; - } - else error_log(ERROR_KALECGOS_NOT_FOUND); - } - } - - void KilledUnit(Unit* victim) - { - switch(rand()%2) - { - case 0: - DoYell(SAY_SATH_SLAY1,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_SATH_SLAY1); - break; - case 1: - DoYell(SAY_SATH_SLAY2,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_SATH_SLAY2); - break; - } - } - - void UpdateAI(const uint32 diff) - { - if(!m_creature->getVictim() || !m_creature->SelectHostilTarget() || Banished) - return; - - if(((m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < 10) && !Enraged) - { - Unit* Kalecgos = Unit::GetUnit(*m_creature, pInstance->GetData64(DATA_KALECGOS_DRAGON)); - if(Kalecgos) - Kalecgos->CastSpell(Kalecgos, SPELL_CRAZED_RAGE, true); - DoCast(m_creature, SPELL_CRAZED_RAGE, true); - Enraged = true; - } - - if(CorruptingStrikeTimer < diff) - { - if(rand()%2 == 0) - { - DoYell(SAY_SATH_SPELL2, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_SATH_SPELL2); - } - DoCast(m_creature->getVictim(), SPELL_CORRUPTING_STRIKE); - CorruptingStrikeTimer = 13000; - }else CorruptingStrikeTimer -= diff; - - if(CurseOfBoundlessAgonyTimer < diff) - { - DoCast(SelectUnit(SELECT_TARGET_RANDOM, 0), SPELL_CURSE_OF_BOUNDLESS_AGONY); - CurseOfBoundlessAgonyTimer = 35000; - DoCast(m_creature, SPELL_SPECTRAL_REALM, true); - }else CurseOfBoundlessAgonyTimer -= diff; - - if(ShadowBoltVolleyTimer < diff) - { - if(rand()%2 == 0) - { - DoYell(SAY_SATH_SPELL1, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_SATH_SPELL1); - } - DoCast(m_creature->getVictim(), SPELL_SHADOW_BOLT_VOLLEY); - ShadowBoltVolleyTimer = 15000; - }else ShadowBoltVolleyTimer -= diff; - - DoMeleeAttackIfReady(); - } -}; - -struct MANGOS_DLL_DECL boss_kalecAI : public ScriptedAI -{ - boss_kalecAI(Creature* c) : ScriptedAI(c) - { - pInstance = ((ScriptedInstance*)c->GetInstanceData()); - Reset(); - } - - ScriptedInstance *pInstance; - - uint32 RevitalizeTimer; - uint32 HeroicStrikeTimer; - - bool HasYelled10Percent; - bool HasYelled20Percent; - - void Reset() - { - //TODO: Times! - RevitalizeTimer = 30000; - HeroicStrikeTimer = 8000; - - HasYelled10Percent = false; - HasYelled20Percent = false; - - DoCast(m_creature, SPELL_SPECTRAL_REALM, true); - } - - void Aggro(Unit* who) - { - DoYell(SAY_KALEC_AGGRO, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_KALEC_AGGRO); - } - - void JustDied(Unit* killer) - { - // Whatever happens when Kalec (Half-elf) dies - } - - void UpdateAI(const uint32 diff) - { - if(!m_creature->getVictim() || !m_creature->SelectHostilTarget()) - return; - - if(RevitalizeTimer < diff) - { - if(pInstance) - { - Unit* pUnit = Unit::GetUnit(*m_creature, pInstance->GetData64(DATA_RANDOM_SPECTRAL_PLAYER)); - if(pUnit) - DoCast(pUnit, SPELL_REVITALIZE); - RevitalizeTimer = 30000; - } - }else RevitalizeTimer -= diff; - - if(HeroicStrikeTimer < diff) - { - DoCast(m_creature->getVictim(), SPELL_HEROIC_STRIKE); - HeroicStrikeTimer = 30000; - }else HeroicStrikeTimer -= diff; - - if(((m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < 20) && !HasYelled20Percent) - { - DoYell(SAY_KALEC_NEAR_DEATH, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_KALEC_NEAR_DEATH); - HasYelled20Percent = true; - } - - if(((m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < 10) && !HasYelled10Percent) - { - DoYell(SAY_KALEC_NEAR_DEATH2, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_KALEC_NEAR_DEATH2); - HasYelled10Percent = true; - } - } -}; - -CreatureAI* GetAI_boss_kalecgos(Creature* c) -{ - return new boss_kalecgosAI(c); -} - -CreatureAI* GetAI_boss_sathrovarr(Creature* c) -{ - return new boss_sathrovarrAI(c); -} - -CreatureAI* GetAI_boss_kalec(Creature* c) -{ - return new boss_kalecAI(c); -} - -void AddSC_boss_kalecgos() -{ - Script* newscript; - - newscript = new Script; - newscript->GetAI = GetAI_boss_kalecgos; - newscript->Name = "boss_kalecgos"; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->GetAI = GetAI_boss_sathrovarr; - newscript->Name = "boss_sathrovarr"; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->GetAI = GetAI_boss_kalec; - newscript->Name = "boss_kalec"; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->pGOHello = GOHello_GO_Spectral_Portal; - newscript->Name = "go_spectral_portal"; - m_scripts[nrscripts++] = newscript; -} +/* Copyright ? 2006,2007 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Kalecgos +SD%Complete: 0 +SDComment: VERIFY SCRIPT +SDCategory: Sunwell Plateau +EndScriptData */ + +#include "precompiled.h" +#include "WorldPacket.h" +#include "def_sunwell_plateau.h" + +#define SAY_KALECGOS_AGGRO "Aggh! No longer will I be a slave to Malygos! Challenge me and you will be destroyed!" +#define SOUND_KALECGOS_AGGRO 12422 +#define SAY_KALECGOS_SPELL1 "I will purge you!" +#define SOUND_KALECGOS_SPELL1 12423 +#define SAY_KALECGOS_SPELL2 "Your pain has only begun!" +#define SOUND_KALECGOS_SPELL2 12424 +#define SAY_KALECGOS_SLAY1 "In the name of Kil'jaeden!" +#define SOUND_KALECGOS_SLAY1 12425 +#define SAY_KALECGOS_SLAY2 "You were warned!" +#define SOUND_KALECGOS_SLAY2 12426 +#define SAY_KALECGOS_ENRAGE "My awakening is complete! You shall all perish!" +#define SOUND_KALECGOS_ENRAGE 12427 + +#define SAY_SATH_AGGRO "There will be no reprieve. My work here is nearly finished." +#define SOUND_SATH_AGGRO 12451 +#define SAY_SATH_DEATH "I'm... never on... the losing... side..." +#define SOUND_SATH_DEATH 12452 +#define SAY_SATH_SPELL1 "Your misery is my delight!" +#define SOUND_SATH_SPELL1 12453 +#define SAY_SATH_SPELL2 "I will watch you bleed!" +#define SOUND_SATH_SPELL2 12454 +#define SAY_SATH_SLAY1 "Pitious mortal!" +#define SOUND_SATH_SLAY1 12455 +#define SAY_SATH_SLAY2 "Haven't you heard? I always win!" +#define SOUND_SATH_SLAY2 12456 +#define SAY_SATH_ENRAGE "I have toyed with you long enough!" +#define SOUND_SATH_ENRAGE 12457 + +#define SAY_KALEC_AGGRO "I need... your help... Cannot... resist him... much longer..." +#define SOUND_KALEC_AGGRO 12428 +#define SAY_KALEC_NEAR_DEATH "Aaahhh! Help me, before I lose my mind!" +#define SOUND_KALEC_NEAR_DEATH 12429 + //??? +#define SAY_KALEC_NEAR_DEATH2 "Hurry! There is not much of me left!" +#define SOUND_KALEC_NEAR_DEATH2 12430 +#define SAY_KALEC_PLRWIN "I am forever in your debt. Once we have triumphed over Kil'jaeden, this entire world will be in your debt as well." +#define SOUND_KALEC_PLRWIN 12431 + +#define SPELL_SPECTRAL_EXHAUSTION 44867 +#define SPELL_TELEPORT_SPECTRAL_REALM 46019 +#define SPELL_SPECTRAL_REALM 46021 + +#define NOTIFY_SPECTRALLY_EXHAUSTED "Your body is too exhausted to travel to the Spectral Realm." +#define ERROR_INST_DATA "SD2: Instance Data not set properly for Sunwell Plateau. Kalecgos Encounter will be buggy." +#define ERROR_INST_DATA_PLR "SD2 ERROR: Instance Data not set properly for Sunwell Plateau. Please report this to your administrator." +#define ERROR_UNABLE_TO_TELEPORT "SD2: Unable to select target for Spectral Blast. Threatlist has too few players." +#define ERROR_MISSING_TELEPORT_GUID "SD2: [Kalecgos] Invalid TeleportTargetGUID. Unable to teleport player." +#define ERROR_KALECGOS_NOT_FOUND "SD2: Unable to create pointer to Kalecgos from Sathrovarr." + +#define KALECGOS_ARENA_X 1704.34 +#define KALECGOS_ARENA_Y 928.17 +#define KALECGOS_ARENA_Z 53.08 + +/*** Kalecgos ****/ +#define SPELL_SPECTRAL_BLAST 44866 +#define SPELL_ARCANE_BUFFET 45018 +#define SPELL_FROST_BREATH 44799 +#define SPELL_HEROIC_STRIKE 45026 +#define SPELL_REVITALIZE 45027 +#define SPELL_TAIL_LASH 45122 +#define SPELL_TRANSFORM_KALEC 45027 +#define SPELL_CRAZED_RAGE 44806 +uint32 WildMagic[]= { 44978, 45001, 45002, 45004, 45006, 45010 }; + +/*** Sathrovarr ***/ +#define SPELL_CORRUPTING_STRIKE 45029 +#define SPELL_CURSE_OF_BOUNDLESS_AGONY 45032 +#define SPELL_SHADOW_BOLT_VOLLEY 45031 + +/*** Misc ***/ +#define SPELL_BANISH 44836 + +void TeleportToInnerVeil(Player* plr) +{ + if(plr->HasAura(SPELL_SPECTRAL_EXHAUSTION, 0)) + { + plr->GetSession()->SendNotification(NOTIFY_SPECTRALLY_EXHAUSTED); + return; + } + + ScriptedInstance* pInstance = ((ScriptedInstance*)plr->GetInstanceData()); + if(!pInstance) + { + error_log(ERROR_INST_DATA); + plr->GetSession()->SendNotification(ERROR_INST_DATA_PLR); + return; + } + + pInstance->SetData64(DATA_PLAYER_SPECTRAL_REALM, plr->GetGUID()); + // Remove the player from Kalecgos' Threat List + Creature* Kalecgos = ((Creature*)Unit::GetUnit(*plr, pInstance->GetData64(DATA_KALECGOS_DRAGON))); + if(Kalecgos) + { + HostilReference* ref = Kalecgos->getThreatManager().getOnlineContainer().getReferenceByTarget(plr); + if(ref) + ref->removeReference(); + } + + // Add the player to Sathrovarr's Threat List + Creature* Sathrovarr = ((Creature*)Unit::GetUnit(*plr, pInstance->GetData64(DATA_SATHROVARR))); + if(Sathrovarr) + Sathrovarr->AddThreat(plr, 1.0f); + + // Make them able to see Sathrovarr (he's invisible for some reason). Also, when this buff wears off, they get teleported back to Normal Realm (this is handled by Instance Script) + plr->CastSpell(plr, SPELL_SPECTRAL_REALM, true); + plr->CastSpell(plr, SPELL_TELEPORT_SPECTRAL_REALM, true); +} + +bool GOHello_GO_Spectral_Portal(Player* plr, GameObject* go) +{ + TeleportToInnerVeil(plr); + + return true; +} + +struct MANGOS_DLL_DECL boss_kalecgosAI : public ScriptedAI +{ + boss_kalecgosAI(Creature* c) : ScriptedAI(c) + { + pInstance = ((ScriptedInstance*)c->GetInstanceData()); + Reset(); + } + + ScriptedInstance* pInstance; + + uint64 TeleportTargetGUID; + + uint32 ArcaneBuffetTimer; + uint32 FrostBreathTimer; + uint32 WildMagicTimer; + uint32 SpectralBlastTimer; + uint32 SpectralTeleportTimer; + uint32 ForceFieldTimer; + uint32 ExitTimer; + + bool LockedArena; + bool Uncorrupted; + bool Banished; + bool Checked; + bool Enraged; + + void Reset() + { + TeleportTargetGUID = 0; + + // TODO: Fix timers + ArcaneBuffetTimer = 8000; + FrostBreathTimer = 24000; + WildMagicTimer = 18000; + SpectralBlastTimer = 30000; + SpectralTeleportTimer = SpectralBlastTimer + 2000; + + ForceFieldTimer = 20000; + ExitTimer = 0; + + LockedArena = false; + Uncorrupted = false; + Banished = false; + Checked = false; + Enraged = false; + + // Reset Sathrovarr too + if(pInstance) + if(Creature* Sath = ((Creature*)Unit::GetUnit(*m_creature, pInstance->GetData64(DATA_SATHROVARR)))) + Sath->AI()->EnterEvadeMode(); + } + + void Aggro(Unit* who) + { + DoYell(SAY_KALECGOS_AGGRO, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_KALECGOS_AGGRO); + + if(pInstance) + pInstance->SetData(DATA_KALECGOS_EVENT, IN_PROGRESS); + } + + void DamageTaken(Unit* done_by, uint32 &damage) + { + if(damage > m_creature->GetHealth() && done_by != m_creature) + { + if(!Uncorrupted) + { + damage = 0; + Banished = true; + DoCast(m_creature, SPELL_BANISH, true); + m_creature->GetMotionMaster()->MoveIdle(); + } + else + { + damage = 0; + BeginOutro(); + } + } + } + + void KilledUnit(Unit* victim) + { + switch(rand()%2) + { + case 0: + DoYell(SAY_KALECGOS_SLAY1,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_KALECGOS_SLAY1); + break; + case 1: + DoYell(SAY_KALECGOS_SLAY2,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_KALECGOS_SLAY2); + break; + } + } + + void BeginOutro() + { + debug_log("SD2: KALEC: Beginning Outro"); + + if(!pInstance) + { + error_log(ERROR_INST_DATA); + return; + } + + Unit* Sathrovarr = Unit::GetUnit(*m_creature, pInstance->GetData64(DATA_SATHROVARR)); + if(Sathrovarr) + { + Sathrovarr->DealDamage(Sathrovarr, Sathrovarr->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); + + Sathrovarr->Relocate(KALECGOS_ARENA_X, KALECGOS_ARENA_Y, KALECGOS_ARENA_Z); + Sathrovarr->SendMonsterMove(KALECGOS_ARENA_X, KALECGOS_ARENA_Y, KALECGOS_ARENA_Z, 0, 0, 0); + } + + Creature* Kalec = ((Creature*)Unit::GetUnit(*m_creature, pInstance->GetData64(DATA_KALECGOS_HUMAN))); + if(Kalec) + { + Kalec->DeleteThreatList(); + Kalec->SetVisibility(VISIBILITY_OFF); + } + + m_creature->GetMotionMaster()->MoveIdle(); + m_creature->setFaction(35); + } + + void MovementInform(uint32 type, uint32 id) + { + if(type != POINT_MOTION_TYPE) + return; + + if(id) + { + if(pInstance) + { + GameObject* ForceField = GameObject::GetGameObject(*m_creature, pInstance->GetData64(DATA_GO_FORCEFIELD)); + if(ForceField) + ForceField->SetGoState(1); + + pInstance->SetData(DATA_KALECGOS_EVENT, DONE); + } + else error_log(ERROR_INST_DATA); + + m_creature->SetVisibility(VISIBILITY_OFF); + m_creature->DealDamage(m_creature, m_creature->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); + } + } + + void UpdateAI(const uint32 diff) + { + if(!m_creature->getVictim() || !m_creature->SelectHostilTarget() || Banished) + return; + + if(((m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < 10) && !Enraged) + { + Unit* Sathrovarr = Unit::GetUnit(*m_creature, pInstance->GetData64(DATA_SATHROVARR)); + if(Sathrovarr) + Sathrovarr->CastSpell(Sathrovarr, SPELL_CRAZED_RAGE, true); + DoCast(m_creature, SPELL_CRAZED_RAGE, true); + Enraged = true; + } + + if(((m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < 1) && !Checked) + { + Checked = true; + + if(!Uncorrupted) + { + Banished = true; + DoCast(m_creature, SPELL_BANISH, true); + m_creature->GetMotionMaster()->MoveIdle(); + } + else + BeginOutro(); + } + + if(ExitTimer) + if(ExitTimer <= diff) + { + debug_log("SD2: KALEC: Exiting the arena"); + DoYell(SAY_KALEC_PLRWIN, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_KALEC_PLRWIN); + m_creature->AddUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT + MOVEMENTFLAG_LEVITATING); + float x, y, z; + float iniX, iniY, iniZ; + m_creature->GetPosition(iniX, iniY, iniZ); + m_creature->GetRandomPoint(iniX, iniY, iniZ, 30, x, y, z); + z = 70; + m_creature->GetMotionMaster()->MovePoint(1, x, y, z); + }else ExitTimer -= diff; + + if(!LockedArena) + if(ForceFieldTimer < diff) + { + if(pInstance) + { + GameObject* ForceField = GameObject::GetGameObject((*m_creature), pInstance->GetData64(DATA_GO_FORCEFIELD)); + if(ForceField) + ForceField->SetUInt32Value(GAMEOBJECT_STATE, 0); + + LockedArena = true; + }else error_log(ERROR_INST_DATA); + }else ForceFieldTimer -= diff; + + if(ArcaneBuffetTimer < diff) + { + if(rand()%3 == 0) + { + DoYell(SAY_KALECGOS_SPELL1, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_KALECGOS_SPELL1); + } + DoCast(m_creature->getVictim(), SPELL_ARCANE_BUFFET); + ArcaneBuffetTimer = 20000; + }else ArcaneBuffetTimer -= diff; + + if(FrostBreathTimer < diff) + { + if(rand()%2 == 0) + { + DoYell(SAY_KALECGOS_SPELL2, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_KALECGOS_SPELL2); + } + DoCast(m_creature->getVictim(), SPELL_FROST_BREATH); + FrostBreathTimer = 25000; + }else FrostBreathTimer -= diff; + + if(WildMagicTimer < diff) + { + DoCast(m_creature->getVictim(), WildMagic[rand()%6]); + WildMagicTimer = 19000; + }else WildMagicTimer -= diff; + + if(SpectralBlastTimer < diff) + { + if(Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 1)) + { + TeleportTargetGUID = target->GetGUID(); + m_creature->SetUInt64Value(UNIT_FIELD_TARGET, TeleportTargetGUID); + SpectralBlastTimer = 30000; + SpectralTeleportTimer = 2000; + } + }else SpectralBlastTimer -= diff; + + if(SpectralTeleportTimer < diff) + { + if(TeleportTargetGUID) + { + Unit* pUnit = Unit::GetUnit((*m_creature), TeleportTargetGUID); + if(pUnit) + { + pUnit->CastSpell(pUnit, SPELL_SPECTRAL_BLAST, true); + TeleportToInnerVeil((Player*)pUnit); + } + else error_log(ERROR_MISSING_TELEPORT_GUID); + } + else error_log(ERROR_MISSING_TELEPORT_GUID); + + m_creature->SetUInt64Value(UNIT_FIELD_TARGET, m_creature->getVictim()->GetGUID()); + TeleportTargetGUID = 0; + SpectralTeleportTimer = SpectralBlastTimer + 2000; + + }else SpectralTeleportTimer -= diff; + + if(!Banished) DoMeleeAttackIfReady(); + } +}; + +struct MANGOS_DLL_DECL boss_sathrovarrAI : public ScriptedAI +{ + boss_sathrovarrAI(Creature* c) : ScriptedAI(c) + { + pInstance = ((ScriptedInstance*)c->GetInstanceData()); + Reset(); + } + + ScriptedInstance* pInstance; + + uint32 CorruptingStrikeTimer; + uint32 CurseOfBoundlessAgonyTimer; + uint32 ShadowBoltVolleyTimer; + bool Banished; + bool Enraged; + + void Reset() + { + // FIXME: Timers + CorruptingStrikeTimer = 5000; + CurseOfBoundlessAgonyTimer = 15000; + ShadowBoltVolleyTimer = 10000; + + Banished = false; + Enraged = false; + + DoCast(m_creature, SPELL_SPECTRAL_REALM, true); + } + + void Aggro(Unit* who) + { + DoYell(SAY_SATH_AGGRO, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_SATH_AGGRO); + + Creature* Kalec = ((Creature*)Unit::GetUnit(*m_creature, pInstance->GetData64(DATA_KALECGOS_HUMAN))); + if(Kalec) + { + m_creature->AddThreat(Kalec, 10000000.0f); + Kalec->AddThreat(m_creature, 10000000.0f); + } + } + + void DamageTaken(Unit* done_by, uint32 &damage) + { + if(damage > m_creature->GetHealth()) + { + damage = 0; + DoCast(m_creature, SPELL_BANISH, true); + Banished = true; + + DoYell(SAY_SATH_DEATH, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_SATH_DEATH); + + if(!pInstance) + { + error_log(ERROR_INST_DATA); + return; + } + + pInstance->SetData(DATA_SET_SPECTRAL_CHECK, 5000); + + Creature* Kalecgos = ((Creature*)Unit::GetUnit((*m_creature), pInstance->GetData64(DATA_KALECGOS_DRAGON))); + if(Kalecgos) + { + ((boss_kalecgosAI*)Kalecgos->AI())->Checked = false; + ((boss_kalecgosAI*)Kalecgos->AI())->Uncorrupted = true; + } + else error_log(ERROR_KALECGOS_NOT_FOUND); + } + } + + void KilledUnit(Unit* victim) + { + switch(rand()%2) + { + case 0: + DoYell(SAY_SATH_SLAY1,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_SATH_SLAY1); + break; + case 1: + DoYell(SAY_SATH_SLAY2,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_SATH_SLAY2); + break; + } + } + + void UpdateAI(const uint32 diff) + { + if(!m_creature->getVictim() || !m_creature->SelectHostilTarget() || Banished) + return; + + if(((m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < 10) && !Enraged) + { + Unit* Kalecgos = Unit::GetUnit(*m_creature, pInstance->GetData64(DATA_KALECGOS_DRAGON)); + if(Kalecgos) + Kalecgos->CastSpell(Kalecgos, SPELL_CRAZED_RAGE, true); + DoCast(m_creature, SPELL_CRAZED_RAGE, true); + Enraged = true; + } + + if(CorruptingStrikeTimer < diff) + { + if(rand()%2 == 0) + { + DoYell(SAY_SATH_SPELL2, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_SATH_SPELL2); + } + DoCast(m_creature->getVictim(), SPELL_CORRUPTING_STRIKE); + CorruptingStrikeTimer = 13000; + }else CorruptingStrikeTimer -= diff; + + if(CurseOfBoundlessAgonyTimer < diff) + { + DoCast(SelectUnit(SELECT_TARGET_RANDOM, 0), SPELL_CURSE_OF_BOUNDLESS_AGONY); + CurseOfBoundlessAgonyTimer = 35000; + DoCast(m_creature, SPELL_SPECTRAL_REALM, true); + }else CurseOfBoundlessAgonyTimer -= diff; + + if(ShadowBoltVolleyTimer < diff) + { + if(rand()%2 == 0) + { + DoYell(SAY_SATH_SPELL1, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_SATH_SPELL1); + } + DoCast(m_creature->getVictim(), SPELL_SHADOW_BOLT_VOLLEY); + ShadowBoltVolleyTimer = 15000; + }else ShadowBoltVolleyTimer -= diff; + + DoMeleeAttackIfReady(); + } +}; + +struct MANGOS_DLL_DECL boss_kalecAI : public ScriptedAI +{ + boss_kalecAI(Creature* c) : ScriptedAI(c) + { + pInstance = ((ScriptedInstance*)c->GetInstanceData()); + Reset(); + } + + ScriptedInstance *pInstance; + + uint32 RevitalizeTimer; + uint32 HeroicStrikeTimer; + + bool HasYelled10Percent; + bool HasYelled20Percent; + + void Reset() + { + //TODO: Times! + RevitalizeTimer = 30000; + HeroicStrikeTimer = 8000; + + HasYelled10Percent = false; + HasYelled20Percent = false; + + DoCast(m_creature, SPELL_SPECTRAL_REALM, true); + } + + void Aggro(Unit* who) + { + DoYell(SAY_KALEC_AGGRO, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_KALEC_AGGRO); + } + + void JustDied(Unit* killer) + { + // Whatever happens when Kalec (Half-elf) dies + } + + void UpdateAI(const uint32 diff) + { + if(!m_creature->getVictim() || !m_creature->SelectHostilTarget()) + return; + + if(RevitalizeTimer < diff) + { + if(pInstance) + { + Unit* pUnit = Unit::GetUnit(*m_creature, pInstance->GetData64(DATA_RANDOM_SPECTRAL_PLAYER)); + if(pUnit) + DoCast(pUnit, SPELL_REVITALIZE); + RevitalizeTimer = 30000; + } + }else RevitalizeTimer -= diff; + + if(HeroicStrikeTimer < diff) + { + DoCast(m_creature->getVictim(), SPELL_HEROIC_STRIKE); + HeroicStrikeTimer = 30000; + }else HeroicStrikeTimer -= diff; + + if(((m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < 20) && !HasYelled20Percent) + { + DoYell(SAY_KALEC_NEAR_DEATH, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_KALEC_NEAR_DEATH); + HasYelled20Percent = true; + } + + if(((m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < 10) && !HasYelled10Percent) + { + DoYell(SAY_KALEC_NEAR_DEATH2, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_KALEC_NEAR_DEATH2); + HasYelled10Percent = true; + } + } +}; + +CreatureAI* GetAI_boss_kalecgos(Creature* c) +{ + return new boss_kalecgosAI(c); +} + +CreatureAI* GetAI_boss_sathrovarr(Creature* c) +{ + return new boss_sathrovarrAI(c); +} + +CreatureAI* GetAI_boss_kalec(Creature* c) +{ + return new boss_kalecAI(c); +} + +void AddSC_boss_kalecgos() +{ + Script* newscript; + + newscript = new Script; + newscript->GetAI = GetAI_boss_kalecgos; + newscript->Name = "boss_kalecgos"; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->GetAI = GetAI_boss_sathrovarr; + newscript->Name = "boss_sathrovarr"; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->GetAI = GetAI_boss_kalec; + newscript->Name = "boss_kalec"; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->pGOHello = GOHello_GO_Spectral_Portal; + newscript->Name = "go_spectral_portal"; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/sunwell_plateau/def_sunwell_plateau.h b/src/bindings/scripts/scripts/zone/sunwell_plateau/def_sunwell_plateau.h index 316b13062f0..5b6ae7fcf9a 100644 --- a/src/bindings/scripts/scripts/zone/sunwell_plateau/def_sunwell_plateau.h +++ b/src/bindings/scripts/scripts/zone/sunwell_plateau/def_sunwell_plateau.h @@ -1,43 +1,43 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software licensed under GPL version 2 - * Please see the included DOCS/LICENSE.TXT for more information */ - -#ifndef DEF_SUNWELLPLATEAU_H -#define DEF_SUNWELLPLATEAU_H - -/*** Encounters ***/ -#define DATA_KALECGOS_EVENT 0 -#define DATA_BRUTALLUS_EVENT 1 -#define DATA_FELMYST_EVENT 2 -#define DATA_EREDAR_TWINS_EVENT 3 -#define DATA_MURU_EVENT 4 -#define DATA_KILJAEDEN_EVENT 5 - -/*** Creatures ***/ -#define DATA_KALECGOS_DRAGON 6 -#define DATA_KALECGOS_HUMAN 7 -#define DATA_SATHROVARR 8 -#define DATA_BRUTALLUS 9 -#define DATA_FELMYST 10 -#define DATA_ALYTHESS 11 -#define DATA_SACROLASH 12 -#define DATA_MURU 13 -#define DATA_KILJAEDEN 14 -#define DATA_KILJAEDEN_CONTROLLER 15 -#define DATA_ANVEENA 16 - -/*** GameObjects ***/ -#define DATA_GO_FORCEFIELD 17 -#define DATA_GO_FIRE_BARRIER 18 -#define DATA_GATE_1 19 -#define DATA_GATE_2 20 -#define DATA_GATE_3 21 -#define DATA_GATE_4 22 -#define DATA_GATE_5 23 - -/*** Misc ***/ -#define DATA_PLAYER_SPECTRAL_REALM 24 -#define DATA_SET_SPECTRAL_CHECK 25 -#define DATA_RANDOM_SPECTRAL_PLAYER 26 -#define DATA_INST_EJECT_PLAYERS 27 -#endif +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software licensed under GPL version 2 + * Please see the included DOCS/LICENSE.TXT for more information */ + +#ifndef DEF_SUNWELLPLATEAU_H +#define DEF_SUNWELLPLATEAU_H + +/*** Encounters ***/ +#define DATA_KALECGOS_EVENT 0 +#define DATA_BRUTALLUS_EVENT 1 +#define DATA_FELMYST_EVENT 2 +#define DATA_EREDAR_TWINS_EVENT 3 +#define DATA_MURU_EVENT 4 +#define DATA_KILJAEDEN_EVENT 5 + +/*** Creatures ***/ +#define DATA_KALECGOS_DRAGON 6 +#define DATA_KALECGOS_HUMAN 7 +#define DATA_SATHROVARR 8 +#define DATA_BRUTALLUS 9 +#define DATA_FELMYST 10 +#define DATA_ALYTHESS 11 +#define DATA_SACROLASH 12 +#define DATA_MURU 13 +#define DATA_KILJAEDEN 14 +#define DATA_KILJAEDEN_CONTROLLER 15 +#define DATA_ANVEENA 16 + +/*** GameObjects ***/ +#define DATA_GO_FORCEFIELD 17 +#define DATA_GO_FIRE_BARRIER 18 +#define DATA_GATE_1 19 +#define DATA_GATE_2 20 +#define DATA_GATE_3 21 +#define DATA_GATE_4 22 +#define DATA_GATE_5 23 + +/*** Misc ***/ +#define DATA_PLAYER_SPECTRAL_REALM 24 +#define DATA_SET_SPECTRAL_CHECK 25 +#define DATA_RANDOM_SPECTRAL_PLAYER 26 +#define DATA_INST_EJECT_PLAYERS 27 +#endif diff --git a/src/bindings/scripts/scripts/zone/sunwell_plateau/instance_sunwell_plateau.cpp b/src/bindings/scripts/scripts/zone/sunwell_plateau/instance_sunwell_plateau.cpp index d5c419520ec..44b060ff646 100644 --- a/src/bindings/scripts/scripts/zone/sunwell_plateau/instance_sunwell_plateau.cpp +++ b/src/bindings/scripts/scripts/zone/sunwell_plateau/instance_sunwell_plateau.cpp @@ -1,275 +1,275 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software licensed under GPL version 2 - * Please see the included DOCS/LICENSE.TXT for more information */ - -/* ScriptData -SDName: instance_sunwell_plateau -SD%Complete: 0 -SDComment: VERIFY SCRIPT -SDCategory: Sunwell_Plateau -EndScriptData */ - -#include "precompiled.h" -#include "def_sunwell_plateau.h" - -#define ENCOUNTERS 6 - -#define SPELL_SPECTRAL_REALM 46021 -#define SPELL_TELEPORT_NORMAL_REALM 46020 -#define SPELL_SPECTRAL_EXHAUSTION 44867 - -/* Sunwell Plateau: -0 - Kalecgos and Sathrovarr -1 - Brutallus -2 - Felmyst -3 - Eredar Twins (Alythess and Sacrolash) -4 - M'uru -5 - Kil'Jaeden -*/ - -struct MANGOS_DLL_DECL instance_sunwell_plateau : public ScriptedInstance -{ - instance_sunwell_plateau(Map *Map) : ScriptedInstance(Map) {Initialize();}; - - uint32 Encounters[ENCOUNTERS]; - - /** Creatures **/ - uint64 Kalecgos_Dragon; - uint64 Kalecgos_Human; - uint64 Sathrovarr; - uint64 Brutallus; - uint64 Felmyst; - uint64 Alythess; - uint64 Sacrolash; - uint64 Muru; - uint64 KilJaeden; - uint64 KilJaedenController; - uint64 Anveena; - - /** GameObjects **/ - uint64 ForceField; // Kalecgos Encounter - uint64 FireBarrier; // Brutallus Encounter - uint64 Gate[5]; // Rename this to be more specific after door placement is verified. - - /*** Misc ***/ - uint32 SpectralRealmTimer; - std::vector SpectralRealmList; - - void Initialize() - { - /*** Creatures ***/ - Kalecgos_Dragon = 0; - Kalecgos_Human = 0; - Sathrovarr = 0; - Brutallus = 0; - Felmyst = 0; - Alythess = 0; - Sacrolash = 0; - Muru = 0; - KilJaeden = 0; - KilJaedenController = 0; - Anveena = 0; - - /*** GameObjects ***/ - ForceField = 0; - FireBarrier = 0; - Gate[0] = 0; // TODO: Rename Gate[n] with gate_ for better specificity - Gate[1] = 0; - Gate[2] = 0; - Gate[3] = 0; - Gate[4] = 0; - - /*** Encounters ***/ - for(uint8 i = 0; i < ENCOUNTERS; ++i) - Encounters[i] = NOT_STARTED; - - /*** Misc ***/ - SpectralRealmTimer = 5000; - } - - bool IsEncounterInProgress() const - { - for(uint8 i = 0; i < ENCOUNTERS; ++i) - if(Encounters[i] == IN_PROGRESS) - return true; - - return false; - } - - void OnCreatureCreate(Creature* creature, uint32 entry) - { - switch(entry) - { - case 24850: Kalecgos_Dragon = creature->GetGUID(); break; - case 24891: Kalecgos_Human = creature->GetGUID(); break; - case 24892: Sathrovarr = creature->GetGUID(); break; - case 24882: Brutallus = creature->GetGUID(); break; - case 25038: Felmyst = creature->GetGUID(); break; - case 25166: Alythess = creature->GetGUID(); break; - case 25165: Sacrolash = creature->GetGUID(); break; - case 25741: Muru = creature->GetGUID(); break; - case 25315: KilJaeden = creature->GetGUID(); break; - case 25608: KilJaedenController = creature->GetGUID(); break; - case 26046: Anveena = creature->GetGUID(); break; - } - } - - void OnObjectCreate(GameObject* gobj) - { - switch(gobj->GetEntry()) - { - case 188421: ForceField = gobj->GetGUID(); break; - case 188075: FireBarrier = gobj->GetGUID(); break; - case 187979: Gate[0] = gobj->GetGUID(); break; - case 187770: Gate[1] = gobj->GetGUID(); break; - case 187896: Gate[2] = gobj->GetGUID(); break; - case 187990: Gate[3] = gobj->GetGUID(); break; - case 188118: Gate[4] = gobj->GetGUID(); break; - } - } - - uint32 GetData(uint32 id) - { - switch(id) - { - case DATA_KALECGOS_EVENT: return Encounters[0]; break; - case DATA_BRUTALLUS_EVENT: return Encounters[1]; break; - case DATA_FELMYST_EVENT: return Encounters[2]; break; - case DATA_EREDAR_TWINS_EVENT: return Encounters[3]; break; - case DATA_MURU_EVENT: return Encounters[4]; break; - case DATA_KILJAEDEN_EVENT: return Encounters[5]; break; - } - - return 0; - } - - uint64 GetData64(uint32 id) - { - switch(id) - { - case DATA_KALECGOS_DRAGON: return Kalecgos_Dragon; break; - case DATA_KALECGOS_HUMAN: return Kalecgos_Human; break; - case DATA_SATHROVARR: return Sathrovarr; break; - case DATA_BRUTALLUS: return Brutallus; break; - case DATA_FELMYST: return Felmyst; break; - case DATA_ALYTHESS: return Alythess; break; - case DATA_SACROLASH: return Sacrolash; break; - case DATA_MURU: return Muru; break; - case DATA_KILJAEDEN: return KilJaeden; break; - case DATA_KILJAEDEN_CONTROLLER: return KilJaedenController; break; - case DATA_ANVEENA: return Anveena; break; - - case DATA_RANDOM_SPECTRAL_PLAYER: - return *(SpectralRealmList.begin() + rand()%SpectralRealmList.size()); - break; - } - return 0; - } - - void SetData(uint32 id, uint32 data) - { - switch(id) - { - case DATA_KALECGOS_EVENT: Encounters[0] = data; break; - case DATA_BRUTALLUS_EVENT: Encounters[1] = data; break; - case DATA_FELMYST_EVENT: Encounters[2] = data; break; - case DATA_EREDAR_TWINS_EVENT: Encounters[3] = data; break; - case DATA_MURU_EVENT: Encounters[4] = data; break; - case DATA_KILJAEDEN_EVENT: Encounters[5] = data; break; - - case DATA_SET_SPECTRAL_CHECK: SpectralRealmTimer = data; break; - case DATA_INST_EJECT_PLAYERS: EjectPlayers(); break; - } - } - - void SetData64(uint32 id, uint64 guid) - { - switch(id) - { - case DATA_PLAYER_SPECTRAL_REALM: - SpectralRealmList.push_back(guid); - break; - } - } - - // Dirty Hack as we can't use Unit::GetUnit in instance scripts due to lack of a WorldObject. - Player* DirtyHackToGetPlayerFromSpectralList(uint64 guid) - { - Player* first = ((InstanceMap*)instance)->GetPlayers().front(); - if(!first) - return NULL; - - Player* plr = ((Player*)Unit::GetUnit(*first, guid)); - if(plr) - return plr; - - return NULL; - } - - void EjectPlayer(Player* plr) - { - debug_log("SD2: INST: Ejecting Player %s from Spectral Realm", plr->GetName()); - // Remove player from Sathrovarr's threat list - Creature* Sath = ((Creature*)Unit::GetUnit(*plr, Sathrovarr)); - if(Sath && Sath->isAlive()) - { - HostilReference* ref = Sath->getThreatManager().getOnlineContainer().getReferenceByTarget(plr); - if(ref) - { - ref->removeReference(); - debug_log("SD2: INST: Deleting %s from Sathrovarr's threatlist", plr->GetName()); - } - } - - // Put player back in Kalecgos(Dragon)'s threat list - Creature* Kalecgos = ((Creature*)Unit::GetUnit(*plr, Kalecgos_Dragon)); - if(Kalecgos && Kalecgos->isAlive()) - { - debug_log("SD2: INST: Putting %s in Kalecgos' threatlist", plr->GetName()); - Kalecgos->AddThreat(plr, 1.0f); - } - - plr->CastSpell(plr, SPELL_TELEPORT_NORMAL_REALM, true); - plr->CastSpell(plr, SPELL_SPECTRAL_EXHAUSTION, true); - } - - void EjectPlayers() - { - for(uint8 i = 0; i < SpectralRealmList.size(); ++i) - { - Player* plr = DirtyHackToGetPlayerFromSpectralList(SpectralRealmList[i]); - if(plr && !plr->HasAura(SPELL_SPECTRAL_REALM, 0)) - { - EjectPlayer(plr); - SpectralRealmList.erase(SpectralRealmList.begin() + i); - } - } - - SpectralRealmList.clear(); - } - - void Update(uint32 diff) - { - // Only check for Spectral Realm if Kalecgos Encounter is running - if(Encounters[0] == IN_PROGRESS) - if(SpectralRealmTimer < diff) - { - EjectPlayers(); - SpectralRealmTimer = 5000; - }else SpectralRealmTimer -= diff; - } -}; - -InstanceData* GetInstanceData_instance_sunwell_plateau(Map* map) -{ - return new instance_sunwell_plateau(map); -} - -void AddSC_instance_sunwell_plateau() -{ - Script *newscript; - newscript = new Script; - newscript->Name = "instance_sunwell_plateau"; - newscript->GetInstanceData = GetInstanceData_instance_sunwell_plateau; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software licensed under GPL version 2 + * Please see the included DOCS/LICENSE.TXT for more information */ + +/* ScriptData +SDName: instance_sunwell_plateau +SD%Complete: 0 +SDComment: VERIFY SCRIPT +SDCategory: Sunwell_Plateau +EndScriptData */ + +#include "precompiled.h" +#include "def_sunwell_plateau.h" + +#define ENCOUNTERS 6 + +#define SPELL_SPECTRAL_REALM 46021 +#define SPELL_TELEPORT_NORMAL_REALM 46020 +#define SPELL_SPECTRAL_EXHAUSTION 44867 + +/* Sunwell Plateau: +0 - Kalecgos and Sathrovarr +1 - Brutallus +2 - Felmyst +3 - Eredar Twins (Alythess and Sacrolash) +4 - M'uru +5 - Kil'Jaeden +*/ + +struct MANGOS_DLL_DECL instance_sunwell_plateau : public ScriptedInstance +{ + instance_sunwell_plateau(Map *Map) : ScriptedInstance(Map) {Initialize();}; + + uint32 Encounters[ENCOUNTERS]; + + /** Creatures **/ + uint64 Kalecgos_Dragon; + uint64 Kalecgos_Human; + uint64 Sathrovarr; + uint64 Brutallus; + uint64 Felmyst; + uint64 Alythess; + uint64 Sacrolash; + uint64 Muru; + uint64 KilJaeden; + uint64 KilJaedenController; + uint64 Anveena; + + /** GameObjects **/ + uint64 ForceField; // Kalecgos Encounter + uint64 FireBarrier; // Brutallus Encounter + uint64 Gate[5]; // Rename this to be more specific after door placement is verified. + + /*** Misc ***/ + uint32 SpectralRealmTimer; + std::vector SpectralRealmList; + + void Initialize() + { + /*** Creatures ***/ + Kalecgos_Dragon = 0; + Kalecgos_Human = 0; + Sathrovarr = 0; + Brutallus = 0; + Felmyst = 0; + Alythess = 0; + Sacrolash = 0; + Muru = 0; + KilJaeden = 0; + KilJaedenController = 0; + Anveena = 0; + + /*** GameObjects ***/ + ForceField = 0; + FireBarrier = 0; + Gate[0] = 0; // TODO: Rename Gate[n] with gate_ for better specificity + Gate[1] = 0; + Gate[2] = 0; + Gate[3] = 0; + Gate[4] = 0; + + /*** Encounters ***/ + for(uint8 i = 0; i < ENCOUNTERS; ++i) + Encounters[i] = NOT_STARTED; + + /*** Misc ***/ + SpectralRealmTimer = 5000; + } + + bool IsEncounterInProgress() const + { + for(uint8 i = 0; i < ENCOUNTERS; ++i) + if(Encounters[i] == IN_PROGRESS) + return true; + + return false; + } + + void OnCreatureCreate(Creature* creature, uint32 entry) + { + switch(entry) + { + case 24850: Kalecgos_Dragon = creature->GetGUID(); break; + case 24891: Kalecgos_Human = creature->GetGUID(); break; + case 24892: Sathrovarr = creature->GetGUID(); break; + case 24882: Brutallus = creature->GetGUID(); break; + case 25038: Felmyst = creature->GetGUID(); break; + case 25166: Alythess = creature->GetGUID(); break; + case 25165: Sacrolash = creature->GetGUID(); break; + case 25741: Muru = creature->GetGUID(); break; + case 25315: KilJaeden = creature->GetGUID(); break; + case 25608: KilJaedenController = creature->GetGUID(); break; + case 26046: Anveena = creature->GetGUID(); break; + } + } + + void OnObjectCreate(GameObject* gobj) + { + switch(gobj->GetEntry()) + { + case 188421: ForceField = gobj->GetGUID(); break; + case 188075: FireBarrier = gobj->GetGUID(); break; + case 187979: Gate[0] = gobj->GetGUID(); break; + case 187770: Gate[1] = gobj->GetGUID(); break; + case 187896: Gate[2] = gobj->GetGUID(); break; + case 187990: Gate[3] = gobj->GetGUID(); break; + case 188118: Gate[4] = gobj->GetGUID(); break; + } + } + + uint32 GetData(uint32 id) + { + switch(id) + { + case DATA_KALECGOS_EVENT: return Encounters[0]; break; + case DATA_BRUTALLUS_EVENT: return Encounters[1]; break; + case DATA_FELMYST_EVENT: return Encounters[2]; break; + case DATA_EREDAR_TWINS_EVENT: return Encounters[3]; break; + case DATA_MURU_EVENT: return Encounters[4]; break; + case DATA_KILJAEDEN_EVENT: return Encounters[5]; break; + } + + return 0; + } + + uint64 GetData64(uint32 id) + { + switch(id) + { + case DATA_KALECGOS_DRAGON: return Kalecgos_Dragon; break; + case DATA_KALECGOS_HUMAN: return Kalecgos_Human; break; + case DATA_SATHROVARR: return Sathrovarr; break; + case DATA_BRUTALLUS: return Brutallus; break; + case DATA_FELMYST: return Felmyst; break; + case DATA_ALYTHESS: return Alythess; break; + case DATA_SACROLASH: return Sacrolash; break; + case DATA_MURU: return Muru; break; + case DATA_KILJAEDEN: return KilJaeden; break; + case DATA_KILJAEDEN_CONTROLLER: return KilJaedenController; break; + case DATA_ANVEENA: return Anveena; break; + + case DATA_RANDOM_SPECTRAL_PLAYER: + return *(SpectralRealmList.begin() + rand()%SpectralRealmList.size()); + break; + } + return 0; + } + + void SetData(uint32 id, uint32 data) + { + switch(id) + { + case DATA_KALECGOS_EVENT: Encounters[0] = data; break; + case DATA_BRUTALLUS_EVENT: Encounters[1] = data; break; + case DATA_FELMYST_EVENT: Encounters[2] = data; break; + case DATA_EREDAR_TWINS_EVENT: Encounters[3] = data; break; + case DATA_MURU_EVENT: Encounters[4] = data; break; + case DATA_KILJAEDEN_EVENT: Encounters[5] = data; break; + + case DATA_SET_SPECTRAL_CHECK: SpectralRealmTimer = data; break; + case DATA_INST_EJECT_PLAYERS: EjectPlayers(); break; + } + } + + void SetData64(uint32 id, uint64 guid) + { + switch(id) + { + case DATA_PLAYER_SPECTRAL_REALM: + SpectralRealmList.push_back(guid); + break; + } + } + + // Dirty Hack as we can't use Unit::GetUnit in instance scripts due to lack of a WorldObject. + Player* DirtyHackToGetPlayerFromSpectralList(uint64 guid) + { + Player* first = ((InstanceMap*)instance)->GetPlayers().front(); + if(!first) + return NULL; + + Player* plr = ((Player*)Unit::GetUnit(*first, guid)); + if(plr) + return plr; + + return NULL; + } + + void EjectPlayer(Player* plr) + { + debug_log("SD2: INST: Ejecting Player %s from Spectral Realm", plr->GetName()); + // Remove player from Sathrovarr's threat list + Creature* Sath = ((Creature*)Unit::GetUnit(*plr, Sathrovarr)); + if(Sath && Sath->isAlive()) + { + HostilReference* ref = Sath->getThreatManager().getOnlineContainer().getReferenceByTarget(plr); + if(ref) + { + ref->removeReference(); + debug_log("SD2: INST: Deleting %s from Sathrovarr's threatlist", plr->GetName()); + } + } + + // Put player back in Kalecgos(Dragon)'s threat list + Creature* Kalecgos = ((Creature*)Unit::GetUnit(*plr, Kalecgos_Dragon)); + if(Kalecgos && Kalecgos->isAlive()) + { + debug_log("SD2: INST: Putting %s in Kalecgos' threatlist", plr->GetName()); + Kalecgos->AddThreat(plr, 1.0f); + } + + plr->CastSpell(plr, SPELL_TELEPORT_NORMAL_REALM, true); + plr->CastSpell(plr, SPELL_SPECTRAL_EXHAUSTION, true); + } + + void EjectPlayers() + { + for(uint8 i = 0; i < SpectralRealmList.size(); ++i) + { + Player* plr = DirtyHackToGetPlayerFromSpectralList(SpectralRealmList[i]); + if(plr && !plr->HasAura(SPELL_SPECTRAL_REALM, 0)) + { + EjectPlayer(plr); + SpectralRealmList.erase(SpectralRealmList.begin() + i); + } + } + + SpectralRealmList.clear(); + } + + void Update(uint32 diff) + { + // Only check for Spectral Realm if Kalecgos Encounter is running + if(Encounters[0] == IN_PROGRESS) + if(SpectralRealmTimer < diff) + { + EjectPlayers(); + SpectralRealmTimer = 5000; + }else SpectralRealmTimer -= diff; + } +}; + +InstanceData* GetInstanceData_instance_sunwell_plateau(Map* map) +{ + return new instance_sunwell_plateau(map); +} + +void AddSC_instance_sunwell_plateau() +{ + Script *newscript; + newscript = new Script; + newscript->Name = "instance_sunwell_plateau"; + newscript->GetInstanceData = GetInstanceData_instance_sunwell_plateau; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/tanaris/tanaris.cpp b/src/bindings/scripts/scripts/zone/tanaris/tanaris.cpp index a5e74587a51..5def6196fa1 100644 --- a/src/bindings/scripts/scripts/zone/tanaris/tanaris.cpp +++ b/src/bindings/scripts/scripts/zone/tanaris/tanaris.cpp @@ -1,402 +1,402 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Tanaris -SD%Complete: 80 -SDComment: Quest support: 2954, 4005, 10277, 10279(Special flight path). Noggenfogger vendor -SDCategory: Tanaris -EndScriptData */ - -/* ContentData -mob_aquementas -npc_custodian_of_time -npc_marin_noggenfogger -npc_steward_of_time -npc_stone_watcher_of_norgannon -EndContentData */ - -#include "precompiled.h" -#include "../../npc/npc_escortAI.h" - -/*###### -## mob_aquementas -######*/ - -#define AGGRO_YELL_AQUE "Who dares awaken Aquementas?" - -#define SPELL_AQUA_JET 13586 -#define SPELL_FROST_SHOCK 15089 - -struct MANGOS_DLL_DECL mob_aquementasAI : public ScriptedAI -{ - mob_aquementasAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 SendItem_Timer; - uint32 SwitchFaction_Timer; - bool isFriendly; - - uint32 FrostShock_Timer; - uint32 AquaJet_Timer; - - void Reset() - { - SendItem_Timer = 0; - SwitchFaction_Timer = 10000; - m_creature->setFaction(35); - isFriendly = true; - - AquaJet_Timer = 5000; - FrostShock_Timer = 1000; - } - - void SendItem(Unit* receiver) - { - if (((Player*)receiver)->HasItemCount(11169,1,false) && - ((Player*)receiver)->HasItemCount(11172,11,false) && - ((Player*)receiver)->HasItemCount(11173,1,false) && - !((Player*)receiver)->HasItemCount(11522,1,true)) - { - ItemPosCountVec dest; - uint8 msg = ((Player*)receiver)->CanStoreNewItem( NULL_BAG, NULL_SLOT, dest, 11522, 1, false); - if( msg == EQUIP_ERR_OK ) - ((Player*)receiver)->StoreNewItem( dest, 11522, 1, true); - } - } - - void Aggro(Unit* who) - { - DoYell(AGGRO_YELL_AQUE,LANG_UNIVERSAL,who); - } - - void UpdateAI(const uint32 diff) - { - if( isFriendly ) - { - if( SwitchFaction_Timer < diff ) - { - m_creature->setFaction(91); - isFriendly = false; - }else SwitchFaction_Timer -= diff; - } - - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - if( !isFriendly ) - { - if( SendItem_Timer < diff ) - { - if( m_creature->getVictim()->GetTypeId() == TYPEID_PLAYER ) - SendItem(m_creature->getVictim()); - SendItem_Timer = 5000; - }else SendItem_Timer -= diff; - } - - if( FrostShock_Timer < diff ) - { - DoCast(m_creature->getVictim(),SPELL_FROST_SHOCK); - FrostShock_Timer = 15000; - }else FrostShock_Timer -= diff; - - if( AquaJet_Timer < diff ) - { - DoCast(m_creature,SPELL_AQUA_JET); - AquaJet_Timer = 15000; - }else AquaJet_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; -CreatureAI* GetAI_mob_aquementas(Creature *_Creature) -{ - return new mob_aquementasAI (_Creature); -} - -/*###### -## npc_custodian_of_time -######*/ - -#define WHISPER_CUSTODIAN_1 "Greetings, $N. I will guide you through the cavern. Please try and keep up." -#define WHISPER_CUSTODIAN_2 "We do not know if the Caverns of Time have always been accessible to mortals. Truly, it is impossible to tell as the Timeless One is in perpetual motion, changing our timeways as he sees fit. What you see now may very well not exist tomorrow. You may wake up and have no memory of this place." -#define WHISPER_CUSTODIAN_3 "It is strange, I know... Most mortals cannot actually comprehend what they see here, as often, what they see is not anchored within their own perception of reality." -#define WHISPER_CUSTODIAN_4 "Follow me, please." -#define WHISPER_CUSTODIAN_5 "There are only two truths to be found here: First, that time is chaotic, always in flux, and completely malleable and second, perception does not dictate reality." -#define WHISPER_CUSTODIAN_6 "As custodians of time, we watch over and care for Nozdormu's realm. The master is away at the moment, which means that attempts are being made to dramatically alter time. The master never meddles in the affairs of mortals but instead corrects the alterations made to time by others. He is reactionary in this regard." -#define WHISPER_CUSTODIAN_7 "For normal maintenance of time, the Keepers of Time are sufficient caretakers. We are able to deal with most ordinary disturbances. I speak of little things, such as rogue mages changing something in the past to elevate their status or wealth in the present." -#define WHISPER_CUSTODIAN_8 "These tunnels that you see are called timeways. They are infinite in number. The ones that currently exist in your reality are what the master has deemed as 'trouble spots.' These trouble spots may differ completely in theme but they always share a cause. That is, their existence is a result of the same temporal disturbance. Remember that should you venture inside one..." -#define WHISPER_CUSTODIAN_9 "This timeway is in great disarray! We have agents inside right now attempting to restore order. What information I have indicates that Thrall's freedom is in jeopardy. A malevolent organization known as the Infinite Dragonflight is trying to prevent his escape. I fear without outside assistance, all will be lost." -#define WHISPER_CUSTODIAN_10 "We have very little information on this timeway. Sa'at has been dispatched and is currently inside. The data we have gathered from his correspondence is that the Infinite Dragonflight are once again attempting to alter time. Could it be that the opening of the Dark Portal is being targeted for sabotage? Let us hope not..." -#define WHISPER_CUSTODIAN_11 "This timeway is currently collapsing. What that may hold for the past, present and future is currently unknown..." -#define WHISPER_CUSTODIAN_12 "The timeways are currently ranked in order from least catastrophic to most catastrophic. Note that they are all classified as catastrophic, meaning that any single one of these timeways collapsing would mean that your world would end. We only classify them in such a way so that the heroes and adventurers that are sent here know which timeway best suits their abilities." -#define WHISPER_CUSTODIAN_13 "All we know of this timeway is that it leads to Mount Hyjal. The Infinite Dragonflight have gone to great lengths to prevent our involvement. We know next to nothing, mortal. Soridormi is currently attempting to break through the timeway's defenses but has thus far been unsuccessful. You might be our only hope of breaking through and resolving the conflict." -#define WHISPER_CUSTODIAN_14 "Our time is at an end $N. I would wish you luck, if such a thing existed." - -struct MANGOS_DLL_DECL npc_custodian_of_timeAI : public npc_escortAI -{ - npc_custodian_of_timeAI(Creature *c) : npc_escortAI(c) { Reset(); } - - void WaypointReached(uint32 i) - { - Unit *pTemp = Unit::GetUnit(*m_creature,PlayerGUID); - if( !pTemp ) - return; - - switch( i ) - { - case 0: DoWhisper(WHISPER_CUSTODIAN_1, pTemp); break; - case 1: DoWhisper(WHISPER_CUSTODIAN_2, pTemp); break; - case 2: DoWhisper(WHISPER_CUSTODIAN_3, pTemp); break; - case 3: DoWhisper(WHISPER_CUSTODIAN_4, pTemp); break; - case 5: DoWhisper(WHISPER_CUSTODIAN_5, pTemp); break; - case 6: DoWhisper(WHISPER_CUSTODIAN_6, pTemp); break; - case 7: DoWhisper(WHISPER_CUSTODIAN_7, pTemp); break; - case 8: DoWhisper(WHISPER_CUSTODIAN_8, pTemp); break; - case 9: DoWhisper(WHISPER_CUSTODIAN_9, pTemp); break; - case 10: DoWhisper(WHISPER_CUSTODIAN_4, pTemp); break; - case 13: DoWhisper(WHISPER_CUSTODIAN_10, pTemp); break; - case 14: DoWhisper(WHISPER_CUSTODIAN_4, pTemp); break; - case 16: DoWhisper(WHISPER_CUSTODIAN_11, pTemp); break; - case 17: DoWhisper(WHISPER_CUSTODIAN_12, pTemp); break; - case 18: DoWhisper(WHISPER_CUSTODIAN_4, pTemp); break; - case 22: DoWhisper(WHISPER_CUSTODIAN_13, pTemp); break; - case 23: DoWhisper(WHISPER_CUSTODIAN_4, pTemp); break; - case 24: - DoWhisper(WHISPER_CUSTODIAN_14, pTemp); - DoCast(pTemp,34883); - //below here is temporary workaround, to be removed when spell works properly - ((Player*)pTemp)->AreaExploredOrEventHappens(10277); - break; - } - } - - void MoveInLineOfSight(Unit *who) - { - if( IsBeingEscorted ) - return; - - if( who->GetTypeId() == TYPEID_PLAYER ) - { - if( ((Player*)who)->HasAura(34877,1) && ((Player*)who)->GetQuestStatus(10277) == QUEST_STATUS_INCOMPLETE ) - { - float Radius = 10.0; - if( m_creature->IsWithinDistInMap(who, Radius) ) - { - ((npc_escortAI*)(m_creature->AI()))->Start(false, false, false, who->GetGUID()); - } - } - } - } - - void Aggro(Unit* who) { } - void Reset() { } - - void UpdateAI(const uint32 diff) - { - npc_escortAI::UpdateAI(diff); - } -}; - -CreatureAI* GetAI_npc_custodian_of_time(Creature *_Creature) -{ - npc_custodian_of_timeAI* custodian_of_timeAI = new npc_custodian_of_timeAI(_Creature); - - custodian_of_timeAI->AddWaypoint(0, -8374.93,-4250.21, -204.38,5000); - custodian_of_timeAI->AddWaypoint(1, -8374.93,-4250.21, -204.38,16000); - custodian_of_timeAI->AddWaypoint(2, -8374.93,-4250.21, -204.38,10000); - custodian_of_timeAI->AddWaypoint(3, -8374.93,-4250.21, -204.38,2000); - custodian_of_timeAI->AddWaypoint(4, -8439.40,-4180.05, -209.25); - custodian_of_timeAI->AddWaypoint(5, -8437.82,-4120.84, -208.59,10000); - custodian_of_timeAI->AddWaypoint(6, -8437.82,-4120.84, -208.59,16000); - custodian_of_timeAI->AddWaypoint(7, -8437.82,-4120.84, -208.59,13000); - custodian_of_timeAI->AddWaypoint(8, -8437.82,-4120.84, -208.59,18000); - custodian_of_timeAI->AddWaypoint(9, -8437.82,-4120.84, -208.59,15000); - custodian_of_timeAI->AddWaypoint(10, -8437.82,-4120.84, -208.59,2000); - custodian_of_timeAI->AddWaypoint(11, -8467.26,-4198.63, -214.21); - custodian_of_timeAI->AddWaypoint(12, -8667.76,-4252.13, -209.56); - custodian_of_timeAI->AddWaypoint(13, -8703.71,-4234.58, -209.5,14000); - custodian_of_timeAI->AddWaypoint(14, -8703.71,-4234.58, -209.5,2000); - custodian_of_timeAI->AddWaypoint(15, -8642.81,-4304.37, -209.57); - custodian_of_timeAI->AddWaypoint(16, -8649.06,-4394.36, -208.46,6000); - custodian_of_timeAI->AddWaypoint(17, -8649.06,-4394.36, -208.46,18000); - custodian_of_timeAI->AddWaypoint(18, -8649.06,-4394.36, -208.46,2000); - custodian_of_timeAI->AddWaypoint(19, -8468.72,-4437.67, -215.45); - custodian_of_timeAI->AddWaypoint(20, -8427.54,-4426, -211.13); - custodian_of_timeAI->AddWaypoint(21, -8364.83,-4393.32, -205.91); - custodian_of_timeAI->AddWaypoint(22, -8304.54,-4357.2, -208.2,18000); - custodian_of_timeAI->AddWaypoint(23, -8304.54,-4357.2, -208.2,2000); - custodian_of_timeAI->AddWaypoint(24, -8375.42,-4250.41, -205.14,5000); - custodian_of_timeAI->AddWaypoint(25, -8375.42,-4250.41, -205.14,5000); - - return (CreatureAI*)custodian_of_timeAI; -} - -/*###### -## npc_marin_noggenfogger -######*/ - -bool GossipHello_npc_marin_noggenfogger(Player *player, Creature *_Creature) -{ - if( _Creature->isQuestGiver() ) - player->PrepareQuestMenu( _Creature->GetGUID() ); - - if( _Creature->isVendor() && player->GetQuestRewardStatus(2662) ) - player->ADD_GOSSIP_ITEM(1, GOSSIP_TEXT_BROWSE_GOODS, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_TRADE); - - player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); - - return true; -} - -bool GossipSelect_npc_marin_noggenfogger(Player *player, Creature *_Creature, uint32 sender, uint32 action) -{ - if( action == GOSSIP_ACTION_TRADE ) - player->SEND_VENDORLIST( _Creature->GetGUID() ); - - return true; -} - -/*###### -## npc_steward_of_time -######*/ - -#define GOSSIP_ITEM_FLIGHT "Please take me to the master's lair." - -bool GossipHello_npc_steward_of_time(Player *player, Creature *_Creature) -{ - if( _Creature->isQuestGiver() ) - player->PrepareQuestMenu( _Creature->GetGUID() ); - - if( player->GetQuestStatus(10279) == QUEST_STATUS_INCOMPLETE || player->GetQuestRewardStatus(10279) ) - { - player->ADD_GOSSIP_ITEM(0, GOSSIP_ITEM_FLIGHT, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); - player->SEND_GOSSIP_MENU(9978,_Creature->GetGUID()); - } - else - player->SEND_GOSSIP_MENU(9977,_Creature->GetGUID()); - - return true; -} - -bool QuestAccept_npc_steward_of_time(Player *player, Creature *creature, Quest const *quest ) -{ - if( quest->GetQuestId() == 10279 ) //Quest: To The Master's Lair - player->CastSpell(player,34891,true); //(Flight through Caverns) - - return false; -} - -bool GossipSelect_npc_steward_of_time(Player *player, Creature *_Creature, uint32 sender, uint32 action ) -{ - if( action == GOSSIP_ACTION_INFO_DEF + 1 ) - player->CastSpell(player,34891,true); //(Flight through Caverns) - - return true; -} - -/*###### -## npc_stone_watcher_of_norgannon -######*/ - -#define GOSSIP_ITEM_NORGANNON_1 "What function do you serve?" -#define GOSSIP_ITEM_NORGANNON_2 "What are the Plates of Uldum?" -#define GOSSIP_ITEM_NORGANNON_3 "Where are the Plates of Uldum?" -#define GOSSIP_ITEM_NORGANNON_4 "Excuse me? We've been \"reschedueled for visitations\"? What does that mean?!" -#define GOSSIP_ITEM_NORGANNON_5 "So, what's inside Uldum?" -#define GOSSIP_ITEM_NORGANNON_6 "I will return when i have the Plates of Uldum." - -bool GossipHello_npc_stone_watcher_of_norgannon(Player *player, Creature *_Creature) -{ - if( _Creature->isQuestGiver() ) - player->PrepareQuestMenu( _Creature->GetGUID() ); - - if( player->GetQuestStatus(2954) == QUEST_STATUS_INCOMPLETE ) - player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM_NORGANNON_1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF); - - player->SEND_GOSSIP_MENU(1674, _Creature->GetGUID()); - - return true; -} - -bool GossipSelect_npc_stone_watcher_of_norgannon(Player *player, Creature *_Creature, uint32 sender, uint32 action) -{ - switch (action) - { - case GOSSIP_ACTION_INFO_DEF: - player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM_NORGANNON_2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); - player->SEND_GOSSIP_MENU(1675, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+1: - player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM_NORGANNON_3, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2); - player->SEND_GOSSIP_MENU(1676, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+2: - player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM_NORGANNON_4, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+3); - player->SEND_GOSSIP_MENU(1677, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+3: - player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM_NORGANNON_5, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+4); - player->SEND_GOSSIP_MENU(1678, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+4: - player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM_NORGANNON_6, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+5); - player->SEND_GOSSIP_MENU(1679, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+5: - player->CLOSE_GOSSIP_MENU(); - player->AreaExploredOrEventHappens(2954); - break; - } - return true; -} - -/*###### -## AddSC -######*/ - -void AddSC_tanaris() -{ - Script *newscript; - - newscript = new Script; - newscript->Name="mob_aquementas"; - newscript->GetAI = GetAI_mob_aquementas; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="npc_custodian_of_time"; - newscript->GetAI = GetAI_npc_custodian_of_time; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="npc_marin_noggenfogger"; - newscript->pGossipHello = &GossipHello_npc_marin_noggenfogger; - newscript->pGossipSelect = &GossipSelect_npc_marin_noggenfogger; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="npc_steward_of_time"; - newscript->pGossipHello = &GossipHello_npc_steward_of_time; - newscript->pGossipSelect = &GossipSelect_npc_steward_of_time; - newscript->pQuestAccept = &QuestAccept_npc_steward_of_time; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="npc_stone_watcher_of_norgannon"; - newscript->pGossipHello = &GossipHello_npc_stone_watcher_of_norgannon; - newscript->pGossipSelect = &GossipSelect_npc_stone_watcher_of_norgannon; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Tanaris +SD%Complete: 80 +SDComment: Quest support: 2954, 4005, 10277, 10279(Special flight path). Noggenfogger vendor +SDCategory: Tanaris +EndScriptData */ + +/* ContentData +mob_aquementas +npc_custodian_of_time +npc_marin_noggenfogger +npc_steward_of_time +npc_stone_watcher_of_norgannon +EndContentData */ + +#include "precompiled.h" +#include "../../npc/npc_escortAI.h" + +/*###### +## mob_aquementas +######*/ + +#define AGGRO_YELL_AQUE "Who dares awaken Aquementas?" + +#define SPELL_AQUA_JET 13586 +#define SPELL_FROST_SHOCK 15089 + +struct MANGOS_DLL_DECL mob_aquementasAI : public ScriptedAI +{ + mob_aquementasAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 SendItem_Timer; + uint32 SwitchFaction_Timer; + bool isFriendly; + + uint32 FrostShock_Timer; + uint32 AquaJet_Timer; + + void Reset() + { + SendItem_Timer = 0; + SwitchFaction_Timer = 10000; + m_creature->setFaction(35); + isFriendly = true; + + AquaJet_Timer = 5000; + FrostShock_Timer = 1000; + } + + void SendItem(Unit* receiver) + { + if (((Player*)receiver)->HasItemCount(11169,1,false) && + ((Player*)receiver)->HasItemCount(11172,11,false) && + ((Player*)receiver)->HasItemCount(11173,1,false) && + !((Player*)receiver)->HasItemCount(11522,1,true)) + { + ItemPosCountVec dest; + uint8 msg = ((Player*)receiver)->CanStoreNewItem( NULL_BAG, NULL_SLOT, dest, 11522, 1, false); + if( msg == EQUIP_ERR_OK ) + ((Player*)receiver)->StoreNewItem( dest, 11522, 1, true); + } + } + + void Aggro(Unit* who) + { + DoYell(AGGRO_YELL_AQUE,LANG_UNIVERSAL,who); + } + + void UpdateAI(const uint32 diff) + { + if( isFriendly ) + { + if( SwitchFaction_Timer < diff ) + { + m_creature->setFaction(91); + isFriendly = false; + }else SwitchFaction_Timer -= diff; + } + + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + if( !isFriendly ) + { + if( SendItem_Timer < diff ) + { + if( m_creature->getVictim()->GetTypeId() == TYPEID_PLAYER ) + SendItem(m_creature->getVictim()); + SendItem_Timer = 5000; + }else SendItem_Timer -= diff; + } + + if( FrostShock_Timer < diff ) + { + DoCast(m_creature->getVictim(),SPELL_FROST_SHOCK); + FrostShock_Timer = 15000; + }else FrostShock_Timer -= diff; + + if( AquaJet_Timer < diff ) + { + DoCast(m_creature,SPELL_AQUA_JET); + AquaJet_Timer = 15000; + }else AquaJet_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; +CreatureAI* GetAI_mob_aquementas(Creature *_Creature) +{ + return new mob_aquementasAI (_Creature); +} + +/*###### +## npc_custodian_of_time +######*/ + +#define WHISPER_CUSTODIAN_1 "Greetings, $N. I will guide you through the cavern. Please try and keep up." +#define WHISPER_CUSTODIAN_2 "We do not know if the Caverns of Time have always been accessible to mortals. Truly, it is impossible to tell as the Timeless One is in perpetual motion, changing our timeways as he sees fit. What you see now may very well not exist tomorrow. You may wake up and have no memory of this place." +#define WHISPER_CUSTODIAN_3 "It is strange, I know... Most mortals cannot actually comprehend what they see here, as often, what they see is not anchored within their own perception of reality." +#define WHISPER_CUSTODIAN_4 "Follow me, please." +#define WHISPER_CUSTODIAN_5 "There are only two truths to be found here: First, that time is chaotic, always in flux, and completely malleable and second, perception does not dictate reality." +#define WHISPER_CUSTODIAN_6 "As custodians of time, we watch over and care for Nozdormu's realm. The master is away at the moment, which means that attempts are being made to dramatically alter time. The master never meddles in the affairs of mortals but instead corrects the alterations made to time by others. He is reactionary in this regard." +#define WHISPER_CUSTODIAN_7 "For normal maintenance of time, the Keepers of Time are sufficient caretakers. We are able to deal with most ordinary disturbances. I speak of little things, such as rogue mages changing something in the past to elevate their status or wealth in the present." +#define WHISPER_CUSTODIAN_8 "These tunnels that you see are called timeways. They are infinite in number. The ones that currently exist in your reality are what the master has deemed as 'trouble spots.' These trouble spots may differ completely in theme but they always share a cause. That is, their existence is a result of the same temporal disturbance. Remember that should you venture inside one..." +#define WHISPER_CUSTODIAN_9 "This timeway is in great disarray! We have agents inside right now attempting to restore order. What information I have indicates that Thrall's freedom is in jeopardy. A malevolent organization known as the Infinite Dragonflight is trying to prevent his escape. I fear without outside assistance, all will be lost." +#define WHISPER_CUSTODIAN_10 "We have very little information on this timeway. Sa'at has been dispatched and is currently inside. The data we have gathered from his correspondence is that the Infinite Dragonflight are once again attempting to alter time. Could it be that the opening of the Dark Portal is being targeted for sabotage? Let us hope not..." +#define WHISPER_CUSTODIAN_11 "This timeway is currently collapsing. What that may hold for the past, present and future is currently unknown..." +#define WHISPER_CUSTODIAN_12 "The timeways are currently ranked in order from least catastrophic to most catastrophic. Note that they are all classified as catastrophic, meaning that any single one of these timeways collapsing would mean that your world would end. We only classify them in such a way so that the heroes and adventurers that are sent here know which timeway best suits their abilities." +#define WHISPER_CUSTODIAN_13 "All we know of this timeway is that it leads to Mount Hyjal. The Infinite Dragonflight have gone to great lengths to prevent our involvement. We know next to nothing, mortal. Soridormi is currently attempting to break through the timeway's defenses but has thus far been unsuccessful. You might be our only hope of breaking through and resolving the conflict." +#define WHISPER_CUSTODIAN_14 "Our time is at an end $N. I would wish you luck, if such a thing existed." + +struct MANGOS_DLL_DECL npc_custodian_of_timeAI : public npc_escortAI +{ + npc_custodian_of_timeAI(Creature *c) : npc_escortAI(c) { Reset(); } + + void WaypointReached(uint32 i) + { + Unit *pTemp = Unit::GetUnit(*m_creature,PlayerGUID); + if( !pTemp ) + return; + + switch( i ) + { + case 0: DoWhisper(WHISPER_CUSTODIAN_1, pTemp); break; + case 1: DoWhisper(WHISPER_CUSTODIAN_2, pTemp); break; + case 2: DoWhisper(WHISPER_CUSTODIAN_3, pTemp); break; + case 3: DoWhisper(WHISPER_CUSTODIAN_4, pTemp); break; + case 5: DoWhisper(WHISPER_CUSTODIAN_5, pTemp); break; + case 6: DoWhisper(WHISPER_CUSTODIAN_6, pTemp); break; + case 7: DoWhisper(WHISPER_CUSTODIAN_7, pTemp); break; + case 8: DoWhisper(WHISPER_CUSTODIAN_8, pTemp); break; + case 9: DoWhisper(WHISPER_CUSTODIAN_9, pTemp); break; + case 10: DoWhisper(WHISPER_CUSTODIAN_4, pTemp); break; + case 13: DoWhisper(WHISPER_CUSTODIAN_10, pTemp); break; + case 14: DoWhisper(WHISPER_CUSTODIAN_4, pTemp); break; + case 16: DoWhisper(WHISPER_CUSTODIAN_11, pTemp); break; + case 17: DoWhisper(WHISPER_CUSTODIAN_12, pTemp); break; + case 18: DoWhisper(WHISPER_CUSTODIAN_4, pTemp); break; + case 22: DoWhisper(WHISPER_CUSTODIAN_13, pTemp); break; + case 23: DoWhisper(WHISPER_CUSTODIAN_4, pTemp); break; + case 24: + DoWhisper(WHISPER_CUSTODIAN_14, pTemp); + DoCast(pTemp,34883); + //below here is temporary workaround, to be removed when spell works properly + ((Player*)pTemp)->AreaExploredOrEventHappens(10277); + break; + } + } + + void MoveInLineOfSight(Unit *who) + { + if( IsBeingEscorted ) + return; + + if( who->GetTypeId() == TYPEID_PLAYER ) + { + if( ((Player*)who)->HasAura(34877,1) && ((Player*)who)->GetQuestStatus(10277) == QUEST_STATUS_INCOMPLETE ) + { + float Radius = 10.0; + if( m_creature->IsWithinDistInMap(who, Radius) ) + { + ((npc_escortAI*)(m_creature->AI()))->Start(false, false, false, who->GetGUID()); + } + } + } + } + + void Aggro(Unit* who) { } + void Reset() { } + + void UpdateAI(const uint32 diff) + { + npc_escortAI::UpdateAI(diff); + } +}; + +CreatureAI* GetAI_npc_custodian_of_time(Creature *_Creature) +{ + npc_custodian_of_timeAI* custodian_of_timeAI = new npc_custodian_of_timeAI(_Creature); + + custodian_of_timeAI->AddWaypoint(0, -8374.93,-4250.21, -204.38,5000); + custodian_of_timeAI->AddWaypoint(1, -8374.93,-4250.21, -204.38,16000); + custodian_of_timeAI->AddWaypoint(2, -8374.93,-4250.21, -204.38,10000); + custodian_of_timeAI->AddWaypoint(3, -8374.93,-4250.21, -204.38,2000); + custodian_of_timeAI->AddWaypoint(4, -8439.40,-4180.05, -209.25); + custodian_of_timeAI->AddWaypoint(5, -8437.82,-4120.84, -208.59,10000); + custodian_of_timeAI->AddWaypoint(6, -8437.82,-4120.84, -208.59,16000); + custodian_of_timeAI->AddWaypoint(7, -8437.82,-4120.84, -208.59,13000); + custodian_of_timeAI->AddWaypoint(8, -8437.82,-4120.84, -208.59,18000); + custodian_of_timeAI->AddWaypoint(9, -8437.82,-4120.84, -208.59,15000); + custodian_of_timeAI->AddWaypoint(10, -8437.82,-4120.84, -208.59,2000); + custodian_of_timeAI->AddWaypoint(11, -8467.26,-4198.63, -214.21); + custodian_of_timeAI->AddWaypoint(12, -8667.76,-4252.13, -209.56); + custodian_of_timeAI->AddWaypoint(13, -8703.71,-4234.58, -209.5,14000); + custodian_of_timeAI->AddWaypoint(14, -8703.71,-4234.58, -209.5,2000); + custodian_of_timeAI->AddWaypoint(15, -8642.81,-4304.37, -209.57); + custodian_of_timeAI->AddWaypoint(16, -8649.06,-4394.36, -208.46,6000); + custodian_of_timeAI->AddWaypoint(17, -8649.06,-4394.36, -208.46,18000); + custodian_of_timeAI->AddWaypoint(18, -8649.06,-4394.36, -208.46,2000); + custodian_of_timeAI->AddWaypoint(19, -8468.72,-4437.67, -215.45); + custodian_of_timeAI->AddWaypoint(20, -8427.54,-4426, -211.13); + custodian_of_timeAI->AddWaypoint(21, -8364.83,-4393.32, -205.91); + custodian_of_timeAI->AddWaypoint(22, -8304.54,-4357.2, -208.2,18000); + custodian_of_timeAI->AddWaypoint(23, -8304.54,-4357.2, -208.2,2000); + custodian_of_timeAI->AddWaypoint(24, -8375.42,-4250.41, -205.14,5000); + custodian_of_timeAI->AddWaypoint(25, -8375.42,-4250.41, -205.14,5000); + + return (CreatureAI*)custodian_of_timeAI; +} + +/*###### +## npc_marin_noggenfogger +######*/ + +bool GossipHello_npc_marin_noggenfogger(Player *player, Creature *_Creature) +{ + if( _Creature->isQuestGiver() ) + player->PrepareQuestMenu( _Creature->GetGUID() ); + + if( _Creature->isVendor() && player->GetQuestRewardStatus(2662) ) + player->ADD_GOSSIP_ITEM(1, GOSSIP_TEXT_BROWSE_GOODS, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_TRADE); + + player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); + + return true; +} + +bool GossipSelect_npc_marin_noggenfogger(Player *player, Creature *_Creature, uint32 sender, uint32 action) +{ + if( action == GOSSIP_ACTION_TRADE ) + player->SEND_VENDORLIST( _Creature->GetGUID() ); + + return true; +} + +/*###### +## npc_steward_of_time +######*/ + +#define GOSSIP_ITEM_FLIGHT "Please take me to the master's lair." + +bool GossipHello_npc_steward_of_time(Player *player, Creature *_Creature) +{ + if( _Creature->isQuestGiver() ) + player->PrepareQuestMenu( _Creature->GetGUID() ); + + if( player->GetQuestStatus(10279) == QUEST_STATUS_INCOMPLETE || player->GetQuestRewardStatus(10279) ) + { + player->ADD_GOSSIP_ITEM(0, GOSSIP_ITEM_FLIGHT, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); + player->SEND_GOSSIP_MENU(9978,_Creature->GetGUID()); + } + else + player->SEND_GOSSIP_MENU(9977,_Creature->GetGUID()); + + return true; +} + +bool QuestAccept_npc_steward_of_time(Player *player, Creature *creature, Quest const *quest ) +{ + if( quest->GetQuestId() == 10279 ) //Quest: To The Master's Lair + player->CastSpell(player,34891,true); //(Flight through Caverns) + + return false; +} + +bool GossipSelect_npc_steward_of_time(Player *player, Creature *_Creature, uint32 sender, uint32 action ) +{ + if( action == GOSSIP_ACTION_INFO_DEF + 1 ) + player->CastSpell(player,34891,true); //(Flight through Caverns) + + return true; +} + +/*###### +## npc_stone_watcher_of_norgannon +######*/ + +#define GOSSIP_ITEM_NORGANNON_1 "What function do you serve?" +#define GOSSIP_ITEM_NORGANNON_2 "What are the Plates of Uldum?" +#define GOSSIP_ITEM_NORGANNON_3 "Where are the Plates of Uldum?" +#define GOSSIP_ITEM_NORGANNON_4 "Excuse me? We've been \"reschedueled for visitations\"? What does that mean?!" +#define GOSSIP_ITEM_NORGANNON_5 "So, what's inside Uldum?" +#define GOSSIP_ITEM_NORGANNON_6 "I will return when i have the Plates of Uldum." + +bool GossipHello_npc_stone_watcher_of_norgannon(Player *player, Creature *_Creature) +{ + if( _Creature->isQuestGiver() ) + player->PrepareQuestMenu( _Creature->GetGUID() ); + + if( player->GetQuestStatus(2954) == QUEST_STATUS_INCOMPLETE ) + player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM_NORGANNON_1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF); + + player->SEND_GOSSIP_MENU(1674, _Creature->GetGUID()); + + return true; +} + +bool GossipSelect_npc_stone_watcher_of_norgannon(Player *player, Creature *_Creature, uint32 sender, uint32 action) +{ + switch (action) + { + case GOSSIP_ACTION_INFO_DEF: + player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM_NORGANNON_2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); + player->SEND_GOSSIP_MENU(1675, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+1: + player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM_NORGANNON_3, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2); + player->SEND_GOSSIP_MENU(1676, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+2: + player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM_NORGANNON_4, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+3); + player->SEND_GOSSIP_MENU(1677, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+3: + player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM_NORGANNON_5, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+4); + player->SEND_GOSSIP_MENU(1678, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+4: + player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM_NORGANNON_6, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+5); + player->SEND_GOSSIP_MENU(1679, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+5: + player->CLOSE_GOSSIP_MENU(); + player->AreaExploredOrEventHappens(2954); + break; + } + return true; +} + +/*###### +## AddSC +######*/ + +void AddSC_tanaris() +{ + Script *newscript; + + newscript = new Script; + newscript->Name="mob_aquementas"; + newscript->GetAI = GetAI_mob_aquementas; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="npc_custodian_of_time"; + newscript->GetAI = GetAI_npc_custodian_of_time; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="npc_marin_noggenfogger"; + newscript->pGossipHello = &GossipHello_npc_marin_noggenfogger; + newscript->pGossipSelect = &GossipSelect_npc_marin_noggenfogger; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="npc_steward_of_time"; + newscript->pGossipHello = &GossipHello_npc_steward_of_time; + newscript->pGossipSelect = &GossipSelect_npc_steward_of_time; + newscript->pQuestAccept = &QuestAccept_npc_steward_of_time; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="npc_stone_watcher_of_norgannon"; + newscript->pGossipHello = &GossipHello_npc_stone_watcher_of_norgannon; + newscript->pGossipSelect = &GossipSelect_npc_stone_watcher_of_norgannon; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/tempest_keep/arcatraz/arcatraz.cpp b/src/bindings/scripts/scripts/zone/tempest_keep/arcatraz/arcatraz.cpp index abff86b24dd..4be37887e3d 100644 --- a/src/bindings/scripts/scripts/zone/tempest_keep/arcatraz/arcatraz.cpp +++ b/src/bindings/scripts/scripts/zone/tempest_keep/arcatraz/arcatraz.cpp @@ -1,612 +1,612 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Arcatraz -SD%Complete: 60 -SDComment: Warden Mellichar, event controller for Skyriss event. Millhouse Manastorm. TODO: make better combatAI for Millhouse. -SDCategory: Tempest Keep, The Arcatraz -EndScriptData */ - -/* ContentData -npc_millhouse_manastorm -npc_warden_mellichar -mob_zerekethvoidzone -EndContentData */ - -#include "precompiled.h" -#include "def_arcatraz.h" - -/*##### -# npc_millhouse_manastorm -#####*/ - -#define SAY_INTRO_1 "Where in Bonzo's brass buttons am I? And who are-- yaaghh, that's one mother of a headache!" -#define SOUND_INTRO_1 11171 -#define SAY_INTRO_2 "\"Lowly\"? I don't care who you are friend, no one refers to the mighty Millhouse Manastorm as \"Lowly\"! I have no idea what goes on here, but I will gladly join your fight against this impudent imbecile! Prepare to defend yourself, cretin!" -#define SOUND_INTRO_2 11172 - -#define SAY_WATER "I just need to get some things ready first. You guys go ahead and get started. I need to summon up some water..." -#define SOUND_WATER 11173 - -#define SAY_BUFFS "Fantastic! Next, some protective spells. Yes! Now we're cookin'" -#define SOUND_BUFFS 11174 - -#define SAY_DRINK "And of course i'll need some mana. You guys are gonna love this, just wait." -#define SOUND_DRINK 11175 - -#define SAY_READY "Aaalllriiiight!! Who ordered up an extra large can of whoop-ass?" -#define SOUND_READY 11176 - -#define SAY_KILL_1 "I didn't even break a sweat on that one." -#define SOUND_KILL_1 11177 -#define SAY_KILL_2 "You guys, feel free to jump in anytime." -#define SOUND_KILL_2 11178 - -#define SAY_PYRO "I'm gonna light you up, sweet cheeks!" -#define SOUND_PYRO 11179 - -#define SAY_ICEBLOCK "Ice, ice, baby!" -#define SOUND_ICEBLOCK 11180 - -#define SAY_LOWHP "Heal me! Oh, for the love of all that is holy, HEAL me! I'm dying!" -#define SOUND_LOWHP 11181 - -#define SAY_DEATH "You'll be hearing from my lawyer..." -#define SOUND_DEATH 11182 - -#define SAY_COMPLETE "Who's bad? Who's bad? That's right: we bad!" -#define SOUND_COMPLETE 11183 - -#define SPELL_CONJURE_WATER 36879 -#define SPELL_ARCANE_INTELLECT 36880 -#define SPELL_ICE_ARMOR 36881 - -#define SPELL_ARCANE_MISSILES 33833 -#define SPELL_CONE_OF_COLD 12611 -#define SPELL_FIRE_BLAST 13341 -#define SPELL_FIREBALL 14034 -#define SPELL_FROSTBOLT 15497 -#define SPELL_PYROBLAST 33975 - -struct MANGOS_DLL_DECL npc_millhouse_manastormAI : public ScriptedAI -{ - npc_millhouse_manastormAI(Creature *c) : ScriptedAI(c) - { - pInstance = ((ScriptedInstance*)c->GetInstanceData()); - Reset(); - } - - ScriptedInstance* pInstance; - - uint32 EventProgress_Timer; - uint32 Phase; - bool Init; - bool LowHp; - - uint32 Pyroblast_Timer; - uint32 Fireball_Timer; - - void Reset() - { - EventProgress_Timer = 2000; - LowHp = false; - Init = false; - Phase = 1; - - Pyroblast_Timer = 1000; - Fireball_Timer = 2500; - - if( pInstance ) - { - if( pInstance->GetData(TYPE_WARDEN_2) == DONE ) - Init = true; - - if( pInstance->GetData(TYPE_HARBINGERSKYRISS) == DONE ) - { - DoYell(SAY_COMPLETE,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_COMPLETE); - } - } - } - - void MoveInLineOfSight(Unit *who) - { - if( !m_creature->getVictim() && who->isTargetableForAttack() && ( m_creature->IsHostileTo( who )) && who->isInAccessablePlaceFor(m_creature) ) - { - if (m_creature->GetDistanceZ(who) > CREATURE_Z_ATTACK_RANGE) - return; - - float attackRadius = m_creature->GetAttackDistance(who); - if( m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->IsWithinLOSInMap(who) ) - { - DoStartAttackNoMovement(who); - who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); - - if (!InCombat) - { - Aggro(who); - InCombat = true; - } - } - } - } - - void AttackStart(Unit* who) - { - if (who->isTargetableForAttack()) - { - DoStartAttackNoMovement(who); - - if (!InCombat) - { - Aggro(who); - InCombat = true; - } - } - } - - void Aggro(Unit *who) - { - } - - void KilledUnit(Unit *victim) - { - switch(rand()%2) - { - case 0: - DoYell(SAY_KILL_1,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_KILL_1); - break; - case 1: - DoYell(SAY_KILL_2,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_KILL_2); - break; - } - } - - void JustDied(Unit *victim) - { - DoYell(SAY_DEATH,LANG_UNIVERSAL,0); - DoPlaySoundToSet(m_creature,SOUND_DEATH); - - /*for questId 10886 (heroic mode only) - if( pInstance && pInstance->GetData(TYPE_HARBINGERSKYRISS) != DONE ) - ->FailQuest();*/ - } - - void UpdateAI(const uint32 diff) - { - if( !Init ) - { - if( EventProgress_Timer < diff ) - { - if( Phase < 8 ) - { - switch( Phase ) - { - case 1: - DoYell(SAY_INTRO_1,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_INTRO_1); - EventProgress_Timer = 18000; - break; - case 2: - DoYell(SAY_INTRO_2,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_INTRO_2); - EventProgress_Timer = 18000; - break; - case 3: - DoYell(SAY_WATER,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_WATER); - DoCast(m_creature,SPELL_CONJURE_WATER); - EventProgress_Timer = 7000; - break; - case 4: - DoYell(SAY_BUFFS,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_BUFFS); - DoCast(m_creature,SPELL_ICE_ARMOR); - EventProgress_Timer = 7000; - break; - case 5: - DoYell(SAY_DRINK,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_DRINK); - DoCast(m_creature,SPELL_ARCANE_INTELLECT); - EventProgress_Timer = 7000; - break; - case 6: - DoYell(SAY_READY,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_READY); - EventProgress_Timer = 6000; - break; - case 7: - if( pInstance ) - pInstance->SetData(TYPE_WARDEN_2,DONE); - Init = true; - break; - } - ++Phase; - } - } else EventProgress_Timer -= diff; - } - - if( !m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - if( !LowHp && ((m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < 20) ) - { - DoYell(SAY_LOWHP,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_LOWHP); - LowHp = true; - } - - if( Pyroblast_Timer < diff ) - { - if( m_creature->IsNonMeleeSpellCasted(false) ) - return; - - DoYell(SAY_PYRO,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_PYRO); - - DoCast(m_creature->getVictim(),SPELL_PYROBLAST); - Pyroblast_Timer = 40000; - }else Pyroblast_Timer -=diff; - - if( Fireball_Timer < diff ) - { - DoCast(m_creature->getVictim(),SPELL_FIREBALL); - Fireball_Timer = 4000; - }else Fireball_Timer -=diff; - - DoMeleeAttackIfReady(); - } -}; - -CreatureAI* GetAI_npc_millhouse_manastorm(Creature *_Creature) -{ - return new npc_millhouse_manastormAI (_Creature); -} - -/*##### -# npc_warden_mellichar -#####*/ - -#define YELL_INTRO1 "I knew the prince would be angry but, I... I have not been myself. I had to let them out! The great one speaks to me, you see. Wait--outsiders. Kael'thas did not send you! Good... I'll just tell the prince you released the prisoners!" -#define SOUND_INTRO1 11222 - -#define YELL_INTRO2 "The naaru kept some of the most dangerous beings in existence here in these cells. Let me introduce you to another...." -#define SOUND_INTRO2 11223 - -#define YELL_RELEASE1 "Yes, yes... another! Your will is mine!" -#define SOUND_RELEASE1 11224 - -#define YELL_RELEASE2A "Behold another terrifying creature of incomprehensible power!" -#define SOUND_RELEASE2A 11225 -#define YELL_RELEASE2B "What is this? A lowly gnome? I will do better, O'great one." -#define SOUND_RELEASE2B 11226 - -#define YELL_RELEASE3 "Anarchy! Bedlam! Oh, you are so wise! Yes, I see it now, of course!" -#define SOUND_RELEASE3 11227 - -#define YELL_RELEASE4 "One final cell remains. Yes, O'great one, right away!" -#define SOUND_RELEASE4 11228 - -#define YELL_WELCOME "Welcome, O'great one. I am your humble servant." -#define SOUND_WELCOME 11229 - -//phase 2(acid mobs) -#define ENTRY_TRICKSTER 20905 -#define ENTRY_PH_HUNTER 20906 -//phase 3 -#define ENTRY_MILLHOUSE 20977 -//phase 4(acid mobs) -#define ENTRY_AKKIRIS 20908 -#define ENTRY_SULFURON 20909 -//phase 5(acid mobs) -#define ENTRY_TW_DRAK 20910 -#define ENTRY_BL_DRAK 20911 -//phase 6 -#define ENTRY_SKYRISS 20912 - -//TARGET_SCRIPT -#define SPELL_TARGET_ALPHA 36856 -#define SPELL_TARGET_BETA 36854 -#define SPELL_TARGET_DELTA 36857 -#define SPELL_TARGET_GAMMA 36858 -#define SPELL_TARGET_OMEGA 36852 -#define SPELL_BUBBLE_VISUAL 36849 - -struct MANGOS_DLL_DECL npc_warden_mellicharAI : public ScriptedAI -{ - npc_warden_mellicharAI(Creature *c) : ScriptedAI(c) - { - pInstance = ((ScriptedInstance*)c->GetInstanceData()); - Reset(); - } - - ScriptedInstance* pInstance; - - bool IsRunning; - bool CanSpawn; - - uint32 EventProgress_Timer; - uint32 Phase; - - void Reset() - { - IsRunning = false; - CanSpawn = false; - - EventProgress_Timer = 22000; - Phase = 1; - - m_creature->SetFlag(UNIT_FIELD_FLAGS,UNIT_FLAG_NON_ATTACKABLE); - DoCast(m_creature,SPELL_TARGET_OMEGA); - - if( pInstance ) - pInstance->SetData(TYPE_HARBINGERSKYRISS,NOT_STARTED); - } - - void AttackStart(Unit* who) { } - - void MoveInLineOfSight(Unit *who) - { - if( IsRunning ) - return; - - if( !m_creature->getVictim() && who->isTargetableForAttack() && ( m_creature->IsHostileTo( who )) && who->isInAccessablePlaceFor(m_creature) ) - { - if (m_creature->GetDistanceZ(who) > CREATURE_Z_ATTACK_RANGE) - return; - if (who->GetTypeId() != TYPEID_PLAYER) - return; - - float attackRadius = m_creature->GetAttackDistance(who)/10; - if( m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->IsWithinLOSInMap(who) ) - Aggro(who); - } - } - - void Aggro(Unit *who) - { - DoYell(YELL_INTRO1,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_INTRO1); - //possibly wrong spell OR should also cast second spell to make bubble appear (visual for this spell appear to be the correct) - DoCast(m_creature,SPELL_BUBBLE_VISUAL); - - if( pInstance ) - { - pInstance->SetData(TYPE_HARBINGERSKYRISS,IN_PROGRESS); - IsRunning = true; - } - } - - uint32 CanProgress() - { - if( pInstance ) - { - if( Phase == 7 && pInstance->GetData(TYPE_WARDEN_4) == DONE ) - return true; - if( Phase == 6 && pInstance->GetData(TYPE_WARDEN_3) == DONE ) - return true; - if( Phase == 5 && pInstance->GetData(TYPE_WARDEN_2) == DONE ) - return true; - if( Phase == 4 ) - return true; - if( Phase == 3 && pInstance->GetData(TYPE_WARDEN_1) == DONE ) - return true; - if( Phase == 2 && pInstance->GetData(TYPE_HARBINGERSKYRISS) == IN_PROGRESS ) - return true; - if( Phase == 1 && pInstance->GetData(TYPE_HARBINGERSKYRISS) == IN_PROGRESS ) - return true; - return false; - } - return false; - } - - void DoPrepareForPhase() - { - if( pInstance ) - { - m_creature->InterruptNonMeleeSpells(true); - m_creature->RemoveSpellsCausingAura(SPELL_AURA_DUMMY); - - switch( Phase ) - { - case 2: - DoCast(m_creature,SPELL_TARGET_ALPHA); - pInstance->SetData(TYPE_WARDEN_1,IN_PROGRESS); - break; - case 3: - DoCast(m_creature,SPELL_TARGET_BETA); - pInstance->SetData(TYPE_WARDEN_2,IN_PROGRESS); - break; - case 5: - DoCast(m_creature,SPELL_TARGET_DELTA); - pInstance->SetData(TYPE_WARDEN_3,IN_PROGRESS); - break; - case 6: - DoCast(m_creature,SPELL_TARGET_GAMMA); - pInstance->SetData(TYPE_WARDEN_4,IN_PROGRESS); - break; - case 7: - pInstance->SetData(TYPE_WARDEN_5,IN_PROGRESS); - break; - default: - break; - } - CanSpawn = true; - } - } - - void UpdateAI(const uint32 diff) - { - if( !IsRunning ) - return; - - if( EventProgress_Timer < diff ) - { - if( pInstance ) - { - if( pInstance->GetData(TYPE_HARBINGERSKYRISS) == FAIL ) - Reset(); - } - - if( CanSpawn ) - { - //continue beam omega pod, unless we are about to summon skyriss - if( Phase != 7 ) - DoCast(m_creature,SPELL_TARGET_OMEGA); - - switch( Phase ) - { - case 2: - switch( rand()%2 ) - { - case 0: m_creature->SummonCreature(ENTRY_TRICKSTER,478.326,-148.505,42.56,3.19,TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,600000); break; - case 1: m_creature->SummonCreature(ENTRY_PH_HUNTER,478.326,-148.505,42.56,3.19,TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,600000); break; - } - break; - case 3: - m_creature->SummonCreature(ENTRY_MILLHOUSE,413.292,-148.378,42.56,6.27,TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,600000); - break; - case 4: - DoYell(YELL_RELEASE2B,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_RELEASE2B); - break; - case 5: - switch( rand()%2 ) - { - case 0: m_creature->SummonCreature(ENTRY_AKKIRIS,420.179,-174.396,42.58,0.02,TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,600000); break; - case 1: m_creature->SummonCreature(ENTRY_SULFURON,420.179,-174.396,42.58,0.02,TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,600000); break; - } - break; - case 6: - switch( rand()%2 ) - { - case 0: m_creature->SummonCreature(ENTRY_TW_DRAK,471.795,-174.58,42.58,3.06,TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,600000); break; - case 1: m_creature->SummonCreature(ENTRY_BL_DRAK,471.795,-174.58,42.58,3.06,TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,600000); break; - } - break; - case 7: - m_creature->SummonCreature(ENTRY_SKYRISS,445.763,-191.639,44.64,1.60,TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,600000); - DoYell(YELL_WELCOME,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_WELCOME); - break; - default: - break; - } - CanSpawn = false; - ++Phase; - } - if( CanProgress() ) - { - switch( Phase ) - { - case 1: - DoYell(YELL_INTRO2,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_INTRO2); - EventProgress_Timer = 10000; - ++Phase; - break; - case 2: - DoYell(YELL_RELEASE1,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_RELEASE1); - DoPrepareForPhase(); - EventProgress_Timer = 7000; - break; - case 3: - DoYell(YELL_RELEASE2A,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_RELEASE2A); - DoPrepareForPhase(); - EventProgress_Timer = 10000; - break; - case 4: - DoPrepareForPhase(); - EventProgress_Timer = 15000; - break; - case 5: - DoYell(YELL_RELEASE3,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_RELEASE3); - DoPrepareForPhase(); - EventProgress_Timer = 15000; - break; - case 6: - DoYell(YELL_RELEASE4,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_RELEASE4); - DoPrepareForPhase(); - EventProgress_Timer = 15000; - break; - case 7: - DoPrepareForPhase(); - EventProgress_Timer = 15000; - break; - default: - break; - } - } - } else EventProgress_Timer -= diff; - } -}; -CreatureAI* GetAI_npc_warden_mellichar(Creature *_Creature) -{ - return new npc_warden_mellicharAI (_Creature); -} - -/*##### -# mob_zerekethvoidzone (this script probably not needed in future -> `creature_template_addon`.`auras`='36120 0') -#####*/ - -#define SPELL_VOID_ZONE_DAMAGE 36120 - -struct MANGOS_DLL_DECL mob_zerekethvoidzoneAI : public ScriptedAI -{ - mob_zerekethvoidzoneAI(Creature *c) : ScriptedAI(c) {Reset();} - - void Reset() - { - m_creature->SetUInt32Value(UNIT_NPC_FLAGS,0); - m_creature->setFaction(16); - m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - - DoCast(m_creature,SPELL_VOID_ZONE_DAMAGE); - } - - void Aggro(Unit* who) {} -}; -CreatureAI* GetAI_mob_zerekethvoidzoneAI(Creature *_Creature) -{ - return new mob_zerekethvoidzoneAI (_Creature); -} - -void AddSC_arcatraz() -{ - Script *newscript; - - newscript = new Script; - newscript->Name="npc_millhouse_manastorm"; - newscript->GetAI = GetAI_npc_millhouse_manastorm; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="npc_warden_mellichar"; - newscript->GetAI = GetAI_npc_warden_mellichar; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="mob_zerekethvoidzone"; - newscript->GetAI = GetAI_mob_zerekethvoidzoneAI; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Arcatraz +SD%Complete: 60 +SDComment: Warden Mellichar, event controller for Skyriss event. Millhouse Manastorm. TODO: make better combatAI for Millhouse. +SDCategory: Tempest Keep, The Arcatraz +EndScriptData */ + +/* ContentData +npc_millhouse_manastorm +npc_warden_mellichar +mob_zerekethvoidzone +EndContentData */ + +#include "precompiled.h" +#include "def_arcatraz.h" + +/*##### +# npc_millhouse_manastorm +#####*/ + +#define SAY_INTRO_1 "Where in Bonzo's brass buttons am I? And who are-- yaaghh, that's one mother of a headache!" +#define SOUND_INTRO_1 11171 +#define SAY_INTRO_2 "\"Lowly\"? I don't care who you are friend, no one refers to the mighty Millhouse Manastorm as \"Lowly\"! I have no idea what goes on here, but I will gladly join your fight against this impudent imbecile! Prepare to defend yourself, cretin!" +#define SOUND_INTRO_2 11172 + +#define SAY_WATER "I just need to get some things ready first. You guys go ahead and get started. I need to summon up some water..." +#define SOUND_WATER 11173 + +#define SAY_BUFFS "Fantastic! Next, some protective spells. Yes! Now we're cookin'" +#define SOUND_BUFFS 11174 + +#define SAY_DRINK "And of course i'll need some mana. You guys are gonna love this, just wait." +#define SOUND_DRINK 11175 + +#define SAY_READY "Aaalllriiiight!! Who ordered up an extra large can of whoop-ass?" +#define SOUND_READY 11176 + +#define SAY_KILL_1 "I didn't even break a sweat on that one." +#define SOUND_KILL_1 11177 +#define SAY_KILL_2 "You guys, feel free to jump in anytime." +#define SOUND_KILL_2 11178 + +#define SAY_PYRO "I'm gonna light you up, sweet cheeks!" +#define SOUND_PYRO 11179 + +#define SAY_ICEBLOCK "Ice, ice, baby!" +#define SOUND_ICEBLOCK 11180 + +#define SAY_LOWHP "Heal me! Oh, for the love of all that is holy, HEAL me! I'm dying!" +#define SOUND_LOWHP 11181 + +#define SAY_DEATH "You'll be hearing from my lawyer..." +#define SOUND_DEATH 11182 + +#define SAY_COMPLETE "Who's bad? Who's bad? That's right: we bad!" +#define SOUND_COMPLETE 11183 + +#define SPELL_CONJURE_WATER 36879 +#define SPELL_ARCANE_INTELLECT 36880 +#define SPELL_ICE_ARMOR 36881 + +#define SPELL_ARCANE_MISSILES 33833 +#define SPELL_CONE_OF_COLD 12611 +#define SPELL_FIRE_BLAST 13341 +#define SPELL_FIREBALL 14034 +#define SPELL_FROSTBOLT 15497 +#define SPELL_PYROBLAST 33975 + +struct MANGOS_DLL_DECL npc_millhouse_manastormAI : public ScriptedAI +{ + npc_millhouse_manastormAI(Creature *c) : ScriptedAI(c) + { + pInstance = ((ScriptedInstance*)c->GetInstanceData()); + Reset(); + } + + ScriptedInstance* pInstance; + + uint32 EventProgress_Timer; + uint32 Phase; + bool Init; + bool LowHp; + + uint32 Pyroblast_Timer; + uint32 Fireball_Timer; + + void Reset() + { + EventProgress_Timer = 2000; + LowHp = false; + Init = false; + Phase = 1; + + Pyroblast_Timer = 1000; + Fireball_Timer = 2500; + + if( pInstance ) + { + if( pInstance->GetData(TYPE_WARDEN_2) == DONE ) + Init = true; + + if( pInstance->GetData(TYPE_HARBINGERSKYRISS) == DONE ) + { + DoYell(SAY_COMPLETE,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_COMPLETE); + } + } + } + + void MoveInLineOfSight(Unit *who) + { + if( !m_creature->getVictim() && who->isTargetableForAttack() && ( m_creature->IsHostileTo( who )) && who->isInAccessablePlaceFor(m_creature) ) + { + if (!m_creature->canFly() && m_creature->GetDistanceZ(who) > CREATURE_Z_ATTACK_RANGE) + return; + + float attackRadius = m_creature->GetAttackDistance(who); + if( m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->IsWithinLOSInMap(who) ) + { + DoStartAttackNoMovement(who); + who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); + + if (!InCombat) + { + Aggro(who); + InCombat = true; + } + } + } + } + + void AttackStart(Unit* who) + { + if (who->isTargetableForAttack()) + { + DoStartAttackNoMovement(who); + + if (!InCombat) + { + Aggro(who); + InCombat = true; + } + } + } + + void Aggro(Unit *who) + { + } + + void KilledUnit(Unit *victim) + { + switch(rand()%2) + { + case 0: + DoYell(SAY_KILL_1,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_KILL_1); + break; + case 1: + DoYell(SAY_KILL_2,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_KILL_2); + break; + } + } + + void JustDied(Unit *victim) + { + DoYell(SAY_DEATH,LANG_UNIVERSAL,0); + DoPlaySoundToSet(m_creature,SOUND_DEATH); + + /*for questId 10886 (heroic mode only) + if( pInstance && pInstance->GetData(TYPE_HARBINGERSKYRISS) != DONE ) + ->FailQuest();*/ + } + + void UpdateAI(const uint32 diff) + { + if( !Init ) + { + if( EventProgress_Timer < diff ) + { + if( Phase < 8 ) + { + switch( Phase ) + { + case 1: + DoYell(SAY_INTRO_1,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_INTRO_1); + EventProgress_Timer = 18000; + break; + case 2: + DoYell(SAY_INTRO_2,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_INTRO_2); + EventProgress_Timer = 18000; + break; + case 3: + DoYell(SAY_WATER,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_WATER); + DoCast(m_creature,SPELL_CONJURE_WATER); + EventProgress_Timer = 7000; + break; + case 4: + DoYell(SAY_BUFFS,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_BUFFS); + DoCast(m_creature,SPELL_ICE_ARMOR); + EventProgress_Timer = 7000; + break; + case 5: + DoYell(SAY_DRINK,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_DRINK); + DoCast(m_creature,SPELL_ARCANE_INTELLECT); + EventProgress_Timer = 7000; + break; + case 6: + DoYell(SAY_READY,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_READY); + EventProgress_Timer = 6000; + break; + case 7: + if( pInstance ) + pInstance->SetData(TYPE_WARDEN_2,DONE); + Init = true; + break; + } + ++Phase; + } + } else EventProgress_Timer -= diff; + } + + if( !m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + if( !LowHp && ((m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < 20) ) + { + DoYell(SAY_LOWHP,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_LOWHP); + LowHp = true; + } + + if( Pyroblast_Timer < diff ) + { + if( m_creature->IsNonMeleeSpellCasted(false) ) + return; + + DoYell(SAY_PYRO,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_PYRO); + + DoCast(m_creature->getVictim(),SPELL_PYROBLAST); + Pyroblast_Timer = 40000; + }else Pyroblast_Timer -=diff; + + if( Fireball_Timer < diff ) + { + DoCast(m_creature->getVictim(),SPELL_FIREBALL); + Fireball_Timer = 4000; + }else Fireball_Timer -=diff; + + DoMeleeAttackIfReady(); + } +}; + +CreatureAI* GetAI_npc_millhouse_manastorm(Creature *_Creature) +{ + return new npc_millhouse_manastormAI (_Creature); +} + +/*##### +# npc_warden_mellichar +#####*/ + +#define YELL_INTRO1 "I knew the prince would be angry but, I... I have not been myself. I had to let them out! The great one speaks to me, you see. Wait--outsiders. Kael'thas did not send you! Good... I'll just tell the prince you released the prisoners!" +#define SOUND_INTRO1 11222 + +#define YELL_INTRO2 "The naaru kept some of the most dangerous beings in existence here in these cells. Let me introduce you to another...." +#define SOUND_INTRO2 11223 + +#define YELL_RELEASE1 "Yes, yes... another! Your will is mine!" +#define SOUND_RELEASE1 11224 + +#define YELL_RELEASE2A "Behold another terrifying creature of incomprehensible power!" +#define SOUND_RELEASE2A 11225 +#define YELL_RELEASE2B "What is this? A lowly gnome? I will do better, O'great one." +#define SOUND_RELEASE2B 11226 + +#define YELL_RELEASE3 "Anarchy! Bedlam! Oh, you are so wise! Yes, I see it now, of course!" +#define SOUND_RELEASE3 11227 + +#define YELL_RELEASE4 "One final cell remains. Yes, O'great one, right away!" +#define SOUND_RELEASE4 11228 + +#define YELL_WELCOME "Welcome, O'great one. I am your humble servant." +#define SOUND_WELCOME 11229 + +//phase 2(acid mobs) +#define ENTRY_TRICKSTER 20905 +#define ENTRY_PH_HUNTER 20906 +//phase 3 +#define ENTRY_MILLHOUSE 20977 +//phase 4(acid mobs) +#define ENTRY_AKKIRIS 20908 +#define ENTRY_SULFURON 20909 +//phase 5(acid mobs) +#define ENTRY_TW_DRAK 20910 +#define ENTRY_BL_DRAK 20911 +//phase 6 +#define ENTRY_SKYRISS 20912 + +//TARGET_SCRIPT +#define SPELL_TARGET_ALPHA 36856 +#define SPELL_TARGET_BETA 36854 +#define SPELL_TARGET_DELTA 36857 +#define SPELL_TARGET_GAMMA 36858 +#define SPELL_TARGET_OMEGA 36852 +#define SPELL_BUBBLE_VISUAL 36849 + +struct MANGOS_DLL_DECL npc_warden_mellicharAI : public ScriptedAI +{ + npc_warden_mellicharAI(Creature *c) : ScriptedAI(c) + { + pInstance = ((ScriptedInstance*)c->GetInstanceData()); + Reset(); + } + + ScriptedInstance* pInstance; + + bool IsRunning; + bool CanSpawn; + + uint32 EventProgress_Timer; + uint32 Phase; + + void Reset() + { + IsRunning = false; + CanSpawn = false; + + EventProgress_Timer = 22000; + Phase = 1; + + m_creature->SetFlag(UNIT_FIELD_FLAGS,UNIT_FLAG_NON_ATTACKABLE); + DoCast(m_creature,SPELL_TARGET_OMEGA); + + if( pInstance ) + pInstance->SetData(TYPE_HARBINGERSKYRISS,NOT_STARTED); + } + + void AttackStart(Unit* who) { } + + void MoveInLineOfSight(Unit *who) + { + if( IsRunning ) + return; + + if( !m_creature->getVictim() && who->isTargetableForAttack() && ( m_creature->IsHostileTo( who )) && who->isInAccessablePlaceFor(m_creature) ) + { + if (!m_creature->canFly() && m_creature->GetDistanceZ(who) > CREATURE_Z_ATTACK_RANGE) + return; + if (who->GetTypeId() != TYPEID_PLAYER) + return; + + float attackRadius = m_creature->GetAttackDistance(who)/10; + if( m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->IsWithinLOSInMap(who) ) + Aggro(who); + } + } + + void Aggro(Unit *who) + { + DoYell(YELL_INTRO1,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_INTRO1); + //possibly wrong spell OR should also cast second spell to make bubble appear (visual for this spell appear to be the correct) + DoCast(m_creature,SPELL_BUBBLE_VISUAL); + + if( pInstance ) + { + pInstance->SetData(TYPE_HARBINGERSKYRISS,IN_PROGRESS); + IsRunning = true; + } + } + + uint32 CanProgress() + { + if( pInstance ) + { + if( Phase == 7 && pInstance->GetData(TYPE_WARDEN_4) == DONE ) + return true; + if( Phase == 6 && pInstance->GetData(TYPE_WARDEN_3) == DONE ) + return true; + if( Phase == 5 && pInstance->GetData(TYPE_WARDEN_2) == DONE ) + return true; + if( Phase == 4 ) + return true; + if( Phase == 3 && pInstance->GetData(TYPE_WARDEN_1) == DONE ) + return true; + if( Phase == 2 && pInstance->GetData(TYPE_HARBINGERSKYRISS) == IN_PROGRESS ) + return true; + if( Phase == 1 && pInstance->GetData(TYPE_HARBINGERSKYRISS) == IN_PROGRESS ) + return true; + return false; + } + return false; + } + + void DoPrepareForPhase() + { + if( pInstance ) + { + m_creature->InterruptNonMeleeSpells(true); + m_creature->RemoveSpellsCausingAura(SPELL_AURA_DUMMY); + + switch( Phase ) + { + case 2: + DoCast(m_creature,SPELL_TARGET_ALPHA); + pInstance->SetData(TYPE_WARDEN_1,IN_PROGRESS); + break; + case 3: + DoCast(m_creature,SPELL_TARGET_BETA); + pInstance->SetData(TYPE_WARDEN_2,IN_PROGRESS); + break; + case 5: + DoCast(m_creature,SPELL_TARGET_DELTA); + pInstance->SetData(TYPE_WARDEN_3,IN_PROGRESS); + break; + case 6: + DoCast(m_creature,SPELL_TARGET_GAMMA); + pInstance->SetData(TYPE_WARDEN_4,IN_PROGRESS); + break; + case 7: + pInstance->SetData(TYPE_WARDEN_5,IN_PROGRESS); + break; + default: + break; + } + CanSpawn = true; + } + } + + void UpdateAI(const uint32 diff) + { + if( !IsRunning ) + return; + + if( EventProgress_Timer < diff ) + { + if( pInstance ) + { + if( pInstance->GetData(TYPE_HARBINGERSKYRISS) == FAIL ) + Reset(); + } + + if( CanSpawn ) + { + //continue beam omega pod, unless we are about to summon skyriss + if( Phase != 7 ) + DoCast(m_creature,SPELL_TARGET_OMEGA); + + switch( Phase ) + { + case 2: + switch( rand()%2 ) + { + case 0: m_creature->SummonCreature(ENTRY_TRICKSTER,478.326,-148.505,42.56,3.19,TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,600000); break; + case 1: m_creature->SummonCreature(ENTRY_PH_HUNTER,478.326,-148.505,42.56,3.19,TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,600000); break; + } + break; + case 3: + m_creature->SummonCreature(ENTRY_MILLHOUSE,413.292,-148.378,42.56,6.27,TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,600000); + break; + case 4: + DoYell(YELL_RELEASE2B,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_RELEASE2B); + break; + case 5: + switch( rand()%2 ) + { + case 0: m_creature->SummonCreature(ENTRY_AKKIRIS,420.179,-174.396,42.58,0.02,TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,600000); break; + case 1: m_creature->SummonCreature(ENTRY_SULFURON,420.179,-174.396,42.58,0.02,TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,600000); break; + } + break; + case 6: + switch( rand()%2 ) + { + case 0: m_creature->SummonCreature(ENTRY_TW_DRAK,471.795,-174.58,42.58,3.06,TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,600000); break; + case 1: m_creature->SummonCreature(ENTRY_BL_DRAK,471.795,-174.58,42.58,3.06,TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,600000); break; + } + break; + case 7: + m_creature->SummonCreature(ENTRY_SKYRISS,445.763,-191.639,44.64,1.60,TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,600000); + DoYell(YELL_WELCOME,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_WELCOME); + break; + default: + break; + } + CanSpawn = false; + ++Phase; + } + if( CanProgress() ) + { + switch( Phase ) + { + case 1: + DoYell(YELL_INTRO2,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_INTRO2); + EventProgress_Timer = 10000; + ++Phase; + break; + case 2: + DoYell(YELL_RELEASE1,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_RELEASE1); + DoPrepareForPhase(); + EventProgress_Timer = 7000; + break; + case 3: + DoYell(YELL_RELEASE2A,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_RELEASE2A); + DoPrepareForPhase(); + EventProgress_Timer = 10000; + break; + case 4: + DoPrepareForPhase(); + EventProgress_Timer = 15000; + break; + case 5: + DoYell(YELL_RELEASE3,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_RELEASE3); + DoPrepareForPhase(); + EventProgress_Timer = 15000; + break; + case 6: + DoYell(YELL_RELEASE4,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_RELEASE4); + DoPrepareForPhase(); + EventProgress_Timer = 15000; + break; + case 7: + DoPrepareForPhase(); + EventProgress_Timer = 15000; + break; + default: + break; + } + } + } else EventProgress_Timer -= diff; + } +}; +CreatureAI* GetAI_npc_warden_mellichar(Creature *_Creature) +{ + return new npc_warden_mellicharAI (_Creature); +} + +/*##### +# mob_zerekethvoidzone (this script probably not needed in future -> `creature_template_addon`.`auras`='36120 0') +#####*/ + +#define SPELL_VOID_ZONE_DAMAGE 36120 + +struct MANGOS_DLL_DECL mob_zerekethvoidzoneAI : public ScriptedAI +{ + mob_zerekethvoidzoneAI(Creature *c) : ScriptedAI(c) {Reset();} + + void Reset() + { + m_creature->SetUInt32Value(UNIT_NPC_FLAGS,0); + m_creature->setFaction(16); + m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + + DoCast(m_creature,SPELL_VOID_ZONE_DAMAGE); + } + + void Aggro(Unit* who) {} +}; +CreatureAI* GetAI_mob_zerekethvoidzoneAI(Creature *_Creature) +{ + return new mob_zerekethvoidzoneAI (_Creature); +} + +void AddSC_arcatraz() +{ + Script *newscript; + + newscript = new Script; + newscript->Name="npc_millhouse_manastorm"; + newscript->GetAI = GetAI_npc_millhouse_manastorm; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="npc_warden_mellichar"; + newscript->GetAI = GetAI_npc_warden_mellichar; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="mob_zerekethvoidzone"; + newscript->GetAI = GetAI_mob_zerekethvoidzoneAI; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/tempest_keep/arcatraz/boss_harbinger_skyriss.cpp b/src/bindings/scripts/scripts/zone/tempest_keep/arcatraz/boss_harbinger_skyriss.cpp index 650a6a8979e..739bf237e16 100644 --- a/src/bindings/scripts/scripts/zone/tempest_keep/arcatraz/boss_harbinger_skyriss.cpp +++ b/src/bindings/scripts/scripts/zone/tempest_keep/arcatraz/boss_harbinger_skyriss.cpp @@ -1,380 +1,380 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Harbinger_Skyriss -SD%Complete: 45 -SDComment: CombatAI not fully implemented. Timers will need adjustments. Need better method to "kill" the warden. Need more docs on how event fully work. Reset all event and force start over if fail at one point? -SDCategory: Tempest Keep, The Arcatraz -EndScriptData */ - -/* ContentData -boss_harbinger_skyriss -boss_harbinger_skyriss_illusion -EndContentData */ - -#include "precompiled.h" -#include "def_arcatraz.h" - -#define SAY_INTRO "It is a small matter to control the mind of the weak... for I bear allegiance to powers untouched by time, unmoved by fate. No force on this world or beyond harbors the strength to bend our knee... not even the mighty Legion!" -#define SOUND_INTRO 11122 - -#define SAY_AGGRO "Bear witness to the agent of your demise!" -#define SOUND_AGGRO 11123 - -#define SAY_KILL_1 "Your fate is written!" -#define SOUND_KILL_1 11124 -#define SAY_KILL_2 "The chaos I have sown here is but a taste...." -#define SOUND_KILL_2 11125 - -#define SAY_MIND_1 "You will do my bidding, weakling." -#define SOUND_MIND_1 11127 -#define SAY_MIND_2 "Your will is no longer your own." -#define SOUND_MIND_2 11128 - -#define SAY_FEAR_1 "Flee in terror!" -#define SOUND_FEAR_1 11129 -#define SAY_FEAR_2 "I will show you horrors undreamed of!" -#define SOUND_FEAR_2 11130 - -#define SAY_IMAGE "We span the universe, as countless as the stars!" -#define SOUND_IMAGE 11131 - -#define SAY_DEATH "I am merely one of... infinite multitudes." -#define SOUND_DEATH 11126 - -#define SPELL_FEAR 39415 - -#define SPELL_MIND_REND 36924 -#define H_SPELL_MIND_REND 39017 - -#define SPELL_DOMINATION 37162 -#define H_SPELL_DOMINATION 39019 - -#define H_SPELL_MANA_BURN 39020 - -#define SPELL_66_ILLUSION 36931 //entry 21466 -#define SPELL_33_ILLUSION 36932 //entry 21467 - -struct MANGOS_DLL_DECL boss_harbinger_skyrissAI : public ScriptedAI -{ - boss_harbinger_skyrissAI(Creature *c) : ScriptedAI(c) - { - pInstance = ((ScriptedInstance*)c->GetInstanceData()); - HeroicMode = m_creature->GetMap()->IsHeroic(); - Reset(); - } - - ScriptedInstance *pInstance; - bool HeroicMode; - - bool Intro; - bool IsImage33; - bool IsImage66; - - uint32 Intro_Phase; - uint32 Intro_Timer; - uint32 MindRend_Timer; - uint32 Fear_Timer; - uint32 Domination_Timer; - uint32 ManaBurn_Timer; - - void Reset() - { - m_creature->SetFlag(UNIT_FIELD_FLAGS,UNIT_FLAG_UNKNOWN2); - - if( Intro ) - Intro = true; - else - Intro = false; - - IsImage33 = false; - IsImage66 = false; - - Intro_Phase = 1; - Intro_Timer = 5000; - MindRend_Timer = 3000; - Fear_Timer = 15000; - Domination_Timer = 30000; - ManaBurn_Timer = 25000; - } - - void MoveInLineOfSight(Unit *who) - { - if( !Intro ) - return; - - if( !m_creature->getVictim() && who->isTargetableForAttack() && ( m_creature->IsHostileTo( who )) && who->isInAccessablePlaceFor(m_creature) ) - { - if (m_creature->GetDistanceZ(who) > CREATURE_Z_ATTACK_RANGE) - return; - - float attackRadius = m_creature->GetAttackDistance(who); - if( m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->IsWithinLOSInMap(who) ) - { - DoStartAttackAndMovement(who); - who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); - - if (!InCombat) - { - Aggro(who); - InCombat = true; - } - } - } - } - - void AttackStart(Unit* who) - { - if( !Intro ) - return; - - if( who->isTargetableForAttack() ) - { - DoStartAttackAndMovement(who); - - if( !InCombat ) - { - Aggro(who); - InCombat = true; - } - } - } - - void Aggro(Unit *who) - { - m_creature->RemoveFlag(UNIT_FIELD_FLAGS,UNIT_FLAG_UNKNOWN2); - } - - void JustDied(Unit* Killer) - { - DoYell(SAY_DEATH, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature,SOUND_DEATH); - if( pInstance ) - pInstance->SetData(TYPE_HARBINGERSKYRISS,DONE); - } - - void KilledUnit(Unit* victim) - { - /*if( victim->GetEntry() == 21436 ) - return;*/ - - switch(rand()%2) - { - case 0: - DoYell(SAY_KILL_1, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature,SOUND_KILL_1); - break; - case 1: - DoYell(SAY_KILL_2, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature,SOUND_KILL_2); - break; - } - } - - void JustSummoned(Creature *summoned) - { - summoned->AI()->AttackStart(m_creature->getVictim()); - } - - void DoSplit(uint32 val) - { - if( m_creature->IsNonMeleeSpellCasted(false) ) - m_creature->InterruptNonMeleeSpells(false); - - DoYell(SAY_IMAGE, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature,SOUND_IMAGE); - - if( val == 66 ) - DoCast(m_creature, SPELL_66_ILLUSION); - else - DoCast(m_creature, SPELL_33_ILLUSION); - } - - void UpdateAI(const uint32 diff) - { - if( !Intro && !InCombat ) - { - if( !pInstance ) - return; - - if( Intro_Timer < diff ) - { - switch( Intro_Phase ) - { - case 1: - DoYell(SAY_INTRO, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature,SOUND_INTRO); - ++Intro_Phase; - Intro_Timer = 25000; - break; - case 2: - DoYell(SAY_AGGRO, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature,SOUND_AGGRO); - if( Unit *mellic = Unit::GetUnit(*m_creature,pInstance->GetData64(DATA_MELLICHAR)) ) - { - //should have a better way to do this. possibly spell exist. - mellic->setDeathState(JUST_DIED); - mellic->SetHealth(0); - } - ++Intro_Phase; - Intro_Timer = 3000; - break; - case 3: - Intro = true; - break; - default: - break; - } - }else Intro_Timer -=diff; - } - - if( !m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - if( !IsImage66 && ((m_creature->GetHealth()*100) / m_creature->GetMaxHealth() <= 66) ) - { - DoSplit(66); - IsImage66 = true; - } - if( !IsImage33 && ((m_creature->GetHealth()*100) / m_creature->GetMaxHealth() <= 33) ) - { - DoSplit(33); - IsImage33 = true; - } - - if( MindRend_Timer < diff ) - { - if( Unit* target = SelectUnit(SELECT_TARGET_RANDOM,1) ) - DoCast(target,HeroicMode ? H_SPELL_MIND_REND : SPELL_MIND_REND); - else - DoCast(m_creature->getVictim(),HeroicMode ? H_SPELL_MIND_REND : SPELL_MIND_REND); - - MindRend_Timer = 8000; - }else MindRend_Timer -=diff; - - if( Fear_Timer < diff ) - { - if( m_creature->IsNonMeleeSpellCasted(false) ) - return; - - switch(rand()%2) - { - case 0: - DoYell(SAY_FEAR_1, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature,SOUND_FEAR_1); - break; - case 1: - DoYell(SAY_FEAR_2, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature,SOUND_FEAR_2); - break; - } - - if( Unit* target = SelectUnit(SELECT_TARGET_RANDOM,1) ) - DoCast(target,SPELL_FEAR); - else - DoCast(m_creature->getVictim(),SPELL_FEAR); - - Fear_Timer = 25000; - }else Fear_Timer -=diff; - - if( Domination_Timer < diff ) - { - if( m_creature->IsNonMeleeSpellCasted(false) ) - return; - - switch(rand()%2) - { - case 0: - DoYell(SAY_MIND_1, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature,SOUND_MIND_1); - break; - case 1: - DoYell(SAY_MIND_2, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature,SOUND_MIND_2); - break; - } - - if( Unit* target = SelectUnit(SELECT_TARGET_RANDOM,1) ) - DoCast(target,HeroicMode ? H_SPELL_DOMINATION : SPELL_DOMINATION); - else - DoCast(m_creature->getVictim(),HeroicMode ? H_SPELL_DOMINATION : SPELL_DOMINATION); - - Domination_Timer = 16000+rand()%16000; - }else Domination_Timer -=diff; - - if( HeroicMode ) - { - if( ManaBurn_Timer < diff ) - { - if( m_creature->IsNonMeleeSpellCasted(false) ) - return; - - if( Unit* target = SelectUnit(SELECT_TARGET_RANDOM,1) ) - DoCast(target,H_SPELL_MANA_BURN); - - ManaBurn_Timer = 16000+rand()%16000; - }else ManaBurn_Timer -=diff; - } - - DoMeleeAttackIfReady(); - } -}; - -CreatureAI* GetAI_boss_harbinger_skyriss(Creature *_Creature) -{ - return new boss_harbinger_skyrissAI (_Creature); -} - -#define SPELL_MIND_REND_IMAGE 36929 -#define H_SPELL_MIND_REND_IMAGE 39021 - -struct MANGOS_DLL_DECL boss_harbinger_skyriss_illusionAI : public ScriptedAI -{ - boss_harbinger_skyriss_illusionAI(Creature *c) : ScriptedAI(c) - { - pInstance = ((ScriptedInstance*)c->GetInstanceData()); - HeroicMode = m_creature->GetMap()->IsHeroic(); - Reset(); - } - - ScriptedInstance *pInstance; - bool HeroicMode; - - void Reset() { } - - void Aggro(Unit *who) { } -}; - -CreatureAI* GetAI_boss_harbinger_skyriss_illusion(Creature *_Creature) -{ - return new boss_harbinger_skyriss_illusionAI (_Creature); -} - -void AddSC_boss_harbinger_skyriss() -{ - Script *newscript; - - newscript = new Script; - newscript->Name="boss_harbinger_skyriss"; - newscript->GetAI = GetAI_boss_harbinger_skyriss; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="boss_harbinger_skyriss_illusion"; - newscript->GetAI = GetAI_boss_harbinger_skyriss_illusion; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Harbinger_Skyriss +SD%Complete: 45 +SDComment: CombatAI not fully implemented. Timers will need adjustments. Need better method to "kill" the warden. Need more docs on how event fully work. Reset all event and force start over if fail at one point? +SDCategory: Tempest Keep, The Arcatraz +EndScriptData */ + +/* ContentData +boss_harbinger_skyriss +boss_harbinger_skyriss_illusion +EndContentData */ + +#include "precompiled.h" +#include "def_arcatraz.h" + +#define SAY_INTRO "It is a small matter to control the mind of the weak... for I bear allegiance to powers untouched by time, unmoved by fate. No force on this world or beyond harbors the strength to bend our knee... not even the mighty Legion!" +#define SOUND_INTRO 11122 + +#define SAY_AGGRO "Bear witness to the agent of your demise!" +#define SOUND_AGGRO 11123 + +#define SAY_KILL_1 "Your fate is written!" +#define SOUND_KILL_1 11124 +#define SAY_KILL_2 "The chaos I have sown here is but a taste...." +#define SOUND_KILL_2 11125 + +#define SAY_MIND_1 "You will do my bidding, weakling." +#define SOUND_MIND_1 11127 +#define SAY_MIND_2 "Your will is no longer your own." +#define SOUND_MIND_2 11128 + +#define SAY_FEAR_1 "Flee in terror!" +#define SOUND_FEAR_1 11129 +#define SAY_FEAR_2 "I will show you horrors undreamed of!" +#define SOUND_FEAR_2 11130 + +#define SAY_IMAGE "We span the universe, as countless as the stars!" +#define SOUND_IMAGE 11131 + +#define SAY_DEATH "I am merely one of... infinite multitudes." +#define SOUND_DEATH 11126 + +#define SPELL_FEAR 39415 + +#define SPELL_MIND_REND 36924 +#define H_SPELL_MIND_REND 39017 + +#define SPELL_DOMINATION 37162 +#define H_SPELL_DOMINATION 39019 + +#define H_SPELL_MANA_BURN 39020 + +#define SPELL_66_ILLUSION 36931 //entry 21466 +#define SPELL_33_ILLUSION 36932 //entry 21467 + +struct MANGOS_DLL_DECL boss_harbinger_skyrissAI : public ScriptedAI +{ + boss_harbinger_skyrissAI(Creature *c) : ScriptedAI(c) + { + pInstance = ((ScriptedInstance*)c->GetInstanceData()); + HeroicMode = m_creature->GetMap()->IsHeroic(); + Reset(); + } + + ScriptedInstance *pInstance; + bool HeroicMode; + + bool Intro; + bool IsImage33; + bool IsImage66; + + uint32 Intro_Phase; + uint32 Intro_Timer; + uint32 MindRend_Timer; + uint32 Fear_Timer; + uint32 Domination_Timer; + uint32 ManaBurn_Timer; + + void Reset() + { + m_creature->SetFlag(UNIT_FIELD_FLAGS,UNIT_FLAG_UNKNOWN2); + + if( Intro ) + Intro = true; + else + Intro = false; + + IsImage33 = false; + IsImage66 = false; + + Intro_Phase = 1; + Intro_Timer = 5000; + MindRend_Timer = 3000; + Fear_Timer = 15000; + Domination_Timer = 30000; + ManaBurn_Timer = 25000; + } + + void MoveInLineOfSight(Unit *who) + { + if( !Intro ) + return; + + if( !m_creature->getVictim() && who->isTargetableForAttack() && ( m_creature->IsHostileTo( who )) && who->isInAccessablePlaceFor(m_creature) ) + { + if (!m_creature->canFly() && m_creature->GetDistanceZ(who) > CREATURE_Z_ATTACK_RANGE) + return; + + float attackRadius = m_creature->GetAttackDistance(who); + if( m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->IsWithinLOSInMap(who) ) + { + DoStartAttackAndMovement(who); + who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); + + if (!InCombat) + { + Aggro(who); + InCombat = true; + } + } + } + } + + void AttackStart(Unit* who) + { + if( !Intro ) + return; + + if( who->isTargetableForAttack() ) + { + DoStartAttackAndMovement(who); + + if( !InCombat ) + { + Aggro(who); + InCombat = true; + } + } + } + + void Aggro(Unit *who) + { + m_creature->RemoveFlag(UNIT_FIELD_FLAGS,UNIT_FLAG_UNKNOWN2); + } + + void JustDied(Unit* Killer) + { + DoYell(SAY_DEATH, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature,SOUND_DEATH); + if( pInstance ) + pInstance->SetData(TYPE_HARBINGERSKYRISS,DONE); + } + + void KilledUnit(Unit* victim) + { + /*if( victim->GetEntry() == 21436 ) + return;*/ + + switch(rand()%2) + { + case 0: + DoYell(SAY_KILL_1, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature,SOUND_KILL_1); + break; + case 1: + DoYell(SAY_KILL_2, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature,SOUND_KILL_2); + break; + } + } + + void JustSummoned(Creature *summoned) + { + summoned->AI()->AttackStart(m_creature->getVictim()); + } + + void DoSplit(uint32 val) + { + if( m_creature->IsNonMeleeSpellCasted(false) ) + m_creature->InterruptNonMeleeSpells(false); + + DoYell(SAY_IMAGE, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature,SOUND_IMAGE); + + if( val == 66 ) + DoCast(m_creature, SPELL_66_ILLUSION); + else + DoCast(m_creature, SPELL_33_ILLUSION); + } + + void UpdateAI(const uint32 diff) + { + if( !Intro && !InCombat ) + { + if( !pInstance ) + return; + + if( Intro_Timer < diff ) + { + switch( Intro_Phase ) + { + case 1: + DoYell(SAY_INTRO, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature,SOUND_INTRO); + ++Intro_Phase; + Intro_Timer = 25000; + break; + case 2: + DoYell(SAY_AGGRO, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature,SOUND_AGGRO); + if( Unit *mellic = Unit::GetUnit(*m_creature,pInstance->GetData64(DATA_MELLICHAR)) ) + { + //should have a better way to do this. possibly spell exist. + mellic->setDeathState(JUST_DIED); + mellic->SetHealth(0); + } + ++Intro_Phase; + Intro_Timer = 3000; + break; + case 3: + Intro = true; + break; + default: + break; + } + }else Intro_Timer -=diff; + } + + if( !m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + if( !IsImage66 && ((m_creature->GetHealth()*100) / m_creature->GetMaxHealth() <= 66) ) + { + DoSplit(66); + IsImage66 = true; + } + if( !IsImage33 && ((m_creature->GetHealth()*100) / m_creature->GetMaxHealth() <= 33) ) + { + DoSplit(33); + IsImage33 = true; + } + + if( MindRend_Timer < diff ) + { + if( Unit* target = SelectUnit(SELECT_TARGET_RANDOM,1) ) + DoCast(target,HeroicMode ? H_SPELL_MIND_REND : SPELL_MIND_REND); + else + DoCast(m_creature->getVictim(),HeroicMode ? H_SPELL_MIND_REND : SPELL_MIND_REND); + + MindRend_Timer = 8000; + }else MindRend_Timer -=diff; + + if( Fear_Timer < diff ) + { + if( m_creature->IsNonMeleeSpellCasted(false) ) + return; + + switch(rand()%2) + { + case 0: + DoYell(SAY_FEAR_1, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature,SOUND_FEAR_1); + break; + case 1: + DoYell(SAY_FEAR_2, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature,SOUND_FEAR_2); + break; + } + + if( Unit* target = SelectUnit(SELECT_TARGET_RANDOM,1) ) + DoCast(target,SPELL_FEAR); + else + DoCast(m_creature->getVictim(),SPELL_FEAR); + + Fear_Timer = 25000; + }else Fear_Timer -=diff; + + if( Domination_Timer < diff ) + { + if( m_creature->IsNonMeleeSpellCasted(false) ) + return; + + switch(rand()%2) + { + case 0: + DoYell(SAY_MIND_1, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature,SOUND_MIND_1); + break; + case 1: + DoYell(SAY_MIND_2, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature,SOUND_MIND_2); + break; + } + + if( Unit* target = SelectUnit(SELECT_TARGET_RANDOM,1) ) + DoCast(target,HeroicMode ? H_SPELL_DOMINATION : SPELL_DOMINATION); + else + DoCast(m_creature->getVictim(),HeroicMode ? H_SPELL_DOMINATION : SPELL_DOMINATION); + + Domination_Timer = 16000+rand()%16000; + }else Domination_Timer -=diff; + + if( HeroicMode ) + { + if( ManaBurn_Timer < diff ) + { + if( m_creature->IsNonMeleeSpellCasted(false) ) + return; + + if( Unit* target = SelectUnit(SELECT_TARGET_RANDOM,1) ) + DoCast(target,H_SPELL_MANA_BURN); + + ManaBurn_Timer = 16000+rand()%16000; + }else ManaBurn_Timer -=diff; + } + + DoMeleeAttackIfReady(); + } +}; + +CreatureAI* GetAI_boss_harbinger_skyriss(Creature *_Creature) +{ + return new boss_harbinger_skyrissAI (_Creature); +} + +#define SPELL_MIND_REND_IMAGE 36929 +#define H_SPELL_MIND_REND_IMAGE 39021 + +struct MANGOS_DLL_DECL boss_harbinger_skyriss_illusionAI : public ScriptedAI +{ + boss_harbinger_skyriss_illusionAI(Creature *c) : ScriptedAI(c) + { + pInstance = ((ScriptedInstance*)c->GetInstanceData()); + HeroicMode = m_creature->GetMap()->IsHeroic(); + Reset(); + } + + ScriptedInstance *pInstance; + bool HeroicMode; + + void Reset() { } + + void Aggro(Unit *who) { } +}; + +CreatureAI* GetAI_boss_harbinger_skyriss_illusion(Creature *_Creature) +{ + return new boss_harbinger_skyriss_illusionAI (_Creature); +} + +void AddSC_boss_harbinger_skyriss() +{ + Script *newscript; + + newscript = new Script; + newscript->Name="boss_harbinger_skyriss"; + newscript->GetAI = GetAI_boss_harbinger_skyriss; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="boss_harbinger_skyriss_illusion"; + newscript->GetAI = GetAI_boss_harbinger_skyriss_illusion; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/tempest_keep/arcatraz/def_arcatraz.h b/src/bindings/scripts/scripts/zone/tempest_keep/arcatraz/def_arcatraz.h index 8868a36d70c..fc6cde1ebaa 100644 --- a/src/bindings/scripts/scripts/zone/tempest_keep/arcatraz/def_arcatraz.h +++ b/src/bindings/scripts/scripts/zone/tempest_keep/arcatraz/def_arcatraz.h @@ -1,19 +1,19 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software licensed under GPL version 2 - * Please see the included DOCS/LICENSE.TXT for more information */ - -#ifndef DEF_ARCATRAZ_H -#define DEF_ARCATRAZ_H - -#define TYPE_ZEREKETH 1 -#define TYPE_DALLIAH 2 -#define TYPE_SOCCOTHRATES 3 -#define TYPE_HARBINGERSKYRISS 4 -#define TYPE_WARDEN_1 5 -#define TYPE_WARDEN_2 6 -#define TYPE_WARDEN_3 7 -#define TYPE_WARDEN_4 8 -#define TYPE_WARDEN_5 9 - -#define DATA_MELLICHAR 10 -#endif +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software licensed under GPL version 2 + * Please see the included DOCS/LICENSE.TXT for more information */ + +#ifndef DEF_ARCATRAZ_H +#define DEF_ARCATRAZ_H + +#define TYPE_ZEREKETH 1 +#define TYPE_DALLIAH 2 +#define TYPE_SOCCOTHRATES 3 +#define TYPE_HARBINGERSKYRISS 4 +#define TYPE_WARDEN_1 5 +#define TYPE_WARDEN_2 6 +#define TYPE_WARDEN_3 7 +#define TYPE_WARDEN_4 8 +#define TYPE_WARDEN_5 9 + +#define DATA_MELLICHAR 10 +#endif diff --git a/src/bindings/scripts/scripts/zone/tempest_keep/arcatraz/instance_arcatraz.cpp b/src/bindings/scripts/scripts/zone/tempest_keep/arcatraz/instance_arcatraz.cpp index 7fc1c573ab6..024781d0c41 100644 --- a/src/bindings/scripts/scripts/zone/tempest_keep/arcatraz/instance_arcatraz.cpp +++ b/src/bindings/scripts/scripts/zone/tempest_keep/arcatraz/instance_arcatraz.cpp @@ -1,224 +1,224 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Instance_Arcatraz -SD%Complete: 80 -SDComment: Mainly Harbringer Skyriss event -SDCategory: Tempest Keep, The Arcatraz -EndScriptData */ - -#include "precompiled.h" -#include "def_arcatraz.h" - -#define ENCOUNTERS 9 - -#define CONTAINMENT_CORE_SECURITY_FIELD_ALPHA 184318 //door opened when Wrath-Scryer Soccothrates dies -#define CONTAINMENT_CORE_SECURITY_FIELD_BETA 184319 //door opened when Dalliah the Doomsayer dies -#define POD_ALPHA 183961 //pod first boss wave -#define POD_BETA 183963 //pod second boss wave -#define POD_DELTA 183964 //pod third boss wave -#define POD_GAMMA 183962 //pod fourth boss wave -#define POD_OMEGA 183965 //pod fifth boss wave - -#define MELLICHAR 21436 //skyriss will kill this unit - -/* Arcatraz encounters: -1 - Zereketh the Unbound event -2 - Dalliah the Doomsayer event -3 - Wrath-Scryer Soccothrates event -4 - Harbinger Skyriss event, 5 sub-events -*/ - -struct MANGOS_DLL_DECL instance_arcatraz : public ScriptedInstance -{ - instance_arcatraz(Map *Map) : ScriptedInstance(Map) {Initialize();}; - - uint32 Encounter[ENCOUNTERS]; - - GameObject *Containment_Core_Security_Field_Alpha; - GameObject *Containment_Core_Security_Field_Beta; - GameObject *Pod_Alpha; - GameObject *Pod_Gamma; - GameObject *Pod_Beta; - GameObject *Pod_Delta; - GameObject *Pod_Omega; - - uint64 Mellichar; - - void Initialize() - { - Containment_Core_Security_Field_Alpha = NULL; - Containment_Core_Security_Field_Beta = NULL; - Pod_Alpha = NULL; - Pod_Beta = NULL; - Pod_Delta = NULL; - Pod_Gamma = NULL; - Pod_Omega = NULL; - - Mellichar = 0; - - for(uint8 i = 0; i < ENCOUNTERS; i++) - Encounter[i] = NOT_STARTED; - } - - bool IsEncounterInProgress() const - { - for(uint8 i = 0; i < ENCOUNTERS; i++) - if(Encounter[i]) return true; - - return false; - } - - void OnObjectCreate(GameObject *go) - { - switch(go->GetEntry()) - { - case CONTAINMENT_CORE_SECURITY_FIELD_ALPHA: Containment_Core_Security_Field_Alpha = go; break; - case CONTAINMENT_CORE_SECURITY_FIELD_BETA: Containment_Core_Security_Field_Beta = go; break; - case POD_ALPHA: Pod_Alpha = go; break; - case POD_BETA: Pod_Beta = go; break; - case POD_DELTA: Pod_Delta = go; break; - case POD_GAMMA: Pod_Gamma = go; break; - case POD_OMEGA: Pod_Omega = go; break; - } - } - - void OnCreatureCreate(Creature *creature, uint32 creature_entry) - { - switch(creature_entry) - { - case MELLICHAR: - Mellichar = creature->GetGUID(); - break; - } - } - - void SetData(uint32 type, uint32 data) - { - switch(type) - { - case TYPE_ZEREKETH: - Encounter[0] = data; - break; - - case TYPE_DALLIAH: - if( data == DONE ) - if( Containment_Core_Security_Field_Beta ) - Containment_Core_Security_Field_Beta->UseDoorOrButton(); - Encounter[1] = data; - break; - - case TYPE_SOCCOTHRATES: - if( data == DONE ) - if( Containment_Core_Security_Field_Alpha ) - Containment_Core_Security_Field_Alpha->UseDoorOrButton(); - Encounter[2] = data; - break; - - case TYPE_HARBINGERSKYRISS: - if( data == NOT_STARTED || data == FAIL ) - { - Encounter[4] = NOT_STARTED; - Encounter[5] = NOT_STARTED; - Encounter[6] = NOT_STARTED; - Encounter[7] = NOT_STARTED; - Encounter[8] = NOT_STARTED; - } - Encounter[3] = data; - break; - - case TYPE_WARDEN_1: - if( data == IN_PROGRESS ) - if( Pod_Alpha ) - Pod_Alpha->UseDoorOrButton(); - Encounter[4] = data; - break; - - case TYPE_WARDEN_2: - if( data == IN_PROGRESS ) - if( Pod_Beta ) - Pod_Beta->UseDoorOrButton(); - Encounter[5] = data; - break; - - case TYPE_WARDEN_3: - if( data == IN_PROGRESS ) - if( Pod_Delta ) - Pod_Delta->UseDoorOrButton(); - Encounter[6] = data; - break; - - case TYPE_WARDEN_4: - if( data == IN_PROGRESS ) - if( Pod_Gamma ) - Pod_Gamma->UseDoorOrButton(); - Encounter[7] = data; - break; - - case TYPE_WARDEN_5: - if( data == IN_PROGRESS ) - if( Pod_Omega ) - Pod_Omega->UseDoorOrButton(); - Encounter[8] = data; - break; - } - } - - uint32 GetData(uint32 data) - { - switch(data) - { - case TYPE_HARBINGERSKYRISS: - return Encounter[3]; - case TYPE_WARDEN_1: - return Encounter[4]; - case TYPE_WARDEN_2: - return Encounter[5]; - case TYPE_WARDEN_3: - return Encounter[6]; - case TYPE_WARDEN_4: - return Encounter[7]; - case TYPE_WARDEN_5: - return Encounter[8]; - } - return 0; - } - - uint64 GetData64(uint32 identifier) - { - switch(identifier) - { - case DATA_MELLICHAR: - return Mellichar; - } - return 0; - } -}; - -InstanceData* GetInstanceData_instance_arcatraz(Map* map) -{ - return new instance_arcatraz(map); -} - -void AddSC_instance_arcatraz() -{ - Script *newscript; - newscript = new Script; - newscript->Name = "instance_arcatraz"; - newscript->GetInstanceData = GetInstanceData_instance_arcatraz; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Instance_Arcatraz +SD%Complete: 80 +SDComment: Mainly Harbringer Skyriss event +SDCategory: Tempest Keep, The Arcatraz +EndScriptData */ + +#include "precompiled.h" +#include "def_arcatraz.h" + +#define ENCOUNTERS 9 + +#define CONTAINMENT_CORE_SECURITY_FIELD_ALPHA 184318 //door opened when Wrath-Scryer Soccothrates dies +#define CONTAINMENT_CORE_SECURITY_FIELD_BETA 184319 //door opened when Dalliah the Doomsayer dies +#define POD_ALPHA 183961 //pod first boss wave +#define POD_BETA 183963 //pod second boss wave +#define POD_DELTA 183964 //pod third boss wave +#define POD_GAMMA 183962 //pod fourth boss wave +#define POD_OMEGA 183965 //pod fifth boss wave + +#define MELLICHAR 21436 //skyriss will kill this unit + +/* Arcatraz encounters: +1 - Zereketh the Unbound event +2 - Dalliah the Doomsayer event +3 - Wrath-Scryer Soccothrates event +4 - Harbinger Skyriss event, 5 sub-events +*/ + +struct MANGOS_DLL_DECL instance_arcatraz : public ScriptedInstance +{ + instance_arcatraz(Map *Map) : ScriptedInstance(Map) {Initialize();}; + + uint32 Encounter[ENCOUNTERS]; + + GameObject *Containment_Core_Security_Field_Alpha; + GameObject *Containment_Core_Security_Field_Beta; + GameObject *Pod_Alpha; + GameObject *Pod_Gamma; + GameObject *Pod_Beta; + GameObject *Pod_Delta; + GameObject *Pod_Omega; + + uint64 Mellichar; + + void Initialize() + { + Containment_Core_Security_Field_Alpha = NULL; + Containment_Core_Security_Field_Beta = NULL; + Pod_Alpha = NULL; + Pod_Beta = NULL; + Pod_Delta = NULL; + Pod_Gamma = NULL; + Pod_Omega = NULL; + + Mellichar = 0; + + for(uint8 i = 0; i < ENCOUNTERS; i++) + Encounter[i] = NOT_STARTED; + } + + bool IsEncounterInProgress() const + { + for(uint8 i = 0; i < ENCOUNTERS; i++) + if(Encounter[i]) return true; + + return false; + } + + void OnObjectCreate(GameObject *go) + { + switch(go->GetEntry()) + { + case CONTAINMENT_CORE_SECURITY_FIELD_ALPHA: Containment_Core_Security_Field_Alpha = go; break; + case CONTAINMENT_CORE_SECURITY_FIELD_BETA: Containment_Core_Security_Field_Beta = go; break; + case POD_ALPHA: Pod_Alpha = go; break; + case POD_BETA: Pod_Beta = go; break; + case POD_DELTA: Pod_Delta = go; break; + case POD_GAMMA: Pod_Gamma = go; break; + case POD_OMEGA: Pod_Omega = go; break; + } + } + + void OnCreatureCreate(Creature *creature, uint32 creature_entry) + { + switch(creature_entry) + { + case MELLICHAR: + Mellichar = creature->GetGUID(); + break; + } + } + + void SetData(uint32 type, uint32 data) + { + switch(type) + { + case TYPE_ZEREKETH: + Encounter[0] = data; + break; + + case TYPE_DALLIAH: + if( data == DONE ) + if( Containment_Core_Security_Field_Beta ) + Containment_Core_Security_Field_Beta->UseDoorOrButton(); + Encounter[1] = data; + break; + + case TYPE_SOCCOTHRATES: + if( data == DONE ) + if( Containment_Core_Security_Field_Alpha ) + Containment_Core_Security_Field_Alpha->UseDoorOrButton(); + Encounter[2] = data; + break; + + case TYPE_HARBINGERSKYRISS: + if( data == NOT_STARTED || data == FAIL ) + { + Encounter[4] = NOT_STARTED; + Encounter[5] = NOT_STARTED; + Encounter[6] = NOT_STARTED; + Encounter[7] = NOT_STARTED; + Encounter[8] = NOT_STARTED; + } + Encounter[3] = data; + break; + + case TYPE_WARDEN_1: + if( data == IN_PROGRESS ) + if( Pod_Alpha ) + Pod_Alpha->UseDoorOrButton(); + Encounter[4] = data; + break; + + case TYPE_WARDEN_2: + if( data == IN_PROGRESS ) + if( Pod_Beta ) + Pod_Beta->UseDoorOrButton(); + Encounter[5] = data; + break; + + case TYPE_WARDEN_3: + if( data == IN_PROGRESS ) + if( Pod_Delta ) + Pod_Delta->UseDoorOrButton(); + Encounter[6] = data; + break; + + case TYPE_WARDEN_4: + if( data == IN_PROGRESS ) + if( Pod_Gamma ) + Pod_Gamma->UseDoorOrButton(); + Encounter[7] = data; + break; + + case TYPE_WARDEN_5: + if( data == IN_PROGRESS ) + if( Pod_Omega ) + Pod_Omega->UseDoorOrButton(); + Encounter[8] = data; + break; + } + } + + uint32 GetData(uint32 data) + { + switch(data) + { + case TYPE_HARBINGERSKYRISS: + return Encounter[3]; + case TYPE_WARDEN_1: + return Encounter[4]; + case TYPE_WARDEN_2: + return Encounter[5]; + case TYPE_WARDEN_3: + return Encounter[6]; + case TYPE_WARDEN_4: + return Encounter[7]; + case TYPE_WARDEN_5: + return Encounter[8]; + } + return 0; + } + + uint64 GetData64(uint32 identifier) + { + switch(identifier) + { + case DATA_MELLICHAR: + return Mellichar; + } + return 0; + } +}; + +InstanceData* GetInstanceData_instance_arcatraz(Map* map) +{ + return new instance_arcatraz(map); +} + +void AddSC_instance_arcatraz() +{ + Script *newscript; + newscript = new Script; + newscript->Name = "instance_arcatraz"; + newscript->GetInstanceData = GetInstanceData_instance_arcatraz; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/tempest_keep/botanica/boss_high_botanist_freywinn.cpp b/src/bindings/scripts/scripts/zone/tempest_keep/botanica/boss_high_botanist_freywinn.cpp index 3dfc0782512..baa9a018d5c 100644 --- a/src/bindings/scripts/scripts/zone/tempest_keep/botanica/boss_high_botanist_freywinn.cpp +++ b/src/bindings/scripts/scripts/zone/tempest_keep/botanica/boss_high_botanist_freywinn.cpp @@ -1,215 +1,215 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_High_Botanist_Freywinn -SD%Complete: 90 -SDComment: some strange visual related to tree form(if aura lost before normal duration end). possible make summon&transform -process smoother(transform after delay) -SDCategory: Tempest Keep, The Botanica -EndScriptData */ - -#include "precompiled.h" - -#define SAY_AGGRO "What are you doing? These specimens are very delicate!" -#define SOUND_AGGRO 11144 - -#define SAY_KILL_1 "Your life cycle is now concluded!" -#define SOUND_KILL_1 11145 -#define SAY_KILL_2 "You will feed the worms." -#define SOUND_KILL_2 11146 - -#define SAY_TREE_1 "Endorel aluminor!" -#define SOUND_TREE_1 11147 -#define SAY_TREE_2 "Nature bends to my will!" -#define SOUND_TREE_2 11148 - -#define SAY_DEATH "The specimens...must be preserved." -#define SOUND_DEATH 11149 - -#define SPELL_TRANQUILITY 34550 -#define SPELL_TREE_FORM 34551 - -#define SPELL_SUMMON_FRAYER 34557 -#define ENTRY_FRAYER 19953 - -#define SPELL_PLANT_WHITE 34759 -#define SPELL_PLANT_GREEN 34761 -#define SPELL_PLANT_BLUE 34762 -#define SPELL_PLANT_RED 34763 - -struct MANGOS_DLL_DECL boss_high_botanist_freywinnAI : public ScriptedAI -{ - boss_high_botanist_freywinnAI(Creature *c) : ScriptedAI(c) { Reset(); } - - std::list Adds_List; - - uint32 SummonSeedling_Timer; - uint32 TreeForm_Timer; - uint32 MoveCheck_Timer; - uint32 DeadAddsCount; - bool MoveFree; - - void Reset() - { - Adds_List.clear(); - - SummonSeedling_Timer = 6000; - TreeForm_Timer = 30000; - MoveCheck_Timer = 1000; - DeadAddsCount = 0; - MoveFree = true; - } - - void Aggro(Unit *who) - { - DoYell(SAY_AGGRO, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature,SOUND_AGGRO); - } - - void JustSummoned(Creature *summoned) - { - if( summoned->GetEntry() == ENTRY_FRAYER ) - Adds_List.push_back(summoned->GetGUID()); - } - - void DoSummonSeedling() - { - switch(rand()%4) - { - case 0: DoCast(m_creature,SPELL_PLANT_WHITE); break; - case 1: DoCast(m_creature,SPELL_PLANT_GREEN); break; - case 2: DoCast(m_creature,SPELL_PLANT_BLUE); break; - case 3: DoCast(m_creature,SPELL_PLANT_RED); break; - } - } - - void KilledUnit(Unit* victim) - { - switch(rand()%2) - { - case 0: - DoYell(SAY_KILL_1, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature,SOUND_KILL_1); - break; - case 1: - DoYell(SAY_KILL_2, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature,SOUND_KILL_2); - break; - } - } - - void UpdateAI(const uint32 diff) - { - if( !m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - if( TreeForm_Timer < diff ) - { - switch(rand()%2) - { - case 0: - DoYell(SAY_TREE_1, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature,SOUND_TREE_1); - break; - case 1: - DoYell(SAY_TREE_2, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature,SOUND_TREE_2); - break; - } - - if( m_creature->IsNonMeleeSpellCasted(false) ) - m_creature->InterruptNonMeleeSpells(true); - - m_creature->RemoveAllAuras(); - - DoCast(m_creature,SPELL_SUMMON_FRAYER,true); - DoCast(m_creature,SPELL_TRANQUILITY,true); - DoCast(m_creature,SPELL_TREE_FORM,true); - - m_creature->GetMotionMaster()->MoveIdle(); - MoveFree = false; - - TreeForm_Timer = 75000; - }else TreeForm_Timer -= diff; - - if( !MoveFree ) - { - if( MoveCheck_Timer < diff ) - { - if( !Adds_List.empty() ) - { - for(std::list::iterator itr = Adds_List.begin(); itr != Adds_List.end(); ++itr) - { - if( Unit *temp = Unit::GetUnit(*m_creature,*itr) ) - { - if( !temp->isAlive() ) - { - Adds_List.erase(itr); - ++DeadAddsCount; - break; - } - } - } - } - - if( DeadAddsCount < 3 && TreeForm_Timer-30000 < diff ) - DeadAddsCount = 3; - - if( DeadAddsCount >= 3 ) - { - Adds_List.clear(); - DeadAddsCount = 0; - - m_creature->InterruptNonMeleeSpells(true); - m_creature->RemoveAllAuras(); - m_creature->GetMotionMaster()->MoveChase(m_creature->getVictim()); - MoveFree = true; - } - MoveCheck_Timer = 500; - } - else MoveCheck_Timer -= diff; - - return; - } - - /*if( m_creature->HasAura(SPELL_TREE_FORM,0) || m_creature->HasAura(SPELL_TRANQUILITY,0) ) - return;*/ - - //one random seedling every 5 secs, but not in tree form - if( SummonSeedling_Timer < diff ) - { - DoSummonSeedling(); - SummonSeedling_Timer = 6000; - }else SummonSeedling_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; - -CreatureAI* GetAI_boss_high_botanist_freywinn(Creature *_Creature) -{ - return new boss_high_botanist_freywinnAI (_Creature); -} - -void AddSC_boss_high_botanist_freywinn() -{ - Script *newscript; - - newscript = new Script; - newscript->Name="boss_high_botanist_freywinn"; - newscript->GetAI = GetAI_boss_high_botanist_freywinn; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_High_Botanist_Freywinn +SD%Complete: 90 +SDComment: some strange visual related to tree form(if aura lost before normal duration end). possible make summon&transform -process smoother(transform after delay) +SDCategory: Tempest Keep, The Botanica +EndScriptData */ + +#include "precompiled.h" + +#define SAY_AGGRO "What are you doing? These specimens are very delicate!" +#define SOUND_AGGRO 11144 + +#define SAY_KILL_1 "Your life cycle is now concluded!" +#define SOUND_KILL_1 11145 +#define SAY_KILL_2 "You will feed the worms." +#define SOUND_KILL_2 11146 + +#define SAY_TREE_1 "Endorel aluminor!" +#define SOUND_TREE_1 11147 +#define SAY_TREE_2 "Nature bends to my will!" +#define SOUND_TREE_2 11148 + +#define SAY_DEATH "The specimens...must be preserved." +#define SOUND_DEATH 11149 + +#define SPELL_TRANQUILITY 34550 +#define SPELL_TREE_FORM 34551 + +#define SPELL_SUMMON_FRAYER 34557 +#define ENTRY_FRAYER 19953 + +#define SPELL_PLANT_WHITE 34759 +#define SPELL_PLANT_GREEN 34761 +#define SPELL_PLANT_BLUE 34762 +#define SPELL_PLANT_RED 34763 + +struct MANGOS_DLL_DECL boss_high_botanist_freywinnAI : public ScriptedAI +{ + boss_high_botanist_freywinnAI(Creature *c) : ScriptedAI(c) { Reset(); } + + std::list Adds_List; + + uint32 SummonSeedling_Timer; + uint32 TreeForm_Timer; + uint32 MoveCheck_Timer; + uint32 DeadAddsCount; + bool MoveFree; + + void Reset() + { + Adds_List.clear(); + + SummonSeedling_Timer = 6000; + TreeForm_Timer = 30000; + MoveCheck_Timer = 1000; + DeadAddsCount = 0; + MoveFree = true; + } + + void Aggro(Unit *who) + { + DoYell(SAY_AGGRO, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature,SOUND_AGGRO); + } + + void JustSummoned(Creature *summoned) + { + if( summoned->GetEntry() == ENTRY_FRAYER ) + Adds_List.push_back(summoned->GetGUID()); + } + + void DoSummonSeedling() + { + switch(rand()%4) + { + case 0: DoCast(m_creature,SPELL_PLANT_WHITE); break; + case 1: DoCast(m_creature,SPELL_PLANT_GREEN); break; + case 2: DoCast(m_creature,SPELL_PLANT_BLUE); break; + case 3: DoCast(m_creature,SPELL_PLANT_RED); break; + } + } + + void KilledUnit(Unit* victim) + { + switch(rand()%2) + { + case 0: + DoYell(SAY_KILL_1, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature,SOUND_KILL_1); + break; + case 1: + DoYell(SAY_KILL_2, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature,SOUND_KILL_2); + break; + } + } + + void UpdateAI(const uint32 diff) + { + if( !m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + if( TreeForm_Timer < diff ) + { + switch(rand()%2) + { + case 0: + DoYell(SAY_TREE_1, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature,SOUND_TREE_1); + break; + case 1: + DoYell(SAY_TREE_2, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature,SOUND_TREE_2); + break; + } + + if( m_creature->IsNonMeleeSpellCasted(false) ) + m_creature->InterruptNonMeleeSpells(true); + + m_creature->RemoveAllAuras(); + + DoCast(m_creature,SPELL_SUMMON_FRAYER,true); + DoCast(m_creature,SPELL_TRANQUILITY,true); + DoCast(m_creature,SPELL_TREE_FORM,true); + + m_creature->GetMotionMaster()->MoveIdle(); + MoveFree = false; + + TreeForm_Timer = 75000; + }else TreeForm_Timer -= diff; + + if( !MoveFree ) + { + if( MoveCheck_Timer < diff ) + { + if( !Adds_List.empty() ) + { + for(std::list::iterator itr = Adds_List.begin(); itr != Adds_List.end(); ++itr) + { + if( Unit *temp = Unit::GetUnit(*m_creature,*itr) ) + { + if( !temp->isAlive() ) + { + Adds_List.erase(itr); + ++DeadAddsCount; + break; + } + } + } + } + + if( DeadAddsCount < 3 && TreeForm_Timer-30000 < diff ) + DeadAddsCount = 3; + + if( DeadAddsCount >= 3 ) + { + Adds_List.clear(); + DeadAddsCount = 0; + + m_creature->InterruptNonMeleeSpells(true); + m_creature->RemoveAllAuras(); + m_creature->GetMotionMaster()->MoveChase(m_creature->getVictim()); + MoveFree = true; + } + MoveCheck_Timer = 500; + } + else MoveCheck_Timer -= diff; + + return; + } + + /*if( m_creature->HasAura(SPELL_TREE_FORM,0) || m_creature->HasAura(SPELL_TRANQUILITY,0) ) + return;*/ + + //one random seedling every 5 secs, but not in tree form + if( SummonSeedling_Timer < diff ) + { + DoSummonSeedling(); + SummonSeedling_Timer = 6000; + }else SummonSeedling_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; + +CreatureAI* GetAI_boss_high_botanist_freywinn(Creature *_Creature) +{ + return new boss_high_botanist_freywinnAI (_Creature); +} + +void AddSC_boss_high_botanist_freywinn() +{ + Script *newscript; + + newscript = new Script; + newscript->Name="boss_high_botanist_freywinn"; + newscript->GetAI = GetAI_boss_high_botanist_freywinn; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/tempest_keep/botanica/boss_laj.cpp b/src/bindings/scripts/scripts/zone/tempest_keep/botanica/boss_laj.cpp index f0bc53e7264..825d16eeb54 100644 --- a/src/bindings/scripts/scripts/zone/tempest_keep/botanica/boss_laj.cpp +++ b/src/bindings/scripts/scripts/zone/tempest_keep/botanica/boss_laj.cpp @@ -1,198 +1,198 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Laj -SD%Complete: 95 -SDComment: Immunities _may_ be applied by spells, but this has _not_ been confirmed to be proper way. Most spells require database support. -SDCategory: Tempest Keep, The Botanica -EndScriptData */ - -#include "precompiled.h" - -#define SPELL_ALLERGIC_REACTION 34697 -#define SPELL_TELEPORT_SELF 34673 - -#define SPELL_SUMMON_LASHER_1 34681 -#define SPELL_SUMMON_FLAYER_1 34682 -#define SPELL_SUMMON_LASHER_2 34684 -#define SPELL_SUMMON_FLAYER_2 34685 -#define SPELL_SUMMON_LASHER_3 34686 -#define SPELL_SUMMON_FLAYER_4 34687 -#define SPELL_SUMMON_LASHER_4 34688 -#define SPELL_SUMMON_FLAYER_3 34690 - -#define EMOTE_SUMMON "emits a strange noise." - -#define MODEL_DEFAULT 13109 -#define MODEL_ARCANE 14213 -#define MODEL_FIRE 13110 -#define MODEL_FROST 14112 -#define MODEL_NATURE 14214 - -struct MANGOS_DLL_DECL boss_lajAI : public ScriptedAI -{ - boss_lajAI(Creature *c) : ScriptedAI(c) { Reset(); } - - bool CanSummon; - uint32 Teleport_Timer; - uint32 Summon_Timer; - uint32 Transform_Timer; - uint32 Allergic_Timer; - - void Reset() - { - m_creature->SetUInt32Value(UNIT_FIELD_DISPLAYID,MODEL_DEFAULT); - m_creature->ApplySpellImmune(0, IMMUNITY_SCHOOL, SPELL_SCHOOL_MASK_SHADOW, true); - m_creature->ApplySpellImmune(0, IMMUNITY_SCHOOL, SPELL_SCHOOL_MASK_ARCANE, false); - m_creature->ApplySpellImmune(0, IMMUNITY_SCHOOL, SPELL_SCHOOL_MASK_FIRE, false); - m_creature->ApplySpellImmune(0, IMMUNITY_SCHOOL, SPELL_SCHOOL_MASK_FROST, false); - m_creature->ApplySpellImmune(0, IMMUNITY_SCHOOL, SPELL_SCHOOL_MASK_NATURE, false); - - CanSummon = false; - Teleport_Timer = 20000; - Summon_Timer = 2500; - Transform_Timer = 30000; - Allergic_Timer = 5000; - } - - void DoTransform() - { - switch(rand()%5) - { - case 0: - m_creature->SetUInt32Value(UNIT_FIELD_DISPLAYID,MODEL_DEFAULT); - m_creature->ApplySpellImmune(0, IMMUNITY_SCHOOL, SPELL_SCHOOL_MASK_SHADOW, true); - m_creature->ApplySpellImmune(0, IMMUNITY_SCHOOL, SPELL_SCHOOL_MASK_ARCANE, false); - m_creature->ApplySpellImmune(0, IMMUNITY_SCHOOL, SPELL_SCHOOL_MASK_FIRE, false); - m_creature->ApplySpellImmune(0, IMMUNITY_SCHOOL, SPELL_SCHOOL_MASK_FROST, false); - m_creature->ApplySpellImmune(0, IMMUNITY_SCHOOL, SPELL_SCHOOL_MASK_NATURE, false); - break; - case 1: - m_creature->SetUInt32Value(UNIT_FIELD_DISPLAYID,MODEL_ARCANE); - m_creature->ApplySpellImmune(0, IMMUNITY_SCHOOL, SPELL_SCHOOL_MASK_SHADOW, false); - m_creature->ApplySpellImmune(0, IMMUNITY_SCHOOL, SPELL_SCHOOL_MASK_ARCANE, true); - m_creature->ApplySpellImmune(0, IMMUNITY_SCHOOL, SPELL_SCHOOL_MASK_FIRE, false); - m_creature->ApplySpellImmune(0, IMMUNITY_SCHOOL, SPELL_SCHOOL_MASK_FROST, false); - m_creature->ApplySpellImmune(0, IMMUNITY_SCHOOL, SPELL_SCHOOL_MASK_NATURE, false); - break; - case 2: - m_creature->SetUInt32Value(UNIT_FIELD_DISPLAYID,MODEL_FIRE); - m_creature->ApplySpellImmune(0, IMMUNITY_SCHOOL, SPELL_SCHOOL_MASK_SHADOW, false); - m_creature->ApplySpellImmune(0, IMMUNITY_SCHOOL, SPELL_SCHOOL_MASK_ARCANE, false); - m_creature->ApplySpellImmune(0, IMMUNITY_SCHOOL, SPELL_SCHOOL_MASK_FIRE, true); - m_creature->ApplySpellImmune(0, IMMUNITY_SCHOOL, SPELL_SCHOOL_MASK_FROST, false); - m_creature->ApplySpellImmune(0, IMMUNITY_SCHOOL, SPELL_SCHOOL_MASK_NATURE, false); - break; - case 3: - m_creature->SetUInt32Value(UNIT_FIELD_DISPLAYID,MODEL_FROST); - m_creature->ApplySpellImmune(0, IMMUNITY_SCHOOL, SPELL_SCHOOL_MASK_SHADOW, false); - m_creature->ApplySpellImmune(0, IMMUNITY_SCHOOL, SPELL_SCHOOL_MASK_ARCANE, false); - m_creature->ApplySpellImmune(0, IMMUNITY_SCHOOL, SPELL_SCHOOL_MASK_FIRE, false); - m_creature->ApplySpellImmune(0, IMMUNITY_SCHOOL, SPELL_SCHOOL_MASK_FROST, true); - m_creature->ApplySpellImmune(0, IMMUNITY_SCHOOL, SPELL_SCHOOL_MASK_NATURE, false); - break; - case 4: - m_creature->SetUInt32Value(UNIT_FIELD_DISPLAYID,MODEL_NATURE); - m_creature->ApplySpellImmune(0, IMMUNITY_SCHOOL, SPELL_SCHOOL_MASK_SHADOW, false); - m_creature->ApplySpellImmune(0, IMMUNITY_SCHOOL, SPELL_SCHOOL_MASK_ARCANE, false); - m_creature->ApplySpellImmune(0, IMMUNITY_SCHOOL, SPELL_SCHOOL_MASK_FIRE, false); - m_creature->ApplySpellImmune(0, IMMUNITY_SCHOOL, SPELL_SCHOOL_MASK_FROST, false); - m_creature->ApplySpellImmune(0, IMMUNITY_SCHOOL, SPELL_SCHOOL_MASK_NATURE, true); - break; - } - } - - void DoSummons() - { - switch(rand()%4) - { - case 0: - DoCast(m_creature,SPELL_SUMMON_LASHER_1,true); - DoCast(m_creature,SPELL_SUMMON_FLAYER_1,true); - break; - case 1: - DoCast(m_creature,SPELL_SUMMON_LASHER_2,true); - DoCast(m_creature,SPELL_SUMMON_FLAYER_2,true); - break; - case 2: - DoCast(m_creature,SPELL_SUMMON_LASHER_3,true); - DoCast(m_creature,SPELL_SUMMON_FLAYER_3,true); - break; - case 3: - DoCast(m_creature,SPELL_SUMMON_LASHER_4,true); - DoCast(m_creature,SPELL_SUMMON_FLAYER_4,true); - break; - } - CanSummon = false; - } - - void Aggro(Unit *who) - { - } - - void UpdateAI(const uint32 diff) - { - if( !m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - if( CanSummon ) - { - if( Summon_Timer < diff ) - { - DoTextEmote(EMOTE_SUMMON,NULL); - DoSummons(); - Summon_Timer = 2500; - }else Summon_Timer -= diff; - } - - if( Allergic_Timer < diff ) - { - DoCast(m_creature->getVictim(),SPELL_ALLERGIC_REACTION); - Allergic_Timer = 25000+rand()%15000; - }else Allergic_Timer -= diff; - - if( Teleport_Timer < diff ) - { - DoCast(m_creature,SPELL_TELEPORT_SELF); - Teleport_Timer = 30000+rand()%10000; - CanSummon = true; - }else Teleport_Timer -= diff; - - if( Transform_Timer < diff ) - { - DoTransform(); - Transform_Timer = 25000+rand()%15000; - }else Transform_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; - -CreatureAI* GetAI_boss_laj(Creature *_Creature) -{ - return new boss_lajAI (_Creature); -} - -void AddSC_boss_laj() -{ - Script *newscript; - - newscript = new Script; - newscript->Name="boss_laj"; - newscript->GetAI = GetAI_boss_laj; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Laj +SD%Complete: 95 +SDComment: Immunities _may_ be applied by spells, but this has _not_ been confirmed to be proper way. Most spells require database support. +SDCategory: Tempest Keep, The Botanica +EndScriptData */ + +#include "precompiled.h" + +#define SPELL_ALLERGIC_REACTION 34697 +#define SPELL_TELEPORT_SELF 34673 + +#define SPELL_SUMMON_LASHER_1 34681 +#define SPELL_SUMMON_FLAYER_1 34682 +#define SPELL_SUMMON_LASHER_2 34684 +#define SPELL_SUMMON_FLAYER_2 34685 +#define SPELL_SUMMON_LASHER_3 34686 +#define SPELL_SUMMON_FLAYER_4 34687 +#define SPELL_SUMMON_LASHER_4 34688 +#define SPELL_SUMMON_FLAYER_3 34690 + +#define EMOTE_SUMMON "emits a strange noise." + +#define MODEL_DEFAULT 13109 +#define MODEL_ARCANE 14213 +#define MODEL_FIRE 13110 +#define MODEL_FROST 14112 +#define MODEL_NATURE 14214 + +struct MANGOS_DLL_DECL boss_lajAI : public ScriptedAI +{ + boss_lajAI(Creature *c) : ScriptedAI(c) { Reset(); } + + bool CanSummon; + uint32 Teleport_Timer; + uint32 Summon_Timer; + uint32 Transform_Timer; + uint32 Allergic_Timer; + + void Reset() + { + m_creature->SetUInt32Value(UNIT_FIELD_DISPLAYID,MODEL_DEFAULT); + m_creature->ApplySpellImmune(0, IMMUNITY_SCHOOL, SPELL_SCHOOL_MASK_SHADOW, true); + m_creature->ApplySpellImmune(0, IMMUNITY_SCHOOL, SPELL_SCHOOL_MASK_ARCANE, false); + m_creature->ApplySpellImmune(0, IMMUNITY_SCHOOL, SPELL_SCHOOL_MASK_FIRE, false); + m_creature->ApplySpellImmune(0, IMMUNITY_SCHOOL, SPELL_SCHOOL_MASK_FROST, false); + m_creature->ApplySpellImmune(0, IMMUNITY_SCHOOL, SPELL_SCHOOL_MASK_NATURE, false); + + CanSummon = false; + Teleport_Timer = 20000; + Summon_Timer = 2500; + Transform_Timer = 30000; + Allergic_Timer = 5000; + } + + void DoTransform() + { + switch(rand()%5) + { + case 0: + m_creature->SetUInt32Value(UNIT_FIELD_DISPLAYID,MODEL_DEFAULT); + m_creature->ApplySpellImmune(0, IMMUNITY_SCHOOL, SPELL_SCHOOL_MASK_SHADOW, true); + m_creature->ApplySpellImmune(0, IMMUNITY_SCHOOL, SPELL_SCHOOL_MASK_ARCANE, false); + m_creature->ApplySpellImmune(0, IMMUNITY_SCHOOL, SPELL_SCHOOL_MASK_FIRE, false); + m_creature->ApplySpellImmune(0, IMMUNITY_SCHOOL, SPELL_SCHOOL_MASK_FROST, false); + m_creature->ApplySpellImmune(0, IMMUNITY_SCHOOL, SPELL_SCHOOL_MASK_NATURE, false); + break; + case 1: + m_creature->SetUInt32Value(UNIT_FIELD_DISPLAYID,MODEL_ARCANE); + m_creature->ApplySpellImmune(0, IMMUNITY_SCHOOL, SPELL_SCHOOL_MASK_SHADOW, false); + m_creature->ApplySpellImmune(0, IMMUNITY_SCHOOL, SPELL_SCHOOL_MASK_ARCANE, true); + m_creature->ApplySpellImmune(0, IMMUNITY_SCHOOL, SPELL_SCHOOL_MASK_FIRE, false); + m_creature->ApplySpellImmune(0, IMMUNITY_SCHOOL, SPELL_SCHOOL_MASK_FROST, false); + m_creature->ApplySpellImmune(0, IMMUNITY_SCHOOL, SPELL_SCHOOL_MASK_NATURE, false); + break; + case 2: + m_creature->SetUInt32Value(UNIT_FIELD_DISPLAYID,MODEL_FIRE); + m_creature->ApplySpellImmune(0, IMMUNITY_SCHOOL, SPELL_SCHOOL_MASK_SHADOW, false); + m_creature->ApplySpellImmune(0, IMMUNITY_SCHOOL, SPELL_SCHOOL_MASK_ARCANE, false); + m_creature->ApplySpellImmune(0, IMMUNITY_SCHOOL, SPELL_SCHOOL_MASK_FIRE, true); + m_creature->ApplySpellImmune(0, IMMUNITY_SCHOOL, SPELL_SCHOOL_MASK_FROST, false); + m_creature->ApplySpellImmune(0, IMMUNITY_SCHOOL, SPELL_SCHOOL_MASK_NATURE, false); + break; + case 3: + m_creature->SetUInt32Value(UNIT_FIELD_DISPLAYID,MODEL_FROST); + m_creature->ApplySpellImmune(0, IMMUNITY_SCHOOL, SPELL_SCHOOL_MASK_SHADOW, false); + m_creature->ApplySpellImmune(0, IMMUNITY_SCHOOL, SPELL_SCHOOL_MASK_ARCANE, false); + m_creature->ApplySpellImmune(0, IMMUNITY_SCHOOL, SPELL_SCHOOL_MASK_FIRE, false); + m_creature->ApplySpellImmune(0, IMMUNITY_SCHOOL, SPELL_SCHOOL_MASK_FROST, true); + m_creature->ApplySpellImmune(0, IMMUNITY_SCHOOL, SPELL_SCHOOL_MASK_NATURE, false); + break; + case 4: + m_creature->SetUInt32Value(UNIT_FIELD_DISPLAYID,MODEL_NATURE); + m_creature->ApplySpellImmune(0, IMMUNITY_SCHOOL, SPELL_SCHOOL_MASK_SHADOW, false); + m_creature->ApplySpellImmune(0, IMMUNITY_SCHOOL, SPELL_SCHOOL_MASK_ARCANE, false); + m_creature->ApplySpellImmune(0, IMMUNITY_SCHOOL, SPELL_SCHOOL_MASK_FIRE, false); + m_creature->ApplySpellImmune(0, IMMUNITY_SCHOOL, SPELL_SCHOOL_MASK_FROST, false); + m_creature->ApplySpellImmune(0, IMMUNITY_SCHOOL, SPELL_SCHOOL_MASK_NATURE, true); + break; + } + } + + void DoSummons() + { + switch(rand()%4) + { + case 0: + DoCast(m_creature,SPELL_SUMMON_LASHER_1,true); + DoCast(m_creature,SPELL_SUMMON_FLAYER_1,true); + break; + case 1: + DoCast(m_creature,SPELL_SUMMON_LASHER_2,true); + DoCast(m_creature,SPELL_SUMMON_FLAYER_2,true); + break; + case 2: + DoCast(m_creature,SPELL_SUMMON_LASHER_3,true); + DoCast(m_creature,SPELL_SUMMON_FLAYER_3,true); + break; + case 3: + DoCast(m_creature,SPELL_SUMMON_LASHER_4,true); + DoCast(m_creature,SPELL_SUMMON_FLAYER_4,true); + break; + } + CanSummon = false; + } + + void Aggro(Unit *who) + { + } + + void UpdateAI(const uint32 diff) + { + if( !m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + if( CanSummon ) + { + if( Summon_Timer < diff ) + { + DoTextEmote(EMOTE_SUMMON,NULL); + DoSummons(); + Summon_Timer = 2500; + }else Summon_Timer -= diff; + } + + if( Allergic_Timer < diff ) + { + DoCast(m_creature->getVictim(),SPELL_ALLERGIC_REACTION); + Allergic_Timer = 25000+rand()%15000; + }else Allergic_Timer -= diff; + + if( Teleport_Timer < diff ) + { + DoCast(m_creature,SPELL_TELEPORT_SELF); + Teleport_Timer = 30000+rand()%10000; + CanSummon = true; + }else Teleport_Timer -= diff; + + if( Transform_Timer < diff ) + { + DoTransform(); + Transform_Timer = 25000+rand()%15000; + }else Transform_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; + +CreatureAI* GetAI_boss_laj(Creature *_Creature) +{ + return new boss_lajAI (_Creature); +} + +void AddSC_boss_laj() +{ + Script *newscript; + + newscript = new Script; + newscript->Name="boss_laj"; + newscript->GetAI = GetAI_boss_laj; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/tempest_keep/botanica/boss_warp_splinter.cpp b/src/bindings/scripts/scripts/zone/tempest_keep/botanica/boss_warp_splinter.cpp index ed1f6458faa..a9eb4a7cc17 100644 --- a/src/bindings/scripts/scripts/zone/tempest_keep/botanica/boss_warp_splinter.cpp +++ b/src/bindings/scripts/scripts/zone/tempest_keep/botanica/boss_warp_splinter.cpp @@ -1,288 +1,288 @@ -/* Copyright (C) 2006,2007 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Warp_Splinter -SD%Complete: 80 -SDComment: Includes Sapling (need some better control with these). Spells for boss possibly need some rework. -SDCategory: Tempest Keep, The Botanica -EndScriptData */ - -#include "precompiled.h" - -/*##### -# mob_treant (Sapling) -#####*/ - -struct MANGOS_DLL_DECL mob_treantAI : public ScriptedAI -{ - mob_treantAI (Creature *c) : ScriptedAI(c) - { - WarpGuid = 0; - Reset(); - } - - uint64 WarpGuid; - - void Reset() - { - m_creature->SetSpeed( MOVE_RUN, 0.5f, true); - m_creature->SetUnitMovementFlags(0); - } - - void Aggro(Unit *who) - { - return; - } - - void MoveInLineOfSight(Unit *who) - { - } - - void UpdateAI(const uint32 diff) - { - //Return since we have no target - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - if (m_creature->getVictim()->GetGUID() != WarpGuid) - DoMeleeAttackIfReady(); - } -}; - -/*##### -# boss_warp_splinter -#####*/ - -#define WAR_STOMP 34716 -#define SUMMON_TREANTS 34727 // DBC: 34727, 34731, 34733, 34734, 34736, 34739, 34741 (with Ancestral Life spell 34742) // won't work (guardian summon) -#define ARCANE_VOLLEY 35059 //37078, 34785 //must additional script them (because Splinter eats them after 20 sec ^) -#define SPELL_HEAL_FATHER 6262 - -#define CREATURE_TREANT 19949 - -#define SAY_COMBAT_START "Who disturbs this sanctuary?" -#define SOUND_COMBAT_START 11230 - -#define SAY_SLAY_1 "You must die! But wait: this does not-- No, no... you must die!" -#define SOUND_SLAY_1 11231 -#define SAY_SLAY_2 "What am I doing? Why do I..." -#define SOUND_SLAY_2 11232 - -#define SAY_SUMMON_1 "Children, come to me!" -#define SOUND_SUMMON_1 11233 -#define SAY_SUMMON_2 "Maybe this is not-- No, we fight! Come to my aid." -#define SOUND_SUMMON_2 11234 - -#define SAY_DEATH "So... confused. Do not... belong here!" -#define SOUND_DEATH 11235 - -#define TREANT_SPAWN_DIST 50 //50 yards from Warp Splinter's spawn point - -float treant_pos[6][3] = -{ - {24.301233, 427.221100, -27.060635}, - {16.795492, 359.678802, -27.355425}, - {53.493484, 345.381470, -26.196192}, - {61.867096, 439.362732, -25.921030}, - {109.861877, 423.201630, -27.356019}, - {106.780159, 355.582581, -27.593357} -}; - -struct MANGOS_DLL_DECL boss_warp_splinterAI : public ScriptedAI -{ - boss_warp_splinterAI(Creature *c) : ScriptedAI(c) - { - Treant_Spawn_Pos_X = c->GetPositionX(); - Treant_Spawn_Pos_Y = c->GetPositionY(); - Reset(); - } - - uint32 War_Stomp_Timer; - uint32 Summon_Treants_Timer; - uint32 Arcane_Volley_Timer; - uint32 CheckTreantLOS_Timer; - uint32 TreantLife_Timer; - uint64 Treant_GUIDs[6]; - - float Treant_Spawn_Pos_X; - float Treant_Spawn_Pos_Y; - - - void Reset() - { - War_Stomp_Timer = 60000; - Summon_Treants_Timer = 45000; - Arcane_Volley_Timer = 140000; - CheckTreantLOS_Timer = 1000; - TreantLife_Timer = 999999; - - for(int i = 0; i < 6; ++i) - Treant_GUIDs[i] = 0; - - m_creature->SetSpeed( MOVE_RUN, 0.7f, true); - } - - void Aggro(Unit *who) - { - DoYell(SAY_COMBAT_START,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_COMBAT_START); - } - - // On Killed Unit - void KilledUnit(Unit* victim) - { - switch(rand()%2) - { - case 0: - DoYell(SAY_SLAY_1,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature, SOUND_SLAY_1); - break; - case 1: - DoYell(SAY_SLAY_2,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature, SOUND_SLAY_2); - break; - } - } - - void JustDied(Unit* Killer) - { - DoYell(SAY_DEATH,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature, SOUND_DEATH); - } - - void SummonTreants() - { - for(int i = 0; i < 6; ++i) - { - float angle = (M_PI / 3) * i; - - float X = Treant_Spawn_Pos_X + TREANT_SPAWN_DIST * cos(angle); - float Y = Treant_Spawn_Pos_Y + TREANT_SPAWN_DIST * sin(angle); - //float Z = m_creature->GetMap()->GetHeight(X,Y, m_creature->GetPositionZ()); - //float Z = m_creature->GetPositionZ(); - float O = - m_creature->GetAngle(X,Y); - - Creature* pTreant = m_creature->SummonCreature(CREATURE_TREANT,treant_pos[i][0],treant_pos[i][1],treant_pos[i][2],O,TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN,40000); - if(pTreant) - { - //pTreant->GetMotionMaster()->Mutate(new TargetedMovementGenerator(*m_creature)); - pTreant->AddThreat(m_creature, 0.1f); - Treant_GUIDs[i] = pTreant->GetGUID(); - ((mob_treantAI*)pTreant->AI())->WarpGuid = m_creature->GetGUID(); - } - } - - switch(rand()%2) - { - case 0: - DoYell(SAY_SUMMON_1,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_SUMMON_1); - break; - case 1: - DoYell(SAY_SUMMON_2,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_SUMMON_2); - break; - } - } - - // Warp Splinter eat treants if they are near him - void EatTreant() - { - for( int i=0; i<6; ++i ) - { - Unit *pTreant = Unit::GetUnit(*m_creature, Treant_GUIDs[i]); - - if( pTreant ) - { - if( m_creature->IsWithinDistInMap(pTreant, 5)) - { - // 2) Heal Warp Splinter - int32 CurrentHP_Treant = (int32)pTreant->GetHealth(); - m_creature->CastCustomSpell(m_creature,SPELL_HEAL_FATHER,&CurrentHP_Treant, 0, 0, true,0 ,0, m_creature->GetGUID()); - - // 3) Kill Treant - pTreant->DealDamage(pTreant, pTreant->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); - } - } - } - } - - void UpdateAI(const uint32 diff) - { - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - //Check for War Stomp - if(War_Stomp_Timer < diff) - { - DoCast(m_creature->getVictim(),WAR_STOMP); - War_Stomp_Timer = 60000; - } - else War_Stomp_Timer -= diff; - - //Check for Arcane Volley - if(Arcane_Volley_Timer < diff) - { - DoCast(m_creature->getVictim(),ARCANE_VOLLEY); - Arcane_Volley_Timer = 40000+((rand()%20)*1000); - } - else Arcane_Volley_Timer -= diff; - - //Check for Summon Treants - if(Summon_Treants_Timer < diff) - { - SummonTreants(); - Summon_Treants_Timer = 45000; - } - else Summon_Treants_Timer -= diff; - - // I check if there is a Treant in Warp Splinter's LOS, so he can eat them - if( CheckTreantLOS_Timer < diff) - { - EatTreant(); - CheckTreantLOS_Timer = 1000; - } - else CheckTreantLOS_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; - -CreatureAI* GetAI_boss_warp_splinter(Creature *_Creature) -{ - return new boss_warp_splinterAI (_Creature); -} - -CreatureAI* GetAI_mob_treant(Creature *_Creature) -{ - return new mob_treantAI (_Creature); -} - -void AddSC_boss_warp_splinter() -{ - Script *newscript; - - newscript = new Script; - newscript->Name="boss_warp_splinter"; - newscript->GetAI = GetAI_boss_warp_splinter; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="mob_warp_splinter_treant"; - newscript->GetAI = GetAI_mob_treant; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006,2007 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Warp_Splinter +SD%Complete: 80 +SDComment: Includes Sapling (need some better control with these). Spells for boss possibly need some rework. +SDCategory: Tempest Keep, The Botanica +EndScriptData */ + +#include "precompiled.h" + +/*##### +# mob_treant (Sapling) +#####*/ + +struct MANGOS_DLL_DECL mob_treantAI : public ScriptedAI +{ + mob_treantAI (Creature *c) : ScriptedAI(c) + { + WarpGuid = 0; + Reset(); + } + + uint64 WarpGuid; + + void Reset() + { + m_creature->SetSpeed( MOVE_RUN, 0.5f, true); + m_creature->SetUnitMovementFlags(0); + } + + void Aggro(Unit *who) + { + return; + } + + void MoveInLineOfSight(Unit *who) + { + } + + void UpdateAI(const uint32 diff) + { + //Return since we have no target + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + if (m_creature->getVictim()->GetGUID() != WarpGuid) + DoMeleeAttackIfReady(); + } +}; + +/*##### +# boss_warp_splinter +#####*/ + +#define WAR_STOMP 34716 +#define SUMMON_TREANTS 34727 // DBC: 34727, 34731, 34733, 34734, 34736, 34739, 34741 (with Ancestral Life spell 34742) // won't work (guardian summon) +#define ARCANE_VOLLEY 35059 //37078, 34785 //must additional script them (because Splinter eats them after 20 sec ^) +#define SPELL_HEAL_FATHER 6262 + +#define CREATURE_TREANT 19949 + +#define SAY_COMBAT_START "Who disturbs this sanctuary?" +#define SOUND_COMBAT_START 11230 + +#define SAY_SLAY_1 "You must die! But wait: this does not-- No, no... you must die!" +#define SOUND_SLAY_1 11231 +#define SAY_SLAY_2 "What am I doing? Why do I..." +#define SOUND_SLAY_2 11232 + +#define SAY_SUMMON_1 "Children, come to me!" +#define SOUND_SUMMON_1 11233 +#define SAY_SUMMON_2 "Maybe this is not-- No, we fight! Come to my aid." +#define SOUND_SUMMON_2 11234 + +#define SAY_DEATH "So... confused. Do not... belong here!" +#define SOUND_DEATH 11235 + +#define TREANT_SPAWN_DIST 50 //50 yards from Warp Splinter's spawn point + +float treant_pos[6][3] = +{ + {24.301233, 427.221100, -27.060635}, + {16.795492, 359.678802, -27.355425}, + {53.493484, 345.381470, -26.196192}, + {61.867096, 439.362732, -25.921030}, + {109.861877, 423.201630, -27.356019}, + {106.780159, 355.582581, -27.593357} +}; + +struct MANGOS_DLL_DECL boss_warp_splinterAI : public ScriptedAI +{ + boss_warp_splinterAI(Creature *c) : ScriptedAI(c) + { + Treant_Spawn_Pos_X = c->GetPositionX(); + Treant_Spawn_Pos_Y = c->GetPositionY(); + Reset(); + } + + uint32 War_Stomp_Timer; + uint32 Summon_Treants_Timer; + uint32 Arcane_Volley_Timer; + uint32 CheckTreantLOS_Timer; + uint32 TreantLife_Timer; + uint64 Treant_GUIDs[6]; + + float Treant_Spawn_Pos_X; + float Treant_Spawn_Pos_Y; + + + void Reset() + { + War_Stomp_Timer = 60000; + Summon_Treants_Timer = 45000; + Arcane_Volley_Timer = 140000; + CheckTreantLOS_Timer = 1000; + TreantLife_Timer = 999999; + + for(int i = 0; i < 6; ++i) + Treant_GUIDs[i] = 0; + + m_creature->SetSpeed( MOVE_RUN, 0.7f, true); + } + + void Aggro(Unit *who) + { + DoYell(SAY_COMBAT_START,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_COMBAT_START); + } + + // On Killed Unit + void KilledUnit(Unit* victim) + { + switch(rand()%2) + { + case 0: + DoYell(SAY_SLAY_1,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature, SOUND_SLAY_1); + break; + case 1: + DoYell(SAY_SLAY_2,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature, SOUND_SLAY_2); + break; + } + } + + void JustDied(Unit* Killer) + { + DoYell(SAY_DEATH,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature, SOUND_DEATH); + } + + void SummonTreants() + { + for(int i = 0; i < 6; ++i) + { + float angle = (M_PI / 3) * i; + + float X = Treant_Spawn_Pos_X + TREANT_SPAWN_DIST * cos(angle); + float Y = Treant_Spawn_Pos_Y + TREANT_SPAWN_DIST * sin(angle); + //float Z = m_creature->GetMap()->GetHeight(X,Y, m_creature->GetPositionZ()); + //float Z = m_creature->GetPositionZ(); + float O = - m_creature->GetAngle(X,Y); + + Creature* pTreant = m_creature->SummonCreature(CREATURE_TREANT,treant_pos[i][0],treant_pos[i][1],treant_pos[i][2],O,TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN,40000); + if(pTreant) + { + //pTreant->GetMotionMaster()->Mutate(new TargetedMovementGenerator(*m_creature)); + pTreant->AddThreat(m_creature, 0.1f); + Treant_GUIDs[i] = pTreant->GetGUID(); + ((mob_treantAI*)pTreant->AI())->WarpGuid = m_creature->GetGUID(); + } + } + + switch(rand()%2) + { + case 0: + DoYell(SAY_SUMMON_1,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_SUMMON_1); + break; + case 1: + DoYell(SAY_SUMMON_2,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_SUMMON_2); + break; + } + } + + // Warp Splinter eat treants if they are near him + void EatTreant() + { + for( int i=0; i<6; ++i ) + { + Unit *pTreant = Unit::GetUnit(*m_creature, Treant_GUIDs[i]); + + if( pTreant ) + { + if( m_creature->IsWithinDistInMap(pTreant, 5)) + { + // 2) Heal Warp Splinter + int32 CurrentHP_Treant = (int32)pTreant->GetHealth(); + m_creature->CastCustomSpell(m_creature,SPELL_HEAL_FATHER,&CurrentHP_Treant, 0, 0, true,0 ,0, m_creature->GetGUID()); + + // 3) Kill Treant + pTreant->DealDamage(pTreant, pTreant->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); + } + } + } + } + + void UpdateAI(const uint32 diff) + { + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + //Check for War Stomp + if(War_Stomp_Timer < diff) + { + DoCast(m_creature->getVictim(),WAR_STOMP); + War_Stomp_Timer = 60000; + } + else War_Stomp_Timer -= diff; + + //Check for Arcane Volley + if(Arcane_Volley_Timer < diff) + { + DoCast(m_creature->getVictim(),ARCANE_VOLLEY); + Arcane_Volley_Timer = 40000+((rand()%20)*1000); + } + else Arcane_Volley_Timer -= diff; + + //Check for Summon Treants + if(Summon_Treants_Timer < diff) + { + SummonTreants(); + Summon_Treants_Timer = 45000; + } + else Summon_Treants_Timer -= diff; + + // I check if there is a Treant in Warp Splinter's LOS, so he can eat them + if( CheckTreantLOS_Timer < diff) + { + EatTreant(); + CheckTreantLOS_Timer = 1000; + } + else CheckTreantLOS_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; + +CreatureAI* GetAI_boss_warp_splinter(Creature *_Creature) +{ + return new boss_warp_splinterAI (_Creature); +} + +CreatureAI* GetAI_mob_treant(Creature *_Creature) +{ + return new mob_treantAI (_Creature); +} + +void AddSC_boss_warp_splinter() +{ + Script *newscript; + + newscript = new Script; + newscript->Name="boss_warp_splinter"; + newscript->GetAI = GetAI_boss_warp_splinter; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="mob_warp_splinter_treant"; + newscript->GetAI = GetAI_mob_treant; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/tempest_keep/the_eye/boss_astromancer.cpp b/src/bindings/scripts/scripts/zone/tempest_keep/the_eye/boss_astromancer.cpp index c671343ad2c..987e9939f3d 100644 --- a/src/bindings/scripts/scripts/zone/tempest_keep/the_eye/boss_astromancer.cpp +++ b/src/bindings/scripts/scripts/zone/tempest_keep/the_eye/boss_astromancer.cpp @@ -1,563 +1,545 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: boss_astromancer -SD%Complete: 75 -SDComment: -SDCategory: Tempest Keep, The Eye -EndScriptData */ - -#include "precompiled.h" -#include "def_the_eye.h" - -#define SPELL_ARCANE_MISSILES 33031 -#define SPELL_MARK_OF_THE_ASTROMANCER 33045 -#define MARK_OF_SOLARIAN 33023 -#define SPELL_BLINDING_LIGHT 33009 -#define SPELL_FEAR 29321 -#define SPELL_VOID_BOLT 39329 - -#define SAY_PHASE1 "Tal anu'men no Sin'dorei!" -#define SOUND_PHASE1 11134 -#define SAY_PHASE2 "I will crush your delusions of grandeur!" -#define SOUND_PHASE2 11140 -#define SAY_PHASE21 "Ha ha ha! You are hopelessly outmatched!" -#define SOUND_PHASE21 11139 - -#define SAY_VOID "Enough of this! Now I call upon the fury of the cosmos itself." -//#define SOUND_VOID Not found :( -#define SAY_VOID1 "I become ONE... with the VOID!" -//#define SOUND_VOID1 Not found :( - -#define SAY_KILL1 "Your soul belongs to the Abyss!" -#define SOUND_KILL1 11136 -#define SAY_KILL2 "By the blood of the Highborne!" -#define SOUND_KILL2 11137 -#define SAY_KILL3 "For the Sunwell!" -#define SOUND_KILL3 11138 -#define SAY_DEATH "The warmth of the sun... awaits." -#define SOUND_DEATH 11135 - -#define CENTER_X 432.909f -#define CENTER_Y -373.424f -#define CENTER_Z 17.9608f -#define CENTER_O 1.06421f -#define SMALL_PORTAL_RADIUS 12.6f -#define LARGE_PORTAL_RADIUS 26.0f -#define PORTAL_Z 17.005f - -#define SOLARIUM_AGENT 18925 -#define SOLARIUM_PRIEST 18806 -#define ASTROMANCER_SOLARIAN_SPOTLIGHT 18928 -#define SPELL_SPOTLIGHT 25824 -#define MODEL_HUMAN 18239 -#define MODEL_VOIDWALKER 18988 - -#define SOLARIUM_HEAL 41378 -#define SOLARIUM_SMITE 31740 -#define SOLARIUM_SILENCE 37160 - -#define WV_ARMOR 31000 -#define MIN_RANGE_FOR_DOT_JUMP 20.0f - -struct MANGOS_DLL_DECL boss_high_astromancer_solarianAI : public ScriptedAI -{ - boss_high_astromancer_solarianAI(Creature *c) : ScriptedAI(c) - { - pInstance = ((ScriptedInstance*)c->GetInstanceData()); - - defaultarmor=m_creature->GetArmor(); - defaultsize=m_creature->GetFloatValue(OBJECT_FIELD_SCALE_X); - Reset(); - } - - ScriptedInstance *pInstance; - - uint32 ArcaneMissiles_Timer; - uint32 MarkOfTheAstromancer_Timer; - uint32 BlindingLight_Timer; - uint32 Fear_Timer; - uint32 VoidBolt_Timer; - uint32 Phase1_Timer; - uint32 Phase2_Timer; - uint32 Phase3_Timer; - uint32 AppearDelay_Timer; - uint32 MarkOfTheSolarian_Timer; - uint32 Jump_Timer; - uint32 defaultarmor; - - float defaultsize; - - bool AppearDelay; - - uint8 Phase; - - uint64 WrathTarget; - - float Portals[3][3]; - - void Reset() - { - WrathTarget=0; - ArcaneMissiles_Timer = 2000; - MarkOfTheAstromancer_Timer = 15000; - BlindingLight_Timer = 41000; - Fear_Timer = 20000; - VoidBolt_Timer = 10000; - Phase1_Timer = 50000; - Phase2_Timer = 10000; - Phase3_Timer = 15000; - AppearDelay_Timer = 2000; - AppearDelay = false; - MarkOfTheSolarian_Timer=45000; - Jump_Timer=8000; - Phase = 1; - - if(pInstance) - pInstance->SetData(DATA_HIGHASTROMANCERSOLARIANEVENT, NOT_STARTED); - - m_creature->SetArmor(defaultarmor); - m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - m_creature->SetVisibility(VISIBILITY_ON); - m_creature->SetFloatValue(OBJECT_FIELD_SCALE_X, defaultsize); - m_creature->SetUInt32Value(UNIT_FIELD_DISPLAYID, MODEL_HUMAN); - } - - void StartEvent() - { - DoYell(SAY_PHASE1, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_PHASE1); - - if(pInstance) - pInstance->SetData(DATA_HIGHASTROMANCERSOLARIANEVENT, IN_PROGRESS); - } - - void KilledUnit(Unit *victim) - { - switch(rand()%3) - { - case 0: - DoYell(SAY_KILL1, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_KILL1); - break; - case 1: - DoYell(SAY_KILL2, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_KILL2); - break; - case 2: - DoYell(SAY_KILL3, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_KILL3); - break; - } - } - - void JustDied(Unit *victim) - { - m_creature->SetFloatValue(OBJECT_FIELD_SCALE_X, defaultsize); - m_creature->SetUInt32Value(UNIT_FIELD_DISPLAYID, MODEL_HUMAN); - DoYell(SAY_DEATH, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_DEATH); - - if(pInstance) - pInstance->SetData(DATA_HIGHASTROMANCERSOLARIANEVENT, NOT_STARTED); - } - - void Aggro(Unit *who) - { - StartEvent(); - } - - void SummonMinion(uint32 entry, float x, float y, float z) - { - Creature* Summoned = m_creature->SummonCreature(entry, x, y, z, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000); - if(Summoned) - { - Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0); - if(target) - Summoned->AI()->AttackStart(target); - } - } - - float Portal_X(float radius) - { - if ((rand()%2)==1) radius = -radius; - return (radius * (float)(rand()%100)/100.0f + CENTER_X); - } - - float Portal_Y(float x, float radius) - { - float z; - - switch(rand()%2) - { - case 0: z = 1; break; - case 1: z = -1; break; - } - return (z*sqrt(radius*radius - (x - CENTER_X)*(x - CENTER_X)) + CENTER_Y); - } - - void UpdateAI(const uint32 diff) - { - if(!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - if (AppearDelay) - { - m_creature->StopMoving(); - m_creature->AttackStop(); - if (AppearDelay_Timer < diff) - { - AppearDelay = false; - if (Phase == 2) - { - switch (rand()%2) - { - case 0: - DoYell(SAY_PHASE2, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_PHASE2); - break; - case 1: - DoYell(SAY_PHASE21, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_PHASE21); - break; - } - m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - m_creature->SetVisibility(VISIBILITY_OFF); - } - if (Phase == 3) - Phase = 1; - - AppearDelay_Timer = 2000; - }else AppearDelay_Timer -= diff; - } - - //the jumping of the dot part of the wrath of the astromancer - if(WrathTarget) - { - if(Jump_Timer< diff) - { - std::list& m_threatlist = m_creature->getThreatManager().getThreatList(); - bool hasJumped = false; - - Unit* target = Unit::GetUnit((*m_creature),WrathTarget); - if(target && target->isAlive()) - { - for(std::list::iterator iter = m_threatlist.begin();iter!=m_threatlist.end();++iter) - { - Unit* currentUnit=Unit::GetUnit((*m_creature),(*iter)->getUnitGuid()); - if(currentUnit) - { - if(currentUnit->IsWithinDistInMap(target,MIN_RANGE_FOR_DOT_JUMP)&¤tUnit->isAlive()&¤tUnit!=target) - { - m_creature->CastSpell(currentUnit,SPELL_MARK_OF_THE_ASTROMANCER, false,0,0,m_creature->GetGUID()); - - Jump_Timer=8000; - WrathTarget=currentUnit->GetGUID(); - hasJumped = true; - break; - } - } - } - } - - if(!hasJumped) - WrathTarget = 0; - }else Jump_Timer -= diff; - } - - if (Phase == 1) - { - //ArcaneMissiles_Timer - if (ArcaneMissiles_Timer < diff) - { - //Solarian casts Arcane Missiles on on random targets in the raid. - Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0); - if (!m_creature->HasInArc(2.5f, target)) - target = m_creature->getVictim(); - if (target) - DoCast(target, SPELL_ARCANE_MISSILES); - - ArcaneMissiles_Timer = 3000; - }else ArcaneMissiles_Timer -= diff; - - //MarkOfTheSolarian_Timer - if (MarkOfTheSolarian_Timer < diff) - { - DoCast(m_creature->getVictim(), MARK_OF_SOLARIAN); - MarkOfTheSolarian_Timer = 45000; - }else MarkOfTheSolarian_Timer -= diff; - - //MarkOfTheAstromancer_Timer - if (MarkOfTheAstromancer_Timer < diff) - { - //A debuff that lasts for 5 seconds, cast several times each phase on a random raid member, but not the main tank - Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 1); - - if(target) - { - DoCast(target, SPELL_MARK_OF_THE_ASTROMANCER); - - WrathTarget=target->GetGUID(); - Jump_Timer=8000; - } - - MarkOfTheAstromancer_Timer = 15000; - }else MarkOfTheAstromancer_Timer -= diff; - - //BlindingLight_Timer - if (BlindingLight_Timer < diff) - { - //She casts this spell every 45 seconds. It is a kind of Moonfire spell, which she strikes down on the whole raid simultaneously. It hits everyone in the raid for 2280 to 2520 arcane damage. - DoCast(m_creature->getVictim(), SPELL_BLINDING_LIGHT); - - BlindingLight_Timer = 45000; - }else BlindingLight_Timer -= diff; - - //Phase1_Timer - if (Phase1_Timer < diff) - { - Phase = 2; - Phase1_Timer = 50000; - //After these 50 seconds she portals to the middle of the room and disappears, leaving 3 light portals behind. - m_creature->GetMotionMaster()->Clear(); - m_creature->Relocate(CENTER_X, CENTER_Y, CENTER_Z, CENTER_O); - for(int i=0; i<=2; i++) - { - if (!i) - { - Portals[i][0] = Portal_X(SMALL_PORTAL_RADIUS); - Portals[i][1] = Portal_Y(Portals[i][0], SMALL_PORTAL_RADIUS); - Portals[i][2] = CENTER_Z; - }else - { - Portals[i][0] = Portal_X(LARGE_PORTAL_RADIUS); - Portals[i][1] = Portal_Y(Portals[i][0], LARGE_PORTAL_RADIUS); - Portals[i][2] = PORTAL_Z; - } - } - if((abs(Portals[2][0] - Portals[1][0]) < 7) - && (abs(Portals[2][1] - Portals[1][1]) < 7)) - { - int i=1; - if(abs(CENTER_X + 26.0f - Portals[2][0]) < 7) - i = -1; - Portals[2][0] = Portals[2][0]+7*i; - Portals[2][1] = Portal_Y(Portals[2][0], LARGE_PORTAL_RADIUS); - } - for (int i=0; i<=2; i++) - { - Creature* Summoned = m_creature->SummonCreature(ASTROMANCER_SOLARIAN_SPOTLIGHT, Portals[i][0], Portals[i][1], Portals[i][2], CENTER_O, TEMPSUMMON_TIMED_DESPAWN, Phase2_Timer+Phase3_Timer+AppearDelay_Timer+1700); - if(Summoned) - { - Summoned->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - Summoned->CastSpell(Summoned, SPELL_SPOTLIGHT, false); - } - } - AppearDelay = true; - }else Phase1_Timer-=diff; - } - else if(Phase == 2) - { - //10 seconds after Solarian disappears, 12 mobs spawn out of the three portals. - m_creature->AttackStop(); - m_creature->StopMoving(); - if (Phase2_Timer < diff) - { - Phase = 3; - for (int i=0; i<=2; i++) - for (int j=1; j<=4; j++) - SummonMinion(SOLARIUM_AGENT, Portals[i][0], Portals[i][1], Portals[i][2]); - Phase2_Timer = 10000; - } else Phase2_Timer -= diff; - } - else if(Phase == 3) - { - //Check Phase3_Timer - if(Phase3_Timer < diff) - { - //15 seconds later Solarian reappears out of one of the 3 portals. Simultaneously, 2 healers appear in the two other portals. - m_creature->AttackStop(); - m_creature->StopMoving(); - int i = rand()%3; - m_creature->GetMotionMaster()->Clear(); - m_creature->Relocate(Portals[i][0], Portals[i][1], Portals[i][2], CENTER_O); - - for (int j=0; j<=2; j++) - if (j!=i) - SummonMinion(SOLARIUM_PRIEST, Portals[j][0], Portals[j][1], Portals[j][2]); - - m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - m_creature->SetVisibility(VISIBILITY_ON); - - DoYell(SAY_PHASE1, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_PHASE1); - AppearDelay = true; - Phase3_Timer = 15000; - }else Phase3_Timer -= diff; - } - else if(Phase == 4) - { - //Fear_Timer - if (Fear_Timer < diff) - { - DoCast(m_creature->getVictim(), SPELL_FEAR); - Fear_Timer = 20000; - }else Fear_Timer -= diff; - - //VoidBolt_Timer - if (VoidBolt_Timer < diff) - { - DoCast(m_creature->getVictim(), SPELL_VOID_BOLT); - VoidBolt_Timer = 10000; - }else VoidBolt_Timer -= diff; - } - - //When Solarian reaches 20% she will transform into a huge void walker. - if(Phase != 4 && ((m_creature->GetHealth()*100 / m_creature->GetMaxHealth())<20)) - { - Phase = 4; - - //To make sure she wont be invisible or not selecatble - m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - m_creature->SetVisibility(VISIBILITY_ON); - switch(rand()%2) - { - case 0: - DoYell(SAY_VOID, LANG_UNIVERSAL, NULL); - break; - case 1: - DoYell(SAY_VOID1, LANG_UNIVERSAL, NULL); - break; - } - - m_creature->SetArmor(WV_ARMOR); - m_creature->SetUInt32Value(UNIT_FIELD_DISPLAYID, MODEL_VOIDWALKER); - m_creature->SetFloatValue(OBJECT_FIELD_SCALE_X, defaultsize*2.5f); - } - DoMeleeAttackIfReady(); - } -}; - -struct MANGOS_DLL_DECL mob_solarium_priestAI : public ScriptedAI -{ - mob_solarium_priestAI(Creature *c) : ScriptedAI(c) - { - pInstance = ((ScriptedInstance*)c->GetInstanceData()); - Reset(); - } - - ScriptedInstance *pInstance; - - uint32 healTimer; - uint32 holysmiteTimer; - uint32 aoesilenceTimer; - - void Reset() - { - healTimer = 9000; - holysmiteTimer = 1; - aoesilenceTimer = 15000; - } - - void Aggro(Unit *who) - { - } - - void MoveInLineOfSight(Unit *who) - { - if (!who || m_creature->getVictim()) - return; - - if (who->isTargetableForAttack() && who->isInAccessablePlaceFor(m_creature) && m_creature->IsHostileTo(who)) - { - float attackRadius = m_creature->GetAttackDistance(who); - if (m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->GetDistanceZ(who) <= CREATURE_Z_ATTACK_RANGE && m_creature->IsWithinLOSInMap(who)) - { - if(who->HasStealthAura()) - who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); - - DoStartAttackAndMovement(who); - } - } - } - - void UpdateAI(const uint32 diff) - { - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - if (healTimer < diff) - { - Unit* target = NULL; - - switch(rand()%2) - { - case 0: - if(pInstance) - target = Unit::GetUnit((*m_creature), pInstance->GetData64(DATA_ASTROMANCER)); - break; - case 1: - target = m_creature; - break; - } - - if(target) - { - DoCast(target,SOLARIUM_HEAL); - healTimer = 9000; - } - } else healTimer -= diff; - - if(holysmiteTimer < diff) - { - DoCast(m_creature->getVictim(), SOLARIUM_SMITE); - holysmiteTimer = 4000; - } else holysmiteTimer -= diff; - - if (aoesilenceTimer < diff) - { - DoCast(m_creature->getVictim(), SOLARIUM_SILENCE); - aoesilenceTimer = 13000; - } else aoesilenceTimer -= diff; - - DoMeleeAttackIfReady(); - } -}; - -CreatureAI* GetAI_mob_solarium_priest(Creature *_Creature) -{ - return new mob_solarium_priestAI (_Creature); -} - -CreatureAI* GetAI_boss_high_astromancer_solarian(Creature *_Creature) -{ - return new boss_high_astromancer_solarianAI (_Creature); -} - -void AddSC_boss_high_astromancer_solarian() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_high_astromancer_solarian"; - newscript->GetAI = GetAI_boss_high_astromancer_solarian; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="mob_solarium_priest"; - newscript->GetAI = GetAI_mob_solarium_priest; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: boss_astromancer +SD%Complete: 75 +SDComment: +SDCategory: Tempest Keep, The Eye +EndScriptData */ + +#include "precompiled.h" +#include "def_the_eye.h" + +#define SPELL_ARCANE_MISSILES 33031 +#define SPELL_MARK_OF_THE_ASTROMANCER 33045 +#define MARK_OF_SOLARIAN 33023 +#define SPELL_BLINDING_LIGHT 33009 +#define SPELL_FEAR 29321 +#define SPELL_VOID_BOLT 39329 + +#define SAY_PHASE1 "Tal anu'men no Sin'dorei!" +#define SOUND_PHASE1 11134 +#define SAY_PHASE2 "I will crush your delusions of grandeur!" +#define SOUND_PHASE2 11140 +#define SAY_PHASE21 "Ha ha ha! You are hopelessly outmatched!" +#define SOUND_PHASE21 11139 + +#define SAY_VOID "Enough of this! Now I call upon the fury of the cosmos itself." +//#define SOUND_VOID Not found :( +#define SAY_VOID1 "I become ONE... with the VOID!" +//#define SOUND_VOID1 Not found :( + +#define SAY_KILL1 "Your soul belongs to the Abyss!" +#define SOUND_KILL1 11136 +#define SAY_KILL2 "By the blood of the Highborne!" +#define SOUND_KILL2 11137 +#define SAY_KILL3 "For the Sunwell!" +#define SOUND_KILL3 11138 +#define SAY_DEATH "The warmth of the sun... awaits." +#define SOUND_DEATH 11135 + +#define CENTER_X 432.909f +#define CENTER_Y -373.424f +#define CENTER_Z 17.9608f +#define CENTER_O 1.06421f +#define SMALL_PORTAL_RADIUS 12.6f +#define LARGE_PORTAL_RADIUS 26.0f +#define PORTAL_Z 17.005f + +#define SOLARIUM_AGENT 18925 +#define SOLARIUM_PRIEST 18806 +#define ASTROMANCER_SOLARIAN_SPOTLIGHT 18928 +#define SPELL_SPOTLIGHT 25824 +#define MODEL_HUMAN 18239 +#define MODEL_VOIDWALKER 18988 + +#define SOLARIUM_HEAL 41378 +#define SOLARIUM_SMITE 31740 +#define SOLARIUM_SILENCE 37160 + +#define WV_ARMOR 31000 +#define MIN_RANGE_FOR_DOT_JUMP 20.0f + +struct MANGOS_DLL_DECL boss_high_astromancer_solarianAI : public ScriptedAI +{ + boss_high_astromancer_solarianAI(Creature *c) : ScriptedAI(c) + { + pInstance = ((ScriptedInstance*)c->GetInstanceData()); + + defaultarmor=m_creature->GetArmor(); + defaultsize=m_creature->GetFloatValue(OBJECT_FIELD_SCALE_X); + Reset(); + } + + ScriptedInstance *pInstance; + + uint32 ArcaneMissiles_Timer; + uint32 MarkOfTheAstromancer_Timer; + uint32 BlindingLight_Timer; + uint32 Fear_Timer; + uint32 VoidBolt_Timer; + uint32 Phase1_Timer; + uint32 Phase2_Timer; + uint32 Phase3_Timer; + uint32 AppearDelay_Timer; + uint32 MarkOfTheSolarian_Timer; + uint32 Jump_Timer; + uint32 defaultarmor; + + float defaultsize; + + bool AppearDelay; + + uint8 Phase; + + uint64 WrathTarget; + + float Portals[3][3]; + + void Reset() + { + WrathTarget=0; + ArcaneMissiles_Timer = 2000; + MarkOfTheAstromancer_Timer = 15000; + BlindingLight_Timer = 41000; + Fear_Timer = 20000; + VoidBolt_Timer = 10000; + Phase1_Timer = 50000; + Phase2_Timer = 10000; + Phase3_Timer = 15000; + AppearDelay_Timer = 2000; + AppearDelay = false; + MarkOfTheSolarian_Timer=45000; + Jump_Timer=8000; + Phase = 1; + + if(pInstance) + pInstance->SetData(DATA_HIGHASTROMANCERSOLARIANEVENT, NOT_STARTED); + + m_creature->SetArmor(defaultarmor); + m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + m_creature->SetVisibility(VISIBILITY_ON); + m_creature->SetFloatValue(OBJECT_FIELD_SCALE_X, defaultsize); + m_creature->SetUInt32Value(UNIT_FIELD_DISPLAYID, MODEL_HUMAN); + } + + void StartEvent() + { + DoYell(SAY_PHASE1, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_PHASE1); + + if(pInstance) + pInstance->SetData(DATA_HIGHASTROMANCERSOLARIANEVENT, IN_PROGRESS); + } + + void KilledUnit(Unit *victim) + { + switch(rand()%3) + { + case 0: + DoYell(SAY_KILL1, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_KILL1); + break; + case 1: + DoYell(SAY_KILL2, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_KILL2); + break; + case 2: + DoYell(SAY_KILL3, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_KILL3); + break; + } + } + + void JustDied(Unit *victim) + { + m_creature->SetFloatValue(OBJECT_FIELD_SCALE_X, defaultsize); + m_creature->SetUInt32Value(UNIT_FIELD_DISPLAYID, MODEL_HUMAN); + DoYell(SAY_DEATH, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_DEATH); + + if(pInstance) + pInstance->SetData(DATA_HIGHASTROMANCERSOLARIANEVENT, NOT_STARTED); + } + + void Aggro(Unit *who) + { + StartEvent(); + } + + void SummonMinion(uint32 entry, float x, float y, float z) + { + Creature* Summoned = m_creature->SummonCreature(entry, x, y, z, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000); + if(Summoned) + { + Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0); + if(target) + Summoned->AI()->AttackStart(target); + } + } + + float Portal_X(float radius) + { + if ((rand()%2)==1) radius = -radius; + return (radius * (float)(rand()%100)/100.0f + CENTER_X); + } + + float Portal_Y(float x, float radius) + { + float z; + + switch(rand()%2) + { + case 0: z = 1; break; + case 1: z = -1; break; + } + return (z*sqrt(radius*radius - (x - CENTER_X)*(x - CENTER_X)) + CENTER_Y); + } + + void UpdateAI(const uint32 diff) + { + if(!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + if (AppearDelay) + { + m_creature->StopMoving(); + m_creature->AttackStop(); + if (AppearDelay_Timer < diff) + { + AppearDelay = false; + if (Phase == 2) + { + switch (rand()%2) + { + case 0: + DoYell(SAY_PHASE2, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_PHASE2); + break; + case 1: + DoYell(SAY_PHASE21, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_PHASE21); + break; + } + m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + m_creature->SetVisibility(VISIBILITY_OFF); + } + if (Phase == 3) + Phase = 1; + + AppearDelay_Timer = 2000; + }else AppearDelay_Timer -= diff; + } + + //the jumping of the dot part of the wrath of the astromancer + if(WrathTarget) + { + if(Jump_Timer< diff) + { + std::list& m_threatlist = m_creature->getThreatManager().getThreatList(); + bool hasJumped = false; + + Unit* target = Unit::GetUnit((*m_creature),WrathTarget); + if(target && target->isAlive()) + { + for(std::list::iterator iter = m_threatlist.begin();iter!=m_threatlist.end();++iter) + { + Unit* currentUnit=Unit::GetUnit((*m_creature),(*iter)->getUnitGuid()); + if(currentUnit) + { + if(currentUnit->IsWithinDistInMap(target,MIN_RANGE_FOR_DOT_JUMP)&¤tUnit->isAlive()&¤tUnit!=target) + { + m_creature->CastSpell(currentUnit,SPELL_MARK_OF_THE_ASTROMANCER, false,0,0,m_creature->GetGUID()); + + Jump_Timer=8000; + WrathTarget=currentUnit->GetGUID(); + hasJumped = true; + break; + } + } + } + } + + if(!hasJumped) + WrathTarget = 0; + }else Jump_Timer -= diff; + } + + if (Phase == 1) + { + //ArcaneMissiles_Timer + if (ArcaneMissiles_Timer < diff) + { + //Solarian casts Arcane Missiles on on random targets in the raid. + Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0); + if (!m_creature->HasInArc(2.5f, target)) + target = m_creature->getVictim(); + if (target) + DoCast(target, SPELL_ARCANE_MISSILES); + + ArcaneMissiles_Timer = 3000; + }else ArcaneMissiles_Timer -= diff; + + //MarkOfTheSolarian_Timer + if (MarkOfTheSolarian_Timer < diff) + { + DoCast(m_creature->getVictim(), MARK_OF_SOLARIAN); + MarkOfTheSolarian_Timer = 45000; + }else MarkOfTheSolarian_Timer -= diff; + + //MarkOfTheAstromancer_Timer + if (MarkOfTheAstromancer_Timer < diff) + { + //A debuff that lasts for 5 seconds, cast several times each phase on a random raid member, but not the main tank + Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 1); + + if(target) + { + DoCast(target, SPELL_MARK_OF_THE_ASTROMANCER); + + WrathTarget=target->GetGUID(); + Jump_Timer=8000; + } + + MarkOfTheAstromancer_Timer = 15000; + }else MarkOfTheAstromancer_Timer -= diff; + + //BlindingLight_Timer + if (BlindingLight_Timer < diff) + { + //She casts this spell every 45 seconds. It is a kind of Moonfire spell, which she strikes down on the whole raid simultaneously. It hits everyone in the raid for 2280 to 2520 arcane damage. + DoCast(m_creature->getVictim(), SPELL_BLINDING_LIGHT); + + BlindingLight_Timer = 45000; + }else BlindingLight_Timer -= diff; + + //Phase1_Timer + if (Phase1_Timer < diff) + { + Phase = 2; + Phase1_Timer = 50000; + //After these 50 seconds she portals to the middle of the room and disappears, leaving 3 light portals behind. + m_creature->GetMotionMaster()->Clear(); + m_creature->Relocate(CENTER_X, CENTER_Y, CENTER_Z, CENTER_O); + for(int i=0; i<=2; i++) + { + if (!i) + { + Portals[i][0] = Portal_X(SMALL_PORTAL_RADIUS); + Portals[i][1] = Portal_Y(Portals[i][0], SMALL_PORTAL_RADIUS); + Portals[i][2] = CENTER_Z; + }else + { + Portals[i][0] = Portal_X(LARGE_PORTAL_RADIUS); + Portals[i][1] = Portal_Y(Portals[i][0], LARGE_PORTAL_RADIUS); + Portals[i][2] = PORTAL_Z; + } + } + if((abs(Portals[2][0] - Portals[1][0]) < 7) + && (abs(Portals[2][1] - Portals[1][1]) < 7)) + { + int i=1; + if(abs(CENTER_X + 26.0f - Portals[2][0]) < 7) + i = -1; + Portals[2][0] = Portals[2][0]+7*i; + Portals[2][1] = Portal_Y(Portals[2][0], LARGE_PORTAL_RADIUS); + } + for (int i=0; i<=2; i++) + { + Creature* Summoned = m_creature->SummonCreature(ASTROMANCER_SOLARIAN_SPOTLIGHT, Portals[i][0], Portals[i][1], Portals[i][2], CENTER_O, TEMPSUMMON_TIMED_DESPAWN, Phase2_Timer+Phase3_Timer+AppearDelay_Timer+1700); + if(Summoned) + { + Summoned->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + Summoned->CastSpell(Summoned, SPELL_SPOTLIGHT, false); + } + } + AppearDelay = true; + }else Phase1_Timer-=diff; + } + else if(Phase == 2) + { + //10 seconds after Solarian disappears, 12 mobs spawn out of the three portals. + m_creature->AttackStop(); + m_creature->StopMoving(); + if (Phase2_Timer < diff) + { + Phase = 3; + for (int i=0; i<=2; i++) + for (int j=1; j<=4; j++) + SummonMinion(SOLARIUM_AGENT, Portals[i][0], Portals[i][1], Portals[i][2]); + Phase2_Timer = 10000; + } else Phase2_Timer -= diff; + } + else if(Phase == 3) + { + //Check Phase3_Timer + if(Phase3_Timer < diff) + { + //15 seconds later Solarian reappears out of one of the 3 portals. Simultaneously, 2 healers appear in the two other portals. + m_creature->AttackStop(); + m_creature->StopMoving(); + int i = rand()%3; + m_creature->GetMotionMaster()->Clear(); + m_creature->Relocate(Portals[i][0], Portals[i][1], Portals[i][2], CENTER_O); + + for (int j=0; j<=2; j++) + if (j!=i) + SummonMinion(SOLARIUM_PRIEST, Portals[j][0], Portals[j][1], Portals[j][2]); + + m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + m_creature->SetVisibility(VISIBILITY_ON); + + DoYell(SAY_PHASE1, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_PHASE1); + AppearDelay = true; + Phase3_Timer = 15000; + }else Phase3_Timer -= diff; + } + else if(Phase == 4) + { + //Fear_Timer + if (Fear_Timer < diff) + { + DoCast(m_creature->getVictim(), SPELL_FEAR); + Fear_Timer = 20000; + }else Fear_Timer -= diff; + + //VoidBolt_Timer + if (VoidBolt_Timer < diff) + { + DoCast(m_creature->getVictim(), SPELL_VOID_BOLT); + VoidBolt_Timer = 10000; + }else VoidBolt_Timer -= diff; + } + + //When Solarian reaches 20% she will transform into a huge void walker. + if(Phase != 4 && ((m_creature->GetHealth()*100 / m_creature->GetMaxHealth())<20)) + { + Phase = 4; + + //To make sure she wont be invisible or not selecatble + m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + m_creature->SetVisibility(VISIBILITY_ON); + switch(rand()%2) + { + case 0: + DoYell(SAY_VOID, LANG_UNIVERSAL, NULL); + break; + case 1: + DoYell(SAY_VOID1, LANG_UNIVERSAL, NULL); + break; + } + + m_creature->SetArmor(WV_ARMOR); + m_creature->SetUInt32Value(UNIT_FIELD_DISPLAYID, MODEL_VOIDWALKER); + m_creature->SetFloatValue(OBJECT_FIELD_SCALE_X, defaultsize*2.5f); + } + DoMeleeAttackIfReady(); + } +}; + +struct MANGOS_DLL_DECL mob_solarium_priestAI : public ScriptedAI +{ + mob_solarium_priestAI(Creature *c) : ScriptedAI(c) + { + pInstance = ((ScriptedInstance*)c->GetInstanceData()); + Reset(); + } + + ScriptedInstance *pInstance; + + uint32 healTimer; + uint32 holysmiteTimer; + uint32 aoesilenceTimer; + + void Reset() + { + healTimer = 9000; + holysmiteTimer = 1; + aoesilenceTimer = 15000; + } + + void Aggro(Unit *who) + { + } + + void UpdateAI(const uint32 diff) + { + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + if (healTimer < diff) + { + Unit* target = NULL; + + switch(rand()%2) + { + case 0: + if(pInstance) + target = Unit::GetUnit((*m_creature), pInstance->GetData64(DATA_ASTROMANCER)); + break; + case 1: + target = m_creature; + break; + } + + if(target) + { + DoCast(target,SOLARIUM_HEAL); + healTimer = 9000; + } + } else healTimer -= diff; + + if(holysmiteTimer < diff) + { + DoCast(m_creature->getVictim(), SOLARIUM_SMITE); + holysmiteTimer = 4000; + } else holysmiteTimer -= diff; + + if (aoesilenceTimer < diff) + { + DoCast(m_creature->getVictim(), SOLARIUM_SILENCE); + aoesilenceTimer = 13000; + } else aoesilenceTimer -= diff; + + DoMeleeAttackIfReady(); + } +}; + +CreatureAI* GetAI_mob_solarium_priest(Creature *_Creature) +{ + return new mob_solarium_priestAI (_Creature); +} + +CreatureAI* GetAI_boss_high_astromancer_solarian(Creature *_Creature) +{ + return new boss_high_astromancer_solarianAI (_Creature); +} + +void AddSC_boss_high_astromancer_solarian() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_high_astromancer_solarian"; + newscript->GetAI = GetAI_boss_high_astromancer_solarian; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="mob_solarium_priest"; + newscript->GetAI = GetAI_mob_solarium_priest; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/tempest_keep/the_eye/boss_kaelthas.cpp b/src/bindings/scripts/scripts/zone/tempest_keep/the_eye/boss_kaelthas.cpp index 4e88e44f799..78eabcde19f 100644 --- a/src/bindings/scripts/scripts/zone/tempest_keep/the_eye/boss_kaelthas.cpp +++ b/src/bindings/scripts/scripts/zone/tempest_keep/the_eye/boss_kaelthas.cpp @@ -1,1639 +1,1621 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: boss_Kaelthas -SD%Complete: 60 -SDComment: SQL, phase 2, phase 3, Mind Control, taunt immunity -SDCategory: Tempest Keep, The Eye -EndScriptData */ - -#include "precompiled.h" -#include "def_the_eye.h" -#include "WorldPacket.h" - -//Phase 2 spells (Not used) -#define SPELL_SUMMON_WEAPONS 36976 -#define SPELL_SUMMON_WEAPONA 36958 -#define SPELL_SUMMON_WEAPONB 36959 -#define SPELL_SUMMON_WEAPONC 36960 -#define SPELL_SUMMON_WEAPOND 36961 -#define SPELL_SUMMON_WEAPONE 36962 -#define SPELL_SUMMON_WEAPONF 36963 -#define SPELL_SUMMON_WEAPONG 36964 -#define SPELL_RES_VISUAL 24171 -#define SPELL_WEAPON_SPAWN 41236 -//Phase 4 spells -#define SPELL_FIREBALL 22088 //wrong but works with CastCustomSpell -#define SPELL_PYROBLAST 36819 -#define SPELL_FLAME_STRIKE 36735 -#define SPELL_FLAME_STRIKE_VIS 36730 -#define SPELL_FLAME_STRIKE_DMG 36731 -#define SPELL_ARCANE_DISRUPTION 36834 -#define SPELL_SHOCK_BARRIER 36815 -#define SPELL_PHOENIX_ANIMATION 36723 -#define SPELL_MIND_CONTROL 32830 -//Phase 5 spells -#define SPELL_EXPLODE 36092 -#define SPELL_FULLPOWER 36187 -#define SPELL_KNOCKBACK 11027 -#define SPELL_GRAVITY_LAPSE 34480 -#define SPELL_GRAVITY_LAPSE_AURA 39432 -#define SPELL_NETHER_BEAM 35873 -//Thaladred the Darkener spells -#define SPELL_PSYCHIC_BLOW 10689 -#define SPELL_SILENCE 30225 -//Lord Sanguinar spells -#define SPELL_BELLOWING_ROAR 40636 -//Grand Astromancer Capernian spells -#define CAPERNIAN_DISTANCE 20 //she casts away from the target -#define SPELL_CAPERNIAN_FIREBALL 36971 -#define SPELL_CONFLAGRATION 37018 -#define SPELL_ARCANE_EXPLOSION 36970 -//Master Engineer Telonicus spells -#define SPELL_BOMB 37036 -#define SPELL_REMOTE_TOY 37027 -//Nether Vapor spell -#define SPELL_NETHER_VAPOR 35859 -//Phoenix spell -#define SPELL_BURN 36721 - -//kael'thas Speech -#define SAY_INTRO "Energy. Power. My people are addicted to it... a dependence made manifest after the Sunwell was destroyed. Welcome... to the future. A pity you are too late to stop it. No one can stop me now! Selama ashal'anore!" -#define SOUND_INTRO 11256 - -#define SAY_ASTROMANCER_CAPERNIAN "Capernian will see to it that your stay here is a short one." -#define SOUND_ASTROMANCER_CAPERNIAN 11257 - -#define SAY_ENGINEER_TELONICUS "Well done, you have proven worthy to test your skills against my master engineer, Telonicus." -#define SOUND_ENGINEER_TELONICUS 11258 - -#define SAY_THALADRED_THE_DARKENER "Let us see how your nerves hold up against the Darkener, Thaladred" -#define SOUND_THALADRED_THE_DARKENER 11259 - -#define SAY_LORD_SANGUINAR "You have persevered against some of my best advisors... but none can withstand the might of the Blood Hammer. Behold, Lord Sanguinar!" -#define SOUND_LORD_SANGUINAR 11260 - -#define SAY_PHASE2 "As you see, I have many weapons in my arsenal...." -#define SOUND_PHASE2 11261 - -#define SAY_PHASE3 "Perhaps I underestimated you. It would be unfair to make you fight all four advisors at once, but... fair treatment was never shown to my people. I'm just returning the favor." -#define SOUND_PHASE3 11262 - -#define SAY_PHASE4 "Alas, sometimes one must take matters into one's own hands. Balamore shanal!" -#define SOUND_PHASE4 11263 - -#define SAY_PHASE5 "I have not come this far to be stopped! The future I have planned will not be jeopardized! Now you will taste true power!!" -#define SOUND_PHASE5 11273 - -#define SAY_SLAY1 "You will not prevail." -#define SOUND_SLAY1 11270 - -#define SAY_SLAY2 "You gambled...and lost." -#define SOUND_SLAY2 11271 - -#define SAY_MINDCONTROL1 "Obey me." -#define SOUND_MINDCONTROL1 11268 - -#define SAY_MINDCONTROL2 "Bow to my will." -#define SOUND_MINDCONTROL2 11269 - -#define SAY_GRAVITYLAPSE1 "Let us see how you fare when your world is turned upside down." -#define SOUND_GRAVITYLAPSE1 11264 - -#define SAY_GRAVITYLAPSE2 "Having trouble staying grounded?" -#define SOUND_GRAVITYLAPSE2 11265 - -#define SAY_SUMMON_PHOENIX1 "Anara'nel belore!" -#define SOUND_SUMMON_PHOENIX1 11267 - -#define SAY_SUMMON_PHOENIX2 "By the power of the sun!" -#define SOUND_SUMMON_PHOENIX2 11266 - -#define SAY_DEATH "For...Quel...thalas!" -#define SOUND_DEATH 11274 - -//Thaladred the Darkener speech -#define SAY_THALADRED_AGGRO "Prepare yourselves!" -#define SOUND_THALADRED_AGGRO 11203 -#define SAY_THALADRED_DEATH "Forgive me, my prince! I have... failed." -#define SOUND_THALADRED_DEATH 11204 -#define EMOTE_THALADRED_GAZE "sets his gaze on $N!" - -//Lord Sanguinar speech -#define SAY_SANGUINAR_AGGRO "Blood for blood!" -#define SOUND_SANGUINAR_AGGRO 11152 -#define SAY_SANGUINAR_DEATH "NO! I ...will... not..." -#define SOUND_SANGUINAR_DEATH 11153 - -//Grand Astromancer Capernian speech -#define SAY_CAPERNIAN_AGGRO "The sin'dore reign supreme!" -#define SOUND_CAPERNIAN_AGGRO 11117 -#define SAY_CAPERNIAN_DEATH "This is not over!" -#define SOUND_CAPERNIAN_DEATH 11118 - -//Master Engineer Telonicus speech -#define SAY_TELONICUS_AGGRO "Anar'alah belore!" -#define SOUND_TELONICUS_AGGRO 11157 -#define SAY_TELONICUS_DEATH "More perils... await" -#define SOUND_TELONICUS_DEATH 11158 - -//Creature IDs -#define PHOENIX 21362 -#define PHOENIX_EGG 21364 - -//Phoenix egg and phoenix model -#define PHOENIX_MODEL 19682 -#define PHOENIX_EGG_MODEL 20245 - -//#define PI 3.141592 -#define TEMP_MC_WHISPER "[SD2 Debug] You would be mind controlled here!" - -//weapon id + position -float KaelthasWeapons[7][5] = -{ - {21270, 794.38, 15, 48.72, 2.9}, //[Cosmic Infuser] - {21269, 785.47, 12.12, 48.72, 3.14}, //[Devastation] - {21271, 781.25, 4.39, 48.72, 3.14}, //[Infinity Blade] - {21273, 777.38, -0.81, 48.72, 3.06}, //[Phaseshift Bulwark] - {21274, 781.48, -6.08, 48.72, 3.9}, //[Staff of Disintegration] - {21272, 785.42, -13.59, 48.72, 3.4}, //[Warp Slicer] - {21268, 793.06, -16.61, 48.72, 3.10} //[Netherstrand Longbow] -}; - -#define GRAVITY_X 795.0f -#define GRAVITY_Y 0.0f -#define GRAVITY_Z 70.0f - -#define TIME_PHASE_2_3 120000 -#define TIME_PHASE_3_4 120000 - -#define KAEL_VISIBLE_RANGE 50.0f - -//Base AI for Advisors -struct MANGOS_DLL_DECL advisorbase_ai : public ScriptedAI -{ - ScriptedInstance* pInstance; - bool FakeDeath; - uint32 DelayRes_Timer; - uint64 DelayRes_Target; - - advisorbase_ai(Creature *c) : ScriptedAI(c) - { - pInstance = ((ScriptedInstance*)c->GetInstanceData()); - Reset(); - } - - void MoveInLineOfSight(Unit *who) - { - if (!who || FakeDeath || m_creature->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE)) - return; - - if( !m_creature->getVictim() && who->isTargetableForAttack() && ( m_creature->IsHostileTo( who )) && who->isInAccessablePlaceFor(m_creature) ) - { - if (m_creature->GetDistanceZ(who) > CREATURE_Z_ATTACK_RANGE) - return; - - float attackRadius = m_creature->GetAttackDistance(who); - if(m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->IsWithinLOSInMap(who) ) - { - DoStartAttackAndMovement(who); - who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); - - if (!InCombat) - { - Aggro(who); - InCombat = true; - } - } - } - } - - void AttackStart(Unit* who) - { - if (!who || FakeDeath || m_creature->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE)) - return; - - if (who->isTargetableForAttack()) - { - //Begin attack - DoStartAttackAndMovement(who); - - if (!InCombat) - { - Aggro(who); - InCombat = true; - } - } - } - - void Reset() - { - FakeDeath = false; - DelayRes_Timer = 0; - DelayRes_Target = 0; - - m_creature->SetUInt32Value(UNIT_FIELD_BYTES_1, 0); - m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); - m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - - //reset encounter - if(pInstance && (pInstance->GetData(DATA_KAELTHASEVENT) == 1 || pInstance->GetData(DATA_KAELTHASEVENT) == 3)) - { - Creature *Kaelthas = NULL; - Kaelthas = (Creature*)(Unit::GetUnit((*m_creature), pInstance->GetData64(DATA_KAELTHAS))); - - if(Kaelthas) - Kaelthas->AI()->EnterEvadeMode(); - } - } - - void Revive(Unit* Target) - { - m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - m_creature->SetHealth(m_creature->GetMaxHealth()); - m_creature->SetUInt32Value(UNIT_FIELD_BYTES_1, 0); - DoCast(m_creature, SPELL_RES_VISUAL, false); - DelayRes_Timer = 2000; - } - - void DamageTaken(Unit* pKiller, uint32 &damage) - { - if (damage < m_creature->GetHealth()) - return; - - //Prevent glitch if in fake death - if (FakeDeath) - { - damage = 0; - return; - } - //Don't really die in phase 1 & 3, only die after that - if(pInstance && pInstance->GetData(DATA_KAELTHASEVENT) != 0) - { - //prevent death - damage = 0; - FakeDeath = true; - - m_creature->InterruptNonMeleeSpells(false); - m_creature->SetHealth(0); - m_creature->StopMoving(); - m_creature->ClearComboPointHolders(); - m_creature->RemoveAllAurasOnDeath(); - m_creature->ModifyAuraState(AURA_STATE_HEALTHLESS_20_PERCENT, false); - m_creature->ModifyAuraState(AURA_STATE_HEALTHLESS_35_PERCENT, false); - m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - m_creature->ClearAllReactives(); - m_creature->SetUInt64Value(UNIT_FIELD_TARGET,0); - m_creature->GetMotionMaster()->Clear(); - m_creature->GetMotionMaster()->MoveIdle(); - m_creature->SetUInt32Value(UNIT_FIELD_BYTES_1,PLAYER_STATE_DEAD); - - if (pInstance->GetData(DATA_KAELTHASEVENT) == 3) - JustDied(pKiller); - } - } - - void UpdateAI(const uint32 diff) - { - if (DelayRes_Timer) - if (DelayRes_Timer <= diff) - { - DelayRes_Timer = 0; - FakeDeath = false; - - Unit* Target = Unit::GetUnit((*m_creature), DelayRes_Target); - if (!Target)Target = m_creature->getVictim(); - DoResetThreat(); - AttackStart(Target); - m_creature->GetMotionMaster()->Clear(); - m_creature->GetMotionMaster()->MoveChase(Target); - m_creature->AddThreat(Target, 0.0f); - }else DelayRes_Timer -= diff; - } - -}; - -//Kael'thas AI -struct MANGOS_DLL_DECL boss_kaelthasAI : public ScriptedAI -{ - boss_kaelthasAI(Creature *c) : ScriptedAI(c) - { - pInstance = ((ScriptedInstance*)c->GetInstanceData()); - AdvisorGuid[0] = 0; - AdvisorGuid[1] = 0; - AdvisorGuid[2] = 0; - AdvisorGuid[3] = 0; - Reset(); - } - - ScriptedInstance* pInstance; - - uint32 Fireball_Timer; - uint32 ArcaneDisruption_Timer; - uint32 Phoenix_Timer; - uint32 ShockBarrier_Timer; - uint32 GravityLapse_Timer; - uint32 GravityLapse_Phase; - uint32 NetherBeam_Timer; - uint32 NetherVapor_Timer; - uint32 FlameStrike_Timer; - uint32 MindControl_Timer; - uint32 Phase; - uint32 PhaseSubphase; //generic - uint32 Phase_Timer; //generic timer - uint32 PyrosCasted; - - bool InGravityLapse; - bool IsCastingFireball; - bool ChainPyros; - - uint64 AdvisorGuid[4]; - - void Reset() - { - Fireball_Timer = 5000+rand()%10000; - ArcaneDisruption_Timer = 45000; - MindControl_Timer = 40000; - Phoenix_Timer = 50000; - ShockBarrier_Timer = 60000; - FlameStrike_Timer = 30000; - GravityLapse_Timer = 20000; - GravityLapse_Phase = 0; - NetherBeam_Timer = 8000; - NetherVapor_Timer = 10000; - PyrosCasted = 0; - Phase = 0; - InGravityLapse = false; - IsCastingFireball = false; - ChainPyros = false; - - if(InCombat) - PrepareAdvisors(); - - m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); - - if(pInstance) - pInstance->SetData(DATA_KAELTHASEVENT, 0); - } - - void PrepareAdvisors() - { - Creature *pCreature; - for(uint8 i = 0; i < 4; i++) - { - pCreature = (Creature*)(Unit::GetUnit((*m_creature), AdvisorGuid[i])); - if(pCreature) - { - pCreature->Respawn(); - pCreature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); - pCreature->setFaction(m_creature->getFaction()); - pCreature->AI()->EnterEvadeMode(); - } - } - } - - void StartEvent() - { - if(!pInstance) - return; - - AdvisorGuid[0] = pInstance->GetData64(DATA_THALADREDTHEDARKENER); - AdvisorGuid[1] = pInstance->GetData64(DATA_LORDSANGUINAR); - AdvisorGuid[2] = pInstance->GetData64(DATA_GRANDASTROMANCERCAPERNIAN); - AdvisorGuid[3] = pInstance->GetData64(DATA_MASTERENGINEERTELONICUS); - - if(!AdvisorGuid[0] || !AdvisorGuid[1] || !AdvisorGuid[2] || !AdvisorGuid[3]) - { - error_log("SD2: Kael'Thas One or more advisors missing, Skipping Phases 1-3"); - DoYell("SD2: Kael'Thas One or more advisors missing, Skipping Phases 1-3", LANG_UNIVERSAL, NULL); - - DoYell(SAY_PHASE4, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_PHASE4); - Phase = 4; - - pInstance->SetData(DATA_KAELTHASEVENT, 4); - - m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); - - Unit *target = NULL; - target = SelectUnit(SELECT_TARGET_RANDOM, 0); - if(target) - { - DoStartAttackAndMovement(target); - } - }else - { - PrepareAdvisors(); - - DoYell(SAY_INTRO, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_INTRO); - - pInstance->SetData(DATA_KAELTHASEVENT, 1); - m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); - - PhaseSubphase = 0; - Phase_Timer = 23000; - Phase = 1; - } - } - - void KilledUnit() - { - switch(rand()%2) - { - case 0: - DoYell(SAY_SLAY1,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_SLAY1); - break; - case 1: - DoYell(SAY_SLAY2,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_SLAY2); - break; - } - } - - void JustDied(Unit* Killer) - { - m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); - - DoYell(SAY_DEATH,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_DEATH); - - if(pInstance) - pInstance->SetData(DATA_KAELTHASEVENT, 0); - - Creature *pCreature; - for(uint8 i = 0; i < 4; i++) - { - pCreature = (Creature*)(Unit::GetUnit((*m_creature), AdvisorGuid[i])); - if(pCreature) - { - pCreature->DealDamage(pCreature, pCreature->GetMaxHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); - } - } - } - - void Aggro(Unit *who) - { - if (pInstance && !pInstance->GetData(DATA_KAELTHASEVENT) && !Phase) - StartEvent(); - } - - void MoveInLineOfSight(Unit *who) - { - if (!who || m_creature->getVictim()) - return; - - if (who->isTargetableForAttack() && who->isInAccessablePlaceFor(m_creature) && m_creature->IsHostileTo(who)) - { - float attackRadius = m_creature->GetAttackDistance(who); - if (Phase >= 4 && m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->GetDistanceZ(who) <= CREATURE_Z_ATTACK_RANGE && m_creature->IsWithinLOSInMap(who)) - { - if(who->HasStealthAura()) - who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); - - DoStartAttackAndMovement(who); - } - else if(who->isAlive()) - { - if (pInstance && !pInstance->GetData(DATA_KAELTHASEVENT) && !Phase && m_creature->IsWithinDistInMap(who, 60.0f)) - StartEvent(); - - //add to the threat list, so we can use SelectTarget - m_creature->AddThreat(who,0.0f); - } - } - } - - void UpdateAI(const uint32 diff) - { - //Phase 1 - switch (Phase) - { - case 1: - { - Unit *target; - Creature* Advisor; - - //Subphase switch - switch(PhaseSubphase) - { - //Subphase 1 - Start - case 0: - if(Phase_Timer < diff) - { - DoYell(SAY_THALADRED_THE_DARKENER, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_THALADRED_THE_DARKENER); - - //start advisor within 7 seconds - Phase_Timer = 7000; - - PhaseSubphase++; - }else Phase_Timer -= diff; - break; - - //Subphase 1 - Unlock advisor - case 1: - if(Phase_Timer < diff) - { - Advisor = (Creature*)(Unit::GetUnit((*m_creature), AdvisorGuid[0])); - - if(Advisor) - { - Advisor->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); - Advisor->setFaction(m_creature->getFaction()); - - target = SelectUnit(SELECT_TARGET_RANDOM, 0); - if(target) - Advisor->AI()->AttackStart(target); - } - - PhaseSubphase++; - }else Phase_Timer -= diff; - break; - - //Subphase 2 - Start - case 2: - Advisor = (Creature*)(Unit::GetUnit((*m_creature), AdvisorGuid[0])); - if(Advisor && (Advisor->GetUInt32Value(UNIT_FIELD_BYTES_1) == PLAYER_STATE_DEAD)) - { - DoYell(SAY_LORD_SANGUINAR, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_LORD_SANGUINAR); - - //start advisor within 12.5 seconds - Phase_Timer = 12500; - - PhaseSubphase++; - } - break; - - //Subphase 2 - Unlock advisor - case 3: - if(Phase_Timer < diff) - { - Advisor = (Creature*)(Unit::GetUnit((*m_creature), AdvisorGuid[1])); - - if(Advisor) - { - Advisor->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); - Advisor->setFaction(m_creature->getFaction()); - - target = SelectUnit(SELECT_TARGET_RANDOM, 0); - if(target) - Advisor->AI()->AttackStart(target); - } - - PhaseSubphase++; - }else Phase_Timer -= diff; - break; - - //Subphase 3 - Start - case 4: - Advisor = (Creature*)(Unit::GetUnit((*m_creature), AdvisorGuid[1])); - if(Advisor && (Advisor->GetUInt32Value(UNIT_FIELD_BYTES_1) == PLAYER_STATE_DEAD)) - { - DoYell(SAY_ASTROMANCER_CAPERNIAN, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_ASTROMANCER_CAPERNIAN); - - //start advisor within 7 seconds - Phase_Timer = 7000; - - PhaseSubphase++; - } - break; - - //Subphase 3 - Unlock advisor - case 5: - if(Phase_Timer < diff) - { - Advisor = (Creature*)(Unit::GetUnit((*m_creature), AdvisorGuid[2])); - - if(Advisor) - { - Advisor->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); - Advisor->setFaction(m_creature->getFaction()); - - target = SelectUnit(SELECT_TARGET_RANDOM, 0); - if(target) - Advisor->AI()->AttackStart(target); - } - - PhaseSubphase++; - }else Phase_Timer -= diff; - break; - - //Subphase 4 - Start - case 6: - Advisor = (Creature*)(Unit::GetUnit((*m_creature), AdvisorGuid[2])); - if(Advisor && (Advisor->GetUInt32Value(UNIT_FIELD_BYTES_1) == PLAYER_STATE_DEAD)) - { - DoYell(SAY_ENGINEER_TELONICUS, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_ENGINEER_TELONICUS); - - //start advisor within 8.4 seconds - Phase_Timer = 8400; - - PhaseSubphase++; - } - break; - - //Subphase 4 - Unlock advisor - case 7: - if(Phase_Timer < diff) - { - Advisor = (Creature*)(Unit::GetUnit((*m_creature), AdvisorGuid[3])); - - if(Advisor) - { - Advisor->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); - Advisor->setFaction(m_creature->getFaction()); - - target = SelectUnit(SELECT_TARGET_RANDOM, 0); - if(target) - Advisor->AI()->AttackStart(target); - } - - Phase_Timer = 3000; - - PhaseSubphase++; - }else Phase_Timer -= diff; - break; - - //End of phase 1 - case 8: - Advisor = (Creature*)(Unit::GetUnit((*m_creature), AdvisorGuid[3])); - if(Advisor && (Advisor->GetUInt32Value(UNIT_FIELD_BYTES_1) == PLAYER_STATE_DEAD)) - { - Phase = 2; - pInstance->SetData(DATA_KAELTHASEVENT, 2); - - DoYell(SAY_PHASE2, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_PHASE2); - PhaseSubphase = 0; - Phase_Timer = 3500; - DoCast(m_creature, SPELL_SUMMON_WEAPONS); - } - break; - } - }break; - - case 2: - { - if (PhaseSubphase == 0) - { - if (Phase_Timer < diff) - { - PhaseSubphase = 1; - }else Phase_Timer -= diff; - } - - //Spawn weapons - if (PhaseSubphase == 1) - { - Unit* Target = SelectUnit(SELECT_TARGET_RANDOM, 0); - - Creature* Weapon; - for (uint32 i = 0; i < 7; i++) - { - Weapon = m_creature->SummonCreature(((uint32)KaelthasWeapons[i][0]),KaelthasWeapons[i][1],KaelthasWeapons[i][2],KaelthasWeapons[i][3],0,TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 60000); - - if (!Weapon) - error_log("SD2: Kael'thas weapon %i could not be spawned", i); - else - { - Weapon->setFaction(m_creature->getFaction()); - Weapon->AI()->AttackStart(Target); - Weapon->CastSpell(Weapon, SPELL_WEAPON_SPAWN, false); - } - } - - PhaseSubphase = 2; - Phase_Timer = TIME_PHASE_2_3; - } - - if (PhaseSubphase == 2) - if (Phase_Timer < diff) - { - DoYell(SAY_PHASE3, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_PHASE3); - pInstance->SetData(DATA_KAELTHASEVENT, 3); - Phase = 3; - PhaseSubphase = 0; - }else Phase_Timer -= diff; - }break; - - case 3: - { - if (PhaseSubphase == 0) - { - //Respawn advisors - Unit* Target = SelectUnit(SELECT_TARGET_RANDOM, 0); - - Creature* Advisor; - for (uint32 i = 0; i < 4; i++) - { - Advisor = (Creature*)(Unit::GetUnit((*m_creature), AdvisorGuid[i])); - if (!Advisor) - error_log("SD2: Kael'Thas Advisor %u does not exist. Possibly despawned? Incorrectly Killed?", i); - else ((advisorbase_ai*)Advisor->AI())->Revive(Target); - } - - PhaseSubphase = 1; - Phase_Timer = TIME_PHASE_3_4; - } - - if(Phase_Timer < diff) - { - DoYell(SAY_PHASE4, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_PHASE4); - Phase = 4; - - pInstance->SetData(DATA_KAELTHASEVENT, 4); - - m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); - - Unit *target = NULL; - target = SelectUnit(SELECT_TARGET_RANDOM, 0); - if(target) - { - DoStartAttackAndMovement(target); - } - Phase_Timer = 30000; - }else Phase_Timer -= diff; - } - break; - - case 4: - case 5: - case 6: - { - //Return since we have no target - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - //Fireball_Timer - if(!InGravityLapse && !ChainPyros && Phase != 5) - { - if(Fireball_Timer < diff) - { - if(!IsCastingFireball) - { - if(!m_creature->IsNonMeleeSpellCasted(false)) - { - //interruptable - m_creature->ApplySpellImmune(0, IMMUNITY_EFFECT, SPELL_EFFECT_INTERRUPT_CAST, false); - int32 dmg = 20000+rand()%5000; - m_creature->CastCustomSpell(m_creature->getVictim(), SPELL_FIREBALL, &dmg, 0, 0, false); - IsCastingFireball = true; - Fireball_Timer = 2500; - } - } - else - { - //apply resistance - m_creature->ApplySpellImmune(0, IMMUNITY_EFFECT, SPELL_EFFECT_INTERRUPT_CAST, true); - IsCastingFireball = false; - Fireball_Timer = 5000+rand()%10000; - } - }else Fireball_Timer -= diff; - - //ArcaneDisruption_Timer - if(ArcaneDisruption_Timer < diff) - { - DoCast(m_creature->getVictim(), SPELL_ARCANE_DISRUPTION, true); - - ArcaneDisruption_Timer = 60000; - }else ArcaneDisruption_Timer -= diff; - - if (FlameStrike_Timer < diff) - { - Unit* pUnit = SelectUnit(SELECT_TARGET_RANDOM, 0); - DoCast(pUnit, SPELL_FLAME_STRIKE); - - FlameStrike_Timer = 30000; - }FlameStrike_Timer -= diff; - - if (MindControl_Timer < diff) - { - if (m_creature->getThreatManager().getThreatList().size() >= 2) - for (uint32 i = 0; i < 3; i++) - { - debug_log("SD2: Kael'Thas mind control not supported."); - //DoCast(pUnit, SPELL_MIND_CONTROL); - } - - MindControl_Timer = 60000; - }MindControl_Timer -= diff; - } - - //Phoenix_Timer - if(Phoenix_Timer < diff) - { - DoCast(m_creature, SPELL_PHOENIX_ANIMATION); - Creature *Phoenix = DoSpawnCreature(PHOENIX, 0, 0, 0, 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 45000); - - if(Phoenix) - { - Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0); - if (target) - Phoenix->AI()->AttackStart(target); - }else error_log("SD2: Kael'Thas Phoenix could not be spawned"); - - switch(rand()%2) - { - case 0: - DoYell(SAY_SUMMON_PHOENIX1, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_SUMMON_PHOENIX1); - break; - - case 1: - DoYell(SAY_SUMMON_PHOENIX2, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_SUMMON_PHOENIX2); - break; - - default: - break; - } - - Phoenix_Timer = 60000; - }else Phoenix_Timer -= diff; - - //Phase 4 specific spells - if(Phase == 4) - { - if (m_creature->GetHealth()*100 / m_creature->GetMaxHealth() < 50) - { - pInstance->SetData(DATA_KAELTHASEVENT, 4); - Phase = 5; - Phase_Timer = 10000; - - DoYell(SAY_PHASE5, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_PHASE5); - - m_creature->StopMoving(); - m_creature->GetMotionMaster()->Clear(); - m_creature->GetMotionMaster()->MoveIdle(); - m_creature->Relocate(GRAVITY_X, GRAVITY_Y, GRAVITY_Z, 0); - m_creature->SendMonsterMove(GRAVITY_X, GRAVITY_Y,GRAVITY_Z, 0, 0, 0); - - m_creature->InterruptNonMeleeSpells(false); - DoCast(m_creature, SPELL_FULLPOWER); - m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); - } - - //ShockBarrier_Timer - if(ShockBarrier_Timer < diff) - { - DoCast(m_creature, SPELL_SHOCK_BARRIER); - ChainPyros = true; - PyrosCasted = 0; - - ShockBarrier_Timer = 60000; - }else ShockBarrier_Timer -= diff; - - //Chain Pyros (3 of them max) - if (ChainPyros && !m_creature->IsNonMeleeSpellCasted(false)) - { - if (PyrosCasted < 3) - { - DoCast(m_creature->getVictim(), SPELL_PYROBLAST); - PyrosCasted++; - - }else - { - ChainPyros = false; - Fireball_Timer = 2500; - ArcaneDisruption_Timer = 60000; - } - } - } - - if (Phase == 5) - { - if(Phase_Timer < diff) - { - m_creature->InterruptNonMeleeSpells(false); - m_creature->RemoveAurasDueToSpell(SPELL_FULLPOWER); - DoCast(m_creature, SPELL_EXPLODE); - m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); - Phase = 6; - DoStartAttackAndMovement(m_creature->getVictim()); - m_creature->GetMotionMaster()->Clear(); - m_creature->GetMotionMaster()->MoveChase(m_creature->getVictim()); - - }else Phase_Timer -= diff; - } - - //Phase 5 - if(Phase == 6) - { - - //GravityLapse_Timer - if(GravityLapse_Timer < diff) - { - std::list::iterator i = m_creature->getThreatManager().getThreatList().begin(); - switch(GravityLapse_Phase) - { - case 0: - m_creature->StopMoving(); - m_creature->GetMotionMaster()->Clear(); - m_creature->GetMotionMaster()->MoveIdle(); - m_creature->Relocate(GRAVITY_X, GRAVITY_Y, GRAVITY_Z, 0); - m_creature->SendMonsterMove(GRAVITY_X, GRAVITY_Y, GRAVITY_Z, 0, 0, 0); - // 1) Kael'thas will portal the whole raid right into his body - for (i = m_creature->getThreatManager().getThreatList().begin(); i!= m_creature->getThreatManager().getThreatList().end();++i) - { - Unit* pUnit = Unit::GetUnit((*m_creature), (*i)->getUnitGuid()); - if(pUnit && (pUnit->GetTypeId() == TYPEID_PLAYER)) - { - //Use work around packet to prevent player from being dropped from combat - DoTeleportPlayer(pUnit, GRAVITY_X, GRAVITY_Y, GRAVITY_Z, pUnit->GetOrientation()); - } - } - GravityLapse_Timer = 500; - ++GravityLapse_Phase; - InGravityLapse = true; - ShockBarrier_Timer = 1000; - NetherBeam_Timer = 5000; - break; - - case 1: - switch(rand()%2) - { - case 0: - DoYell(SAY_GRAVITYLAPSE1, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_GRAVITYLAPSE1); - break; - - case 1: - DoYell(SAY_GRAVITYLAPSE2, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_GRAVITYLAPSE2); - break; - } - - // 2) At that point he will put a Gravity Lapse debuff on everyone - for (i = m_creature->getThreatManager().getThreatList().begin(); i!= m_creature->getThreatManager().getThreatList().end();i++) - { - Unit* pUnit = Unit::GetUnit((*m_creature), (*i)->getUnitGuid()); - if(pUnit) - { - m_creature->CastSpell(pUnit, SPELL_KNOCKBACK, true); - //Gravity lapse - needs an exception in Spell system to work - - pUnit->CastSpell(pUnit, SPELL_GRAVITY_LAPSE, true, 0, 0, m_creature->GetGUID()); - pUnit->CastSpell(pUnit, SPELL_GRAVITY_LAPSE_AURA, true, 0, 0, m_creature->GetGUID()); - - //Using packet workaround - WorldPacket data(12); - data.SetOpcode(SMSG_MOVE_SET_CAN_FLY); - data.append(pUnit->GetPackGUID()); - data << uint32(0); - pUnit->SendMessageToSet(&data, true); - } - } - GravityLapse_Timer = 10000; - GravityLapse_Phase++; - break; - - case 2: - //Cast nether vapor aura on self - m_creature->InterruptNonMeleeSpells(false); - DoCast(m_creature, SPELL_NETHER_VAPOR); - - GravityLapse_Timer = 20000; - GravityLapse_Phase++; - break; - - case 3: - //Remove flight - for (i = m_creature->getThreatManager().getThreatList().begin(); i!= m_creature->getThreatManager().getThreatList().end();i++) - { - Unit* pUnit = Unit::GetUnit((*m_creature), (*i)->getUnitGuid()); - if(pUnit) - { - //Using packet workaround - WorldPacket data(12); - data.SetOpcode(SMSG_MOVE_UNSET_CAN_FLY); - data.append(pUnit->GetPackGUID()); - data << uint32(0); - pUnit->SendMessageToSet(&data, true); - } - } - m_creature->RemoveAurasDueToSpell(SPELL_NETHER_VAPOR); - InGravityLapse = false; - GravityLapse_Timer = 60000; - GravityLapse_Phase = 0; - DoStartAttackAndMovement(m_creature->getVictim()); - m_creature->GetMotionMaster()->Clear(); - m_creature->GetMotionMaster()->MoveChase(m_creature->getVictim()); - DoResetThreat(); - break; - } - }else GravityLapse_Timer -= diff; - - if(InGravityLapse) - { - //ShockBarrier_Timer - if(ShockBarrier_Timer < diff) - { - DoCast(m_creature, SPELL_SHOCK_BARRIER); - - ShockBarrier_Timer = 20000; - }else ShockBarrier_Timer -= diff; - - //NetherBeam_Timer - if(NetherBeam_Timer < diff) - { - Unit* pUnit = SelectUnit(SELECT_TARGET_RANDOM, 0); - DoCast(pUnit, SPELL_NETHER_BEAM); - - NetherBeam_Timer = 4000; - }else NetherBeam_Timer -= diff; - } - } - - if (!InGravityLapse) - DoMeleeAttackIfReady(); - } - } - } -}; - -//Thaladred the Darkener AI -struct MANGOS_DLL_DECL boss_thaladred_the_darkenerAI : public advisorbase_ai -{ - boss_thaladred_the_darkenerAI(Creature *c) : advisorbase_ai(c) {} - - uint32 Gaze_Timer; - uint32 Silence_Timer; - uint32 PsychicBlow_Timer; - - void Reset() - { - Gaze_Timer = 100; - Silence_Timer = 20000; - PsychicBlow_Timer = 10000; - - advisorbase_ai::Reset(); - } - - void JustDied(Unit* pKiller) - { - DoPlaySoundToSet(m_creature, SOUND_THALADRED_DEATH); - DoYell(SAY_THALADRED_DEATH, LANG_UNIVERSAL, NULL); - } - - void Aggro(Unit *who) - { - if (m_creature->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE)) - return; - - if (!who || FakeDeath) - return; - - DoYell(SAY_THALADRED_AGGRO, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_THALADRED_AGGRO); - m_creature->AddThreat(who, 5000000.0f); - } - - void UpdateAI(const uint32 diff) - { - advisorbase_ai::UpdateAI(diff); - - //Faking death, don't do anything - if (FakeDeath) - return; - - //Return since we have no target - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - //Gaze_Timer - if(Gaze_Timer < diff) - { - Unit* target = NULL; - target = SelectUnit(SELECT_TARGET_RANDOM, 0); - if(target) - { - DoResetThreat(); - m_creature->AddThreat(target, 5000000.0f); - DoTextEmote(EMOTE_THALADRED_GAZE, target); - Gaze_Timer = 8500; - } - }else Gaze_Timer -= diff; - - //Silence_Timer - if(Silence_Timer < diff) - { - DoCast(m_creature->getVictim(), SPELL_SILENCE); - Silence_Timer = 20000; - }else Silence_Timer -= diff; - - //PsychicBlow_Timer - if(PsychicBlow_Timer < diff) - { - DoCast(m_creature->getVictim(), SPELL_PSYCHIC_BLOW); - PsychicBlow_Timer = 20000+rand()%5000; - }else PsychicBlow_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; - -//Lord Sanguinar AI -struct MANGOS_DLL_DECL boss_lord_sanguinarAI : public advisorbase_ai -{ - boss_lord_sanguinarAI(Creature *c) : advisorbase_ai(c){} - - uint32 Fear_Timer; - - void Reset() - { - Fear_Timer = 20000; - advisorbase_ai::Reset(); - } - - void JustDied(Unit* Killer) - { - DoPlaySoundToSet(m_creature, SOUND_SANGUINAR_DEATH); - DoYell(SAY_SANGUINAR_DEATH, LANG_UNIVERSAL, NULL); - } - - void Aggro(Unit *who) - { - if (m_creature->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE)) - return; - - if (!who || FakeDeath) - return; - - DoYell(SAY_SANGUINAR_AGGRO, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_SANGUINAR_AGGRO); - } - - void UpdateAI(const uint32 diff) - { - advisorbase_ai::UpdateAI(diff); - - //Faking death, don't do anything - if (FakeDeath) - return; - - //Return since we have no target - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - //Fear_Timer - if(Fear_Timer < diff) - { - DoCast(m_creature->getVictim(), SPELL_BELLOWING_ROAR); - Fear_Timer = 25000+rand()%10000; //approximately every 30 seconds - }else Fear_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; - -//Grand Astromancer Capernian AI -struct MANGOS_DLL_DECL boss_grand_astromancer_capernianAI : public advisorbase_ai -{ - boss_grand_astromancer_capernianAI(Creature *c) : advisorbase_ai(c){} - - uint32 Fireball_Timer; - uint32 Conflagration_Timer; - uint32 ArcaneExplosion_Timer; - uint32 Yell_Timer; - bool Yell; - - void Reset() - { - Fireball_Timer = 2000; - Conflagration_Timer = 20000; - ArcaneExplosion_Timer = 5000; - Yell_Timer = 2000; - Yell = false; - - advisorbase_ai::Reset(); - } - - void JustDied(Unit* pKiller) - { - DoPlaySoundToSet(m_creature, SOUND_CAPERNIAN_DEATH); - DoYell(SAY_CAPERNIAN_DEATH, LANG_UNIVERSAL, NULL); - } - - void AttackStart(Unit* who) - { - if (!who || FakeDeath || m_creature->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE)) - return; - - if (who->isTargetableForAttack()) - { - //Begin attack - DoStartAttackAndMovement(who, CAPERNIAN_DISTANCE, M_PI/2); - - if (!InCombat) - { - Aggro(who); - InCombat = true; - } - } - } - - void Aggro(Unit *who) - { - if (m_creature->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE)) - return; - - if (!who || FakeDeath) - return; - } - - void UpdateAI(const uint32 diff) - { - advisorbase_ai::UpdateAI(diff); - - //Faking Death, don't do anything - if (FakeDeath) - return; - - //Return since we have no target - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - //Yell_Timer - if(!Yell) - if(Yell_Timer < diff) - { - DoYell(SAY_CAPERNIAN_AGGRO, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_CAPERNIAN_AGGRO); - - Yell = true; - }else Yell_Timer -= diff; - - //Fireball_Timer - if(Fireball_Timer < diff) - { - DoCast(m_creature->getVictim(), SPELL_CAPERNIAN_FIREBALL); - Fireball_Timer = 4000; - }else Fireball_Timer -= diff; - - //Conflagration_Timer - if(Conflagration_Timer < diff) - { - Unit *target = NULL; - target = SelectUnit(SELECT_TARGET_RANDOM, 0); - - if(target && m_creature->IsWithinDistInMap(target, 30)) - DoCast(target, SPELL_CONFLAGRATION); - else - DoCast(m_creature->getVictim(), SPELL_CONFLAGRATION); - - Conflagration_Timer = 10000+rand()%5000; - }else Conflagration_Timer -= diff; - - //ArcaneExplosion_Timer - if(ArcaneExplosion_Timer < diff) - { - bool InMeleeRange = false; - Unit *target = NULL; - std::list& m_threatlist = m_creature->getThreatManager().getThreatList(); - for (std::list::iterator i = m_threatlist.begin(); i!= m_threatlist.end();++i) - { - Unit* pUnit = Unit::GetUnit((*m_creature), (*i)->getUnitGuid()); - //if in melee range - if(pUnit && pUnit->IsWithinDistInMap(m_creature, 5)) - { - InMeleeRange = true; - target = pUnit; - break; - } - } - - if(InMeleeRange) - DoCast(target, SPELL_ARCANE_EXPLOSION); - - ArcaneExplosion_Timer = 4000+rand()%2000; - }else ArcaneExplosion_Timer -= diff; - - //Do NOT deal any melee damage. - } -}; - -//Master Engineer Telonicus AI -struct MANGOS_DLL_DECL boss_master_engineer_telonicusAI : public advisorbase_ai -{ - boss_master_engineer_telonicusAI(Creature *c) : advisorbase_ai(c){} - - uint32 Bomb_Timer; - uint32 RemoteToy_Timer; - - void Reset() - { - Bomb_Timer = 10000; - RemoteToy_Timer = 5000; - - advisorbase_ai::Reset(); - } - - void JustDied(Unit* pKiller) - { - DoPlaySoundToSet(m_creature, SOUND_TELONICUS_DEATH); - DoYell(SAY_TELONICUS_DEATH, LANG_UNIVERSAL, NULL); - } - - void Aggro(Unit *who) - { - if (m_creature->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE)) - return; - - if (!who || FakeDeath) - return; - - DoYell(SAY_TELONICUS_AGGRO, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_TELONICUS_AGGRO); - } - - void UpdateAI(const uint32 diff) - { - advisorbase_ai::UpdateAI(diff); - - //Faking Death, do nothing - if (FakeDeath) - return; - - //Return since we have no target - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - //Bomb_Timer - if(Bomb_Timer < diff) - { - DoCast(m_creature->getVictim(), SPELL_BOMB); - Bomb_Timer = 25000; - }else Bomb_Timer -= diff; - - //RemoteToy_Timer - if(RemoteToy_Timer < diff) - { - Unit *target = NULL; - target = SelectUnit(SELECT_TARGET_RANDOM, 0); - - if(target) - DoCast(target, SPELL_REMOTE_TOY); - - RemoteToy_Timer = 10000+rand()%5000; - }else RemoteToy_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; - -//Flame Strike AI -struct MANGOS_DLL_DECL mob_kael_flamestrikeAI : public ScriptedAI -{ - mob_kael_flamestrikeAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 Timer; - bool Casting; - bool KillSelf; - - void Reset() - { - Timer = 5000; - Casting = false; - KillSelf = false; - - m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - m_creature->setFaction(14); - } - - void Aggro(Unit *who) - { - } - - void MoveInLineOfSight(Unit *who) - { - } - - void UpdateAI(const uint32 diff) - { - if (!Casting) - { - DoCast(m_creature, SPELL_FLAME_STRIKE_VIS); - Casting = true; - } - - //Timer - if(Timer < diff) - { - if (!KillSelf) - { - m_creature->InterruptNonMeleeSpells(false); - DoCast(m_creature, SPELL_FLAME_STRIKE_DMG); - }else m_creature->DealDamage(m_creature, m_creature->GetMaxHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); - - KillSelf = true; - Timer = 1000; - }else Timer -= diff; - } -}; - -//Phoenix AI -struct MANGOS_DLL_DECL mob_phoenixAI : public ScriptedAI -{ - mob_phoenixAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 Burn_Timer; - uint32 Hatch_Timer; - uint32 EggVis_Timer; - bool IsEgg; - - void Reset() - { - Burn_Timer = 1000; - Hatch_Timer = 15000; - EggVis_Timer = 0; - IsEgg = false; - m_creature->SetUInt32Value(UNIT_FIELD_DISPLAYID, PHOENIX_MODEL); - } - - void Hatch() - { - IsEgg = false; - m_creature->SetHealth(m_creature->GetMaxHealth()); - m_creature->SetUInt32Value(UNIT_FIELD_DISPLAYID, PHOENIX_MODEL); - Burn_Timer = 1000; - Hatch_Timer = 15000; - EggVis_Timer = 0; - AttackStart(m_creature->getVictim()); - } - - void DamageTaken(Unit* pKiller, uint32 &damage) - { - if (damage < m_creature->GetHealth()) - return; - - //Bird cannot die, only egg - if (!IsEgg) - { - //prevent death - damage = 0; - IsEgg = true; - - m_creature->GetMotionMaster()->Clear(); - m_creature->GetMotionMaster()->MoveIdle(); - m_creature->SetHealth(m_creature->GetMaxHealth()); - EggVis_Timer = 1000; - m_creature->SetUInt32Value(UNIT_FIELD_BYTES_1,PLAYER_STATE_DEAD); - } - } - - void Aggro(Unit *who) - { - } - - void MoveInLineOfSight(Unit *who) - { - if (!who || m_creature->getVictim()) - return; - - if (who->isTargetableForAttack() && who->isInAccessablePlaceFor(m_creature) && m_creature->IsHostileTo(who)) - { - float attackRadius = m_creature->GetAttackDistance(who); - if (m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->GetDistanceZ(who) <= CREATURE_Z_ATTACK_RANGE && m_creature->IsWithinLOSInMap(who)) - { - if(who->HasStealthAura()) - who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); - - AttackStart(who); - } - } - } - - void UpdateAI(const uint32 diff) - { - //Check if we have a current target - if (!IsEgg) - { - //Return since we have no target - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - if (Burn_Timer < diff) - { - DoCast(m_creature->getVictim(), SPELL_BURN); - Burn_Timer = 1000; - }else Burn_Timer -= diff; - - DoMeleeAttackIfReady(); - } - else - { - if (EggVis_Timer) - if (EggVis_Timer <= diff) - { - m_creature->SetUInt32Value(UNIT_FIELD_DISPLAYID, PHOENIX_EGG_MODEL); - m_creature->SetUInt32Value(UNIT_FIELD_BYTES_1, 0); - EggVis_Timer = 0; - }else EggVis_Timer -= diff; - - if (Hatch_Timer < diff) - { - Hatch(); - }else Hatch_Timer -= diff; - } - } -}; - -CreatureAI* GetAI_boss_kaelthas(Creature *_Creature) -{ - return new boss_kaelthasAI (_Creature); -} - -CreatureAI* GetAI_boss_thaladred_the_darkener(Creature *_Creature) -{ - return new boss_thaladred_the_darkenerAI (_Creature); -} - -CreatureAI* GetAI_boss_lord_sanguinar(Creature *_Creature) -{ - return new boss_lord_sanguinarAI (_Creature); -} - -CreatureAI* GetAI_boss_grand_astromancer_capernian(Creature *_Creature) -{ - return new boss_grand_astromancer_capernianAI (_Creature); -} - -CreatureAI* GetAI_boss_master_engineer_telonicus(Creature *_Creature) -{ - return new boss_master_engineer_telonicusAI (_Creature); -} - -CreatureAI* GetAI_mob_kael_flamestrike(Creature *_Creature) -{ - return new mob_kael_flamestrikeAI (_Creature); -} - -CreatureAI* GetAI_mob_phoenix(Creature *_Creature) -{ - return new mob_phoenixAI (_Creature); -} - -void AddSC_boss_kaelthas() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_kaelthas"; - newscript->GetAI = GetAI_boss_kaelthas; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="boss_thaladred_the_darkener"; - newscript->GetAI = GetAI_boss_thaladred_the_darkener; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="boss_lord_sanguinar"; - newscript->GetAI = GetAI_boss_lord_sanguinar; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="boss_grand_astromancer_capernian"; - newscript->GetAI = GetAI_boss_grand_astromancer_capernian; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="boss_master_engineer_telonicus"; - newscript->GetAI = GetAI_boss_master_engineer_telonicus; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name= "mob_kael_flamestrike"; - newscript->GetAI = GetAI_mob_kael_flamestrike; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="mob_phoenix"; - newscript->GetAI = GetAI_mob_phoenix; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: boss_Kaelthas +SD%Complete: 60 +SDComment: SQL, phase 2, phase 3, Mind Control, taunt immunity +SDCategory: Tempest Keep, The Eye +EndScriptData */ + +#include "precompiled.h" +#include "def_the_eye.h" +#include "WorldPacket.h" + +//Phase 2 spells (Not used) +#define SPELL_SUMMON_WEAPONS 36976 +#define SPELL_SUMMON_WEAPONA 36958 +#define SPELL_SUMMON_WEAPONB 36959 +#define SPELL_SUMMON_WEAPONC 36960 +#define SPELL_SUMMON_WEAPOND 36961 +#define SPELL_SUMMON_WEAPONE 36962 +#define SPELL_SUMMON_WEAPONF 36963 +#define SPELL_SUMMON_WEAPONG 36964 +#define SPELL_RES_VISUAL 24171 +#define SPELL_WEAPON_SPAWN 41236 +//Phase 4 spells +#define SPELL_FIREBALL 22088 //wrong but works with CastCustomSpell +#define SPELL_PYROBLAST 36819 +#define SPELL_FLAME_STRIKE 36735 +#define SPELL_FLAME_STRIKE_VIS 36730 +#define SPELL_FLAME_STRIKE_DMG 36731 +#define SPELL_ARCANE_DISRUPTION 36834 +#define SPELL_SHOCK_BARRIER 36815 +#define SPELL_PHOENIX_ANIMATION 36723 +#define SPELL_MIND_CONTROL 32830 +//Phase 5 spells +#define SPELL_EXPLODE 36092 +#define SPELL_FULLPOWER 36187 +#define SPELL_KNOCKBACK 11027 +#define SPELL_GRAVITY_LAPSE 34480 +#define SPELL_GRAVITY_LAPSE_AURA 39432 +#define SPELL_NETHER_BEAM 35873 +//Thaladred the Darkener spells +#define SPELL_PSYCHIC_BLOW 10689 +#define SPELL_SILENCE 30225 +//Lord Sanguinar spells +#define SPELL_BELLOWING_ROAR 40636 +//Grand Astromancer Capernian spells +#define CAPERNIAN_DISTANCE 20 //she casts away from the target +#define SPELL_CAPERNIAN_FIREBALL 36971 +#define SPELL_CONFLAGRATION 37018 +#define SPELL_ARCANE_EXPLOSION 36970 +//Master Engineer Telonicus spells +#define SPELL_BOMB 37036 +#define SPELL_REMOTE_TOY 37027 +//Nether Vapor spell +#define SPELL_NETHER_VAPOR 35859 +//Phoenix spell +#define SPELL_BURN 36721 + +//kael'thas Speech +#define SAY_INTRO "Energy. Power. My people are addicted to it... a dependence made manifest after the Sunwell was destroyed. Welcome... to the future. A pity you are too late to stop it. No one can stop me now! Selama ashal'anore!" +#define SOUND_INTRO 11256 + +#define SAY_ASTROMANCER_CAPERNIAN "Capernian will see to it that your stay here is a short one." +#define SOUND_ASTROMANCER_CAPERNIAN 11257 + +#define SAY_ENGINEER_TELONICUS "Well done, you have proven worthy to test your skills against my master engineer, Telonicus." +#define SOUND_ENGINEER_TELONICUS 11258 + +#define SAY_THALADRED_THE_DARKENER "Let us see how your nerves hold up against the Darkener, Thaladred" +#define SOUND_THALADRED_THE_DARKENER 11259 + +#define SAY_LORD_SANGUINAR "You have persevered against some of my best advisors... but none can withstand the might of the Blood Hammer. Behold, Lord Sanguinar!" +#define SOUND_LORD_SANGUINAR 11260 + +#define SAY_PHASE2 "As you see, I have many weapons in my arsenal...." +#define SOUND_PHASE2 11261 + +#define SAY_PHASE3 "Perhaps I underestimated you. It would be unfair to make you fight all four advisors at once, but... fair treatment was never shown to my people. I'm just returning the favor." +#define SOUND_PHASE3 11262 + +#define SAY_PHASE4 "Alas, sometimes one must take matters into one's own hands. Balamore shanal!" +#define SOUND_PHASE4 11263 + +#define SAY_PHASE5 "I have not come this far to be stopped! The future I have planned will not be jeopardized! Now you will taste true power!!" +#define SOUND_PHASE5 11273 + +#define SAY_SLAY1 "You will not prevail." +#define SOUND_SLAY1 11270 + +#define SAY_SLAY2 "You gambled...and lost." +#define SOUND_SLAY2 11271 + +#define SAY_MINDCONTROL1 "Obey me." +#define SOUND_MINDCONTROL1 11268 + +#define SAY_MINDCONTROL2 "Bow to my will." +#define SOUND_MINDCONTROL2 11269 + +#define SAY_GRAVITYLAPSE1 "Let us see how you fare when your world is turned upside down." +#define SOUND_GRAVITYLAPSE1 11264 + +#define SAY_GRAVITYLAPSE2 "Having trouble staying grounded?" +#define SOUND_GRAVITYLAPSE2 11265 + +#define SAY_SUMMON_PHOENIX1 "Anara'nel belore!" +#define SOUND_SUMMON_PHOENIX1 11267 + +#define SAY_SUMMON_PHOENIX2 "By the power of the sun!" +#define SOUND_SUMMON_PHOENIX2 11266 + +#define SAY_DEATH "For...Quel...thalas!" +#define SOUND_DEATH 11274 + +//Thaladred the Darkener speech +#define SAY_THALADRED_AGGRO "Prepare yourselves!" +#define SOUND_THALADRED_AGGRO 11203 +#define SAY_THALADRED_DEATH "Forgive me, my prince! I have... failed." +#define SOUND_THALADRED_DEATH 11204 +#define EMOTE_THALADRED_GAZE "sets his gaze on $N!" + +//Lord Sanguinar speech +#define SAY_SANGUINAR_AGGRO "Blood for blood!" +#define SOUND_SANGUINAR_AGGRO 11152 +#define SAY_SANGUINAR_DEATH "NO! I ...will... not..." +#define SOUND_SANGUINAR_DEATH 11153 + +//Grand Astromancer Capernian speech +#define SAY_CAPERNIAN_AGGRO "The sin'dore reign supreme!" +#define SOUND_CAPERNIAN_AGGRO 11117 +#define SAY_CAPERNIAN_DEATH "This is not over!" +#define SOUND_CAPERNIAN_DEATH 11118 + +//Master Engineer Telonicus speech +#define SAY_TELONICUS_AGGRO "Anar'alah belore!" +#define SOUND_TELONICUS_AGGRO 11157 +#define SAY_TELONICUS_DEATH "More perils... await" +#define SOUND_TELONICUS_DEATH 11158 + +//Creature IDs +#define PHOENIX 21362 +#define PHOENIX_EGG 21364 + +//Phoenix egg and phoenix model +#define PHOENIX_MODEL 19682 +#define PHOENIX_EGG_MODEL 20245 + +//#define PI 3.141592 +#define TEMP_MC_WHISPER "[SD2 Debug] You would be mind controlled here!" + +//weapon id + position +float KaelthasWeapons[7][5] = +{ + {21270, 794.38, 15, 48.72, 2.9}, //[Cosmic Infuser] + {21269, 785.47, 12.12, 48.72, 3.14}, //[Devastation] + {21271, 781.25, 4.39, 48.72, 3.14}, //[Infinity Blade] + {21273, 777.38, -0.81, 48.72, 3.06}, //[Phaseshift Bulwark] + {21274, 781.48, -6.08, 48.72, 3.9}, //[Staff of Disintegration] + {21272, 785.42, -13.59, 48.72, 3.4}, //[Warp Slicer] + {21268, 793.06, -16.61, 48.72, 3.10} //[Netherstrand Longbow] +}; + +#define GRAVITY_X 795.0f +#define GRAVITY_Y 0.0f +#define GRAVITY_Z 70.0f + +#define TIME_PHASE_2_3 120000 +#define TIME_PHASE_3_4 120000 + +#define KAEL_VISIBLE_RANGE 50.0f + +//Base AI for Advisors +struct MANGOS_DLL_DECL advisorbase_ai : public ScriptedAI +{ + ScriptedInstance* pInstance; + bool FakeDeath; + uint32 DelayRes_Timer; + uint64 DelayRes_Target; + + advisorbase_ai(Creature *c) : ScriptedAI(c) + { + pInstance = ((ScriptedInstance*)c->GetInstanceData()); + Reset(); + } + + void MoveInLineOfSight(Unit *who) + { + if (!who || FakeDeath || m_creature->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE)) + return; + + if( !m_creature->getVictim() && who->isTargetableForAttack() && ( m_creature->IsHostileTo( who )) && who->isInAccessablePlaceFor(m_creature) ) + { + if (!m_creature->canFly() && m_creature->GetDistanceZ(who) > CREATURE_Z_ATTACK_RANGE) + return; + + float attackRadius = m_creature->GetAttackDistance(who); + if(m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->IsWithinLOSInMap(who) ) + { + DoStartAttackAndMovement(who); + who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); + + if (!InCombat) + { + Aggro(who); + InCombat = true; + } + } + } + } + + void AttackStart(Unit* who) + { + if (!who || FakeDeath || m_creature->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE)) + return; + + if (who->isTargetableForAttack()) + { + //Begin attack + DoStartAttackAndMovement(who); + + if (!InCombat) + { + Aggro(who); + InCombat = true; + } + } + } + + void Reset() + { + FakeDeath = false; + DelayRes_Timer = 0; + DelayRes_Target = 0; + + m_creature->SetUInt32Value(UNIT_FIELD_BYTES_1, 0); + m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + + //reset encounter + if(pInstance && (pInstance->GetData(DATA_KAELTHASEVENT) == 1 || pInstance->GetData(DATA_KAELTHASEVENT) == 3)) + { + Creature *Kaelthas = NULL; + Kaelthas = (Creature*)(Unit::GetUnit((*m_creature), pInstance->GetData64(DATA_KAELTHAS))); + + if(Kaelthas) + Kaelthas->AI()->EnterEvadeMode(); + } + } + + void Revive(Unit* Target) + { + m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + m_creature->SetHealth(m_creature->GetMaxHealth()); + m_creature->SetUInt32Value(UNIT_FIELD_BYTES_1, 0); + DoCast(m_creature, SPELL_RES_VISUAL, false); + DelayRes_Timer = 2000; + } + + void DamageTaken(Unit* pKiller, uint32 &damage) + { + if (damage < m_creature->GetHealth()) + return; + + //Prevent glitch if in fake death + if (FakeDeath) + { + damage = 0; + return; + } + //Don't really die in phase 1 & 3, only die after that + if(pInstance && pInstance->GetData(DATA_KAELTHASEVENT) != 0) + { + //prevent death + damage = 0; + FakeDeath = true; + + m_creature->InterruptNonMeleeSpells(false); + m_creature->SetHealth(0); + m_creature->StopMoving(); + m_creature->ClearComboPointHolders(); + m_creature->RemoveAllAurasOnDeath(); + m_creature->ModifyAuraState(AURA_STATE_HEALTHLESS_20_PERCENT, false); + m_creature->ModifyAuraState(AURA_STATE_HEALTHLESS_35_PERCENT, false); + m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + m_creature->ClearAllReactives(); + m_creature->SetUInt64Value(UNIT_FIELD_TARGET,0); + m_creature->GetMotionMaster()->Clear(); + m_creature->GetMotionMaster()->MoveIdle(); + m_creature->SetUInt32Value(UNIT_FIELD_BYTES_1,PLAYER_STATE_DEAD); + + if (pInstance->GetData(DATA_KAELTHASEVENT) == 3) + JustDied(pKiller); + } + } + + void UpdateAI(const uint32 diff) + { + if (DelayRes_Timer) + if (DelayRes_Timer <= diff) + { + DelayRes_Timer = 0; + FakeDeath = false; + + Unit* Target = Unit::GetUnit((*m_creature), DelayRes_Target); + if (!Target)Target = m_creature->getVictim(); + DoResetThreat(); + AttackStart(Target); + m_creature->GetMotionMaster()->Clear(); + m_creature->GetMotionMaster()->MoveChase(Target); + m_creature->AddThreat(Target, 0.0f); + }else DelayRes_Timer -= diff; + } + +}; + +//Kael'thas AI +struct MANGOS_DLL_DECL boss_kaelthasAI : public ScriptedAI +{ + boss_kaelthasAI(Creature *c) : ScriptedAI(c) + { + pInstance = ((ScriptedInstance*)c->GetInstanceData()); + AdvisorGuid[0] = 0; + AdvisorGuid[1] = 0; + AdvisorGuid[2] = 0; + AdvisorGuid[3] = 0; + Reset(); + } + + ScriptedInstance* pInstance; + + uint32 Fireball_Timer; + uint32 ArcaneDisruption_Timer; + uint32 Phoenix_Timer; + uint32 ShockBarrier_Timer; + uint32 GravityLapse_Timer; + uint32 GravityLapse_Phase; + uint32 NetherBeam_Timer; + uint32 NetherVapor_Timer; + uint32 FlameStrike_Timer; + uint32 MindControl_Timer; + uint32 Phase; + uint32 PhaseSubphase; //generic + uint32 Phase_Timer; //generic timer + uint32 PyrosCasted; + + bool InGravityLapse; + bool IsCastingFireball; + bool ChainPyros; + + uint64 AdvisorGuid[4]; + + void Reset() + { + Fireball_Timer = 5000+rand()%10000; + ArcaneDisruption_Timer = 45000; + MindControl_Timer = 40000; + Phoenix_Timer = 50000; + ShockBarrier_Timer = 60000; + FlameStrike_Timer = 30000; + GravityLapse_Timer = 20000; + GravityLapse_Phase = 0; + NetherBeam_Timer = 8000; + NetherVapor_Timer = 10000; + PyrosCasted = 0; + Phase = 0; + InGravityLapse = false; + IsCastingFireball = false; + ChainPyros = false; + + if(InCombat) + PrepareAdvisors(); + + m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + + if(pInstance) + pInstance->SetData(DATA_KAELTHASEVENT, 0); + } + + void PrepareAdvisors() + { + Creature *pCreature; + for(uint8 i = 0; i < 4; i++) + { + pCreature = (Creature*)(Unit::GetUnit((*m_creature), AdvisorGuid[i])); + if(pCreature) + { + pCreature->Respawn(); + pCreature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + pCreature->setFaction(m_creature->getFaction()); + pCreature->AI()->EnterEvadeMode(); + } + } + } + + void StartEvent() + { + if(!pInstance) + return; + + AdvisorGuid[0] = pInstance->GetData64(DATA_THALADREDTHEDARKENER); + AdvisorGuid[1] = pInstance->GetData64(DATA_LORDSANGUINAR); + AdvisorGuid[2] = pInstance->GetData64(DATA_GRANDASTROMANCERCAPERNIAN); + AdvisorGuid[3] = pInstance->GetData64(DATA_MASTERENGINEERTELONICUS); + + if(!AdvisorGuid[0] || !AdvisorGuid[1] || !AdvisorGuid[2] || !AdvisorGuid[3]) + { + error_log("SD2: Kael'Thas One or more advisors missing, Skipping Phases 1-3"); + DoYell("SD2: Kael'Thas One or more advisors missing, Skipping Phases 1-3", LANG_UNIVERSAL, NULL); + + DoYell(SAY_PHASE4, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_PHASE4); + Phase = 4; + + pInstance->SetData(DATA_KAELTHASEVENT, 4); + + m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + + Unit *target = NULL; + target = SelectUnit(SELECT_TARGET_RANDOM, 0); + if(target) + { + DoStartAttackAndMovement(target); + } + }else + { + PrepareAdvisors(); + + DoYell(SAY_INTRO, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_INTRO); + + pInstance->SetData(DATA_KAELTHASEVENT, 1); + m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + + PhaseSubphase = 0; + Phase_Timer = 23000; + Phase = 1; + } + } + + void KilledUnit() + { + switch(rand()%2) + { + case 0: + DoYell(SAY_SLAY1,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_SLAY1); + break; + case 1: + DoYell(SAY_SLAY2,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_SLAY2); + break; + } + } + + void JustDied(Unit* Killer) + { + m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + + DoYell(SAY_DEATH,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_DEATH); + + if(pInstance) + pInstance->SetData(DATA_KAELTHASEVENT, 0); + + Creature *pCreature; + for(uint8 i = 0; i < 4; i++) + { + pCreature = (Creature*)(Unit::GetUnit((*m_creature), AdvisorGuid[i])); + if(pCreature) + { + pCreature->DealDamage(pCreature, pCreature->GetMaxHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); + } + } + } + + void Aggro(Unit *who) + { + if (pInstance && !pInstance->GetData(DATA_KAELTHASEVENT) && !Phase) + StartEvent(); + } + + void MoveInLineOfSight(Unit *who) + { + if (!m_creature->getVictim() && who->isTargetableForAttack() && who->isInAccessablePlaceFor(m_creature) && m_creature->IsHostileTo(who)) + { + if (!m_creature->canFly() && m_creature->GetDistanceZ(who) > CREATURE_Z_ATTACK_RANGE) + return; + + float attackRadius = m_creature->GetAttackDistance(who); + if (Phase >= 4 && m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->IsWithinLOSInMap(who)) + { + if(who->HasStealthAura()) + who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); + + DoStartAttackAndMovement(who); + } + else if(who->isAlive()) + { + if (pInstance && !pInstance->GetData(DATA_KAELTHASEVENT) && !Phase && m_creature->IsWithinDistInMap(who, 60.0f)) + StartEvent(); + + //add to the threat list, so we can use SelectTarget + m_creature->AddThreat(who,0.0f); + } + } + } + + void UpdateAI(const uint32 diff) + { + //Phase 1 + switch (Phase) + { + case 1: + { + Unit *target; + Creature* Advisor; + + //Subphase switch + switch(PhaseSubphase) + { + //Subphase 1 - Start + case 0: + if(Phase_Timer < diff) + { + DoYell(SAY_THALADRED_THE_DARKENER, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_THALADRED_THE_DARKENER); + + //start advisor within 7 seconds + Phase_Timer = 7000; + + PhaseSubphase++; + }else Phase_Timer -= diff; + break; + + //Subphase 1 - Unlock advisor + case 1: + if(Phase_Timer < diff) + { + Advisor = (Creature*)(Unit::GetUnit((*m_creature), AdvisorGuid[0])); + + if(Advisor) + { + Advisor->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + Advisor->setFaction(m_creature->getFaction()); + + target = SelectUnit(SELECT_TARGET_RANDOM, 0); + if(target) + Advisor->AI()->AttackStart(target); + } + + PhaseSubphase++; + }else Phase_Timer -= diff; + break; + + //Subphase 2 - Start + case 2: + Advisor = (Creature*)(Unit::GetUnit((*m_creature), AdvisorGuid[0])); + if(Advisor && (Advisor->GetUInt32Value(UNIT_FIELD_BYTES_1) == PLAYER_STATE_DEAD)) + { + DoYell(SAY_LORD_SANGUINAR, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_LORD_SANGUINAR); + + //start advisor within 12.5 seconds + Phase_Timer = 12500; + + PhaseSubphase++; + } + break; + + //Subphase 2 - Unlock advisor + case 3: + if(Phase_Timer < diff) + { + Advisor = (Creature*)(Unit::GetUnit((*m_creature), AdvisorGuid[1])); + + if(Advisor) + { + Advisor->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + Advisor->setFaction(m_creature->getFaction()); + + target = SelectUnit(SELECT_TARGET_RANDOM, 0); + if(target) + Advisor->AI()->AttackStart(target); + } + + PhaseSubphase++; + }else Phase_Timer -= diff; + break; + + //Subphase 3 - Start + case 4: + Advisor = (Creature*)(Unit::GetUnit((*m_creature), AdvisorGuid[1])); + if(Advisor && (Advisor->GetUInt32Value(UNIT_FIELD_BYTES_1) == PLAYER_STATE_DEAD)) + { + DoYell(SAY_ASTROMANCER_CAPERNIAN, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_ASTROMANCER_CAPERNIAN); + + //start advisor within 7 seconds + Phase_Timer = 7000; + + PhaseSubphase++; + } + break; + + //Subphase 3 - Unlock advisor + case 5: + if(Phase_Timer < diff) + { + Advisor = (Creature*)(Unit::GetUnit((*m_creature), AdvisorGuid[2])); + + if(Advisor) + { + Advisor->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + Advisor->setFaction(m_creature->getFaction()); + + target = SelectUnit(SELECT_TARGET_RANDOM, 0); + if(target) + Advisor->AI()->AttackStart(target); + } + + PhaseSubphase++; + }else Phase_Timer -= diff; + break; + + //Subphase 4 - Start + case 6: + Advisor = (Creature*)(Unit::GetUnit((*m_creature), AdvisorGuid[2])); + if(Advisor && (Advisor->GetUInt32Value(UNIT_FIELD_BYTES_1) == PLAYER_STATE_DEAD)) + { + DoYell(SAY_ENGINEER_TELONICUS, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_ENGINEER_TELONICUS); + + //start advisor within 8.4 seconds + Phase_Timer = 8400; + + PhaseSubphase++; + } + break; + + //Subphase 4 - Unlock advisor + case 7: + if(Phase_Timer < diff) + { + Advisor = (Creature*)(Unit::GetUnit((*m_creature), AdvisorGuid[3])); + + if(Advisor) + { + Advisor->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + Advisor->setFaction(m_creature->getFaction()); + + target = SelectUnit(SELECT_TARGET_RANDOM, 0); + if(target) + Advisor->AI()->AttackStart(target); + } + + Phase_Timer = 3000; + + PhaseSubphase++; + }else Phase_Timer -= diff; + break; + + //End of phase 1 + case 8: + Advisor = (Creature*)(Unit::GetUnit((*m_creature), AdvisorGuid[3])); + if(Advisor && (Advisor->GetUInt32Value(UNIT_FIELD_BYTES_1) == PLAYER_STATE_DEAD)) + { + Phase = 2; + pInstance->SetData(DATA_KAELTHASEVENT, 2); + + DoYell(SAY_PHASE2, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_PHASE2); + PhaseSubphase = 0; + Phase_Timer = 3500; + DoCast(m_creature, SPELL_SUMMON_WEAPONS); + } + break; + } + }break; + + case 2: + { + if (PhaseSubphase == 0) + { + if (Phase_Timer < diff) + { + PhaseSubphase = 1; + }else Phase_Timer -= diff; + } + + //Spawn weapons + if (PhaseSubphase == 1) + { + Unit* Target = SelectUnit(SELECT_TARGET_RANDOM, 0); + + Creature* Weapon; + for (uint32 i = 0; i < 7; i++) + { + Weapon = m_creature->SummonCreature(((uint32)KaelthasWeapons[i][0]),KaelthasWeapons[i][1],KaelthasWeapons[i][2],KaelthasWeapons[i][3],0,TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 60000); + + if (!Weapon) + error_log("SD2: Kael'thas weapon %i could not be spawned", i); + else + { + Weapon->setFaction(m_creature->getFaction()); + Weapon->AI()->AttackStart(Target); + Weapon->CastSpell(Weapon, SPELL_WEAPON_SPAWN, false); + } + } + + PhaseSubphase = 2; + Phase_Timer = TIME_PHASE_2_3; + } + + if (PhaseSubphase == 2) + if (Phase_Timer < diff) + { + DoYell(SAY_PHASE3, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_PHASE3); + pInstance->SetData(DATA_KAELTHASEVENT, 3); + Phase = 3; + PhaseSubphase = 0; + }else Phase_Timer -= diff; + }break; + + case 3: + { + if (PhaseSubphase == 0) + { + //Respawn advisors + Unit* Target = SelectUnit(SELECT_TARGET_RANDOM, 0); + + Creature* Advisor; + for (uint32 i = 0; i < 4; i++) + { + Advisor = (Creature*)(Unit::GetUnit((*m_creature), AdvisorGuid[i])); + if (!Advisor) + error_log("SD2: Kael'Thas Advisor %u does not exist. Possibly despawned? Incorrectly Killed?", i); + else ((advisorbase_ai*)Advisor->AI())->Revive(Target); + } + + PhaseSubphase = 1; + Phase_Timer = TIME_PHASE_3_4; + } + + if(Phase_Timer < diff) + { + DoYell(SAY_PHASE4, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_PHASE4); + Phase = 4; + + pInstance->SetData(DATA_KAELTHASEVENT, 4); + + m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + + Unit *target = NULL; + target = SelectUnit(SELECT_TARGET_RANDOM, 0); + if(target) + { + DoStartAttackAndMovement(target); + } + Phase_Timer = 30000; + }else Phase_Timer -= diff; + } + break; + + case 4: + case 5: + case 6: + { + //Return since we have no target + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + //Fireball_Timer + if(!InGravityLapse && !ChainPyros && Phase != 5) + { + if(Fireball_Timer < diff) + { + if(!IsCastingFireball) + { + if(!m_creature->IsNonMeleeSpellCasted(false)) + { + //interruptable + m_creature->ApplySpellImmune(0, IMMUNITY_EFFECT, SPELL_EFFECT_INTERRUPT_CAST, false); + int32 dmg = 20000+rand()%5000; + m_creature->CastCustomSpell(m_creature->getVictim(), SPELL_FIREBALL, &dmg, 0, 0, false); + IsCastingFireball = true; + Fireball_Timer = 2500; + } + } + else + { + //apply resistance + m_creature->ApplySpellImmune(0, IMMUNITY_EFFECT, SPELL_EFFECT_INTERRUPT_CAST, true); + IsCastingFireball = false; + Fireball_Timer = 5000+rand()%10000; + } + }else Fireball_Timer -= diff; + + //ArcaneDisruption_Timer + if(ArcaneDisruption_Timer < diff) + { + DoCast(m_creature->getVictim(), SPELL_ARCANE_DISRUPTION, true); + + ArcaneDisruption_Timer = 60000; + }else ArcaneDisruption_Timer -= diff; + + if (FlameStrike_Timer < diff) + { + Unit* pUnit = SelectUnit(SELECT_TARGET_RANDOM, 0); + DoCast(pUnit, SPELL_FLAME_STRIKE); + + FlameStrike_Timer = 30000; + }FlameStrike_Timer -= diff; + + if (MindControl_Timer < diff) + { + if (m_creature->getThreatManager().getThreatList().size() >= 2) + for (uint32 i = 0; i < 3; i++) + { + debug_log("SD2: Kael'Thas mind control not supported."); + //DoCast(pUnit, SPELL_MIND_CONTROL); + } + + MindControl_Timer = 60000; + }MindControl_Timer -= diff; + } + + //Phoenix_Timer + if(Phoenix_Timer < diff) + { + DoCast(m_creature, SPELL_PHOENIX_ANIMATION); + Creature *Phoenix = DoSpawnCreature(PHOENIX, 0, 0, 0, 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 45000); + + if(Phoenix) + { + Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0); + if (target) + Phoenix->AI()->AttackStart(target); + }else error_log("SD2: Kael'Thas Phoenix could not be spawned"); + + switch(rand()%2) + { + case 0: + DoYell(SAY_SUMMON_PHOENIX1, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_SUMMON_PHOENIX1); + break; + + case 1: + DoYell(SAY_SUMMON_PHOENIX2, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_SUMMON_PHOENIX2); + break; + + default: + break; + } + + Phoenix_Timer = 60000; + }else Phoenix_Timer -= diff; + + //Phase 4 specific spells + if(Phase == 4) + { + if (m_creature->GetHealth()*100 / m_creature->GetMaxHealth() < 50) + { + pInstance->SetData(DATA_KAELTHASEVENT, 4); + Phase = 5; + Phase_Timer = 10000; + + DoYell(SAY_PHASE5, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_PHASE5); + + m_creature->StopMoving(); + m_creature->GetMotionMaster()->Clear(); + m_creature->GetMotionMaster()->MoveIdle(); + m_creature->Relocate(GRAVITY_X, GRAVITY_Y, GRAVITY_Z, 0); + m_creature->SendMonsterMove(GRAVITY_X, GRAVITY_Y,GRAVITY_Z, 0, 0, 0); + + m_creature->InterruptNonMeleeSpells(false); + DoCast(m_creature, SPELL_FULLPOWER); + m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + } + + //ShockBarrier_Timer + if(ShockBarrier_Timer < diff) + { + DoCast(m_creature, SPELL_SHOCK_BARRIER); + ChainPyros = true; + PyrosCasted = 0; + + ShockBarrier_Timer = 60000; + }else ShockBarrier_Timer -= diff; + + //Chain Pyros (3 of them max) + if (ChainPyros && !m_creature->IsNonMeleeSpellCasted(false)) + { + if (PyrosCasted < 3) + { + DoCast(m_creature->getVictim(), SPELL_PYROBLAST); + PyrosCasted++; + + }else + { + ChainPyros = false; + Fireball_Timer = 2500; + ArcaneDisruption_Timer = 60000; + } + } + } + + if (Phase == 5) + { + if(Phase_Timer < diff) + { + m_creature->InterruptNonMeleeSpells(false); + m_creature->RemoveAurasDueToSpell(SPELL_FULLPOWER); + DoCast(m_creature, SPELL_EXPLODE); + m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + Phase = 6; + DoStartAttackAndMovement(m_creature->getVictim()); + m_creature->GetMotionMaster()->Clear(); + m_creature->GetMotionMaster()->MoveChase(m_creature->getVictim()); + + }else Phase_Timer -= diff; + } + + //Phase 5 + if(Phase == 6) + { + + //GravityLapse_Timer + if(GravityLapse_Timer < diff) + { + std::list::iterator i = m_creature->getThreatManager().getThreatList().begin(); + switch(GravityLapse_Phase) + { + case 0: + m_creature->StopMoving(); + m_creature->GetMotionMaster()->Clear(); + m_creature->GetMotionMaster()->MoveIdle(); + m_creature->Relocate(GRAVITY_X, GRAVITY_Y, GRAVITY_Z, 0); + m_creature->SendMonsterMove(GRAVITY_X, GRAVITY_Y, GRAVITY_Z, 0, 0, 0); + // 1) Kael'thas will portal the whole raid right into his body + for (i = m_creature->getThreatManager().getThreatList().begin(); i!= m_creature->getThreatManager().getThreatList().end();++i) + { + Unit* pUnit = Unit::GetUnit((*m_creature), (*i)->getUnitGuid()); + if(pUnit && (pUnit->GetTypeId() == TYPEID_PLAYER)) + { + //Use work around packet to prevent player from being dropped from combat + DoTeleportPlayer(pUnit, GRAVITY_X, GRAVITY_Y, GRAVITY_Z, pUnit->GetOrientation()); + } + } + GravityLapse_Timer = 500; + ++GravityLapse_Phase; + InGravityLapse = true; + ShockBarrier_Timer = 1000; + NetherBeam_Timer = 5000; + break; + + case 1: + switch(rand()%2) + { + case 0: + DoYell(SAY_GRAVITYLAPSE1, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_GRAVITYLAPSE1); + break; + + case 1: + DoYell(SAY_GRAVITYLAPSE2, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_GRAVITYLAPSE2); + break; + } + + // 2) At that point he will put a Gravity Lapse debuff on everyone + for (i = m_creature->getThreatManager().getThreatList().begin(); i!= m_creature->getThreatManager().getThreatList().end();i++) + { + Unit* pUnit = Unit::GetUnit((*m_creature), (*i)->getUnitGuid()); + if(pUnit) + { + m_creature->CastSpell(pUnit, SPELL_KNOCKBACK, true); + //Gravity lapse - needs an exception in Spell system to work + + pUnit->CastSpell(pUnit, SPELL_GRAVITY_LAPSE, true, 0, 0, m_creature->GetGUID()); + pUnit->CastSpell(pUnit, SPELL_GRAVITY_LAPSE_AURA, true, 0, 0, m_creature->GetGUID()); + + //Using packet workaround + WorldPacket data(12); + data.SetOpcode(SMSG_MOVE_SET_CAN_FLY); + data.append(pUnit->GetPackGUID()); + data << uint32(0); + pUnit->SendMessageToSet(&data, true); + } + } + GravityLapse_Timer = 10000; + GravityLapse_Phase++; + break; + + case 2: + //Cast nether vapor aura on self + m_creature->InterruptNonMeleeSpells(false); + DoCast(m_creature, SPELL_NETHER_VAPOR); + + GravityLapse_Timer = 20000; + GravityLapse_Phase++; + break; + + case 3: + //Remove flight + for (i = m_creature->getThreatManager().getThreatList().begin(); i!= m_creature->getThreatManager().getThreatList().end();i++) + { + Unit* pUnit = Unit::GetUnit((*m_creature), (*i)->getUnitGuid()); + if(pUnit) + { + //Using packet workaround + WorldPacket data(12); + data.SetOpcode(SMSG_MOVE_UNSET_CAN_FLY); + data.append(pUnit->GetPackGUID()); + data << uint32(0); + pUnit->SendMessageToSet(&data, true); + } + } + m_creature->RemoveAurasDueToSpell(SPELL_NETHER_VAPOR); + InGravityLapse = false; + GravityLapse_Timer = 60000; + GravityLapse_Phase = 0; + DoStartAttackAndMovement(m_creature->getVictim()); + m_creature->GetMotionMaster()->Clear(); + m_creature->GetMotionMaster()->MoveChase(m_creature->getVictim()); + DoResetThreat(); + break; + } + }else GravityLapse_Timer -= diff; + + if(InGravityLapse) + { + //ShockBarrier_Timer + if(ShockBarrier_Timer < diff) + { + DoCast(m_creature, SPELL_SHOCK_BARRIER); + + ShockBarrier_Timer = 20000; + }else ShockBarrier_Timer -= diff; + + //NetherBeam_Timer + if(NetherBeam_Timer < diff) + { + Unit* pUnit = SelectUnit(SELECT_TARGET_RANDOM, 0); + DoCast(pUnit, SPELL_NETHER_BEAM); + + NetherBeam_Timer = 4000; + }else NetherBeam_Timer -= diff; + } + } + + if (!InGravityLapse) + DoMeleeAttackIfReady(); + } + } + } +}; + +//Thaladred the Darkener AI +struct MANGOS_DLL_DECL boss_thaladred_the_darkenerAI : public advisorbase_ai +{ + boss_thaladred_the_darkenerAI(Creature *c) : advisorbase_ai(c) {} + + uint32 Gaze_Timer; + uint32 Silence_Timer; + uint32 PsychicBlow_Timer; + + void Reset() + { + Gaze_Timer = 100; + Silence_Timer = 20000; + PsychicBlow_Timer = 10000; + + advisorbase_ai::Reset(); + } + + void JustDied(Unit* pKiller) + { + DoPlaySoundToSet(m_creature, SOUND_THALADRED_DEATH); + DoYell(SAY_THALADRED_DEATH, LANG_UNIVERSAL, NULL); + } + + void Aggro(Unit *who) + { + if (m_creature->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE)) + return; + + if (!who || FakeDeath) + return; + + DoYell(SAY_THALADRED_AGGRO, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_THALADRED_AGGRO); + m_creature->AddThreat(who, 5000000.0f); + } + + void UpdateAI(const uint32 diff) + { + advisorbase_ai::UpdateAI(diff); + + //Faking death, don't do anything + if (FakeDeath) + return; + + //Return since we have no target + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + //Gaze_Timer + if(Gaze_Timer < diff) + { + Unit* target = NULL; + target = SelectUnit(SELECT_TARGET_RANDOM, 0); + if(target) + { + DoResetThreat(); + m_creature->AddThreat(target, 5000000.0f); + DoTextEmote(EMOTE_THALADRED_GAZE, target); + Gaze_Timer = 8500; + } + }else Gaze_Timer -= diff; + + //Silence_Timer + if(Silence_Timer < diff) + { + DoCast(m_creature->getVictim(), SPELL_SILENCE); + Silence_Timer = 20000; + }else Silence_Timer -= diff; + + //PsychicBlow_Timer + if(PsychicBlow_Timer < diff) + { + DoCast(m_creature->getVictim(), SPELL_PSYCHIC_BLOW); + PsychicBlow_Timer = 20000+rand()%5000; + }else PsychicBlow_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; + +//Lord Sanguinar AI +struct MANGOS_DLL_DECL boss_lord_sanguinarAI : public advisorbase_ai +{ + boss_lord_sanguinarAI(Creature *c) : advisorbase_ai(c){} + + uint32 Fear_Timer; + + void Reset() + { + Fear_Timer = 20000; + advisorbase_ai::Reset(); + } + + void JustDied(Unit* Killer) + { + DoPlaySoundToSet(m_creature, SOUND_SANGUINAR_DEATH); + DoYell(SAY_SANGUINAR_DEATH, LANG_UNIVERSAL, NULL); + } + + void Aggro(Unit *who) + { + if (m_creature->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE)) + return; + + if (!who || FakeDeath) + return; + + DoYell(SAY_SANGUINAR_AGGRO, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_SANGUINAR_AGGRO); + } + + void UpdateAI(const uint32 diff) + { + advisorbase_ai::UpdateAI(diff); + + //Faking death, don't do anything + if (FakeDeath) + return; + + //Return since we have no target + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + //Fear_Timer + if(Fear_Timer < diff) + { + DoCast(m_creature->getVictim(), SPELL_BELLOWING_ROAR); + Fear_Timer = 25000+rand()%10000; //approximately every 30 seconds + }else Fear_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; + +//Grand Astromancer Capernian AI +struct MANGOS_DLL_DECL boss_grand_astromancer_capernianAI : public advisorbase_ai +{ + boss_grand_astromancer_capernianAI(Creature *c) : advisorbase_ai(c){} + + uint32 Fireball_Timer; + uint32 Conflagration_Timer; + uint32 ArcaneExplosion_Timer; + uint32 Yell_Timer; + bool Yell; + + void Reset() + { + Fireball_Timer = 2000; + Conflagration_Timer = 20000; + ArcaneExplosion_Timer = 5000; + Yell_Timer = 2000; + Yell = false; + + advisorbase_ai::Reset(); + } + + void JustDied(Unit* pKiller) + { + DoPlaySoundToSet(m_creature, SOUND_CAPERNIAN_DEATH); + DoYell(SAY_CAPERNIAN_DEATH, LANG_UNIVERSAL, NULL); + } + + void AttackStart(Unit* who) + { + if (!who || FakeDeath || m_creature->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE)) + return; + + if (who->isTargetableForAttack()) + { + //Begin attack + DoStartAttackAndMovement(who, CAPERNIAN_DISTANCE, M_PI/2); + + if (!InCombat) + { + Aggro(who); + InCombat = true; + } + } + } + + void Aggro(Unit *who) + { + if (m_creature->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE)) + return; + + if (!who || FakeDeath) + return; + } + + void UpdateAI(const uint32 diff) + { + advisorbase_ai::UpdateAI(diff); + + //Faking Death, don't do anything + if (FakeDeath) + return; + + //Return since we have no target + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + //Yell_Timer + if(!Yell) + if(Yell_Timer < diff) + { + DoYell(SAY_CAPERNIAN_AGGRO, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_CAPERNIAN_AGGRO); + + Yell = true; + }else Yell_Timer -= diff; + + //Fireball_Timer + if(Fireball_Timer < diff) + { + DoCast(m_creature->getVictim(), SPELL_CAPERNIAN_FIREBALL); + Fireball_Timer = 4000; + }else Fireball_Timer -= diff; + + //Conflagration_Timer + if(Conflagration_Timer < diff) + { + Unit *target = NULL; + target = SelectUnit(SELECT_TARGET_RANDOM, 0); + + if(target && m_creature->IsWithinDistInMap(target, 30)) + DoCast(target, SPELL_CONFLAGRATION); + else + DoCast(m_creature->getVictim(), SPELL_CONFLAGRATION); + + Conflagration_Timer = 10000+rand()%5000; + }else Conflagration_Timer -= diff; + + //ArcaneExplosion_Timer + if(ArcaneExplosion_Timer < diff) + { + bool InMeleeRange = false; + Unit *target = NULL; + std::list& m_threatlist = m_creature->getThreatManager().getThreatList(); + for (std::list::iterator i = m_threatlist.begin(); i!= m_threatlist.end();++i) + { + Unit* pUnit = Unit::GetUnit((*m_creature), (*i)->getUnitGuid()); + //if in melee range + if(pUnit && pUnit->IsWithinDistInMap(m_creature, 5)) + { + InMeleeRange = true; + target = pUnit; + break; + } + } + + if(InMeleeRange) + DoCast(target, SPELL_ARCANE_EXPLOSION); + + ArcaneExplosion_Timer = 4000+rand()%2000; + }else ArcaneExplosion_Timer -= diff; + + //Do NOT deal any melee damage. + } +}; + +//Master Engineer Telonicus AI +struct MANGOS_DLL_DECL boss_master_engineer_telonicusAI : public advisorbase_ai +{ + boss_master_engineer_telonicusAI(Creature *c) : advisorbase_ai(c){} + + uint32 Bomb_Timer; + uint32 RemoteToy_Timer; + + void Reset() + { + Bomb_Timer = 10000; + RemoteToy_Timer = 5000; + + advisorbase_ai::Reset(); + } + + void JustDied(Unit* pKiller) + { + DoPlaySoundToSet(m_creature, SOUND_TELONICUS_DEATH); + DoYell(SAY_TELONICUS_DEATH, LANG_UNIVERSAL, NULL); + } + + void Aggro(Unit *who) + { + if (m_creature->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE)) + return; + + if (!who || FakeDeath) + return; + + DoYell(SAY_TELONICUS_AGGRO, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_TELONICUS_AGGRO); + } + + void UpdateAI(const uint32 diff) + { + advisorbase_ai::UpdateAI(diff); + + //Faking Death, do nothing + if (FakeDeath) + return; + + //Return since we have no target + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + //Bomb_Timer + if(Bomb_Timer < diff) + { + DoCast(m_creature->getVictim(), SPELL_BOMB); + Bomb_Timer = 25000; + }else Bomb_Timer -= diff; + + //RemoteToy_Timer + if(RemoteToy_Timer < diff) + { + Unit *target = NULL; + target = SelectUnit(SELECT_TARGET_RANDOM, 0); + + if(target) + DoCast(target, SPELL_REMOTE_TOY); + + RemoteToy_Timer = 10000+rand()%5000; + }else RemoteToy_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; + +//Flame Strike AI +struct MANGOS_DLL_DECL mob_kael_flamestrikeAI : public ScriptedAI +{ + mob_kael_flamestrikeAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 Timer; + bool Casting; + bool KillSelf; + + void Reset() + { + Timer = 5000; + Casting = false; + KillSelf = false; + + m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + m_creature->setFaction(14); + } + + void Aggro(Unit *who) + { + } + + void MoveInLineOfSight(Unit *who) + { + } + + void UpdateAI(const uint32 diff) + { + if (!Casting) + { + DoCast(m_creature, SPELL_FLAME_STRIKE_VIS); + Casting = true; + } + + //Timer + if(Timer < diff) + { + if (!KillSelf) + { + m_creature->InterruptNonMeleeSpells(false); + DoCast(m_creature, SPELL_FLAME_STRIKE_DMG); + }else m_creature->DealDamage(m_creature, m_creature->GetMaxHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); + + KillSelf = true; + Timer = 1000; + }else Timer -= diff; + } +}; + +//Phoenix AI +struct MANGOS_DLL_DECL mob_phoenixAI : public ScriptedAI +{ + mob_phoenixAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 Burn_Timer; + uint32 Hatch_Timer; + uint32 EggVis_Timer; + bool IsEgg; + + void Reset() + { + Burn_Timer = 1000; + Hatch_Timer = 15000; + EggVis_Timer = 0; + IsEgg = false; + m_creature->SetUInt32Value(UNIT_FIELD_DISPLAYID, PHOENIX_MODEL); + } + + void Hatch() + { + IsEgg = false; + m_creature->SetHealth(m_creature->GetMaxHealth()); + m_creature->SetUInt32Value(UNIT_FIELD_DISPLAYID, PHOENIX_MODEL); + Burn_Timer = 1000; + Hatch_Timer = 15000; + EggVis_Timer = 0; + AttackStart(m_creature->getVictim()); + } + + void DamageTaken(Unit* pKiller, uint32 &damage) + { + if (damage < m_creature->GetHealth()) + return; + + //Bird cannot die, only egg + if (!IsEgg) + { + //prevent death + damage = 0; + IsEgg = true; + + m_creature->GetMotionMaster()->Clear(); + m_creature->GetMotionMaster()->MoveIdle(); + m_creature->SetHealth(m_creature->GetMaxHealth()); + EggVis_Timer = 1000; + m_creature->SetUInt32Value(UNIT_FIELD_BYTES_1,PLAYER_STATE_DEAD); + } + } + + void Aggro(Unit *who) + { + } + + void UpdateAI(const uint32 diff) + { + //Check if we have a current target + if (!IsEgg) + { + //Return since we have no target + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + if (Burn_Timer < diff) + { + DoCast(m_creature->getVictim(), SPELL_BURN); + Burn_Timer = 1000; + }else Burn_Timer -= diff; + + DoMeleeAttackIfReady(); + } + else + { + if (EggVis_Timer) + if (EggVis_Timer <= diff) + { + m_creature->SetUInt32Value(UNIT_FIELD_DISPLAYID, PHOENIX_EGG_MODEL); + m_creature->SetUInt32Value(UNIT_FIELD_BYTES_1, 0); + EggVis_Timer = 0; + }else EggVis_Timer -= diff; + + if (Hatch_Timer < diff) + { + Hatch(); + }else Hatch_Timer -= diff; + } + } +}; + +CreatureAI* GetAI_boss_kaelthas(Creature *_Creature) +{ + return new boss_kaelthasAI (_Creature); +} + +CreatureAI* GetAI_boss_thaladred_the_darkener(Creature *_Creature) +{ + return new boss_thaladred_the_darkenerAI (_Creature); +} + +CreatureAI* GetAI_boss_lord_sanguinar(Creature *_Creature) +{ + return new boss_lord_sanguinarAI (_Creature); +} + +CreatureAI* GetAI_boss_grand_astromancer_capernian(Creature *_Creature) +{ + return new boss_grand_astromancer_capernianAI (_Creature); +} + +CreatureAI* GetAI_boss_master_engineer_telonicus(Creature *_Creature) +{ + return new boss_master_engineer_telonicusAI (_Creature); +} + +CreatureAI* GetAI_mob_kael_flamestrike(Creature *_Creature) +{ + return new mob_kael_flamestrikeAI (_Creature); +} + +CreatureAI* GetAI_mob_phoenix(Creature *_Creature) +{ + return new mob_phoenixAI (_Creature); +} + +void AddSC_boss_kaelthas() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_kaelthas"; + newscript->GetAI = GetAI_boss_kaelthas; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="boss_thaladred_the_darkener"; + newscript->GetAI = GetAI_boss_thaladred_the_darkener; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="boss_lord_sanguinar"; + newscript->GetAI = GetAI_boss_lord_sanguinar; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="boss_grand_astromancer_capernian"; + newscript->GetAI = GetAI_boss_grand_astromancer_capernian; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="boss_master_engineer_telonicus"; + newscript->GetAI = GetAI_boss_master_engineer_telonicus; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name= "mob_kael_flamestrike"; + newscript->GetAI = GetAI_mob_kael_flamestrike; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="mob_phoenix"; + newscript->GetAI = GetAI_mob_phoenix; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/tempest_keep/the_eye/boss_void_reaver.cpp b/src/bindings/scripts/scripts/zone/tempest_keep/the_eye/boss_void_reaver.cpp index 43072b1947d..0dbf7d66761 100644 --- a/src/bindings/scripts/scripts/zone/tempest_keep/the_eye/boss_void_reaver.cpp +++ b/src/bindings/scripts/scripts/zone/tempest_keep/the_eye/boss_void_reaver.cpp @@ -1,203 +1,203 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Void_Reaver -SD%Complete: 100 -SDComment: -SDCategory: Tempest Keep, The Eye -EndScriptData */ - -#include "precompiled.h" -#include "def_the_eye.h" - -#define SPELL_POUNDING 34162 -#define SPELL_ARCANE_ORB_TRIGGER 34172 -#define SPELL_KNOCK_AWAY 11130 -#define SPELL_BERSERK 27680 - -#define SAY_AGGRO "Alert, you are marked for extermination!" -#define SAY_SLAY1 "Extermination, successful." -#define SAY_SLAY2 "Imbecile life form, no longer functional." -#define SAY_SLAY3 "Threat neutralized." -#define SAY_DEATH "Systems... shutting... down..." -#define SAY_POUNDING1 "Alternative measure commencing..." -#define SAY_POUNDING2 "Calculating force parameters..." - -#define SOUND_AGGRO 11213 -#define SOUND_SLAY1 11215 -#define SOUND_SLAY2 11216 -#define SOUND_SLAY3 11217 -#define SOUND_DEATH 11214 -#define SOUND_POUNDING1 11218 -#define SOUND_POUNDING2 11219 - -#define CREATURE_ORB_TARGET 19577 - -struct MANGOS_DLL_DECL boss_void_reaverAI : public ScriptedAI -{ - boss_void_reaverAI(Creature *c) : ScriptedAI(c) - { - pInstance = ((ScriptedInstance*)c->GetInstanceData()); - Reset(); - } - - ScriptedInstance* pInstance; - - uint32 Pounding_Timer; - uint32 ArcaneOrb_Timer; - uint32 KnockAway_Timer; - uint32 Berserk_Timer; - - void Reset() - { - Pounding_Timer = 12000; - ArcaneOrb_Timer = 3000; - KnockAway_Timer = 30000; - Berserk_Timer = 600000; - - if(pInstance) - pInstance->SetData(DATA_VOIDREAVEREVENT, NOT_STARTED); - } - - void KilledUnit(Unit *victim) - { - switch(rand()%3) - { - case 0: - DoYell(SAY_SLAY1, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_SLAY1); - break; - case 1: - DoYell(SAY_SLAY2, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_SLAY2); - break; - case 2: - DoYell(SAY_SLAY3, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_SLAY3); - break; - } - } - - void JustDied(Unit *victim) - { - DoYell(SAY_DEATH, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_DEATH); - - if(pInstance) - pInstance->SetData(DATA_VOIDREAVEREVENT, NOT_STARTED); - } - - void Aggro(Unit *who) - { - DoYell(SAY_AGGRO, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_AGGRO); - - if(pInstance) - pInstance->SetData(DATA_VOIDREAVEREVENT, IN_PROGRESS); - } - - void UpdateAI(const uint32 diff) - { - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - // Pounding - if(Pounding_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_POUNDING); - - switch(rand()%2) - { - case 0: - DoPlaySoundToSet(m_creature, SOUND_POUNDING1); - DoYell(SAY_POUNDING1, LANG_UNIVERSAL, NULL); - break; - case 1: - DoPlaySoundToSet(m_creature, SOUND_POUNDING2); - DoYell(SAY_POUNDING2, LANG_UNIVERSAL, NULL); - break; - } - Pounding_Timer = 12000; - }else Pounding_Timer -= diff; - - // Arcane Orb - if(ArcaneOrb_Timer < diff) - { - Unit *target; - std::list t_list = m_creature->getThreatManager().getThreatList(); - std::vector target_list; - for(std::list::iterator itr = t_list.begin(); itr!= t_list.end(); ++itr) - { - target = Unit::GetUnit(*m_creature, (*itr)->getUnitGuid()); - //15 yard radius minimum - if(target && target->GetDistance2d(m_creature) > 15) - target_list.push_back(target); - target = NULL; - } - if(target_list.size()) - target = *(target_list.begin()+rand()%target_list.size()); - - if (target) - { - Unit* Spawn = NULL; - Spawn = m_creature->SummonCreature(CREATURE_ORB_TARGET, target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN, 10000); - if (Spawn) - m_creature->CastSpell(Spawn, SPELL_ARCANE_ORB_TRIGGER, true); - } - - ArcaneOrb_Timer = 3000; - }else ArcaneOrb_Timer -= diff; - - // Single Target knock back, reduces aggro - if(KnockAway_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_KNOCK_AWAY); - - //Drop 25% aggro - if(m_creature->getThreatManager().getThreat(m_creature->getVictim())) - m_creature->getThreatManager().modifyThreatPercent(m_creature->getVictim(),-25); - - KnockAway_Timer = 30000; - }else KnockAway_Timer -= diff; - - //Berserk - if(Berserk_Timer < diff) - { - if (m_creature->IsNonMeleeSpellCasted(false)) - m_creature->InterruptNonMeleeSpells(false); - - DoCast(m_creature,SPELL_BERSERK); - Berserk_Timer = 600000; - }else Berserk_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; - -CreatureAI* GetAI_boss_void_reaver(Creature *_Creature) -{ - return new boss_void_reaverAI (_Creature); -} - -void AddSC_boss_void_reaver() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_void_reaver"; - newscript->GetAI = GetAI_boss_void_reaver; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Void_Reaver +SD%Complete: 100 +SDComment: +SDCategory: Tempest Keep, The Eye +EndScriptData */ + +#include "precompiled.h" +#include "def_the_eye.h" + +#define SPELL_POUNDING 34162 +#define SPELL_ARCANE_ORB_TRIGGER 34172 +#define SPELL_KNOCK_AWAY 11130 +#define SPELL_BERSERK 27680 + +#define SAY_AGGRO "Alert, you are marked for extermination!" +#define SAY_SLAY1 "Extermination, successful." +#define SAY_SLAY2 "Imbecile life form, no longer functional." +#define SAY_SLAY3 "Threat neutralized." +#define SAY_DEATH "Systems... shutting... down..." +#define SAY_POUNDING1 "Alternative measure commencing..." +#define SAY_POUNDING2 "Calculating force parameters..." + +#define SOUND_AGGRO 11213 +#define SOUND_SLAY1 11215 +#define SOUND_SLAY2 11216 +#define SOUND_SLAY3 11217 +#define SOUND_DEATH 11214 +#define SOUND_POUNDING1 11218 +#define SOUND_POUNDING2 11219 + +#define CREATURE_ORB_TARGET 19577 + +struct MANGOS_DLL_DECL boss_void_reaverAI : public ScriptedAI +{ + boss_void_reaverAI(Creature *c) : ScriptedAI(c) + { + pInstance = ((ScriptedInstance*)c->GetInstanceData()); + Reset(); + } + + ScriptedInstance* pInstance; + + uint32 Pounding_Timer; + uint32 ArcaneOrb_Timer; + uint32 KnockAway_Timer; + uint32 Berserk_Timer; + + void Reset() + { + Pounding_Timer = 12000; + ArcaneOrb_Timer = 3000; + KnockAway_Timer = 30000; + Berserk_Timer = 600000; + + if(pInstance) + pInstance->SetData(DATA_VOIDREAVEREVENT, NOT_STARTED); + } + + void KilledUnit(Unit *victim) + { + switch(rand()%3) + { + case 0: + DoYell(SAY_SLAY1, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_SLAY1); + break; + case 1: + DoYell(SAY_SLAY2, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_SLAY2); + break; + case 2: + DoYell(SAY_SLAY3, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_SLAY3); + break; + } + } + + void JustDied(Unit *victim) + { + DoYell(SAY_DEATH, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_DEATH); + + if(pInstance) + pInstance->SetData(DATA_VOIDREAVEREVENT, NOT_STARTED); + } + + void Aggro(Unit *who) + { + DoYell(SAY_AGGRO, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_AGGRO); + + if(pInstance) + pInstance->SetData(DATA_VOIDREAVEREVENT, IN_PROGRESS); + } + + void UpdateAI(const uint32 diff) + { + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + // Pounding + if(Pounding_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_POUNDING); + + switch(rand()%2) + { + case 0: + DoPlaySoundToSet(m_creature, SOUND_POUNDING1); + DoYell(SAY_POUNDING1, LANG_UNIVERSAL, NULL); + break; + case 1: + DoPlaySoundToSet(m_creature, SOUND_POUNDING2); + DoYell(SAY_POUNDING2, LANG_UNIVERSAL, NULL); + break; + } + Pounding_Timer = 12000; + }else Pounding_Timer -= diff; + + // Arcane Orb + if(ArcaneOrb_Timer < diff) + { + Unit *target; + std::list t_list = m_creature->getThreatManager().getThreatList(); + std::vector target_list; + for(std::list::iterator itr = t_list.begin(); itr!= t_list.end(); ++itr) + { + target = Unit::GetUnit(*m_creature, (*itr)->getUnitGuid()); + //15 yard radius minimum + if(target && target->GetDistance2d(m_creature) > 15) + target_list.push_back(target); + target = NULL; + } + if(target_list.size()) + target = *(target_list.begin()+rand()%target_list.size()); + + if (target) + { + Unit* Spawn = NULL; + Spawn = m_creature->SummonCreature(CREATURE_ORB_TARGET, target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN, 10000); + if (Spawn) + m_creature->CastSpell(Spawn, SPELL_ARCANE_ORB_TRIGGER, true); + } + + ArcaneOrb_Timer = 3000; + }else ArcaneOrb_Timer -= diff; + + // Single Target knock back, reduces aggro + if(KnockAway_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_KNOCK_AWAY); + + //Drop 25% aggro + if(m_creature->getThreatManager().getThreat(m_creature->getVictim())) + m_creature->getThreatManager().modifyThreatPercent(m_creature->getVictim(),-25); + + KnockAway_Timer = 30000; + }else KnockAway_Timer -= diff; + + //Berserk + if(Berserk_Timer < diff) + { + if (m_creature->IsNonMeleeSpellCasted(false)) + m_creature->InterruptNonMeleeSpells(false); + + DoCast(m_creature,SPELL_BERSERK); + Berserk_Timer = 600000; + }else Berserk_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; + +CreatureAI* GetAI_boss_void_reaver(Creature *_Creature) +{ + return new boss_void_reaverAI (_Creature); +} + +void AddSC_boss_void_reaver() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_void_reaver"; + newscript->GetAI = GetAI_boss_void_reaver; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/tempest_keep/the_eye/def_the_eye.h b/src/bindings/scripts/scripts/zone/tempest_keep/the_eye/def_the_eye.h index eb7a9ecedf1..3478ae88970 100644 --- a/src/bindings/scripts/scripts/zone/tempest_keep/the_eye/def_the_eye.h +++ b/src/bindings/scripts/scripts/zone/tempest_keep/the_eye/def_the_eye.h @@ -1,20 +1,20 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software licensed under GPL version 2 - * Please see the included DOCS/LICENSE.TXT for more information */ - -#ifndef DEF_THE_EYE_H -#define DEF_THE_EYE_H - -#define DATA_ALAREVENT 1 -#define DATA_ASTROMANCER 2 -#define DATA_GRANDASTROMANCERCAPERNIAN 3 -#define DATA_HIGHASTROMANCERSOLARIANEVENT 4 -#define DATA_FATHOMLORDKARATHRESSEVENT 5 -#define DATA_KAELTHAS 6 -#define DATA_KAELTHASEVENT 7 -#define DATA_LORDSANGUINAR 8 -#define DATA_MASTERENGINEERTELONICUS 9 -#define DATA_SOLARIANEVENT 10 -#define DATA_THALADREDTHEDARKENER 11 -#define DATA_VOIDREAVEREVENT 12 -#endif +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software licensed under GPL version 2 + * Please see the included DOCS/LICENSE.TXT for more information */ + +#ifndef DEF_THE_EYE_H +#define DEF_THE_EYE_H + +#define DATA_ALAREVENT 1 +#define DATA_ASTROMANCER 2 +#define DATA_GRANDASTROMANCERCAPERNIAN 3 +#define DATA_HIGHASTROMANCERSOLARIANEVENT 4 +#define DATA_FATHOMLORDKARATHRESSEVENT 5 +#define DATA_KAELTHAS 6 +#define DATA_KAELTHASEVENT 7 +#define DATA_LORDSANGUINAR 8 +#define DATA_MASTERENGINEERTELONICUS 9 +#define DATA_SOLARIANEVENT 10 +#define DATA_THALADREDTHEDARKENER 11 +#define DATA_VOIDREAVEREVENT 12 +#endif diff --git a/src/bindings/scripts/scripts/zone/tempest_keep/the_eye/instance_the_eye.cpp b/src/bindings/scripts/scripts/zone/tempest_keep/the_eye/instance_the_eye.cpp index b2bd2920a82..8091216efe3 100644 --- a/src/bindings/scripts/scripts/zone/tempest_keep/the_eye/instance_the_eye.cpp +++ b/src/bindings/scripts/scripts/zone/tempest_keep/the_eye/instance_the_eye.cpp @@ -1,178 +1,178 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Instance_The_Eye -SD%Complete: 100 -SDComment: -SDCategory: Tempest Keep, The Eye -EndScriptData */ - -#include "precompiled.h" -#include "def_the_eye.h" - -#define ENCOUNTERS 5 - -/* The Eye encounters: -0 - Kael'thas event -1 - Al' ar event -2 - Solarian Event -3 - Void Reaver event -*/ - -struct MANGOS_DLL_DECL instance_the_eye : public ScriptedInstance -{ - instance_the_eye(Map *Map) : ScriptedInstance(Map) {Initialize();}; - - uint64 ThaladredTheDarkener; - uint64 LordSanguinar; - uint64 GrandAstromancerCapernian; - uint64 MasterEngineerTelonicus; - uint64 Kaelthas; - uint64 Astromancer; - - uint8 KaelthasEventPhase; - - bool Encounters[ENCOUNTERS]; - - void Initialize() - { - ThaladredTheDarkener = 0; - LordSanguinar = 0; - GrandAstromancerCapernian = 0; - MasterEngineerTelonicus = 0; - Kaelthas = 0; - Astromancer = 0; - - KaelthasEventPhase = 0; - - for(uint8 i = 0; i < ENCOUNTERS; i++) - Encounters[i] = false; - } - - bool IsEncounterInProgress() const - { - for(uint8 i = 0; i < ENCOUNTERS; i++) - if(Encounters[i]) return true; - - return false; - } - - void OnCreatureCreate(Creature *creature, uint32 creature_entry) - { - switch(creature_entry) - { - case 20064: ThaladredTheDarkener = creature->GetGUID(); break; - case 20063: MasterEngineerTelonicus = creature->GetGUID(); break; - case 20062: GrandAstromancerCapernian = creature->GetGUID(); break; - case 20060: LordSanguinar = creature->GetGUID(); break; - case 19622: Kaelthas = creature->GetGUID(); break; - case 18805: Astromancer = creature->GetGUID(); break; - } - } - - uint64 GetData64(uint32 identifier) - { - switch(identifier) - { - case DATA_THALADREDTHEDARKENER: - return ThaladredTheDarkener; - - case DATA_LORDSANGUINAR: - return LordSanguinar; - - case DATA_GRANDASTROMANCERCAPERNIAN: - return GrandAstromancerCapernian; - - case DATA_MASTERENGINEERTELONICUS: - return MasterEngineerTelonicus; - - case DATA_KAELTHAS: - return Kaelthas; - - case DATA_ASTROMANCER: - return Astromancer; - } - - return 0; - } - - void SetData(uint32 type, uint32 data) - { - switch(type) - { - case DATA_ALAREVENT: - Encounters[0] = (data) ? true : false; - break; - - case DATA_SOLARIANEVENT: - Encounters[1] = (data) ? true : false; - break; - - case DATA_VOIDREAVEREVENT: - Encounters[2] = (data) ? true : false; - break; - - //Kael'thas - case DATA_KAELTHASEVENT: - KaelthasEventPhase = data; - Encounters[3] = (data) ? true : false; - break; - - case DATA_HIGHASTROMANCERSOLARIANEVENT: - Encounters[4] = (data) ? true : false; - break; - } - } - - uint32 GetData(uint32 type) - { - switch(type) - { - case DATA_ALAREVENT: - return Encounters[0]; - - case DATA_SOLARIANEVENT: - return Encounters[1]; - - case DATA_VOIDREAVEREVENT: - return Encounters[2]; - - case DATA_HIGHASTROMANCERSOLARIANEVENT: - return Encounters[4]; - - //Kael'thas - case DATA_KAELTHASEVENT: - return KaelthasEventPhase; - } - - return 0; - } -}; - -InstanceData* GetInstanceData_instance_the_eye(Map* map) -{ - return new instance_the_eye(map); -} - -void AddSC_instance_the_eye() -{ - Script *newscript; - newscript = new Script; - newscript->Name = "instance_the_eye"; - newscript->GetInstanceData = GetInstanceData_instance_the_eye; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Instance_The_Eye +SD%Complete: 100 +SDComment: +SDCategory: Tempest Keep, The Eye +EndScriptData */ + +#include "precompiled.h" +#include "def_the_eye.h" + +#define ENCOUNTERS 5 + +/* The Eye encounters: +0 - Kael'thas event +1 - Al' ar event +2 - Solarian Event +3 - Void Reaver event +*/ + +struct MANGOS_DLL_DECL instance_the_eye : public ScriptedInstance +{ + instance_the_eye(Map *Map) : ScriptedInstance(Map) {Initialize();}; + + uint64 ThaladredTheDarkener; + uint64 LordSanguinar; + uint64 GrandAstromancerCapernian; + uint64 MasterEngineerTelonicus; + uint64 Kaelthas; + uint64 Astromancer; + + uint8 KaelthasEventPhase; + + bool Encounters[ENCOUNTERS]; + + void Initialize() + { + ThaladredTheDarkener = 0; + LordSanguinar = 0; + GrandAstromancerCapernian = 0; + MasterEngineerTelonicus = 0; + Kaelthas = 0; + Astromancer = 0; + + KaelthasEventPhase = 0; + + for(uint8 i = 0; i < ENCOUNTERS; i++) + Encounters[i] = false; + } + + bool IsEncounterInProgress() const + { + for(uint8 i = 0; i < ENCOUNTERS; i++) + if(Encounters[i]) return true; + + return false; + } + + void OnCreatureCreate(Creature *creature, uint32 creature_entry) + { + switch(creature_entry) + { + case 20064: ThaladredTheDarkener = creature->GetGUID(); break; + case 20063: MasterEngineerTelonicus = creature->GetGUID(); break; + case 20062: GrandAstromancerCapernian = creature->GetGUID(); break; + case 20060: LordSanguinar = creature->GetGUID(); break; + case 19622: Kaelthas = creature->GetGUID(); break; + case 18805: Astromancer = creature->GetGUID(); break; + } + } + + uint64 GetData64(uint32 identifier) + { + switch(identifier) + { + case DATA_THALADREDTHEDARKENER: + return ThaladredTheDarkener; + + case DATA_LORDSANGUINAR: + return LordSanguinar; + + case DATA_GRANDASTROMANCERCAPERNIAN: + return GrandAstromancerCapernian; + + case DATA_MASTERENGINEERTELONICUS: + return MasterEngineerTelonicus; + + case DATA_KAELTHAS: + return Kaelthas; + + case DATA_ASTROMANCER: + return Astromancer; + } + + return 0; + } + + void SetData(uint32 type, uint32 data) + { + switch(type) + { + case DATA_ALAREVENT: + Encounters[0] = (data) ? true : false; + break; + + case DATA_SOLARIANEVENT: + Encounters[1] = (data) ? true : false; + break; + + case DATA_VOIDREAVEREVENT: + Encounters[2] = (data) ? true : false; + break; + + //Kael'thas + case DATA_KAELTHASEVENT: + KaelthasEventPhase = data; + Encounters[3] = (data) ? true : false; + break; + + case DATA_HIGHASTROMANCERSOLARIANEVENT: + Encounters[4] = (data) ? true : false; + break; + } + } + + uint32 GetData(uint32 type) + { + switch(type) + { + case DATA_ALAREVENT: + return Encounters[0]; + + case DATA_SOLARIANEVENT: + return Encounters[1]; + + case DATA_VOIDREAVEREVENT: + return Encounters[2]; + + case DATA_HIGHASTROMANCERSOLARIANEVENT: + return Encounters[4]; + + //Kael'thas + case DATA_KAELTHASEVENT: + return KaelthasEventPhase; + } + + return 0; + } +}; + +InstanceData* GetInstanceData_instance_the_eye(Map* map) +{ + return new instance_the_eye(map); +} + +void AddSC_instance_the_eye() +{ + Script *newscript; + newscript = new Script; + newscript->Name = "instance_the_eye"; + newscript->GetInstanceData = GetInstanceData_instance_the_eye; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/tempest_keep/the_eye/the_eye.cpp b/src/bindings/scripts/scripts/zone/tempest_keep/the_eye/the_eye.cpp index 055a7ad3095..1effc9a2412 100644 --- a/src/bindings/scripts/scripts/zone/tempest_keep/the_eye/the_eye.cpp +++ b/src/bindings/scripts/scripts/zone/tempest_keep/the_eye/the_eye.cpp @@ -1,98 +1,98 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: The_Eye -SD%Complete: 100 -SDComment: -SDCategory: Tempest Keep, The Eye -EndScriptData */ - -/* ContentData -mob_crystalcore_devastator -EndContentData */ - -#include "precompiled.h" -#include "def_the_eye.h" - -#define SPELL_COUNTERCHARGE 35035 -#define SPELL_KNOCKAWAY 22893 - -struct MANGOS_DLL_DECL mob_crystalcore_devastatorAI : public ScriptedAI -{ - mob_crystalcore_devastatorAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 Knockaway_Timer; - uint32 Countercharge_Timer; - - void Reset() - { - Countercharge_Timer = 9000; - Knockaway_Timer = 25000; - } - - void Aggro(Unit *who) - { - } - - void UpdateAI(const uint32 diff) - { - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - //Check if we have a current target - //Knockaway_Timer - if (Knockaway_Timer < diff) - { - m_creature->CastSpell(m_creature->getVictim(),SPELL_KNOCKAWAY, true); - - // current aggro target is knocked away pick new target - Unit* Target = SelectUnit(SELECT_TARGET_TOPAGGRO, 0); - - if (!Target || Target == m_creature->getVictim()) - Target = SelectUnit(SELECT_TARGET_TOPAGGRO, 1); - - if (Target) - m_creature->TauntApply(Target); - - Knockaway_Timer = 23000; - } - else Knockaway_Timer -= diff; - - //Countercharge_Timer - if (Countercharge_Timer < diff) - { - DoCast(this->m_creature,SPELL_COUNTERCHARGE); - Countercharge_Timer = 45000; - }else Countercharge_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; - -CreatureAI* GetAI_mob_crystalcore_devastator(Creature *_Creature) -{ - return new mob_crystalcore_devastatorAI (_Creature); -} - -void AddSC_the_eye() -{ - Script *newscript; - newscript = new Script; - newscript->Name="mob_crystalcore_devastator"; - newscript->GetAI = GetAI_mob_crystalcore_devastator; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: The_Eye +SD%Complete: 100 +SDComment: +SDCategory: Tempest Keep, The Eye +EndScriptData */ + +/* ContentData +mob_crystalcore_devastator +EndContentData */ + +#include "precompiled.h" +#include "def_the_eye.h" + +#define SPELL_COUNTERCHARGE 35035 +#define SPELL_KNOCKAWAY 22893 + +struct MANGOS_DLL_DECL mob_crystalcore_devastatorAI : public ScriptedAI +{ + mob_crystalcore_devastatorAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 Knockaway_Timer; + uint32 Countercharge_Timer; + + void Reset() + { + Countercharge_Timer = 9000; + Knockaway_Timer = 25000; + } + + void Aggro(Unit *who) + { + } + + void UpdateAI(const uint32 diff) + { + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + //Check if we have a current target + //Knockaway_Timer + if (Knockaway_Timer < diff) + { + m_creature->CastSpell(m_creature->getVictim(),SPELL_KNOCKAWAY, true); + + // current aggro target is knocked away pick new target + Unit* Target = SelectUnit(SELECT_TARGET_TOPAGGRO, 0); + + if (!Target || Target == m_creature->getVictim()) + Target = SelectUnit(SELECT_TARGET_TOPAGGRO, 1); + + if (Target) + m_creature->TauntApply(Target); + + Knockaway_Timer = 23000; + } + else Knockaway_Timer -= diff; + + //Countercharge_Timer + if (Countercharge_Timer < diff) + { + DoCast(this->m_creature,SPELL_COUNTERCHARGE); + Countercharge_Timer = 45000; + }else Countercharge_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; + +CreatureAI* GetAI_mob_crystalcore_devastator(Creature *_Creature) +{ + return new mob_crystalcore_devastatorAI (_Creature); +} + +void AddSC_the_eye() +{ + Script *newscript; + newscript = new Script; + newscript->Name="mob_crystalcore_devastator"; + newscript->GetAI = GetAI_mob_crystalcore_devastator; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/tempest_keep/the_mechanar/boss_gatewatcher_gyrokill.cpp b/src/bindings/scripts/scripts/zone/tempest_keep/the_mechanar/boss_gatewatcher_gyrokill.cpp index f7aab61b6bb..cf9f26b7c37 100644 --- a/src/bindings/scripts/scripts/zone/tempest_keep/the_mechanar/boss_gatewatcher_gyrokill.cpp +++ b/src/bindings/scripts/scripts/zone/tempest_keep/the_mechanar/boss_gatewatcher_gyrokill.cpp @@ -1,24 +1,24 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss Gatewatcher Gyrokill -SD%Complete: 0 -SDComment: Place Holder -SDCategory: Tempest Keep, The Mechanar -EndScriptData */ - -#include "precompiled.h" +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss Gatewatcher Gyrokill +SD%Complete: 0 +SDComment: Place Holder +SDCategory: Tempest Keep, The Mechanar +EndScriptData */ + +#include "precompiled.h" diff --git a/src/bindings/scripts/scripts/zone/tempest_keep/the_mechanar/boss_gatewatcher_ironhand.cpp b/src/bindings/scripts/scripts/zone/tempest_keep/the_mechanar/boss_gatewatcher_ironhand.cpp index 77d57ff9b4c..7716782f682 100644 --- a/src/bindings/scripts/scripts/zone/tempest_keep/the_mechanar/boss_gatewatcher_ironhand.cpp +++ b/src/bindings/scripts/scripts/zone/tempest_keep/the_mechanar/boss_gatewatcher_ironhand.cpp @@ -1,147 +1,147 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss Gatewatcher Ironhand -SD%Complete: 100 -SDComment: -SDCategory: Tempest Keep, The Mechanar -EndScriptData */ - -#include "precompiled.h" - -#define SPELL_SHADOW_POWER 35322 -#define SPELL_JACKHAMMER 35326 -#define SPELL_STREAM_OF_MACHINE_FLUID 35311 - -#define SAY_SPELL_JACKHAMMER_1 "With the precise angle and velocity... " -#define SOUND_SPELL_JACKHAMMER_1 11112 -#define SAY_SPELL_JACKHAMMER_2 "Low tech yet quiet effective!" -#define SOUND_SPELL_JACKHAMMER_2 11113 - -#define SAY_AGGRO_1 "You have approximately five seconds to live." -#define SOUND_SAY_AGGRO_1 11109 - -#define SAY_SLAY_1 "A foregone conclusion." -#define SOUND_SLAY_1 11110 -#define SAY_SLAY_2 "The processing will continue a schedule!" -#define SOUND_SLAY_2 11111 - -#define SAY_DEATH_1 "My calculations did not... " -#define SOUND_DEATH_1 11114 - - -struct MANGOS_DLL_DECL boss_gatewatcher_iron_handAI : public ScriptedAI -{ - boss_gatewatcher_iron_handAI(Creature *c) : ScriptedAI(c) { Reset(); } - - uint32 Shadow_Power_Timer; - uint32 Jackhammer_Timer; - uint32 Stream_of_Machine_Fluid_Timer; - - void Reset() - { - Shadow_Power_Timer = 25000; - Jackhammer_Timer = 45000; - Stream_of_Machine_Fluid_Timer = 55000; - } - - void Aggro(Unit *who) - { - } - - void KilledUnit(Unit* victim) - { - if (rand()%2) - return; - - switch(rand()%2) - { - case 0: - DoYell(SAY_SLAY_1, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature,SOUND_SLAY_1); - break; - case 1: - DoYell(SAY_SLAY_2, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature,SOUND_SLAY_2); - break; - } - } - - void JustDied(Unit* Killer) - { - DoYell(SAY_DEATH_1,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature, SOUND_DEATH_1); - } - - void UpdateAI(const uint32 diff) - { - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - //Shadow Power - if(Shadow_Power_Timer < diff) - { - DoCast(m_creature,SPELL_SHADOW_POWER); - Shadow_Power_Timer = 25000; - }else Shadow_Power_Timer -= diff; - - //Jack Hammer - if(Jackhammer_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_JACKHAMMER); - - if (rand()%2) - return; - - switch(rand()%2) - { - case 0: - DoYell(SAY_SPELL_JACKHAMMER_1, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature,SOUND_SPELL_JACKHAMMER_1); - break; - case 1: - DoYell(SAY_SPELL_JACKHAMMER_2, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature,SOUND_SPELL_JACKHAMMER_2); - break; - } - - Jackhammer_Timer = 45000; - }else Jackhammer_Timer -= diff; - - //Stream of Machine Fluid - if(Stream_of_Machine_Fluid_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_STREAM_OF_MACHINE_FLUID); - Stream_of_Machine_Fluid_Timer = 55000; - }else Stream_of_Machine_Fluid_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; -CreatureAI* GetAI_boss_gatewatcher_iron_hand(Creature *_Creature) -{ - return new boss_gatewatcher_iron_handAI (_Creature); -} - -void AddSC_boss_gatewatcher_iron_hand() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_gatewatcher_iron_hand"; - newscript->GetAI = GetAI_boss_gatewatcher_iron_hand; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss Gatewatcher Ironhand +SD%Complete: 100 +SDComment: +SDCategory: Tempest Keep, The Mechanar +EndScriptData */ + +#include "precompiled.h" + +#define SPELL_SHADOW_POWER 35322 +#define SPELL_JACKHAMMER 35326 +#define SPELL_STREAM_OF_MACHINE_FLUID 35311 + +#define SAY_SPELL_JACKHAMMER_1 "With the precise angle and velocity... " +#define SOUND_SPELL_JACKHAMMER_1 11112 +#define SAY_SPELL_JACKHAMMER_2 "Low tech yet quiet effective!" +#define SOUND_SPELL_JACKHAMMER_2 11113 + +#define SAY_AGGRO_1 "You have approximately five seconds to live." +#define SOUND_SAY_AGGRO_1 11109 + +#define SAY_SLAY_1 "A foregone conclusion." +#define SOUND_SLAY_1 11110 +#define SAY_SLAY_2 "The processing will continue a schedule!" +#define SOUND_SLAY_2 11111 + +#define SAY_DEATH_1 "My calculations did not... " +#define SOUND_DEATH_1 11114 + + +struct MANGOS_DLL_DECL boss_gatewatcher_iron_handAI : public ScriptedAI +{ + boss_gatewatcher_iron_handAI(Creature *c) : ScriptedAI(c) { Reset(); } + + uint32 Shadow_Power_Timer; + uint32 Jackhammer_Timer; + uint32 Stream_of_Machine_Fluid_Timer; + + void Reset() + { + Shadow_Power_Timer = 25000; + Jackhammer_Timer = 45000; + Stream_of_Machine_Fluid_Timer = 55000; + } + + void Aggro(Unit *who) + { + } + + void KilledUnit(Unit* victim) + { + if (rand()%2) + return; + + switch(rand()%2) + { + case 0: + DoYell(SAY_SLAY_1, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature,SOUND_SLAY_1); + break; + case 1: + DoYell(SAY_SLAY_2, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature,SOUND_SLAY_2); + break; + } + } + + void JustDied(Unit* Killer) + { + DoYell(SAY_DEATH_1,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature, SOUND_DEATH_1); + } + + void UpdateAI(const uint32 diff) + { + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + //Shadow Power + if(Shadow_Power_Timer < diff) + { + DoCast(m_creature,SPELL_SHADOW_POWER); + Shadow_Power_Timer = 25000; + }else Shadow_Power_Timer -= diff; + + //Jack Hammer + if(Jackhammer_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_JACKHAMMER); + + if (rand()%2) + return; + + switch(rand()%2) + { + case 0: + DoYell(SAY_SPELL_JACKHAMMER_1, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature,SOUND_SPELL_JACKHAMMER_1); + break; + case 1: + DoYell(SAY_SPELL_JACKHAMMER_2, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature,SOUND_SPELL_JACKHAMMER_2); + break; + } + + Jackhammer_Timer = 45000; + }else Jackhammer_Timer -= diff; + + //Stream of Machine Fluid + if(Stream_of_Machine_Fluid_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_STREAM_OF_MACHINE_FLUID); + Stream_of_Machine_Fluid_Timer = 55000; + }else Stream_of_Machine_Fluid_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; +CreatureAI* GetAI_boss_gatewatcher_iron_hand(Creature *_Creature) +{ + return new boss_gatewatcher_iron_handAI (_Creature); +} + +void AddSC_boss_gatewatcher_iron_hand() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_gatewatcher_iron_hand"; + newscript->GetAI = GetAI_boss_gatewatcher_iron_hand; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/tempest_keep/the_mechanar/boss_nethermancer_sepethrea.cpp b/src/bindings/scripts/scripts/zone/tempest_keep/the_mechanar/boss_nethermancer_sepethrea.cpp index e5012885d93..0d8b1a2486f 100644 --- a/src/bindings/scripts/scripts/zone/tempest_keep/the_mechanar/boss_nethermancer_sepethrea.cpp +++ b/src/bindings/scripts/scripts/zone/tempest_keep/the_mechanar/boss_nethermancer_sepethrea.cpp @@ -1,223 +1,223 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss Nethermancer Sepethrea -SD%Complete: 100 -SDComment: -SDCategory: Tempest Keep, The Mechanar -EndScriptData */ - -#include "precompiled.h" - -#define SPELL_SUMMON_RAGIN_FLAMES 35275 -#define SPELL_INFERNO 19695 -#define SPELL_FIRE_TAIL 35278 - -#define SPELL_FROST_ATTACK 35263 -#define SPELL_ARCANE_BLAST 35314 -#define SPELL_DRAGONS_BREATH 35250 -#define SPELL_KNOCKBACK 37317 -#define SPELL_SOLARBURN 35267 - -#define SAY_SPELL_DRAGONS_BREATH_1 "Think you can take the heat?" -#define SOUND_SPELL_DRAGONS_BREATH_1 11189 -#define SAY_SPELL_DRAGONS_BREATH_2 "Anar'endal dracon!" -#define SOUND_SPELL_DRAGONS_BREATH_2 11190 - -#define SAY_AGGRO "Don't value your life very much, do you?" -#define SOUND_SAY_AGGRO 11186 - -#define SAY_SLAY "And don't come back!" -#define SOUND_SLAY 11187 - -#define SAY_DEATH "Anu... bala belore...alon." -#define SOUND_DEATH 11192 - -struct MANGOS_DLL_DECL boss_nethermancer_sepethreaAI : public ScriptedAI -{ - boss_nethermancer_sepethreaAI(Creature *c) : ScriptedAI(c) { Reset(); } - - uint32 frost_attack_Timer; - uint32 arcane_blast_Timer; - uint32 dragons_breath_Timer; - uint32 knockback_Timer; - uint32 solarburn_Timer; - - void Reset() - { - frost_attack_Timer = 10000; - arcane_blast_Timer = 15000; - dragons_breath_Timer = 20000; - knockback_Timer = 25000; - solarburn_Timer = 30000; - } - - void Aggro(Unit *who) - { - } - - void KilledUnit(Unit* victim) - { - DoYell(SAY_SLAY, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature,SOUND_SLAY); - } - - void JustDied(Unit* Killer) - { - DoYell(SAY_DEATH, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_DEATH); - } - - void UpdateAI(const uint32 diff) - { - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - //Frost Attack - if(frost_attack_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_FROST_ATTACK); - frost_attack_Timer = 10000; - }else frost_attack_Timer -= diff; - - //Arcane Blast - if(arcane_blast_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_ARCANE_BLAST); - arcane_blast_Timer = 15000; - }else arcane_blast_Timer -= diff; - - //Dragons Breath - if(dragons_breath_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_DRAGONS_BREATH); - dragons_breath_Timer = 20000; - - if (rand()%2) - return; - - switch(rand()%2) - { - case 0: - DoYell(SAY_SPELL_DRAGONS_BREATH_1, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature,SOUND_SPELL_DRAGONS_BREATH_1); - break; - case 1: - DoYell(SAY_SPELL_DRAGONS_BREATH_2, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature,SOUND_SPELL_DRAGONS_BREATH_2); - break; - } - }else dragons_breath_Timer -= diff; - - //Knockback - if(knockback_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_KNOCKBACK); - knockback_Timer = 25000; - }else knockback_Timer -= diff; - - //Solarburn - if(solarburn_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_SOLARBURN); - solarburn_Timer = 30000; - }else solarburn_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; - -CreatureAI* GetAI_boss_nethermancer_sepethrea(Creature *_Creature) -{ - return new boss_nethermancer_sepethreaAI (_Creature); -} - -struct MANGOS_DLL_DECL mob_ragin_flamesAI : public ScriptedAI -{ - mob_ragin_flamesAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 inferno_Timer; - uint32 flame_timer; - - bool onlyonce; - - void Reset() - { - inferno_Timer = 10000; - flame_timer = 200; - onlyonce = false; - } - - void Aggro(Unit* who) - { - } - - void UpdateAI(const uint32 diff) - { - Unit* target = NULL; - - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - if (!onlyonce) - { - Unit* target = NULL; - target = SelectUnit(SELECT_TARGET_RANDOM,0); - - m_creature->GetMotionMaster()->MoveChase(target); - onlyonce = true; - } - - if(inferno_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_INFERNO); - inferno_Timer = 10000; - - Unit* target = NULL; - target = SelectUnit(SELECT_TARGET_RANDOM,0); - - m_creature->GetMotionMaster()->MoveChase(target); - }else inferno_Timer -= diff; - - if(flame_timer < diff) - { - DoCast(m_creature,SPELL_FIRE_TAIL); - flame_timer = 200; - }else flame_timer -=diff; - - DoMeleeAttackIfReady(); - } -}; -CreatureAI* GetAI_mob_ragin_flames(Creature *_Creature) -{ - return new mob_ragin_flamesAI (_Creature); -} - -void AddSC_boss_nethermancer_sepethrea() -{ - Script *newscript; - - newscript = new Script; - newscript->Name="boss_nethermancer_sepethrea"; - newscript->GetAI = GetAI_boss_nethermancer_sepethrea; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="mob_ragin_flames"; - newscript->GetAI = GetAI_mob_ragin_flames; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss Nethermancer Sepethrea +SD%Complete: 100 +SDComment: +SDCategory: Tempest Keep, The Mechanar +EndScriptData */ + +#include "precompiled.h" + +#define SPELL_SUMMON_RAGIN_FLAMES 35275 +#define SPELL_INFERNO 19695 +#define SPELL_FIRE_TAIL 35278 + +#define SPELL_FROST_ATTACK 35263 +#define SPELL_ARCANE_BLAST 35314 +#define SPELL_DRAGONS_BREATH 35250 +#define SPELL_KNOCKBACK 37317 +#define SPELL_SOLARBURN 35267 + +#define SAY_SPELL_DRAGONS_BREATH_1 "Think you can take the heat?" +#define SOUND_SPELL_DRAGONS_BREATH_1 11189 +#define SAY_SPELL_DRAGONS_BREATH_2 "Anar'endal dracon!" +#define SOUND_SPELL_DRAGONS_BREATH_2 11190 + +#define SAY_AGGRO "Don't value your life very much, do you?" +#define SOUND_SAY_AGGRO 11186 + +#define SAY_SLAY "And don't come back!" +#define SOUND_SLAY 11187 + +#define SAY_DEATH "Anu... bala belore...alon." +#define SOUND_DEATH 11192 + +struct MANGOS_DLL_DECL boss_nethermancer_sepethreaAI : public ScriptedAI +{ + boss_nethermancer_sepethreaAI(Creature *c) : ScriptedAI(c) { Reset(); } + + uint32 frost_attack_Timer; + uint32 arcane_blast_Timer; + uint32 dragons_breath_Timer; + uint32 knockback_Timer; + uint32 solarburn_Timer; + + void Reset() + { + frost_attack_Timer = 10000; + arcane_blast_Timer = 15000; + dragons_breath_Timer = 20000; + knockback_Timer = 25000; + solarburn_Timer = 30000; + } + + void Aggro(Unit *who) + { + } + + void KilledUnit(Unit* victim) + { + DoYell(SAY_SLAY, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature,SOUND_SLAY); + } + + void JustDied(Unit* Killer) + { + DoYell(SAY_DEATH, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_DEATH); + } + + void UpdateAI(const uint32 diff) + { + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + //Frost Attack + if(frost_attack_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_FROST_ATTACK); + frost_attack_Timer = 10000; + }else frost_attack_Timer -= diff; + + //Arcane Blast + if(arcane_blast_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_ARCANE_BLAST); + arcane_blast_Timer = 15000; + }else arcane_blast_Timer -= diff; + + //Dragons Breath + if(dragons_breath_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_DRAGONS_BREATH); + dragons_breath_Timer = 20000; + + if (rand()%2) + return; + + switch(rand()%2) + { + case 0: + DoYell(SAY_SPELL_DRAGONS_BREATH_1, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature,SOUND_SPELL_DRAGONS_BREATH_1); + break; + case 1: + DoYell(SAY_SPELL_DRAGONS_BREATH_2, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature,SOUND_SPELL_DRAGONS_BREATH_2); + break; + } + }else dragons_breath_Timer -= diff; + + //Knockback + if(knockback_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_KNOCKBACK); + knockback_Timer = 25000; + }else knockback_Timer -= diff; + + //Solarburn + if(solarburn_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_SOLARBURN); + solarburn_Timer = 30000; + }else solarburn_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; + +CreatureAI* GetAI_boss_nethermancer_sepethrea(Creature *_Creature) +{ + return new boss_nethermancer_sepethreaAI (_Creature); +} + +struct MANGOS_DLL_DECL mob_ragin_flamesAI : public ScriptedAI +{ + mob_ragin_flamesAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 inferno_Timer; + uint32 flame_timer; + + bool onlyonce; + + void Reset() + { + inferno_Timer = 10000; + flame_timer = 200; + onlyonce = false; + } + + void Aggro(Unit* who) + { + } + + void UpdateAI(const uint32 diff) + { + Unit* target = NULL; + + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + if (!onlyonce) + { + Unit* target = NULL; + target = SelectUnit(SELECT_TARGET_RANDOM,0); + + m_creature->GetMotionMaster()->MoveChase(target); + onlyonce = true; + } + + if(inferno_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_INFERNO); + inferno_Timer = 10000; + + Unit* target = NULL; + target = SelectUnit(SELECT_TARGET_RANDOM,0); + + m_creature->GetMotionMaster()->MoveChase(target); + }else inferno_Timer -= diff; + + if(flame_timer < diff) + { + DoCast(m_creature,SPELL_FIRE_TAIL); + flame_timer = 200; + }else flame_timer -=diff; + + DoMeleeAttackIfReady(); + } +}; +CreatureAI* GetAI_mob_ragin_flames(Creature *_Creature) +{ + return new mob_ragin_flamesAI (_Creature); +} + +void AddSC_boss_nethermancer_sepethrea() +{ + Script *newscript; + + newscript = new Script; + newscript->Name="boss_nethermancer_sepethrea"; + newscript->GetAI = GetAI_boss_nethermancer_sepethrea; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="mob_ragin_flames"; + newscript->GetAI = GetAI_mob_ragin_flames; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/boss_bug_trio.cpp b/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/boss_bug_trio.cpp index 2592d8e8297..c507fe03898 100644 --- a/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/boss_bug_trio.cpp +++ b/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/boss_bug_trio.cpp @@ -1,384 +1,348 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: boss_kri, boss_yauj, boss_vem : The Bug Trio -SD%Complete: 100 -SDComment: -SDCategory: Temple of Ahn'Qiraj -EndScriptData */ - -#include "precompiled.h" -#include "def_temple_of_ahnqiraj.h" - -#define SPELL_CLEAVE 26350 -#define SPELL_TOXIC_VOLLEY 25812 -#define SPELL_POISON_CLOUD 38718 //Only Spell with right dmg. -#define SPELL_ENRAGE 34624 //Changed cause 25790 is casted on gamers too. Same prob with old explosion of twin emperors. - -#define SPELL_CHARGE 26561 -#define SPELL_KNOCKBACK 26027 - -#define SPELL_HEAL 25807 -#define SPELL_FEAR 19408 - -struct MANGOS_DLL_DECL boss_kriAI : public ScriptedAI -{ - boss_kriAI(Creature *c) : ScriptedAI(c) - { - pInstance = ((ScriptedInstance*)c->GetInstanceData()); - Reset(); - } - - ScriptedInstance *pInstance; - - uint32 Cleave_Timer; - uint32 ToxicVolley_Timer; - uint32 Check_Timer; - - bool VemDead; - bool Death; - - void Reset() - { - Cleave_Timer = 4000 + rand()%4000; - ToxicVolley_Timer = 6000 + rand()%6000; - Check_Timer = 2000; - - VemDead = false; - Death = false; - } - - void Aggro(Unit *who) - { - } - - void JustDied(Unit* killer) - { - if(pInstance) - { - if(pInstance->GetData(DATA_BUG_TRIO_DEATH) < 2) - // Unlootable if death - m_creature->RemoveFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE); - - pInstance->SetData(DATA_BUG_TRIO_DEATH, 1); - } - } - void UpdateAI(const uint32 diff) - { - //Return since we have no target - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - //Cleave_Timer - if (Cleave_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_CLEAVE); - Cleave_Timer = 5000 + rand()%7000; - }else Cleave_Timer -= diff; - - //ToxicVolley_Timer - if (ToxicVolley_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_TOXIC_VOLLEY); - ToxicVolley_Timer = 10000 + rand()%5000; - }else ToxicVolley_Timer -= diff; - - if (m_creature->GetHealth() <= m_creature->GetMaxHealth() * 0.05 && !Death) - { - DoCast(m_creature->getVictim(),SPELL_POISON_CLOUD); - Death = true; - } - - if(!VemDead) - { - //Checking if Vem is dead. If yes we will enrage. - if(Check_Timer < diff) - { - if(pInstance && pInstance->GetData(DATA_VEMISDEAD)) - { - DoCast(m_creature, SPELL_ENRAGE); - VemDead = true; - } - Check_Timer = 2000; - }else Check_Timer -=diff; - } - - DoMeleeAttackIfReady(); - } -}; - -struct MANGOS_DLL_DECL boss_vemAI : public ScriptedAI -{ - boss_vemAI(Creature *c) : ScriptedAI(c) - { - pInstance = ((ScriptedInstance*)c->GetInstanceData()); - Reset(); - } - - ScriptedInstance *pInstance; - - uint32 Charge_Timer; - uint32 KnockBack_Timer; - uint32 Enrage_Timer; - - bool Enraged; - - void Reset() - { - Charge_Timer = 15000 + rand()%12000; - KnockBack_Timer = 8000 + rand()%12000; - Enrage_Timer = 120000; - - Enraged = false; - } - - void JustDied(Unit* Killer) - { - if(pInstance) - { - pInstance->SetData(DATA_VEM_DEATH, 0); - if(pInstance->GetData(DATA_BUG_TRIO_DEATH) < 2) - // Unlootable if death - m_creature->RemoveFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE); - pInstance->SetData(DATA_BUG_TRIO_DEATH, 1); - } - } - - void Aggro(Unit *who) - { - } - - void MoveInLineOfSight(Unit *who) - { - if (!who || m_creature->getVictim()) - return; - - if (who->isTargetableForAttack() && IsVisible(who) && who->isInAccessablePlaceFor(m_creature) && m_creature->IsHostileTo(who)) - { - float attackRadius = m_creature->GetAttackDistance(who); - if (m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->GetDistanceZ(who) <= CREATURE_Z_ATTACK_RANGE && m_creature->IsWithinLOSInMap(who)) - { - if(who->HasStealthAura()) - who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); - //Begin melee attack if we are within range - DoStartAttackAndMovement(who); - } - } - } - - void UpdateAI(const uint32 diff) - { - //Return since we have no target - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - //Charge_Timer - if (Charge_Timer < diff) - { - Unit* target = NULL; - target = SelectUnit(SELECT_TARGET_RANDOM,0); - if(target) - { - DoCast(target, SPELL_CHARGE); - m_creature->SendMonsterMove(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0, true,1); - DoStartAttackAndMovement(target); - } - - Charge_Timer = 8000 + rand()%8000; - }else Charge_Timer -= diff; - - //KnockBack_Timer - if (KnockBack_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_KNOCKBACK); - if(m_creature->getThreatManager().getThreat(m_creature->getVictim())) - m_creature->getThreatManager().modifyThreatPercent(m_creature->getVictim(),-80); - KnockBack_Timer = 15000 + rand()%10000; - }else KnockBack_Timer -= diff; - - //Enrage_Timer - if (!Enraged && Enrage_Timer < diff) - { - DoCast(m_creature,SPELL_ENRAGE); - Enraged = true; - }else Charge_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; - -struct MANGOS_DLL_DECL boss_yaujAI : public ScriptedAI -{ - boss_yaujAI(Creature *c) : ScriptedAI(c) - { - pInstance = ((ScriptedInstance*)c->GetInstanceData()); - Reset(); - } - - ScriptedInstance *pInstance; - - uint32 Heal_Timer; - uint32 Fear_Timer; - uint32 Check_Timer; - - bool VemDead; - - void Reset() - { - Heal_Timer = 25000 + rand()%15000; - Fear_Timer = 12000 + rand()%12000; - Check_Timer = 2000; - - VemDead = false; - } - - void JustDied(Unit* Killer) - { - if(pInstance) - { - if(pInstance->GetData(DATA_BUG_TRIO_DEATH) < 2) - // Unlootable if death - m_creature->RemoveFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE); - pInstance->SetData(DATA_BUG_TRIO_DEATH, 1); - } - - for(int i = 0; i < 10;i++) - { - Unit* target = SelectUnit(SELECT_TARGET_RANDOM,0); - Creature* Summoned = m_creature->SummonCreature(15621,m_creature->GetPositionX(), m_creature->GetPositionY(), m_creature->GetPositionZ(),0,TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN,90000); - if(Summoned) - ((CreatureAI*)Summoned->AI())->AttackStart(target); - } - } - - void Aggro(Unit *who) - { - } - - void MoveInLineOfSight(Unit *who) - { - if (!who || m_creature->getVictim()) - return; - - if (who->isTargetableForAttack() && IsVisible(who) && who->isInAccessablePlaceFor(m_creature) && m_creature->IsHostileTo(who)) - { - float attackRadius = m_creature->GetAttackDistance(who); - if (m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->GetDistanceZ(who) <= CREATURE_Z_ATTACK_RANGE && m_creature->IsWithinLOSInMap(who)) - { - if(who->HasStealthAura()) - who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); - //Begin melee attack if we are within range - DoStartAttackAndMovement(who); - } - } - } - - void UpdateAI(const uint32 diff) - { - //Return since we have no target - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - //Fear_Timer - if (Fear_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_FEAR); - DoResetThreat(); - Fear_Timer = 20000; - }else Fear_Timer -= diff; - - //Casting Heal to other twins or herself. - if(Heal_Timer < diff) - { - if(pInstance) - { - Unit *pKri = Unit::GetUnit((*m_creature), pInstance->GetData64(DATA_KRI)); - Unit *pVem = Unit::GetUnit((*m_creature), pInstance->GetData64(DATA_VEM)); - - switch(rand()%3) - { - case 0: - if(pKri) - DoCast(pKri, SPELL_HEAL); - break; - case 1: - if(pVem) - DoCast(pVem, SPELL_HEAL); - break; - case 2: - DoCast(m_creature, SPELL_HEAL); - break; - } - } - - Heal_Timer = 15000+rand()%15000; - }else Heal_Timer -= diff; - - //Checking if Vem is dead. If yes we will enrage. - if(Check_Timer < diff) - { - if (!VemDead) - { - if(pInstance) - { - if(pInstance->GetData(DATA_VEMISDEAD)) - { - DoCast(m_creature, SPELL_ENRAGE); - VemDead = true; - } - } - } - Check_Timer = 2000; - }else Check_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; - -CreatureAI* GetAI_boss_yauj(Creature *_Creature) -{ - return new boss_yaujAI (_Creature); -} - -CreatureAI* GetAI_boss_vem(Creature *_Creature) -{ - return new boss_vemAI (_Creature); -} - -CreatureAI* GetAI_boss_kri(Creature *_Creature) -{ - return new boss_kriAI (_Creature); -} - -void AddSC_bug_trio() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_kri"; - newscript->GetAI = GetAI_boss_kri; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="boss_vem"; - newscript->GetAI = GetAI_boss_vem; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="boss_yauj"; - newscript->GetAI = GetAI_boss_yauj; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: boss_kri, boss_yauj, boss_vem : The Bug Trio +SD%Complete: 100 +SDComment: +SDCategory: Temple of Ahn'Qiraj +EndScriptData */ + +#include "precompiled.h" +#include "def_temple_of_ahnqiraj.h" + +#define SPELL_CLEAVE 26350 +#define SPELL_TOXIC_VOLLEY 25812 +#define SPELL_POISON_CLOUD 38718 //Only Spell with right dmg. +#define SPELL_ENRAGE 34624 //Changed cause 25790 is casted on gamers too. Same prob with old explosion of twin emperors. + +#define SPELL_CHARGE 26561 +#define SPELL_KNOCKBACK 26027 + +#define SPELL_HEAL 25807 +#define SPELL_FEAR 19408 + +struct MANGOS_DLL_DECL boss_kriAI : public ScriptedAI +{ + boss_kriAI(Creature *c) : ScriptedAI(c) + { + pInstance = ((ScriptedInstance*)c->GetInstanceData()); + Reset(); + } + + ScriptedInstance *pInstance; + + uint32 Cleave_Timer; + uint32 ToxicVolley_Timer; + uint32 Check_Timer; + + bool VemDead; + bool Death; + + void Reset() + { + Cleave_Timer = 4000 + rand()%4000; + ToxicVolley_Timer = 6000 + rand()%6000; + Check_Timer = 2000; + + VemDead = false; + Death = false; + } + + void Aggro(Unit *who) + { + } + + void JustDied(Unit* killer) + { + if(pInstance) + { + if(pInstance->GetData(DATA_BUG_TRIO_DEATH) < 2) + // Unlootable if death + m_creature->RemoveFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE); + + pInstance->SetData(DATA_BUG_TRIO_DEATH, 1); + } + } + void UpdateAI(const uint32 diff) + { + //Return since we have no target + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + //Cleave_Timer + if (Cleave_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_CLEAVE); + Cleave_Timer = 5000 + rand()%7000; + }else Cleave_Timer -= diff; + + //ToxicVolley_Timer + if (ToxicVolley_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_TOXIC_VOLLEY); + ToxicVolley_Timer = 10000 + rand()%5000; + }else ToxicVolley_Timer -= diff; + + if (m_creature->GetHealth() <= m_creature->GetMaxHealth() * 0.05 && !Death) + { + DoCast(m_creature->getVictim(),SPELL_POISON_CLOUD); + Death = true; + } + + if(!VemDead) + { + //Checking if Vem is dead. If yes we will enrage. + if(Check_Timer < diff) + { + if(pInstance && pInstance->GetData(DATA_VEMISDEAD)) + { + DoCast(m_creature, SPELL_ENRAGE); + VemDead = true; + } + Check_Timer = 2000; + }else Check_Timer -=diff; + } + + DoMeleeAttackIfReady(); + } +}; + +struct MANGOS_DLL_DECL boss_vemAI : public ScriptedAI +{ + boss_vemAI(Creature *c) : ScriptedAI(c) + { + pInstance = ((ScriptedInstance*)c->GetInstanceData()); + Reset(); + } + + ScriptedInstance *pInstance; + + uint32 Charge_Timer; + uint32 KnockBack_Timer; + uint32 Enrage_Timer; + + bool Enraged; + + void Reset() + { + Charge_Timer = 15000 + rand()%12000; + KnockBack_Timer = 8000 + rand()%12000; + Enrage_Timer = 120000; + + Enraged = false; + } + + void JustDied(Unit* Killer) + { + if(pInstance) + { + pInstance->SetData(DATA_VEM_DEATH, 0); + if(pInstance->GetData(DATA_BUG_TRIO_DEATH) < 2) + // Unlootable if death + m_creature->RemoveFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE); + pInstance->SetData(DATA_BUG_TRIO_DEATH, 1); + } + } + + void Aggro(Unit *who) + { + } + + void UpdateAI(const uint32 diff) + { + //Return since we have no target + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + //Charge_Timer + if (Charge_Timer < diff) + { + Unit* target = NULL; + target = SelectUnit(SELECT_TARGET_RANDOM,0); + if(target) + { + DoCast(target, SPELL_CHARGE); + m_creature->SendMonsterMove(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0, true,1); + DoStartAttackAndMovement(target); + } + + Charge_Timer = 8000 + rand()%8000; + }else Charge_Timer -= diff; + + //KnockBack_Timer + if (KnockBack_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_KNOCKBACK); + if(m_creature->getThreatManager().getThreat(m_creature->getVictim())) + m_creature->getThreatManager().modifyThreatPercent(m_creature->getVictim(),-80); + KnockBack_Timer = 15000 + rand()%10000; + }else KnockBack_Timer -= diff; + + //Enrage_Timer + if (!Enraged && Enrage_Timer < diff) + { + DoCast(m_creature,SPELL_ENRAGE); + Enraged = true; + }else Charge_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; + +struct MANGOS_DLL_DECL boss_yaujAI : public ScriptedAI +{ + boss_yaujAI(Creature *c) : ScriptedAI(c) + { + pInstance = ((ScriptedInstance*)c->GetInstanceData()); + Reset(); + } + + ScriptedInstance *pInstance; + + uint32 Heal_Timer; + uint32 Fear_Timer; + uint32 Check_Timer; + + bool VemDead; + + void Reset() + { + Heal_Timer = 25000 + rand()%15000; + Fear_Timer = 12000 + rand()%12000; + Check_Timer = 2000; + + VemDead = false; + } + + void JustDied(Unit* Killer) + { + if(pInstance) + { + if(pInstance->GetData(DATA_BUG_TRIO_DEATH) < 2) + // Unlootable if death + m_creature->RemoveFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE); + pInstance->SetData(DATA_BUG_TRIO_DEATH, 1); + } + + for(int i = 0; i < 10;i++) + { + Unit* target = SelectUnit(SELECT_TARGET_RANDOM,0); + Creature* Summoned = m_creature->SummonCreature(15621,m_creature->GetPositionX(), m_creature->GetPositionY(), m_creature->GetPositionZ(),0,TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN,90000); + if(Summoned) + ((CreatureAI*)Summoned->AI())->AttackStart(target); + } + } + + void Aggro(Unit *who) + { + } + + void UpdateAI(const uint32 diff) + { + //Return since we have no target + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + //Fear_Timer + if (Fear_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_FEAR); + DoResetThreat(); + Fear_Timer = 20000; + }else Fear_Timer -= diff; + + //Casting Heal to other twins or herself. + if(Heal_Timer < diff) + { + if(pInstance) + { + Unit *pKri = Unit::GetUnit((*m_creature), pInstance->GetData64(DATA_KRI)); + Unit *pVem = Unit::GetUnit((*m_creature), pInstance->GetData64(DATA_VEM)); + + switch(rand()%3) + { + case 0: + if(pKri) + DoCast(pKri, SPELL_HEAL); + break; + case 1: + if(pVem) + DoCast(pVem, SPELL_HEAL); + break; + case 2: + DoCast(m_creature, SPELL_HEAL); + break; + } + } + + Heal_Timer = 15000+rand()%15000; + }else Heal_Timer -= diff; + + //Checking if Vem is dead. If yes we will enrage. + if(Check_Timer < diff) + { + if (!VemDead) + { + if(pInstance) + { + if(pInstance->GetData(DATA_VEMISDEAD)) + { + DoCast(m_creature, SPELL_ENRAGE); + VemDead = true; + } + } + } + Check_Timer = 2000; + }else Check_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; + +CreatureAI* GetAI_boss_yauj(Creature *_Creature) +{ + return new boss_yaujAI (_Creature); +} + +CreatureAI* GetAI_boss_vem(Creature *_Creature) +{ + return new boss_vemAI (_Creature); +} + +CreatureAI* GetAI_boss_kri(Creature *_Creature) +{ + return new boss_kriAI (_Creature); +} + +void AddSC_bug_trio() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_kri"; + newscript->GetAI = GetAI_boss_kri; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="boss_vem"; + newscript->GetAI = GetAI_boss_vem; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="boss_yauj"; + newscript->GetAI = GetAI_boss_yauj; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/boss_cthun.cpp b/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/boss_cthun.cpp index a01de84604b..17d159451f4 100644 --- a/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/boss_cthun.cpp +++ b/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/boss_cthun.cpp @@ -1,1360 +1,1360 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Cthun -SD%Complete: 95 -SDComment: Darkglare tracking issue -SDCategory: Temple of Ahn'Qiraj -EndScriptData */ - -#include "precompiled.h" -#include "def_temple_of_ahnqiraj.h" - -#define PI 3.14 - -//****** Out of Combat ****** -//Random Wispers - No txt only sound -#define RND_WISPER_1 8580 //Death is close -#define RND_WISPER_2 8581 //You are already dead -#define RND_WISPER_3 8582 //Your courage will fail -#define RND_WISPER_4 8583 //Your friends will abandon you -#define RND_WISPER_5 8584 //You will betray your friends -#define RND_WISPER_6 8585 //You will die -#define RND_WISPER_7 8586 //You are weak -#define RND_WISPER_8 8587 //Your heart will explode - -//***** Phase 1 ******** - -//Mobs -#define BOSS_EYE_OF_CTHUN 15589 -#define MOB_CLAW_TENTACLE 15725 -#define MOB_EYE_TENTACLE 15726 -#define MOB_SMALL_PORTAL 15904 - -//Eye Spells -#define SPELL_GREEN_BEAM 26134 -#define SPELL_DARK_GLARE 26029 -#define SPELL_RED_COLORATION 22518 //Probably not the right spell but looks similar - -//Eye Tentacles Spells -#define SPELL_MIND_FLAY 26143 - -//Claw Tentacles Spells -#define SPELL_GROUND_RUPTURE 26139 -#define SPELL_HAMSTRING 26141 - -#define MOB_ - -//*****Phase 2****** -//Body spells -//#define SPELL_CARAPACE_CTHUN 26156 //Was removed from client dbcs -#define SPELL_TRANSFORM 26232 - -//Eye Tentacles Spells -//SAME AS PHASE1 - -//Giant Claw Tentacles -#define SPELL_MASSIVE_GROUND_RUPTURE 26100 - -//Also casts Hamstring -#define SPELL_THRASH 3391 - -//Giant Eye Tentacles -//CHAIN CASTS "SPELL_GREEN_BEAM" - -//Stomach Spells -#define SPELL_MOUTH_TENTACLE 26332 -#define SPELL_EXIT_STOMACH_KNOCKBACK 25383 -#define SPELL_DIGESTIVE_ACID 26476 - -//Mobs -#define MOB_BODY_OF_CTHUN 15809 -#define MOB_GIANT_CLAW_TENTACLE 15728 -#define MOB_GIANT_EYE_TENTACLE 15334 -#define MOB_FLESH_TENTACLE 15802 -#define MOB_GIANT_PORTAL 15910 - -//Text emote -#define EMOTE_WEAKENED "is weakened!" - -//Stomach Teleport positions -#define STOMACH_X -8562.0f -#define STOMACH_Y 2037.0f -#define STOMACH_Z -70.0f -#define STOMACH_O 5.05f - -//Flesh tentacle positions -#define TENTACLE_POS1_X -8571.0f -#define TENTACLE_POS1_Y 1990.0f -#define TENTACLE_POS1_Z -98.0f -#define TENTACLE_POS1_O 1.22f - -#define TENTACLE_POS2_X -8525.0f -#define TENTACLE_POS2_Y 1994.0f -#define TENTACLE_POS2_Z -98.0f -#define TENTACLE_POS2_O 2.12f - -//Kick out position -#define KICK_X -8545.0f -#define KICK_Y 1984.0f -#define KICK_Z -96.0f - -struct MANGOS_DLL_DECL flesh_tentacleAI : public Scripted_NoMovementAI -{ - flesh_tentacleAI(Creature *c) : Scripted_NoMovementAI(c), Parent(0) {Reset();} - - uint64 Parent; - uint32 CheckTimer; - - void SpawnedByCthun(uint64 p) - { - Parent = p; - } - - void Reset() - { - CheckTimer = 1000; - } - - void Aggro(Unit *who) - { - } - - void UpdateAI(const uint32 diff); - - void JustDied(Unit* killer); -}; - -struct MANGOS_DLL_DECL eye_of_cthunAI : public Scripted_NoMovementAI -{ - eye_of_cthunAI(Creature *c) : Scripted_NoMovementAI(c) - { - pInst = (ScriptedInstance*)c->GetInstanceData(); - if (!pInst) - error_log("SD2: No Instance eye_of_cthunAI"); - - Reset(); - } - - ScriptedInstance* pInst; - - //Global variables - uint32 PhaseTimer; - - //Eye beam phase - uint32 BeamTimer; - uint32 EyeTentacleTimer; - uint32 ClawTentacleTimer; - - //Dark Glare phase - uint32 DarkGlareTick; - uint32 DarkGlareTickTimer; - float DarkGlareAngle; - bool ClockWise; - - void Reset() - { - //Phase information - PhaseTimer = 50000; //First dark glare in 50 seconds - - //Eye beam phase 50 seconds - BeamTimer = 3000; - EyeTentacleTimer = 45000; //Always spawns 5 seconds before Dark Beam - ClawTentacleTimer = 12500; //4 per Eye beam phase (unsure if they spawn durring Dark beam) - - //Dark Beam phase 35 seconds (each tick = 1 second, 35 ticks) - DarkGlareTick = 0; - DarkGlareTickTimer = 1000; - DarkGlareAngle = 0; - ClockWise = false; - - //Reset flags - m_creature->RemoveAurasDueToSpell(SPELL_RED_COLORATION); - m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE | UNIT_FLAG_NON_ATTACKABLE); - - //Reset Phase - if (pInst) - pInst->SetData(DATA_CTHUN_PHASE, 0); - } - - void Aggro(Unit *who) - { - DoZoneInCombat(); - } - - void SpawnEyeTentacle(float x, float y) - { - Creature* Spawned; - Spawned = (Creature*)m_creature->SummonCreature(MOB_EYE_TENTACLE,m_creature->GetPositionX()+x,m_creature->GetPositionY()+y,m_creature->GetPositionZ(),0,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,500); - if (Spawned) - { - Unit* target; - target = SelectUnit(SELECT_TARGET_RANDOM,0); - - if (target) - Spawned->AI()->AttackStart(target); - } - } - - void UpdateAI(const uint32 diff) - { - //Check if we have a target - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - //No instance - if (!pInst) - return; - - switch (pInst->GetData(DATA_CTHUN_PHASE)) - { - case 0: - { - //BeamTimer - if (BeamTimer < diff) - { - //SPELL_GREEN_BEAM - Unit* target = NULL; - target = SelectUnit(SELECT_TARGET_RANDOM,0); - if (target) - { - m_creature->InterruptNonMeleeSpells(false); - DoCast(target,SPELL_GREEN_BEAM); - - //Correctly update our target - m_creature->SetUInt64Value(UNIT_FIELD_TARGET, target->GetGUID()); - } - - //Beam every 3 seconds - BeamTimer = 3000; - }else BeamTimer -= diff; - - //ClawTentacleTimer - if (ClawTentacleTimer < diff) - { - Unit* target = NULL; - target = SelectUnit(SELECT_TARGET_RANDOM,0); - if (target) - { - Creature* Spawned = NULL; - - //Spawn claw tentacle on the random target - Spawned = (Creature*)m_creature->SummonCreature(MOB_CLAW_TENTACLE,target->GetPositionX(),target->GetPositionY(),target->GetPositionZ(),0,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,500); - - if (Spawned) - Spawned->AI()->AttackStart(target); - } - - //One claw tentacle every 12.5 seconds - ClawTentacleTimer = 12500; - }else ClawTentacleTimer -= diff; - - //EyeTentacleTimer - if (EyeTentacleTimer < diff) - { - //Spawn the 8 Eye Tentacles in the corret spots - SpawnEyeTentacle(0, 20); //south - SpawnEyeTentacle(10, 10); //south west - SpawnEyeTentacle(20, 0); //west - SpawnEyeTentacle(10, -10); //north west - - SpawnEyeTentacle(0, -20); //north - SpawnEyeTentacle(-10, -10); //north east - SpawnEyeTentacle(-20, 0); // east - SpawnEyeTentacle(-10, 10); // south east - - //No point actually putting a timer here since - //These shouldn't trigger agian until after phase shifts - EyeTentacleTimer = 45000; - }else EyeTentacleTimer -= diff; - - //PhaseTimer - if (PhaseTimer < diff) - { - //Switch to Dark Beam - pInst->SetData(DATA_CTHUN_PHASE, 1); - - m_creature->InterruptNonMeleeSpells(false); - - //Select random target for dark beam to start on - Unit* target = NULL; - target = SelectUnit(SELECT_TARGET_RANDOM,0); - - if (target) - { - //Correctly update our target - m_creature->SetUInt64Value(UNIT_FIELD_TARGET, target->GetGUID()); - - //Face our target - DarkGlareAngle = m_creature->GetAngle(target); - DarkGlareTickTimer = 1000; - DarkGlareTick = 0; - ClockWise = rand()%2; - } - - //Add red coloration to C'thun - DoCast(m_creature,SPELL_RED_COLORATION); - - //Freeze animation - m_creature->setEmoteState(53); - - //Darkbeam for 35 seconds - PhaseTimer = 35000; - }else PhaseTimer -= diff; - - } - break; - case 1: - { - //EyeTentacleTimer - if (DarkGlareTick < 35) - if (DarkGlareTickTimer < diff) - { - //Remove any target - m_creature->SetUInt64Value(UNIT_FIELD_TARGET, 0); - - //Set angle and cast - if (ClockWise) - m_creature->SetOrientation(DarkGlareAngle + ((float)DarkGlareTick*PI/35)); - else m_creature->SetOrientation(DarkGlareAngle - ((float)DarkGlareTick*PI/35)); - - m_creature->StopMoving(); - - //Actual dark glare cast, maybe something missing here? - m_creature->CastSpell(NULL, SPELL_DARK_GLARE, false); - - //Increase tick - DarkGlareTick++; - - //1 second per tick - DarkGlareTickTimer = 1000; - }else DarkGlareTickTimer -= diff; - - //PhaseTimer - if (PhaseTimer < diff) - { - //Switch to Eye Beam - pInst->SetData(DATA_CTHUN_PHASE, 0); - - BeamTimer = 3000; - EyeTentacleTimer = 45000; //Always spawns 5 seconds before Dark Beam - ClawTentacleTimer = 12500; //4 per Eye beam phase (unsure if they spawn durring Dark beam) - - m_creature->InterruptNonMeleeSpells(false); - - //Remove Red coloration from c'thun - m_creature->RemoveAurasDueToSpell(SPELL_RED_COLORATION); - - //Freeze animation - m_creature->setEmoteState(0); - m_creature->SetUInt32Value(UNIT_FIELD_FLAGS, 0); - - //Eye Beam for 50 seconds - PhaseTimer = 50000; - }else PhaseTimer -= diff; - }break; - - //Transition phase - case 2: - { - //Remove any target - m_creature->SetUInt64Value(UNIT_FIELD_TARGET, 0); - m_creature->SetHealth(0); - } - - //Dead phase - case 5: - { - m_creature->DealDamage(m_creature, m_creature->GetMaxHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NONE, NULL, false); - } - } - } - - void DamageTaken(Unit *done_by, uint32 &damage) - { - //No instance - if (!pInst) - return; - - switch (pInst->GetData(DATA_CTHUN_PHASE)) - { - case 0: - case 1: - { - //Only if it will kill - if (damage < m_creature->GetHealth()) - return; - - //Fake death in phase 0 or 1 (green beam or dark glare phase) - m_creature->InterruptNonMeleeSpells(false); - - //Remove Red coloration from c'thun - m_creature->RemoveAurasDueToSpell(SPELL_RED_COLORATION); - - //Reset to normal emote state and prevent select and attack - m_creature->setEmoteState(0); - m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE | UNIT_FLAG_NON_ATTACKABLE); - - //Remove Target field - m_creature->SetUInt64Value(UNIT_FIELD_TARGET, 0); - - //Death animation/respawning; - pInst->SetData(DATA_CTHUN_PHASE, 2); - - m_creature->SetHealth(0); - damage = 0; - - m_creature->InterruptNonMeleeSpells(true); - m_creature->RemoveAllAuras(); - } - break; - - case 5: - { - //Allow death here - return; - } - - default: - { - //Prevent death in this phase - damage = 0; - return; - } - break; - } - } -}; - -struct MANGOS_DLL_DECL cthunAI : public Scripted_NoMovementAI -{ - cthunAI(Creature *c) : Scripted_NoMovementAI(c) - { - pInst = (ScriptedInstance*)c->GetInstanceData(); - if (!pInst) - error_log("SD2: No Instance eye_of_cthunAI"); - - Reset(); - } - - ScriptedInstance* pInst; - - //Out of combat whisper timer - uint32 WisperTimer; - - //Global variables - uint32 PhaseTimer; - - //------------------- - - //Phase transition - uint64 HoldPlayer; - - //Body Phase - uint32 EyeTentacleTimer; - uint8 FleshTentaclesKilled; - uint32 GiantClawTentacleTimer; - uint32 GiantEyeTentacleTimer; - uint32 StomachAcidTimer; - uint32 StomachEnterTimer; - uint32 StomachEnterVisTimer; - uint64 StomachEnterTarget; - - //Stomach map, bool = true then in stomach - HM_NAMESPACE::hash_map Stomach_Map; - - void Reset() - { - //One random wisper every 90 - 300 seconds - WisperTimer = 90000; - - //Phase information - PhaseTimer = 10000; //Emerge in 10 seconds - - //No hold player for transition - HoldPlayer = 0; - - //Body Phase - EyeTentacleTimer = 30000; - FleshTentaclesKilled = 0; - GiantClawTentacleTimer = 15000; //15 seconds into body phase (1 min repeat) - GiantEyeTentacleTimer = 45000; //15 seconds into body phase (1 min repeat) - StomachAcidTimer = 4000; //Every 4 seconds - StomachEnterTimer = 10000; //Every 10 seconds - StomachEnterVisTimer = 0; //Always 3.5 seconds after Stomach Enter Timer - StomachEnterTarget = 0; //Target to be teleported to stomach - - //Clear players in stomach and outside - Stomach_Map.clear(); - - //Reset flags - m_creature->RemoveAurasDueToSpell(SPELL_TRANSFORM); - m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE | UNIT_FLAG_NON_ATTACKABLE); - - if (pInst) - pInst->SetData(DATA_CTHUN_PHASE, 0); - } - - void Aggro(Unit *who) - { - DoZoneInCombat(); - } - - void SpawnEyeTentacle(float x, float y) - { - Creature* Spawned; - Spawned = (Creature*)m_creature->SummonCreature(MOB_EYE_TENTACLE,m_creature->GetPositionX()+x,m_creature->GetPositionY()+y,m_creature->GetPositionZ(),0,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,500); - if (Spawned) - { - Unit* target; - - target = SelectRandomNotStomach(); - - if (target) - Spawned->AI()->AttackStart(target); - } - } - - Unit* SelectRandomNotStomach() - { - if (Stomach_Map.empty()) - return NULL; - - HM_NAMESPACE::hash_map::iterator i = Stomach_Map.begin(); - - std::list temp; - std::list::iterator j; - - //Get all players in map - while (i != Stomach_Map.end()) - { - //Check for valid player - Unit* pUnit = Unit::GetUnit(*m_creature, i->first); - - //Only units out of stomach - if (pUnit && i->second == false) - { - temp.push_back(pUnit); - } - ++i; - } - - if (temp.empty()) - return NULL; - - j = temp.begin(); - - //Get random but only if we have more than one unit on threat list - if (temp.size() > 1) - advance ( i , rand() % (temp.size() - 1) ); - - return (*j); - } - - void UpdateAI(const uint32 diff) - { - //Check if we have a target - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - { - //No target so we'll use this section to do our random wispers instance wide - //WisperTimer - if (WisperTimer < diff) - { - Map *map = m_creature->GetMap(); - if(!map->IsDungeon()) return; - - InstanceMap::PlayerList const &PlayerList = ((InstanceMap*)map)->GetPlayers(); - for (InstanceMap::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i) - { - //Play random sound to the zone - switch (rand()%8) - { - case 0: (*i)->PlaySound(RND_WISPER_1, true); break; - case 1: (*i)->PlaySound(RND_WISPER_2, true); break; - case 2: (*i)->PlaySound(RND_WISPER_3, true); break; - case 3: (*i)->PlaySound(RND_WISPER_4, true); break; - case 4: (*i)->PlaySound(RND_WISPER_5, true); break; - case 5: (*i)->PlaySound(RND_WISPER_6, true); break; - case 6: (*i)->PlaySound(RND_WISPER_7, true); break; - case 7: (*i)->PlaySound(RND_WISPER_8, true); break; - } - } - - //One random wisper every 90 - 300 seconds - WisperTimer = 90000 + (rand()% 210000); - }else WisperTimer -= diff; - - return; - } - - m_creature->SetUInt64Value(UNIT_FIELD_TARGET, 0); - - //No instance - if (!pInst) - return; - - switch (pInst->GetData(DATA_CTHUN_PHASE)) - { - //Transition phase - case 2: - { - //PhaseTimer - if (PhaseTimer < diff) - { - //Switch - pInst->SetData(DATA_CTHUN_PHASE, 3); - - //Switch to c'thun model - m_creature->InterruptNonMeleeSpells(false); - DoCast(m_creature, SPELL_TRANSFORM, false); - m_creature->SetHealth(m_creature->GetMaxHealth()); - - m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE | UNIT_FLAG_NON_ATTACKABLE); - - //Emerging phase - //AttackStart(Unit::GetUnit(*m_creature, HoldPlayer)); - DoZoneInCombat(); - - //Place all units in threat list on outside of stomach - Stomach_Map.clear(); - - std::list::iterator i = m_creature->getThreatManager().getThreatList().begin(); - for (; i != m_creature->getThreatManager().getThreatList().end(); ++i) - { - //Outside stomach - Stomach_Map[(*i)->getUnitGuid()] = false; - } - - //Spawn 2 flesh tentacles - FleshTentaclesKilled = 0; - - Creature* Spawned; - - //Spawn flesh tentacle - Spawned = (Creature*)m_creature->SummonCreature(MOB_FLESH_TENTACLE, TENTACLE_POS1_X, TENTACLE_POS1_Y, TENTACLE_POS1_Z, TENTACLE_POS1_O, TEMPSUMMON_CORPSE_DESPAWN, 0); - - if (!Spawned) - FleshTentaclesKilled++; - else - ((flesh_tentacleAI*)(Spawned->AI()))->SpawnedByCthun(m_creature->GetGUID()); - - //Spawn flesh tentacle - Spawned = (Creature*)m_creature->SummonCreature(MOB_FLESH_TENTACLE, TENTACLE_POS2_X, TENTACLE_POS2_Y, TENTACLE_POS2_Z, TENTACLE_POS2_O, TEMPSUMMON_CORPSE_DESPAWN, 0); - - if (!Spawned) - FleshTentaclesKilled++; - else - ((flesh_tentacleAI*)(Spawned->AI()))->SpawnedByCthun(m_creature->GetGUID()); - - PhaseTimer = 0; - }else PhaseTimer -= diff; - - }break; - - //Body Phase - case 3: - { - //Remove Target field - m_creature->SetUInt64Value(UNIT_FIELD_TARGET, 0); - - //Weaken - if (FleshTentaclesKilled > 1) - { - pInst->SetData(DATA_CTHUN_PHASE, 4); - - DoTextEmote(EMOTE_WEAKENED, NULL); - PhaseTimer = 45000; - - DoCast(m_creature, SPELL_RED_COLORATION, true); - - HM_NAMESPACE::hash_map::iterator i = Stomach_Map.begin(); - - //Kick all players out of stomach - while (i != Stomach_Map.end()) - { - //Check for valid player - Unit* pUnit = Unit::GetUnit(*m_creature, i->first); - - //Only move units in stomach - if (pUnit && i->second == true) - { - //Teleport each player out - DoTeleportPlayer(pUnit, m_creature->GetPositionX(), m_creature->GetPositionY(), m_creature->GetPositionZ()+10, rand()%6); - - //Cast knockback on them - DoCast(pUnit, SPELL_EXIT_STOMACH_KNOCKBACK, true); - - //Remove the acid debuff - pUnit->RemoveAurasDueToSpell(SPELL_DIGESTIVE_ACID); - - i->second = false; - } - ++i; - } - - return; - } - - //Stomach acid - if (StomachAcidTimer < diff) - { - //Apply aura to all players in stomach - HM_NAMESPACE::hash_map::iterator i = Stomach_Map.begin(); - - while (i != Stomach_Map.end()) - { - //Check for valid player - Unit* pUnit = Unit::GetUnit(*m_creature, i->first); - - //Only apply to units in stomach - if (pUnit && i->second == true) - { - //Cast digestive acid on them - DoCast(pUnit, SPELL_DIGESTIVE_ACID, true); - - //Check if player should be kicked from stomach - if (pUnit->GetDistance(KICK_X, KICK_Y, KICK_Z) < 15) - { - //Teleport each player out - DoTeleportPlayer(pUnit, m_creature->GetPositionX(), m_creature->GetPositionY(), m_creature->GetPositionZ()+10, rand()%6); - - //Cast knockback on them - DoCast(pUnit, SPELL_EXIT_STOMACH_KNOCKBACK, true); - - //Remove the acid debuff - pUnit->RemoveAurasDueToSpell(SPELL_DIGESTIVE_ACID); - - i->second = false; - } - } - ++i; - } - - StomachAcidTimer = 4000; - }else StomachAcidTimer -= diff; - - //Stomach Enter Timer - if (StomachEnterTimer < diff) - { - Unit* target = NULL; - target = SelectRandomNotStomach(); - - if (target) - { - //Set target in stomach - Stomach_Map[target->GetGUID()] = true; - target->InterruptNonMeleeSpells(false); - target->CastSpell(target, SPELL_MOUTH_TENTACLE, true, NULL, NULL, m_creature->GetGUID()); - StomachEnterTarget = target->GetGUID(); - StomachEnterVisTimer = 3800; - } - - StomachEnterTimer = 13800; - }else StomachEnterTimer -= diff; - - if (StomachEnterVisTimer && StomachEnterTarget) - if (StomachEnterVisTimer <= diff) - { - //Check for valid player - Unit* pUnit = Unit::GetUnit(*m_creature, StomachEnterTarget); - - if (pUnit) - { - DoTeleportPlayer(pUnit, STOMACH_X, STOMACH_Y, STOMACH_Z, STOMACH_O); - } - - StomachEnterTarget = 0; - StomachEnterVisTimer = 0; - }else StomachEnterVisTimer -= diff; - - //GientClawTentacleTimer - if (GiantClawTentacleTimer < diff) - { - Unit* target = NULL; - target = SelectRandomNotStomach(); - if (target) - { - Creature* Spawned = NULL; - - //Spawn claw tentacle on the random target - Spawned = (Creature*)m_creature->SummonCreature(MOB_GIANT_CLAW_TENTACLE,target->GetPositionX(),target->GetPositionY(),target->GetPositionZ(),0,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,500); - - if (Spawned) - Spawned->AI()->AttackStart(target); - } - - //One giant claw tentacle every minute - GiantClawTentacleTimer = 60000; - }else GiantClawTentacleTimer -= diff; - - //GiantEyeTentacleTimer - if (GiantEyeTentacleTimer < diff) - { - Unit* target = NULL; - target = SelectRandomNotStomach(); - if (target) - { - - Creature* Spawned = NULL; - - //Spawn claw tentacle on the random target - Spawned = (Creature*)m_creature->SummonCreature(MOB_GIANT_EYE_TENTACLE,target->GetPositionX(),target->GetPositionY(),target->GetPositionZ(),0,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,500); - - if (Spawned) - Spawned->AI()->AttackStart(target); - } - - //One giant eye tentacle every minute - GiantEyeTentacleTimer = 60000; - }else GiantEyeTentacleTimer -= diff; - - //EyeTentacleTimer - if (EyeTentacleTimer < diff) - { - //Spawn the 8 Eye Tentacles in the corret spots - SpawnEyeTentacle(0, 25); //south - SpawnEyeTentacle(12, 12); //south west - SpawnEyeTentacle(25, 0); //west - SpawnEyeTentacle(12, -12); //north west - - SpawnEyeTentacle(0, -25); //north - SpawnEyeTentacle(-12, -12); //north east - SpawnEyeTentacle(-25, 0); // east - SpawnEyeTentacle(-12, 12); // south east - - //These spawn at every 30 seconds - EyeTentacleTimer = 30000; - }else EyeTentacleTimer -= diff; - - }break; - - //Weakened state - case 4: - { - //PhaseTimer - if (PhaseTimer < diff) - { - //Switch - pInst->SetData(DATA_CTHUN_PHASE, 3); - - //Remove red coloration - m_creature->RemoveAurasDueToSpell(SPELL_RED_COLORATION); - - //Spawn 2 flesh tentacles - FleshTentaclesKilled = 0; - - Creature* Spawned; - - //Spawn flesh tentacle - Spawned = (Creature*)m_creature->SummonCreature(MOB_FLESH_TENTACLE, TENTACLE_POS1_X, TENTACLE_POS1_Y, TENTACLE_POS1_Z, TENTACLE_POS1_O, TEMPSUMMON_CORPSE_DESPAWN, 0); - - if (!Spawned) - FleshTentaclesKilled++; - else - ((flesh_tentacleAI*)(Spawned->AI()))->SpawnedByCthun(m_creature->GetGUID()); - - //Spawn flesh tentacle - Spawned = (Creature*)m_creature->SummonCreature(MOB_FLESH_TENTACLE, TENTACLE_POS2_X, TENTACLE_POS2_Y, TENTACLE_POS2_Z, TENTACLE_POS2_O, TEMPSUMMON_CORPSE_DESPAWN, 0); - - if (!Spawned) - FleshTentaclesKilled++; - else - ((flesh_tentacleAI*)(Spawned->AI()))->SpawnedByCthun(m_creature->GetGUID()); - - PhaseTimer = 0; - }else PhaseTimer -= diff; - } - } - } - - void JustDied(Unit* pKiller) - { - //Switch - if( pInst ) - pInst->SetData(DATA_CTHUN_PHASE, 5); - } - - void DamageTaken(Unit *done_by, uint32 &damage) - { - //No instance - if (!pInst) - return; - - switch (pInst->GetData(DATA_CTHUN_PHASE)) - { - case 3: - { - //Not weakened so reduce damage by 99% - if (damage / 99 > 0) damage/= 99; - else damage = 1; - - //Prevent death in non-weakened state - if (damage >= m_creature->GetHealth()) - damage = 0; - - return; - } - break; - - case 4: - { - //Weakened - takes normal damage - return; - } - - default: - damage = 0; - break; - } - } - - void FleshTentcleKilled() - { - FleshTentaclesKilled++; - } -}; - -struct MANGOS_DLL_DECL eye_tentacleAI : public Scripted_NoMovementAI -{ - eye_tentacleAI(Creature *c) : Scripted_NoMovementAI(c) - { - Reset(); - Unit* p = DoSpawnCreature(MOB_SMALL_PORTAL,0,0,0,0,TEMPSUMMON_CORPSE_DESPAWN, 0); - if (p) - Portal = p->GetGUID(); - } - - uint32 MindflayTimer; - uint32 KillSelfTimer; - uint64 Portal; - - void JustDied(Unit*) - { - Unit* p = Unit::GetUnit(*m_creature, Portal); - if (p) - p->DealDamage(p, p->GetMaxHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NONE, NULL, false); - } - - void Reset() - { - //Mind flay half a second after we spawn - MindflayTimer = 500; - - //This prevents eyes from overlapping - KillSelfTimer = 35000; - } - - void Aggro(Unit *who) - { - DoZoneInCombat(); - } - - void UpdateAI(const uint32 diff) - { - //Check if we have a target - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - //KillSelfTimer - if (KillSelfTimer < diff) - { - m_creature->DealDamage(m_creature, m_creature->GetMaxHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NONE, NULL, false); - - return; - }else KillSelfTimer -= diff; - - //MindflayTimer - if (MindflayTimer < diff) - { - Unit* target = NULL; - target = SelectUnit(SELECT_TARGET_RANDOM,0); - if (target && !target->HasAura(SPELL_DIGESTIVE_ACID, 0)) - DoCast(target,SPELL_MIND_FLAY); - - //Mindflay every 10 seconds - MindflayTimer = 10100; - }else MindflayTimer -= diff; - } -}; - -struct MANGOS_DLL_DECL claw_tentacleAI : public Scripted_NoMovementAI -{ - claw_tentacleAI(Creature *c) : Scripted_NoMovementAI(c) - { - Reset(); - Unit* p = DoSpawnCreature(MOB_SMALL_PORTAL,0,0,0,0,TEMPSUMMON_CORPSE_DESPAWN, 0); - if (p) - Portal = p->GetGUID(); - } - - uint32 GroundRuptureTimer; - uint32 HamstringTimer; - uint32 EvadeTimer; - uint64 Portal; - - void JustDied(Unit*) - { - Unit* p = Unit::GetUnit(*m_creature, Portal); - if (p) - p->DealDamage(p, p->GetMaxHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NONE, NULL, false); - } - - void Reset() - { - //First rupture should happen half a second after we spawn - GroundRuptureTimer = 500; - HamstringTimer = 2000; - EvadeTimer = 5000; - } - - void Aggro(Unit *who) - { - DoZoneInCombat(); - } - - void UpdateAI(const uint32 diff) - { - //Check if we have a target - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - //EvadeTimer - if (m_creature->GetDistance(m_creature->getVictim()) > ATTACK_DISTANCE) - if (EvadeTimer < diff) - { - Unit* p = Unit::GetUnit(*m_creature, Portal); - if (p) - p->DealDamage(p, m_creature->GetMaxHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NONE, NULL, false); - - //Dissapear and reappear at new position - m_creature->SetVisibility(VISIBILITY_OFF); - - Unit* target = NULL; - target = SelectUnit(SELECT_TARGET_RANDOM,0); - if (!target) - { - m_creature->DealDamage(m_creature, m_creature->GetMaxHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NONE, NULL, false); - return; - } - - if (!target->HasAura(SPELL_DIGESTIVE_ACID, 0)) - { - m_creature->GetMap()->CreatureRelocation(m_creature, target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0); - Unit* p = DoSpawnCreature(MOB_SMALL_PORTAL,0,0,0,0,TEMPSUMMON_CORPSE_DESPAWN, 0); - if (p) - Portal = p->GetGUID(); - - GroundRuptureTimer = 500; - HamstringTimer = 2000; - EvadeTimer = 5000; - AttackStart(target); - } - - m_creature->SetVisibility(VISIBILITY_ON); - - }else EvadeTimer -= diff; - - //GroundRuptureTimer - if (GroundRuptureTimer < diff) - { - DoCast(m_creature->getVictim(),SPELL_GROUND_RUPTURE); - GroundRuptureTimer = 30000; - }else GroundRuptureTimer -= diff; - - //HamstringTimer - if (HamstringTimer < diff) - { - DoCast(m_creature->getVictim(),SPELL_HAMSTRING); - HamstringTimer = 5000; - }else HamstringTimer -= diff; - - DoMeleeAttackIfReady(); - } -}; - -struct MANGOS_DLL_DECL giant_claw_tentacleAI : public Scripted_NoMovementAI -{ - giant_claw_tentacleAI(Creature *c) : Scripted_NoMovementAI(c) - { - Reset(); - Unit* p = DoSpawnCreature(MOB_GIANT_PORTAL,0,0,0,0,TEMPSUMMON_CORPSE_DESPAWN, 0); - if (p) - Portal = p->GetGUID(); - } - - uint32 GroundRuptureTimer; - uint32 ThrashTimer; - uint32 HamstringTimer; - uint32 EvadeTimer; - uint64 Portal; - - void JustDied(Unit*) - { - Unit* p = Unit::GetUnit(*m_creature, Portal); - if (p) - p->DealDamage(p, p->GetMaxHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NONE, NULL, false); - } - - void Reset() - { - //First rupture should happen half a second after we spawn - GroundRuptureTimer = 500; - HamstringTimer = 2000; - ThrashTimer = 5000; - EvadeTimer = 5000; - } - - void Aggro(Unit *who) - { - DoZoneInCombat(); - } - - void UpdateAI(const uint32 diff) - { - //Check if we have a target - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - //EvadeTimer - if (m_creature->GetDistance(m_creature->getVictim()) > ATTACK_DISTANCE) - if (EvadeTimer < diff) - { - Unit* p = Unit::GetUnit(*m_creature, Portal); - if (p) - p->DealDamage(p, m_creature->GetMaxHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NONE, NULL, false); - - //Dissapear and reappear at new position - m_creature->SetVisibility(VISIBILITY_OFF); - - Unit* target = NULL; - target = SelectUnit(SELECT_TARGET_RANDOM, 0); - if (!target) - { - m_creature->DealDamage(m_creature, m_creature->GetMaxHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NONE, NULL, false); - return; - } - - if (!target->HasAura(SPELL_DIGESTIVE_ACID, 0)) - { - m_creature->GetMap()->CreatureRelocation(m_creature, target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0); - Unit* p = DoSpawnCreature(MOB_GIANT_PORTAL,0,0,0,0,TEMPSUMMON_CORPSE_DESPAWN, 0); - if (p) - Portal = p->GetGUID(); - - GroundRuptureTimer = 500; - HamstringTimer = 2000; - ThrashTimer = 5000; - EvadeTimer = 5000; - AttackStart(target); - } - - m_creature->SetVisibility(VISIBILITY_ON); - - }else EvadeTimer -= diff; - - //GroundRuptureTimer - if (GroundRuptureTimer < diff) - { - DoCast(m_creature->getVictim(),SPELL_GROUND_RUPTURE); - GroundRuptureTimer = 30000; - }else GroundRuptureTimer -= diff; - - //ThrashTimer - if (ThrashTimer < diff) - { - DoCast(m_creature->getVictim(),SPELL_THRASH); - ThrashTimer = 10000; - }else ThrashTimer -= diff; - - //HamstringTimer - if (HamstringTimer < diff) - { - DoCast(m_creature->getVictim(),SPELL_HAMSTRING); - HamstringTimer = 10000; - }else HamstringTimer -= diff; - - DoMeleeAttackIfReady(); - } -}; - -struct MANGOS_DLL_DECL giant_eye_tentacleAI : public Scripted_NoMovementAI -{ - giant_eye_tentacleAI(Creature *c) : Scripted_NoMovementAI(c) - { - Reset(); - Unit* p = DoSpawnCreature(MOB_GIANT_PORTAL,0,0,0,0,TEMPSUMMON_CORPSE_DESPAWN, 0); - if (p) - Portal = p->GetGUID(); - } - - uint32 BeamTimer; - uint64 Portal; - - void JustDied(Unit*) - { - Unit* p = Unit::GetUnit(*m_creature, Portal); - if (p) - p->DealDamage(p, p->GetMaxHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NONE, NULL, false); - } - - void Reset() - { - //Green Beam half a second after we spawn - BeamTimer = 500; - } - - void Aggro(Unit *who) - { - DoZoneInCombat(); - } - - void UpdateAI(const uint32 diff) - { - //Check if we have a target - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - //BeamTimer - if (BeamTimer < diff) - { - Unit* target = NULL; - target = SelectUnit(SELECT_TARGET_RANDOM,0); - if (target && !target->HasAura(SPELL_DIGESTIVE_ACID, 0)) - DoCast(target,SPELL_GREEN_BEAM); - - //Beam every 2 seconds - BeamTimer = 2100; - }else BeamTimer -= diff; - } -}; - -//Flesh tentacle functions -void flesh_tentacleAI::UpdateAI(const uint32 diff) -{ - //Check if we have a target - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - if (Parent) - if (CheckTimer < diff) - { - Unit* pUnit = Unit::GetUnit(*m_creature, Parent); - - if (!pUnit || !pUnit->isAlive() || !pUnit->isInCombat()) - { - Parent = 0; - m_creature->DealDamage(m_creature, m_creature->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NONE, NULL, false); - return; - } - - CheckTimer = 1000; - }else CheckTimer -= diff; - - DoMeleeAttackIfReady(); -} - -void flesh_tentacleAI::JustDied(Unit* killer) -{ - if (!Parent) - { - DoYell("Error: No Parent variable", LANG_UNIVERSAL, NULL); - return; - } - - Creature* Cthun = (Creature*)Unit::GetUnit(*m_creature, Parent); - - if (Cthun) - ((cthunAI*)(Cthun->AI()))->FleshTentcleKilled(); - else DoYell("Error: No Cthun", LANG_UNIVERSAL, NULL); -} - -//GetAIs -CreatureAI* GetAI_eye_of_cthun(Creature *_Creature) -{ - return new eye_of_cthunAI (_Creature); -} - -CreatureAI* GetAI_cthun(Creature *_Creature) -{ - return new cthunAI (_Creature); -} - -CreatureAI* GetAI_eye_tentacle(Creature *_Creature) -{ - return new eye_tentacleAI (_Creature); -} - -CreatureAI* GetAI_claw_tentacle(Creature *_Creature) -{ - return new claw_tentacleAI (_Creature); -} - -CreatureAI* GetAI_giant_claw_tentacle(Creature *_Creature) -{ - return new giant_claw_tentacleAI (_Creature); -} - -CreatureAI* GetAI_giant_eye_tentacle(Creature *_Creature) -{ - return new giant_eye_tentacleAI (_Creature); -} - -CreatureAI* GetAI_flesh_tentacle(Creature *_Creature) -{ - return new flesh_tentacleAI (_Creature); -} - -void AddSC_boss_cthun() -{ - Script *newscript; - - //Eye - newscript = new Script; - newscript->Name="boss_eye_of_cthun"; - newscript->GetAI = GetAI_eye_of_cthun; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="boss_cthun"; - newscript->GetAI = GetAI_cthun; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="mob_eye_tentacle"; - newscript->GetAI = GetAI_eye_tentacle; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="mob_claw_tentacle"; - newscript->GetAI = GetAI_claw_tentacle; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="mob_giant_claw_tentacle"; - newscript->GetAI = GetAI_giant_claw_tentacle; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="mob_giant_eye_tentacle"; - newscript->GetAI = GetAI_giant_eye_tentacle; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="mob_giant_flesh_tentacle"; - newscript->GetAI = GetAI_flesh_tentacle; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Cthun +SD%Complete: 95 +SDComment: Darkglare tracking issue +SDCategory: Temple of Ahn'Qiraj +EndScriptData */ + +#include "precompiled.h" +#include "def_temple_of_ahnqiraj.h" + +#define PI 3.14 + +//****** Out of Combat ****** +//Random Wispers - No txt only sound +#define RND_WISPER_1 8580 //Death is close +#define RND_WISPER_2 8581 //You are already dead +#define RND_WISPER_3 8582 //Your courage will fail +#define RND_WISPER_4 8583 //Your friends will abandon you +#define RND_WISPER_5 8584 //You will betray your friends +#define RND_WISPER_6 8585 //You will die +#define RND_WISPER_7 8586 //You are weak +#define RND_WISPER_8 8587 //Your heart will explode + +//***** Phase 1 ******** + +//Mobs +#define BOSS_EYE_OF_CTHUN 15589 +#define MOB_CLAW_TENTACLE 15725 +#define MOB_EYE_TENTACLE 15726 +#define MOB_SMALL_PORTAL 15904 + +//Eye Spells +#define SPELL_GREEN_BEAM 26134 +#define SPELL_DARK_GLARE 26029 +#define SPELL_RED_COLORATION 22518 //Probably not the right spell but looks similar + +//Eye Tentacles Spells +#define SPELL_MIND_FLAY 26143 + +//Claw Tentacles Spells +#define SPELL_GROUND_RUPTURE 26139 +#define SPELL_HAMSTRING 26141 + +#define MOB_ + +//*****Phase 2****** +//Body spells +//#define SPELL_CARAPACE_CTHUN 26156 //Was removed from client dbcs +#define SPELL_TRANSFORM 26232 + +//Eye Tentacles Spells +//SAME AS PHASE1 + +//Giant Claw Tentacles +#define SPELL_MASSIVE_GROUND_RUPTURE 26100 + +//Also casts Hamstring +#define SPELL_THRASH 3391 + +//Giant Eye Tentacles +//CHAIN CASTS "SPELL_GREEN_BEAM" + +//Stomach Spells +#define SPELL_MOUTH_TENTACLE 26332 +#define SPELL_EXIT_STOMACH_KNOCKBACK 25383 +#define SPELL_DIGESTIVE_ACID 26476 + +//Mobs +#define MOB_BODY_OF_CTHUN 15809 +#define MOB_GIANT_CLAW_TENTACLE 15728 +#define MOB_GIANT_EYE_TENTACLE 15334 +#define MOB_FLESH_TENTACLE 15802 +#define MOB_GIANT_PORTAL 15910 + +//Text emote +#define EMOTE_WEAKENED "is weakened!" + +//Stomach Teleport positions +#define STOMACH_X -8562.0f +#define STOMACH_Y 2037.0f +#define STOMACH_Z -70.0f +#define STOMACH_O 5.05f + +//Flesh tentacle positions +#define TENTACLE_POS1_X -8571.0f +#define TENTACLE_POS1_Y 1990.0f +#define TENTACLE_POS1_Z -98.0f +#define TENTACLE_POS1_O 1.22f + +#define TENTACLE_POS2_X -8525.0f +#define TENTACLE_POS2_Y 1994.0f +#define TENTACLE_POS2_Z -98.0f +#define TENTACLE_POS2_O 2.12f + +//Kick out position +#define KICK_X -8545.0f +#define KICK_Y 1984.0f +#define KICK_Z -96.0f + +struct MANGOS_DLL_DECL flesh_tentacleAI : public Scripted_NoMovementAI +{ + flesh_tentacleAI(Creature *c) : Scripted_NoMovementAI(c), Parent(0) {Reset();} + + uint64 Parent; + uint32 CheckTimer; + + void SpawnedByCthun(uint64 p) + { + Parent = p; + } + + void Reset() + { + CheckTimer = 1000; + } + + void Aggro(Unit *who) + { + } + + void UpdateAI(const uint32 diff); + + void JustDied(Unit* killer); +}; + +struct MANGOS_DLL_DECL eye_of_cthunAI : public Scripted_NoMovementAI +{ + eye_of_cthunAI(Creature *c) : Scripted_NoMovementAI(c) + { + pInst = (ScriptedInstance*)c->GetInstanceData(); + if (!pInst) + error_log("SD2: No Instance eye_of_cthunAI"); + + Reset(); + } + + ScriptedInstance* pInst; + + //Global variables + uint32 PhaseTimer; + + //Eye beam phase + uint32 BeamTimer; + uint32 EyeTentacleTimer; + uint32 ClawTentacleTimer; + + //Dark Glare phase + uint32 DarkGlareTick; + uint32 DarkGlareTickTimer; + float DarkGlareAngle; + bool ClockWise; + + void Reset() + { + //Phase information + PhaseTimer = 50000; //First dark glare in 50 seconds + + //Eye beam phase 50 seconds + BeamTimer = 3000; + EyeTentacleTimer = 45000; //Always spawns 5 seconds before Dark Beam + ClawTentacleTimer = 12500; //4 per Eye beam phase (unsure if they spawn durring Dark beam) + + //Dark Beam phase 35 seconds (each tick = 1 second, 35 ticks) + DarkGlareTick = 0; + DarkGlareTickTimer = 1000; + DarkGlareAngle = 0; + ClockWise = false; + + //Reset flags + m_creature->RemoveAurasDueToSpell(SPELL_RED_COLORATION); + m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE | UNIT_FLAG_NON_ATTACKABLE); + + //Reset Phase + if (pInst) + pInst->SetData(DATA_CTHUN_PHASE, 0); + } + + void Aggro(Unit *who) + { + DoZoneInCombat(); + } + + void SpawnEyeTentacle(float x, float y) + { + Creature* Spawned; + Spawned = (Creature*)m_creature->SummonCreature(MOB_EYE_TENTACLE,m_creature->GetPositionX()+x,m_creature->GetPositionY()+y,m_creature->GetPositionZ(),0,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,500); + if (Spawned) + { + Unit* target; + target = SelectUnit(SELECT_TARGET_RANDOM,0); + + if (target) + Spawned->AI()->AttackStart(target); + } + } + + void UpdateAI(const uint32 diff) + { + //Check if we have a target + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + //No instance + if (!pInst) + return; + + switch (pInst->GetData(DATA_CTHUN_PHASE)) + { + case 0: + { + //BeamTimer + if (BeamTimer < diff) + { + //SPELL_GREEN_BEAM + Unit* target = NULL; + target = SelectUnit(SELECT_TARGET_RANDOM,0); + if (target) + { + m_creature->InterruptNonMeleeSpells(false); + DoCast(target,SPELL_GREEN_BEAM); + + //Correctly update our target + m_creature->SetUInt64Value(UNIT_FIELD_TARGET, target->GetGUID()); + } + + //Beam every 3 seconds + BeamTimer = 3000; + }else BeamTimer -= diff; + + //ClawTentacleTimer + if (ClawTentacleTimer < diff) + { + Unit* target = NULL; + target = SelectUnit(SELECT_TARGET_RANDOM,0); + if (target) + { + Creature* Spawned = NULL; + + //Spawn claw tentacle on the random target + Spawned = (Creature*)m_creature->SummonCreature(MOB_CLAW_TENTACLE,target->GetPositionX(),target->GetPositionY(),target->GetPositionZ(),0,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,500); + + if (Spawned) + Spawned->AI()->AttackStart(target); + } + + //One claw tentacle every 12.5 seconds + ClawTentacleTimer = 12500; + }else ClawTentacleTimer -= diff; + + //EyeTentacleTimer + if (EyeTentacleTimer < diff) + { + //Spawn the 8 Eye Tentacles in the corret spots + SpawnEyeTentacle(0, 20); //south + SpawnEyeTentacle(10, 10); //south west + SpawnEyeTentacle(20, 0); //west + SpawnEyeTentacle(10, -10); //north west + + SpawnEyeTentacle(0, -20); //north + SpawnEyeTentacle(-10, -10); //north east + SpawnEyeTentacle(-20, 0); // east + SpawnEyeTentacle(-10, 10); // south east + + //No point actually putting a timer here since + //These shouldn't trigger agian until after phase shifts + EyeTentacleTimer = 45000; + }else EyeTentacleTimer -= diff; + + //PhaseTimer + if (PhaseTimer < diff) + { + //Switch to Dark Beam + pInst->SetData(DATA_CTHUN_PHASE, 1); + + m_creature->InterruptNonMeleeSpells(false); + + //Select random target for dark beam to start on + Unit* target = NULL; + target = SelectUnit(SELECT_TARGET_RANDOM,0); + + if (target) + { + //Correctly update our target + m_creature->SetUInt64Value(UNIT_FIELD_TARGET, target->GetGUID()); + + //Face our target + DarkGlareAngle = m_creature->GetAngle(target); + DarkGlareTickTimer = 1000; + DarkGlareTick = 0; + ClockWise = rand()%2; + } + + //Add red coloration to C'thun + DoCast(m_creature,SPELL_RED_COLORATION); + + //Freeze animation + m_creature->setEmoteState(53); + + //Darkbeam for 35 seconds + PhaseTimer = 35000; + }else PhaseTimer -= diff; + + } + break; + case 1: + { + //EyeTentacleTimer + if (DarkGlareTick < 35) + if (DarkGlareTickTimer < diff) + { + //Remove any target + m_creature->SetUInt64Value(UNIT_FIELD_TARGET, 0); + + //Set angle and cast + if (ClockWise) + m_creature->SetOrientation(DarkGlareAngle + ((float)DarkGlareTick*PI/35)); + else m_creature->SetOrientation(DarkGlareAngle - ((float)DarkGlareTick*PI/35)); + + m_creature->StopMoving(); + + //Actual dark glare cast, maybe something missing here? + m_creature->CastSpell(NULL, SPELL_DARK_GLARE, false); + + //Increase tick + DarkGlareTick++; + + //1 second per tick + DarkGlareTickTimer = 1000; + }else DarkGlareTickTimer -= diff; + + //PhaseTimer + if (PhaseTimer < diff) + { + //Switch to Eye Beam + pInst->SetData(DATA_CTHUN_PHASE, 0); + + BeamTimer = 3000; + EyeTentacleTimer = 45000; //Always spawns 5 seconds before Dark Beam + ClawTentacleTimer = 12500; //4 per Eye beam phase (unsure if they spawn durring Dark beam) + + m_creature->InterruptNonMeleeSpells(false); + + //Remove Red coloration from c'thun + m_creature->RemoveAurasDueToSpell(SPELL_RED_COLORATION); + + //Freeze animation + m_creature->setEmoteState(0); + m_creature->SetUInt32Value(UNIT_FIELD_FLAGS, 0); + + //Eye Beam for 50 seconds + PhaseTimer = 50000; + }else PhaseTimer -= diff; + }break; + + //Transition phase + case 2: + { + //Remove any target + m_creature->SetUInt64Value(UNIT_FIELD_TARGET, 0); + m_creature->SetHealth(0); + } + + //Dead phase + case 5: + { + m_creature->DealDamage(m_creature, m_creature->GetMaxHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NONE, NULL, false); + } + } + } + + void DamageTaken(Unit *done_by, uint32 &damage) + { + //No instance + if (!pInst) + return; + + switch (pInst->GetData(DATA_CTHUN_PHASE)) + { + case 0: + case 1: + { + //Only if it will kill + if (damage < m_creature->GetHealth()) + return; + + //Fake death in phase 0 or 1 (green beam or dark glare phase) + m_creature->InterruptNonMeleeSpells(false); + + //Remove Red coloration from c'thun + m_creature->RemoveAurasDueToSpell(SPELL_RED_COLORATION); + + //Reset to normal emote state and prevent select and attack + m_creature->setEmoteState(0); + m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE | UNIT_FLAG_NON_ATTACKABLE); + + //Remove Target field + m_creature->SetUInt64Value(UNIT_FIELD_TARGET, 0); + + //Death animation/respawning; + pInst->SetData(DATA_CTHUN_PHASE, 2); + + m_creature->SetHealth(0); + damage = 0; + + m_creature->InterruptNonMeleeSpells(true); + m_creature->RemoveAllAuras(); + } + break; + + case 5: + { + //Allow death here + return; + } + + default: + { + //Prevent death in this phase + damage = 0; + return; + } + break; + } + } +}; + +struct MANGOS_DLL_DECL cthunAI : public Scripted_NoMovementAI +{ + cthunAI(Creature *c) : Scripted_NoMovementAI(c) + { + pInst = (ScriptedInstance*)c->GetInstanceData(); + if (!pInst) + error_log("SD2: No Instance eye_of_cthunAI"); + + Reset(); + } + + ScriptedInstance* pInst; + + //Out of combat whisper timer + uint32 WisperTimer; + + //Global variables + uint32 PhaseTimer; + + //------------------- + + //Phase transition + uint64 HoldPlayer; + + //Body Phase + uint32 EyeTentacleTimer; + uint8 FleshTentaclesKilled; + uint32 GiantClawTentacleTimer; + uint32 GiantEyeTentacleTimer; + uint32 StomachAcidTimer; + uint32 StomachEnterTimer; + uint32 StomachEnterVisTimer; + uint64 StomachEnterTarget; + + //Stomach map, bool = true then in stomach + HM_NAMESPACE::hash_map Stomach_Map; + + void Reset() + { + //One random wisper every 90 - 300 seconds + WisperTimer = 90000; + + //Phase information + PhaseTimer = 10000; //Emerge in 10 seconds + + //No hold player for transition + HoldPlayer = 0; + + //Body Phase + EyeTentacleTimer = 30000; + FleshTentaclesKilled = 0; + GiantClawTentacleTimer = 15000; //15 seconds into body phase (1 min repeat) + GiantEyeTentacleTimer = 45000; //15 seconds into body phase (1 min repeat) + StomachAcidTimer = 4000; //Every 4 seconds + StomachEnterTimer = 10000; //Every 10 seconds + StomachEnterVisTimer = 0; //Always 3.5 seconds after Stomach Enter Timer + StomachEnterTarget = 0; //Target to be teleported to stomach + + //Clear players in stomach and outside + Stomach_Map.clear(); + + //Reset flags + m_creature->RemoveAurasDueToSpell(SPELL_TRANSFORM); + m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE | UNIT_FLAG_NON_ATTACKABLE); + + if (pInst) + pInst->SetData(DATA_CTHUN_PHASE, 0); + } + + void Aggro(Unit *who) + { + DoZoneInCombat(); + } + + void SpawnEyeTentacle(float x, float y) + { + Creature* Spawned; + Spawned = (Creature*)m_creature->SummonCreature(MOB_EYE_TENTACLE,m_creature->GetPositionX()+x,m_creature->GetPositionY()+y,m_creature->GetPositionZ(),0,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,500); + if (Spawned) + { + Unit* target; + + target = SelectRandomNotStomach(); + + if (target) + Spawned->AI()->AttackStart(target); + } + } + + Unit* SelectRandomNotStomach() + { + if (Stomach_Map.empty()) + return NULL; + + HM_NAMESPACE::hash_map::iterator i = Stomach_Map.begin(); + + std::list temp; + std::list::iterator j; + + //Get all players in map + while (i != Stomach_Map.end()) + { + //Check for valid player + Unit* pUnit = Unit::GetUnit(*m_creature, i->first); + + //Only units out of stomach + if (pUnit && i->second == false) + { + temp.push_back(pUnit); + } + ++i; + } + + if (temp.empty()) + return NULL; + + j = temp.begin(); + + //Get random but only if we have more than one unit on threat list + if (temp.size() > 1) + advance ( i , rand() % (temp.size() - 1) ); + + return (*j); + } + + void UpdateAI(const uint32 diff) + { + //Check if we have a target + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + { + //No target so we'll use this section to do our random wispers instance wide + //WisperTimer + if (WisperTimer < diff) + { + Map *map = m_creature->GetMap(); + if(!map->IsDungeon()) return; + + InstanceMap::PlayerList const &PlayerList = ((InstanceMap*)map)->GetPlayers(); + for (InstanceMap::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i) + { + //Play random sound to the zone + switch (rand()%8) + { + case 0: (*i)->PlaySound(RND_WISPER_1, true); break; + case 1: (*i)->PlaySound(RND_WISPER_2, true); break; + case 2: (*i)->PlaySound(RND_WISPER_3, true); break; + case 3: (*i)->PlaySound(RND_WISPER_4, true); break; + case 4: (*i)->PlaySound(RND_WISPER_5, true); break; + case 5: (*i)->PlaySound(RND_WISPER_6, true); break; + case 6: (*i)->PlaySound(RND_WISPER_7, true); break; + case 7: (*i)->PlaySound(RND_WISPER_8, true); break; + } + } + + //One random wisper every 90 - 300 seconds + WisperTimer = 90000 + (rand()% 210000); + }else WisperTimer -= diff; + + return; + } + + m_creature->SetUInt64Value(UNIT_FIELD_TARGET, 0); + + //No instance + if (!pInst) + return; + + switch (pInst->GetData(DATA_CTHUN_PHASE)) + { + //Transition phase + case 2: + { + //PhaseTimer + if (PhaseTimer < diff) + { + //Switch + pInst->SetData(DATA_CTHUN_PHASE, 3); + + //Switch to c'thun model + m_creature->InterruptNonMeleeSpells(false); + DoCast(m_creature, SPELL_TRANSFORM, false); + m_creature->SetHealth(m_creature->GetMaxHealth()); + + m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE | UNIT_FLAG_NON_ATTACKABLE); + + //Emerging phase + //AttackStart(Unit::GetUnit(*m_creature, HoldPlayer)); + DoZoneInCombat(); + + //Place all units in threat list on outside of stomach + Stomach_Map.clear(); + + std::list::iterator i = m_creature->getThreatManager().getThreatList().begin(); + for (; i != m_creature->getThreatManager().getThreatList().end(); ++i) + { + //Outside stomach + Stomach_Map[(*i)->getUnitGuid()] = false; + } + + //Spawn 2 flesh tentacles + FleshTentaclesKilled = 0; + + Creature* Spawned; + + //Spawn flesh tentacle + Spawned = (Creature*)m_creature->SummonCreature(MOB_FLESH_TENTACLE, TENTACLE_POS1_X, TENTACLE_POS1_Y, TENTACLE_POS1_Z, TENTACLE_POS1_O, TEMPSUMMON_CORPSE_DESPAWN, 0); + + if (!Spawned) + FleshTentaclesKilled++; + else + ((flesh_tentacleAI*)(Spawned->AI()))->SpawnedByCthun(m_creature->GetGUID()); + + //Spawn flesh tentacle + Spawned = (Creature*)m_creature->SummonCreature(MOB_FLESH_TENTACLE, TENTACLE_POS2_X, TENTACLE_POS2_Y, TENTACLE_POS2_Z, TENTACLE_POS2_O, TEMPSUMMON_CORPSE_DESPAWN, 0); + + if (!Spawned) + FleshTentaclesKilled++; + else + ((flesh_tentacleAI*)(Spawned->AI()))->SpawnedByCthun(m_creature->GetGUID()); + + PhaseTimer = 0; + }else PhaseTimer -= diff; + + }break; + + //Body Phase + case 3: + { + //Remove Target field + m_creature->SetUInt64Value(UNIT_FIELD_TARGET, 0); + + //Weaken + if (FleshTentaclesKilled > 1) + { + pInst->SetData(DATA_CTHUN_PHASE, 4); + + DoTextEmote(EMOTE_WEAKENED, NULL); + PhaseTimer = 45000; + + DoCast(m_creature, SPELL_RED_COLORATION, true); + + HM_NAMESPACE::hash_map::iterator i = Stomach_Map.begin(); + + //Kick all players out of stomach + while (i != Stomach_Map.end()) + { + //Check for valid player + Unit* pUnit = Unit::GetUnit(*m_creature, i->first); + + //Only move units in stomach + if (pUnit && i->second == true) + { + //Teleport each player out + DoTeleportPlayer(pUnit, m_creature->GetPositionX(), m_creature->GetPositionY(), m_creature->GetPositionZ()+10, rand()%6); + + //Cast knockback on them + DoCast(pUnit, SPELL_EXIT_STOMACH_KNOCKBACK, true); + + //Remove the acid debuff + pUnit->RemoveAurasDueToSpell(SPELL_DIGESTIVE_ACID); + + i->second = false; + } + ++i; + } + + return; + } + + //Stomach acid + if (StomachAcidTimer < diff) + { + //Apply aura to all players in stomach + HM_NAMESPACE::hash_map::iterator i = Stomach_Map.begin(); + + while (i != Stomach_Map.end()) + { + //Check for valid player + Unit* pUnit = Unit::GetUnit(*m_creature, i->first); + + //Only apply to units in stomach + if (pUnit && i->second == true) + { + //Cast digestive acid on them + DoCast(pUnit, SPELL_DIGESTIVE_ACID, true); + + //Check if player should be kicked from stomach + if (pUnit->GetDistance(KICK_X, KICK_Y, KICK_Z) < 15) + { + //Teleport each player out + DoTeleportPlayer(pUnit, m_creature->GetPositionX(), m_creature->GetPositionY(), m_creature->GetPositionZ()+10, rand()%6); + + //Cast knockback on them + DoCast(pUnit, SPELL_EXIT_STOMACH_KNOCKBACK, true); + + //Remove the acid debuff + pUnit->RemoveAurasDueToSpell(SPELL_DIGESTIVE_ACID); + + i->second = false; + } + } + ++i; + } + + StomachAcidTimer = 4000; + }else StomachAcidTimer -= diff; + + //Stomach Enter Timer + if (StomachEnterTimer < diff) + { + Unit* target = NULL; + target = SelectRandomNotStomach(); + + if (target) + { + //Set target in stomach + Stomach_Map[target->GetGUID()] = true; + target->InterruptNonMeleeSpells(false); + target->CastSpell(target, SPELL_MOUTH_TENTACLE, true, NULL, NULL, m_creature->GetGUID()); + StomachEnterTarget = target->GetGUID(); + StomachEnterVisTimer = 3800; + } + + StomachEnterTimer = 13800; + }else StomachEnterTimer -= diff; + + if (StomachEnterVisTimer && StomachEnterTarget) + if (StomachEnterVisTimer <= diff) + { + //Check for valid player + Unit* pUnit = Unit::GetUnit(*m_creature, StomachEnterTarget); + + if (pUnit) + { + DoTeleportPlayer(pUnit, STOMACH_X, STOMACH_Y, STOMACH_Z, STOMACH_O); + } + + StomachEnterTarget = 0; + StomachEnterVisTimer = 0; + }else StomachEnterVisTimer -= diff; + + //GientClawTentacleTimer + if (GiantClawTentacleTimer < diff) + { + Unit* target = NULL; + target = SelectRandomNotStomach(); + if (target) + { + Creature* Spawned = NULL; + + //Spawn claw tentacle on the random target + Spawned = (Creature*)m_creature->SummonCreature(MOB_GIANT_CLAW_TENTACLE,target->GetPositionX(),target->GetPositionY(),target->GetPositionZ(),0,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,500); + + if (Spawned) + Spawned->AI()->AttackStart(target); + } + + //One giant claw tentacle every minute + GiantClawTentacleTimer = 60000; + }else GiantClawTentacleTimer -= diff; + + //GiantEyeTentacleTimer + if (GiantEyeTentacleTimer < diff) + { + Unit* target = NULL; + target = SelectRandomNotStomach(); + if (target) + { + + Creature* Spawned = NULL; + + //Spawn claw tentacle on the random target + Spawned = (Creature*)m_creature->SummonCreature(MOB_GIANT_EYE_TENTACLE,target->GetPositionX(),target->GetPositionY(),target->GetPositionZ(),0,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,500); + + if (Spawned) + Spawned->AI()->AttackStart(target); + } + + //One giant eye tentacle every minute + GiantEyeTentacleTimer = 60000; + }else GiantEyeTentacleTimer -= diff; + + //EyeTentacleTimer + if (EyeTentacleTimer < diff) + { + //Spawn the 8 Eye Tentacles in the corret spots + SpawnEyeTentacle(0, 25); //south + SpawnEyeTentacle(12, 12); //south west + SpawnEyeTentacle(25, 0); //west + SpawnEyeTentacle(12, -12); //north west + + SpawnEyeTentacle(0, -25); //north + SpawnEyeTentacle(-12, -12); //north east + SpawnEyeTentacle(-25, 0); // east + SpawnEyeTentacle(-12, 12); // south east + + //These spawn at every 30 seconds + EyeTentacleTimer = 30000; + }else EyeTentacleTimer -= diff; + + }break; + + //Weakened state + case 4: + { + //PhaseTimer + if (PhaseTimer < diff) + { + //Switch + pInst->SetData(DATA_CTHUN_PHASE, 3); + + //Remove red coloration + m_creature->RemoveAurasDueToSpell(SPELL_RED_COLORATION); + + //Spawn 2 flesh tentacles + FleshTentaclesKilled = 0; + + Creature* Spawned; + + //Spawn flesh tentacle + Spawned = (Creature*)m_creature->SummonCreature(MOB_FLESH_TENTACLE, TENTACLE_POS1_X, TENTACLE_POS1_Y, TENTACLE_POS1_Z, TENTACLE_POS1_O, TEMPSUMMON_CORPSE_DESPAWN, 0); + + if (!Spawned) + FleshTentaclesKilled++; + else + ((flesh_tentacleAI*)(Spawned->AI()))->SpawnedByCthun(m_creature->GetGUID()); + + //Spawn flesh tentacle + Spawned = (Creature*)m_creature->SummonCreature(MOB_FLESH_TENTACLE, TENTACLE_POS2_X, TENTACLE_POS2_Y, TENTACLE_POS2_Z, TENTACLE_POS2_O, TEMPSUMMON_CORPSE_DESPAWN, 0); + + if (!Spawned) + FleshTentaclesKilled++; + else + ((flesh_tentacleAI*)(Spawned->AI()))->SpawnedByCthun(m_creature->GetGUID()); + + PhaseTimer = 0; + }else PhaseTimer -= diff; + } + } + } + + void JustDied(Unit* pKiller) + { + //Switch + if( pInst ) + pInst->SetData(DATA_CTHUN_PHASE, 5); + } + + void DamageTaken(Unit *done_by, uint32 &damage) + { + //No instance + if (!pInst) + return; + + switch (pInst->GetData(DATA_CTHUN_PHASE)) + { + case 3: + { + //Not weakened so reduce damage by 99% + if (damage / 99 > 0) damage/= 99; + else damage = 1; + + //Prevent death in non-weakened state + if (damage >= m_creature->GetHealth()) + damage = 0; + + return; + } + break; + + case 4: + { + //Weakened - takes normal damage + return; + } + + default: + damage = 0; + break; + } + } + + void FleshTentcleKilled() + { + FleshTentaclesKilled++; + } +}; + +struct MANGOS_DLL_DECL eye_tentacleAI : public Scripted_NoMovementAI +{ + eye_tentacleAI(Creature *c) : Scripted_NoMovementAI(c) + { + Reset(); + Unit* p = DoSpawnCreature(MOB_SMALL_PORTAL,0,0,0,0,TEMPSUMMON_CORPSE_DESPAWN, 0); + if (p) + Portal = p->GetGUID(); + } + + uint32 MindflayTimer; + uint32 KillSelfTimer; + uint64 Portal; + + void JustDied(Unit*) + { + Unit* p = Unit::GetUnit(*m_creature, Portal); + if (p) + p->DealDamage(p, p->GetMaxHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NONE, NULL, false); + } + + void Reset() + { + //Mind flay half a second after we spawn + MindflayTimer = 500; + + //This prevents eyes from overlapping + KillSelfTimer = 35000; + } + + void Aggro(Unit *who) + { + DoZoneInCombat(); + } + + void UpdateAI(const uint32 diff) + { + //Check if we have a target + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + //KillSelfTimer + if (KillSelfTimer < diff) + { + m_creature->DealDamage(m_creature, m_creature->GetMaxHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NONE, NULL, false); + + return; + }else KillSelfTimer -= diff; + + //MindflayTimer + if (MindflayTimer < diff) + { + Unit* target = NULL; + target = SelectUnit(SELECT_TARGET_RANDOM,0); + if (target && !target->HasAura(SPELL_DIGESTIVE_ACID, 0)) + DoCast(target,SPELL_MIND_FLAY); + + //Mindflay every 10 seconds + MindflayTimer = 10100; + }else MindflayTimer -= diff; + } +}; + +struct MANGOS_DLL_DECL claw_tentacleAI : public Scripted_NoMovementAI +{ + claw_tentacleAI(Creature *c) : Scripted_NoMovementAI(c) + { + Reset(); + Unit* p = DoSpawnCreature(MOB_SMALL_PORTAL,0,0,0,0,TEMPSUMMON_CORPSE_DESPAWN, 0); + if (p) + Portal = p->GetGUID(); + } + + uint32 GroundRuptureTimer; + uint32 HamstringTimer; + uint32 EvadeTimer; + uint64 Portal; + + void JustDied(Unit*) + { + Unit* p = Unit::GetUnit(*m_creature, Portal); + if (p) + p->DealDamage(p, p->GetMaxHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NONE, NULL, false); + } + + void Reset() + { + //First rupture should happen half a second after we spawn + GroundRuptureTimer = 500; + HamstringTimer = 2000; + EvadeTimer = 5000; + } + + void Aggro(Unit *who) + { + DoZoneInCombat(); + } + + void UpdateAI(const uint32 diff) + { + //Check if we have a target + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + //EvadeTimer + if (m_creature->GetDistance(m_creature->getVictim()) > ATTACK_DISTANCE) + if (EvadeTimer < diff) + { + Unit* p = Unit::GetUnit(*m_creature, Portal); + if (p) + p->DealDamage(p, m_creature->GetMaxHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NONE, NULL, false); + + //Dissapear and reappear at new position + m_creature->SetVisibility(VISIBILITY_OFF); + + Unit* target = NULL; + target = SelectUnit(SELECT_TARGET_RANDOM,0); + if (!target) + { + m_creature->DealDamage(m_creature, m_creature->GetMaxHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NONE, NULL, false); + return; + } + + if (!target->HasAura(SPELL_DIGESTIVE_ACID, 0)) + { + m_creature->GetMap()->CreatureRelocation(m_creature, target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0); + Unit* p = DoSpawnCreature(MOB_SMALL_PORTAL,0,0,0,0,TEMPSUMMON_CORPSE_DESPAWN, 0); + if (p) + Portal = p->GetGUID(); + + GroundRuptureTimer = 500; + HamstringTimer = 2000; + EvadeTimer = 5000; + AttackStart(target); + } + + m_creature->SetVisibility(VISIBILITY_ON); + + }else EvadeTimer -= diff; + + //GroundRuptureTimer + if (GroundRuptureTimer < diff) + { + DoCast(m_creature->getVictim(),SPELL_GROUND_RUPTURE); + GroundRuptureTimer = 30000; + }else GroundRuptureTimer -= diff; + + //HamstringTimer + if (HamstringTimer < diff) + { + DoCast(m_creature->getVictim(),SPELL_HAMSTRING); + HamstringTimer = 5000; + }else HamstringTimer -= diff; + + DoMeleeAttackIfReady(); + } +}; + +struct MANGOS_DLL_DECL giant_claw_tentacleAI : public Scripted_NoMovementAI +{ + giant_claw_tentacleAI(Creature *c) : Scripted_NoMovementAI(c) + { + Reset(); + Unit* p = DoSpawnCreature(MOB_GIANT_PORTAL,0,0,0,0,TEMPSUMMON_CORPSE_DESPAWN, 0); + if (p) + Portal = p->GetGUID(); + } + + uint32 GroundRuptureTimer; + uint32 ThrashTimer; + uint32 HamstringTimer; + uint32 EvadeTimer; + uint64 Portal; + + void JustDied(Unit*) + { + Unit* p = Unit::GetUnit(*m_creature, Portal); + if (p) + p->DealDamage(p, p->GetMaxHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NONE, NULL, false); + } + + void Reset() + { + //First rupture should happen half a second after we spawn + GroundRuptureTimer = 500; + HamstringTimer = 2000; + ThrashTimer = 5000; + EvadeTimer = 5000; + } + + void Aggro(Unit *who) + { + DoZoneInCombat(); + } + + void UpdateAI(const uint32 diff) + { + //Check if we have a target + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + //EvadeTimer + if (m_creature->GetDistance(m_creature->getVictim()) > ATTACK_DISTANCE) + if (EvadeTimer < diff) + { + Unit* p = Unit::GetUnit(*m_creature, Portal); + if (p) + p->DealDamage(p, m_creature->GetMaxHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NONE, NULL, false); + + //Dissapear and reappear at new position + m_creature->SetVisibility(VISIBILITY_OFF); + + Unit* target = NULL; + target = SelectUnit(SELECT_TARGET_RANDOM, 0); + if (!target) + { + m_creature->DealDamage(m_creature, m_creature->GetMaxHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NONE, NULL, false); + return; + } + + if (!target->HasAura(SPELL_DIGESTIVE_ACID, 0)) + { + m_creature->GetMap()->CreatureRelocation(m_creature, target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0); + Unit* p = DoSpawnCreature(MOB_GIANT_PORTAL,0,0,0,0,TEMPSUMMON_CORPSE_DESPAWN, 0); + if (p) + Portal = p->GetGUID(); + + GroundRuptureTimer = 500; + HamstringTimer = 2000; + ThrashTimer = 5000; + EvadeTimer = 5000; + AttackStart(target); + } + + m_creature->SetVisibility(VISIBILITY_ON); + + }else EvadeTimer -= diff; + + //GroundRuptureTimer + if (GroundRuptureTimer < diff) + { + DoCast(m_creature->getVictim(),SPELL_GROUND_RUPTURE); + GroundRuptureTimer = 30000; + }else GroundRuptureTimer -= diff; + + //ThrashTimer + if (ThrashTimer < diff) + { + DoCast(m_creature->getVictim(),SPELL_THRASH); + ThrashTimer = 10000; + }else ThrashTimer -= diff; + + //HamstringTimer + if (HamstringTimer < diff) + { + DoCast(m_creature->getVictim(),SPELL_HAMSTRING); + HamstringTimer = 10000; + }else HamstringTimer -= diff; + + DoMeleeAttackIfReady(); + } +}; + +struct MANGOS_DLL_DECL giant_eye_tentacleAI : public Scripted_NoMovementAI +{ + giant_eye_tentacleAI(Creature *c) : Scripted_NoMovementAI(c) + { + Reset(); + Unit* p = DoSpawnCreature(MOB_GIANT_PORTAL,0,0,0,0,TEMPSUMMON_CORPSE_DESPAWN, 0); + if (p) + Portal = p->GetGUID(); + } + + uint32 BeamTimer; + uint64 Portal; + + void JustDied(Unit*) + { + Unit* p = Unit::GetUnit(*m_creature, Portal); + if (p) + p->DealDamage(p, p->GetMaxHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NONE, NULL, false); + } + + void Reset() + { + //Green Beam half a second after we spawn + BeamTimer = 500; + } + + void Aggro(Unit *who) + { + DoZoneInCombat(); + } + + void UpdateAI(const uint32 diff) + { + //Check if we have a target + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + //BeamTimer + if (BeamTimer < diff) + { + Unit* target = NULL; + target = SelectUnit(SELECT_TARGET_RANDOM,0); + if (target && !target->HasAura(SPELL_DIGESTIVE_ACID, 0)) + DoCast(target,SPELL_GREEN_BEAM); + + //Beam every 2 seconds + BeamTimer = 2100; + }else BeamTimer -= diff; + } +}; + +//Flesh tentacle functions +void flesh_tentacleAI::UpdateAI(const uint32 diff) +{ + //Check if we have a target + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + if (Parent) + if (CheckTimer < diff) + { + Unit* pUnit = Unit::GetUnit(*m_creature, Parent); + + if (!pUnit || !pUnit->isAlive() || !pUnit->isInCombat()) + { + Parent = 0; + m_creature->DealDamage(m_creature, m_creature->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NONE, NULL, false); + return; + } + + CheckTimer = 1000; + }else CheckTimer -= diff; + + DoMeleeAttackIfReady(); +} + +void flesh_tentacleAI::JustDied(Unit* killer) +{ + if (!Parent) + { + DoYell("Error: No Parent variable", LANG_UNIVERSAL, NULL); + return; + } + + Creature* Cthun = (Creature*)Unit::GetUnit(*m_creature, Parent); + + if (Cthun) + ((cthunAI*)(Cthun->AI()))->FleshTentcleKilled(); + else DoYell("Error: No Cthun", LANG_UNIVERSAL, NULL); +} + +//GetAIs +CreatureAI* GetAI_eye_of_cthun(Creature *_Creature) +{ + return new eye_of_cthunAI (_Creature); +} + +CreatureAI* GetAI_cthun(Creature *_Creature) +{ + return new cthunAI (_Creature); +} + +CreatureAI* GetAI_eye_tentacle(Creature *_Creature) +{ + return new eye_tentacleAI (_Creature); +} + +CreatureAI* GetAI_claw_tentacle(Creature *_Creature) +{ + return new claw_tentacleAI (_Creature); +} + +CreatureAI* GetAI_giant_claw_tentacle(Creature *_Creature) +{ + return new giant_claw_tentacleAI (_Creature); +} + +CreatureAI* GetAI_giant_eye_tentacle(Creature *_Creature) +{ + return new giant_eye_tentacleAI (_Creature); +} + +CreatureAI* GetAI_flesh_tentacle(Creature *_Creature) +{ + return new flesh_tentacleAI (_Creature); +} + +void AddSC_boss_cthun() +{ + Script *newscript; + + //Eye + newscript = new Script; + newscript->Name="boss_eye_of_cthun"; + newscript->GetAI = GetAI_eye_of_cthun; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="boss_cthun"; + newscript->GetAI = GetAI_cthun; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="mob_eye_tentacle"; + newscript->GetAI = GetAI_eye_tentacle; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="mob_claw_tentacle"; + newscript->GetAI = GetAI_claw_tentacle; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="mob_giant_claw_tentacle"; + newscript->GetAI = GetAI_giant_claw_tentacle; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="mob_giant_eye_tentacle"; + newscript->GetAI = GetAI_giant_eye_tentacle; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="mob_giant_flesh_tentacle"; + newscript->GetAI = GetAI_flesh_tentacle; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/boss_fankriss.cpp b/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/boss_fankriss.cpp index da03cc2aad5..9e903593df4 100644 --- a/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/boss_fankriss.cpp +++ b/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/boss_fankriss.cpp @@ -1,190 +1,190 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Fankriss -SD%Complete: 100 -SDComment: sound not implemented -SDCategory: Temple of Ahn'Qiraj -EndScriptData */ - -#include "precompiled.h" - -#define SOUND_SENTENCE_YOU 8588 -#define SOUND_SERVE_TO 8589 -#define SOUND_LAWS 8590 -#define SOUND_TRESPASS 8591 -#define SOUND_WILL_BE 8592 - -#define SPELL_MORTAL_WOUND 28467 -#define SPELL_ROOT 28858 - -// Enrage for his spawns -#define SPELL_ENRAGE 28798 - -struct MANGOS_DLL_DECL boss_fankrissAI : public ScriptedAI -{ - boss_fankrissAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 MortalWound_Timer; - uint32 SpawnHatchlings_Timer; - uint32 SpawnSpawns_Timer; - int Rand; - int RandX; - int RandY; - - Creature* Hatchling; - Creature* Spawn; - - void Reset() - { - MortalWound_Timer = 10000 + rand()%5000; - SpawnHatchlings_Timer = 6000 + rand()%6000; - SpawnSpawns_Timer = 15000 + rand()%30000; - } - - void SummonSpawn(Unit* victim) - { - Rand = 10 + (rand()%10); - switch (rand()%2) - { - case 0: RandX = 0 - Rand; break; - case 1: RandX = 0 + Rand; break; - } - Rand = 0; - Rand = 10 + (rand()%10); - switch (rand()%2) - { - case 0: RandY = 0 - Rand; break; - case 1: RandY = 0 + Rand; break; - } - Rand = 0; - Spawn = DoSpawnCreature(15630, RandX, RandY, 0, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 30000); - if(Spawn) - ((CreatureAI*)Spawn->AI())->AttackStart(victim); - } - - void Aggro(Unit *who) - { - } - - void UpdateAI(const uint32 diff) - { - //Return since we have no target - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - //MortalWound_Timer - if (MortalWound_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_MORTAL_WOUND); - MortalWound_Timer = 10000 + rand()%10000; - }else MortalWound_Timer -= diff; - - //Summon 1-3 Spawns of Fankriss at random time. - if (SpawnSpawns_Timer < diff) - { - switch(rand()%3) - { - case 0: - SummonSpawn(SelectUnit(SELECT_TARGET_RANDOM,0)); - break; - case 1: - SummonSpawn(SelectUnit(SELECT_TARGET_RANDOM,0)); - SummonSpawn(SelectUnit(SELECT_TARGET_RANDOM,0)); - break; - case 2: - SummonSpawn(SelectUnit(SELECT_TARGET_RANDOM,0)); - SummonSpawn(SelectUnit(SELECT_TARGET_RANDOM,0)); - SummonSpawn(SelectUnit(SELECT_TARGET_RANDOM,0)); - break; - } - SpawnSpawns_Timer = 30000 + rand()%30000; - }else SpawnSpawns_Timer -= diff; - - // Teleporting Random Target to one of the three tunnels and spawn 4 hatchlings near the gamer. - //We will only telport if fankriss has more than 3% of hp so teleported gamers can always loot. - if ( m_creature->GetHealth()*100 / m_creature->GetMaxHealth() > 3 ) - { - if(SpawnHatchlings_Timer< diff) - { - Unit* target = NULL; - target = SelectUnit(SELECT_TARGET_RANDOM,0); - if (target && target->GetTypeId() == TYPEID_PLAYER) - { - DoCast(target, SPELL_ROOT); - - if(m_creature->getThreatManager().getThreat(target)) - m_creature->getThreatManager().modifyThreatPercent(target, -100); - - switch(rand()%3) - { - case 0: - DoTeleportPlayer(target, -8106.0142,1289.2900,-74.419533,5.112); - Hatchling = m_creature->SummonCreature(15962, target->GetPositionX()-3, target->GetPositionY()-3, target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000); - ((CreatureAI*)Hatchling->AI())->AttackStart(target); - Hatchling = m_creature->SummonCreature(15962, target->GetPositionX()-3, target->GetPositionY()+3, target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000); - ((CreatureAI*)Hatchling->AI())->AttackStart(target); - Hatchling = m_creature->SummonCreature(15962, target->GetPositionX()-5, target->GetPositionY()-5, target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000); - ((CreatureAI*)Hatchling->AI())->AttackStart(target); - Hatchling = m_creature->SummonCreature(15962, target->GetPositionX()-5, target->GetPositionY()+5, target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000); - ((CreatureAI*)Hatchling->AI())->AttackStart(target); - break; - case 1: - DoTeleportPlayer(target, -7990.135354,1155.1907,-78.849319,2.608); - Hatchling = m_creature->SummonCreature(15962, target->GetPositionX()-3, target->GetPositionY()-3, target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000); - ((CreatureAI*)Hatchling->AI())->AttackStart(target); - Hatchling = m_creature->SummonCreature(15962, target->GetPositionX()-3, target->GetPositionY()+3, target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000); - ((CreatureAI*)Hatchling->AI())->AttackStart(target); - Hatchling = m_creature->SummonCreature(15962, target->GetPositionX()-5, target->GetPositionY()-5, target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000); - ((CreatureAI*)Hatchling->AI())->AttackStart(target); - Hatchling = m_creature->SummonCreature(15962, target->GetPositionX()-5, target->GetPositionY()+5, target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000); - ((CreatureAI*)Hatchling->AI())->AttackStart(target); - break; - case 2: - DoTeleportPlayer(target,-8159.7753,1127.9064,-76.868660,0.675); - Hatchling = m_creature->SummonCreature(15962, target->GetPositionX()-3, target->GetPositionY()-3, target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000); - ((CreatureAI*)Hatchling->AI())->AttackStart(target); - Hatchling = m_creature->SummonCreature(15962, target->GetPositionX()-3, target->GetPositionY()+3, target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000); - ((CreatureAI*)Hatchling->AI())->AttackStart(target); - Hatchling = m_creature->SummonCreature(15962, target->GetPositionX()-5, target->GetPositionY()-5, target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000); - ((CreatureAI*)Hatchling->AI())->AttackStart(target); - Hatchling = m_creature->SummonCreature(15962, target->GetPositionX()-5, target->GetPositionY()+5, target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000); - ((CreatureAI*)Hatchling->AI())->AttackStart(target); - break; - } - } - SpawnHatchlings_Timer = 45000 + rand()%15000; - }else SpawnHatchlings_Timer -= diff; - } - - DoMeleeAttackIfReady(); - } -}; - -CreatureAI* GetAI_boss_fankriss(Creature *_Creature) -{ - return new boss_fankrissAI (_Creature); -} - -void AddSC_boss_fankriss() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_fankriss"; - newscript->GetAI = GetAI_boss_fankriss; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Fankriss +SD%Complete: 100 +SDComment: sound not implemented +SDCategory: Temple of Ahn'Qiraj +EndScriptData */ + +#include "precompiled.h" + +#define SOUND_SENTENCE_YOU 8588 +#define SOUND_SERVE_TO 8589 +#define SOUND_LAWS 8590 +#define SOUND_TRESPASS 8591 +#define SOUND_WILL_BE 8592 + +#define SPELL_MORTAL_WOUND 28467 +#define SPELL_ROOT 28858 + +// Enrage for his spawns +#define SPELL_ENRAGE 28798 + +struct MANGOS_DLL_DECL boss_fankrissAI : public ScriptedAI +{ + boss_fankrissAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 MortalWound_Timer; + uint32 SpawnHatchlings_Timer; + uint32 SpawnSpawns_Timer; + int Rand; + int RandX; + int RandY; + + Creature* Hatchling; + Creature* Spawn; + + void Reset() + { + MortalWound_Timer = 10000 + rand()%5000; + SpawnHatchlings_Timer = 6000 + rand()%6000; + SpawnSpawns_Timer = 15000 + rand()%30000; + } + + void SummonSpawn(Unit* victim) + { + Rand = 10 + (rand()%10); + switch (rand()%2) + { + case 0: RandX = 0 - Rand; break; + case 1: RandX = 0 + Rand; break; + } + Rand = 0; + Rand = 10 + (rand()%10); + switch (rand()%2) + { + case 0: RandY = 0 - Rand; break; + case 1: RandY = 0 + Rand; break; + } + Rand = 0; + Spawn = DoSpawnCreature(15630, RandX, RandY, 0, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 30000); + if(Spawn) + ((CreatureAI*)Spawn->AI())->AttackStart(victim); + } + + void Aggro(Unit *who) + { + } + + void UpdateAI(const uint32 diff) + { + //Return since we have no target + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + //MortalWound_Timer + if (MortalWound_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_MORTAL_WOUND); + MortalWound_Timer = 10000 + rand()%10000; + }else MortalWound_Timer -= diff; + + //Summon 1-3 Spawns of Fankriss at random time. + if (SpawnSpawns_Timer < diff) + { + switch(rand()%3) + { + case 0: + SummonSpawn(SelectUnit(SELECT_TARGET_RANDOM,0)); + break; + case 1: + SummonSpawn(SelectUnit(SELECT_TARGET_RANDOM,0)); + SummonSpawn(SelectUnit(SELECT_TARGET_RANDOM,0)); + break; + case 2: + SummonSpawn(SelectUnit(SELECT_TARGET_RANDOM,0)); + SummonSpawn(SelectUnit(SELECT_TARGET_RANDOM,0)); + SummonSpawn(SelectUnit(SELECT_TARGET_RANDOM,0)); + break; + } + SpawnSpawns_Timer = 30000 + rand()%30000; + }else SpawnSpawns_Timer -= diff; + + // Teleporting Random Target to one of the three tunnels and spawn 4 hatchlings near the gamer. + //We will only telport if fankriss has more than 3% of hp so teleported gamers can always loot. + if ( m_creature->GetHealth()*100 / m_creature->GetMaxHealth() > 3 ) + { + if(SpawnHatchlings_Timer< diff) + { + Unit* target = NULL; + target = SelectUnit(SELECT_TARGET_RANDOM,0); + if (target && target->GetTypeId() == TYPEID_PLAYER) + { + DoCast(target, SPELL_ROOT); + + if(m_creature->getThreatManager().getThreat(target)) + m_creature->getThreatManager().modifyThreatPercent(target, -100); + + switch(rand()%3) + { + case 0: + DoTeleportPlayer(target, -8106.0142,1289.2900,-74.419533,5.112); + Hatchling = m_creature->SummonCreature(15962, target->GetPositionX()-3, target->GetPositionY()-3, target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000); + ((CreatureAI*)Hatchling->AI())->AttackStart(target); + Hatchling = m_creature->SummonCreature(15962, target->GetPositionX()-3, target->GetPositionY()+3, target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000); + ((CreatureAI*)Hatchling->AI())->AttackStart(target); + Hatchling = m_creature->SummonCreature(15962, target->GetPositionX()-5, target->GetPositionY()-5, target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000); + ((CreatureAI*)Hatchling->AI())->AttackStart(target); + Hatchling = m_creature->SummonCreature(15962, target->GetPositionX()-5, target->GetPositionY()+5, target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000); + ((CreatureAI*)Hatchling->AI())->AttackStart(target); + break; + case 1: + DoTeleportPlayer(target, -7990.135354,1155.1907,-78.849319,2.608); + Hatchling = m_creature->SummonCreature(15962, target->GetPositionX()-3, target->GetPositionY()-3, target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000); + ((CreatureAI*)Hatchling->AI())->AttackStart(target); + Hatchling = m_creature->SummonCreature(15962, target->GetPositionX()-3, target->GetPositionY()+3, target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000); + ((CreatureAI*)Hatchling->AI())->AttackStart(target); + Hatchling = m_creature->SummonCreature(15962, target->GetPositionX()-5, target->GetPositionY()-5, target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000); + ((CreatureAI*)Hatchling->AI())->AttackStart(target); + Hatchling = m_creature->SummonCreature(15962, target->GetPositionX()-5, target->GetPositionY()+5, target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000); + ((CreatureAI*)Hatchling->AI())->AttackStart(target); + break; + case 2: + DoTeleportPlayer(target,-8159.7753,1127.9064,-76.868660,0.675); + Hatchling = m_creature->SummonCreature(15962, target->GetPositionX()-3, target->GetPositionY()-3, target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000); + ((CreatureAI*)Hatchling->AI())->AttackStart(target); + Hatchling = m_creature->SummonCreature(15962, target->GetPositionX()-3, target->GetPositionY()+3, target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000); + ((CreatureAI*)Hatchling->AI())->AttackStart(target); + Hatchling = m_creature->SummonCreature(15962, target->GetPositionX()-5, target->GetPositionY()-5, target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000); + ((CreatureAI*)Hatchling->AI())->AttackStart(target); + Hatchling = m_creature->SummonCreature(15962, target->GetPositionX()-5, target->GetPositionY()+5, target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000); + ((CreatureAI*)Hatchling->AI())->AttackStart(target); + break; + } + } + SpawnHatchlings_Timer = 45000 + rand()%15000; + }else SpawnHatchlings_Timer -= diff; + } + + DoMeleeAttackIfReady(); + } +}; + +CreatureAI* GetAI_boss_fankriss(Creature *_Creature) +{ + return new boss_fankrissAI (_Creature); +} + +void AddSC_boss_fankriss() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_fankriss"; + newscript->GetAI = GetAI_boss_fankriss; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/boss_huhuran.cpp b/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/boss_huhuran.cpp index 65e1da14955..2f960307663 100644 --- a/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/boss_huhuran.cpp +++ b/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/boss_huhuran.cpp @@ -1,143 +1,143 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Huhuran -SD%Complete: 100 -SDComment: -SDCategory: Temple of Ahn'Qiraj -EndScriptData */ - -#include "precompiled.h" - -#define SPELL_FRENZY 26051 -#define SPELL_BERSERK 26068 -#define SPELL_POISONBOLT 26052 -#define SPELL_NOXIOUSPOISON 26053 -#define SPELL_WYVERNSTING 26180 -#define SPELL_ACIDSPIT 26050 - -struct MANGOS_DLL_DECL boss_huhuranAI : public ScriptedAI -{ - boss_huhuranAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 Frenzy_Timer; - uint32 Wyvern_Timer; - uint32 Spit_Timer; - uint32 PoisonBolt_Timer; - uint32 NoxiousPoison_Timer; - uint32 FrenzyBack_Timer; - - bool Frenzy; - bool Berserk; - - void Reset() - { - Frenzy_Timer = 25000 + rand()%10000; - Wyvern_Timer = 18000 + rand()%10000; - Spit_Timer = 8000; - PoisonBolt_Timer = 4000; - NoxiousPoison_Timer = 10000 + rand()%10000; - FrenzyBack_Timer = 15000; - - Frenzy = false; - Berserk = false; - } - - void Aggro(Unit *who) - { - } - - void UpdateAI(const uint32 diff) - { - //Return since we have no target - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - //Frenzy_Timer - if (!Frenzy && Frenzy_Timer < diff) - { - DoCast(m_creature, SPELL_FRENZY); - Frenzy = true; - PoisonBolt_Timer = 3000; - Frenzy_Timer = 25000 + rand()%10000; - }else Frenzy_Timer -= diff; - - // Wyvern Timer - if (Wyvern_Timer < diff) - { - if( Unit *target = SelectUnit(SELECT_TARGET_RANDOM,0) ) - DoCast(target,SPELL_WYVERNSTING); - Wyvern_Timer = 15000 + rand()%17000; - }else Wyvern_Timer -= diff; - - //Spit Timer - if (Spit_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_ACIDSPIT); - Spit_Timer = 5000 + rand()%5000; - }else Spit_Timer -= diff; - - //NoxiousPoison_Timer - if (NoxiousPoison_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_NOXIOUSPOISON); - NoxiousPoison_Timer = 12000 + rand()%12000; - }else NoxiousPoison_Timer -= diff; - - //PoisonBolt only if frenzy or berserk - if (Frenzy || Berserk) - { - if (PoisonBolt_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_POISONBOLT); - PoisonBolt_Timer = 3000; - }else PoisonBolt_Timer -= diff; - } - - //FrenzyBack_Timer - if (Frenzy && FrenzyBack_Timer < diff) - { - m_creature->InterruptNonMeleeSpells(false); - Frenzy = false; - FrenzyBack_Timer = 15000; - }else FrenzyBack_Timer -= diff; - - if ( !Berserk && m_creature->GetHealth()*100 / m_creature->GetMaxHealth() < 31 ) - { - m_creature->InterruptNonMeleeSpells(false); - DoTextEmote("is going berserk", NULL); - DoCast(m_creature, SPELL_BERSERK); - Berserk = true; - } - - DoMeleeAttackIfReady(); - } -}; - -CreatureAI* GetAI_boss_huhuran(Creature *_Creature) -{ - return new boss_huhuranAI (_Creature); -} - -void AddSC_boss_huhuran() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_huhuran"; - newscript->GetAI = GetAI_boss_huhuran; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Huhuran +SD%Complete: 100 +SDComment: +SDCategory: Temple of Ahn'Qiraj +EndScriptData */ + +#include "precompiled.h" + +#define SPELL_FRENZY 26051 +#define SPELL_BERSERK 26068 +#define SPELL_POISONBOLT 26052 +#define SPELL_NOXIOUSPOISON 26053 +#define SPELL_WYVERNSTING 26180 +#define SPELL_ACIDSPIT 26050 + +struct MANGOS_DLL_DECL boss_huhuranAI : public ScriptedAI +{ + boss_huhuranAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 Frenzy_Timer; + uint32 Wyvern_Timer; + uint32 Spit_Timer; + uint32 PoisonBolt_Timer; + uint32 NoxiousPoison_Timer; + uint32 FrenzyBack_Timer; + + bool Frenzy; + bool Berserk; + + void Reset() + { + Frenzy_Timer = 25000 + rand()%10000; + Wyvern_Timer = 18000 + rand()%10000; + Spit_Timer = 8000; + PoisonBolt_Timer = 4000; + NoxiousPoison_Timer = 10000 + rand()%10000; + FrenzyBack_Timer = 15000; + + Frenzy = false; + Berserk = false; + } + + void Aggro(Unit *who) + { + } + + void UpdateAI(const uint32 diff) + { + //Return since we have no target + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + //Frenzy_Timer + if (!Frenzy && Frenzy_Timer < diff) + { + DoCast(m_creature, SPELL_FRENZY); + Frenzy = true; + PoisonBolt_Timer = 3000; + Frenzy_Timer = 25000 + rand()%10000; + }else Frenzy_Timer -= diff; + + // Wyvern Timer + if (Wyvern_Timer < diff) + { + if( Unit *target = SelectUnit(SELECT_TARGET_RANDOM,0) ) + DoCast(target,SPELL_WYVERNSTING); + Wyvern_Timer = 15000 + rand()%17000; + }else Wyvern_Timer -= diff; + + //Spit Timer + if (Spit_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_ACIDSPIT); + Spit_Timer = 5000 + rand()%5000; + }else Spit_Timer -= diff; + + //NoxiousPoison_Timer + if (NoxiousPoison_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_NOXIOUSPOISON); + NoxiousPoison_Timer = 12000 + rand()%12000; + }else NoxiousPoison_Timer -= diff; + + //PoisonBolt only if frenzy or berserk + if (Frenzy || Berserk) + { + if (PoisonBolt_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_POISONBOLT); + PoisonBolt_Timer = 3000; + }else PoisonBolt_Timer -= diff; + } + + //FrenzyBack_Timer + if (Frenzy && FrenzyBack_Timer < diff) + { + m_creature->InterruptNonMeleeSpells(false); + Frenzy = false; + FrenzyBack_Timer = 15000; + }else FrenzyBack_Timer -= diff; + + if ( !Berserk && m_creature->GetHealth()*100 / m_creature->GetMaxHealth() < 31 ) + { + m_creature->InterruptNonMeleeSpells(false); + DoTextEmote("is going berserk", NULL); + DoCast(m_creature, SPELL_BERSERK); + Berserk = true; + } + + DoMeleeAttackIfReady(); + } +}; + +CreatureAI* GetAI_boss_huhuran(Creature *_Creature) +{ + return new boss_huhuranAI (_Creature); +} + +void AddSC_boss_huhuran() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_huhuran"; + newscript->GetAI = GetAI_boss_huhuran; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/boss_ouro.cpp b/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/boss_ouro.cpp index 97853c6cf87..6c018321fc1 100644 --- a/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/boss_ouro.cpp +++ b/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/boss_ouro.cpp @@ -1,140 +1,140 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Ouro -SD%Complete: 85 -SDComment: No model for submerging. Currently just invisible. -SDCategory: Temple of Ahn'Qiraj -EndScriptData */ - -#include "precompiled.h" -#include "def_temple_of_ahnqiraj.h" - -#define SPELL_SWEEP 26103 -#define SPELL_SANDBLAST 26102 -#define SPELL_GROUND_RUPTURE 26100 -#define SPELL_BIRTH 26262 //The Birth Animation - -#define SPELL_DIRTMOUND_PASSIVE 26092 - -struct MANGOS_DLL_DECL boss_ouroAI : public ScriptedAI -{ - boss_ouroAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 Sweep_Timer; - uint32 SandBlast_Timer; - uint32 Submerge_Timer; - uint32 Back_Timer; - uint32 ChangeTarget_Timer; - uint32 Spawn_Timer; - - bool Enrage; - bool Submerged; - bool InCombat; - - void Reset() - { - Sweep_Timer = 5000 + rand()%5000; - SandBlast_Timer = 20000 + rand()%15000; - Submerge_Timer = 90000 + rand()%60000; - Back_Timer = 30000 + rand()%15000; - ChangeTarget_Timer = 5000 + rand()%3000; - Spawn_Timer = 10000 + rand()%10000; - - Enrage = false; - Submerged = false; - } - - void Aggro(Unit *who) - { - DoCast(m_creature->getVictim(), SPELL_BIRTH); - } - - void UpdateAI(const uint32 diff) - { - //Return since we have no target - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - //Sweep_Timer - if (!Submerged && Sweep_Timer < diff) - { - DoCast(m_creature->getVictim(), SPELL_SWEEP); - Sweep_Timer = 15000 + rand()%15000; - }else Sweep_Timer -= diff; - - //SandBlast_Timer - if (!Submerged && SandBlast_Timer < diff) - { - DoCast(m_creature->getVictim(), SPELL_SANDBLAST); - SandBlast_Timer = 20000 + rand()%15000; - }else SandBlast_Timer -= diff; - - //Submerge_Timer - if (!Submerged && Submerge_Timer < diff) - { - //Cast - m_creature->HandleEmoteCommand(EMOTE_ONESHOT_SUBMERGE); - m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - m_creature->setFaction(35); - DoCast(m_creature, SPELL_DIRTMOUND_PASSIVE); - - Submerged = true; - Back_Timer = 30000 + rand()%15000; - }else Submerge_Timer -= diff; - - //ChangeTarget_Timer - if (Submerged && ChangeTarget_Timer < diff) - { - Unit* target = NULL; - target = SelectUnit(SELECT_TARGET_RANDOM,0); - - m_creature->Relocate(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0); - m_creature->SendMonsterMove(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0, true,1); - - ChangeTarget_Timer = 10000 + rand()%10000; - }else ChangeTarget_Timer -= diff; - - //Back_Timer - if (Submerged && Back_Timer < diff) - { - m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - m_creature->setFaction(14); - - DoCast(m_creature->getVictim(), SPELL_GROUND_RUPTURE); - - Submerged = false; - Submerge_Timer = 60000 + rand()%60000; - }else Back_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; - -CreatureAI* GetAI_boss_ouro(Creature *_Creature) -{ - return new boss_ouroAI (_Creature); -} - -void AddSC_boss_ouro() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_ouro"; - newscript->GetAI = GetAI_boss_ouro; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Ouro +SD%Complete: 85 +SDComment: No model for submerging. Currently just invisible. +SDCategory: Temple of Ahn'Qiraj +EndScriptData */ + +#include "precompiled.h" +#include "def_temple_of_ahnqiraj.h" + +#define SPELL_SWEEP 26103 +#define SPELL_SANDBLAST 26102 +#define SPELL_GROUND_RUPTURE 26100 +#define SPELL_BIRTH 26262 //The Birth Animation + +#define SPELL_DIRTMOUND_PASSIVE 26092 + +struct MANGOS_DLL_DECL boss_ouroAI : public ScriptedAI +{ + boss_ouroAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 Sweep_Timer; + uint32 SandBlast_Timer; + uint32 Submerge_Timer; + uint32 Back_Timer; + uint32 ChangeTarget_Timer; + uint32 Spawn_Timer; + + bool Enrage; + bool Submerged; + bool InCombat; + + void Reset() + { + Sweep_Timer = 5000 + rand()%5000; + SandBlast_Timer = 20000 + rand()%15000; + Submerge_Timer = 90000 + rand()%60000; + Back_Timer = 30000 + rand()%15000; + ChangeTarget_Timer = 5000 + rand()%3000; + Spawn_Timer = 10000 + rand()%10000; + + Enrage = false; + Submerged = false; + } + + void Aggro(Unit *who) + { + DoCast(m_creature->getVictim(), SPELL_BIRTH); + } + + void UpdateAI(const uint32 diff) + { + //Return since we have no target + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + //Sweep_Timer + if (!Submerged && Sweep_Timer < diff) + { + DoCast(m_creature->getVictim(), SPELL_SWEEP); + Sweep_Timer = 15000 + rand()%15000; + }else Sweep_Timer -= diff; + + //SandBlast_Timer + if (!Submerged && SandBlast_Timer < diff) + { + DoCast(m_creature->getVictim(), SPELL_SANDBLAST); + SandBlast_Timer = 20000 + rand()%15000; + }else SandBlast_Timer -= diff; + + //Submerge_Timer + if (!Submerged && Submerge_Timer < diff) + { + //Cast + m_creature->HandleEmoteCommand(EMOTE_ONESHOT_SUBMERGE); + m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + m_creature->setFaction(35); + DoCast(m_creature, SPELL_DIRTMOUND_PASSIVE); + + Submerged = true; + Back_Timer = 30000 + rand()%15000; + }else Submerge_Timer -= diff; + + //ChangeTarget_Timer + if (Submerged && ChangeTarget_Timer < diff) + { + Unit* target = NULL; + target = SelectUnit(SELECT_TARGET_RANDOM,0); + + m_creature->Relocate(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0); + m_creature->SendMonsterMove(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0, true,1); + + ChangeTarget_Timer = 10000 + rand()%10000; + }else ChangeTarget_Timer -= diff; + + //Back_Timer + if (Submerged && Back_Timer < diff) + { + m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + m_creature->setFaction(14); + + DoCast(m_creature->getVictim(), SPELL_GROUND_RUPTURE); + + Submerged = false; + Submerge_Timer = 60000 + rand()%60000; + }else Back_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; + +CreatureAI* GetAI_boss_ouro(Creature *_Creature) +{ + return new boss_ouroAI (_Creature); +} + +void AddSC_boss_ouro() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_ouro"; + newscript->GetAI = GetAI_boss_ouro; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/boss_sartura.cpp b/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/boss_sartura.cpp index d9a9d27dffc..9a6e04982fd 100644 --- a/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/boss_sartura.cpp +++ b/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/boss_sartura.cpp @@ -1,271 +1,271 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Sartura -SD%Complete: 99 -SDComment: -SDCategory: Temple of Ahn'Qiraj -EndScriptData */ - -#include "precompiled.h" - -#define SPELL_WHIRLWIND 26083 -#define SPELL_ENRAGE 28747 //Not sure if right ID. -#define SPELL_ENRAGEHARD 28798 - -//Guard Spell -#define SPELL_WHIRLWINDADD 26038 -#define SPELL_KNOCKBACK 26027 - -struct MANGOS_DLL_DECL boss_sarturaAI : public ScriptedAI -{ - boss_sarturaAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 WhirlWind_Timer; - uint32 WhirlWindRandom_Timer; - uint32 WhirlWindEnd_Timer; - uint32 AggroReset_Timer; - uint32 AggroResetEnd_Timer; - uint32 EnrageHard_Timer; - - bool Enraged; - bool EnragedHard; - bool WhirlWind; - bool AggroReset; - - void Reset() - { - WhirlWind_Timer = 30000; - WhirlWindRandom_Timer = 3000 + rand()%4000; - WhirlWindEnd_Timer = 15000; - AggroReset_Timer = 45000 + rand()%10000; - AggroResetEnd_Timer = 5000; - EnrageHard_Timer = 10*60000; - - WhirlWind = false; - AggroReset = false; - Enraged = false; - EnragedHard = false; - } - - void Aggro(Unit *who) - { - } - - void UpdateAI(const uint32 diff) - { - //Return since we have no target - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - if (WhirlWind) - { - if (WhirlWindRandom_Timer < diff) - { - //Attack random Gamers - Unit* target = NULL; - target = SelectUnit(SELECT_TARGET_RANDOM,1); - if (target) - DoStartAttackAndMovement(target); - - WhirlWindRandom_Timer = 3000 + rand()%4000; - }else WhirlWindRandom_Timer -= diff; - - if (WhirlWindEnd_Timer < diff) - { - WhirlWind = false; - WhirlWind_Timer = 25000 + rand()%15000; - }else WhirlWindEnd_Timer -= diff; - } - - if (!WhirlWind) - { - if (WhirlWind_Timer < diff) - { - DoCast(m_creature, SPELL_WHIRLWIND); - WhirlWind = true; - WhirlWindEnd_Timer = 15000; - }else WhirlWind_Timer -= diff; - - if (AggroReset_Timer < diff) - { - //Attack random Gamers - Unit* target = NULL; - target = SelectUnit(SELECT_TARGET_RANDOM,1); - if (target) - m_creature->TauntApply(target); - - AggroReset = true; - AggroReset_Timer = 2000 + rand()%3000; - }else AggroReset_Timer -= diff; - - if (AggroReset) - { - if (AggroResetEnd_Timer GetHealth()*100 / m_creature->GetMaxHealth() <= 20 && !m_creature->IsNonMeleeSpellCasted(false)) - { - DoCast(m_creature, SPELL_ENRAGE); - Enraged = true; - } - } - - //After 10 minutes hard enrage - if (!EnragedHard) - { - if (EnrageHard_Timer < diff) - { - DoCast(m_creature, SPELL_ENRAGEHARD); - EnragedHard = true; - }EnrageHard_Timer -= diff; - } - - DoMeleeAttackIfReady(); - } - } -}; - -struct MANGOS_DLL_DECL mob_sartura_royal_guardAI : public ScriptedAI -{ - mob_sartura_royal_guardAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 WhirlWind_Timer; - uint32 WhirlWindRandom_Timer; - uint32 WhirlWindEnd_Timer; - uint32 AggroReset_Timer; - uint32 AggroResetEnd_Timer; - uint32 KnockBack_Timer; - - bool WhirlWind; - bool AggroReset; - - void Reset() - { - WhirlWind_Timer = 30000; - WhirlWindRandom_Timer = 3000 + rand()%4000; - WhirlWindEnd_Timer = 15000; - AggroReset_Timer = 45000 + rand()%10000; - AggroResetEnd_Timer = 5000; - KnockBack_Timer = 10000; - - WhirlWind = false; - AggroReset = false; - } - - void Aggro(Unit *who) - { - } - - void UpdateAI(const uint32 diff) - { - //Return since we have no target - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - if (!WhirlWind && WhirlWind_Timer < diff) - { - DoCast(m_creature, SPELL_WHIRLWINDADD); - WhirlWind = true; - WhirlWind_Timer = 25000 + rand()%15000; - WhirlWindEnd_Timer = 15000; - }else WhirlWind_Timer -= diff; - - if (WhirlWind) - { - if (WhirlWindRandom_Timer < diff) - { - //Attack random Gamers - Unit* target = NULL; - target = SelectUnit(SELECT_TARGET_RANDOM,1); - if (target) - m_creature->TauntApply(target); - - WhirlWindRandom_Timer = 3000 + rand()%4000; - }else WhirlWindRandom_Timer -= diff; - - if (WhirlWindEnd_Timer < diff) - { - WhirlWind = false; - }else WhirlWindEnd_Timer -= diff; - } - - if (!WhirlWind) - { - if(AggroReset_Timer < diff) - { - //Attack random Gamers - Unit* target = NULL; - target = SelectUnit(SELECT_TARGET_RANDOM,1); - if (target) - DoStartAttackAndMovement(target); - - AggroReset = true; - AggroReset_Timer = 2000 + rand()%3000; - }else AggroReset_Timer -= diff; - - if (KnockBack_Timer < diff) - { - DoCast(m_creature, SPELL_WHIRLWINDADD); - KnockBack_Timer = 10000 + rand()%10000; - }else KnockBack_Timer -= diff; - } - - if (AggroReset) - { - if (AggroResetEnd_Timer Name="boss_sartura"; - newscript->GetAI = GetAI_boss_sartura; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="mob_sartura_royal_guard"; - newscript->GetAI = GetAI_mob_sartura_royal_guard; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Sartura +SD%Complete: 99 +SDComment: +SDCategory: Temple of Ahn'Qiraj +EndScriptData */ + +#include "precompiled.h" + +#define SPELL_WHIRLWIND 26083 +#define SPELL_ENRAGE 28747 //Not sure if right ID. +#define SPELL_ENRAGEHARD 28798 + +//Guard Spell +#define SPELL_WHIRLWINDADD 26038 +#define SPELL_KNOCKBACK 26027 + +struct MANGOS_DLL_DECL boss_sarturaAI : public ScriptedAI +{ + boss_sarturaAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 WhirlWind_Timer; + uint32 WhirlWindRandom_Timer; + uint32 WhirlWindEnd_Timer; + uint32 AggroReset_Timer; + uint32 AggroResetEnd_Timer; + uint32 EnrageHard_Timer; + + bool Enraged; + bool EnragedHard; + bool WhirlWind; + bool AggroReset; + + void Reset() + { + WhirlWind_Timer = 30000; + WhirlWindRandom_Timer = 3000 + rand()%4000; + WhirlWindEnd_Timer = 15000; + AggroReset_Timer = 45000 + rand()%10000; + AggroResetEnd_Timer = 5000; + EnrageHard_Timer = 10*60000; + + WhirlWind = false; + AggroReset = false; + Enraged = false; + EnragedHard = false; + } + + void Aggro(Unit *who) + { + } + + void UpdateAI(const uint32 diff) + { + //Return since we have no target + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + if (WhirlWind) + { + if (WhirlWindRandom_Timer < diff) + { + //Attack random Gamers + Unit* target = NULL; + target = SelectUnit(SELECT_TARGET_RANDOM,1); + if (target) + DoStartAttackAndMovement(target); + + WhirlWindRandom_Timer = 3000 + rand()%4000; + }else WhirlWindRandom_Timer -= diff; + + if (WhirlWindEnd_Timer < diff) + { + WhirlWind = false; + WhirlWind_Timer = 25000 + rand()%15000; + }else WhirlWindEnd_Timer -= diff; + } + + if (!WhirlWind) + { + if (WhirlWind_Timer < diff) + { + DoCast(m_creature, SPELL_WHIRLWIND); + WhirlWind = true; + WhirlWindEnd_Timer = 15000; + }else WhirlWind_Timer -= diff; + + if (AggroReset_Timer < diff) + { + //Attack random Gamers + Unit* target = NULL; + target = SelectUnit(SELECT_TARGET_RANDOM,1); + if (target) + m_creature->TauntApply(target); + + AggroReset = true; + AggroReset_Timer = 2000 + rand()%3000; + }else AggroReset_Timer -= diff; + + if (AggroReset) + { + if (AggroResetEnd_Timer GetHealth()*100 / m_creature->GetMaxHealth() <= 20 && !m_creature->IsNonMeleeSpellCasted(false)) + { + DoCast(m_creature, SPELL_ENRAGE); + Enraged = true; + } + } + + //After 10 minutes hard enrage + if (!EnragedHard) + { + if (EnrageHard_Timer < diff) + { + DoCast(m_creature, SPELL_ENRAGEHARD); + EnragedHard = true; + }EnrageHard_Timer -= diff; + } + + DoMeleeAttackIfReady(); + } + } +}; + +struct MANGOS_DLL_DECL mob_sartura_royal_guardAI : public ScriptedAI +{ + mob_sartura_royal_guardAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 WhirlWind_Timer; + uint32 WhirlWindRandom_Timer; + uint32 WhirlWindEnd_Timer; + uint32 AggroReset_Timer; + uint32 AggroResetEnd_Timer; + uint32 KnockBack_Timer; + + bool WhirlWind; + bool AggroReset; + + void Reset() + { + WhirlWind_Timer = 30000; + WhirlWindRandom_Timer = 3000 + rand()%4000; + WhirlWindEnd_Timer = 15000; + AggroReset_Timer = 45000 + rand()%10000; + AggroResetEnd_Timer = 5000; + KnockBack_Timer = 10000; + + WhirlWind = false; + AggroReset = false; + } + + void Aggro(Unit *who) + { + } + + void UpdateAI(const uint32 diff) + { + //Return since we have no target + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + if (!WhirlWind && WhirlWind_Timer < diff) + { + DoCast(m_creature, SPELL_WHIRLWINDADD); + WhirlWind = true; + WhirlWind_Timer = 25000 + rand()%15000; + WhirlWindEnd_Timer = 15000; + }else WhirlWind_Timer -= diff; + + if (WhirlWind) + { + if (WhirlWindRandom_Timer < diff) + { + //Attack random Gamers + Unit* target = NULL; + target = SelectUnit(SELECT_TARGET_RANDOM,1); + if (target) + m_creature->TauntApply(target); + + WhirlWindRandom_Timer = 3000 + rand()%4000; + }else WhirlWindRandom_Timer -= diff; + + if (WhirlWindEnd_Timer < diff) + { + WhirlWind = false; + }else WhirlWindEnd_Timer -= diff; + } + + if (!WhirlWind) + { + if(AggroReset_Timer < diff) + { + //Attack random Gamers + Unit* target = NULL; + target = SelectUnit(SELECT_TARGET_RANDOM,1); + if (target) + DoStartAttackAndMovement(target); + + AggroReset = true; + AggroReset_Timer = 2000 + rand()%3000; + }else AggroReset_Timer -= diff; + + if (KnockBack_Timer < diff) + { + DoCast(m_creature, SPELL_WHIRLWINDADD); + KnockBack_Timer = 10000 + rand()%10000; + }else KnockBack_Timer -= diff; + } + + if (AggroReset) + { + if (AggroResetEnd_Timer Name="boss_sartura"; + newscript->GetAI = GetAI_boss_sartura; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="mob_sartura_royal_guard"; + newscript->GetAI = GetAI_mob_sartura_royal_guard; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/boss_skeram.cpp b/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/boss_skeram.cpp index a2123c21da0..ada2f7a1dd7 100644 --- a/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/boss_skeram.cpp +++ b/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/boss_skeram.cpp @@ -1,314 +1,314 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Skeram -SD%Complete: 75 -SDComment: Mind Control buggy. -SDCategory: Temple of Ahn'Qiraj -EndScriptData */ - -#include "precompiled.h" -#include "def_temple_of_ahnqiraj.h" -#include "Group.h" - -#define SPELL_ARCANE_EXPLOSION 25679 -#define SPELL_EARTH_SHOCK 26194 -#define SPELL_TRUE_FULFILLMENT4 26526 -#define SPELL_BLINK 28391 - -#define SOUND_AGGRO1 8615 //8615 Are you so eager to die? I would be happy to accomodate you. -#define SOUND_AGGRO2 8616 //8616 Cower mortals! The age of darkness is at hand. -#define SOUND_AGGRO3 8621 //8621 Tremble! The end is upon you. -#define SOUND_SLAY1 8617 //8617 Let your death serve as an example! -#define SOUND_SLAY2 8619 //8619 Spineless wretchers you will drown in rivers of blood! -#define SOUND_SLAY3 8620 //8620 The screams of the dying will fill the air. A symphony of terror is about to begin! -#define SOUND_SPLIT 8618 //8618 Prepare for the return of the ancient ones! -#define SOUND_DEATH 8622 //8622 You only delay... the inevetable - -class ov_mycoordinates -{ - public: - float x,y,z,r; - ov_mycoordinates(float cx, float cy, float cz, float cr) - { - x = cx; y = cy; z = cz; r = cr; - } -}; - -struct MANGOS_DLL_DECL boss_skeramAI : public ScriptedAI -{ - boss_skeramAI(Creature *c) : ScriptedAI(c) - { - pInstance = (c->GetInstanceData()) ? ((ScriptedInstance*)c->GetInstanceData()) : NULL; - IsImage = false; - Reset(); - } - - ScriptedInstance *pInstance; - - uint32 ArcaneExplosion_Timer; - uint32 EarthShock_Timer; - uint32 FullFillment_Timer; - uint32 Blink_Timer; - uint32 Invisible_Timer; - - Creature *Image1, *Image2; - - bool Images75; - bool Images50; - bool Images25; - bool IsImage; - bool Invisible; - - void Reset() - { - ArcaneExplosion_Timer = 6000 + rand()%6000; - EarthShock_Timer = 2000; - FullFillment_Timer = 15000; - Blink_Timer = 8000 + rand()%12000; - Invisible_Timer = 500; - - Images75 = false; - Images50 = false; - Images25 = false; - Invisible = false; - - m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - m_creature->SetVisibility(VISIBILITY_ON); - - if (IsImage) - m_creature->setDeathState(JUST_DIED); - } - - void KilledUnit(Unit* victim) - { - switch(rand()%3) - { - case 0: - DoPlaySoundToSet(m_creature,SOUND_SLAY1); - break; - case 1: - DoPlaySoundToSet(m_creature,SOUND_SLAY2); - break; - case 2: - DoPlaySoundToSet(m_creature,SOUND_SLAY3); - break; - } - } - - void JustDied(Unit* Killer) - { - if (!IsImage) - DoPlaySoundToSet(m_creature,SOUND_DEATH); - } - - void Aggro(Unit *who) - { - if (IsImage || Images75) - return; - switch(rand()%3) - { - case 0: - DoPlaySoundToSet(m_creature,SOUND_AGGRO1); - break; - case 1: - DoPlaySoundToSet(m_creature,SOUND_AGGRO2); - break; - case 2: - DoPlaySoundToSet(m_creature,SOUND_AGGRO3); - break; - } - } - - void UpdateAI(const uint32 diff) - { - //Return since we have no target - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - //ArcaneExplosion_Timer - if (ArcaneExplosion_Timer < diff) - { - DoCast(m_creature->getVictim(), SPELL_ARCANE_EXPLOSION); - ArcaneExplosion_Timer = 8000 + rand()%10000; - }else ArcaneExplosion_Timer -= diff; - - //If we are within range melee the target - if( m_creature->IsWithinDistInMap(m_creature->getVictim(), ATTACK_DISTANCE)) - { - //Make sure our attack is ready and we arn't currently casting - if( m_creature->isAttackReady() && !m_creature->IsNonMeleeSpellCasted(false)) - { - m_creature->AttackerStateUpdate(m_creature->getVictim()); - m_creature->resetAttackTimer(); - } - }else - { - //EarthShock_Timer - if (EarthShock_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_EARTH_SHOCK); - EarthShock_Timer = 1000; - }else EarthShock_Timer -= diff; - } - - //Blink_Timer - if (Blink_Timer < diff) - { - //DoCast(m_creature, SPELL_BLINK); - switch(rand()%3) - { - case 0: - m_creature->Relocate(-8340.782227,2083.814453,125.648788,0); - DoResetThreat(); - break; - case 1: - m_creature->Relocate(-8341.546875,2118.504639,133.058151,0); - DoResetThreat(); - break; - case 2: - m_creature->Relocate(-8318.822266,2058.231201,133.058151,0); - DoResetThreat(); - break; - } - DoStopAttack(); - - Blink_Timer= 20000 + rand()%20000; - }else Blink_Timer -= diff; - - int procent = (int) (m_creature->GetHealth()*100 / m_creature->GetMaxHealth() +0.5); - - //Summoning 2 Images and teleporting to a random position on 75% health - if ( (!Images75 && !IsImage) && - (procent <= 75 && procent > 70) ) - DoSplit(75); - - //Summoning 2 Images and teleporting to a random position on 50% health - if ( (!Images50 && !IsImage) && - (procent <= 50 && procent > 45) ) - DoSplit(50); - - //Summoning 2 Images and teleporting to a random position on 25% health - if ( (!Images25 && !IsImage) && - (procent <= 25 && procent > 20) ) - DoSplit(25); - - //Invisible_Timer - if (Invisible) - { - if (Invisible_Timer < diff) - { - //Making Skeram visible after telporting - m_creature->SetVisibility(VISIBILITY_ON); - m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - - Invisible_Timer = 2500; - Invisible = false; - }else Invisible_Timer -= diff; - } - - DoMeleeAttackIfReady(); - } - - void DoSplit(int atPercent /* 75 50 25 */) - { - DoPlaySoundToSet(m_creature,SOUND_SPLIT); - Unit* target = NULL; - target = SelectUnit(SELECT_TARGET_RANDOM,0); - - ov_mycoordinates *place1 = new ov_mycoordinates(-8340.782227,2083.814453,125.648788,0); - ov_mycoordinates *place2 = new ov_mycoordinates(-8341.546875,2118.504639,133.058151,0); - ov_mycoordinates *place3 = new ov_mycoordinates(-8318.822266,2058.231201,133.058151,0); - - ov_mycoordinates *bossc=place1, *i1=place2, *i2=place3; - - switch(rand()%3) - { - case 0: - bossc=place1;i1=place2;i2=place3; - break; - case 1: - bossc=place2;i1=place1;i2=place3; - break; - case 2: - bossc=place3;i1=place1;i2=place2; - break; - } - - for (int tryi = 0; tryi < 41; tryi ++) - { - Unit *targetpl = SelectUnit(SELECT_TARGET_RANDOM, 0); - if (targetpl->isType(TYPEMASK_PLAYER)) - { - Group *grp = ((Player *)targetpl)->GetGroup(); - if (grp) - { - for (int ici = 0; ici < TARGETICONCOUNT; ici++) - { - //if (grp ->m_targetIcons[ici] == m_creature->GetGUID()) -- private member:( - grp->SetTargetIcon(ici, 0); - } - } - break; - } - } - - m_creature->RemoveAllAuras(); - m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - m_creature->SetVisibility(VISIBILITY_OFF); - m_creature->Relocate(bossc->x, bossc->y, bossc->z, bossc->r); - Invisible = true; - DoResetThreat(); - DoStopAttack(); - - switch (atPercent) - { - case 75: Images75 = true; break; - case 50: Images50 = true; break; - case 25: Images25 = true; break; - } - - Image1 = m_creature->SummonCreature(15263, i1->x, i1->y, i1->z, i1->r, TEMPSUMMON_CORPSE_DESPAWN, 30000); - Image1->SetMaxHealth(m_creature->GetMaxHealth() / 5); - Image1->SetHealth(m_creature->GetHealth() / 5); - Image1->AI()->AttackStart(target); - - Image2 = m_creature->SummonCreature(15263,i2->x, i2->y, i2->z, i2->r, TEMPSUMMON_CORPSE_DESPAWN, 30000); - Image2->SetMaxHealth(m_creature->GetMaxHealth() / 5); - Image2->SetHealth(m_creature->GetHealth() / 5); - Image2->AI()->AttackStart(target); - - ((boss_skeramAI*)Image1->AI())->IsImage = true; - ((boss_skeramAI*)Image2->AI())->IsImage = true; - - Invisible = true; - } -}; - -CreatureAI* GetAI_boss_skeram(Creature *_Creature) -{ - return new boss_skeramAI (_Creature); -} - -void AddSC_boss_skeram() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_skeram"; - newscript->GetAI = GetAI_boss_skeram; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Skeram +SD%Complete: 75 +SDComment: Mind Control buggy. +SDCategory: Temple of Ahn'Qiraj +EndScriptData */ + +#include "precompiled.h" +#include "def_temple_of_ahnqiraj.h" +#include "Group.h" + +#define SPELL_ARCANE_EXPLOSION 25679 +#define SPELL_EARTH_SHOCK 26194 +#define SPELL_TRUE_FULFILLMENT4 26526 +#define SPELL_BLINK 28391 + +#define SOUND_AGGRO1 8615 //8615 Are you so eager to die? I would be happy to accomodate you. +#define SOUND_AGGRO2 8616 //8616 Cower mortals! The age of darkness is at hand. +#define SOUND_AGGRO3 8621 //8621 Tremble! The end is upon you. +#define SOUND_SLAY1 8617 //8617 Let your death serve as an example! +#define SOUND_SLAY2 8619 //8619 Spineless wretchers you will drown in rivers of blood! +#define SOUND_SLAY3 8620 //8620 The screams of the dying will fill the air. A symphony of terror is about to begin! +#define SOUND_SPLIT 8618 //8618 Prepare for the return of the ancient ones! +#define SOUND_DEATH 8622 //8622 You only delay... the inevetable + +class ov_mycoordinates +{ + public: + float x,y,z,r; + ov_mycoordinates(float cx, float cy, float cz, float cr) + { + x = cx; y = cy; z = cz; r = cr; + } +}; + +struct MANGOS_DLL_DECL boss_skeramAI : public ScriptedAI +{ + boss_skeramAI(Creature *c) : ScriptedAI(c) + { + pInstance = (c->GetInstanceData()) ? ((ScriptedInstance*)c->GetInstanceData()) : NULL; + IsImage = false; + Reset(); + } + + ScriptedInstance *pInstance; + + uint32 ArcaneExplosion_Timer; + uint32 EarthShock_Timer; + uint32 FullFillment_Timer; + uint32 Blink_Timer; + uint32 Invisible_Timer; + + Creature *Image1, *Image2; + + bool Images75; + bool Images50; + bool Images25; + bool IsImage; + bool Invisible; + + void Reset() + { + ArcaneExplosion_Timer = 6000 + rand()%6000; + EarthShock_Timer = 2000; + FullFillment_Timer = 15000; + Blink_Timer = 8000 + rand()%12000; + Invisible_Timer = 500; + + Images75 = false; + Images50 = false; + Images25 = false; + Invisible = false; + + m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + m_creature->SetVisibility(VISIBILITY_ON); + + if (IsImage) + m_creature->setDeathState(JUST_DIED); + } + + void KilledUnit(Unit* victim) + { + switch(rand()%3) + { + case 0: + DoPlaySoundToSet(m_creature,SOUND_SLAY1); + break; + case 1: + DoPlaySoundToSet(m_creature,SOUND_SLAY2); + break; + case 2: + DoPlaySoundToSet(m_creature,SOUND_SLAY3); + break; + } + } + + void JustDied(Unit* Killer) + { + if (!IsImage) + DoPlaySoundToSet(m_creature,SOUND_DEATH); + } + + void Aggro(Unit *who) + { + if (IsImage || Images75) + return; + switch(rand()%3) + { + case 0: + DoPlaySoundToSet(m_creature,SOUND_AGGRO1); + break; + case 1: + DoPlaySoundToSet(m_creature,SOUND_AGGRO2); + break; + case 2: + DoPlaySoundToSet(m_creature,SOUND_AGGRO3); + break; + } + } + + void UpdateAI(const uint32 diff) + { + //Return since we have no target + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + //ArcaneExplosion_Timer + if (ArcaneExplosion_Timer < diff) + { + DoCast(m_creature->getVictim(), SPELL_ARCANE_EXPLOSION); + ArcaneExplosion_Timer = 8000 + rand()%10000; + }else ArcaneExplosion_Timer -= diff; + + //If we are within range melee the target + if( m_creature->IsWithinDistInMap(m_creature->getVictim(), ATTACK_DISTANCE)) + { + //Make sure our attack is ready and we arn't currently casting + if( m_creature->isAttackReady() && !m_creature->IsNonMeleeSpellCasted(false)) + { + m_creature->AttackerStateUpdate(m_creature->getVictim()); + m_creature->resetAttackTimer(); + } + }else + { + //EarthShock_Timer + if (EarthShock_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_EARTH_SHOCK); + EarthShock_Timer = 1000; + }else EarthShock_Timer -= diff; + } + + //Blink_Timer + if (Blink_Timer < diff) + { + //DoCast(m_creature, SPELL_BLINK); + switch(rand()%3) + { + case 0: + m_creature->Relocate(-8340.782227,2083.814453,125.648788,0); + DoResetThreat(); + break; + case 1: + m_creature->Relocate(-8341.546875,2118.504639,133.058151,0); + DoResetThreat(); + break; + case 2: + m_creature->Relocate(-8318.822266,2058.231201,133.058151,0); + DoResetThreat(); + break; + } + DoStopAttack(); + + Blink_Timer= 20000 + rand()%20000; + }else Blink_Timer -= diff; + + int procent = (int) (m_creature->GetHealth()*100 / m_creature->GetMaxHealth() +0.5); + + //Summoning 2 Images and teleporting to a random position on 75% health + if ( (!Images75 && !IsImage) && + (procent <= 75 && procent > 70) ) + DoSplit(75); + + //Summoning 2 Images and teleporting to a random position on 50% health + if ( (!Images50 && !IsImage) && + (procent <= 50 && procent > 45) ) + DoSplit(50); + + //Summoning 2 Images and teleporting to a random position on 25% health + if ( (!Images25 && !IsImage) && + (procent <= 25 && procent > 20) ) + DoSplit(25); + + //Invisible_Timer + if (Invisible) + { + if (Invisible_Timer < diff) + { + //Making Skeram visible after telporting + m_creature->SetVisibility(VISIBILITY_ON); + m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + + Invisible_Timer = 2500; + Invisible = false; + }else Invisible_Timer -= diff; + } + + DoMeleeAttackIfReady(); + } + + void DoSplit(int atPercent /* 75 50 25 */) + { + DoPlaySoundToSet(m_creature,SOUND_SPLIT); + Unit* target = NULL; + target = SelectUnit(SELECT_TARGET_RANDOM,0); + + ov_mycoordinates *place1 = new ov_mycoordinates(-8340.782227,2083.814453,125.648788,0); + ov_mycoordinates *place2 = new ov_mycoordinates(-8341.546875,2118.504639,133.058151,0); + ov_mycoordinates *place3 = new ov_mycoordinates(-8318.822266,2058.231201,133.058151,0); + + ov_mycoordinates *bossc=place1, *i1=place2, *i2=place3; + + switch(rand()%3) + { + case 0: + bossc=place1;i1=place2;i2=place3; + break; + case 1: + bossc=place2;i1=place1;i2=place3; + break; + case 2: + bossc=place3;i1=place1;i2=place2; + break; + } + + for (int tryi = 0; tryi < 41; tryi ++) + { + Unit *targetpl = SelectUnit(SELECT_TARGET_RANDOM, 0); + if (targetpl->isType(TYPEMASK_PLAYER)) + { + Group *grp = ((Player *)targetpl)->GetGroup(); + if (grp) + { + for (int ici = 0; ici < TARGETICONCOUNT; ici++) + { + //if (grp ->m_targetIcons[ici] == m_creature->GetGUID()) -- private member:( + grp->SetTargetIcon(ici, 0); + } + } + break; + } + } + + m_creature->RemoveAllAuras(); + m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + m_creature->SetVisibility(VISIBILITY_OFF); + m_creature->Relocate(bossc->x, bossc->y, bossc->z, bossc->r); + Invisible = true; + DoResetThreat(); + DoStopAttack(); + + switch (atPercent) + { + case 75: Images75 = true; break; + case 50: Images50 = true; break; + case 25: Images25 = true; break; + } + + Image1 = m_creature->SummonCreature(15263, i1->x, i1->y, i1->z, i1->r, TEMPSUMMON_CORPSE_DESPAWN, 30000); + Image1->SetMaxHealth(m_creature->GetMaxHealth() / 5); + Image1->SetHealth(m_creature->GetHealth() / 5); + Image1->AI()->AttackStart(target); + + Image2 = m_creature->SummonCreature(15263,i2->x, i2->y, i2->z, i2->r, TEMPSUMMON_CORPSE_DESPAWN, 30000); + Image2->SetMaxHealth(m_creature->GetMaxHealth() / 5); + Image2->SetHealth(m_creature->GetHealth() / 5); + Image2->AI()->AttackStart(target); + + ((boss_skeramAI*)Image1->AI())->IsImage = true; + ((boss_skeramAI*)Image2->AI())->IsImage = true; + + Invisible = true; + } +}; + +CreatureAI* GetAI_boss_skeram(Creature *_Creature) +{ + return new boss_skeramAI (_Creature); +} + +void AddSC_boss_skeram() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_skeram"; + newscript->GetAI = GetAI_boss_skeram; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/boss_twinemperors.cpp b/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/boss_twinemperors.cpp index dacb55c4055..16528b6c595 100644 --- a/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/boss_twinemperors.cpp +++ b/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/boss_twinemperors.cpp @@ -1,698 +1,698 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Twinemperors -SD%Complete: 95 -SDComment: -SDCategory: Temple of Ahn'Qiraj -EndScriptData */ - -#include "precompiled.h" -#include "def_temple_of_ahnqiraj.h" -#include "WorldPacket.h" - -#include "Item.h" -#include "Spell.h" - -#define SPELL_HEAL_BROTHER 7393 -#define SPELL_TWIN_TELEPORT 800 // CTRA watches for this spell to start its teleport timer -#define SPELL_TWIN_TELEPORT_VISUAL 26638 // visual - -#define SPELL_EXPLODEBUG 804 -#define SPELL_MUTATE_BUG 802 - -#define SOUND_VN_DEATH 8660 //8660 - Death - Feel -#define SOUND_VN_AGGRO 8661 //8661 - Aggro - Let none -#define SOUND_VN_KILL 8662 //8661 - Kill - your fate - -#define SOUND_VL_AGGRO 8657 //8657 - Aggro - To Late -#define SOUND_VL_KILL 8658 //8658 - Kill - You will not -#define SOUND_VL_DEATH 8659 //8659 - Death - -#define PULL_RANGE 50 -#define ABUSE_BUG_RANGE 20 -#define SPELL_BERSERK 26662 -#define TELEPORTTIME 30000 - -#define SPELL_UPPERCUT 26007 -#define SPELL_UNBALANCING_STRIKE 26613 - -#define VEKLOR_DIST 20 // VL will not come to melee when attacking - -#define SPELL_SHADOWBOLT 26006 -#define SPELL_BLIZZARD 26607 -#define SPELL_ARCANEBURST 568 - -struct MANGOS_DLL_DECL boss_twinemperorsAI : public ScriptedAI -{ - ScriptedInstance *pInstance; - uint32 Heal_Timer; - uint32 Teleport_Timer; - bool AfterTeleport; - uint32 AfterTeleportTimer; - bool DontYellWhenDead; - uint32 Abuse_Bug_Timer, BugsTimer; - bool tspellcasted; - uint32 EnrageTimer; - - virtual bool IAmVeklor() = 0; - virtual void Reset() = 0; - virtual void CastSpellOnBug(Creature *target) = 0; - - boss_twinemperorsAI(Creature *c): ScriptedAI(c) - { - pInstance = ((ScriptedInstance*)c->GetInstanceData()); - } - - void TwinReset() - { - Heal_Timer = 0; // first heal immediately when they get close together - Teleport_Timer = TELEPORTTIME; - AfterTeleport = false; - tspellcasted = false; - AfterTeleportTimer = 0; - Abuse_Bug_Timer = 10000 + rand()%7000; - BugsTimer = 2000; - m_creature->clearUnitState(UNIT_STAT_STUNDED); - DontYellWhenDead = false; - EnrageTimer = 15*60000; - } - - Creature *GetOtherBoss() - { - if(pInstance) - { - return (Creature *)Unit::GetUnit((*m_creature), pInstance->GetData64(IAmVeklor() ? DATA_VEKNILASH : DATA_VEKLOR)); - } - else - { - return (Creature *)0; - } - } - - void DamageTaken(Unit *done_by, uint32 &damage) - { - Unit *pOtherBoss = GetOtherBoss(); - if (pOtherBoss) - { - float dPercent = ((float)damage) / ((float)m_creature->GetMaxHealth()); - int odmg = (int)(dPercent * ((float)pOtherBoss->GetMaxHealth())); - int ohealth = pOtherBoss->GetHealth()-odmg; - pOtherBoss->SetHealth(ohealth > 0 ? ohealth : 0); - if (ohealth <= 0) - { - pOtherBoss->setDeathState(JUST_DIED); - pOtherBoss->SetUInt32Value(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE); - } - } - } - - void JustDied(Unit* Killer) - { - Creature *pOtherBoss = GetOtherBoss(); - if (pOtherBoss) - { - pOtherBoss->SetHealth(0); - pOtherBoss->setDeathState(JUST_DIED); - pOtherBoss->SetUInt32Value(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE); - ((boss_twinemperorsAI *)pOtherBoss->AI())->DontYellWhenDead = true; - } - if (!DontYellWhenDead) // I hope AI is not threaded - DoPlaySoundToSet(m_creature, IAmVeklor() ? SOUND_VL_DEATH : SOUND_VN_DEATH); - } - - void KilledUnit(Unit* victim) - { - DoPlaySoundToSet(m_creature, IAmVeklor() ? SOUND_VL_KILL : SOUND_VN_KILL); - } - - void Aggro(Unit *who) - { - DoZoneInCombat(); - InCombat = true; - Creature *pOtherBoss = GetOtherBoss(); - if (pOtherBoss) - { - // TODO: we should activate the other boss location so he can start attackning even if nobody - // is near I dont know how to do that - ScriptedAI *otherAI = (ScriptedAI*)pOtherBoss->AI(); - if (!otherAI->InCombat) - { - DoPlaySoundToSet(m_creature, IAmVeklor() ? SOUND_VL_AGGRO : SOUND_VN_AGGRO); - otherAI->AttackStart(who); - otherAI->DoZoneInCombat(); - } - } - } - - void SpellHit(Unit *caster, const SpellEntry *entry) - { - if (caster == m_creature) - return; - - Creature *pOtherBoss = GetOtherBoss(); - if (entry->Id != SPELL_HEAL_BROTHER || !pOtherBoss) - return; - - // add health so we keep same percentage for both brothers - uint32 mytotal = m_creature->GetMaxHealth(), histotal = pOtherBoss->GetMaxHealth(); - float mult = ((float)mytotal) / ((float)histotal); - if (mult < 1) - mult = 1.0f/mult; - #define HEAL_BROTHER_AMOUNT 30000.0f - uint32 largerAmount = (uint32)((HEAL_BROTHER_AMOUNT * mult) - HEAL_BROTHER_AMOUNT); - - uint32 myh = m_creature->GetHealth(); - uint32 hish = pOtherBoss->GetHealth(); - if (mytotal > histotal) - { - uint32 h = m_creature->GetHealth()+largerAmount; - m_creature->SetHealth(std::min(mytotal, h)); - } - else - { - uint32 h = pOtherBoss->GetHealth()+largerAmount; - pOtherBoss->SetHealth(std::min(histotal, h)); - } - } - - void TryHealBrother(uint32 diff) - { - if (IAmVeklor()) // this spell heals caster and the other brother so let VN cast it - return; - - if (Heal_Timer < diff) - { - Unit *pOtherBoss = GetOtherBoss(); - if (pOtherBoss && (pOtherBoss->GetDistance((const Creature *)m_creature) <= 60)) - { - DoCast(pOtherBoss, SPELL_HEAL_BROTHER); - Heal_Timer = 1000; - } - } else Heal_Timer -= diff; - } - - Unit *GetAnyoneCloseEnough(float dist, bool totallyRandom) - { - int cnt = 0; - std::list::iterator i; - std::list candidates; - - for (i = m_creature->getThreatManager().getThreatList().begin();i != m_creature->getThreatManager().getThreatList().end(); ++i) - { - Unit* pUnit = Unit::GetUnit((*m_creature), (*i)->getUnitGuid()); - if (m_creature->IsWithinDistInMap(pUnit, dist)) - { - if (!totallyRandom) - return pUnit; - candidates.push_back((*i)); - cnt ++; - } - } - if (!cnt) - return NULL; - for (int randomi = rand() % cnt; randomi > 0; randomi --) - candidates.pop_front(); - - i = candidates.begin(); - Unit *ret = Unit::GetUnit((*m_creature), (*i)->getUnitGuid()); - candidates.clear(); - return ret; - } - - Unit *PickNearestPlayer() - { - Unit *nearp = NULL; - float neardist = 0.0f; - std::list::iterator i; - for (i = m_creature->getThreatManager().getThreatList().begin();i != m_creature->getThreatManager().getThreatList().end(); ++i) - { - Unit* pUnit = NULL; - pUnit = Unit::GetUnit((*m_creature), (*i)->getUnitGuid()); - if (!pUnit) - continue; - float pudist = pUnit->GetDistance((const Creature *)m_creature); - if (!nearp || (neardist > pudist)) - { - nearp = pUnit; - neardist = pudist; - } - } - return nearp; - } - - void TeleportToMyBrother() - { - if (!pInstance) - return; - - Teleport_Timer = TELEPORTTIME; - - if(IAmVeklor()) - return; // mechanics handled by veknilash so they teleport exactly at the same time and to correct coordinates - - Creature *pOtherBoss = GetOtherBoss(); - if (pOtherBoss) - { - //m_creature->MonsterYell("Teleporting ...", LANG_UNIVERSAL, 0); - float other_x = pOtherBoss->GetPositionX(); - float other_y = pOtherBoss->GetPositionY(); - float other_z = pOtherBoss->GetPositionZ(); - float other_o = pOtherBoss->GetOrientation(); - - Map *thismap = m_creature->GetMap(); - thismap->CreatureRelocation(pOtherBoss, m_creature->GetPositionX(), - m_creature->GetPositionY(), m_creature->GetPositionZ(), m_creature->GetOrientation()); - thismap->CreatureRelocation(m_creature, other_x, other_y, other_z, other_o); - - SetAfterTeleport(); - ((boss_twinemperorsAI*) pOtherBoss->AI())->SetAfterTeleport(); - } - } - - void SetAfterTeleport() - { - m_creature->InterruptNonMeleeSpells(false); - DoStopAttack(); - DoResetThreat(); - DoCast(m_creature, SPELL_TWIN_TELEPORT_VISUAL); - m_creature->addUnitState(UNIT_STAT_STUNDED); - AfterTeleport = true; - AfterTeleportTimer = 2000; - tspellcasted = false; - } - - bool TryActivateAfterTTelep(uint32 diff) - { - if (AfterTeleport) - { - if (!tspellcasted) - { - m_creature->clearUnitState(UNIT_STAT_STUNDED); - DoCast(m_creature, SPELL_TWIN_TELEPORT); - m_creature->addUnitState(UNIT_STAT_STUNDED); - } - - tspellcasted = true; - - if (AfterTeleportTimer < diff) - { - AfterTeleport = false; - m_creature->clearUnitState(UNIT_STAT_STUNDED); - Unit *nearu = PickNearestPlayer(); - //DoYell(nearu->GetName(), LANG_UNIVERSAL, 0); - AttackStart(nearu); - m_creature->getThreatManager().addThreat(nearu, 10000); - return true; - } - else - { - AfterTeleportTimer -= diff; - // update important timers which would otherwise get skipped - if (EnrageTimer > diff) - EnrageTimer -= diff; - else - EnrageTimer = 0; - if (Teleport_Timer > diff) - Teleport_Timer -= diff; - else - Teleport_Timer = 0; - return false; - } - } - else - { - return true; - } - } - - void MoveInLineOfSight(Unit *who) - { - if (!who || m_creature->getVictim()) - return; - - if (who->isTargetableForAttack() && who->isInAccessablePlaceFor(m_creature) && m_creature->IsHostileTo(who)) - { - float attackRadius = m_creature->GetAttackDistance(who); - if (attackRadius < PULL_RANGE) - attackRadius = PULL_RANGE; - if (m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->GetDistanceZ(who) <= /*CREATURE_Z_ATTACK_RANGE*/7 /*there are stairs*/) - { - if(who->HasStealthAura()) - who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); - AttackStart(who); - } - } - } - - class AnyBugCheck - { - public: - AnyBugCheck(WorldObject const* obj, float range) : i_obj(obj), i_range(range) {} - bool operator()(Unit* u) - { - Creature *c = (Creature *)u; - if (!i_obj->IsWithinDistInMap(c, i_range)) - return false; - return (c->GetEntry() == 15316 || c->GetEntry() == 15317); - } - private: - WorldObject const* i_obj; - float i_range; - }; - - Creature *RespawnNearbyBugsAndGetOne() - { - CellPair p(MaNGOS::ComputeCellPair(m_creature->GetPositionX(), m_creature->GetPositionY())); - Cell cell(p); - cell.data.Part.reserved = ALL_DISTRICT; - cell.SetNoCreate(); - - std::list unitList; - - AnyBugCheck u_check(m_creature, 150); - MaNGOS::CreatureListSearcher searcher(unitList, u_check); - TypeContainerVisitor, GridTypeMapContainer > grid_creature_searcher(searcher); - CellLock cell_lock(cell, p); - cell_lock->Visit(cell_lock, grid_creature_searcher, *(m_creature->GetMap())); - - Creature *nearb = NULL; - - for(std::list::iterator iter = unitList.begin(); iter != unitList.end(); ++iter) - { - Creature *c = (Creature *)(*iter); - if (c->isDead()) - { - c->Respawn(); - c->setFaction(7); - c->RemoveAllAuras(); - } - if (c->IsWithinDistInMap(m_creature, ABUSE_BUG_RANGE)) - { - if (!nearb || (rand()%4)==0) - nearb = c; - } - } - return nearb; - } - - void HandleBugs(uint32 diff) - { - if (BugsTimer < diff || Abuse_Bug_Timer < diff) - { - Creature *c = RespawnNearbyBugsAndGetOne(); - if (Abuse_Bug_Timer < diff) - { - if (c) - { - CastSpellOnBug(c); - Abuse_Bug_Timer = 10000 + rand()%7000; - } - else - { - Abuse_Bug_Timer = 1000; - } - } - else - { - Abuse_Bug_Timer -= diff; - } - BugsTimer = 2000; - } - else - { - BugsTimer -= diff; - Abuse_Bug_Timer -= diff; - } - } - - void CheckEnrage(uint32 diff) - { - if (EnrageTimer < diff) - { - if (!m_creature->IsNonMeleeSpellCasted(true)) - { - DoCast(m_creature, SPELL_BERSERK); - EnrageTimer = 60*60000; - } else EnrageTimer = 0; - } else EnrageTimer-=diff; - } -}; - -class MANGOS_DLL_DECL BugAura : public Aura -{ - public: - BugAura(SpellEntry *spell, uint32 eff, int32 *bp, Unit *target, Unit *caster) : Aura(spell, eff, bp, target, caster, NULL) - {} -}; - -struct MANGOS_DLL_DECL boss_veknilashAI : public boss_twinemperorsAI -{ - bool IAmVeklor() {return false;} - boss_veknilashAI(Creature *c) : boss_twinemperorsAI(c) - { - Reset(); - } - - uint32 UpperCut_Timer; - uint32 UnbalancingStrike_Timer; - uint32 Scarabs_Timer; - int Rand; - int RandX; - int RandY; - - Creature* Summoned; - - void Reset() - { - TwinReset(); - UpperCut_Timer = 14000 + rand()%15000; - UnbalancingStrike_Timer = 8000 + rand()%10000; - Scarabs_Timer = 7000 + rand()%7000; - - //Added. Can be removed if its included in DB. - m_creature->ApplySpellImmune(0, IMMUNITY_DAMAGE, SPELL_SCHOOL_MASK_MAGIC, true); - } - - void CastSpellOnBug(Creature *target) - { - target->setFaction(14); - ((CreatureAI*)target->AI())->AttackStart(m_creature->getThreatManager().getHostilTarget()); - SpellEntry *spell = (SpellEntry *)GetSpellStore()->LookupEntry(SPELL_MUTATE_BUG); - for (int i=0; i<3; i++) - { - if (!spell->Effect[i]) - continue; - target->AddAura(new BugAura(spell, i, NULL, target, target)); - } - target->SetHealth(target->GetMaxHealth()); - } - - void UpdateAI(const uint32 diff) - { - //Return since we have no target - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - if (!TryActivateAfterTTelep(diff)) - return; - - //UnbalancingStrike_Timer - if (UnbalancingStrike_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_UNBALANCING_STRIKE); - UnbalancingStrike_Timer = 8000+rand()%12000; - }else UnbalancingStrike_Timer -= diff; - - if (UpperCut_Timer < diff) - { - Unit* randomMelee = GetAnyoneCloseEnough(ATTACK_DISTANCE, true); - if (randomMelee) - DoCast(randomMelee,SPELL_UPPERCUT); - UpperCut_Timer = 15000+rand()%15000; - }else UpperCut_Timer -= diff; - - HandleBugs(diff); - - //Heal brother when 60yrds close - TryHealBrother(diff); - - //Teleporting to brother - if(Teleport_Timer < diff) - { - TeleportToMyBrother(); - }else Teleport_Timer -= diff; - - CheckEnrage(diff); - - DoMeleeAttackIfReady(); - } -}; - -struct MANGOS_DLL_DECL boss_veklorAI : public boss_twinemperorsAI -{ - bool IAmVeklor() {return true;} - boss_veklorAI(Creature *c) : boss_twinemperorsAI(c) - { - Reset(); - } - - uint32 ShadowBolt_Timer; - uint32 Blizzard_Timer; - uint32 ArcaneBurst_Timer; - uint32 Scorpions_Timer; - int Rand; - int RandX; - int RandY; - - Creature* Summoned; - - void Reset() - { - TwinReset(); - ShadowBolt_Timer = 0; - Blizzard_Timer = 15000 + rand()%5000;; - ArcaneBurst_Timer = 1000; - Scorpions_Timer = 7000 + rand()%7000; - - //Added. Can be removed if its included in DB. - m_creature->ApplySpellImmune(0, IMMUNITY_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, true); - m_creature->SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, 0); - m_creature->SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, 0); - } - - void CastSpellOnBug(Creature *target) - { - target->setFaction(14); - SpellEntry *spell = (SpellEntry *)GetSpellStore()->LookupEntry(SPELL_EXPLODEBUG); - for (int i=0; i<3; i++) - { - if (!spell->Effect[i]) - continue; - target->AddAura(new BugAura(spell, i, NULL, target, target)); - } - target->SetHealth(target->GetMaxHealth()); - } - - void UpdateAI(const uint32 diff) - { - //Return since we have no target - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - // reset arcane burst after teleport - we need to do this because - // when VL jumps to VN's location there will be a warrior who will get only 2s to run away - // which is almost impossible - if (AfterTeleport) - ArcaneBurst_Timer = 5000; - if (!TryActivateAfterTTelep(diff)) - return; - - //ShadowBolt_Timer - if (ShadowBolt_Timer < diff) - { - if (m_creature->GetDistance(m_creature->getVictim()) > 45) - m_creature->GetMotionMaster()->MoveChase(m_creature->getVictim(), VEKLOR_DIST, 0); - else - DoCast(m_creature->getVictim(),SPELL_SHADOWBOLT); - ShadowBolt_Timer = 2000; - }else ShadowBolt_Timer -= diff; - - //Blizzard_Timer - if (Blizzard_Timer < diff) - { - Unit* target = NULL; - target = GetAnyoneCloseEnough(45, true); - if (target) - DoCast(target,SPELL_BLIZZARD); - Blizzard_Timer = 15000+rand()%15000; - }else Blizzard_Timer -= diff; - - if (ArcaneBurst_Timer < diff) - { - Unit *mvic; - if ((mvic=GetAnyoneCloseEnough(ATTACK_DISTANCE, false))!=NULL) - { - DoCast(mvic,SPELL_ARCANEBURST); - ArcaneBurst_Timer = 5000; - } - }else ArcaneBurst_Timer -= diff; - - HandleBugs(diff); - - //Heal brother when 60yrds close - TryHealBrother(diff); - - //Teleporting to brother - if(Teleport_Timer < diff) - { - TeleportToMyBrother(); - }else Teleport_Timer -= diff; - - CheckEnrage(diff); - - //VL doesn't melee - //DoMeleeAttackIfReady(); - } - - void AttackStart(Unit* who) - { - if (!who) - return; - - if (who->isTargetableForAttack()) - { - // VL doesn't melee - if ( m_creature->Attack(who, false) ) - { - m_creature->GetMotionMaster()->MoveChase(who, VEKLOR_DIST, 0); - m_creature->AddThreat(who, 0.0f); - } - - if (!InCombat) - { - Aggro(who); - InCombat = true; - } - } - } -}; - -CreatureAI* GetAI_boss_veknilash(Creature *_Creature) -{ - return new boss_veknilashAI (_Creature); -} - -CreatureAI* GetAI_boss_veklor(Creature *_Creature) -{ - return new boss_veklorAI (_Creature); -} - -void AddSC_boss_twinemperors() -{ - Script *newscript; - - newscript = new Script; - newscript->Name="boss_veknilash"; - newscript->GetAI = GetAI_boss_veknilash; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="boss_veklor"; - newscript->GetAI = GetAI_boss_veklor; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Twinemperors +SD%Complete: 95 +SDComment: +SDCategory: Temple of Ahn'Qiraj +EndScriptData */ + +#include "precompiled.h" +#include "def_temple_of_ahnqiraj.h" +#include "WorldPacket.h" + +#include "Item.h" +#include "Spell.h" + +#define SPELL_HEAL_BROTHER 7393 +#define SPELL_TWIN_TELEPORT 800 // CTRA watches for this spell to start its teleport timer +#define SPELL_TWIN_TELEPORT_VISUAL 26638 // visual + +#define SPELL_EXPLODEBUG 804 +#define SPELL_MUTATE_BUG 802 + +#define SOUND_VN_DEATH 8660 //8660 - Death - Feel +#define SOUND_VN_AGGRO 8661 //8661 - Aggro - Let none +#define SOUND_VN_KILL 8662 //8661 - Kill - your fate + +#define SOUND_VL_AGGRO 8657 //8657 - Aggro - To Late +#define SOUND_VL_KILL 8658 //8658 - Kill - You will not +#define SOUND_VL_DEATH 8659 //8659 - Death + +#define PULL_RANGE 50 +#define ABUSE_BUG_RANGE 20 +#define SPELL_BERSERK 26662 +#define TELEPORTTIME 30000 + +#define SPELL_UPPERCUT 26007 +#define SPELL_UNBALANCING_STRIKE 26613 + +#define VEKLOR_DIST 20 // VL will not come to melee when attacking + +#define SPELL_SHADOWBOLT 26006 +#define SPELL_BLIZZARD 26607 +#define SPELL_ARCANEBURST 568 + +struct MANGOS_DLL_DECL boss_twinemperorsAI : public ScriptedAI +{ + ScriptedInstance *pInstance; + uint32 Heal_Timer; + uint32 Teleport_Timer; + bool AfterTeleport; + uint32 AfterTeleportTimer; + bool DontYellWhenDead; + uint32 Abuse_Bug_Timer, BugsTimer; + bool tspellcasted; + uint32 EnrageTimer; + + virtual bool IAmVeklor() = 0; + virtual void Reset() = 0; + virtual void CastSpellOnBug(Creature *target) = 0; + + boss_twinemperorsAI(Creature *c): ScriptedAI(c) + { + pInstance = ((ScriptedInstance*)c->GetInstanceData()); + } + + void TwinReset() + { + Heal_Timer = 0; // first heal immediately when they get close together + Teleport_Timer = TELEPORTTIME; + AfterTeleport = false; + tspellcasted = false; + AfterTeleportTimer = 0; + Abuse_Bug_Timer = 10000 + rand()%7000; + BugsTimer = 2000; + m_creature->clearUnitState(UNIT_STAT_STUNDED); + DontYellWhenDead = false; + EnrageTimer = 15*60000; + } + + Creature *GetOtherBoss() + { + if(pInstance) + { + return (Creature *)Unit::GetUnit((*m_creature), pInstance->GetData64(IAmVeklor() ? DATA_VEKNILASH : DATA_VEKLOR)); + } + else + { + return (Creature *)0; + } + } + + void DamageTaken(Unit *done_by, uint32 &damage) + { + Unit *pOtherBoss = GetOtherBoss(); + if (pOtherBoss) + { + float dPercent = ((float)damage) / ((float)m_creature->GetMaxHealth()); + int odmg = (int)(dPercent * ((float)pOtherBoss->GetMaxHealth())); + int ohealth = pOtherBoss->GetHealth()-odmg; + pOtherBoss->SetHealth(ohealth > 0 ? ohealth : 0); + if (ohealth <= 0) + { + pOtherBoss->setDeathState(JUST_DIED); + pOtherBoss->SetUInt32Value(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE); + } + } + } + + void JustDied(Unit* Killer) + { + Creature *pOtherBoss = GetOtherBoss(); + if (pOtherBoss) + { + pOtherBoss->SetHealth(0); + pOtherBoss->setDeathState(JUST_DIED); + pOtherBoss->SetUInt32Value(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE); + ((boss_twinemperorsAI *)pOtherBoss->AI())->DontYellWhenDead = true; + } + if (!DontYellWhenDead) // I hope AI is not threaded + DoPlaySoundToSet(m_creature, IAmVeklor() ? SOUND_VL_DEATH : SOUND_VN_DEATH); + } + + void KilledUnit(Unit* victim) + { + DoPlaySoundToSet(m_creature, IAmVeklor() ? SOUND_VL_KILL : SOUND_VN_KILL); + } + + void Aggro(Unit *who) + { + DoZoneInCombat(); + InCombat = true; + Creature *pOtherBoss = GetOtherBoss(); + if (pOtherBoss) + { + // TODO: we should activate the other boss location so he can start attackning even if nobody + // is near I dont know how to do that + ScriptedAI *otherAI = (ScriptedAI*)pOtherBoss->AI(); + if (!otherAI->InCombat) + { + DoPlaySoundToSet(m_creature, IAmVeklor() ? SOUND_VL_AGGRO : SOUND_VN_AGGRO); + otherAI->AttackStart(who); + otherAI->DoZoneInCombat(); + } + } + } + + void SpellHit(Unit *caster, const SpellEntry *entry) + { + if (caster == m_creature) + return; + + Creature *pOtherBoss = GetOtherBoss(); + if (entry->Id != SPELL_HEAL_BROTHER || !pOtherBoss) + return; + + // add health so we keep same percentage for both brothers + uint32 mytotal = m_creature->GetMaxHealth(), histotal = pOtherBoss->GetMaxHealth(); + float mult = ((float)mytotal) / ((float)histotal); + if (mult < 1) + mult = 1.0f/mult; + #define HEAL_BROTHER_AMOUNT 30000.0f + uint32 largerAmount = (uint32)((HEAL_BROTHER_AMOUNT * mult) - HEAL_BROTHER_AMOUNT); + + uint32 myh = m_creature->GetHealth(); + uint32 hish = pOtherBoss->GetHealth(); + if (mytotal > histotal) + { + uint32 h = m_creature->GetHealth()+largerAmount; + m_creature->SetHealth(std::min(mytotal, h)); + } + else + { + uint32 h = pOtherBoss->GetHealth()+largerAmount; + pOtherBoss->SetHealth(std::min(histotal, h)); + } + } + + void TryHealBrother(uint32 diff) + { + if (IAmVeklor()) // this spell heals caster and the other brother so let VN cast it + return; + + if (Heal_Timer < diff) + { + Unit *pOtherBoss = GetOtherBoss(); + if (pOtherBoss && (pOtherBoss->GetDistance((const Creature *)m_creature) <= 60)) + { + DoCast(pOtherBoss, SPELL_HEAL_BROTHER); + Heal_Timer = 1000; + } + } else Heal_Timer -= diff; + } + + Unit *GetAnyoneCloseEnough(float dist, bool totallyRandom) + { + int cnt = 0; + std::list::iterator i; + std::list candidates; + + for (i = m_creature->getThreatManager().getThreatList().begin();i != m_creature->getThreatManager().getThreatList().end(); ++i) + { + Unit* pUnit = Unit::GetUnit((*m_creature), (*i)->getUnitGuid()); + if (m_creature->IsWithinDistInMap(pUnit, dist)) + { + if (!totallyRandom) + return pUnit; + candidates.push_back((*i)); + cnt ++; + } + } + if (!cnt) + return NULL; + for (int randomi = rand() % cnt; randomi > 0; randomi --) + candidates.pop_front(); + + i = candidates.begin(); + Unit *ret = Unit::GetUnit((*m_creature), (*i)->getUnitGuid()); + candidates.clear(); + return ret; + } + + Unit *PickNearestPlayer() + { + Unit *nearp = NULL; + float neardist = 0.0f; + std::list::iterator i; + for (i = m_creature->getThreatManager().getThreatList().begin();i != m_creature->getThreatManager().getThreatList().end(); ++i) + { + Unit* pUnit = NULL; + pUnit = Unit::GetUnit((*m_creature), (*i)->getUnitGuid()); + if (!pUnit) + continue; + float pudist = pUnit->GetDistance((const Creature *)m_creature); + if (!nearp || (neardist > pudist)) + { + nearp = pUnit; + neardist = pudist; + } + } + return nearp; + } + + void TeleportToMyBrother() + { + if (!pInstance) + return; + + Teleport_Timer = TELEPORTTIME; + + if(IAmVeklor()) + return; // mechanics handled by veknilash so they teleport exactly at the same time and to correct coordinates + + Creature *pOtherBoss = GetOtherBoss(); + if (pOtherBoss) + { + //m_creature->MonsterYell("Teleporting ...", LANG_UNIVERSAL, 0); + float other_x = pOtherBoss->GetPositionX(); + float other_y = pOtherBoss->GetPositionY(); + float other_z = pOtherBoss->GetPositionZ(); + float other_o = pOtherBoss->GetOrientation(); + + Map *thismap = m_creature->GetMap(); + thismap->CreatureRelocation(pOtherBoss, m_creature->GetPositionX(), + m_creature->GetPositionY(), m_creature->GetPositionZ(), m_creature->GetOrientation()); + thismap->CreatureRelocation(m_creature, other_x, other_y, other_z, other_o); + + SetAfterTeleport(); + ((boss_twinemperorsAI*) pOtherBoss->AI())->SetAfterTeleport(); + } + } + + void SetAfterTeleport() + { + m_creature->InterruptNonMeleeSpells(false); + DoStopAttack(); + DoResetThreat(); + DoCast(m_creature, SPELL_TWIN_TELEPORT_VISUAL); + m_creature->addUnitState(UNIT_STAT_STUNDED); + AfterTeleport = true; + AfterTeleportTimer = 2000; + tspellcasted = false; + } + + bool TryActivateAfterTTelep(uint32 diff) + { + if (AfterTeleport) + { + if (!tspellcasted) + { + m_creature->clearUnitState(UNIT_STAT_STUNDED); + DoCast(m_creature, SPELL_TWIN_TELEPORT); + m_creature->addUnitState(UNIT_STAT_STUNDED); + } + + tspellcasted = true; + + if (AfterTeleportTimer < diff) + { + AfterTeleport = false; + m_creature->clearUnitState(UNIT_STAT_STUNDED); + Unit *nearu = PickNearestPlayer(); + //DoYell(nearu->GetName(), LANG_UNIVERSAL, 0); + AttackStart(nearu); + m_creature->getThreatManager().addThreat(nearu, 10000); + return true; + } + else + { + AfterTeleportTimer -= diff; + // update important timers which would otherwise get skipped + if (EnrageTimer > diff) + EnrageTimer -= diff; + else + EnrageTimer = 0; + if (Teleport_Timer > diff) + Teleport_Timer -= diff; + else + Teleport_Timer = 0; + return false; + } + } + else + { + return true; + } + } + + void MoveInLineOfSight(Unit *who) + { + if (!who || m_creature->getVictim()) + return; + + if (who->isTargetableForAttack() && who->isInAccessablePlaceFor(m_creature) && m_creature->IsHostileTo(who)) + { + float attackRadius = m_creature->GetAttackDistance(who); + if (attackRadius < PULL_RANGE) + attackRadius = PULL_RANGE; + if (m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->GetDistanceZ(who) <= /*CREATURE_Z_ATTACK_RANGE*/7 /*there are stairs*/) + { + if(who->HasStealthAura()) + who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); + AttackStart(who); + } + } + } + + class AnyBugCheck + { + public: + AnyBugCheck(WorldObject const* obj, float range) : i_obj(obj), i_range(range) {} + bool operator()(Unit* u) + { + Creature *c = (Creature *)u; + if (!i_obj->IsWithinDistInMap(c, i_range)) + return false; + return (c->GetEntry() == 15316 || c->GetEntry() == 15317); + } + private: + WorldObject const* i_obj; + float i_range; + }; + + Creature *RespawnNearbyBugsAndGetOne() + { + CellPair p(MaNGOS::ComputeCellPair(m_creature->GetPositionX(), m_creature->GetPositionY())); + Cell cell(p); + cell.data.Part.reserved = ALL_DISTRICT; + cell.SetNoCreate(); + + std::list unitList; + + AnyBugCheck u_check(m_creature, 150); + MaNGOS::CreatureListSearcher searcher(unitList, u_check); + TypeContainerVisitor, GridTypeMapContainer > grid_creature_searcher(searcher); + CellLock cell_lock(cell, p); + cell_lock->Visit(cell_lock, grid_creature_searcher, *(m_creature->GetMap())); + + Creature *nearb = NULL; + + for(std::list::iterator iter = unitList.begin(); iter != unitList.end(); ++iter) + { + Creature *c = (Creature *)(*iter); + if (c->isDead()) + { + c->Respawn(); + c->setFaction(7); + c->RemoveAllAuras(); + } + if (c->IsWithinDistInMap(m_creature, ABUSE_BUG_RANGE)) + { + if (!nearb || (rand()%4)==0) + nearb = c; + } + } + return nearb; + } + + void HandleBugs(uint32 diff) + { + if (BugsTimer < diff || Abuse_Bug_Timer < diff) + { + Creature *c = RespawnNearbyBugsAndGetOne(); + if (Abuse_Bug_Timer < diff) + { + if (c) + { + CastSpellOnBug(c); + Abuse_Bug_Timer = 10000 + rand()%7000; + } + else + { + Abuse_Bug_Timer = 1000; + } + } + else + { + Abuse_Bug_Timer -= diff; + } + BugsTimer = 2000; + } + else + { + BugsTimer -= diff; + Abuse_Bug_Timer -= diff; + } + } + + void CheckEnrage(uint32 diff) + { + if (EnrageTimer < diff) + { + if (!m_creature->IsNonMeleeSpellCasted(true)) + { + DoCast(m_creature, SPELL_BERSERK); + EnrageTimer = 60*60000; + } else EnrageTimer = 0; + } else EnrageTimer-=diff; + } +}; + +class MANGOS_DLL_DECL BugAura : public Aura +{ + public: + BugAura(SpellEntry *spell, uint32 eff, int32 *bp, Unit *target, Unit *caster) : Aura(spell, eff, bp, target, caster, NULL) + {} +}; + +struct MANGOS_DLL_DECL boss_veknilashAI : public boss_twinemperorsAI +{ + bool IAmVeklor() {return false;} + boss_veknilashAI(Creature *c) : boss_twinemperorsAI(c) + { + Reset(); + } + + uint32 UpperCut_Timer; + uint32 UnbalancingStrike_Timer; + uint32 Scarabs_Timer; + int Rand; + int RandX; + int RandY; + + Creature* Summoned; + + void Reset() + { + TwinReset(); + UpperCut_Timer = 14000 + rand()%15000; + UnbalancingStrike_Timer = 8000 + rand()%10000; + Scarabs_Timer = 7000 + rand()%7000; + + //Added. Can be removed if its included in DB. + m_creature->ApplySpellImmune(0, IMMUNITY_DAMAGE, SPELL_SCHOOL_MASK_MAGIC, true); + } + + void CastSpellOnBug(Creature *target) + { + target->setFaction(14); + ((CreatureAI*)target->AI())->AttackStart(m_creature->getThreatManager().getHostilTarget()); + SpellEntry *spell = (SpellEntry *)GetSpellStore()->LookupEntry(SPELL_MUTATE_BUG); + for (int i=0; i<3; i++) + { + if (!spell->Effect[i]) + continue; + target->AddAura(new BugAura(spell, i, NULL, target, target)); + } + target->SetHealth(target->GetMaxHealth()); + } + + void UpdateAI(const uint32 diff) + { + //Return since we have no target + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + if (!TryActivateAfterTTelep(diff)) + return; + + //UnbalancingStrike_Timer + if (UnbalancingStrike_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_UNBALANCING_STRIKE); + UnbalancingStrike_Timer = 8000+rand()%12000; + }else UnbalancingStrike_Timer -= diff; + + if (UpperCut_Timer < diff) + { + Unit* randomMelee = GetAnyoneCloseEnough(ATTACK_DISTANCE, true); + if (randomMelee) + DoCast(randomMelee,SPELL_UPPERCUT); + UpperCut_Timer = 15000+rand()%15000; + }else UpperCut_Timer -= diff; + + HandleBugs(diff); + + //Heal brother when 60yrds close + TryHealBrother(diff); + + //Teleporting to brother + if(Teleport_Timer < diff) + { + TeleportToMyBrother(); + }else Teleport_Timer -= diff; + + CheckEnrage(diff); + + DoMeleeAttackIfReady(); + } +}; + +struct MANGOS_DLL_DECL boss_veklorAI : public boss_twinemperorsAI +{ + bool IAmVeklor() {return true;} + boss_veklorAI(Creature *c) : boss_twinemperorsAI(c) + { + Reset(); + } + + uint32 ShadowBolt_Timer; + uint32 Blizzard_Timer; + uint32 ArcaneBurst_Timer; + uint32 Scorpions_Timer; + int Rand; + int RandX; + int RandY; + + Creature* Summoned; + + void Reset() + { + TwinReset(); + ShadowBolt_Timer = 0; + Blizzard_Timer = 15000 + rand()%5000;; + ArcaneBurst_Timer = 1000; + Scorpions_Timer = 7000 + rand()%7000; + + //Added. Can be removed if its included in DB. + m_creature->ApplySpellImmune(0, IMMUNITY_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, true); + m_creature->SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, 0); + m_creature->SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, 0); + } + + void CastSpellOnBug(Creature *target) + { + target->setFaction(14); + SpellEntry *spell = (SpellEntry *)GetSpellStore()->LookupEntry(SPELL_EXPLODEBUG); + for (int i=0; i<3; i++) + { + if (!spell->Effect[i]) + continue; + target->AddAura(new BugAura(spell, i, NULL, target, target)); + } + target->SetHealth(target->GetMaxHealth()); + } + + void UpdateAI(const uint32 diff) + { + //Return since we have no target + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + // reset arcane burst after teleport - we need to do this because + // when VL jumps to VN's location there will be a warrior who will get only 2s to run away + // which is almost impossible + if (AfterTeleport) + ArcaneBurst_Timer = 5000; + if (!TryActivateAfterTTelep(diff)) + return; + + //ShadowBolt_Timer + if (ShadowBolt_Timer < diff) + { + if (m_creature->GetDistance(m_creature->getVictim()) > 45) + m_creature->GetMotionMaster()->MoveChase(m_creature->getVictim(), VEKLOR_DIST, 0); + else + DoCast(m_creature->getVictim(),SPELL_SHADOWBOLT); + ShadowBolt_Timer = 2000; + }else ShadowBolt_Timer -= diff; + + //Blizzard_Timer + if (Blizzard_Timer < diff) + { + Unit* target = NULL; + target = GetAnyoneCloseEnough(45, true); + if (target) + DoCast(target,SPELL_BLIZZARD); + Blizzard_Timer = 15000+rand()%15000; + }else Blizzard_Timer -= diff; + + if (ArcaneBurst_Timer < diff) + { + Unit *mvic; + if ((mvic=GetAnyoneCloseEnough(ATTACK_DISTANCE, false))!=NULL) + { + DoCast(mvic,SPELL_ARCANEBURST); + ArcaneBurst_Timer = 5000; + } + }else ArcaneBurst_Timer -= diff; + + HandleBugs(diff); + + //Heal brother when 60yrds close + TryHealBrother(diff); + + //Teleporting to brother + if(Teleport_Timer < diff) + { + TeleportToMyBrother(); + }else Teleport_Timer -= diff; + + CheckEnrage(diff); + + //VL doesn't melee + //DoMeleeAttackIfReady(); + } + + void AttackStart(Unit* who) + { + if (!who) + return; + + if (who->isTargetableForAttack()) + { + // VL doesn't melee + if ( m_creature->Attack(who, false) ) + { + m_creature->GetMotionMaster()->MoveChase(who, VEKLOR_DIST, 0); + m_creature->AddThreat(who, 0.0f); + } + + if (!InCombat) + { + Aggro(who); + InCombat = true; + } + } + } +}; + +CreatureAI* GetAI_boss_veknilash(Creature *_Creature) +{ + return new boss_veknilashAI (_Creature); +} + +CreatureAI* GetAI_boss_veklor(Creature *_Creature) +{ + return new boss_veklorAI (_Creature); +} + +void AddSC_boss_twinemperors() +{ + Script *newscript; + + newscript = new Script; + newscript->Name="boss_veknilash"; + newscript->GetAI = GetAI_boss_veknilash; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="boss_veklor"; + newscript->GetAI = GetAI_boss_veklor; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/boss_viscidus.cpp b/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/boss_viscidus.cpp index 36a8bfea1c1..28d1d7ba963 100644 --- a/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/boss_viscidus.cpp +++ b/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/boss_viscidus.cpp @@ -1,29 +1,29 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Viscidus -SD%Complete: 0 -SDComment: place holder -SDCategory: Temple of Ahn'Qiraj -EndScriptData */ - -#include "precompiled.h" - -#define SPELL_POISON_SHOCK 25993 -#define SPELL_POISONBOLT_VOLLEY 25991 - -#define SPELL_TOXIN_CLOUD 25989 +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Viscidus +SD%Complete: 0 +SDComment: place holder +SDCategory: Temple of Ahn'Qiraj +EndScriptData */ + +#include "precompiled.h" + +#define SPELL_POISON_SHOCK 25993 +#define SPELL_POISONBOLT_VOLLEY 25991 + +#define SPELL_TOXIN_CLOUD 25989 diff --git a/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/def_temple_of_ahnqiraj.h b/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/def_temple_of_ahnqiraj.h index fdc6d30a0cb..935a1587c2a 100644 --- a/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/def_temple_of_ahnqiraj.h +++ b/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/def_temple_of_ahnqiraj.h @@ -1,22 +1,22 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software licensed under GPL version 2 - * Please see the included DOCS/LICENSE.TXT for more information */ - -#ifndef DEF_TEMPLE_OF_AHNQIRAJ_H -#define DEF_TEMPLE_OF_AHNQIRAJ_H - -#define DATA_SKERAM 1 -#define DATA_KRI 2 -#define DATA_VEM 3 -#define DATA_VEMISDEAD 4 -#define DATA_VEM_DEATH 5 -#define DATA_VEKLOR 6 -#define DATA_VEKLORISDEAD 7 -#define DATA_VEKLOR_DEATH 8 -#define DATA_VEKNILASH 9 -#define DATA_VEKNILASHISDEAD 10 -#define DATA_VEKNILASH_DEATH 11 -#define DATA_BUG_TRIO_DEATH 14 - -#define DATA_CTHUN_PHASE 20 -#endif +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software licensed under GPL version 2 + * Please see the included DOCS/LICENSE.TXT for more information */ + +#ifndef DEF_TEMPLE_OF_AHNQIRAJ_H +#define DEF_TEMPLE_OF_AHNQIRAJ_H + +#define DATA_SKERAM 1 +#define DATA_KRI 2 +#define DATA_VEM 3 +#define DATA_VEMISDEAD 4 +#define DATA_VEM_DEATH 5 +#define DATA_VEKLOR 6 +#define DATA_VEKLORISDEAD 7 +#define DATA_VEKLOR_DEATH 8 +#define DATA_VEKNILASH 9 +#define DATA_VEKNILASHISDEAD 10 +#define DATA_VEKNILASH_DEATH 11 +#define DATA_BUG_TRIO_DEATH 14 + +#define DATA_CTHUN_PHASE 20 +#endif diff --git a/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/instance_temple_of_ahnqiraj.cpp b/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/instance_temple_of_ahnqiraj.cpp index 724a64e2baa..933550b07c3 100644 --- a/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/instance_temple_of_ahnqiraj.cpp +++ b/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/instance_temple_of_ahnqiraj.cpp @@ -1,165 +1,165 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Instance_Temple_of_Ahnqiraj -SD%Complete: 80 -SDComment: -SDCategory: Temple of Ahn'Qiraj -EndScriptData */ - -#include "precompiled.h" -#include "def_temple_of_ahnqiraj.h" - -struct MANGOS_DLL_DECL instance_temple_of_ahnqiraj : public ScriptedInstance -{ - instance_temple_of_ahnqiraj(Map *Map) : ScriptedInstance(Map) {Initialize();}; - - //If Vem is dead... - bool IsBossDied[3]; - - //Storing Skeram, Vem and Kri. - uint64 SkeramGUID; - uint64 VemGUID; - uint64 KriGUID; - uint64 VeklorGUID; - uint64 VeknilashGUID; - - uint32 BugTrioDeathCount; - - uint32 CthunPhase; - - void Initialize() - { - IsBossDied[0] = false; - IsBossDied[1] = false; - IsBossDied[2] = false; - - SkeramGUID = 0; - VemGUID = 0; - KriGUID = 0; - VeklorGUID = 0; - VeknilashGUID = 0; - - BugTrioDeathCount = 0; - - CthunPhase = 0; - } - - void OnCreatureCreate (Creature *creature, uint32 creature_entry) - { - switch (creature_entry) - { - case 15263: SkeramGUID = creature->GetGUID(); break; - case 15544: VemGUID = creature->GetGUID(); break; - case 15511: KriGUID = creature->GetGUID(); break; - case 15276: VeklorGUID = creature->GetGUID(); break; - case 15275: VeknilashGUID = creature->GetGUID(); break; - } - } - - bool IsEncounterInProgress() const - { - //not active in AQ40 - return false; - } - - uint32 GetData(uint32 type) - { - switch(type) - { - case DATA_VEMISDEAD: - if(IsBossDied[0]) - return 1; - break; - - case DATA_VEKLORISDEAD: - if(IsBossDied[1]) - return 1; - break; - - case DATA_VEKNILASHISDEAD: - if(IsBossDied[2]) - return 1; - break; - - case DATA_BUG_TRIO_DEATH: - return BugTrioDeathCount; - - case DATA_CTHUN_PHASE: - return CthunPhase; - } - return 0; - } - - uint64 GetData64 (uint32 identifier) - { - switch(identifier) - { - case DATA_SKERAM: - return SkeramGUID; - case DATA_VEM: - return VemGUID; - case DATA_KRI: - return KriGUID; - case DATA_VEKLOR: - return VeklorGUID; - case DATA_VEKNILASH: - return VeknilashGUID; - } - return 0; - } // end GetData64 - - void SetData(uint32 type, uint32 data) - { - switch(type) - { - case DATA_VEM_DEATH: - IsBossDied[0] = true; - break; - - case DATA_BUG_TRIO_DEATH: - BugTrioDeathCount++; - break; - - case DATA_VEKLOR_DEATH: - IsBossDied[1] = true; - break; - - case DATA_VEKNILASH_DEATH: - IsBossDied[2] = true; - break; - - case DATA_CTHUN_PHASE: - CthunPhase = data; - break; - } - } -}; - -InstanceData* GetInstanceData_instance_temple_of_ahnqiraj(Map* map) -{ - return new instance_temple_of_ahnqiraj(map); -} - -void AddSC_instance_temple_of_ahnqiraj() -{ - Script *newscript; - newscript = new Script; - newscript->Name = "instance_temple_of_ahnqiraj"; - newscript->GetInstanceData = GetInstanceData_instance_temple_of_ahnqiraj; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Instance_Temple_of_Ahnqiraj +SD%Complete: 80 +SDComment: +SDCategory: Temple of Ahn'Qiraj +EndScriptData */ + +#include "precompiled.h" +#include "def_temple_of_ahnqiraj.h" + +struct MANGOS_DLL_DECL instance_temple_of_ahnqiraj : public ScriptedInstance +{ + instance_temple_of_ahnqiraj(Map *Map) : ScriptedInstance(Map) {Initialize();}; + + //If Vem is dead... + bool IsBossDied[3]; + + //Storing Skeram, Vem and Kri. + uint64 SkeramGUID; + uint64 VemGUID; + uint64 KriGUID; + uint64 VeklorGUID; + uint64 VeknilashGUID; + + uint32 BugTrioDeathCount; + + uint32 CthunPhase; + + void Initialize() + { + IsBossDied[0] = false; + IsBossDied[1] = false; + IsBossDied[2] = false; + + SkeramGUID = 0; + VemGUID = 0; + KriGUID = 0; + VeklorGUID = 0; + VeknilashGUID = 0; + + BugTrioDeathCount = 0; + + CthunPhase = 0; + } + + void OnCreatureCreate (Creature *creature, uint32 creature_entry) + { + switch (creature_entry) + { + case 15263: SkeramGUID = creature->GetGUID(); break; + case 15544: VemGUID = creature->GetGUID(); break; + case 15511: KriGUID = creature->GetGUID(); break; + case 15276: VeklorGUID = creature->GetGUID(); break; + case 15275: VeknilashGUID = creature->GetGUID(); break; + } + } + + bool IsEncounterInProgress() const + { + //not active in AQ40 + return false; + } + + uint32 GetData(uint32 type) + { + switch(type) + { + case DATA_VEMISDEAD: + if(IsBossDied[0]) + return 1; + break; + + case DATA_VEKLORISDEAD: + if(IsBossDied[1]) + return 1; + break; + + case DATA_VEKNILASHISDEAD: + if(IsBossDied[2]) + return 1; + break; + + case DATA_BUG_TRIO_DEATH: + return BugTrioDeathCount; + + case DATA_CTHUN_PHASE: + return CthunPhase; + } + return 0; + } + + uint64 GetData64 (uint32 identifier) + { + switch(identifier) + { + case DATA_SKERAM: + return SkeramGUID; + case DATA_VEM: + return VemGUID; + case DATA_KRI: + return KriGUID; + case DATA_VEKLOR: + return VeklorGUID; + case DATA_VEKNILASH: + return VeknilashGUID; + } + return 0; + } // end GetData64 + + void SetData(uint32 type, uint32 data) + { + switch(type) + { + case DATA_VEM_DEATH: + IsBossDied[0] = true; + break; + + case DATA_BUG_TRIO_DEATH: + BugTrioDeathCount++; + break; + + case DATA_VEKLOR_DEATH: + IsBossDied[1] = true; + break; + + case DATA_VEKNILASH_DEATH: + IsBossDied[2] = true; + break; + + case DATA_CTHUN_PHASE: + CthunPhase = data; + break; + } + } +}; + +InstanceData* GetInstanceData_instance_temple_of_ahnqiraj(Map* map) +{ + return new instance_temple_of_ahnqiraj(map); +} + +void AddSC_instance_temple_of_ahnqiraj() +{ + Script *newscript; + newscript = new Script; + newscript->Name = "instance_temple_of_ahnqiraj"; + newscript->GetInstanceData = GetInstanceData_instance_temple_of_ahnqiraj; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/mob_anubisath_sentinel.cpp b/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/mob_anubisath_sentinel.cpp index 62c21978adf..5f6e4f0ef44 100644 --- a/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/mob_anubisath_sentinel.cpp +++ b/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/mob_anubisath_sentinel.cpp @@ -1,344 +1,344 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: mob_anubisath_sentinel -SD%Complete: 95 -SDComment: Shadow storm is not properly implemented in core it should only target ppl outside of melee range. -SDCategory: Temple of Ahn'Qiraj -EndScriptData */ - -#include "precompiled.h" -#include "WorldPacket.h" - -#include "Item.h" -#include "Player.h" -#include "Spell.h" - -#include "Cell.h" -#include "CellImpl.h" -#include "GridNotifiers.h" -#include "GridNotifiersImpl.h" - -#define SPELL_MENDING_BUFF 2147 - -#define SPELL_KNOCK_BUFF 21737 -#define SPELL_KNOCK 25778 -#define SPELL_MANAB_BUFF 812 -#define SPELL_MANAB 25779 - -#define SPELL_REFLECTAF_BUFF 13022 -#define SPELL_REFLECTSFr_BUFF 19595 -#define SPELL_THORNS_BUFF 25777 - -#define SPELL_THUNDER_BUFF 2834 -#define SPELL_THUNDER 8732 - -#define SPELL_MSTRIKE_BUFF 9347 -#define SPELL_MSTRIKE 24573 - -#define SPELL_STORM_BUFF 2148 -#define SPELL_STORM 26546 - -class NearbyAQSentinel -{ - public: - NearbyAQSentinel(Unit const* obj) : i_obj(obj) {} - bool operator()(Unit* u) - { - if (u->GetEntry() == 15264 && i_obj->IsWithinDistInMap(u, 70) && !u->isDead()) - return true; - else - return false; - } - private: - Unit const* i_obj; -}; - -struct MANGOS_DLL_DECL aqsentinelAI; -class MANGOS_DLL_DECL SentinelAbilityAura : public Aura -{ - public: - ~SentinelAbilityAura(); - Unit* GetTriggerTarget() const; - SentinelAbilityAura(aqsentinelAI *abilityOwner, SpellEntry *spell, uint32 ability, uint32 eff); - protected: - aqsentinelAI *aOwner; - int32 currentBasePoints; - uint32 abilityId; -}; - -struct MANGOS_DLL_DECL aqsentinelAI : public ScriptedAI -{ - uint32 ability; - int abselected; - - void selectAbility(int asel) - { - switch (asel) - { - case 0: ability = SPELL_MENDING_BUFF;break; - case 1: ability = SPELL_KNOCK_BUFF;break; - case 2: ability = SPELL_MANAB_BUFF;break; - case 3: ability = SPELL_REFLECTAF_BUFF;break; - case 4: ability = SPELL_REFLECTSFr_BUFF;break; - case 5: ability = SPELL_THORNS_BUFF;break; - case 6: ability = SPELL_THUNDER_BUFF;break; - case 7: ability = SPELL_MSTRIKE_BUFF;break; - case 8: ability = SPELL_STORM_BUFF;break; - } - } - - aqsentinelAI(Creature *c) : ScriptedAI(c) - { - ClearBudyList(); - abselected = 0; // just initialization of variable - Reset(); - } - - Creature *nearby[3]; - - void ClearBudyList() - { - nearby[0] = nearby[1] = nearby[2] = NULL; - } - - void AddBuddyToList(Creature *c) - { - if (c==m_creature) - return; - for (int i=0; i<3; i++) - { - if (nearby[i] == c) - return; - if (!nearby[i]) - { - nearby[i] = c; - return; - } - } - } - - void GiveBuddyMyList(Creature *c) - { - aqsentinelAI *cai = (aqsentinelAI *)(c->AI()); - for (int i=0; i<3; i++) - if (nearby[i] && nearby[i]!=c) - cai->AddBuddyToList(nearby[i]); - cai->AddBuddyToList(m_creature); - } - - void SendMyListToBuddies() - { - for (int i=0; i<3; i++) - if (nearby[i]) - GiveBuddyMyList(nearby[i]); - } - - void CallBuddiesToAttack(Unit *who) - { - for (int i=0; i<3; i++) - { - Creature *c = nearby[i]; - if (c) - { - if (!c->isInCombat()) - { - c->SetNoCallAssistence(true); - if(c->AI()) - c->AI()->AttackStart(who); - } - } - } - } - - void AddSentinelsNear(Unit *nears) - { - CellPair p(MaNGOS::ComputeCellPair(nears->GetPositionX(), nears->GetPositionY())); - Cell cell(p); - cell.data.Part.reserved = ALL_DISTRICT; - cell.SetNoCreate(); - - std::list assistList; - - NearbyAQSentinel u_check(nears); - MaNGOS::CreatureListSearcher searcher(assistList, u_check); - TypeContainerVisitor, GridTypeMapContainer > grid_creature_searcher(searcher); - CellLock cell_lock(cell, p); - cell_lock->Visit(cell_lock, grid_creature_searcher, *(nears->GetMap())); - - for(std::list::iterator iter = assistList.begin(); iter != assistList.end(); ++iter) - AddBuddyToList((*iter)); - } - - int pickAbilityRandom(bool *chosenAbilities) - { - for (int t = 0; t < 2; t++) - { - for (int i = !t ? (rand()%9) : 0; i < 9; i++) - { - if (!chosenAbilities[i]) - { - chosenAbilities[i] = true; - return i; - } - } - } - return 0; // should never happen - } - - void GetOtherSentinels(Unit *who) - { - bool *chosenAbilities = new bool[9]; - memset(chosenAbilities, 0, 9*sizeof(bool)); - selectAbility(pickAbilityRandom(chosenAbilities)); - - ClearBudyList(); - AddSentinelsNear(m_creature); - int bli; - for (bli = 0; bli < 3;bli++) - { - if (!nearby[bli]) - break; - AddSentinelsNear(nearby[bli]); - ((aqsentinelAI *)nearby[bli]->AI())->gatherOthersWhenAggro = false; - ((aqsentinelAI *)nearby[bli]->AI())->selectAbility(pickAbilityRandom(chosenAbilities)); - } - /*if (bli < 3) - DoYell("I dont have enough buddies.", LANG_NEUTRAL, 0);*/ - SendMyListToBuddies(); - CallBuddiesToAttack(who); - } - - bool gatherOthersWhenAggro; - - void Reset() - { - if (!m_creature->isDead()) - { - for (int i=0; i<3; i++) - { - if (!nearby[i]) - continue; - if (nearby[i]->isDead()) - nearby[i]->Respawn(); - } - } - ClearBudyList(); - gatherOthersWhenAggro = true; - m_creature->ApplySpellImmune(0, IMMUNITY_STATE, SPELL_AURA_MOD_TAUNT, false); - m_creature->ApplySpellImmune(0, IMMUNITY_EFFECT, SPELL_EFFECT_ATTACK_ME, false); - } - - void GainSentinelAbility(uint32 id) - { - const SpellEntry *spell = GetSpellStore()->LookupEntry(id); - for (int i=0; i<3; i++) - { - if (!spell->Effect[i]) - continue; - SentinelAbilityAura *a = new SentinelAbilityAura(this, (SpellEntry *)spell, id, i); - m_creature->AddAura(a); - } - if (id == SPELL_KNOCK_BUFF) - { - m_creature->ApplySpellImmune(0, IMMUNITY_STATE, SPELL_AURA_MOD_TAUNT, true); - m_creature->ApplySpellImmune(0, IMMUNITY_EFFECT, SPELL_EFFECT_ATTACK_ME, true); - } - } - - void Aggro(Unit *who) - { - if (gatherOthersWhenAggro) - GetOtherSentinels(who); - - GainSentinelAbility(ability); - DoZoneInCombat(); - } - - void JustDied(Unit*) - { - for (int ni=0; ni<3; ni++) - { - Creature *sent = nearby[ni]; - if (!sent) - continue; - if (sent->isDead()) - continue; - int h = sent->GetHealth() + (sent->GetMaxHealth() / 2); - if (h > sent->GetMaxHealth()) - h = sent->GetMaxHealth(); - sent->SetHealth(h); - ((aqsentinelAI *)sent->AI())->GainSentinelAbility(ability); - } - } - - Unit *GetHatedManaUser() - { - std::list::iterator i; - for (i = m_creature->getThreatManager().getThreatList().begin();i != m_creature->getThreatManager().getThreatList().end(); ++i) - { - Unit* pUnit = Unit::GetUnit((*m_creature), (*i)->getUnitGuid()); - if (pUnit->getPowerType()==POWER_MANA) - return pUnit; - } - return NULL; - } -}; -CreatureAI* GetAI_mob_anubisath_sentinelAI(Creature *_Creature) -{ - return new aqsentinelAI (_Creature); -} - -void AddSC_mob_anubisath_sentinel() -{ - Script *newscript; - newscript = new Script; - newscript->Name="mob_anubisath_sentinel"; - newscript->GetAI = GetAI_mob_anubisath_sentinelAI; - m_scripts[nrscripts++] = newscript; -} - -SentinelAbilityAura::~SentinelAbilityAura() {} -Unit* SentinelAbilityAura::GetTriggerTarget() const -{ - switch (abilityId) - { - case SPELL_KNOCK_BUFF: - case SPELL_THUNDER_BUFF: - case SPELL_MSTRIKE_BUFF: - case SPELL_STORM_BUFF: - return aOwner->m_creature->getVictim(); - - case SPELL_MANAB_BUFF: - return aOwner->GetHatedManaUser(); - - case SPELL_MENDING_BUFF: - case SPELL_REFLECTAF_BUFF: - case SPELL_REFLECTSFr_BUFF: - case SPELL_THORNS_BUFF: - default: - return aOwner->m_creature; - } -} - -SentinelAbilityAura::SentinelAbilityAura(aqsentinelAI *abilityOwner, SpellEntry *spell, uint32 ability, uint32 eff) -: Aura(spell, eff, NULL, abilityOwner->m_creature, abilityOwner->m_creature, NULL) -{ - aOwner = abilityOwner; - abilityId = ability; - currentBasePoints = 0; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: mob_anubisath_sentinel +SD%Complete: 95 +SDComment: Shadow storm is not properly implemented in core it should only target ppl outside of melee range. +SDCategory: Temple of Ahn'Qiraj +EndScriptData */ + +#include "precompiled.h" +#include "WorldPacket.h" + +#include "Item.h" +#include "Player.h" +#include "Spell.h" + +#include "Cell.h" +#include "CellImpl.h" +#include "GridNotifiers.h" +#include "GridNotifiersImpl.h" + +#define SPELL_MENDING_BUFF 2147 + +#define SPELL_KNOCK_BUFF 21737 +#define SPELL_KNOCK 25778 +#define SPELL_MANAB_BUFF 812 +#define SPELL_MANAB 25779 + +#define SPELL_REFLECTAF_BUFF 13022 +#define SPELL_REFLECTSFr_BUFF 19595 +#define SPELL_THORNS_BUFF 25777 + +#define SPELL_THUNDER_BUFF 2834 +#define SPELL_THUNDER 8732 + +#define SPELL_MSTRIKE_BUFF 9347 +#define SPELL_MSTRIKE 24573 + +#define SPELL_STORM_BUFF 2148 +#define SPELL_STORM 26546 + +class NearbyAQSentinel +{ + public: + NearbyAQSentinel(Unit const* obj) : i_obj(obj) {} + bool operator()(Unit* u) + { + if (u->GetEntry() == 15264 && i_obj->IsWithinDistInMap(u, 70) && !u->isDead()) + return true; + else + return false; + } + private: + Unit const* i_obj; +}; + +struct MANGOS_DLL_DECL aqsentinelAI; +class MANGOS_DLL_DECL SentinelAbilityAura : public Aura +{ + public: + ~SentinelAbilityAura(); + Unit* GetTriggerTarget() const; + SentinelAbilityAura(aqsentinelAI *abilityOwner, SpellEntry *spell, uint32 ability, uint32 eff); + protected: + aqsentinelAI *aOwner; + int32 currentBasePoints; + uint32 abilityId; +}; + +struct MANGOS_DLL_DECL aqsentinelAI : public ScriptedAI +{ + uint32 ability; + int abselected; + + void selectAbility(int asel) + { + switch (asel) + { + case 0: ability = SPELL_MENDING_BUFF;break; + case 1: ability = SPELL_KNOCK_BUFF;break; + case 2: ability = SPELL_MANAB_BUFF;break; + case 3: ability = SPELL_REFLECTAF_BUFF;break; + case 4: ability = SPELL_REFLECTSFr_BUFF;break; + case 5: ability = SPELL_THORNS_BUFF;break; + case 6: ability = SPELL_THUNDER_BUFF;break; + case 7: ability = SPELL_MSTRIKE_BUFF;break; + case 8: ability = SPELL_STORM_BUFF;break; + } + } + + aqsentinelAI(Creature *c) : ScriptedAI(c) + { + ClearBudyList(); + abselected = 0; // just initialization of variable + Reset(); + } + + Creature *nearby[3]; + + void ClearBudyList() + { + nearby[0] = nearby[1] = nearby[2] = NULL; + } + + void AddBuddyToList(Creature *c) + { + if (c==m_creature) + return; + for (int i=0; i<3; i++) + { + if (nearby[i] == c) + return; + if (!nearby[i]) + { + nearby[i] = c; + return; + } + } + } + + void GiveBuddyMyList(Creature *c) + { + aqsentinelAI *cai = (aqsentinelAI *)(c->AI()); + for (int i=0; i<3; i++) + if (nearby[i] && nearby[i]!=c) + cai->AddBuddyToList(nearby[i]); + cai->AddBuddyToList(m_creature); + } + + void SendMyListToBuddies() + { + for (int i=0; i<3; i++) + if (nearby[i]) + GiveBuddyMyList(nearby[i]); + } + + void CallBuddiesToAttack(Unit *who) + { + for (int i=0; i<3; i++) + { + Creature *c = nearby[i]; + if (c) + { + if (!c->isInCombat()) + { + c->SetNoCallAssistence(true); + if(c->AI()) + c->AI()->AttackStart(who); + } + } + } + } + + void AddSentinelsNear(Unit *nears) + { + CellPair p(MaNGOS::ComputeCellPair(nears->GetPositionX(), nears->GetPositionY())); + Cell cell(p); + cell.data.Part.reserved = ALL_DISTRICT; + cell.SetNoCreate(); + + std::list assistList; + + NearbyAQSentinel u_check(nears); + MaNGOS::CreatureListSearcher searcher(assistList, u_check); + TypeContainerVisitor, GridTypeMapContainer > grid_creature_searcher(searcher); + CellLock cell_lock(cell, p); + cell_lock->Visit(cell_lock, grid_creature_searcher, *(nears->GetMap())); + + for(std::list::iterator iter = assistList.begin(); iter != assistList.end(); ++iter) + AddBuddyToList((*iter)); + } + + int pickAbilityRandom(bool *chosenAbilities) + { + for (int t = 0; t < 2; t++) + { + for (int i = !t ? (rand()%9) : 0; i < 9; i++) + { + if (!chosenAbilities[i]) + { + chosenAbilities[i] = true; + return i; + } + } + } + return 0; // should never happen + } + + void GetOtherSentinels(Unit *who) + { + bool *chosenAbilities = new bool[9]; + memset(chosenAbilities, 0, 9*sizeof(bool)); + selectAbility(pickAbilityRandom(chosenAbilities)); + + ClearBudyList(); + AddSentinelsNear(m_creature); + int bli; + for (bli = 0; bli < 3;bli++) + { + if (!nearby[bli]) + break; + AddSentinelsNear(nearby[bli]); + ((aqsentinelAI *)nearby[bli]->AI())->gatherOthersWhenAggro = false; + ((aqsentinelAI *)nearby[bli]->AI())->selectAbility(pickAbilityRandom(chosenAbilities)); + } + /*if (bli < 3) + DoYell("I dont have enough buddies.", LANG_NEUTRAL, 0);*/ + SendMyListToBuddies(); + CallBuddiesToAttack(who); + } + + bool gatherOthersWhenAggro; + + void Reset() + { + if (!m_creature->isDead()) + { + for (int i=0; i<3; i++) + { + if (!nearby[i]) + continue; + if (nearby[i]->isDead()) + nearby[i]->Respawn(); + } + } + ClearBudyList(); + gatherOthersWhenAggro = true; + m_creature->ApplySpellImmune(0, IMMUNITY_STATE, SPELL_AURA_MOD_TAUNT, false); + m_creature->ApplySpellImmune(0, IMMUNITY_EFFECT, SPELL_EFFECT_ATTACK_ME, false); + } + + void GainSentinelAbility(uint32 id) + { + const SpellEntry *spell = GetSpellStore()->LookupEntry(id); + for (int i=0; i<3; i++) + { + if (!spell->Effect[i]) + continue; + SentinelAbilityAura *a = new SentinelAbilityAura(this, (SpellEntry *)spell, id, i); + m_creature->AddAura(a); + } + if (id == SPELL_KNOCK_BUFF) + { + m_creature->ApplySpellImmune(0, IMMUNITY_STATE, SPELL_AURA_MOD_TAUNT, true); + m_creature->ApplySpellImmune(0, IMMUNITY_EFFECT, SPELL_EFFECT_ATTACK_ME, true); + } + } + + void Aggro(Unit *who) + { + if (gatherOthersWhenAggro) + GetOtherSentinels(who); + + GainSentinelAbility(ability); + DoZoneInCombat(); + } + + void JustDied(Unit*) + { + for (int ni=0; ni<3; ni++) + { + Creature *sent = nearby[ni]; + if (!sent) + continue; + if (sent->isDead()) + continue; + int h = sent->GetHealth() + (sent->GetMaxHealth() / 2); + if (h > sent->GetMaxHealth()) + h = sent->GetMaxHealth(); + sent->SetHealth(h); + ((aqsentinelAI *)sent->AI())->GainSentinelAbility(ability); + } + } + + Unit *GetHatedManaUser() + { + std::list::iterator i; + for (i = m_creature->getThreatManager().getThreatList().begin();i != m_creature->getThreatManager().getThreatList().end(); ++i) + { + Unit* pUnit = Unit::GetUnit((*m_creature), (*i)->getUnitGuid()); + if (pUnit->getPowerType()==POWER_MANA) + return pUnit; + } + return NULL; + } +}; +CreatureAI* GetAI_mob_anubisath_sentinelAI(Creature *_Creature) +{ + return new aqsentinelAI (_Creature); +} + +void AddSC_mob_anubisath_sentinel() +{ + Script *newscript; + newscript = new Script; + newscript->Name="mob_anubisath_sentinel"; + newscript->GetAI = GetAI_mob_anubisath_sentinelAI; + m_scripts[nrscripts++] = newscript; +} + +SentinelAbilityAura::~SentinelAbilityAura() {} +Unit* SentinelAbilityAura::GetTriggerTarget() const +{ + switch (abilityId) + { + case SPELL_KNOCK_BUFF: + case SPELL_THUNDER_BUFF: + case SPELL_MSTRIKE_BUFF: + case SPELL_STORM_BUFF: + return aOwner->m_creature->getVictim(); + + case SPELL_MANAB_BUFF: + return aOwner->GetHatedManaUser(); + + case SPELL_MENDING_BUFF: + case SPELL_REFLECTAF_BUFF: + case SPELL_REFLECTSFr_BUFF: + case SPELL_THORNS_BUFF: + default: + return aOwner->m_creature; + } +} + +SentinelAbilityAura::SentinelAbilityAura(aqsentinelAI *abilityOwner, SpellEntry *spell, uint32 ability, uint32 eff) +: Aura(spell, eff, NULL, abilityOwner->m_creature, abilityOwner->m_creature, NULL) +{ + aOwner = abilityOwner; + abilityId = ability; + currentBasePoints = 0; +} diff --git a/src/bindings/scripts/scripts/zone/terokkar_forest/terokkar_forest.cpp b/src/bindings/scripts/scripts/zone/terokkar_forest/terokkar_forest.cpp index 2dc7e54297b..0dead7e7646 100644 --- a/src/bindings/scripts/scripts/zone/terokkar_forest/terokkar_forest.cpp +++ b/src/bindings/scripts/scripts/zone/terokkar_forest/terokkar_forest.cpp @@ -1,399 +1,399 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Terokkar_Forest -SD%Complete: 80 -SDComment: Quest support: 9889(test script only, sql inside script), 10009, 10873, 10896, 11096. Skettis->Ogri'la Flight -SDCategory: Terokkar Forest -EndScriptData */ - -/* ContentData -mob_unkor_the_ruthless -mob_infested_root_walker -mob_rotting_forest_rager -mob_netherweb_victim -npc_floon -npc_skyguard_handler_deesak -EndContentData */ - -#include "precompiled.h" - -/*###### -## mob_unkor_the_ruthless -######*/ - -/* -UPDATE `creature_template` SET `ScriptName`='mob_unkor_the_ruthless' WHERE `entry`=18262; -*/ - -#define SAY_SUBMIT "I give up! Please don't kill me!" - -#define FACTION_HOSTILE 45 -#define FACTION_FRIENDLY 35 -#define QUEST_DONTKILLTHEFATONE 9889 - -#define SPELL_PULVERIZE 2676 -//#define SPELL_QUID9889 32174 - -struct MANGOS_DLL_DECL mob_unkor_the_ruthlessAI : public ScriptedAI -{ - mob_unkor_the_ruthlessAI(Creature* c) : ScriptedAI(c) { Reset(); } - - bool CanDoQuest; - uint32 UnkorUnfriendly_Timer; - uint32 Pulverize_Timer; - - void Reset() - { - CanDoQuest = false; - UnkorUnfriendly_Timer = 0; - Pulverize_Timer = 3000; - m_creature->SetUInt32Value(UNIT_FIELD_BYTES_1, PLAYER_STATE_NONE); - m_creature->setFaction(FACTION_HOSTILE); - } - - void Aggro(Unit *who) {} - - void DoNice() - { - DoSay(SAY_SUBMIT,LANG_UNIVERSAL,NULL); - m_creature->setFaction(FACTION_FRIENDLY); - m_creature->SetUInt32Value(UNIT_FIELD_BYTES_1, PLAYER_STATE_SIT); - m_creature->RemoveAllAuras(); - m_creature->DeleteThreatList(); - m_creature->CombatStop(); - UnkorUnfriendly_Timer = 60000; - } - - void DamageTaken(Unit *done_by, uint32 &damage) - { - if( done_by->GetTypeId() == TYPEID_PLAYER ) - if( (m_creature->GetHealth()-damage)*100 / m_creature->GetMaxHealth() < 30 ) - { - if( Group* pGroup = ((Player*)done_by)->GetGroup() ) - { - for(GroupReference *itr = pGroup->GetFirstMember(); itr != NULL; itr = itr->next()) - { - Player *pGroupie = itr->getSource(); - if( pGroupie && - pGroupie->GetQuestStatus(QUEST_DONTKILLTHEFATONE) == QUEST_STATUS_INCOMPLETE && - pGroupie->GetReqKillOrCastCurrentCount(QUEST_DONTKILLTHEFATONE, 18260) == 10 ) - { - pGroupie->AreaExploredOrEventHappens(QUEST_DONTKILLTHEFATONE); - if( !CanDoQuest ) - CanDoQuest = true; - } - } - } else - if( ((Player*)done_by)->GetQuestStatus(QUEST_DONTKILLTHEFATONE) == QUEST_STATUS_INCOMPLETE && - ((Player*)done_by)->GetReqKillOrCastCurrentCount(QUEST_DONTKILLTHEFATONE, 18260) == 10 ) - { - ((Player*)done_by)->AreaExploredOrEventHappens(QUEST_DONTKILLTHEFATONE); - CanDoQuest = true; - } - } - } - - void UpdateAI(const uint32 diff) - { - if( CanDoQuest ) - { - if( !UnkorUnfriendly_Timer ) - { - //DoCast(m_creature,SPELL_QUID9889); //not using spell for now - DoNice(); - } - else - { - if( UnkorUnfriendly_Timer < diff ) - { - EnterEvadeMode(); - }else UnkorUnfriendly_Timer -= diff; - } - } - - if(!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - if( Pulverize_Timer < diff ) - { - DoCast(m_creature,SPELL_PULVERIZE); - Pulverize_Timer = 9000; - }else Pulverize_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; - -CreatureAI* GetAI_mob_unkor_the_ruthless(Creature *_Creature) -{ - return new mob_unkor_the_ruthlessAI (_Creature); -} - -/*###### -## mob_infested_root_walker -######*/ - -struct MANGOS_DLL_DECL mob_infested_root_walkerAI : public ScriptedAI -{ - mob_infested_root_walkerAI(Creature *c) : ScriptedAI(c) {Reset();} - - void Reset() { } - void Aggro(Unit *who) { } - - void DamageTaken(Unit *done_by, uint32 &damage) - { - if (done_by && done_by->GetTypeId() == TYPEID_PLAYER) - if (m_creature->GetHealth() <= damage) - if (rand()%100 < 75) - //Summon Wood Mites - m_creature->CastSpell(m_creature,39130,true); - } -}; -CreatureAI* GetAI_mob_infested_root_walker(Creature *_Creature) -{ - return new mob_infested_root_walkerAI (_Creature); -} - -/*###### -## mob_rotting_forest_rager -######*/ - -struct MANGOS_DLL_DECL mob_rotting_forest_ragerAI : public ScriptedAI -{ - mob_rotting_forest_ragerAI(Creature *c) : ScriptedAI(c) {Reset();} - - void Reset() { } - void Aggro(Unit *who) { } - - void DamageTaken(Unit *done_by, uint32 &damage) - { - if (done_by->GetTypeId() == TYPEID_PLAYER) - if (m_creature->GetHealth() <= damage) - if (rand()%100 < 75) - //Summon Lots of Wood Mights - m_creature->CastSpell(m_creature,39134,true); - } -}; -CreatureAI* GetAI_mob_rotting_forest_rager(Creature *_Creature) -{ - return new mob_rotting_forest_ragerAI (_Creature); -} - -/*###### -## mob_netherweb_victim -######*/ - -#define QUEST_TARGET 22459 -//#define SPELL_FREE_WEBBED 38950 - -const uint32 netherwebVictims[6] = -{ - 18470, 16805, 21242, 18452, 22482, 21285 -}; -struct MANGOS_DLL_DECL mob_netherweb_victimAI : public ScriptedAI -{ - mob_netherweb_victimAI(Creature *c) : ScriptedAI(c) {Reset();} - - void Reset() { } - void Aggro(Unit *who) { } - void MoveInLineOfSight(Unit *who) { } - - void JustDied(Unit* Killer) - { - if( Killer->GetTypeId() == TYPEID_PLAYER ) - { - if( ((Player*)Killer)->GetQuestStatus(10873) == QUEST_STATUS_INCOMPLETE ) - { - if( rand()%100 < 25 ) - { - DoSpawnCreature(QUEST_TARGET,0,0,0,0,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,60000); - ((Player*)Killer)->KilledMonster(QUEST_TARGET, m_creature->GetGUID()); - }else - DoSpawnCreature(netherwebVictims[rand()%6],0,0,0,0,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,60000); - - if( rand()%100 < 75 ) - DoSpawnCreature(netherwebVictims[rand()%6],0,0,0,0,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,60000); - DoSpawnCreature(netherwebVictims[rand()%6],0,0,0,0,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,60000); - } - } - } -}; -CreatureAI* GetAI_mob_netherweb_victim(Creature *_Creature) -{ - return new mob_netherweb_victimAI (_Creature); -} - -/*###### -## npc_floon -######*/ - -#define GOSSIP_FLOON1 "You owe Sim'salabim money. Hand them over or die!" -#define GOSSIP_FLOON2 "Hand over the money or die...again!" -#define SAY_FLOON_ATTACK "I choose the third option: KILLING YOU!" - -#define FACTION_HOSTILE_FL 1738 -#define FACTION_FRIENDLY_FL 35 - -#define SPELL_SILENCE 6726 -#define SPELL_FROSTBOLT 9672 -#define SPELL_FROST_NOVA 11831 - -struct MANGOS_DLL_DECL npc_floonAI : public ScriptedAI -{ - npc_floonAI(Creature* c) : ScriptedAI(c) { Reset(); } - - uint32 Silence_Timer; - uint32 Frostbolt_Timer; - uint32 FrostNova_Timer; - - void Reset() - { - Silence_Timer = 2000; - Frostbolt_Timer = 4000; - FrostNova_Timer = 9000; - m_creature->setFaction(FACTION_FRIENDLY_FL); - } - - void Aggro(Unit *who) {} - - void UpdateAI(const uint32 diff) - { - if(!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - if( Silence_Timer < diff ) - { - DoCast(m_creature->getVictim(),SPELL_SILENCE); - Silence_Timer = 30000; - }else Silence_Timer -= diff; - - if( FrostNova_Timer < diff ) - { - DoCast(m_creature,SPELL_FROST_NOVA); - FrostNova_Timer = 20000; - }else FrostNova_Timer -= diff; - - if( Frostbolt_Timer < diff ) - { - DoCast(m_creature->getVictim(),SPELL_FROSTBOLT); - Frostbolt_Timer = 5000; - }else Frostbolt_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; -CreatureAI* GetAI_npc_floon(Creature *_Creature) -{ - return new npc_floonAI (_Creature); -} - -bool GossipHello_npc_floon(Player *player, Creature *_Creature ) -{ - if( player->GetQuestStatus(10009) == QUEST_STATUS_INCOMPLETE ) - player->ADD_GOSSIP_ITEM(1, GOSSIP_FLOON1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF); - - player->SEND_GOSSIP_MENU(9442, _Creature->GetGUID()); - return true; -} - -bool GossipSelect_npc_floon(Player *player, Creature *_Creature, uint32 sender, uint32 action ) -{ - if( action == GOSSIP_ACTION_INFO_DEF ) - { - player->ADD_GOSSIP_ITEM(1, GOSSIP_FLOON2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); - player->SEND_GOSSIP_MENU(9443, _Creature->GetGUID()); - } - if( action == GOSSIP_ACTION_INFO_DEF+1 ) - { - player->CLOSE_GOSSIP_MENU(); - _Creature->setFaction(FACTION_HOSTILE_FL); - ((npc_floonAI*)_Creature->AI())->DoSay(SAY_FLOON_ATTACK,LANG_UNIVERSAL,player); - ((npc_floonAI*)_Creature->AI())->AttackStart(player); - } - return true; -} - -/*###### -## npc_skyguard_handler_deesak -######*/ - -#define GOSSIP_SKYGUARD "Fly me to Ogri'la please" - -bool GossipHello_npc_skyguard_handler_deesak(Player *player, Creature *_Creature ) -{ - if (_Creature->isQuestGiver()) - player->PrepareQuestMenu( _Creature->GetGUID() ); - - if (player->GetReputationRank(1031) >= REP_HONORED) - player->ADD_GOSSIP_ITEM( 2, GOSSIP_SKYGUARD, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); - - player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); - - return true; -} - -bool GossipSelect_npc_skyguard_handler_deesak(Player *player, Creature *_Creature, uint32 sender, uint32 action ) -{ - if (action == GOSSIP_ACTION_INFO_DEF+1) - { - player->CLOSE_GOSSIP_MENU(); - player->CastSpell(player,41279,true); //TaxiPath 705 (Taxi - Skettis to Skyguard Outpost) - } - return true; -} - -/*###### -## AddSC -######*/ - -void AddSC_terokkar_forest() -{ - Script *newscript; - - newscript = new Script; - newscript->Name="mob_unkor_the_ruthless"; - newscript->GetAI = GetAI_mob_unkor_the_ruthless; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="mob_infested_root_walker"; - newscript->GetAI = GetAI_mob_infested_root_walker; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="mob_rotting_forest_rager"; - newscript->GetAI = GetAI_mob_rotting_forest_rager; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="mob_netherweb_victim"; - newscript->GetAI = GetAI_mob_netherweb_victim; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="npc_floon"; - newscript->pGossipHello = &GossipHello_npc_floon; - newscript->pGossipSelect = &GossipSelect_npc_floon; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="npc_skyguard_handler_deesak"; - newscript->pGossipHello = &GossipHello_npc_skyguard_handler_deesak; - newscript->pGossipSelect = &GossipSelect_npc_skyguard_handler_deesak; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Terokkar_Forest +SD%Complete: 80 +SDComment: Quest support: 9889(test script only, sql inside script), 10009, 10873, 10896, 11096. Skettis->Ogri'la Flight +SDCategory: Terokkar Forest +EndScriptData */ + +/* ContentData +mob_unkor_the_ruthless +mob_infested_root_walker +mob_rotting_forest_rager +mob_netherweb_victim +npc_floon +npc_skyguard_handler_deesak +EndContentData */ + +#include "precompiled.h" + +/*###### +## mob_unkor_the_ruthless +######*/ + +/* +UPDATE `creature_template` SET `ScriptName`='mob_unkor_the_ruthless' WHERE `entry`=18262; +*/ + +#define SAY_SUBMIT "I give up! Please don't kill me!" + +#define FACTION_HOSTILE 45 +#define FACTION_FRIENDLY 35 +#define QUEST_DONTKILLTHEFATONE 9889 + +#define SPELL_PULVERIZE 2676 +//#define SPELL_QUID9889 32174 + +struct MANGOS_DLL_DECL mob_unkor_the_ruthlessAI : public ScriptedAI +{ + mob_unkor_the_ruthlessAI(Creature* c) : ScriptedAI(c) { Reset(); } + + bool CanDoQuest; + uint32 UnkorUnfriendly_Timer; + uint32 Pulverize_Timer; + + void Reset() + { + CanDoQuest = false; + UnkorUnfriendly_Timer = 0; + Pulverize_Timer = 3000; + m_creature->SetUInt32Value(UNIT_FIELD_BYTES_1, PLAYER_STATE_NONE); + m_creature->setFaction(FACTION_HOSTILE); + } + + void Aggro(Unit *who) {} + + void DoNice() + { + DoSay(SAY_SUBMIT,LANG_UNIVERSAL,NULL); + m_creature->setFaction(FACTION_FRIENDLY); + m_creature->SetUInt32Value(UNIT_FIELD_BYTES_1, PLAYER_STATE_SIT); + m_creature->RemoveAllAuras(); + m_creature->DeleteThreatList(); + m_creature->CombatStop(); + UnkorUnfriendly_Timer = 60000; + } + + void DamageTaken(Unit *done_by, uint32 &damage) + { + if( done_by->GetTypeId() == TYPEID_PLAYER ) + if( (m_creature->GetHealth()-damage)*100 / m_creature->GetMaxHealth() < 30 ) + { + if( Group* pGroup = ((Player*)done_by)->GetGroup() ) + { + for(GroupReference *itr = pGroup->GetFirstMember(); itr != NULL; itr = itr->next()) + { + Player *pGroupie = itr->getSource(); + if( pGroupie && + pGroupie->GetQuestStatus(QUEST_DONTKILLTHEFATONE) == QUEST_STATUS_INCOMPLETE && + pGroupie->GetReqKillOrCastCurrentCount(QUEST_DONTKILLTHEFATONE, 18260) == 10 ) + { + pGroupie->AreaExploredOrEventHappens(QUEST_DONTKILLTHEFATONE); + if( !CanDoQuest ) + CanDoQuest = true; + } + } + } else + if( ((Player*)done_by)->GetQuestStatus(QUEST_DONTKILLTHEFATONE) == QUEST_STATUS_INCOMPLETE && + ((Player*)done_by)->GetReqKillOrCastCurrentCount(QUEST_DONTKILLTHEFATONE, 18260) == 10 ) + { + ((Player*)done_by)->AreaExploredOrEventHappens(QUEST_DONTKILLTHEFATONE); + CanDoQuest = true; + } + } + } + + void UpdateAI(const uint32 diff) + { + if( CanDoQuest ) + { + if( !UnkorUnfriendly_Timer ) + { + //DoCast(m_creature,SPELL_QUID9889); //not using spell for now + DoNice(); + } + else + { + if( UnkorUnfriendly_Timer < diff ) + { + EnterEvadeMode(); + }else UnkorUnfriendly_Timer -= diff; + } + } + + if(!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + if( Pulverize_Timer < diff ) + { + DoCast(m_creature,SPELL_PULVERIZE); + Pulverize_Timer = 9000; + }else Pulverize_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; + +CreatureAI* GetAI_mob_unkor_the_ruthless(Creature *_Creature) +{ + return new mob_unkor_the_ruthlessAI (_Creature); +} + +/*###### +## mob_infested_root_walker +######*/ + +struct MANGOS_DLL_DECL mob_infested_root_walkerAI : public ScriptedAI +{ + mob_infested_root_walkerAI(Creature *c) : ScriptedAI(c) {Reset();} + + void Reset() { } + void Aggro(Unit *who) { } + + void DamageTaken(Unit *done_by, uint32 &damage) + { + if (done_by && done_by->GetTypeId() == TYPEID_PLAYER) + if (m_creature->GetHealth() <= damage) + if (rand()%100 < 75) + //Summon Wood Mites + m_creature->CastSpell(m_creature,39130,true); + } +}; +CreatureAI* GetAI_mob_infested_root_walker(Creature *_Creature) +{ + return new mob_infested_root_walkerAI (_Creature); +} + +/*###### +## mob_rotting_forest_rager +######*/ + +struct MANGOS_DLL_DECL mob_rotting_forest_ragerAI : public ScriptedAI +{ + mob_rotting_forest_ragerAI(Creature *c) : ScriptedAI(c) {Reset();} + + void Reset() { } + void Aggro(Unit *who) { } + + void DamageTaken(Unit *done_by, uint32 &damage) + { + if (done_by->GetTypeId() == TYPEID_PLAYER) + if (m_creature->GetHealth() <= damage) + if (rand()%100 < 75) + //Summon Lots of Wood Mights + m_creature->CastSpell(m_creature,39134,true); + } +}; +CreatureAI* GetAI_mob_rotting_forest_rager(Creature *_Creature) +{ + return new mob_rotting_forest_ragerAI (_Creature); +} + +/*###### +## mob_netherweb_victim +######*/ + +#define QUEST_TARGET 22459 +//#define SPELL_FREE_WEBBED 38950 + +const uint32 netherwebVictims[6] = +{ + 18470, 16805, 21242, 18452, 22482, 21285 +}; +struct MANGOS_DLL_DECL mob_netherweb_victimAI : public ScriptedAI +{ + mob_netherweb_victimAI(Creature *c) : ScriptedAI(c) {Reset();} + + void Reset() { } + void Aggro(Unit *who) { } + void MoveInLineOfSight(Unit *who) { } + + void JustDied(Unit* Killer) + { + if( Killer->GetTypeId() == TYPEID_PLAYER ) + { + if( ((Player*)Killer)->GetQuestStatus(10873) == QUEST_STATUS_INCOMPLETE ) + { + if( rand()%100 < 25 ) + { + DoSpawnCreature(QUEST_TARGET,0,0,0,0,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,60000); + ((Player*)Killer)->KilledMonster(QUEST_TARGET, m_creature->GetGUID()); + }else + DoSpawnCreature(netherwebVictims[rand()%6],0,0,0,0,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,60000); + + if( rand()%100 < 75 ) + DoSpawnCreature(netherwebVictims[rand()%6],0,0,0,0,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,60000); + DoSpawnCreature(netherwebVictims[rand()%6],0,0,0,0,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,60000); + } + } + } +}; +CreatureAI* GetAI_mob_netherweb_victim(Creature *_Creature) +{ + return new mob_netherweb_victimAI (_Creature); +} + +/*###### +## npc_floon +######*/ + +#define GOSSIP_FLOON1 "You owe Sim'salabim money. Hand them over or die!" +#define GOSSIP_FLOON2 "Hand over the money or die...again!" +#define SAY_FLOON_ATTACK "I choose the third option: KILLING YOU!" + +#define FACTION_HOSTILE_FL 1738 +#define FACTION_FRIENDLY_FL 35 + +#define SPELL_SILENCE 6726 +#define SPELL_FROSTBOLT 9672 +#define SPELL_FROST_NOVA 11831 + +struct MANGOS_DLL_DECL npc_floonAI : public ScriptedAI +{ + npc_floonAI(Creature* c) : ScriptedAI(c) { Reset(); } + + uint32 Silence_Timer; + uint32 Frostbolt_Timer; + uint32 FrostNova_Timer; + + void Reset() + { + Silence_Timer = 2000; + Frostbolt_Timer = 4000; + FrostNova_Timer = 9000; + m_creature->setFaction(FACTION_FRIENDLY_FL); + } + + void Aggro(Unit *who) {} + + void UpdateAI(const uint32 diff) + { + if(!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + if( Silence_Timer < diff ) + { + DoCast(m_creature->getVictim(),SPELL_SILENCE); + Silence_Timer = 30000; + }else Silence_Timer -= diff; + + if( FrostNova_Timer < diff ) + { + DoCast(m_creature,SPELL_FROST_NOVA); + FrostNova_Timer = 20000; + }else FrostNova_Timer -= diff; + + if( Frostbolt_Timer < diff ) + { + DoCast(m_creature->getVictim(),SPELL_FROSTBOLT); + Frostbolt_Timer = 5000; + }else Frostbolt_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; +CreatureAI* GetAI_npc_floon(Creature *_Creature) +{ + return new npc_floonAI (_Creature); +} + +bool GossipHello_npc_floon(Player *player, Creature *_Creature ) +{ + if( player->GetQuestStatus(10009) == QUEST_STATUS_INCOMPLETE ) + player->ADD_GOSSIP_ITEM(1, GOSSIP_FLOON1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF); + + player->SEND_GOSSIP_MENU(9442, _Creature->GetGUID()); + return true; +} + +bool GossipSelect_npc_floon(Player *player, Creature *_Creature, uint32 sender, uint32 action ) +{ + if( action == GOSSIP_ACTION_INFO_DEF ) + { + player->ADD_GOSSIP_ITEM(1, GOSSIP_FLOON2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); + player->SEND_GOSSIP_MENU(9443, _Creature->GetGUID()); + } + if( action == GOSSIP_ACTION_INFO_DEF+1 ) + { + player->CLOSE_GOSSIP_MENU(); + _Creature->setFaction(FACTION_HOSTILE_FL); + ((npc_floonAI*)_Creature->AI())->DoSay(SAY_FLOON_ATTACK,LANG_UNIVERSAL,player); + ((npc_floonAI*)_Creature->AI())->AttackStart(player); + } + return true; +} + +/*###### +## npc_skyguard_handler_deesak +######*/ + +#define GOSSIP_SKYGUARD "Fly me to Ogri'la please" + +bool GossipHello_npc_skyguard_handler_deesak(Player *player, Creature *_Creature ) +{ + if (_Creature->isQuestGiver()) + player->PrepareQuestMenu( _Creature->GetGUID() ); + + if (player->GetReputationRank(1031) >= REP_HONORED) + player->ADD_GOSSIP_ITEM( 2, GOSSIP_SKYGUARD, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); + + player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); + + return true; +} + +bool GossipSelect_npc_skyguard_handler_deesak(Player *player, Creature *_Creature, uint32 sender, uint32 action ) +{ + if (action == GOSSIP_ACTION_INFO_DEF+1) + { + player->CLOSE_GOSSIP_MENU(); + player->CastSpell(player,41279,true); //TaxiPath 705 (Taxi - Skettis to Skyguard Outpost) + } + return true; +} + +/*###### +## AddSC +######*/ + +void AddSC_terokkar_forest() +{ + Script *newscript; + + newscript = new Script; + newscript->Name="mob_unkor_the_ruthless"; + newscript->GetAI = GetAI_mob_unkor_the_ruthless; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="mob_infested_root_walker"; + newscript->GetAI = GetAI_mob_infested_root_walker; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="mob_rotting_forest_rager"; + newscript->GetAI = GetAI_mob_rotting_forest_rager; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="mob_netherweb_victim"; + newscript->GetAI = GetAI_mob_netherweb_victim; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="npc_floon"; + newscript->pGossipHello = &GossipHello_npc_floon; + newscript->pGossipSelect = &GossipSelect_npc_floon; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="npc_skyguard_handler_deesak"; + newscript->pGossipHello = &GossipHello_npc_skyguard_handler_deesak; + newscript->pGossipSelect = &GossipSelect_npc_skyguard_handler_deesak; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/thunder_bluff/thunder_bluff.cpp b/src/bindings/scripts/scripts/zone/thunder_bluff/thunder_bluff.cpp index b526325f5c9..8462cc68a2f 100644 --- a/src/bindings/scripts/scripts/zone/thunder_bluff/thunder_bluff.cpp +++ b/src/bindings/scripts/scripts/zone/thunder_bluff/thunder_bluff.cpp @@ -1,136 +1,136 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Thunder_Bluff -SD%Complete: 100 -SDComment: Quest support: 925 -SDCategory: Thunder Bluff -EndScriptData */ - -#include "precompiled.h" - -/*##### -# npc_cairne_bloodhoof -######*/ - -#define SPELL_BERSERKER_CHARGE 16636 -#define SPELL_CLEAVE 16044 -#define SPELL_MORTAL_STRIKE 16856 -#define SPELL_THUNDERCLAP 23931 -#define SPELL_UPPERCUT 22916 - -//TODO: verify abilities/timers -struct MANGOS_DLL_DECL npc_cairne_bloodhoofAI : public ScriptedAI -{ - npc_cairne_bloodhoofAI(Creature* c) : ScriptedAI(c) { Reset(); } - - uint32 BerserkerCharge_Timer; - uint32 Cleave_Timer; - uint32 MortalStrike_Timer; - uint32 Thunderclap_Timer; - uint32 Uppercut_Timer; - - void Reset() - { - BerserkerCharge_Timer = 30000; - Cleave_Timer = 5000; - MortalStrike_Timer = 10000; - Thunderclap_Timer = 15000; - Uppercut_Timer = 10000; - } - - void Aggro(Unit *who) {} - - void UpdateAI(const uint32 diff) - { - if(!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - if( BerserkerCharge_Timer < diff ) - { - Unit* target = SelectUnit(SELECT_TARGET_RANDOM,0); - if( target ) - DoCast(target,SPELL_BERSERKER_CHARGE); - BerserkerCharge_Timer = 25000; - }else BerserkerCharge_Timer -= diff; - - if( Uppercut_Timer < diff ) - { - DoCast(m_creature->getVictim(),SPELL_UPPERCUT); - Uppercut_Timer = 20000; - }else Uppercut_Timer -= diff; - - if( Thunderclap_Timer < diff ) - { - DoCast(m_creature->getVictim(),SPELL_THUNDERCLAP); - Thunderclap_Timer = 15000; - }else Thunderclap_Timer -= diff; - - if( MortalStrike_Timer < diff ) - { - DoCast(m_creature->getVictim(),SPELL_MORTAL_STRIKE); - MortalStrike_Timer = 15000; - }else MortalStrike_Timer -= diff; - - if( Cleave_Timer < diff ) - { - DoCast(m_creature->getVictim(),SPELL_CLEAVE); - Cleave_Timer = 7000; - }else Cleave_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; -CreatureAI* GetAI_npc_cairne_bloodhoof(Creature *_Creature) -{ - return new npc_cairne_bloodhoofAI (_Creature); -} - -bool GossipHello_npc_cairne_bloodhoof(Player *player, Creature *_Creature) -{ - if (_Creature->isQuestGiver()) - player->PrepareQuestMenu( _Creature->GetGUID() ); - - if( player->GetQuestStatus(925) == QUEST_STATUS_INCOMPLETE ) - player->ADD_GOSSIP_ITEM( 0, "I know this is rather silly but a young ward who is a bit shy would like your hoofprint.", GOSSIP_SENDER_MAIN, GOSSIP_SENDER_INFO ); - - player->SEND_GOSSIP_MENU(7013, _Creature->GetGUID() ); - - return true; -} - -bool GossipSelect_npc_cairne_bloodhoof(Player *player, Creature *_Creature, uint32 sender, uint32 action ) -{ - if( action == GOSSIP_SENDER_INFO ) - { - player->CastSpell(player, 23123, false); - player->SEND_GOSSIP_MENU(7014, _Creature->GetGUID() ); - } - return true; -} - -void AddSC_thunder_bluff() -{ - Script *newscript; - - newscript = new Script; - newscript->Name="npc_cairne_bloodhoof"; - newscript->GetAI = GetAI_npc_cairne_bloodhoof; - newscript->pGossipHello = &GossipHello_npc_cairne_bloodhoof; - newscript->pGossipSelect = &GossipSelect_npc_cairne_bloodhoof; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Thunder_Bluff +SD%Complete: 100 +SDComment: Quest support: 925 +SDCategory: Thunder Bluff +EndScriptData */ + +#include "precompiled.h" + +/*##### +# npc_cairne_bloodhoof +######*/ + +#define SPELL_BERSERKER_CHARGE 16636 +#define SPELL_CLEAVE 16044 +#define SPELL_MORTAL_STRIKE 16856 +#define SPELL_THUNDERCLAP 23931 +#define SPELL_UPPERCUT 22916 + +//TODO: verify abilities/timers +struct MANGOS_DLL_DECL npc_cairne_bloodhoofAI : public ScriptedAI +{ + npc_cairne_bloodhoofAI(Creature* c) : ScriptedAI(c) { Reset(); } + + uint32 BerserkerCharge_Timer; + uint32 Cleave_Timer; + uint32 MortalStrike_Timer; + uint32 Thunderclap_Timer; + uint32 Uppercut_Timer; + + void Reset() + { + BerserkerCharge_Timer = 30000; + Cleave_Timer = 5000; + MortalStrike_Timer = 10000; + Thunderclap_Timer = 15000; + Uppercut_Timer = 10000; + } + + void Aggro(Unit *who) {} + + void UpdateAI(const uint32 diff) + { + if(!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + if( BerserkerCharge_Timer < diff ) + { + Unit* target = SelectUnit(SELECT_TARGET_RANDOM,0); + if( target ) + DoCast(target,SPELL_BERSERKER_CHARGE); + BerserkerCharge_Timer = 25000; + }else BerserkerCharge_Timer -= diff; + + if( Uppercut_Timer < diff ) + { + DoCast(m_creature->getVictim(),SPELL_UPPERCUT); + Uppercut_Timer = 20000; + }else Uppercut_Timer -= diff; + + if( Thunderclap_Timer < diff ) + { + DoCast(m_creature->getVictim(),SPELL_THUNDERCLAP); + Thunderclap_Timer = 15000; + }else Thunderclap_Timer -= diff; + + if( MortalStrike_Timer < diff ) + { + DoCast(m_creature->getVictim(),SPELL_MORTAL_STRIKE); + MortalStrike_Timer = 15000; + }else MortalStrike_Timer -= diff; + + if( Cleave_Timer < diff ) + { + DoCast(m_creature->getVictim(),SPELL_CLEAVE); + Cleave_Timer = 7000; + }else Cleave_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; +CreatureAI* GetAI_npc_cairne_bloodhoof(Creature *_Creature) +{ + return new npc_cairne_bloodhoofAI (_Creature); +} + +bool GossipHello_npc_cairne_bloodhoof(Player *player, Creature *_Creature) +{ + if (_Creature->isQuestGiver()) + player->PrepareQuestMenu( _Creature->GetGUID() ); + + if( player->GetQuestStatus(925) == QUEST_STATUS_INCOMPLETE ) + player->ADD_GOSSIP_ITEM( 0, "I know this is rather silly but a young ward who is a bit shy would like your hoofprint.", GOSSIP_SENDER_MAIN, GOSSIP_SENDER_INFO ); + + player->SEND_GOSSIP_MENU(7013, _Creature->GetGUID() ); + + return true; +} + +bool GossipSelect_npc_cairne_bloodhoof(Player *player, Creature *_Creature, uint32 sender, uint32 action ) +{ + if( action == GOSSIP_SENDER_INFO ) + { + player->CastSpell(player, 23123, false); + player->SEND_GOSSIP_MENU(7014, _Creature->GetGUID() ); + } + return true; +} + +void AddSC_thunder_bluff() +{ + Script *newscript; + + newscript = new Script; + newscript->Name="npc_cairne_bloodhoof"; + newscript->GetAI = GetAI_npc_cairne_bloodhoof; + newscript->pGossipHello = &GossipHello_npc_cairne_bloodhoof; + newscript->pGossipSelect = &GossipSelect_npc_cairne_bloodhoof; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/tirisfal_glades/tirisfal_glades.cpp b/src/bindings/scripts/scripts/zone/tirisfal_glades/tirisfal_glades.cpp index 8a02147eb41..2e9691852c2 100644 --- a/src/bindings/scripts/scripts/zone/tirisfal_glades/tirisfal_glades.cpp +++ b/src/bindings/scripts/scripts/zone/tirisfal_glades/tirisfal_glades.cpp @@ -1,88 +1,88 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Tirisfal_Glades -SD%Complete: 100 -SDComment: Quest support: 590 -SDCategory: Tirisfal Glades -EndScriptData */ - -/* ContentData -npc_calvin_montague -EndContentData */ - -#include "precompiled.h" - -/*###### -## npc_calvin_montague -######*/ - -#define QUEST_590 590 -#define FACTION_FRIENDLY 68 -#define FACTION_HOSTILE 16 - -struct MANGOS_DLL_DECL npc_calvin_montagueAI : public ScriptedAI -{ - npc_calvin_montagueAI(Creature* c) : ScriptedAI(c) { Reset(); } - - void Reset() - { - m_creature->setFaction(FACTION_FRIENDLY); - } - - void Aggro(Unit* who) { } - - void JustDied(Unit* Killer) - { - if( Killer->GetTypeId() == TYPEID_PLAYER ) - if( ((Player*)Killer)->GetQuestStatus(QUEST_590) == QUEST_STATUS_INCOMPLETE ) - ((Player*)Killer)->AreaExploredOrEventHappens(QUEST_590); - } - - void UpdateAI(const uint32 diff) - { - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - DoMeleeAttackIfReady(); - } -}; -CreatureAI* GetAI_npc_calvin_montague(Creature *_Creature) -{ - return new npc_calvin_montagueAI (_Creature); -} - -bool QuestAccept_npc_calvin_montague(Player* player, Creature* creature, Quest const* quest) -{ - if( quest->GetQuestId() == QUEST_590 ) - { - creature->setFaction(FACTION_HOSTILE); - ((npc_calvin_montagueAI*)creature->AI())->AttackStart(player); - } - return true; -} - -void AddSC_tirisfal_glades() -{ - Script *newscript; - - newscript = new Script; - newscript->Name="npc_calvin_montague"; - newscript->GetAI = GetAI_npc_calvin_montague; - newscript->pQuestAccept = &QuestAccept_npc_calvin_montague; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Tirisfal_Glades +SD%Complete: 100 +SDComment: Quest support: 590 +SDCategory: Tirisfal Glades +EndScriptData */ + +/* ContentData +npc_calvin_montague +EndContentData */ + +#include "precompiled.h" + +/*###### +## npc_calvin_montague +######*/ + +#define QUEST_590 590 +#define FACTION_FRIENDLY 68 +#define FACTION_HOSTILE 16 + +struct MANGOS_DLL_DECL npc_calvin_montagueAI : public ScriptedAI +{ + npc_calvin_montagueAI(Creature* c) : ScriptedAI(c) { Reset(); } + + void Reset() + { + m_creature->setFaction(FACTION_FRIENDLY); + } + + void Aggro(Unit* who) { } + + void JustDied(Unit* Killer) + { + if( Killer->GetTypeId() == TYPEID_PLAYER ) + if( ((Player*)Killer)->GetQuestStatus(QUEST_590) == QUEST_STATUS_INCOMPLETE ) + ((Player*)Killer)->AreaExploredOrEventHappens(QUEST_590); + } + + void UpdateAI(const uint32 diff) + { + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + DoMeleeAttackIfReady(); + } +}; +CreatureAI* GetAI_npc_calvin_montague(Creature *_Creature) +{ + return new npc_calvin_montagueAI (_Creature); +} + +bool QuestAccept_npc_calvin_montague(Player* player, Creature* creature, Quest const* quest) +{ + if( quest->GetQuestId() == QUEST_590 ) + { + creature->setFaction(FACTION_HOSTILE); + ((npc_calvin_montagueAI*)creature->AI())->AttackStart(player); + } + return true; +} + +void AddSC_tirisfal_glades() +{ + Script *newscript; + + newscript = new Script; + newscript->Name="npc_calvin_montague"; + newscript->GetAI = GetAI_npc_calvin_montague; + newscript->pQuestAccept = &QuestAccept_npc_calvin_montague; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/uldaman/boss_ironaya.cpp b/src/bindings/scripts/scripts/zone/uldaman/boss_ironaya.cpp index 57871381f9d..fce9a9f29af 100644 --- a/src/bindings/scripts/scripts/zone/uldaman/boss_ironaya.cpp +++ b/src/bindings/scripts/scripts/zone/uldaman/boss_ironaya.cpp @@ -1,107 +1,107 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Ironaya -SD%Complete: 100 -SDComment: -SDCategory: Uldaman -EndScriptData */ - -#include "precompiled.h" - -#define SPELL_ARCINGSMASH 39144 -#define SPELL_KNOCKAWAY 22893 -#define SPELL_WSTOMP 16727 - -#define SAY_AGGRO "None may steal the secrets of the makers!" -#define SOUND_AGGRO 5851 - -struct MANGOS_DLL_DECL boss_ironayaAI : public ScriptedAI -{ - boss_ironayaAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 Arcing_Timer; - bool hasCastedWstomp; - bool hasCastedKnockaway; - - void Reset() - { - Arcing_Timer = 3000; - hasCastedKnockaway = false; - hasCastedWstomp = false; - } - - void Aggro(Unit *who) - { - DoYell(SAY_AGGRO,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_AGGRO); - } - - void UpdateAI(const uint32 diff) - { - //Return since we have no target - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - //If we are <50% hp do knockaway ONCE - if (!hasCastedKnockaway && m_creature->GetHealth()*2 < m_creature->GetMaxHealth()) - { - m_creature->CastSpell(m_creature->getVictim(),SPELL_KNOCKAWAY, true); - - // current aggro target is knocked away pick new target - Unit* Target = SelectUnit(SELECT_TARGET_TOPAGGRO, 0); - - if (!Target || Target == m_creature->getVictim()) - Target = SelectUnit(SELECT_TARGET_TOPAGGRO, 1); - - if (Target) - m_creature->TauntApply(Target); - - //Shouldn't cast this agian - hasCastedKnockaway = true; - } - - //Arcing_Timer - if (Arcing_Timer < diff) - { - DoCast(m_creature,SPELL_ARCINGSMASH); - Arcing_Timer = 13000; - }else Arcing_Timer -= diff; - - if (!hasCastedWstomp && m_creature->GetHealth()*4 < m_creature->GetMaxHealth()) - { - DoCast(m_creature,SPELL_WSTOMP); - hasCastedWstomp = true; - } - - DoMeleeAttackIfReady(); - } -}; - -CreatureAI* GetAI_boss_ironaya(Creature *_Creature) -{ - return new boss_ironayaAI (_Creature); -} - -void AddSC_boss_ironaya() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_ironaya"; - newscript->GetAI = GetAI_boss_ironaya; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Ironaya +SD%Complete: 100 +SDComment: +SDCategory: Uldaman +EndScriptData */ + +#include "precompiled.h" + +#define SPELL_ARCINGSMASH 39144 +#define SPELL_KNOCKAWAY 22893 +#define SPELL_WSTOMP 16727 + +#define SAY_AGGRO "None may steal the secrets of the makers!" +#define SOUND_AGGRO 5851 + +struct MANGOS_DLL_DECL boss_ironayaAI : public ScriptedAI +{ + boss_ironayaAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 Arcing_Timer; + bool hasCastedWstomp; + bool hasCastedKnockaway; + + void Reset() + { + Arcing_Timer = 3000; + hasCastedKnockaway = false; + hasCastedWstomp = false; + } + + void Aggro(Unit *who) + { + DoYell(SAY_AGGRO,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_AGGRO); + } + + void UpdateAI(const uint32 diff) + { + //Return since we have no target + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + //If we are <50% hp do knockaway ONCE + if (!hasCastedKnockaway && m_creature->GetHealth()*2 < m_creature->GetMaxHealth()) + { + m_creature->CastSpell(m_creature->getVictim(),SPELL_KNOCKAWAY, true); + + // current aggro target is knocked away pick new target + Unit* Target = SelectUnit(SELECT_TARGET_TOPAGGRO, 0); + + if (!Target || Target == m_creature->getVictim()) + Target = SelectUnit(SELECT_TARGET_TOPAGGRO, 1); + + if (Target) + m_creature->TauntApply(Target); + + //Shouldn't cast this agian + hasCastedKnockaway = true; + } + + //Arcing_Timer + if (Arcing_Timer < diff) + { + DoCast(m_creature,SPELL_ARCINGSMASH); + Arcing_Timer = 13000; + }else Arcing_Timer -= diff; + + if (!hasCastedWstomp && m_creature->GetHealth()*4 < m_creature->GetMaxHealth()) + { + DoCast(m_creature,SPELL_WSTOMP); + hasCastedWstomp = true; + } + + DoMeleeAttackIfReady(); + } +}; + +CreatureAI* GetAI_boss_ironaya(Creature *_Creature) +{ + return new boss_ironayaAI (_Creature); +} + +void AddSC_boss_ironaya() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_ironaya"; + newscript->GetAI = GetAI_boss_ironaya; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/uldaman/uldaman.cpp b/src/bindings/scripts/scripts/zone/uldaman/uldaman.cpp index 59bad6854fb..16e0c8bee7b 100644 --- a/src/bindings/scripts/scripts/zone/uldaman/uldaman.cpp +++ b/src/bindings/scripts/scripts/zone/uldaman/uldaman.cpp @@ -1,187 +1,187 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Uldaman -SD%Complete: 100 -SDComment: Quest support: 2278 + 1 trash mob. -SDCategory: Uldaman -EndScriptData */ - -/* ContentData -mob_jadespine_basilisk -npc_lore_keeper_of_norgannon -EndContentData */ - -#include "precompiled.h" - -/*###### -## mob_jadespine_basilisk -######*/ - -#define SPELL_CSLUMBER 3636 - -struct MANGOS_DLL_DECL mob_jadespine_basiliskAI : public ScriptedAI -{ - mob_jadespine_basiliskAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 Cslumber_Timer; - - void Reset() - { - Cslumber_Timer = 2000; - } - - void Aggro(Unit *who) - { - } - - void UpdateAI(const uint32 diff) - { - //Return since we have no target - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - //Cslumber_Timer - if (Cslumber_Timer < diff) - { - //Cast - // DoCast(m_creature->getVictim(),SPELL_CSLUMBER); - m_creature->CastSpell(m_creature->getVictim(),SPELL_CSLUMBER, true); - - //Stop attacking target thast asleep and pick new target - Cslumber_Timer = 28000; - - Unit* Target = SelectUnit(SELECT_TARGET_TOPAGGRO, 0); - - if (!Target || Target == m_creature->getVictim()) - Target = SelectUnit(SELECT_TARGET_RANDOM, 0); - - if (Target) - m_creature->TauntApply(Target); - - }else Cslumber_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; - -CreatureAI* GetAI_mob_jadespine_basilisk(Creature *_Creature) -{ - return new mob_jadespine_basiliskAI (_Creature); -} - -/*###### -## npc_lore_keeper_of_norgannon -######*/ - -bool GossipHello_npc_lore_keeper_of_norgannon(Player *player, Creature *_Creature) -{ - if (player->GetQuestStatus(2278) == QUEST_STATUS_INCOMPLETE) - player->ADD_GOSSIP_ITEM( 0, "Who are the Earthen?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); - - player->SEND_GOSSIP_MENU(1079, _Creature->GetGUID()); - - return true; -} - -bool GossipSelect_npc_lore_keeper_of_norgannon(Player *player, Creature *_Creature, uint32 sender, uint32 action) -{ - switch (action) - { - case GOSSIP_ACTION_INFO_DEF+1: - player->ADD_GOSSIP_ITEM( 0, "What is a \"subterranean being matrix\"?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2); - player->SEND_GOSSIP_MENU(1080, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+2: - player->ADD_GOSSIP_ITEM( 0, "What are the anomalies you speak of?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+3); - player->SEND_GOSSIP_MENU(1081, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+3: - player->ADD_GOSSIP_ITEM( 0, "What is a resilient foundation of construction?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+4); - player->SEND_GOSSIP_MENU(1082, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+4: - player->ADD_GOSSIP_ITEM( 0, "So... the Earthen were made out of stone?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+5); - player->SEND_GOSSIP_MENU(1083, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+5: - player->ADD_GOSSIP_ITEM( 0, "Anything else I should know about the Earthen?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+6); - player->SEND_GOSSIP_MENU(1084, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+6: - player->ADD_GOSSIP_ITEM( 0, "I think I understand the Creators' design intent for the Earthen now. What are the Earthen's anomalies that you spoke of earlier?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+7); - player->SEND_GOSSIP_MENU(1085, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+7: - player->ADD_GOSSIP_ITEM( 0, "What high-stress environments would cause the Earthen to destabilize?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+8); - player->SEND_GOSSIP_MENU(1086, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+8: - player->ADD_GOSSIP_ITEM( 0, "What happens when the Earthen destabilize?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+9); - player->SEND_GOSSIP_MENU(1087, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+9: - player->ADD_GOSSIP_ITEM( 0, "Troggs?! Are the troggs you mention the same as the ones in the world today?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+10); - player->SEND_GOSSIP_MENU(1088, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+10: - player->ADD_GOSSIP_ITEM( 0, "You mentioned two results when the Earthen destabilize. What is the second?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+11); - player->SEND_GOSSIP_MENU(1089, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+11: - player->ADD_GOSSIP_ITEM( 0, "Dwarves!!! Now you're telling me that dwarves originally came from the Earthen?!", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+12); - player->SEND_GOSSIP_MENU(1090, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+12: - player->ADD_GOSSIP_ITEM( 0, "These dwarves are the same ones today, yes? Do the dwarves maintain any other links to the Earthen?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+13); - player->SEND_GOSSIP_MENU(1091, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+13: - player->ADD_GOSSIP_ITEM( 0, "Who are the Creators?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+14); - player->SEND_GOSSIP_MENU(1092, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+14: - player->ADD_GOSSIP_ITEM( 0, "This is a lot to think about.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+15); - player->SEND_GOSSIP_MENU(1093, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+15: - player->ADD_GOSSIP_ITEM( 0, "I will access the discs now.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+16); - player->SEND_GOSSIP_MENU(1094, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+16: - player->CLOSE_GOSSIP_MENU(); - player->AreaExploredOrEventHappens(2278); - break; - } - return true; -} - -void AddSC_uldaman() -{ - Script *newscript; - - newscript = new Script; - newscript->Name="mob_jadespine_basilisk"; - newscript->GetAI = GetAI_mob_jadespine_basilisk; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="npc_lore_keeper_of_norgannon"; - newscript->pGossipHello = &GossipHello_npc_lore_keeper_of_norgannon; - newscript->pGossipSelect = &GossipSelect_npc_lore_keeper_of_norgannon; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Uldaman +SD%Complete: 100 +SDComment: Quest support: 2278 + 1 trash mob. +SDCategory: Uldaman +EndScriptData */ + +/* ContentData +mob_jadespine_basilisk +npc_lore_keeper_of_norgannon +EndContentData */ + +#include "precompiled.h" + +/*###### +## mob_jadespine_basilisk +######*/ + +#define SPELL_CSLUMBER 3636 + +struct MANGOS_DLL_DECL mob_jadespine_basiliskAI : public ScriptedAI +{ + mob_jadespine_basiliskAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 Cslumber_Timer; + + void Reset() + { + Cslumber_Timer = 2000; + } + + void Aggro(Unit *who) + { + } + + void UpdateAI(const uint32 diff) + { + //Return since we have no target + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + //Cslumber_Timer + if (Cslumber_Timer < diff) + { + //Cast + // DoCast(m_creature->getVictim(),SPELL_CSLUMBER); + m_creature->CastSpell(m_creature->getVictim(),SPELL_CSLUMBER, true); + + //Stop attacking target thast asleep and pick new target + Cslumber_Timer = 28000; + + Unit* Target = SelectUnit(SELECT_TARGET_TOPAGGRO, 0); + + if (!Target || Target == m_creature->getVictim()) + Target = SelectUnit(SELECT_TARGET_RANDOM, 0); + + if (Target) + m_creature->TauntApply(Target); + + }else Cslumber_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; + +CreatureAI* GetAI_mob_jadespine_basilisk(Creature *_Creature) +{ + return new mob_jadespine_basiliskAI (_Creature); +} + +/*###### +## npc_lore_keeper_of_norgannon +######*/ + +bool GossipHello_npc_lore_keeper_of_norgannon(Player *player, Creature *_Creature) +{ + if (player->GetQuestStatus(2278) == QUEST_STATUS_INCOMPLETE) + player->ADD_GOSSIP_ITEM( 0, "Who are the Earthen?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); + + player->SEND_GOSSIP_MENU(1079, _Creature->GetGUID()); + + return true; +} + +bool GossipSelect_npc_lore_keeper_of_norgannon(Player *player, Creature *_Creature, uint32 sender, uint32 action) +{ + switch (action) + { + case GOSSIP_ACTION_INFO_DEF+1: + player->ADD_GOSSIP_ITEM( 0, "What is a \"subterranean being matrix\"?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2); + player->SEND_GOSSIP_MENU(1080, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+2: + player->ADD_GOSSIP_ITEM( 0, "What are the anomalies you speak of?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+3); + player->SEND_GOSSIP_MENU(1081, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+3: + player->ADD_GOSSIP_ITEM( 0, "What is a resilient foundation of construction?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+4); + player->SEND_GOSSIP_MENU(1082, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+4: + player->ADD_GOSSIP_ITEM( 0, "So... the Earthen were made out of stone?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+5); + player->SEND_GOSSIP_MENU(1083, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+5: + player->ADD_GOSSIP_ITEM( 0, "Anything else I should know about the Earthen?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+6); + player->SEND_GOSSIP_MENU(1084, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+6: + player->ADD_GOSSIP_ITEM( 0, "I think I understand the Creators' design intent for the Earthen now. What are the Earthen's anomalies that you spoke of earlier?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+7); + player->SEND_GOSSIP_MENU(1085, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+7: + player->ADD_GOSSIP_ITEM( 0, "What high-stress environments would cause the Earthen to destabilize?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+8); + player->SEND_GOSSIP_MENU(1086, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+8: + player->ADD_GOSSIP_ITEM( 0, "What happens when the Earthen destabilize?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+9); + player->SEND_GOSSIP_MENU(1087, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+9: + player->ADD_GOSSIP_ITEM( 0, "Troggs?! Are the troggs you mention the same as the ones in the world today?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+10); + player->SEND_GOSSIP_MENU(1088, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+10: + player->ADD_GOSSIP_ITEM( 0, "You mentioned two results when the Earthen destabilize. What is the second?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+11); + player->SEND_GOSSIP_MENU(1089, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+11: + player->ADD_GOSSIP_ITEM( 0, "Dwarves!!! Now you're telling me that dwarves originally came from the Earthen?!", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+12); + player->SEND_GOSSIP_MENU(1090, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+12: + player->ADD_GOSSIP_ITEM( 0, "These dwarves are the same ones today, yes? Do the dwarves maintain any other links to the Earthen?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+13); + player->SEND_GOSSIP_MENU(1091, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+13: + player->ADD_GOSSIP_ITEM( 0, "Who are the Creators?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+14); + player->SEND_GOSSIP_MENU(1092, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+14: + player->ADD_GOSSIP_ITEM( 0, "This is a lot to think about.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+15); + player->SEND_GOSSIP_MENU(1093, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+15: + player->ADD_GOSSIP_ITEM( 0, "I will access the discs now.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+16); + player->SEND_GOSSIP_MENU(1094, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+16: + player->CLOSE_GOSSIP_MENU(); + player->AreaExploredOrEventHappens(2278); + break; + } + return true; +} + +void AddSC_uldaman() +{ + Script *newscript; + + newscript = new Script; + newscript->Name="mob_jadespine_basilisk"; + newscript->GetAI = GetAI_mob_jadespine_basilisk; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="npc_lore_keeper_of_norgannon"; + newscript->pGossipHello = &GossipHello_npc_lore_keeper_of_norgannon; + newscript->pGossipSelect = &GossipSelect_npc_lore_keeper_of_norgannon; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/undercity/undercity.cpp b/src/bindings/scripts/scripts/zone/undercity/undercity.cpp index b4845317612..93ef0584c99 100644 --- a/src/bindings/scripts/scripts/zone/undercity/undercity.cpp +++ b/src/bindings/scripts/scripts/zone/undercity/undercity.cpp @@ -1,260 +1,260 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Undercity -SD%Complete: 95 -SDComment: Quest support: 6628(Parqual Fintallas questions/'answers' might have more to it, need more info), 9180(post-event). -SDCategory: Undercity -EndScriptData */ - -/* ContentData -npc_lady_sylvanas_windrunner -npc_highborne_lamenter -npc_parqual_fintallas -EndContentData */ - -#include "precompiled.h" - -/*###### -## npc_lady_sylvanas_windrunner -######*/ - -#define SAY_LAMENT_END "Belore..." -#define EMOTE_LAMENT_END "kneels down and pick up the amulet." - -#define SOUND_CREDIT 10896 -#define ENTRY_HIGHBORNE_LAMENTER 21628 -#define ENTRY_HIGHBORNE_BUNNY 21641 - -#define SPELL_HIGHBORNE_AURA 37090 -#define SPELL_SYLVANAS_CAST 36568 -#define SPELL_RIBBON_OF_SOULS 34432 //the real one to use might be 37099 - -float HighborneLoc[4][3]= -{ - {1285.41, 312.47, 0.51}, - {1286.96, 310.40, 1.00}, - {1289.66, 309.66, 1.52}, - {1292.51, 310.50, 1.99}, -}; -#define HIGHBORNE_LOC_Y -61.00 -#define HIGHBORNE_LOC_Y_NEW -55.50 - -struct MANGOS_DLL_DECL npc_lady_sylvanas_windrunnerAI : public ScriptedAI -{ - npc_lady_sylvanas_windrunnerAI(Creature *c) : ScriptedAI(c) { Reset(); } - - uint32 LamentEvent_Timer; - bool LamentEvent; - uint64 targetGUID; - - float myX; - float myY; - float myZ; - - void Reset() - { - myX = m_creature->GetPositionX(); - myY = m_creature->GetPositionY(); - myZ = m_creature->GetPositionZ(); - - LamentEvent_Timer = 5000; - LamentEvent = false; - targetGUID = 0; - } - - void Aggro(Unit *who) {} - - void JustSummoned(Creature *summoned) - { - if( summoned->GetEntry() == ENTRY_HIGHBORNE_BUNNY ) - { - if( Unit* target = Unit::GetUnit(*summoned,targetGUID) ) - { - target->SendMonsterMove(target->GetPositionX(),target->GetPositionY(),myZ+15.0,0,0,0); - target->Relocate(target->GetPositionX(),target->GetPositionY(),myZ+15.0); - summoned->CastSpell(target,SPELL_RIBBON_OF_SOULS,false); - } - - summoned->AddUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT); - targetGUID = summoned->GetGUID(); - } - } - - void UpdateAI(const uint32 diff) - { - if( LamentEvent ) - { - if( LamentEvent_Timer < diff ) - { - float raX = myX; - float raY = myY; - float raZ = myZ; - - m_creature->GetRandomPoint(myX,myY,myZ,20.0,raX,raY,raZ); - m_creature->SummonCreature(ENTRY_HIGHBORNE_BUNNY,raX,raY,myZ,0,TEMPSUMMON_TIMED_DESPAWN,3000); - - LamentEvent_Timer = 2000; - if( !m_creature->HasAura(SPELL_SYLVANAS_CAST,0) ) - { - DoSay(SAY_LAMENT_END,LANG_UNIVERSAL,NULL); - DoTextEmote(EMOTE_LAMENT_END,NULL); - LamentEvent = false; - } - }else LamentEvent_Timer -= diff; - } - - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - DoMeleeAttackIfReady(); - } -}; -CreatureAI* GetAI_npc_lady_sylvanas_windrunner(Creature *_Creature) -{ - return new npc_lady_sylvanas_windrunnerAI (_Creature); -} - -bool ChooseReward_npc_lady_sylvanas_windrunner(Player *player, Creature *_Creature, const Quest *_Quest, uint32 slot) -{ - if( _Quest->GetQuestId() == 9180 ) - { - ((npc_lady_sylvanas_windrunnerAI*)_Creature->AI())->LamentEvent = true; - ((npc_lady_sylvanas_windrunnerAI*)_Creature->AI())->DoPlaySoundToSet(_Creature,SOUND_CREDIT); - _Creature->CastSpell(_Creature,SPELL_SYLVANAS_CAST,false); - - for( uint8 i = 0; i < 4; i++ ) - _Creature->SummonCreature(ENTRY_HIGHBORNE_LAMENTER, HighborneLoc[i][0], HighborneLoc[i][1], HIGHBORNE_LOC_Y, HighborneLoc[i][2], TEMPSUMMON_TIMED_DESPAWN, 160000); - } - - return true; -} - -/*###### -## npc_highborne_lamenter -######*/ - -struct MANGOS_DLL_DECL npc_highborne_lamenterAI : public ScriptedAI -{ - npc_highborne_lamenterAI(Creature *c) : ScriptedAI(c) { Reset(); } - - uint32 EventMove_Timer; - uint32 EventCast_Timer; - bool EventMove; - bool EventCast; - - void Reset() - { - EventMove_Timer = 10000; - EventCast_Timer = 17500; - EventMove = true; - EventCast = true; - } - - void Aggro(Unit *who) {} - - void UpdateAI(const uint32 diff) - { - if( EventMove ) - { - if( EventMove_Timer < diff ) - { - m_creature->AddUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT | MOVEMENTFLAG_LEVITATING); - m_creature->SendMonsterMoveWithSpeed(m_creature->GetPositionX(),m_creature->GetPositionY(),HIGHBORNE_LOC_Y_NEW,MOVEMENTFLAG_ONTRANSPORT,5000); - m_creature->GetMap()->CreatureRelocation(m_creature,m_creature->GetPositionX(),m_creature->GetPositionY(),HIGHBORNE_LOC_Y_NEW,m_creature->GetOrientation()); - EventMove = false; - }else EventMove_Timer -= diff; - } - if( EventCast ) - { - if( EventCast_Timer < diff ) - { - DoCast(m_creature,SPELL_HIGHBORNE_AURA); - EventCast = false; - }else EventCast_Timer -= diff; - } - } -}; -CreatureAI* GetAI_npc_highborne_lamenter(Creature *_Creature) -{ - return new npc_highborne_lamenterAI (_Creature); -} - -/*###### -## npc_parqual_fintallas -######*/ - -#define SPELL_MARK_OF_SHAME 6767 - -bool GossipHello_npc_parqual_fintallas(Player *player, Creature *_Creature) -{ - if (_Creature->isQuestGiver()) - player->PrepareQuestMenu( _Creature->GetGUID() ); - - if (player->GetQuestStatus(6628) == QUEST_STATUS_INCOMPLETE && !player->HasAura(SPELL_MARK_OF_SHAME,0) ) - { - player->ADD_GOSSIP_ITEM( 0, "Gul'dan", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); - player->ADD_GOSSIP_ITEM( 0, "Kel'Thuzad", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); - player->ADD_GOSSIP_ITEM( 0, "Ner'zhul", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2); - player->SEND_GOSSIP_MENU(5822, _Creature->GetGUID()); - } - else - player->SEND_GOSSIP_MENU(5821, _Creature->GetGUID()); - - return true; -} - -bool GossipSelect_npc_parqual_fintallas(Player *player, Creature *_Creature, uint32 sender, uint32 action) -{ - if (action == GOSSIP_ACTION_INFO_DEF+1) - { - player->CLOSE_GOSSIP_MENU(); - _Creature->CastSpell(player,SPELL_MARK_OF_SHAME,false); - } - if (action == GOSSIP_ACTION_INFO_DEF+2) - { - player->CLOSE_GOSSIP_MENU(); - player->AreaExploredOrEventHappens(6628); - } - return true; -} - -/*###### -## AddSC -######*/ - -void AddSC_undercity() -{ - Script *newscript; - - newscript = new Script; - newscript->Name="npc_lady_sylvanas_windrunner"; - newscript->GetAI = GetAI_npc_lady_sylvanas_windrunner; - newscript->pChooseReward = &ChooseReward_npc_lady_sylvanas_windrunner; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="npc_highborne_lamenter"; - newscript->GetAI = GetAI_npc_highborne_lamenter; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="npc_parqual_fintallas"; - newscript->pGossipHello = &GossipHello_npc_parqual_fintallas; - newscript->pGossipSelect = &GossipSelect_npc_parqual_fintallas; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Undercity +SD%Complete: 95 +SDComment: Quest support: 6628(Parqual Fintallas questions/'answers' might have more to it, need more info), 9180(post-event). +SDCategory: Undercity +EndScriptData */ + +/* ContentData +npc_lady_sylvanas_windrunner +npc_highborne_lamenter +npc_parqual_fintallas +EndContentData */ + +#include "precompiled.h" + +/*###### +## npc_lady_sylvanas_windrunner +######*/ + +#define SAY_LAMENT_END "Belore..." +#define EMOTE_LAMENT_END "kneels down and pick up the amulet." + +#define SOUND_CREDIT 10896 +#define ENTRY_HIGHBORNE_LAMENTER 21628 +#define ENTRY_HIGHBORNE_BUNNY 21641 + +#define SPELL_HIGHBORNE_AURA 37090 +#define SPELL_SYLVANAS_CAST 36568 +#define SPELL_RIBBON_OF_SOULS 34432 //the real one to use might be 37099 + +float HighborneLoc[4][3]= +{ + {1285.41, 312.47, 0.51}, + {1286.96, 310.40, 1.00}, + {1289.66, 309.66, 1.52}, + {1292.51, 310.50, 1.99}, +}; +#define HIGHBORNE_LOC_Y -61.00 +#define HIGHBORNE_LOC_Y_NEW -55.50 + +struct MANGOS_DLL_DECL npc_lady_sylvanas_windrunnerAI : public ScriptedAI +{ + npc_lady_sylvanas_windrunnerAI(Creature *c) : ScriptedAI(c) { Reset(); } + + uint32 LamentEvent_Timer; + bool LamentEvent; + uint64 targetGUID; + + float myX; + float myY; + float myZ; + + void Reset() + { + myX = m_creature->GetPositionX(); + myY = m_creature->GetPositionY(); + myZ = m_creature->GetPositionZ(); + + LamentEvent_Timer = 5000; + LamentEvent = false; + targetGUID = 0; + } + + void Aggro(Unit *who) {} + + void JustSummoned(Creature *summoned) + { + if( summoned->GetEntry() == ENTRY_HIGHBORNE_BUNNY ) + { + if( Unit* target = Unit::GetUnit(*summoned,targetGUID) ) + { + target->SendMonsterMove(target->GetPositionX(),target->GetPositionY(),myZ+15.0,0,0,0); + target->Relocate(target->GetPositionX(),target->GetPositionY(),myZ+15.0); + summoned->CastSpell(target,SPELL_RIBBON_OF_SOULS,false); + } + + summoned->AddUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT); + targetGUID = summoned->GetGUID(); + } + } + + void UpdateAI(const uint32 diff) + { + if( LamentEvent ) + { + if( LamentEvent_Timer < diff ) + { + float raX = myX; + float raY = myY; + float raZ = myZ; + + m_creature->GetRandomPoint(myX,myY,myZ,20.0,raX,raY,raZ); + m_creature->SummonCreature(ENTRY_HIGHBORNE_BUNNY,raX,raY,myZ,0,TEMPSUMMON_TIMED_DESPAWN,3000); + + LamentEvent_Timer = 2000; + if( !m_creature->HasAura(SPELL_SYLVANAS_CAST,0) ) + { + DoSay(SAY_LAMENT_END,LANG_UNIVERSAL,NULL); + DoTextEmote(EMOTE_LAMENT_END,NULL); + LamentEvent = false; + } + }else LamentEvent_Timer -= diff; + } + + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + DoMeleeAttackIfReady(); + } +}; +CreatureAI* GetAI_npc_lady_sylvanas_windrunner(Creature *_Creature) +{ + return new npc_lady_sylvanas_windrunnerAI (_Creature); +} + +bool ChooseReward_npc_lady_sylvanas_windrunner(Player *player, Creature *_Creature, const Quest *_Quest, uint32 slot) +{ + if( _Quest->GetQuestId() == 9180 ) + { + ((npc_lady_sylvanas_windrunnerAI*)_Creature->AI())->LamentEvent = true; + ((npc_lady_sylvanas_windrunnerAI*)_Creature->AI())->DoPlaySoundToSet(_Creature,SOUND_CREDIT); + _Creature->CastSpell(_Creature,SPELL_SYLVANAS_CAST,false); + + for( uint8 i = 0; i < 4; i++ ) + _Creature->SummonCreature(ENTRY_HIGHBORNE_LAMENTER, HighborneLoc[i][0], HighborneLoc[i][1], HIGHBORNE_LOC_Y, HighborneLoc[i][2], TEMPSUMMON_TIMED_DESPAWN, 160000); + } + + return true; +} + +/*###### +## npc_highborne_lamenter +######*/ + +struct MANGOS_DLL_DECL npc_highborne_lamenterAI : public ScriptedAI +{ + npc_highborne_lamenterAI(Creature *c) : ScriptedAI(c) { Reset(); } + + uint32 EventMove_Timer; + uint32 EventCast_Timer; + bool EventMove; + bool EventCast; + + void Reset() + { + EventMove_Timer = 10000; + EventCast_Timer = 17500; + EventMove = true; + EventCast = true; + } + + void Aggro(Unit *who) {} + + void UpdateAI(const uint32 diff) + { + if( EventMove ) + { + if( EventMove_Timer < diff ) + { + m_creature->AddUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT | MOVEMENTFLAG_LEVITATING); + m_creature->SendMonsterMoveWithSpeed(m_creature->GetPositionX(),m_creature->GetPositionY(),HIGHBORNE_LOC_Y_NEW,MOVEMENTFLAG_ONTRANSPORT,5000); + m_creature->GetMap()->CreatureRelocation(m_creature,m_creature->GetPositionX(),m_creature->GetPositionY(),HIGHBORNE_LOC_Y_NEW,m_creature->GetOrientation()); + EventMove = false; + }else EventMove_Timer -= diff; + } + if( EventCast ) + { + if( EventCast_Timer < diff ) + { + DoCast(m_creature,SPELL_HIGHBORNE_AURA); + EventCast = false; + }else EventCast_Timer -= diff; + } + } +}; +CreatureAI* GetAI_npc_highborne_lamenter(Creature *_Creature) +{ + return new npc_highborne_lamenterAI (_Creature); +} + +/*###### +## npc_parqual_fintallas +######*/ + +#define SPELL_MARK_OF_SHAME 6767 + +bool GossipHello_npc_parqual_fintallas(Player *player, Creature *_Creature) +{ + if (_Creature->isQuestGiver()) + player->PrepareQuestMenu( _Creature->GetGUID() ); + + if (player->GetQuestStatus(6628) == QUEST_STATUS_INCOMPLETE && !player->HasAura(SPELL_MARK_OF_SHAME,0) ) + { + player->ADD_GOSSIP_ITEM( 0, "Gul'dan", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); + player->ADD_GOSSIP_ITEM( 0, "Kel'Thuzad", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); + player->ADD_GOSSIP_ITEM( 0, "Ner'zhul", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2); + player->SEND_GOSSIP_MENU(5822, _Creature->GetGUID()); + } + else + player->SEND_GOSSIP_MENU(5821, _Creature->GetGUID()); + + return true; +} + +bool GossipSelect_npc_parqual_fintallas(Player *player, Creature *_Creature, uint32 sender, uint32 action) +{ + if (action == GOSSIP_ACTION_INFO_DEF+1) + { + player->CLOSE_GOSSIP_MENU(); + _Creature->CastSpell(player,SPELL_MARK_OF_SHAME,false); + } + if (action == GOSSIP_ACTION_INFO_DEF+2) + { + player->CLOSE_GOSSIP_MENU(); + player->AreaExploredOrEventHappens(6628); + } + return true; +} + +/*###### +## AddSC +######*/ + +void AddSC_undercity() +{ + Script *newscript; + + newscript = new Script; + newscript->Name="npc_lady_sylvanas_windrunner"; + newscript->GetAI = GetAI_npc_lady_sylvanas_windrunner; + newscript->pChooseReward = &ChooseReward_npc_lady_sylvanas_windrunner; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="npc_highborne_lamenter"; + newscript->GetAI = GetAI_npc_highborne_lamenter; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="npc_parqual_fintallas"; + newscript->pGossipHello = &GossipHello_npc_parqual_fintallas; + newscript->pGossipSelect = &GossipSelect_npc_parqual_fintallas; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/wailing_caverns/instance_wailing_caverns.cpp b/src/bindings/scripts/scripts/zone/wailing_caverns/instance_wailing_caverns.cpp index a67db38d4ed..963accb14a8 100644 --- a/src/bindings/scripts/scripts/zone/wailing_caverns/instance_wailing_caverns.cpp +++ b/src/bindings/scripts/scripts/zone/wailing_caverns/instance_wailing_caverns.cpp @@ -1,24 +1,24 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Instance_Wailing_Caverns -SD%Complete: 0 -SDComment: Placeholder -SDCategory: Wailing Caverns -EndScriptData */ - -#include "precompiled.h" +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Instance_Wailing_Caverns +SD%Complete: 0 +SDComment: Placeholder +SDCategory: Wailing Caverns +EndScriptData */ + +#include "precompiled.h" diff --git a/src/bindings/scripts/scripts/zone/western_plaguelands/western_plaguelands.cpp b/src/bindings/scripts/scripts/zone/western_plaguelands/western_plaguelands.cpp index d6a20fb5cca..e0eede13e5d 100644 --- a/src/bindings/scripts/scripts/zone/western_plaguelands/western_plaguelands.cpp +++ b/src/bindings/scripts/scripts/zone/western_plaguelands/western_plaguelands.cpp @@ -1,176 +1,176 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Western_Plaguelands -SD%Complete: 90 -SDComment: Quest support: 5216,5219,5222,5225,5229,5231,5233,5235. To obtain Vitreous Focuser (could use more spesifics about gossip items) -SDCategory: Western Plaguelands -EndScriptData */ - -/* ContentData -npcs_dithers_and_arbington -npc_the_scourge_cauldron -EndContentData */ - -#include "precompiled.h" - -/*###### -## npcs_dithers_and_arbington -######*/ - -bool GossipHello_npcs_dithers_and_arbington(Player *player, Creature *_Creature) -{ - if(_Creature->isQuestGiver()) - player->PrepareQuestMenu( _Creature->GetGUID() ); - if (_Creature->isVendor()) - player->ADD_GOSSIP_ITEM(1, GOSSIP_TEXT_BROWSE_GOODS, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_TRADE); - - if(player->GetQuestRewardStatus(5237) || player->GetQuestRewardStatus(5238)) - { - player->ADD_GOSSIP_ITEM(0, "What does the Felstone Field Cauldron need?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); - player->ADD_GOSSIP_ITEM(0, "What does the Dalson's Tears Cauldron need?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2); - player->ADD_GOSSIP_ITEM(0, "What does the Writhing Haunt Cauldron need?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+3); - player->ADD_GOSSIP_ITEM(0, "What does the Gahrron's Withering Cauldron need?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+4); - player->SEND_GOSSIP_MENU(3985, _Creature->GetGUID()); - }else - player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); - - return true; -} - -bool GossipSelect_npcs_dithers_and_arbington(Player *player, Creature *_Creature, uint32 sender, uint32 action) -{ - switch(action) - { - case GOSSIP_ACTION_TRADE: - player->SEND_VENDORLIST( _Creature->GetGUID() ); - break; - case GOSSIP_ACTION_INFO_DEF+1: - player->ADD_GOSSIP_ITEM(0, "Thanks, i need a Vitreous Focuser", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+5); - player->SEND_GOSSIP_MENU(3980, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+2: - player->ADD_GOSSIP_ITEM(0, "Thanks, i need a Vitreous Focuser", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+5); - player->SEND_GOSSIP_MENU(3981, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+3: - player->ADD_GOSSIP_ITEM(0, "Thanks, i need a Vitreous Focuser", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+5); - player->SEND_GOSSIP_MENU(3982, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+4: - player->ADD_GOSSIP_ITEM(0, "Thanks, i need a Vitreous Focuser", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+5); - player->SEND_GOSSIP_MENU(3983, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+5: - player->CLOSE_GOSSIP_MENU(); - _Creature->CastSpell(player, 17529, false); - break; - } - return true; -} - -/*###### -## npc_the_scourge_cauldron -######*/ - -struct MANGOS_DLL_DECL npc_the_scourge_cauldronAI : public ScriptedAI -{ - npc_the_scourge_cauldronAI(Creature *c) : ScriptedAI(c) {Reset();} - - void Reset() {} - - void Aggro(Unit* who) {} - - void DoDie() - { - //summoner dies here - m_creature->DealDamage(m_creature, m_creature->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); - //override any database `spawntimesecs` to prevent duplicated summons - uint32 rTime = m_creature->GetRespawnDelay(); - if( rTime<600 ) - m_creature->SetRespawnDelay(600); - } - - void MoveInLineOfSight(Unit *who) - { - if (!who || who->GetTypeId() != TYPEID_PLAYER) - return; - - if(who->GetTypeId() == TYPEID_PLAYER) - { - switch(m_creature->GetAreaId()) - { - case 199: //felstone - if( ((Player*)who)->GetQuestStatus(5216) == QUEST_STATUS_INCOMPLETE || - ((Player*)who)->GetQuestStatus(5229) == QUEST_STATUS_INCOMPLETE ) - { - DoSpawnCreature(11075,0,0,0,m_creature->GetOrientation(),TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,600000); - DoDie(); - } - break; - case 200: //dalson - if( ((Player*)who)->GetQuestStatus(5219) == QUEST_STATUS_INCOMPLETE || - ((Player*)who)->GetQuestStatus(5231) == QUEST_STATUS_INCOMPLETE ) - { - DoSpawnCreature(11077,0,0,0,m_creature->GetOrientation(),TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,600000); - DoDie(); - } - break; - case 201: //gahrron - if( ((Player*)who)->GetQuestStatus(5225) == QUEST_STATUS_INCOMPLETE || - ((Player*)who)->GetQuestStatus(5235) == QUEST_STATUS_INCOMPLETE ) - { - DoSpawnCreature(11078,0,0,0,m_creature->GetOrientation(),TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,600000); - DoDie(); - } - break; - case 202: //writhing - if( ((Player*)who)->GetQuestStatus(5222) == QUEST_STATUS_INCOMPLETE || - ((Player*)who)->GetQuestStatus(5233) == QUEST_STATUS_INCOMPLETE ) - { - DoSpawnCreature(11076,0,0,0,m_creature->GetOrientation(),TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,600000); - DoDie(); - } - break; - } - } - } -}; -CreatureAI* GetAI_npc_the_scourge_cauldron(Creature *_Creature) -{ - return new npc_the_scourge_cauldronAI (_Creature); -} - -/*###### -## -######*/ - -void AddSC_western_plaguelands() -{ - Script *newscript; - - newscript = new Script; - newscript->Name="npcs_dithers_and_arbington"; - newscript->pGossipHello = &GossipHello_npcs_dithers_and_arbington; - newscript->pGossipSelect = &GossipSelect_npcs_dithers_and_arbington; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="npc_the_scourge_cauldron"; - newscript->GetAI = GetAI_npc_the_scourge_cauldron; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Western_Plaguelands +SD%Complete: 90 +SDComment: Quest support: 5216,5219,5222,5225,5229,5231,5233,5235. To obtain Vitreous Focuser (could use more spesifics about gossip items) +SDCategory: Western Plaguelands +EndScriptData */ + +/* ContentData +npcs_dithers_and_arbington +npc_the_scourge_cauldron +EndContentData */ + +#include "precompiled.h" + +/*###### +## npcs_dithers_and_arbington +######*/ + +bool GossipHello_npcs_dithers_and_arbington(Player *player, Creature *_Creature) +{ + if(_Creature->isQuestGiver()) + player->PrepareQuestMenu( _Creature->GetGUID() ); + if (_Creature->isVendor()) + player->ADD_GOSSIP_ITEM(1, GOSSIP_TEXT_BROWSE_GOODS, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_TRADE); + + if(player->GetQuestRewardStatus(5237) || player->GetQuestRewardStatus(5238)) + { + player->ADD_GOSSIP_ITEM(0, "What does the Felstone Field Cauldron need?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); + player->ADD_GOSSIP_ITEM(0, "What does the Dalson's Tears Cauldron need?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2); + player->ADD_GOSSIP_ITEM(0, "What does the Writhing Haunt Cauldron need?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+3); + player->ADD_GOSSIP_ITEM(0, "What does the Gahrron's Withering Cauldron need?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+4); + player->SEND_GOSSIP_MENU(3985, _Creature->GetGUID()); + }else + player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); + + return true; +} + +bool GossipSelect_npcs_dithers_and_arbington(Player *player, Creature *_Creature, uint32 sender, uint32 action) +{ + switch(action) + { + case GOSSIP_ACTION_TRADE: + player->SEND_VENDORLIST( _Creature->GetGUID() ); + break; + case GOSSIP_ACTION_INFO_DEF+1: + player->ADD_GOSSIP_ITEM(0, "Thanks, i need a Vitreous Focuser", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+5); + player->SEND_GOSSIP_MENU(3980, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+2: + player->ADD_GOSSIP_ITEM(0, "Thanks, i need a Vitreous Focuser", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+5); + player->SEND_GOSSIP_MENU(3981, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+3: + player->ADD_GOSSIP_ITEM(0, "Thanks, i need a Vitreous Focuser", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+5); + player->SEND_GOSSIP_MENU(3982, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+4: + player->ADD_GOSSIP_ITEM(0, "Thanks, i need a Vitreous Focuser", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+5); + player->SEND_GOSSIP_MENU(3983, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+5: + player->CLOSE_GOSSIP_MENU(); + _Creature->CastSpell(player, 17529, false); + break; + } + return true; +} + +/*###### +## npc_the_scourge_cauldron +######*/ + +struct MANGOS_DLL_DECL npc_the_scourge_cauldronAI : public ScriptedAI +{ + npc_the_scourge_cauldronAI(Creature *c) : ScriptedAI(c) {Reset();} + + void Reset() {} + + void Aggro(Unit* who) {} + + void DoDie() + { + //summoner dies here + m_creature->DealDamage(m_creature, m_creature->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); + //override any database `spawntimesecs` to prevent duplicated summons + uint32 rTime = m_creature->GetRespawnDelay(); + if( rTime<600 ) + m_creature->SetRespawnDelay(600); + } + + void MoveInLineOfSight(Unit *who) + { + if (!who || who->GetTypeId() != TYPEID_PLAYER) + return; + + if(who->GetTypeId() == TYPEID_PLAYER) + { + switch(m_creature->GetAreaId()) + { + case 199: //felstone + if( ((Player*)who)->GetQuestStatus(5216) == QUEST_STATUS_INCOMPLETE || + ((Player*)who)->GetQuestStatus(5229) == QUEST_STATUS_INCOMPLETE ) + { + DoSpawnCreature(11075,0,0,0,m_creature->GetOrientation(),TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,600000); + DoDie(); + } + break; + case 200: //dalson + if( ((Player*)who)->GetQuestStatus(5219) == QUEST_STATUS_INCOMPLETE || + ((Player*)who)->GetQuestStatus(5231) == QUEST_STATUS_INCOMPLETE ) + { + DoSpawnCreature(11077,0,0,0,m_creature->GetOrientation(),TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,600000); + DoDie(); + } + break; + case 201: //gahrron + if( ((Player*)who)->GetQuestStatus(5225) == QUEST_STATUS_INCOMPLETE || + ((Player*)who)->GetQuestStatus(5235) == QUEST_STATUS_INCOMPLETE ) + { + DoSpawnCreature(11078,0,0,0,m_creature->GetOrientation(),TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,600000); + DoDie(); + } + break; + case 202: //writhing + if( ((Player*)who)->GetQuestStatus(5222) == QUEST_STATUS_INCOMPLETE || + ((Player*)who)->GetQuestStatus(5233) == QUEST_STATUS_INCOMPLETE ) + { + DoSpawnCreature(11076,0,0,0,m_creature->GetOrientation(),TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,600000); + DoDie(); + } + break; + } + } + } +}; +CreatureAI* GetAI_npc_the_scourge_cauldron(Creature *_Creature) +{ + return new npc_the_scourge_cauldronAI (_Creature); +} + +/*###### +## +######*/ + +void AddSC_western_plaguelands() +{ + Script *newscript; + + newscript = new Script; + newscript->Name="npcs_dithers_and_arbington"; + newscript->pGossipHello = &GossipHello_npcs_dithers_and_arbington; + newscript->pGossipSelect = &GossipSelect_npcs_dithers_and_arbington; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="npc_the_scourge_cauldron"; + newscript->GetAI = GetAI_npc_the_scourge_cauldron; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/winterspring/winterspring.cpp b/src/bindings/scripts/scripts/zone/winterspring/winterspring.cpp index fa3ef8dd027..e430f497104 100644 --- a/src/bindings/scripts/scripts/zone/winterspring/winterspring.cpp +++ b/src/bindings/scripts/scripts/zone/winterspring/winterspring.cpp @@ -1,157 +1,157 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Winterspring -SD%Complete: 90 -SDComment: Quest support: 5126 (Loraxs' tale missing proper gossip items text). Vendor Rivern Frostwind. Obtain Cache of Mau'ari -SDCategory: Winterspring -EndScriptData */ - -/* ContentData -npc_lorax -npc_rivern_frostwind -npc_witch_doctor_mauari -EndContentData */ - -#include "precompiled.h" - -/*###### -## npc_lorax -######*/ - -bool GossipHello_npc_lorax(Player *player, Creature *_Creature) -{ - if (_Creature->isQuestGiver()) - player->PrepareQuestMenu( _Creature->GetGUID() ); - - if (player->GetQuestStatus(5126) == QUEST_STATUS_INCOMPLETE) - player->ADD_GOSSIP_ITEM( 0, "Talk to me", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF); - - player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); - - return true; -} - -bool GossipSelect_npc_lorax(Player *player, Creature *_Creature, uint32 sender, uint32 action) -{ - switch (action) - { - case GOSSIP_ACTION_INFO_DEF: - player->ADD_GOSSIP_ITEM( 0, "What do you do here?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); - player->SEND_GOSSIP_MENU(3759, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+1: - player->ADD_GOSSIP_ITEM( 0, "I can help you", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2); - player->SEND_GOSSIP_MENU(3760, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+2: - player->ADD_GOSSIP_ITEM( 0, "What deal?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 3); - player->SEND_GOSSIP_MENU(3761, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+3: - player->ADD_GOSSIP_ITEM( 0, "Then what happened?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 4); - player->SEND_GOSSIP_MENU(3762, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+4: - player->ADD_GOSSIP_ITEM( 0, "He is not safe, i'll make sure of that.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 5); - player->SEND_GOSSIP_MENU(3763, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF+5: - player->CLOSE_GOSSIP_MENU(); - player->AreaExploredOrEventHappens(5126); - break; - } - return true; -} - -/*###### -## npc_rivern_frostwind -######*/ - -bool GossipHello_npc_rivern_frostwind(Player *player, Creature *_Creature) -{ - if (_Creature->isQuestGiver()) - player->PrepareQuestMenu( _Creature->GetGUID() ); - - if (_Creature->isVendor() && player->GetReputationRank(589) == REP_EXALTED) - player->ADD_GOSSIP_ITEM(1, GOSSIP_TEXT_BROWSE_GOODS, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_TRADE); - - player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); - - return true; -} - -bool GossipSelect_npc_rivern_frostwind(Player *player, Creature *_Creature, uint32 sender, uint32 action) -{ - if (action == GOSSIP_ACTION_TRADE) - player->SEND_VENDORLIST( _Creature->GetGUID() ); - - return true; -} - -/*###### -## npc_witch_doctor_mauari -######*/ - -bool GossipHello_npc_witch_doctor_mauari(Player *player, Creature *_Creature) -{ - if(_Creature->isQuestGiver()) - player->PrepareQuestMenu( _Creature->GetGUID() ); - - if(player->GetQuestRewardStatus(975)) - { - player->ADD_GOSSIP_ITEM(0, "I'd like you to make me a new Cache of Mau'ari please.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); - player->SEND_GOSSIP_MENU(3377, _Creature->GetGUID()); - }else - player->SEND_GOSSIP_MENU(3375, _Creature->GetGUID()); - - return true; -} - -bool GossipSelect_npc_witch_doctor_mauari(Player *player, Creature *_Creature, uint32 sender, uint32 action) -{ - if (action==GOSSIP_ACTION_INFO_DEF+1) - { - player->CLOSE_GOSSIP_MENU(); - _Creature->CastSpell(player, 16351, false); - } - - return true; -} - -void AddSC_winterspring() -{ - Script *newscript; - - newscript = new Script; - newscript->Name="npc_lorax"; - newscript->pGossipHello = &GossipHello_npc_lorax; - newscript->pGossipSelect = &GossipSelect_npc_lorax; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="npc_rivern_frostwind"; - newscript->pGossipHello = &GossipHello_npc_rivern_frostwind; - newscript->pGossipSelect = &GossipSelect_npc_rivern_frostwind; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="npc_witch_doctor_mauari"; - newscript->pGossipHello = &GossipHello_npc_witch_doctor_mauari; - newscript->pGossipSelect = &GossipSelect_npc_witch_doctor_mauari; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Winterspring +SD%Complete: 90 +SDComment: Quest support: 5126 (Loraxs' tale missing proper gossip items text). Vendor Rivern Frostwind. Obtain Cache of Mau'ari +SDCategory: Winterspring +EndScriptData */ + +/* ContentData +npc_lorax +npc_rivern_frostwind +npc_witch_doctor_mauari +EndContentData */ + +#include "precompiled.h" + +/*###### +## npc_lorax +######*/ + +bool GossipHello_npc_lorax(Player *player, Creature *_Creature) +{ + if (_Creature->isQuestGiver()) + player->PrepareQuestMenu( _Creature->GetGUID() ); + + if (player->GetQuestStatus(5126) == QUEST_STATUS_INCOMPLETE) + player->ADD_GOSSIP_ITEM( 0, "Talk to me", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF); + + player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); + + return true; +} + +bool GossipSelect_npc_lorax(Player *player, Creature *_Creature, uint32 sender, uint32 action) +{ + switch (action) + { + case GOSSIP_ACTION_INFO_DEF: + player->ADD_GOSSIP_ITEM( 0, "What do you do here?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); + player->SEND_GOSSIP_MENU(3759, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+1: + player->ADD_GOSSIP_ITEM( 0, "I can help you", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2); + player->SEND_GOSSIP_MENU(3760, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+2: + player->ADD_GOSSIP_ITEM( 0, "What deal?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 3); + player->SEND_GOSSIP_MENU(3761, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+3: + player->ADD_GOSSIP_ITEM( 0, "Then what happened?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 4); + player->SEND_GOSSIP_MENU(3762, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+4: + player->ADD_GOSSIP_ITEM( 0, "He is not safe, i'll make sure of that.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 5); + player->SEND_GOSSIP_MENU(3763, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF+5: + player->CLOSE_GOSSIP_MENU(); + player->AreaExploredOrEventHappens(5126); + break; + } + return true; +} + +/*###### +## npc_rivern_frostwind +######*/ + +bool GossipHello_npc_rivern_frostwind(Player *player, Creature *_Creature) +{ + if (_Creature->isQuestGiver()) + player->PrepareQuestMenu( _Creature->GetGUID() ); + + if (_Creature->isVendor() && player->GetReputationRank(589) == REP_EXALTED) + player->ADD_GOSSIP_ITEM(1, GOSSIP_TEXT_BROWSE_GOODS, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_TRADE); + + player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); + + return true; +} + +bool GossipSelect_npc_rivern_frostwind(Player *player, Creature *_Creature, uint32 sender, uint32 action) +{ + if (action == GOSSIP_ACTION_TRADE) + player->SEND_VENDORLIST( _Creature->GetGUID() ); + + return true; +} + +/*###### +## npc_witch_doctor_mauari +######*/ + +bool GossipHello_npc_witch_doctor_mauari(Player *player, Creature *_Creature) +{ + if(_Creature->isQuestGiver()) + player->PrepareQuestMenu( _Creature->GetGUID() ); + + if(player->GetQuestRewardStatus(975)) + { + player->ADD_GOSSIP_ITEM(0, "I'd like you to make me a new Cache of Mau'ari please.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); + player->SEND_GOSSIP_MENU(3377, _Creature->GetGUID()); + }else + player->SEND_GOSSIP_MENU(3375, _Creature->GetGUID()); + + return true; +} + +bool GossipSelect_npc_witch_doctor_mauari(Player *player, Creature *_Creature, uint32 sender, uint32 action) +{ + if (action==GOSSIP_ACTION_INFO_DEF+1) + { + player->CLOSE_GOSSIP_MENU(); + _Creature->CastSpell(player, 16351, false); + } + + return true; +} + +void AddSC_winterspring() +{ + Script *newscript; + + newscript = new Script; + newscript->Name="npc_lorax"; + newscript->pGossipHello = &GossipHello_npc_lorax; + newscript->pGossipSelect = &GossipSelect_npc_lorax; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="npc_rivern_frostwind"; + newscript->pGossipHello = &GossipHello_npc_rivern_frostwind; + newscript->pGossipSelect = &GossipSelect_npc_rivern_frostwind; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="npc_witch_doctor_mauari"; + newscript->pGossipHello = &GossipHello_npc_witch_doctor_mauari; + newscript->pGossipSelect = &GossipSelect_npc_witch_doctor_mauari; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/zangarmarsh/zangarmarsh.cpp b/src/bindings/scripts/scripts/zone/zangarmarsh/zangarmarsh.cpp index e5917dd25ee..41c201b3450 100644 --- a/src/bindings/scripts/scripts/zone/zangarmarsh/zangarmarsh.cpp +++ b/src/bindings/scripts/scripts/zone/zangarmarsh/zangarmarsh.cpp @@ -1,283 +1,283 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Zangarmarsh -SD%Complete: 100 -SDComment: Quest support: 9785, 9803, 10009. Mark Of ... buffs. -SDCategory: Zangarmarsh -EndScriptData */ - -/* ContentData -npcs_ashyen_and_keleth -npc_cooshcoosh -npc_elder_kuruti -npc_mortog_steamhead -EndContentData */ - -#include "precompiled.h" - -/*###### -## npcs_ashyen_and_keleth -######*/ - -#define GOSSIP_ITEM_BLESS_ASH "Grant me your mark, wise ancient." -#define GOSSIP_ITEM_BLESS_KEL "Grant me your mark, mighty ancient." -#define GOSSIP_REWARD_BLESS "You have my blessing" -//#define TEXT_BLESSINGS "" - -bool GossipHello_npcs_ashyen_and_keleth(Player *player, Creature *_Creature ) -{ - if (player->GetReputationRank(942) > REP_NEUTRAL) - { - if ( _Creature->GetEntry() == 17900) - player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM_BLESS_ASH, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); - if ( _Creature->GetEntry() == 17901) - player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM_BLESS_KEL, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); - } - player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); - - return true; -} - -bool GossipSelect_npcs_ashyen_and_keleth(Player *player, Creature *_Creature, uint32 sender, uint32 action) -{ - if (action == GOSSIP_ACTION_INFO_DEF+1) - { - _Creature->setPowerType(POWER_MANA); - _Creature->SetMaxPower(POWER_MANA,200); //set a "fake" mana value, we can't depend on database doing it in this case - _Creature->SetPower(POWER_MANA,200); - - if ( _Creature->GetEntry() == 17900) //check which creature we are dealing with - { - switch (player->GetReputationRank(942)) - { //mark of lore - case REP_FRIENDLY: - _Creature->CastSpell(player, 31808, true); - _Creature->Say(GOSSIP_REWARD_BLESS, LANG_UNIVERSAL, 0); - break; - case REP_HONORED: - _Creature->CastSpell(player, 31810, true); - _Creature->Say(GOSSIP_REWARD_BLESS, LANG_UNIVERSAL, 0); - break; - case REP_REVERED: - _Creature->CastSpell(player, 31811, true); - _Creature->Say(GOSSIP_REWARD_BLESS, LANG_UNIVERSAL, 0); - break; - case REP_EXALTED: - _Creature->CastSpell(player, 31815, true); - _Creature->Say(GOSSIP_REWARD_BLESS, LANG_UNIVERSAL, 0); - break; - } - } - - if ( _Creature->GetEntry() == 17901) - { - switch (player->GetReputationRank(942)) //mark of war - { - case REP_FRIENDLY: - _Creature->CastSpell(player, 31807, true); - _Creature->Say(GOSSIP_REWARD_BLESS, LANG_UNIVERSAL, 0); - break; - case REP_HONORED: - _Creature->CastSpell(player, 31812, true); - _Creature->Say(GOSSIP_REWARD_BLESS, LANG_UNIVERSAL, 0); - break; - case REP_REVERED: - _Creature->CastSpell(player, 31813, true); - _Creature->Say(GOSSIP_REWARD_BLESS, LANG_UNIVERSAL, 0); - break; - case REP_EXALTED: - _Creature->CastSpell(player, 31814, true); - _Creature->Say(GOSSIP_REWARD_BLESS, LANG_UNIVERSAL, 0); - break; - } - } - player->CLOSE_GOSSIP_MENU(); - player->TalkedToCreature(_Creature->GetEntry(), _Creature->GetGUID()); - } - return true; -} - -/*###### -## npc_cooshcoosh -######*/ - -#define GOSSIP_COOSH "You owe Sim'salabim money. Hand them over or die!" - -#define FACTION_HOSTILE_CO 45 -#define FACTION_FRIENDLY_CO 35 - -#define SPELL_LIGHTNING_BOLT 9532 - -struct MANGOS_DLL_DECL npc_cooshcooshAI : public ScriptedAI -{ - npc_cooshcooshAI(Creature* c) : ScriptedAI(c) { Reset(); } - - uint32 LightningBolt_Timer; - - void Reset() - { - LightningBolt_Timer = 2000; - m_creature->setFaction(FACTION_FRIENDLY_CO); - } - - void Aggro(Unit *who) {} - - void UpdateAI(const uint32 diff) - { - if(!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - if( LightningBolt_Timer < diff ) - { - DoCast(m_creature->getVictim(),SPELL_LIGHTNING_BOLT); - LightningBolt_Timer = 5000; - }else LightningBolt_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; -CreatureAI* GetAI_npc_cooshcoosh(Creature *_Creature) -{ - return new npc_cooshcooshAI (_Creature); -} - -bool GossipHello_npc_cooshcoosh(Player *player, Creature *_Creature ) -{ - if( player->GetQuestStatus(10009) == QUEST_STATUS_INCOMPLETE ) - player->ADD_GOSSIP_ITEM(1, GOSSIP_COOSH, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF); - - player->SEND_GOSSIP_MENU(9441, _Creature->GetGUID()); - return true; -} - -bool GossipSelect_npc_cooshcoosh(Player *player, Creature *_Creature, uint32 sender, uint32 action ) -{ - if( action == GOSSIP_ACTION_INFO_DEF ) - { - player->CLOSE_GOSSIP_MENU(); - _Creature->setFaction(FACTION_HOSTILE_CO); - ((npc_cooshcooshAI*)_Creature->AI())->AttackStart(player); - } - return true; -} - -/*###### -## npc_elder_kuruti -######*/ - -#define GOSSIP_ITEM_KUR1 "Offer treat" -#define GOSSIP_ITEM_KUR2 "Im a messenger for Draenei" -#define GOSSIP_ITEM_KUR3 "Get message" - -bool GossipHello_npc_elder_kuruti(Player *player, Creature *_Creature ) -{ - if( player->GetQuestStatus(9803) == QUEST_STATUS_INCOMPLETE ) - player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM_KUR1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF); - - player->SEND_GOSSIP_MENU(9226,_Creature->GetGUID()); - - return true; -} - -bool GossipSelect_npc_elder_kuruti(Player *player, Creature *_Creature, uint32 sender, uint32 action ) -{ - switch (action) - { - case GOSSIP_ACTION_INFO_DEF: - player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM_KUR2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); - player->SEND_GOSSIP_MENU(9227, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 1: - player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM_KUR3, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2); - player->SEND_GOSSIP_MENU(9229, _Creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 2: - { - if( !player->HasItemCount(24573,1) ) - { - ItemPosCountVec dest; - uint8 msg = player->CanStoreNewItem( NULL_BAG, NULL_SLOT, dest, 24573, 1, false); - if( msg == EQUIP_ERR_OK ) - { - player->StoreNewItem( dest, 24573, true); - } - else - player->SendEquipError( msg,NULL,NULL ); - } - player->SEND_GOSSIP_MENU(9231, _Creature->GetGUID()); - break; - } - } - return true; -} - -/*###### -## npc_mortog_steamhead -######*/ - -bool GossipHello_npc_mortog_steamhead(Player *player, Creature *_Creature) -{ - if (_Creature->isVendor() && player->GetReputationRank(942) == REP_EXALTED) - player->ADD_GOSSIP_ITEM(1, GOSSIP_TEXT_BROWSE_GOODS, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_TRADE); - - player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); - - return true; -} - -bool GossipSelect_npc_mortog_steamhead(Player *player, Creature *_Creature, uint32 sender, uint32 action) -{ - if (action == GOSSIP_ACTION_TRADE) - { - player->SEND_VENDORLIST( _Creature->GetGUID() ); - } - return true; -} - -/*###### -## AddSC -######*/ - -void AddSC_zangarmarsh() -{ - Script *newscript; - - newscript = new Script; - newscript->Name="npcs_ashyen_and_keleth"; - newscript->pGossipHello = &GossipHello_npcs_ashyen_and_keleth; - newscript->pGossipSelect = &GossipSelect_npcs_ashyen_and_keleth; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="npc_cooshcoosh"; - newscript->pGossipHello = &GossipHello_npc_cooshcoosh; - newscript->pGossipSelect = &GossipSelect_npc_cooshcoosh; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="npc_elder_kuruti"; - newscript->pGossipHello = &GossipHello_npc_elder_kuruti; - newscript->pGossipSelect = &GossipSelect_npc_elder_kuruti; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="npc_mortog_steamhead"; - newscript->pGossipHello = &GossipHello_npc_mortog_steamhead; - newscript->pGossipSelect = &GossipSelect_npc_mortog_steamhead; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Zangarmarsh +SD%Complete: 100 +SDComment: Quest support: 9785, 9803, 10009. Mark Of ... buffs. +SDCategory: Zangarmarsh +EndScriptData */ + +/* ContentData +npcs_ashyen_and_keleth +npc_cooshcoosh +npc_elder_kuruti +npc_mortog_steamhead +EndContentData */ + +#include "precompiled.h" + +/*###### +## npcs_ashyen_and_keleth +######*/ + +#define GOSSIP_ITEM_BLESS_ASH "Grant me your mark, wise ancient." +#define GOSSIP_ITEM_BLESS_KEL "Grant me your mark, mighty ancient." +#define GOSSIP_REWARD_BLESS "You have my blessing" +//#define TEXT_BLESSINGS "" + +bool GossipHello_npcs_ashyen_and_keleth(Player *player, Creature *_Creature ) +{ + if (player->GetReputationRank(942) > REP_NEUTRAL) + { + if ( _Creature->GetEntry() == 17900) + player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM_BLESS_ASH, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); + if ( _Creature->GetEntry() == 17901) + player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM_BLESS_KEL, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); + } + player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); + + return true; +} + +bool GossipSelect_npcs_ashyen_and_keleth(Player *player, Creature *_Creature, uint32 sender, uint32 action) +{ + if (action == GOSSIP_ACTION_INFO_DEF+1) + { + _Creature->setPowerType(POWER_MANA); + _Creature->SetMaxPower(POWER_MANA,200); //set a "fake" mana value, we can't depend on database doing it in this case + _Creature->SetPower(POWER_MANA,200); + + if ( _Creature->GetEntry() == 17900) //check which creature we are dealing with + { + switch (player->GetReputationRank(942)) + { //mark of lore + case REP_FRIENDLY: + _Creature->CastSpell(player, 31808, true); + _Creature->Say(GOSSIP_REWARD_BLESS, LANG_UNIVERSAL, 0); + break; + case REP_HONORED: + _Creature->CastSpell(player, 31810, true); + _Creature->Say(GOSSIP_REWARD_BLESS, LANG_UNIVERSAL, 0); + break; + case REP_REVERED: + _Creature->CastSpell(player, 31811, true); + _Creature->Say(GOSSIP_REWARD_BLESS, LANG_UNIVERSAL, 0); + break; + case REP_EXALTED: + _Creature->CastSpell(player, 31815, true); + _Creature->Say(GOSSIP_REWARD_BLESS, LANG_UNIVERSAL, 0); + break; + } + } + + if ( _Creature->GetEntry() == 17901) + { + switch (player->GetReputationRank(942)) //mark of war + { + case REP_FRIENDLY: + _Creature->CastSpell(player, 31807, true); + _Creature->Say(GOSSIP_REWARD_BLESS, LANG_UNIVERSAL, 0); + break; + case REP_HONORED: + _Creature->CastSpell(player, 31812, true); + _Creature->Say(GOSSIP_REWARD_BLESS, LANG_UNIVERSAL, 0); + break; + case REP_REVERED: + _Creature->CastSpell(player, 31813, true); + _Creature->Say(GOSSIP_REWARD_BLESS, LANG_UNIVERSAL, 0); + break; + case REP_EXALTED: + _Creature->CastSpell(player, 31814, true); + _Creature->Say(GOSSIP_REWARD_BLESS, LANG_UNIVERSAL, 0); + break; + } + } + player->CLOSE_GOSSIP_MENU(); + player->TalkedToCreature(_Creature->GetEntry(), _Creature->GetGUID()); + } + return true; +} + +/*###### +## npc_cooshcoosh +######*/ + +#define GOSSIP_COOSH "You owe Sim'salabim money. Hand them over or die!" + +#define FACTION_HOSTILE_CO 45 +#define FACTION_FRIENDLY_CO 35 + +#define SPELL_LIGHTNING_BOLT 9532 + +struct MANGOS_DLL_DECL npc_cooshcooshAI : public ScriptedAI +{ + npc_cooshcooshAI(Creature* c) : ScriptedAI(c) { Reset(); } + + uint32 LightningBolt_Timer; + + void Reset() + { + LightningBolt_Timer = 2000; + m_creature->setFaction(FACTION_FRIENDLY_CO); + } + + void Aggro(Unit *who) {} + + void UpdateAI(const uint32 diff) + { + if(!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + if( LightningBolt_Timer < diff ) + { + DoCast(m_creature->getVictim(),SPELL_LIGHTNING_BOLT); + LightningBolt_Timer = 5000; + }else LightningBolt_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; +CreatureAI* GetAI_npc_cooshcoosh(Creature *_Creature) +{ + return new npc_cooshcooshAI (_Creature); +} + +bool GossipHello_npc_cooshcoosh(Player *player, Creature *_Creature ) +{ + if( player->GetQuestStatus(10009) == QUEST_STATUS_INCOMPLETE ) + player->ADD_GOSSIP_ITEM(1, GOSSIP_COOSH, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF); + + player->SEND_GOSSIP_MENU(9441, _Creature->GetGUID()); + return true; +} + +bool GossipSelect_npc_cooshcoosh(Player *player, Creature *_Creature, uint32 sender, uint32 action ) +{ + if( action == GOSSIP_ACTION_INFO_DEF ) + { + player->CLOSE_GOSSIP_MENU(); + _Creature->setFaction(FACTION_HOSTILE_CO); + ((npc_cooshcooshAI*)_Creature->AI())->AttackStart(player); + } + return true; +} + +/*###### +## npc_elder_kuruti +######*/ + +#define GOSSIP_ITEM_KUR1 "Offer treat" +#define GOSSIP_ITEM_KUR2 "Im a messenger for Draenei" +#define GOSSIP_ITEM_KUR3 "Get message" + +bool GossipHello_npc_elder_kuruti(Player *player, Creature *_Creature ) +{ + if( player->GetQuestStatus(9803) == QUEST_STATUS_INCOMPLETE ) + player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM_KUR1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF); + + player->SEND_GOSSIP_MENU(9226,_Creature->GetGUID()); + + return true; +} + +bool GossipSelect_npc_elder_kuruti(Player *player, Creature *_Creature, uint32 sender, uint32 action ) +{ + switch (action) + { + case GOSSIP_ACTION_INFO_DEF: + player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM_KUR2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); + player->SEND_GOSSIP_MENU(9227, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 1: + player->ADD_GOSSIP_ITEM( 0, GOSSIP_ITEM_KUR3, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2); + player->SEND_GOSSIP_MENU(9229, _Creature->GetGUID()); + break; + case GOSSIP_ACTION_INFO_DEF + 2: + { + if( !player->HasItemCount(24573,1) ) + { + ItemPosCountVec dest; + uint8 msg = player->CanStoreNewItem( NULL_BAG, NULL_SLOT, dest, 24573, 1, false); + if( msg == EQUIP_ERR_OK ) + { + player->StoreNewItem( dest, 24573, true); + } + else + player->SendEquipError( msg,NULL,NULL ); + } + player->SEND_GOSSIP_MENU(9231, _Creature->GetGUID()); + break; + } + } + return true; +} + +/*###### +## npc_mortog_steamhead +######*/ + +bool GossipHello_npc_mortog_steamhead(Player *player, Creature *_Creature) +{ + if (_Creature->isVendor() && player->GetReputationRank(942) == REP_EXALTED) + player->ADD_GOSSIP_ITEM(1, GOSSIP_TEXT_BROWSE_GOODS, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_TRADE); + + player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID()); + + return true; +} + +bool GossipSelect_npc_mortog_steamhead(Player *player, Creature *_Creature, uint32 sender, uint32 action) +{ + if (action == GOSSIP_ACTION_TRADE) + { + player->SEND_VENDORLIST( _Creature->GetGUID() ); + } + return true; +} + +/*###### +## AddSC +######*/ + +void AddSC_zangarmarsh() +{ + Script *newscript; + + newscript = new Script; + newscript->Name="npcs_ashyen_and_keleth"; + newscript->pGossipHello = &GossipHello_npcs_ashyen_and_keleth; + newscript->pGossipSelect = &GossipSelect_npcs_ashyen_and_keleth; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="npc_cooshcoosh"; + newscript->pGossipHello = &GossipHello_npc_cooshcoosh; + newscript->pGossipSelect = &GossipSelect_npc_cooshcoosh; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="npc_elder_kuruti"; + newscript->pGossipHello = &GossipHello_npc_elder_kuruti; + newscript->pGossipSelect = &GossipSelect_npc_elder_kuruti; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="npc_mortog_steamhead"; + newscript->pGossipHello = &GossipHello_npc_mortog_steamhead; + newscript->pGossipSelect = &GossipSelect_npc_mortog_steamhead; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/zulaman/boss_janalai.cpp b/src/bindings/scripts/scripts/zone/zulaman/boss_janalai.cpp index 0f3de44cd10..7ec0eeacfc3 100644 --- a/src/bindings/scripts/scripts/zone/zulaman/boss_janalai.cpp +++ b/src/bindings/scripts/scripts/zone/zulaman/boss_janalai.cpp @@ -1,777 +1,760 @@ -/* Copyright (C) 2006,2007 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Janalai -SD%Complete: 100 -SDComment: -SDCategory: Zul'Aman -EndScriptData */ - -#include "precompiled.h" -#include "def_zulaman.h" - -// Jan'alai -// --Spell -#define SPELL_FLAME_BREATH 43140 -#define SPELL_FIRE_WALL 43113 -#define SPELL_ENRAGE 44779 -#define SPELL_TELETOCENTER 43098 -#define SPELL_SUMMONALL 43097 -#define SPELL_BERSERK 47008 -// -- Fire Bob Spells -#define MOB_FIRE_BOMB 23920 -#define SPELL_FIRE_BOMB_CHANNEL 42621 -#define SPELL_FIRE_BOMB_THROW 42628 -#define SPELL_FIRE_BOMB_DUMMY 42629 -#define SPELL_FIRE_BOMB_DAMAGE 42630 - -// -- SAYs -#define SOUND_AGGRO 12031 -#define SAY_AGGRO "Spirits of da wind be your doom!" -#define SOUND_FIRE_BOMBS 12032 -#define SAY_FIRE_BOMBS "I burn ya now!" -#define SOUND_SUMMON_HATCHER 12033 -#define SAY_SUMMON_HATCHER "Where ma hatcha? Get to work on dem eggs!" -#define SOUND_ALL_EGGS 12034 -#define SAY_ALL_EGGS "I show you strength... in numbers." -#define SOUND_BERSERK 12035 -#define SAY_BERSERK "You done run outta time!" - -#define SOUND_SLAY_1 12036 -#define SAY_SLAY_1 "It all be over now, mon!" -#define SOUND_SLAY_2 12037 -#define SAY_SLAY_2 "Tazaga-choo!" - -#define SOUND_DEATH 12038 -#define SAY_DEATH "Zul'jin... got a surprise for you..." - -#define SOUND_AGGRO_1 12039 //NOT USED need more information - //NOT USED need more information (random say before aggro?) -#define SAY_AGGRO_1 "Come, strangers. The spirit of the dragonhawk hot be hungry for worthy souls." -#define SOUND_AGGRO_2 12040 //NOT USED need more information - //NOT USED need more information (random say before aggro?) -#define SAY_AGGRO_2 "Come, friends. Your bodies gonna feed ma hatchlings, and your souls are going to feed me with power!" - -// --Summons -#define MOB_AMANI_HATCHER 23818 -#define MOB_HATCHLING 23598 - -// -- Hatcher Spells -#define SPELL_HATCH_EGG 43734 - -// -- Hatchling Spells -#define SPELL_FLAMEBUFFED 43299 - -const int area_dx = 44; -const int area_dy = 51; - -float JanalainPos[1][3] = -{ - {-33.93, 1149.27, 19} -}; - -float FireWallCoords[4][4] = -{ - {-10.13, 1149.27, 19, 3.1415}, - {-33.93, 1123.90, 19, 0.5*3.1415}, - {-54.80, 1150.08, 19, 0}, - {-33.93, 1175.68, 19, 1.5*3.1415} -}; - -float hatcherway_l[5][3] = -{ - {-87.46,1170.09,6}, - {-74.41,1154.75,6}, - {-52.74,1153.32,19}, - {-33.37,1172.46,19}, - {-33.09,1203.87,19} -}; - -float hatcherway_r[5][3] = -{ - {-86.57,1132.85,6}, - {-73.94,1146.00,6}, - {-52.29,1146.51,19}, - {-33.57,1125.72,19}, - {-34.29,1095.22,19} -}; - -struct MANGOS_DLL_DECL boss_janalaiAI : public ScriptedAI -{ - boss_janalaiAI(Creature *c) : ScriptedAI(c) - { - pInstance = ((ScriptedInstance*)c->GetInstanceData()); - Reset(); - } - - ScriptedInstance *pInstance; - - uint32 fire_breath_timer; - uint32 bomb_timer; - uint32 throw_timer; - uint32 enrage_timer; - uint32 finishedbomb_timer; - uint32 bombcounter; - uint32 hatchertime; - uint32 eggs; - uint32 wipetimer; - uint32 reset_timer; - bool noeggs; - bool enraged; - bool enragetime; - - uint64 FireBombGUIDs[40]; - uint64 ThrowControllerGUID; - - bool bombing; - - void Reset() - { - if(pInstance) - pInstance->SetData(DATA_JANALAIEVENT, NOT_STARTED); - - fire_breath_timer = 8000; - bomb_timer = 30000; - enrage_timer = 300000; // 5 minutes - finishedbomb_timer = 6000; - throw_timer = 1000; - bombcounter = 0; - noeggs = false; - hatchertime = 10000; - wipetimer = 600000; // 10 mins - bombing =false; - reset_timer = 5000; - enraged = false; - enragetime = false; - - ThrowControllerGUID = 0; - - for(uint8 i = 0; i < 40; i++) - FireBombGUIDs[i] = 0; - } - - void JustDied(Unit* Killer) - { - DoYell(SAY_DEATH, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature,SOUND_DEATH); - - if(pInstance) - pInstance->SetData(DATA_JANALAIEVENT, DONE); - } - - void KilledUnit(Unit* victim) - { - switch(rand()%2) - { - case 0: - DoYell(SAY_SLAY_1, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature,SOUND_SLAY_1); - break; - case 1: - DoYell(SAY_SLAY_2, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature,SOUND_SLAY_1); - break; - } - } - - void Aggro(Unit *who) - { - if(pInstance) - pInstance->SetData(DATA_JANALAIEVENT, IN_PROGRESS); - - DoYell(SAY_AGGRO, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature,SOUND_AGGRO); - } - - void FireWall() // Create Firewall - { - Creature* wall = NULL; - wall = m_creature->SummonCreature(MOB_FIRE_BOMB,FireWallCoords[0][0],FireWallCoords[0][1],FireWallCoords[0][2],FireWallCoords[0][3],TEMPSUMMON_TIMED_DESPAWN,11500); - if(wall) - wall->CastSpell(wall,SPELL_FIRE_WALL,false); - - wall = m_creature->SummonCreature(MOB_FIRE_BOMB,FireWallCoords[0][0],FireWallCoords[0][1]+5,FireWallCoords[0][2],FireWallCoords[0][3],TEMPSUMMON_TIMED_DESPAWN,11500); - if(wall) - wall->CastSpell(wall,SPELL_FIRE_WALL,false); - - wall = m_creature->SummonCreature(MOB_FIRE_BOMB,FireWallCoords[0][0],FireWallCoords[0][1]-5,FireWallCoords[0][2],FireWallCoords[0][3],TEMPSUMMON_TIMED_DESPAWN,11500); - if(wall) - wall->CastSpell(wall,SPELL_FIRE_WALL,false); - - wall = m_creature->SummonCreature(MOB_FIRE_BOMB,FireWallCoords[1][0]-2,FireWallCoords[1][1]-2,FireWallCoords[1][2],FireWallCoords[1][3],TEMPSUMMON_TIMED_DESPAWN,11500); - if(wall) - wall->CastSpell(wall,SPELL_FIRE_WALL,false); - - wall = m_creature->SummonCreature(MOB_FIRE_BOMB,FireWallCoords[1][0]+2,FireWallCoords[1][1]+2,FireWallCoords[1][2],FireWallCoords[1][3],TEMPSUMMON_TIMED_DESPAWN,11500); - if(wall) - wall->CastSpell(wall,SPELL_FIRE_WALL,false); - - wall = m_creature->SummonCreature(MOB_FIRE_BOMB,FireWallCoords[2][0],FireWallCoords[2][1],FireWallCoords[2][2],FireWallCoords[2][3],TEMPSUMMON_TIMED_DESPAWN,11500); - if(wall) - wall->CastSpell(wall,SPELL_FIRE_WALL,false); - - wall = m_creature->SummonCreature(MOB_FIRE_BOMB,FireWallCoords[2][0],FireWallCoords[2][1]-5,FireWallCoords[2][2],FireWallCoords[2][3],TEMPSUMMON_TIMED_DESPAWN,11500); - if(wall) - wall->CastSpell(wall,SPELL_FIRE_WALL,false); - - wall = m_creature->SummonCreature(MOB_FIRE_BOMB,FireWallCoords[2][0],FireWallCoords[2][1]+5,FireWallCoords[2][2],FireWallCoords[2][3],TEMPSUMMON_TIMED_DESPAWN,11500); - if(wall) - wall->CastSpell(wall,SPELL_FIRE_WALL,false); - - wall = m_creature->SummonCreature(MOB_FIRE_BOMB,FireWallCoords[3][0]-2,FireWallCoords[3][1],FireWallCoords[3][2],FireWallCoords[3][3],TEMPSUMMON_TIMED_DESPAWN,11500); - if(wall) - wall->CastSpell(wall,SPELL_FIRE_WALL,false); - - wall = m_creature->SummonCreature(MOB_FIRE_BOMB,FireWallCoords[3][0]+2,FireWallCoords[3][1],FireWallCoords[3][2],FireWallCoords[3][3],TEMPSUMMON_TIMED_DESPAWN,11500); - if(wall) - wall->CastSpell(wall,SPELL_FIRE_WALL,false); - } - - void throwBombs() // create Bombs - { - float dx; - float dy; - for ( int i(0); i < 40; i++) - { - dx = (rand()%(area_dx))-(area_dx/2); - dy = (rand()%(area_dy))-(area_dy/2); - - Creature* bomb = DoSpawnCreature(MOB_FIRE_BOMB, dx, dy, 0, 0, TEMPSUMMON_TIMED_DESPAWN, 13000); - if(bomb) - FireBombGUIDs[i] = bomb->GetGUID(); - } - - Creature* ThrowController = DoSpawnCreature(MOB_FIRE_BOMB,0,0,1,0,TEMPSUMMON_TIMED_DESPAWN,10000); - if(ThrowController) - ThrowControllerGUID = ThrowController->GetGUID(); - - bombcounter = 0; - } - - void throw5Bombs() //throwanimation - { - for ( int i(0); i < 5; i++) - { - Unit* ThrowController = NULL; - Unit* FireBomb = NULL; - if(ThrowControllerGUID) - ThrowController = Unit::GetUnit((*m_creature), ThrowControllerGUID); - - if(FireBombGUIDs[bombcounter]) - FireBomb = Unit::GetUnit((*m_creature), FireBombGUIDs[bombcounter]); - - if(ThrowController && FireBomb) - { - ThrowController->CastSpell(FireBomb,SPELL_FIRE_BOMB_THROW,true); - FireBomb->CastSpell(FireBomb,SPELL_FIRE_BOMB_DUMMY,false); - bombcounter ++; - } - } - } - - void UpdateAI(const uint32 diff) - { - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - if(!bombing) // every Spell if NOT Bombing - { - //FIRE BREATH several videos says every 8Secounds - if(fire_breath_timer < diff) - { - Unit* target = NULL; - target = SelectUnit(SELECT_TARGET_RANDOM,0); - if(target) - DoCast(target,SPELL_FLAME_BREATH); - fire_breath_timer = 8000; - }else fire_breath_timer -=diff; - - if(bomb_timer < diff) - { - FireWall(); - bomb_timer = 20000+rand()%20000; - m_creature->Relocate(JanalainPos[0][0],JanalainPos[0][1],JanalainPos[0][2],0); - m_creature->SendMonsterMove(JanalainPos[0][0], JanalainPos[0][1],JanalainPos[0][2],0,0,100); - DoYell(SAY_FIRE_BOMBS, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature,SOUND_FIRE_BOMBS); - throwBombs(); - bombing = true; - - //Teleport every Player into the middle - Unit* Temp = NULL; - std::list::iterator i = m_creature->getThreatManager().getThreatList().begin(); - for (; i != m_creature->getThreatManager().getThreatList().end(); ++i) - { - Temp = Unit::GetUnit((*m_creature),(*i)->getUnitGuid()); - if (Temp && m_creature->GetDistance(Temp) > 30.0) - DoTeleportPlayer(Temp, m_creature->GetPositionX(), m_creature->GetPositionY(), m_creature->GetPositionZ(), 0); - } - DoCast(m_creature,SPELL_TELETOCENTER,true); // only Effect Spell - DoCast(m_creature,SPELL_FIRE_BOMB_CHANNEL,false); - finishedbomb_timer = 11000; - }else bomb_timer -=diff; - - //enrage if under 25% hp before 5 min. - if (((m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < 25) && !enraged) - { - enragetime = true; - enrage_timer = 600000; - } - - //Enrage but only if not bombing - if(enragetime && !enraged) - { - DoYell(SAY_BERSERK, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature,SOUND_BERSERK); - m_creature->InterruptNonMeleeSpells(false); - DoCast(m_creature,SPELL_ENRAGE); - enraged = true; - } - } - - //Enrage after 5 minutes - if(enrage_timer < diff) - { - enragetime = true; - enrage_timer = 600000; - }else enrage_timer -=diff; - - if(bombing) // every Spell if Bombing - { - if(bombcounter < 40) - { - if(throw_timer < diff) - { - throw5Bombs(); - throw_timer = 1000; - }else throw_timer -=diff; - } - - if(finishedbomb_timer < diff) - { - bombing = false; - finishedbomb_timer = 6000; - m_creature->RemoveAura(SPELL_FIRE_BOMB_CHANNEL,0); - m_creature->RemoveAura(SPELL_FIRE_BOMB_CHANNEL,1); - }else finishedbomb_timer -=diff; - } - - //Call Hatcher - if(!noeggs) - { - if(hatchertime < diff) - { - if(pInstance->GetData(DATA_J_EGGSLEFT)>0 || pInstance->GetData(DATA_J_EGGSRIGHT) > 0) - { - Unit* hatcher = NULL; - DoYell(SAY_SUMMON_HATCHER, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature,SOUND_SUMMON_HATCHER); - hatcher = m_creature->SummonCreature(MOB_AMANI_HATCHER,hatcherway_l[0][0],hatcherway_l[0][1],hatcherway_l[0][2],0,TEMPSUMMON_CORPSE_TIMED_DESPAWN,10000); - if(hatcher) - hatcher->GetMotionMaster()->MovePoint(0, hatcherway_l[0][0], hatcherway_l[0][1], hatcherway_l[0][2]); - - hatcher = m_creature->SummonCreature(MOB_AMANI_HATCHER,hatcherway_r[0][0],hatcherway_r[0][1],hatcherway_r[0][2],0,TEMPSUMMON_CORPSE_TIMED_DESPAWN,10000); - if(hatcher) - hatcher->GetMotionMaster()->MovePoint(0, hatcherway_r[0][0],hatcherway_r[0][1],hatcherway_r[0][2]); - hatchertime = 45000; - } - else - { - noeggs = true; - } - }else hatchertime -=diff; - } - - //WIPE after 10 minutes - if(wipetimer < diff) - { - DoYell(SAY_BERSERK, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature,SOUND_BERSERK); - DoCast(m_creature,SPELL_ENRAGE); - - wipetimer = 30000; - }else wipetimer -=diff; - - //Hatch All - if(!noeggs && (m_creature->GetHealth()*100) / m_creature->GetMaxHealth() < 35) - { - DoYell(SAY_ALL_EGGS , LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature,SOUND_BERSERK); - - if(pInstance) - eggs = pInstance->GetData(DATA_J_EGGSLEFT); - - int i; - for(i=1;i<=eggs;i=i+1) - { - int r = (rand()%20 - 10); - int s = (rand()%20 - 10); - m_creature->SummonCreature(MOB_HATCHLING,JanalainPos[0][0]+s,JanalainPos[0][1]+r,JanalainPos[0][2],0,TEMPSUMMON_CORPSE_TIMED_DESPAWN,15000); - - if(pInstance) - pInstance->SetData(DATA_J_HATCHLEFT,1); - } - - if(pInstance) - eggs = pInstance->GetData(DATA_J_EGGSRIGHT); - - for(i=1;i<=eggs;i=i+1) - { - int r = (rand()%20 - 10); - int s = (rand()%20 - 10); - m_creature->SummonCreature(MOB_HATCHLING,JanalainPos[0][0]+s,JanalainPos[0][1]+r,JanalainPos[0][2],0,TEMPSUMMON_CORPSE_TIMED_DESPAWN,15000); - if(pInstance) - pInstance->SetData(DATA_J_HATCHRIGHT,1); - } - - noeggs = true; - } - - //check for reset ... exploit preventing ... pulled from his podest - if(reset_timer < diff) - { - if(m_creature->GetPositionX() < -70 || m_creature->GetPositionX() > 0) - { - EnterEvadeMode(); - reset_timer = 5000; //every 5 Seca - } - }else reset_timer -=diff; - - DoMeleeAttackIfReady(); - } -}; - -CreatureAI* GetAI_boss_janalaiAI(Creature *_Creature) -{ - return new boss_janalaiAI (_Creature); -} - -struct MANGOS_DLL_DECL mob_jandalai_firebombAI : public ScriptedAI -{ - mob_jandalai_firebombAI(Creature *c) : ScriptedAI(c){Reset();} - - uint32 bomb_timer; - - void Reset() - { - bomb_timer = 12000; - } - - void Aggro(Unit* who) {} - - void AttackStart(Unit* who) {} - - void MoveInLineOfSight(Unit* who) {} - - void UpdateAI(const uint32 diff) - { - if(bomb_timer < diff) //Boom - { - m_creature->CastSpell(m_creature,SPELL_FIRE_BOMB_DAMAGE,false); - bomb_timer = 1800000; - }else bomb_timer -=diff; - } -}; - -CreatureAI* GetAI_mob_jandalai_firebombAI(Creature *_Creature) -{ - return new mob_jandalai_firebombAI (_Creature); -} - -struct MANGOS_DLL_DECL mob_amanishi_hatcherAI : public ScriptedAI -{ - mob_amanishi_hatcherAI(Creature *c) : ScriptedAI(c) - { - pInstance = ((ScriptedInstance*)c->GetInstanceData()); - Reset(); - } - - ScriptedInstance *pInstance; - - uint32 waypoint; - bool waytype; - bool start; - bool hatch; - bool wait; - uint32 hatchlings; - uint32 waittimer; - uint32 eggs; - uint32 delete_timer; - - void Reset() - { - waypoint = 0; - waytype = 0; - hatch = false; - start = false; - wait = false; - waittimer = 4000; - hatchlings = 0; - eggs = 0; - delete_timer = 10000; - - //m_creature->RemoveAllAuras(); - //m_creature->DeleteThreatList(); - //m_creature->CombatStop(); - //DoGoHome(); - } - - void Aggro(Unit* who) - { - } - - void UpdateAI(const uint32 diff) - { - if(pInstance && (pInstance->GetData(DATA_JANALAIEVENT) == 1)) - { - if(!start && !hatch) - { - waytype = ( m_creature->GetPositionY() > 1150); - waypoint = 1; - start = true; - } - - if(start && !hatch) - { - if(wait) - { - if(waittimer < diff) - { - wait = false; - waittimer = 4000; - waypoint++; - - if (waypoint == 5) - { - hatch = true; - waittimer = 0; - hatchlings = 1; - } - } - else - { - waittimer -=diff; - } - } - else - { - m_creature->GetMotionMaster()->Clear(); - if(waytype) - m_creature->GetMotionMaster()->MovePoint(0,hatcherway_l[waypoint][0],hatcherway_l[waypoint][1],hatcherway_l[waypoint][2]); - else - m_creature->GetMotionMaster()->MovePoint(0,hatcherway_r[waypoint][0],hatcherway_r[waypoint][1],hatcherway_r[waypoint][2]); - wait= true; - } - } - - if(start && hatch) - { - if(waittimer < diff) - { - if(!pInstance) - return; - - waittimer = 4000; - Unit* hatchling; - - if(waytype) - { - eggs = pInstance->GetData(DATA_J_EGGSLEFT); - - if(eggs > 0) - DoCast(m_creature,SPELL_HATCH_EGG); - - int i; - for(i=1;i<=hatchlings;i=i+1) - { - eggs = pInstance->GetData(DATA_J_EGGSLEFT); - if(eggs <= 0) - { - if (waytype) waytype = false; else waytype = true; - waittimer = 15000; - hatch = false; - waypoint = 4; - wait = true; - i = hatchlings; - } - else - { - hatchling = DoSpawnCreature(MOB_HATCHLING,rand()%4-2,rand()%4-2,0,0,TEMPSUMMON_CORPSE_TIMED_DESPAWN,15000); - pInstance->SetData(DATA_J_HATCHLEFT,1); - } - } - - DoCast(m_creature,SPELL_HATCH_EGG); - - if(hatchlings < 5) - hatchlings++; - } - else - { - eggs = pInstance->GetData(DATA_J_EGGSRIGHT); - - if(eggs > 0) - DoCast(m_creature,SPELL_HATCH_EGG); - - int i; - for(i=1;i<=hatchlings;i=i+1) - { - eggs = pInstance->GetData(DATA_J_EGGSRIGHT); - if(eggs <= 0) - { - if (waytype) waytype = false; else waytype = true; - waittimer = 15000; - hatch = false; - waypoint = 4; - wait = true; - i = hatchlings; - } - else - { - hatchling = DoSpawnCreature(MOB_HATCHLING,rand()%4-2,rand()%4-2,0,0,TEMPSUMMON_CORPSE_TIMED_DESPAWN,15000); - pInstance->SetData(DATA_J_HATCHRIGHT,1); - } - } - - DoCast(m_creature,SPELL_HATCH_EGG); - hatchlings++; - } - }else waittimer -=diff; - } - } - else - { - if(delete_timer < diff) - { - m_creature->DealDamage(m_creature, m_creature->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); - delete_timer = 10000; - }else delete_timer -=diff; - } - } -}; - -CreatureAI* GetAI_mob_amanishi_hatcherAI(Creature *_Creature) -{ - return new mob_amanishi_hatcherAI (_Creature); -} - -struct MANGOS_DLL_DECL mob_hatchlingAI : public ScriptedAI -{ - mob_hatchlingAI(Creature *c) : ScriptedAI(c) - { - pInstance = ((ScriptedInstance*)c->GetInstanceData()); - Reset(); - } - - ScriptedInstance *pInstance; - - uint32 buffer_timer; - uint32 delete_timer; - bool start; - - void Reset() - { - buffer_timer = 7000; - delete_timer = 10000; - start = false; - } - - void Aggro(Unit *who) - { - } - - void MoveInLineOfSight(Unit *who) - { - if (!who || m_creature->getVictim()) - return; - - if (who->isTargetableForAttack() && who->isInAccessablePlaceFor(m_creature) && m_creature->IsHostileTo(who)) - { - float attackRadius = m_creature->GetAttackDistance(who); - if (m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->GetDistanceZ(who) <= CREATURE_Z_ATTACK_RANGE && m_creature->IsWithinLOSInMap(who)) - { - if(who->HasStealthAura()) - who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); - DoStartAttackAndMovement(who); - } - } - } - - void UpdateAI(const uint32 diff) - { - if(!start) - { - if(m_creature->GetPositionY() > 1150) - m_creature->GetMotionMaster()->MovePoint(0, hatcherway_l[3][0]+rand()%4-2,hatcherway_l[3][1]+rand()%4-2,hatcherway_l[3][2]); - else - m_creature->GetMotionMaster()->MovePoint(0,hatcherway_r[3][0]+rand()%4-2,hatcherway_r[3][1]+rand()%4-2,hatcherway_r[3][2]); - start = true; - } - - if(delete_timer < diff && (pInstance && !(pInstance->GetData(DATA_JANALAIEVENT) == 1))) - { - if(!(m_creature->getVictim())) - m_creature->DealDamage(m_creature, m_creature->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); - delete_timer = 10000; - }else delete_timer -=diff; - - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - if (buffer_timer < diff) - { - Unit* target = NULL; - target = SelectUnit(SELECT_TARGET_RANDOM,0); - if(target) - DoCast(target,SPELL_FLAMEBUFFED); - - buffer_timer = 7000; - }else buffer_timer -=diff; - - DoMeleeAttackIfReady(); - } -}; - -CreatureAI* GetAI_mob_hatchlingAI(Creature *_Creature) -{ - return new mob_hatchlingAI (_Creature); -} - -void AddSC_boss_janalai() -{ - Script *newscript; - - newscript = new Script; - newscript->Name="boss_janalai"; - newscript->GetAI = GetAI_boss_janalaiAI; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="mob_jandalai_firebomb"; - newscript->GetAI = GetAI_mob_jandalai_firebombAI; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="mob_amanishi_hatcher"; - newscript->GetAI = GetAI_mob_amanishi_hatcherAI; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="mob_hatchling"; - newscript->GetAI = GetAI_mob_hatchlingAI; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006,2007 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Janalai +SD%Complete: 100 +SDComment: +SDCategory: Zul'Aman +EndScriptData */ + +#include "precompiled.h" +#include "def_zulaman.h" + +// Jan'alai +// --Spell +#define SPELL_FLAME_BREATH 43140 +#define SPELL_FIRE_WALL 43113 +#define SPELL_ENRAGE 44779 +#define SPELL_TELETOCENTER 43098 +#define SPELL_SUMMONALL 43097 +#define SPELL_BERSERK 47008 +// -- Fire Bob Spells +#define MOB_FIRE_BOMB 23920 +#define SPELL_FIRE_BOMB_CHANNEL 42621 +#define SPELL_FIRE_BOMB_THROW 42628 +#define SPELL_FIRE_BOMB_DUMMY 42629 +#define SPELL_FIRE_BOMB_DAMAGE 42630 + +// -- SAYs +#define SOUND_AGGRO 12031 +#define SAY_AGGRO "Spirits of da wind be your doom!" +#define SOUND_FIRE_BOMBS 12032 +#define SAY_FIRE_BOMBS "I burn ya now!" +#define SOUND_SUMMON_HATCHER 12033 +#define SAY_SUMMON_HATCHER "Where ma hatcha? Get to work on dem eggs!" +#define SOUND_ALL_EGGS 12034 +#define SAY_ALL_EGGS "I show you strength... in numbers." +#define SOUND_BERSERK 12035 +#define SAY_BERSERK "You done run outta time!" + +#define SOUND_SLAY_1 12036 +#define SAY_SLAY_1 "It all be over now, mon!" +#define SOUND_SLAY_2 12037 +#define SAY_SLAY_2 "Tazaga-choo!" + +#define SOUND_DEATH 12038 +#define SAY_DEATH "Zul'jin... got a surprise for you..." + +#define SOUND_AGGRO_1 12039 //NOT USED need more information + //NOT USED need more information (random say before aggro?) +#define SAY_AGGRO_1 "Come, strangers. The spirit of the dragonhawk hot be hungry for worthy souls." +#define SOUND_AGGRO_2 12040 //NOT USED need more information + //NOT USED need more information (random say before aggro?) +#define SAY_AGGRO_2 "Come, friends. Your bodies gonna feed ma hatchlings, and your souls are going to feed me with power!" + +// --Summons +#define MOB_AMANI_HATCHER 23818 +#define MOB_HATCHLING 23598 + +// -- Hatcher Spells +#define SPELL_HATCH_EGG 43734 + +// -- Hatchling Spells +#define SPELL_FLAMEBUFFED 43299 + +const int area_dx = 44; +const int area_dy = 51; + +float JanalainPos[1][3] = +{ + {-33.93, 1149.27, 19} +}; + +float FireWallCoords[4][4] = +{ + {-10.13, 1149.27, 19, 3.1415}, + {-33.93, 1123.90, 19, 0.5*3.1415}, + {-54.80, 1150.08, 19, 0}, + {-33.93, 1175.68, 19, 1.5*3.1415} +}; + +float hatcherway_l[5][3] = +{ + {-87.46,1170.09,6}, + {-74.41,1154.75,6}, + {-52.74,1153.32,19}, + {-33.37,1172.46,19}, + {-33.09,1203.87,19} +}; + +float hatcherway_r[5][3] = +{ + {-86.57,1132.85,6}, + {-73.94,1146.00,6}, + {-52.29,1146.51,19}, + {-33.57,1125.72,19}, + {-34.29,1095.22,19} +}; + +struct MANGOS_DLL_DECL boss_janalaiAI : public ScriptedAI +{ + boss_janalaiAI(Creature *c) : ScriptedAI(c) + { + pInstance = ((ScriptedInstance*)c->GetInstanceData()); + Reset(); + } + + ScriptedInstance *pInstance; + + uint32 fire_breath_timer; + uint32 bomb_timer; + uint32 throw_timer; + uint32 enrage_timer; + uint32 finishedbomb_timer; + uint32 bombcounter; + uint32 hatchertime; + uint32 eggs; + uint32 wipetimer; + uint32 reset_timer; + bool noeggs; + bool enraged; + bool enragetime; + + uint64 FireBombGUIDs[40]; + uint64 ThrowControllerGUID; + + bool bombing; + + void Reset() + { + if(pInstance) + pInstance->SetData(DATA_JANALAIEVENT, NOT_STARTED); + + fire_breath_timer = 8000; + bomb_timer = 30000; + enrage_timer = 300000; // 5 minutes + finishedbomb_timer = 6000; + throw_timer = 1000; + bombcounter = 0; + noeggs = false; + hatchertime = 10000; + wipetimer = 600000; // 10 mins + bombing =false; + reset_timer = 5000; + enraged = false; + enragetime = false; + + ThrowControllerGUID = 0; + + for(uint8 i = 0; i < 40; i++) + FireBombGUIDs[i] = 0; + } + + void JustDied(Unit* Killer) + { + DoYell(SAY_DEATH, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature,SOUND_DEATH); + + if(pInstance) + pInstance->SetData(DATA_JANALAIEVENT, DONE); + } + + void KilledUnit(Unit* victim) + { + switch(rand()%2) + { + case 0: + DoYell(SAY_SLAY_1, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature,SOUND_SLAY_1); + break; + case 1: + DoYell(SAY_SLAY_2, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature,SOUND_SLAY_1); + break; + } + } + + void Aggro(Unit *who) + { + if(pInstance) + pInstance->SetData(DATA_JANALAIEVENT, IN_PROGRESS); + + DoYell(SAY_AGGRO, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature,SOUND_AGGRO); + } + + void FireWall() // Create Firewall + { + Creature* wall = NULL; + wall = m_creature->SummonCreature(MOB_FIRE_BOMB,FireWallCoords[0][0],FireWallCoords[0][1],FireWallCoords[0][2],FireWallCoords[0][3],TEMPSUMMON_TIMED_DESPAWN,11500); + if(wall) + wall->CastSpell(wall,SPELL_FIRE_WALL,false); + + wall = m_creature->SummonCreature(MOB_FIRE_BOMB,FireWallCoords[0][0],FireWallCoords[0][1]+5,FireWallCoords[0][2],FireWallCoords[0][3],TEMPSUMMON_TIMED_DESPAWN,11500); + if(wall) + wall->CastSpell(wall,SPELL_FIRE_WALL,false); + + wall = m_creature->SummonCreature(MOB_FIRE_BOMB,FireWallCoords[0][0],FireWallCoords[0][1]-5,FireWallCoords[0][2],FireWallCoords[0][3],TEMPSUMMON_TIMED_DESPAWN,11500); + if(wall) + wall->CastSpell(wall,SPELL_FIRE_WALL,false); + + wall = m_creature->SummonCreature(MOB_FIRE_BOMB,FireWallCoords[1][0]-2,FireWallCoords[1][1]-2,FireWallCoords[1][2],FireWallCoords[1][3],TEMPSUMMON_TIMED_DESPAWN,11500); + if(wall) + wall->CastSpell(wall,SPELL_FIRE_WALL,false); + + wall = m_creature->SummonCreature(MOB_FIRE_BOMB,FireWallCoords[1][0]+2,FireWallCoords[1][1]+2,FireWallCoords[1][2],FireWallCoords[1][3],TEMPSUMMON_TIMED_DESPAWN,11500); + if(wall) + wall->CastSpell(wall,SPELL_FIRE_WALL,false); + + wall = m_creature->SummonCreature(MOB_FIRE_BOMB,FireWallCoords[2][0],FireWallCoords[2][1],FireWallCoords[2][2],FireWallCoords[2][3],TEMPSUMMON_TIMED_DESPAWN,11500); + if(wall) + wall->CastSpell(wall,SPELL_FIRE_WALL,false); + + wall = m_creature->SummonCreature(MOB_FIRE_BOMB,FireWallCoords[2][0],FireWallCoords[2][1]-5,FireWallCoords[2][2],FireWallCoords[2][3],TEMPSUMMON_TIMED_DESPAWN,11500); + if(wall) + wall->CastSpell(wall,SPELL_FIRE_WALL,false); + + wall = m_creature->SummonCreature(MOB_FIRE_BOMB,FireWallCoords[2][0],FireWallCoords[2][1]+5,FireWallCoords[2][2],FireWallCoords[2][3],TEMPSUMMON_TIMED_DESPAWN,11500); + if(wall) + wall->CastSpell(wall,SPELL_FIRE_WALL,false); + + wall = m_creature->SummonCreature(MOB_FIRE_BOMB,FireWallCoords[3][0]-2,FireWallCoords[3][1],FireWallCoords[3][2],FireWallCoords[3][3],TEMPSUMMON_TIMED_DESPAWN,11500); + if(wall) + wall->CastSpell(wall,SPELL_FIRE_WALL,false); + + wall = m_creature->SummonCreature(MOB_FIRE_BOMB,FireWallCoords[3][0]+2,FireWallCoords[3][1],FireWallCoords[3][2],FireWallCoords[3][3],TEMPSUMMON_TIMED_DESPAWN,11500); + if(wall) + wall->CastSpell(wall,SPELL_FIRE_WALL,false); + } + + void throwBombs() // create Bombs + { + float dx; + float dy; + for ( int i(0); i < 40; i++) + { + dx = (rand()%(area_dx))-(area_dx/2); + dy = (rand()%(area_dy))-(area_dy/2); + + Creature* bomb = DoSpawnCreature(MOB_FIRE_BOMB, dx, dy, 0, 0, TEMPSUMMON_TIMED_DESPAWN, 13000); + if(bomb) + FireBombGUIDs[i] = bomb->GetGUID(); + } + + Creature* ThrowController = DoSpawnCreature(MOB_FIRE_BOMB,0,0,1,0,TEMPSUMMON_TIMED_DESPAWN,10000); + if(ThrowController) + ThrowControllerGUID = ThrowController->GetGUID(); + + bombcounter = 0; + } + + void throw5Bombs() //throwanimation + { + for ( int i(0); i < 5; i++) + { + Unit* ThrowController = NULL; + Unit* FireBomb = NULL; + if(ThrowControllerGUID) + ThrowController = Unit::GetUnit((*m_creature), ThrowControllerGUID); + + if(FireBombGUIDs[bombcounter]) + FireBomb = Unit::GetUnit((*m_creature), FireBombGUIDs[bombcounter]); + + if(ThrowController && FireBomb) + { + ThrowController->CastSpell(FireBomb,SPELL_FIRE_BOMB_THROW,true); + FireBomb->CastSpell(FireBomb,SPELL_FIRE_BOMB_DUMMY,false); + bombcounter ++; + } + } + } + + void UpdateAI(const uint32 diff) + { + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + if(!bombing) // every Spell if NOT Bombing + { + //FIRE BREATH several videos says every 8Secounds + if(fire_breath_timer < diff) + { + Unit* target = NULL; + target = SelectUnit(SELECT_TARGET_RANDOM,0); + if(target) + DoCast(target,SPELL_FLAME_BREATH); + fire_breath_timer = 8000; + }else fire_breath_timer -=diff; + + if(bomb_timer < diff) + { + FireWall(); + bomb_timer = 20000+rand()%20000; + m_creature->Relocate(JanalainPos[0][0],JanalainPos[0][1],JanalainPos[0][2],0); + m_creature->SendMonsterMove(JanalainPos[0][0], JanalainPos[0][1],JanalainPos[0][2],0,0,100); + DoYell(SAY_FIRE_BOMBS, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature,SOUND_FIRE_BOMBS); + throwBombs(); + bombing = true; + + //Teleport every Player into the middle + Unit* Temp = NULL; + std::list::iterator i = m_creature->getThreatManager().getThreatList().begin(); + for (; i != m_creature->getThreatManager().getThreatList().end(); ++i) + { + Temp = Unit::GetUnit((*m_creature),(*i)->getUnitGuid()); + if (Temp && m_creature->GetDistance(Temp) > 30.0) + DoTeleportPlayer(Temp, m_creature->GetPositionX(), m_creature->GetPositionY(), m_creature->GetPositionZ(), 0); + } + DoCast(m_creature,SPELL_TELETOCENTER,true); // only Effect Spell + DoCast(m_creature,SPELL_FIRE_BOMB_CHANNEL,false); + finishedbomb_timer = 11000; + }else bomb_timer -=diff; + + //enrage if under 25% hp before 5 min. + if (((m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < 25) && !enraged) + { + enragetime = true; + enrage_timer = 600000; + } + + //Enrage but only if not bombing + if(enragetime && !enraged) + { + DoYell(SAY_BERSERK, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature,SOUND_BERSERK); + m_creature->InterruptNonMeleeSpells(false); + DoCast(m_creature,SPELL_ENRAGE); + enraged = true; + } + } + + //Enrage after 5 minutes + if(enrage_timer < diff) + { + enragetime = true; + enrage_timer = 600000; + }else enrage_timer -=diff; + + if(bombing) // every Spell if Bombing + { + if(bombcounter < 40) + { + if(throw_timer < diff) + { + throw5Bombs(); + throw_timer = 1000; + }else throw_timer -=diff; + } + + if(finishedbomb_timer < diff) + { + bombing = false; + finishedbomb_timer = 6000; + m_creature->RemoveAura(SPELL_FIRE_BOMB_CHANNEL,0); + m_creature->RemoveAura(SPELL_FIRE_BOMB_CHANNEL,1); + }else finishedbomb_timer -=diff; + } + + //Call Hatcher + if(!noeggs) + { + if(hatchertime < diff) + { + if(pInstance->GetData(DATA_J_EGGSLEFT)>0 || pInstance->GetData(DATA_J_EGGSRIGHT) > 0) + { + Unit* hatcher = NULL; + DoYell(SAY_SUMMON_HATCHER, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature,SOUND_SUMMON_HATCHER); + hatcher = m_creature->SummonCreature(MOB_AMANI_HATCHER,hatcherway_l[0][0],hatcherway_l[0][1],hatcherway_l[0][2],0,TEMPSUMMON_CORPSE_TIMED_DESPAWN,10000); + if(hatcher) + hatcher->GetMotionMaster()->MovePoint(0, hatcherway_l[0][0], hatcherway_l[0][1], hatcherway_l[0][2]); + + hatcher = m_creature->SummonCreature(MOB_AMANI_HATCHER,hatcherway_r[0][0],hatcherway_r[0][1],hatcherway_r[0][2],0,TEMPSUMMON_CORPSE_TIMED_DESPAWN,10000); + if(hatcher) + hatcher->GetMotionMaster()->MovePoint(0, hatcherway_r[0][0],hatcherway_r[0][1],hatcherway_r[0][2]); + hatchertime = 45000; + } + else + { + noeggs = true; + } + }else hatchertime -=diff; + } + + //WIPE after 10 minutes + if(wipetimer < diff) + { + DoYell(SAY_BERSERK, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature,SOUND_BERSERK); + DoCast(m_creature,SPELL_ENRAGE); + + wipetimer = 30000; + }else wipetimer -=diff; + + //Hatch All + if(!noeggs && (m_creature->GetHealth()*100) / m_creature->GetMaxHealth() < 35) + { + DoYell(SAY_ALL_EGGS , LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature,SOUND_BERSERK); + + if(pInstance) + eggs = pInstance->GetData(DATA_J_EGGSLEFT); + + int i; + for(i=1;i<=eggs;i=i+1) + { + int r = (rand()%20 - 10); + int s = (rand()%20 - 10); + m_creature->SummonCreature(MOB_HATCHLING,JanalainPos[0][0]+s,JanalainPos[0][1]+r,JanalainPos[0][2],0,TEMPSUMMON_CORPSE_TIMED_DESPAWN,15000); + + if(pInstance) + pInstance->SetData(DATA_J_HATCHLEFT,1); + } + + if(pInstance) + eggs = pInstance->GetData(DATA_J_EGGSRIGHT); + + for(i=1;i<=eggs;i=i+1) + { + int r = (rand()%20 - 10); + int s = (rand()%20 - 10); + m_creature->SummonCreature(MOB_HATCHLING,JanalainPos[0][0]+s,JanalainPos[0][1]+r,JanalainPos[0][2],0,TEMPSUMMON_CORPSE_TIMED_DESPAWN,15000); + if(pInstance) + pInstance->SetData(DATA_J_HATCHRIGHT,1); + } + + noeggs = true; + } + + //check for reset ... exploit preventing ... pulled from his podest + if(reset_timer < diff) + { + if(m_creature->GetPositionX() < -70 || m_creature->GetPositionX() > 0) + { + EnterEvadeMode(); + reset_timer = 5000; //every 5 Seca + } + }else reset_timer -=diff; + + DoMeleeAttackIfReady(); + } +}; + +CreatureAI* GetAI_boss_janalaiAI(Creature *_Creature) +{ + return new boss_janalaiAI (_Creature); +} + +struct MANGOS_DLL_DECL mob_jandalai_firebombAI : public ScriptedAI +{ + mob_jandalai_firebombAI(Creature *c) : ScriptedAI(c){Reset();} + + uint32 bomb_timer; + + void Reset() + { + bomb_timer = 12000; + } + + void Aggro(Unit* who) {} + + void AttackStart(Unit* who) {} + + void MoveInLineOfSight(Unit* who) {} + + void UpdateAI(const uint32 diff) + { + if(bomb_timer < diff) //Boom + { + m_creature->CastSpell(m_creature,SPELL_FIRE_BOMB_DAMAGE,false); + bomb_timer = 1800000; + }else bomb_timer -=diff; + } +}; + +CreatureAI* GetAI_mob_jandalai_firebombAI(Creature *_Creature) +{ + return new mob_jandalai_firebombAI (_Creature); +} + +struct MANGOS_DLL_DECL mob_amanishi_hatcherAI : public ScriptedAI +{ + mob_amanishi_hatcherAI(Creature *c) : ScriptedAI(c) + { + pInstance = ((ScriptedInstance*)c->GetInstanceData()); + Reset(); + } + + ScriptedInstance *pInstance; + + uint32 waypoint; + bool waytype; + bool start; + bool hatch; + bool wait; + uint32 hatchlings; + uint32 waittimer; + uint32 eggs; + uint32 delete_timer; + + void Reset() + { + waypoint = 0; + waytype = 0; + hatch = false; + start = false; + wait = false; + waittimer = 4000; + hatchlings = 0; + eggs = 0; + delete_timer = 10000; + + //m_creature->RemoveAllAuras(); + //m_creature->DeleteThreatList(); + //m_creature->CombatStop(); + //DoGoHome(); + } + + void Aggro(Unit* who) + { + } + + void UpdateAI(const uint32 diff) + { + if(pInstance && (pInstance->GetData(DATA_JANALAIEVENT) == 1)) + { + if(!start && !hatch) + { + waytype = ( m_creature->GetPositionY() > 1150); + waypoint = 1; + start = true; + } + + if(start && !hatch) + { + if(wait) + { + if(waittimer < diff) + { + wait = false; + waittimer = 4000; + waypoint++; + + if (waypoint == 5) + { + hatch = true; + waittimer = 0; + hatchlings = 1; + } + } + else + { + waittimer -=diff; + } + } + else + { + m_creature->GetMotionMaster()->Clear(); + if(waytype) + m_creature->GetMotionMaster()->MovePoint(0,hatcherway_l[waypoint][0],hatcherway_l[waypoint][1],hatcherway_l[waypoint][2]); + else + m_creature->GetMotionMaster()->MovePoint(0,hatcherway_r[waypoint][0],hatcherway_r[waypoint][1],hatcherway_r[waypoint][2]); + wait= true; + } + } + + if(start && hatch) + { + if(waittimer < diff) + { + if(!pInstance) + return; + + waittimer = 4000; + Unit* hatchling; + + if(waytype) + { + eggs = pInstance->GetData(DATA_J_EGGSLEFT); + + if(eggs > 0) + DoCast(m_creature,SPELL_HATCH_EGG); + + int i; + for(i=1;i<=hatchlings;i=i+1) + { + eggs = pInstance->GetData(DATA_J_EGGSLEFT); + if(eggs <= 0) + { + if (waytype) waytype = false; else waytype = true; + waittimer = 15000; + hatch = false; + waypoint = 4; + wait = true; + i = hatchlings; + } + else + { + hatchling = DoSpawnCreature(MOB_HATCHLING,rand()%4-2,rand()%4-2,0,0,TEMPSUMMON_CORPSE_TIMED_DESPAWN,15000); + pInstance->SetData(DATA_J_HATCHLEFT,1); + } + } + + DoCast(m_creature,SPELL_HATCH_EGG); + + if(hatchlings < 5) + hatchlings++; + } + else + { + eggs = pInstance->GetData(DATA_J_EGGSRIGHT); + + if(eggs > 0) + DoCast(m_creature,SPELL_HATCH_EGG); + + int i; + for(i=1;i<=hatchlings;i=i+1) + { + eggs = pInstance->GetData(DATA_J_EGGSRIGHT); + if(eggs <= 0) + { + if (waytype) waytype = false; else waytype = true; + waittimer = 15000; + hatch = false; + waypoint = 4; + wait = true; + i = hatchlings; + } + else + { + hatchling = DoSpawnCreature(MOB_HATCHLING,rand()%4-2,rand()%4-2,0,0,TEMPSUMMON_CORPSE_TIMED_DESPAWN,15000); + pInstance->SetData(DATA_J_HATCHRIGHT,1); + } + } + + DoCast(m_creature,SPELL_HATCH_EGG); + hatchlings++; + } + }else waittimer -=diff; + } + } + else + { + if(delete_timer < diff) + { + m_creature->DealDamage(m_creature, m_creature->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); + delete_timer = 10000; + }else delete_timer -=diff; + } + } +}; + +CreatureAI* GetAI_mob_amanishi_hatcherAI(Creature *_Creature) +{ + return new mob_amanishi_hatcherAI (_Creature); +} + +struct MANGOS_DLL_DECL mob_hatchlingAI : public ScriptedAI +{ + mob_hatchlingAI(Creature *c) : ScriptedAI(c) + { + pInstance = ((ScriptedInstance*)c->GetInstanceData()); + Reset(); + } + + ScriptedInstance *pInstance; + + uint32 buffer_timer; + uint32 delete_timer; + bool start; + + void Reset() + { + buffer_timer = 7000; + delete_timer = 10000; + start = false; + } + + void Aggro(Unit *who) + { + } + + void UpdateAI(const uint32 diff) + { + if(!start) + { + if(m_creature->GetPositionY() > 1150) + m_creature->GetMotionMaster()->MovePoint(0, hatcherway_l[3][0]+rand()%4-2,hatcherway_l[3][1]+rand()%4-2,hatcherway_l[3][2]); + else + m_creature->GetMotionMaster()->MovePoint(0,hatcherway_r[3][0]+rand()%4-2,hatcherway_r[3][1]+rand()%4-2,hatcherway_r[3][2]); + start = true; + } + + if(delete_timer < diff && (pInstance && !(pInstance->GetData(DATA_JANALAIEVENT) == 1))) + { + if(!(m_creature->getVictim())) + m_creature->DealDamage(m_creature, m_creature->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); + delete_timer = 10000; + }else delete_timer -=diff; + + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + if (buffer_timer < diff) + { + Unit* target = NULL; + target = SelectUnit(SELECT_TARGET_RANDOM,0); + if(target) + DoCast(target,SPELL_FLAMEBUFFED); + + buffer_timer = 7000; + }else buffer_timer -=diff; + + DoMeleeAttackIfReady(); + } +}; + +CreatureAI* GetAI_mob_hatchlingAI(Creature *_Creature) +{ + return new mob_hatchlingAI (_Creature); +} + +void AddSC_boss_janalai() +{ + Script *newscript; + + newscript = new Script; + newscript->Name="boss_janalai"; + newscript->GetAI = GetAI_boss_janalaiAI; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="mob_jandalai_firebomb"; + newscript->GetAI = GetAI_mob_jandalai_firebombAI; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="mob_amanishi_hatcher"; + newscript->GetAI = GetAI_mob_amanishi_hatcherAI; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="mob_hatchling"; + newscript->GetAI = GetAI_mob_hatchlingAI; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/zulaman/boss_nalorakk.cpp b/src/bindings/scripts/scripts/zone/zulaman/boss_nalorakk.cpp index 01dae191217..0a207eae946 100644 --- a/src/bindings/scripts/scripts/zone/zulaman/boss_nalorakk.cpp +++ b/src/bindings/scripts/scripts/zone/zulaman/boss_nalorakk.cpp @@ -1,272 +1,272 @@ -/* Copyright (C) 2006,2007 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Nalorakk -SD%Complete: 80 -SDComment: Todo: Trash Waves -SDCategory: Zul'Aman -EndScriptData */ - -#include "precompiled.h" - -//TODO: Trash Waves - -//Unimplemented SoundIDs -/* -#define SOUND_NALORAKK_WAVE1 12066 -#define SOUND_NALORAKK_WAVE2 12067 -#define SOUND_NALORAKK_WAVE3 12068 -#define SOUND_NALORAKK_WAVE4 12069 - -#define SOUND_NALORAKK_EVENT1 12078 -#define SOUND_NALORAKK_EVENT2 12079 -*/ - -//General defines -#define YELL_AGGRO "You be dead soon enough!" -#define SOUND_YELL_AGGRO 12070 -#define YELL_KILL_ONE "Mua-ha-ha! Now whatchoo got to say?" -#define SOUND_YELL_KILL_ONE 12075 -#define YELL_KILL_TWO "Da Amani gonna rule again!" -#define SOUND_YELL_KILL_TWO 12076 -#define YELL_DEATH "I... be waitin' on da udda side...." -#define SOUND_YELL_DEATH 12077 - //Never seen this being used, so just guessing from what I hear. -#define YELL_BERSERK "You had your chance, now it be too late!" -#define SOUND_YELL_BERSERK 12074 - -#define SPELL_BERSERK 45078 //unsure, this increases damage, size and speed - -//Defines for Troll form -#define SPELL_BRUTALSWIPE 42384 -//#define SPELL_MANGLE 42389 This doesn't seem to apply the mangle debuff after all -#define SPELL_MANGLEEFFECT 44955 -#define SPELL_SURGE 42402 -#define SPELL_BEARFORM 42377 - -#define YELL_SURGE "I bring da pain!" -#define SOUND_YELL_SURGE 12071 - -#define YELL_SHIFTEDTOTROLL "Make way for Nalorakk!" -#define SOUND_YELL_TOTROLL 12073 - -//Defines for Bear form -#define SPELL_LACERATINGSLASH 42395 -#define SPELL_RENDFLESH 42397 -#define SPELL_DEAFENINGROAR 42398 - -#define YELL_SHIFTEDTOBEAR "You call on da beast, you gonna get more dan you bargain for!" -#define SOUND_YELL_TOBEAR 12072 - -struct MANGOS_DLL_DECL boss_nalorakkAI : public ScriptedAI -{ - boss_nalorakkAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 ChangeForm_Timer; - uint32 BrutalSwipe_Timer; - uint32 Mangle_Timer; - uint32 Surge_Timer; - uint32 LaceratingSlash_Timer; - uint32 RendFlesh_Timer; - uint32 DeafeningRoar_Timer; - uint32 ShapeShiftCheck_Timer; - uint32 Berserk_Timer; - bool inBearForm; - bool Berserking; - bool ChangedToBear; - bool ChangedToTroll; - - void Reset() - { - ChangeForm_Timer = 45000; - BrutalSwipe_Timer = 12000; - Mangle_Timer = 15000; - Surge_Timer = 20000; - LaceratingSlash_Timer = 6000; - RendFlesh_Timer = 6000; - DeafeningRoar_Timer = 20000; - ShapeShiftCheck_Timer = 40000; - Berserk_Timer = 600000; - inBearForm = false; - Berserking = false; - ChangedToBear = false; - ChangedToTroll = true; - } - - void Aggro(Unit *who) - { - DoYell(YELL_AGGRO, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_YELL_AGGRO); - } - - void KilledUnit(Unit* victim) - { - switch(rand()%2) - { - case 0: - DoYell(YELL_KILL_ONE, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_YELL_KILL_ONE); - break; - case 1: - DoYell(YELL_KILL_TWO, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_YELL_KILL_TWO); - break; - } - } - - void JustDied(Unit* Killer) - { - DoYell(YELL_DEATH,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature, SOUND_YELL_DEATH); - } - - void UpdateAI(const uint32 diff) - { - //Return since we have no target - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - //Berserking - if ((Berserk_Timer < diff) && (!Berserking)) - { - DoCast(m_creature, SPELL_BERSERK); - DoYell(YELL_BERSERK, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_YELL_BERSERK); - Berserking = true; - }else Berserk_Timer -= diff; - - //Don't check if we're shapeshifted every UpdateAI - if (ShapeShiftCheck_Timer < diff) - { - //This will return true if we have bearform aura - inBearForm = m_creature->HasAura(SPELL_BEARFORM, 0); - ShapeShiftCheck_Timer = 1000; - }else ShapeShiftCheck_Timer -= diff; - - //Spells for Troll Form (only to be casted if we NOT have bear phase aura) - if (!inBearForm) - { - //We just changed to troll form! - if (!ChangedToTroll) - { - DoYell(YELL_SHIFTEDTOTROLL, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_YELL_TOTROLL); - ChangedToTroll = true; - ChangedToBear = false; - //Reset spell timers - LaceratingSlash_Timer = 6000 + rand()%19000; - RendFlesh_Timer = 6000 + rand()%19000; - DeafeningRoar_Timer = 15000 + rand()%10000; - ShapeShiftCheck_Timer = 40000; - } - - //Brutal Swipe (some sources may say otherwise, but I've never seen this in Bear form) - if (BrutalSwipe_Timer < diff) - { - DoCast(m_creature->getVictim(), SPELL_BRUTALSWIPE); - BrutalSwipe_Timer = 7000 + rand()%13000; - }else BrutalSwipe_Timer -= diff; - - //Mangle - if (Mangle_Timer < diff) - { - DoCast(m_creature->getVictim(), SPELL_MANGLEEFFECT); - Mangle_Timer = 3000 + rand()%17000; - }else Mangle_Timer -= diff; - - //Surge - if (Surge_Timer < diff) - { - //select a random unit other than the main tank - Unit *target = SelectUnit(SELECT_TARGET_RANDOM, 1); - - //if there aren't other units, cast on the tank - if(!target) - target = m_creature->getVictim(); - - DoCast(target, SPELL_SURGE); - - DoYell(YELL_SURGE, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_YELL_SURGE); - - Surge_Timer = 15000 + rand()%17500; - }else Surge_Timer -= diff; - - //Change to Bear Form if we're in Troll Form for 45sec - if (ChangeForm_Timer < diff) - { - DoCast(m_creature, SPELL_BEARFORM); - //And 30sec (bear form) + 45sec (troll form) before we should cast this again - ChangeForm_Timer = 75000; - }else ChangeForm_Timer -= diff; - } - //Spells for Bear Form (only to be casted if we have bear phase aura) - else - { - //We just changed to bear form! - if (!ChangedToBear) - { - DoYell(YELL_SHIFTEDTOBEAR, LANG_UNIVERSAL, NULL); - DoPlaySoundToSet(m_creature, SOUND_YELL_TOBEAR); - ChangedToBear = true; - ChangedToTroll = false; - //Reset spell timers - Surge_Timer = 15000 + rand()%17500; - BrutalSwipe_Timer = 7000 + rand()%13000; - Mangle_Timer = 3000 + rand()%17000; - ShapeShiftCheck_Timer = 25000; - } - - //Lacerating Slash - if (LaceratingSlash_Timer < diff) - { - DoCast(m_creature->getVictim(), SPELL_LACERATINGSLASH); - LaceratingSlash_Timer = 6000 + rand()%19000; - }else LaceratingSlash_Timer -= diff; - - //Rend Flesh - if (RendFlesh_Timer < diff) - { - DoCast(m_creature->getVictim(), SPELL_RENDFLESH); - RendFlesh_Timer = 6000 + rand()%19000; - }else RendFlesh_Timer -= diff; - - //Deafening Roar - if (DeafeningRoar_Timer < diff) - { - DoCast(m_creature->getVictim(), SPELL_DEAFENINGROAR); - DeafeningRoar_Timer = 15000 + rand()%10000; - }else DeafeningRoar_Timer -= diff; - } - - DoMeleeAttackIfReady(); - } -}; - -CreatureAI* GetAI_boss_nalorakk(Creature *_Creature) -{ - return new boss_nalorakkAI (_Creature); -} - -void AddSC_boss_nalorakk() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_nalorakk"; - newscript->GetAI = GetAI_boss_nalorakk; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006,2007 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Nalorakk +SD%Complete: 80 +SDComment: Todo: Trash Waves +SDCategory: Zul'Aman +EndScriptData */ + +#include "precompiled.h" + +//TODO: Trash Waves + +//Unimplemented SoundIDs +/* +#define SOUND_NALORAKK_WAVE1 12066 +#define SOUND_NALORAKK_WAVE2 12067 +#define SOUND_NALORAKK_WAVE3 12068 +#define SOUND_NALORAKK_WAVE4 12069 + +#define SOUND_NALORAKK_EVENT1 12078 +#define SOUND_NALORAKK_EVENT2 12079 +*/ + +//General defines +#define YELL_AGGRO "You be dead soon enough!" +#define SOUND_YELL_AGGRO 12070 +#define YELL_KILL_ONE "Mua-ha-ha! Now whatchoo got to say?" +#define SOUND_YELL_KILL_ONE 12075 +#define YELL_KILL_TWO "Da Amani gonna rule again!" +#define SOUND_YELL_KILL_TWO 12076 +#define YELL_DEATH "I... be waitin' on da udda side...." +#define SOUND_YELL_DEATH 12077 + //Never seen this being used, so just guessing from what I hear. +#define YELL_BERSERK "You had your chance, now it be too late!" +#define SOUND_YELL_BERSERK 12074 + +#define SPELL_BERSERK 45078 //unsure, this increases damage, size and speed + +//Defines for Troll form +#define SPELL_BRUTALSWIPE 42384 +//#define SPELL_MANGLE 42389 This doesn't seem to apply the mangle debuff after all +#define SPELL_MANGLEEFFECT 44955 +#define SPELL_SURGE 42402 +#define SPELL_BEARFORM 42377 + +#define YELL_SURGE "I bring da pain!" +#define SOUND_YELL_SURGE 12071 + +#define YELL_SHIFTEDTOTROLL "Make way for Nalorakk!" +#define SOUND_YELL_TOTROLL 12073 + +//Defines for Bear form +#define SPELL_LACERATINGSLASH 42395 +#define SPELL_RENDFLESH 42397 +#define SPELL_DEAFENINGROAR 42398 + +#define YELL_SHIFTEDTOBEAR "You call on da beast, you gonna get more dan you bargain for!" +#define SOUND_YELL_TOBEAR 12072 + +struct MANGOS_DLL_DECL boss_nalorakkAI : public ScriptedAI +{ + boss_nalorakkAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 ChangeForm_Timer; + uint32 BrutalSwipe_Timer; + uint32 Mangle_Timer; + uint32 Surge_Timer; + uint32 LaceratingSlash_Timer; + uint32 RendFlesh_Timer; + uint32 DeafeningRoar_Timer; + uint32 ShapeShiftCheck_Timer; + uint32 Berserk_Timer; + bool inBearForm; + bool Berserking; + bool ChangedToBear; + bool ChangedToTroll; + + void Reset() + { + ChangeForm_Timer = 45000; + BrutalSwipe_Timer = 12000; + Mangle_Timer = 15000; + Surge_Timer = 20000; + LaceratingSlash_Timer = 6000; + RendFlesh_Timer = 6000; + DeafeningRoar_Timer = 20000; + ShapeShiftCheck_Timer = 40000; + Berserk_Timer = 600000; + inBearForm = false; + Berserking = false; + ChangedToBear = false; + ChangedToTroll = true; + } + + void Aggro(Unit *who) + { + DoYell(YELL_AGGRO, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_YELL_AGGRO); + } + + void KilledUnit(Unit* victim) + { + switch(rand()%2) + { + case 0: + DoYell(YELL_KILL_ONE, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_YELL_KILL_ONE); + break; + case 1: + DoYell(YELL_KILL_TWO, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_YELL_KILL_TWO); + break; + } + } + + void JustDied(Unit* Killer) + { + DoYell(YELL_DEATH,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature, SOUND_YELL_DEATH); + } + + void UpdateAI(const uint32 diff) + { + //Return since we have no target + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + //Berserking + if ((Berserk_Timer < diff) && (!Berserking)) + { + DoCast(m_creature, SPELL_BERSERK); + DoYell(YELL_BERSERK, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_YELL_BERSERK); + Berserking = true; + }else Berserk_Timer -= diff; + + //Don't check if we're shapeshifted every UpdateAI + if (ShapeShiftCheck_Timer < diff) + { + //This will return true if we have bearform aura + inBearForm = m_creature->HasAura(SPELL_BEARFORM, 0); + ShapeShiftCheck_Timer = 1000; + }else ShapeShiftCheck_Timer -= diff; + + //Spells for Troll Form (only to be casted if we NOT have bear phase aura) + if (!inBearForm) + { + //We just changed to troll form! + if (!ChangedToTroll) + { + DoYell(YELL_SHIFTEDTOTROLL, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_YELL_TOTROLL); + ChangedToTroll = true; + ChangedToBear = false; + //Reset spell timers + LaceratingSlash_Timer = 6000 + rand()%19000; + RendFlesh_Timer = 6000 + rand()%19000; + DeafeningRoar_Timer = 15000 + rand()%10000; + ShapeShiftCheck_Timer = 40000; + } + + //Brutal Swipe (some sources may say otherwise, but I've never seen this in Bear form) + if (BrutalSwipe_Timer < diff) + { + DoCast(m_creature->getVictim(), SPELL_BRUTALSWIPE); + BrutalSwipe_Timer = 7000 + rand()%13000; + }else BrutalSwipe_Timer -= diff; + + //Mangle + if (Mangle_Timer < diff) + { + DoCast(m_creature->getVictim(), SPELL_MANGLEEFFECT); + Mangle_Timer = 3000 + rand()%17000; + }else Mangle_Timer -= diff; + + //Surge + if (Surge_Timer < diff) + { + //select a random unit other than the main tank + Unit *target = SelectUnit(SELECT_TARGET_RANDOM, 1); + + //if there aren't other units, cast on the tank + if(!target) + target = m_creature->getVictim(); + + DoCast(target, SPELL_SURGE); + + DoYell(YELL_SURGE, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_YELL_SURGE); + + Surge_Timer = 15000 + rand()%17500; + }else Surge_Timer -= diff; + + //Change to Bear Form if we're in Troll Form for 45sec + if (ChangeForm_Timer < diff) + { + DoCast(m_creature, SPELL_BEARFORM); + //And 30sec (bear form) + 45sec (troll form) before we should cast this again + ChangeForm_Timer = 75000; + }else ChangeForm_Timer -= diff; + } + //Spells for Bear Form (only to be casted if we have bear phase aura) + else + { + //We just changed to bear form! + if (!ChangedToBear) + { + DoYell(YELL_SHIFTEDTOBEAR, LANG_UNIVERSAL, NULL); + DoPlaySoundToSet(m_creature, SOUND_YELL_TOBEAR); + ChangedToBear = true; + ChangedToTroll = false; + //Reset spell timers + Surge_Timer = 15000 + rand()%17500; + BrutalSwipe_Timer = 7000 + rand()%13000; + Mangle_Timer = 3000 + rand()%17000; + ShapeShiftCheck_Timer = 25000; + } + + //Lacerating Slash + if (LaceratingSlash_Timer < diff) + { + DoCast(m_creature->getVictim(), SPELL_LACERATINGSLASH); + LaceratingSlash_Timer = 6000 + rand()%19000; + }else LaceratingSlash_Timer -= diff; + + //Rend Flesh + if (RendFlesh_Timer < diff) + { + DoCast(m_creature->getVictim(), SPELL_RENDFLESH); + RendFlesh_Timer = 6000 + rand()%19000; + }else RendFlesh_Timer -= diff; + + //Deafening Roar + if (DeafeningRoar_Timer < diff) + { + DoCast(m_creature->getVictim(), SPELL_DEAFENINGROAR); + DeafeningRoar_Timer = 15000 + rand()%10000; + }else DeafeningRoar_Timer -= diff; + } + + DoMeleeAttackIfReady(); + } +}; + +CreatureAI* GetAI_boss_nalorakk(Creature *_Creature) +{ + return new boss_nalorakkAI (_Creature); +} + +void AddSC_boss_nalorakk() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_nalorakk"; + newscript->GetAI = GetAI_boss_nalorakk; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/zulaman/def_zulaman.h b/src/bindings/scripts/scripts/zone/zulaman/def_zulaman.h index 7a57eba2f51..66694fe51b6 100644 --- a/src/bindings/scripts/scripts/zone/zulaman/def_zulaman.h +++ b/src/bindings/scripts/scripts/zone/zulaman/def_zulaman.h @@ -1,17 +1,17 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software licensed under GPL version 2 - * Please see the included DOCS/LICENSE.TXT for more information */ - -#ifndef DEF_ZULAMAN_H -#define DEF_ZULAMAN_H - -#define DATA_JANALAI 1 -#define DATA_JANALAIEVENT 2 -#define DATA_J_EGGSLEFT 3 -#define DATA_J_EGGSRIGHT 4 -#define DATA_J_HATCHLEFT 5 -#define DATA_J_HATCHRIGHT 6 - -#define TYPE_RAND_VENDOR_1 7 -#define TYPE_RAND_VENDOR_2 8 -#endif +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software licensed under GPL version 2 + * Please see the included DOCS/LICENSE.TXT for more information */ + +#ifndef DEF_ZULAMAN_H +#define DEF_ZULAMAN_H + +#define DATA_JANALAI 1 +#define DATA_JANALAIEVENT 2 +#define DATA_J_EGGSLEFT 3 +#define DATA_J_EGGSRIGHT 4 +#define DATA_J_HATCHLEFT 5 +#define DATA_J_HATCHRIGHT 6 + +#define TYPE_RAND_VENDOR_1 7 +#define TYPE_RAND_VENDOR_2 8 +#endif diff --git a/src/bindings/scripts/scripts/zone/zulaman/instance_zulaman.cpp b/src/bindings/scripts/scripts/zone/zulaman/instance_zulaman.cpp index 7283a27d3a8..7f05e4e0bfb 100644 --- a/src/bindings/scripts/scripts/zone/zulaman/instance_zulaman.cpp +++ b/src/bindings/scripts/scripts/zone/zulaman/instance_zulaman.cpp @@ -1,137 +1,137 @@ -/* Copyright (C) 2006,2007 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Instance_Zulaman -SD%Complete: 80 -SDComment: -SDCategory: Zul'Aman -EndScriptData */ - -#include "precompiled.h" -#include "def_zulaman.h" - -#define ENCOUNTERS 1 -#define RAND_VENDOR 2 - -struct MANGOS_DLL_DECL instance_zulaman : public ScriptedInstance -{ - instance_zulaman(Map *Map) : ScriptedInstance(Map) {Initialize();}; - - uint64 janalai; - uint32 janalai_eggs_l; - uint32 janalai_eggs_r; - - uint32 Encounters[ENCOUNTERS]; - uint32 RandVendor[RAND_VENDOR]; - - void Initialize() - { - janalai = 0; - janalai_eggs_l = 20; - janalai_eggs_r = 20; - - for(uint8 i = 0; i < ENCOUNTERS; i++) - Encounters[i] = NOT_STARTED; - for(uint8 i = 0; i < RAND_VENDOR; i++) - RandVendor[i] = NOT_STARTED; - } - - bool IsEncounterInProgress() const - { - for(uint8 i = 0; i < ENCOUNTERS; i++) - if(Encounters[i] == IN_PROGRESS) return true; - - return false; - } - - void OnCreatureCreate(Creature *creature, uint32 creature_entry) - { - switch(creature_entry) - { - case 23578: - janalai = creature->GetGUID(); - break; - } - } - - uint64 GetData64(uint32 identifier) - { - if(identifier == DATA_JANALAI && janalai) - return janalai; - - return 0; - } - - void SetData(uint32 type, uint32 data) - { - switch(type) - { - case DATA_JANALAIEVENT: - if(data == 0) - { - janalai_eggs_l = 20; - janalai_eggs_r = 20; - } - Encounters[0] = data; - break; - case DATA_J_HATCHLEFT: - janalai_eggs_l -= data; - break; - case DATA_J_HATCHRIGHT: - janalai_eggs_r -= data; - break; - case TYPE_RAND_VENDOR_1: - RandVendor[0] = data; - break; - case TYPE_RAND_VENDOR_2: - RandVendor[1] = data; - break; - } - } - - uint32 GetData(uint32 type) - { - switch(type) - { - case DATA_JANALAIEVENT: - return Encounters[0]; - case DATA_J_EGGSLEFT: - return janalai_eggs_l; - case DATA_J_EGGSRIGHT: - return janalai_eggs_r; - case TYPE_RAND_VENDOR_1: - return RandVendor[0]; - case TYPE_RAND_VENDOR_2: - return RandVendor[1]; - } - return 0; - } -}; - -InstanceData* GetInstanceData_instance_zulaman(Map* map) -{ - return new instance_zulaman(map); -} - -void AddSC_instance_zulaman() -{ - Script *newscript; - newscript = new Script; - newscript->Name = "instance_zulaman"; - newscript->GetInstanceData = GetInstanceData_instance_zulaman; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006,2007 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Instance_Zulaman +SD%Complete: 80 +SDComment: +SDCategory: Zul'Aman +EndScriptData */ + +#include "precompiled.h" +#include "def_zulaman.h" + +#define ENCOUNTERS 1 +#define RAND_VENDOR 2 + +struct MANGOS_DLL_DECL instance_zulaman : public ScriptedInstance +{ + instance_zulaman(Map *Map) : ScriptedInstance(Map) {Initialize();}; + + uint64 janalai; + uint32 janalai_eggs_l; + uint32 janalai_eggs_r; + + uint32 Encounters[ENCOUNTERS]; + uint32 RandVendor[RAND_VENDOR]; + + void Initialize() + { + janalai = 0; + janalai_eggs_l = 20; + janalai_eggs_r = 20; + + for(uint8 i = 0; i < ENCOUNTERS; i++) + Encounters[i] = NOT_STARTED; + for(uint8 i = 0; i < RAND_VENDOR; i++) + RandVendor[i] = NOT_STARTED; + } + + bool IsEncounterInProgress() const + { + for(uint8 i = 0; i < ENCOUNTERS; i++) + if(Encounters[i] == IN_PROGRESS) return true; + + return false; + } + + void OnCreatureCreate(Creature *creature, uint32 creature_entry) + { + switch(creature_entry) + { + case 23578: + janalai = creature->GetGUID(); + break; + } + } + + uint64 GetData64(uint32 identifier) + { + if(identifier == DATA_JANALAI && janalai) + return janalai; + + return 0; + } + + void SetData(uint32 type, uint32 data) + { + switch(type) + { + case DATA_JANALAIEVENT: + if(data == 0) + { + janalai_eggs_l = 20; + janalai_eggs_r = 20; + } + Encounters[0] = data; + break; + case DATA_J_HATCHLEFT: + janalai_eggs_l -= data; + break; + case DATA_J_HATCHRIGHT: + janalai_eggs_r -= data; + break; + case TYPE_RAND_VENDOR_1: + RandVendor[0] = data; + break; + case TYPE_RAND_VENDOR_2: + RandVendor[1] = data; + break; + } + } + + uint32 GetData(uint32 type) + { + switch(type) + { + case DATA_JANALAIEVENT: + return Encounters[0]; + case DATA_J_EGGSLEFT: + return janalai_eggs_l; + case DATA_J_EGGSRIGHT: + return janalai_eggs_r; + case TYPE_RAND_VENDOR_1: + return RandVendor[0]; + case TYPE_RAND_VENDOR_2: + return RandVendor[1]; + } + return 0; + } +}; + +InstanceData* GetInstanceData_instance_zulaman(Map* map) +{ + return new instance_zulaman(map); +} + +void AddSC_instance_zulaman() +{ + Script *newscript; + newscript = new Script; + newscript->Name = "instance_zulaman"; + newscript->GetInstanceData = GetInstanceData_instance_zulaman; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/zulaman/zulaman.cpp b/src/bindings/scripts/scripts/zone/zulaman/zulaman.cpp index 965fc6cb11b..ebf945da7f9 100644 --- a/src/bindings/scripts/scripts/zone/zulaman/zulaman.cpp +++ b/src/bindings/scripts/scripts/zone/zulaman/zulaman.cpp @@ -1,108 +1,108 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Zulaman -SD%Complete: 90 -SDComment: Forest Frog will turn into different NPC's. Workaround to prevent new entry from running this script -SDCategory: Zul'Aman -EndScriptData */ - -/* ContentData -npc_forest_frog -EndContentData */ - -#include "precompiled.h" -#include "def_zulaman.h" - -/*###### -## npc_forest_frog -######*/ - -#define SPELL_REMOVE_AMANI_CURSE 43732 -#define SPELL_PUSH_MOJO 43923 -#define ENTRY_FOREST_FROG 24396 - -struct MANGOS_DLL_DECL npc_forest_frogAI : public ScriptedAI -{ - npc_forest_frogAI(Creature* c) : ScriptedAI(c) - { - pInstance = ((ScriptedInstance*)c->GetInstanceData()); - Reset(); - } - - ScriptedInstance *pInstance; - - void Reset() { } - - void Aggro(Unit *who) { } - - void DoSpawnRandom() - { - if( pInstance ) - { - uint32 cEntry = 0; - switch(rand()%11) - { - case 0: cEntry = 24024; break; //Kraz - case 1: cEntry = 24397; break; //Mannuth - case 2: cEntry = 24403; break; //Deez - case 3: cEntry = 24404; break; //Galathryn - case 4: cEntry = 24405; break; //Adarrah - case 5: cEntry = 24406; break; //Fudgerick - case 6: cEntry = 24407; break; //Darwen - case 7: cEntry = 24445; break; //Mitzi - case 8: cEntry = 24448; break; //Christian - case 9: cEntry = 24453; break; //Brennan - case 10: cEntry = 24455; break; //Hollee - } - - if( !pInstance->GetData(TYPE_RAND_VENDOR_1) ) - if(rand()%10 == 1) cEntry = 24408; //Gunter - if( !pInstance->GetData(TYPE_RAND_VENDOR_2) ) - if(rand()%10 == 1) cEntry = 24409; //Kyren - - if( cEntry ) m_creature->UpdateEntry(cEntry); - - if( cEntry == 24408) pInstance->SetData(TYPE_RAND_VENDOR_1,DONE); - if( cEntry == 24409) pInstance->SetData(TYPE_RAND_VENDOR_2,DONE); - } - } - - void SpellHit(Unit *caster, const SpellEntry *spell) - { - if( spell->Id == SPELL_REMOVE_AMANI_CURSE && caster->GetTypeId() == TYPEID_PLAYER && m_creature->GetEntry() == ENTRY_FOREST_FROG ) - { - //increase or decrease chance of mojo? - if( rand()%99 == 50 ) DoCast(caster,SPELL_PUSH_MOJO,true); - else DoSpawnRandom(); - } - } -}; -CreatureAI* GetAI_npc_forest_frog(Creature *_Creature) -{ - return new npc_forest_frogAI (_Creature); -} - -void AddSC_zulaman() -{ - Script *newscript; - - newscript = new Script; - newscript->Name="npc_forest_frog"; - newscript->GetAI = GetAI_npc_forest_frog; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Zulaman +SD%Complete: 90 +SDComment: Forest Frog will turn into different NPC's. Workaround to prevent new entry from running this script +SDCategory: Zul'Aman +EndScriptData */ + +/* ContentData +npc_forest_frog +EndContentData */ + +#include "precompiled.h" +#include "def_zulaman.h" + +/*###### +## npc_forest_frog +######*/ + +#define SPELL_REMOVE_AMANI_CURSE 43732 +#define SPELL_PUSH_MOJO 43923 +#define ENTRY_FOREST_FROG 24396 + +struct MANGOS_DLL_DECL npc_forest_frogAI : public ScriptedAI +{ + npc_forest_frogAI(Creature* c) : ScriptedAI(c) + { + pInstance = ((ScriptedInstance*)c->GetInstanceData()); + Reset(); + } + + ScriptedInstance *pInstance; + + void Reset() { } + + void Aggro(Unit *who) { } + + void DoSpawnRandom() + { + if( pInstance ) + { + uint32 cEntry = 0; + switch(rand()%11) + { + case 0: cEntry = 24024; break; //Kraz + case 1: cEntry = 24397; break; //Mannuth + case 2: cEntry = 24403; break; //Deez + case 3: cEntry = 24404; break; //Galathryn + case 4: cEntry = 24405; break; //Adarrah + case 5: cEntry = 24406; break; //Fudgerick + case 6: cEntry = 24407; break; //Darwen + case 7: cEntry = 24445; break; //Mitzi + case 8: cEntry = 24448; break; //Christian + case 9: cEntry = 24453; break; //Brennan + case 10: cEntry = 24455; break; //Hollee + } + + if( !pInstance->GetData(TYPE_RAND_VENDOR_1) ) + if(rand()%10 == 1) cEntry = 24408; //Gunter + if( !pInstance->GetData(TYPE_RAND_VENDOR_2) ) + if(rand()%10 == 1) cEntry = 24409; //Kyren + + if( cEntry ) m_creature->UpdateEntry(cEntry); + + if( cEntry == 24408) pInstance->SetData(TYPE_RAND_VENDOR_1,DONE); + if( cEntry == 24409) pInstance->SetData(TYPE_RAND_VENDOR_2,DONE); + } + } + + void SpellHit(Unit *caster, const SpellEntry *spell) + { + if( spell->Id == SPELL_REMOVE_AMANI_CURSE && caster->GetTypeId() == TYPEID_PLAYER && m_creature->GetEntry() == ENTRY_FOREST_FROG ) + { + //increase or decrease chance of mojo? + if( rand()%99 == 50 ) DoCast(caster,SPELL_PUSH_MOJO,true); + else DoSpawnRandom(); + } + } +}; +CreatureAI* GetAI_npc_forest_frog(Creature *_Creature) +{ + return new npc_forest_frogAI (_Creature); +} + +void AddSC_zulaman() +{ + Script *newscript; + + newscript = new Script; + newscript->Name="npc_forest_frog"; + newscript->GetAI = GetAI_npc_forest_frog; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/zulfarrak/zulfarrak.cpp b/src/bindings/scripts/scripts/zone/zulfarrak/zulfarrak.cpp index c526a83ad7e..1834bcf7ff8 100644 --- a/src/bindings/scripts/scripts/zone/zulfarrak/zulfarrak.cpp +++ b/src/bindings/scripts/scripts/zone/zulfarrak/zulfarrak.cpp @@ -1,224 +1,224 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Zulfarrak -SD%Complete: 50 -SDComment: Consider it temporary, no instance script made for this instance yet. -SDCategory: Zul'Farrak -EndScriptData */ - -/* ContentData -npc_sergeant_bly -npc_weegli_blastfuse -EndContentData */ - -#include "precompiled.h" - -/*###### -## npc_sergeant_bly -######*/ - -#define FACTION_HOSTILE 14 -#define FACTION_FRIENDLY 35 - -#define SPELL_SHIELD_BASH 11972 -#define SPELL_REVENGE 12170 - -#define GOSSIP_BLY "[PH] In that case, i will take my reward!" - -struct MANGOS_DLL_DECL npc_sergeant_blyAI : public ScriptedAI -{ - npc_sergeant_blyAI(Creature *c) : ScriptedAI(c) - { - //pInstance = ((ScriptedInstance*)c->GetInstanceData()); - Reset(); - } - - //ScriptedInstance* pInstance; - - uint32 ShieldBash_Timer; - uint32 Revenge_Timer; //this is wrong, spell should never be used unless m_creature->getVictim() dodge, parry or block attack. Mangos support required. - - void Reset() - { - ShieldBash_Timer = 5000; - Revenge_Timer = 8000; - - m_creature->setFaction(FACTION_FRIENDLY); - - /*if( pInstance ) - pInstance->SetData(0, NOT_STARTED);*/ - } - - void Aggro(Unit *who) - { - /*if( pInstance ) - pInstance->SetData(0, IN_PROGRESS);*/ - } - - void JustDied(Unit *victim) - { - /*if( pInstance ) - pInstance->SetData(0, DONE);*/ - } - - void UpdateAI(const uint32 diff) - { - if( !m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - if( ShieldBash_Timer < diff ) - { - DoCast(m_creature->getVictim(),SPELL_SHIELD_BASH); - ShieldBash_Timer = 15000; - }else ShieldBash_Timer -= diff; - - if( Revenge_Timer < diff ) - { - DoCast(m_creature->getVictim(),SPELL_REVENGE); - Revenge_Timer = 10000; - }else Revenge_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; -CreatureAI* GetAI_npc_sergeant_bly(Creature *_Creature) -{ - return new npc_sergeant_blyAI (_Creature); -} - -bool GossipHello_npc_sergeant_bly(Player *player, Creature *_Creature ) -{ - /*if( pInstance->GetData(0) == DONE ) - {*/ - player->ADD_GOSSIP_ITEM(1, GOSSIP_BLY, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); - player->SEND_GOSSIP_MENU(1517, _Creature->GetGUID()); - /*} - else if( pInstance->GetData(0) == IN_PROGRESS ) - player->SEND_GOSSIP_MENU(1516, _Creature->GetGUID()); - else - player->SEND_GOSSIP_MENU(1515, _Creature->GetGUID());*/ - - return true; -} - -bool GossipSelect_npc_sergeant_bly(Player *player, Creature *_Creature, uint32 sender, uint32 action ) -{ - if( action == GOSSIP_ACTION_INFO_DEF+1 ) - { - player->CLOSE_GOSSIP_MENU(); - _Creature->setFaction(FACTION_HOSTILE); - ((npc_sergeant_blyAI*)_Creature->AI())->AttackStart(player); - } - return true; -} - -/*###### -## npc_weegli_blastfuse -######*/ - -#define SPELL_BOMB 8858 -#define SPELL_GOBLIN_LAND_MINE 21688 -#define SPELL_SHOOT 6660 -#define SPELL_WEEGLIS_BARREL 10772 - -#define GOSSIP_WEEGLI "[PH] Please blow up the door." - -struct MANGOS_DLL_DECL npc_weegli_blastfuseAI : public ScriptedAI -{ - npc_weegli_blastfuseAI(Creature *c) : ScriptedAI(c) - { - //pInstance = ((ScriptedInstance*)c->GetInstanceData()); - Reset(); - } - - //ScriptedInstance* pInstance; - - void Reset() - { - /*if( pInstance ) - pInstance->SetData(0, NOT_STARTED);*/ - } - - void Aggro(Unit *who) - { - /*if( pInstance ) - pInstance->SetData(0, IN_PROGRESS);*/ - } - - void JustDied(Unit *victim) - { - /*if( pInstance ) - pInstance->SetData(0, DONE);*/ - } - - void UpdateAI(const uint32 diff) - { - if( !m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - DoMeleeAttackIfReady(); - } -}; -CreatureAI* GetAI_npc_weegli_blastfuse(Creature *_Creature) -{ - return new npc_weegli_blastfuseAI (_Creature); -} - -bool GossipHello_npc_weegli_blastfuse(Player *player, Creature *_Creature ) -{ - //event not implemented yet, this is only placeholder for future developement - /*if( pInstance->GetData(0) == DONE ) - { - player->ADD_GOSSIP_ITEM(1, GOSSIP_WEEGLI, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); - player->SEND_GOSSIP_MENU(1514, _Creature->GetGUID());//if event can proceed to end - } - else if( pInstance->GetData(0) == IN_PROGRESS ) - player->SEND_GOSSIP_MENU(1513, _Creature->GetGUID());//if event are in progress - else*/ - player->SEND_GOSSIP_MENU(1511, _Creature->GetGUID()); //if event not started - return true; -} - -bool GossipSelect_npc_weegli_blastfuse(Player *player, Creature *_Creature, uint32 sender, uint32 action ) -{ - if( action == GOSSIP_ACTION_INFO_DEF+1 ) - { - player->CLOSE_GOSSIP_MENU(); - //here we make him run to door, set the charge and run away off to nowhere - } - return true; -} - -void AddSC_zulfarrak() -{ - Script *newscript; - - newscript = new Script; - newscript->Name="npc_sergeant_bly"; - newscript->GetAI = GetAI_npc_sergeant_bly; - newscript->pGossipHello = &GossipHello_npc_sergeant_bly; - newscript->pGossipSelect = &GossipSelect_npc_sergeant_bly; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="npc_weegli_blastfuse"; - newscript->GetAI = GetAI_npc_weegli_blastfuse; - newscript->pGossipHello = &GossipHello_npc_weegli_blastfuse; - newscript->pGossipSelect = &GossipSelect_npc_weegli_blastfuse; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Zulfarrak +SD%Complete: 50 +SDComment: Consider it temporary, no instance script made for this instance yet. +SDCategory: Zul'Farrak +EndScriptData */ + +/* ContentData +npc_sergeant_bly +npc_weegli_blastfuse +EndContentData */ + +#include "precompiled.h" + +/*###### +## npc_sergeant_bly +######*/ + +#define FACTION_HOSTILE 14 +#define FACTION_FRIENDLY 35 + +#define SPELL_SHIELD_BASH 11972 +#define SPELL_REVENGE 12170 + +#define GOSSIP_BLY "[PH] In that case, i will take my reward!" + +struct MANGOS_DLL_DECL npc_sergeant_blyAI : public ScriptedAI +{ + npc_sergeant_blyAI(Creature *c) : ScriptedAI(c) + { + //pInstance = ((ScriptedInstance*)c->GetInstanceData()); + Reset(); + } + + //ScriptedInstance* pInstance; + + uint32 ShieldBash_Timer; + uint32 Revenge_Timer; //this is wrong, spell should never be used unless m_creature->getVictim() dodge, parry or block attack. Mangos support required. + + void Reset() + { + ShieldBash_Timer = 5000; + Revenge_Timer = 8000; + + m_creature->setFaction(FACTION_FRIENDLY); + + /*if( pInstance ) + pInstance->SetData(0, NOT_STARTED);*/ + } + + void Aggro(Unit *who) + { + /*if( pInstance ) + pInstance->SetData(0, IN_PROGRESS);*/ + } + + void JustDied(Unit *victim) + { + /*if( pInstance ) + pInstance->SetData(0, DONE);*/ + } + + void UpdateAI(const uint32 diff) + { + if( !m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + if( ShieldBash_Timer < diff ) + { + DoCast(m_creature->getVictim(),SPELL_SHIELD_BASH); + ShieldBash_Timer = 15000; + }else ShieldBash_Timer -= diff; + + if( Revenge_Timer < diff ) + { + DoCast(m_creature->getVictim(),SPELL_REVENGE); + Revenge_Timer = 10000; + }else Revenge_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; +CreatureAI* GetAI_npc_sergeant_bly(Creature *_Creature) +{ + return new npc_sergeant_blyAI (_Creature); +} + +bool GossipHello_npc_sergeant_bly(Player *player, Creature *_Creature ) +{ + /*if( pInstance->GetData(0) == DONE ) + {*/ + player->ADD_GOSSIP_ITEM(1, GOSSIP_BLY, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); + player->SEND_GOSSIP_MENU(1517, _Creature->GetGUID()); + /*} + else if( pInstance->GetData(0) == IN_PROGRESS ) + player->SEND_GOSSIP_MENU(1516, _Creature->GetGUID()); + else + player->SEND_GOSSIP_MENU(1515, _Creature->GetGUID());*/ + + return true; +} + +bool GossipSelect_npc_sergeant_bly(Player *player, Creature *_Creature, uint32 sender, uint32 action ) +{ + if( action == GOSSIP_ACTION_INFO_DEF+1 ) + { + player->CLOSE_GOSSIP_MENU(); + _Creature->setFaction(FACTION_HOSTILE); + ((npc_sergeant_blyAI*)_Creature->AI())->AttackStart(player); + } + return true; +} + +/*###### +## npc_weegli_blastfuse +######*/ + +#define SPELL_BOMB 8858 +#define SPELL_GOBLIN_LAND_MINE 21688 +#define SPELL_SHOOT 6660 +#define SPELL_WEEGLIS_BARREL 10772 + +#define GOSSIP_WEEGLI "[PH] Please blow up the door." + +struct MANGOS_DLL_DECL npc_weegli_blastfuseAI : public ScriptedAI +{ + npc_weegli_blastfuseAI(Creature *c) : ScriptedAI(c) + { + //pInstance = ((ScriptedInstance*)c->GetInstanceData()); + Reset(); + } + + //ScriptedInstance* pInstance; + + void Reset() + { + /*if( pInstance ) + pInstance->SetData(0, NOT_STARTED);*/ + } + + void Aggro(Unit *who) + { + /*if( pInstance ) + pInstance->SetData(0, IN_PROGRESS);*/ + } + + void JustDied(Unit *victim) + { + /*if( pInstance ) + pInstance->SetData(0, DONE);*/ + } + + void UpdateAI(const uint32 diff) + { + if( !m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + DoMeleeAttackIfReady(); + } +}; +CreatureAI* GetAI_npc_weegli_blastfuse(Creature *_Creature) +{ + return new npc_weegli_blastfuseAI (_Creature); +} + +bool GossipHello_npc_weegli_blastfuse(Player *player, Creature *_Creature ) +{ + //event not implemented yet, this is only placeholder for future developement + /*if( pInstance->GetData(0) == DONE ) + { + player->ADD_GOSSIP_ITEM(1, GOSSIP_WEEGLI, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); + player->SEND_GOSSIP_MENU(1514, _Creature->GetGUID());//if event can proceed to end + } + else if( pInstance->GetData(0) == IN_PROGRESS ) + player->SEND_GOSSIP_MENU(1513, _Creature->GetGUID());//if event are in progress + else*/ + player->SEND_GOSSIP_MENU(1511, _Creature->GetGUID()); //if event not started + return true; +} + +bool GossipSelect_npc_weegli_blastfuse(Player *player, Creature *_Creature, uint32 sender, uint32 action ) +{ + if( action == GOSSIP_ACTION_INFO_DEF+1 ) + { + player->CLOSE_GOSSIP_MENU(); + //here we make him run to door, set the charge and run away off to nowhere + } + return true; +} + +void AddSC_zulfarrak() +{ + Script *newscript; + + newscript = new Script; + newscript->Name="npc_sergeant_bly"; + newscript->GetAI = GetAI_npc_sergeant_bly; + newscript->pGossipHello = &GossipHello_npc_sergeant_bly; + newscript->pGossipSelect = &GossipSelect_npc_sergeant_bly; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="npc_weegli_blastfuse"; + newscript->GetAI = GetAI_npc_weegli_blastfuse; + newscript->pGossipHello = &GossipHello_npc_weegli_blastfuse; + newscript->pGossipSelect = &GossipSelect_npc_weegli_blastfuse; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/zulgurub/boss_arlokk.cpp b/src/bindings/scripts/scripts/zone/zulgurub/boss_arlokk.cpp index 7be65ad73f0..91e89f7490a 100644 --- a/src/bindings/scripts/scripts/zone/zulgurub/boss_arlokk.cpp +++ b/src/bindings/scripts/scripts/zone/zulgurub/boss_arlokk.cpp @@ -1,211 +1,211 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Arlokk -SD%Complete: 95 -SDComment: Wrong cleave and red aura is missing. -SDCategory: Zul'Gurub -EndScriptData */ - -#include "precompiled.h" -#include "def_zulgurub.h" - -#define SPELL_SHADOWWORDPAIN 23952 -#define SPELL_GOUGE 24698 -#define SPELL_MARK 24210 -#define SPELL_CLEAVE 26350 //Perhaps not right. Not a red aura... -#define SPELL_PANTHER_TRANSFORM 24190 - -#define SAY_TRANSFORM "Bethekk, your priestess calls upon your might!" -#define SAY_DEATH "At last I am free of the soul flayer..." - -#define SOUND_TRANSFORM 8416 -#define SOUND_DEATH 8412 - -struct MANGOS_DLL_DECL boss_arlokkAI : public ScriptedAI -{ - boss_arlokkAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 ShadowWordPain_Timer; - uint32 Gouge_Timer; - uint32 Mark_Timer; - uint32 Cleave_Timer; - uint32 Vanish_Timer; - uint32 Summon_Timer; - uint32 Visible_Timer; - - Unit* markedTarget; - Creature *Panther; - uint32 Counter; - - bool PhaseTwo; - bool VanishedOnce; - - void Reset() - { - ShadowWordPain_Timer = 8000; - Gouge_Timer = 14000; - Mark_Timer = 35000; - Cleave_Timer = 4000; - Vanish_Timer = 60000; - Summon_Timer = 5000; - Visible_Timer = 6000; - - Counter = 0; - - markedTarget = NULL; - PhaseTwo = false; - VanishedOnce = false; - - m_creature->SetUInt32Value(UNIT_FIELD_DISPLAYID,15218); - m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - } - - void Aggro(Unit *who) - { - } - - void JustDied(Unit* Killer) - { - DoYell(SAY_DEATH,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_DEATH); - m_creature->SetUInt32Value(UNIT_FIELD_DISPLAYID,15218); - m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - ScriptedInstance *pInstance = (m_creature->GetInstanceData()) ? ((ScriptedInstance*)m_creature->GetInstanceData()) : NULL; - - if(pInstance) - pInstance->SetData(DATA_ARLOKK_DEATH, 0); - } - - void UpdateAI(const uint32 diff) - { - if (!m_creature->SelectHostilTarget()) - return; - - if( m_creature->getVictim() && m_creature->isAlive()) - { - if (!PhaseTwo && ShadowWordPain_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_SHADOWWORDPAIN); - ShadowWordPain_Timer = 15000; - }else ShadowWordPain_Timer -= diff; - - if (!PhaseTwo && Mark_Timer < diff) - { - markedTarget = SelectUnit(SELECT_TARGET_RANDOM,0); - - DoCast(markedTarget,SPELL_MARK); - Mark_Timer = 15000; - }else Mark_Timer -= diff; - - if (Summon_Timer < diff && Counter < 31) - { - Unit* target = NULL; - target = SelectUnit(SELECT_TARGET_RANDOM,0); - - Panther = m_creature->SummonCreature(15101,-11532.79980,-1649.6734,41.4800,0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000); - - if(markedTarget && Panther ) - { Panther ->AI()->AttackStart(markedTarget); } - else - { Panther ->AI()->AttackStart(target); } - - Panther = m_creature->SummonCreature(15101,-11532.9970,-1606.4840,41.2979,0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000); - - if(markedTarget && Panther ) - { Panther ->AI()->AttackStart(markedTarget); } - else - { Panther ->AI()->AttackStart(target); } - - Counter++; - Summon_Timer = 5000; - }else Summon_Timer -= diff; - - if (Vanish_Timer < diff) - { - //Invisble Model - m_creature->SetUInt32Value(UNIT_FIELD_DISPLAYID,11686); - m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - //m_creature->CombatStop(); - DoResetThreat(); - VanishedOnce = true; - Vanish_Timer = 45000; - Visible_Timer = 6000; - }else Vanish_Timer -= diff; - - if (VanishedOnce) - { - if(Visible_Timer < diff) - { - Unit* target = NULL; - target = SelectUnit(SELECT_TARGET_RANDOM,0); - //The Panther Model - m_creature->SetUInt32Value(UNIT_FIELD_DISPLAYID,15215); - m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - - if (!PhaseTwo) - { - DoYell(SAY_TRANSFORM,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_TRANSFORM); - } - - const CreatureInfo *cinfo = m_creature->GetCreatureInfo(); - m_creature->SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, (cinfo->mindmg +((cinfo->mindmg/100) * 35))); - m_creature->SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, (cinfo->maxdmg +((cinfo->maxdmg/100) * 35))); - m_creature->UpdateDamagePhysical(BASE_ATTACK); - DoStartAttackAndMovement(target); - //The Panther Model - m_creature->SetUInt32Value(UNIT_FIELD_DISPLAYID,15215); - m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - PhaseTwo = true; - }else Visible_Timer -= diff; - } - - //Cleave_Timer - if(PhaseTwo && Cleave_Timer < diff) - { - DoCast(m_creature->getVictim(), SPELL_CLEAVE); - Cleave_Timer = 16000; - }Cleave_Timer -=diff; - - //Gouge_Timer - if(PhaseTwo && Gouge_Timer < diff) - { - DoCast(m_creature->getVictim(), SPELL_GOUGE); - if(m_creature->getThreatManager().getThreat(m_creature->getVictim())) - m_creature->getThreatManager().modifyThreatPercent(m_creature->getVictim(),-80); - - Gouge_Timer = 17000+rand()%10000; - }else Gouge_Timer -= diff; - - DoMeleeAttackIfReady(); - } - } -}; -CreatureAI* GetAI_boss_arlokk(Creature *_Creature) -{ - return new boss_arlokkAI (_Creature); -} - -void AddSC_boss_arlokk() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_arlokk"; - newscript->GetAI = GetAI_boss_arlokk; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Arlokk +SD%Complete: 95 +SDComment: Wrong cleave and red aura is missing. +SDCategory: Zul'Gurub +EndScriptData */ + +#include "precompiled.h" +#include "def_zulgurub.h" + +#define SPELL_SHADOWWORDPAIN 23952 +#define SPELL_GOUGE 24698 +#define SPELL_MARK 24210 +#define SPELL_CLEAVE 26350 //Perhaps not right. Not a red aura... +#define SPELL_PANTHER_TRANSFORM 24190 + +#define SAY_TRANSFORM "Bethekk, your priestess calls upon your might!" +#define SAY_DEATH "At last I am free of the soul flayer..." + +#define SOUND_TRANSFORM 8416 +#define SOUND_DEATH 8412 + +struct MANGOS_DLL_DECL boss_arlokkAI : public ScriptedAI +{ + boss_arlokkAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 ShadowWordPain_Timer; + uint32 Gouge_Timer; + uint32 Mark_Timer; + uint32 Cleave_Timer; + uint32 Vanish_Timer; + uint32 Summon_Timer; + uint32 Visible_Timer; + + Unit* markedTarget; + Creature *Panther; + uint32 Counter; + + bool PhaseTwo; + bool VanishedOnce; + + void Reset() + { + ShadowWordPain_Timer = 8000; + Gouge_Timer = 14000; + Mark_Timer = 35000; + Cleave_Timer = 4000; + Vanish_Timer = 60000; + Summon_Timer = 5000; + Visible_Timer = 6000; + + Counter = 0; + + markedTarget = NULL; + PhaseTwo = false; + VanishedOnce = false; + + m_creature->SetUInt32Value(UNIT_FIELD_DISPLAYID,15218); + m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + } + + void Aggro(Unit *who) + { + } + + void JustDied(Unit* Killer) + { + DoYell(SAY_DEATH,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_DEATH); + m_creature->SetUInt32Value(UNIT_FIELD_DISPLAYID,15218); + m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + ScriptedInstance *pInstance = (m_creature->GetInstanceData()) ? ((ScriptedInstance*)m_creature->GetInstanceData()) : NULL; + + if(pInstance) + pInstance->SetData(DATA_ARLOKK_DEATH, 0); + } + + void UpdateAI(const uint32 diff) + { + if (!m_creature->SelectHostilTarget()) + return; + + if( m_creature->getVictim() && m_creature->isAlive()) + { + if (!PhaseTwo && ShadowWordPain_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_SHADOWWORDPAIN); + ShadowWordPain_Timer = 15000; + }else ShadowWordPain_Timer -= diff; + + if (!PhaseTwo && Mark_Timer < diff) + { + markedTarget = SelectUnit(SELECT_TARGET_RANDOM,0); + + DoCast(markedTarget,SPELL_MARK); + Mark_Timer = 15000; + }else Mark_Timer -= diff; + + if (Summon_Timer < diff && Counter < 31) + { + Unit* target = NULL; + target = SelectUnit(SELECT_TARGET_RANDOM,0); + + Panther = m_creature->SummonCreature(15101,-11532.79980,-1649.6734,41.4800,0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000); + + if(markedTarget && Panther ) + { Panther ->AI()->AttackStart(markedTarget); } + else + { Panther ->AI()->AttackStart(target); } + + Panther = m_creature->SummonCreature(15101,-11532.9970,-1606.4840,41.2979,0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000); + + if(markedTarget && Panther ) + { Panther ->AI()->AttackStart(markedTarget); } + else + { Panther ->AI()->AttackStart(target); } + + Counter++; + Summon_Timer = 5000; + }else Summon_Timer -= diff; + + if (Vanish_Timer < diff) + { + //Invisble Model + m_creature->SetUInt32Value(UNIT_FIELD_DISPLAYID,11686); + m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + //m_creature->CombatStop(); + DoResetThreat(); + VanishedOnce = true; + Vanish_Timer = 45000; + Visible_Timer = 6000; + }else Vanish_Timer -= diff; + + if (VanishedOnce) + { + if(Visible_Timer < diff) + { + Unit* target = NULL; + target = SelectUnit(SELECT_TARGET_RANDOM,0); + //The Panther Model + m_creature->SetUInt32Value(UNIT_FIELD_DISPLAYID,15215); + m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + + if (!PhaseTwo) + { + DoYell(SAY_TRANSFORM,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_TRANSFORM); + } + + const CreatureInfo *cinfo = m_creature->GetCreatureInfo(); + m_creature->SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, (cinfo->mindmg +((cinfo->mindmg/100) * 35))); + m_creature->SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, (cinfo->maxdmg +((cinfo->maxdmg/100) * 35))); + m_creature->UpdateDamagePhysical(BASE_ATTACK); + DoStartAttackAndMovement(target); + //The Panther Model + m_creature->SetUInt32Value(UNIT_FIELD_DISPLAYID,15215); + m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + PhaseTwo = true; + }else Visible_Timer -= diff; + } + + //Cleave_Timer + if(PhaseTwo && Cleave_Timer < diff) + { + DoCast(m_creature->getVictim(), SPELL_CLEAVE); + Cleave_Timer = 16000; + }Cleave_Timer -=diff; + + //Gouge_Timer + if(PhaseTwo && Gouge_Timer < diff) + { + DoCast(m_creature->getVictim(), SPELL_GOUGE); + if(m_creature->getThreatManager().getThreat(m_creature->getVictim())) + m_creature->getThreatManager().modifyThreatPercent(m_creature->getVictim(),-80); + + Gouge_Timer = 17000+rand()%10000; + }else Gouge_Timer -= diff; + + DoMeleeAttackIfReady(); + } + } +}; +CreatureAI* GetAI_boss_arlokk(Creature *_Creature) +{ + return new boss_arlokkAI (_Creature); +} + +void AddSC_boss_arlokk() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_arlokk"; + newscript->GetAI = GetAI_boss_arlokk; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/zulgurub/boss_gahzranka.cpp b/src/bindings/scripts/scripts/zone/zulgurub/boss_gahzranka.cpp index 6fd39159cb5..6b879e58ed6 100644 --- a/src/bindings/scripts/scripts/zone/zulgurub/boss_gahzranka.cpp +++ b/src/bindings/scripts/scripts/zone/zulgurub/boss_gahzranka.cpp @@ -1,92 +1,92 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Gahz'ranka -SD%Complete: 85 -SDComment: Massive Geyser with knockback not working. Spell buggy. -SDCategory: Zul'Gurub -EndScriptData */ - -#include "precompiled.h" - -#define SPELL_FROSTBREATH 21099 -#define SPELL_MASSIVEGEYSER 22421 //Not working. Cause its a summon... -#define SPELL_SLAM 24326 - -struct MANGOS_DLL_DECL boss_gahzrankaAI : public ScriptedAI -{ - boss_gahzrankaAI(Creature *c) : ScriptedAI(c) {Reset();} - uint32 Frostbreath_Timer; - uint32 MassiveGeyser_Timer; - uint32 Slam_Timer; - - void Reset() - { - Frostbreath_Timer = 8000; - MassiveGeyser_Timer = 25000; - Slam_Timer = 17000; - } - - void Aggro(Unit *who) - { - } - - void UpdateAI(const uint32 diff) - { - //Return since we have no target - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - //Frostbreath_Timer - if (Frostbreath_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_FROSTBREATH); - Frostbreath_Timer = 7000 + rand()%4000; - }else Frostbreath_Timer -= diff; - - //MassiveGeyser_Timer - if (MassiveGeyser_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_MASSIVEGEYSER); - DoResetThreat(); - - MassiveGeyser_Timer = 22000 + rand()%10000; - }else MassiveGeyser_Timer -= diff; - - //Slam_Timer - if (Slam_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_SLAM); - Slam_Timer = 12000 + rand()%8000; - }else Slam_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; -CreatureAI* GetAI_boss_gahzranka(Creature *_Creature) -{ - return new boss_gahzrankaAI (_Creature); -} - -void AddSC_boss_gahzranka() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_gahzranka"; - newscript->GetAI = GetAI_boss_gahzranka; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Gahz'ranka +SD%Complete: 85 +SDComment: Massive Geyser with knockback not working. Spell buggy. +SDCategory: Zul'Gurub +EndScriptData */ + +#include "precompiled.h" + +#define SPELL_FROSTBREATH 21099 +#define SPELL_MASSIVEGEYSER 22421 //Not working. Cause its a summon... +#define SPELL_SLAM 24326 + +struct MANGOS_DLL_DECL boss_gahzrankaAI : public ScriptedAI +{ + boss_gahzrankaAI(Creature *c) : ScriptedAI(c) {Reset();} + uint32 Frostbreath_Timer; + uint32 MassiveGeyser_Timer; + uint32 Slam_Timer; + + void Reset() + { + Frostbreath_Timer = 8000; + MassiveGeyser_Timer = 25000; + Slam_Timer = 17000; + } + + void Aggro(Unit *who) + { + } + + void UpdateAI(const uint32 diff) + { + //Return since we have no target + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + //Frostbreath_Timer + if (Frostbreath_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_FROSTBREATH); + Frostbreath_Timer = 7000 + rand()%4000; + }else Frostbreath_Timer -= diff; + + //MassiveGeyser_Timer + if (MassiveGeyser_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_MASSIVEGEYSER); + DoResetThreat(); + + MassiveGeyser_Timer = 22000 + rand()%10000; + }else MassiveGeyser_Timer -= diff; + + //Slam_Timer + if (Slam_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_SLAM); + Slam_Timer = 12000 + rand()%8000; + }else Slam_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; +CreatureAI* GetAI_boss_gahzranka(Creature *_Creature) +{ + return new boss_gahzrankaAI (_Creature); +} + +void AddSC_boss_gahzranka() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_gahzranka"; + newscript->GetAI = GetAI_boss_gahzranka; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/zulgurub/boss_grilek.cpp b/src/bindings/scripts/scripts/zone/zulgurub/boss_grilek.cpp index b25843dbb24..cb0567d0fcc 100644 --- a/src/bindings/scripts/scripts/zone/zulgurub/boss_grilek.cpp +++ b/src/bindings/scripts/scripts/zone/zulgurub/boss_grilek.cpp @@ -1,92 +1,92 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Grilek -SD%Complete: 100 -SDComment: -SDCategory: Zul'Gurub -EndScriptData */ - -#include "precompiled.h" -#include "def_zulgurub.h" - -#define SPELL_AVARTAR 24646 //The Enrage Spell -#define SPELL_GROUNDTREMOR 6524 - -struct MANGOS_DLL_DECL boss_grilekAI : public ScriptedAI -{ - boss_grilekAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 Avartar_Timer; - uint32 GroundTremor_Timer; - - void Reset() - { - Avartar_Timer = 15000 + rand()%10000; - GroundTremor_Timer = 8000 + rand()%8000; - } - - void Aggro(Unit *who) - { - } - - void UpdateAI(const uint32 diff) - { - //Return since we have no target - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - //Avartar_Timer - if (Avartar_Timer < diff) - { - - DoCast(m_creature, SPELL_AVARTAR); - Unit* target = NULL; - - target = SelectUnit(SELECT_TARGET_RANDOM,1); - - if(m_creature->getThreatManager().getThreat(m_creature->getVictim())) - m_creature->getThreatManager().modifyThreatPercent(m_creature->getVictim(),-50); - if (target) - DoStartAttackAndMovement(target); - - Avartar_Timer = 25000 + rand()%10000; - }else Avartar_Timer -= diff; - - //GroundTremor_Timer - if (GroundTremor_Timer < diff) - { - DoCast(m_creature->getVictim(), SPELL_GROUNDTREMOR); - GroundTremor_Timer = 12000 + rand()%4000; - }else GroundTremor_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; -CreatureAI* GetAI_boss_grilek(Creature *_Creature) -{ - return new boss_grilekAI (_Creature); -} - -void AddSC_boss_grilek() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_grilek"; - newscript->GetAI = GetAI_boss_grilek; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Grilek +SD%Complete: 100 +SDComment: +SDCategory: Zul'Gurub +EndScriptData */ + +#include "precompiled.h" +#include "def_zulgurub.h" + +#define SPELL_AVARTAR 24646 //The Enrage Spell +#define SPELL_GROUNDTREMOR 6524 + +struct MANGOS_DLL_DECL boss_grilekAI : public ScriptedAI +{ + boss_grilekAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 Avartar_Timer; + uint32 GroundTremor_Timer; + + void Reset() + { + Avartar_Timer = 15000 + rand()%10000; + GroundTremor_Timer = 8000 + rand()%8000; + } + + void Aggro(Unit *who) + { + } + + void UpdateAI(const uint32 diff) + { + //Return since we have no target + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + //Avartar_Timer + if (Avartar_Timer < diff) + { + + DoCast(m_creature, SPELL_AVARTAR); + Unit* target = NULL; + + target = SelectUnit(SELECT_TARGET_RANDOM,1); + + if(m_creature->getThreatManager().getThreat(m_creature->getVictim())) + m_creature->getThreatManager().modifyThreatPercent(m_creature->getVictim(),-50); + if (target) + DoStartAttackAndMovement(target); + + Avartar_Timer = 25000 + rand()%10000; + }else Avartar_Timer -= diff; + + //GroundTremor_Timer + if (GroundTremor_Timer < diff) + { + DoCast(m_creature->getVictim(), SPELL_GROUNDTREMOR); + GroundTremor_Timer = 12000 + rand()%4000; + }else GroundTremor_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; +CreatureAI* GetAI_boss_grilek(Creature *_Creature) +{ + return new boss_grilekAI (_Creature); +} + +void AddSC_boss_grilek() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_grilek"; + newscript->GetAI = GetAI_boss_grilek; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/zulgurub/boss_hakkar.cpp b/src/bindings/scripts/scripts/zone/zulgurub/boss_hakkar.cpp index 719f2d77b87..16056784a18 100644 --- a/src/bindings/scripts/scripts/zone/zulgurub/boss_hakkar.cpp +++ b/src/bindings/scripts/scripts/zone/zulgurub/boss_hakkar.cpp @@ -1,256 +1,256 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Hakkar -SD%Complete: 95 -SDComment: Blood siphon spell buggy cause of Core Issue. -SDCategory: Zul'Gurub -EndScriptData */ - -#include "precompiled.h" -#include "def_zulgurub.h" - -#define SPELL_BLOODSIPHON 24322 -#define SPELL_CORRUPTEDBLOOD 24328 -#define SPELL_CAUSEINSANITY 24327 //Not working disabled. -#define SPELL_WILLOFHAKKAR 24178 -#define SPELL_ENRAGE 24318 - -// The Aspects of all High Priests -#define SPELL_ASPECT_OF_JEKLIK 24687 -#define SPELL_ASPECT_OF_VENOXIS 24688 -#define SPELL_ASPECT_OF_MARLI 24686 -#define SPELL_ASPECT_OF_THEKAL 24689 -#define SPELL_ASPECT_OF_ARLOKK 24690 - -#define SAY_AGGRO "PRIDE HERALDS THE END OF YOUR WORLD. COME, MORTALS! FACE THE WRATH OF THE SOULFLAYER!" -#define SOUND_AGGRO 8414 - -#define SAY_SLAY "Fleeing will do you no good, mortals!" - -struct MANGOS_DLL_DECL boss_hakkarAI : public ScriptedAI -{ - boss_hakkarAI(Creature *c) : ScriptedAI(c) - { - pInstance = ((ScriptedInstance*)c->GetInstanceData()); - Reset(); - } - - uint32 BloodSiphon_Timer; - uint32 CorruptedBlood_Timer; - uint32 CauseInsanity_Timer; - uint32 WillOfHakkar_Timer; - uint32 Enrage_Timer; - - uint32 CheckJeklik_Timer; - uint32 CheckVenoxis_Timer; - uint32 CheckMarli_Timer; - uint32 CheckThekal_Timer; - uint32 CheckArlokk_Timer; - - uint32 AspectOfJeklik_Timer; - uint32 AspectOfVenoxis_Timer; - uint32 AspectOfMarli_Timer; - uint32 AspectOfThekal_Timer; - uint32 AspectOfArlokk_Timer; - - ScriptedInstance *pInstance; - - bool Enraged; - - void Reset() - { - BloodSiphon_Timer = 90000; - CorruptedBlood_Timer = 25000; - CauseInsanity_Timer = 17000; - WillOfHakkar_Timer = 17000; - Enrage_Timer = 600000; - - CheckJeklik_Timer = 1000; - CheckVenoxis_Timer = 2000; - CheckMarli_Timer = 3000; - CheckThekal_Timer = 4000; - CheckArlokk_Timer = 5000; - - AspectOfJeklik_Timer = 4000; - AspectOfVenoxis_Timer = 7000; - AspectOfMarli_Timer = 12000; - AspectOfThekal_Timer = 8000; - AspectOfArlokk_Timer = 18000; - - Enraged = false; - } - - void Aggro(Unit *who) - { - DoYell(SAY_AGGRO,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_AGGRO); - } - - void UpdateAI(const uint32 diff) - { - //Return since we have no target - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - //BloodSiphon_Timer - if (BloodSiphon_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_BLOODSIPHON); - BloodSiphon_Timer = 90000; - }else BloodSiphon_Timer -= diff; - - //CorruptedBlood_Timer - if (CorruptedBlood_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_CORRUPTEDBLOOD); - CorruptedBlood_Timer = 30000 + rand()%15000; - }else CorruptedBlood_Timer -= diff; - - //CauseInsanity_Timer - // if (CauseInsanity_Timer < diff) - // { - // - // Unit* target = NULL; - // target = SelectUnit(SELECT_TARGET_RANDOM,0); - - // DoCast(target,SPELL_CAUSEINSANITY); - - // CauseInsanity_Timer = 35000 + rand()%8000; - // }else CauseInsanity_Timer -= diff; - - //WillOfHakkar_Timer - if (WillOfHakkar_Timer < diff) - { - - Unit* target = NULL; - target = SelectUnit(SELECT_TARGET_RANDOM,0); - - DoCast(target,SPELL_WILLOFHAKKAR); - WillOfHakkar_Timer = 25000 + rand()%10000; - }else WillOfHakkar_Timer -= diff; - - if (!Enraged && Enrage_Timer < diff) - { - DoCast(m_creature, SPELL_ENRAGE); - Enraged = true; - }else Enrage_Timer -= diff; - - //Checking if Jeklik is dead. If not we cast her Aspect - if(CheckJeklik_Timer < diff) - { - if(pInstance) - { - if(!pInstance->GetData(DATA_JEKLIKISDEAD)) - { - if (AspectOfJeklik_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_ASPECT_OF_JEKLIK); - AspectOfJeklik_Timer = 10000 + rand()%4000; - }else AspectOfJeklik_Timer -= diff; - } - } - CheckJeklik_Timer = 1000; - }else CheckJeklik_Timer -= diff; - - //Checking if Venoxis is dead. If not we cast his Aspect - if(CheckVenoxis_Timer < diff) - { - if(pInstance) - { - if(!pInstance->GetData(DATA_VENOXISISDEAD)) - { - if (AspectOfVenoxis_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_ASPECT_OF_VENOXIS); - AspectOfVenoxis_Timer = 8000; - }else AspectOfVenoxis_Timer -= diff; - } - } - CheckVenoxis_Timer = 1000; - }else CheckVenoxis_Timer -= diff; - - //Checking if Marli is dead. If not we cast her Aspect - if(CheckMarli_Timer < diff) - { - if(pInstance) - { - if(!pInstance->GetData(DATA_MARLIISDEAD)) - { - if (AspectOfMarli_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_ASPECT_OF_MARLI); - AspectOfMarli_Timer = 10000; - }else AspectOfMarli_Timer -= diff; - - } - } - CheckMarli_Timer = 1000; - }else CheckMarli_Timer -= diff; - - //Checking if Thekal is dead. If not we cast his Aspect - if(CheckThekal_Timer < diff) - { - if(pInstance) - { - if(!pInstance->GetData(DATA_THEKALISDEAD)) - { - if (AspectOfThekal_Timer < diff) - { - DoCast(m_creature,SPELL_ASPECT_OF_THEKAL); - AspectOfThekal_Timer = 15000; - }else AspectOfThekal_Timer -= diff; - } - } - CheckThekal_Timer = 1000; - }else CheckThekal_Timer -= diff; - - //Checking if Arlokk is dead. If yes we cast her Aspect - if(CheckArlokk_Timer < diff) - { - if(pInstance) - { - if(!pInstance->GetData(DATA_ARLOKKISDEAD)) - { - if (AspectOfArlokk_Timer < diff) - { - DoCast(m_creature,SPELL_ASPECT_OF_ARLOKK); - DoResetThreat(); - - AspectOfArlokk_Timer = 10000 + rand()%5000; - }else AspectOfArlokk_Timer -= diff; - } - } - CheckArlokk_Timer = 1000; - }else CheckArlokk_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; -CreatureAI* GetAI_boss_hakkar(Creature *_Creature) -{ - return new boss_hakkarAI (_Creature); -} - -void AddSC_boss_hakkar() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_hakkar"; - newscript->GetAI = GetAI_boss_hakkar; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Hakkar +SD%Complete: 95 +SDComment: Blood siphon spell buggy cause of Core Issue. +SDCategory: Zul'Gurub +EndScriptData */ + +#include "precompiled.h" +#include "def_zulgurub.h" + +#define SPELL_BLOODSIPHON 24322 +#define SPELL_CORRUPTEDBLOOD 24328 +#define SPELL_CAUSEINSANITY 24327 //Not working disabled. +#define SPELL_WILLOFHAKKAR 24178 +#define SPELL_ENRAGE 24318 + +// The Aspects of all High Priests +#define SPELL_ASPECT_OF_JEKLIK 24687 +#define SPELL_ASPECT_OF_VENOXIS 24688 +#define SPELL_ASPECT_OF_MARLI 24686 +#define SPELL_ASPECT_OF_THEKAL 24689 +#define SPELL_ASPECT_OF_ARLOKK 24690 + +#define SAY_AGGRO "PRIDE HERALDS THE END OF YOUR WORLD. COME, MORTALS! FACE THE WRATH OF THE SOULFLAYER!" +#define SOUND_AGGRO 8414 + +#define SAY_SLAY "Fleeing will do you no good, mortals!" + +struct MANGOS_DLL_DECL boss_hakkarAI : public ScriptedAI +{ + boss_hakkarAI(Creature *c) : ScriptedAI(c) + { + pInstance = ((ScriptedInstance*)c->GetInstanceData()); + Reset(); + } + + uint32 BloodSiphon_Timer; + uint32 CorruptedBlood_Timer; + uint32 CauseInsanity_Timer; + uint32 WillOfHakkar_Timer; + uint32 Enrage_Timer; + + uint32 CheckJeklik_Timer; + uint32 CheckVenoxis_Timer; + uint32 CheckMarli_Timer; + uint32 CheckThekal_Timer; + uint32 CheckArlokk_Timer; + + uint32 AspectOfJeklik_Timer; + uint32 AspectOfVenoxis_Timer; + uint32 AspectOfMarli_Timer; + uint32 AspectOfThekal_Timer; + uint32 AspectOfArlokk_Timer; + + ScriptedInstance *pInstance; + + bool Enraged; + + void Reset() + { + BloodSiphon_Timer = 90000; + CorruptedBlood_Timer = 25000; + CauseInsanity_Timer = 17000; + WillOfHakkar_Timer = 17000; + Enrage_Timer = 600000; + + CheckJeklik_Timer = 1000; + CheckVenoxis_Timer = 2000; + CheckMarli_Timer = 3000; + CheckThekal_Timer = 4000; + CheckArlokk_Timer = 5000; + + AspectOfJeklik_Timer = 4000; + AspectOfVenoxis_Timer = 7000; + AspectOfMarli_Timer = 12000; + AspectOfThekal_Timer = 8000; + AspectOfArlokk_Timer = 18000; + + Enraged = false; + } + + void Aggro(Unit *who) + { + DoYell(SAY_AGGRO,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_AGGRO); + } + + void UpdateAI(const uint32 diff) + { + //Return since we have no target + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + //BloodSiphon_Timer + if (BloodSiphon_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_BLOODSIPHON); + BloodSiphon_Timer = 90000; + }else BloodSiphon_Timer -= diff; + + //CorruptedBlood_Timer + if (CorruptedBlood_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_CORRUPTEDBLOOD); + CorruptedBlood_Timer = 30000 + rand()%15000; + }else CorruptedBlood_Timer -= diff; + + //CauseInsanity_Timer + // if (CauseInsanity_Timer < diff) + // { + // + // Unit* target = NULL; + // target = SelectUnit(SELECT_TARGET_RANDOM,0); + + // DoCast(target,SPELL_CAUSEINSANITY); + + // CauseInsanity_Timer = 35000 + rand()%8000; + // }else CauseInsanity_Timer -= diff; + + //WillOfHakkar_Timer + if (WillOfHakkar_Timer < diff) + { + + Unit* target = NULL; + target = SelectUnit(SELECT_TARGET_RANDOM,0); + + DoCast(target,SPELL_WILLOFHAKKAR); + WillOfHakkar_Timer = 25000 + rand()%10000; + }else WillOfHakkar_Timer -= diff; + + if (!Enraged && Enrage_Timer < diff) + { + DoCast(m_creature, SPELL_ENRAGE); + Enraged = true; + }else Enrage_Timer -= diff; + + //Checking if Jeklik is dead. If not we cast her Aspect + if(CheckJeklik_Timer < diff) + { + if(pInstance) + { + if(!pInstance->GetData(DATA_JEKLIKISDEAD)) + { + if (AspectOfJeklik_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_ASPECT_OF_JEKLIK); + AspectOfJeklik_Timer = 10000 + rand()%4000; + }else AspectOfJeklik_Timer -= diff; + } + } + CheckJeklik_Timer = 1000; + }else CheckJeklik_Timer -= diff; + + //Checking if Venoxis is dead. If not we cast his Aspect + if(CheckVenoxis_Timer < diff) + { + if(pInstance) + { + if(!pInstance->GetData(DATA_VENOXISISDEAD)) + { + if (AspectOfVenoxis_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_ASPECT_OF_VENOXIS); + AspectOfVenoxis_Timer = 8000; + }else AspectOfVenoxis_Timer -= diff; + } + } + CheckVenoxis_Timer = 1000; + }else CheckVenoxis_Timer -= diff; + + //Checking if Marli is dead. If not we cast her Aspect + if(CheckMarli_Timer < diff) + { + if(pInstance) + { + if(!pInstance->GetData(DATA_MARLIISDEAD)) + { + if (AspectOfMarli_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_ASPECT_OF_MARLI); + AspectOfMarli_Timer = 10000; + }else AspectOfMarli_Timer -= diff; + + } + } + CheckMarli_Timer = 1000; + }else CheckMarli_Timer -= diff; + + //Checking if Thekal is dead. If not we cast his Aspect + if(CheckThekal_Timer < diff) + { + if(pInstance) + { + if(!pInstance->GetData(DATA_THEKALISDEAD)) + { + if (AspectOfThekal_Timer < diff) + { + DoCast(m_creature,SPELL_ASPECT_OF_THEKAL); + AspectOfThekal_Timer = 15000; + }else AspectOfThekal_Timer -= diff; + } + } + CheckThekal_Timer = 1000; + }else CheckThekal_Timer -= diff; + + //Checking if Arlokk is dead. If yes we cast her Aspect + if(CheckArlokk_Timer < diff) + { + if(pInstance) + { + if(!pInstance->GetData(DATA_ARLOKKISDEAD)) + { + if (AspectOfArlokk_Timer < diff) + { + DoCast(m_creature,SPELL_ASPECT_OF_ARLOKK); + DoResetThreat(); + + AspectOfArlokk_Timer = 10000 + rand()%5000; + }else AspectOfArlokk_Timer -= diff; + } + } + CheckArlokk_Timer = 1000; + }else CheckArlokk_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; +CreatureAI* GetAI_boss_hakkar(Creature *_Creature) +{ + return new boss_hakkarAI (_Creature); +} + +void AddSC_boss_hakkar() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_hakkar"; + newscript->GetAI = GetAI_boss_hakkar; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/zulgurub/boss_hazzarah.cpp b/src/bindings/scripts/scripts/zone/zulgurub/boss_hazzarah.cpp index adf5a44ec95..f4defb02a17 100644 --- a/src/bindings/scripts/scripts/zone/zulgurub/boss_hazzarah.cpp +++ b/src/bindings/scripts/scripts/zone/zulgurub/boss_hazzarah.cpp @@ -1,100 +1,100 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Hazzarah -SD%Complete: 100 -SDComment: -SDCategory: Zul'Gurub -EndScriptData */ - -#include "precompiled.h" -#include "def_zulgurub.h" - -#define SPELL_MANABURN 26046 -#define SPELL_SLEEP 24664 - -struct MANGOS_DLL_DECL boss_hazzarahAI : public ScriptedAI -{ - boss_hazzarahAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 ManaBurn_Timer; - uint32 Sleep_Timer; - uint32 Illusions_Timer; - Creature* Illusion; - - void Reset() - { - ManaBurn_Timer = 4000 + rand()%6000; - Sleep_Timer = 10000 + rand()%8000; - Illusions_Timer = 10000 + rand()%8000; - } - - void Aggro(Unit *who) - { - } - - void UpdateAI(const uint32 diff) - { - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - //ManaBurn_Timer - if (ManaBurn_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_MANABURN); - ManaBurn_Timer = 8000 + rand()%8000; - }else ManaBurn_Timer -= diff; - - //Sleep_Timer - if (Sleep_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_SLEEP); - Sleep_Timer = 12000 + rand()%8000; - }else Sleep_Timer -= diff; - - //Illusions_Timer - if (Illusions_Timer < diff) - { - //We will summon 3 illusions that will spawn on a random gamer and attack this gamer - //We will just use one model for the beginning - Unit* target = NULL; - for(int i = 0; i < 3;i++) - { - target = SelectUnit(SELECT_TARGET_RANDOM,0); - Illusion = m_creature->SummonCreature(15163,target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(),0,TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN,30000); - ((CreatureAI*)Illusion->AI())->AttackStart(target); - } - - Illusions_Timer = 15000 + rand()%10000; - }else Illusions_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; -CreatureAI* GetAI_boss_hazzarah(Creature *_Creature) -{ - return new boss_hazzarahAI (_Creature); -} - -void AddSC_boss_hazzarah() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_hazzarah"; - newscript->GetAI = GetAI_boss_hazzarah; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Hazzarah +SD%Complete: 100 +SDComment: +SDCategory: Zul'Gurub +EndScriptData */ + +#include "precompiled.h" +#include "def_zulgurub.h" + +#define SPELL_MANABURN 26046 +#define SPELL_SLEEP 24664 + +struct MANGOS_DLL_DECL boss_hazzarahAI : public ScriptedAI +{ + boss_hazzarahAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 ManaBurn_Timer; + uint32 Sleep_Timer; + uint32 Illusions_Timer; + Creature* Illusion; + + void Reset() + { + ManaBurn_Timer = 4000 + rand()%6000; + Sleep_Timer = 10000 + rand()%8000; + Illusions_Timer = 10000 + rand()%8000; + } + + void Aggro(Unit *who) + { + } + + void UpdateAI(const uint32 diff) + { + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + //ManaBurn_Timer + if (ManaBurn_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_MANABURN); + ManaBurn_Timer = 8000 + rand()%8000; + }else ManaBurn_Timer -= diff; + + //Sleep_Timer + if (Sleep_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_SLEEP); + Sleep_Timer = 12000 + rand()%8000; + }else Sleep_Timer -= diff; + + //Illusions_Timer + if (Illusions_Timer < diff) + { + //We will summon 3 illusions that will spawn on a random gamer and attack this gamer + //We will just use one model for the beginning + Unit* target = NULL; + for(int i = 0; i < 3;i++) + { + target = SelectUnit(SELECT_TARGET_RANDOM,0); + Illusion = m_creature->SummonCreature(15163,target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(),0,TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN,30000); + ((CreatureAI*)Illusion->AI())->AttackStart(target); + } + + Illusions_Timer = 15000 + rand()%10000; + }else Illusions_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; +CreatureAI* GetAI_boss_hazzarah(Creature *_Creature) +{ + return new boss_hazzarahAI (_Creature); +} + +void AddSC_boss_hazzarah() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_hazzarah"; + newscript->GetAI = GetAI_boss_hazzarah; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/zulgurub/boss_jeklik.cpp b/src/bindings/scripts/scripts/zone/zulgurub/boss_jeklik.cpp index efe76bbe5ec..014c305a146 100644 --- a/src/bindings/scripts/scripts/zone/zulgurub/boss_jeklik.cpp +++ b/src/bindings/scripts/scripts/zone/zulgurub/boss_jeklik.cpp @@ -1,297 +1,297 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Jeklik -SD%Complete: 85 -SDComment: Problem in finding the right flying batriders for spawning and making them fly. -SDCategory: Zul'Gurub -EndScriptData */ - -#include "precompiled.h" -#include "def_zulgurub.h" - -#define SPELL_CHARGE 22911 -#define SPELL_SONICBURST 23918 -#define SPELL_SCREECH 6605 -#define SPELL_SHADOW_WORD_PAIN 23952 -#define SPELL_MIND_FLAY 23953 -#define SPELL_CHAIN_MIND_FLAY 26044 //Right ID unknown. So disabled -#define SPELL_GREATERHEAL 23954 -#define SPELL_BAT_FORM 23966 - -// Batriders Spell - -#define SPELL_BOMB 40332 //Wrong ID but Magmadars bomb is not working... - -#define SAY_AGGRO "Lord Hireek grant me wings of vengance!" -#define SAY_DEATH "Hireek - Finnaly death. Curse you Hakkar! Curse you!" - -#define SOUND_AGGRO 8417 -#define SOUND_DEATH 8422 - -struct MANGOS_DLL_DECL boss_jeklikAI : public ScriptedAI -{ - boss_jeklikAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 Charge_Timer; - uint32 SonicBurst_Timer; - uint32 Screech_Timer; - uint32 SpawnBats_Timer; - uint32 ShadowWordPain_Timer; - uint32 MindFlay_Timer; - uint32 ChainMindFlay_Timer; - uint32 GreaterHeal_Timer; - uint32 SpawnFlyingBats_Timer; - - bool PhaseTwo; - - void Reset() - { - Charge_Timer = 20000; - SonicBurst_Timer = 8000; - Screech_Timer = 13000; - SpawnBats_Timer = 60000; - ShadowWordPain_Timer = 6000; - MindFlay_Timer = 11000; - ChainMindFlay_Timer = 26000; - GreaterHeal_Timer = 50000; - SpawnFlyingBats_Timer = 10000; - - PhaseTwo = false; - } - - void Aggro(Unit *who) - { - DoYell(SAY_AGGRO,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_AGGRO); - DoCast(m_creature,SPELL_BAT_FORM); - } - - void JustDied(Unit* Killer) - { - DoYell(SAY_DEATH,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_DEATH); - - ScriptedInstance *pInstance = ((ScriptedInstance*)m_creature->GetInstanceData()); - if(pInstance) - pInstance->SetData(DATA_JEKLIK_DEATH, 0); - } - - void UpdateAI(const uint32 diff) - { - if (!m_creature->SelectHostilTarget()) - return; - - if( m_creature->getVictim() && m_creature->isAlive()) - { - if ((m_creature->GetHealth()*100 / m_creature->GetMaxHealth() > 50)) - { - if (Charge_Timer < diff) - { - Unit* target = SelectUnit(SELECT_TARGET_RANDOM,0); - if(target) - { - DoCast(target,SPELL_CHARGE); - - m_creature->Relocate(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0); - m_creature->SendMonsterMove(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0, true,1); - DoStartAttackAndMovement(target); - } - - Charge_Timer = 15000 + rand()%15000; - }else Charge_Timer -= diff; - - if (SonicBurst_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_SONICBURST); - SonicBurst_Timer = 8000 + rand()%5000; - }else SonicBurst_Timer -= diff; - - if (Screech_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_SCREECH); - Screech_Timer = 18000 + rand()%8000; - }else Screech_Timer -= diff; - - if (SpawnBats_Timer < diff) - { - Unit* target = SelectUnit(SELECT_TARGET_RANDOM,0); - - Creature* Bat = NULL; - Bat = m_creature->SummonCreature(11368,-12291.6220,-1380.2640,144.8304,5.483, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000); - if(target && Bat ) { Bat ->AI()->AttackStart(target); } - - Bat = m_creature->SummonCreature(11368,-12289.6220,-1380.2640,144.8304,5.483, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000); - if(target && Bat ) { Bat ->AI()->AttackStart(target); } - - Bat = m_creature->SummonCreature(11368,-12293.6220,-1380.2640,144.8304,5.483, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000); - if(target && Bat ) { Bat ->AI()->AttackStart(target); } - - Bat = m_creature->SummonCreature(11368,-12291.6220,-1380.2640,144.8304,5.483, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000); - if(target && Bat ) { Bat ->AI()->AttackStart(target); } - - Bat = m_creature->SummonCreature(11368,-12289.6220,-1380.2640,144.8304,5.483, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000); - if(target && Bat ) { Bat ->AI()->AttackStart(target); } - Bat = m_creature->SummonCreature(11368,-12293.6220,-1380.2640,144.8304,5.483, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000); - if(target && Bat ) { Bat ->AI()->AttackStart(target); } - - SpawnBats_Timer = 60000; - }else SpawnBats_Timer -= diff; - } - else - { - if(PhaseTwo) - { - if(PhaseTwo && ShadowWordPain_Timer < diff) - { - Unit* target = SelectUnit(SELECT_TARGET_RANDOM,0); - if(target) - { - DoCast(target, SPELL_SHADOW_WORD_PAIN); - ShadowWordPain_Timer = 12000 + rand()%6000; - } - }ShadowWordPain_Timer -=diff; - - if(MindFlay_Timer < diff) - { - DoCast(m_creature->getVictim(), SPELL_MIND_FLAY); - MindFlay_Timer = 16000; - }MindFlay_Timer -=diff; - - if(ChainMindFlay_Timer < diff) - { - m_creature->InterruptNonMeleeSpells(false); - DoCast(m_creature->getVictim(), SPELL_CHAIN_MIND_FLAY); - ChainMindFlay_Timer = 15000 + rand()%15000; - }ChainMindFlay_Timer -=diff; - - if(GreaterHeal_Timer < diff) - { - m_creature->InterruptNonMeleeSpells(false); - DoCast(m_creature,SPELL_GREATERHEAL); - GreaterHeal_Timer = 25000 + rand()%10000; - }GreaterHeal_Timer -=diff; - - if(SpawnFlyingBats_Timer < diff) - { - Unit *target = SelectUnit(SELECT_TARGET_RANDOM, 0); - - Creature* FlyingBat = m_creature->SummonCreature(14965, target->GetPositionX(), target->GetPositionY(), target->GetPositionZ()+15, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000); - if(FlyingBat) - { - if(target) - FlyingBat->AI()->AttackStart(target); - } - - SpawnFlyingBats_Timer = 10000 + rand()%5000; - }SpawnFlyingBats_Timer -=diff; - } - else - { - m_creature->SetUInt32Value(UNIT_FIELD_DISPLAYID,15219); - DoResetThreat(); - PhaseTwo = true; - } - } - - DoMeleeAttackIfReady(); - } - } -}; - -//Flying Bat -struct MANGOS_DLL_DECL mob_batriderAI : public ScriptedAI -{ - mob_batriderAI(Creature *c) : ScriptedAI(c) - { - pInstance = ((ScriptedInstance*)c->GetInstanceData()); - Reset(); - } - - ScriptedInstance *pInstance; - - uint32 Bomb_Timer; - uint32 Check_Timer; - - void Reset() - { - Bomb_Timer = 2000; - Check_Timer = 1000; - - m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - } - - void Aggro(Unit *who) {} - - void UpdateAI (const uint32 diff) - { - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - //Bomb_Timer - if(Bomb_Timer < diff) - { - Unit *target = SelectUnit(SELECT_TARGET_RANDOM, 0); - if(target) - { - DoCast(target, SPELL_BOMB); - Bomb_Timer = 5000; - } - }else Bomb_Timer -= diff; - - //Check_Timer - if(Check_Timer < diff) - { - if(pInstance) - { - if(pInstance->GetData(DATA_JEKLIKISDEAD)) - { - m_creature->setDeathState(JUST_DIED); - m_creature->RemoveCorpse(); - } - } - - Check_Timer = 1000; - }else Check_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; - -CreatureAI* GetAI_boss_jeklik(Creature *_Creature) -{ - return new boss_jeklikAI (_Creature); -} - -CreatureAI* GetAI_mob_batrider(Creature *_Creature) -{ - return new mob_batriderAI (_Creature); -} - -void AddSC_boss_jeklik() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_jeklik"; - newscript->GetAI = GetAI_boss_jeklik; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="mob_batrider"; - newscript->GetAI = GetAI_mob_batrider; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Jeklik +SD%Complete: 85 +SDComment: Problem in finding the right flying batriders for spawning and making them fly. +SDCategory: Zul'Gurub +EndScriptData */ + +#include "precompiled.h" +#include "def_zulgurub.h" + +#define SPELL_CHARGE 22911 +#define SPELL_SONICBURST 23918 +#define SPELL_SCREECH 6605 +#define SPELL_SHADOW_WORD_PAIN 23952 +#define SPELL_MIND_FLAY 23953 +#define SPELL_CHAIN_MIND_FLAY 26044 //Right ID unknown. So disabled +#define SPELL_GREATERHEAL 23954 +#define SPELL_BAT_FORM 23966 + +// Batriders Spell + +#define SPELL_BOMB 40332 //Wrong ID but Magmadars bomb is not working... + +#define SAY_AGGRO "Lord Hireek grant me wings of vengance!" +#define SAY_DEATH "Hireek - Finnaly death. Curse you Hakkar! Curse you!" + +#define SOUND_AGGRO 8417 +#define SOUND_DEATH 8422 + +struct MANGOS_DLL_DECL boss_jeklikAI : public ScriptedAI +{ + boss_jeklikAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 Charge_Timer; + uint32 SonicBurst_Timer; + uint32 Screech_Timer; + uint32 SpawnBats_Timer; + uint32 ShadowWordPain_Timer; + uint32 MindFlay_Timer; + uint32 ChainMindFlay_Timer; + uint32 GreaterHeal_Timer; + uint32 SpawnFlyingBats_Timer; + + bool PhaseTwo; + + void Reset() + { + Charge_Timer = 20000; + SonicBurst_Timer = 8000; + Screech_Timer = 13000; + SpawnBats_Timer = 60000; + ShadowWordPain_Timer = 6000; + MindFlay_Timer = 11000; + ChainMindFlay_Timer = 26000; + GreaterHeal_Timer = 50000; + SpawnFlyingBats_Timer = 10000; + + PhaseTwo = false; + } + + void Aggro(Unit *who) + { + DoYell(SAY_AGGRO,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_AGGRO); + DoCast(m_creature,SPELL_BAT_FORM); + } + + void JustDied(Unit* Killer) + { + DoYell(SAY_DEATH,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_DEATH); + + ScriptedInstance *pInstance = ((ScriptedInstance*)m_creature->GetInstanceData()); + if(pInstance) + pInstance->SetData(DATA_JEKLIK_DEATH, 0); + } + + void UpdateAI(const uint32 diff) + { + if (!m_creature->SelectHostilTarget()) + return; + + if( m_creature->getVictim() && m_creature->isAlive()) + { + if ((m_creature->GetHealth()*100 / m_creature->GetMaxHealth() > 50)) + { + if (Charge_Timer < diff) + { + Unit* target = SelectUnit(SELECT_TARGET_RANDOM,0); + if(target) + { + DoCast(target,SPELL_CHARGE); + + m_creature->Relocate(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0); + m_creature->SendMonsterMove(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0, true,1); + DoStartAttackAndMovement(target); + } + + Charge_Timer = 15000 + rand()%15000; + }else Charge_Timer -= diff; + + if (SonicBurst_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_SONICBURST); + SonicBurst_Timer = 8000 + rand()%5000; + }else SonicBurst_Timer -= diff; + + if (Screech_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_SCREECH); + Screech_Timer = 18000 + rand()%8000; + }else Screech_Timer -= diff; + + if (SpawnBats_Timer < diff) + { + Unit* target = SelectUnit(SELECT_TARGET_RANDOM,0); + + Creature* Bat = NULL; + Bat = m_creature->SummonCreature(11368,-12291.6220,-1380.2640,144.8304,5.483, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000); + if(target && Bat ) { Bat ->AI()->AttackStart(target); } + + Bat = m_creature->SummonCreature(11368,-12289.6220,-1380.2640,144.8304,5.483, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000); + if(target && Bat ) { Bat ->AI()->AttackStart(target); } + + Bat = m_creature->SummonCreature(11368,-12293.6220,-1380.2640,144.8304,5.483, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000); + if(target && Bat ) { Bat ->AI()->AttackStart(target); } + + Bat = m_creature->SummonCreature(11368,-12291.6220,-1380.2640,144.8304,5.483, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000); + if(target && Bat ) { Bat ->AI()->AttackStart(target); } + + Bat = m_creature->SummonCreature(11368,-12289.6220,-1380.2640,144.8304,5.483, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000); + if(target && Bat ) { Bat ->AI()->AttackStart(target); } + Bat = m_creature->SummonCreature(11368,-12293.6220,-1380.2640,144.8304,5.483, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000); + if(target && Bat ) { Bat ->AI()->AttackStart(target); } + + SpawnBats_Timer = 60000; + }else SpawnBats_Timer -= diff; + } + else + { + if(PhaseTwo) + { + if(PhaseTwo && ShadowWordPain_Timer < diff) + { + Unit* target = SelectUnit(SELECT_TARGET_RANDOM,0); + if(target) + { + DoCast(target, SPELL_SHADOW_WORD_PAIN); + ShadowWordPain_Timer = 12000 + rand()%6000; + } + }ShadowWordPain_Timer -=diff; + + if(MindFlay_Timer < diff) + { + DoCast(m_creature->getVictim(), SPELL_MIND_FLAY); + MindFlay_Timer = 16000; + }MindFlay_Timer -=diff; + + if(ChainMindFlay_Timer < diff) + { + m_creature->InterruptNonMeleeSpells(false); + DoCast(m_creature->getVictim(), SPELL_CHAIN_MIND_FLAY); + ChainMindFlay_Timer = 15000 + rand()%15000; + }ChainMindFlay_Timer -=diff; + + if(GreaterHeal_Timer < diff) + { + m_creature->InterruptNonMeleeSpells(false); + DoCast(m_creature,SPELL_GREATERHEAL); + GreaterHeal_Timer = 25000 + rand()%10000; + }GreaterHeal_Timer -=diff; + + if(SpawnFlyingBats_Timer < diff) + { + Unit *target = SelectUnit(SELECT_TARGET_RANDOM, 0); + + Creature* FlyingBat = m_creature->SummonCreature(14965, target->GetPositionX(), target->GetPositionY(), target->GetPositionZ()+15, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000); + if(FlyingBat) + { + if(target) + FlyingBat->AI()->AttackStart(target); + } + + SpawnFlyingBats_Timer = 10000 + rand()%5000; + }SpawnFlyingBats_Timer -=diff; + } + else + { + m_creature->SetUInt32Value(UNIT_FIELD_DISPLAYID,15219); + DoResetThreat(); + PhaseTwo = true; + } + } + + DoMeleeAttackIfReady(); + } + } +}; + +//Flying Bat +struct MANGOS_DLL_DECL mob_batriderAI : public ScriptedAI +{ + mob_batriderAI(Creature *c) : ScriptedAI(c) + { + pInstance = ((ScriptedInstance*)c->GetInstanceData()); + Reset(); + } + + ScriptedInstance *pInstance; + + uint32 Bomb_Timer; + uint32 Check_Timer; + + void Reset() + { + Bomb_Timer = 2000; + Check_Timer = 1000; + + m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + } + + void Aggro(Unit *who) {} + + void UpdateAI (const uint32 diff) + { + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + //Bomb_Timer + if(Bomb_Timer < diff) + { + Unit *target = SelectUnit(SELECT_TARGET_RANDOM, 0); + if(target) + { + DoCast(target, SPELL_BOMB); + Bomb_Timer = 5000; + } + }else Bomb_Timer -= diff; + + //Check_Timer + if(Check_Timer < diff) + { + if(pInstance) + { + if(pInstance->GetData(DATA_JEKLIKISDEAD)) + { + m_creature->setDeathState(JUST_DIED); + m_creature->RemoveCorpse(); + } + } + + Check_Timer = 1000; + }else Check_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; + +CreatureAI* GetAI_boss_jeklik(Creature *_Creature) +{ + return new boss_jeklikAI (_Creature); +} + +CreatureAI* GetAI_mob_batrider(Creature *_Creature) +{ + return new mob_batriderAI (_Creature); +} + +void AddSC_boss_jeklik() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_jeklik"; + newscript->GetAI = GetAI_boss_jeklik; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="mob_batrider"; + newscript->GetAI = GetAI_mob_batrider; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/zulgurub/boss_jindo.cpp b/src/bindings/scripts/scripts/zone/zulgurub/boss_jindo.cpp index 8a9a5cb2cc8..79ae84968b8 100644 --- a/src/bindings/scripts/scripts/zone/zulgurub/boss_jindo.cpp +++ b/src/bindings/scripts/scripts/zone/zulgurub/boss_jindo.cpp @@ -1,308 +1,272 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Jin'do the Hexxer -SD%Complete: 85 -SDComment: Mind Control not working because of core bug. Shades visible for all. -SDCategory: Zul'Gurub -EndScriptData */ - -#include "precompiled.h" -#include "def_zulgurub.h" - -#define SPELL_BRAINWASHTOTEM 24262 -#define SPELL_POWERFULLHEALINGWARD 24309 //We will not use this spell. We will summon a totem by script cause the spell totems will not cast. -#define SPELL_HEX 24053 -#define SPELL_DELUSIONSOFJINDO 24306 -#define SPELL_SHADEOFJINDO 24308 //We will not use this spell. We will summon a shade by script. - -//Healing Ward Spell -#define SPELL_HEAL 38588 //Totems are not working right. Right heal spell ID is 24311 but this spell is not casting... - -//Shade of Jindo Spell -#define SPELL_SHADOWSHOCK 19460 -#define SPELL_INVISIBLE 24699 - -#define SAY_AGGRO "Welcome to da great show friends! Step right up to die!" - -#define SOUND_AGGRO 8425 - -struct MANGOS_DLL_DECL boss_jindoAI : public ScriptedAI -{ - boss_jindoAI(Creature *c) : ScriptedAI(c) - { - pInstance = (c->GetInstanceData()) ? ((ScriptedInstance*)c->GetInstanceData()) : NULL; - Reset(); - } - - uint32 BrainWashTotem_Timer; - uint32 HealingWard_Timer; - uint32 Hex_Timer; - uint32 Delusions_Timer; - uint32 Teleport_Timer; - - Creature *Shade; - Creature *Skeletons; - Creature *HealingWard; - - ScriptedInstance *pInstance; - - void Reset() - { - BrainWashTotem_Timer = 20000; - HealingWard_Timer = 16000; - Hex_Timer = 8000; - Delusions_Timer = 10000; - Teleport_Timer = 5000; - } - - void Aggro(Unit *who) - { - DoYell(SAY_AGGRO,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_AGGRO); - } - - void UpdateAI(const uint32 diff) - { - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - //BrainWashTotem_Timer - if (BrainWashTotem_Timer < diff) - { - DoCast(m_creature, SPELL_BRAINWASHTOTEM); - BrainWashTotem_Timer = 18000 + rand()%8000; - }else BrainWashTotem_Timer -= diff; - - //HealingWard_Timer - if (HealingWard_Timer < diff) - { - //DoCast(m_creature, SPELL_POWERFULLHEALINGWARD); - HealingWard = m_creature->SummonCreature(14987, m_creature->GetPositionX()+3, m_creature->GetPositionY()-2, m_creature->GetPositionZ(), 0, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,30000); - HealingWard_Timer = 14000 + rand()%6000; - }else HealingWard_Timer -= diff; - - //Hex_Timer - if (Hex_Timer < diff) - { - DoCast(m_creature->getVictim(), SPELL_HEX); - - if(m_creature->getThreatManager().getThreat(m_creature->getVictim())) - m_creature->getThreatManager().modifyThreatPercent(m_creature->getVictim(),-80); - - Hex_Timer = 12000 + rand()%8000; - }else Hex_Timer -= diff; - - //Casting the delusion curse with a shade. So shade will attack the same target with the curse. - if (Delusions_Timer < diff) - { - Unit* target = NULL; - target = SelectUnit(SELECT_TARGET_RANDOM,0); - - DoCast(target, SPELL_DELUSIONSOFJINDO); - - Shade = m_creature->SummonCreature(14986, target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000); - Shade->AI()->AttackStart(target); - - Delusions_Timer = 4000 + rand()%8000; - }else Delusions_Timer -= diff; - - //Teleporting a random gamer and spawning 9 skeletons that will attack this gamer - if (Teleport_Timer < diff) - { - Unit* target = NULL; - target = SelectUnit(SELECT_TARGET_RANDOM,0); - if (target && target->GetTypeId() == TYPEID_PLAYER) - { - DoTeleportPlayer(target, -11583.7783,-1249.4278,77.5471,4.745); - - if(m_creature->getThreatManager().getThreat(m_creature->getVictim())) - m_creature->getThreatManager().modifyThreatPercent(target,-100); - - Skeletons = m_creature->SummonCreature(14826, target->GetPositionX()+2, target->GetPositionY(), target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000); - Skeletons->AI()->AttackStart(target); - Skeletons = m_creature->SummonCreature(14826, target->GetPositionX()-2, target->GetPositionY(), target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000); - Skeletons->AI()->AttackStart(target); - Skeletons = m_creature->SummonCreature(14826, target->GetPositionX()+4, target->GetPositionY(), target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000); - Skeletons->AI()->AttackStart(target); - Skeletons = m_creature->SummonCreature(14826, target->GetPositionX()-4, target->GetPositionY(), target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000); - Skeletons->AI()->AttackStart(target); - Skeletons = m_creature->SummonCreature(14826, target->GetPositionX(), target->GetPositionY()+2, target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000); - Skeletons->AI()->AttackStart(target); - Skeletons = m_creature->SummonCreature(14826, target->GetPositionX(), target->GetPositionY()-2, target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000); - Skeletons->AI()->AttackStart(target); - Skeletons = m_creature->SummonCreature(14826, target->GetPositionX(), target->GetPositionY()+4, target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000); - Skeletons->AI()->AttackStart(target); - Skeletons = m_creature->SummonCreature(14826, target->GetPositionX(), target->GetPositionY()-4, target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000); - Skeletons->AI()->AttackStart(target); - Skeletons = m_creature->SummonCreature(14826, target->GetPositionX()+3, target->GetPositionY(), target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000); - Skeletons->AI()->AttackStart(target); - } - - Teleport_Timer = 15000 + rand()%8000; - }else Teleport_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; - -//Healing Ward -struct MANGOS_DLL_DECL mob_healing_wardAI : public ScriptedAI -{ - mob_healing_wardAI(Creature *c) : ScriptedAI(c) - { - pInstance = (c->GetInstanceData()) ? ((ScriptedInstance*)c->GetInstanceData()) : NULL; - Reset(); - } - - uint32 Heal_Timer; - - ScriptedInstance *pInstance; - - void Reset() - { - Heal_Timer = 2000; - } - - void Aggro(Unit *who) - { - } - - void MoveInLineOfSight(Unit *who) - { - if (!who || m_creature->getVictim()) - return; - - if (who->isTargetableForAttack() && who->isInAccessablePlaceFor(m_creature) && m_creature->IsHostileTo(who)) - { - float attackRadius = m_creature->GetAttackDistance(who); - if (m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->GetDistanceZ(who) <= CREATURE_Z_ATTACK_RANGE && m_creature->IsWithinLOSInMap(who)) - { - if(who->HasStealthAura()) - who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); - - DoStartAttackAndMovement(who); - } - } - } - - void UpdateAI (const uint32 diff) - { - //Heal_Timer - if(Heal_Timer < diff) - { - if(pInstance) - { - Unit *pJindo = Unit::GetUnit((*m_creature), pInstance->GetData64(DATA_JINDO)); - DoCast(pJindo, SPELL_HEAL); - } - Heal_Timer = 3000; - }else Heal_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; - -//Shade of Jindo -struct MANGOS_DLL_DECL mob_shade_of_jindoAI : public ScriptedAI -{ - mob_shade_of_jindoAI(Creature *c) : ScriptedAI(c) - { - pInstance = (c->GetInstanceData()) ? ((ScriptedInstance*)c->GetInstanceData()) : NULL; - Reset(); - } - - uint32 ShadowShock_Timer; - - ScriptedInstance *pInstance; - - void Reset() - { - ShadowShock_Timer = 1000; - m_creature->CastSpell(m_creature, SPELL_INVISIBLE,true); - } - - void Aggro(Unit *who) - { - } - - void MoveInLineOfSight(Unit *who) - { - if (!who || m_creature->getVictim()) - return; - - if (who->isTargetableForAttack() && who->isInAccessablePlaceFor(m_creature) && m_creature->IsHostileTo(who)) - { - float attackRadius = m_creature->GetAttackDistance(who); - if (m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->GetDistanceZ(who) <= CREATURE_Z_ATTACK_RANGE && m_creature->IsWithinLOSInMap(who)) - { - if(who->HasStealthAura()) - who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); - - DoStartAttackAndMovement(who); - } - } - } - - void UpdateAI (const uint32 diff) - { - - //ShadowShock_Timer - if(ShadowShock_Timer < diff) - { - DoCast(m_creature->getVictim(), SPELL_SHADOWSHOCK); - ShadowShock_Timer = 2000; - }else ShadowShock_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; - -CreatureAI* GetAI_boss_jindo(Creature *_Creature) -{ - return new boss_jindoAI (_Creature); -} - -CreatureAI* GetAI_mob_healing_ward(Creature *_Creature) -{ - return new mob_healing_wardAI (_Creature); -} - -CreatureAI* GetAI_mob_shade_of_jindo(Creature *_Creature) -{ - return new mob_shade_of_jindoAI (_Creature); -} - -void AddSC_boss_jindo() -{ - Script *newscript; - - newscript = new Script; - newscript->Name="boss_jindo"; - newscript->GetAI = GetAI_boss_jindo; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="mob_healing_ward"; - newscript->GetAI = GetAI_mob_healing_ward; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="mob_shade_of_jindo"; - newscript->GetAI = GetAI_mob_shade_of_jindo; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Jin'do the Hexxer +SD%Complete: 85 +SDComment: Mind Control not working because of core bug. Shades visible for all. +SDCategory: Zul'Gurub +EndScriptData */ + +#include "precompiled.h" +#include "def_zulgurub.h" + +#define SPELL_BRAINWASHTOTEM 24262 +#define SPELL_POWERFULLHEALINGWARD 24309 //We will not use this spell. We will summon a totem by script cause the spell totems will not cast. +#define SPELL_HEX 24053 +#define SPELL_DELUSIONSOFJINDO 24306 +#define SPELL_SHADEOFJINDO 24308 //We will not use this spell. We will summon a shade by script. + +//Healing Ward Spell +#define SPELL_HEAL 38588 //Totems are not working right. Right heal spell ID is 24311 but this spell is not casting... + +//Shade of Jindo Spell +#define SPELL_SHADOWSHOCK 19460 +#define SPELL_INVISIBLE 24699 + +#define SAY_AGGRO "Welcome to da great show friends! Step right up to die!" + +#define SOUND_AGGRO 8425 + +struct MANGOS_DLL_DECL boss_jindoAI : public ScriptedAI +{ + boss_jindoAI(Creature *c) : ScriptedAI(c) + { + pInstance = (c->GetInstanceData()) ? ((ScriptedInstance*)c->GetInstanceData()) : NULL; + Reset(); + } + + uint32 BrainWashTotem_Timer; + uint32 HealingWard_Timer; + uint32 Hex_Timer; + uint32 Delusions_Timer; + uint32 Teleport_Timer; + + Creature *Shade; + Creature *Skeletons; + Creature *HealingWard; + + ScriptedInstance *pInstance; + + void Reset() + { + BrainWashTotem_Timer = 20000; + HealingWard_Timer = 16000; + Hex_Timer = 8000; + Delusions_Timer = 10000; + Teleport_Timer = 5000; + } + + void Aggro(Unit *who) + { + DoYell(SAY_AGGRO,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_AGGRO); + } + + void UpdateAI(const uint32 diff) + { + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + //BrainWashTotem_Timer + if (BrainWashTotem_Timer < diff) + { + DoCast(m_creature, SPELL_BRAINWASHTOTEM); + BrainWashTotem_Timer = 18000 + rand()%8000; + }else BrainWashTotem_Timer -= diff; + + //HealingWard_Timer + if (HealingWard_Timer < diff) + { + //DoCast(m_creature, SPELL_POWERFULLHEALINGWARD); + HealingWard = m_creature->SummonCreature(14987, m_creature->GetPositionX()+3, m_creature->GetPositionY()-2, m_creature->GetPositionZ(), 0, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,30000); + HealingWard_Timer = 14000 + rand()%6000; + }else HealingWard_Timer -= diff; + + //Hex_Timer + if (Hex_Timer < diff) + { + DoCast(m_creature->getVictim(), SPELL_HEX); + + if(m_creature->getThreatManager().getThreat(m_creature->getVictim())) + m_creature->getThreatManager().modifyThreatPercent(m_creature->getVictim(),-80); + + Hex_Timer = 12000 + rand()%8000; + }else Hex_Timer -= diff; + + //Casting the delusion curse with a shade. So shade will attack the same target with the curse. + if (Delusions_Timer < diff) + { + Unit* target = NULL; + target = SelectUnit(SELECT_TARGET_RANDOM,0); + + DoCast(target, SPELL_DELUSIONSOFJINDO); + + Shade = m_creature->SummonCreature(14986, target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000); + Shade->AI()->AttackStart(target); + + Delusions_Timer = 4000 + rand()%8000; + }else Delusions_Timer -= diff; + + //Teleporting a random gamer and spawning 9 skeletons that will attack this gamer + if (Teleport_Timer < diff) + { + Unit* target = NULL; + target = SelectUnit(SELECT_TARGET_RANDOM,0); + if (target && target->GetTypeId() == TYPEID_PLAYER) + { + DoTeleportPlayer(target, -11583.7783,-1249.4278,77.5471,4.745); + + if(m_creature->getThreatManager().getThreat(m_creature->getVictim())) + m_creature->getThreatManager().modifyThreatPercent(target,-100); + + Skeletons = m_creature->SummonCreature(14826, target->GetPositionX()+2, target->GetPositionY(), target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000); + Skeletons->AI()->AttackStart(target); + Skeletons = m_creature->SummonCreature(14826, target->GetPositionX()-2, target->GetPositionY(), target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000); + Skeletons->AI()->AttackStart(target); + Skeletons = m_creature->SummonCreature(14826, target->GetPositionX()+4, target->GetPositionY(), target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000); + Skeletons->AI()->AttackStart(target); + Skeletons = m_creature->SummonCreature(14826, target->GetPositionX()-4, target->GetPositionY(), target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000); + Skeletons->AI()->AttackStart(target); + Skeletons = m_creature->SummonCreature(14826, target->GetPositionX(), target->GetPositionY()+2, target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000); + Skeletons->AI()->AttackStart(target); + Skeletons = m_creature->SummonCreature(14826, target->GetPositionX(), target->GetPositionY()-2, target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000); + Skeletons->AI()->AttackStart(target); + Skeletons = m_creature->SummonCreature(14826, target->GetPositionX(), target->GetPositionY()+4, target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000); + Skeletons->AI()->AttackStart(target); + Skeletons = m_creature->SummonCreature(14826, target->GetPositionX(), target->GetPositionY()-4, target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000); + Skeletons->AI()->AttackStart(target); + Skeletons = m_creature->SummonCreature(14826, target->GetPositionX()+3, target->GetPositionY(), target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000); + Skeletons->AI()->AttackStart(target); + } + + Teleport_Timer = 15000 + rand()%8000; + }else Teleport_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; + +//Healing Ward +struct MANGOS_DLL_DECL mob_healing_wardAI : public ScriptedAI +{ + mob_healing_wardAI(Creature *c) : ScriptedAI(c) + { + pInstance = (c->GetInstanceData()) ? ((ScriptedInstance*)c->GetInstanceData()) : NULL; + Reset(); + } + + uint32 Heal_Timer; + + ScriptedInstance *pInstance; + + void Reset() + { + Heal_Timer = 2000; + } + + void Aggro(Unit *who) + { + } + + void UpdateAI (const uint32 diff) + { + //Heal_Timer + if(Heal_Timer < diff) + { + if(pInstance) + { + Unit *pJindo = Unit::GetUnit((*m_creature), pInstance->GetData64(DATA_JINDO)); + DoCast(pJindo, SPELL_HEAL); + } + Heal_Timer = 3000; + }else Heal_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; + +//Shade of Jindo +struct MANGOS_DLL_DECL mob_shade_of_jindoAI : public ScriptedAI +{ + mob_shade_of_jindoAI(Creature *c) : ScriptedAI(c) + { + pInstance = (c->GetInstanceData()) ? ((ScriptedInstance*)c->GetInstanceData()) : NULL; + Reset(); + } + + uint32 ShadowShock_Timer; + + ScriptedInstance *pInstance; + + void Reset() + { + ShadowShock_Timer = 1000; + m_creature->CastSpell(m_creature, SPELL_INVISIBLE,true); + } + + void Aggro(Unit *who) + { + } + + void UpdateAI (const uint32 diff) + { + + //ShadowShock_Timer + if(ShadowShock_Timer < diff) + { + DoCast(m_creature->getVictim(), SPELL_SHADOWSHOCK); + ShadowShock_Timer = 2000; + }else ShadowShock_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; + +CreatureAI* GetAI_boss_jindo(Creature *_Creature) +{ + return new boss_jindoAI (_Creature); +} + +CreatureAI* GetAI_mob_healing_ward(Creature *_Creature) +{ + return new mob_healing_wardAI (_Creature); +} + +CreatureAI* GetAI_mob_shade_of_jindo(Creature *_Creature) +{ + return new mob_shade_of_jindoAI (_Creature); +} + +void AddSC_boss_jindo() +{ + Script *newscript; + + newscript = new Script; + newscript->Name="boss_jindo"; + newscript->GetAI = GetAI_boss_jindo; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="mob_healing_ward"; + newscript->GetAI = GetAI_mob_healing_ward; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="mob_shade_of_jindo"; + newscript->GetAI = GetAI_mob_shade_of_jindo; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/zulgurub/boss_mandokir.cpp b/src/bindings/scripts/scripts/zone/zulgurub/boss_mandokir.cpp index 7d8465b2780..3ffb5a0d32a 100644 --- a/src/bindings/scripts/scripts/zone/zulgurub/boss_mandokir.cpp +++ b/src/bindings/scripts/scripts/zone/zulgurub/boss_mandokir.cpp @@ -1,311 +1,311 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Mandokir -SD%Complete: 90 -SDComment: Ohgan function needs improvements. -SDCategory: Zul'Gurub -EndScriptData */ - -#include "precompiled.h" -#include "def_zulgurub.h" - -#define SPELL_CHARGE 24315 -#define SPELL_CLEAVE 20691 -#define SPELL_FEAR 29321 -#define SPELL_WHIRLWIND 24236 -#define SPELL_MORTAL_STRIKE 24573 -#define SPELL_ENRAGE 23537 -#define SPELL_WATCH 24314 -#define SPELL_LEVEL_UP 24312 - -//Ohgans Spells -#define SPELL_SUNDERARMOR 24317 - -#define SAY_AGGRO "I'll feed your souls to Hakkar himself!" -#define SOUND_AGGRO 8413 - -#define SAY_WATCH "I'm keeping my eye on you, $N!" -#define SAY_KILL "DING!" - -struct MANGOS_DLL_DECL boss_mandokirAI : public ScriptedAI -{ - boss_mandokirAI(Creature *c) : ScriptedAI(c) - { - pInstance = ((ScriptedInstance*)c->GetInstanceData()); - Reset(); - } - - uint32 Watch_Timer; - uint32 TargetInRange; - uint32 Cleave_Timer; - uint32 Whirlwind_Timer; - uint32 Fear_Timer; - uint32 MortalStrike_Timer; - uint32 Check_Timer; - float targetX; - float targetY; - float targetZ; - - ScriptedInstance *pInstance; - - bool endWatch; - bool someWatched; - bool RaptorDead; - bool CombatStart; - - uint64 WatchTarget; - - void Reset() - { - Watch_Timer = 33000; - Cleave_Timer = 7000; - Whirlwind_Timer = 20000; - Fear_Timer = 1000; - MortalStrike_Timer = 1000; - Check_Timer = 1000; - - targetX = 0.0; - targetY = 0.0; - targetZ = 0.0; - TargetInRange = 0; - - WatchTarget = 0; - - someWatched = false; - endWatch = false; - RaptorDead = false; - CombatStart = false; - - DoCast(m_creature, 23243); - } - - void KilledUnit(Unit* victim) - { - if(victim->GetTypeId() == TYPEID_PLAYER) - { - DoYell(SAY_KILL, LANG_UNIVERSAL, NULL); - DoCast(m_creature, SPELL_LEVEL_UP, true); - } - } - - void Aggro(Unit *who) {} - - void UpdateAI(const uint32 diff) - { - if (!m_creature->SelectHostilTarget()) - return; - - if( m_creature->getVictim() && m_creature->isAlive()) - { - if(!CombatStart) - { - //At combat Start Mandokir is mounted so we must unmount it first - m_creature->Unmount(); - - //And summon his raptor - m_creature->SummonCreature(14988, m_creature->getVictim()->GetPositionX(), m_creature->getVictim()->GetPositionY(), m_creature->getVictim()->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 35000); - CombatStart = true; - } - - if (Watch_Timer < diff) //Every 20 Sec Mandokir will check this - { - if(WatchTarget) //If someone is watched and If the Position of the watched target is different from the one stored, or are attacking, mandokir will charge him - { - Unit* pUnit = Unit::GetUnit(*m_creature, WatchTarget); - - if( pUnit && ( - targetX != pUnit->GetPositionX() || - targetY != pUnit->GetPositionY() || - targetZ != pUnit->GetPositionZ() || - pUnit->isInCombat())) - { - if(m_creature->IsWithinDistInMap(pUnit, ATTACK_DISTANCE)) - { - DoCast(pUnit,24316); - } - else - { - DoCast(pUnit,SPELL_CHARGE); - m_creature->SendMonsterMove(pUnit->GetPositionX(), pUnit->GetPositionY(), pUnit->GetPositionZ(), 0, true,1); - DoStartAttackAndMovement(pUnit); - } - } - } - someWatched = false; - Watch_Timer = 20000; - }else Watch_Timer -= diff; - - if ((Watch_Timer < 8000) && !someWatched) //8 sec(cast time + expire time) before the check for the watch effect mandokir will cast watch debuff on a random target - { - Unit* p = SelectUnit(SELECT_TARGET_RANDOM,0); - if(p) - { - DoYell(SAY_WATCH, LANG_UNIVERSAL, p); - DoCast(p, SPELL_WATCH); - WatchTarget = p->GetGUID(); - someWatched = true; - endWatch = true; - } - } - - if ((Watch_Timer < 1000) && endWatch) //1 sec before the debuf expire, store the target position - { - Unit* pUnit = Unit::GetUnit(*m_creature, WatchTarget); - if (pUnit) - { - targetX = pUnit->GetPositionX(); - targetY = pUnit->GetPositionY(); - targetZ = pUnit->GetPositionZ(); - } - endWatch = false; - } - - if(!someWatched) - { - //Cleave - if (Cleave_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_CLEAVE); - Cleave_Timer = 7000; - }else Cleave_Timer -= diff; - - //Whirlwind - if (Whirlwind_Timer < diff) - { - DoCast(m_creature,SPELL_WHIRLWIND); - Whirlwind_Timer = 18000; - }else Whirlwind_Timer -= diff; - - //If more then 3 targets in melee range mandokir will cast fear - if (Fear_Timer < diff) - { - TargetInRange = 0; - - std::list::iterator i = m_creature->getThreatManager().getThreatList().begin(); - for(; i != m_creature->getThreatManager().getThreatList().end(); ++i) - { - Unit* pUnit = Unit::GetUnit(*m_creature, (*i)->getUnitGuid()); - if(pUnit && m_creature->IsWithinDistInMap(pUnit, ATTACK_DISTANCE)) - TargetInRange++; - } - - if(TargetInRange > 3) - DoCast(m_creature->getVictim(),SPELL_FEAR); - - Fear_Timer = 4000; - }else Fear_Timer -=diff; - - //Mortal Strike if target below 50% hp - if (m_creature->getVictim()->GetHealth() < m_creature->getVictim()->GetMaxHealth()*0.5) - { - if (MortalStrike_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_MORTAL_STRIKE); - MortalStrike_Timer = 15000; - }else MortalStrike_Timer -= diff; - } - } - //Checking if Ohgan is dead. If yes Mandokir will enrage. - if(Check_Timer < diff) - { - if(pInstance) - { - if(pInstance->GetData(DATA_OHGANISDEAD)) - { - if (!RaptorDead) - { - DoCast(m_creature, SPELL_ENRAGE); - RaptorDead = true; - } - } - } - - Check_Timer = 1000; - }else Check_Timer -= diff; - - DoMeleeAttackIfReady(); - } - } -}; - -//Ohgan -struct MANGOS_DLL_DECL mob_ohganAI : public ScriptedAI -{ - mob_ohganAI(Creature *c) : ScriptedAI(c) - { - pInstance = ((ScriptedInstance*)c->GetInstanceData()); - Reset(); - } - - uint32 SunderArmor_Timer; - ScriptedInstance *pInstance; - - void Reset() - { - SunderArmor_Timer = 5000; - } - - void Aggro(Unit *who) {} - - void JustDied(Unit* Killer) - { - if(pInstance) - pInstance->SetData(DATA_OHGAN_DEATH, 0); - } - - void UpdateAI (const uint32 diff) - { - //Return since we have no target - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - //SunderArmor_Timer - if(SunderArmor_Timer < diff) - { - DoCast(m_creature->getVictim(), SPELL_SUNDERARMOR); - SunderArmor_Timer = 10000 + rand()%5000; - }else SunderArmor_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; - -CreatureAI* GetAI_boss_mandokir(Creature *_Creature) -{ - return new boss_mandokirAI (_Creature); -} - -CreatureAI* GetAI_mob_ohgan(Creature *_Creature) -{ - return new mob_ohganAI (_Creature); -} - -void AddSC_boss_mandokir() -{ - Script *newscript; - - newscript = new Script; - newscript->Name="boss_mandokir"; - newscript->GetAI = GetAI_boss_mandokir; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="mob_ohgan"; - newscript->GetAI = GetAI_mob_ohgan; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Mandokir +SD%Complete: 90 +SDComment: Ohgan function needs improvements. +SDCategory: Zul'Gurub +EndScriptData */ + +#include "precompiled.h" +#include "def_zulgurub.h" + +#define SPELL_CHARGE 24315 +#define SPELL_CLEAVE 20691 +#define SPELL_FEAR 29321 +#define SPELL_WHIRLWIND 24236 +#define SPELL_MORTAL_STRIKE 24573 +#define SPELL_ENRAGE 23537 +#define SPELL_WATCH 24314 +#define SPELL_LEVEL_UP 24312 + +//Ohgans Spells +#define SPELL_SUNDERARMOR 24317 + +#define SAY_AGGRO "I'll feed your souls to Hakkar himself!" +#define SOUND_AGGRO 8413 + +#define SAY_WATCH "I'm keeping my eye on you, $N!" +#define SAY_KILL "DING!" + +struct MANGOS_DLL_DECL boss_mandokirAI : public ScriptedAI +{ + boss_mandokirAI(Creature *c) : ScriptedAI(c) + { + pInstance = ((ScriptedInstance*)c->GetInstanceData()); + Reset(); + } + + uint32 Watch_Timer; + uint32 TargetInRange; + uint32 Cleave_Timer; + uint32 Whirlwind_Timer; + uint32 Fear_Timer; + uint32 MortalStrike_Timer; + uint32 Check_Timer; + float targetX; + float targetY; + float targetZ; + + ScriptedInstance *pInstance; + + bool endWatch; + bool someWatched; + bool RaptorDead; + bool CombatStart; + + uint64 WatchTarget; + + void Reset() + { + Watch_Timer = 33000; + Cleave_Timer = 7000; + Whirlwind_Timer = 20000; + Fear_Timer = 1000; + MortalStrike_Timer = 1000; + Check_Timer = 1000; + + targetX = 0.0; + targetY = 0.0; + targetZ = 0.0; + TargetInRange = 0; + + WatchTarget = 0; + + someWatched = false; + endWatch = false; + RaptorDead = false; + CombatStart = false; + + DoCast(m_creature, 23243); + } + + void KilledUnit(Unit* victim) + { + if(victim->GetTypeId() == TYPEID_PLAYER) + { + DoYell(SAY_KILL, LANG_UNIVERSAL, NULL); + DoCast(m_creature, SPELL_LEVEL_UP, true); + } + } + + void Aggro(Unit *who) {} + + void UpdateAI(const uint32 diff) + { + if (!m_creature->SelectHostilTarget()) + return; + + if( m_creature->getVictim() && m_creature->isAlive()) + { + if(!CombatStart) + { + //At combat Start Mandokir is mounted so we must unmount it first + m_creature->Unmount(); + + //And summon his raptor + m_creature->SummonCreature(14988, m_creature->getVictim()->GetPositionX(), m_creature->getVictim()->GetPositionY(), m_creature->getVictim()->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 35000); + CombatStart = true; + } + + if (Watch_Timer < diff) //Every 20 Sec Mandokir will check this + { + if(WatchTarget) //If someone is watched and If the Position of the watched target is different from the one stored, or are attacking, mandokir will charge him + { + Unit* pUnit = Unit::GetUnit(*m_creature, WatchTarget); + + if( pUnit && ( + targetX != pUnit->GetPositionX() || + targetY != pUnit->GetPositionY() || + targetZ != pUnit->GetPositionZ() || + pUnit->isInCombat())) + { + if(m_creature->IsWithinDistInMap(pUnit, ATTACK_DISTANCE)) + { + DoCast(pUnit,24316); + } + else + { + DoCast(pUnit,SPELL_CHARGE); + m_creature->SendMonsterMove(pUnit->GetPositionX(), pUnit->GetPositionY(), pUnit->GetPositionZ(), 0, true,1); + DoStartAttackAndMovement(pUnit); + } + } + } + someWatched = false; + Watch_Timer = 20000; + }else Watch_Timer -= diff; + + if ((Watch_Timer < 8000) && !someWatched) //8 sec(cast time + expire time) before the check for the watch effect mandokir will cast watch debuff on a random target + { + Unit* p = SelectUnit(SELECT_TARGET_RANDOM,0); + if(p) + { + DoYell(SAY_WATCH, LANG_UNIVERSAL, p); + DoCast(p, SPELL_WATCH); + WatchTarget = p->GetGUID(); + someWatched = true; + endWatch = true; + } + } + + if ((Watch_Timer < 1000) && endWatch) //1 sec before the debuf expire, store the target position + { + Unit* pUnit = Unit::GetUnit(*m_creature, WatchTarget); + if (pUnit) + { + targetX = pUnit->GetPositionX(); + targetY = pUnit->GetPositionY(); + targetZ = pUnit->GetPositionZ(); + } + endWatch = false; + } + + if(!someWatched) + { + //Cleave + if (Cleave_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_CLEAVE); + Cleave_Timer = 7000; + }else Cleave_Timer -= diff; + + //Whirlwind + if (Whirlwind_Timer < diff) + { + DoCast(m_creature,SPELL_WHIRLWIND); + Whirlwind_Timer = 18000; + }else Whirlwind_Timer -= diff; + + //If more then 3 targets in melee range mandokir will cast fear + if (Fear_Timer < diff) + { + TargetInRange = 0; + + std::list::iterator i = m_creature->getThreatManager().getThreatList().begin(); + for(; i != m_creature->getThreatManager().getThreatList().end(); ++i) + { + Unit* pUnit = Unit::GetUnit(*m_creature, (*i)->getUnitGuid()); + if(pUnit && m_creature->IsWithinDistInMap(pUnit, ATTACK_DISTANCE)) + TargetInRange++; + } + + if(TargetInRange > 3) + DoCast(m_creature->getVictim(),SPELL_FEAR); + + Fear_Timer = 4000; + }else Fear_Timer -=diff; + + //Mortal Strike if target below 50% hp + if (m_creature->getVictim()->GetHealth() < m_creature->getVictim()->GetMaxHealth()*0.5) + { + if (MortalStrike_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_MORTAL_STRIKE); + MortalStrike_Timer = 15000; + }else MortalStrike_Timer -= diff; + } + } + //Checking if Ohgan is dead. If yes Mandokir will enrage. + if(Check_Timer < diff) + { + if(pInstance) + { + if(pInstance->GetData(DATA_OHGANISDEAD)) + { + if (!RaptorDead) + { + DoCast(m_creature, SPELL_ENRAGE); + RaptorDead = true; + } + } + } + + Check_Timer = 1000; + }else Check_Timer -= diff; + + DoMeleeAttackIfReady(); + } + } +}; + +//Ohgan +struct MANGOS_DLL_DECL mob_ohganAI : public ScriptedAI +{ + mob_ohganAI(Creature *c) : ScriptedAI(c) + { + pInstance = ((ScriptedInstance*)c->GetInstanceData()); + Reset(); + } + + uint32 SunderArmor_Timer; + ScriptedInstance *pInstance; + + void Reset() + { + SunderArmor_Timer = 5000; + } + + void Aggro(Unit *who) {} + + void JustDied(Unit* Killer) + { + if(pInstance) + pInstance->SetData(DATA_OHGAN_DEATH, 0); + } + + void UpdateAI (const uint32 diff) + { + //Return since we have no target + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + //SunderArmor_Timer + if(SunderArmor_Timer < diff) + { + DoCast(m_creature->getVictim(), SPELL_SUNDERARMOR); + SunderArmor_Timer = 10000 + rand()%5000; + }else SunderArmor_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; + +CreatureAI* GetAI_boss_mandokir(Creature *_Creature) +{ + return new boss_mandokirAI (_Creature); +} + +CreatureAI* GetAI_mob_ohgan(Creature *_Creature) +{ + return new mob_ohganAI (_Creature); +} + +void AddSC_boss_mandokir() +{ + Script *newscript; + + newscript = new Script; + newscript->Name="boss_mandokir"; + newscript->GetAI = GetAI_boss_mandokir; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="mob_ohgan"; + newscript->GetAI = GetAI_mob_ohgan; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/zulgurub/boss_marli.cpp b/src/bindings/scripts/scripts/zone/zulgurub/boss_marli.cpp index 44bfc0973e8..3849574db97 100644 --- a/src/bindings/scripts/scripts/zone/zulgurub/boss_marli.cpp +++ b/src/bindings/scripts/scripts/zone/zulgurub/boss_marli.cpp @@ -1,269 +1,251 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Marli -SD%Complete: 80 -SDComment: Charging healers and casters not working. Perhaps wrong Spell Timers. -SDCategory: Zul'Gurub -EndScriptData */ - -#include "precompiled.h" -#include "def_zulgurub.h" - -#define SPELL_CHARGE 22911 -#define SPELL_ASPECT_OF_MARLI 24686 // A stun spell -#define SPELL_ENVOLWINGWEB 24110 -#define SPELL_POISONVOLLEY 24099 -#define SPELL_SPIDER_FORM 24084 - -//The Spider Spells -#define SPELL_LEVELUP 24312 //Not right Spell. - -#define SAY_AGGRO "Draw me to your web mistress Shadra. Unleash your venom!" -#define SOUND_AGGRO 8418 - -#define SAY_DEATH "ShadraDeath - Bless you mortal for this release. Hakkar controls me no longer..." -#define SOUND_DEATH 8423 - -struct MANGOS_DLL_DECL boss_marliAI : public ScriptedAI -{ - boss_marliAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 SpawnStartSpiders_Timer; - uint32 PoisonVolley_Timer; - uint32 SpawnSpider_Timer; - uint32 Charge_Timer; - uint32 Aspect_Timer; - uint32 Transform_Timer; - uint32 TransformBack_Timer; - - Creature *Spider; - bool Spawned; - bool PhaseTwo; - - void Reset() - { - SpawnStartSpiders_Timer = 1000; - PoisonVolley_Timer = 15000; - SpawnSpider_Timer = 30000; - Charge_Timer = 1500; - Aspect_Timer = 12000; - Transform_Timer = 45000; - TransformBack_Timer = 25000; - - Spawned = false; - PhaseTwo = false; - - m_creature->ApplySpellImmune(0, IMMUNITY_STATE, SPELL_AURA_MOD_TAUNT, true); - m_creature->ApplySpellImmune(1, IMMUNITY_EFFECT,SPELL_EFFECT_ATTACK_ME, true); - } - - void Aggro(Unit *who) - { - DoYell(SAY_AGGRO,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_AGGRO); - } - - void JustDied(Unit* Killer) - { - DoYell(SAY_DEATH,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_DEATH); - ScriptedInstance *pInstance = (m_creature->GetInstanceData()) ? ((ScriptedInstance*)m_creature->GetInstanceData()) : NULL; - if(pInstance) - pInstance->SetData(DATA_MARLI_DEATH, 0); - } - - void UpdateAI(const uint32 diff) - { - if (!m_creature->SelectHostilTarget()) - return; - - if( m_creature->getVictim() && m_creature->isAlive()) - { - if (PoisonVolley_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_POISONVOLLEY); - PoisonVolley_Timer = 10000 + rand()%10000; - }else PoisonVolley_Timer -= diff; - - if (!PhaseTwo && Aspect_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_ASPECT_OF_MARLI); - Aspect_Timer = 13000 + rand()%5000; - }else Aspect_Timer -= diff; - - if (!Spawned && SpawnStartSpiders_Timer < diff) - { - Unit* target = NULL; - target = SelectUnit(SELECT_TARGET_RANDOM,0); - - Spider = m_creature->SummonCreature(15041,target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(),0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000); - if(target && Spider ) { Spider ->AI()->AttackStart(target); } - Spider = m_creature->SummonCreature(15041,target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(),0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000); - if(target && Spider ) { Spider ->AI()->AttackStart(target); } - Spider = m_creature->SummonCreature(15041,target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(),0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000); - if(target && Spider ) { Spider ->AI()->AttackStart(target); } - Spider = m_creature->SummonCreature(15041,target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(),0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000); - if(target && Spider ) { Spider ->AI()->AttackStart(target); } - - Spawned = true; - }else SpawnStartSpiders_Timer -= diff; - - if (SpawnSpider_Timer < diff) - { - Unit* target = NULL; - target = SelectUnit(SELECT_TARGET_RANDOM,0); - - Spider = m_creature->SummonCreature(15041,target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(),0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000); - if(target && Spider ) { Spider ->AI()->AttackStart(target); } - - SpawnSpider_Timer = 12000 + rand()%5000; - }else SpawnSpider_Timer -= diff; - - if(!PhaseTwo && Transform_Timer < diff) - { - DoCast(m_creature,SPELL_SPIDER_FORM); - const CreatureInfo *cinfo = m_creature->GetCreatureInfo(); - m_creature->SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, (cinfo->mindmg +((cinfo->mindmg/100) * 35))); - m_creature->SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, (cinfo->maxdmg +((cinfo->maxdmg/100) * 35))); - m_creature->UpdateDamagePhysical(BASE_ATTACK); - DoCast(m_creature->getVictim(),SPELL_ENVOLWINGWEB); - - if(m_creature->getThreatManager().getThreat(m_creature->getVictim())) - m_creature->getThreatManager().modifyThreatPercent(m_creature->getVictim(),-100); - - PhaseTwo = true; - Transform_Timer = 35000 + rand()%25000; - }else Transform_Timer -= diff; - - if (PhaseTwo) - { - if (Charge_Timer < diff) - { - Unit* target = NULL; - int i = 0 ; - while (i < 3) // max 3 tries to get a random target with power_mana - { - ++i; //not aggro leader - target = SelectUnit(SELECT_TARGET_RANDOM,1); - if (target) - if (target->getPowerType() == POWER_MANA) - i=3; - } - if (target) - DoCast(target, SPELL_CHARGE); - // m_creature->Relocate(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0); - // m_creature->SendMonsterMove(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0, true,1); - DoStartAttackAndMovement(target); - - Charge_Timer = 8000; - }else Charge_Timer -= diff; - - if (TransformBack_Timer < diff) - { - m_creature->SetUInt32Value(UNIT_FIELD_DISPLAYID,15220); - const CreatureInfo *cinfo = m_creature->GetCreatureInfo(); - m_creature->SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, (cinfo->mindmg +((cinfo->mindmg/100) * 1))); - m_creature->SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, (cinfo->maxdmg +((cinfo->maxdmg/100) * 1))); - m_creature->UpdateDamagePhysical(BASE_ATTACK); - - PhaseTwo = false; - TransformBack_Timer = 25000 + rand()%15000; - }else TransformBack_Timer -= diff; - - } - - DoMeleeAttackIfReady(); - } - } -}; - -//Spawn of Marli -struct MANGOS_DLL_DECL mob_spawn_of_marliAI : public ScriptedAI -{ - mob_spawn_of_marliAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 LevelUp_Timer; - - void Reset() - { - LevelUp_Timer = 3000; - } - - void Aggro(Unit *who) - { - } - - void MoveInLineOfSight(Unit *who) - { - if (!who || m_creature->getVictim()) - return; - - if (who->isTargetableForAttack() && who->isInAccessablePlaceFor(m_creature) && m_creature->IsHostileTo(who)) - { - float attackRadius = m_creature->GetAttackDistance(who); - if (m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->GetDistanceZ(who) <= CREATURE_Z_ATTACK_RANGE && m_creature->IsWithinLOSInMap(who)) - { - if(who->HasStealthAura()) - who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); - - DoStartAttackAndMovement(who); - } - } - } - - void UpdateAI (const uint32 diff) - { - //Return since we have no target - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - //LevelUp_Timer - if(LevelUp_Timer < diff) - { - DoCast(m_creature,SPELL_LEVELUP); - LevelUp_Timer = 3000; - }else LevelUp_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; - -CreatureAI* GetAI_boss_marli(Creature *_Creature) -{ - return new boss_marliAI (_Creature); -} - -CreatureAI* GetAI_mob_spawn_of_marli(Creature *_Creature) -{ - return new mob_spawn_of_marliAI (_Creature); -} - -void AddSC_boss_marli() -{ - Script *newscript; - - newscript = new Script; - newscript->Name="boss_marli"; - newscript->GetAI = GetAI_boss_marli; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="mob_spawn_of_marli"; - newscript->GetAI = GetAI_mob_spawn_of_marli; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Marli +SD%Complete: 80 +SDComment: Charging healers and casters not working. Perhaps wrong Spell Timers. +SDCategory: Zul'Gurub +EndScriptData */ + +#include "precompiled.h" +#include "def_zulgurub.h" + +#define SPELL_CHARGE 22911 +#define SPELL_ASPECT_OF_MARLI 24686 // A stun spell +#define SPELL_ENVOLWINGWEB 24110 +#define SPELL_POISONVOLLEY 24099 +#define SPELL_SPIDER_FORM 24084 + +//The Spider Spells +#define SPELL_LEVELUP 24312 //Not right Spell. + +#define SAY_AGGRO "Draw me to your web mistress Shadra. Unleash your venom!" +#define SOUND_AGGRO 8418 + +#define SAY_DEATH "ShadraDeath - Bless you mortal for this release. Hakkar controls me no longer..." +#define SOUND_DEATH 8423 + +struct MANGOS_DLL_DECL boss_marliAI : public ScriptedAI +{ + boss_marliAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 SpawnStartSpiders_Timer; + uint32 PoisonVolley_Timer; + uint32 SpawnSpider_Timer; + uint32 Charge_Timer; + uint32 Aspect_Timer; + uint32 Transform_Timer; + uint32 TransformBack_Timer; + + Creature *Spider; + bool Spawned; + bool PhaseTwo; + + void Reset() + { + SpawnStartSpiders_Timer = 1000; + PoisonVolley_Timer = 15000; + SpawnSpider_Timer = 30000; + Charge_Timer = 1500; + Aspect_Timer = 12000; + Transform_Timer = 45000; + TransformBack_Timer = 25000; + + Spawned = false; + PhaseTwo = false; + + m_creature->ApplySpellImmune(0, IMMUNITY_STATE, SPELL_AURA_MOD_TAUNT, true); + m_creature->ApplySpellImmune(1, IMMUNITY_EFFECT,SPELL_EFFECT_ATTACK_ME, true); + } + + void Aggro(Unit *who) + { + DoYell(SAY_AGGRO,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_AGGRO); + } + + void JustDied(Unit* Killer) + { + DoYell(SAY_DEATH,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_DEATH); + ScriptedInstance *pInstance = (m_creature->GetInstanceData()) ? ((ScriptedInstance*)m_creature->GetInstanceData()) : NULL; + if(pInstance) + pInstance->SetData(DATA_MARLI_DEATH, 0); + } + + void UpdateAI(const uint32 diff) + { + if (!m_creature->SelectHostilTarget()) + return; + + if( m_creature->getVictim() && m_creature->isAlive()) + { + if (PoisonVolley_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_POISONVOLLEY); + PoisonVolley_Timer = 10000 + rand()%10000; + }else PoisonVolley_Timer -= diff; + + if (!PhaseTwo && Aspect_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_ASPECT_OF_MARLI); + Aspect_Timer = 13000 + rand()%5000; + }else Aspect_Timer -= diff; + + if (!Spawned && SpawnStartSpiders_Timer < diff) + { + Unit* target = NULL; + target = SelectUnit(SELECT_TARGET_RANDOM,0); + + Spider = m_creature->SummonCreature(15041,target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(),0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000); + if(target && Spider ) { Spider ->AI()->AttackStart(target); } + Spider = m_creature->SummonCreature(15041,target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(),0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000); + if(target && Spider ) { Spider ->AI()->AttackStart(target); } + Spider = m_creature->SummonCreature(15041,target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(),0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000); + if(target && Spider ) { Spider ->AI()->AttackStart(target); } + Spider = m_creature->SummonCreature(15041,target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(),0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000); + if(target && Spider ) { Spider ->AI()->AttackStart(target); } + + Spawned = true; + }else SpawnStartSpiders_Timer -= diff; + + if (SpawnSpider_Timer < diff) + { + Unit* target = NULL; + target = SelectUnit(SELECT_TARGET_RANDOM,0); + + Spider = m_creature->SummonCreature(15041,target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(),0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000); + if(target && Spider ) { Spider ->AI()->AttackStart(target); } + + SpawnSpider_Timer = 12000 + rand()%5000; + }else SpawnSpider_Timer -= diff; + + if(!PhaseTwo && Transform_Timer < diff) + { + DoCast(m_creature,SPELL_SPIDER_FORM); + const CreatureInfo *cinfo = m_creature->GetCreatureInfo(); + m_creature->SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, (cinfo->mindmg +((cinfo->mindmg/100) * 35))); + m_creature->SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, (cinfo->maxdmg +((cinfo->maxdmg/100) * 35))); + m_creature->UpdateDamagePhysical(BASE_ATTACK); + DoCast(m_creature->getVictim(),SPELL_ENVOLWINGWEB); + + if(m_creature->getThreatManager().getThreat(m_creature->getVictim())) + m_creature->getThreatManager().modifyThreatPercent(m_creature->getVictim(),-100); + + PhaseTwo = true; + Transform_Timer = 35000 + rand()%25000; + }else Transform_Timer -= diff; + + if (PhaseTwo) + { + if (Charge_Timer < diff) + { + Unit* target = NULL; + int i = 0 ; + while (i < 3) // max 3 tries to get a random target with power_mana + { + ++i; //not aggro leader + target = SelectUnit(SELECT_TARGET_RANDOM,1); + if (target) + if (target->getPowerType() == POWER_MANA) + i=3; + } + if (target) + DoCast(target, SPELL_CHARGE); + // m_creature->Relocate(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0); + // m_creature->SendMonsterMove(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0, true,1); + DoStartAttackAndMovement(target); + + Charge_Timer = 8000; + }else Charge_Timer -= diff; + + if (TransformBack_Timer < diff) + { + m_creature->SetUInt32Value(UNIT_FIELD_DISPLAYID,15220); + const CreatureInfo *cinfo = m_creature->GetCreatureInfo(); + m_creature->SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, (cinfo->mindmg +((cinfo->mindmg/100) * 1))); + m_creature->SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, (cinfo->maxdmg +((cinfo->maxdmg/100) * 1))); + m_creature->UpdateDamagePhysical(BASE_ATTACK); + + PhaseTwo = false; + TransformBack_Timer = 25000 + rand()%15000; + }else TransformBack_Timer -= diff; + + } + + DoMeleeAttackIfReady(); + } + } +}; + +//Spawn of Marli +struct MANGOS_DLL_DECL mob_spawn_of_marliAI : public ScriptedAI +{ + mob_spawn_of_marliAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 LevelUp_Timer; + + void Reset() + { + LevelUp_Timer = 3000; + } + + void Aggro(Unit *who) + { + } + + void UpdateAI (const uint32 diff) + { + //Return since we have no target + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + //LevelUp_Timer + if(LevelUp_Timer < diff) + { + DoCast(m_creature,SPELL_LEVELUP); + LevelUp_Timer = 3000; + }else LevelUp_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; + +CreatureAI* GetAI_boss_marli(Creature *_Creature) +{ + return new boss_marliAI (_Creature); +} + +CreatureAI* GetAI_mob_spawn_of_marli(Creature *_Creature) +{ + return new mob_spawn_of_marliAI (_Creature); +} + +void AddSC_boss_marli() +{ + Script *newscript; + + newscript = new Script; + newscript->Name="boss_marli"; + newscript->GetAI = GetAI_boss_marli; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="mob_spawn_of_marli"; + newscript->GetAI = GetAI_mob_spawn_of_marli; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/zulgurub/boss_renataki.cpp b/src/bindings/scripts/scripts/zone/zulgurub/boss_renataki.cpp index f7e31309b59..b44564825ca 100644 --- a/src/bindings/scripts/scripts/zone/zulgurub/boss_renataki.cpp +++ b/src/bindings/scripts/scripts/zone/zulgurub/boss_renataki.cpp @@ -1,151 +1,151 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Renataki -SD%Complete: 100 -SDComment: -SDCategory: Zul'Gurub -EndScriptData */ - -#include "precompiled.h" -#include "def_zulgurub.h" - -#define SPELL_AMBUSH 24337 -#define SPELL_THOUSANDBLADES 24649 - -struct MANGOS_DLL_DECL boss_renatakiAI : public ScriptedAI -{ - boss_renatakiAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 Invisible_Timer; - uint32 Ambush_Timer; - uint32 Visible_Timer; - uint32 Aggro_Timer; - uint32 ThousandBlades_Timer; - - bool Invisible; - bool Ambushed; - - void Reset() - { - Invisible_Timer = 8000 + rand()%10000; - Ambush_Timer = 3000; - Visible_Timer = 4000; - Aggro_Timer = 15000 + rand()%10000; - ThousandBlades_Timer = 4000 + rand()%4000; - - Invisible = false; - Ambushed = false; - } - - void Aggro(Unit *who) - { - } - - void UpdateAI(const uint32 diff) - { - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - //Invisible_Timer - if (Invisible_Timer < diff) - { - m_creature->InterruptSpell(CURRENT_GENERIC_SPELL); - m_creature->SetUInt32Value( UNIT_VIRTUAL_ITEM_SLOT_DISPLAY, 0); - m_creature->SetUInt32Value( UNIT_VIRTUAL_ITEM_INFO , 218171138); - m_creature->SetUInt32Value( UNIT_VIRTUAL_ITEM_INFO + 1, 3); - m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - m_creature->SetUInt32Value(UNIT_FIELD_DISPLAYID,11686); - Invisible = true; - - Invisible_Timer = 15000 + rand()%15000; - }else Invisible_Timer -= diff; - - if (Invisible) - { - if (Ambush_Timer < diff) - { - Unit* target = NULL; - target = SelectUnit(SELECT_TARGET_RANDOM,0); - if (target) - { - m_creature->Relocate(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0); - m_creature->SendMonsterMove(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0, true,1); - DoCast(target,SPELL_AMBUSH); - } - - Ambushed = true; - Ambush_Timer = 3000; - }else Ambush_Timer -= diff; - } - - if (Ambushed) - { - if (Visible_Timer < diff) - { - m_creature->InterruptSpell(CURRENT_GENERIC_SPELL); - m_creature->SetUInt32Value(UNIT_FIELD_DISPLAYID,15268); - m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - m_creature->SetUInt32Value( UNIT_VIRTUAL_ITEM_SLOT_DISPLAY, 31818); - m_creature->SetUInt32Value( UNIT_VIRTUAL_ITEM_INFO , 218171138); - m_creature->SetUInt32Value( UNIT_VIRTUAL_ITEM_INFO + 1, 3); - m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - Invisible = false; - - Visible_Timer = 4000; - }else Visible_Timer -= diff; - } - - //Resetting some aggro so he attacks other gamers - if(!Invisible) - if (Aggro_Timer < diff) - { - Unit* target = NULL; - target = SelectUnit(SELECT_TARGET_RANDOM,1); - - if(m_creature->getThreatManager().getThreat(m_creature->getVictim())) - m_creature->getThreatManager().modifyThreatPercent(m_creature->getVictim(),-50); - - if (target) - DoStartAttackAndMovement(target); - - Aggro_Timer = 7000 + rand()%13000; - }else Aggro_Timer -= diff; - - if (!Invisible) - if(ThousandBlades_Timer < diff) - { - DoCast(m_creature->getVictim(), SPELL_THOUSANDBLADES); - ThousandBlades_Timer = 7000 + rand()%5000; - }else ThousandBlades_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; -CreatureAI* GetAI_boss_renataki(Creature *_Creature) -{ - return new boss_renatakiAI (_Creature); -} - -void AddSC_boss_renataki() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_renataki"; - newscript->GetAI = GetAI_boss_renataki; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Renataki +SD%Complete: 100 +SDComment: +SDCategory: Zul'Gurub +EndScriptData */ + +#include "precompiled.h" +#include "def_zulgurub.h" + +#define SPELL_AMBUSH 24337 +#define SPELL_THOUSANDBLADES 24649 + +struct MANGOS_DLL_DECL boss_renatakiAI : public ScriptedAI +{ + boss_renatakiAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 Invisible_Timer; + uint32 Ambush_Timer; + uint32 Visible_Timer; + uint32 Aggro_Timer; + uint32 ThousandBlades_Timer; + + bool Invisible; + bool Ambushed; + + void Reset() + { + Invisible_Timer = 8000 + rand()%10000; + Ambush_Timer = 3000; + Visible_Timer = 4000; + Aggro_Timer = 15000 + rand()%10000; + ThousandBlades_Timer = 4000 + rand()%4000; + + Invisible = false; + Ambushed = false; + } + + void Aggro(Unit *who) + { + } + + void UpdateAI(const uint32 diff) + { + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + //Invisible_Timer + if (Invisible_Timer < diff) + { + m_creature->InterruptSpell(CURRENT_GENERIC_SPELL); + m_creature->SetUInt32Value( UNIT_VIRTUAL_ITEM_SLOT_DISPLAY, 0); + m_creature->SetUInt32Value( UNIT_VIRTUAL_ITEM_INFO , 218171138); + m_creature->SetUInt32Value( UNIT_VIRTUAL_ITEM_INFO + 1, 3); + m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + m_creature->SetUInt32Value(UNIT_FIELD_DISPLAYID,11686); + Invisible = true; + + Invisible_Timer = 15000 + rand()%15000; + }else Invisible_Timer -= diff; + + if (Invisible) + { + if (Ambush_Timer < diff) + { + Unit* target = NULL; + target = SelectUnit(SELECT_TARGET_RANDOM,0); + if (target) + { + m_creature->Relocate(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0); + m_creature->SendMonsterMove(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0, true,1); + DoCast(target,SPELL_AMBUSH); + } + + Ambushed = true; + Ambush_Timer = 3000; + }else Ambush_Timer -= diff; + } + + if (Ambushed) + { + if (Visible_Timer < diff) + { + m_creature->InterruptSpell(CURRENT_GENERIC_SPELL); + m_creature->SetUInt32Value(UNIT_FIELD_DISPLAYID,15268); + m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + m_creature->SetUInt32Value( UNIT_VIRTUAL_ITEM_SLOT_DISPLAY, 31818); + m_creature->SetUInt32Value( UNIT_VIRTUAL_ITEM_INFO , 218171138); + m_creature->SetUInt32Value( UNIT_VIRTUAL_ITEM_INFO + 1, 3); + m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + Invisible = false; + + Visible_Timer = 4000; + }else Visible_Timer -= diff; + } + + //Resetting some aggro so he attacks other gamers + if(!Invisible) + if (Aggro_Timer < diff) + { + Unit* target = NULL; + target = SelectUnit(SELECT_TARGET_RANDOM,1); + + if(m_creature->getThreatManager().getThreat(m_creature->getVictim())) + m_creature->getThreatManager().modifyThreatPercent(m_creature->getVictim(),-50); + + if (target) + DoStartAttackAndMovement(target); + + Aggro_Timer = 7000 + rand()%13000; + }else Aggro_Timer -= diff; + + if (!Invisible) + if(ThousandBlades_Timer < diff) + { + DoCast(m_creature->getVictim(), SPELL_THOUSANDBLADES); + ThousandBlades_Timer = 7000 + rand()%5000; + }else ThousandBlades_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; +CreatureAI* GetAI_boss_renataki(Creature *_Creature) +{ + return new boss_renatakiAI (_Creature); +} + +void AddSC_boss_renataki() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_renataki"; + newscript->GetAI = GetAI_boss_renataki; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/zulgurub/boss_thekal.cpp b/src/bindings/scripts/scripts/zone/zulgurub/boss_thekal.cpp index 91d0d6a290c..e46b2d72782 100644 --- a/src/bindings/scripts/scripts/zone/zulgurub/boss_thekal.cpp +++ b/src/bindings/scripts/scripts/zone/zulgurub/boss_thekal.cpp @@ -1,545 +1,545 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Thekal -SD%Complete: 95 -SDComment: Almost finished. -SDCategory: Zul'Gurub -EndScriptData */ - -#include "precompiled.h" -#include "def_zulgurub.h" - -#define SPELL_MORTALCLEAVE 22859 -#define SPELL_SILENCE 23207 -#define SPELL_FRENZY 23342 -#define SPELL_FORCEPUNCH 24189 -#define SPELL_CHARGE 24408 -#define SPELL_ENRAGE 23537 -#define SPELL_SUMMONTIGERS 24183 -#define SPELL_TIGER_FORM 24169 -#define SPELL_RESURRECT 24173 //We will not use this spell. - -//Zealot Lor'Khan Spells -#define SPELL_SHIELD 25020 -#define SPELL_BLOODLUST 24185 -#define SPELL_GREATERHEAL 24208 -#define SPELL_DISARM 22691 - -//Zealot Lor'Khan Spells -#define SPELL_SWEEPINGSTRIKES 18765 -#define SPELL_SINISTERSTRIKE 15667 -#define SPELL_GOUGE 24698 -#define SPELL_KICK 15614 -#define SPELL_BLIND 21060 - -#define SAY_AGGRO "Shirvallah fill me with your rage!" -#define SOUND_AGGRO 8419 - -#define SAY_DEATH "Hakkar binds me no more. Peace at last." -#define SOUND_DEATH 8424 - -struct MANGOS_DLL_DECL boss_thekalAI : public ScriptedAI -{ - boss_thekalAI(Creature *c) : ScriptedAI(c) - { - pInstance = (c->GetInstanceData()) ? ((ScriptedInstance*)c->GetInstanceData()) : NULL; - Reset(); - } - - uint32 MortalCleave_Timer; - uint32 Silence_Timer; - uint32 Frenzy_Timer; - uint32 ForcePunch_Timer; - uint32 Charge_Timer; - uint32 Enrage_Timer; - uint32 SummonTigers_Timer; - uint32 Check_Timer; - uint32 Resurrect_Timer; - - ScriptedInstance *pInstance; - bool Enraged; - bool PhaseTwo; - bool WasDead; - - void Reset() - { - MortalCleave_Timer = 4000; - Silence_Timer = 9000; - Frenzy_Timer = 30000; - ForcePunch_Timer = 4000; - Charge_Timer = 12000; - Enrage_Timer = 32000; - SummonTigers_Timer = 25000; - Check_Timer = 10000; - Resurrect_Timer = 10000; - - Enraged = false; - PhaseTwo = false; - WasDead = false; - - if(pInstance) - pInstance->SetData(DATA_THEKAL_ALIVE, 0); - } - - void Aggro(Unit *who) - { - DoYell(SAY_AGGRO,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_AGGRO); - } - - void JustDied(Unit* Killer) - { - DoYell(SAY_DEATH,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_DEATH); - ScriptedInstance *pInstance = (m_creature->GetInstanceData()) ? ((ScriptedInstance*)m_creature->GetInstanceData()) : NULL; - if(pInstance) - pInstance->SetData(DATA_THEKAL_DEATH, 0); - } - - void UpdateAI(const uint32 diff) - { - if (!m_creature->SelectHostilTarget()) - return; - - if( m_creature->getVictim() && m_creature->isAlive()) - { - - //Check_Timer for the death of LorKhan and Zath. - if(!WasDead && Check_Timer < diff) - { - if(pInstance) - { - if(pInstance->GetData(DATA_LORKHANISDEAD)) - { - //Resurrect LorKhan - Unit *pLorKhan = Unit::GetUnit((*m_creature), pInstance->GetData64(DATA_LORKHAN)); - pLorKhan->SetUInt32Value(UNIT_FIELD_BYTES_1, 0); - pLorKhan->setFaction(14); - pLorKhan->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - pLorKhan->SetHealth(int(pLorKhan->GetMaxHealth()*1.0)); - } - - if(pInstance->GetData(DATA_ZATHISDEAD)) - { - //Resurrect Zath - Unit *pZath = Unit::GetUnit((*m_creature), pInstance->GetData64(DATA_ZATH)); - pZath->SetUInt32Value(UNIT_FIELD_BYTES_1, 0); - pZath->setFaction(14); - pZath->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - pZath->SetHealth(int(pZath->GetMaxHealth()*1.0)); - } - } - - Check_Timer = 5000; - }else Check_Timer -= diff; - - if (!PhaseTwo && MortalCleave_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_MORTALCLEAVE); - MortalCleave_Timer = 15000 + rand()%5000; - }else MortalCleave_Timer -= diff; - - if (!PhaseTwo && Silence_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_SILENCE); - Silence_Timer = 20000 + rand()%5000; - }else Silence_Timer -= diff; - - if (!PhaseTwo && !WasDead && m_creature->GetHealth() <= m_creature->GetMaxHealth() * 0.05) - { - m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - m_creature->SetUInt32Value(UNIT_FIELD_BYTES_1, 3); - m_creature->AttackStop(); - - if(pInstance) - pInstance->SetData(DATA_THEKALFAKE_DEATH, 0); - - WasDead=true; - } - - //Thekal will transform to Tiger if he died and was not resurrected after 10 seconds. - if(!PhaseTwo && WasDead) - { - if (Resurrect_Timer < diff) - { - DoCast(m_creature,SPELL_TIGER_FORM); - m_creature->SetFloatValue(OBJECT_FIELD_SCALE_X, 2.00f); - m_creature->SetUInt32Value(UNIT_FIELD_BYTES_1, 0); - m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - m_creature->SetHealth(int(m_creature->GetMaxHealth()*1.0)); - const CreatureInfo *cinfo = m_creature->GetCreatureInfo(); - m_creature->SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, (cinfo->mindmg +((cinfo->mindmg/100) * 40))); - m_creature->SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, (cinfo->maxdmg +((cinfo->maxdmg/100) * 40))); - m_creature->UpdateDamagePhysical(BASE_ATTACK); - DoResetThreat(); - PhaseTwo = true; - }else Resurrect_Timer -= diff; - } - - if ((m_creature->GetHealth()*100 / m_creature->GetMaxHealth() == 100) && WasDead) - { - WasDead = false; - } - - if (PhaseTwo) - { - if (Charge_Timer < diff) - { - Unit* target = NULL; - target = SelectUnit(SELECT_TARGET_RANDOM,0); - - DoCast(target,SPELL_CHARGE); - m_creature->SendMonsterMove(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0, true,1); - DoStartAttackAndMovement(target); - DoResetThreat(); - - Charge_Timer = 15000 + rand()%7000; - }else Charge_Timer -= diff; - - if (Frenzy_Timer < diff) - { - DoCast(m_creature,SPELL_FRENZY); - Frenzy_Timer = 30000; - }else Frenzy_Timer -= diff; - - if (ForcePunch_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_SILENCE); - ForcePunch_Timer = 16000 + rand()%5000; - }else ForcePunch_Timer -= diff; - - if (SummonTigers_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_SUMMONTIGERS); - SummonTigers_Timer = 10000 + rand()%4000; - }else SummonTigers_Timer -= diff; - - if ((m_creature->GetHealth()*100 / m_creature->GetMaxHealth() < 11) && !Enraged) - { - DoCast(m_creature, SPELL_ENRAGE); - Enraged = true; - } - } - - DoMeleeAttackIfReady(); - } - } -}; - -//Zealot Lor'Khan -struct MANGOS_DLL_DECL mob_zealot_lorkhanAI : public ScriptedAI -{ - mob_zealot_lorkhanAI(Creature *c) : ScriptedAI(c) - { - pInstance = (c->GetInstanceData()) ? ((ScriptedInstance*)c->GetInstanceData()) : NULL; - Reset(); - } - - uint32 Shield_Timer; - uint32 BloodLust_Timer; - uint32 GreaterHeal_Timer; - uint32 Disarm_Timer; - uint32 Check_Timer; - - bool FakeDeath; - - ScriptedInstance *pInstance; - - void Reset() - { - Shield_Timer = 1000; - BloodLust_Timer = 16000; - GreaterHeal_Timer = 32000; - Disarm_Timer = 6000; - Check_Timer = 10000; - - FakeDeath = false; - - if(pInstance) - pInstance->SetData(DATA_LORKHAN_ALIVE, 0); - - m_creature->SetUInt32Value(UNIT_FIELD_BYTES_1, 0); - m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - } - - void Aggro(Unit *who) - { - } - - void UpdateAI (const uint32 diff) - { - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - //Shield_Timer - if(Shield_Timer < diff) - { - DoCast(m_creature,SPELL_SHIELD); - Shield_Timer = 61000; - }else Shield_Timer -= diff; - - //BloodLust_Timer - if(BloodLust_Timer < diff) - { - DoCast(m_creature,SPELL_BLOODLUST); - BloodLust_Timer = 20000+rand()%8000; - }else BloodLust_Timer -= diff; - - //Casting Greaterheal to Thekal or Zath if they are in meele range. - if(GreaterHeal_Timer < diff) - { - if(pInstance) - { - Unit *pThekal = Unit::GetUnit((*m_creature), pInstance->GetData64(DATA_THEKAL)); - Unit *pZath = Unit::GetUnit((*m_creature), pInstance->GetData64(DATA_ZATH)); - - switch(rand()%2) - { - case 0: - if(m_creature->IsWithinDistInMap(pThekal, ATTACK_DISTANCE)) - DoCast(pThekal, SPELL_GREATERHEAL); - break; - case 1: - if(m_creature->IsWithinDistInMap(pZath, ATTACK_DISTANCE)) - DoCast(pZath, SPELL_GREATERHEAL); - break; - } - } - - GreaterHeal_Timer = 15000+rand()%5000; - }else GreaterHeal_Timer -= diff; - - //Disarm_Timer - if(Disarm_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_DISARM); - Disarm_Timer = 15000+rand()%10000; - }else Disarm_Timer -= diff; - - //Check_Timer for the death of LorKhan and Zath. - if(!FakeDeath && Check_Timer < diff) - { - if(pInstance) - { - if(pInstance->GetData(DATA_THEKALISFAKEDEAD)) - { - //Resurrect Thekal - Unit *pThekal = Unit::GetUnit((*m_creature), pInstance->GetData64(DATA_THEKAL)); - pThekal->SetUInt32Value(UNIT_FIELD_BYTES_1, 0); - pThekal->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - pThekal->setFaction(14); - pThekal->SetHealth(int(pThekal->GetMaxHealth()*1.0)); - } - - if(pInstance->GetData(DATA_ZATHISDEAD)) - { - //Resurrect Zath - Unit *pZath = Unit::GetUnit((*m_creature), pInstance->GetData64(DATA_ZATH)); - pZath->SetUInt32Value(UNIT_FIELD_BYTES_1, 0); - pZath->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - pZath->setFaction(14); - pZath->SetHealth(int(pZath->GetMaxHealth()*1.0)); - } - } - - Check_Timer = 5000; - }else Check_Timer -= diff; - - if (m_creature->GetHealth() <= m_creature->GetMaxHealth() * 0.05) - { - m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - m_creature->SetUInt32Value(UNIT_FIELD_BYTES_1, 3); - m_creature->setFaction(35); - m_creature->AttackStop(); - - if(pInstance) - pInstance->SetData(DATA_LORKHAN_DEATH, 0); - - FakeDeath = true; - } - - DoMeleeAttackIfReady(); - } -}; - -//Zealot Zath -struct MANGOS_DLL_DECL mob_zealot_zathAI : public ScriptedAI -{ - mob_zealot_zathAI(Creature *c) : ScriptedAI(c) - { - pInstance = (c->GetInstanceData()) ? ((ScriptedInstance*)c->GetInstanceData()) : NULL; - Reset(); - } - - uint32 SweepingStrikes_Timer; - uint32 SinisterStrike_Timer; - uint32 Gouge_Timer; - uint32 Kick_Timer; - uint32 Blind_Timer; - uint32 Check_Timer; - - bool FakeDeath; - - ScriptedInstance *pInstance; - - void Reset() - { - SweepingStrikes_Timer = 13000; - SinisterStrike_Timer = 8000; - Gouge_Timer = 25000; - Kick_Timer = 18000; - Blind_Timer = 5000; - Check_Timer = 10000; - - FakeDeath = false; - - if(pInstance) - pInstance->SetData(DATA_ZATH_ALIVE, 0); - - m_creature->SetUInt32Value(UNIT_FIELD_BYTES_1, 0); - m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - } - - void Aggro(Unit *who) - { - } - - void UpdateAI (const uint32 diff) - { - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) - return; - - //SweepingStrikes_Timer - if(SweepingStrikes_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_SWEEPINGSTRIKES); - SweepingStrikes_Timer = 22000+rand()%4000; - }else SweepingStrikes_Timer -= diff; - - //SinisterStrike_Timer - if(SinisterStrike_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_SINISTERSTRIKE); - SinisterStrike_Timer = 8000+rand()%8000; - }else SinisterStrike_Timer -= diff; - - //Gouge_Timer - if(Gouge_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_GOUGE); - - if(m_creature->getThreatManager().getThreat(m_creature->getVictim())) - m_creature->getThreatManager().modifyThreatPercent(m_creature->getVictim(),-100); - - Gouge_Timer = 17000+rand()%10000; - }else Gouge_Timer -= diff; - - //Kick_Timer - if(Kick_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_KICK); - Kick_Timer = 15000+rand()%10000; - }else Kick_Timer -= diff; - - //Blind_Timer - if(Blind_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_BLIND); - Blind_Timer = 10000+rand()%10000; - }else Blind_Timer -= diff; - - //Check_Timer for the death of LorKhan and Zath. - if(!FakeDeath && Check_Timer < diff) - { - if(pInstance) - { - if(pInstance->GetData(DATA_LORKHANISDEAD)) - { - //Resurrect LorKhan - Unit *pLorKhan = Unit::GetUnit((*m_creature), pInstance->GetData64(DATA_LORKHAN)); - pLorKhan->SetUInt32Value(UNIT_FIELD_BYTES_1, 0); - pLorKhan->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - pLorKhan->setFaction(14); - pLorKhan->SetHealth(int(pLorKhan->GetMaxHealth()*1.0)); - } - - if(pInstance->GetData(DATA_THEKALISFAKEDEAD)) - { - //Resurrect Thekal - Unit *pThekal = Unit::GetUnit((*m_creature), pInstance->GetData64(DATA_THEKAL)); - pThekal->SetUInt32Value(UNIT_FIELD_BYTES_1, 0); - pThekal->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - pThekal->setFaction(14); - pThekal->SetHealth(int(pThekal->GetMaxHealth()*1.0)); - } - } - - Check_Timer = 5000; - }else Check_Timer -= diff; - - if (m_creature->GetHealth() <= m_creature->GetMaxHealth() * 0.05) - { - m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - m_creature->SetUInt32Value(UNIT_FIELD_BYTES_1, 3); - m_creature->setFaction(35); - m_creature->AttackStop(); - - if(pInstance) - pInstance->SetData(DATA_ZATH_DEATH, 0); - - FakeDeath = true; - } - - DoMeleeAttackIfReady(); - } -}; - -CreatureAI* GetAI_boss_thekal(Creature *_Creature) -{ - return new boss_thekalAI (_Creature); -} - -CreatureAI* GetAI_mob_zealot_lorkhan(Creature *_Creature) -{ - return new mob_zealot_lorkhanAI (_Creature); -} - -CreatureAI* GetAI_mob_zealot_zath(Creature *_Creature) -{ - return new mob_zealot_zathAI (_Creature); -} - -void AddSC_boss_thekal() -{ - Script *newscript; - - newscript = new Script; - newscript->Name="boss_thekal"; - newscript->GetAI = GetAI_boss_thekal; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="mob_zealot_lorkhan"; - newscript->GetAI = GetAI_mob_zealot_lorkhan; - m_scripts[nrscripts++] = newscript; - - newscript = new Script; - newscript->Name="mob_zealot_zath"; - newscript->GetAI = GetAI_mob_zealot_zath; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Thekal +SD%Complete: 95 +SDComment: Almost finished. +SDCategory: Zul'Gurub +EndScriptData */ + +#include "precompiled.h" +#include "def_zulgurub.h" + +#define SPELL_MORTALCLEAVE 22859 +#define SPELL_SILENCE 23207 +#define SPELL_FRENZY 23342 +#define SPELL_FORCEPUNCH 24189 +#define SPELL_CHARGE 24408 +#define SPELL_ENRAGE 23537 +#define SPELL_SUMMONTIGERS 24183 +#define SPELL_TIGER_FORM 24169 +#define SPELL_RESURRECT 24173 //We will not use this spell. + +//Zealot Lor'Khan Spells +#define SPELL_SHIELD 25020 +#define SPELL_BLOODLUST 24185 +#define SPELL_GREATERHEAL 24208 +#define SPELL_DISARM 22691 + +//Zealot Lor'Khan Spells +#define SPELL_SWEEPINGSTRIKES 18765 +#define SPELL_SINISTERSTRIKE 15667 +#define SPELL_GOUGE 24698 +#define SPELL_KICK 15614 +#define SPELL_BLIND 21060 + +#define SAY_AGGRO "Shirvallah fill me with your rage!" +#define SOUND_AGGRO 8419 + +#define SAY_DEATH "Hakkar binds me no more. Peace at last." +#define SOUND_DEATH 8424 + +struct MANGOS_DLL_DECL boss_thekalAI : public ScriptedAI +{ + boss_thekalAI(Creature *c) : ScriptedAI(c) + { + pInstance = (c->GetInstanceData()) ? ((ScriptedInstance*)c->GetInstanceData()) : NULL; + Reset(); + } + + uint32 MortalCleave_Timer; + uint32 Silence_Timer; + uint32 Frenzy_Timer; + uint32 ForcePunch_Timer; + uint32 Charge_Timer; + uint32 Enrage_Timer; + uint32 SummonTigers_Timer; + uint32 Check_Timer; + uint32 Resurrect_Timer; + + ScriptedInstance *pInstance; + bool Enraged; + bool PhaseTwo; + bool WasDead; + + void Reset() + { + MortalCleave_Timer = 4000; + Silence_Timer = 9000; + Frenzy_Timer = 30000; + ForcePunch_Timer = 4000; + Charge_Timer = 12000; + Enrage_Timer = 32000; + SummonTigers_Timer = 25000; + Check_Timer = 10000; + Resurrect_Timer = 10000; + + Enraged = false; + PhaseTwo = false; + WasDead = false; + + if(pInstance) + pInstance->SetData(DATA_THEKAL_ALIVE, 0); + } + + void Aggro(Unit *who) + { + DoYell(SAY_AGGRO,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_AGGRO); + } + + void JustDied(Unit* Killer) + { + DoYell(SAY_DEATH,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_DEATH); + ScriptedInstance *pInstance = (m_creature->GetInstanceData()) ? ((ScriptedInstance*)m_creature->GetInstanceData()) : NULL; + if(pInstance) + pInstance->SetData(DATA_THEKAL_DEATH, 0); + } + + void UpdateAI(const uint32 diff) + { + if (!m_creature->SelectHostilTarget()) + return; + + if( m_creature->getVictim() && m_creature->isAlive()) + { + + //Check_Timer for the death of LorKhan and Zath. + if(!WasDead && Check_Timer < diff) + { + if(pInstance) + { + if(pInstance->GetData(DATA_LORKHANISDEAD)) + { + //Resurrect LorKhan + Unit *pLorKhan = Unit::GetUnit((*m_creature), pInstance->GetData64(DATA_LORKHAN)); + pLorKhan->SetUInt32Value(UNIT_FIELD_BYTES_1, 0); + pLorKhan->setFaction(14); + pLorKhan->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + pLorKhan->SetHealth(int(pLorKhan->GetMaxHealth()*1.0)); + } + + if(pInstance->GetData(DATA_ZATHISDEAD)) + { + //Resurrect Zath + Unit *pZath = Unit::GetUnit((*m_creature), pInstance->GetData64(DATA_ZATH)); + pZath->SetUInt32Value(UNIT_FIELD_BYTES_1, 0); + pZath->setFaction(14); + pZath->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + pZath->SetHealth(int(pZath->GetMaxHealth()*1.0)); + } + } + + Check_Timer = 5000; + }else Check_Timer -= diff; + + if (!PhaseTwo && MortalCleave_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_MORTALCLEAVE); + MortalCleave_Timer = 15000 + rand()%5000; + }else MortalCleave_Timer -= diff; + + if (!PhaseTwo && Silence_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_SILENCE); + Silence_Timer = 20000 + rand()%5000; + }else Silence_Timer -= diff; + + if (!PhaseTwo && !WasDead && m_creature->GetHealth() <= m_creature->GetMaxHealth() * 0.05) + { + m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + m_creature->SetUInt32Value(UNIT_FIELD_BYTES_1, 3); + m_creature->AttackStop(); + + if(pInstance) + pInstance->SetData(DATA_THEKALFAKE_DEATH, 0); + + WasDead=true; + } + + //Thekal will transform to Tiger if he died and was not resurrected after 10 seconds. + if(!PhaseTwo && WasDead) + { + if (Resurrect_Timer < diff) + { + DoCast(m_creature,SPELL_TIGER_FORM); + m_creature->SetFloatValue(OBJECT_FIELD_SCALE_X, 2.00f); + m_creature->SetUInt32Value(UNIT_FIELD_BYTES_1, 0); + m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + m_creature->SetHealth(int(m_creature->GetMaxHealth()*1.0)); + const CreatureInfo *cinfo = m_creature->GetCreatureInfo(); + m_creature->SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, (cinfo->mindmg +((cinfo->mindmg/100) * 40))); + m_creature->SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, (cinfo->maxdmg +((cinfo->maxdmg/100) * 40))); + m_creature->UpdateDamagePhysical(BASE_ATTACK); + DoResetThreat(); + PhaseTwo = true; + }else Resurrect_Timer -= diff; + } + + if ((m_creature->GetHealth()*100 / m_creature->GetMaxHealth() == 100) && WasDead) + { + WasDead = false; + } + + if (PhaseTwo) + { + if (Charge_Timer < diff) + { + Unit* target = NULL; + target = SelectUnit(SELECT_TARGET_RANDOM,0); + + DoCast(target,SPELL_CHARGE); + m_creature->SendMonsterMove(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0, true,1); + DoStartAttackAndMovement(target); + DoResetThreat(); + + Charge_Timer = 15000 + rand()%7000; + }else Charge_Timer -= diff; + + if (Frenzy_Timer < diff) + { + DoCast(m_creature,SPELL_FRENZY); + Frenzy_Timer = 30000; + }else Frenzy_Timer -= diff; + + if (ForcePunch_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_SILENCE); + ForcePunch_Timer = 16000 + rand()%5000; + }else ForcePunch_Timer -= diff; + + if (SummonTigers_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_SUMMONTIGERS); + SummonTigers_Timer = 10000 + rand()%4000; + }else SummonTigers_Timer -= diff; + + if ((m_creature->GetHealth()*100 / m_creature->GetMaxHealth() < 11) && !Enraged) + { + DoCast(m_creature, SPELL_ENRAGE); + Enraged = true; + } + } + + DoMeleeAttackIfReady(); + } + } +}; + +//Zealot Lor'Khan +struct MANGOS_DLL_DECL mob_zealot_lorkhanAI : public ScriptedAI +{ + mob_zealot_lorkhanAI(Creature *c) : ScriptedAI(c) + { + pInstance = (c->GetInstanceData()) ? ((ScriptedInstance*)c->GetInstanceData()) : NULL; + Reset(); + } + + uint32 Shield_Timer; + uint32 BloodLust_Timer; + uint32 GreaterHeal_Timer; + uint32 Disarm_Timer; + uint32 Check_Timer; + + bool FakeDeath; + + ScriptedInstance *pInstance; + + void Reset() + { + Shield_Timer = 1000; + BloodLust_Timer = 16000; + GreaterHeal_Timer = 32000; + Disarm_Timer = 6000; + Check_Timer = 10000; + + FakeDeath = false; + + if(pInstance) + pInstance->SetData(DATA_LORKHAN_ALIVE, 0); + + m_creature->SetUInt32Value(UNIT_FIELD_BYTES_1, 0); + m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + } + + void Aggro(Unit *who) + { + } + + void UpdateAI (const uint32 diff) + { + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + //Shield_Timer + if(Shield_Timer < diff) + { + DoCast(m_creature,SPELL_SHIELD); + Shield_Timer = 61000; + }else Shield_Timer -= diff; + + //BloodLust_Timer + if(BloodLust_Timer < diff) + { + DoCast(m_creature,SPELL_BLOODLUST); + BloodLust_Timer = 20000+rand()%8000; + }else BloodLust_Timer -= diff; + + //Casting Greaterheal to Thekal or Zath if they are in meele range. + if(GreaterHeal_Timer < diff) + { + if(pInstance) + { + Unit *pThekal = Unit::GetUnit((*m_creature), pInstance->GetData64(DATA_THEKAL)); + Unit *pZath = Unit::GetUnit((*m_creature), pInstance->GetData64(DATA_ZATH)); + + switch(rand()%2) + { + case 0: + if(m_creature->IsWithinDistInMap(pThekal, ATTACK_DISTANCE)) + DoCast(pThekal, SPELL_GREATERHEAL); + break; + case 1: + if(m_creature->IsWithinDistInMap(pZath, ATTACK_DISTANCE)) + DoCast(pZath, SPELL_GREATERHEAL); + break; + } + } + + GreaterHeal_Timer = 15000+rand()%5000; + }else GreaterHeal_Timer -= diff; + + //Disarm_Timer + if(Disarm_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_DISARM); + Disarm_Timer = 15000+rand()%10000; + }else Disarm_Timer -= diff; + + //Check_Timer for the death of LorKhan and Zath. + if(!FakeDeath && Check_Timer < diff) + { + if(pInstance) + { + if(pInstance->GetData(DATA_THEKALISFAKEDEAD)) + { + //Resurrect Thekal + Unit *pThekal = Unit::GetUnit((*m_creature), pInstance->GetData64(DATA_THEKAL)); + pThekal->SetUInt32Value(UNIT_FIELD_BYTES_1, 0); + pThekal->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + pThekal->setFaction(14); + pThekal->SetHealth(int(pThekal->GetMaxHealth()*1.0)); + } + + if(pInstance->GetData(DATA_ZATHISDEAD)) + { + //Resurrect Zath + Unit *pZath = Unit::GetUnit((*m_creature), pInstance->GetData64(DATA_ZATH)); + pZath->SetUInt32Value(UNIT_FIELD_BYTES_1, 0); + pZath->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + pZath->setFaction(14); + pZath->SetHealth(int(pZath->GetMaxHealth()*1.0)); + } + } + + Check_Timer = 5000; + }else Check_Timer -= diff; + + if (m_creature->GetHealth() <= m_creature->GetMaxHealth() * 0.05) + { + m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + m_creature->SetUInt32Value(UNIT_FIELD_BYTES_1, 3); + m_creature->setFaction(35); + m_creature->AttackStop(); + + if(pInstance) + pInstance->SetData(DATA_LORKHAN_DEATH, 0); + + FakeDeath = true; + } + + DoMeleeAttackIfReady(); + } +}; + +//Zealot Zath +struct MANGOS_DLL_DECL mob_zealot_zathAI : public ScriptedAI +{ + mob_zealot_zathAI(Creature *c) : ScriptedAI(c) + { + pInstance = (c->GetInstanceData()) ? ((ScriptedInstance*)c->GetInstanceData()) : NULL; + Reset(); + } + + uint32 SweepingStrikes_Timer; + uint32 SinisterStrike_Timer; + uint32 Gouge_Timer; + uint32 Kick_Timer; + uint32 Blind_Timer; + uint32 Check_Timer; + + bool FakeDeath; + + ScriptedInstance *pInstance; + + void Reset() + { + SweepingStrikes_Timer = 13000; + SinisterStrike_Timer = 8000; + Gouge_Timer = 25000; + Kick_Timer = 18000; + Blind_Timer = 5000; + Check_Timer = 10000; + + FakeDeath = false; + + if(pInstance) + pInstance->SetData(DATA_ZATH_ALIVE, 0); + + m_creature->SetUInt32Value(UNIT_FIELD_BYTES_1, 0); + m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + } + + void Aggro(Unit *who) + { + } + + void UpdateAI (const uint32 diff) + { + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() ) + return; + + //SweepingStrikes_Timer + if(SweepingStrikes_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_SWEEPINGSTRIKES); + SweepingStrikes_Timer = 22000+rand()%4000; + }else SweepingStrikes_Timer -= diff; + + //SinisterStrike_Timer + if(SinisterStrike_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_SINISTERSTRIKE); + SinisterStrike_Timer = 8000+rand()%8000; + }else SinisterStrike_Timer -= diff; + + //Gouge_Timer + if(Gouge_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_GOUGE); + + if(m_creature->getThreatManager().getThreat(m_creature->getVictim())) + m_creature->getThreatManager().modifyThreatPercent(m_creature->getVictim(),-100); + + Gouge_Timer = 17000+rand()%10000; + }else Gouge_Timer -= diff; + + //Kick_Timer + if(Kick_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_KICK); + Kick_Timer = 15000+rand()%10000; + }else Kick_Timer -= diff; + + //Blind_Timer + if(Blind_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_BLIND); + Blind_Timer = 10000+rand()%10000; + }else Blind_Timer -= diff; + + //Check_Timer for the death of LorKhan and Zath. + if(!FakeDeath && Check_Timer < diff) + { + if(pInstance) + { + if(pInstance->GetData(DATA_LORKHANISDEAD)) + { + //Resurrect LorKhan + Unit *pLorKhan = Unit::GetUnit((*m_creature), pInstance->GetData64(DATA_LORKHAN)); + pLorKhan->SetUInt32Value(UNIT_FIELD_BYTES_1, 0); + pLorKhan->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + pLorKhan->setFaction(14); + pLorKhan->SetHealth(int(pLorKhan->GetMaxHealth()*1.0)); + } + + if(pInstance->GetData(DATA_THEKALISFAKEDEAD)) + { + //Resurrect Thekal + Unit *pThekal = Unit::GetUnit((*m_creature), pInstance->GetData64(DATA_THEKAL)); + pThekal->SetUInt32Value(UNIT_FIELD_BYTES_1, 0); + pThekal->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + pThekal->setFaction(14); + pThekal->SetHealth(int(pThekal->GetMaxHealth()*1.0)); + } + } + + Check_Timer = 5000; + }else Check_Timer -= diff; + + if (m_creature->GetHealth() <= m_creature->GetMaxHealth() * 0.05) + { + m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + m_creature->SetUInt32Value(UNIT_FIELD_BYTES_1, 3); + m_creature->setFaction(35); + m_creature->AttackStop(); + + if(pInstance) + pInstance->SetData(DATA_ZATH_DEATH, 0); + + FakeDeath = true; + } + + DoMeleeAttackIfReady(); + } +}; + +CreatureAI* GetAI_boss_thekal(Creature *_Creature) +{ + return new boss_thekalAI (_Creature); +} + +CreatureAI* GetAI_mob_zealot_lorkhan(Creature *_Creature) +{ + return new mob_zealot_lorkhanAI (_Creature); +} + +CreatureAI* GetAI_mob_zealot_zath(Creature *_Creature) +{ + return new mob_zealot_zathAI (_Creature); +} + +void AddSC_boss_thekal() +{ + Script *newscript; + + newscript = new Script; + newscript->Name="boss_thekal"; + newscript->GetAI = GetAI_boss_thekal; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="mob_zealot_lorkhan"; + newscript->GetAI = GetAI_mob_zealot_lorkhan; + m_scripts[nrscripts++] = newscript; + + newscript = new Script; + newscript->Name="mob_zealot_zath"; + newscript->GetAI = GetAI_mob_zealot_zath; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/zulgurub/boss_venoxis.cpp b/src/bindings/scripts/scripts/zone/zulgurub/boss_venoxis.cpp index a2405ec9c6f..345c05a88d4 100644 --- a/src/bindings/scripts/scripts/zone/zulgurub/boss_venoxis.cpp +++ b/src/bindings/scripts/scripts/zone/zulgurub/boss_venoxis.cpp @@ -1,200 +1,200 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Venoxis -SD%Complete: 100 -SDComment: -SDCategory: Zul'Gurub -EndScriptData */ - -#include "precompiled.h" -#include "def_zulgurub.h" - -#define SPELL_HOLY_FIRE 23860 -#define SPELL_HOLY_WRATH 28883 //Not sure if this or 23979 -#define SPELL_VENOMSPIT 23862 -#define SPELL_HOLY_NOVA 23858 -#define SPELL_POISON_CLOUD 23861 -#define SPELL_SNAKE_FORM 23849 -#define SPELL_RENEW 23895 -#define SPELL_BERSERK 23537 -#define SPELL_DISPELL 23859 - -#define SAY_AGGRO "Let the coils of hate unfurl!" -#define SOUND_AGGRO 8421 - -struct MANGOS_DLL_DECL boss_venoxisAI : public ScriptedAI -{ - boss_venoxisAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 HolyFire_Timer; - uint32 HolyWrath_Timer; - uint32 VenomSpit_Timer; - uint32 Renew_Timer; - uint32 PoisonCloud_Timer; - uint32 HolyNova_Timer; - uint32 Dispell_Timer; - uint32 TargetInRange; - - bool PhaseTwo; - bool InBerserk; - - void Reset() - { - HolyFire_Timer = 10000; - HolyWrath_Timer = 60500; - VenomSpit_Timer = 5500; - Renew_Timer = 30500; - PoisonCloud_Timer = 2000; - HolyNova_Timer = 5000; - Dispell_Timer = 35000; - TargetInRange = 0; - - PhaseTwo = false; - InBerserk= false; - } - - void Aggro(Unit *who) - { - DoYell(SAY_AGGRO,LANG_UNIVERSAL,NULL); - DoPlaySoundToSet(m_creature,SOUND_AGGRO); - } - - void JustDied(Unit* Killer) - { - ScriptedInstance *pInstance = (m_creature->GetInstanceData()) ? ((ScriptedInstance*)m_creature->GetInstanceData()) : NULL; - if(pInstance) - pInstance->SetData(DATA_VENOXIS_DEATH, 0); - } - - void UpdateAI(const uint32 diff) - { - if (!m_creature->SelectHostilTarget()) - return; - - if( m_creature->getVictim() && m_creature->isAlive()) - { - if ((m_creature->GetHealth()*100 / m_creature->GetMaxHealth() > 50)) - { - if (Dispell_Timer < diff) - { - DoCast(m_creature, SPELL_DISPELL); - Dispell_Timer = 15000 + rand()%15000; - }else Dispell_Timer -= diff; - - if (Renew_Timer < diff) - { - DoCast(m_creature, SPELL_RENEW); - Renew_Timer = 20000 + rand()%10000; - }else Renew_Timer -= diff; - - if (HolyWrath_Timer < diff) - { - DoCast(m_creature->getVictim(), SPELL_HOLY_WRATH); - HolyWrath_Timer = 15000 + rand()%10000; - }else HolyWrath_Timer -= diff; - - if (HolyNova_Timer < diff) - { - Unit* target = NULL; - TargetInRange = 0; - for(int i=0; i<10; i++) - { - target = SelectUnit(SELECT_TARGET_TOPAGGRO,i); - if(target) - if(m_creature->IsWithinDistInMap(target, ATTACK_DISTANCE)) - TargetInRange++; - } - - if(TargetInRange > 1) - { - DoCast(m_creature->getVictim(),SPELL_HOLY_NOVA); - HolyNova_Timer = 1000; - } - else - { - HolyNova_Timer = 2000; - } - - }else HolyNova_Timer -= diff; - - if (HolyFire_Timer < diff && TargetInRange < 3) - { - Unit* targetrandom = NULL; - targetrandom = SelectUnit(SELECT_TARGET_RANDOM,0); - - DoCast(targetrandom, SPELL_HOLY_FIRE); - HolyFire_Timer = 8000; - }else HolyFire_Timer -= diff; - } - else - { - if(!PhaseTwo) - { - m_creature->InterruptNonMeleeSpells(false); - DoCast(m_creature,SPELL_SNAKE_FORM); - m_creature->SetFloatValue(OBJECT_FIELD_SCALE_X, 2.00f); - const CreatureInfo *cinfo = m_creature->GetCreatureInfo(); - m_creature->SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, (cinfo->mindmg +((cinfo->mindmg/100) * 25))); - m_creature->SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, (cinfo->maxdmg +((cinfo->maxdmg/100) * 25))); - m_creature->UpdateDamagePhysical(BASE_ATTACK); - DoResetThreat(); - PhaseTwo = true; - } - - if(PhaseTwo && PoisonCloud_Timer < diff) - { - DoCast(m_creature->getVictim(), SPELL_POISON_CLOUD); - PoisonCloud_Timer = 15000; - }PoisonCloud_Timer -=diff; - - if (PhaseTwo && VenomSpit_Timer < diff) - { - Unit* targetrandom = NULL; - targetrandom = SelectUnit(SELECT_TARGET_RANDOM,0); - - DoCast(targetrandom, SPELL_VENOMSPIT); - VenomSpit_Timer = 15000 + rand()%5000; - }else VenomSpit_Timer -= diff; - - if (PhaseTwo && (m_creature->GetHealth()*100 / m_creature->GetMaxHealth() < 11)) - { - if (!InBerserk) - { - m_creature->InterruptNonMeleeSpells(false); - DoCast(m_creature, SPELL_BERSERK); - InBerserk = true; - } - } - } - DoMeleeAttackIfReady(); - } - } -}; -CreatureAI* GetAI_boss_venoxis(Creature *_Creature) -{ - return new boss_venoxisAI (_Creature); -} - -void AddSC_boss_venoxis() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_venoxis"; - newscript->GetAI = GetAI_boss_venoxis; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Venoxis +SD%Complete: 100 +SDComment: +SDCategory: Zul'Gurub +EndScriptData */ + +#include "precompiled.h" +#include "def_zulgurub.h" + +#define SPELL_HOLY_FIRE 23860 +#define SPELL_HOLY_WRATH 28883 //Not sure if this or 23979 +#define SPELL_VENOMSPIT 23862 +#define SPELL_HOLY_NOVA 23858 +#define SPELL_POISON_CLOUD 23861 +#define SPELL_SNAKE_FORM 23849 +#define SPELL_RENEW 23895 +#define SPELL_BERSERK 23537 +#define SPELL_DISPELL 23859 + +#define SAY_AGGRO "Let the coils of hate unfurl!" +#define SOUND_AGGRO 8421 + +struct MANGOS_DLL_DECL boss_venoxisAI : public ScriptedAI +{ + boss_venoxisAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 HolyFire_Timer; + uint32 HolyWrath_Timer; + uint32 VenomSpit_Timer; + uint32 Renew_Timer; + uint32 PoisonCloud_Timer; + uint32 HolyNova_Timer; + uint32 Dispell_Timer; + uint32 TargetInRange; + + bool PhaseTwo; + bool InBerserk; + + void Reset() + { + HolyFire_Timer = 10000; + HolyWrath_Timer = 60500; + VenomSpit_Timer = 5500; + Renew_Timer = 30500; + PoisonCloud_Timer = 2000; + HolyNova_Timer = 5000; + Dispell_Timer = 35000; + TargetInRange = 0; + + PhaseTwo = false; + InBerserk= false; + } + + void Aggro(Unit *who) + { + DoYell(SAY_AGGRO,LANG_UNIVERSAL,NULL); + DoPlaySoundToSet(m_creature,SOUND_AGGRO); + } + + void JustDied(Unit* Killer) + { + ScriptedInstance *pInstance = (m_creature->GetInstanceData()) ? ((ScriptedInstance*)m_creature->GetInstanceData()) : NULL; + if(pInstance) + pInstance->SetData(DATA_VENOXIS_DEATH, 0); + } + + void UpdateAI(const uint32 diff) + { + if (!m_creature->SelectHostilTarget()) + return; + + if( m_creature->getVictim() && m_creature->isAlive()) + { + if ((m_creature->GetHealth()*100 / m_creature->GetMaxHealth() > 50)) + { + if (Dispell_Timer < diff) + { + DoCast(m_creature, SPELL_DISPELL); + Dispell_Timer = 15000 + rand()%15000; + }else Dispell_Timer -= diff; + + if (Renew_Timer < diff) + { + DoCast(m_creature, SPELL_RENEW); + Renew_Timer = 20000 + rand()%10000; + }else Renew_Timer -= diff; + + if (HolyWrath_Timer < diff) + { + DoCast(m_creature->getVictim(), SPELL_HOLY_WRATH); + HolyWrath_Timer = 15000 + rand()%10000; + }else HolyWrath_Timer -= diff; + + if (HolyNova_Timer < diff) + { + Unit* target = NULL; + TargetInRange = 0; + for(int i=0; i<10; i++) + { + target = SelectUnit(SELECT_TARGET_TOPAGGRO,i); + if(target) + if(m_creature->IsWithinDistInMap(target, ATTACK_DISTANCE)) + TargetInRange++; + } + + if(TargetInRange > 1) + { + DoCast(m_creature->getVictim(),SPELL_HOLY_NOVA); + HolyNova_Timer = 1000; + } + else + { + HolyNova_Timer = 2000; + } + + }else HolyNova_Timer -= diff; + + if (HolyFire_Timer < diff && TargetInRange < 3) + { + Unit* targetrandom = NULL; + targetrandom = SelectUnit(SELECT_TARGET_RANDOM,0); + + DoCast(targetrandom, SPELL_HOLY_FIRE); + HolyFire_Timer = 8000; + }else HolyFire_Timer -= diff; + } + else + { + if(!PhaseTwo) + { + m_creature->InterruptNonMeleeSpells(false); + DoCast(m_creature,SPELL_SNAKE_FORM); + m_creature->SetFloatValue(OBJECT_FIELD_SCALE_X, 2.00f); + const CreatureInfo *cinfo = m_creature->GetCreatureInfo(); + m_creature->SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, (cinfo->mindmg +((cinfo->mindmg/100) * 25))); + m_creature->SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, (cinfo->maxdmg +((cinfo->maxdmg/100) * 25))); + m_creature->UpdateDamagePhysical(BASE_ATTACK); + DoResetThreat(); + PhaseTwo = true; + } + + if(PhaseTwo && PoisonCloud_Timer < diff) + { + DoCast(m_creature->getVictim(), SPELL_POISON_CLOUD); + PoisonCloud_Timer = 15000; + }PoisonCloud_Timer -=diff; + + if (PhaseTwo && VenomSpit_Timer < diff) + { + Unit* targetrandom = NULL; + targetrandom = SelectUnit(SELECT_TARGET_RANDOM,0); + + DoCast(targetrandom, SPELL_VENOMSPIT); + VenomSpit_Timer = 15000 + rand()%5000; + }else VenomSpit_Timer -= diff; + + if (PhaseTwo && (m_creature->GetHealth()*100 / m_creature->GetMaxHealth() < 11)) + { + if (!InBerserk) + { + m_creature->InterruptNonMeleeSpells(false); + DoCast(m_creature, SPELL_BERSERK); + InBerserk = true; + } + } + } + DoMeleeAttackIfReady(); + } + } +}; +CreatureAI* GetAI_boss_venoxis(Creature *_Creature) +{ + return new boss_venoxisAI (_Creature); +} + +void AddSC_boss_venoxis() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_venoxis"; + newscript->GetAI = GetAI_boss_venoxis; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/zulgurub/boss_wushoolay.cpp b/src/bindings/scripts/scripts/zone/zulgurub/boss_wushoolay.cpp index c94c665c1cb..200768cf84b 100644 --- a/src/bindings/scripts/scripts/zone/zulgurub/boss_wushoolay.cpp +++ b/src/bindings/scripts/scripts/zone/zulgurub/boss_wushoolay.cpp @@ -1,84 +1,84 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Boss_Wushoolay -SD%Complete: 100 -SDComment: -SDCategory: Zul'Gurub -EndScriptData */ - -#include "precompiled.h" -#include "def_zulgurub.h" - -#define SPELL_LIGHTNINGCLOUD 25033 -#define SPELL_LIGHTNINGWAVE 24819 - -struct MANGOS_DLL_DECL boss_wushoolayAI : public ScriptedAI -{ - boss_wushoolayAI(Creature *c) : ScriptedAI(c) {Reset();} - - uint32 LightningCloud_Timer; - uint32 LightningWave_Timer; - - void Reset() - { - LightningCloud_Timer = 5000 + rand()%5000; - LightningWave_Timer = 8000 + rand()%8000; - } - - void Aggro(Unit *who) - { - } - - void UpdateAI(const uint32 diff) - { - if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) - return; - - //LightningCloud_Timer - if (LightningCloud_Timer < diff) - { - DoCast(m_creature->getVictim(),SPELL_LIGHTNINGCLOUD); - LightningCloud_Timer = 15000 + rand()%5000; - }else LightningCloud_Timer -= diff; - - //LightningWave_Timer - if (LightningWave_Timer < diff) - { - Unit* target = NULL; - target = SelectUnit(SELECT_TARGET_RANDOM,0); - if (target) DoCast(target,SPELL_LIGHTNINGWAVE); - - LightningWave_Timer = 12000 + rand()%4000; - }else LightningWave_Timer -= diff; - - DoMeleeAttackIfReady(); - } -}; -CreatureAI* GetAI_boss_wushoolay(Creature *_Creature) -{ - return new boss_wushoolayAI (_Creature); -} - -void AddSC_boss_wushoolay() -{ - Script *newscript; - newscript = new Script; - newscript->Name="boss_wushoolay"; - newscript->GetAI = GetAI_boss_wushoolay; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Boss_Wushoolay +SD%Complete: 100 +SDComment: +SDCategory: Zul'Gurub +EndScriptData */ + +#include "precompiled.h" +#include "def_zulgurub.h" + +#define SPELL_LIGHTNINGCLOUD 25033 +#define SPELL_LIGHTNINGWAVE 24819 + +struct MANGOS_DLL_DECL boss_wushoolayAI : public ScriptedAI +{ + boss_wushoolayAI(Creature *c) : ScriptedAI(c) {Reset();} + + uint32 LightningCloud_Timer; + uint32 LightningWave_Timer; + + void Reset() + { + LightningCloud_Timer = 5000 + rand()%5000; + LightningWave_Timer = 8000 + rand()%8000; + } + + void Aggro(Unit *who) + { + } + + void UpdateAI(const uint32 diff) + { + if (!m_creature->SelectHostilTarget() || !m_creature->getVictim()) + return; + + //LightningCloud_Timer + if (LightningCloud_Timer < diff) + { + DoCast(m_creature->getVictim(),SPELL_LIGHTNINGCLOUD); + LightningCloud_Timer = 15000 + rand()%5000; + }else LightningCloud_Timer -= diff; + + //LightningWave_Timer + if (LightningWave_Timer < diff) + { + Unit* target = NULL; + target = SelectUnit(SELECT_TARGET_RANDOM,0); + if (target) DoCast(target,SPELL_LIGHTNINGWAVE); + + LightningWave_Timer = 12000 + rand()%4000; + }else LightningWave_Timer -= diff; + + DoMeleeAttackIfReady(); + } +}; +CreatureAI* GetAI_boss_wushoolay(Creature *_Creature) +{ + return new boss_wushoolayAI (_Creature); +} + +void AddSC_boss_wushoolay() +{ + Script *newscript; + newscript = new Script; + newscript->Name="boss_wushoolay"; + newscript->GetAI = GetAI_boss_wushoolay; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/bindings/scripts/scripts/zone/zulgurub/def_zulgurub.h b/src/bindings/scripts/scripts/zone/zulgurub/def_zulgurub.h index 0dcbb83c4df..d4d181db15a 100644 --- a/src/bindings/scripts/scripts/zone/zulgurub/def_zulgurub.h +++ b/src/bindings/scripts/scripts/zone/zulgurub/def_zulgurub.h @@ -1,36 +1,36 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software licensed under GPL version 2 - * Please see the included DOCS/LICENSE.TXT for more information */ - -#ifndef DEF_ZULGURUB_H -#define DEF_ZULGURUB_H - -#define DATA_ARLOKKISDEAD 1 -#define DATA_ARLOKK_DEATH 2 -#define DATA_JEKLIKISDEAD 3 -#define DATA_JEKLIK_DEATH 4 -#define DATA_JINDO 5 -#define DATA_LORKHAN 6 -#define DATA_LORKHANISALIVE 7 -#define DATA_LORKHANISDEAD 8 -#define DATA_LORKHAN_ALIVE 9 -#define DATA_LORKHAN_DEATH 10 -#define DATA_MARLIISDEAD 11 -#define DATA_MARLI_DEATH 12 -#define DATA_OHGANISDEAD 13 -#define DATA_OHGAN_DEATH 14 -#define DATA_THEKAL 15 -#define DATA_THEKALFAKE_DEATH 16 -#define DATA_THEKALISALIVE 17 -#define DATA_THEKALISDEAD 18 -#define DATA_THEKALISFAKEDEAD 19 -#define DATA_THEKAL_ALIVE 20 -#define DATA_THEKAL_DEATH 21 -#define DATA_VENOXISISDEAD 22 -#define DATA_VENOXIS_DEATH 23 -#define DATA_ZATH 24 -#define DATA_ZATHISALIVE 25 -#define DATA_ZATHISDEAD 26 -#define DATA_ZATH_ALIVE 27 -#define DATA_ZATH_DEATH 28 -#endif +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software licensed under GPL version 2 + * Please see the included DOCS/LICENSE.TXT for more information */ + +#ifndef DEF_ZULGURUB_H +#define DEF_ZULGURUB_H + +#define DATA_ARLOKKISDEAD 1 +#define DATA_ARLOKK_DEATH 2 +#define DATA_JEKLIKISDEAD 3 +#define DATA_JEKLIK_DEATH 4 +#define DATA_JINDO 5 +#define DATA_LORKHAN 6 +#define DATA_LORKHANISALIVE 7 +#define DATA_LORKHANISDEAD 8 +#define DATA_LORKHAN_ALIVE 9 +#define DATA_LORKHAN_DEATH 10 +#define DATA_MARLIISDEAD 11 +#define DATA_MARLI_DEATH 12 +#define DATA_OHGANISDEAD 13 +#define DATA_OHGAN_DEATH 14 +#define DATA_THEKAL 15 +#define DATA_THEKALFAKE_DEATH 16 +#define DATA_THEKALISALIVE 17 +#define DATA_THEKALISDEAD 18 +#define DATA_THEKALISFAKEDEAD 19 +#define DATA_THEKAL_ALIVE 20 +#define DATA_THEKAL_DEATH 21 +#define DATA_VENOXISISDEAD 22 +#define DATA_VENOXIS_DEATH 23 +#define DATA_ZATH 24 +#define DATA_ZATHISALIVE 25 +#define DATA_ZATHISDEAD 26 +#define DATA_ZATH_ALIVE 27 +#define DATA_ZATH_DEATH 28 +#endif diff --git a/src/bindings/scripts/scripts/zone/zulgurub/instance_zulgurub.cpp b/src/bindings/scripts/scripts/zone/zulgurub/instance_zulgurub.cpp index d0573414143..53d978bed18 100644 --- a/src/bindings/scripts/scripts/zone/zulgurub/instance_zulgurub.cpp +++ b/src/bindings/scripts/scripts/zone/zulgurub/instance_zulgurub.cpp @@ -1,238 +1,238 @@ -/* Copyright (C) 2006 - 2008 ScriptDev2 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* ScriptData -SDName: Instance_ZulGurub -SD%Complete: 80 -SDComment: Missing reset function after killing a boss for Ohgan, Thekal. -SDCategory: Zul'Gurub -EndScriptData */ - -#include "precompiled.h" -#include "def_zulgurub.h" - -struct MANGOS_DLL_DECL instance_zulgurub : public ScriptedInstance -{ - instance_zulgurub(Map *Map) : ScriptedInstance(Map) {Initialize();}; - - //If all High Priest bosses were killed. Lorkhan, Zath and Ohgan are added too. - bool IsBossDied[9]; - - //Storing Lorkhan, Zath and Thekal because we need to cast on them later. Jindo is needed for healfunction too. - uint64 LorKhanGUID; - uint64 ZathGUID; - uint64 ThekalGUID; - uint64 JindoGUID; - - void OnCreatureCreate (Creature *creature, uint32 creature_entry) - { - switch (creature_entry) - { - case 11347: - LorKhanGUID = creature->GetGUID(); - break; - - case 11348: - ZathGUID = creature->GetGUID(); - break; - - case 14509: - ThekalGUID = creature->GetGUID(); - break; - - case 11380: - JindoGUID = creature->GetGUID(); - break; - } - } - - void Initialize() - { - IsBossDied[0] = false; - IsBossDied[1] = false; - IsBossDied[2] = false; - IsBossDied[3] = false; - IsBossDied[4] = false; - IsBossDied[5] = false; - IsBossDied[6] = false; - - IsBossDied[7] = false; - IsBossDied[8] = false; - } - - bool IsEncounterInProgress() const - { - //not active in Zul'Gurub - return false; - } - - uint32 GetData(uint32 type) - { - switch(type) - { - case DATA_JEKLIKISDEAD: - if(IsBossDied[0]) - return 1; - break; - - case DATA_VENOXISISDEAD: - if(IsBossDied[1]) - return 1; - break; - - case DATA_MARLIISDEAD: - if(IsBossDied[2]) - return 1; - break; - - case DATA_THEKALISDEAD: - if(IsBossDied[3]) - return 1; - break; - - case DATA_ARLOKKISDEAD: - if(IsBossDied[4]) - return 1; - break; - - case DATA_LORKHANISDEAD: - if(IsBossDied[5]) - return 1; - break; - - case DATA_ZATHISDEAD: - if(IsBossDied[6]) - return 1; - break; - - case DATA_THEKALISFAKEDEAD: - if(IsBossDied[7]) - return 1; - break; - - case DATA_OHGANISDEAD: - if(IsBossDied[8]) - return 1; - break; - - //Boss is not dead. Resetting function for some bosses after killing them but whiping at the complete encounter. - - case DATA_THEKALISALIVE: - if(IsBossDied[3]) - return 0; - break; - - case DATA_LORKHANISALIVE: - if(IsBossDied[5]) - return 0; - break; - - case DATA_ZATHISALIVE: - if(IsBossDied[6]) - return 0; - break; - } - - return 0; - } - - uint64 GetData64 (uint32 identifier) - { - switch(identifier) - { - case DATA_LORKHAN: - return LorKhanGUID; - - case DATA_ZATH: - return ZathGUID; - - case DATA_THEKAL: - return ThekalGUID; - - case DATA_JINDO: - return JindoGUID; - } - return 0; - } // end GetData64 - - void SetData(uint32 type, uint32 data) - { - switch(type) - { - case DATA_JEKLIK_DEATH: - IsBossDied[0] = true; - break; - - case DATA_VENOXIS_DEATH: - IsBossDied[1] = true; - break; - - case DATA_MARLI_DEATH: - IsBossDied[2] = true; - break; - - case DATA_THEKAL_DEATH: - IsBossDied[3] = true; - break; - - case DATA_ARLOKK_DEATH: - IsBossDied[4] = true; - break; - - case DATA_LORKHAN_DEATH: - IsBossDied[5] = true; - break; - - case DATA_ZATH_DEATH: - IsBossDied[6] = true; - break; - - case DATA_THEKALFAKE_DEATH: - IsBossDied[7] = true; - break; - - case DATA_OHGAN_DEATH: - IsBossDied[8] = true; - break; - - case DATA_LORKHAN_ALIVE: - IsBossDied[5] = false; - break; - - case DATA_ZATH_ALIVE: - IsBossDied[6] = false; - break; - - case DATA_THEKAL_ALIVE: - IsBossDied[7] = false; - break; - } - } -}; - -InstanceData* GetInstanceData_instance_zulgurub(Map* map) -{ - return new instance_zulgurub(map); -} - -void AddSC_instance_zulgurub() -{ - Script *newscript; - newscript = new Script; - newscript->Name = "instance_zulgurub"; - newscript->GetInstanceData = GetInstanceData_instance_zulgurub; - m_scripts[nrscripts++] = newscript; -} +/* Copyright (C) 2006 - 2008 ScriptDev2 + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: Instance_ZulGurub +SD%Complete: 80 +SDComment: Missing reset function after killing a boss for Ohgan, Thekal. +SDCategory: Zul'Gurub +EndScriptData */ + +#include "precompiled.h" +#include "def_zulgurub.h" + +struct MANGOS_DLL_DECL instance_zulgurub : public ScriptedInstance +{ + instance_zulgurub(Map *Map) : ScriptedInstance(Map) {Initialize();}; + + //If all High Priest bosses were killed. Lorkhan, Zath and Ohgan are added too. + bool IsBossDied[9]; + + //Storing Lorkhan, Zath and Thekal because we need to cast on them later. Jindo is needed for healfunction too. + uint64 LorKhanGUID; + uint64 ZathGUID; + uint64 ThekalGUID; + uint64 JindoGUID; + + void OnCreatureCreate (Creature *creature, uint32 creature_entry) + { + switch (creature_entry) + { + case 11347: + LorKhanGUID = creature->GetGUID(); + break; + + case 11348: + ZathGUID = creature->GetGUID(); + break; + + case 14509: + ThekalGUID = creature->GetGUID(); + break; + + case 11380: + JindoGUID = creature->GetGUID(); + break; + } + } + + void Initialize() + { + IsBossDied[0] = false; + IsBossDied[1] = false; + IsBossDied[2] = false; + IsBossDied[3] = false; + IsBossDied[4] = false; + IsBossDied[5] = false; + IsBossDied[6] = false; + + IsBossDied[7] = false; + IsBossDied[8] = false; + } + + bool IsEncounterInProgress() const + { + //not active in Zul'Gurub + return false; + } + + uint32 GetData(uint32 type) + { + switch(type) + { + case DATA_JEKLIKISDEAD: + if(IsBossDied[0]) + return 1; + break; + + case DATA_VENOXISISDEAD: + if(IsBossDied[1]) + return 1; + break; + + case DATA_MARLIISDEAD: + if(IsBossDied[2]) + return 1; + break; + + case DATA_THEKALISDEAD: + if(IsBossDied[3]) + return 1; + break; + + case DATA_ARLOKKISDEAD: + if(IsBossDied[4]) + return 1; + break; + + case DATA_LORKHANISDEAD: + if(IsBossDied[5]) + return 1; + break; + + case DATA_ZATHISDEAD: + if(IsBossDied[6]) + return 1; + break; + + case DATA_THEKALISFAKEDEAD: + if(IsBossDied[7]) + return 1; + break; + + case DATA_OHGANISDEAD: + if(IsBossDied[8]) + return 1; + break; + + //Boss is not dead. Resetting function for some bosses after killing them but whiping at the complete encounter. + + case DATA_THEKALISALIVE: + if(IsBossDied[3]) + return 0; + break; + + case DATA_LORKHANISALIVE: + if(IsBossDied[5]) + return 0; + break; + + case DATA_ZATHISALIVE: + if(IsBossDied[6]) + return 0; + break; + } + + return 0; + } + + uint64 GetData64 (uint32 identifier) + { + switch(identifier) + { + case DATA_LORKHAN: + return LorKhanGUID; + + case DATA_ZATH: + return ZathGUID; + + case DATA_THEKAL: + return ThekalGUID; + + case DATA_JINDO: + return JindoGUID; + } + return 0; + } // end GetData64 + + void SetData(uint32 type, uint32 data) + { + switch(type) + { + case DATA_JEKLIK_DEATH: + IsBossDied[0] = true; + break; + + case DATA_VENOXIS_DEATH: + IsBossDied[1] = true; + break; + + case DATA_MARLI_DEATH: + IsBossDied[2] = true; + break; + + case DATA_THEKAL_DEATH: + IsBossDied[3] = true; + break; + + case DATA_ARLOKK_DEATH: + IsBossDied[4] = true; + break; + + case DATA_LORKHAN_DEATH: + IsBossDied[5] = true; + break; + + case DATA_ZATH_DEATH: + IsBossDied[6] = true; + break; + + case DATA_THEKALFAKE_DEATH: + IsBossDied[7] = true; + break; + + case DATA_OHGAN_DEATH: + IsBossDied[8] = true; + break; + + case DATA_LORKHAN_ALIVE: + IsBossDied[5] = false; + break; + + case DATA_ZATH_ALIVE: + IsBossDied[6] = false; + break; + + case DATA_THEKAL_ALIVE: + IsBossDied[7] = false; + break; + } + } +}; + +InstanceData* GetInstanceData_instance_zulgurub(Map* map) +{ + return new instance_zulgurub(map); +} + +void AddSC_instance_zulgurub() +{ + Script *newscript; + newscript = new Script; + newscript->Name = "instance_zulgurub"; + newscript->GetInstanceData = GetInstanceData_instance_zulgurub; + m_scripts[nrscripts++] = newscript; +} diff --git a/src/game/AggressorAI.cpp b/src/game/AggressorAI.cpp index 494acbb9a51..a4ef9e39f47 100644 --- a/src/game/AggressorAI.cpp +++ b/src/game/AggressorAI.cpp @@ -1,155 +1,157 @@ -/* - * Copyright (C) 2005-2008 MaNGOS - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "AggressorAI.h" -#include "Errors.h" -#include "Creature.h" -#include "Player.h" -#include "ObjectAccessor.h" -#include "VMapFactory.h" -#include "World.h" - -#include - -int -AggressorAI::Permissible(const Creature *creature) -{ - // have some hostile factions, it will be selected by IsHostileTo check at MoveInLineOfSight - if( !creature->isCivilian() && !creature->IsNeutralToAll() ) - return PERMIT_BASE_PROACTIVE; - - return PERMIT_BASE_NO; -} - -AggressorAI::AggressorAI(Creature &c) : i_creature(c), i_victimGuid(0), i_state(STATE_NORMAL), i_tracker(TIME_INTERVAL_LOOK) -{ -} - -void -AggressorAI::MoveInLineOfSight(Unit *u) -{ - if( i_creature.GetDistanceZ(u) > CREATURE_Z_ATTACK_RANGE ) - return; - if( !i_creature.getVictim() && !i_creature.hasUnitState(UNIT_STAT_STUNDED) && u->isTargetableForAttack() && - ( i_creature.IsHostileTo( u ) /*|| u->getVictim() && i_creature.IsFriendlyTo( u->getVictim() )*/ ) && - u->isInAccessablePlaceFor(&i_creature) ) - { - float attackRadius = i_creature.GetAttackDistance(u); - if(i_creature.IsWithinDistInMap(u, attackRadius) && i_creature.IsWithinLOSInMap(u) ) - { - AttackStart(u); - u->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); - } - } -} - -void AggressorAI::EnterEvadeMode() -{ - if( !i_creature.isAlive() ) - { - DEBUG_LOG("Creature stopped attacking cuz his dead [guid=%u]", i_creature.GetGUIDLow()); - i_victimGuid = 0; - i_creature.CombatStop(); - i_creature.DeleteThreatList(); - return; - } - - Unit* victim = ObjectAccessor::GetUnit(i_creature, i_victimGuid ); - - if( !victim ) - { - DEBUG_LOG("Creature stopped attacking because victim is non exist [guid=%u]", i_creature.GetGUIDLow()); - } - else if( !victim->isAlive() ) - { - DEBUG_LOG("Creature stopped attacking cuz his victim is dead [guid=%u]", i_creature.GetGUIDLow()); - } - else if( victim->HasStealthAura() ) - { - DEBUG_LOG("Creature stopped attacking cuz his victim is stealth [guid=%u]", i_creature.GetGUIDLow()); - } - else if( victim->isInFlight() ) - { - DEBUG_LOG("Creature stopped attacking cuz his victim is fly away [guid=%u]", i_creature.GetGUIDLow()); - } - else - { - DEBUG_LOG("Creature stopped attacking due to target out run him [guid=%u]", i_creature.GetGUIDLow()); - //i_state = STATE_LOOK_AT_VICTIM; - //i_tracker.Reset(TIME_INTERVAL_LOOK); - } - - if(!i_creature.isCharmed()) - { - i_creature.RemoveAllAuras(); - - // Remove TargetedMovementGenerator from MotionMaster stack list, and add HomeMovementGenerator instead - if( i_creature.GetMotionMaster()->GetCurrentMovementGeneratorType() == TARGETED_MOTION_TYPE ) - i_creature.GetMotionMaster()->MoveTargetedHome(); - } - - i_creature.DeleteThreatList(); - i_victimGuid = 0; - i_creature.CombatStop(); - i_creature.SetLootRecipient(NULL); -} - -void -AggressorAI::UpdateAI(const uint32 /*diff*/) -{ - // update i_victimGuid if i_creature.getVictim() !=0 and changed - if(!i_creature.SelectHostilTarget() || !i_creature.getVictim()) - return; - - i_victimGuid = i_creature.getVictim()->GetGUID(); - - if( i_creature.isAttackReady() ) - { - if( i_creature.IsWithinDistInMap(i_creature.getVictim(), ATTACK_DISTANCE)) - { - i_creature.AttackerStateUpdate(i_creature.getVictim()); - i_creature.resetAttackTimer(); - } - } -} - -bool -AggressorAI::IsVisible(Unit *pl) const -{ - return i_creature.GetDistance(pl) < sWorld.getConfig(CONFIG_SIGHT_MONSTER) - && pl->isVisibleForOrDetect(&i_creature,true); -} - -void -AggressorAI::AttackStart(Unit *u) -{ - if( !u ) - return; - - if(i_creature.Attack(u,true)) - { - i_creature.SetInCombatWith(u); - u->SetInCombatWith(&i_creature); - - i_creature.AddThreat(u, 0.0f); - // DEBUG_LOG("Creature %s tagged a victim to kill [guid=%u]", i_creature.GetName(), u->GetGUIDLow()); - i_victimGuid = u->GetGUID(); - - i_creature.GetMotionMaster()->MoveChase(u); - } -} +/* + * Copyright (C) 2005-2008 MaNGOS + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "AggressorAI.h" +#include "Errors.h" +#include "Creature.h" +#include "Player.h" +#include "ObjectAccessor.h" +#include "VMapFactory.h" +#include "World.h" + +#include + +int +AggressorAI::Permissible(const Creature *creature) +{ + // have some hostile factions, it will be selected by IsHostileTo check at MoveInLineOfSight + if( !creature->isCivilian() && !creature->IsNeutralToAll() ) + return PERMIT_BASE_PROACTIVE; + + return PERMIT_BASE_NO; +} + +AggressorAI::AggressorAI(Creature &c) : i_creature(c), i_victimGuid(0), i_state(STATE_NORMAL), i_tracker(TIME_INTERVAL_LOOK) +{ +} + +void +AggressorAI::MoveInLineOfSight(Unit *u) +{ + // Ignore Z for flying creatures + if( !i_creature.canFly() && i_creature.GetDistanceZ(u) > CREATURE_Z_ATTACK_RANGE ) + return; + + if( !i_creature.getVictim() && !i_creature.hasUnitState(UNIT_STAT_STUNDED) && u->isTargetableForAttack() && + ( i_creature.IsHostileTo( u ) /*|| u->getVictim() && i_creature.IsFriendlyTo( u->getVictim() )*/ ) && + u->isInAccessablePlaceFor(&i_creature) ) + { + float attackRadius = i_creature.GetAttackDistance(u); + if(i_creature.IsWithinDistInMap(u, attackRadius) && i_creature.IsWithinLOSInMap(u) ) + { + AttackStart(u); + u->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); + } + } +} + +void AggressorAI::EnterEvadeMode() +{ + if( !i_creature.isAlive() ) + { + DEBUG_LOG("Creature stopped attacking cuz his dead [guid=%u]", i_creature.GetGUIDLow()); + i_victimGuid = 0; + i_creature.CombatStop(); + i_creature.DeleteThreatList(); + return; + } + + Unit* victim = ObjectAccessor::GetUnit(i_creature, i_victimGuid ); + + if( !victim ) + { + DEBUG_LOG("Creature stopped attacking because victim is non exist [guid=%u]", i_creature.GetGUIDLow()); + } + else if( !victim->isAlive() ) + { + DEBUG_LOG("Creature stopped attacking cuz his victim is dead [guid=%u]", i_creature.GetGUIDLow()); + } + else if( victim->HasStealthAura() ) + { + DEBUG_LOG("Creature stopped attacking cuz his victim is stealth [guid=%u]", i_creature.GetGUIDLow()); + } + else if( victim->isInFlight() ) + { + DEBUG_LOG("Creature stopped attacking cuz his victim is fly away [guid=%u]", i_creature.GetGUIDLow()); + } + else + { + DEBUG_LOG("Creature stopped attacking due to target out run him [guid=%u]", i_creature.GetGUIDLow()); + //i_state = STATE_LOOK_AT_VICTIM; + //i_tracker.Reset(TIME_INTERVAL_LOOK); + } + + if(!i_creature.isCharmed()) + { + i_creature.RemoveAllAuras(); + + // Remove TargetedMovementGenerator from MotionMaster stack list, and add HomeMovementGenerator instead + if( i_creature.GetMotionMaster()->GetCurrentMovementGeneratorType() == TARGETED_MOTION_TYPE ) + i_creature.GetMotionMaster()->MoveTargetedHome(); + } + + i_creature.DeleteThreatList(); + i_victimGuid = 0; + i_creature.CombatStop(); + i_creature.SetLootRecipient(NULL); +} + +void +AggressorAI::UpdateAI(const uint32 /*diff*/) +{ + // update i_victimGuid if i_creature.getVictim() !=0 and changed + if(!i_creature.SelectHostilTarget() || !i_creature.getVictim()) + return; + + i_victimGuid = i_creature.getVictim()->GetGUID(); + + if( i_creature.isAttackReady() ) + { + if( i_creature.IsWithinDistInMap(i_creature.getVictim(), ATTACK_DISTANCE)) + { + i_creature.AttackerStateUpdate(i_creature.getVictim()); + i_creature.resetAttackTimer(); + } + } +} + +bool +AggressorAI::IsVisible(Unit *pl) const +{ + return i_creature.GetDistance(pl) < sWorld.getConfig(CONFIG_SIGHT_MONSTER) + && pl->isVisibleForOrDetect(&i_creature,true); +} + +void +AggressorAI::AttackStart(Unit *u) +{ + if( !u ) + return; + + if(i_creature.Attack(u,true)) + { + i_creature.SetInCombatWith(u); + u->SetInCombatWith(&i_creature); + + i_creature.AddThreat(u, 0.0f); + // DEBUG_LOG("Creature %s tagged a victim to kill [guid=%u]", i_creature.GetName(), u->GetGUIDLow()); + i_victimGuid = u->GetGUID(); + + i_creature.GetMotionMaster()->MoveChase(u); + } +} diff --git a/src/game/CharacterHandler.cpp b/src/game/CharacterHandler.cpp index f63af7d7f81..929a0543f0b 100644 --- a/src/game/CharacterHandler.cpp +++ b/src/game/CharacterHandler.cpp @@ -19,7 +19,7 @@ #include "Common.h" #include "Database/DatabaseEnv.h" #include "WorldPacket.h" -#include "WorldSocket.h" +#include "SharedDefines.h" #include "WorldSession.h" #include "Opcodes.h" #include "Log.h" @@ -366,7 +366,7 @@ void WorldSession::HandleCharCreateOpcode( WorldPacket & recv_data ) data << (uint8)CHAR_CREATE_SUCCESS; SendPacket( &data ); - std::string IP_str = _socket ? _socket->GetRemoteAddress().c_str() : "-"; + std::string IP_str = GetRemoteAddress().c_str(); sLog.outBasic("Account: %d (IP: %s) Create Character:[%s]",GetAccountId(),IP_str.c_str(),name.c_str()); sLog.outChar("Account: %d (IP: %s) Create Character:[%s]",GetAccountId(),IP_str.c_str(),name.c_str()); } @@ -416,7 +416,7 @@ void WorldSession::HandleCharDeleteOpcode( WorldPacket & recv_data ) if(accountId != GetAccountId()) return; - std::string IP_str = _socket ? _socket->GetRemoteAddress().c_str() : "-"; + std::string IP_str = GetRemoteAddress(); sLog.outBasic("Account: %d (IP: %s) Delete Character:[%s] (guid:%u)",GetAccountId(),IP_str.c_str(),name.c_str(),GUID_LOPART(guid)); sLog.outChar("Account: %d (IP: %s) Delete Character:[%s] (guid: %u)",GetAccountId(),IP_str.c_str(),name.c_str(),GUID_LOPART(guid)); @@ -734,7 +734,7 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder * holder) if(pCurrChar->isGameMaster()) SendNotification("GM mode is ON"); - std::string IP_str = _socket ? _socket->GetRemoteAddress().c_str() : "-"; + std::string IP_str = GetRemoteAddress(); sLog.outChar("Account: %d (IP: %s) Login Character:[%s] (guid:%u)",GetAccountId(),IP_str.c_str(),pCurrChar->GetName() ,pCurrChar->GetGUID()); m_playerLoading = false; @@ -966,7 +966,7 @@ void WorldSession::HandleChangePlayerNameOpcode(WorldPacket& recv_data) CharacterDatabase.PExecute("UPDATE characters set name = '%s', at_login = at_login & ~ %u WHERE guid ='%u'", newname.c_str(), uint32(AT_LOGIN_RENAME),GUID_LOPART(guid)); CharacterDatabase.PExecute("DELETE FROM character_declinedname WHERE guid ='%u'", GUID_LOPART(guid)); - std::string IP_str = _socket ? _socket->GetRemoteAddress().c_str() : "-"; + std::string IP_str = GetRemoteAddress(); sLog.outChar("Account: %d (IP: %s) Character:[%s] (guid:%u) Changed name to: %s",GetAccountId(),IP_str.c_str(),oldname.c_str(),GUID_LOPART(guid),newname.c_str()); WorldPacket data(SMSG_CHAR_RENAME,1+8+(newname.size()+1)); diff --git a/src/game/Chat.cpp b/src/game/Chat.cpp index 9635542cf4f..7415bfb405c 100644 --- a/src/game/Chat.cpp +++ b/src/game/Chat.cpp @@ -1,1103 +1,1131 @@ -/* - * Copyright (C) 2005-2008 MaNGOS - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "Common.h" -#include "Language.h" -#include "Database/DatabaseEnv.h" -#include "WorldPacket.h" -#include "WorldSession.h" -#include "Opcodes.h" -#include "Log.h" -#include "World.h" -#include "ObjectMgr.h" -#include "Player.h" -#include "UpdateMask.h" -#include "Chat.h" -#include "MapManager.h" -#include "GridNotifiersImpl.h" -#include "CellImpl.h" - -bool ChatHandler::load_command_table = true; - -LanguageDesc lang_description[LANGUAGES_COUNT] = -{ - { LANG_ADDON, 0, 0 }, - { LANG_UNIVERSAL, 0, 0 }, - { LANG_ORCISH, 669, SKILL_LANG_ORCISH }, - { LANG_DARNASSIAN, 671, SKILL_LANG_DARNASSIAN }, - { LANG_TAURAHE, 670, SKILL_LANG_TAURAHE }, - { LANG_DWARVISH, 672, SKILL_LANG_DWARVEN }, - { LANG_COMMON, 668, SKILL_LANG_COMMON }, - { LANG_DEMONIC, 815, SKILL_LANG_DEMON_TONGUE }, - { LANG_TITAN, 816, SKILL_LANG_TITAN }, - { LANG_THALASSIAN, 813, SKILL_LANG_THALASSIAN }, - { LANG_DRACONIC, 814, SKILL_LANG_DRACONIC }, - { LANG_KALIMAG, 817, SKILL_LANG_OLD_TONGUE }, - { LANG_GNOMISH, 7340, SKILL_LANG_GNOMISH }, - { LANG_TROLL, 7341, SKILL_LANG_TROLL }, - { LANG_GUTTERSPEAK, 17737, SKILL_LANG_GUTTERSPEAK }, - { LANG_DRAENEI, 29932, SKILL_LANG_DRAENEI }, - { LANG_ZOMBIE, 0, 0 }, - { LANG_GNOMISH_BINARY, 0, 0 }, - { LANG_GOBLIN_BINARY, 0, 0 } -}; - -LanguageDesc const* GetLanguageDescByID(uint32 lang) -{ - for(int i = 0; i < LANGUAGES_COUNT; ++i) - { - if(uint32(lang_description[i].lang_id) == lang) - return &lang_description[i]; - } - - return NULL; -} - -LanguageDesc const* GetLanguageDescBySpell(uint32 spell_id) -{ - for(int i = 0; i < LANGUAGES_COUNT; ++i) - { - if(lang_description[i].spell_id == spell_id) - return &lang_description[i]; - } - - return NULL; -} - -LanguageDesc const* GetLanguageDescBySkill(uint32 skill_id) -{ - for(int i = 0; i < LANGUAGES_COUNT; ++i) - { - if(lang_description[i].skill_id == skill_id) - return &lang_description[i]; - } - - return NULL; -} - -ChatCommand * ChatHandler::getCommandTable() -{ - static ChatCommand serverCommandTable[] = - { - { "idlerestart", SEC_ADMINISTRATOR, &ChatHandler::HandleIdleRestartCommand, "", NULL }, - { "idleshutdown", SEC_ADMINISTRATOR, &ChatHandler::HandleIdleShutDownCommand, "", NULL }, - { "info", SEC_PLAYER, &ChatHandler::HandleInfoCommand, "", NULL }, - { "restart", SEC_ADMINISTRATOR, &ChatHandler::HandleRestartCommand, "", NULL }, - { "shutdown", SEC_ADMINISTRATOR, &ChatHandler::HandleShutDownCommand, "", NULL }, - { NULL, 0, NULL, "", NULL } - }; - - static ChatCommand modifyCommandTable[] = - { - { "hp", SEC_MODERATOR, &ChatHandler::HandleModifyHPCommand, "", NULL }, - { "mana", SEC_MODERATOR, &ChatHandler::HandleModifyManaCommand, "", NULL }, - { "rage", SEC_MODERATOR, &ChatHandler::HandleModifyRageCommand, "", NULL }, - { "energy", SEC_MODERATOR, &ChatHandler::HandleModifyEnergyCommand, "", NULL }, - { "money", SEC_MODERATOR, &ChatHandler::HandleModifyMoneyCommand, "", NULL }, - { "speed", SEC_MODERATOR, &ChatHandler::HandleModifySpeedCommand, "", NULL }, - { "swim", SEC_MODERATOR, &ChatHandler::HandleModifySwimCommand, "", NULL }, - { "scale", SEC_MODERATOR, &ChatHandler::HandleModifyScaleCommand, "", NULL }, - { "bit", SEC_MODERATOR, &ChatHandler::HandleModifyBitCommand, "", NULL }, - { "bwalk", SEC_MODERATOR, &ChatHandler::HandleModifyBWalkCommand, "", NULL }, - { "fly", SEC_MODERATOR, &ChatHandler::HandleModifyFlyCommand, "", NULL }, - { "aspeed", SEC_MODERATOR, &ChatHandler::HandleModifyASpeedCommand, "", NULL }, - { "faction", SEC_MODERATOR, &ChatHandler::HandleModifyFactionCommand, "", NULL }, - { "spell", SEC_MODERATOR, &ChatHandler::HandleModifySpellCommand, "", NULL }, - { "tp", SEC_MODERATOR, &ChatHandler::HandleModifyTalentCommand, "", NULL }, - { "titles", SEC_MODERATOR, &ChatHandler::HandleModifyKnownTitlesCommand, "", NULL }, - { "mount", SEC_MODERATOR, &ChatHandler::HandleModifyMountCommand, "", NULL }, - { "honor", SEC_MODERATOR, &ChatHandler::HandleModifyHonorCommand, "", NULL }, - { "rep", SEC_MODERATOR, &ChatHandler::HandleModifyRepCommand, "", NULL }, - { "arena", SEC_MODERATOR, &ChatHandler::HandleModifyArenaCommand, "", NULL }, - { "drunk", SEC_MODERATOR, &ChatHandler::HandleDrunkCommand, "", NULL }, - { "standstate", SEC_GAMEMASTER, &ChatHandler::HandleStandStateCommand, "", NULL }, - { "morph", SEC_GAMEMASTER, &ChatHandler::HandleMorphCommand, "", NULL }, - { NULL, 0, NULL, "", NULL } - }; - - static ChatCommand wpCommandTable[] = - { - { "show", SEC_GAMEMASTER, &ChatHandler::HandleWpShowCommand, "", NULL }, - { "add", SEC_GAMEMASTER, &ChatHandler::HandleWpAddCommand, "", NULL }, - { "modify", SEC_GAMEMASTER, &ChatHandler::HandleWpModifyCommand, "", NULL }, - { "export", SEC_ADMINISTRATOR, &ChatHandler::HandleWpExportCommand, "", NULL }, - { "import", SEC_ADMINISTRATOR, &ChatHandler::HandleWpImportCommand, "", NULL }, - { NULL, 0, NULL, "", NULL } - }; - - static ChatCommand debugCommandTable[] = - { - { "inarc", SEC_ADMINISTRATOR, &ChatHandler::HandleDebugInArcCommand, "", NULL }, - { "spellfail", SEC_ADMINISTRATOR, &ChatHandler::HandleDebugSpellFailCommand, "", NULL }, - { "setpoi", SEC_ADMINISTRATOR, &ChatHandler::HandleSetPoiCommand, "", NULL }, - { "qpartymsg", SEC_ADMINISTRATOR, &ChatHandler::HandleSendQuestPartyMsgCommand, "", NULL }, - { "qinvalidmsg", SEC_ADMINISTRATOR, &ChatHandler::HandleSendQuestInvalidMsgCommand, "", NULL }, - { "equiperr", SEC_ADMINISTRATOR, &ChatHandler::HandleEquipErrorCommand, "", NULL }, - { "sellerr", SEC_ADMINISTRATOR, &ChatHandler::HandleSellErrorCommand, "", NULL }, - { "buyerr", SEC_ADMINISTRATOR, &ChatHandler::HandleBuyErrorCommand, "", NULL }, - { "sendopcode", SEC_ADMINISTRATOR, &ChatHandler::HandleSendOpcodeCommand, "", NULL }, - { "uws", SEC_ADMINISTRATOR, &ChatHandler::HandleUpdateWorldStateCommand, "", NULL }, - { "ps", SEC_ADMINISTRATOR, &ChatHandler::HandlePlaySound2Command, "", NULL }, - { "scn", SEC_ADMINISTRATOR, &ChatHandler::HandleSendChannelNotifyCommand, "", NULL }, - { "scm", SEC_ADMINISTRATOR, &ChatHandler::HandleSendChatMsgCommand, "", NULL }, - { "getitemstate", SEC_ADMINISTRATOR, &ChatHandler::HandleGetItemState, "", NULL }, - { "playsound", SEC_MODERATOR, &ChatHandler::HandlePlaySoundCommand, "", NULL }, - { "update", SEC_ADMINISTRATOR, &ChatHandler::HandleUpdate, "", NULL }, - { "setvalue", SEC_ADMINISTRATOR, &ChatHandler::HandleSetValue, "", NULL }, - { "getvalue", SEC_ADMINISTRATOR, &ChatHandler::HandleGetValue, "", NULL }, - { "Mod32Value", SEC_ADMINISTRATOR, &ChatHandler::HandleMod32Value, "", NULL }, - { "anim", SEC_GAMEMASTER, &ChatHandler::HandleAnimCommand, "", NULL }, - { "lootrecipient", SEC_GAMEMASTER, &ChatHandler::HandleGetLootRecipient, "", NULL }, - { NULL, 0, NULL, "", NULL } - }; - - static ChatCommand eventCommandTable[] = - { - { "activelist", SEC_GAMEMASTER, &ChatHandler::HandleEventActiveListCommand, "", NULL }, - { "start", SEC_GAMEMASTER, &ChatHandler::HandleEventStartCommand, "", NULL }, - { "stop", SEC_GAMEMASTER, &ChatHandler::HandleEventStopCommand, "", NULL }, - { "", SEC_GAMEMASTER, &ChatHandler::HandleEventInfoCommand, "", NULL }, - { NULL, 0, NULL, "", NULL } - }; - - static ChatCommand learnCommandTable[] = - { - { "all", SEC_ADMINISTRATOR, &ChatHandler::HandleLearnAllCommand, "", NULL }, - { "all_gm", SEC_GAMEMASTER, &ChatHandler::HandleLearnAllGMCommand, "", NULL }, - { "all_crafts", SEC_GAMEMASTER, &ChatHandler::HandleLearnAllCraftsCommand, "", NULL }, - { "all_default", SEC_MODERATOR, &ChatHandler::HandleLearnAllDefaultCommand, "", NULL }, - { "all_lang", SEC_MODERATOR, &ChatHandler::HandleLearnAllLangCommand, "", NULL }, - { "all_myclass", SEC_ADMINISTRATOR, &ChatHandler::HandleLearnAllMyClassCommand, "", NULL }, - { "all_myspells", SEC_ADMINISTRATOR, &ChatHandler::HandleLearnAllMySpellsCommand, "", NULL }, - { "all_mytalents", SEC_ADMINISTRATOR, &ChatHandler::HandleLearnAllMyTalentsCommand, "", NULL }, - { "all_recipes", SEC_GAMEMASTER, &ChatHandler::HandleLearnAllRecipesCommand, "", NULL }, - { "", SEC_ADMINISTRATOR, &ChatHandler::HandleLearnCommand, "", NULL }, - { NULL, 0, NULL, "", NULL } - }; - - static ChatCommand reloadCommandTable[] = - { - { "all", SEC_ADMINISTRATOR, &ChatHandler::HandleReloadAllCommand, "", NULL }, - { "all_quest", SEC_ADMINISTRATOR, &ChatHandler::HandleReloadAllQuestCommand, "", NULL }, - { "all_loot", SEC_ADMINISTRATOR, &ChatHandler::HandleReloadAllLootCommand, "", NULL }, - { "all_scripts", SEC_ADMINISTRATOR, &ChatHandler::HandleReloadAllScriptsCommand, "", NULL }, - { "all_spell", SEC_ADMINISTRATOR, &ChatHandler::HandleReloadAllSpellCommand, "", NULL }, - { "all_item", SEC_ADMINISTRATOR, &ChatHandler::HandleReloadAllItemCommand, "", NULL }, - - { "config", SEC_ADMINISTRATOR, &ChatHandler::HandleReloadConfigCommand, "", NULL }, - - { "areatrigger_tavern", SEC_ADMINISTRATOR, &ChatHandler::HandleReloadAreaTriggerTavernCommand, "", NULL }, - { "areatrigger_teleport", SEC_ADMINISTRATOR, &ChatHandler::HandleReloadAreaTriggerTeleportCommand, "", NULL }, - { "areatrigger_involvedrelation",SEC_ADMINISTRATOR, &ChatHandler::HandleReloadQuestAreaTriggersCommand, "", NULL }, - { "event_scripts", SEC_ADMINISTRATOR, &ChatHandler::HandleReloadEventScriptsCommand, "", NULL }, - { "command", SEC_ADMINISTRATOR, &ChatHandler::HandleReloadCommandCommand, "", NULL }, - { "creature_involvedrelation", SEC_ADMINISTRATOR, &ChatHandler::HandleReloadCreatureQuestInvRelationsCommand,"",NULL }, - { "creature_loot_template", SEC_ADMINISTRATOR, &ChatHandler::HandleReloadLootTemplatesCreatureCommand, "", NULL }, - { "creature_questrelation", SEC_ADMINISTRATOR, &ChatHandler::HandleReloadCreatureQuestRelationsCommand, "", NULL }, - { "disenchant_loot_template", SEC_ADMINISTRATOR, &ChatHandler::HandleReloadLootTemplatesDisenchantCommand, "", NULL }, - { "fishing_loot_template", SEC_ADMINISTRATOR, &ChatHandler::HandleReloadLootTemplatesFishingCommand, "", NULL }, - { "game_graveyard_zone", SEC_ADMINISTRATOR, &ChatHandler::HandleReloadGameGraveyardZoneCommand, "", NULL }, - { "gameobject_involvedrelation", SEC_ADMINISTRATOR, &ChatHandler::HandleReloadGOQuestInvRelationsCommand, "", NULL }, - { "gameobject_loot_template", SEC_ADMINISTRATOR, &ChatHandler::HandleReloadLootTemplatesGameobjectCommand, "", NULL }, - { "gameobject_questrelation", SEC_ADMINISTRATOR, &ChatHandler::HandleReloadGOQuestRelationsCommand, "", NULL }, - { "gameobject_scripts", SEC_ADMINISTRATOR, &ChatHandler::HandleReloadGameObjectScriptsCommand, "", NULL }, - { "item_enchantment_template", SEC_ADMINISTRATOR, &ChatHandler::HandleReloadItemEnchantementsCommand, "", NULL }, - { "item_loot_template", SEC_ADMINISTRATOR, &ChatHandler::HandleReloadLootTemplatesItemCommand, "", NULL }, - { "mangos_string", SEC_ADMINISTRATOR, &ChatHandler::HandleReloadMangosStringCommand, "", NULL }, - { "page_text", SEC_ADMINISTRATOR, &ChatHandler::HandleReloadPageTextsCommand, "", NULL }, - { "pickpocketing_loot_template", SEC_ADMINISTRATOR, &ChatHandler::HandleReloadLootTemplatesPickpocketingCommand,"",NULL}, - { "prospecting_loot_template", SEC_ADMINISTRATOR, &ChatHandler::HandleReloadLootTemplatesProspectingCommand,"", NULL }, - { "quest_mail_loot_template", SEC_ADMINISTRATOR, &ChatHandler::HandleReloadLootTemplatesQuestMailCommand, "", NULL }, - { "quest_end_scripts", SEC_ADMINISTRATOR, &ChatHandler::HandleReloadQuestEndScriptsCommand, "", NULL }, - { "quest_start_scripts", SEC_ADMINISTRATOR, &ChatHandler::HandleReloadQuestStartScriptsCommand, "", NULL }, - { "quest_template", SEC_ADMINISTRATOR, &ChatHandler::HandleReloadQuestTemplateCommand, "", NULL }, - { "reference_loot_template", SEC_ADMINISTRATOR, &ChatHandler::HandleReloadLootTemplatesReferenceCommand, "", NULL }, - { "reserved_name", SEC_ADMINISTRATOR, &ChatHandler::HandleReloadReservedNameCommand, "", NULL }, - { "skill_discovery_template", SEC_ADMINISTRATOR, &ChatHandler::HandleReloadSkillDiscoveryTemplateCommand, "", NULL }, - { "skill_extra_item_template", SEC_ADMINISTRATOR, &ChatHandler::HandleReloadSkillExtraItemTemplateCommand, "", NULL }, - { "skill_fishing_base_level", SEC_ADMINISTRATOR, &ChatHandler::HandleReloadSkillFishingBaseLevelCommand, "", NULL }, - { "skinning_loot_template", SEC_ADMINISTRATOR, &ChatHandler::HandleReloadLootTemplatesSkinningCommand, "", NULL }, - { "spell_affect", SEC_ADMINISTRATOR, &ChatHandler::HandleReloadSpellAffectCommand, "", NULL }, - { "spell_chain", SEC_ADMINISTRATOR, &ChatHandler::HandleReloadSpellChainCommand, "", NULL }, - { "spell_elixir", SEC_ADMINISTRATOR, &ChatHandler::HandleReloadSpellElixirCommand, "", NULL }, - { "spell_learn_spell", SEC_ADMINISTRATOR, &ChatHandler::HandleReloadSpellLearnSpellCommand, "", NULL }, - { "spell_pet_auras", SEC_ADMINISTRATOR, &ChatHandler::HandleReloadSpellPetAurasCommand, "", NULL }, - { "spell_proc_event", SEC_ADMINISTRATOR, &ChatHandler::HandleReloadSpellProcEventCommand, "", NULL }, - { "spell_script_target", SEC_ADMINISTRATOR, &ChatHandler::HandleReloadSpellScriptTargetCommand, "", NULL }, - { "spell_scripts", SEC_ADMINISTRATOR, &ChatHandler::HandleReloadSpellScriptsCommand, "", NULL }, - { "spell_target_position", SEC_ADMINISTRATOR, &ChatHandler::HandleReloadSpellTargetPositionCommand, "", NULL }, - { "spell_threats", SEC_ADMINISTRATOR, &ChatHandler::HandleReloadSpellThreatsCommand, "", NULL }, - { "", SEC_ADMINISTRATOR, &ChatHandler::HandleReloadCommand, "", NULL }, - { NULL, 0, NULL, "", NULL } - }; - - static ChatCommand honorCommandTable[] = - { - { "add", SEC_GAMEMASTER, &ChatHandler::HandleAddHonorCommand, "", NULL }, - { "addkill", SEC_GAMEMASTER, &ChatHandler::HandleHonorAddKillCommand, "", NULL }, - { "update", SEC_GAMEMASTER, &ChatHandler::HandleUpdateHonorFieldsCommand, "", NULL }, - { NULL, 0, NULL, "", NULL } - }; - - static ChatCommand guildCommandTable[] = - { - { "create", SEC_GAMEMASTER, &ChatHandler::HandleGuildCreateCommand, "", NULL }, - { "delete", SEC_GAMEMASTER, &ChatHandler::HandleGuildDeleteCommand, "", NULL }, - { "invite", SEC_GAMEMASTER, &ChatHandler::HandleGuildInviteCommand, "", NULL }, - { "uninvite", SEC_GAMEMASTER, &ChatHandler::HandleGuildUninviteCommand, "", NULL }, - { "rank", SEC_GAMEMASTER, &ChatHandler::HandleGuildRankCommand, "", NULL }, - { NULL, 0, NULL, "", NULL } - }; - - static ChatCommand lookupCommandTable[] = - { - { "area", SEC_MODERATOR, &ChatHandler::HandleLookupAreaCommand, "", NULL }, - { "creature", SEC_ADMINISTRATOR, &ChatHandler::HandleLookupCreatureCommand, "", NULL }, - { "event", SEC_GAMEMASTER, &ChatHandler::HandleLookupEventCommand, "", NULL }, - { "faction", SEC_ADMINISTRATOR, &ChatHandler::HandleLookupFactionCommand, "", NULL }, - { "item", SEC_ADMINISTRATOR, &ChatHandler::HandleLookupItemCommand, "", NULL }, - { "itemset", SEC_ADMINISTRATOR, &ChatHandler::HandleLookupItemSetCommand, "", NULL }, - { "object", SEC_ADMINISTRATOR, &ChatHandler::HandleLookupObjectCommand, "", NULL }, - { "quest", SEC_ADMINISTRATOR, &ChatHandler::HandleLookupQuestCommand, "", NULL }, - { "skill", SEC_ADMINISTRATOR, &ChatHandler::HandleLookupSkillCommand, "", NULL }, - { "spell", SEC_ADMINISTRATOR, &ChatHandler::HandleLookupSpellCommand, "", NULL }, - { "tele", SEC_MODERATOR, &ChatHandler::HandleLookupTeleCommand, "", NULL }, - { NULL, 0, NULL, "", NULL } - }; - - static ChatCommand resetCommandTable[] = - { - { "honor", SEC_ADMINISTRATOR, &ChatHandler::HandleResetHonorCommand, "", NULL }, - { "level", SEC_ADMINISTRATOR, &ChatHandler::HandleResetLevelCommand, "", NULL }, - { "spells", SEC_ADMINISTRATOR, &ChatHandler::HandleResetSpellsCommand, "", NULL }, - { "stats", SEC_ADMINISTRATOR, &ChatHandler::HandleResetStatsCommand, "", NULL }, - { "talents", SEC_ADMINISTRATOR, &ChatHandler::HandleResetTalentsCommand, "", NULL }, - { "all", SEC_ADMINISTRATOR, &ChatHandler::HandleResetAllCommand, "", NULL }, - { NULL, 0, NULL, "", NULL } - }; - - static ChatCommand castCommandTable[] = - { - { "back", SEC_ADMINISTRATOR, &ChatHandler::HandleCastBackCommand, "", NULL }, - { "dist", SEC_ADMINISTRATOR, &ChatHandler::HandleCastDistCommand, "", NULL }, - { "self", SEC_ADMINISTRATOR, &ChatHandler::HandleCastSelfCommand, "", NULL }, - { "target", SEC_ADMINISTRATOR, &ChatHandler::HandleCastTargetCommand, "", NULL }, - { "", SEC_ADMINISTRATOR, &ChatHandler::HandleCastCommand, "", NULL }, - { NULL, 0, NULL, "", NULL } - }; - - static ChatCommand pdumpCommandTable[] = - { - { "load", SEC_ADMINISTRATOR, &ChatHandler::HandleLoadPDumpCommand, "", NULL }, - { "write", SEC_ADMINISTRATOR, &ChatHandler::HandleWritePDumpCommand, "", NULL }, - { NULL, 0, NULL, "", NULL } - }; - - static ChatCommand listCommandTable[] = - { - { "creature", SEC_ADMINISTRATOR, &ChatHandler::HandleListCreatureCommand, "", NULL }, - { "item", SEC_ADMINISTRATOR, &ChatHandler::HandleListItemCommand, "", NULL }, - { "object", SEC_ADMINISTRATOR, &ChatHandler::HandleListObjectCommand, "", NULL }, - { "auras", SEC_ADMINISTRATOR, &ChatHandler::HandleListAurasCommand, "", NULL }, - { NULL, 0, NULL, "", NULL } - }; - - static ChatCommand teleCommandTable[] = - { - { "add", SEC_ADMINISTRATOR, &ChatHandler::HandleAddTeleCommand, "", NULL }, - { "del", SEC_ADMINISTRATOR, &ChatHandler::HandleDelTeleCommand, "", NULL }, - { "name", SEC_MODERATOR, &ChatHandler::HandleNameTeleCommand, "", NULL }, - { "group", SEC_MODERATOR, &ChatHandler::HandleGroupTeleCommand, "", NULL }, - { "", SEC_MODERATOR, &ChatHandler::HandleTeleCommand, "", NULL }, - { NULL, 0, NULL, "", NULL } - }; - - static ChatCommand npcCommandTable[] = - { - { "say", SEC_MODERATOR, &ChatHandler::HandleSayCommand, "", NULL }, - { "whisper", SEC_MODERATOR, &ChatHandler::HandleNpcWhisperCommand, "", NULL }, - { "yell", SEC_MODERATOR, &ChatHandler::HandleYellCommand, "", NULL }, - { "textemote", SEC_MODERATOR, &ChatHandler::HandleTextEmoteCommand, "", NULL }, - { "add", SEC_GAMEMASTER, &ChatHandler::HandleAddSpwCommand, "", NULL }, - { "delete", SEC_GAMEMASTER, &ChatHandler::HandleDelCreatureCommand, "", NULL }, - { "spawndist", SEC_GAMEMASTER, &ChatHandler::HandleSpawnDistCommand, "", NULL }, - { "spawntime", SEC_GAMEMASTER, &ChatHandler::HandleSpawnTimeCommand, "", NULL }, - { "factionid", SEC_GAMEMASTER, &ChatHandler::HandleFactionIdCommand, "", NULL }, - { "addmove", SEC_GAMEMASTER, &ChatHandler::HandleAddMoveCommand, "", NULL }, - { "setmovetype", SEC_GAMEMASTER, &ChatHandler::HandleSetMoveTypeCommand, "", NULL }, - { "move", SEC_GAMEMASTER, &ChatHandler::HandleMoveCreatureCommand, "", NULL }, - { "changelevel", SEC_GAMEMASTER, &ChatHandler::HandleChangeLevelCommand, "", NULL }, - { "setmodel", SEC_GAMEMASTER, &ChatHandler::HandleSetModelCommand, "", NULL }, - { "additem", SEC_GAMEMASTER, &ChatHandler::HandleAddVendorItemCommand, "", NULL }, - { "delitem", SEC_GAMEMASTER, &ChatHandler::HandleDelVendorItemCommand, "", NULL }, - { "flag", SEC_GAMEMASTER, &ChatHandler::HandleNPCFlagCommand, "", NULL }, - { "changeentry", SEC_ADMINISTRATOR, &ChatHandler::HandleChangeEntryCommand, "", NULL }, - { "info", SEC_ADMINISTRATOR, &ChatHandler::HandleNpcInfoCommand, "", NULL }, - { "playemote", SEC_ADMINISTRATOR, &ChatHandler::HandlePlayEmoteCommand, "", NULL }, - - //{ TODO: fix or remove this commands - { "name", SEC_GAMEMASTER, &ChatHandler::HandleNameCommand, "", NULL }, - { "subname", SEC_GAMEMASTER, &ChatHandler::HandleSubNameCommand, "", NULL }, - { "addweapon", SEC_ADMINISTRATOR, &ChatHandler::HandleAddWeaponCommand, "", NULL }, - //} - - { NULL, 0, NULL, "", NULL } - }; - - static ChatCommand goCommandTable[] = - { - { "grid", SEC_MODERATOR, &ChatHandler::HandleGoGridCommand, "", NULL }, - { "creature", SEC_GAMEMASTER, &ChatHandler::HandleGoCreatureCommand, "", NULL }, - { "object", SEC_GAMEMASTER, &ChatHandler::HandleGoObjectCommand, "", NULL }, - { "trigger", SEC_GAMEMASTER, &ChatHandler::HandleGoTriggerCommand, "", NULL }, - { "graveyard", SEC_GAMEMASTER, &ChatHandler::HandleGoGraveyardCommand, "", NULL }, - { "zonexy", SEC_MODERATOR, &ChatHandler::HandleGoZoneXYCommand, "", NULL }, - { "xy", SEC_MODERATOR, &ChatHandler::HandleGoXYCommand, "", NULL }, - { "xyz", SEC_MODERATOR, &ChatHandler::HandleGoXYZCommand, "", NULL }, - { "", SEC_MODERATOR, &ChatHandler::HandleGoXYZCommand, "", NULL }, - { NULL, 0, NULL, "", NULL } - }; - - static ChatCommand gobjectCommandTable[] = - { - { "add", SEC_GAMEMASTER, &ChatHandler::HandleGameObjectCommand, "", NULL }, - { "delete", SEC_GAMEMASTER, &ChatHandler::HandleDelObjectCommand, "", NULL }, - { "target", SEC_GAMEMASTER, &ChatHandler::HandleTargetObjectCommand, "", NULL }, - { "turn", SEC_GAMEMASTER, &ChatHandler::HandleTurnObjectCommand, "", NULL }, - { "move", SEC_GAMEMASTER, &ChatHandler::HandleMoveObjectCommand, "", NULL }, - { "near", SEC_ADMINISTRATOR, &ChatHandler::HandleNearObjectCommand, "", NULL }, - { NULL, 0, NULL, "", NULL } - }; - - static ChatCommand questCommandTable[] = - { - { "add", SEC_ADMINISTRATOR, &ChatHandler::HandleAddQuest, "", NULL }, - { "complete", SEC_ADMINISTRATOR, &ChatHandler::HandleCompleteQuest, "", NULL }, - { "remove", SEC_ADMINISTRATOR, &ChatHandler::HandleRemoveQuest, "", NULL }, - { NULL, 0, NULL, "", NULL } - }; - - static ChatCommand gmCommandTable[] = - { - { "list", SEC_PLAYER, &ChatHandler::HandleGMListCommand, "", NULL }, - { "visible", SEC_MODERATOR, &ChatHandler::HandleVisibleCommand, "", NULL }, - { "fly", SEC_ADMINISTRATOR, &ChatHandler::HandleFlyModeCommand, "", NULL }, - { "", SEC_MODERATOR, &ChatHandler::HandleGMmodeCommand, "", NULL }, - { NULL, 0, NULL, "", NULL } - }; - - static ChatCommand instanceCommandTable[] = - { - { "listbinds", SEC_MODERATOR, &ChatHandler::HandleInstanceListBindsCommand, "", NULL }, - { "unbind", SEC_MODERATOR, &ChatHandler::HandleInstanceUnbindCommand, "", NULL }, - { "stats", SEC_MODERATOR, &ChatHandler::HandleInstanceStatsCommand, "", NULL }, - { "savedata", SEC_MODERATOR, &ChatHandler::HandleInstanceSaveDataCommand, "", NULL }, - { NULL, 0, NULL, "", NULL } - }; - - static ChatCommand commandTable[] = - { - { "gm", SEC_MODERATOR, NULL, "", gmCommandTable }, - { "npc", SEC_MODERATOR, NULL, "", npcCommandTable }, - { "go", SEC_MODERATOR, NULL, "", goCommandTable }, - { "learn", SEC_MODERATOR, NULL, "", learnCommandTable }, - { "modify", SEC_MODERATOR, NULL, "", modifyCommandTable }, - { "debug", SEC_MODERATOR, NULL, "", debugCommandTable }, - { "tele", SEC_MODERATOR, NULL, "", teleCommandTable }, - { "event", SEC_GAMEMASTER, NULL, "", eventCommandTable }, - { "gobject", SEC_GAMEMASTER, NULL, "", gobjectCommandTable }, - { "honor", SEC_GAMEMASTER, NULL, "", honorCommandTable }, - { "wp", SEC_GAMEMASTER, NULL, "", wpCommandTable }, - { "quest", SEC_ADMINISTRATOR, NULL, "", questCommandTable }, - { "reload", SEC_ADMINISTRATOR, NULL, "", reloadCommandTable }, - { "list", SEC_ADMINISTRATOR, NULL, "", listCommandTable }, - { "lookup", SEC_ADMINISTRATOR, NULL, "", lookupCommandTable }, - { "pdump", SEC_ADMINISTRATOR, NULL, "", pdumpCommandTable }, - { "guild", SEC_ADMINISTRATOR, NULL, "", guildCommandTable }, - { "cast", SEC_ADMINISTRATOR, NULL, "", castCommandTable }, - { "reset", SEC_ADMINISTRATOR, NULL, "", resetCommandTable }, - { "instance", SEC_ADMINISTRATOR, NULL, "", instanceCommandTable }, - { "server", SEC_ADMINISTRATOR, NULL, "", serverCommandTable }, - - { "aura", SEC_ADMINISTRATOR, &ChatHandler::HandleAuraCommand, "", NULL }, - { "unaura", SEC_ADMINISTRATOR, &ChatHandler::HandleUnAuraCommand, "", NULL }, - { "acct", SEC_PLAYER, &ChatHandler::HandleAcctCommand, "", NULL }, - { "announce", SEC_MODERATOR, &ChatHandler::HandleAnnounceCommand, "", NULL }, - { "notify", SEC_MODERATOR, &ChatHandler::HandleNotifyCommand, "", NULL }, - { "goname", SEC_MODERATOR, &ChatHandler::HandleGonameCommand, "", NULL }, - { "namego", SEC_MODERATOR, &ChatHandler::HandleNamegoCommand, "", NULL }, - { "groupgo", SEC_MODERATOR, &ChatHandler::HandleGroupgoCommand, "", NULL }, - { "commands", SEC_PLAYER, &ChatHandler::HandleCommandsCommand, "", NULL }, - { "demorph", SEC_GAMEMASTER, &ChatHandler::HandleDeMorphCommand, "", NULL }, - { "die", SEC_ADMINISTRATOR, &ChatHandler::HandleDieCommand, "", NULL }, - { "revive", SEC_ADMINISTRATOR, &ChatHandler::HandleReviveCommand, "", NULL }, - { "dismount", SEC_PLAYER, &ChatHandler::HandleDismountCommand, "", NULL }, - { "gps", SEC_MODERATOR, &ChatHandler::HandleGPSCommand, "", NULL }, - { "guid", SEC_GAMEMASTER, &ChatHandler::HandleGUIDCommand, "", NULL }, - { "help", SEC_PLAYER, &ChatHandler::HandleHelpCommand, "", NULL }, - { "itemmove", SEC_GAMEMASTER, &ChatHandler::HandleItemMoveCommand, "", NULL }, - { "cooldown", SEC_ADMINISTRATOR, &ChatHandler::HandleCooldownCommand, "", NULL }, - { "unlearn", SEC_ADMINISTRATOR, &ChatHandler::HandleUnLearnCommand, "", NULL }, - { "distance", SEC_ADMINISTRATOR, &ChatHandler::HandleGetDistanceCommand, "", NULL }, - { "recall", SEC_MODERATOR, &ChatHandler::HandleRecallCommand, "", NULL }, - { "save", SEC_PLAYER, &ChatHandler::HandleSaveCommand, "", NULL }, - { "saveall", SEC_MODERATOR, &ChatHandler::HandleSaveAllCommand, "", NULL }, - { "kick", SEC_GAMEMASTER, &ChatHandler::HandleKickPlayerCommand, "", NULL }, - { "security", SEC_ADMINISTRATOR, &ChatHandler::HandleSecurityCommand, "", NULL }, - { "ban", SEC_ADMINISTRATOR, &ChatHandler::HandleBanCommand, "", NULL }, - { "unban", SEC_ADMINISTRATOR, &ChatHandler::HandleUnBanCommand, "", NULL }, - { "baninfo", SEC_ADMINISTRATOR, &ChatHandler::HandleBanInfoCommand, "", NULL }, - { "banlist", SEC_ADMINISTRATOR, &ChatHandler::HandleBanListCommand, "", NULL }, - { "plimit", SEC_ADMINISTRATOR, &ChatHandler::HandlePLimitCommand, "", NULL }, - { "start", SEC_PLAYER, &ChatHandler::HandleStartCommand, "", NULL }, - { "taxicheat", SEC_MODERATOR, &ChatHandler::HandleTaxiCheatCommand, "", NULL }, - { "allowmove", SEC_ADMINISTRATOR, &ChatHandler::HandleAllowMovementCommand, "", NULL }, - { "linkgrave", SEC_ADMINISTRATOR, &ChatHandler::HandleLinkGraveCommand, "", NULL }, - { "neargrave", SEC_ADMINISTRATOR, &ChatHandler::HandleNearGraveCommand, "", NULL }, - { "transport", SEC_ADMINISTRATOR, &ChatHandler::HandleSpawnTransportCommand, "", NULL }, - { "explorecheat", SEC_ADMINISTRATOR, &ChatHandler::HandleExploreCheatCommand, "", NULL }, - { "hover", SEC_ADMINISTRATOR, &ChatHandler::HandleHoverCommand, "", NULL }, - { "levelup", SEC_ADMINISTRATOR, &ChatHandler::HandleLevelUpCommand, "", NULL }, - { "showarea", SEC_ADMINISTRATOR, &ChatHandler::HandleShowAreaCommand, "", NULL }, - { "hidearea", SEC_ADMINISTRATOR, &ChatHandler::HandleHideAreaCommand, "", NULL }, - { "additem", SEC_ADMINISTRATOR, &ChatHandler::HandleAddItemCommand, "", NULL }, - { "additemset", SEC_ADMINISTRATOR, &ChatHandler::HandleAddItemSetCommand, "", NULL }, - { "bank", SEC_ADMINISTRATOR, &ChatHandler::HandleBankCommand, "", NULL }, - { "wchange", SEC_ADMINISTRATOR, &ChatHandler::HandleChangeWeather, "", NULL }, - { "ticket", SEC_GAMEMASTER, &ChatHandler::HandleTicketCommand, "", NULL }, - { "delticket", SEC_GAMEMASTER, &ChatHandler::HandleDelTicketCommand, "", NULL }, - { "maxskill", SEC_ADMINISTRATOR, &ChatHandler::HandleMaxSkillCommand, "", NULL }, - { "setskill", SEC_ADMINISTRATOR, &ChatHandler::HandleSetSkillCommand, "", NULL }, - { "whispers", SEC_MODERATOR, &ChatHandler::HandleWhispersCommand, "", NULL }, - { "pinfo", SEC_GAMEMASTER, &ChatHandler::HandlePInfoCommand, "", NULL }, - { "password", SEC_PLAYER, &ChatHandler::HandlePasswordCommand, "", NULL }, - { "lockaccount", SEC_PLAYER, &ChatHandler::HandleLockAccountCommand, "", NULL }, - { "respawn", SEC_ADMINISTRATOR, &ChatHandler::HandleRespawnCommand, "", NULL }, - { "sendmail", SEC_MODERATOR, &ChatHandler::HandleSendMailCommand, "", NULL }, - { "rename", SEC_GAMEMASTER, &ChatHandler::HandleRenameCommand, "", NULL }, - { "loadscripts", SEC_ADMINISTRATOR, &ChatHandler::HandleLoadScriptsCommand, "", NULL }, - { "mute", SEC_GAMEMASTER, &ChatHandler::HandleMuteCommand, "", NULL }, - { "unmute", SEC_GAMEMASTER, &ChatHandler::HandleUnmuteCommand, "", NULL }, - { "movegens", SEC_ADMINISTRATOR, &ChatHandler::HandleMovegensCommand, "", NULL }, - { "cometome", SEC_ADMINISTRATOR, &ChatHandler::HandleComeToMeCommand, "", NULL }, - { "damage", SEC_ADMINISTRATOR, &ChatHandler::HandleDamageCommand, "", NULL }, - { "combatstop", SEC_GAMEMASTER, &ChatHandler::HandleCombatStopCommand, "", NULL }, - - { NULL, 0, NULL, "", NULL } - }; - - if(load_command_table) - { - load_command_table = false; - - QueryResult *result = WorldDatabase.Query("SELECT name,security,help FROM command"); - if (result) - { - do - { - Field *fields = result->Fetch(); - std::string name = fields[0].GetCppString(); - for(uint32 i = 0; commandTable[i].Name != NULL; i++) - { - if (name == commandTable[i].Name) - { - commandTable[i].SecurityLevel = (uint16)fields[1].GetUInt16(); - commandTable[i].Help = fields[2].GetCppString(); - } - if(commandTable[i].ChildCommands != NULL) - { - ChatCommand *ptable = commandTable[i].ChildCommands; - for(uint32 j = 0; ptable[j].Name != NULL; j++) - { - // first case for "" named subcommand - if (ptable[j].Name[0]=='\0' && name == commandTable[i].Name || - name == fmtstring("%s %s", commandTable[i].Name, ptable[j].Name) ) - { - ptable[j].SecurityLevel = (uint16)fields[1].GetUInt16(); - ptable[j].Help = fields[2].GetCppString(); - } - } - } - } - } while(result->NextRow()); - delete result; - } - } - - return commandTable; -} - -const char *ChatHandler::GetMangosString(int32 entry) -{ - return m_session->GetMangosString(entry); -} - -bool ChatHandler::hasStringAbbr(const char* s1, const char* s2) -{ - for(;;) - { - if( !*s2 ) - return true; - else if( !*s1 ) - return false; - else if( tolower( *s1 ) != tolower( *s2 ) ) - return false; - ++s1; ++s2; - } -} - -void ChatHandler::SendSysMessage(const char *str) -{ - WorldPacket data; - - // need copy to prevent corruption by strtok call in LineFromMessage original string - char* buf = strdup(str); - char* pos = buf; - - while(char* line = LineFromMessage(pos)) - { - FillSystemMessageData(&data, line); - m_session->SendPacket(&data); - } - - free(buf); -} - -void ChatHandler::SendGlobalSysMessage(const char *str) -{ - WorldPacket data; - - // need copy to prevent corruption by strtok call in LineFromMessage original string - char* buf = strdup(str); - char* pos = buf; - - while(char* line = LineFromMessage(pos)) - { - FillSystemMessageData(&data, line); - sWorld.SendGlobalMessage(&data); - } - - free(buf); -} - -void ChatHandler::SendSysMessage(int32 entry) -{ - SendSysMessage(GetMangosString(entry)); -} - -void ChatHandler::PSendSysMessage(int32 entry, ...) -{ - const char *format = GetMangosString(entry); - va_list ap; - char str [1024]; - va_start(ap, entry); - vsnprintf(str,1024,format, ap ); - va_end(ap); - SendSysMessage(str); -} - -void ChatHandler::PSendSysMessage(const char *format, ...) -{ - va_list ap; - char str [1024]; - va_start(ap, format); - vsnprintf(str,1024,format, ap ); - va_end(ap); - SendSysMessage(str); -} - -bool ChatHandler::ExecuteCommandInTable(ChatCommand *table, const char* text, std::string fullcmd) -{ - char const* oldtext = text; - std::string cmd = ""; - - while (*text != ' ' && *text != '\0') - { - cmd += *text; - ++text; - } - - while (*text == ' ') ++text; - - if(!cmd.length()) - return false; - - for(uint32 i = 0; table[i].Name != NULL; i++) - { - // allow pass "" command name in table - if(strlen(table[i].Name) && !hasStringAbbr(table[i].Name, cmd.c_str())) - continue; - - // select subcommand from child commands list - if(table[i].ChildCommands != NULL) - { - if(!ExecuteCommandInTable(table[i].ChildCommands, text, fullcmd)) - { - if(text && text[0] != '\0') - SendSysMessage(LANG_NO_SUBCMD); - else - SendSysMessage(LANG_CMD_SYNTAX); - - ShowHelpForCommand(table[i].ChildCommands,text); - } - - return true; - } - - // check security level only for simple command (without child commands) - if(m_session->GetSecurity() < table[i].SecurityLevel) - continue; - - SetSentErrorMessage(false); - // table[i].Name == "" is special case: send original command to handler - if((this->*(table[i].Handler))(strlen(table[i].Name)!=0 ? text : oldtext)) - { - if(table[i].SecurityLevel > SEC_PLAYER) - { - Player* p = m_session->GetPlayer(); - uint64 sel_guid = p->GetSelection(); - sLog.outCommand("Command: %s [Player: %s (Account: %u) X: %f Y: %f Z: %f Map: %u Selected: %s (GUID: %u)]", - fullcmd.c_str(),p->GetName(),m_session->GetAccountId(),p->GetPositionX(),p->GetPositionY(),p->GetPositionZ(),p->GetMapId(), - GetLogNameForGuid(sel_guid),GUID_LOPART(sel_guid)); - } - } - // some commands have custom error messages. Don't send the default one in these cases. - else if(!sentErrorMessage) - { - if(!table[i].Help.empty()) - SendSysMessage(table[i].Help.c_str()); - else - SendSysMessage(LANG_CMD_SYNTAX); - } - - return true; - } - - return false; -} - -int ChatHandler::ParseCommands(const char* text) -{ - ASSERT(text); - ASSERT(*text); - - //if(m_session->GetSecurity() == 0) - // return 0; - - if(text[0] != '!' && text[0] != '.') - return 0; - - // ignore single . and ! in line - if(strlen(text) < 2) - return 0; - - // ignore messages staring from many dots. - if(text[0] == '.' && text[1] == '.' || text[0] == '!' && text[1] == '!') - return 0; - - ++text; - - std::string fullcmd = text; // original `text` can't be used. It content destroyed in command code processing. - - if(!ExecuteCommandInTable(getCommandTable(), text, fullcmd)) - SendSysMessage(LANG_NO_CMD); - - return 1; -} - -bool ChatHandler::ShowHelpForSubCommands(ChatCommand *table, char const* cmd, char const* subcmd) -{ - std::string list; - for(uint32 i = 0; table[i].Name != NULL; ++i) - { - if(m_session->GetSecurity() < table[i].SecurityLevel) - continue; - - if(strlen(table[i].Name) && !hasStringAbbr(table[i].Name, subcmd)) - continue; - - (list += "\n ") += table[i].Name; - } - - if(list.empty()) - return false; - - if(table==getCommandTable()) - { - SendSysMessage(LANG_AVIABLE_CMD); - PSendSysMessage("%s",list.c_str()); - } - else - PSendSysMessage(LANG_SUBCMDS_LIST,cmd,list.c_str()); - - return true; -} - -bool ChatHandler::ShowHelpForCommand(ChatCommand *table, const char* cmd) -{ - if(*cmd) - { - for(uint32 i = 0; table[i].Name != NULL; ++i) - { - if(m_session->GetSecurity() < table[i].SecurityLevel) - continue; - - if(strlen(table[i].Name) && !hasStringAbbr(table[i].Name, cmd)) - continue; - - // have subcommand - char const* subcmd = (*cmd) ? strtok(NULL, " ") : ""; - - if(table[i].ChildCommands && subcmd && *subcmd) - { - if(ShowHelpForCommand(table[i].ChildCommands, subcmd)) - return true; - } - - if(!table[i].Help.empty()) - SendSysMessage(table[i].Help.c_str()); - - if(table[i].ChildCommands) - if(ShowHelpForSubCommands(table[i].ChildCommands,table[i].Name,subcmd ? subcmd : "")) - return true; - - return !table[i].Help.empty(); - } - } - else - { - for(uint32 i = 0; table[i].Name != NULL; ++i) - { - if(m_session->GetSecurity() < table[i].SecurityLevel) - continue; - - if(strlen(table[i].Name)) - continue; - - if(!table[i].Help.empty()) - SendSysMessage(table[i].Help.c_str()); - - if(table[i].ChildCommands) - if(ShowHelpForSubCommands(table[i].ChildCommands,"","")) - return true; - - return !table[i].Help.empty(); - } - } - - return ShowHelpForSubCommands(table,"",cmd); -} - -//Note: target_guid used only in CHAT_MSG_WHISPER_INFORM mode (in this case channelName ignored) -void ChatHandler::FillMessageData( WorldPacket *data, WorldSession* session, uint8 type, uint32 language, const char *channelName, uint64 target_guid, const char *message, Unit *speaker) -{ - uint32 messageLength = (message ? strlen(message) : 0) + 1; - - data->Initialize(SMSG_MESSAGECHAT, 100); // guess size - *data << uint8(type); - if ((type != CHAT_MSG_CHANNEL && type != CHAT_MSG_WHISPER) || language == LANG_ADDON) - *data << uint32(language); - else - *data << uint32(LANG_UNIVERSAL); - - switch(type) - { - case CHAT_MSG_SAY: - case CHAT_MSG_PARTY: - case CHAT_MSG_RAID: - case CHAT_MSG_GUILD: - case CHAT_MSG_OFFICER: - case CHAT_MSG_YELL: - case CHAT_MSG_WHISPER: - case CHAT_MSG_CHANNEL: - case CHAT_MSG_RAID_LEADER: - case CHAT_MSG_RAID_WARNING: - case CHAT_MSG_BG_SYSTEM_NEUTRAL: - case CHAT_MSG_BG_SYSTEM_ALLIANCE: - case CHAT_MSG_BG_SYSTEM_HORDE: - case CHAT_MSG_BATTLEGROUND: - case CHAT_MSG_BATTLEGROUND_LEADER: - target_guid = session ? session->GetPlayer()->GetGUID() : 0; - break; - case CHAT_MSG_MONSTER_SAY: - case CHAT_MSG_MONSTER_PARTY: - case CHAT_MSG_MONSTER_YELL: - case CHAT_MSG_MONSTER_WHISPER: - case CHAT_MSG_MONSTER_EMOTE: - case CHAT_MSG_RAID_BOSS_WHISPER: - case CHAT_MSG_RAID_BOSS_EMOTE: - { - *data << uint64(speaker->GetGUID()); - *data << uint32(0); // 2.1.0 - *data << uint32(strlen(speaker->GetName()) + 1); - *data << speaker->GetName(); - uint64 listener_guid = 0; - *data << uint64(listener_guid); - if(listener_guid && !IS_PLAYER_GUID(listener_guid)) - { - *data << uint32(1); // string listener_name_length - *data << uint8(0); // string listener_name - } - *data << uint32(messageLength); - *data << message; - *data << uint8(0); - return; - } - default: - if (type != CHAT_MSG_REPLY && type != CHAT_MSG_IGNORED && type != CHAT_MSG_DND && type != CHAT_MSG_AFK) - target_guid = 0; // only for CHAT_MSG_WHISPER_INFORM used original value target_guid - break; - } - - *data << uint64(target_guid); // there 0 for BG messages - *data << uint32(0); // can be chat msg group or something - - if (type == CHAT_MSG_CHANNEL) - { - ASSERT(channelName); - *data << channelName; - } - - *data << uint64(target_guid); - *data << uint32(messageLength); - *data << message; - if(session != 0 && type != CHAT_MSG_REPLY && type != CHAT_MSG_DND && type != CHAT_MSG_AFK) - *data << uint8(session->GetPlayer()->chatTag()); - else - *data << uint8(0); -} - -Player * ChatHandler::getSelectedPlayer() -{ - uint64 guid = m_session->GetPlayer()->GetSelection(); - - if (guid == 0) - return m_session->GetPlayer(); - - return objmgr.GetPlayer(guid); -} - -Unit* ChatHandler::getSelectedUnit() -{ - uint64 guid = m_session->GetPlayer()->GetSelection(); - - if (guid == 0) - return m_session->GetPlayer(); - - return ObjectAccessor::GetUnit(*m_session->GetPlayer(),guid); -} - -Creature* ChatHandler::getSelectedCreature() -{ - return ObjectAccessor::GetCreatureOrPet(*m_session->GetPlayer(),m_session->GetPlayer()->GetSelection()); -} - -char* ChatHandler::extractKeyFromLink(char* text, char const* linkType, char** something1) -{ - // skip empty - if(!text) - return NULL; - - // skip speces - while(*text==' '||*text=='\t'||*text=='\b') - ++text; - - if(!*text) - return NULL; - - // return non link case - if(text[0]!='|') - return strtok(text, " "); - - // [name] Shift-click form |color|linkType:key|h[name]|h|r - // or - // [name] Shift-click form |color|linkType:key:something1:...:somethingN|h[name]|h|r - - char* check = strtok(text, "|"); // skip color - if(!check) - return NULL; // end of data - - char* cLinkType = strtok(NULL, ":"); // linktype - if(!cLinkType) - return NULL; // end of data - - if(strcmp(cLinkType,linkType) != 0) - { - strtok(NULL, " "); // skip link tail (to allow continue strtok(NULL,s) use after retturn from function - SendSysMessage(LANG_WRONG_LINK_TYPE); - return NULL; - } - - char* cKeys = strtok(NULL, "|"); // extract keys and values - char* cKeysTail = strtok(NULL, ""); - - char* cKey = strtok(cKeys, ":|"); // extract key - if(something1) - *something1 = strtok(NULL, ":|"); // extract something - - strtok(cKeysTail, "]"); // restart scan tail and skip name with possible spaces - strtok(NULL, " "); // skip link tail (to allow continue strtok(NULL,s) use after retturn from function - return cKey; -} - -char* ChatHandler::extractKeyFromLink(char* text, char const* const* linkTypes, int* found_idx, char** something1) -{ - // skip empty - if(!text) - return NULL; - - // skip speces - while(*text==' '||*text=='\t'||*text=='\b') - ++text; - - if(!*text) - return NULL; - - // return non link case - if(text[0]!='|') - return strtok(text, " "); - - // [name] Shift-click form |color|linkType:key|h[name]|h|r - // or - // [name] Shift-click form |color|linkType:key:something1:...:somethingN|h[name]|h|r - - char* check = strtok(text, "|"); // skip color - if(!check) - return NULL; // end of data - - char* cLinkType = strtok(NULL, ":"); // linktype - if(!cLinkType) - return NULL; // end of data - - for(int i = 0; linkTypes[i]; ++i) - { - if(strcmp(cLinkType,linkTypes[i]) == 0) - { - char* cKeys = strtok(NULL, "|"); // extract keys and values - char* cKeysTail = strtok(NULL, ""); - - char* cKey = strtok(cKeys, ":|"); // extract key - if(something1) - *something1 = strtok(NULL, ":|"); // extract something - - strtok(cKeysTail, "]"); // restart scan tail and skip name with possible spaces - strtok(NULL, " "); // skip link tail (to allow continue strtok(NULL,s) use after return from function - if(found_idx) - *found_idx = i; - return cKey; - } - } - - strtok(NULL, " "); // skip link tail (to allow continue strtok(NULL,s) use after return from function - SendSysMessage(LANG_WRONG_LINK_TYPE); - return NULL; -} - -char const *fmtstring( char const *format, ... ) -{ - va_list argptr; - #define MAX_FMT_STRING 32000 - static char temp_buffer[MAX_FMT_STRING]; - static char string[MAX_FMT_STRING]; - static int index = 0; - char *buf; - int len; - - va_start(argptr, format); - vsnprintf(temp_buffer,MAX_FMT_STRING, format, argptr); - va_end(argptr); - - len = strlen(temp_buffer); - - if( len >= MAX_FMT_STRING ) - return "ERROR"; - - if (len + index >= MAX_FMT_STRING-1) - { - index = 0; - } - - buf = &string[index]; - memcpy( buf, temp_buffer, len+1 ); - - index += len + 1; - - return buf; -} - -GameObject* ChatHandler::GetObjectGlobalyWithGuidOrNearWithDbGuid(uint32 lowguid,uint32 entry) -{ - Player* pl = m_session->GetPlayer(); - - GameObject* obj = ObjectAccessor::GetGameObject(*pl, MAKE_NEW_GUID(lowguid, entry, HIGHGUID_GAMEOBJECT)); - - if(!obj && objmgr.GetGOData(lowguid)) // guid is DB guid of object - { - // search near player then - CellPair p(MaNGOS::ComputeCellPair(pl->GetPositionX(), pl->GetPositionY())); - Cell cell(p); - cell.data.Part.reserved = ALL_DISTRICT; - - MaNGOS::GameObjectWithDbGUIDCheck go_check(*pl,lowguid); - MaNGOS::GameObjectSearcher checker(obj,go_check); - - TypeContainerVisitor, GridTypeMapContainer > object_checker(checker); - CellLock cell_lock(cell, p); - cell_lock->Visit(cell_lock, object_checker, *MapManager::Instance().GetMap(pl->GetMapId(), pl)); - } - - return obj; -} - -static char const* const spellTalentKeys[] = { - "Hspell", - "Htalent", - 0 -}; - -uint32 ChatHandler::extractSpellIdFromLink(char* text) -{ - // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r - // number or [name] Shift-click form |color|Htalent:telen_id,rank|h[name]|h|r - int type = 0; - char* rankS = NULL; - char* idS = extractKeyFromLink(text,spellTalentKeys,&type,&rankS); - if(!idS) - return 0; - - uint32 id = (uint32)atol(idS); - - // spell - if(type==0) - return id; - - // talent - TalentEntry const* talentEntry = sTalentStore.LookupEntry(id); - if(!talentEntry) - return 0; - - int32 rank = rankS ? (uint32)atol(rankS) : 0; - if(rank >= 5) - return 0; - - if(rank < 0) - rank = 0; - - return talentEntry->RankID[rank]; -} - +/* + * Copyright (C) 2005-2008 MaNGOS + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "Common.h" +#include "Language.h" +#include "Database/DatabaseEnv.h" +#include "WorldPacket.h" +#include "WorldSession.h" +#include "Opcodes.h" +#include "Log.h" +#include "World.h" +#include "ObjectMgr.h" +#include "Player.h" +#include "UpdateMask.h" +#include "Chat.h" +#include "MapManager.h" +#include "GridNotifiersImpl.h" +#include "CellImpl.h" + +bool ChatHandler::load_command_table = true; + +LanguageDesc lang_description[LANGUAGES_COUNT] = +{ + { LANG_ADDON, 0, 0 }, + { LANG_UNIVERSAL, 0, 0 }, + { LANG_ORCISH, 669, SKILL_LANG_ORCISH }, + { LANG_DARNASSIAN, 671, SKILL_LANG_DARNASSIAN }, + { LANG_TAURAHE, 670, SKILL_LANG_TAURAHE }, + { LANG_DWARVISH, 672, SKILL_LANG_DWARVEN }, + { LANG_COMMON, 668, SKILL_LANG_COMMON }, + { LANG_DEMONIC, 815, SKILL_LANG_DEMON_TONGUE }, + { LANG_TITAN, 816, SKILL_LANG_TITAN }, + { LANG_THALASSIAN, 813, SKILL_LANG_THALASSIAN }, + { LANG_DRACONIC, 814, SKILL_LANG_DRACONIC }, + { LANG_KALIMAG, 817, SKILL_LANG_OLD_TONGUE }, + { LANG_GNOMISH, 7340, SKILL_LANG_GNOMISH }, + { LANG_TROLL, 7341, SKILL_LANG_TROLL }, + { LANG_GUTTERSPEAK, 17737, SKILL_LANG_GUTTERSPEAK }, + { LANG_DRAENEI, 29932, SKILL_LANG_DRAENEI }, + { LANG_ZOMBIE, 0, 0 }, + { LANG_GNOMISH_BINARY, 0, 0 }, + { LANG_GOBLIN_BINARY, 0, 0 } +}; + +LanguageDesc const* GetLanguageDescByID(uint32 lang) +{ + for(int i = 0; i < LANGUAGES_COUNT; ++i) + { + if(uint32(lang_description[i].lang_id) == lang) + return &lang_description[i]; + } + + return NULL; +} + +LanguageDesc const* GetLanguageDescBySpell(uint32 spell_id) +{ + for(int i = 0; i < LANGUAGES_COUNT; ++i) + { + if(lang_description[i].spell_id == spell_id) + return &lang_description[i]; + } + + return NULL; +} + +LanguageDesc const* GetLanguageDescBySkill(uint32 skill_id) +{ + for(int i = 0; i < LANGUAGES_COUNT; ++i) + { + if(lang_description[i].skill_id == skill_id) + return &lang_description[i]; + } + + return NULL; +} + +ChatCommand * ChatHandler::getCommandTable() +{ + static ChatCommand serverCommandTable[] = + { + { "idlerestart", SEC_ADMINISTRATOR, &ChatHandler::HandleIdleRestartCommand, "", NULL }, + { "idleshutdown", SEC_ADMINISTRATOR, &ChatHandler::HandleIdleShutDownCommand, "", NULL }, + { "info", SEC_PLAYER, &ChatHandler::HandleInfoCommand, "", NULL }, + { "restart", SEC_ADMINISTRATOR, &ChatHandler::HandleRestartCommand, "", NULL }, + { "shutdown", SEC_ADMINISTRATOR, &ChatHandler::HandleShutDownCommand, "", NULL }, + { NULL, 0, NULL, "", NULL } + }; + + static ChatCommand modifyCommandTable[] = + { + { "hp", SEC_MODERATOR, &ChatHandler::HandleModifyHPCommand, "", NULL }, + { "mana", SEC_MODERATOR, &ChatHandler::HandleModifyManaCommand, "", NULL }, + { "rage", SEC_MODERATOR, &ChatHandler::HandleModifyRageCommand, "", NULL }, + { "energy", SEC_MODERATOR, &ChatHandler::HandleModifyEnergyCommand, "", NULL }, + { "money", SEC_MODERATOR, &ChatHandler::HandleModifyMoneyCommand, "", NULL }, + { "speed", SEC_MODERATOR, &ChatHandler::HandleModifySpeedCommand, "", NULL }, + { "swim", SEC_MODERATOR, &ChatHandler::HandleModifySwimCommand, "", NULL }, + { "scale", SEC_MODERATOR, &ChatHandler::HandleModifyScaleCommand, "", NULL }, + { "bit", SEC_MODERATOR, &ChatHandler::HandleModifyBitCommand, "", NULL }, + { "bwalk", SEC_MODERATOR, &ChatHandler::HandleModifyBWalkCommand, "", NULL }, + { "fly", SEC_MODERATOR, &ChatHandler::HandleModifyFlyCommand, "", NULL }, + { "aspeed", SEC_MODERATOR, &ChatHandler::HandleModifyASpeedCommand, "", NULL }, + { "faction", SEC_MODERATOR, &ChatHandler::HandleModifyFactionCommand, "", NULL }, + { "spell", SEC_MODERATOR, &ChatHandler::HandleModifySpellCommand, "", NULL }, + { "tp", SEC_MODERATOR, &ChatHandler::HandleModifyTalentCommand, "", NULL }, + { "titles", SEC_MODERATOR, &ChatHandler::HandleModifyKnownTitlesCommand, "", NULL }, + { "mount", SEC_MODERATOR, &ChatHandler::HandleModifyMountCommand, "", NULL }, + { "honor", SEC_MODERATOR, &ChatHandler::HandleModifyHonorCommand, "", NULL }, + { "rep", SEC_MODERATOR, &ChatHandler::HandleModifyRepCommand, "", NULL }, + { "arena", SEC_MODERATOR, &ChatHandler::HandleModifyArenaCommand, "", NULL }, + { "drunk", SEC_MODERATOR, &ChatHandler::HandleDrunkCommand, "", NULL }, + { "standstate", SEC_GAMEMASTER, &ChatHandler::HandleStandStateCommand, "", NULL }, + { "morph", SEC_GAMEMASTER, &ChatHandler::HandleMorphCommand, "", NULL }, + { NULL, 0, NULL, "", NULL } + }; + + static ChatCommand wpCommandTable[] = + { + { "show", SEC_GAMEMASTER, &ChatHandler::HandleWpShowCommand, "", NULL }, + { "add", SEC_GAMEMASTER, &ChatHandler::HandleWpAddCommand, "", NULL }, + { "modify", SEC_GAMEMASTER, &ChatHandler::HandleWpModifyCommand, "", NULL }, + { "export", SEC_ADMINISTRATOR, &ChatHandler::HandleWpExportCommand, "", NULL }, + { "import", SEC_ADMINISTRATOR, &ChatHandler::HandleWpImportCommand, "", NULL }, + { NULL, 0, NULL, "", NULL } + }; + + static ChatCommand debugCommandTable[] = + { + { "inarc", SEC_ADMINISTRATOR, &ChatHandler::HandleDebugInArcCommand, "", NULL }, + { "spellfail", SEC_ADMINISTRATOR, &ChatHandler::HandleDebugSpellFailCommand, "", NULL }, + { "setpoi", SEC_ADMINISTRATOR, &ChatHandler::HandleSetPoiCommand, "", NULL }, + { "qpartymsg", SEC_ADMINISTRATOR, &ChatHandler::HandleSendQuestPartyMsgCommand, "", NULL }, + { "qinvalidmsg", SEC_ADMINISTRATOR, &ChatHandler::HandleSendQuestInvalidMsgCommand, "", NULL }, + { "equiperr", SEC_ADMINISTRATOR, &ChatHandler::HandleEquipErrorCommand, "", NULL }, + { "sellerr", SEC_ADMINISTRATOR, &ChatHandler::HandleSellErrorCommand, "", NULL }, + { "buyerr", SEC_ADMINISTRATOR, &ChatHandler::HandleBuyErrorCommand, "", NULL }, + { "sendopcode", SEC_ADMINISTRATOR, &ChatHandler::HandleSendOpcodeCommand, "", NULL }, + { "uws", SEC_ADMINISTRATOR, &ChatHandler::HandleUpdateWorldStateCommand, "", NULL }, + { "ps", SEC_ADMINISTRATOR, &ChatHandler::HandlePlaySound2Command, "", NULL }, + { "scn", SEC_ADMINISTRATOR, &ChatHandler::HandleSendChannelNotifyCommand, "", NULL }, + { "scm", SEC_ADMINISTRATOR, &ChatHandler::HandleSendChatMsgCommand, "", NULL }, + { "getitemstate", SEC_ADMINISTRATOR, &ChatHandler::HandleGetItemState, "", NULL }, + { "playsound", SEC_MODERATOR, &ChatHandler::HandlePlaySoundCommand, "", NULL }, + { "update", SEC_ADMINISTRATOR, &ChatHandler::HandleUpdate, "", NULL }, + { "setvalue", SEC_ADMINISTRATOR, &ChatHandler::HandleSetValue, "", NULL }, + { "getvalue", SEC_ADMINISTRATOR, &ChatHandler::HandleGetValue, "", NULL }, + { "Mod32Value", SEC_ADMINISTRATOR, &ChatHandler::HandleMod32Value, "", NULL }, + { "anim", SEC_GAMEMASTER, &ChatHandler::HandleAnimCommand, "", NULL }, + { "lootrecipient", SEC_GAMEMASTER, &ChatHandler::HandleGetLootRecipient, "", NULL }, + { NULL, 0, NULL, "", NULL } + }; + + static ChatCommand eventCommandTable[] = + { + { "activelist", SEC_GAMEMASTER, &ChatHandler::HandleEventActiveListCommand, "", NULL }, + { "start", SEC_GAMEMASTER, &ChatHandler::HandleEventStartCommand, "", NULL }, + { "stop", SEC_GAMEMASTER, &ChatHandler::HandleEventStopCommand, "", NULL }, + { "", SEC_GAMEMASTER, &ChatHandler::HandleEventInfoCommand, "", NULL }, + { NULL, 0, NULL, "", NULL } + }; + + static ChatCommand learnCommandTable[] = + { + { "all", SEC_ADMINISTRATOR, &ChatHandler::HandleLearnAllCommand, "", NULL }, + { "all_gm", SEC_GAMEMASTER, &ChatHandler::HandleLearnAllGMCommand, "", NULL }, + { "all_crafts", SEC_GAMEMASTER, &ChatHandler::HandleLearnAllCraftsCommand, "", NULL }, + { "all_default", SEC_MODERATOR, &ChatHandler::HandleLearnAllDefaultCommand, "", NULL }, + { "all_lang", SEC_MODERATOR, &ChatHandler::HandleLearnAllLangCommand, "", NULL }, + { "all_myclass", SEC_ADMINISTRATOR, &ChatHandler::HandleLearnAllMyClassCommand, "", NULL }, + { "all_myspells", SEC_ADMINISTRATOR, &ChatHandler::HandleLearnAllMySpellsCommand, "", NULL }, + { "all_mytalents", SEC_ADMINISTRATOR, &ChatHandler::HandleLearnAllMyTalentsCommand, "", NULL }, + { "all_recipes", SEC_GAMEMASTER, &ChatHandler::HandleLearnAllRecipesCommand, "", NULL }, + { "", SEC_ADMINISTRATOR, &ChatHandler::HandleLearnCommand, "", NULL }, + { NULL, 0, NULL, "", NULL } + }; + + static ChatCommand reloadCommandTable[] = + { + { "all", SEC_ADMINISTRATOR, &ChatHandler::HandleReloadAllCommand, "", NULL }, + { "all_loot", SEC_ADMINISTRATOR, &ChatHandler::HandleReloadAllLootCommand, "", NULL }, + { "all_npc", SEC_ADMINISTRATOR, &ChatHandler::HandleReloadAllNpcCommand, "", NULL }, + { "all_quest", SEC_ADMINISTRATOR, &ChatHandler::HandleReloadAllQuestCommand, "", NULL }, + { "all_scripts", SEC_ADMINISTRATOR, &ChatHandler::HandleReloadAllScriptsCommand, "", NULL }, + { "all_spell", SEC_ADMINISTRATOR, &ChatHandler::HandleReloadAllSpellCommand, "", NULL }, + { "all_item", SEC_ADMINISTRATOR, &ChatHandler::HandleReloadAllItemCommand, "", NULL }, + + { "config", SEC_ADMINISTRATOR, &ChatHandler::HandleReloadConfigCommand, "", NULL }, + + { "areatrigger_tavern", SEC_ADMINISTRATOR, &ChatHandler::HandleReloadAreaTriggerTavernCommand, "", NULL }, + { "areatrigger_teleport", SEC_ADMINISTRATOR, &ChatHandler::HandleReloadAreaTriggerTeleportCommand, "", NULL }, + { "areatrigger_involvedrelation",SEC_ADMINISTRATOR, &ChatHandler::HandleReloadQuestAreaTriggersCommand, "", NULL }, + { "event_scripts", SEC_ADMINISTRATOR, &ChatHandler::HandleReloadEventScriptsCommand, "", NULL }, + { "command", SEC_ADMINISTRATOR, &ChatHandler::HandleReloadCommandCommand, "", NULL }, + { "creature_involvedrelation", SEC_ADMINISTRATOR, &ChatHandler::HandleReloadCreatureQuestInvRelationsCommand,"",NULL }, + { "creature_loot_template", SEC_ADMINISTRATOR, &ChatHandler::HandleReloadLootTemplatesCreatureCommand, "", NULL }, + { "creature_questrelation", SEC_ADMINISTRATOR, &ChatHandler::HandleReloadCreatureQuestRelationsCommand, "", NULL }, + { "disenchant_loot_template", SEC_ADMINISTRATOR, &ChatHandler::HandleReloadLootTemplatesDisenchantCommand, "", NULL }, + { "fishing_loot_template", SEC_ADMINISTRATOR, &ChatHandler::HandleReloadLootTemplatesFishingCommand, "", NULL }, + { "game_graveyard_zone", SEC_ADMINISTRATOR, &ChatHandler::HandleReloadGameGraveyardZoneCommand, "", NULL }, + { "game_tele", SEC_ADMINISTRATOR, &ChatHandler::HandleReloadGameTeleCommand, "", NULL }, + { "gameobject_involvedrelation", SEC_ADMINISTRATOR, &ChatHandler::HandleReloadGOQuestInvRelationsCommand, "", NULL }, + { "gameobject_loot_template", SEC_ADMINISTRATOR, &ChatHandler::HandleReloadLootTemplatesGameobjectCommand, "", NULL }, + { "gameobject_questrelation", SEC_ADMINISTRATOR, &ChatHandler::HandleReloadGOQuestRelationsCommand, "", NULL }, + { "gameobject_scripts", SEC_ADMINISTRATOR, &ChatHandler::HandleReloadGameObjectScriptsCommand, "", NULL }, + { "item_enchantment_template", SEC_ADMINISTRATOR, &ChatHandler::HandleReloadItemEnchantementsCommand, "", NULL }, + { "item_loot_template", SEC_ADMINISTRATOR, &ChatHandler::HandleReloadLootTemplatesItemCommand, "", NULL }, + { "mangos_string", SEC_ADMINISTRATOR, &ChatHandler::HandleReloadMangosStringCommand, "", NULL }, + { "npc_gossip", SEC_ADMINISTRATOR, &ChatHandler::HandleReloadNpcGossipCommand, "", NULL }, + { "npc_trainer", SEC_ADMINISTRATOR, &ChatHandler::HandleReloadNpcTrainerCommand, "", NULL }, + { "npc_vendor", SEC_ADMINISTRATOR, &ChatHandler::HandleReloadNpcVendorCommand, "", NULL }, + { "page_text", SEC_ADMINISTRATOR, &ChatHandler::HandleReloadPageTextsCommand, "", NULL }, + { "pickpocketing_loot_template", SEC_ADMINISTRATOR, &ChatHandler::HandleReloadLootTemplatesPickpocketingCommand,"",NULL}, + { "prospecting_loot_template", SEC_ADMINISTRATOR, &ChatHandler::HandleReloadLootTemplatesProspectingCommand,"", NULL }, + { "quest_mail_loot_template", SEC_ADMINISTRATOR, &ChatHandler::HandleReloadLootTemplatesQuestMailCommand, "", NULL }, + { "quest_end_scripts", SEC_ADMINISTRATOR, &ChatHandler::HandleReloadQuestEndScriptsCommand, "", NULL }, + { "quest_start_scripts", SEC_ADMINISTRATOR, &ChatHandler::HandleReloadQuestStartScriptsCommand, "", NULL }, + { "quest_template", SEC_ADMINISTRATOR, &ChatHandler::HandleReloadQuestTemplateCommand, "", NULL }, + { "reference_loot_template", SEC_ADMINISTRATOR, &ChatHandler::HandleReloadLootTemplatesReferenceCommand, "", NULL }, + { "reserved_name", SEC_ADMINISTRATOR, &ChatHandler::HandleReloadReservedNameCommand, "", NULL }, + { "skill_discovery_template", SEC_ADMINISTRATOR, &ChatHandler::HandleReloadSkillDiscoveryTemplateCommand, "", NULL }, + { "skill_extra_item_template", SEC_ADMINISTRATOR, &ChatHandler::HandleReloadSkillExtraItemTemplateCommand, "", NULL }, + { "skill_fishing_base_level", SEC_ADMINISTRATOR, &ChatHandler::HandleReloadSkillFishingBaseLevelCommand, "", NULL }, + { "skinning_loot_template", SEC_ADMINISTRATOR, &ChatHandler::HandleReloadLootTemplatesSkinningCommand, "", NULL }, + { "spell_affect", SEC_ADMINISTRATOR, &ChatHandler::HandleReloadSpellAffectCommand, "", NULL }, + { "spell_chain", SEC_ADMINISTRATOR, &ChatHandler::HandleReloadSpellChainCommand, "", NULL }, + { "spell_elixir", SEC_ADMINISTRATOR, &ChatHandler::HandleReloadSpellElixirCommand, "", NULL }, + { "spell_learn_spell", SEC_ADMINISTRATOR, &ChatHandler::HandleReloadSpellLearnSpellCommand, "", NULL }, + { "spell_pet_auras", SEC_ADMINISTRATOR, &ChatHandler::HandleReloadSpellPetAurasCommand, "", NULL }, + { "spell_proc_event", SEC_ADMINISTRATOR, &ChatHandler::HandleReloadSpellProcEventCommand, "", NULL }, + { "spell_script_target", SEC_ADMINISTRATOR, &ChatHandler::HandleReloadSpellScriptTargetCommand, "", NULL }, + { "spell_scripts", SEC_ADMINISTRATOR, &ChatHandler::HandleReloadSpellScriptsCommand, "", NULL }, + { "spell_target_position", SEC_ADMINISTRATOR, &ChatHandler::HandleReloadSpellTargetPositionCommand, "", NULL }, + { "spell_threats", SEC_ADMINISTRATOR, &ChatHandler::HandleReloadSpellThreatsCommand, "", NULL }, + { "", SEC_ADMINISTRATOR, &ChatHandler::HandleReloadCommand, "", NULL }, + { NULL, 0, NULL, "", NULL } + }; + + static ChatCommand honorCommandTable[] = + { + { "add", SEC_GAMEMASTER, &ChatHandler::HandleAddHonorCommand, "", NULL }, + { "addkill", SEC_GAMEMASTER, &ChatHandler::HandleHonorAddKillCommand, "", NULL }, + { "update", SEC_GAMEMASTER, &ChatHandler::HandleUpdateHonorFieldsCommand, "", NULL }, + { NULL, 0, NULL, "", NULL } + }; + + static ChatCommand guildCommandTable[] = + { + { "create", SEC_GAMEMASTER, &ChatHandler::HandleGuildCreateCommand, "", NULL }, + { "delete", SEC_GAMEMASTER, &ChatHandler::HandleGuildDeleteCommand, "", NULL }, + { "invite", SEC_GAMEMASTER, &ChatHandler::HandleGuildInviteCommand, "", NULL }, + { "uninvite", SEC_GAMEMASTER, &ChatHandler::HandleGuildUninviteCommand, "", NULL }, + { "rank", SEC_GAMEMASTER, &ChatHandler::HandleGuildRankCommand, "", NULL }, + { NULL, 0, NULL, "", NULL } + }; + + static ChatCommand lookupPlayerCommandTable[] = + { + { "ip", SEC_GAMEMASTER, &ChatHandler::HandleLookupPlayerIpCommand, "", NULL }, + { "account", SEC_GAMEMASTER, &ChatHandler::HandleLookupPlayerAccountCommand, "", NULL }, + { "email", SEC_GAMEMASTER, &ChatHandler::HandleLookupPlayerEmailCommand, "", NULL }, + { NULL, 0, NULL, "", NULL } + }; + + static ChatCommand lookupCommandTable[] = + { + { "area", SEC_MODERATOR, &ChatHandler::HandleLookupAreaCommand, "", NULL }, + { "creature", SEC_ADMINISTRATOR, &ChatHandler::HandleLookupCreatureCommand, "", NULL }, + { "event", SEC_GAMEMASTER, &ChatHandler::HandleLookupEventCommand, "", NULL }, + { "faction", SEC_ADMINISTRATOR, &ChatHandler::HandleLookupFactionCommand, "", NULL }, + { "item", SEC_ADMINISTRATOR, &ChatHandler::HandleLookupItemCommand, "", NULL }, + { "itemset", SEC_ADMINISTRATOR, &ChatHandler::HandleLookupItemSetCommand, "", NULL }, + { "object", SEC_ADMINISTRATOR, &ChatHandler::HandleLookupObjectCommand, "", NULL }, + { "quest", SEC_ADMINISTRATOR, &ChatHandler::HandleLookupQuestCommand, "", NULL }, + { "player", SEC_GAMEMASTER, NULL, "", lookupPlayerCommandTable }, + { "skill", SEC_ADMINISTRATOR, &ChatHandler::HandleLookupSkillCommand, "", NULL }, + { "spell", SEC_ADMINISTRATOR, &ChatHandler::HandleLookupSpellCommand, "", NULL }, + { "tele", SEC_MODERATOR, &ChatHandler::HandleLookupTeleCommand, "", NULL }, + { NULL, 0, NULL, "", NULL } + }; + + static ChatCommand resetCommandTable[] = + { + { "honor", SEC_ADMINISTRATOR, &ChatHandler::HandleResetHonorCommand, "", NULL }, + { "level", SEC_ADMINISTRATOR, &ChatHandler::HandleResetLevelCommand, "", NULL }, + { "spells", SEC_ADMINISTRATOR, &ChatHandler::HandleResetSpellsCommand, "", NULL }, + { "stats", SEC_ADMINISTRATOR, &ChatHandler::HandleResetStatsCommand, "", NULL }, + { "talents", SEC_ADMINISTRATOR, &ChatHandler::HandleResetTalentsCommand, "", NULL }, + { "all", SEC_ADMINISTRATOR, &ChatHandler::HandleResetAllCommand, "", NULL }, + { NULL, 0, NULL, "", NULL } + }; + + static ChatCommand castCommandTable[] = + { + { "back", SEC_ADMINISTRATOR, &ChatHandler::HandleCastBackCommand, "", NULL }, + { "dist", SEC_ADMINISTRATOR, &ChatHandler::HandleCastDistCommand, "", NULL }, + { "self", SEC_ADMINISTRATOR, &ChatHandler::HandleCastSelfCommand, "", NULL }, + { "target", SEC_ADMINISTRATOR, &ChatHandler::HandleCastTargetCommand, "", NULL }, + { "", SEC_ADMINISTRATOR, &ChatHandler::HandleCastCommand, "", NULL }, + { NULL, 0, NULL, "", NULL } + }; + + static ChatCommand pdumpCommandTable[] = + { + { "load", SEC_ADMINISTRATOR, &ChatHandler::HandleLoadPDumpCommand, "", NULL }, + { "write", SEC_ADMINISTRATOR, &ChatHandler::HandleWritePDumpCommand, "", NULL }, + { NULL, 0, NULL, "", NULL } + }; + + static ChatCommand listCommandTable[] = + { + { "creature", SEC_ADMINISTRATOR, &ChatHandler::HandleListCreatureCommand, "", NULL }, + { "item", SEC_ADMINISTRATOR, &ChatHandler::HandleListItemCommand, "", NULL }, + { "object", SEC_ADMINISTRATOR, &ChatHandler::HandleListObjectCommand, "", NULL }, + { "auras", SEC_ADMINISTRATOR, &ChatHandler::HandleListAurasCommand, "", NULL }, + { NULL, 0, NULL, "", NULL } + }; + + static ChatCommand teleCommandTable[] = + { + { "add", SEC_ADMINISTRATOR, &ChatHandler::HandleAddTeleCommand, "", NULL }, + { "del", SEC_ADMINISTRATOR, &ChatHandler::HandleDelTeleCommand, "", NULL }, + { "name", SEC_MODERATOR, &ChatHandler::HandleNameTeleCommand, "", NULL }, + { "group", SEC_MODERATOR, &ChatHandler::HandleGroupTeleCommand, "", NULL }, + { "", SEC_MODERATOR, &ChatHandler::HandleTeleCommand, "", NULL }, + { NULL, 0, NULL, "", NULL } + }; + + static ChatCommand npcCommandTable[] = + { + { "say", SEC_MODERATOR, &ChatHandler::HandleSayCommand, "", NULL }, + { "whisper", SEC_MODERATOR, &ChatHandler::HandleNpcWhisperCommand, "", NULL }, + { "yell", SEC_MODERATOR, &ChatHandler::HandleYellCommand, "", NULL }, + { "textemote", SEC_MODERATOR, &ChatHandler::HandleTextEmoteCommand, "", NULL }, + { "add", SEC_GAMEMASTER, &ChatHandler::HandleAddSpwCommand, "", NULL }, + { "delete", SEC_GAMEMASTER, &ChatHandler::HandleDelCreatureCommand, "", NULL }, + { "spawndist", SEC_GAMEMASTER, &ChatHandler::HandleSpawnDistCommand, "", NULL }, + { "spawntime", SEC_GAMEMASTER, &ChatHandler::HandleSpawnTimeCommand, "", NULL }, + { "factionid", SEC_GAMEMASTER, &ChatHandler::HandleFactionIdCommand, "", NULL }, + { "addmove", SEC_GAMEMASTER, &ChatHandler::HandleAddMoveCommand, "", NULL }, + { "setmovetype", SEC_GAMEMASTER, &ChatHandler::HandleSetMoveTypeCommand, "", NULL }, + { "move", SEC_GAMEMASTER, &ChatHandler::HandleMoveCreatureCommand, "", NULL }, + { "changelevel", SEC_GAMEMASTER, &ChatHandler::HandleChangeLevelCommand, "", NULL }, + { "setmodel", SEC_GAMEMASTER, &ChatHandler::HandleSetModelCommand, "", NULL }, + { "additem", SEC_GAMEMASTER, &ChatHandler::HandleAddVendorItemCommand, "", NULL }, + { "delitem", SEC_GAMEMASTER, &ChatHandler::HandleDelVendorItemCommand, "", NULL }, + { "flag", SEC_GAMEMASTER, &ChatHandler::HandleNPCFlagCommand, "", NULL }, + { "changeentry", SEC_ADMINISTRATOR, &ChatHandler::HandleChangeEntryCommand, "", NULL }, + { "info", SEC_ADMINISTRATOR, &ChatHandler::HandleNpcInfoCommand, "", NULL }, + { "playemote", SEC_ADMINISTRATOR, &ChatHandler::HandlePlayEmoteCommand, "", NULL }, + + //{ TODO: fix or remove this commands + { "name", SEC_GAMEMASTER, &ChatHandler::HandleNameCommand, "", NULL }, + { "subname", SEC_GAMEMASTER, &ChatHandler::HandleSubNameCommand, "", NULL }, + { "addweapon", SEC_ADMINISTRATOR, &ChatHandler::HandleAddWeaponCommand, "", NULL }, + //} + + { NULL, 0, NULL, "", NULL } + }; + + static ChatCommand goCommandTable[] = + { + { "grid", SEC_MODERATOR, &ChatHandler::HandleGoGridCommand, "", NULL }, + { "creature", SEC_GAMEMASTER, &ChatHandler::HandleGoCreatureCommand, "", NULL }, + { "object", SEC_GAMEMASTER, &ChatHandler::HandleGoObjectCommand, "", NULL }, + { "trigger", SEC_GAMEMASTER, &ChatHandler::HandleGoTriggerCommand, "", NULL }, + { "graveyard", SEC_GAMEMASTER, &ChatHandler::HandleGoGraveyardCommand, "", NULL }, + { "zonexy", SEC_MODERATOR, &ChatHandler::HandleGoZoneXYCommand, "", NULL }, + { "xy", SEC_MODERATOR, &ChatHandler::HandleGoXYCommand, "", NULL }, + { "xyz", SEC_MODERATOR, &ChatHandler::HandleGoXYZCommand, "", NULL }, + { "", SEC_MODERATOR, &ChatHandler::HandleGoXYZCommand, "", NULL }, + { NULL, 0, NULL, "", NULL } + }; + + static ChatCommand gobjectCommandTable[] = + { + { "add", SEC_GAMEMASTER, &ChatHandler::HandleGameObjectCommand, "", NULL }, + { "delete", SEC_GAMEMASTER, &ChatHandler::HandleDelObjectCommand, "", NULL }, + { "target", SEC_GAMEMASTER, &ChatHandler::HandleTargetObjectCommand, "", NULL }, + { "turn", SEC_GAMEMASTER, &ChatHandler::HandleTurnObjectCommand, "", NULL }, + { "move", SEC_GAMEMASTER, &ChatHandler::HandleMoveObjectCommand, "", NULL }, + { "near", SEC_ADMINISTRATOR, &ChatHandler::HandleNearObjectCommand, "", NULL }, + { NULL, 0, NULL, "", NULL } + }; + + static ChatCommand questCommandTable[] = + { + { "add", SEC_ADMINISTRATOR, &ChatHandler::HandleAddQuest, "", NULL }, + { "complete", SEC_ADMINISTRATOR, &ChatHandler::HandleCompleteQuest, "", NULL }, + { "remove", SEC_ADMINISTRATOR, &ChatHandler::HandleRemoveQuest, "", NULL }, + { NULL, 0, NULL, "", NULL } + }; + + static ChatCommand gmCommandTable[] = + { + { "list", SEC_PLAYER, &ChatHandler::HandleGMListCommand, "", NULL }, + { "visible", SEC_MODERATOR, &ChatHandler::HandleVisibleCommand, "", NULL }, + { "fly", SEC_ADMINISTRATOR, &ChatHandler::HandleFlyModeCommand, "", NULL }, + { "", SEC_MODERATOR, &ChatHandler::HandleGMmodeCommand, "", NULL }, + { NULL, 0, NULL, "", NULL } + }; + + static ChatCommand instanceCommandTable[] = + { + { "listbinds", SEC_MODERATOR, &ChatHandler::HandleInstanceListBindsCommand, "", NULL }, + { "unbind", SEC_MODERATOR, &ChatHandler::HandleInstanceUnbindCommand, "", NULL }, + { "stats", SEC_MODERATOR, &ChatHandler::HandleInstanceStatsCommand, "", NULL }, + { "savedata", SEC_MODERATOR, &ChatHandler::HandleInstanceSaveDataCommand, "", NULL }, + { NULL, 0, NULL, "", NULL } + }; + + static ChatCommand commandTable[] = + { + { "gm", SEC_MODERATOR, NULL, "", gmCommandTable }, + { "npc", SEC_MODERATOR, NULL, "", npcCommandTable }, + { "go", SEC_MODERATOR, NULL, "", goCommandTable }, + { "learn", SEC_MODERATOR, NULL, "", learnCommandTable }, + { "modify", SEC_MODERATOR, NULL, "", modifyCommandTable }, + { "debug", SEC_MODERATOR, NULL, "", debugCommandTable }, + { "tele", SEC_MODERATOR, NULL, "", teleCommandTable }, + { "event", SEC_GAMEMASTER, NULL, "", eventCommandTable }, + { "gobject", SEC_GAMEMASTER, NULL, "", gobjectCommandTable }, + { "honor", SEC_GAMEMASTER, NULL, "", honorCommandTable }, + { "wp", SEC_GAMEMASTER, NULL, "", wpCommandTable }, + { "quest", SEC_ADMINISTRATOR, NULL, "", questCommandTable }, + { "reload", SEC_ADMINISTRATOR, NULL, "", reloadCommandTable }, + { "list", SEC_ADMINISTRATOR, NULL, "", listCommandTable }, + { "lookup", SEC_ADMINISTRATOR, NULL, "", lookupCommandTable }, + { "pdump", SEC_ADMINISTRATOR, NULL, "", pdumpCommandTable }, + { "guild", SEC_ADMINISTRATOR, NULL, "", guildCommandTable }, + { "cast", SEC_ADMINISTRATOR, NULL, "", castCommandTable }, + { "reset", SEC_ADMINISTRATOR, NULL, "", resetCommandTable }, + { "instance", SEC_ADMINISTRATOR, NULL, "", instanceCommandTable }, + { "server", SEC_ADMINISTRATOR, NULL, "", serverCommandTable }, + + { "aura", SEC_ADMINISTRATOR, &ChatHandler::HandleAuraCommand, "", NULL }, + { "unaura", SEC_ADMINISTRATOR, &ChatHandler::HandleUnAuraCommand, "", NULL }, + { "acct", SEC_PLAYER, &ChatHandler::HandleAcctCommand, "", NULL }, + { "announce", SEC_MODERATOR, &ChatHandler::HandleAnnounceCommand, "", NULL }, + { "notify", SEC_MODERATOR, &ChatHandler::HandleNotifyCommand, "", NULL }, + { "goname", SEC_MODERATOR, &ChatHandler::HandleGonameCommand, "", NULL }, + { "namego", SEC_MODERATOR, &ChatHandler::HandleNamegoCommand, "", NULL }, + { "groupgo", SEC_MODERATOR, &ChatHandler::HandleGroupgoCommand, "", NULL }, + { "commands", SEC_PLAYER, &ChatHandler::HandleCommandsCommand, "", NULL }, + { "demorph", SEC_GAMEMASTER, &ChatHandler::HandleDeMorphCommand, "", NULL }, + { "die", SEC_ADMINISTRATOR, &ChatHandler::HandleDieCommand, "", NULL }, + { "revive", SEC_ADMINISTRATOR, &ChatHandler::HandleReviveCommand, "", NULL }, + { "dismount", SEC_PLAYER, &ChatHandler::HandleDismountCommand, "", NULL }, + { "gps", SEC_MODERATOR, &ChatHandler::HandleGPSCommand, "", NULL }, + { "guid", SEC_GAMEMASTER, &ChatHandler::HandleGUIDCommand, "", NULL }, + { "help", SEC_PLAYER, &ChatHandler::HandleHelpCommand, "", NULL }, + { "itemmove", SEC_GAMEMASTER, &ChatHandler::HandleItemMoveCommand, "", NULL }, + { "cooldown", SEC_ADMINISTRATOR, &ChatHandler::HandleCooldownCommand, "", NULL }, + { "unlearn", SEC_ADMINISTRATOR, &ChatHandler::HandleUnLearnCommand, "", NULL }, + { "distance", SEC_ADMINISTRATOR, &ChatHandler::HandleGetDistanceCommand, "", NULL }, + { "recall", SEC_MODERATOR, &ChatHandler::HandleRecallCommand, "", NULL }, + { "save", SEC_PLAYER, &ChatHandler::HandleSaveCommand, "", NULL }, + { "saveall", SEC_MODERATOR, &ChatHandler::HandleSaveAllCommand, "", NULL }, + { "kick", SEC_GAMEMASTER, &ChatHandler::HandleKickPlayerCommand, "", NULL }, + { "security", SEC_ADMINISTRATOR, &ChatHandler::HandleSecurityCommand, "", NULL }, + { "ban", SEC_ADMINISTRATOR, &ChatHandler::HandleBanCommand, "", NULL }, + { "unban", SEC_ADMINISTRATOR, &ChatHandler::HandleUnBanCommand, "", NULL }, + { "baninfo", SEC_ADMINISTRATOR, &ChatHandler::HandleBanInfoCommand, "", NULL }, + { "banlist", SEC_ADMINISTRATOR, &ChatHandler::HandleBanListCommand, "", NULL }, + { "plimit", SEC_ADMINISTRATOR, &ChatHandler::HandlePLimitCommand, "", NULL }, + { "start", SEC_PLAYER, &ChatHandler::HandleStartCommand, "", NULL }, + { "taxicheat", SEC_MODERATOR, &ChatHandler::HandleTaxiCheatCommand, "", NULL }, + { "allowmove", SEC_ADMINISTRATOR, &ChatHandler::HandleAllowMovementCommand, "", NULL }, + { "linkgrave", SEC_ADMINISTRATOR, &ChatHandler::HandleLinkGraveCommand, "", NULL }, + { "neargrave", SEC_ADMINISTRATOR, &ChatHandler::HandleNearGraveCommand, "", NULL }, + { "transport", SEC_ADMINISTRATOR, &ChatHandler::HandleSpawnTransportCommand, "", NULL }, + { "explorecheat", SEC_ADMINISTRATOR, &ChatHandler::HandleExploreCheatCommand, "", NULL }, + { "hover", SEC_ADMINISTRATOR, &ChatHandler::HandleHoverCommand, "", NULL }, + { "levelup", SEC_ADMINISTRATOR, &ChatHandler::HandleLevelUpCommand, "", NULL }, + { "showarea", SEC_ADMINISTRATOR, &ChatHandler::HandleShowAreaCommand, "", NULL }, + { "hidearea", SEC_ADMINISTRATOR, &ChatHandler::HandleHideAreaCommand, "", NULL }, + { "additem", SEC_ADMINISTRATOR, &ChatHandler::HandleAddItemCommand, "", NULL }, + { "additemset", SEC_ADMINISTRATOR, &ChatHandler::HandleAddItemSetCommand, "", NULL }, + { "bank", SEC_ADMINISTRATOR, &ChatHandler::HandleBankCommand, "", NULL }, + { "wchange", SEC_ADMINISTRATOR, &ChatHandler::HandleChangeWeather, "", NULL }, + { "ticket", SEC_GAMEMASTER, &ChatHandler::HandleTicketCommand, "", NULL }, + { "delticket", SEC_GAMEMASTER, &ChatHandler::HandleDelTicketCommand, "", NULL }, + { "maxskill", SEC_ADMINISTRATOR, &ChatHandler::HandleMaxSkillCommand, "", NULL }, + { "setskill", SEC_ADMINISTRATOR, &ChatHandler::HandleSetSkillCommand, "", NULL }, + { "whispers", SEC_MODERATOR, &ChatHandler::HandleWhispersCommand, "", NULL }, + { "pinfo", SEC_GAMEMASTER, &ChatHandler::HandlePInfoCommand, "", NULL }, + { "password", SEC_PLAYER, &ChatHandler::HandlePasswordCommand, "", NULL }, + { "lockaccount", SEC_PLAYER, &ChatHandler::HandleLockAccountCommand, "", NULL }, + { "respawn", SEC_ADMINISTRATOR, &ChatHandler::HandleRespawnCommand, "", NULL }, + { "sendmail", SEC_MODERATOR, &ChatHandler::HandleSendMailCommand, "", NULL }, + { "rename", SEC_GAMEMASTER, &ChatHandler::HandleRenameCommand, "", NULL }, + { "loadscripts", SEC_ADMINISTRATOR, &ChatHandler::HandleLoadScriptsCommand, "", NULL }, + { "mute", SEC_GAMEMASTER, &ChatHandler::HandleMuteCommand, "", NULL }, + { "unmute", SEC_GAMEMASTER, &ChatHandler::HandleUnmuteCommand, "", NULL }, + { "movegens", SEC_ADMINISTRATOR, &ChatHandler::HandleMovegensCommand, "", NULL }, + { "cometome", SEC_ADMINISTRATOR, &ChatHandler::HandleComeToMeCommand, "", NULL }, + { "damage", SEC_ADMINISTRATOR, &ChatHandler::HandleDamageCommand, "", NULL }, + { "combatstop", SEC_GAMEMASTER, &ChatHandler::HandleCombatStopCommand, "", NULL }, + + { NULL, 0, NULL, "", NULL } + }; + + if(load_command_table) + { + load_command_table = false; + + QueryResult *result = WorldDatabase.Query("SELECT name,security,help FROM command"); + if (result) + { + do + { + Field *fields = result->Fetch(); + std::string name = fields[0].GetCppString(); + for(uint32 i = 0; commandTable[i].Name != NULL; i++) + { + if (name == commandTable[i].Name) + { + commandTable[i].SecurityLevel = (uint16)fields[1].GetUInt16(); + commandTable[i].Help = fields[2].GetCppString(); + } + if(commandTable[i].ChildCommands != NULL) + { + ChatCommand *ptable = commandTable[i].ChildCommands; + for(uint32 j = 0; ptable[j].Name != NULL; j++) + { + // first case for "" named subcommand + if (ptable[j].Name[0]=='\0' && name == commandTable[i].Name || + name == fmtstring("%s %s", commandTable[i].Name, ptable[j].Name) ) + { + ptable[j].SecurityLevel = (uint16)fields[1].GetUInt16(); + ptable[j].Help = fields[2].GetCppString(); + } + } + } + } + } while(result->NextRow()); + delete result; + } + } + + return commandTable; +} + +const char *ChatHandler::GetMangosString(int32 entry) +{ + return m_session->GetMangosString(entry); +} + +bool ChatHandler::hasStringAbbr(const char* s1, const char* s2) +{ + for(;;) + { + if( !*s2 ) + return true; + else if( !*s1 ) + return false; + else if( tolower( *s1 ) != tolower( *s2 ) ) + return false; + ++s1; ++s2; + } +} + +void ChatHandler::SendSysMessage(const char *str) +{ + WorldPacket data; + + // need copy to prevent corruption by strtok call in LineFromMessage original string + char* buf = strdup(str); + char* pos = buf; + + while(char* line = LineFromMessage(pos)) + { + FillSystemMessageData(&data, line); + m_session->SendPacket(&data); + } + + free(buf); +} + +void ChatHandler::SendGlobalSysMessage(const char *str) +{ + WorldPacket data; + + // need copy to prevent corruption by strtok call in LineFromMessage original string + char* buf = strdup(str); + char* pos = buf; + + while(char* line = LineFromMessage(pos)) + { + FillSystemMessageData(&data, line); + sWorld.SendGlobalMessage(&data); + } + + free(buf); +} + +void ChatHandler::SendSysMessage(int32 entry) +{ + SendSysMessage(GetMangosString(entry)); +} + +void ChatHandler::PSendSysMessage(int32 entry, ...) +{ + const char *format = GetMangosString(entry); + va_list ap; + char str [1024]; + va_start(ap, entry); + vsnprintf(str,1024,format, ap ); + va_end(ap); + SendSysMessage(str); +} + +void ChatHandler::PSendSysMessage(const char *format, ...) +{ + va_list ap; + char str [1024]; + va_start(ap, format); + vsnprintf(str,1024,format, ap ); + va_end(ap); + SendSysMessage(str); +} + +bool ChatHandler::ExecuteCommandInTable(ChatCommand *table, const char* text, std::string fullcmd) +{ + char const* oldtext = text; + std::string cmd = ""; + + while (*text != ' ' && *text != '\0') + { + cmd += *text; + ++text; + } + + while (*text == ' ') ++text; + + if(!cmd.length()) + return false; + + for(uint32 i = 0; table[i].Name != NULL; i++) + { + // allow pass "" command name in table + if(strlen(table[i].Name) && !hasStringAbbr(table[i].Name, cmd.c_str())) + continue; + + // select subcommand from child commands list + if(table[i].ChildCommands != NULL) + { + if(!ExecuteCommandInTable(table[i].ChildCommands, text, fullcmd)) + { + if(text && text[0] != '\0') + SendSysMessage(LANG_NO_SUBCMD); + else + SendSysMessage(LANG_CMD_SYNTAX); + + ShowHelpForCommand(table[i].ChildCommands,text); + } + + return true; + } + + // check security level only for simple command (without child commands) + if(m_session->GetSecurity() < table[i].SecurityLevel) + continue; + + SetSentErrorMessage(false); + // table[i].Name == "" is special case: send original command to handler + if((this->*(table[i].Handler))(strlen(table[i].Name)!=0 ? text : oldtext)) + { + if(table[i].SecurityLevel > SEC_PLAYER) + { + Player* p = m_session->GetPlayer(); + uint64 sel_guid = p->GetSelection(); + sLog.outCommand("Command: %s [Player: %s (Account: %u) X: %f Y: %f Z: %f Map: %u Selected: %s (GUID: %u)]", + fullcmd.c_str(),p->GetName(),m_session->GetAccountId(),p->GetPositionX(),p->GetPositionY(),p->GetPositionZ(),p->GetMapId(), + GetLogNameForGuid(sel_guid),GUID_LOPART(sel_guid)); + } + } + // some commands have custom error messages. Don't send the default one in these cases. + else if(!sentErrorMessage) + { + if(!table[i].Help.empty()) + SendSysMessage(table[i].Help.c_str()); + else + SendSysMessage(LANG_CMD_SYNTAX); + } + + return true; + } + + return false; +} + +int ChatHandler::ParseCommands(const char* text) +{ + ASSERT(text); + ASSERT(*text); + + //if(m_session->GetSecurity() == 0) + // return 0; + + if(text[0] != '!' && text[0] != '.') + return 0; + + // ignore single . and ! in line + if(strlen(text) < 2) + return 0; + + // ignore messages staring from many dots. + if(text[0] == '.' && text[1] == '.' || text[0] == '!' && text[1] == '!') + return 0; + + ++text; + + std::string fullcmd = text; // original `text` can't be used. It content destroyed in command code processing. + + if(!ExecuteCommandInTable(getCommandTable(), text, fullcmd)) + SendSysMessage(LANG_NO_CMD); + + return 1; +} + +bool ChatHandler::ShowHelpForSubCommands(ChatCommand *table, char const* cmd, char const* subcmd) +{ + std::string list; + for(uint32 i = 0; table[i].Name != NULL; ++i) + { + if(m_session->GetSecurity() < table[i].SecurityLevel) + continue; + + if(strlen(table[i].Name) && !hasStringAbbr(table[i].Name, subcmd)) + continue; + + (list += "\n ") += table[i].Name; + } + + if(list.empty()) + return false; + + if(table==getCommandTable()) + { + SendSysMessage(LANG_AVIABLE_CMD); + PSendSysMessage("%s",list.c_str()); + } + else + PSendSysMessage(LANG_SUBCMDS_LIST,cmd,list.c_str()); + + return true; +} + +bool ChatHandler::ShowHelpForCommand(ChatCommand *table, const char* cmd) +{ + if(*cmd) + { + for(uint32 i = 0; table[i].Name != NULL; ++i) + { + if(m_session->GetSecurity() < table[i].SecurityLevel) + continue; + + if(strlen(table[i].Name) && !hasStringAbbr(table[i].Name, cmd)) + continue; + + // have subcommand + char const* subcmd = (*cmd) ? strtok(NULL, " ") : ""; + + if(table[i].ChildCommands && subcmd && *subcmd) + { + if(ShowHelpForCommand(table[i].ChildCommands, subcmd)) + return true; + } + + if(!table[i].Help.empty()) + SendSysMessage(table[i].Help.c_str()); + + if(table[i].ChildCommands) + if(ShowHelpForSubCommands(table[i].ChildCommands,table[i].Name,subcmd ? subcmd : "")) + return true; + + return !table[i].Help.empty(); + } + } + else + { + for(uint32 i = 0; table[i].Name != NULL; ++i) + { + if(m_session->GetSecurity() < table[i].SecurityLevel) + continue; + + if(strlen(table[i].Name)) + continue; + + if(!table[i].Help.empty()) + SendSysMessage(table[i].Help.c_str()); + + if(table[i].ChildCommands) + if(ShowHelpForSubCommands(table[i].ChildCommands,"","")) + return true; + + return !table[i].Help.empty(); + } + } + + return ShowHelpForSubCommands(table,"",cmd); +} + +//Note: target_guid used only in CHAT_MSG_WHISPER_INFORM mode (in this case channelName ignored) +void ChatHandler::FillMessageData( WorldPacket *data, WorldSession* session, uint8 type, uint32 language, const char *channelName, uint64 target_guid, const char *message, Unit *speaker) +{ + uint32 messageLength = (message ? strlen(message) : 0) + 1; + + data->Initialize(SMSG_MESSAGECHAT, 100); // guess size + *data << uint8(type); + if ((type != CHAT_MSG_CHANNEL && type != CHAT_MSG_WHISPER) || language == LANG_ADDON) + *data << uint32(language); + else + *data << uint32(LANG_UNIVERSAL); + + switch(type) + { + case CHAT_MSG_SAY: + case CHAT_MSG_PARTY: + case CHAT_MSG_RAID: + case CHAT_MSG_GUILD: + case CHAT_MSG_OFFICER: + case CHAT_MSG_YELL: + case CHAT_MSG_WHISPER: + case CHAT_MSG_CHANNEL: + case CHAT_MSG_RAID_LEADER: + case CHAT_MSG_RAID_WARNING: + case CHAT_MSG_BG_SYSTEM_NEUTRAL: + case CHAT_MSG_BG_SYSTEM_ALLIANCE: + case CHAT_MSG_BG_SYSTEM_HORDE: + case CHAT_MSG_BATTLEGROUND: + case CHAT_MSG_BATTLEGROUND_LEADER: + target_guid = session ? session->GetPlayer()->GetGUID() : 0; + break; + case CHAT_MSG_MONSTER_SAY: + case CHAT_MSG_MONSTER_PARTY: + case CHAT_MSG_MONSTER_YELL: + case CHAT_MSG_MONSTER_WHISPER: + case CHAT_MSG_MONSTER_EMOTE: + case CHAT_MSG_RAID_BOSS_WHISPER: + case CHAT_MSG_RAID_BOSS_EMOTE: + { + *data << uint64(speaker->GetGUID()); + *data << uint32(0); // 2.1.0 + *data << uint32(strlen(speaker->GetName()) + 1); + *data << speaker->GetName(); + uint64 listener_guid = 0; + *data << uint64(listener_guid); + if(listener_guid && !IS_PLAYER_GUID(listener_guid)) + { + *data << uint32(1); // string listener_name_length + *data << uint8(0); // string listener_name + } + *data << uint32(messageLength); + *data << message; + *data << uint8(0); + return; + } + default: + if (type != CHAT_MSG_REPLY && type != CHAT_MSG_IGNORED && type != CHAT_MSG_DND && type != CHAT_MSG_AFK) + target_guid = 0; // only for CHAT_MSG_WHISPER_INFORM used original value target_guid + break; + } + + *data << uint64(target_guid); // there 0 for BG messages + *data << uint32(0); // can be chat msg group or something + + if (type == CHAT_MSG_CHANNEL) + { + ASSERT(channelName); + *data << channelName; + } + + *data << uint64(target_guid); + *data << uint32(messageLength); + *data << message; + if(session != 0 && type != CHAT_MSG_REPLY && type != CHAT_MSG_DND && type != CHAT_MSG_AFK) + *data << uint8(session->GetPlayer()->chatTag()); + else + *data << uint8(0); +} + +Player * ChatHandler::getSelectedPlayer() +{ + uint64 guid = m_session->GetPlayer()->GetSelection(); + + if (guid == 0) + return m_session->GetPlayer(); + + return objmgr.GetPlayer(guid); +} + +Unit* ChatHandler::getSelectedUnit() +{ + uint64 guid = m_session->GetPlayer()->GetSelection(); + + if (guid == 0) + return m_session->GetPlayer(); + + return ObjectAccessor::GetUnit(*m_session->GetPlayer(),guid); +} + +Creature* ChatHandler::getSelectedCreature() +{ + return ObjectAccessor::GetCreatureOrPet(*m_session->GetPlayer(),m_session->GetPlayer()->GetSelection()); +} + +char* ChatHandler::extractKeyFromLink(char* text, char const* linkType, char** something1) +{ + // skip empty + if(!text) + return NULL; + + // skip speces + while(*text==' '||*text=='\t'||*text=='\b') + ++text; + + if(!*text) + return NULL; + + // return non link case + if(text[0]!='|') + return strtok(text, " "); + + // [name] Shift-click form |color|linkType:key|h[name]|h|r + // or + // [name] Shift-click form |color|linkType:key:something1:...:somethingN|h[name]|h|r + + char* check = strtok(text, "|"); // skip color + if(!check) + return NULL; // end of data + + char* cLinkType = strtok(NULL, ":"); // linktype + if(!cLinkType) + return NULL; // end of data + + if(strcmp(cLinkType,linkType) != 0) + { + strtok(NULL, " "); // skip link tail (to allow continue strtok(NULL,s) use after retturn from function + SendSysMessage(LANG_WRONG_LINK_TYPE); + return NULL; + } + + char* cKeys = strtok(NULL, "|"); // extract keys and values + char* cKeysTail = strtok(NULL, ""); + + char* cKey = strtok(cKeys, ":|"); // extract key + if(something1) + *something1 = strtok(NULL, ":|"); // extract something + + strtok(cKeysTail, "]"); // restart scan tail and skip name with possible spaces + strtok(NULL, " "); // skip link tail (to allow continue strtok(NULL,s) use after retturn from function + return cKey; +} + +char* ChatHandler::extractKeyFromLink(char* text, char const* const* linkTypes, int* found_idx, char** something1) +{ + // skip empty + if(!text) + return NULL; + + // skip speces + while(*text==' '||*text=='\t'||*text=='\b') + ++text; + + if(!*text) + return NULL; + + // return non link case + if(text[0]!='|') + return strtok(text, " "); + + // [name] Shift-click form |color|linkType:key|h[name]|h|r + // or + // [name] Shift-click form |color|linkType:key:something1:...:somethingN|h[name]|h|r + + char* check = strtok(text, "|"); // skip color + if(!check) + return NULL; // end of data + + char* cLinkType = strtok(NULL, ":"); // linktype + if(!cLinkType) + return NULL; // end of data + + for(int i = 0; linkTypes[i]; ++i) + { + if(strcmp(cLinkType,linkTypes[i]) == 0) + { + char* cKeys = strtok(NULL, "|"); // extract keys and values + char* cKeysTail = strtok(NULL, ""); + + char* cKey = strtok(cKeys, ":|"); // extract key + if(something1) + *something1 = strtok(NULL, ":|"); // extract something + + strtok(cKeysTail, "]"); // restart scan tail and skip name with possible spaces + strtok(NULL, " "); // skip link tail (to allow continue strtok(NULL,s) use after return from function + if(found_idx) + *found_idx = i; + return cKey; + } + } + + strtok(NULL, " "); // skip link tail (to allow continue strtok(NULL,s) use after return from function + SendSysMessage(LANG_WRONG_LINK_TYPE); + return NULL; +} + +char const *fmtstring( char const *format, ... ) +{ + va_list argptr; + #define MAX_FMT_STRING 32000 + static char temp_buffer[MAX_FMT_STRING]; + static char string[MAX_FMT_STRING]; + static int index = 0; + char *buf; + int len; + + va_start(argptr, format); + vsnprintf(temp_buffer,MAX_FMT_STRING, format, argptr); + va_end(argptr); + + len = strlen(temp_buffer); + + if( len >= MAX_FMT_STRING ) + return "ERROR"; + + if (len + index >= MAX_FMT_STRING-1) + { + index = 0; + } + + buf = &string[index]; + memcpy( buf, temp_buffer, len+1 ); + + index += len + 1; + + return buf; +} + +GameObject* ChatHandler::GetObjectGlobalyWithGuidOrNearWithDbGuid(uint32 lowguid,uint32 entry) +{ + Player* pl = m_session->GetPlayer(); + + GameObject* obj = ObjectAccessor::GetGameObject(*pl, MAKE_NEW_GUID(lowguid, entry, HIGHGUID_GAMEOBJECT)); + + if(!obj && objmgr.GetGOData(lowguid)) // guid is DB guid of object + { + // search near player then + CellPair p(MaNGOS::ComputeCellPair(pl->GetPositionX(), pl->GetPositionY())); + Cell cell(p); + cell.data.Part.reserved = ALL_DISTRICT; + + MaNGOS::GameObjectWithDbGUIDCheck go_check(*pl,lowguid); + MaNGOS::GameObjectSearcher checker(obj,go_check); + + TypeContainerVisitor, GridTypeMapContainer > object_checker(checker); + CellLock cell_lock(cell, p); + cell_lock->Visit(cell_lock, object_checker, *MapManager::Instance().GetMap(pl->GetMapId(), pl)); + } + + return obj; +} + +static char const* const spellTalentKeys[] = { + "Hspell", + "Htalent", + 0 +}; + +uint32 ChatHandler::extractSpellIdFromLink(char* text) +{ + // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r + // number or [name] Shift-click form |color|Htalent:telen_id,rank|h[name]|h|r + int type = 0; + char* rankS = NULL; + char* idS = extractKeyFromLink(text,spellTalentKeys,&type,&rankS); + if(!idS) + return 0; + + uint32 id = (uint32)atol(idS); + + // spell + if(type==0) + return id; + + // talent + TalentEntry const* talentEntry = sTalentStore.LookupEntry(id); + if(!talentEntry) + return 0; + + int32 rank = rankS ? (uint32)atol(rankS) : 0; + if(rank >= 5) + return 0; + + if(rank < 0) + rank = 0; + + return talentEntry->RankID[rank]; +} + +GameTele const* ChatHandler::extractGameTeleFromLink(char* text) +{ + // id, or string, or [name] Shift-click form |color|Htele:id|h[name]|h|r + char* cId = extractKeyFromLink(text,"Htele"); + if(!cId) + return false; + + // id case (explicit or from shift link) + if(cId[0] >= '0' || cId[0] >= '9') + if(uint32 id = atoi(cId)) + return objmgr.GetGameTele(id); + + return objmgr.GetGameTele(cId); +} diff --git a/src/game/Chat.h b/src/game/Chat.h index 49b219e875e..388cd83b951 100644 --- a/src/game/Chat.h +++ b/src/game/Chat.h @@ -1,406 +1,421 @@ -/* - * Copyright (C) 2005-2008 MaNGOS - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef MANGOSSERVER_CHAT_H -#define MANGOSSERVER_CHAT_H - -#include "SharedDefines.h" - -class ChatHandler; -class WorldSession; -class Creature; -class Player; -class Unit; - -struct LanguageDesc -{ - Language lang_id; - uint32 spell_id; - uint32 skill_id; -}; - -extern LanguageDesc lang_description[LANGUAGES_COUNT]; - -LanguageDesc const* GetLanguageDescByID(uint32 lang); -LanguageDesc const* GetLanguageDescBySpell(uint32 spell_id); -LanguageDesc const* GetLanguageDescBySkill(uint32 skill_id); - -class ChatCommand -{ - public: - const char * Name; - uint32 SecurityLevel; // function pointer required correct align (use uint32) - bool (ChatHandler::*Handler)(const char* args); - std::string Help; - ChatCommand * ChildCommands; -}; - -class ChatHandler -{ - public: - explicit ChatHandler(WorldSession* session) : m_session(session) {} - explicit ChatHandler(Player* player) : m_session(player->GetSession()) {} - ~ChatHandler() {} - - static void FillMessageData( WorldPacket *data, WorldSession* session, uint8 type, uint32 language, const char *channelName, uint64 target_guid, const char *message, Unit *speaker); - - void FillMessageData( WorldPacket *data, uint8 type, uint32 language, uint64 target_guid, const char* message) - { - FillMessageData( data, m_session, type, language, NULL, target_guid, message, NULL); - } - - void FillSystemMessageData( WorldPacket *data, const char* message ) - { - FillMessageData( data, CHAT_MSG_SYSTEM, LANG_UNIVERSAL, 0, message ); - } - - static char* LineFromMessage(char*& pos) { char* start = strtok(pos,"\n"); pos = NULL; return start; } - - const char *GetMangosString(int32 entry); - - void SendSysMessage( const char *str); - void SendSysMessage( int32 entry); - void PSendSysMessage( const char *format, ...) ATTR_PRINTF(2,3); - void PSendSysMessage( int32 entry, ... ); - - int ParseCommands(const char* text); - - protected: - bool hasStringAbbr(const char* s1, const char* s2); - void SendGlobalSysMessage(const char *str); - - bool ExecuteCommandInTable(ChatCommand *table, const char* text, std::string fullcommand); - bool ShowHelpForCommand(ChatCommand *table, const char* cmd); - bool ShowHelpForSubCommands(ChatCommand *table, char const* cmd, char const* subcmd); - - ChatCommand* getCommandTable(); - - bool HandleHelpCommand(const char* args); - bool HandleCommandsCommand(const char* args); - bool HandleAcctCommand(const char* args); - bool HandleStartCommand(const char* args); - bool HandleInfoCommand(const char* args); - bool HandleDismountCommand(const char* args); - bool HandleSaveCommand(const char* args); - bool HandleGMListCommand(const char* args); - - bool HandleNamegoCommand(const char* args); - bool HandleGonameCommand(const char* args); - bool HandleGroupgoCommand(const char* args); - bool HandleRecallCommand(const char* args); - bool HandleAnnounceCommand(const char* args); - bool HandleNotifyCommand(const char* args); - bool HandleGMmodeCommand(const char* args); - bool HandleVisibleCommand(const char* args); - bool HandleGPSCommand(const char* args); - bool HandleTaxiCheatCommand(const char* args); - bool HandleWhispersCommand(const char* args); - bool HandleSayCommand(const char* args); - bool HandleNpcWhisperCommand(const char* args); - bool HandleYellCommand(const char* args); - bool HandlePlayEmoteCommand(const char* args); - bool HandleSendMailCommand(const char* args); - bool HandleNameTeleCommand(const char* args); - bool HandleGroupTeleCommand(const char* args); - bool HandleDrunkCommand(const char* args); - - bool HandleEventActiveListCommand(const char* args); - bool HandleEventStartCommand(const char* args); - bool HandleEventStopCommand(const char* args); - bool HandleEventInfoCommand(const char* args); - - bool HandleModifyKnownTitlesCommand(const char* args); - bool HandleModifyHPCommand(const char* args); - bool HandleModifyManaCommand(const char* args); - bool HandleModifyRageCommand(const char* args); - bool HandleModifyEnergyCommand(const char* args); - bool HandleModifyMoneyCommand(const char* args); - bool HandleModifyASpeedCommand(const char* args); - bool HandleModifySpeedCommand(const char* args); - bool HandleModifyBWalkCommand(const char* args); - bool HandleModifyFlyCommand(const char* args); - bool HandleModifySwimCommand(const char* args); - bool HandleModifyScaleCommand(const char* args); - bool HandleModifyMountCommand(const char* args); - bool HandleModifyBitCommand(const char* args); - bool HandleModifyFactionCommand(const char* args); - bool HandleModifySpellCommand(const char* args); - bool HandleModifyTalentCommand (const char* args); - bool HandleModifyHonorCommand (const char* args); - bool HandleModifyRepCommand(const char* args); - bool HandleModifyArenaCommand(const char* args); - - bool HandleReloadCommand(const char* args); - bool HandleReloadAllCommand(const char* args); - bool HandleReloadAllAreaCommand(const char* args); - bool HandleReloadAllItemCommand(const char* args); - bool HandleReloadAllLootCommand(const char* args); - bool HandleReloadAllQuestCommand(const char* args); - bool HandleReloadAllScriptsCommand(const char* args); - bool HandleReloadAllSpellCommand(const char* args); - - bool HandleReloadConfigCommand(const char* args); - - bool HandleReloadAreaTriggerTavernCommand(const char* args); - bool HandleReloadAreaTriggerTeleportCommand(const char* args); - bool HandleReloadEventScriptsCommand(const char* args); - bool HandleReloadCommandCommand(const char* args); - bool HandleReloadCreatureQuestRelationsCommand(const char* args); - bool HandleReloadCreatureQuestInvRelationsCommand(const char* args); - bool HandleReloadGameGraveyardZoneCommand(const char* args); - bool HandleReloadGameObjectScriptsCommand(const char* args); - bool HandleReloadGOQuestRelationsCommand(const char* args); - bool HandleReloadGOQuestInvRelationsCommand(const char* args); - bool HandleReloadLootTemplatesCreatureCommand(const char* args); - bool HandleReloadLootTemplatesDisenchantCommand(const char* args); - bool HandleReloadLootTemplatesFishingCommand(const char* args); - bool HandleReloadLootTemplatesGameobjectCommand(const char* args); - bool HandleReloadLootTemplatesItemCommand(const char* args); - bool HandleReloadLootTemplatesPickpocketingCommand(const char* args); - bool HandleReloadLootTemplatesProspectingCommand(const char* args); - bool HandleReloadLootTemplatesReferenceCommand(const char* args); - bool HandleReloadLootTemplatesQuestMailCommand(const char* args); - bool HandleReloadLootTemplatesSkinningCommand(const char* args); - bool HandleReloadMangosStringCommand(const char* args); - bool HandleReloadQuestAreaTriggersCommand(const char* args); - bool HandleReloadQuestEndScriptsCommand(const char* args); - bool HandleReloadQuestStartScriptsCommand(const char* args); - bool HandleReloadQuestTemplateCommand(const char* args); - bool HandleReloadReservedNameCommand(const char*); - bool HandleReloadSkillDiscoveryTemplateCommand(const char* args); - bool HandleReloadSkillExtraItemTemplateCommand(const char* args); - bool HandleReloadSkillFishingBaseLevelCommand(const char* args); - bool HandleReloadSpellAffectCommand(const char* args); - bool HandleReloadSpellChainCommand(const char* args); - bool HandleReloadSpellElixirCommand(const char* args); - bool HandleReloadSpellLearnSpellCommand(const char* args); - bool HandleReloadSpellProcEventCommand(const char* args); - bool HandleReloadSpellScriptTargetCommand(const char* args); - bool HandleReloadSpellScriptsCommand(const char* args); - bool HandleReloadSpellTargetPositionCommand(const char* args); - bool HandleReloadSpellThreatsCommand(const char* args); - bool HandleReloadSpellPetAurasCommand(const char* args); - bool HandleReloadPageTextsCommand(const char* args); - bool HandleReloadItemEnchantementsCommand(const char* args); - - bool HandleInstanceListBindsCommand(const char* args); - bool HandleInstanceUnbindCommand(const char* args); - bool HandleInstanceStatsCommand(const char* args); - bool HandleInstanceSaveDataCommand(const char * args); - - bool HandleAddHonorCommand(const char* args); - bool HandleHonorAddKillCommand(const char* args); - bool HandleUpdateHonorFieldsCommand(const char* args); - - bool HandleLoadScriptsCommand(const char* args); - bool HandleSendQuestPartyMsgCommand(const char* args); - bool HandleSendQuestInvalidMsgCommand(const char* args); - - bool HandleDebugInArcCommand(const char* args); - bool HandleDebugSpellFailCommand(const char* args); - - bool HandleGUIDCommand(const char* args); - bool HandleNameCommand(const char* args); - bool HandleSubNameCommand(const char* args); - bool HandleItemMoveCommand(const char* args); - bool HandleDelCreatureCommand(const char* args); - bool HandleDeMorphCommand(const char* args); - bool HandleAddVendorItemCommand(const char* args); - bool HandleDelVendorItemCommand(const char* args); - bool HandleAddMoveCommand(const char* args); - bool HandleSetMoveTypeCommand(const char* args); - bool HandleChangeLevelCommand(const char* args); - bool HandleSetPoiCommand(const char* args); - bool HandleEquipErrorCommand(const char* args); - bool HandleNPCFlagCommand(const char* args); - bool HandleSetModelCommand(const char* args); - bool HandleFactionIdCommand(const char* args); - bool HandleAddSpwCommand(const char* args); - bool HandleSpawnDistCommand(const char* args); - bool HandleSpawnTimeCommand(const char* args); - bool HandleGoCreatureCommand(const char* args); - bool HandleGoObjectCommand(const char* args); - bool HandleGoTriggerCommand(const char* args); - bool HandleGoGraveyardCommand(const char* args); - bool HandleTargetObjectCommand(const char* args); - bool HandleDelObjectCommand(const char* args); - bool HandleMoveCreatureCommand(const char* args); - bool HandleMoveObjectCommand(const char* args); - bool HandleTurnObjectCommand(const char* args); - bool HandlePInfoCommand(const char* args); - bool HandlePLimitCommand(const char* args); - bool HandleMuteCommand(const char* args); - bool HandleUnmuteCommand(const char* args); - bool HandleMovegensCommand(const char* args); - - bool HandleBanCommand(const char* args); - bool HandleUnBanCommand(const char* args); - bool HandleBanInfoCommand(const char* args); - bool HandleBanListCommand(const char* args); - bool HandleIdleRestartCommand(const char* args); - bool HandleIdleShutDownCommand(const char* args); - bool HandleShutDownCommand(const char* args); - bool HandleRestartCommand(const char* args); - bool HandleSecurityCommand(const char* args); - bool HandleGoXYCommand(const char* args); - bool HandleGoXYZCommand(const char* args); - bool HandleGoZoneXYCommand(const char* args); - bool HandleGoGridCommand(const char* args); - bool HandleAddWeaponCommand(const char* args); - bool HandleAllowMovementCommand(const char* args); - bool HandleGoCommand(const char* args); - bool HandleLearnCommand(const char* args); - bool HandleLearnAllCommand(const char* args); - bool HandleLearnAllGMCommand(const char* args); - bool HandleLearnAllCraftsCommand(const char* args); - bool HandleLearnAllRecipesCommand(const char* args); - bool HandleLearnAllDefaultCommand(const char* args); - bool HandleLearnAllLangCommand(const char* args); - bool HandleLearnAllMyClassCommand(const char* args); - bool HandleLearnAllMySpellsCommand(const char* args); - bool HandleLearnAllMyTalentsCommand(const char* args); - bool HandleCooldownCommand(const char* args); - bool HandleUnLearnCommand(const char* args); - bool HandleGetDistanceCommand(const char* args); - bool HandleGameObjectCommand(const char* args); - bool HandleAnimCommand(const char* args); - bool HandlePlaySoundCommand(const char* args); - bool HandleStandStateCommand(const char* args); - bool HandleDieCommand(const char* args); - bool HandleDamageCommand(const char *args); - bool HandleReviveCommand(const char* args); - bool HandleMorphCommand(const char* args); - bool HandleAuraCommand(const char* args); - bool HandleUnAuraCommand(const char* args); - bool HandleLinkGraveCommand(const char* args); - bool HandleNearGraveCommand(const char* args); - bool HandleSpawnTransportCommand(const char* args); - bool HandleExploreCheatCommand(const char* args); - bool HandleTextEmoteCommand(const char* args); - bool HandleNpcInfoCommand(const char* args); - bool HandleHoverCommand(const char* args); - bool HandleLevelUpCommand(const char* args); - bool HandleShowAreaCommand(const char* args); - bool HandleHideAreaCommand(const char* args); - bool HandleAddItemCommand(const char* args); - bool HandleAddItemSetCommand(const char* args); - bool HandleLookupItemCommand(const char * args); - bool HandleLookupItemSetCommand(const char * args); - bool HandleGuildCreateCommand(const char* args); - bool HandleGuildInviteCommand(const char* args); - bool HandleGuildUninviteCommand(const char* args); - bool HandleGuildRankCommand(const char* args); - bool HandleGuildDeleteCommand(const char* args); - bool HandleUpdate(const char* args); - bool HandleBankCommand(const char* args); - bool HandleChangeWeather(const char* args); - bool HandleKickPlayerCommand(const char * args); - bool HandleTeleCommand(const char * args); - bool HandleAddTeleCommand(const char * args); - bool HandleDelTeleCommand(const char * args); - bool HandleListAurasCommand(const char * args); - bool HandleLookupTeleCommand(const char * args); - - bool HandleResetHonorCommand(const char * args); - bool HandleResetLevelCommand(const char * args); - bool HandleResetSpellsCommand(const char * args); - - bool HandleResetStatsCommand(const char * args); - bool HandleResetTalentsCommand(const char * args); - - bool HandleResetAllCommand(const char * args); - bool HandleTicketCommand(const char* args); - bool HandleDelTicketCommand(const char* args); - bool HandleMaxSkillCommand(const char* args); - bool HandleSetSkillCommand(const char* args); - bool HandleListCreatureCommand(const char* args); - bool HandleListItemCommand(const char* args); - bool HandleListObjectCommand(const char* args); - bool HandleNearObjectCommand(const char* args); - bool HandleLookupAreaCommand(const char* args); - bool HandleLookupCreatureCommand(const char* args); - bool HandleLookupEventCommand(const char* args); - bool HandleLookupFactionCommand(const char * args); - bool HandleLookupObjectCommand(const char* args); - bool HandleLookupQuestCommand(const char* args); - bool HandleLookupSkillCommand(const char* args); - bool HandleLookupSpellCommand(const char* args); - bool HandlePasswordCommand(const char* args); - bool HandleLockAccountCommand(const char* args); - bool HandleRespawnCommand(const char* args); - bool HandleWpAddCommand(const char* args); - bool HandleWpModifyCommand(const char* args); - bool HandleWpShowCommand(const char* args); - bool HandleWpExportCommand(const char* args); - bool HandleWpImportCommand(const char* args); - bool HandleFlyModeCommand(const char* args); - bool HandleSendOpcodeCommand(const char* args); - bool HandleSellErrorCommand(const char* args); - bool HandleBuyErrorCommand(const char* args); - bool HandleUpdateWorldStateCommand(const char* args); - bool HandlePlaySound2Command(const char* args); - bool HandleSendChannelNotifyCommand(const char* args); - bool HandleSendChatMsgCommand(const char* args); - bool HandleRenameCommand(const char * args); - bool HandleLoadPDumpCommand(const char *args); - bool HandleWritePDumpCommand(const char *args); - bool HandleChangeEntryCommand(const char *args); - bool HandleCastCommand(const char *args); - bool HandleCastBackCommand(const char *args); - bool HandleCastDistCommand(const char *args); - bool HandleCastSelfCommand(const char *args); - bool HandleCastTargetCommand(const char *args); - bool HandleComeToMeCommand(const char *args); - bool HandleCombatStopCommand(const char *args); - - //! Development Commands - bool HandleSetValue(const char* args); - bool HandleGetValue(const char* args); - bool HandleSet32Bit(const char* args); - bool HandleMod32Value(const char* args); - bool HandleAddQuest(const char * args); - bool HandleRemoveQuest(const char * args); - bool HandleCompleteQuest(const char * args); - bool HandleSaveAllCommand(const char* args); - bool HandleGetItemState(const char * args); - bool HandleGetLootRecipient(const char * args); - - Player* getSelectedPlayer(); - Creature* getSelectedCreature(); - Unit* getSelectedUnit(); - char* extractKeyFromLink(char* text, char const* linkType, char** something1 = NULL); - char* extractKeyFromLink(char* text, char const* const* linkTypes, int* found_idx, char** something1 = NULL); - uint32 extractSpellIdFromLink(char* text); - - GameObject* GetObjectGlobalyWithGuidOrNearWithDbGuid(uint32 lowguid,uint32 entry); - - WorldSession * m_session; - - // Utility methods for commands - void ShowTicket(uint64 guid, char const* text, char const* time); - uint32 GetTicketIDByNum(uint32 num); - - void SetSentErrorMessage(bool val){ sentErrorMessage = val;}; - private: - // common global flag - static bool load_command_table; - bool sentErrorMessage; -}; -#endif - -char const *fmtstring( char const *format, ... ); +/* + * Copyright (C) 2005-2008 MaNGOS + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef MANGOSSERVER_CHAT_H +#define MANGOSSERVER_CHAT_H + +#include "SharedDefines.h" + +class ChatHandler; +class WorldSession; +class Creature; +class Player; +class Unit; +struct GameTele; + +struct LanguageDesc +{ + Language lang_id; + uint32 spell_id; + uint32 skill_id; +}; + +extern LanguageDesc lang_description[LANGUAGES_COUNT]; + +LanguageDesc const* GetLanguageDescByID(uint32 lang); +LanguageDesc const* GetLanguageDescBySpell(uint32 spell_id); +LanguageDesc const* GetLanguageDescBySkill(uint32 skill_id); + +class ChatCommand +{ + public: + const char * Name; + uint32 SecurityLevel; // function pointer required correct align (use uint32) + bool (ChatHandler::*Handler)(const char* args); + std::string Help; + ChatCommand * ChildCommands; +}; + +class ChatHandler +{ + public: + explicit ChatHandler(WorldSession* session) : m_session(session) {} + explicit ChatHandler(Player* player) : m_session(player->GetSession()) {} + ~ChatHandler() {} + + static void FillMessageData( WorldPacket *data, WorldSession* session, uint8 type, uint32 language, const char *channelName, uint64 target_guid, const char *message, Unit *speaker); + + void FillMessageData( WorldPacket *data, uint8 type, uint32 language, uint64 target_guid, const char* message) + { + FillMessageData( data, m_session, type, language, NULL, target_guid, message, NULL); + } + + void FillSystemMessageData( WorldPacket *data, const char* message ) + { + FillMessageData( data, CHAT_MSG_SYSTEM, LANG_UNIVERSAL, 0, message ); + } + + static char* LineFromMessage(char*& pos) { char* start = strtok(pos,"\n"); pos = NULL; return start; } + + const char *GetMangosString(int32 entry); + + void SendSysMessage( const char *str); + void SendSysMessage( int32 entry); + void PSendSysMessage( const char *format, ...) ATTR_PRINTF(2,3); + void PSendSysMessage( int32 entry, ... ); + + int ParseCommands(const char* text); + + protected: + bool hasStringAbbr(const char* s1, const char* s2); + void SendGlobalSysMessage(const char *str); + + bool ExecuteCommandInTable(ChatCommand *table, const char* text, std::string fullcommand); + bool ShowHelpForCommand(ChatCommand *table, const char* cmd); + bool ShowHelpForSubCommands(ChatCommand *table, char const* cmd, char const* subcmd); + + ChatCommand* getCommandTable(); + + bool HandleHelpCommand(const char* args); + bool HandleCommandsCommand(const char* args); + bool HandleAcctCommand(const char* args); + bool HandleStartCommand(const char* args); + bool HandleInfoCommand(const char* args); + bool HandleDismountCommand(const char* args); + bool HandleSaveCommand(const char* args); + bool HandleGMListCommand(const char* args); + + bool HandleNamegoCommand(const char* args); + bool HandleGonameCommand(const char* args); + bool HandleGroupgoCommand(const char* args); + bool HandleRecallCommand(const char* args); + bool HandleAnnounceCommand(const char* args); + bool HandleNotifyCommand(const char* args); + bool HandleGMmodeCommand(const char* args); + bool HandleVisibleCommand(const char* args); + bool HandleGPSCommand(const char* args); + bool HandleTaxiCheatCommand(const char* args); + bool HandleWhispersCommand(const char* args); + bool HandleSayCommand(const char* args); + bool HandleNpcWhisperCommand(const char* args); + bool HandleYellCommand(const char* args); + bool HandlePlayEmoteCommand(const char* args); + bool HandleSendMailCommand(const char* args); + bool HandleNameTeleCommand(const char* args); + bool HandleGroupTeleCommand(const char* args); + bool HandleDrunkCommand(const char* args); + + bool HandleEventActiveListCommand(const char* args); + bool HandleEventStartCommand(const char* args); + bool HandleEventStopCommand(const char* args); + bool HandleEventInfoCommand(const char* args); + + bool HandleModifyKnownTitlesCommand(const char* args); + bool HandleModifyHPCommand(const char* args); + bool HandleModifyManaCommand(const char* args); + bool HandleModifyRageCommand(const char* args); + bool HandleModifyEnergyCommand(const char* args); + bool HandleModifyMoneyCommand(const char* args); + bool HandleModifyASpeedCommand(const char* args); + bool HandleModifySpeedCommand(const char* args); + bool HandleModifyBWalkCommand(const char* args); + bool HandleModifyFlyCommand(const char* args); + bool HandleModifySwimCommand(const char* args); + bool HandleModifyScaleCommand(const char* args); + bool HandleModifyMountCommand(const char* args); + bool HandleModifyBitCommand(const char* args); + bool HandleModifyFactionCommand(const char* args); + bool HandleModifySpellCommand(const char* args); + bool HandleModifyTalentCommand (const char* args); + bool HandleModifyHonorCommand (const char* args); + bool HandleModifyRepCommand(const char* args); + bool HandleModifyArenaCommand(const char* args); + + bool HandleReloadCommand(const char* args); + bool HandleReloadAllCommand(const char* args); + bool HandleReloadAllAreaCommand(const char* args); + bool HandleReloadAllItemCommand(const char* args); + bool HandleReloadAllLootCommand(const char* args); + bool HandleReloadAllNpcCommand(const char* args); + bool HandleReloadAllQuestCommand(const char* args); + bool HandleReloadAllScriptsCommand(const char* args); + bool HandleReloadAllSpellCommand(const char* args); + + bool HandleReloadConfigCommand(const char* args); + + bool HandleReloadAreaTriggerTavernCommand(const char* args); + bool HandleReloadAreaTriggerTeleportCommand(const char* args); + bool HandleReloadEventScriptsCommand(const char* args); + bool HandleReloadCommandCommand(const char* args); + bool HandleReloadCreatureQuestRelationsCommand(const char* args); + bool HandleReloadCreatureQuestInvRelationsCommand(const char* args); + bool HandleReloadGameGraveyardZoneCommand(const char* args); + bool HandleReloadGameObjectScriptsCommand(const char* args); + bool HandleReloadGameTeleCommand(const char* args); + bool HandleReloadGOQuestRelationsCommand(const char* args); + bool HandleReloadGOQuestInvRelationsCommand(const char* args); + bool HandleReloadLootTemplatesCreatureCommand(const char* args); + bool HandleReloadLootTemplatesDisenchantCommand(const char* args); + bool HandleReloadLootTemplatesFishingCommand(const char* args); + bool HandleReloadLootTemplatesGameobjectCommand(const char* args); + bool HandleReloadLootTemplatesItemCommand(const char* args); + bool HandleReloadLootTemplatesPickpocketingCommand(const char* args); + bool HandleReloadLootTemplatesProspectingCommand(const char* args); + bool HandleReloadLootTemplatesReferenceCommand(const char* args); + bool HandleReloadLootTemplatesQuestMailCommand(const char* args); + bool HandleReloadLootTemplatesSkinningCommand(const char* args); + bool HandleReloadMangosStringCommand(const char* args); + bool HandleReloadNpcGossipCommand(const char* args); + bool HandleReloadNpcTrainerCommand(const char* args); + bool HandleReloadNpcVendorCommand(const char* args); + bool HandleReloadQuestAreaTriggersCommand(const char* args); + bool HandleReloadQuestEndScriptsCommand(const char* args); + bool HandleReloadQuestStartScriptsCommand(const char* args); + bool HandleReloadQuestTemplateCommand(const char* args); + bool HandleReloadReservedNameCommand(const char*); + bool HandleReloadSkillDiscoveryTemplateCommand(const char* args); + bool HandleReloadSkillExtraItemTemplateCommand(const char* args); + bool HandleReloadSkillFishingBaseLevelCommand(const char* args); + bool HandleReloadSpellAffectCommand(const char* args); + bool HandleReloadSpellChainCommand(const char* args); + bool HandleReloadSpellElixirCommand(const char* args); + bool HandleReloadSpellLearnSpellCommand(const char* args); + bool HandleReloadSpellProcEventCommand(const char* args); + bool HandleReloadSpellScriptTargetCommand(const char* args); + bool HandleReloadSpellScriptsCommand(const char* args); + bool HandleReloadSpellTargetPositionCommand(const char* args); + bool HandleReloadSpellThreatsCommand(const char* args); + bool HandleReloadSpellPetAurasCommand(const char* args); + bool HandleReloadPageTextsCommand(const char* args); + bool HandleReloadItemEnchantementsCommand(const char* args); + + bool HandleInstanceListBindsCommand(const char* args); + bool HandleInstanceUnbindCommand(const char* args); + bool HandleInstanceStatsCommand(const char* args); + bool HandleInstanceSaveDataCommand(const char * args); + + bool HandleAddHonorCommand(const char* args); + bool HandleHonorAddKillCommand(const char* args); + bool HandleUpdateHonorFieldsCommand(const char* args); + + bool HandleLoadScriptsCommand(const char* args); + bool HandleSendQuestPartyMsgCommand(const char* args); + bool HandleSendQuestInvalidMsgCommand(const char* args); + + bool HandleDebugInArcCommand(const char* args); + bool HandleDebugSpellFailCommand(const char* args); + + bool HandleGUIDCommand(const char* args); + bool HandleNameCommand(const char* args); + bool HandleSubNameCommand(const char* args); + bool HandleItemMoveCommand(const char* args); + bool HandleDelCreatureCommand(const char* args); + bool HandleDeMorphCommand(const char* args); + bool HandleAddVendorItemCommand(const char* args); + bool HandleDelVendorItemCommand(const char* args); + bool HandleAddMoveCommand(const char* args); + bool HandleSetMoveTypeCommand(const char* args); + bool HandleChangeLevelCommand(const char* args); + bool HandleSetPoiCommand(const char* args); + bool HandleEquipErrorCommand(const char* args); + bool HandleNPCFlagCommand(const char* args); + bool HandleSetModelCommand(const char* args); + bool HandleFactionIdCommand(const char* args); + bool HandleAddSpwCommand(const char* args); + bool HandleSpawnDistCommand(const char* args); + bool HandleSpawnTimeCommand(const char* args); + bool HandleGoCreatureCommand(const char* args); + bool HandleGoObjectCommand(const char* args); + bool HandleGoTriggerCommand(const char* args); + bool HandleGoGraveyardCommand(const char* args); + bool HandleTargetObjectCommand(const char* args); + bool HandleDelObjectCommand(const char* args); + bool HandleMoveCreatureCommand(const char* args); + bool HandleMoveObjectCommand(const char* args); + bool HandleTurnObjectCommand(const char* args); + bool HandlePInfoCommand(const char* args); + bool HandlePLimitCommand(const char* args); + bool HandleMuteCommand(const char* args); + bool HandleUnmuteCommand(const char* args); + bool HandleMovegensCommand(const char* args); + + bool HandleBanCommand(const char* args); + bool HandleUnBanCommand(const char* args); + bool HandleBanInfoCommand(const char* args); + bool HandleBanListCommand(const char* args); + bool HandleIdleRestartCommand(const char* args); + bool HandleIdleShutDownCommand(const char* args); + bool HandleShutDownCommand(const char* args); + bool HandleRestartCommand(const char* args); + bool HandleSecurityCommand(const char* args); + bool HandleGoXYCommand(const char* args); + bool HandleGoXYZCommand(const char* args); + bool HandleGoZoneXYCommand(const char* args); + bool HandleGoGridCommand(const char* args); + bool HandleAddWeaponCommand(const char* args); + bool HandleAllowMovementCommand(const char* args); + bool HandleGoCommand(const char* args); + + bool HandleLearnCommand(const char* args); + bool HandleLearnAllCommand(const char* args); + bool HandleLearnAllGMCommand(const char* args); + bool HandleLearnAllCraftsCommand(const char* args); + bool HandleLearnAllRecipesCommand(const char* args); + bool HandleLearnAllDefaultCommand(const char* args); + bool HandleLearnAllLangCommand(const char* args); + bool HandleLearnAllMyClassCommand(const char* args); + bool HandleLearnAllMySpellsCommand(const char* args); + bool HandleLearnAllMyTalentsCommand(const char* args); + + bool HandleLookupAreaCommand(const char* args); + bool HandleLookupCreatureCommand(const char* args); + bool HandleLookupEventCommand(const char* args); + bool HandleLookupFactionCommand(const char * args); + bool HandleLookupItemCommand(const char * args); + bool HandleLookupItemSetCommand(const char * args); + bool HandleLookupObjectCommand(const char* args); + bool HandleLookupPlayerIpCommand(const char* args); + bool HandleLookupPlayerAccountCommand(const char* args); + bool HandleLookupPlayerEmailCommand(const char* args); + bool HandleLookupQuestCommand(const char* args); + bool HandleLookupSkillCommand(const char* args); + bool HandleLookupSpellCommand(const char* args); + bool HandleLookupTeleCommand(const char * args); + + bool HandleCooldownCommand(const char* args); + bool HandleUnLearnCommand(const char* args); + bool HandleGetDistanceCommand(const char* args); + bool HandleGameObjectCommand(const char* args); + bool HandleAnimCommand(const char* args); + bool HandlePlaySoundCommand(const char* args); + bool HandleStandStateCommand(const char* args); + bool HandleDieCommand(const char* args); + bool HandleDamageCommand(const char *args); + bool HandleReviveCommand(const char* args); + bool HandleMorphCommand(const char* args); + bool HandleAuraCommand(const char* args); + bool HandleUnAuraCommand(const char* args); + bool HandleLinkGraveCommand(const char* args); + bool HandleNearGraveCommand(const char* args); + bool HandleSpawnTransportCommand(const char* args); + bool HandleExploreCheatCommand(const char* args); + bool HandleTextEmoteCommand(const char* args); + bool HandleNpcInfoCommand(const char* args); + bool HandleHoverCommand(const char* args); + bool HandleLevelUpCommand(const char* args); + bool HandleShowAreaCommand(const char* args); + bool HandleHideAreaCommand(const char* args); + bool HandleAddItemCommand(const char* args); + bool HandleAddItemSetCommand(const char* args); + + bool HandleGuildCreateCommand(const char* args); + bool HandleGuildInviteCommand(const char* args); + bool HandleGuildUninviteCommand(const char* args); + bool HandleGuildRankCommand(const char* args); + bool HandleGuildDeleteCommand(const char* args); + bool HandleUpdate(const char* args); + bool HandleBankCommand(const char* args); + bool HandleChangeWeather(const char* args); + bool HandleKickPlayerCommand(const char * args); + bool HandleTeleCommand(const char * args); + bool HandleAddTeleCommand(const char * args); + bool HandleDelTeleCommand(const char * args); + bool HandleListAurasCommand(const char * args); + + bool HandleResetHonorCommand(const char * args); + bool HandleResetLevelCommand(const char * args); + bool HandleResetSpellsCommand(const char * args); + + bool HandleResetStatsCommand(const char * args); + bool HandleResetTalentsCommand(const char * args); + + bool HandleResetAllCommand(const char * args); + bool HandleTicketCommand(const char* args); + bool HandleDelTicketCommand(const char* args); + bool HandleMaxSkillCommand(const char* args); + bool HandleSetSkillCommand(const char* args); + bool HandleListCreatureCommand(const char* args); + bool HandleListItemCommand(const char* args); + bool HandleListObjectCommand(const char* args); + bool HandleNearObjectCommand(const char* args); + bool HandlePasswordCommand(const char* args); + bool HandleLockAccountCommand(const char* args); + bool HandleRespawnCommand(const char* args); + bool HandleWpAddCommand(const char* args); + bool HandleWpModifyCommand(const char* args); + bool HandleWpShowCommand(const char* args); + bool HandleWpExportCommand(const char* args); + bool HandleWpImportCommand(const char* args); + bool HandleFlyModeCommand(const char* args); + bool HandleSendOpcodeCommand(const char* args); + bool HandleSellErrorCommand(const char* args); + bool HandleBuyErrorCommand(const char* args); + bool HandleUpdateWorldStateCommand(const char* args); + bool HandlePlaySound2Command(const char* args); + bool HandleSendChannelNotifyCommand(const char* args); + bool HandleSendChatMsgCommand(const char* args); + bool HandleRenameCommand(const char * args); + bool HandleLoadPDumpCommand(const char *args); + bool HandleWritePDumpCommand(const char *args); + bool HandleChangeEntryCommand(const char *args); + bool HandleCastCommand(const char *args); + bool HandleCastBackCommand(const char *args); + bool HandleCastDistCommand(const char *args); + bool HandleCastSelfCommand(const char *args); + bool HandleCastTargetCommand(const char *args); + bool HandleComeToMeCommand(const char *args); + bool HandleCombatStopCommand(const char *args); + + //! Development Commands + bool HandleSetValue(const char* args); + bool HandleGetValue(const char* args); + bool HandleSet32Bit(const char* args); + bool HandleMod32Value(const char* args); + bool HandleAddQuest(const char * args); + bool HandleRemoveQuest(const char * args); + bool HandleCompleteQuest(const char * args); + bool HandleSaveAllCommand(const char* args); + bool HandleGetItemState(const char * args); + bool HandleGetLootRecipient(const char * args); + + Player* getSelectedPlayer(); + Creature* getSelectedCreature(); + Unit* getSelectedUnit(); + char* extractKeyFromLink(char* text, char const* linkType, char** something1 = NULL); + char* extractKeyFromLink(char* text, char const* const* linkTypes, int* found_idx, char** something1 = NULL); + uint32 extractSpellIdFromLink(char* text); + GameTele const* extractGameTeleFromLink(char* text); + + GameObject* GetObjectGlobalyWithGuidOrNearWithDbGuid(uint32 lowguid,uint32 entry); + + WorldSession * m_session; + + // Utility methods for commands + void ShowTicket(uint64 guid, char const* text, char const* time); + uint32 GetTicketIDByNum(uint32 num); + bool LookupPlayerSearchCommand(QueryResult* result, int32 limit); + + void SetSentErrorMessage(bool val){ sentErrorMessage = val;}; + private: + // common global flag + static bool load_command_table; + bool sentErrorMessage; +}; +#endif + +char const *fmtstring( char const *format, ... ); diff --git a/src/game/Creature.cpp b/src/game/Creature.cpp index bab0c16b4e9..b8943f55061 100644 --- a/src/game/Creature.cpp +++ b/src/game/Creature.cpp @@ -1,1993 +1,1928 @@ -/* - * Copyright (C) 2005-2008 MaNGOS - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "Common.h" -#include "Database/DatabaseEnv.h" -#include "WorldPacket.h" -#include "WorldSession.h" -#include "World.h" -#include "ObjectMgr.h" -#include "SpellMgr.h" -#include "Creature.h" -#include "QuestDef.h" -#include "GossipDef.h" -#include "Player.h" -#include "Opcodes.h" -#include "Log.h" -#include "LootMgr.h" -#include "MapManager.h" -#include "CreatureAI.h" -#include "CreatureAISelector.h" -#include "Formulas.h" -#include "SpellAuras.h" -#include "WaypointMovementGenerator.h" -#include "InstanceData.h" -#include "BattleGround.h" -#include "Util.h" -#include "GridNotifiers.h" -#include "GridNotifiersImpl.h" -#include "CellImpl.h" - -// apply implementation of the singletons -#include "Policies/SingletonImp.h" - -Creature::Creature() : -Unit(), i_AI(NULL), -lootForPickPocketed(false), lootForBody(false), m_groupLootTimer(0), lootingGroupLeaderGUID(0), -m_itemsLoaded(false), m_trainerSpellsLoaded(false), m_trainer_type(0), m_lootMoney(0), m_lootRecipient(0), -m_deathTimer(0), m_respawnTime(0), m_respawnDelay(25), m_corpseDelay(60), m_respawnradius(0.0f), -m_gossipOptionLoaded(false),m_NPCTextId(0), m_emoteState(0), m_isPet(false), m_isTotem(false), -m_regenTimer(2000), m_defaultMovementType(IDLE_MOTION_TYPE), m_equipmentId(0), -m_AlreadyCallAssistence(false), m_regenHealth(true), m_AI_locked(false), m_isDeadByDefault(false), -m_meleeDamageSchoolMask(SPELL_SCHOOL_MASK_NORMAL),m_creatureInfo(NULL) -{ - m_valuesCount = UNIT_END; - - for(int i =0; i<4; ++i) - m_spells[i] = 0; - - m_CreatureSpellCooldowns.clear(); - m_CreatureCategoryCooldowns.clear(); - m_GlobalCooldown = 0; - m_unit_movement_flags = MOVEMENTFLAG_WALK_MODE; -} - -Creature::~Creature() -{ - CleanupsBeforeDelete(); - - m_trainer_spells.clear(); - m_vendor_items.clear(); - - delete i_AI; - i_AI = NULL; -} - -void Creature::AddToWorld() -{ - ///- Register the creature for guid lookup - if(!IsInWorld()) ObjectAccessor::Instance().AddObject(this); - Unit::AddToWorld(); -} - -void Creature::RemoveFromWorld() -{ - ///- Remove the creature from the accessor - if(IsInWorld()) ObjectAccessor::Instance().RemoveObject(this); - Unit::RemoveFromWorld(); -} - -void Creature::LoadTrainerSpells() -{ - if(m_trainerSpellsLoaded) - return; - - m_trainer_spells.clear(); - m_trainer_type = 0; - - Field *fields; - QueryResult *result = WorldDatabase.PQuery("SELECT spell,spellcost,reqskill,reqskillvalue,reqlevel FROM npc_trainer WHERE entry = '%u'", GetEntry()); - - if(!result) - return; - - do - { - fields = result->Fetch(); - - uint32 spellid = fields[0].GetUInt32(); - SpellEntry const *spellinfo = sSpellStore.LookupEntry(spellid); - - if(!spellinfo) - { - sLog.outErrorDb("Trainer (Entry: %u ) has non existing spell %u",GetEntry(),spellid); - continue; - } - - if(!SpellMgr::IsSpellValid(spellinfo)) - { - sLog.outErrorDb("LoadTrainerSpells: Trainer (Entry: %u) has broken learning spell %u.", GetEntry(), spellid); - continue; - } - - if(SpellMgr::IsProfessionSpell(spellinfo->Id)) - m_trainer_type = 2; - - TrainerSpell tspell; - tspell.spell = spellinfo; - tspell.spellcost = fields[1].GetUInt32(); - tspell.reqskill = fields[2].GetUInt32(); - tspell.reqskillvalue= fields[3].GetUInt32(); - tspell.reqlevel = fields[4].GetUInt32(); - - m_trainer_spells.push_back(tspell); - - } while( result->NextRow() ); - - delete result; - - m_trainerSpellsLoaded = true; -} - -void Creature::RemoveCorpse() -{ - if( getDeathState()!=CORPSE && !m_isDeadByDefault || getDeathState()!=ALIVE && m_isDeadByDefault ) - return; - - m_deathTimer = 0; - setDeathState(DEAD); - ObjectAccessor::UpdateObjectVisibility(this); - loot.clear(); - m_respawnTime = time(NULL) + m_respawnDelay; - - float x,y,z,o; - GetRespawnCoord(x, y, z, &o); - MapManager::Instance().GetMap(GetMapId(), this)->CreatureRelocation(this,x,y,z,o); -} - -/** - * change the entry of creature until respawn - */ -bool Creature::InitEntry(uint32 Entry, uint32 team, const CreatureData *data ) -{ - CreatureInfo const *normalInfo = objmgr.GetCreatureTemplate(Entry); - if(!normalInfo) - { - sLog.outErrorDb("Creature::UpdateEntry creature entry %u does not exist.", Entry); - return false; - } - - // get heroic mode entry - uint32 actualEntry = Entry; - CreatureInfo const *cinfo = normalInfo; - if(normalInfo->HeroicEntry) - { - Map *map = MapManager::Instance().FindMap(GetMapId(), GetInstanceId()); - if(map && map->IsHeroic()) - { - cinfo = objmgr.GetCreatureTemplate(normalInfo->HeroicEntry); - if(!cinfo) - { - sLog.outErrorDb("Creature::UpdateEntry creature heroic entry %u does not exist.", actualEntry); - return false; - } - } - } - - SetUInt32Value(OBJECT_FIELD_ENTRY, Entry); // normal entry always - m_creatureInfo = cinfo; // map mode related always - - if (cinfo->DisplayID_A == 0 || cinfo->DisplayID_H == 0) // Cancel load if no model defined - { - sLog.outErrorDb("Creature (Entry: %u) has no model defined for Horde or Alliance in table `creature_template`, can't load. ",Entry); - return false; - } - - uint32 display_id = objmgr.ChooseDisplayId(team, GetCreatureInfo(), data); - CreatureModelInfo const *minfo = objmgr.GetCreatureModelRandomGender(display_id); - if (!minfo) - { - sLog.outErrorDb("Creature (Entry: %u) has model %u not found in table `creature_model_info`, can't load. ", Entry, display_id); - return false; - } - else - display_id = minfo->modelid; // it can be different (for another gender) - - SetDisplayId(display_id); - SetNativeDisplayId(display_id); - SetByteValue(UNIT_FIELD_BYTES_0, 2, minfo->gender); - - // Load creature equipment - if(!data || data->equipmentId == 0) - { // use default from the template - LoadEquipment(cinfo->equipmentId); - } - else if(data && data->equipmentId != -1) - { // override, -1 means no equipment - LoadEquipment(data->equipmentId); - } - - SetName(normalInfo->Name); // at normal entry always - - SetFloatValue(UNIT_FIELD_BOUNDINGRADIUS,minfo->bounding_radius); - SetFloatValue(UNIT_FIELD_COMBATREACH,minfo->combat_reach ); - - SetFloatValue(UNIT_MOD_CAST_SPEED, 1.0f); - - SetSpeed(MOVE_WALK, cinfo->speed ); - SetSpeed(MOVE_RUN, cinfo->speed ); - SetSpeed(MOVE_SWIM, cinfo->speed ); - - SetFloatValue(OBJECT_FIELD_SCALE_X, cinfo->scale); - - // checked at loading - m_defaultMovementType = MovementGeneratorType(cinfo->MovementType); - if(!m_respawnradius && m_defaultMovementType==RANDOM_MOTION_TYPE) - m_defaultMovementType = IDLE_MOTION_TYPE; - - return true; -} - -bool Creature::UpdateEntry(uint32 Entry, uint32 team, const CreatureData *data ) -{ - if(!InitEntry(Entry,team,data)) - return false; - - m_regenHealth = GetCreatureInfo()->RegenHealth; - - // creatures always have melee weapon ready if any - SetByteValue(UNIT_FIELD_BYTES_2, 0, SHEATH_STATE_MELEE ); - SetByteValue(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_AURAS ); - - SelectLevel(GetCreatureInfo()); - if (team == HORDE) - SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE, GetCreatureInfo()->faction_H); - else - SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE, GetCreatureInfo()->faction_A); - - SetUInt32Value(UNIT_NPC_FLAGS,GetCreatureInfo()->npcflag); - - SetAttackTime(BASE_ATTACK, GetCreatureInfo()->baseattacktime); - SetAttackTime(OFF_ATTACK, GetCreatureInfo()->baseattacktime); - SetAttackTime(RANGED_ATTACK,GetCreatureInfo()->rangeattacktime); - - SetUInt32Value(UNIT_FIELD_FLAGS,GetCreatureInfo()->Flags); - SetUInt32Value(UNIT_DYNAMIC_FLAGS,GetCreatureInfo()->dynamicflags); - - SetModifierValue(UNIT_MOD_ARMOR, BASE_VALUE, float(GetCreatureInfo()->armor)); - SetModifierValue(UNIT_MOD_RESISTANCE_HOLY, BASE_VALUE, float(GetCreatureInfo()->resistance1)); - SetModifierValue(UNIT_MOD_RESISTANCE_FIRE, BASE_VALUE, float(GetCreatureInfo()->resistance2)); - SetModifierValue(UNIT_MOD_RESISTANCE_NATURE, BASE_VALUE, float(GetCreatureInfo()->resistance3)); - SetModifierValue(UNIT_MOD_RESISTANCE_FROST, BASE_VALUE, float(GetCreatureInfo()->resistance4)); - SetModifierValue(UNIT_MOD_RESISTANCE_SHADOW, BASE_VALUE, float(GetCreatureInfo()->resistance5)); - SetModifierValue(UNIT_MOD_RESISTANCE_ARCANE, BASE_VALUE, float(GetCreatureInfo()->resistance6)); - - SetCanModifyStats(true); - UpdateAllStats(); - - FactionTemplateEntry const* factionTemplate = sFactionTemplateStore.LookupEntry(GetCreatureInfo()->faction_A); - if (factionTemplate) // check and error show at loading templates - { - FactionEntry const* factionEntry = sFactionStore.LookupEntry(factionTemplate->faction); - if (factionEntry) - if( !(GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_CIVILIAN) && - (factionEntry->team == ALLIANCE || factionEntry->team == HORDE) ) - SetPvP(true); - } - - m_spells[0] = GetCreatureInfo()->spell1; - m_spells[1] = GetCreatureInfo()->spell2; - m_spells[2] = GetCreatureInfo()->spell3; - m_spells[3] = GetCreatureInfo()->spell4; - - return true; -} - -void Creature::Update(uint32 diff) -{ - if(m_GlobalCooldown <= diff) - m_GlobalCooldown = 0; - else - m_GlobalCooldown -= diff; - - switch( m_deathState ) - { - case JUST_ALIVED: - // Dont must be called, see Creature::setDeathState JUST_ALIVED -> ALIVE promoting. - sLog.outError("Creature (GUIDLow: %u Entry: %u ) in wrong state: JUST_ALIVED (4)",GetGUIDLow(),GetEntry()); - break; - case JUST_DIED: - // Dont must be called, see Creature::setDeathState JUST_DIED -> CORPSE promoting. - sLog.outError("Creature (GUIDLow: %u Entry: %u ) in wrong state: JUST_DEAD (1)",GetGUIDLow(),GetEntry()); - break; - case DEAD: - { - if( m_respawnTime <= time(NULL) ) - { - DEBUG_LOG("Respawning..."); - m_respawnTime = 0; - lootForPickPocketed = false; - lootForBody = false; - - if(m_originalEntry != GetUInt32Value(OBJECT_FIELD_ENTRY)) - UpdateEntry(m_originalEntry); - - CreatureInfo const *cinfo = GetCreatureInfo(); - - SelectLevel(cinfo); - SetUInt32Value(UNIT_DYNAMIC_FLAGS, 0); - if (m_isDeadByDefault) - { - setDeathState(JUST_DIED); - SetHealth(0); - i_motionMaster.Clear(); - clearUnitState(UNIT_STAT_ALL_STATE); - LoadCreaturesAddon(true); - } - else - setDeathState( JUST_ALIVED ); - - //Call AI respawn virtual function - i_AI->JustRespawned(); - - MapManager::Instance().GetMap(GetMapId(), this)->Add(this); - } - break; - } - case CORPSE: - { - if (m_isDeadByDefault) - break; - - if( m_deathTimer <= diff ) - { - RemoveCorpse(); - DEBUG_LOG("Removing corpse... %u ", GetUInt32Value(OBJECT_FIELD_ENTRY)); - } - else - { - m_deathTimer -= diff; - if (m_groupLootTimer && lootingGroupLeaderGUID) - { - if(diff <= m_groupLootTimer) - { - m_groupLootTimer -= diff; - } - else - { - Group* group = objmgr.GetGroupByLeader(lootingGroupLeaderGUID); - if (group) - group->EndRoll(); - m_groupLootTimer = 0; - lootingGroupLeaderGUID = 0; - } - } - } - - break; - } - case ALIVE: - { - if (m_isDeadByDefault) - { - if( m_deathTimer <= diff ) - { - RemoveCorpse(); - DEBUG_LOG("Removing alive corpse... %u ", GetUInt32Value(OBJECT_FIELD_ENTRY)); - } - else - { - m_deathTimer -= diff; - } - } - - Unit::Update( diff ); - - // creature can be dead after Unit::Update call - // CORPSE/DEAD state will processed at next tick (in other case death timer will be updated unexpectedly) - if(!isAlive()) - break; - - if(!IsInEvadeMode()) - { - // do not allow the AI to be changed during update - m_AI_locked = true; - i_AI->UpdateAI(diff); - m_AI_locked = false; - } - - // creature can be dead after UpdateAI call - // CORPSE/DEAD state will processed at next tick (in other case death timer will be updated unexpectedly) - if(!isAlive()) - break; - if(m_regenTimer > 0) - { - if(diff >= m_regenTimer) - m_regenTimer = 0; - else - m_regenTimer -= diff; - } - if (m_regenTimer != 0) - break; - - if (!isInCombat() || IsPolymorphed()) - RegenerateHealth(); - - RegenerateMana(); - - m_regenTimer = 2000; - break; - } - default: - break; - } -} - -void Creature::RegenerateMana() -{ - uint32 curValue = GetPower(POWER_MANA); - uint32 maxValue = GetMaxPower(POWER_MANA); - - if (curValue >= maxValue) - return; - - uint32 addvalue = 0; - - // Combat and any controlled creature - if (isInCombat() || GetCharmerOrOwnerGUID()) - { - if(!IsUnderLastManaUseEffect()) - { - float ManaIncreaseRate = sWorld.getRate(RATE_POWER_MANA); - float Spirit = GetStat(STAT_SPIRIT); - - addvalue = uint32((Spirit/5.0f + 17.0f) * ManaIncreaseRate); - } - } - else - addvalue = maxValue/3; - - ModifyPower(POWER_MANA, addvalue); -} - -void Creature::RegenerateHealth() -{ - if (!isRegeneratingHealth()) - return; - - uint32 curValue = GetHealth(); - uint32 maxValue = GetMaxHealth(); - - if (curValue >= maxValue) - return; - - uint32 addvalue = 0; - - // Not only pet, but any controelled creature - if(GetCharmerOrOwnerGUID()) - { - float HealthIncreaseRate = sWorld.getRate(RATE_HEALTH); - float Spirit = GetStat(STAT_SPIRIT); - - if( GetPower(POWER_MANA) > 0 ) - addvalue = uint32(Spirit * 0.25 * HealthIncreaseRate); - else - addvalue = uint32(Spirit * 0.80 * HealthIncreaseRate); - } - else - addvalue = maxValue/3; - - ModifyHealth(addvalue); -} - -bool Creature::AIM_Initialize() -{ - // make sure nothing can change the AI during AI update - if(m_AI_locked) - { - sLog.outDebug("AIM_Initialize: failed to init, locked."); - return false; - } - - CreatureAI * oldAI = i_AI; - i_motionMaster.Initialize(); - i_AI = FactorySelector::selectAI(this); - if (oldAI) - delete oldAI; - return true; -} - -bool Creature::Create (uint32 guidlow, Map *map, uint32 Entry, uint32 team, const CreatureData *data) -{ - SetMapId(map->GetId()); - SetInstanceId(map->GetInstanceId()); - - //oX = x; oY = y; dX = x; dY = y; m_moveTime = 0; m_startMove = 0; - const bool bResult = CreateFromProto(guidlow, Entry, team, data); - - if (bResult) - { - switch (GetCreatureInfo()->rank) - { - case CREATURE_ELITE_RARE: - m_corpseDelay = sWorld.getConfig(CONFIG_CORPSE_DECAY_RARE); - break; - case CREATURE_ELITE_ELITE: - m_corpseDelay = sWorld.getConfig(CONFIG_CORPSE_DECAY_ELITE); - break; - case CREATURE_ELITE_RAREELITE: - m_corpseDelay = sWorld.getConfig(CONFIG_CORPSE_DECAY_RAREELITE); - break; - case CREATURE_ELITE_WORLDBOSS: - m_corpseDelay = sWorld.getConfig(CONFIG_CORPSE_DECAY_WORLDBOSS); - break; - default: - m_corpseDelay = sWorld.getConfig(CONFIG_CORPSE_DECAY_NORMAL); - break; - } - } - - return bResult; -} - -bool Creature::isCanTrainingOf(Player* pPlayer, bool msg) const -{ - if(!isTrainer()) - return false; - - if(m_trainer_spells.empty()) - { - sLog.outErrorDb("Creature %u (Entry: %u) have UNIT_NPC_FLAG_TRAINER but have empty trainer spell list.", - GetGUIDLow(),GetEntry()); - return false; - } - - switch(GetCreatureInfo()->trainer_type) - { - case TRAINER_TYPE_CLASS: - if(pPlayer->getClass()!=GetCreatureInfo()->classNum) - { - if(msg) - { - pPlayer->PlayerTalkClass->ClearMenus(); - switch(GetCreatureInfo()->classNum) - { - case CLASS_DRUID: pPlayer->PlayerTalkClass->SendGossipMenu( 4913,GetGUID()); break; - case CLASS_HUNTER: pPlayer->PlayerTalkClass->SendGossipMenu(10090,GetGUID()); break; - case CLASS_MAGE: pPlayer->PlayerTalkClass->SendGossipMenu( 328,GetGUID()); break; - case CLASS_PALADIN:pPlayer->PlayerTalkClass->SendGossipMenu( 1635,GetGUID()); break; - case CLASS_PRIEST: pPlayer->PlayerTalkClass->SendGossipMenu( 4436,GetGUID()); break; - case CLASS_ROGUE: pPlayer->PlayerTalkClass->SendGossipMenu( 4797,GetGUID()); break; - case CLASS_SHAMAN: pPlayer->PlayerTalkClass->SendGossipMenu( 5003,GetGUID()); break; - case CLASS_WARLOCK:pPlayer->PlayerTalkClass->SendGossipMenu( 5836,GetGUID()); break; - case CLASS_WARRIOR:pPlayer->PlayerTalkClass->SendGossipMenu( 4985,GetGUID()); break; - } - } - return false; - } - break; - case TRAINER_TYPE_PETS: - if(pPlayer->getClass()!=CLASS_HUNTER) - { - pPlayer->PlayerTalkClass->ClearMenus(); - pPlayer->PlayerTalkClass->SendGossipMenu(3620,GetGUID()); - return false; - } - break; - case TRAINER_TYPE_MOUNTS: - if(GetCreatureInfo()->race && pPlayer->getRace() != GetCreatureInfo()->race) - { - if(msg) - { - pPlayer->PlayerTalkClass->ClearMenus(); - switch(GetCreatureInfo()->classNum) - { - case RACE_DWARF: pPlayer->PlayerTalkClass->SendGossipMenu(5865,GetGUID()); break; - case RACE_GNOME: pPlayer->PlayerTalkClass->SendGossipMenu(4881,GetGUID()); break; - case RACE_HUMAN: pPlayer->PlayerTalkClass->SendGossipMenu(5861,GetGUID()); break; - case RACE_NIGHTELF: pPlayer->PlayerTalkClass->SendGossipMenu(5862,GetGUID()); break; - case RACE_ORC: pPlayer->PlayerTalkClass->SendGossipMenu(5863,GetGUID()); break; - case RACE_TAUREN: pPlayer->PlayerTalkClass->SendGossipMenu(5864,GetGUID()); break; - case RACE_TROLL: pPlayer->PlayerTalkClass->SendGossipMenu(5816,GetGUID()); break; - case RACE_UNDEAD_PLAYER:pPlayer->PlayerTalkClass->SendGossipMenu( 624,GetGUID()); break; - case RACE_BLOODELF: pPlayer->PlayerTalkClass->SendGossipMenu(5862,GetGUID()); break; - case RACE_DRAENEI: pPlayer->PlayerTalkClass->SendGossipMenu(5864,GetGUID()); break; - } - } - return false; - } - break; - case TRAINER_TYPE_TRADESKILLS: - if(GetCreatureInfo()->trainer_spell && !pPlayer->HasSpell(GetCreatureInfo()->trainer_spell)) - { - if(msg) - { - pPlayer->PlayerTalkClass->ClearMenus(); - pPlayer->PlayerTalkClass->SendGossipMenu(11031,GetGUID()); - } - return false; - } - break; - default: - return false; // checked and error output at creature_template loading - } - return true; -} - -bool Creature::isCanIneractWithBattleMaster(Player* pPlayer, bool msg) const -{ - if(!isBattleMaster()) - return false; - - uint32 bgTypeId = objmgr.GetBattleMasterBG(GetEntry()); - if(!msg) - return pPlayer->GetBGAccessByLevel(bgTypeId); - - if(!pPlayer->GetBGAccessByLevel(bgTypeId)) - { - pPlayer->PlayerTalkClass->ClearMenus(); - switch(bgTypeId) - { - case BATTLEGROUND_AV: pPlayer->PlayerTalkClass->SendGossipMenu(7616,GetGUID()); break; - case BATTLEGROUND_WS: pPlayer->PlayerTalkClass->SendGossipMenu(7599,GetGUID()); break; - case BATTLEGROUND_AB: pPlayer->PlayerTalkClass->SendGossipMenu(7642,GetGUID()); break; - case BATTLEGROUND_EY: - case BATTLEGROUND_NA: - case BATTLEGROUND_BE: - case BATTLEGROUND_AA: - case BATTLEGROUND_RL: pPlayer->PlayerTalkClass->SendGossipMenu(10024,GetGUID()); break; - break; - } - return false; - } - return true; -} - -bool Creature::isCanTrainingAndResetTalentsOf(Player* pPlayer) const -{ - return pPlayer->getLevel() >= 10 - && GetCreatureInfo()->trainer_type == TRAINER_TYPE_CLASS - && pPlayer->getClass() == GetCreatureInfo()->classNum; -} - -void Creature::prepareGossipMenu( Player *pPlayer,uint32 gossipid ) -{ - PlayerMenu* pm=pPlayer->PlayerTalkClass; - pm->ClearMenus(); - - // lazy loading single time at use - LoadGossipOptions(); - - GossipOption* gso; - GossipOption* ingso; - - for( GossipOptionList::iterator i = m_goptions.begin( ); i != m_goptions.end( ); i++ ) - { - gso=&*i; - if(gso->GossipId == gossipid) - { - bool cantalking=true; - if(gso->Id==1) - { - uint32 textid=GetNpcTextId(); - GossipText * gossiptext=objmgr.GetGossipText(textid); - if(!gossiptext) - cantalking=false; - } - else - { - switch (gso->Action) - { - case GOSSIP_OPTION_QUESTGIVER: - pPlayer->PrepareQuestMenu(GetGUID()); - //if (pm->GetQuestMenu()->MenuItemCount() == 0) - cantalking=false; - //pm->GetQuestMenu()->ClearMenu(); - break; - case GOSSIP_OPTION_ARMORER: - cantalking=false; // added in special mode - break; - case GOSSIP_OPTION_SPIRITHEALER: - if( !pPlayer->isDead() ) - cantalking=false; - break; - case GOSSIP_OPTION_VENDOR: - // load vendor items if not yet - LoadGoods(); - - if(!GetItemCount()) - { - sLog.outErrorDb("Creature %u (Entry: %u) have UNIT_NPC_FLAG_VENDOR but have empty trading item list.", - GetGUIDLow(),GetEntry()); - cantalking=false; - } - break; - case GOSSIP_OPTION_TRAINER: - // Lazy loading at first access - LoadTrainerSpells(); - - if(!isCanTrainingOf(pPlayer,false)) - cantalking=false; - break; - case GOSSIP_OPTION_UNLEARNTALENTS: - if(!isCanTrainingAndResetTalentsOf(pPlayer)) - cantalking=false; - break; - case GOSSIP_OPTION_UNLEARNPETSKILLS: - if(!pPlayer->GetPet() || pPlayer->GetPet()->getPetType() != HUNTER_PET || pPlayer->GetPet()->m_spells.size() <= 1 || GetCreatureInfo()->trainer_type != TRAINER_TYPE_PETS || GetCreatureInfo()->classNum != CLASS_HUNTER) - cantalking=false; - break; - case GOSSIP_OPTION_TAXIVENDOR: - if ( pPlayer->GetSession()->SendLearnNewTaxiNode(this) ) - return; - break; - case GOSSIP_OPTION_BATTLEFIELD: - if(!isCanIneractWithBattleMaster(pPlayer,false)) - cantalking=false; - break; - case GOSSIP_OPTION_SPIRITGUIDE: - case GOSSIP_OPTION_INNKEEPER: - case GOSSIP_OPTION_BANKER: - case GOSSIP_OPTION_PETITIONER: - case GOSSIP_OPTION_STABLEPET: - case GOSSIP_OPTION_TABARDDESIGNER: - case GOSSIP_OPTION_AUCTIONEER: - break; // no checks - default: - sLog.outErrorDb("Creature %u (entry: %u) have unknown gossip option %u",GetGUIDLow(),GetEntry(),gso->Action); - break; - } - } - - if(!gso->Option.empty() && cantalking ) - { //note for future dev: should have database fields for BoxMessage & BoxMoney - pm->GetGossipMenu()->AddMenuItem((uint8)gso->Icon,gso->Option, gossipid,gso->Action,"",0,false); - ingso=gso; - } - } - } - - ///some gossips aren't handled in normal way ... so we need to do it this way .. TODO: handle it in normal way ;-) - if(pm->GetGossipMenu()->MenuItemCount()==0 && !pm->GetQuestMenu()->MenuItemCount()) - { - if(HasFlag(UNIT_NPC_FLAGS,UNIT_NPC_FLAG_TRAINER)) - { - LoadTrainerSpells(); // Lazy loading at first access - isCanTrainingOf(pPlayer,true); // output error message if need - } - if(HasFlag(UNIT_NPC_FLAGS,UNIT_NPC_FLAG_BATTLEMASTER)) - { - isCanIneractWithBattleMaster(pPlayer,true); // output error message if need - } - } -} - -void Creature::sendPreparedGossip(Player* player) -{ - if(!player) - return; - - GossipMenu* gossipmenu = player->PlayerTalkClass->GetGossipMenu(); - - // in case empty gossip menu open quest menu if any - if (gossipmenu->MenuItemCount() == 0 && GetNpcTextId() == 0) - { - player->SendPreparedQuest(GetGUID()); - return; - } - - // in case non empty gossip menu (that not included quests list size) show it - // (quest entries from quest menu wiill be included in list) - player->PlayerTalkClass->SendGossipMenu(GetNpcTextId(), GetGUID()); -} - -void Creature::OnGossipSelect(Player* player, uint32 option) -{ - GossipMenu* gossipmenu = player->PlayerTalkClass->GetGossipMenu(); - uint32 action=gossipmenu->GetItem(option).m_gAction; - uint32 zoneid=GetZoneId(); - uint64 guid=GetGUID(); - GossipOption const *gossip=GetGossipOption( action ); - uint32 textid; - if(!gossip) - { - zoneid=0; - gossip=GetGossipOption( action ); - if(!gossip) - return; - } - textid=GetGossipTextId( action, zoneid); - if(textid==0) - textid=GetNpcTextId(); - - switch (gossip->Action) - { - case GOSSIP_OPTION_GOSSIP: - player->PlayerTalkClass->CloseGossip(); - player->PlayerTalkClass->SendTalking( textid ); - break; - case GOSSIP_OPTION_SPIRITHEALER: - if( player->isDead() ) - CastSpell(this,17251,true,NULL,NULL,player->GetGUID()); - break; - case GOSSIP_OPTION_QUESTGIVER: - player->PrepareQuestMenu( guid ); - player->SendPreparedQuest( guid ); - break; - case GOSSIP_OPTION_VENDOR: - case GOSSIP_OPTION_ARMORER: - player->GetSession()->SendListInventory(guid); - break; - case GOSSIP_OPTION_STABLEPET: - player->GetSession()->SendStablePet(guid); - break; - case GOSSIP_OPTION_TRAINER: - player->GetSession()->SendTrainerList(guid); - break; - case GOSSIP_OPTION_UNLEARNTALENTS: - player->PlayerTalkClass->CloseGossip(); - player->SendTalentWipeConfirm(guid); - break; - case GOSSIP_OPTION_UNLEARNPETSKILLS: - player->PlayerTalkClass->CloseGossip(); - player->SendPetSkillWipeConfirm(); - break; - case GOSSIP_OPTION_TAXIVENDOR: - player->GetSession()->SendTaxiMenu(this); - break; - case GOSSIP_OPTION_INNKEEPER: - player->PlayerTalkClass->CloseGossip(); - player->SetBindPoint( guid ); - break; - case GOSSIP_OPTION_BANKER: - player->GetSession()->SendShowBank( guid ); - break; - case GOSSIP_OPTION_PETITIONER: - player->PlayerTalkClass->CloseGossip(); - player->GetSession()->SendPetitionShowList( guid ); - break; - case GOSSIP_OPTION_TABARDDESIGNER: - player->PlayerTalkClass->CloseGossip(); - player->GetSession()->SendTabardVendorActivate( guid ); - break; - case GOSSIP_OPTION_AUCTIONEER: - player->GetSession()->SendAuctionHello( guid, this ); - break; - case GOSSIP_OPTION_SPIRITGUIDE: - case GOSSIP_GUARD_SPELLTRAINER: - case GOSSIP_GUARD_SKILLTRAINER: - prepareGossipMenu( player,gossip->Id ); - sendPreparedGossip( player ); - break; - case GOSSIP_OPTION_BATTLEFIELD: - { - uint32 bgTypeId = objmgr.GetBattleMasterBG(GetEntry()); - player->GetSession()->SendBattlegGroundList( GetGUID(), bgTypeId ); - break; - } - default: - OnPoiSelect( player, gossip ); - break; - } - -} - -void Creature::OnPoiSelect(Player* player, GossipOption const *gossip) -{ - if(gossip->GossipId==GOSSIP_GUARD_SPELLTRAINER || gossip->GossipId==GOSSIP_GUARD_SKILLTRAINER) - { - //float x,y; - //bool findnpc=false; - Poi_Icon icon = ICON_POI_0; - //QueryResult *result; - //Field *fields; - uint32 mapid=GetMapId(); - Map const* map=MapManager::Instance().GetBaseMap( mapid ); - uint16 areaflag=map->GetAreaFlag(GetPositionX(),GetPositionY()); - uint32 zoneid=Map::GetZoneId(areaflag,mapid); - std::string areaname= gossip->Option; - /* - uint16 pflag; - - // use the action relate to creaturetemplate.trainer_type ? - result= WorldDatabase.PQuery("SELECT creature.position_x,creature.position_y FROM creature,creature_template WHERE creature.map = '%u' AND creature.id = creature_template.entry AND creature_template.trainer_type = '%u'", mapid, gossip->Action ); - if(!result) - return; - do - { - fields = result->Fetch(); - x=fields[0].GetFloat(); - y=fields[1].GetFloat(); - pflag=map->GetAreaFlag(GetPositionX(),GetPositionY()); - if(pflag==areaflag) - { - findnpc=true; - break; - } - }while(result->NextRow()); - - delete result; - - if(!findnpc) - { - player->PlayerTalkClass->SendTalking( "$NSorry", "Here no this person."); - return; - }*/ - - //need add more case. - switch(gossip->Action) - { - case GOSSIP_GUARD_BANK: - icon=ICON_POI_HOUSE; - break; - case GOSSIP_GUARD_RIDE: - icon=ICON_POI_RWHORSE; - break; - case GOSSIP_GUARD_GUILD: - icon=ICON_POI_BLUETOWER; - break; - default: - icon=ICON_POI_TOWER; - break; - } - uint32 textid=GetGossipTextId( gossip->Action, zoneid ); - player->PlayerTalkClass->SendTalking( textid ); - // how this could worked player->PlayerTalkClass->SendPointOfInterest( x, y, icon, 2, 15, areaname.c_str() ); - } -} - -uint32 Creature::GetGossipTextId(uint32 action, uint32 zoneid) -{ - QueryResult *result= WorldDatabase.PQuery("SELECT textid FROM npc_gossip_textid WHERE action = '%u' AND zoneid ='%u'", action, zoneid ); - - if(!result) - return 0; - - Field *fields = result->Fetch(); - uint32 id = fields[0].GetUInt32(); - - delete result; - - return id; -} - -uint32 Creature::GetNpcTextId() -{ - // already loaded and cached - if(m_NPCTextId) - return m_NPCTextId; - - QueryResult* result = WorldDatabase.PQuery("SELECT textid FROM npc_gossip WHERE npc_guid= '%u'", m_DBTableGuid); - if(result) - { - Field *fields = result->Fetch(); - m_NPCTextId = fields[0].GetUInt32(); - delete result; - } - else - m_NPCTextId = DEFAULT_GOSSIP_MESSAGE; - - return m_NPCTextId; -} - -GossipOption const* Creature::GetGossipOption( uint32 id ) const -{ - for( GossipOptionList::const_iterator i = m_goptions.begin( ); i != m_goptions.end( ); i++ ) - { - if(i->Action==id ) - return &*i; - } - return NULL; -} - -void Creature::LoadGossipOptions() -{ - if(m_gossipOptionLoaded) - return; - - uint32 npcflags=GetUInt32Value(UNIT_NPC_FLAGS); - - QueryResult *result = WorldDatabase.PQuery( "SELECT id,gossip_id,npcflag,icon,action,option_text FROM npc_option WHERE (npcflag & %u)<>0", npcflags ); - - if(!result) - return; - - GossipOption go; - do - { - Field *fields = result->Fetch(); - go.Id= fields[0].GetUInt32(); - go.GossipId = fields[1].GetUInt32(); - go.NpcFlag=fields[2].GetUInt32(); - go.Icon=fields[3].GetUInt32(); - go.Action=fields[4].GetUInt32(); - go.Option=fields[5].GetCppString(); - addGossipOption(go); - }while( result->NextRow() ); - delete result; - - m_gossipOptionLoaded = true; -} - -void Creature::AI_SendMoveToPacket(float x, float y, float z, uint32 time, uint32 MovementFlags, uint8 type) -{ - /* uint32 timeElap = getMSTime(); - if ((timeElap - m_startMove) < m_moveTime) - { - oX = (dX - oX) * ( (timeElap - m_startMove) / m_moveTime ); - oY = (dY - oY) * ( (timeElap - m_startMove) / m_moveTime ); - } - else - { - oX = dX; - oY = dY; - } - - dX = x; - dY = y; - m_orientation = atan2((oY - dY), (oX - dX)); - - m_startMove = getMSTime(); - m_moveTime = time;*/ - SendMonsterMove(x, y, z, type, MovementFlags, time); -} - -Player *Creature::GetLootRecipient() const -{ - if (!m_lootRecipient) return NULL; - else return ObjectAccessor::FindPlayer(m_lootRecipient); -} - -void Creature::SetLootRecipient(Unit *unit) -{ - // set the player whose group should receive the right - // to loot the creature after it dies - // should be set to NULL after the loot disappears - - if (!unit) - { - m_lootRecipient = 0; - RemoveFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_OTHER_TAGGER); - return; - } - - Player* player = unit->GetCharmerOrOwnerPlayerOrPlayerItself(); - if(!player) // normal creature, no player involved - return; - - m_lootRecipient = player->GetGUID(); - SetFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_OTHER_TAGGER); -} - -void Creature::SaveToDB() -{ - // this should only be used when the creature has already been loaded - // perferably after adding to map, because mapid may not be valid otherwise - CreatureData const *data = objmgr.GetCreatureData(m_DBTableGuid); - if(!data) - { - sLog.outError("Creature::SaveToDB failed, cannot get creature data!"); - return; - } - - SaveToDB(GetMapId(), data->spawnMask); -} - -void Creature::SaveToDB(uint32 mapid, uint8 spawnMask) -{ - // update in loaded data - CreatureData& data = objmgr.NewOrExistCreatureData(m_DBTableGuid); - - uint32 displayId = GetNativeDisplayId(); - - // check if it's a custom model and if not, use 0 for displayId - CreatureInfo const *cinfo = GetCreatureInfo(); - if(cinfo) - { - if(displayId != cinfo->DisplayID_A && displayId != cinfo->DisplayID_H) - { - CreatureModelInfo const *minfo = objmgr.GetCreatureModelInfo(cinfo->DisplayID_A); - if(!minfo || displayId != minfo->modelid_other_gender) - { - minfo = objmgr.GetCreatureModelInfo(cinfo->DisplayID_H); - if(minfo && displayId == minfo->modelid_other_gender) - displayId = 0; - } - else - displayId = 0; - } - else - displayId = 0; - } - - // data->guid = guid don't must be update at save - data.id = GetEntry(); - data.mapid = mapid; - data.displayid = displayId; - data.equipmentId = GetEquipmentId(); - data.posX = GetPositionX(); - data.posY = GetPositionY(); - data.posZ = GetPositionZ(); - data.orientation = GetOrientation(); - data.spawntimesecs = m_respawnDelay; - // prevent add data integrity problems - data.spawndist = GetDefaultMovementType()==IDLE_MOTION_TYPE ? 0 : m_respawnradius; - data.currentwaypoint = 0; - data.curhealth = GetHealth(); - data.curmana = GetPower(POWER_MANA); - data.is_dead = m_isDeadByDefault; - // prevent add data integrity problems - data.movementType = !m_respawnradius && GetDefaultMovementType()==RANDOM_MOTION_TYPE - ? IDLE_MOTION_TYPE : GetDefaultMovementType(); - data.spawnMask = spawnMask; - - // updated in DB - WorldDatabase.BeginTransaction(); - - WorldDatabase.PExecuteLog("DELETE FROM creature WHERE guid = '%u'", m_DBTableGuid); - - std::ostringstream ss; - ss << "INSERT INTO creature VALUES (" - << m_DBTableGuid << "," - << GetEntry() << "," - << mapid <<"," - << (uint32)spawnMask << "," - << displayId <<"," - << GetEquipmentId() <<"," - << GetPositionX() << "," - << GetPositionY() << "," - << GetPositionZ() << "," - << GetOrientation() << "," - << m_respawnDelay << "," //respawn time - << (float) m_respawnradius << "," //spawn distance (float) - << (uint32) (0) << "," //currentwaypoint - << GetHealth() << "," //curhealth - << GetPower(POWER_MANA) << "," //curmana - << (m_isDeadByDefault ? 1 : 0) << "," //is_dead - << GetDefaultMovementType() << ")"; //default movement generator type - - WorldDatabase.PExecuteLog( ss.str( ).c_str( ) ); - - WorldDatabase.CommitTransaction(); -} - -void Creature::SelectLevel(const CreatureInfo *cinfo) -{ - uint32 rank = isPet()? 0 : cinfo->rank; - - // level - uint32 minlevel = std::min(cinfo->maxlevel, cinfo->minlevel); - uint32 maxlevel = std::max(cinfo->maxlevel, cinfo->minlevel); - uint32 level = minlevel == maxlevel ? minlevel : urand(minlevel, maxlevel); - SetLevel(level); - - float rellevel = maxlevel == minlevel ? 0 : (float(level - minlevel))/(maxlevel - minlevel); - - // health - float healthmod = _GetHealthMod(rank); - - uint32 minhealth = std::min(cinfo->maxhealth, cinfo->minhealth); - uint32 maxhealth = std::max(cinfo->maxhealth, cinfo->minhealth); - uint32 health = uint32(healthmod * (minhealth + uint32(rellevel*(maxhealth - minhealth)))); - - SetCreateHealth(health); - SetMaxHealth(health); - SetHealth(health); - - // mana - uint32 minmana = std::min(cinfo->maxmana, cinfo->minmana); - uint32 maxmana = std::max(cinfo->maxmana, cinfo->minmana); - uint32 mana = minmana + uint32(rellevel*(maxmana - minmana)); - - SetCreateMana(mana); - SetMaxPower(POWER_MANA, mana); //MAX Mana - SetPower(POWER_MANA, mana); - - SetModifierValue(UNIT_MOD_HEALTH, BASE_VALUE, health); - SetModifierValue(UNIT_MOD_MANA, BASE_VALUE, mana); - - // damage - float damagemod = _GetDamageMod(rank); - - SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, cinfo->mindmg * damagemod); - SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, cinfo->maxdmg * damagemod); - - SetFloatValue(UNIT_FIELD_MINRANGEDDAMAGE,cinfo->minrangedmg * damagemod); - SetFloatValue(UNIT_FIELD_MAXRANGEDDAMAGE,cinfo->maxrangedmg * damagemod); - - SetModifierValue(UNIT_MOD_ATTACK_POWER, BASE_VALUE, cinfo->attackpower * damagemod); -} - -float Creature::_GetHealthMod(int32 Rank) -{ - switch (Rank) // define rates for each elite rank - { - case CREATURE_ELITE_NORMAL: - return sWorld.getRate(RATE_CREATURE_NORMAL_HP); - case CREATURE_ELITE_ELITE: - return sWorld.getRate(RATE_CREATURE_ELITE_ELITE_HP); - case CREATURE_ELITE_RAREELITE: - return sWorld.getRate(RATE_CREATURE_ELITE_RAREELITE_HP); - case CREATURE_ELITE_WORLDBOSS: - return sWorld.getRate(RATE_CREATURE_ELITE_WORLDBOSS_HP); - case CREATURE_ELITE_RARE: - return sWorld.getRate(RATE_CREATURE_ELITE_RARE_HP); - default: - return sWorld.getRate(RATE_CREATURE_ELITE_ELITE_HP); - } -} - -float Creature::_GetDamageMod(int32 Rank) -{ - switch (Rank) // define rates for each elite rank - { - case CREATURE_ELITE_NORMAL: - return sWorld.getRate(RATE_CREATURE_NORMAL_DAMAGE); - case CREATURE_ELITE_ELITE: - return sWorld.getRate(RATE_CREATURE_ELITE_ELITE_DAMAGE); - case CREATURE_ELITE_RAREELITE: - return sWorld.getRate(RATE_CREATURE_ELITE_RAREELITE_DAMAGE); - case CREATURE_ELITE_WORLDBOSS: - return sWorld.getRate(RATE_CREATURE_ELITE_WORLDBOSS_DAMAGE); - case CREATURE_ELITE_RARE: - return sWorld.getRate(RATE_CREATURE_ELITE_RARE_DAMAGE); - default: - return sWorld.getRate(RATE_CREATURE_ELITE_ELITE_DAMAGE); - } -} - -float Creature::GetSpellDamageMod(int32 Rank) -{ - switch (Rank) // define rates for each elite rank - { - case CREATURE_ELITE_NORMAL: - return sWorld.getRate(RATE_CREATURE_NORMAL_SPELLDAMAGE); - case CREATURE_ELITE_ELITE: - return sWorld.getRate(RATE_CREATURE_ELITE_ELITE_SPELLDAMAGE); - case CREATURE_ELITE_RAREELITE: - return sWorld.getRate(RATE_CREATURE_ELITE_RAREELITE_SPELLDAMAGE); - case CREATURE_ELITE_WORLDBOSS: - return sWorld.getRate(RATE_CREATURE_ELITE_WORLDBOSS_SPELLDAMAGE); - case CREATURE_ELITE_RARE: - return sWorld.getRate(RATE_CREATURE_ELITE_RARE_SPELLDAMAGE); - default: - return sWorld.getRate(RATE_CREATURE_ELITE_ELITE_SPELLDAMAGE); - } -} - -bool Creature::CreateFromProto(uint32 guidlow, uint32 Entry, uint32 team, const CreatureData *data) -{ - CreatureInfo const *cinfo = objmgr.GetCreatureTemplate(Entry); - if(!cinfo) - { - sLog.outErrorDb("Error: creature entry %u does not exist.", Entry); - return false; - } - m_originalEntry = Entry; - - Object::_Create(guidlow, Entry, HIGHGUID_UNIT); - - m_DBTableGuid = guidlow; - if(!UpdateEntry(Entry, team, data)) - return false; - - //Notify the map's instance data. - //Only works if you create the object in it, not if it is moves to that map. - //Normally non-players do not teleport to other maps. - Map *map = MapManager::Instance().FindMap(GetMapId(), GetInstanceId()); - if(map && map->IsDungeon() && ((InstanceMap*)map)->GetInstanceData()) - { - ((InstanceMap*)map)->GetInstanceData()->OnCreatureCreate(this, Entry); - } - - return true; -} - -bool Creature::LoadFromDB(uint32 guid, Map *map) -{ - CreatureData const* data = objmgr.GetCreatureData(guid); - - if(!data) - { - sLog.outErrorDb("Creature (GUID: %u) not found in table `creature`, can't load. ",guid); - return false; - } - - uint32 stored_guid = guid; - if (map->GetInstanceId() != 0) guid = objmgr.GenerateLowGuid(HIGHGUID_UNIT); - - uint16 team = 0; - if(!Create(guid,map,data->id,team,data)) - return false; - - Relocate(data->posX,data->posY,data->posZ,data->orientation); - - if(!IsPositionValid()) - { - sLog.outError("ERROR: Creature (guidlow %d, entry %d) not loaded. Suggested coordinates isn't valid (X: %f Y: %f)",GetGUIDLow(),GetEntry(),GetPositionX(),GetPositionY()); - return false; - } - - m_DBTableGuid = stored_guid; - LoadCreaturesAddon(); - - m_respawnradius = data->spawndist; - - m_respawnDelay = data->spawntimesecs; - m_isDeadByDefault = data->is_dead; - m_deathState = m_isDeadByDefault ? DEAD : ALIVE; - - m_respawnTime = objmgr.GetCreatureRespawnTime(m_DBTableGuid,GetInstanceId()); - if(m_respawnTime > time(NULL)) // not ready to respawn - m_deathState = DEAD; - else if(m_respawnTime) // respawn time set but expired - { - m_respawnTime = 0; - objmgr.SaveCreatureRespawnTime(m_DBTableGuid,GetInstanceId(),0); - } - - uint32 curhealth = data->curhealth; - if(curhealth) - { - curhealth = uint32(curhealth*_GetHealthMod(GetCreatureInfo()->rank)); - if(curhealth < 1) - curhealth = 1; - } - - SetHealth(m_deathState == ALIVE ? curhealth : 0); - SetPower(POWER_MANA,data->curmana); - - SetMeleeDamageSchool(SpellSchools(GetCreatureInfo()->dmgschool)); - - // checked at creature_template loading - m_defaultMovementType = MovementGeneratorType(data->movementType); - - AIM_Initialize(); - return true; -} - -void Creature::LoadEquipment(uint32 equip_entry, bool force) -{ - if(equip_entry == 0) - { - if (force) - { - for (uint8 i=0;i<3;i++) - { - SetUInt32Value( UNIT_VIRTUAL_ITEM_SLOT_DISPLAY + i, 0); - SetUInt32Value( UNIT_VIRTUAL_ITEM_INFO + (i * 2), 0); - SetUInt32Value( UNIT_VIRTUAL_ITEM_INFO + (i * 2) + 1, 0); - } - m_equipmentId = 0; - } - return; - } - - EquipmentInfo const *einfo = objmgr.GetEquipmentInfo(equip_entry); - if (!einfo) - return; - - m_equipmentId = equip_entry; - for (uint8 i=0;i<3;i++) - { - SetUInt32Value( UNIT_VIRTUAL_ITEM_SLOT_DISPLAY + i, einfo->equipmodel[i]); - SetUInt32Value( UNIT_VIRTUAL_ITEM_INFO + (i * 2), einfo->equipinfo[i]); - SetUInt32Value( UNIT_VIRTUAL_ITEM_INFO + (i * 2) + 1, einfo->equipslot[i]); - } -} - -void Creature::LoadGoods() -{ - // already loaded; - if(m_itemsLoaded) - return; - - m_vendor_items.clear(); - - QueryResult *result = WorldDatabase.PQuery("SELECT item, maxcount, incrtime, ExtendedCost FROM npc_vendor WHERE entry = '%u'", GetEntry()); - - if(!result) - return; - - do - { - Field *fields = result->Fetch(); - - if (GetItemCount() >= MAX_VENDOR_ITEMS) - { - sLog.outErrorDb( "Vendor %u has too many items (%u >= %i). Check the DB!", GetEntry(), GetItemCount(), MAX_VENDOR_ITEMS ); - break; - } - - uint32 item_id = fields[0].GetUInt32(); - if(!sItemStorage.LookupEntry(item_id)) - { - sLog.outErrorDb("Vendor %u have in item list non-existed item %u",GetEntry(),item_id); - continue; - } - - uint32 ExtendedCost = fields[3].GetUInt32(); - if(ExtendedCost && !sItemExtendedCostStore.LookupEntry(ExtendedCost)) - sLog.outErrorDb("Item (Entry: %u) has wrong ExtendedCost (%u) for vendor (%u)",item_id,ExtendedCost,GetEntry()); - - AddItem( item_id, fields[1].GetUInt32(), fields[2].GetUInt32(), ExtendedCost); - } - while( result->NextRow() ); - - delete result; - - m_itemsLoaded = true; -} - -bool Creature::hasQuest(uint32 quest_id) const -{ - QuestRelations const& qr = objmgr.mCreatureQuestRelations; - for(QuestRelations::const_iterator itr = qr.lower_bound(GetEntry()); itr != qr.upper_bound(GetEntry()); ++itr) - { - if(itr->second==quest_id) - return true; - } - return false; -} - -bool Creature::hasInvolvedQuest(uint32 quest_id) const -{ - QuestRelations const& qr = objmgr.mCreatureQuestInvolvedRelations; - for(QuestRelations::const_iterator itr = qr.lower_bound(GetEntry()); itr != qr.upper_bound(GetEntry()); ++itr) - { - if(itr->second==quest_id) - return true; - } - return false; -} - -void Creature::DeleteFromDB() -{ - objmgr.SaveCreatureRespawnTime(m_DBTableGuid,GetInstanceId(),0); - objmgr.DeleteCreatureData(m_DBTableGuid); - - WorldDatabase.BeginTransaction(); - WorldDatabase.PExecuteLog("DELETE FROM creature WHERE guid = '%u'", m_DBTableGuid); - WorldDatabase.PExecuteLog("DELETE FROM creature_addon WHERE guid = '%u'", m_DBTableGuid); - WorldDatabase.PExecuteLog("DELETE FROM creature_movement WHERE id = '%u'", m_DBTableGuid); - WorldDatabase.PExecuteLog("DELETE FROM game_event_creature WHERE guid = '%u'", m_DBTableGuid); - WorldDatabase.PExecuteLog("DELETE FROM game_event_model_equip WHERE guid = '%u'", m_DBTableGuid); - WorldDatabase.CommitTransaction(); -} - -float Creature::GetAttackDistance(Unit const* pl) const -{ - float aggroRate = sWorld.getRate(RATE_CREATURE_AGGRO); - if(aggroRate==0) - return 0.0f; - - int32 playerlevel = pl->getLevelForTarget(this); - int32 creaturelevel = getLevelForTarget(pl); - - int32 leveldif = playerlevel - creaturelevel; - - // "The maximum Aggro Radius has a cap of 25 levels under. Example: A level 30 char has the same Aggro Radius of a level 5 char on a level 60 mob." - if ( leveldif < - 25) - leveldif = -25; - - // "The aggro radius of a mob having the same level as the player is roughly 20 yards" - float RetDistance = 20; - - // "Aggro Radius varries with level difference at a rate of roughly 1 yard/level" - // radius grow if playlevel < creaturelevel - RetDistance -= (float)leveldif; - - if(creaturelevel+5 <= sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL)) - { - // detect range auras - RetDistance += GetTotalAuraModifier(SPELL_AURA_MOD_DETECT_RANGE); - - // detected range auras - RetDistance += pl->GetTotalAuraModifier(SPELL_AURA_MOD_DETECTED_RANGE); - } - - // "Minimum Aggro Radius for a mob seems to be combat range (5 yards)" - if(RetDistance < 5) - RetDistance = 5; - - return (RetDistance*aggroRate); -} - -void Creature::setDeathState(DeathState s) -{ - if((s == JUST_DIED && !m_isDeadByDefault)||(s == JUST_ALIVED && m_isDeadByDefault)) - { - m_deathTimer = m_corpseDelay*1000; - - // always save boss respawn time at death to prevent crash cheating - if(sWorld.getConfig(CONFIG_SAVE_RESPAWN_TIME_IMMEDIATLY) || isWorldBoss()) - SaveRespawnTime(); - - if(!IsStopped()) - StopMoving(); - } - Unit::setDeathState(s); - - if(s == JUST_DIED) - { - SetUInt64Value (UNIT_FIELD_TARGET,0); // remove target selection in any cases (can be set at aura remove in Unit::setDeathState) - SetUInt32Value(UNIT_NPC_FLAGS, 0); - - if(!isPet() && GetCreatureInfo()->SkinLootId) - if ( LootTemplates_Skinning.HaveLootFor(GetCreatureInfo()->SkinLootId) ) - SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SKINNABLE); - - Unit::setDeathState(CORPSE); - } - if(s == JUST_ALIVED) - { - SetHealth(GetMaxHealth()); - SetLootRecipient(NULL); - Unit::setDeathState(ALIVE); - CreatureInfo const *cinfo = GetCreatureInfo(); - SetUInt32Value(UNIT_DYNAMIC_FLAGS, 0); - RemoveFlag (UNIT_FIELD_FLAGS, UNIT_FLAG_SKINNABLE); - AddUnitMovementFlag(MOVEMENTFLAG_WALK_MODE); - SetUInt32Value(UNIT_NPC_FLAGS, cinfo->npcflag); - clearUnitState(UNIT_STAT_ALL_STATE); - i_motionMaster.Clear(); - SetMeleeDamageSchool(SpellSchools(cinfo->dmgschool)); - LoadCreaturesAddon(true); - } -} - -void Creature::Respawn() -{ - RemoveCorpse(); - - // forced recreate creature object at clients - UnitVisibility currentVis = GetVisibility(); - SetVisibility(VISIBILITY_RESPAWN); - ObjectAccessor::UpdateObjectVisibility(this); - SetVisibility(currentVis); // restore visibility state - ObjectAccessor::UpdateObjectVisibility(this); - - if(getDeathState()==DEAD) - { - objmgr.SaveCreatureRespawnTime(m_DBTableGuid,GetInstanceId(),0); - m_respawnTime = time(NULL); // respawn at next tick - } -} - -bool Creature::IsImmunedToSpell(SpellEntry const* spellInfo, bool useCharges) -{ - if (!spellInfo) - return false; - - if (GetCreatureInfo()->MechanicImmuneMask & (1 << (spellInfo->Mechanic - 1))) - return true; - - return Unit::IsImmunedToSpell(spellInfo, useCharges); -} - -bool Creature::IsImmunedToSpellEffect(uint32 effect, uint32 mechanic) const -{ - if (GetCreatureInfo()->MechanicImmuneMask & (1 << (mechanic-1))) - return true; - - return Unit::IsImmunedToSpellEffect(effect, mechanic); -} - -SpellEntry const *Creature::reachWithSpellAttack(Unit *pVictim) -{ - if(!pVictim) - return NULL; - - for(uint32 i=0; i < CREATURE_MAX_SPELLS; i++) - { - if(!m_spells[i]) - continue; - SpellEntry const *spellInfo = sSpellStore.LookupEntry(m_spells[i] ); - if(!spellInfo) - { - sLog.outError("WORLD: unknown spell id %i\n", m_spells[i]); - continue; - } - - bool bcontinue = true; - for(uint32 j=0;j<3;j++) - { - if( (spellInfo->Effect[j] == SPELL_EFFECT_SCHOOL_DAMAGE ) || - (spellInfo->Effect[j] == SPELL_EFFECT_INSTAKILL) || - (spellInfo->Effect[j] == SPELL_EFFECT_ENVIRONMENTAL_DAMAGE) || - (spellInfo->Effect[j] == SPELL_EFFECT_HEALTH_LEECH ) - ) - { - bcontinue = false; - break; - } - } - if(bcontinue) continue; - - if(spellInfo->manaCost > GetPower(POWER_MANA)) - continue; - SpellRangeEntry const* srange = sSpellRangeStore.LookupEntry(spellInfo->rangeIndex); - float range = GetSpellMaxRange(srange); - float minrange = GetSpellMinRange(srange); - float dist = GetDistance(pVictim); - //if(!isInFront( pVictim, range ) && spellInfo->AttributesEx ) - // continue; - if( dist > range || dist < minrange ) - continue; - if(HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SILENCED)) - continue; - return spellInfo; - } - return NULL; -} - -SpellEntry const *Creature::reachWithSpellCure(Unit *pVictim) -{ - if(!pVictim) - return NULL; - - for(uint32 i=0; i < CREATURE_MAX_SPELLS; i++) - { - if(!m_spells[i]) - continue; - SpellEntry const *spellInfo = sSpellStore.LookupEntry(m_spells[i] ); - if(!spellInfo) - { - sLog.outError("WORLD: unknown spell id %i\n", m_spells[i]); - continue; - } - - bool bcontinue = true; - for(uint32 j=0;j<3;j++) - { - if( (spellInfo->Effect[j] == SPELL_EFFECT_HEAL ) ) - { - bcontinue = false; - break; - } - } - if(bcontinue) continue; - - if(spellInfo->manaCost > GetPower(POWER_MANA)) - continue; - SpellRangeEntry const* srange = sSpellRangeStore.LookupEntry(spellInfo->rangeIndex); - float range = GetSpellMaxRange(srange); - float minrange = GetSpellMinRange(srange); - float dist = GetDistance(pVictim); - //if(!isInFront( pVictim, range ) && spellInfo->AttributesEx ) - // continue; - if( dist > range || dist < minrange ) - continue; - if(HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SILENCED)) - continue; - return spellInfo; - } - return NULL; -} - -bool Creature::IsVisibleInGridForPlayer(Player* pl) const -{ - // gamemaster in GM mode see all, including ghosts - if(pl->isGameMaster()) - return true; - - // Live player (or with not release body see live creatures or death creatures with corpse disappearing time > 0 - if(pl->isAlive() || pl->GetDeathTimer() > 0) - { - if( GetEntry() == VISUAL_WAYPOINT && !pl->isGameMaster() ) - return false; - return isAlive() || m_deathTimer > 0 || m_isDeadByDefault && m_deathState==CORPSE; - } - - // Dead player see live creatures near own corpse - if(isAlive()) - { - Corpse *corpse = pl->GetCorpse(); - if(corpse) - { - // 20 - aggro distance for same level, 25 - max additional distance if player level less that creature level - if(corpse->IsWithinDistInMap(this,(20+25)*sWorld.getRate(RATE_CREATURE_AGGRO))) - return true; - } - } - - // Dead player see Spirit Healer or Spirit Guide - if(isSpiritService()) - return true; - - // and not see any other - return false; -} - -void Creature::CallAssistence() -{ - if( !m_AlreadyCallAssistence && getVictim() && !isPet() && !isCharmed()) - { - SetNoCallAssistence(true); - - float radius = sWorld.getConfig(CONFIG_CREATURE_FAMILY_ASSISTEMCE_RADIUS); - if(radius > 0) - { - std::list assistList; - - { - CellPair p(MaNGOS::ComputeCellPair(GetPositionX(), GetPositionY())); - Cell cell(p); - cell.data.Part.reserved = ALL_DISTRICT; - cell.SetNoCreate(); - - MaNGOS::AnyAssistCreatureInRangeCheck u_check(this, getVictim(), radius); - MaNGOS::CreatureListSearcher searcher(assistList, u_check); - - TypeContainerVisitor, GridTypeMapContainer > grid_creature_searcher(searcher); - - CellLock cell_lock(cell, p); - cell_lock->Visit(cell_lock, grid_creature_searcher, *MapManager::Instance().GetMap(GetMapId(), this)); - } - - for(std::list::iterator iter = assistList.begin(); iter != assistList.end(); ++iter) - { - (*iter)->SetNoCallAssistence(true); - if((*iter)->AI()) - (*iter)->AI()->AttackStart(getVictim()); - } - } - } -} - -void Creature::SaveRespawnTime() -{ - if(isPet()) - return; - - if(m_respawnTime > time(NULL)) // dead (no corpse) - objmgr.SaveCreatureRespawnTime(m_DBTableGuid,GetInstanceId(),m_respawnTime); - else if(m_deathTimer > 0) // dead (corpse) - objmgr.SaveCreatureRespawnTime(m_DBTableGuid,GetInstanceId(),time(NULL)+m_respawnDelay+m_deathTimer/1000); -} - -bool Creature::IsOutOfThreatArea(Unit* pVictim) const -{ - if(!pVictim) - return true; - - if(!pVictim->IsInMap(this)) - return true; - - if(!pVictim->isTargetableForAttack()) - return true; - - if(!pVictim->isInAccessablePlaceFor(this)) - return true; - - if(sMapStore.LookupEntry(GetMapId())->Instanceable()) - return false; - - float length = pVictim->GetDistance(CombatStartX,CombatStartY,CombatStartZ); - float AttackDist = GetAttackDistance(pVictim); - uint32 ThreatRadius = sWorld.getConfig(CONFIG_THREAT_RADIUS); - - //Use AttackDistance in distance check if threat radius is lower. This prevents creature bounce in and ouf of combat every update tick. - return ( length > (ThreatRadius > AttackDist ? ThreatRadius : AttackDist)); -} - -CreatureDataAddon const* Creature::GetCreatureAddon() const -{ - if(CreatureDataAddon const* addon = ObjectMgr::GetCreatureAddon(m_DBTableGuid)) - return addon; - - // dependent from heroic mode entry - return ObjectMgr::GetCreatureTemplateAddon(GetCreatureInfo()->Entry); -} - -//creature_addon table -bool Creature::LoadCreaturesAddon(bool reload) -{ - CreatureDataAddon const *cainfo = GetCreatureAddon(); - if(!cainfo) - return false; - - if (cainfo->mount != 0) - Mount(cainfo->mount); - - if (cainfo->bytes0 != 0) - SetUInt32Value(UNIT_FIELD_BYTES_0, cainfo->bytes0); - - if (cainfo->bytes1 != 0) - SetUInt32Value(UNIT_FIELD_BYTES_1, cainfo->bytes1); - - if (cainfo->bytes2 != 0) - SetUInt32Value(UNIT_FIELD_BYTES_2, cainfo->bytes2); - - if (cainfo->emote != 0) - SetUInt32Value(UNIT_NPC_EMOTESTATE, cainfo->emote); - - if (cainfo->move_flags != 0) - SetUnitMovementFlags(cainfo->move_flags); - - if(cainfo->auras) - { - for (CreatureDataAddonAura const* cAura = cainfo->auras; cAura->spell_id; ++cAura) - { - SpellEntry const *AdditionalSpellInfo = sSpellStore.LookupEntry(cAura->spell_id); - if (!AdditionalSpellInfo) - { - sLog.outErrorDb("Creature (GUIDLow: %u Entry: %u ) has wrong spell %u defined in `auras` field.",GetGUIDLow(),GetEntry(),cAura->spell_id); - continue; - } - - // skip already applied aura - if(HasAura(cAura->spell_id,cAura->effect_idx)) - { - if(!reload) - sLog.outErrorDb("Creature (GUIDLow: %u Entry: %u ) has duplicate aura (spell %u effect %u) in `auras` field.",GetGUIDLow(),GetEntry(),cAura->spell_id,cAura->effect_idx); - - continue; - } - - Aura* AdditionalAura = CreateAura(AdditionalSpellInfo, cAura->effect_idx, NULL, this, this, 0); - AddAura(AdditionalAura); - sLog.outDebug("Spell: %u with Aura %u added to creature (GUIDLow: %u Entry: %u )", cAura->spell_id, AdditionalSpellInfo->EffectApplyAuraName[0],GetGUIDLow(),GetEntry()); - } - } - return true; -} - -/// Send a message to LocalDefense channel for players oposition team in the zone -void Creature::SendZoneUnderAttackMessage(Player* attacker) -{ - uint32 enemy_team = attacker->GetTeam(); - - WorldPacket data(SMSG_ZONE_UNDER_ATTACK,4); - data << (uint32)GetZoneId(); - sWorld.SendGlobalMessage(&data,NULL,(enemy_team==ALLIANCE ? HORDE : ALLIANCE)); -} - -void Creature::_AddCreatureSpellCooldown(uint32 spell_id, time_t end_time) -{ - m_CreatureSpellCooldowns[spell_id] = end_time; -} - -void Creature::_AddCreatureCategoryCooldown(uint32 category, time_t apply_time) -{ - m_CreatureCategoryCooldowns[category] = apply_time; -} - -void Creature::AddCreatureSpellCooldown(uint32 spellid) -{ - SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellid); - if(!spellInfo) - return; - - uint32 cooldown = GetSpellRecoveryTime(spellInfo); - if(cooldown) - _AddCreatureSpellCooldown(spellid, time(NULL) + cooldown/1000); - - if(spellInfo->Category) - _AddCreatureCategoryCooldown(spellInfo->Category, time(NULL)); - - m_GlobalCooldown = spellInfo->StartRecoveryTime; -} - -bool Creature::HasCategoryCooldown(uint32 spell_id) const -{ - SpellEntry const *spellInfo = sSpellStore.LookupEntry(spell_id); - if(!spellInfo) - return false; - - // check global cooldown if spell affected by it - if (spellInfo->StartRecoveryCategory > 0 && m_GlobalCooldown > 0) - return true; - - CreatureSpellCooldowns::const_iterator itr = m_CreatureCategoryCooldowns.find(spellInfo->Category); - return(itr != m_CreatureCategoryCooldowns.end() && time_t(itr->second + (spellInfo->CategoryRecoveryTime / 1000)) > time(NULL)); -} - -bool Creature::HasSpellCooldown(uint32 spell_id) const -{ - CreatureSpellCooldowns::const_iterator itr = m_CreatureSpellCooldowns.find(spell_id); - return (itr != m_CreatureSpellCooldowns.end() && itr->second > time(NULL)) || HasCategoryCooldown(spell_id); -} - -bool Creature::IsInEvadeMode() const -{ - return !i_motionMaster.empty() && i_motionMaster.GetCurrentMovementGeneratorType() == HOME_MOTION_TYPE; -} - -bool Creature::HasSpell(uint32 spellID) const -{ - uint8 i; - for(i = 0; i < CREATURE_MAX_SPELLS; ++i) - if(spellID == m_spells[i]) - break; - return i < CREATURE_MAX_SPELLS; //broke before end of iteration of known spells -} - -time_t Creature::GetRespawnTimeEx() const -{ - time_t now = time(NULL); - if(m_respawnTime > now) // dead (no corpse) - return m_respawnTime; - else if(m_deathTimer > 0) // dead (corpse) - return now+m_respawnDelay+m_deathTimer/1000; - else - return now; -} - -void Creature::GetRespawnCoord( float &x, float &y, float &z, float* ori, float* dist ) const -{ - if(CreatureData const* data = objmgr.GetCreatureData(GetDBTableGUIDLow())) - { - x = data->posX; - y = data->posY; - z = data->posZ; - if(ori) - *ori = data->orientation; - if(dist) - *dist = data->spawndist; - } - else - { - x = GetPositionX(); - y = GetPositionY(); - z = GetPositionZ(); - if(ori) - *ori = GetOrientation(); - if(dist) - *dist = 0; - } -} - -void Creature::AllLootRemovedFromCorpse() -{ - if (!HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SKINNABLE)) - { - uint32 nDeathTimer; - - CreatureInfo const *cinfo = GetCreatureInfo(); - - // corpse was not skinnable -> apply corpse looted timer - if (!cinfo || !cinfo->SkinLootId) - nDeathTimer = (uint32)((m_corpseDelay * 1000) * sWorld.getRate(RATE_CORPSE_DECAY_LOOTED)); - // corpse skinnable, but without skinning flag, and then skinned, corpse will despawn next update - else - nDeathTimer = 0; - - // update death timer only if looted timer is shorter - if (m_deathTimer > nDeathTimer) - m_deathTimer = nDeathTimer; - } -} - -uint32 Creature::getLevelForTarget( Unit const* target ) const -{ - if(!isWorldBoss()) - return Unit::getLevelForTarget(target); - - uint32 level = target->getLevel()+sWorld.getConfig(CONFIG_WORLD_BOSS_LEVEL_DIFF); - if(level < 1) - return 1; - if(level > 255) - return 255; - return level; -} - -char const* Creature::GetScriptName() const -{ - return ObjectMgr::GetCreatureTemplate(GetEntry())->ScriptName; -} +/* + * Copyright (C) 2005-2008 MaNGOS + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "Common.h" +#include "Database/DatabaseEnv.h" +#include "WorldPacket.h" +#include "WorldSession.h" +#include "World.h" +#include "ObjectMgr.h" +#include "SpellMgr.h" +#include "Creature.h" +#include "QuestDef.h" +#include "GossipDef.h" +#include "Player.h" +#include "Opcodes.h" +#include "Log.h" +#include "LootMgr.h" +#include "MapManager.h" +#include "CreatureAI.h" +#include "CreatureAISelector.h" +#include "Formulas.h" +#include "SpellAuras.h" +#include "WaypointMovementGenerator.h" +#include "InstanceData.h" +#include "BattleGround.h" +#include "Util.h" +#include "GridNotifiers.h" +#include "GridNotifiersImpl.h" +#include "CellImpl.h" + +// apply implementation of the singletons +#include "Policies/SingletonImp.h" + +void TrainerSpellData::Clear() +{ + for (TrainerSpellList::iterator itr = spellList.begin(); itr != spellList.end(); ++itr) + delete (*itr); + spellList.empty(); +} + +TrainerSpell const* TrainerSpellData::Find(uint32 spell_id) const +{ + for(TrainerSpellList::const_iterator itr = spellList.begin(); itr != spellList.end(); ++itr) + if((*itr)->spell == spell_id) + return *itr; + + return NULL; +} + +Creature::Creature() : +Unit(), i_AI(NULL), +lootForPickPocketed(false), lootForBody(false), m_groupLootTimer(0), lootingGroupLeaderGUID(0), +m_itemsLoaded(false), m_lootMoney(0), m_lootRecipient(0), +m_deathTimer(0), m_respawnTime(0), m_respawnDelay(25), m_corpseDelay(60), m_respawnradius(0.0f), +m_gossipOptionLoaded(false),m_emoteState(0), m_isPet(false), m_isTotem(false), +m_regenTimer(2000), m_defaultMovementType(IDLE_MOTION_TYPE), m_equipmentId(0), +m_AlreadyCallAssistence(false), m_regenHealth(true), m_AI_locked(false), m_isDeadByDefault(false), +m_meleeDamageSchoolMask(SPELL_SCHOOL_MASK_NORMAL),m_creatureInfo(NULL) +{ + m_valuesCount = UNIT_END; + + for(int i =0; i<4; ++i) + m_spells[i] = 0; + + m_CreatureSpellCooldowns.clear(); + m_CreatureCategoryCooldowns.clear(); + m_GlobalCooldown = 0; + m_unit_movement_flags = MOVEMENTFLAG_WALK_MODE; +} + +Creature::~Creature() +{ + CleanupsBeforeDelete(); + + m_vendor_items.clear(); + + delete i_AI; + i_AI = NULL; +} + +void Creature::AddToWorld() +{ + ///- Register the creature for guid lookup + if(!IsInWorld()) ObjectAccessor::Instance().AddObject(this); + Unit::AddToWorld(); +} + +void Creature::RemoveFromWorld() +{ + ///- Remove the creature from the accessor + if(IsInWorld()) ObjectAccessor::Instance().RemoveObject(this); + Unit::RemoveFromWorld(); +} + +void Creature::RemoveCorpse() +{ + if( getDeathState()!=CORPSE && !m_isDeadByDefault || getDeathState()!=ALIVE && m_isDeadByDefault ) + return; + + m_deathTimer = 0; + setDeathState(DEAD); + ObjectAccessor::UpdateObjectVisibility(this); + loot.clear(); + m_respawnTime = time(NULL) + m_respawnDelay; + + float x,y,z,o; + GetRespawnCoord(x, y, z, &o); + MapManager::Instance().GetMap(GetMapId(), this)->CreatureRelocation(this,x,y,z,o); +} + +/** + * change the entry of creature until respawn + */ +bool Creature::InitEntry(uint32 Entry, uint32 team, const CreatureData *data ) +{ + CreatureInfo const *normalInfo = objmgr.GetCreatureTemplate(Entry); + if(!normalInfo) + { + sLog.outErrorDb("Creature::UpdateEntry creature entry %u does not exist.", Entry); + return false; + } + + // get heroic mode entry + uint32 actualEntry = Entry; + CreatureInfo const *cinfo = normalInfo; + if(normalInfo->HeroicEntry) + { + Map *map = MapManager::Instance().FindMap(GetMapId(), GetInstanceId()); + if(map && map->IsHeroic()) + { + cinfo = objmgr.GetCreatureTemplate(normalInfo->HeroicEntry); + if(!cinfo) + { + sLog.outErrorDb("Creature::UpdateEntry creature heroic entry %u does not exist.", actualEntry); + return false; + } + } + } + + SetUInt32Value(OBJECT_FIELD_ENTRY, Entry); // normal entry always + m_creatureInfo = cinfo; // map mode related always + + if (cinfo->DisplayID_A == 0 || cinfo->DisplayID_H == 0) // Cancel load if no model defined + { + sLog.outErrorDb("Creature (Entry: %u) has no model defined for Horde or Alliance in table `creature_template`, can't load. ",Entry); + return false; + } + + uint32 display_id = objmgr.ChooseDisplayId(team, GetCreatureInfo(), data); + CreatureModelInfo const *minfo = objmgr.GetCreatureModelRandomGender(display_id); + if (!minfo) + { + sLog.outErrorDb("Creature (Entry: %u) has model %u not found in table `creature_model_info`, can't load. ", Entry, display_id); + return false; + } + else + display_id = minfo->modelid; // it can be different (for another gender) + + SetDisplayId(display_id); + SetNativeDisplayId(display_id); + SetByteValue(UNIT_FIELD_BYTES_0, 2, minfo->gender); + + // Load creature equipment + if(!data || data->equipmentId == 0) + { // use default from the template + LoadEquipment(cinfo->equipmentId); + } + else if(data && data->equipmentId != -1) + { // override, -1 means no equipment + LoadEquipment(data->equipmentId); + } + + SetName(normalInfo->Name); // at normal entry always + + SetFloatValue(UNIT_FIELD_BOUNDINGRADIUS,minfo->bounding_radius); + SetFloatValue(UNIT_FIELD_COMBATREACH,minfo->combat_reach ); + + SetFloatValue(UNIT_MOD_CAST_SPEED, 1.0f); + + SetSpeed(MOVE_WALK, cinfo->speed ); + SetSpeed(MOVE_RUN, cinfo->speed ); + SetSpeed(MOVE_SWIM, cinfo->speed ); + + SetFloatValue(OBJECT_FIELD_SCALE_X, cinfo->scale); + + // checked at loading + m_defaultMovementType = MovementGeneratorType(cinfo->MovementType); + if(!m_respawnradius && m_defaultMovementType==RANDOM_MOTION_TYPE) + m_defaultMovementType = IDLE_MOTION_TYPE; + + return true; +} + +bool Creature::UpdateEntry(uint32 Entry, uint32 team, const CreatureData *data ) +{ + if(!InitEntry(Entry,team,data)) + return false; + + m_regenHealth = GetCreatureInfo()->RegenHealth; + + // creatures always have melee weapon ready if any + SetByteValue(UNIT_FIELD_BYTES_2, 0, SHEATH_STATE_MELEE ); + SetByteValue(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_AURAS ); + + SelectLevel(GetCreatureInfo()); + if (team == HORDE) + SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE, GetCreatureInfo()->faction_H); + else + SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE, GetCreatureInfo()->faction_A); + + SetUInt32Value(UNIT_NPC_FLAGS,GetCreatureInfo()->npcflag); + + SetAttackTime(BASE_ATTACK, GetCreatureInfo()->baseattacktime); + SetAttackTime(OFF_ATTACK, GetCreatureInfo()->baseattacktime); + SetAttackTime(RANGED_ATTACK,GetCreatureInfo()->rangeattacktime); + + SetUInt32Value(UNIT_FIELD_FLAGS,GetCreatureInfo()->Flags); + SetUInt32Value(UNIT_DYNAMIC_FLAGS,GetCreatureInfo()->dynamicflags); + + SetModifierValue(UNIT_MOD_ARMOR, BASE_VALUE, float(GetCreatureInfo()->armor)); + SetModifierValue(UNIT_MOD_RESISTANCE_HOLY, BASE_VALUE, float(GetCreatureInfo()->resistance1)); + SetModifierValue(UNIT_MOD_RESISTANCE_FIRE, BASE_VALUE, float(GetCreatureInfo()->resistance2)); + SetModifierValue(UNIT_MOD_RESISTANCE_NATURE, BASE_VALUE, float(GetCreatureInfo()->resistance3)); + SetModifierValue(UNIT_MOD_RESISTANCE_FROST, BASE_VALUE, float(GetCreatureInfo()->resistance4)); + SetModifierValue(UNIT_MOD_RESISTANCE_SHADOW, BASE_VALUE, float(GetCreatureInfo()->resistance5)); + SetModifierValue(UNIT_MOD_RESISTANCE_ARCANE, BASE_VALUE, float(GetCreatureInfo()->resistance6)); + + SetCanModifyStats(true); + UpdateAllStats(); + + FactionTemplateEntry const* factionTemplate = sFactionTemplateStore.LookupEntry(GetCreatureInfo()->faction_A); + if (factionTemplate) // check and error show at loading templates + { + FactionEntry const* factionEntry = sFactionStore.LookupEntry(factionTemplate->faction); + if (factionEntry) + if( !(GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_CIVILIAN) && + (factionEntry->team == ALLIANCE || factionEntry->team == HORDE) ) + SetPvP(true); + } + + m_spells[0] = GetCreatureInfo()->spell1; + m_spells[1] = GetCreatureInfo()->spell2; + m_spells[2] = GetCreatureInfo()->spell3; + m_spells[3] = GetCreatureInfo()->spell4; + + return true; +} + +void Creature::Update(uint32 diff) +{ + if(m_GlobalCooldown <= diff) + m_GlobalCooldown = 0; + else + m_GlobalCooldown -= diff; + + switch( m_deathState ) + { + case JUST_ALIVED: + // Dont must be called, see Creature::setDeathState JUST_ALIVED -> ALIVE promoting. + sLog.outError("Creature (GUIDLow: %u Entry: %u ) in wrong state: JUST_ALIVED (4)",GetGUIDLow(),GetEntry()); + break; + case JUST_DIED: + // Dont must be called, see Creature::setDeathState JUST_DIED -> CORPSE promoting. + sLog.outError("Creature (GUIDLow: %u Entry: %u ) in wrong state: JUST_DEAD (1)",GetGUIDLow(),GetEntry()); + break; + case DEAD: + { + if( m_respawnTime <= time(NULL) ) + { + DEBUG_LOG("Respawning..."); + m_respawnTime = 0; + lootForPickPocketed = false; + lootForBody = false; + + if(m_originalEntry != GetUInt32Value(OBJECT_FIELD_ENTRY)) + UpdateEntry(m_originalEntry); + + CreatureInfo const *cinfo = GetCreatureInfo(); + + SelectLevel(cinfo); + SetUInt32Value(UNIT_DYNAMIC_FLAGS, 0); + if (m_isDeadByDefault) + { + setDeathState(JUST_DIED); + SetHealth(0); + i_motionMaster.Clear(); + clearUnitState(UNIT_STAT_ALL_STATE); + LoadCreaturesAddon(true); + } + else + setDeathState( JUST_ALIVED ); + + //Call AI respawn virtual function + i_AI->JustRespawned(); + + MapManager::Instance().GetMap(GetMapId(), this)->Add(this); + } + break; + } + case CORPSE: + { + if (m_isDeadByDefault) + break; + + if( m_deathTimer <= diff ) + { + RemoveCorpse(); + DEBUG_LOG("Removing corpse... %u ", GetUInt32Value(OBJECT_FIELD_ENTRY)); + } + else + { + m_deathTimer -= diff; + if (m_groupLootTimer && lootingGroupLeaderGUID) + { + if(diff <= m_groupLootTimer) + { + m_groupLootTimer -= diff; + } + else + { + Group* group = objmgr.GetGroupByLeader(lootingGroupLeaderGUID); + if (group) + group->EndRoll(); + m_groupLootTimer = 0; + lootingGroupLeaderGUID = 0; + } + } + } + + break; + } + case ALIVE: + { + if (m_isDeadByDefault) + { + if( m_deathTimer <= diff ) + { + RemoveCorpse(); + DEBUG_LOG("Removing alive corpse... %u ", GetUInt32Value(OBJECT_FIELD_ENTRY)); + } + else + { + m_deathTimer -= diff; + } + } + + Unit::Update( diff ); + + // creature can be dead after Unit::Update call + // CORPSE/DEAD state will processed at next tick (in other case death timer will be updated unexpectedly) + if(!isAlive()) + break; + + if(!IsInEvadeMode()) + { + // do not allow the AI to be changed during update + m_AI_locked = true; + i_AI->UpdateAI(diff); + m_AI_locked = false; + } + + // creature can be dead after UpdateAI call + // CORPSE/DEAD state will processed at next tick (in other case death timer will be updated unexpectedly) + if(!isAlive()) + break; + if(m_regenTimer > 0) + { + if(diff >= m_regenTimer) + m_regenTimer = 0; + else + m_regenTimer -= diff; + } + if (m_regenTimer != 0) + break; + + if (!isInCombat() || IsPolymorphed()) + RegenerateHealth(); + + RegenerateMana(); + + m_regenTimer = 2000; + break; + } + default: + break; + } +} + +void Creature::RegenerateMana() +{ + uint32 curValue = GetPower(POWER_MANA); + uint32 maxValue = GetMaxPower(POWER_MANA); + + if (curValue >= maxValue) + return; + + uint32 addvalue = 0; + + // Combat and any controlled creature + if (isInCombat() || GetCharmerOrOwnerGUID()) + { + if(!IsUnderLastManaUseEffect()) + { + float ManaIncreaseRate = sWorld.getRate(RATE_POWER_MANA); + float Spirit = GetStat(STAT_SPIRIT); + + addvalue = uint32((Spirit/5.0f + 17.0f) * ManaIncreaseRate); + } + } + else + addvalue = maxValue/3; + + ModifyPower(POWER_MANA, addvalue); +} + +void Creature::RegenerateHealth() +{ + if (!isRegeneratingHealth()) + return; + + uint32 curValue = GetHealth(); + uint32 maxValue = GetMaxHealth(); + + if (curValue >= maxValue) + return; + + uint32 addvalue = 0; + + // Not only pet, but any controelled creature + if(GetCharmerOrOwnerGUID()) + { + float HealthIncreaseRate = sWorld.getRate(RATE_HEALTH); + float Spirit = GetStat(STAT_SPIRIT); + + if( GetPower(POWER_MANA) > 0 ) + addvalue = uint32(Spirit * 0.25 * HealthIncreaseRate); + else + addvalue = uint32(Spirit * 0.80 * HealthIncreaseRate); + } + else + addvalue = maxValue/3; + + ModifyHealth(addvalue); +} + +bool Creature::AIM_Initialize() +{ + // make sure nothing can change the AI during AI update + if(m_AI_locked) + { + sLog.outDebug("AIM_Initialize: failed to init, locked."); + return false; + } + + CreatureAI * oldAI = i_AI; + i_motionMaster.Initialize(); + i_AI = FactorySelector::selectAI(this); + if (oldAI) + delete oldAI; + return true; +} + +bool Creature::Create (uint32 guidlow, Map *map, uint32 Entry, uint32 team, const CreatureData *data) +{ + SetMapId(map->GetId()); + SetInstanceId(map->GetInstanceId()); + + //oX = x; oY = y; dX = x; dY = y; m_moveTime = 0; m_startMove = 0; + const bool bResult = CreateFromProto(guidlow, Entry, team, data); + + if (bResult) + { + switch (GetCreatureInfo()->rank) + { + case CREATURE_ELITE_RARE: + m_corpseDelay = sWorld.getConfig(CONFIG_CORPSE_DECAY_RARE); + break; + case CREATURE_ELITE_ELITE: + m_corpseDelay = sWorld.getConfig(CONFIG_CORPSE_DECAY_ELITE); + break; + case CREATURE_ELITE_RAREELITE: + m_corpseDelay = sWorld.getConfig(CONFIG_CORPSE_DECAY_RAREELITE); + break; + case CREATURE_ELITE_WORLDBOSS: + m_corpseDelay = sWorld.getConfig(CONFIG_CORPSE_DECAY_WORLDBOSS); + break; + default: + m_corpseDelay = sWorld.getConfig(CONFIG_CORPSE_DECAY_NORMAL); + break; + } + } + + return bResult; +} + +bool Creature::isCanTrainingOf(Player* pPlayer, bool msg) const +{ + if(!isTrainer()) + return false; + + TrainerSpellData const* trainer_spells = GetTrainerSpells(); + + + if(!trainer_spells || trainer_spells->spellList.empty()) + { + sLog.outErrorDb("Creature %u (Entry: %u) have UNIT_NPC_FLAG_TRAINER but have empty trainer spell list.", + GetGUIDLow(),GetEntry()); + return false; + } + + switch(GetCreatureInfo()->trainer_type) + { + case TRAINER_TYPE_CLASS: + if(pPlayer->getClass()!=GetCreatureInfo()->classNum) + { + if(msg) + { + pPlayer->PlayerTalkClass->ClearMenus(); + switch(GetCreatureInfo()->classNum) + { + case CLASS_DRUID: pPlayer->PlayerTalkClass->SendGossipMenu( 4913,GetGUID()); break; + case CLASS_HUNTER: pPlayer->PlayerTalkClass->SendGossipMenu(10090,GetGUID()); break; + case CLASS_MAGE: pPlayer->PlayerTalkClass->SendGossipMenu( 328,GetGUID()); break; + case CLASS_PALADIN:pPlayer->PlayerTalkClass->SendGossipMenu( 1635,GetGUID()); break; + case CLASS_PRIEST: pPlayer->PlayerTalkClass->SendGossipMenu( 4436,GetGUID()); break; + case CLASS_ROGUE: pPlayer->PlayerTalkClass->SendGossipMenu( 4797,GetGUID()); break; + case CLASS_SHAMAN: pPlayer->PlayerTalkClass->SendGossipMenu( 5003,GetGUID()); break; + case CLASS_WARLOCK:pPlayer->PlayerTalkClass->SendGossipMenu( 5836,GetGUID()); break; + case CLASS_WARRIOR:pPlayer->PlayerTalkClass->SendGossipMenu( 4985,GetGUID()); break; + } + } + return false; + } + break; + case TRAINER_TYPE_PETS: + if(pPlayer->getClass()!=CLASS_HUNTER) + { + pPlayer->PlayerTalkClass->ClearMenus(); + pPlayer->PlayerTalkClass->SendGossipMenu(3620,GetGUID()); + return false; + } + break; + case TRAINER_TYPE_MOUNTS: + if(GetCreatureInfo()->race && pPlayer->getRace() != GetCreatureInfo()->race) + { + if(msg) + { + pPlayer->PlayerTalkClass->ClearMenus(); + switch(GetCreatureInfo()->classNum) + { + case RACE_DWARF: pPlayer->PlayerTalkClass->SendGossipMenu(5865,GetGUID()); break; + case RACE_GNOME: pPlayer->PlayerTalkClass->SendGossipMenu(4881,GetGUID()); break; + case RACE_HUMAN: pPlayer->PlayerTalkClass->SendGossipMenu(5861,GetGUID()); break; + case RACE_NIGHTELF: pPlayer->PlayerTalkClass->SendGossipMenu(5862,GetGUID()); break; + case RACE_ORC: pPlayer->PlayerTalkClass->SendGossipMenu(5863,GetGUID()); break; + case RACE_TAUREN: pPlayer->PlayerTalkClass->SendGossipMenu(5864,GetGUID()); break; + case RACE_TROLL: pPlayer->PlayerTalkClass->SendGossipMenu(5816,GetGUID()); break; + case RACE_UNDEAD_PLAYER:pPlayer->PlayerTalkClass->SendGossipMenu( 624,GetGUID()); break; + case RACE_BLOODELF: pPlayer->PlayerTalkClass->SendGossipMenu(5862,GetGUID()); break; + case RACE_DRAENEI: pPlayer->PlayerTalkClass->SendGossipMenu(5864,GetGUID()); break; + } + } + return false; + } + break; + case TRAINER_TYPE_TRADESKILLS: + if(GetCreatureInfo()->trainer_spell && !pPlayer->HasSpell(GetCreatureInfo()->trainer_spell)) + { + if(msg) + { + pPlayer->PlayerTalkClass->ClearMenus(); + pPlayer->PlayerTalkClass->SendGossipMenu(11031,GetGUID()); + } + return false; + } + break; + default: + return false; // checked and error output at creature_template loading + } + return true; +} + +bool Creature::isCanIneractWithBattleMaster(Player* pPlayer, bool msg) const +{ + if(!isBattleMaster()) + return false; + + uint32 bgTypeId = objmgr.GetBattleMasterBG(GetEntry()); + if(!msg) + return pPlayer->GetBGAccessByLevel(bgTypeId); + + if(!pPlayer->GetBGAccessByLevel(bgTypeId)) + { + pPlayer->PlayerTalkClass->ClearMenus(); + switch(bgTypeId) + { + case BATTLEGROUND_AV: pPlayer->PlayerTalkClass->SendGossipMenu(7616,GetGUID()); break; + case BATTLEGROUND_WS: pPlayer->PlayerTalkClass->SendGossipMenu(7599,GetGUID()); break; + case BATTLEGROUND_AB: pPlayer->PlayerTalkClass->SendGossipMenu(7642,GetGUID()); break; + case BATTLEGROUND_EY: + case BATTLEGROUND_NA: + case BATTLEGROUND_BE: + case BATTLEGROUND_AA: + case BATTLEGROUND_RL: pPlayer->PlayerTalkClass->SendGossipMenu(10024,GetGUID()); break; + break; + } + return false; + } + return true; +} + +bool Creature::isCanTrainingAndResetTalentsOf(Player* pPlayer) const +{ + return pPlayer->getLevel() >= 10 + && GetCreatureInfo()->trainer_type == TRAINER_TYPE_CLASS + && pPlayer->getClass() == GetCreatureInfo()->classNum; +} + +void Creature::prepareGossipMenu( Player *pPlayer,uint32 gossipid ) +{ + PlayerMenu* pm=pPlayer->PlayerTalkClass; + pm->ClearMenus(); + + // lazy loading single time at use + LoadGossipOptions(); + + GossipOption* gso; + GossipOption* ingso; + + for( GossipOptionList::iterator i = m_goptions.begin( ); i != m_goptions.end( ); i++ ) + { + gso=&*i; + if(gso->GossipId == gossipid) + { + bool cantalking=true; + if(gso->Id==1) + { + uint32 textid=GetNpcTextId(); + GossipText * gossiptext=objmgr.GetGossipText(textid); + if(!gossiptext) + cantalking=false; + } + else + { + switch (gso->Action) + { + case GOSSIP_OPTION_QUESTGIVER: + pPlayer->PrepareQuestMenu(GetGUID()); + //if (pm->GetQuestMenu()->MenuItemCount() == 0) + cantalking=false; + //pm->GetQuestMenu()->ClearMenu(); + break; + case GOSSIP_OPTION_ARMORER: + cantalking=false; // added in special mode + break; + case GOSSIP_OPTION_SPIRITHEALER: + if( !pPlayer->isDead() ) + cantalking=false; + break; + case GOSSIP_OPTION_VENDOR: + // load vendor items if not yet + LoadGoods(); + + if(!GetItemCount()) + { + sLog.outErrorDb("Creature %u (Entry: %u) have UNIT_NPC_FLAG_VENDOR but have empty trading item list.", + GetGUIDLow(),GetEntry()); + cantalking=false; + } + break; + case GOSSIP_OPTION_TRAINER: + if(!isCanTrainingOf(pPlayer,false)) + cantalking=false; + break; + case GOSSIP_OPTION_UNLEARNTALENTS: + if(!isCanTrainingAndResetTalentsOf(pPlayer)) + cantalking=false; + break; + case GOSSIP_OPTION_UNLEARNPETSKILLS: + if(!pPlayer->GetPet() || pPlayer->GetPet()->getPetType() != HUNTER_PET || pPlayer->GetPet()->m_spells.size() <= 1 || GetCreatureInfo()->trainer_type != TRAINER_TYPE_PETS || GetCreatureInfo()->classNum != CLASS_HUNTER) + cantalking=false; + break; + case GOSSIP_OPTION_TAXIVENDOR: + if ( pPlayer->GetSession()->SendLearnNewTaxiNode(this) ) + return; + break; + case GOSSIP_OPTION_BATTLEFIELD: + if(!isCanIneractWithBattleMaster(pPlayer,false)) + cantalking=false; + break; + case GOSSIP_OPTION_SPIRITGUIDE: + case GOSSIP_OPTION_INNKEEPER: + case GOSSIP_OPTION_BANKER: + case GOSSIP_OPTION_PETITIONER: + case GOSSIP_OPTION_STABLEPET: + case GOSSIP_OPTION_TABARDDESIGNER: + case GOSSIP_OPTION_AUCTIONEER: + break; // no checks + default: + sLog.outErrorDb("Creature %u (entry: %u) have unknown gossip option %u",GetGUIDLow(),GetEntry(),gso->Action); + break; + } + } + + if(!gso->Option.empty() && cantalking ) + { //note for future dev: should have database fields for BoxMessage & BoxMoney + pm->GetGossipMenu().AddMenuItem((uint8)gso->Icon,gso->Option, gossipid,gso->Action,"",0,false); + ingso=gso; + } + } + } + + ///some gossips aren't handled in normal way ... so we need to do it this way .. TODO: handle it in normal way ;-) + if(pm->Empty()) + { + if(HasFlag(UNIT_NPC_FLAGS,UNIT_NPC_FLAG_TRAINER)) + { + isCanTrainingOf(pPlayer,true); // output error message if need + } + if(HasFlag(UNIT_NPC_FLAGS,UNIT_NPC_FLAG_BATTLEMASTER)) + { + isCanIneractWithBattleMaster(pPlayer,true); // output error message if need + } + } +} + +void Creature::sendPreparedGossip(Player* player) +{ + if(!player) + return; + + GossipMenu& gossipmenu = player->PlayerTalkClass->GetGossipMenu(); + + // in case empty gossip menu open quest menu if any + if (gossipmenu.Empty() && GetNpcTextId() == 0) + { + player->SendPreparedQuest(GetGUID()); + return; + } + + // in case non empty gossip menu (that not included quests list size) show it + // (quest entries from quest menu wiill be included in list) + player->PlayerTalkClass->SendGossipMenu(GetNpcTextId(), GetGUID()); +} + +void Creature::OnGossipSelect(Player* player, uint32 option) +{ + GossipMenu& gossipmenu = player->PlayerTalkClass->GetGossipMenu(); + + if(option >= gossipmenu.MenuItemCount()) + return; + + uint32 action=gossipmenu.GetItem(option).m_gAction; + uint32 zoneid=GetZoneId(); + uint64 guid=GetGUID(); + GossipOption const *gossip=GetGossipOption( action ); + uint32 textid; + if(!gossip) + { + zoneid=0; + gossip=GetGossipOption( action ); + if(!gossip) + return; + } + textid=GetGossipTextId( action, zoneid); + if(textid==0) + textid=GetNpcTextId(); + + switch (gossip->Action) + { + case GOSSIP_OPTION_GOSSIP: + player->PlayerTalkClass->CloseGossip(); + player->PlayerTalkClass->SendTalking( textid ); + break; + case GOSSIP_OPTION_SPIRITHEALER: + if( player->isDead() ) + CastSpell(this,17251,true,NULL,NULL,player->GetGUID()); + break; + case GOSSIP_OPTION_QUESTGIVER: + player->PrepareQuestMenu( guid ); + player->SendPreparedQuest( guid ); + break; + case GOSSIP_OPTION_VENDOR: + case GOSSIP_OPTION_ARMORER: + player->GetSession()->SendListInventory(guid); + break; + case GOSSIP_OPTION_STABLEPET: + player->GetSession()->SendStablePet(guid); + break; + case GOSSIP_OPTION_TRAINER: + player->GetSession()->SendTrainerList(guid); + break; + case GOSSIP_OPTION_UNLEARNTALENTS: + player->PlayerTalkClass->CloseGossip(); + player->SendTalentWipeConfirm(guid); + break; + case GOSSIP_OPTION_UNLEARNPETSKILLS: + player->PlayerTalkClass->CloseGossip(); + player->SendPetSkillWipeConfirm(); + break; + case GOSSIP_OPTION_TAXIVENDOR: + player->GetSession()->SendTaxiMenu(this); + break; + case GOSSIP_OPTION_INNKEEPER: + player->PlayerTalkClass->CloseGossip(); + player->SetBindPoint( guid ); + break; + case GOSSIP_OPTION_BANKER: + player->GetSession()->SendShowBank( guid ); + break; + case GOSSIP_OPTION_PETITIONER: + player->PlayerTalkClass->CloseGossip(); + player->GetSession()->SendPetitionShowList( guid ); + break; + case GOSSIP_OPTION_TABARDDESIGNER: + player->PlayerTalkClass->CloseGossip(); + player->GetSession()->SendTabardVendorActivate( guid ); + break; + case GOSSIP_OPTION_AUCTIONEER: + player->GetSession()->SendAuctionHello( guid, this ); + break; + case GOSSIP_OPTION_SPIRITGUIDE: + case GOSSIP_GUARD_SPELLTRAINER: + case GOSSIP_GUARD_SKILLTRAINER: + prepareGossipMenu( player,gossip->Id ); + sendPreparedGossip( player ); + break; + case GOSSIP_OPTION_BATTLEFIELD: + { + uint32 bgTypeId = objmgr.GetBattleMasterBG(GetEntry()); + player->GetSession()->SendBattlegGroundList( GetGUID(), bgTypeId ); + break; + } + default: + OnPoiSelect( player, gossip ); + break; + } + +} + +void Creature::OnPoiSelect(Player* player, GossipOption const *gossip) +{ + if(gossip->GossipId==GOSSIP_GUARD_SPELLTRAINER || gossip->GossipId==GOSSIP_GUARD_SKILLTRAINER) + { + //float x,y; + //bool findnpc=false; + Poi_Icon icon = ICON_POI_0; + //QueryResult *result; + //Field *fields; + uint32 mapid=GetMapId(); + Map const* map=MapManager::Instance().GetBaseMap( mapid ); + uint16 areaflag=map->GetAreaFlag(GetPositionX(),GetPositionY()); + uint32 zoneid=Map::GetZoneId(areaflag,mapid); + std::string areaname= gossip->Option; + /* + uint16 pflag; + + // use the action relate to creaturetemplate.trainer_type ? + result= WorldDatabase.PQuery("SELECT creature.position_x,creature.position_y FROM creature,creature_template WHERE creature.map = '%u' AND creature.id = creature_template.entry AND creature_template.trainer_type = '%u'", mapid, gossip->Action ); + if(!result) + return; + do + { + fields = result->Fetch(); + x=fields[0].GetFloat(); + y=fields[1].GetFloat(); + pflag=map->GetAreaFlag(GetPositionX(),GetPositionY()); + if(pflag==areaflag) + { + findnpc=true; + break; + } + }while(result->NextRow()); + + delete result; + + if(!findnpc) + { + player->PlayerTalkClass->SendTalking( "$NSorry", "Here no this person."); + return; + }*/ + + //need add more case. + switch(gossip->Action) + { + case GOSSIP_GUARD_BANK: + icon=ICON_POI_HOUSE; + break; + case GOSSIP_GUARD_RIDE: + icon=ICON_POI_RWHORSE; + break; + case GOSSIP_GUARD_GUILD: + icon=ICON_POI_BLUETOWER; + break; + default: + icon=ICON_POI_TOWER; + break; + } + uint32 textid=GetGossipTextId( gossip->Action, zoneid ); + player->PlayerTalkClass->SendTalking( textid ); + // how this could worked player->PlayerTalkClass->SendPointOfInterest( x, y, icon, 2, 15, areaname.c_str() ); + } +} + +uint32 Creature::GetGossipTextId(uint32 action, uint32 zoneid) +{ + QueryResult *result= WorldDatabase.PQuery("SELECT textid FROM npc_gossip_textid WHERE action = '%u' AND zoneid ='%u'", action, zoneid ); + + if(!result) + return 0; + + Field *fields = result->Fetch(); + uint32 id = fields[0].GetUInt32(); + + delete result; + + return id; +} + +uint32 Creature::GetNpcTextId() +{ + if(uint32 pos = objmgr.GetNpcGossip(m_DBTableGuid)) + return pos; + + return DEFAULT_GOSSIP_MESSAGE; +} + +GossipOption const* Creature::GetGossipOption( uint32 id ) const +{ + for( GossipOptionList::const_iterator i = m_goptions.begin( ); i != m_goptions.end( ); i++ ) + { + if(i->Action==id ) + return &*i; + } + return NULL; +} + +void Creature::LoadGossipOptions() +{ + if(m_gossipOptionLoaded) + return; + + uint32 npcflags=GetUInt32Value(UNIT_NPC_FLAGS); + + QueryResult *result = WorldDatabase.PQuery( "SELECT id,gossip_id,npcflag,icon,action,option_text FROM npc_option WHERE (npcflag & %u)<>0", npcflags ); + + if(!result) + return; + + GossipOption go; + do + { + Field *fields = result->Fetch(); + go.Id= fields[0].GetUInt32(); + go.GossipId = fields[1].GetUInt32(); + go.NpcFlag=fields[2].GetUInt32(); + go.Icon=fields[3].GetUInt32(); + go.Action=fields[4].GetUInt32(); + go.Option=fields[5].GetCppString(); + addGossipOption(go); + }while( result->NextRow() ); + delete result; + + m_gossipOptionLoaded = true; +} + +void Creature::AI_SendMoveToPacket(float x, float y, float z, uint32 time, uint32 MovementFlags, uint8 type) +{ + /* uint32 timeElap = getMSTime(); + if ((timeElap - m_startMove) < m_moveTime) + { + oX = (dX - oX) * ( (timeElap - m_startMove) / m_moveTime ); + oY = (dY - oY) * ( (timeElap - m_startMove) / m_moveTime ); + } + else + { + oX = dX; + oY = dY; + } + + dX = x; + dY = y; + m_orientation = atan2((oY - dY), (oX - dX)); + + m_startMove = getMSTime(); + m_moveTime = time;*/ + SendMonsterMove(x, y, z, type, MovementFlags, time); +} + +Player *Creature::GetLootRecipient() const +{ + if (!m_lootRecipient) return NULL; + else return ObjectAccessor::FindPlayer(m_lootRecipient); +} + +void Creature::SetLootRecipient(Unit *unit) +{ + // set the player whose group should receive the right + // to loot the creature after it dies + // should be set to NULL after the loot disappears + + if (!unit) + { + m_lootRecipient = 0; + RemoveFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_OTHER_TAGGER); + return; + } + + Player* player = unit->GetCharmerOrOwnerPlayerOrPlayerItself(); + if(!player) // normal creature, no player involved + return; + + m_lootRecipient = player->GetGUID(); + SetFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_OTHER_TAGGER); +} + +void Creature::SaveToDB() +{ + // this should only be used when the creature has already been loaded + // perferably after adding to map, because mapid may not be valid otherwise + CreatureData const *data = objmgr.GetCreatureData(m_DBTableGuid); + if(!data) + { + sLog.outError("Creature::SaveToDB failed, cannot get creature data!"); + return; + } + + SaveToDB(GetMapId(), data->spawnMask); +} + +void Creature::SaveToDB(uint32 mapid, uint8 spawnMask) +{ + // update in loaded data + CreatureData& data = objmgr.NewOrExistCreatureData(m_DBTableGuid); + + uint32 displayId = GetNativeDisplayId(); + + // check if it's a custom model and if not, use 0 for displayId + CreatureInfo const *cinfo = GetCreatureInfo(); + if(cinfo) + { + if(displayId != cinfo->DisplayID_A && displayId != cinfo->DisplayID_H) + { + CreatureModelInfo const *minfo = objmgr.GetCreatureModelInfo(cinfo->DisplayID_A); + if(!minfo || displayId != minfo->modelid_other_gender) + { + minfo = objmgr.GetCreatureModelInfo(cinfo->DisplayID_H); + if(minfo && displayId == minfo->modelid_other_gender) + displayId = 0; + } + else + displayId = 0; + } + else + displayId = 0; + } + + // data->guid = guid don't must be update at save + data.id = GetEntry(); + data.mapid = mapid; + data.displayid = displayId; + data.equipmentId = GetEquipmentId(); + data.posX = GetPositionX(); + data.posY = GetPositionY(); + data.posZ = GetPositionZ(); + data.orientation = GetOrientation(); + data.spawntimesecs = m_respawnDelay; + // prevent add data integrity problems + data.spawndist = GetDefaultMovementType()==IDLE_MOTION_TYPE ? 0 : m_respawnradius; + data.currentwaypoint = 0; + data.curhealth = GetHealth(); + data.curmana = GetPower(POWER_MANA); + data.is_dead = m_isDeadByDefault; + // prevent add data integrity problems + data.movementType = !m_respawnradius && GetDefaultMovementType()==RANDOM_MOTION_TYPE + ? IDLE_MOTION_TYPE : GetDefaultMovementType(); + data.spawnMask = spawnMask; + + // updated in DB + WorldDatabase.BeginTransaction(); + + WorldDatabase.PExecuteLog("DELETE FROM creature WHERE guid = '%u'", m_DBTableGuid); + + std::ostringstream ss; + ss << "INSERT INTO creature VALUES (" + << m_DBTableGuid << "," + << GetEntry() << "," + << mapid <<"," + << (uint32)spawnMask << "," + << displayId <<"," + << GetEquipmentId() <<"," + << GetPositionX() << "," + << GetPositionY() << "," + << GetPositionZ() << "," + << GetOrientation() << "," + << m_respawnDelay << "," //respawn time + << (float) m_respawnradius << "," //spawn distance (float) + << (uint32) (0) << "," //currentwaypoint + << GetHealth() << "," //curhealth + << GetPower(POWER_MANA) << "," //curmana + << (m_isDeadByDefault ? 1 : 0) << "," //is_dead + << GetDefaultMovementType() << ")"; //default movement generator type + + WorldDatabase.PExecuteLog( ss.str( ).c_str( ) ); + + WorldDatabase.CommitTransaction(); +} + +void Creature::SelectLevel(const CreatureInfo *cinfo) +{ + uint32 rank = isPet()? 0 : cinfo->rank; + + // level + uint32 minlevel = std::min(cinfo->maxlevel, cinfo->minlevel); + uint32 maxlevel = std::max(cinfo->maxlevel, cinfo->minlevel); + uint32 level = minlevel == maxlevel ? minlevel : urand(minlevel, maxlevel); + SetLevel(level); + + float rellevel = maxlevel == minlevel ? 0 : (float(level - minlevel))/(maxlevel - minlevel); + + // health + float healthmod = _GetHealthMod(rank); + + uint32 minhealth = std::min(cinfo->maxhealth, cinfo->minhealth); + uint32 maxhealth = std::max(cinfo->maxhealth, cinfo->minhealth); + uint32 health = uint32(healthmod * (minhealth + uint32(rellevel*(maxhealth - minhealth)))); + + SetCreateHealth(health); + SetMaxHealth(health); + SetHealth(health); + + // mana + uint32 minmana = std::min(cinfo->maxmana, cinfo->minmana); + uint32 maxmana = std::max(cinfo->maxmana, cinfo->minmana); + uint32 mana = minmana + uint32(rellevel*(maxmana - minmana)); + + SetCreateMana(mana); + SetMaxPower(POWER_MANA, mana); //MAX Mana + SetPower(POWER_MANA, mana); + + SetModifierValue(UNIT_MOD_HEALTH, BASE_VALUE, health); + SetModifierValue(UNIT_MOD_MANA, BASE_VALUE, mana); + + // damage + float damagemod = _GetDamageMod(rank); + + SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, cinfo->mindmg * damagemod); + SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, cinfo->maxdmg * damagemod); + + SetFloatValue(UNIT_FIELD_MINRANGEDDAMAGE,cinfo->minrangedmg * damagemod); + SetFloatValue(UNIT_FIELD_MAXRANGEDDAMAGE,cinfo->maxrangedmg * damagemod); + + SetModifierValue(UNIT_MOD_ATTACK_POWER, BASE_VALUE, cinfo->attackpower * damagemod); +} + +float Creature::_GetHealthMod(int32 Rank) +{ + switch (Rank) // define rates for each elite rank + { + case CREATURE_ELITE_NORMAL: + return sWorld.getRate(RATE_CREATURE_NORMAL_HP); + case CREATURE_ELITE_ELITE: + return sWorld.getRate(RATE_CREATURE_ELITE_ELITE_HP); + case CREATURE_ELITE_RAREELITE: + return sWorld.getRate(RATE_CREATURE_ELITE_RAREELITE_HP); + case CREATURE_ELITE_WORLDBOSS: + return sWorld.getRate(RATE_CREATURE_ELITE_WORLDBOSS_HP); + case CREATURE_ELITE_RARE: + return sWorld.getRate(RATE_CREATURE_ELITE_RARE_HP); + default: + return sWorld.getRate(RATE_CREATURE_ELITE_ELITE_HP); + } +} + +float Creature::_GetDamageMod(int32 Rank) +{ + switch (Rank) // define rates for each elite rank + { + case CREATURE_ELITE_NORMAL: + return sWorld.getRate(RATE_CREATURE_NORMAL_DAMAGE); + case CREATURE_ELITE_ELITE: + return sWorld.getRate(RATE_CREATURE_ELITE_ELITE_DAMAGE); + case CREATURE_ELITE_RAREELITE: + return sWorld.getRate(RATE_CREATURE_ELITE_RAREELITE_DAMAGE); + case CREATURE_ELITE_WORLDBOSS: + return sWorld.getRate(RATE_CREATURE_ELITE_WORLDBOSS_DAMAGE); + case CREATURE_ELITE_RARE: + return sWorld.getRate(RATE_CREATURE_ELITE_RARE_DAMAGE); + default: + return sWorld.getRate(RATE_CREATURE_ELITE_ELITE_DAMAGE); + } +} + +float Creature::GetSpellDamageMod(int32 Rank) +{ + switch (Rank) // define rates for each elite rank + { + case CREATURE_ELITE_NORMAL: + return sWorld.getRate(RATE_CREATURE_NORMAL_SPELLDAMAGE); + case CREATURE_ELITE_ELITE: + return sWorld.getRate(RATE_CREATURE_ELITE_ELITE_SPELLDAMAGE); + case CREATURE_ELITE_RAREELITE: + return sWorld.getRate(RATE_CREATURE_ELITE_RAREELITE_SPELLDAMAGE); + case CREATURE_ELITE_WORLDBOSS: + return sWorld.getRate(RATE_CREATURE_ELITE_WORLDBOSS_SPELLDAMAGE); + case CREATURE_ELITE_RARE: + return sWorld.getRate(RATE_CREATURE_ELITE_RARE_SPELLDAMAGE); + default: + return sWorld.getRate(RATE_CREATURE_ELITE_ELITE_SPELLDAMAGE); + } +} + +bool Creature::CreateFromProto(uint32 guidlow, uint32 Entry, uint32 team, const CreatureData *data) +{ + CreatureInfo const *cinfo = objmgr.GetCreatureTemplate(Entry); + if(!cinfo) + { + sLog.outErrorDb("Error: creature entry %u does not exist.", Entry); + return false; + } + m_originalEntry = Entry; + + Object::_Create(guidlow, Entry, HIGHGUID_UNIT); + + m_DBTableGuid = guidlow; + if(!UpdateEntry(Entry, team, data)) + return false; + + //Notify the map's instance data. + //Only works if you create the object in it, not if it is moves to that map. + //Normally non-players do not teleport to other maps. + Map *map = MapManager::Instance().FindMap(GetMapId(), GetInstanceId()); + if(map && map->IsDungeon() && ((InstanceMap*)map)->GetInstanceData()) + { + ((InstanceMap*)map)->GetInstanceData()->OnCreatureCreate(this, Entry); + } + + return true; +} + +bool Creature::LoadFromDB(uint32 guid, Map *map) +{ + CreatureData const* data = objmgr.GetCreatureData(guid); + + if(!data) + { + sLog.outErrorDb("Creature (GUID: %u) not found in table `creature`, can't load. ",guid); + return false; + } + + uint32 stored_guid = guid; + if (map->GetInstanceId() != 0) guid = objmgr.GenerateLowGuid(HIGHGUID_UNIT); + + uint16 team = 0; + if(!Create(guid,map,data->id,team,data)) + return false; + + Relocate(data->posX,data->posY,data->posZ,data->orientation); + + if(!IsPositionValid()) + { + sLog.outError("ERROR: Creature (guidlow %d, entry %d) not loaded. Suggested coordinates isn't valid (X: %f Y: %f)",GetGUIDLow(),GetEntry(),GetPositionX(),GetPositionY()); + return false; + } + + m_DBTableGuid = stored_guid; + LoadCreaturesAddon(); + + m_respawnradius = data->spawndist; + + m_respawnDelay = data->spawntimesecs; + m_isDeadByDefault = data->is_dead; + m_deathState = m_isDeadByDefault ? DEAD : ALIVE; + + m_respawnTime = objmgr.GetCreatureRespawnTime(m_DBTableGuid,GetInstanceId()); + if(m_respawnTime > time(NULL)) // not ready to respawn + m_deathState = DEAD; + else if(m_respawnTime) // respawn time set but expired + { + m_respawnTime = 0; + objmgr.SaveCreatureRespawnTime(m_DBTableGuid,GetInstanceId(),0); + } + + uint32 curhealth = data->curhealth; + if(curhealth) + { + curhealth = uint32(curhealth*_GetHealthMod(GetCreatureInfo()->rank)); + if(curhealth < 1) + curhealth = 1; + } + + SetHealth(m_deathState == ALIVE ? curhealth : 0); + SetPower(POWER_MANA,data->curmana); + + SetMeleeDamageSchool(SpellSchools(GetCreatureInfo()->dmgschool)); + + // checked at creature_template loading + m_defaultMovementType = MovementGeneratorType(data->movementType); + + AIM_Initialize(); + return true; +} + +void Creature::LoadEquipment(uint32 equip_entry, bool force) +{ + if(equip_entry == 0) + { + if (force) + { + for (uint8 i=0;i<3;i++) + { + SetUInt32Value( UNIT_VIRTUAL_ITEM_SLOT_DISPLAY + i, 0); + SetUInt32Value( UNIT_VIRTUAL_ITEM_INFO + (i * 2), 0); + SetUInt32Value( UNIT_VIRTUAL_ITEM_INFO + (i * 2) + 1, 0); + } + m_equipmentId = 0; + } + return; + } + + EquipmentInfo const *einfo = objmgr.GetEquipmentInfo(equip_entry); + if (!einfo) + return; + + m_equipmentId = equip_entry; + for (uint8 i=0;i<3;i++) + { + SetUInt32Value( UNIT_VIRTUAL_ITEM_SLOT_DISPLAY + i, einfo->equipmodel[i]); + SetUInt32Value( UNIT_VIRTUAL_ITEM_INFO + (i * 2), einfo->equipinfo[i]); + SetUInt32Value( UNIT_VIRTUAL_ITEM_INFO + (i * 2) + 1, einfo->equipslot[i]); + } +} + +void Creature::LoadGoods() +{ + // already loaded; + if(m_itemsLoaded) + return; + + m_vendor_items.clear(); + + VendorItemList const* vList = objmgr.GetNpcVendorItemList(GetEntry()); + if(!vList) + return; + + for (VendorItemList::const_iterator _item_iter = vList->begin(); _item_iter != vList->end(); ++_item_iter) + AddItem( (*_item_iter)->item, (*_item_iter)->maxcount, (*_item_iter)->incrtime, (*_item_iter)->ExtendedCost); + + m_itemsLoaded = true; +} + +bool Creature::hasQuest(uint32 quest_id) const +{ + QuestRelations const& qr = objmgr.mCreatureQuestRelations; + for(QuestRelations::const_iterator itr = qr.lower_bound(GetEntry()); itr != qr.upper_bound(GetEntry()); ++itr) + { + if(itr->second==quest_id) + return true; + } + return false; +} + +bool Creature::hasInvolvedQuest(uint32 quest_id) const +{ + QuestRelations const& qr = objmgr.mCreatureQuestInvolvedRelations; + for(QuestRelations::const_iterator itr = qr.lower_bound(GetEntry()); itr != qr.upper_bound(GetEntry()); ++itr) + { + if(itr->second==quest_id) + return true; + } + return false; +} + +void Creature::DeleteFromDB() +{ + objmgr.SaveCreatureRespawnTime(m_DBTableGuid,GetInstanceId(),0); + objmgr.DeleteCreatureData(m_DBTableGuid); + + WorldDatabase.BeginTransaction(); + WorldDatabase.PExecuteLog("DELETE FROM creature WHERE guid = '%u'", m_DBTableGuid); + WorldDatabase.PExecuteLog("DELETE FROM creature_addon WHERE guid = '%u'", m_DBTableGuid); + WorldDatabase.PExecuteLog("DELETE FROM creature_movement WHERE id = '%u'", m_DBTableGuid); + WorldDatabase.PExecuteLog("DELETE FROM game_event_creature WHERE guid = '%u'", m_DBTableGuid); + WorldDatabase.PExecuteLog("DELETE FROM game_event_model_equip WHERE guid = '%u'", m_DBTableGuid); + WorldDatabase.CommitTransaction(); +} + +float Creature::GetAttackDistance(Unit const* pl) const +{ + float aggroRate = sWorld.getRate(RATE_CREATURE_AGGRO); + if(aggroRate==0) + return 0.0f; + + int32 playerlevel = pl->getLevelForTarget(this); + int32 creaturelevel = getLevelForTarget(pl); + + int32 leveldif = playerlevel - creaturelevel; + + // "The maximum Aggro Radius has a cap of 25 levels under. Example: A level 30 char has the same Aggro Radius of a level 5 char on a level 60 mob." + if ( leveldif < - 25) + leveldif = -25; + + // "The aggro radius of a mob having the same level as the player is roughly 20 yards" + float RetDistance = 20; + + // "Aggro Radius varries with level difference at a rate of roughly 1 yard/level" + // radius grow if playlevel < creaturelevel + RetDistance -= (float)leveldif; + + if(creaturelevel+5 <= sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL)) + { + // detect range auras + RetDistance += GetTotalAuraModifier(SPELL_AURA_MOD_DETECT_RANGE); + + // detected range auras + RetDistance += pl->GetTotalAuraModifier(SPELL_AURA_MOD_DETECTED_RANGE); + } + + // "Minimum Aggro Radius for a mob seems to be combat range (5 yards)" + if(RetDistance < 5) + RetDistance = 5; + + return (RetDistance*aggroRate); +} + +void Creature::setDeathState(DeathState s) +{ + if((s == JUST_DIED && !m_isDeadByDefault)||(s == JUST_ALIVED && m_isDeadByDefault)) + { + m_deathTimer = m_corpseDelay*1000; + + // always save boss respawn time at death to prevent crash cheating + if(sWorld.getConfig(CONFIG_SAVE_RESPAWN_TIME_IMMEDIATLY) || isWorldBoss()) + SaveRespawnTime(); + + if(!IsStopped()) + StopMoving(); + } + Unit::setDeathState(s); + + if(s == JUST_DIED) + { + SetUInt64Value (UNIT_FIELD_TARGET,0); // remove target selection in any cases (can be set at aura remove in Unit::setDeathState) + SetUInt32Value(UNIT_NPC_FLAGS, 0); + + if(!isPet() && GetCreatureInfo()->SkinLootId) + if ( LootTemplates_Skinning.HaveLootFor(GetCreatureInfo()->SkinLootId) ) + SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SKINNABLE); + + Unit::setDeathState(CORPSE); + } + if(s == JUST_ALIVED) + { + SetHealth(GetMaxHealth()); + SetLootRecipient(NULL); + Unit::setDeathState(ALIVE); + CreatureInfo const *cinfo = GetCreatureInfo(); + SetUInt32Value(UNIT_DYNAMIC_FLAGS, 0); + RemoveFlag (UNIT_FIELD_FLAGS, UNIT_FLAG_SKINNABLE); + AddUnitMovementFlag(MOVEMENTFLAG_WALK_MODE); + SetUInt32Value(UNIT_NPC_FLAGS, cinfo->npcflag); + clearUnitState(UNIT_STAT_ALL_STATE); + i_motionMaster.Clear(); + SetMeleeDamageSchool(SpellSchools(cinfo->dmgschool)); + LoadCreaturesAddon(true); + } +} + +void Creature::Respawn() +{ + RemoveCorpse(); + + // forced recreate creature object at clients + UnitVisibility currentVis = GetVisibility(); + SetVisibility(VISIBILITY_RESPAWN); + ObjectAccessor::UpdateObjectVisibility(this); + SetVisibility(currentVis); // restore visibility state + ObjectAccessor::UpdateObjectVisibility(this); + + if(getDeathState()==DEAD) + { + objmgr.SaveCreatureRespawnTime(m_DBTableGuid,GetInstanceId(),0); + m_respawnTime = time(NULL); // respawn at next tick + } +} + +bool Creature::IsImmunedToSpell(SpellEntry const* spellInfo, bool useCharges) +{ + if (!spellInfo) + return false; + + if (GetCreatureInfo()->MechanicImmuneMask & (1 << (spellInfo->Mechanic - 1))) + return true; + + return Unit::IsImmunedToSpell(spellInfo, useCharges); +} + +bool Creature::IsImmunedToSpellEffect(uint32 effect, uint32 mechanic) const +{ + if (GetCreatureInfo()->MechanicImmuneMask & (1 << (mechanic-1))) + return true; + + return Unit::IsImmunedToSpellEffect(effect, mechanic); +} + +SpellEntry const *Creature::reachWithSpellAttack(Unit *pVictim) +{ + if(!pVictim) + return NULL; + + for(uint32 i=0; i < CREATURE_MAX_SPELLS; i++) + { + if(!m_spells[i]) + continue; + SpellEntry const *spellInfo = sSpellStore.LookupEntry(m_spells[i] ); + if(!spellInfo) + { + sLog.outError("WORLD: unknown spell id %i\n", m_spells[i]); + continue; + } + + bool bcontinue = true; + for(uint32 j=0;j<3;j++) + { + if( (spellInfo->Effect[j] == SPELL_EFFECT_SCHOOL_DAMAGE ) || + (spellInfo->Effect[j] == SPELL_EFFECT_INSTAKILL) || + (spellInfo->Effect[j] == SPELL_EFFECT_ENVIRONMENTAL_DAMAGE) || + (spellInfo->Effect[j] == SPELL_EFFECT_HEALTH_LEECH ) + ) + { + bcontinue = false; + break; + } + } + if(bcontinue) continue; + + if(spellInfo->manaCost > GetPower(POWER_MANA)) + continue; + SpellRangeEntry const* srange = sSpellRangeStore.LookupEntry(spellInfo->rangeIndex); + float range = GetSpellMaxRange(srange); + float minrange = GetSpellMinRange(srange); + float dist = GetDistance(pVictim); + //if(!isInFront( pVictim, range ) && spellInfo->AttributesEx ) + // continue; + if( dist > range || dist < minrange ) + continue; + if(HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SILENCED)) + continue; + return spellInfo; + } + return NULL; +} + +SpellEntry const *Creature::reachWithSpellCure(Unit *pVictim) +{ + if(!pVictim) + return NULL; + + for(uint32 i=0; i < CREATURE_MAX_SPELLS; i++) + { + if(!m_spells[i]) + continue; + SpellEntry const *spellInfo = sSpellStore.LookupEntry(m_spells[i] ); + if(!spellInfo) + { + sLog.outError("WORLD: unknown spell id %i\n", m_spells[i]); + continue; + } + + bool bcontinue = true; + for(uint32 j=0;j<3;j++) + { + if( (spellInfo->Effect[j] == SPELL_EFFECT_HEAL ) ) + { + bcontinue = false; + break; + } + } + if(bcontinue) continue; + + if(spellInfo->manaCost > GetPower(POWER_MANA)) + continue; + SpellRangeEntry const* srange = sSpellRangeStore.LookupEntry(spellInfo->rangeIndex); + float range = GetSpellMaxRange(srange); + float minrange = GetSpellMinRange(srange); + float dist = GetDistance(pVictim); + //if(!isInFront( pVictim, range ) && spellInfo->AttributesEx ) + // continue; + if( dist > range || dist < minrange ) + continue; + if(HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SILENCED)) + continue; + return spellInfo; + } + return NULL; +} + +bool Creature::IsVisibleInGridForPlayer(Player* pl) const +{ + // gamemaster in GM mode see all, including ghosts + if(pl->isGameMaster()) + return true; + + // Live player (or with not release body see live creatures or death creatures with corpse disappearing time > 0 + if(pl->isAlive() || pl->GetDeathTimer() > 0) + { + if( GetEntry() == VISUAL_WAYPOINT && !pl->isGameMaster() ) + return false; + return isAlive() || m_deathTimer > 0 || m_isDeadByDefault && m_deathState==CORPSE; + } + + // Dead player see live creatures near own corpse + if(isAlive()) + { + Corpse *corpse = pl->GetCorpse(); + if(corpse) + { + // 20 - aggro distance for same level, 25 - max additional distance if player level less that creature level + if(corpse->IsWithinDistInMap(this,(20+25)*sWorld.getRate(RATE_CREATURE_AGGRO))) + return true; + } + } + + // Dead player see Spirit Healer or Spirit Guide + if(isSpiritService()) + return true; + + // and not see any other + return false; +} + +void Creature::CallAssistence() +{ + if( !m_AlreadyCallAssistence && getVictim() && !isPet() && !isCharmed()) + { + SetNoCallAssistence(true); + + float radius = sWorld.getConfig(CONFIG_CREATURE_FAMILY_ASSISTEMCE_RADIUS); + if(radius > 0) + { + std::list assistList; + + { + CellPair p(MaNGOS::ComputeCellPair(GetPositionX(), GetPositionY())); + Cell cell(p); + cell.data.Part.reserved = ALL_DISTRICT; + cell.SetNoCreate(); + + MaNGOS::AnyAssistCreatureInRangeCheck u_check(this, getVictim(), radius); + MaNGOS::CreatureListSearcher searcher(assistList, u_check); + + TypeContainerVisitor, GridTypeMapContainer > grid_creature_searcher(searcher); + + CellLock cell_lock(cell, p); + cell_lock->Visit(cell_lock, grid_creature_searcher, *MapManager::Instance().GetMap(GetMapId(), this)); + } + + for(std::list::iterator iter = assistList.begin(); iter != assistList.end(); ++iter) + { + (*iter)->SetNoCallAssistence(true); + if((*iter)->AI()) + (*iter)->AI()->AttackStart(getVictim()); + } + } + } +} + +void Creature::SaveRespawnTime() +{ + if(isPet()) + return; + + if(m_respawnTime > time(NULL)) // dead (no corpse) + objmgr.SaveCreatureRespawnTime(m_DBTableGuid,GetInstanceId(),m_respawnTime); + else if(m_deathTimer > 0) // dead (corpse) + objmgr.SaveCreatureRespawnTime(m_DBTableGuid,GetInstanceId(),time(NULL)+m_respawnDelay+m_deathTimer/1000); +} + +bool Creature::IsOutOfThreatArea(Unit* pVictim) const +{ + if(!pVictim) + return true; + + if(!pVictim->IsInMap(this)) + return true; + + if(!pVictim->isTargetableForAttack()) + return true; + + if(!pVictim->isInAccessablePlaceFor(this)) + return true; + + if(sMapStore.LookupEntry(GetMapId())->Instanceable()) + return false; + + float length = pVictim->GetDistance(CombatStartX,CombatStartY,CombatStartZ); + float AttackDist = GetAttackDistance(pVictim); + uint32 ThreatRadius = sWorld.getConfig(CONFIG_THREAT_RADIUS); + + //Use AttackDistance in distance check if threat radius is lower. This prevents creature bounce in and ouf of combat every update tick. + return ( length > (ThreatRadius > AttackDist ? ThreatRadius : AttackDist)); +} + +CreatureDataAddon const* Creature::GetCreatureAddon() const +{ + if(CreatureDataAddon const* addon = ObjectMgr::GetCreatureAddon(m_DBTableGuid)) + return addon; + + // dependent from heroic mode entry + return ObjectMgr::GetCreatureTemplateAddon(GetCreatureInfo()->Entry); +} + +//creature_addon table +bool Creature::LoadCreaturesAddon(bool reload) +{ + CreatureDataAddon const *cainfo = GetCreatureAddon(); + if(!cainfo) + return false; + + if (cainfo->mount != 0) + Mount(cainfo->mount); + + if (cainfo->bytes0 != 0) + SetUInt32Value(UNIT_FIELD_BYTES_0, cainfo->bytes0); + + if (cainfo->bytes1 != 0) + SetUInt32Value(UNIT_FIELD_BYTES_1, cainfo->bytes1); + + if (cainfo->bytes2 != 0) + SetUInt32Value(UNIT_FIELD_BYTES_2, cainfo->bytes2); + + if (cainfo->emote != 0) + SetUInt32Value(UNIT_NPC_EMOTESTATE, cainfo->emote); + + if (cainfo->move_flags != 0) + SetUnitMovementFlags(cainfo->move_flags); + + if(cainfo->auras) + { + for (CreatureDataAddonAura const* cAura = cainfo->auras; cAura->spell_id; ++cAura) + { + SpellEntry const *AdditionalSpellInfo = sSpellStore.LookupEntry(cAura->spell_id); + if (!AdditionalSpellInfo) + { + sLog.outErrorDb("Creature (GUIDLow: %u Entry: %u ) has wrong spell %u defined in `auras` field.",GetGUIDLow(),GetEntry(),cAura->spell_id); + continue; + } + + // skip already applied aura + if(HasAura(cAura->spell_id,cAura->effect_idx)) + { + if(!reload) + sLog.outErrorDb("Creature (GUIDLow: %u Entry: %u ) has duplicate aura (spell %u effect %u) in `auras` field.",GetGUIDLow(),GetEntry(),cAura->spell_id,cAura->effect_idx); + + continue; + } + + Aura* AdditionalAura = CreateAura(AdditionalSpellInfo, cAura->effect_idx, NULL, this, this, 0); + AddAura(AdditionalAura); + sLog.outDebug("Spell: %u with Aura %u added to creature (GUIDLow: %u Entry: %u )", cAura->spell_id, AdditionalSpellInfo->EffectApplyAuraName[0],GetGUIDLow(),GetEntry()); + } + } + return true; +} + +/// Send a message to LocalDefense channel for players oposition team in the zone +void Creature::SendZoneUnderAttackMessage(Player* attacker) +{ + uint32 enemy_team = attacker->GetTeam(); + + WorldPacket data(SMSG_ZONE_UNDER_ATTACK,4); + data << (uint32)GetZoneId(); + sWorld.SendGlobalMessage(&data,NULL,(enemy_team==ALLIANCE ? HORDE : ALLIANCE)); +} + +void Creature::_AddCreatureSpellCooldown(uint32 spell_id, time_t end_time) +{ + m_CreatureSpellCooldowns[spell_id] = end_time; +} + +void Creature::_AddCreatureCategoryCooldown(uint32 category, time_t apply_time) +{ + m_CreatureCategoryCooldowns[category] = apply_time; +} + +void Creature::AddCreatureSpellCooldown(uint32 spellid) +{ + SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellid); + if(!spellInfo) + return; + + uint32 cooldown = GetSpellRecoveryTime(spellInfo); + if(cooldown) + _AddCreatureSpellCooldown(spellid, time(NULL) + cooldown/1000); + + if(spellInfo->Category) + _AddCreatureCategoryCooldown(spellInfo->Category, time(NULL)); + + m_GlobalCooldown = spellInfo->StartRecoveryTime; +} + +bool Creature::HasCategoryCooldown(uint32 spell_id) const +{ + SpellEntry const *spellInfo = sSpellStore.LookupEntry(spell_id); + if(!spellInfo) + return false; + + // check global cooldown if spell affected by it + if (spellInfo->StartRecoveryCategory > 0 && m_GlobalCooldown > 0) + return true; + + CreatureSpellCooldowns::const_iterator itr = m_CreatureCategoryCooldowns.find(spellInfo->Category); + return(itr != m_CreatureCategoryCooldowns.end() && time_t(itr->second + (spellInfo->CategoryRecoveryTime / 1000)) > time(NULL)); +} + +bool Creature::HasSpellCooldown(uint32 spell_id) const +{ + CreatureSpellCooldowns::const_iterator itr = m_CreatureSpellCooldowns.find(spell_id); + return (itr != m_CreatureSpellCooldowns.end() && itr->second > time(NULL)) || HasCategoryCooldown(spell_id); +} + +bool Creature::IsInEvadeMode() const +{ + return !i_motionMaster.empty() && i_motionMaster.GetCurrentMovementGeneratorType() == HOME_MOTION_TYPE; +} + +bool Creature::HasSpell(uint32 spellID) const +{ + uint8 i; + for(i = 0; i < CREATURE_MAX_SPELLS; ++i) + if(spellID == m_spells[i]) + break; + return i < CREATURE_MAX_SPELLS; //broke before end of iteration of known spells +} + +time_t Creature::GetRespawnTimeEx() const +{ + time_t now = time(NULL); + if(m_respawnTime > now) // dead (no corpse) + return m_respawnTime; + else if(m_deathTimer > 0) // dead (corpse) + return now+m_respawnDelay+m_deathTimer/1000; + else + return now; +} + +void Creature::GetRespawnCoord( float &x, float &y, float &z, float* ori, float* dist ) const +{ + if(CreatureData const* data = objmgr.GetCreatureData(GetDBTableGUIDLow())) + { + x = data->posX; + y = data->posY; + z = data->posZ; + if(ori) + *ori = data->orientation; + if(dist) + *dist = data->spawndist; + } + else + { + x = GetPositionX(); + y = GetPositionY(); + z = GetPositionZ(); + if(ori) + *ori = GetOrientation(); + if(dist) + *dist = 0; + } +} + +void Creature::AllLootRemovedFromCorpse() +{ + if (!HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SKINNABLE)) + { + uint32 nDeathTimer; + + CreatureInfo const *cinfo = GetCreatureInfo(); + + // corpse was not skinnable -> apply corpse looted timer + if (!cinfo || !cinfo->SkinLootId) + nDeathTimer = (uint32)((m_corpseDelay * 1000) * sWorld.getRate(RATE_CORPSE_DECAY_LOOTED)); + // corpse skinnable, but without skinning flag, and then skinned, corpse will despawn next update + else + nDeathTimer = 0; + + // update death timer only if looted timer is shorter + if (m_deathTimer > nDeathTimer) + m_deathTimer = nDeathTimer; + } +} + +uint32 Creature::getLevelForTarget( Unit const* target ) const +{ + if(!isWorldBoss()) + return Unit::getLevelForTarget(target); + + uint32 level = target->getLevel()+sWorld.getConfig(CONFIG_WORLD_BOSS_LEVEL_DIFF); + if(level < 1) + return 1; + if(level > 255) + return 255; + return level; +} + +char const* Creature::GetScriptName() const +{ + return ObjectMgr::GetCreatureTemplate(GetEntry())->ScriptName; +} + +TrainerSpellData const* Creature::GetTrainerSpells() const +{ + return objmgr.GetNpcTrainerSpells(GetEntry()); +} diff --git a/src/game/Creature.h b/src/game/Creature.h index d70954acefe..394d75f5355 100644 --- a/src/game/Creature.h +++ b/src/game/Creature.h @@ -1,611 +1,612 @@ -/* - * Copyright (C) 2005-2008 MaNGOS - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef MANGOSSERVER_CREATURE_H -#define MANGOSSERVER_CREATURE_H - -#include "Common.h" -#include "Unit.h" -#include "UpdateMask.h" -#include "ItemPrototype.h" -#include "LootMgr.h" -#include "Database/DatabaseEnv.h" -#include "Cell.h" - -struct SpellEntry; - -class CreatureAI; -class Quest; -class Player; -class WorldSession; - -enum Gossip_Option -{ - GOSSIP_OPTION_NONE = 0, //UNIT_NPC_FLAG_NONE = 0, - GOSSIP_OPTION_GOSSIP = 1, //UNIT_NPC_FLAG_GOSSIP = 1, - GOSSIP_OPTION_QUESTGIVER = 2, //UNIT_NPC_FLAG_QUESTGIVER = 2, - GOSSIP_OPTION_VENDOR = 3, //UNIT_NPC_FLAG_VENDOR = 4, - GOSSIP_OPTION_TAXIVENDOR = 4, //UNIT_NPC_FLAG_TAXIVENDOR = 8, - GOSSIP_OPTION_TRAINER = 5, //UNIT_NPC_FLAG_TRAINER = 16, - GOSSIP_OPTION_SPIRITHEALER = 6, //UNIT_NPC_FLAG_SPIRITHEALER = 32, - GOSSIP_OPTION_SPIRITGUIDE = 7, //UNIT_NPC_FLAG_SPIRITGUIDE = 64, - GOSSIP_OPTION_INNKEEPER = 8, //UNIT_NPC_FLAG_INNKEEPER = 128, - GOSSIP_OPTION_BANKER = 9, //UNIT_NPC_FLAG_BANKER = 256, - GOSSIP_OPTION_PETITIONER = 10, //UNIT_NPC_FLAG_PETITIONER = 512, - GOSSIP_OPTION_TABARDDESIGNER = 11, //UNIT_NPC_FLAG_TABARDDESIGNER = 1024, - GOSSIP_OPTION_BATTLEFIELD = 12, //UNIT_NPC_FLAG_BATTLEFIELDPERSON = 2048, - GOSSIP_OPTION_AUCTIONEER = 13, //UNIT_NPC_FLAG_AUCTIONEER = 4096, - GOSSIP_OPTION_STABLEPET = 14, //UNIT_NPC_FLAG_STABLE = 8192, - GOSSIP_OPTION_ARMORER = 15, //UNIT_NPC_FLAG_ARMORER = 16384, - GOSSIP_OPTION_UNLEARNTALENTS = 16, //UNIT_NPC_FLAG_TRAINER (bonus option for GOSSIP_OPTION_TRAINER) - GOSSIP_OPTION_UNLEARNPETSKILLS = 17 //UNIT_NPC_FLAG_TRAINER (bonus option for GOSSIP_OPTION_TRAINER) -}; - -enum Gossip_Guard -{ - GOSSIP_GUARD_BANK = 32, - GOSSIP_GUARD_RIDE = 33, - GOSSIP_GUARD_GUILD = 34, - GOSSIP_GUARD_INN = 35, - GOSSIP_GUARD_MAIL = 36, - GOSSIP_GUARD_AUCTION = 37, - GOSSIP_GUARD_WEAPON = 38, - GOSSIP_GUARD_STABLE = 39, - GOSSIP_GUARD_BATTLE = 40, - GOSSIP_GUARD_SPELLTRAINER = 41, - GOSSIP_GUARD_SKILLTRAINER = 42 -}; - -enum Gossip_Guard_Spell -{ - GOSSIP_GUARD_SPELL_WARRIOR = 64, - GOSSIP_GUARD_SPELL_PALADIN = 65, - GOSSIP_GUARD_SPELL_HUNTER = 66, - GOSSIP_GUARD_SPELL_ROGUE = 67, - GOSSIP_GUARD_SPELL_PRIEST = 68, - GOSSIP_GUARD_SPELL_UNKNOWN1 = 69, - GOSSIP_GUARD_SPELL_SHAMAN = 70, - GOSSIP_GUARD_SPELL_MAGE = 71, - GOSSIP_GUARD_SPELL_WARLOCK = 72, - GOSSIP_GUARD_SPELL_UNKNOWN2 = 73, - GOSSIP_GUARD_SPELL_DRUID = 74 -}; - -enum Gossip_Guard_Skill -{ - GOSSIP_GUARD_SKILL_ALCHEMY = 80, - GOSSIP_GUARD_SKILL_BLACKSMITH = 81, - GOSSIP_GUARD_SKILL_COOKING = 82, - GOSSIP_GUARD_SKILL_ENCHANT = 83, - GOSSIP_GUARD_SKILL_FIRSTAID = 84, - GOSSIP_GUARD_SKILL_FISHING = 85, - GOSSIP_GUARD_SKILL_HERBALISM = 86, - GOSSIP_GUARD_SKILL_LEATHER = 87, - GOSSIP_GUARD_SKILL_MINING = 88, - GOSSIP_GUARD_SKILL_SKINNING = 89, - GOSSIP_GUARD_SKILL_TAILORING = 90, - GOSSIP_GUARD_SKILL_ENGINERING = 91 -}; - -struct GossipOption -{ - uint32 Id; - uint32 GossipId; - uint32 NpcFlag; - uint32 Icon; - uint32 Action; - std::string Option; -}; - -struct CreatureItem -{ - CreatureItem(uint32 _item, uint32 _maxcount, uint32 _incrtime, uint32 _ExtendedCost) - : id(_item), count(_maxcount), maxcount(_maxcount), incrtime(_incrtime), ExtendedCost(_ExtendedCost), lastincr((uint32)time(NULL)) {} - - uint32 id; - uint32 count; - uint32 maxcount; - uint32 incrtime; - uint32 lastincr; - uint32 ExtendedCost; -}; - -struct TrainerSpell -{ - SpellEntry const* spell; - uint32 spellcost; - uint32 reqskill; - uint32 reqskillvalue; - uint32 reqlevel; -}; - -enum CreatureFlagsExtra -{ - CREATURE_FLAG_EXTRA_INSTANCE_BIND = 0x00000001, // creature kill bind instance with killer and killer's group - CREATURE_FLAG_EXTRA_CIVILIAN = 0x00000002, // not aggro (ignore faction/reputation hostility) - CREATURE_FLAG_EXTRA_NO_PARRY = 0x00000004, // creature can't parry - CREATURE_FLAG_EXTRA_NO_PARRY_HASTEN = 0x00000008, // creature can't counter-attack at parry - CREATURE_FLAG_EXTRA_NO_BLOCK = 0x00000010, // creature can't block - CREATURE_FLAG_EXTRA_NO_CRUSH = 0x00000020, // creature can't do crush attacks - CREATURE_FLAG_EXTRA_NO_XP_AT_KILL = 0x00000040, // creature kill not provide XP -}; - -// GCC have alternative #pragma pack(N) syntax and old gcc version not support pack(push,N), also any gcc version not support it at some platform -#if defined( __GNUC__ ) -#pragma pack(1) -#else -#pragma pack(push,1) -#endif - -// from `creature_template` table -struct CreatureInfo -{ - uint32 Entry; - uint32 HeroicEntry; - uint32 DisplayID_A; - uint32 DisplayID_A2; - uint32 DisplayID_H; - uint32 DisplayID_H2; - char* Name; - char* SubName; - char* IconName; - uint32 minlevel; - uint32 maxlevel; - uint32 minhealth; - uint32 maxhealth; - uint32 minmana; - uint32 maxmana; - uint32 armor; - uint32 faction_A; - uint32 faction_H; - uint32 npcflag; - float speed; - float scale; - uint32 rank; - float mindmg; - float maxdmg; - uint32 dmgschool; - uint32 attackpower; - uint32 baseattacktime; - uint32 rangeattacktime; - uint32 Flags; - uint32 dynamicflags; - uint32 family; - uint32 trainer_type; - uint32 trainer_spell; - uint32 classNum; - uint32 race; - float minrangedmg; - float maxrangedmg; - uint32 rangedattackpower; - uint32 type; - uint32 flag1; - uint32 lootid; - uint32 pickpocketLootId; - uint32 SkinLootId; - int32 resistance1; - int32 resistance2; - int32 resistance3; - int32 resistance4; - int32 resistance5; - int32 resistance6; - uint32 spell1; - uint32 spell2; - uint32 spell3; - uint32 spell4; - uint32 PetSpellDataId; - uint32 mingold; - uint32 maxgold; - char const* AIName; - uint32 MovementType; - uint32 InhabitType; - bool RacialLeader; - bool RegenHealth; - uint32 equipmentId; - uint32 MechanicImmuneMask; - uint32 flags_extra; - char const* ScriptName; -}; - -struct CreatureLocale -{ - std::vector Name; - std::vector SubName; -}; - -struct EquipmentInfo -{ - uint32 entry; - uint32 equipmodel[3]; - uint32 equipinfo[3]; - uint32 equipslot[3]; -}; - -// from `creature` table -struct CreatureData -{ - uint32 id; // entry in creature_template - uint16 mapid; - uint32 displayid; - int32 equipmentId; - float posX; - float posY; - float posZ; - float orientation; - uint32 spawntimesecs; - float spawndist; - uint32 currentwaypoint; - uint32 curhealth; - uint32 curmana; - bool is_dead; - uint8 movementType; - uint8 spawnMask; -}; - -struct CreatureDataAddonAura -{ - uint16 spell_id; - uint8 effect_idx; -}; - -// from `creature_addon` table -struct CreatureDataAddon -{ - uint32 guidOrEntry; - uint32 mount; - uint32 bytes0; - uint32 bytes1; - uint32 bytes2; - uint32 emote; - uint32 move_flags; - CreatureDataAddonAura const* auras; // loaded as char* "spell1 eff1 spell2 eff2 ... " -}; - -struct CreatureModelInfo -{ - uint32 modelid; - float bounding_radius; - float combat_reach; - uint8 gender; - uint32 modelid_other_gender; -}; - -enum InhabitTypeValues -{ - INHABIT_GROUND = 1, - INHABIT_WATER = 2, - INHABIT_AIR = 4, - INHABIT_ANYWHERE = INHABIT_GROUND | INHABIT_WATER | INHABIT_AIR -}; - -// GCC have alternative #pragma pack() syntax and old gcc version not support pack(pop), also any gcc version not support it at some platform -#if defined( __GNUC__ ) -#pragma pack() -#else -#pragma pack(pop) -#endif - -typedef std::list GossipOptionList; - -typedef std::map CreatureSpellCooldowns; - -// max different by z coordinate for creature aggro reaction -#define CREATURE_Z_ATTACK_RANGE 3 - -#define MAX_VENDOR_ITEMS 255 // Limitation in item count field size in SMSG_LIST_INVENTORY - -class MANGOS_DLL_SPEC Creature : public Unit -{ - CreatureAI *i_AI; - - public: - - explicit Creature(); - virtual ~Creature(); - - void AddToWorld(); - void RemoveFromWorld(); - - bool Create (uint32 guidlow, Map *map, uint32 Entry, uint32 team, const CreatureData *data = NULL); - bool LoadCreaturesAddon(bool reload = false); - void SelectLevel(const CreatureInfo *cinfo); - void LoadEquipment(uint32 equip_entry, bool force=false); - - uint32 GetDBTableGUIDLow() const { return m_DBTableGuid; } - char const* GetSubName() const { return GetCreatureInfo()->SubName; } - - void Update( uint32 time ); // overwrited Unit::Update - void GetRespawnCoord(float &x, float &y, float &z, float* ori = NULL, float* dist =NULL) const; - uint32 GetEquipmentId() const { return m_equipmentId; } - - bool isPet() const { return m_isPet; } - void SetCorpseDelay(uint32 delay) { m_corpseDelay = delay; } - bool isTotem() const { return m_isTotem; } - bool isRacialLeader() const { return GetCreatureInfo()->RacialLeader; } - bool isCivilian() const { return GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_CIVILIAN; } - bool canWalk() const { return GetCreatureInfo()->InhabitType & INHABIT_GROUND; } - bool canSwim() const { return GetCreatureInfo()->InhabitType & INHABIT_WATER; } - bool canFly() const { return GetCreatureInfo()->InhabitType & INHABIT_AIR; } - ///// TODO RENAME THIS!!!!! - bool isCanTrainingOf(Player* player, bool msg) const; - bool isCanIneractWithBattleMaster(Player* player, bool msg) const; - bool isCanTrainingAndResetTalentsOf(Player* pPlayer) const; - bool IsOutOfThreatArea(Unit* pVictim) const; - bool IsImmunedToSpell(SpellEntry const* spellInfo, bool useCharges = false); - // redefine Unit::IsImmunedToSpell - bool IsImmunedToSpellEffect(uint32 effect, uint32 mechanic) const; - // redefine Unit::IsImmunedToSpellEffect - bool isElite() const - { - if(isPet()) - return false; - - uint32 rank = GetCreatureInfo()->rank; - return rank != CREATURE_ELITE_NORMAL && rank != CREATURE_ELITE_RARE; - } - - bool isWorldBoss() const - { - if(isPet()) - return false; - - return GetCreatureInfo()->rank == CREATURE_ELITE_WORLDBOSS; - } - - uint32 getLevelForTarget(Unit const* target) const; // overwrite Unit::getLevelForTarget for boss level support - - bool IsInEvadeMode() const; - - bool AIM_Initialize(); - - void AI_SendMoveToPacket(float x, float y, float z, uint32 time, uint32 MovementFlags, uint8 type); - CreatureAI* AI() { return i_AI; } - - uint32 GetShieldBlockValue() const //dunno mob block value - { - return (getLevel()/2 + uint32(GetStat(STAT_STRENGTH)/20)); - } - - SpellSchoolMask GetMeleeDamageSchoolMask() const { return m_meleeDamageSchoolMask; } - void SetMeleeDamageSchool(SpellSchools school) { m_meleeDamageSchoolMask = SpellSchoolMask(1 << school); } - - void _AddCreatureSpellCooldown(uint32 spell_id, time_t end_time); - void _AddCreatureCategoryCooldown(uint32 category, time_t apply_time); - void AddCreatureSpellCooldown(uint32 spellid); - bool HasSpellCooldown(uint32 spell_id) const; - bool HasCategoryCooldown(uint32 spell_id) const; - - bool HasSpell(uint32 spellID) const; - - bool UpdateEntry(uint32 entry, uint32 team=ALLIANCE, const CreatureData* data=NULL); - bool UpdateStats(Stats stat); - bool UpdateAllStats(); - void UpdateResistances(uint32 school); - void UpdateArmor(); - void UpdateMaxHealth(); - void UpdateMaxPower(Powers power); - void UpdateAttackPowerAndDamage(bool ranged = false); - void UpdateDamagePhysical(WeaponAttackType attType); - uint32 GetCurrentEquipmentId() { return m_equipmentId; } - float GetSpellDamageMod(int32 Rank); - - /*********************************************************/ - /*** VENDOR SYSTEM ***/ - /*********************************************************/ - void LoadGoods(); // must be called before access to vendor items, lazy loading at first call - void ReloadGoods() { m_itemsLoaded = false; LoadGoods(); } - - CreatureItem* GetItem(uint32 slot) - { - if(slot>=m_vendor_items.size()) return NULL; - return &m_vendor_items[slot]; - } - uint8 GetItemCount() const { return m_vendor_items.size(); } - void AddItem( uint32 item, uint32 maxcount, uint32 ptime, uint32 ExtendedCost) - { - m_vendor_items.push_back(CreatureItem(item, maxcount, ptime, ExtendedCost)); - } - bool RemoveItem( uint32 item_id ) - { - for(CreatureItems::iterator i = m_vendor_items.begin(); i != m_vendor_items.end(); ++i ) - { - if(i->id==item_id) - { - m_vendor_items.erase(i); - return true; - } - } - return false; - } - CreatureItem* FindItem(uint32 item_id) - { - for(CreatureItems::iterator i = m_vendor_items.begin(); i != m_vendor_items.end(); ++i ) - if(i->id==item_id) - return &*i; - return NULL; - } - - /*********************************************************/ - /*** TRAINER SYSTEM ***/ - /*********************************************************/ - typedef std::list SpellsList; - void LoadTrainerSpells(); // must be called before access to trainer spells, lazy loading at first call - void ReloadTrainerSpells() { m_trainerSpellsLoaded = false; LoadTrainerSpells(); } - SpellsList const& GetTrainerSpells() const { return m_trainer_spells; } - uint32 GetTrainerType() const { return m_trainer_type; } - - CreatureInfo const *GetCreatureInfo() const { return m_creatureInfo; } - CreatureDataAddon const* GetCreatureAddon() const; - char const* GetScriptName() const; - - void prepareGossipMenu( Player *pPlayer,uint32 gossipid ); - void sendPreparedGossip( Player* player); - void OnGossipSelect(Player* player, uint32 option); - void OnPoiSelect(Player* player, GossipOption const *gossip); - - uint32 GetGossipTextId(uint32 action, uint32 zoneid); - uint32 GetNpcTextId(); - void LoadGossipOptions(); - GossipOption const* GetGossipOption( uint32 id ) const; - void addGossipOption(GossipOption const& gso) { m_goptions.push_back(gso); } - - void setEmoteState(uint8 emote) { m_emoteState = emote; }; - void Say(const char* text, uint32 language, uint64 TargetGuid) { MonsterSay(text,language,TargetGuid); } - void Yell(const char* text, uint32 language, uint64 TargetGuid) { MonsterYell(text,language,TargetGuid); } - void TextEmote(const char* text, uint64 TargetGuid, bool IsBossEmote = false) { MonsterTextEmote(text,TargetGuid,IsBossEmote); } - void Whisper(const char* text, uint64 receiver, bool IsBossWhisper = false) { MonsterWhisper(text,receiver,IsBossWhisper); } - void Say(int32 textId, uint32 language, uint64 TargetGuid) { MonsterSay(textId,language,TargetGuid); } - void Yell(int32 textId, uint32 language, uint64 TargetGuid) { MonsterYell(textId,language,TargetGuid); } - void TextEmote(int32 textId, uint64 TargetGuid, bool IsBossEmote = false) { MonsterTextEmote(textId,TargetGuid,IsBossEmote); } - void Whisper(int32 textId, uint64 receiver, bool IsBossWhisper = false) { MonsterWhisper(textId,receiver,IsBossWhisper); } - - void setDeathState(DeathState s); // overwrite virtual Unit::setDeathState - - bool LoadFromDB(uint32 guid, Map *map); - void SaveToDB(); - // overwrited in Pet - virtual void SaveToDB(uint32 mapid, uint8 spawnMask); - virtual void DeleteFromDB(); // overwrited in Pet - - Loot loot; - bool lootForPickPocketed; - bool lootForBody; - Player *GetLootRecipient() const; - bool hasLootRecipient() const { return m_lootRecipient!=0; } - - void SetLootRecipient (Unit* unit); - void AllLootRemovedFromCorpse(); - - SpellEntry const *reachWithSpellAttack(Unit *pVictim); - SpellEntry const *reachWithSpellCure(Unit *pVictim); - - uint32 m_spells[CREATURE_MAX_SPELLS]; - CreatureSpellCooldowns m_CreatureSpellCooldowns; - CreatureSpellCooldowns m_CreatureCategoryCooldowns; - uint32 m_GlobalCooldown; - - float GetAttackDistance(Unit const* pl) const; - - void CallAssistence(); - void SetNoCallAssistence(bool val) { m_AlreadyCallAssistence = val; } - - MovementGeneratorType GetDefaultMovementType() const { return m_defaultMovementType; } - void SetDefaultMovementType(MovementGeneratorType mgt) { m_defaultMovementType = mgt; } - - // for use only in LoadHelper, Map::Add Map::CreatureCellRelocation - Cell const& GetCurrentCell() const { return m_currentCell; } - void SetCurrentCell(Cell const& cell) { m_currentCell = cell; } - - bool IsVisibleInGridForPlayer(Player* pl) const; - - void RemoveCorpse(); - - time_t const& GetRespawnTime() const { return m_respawnTime; } - time_t GetRespawnTimeEx() const; - void SetRespawnTime(uint32 respawn) { m_respawnTime = respawn ? time(NULL) + respawn : 0; } - void Respawn(); - void SaveRespawnTime(); - - uint32 GetRespawnDelay() const { return m_respawnDelay; } - void SetRespawnDelay(uint32 delay) { m_respawnDelay = delay; } - - float GetRespawnRadius() const { return m_respawnradius; } - void SetRespawnRadius(float dist) { m_respawnradius = dist; } - - uint32 m_groupLootTimer; // (msecs)timer used for group loot - uint64 lootingGroupLeaderGUID; // used to find group which is looting corpse - - void SendZoneUnderAttackMessage(Player* attacker); - - bool hasQuest(uint32 quest_id) const; - bool hasInvolvedQuest(uint32 quest_id) const; - - GridReference &GetGridRef() { return m_gridRef; } - bool isRegeneratingHealth() { return m_regenHealth; } - virtual uint8 GetPetAutoSpellSize() const { return CREATURE_MAX_SPELLS; } - virtual uint32 GetPetAutoSpellOnPos(uint8 pos) const - { - if (pos >= CREATURE_MAX_SPELLS || m_charmInfo->GetCharmSpell(pos)->active != ACT_ENABLED) - return 0; - else - return m_charmInfo->GetCharmSpell(pos)->spellId; - } - - void SetCombatStartPosition(float x, float y, float z) { CombatStartX = x; CombatStartY = y; CombatStartZ = z; } - void GetCombatStartPosition(float &x, float &y, float &z) { x = CombatStartX; y = CombatStartY; z = CombatStartZ; } - - protected: - bool CreateFromProto(uint32 guidlow,uint32 Entry,uint32 team, const CreatureData *data = NULL); - bool InitEntry(uint32 entry, uint32 team=ALLIANCE, const CreatureData* data=NULL); - - // vendor items - typedef std::vector CreatureItems; - CreatureItems m_vendor_items; - bool m_itemsLoaded; // vendor items loading state - - // trainer spells - bool m_trainerSpellsLoaded; // trainer spells loading state - SpellsList m_trainer_spells; - uint32 m_trainer_type; // trainer type based at trainer spells, can be different from creature_template value. - // req. for correct show non-prof. trainers like weaponmaster. - void _RealtimeSetCreatureInfo(); - - static float _GetHealthMod(int32 Rank); - static float _GetDamageMod(int32 Rank); - - uint32 m_lootMoney; - uint64 m_lootRecipient; - - /// Timers - uint32 m_deathTimer; // (msecs)timer for death or corpse disappearance - time_t m_respawnTime; // (secs) time of next respawn - uint32 m_respawnDelay; // (secs) delay between corpse disappearance and respawning - uint32 m_corpseDelay; // (secs) delay between death and corpse disappearance - float m_respawnradius; - - bool m_gossipOptionLoaded; - GossipOptionList m_goptions; - uint32 m_NPCTextId; // cached value - - uint8 m_emoteState; - bool m_isPet; // set only in Pet::Pet - bool m_isTotem; // set only in Totem::Totem - void RegenerateMana(); - void RegenerateHealth(); - uint32 m_regenTimer; - MovementGeneratorType m_defaultMovementType; - Cell m_currentCell; // store current cell where creature listed - uint32 m_DBTableGuid; - uint32 m_equipmentId; - - bool m_AlreadyCallAssistence; - bool m_regenHealth; - bool m_AI_locked; - bool m_isDeadByDefault; - - SpellSchoolMask m_meleeDamageSchoolMask; - uint32 m_originalEntry; - - float CombatStartX; - float CombatStartY; - float CombatStartZ; - private: - GridReference m_gridRef; - CreatureInfo const* m_creatureInfo; // in heroic mode can different from ObjMgr::GetCreatureTemplate(GetEntry()) -}; -#endif +/* + * Copyright (C) 2005-2008 MaNGOS + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef MANGOSSERVER_CREATURE_H +#define MANGOSSERVER_CREATURE_H + +#include "Common.h" +#include "Unit.h" +#include "UpdateMask.h" +#include "ItemPrototype.h" +#include "LootMgr.h" +#include "Database/DatabaseEnv.h" +#include "Cell.h" + +struct SpellEntry; + +class CreatureAI; +class Quest; +class Player; +class WorldSession; + +enum Gossip_Option +{ + GOSSIP_OPTION_NONE = 0, //UNIT_NPC_FLAG_NONE = 0, + GOSSIP_OPTION_GOSSIP = 1, //UNIT_NPC_FLAG_GOSSIP = 1, + GOSSIP_OPTION_QUESTGIVER = 2, //UNIT_NPC_FLAG_QUESTGIVER = 2, + GOSSIP_OPTION_VENDOR = 3, //UNIT_NPC_FLAG_VENDOR = 4, + GOSSIP_OPTION_TAXIVENDOR = 4, //UNIT_NPC_FLAG_TAXIVENDOR = 8, + GOSSIP_OPTION_TRAINER = 5, //UNIT_NPC_FLAG_TRAINER = 16, + GOSSIP_OPTION_SPIRITHEALER = 6, //UNIT_NPC_FLAG_SPIRITHEALER = 32, + GOSSIP_OPTION_SPIRITGUIDE = 7, //UNIT_NPC_FLAG_SPIRITGUIDE = 64, + GOSSIP_OPTION_INNKEEPER = 8, //UNIT_NPC_FLAG_INNKEEPER = 128, + GOSSIP_OPTION_BANKER = 9, //UNIT_NPC_FLAG_BANKER = 256, + GOSSIP_OPTION_PETITIONER = 10, //UNIT_NPC_FLAG_PETITIONER = 512, + GOSSIP_OPTION_TABARDDESIGNER = 11, //UNIT_NPC_FLAG_TABARDDESIGNER = 1024, + GOSSIP_OPTION_BATTLEFIELD = 12, //UNIT_NPC_FLAG_BATTLEFIELDPERSON = 2048, + GOSSIP_OPTION_AUCTIONEER = 13, //UNIT_NPC_FLAG_AUCTIONEER = 4096, + GOSSIP_OPTION_STABLEPET = 14, //UNIT_NPC_FLAG_STABLE = 8192, + GOSSIP_OPTION_ARMORER = 15, //UNIT_NPC_FLAG_ARMORER = 16384, + GOSSIP_OPTION_UNLEARNTALENTS = 16, //UNIT_NPC_FLAG_TRAINER (bonus option for GOSSIP_OPTION_TRAINER) + GOSSIP_OPTION_UNLEARNPETSKILLS = 17 //UNIT_NPC_FLAG_TRAINER (bonus option for GOSSIP_OPTION_TRAINER) +}; + +enum Gossip_Guard +{ + GOSSIP_GUARD_BANK = 32, + GOSSIP_GUARD_RIDE = 33, + GOSSIP_GUARD_GUILD = 34, + GOSSIP_GUARD_INN = 35, + GOSSIP_GUARD_MAIL = 36, + GOSSIP_GUARD_AUCTION = 37, + GOSSIP_GUARD_WEAPON = 38, + GOSSIP_GUARD_STABLE = 39, + GOSSIP_GUARD_BATTLE = 40, + GOSSIP_GUARD_SPELLTRAINER = 41, + GOSSIP_GUARD_SKILLTRAINER = 42 +}; + +enum Gossip_Guard_Spell +{ + GOSSIP_GUARD_SPELL_WARRIOR = 64, + GOSSIP_GUARD_SPELL_PALADIN = 65, + GOSSIP_GUARD_SPELL_HUNTER = 66, + GOSSIP_GUARD_SPELL_ROGUE = 67, + GOSSIP_GUARD_SPELL_PRIEST = 68, + GOSSIP_GUARD_SPELL_UNKNOWN1 = 69, + GOSSIP_GUARD_SPELL_SHAMAN = 70, + GOSSIP_GUARD_SPELL_MAGE = 71, + GOSSIP_GUARD_SPELL_WARLOCK = 72, + GOSSIP_GUARD_SPELL_UNKNOWN2 = 73, + GOSSIP_GUARD_SPELL_DRUID = 74 +}; + +enum Gossip_Guard_Skill +{ + GOSSIP_GUARD_SKILL_ALCHEMY = 80, + GOSSIP_GUARD_SKILL_BLACKSMITH = 81, + GOSSIP_GUARD_SKILL_COOKING = 82, + GOSSIP_GUARD_SKILL_ENCHANT = 83, + GOSSIP_GUARD_SKILL_FIRSTAID = 84, + GOSSIP_GUARD_SKILL_FISHING = 85, + GOSSIP_GUARD_SKILL_HERBALISM = 86, + GOSSIP_GUARD_SKILL_LEATHER = 87, + GOSSIP_GUARD_SKILL_MINING = 88, + GOSSIP_GUARD_SKILL_SKINNING = 89, + GOSSIP_GUARD_SKILL_TAILORING = 90, + GOSSIP_GUARD_SKILL_ENGINERING = 91 +}; + +struct GossipOption +{ + uint32 Id; + uint32 GossipId; + uint32 NpcFlag; + uint32 Icon; + uint32 Action; + std::string Option; +}; + +struct CreatureItem +{ + CreatureItem(uint32 _item, uint32 _maxcount, uint32 _incrtime, uint32 _ExtendedCost) + : id(_item), count(_maxcount), maxcount(_maxcount), incrtime(_incrtime), ExtendedCost(_ExtendedCost), lastincr((uint32)time(NULL)) {} + + uint32 id; + uint32 count; + uint32 maxcount; + uint32 incrtime; + uint32 lastincr; + uint32 ExtendedCost; +}; + +enum CreatureFlagsExtra +{ + CREATURE_FLAG_EXTRA_INSTANCE_BIND = 0x00000001, // creature kill bind instance with killer and killer's group + CREATURE_FLAG_EXTRA_CIVILIAN = 0x00000002, // not aggro (ignore faction/reputation hostility) + CREATURE_FLAG_EXTRA_NO_PARRY = 0x00000004, // creature can't parry + CREATURE_FLAG_EXTRA_NO_PARRY_HASTEN = 0x00000008, // creature can't counter-attack at parry + CREATURE_FLAG_EXTRA_NO_BLOCK = 0x00000010, // creature can't block + CREATURE_FLAG_EXTRA_NO_CRUSH = 0x00000020, // creature can't do crush attacks + CREATURE_FLAG_EXTRA_NO_XP_AT_KILL = 0x00000040, // creature kill not provide XP +}; + +// GCC have alternative #pragma pack(N) syntax and old gcc version not support pack(push,N), also any gcc version not support it at some platform +#if defined( __GNUC__ ) +#pragma pack(1) +#else +#pragma pack(push,1) +#endif + +// from `creature_template` table +struct CreatureInfo +{ + uint32 Entry; + uint32 HeroicEntry; + uint32 DisplayID_A; + uint32 DisplayID_A2; + uint32 DisplayID_H; + uint32 DisplayID_H2; + char* Name; + char* SubName; + char* IconName; + uint32 minlevel; + uint32 maxlevel; + uint32 minhealth; + uint32 maxhealth; + uint32 minmana; + uint32 maxmana; + uint32 armor; + uint32 faction_A; + uint32 faction_H; + uint32 npcflag; + float speed; + float scale; + uint32 rank; + float mindmg; + float maxdmg; + uint32 dmgschool; + uint32 attackpower; + uint32 baseattacktime; + uint32 rangeattacktime; + uint32 Flags; + uint32 dynamicflags; + uint32 family; + uint32 trainer_type; + uint32 trainer_spell; + uint32 classNum; + uint32 race; + float minrangedmg; + float maxrangedmg; + uint32 rangedattackpower; + uint32 type; + uint32 flag1; + uint32 lootid; + uint32 pickpocketLootId; + uint32 SkinLootId; + int32 resistance1; + int32 resistance2; + int32 resistance3; + int32 resistance4; + int32 resistance5; + int32 resistance6; + uint32 spell1; + uint32 spell2; + uint32 spell3; + uint32 spell4; + uint32 PetSpellDataId; + uint32 mingold; + uint32 maxgold; + char const* AIName; + uint32 MovementType; + uint32 InhabitType; + bool RacialLeader; + bool RegenHealth; + uint32 equipmentId; + uint32 MechanicImmuneMask; + uint32 flags_extra; + char const* ScriptName; +}; + +struct CreatureLocale +{ + std::vector Name; + std::vector SubName; +}; + +struct EquipmentInfo +{ + uint32 entry; + uint32 equipmodel[3]; + uint32 equipinfo[3]; + uint32 equipslot[3]; +}; + +// from `creature` table +struct CreatureData +{ + uint32 id; // entry in creature_template + uint16 mapid; + uint32 displayid; + int32 equipmentId; + float posX; + float posY; + float posZ; + float orientation; + uint32 spawntimesecs; + float spawndist; + uint32 currentwaypoint; + uint32 curhealth; + uint32 curmana; + bool is_dead; + uint8 movementType; + uint8 spawnMask; +}; + +struct CreatureDataAddonAura +{ + uint16 spell_id; + uint8 effect_idx; +}; + +// from `creature_addon` table +struct CreatureDataAddon +{ + uint32 guidOrEntry; + uint32 mount; + uint32 bytes0; + uint32 bytes1; + uint32 bytes2; + uint32 emote; + uint32 move_flags; + CreatureDataAddonAura const* auras; // loaded as char* "spell1 eff1 spell2 eff2 ... " +}; + +struct CreatureModelInfo +{ + uint32 modelid; + float bounding_radius; + float combat_reach; + uint8 gender; + uint32 modelid_other_gender; +}; + +enum InhabitTypeValues +{ + INHABIT_GROUND = 1, + INHABIT_WATER = 2, + INHABIT_AIR = 4, + INHABIT_ANYWHERE = INHABIT_GROUND | INHABIT_WATER | INHABIT_AIR +}; + +// GCC have alternative #pragma pack() syntax and old gcc version not support pack(pop), also any gcc version not support it at some platform +#if defined( __GNUC__ ) +#pragma pack() +#else +#pragma pack(pop) +#endif + +struct TrainerSpell +{ + uint32 spell; + uint32 spellcost; + uint32 reqskill; + uint32 reqskillvalue; + uint32 reqlevel; +}; + +typedef std::vector TrainerSpellList; + +struct TrainerSpellData +{ + TrainerSpellData() : trainerType(0) {} + + TrainerSpellList spellList; + uint32 trainerType; // trainer type based at trainer spells, can be different from creature_template value. + // req. for correct show non-prof. trainers like weaponmaster, allowed values 0 and 2. + + void Clear(); + TrainerSpell const* Find(uint32 spell_id) const; +}; + +typedef std::list GossipOptionList; + +typedef std::map CreatureSpellCooldowns; + +// max different by z coordinate for creature aggro reaction +#define CREATURE_Z_ATTACK_RANGE 3 + +#define MAX_VENDOR_ITEMS 255 // Limitation in item count field size in SMSG_LIST_INVENTORY + +class MANGOS_DLL_SPEC Creature : public Unit +{ + CreatureAI *i_AI; + + public: + + explicit Creature(); + virtual ~Creature(); + + void AddToWorld(); + void RemoveFromWorld(); + + bool Create (uint32 guidlow, Map *map, uint32 Entry, uint32 team, const CreatureData *data = NULL); + bool LoadCreaturesAddon(bool reload = false); + void SelectLevel(const CreatureInfo *cinfo); + void LoadEquipment(uint32 equip_entry, bool force=false); + + uint32 GetDBTableGUIDLow() const { return m_DBTableGuid; } + char const* GetSubName() const { return GetCreatureInfo()->SubName; } + + void Update( uint32 time ); // overwrited Unit::Update + void GetRespawnCoord(float &x, float &y, float &z, float* ori = NULL, float* dist =NULL) const; + uint32 GetEquipmentId() const { return m_equipmentId; } + + bool isPet() const { return m_isPet; } + void SetCorpseDelay(uint32 delay) { m_corpseDelay = delay; } + bool isTotem() const { return m_isTotem; } + bool isRacialLeader() const { return GetCreatureInfo()->RacialLeader; } + bool isCivilian() const { return GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_CIVILIAN; } + bool canWalk() const { return GetCreatureInfo()->InhabitType & INHABIT_GROUND; } + bool canSwim() const { return GetCreatureInfo()->InhabitType & INHABIT_WATER; } + bool canFly() const { return GetCreatureInfo()->InhabitType & INHABIT_AIR; } + ///// TODO RENAME THIS!!!!! + bool isCanTrainingOf(Player* player, bool msg) const; + bool isCanIneractWithBattleMaster(Player* player, bool msg) const; + bool isCanTrainingAndResetTalentsOf(Player* pPlayer) const; + bool IsOutOfThreatArea(Unit* pVictim) const; + bool IsImmunedToSpell(SpellEntry const* spellInfo, bool useCharges = false); + // redefine Unit::IsImmunedToSpell + bool IsImmunedToSpellEffect(uint32 effect, uint32 mechanic) const; + // redefine Unit::IsImmunedToSpellEffect + bool isElite() const + { + if(isPet()) + return false; + + uint32 rank = GetCreatureInfo()->rank; + return rank != CREATURE_ELITE_NORMAL && rank != CREATURE_ELITE_RARE; + } + + bool isWorldBoss() const + { + if(isPet()) + return false; + + return GetCreatureInfo()->rank == CREATURE_ELITE_WORLDBOSS; + } + + uint32 getLevelForTarget(Unit const* target) const; // overwrite Unit::getLevelForTarget for boss level support + + bool IsInEvadeMode() const; + + bool AIM_Initialize(); + + void AI_SendMoveToPacket(float x, float y, float z, uint32 time, uint32 MovementFlags, uint8 type); + CreatureAI* AI() { return i_AI; } + + uint32 GetShieldBlockValue() const //dunno mob block value + { + return (getLevel()/2 + uint32(GetStat(STAT_STRENGTH)/20)); + } + + SpellSchoolMask GetMeleeDamageSchoolMask() const { return m_meleeDamageSchoolMask; } + void SetMeleeDamageSchool(SpellSchools school) { m_meleeDamageSchoolMask = SpellSchoolMask(1 << school); } + + void _AddCreatureSpellCooldown(uint32 spell_id, time_t end_time); + void _AddCreatureCategoryCooldown(uint32 category, time_t apply_time); + void AddCreatureSpellCooldown(uint32 spellid); + bool HasSpellCooldown(uint32 spell_id) const; + bool HasCategoryCooldown(uint32 spell_id) const; + + bool HasSpell(uint32 spellID) const; + + bool UpdateEntry(uint32 entry, uint32 team=ALLIANCE, const CreatureData* data=NULL); + bool UpdateStats(Stats stat); + bool UpdateAllStats(); + void UpdateResistances(uint32 school); + void UpdateArmor(); + void UpdateMaxHealth(); + void UpdateMaxPower(Powers power); + void UpdateAttackPowerAndDamage(bool ranged = false); + void UpdateDamagePhysical(WeaponAttackType attType); + uint32 GetCurrentEquipmentId() { return m_equipmentId; } + float GetSpellDamageMod(int32 Rank); + + /*********************************************************/ + /*** VENDOR SYSTEM ***/ + /*********************************************************/ + void LoadGoods(); // must be called before access to vendor items, lazy loading at first call + void ReloadGoods() { m_itemsLoaded = false; LoadGoods(); } + + CreatureItem* GetItem(uint32 slot) + { + if(slot>=m_vendor_items.size()) return NULL; + return &m_vendor_items[slot]; + } + uint8 GetItemCount() const { return m_vendor_items.size(); } + void AddItem( uint32 item, uint32 maxcount, uint32 ptime, uint32 ExtendedCost) + { + m_vendor_items.push_back(CreatureItem(item, maxcount, ptime, ExtendedCost)); + } + bool RemoveItem( uint32 item_id ) + { + for(CreatureItems::iterator i = m_vendor_items.begin(); i != m_vendor_items.end(); ++i ) + { + if(i->id==item_id) + { + m_vendor_items.erase(i); + return true; + } + } + return false; + } + CreatureItem* FindItem(uint32 item_id) + { + for(CreatureItems::iterator i = m_vendor_items.begin(); i != m_vendor_items.end(); ++i ) + if(i->id==item_id) + return &*i; + return NULL; + } + + TrainerSpellData const* GetTrainerSpells() const; + + CreatureInfo const *GetCreatureInfo() const { return m_creatureInfo; } + CreatureDataAddon const* GetCreatureAddon() const; + char const* GetScriptName() const; + + void prepareGossipMenu( Player *pPlayer,uint32 gossipid ); + void sendPreparedGossip( Player* player); + void OnGossipSelect(Player* player, uint32 option); + void OnPoiSelect(Player* player, GossipOption const *gossip); + + uint32 GetGossipTextId(uint32 action, uint32 zoneid); + uint32 GetNpcTextId(); + void LoadGossipOptions(); + GossipOption const* GetGossipOption( uint32 id ) const; + void addGossipOption(GossipOption const& gso) { m_goptions.push_back(gso); } + + void setEmoteState(uint8 emote) { m_emoteState = emote; }; + void Say(const char* text, uint32 language, uint64 TargetGuid) { MonsterSay(text,language,TargetGuid); } + void Yell(const char* text, uint32 language, uint64 TargetGuid) { MonsterYell(text,language,TargetGuid); } + void TextEmote(const char* text, uint64 TargetGuid, bool IsBossEmote = false) { MonsterTextEmote(text,TargetGuid,IsBossEmote); } + void Whisper(const char* text, uint64 receiver, bool IsBossWhisper = false) { MonsterWhisper(text,receiver,IsBossWhisper); } + void Say(int32 textId, uint32 language, uint64 TargetGuid) { MonsterSay(textId,language,TargetGuid); } + void Yell(int32 textId, uint32 language, uint64 TargetGuid) { MonsterYell(textId,language,TargetGuid); } + void TextEmote(int32 textId, uint64 TargetGuid, bool IsBossEmote = false) { MonsterTextEmote(textId,TargetGuid,IsBossEmote); } + void Whisper(int32 textId, uint64 receiver, bool IsBossWhisper = false) { MonsterWhisper(textId,receiver,IsBossWhisper); } + + void setDeathState(DeathState s); // overwrite virtual Unit::setDeathState + + bool LoadFromDB(uint32 guid, Map *map); + void SaveToDB(); + // overwrited in Pet + virtual void SaveToDB(uint32 mapid, uint8 spawnMask); + virtual void DeleteFromDB(); // overwrited in Pet + + Loot loot; + bool lootForPickPocketed; + bool lootForBody; + Player *GetLootRecipient() const; + bool hasLootRecipient() const { return m_lootRecipient!=0; } + + void SetLootRecipient (Unit* unit); + void AllLootRemovedFromCorpse(); + + SpellEntry const *reachWithSpellAttack(Unit *pVictim); + SpellEntry const *reachWithSpellCure(Unit *pVictim); + + uint32 m_spells[CREATURE_MAX_SPELLS]; + CreatureSpellCooldowns m_CreatureSpellCooldowns; + CreatureSpellCooldowns m_CreatureCategoryCooldowns; + uint32 m_GlobalCooldown; + + float GetAttackDistance(Unit const* pl) const; + + void CallAssistence(); + void SetNoCallAssistence(bool val) { m_AlreadyCallAssistence = val; } + + MovementGeneratorType GetDefaultMovementType() const { return m_defaultMovementType; } + void SetDefaultMovementType(MovementGeneratorType mgt) { m_defaultMovementType = mgt; } + + // for use only in LoadHelper, Map::Add Map::CreatureCellRelocation + Cell const& GetCurrentCell() const { return m_currentCell; } + void SetCurrentCell(Cell const& cell) { m_currentCell = cell; } + + bool IsVisibleInGridForPlayer(Player* pl) const; + + void RemoveCorpse(); + + time_t const& GetRespawnTime() const { return m_respawnTime; } + time_t GetRespawnTimeEx() const; + void SetRespawnTime(uint32 respawn) { m_respawnTime = respawn ? time(NULL) + respawn : 0; } + void Respawn(); + void SaveRespawnTime(); + + uint32 GetRespawnDelay() const { return m_respawnDelay; } + void SetRespawnDelay(uint32 delay) { m_respawnDelay = delay; } + + float GetRespawnRadius() const { return m_respawnradius; } + void SetRespawnRadius(float dist) { m_respawnradius = dist; } + + uint32 m_groupLootTimer; // (msecs)timer used for group loot + uint64 lootingGroupLeaderGUID; // used to find group which is looting corpse + + void SendZoneUnderAttackMessage(Player* attacker); + + bool hasQuest(uint32 quest_id) const; + bool hasInvolvedQuest(uint32 quest_id) const; + + GridReference &GetGridRef() { return m_gridRef; } + bool isRegeneratingHealth() { return m_regenHealth; } + virtual uint8 GetPetAutoSpellSize() const { return CREATURE_MAX_SPELLS; } + virtual uint32 GetPetAutoSpellOnPos(uint8 pos) const + { + if (pos >= CREATURE_MAX_SPELLS || m_charmInfo->GetCharmSpell(pos)->active != ACT_ENABLED) + return 0; + else + return m_charmInfo->GetCharmSpell(pos)->spellId; + } + + void SetCombatStartPosition(float x, float y, float z) { CombatStartX = x; CombatStartY = y; CombatStartZ = z; } + void GetCombatStartPosition(float &x, float &y, float &z) { x = CombatStartX; y = CombatStartY; z = CombatStartZ; } + + protected: + bool CreateFromProto(uint32 guidlow,uint32 Entry,uint32 team, const CreatureData *data = NULL); + bool InitEntry(uint32 entry, uint32 team=ALLIANCE, const CreatureData* data=NULL); + + // vendor items + typedef std::vector CreatureItems; + CreatureItems m_vendor_items; + bool m_itemsLoaded; // vendor items loading state + + void _RealtimeSetCreatureInfo(); + + static float _GetHealthMod(int32 Rank); + static float _GetDamageMod(int32 Rank); + + uint32 m_lootMoney; + uint64 m_lootRecipient; + + /// Timers + uint32 m_deathTimer; // (msecs)timer for death or corpse disappearance + time_t m_respawnTime; // (secs) time of next respawn + uint32 m_respawnDelay; // (secs) delay between corpse disappearance and respawning + uint32 m_corpseDelay; // (secs) delay between death and corpse disappearance + float m_respawnradius; + + bool m_gossipOptionLoaded; + GossipOptionList m_goptions; + + uint8 m_emoteState; + bool m_isPet; // set only in Pet::Pet + bool m_isTotem; // set only in Totem::Totem + void RegenerateMana(); + void RegenerateHealth(); + uint32 m_regenTimer; + MovementGeneratorType m_defaultMovementType; + Cell m_currentCell; // store current cell where creature listed + uint32 m_DBTableGuid; + uint32 m_equipmentId; + + bool m_AlreadyCallAssistence; + bool m_regenHealth; + bool m_AI_locked; + bool m_isDeadByDefault; + + SpellSchoolMask m_meleeDamageSchoolMask; + uint32 m_originalEntry; + + float CombatStartX; + float CombatStartY; + float CombatStartZ; + private: + GridReference m_gridRef; + CreatureInfo const* m_creatureInfo; // in heroic mode can different from ObjMgr::GetCreatureTemplate(GetEntry()) +}; +#endif diff --git a/src/game/CreatureAISelector.cpp b/src/game/CreatureAISelector.cpp index 2e8b6f1a230..a113a3f1c7e 100644 --- a/src/game/CreatureAISelector.cpp +++ b/src/game/CreatureAISelector.cpp @@ -1,120 +1,118 @@ -/* - * Copyright (C) 2005-2008 MaNGOS - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "Creature.h" -#include "CreatureAIImpl.h" -#include "CreatureAISelector.h" -#include "NullCreatureAI.h" -#include "Policies/SingletonImp.h" -#include "MovementGenerator.h" -#include "ScriptCalls.h" -#include "Pet.h" - -INSTANTIATE_SINGLETON_1(CreatureAIRegistry); -INSTANTIATE_SINGLETON_1(MovementGeneratorRegistry); - -namespace FactorySelector -{ - CreatureAI* selectAI(Creature *creature) - { - // Allow scripting AI for normal creatures and not controlled pets (guardians and mini-pets) - if((!creature->isPet() || !((Pet*)creature)->isControlled()) && !creature->isCharmed()) - if(CreatureAI* scriptedAI = Script->GetAI(creature)) - return scriptedAI; - - CreatureAIRegistry &ai_registry(CreatureAIRepository::Instance()); - assert( creature->GetCreatureInfo() != NULL ); - CreatureInfo const *cinfo=creature->GetCreatureInfo(); - - const CreatureAICreator *ai_factory = NULL; - - std::string ainame=cinfo->AIName; - - // select by script name - if( !ainame.empty()) - ai_factory = ai_registry.GetRegistryItem( ainame.c_str() ); - - // select by NPC flags - if(!ai_factory) - { - if( creature->isGuard() ) - ainame="GuardAI"; - else if(creature->isPet() || creature->isCharmed()) - ainame="PetAI"; - else if(creature->isTotem()) - ainame="TotemAI"; - - ai_factory = ai_registry.GetRegistryItem( ainame.c_str() ); - } - - // select by permit check - if(!ai_factory) - { - int best_val = -1; - typedef CreatureAIRegistry::RegistryMapType RMT; - RMT const &l = ai_registry.GetRegisteredItems(); - for( RMT::const_iterator iter = l.begin(); iter != l.end(); ++iter) - { - const CreatureAICreator *factory = iter->second; - const SelectableAI *p = dynamic_cast(factory); - assert( p != NULL ); - int val = p->Permit(creature); - if( val > best_val ) - { - best_val = val; - ai_factory = p; - } - } - } - - // select NullCreatureAI if not another cases - ainame = (ai_factory == NULL) ? "NullCreatureAI" : ai_factory->key(); - - DEBUG_LOG("Creature %u used AI is %s.", creature->GetGUIDLow(), ainame.c_str() ); - return ( ai_factory == NULL ? new NullCreatureAI : ai_factory->Create(creature) ); - } - - MovementGenerator* selectMovementGenerator(Creature *creature) - { - MovementGeneratorRegistry &mv_registry(MovementGeneratorRepository::Instance()); - assert( creature->GetCreatureInfo() != NULL ); - const MovementGeneratorCreator *mv_factory = mv_registry.GetRegistryItem( creature->GetDefaultMovementType()); - - /* if( mv_factory == NULL ) - { - int best_val = -1; - std::vector l; - mv_registry.GetRegisteredItems(l); - for( std::vector::iterator iter = l.begin(); iter != l.end(); ++iter) - { - const MovementGeneratorCreator *factory = mv_registry.GetRegistryItem((*iter).c_str()); - const SelectableMovement *p = dynamic_cast(factory); - assert( p != NULL ); - int val = p->Permit(creature); - if( val > best_val ) - { - best_val = val; - mv_factory = p; - } - } - }*/ - - return ( mv_factory == NULL ? NULL : mv_factory->Create(creature) ); - - } -} +/* + * Copyright (C) 2005-2008 MaNGOS + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "Creature.h" +#include "CreatureAIImpl.h" +#include "CreatureAISelector.h" +#include "NullCreatureAI.h" +#include "Policies/SingletonImp.h" +#include "MovementGenerator.h" +#include "ScriptCalls.h" +#include "Pet.h" + +INSTANTIATE_SINGLETON_1(CreatureAIRegistry); +INSTANTIATE_SINGLETON_1(MovementGeneratorRegistry); + +namespace FactorySelector +{ + CreatureAI* selectAI(Creature *creature) + { + // Allow scripting AI for normal creatures and not controlled pets (guardians and mini-pets) + if((!creature->isPet() || !((Pet*)creature)->isControlled()) && !creature->isCharmed()) + if(CreatureAI* scriptedAI = Script->GetAI(creature)) + return scriptedAI; + + CreatureAIRegistry &ai_registry(CreatureAIRepository::Instance()); + assert( creature->GetCreatureInfo() != NULL ); + CreatureInfo const *cinfo=creature->GetCreatureInfo(); + + const CreatureAICreator *ai_factory = NULL; + + std::string ainame=cinfo->AIName; + + // select by script name + if( !ainame.empty()) + ai_factory = ai_registry.GetRegistryItem( ainame.c_str() ); + + // select by NPC flags + if(!ai_factory) + { + if( creature->isGuard() ) + ai_factory = ai_registry.GetRegistryItem("GuardAI"); + else if(creature->isPet() || creature->isCharmed()) + ai_factory = ai_registry.GetRegistryItem("PetAI"); + else if(creature->isTotem()) + ai_factory = ai_registry.GetRegistryItem("TotemAI"); + } + + // select by permit check + if(!ai_factory) + { + int best_val = -1; + typedef CreatureAIRegistry::RegistryMapType RMT; + RMT const &l = ai_registry.GetRegisteredItems(); + for( RMT::const_iterator iter = l.begin(); iter != l.end(); ++iter) + { + const CreatureAICreator *factory = iter->second; + const SelectableAI *p = dynamic_cast(factory); + assert( p != NULL ); + int val = p->Permit(creature); + if( val > best_val ) + { + best_val = val; + ai_factory = p; + } + } + } + + // select NullCreatureAI if not another cases + ainame = (ai_factory == NULL) ? "NullCreatureAI" : ai_factory->key(); + + DEBUG_LOG("Creature %u used AI is %s.", creature->GetGUIDLow(), ainame.c_str() ); + return ( ai_factory == NULL ? new NullCreatureAI : ai_factory->Create(creature) ); + } + + MovementGenerator* selectMovementGenerator(Creature *creature) + { + MovementGeneratorRegistry &mv_registry(MovementGeneratorRepository::Instance()); + assert( creature->GetCreatureInfo() != NULL ); + const MovementGeneratorCreator *mv_factory = mv_registry.GetRegistryItem( creature->GetDefaultMovementType()); + + /* if( mv_factory == NULL ) + { + int best_val = -1; + std::vector l; + mv_registry.GetRegisteredItems(l); + for( std::vector::iterator iter = l.begin(); iter != l.end(); ++iter) + { + const MovementGeneratorCreator *factory = mv_registry.GetRegistryItem((*iter).c_str()); + const SelectableMovement *p = dynamic_cast(factory); + assert( p != NULL ); + int val = p->Permit(creature); + if( val > best_val ) + { + best_val = val; + mv_factory = p; + } + } + }*/ + + return ( mv_factory == NULL ? NULL : mv_factory->Create(creature) ); + + } +} diff --git a/src/game/GossipDef.cpp b/src/game/GossipDef.cpp index 57c3597a7b8..08f35c8618b 100644 --- a/src/game/GossipDef.cpp +++ b/src/game/GossipDef.cpp @@ -1,765 +1,762 @@ -/* - * Copyright (C) 2005-2008 MaNGOS - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "QuestDef.h" -#include "GossipDef.h" -#include "ObjectMgr.h" -#include "Opcodes.h" -#include "WorldPacket.h" -#include "WorldSession.h" - -GossipMenu::GossipMenu() -{ - m_gItems.reserve(16); // can be set for max from most often sizes to speedup push_back and less memory use -} - -GossipMenu::~GossipMenu() -{ - ClearMenu(); -} - -void GossipMenu::AddMenuItem(uint8 Icon, std::string Message, uint32 dtSender, uint32 dtAction, std::string BoxMessage, uint32 BoxMoney, bool Coded) -{ - ASSERT( m_gItems.size() <= GOSSIP_MAX_MENU_ITEMS ); - - GossipMenuItem gItem; - - gItem.m_gIcon = Icon; - gItem.m_gMessage = Message; - gItem.m_gCoded = Coded; - gItem.m_gSender = dtSender; - gItem.m_gAction = dtAction; - gItem.m_gBoxMessage = BoxMessage; - gItem.m_gBoxMoney = BoxMoney; - - m_gItems.push_back(gItem); -} - -void GossipMenu::AddMenuItem(uint8 Icon, std::string Message, bool Coded) -{ - AddMenuItem( Icon, Message, 0, 0, "", 0, Coded); -} - -void GossipMenu::AddMenuItem(uint8 Icon, char const* Message, bool Coded) -{ - AddMenuItem(Icon, std::string(Message ? Message : ""),Coded); -} - -void GossipMenu::AddMenuItem(uint8 Icon, char const* Message, uint32 dtSender, uint32 dtAction, char const* BoxMessage, uint32 BoxMoney, bool Coded) -{ - AddMenuItem(Icon, std::string(Message ? Message : ""), dtSender, dtAction, std::string(BoxMessage ? BoxMessage : ""), BoxMoney, Coded); -} - -uint32 GossipMenu::MenuItemSender( unsigned int ItemId ) -{ - if ( ItemId >= m_gItems.size() ) return 0; - - return m_gItems[ ItemId ].m_gSender; -} - -uint32 GossipMenu::MenuItemAction( unsigned int ItemId ) -{ - if ( ItemId >= m_gItems.size() ) return 0; - - return m_gItems[ ItemId ].m_gAction; -} - -bool GossipMenu::MenuItemCoded( unsigned int ItemId ) -{ - if ( ItemId >= m_gItems.size() ) return 0; - - return m_gItems[ ItemId ].m_gCoded; -} - -void GossipMenu::ClearMenu() -{ - m_gItems.clear(); -} - -PlayerMenu::PlayerMenu( WorldSession *Session ) -{ - pGossipMenu = new GossipMenu(); - pQuestMenu = new QuestMenu(); - pSession = Session; -} - -PlayerMenu::~PlayerMenu() -{ - delete pGossipMenu; - delete pQuestMenu; -} - -void PlayerMenu::ClearMenus() -{ - pGossipMenu->ClearMenu(); - pQuestMenu->ClearMenu(); -} - -uint32 PlayerMenu::GossipOptionSender( unsigned int Selection ) -{ - return pGossipMenu->MenuItemSender( Selection ); -} - -uint32 PlayerMenu::GossipOptionAction( unsigned int Selection ) -{ - return pGossipMenu->MenuItemAction( Selection ); -} - -bool PlayerMenu::GossipOptionCoded( unsigned int Selection ) -{ - return pGossipMenu->MenuItemCoded( Selection ); -} - -void PlayerMenu::SendGossipMenu( uint32 TitleTextId, uint64 npcGUID ) -{ - WorldPacket data( SMSG_GOSSIP_MESSAGE, (100) ); // guess size - data << npcGUID; - data << uint32(0); // new 2.4.0 - data << uint32( TitleTextId ); - data << uint32( pGossipMenu->MenuItemCount() ); // max count 0x0F - - for ( unsigned int iI = 0; iI < pGossipMenu->MenuItemCount(); iI++ ) - { - GossipMenuItem const& gItem = pGossipMenu->GetItem(iI); - data << uint32( iI ); - data << uint8( gItem.m_gIcon ); - // icons: - // 0 unlearn talents/misc - // 1 trader - // 2 taxi - // 3 trainer - // 9 BG/arena - data << uint8( gItem.m_gCoded ); // makes pop up box password - data << uint32(gItem.m_gBoxMoney); // money required to open menu, 2.0.3 - data << gItem.m_gMessage; // text for gossip item - data << gItem.m_gBoxMessage; // accept text (related to money) pop up box, 2.0.3 - } - - data << uint32( pQuestMenu->MenuItemCount() ); // max count 0x20 - - for ( uint16 iI = 0; iI < pQuestMenu->MenuItemCount(); iI++ ) - { - QuestMenuItem const& qItem = pQuestMenu->GetItem(iI); - uint32 questID = qItem.m_qId; - Quest const* pQuest = objmgr.GetQuestTemplate(questID); - - data << questID; - data << uint32( qItem.m_qIcon ); - data << uint32( pQuest ? pQuest->GetQuestLevel() : 0 ); - std::string Title = pQuest->GetTitle(); - - int loc_idx = pSession->GetSessionDbLocaleIndex(); - if (loc_idx >= 0) - { - QuestLocale const *ql = objmgr.GetQuestLocale(questID); - if (ql) - { - if (ql->Title.size() > loc_idx && !ql->Title[loc_idx].empty()) - Title=ql->Title[loc_idx]; - } - } - data << Title; - } - - pSession->SendPacket( &data ); - //sLog.outDebug( "WORLD: Sent SMSG_GOSSIP_MESSAGE NPCGuid=%u",GUID_LOPART(npcGUID) ); -} - -void PlayerMenu::CloseGossip() -{ - WorldPacket data( SMSG_GOSSIP_COMPLETE, 0 ); - pSession->SendPacket( &data ); - - //sLog.outDebug( "WORLD: Sent SMSG_GOSSIP_COMPLETE" ); -} - -void PlayerMenu::SendPointOfInterest( float X, float Y, uint32 Icon, uint32 Flags, uint32 Data, char const * locName ) -{ - WorldPacket data( SMSG_GOSSIP_POI, (4+4+4+4+4+10) ); // guess size - data << Flags; - data << X << Y; - data << uint32(Icon); - data << uint32(Data); - data << locName; - - pSession->SendPacket( &data ); - //sLog.outDebug("WORLD: Sent SMSG_GOSSIP_POI"); -} - -void PlayerMenu::SendTalking( uint32 textID ) -{ - GossipText *pGossip; - std::string GossipStr; - - pGossip = objmgr.GetGossipText(textID); - - WorldPacket data( SMSG_NPC_TEXT_UPDATE, 100 ); // guess size - data << textID; // can be < 0 - - if (!pGossip) - { - for(uint32 i = 0; i < 8; ++i) - { - data << float(0); - data << "Greetings $N"; - data << "Greetings $N"; - data << uint32(0); - data << uint32(0); - data << uint32(0); - data << uint32(0); - data << uint32(0); - data << uint32(0); - data << uint32(0); - } - } - else - { - std::string Text_0[8],Text_1[8]; - for (int i=0;i<8;i++) - { - Text_0[i]=pGossip->Options[i].Text_0; - Text_1[i]=pGossip->Options[i].Text_1; - } - int loc_idx = pSession->GetSessionDbLocaleIndex(); - if (loc_idx >= 0) - { - NpcTextLocale const *nl = objmgr.GetNpcTextLocale(textID); - if (nl) - { - for (int i=0;i<8;i++) - { - if (nl->Text_0[i].size() > loc_idx && !nl->Text_0[i][loc_idx].empty()) - Text_0[i]=nl->Text_0[i][loc_idx]; - if (nl->Text_1[i].size() > loc_idx && !nl->Text_1[i][loc_idx].empty()) - Text_1[i]=nl->Text_1[i][loc_idx]; - } - } - } - for (int i=0; i<8; i++) - { - data << pGossip->Options[i].Probability; - - if ( Text_0[i].empty() ) - data << Text_1[i]; - else - data << Text_0[i]; - - if ( Text_1[i].empty() ) - data << Text_0[i]; - else - data << Text_1[i]; - - data << pGossip->Options[i].Language; - - data << pGossip->Options[i].Emotes[0]._Delay; - data << pGossip->Options[i].Emotes[0]._Emote; - - data << pGossip->Options[i].Emotes[1]._Delay; - data << pGossip->Options[i].Emotes[1]._Emote; - - data << pGossip->Options[i].Emotes[2]._Delay; - data << pGossip->Options[i].Emotes[2]._Emote; - } - } - pSession->SendPacket( &data ); - - sLog.outDebug( "WORLD: Sent SMSG_NPC_TEXT_UPDATE " ); -} - -void PlayerMenu::SendTalking( char const * title, char const * text ) -{ - WorldPacket data( SMSG_NPC_TEXT_UPDATE, 50 ); // guess size - data << uint32(0); - for(uint32 i = 0; i < 8; ++i) - { - data << float(0); - data << title; - data << text; - data << uint32(0); - data << uint32(0); - data << uint32(0); - data << uint32(0); - data << uint32(0); - data << uint32(0); - data << uint32(0); - } - - pSession->SendPacket( &data ); - - sLog.outDebug( "WORLD: Sent SMSG_NPC_TEXT_UPDATE " ); -} - -/*********************************************************/ -/*** QUEST SYSTEM ***/ -/*********************************************************/ - -QuestMenu::QuestMenu() -{ - m_qItems.reserve(16); // can be set for max from most often sizes to speedup push_back and less memory use -} - -QuestMenu::~QuestMenu() -{ - ClearMenu(); -} - -void QuestMenu::AddMenuItem( uint32 QuestId, uint8 Icon) -{ - Quest const* qinfo = objmgr.GetQuestTemplate(QuestId); - if (!qinfo) return; - - ASSERT( m_qItems.size() <= GOSSIP_MAX_MENU_ITEMS ); - - QuestMenuItem qItem; - - qItem.m_qId = QuestId; - qItem.m_qIcon = Icon; - - m_qItems.push_back(qItem); -} - -bool QuestMenu::HasItem( uint32 questid ) -{ - for (QuestMenuItemList::iterator i = m_qItems.begin(); i != m_qItems.end(); i++) - { - if(i->m_qId==questid) - { - return true; - } - } - return false; -} - -void QuestMenu::ClearMenu() -{ - m_qItems.clear(); -} - -void PlayerMenu::SendQuestGiverQuestList( QEmote eEmote, std::string Title, uint64 npcGUID ) -{ - WorldPacket data( SMSG_QUESTGIVER_QUEST_LIST, 100 ); // guess size - data << uint64(npcGUID); - data << Title; - data << uint32(eEmote._Delay ); // player emote - data << uint32(eEmote._Emote ); // NPC emote - data << uint8 ( pQuestMenu->MenuItemCount() ); - - for ( uint16 iI = 0; iI < pQuestMenu->MenuItemCount(); iI++ ) - { - QuestMenuItem qmi=pQuestMenu->GetItem(iI); - uint32 questID = qmi.m_qId; - Quest const *pQuest = objmgr.GetQuestTemplate(questID); - - std::string title = pQuest ? pQuest->GetTitle() : ""; - - int loc_idx = pSession->GetSessionDbLocaleIndex(); - if (loc_idx >= 0) - { - if(QuestLocale const *ql = objmgr.GetQuestLocale(questID)) - { - if (ql->Title.size() > loc_idx && !ql->Title[loc_idx].empty()) - title=ql->Title[loc_idx]; - } - } - - data << uint32(questID); - data << uint32(qmi.m_qIcon); - data << uint32(pQuest ? pQuest->GetQuestLevel() : 0); - data << title; - } - pSession->SendPacket( &data ); - //uint32 fqid=pQuestMenu->GetItem(0).m_qId; - //sLog.outDebug( "WORLD: Sent SMSG_QUESTGIVER_QUEST_LIST NPC Guid=%u, questid-0=%u",npcGUID,fqid); -} - -void PlayerMenu::SendQuestGiverStatus( uint8 questStatus, uint64 npcGUID ) -{ - WorldPacket data( SMSG_QUESTGIVER_STATUS, 9 ); - data << uint64(npcGUID); - data << uint8(questStatus); - - pSession->SendPacket( &data ); - //sLog.outDebug( "WORLD: Sent SMSG_QUESTGIVER_STATUS NPC Guid=%u, status=%u",GUID_LOPART(npcGUID),questStatus); -} - -void PlayerMenu::SendQuestGiverQuestDetails( Quest const *pQuest, uint64 npcGUID, bool ActivateAccept ) -{ - WorldPacket data(SMSG_QUESTGIVER_QUEST_DETAILS, 100); // guess size - - std::string Title = pQuest->GetTitle(); - std::string Details = pQuest->GetDetails(); - std::string Objectives = pQuest->GetObjectives(); - std::string EndText = pQuest->GetEndText(); - - int loc_idx = pSession->GetSessionDbLocaleIndex(); - if (loc_idx >= 0) - { - QuestLocale const *ql = objmgr.GetQuestLocale(pQuest->GetQuestId()); - if (ql) - { - if (ql->Title.size() > loc_idx && !ql->Title[loc_idx].empty()) - Title=ql->Title[loc_idx]; - if (ql->Details.size() > loc_idx && !ql->Details[loc_idx].empty()) - Details=ql->Details[loc_idx]; - if (ql->Objectives.size() > loc_idx && !ql->Objectives[loc_idx].empty()) - Objectives=ql->Objectives[loc_idx]; - if (ql->EndText.size() > loc_idx && !ql->EndText[loc_idx].empty()) - EndText=ql->EndText[loc_idx]; - } - } - - data << uint64(npcGUID); - data << uint32(pQuest->GetQuestId()); - data << Title << Details << Objectives; - data << uint32(ActivateAccept); - data << uint32(pQuest->GetSuggestedPlayers()); - - if (pQuest->HasFlag(QUEST_FLAGS_HIDDEN_REWARDS)) - { - data << uint32(0); // Rewarded chosen items hidden - data << uint32(0); // Rewarded items hidden - data << uint32(0); // Rewarded money hidden - } - else - { - ItemPrototype const* IProto; - - data << uint32(pQuest->GetRewChoiceItemsCount()); - for (uint32 i=0; i < QUEST_REWARD_CHOICES_COUNT; i++) - { - if ( !pQuest->RewChoiceItemId[i] ) continue; - data << uint32(pQuest->RewChoiceItemId[i]); - data << uint32(pQuest->RewChoiceItemCount[i]); - IProto = objmgr.GetItemPrototype(pQuest->RewChoiceItemId[i]); - if ( IProto ) - data << uint32(IProto->DisplayInfoID); - else - data << uint32( 0x00 ); - } - - data << uint32(pQuest->GetRewItemsCount()); - for (uint32 i=0; i < QUEST_REWARDS_COUNT; i++) - { - if ( !pQuest->RewItemId[i] ) continue; - data << uint32(pQuest->RewItemId[i]); - data << uint32(pQuest->RewItemCount[i]); - IProto = objmgr.GetItemPrototype(pQuest->RewItemId[i]); - if ( IProto ) - data << uint32(IProto->DisplayInfoID); - else - data << uint32(0); - } - data << uint32(pQuest->GetRewOrReqMoney()); - } - - data << uint32(0); // Honor points reward, not implemented - data << uint32(pQuest->GetRewSpell()); // reward spell, this spell will display (icon) (casted if RewSpellCast==0) - data << uint32(pQuest->GetRewSpellCast()); // casted spell - data << uint32(pQuest->GetCharTitleId()); // CharTitleId, new 2.4.0, player gets this title (id from CharTitles) - - data << uint32(QUEST_EMOTE_COUNT); - for (uint32 i=0; i < QUEST_EMOTE_COUNT; i++) - { - data << uint32(pQuest->DetailsEmote[i]); - data << uint32(0); // DetailsEmoteDelay - } - pSession->SendPacket( &data ); - - //sLog.outDebug("WORLD: Sent SMSG_QUESTGIVER_QUEST_DETAILS NPCGuid=%u, questid=%u",GUID_LOPART(npcGUID),pQuest->GetQuestId()); -} - -void PlayerMenu::SendQuestQueryResponse( Quest const *pQuest ) -{ - std::string Title,Details,Objectives,EndText; - std::string ObjectiveText[QUEST_OBJECTIVES_COUNT]; - Title = pQuest->GetTitle(); - Details = pQuest->GetDetails(); - Objectives = pQuest->GetObjectives(); - EndText = pQuest->GetEndText(); - for (int i=0;iObjectiveText[i]; - - int loc_idx = pSession->GetSessionDbLocaleIndex(); - if (loc_idx >= 0) - { - QuestLocale const *ql = objmgr.GetQuestLocale(pQuest->GetQuestId()); - if (ql) - { - if (ql->Title.size() > loc_idx && !ql->Title[loc_idx].empty()) - Title=ql->Title[loc_idx]; - if (ql->Details.size() > loc_idx && !ql->Details[loc_idx].empty()) - Details=ql->Details[loc_idx]; - if (ql->Objectives.size() > loc_idx && !ql->Objectives[loc_idx].empty()) - Objectives=ql->Objectives[loc_idx]; - if (ql->EndText.size() > loc_idx && !ql->EndText[loc_idx].empty()) - EndText=ql->EndText[loc_idx]; - - for (int i=0;iObjectiveText[i].size() > loc_idx && !ql->ObjectiveText[i][loc_idx].empty()) - ObjectiveText[i]=ql->ObjectiveText[i][loc_idx]; - } - } - - WorldPacket data( SMSG_QUEST_QUERY_RESPONSE, 100 ); // guess size - - data << uint32(pQuest->GetQuestId()); - data << uint32(pQuest->GetMinLevel()); // not MinLevel. Accepted values: 0, 1 or 2 Possible theory for future dev: 0==cannot in quest log, 1==can in quest log session only(removed on log out), 2==can in quest log always (save to db) - data << uint32(pQuest->GetQuestLevel()); // may be 0 - data << uint32(pQuest->GetZoneOrSort()); // zone or sort to display in quest log - - data << uint32(pQuest->GetType()); - data << uint32(pQuest->GetSuggestedPlayers()); - - data << uint32(pQuest->GetRepObjectiveFaction()); // shown in quest log as part of quest objective - data << uint32(pQuest->GetRepObjectiveValue()); // shown in quest log as part of quest objective - - data << uint32(0); // RequiredOpositeRepFaction - data << uint32(0); // RequiredOpositeRepValue, required faction value with another (oposite) faction (objective) - - data << uint32(pQuest->GetNextQuestInChain()); // client will request this quest from NPC, if not 0 - - if (pQuest->HasFlag(QUEST_FLAGS_HIDDEN_REWARDS)) - data << uint32(0); // Hide money rewarded - else - data << uint32(pQuest->GetRewOrReqMoney()); - - data << uint32(pQuest->GetRewMoneyMaxLevel()); // used in XP calculation at client - data << uint32(pQuest->GetRewSpell()); // reward spell, this spell will display (icon) (casted if RewSpellCast==0) - data << uint32(pQuest->GetRewSpellCast()); // casted spell - - data << uint32(0); // Honor points reward, not implemented - data << uint32(pQuest->GetSrcItemId()); - data << uint32(pQuest->GetFlags() & 0xFFFF); - data << uint32(pQuest->GetCharTitleId()); // CharTitleId, new 2.4.0, player gets this title (id from CharTitles) - - int iI; - - if (pQuest->HasFlag(QUEST_FLAGS_HIDDEN_REWARDS)) - { - for (iI = 0; iI < QUEST_REWARDS_COUNT; iI++) - data << uint32(0) << uint32(0); - for (iI = 0; iI < QUEST_REWARD_CHOICES_COUNT; iI++) - data << uint32(0) << uint32(0); - } - else - { - for (iI = 0; iI < QUEST_REWARDS_COUNT; iI++) - { - data << uint32(pQuest->RewItemId[iI]); - data << uint32(pQuest->RewItemCount[iI]); - } - for (iI = 0; iI < QUEST_REWARD_CHOICES_COUNT; iI++) - { - data << uint32(pQuest->RewChoiceItemId[iI]); - data << uint32(pQuest->RewChoiceItemCount[iI]); - } - } - - data << pQuest->GetPointMapId(); - data << pQuest->GetPointX(); - data << pQuest->GetPointY(); - data << pQuest->GetPointOpt(); - - data << Title; - data << Objectives; - data << Details; - data << EndText; - - for (iI = 0; iI < QUEST_OBJECTIVES_COUNT; iI++) - { - if (pQuest->ReqCreatureOrGOId[iI] < 0) - { - // client expected gameobject template id in form (id|0x80000000) - data << uint32((pQuest->ReqCreatureOrGOId[iI]*(-1))|0x80000000); - } - else - { - data << uint32(pQuest->ReqCreatureOrGOId[iI]); - } - data << uint32(pQuest->ReqCreatureOrGOCount[iI]); - data << uint32(pQuest->ReqItemId[iI]); - data << uint32(pQuest->ReqItemCount[iI]); - } - - for (iI = 0; iI < QUEST_OBJECTIVES_COUNT; iI++) - data << ObjectiveText[iI]; - - pSession->SendPacket( &data ); - //sLog.outDebug( "WORLD: Sent SMSG_QUEST_QUERY_RESPONSE questid=%u",pQuest->GetQuestId() ); -} - -void PlayerMenu::SendQuestGiverOfferReward( Quest const* pQuest, uint64 npcGUID, bool EnbleNext ) -{ - std::string Title = pQuest->GetTitle(); - std::string OfferRewardText = pQuest->GetOfferRewardText(); - - int loc_idx = pSession->GetSessionDbLocaleIndex(); - if (loc_idx >= 0) - { - QuestLocale const *ql = objmgr.GetQuestLocale(pQuest->GetQuestId()); - if (ql) - { - if (ql->Title.size() > loc_idx && !ql->Title[loc_idx].empty()) - Title=ql->Title[loc_idx]; - if (ql->OfferRewardText.size() > loc_idx && !ql->OfferRewardText[loc_idx].empty()) - OfferRewardText=ql->OfferRewardText[loc_idx]; - } - } - - WorldPacket data( SMSG_QUESTGIVER_OFFER_REWARD, 50 ); // guess size - - data << npcGUID; - data << pQuest->GetQuestId(); - data << Title; - data << OfferRewardText; - - data << uint32( EnbleNext ); - data << uint32(0); // unk - - uint32 EmoteCount = 0; - for (uint32 i = 0; i < QUEST_EMOTE_COUNT; i++) - { - if(pQuest->OfferRewardEmote[i] <= 0) - break; - ++EmoteCount; - } - - data << EmoteCount; // Emote Count - for (uint32 i = 0; i < EmoteCount; i++) - { - data << uint32(0); // Delay Emote - data << pQuest->OfferRewardEmote[i]; - } - - ItemPrototype const *pItem; - - data << uint32(pQuest->GetRewChoiceItemsCount()); - for (uint32 i=0; i < pQuest->GetRewChoiceItemsCount(); i++) - { - pItem = objmgr.GetItemPrototype( pQuest->RewChoiceItemId[i] ); - - data << uint32(pQuest->RewChoiceItemId[i]); - data << uint32(pQuest->RewChoiceItemCount[i]); - - if ( pItem ) - data << uint32(pItem->DisplayInfoID); - else - data << uint32(0); - } - - data << uint32(pQuest->GetRewItemsCount()); - for (uint16 i=0; i < pQuest->GetRewItemsCount(); i++) - { - pItem = objmgr.GetItemPrototype(pQuest->RewItemId[i]); - data << uint32(pQuest->RewItemId[i]); - data << uint32(pQuest->RewItemCount[i]); - - if ( pItem ) - data << uint32(pItem->DisplayInfoID); - else - data << uint32(0); - } - - data << uint32(pQuest->GetRewOrReqMoney()); - data << uint32(0x00); // new 2.3.0. Honor points - data << uint32(0x08); // unused by client? - data << uint32(pQuest->GetRewSpell()); // reward spell, this spell will display (icon) (casted if RewSpellCast==0) - data << uint32(pQuest->GetRewSpellCast()); // casted spell - data << uint32(0); // Honor points reward, not implemented - pSession->SendPacket( &data ); - //sLog.outDebug( "WORLD: Sent SMSG_QUESTGIVER_OFFER_REWARD NPCGuid=%u, questid=%u",GUID_LOPART(npcGUID),pQuest->GetQuestId() ); -} - -void PlayerMenu::SendQuestGiverRequestItems( Quest const *pQuest, uint64 npcGUID, bool Completable, bool CloseOnCancel ) -{ - // We can always call to RequestItems, but this packet only goes out if there are actually - // items. Otherwise, we'll skip straight to the OfferReward - - // We may wish a better check, perhaps checking the real quest requirements - if (pQuest->GetRequestItemsText().empty()) - { - SendQuestGiverOfferReward(pQuest, npcGUID, true); - return; - } - - std::string Title,RequestItemsText; - Title = pQuest->GetTitle(); - RequestItemsText = pQuest->GetRequestItemsText(); - - int loc_idx = pSession->GetSessionDbLocaleIndex(); - if (loc_idx >= 0) - { - QuestLocale const *ql = objmgr.GetQuestLocale(pQuest->GetQuestId()); - if (ql) - { - if (ql->Title.size() > loc_idx && !ql->Title[loc_idx].empty()) - Title=ql->Title[loc_idx]; - if (ql->RequestItemsText.size() > loc_idx && !ql->RequestItemsText[loc_idx].empty()) - RequestItemsText=ql->RequestItemsText[loc_idx]; - } - } - - WorldPacket data( SMSG_QUESTGIVER_REQUEST_ITEMS, 50 ); // guess size - data << npcGUID; - data << pQuest->GetQuestId(); - data << Title; - data << RequestItemsText; - - data << uint32(0x00); // unknown - - if(Completable) - data << pQuest->GetCompleteEmote(); - else - data << pQuest->GetIncompleteEmote(); - - // Close Window after cancel - if (CloseOnCancel) - data << uint32(0x01); - else - data << uint32(0x00); - - data << uint32(0x00); // unknown - - // Required Money - data << uint32(pQuest->GetRewOrReqMoney() < 0 ? -pQuest->GetRewOrReqMoney() : 0); - - data << uint32( pQuest->GetReqItemsCount() ); - ItemPrototype const *pItem; - for (int i = 0; i < QUEST_OBJECTIVES_COUNT; i++) - { - if ( !pQuest->ReqItemId[i] ) continue; - pItem = objmgr.GetItemPrototype(pQuest->ReqItemId[i]); - data << uint32(pQuest->ReqItemId[i]); - data << uint32(pQuest->ReqItemCount[i]); - - if ( pItem ) - data << uint32(pItem->DisplayInfoID); - else - data << uint32(0); - } - - if ( !Completable ) - data << uint32(0x00); - else - data << uint32(0x03); - - data << uint32(0x04) << uint32(0x08) << uint32(0x10); - - pSession->SendPacket( &data ); - //sLog.outDebug( "WORLD: Sent SMSG_QUESTGIVER_REQUEST_ITEMS NPCGuid=%u, questid=%u",GUID_LOPART(npcGUID),pQuest->GetQuestId() ); -} +/* + * Copyright (C) 2005-2008 MaNGOS + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "QuestDef.h" +#include "GossipDef.h" +#include "ObjectMgr.h" +#include "Opcodes.h" +#include "WorldPacket.h" +#include "WorldSession.h" + +GossipMenu::GossipMenu() +{ + m_gItems.reserve(16); // can be set for max from most often sizes to speedup push_back and less memory use +} + +GossipMenu::~GossipMenu() +{ + ClearMenu(); +} + +void GossipMenu::AddMenuItem(uint8 Icon, std::string Message, uint32 dtSender, uint32 dtAction, std::string BoxMessage, uint32 BoxMoney, bool Coded) +{ + ASSERT( m_gItems.size() <= GOSSIP_MAX_MENU_ITEMS ); + + GossipMenuItem gItem; + + gItem.m_gIcon = Icon; + gItem.m_gMessage = Message; + gItem.m_gCoded = Coded; + gItem.m_gSender = dtSender; + gItem.m_gAction = dtAction; + gItem.m_gBoxMessage = BoxMessage; + gItem.m_gBoxMoney = BoxMoney; + + m_gItems.push_back(gItem); +} + +void GossipMenu::AddMenuItem(uint8 Icon, std::string Message, bool Coded) +{ + AddMenuItem( Icon, Message, 0, 0, "", 0, Coded); +} + +void GossipMenu::AddMenuItem(uint8 Icon, char const* Message, bool Coded) +{ + AddMenuItem(Icon, std::string(Message ? Message : ""),Coded); +} + +void GossipMenu::AddMenuItem(uint8 Icon, char const* Message, uint32 dtSender, uint32 dtAction, char const* BoxMessage, uint32 BoxMoney, bool Coded) +{ + AddMenuItem(Icon, std::string(Message ? Message : ""), dtSender, dtAction, std::string(BoxMessage ? BoxMessage : ""), BoxMoney, Coded); +} + +uint32 GossipMenu::MenuItemSender( unsigned int ItemId ) +{ + if ( ItemId >= m_gItems.size() ) return 0; + + return m_gItems[ ItemId ].m_gSender; +} + +uint32 GossipMenu::MenuItemAction( unsigned int ItemId ) +{ + if ( ItemId >= m_gItems.size() ) return 0; + + return m_gItems[ ItemId ].m_gAction; +} + +bool GossipMenu::MenuItemCoded( unsigned int ItemId ) +{ + if ( ItemId >= m_gItems.size() ) return 0; + + return m_gItems[ ItemId ].m_gCoded; +} + +void GossipMenu::ClearMenu() +{ + m_gItems.clear(); +} + +PlayerMenu::PlayerMenu( WorldSession *session ) : pSession(session) +{ +} + +PlayerMenu::~PlayerMenu() +{ + ClearMenus(); +} + +void PlayerMenu::ClearMenus() +{ + mGossipMenu.ClearMenu(); + mQuestMenu.ClearMenu(); +} + +uint32 PlayerMenu::GossipOptionSender( unsigned int Selection ) +{ + return mGossipMenu.MenuItemSender( Selection ); +} + +uint32 PlayerMenu::GossipOptionAction( unsigned int Selection ) +{ + return mGossipMenu.MenuItemAction( Selection ); +} + +bool PlayerMenu::GossipOptionCoded( unsigned int Selection ) +{ + return mGossipMenu.MenuItemCoded( Selection ); +} + +void PlayerMenu::SendGossipMenu( uint32 TitleTextId, uint64 npcGUID ) +{ + WorldPacket data( SMSG_GOSSIP_MESSAGE, (100) ); // guess size + data << npcGUID; + data << uint32(0); // new 2.4.0 + data << uint32( TitleTextId ); + data << uint32( mGossipMenu.MenuItemCount() ); // max count 0x0F + + for ( unsigned int iI = 0; iI < mGossipMenu.MenuItemCount(); iI++ ) + { + GossipMenuItem const& gItem = mGossipMenu.GetItem(iI); + data << uint32( iI ); + data << uint8( gItem.m_gIcon ); + // icons: + // 0 unlearn talents/misc + // 1 trader + // 2 taxi + // 3 trainer + // 9 BG/arena + data << uint8( gItem.m_gCoded ); // makes pop up box password + data << uint32(gItem.m_gBoxMoney); // money required to open menu, 2.0.3 + data << gItem.m_gMessage; // text for gossip item + data << gItem.m_gBoxMessage; // accept text (related to money) pop up box, 2.0.3 + } + + data << uint32( mQuestMenu.MenuItemCount() ); // max count 0x20 + + for ( uint16 iI = 0; iI < mQuestMenu.MenuItemCount(); iI++ ) + { + QuestMenuItem const& qItem = mQuestMenu.GetItem(iI); + uint32 questID = qItem.m_qId; + Quest const* pQuest = objmgr.GetQuestTemplate(questID); + + data << questID; + data << uint32( qItem.m_qIcon ); + data << uint32( pQuest ? pQuest->GetQuestLevel() : 0 ); + std::string Title = pQuest->GetTitle(); + + int loc_idx = pSession->GetSessionDbLocaleIndex(); + if (loc_idx >= 0) + { + QuestLocale const *ql = objmgr.GetQuestLocale(questID); + if (ql) + { + if (ql->Title.size() > loc_idx && !ql->Title[loc_idx].empty()) + Title=ql->Title[loc_idx]; + } + } + data << Title; + } + + pSession->SendPacket( &data ); + //sLog.outDebug( "WORLD: Sent SMSG_GOSSIP_MESSAGE NPCGuid=%u",GUID_LOPART(npcGUID) ); +} + +void PlayerMenu::CloseGossip() +{ + WorldPacket data( SMSG_GOSSIP_COMPLETE, 0 ); + pSession->SendPacket( &data ); + + //sLog.outDebug( "WORLD: Sent SMSG_GOSSIP_COMPLETE" ); +} + +void PlayerMenu::SendPointOfInterest( float X, float Y, uint32 Icon, uint32 Flags, uint32 Data, char const * locName ) +{ + WorldPacket data( SMSG_GOSSIP_POI, (4+4+4+4+4+10) ); // guess size + data << Flags; + data << X << Y; + data << uint32(Icon); + data << uint32(Data); + data << locName; + + pSession->SendPacket( &data ); + //sLog.outDebug("WORLD: Sent SMSG_GOSSIP_POI"); +} + +void PlayerMenu::SendTalking( uint32 textID ) +{ + GossipText *pGossip; + std::string GossipStr; + + pGossip = objmgr.GetGossipText(textID); + + WorldPacket data( SMSG_NPC_TEXT_UPDATE, 100 ); // guess size + data << textID; // can be < 0 + + if (!pGossip) + { + for(uint32 i = 0; i < 8; ++i) + { + data << float(0); + data << "Greetings $N"; + data << "Greetings $N"; + data << uint32(0); + data << uint32(0); + data << uint32(0); + data << uint32(0); + data << uint32(0); + data << uint32(0); + data << uint32(0); + } + } + else + { + std::string Text_0[8],Text_1[8]; + for (int i=0;i<8;i++) + { + Text_0[i]=pGossip->Options[i].Text_0; + Text_1[i]=pGossip->Options[i].Text_1; + } + int loc_idx = pSession->GetSessionDbLocaleIndex(); + if (loc_idx >= 0) + { + NpcTextLocale const *nl = objmgr.GetNpcTextLocale(textID); + if (nl) + { + for (int i=0;i<8;i++) + { + if (nl->Text_0[i].size() > loc_idx && !nl->Text_0[i][loc_idx].empty()) + Text_0[i]=nl->Text_0[i][loc_idx]; + if (nl->Text_1[i].size() > loc_idx && !nl->Text_1[i][loc_idx].empty()) + Text_1[i]=nl->Text_1[i][loc_idx]; + } + } + } + for (int i=0; i<8; i++) + { + data << pGossip->Options[i].Probability; + + if ( Text_0[i].empty() ) + data << Text_1[i]; + else + data << Text_0[i]; + + if ( Text_1[i].empty() ) + data << Text_0[i]; + else + data << Text_1[i]; + + data << pGossip->Options[i].Language; + + data << pGossip->Options[i].Emotes[0]._Delay; + data << pGossip->Options[i].Emotes[0]._Emote; + + data << pGossip->Options[i].Emotes[1]._Delay; + data << pGossip->Options[i].Emotes[1]._Emote; + + data << pGossip->Options[i].Emotes[2]._Delay; + data << pGossip->Options[i].Emotes[2]._Emote; + } + } + pSession->SendPacket( &data ); + + sLog.outDebug( "WORLD: Sent SMSG_NPC_TEXT_UPDATE " ); +} + +void PlayerMenu::SendTalking( char const * title, char const * text ) +{ + WorldPacket data( SMSG_NPC_TEXT_UPDATE, 50 ); // guess size + data << uint32(0); + for(uint32 i = 0; i < 8; ++i) + { + data << float(0); + data << title; + data << text; + data << uint32(0); + data << uint32(0); + data << uint32(0); + data << uint32(0); + data << uint32(0); + data << uint32(0); + data << uint32(0); + } + + pSession->SendPacket( &data ); + + sLog.outDebug( "WORLD: Sent SMSG_NPC_TEXT_UPDATE " ); +} + +/*********************************************************/ +/*** QUEST SYSTEM ***/ +/*********************************************************/ + +QuestMenu::QuestMenu() +{ + m_qItems.reserve(16); // can be set for max from most often sizes to speedup push_back and less memory use +} + +QuestMenu::~QuestMenu() +{ + ClearMenu(); +} + +void QuestMenu::AddMenuItem( uint32 QuestId, uint8 Icon) +{ + Quest const* qinfo = objmgr.GetQuestTemplate(QuestId); + if (!qinfo) return; + + ASSERT( m_qItems.size() <= GOSSIP_MAX_MENU_ITEMS ); + + QuestMenuItem qItem; + + qItem.m_qId = QuestId; + qItem.m_qIcon = Icon; + + m_qItems.push_back(qItem); +} + +bool QuestMenu::HasItem( uint32 questid ) +{ + for (QuestMenuItemList::iterator i = m_qItems.begin(); i != m_qItems.end(); i++) + { + if(i->m_qId==questid) + { + return true; + } + } + return false; +} + +void QuestMenu::ClearMenu() +{ + m_qItems.clear(); +} + +void PlayerMenu::SendQuestGiverQuestList( QEmote eEmote, std::string Title, uint64 npcGUID ) +{ + WorldPacket data( SMSG_QUESTGIVER_QUEST_LIST, 100 ); // guess size + data << uint64(npcGUID); + data << Title; + data << uint32(eEmote._Delay ); // player emote + data << uint32(eEmote._Emote ); // NPC emote + data << uint8 ( mQuestMenu.MenuItemCount() ); + + for ( uint16 iI = 0; iI < mQuestMenu.MenuItemCount(); iI++ ) + { + QuestMenuItem const& qmi = mQuestMenu.GetItem(iI); + + uint32 questID = qmi.m_qId; + Quest const *pQuest = objmgr.GetQuestTemplate(questID); + + std::string title = pQuest ? pQuest->GetTitle() : ""; + + int loc_idx = pSession->GetSessionDbLocaleIndex(); + if (loc_idx >= 0) + { + if(QuestLocale const *ql = objmgr.GetQuestLocale(questID)) + { + if (ql->Title.size() > loc_idx && !ql->Title[loc_idx].empty()) + title=ql->Title[loc_idx]; + } + } + + data << uint32(questID); + data << uint32(qmi.m_qIcon); + data << uint32(pQuest ? pQuest->GetQuestLevel() : 0); + data << title; + } + pSession->SendPacket( &data ); + //uint32 fqid=pQuestMenu->GetItem(0).m_qId; + //sLog.outDebug( "WORLD: Sent SMSG_QUESTGIVER_QUEST_LIST NPC Guid=%u, questid-0=%u",npcGUID,fqid); +} + +void PlayerMenu::SendQuestGiverStatus( uint8 questStatus, uint64 npcGUID ) +{ + WorldPacket data( SMSG_QUESTGIVER_STATUS, 9 ); + data << uint64(npcGUID); + data << uint8(questStatus); + + pSession->SendPacket( &data ); + //sLog.outDebug( "WORLD: Sent SMSG_QUESTGIVER_STATUS NPC Guid=%u, status=%u",GUID_LOPART(npcGUID),questStatus); +} + +void PlayerMenu::SendQuestGiverQuestDetails( Quest const *pQuest, uint64 npcGUID, bool ActivateAccept ) +{ + WorldPacket data(SMSG_QUESTGIVER_QUEST_DETAILS, 100); // guess size + + std::string Title = pQuest->GetTitle(); + std::string Details = pQuest->GetDetails(); + std::string Objectives = pQuest->GetObjectives(); + std::string EndText = pQuest->GetEndText(); + + int loc_idx = pSession->GetSessionDbLocaleIndex(); + if (loc_idx >= 0) + { + QuestLocale const *ql = objmgr.GetQuestLocale(pQuest->GetQuestId()); + if (ql) + { + if (ql->Title.size() > loc_idx && !ql->Title[loc_idx].empty()) + Title=ql->Title[loc_idx]; + if (ql->Details.size() > loc_idx && !ql->Details[loc_idx].empty()) + Details=ql->Details[loc_idx]; + if (ql->Objectives.size() > loc_idx && !ql->Objectives[loc_idx].empty()) + Objectives=ql->Objectives[loc_idx]; + if (ql->EndText.size() > loc_idx && !ql->EndText[loc_idx].empty()) + EndText=ql->EndText[loc_idx]; + } + } + + data << uint64(npcGUID); + data << uint32(pQuest->GetQuestId()); + data << Title << Details << Objectives; + data << uint32(ActivateAccept); + data << uint32(pQuest->GetSuggestedPlayers()); + + if (pQuest->HasFlag(QUEST_FLAGS_HIDDEN_REWARDS)) + { + data << uint32(0); // Rewarded chosen items hidden + data << uint32(0); // Rewarded items hidden + data << uint32(0); // Rewarded money hidden + } + else + { + ItemPrototype const* IProto; + + data << uint32(pQuest->GetRewChoiceItemsCount()); + for (uint32 i=0; i < QUEST_REWARD_CHOICES_COUNT; i++) + { + if ( !pQuest->RewChoiceItemId[i] ) continue; + data << uint32(pQuest->RewChoiceItemId[i]); + data << uint32(pQuest->RewChoiceItemCount[i]); + IProto = objmgr.GetItemPrototype(pQuest->RewChoiceItemId[i]); + if ( IProto ) + data << uint32(IProto->DisplayInfoID); + else + data << uint32( 0x00 ); + } + + data << uint32(pQuest->GetRewItemsCount()); + for (uint32 i=0; i < QUEST_REWARDS_COUNT; i++) + { + if ( !pQuest->RewItemId[i] ) continue; + data << uint32(pQuest->RewItemId[i]); + data << uint32(pQuest->RewItemCount[i]); + IProto = objmgr.GetItemPrototype(pQuest->RewItemId[i]); + if ( IProto ) + data << uint32(IProto->DisplayInfoID); + else + data << uint32(0); + } + data << uint32(pQuest->GetRewOrReqMoney()); + } + + data << uint32(0); // Honor points reward, not implemented + data << uint32(pQuest->GetRewSpell()); // reward spell, this spell will display (icon) (casted if RewSpellCast==0) + data << uint32(pQuest->GetRewSpellCast()); // casted spell + data << uint32(pQuest->GetCharTitleId()); // CharTitleId, new 2.4.0, player gets this title (id from CharTitles) + + data << uint32(QUEST_EMOTE_COUNT); + for (uint32 i=0; i < QUEST_EMOTE_COUNT; i++) + { + data << uint32(pQuest->DetailsEmote[i]); + data << uint32(0); // DetailsEmoteDelay + } + pSession->SendPacket( &data ); + + //sLog.outDebug("WORLD: Sent SMSG_QUESTGIVER_QUEST_DETAILS NPCGuid=%u, questid=%u",GUID_LOPART(npcGUID),pQuest->GetQuestId()); +} + +void PlayerMenu::SendQuestQueryResponse( Quest const *pQuest ) +{ + std::string Title,Details,Objectives,EndText; + std::string ObjectiveText[QUEST_OBJECTIVES_COUNT]; + Title = pQuest->GetTitle(); + Details = pQuest->GetDetails(); + Objectives = pQuest->GetObjectives(); + EndText = pQuest->GetEndText(); + for (int i=0;iObjectiveText[i]; + + int loc_idx = pSession->GetSessionDbLocaleIndex(); + if (loc_idx >= 0) + { + QuestLocale const *ql = objmgr.GetQuestLocale(pQuest->GetQuestId()); + if (ql) + { + if (ql->Title.size() > loc_idx && !ql->Title[loc_idx].empty()) + Title=ql->Title[loc_idx]; + if (ql->Details.size() > loc_idx && !ql->Details[loc_idx].empty()) + Details=ql->Details[loc_idx]; + if (ql->Objectives.size() > loc_idx && !ql->Objectives[loc_idx].empty()) + Objectives=ql->Objectives[loc_idx]; + if (ql->EndText.size() > loc_idx && !ql->EndText[loc_idx].empty()) + EndText=ql->EndText[loc_idx]; + + for (int i=0;iObjectiveText[i].size() > loc_idx && !ql->ObjectiveText[i][loc_idx].empty()) + ObjectiveText[i]=ql->ObjectiveText[i][loc_idx]; + } + } + + WorldPacket data( SMSG_QUEST_QUERY_RESPONSE, 100 ); // guess size + + data << uint32(pQuest->GetQuestId()); + data << uint32(pQuest->GetMinLevel()); // not MinLevel. Accepted values: 0, 1 or 2 Possible theory for future dev: 0==cannot in quest log, 1==can in quest log session only(removed on log out), 2==can in quest log always (save to db) + data << uint32(pQuest->GetQuestLevel()); // may be 0 + data << uint32(pQuest->GetZoneOrSort()); // zone or sort to display in quest log + + data << uint32(pQuest->GetType()); + data << uint32(pQuest->GetSuggestedPlayers()); + + data << uint32(pQuest->GetRepObjectiveFaction()); // shown in quest log as part of quest objective + data << uint32(pQuest->GetRepObjectiveValue()); // shown in quest log as part of quest objective + + data << uint32(0); // RequiredOpositeRepFaction + data << uint32(0); // RequiredOpositeRepValue, required faction value with another (oposite) faction (objective) + + data << uint32(pQuest->GetNextQuestInChain()); // client will request this quest from NPC, if not 0 + + if (pQuest->HasFlag(QUEST_FLAGS_HIDDEN_REWARDS)) + data << uint32(0); // Hide money rewarded + else + data << uint32(pQuest->GetRewOrReqMoney()); + + data << uint32(pQuest->GetRewMoneyMaxLevel()); // used in XP calculation at client + data << uint32(pQuest->GetRewSpell()); // reward spell, this spell will display (icon) (casted if RewSpellCast==0) + data << uint32(pQuest->GetRewSpellCast()); // casted spell + + data << uint32(0); // Honor points reward, not implemented + data << uint32(pQuest->GetSrcItemId()); + data << uint32(pQuest->GetFlags() & 0xFFFF); + data << uint32(pQuest->GetCharTitleId()); // CharTitleId, new 2.4.0, player gets this title (id from CharTitles) + + int iI; + + if (pQuest->HasFlag(QUEST_FLAGS_HIDDEN_REWARDS)) + { + for (iI = 0; iI < QUEST_REWARDS_COUNT; iI++) + data << uint32(0) << uint32(0); + for (iI = 0; iI < QUEST_REWARD_CHOICES_COUNT; iI++) + data << uint32(0) << uint32(0); + } + else + { + for (iI = 0; iI < QUEST_REWARDS_COUNT; iI++) + { + data << uint32(pQuest->RewItemId[iI]); + data << uint32(pQuest->RewItemCount[iI]); + } + for (iI = 0; iI < QUEST_REWARD_CHOICES_COUNT; iI++) + { + data << uint32(pQuest->RewChoiceItemId[iI]); + data << uint32(pQuest->RewChoiceItemCount[iI]); + } + } + + data << pQuest->GetPointMapId(); + data << pQuest->GetPointX(); + data << pQuest->GetPointY(); + data << pQuest->GetPointOpt(); + + data << Title; + data << Objectives; + data << Details; + data << EndText; + + for (iI = 0; iI < QUEST_OBJECTIVES_COUNT; iI++) + { + if (pQuest->ReqCreatureOrGOId[iI] < 0) + { + // client expected gameobject template id in form (id|0x80000000) + data << uint32((pQuest->ReqCreatureOrGOId[iI]*(-1))|0x80000000); + } + else + { + data << uint32(pQuest->ReqCreatureOrGOId[iI]); + } + data << uint32(pQuest->ReqCreatureOrGOCount[iI]); + data << uint32(pQuest->ReqItemId[iI]); + data << uint32(pQuest->ReqItemCount[iI]); + } + + for (iI = 0; iI < QUEST_OBJECTIVES_COUNT; iI++) + data << ObjectiveText[iI]; + + pSession->SendPacket( &data ); + //sLog.outDebug( "WORLD: Sent SMSG_QUEST_QUERY_RESPONSE questid=%u",pQuest->GetQuestId() ); +} + +void PlayerMenu::SendQuestGiverOfferReward( Quest const* pQuest, uint64 npcGUID, bool EnbleNext ) +{ + std::string Title = pQuest->GetTitle(); + std::string OfferRewardText = pQuest->GetOfferRewardText(); + + int loc_idx = pSession->GetSessionDbLocaleIndex(); + if (loc_idx >= 0) + { + QuestLocale const *ql = objmgr.GetQuestLocale(pQuest->GetQuestId()); + if (ql) + { + if (ql->Title.size() > loc_idx && !ql->Title[loc_idx].empty()) + Title=ql->Title[loc_idx]; + if (ql->OfferRewardText.size() > loc_idx && !ql->OfferRewardText[loc_idx].empty()) + OfferRewardText=ql->OfferRewardText[loc_idx]; + } + } + + WorldPacket data( SMSG_QUESTGIVER_OFFER_REWARD, 50 ); // guess size + + data << npcGUID; + data << pQuest->GetQuestId(); + data << Title; + data << OfferRewardText; + + data << uint32( EnbleNext ); + data << uint32(0); // unk + + uint32 EmoteCount = 0; + for (uint32 i = 0; i < QUEST_EMOTE_COUNT; i++) + { + if(pQuest->OfferRewardEmote[i] <= 0) + break; + ++EmoteCount; + } + + data << EmoteCount; // Emote Count + for (uint32 i = 0; i < EmoteCount; i++) + { + data << uint32(0); // Delay Emote + data << pQuest->OfferRewardEmote[i]; + } + + ItemPrototype const *pItem; + + data << uint32(pQuest->GetRewChoiceItemsCount()); + for (uint32 i=0; i < pQuest->GetRewChoiceItemsCount(); i++) + { + pItem = objmgr.GetItemPrototype( pQuest->RewChoiceItemId[i] ); + + data << uint32(pQuest->RewChoiceItemId[i]); + data << uint32(pQuest->RewChoiceItemCount[i]); + + if ( pItem ) + data << uint32(pItem->DisplayInfoID); + else + data << uint32(0); + } + + data << uint32(pQuest->GetRewItemsCount()); + for (uint16 i=0; i < pQuest->GetRewItemsCount(); i++) + { + pItem = objmgr.GetItemPrototype(pQuest->RewItemId[i]); + data << uint32(pQuest->RewItemId[i]); + data << uint32(pQuest->RewItemCount[i]); + + if ( pItem ) + data << uint32(pItem->DisplayInfoID); + else + data << uint32(0); + } + + data << uint32(pQuest->GetRewOrReqMoney()); + data << uint32(0x00); // new 2.3.0. Honor points + data << uint32(0x08); // unused by client? + data << uint32(pQuest->GetRewSpell()); // reward spell, this spell will display (icon) (casted if RewSpellCast==0) + data << uint32(pQuest->GetRewSpellCast()); // casted spell + data << uint32(0); // Honor points reward, not implemented + pSession->SendPacket( &data ); + //sLog.outDebug( "WORLD: Sent SMSG_QUESTGIVER_OFFER_REWARD NPCGuid=%u, questid=%u",GUID_LOPART(npcGUID),pQuest->GetQuestId() ); +} + +void PlayerMenu::SendQuestGiverRequestItems( Quest const *pQuest, uint64 npcGUID, bool Completable, bool CloseOnCancel ) +{ + // We can always call to RequestItems, but this packet only goes out if there are actually + // items. Otherwise, we'll skip straight to the OfferReward + + // We may wish a better check, perhaps checking the real quest requirements + if (pQuest->GetRequestItemsText().empty()) + { + SendQuestGiverOfferReward(pQuest, npcGUID, true); + return; + } + + std::string Title,RequestItemsText; + Title = pQuest->GetTitle(); + RequestItemsText = pQuest->GetRequestItemsText(); + + int loc_idx = pSession->GetSessionDbLocaleIndex(); + if (loc_idx >= 0) + { + QuestLocale const *ql = objmgr.GetQuestLocale(pQuest->GetQuestId()); + if (ql) + { + if (ql->Title.size() > loc_idx && !ql->Title[loc_idx].empty()) + Title=ql->Title[loc_idx]; + if (ql->RequestItemsText.size() > loc_idx && !ql->RequestItemsText[loc_idx].empty()) + RequestItemsText=ql->RequestItemsText[loc_idx]; + } + } + + WorldPacket data( SMSG_QUESTGIVER_REQUEST_ITEMS, 50 ); // guess size + data << npcGUID; + data << pQuest->GetQuestId(); + data << Title; + data << RequestItemsText; + + data << uint32(0x00); // unknown + + if(Completable) + data << pQuest->GetCompleteEmote(); + else + data << pQuest->GetIncompleteEmote(); + + // Close Window after cancel + if (CloseOnCancel) + data << uint32(0x01); + else + data << uint32(0x00); + + data << uint32(0x00); // unknown + + // Required Money + data << uint32(pQuest->GetRewOrReqMoney() < 0 ? -pQuest->GetRewOrReqMoney() : 0); + + data << uint32( pQuest->GetReqItemsCount() ); + ItemPrototype const *pItem; + for (int i = 0; i < QUEST_OBJECTIVES_COUNT; i++) + { + if ( !pQuest->ReqItemId[i] ) continue; + pItem = objmgr.GetItemPrototype(pQuest->ReqItemId[i]); + data << uint32(pQuest->ReqItemId[i]); + data << uint32(pQuest->ReqItemCount[i]); + + if ( pItem ) + data << uint32(pItem->DisplayInfoID); + else + data << uint32(0); + } + + if ( !Completable ) + data << uint32(0x00); + else + data << uint32(0x03); + + data << uint32(0x04) << uint32(0x08) << uint32(0x10); + + pSession->SendPacket( &data ); + //sLog.outDebug( "WORLD: Sent SMSG_QUESTGIVER_REQUEST_ITEMS NPCGuid=%u, questid=%u",GUID_LOPART(npcGUID),pQuest->GetQuestId() ); +} diff --git a/src/game/GossipDef.h b/src/game/GossipDef.h index aacf7a8fcb8..18f7c007aa1 100644 --- a/src/game/GossipDef.h +++ b/src/game/GossipDef.h @@ -1,193 +1,206 @@ -/* - * Copyright (C) 2005-2008 MaNGOS - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef MANGOSSERVER_GOSSIP_H -#define MANGOSSERVER_GOSSIP_H - -#include "Common.h" -#include "QuestDef.h" -#include "NPCHandler.h" - -class WorldSession; - -#define GOSSIP_MAX_MENU_ITEMS 64 // client supported items unknown, but provided number must be enough -#define DEFAULT_GOSSIP_MESSAGE 0xffffff - -//POI defines -enum Poi_Icon -{ - ICON_POI_0 = 0, // Grey ? - ICON_POI_1 = 1, // Red ? - ICON_POI_2 = 2, // Blue ? - ICON_POI_BWTOMB = 3, // Blue and White Tomb Stone - ICON_POI_HOUSE = 4, // House - ICON_POI_TOWER = 5, // Tower - ICON_POI_REDFLAG = 6, // Red Flag with Yellow ! - ICON_POI_TOMB = 7, // Tomb Stone - ICON_POI_BWTOWER = 8, // Blue and White Tower - ICON_POI_REDTOWER = 9, // Red Tower - ICON_POI_BLUETOWER = 10, // Blue Tower - ICON_POI_RWTOWER = 11, // Red and White Tower - ICON_POI_REDTOMB = 12, // Red Tomb Stone - ICON_POI_RWTOMB = 13, // Red and White Tomb Stone - ICON_POI_BLUETOMB = 14, // Blue Tomb Stone - ICON_POI_NOTHING = 15, // NOTHING - ICON_POI_16 = 16, // Red ? - ICON_POI_17 = 17, // Grey ? - ICON_POI_18 = 18, // Blue ? - ICON_POI_19 = 19, // Red and White ? - ICON_POI_20 = 20, // Red ? - ICON_POI_GREYLOGS = 21, // Grey Wood Logs - ICON_POI_BWLOGS = 22, // Blue and White Wood Logs - ICON_POI_BLUELOGS = 23, // Blue Wood Logs - ICON_POI_RWLOGS = 24, // Red and White Wood Logs - ICON_POI_REDLOGS = 25, // Red Wood Logs - ICON_POI_26 = 26, // Grey ? - ICON_POI_27 = 27, // Blue and White ? - ICON_POI_28 = 28, // Blue ? - ICON_POI_29 = 29, // Red and White ? - ICON_POI_30 = 30, // Red ? - ICON_POI_GREYHOUSE = 31, // Grey House - ICON_POI_BWHOUSE = 32, // Blue and White House - ICON_POI_BLUEHOUSE = 33, // Blue House - ICON_POI_RWHOUSE = 34, // Red and White House - ICON_POI_REDHOUSE = 35, // Red House - ICON_POI_GREYHORSE = 36, // Grey Horse - ICON_POI_BWHORSE = 37, // Blue and White Horse - ICON_POI_BLUEHORSE = 38, // Blue Horse - ICON_POI_RWHORSE = 39, // Red and White Horse - ICON_POI_REDHORSE = 40 // Red Horse -}; - -struct GossipMenuItem -{ - uint8 m_gIcon; - bool m_gCoded; - std::string m_gMessage; - uint32 m_gSender; - uint32 m_gAction; - std::string m_gBoxMessage; - uint32 m_gBoxMoney; -}; - -typedef std::vector GossipMenuItemList; - -struct QuestMenuItem -{ - uint32 m_qId; - uint8 m_qIcon; -}; - -typedef std::vector QuestMenuItemList; - -class MANGOS_DLL_SPEC GossipMenu -{ - public: - GossipMenu(); - ~GossipMenu(); - - void AddMenuItem(uint8 Icon, std::string Message, bool Coded = false); - void AddMenuItem(uint8 Icon, std::string Message, uint32 dtSender, uint32 dtAction, std::string BoxMessage, uint32 BoxMoney, bool Coded = false); - - // for using from scripts, don't must be inlined - void AddMenuItem(uint8 Icon, char const* Message, bool Coded = false); - void AddMenuItem(uint8 Icon, char const* Message, uint32 dtSender, uint32 dtAction, char const* BoxMessage, uint32 BoxMoney, bool Coded = false); - - unsigned int MenuItemCount() - { - return m_gItems.size(); - } - - GossipMenuItem const& GetItem( unsigned int Id ) - { - return m_gItems[ Id ]; - } - - uint32 MenuItemSender( unsigned int ItemId ); - uint32 MenuItemAction( unsigned int ItemId ); - bool MenuItemCoded( unsigned int ItemId ); - - void ClearMenu(); - - protected: - GossipMenuItemList m_gItems; -}; - -class QuestMenu -{ - public: - QuestMenu(); - ~QuestMenu(); - - void AddMenuItem( uint32 QuestId, uint8 Icon); - void ClearMenu(); - - uint8 MenuItemCount() - { - return m_qItems.size(); - } - bool HasItem( uint32 questid ); - - QuestMenuItem const& GetItem( uint16 Id ) - { - return m_qItems[ Id ]; - } - - protected: - QuestMenuItemList m_qItems; -}; - -class MANGOS_DLL_SPEC PlayerMenu -{ - private: - GossipMenu* pGossipMenu; - QuestMenu* pQuestMenu; - WorldSession* pSession; - - public: - PlayerMenu( WorldSession *Session ); - ~PlayerMenu(); - - GossipMenu* GetGossipMenu() { return pGossipMenu; } - QuestMenu* GetQuestMenu() { return pQuestMenu; } - - void ClearMenus(); - uint32 GossipOptionSender( unsigned int Selection ); - uint32 GossipOptionAction( unsigned int Selection ); - bool GossipOptionCoded( unsigned int Selection ); - - void SendGossipMenu( uint32 TitleTextId, uint64 npcGUID ); - void CloseGossip(); - void SendPointOfInterest( float X, float Y, uint32 Icon, uint32 Flags, uint32 Data, const char * locName ); - void SendTalking( uint32 textID ); - void SendTalking( char const * title, char const * text ); - - /*********************************************************/ - /*** QUEST SYSTEM ***/ - /*********************************************************/ - void SendQuestGiverStatus( uint8 questStatus, uint64 npcGUID ); - - void SendQuestGiverQuestList( QEmote eEmote, std::string Title, uint64 npcGUID ); - - void SendQuestQueryResponse ( Quest const *pQuest ); - void SendQuestGiverQuestDetails( Quest const *pQuest, uint64 npcGUID, bool ActivateAccept); - - void SendQuestGiverOfferReward( Quest const* pQuest, uint64 npcGUID, bool EnbleNext ); - void SendQuestGiverRequestItems( Quest const *pQuest, uint64 npcGUID, bool Completable, bool CloseOnCancel ); -}; -#endif +/* + * Copyright (C) 2005-2008 MaNGOS + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef MANGOSSERVER_GOSSIP_H +#define MANGOSSERVER_GOSSIP_H + +#include "Common.h" +#include "QuestDef.h" +#include "NPCHandler.h" + +class WorldSession; + +#define GOSSIP_MAX_MENU_ITEMS 64 // client supported items unknown, but provided number must be enough +#define DEFAULT_GOSSIP_MESSAGE 0xffffff + +//POI defines +enum Poi_Icon +{ + ICON_POI_0 = 0, // Grey ? + ICON_POI_1 = 1, // Red ? + ICON_POI_2 = 2, // Blue ? + ICON_POI_BWTOMB = 3, // Blue and White Tomb Stone + ICON_POI_HOUSE = 4, // House + ICON_POI_TOWER = 5, // Tower + ICON_POI_REDFLAG = 6, // Red Flag with Yellow ! + ICON_POI_TOMB = 7, // Tomb Stone + ICON_POI_BWTOWER = 8, // Blue and White Tower + ICON_POI_REDTOWER = 9, // Red Tower + ICON_POI_BLUETOWER = 10, // Blue Tower + ICON_POI_RWTOWER = 11, // Red and White Tower + ICON_POI_REDTOMB = 12, // Red Tomb Stone + ICON_POI_RWTOMB = 13, // Red and White Tomb Stone + ICON_POI_BLUETOMB = 14, // Blue Tomb Stone + ICON_POI_NOTHING = 15, // NOTHING + ICON_POI_16 = 16, // Red ? + ICON_POI_17 = 17, // Grey ? + ICON_POI_18 = 18, // Blue ? + ICON_POI_19 = 19, // Red and White ? + ICON_POI_20 = 20, // Red ? + ICON_POI_GREYLOGS = 21, // Grey Wood Logs + ICON_POI_BWLOGS = 22, // Blue and White Wood Logs + ICON_POI_BLUELOGS = 23, // Blue Wood Logs + ICON_POI_RWLOGS = 24, // Red and White Wood Logs + ICON_POI_REDLOGS = 25, // Red Wood Logs + ICON_POI_26 = 26, // Grey ? + ICON_POI_27 = 27, // Blue and White ? + ICON_POI_28 = 28, // Blue ? + ICON_POI_29 = 29, // Red and White ? + ICON_POI_30 = 30, // Red ? + ICON_POI_GREYHOUSE = 31, // Grey House + ICON_POI_BWHOUSE = 32, // Blue and White House + ICON_POI_BLUEHOUSE = 33, // Blue House + ICON_POI_RWHOUSE = 34, // Red and White House + ICON_POI_REDHOUSE = 35, // Red House + ICON_POI_GREYHORSE = 36, // Grey Horse + ICON_POI_BWHORSE = 37, // Blue and White Horse + ICON_POI_BLUEHORSE = 38, // Blue Horse + ICON_POI_RWHORSE = 39, // Red and White Horse + ICON_POI_REDHORSE = 40 // Red Horse +}; + +struct GossipMenuItem +{ + uint8 m_gIcon; + bool m_gCoded; + std::string m_gMessage; + uint32 m_gSender; + uint32 m_gAction; + std::string m_gBoxMessage; + uint32 m_gBoxMoney; +}; + +typedef std::vector GossipMenuItemList; + +struct QuestMenuItem +{ + uint32 m_qId; + uint8 m_qIcon; +}; + +typedef std::vector QuestMenuItemList; + +class MANGOS_DLL_SPEC GossipMenu +{ + public: + GossipMenu(); + ~GossipMenu(); + + void AddMenuItem(uint8 Icon, std::string Message, bool Coded = false); + void AddMenuItem(uint8 Icon, std::string Message, uint32 dtSender, uint32 dtAction, std::string BoxMessage, uint32 BoxMoney, bool Coded = false); + + // for using from scripts, don't must be inlined + void AddMenuItem(uint8 Icon, char const* Message, bool Coded = false); + void AddMenuItem(uint8 Icon, char const* Message, uint32 dtSender, uint32 dtAction, char const* BoxMessage, uint32 BoxMoney, bool Coded = false); + + unsigned int MenuItemCount() const + { + return m_gItems.size(); + } + + bool Empty() const + { + return m_gItems.empty(); + } + + GossipMenuItem const& GetItem( unsigned int Id ) + { + return m_gItems[ Id ]; + } + + uint32 MenuItemSender( unsigned int ItemId ); + uint32 MenuItemAction( unsigned int ItemId ); + bool MenuItemCoded( unsigned int ItemId ); + + void ClearMenu(); + + protected: + GossipMenuItemList m_gItems; +}; + +class QuestMenu +{ + public: + QuestMenu(); + ~QuestMenu(); + + void AddMenuItem( uint32 QuestId, uint8 Icon); + void ClearMenu(); + + uint8 MenuItemCount() const + { + return m_qItems.size(); + } + + bool Empty() const + { + return m_qItems.empty(); + } + + bool HasItem( uint32 questid ); + + QuestMenuItem const& GetItem( uint16 Id ) + { + return m_qItems[ Id ]; + } + + protected: + QuestMenuItemList m_qItems; +}; + +class MANGOS_DLL_SPEC PlayerMenu +{ + private: + GossipMenu mGossipMenu; + QuestMenu mQuestMenu; + WorldSession* pSession; + + public: + PlayerMenu( WorldSession *Session ); + ~PlayerMenu(); + + GossipMenu& GetGossipMenu() { return mGossipMenu; } + QuestMenu& GetQuestMenu() { return mQuestMenu; } + + bool Empty() const { return mGossipMenu.Empty() && mQuestMenu.Empty(); } + + void ClearMenus(); + uint32 GossipOptionSender( unsigned int Selection ); + uint32 GossipOptionAction( unsigned int Selection ); + bool GossipOptionCoded( unsigned int Selection ); + + void SendGossipMenu( uint32 TitleTextId, uint64 npcGUID ); + void CloseGossip(); + void SendPointOfInterest( float X, float Y, uint32 Icon, uint32 Flags, uint32 Data, const char * locName ); + void SendTalking( uint32 textID ); + void SendTalking( char const * title, char const * text ); + + /*********************************************************/ + /*** QUEST SYSTEM ***/ + /*********************************************************/ + void SendQuestGiverStatus( uint8 questStatus, uint64 npcGUID ); + + void SendQuestGiverQuestList( QEmote eEmote, std::string Title, uint64 npcGUID ); + + void SendQuestQueryResponse ( Quest const *pQuest ); + void SendQuestGiverQuestDetails( Quest const *pQuest, uint64 npcGUID, bool ActivateAccept); + + void SendQuestGiverOfferReward( Quest const* pQuest, uint64 npcGUID, bool EnbleNext ); + void SendQuestGiverRequestItems( Quest const *pQuest, uint64 npcGUID, bool Completable, bool CloseOnCancel ); +}; +#endif diff --git a/src/game/GridNotifiers.h b/src/game/GridNotifiers.h index 215cf9152e6..98e25857638 100644 --- a/src/game/GridNotifiers.h +++ b/src/game/GridNotifiers.h @@ -1,812 +1,812 @@ -/* - * Copyright (C) 2005-2008 MaNGOS - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef MANGOS_GRIDNOTIFIERS_H -#define MANGOS_GRIDNOTIFIERS_H - -#include "ObjectGridLoader.h" -#include "ByteBuffer.h" -#include "UpdateData.h" -#include - -#include "Corpse.h" -#include "Object.h" -#include "DynamicObject.h" -#include "GameObject.h" -#include "Player.h" -#include "Unit.h" - -class Player; -//class Map; - -namespace MaNGOS -{ - - struct MANGOS_DLL_DECL PlayerNotifier - { - explicit PlayerNotifier(Player &pl) : i_player(pl) {} - void Visit(PlayerMapType &); - template void Visit(GridRefManager &) {} - Player &i_player; - }; - - struct MANGOS_DLL_DECL VisibleNotifier - { - Player &i_player; - UpdateData i_data; - UpdateDataMapType i_data_updates; - Player::ClientGUIDs i_clientGUIDs; - std::set i_visibleNow; - - explicit VisibleNotifier(Player &player) : i_player(player),i_clientGUIDs(player.m_clientGUIDs) {} - template void Visit(GridRefManager &m); - void Visit(PlayerMapType &); - void Notify(void); - }; - - struct MANGOS_DLL_DECL VisibleChangesNotifier - { - WorldObject &i_object; - - explicit VisibleChangesNotifier(WorldObject &object) : i_object(object) {} - template void Visit(GridRefManager &) {} - void Visit(PlayerMapType &); - }; - - struct MANGOS_DLL_DECL GridUpdater - { - GridType &i_grid; - uint32 i_timeDiff; - GridUpdater(GridType &grid, uint32 diff) : i_grid(grid), i_timeDiff(diff) {} - - template void updateObjects(GridRefManager &m) - { - for(typename GridRefManager::iterator iter = m.begin(); iter != m.end(); ++iter) - iter->getSource()->Update(i_timeDiff); - } - - void Visit(PlayerMapType &m) { updateObjects(m); } - void Visit(CreatureMapType &m){ updateObjects(m); } - void Visit(GameObjectMapType &m) { updateObjects(m); } - void Visit(DynamicObjectMapType &m) { updateObjects(m); } - void Visit(CorpseMapType &m) { updateObjects(m); } - }; - - struct MANGOS_DLL_DECL MessageDeliverer - { - Player &i_player; - WorldPacket *i_message; - bool i_toSelf; - MessageDeliverer(Player &pl, WorldPacket *msg, bool to_self) : i_player(pl), i_message(msg), i_toSelf(to_self) {} - void Visit(PlayerMapType &m); - template void Visit(GridRefManager &) {} - }; - - struct MANGOS_DLL_DECL ObjectMessageDeliverer - { - WorldPacket *i_message; - explicit ObjectMessageDeliverer(WorldPacket *msg) : i_message(msg) {} - void Visit(PlayerMapType &m); - template void Visit(GridRefManager &) {} - }; - - struct MANGOS_DLL_DECL MessageDistDeliverer - { - Player &i_player; - WorldPacket *i_message; - bool i_toSelf; - bool i_ownTeamOnly; - float i_dist; - MessageDistDeliverer(Player &pl, WorldPacket *msg, bool to_self, bool ownTeamOnly, float dist) : i_player(pl), i_message(msg), i_toSelf(to_self), i_ownTeamOnly(ownTeamOnly), i_dist(dist) {} - void Visit(PlayerMapType &m); - template void Visit(GridRefManager &) {} - }; - - struct MANGOS_DLL_DECL ObjectMessageDistDeliverer - { - WorldObject &i_object; - WorldPacket *i_message; - float i_dist; - ObjectMessageDistDeliverer(WorldObject &obj, WorldPacket *msg, float dist) : i_object(obj), i_message(msg), i_dist(dist) {} - void Visit(PlayerMapType &m); - template void Visit(GridRefManager &) {} - }; - - struct MANGOS_DLL_DECL ObjectUpdater - { - uint32 i_timeDiff; - explicit ObjectUpdater(const uint32 &diff) : i_timeDiff(diff) {} - template void Visit(GridRefManager &m); - void Visit(PlayerMapType &) {} - void Visit(CorpseMapType &) {} - void Visit(CreatureMapType &); - }; - - template - struct MANGOS_DLL_DECL ObjectAccessorNotifier - { - T *& i_object; - - uint64 i_id; - ObjectAccessorNotifier(T * &obj, uint64 id) : i_object(obj), i_id(id) - { - i_object = NULL; - } - - void Visit(GridRefManager &m ) - { - if( i_object == NULL ) - { - GridRefManager *iter = m.find(i_id); - if( iter != m.end() ) - { - assert( iter->second != NULL ); - i_object = iter->second; - } - } - } - - template void Visit(GridRefManager &) {} - }; - - struct MANGOS_DLL_DECL PlayerRelocationNotifier - { - Player &i_player; - PlayerRelocationNotifier(Player &pl) : i_player(pl) {} - template void Visit(GridRefManager &) {} - void Visit(PlayerMapType &); - void Visit(CreatureMapType &); - }; - - struct MANGOS_DLL_DECL CreatureRelocationNotifier - { - Creature &i_creature; - CreatureRelocationNotifier(Creature &c) : i_creature(c) {} - template void Visit(GridRefManager &) {} - #ifdef WIN32 - template<> void Visit(PlayerMapType &); - #endif - }; - - struct MANGOS_DLL_DECL DynamicObjectUpdater - { - DynamicObject &i_dynobject; - Unit* i_check; - DynamicObjectUpdater(DynamicObject &dynobject, Unit* caster) : i_dynobject(dynobject) - { - i_check = caster; - Unit* owner = i_check->GetOwner(); - if(owner) - i_check = owner; - } - - template inline void Visit(GridRefManager &) {} - #ifdef WIN32 - template<> inline void Visit(PlayerMapType &); - template<> inline void Visit(CreatureMapType &); - #endif - - void VisitHelper(Unit* target); - }; - - // SEARCHERS & LIST SEARCHERS & WORKERS - - // WorldObject searchers & workers - - template - struct MANGOS_DLL_DECL WorldObjectSearcher - { - WorldObject* &i_object; - Check &i_check; - - WorldObjectSearcher(WorldObject* & result, Check& check) : i_object(result),i_check(check) {} - - void Visit(GameObjectMapType &m); - void Visit(PlayerMapType &m); - void Visit(CreatureMapType &m); - void Visit(CorpseMapType &m); - void Visit(DynamicObjectMapType &m); - - template void Visit(GridRefManager &) {} - }; - - template - struct MANGOS_DLL_DECL WorldObjectListSearcher - { - std::list &i_objects; - Check& i_check; - - WorldObjectListSearcher(std::list &objects, Check & check) : i_objects(objects),i_check(check) {} - - void Visit(PlayerMapType &m); - void Visit(CreatureMapType &m); - void Visit(CorpseMapType &m); - void Visit(GameObjectMapType &m); - void Visit(DynamicObjectMapType &m); - - template void Visit(GridRefManager &) {} - }; - - template - struct MANGOS_DLL_DECL WorldObjectWorker - { - Do const& i_do; - - explicit WorldObjectWorker(Do const& _do) : i_do(_do) {} - - void Visit(GameObjectMapType &m) - { - for(GameObjectMapType::iterator itr=m.begin(); itr != m.end(); ++itr) - i_do(itr->getSource()); - } - - void Visit(PlayerMapType &m) - { - for(PlayerMapType::iterator itr=m.begin(); itr != m.end(); ++itr) - i_do(itr->getSource()); - } - void Visit(CreatureMapType &m) - { - for(CreatureMapType::iterator itr=m.begin(); itr != m.end(); ++itr) - i_do(itr->getSource()); - } - - void Visit(CorpseMapType &m) - { - for(CorpseMapType::iterator itr=m.begin(); itr != m.end(); ++itr) - i_do(itr->getSource()); - } - - void Visit(DynamicObjectMapType &m) - { - for(DynamicObjectMapType::iterator itr=m.begin(); itr != m.end(); ++itr) - i_do(itr->getSource()); - } - - template void Visit(GridRefManager &) {} - }; - - // Gameobject searchers - - template - struct MANGOS_DLL_DECL GameObjectSearcher - { - GameObject* &i_object; - Check &i_check; - - GameObjectSearcher(GameObject* & result, Check& check) : i_object(result),i_check(check) {} - - void Visit(GameObjectMapType &m); - - template void Visit(GridRefManager &) {} - }; - - // Last accepted by Check GO if any (Check can change requirements at each call) - template - struct MANGOS_DLL_DECL GameObjectLastSearcher - { - GameObject* &i_object; - Check& i_check; - - GameObjectLastSearcher(GameObject* & result, Check& check) : i_object(result),i_check(check) {} - - void Visit(GameObjectMapType &m); - - template void Visit(GridRefManager &) {} - }; - - template - struct MANGOS_DLL_DECL GameObjectListSearcher - { - std::list &i_objects; - Check& i_check; - - GameObjectListSearcher(std::list &objects, Check & check) : i_objects(objects),i_check(check) {} - - void Visit(GameObjectMapType &m); - - template void Visit(GridRefManager &) {} - }; - - // Unit searchers - - // First accepted by Check Unit if any - template - struct MANGOS_DLL_DECL UnitSearcher - { - Unit* &i_object; - Check & i_check; - - UnitSearcher(Unit* & result, Check & check) : i_object(result),i_check(check) {} - - void Visit(CreatureMapType &m); - void Visit(PlayerMapType &m); - - template void Visit(GridRefManager &) {} - }; - - // Last accepted by Check Unit if any (Check can change requirements at each call) - template - struct MANGOS_DLL_DECL UnitLastSearcher - { - Unit* &i_object; - Check & i_check; - - UnitLastSearcher(Unit* & result, Check & check) : i_object(result),i_check(check) {} - - void Visit(CreatureMapType &m); - void Visit(PlayerMapType &m); - - template void Visit(GridRefManager &) {} - }; - - // All accepted by Check units if any - template - struct MANGOS_DLL_DECL UnitListSearcher - { - std::list &i_objects; - Check& i_check; - - UnitListSearcher(std::list &objects, Check & check) : i_objects(objects),i_check(check) {} - - void Visit(PlayerMapType &m); - void Visit(CreatureMapType &m); - - template void Visit(GridRefManager &) {} - }; - - // Creature searchers - - template - struct MANGOS_DLL_DECL CreatureSearcher - { - Creature* &i_object; - Check & i_check; - - CreatureSearcher(Creature* & result, Check & check) : i_object(result),i_check(check) {} - - void Visit(CreatureMapType &m); - - template void Visit(GridRefManager &) {} - }; - - // Last accepted by Check Creature if any (Check can change requirements at each call) - template - struct MANGOS_DLL_DECL CreatureLastSearcher - { - Creature* &i_object; - Check & i_check; - - CreatureLastSearcher(Creature* & result, Check & check) : i_object(result),i_check(check) {} - - void Visit(CreatureMapType &m); - - template void Visit(GridRefManager &) {} - }; - - template - struct MANGOS_DLL_DECL CreatureListSearcher - { - std::list &i_objects; - Check& i_check; - - CreatureListSearcher(std::list &objects, Check & check) : i_objects(objects),i_check(check) {} - - void Visit(CreatureMapType &m); - - template void Visit(GridRefManager &) {} - }; - - // Player searchers - - template - struct MANGOS_DLL_DECL PlayerSearcher - { - Player* &i_object; - Check & i_check; - - PlayerSearcher(Player* & result, Check & check) : i_object(result),i_check(check) {} - - void Visit(PlayerMapType &m); - - template void Visit(GridRefManager &) {} - }; - - template - struct MANGOS_DLL_DECL PlayerWorker - { - Do& i_do; - - explicit PlayerWorker(Do& _do) : i_do(_do) {} - - void Visit(PlayerMapType &m) - { - for(PlayerMapType::iterator itr=m.begin(); itr != m.end(); ++itr) - i_do(itr->getSource()); - } - - template void Visit(GridRefManager &) {} - }; - - // CHECKS && DO classes - - // WorldObject check classes - class CannibalizeObjectCheck - { - public: - CannibalizeObjectCheck(Unit* funit, float range) : i_funit(funit), i_range(range) {} - bool operator()(Player* u) - { - if( i_funit->IsFriendlyTo(u) || u->isAlive() || u->isInFlight() ) - return false; - - if(i_funit->IsWithinDistInMap(u, i_range) ) - return true; - - return false; - } - bool operator()(Corpse* u); - bool operator()(Creature* u) - { - if( i_funit->IsFriendlyTo(u) || u->isAlive() || u->isInFlight() || - (u->GetCreatureTypeMask() & CREATURE_TYPEMASK_HUMANOID_OR_UNDEAD)==0) - return false; - - if(i_funit->IsWithinDistInMap(u, i_range) ) - return true; - - return false; - } - template bool operator()(NOT_INTERESTED* u) { return false; } - private: - Unit* const i_funit; - float i_range; - }; - - // WorldObject do classes - - class RespawnDo - { - public: - RespawnDo() {} - void operator()(Creature* u) const { u->Respawn(); } - void operator()(GameObject* u) const { u->Respawn(); } - void operator()(WorldObject*) const {} - void operator()(Corpse*) const {} - }; - - // GameObject checks - - class GameObjectFocusCheck - { - public: - GameObjectFocusCheck(Unit const* unit,uint32 focusId) : i_unit(unit), i_focusId(focusId) {} - bool operator()(GameObject* go) const - { - if(go->GetGOInfo()->type != GAMEOBJECT_TYPE_SPELL_FOCUS) - return false; - - if(go->GetGOInfo()->spellFocus.focusId != i_focusId) - return false; - - float dist = go->GetGOInfo()->spellFocus.dist; - - return go->IsWithinDistInMap(i_unit, dist); - } - private: - Unit const* i_unit; - uint32 i_focusId; - }; - - // Find the nearest Fishing hole and return true only if source object is in range of hole - class NearestGameObjectFishingHole - { - public: - NearestGameObjectFishingHole(WorldObject const& obj, float range) : i_obj(obj), i_range(range) {} - bool operator()(GameObject* go) - { - if(go->GetGOInfo()->type == GAMEOBJECT_TYPE_FISHINGHOLE && go->isSpawned() && i_obj.IsWithinDistInMap(go, i_range) && i_obj.IsWithinDistInMap(go, go->GetGOInfo()->fishinghole.radius)) - { - i_range = i_obj.GetDistance(go); - return true; - } - return false; - } - float GetLastRange() const { return i_range; } - private: - WorldObject const& i_obj; - float i_range; - - // prevent clone - NearestGameObjectFishingHole(NearestGameObjectFishingHole const&); - }; - - // Success at unit in range, range update for next check (this can be use with GameobjectLastSearcher to find nearest GO) - class NearestGameObjectEntryInObjectRangeCheck - { - public: - NearestGameObjectEntryInObjectRangeCheck(WorldObject const& obj,uint32 entry, float range) : i_obj(obj), i_entry(entry), i_range(range) {} - bool operator()(GameObject* go) - { - if(go->GetEntry() == i_entry && i_obj.IsWithinDistInMap(go, i_range)) - { - i_range = i_obj.GetDistance(go); // use found GO range as new range limit for next check - return true; - } - return false; - } - float GetLastRange() const { return i_range; } - private: - WorldObject const& i_obj; - uint32 i_entry; - float i_range; - - // prevent clone this object - NearestGameObjectEntryInObjectRangeCheck(NearestGameObjectEntryInObjectRangeCheck const&); - }; - - class GameObjectWithDbGUIDCheck - { - public: - GameObjectWithDbGUIDCheck(WorldObject const& obj,uint32 db_guid) : i_obj(obj), i_db_guid(db_guid) {} - bool operator()(GameObject const* go) const - { - return go->GetDBTableGUIDLow() == i_db_guid; - } - private: - WorldObject const& i_obj; - uint32 i_db_guid; - }; - - // Unit checks - - class AnyUnfriendlyUnitInObjectRangeCheck - { - public: - AnyUnfriendlyUnitInObjectRangeCheck(WorldObject const* obj, Unit const* funit, float range) : i_obj(obj), i_funit(funit), i_range(range) {} - bool operator()(Unit* u) - { - if(u->isAlive() && i_obj->IsWithinDistInMap(u, i_range) && !i_funit->IsFriendlyTo(u)) - return true; - else - return false; - } - private: - WorldObject const* i_obj; - Unit const* i_funit; - float i_range; - }; - - class AnyFriendlyUnitInObjectRangeCheck - { - public: - AnyFriendlyUnitInObjectRangeCheck(WorldObject const* obj, Unit const* funit, float range) : i_obj(obj), i_funit(funit), i_range(range) {} - bool operator()(Unit* u) - { - if(u->isAlive() && i_obj->IsWithinDistInMap(u, i_range) && i_funit->IsFriendlyTo(u)) - return true; - else - return false; - } - private: - WorldObject const* i_obj; - Unit const* i_funit; - float i_range; - }; - - class AnyUnitInObjectRangeCheck - { - public: - AnyUnitInObjectRangeCheck(WorldObject const* obj, float range) : i_obj(obj), i_range(range) {} - bool operator()(Unit* u) - { - if(u->isAlive() && i_obj->IsWithinDistInMap(u, i_range)) - return true; - - return false; - } - private: - WorldObject const* i_obj; - float i_range; - }; - - // Success at unit in range, range update for next check (this can be use with UnitLastSearcher to find nearest unit) - class NearestAttackableUnitInObjectRangeCheck - { - public: - NearestAttackableUnitInObjectRangeCheck(WorldObject const* obj, Unit const* funit, float range) : i_obj(obj), i_funit(funit), i_range(range) {} - bool operator()(Unit* u) - { - if( u->isTargetableForAttack() && i_obj->IsWithinDistInMap(u, i_range) && - !i_funit->IsFriendlyTo(u) && u->isVisibleForOrDetect(i_funit,false) ) - { - i_range = i_obj->GetDistance(u); // use found unit range as new range limit for next check - return true; - } - - return false; - } - private: - WorldObject const* i_obj; - Unit const* i_funit; - float i_range; - - // prevent clone this object - NearestAttackableUnitInObjectRangeCheck(NearestAttackableUnitInObjectRangeCheck const&); - }; - - class AnyAoETargetUnitInObjectRangeCheck - { - public: - AnyAoETargetUnitInObjectRangeCheck(WorldObject const* obj, Unit const* funit, float range) - : i_obj(obj), i_funit(funit), i_range(range) - { - Unit const* check = i_funit; - Unit const* owner = i_funit->GetOwner(); - if(owner) - check = owner; - i_targetForPlayer = ( check->GetTypeId()==TYPEID_PLAYER ); - } - bool operator()(Unit* u) - { - // Check contains checks for: live, non-selectable, non-attackable flags, flight check and GM check, ignore totems - if (!u->isTargetableForAttack()) - return false; - if(u->GetTypeId()==TYPEID_UNIT && ((Creature*)u)->isTotem()) - return false; - - if(( i_targetForPlayer ? !i_funit->IsFriendlyTo(u) : i_funit->IsHostileTo(u) )&& i_obj->IsWithinDistInMap(u, i_range)) - return true; - - return false; - } - private: - bool i_targetForPlayer; - WorldObject const* i_obj; - Unit const* i_funit; - float i_range; - }; - - struct AnyDeadUnitCheck - { - bool operator()(Unit* u) { return !u->isAlive(); } - }; - - struct AnyStealthedCheck - { - bool operator()(Unit* u) { return u->GetVisibility()==VISIBILITY_GROUP_STEALTH; } - }; - - // Creature checks - - class InAttackDistanceFromAnyHostileCreatureCheck - { - public: - explicit InAttackDistanceFromAnyHostileCreatureCheck(Unit* funit) : i_funit(funit) {} - bool operator()(Creature* u) - { - if(u->isAlive() && u->IsHostileTo(i_funit) && i_funit->IsWithinDistInMap(u, u->GetAttackDistance(i_funit))) - return true; - - return false; - } - private: - Unit* const i_funit; - }; - - class AnyAssistCreatureInRangeCheck - { - public: - AnyAssistCreatureInRangeCheck(Unit* funit, Unit* enemy, float range) - : i_funit(funit), i_enemy(enemy), i_range(range) - { - } - bool operator()(Creature* u) - { - if(u == i_funit) - return false; - - // we don't need help from zombies :) - if( !u->isAlive() ) - return false; - - // skip fighting creature - if( u->isInCombat() ) - return false; - - // only from same creature faction - if(u->getFaction() != i_funit->getFaction() ) - return false; - - // only free creature - if( u->GetCharmerOrOwnerGUID() ) - return false; - - // too far - if( !i_funit->IsWithinDistInMap(u, i_range) ) - return false; - - // skip non hostile to caster enemy creatures - if( !u->IsHostileTo(i_enemy) ) - return false; - - // only if see assisted creature - if(!u->IsWithinLOSInMap(i_funit) ) - return false; - - return true; - } - private: - Unit* const i_funit; - Unit* const i_enemy; - float i_range; - }; - - // Success at unit in range, range update for next check (this can be use with CreatureLastSearcher to find nearest creature) - class NearestCreatureEntryWithLiveStateInObjectRangeCheck - { - public: - NearestCreatureEntryWithLiveStateInObjectRangeCheck(WorldObject const& obj,uint32 entry, bool alive, float range) - : i_obj(obj), i_entry(entry), i_alive(alive), i_range(range) {} - - bool operator()(Creature* u) - { - if(u->GetEntry() == i_entry && u->isAlive()==i_alive && i_obj.IsWithinDistInMap(u, i_range)) - { - i_range = i_obj.GetDistance(u); // use found unit range as new range limit for next check - return true; - } - return false; - } - float GetLastRange() const { return i_range; } - private: - WorldObject const& i_obj; - uint32 i_entry; - bool i_alive; - float i_range; - - // prevent clone this object - NearestCreatureEntryWithLiveStateInObjectRangeCheck(NearestCreatureEntryWithLiveStateInObjectRangeCheck const&); - }; - - class AnyPlayerInObjectRangeCheck - { - public: - AnyPlayerInObjectRangeCheck(WorldObject const* obj, float range) : i_obj(obj), i_range(range) {} - bool operator()(Player* u) - { - if(u->isAlive() && i_obj->IsWithinDistInMap(u, i_range)) - return true; - - return false; - } - private: - WorldObject const* i_obj; - float i_range; - }; - - #ifndef WIN32 - template<> void PlayerRelocationNotifier::Visit(CreatureMapType &); - template<> void PlayerRelocationNotifier::Visit(PlayerMapType &); - template<> void CreatureRelocationNotifier::Visit(PlayerMapType &); - template<> void CreatureRelocationNotifier::Visit(CreatureMapType &); - template<> inline void DynamicObjectUpdater::Visit(CreatureMapType &); - template<> inline void DynamicObjectUpdater::Visit(PlayerMapType &); - #endif -} -#endif +/* + * Copyright (C) 2005-2008 MaNGOS + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef MANGOS_GRIDNOTIFIERS_H +#define MANGOS_GRIDNOTIFIERS_H + +#include "ObjectGridLoader.h" +#include "ByteBuffer.h" +#include "UpdateData.h" +#include + +#include "Corpse.h" +#include "Object.h" +#include "DynamicObject.h" +#include "GameObject.h" +#include "Player.h" +#include "Unit.h" + +class Player; +//class Map; + +namespace MaNGOS +{ + + struct MANGOS_DLL_DECL PlayerNotifier + { + explicit PlayerNotifier(Player &pl) : i_player(pl) {} + void Visit(PlayerMapType &); + template void Visit(GridRefManager &) {} + Player &i_player; + }; + + struct MANGOS_DLL_DECL VisibleNotifier + { + Player &i_player; + UpdateData i_data; + UpdateDataMapType i_data_updates; + Player::ClientGUIDs i_clientGUIDs; + std::set i_visibleNow; + + explicit VisibleNotifier(Player &player) : i_player(player),i_clientGUIDs(player.m_clientGUIDs) {} + template void Visit(GridRefManager &m); + void Visit(PlayerMapType &); + void Notify(void); + }; + + struct MANGOS_DLL_DECL VisibleChangesNotifier + { + WorldObject &i_object; + + explicit VisibleChangesNotifier(WorldObject &object) : i_object(object) {} + template void Visit(GridRefManager &) {} + void Visit(PlayerMapType &); + }; + + struct MANGOS_DLL_DECL GridUpdater + { + GridType &i_grid; + uint32 i_timeDiff; + GridUpdater(GridType &grid, uint32 diff) : i_grid(grid), i_timeDiff(diff) {} + + template void updateObjects(GridRefManager &m) + { + for(typename GridRefManager::iterator iter = m.begin(); iter != m.end(); ++iter) + iter->getSource()->Update(i_timeDiff); + } + + void Visit(PlayerMapType &m) { updateObjects(m); } + void Visit(CreatureMapType &m){ updateObjects(m); } + void Visit(GameObjectMapType &m) { updateObjects(m); } + void Visit(DynamicObjectMapType &m) { updateObjects(m); } + void Visit(CorpseMapType &m) { updateObjects(m); } + }; + + struct MANGOS_DLL_DECL MessageDeliverer + { + Player &i_player; + WorldPacket *i_message; + bool i_toSelf; + MessageDeliverer(Player &pl, WorldPacket *msg, bool to_self) : i_player(pl), i_message(msg), i_toSelf(to_self) {} + void Visit(PlayerMapType &m); + template void Visit(GridRefManager &) {} + }; + + struct MANGOS_DLL_DECL ObjectMessageDeliverer + { + WorldPacket *i_message; + explicit ObjectMessageDeliverer(WorldPacket *msg) : i_message(msg) {} + void Visit(PlayerMapType &m); + template void Visit(GridRefManager &) {} + }; + + struct MANGOS_DLL_DECL MessageDistDeliverer + { + Player &i_player; + WorldPacket *i_message; + bool i_toSelf; + bool i_ownTeamOnly; + float i_dist; + MessageDistDeliverer(Player &pl, WorldPacket *msg, float dist, bool to_self, bool ownTeamOnly) : i_player(pl), i_message(msg), i_dist(dist), i_toSelf(to_self), i_ownTeamOnly(ownTeamOnly) {} + void Visit(PlayerMapType &m); + template void Visit(GridRefManager &) {} + }; + + struct MANGOS_DLL_DECL ObjectMessageDistDeliverer + { + WorldObject &i_object; + WorldPacket *i_message; + float i_dist; + ObjectMessageDistDeliverer(WorldObject &obj, WorldPacket *msg, float dist) : i_object(obj), i_message(msg), i_dist(dist) {} + void Visit(PlayerMapType &m); + template void Visit(GridRefManager &) {} + }; + + struct MANGOS_DLL_DECL ObjectUpdater + { + uint32 i_timeDiff; + explicit ObjectUpdater(const uint32 &diff) : i_timeDiff(diff) {} + template void Visit(GridRefManager &m); + void Visit(PlayerMapType &) {} + void Visit(CorpseMapType &) {} + void Visit(CreatureMapType &); + }; + + template + struct MANGOS_DLL_DECL ObjectAccessorNotifier + { + T *& i_object; + + uint64 i_id; + ObjectAccessorNotifier(T * &obj, uint64 id) : i_object(obj), i_id(id) + { + i_object = NULL; + } + + void Visit(GridRefManager &m ) + { + if( i_object == NULL ) + { + GridRefManager *iter = m.find(i_id); + if( iter != m.end() ) + { + assert( iter->second != NULL ); + i_object = iter->second; + } + } + } + + template void Visit(GridRefManager &) {} + }; + + struct MANGOS_DLL_DECL PlayerRelocationNotifier + { + Player &i_player; + PlayerRelocationNotifier(Player &pl) : i_player(pl) {} + template void Visit(GridRefManager &) {} + void Visit(PlayerMapType &); + void Visit(CreatureMapType &); + }; + + struct MANGOS_DLL_DECL CreatureRelocationNotifier + { + Creature &i_creature; + CreatureRelocationNotifier(Creature &c) : i_creature(c) {} + template void Visit(GridRefManager &) {} + #ifdef WIN32 + template<> void Visit(PlayerMapType &); + #endif + }; + + struct MANGOS_DLL_DECL DynamicObjectUpdater + { + DynamicObject &i_dynobject; + Unit* i_check; + DynamicObjectUpdater(DynamicObject &dynobject, Unit* caster) : i_dynobject(dynobject) + { + i_check = caster; + Unit* owner = i_check->GetOwner(); + if(owner) + i_check = owner; + } + + template inline void Visit(GridRefManager &) {} + #ifdef WIN32 + template<> inline void Visit(PlayerMapType &); + template<> inline void Visit(CreatureMapType &); + #endif + + void VisitHelper(Unit* target); + }; + + // SEARCHERS & LIST SEARCHERS & WORKERS + + // WorldObject searchers & workers + + template + struct MANGOS_DLL_DECL WorldObjectSearcher + { + WorldObject* &i_object; + Check &i_check; + + WorldObjectSearcher(WorldObject* & result, Check& check) : i_object(result),i_check(check) {} + + void Visit(GameObjectMapType &m); + void Visit(PlayerMapType &m); + void Visit(CreatureMapType &m); + void Visit(CorpseMapType &m); + void Visit(DynamicObjectMapType &m); + + template void Visit(GridRefManager &) {} + }; + + template + struct MANGOS_DLL_DECL WorldObjectListSearcher + { + std::list &i_objects; + Check& i_check; + + WorldObjectListSearcher(std::list &objects, Check & check) : i_objects(objects),i_check(check) {} + + void Visit(PlayerMapType &m); + void Visit(CreatureMapType &m); + void Visit(CorpseMapType &m); + void Visit(GameObjectMapType &m); + void Visit(DynamicObjectMapType &m); + + template void Visit(GridRefManager &) {} + }; + + template + struct MANGOS_DLL_DECL WorldObjectWorker + { + Do const& i_do; + + explicit WorldObjectWorker(Do const& _do) : i_do(_do) {} + + void Visit(GameObjectMapType &m) + { + for(GameObjectMapType::iterator itr=m.begin(); itr != m.end(); ++itr) + i_do(itr->getSource()); + } + + void Visit(PlayerMapType &m) + { + for(PlayerMapType::iterator itr=m.begin(); itr != m.end(); ++itr) + i_do(itr->getSource()); + } + void Visit(CreatureMapType &m) + { + for(CreatureMapType::iterator itr=m.begin(); itr != m.end(); ++itr) + i_do(itr->getSource()); + } + + void Visit(CorpseMapType &m) + { + for(CorpseMapType::iterator itr=m.begin(); itr != m.end(); ++itr) + i_do(itr->getSource()); + } + + void Visit(DynamicObjectMapType &m) + { + for(DynamicObjectMapType::iterator itr=m.begin(); itr != m.end(); ++itr) + i_do(itr->getSource()); + } + + template void Visit(GridRefManager &) {} + }; + + // Gameobject searchers + + template + struct MANGOS_DLL_DECL GameObjectSearcher + { + GameObject* &i_object; + Check &i_check; + + GameObjectSearcher(GameObject* & result, Check& check) : i_object(result),i_check(check) {} + + void Visit(GameObjectMapType &m); + + template void Visit(GridRefManager &) {} + }; + + // Last accepted by Check GO if any (Check can change requirements at each call) + template + struct MANGOS_DLL_DECL GameObjectLastSearcher + { + GameObject* &i_object; + Check& i_check; + + GameObjectLastSearcher(GameObject* & result, Check& check) : i_object(result),i_check(check) {} + + void Visit(GameObjectMapType &m); + + template void Visit(GridRefManager &) {} + }; + + template + struct MANGOS_DLL_DECL GameObjectListSearcher + { + std::list &i_objects; + Check& i_check; + + GameObjectListSearcher(std::list &objects, Check & check) : i_objects(objects),i_check(check) {} + + void Visit(GameObjectMapType &m); + + template void Visit(GridRefManager &) {} + }; + + // Unit searchers + + // First accepted by Check Unit if any + template + struct MANGOS_DLL_DECL UnitSearcher + { + Unit* &i_object; + Check & i_check; + + UnitSearcher(Unit* & result, Check & check) : i_object(result),i_check(check) {} + + void Visit(CreatureMapType &m); + void Visit(PlayerMapType &m); + + template void Visit(GridRefManager &) {} + }; + + // Last accepted by Check Unit if any (Check can change requirements at each call) + template + struct MANGOS_DLL_DECL UnitLastSearcher + { + Unit* &i_object; + Check & i_check; + + UnitLastSearcher(Unit* & result, Check & check) : i_object(result),i_check(check) {} + + void Visit(CreatureMapType &m); + void Visit(PlayerMapType &m); + + template void Visit(GridRefManager &) {} + }; + + // All accepted by Check units if any + template + struct MANGOS_DLL_DECL UnitListSearcher + { + std::list &i_objects; + Check& i_check; + + UnitListSearcher(std::list &objects, Check & check) : i_objects(objects),i_check(check) {} + + void Visit(PlayerMapType &m); + void Visit(CreatureMapType &m); + + template void Visit(GridRefManager &) {} + }; + + // Creature searchers + + template + struct MANGOS_DLL_DECL CreatureSearcher + { + Creature* &i_object; + Check & i_check; + + CreatureSearcher(Creature* & result, Check & check) : i_object(result),i_check(check) {} + + void Visit(CreatureMapType &m); + + template void Visit(GridRefManager &) {} + }; + + // Last accepted by Check Creature if any (Check can change requirements at each call) + template + struct MANGOS_DLL_DECL CreatureLastSearcher + { + Creature* &i_object; + Check & i_check; + + CreatureLastSearcher(Creature* & result, Check & check) : i_object(result),i_check(check) {} + + void Visit(CreatureMapType &m); + + template void Visit(GridRefManager &) {} + }; + + template + struct MANGOS_DLL_DECL CreatureListSearcher + { + std::list &i_objects; + Check& i_check; + + CreatureListSearcher(std::list &objects, Check & check) : i_objects(objects),i_check(check) {} + + void Visit(CreatureMapType &m); + + template void Visit(GridRefManager &) {} + }; + + // Player searchers + + template + struct MANGOS_DLL_DECL PlayerSearcher + { + Player* &i_object; + Check & i_check; + + PlayerSearcher(Player* & result, Check & check) : i_object(result),i_check(check) {} + + void Visit(PlayerMapType &m); + + template void Visit(GridRefManager &) {} + }; + + template + struct MANGOS_DLL_DECL PlayerWorker + { + Do& i_do; + + explicit PlayerWorker(Do& _do) : i_do(_do) {} + + void Visit(PlayerMapType &m) + { + for(PlayerMapType::iterator itr=m.begin(); itr != m.end(); ++itr) + i_do(itr->getSource()); + } + + template void Visit(GridRefManager &) {} + }; + + // CHECKS && DO classes + + // WorldObject check classes + class CannibalizeObjectCheck + { + public: + CannibalizeObjectCheck(Unit* funit, float range) : i_funit(funit), i_range(range) {} + bool operator()(Player* u) + { + if( i_funit->IsFriendlyTo(u) || u->isAlive() || u->isInFlight() ) + return false; + + if(i_funit->IsWithinDistInMap(u, i_range) ) + return true; + + return false; + } + bool operator()(Corpse* u); + bool operator()(Creature* u) + { + if( i_funit->IsFriendlyTo(u) || u->isAlive() || u->isInFlight() || + (u->GetCreatureTypeMask() & CREATURE_TYPEMASK_HUMANOID_OR_UNDEAD)==0) + return false; + + if(i_funit->IsWithinDistInMap(u, i_range) ) + return true; + + return false; + } + template bool operator()(NOT_INTERESTED* u) { return false; } + private: + Unit* const i_funit; + float i_range; + }; + + // WorldObject do classes + + class RespawnDo + { + public: + RespawnDo() {} + void operator()(Creature* u) const { u->Respawn(); } + void operator()(GameObject* u) const { u->Respawn(); } + void operator()(WorldObject*) const {} + void operator()(Corpse*) const {} + }; + + // GameObject checks + + class GameObjectFocusCheck + { + public: + GameObjectFocusCheck(Unit const* unit,uint32 focusId) : i_unit(unit), i_focusId(focusId) {} + bool operator()(GameObject* go) const + { + if(go->GetGOInfo()->type != GAMEOBJECT_TYPE_SPELL_FOCUS) + return false; + + if(go->GetGOInfo()->spellFocus.focusId != i_focusId) + return false; + + float dist = go->GetGOInfo()->spellFocus.dist; + + return go->IsWithinDistInMap(i_unit, dist); + } + private: + Unit const* i_unit; + uint32 i_focusId; + }; + + // Find the nearest Fishing hole and return true only if source object is in range of hole + class NearestGameObjectFishingHole + { + public: + NearestGameObjectFishingHole(WorldObject const& obj, float range) : i_obj(obj), i_range(range) {} + bool operator()(GameObject* go) + { + if(go->GetGOInfo()->type == GAMEOBJECT_TYPE_FISHINGHOLE && go->isSpawned() && i_obj.IsWithinDistInMap(go, i_range) && i_obj.IsWithinDistInMap(go, go->GetGOInfo()->fishinghole.radius)) + { + i_range = i_obj.GetDistance(go); + return true; + } + return false; + } + float GetLastRange() const { return i_range; } + private: + WorldObject const& i_obj; + float i_range; + + // prevent clone + NearestGameObjectFishingHole(NearestGameObjectFishingHole const&); + }; + + // Success at unit in range, range update for next check (this can be use with GameobjectLastSearcher to find nearest GO) + class NearestGameObjectEntryInObjectRangeCheck + { + public: + NearestGameObjectEntryInObjectRangeCheck(WorldObject const& obj,uint32 entry, float range) : i_obj(obj), i_entry(entry), i_range(range) {} + bool operator()(GameObject* go) + { + if(go->GetEntry() == i_entry && i_obj.IsWithinDistInMap(go, i_range)) + { + i_range = i_obj.GetDistance(go); // use found GO range as new range limit for next check + return true; + } + return false; + } + float GetLastRange() const { return i_range; } + private: + WorldObject const& i_obj; + uint32 i_entry; + float i_range; + + // prevent clone this object + NearestGameObjectEntryInObjectRangeCheck(NearestGameObjectEntryInObjectRangeCheck const&); + }; + + class GameObjectWithDbGUIDCheck + { + public: + GameObjectWithDbGUIDCheck(WorldObject const& obj,uint32 db_guid) : i_obj(obj), i_db_guid(db_guid) {} + bool operator()(GameObject const* go) const + { + return go->GetDBTableGUIDLow() == i_db_guid; + } + private: + WorldObject const& i_obj; + uint32 i_db_guid; + }; + + // Unit checks + + class AnyUnfriendlyUnitInObjectRangeCheck + { + public: + AnyUnfriendlyUnitInObjectRangeCheck(WorldObject const* obj, Unit const* funit, float range) : i_obj(obj), i_funit(funit), i_range(range) {} + bool operator()(Unit* u) + { + if(u->isAlive() && i_obj->IsWithinDistInMap(u, i_range) && !i_funit->IsFriendlyTo(u)) + return true; + else + return false; + } + private: + WorldObject const* i_obj; + Unit const* i_funit; + float i_range; + }; + + class AnyFriendlyUnitInObjectRangeCheck + { + public: + AnyFriendlyUnitInObjectRangeCheck(WorldObject const* obj, Unit const* funit, float range) : i_obj(obj), i_funit(funit), i_range(range) {} + bool operator()(Unit* u) + { + if(u->isAlive() && i_obj->IsWithinDistInMap(u, i_range) && i_funit->IsFriendlyTo(u)) + return true; + else + return false; + } + private: + WorldObject const* i_obj; + Unit const* i_funit; + float i_range; + }; + + class AnyUnitInObjectRangeCheck + { + public: + AnyUnitInObjectRangeCheck(WorldObject const* obj, float range) : i_obj(obj), i_range(range) {} + bool operator()(Unit* u) + { + if(u->isAlive() && i_obj->IsWithinDistInMap(u, i_range)) + return true; + + return false; + } + private: + WorldObject const* i_obj; + float i_range; + }; + + // Success at unit in range, range update for next check (this can be use with UnitLastSearcher to find nearest unit) + class NearestAttackableUnitInObjectRangeCheck + { + public: + NearestAttackableUnitInObjectRangeCheck(WorldObject const* obj, Unit const* funit, float range) : i_obj(obj), i_funit(funit), i_range(range) {} + bool operator()(Unit* u) + { + if( u->isTargetableForAttack() && i_obj->IsWithinDistInMap(u, i_range) && + !i_funit->IsFriendlyTo(u) && u->isVisibleForOrDetect(i_funit,false) ) + { + i_range = i_obj->GetDistance(u); // use found unit range as new range limit for next check + return true; + } + + return false; + } + private: + WorldObject const* i_obj; + Unit const* i_funit; + float i_range; + + // prevent clone this object + NearestAttackableUnitInObjectRangeCheck(NearestAttackableUnitInObjectRangeCheck const&); + }; + + class AnyAoETargetUnitInObjectRangeCheck + { + public: + AnyAoETargetUnitInObjectRangeCheck(WorldObject const* obj, Unit const* funit, float range) + : i_obj(obj), i_funit(funit), i_range(range) + { + Unit const* check = i_funit; + Unit const* owner = i_funit->GetOwner(); + if(owner) + check = owner; + i_targetForPlayer = ( check->GetTypeId()==TYPEID_PLAYER ); + } + bool operator()(Unit* u) + { + // Check contains checks for: live, non-selectable, non-attackable flags, flight check and GM check, ignore totems + if (!u->isTargetableForAttack()) + return false; + if(u->GetTypeId()==TYPEID_UNIT && ((Creature*)u)->isTotem()) + return false; + + if(( i_targetForPlayer ? !i_funit->IsFriendlyTo(u) : i_funit->IsHostileTo(u) )&& i_obj->IsWithinDistInMap(u, i_range)) + return true; + + return false; + } + private: + bool i_targetForPlayer; + WorldObject const* i_obj; + Unit const* i_funit; + float i_range; + }; + + struct AnyDeadUnitCheck + { + bool operator()(Unit* u) { return !u->isAlive(); } + }; + + struct AnyStealthedCheck + { + bool operator()(Unit* u) { return u->GetVisibility()==VISIBILITY_GROUP_STEALTH; } + }; + + // Creature checks + + class InAttackDistanceFromAnyHostileCreatureCheck + { + public: + explicit InAttackDistanceFromAnyHostileCreatureCheck(Unit* funit) : i_funit(funit) {} + bool operator()(Creature* u) + { + if(u->isAlive() && u->IsHostileTo(i_funit) && i_funit->IsWithinDistInMap(u, u->GetAttackDistance(i_funit))) + return true; + + return false; + } + private: + Unit* const i_funit; + }; + + class AnyAssistCreatureInRangeCheck + { + public: + AnyAssistCreatureInRangeCheck(Unit* funit, Unit* enemy, float range) + : i_funit(funit), i_enemy(enemy), i_range(range) + { + } + bool operator()(Creature* u) + { + if(u == i_funit) + return false; + + // we don't need help from zombies :) + if( !u->isAlive() ) + return false; + + // skip fighting creature + if( u->isInCombat() ) + return false; + + // only from same creature faction + if(u->getFaction() != i_funit->getFaction() ) + return false; + + // only free creature + if( u->GetCharmerOrOwnerGUID() ) + return false; + + // too far + if( !i_funit->IsWithinDistInMap(u, i_range) ) + return false; + + // skip non hostile to caster enemy creatures + if( !u->IsHostileTo(i_enemy) ) + return false; + + // only if see assisted creature + if(!u->IsWithinLOSInMap(i_funit) ) + return false; + + return true; + } + private: + Unit* const i_funit; + Unit* const i_enemy; + float i_range; + }; + + // Success at unit in range, range update for next check (this can be use with CreatureLastSearcher to find nearest creature) + class NearestCreatureEntryWithLiveStateInObjectRangeCheck + { + public: + NearestCreatureEntryWithLiveStateInObjectRangeCheck(WorldObject const& obj,uint32 entry, bool alive, float range) + : i_obj(obj), i_entry(entry), i_alive(alive), i_range(range) {} + + bool operator()(Creature* u) + { + if(u->GetEntry() == i_entry && u->isAlive()==i_alive && i_obj.IsWithinDistInMap(u, i_range)) + { + i_range = i_obj.GetDistance(u); // use found unit range as new range limit for next check + return true; + } + return false; + } + float GetLastRange() const { return i_range; } + private: + WorldObject const& i_obj; + uint32 i_entry; + bool i_alive; + float i_range; + + // prevent clone this object + NearestCreatureEntryWithLiveStateInObjectRangeCheck(NearestCreatureEntryWithLiveStateInObjectRangeCheck const&); + }; + + class AnyPlayerInObjectRangeCheck + { + public: + AnyPlayerInObjectRangeCheck(WorldObject const* obj, float range) : i_obj(obj), i_range(range) {} + bool operator()(Player* u) + { + if(u->isAlive() && i_obj->IsWithinDistInMap(u, i_range)) + return true; + + return false; + } + private: + WorldObject const* i_obj; + float i_range; + }; + + #ifndef WIN32 + template<> void PlayerRelocationNotifier::Visit(CreatureMapType &); + template<> void PlayerRelocationNotifier::Visit(PlayerMapType &); + template<> void CreatureRelocationNotifier::Visit(PlayerMapType &); + template<> void CreatureRelocationNotifier::Visit(CreatureMapType &); + template<> inline void DynamicObjectUpdater::Visit(CreatureMapType &); + template<> inline void DynamicObjectUpdater::Visit(PlayerMapType &); + #endif +} +#endif diff --git a/src/game/GuardAI.cpp b/src/game/GuardAI.cpp index fffbb7d4000..32598e8a3d3 100644 --- a/src/game/GuardAI.cpp +++ b/src/game/GuardAI.cpp @@ -1,150 +1,154 @@ -/* - * Copyright (C) 2005-2008 MaNGOS - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "GuardAI.h" -#include "Errors.h" -#include "Creature.h" -#include "Player.h" -#include "ObjectAccessor.h" -#include "World.h" - -int GuardAI::Permissible(const Creature *creature) -{ - if( creature->isGuard()) - return PERMIT_BASE_SPECIAL; - - return PERMIT_BASE_NO; -} - -GuardAI::GuardAI(Creature &c) : i_creature(c), i_victimGuid(0), i_state(STATE_NORMAL), i_tracker(TIME_INTERVAL_LOOK) -{ -} - -void GuardAI::MoveInLineOfSight(Unit *u) -{ - if( !i_creature.getVictim() && u->isTargetableForAttack() && - ( u->IsHostileToPlayers() || i_creature.IsHostileTo(u) /*|| u->getVictim() && i_creature.IsFriendlyTo(u->getVictim())*/ ) && - u->isInAccessablePlaceFor(&i_creature)) - { - float attackRadius = i_creature.GetAttackDistance(u); - if(i_creature.IsWithinDistInMap(u,attackRadius) && i_creature.GetDistanceZ(u) <= CREATURE_Z_ATTACK_RANGE) - { - //Need add code to let guard support player - AttackStart(u); - u->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); - } - } -} - -void GuardAI::EnterEvadeMode() -{ - if( !i_creature.isAlive() ) - { - DEBUG_LOG("Creature stopped attacking because he's dead [guid=%u]", i_creature.GetGUIDLow()); - i_creature.StopMoving(); - i_creature.GetMotionMaster()->MoveIdle(); - - i_state = STATE_NORMAL; - - i_victimGuid = 0; - i_creature.CombatStop(); - i_creature.DeleteThreatList(); - return; - } - - Unit* victim = ObjectAccessor::GetUnit(i_creature, i_victimGuid ); - - if( !victim ) - { - DEBUG_LOG("Creature stopped attacking because victim is non exist [guid=%u]", i_creature.GetGUIDLow()); - } - else if( !victim ->isAlive() ) - { - DEBUG_LOG("Creature stopped attacking because victim is dead [guid=%u]", i_creature.GetGUIDLow()); - } - else if( victim ->HasStealthAura() ) - { - DEBUG_LOG("Creature stopped attacking because victim is using stealth [guid=%u]", i_creature.GetGUIDLow()); - } - else if( victim ->isInFlight() ) - { - DEBUG_LOG("Creature stopped attacking because victim is flying away [guid=%u]", i_creature.GetGUIDLow()); - } - else - { - DEBUG_LOG("Creature stopped attacking because victim outran him [guid=%u]", i_creature.GetGUIDLow()); - } - - i_creature.RemoveAllAuras(); - i_creature.DeleteThreatList(); - i_victimGuid = 0; - i_creature.CombatStop(); - i_state = STATE_NORMAL; - - // Remove TargetedMovementGenerator from MotionMaster stack list, and add HomeMovementGenerator instead - if( i_creature.GetMotionMaster()->GetCurrentMovementGeneratorType() == TARGETED_MOTION_TYPE ) - i_creature.GetMotionMaster()->MoveTargetedHome(); -} - -void GuardAI::UpdateAI(const uint32 /*diff*/) -{ - // update i_victimGuid if i_creature.getVictim() !=0 and changed - if(!i_creature.SelectHostilTarget() || !i_creature.getVictim()) - return; - - i_victimGuid = i_creature.getVictim()->GetGUID(); - - if( i_creature.isAttackReady() ) - { - if( i_creature.IsWithinDistInMap(i_creature.getVictim(), ATTACK_DISTANCE)) - { - i_creature.AttackerStateUpdate(i_creature.getVictim()); - i_creature.resetAttackTimer(); - } - } -} - -bool GuardAI::IsVisible(Unit *pl) const -{ - return i_creature.GetDistance(pl) < sWorld.getConfig(CONFIG_SIGHT_GUARDER) - && pl->isVisibleForOrDetect(&i_creature,true); -} - -void GuardAI::AttackStart(Unit *u) -{ - if( !u ) - return; - - // DEBUG_LOG("Creature %s tagged a victim to kill [guid=%u]", i_creature.GetName(), u->GetGUIDLow()); - if(i_creature.Attack(u,true)) - { - i_creature.SetInCombatWith(u); - u->SetInCombatWith(&i_creature); - - i_creature.AddThreat(u, 0.0f); - i_victimGuid = u->GetGUID(); - i_creature.GetMotionMaster()->MoveChase(u); - } -} - -void GuardAI::JustDied(Unit *killer) -{ - if(Player* pkiller = killer->GetCharmerOrOwnerPlayerOrPlayerItself()) - i_creature.SendZoneUnderAttackMessage(pkiller); -} - +/* + * Copyright (C) 2005-2008 MaNGOS + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "GuardAI.h" +#include "Errors.h" +#include "Creature.h" +#include "Player.h" +#include "ObjectAccessor.h" +#include "World.h" + +int GuardAI::Permissible(const Creature *creature) +{ + if( creature->isGuard()) + return PERMIT_BASE_SPECIAL; + + return PERMIT_BASE_NO; +} + +GuardAI::GuardAI(Creature &c) : i_creature(c), i_victimGuid(0), i_state(STATE_NORMAL), i_tracker(TIME_INTERVAL_LOOK) +{ +} + +void GuardAI::MoveInLineOfSight(Unit *u) +{ + // Ignore Z for flying creatures + if ( !i_creature.canFly() && i_creature.GetDistanceZ(u) > CREATURE_Z_ATTACK_RANGE ) + return; + + if( !i_creature.getVictim() && u->isTargetableForAttack() && + ( u->IsHostileToPlayers() || i_creature.IsHostileTo(u) /*|| u->getVictim() && i_creature.IsFriendlyTo(u->getVictim())*/ ) && + u->isInAccessablePlaceFor(&i_creature)) + { + float attackRadius = i_creature.GetAttackDistance(u); + if(i_creature.IsWithinDistInMap(u,attackRadius)) + { + //Need add code to let guard support player + AttackStart(u); + u->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); + } + } +} + +void GuardAI::EnterEvadeMode() +{ + if( !i_creature.isAlive() ) + { + DEBUG_LOG("Creature stopped attacking because he's dead [guid=%u]", i_creature.GetGUIDLow()); + i_creature.StopMoving(); + i_creature.GetMotionMaster()->MoveIdle(); + + i_state = STATE_NORMAL; + + i_victimGuid = 0; + i_creature.CombatStop(); + i_creature.DeleteThreatList(); + return; + } + + Unit* victim = ObjectAccessor::GetUnit(i_creature, i_victimGuid ); + + if( !victim ) + { + DEBUG_LOG("Creature stopped attacking because victim is non exist [guid=%u]", i_creature.GetGUIDLow()); + } + else if( !victim ->isAlive() ) + { + DEBUG_LOG("Creature stopped attacking because victim is dead [guid=%u]", i_creature.GetGUIDLow()); + } + else if( victim ->HasStealthAura() ) + { + DEBUG_LOG("Creature stopped attacking because victim is using stealth [guid=%u]", i_creature.GetGUIDLow()); + } + else if( victim ->isInFlight() ) + { + DEBUG_LOG("Creature stopped attacking because victim is flying away [guid=%u]", i_creature.GetGUIDLow()); + } + else + { + DEBUG_LOG("Creature stopped attacking because victim outran him [guid=%u]", i_creature.GetGUIDLow()); + } + + i_creature.RemoveAllAuras(); + i_creature.DeleteThreatList(); + i_victimGuid = 0; + i_creature.CombatStop(); + i_state = STATE_NORMAL; + + // Remove TargetedMovementGenerator from MotionMaster stack list, and add HomeMovementGenerator instead + if( i_creature.GetMotionMaster()->GetCurrentMovementGeneratorType() == TARGETED_MOTION_TYPE ) + i_creature.GetMotionMaster()->MoveTargetedHome(); +} + +void GuardAI::UpdateAI(const uint32 /*diff*/) +{ + // update i_victimGuid if i_creature.getVictim() !=0 and changed + if(!i_creature.SelectHostilTarget() || !i_creature.getVictim()) + return; + + i_victimGuid = i_creature.getVictim()->GetGUID(); + + if( i_creature.isAttackReady() ) + { + if( i_creature.IsWithinDistInMap(i_creature.getVictim(), ATTACK_DISTANCE)) + { + i_creature.AttackerStateUpdate(i_creature.getVictim()); + i_creature.resetAttackTimer(); + } + } +} + +bool GuardAI::IsVisible(Unit *pl) const +{ + return i_creature.GetDistance(pl) < sWorld.getConfig(CONFIG_SIGHT_GUARDER) + && pl->isVisibleForOrDetect(&i_creature,true); +} + +void GuardAI::AttackStart(Unit *u) +{ + if( !u ) + return; + + // DEBUG_LOG("Creature %s tagged a victim to kill [guid=%u]", i_creature.GetName(), u->GetGUIDLow()); + if(i_creature.Attack(u,true)) + { + i_creature.SetInCombatWith(u); + u->SetInCombatWith(&i_creature); + + i_creature.AddThreat(u, 0.0f); + i_victimGuid = u->GetGUID(); + i_creature.GetMotionMaster()->MoveChase(u); + } +} + +void GuardAI::JustDied(Unit *killer) +{ + if(Player* pkiller = killer->GetCharmerOrOwnerPlayerOrPlayerItself()) + i_creature.SendZoneUnderAttackMessage(pkiller); +} + diff --git a/src/game/Guild.cpp b/src/game/Guild.cpp index bce616be394..07b9346312d 100644 --- a/src/game/Guild.cpp +++ b/src/game/Guild.cpp @@ -1,1940 +1,1963 @@ -/* - * Copyright (C) 2005-2008 MaNGOS - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "Database/DatabaseEnv.h" -#include "WorldPacket.h" -#include "WorldSession.h" -#include "MapManager.h" -#include "Player.h" -#include "Opcodes.h" -#include "ObjectMgr.h" -#include "Guild.h" -#include "Chat.h" -#include "SocialMgr.h" -#include "Util.h" - -Guild::Guild() -{ - Id = 0; - name = ""; - leaderGuid = 0; - GINFO = MOTD = ""; - EmblemStyle = 0; - EmblemColor = 0; - BorderStyle = 0; - BorderColor = 0; - BackgroundColor = 0; - - CreatedYear = 0; - CreatedMonth = 0; - CreatedDay = 0; -} - -Guild::~Guild() -{ - -} - -bool Guild::create(uint64 lGuid, std::string gname) -{ - std::string rname; - std::string lName; - - if(!objmgr.GetPlayerNameByGUID(lGuid, lName)) - return false; - if(objmgr.GetGuildByName(gname)) - return false; - - sLog.outDebug("GUILD: creating guild %s to leader: %u", gname.c_str(), GUID_LOPART(lGuid)); - - leaderGuid = lGuid; - name = gname; - GINFO = ""; - MOTD = "No message set."; - guildbank_money = 0; - purchased_tabs = 0; - - QueryResult *result = CharacterDatabase.Query( "SELECT MAX(guildid) FROM guild" ); - if( result ) - { - Id = (*result)[0].GetUInt32()+1; - delete result; - } - else Id = 1; - - // gname already assigned to Guild::name, use it to encode string for DB - CharacterDatabase.escape_string(gname); - - std::string dbGINFO = GINFO; - std::string dbMOTD = MOTD; - CharacterDatabase.escape_string(dbGINFO); - CharacterDatabase.escape_string(dbMOTD); - - CharacterDatabase.BeginTransaction(); - // CharacterDatabase.PExecute("DELETE FROM guild WHERE guildid='%u'", Id); - MAX(guildid)+1 not exist - CharacterDatabase.PExecute("DELETE FROM guild_rank WHERE guildid='%u'", Id); - CharacterDatabase.PExecute("DELETE FROM guild_member WHERE guildid='%u'", Id); - CharacterDatabase.PExecute("INSERT INTO guild (guildid,name,leaderguid,info,motd,createdate,EmblemStyle,EmblemColor,BorderStyle,BorderColor,BackgroundColor,BankMoney) " - "VALUES('%u','%s','%u', '%s', '%s', NOW(),'%u','%u','%u','%u','%u','" I64FMTD "')", - Id, gname.c_str(), GUID_LOPART(leaderGuid), dbGINFO.c_str(), dbMOTD.c_str(), EmblemStyle, EmblemColor, BorderStyle, BorderColor, BackgroundColor, guildbank_money); - CharacterDatabase.CommitTransaction(); - - rname = "Guild Master"; - CreateRank(rname,GR_RIGHT_ALL); - rname = "Officer"; - CreateRank(rname,GR_RIGHT_ALL); - rname = "Veteran"; - CreateRank(rname,GR_RIGHT_GCHATLISTEN | GR_RIGHT_GCHATSPEAK); - rname = "Member"; - CreateRank(rname,GR_RIGHT_GCHATLISTEN | GR_RIGHT_GCHATSPEAK); - rname = "Initiate"; - CreateRank(rname,GR_RIGHT_GCHATLISTEN | GR_RIGHT_GCHATSPEAK); - - return AddMember(lGuid, (uint32)GR_GUILDMASTER); -} - -bool Guild::AddMember(uint64 plGuid, uint32 plRank) -{ - if(Player::GetGuildIdFromDB(plGuid) != 0) // player already in guild - return false; - - // remove all player signs from another petitions - // this will be prevent attempt joining player to many guilds and corrupt guild data integrity - Player::RemovePetitionsAndSigns(plGuid, 9); - - // fill player data - MemberSlot newmember; - - if(!FillPlayerData(plGuid, &newmember)) // problems with player data collection - return false; - - newmember.RankId = plRank; - newmember.OFFnote = (std::string)""; - newmember.Pnote = (std::string)""; - newmember.logout_time = time(NULL); - newmember.BankResetTimeMoney = 0; // this will force update at first query - for (int i = 0; i < GUILD_BANK_MAX_TABS; ++i) - newmember.BankResetTimeTab[i] = 0; - members[GUID_LOPART(plGuid)] = newmember; - - std::string dbPnote = newmember.Pnote; - std::string dbOFFnote = newmember.OFFnote; - CharacterDatabase.escape_string(dbPnote); - CharacterDatabase.escape_string(dbOFFnote); - - CharacterDatabase.PExecute("INSERT INTO guild_member (guildid,guid,rank,pnote,offnote) VALUES ('%u', '%u', '%u','%s','%s')", - Id, GUID_LOPART(plGuid), newmember.RankId, dbPnote.c_str(), dbOFFnote.c_str()); - - Player* pl = objmgr.GetPlayer(plGuid); - if(pl) - { - pl->SetInGuild(Id); - pl->SetRank(newmember.RankId); - pl->SetGuildIdInvited(0); - } - else - { - Player::SetUInt32ValueInDB(PLAYER_GUILDID, Id, plGuid); - Player::SetUInt32ValueInDB(PLAYER_GUILDRANK, newmember.RankId, plGuid); - } - return true; -} - -void Guild::SetMOTD(std::string motd) -{ - MOTD = motd; - - // motd now can be used for encoding to DB - CharacterDatabase.escape_string(motd); - CharacterDatabase.PExecute("UPDATE guild SET motd='%s' WHERE guildid='%u'", motd.c_str(), Id); -} - -void Guild::SetGINFO(std::string ginfo) -{ - GINFO = ginfo; - - // ginfo now can be used for encoding to DB - CharacterDatabase.escape_string(ginfo); - CharacterDatabase.PExecute("UPDATE guild SET info='%s' WHERE guildid='%u'", ginfo.c_str(), Id); -} - -bool Guild::LoadGuildFromDB(uint32 GuildId) -{ - if(!LoadRanksFromDB(GuildId)) - return false; - - if(!LoadMembersFromDB(GuildId)) - return false; - - QueryResult *result = CharacterDatabase.PQuery("SELECT MAX(TabId) FROM guild_bank_tab WHERE guildid='%u'", GuildId); - if(result) - { - Field *fields = result->Fetch(); - purchased_tabs = fields[0].GetUInt8()+1; // Because TabId begins at 0 - delete result; - } - else - purchased_tabs = 0; - - LoadBankRightsFromDB(GuildId); // Must be after LoadRanksFromDB because it populates rank struct - - // 0 1 2 3 4 5 6 - result = CharacterDatabase.PQuery("SELECT guildid, name, leaderguid, EmblemStyle, EmblemColor, BorderStyle, BorderColor," - // 7 8 9 10 11 - "BackgroundColor, info, motd, createdate, BankMoney FROM guild WHERE guildid = '%u'", GuildId); - - if(!result) - return false; - - Field *fields = result->Fetch(); - - Id = fields[0].GetUInt32(); - name = fields[1].GetCppString(); - leaderGuid = MAKE_NEW_GUID(fields[2].GetUInt32(), 0, HIGHGUID_PLAYER); - - EmblemStyle = fields[3].GetUInt32(); - EmblemColor = fields[4].GetUInt32(); - BorderStyle = fields[5].GetUInt32(); - BorderColor = fields[6].GetUInt32(); - BackgroundColor = fields[7].GetUInt32(); - GINFO = fields[8].GetCppString(); - MOTD = fields[9].GetCppString(); - uint64 time = fields[10].GetUInt64(); //datetime is uint64 type ... YYYYmmdd:hh:mm:ss - guildbank_money = fields[11].GetUInt64(); - - delete result; - - uint64 dTime = time /1000000; - CreatedDay = dTime%100; - CreatedMonth = (dTime/100)%100; - CreatedYear = (dTime/10000)%10000; - - // If the leader does not exist attempt to promote another member - if(!objmgr.GetPlayerAccountIdByGUID(leaderGuid )) - { - DelMember(leaderGuid); - - // check no members case (disbanded) - if(members.empty()) - return false; - } - - sLog.outDebug("Guild %u Creation time Loaded day: %u, month: %u, year: %u", GuildId, CreatedDay, CreatedMonth, CreatedYear); - m_bankloaded = false; - m_eventlogloaded = false; - m_onlinemembers = 0; - RenumBankLogs(); - RenumGuildEventlog(); - return true; -} - -bool Guild::LoadRanksFromDB(uint32 GuildId) -{ - Field *fields; - QueryResult *result = CharacterDatabase.PQuery("SELECT rname,rights,BankMoneyPerDay,rid FROM guild_rank WHERE guildid = '%u' ORDER BY rid ASC", GuildId); - - if(!result) - return false; - - bool broken_ranks = false; - - do - { - fields = result->Fetch(); - - std::string rankName = fields[0].GetCppString(); - uint32 rankRights = fields[1].GetUInt32(); - uint32 rankMoney = fields[2].GetUInt32(); - uint32 rankRID = fields[3].GetUInt32(); - - if(rankRID != m_ranks.size()+1) // guild_rank.rid always store rank+1 - broken_ranks = true; - - if(m_ranks.size()==GR_GUILDMASTER) // prevent loss leader rights - rankRights |= GR_RIGHT_ALL; - - AddRank(rankName,rankRights,rankMoney); - }while( result->NextRow() ); - delete result; - - if(m_ranks.size()==0) // empty rank table? - { - AddRank("Guild Master",GR_RIGHT_ALL,0); - broken_ranks = true; - } - - // guild_rank have wrong numbered ranks, repair - if(broken_ranks) - { - sLog.outError("Guild %u have broken `guild_rank` data, repairing...",GuildId); - CharacterDatabase.BeginTransaction(); - CharacterDatabase.PExecute("DELETE FROM guild_rank WHERE guildid='%u'", GuildId); - for(size_t i =0; i < m_ranks.size(); ++i) - { - // guild_rank.rid always store rank+1 - std::string name = m_ranks[i].name; - uint32 rights = m_ranks[i].rights; - CharacterDatabase.escape_string(name); - CharacterDatabase.PExecute( "INSERT INTO guild_rank (guildid,rid,rname,rights) VALUES ('%u', '%u', '%s', '%u')", GuildId, i+1, name.c_str(), rights); - } - CharacterDatabase.CommitTransaction(); - } - - return true; -} - -bool Guild::LoadMembersFromDB(uint32 GuildId) -{ - // 0 1 2 3 4 5 - QueryResult *result = CharacterDatabase.PQuery("SELECT guild_member.guid,rank, pnote, offnote, BankResetTimeMoney,BankRemMoney," - // 6 7 8 9 10 11 - "BankResetTimeTab0, BankRemSlotsTab0, BankResetTimeTab1, BankRemSlotsTab1, BankResetTimeTab2, BankRemSlotsTab2," - // 12 13 14 15 16 17 - "BankResetTimeTab3, BankRemSlotsTab3, BankResetTimeTab4, BankRemSlotsTab4, BankResetTimeTab5, BankRemSlotsTab5," - // 18 - "logout_time FROM guild_member LEFT JOIN characters ON characters.guid = guild_member.guid WHERE guildid = '%u'", GuildId); - - if(!result) - return false; - - do - { - Field *fields = result->Fetch(); - MemberSlot newmember; - newmember.RankId = fields[1].GetUInt32(); - uint64 guid = MAKE_NEW_GUID(fields[0].GetUInt32(), 0, HIGHGUID_PLAYER); - - // Player does not exist - if(!FillPlayerData(guid, &newmember)) - continue; - - newmember.Pnote = fields[2].GetCppString(); - newmember.OFFnote = fields[3].GetCppString(); - newmember.BankResetTimeMoney = fields[4].GetUInt32(); - newmember.BankRemMoney = fields[5].GetUInt32(); - for (int i = 0; i < GUILD_BANK_MAX_TABS; ++i) - { - newmember.BankResetTimeTab[i] = fields[6+(2*i)].GetUInt32(); - newmember.BankRemSlotsTab[i] = fields[7+(2*i)].GetUInt32(); - } - newmember.logout_time = fields[18].GetUInt64(); - members[GUID_LOPART(guid)] = newmember; - - }while( result->NextRow() ); - delete result; - - if(members.empty()) - return false; - - return true; -} - -bool Guild::FillPlayerData(uint64 guid, MemberSlot* memslot) -{ - std::string plName; - uint32 plLevel; - uint32 plClass; - uint32 plZone; - - Player* pl = objmgr.GetPlayer(guid); - if(pl) - { - plName = pl->GetName(); - plLevel = pl->getLevel(); - plClass = pl->getClass(); - plZone = pl->GetZoneId(); - } - else - { - if(!objmgr.GetPlayerNameByGUID(guid, plName)) // player doesn't exist - return false; - - plLevel = Player::GetUInt32ValueFromDB(UNIT_FIELD_LEVEL, guid); - if(plLevel<1||plLevel>255) // can be at broken `data` field - { - sLog.outError("Player (GUID: %u) has a broken data in field `characters`.`data`.",GUID_LOPART(guid)); - return false; - } - plZone = Player::GetZoneIdFromDB(guid); - - QueryResult *result = CharacterDatabase.PQuery("SELECT class FROM characters WHERE guid='%u'", GUID_LOPART(guid)); - if(!result) - return false; - plClass = (*result)[0].GetUInt32(); - if(plClass=MAX_CLASSES) // can be at broken `class` field - { - sLog.outError("Player (GUID: %u) has a broken data in field `characters`.`class`.",GUID_LOPART(guid)); - return false; - } - - delete result; - } - - memslot->name = plName; - memslot->level = plLevel; - memslot->Class = plClass; - memslot->zoneId = plZone; - - return(true); -} - -void Guild::LoadPlayerStatsByGuid(uint64 guid) -{ - MemberList::iterator itr = members.find(GUID_LOPART(guid)); - if (itr == members.end() ) - return; - - Player *pl = ObjectAccessor::FindPlayer(guid); - if(!pl) - return; - itr->second.name = pl->GetName(); - itr->second.level = pl->getLevel(); - itr->second.Class = pl->getClass(); -} - -void Guild::SetLeader(uint64 guid) -{ - leaderGuid = guid; - this->ChangeRank(guid, GR_GUILDMASTER); - - CharacterDatabase.PExecute("UPDATE guild SET leaderguid='%u' WHERE guildid='%u'", GUID_LOPART(guid), Id); -} - -void Guild::DelMember(uint64 guid, bool isDisbanding) -{ - if(this->leaderGuid == guid && !isDisbanding) - { - std::ostringstream ss; - ss<<"SELECT guid FROM guild_member WHERE guildid='"<SetLeader(newLeaderGUID); - - newLeader = objmgr.GetPlayer(newLeaderGUID); - if(newLeader) - { - newLeader->SetRank(GR_GUILDMASTER); - newLeaderName = newLeader->GetName(); - } - else - { - Player::SetUInt32ValueInDB(PLAYER_GUILDRANK, GR_GUILDMASTER, newLeaderGUID); - objmgr.GetPlayerNameByGUID(newLeaderGUID, newLeaderName); - } - - // when leader non-exist (at guild load with deleted leader only) not send broadcasts - if(objmgr.GetPlayerNameByGUID(guid, oldLeaderName)) - { - WorldPacket data(SMSG_GUILD_EVENT, (1+1+oldLeaderName.size()+1+newLeaderName.size()+1)); - data << (uint8)GE_LEADER_CHANGED; - data << (uint8)2; - data << oldLeaderName; - data << newLeaderName; - this->BroadcastPacket(&data); - - data.Initialize(SMSG_GUILD_EVENT, (1+1+oldLeaderName.size()+1)); - data << (uint8)GE_LEFT; - data << (uint8)1; - data << oldLeaderName; - this->BroadcastPacket(&data); - } - - sLog.outDebug( "WORLD: Sent (SMSG_GUILD_EVENT)" ); - } - else - { - this->Disband(); - return; - } - } - - members.erase(GUID_LOPART(guid)); - - Player *player = objmgr.GetPlayer(guid); - if(player) - { - player->SetInGuild(0); - player->SetRank(0); - } - else - { - Player::SetUInt32ValueInDB(PLAYER_GUILDID, 0, guid); - Player::SetUInt32ValueInDB(PLAYER_GUILDRANK, GR_GUILDMASTER, guid); - } - - CharacterDatabase.PExecute("DELETE FROM guild_member WHERE guid = '%u'", GUID_LOPART(guid)); -} - -void Guild::ChangeRank(uint64 guid, uint32 newRank) -{ - MemberList::iterator itr = members.find(GUID_LOPART(guid)); - if( itr != members.end() ) - itr->second.RankId = newRank; - - Player *player = objmgr.GetPlayer(guid); - if(player) - player->SetRank(newRank); - else - Player::SetUInt32ValueInDB(PLAYER_GUILDRANK, newRank, guid); - - CharacterDatabase.PExecute( "UPDATE guild_member SET rank='%u' WHERE guid='%u'", newRank, GUID_LOPART(guid) ); -} - -void Guild::SetPNOTE(uint64 guid,std::string pnote) -{ - MemberList::iterator itr = members.find(GUID_LOPART(guid)); - if( itr == members.end() ) - return; - - itr->second.Pnote = pnote; - - // pnote now can be used for encoding to DB - CharacterDatabase.escape_string(pnote); - CharacterDatabase.PExecute("UPDATE guild_member SET pnote = '%s' WHERE guid = '%u'", pnote.c_str(), itr->first); -} - -void Guild::SetOFFNOTE(uint64 guid,std::string offnote) -{ - MemberList::iterator itr = members.find(GUID_LOPART(guid)); - if( itr == members.end() ) - return; - itr->second.OFFnote = offnote; - // offnote now can be used for encoding to DB - CharacterDatabase.escape_string(offnote); - CharacterDatabase.PExecute("UPDATE guild_member SET offnote = '%s' WHERE guid = '%u'", offnote.c_str(), itr->first); -} - -void Guild::BroadcastToGuild(WorldSession *session, std::string msg, uint32 language) -{ - if (session && session->GetPlayer() && HasRankRight(session->GetPlayer()->GetRank(),GR_RIGHT_GCHATSPEAK)) - { - WorldPacket data; - ChatHandler(session).FillMessageData(&data, CHAT_MSG_GUILD, language, 0, msg.c_str()); - - for (MemberList::const_iterator itr = members.begin(); itr != members.end(); ++itr) - { - Player *pl = ObjectAccessor::FindPlayer(MAKE_NEW_GUID(itr->first, 0, HIGHGUID_PLAYER)); - - if (pl && pl->GetSession() && HasRankRight(pl->GetRank(),GR_RIGHT_GCHATLISTEN) && !pl->GetSocial()->HasIgnore(session->GetPlayer()->GetGUIDLow()) ) - pl->GetSession()->SendPacket(&data); - } - } -} - -void Guild::BroadcastToOfficers(WorldSession *session, std::string msg, uint32 language) -{ - if (session && session->GetPlayer() && HasRankRight(session->GetPlayer()->GetRank(),GR_RIGHT_OFFCHATSPEAK)) - { - for(MemberList::iterator itr = members.begin(); itr != members.end(); ++itr) - { - WorldPacket data; - ChatHandler::FillMessageData(&data, session, CHAT_MSG_OFFICER, language, NULL, 0, msg.c_str(),NULL); - - Player *pl = ObjectAccessor::FindPlayer(MAKE_NEW_GUID(itr->first, 0, HIGHGUID_PLAYER)); - - if (pl && pl->GetSession() && HasRankRight(pl->GetRank(),GR_RIGHT_OFFCHATLISTEN) && !pl->GetSocial()->HasIgnore(session->GetPlayer()->GetGUIDLow())) - pl->GetSession()->SendPacket(&data); - } - } -} - -void Guild::BroadcastPacket(WorldPacket *packet) -{ - for(MemberList::iterator itr = members.begin(); itr != members.end(); ++itr) - { - Player *player = ObjectAccessor::FindPlayer(MAKE_NEW_GUID(itr->first, 0, HIGHGUID_PLAYER)); - if(player) - player->GetSession()->SendPacket(packet); - } -} - -void Guild::BroadcastPacketToRank(WorldPacket *packet, uint32 rankId) -{ - for(MemberList::iterator itr = members.begin(); itr != members.end(); ++itr) - { - if (itr->second.RankId == rankId) - { - Player *player = ObjectAccessor::FindPlayer(MAKE_NEW_GUID(itr->first, 0, HIGHGUID_PLAYER)); - if(player) - player->GetSession()->SendPacket(packet); - } - } -} - -void Guild::CreateRank(std::string name_,uint32 rights) -{ - if(m_ranks.size() >= GUILD_MAX_RANKS) - return; - - AddRank(name_,rights,0); - - for (int i = 0; i < purchased_tabs; ++i) - { - CreateBankRightForTab(m_ranks.size()-1, uint8(i)); - } - - // guild_rank.rid always store rank+1 value - - // name now can be used for encoding to DB - CharacterDatabase.escape_string(name_); - CharacterDatabase.PExecute( "INSERT INTO guild_rank (guildid,rid,rname,rights) VALUES ('%u', '%u', '%s', '%u')", Id, m_ranks.size(), name_.c_str(), rights ); -} - -void Guild::AddRank(std::string name_,uint32 rights, uint32 money) -{ - m_ranks.push_back(RankInfo(name_,rights,money)); -} - -void Guild::DelRank() -{ - if(m_ranks.empty()) - return; - - // guild_rank.rid always store rank+1 value - uint32 rank = m_ranks.size()-1; - CharacterDatabase.PExecute("DELETE FROM guild_rank WHERE rid>='%u' AND guildid='%u'", (rank+1), Id); - - m_ranks.pop_back(); -} - -std::string Guild::GetRankName(uint32 rankId) -{ - if(rankId >= m_ranks.size()) - return ""; - - return m_ranks[rankId].name; -} - -uint32 Guild::GetRankRights(uint32 rankId) -{ - if(rankId >= m_ranks.size()) - return 0; - - return m_ranks[rankId].rights; -} - -void Guild::SetRankName(uint32 rankId, std::string name_) -{ - if(rankId >= m_ranks.size()) - return; - - m_ranks[rankId].name = name_; - - // name now can be used for encoding to DB - CharacterDatabase.escape_string(name_); - CharacterDatabase.PExecute("UPDATE guild_rank SET rname='%s' WHERE rid='%u' AND guildid='%u'", name_.c_str(), (rankId+1), Id); -} - -void Guild::SetRankRights(uint32 rankId, uint32 rights) -{ - if(rankId >= m_ranks.size()) - return; - - m_ranks[rankId].rights = rights; - - CharacterDatabase.PExecute("UPDATE guild_rank SET rights='%u' WHERE rid='%u' AND guildid='%u'", rights, (rankId+1), Id); -} - -void Guild::Disband() -{ - WorldPacket data(SMSG_GUILD_EVENT, 1); - data << (uint8)GE_DISBANDED; - this->BroadcastPacket(&data); - - while (!members.empty()) - { - MemberList::iterator itr = members.begin(); - DelMember(MAKE_NEW_GUID(itr->first, 0, HIGHGUID_PLAYER), true); - } - - CharacterDatabase.BeginTransaction(); - CharacterDatabase.PExecute("DELETE FROM guild WHERE guildid = '%u'",Id); - CharacterDatabase.PExecute("DELETE FROM guild_rank WHERE guildid = '%u'",Id); - CharacterDatabase.PExecute("DELETE FROM guild_bank_tab WHERE guildid = '%u'",Id); - CharacterDatabase.PExecute("DELETE FROM guild_bank_item WHERE guildid = '%u'",Id); - CharacterDatabase.PExecute("DELETE FROM guild_bank_right WHERE guildid = '%u'",Id); - CharacterDatabase.PExecute("DELETE FROM guild_bank_eventlog WHERE guildid = '%u'",Id); - CharacterDatabase.PExecute("DELETE FROM guild_eventlog WHERE guildid = '%u'",Id); - CharacterDatabase.CommitTransaction(); - objmgr.RemoveGuild(this); -} - -void Guild::Roster(WorldSession *session) -{ - // we can only guess size - WorldPacket data(SMSG_GUILD_ROSTER, (4+MOTD.length()+1+GINFO.length()+1+4+m_ranks.size()*(4+4+GUILD_BANK_MAX_TABS*(4+4))+members.size()*50)); - data << (uint32)members.size(); - data << MOTD; - data << GINFO; - - data << (uint32)m_ranks.size(); - for (RankList::iterator ritr = m_ranks.begin(); ritr != m_ranks.end();++ritr) - { - data << (uint32)ritr->rights; - data << (uint32)ritr->BankMoneyPerDay; // count of: withdraw gold(gold/day) Note: in game set gold, in packet set bronze. - for (int i = 0; i < GUILD_BANK_MAX_TABS; ++i) - { - data << (uint32)ritr->TabRight[i]; // for TAB_i rights: view tabs = 0x01, deposit items =0x02 - data << (uint32)ritr->TabSlotPerDay[i]; // for TAB_i count of: withdraw items(stack/day) - } - } - for (MemberList::iterator itr = members.begin(); itr != members.end(); ++itr) - { - if (Player *pl = ObjectAccessor::FindPlayer(MAKE_NEW_GUID(itr->first, 0, HIGHGUID_PLAYER))) - { - data << (uint64)pl->GetGUID(); - data << (uint8)1; - data << (std::string)pl->GetName(); - data << (uint32)itr->second.RankId; - data << (uint8)pl->getLevel(); - data << (uint8)pl->getClass(); - data << (uint8)0; // new 2.4.0 - data << (uint32)pl->GetZoneId(); - data << itr->second.Pnote; - data << itr->second.OFFnote; - } - else - { - data << uint64(MAKE_NEW_GUID(itr->first, 0, HIGHGUID_PLAYER)); - data << (uint8)0; - data << itr->second.name; - data << (uint32)itr->second.RankId; - data << (uint8)itr->second.level; - data << (uint8)itr->second.Class; - data << (uint8)0; // new 2.4.0 - data << (uint32)itr->second.zoneId; - data << (float(time(NULL)-itr->second.logout_time) / DAY); - data << itr->second.Pnote; - data << itr->second.OFFnote; - } - } - session->SendPacket(&data);; - sLog.outDebug( "WORLD: Sent (SMSG_GUILD_ROSTER)" ); -} - -void Guild::Query(WorldSession *session) -{ - WorldPacket data(SMSG_GUILD_QUERY_RESPONSE, (8*32+200));// we can only guess size - - data << Id; - data << name; - RankList::iterator itr; - for (size_t i = 0 ; i < 10; ++i) // show always 10 ranks - { - if(i < m_ranks.size()) - data << m_ranks[i].name; - else - data << (uint8)0; // null string - } - - data << uint32(EmblemStyle); - data << uint32(EmblemColor); - data << uint32(BorderStyle); - data << uint32(BorderColor); - data << uint32(BackgroundColor); - - session->SendPacket( &data ); - sLog.outDebug( "WORLD: Sent (SMSG_GUILD_QUERY_RESPONSE)" ); -} - -void Guild::SetEmblem(uint32 emblemStyle, uint32 emblemColor, uint32 borderStyle, uint32 borderColor, uint32 backgroundColor) -{ - this->EmblemStyle = emblemStyle; - this->EmblemColor = emblemColor; - this->BorderStyle = borderStyle; - this->BorderColor = borderColor; - this->BackgroundColor = backgroundColor; - - CharacterDatabase.PExecute("UPDATE guild SET EmblemStyle=%u, EmblemColor=%u, BorderStyle=%u, BorderColor=%u, BackgroundColor=%u WHERE guildid = %u", EmblemStyle, EmblemColor, BorderStyle, BorderColor, BackgroundColor, Id); -} - -void Guild::UpdateLogoutTime(uint64 guid) -{ - MemberList::iterator itr = members.find(GUID_LOPART(guid)); - if (itr == members.end() ) - return; - - itr->second.logout_time = time(NULL); - - if (m_onlinemembers > 0) - --m_onlinemembers; - else - { - UnloadGuildBank(); - UnloadGuildEventlog(); - } -} - -// ************************************************* -// Guild Eventlog part -// ************************************************* -// Display guild eventlog -void Guild::DisplayGuildEventlog(WorldSession *session) -{ - // Load guild eventlog, if not already done - if (!m_eventlogloaded) - LoadGuildEventLogFromDB(); - - // Sending result - WorldPacket data(MSG_GUILD_EVENT_LOG_QUERY, 0); - // count, max count == 100 - data << uint8(m_GuildEventlog.size()); - for (GuildEventlog::const_iterator itr = m_GuildEventlog.begin(); itr != m_GuildEventlog.end(); ++itr) - { - // Event type - data << uint8((*itr)->EventType); - // Player 1 - data << uint64((*itr)->PlayerGuid1); - // Player 2 not for left/join guild events - if( (*itr)->EventType != GUILD_EVENT_LOG_JOIN_GUILD && (*itr)->EventType != GUILD_EVENT_LOG_LEAVE_GUILD ) - data << uint64((*itr)->PlayerGuid2); - // New Rank - only for promote/demote guild events - if( (*itr)->EventType == GUILD_EVENT_LOG_PROMOTE_PLAYER || (*itr)->EventType == GUILD_EVENT_LOG_DEMOTE_PLAYER ) - data << uint8((*itr)->NewRank); - // Event timestamp - data << uint32(time(NULL)-(*itr)->TimeStamp); - } - session->SendPacket(&data); - sLog.outDebug("WORLD: Sent (MSG_GUILD_EVENT_LOG_QUERY)"); -} - -// Load guild eventlog from DB -void Guild::LoadGuildEventLogFromDB() -{ - // Return if already loaded - if (m_eventlogloaded) - return; - - QueryResult *result = CharacterDatabase.PQuery("SELECT LogGuid, EventType, PlayerGuid1, PlayerGuid2, NewRank, TimeStamp FROM guild_eventlog WHERE guildid=%u ORDER BY LogGuid DESC LIMIT %u", Id, GUILD_EVENTLOG_MAX_ENTRIES); - if(!result) - return; - do - { - Field *fields = result->Fetch(); - GuildEventlogEntry *NewEvent = new GuildEventlogEntry; - // Fill entry - NewEvent->LogGuid = fields[0].GetUInt32(); - NewEvent->EventType = fields[1].GetUInt8(); - NewEvent->PlayerGuid1 = fields[2].GetUInt32(); - NewEvent->PlayerGuid2 = fields[3].GetUInt32(); - NewEvent->NewRank = fields[4].GetUInt8(); - NewEvent->TimeStamp = fields[5].GetUInt64(); - // Add entry to map - m_GuildEventlog.push_front(NewEvent); - - } while( result->NextRow() ); - delete result; - - // Check lists size in case to many event entries in db - // This cases can happen only if a crash occured somewhere and table has too many log entries - if (!m_GuildEventlog.empty()) - { - CharacterDatabase.PExecute("DELETE FROM guild_eventlog WHERE guildid=%u AND LogGuid < %u", Id, m_GuildEventlog.front()->LogGuid); - } - m_eventlogloaded = true; -} - -// Unload guild eventlog -void Guild::UnloadGuildEventlog() -{ - if (!m_eventlogloaded) - return; - GuildEventlogEntry *EventLogEntry; - if( !m_GuildEventlog.empty() ) - { - do - { - EventLogEntry = *(m_GuildEventlog.begin()); - m_GuildEventlog.pop_front(); - delete EventLogEntry; - }while( !m_GuildEventlog.empty() ); - } - m_eventlogloaded = false; -} - -// This will renum guids used at load to prevent always going up until infinit -void Guild::RenumGuildEventlog() -{ - QueryResult *result = CharacterDatabase.PQuery("SELECT Min(LogGuid), Max(LogGuid) FROM guild_eventlog WHERE guildid = %u", Id); - if(!result) - return; - - Field *fields = result->Fetch(); - CharacterDatabase.PExecute("UPDATE guild_eventlog SET LogGuid=LogGuid-%u+1 WHERE guildid=%u ORDER BY LogGuid %s",fields[0].GetUInt32(), Id, fields[0].GetUInt32()?"ASC":"DESC"); - GuildEventlogMaxGuid = fields[1].GetUInt32()+1; - delete result; -} - -// Add entry to guild eventlog -void Guild::LogGuildEvent(uint8 EventType, uint32 PlayerGuid1, uint32 PlayerGuid2, uint8 NewRank) -{ - GuildEventlogEntry *NewEvent = new GuildEventlogEntry; - // Fill entry - NewEvent->LogGuid = GuildEventlogMaxGuid++; - NewEvent->EventType = EventType; - NewEvent->PlayerGuid1 = PlayerGuid1; - NewEvent->PlayerGuid2 = PlayerGuid2; - NewEvent->NewRank = NewRank; - NewEvent->TimeStamp = uint32(time(NULL)); - // Check max entry limit and delete from db if needed - if (m_GuildEventlog.size() > GUILD_EVENTLOG_MAX_ENTRIES) - { - GuildEventlogEntry *OldEvent = *(m_GuildEventlog.begin()); - m_GuildEventlog.pop_front(); - CharacterDatabase.PExecute("DELETE FROM guild_eventlog WHERE guildid='%u' AND LogGuid='%u'", Id, OldEvent->LogGuid); - delete OldEvent; - } - // Add entry to map - m_GuildEventlog.push_back(NewEvent); - // Add new eventlog entry into DB - CharacterDatabase.PExecute("INSERT INTO guild_eventlog (guildid, LogGuid, EventType, PlayerGuid1, PlayerGuid2, NewRank, TimeStamp) VALUES ('%u','%u','%u','%u','%u','%u','" I64FMTD "')", - Id, NewEvent->LogGuid, uint32(NewEvent->EventType), NewEvent->PlayerGuid1, NewEvent->PlayerGuid2, uint32(NewEvent->NewRank), NewEvent->TimeStamp); -} - -// ************************************************* -// Guild Bank part -// ************************************************* -// Bank content related -void Guild::DisplayGuildBankContent(WorldSession *session, uint8 TabId) -{ - WorldPacket data(SMSG_GUILD_BANK_LIST,1200); - - GuildBankTab const* tab = GetBankTab(TabId); - if (!tab) - return; - - if(!IsMemberHaveRights(session->GetPlayer()->GetGUIDLow(),TabId,GUILD_BANK_RIGHT_VIEW_TAB)) - return; - - data << uint64(GetGuildBankMoney()); - data << uint8(TabId); - // remaining slots for today - data << uint32(GetMemberSlotWithdrawRem(session->GetPlayer()->GetGUIDLow(), TabId)); - data << uint8(0); // Tell client this is a tab content packet - - data << uint8(GUILD_BANK_MAX_SLOTS); - - for (int i=0; iSendPacket(&data); - - sLog.outDebug("WORLD: Sent (SMSG_GUILD_BANK_LIST)"); -} - -void Guild::DisplayGuildBankMoneyUpdate() -{ - WorldPacket data(SMSG_GUILD_BANK_LIST, 8+1+4+1+1); - - data << uint64(GetGuildBankMoney()); - data << uint8(0); - // remaining slots for today - - size_t rempos = data.wpos(); - data << uint32(0); // will be filled later - data << uint8(0); // Tell client this is a tab content packet - - data << uint8(0); // not send items - - BroadcastPacket(&data); - - sLog.outDebug("WORLD: Sent (SMSG_GUILD_BANK_LIST)"); -} - -void Guild::DisplayGuildBankContentUpdate(uint8 TabId, int32 slot1, int32 slot2) -{ - GuildBankTab const* tab = GetBankTab(TabId); - if (!tab) - return; - - WorldPacket data(SMSG_GUILD_BANK_LIST,1200); - - data << uint64(GetGuildBankMoney()); - data << uint8(TabId); - // remaining slots for today - - size_t rempos = data.wpos(); - data << uint32(0); // will be filled later - data << uint8(0); // Tell client this is a tab content packet - - if(slot2==-1) // single item in slot1 - { - data << uint8(1); - - AppendDisplayGuildBankSlot(data, tab, slot1); - } - else // 2 items (in slot1 and slot2) - { - data << uint8(2); - - if(slot1 > slot2) - std::swap(slot1,slot2); - - AppendDisplayGuildBankSlot(data, tab, slot1); - AppendDisplayGuildBankSlot(data, tab, slot2); - } - - for(MemberList::iterator itr = members.begin(); itr != members.end(); ++itr) - { - Player *player = ObjectAccessor::FindPlayer(MAKE_NEW_GUID(itr->first, 0, HIGHGUID_PLAYER)); - if(!player) - continue; - - if(!IsMemberHaveRights(itr->first,TabId,GUILD_BANK_RIGHT_VIEW_TAB)) - continue; - - data.put(rempos,uint32(GetMemberSlotWithdrawRem(player->GetGUIDLow(), TabId))); - - player->GetSession()->SendPacket(&data); - } - - sLog.outDebug("WORLD: Sent (SMSG_GUILD_BANK_LIST)"); -} - -void Guild::DisplayGuildBankContentUpdate(uint8 TabId, GuildItemPosCountVec const& slots) -{ - GuildBankTab const* tab = GetBankTab(TabId); - if (!tab) - return; - - WorldPacket data(SMSG_GUILD_BANK_LIST,1200); - - data << uint64(GetGuildBankMoney()); - data << uint8(TabId); - // remaining slots for today - - size_t rempos = data.wpos(); - data << uint32(0); // will be filled later - data << uint8(0); // Tell client this is a tab content packet - - data << uint8(slots.size()); // updates count - - for(GuildItemPosCountVec::const_iterator itr = slots.begin(); itr != slots.end(); ++itr) - AppendDisplayGuildBankSlot(data, tab, itr->slot); - - for(MemberList::iterator itr = members.begin(); itr != members.end(); ++itr) - { - Player *player = ObjectAccessor::FindPlayer(MAKE_NEW_GUID(itr->first, 0, HIGHGUID_PLAYER)); - if(!player) - continue; - - if(!IsMemberHaveRights(itr->first,TabId,GUILD_BANK_RIGHT_VIEW_TAB)) - continue; - - data.put(rempos,uint32(GetMemberSlotWithdrawRem(player->GetGUIDLow(), TabId))); - - player->GetSession()->SendPacket(&data); - } - - sLog.outDebug("WORLD: Sent (SMSG_GUILD_BANK_LIST)"); -} - -Item* Guild::GetItem(uint8 TabId, uint8 SlotId) -{ - if (TabId >= m_TabListMap.size() || SlotId >= GUILD_BANK_MAX_SLOTS) - return NULL; - return m_TabListMap[TabId]->Slots[SlotId]; -} - -// ************************************************* -// Tab related - -void Guild::DisplayGuildBankTabsInfo(WorldSession *session) -{ - // Time to load bank if not already done - if (!m_bankloaded) - LoadGuildBankFromDB(); - - WorldPacket data(SMSG_GUILD_BANK_LIST, 500); - - data << uint64(GetGuildBankMoney()); - data << uint8(0); // TabInfo packet must be for TabId 0 - data << uint32(0xFFFFFFFF); // bit 9 must be set for this packet to work - data << uint8(1); // Tell Client this is a TabInfo packet - - data << uint8(purchased_tabs); // here is the number of tabs - - for(int i = 0; i < purchased_tabs; ++i) - { - data << m_TabListMap[i]->Name.c_str(); - data << m_TabListMap[i]->Icon.c_str(); - } - data << uint8(0); // Do not send tab content - session->SendPacket(&data); - - sLog.outDebug("WORLD: Sent (SMSG_GUILD_BANK_LIST)"); -} - -void Guild::CreateNewBankTab() -{ - if (purchased_tabs >= GUILD_BANK_MAX_TABS) - return; - - ++purchased_tabs; - - GuildBankTab* AnotherTab = new GuildBankTab; - memset(AnotherTab->Slots, 0, GUILD_BANK_MAX_SLOTS * sizeof(Item*)); - m_TabListMap.resize(purchased_tabs); - m_TabListMap[purchased_tabs-1] = AnotherTab; - - CharacterDatabase.BeginTransaction(); - CharacterDatabase.PExecute("DELETE FROM guild_bank_tab WHERE guildid='%u' AND TabId='%u'", Id, uint32(purchased_tabs-1)); - CharacterDatabase.PExecute("INSERT INTO guild_bank_tab (guildid,TabId) VALUES ('%u','%u')", Id, uint32(purchased_tabs-1)); - CharacterDatabase.CommitTransaction(); -} - -void Guild::SetGuildBankTabInfo(uint8 TabId, std::string Name, std::string Icon) -{ - if (TabId >= GUILD_BANK_MAX_TABS) - return; - if (TabId >= m_TabListMap.size()) - return; - - if (!m_TabListMap[TabId]) - return; - - if(m_TabListMap[TabId]->Name == Name && m_TabListMap[TabId]->Icon == Icon) - return; - - m_TabListMap[TabId]->Name = Name; - m_TabListMap[TabId]->Icon = Icon; - - CharacterDatabase.escape_string(Name); - CharacterDatabase.escape_string(Icon); - CharacterDatabase.PExecute("UPDATE guild_bank_tab SET TabName='%s',TabIcon='%s' WHERE guildid='%u' AND TabId='%u'", Name.c_str(), Icon.c_str(), Id, uint32(TabId)); -} - -void Guild::CreateBankRightForTab(uint32 rankId, uint8 TabId) -{ - sLog.outDebug("CreateBankRightForTab. rank: %u, TabId: %u", rankId, uint32(TabId)); - if (rankId >= m_ranks.size() || TabId >= GUILD_BANK_MAX_TABS) - return; - - m_ranks[rankId].TabRight[TabId]=0; - m_ranks[rankId].TabSlotPerDay[TabId]=0; - CharacterDatabase.BeginTransaction(); - CharacterDatabase.PExecute("DELETE FROM guild_bank_right WHERE guildid = '%u' AND TabId = '%u' AND rid = '%u'", Id, uint32(TabId), rankId); - CharacterDatabase.PExecute("INSERT INTO guild_bank_right (guildid,TabId,rid) VALUES ('%u','%u','%u')", Id, uint32(TabId), rankId); - CharacterDatabase.CommitTransaction(); -} - -uint32 Guild::GetBankRights(uint32 rankId, uint8 TabId) const -{ - if(rankId >= m_ranks.size() || TabId >= GUILD_BANK_MAX_TABS) - return 0; - - return m_ranks[rankId].TabRight[TabId]; -} - -// ************************************************* -// Guild bank loading/unloading related - -// This load should be called when the bank is first accessed by a guild member -void Guild::LoadGuildBankFromDB() -{ - if (m_bankloaded) - return; - - m_bankloaded = true; - LoadGuildBankEventLogFromDB(); - - // 0 1 2 3 - QueryResult *result = CharacterDatabase.PQuery("SELECT TabId, TabName, TabIcon, TabText FROM guild_bank_tab WHERE guildid='%u' ORDER BY TabId", Id); - if(!result) - { - purchased_tabs = 0; - return; - } - - m_TabListMap.resize(purchased_tabs); - do - { - Field *fields = result->Fetch(); - uint8 TabId = fields[0].GetUInt8(); - - GuildBankTab *NewTab = new GuildBankTab; - memset(NewTab->Slots, 0, GUILD_BANK_MAX_SLOTS * sizeof(Item*)); - - NewTab->Name = fields[1].GetCppString(); - NewTab->Icon = fields[2].GetCppString(); - NewTab->Text = fields[3].GetCppString(); - - m_TabListMap[TabId] = NewTab; - }while( result->NextRow() ); - - delete result; - - // 0 1 2 3 - result = CharacterDatabase.PQuery("SELECT TabId, SlotId, item_guid, item_entry FROM guild_bank_item WHERE guildid='%u' ORDER BY TabId", Id); - if(!result) - return; - - do - { - Field *fields = result->Fetch(); - uint8 TabId = fields[0].GetUInt8(); - uint8 SlotId = fields[1].GetUInt8(); - uint32 ItemGuid = fields[2].GetUInt32(); - uint32 ItemEntry = fields[3].GetUInt32(); - - if (TabId >= purchased_tabs || TabId >= GUILD_BANK_MAX_TABS) - { - sLog.outError( "Guild::LoadGuildBankFromDB: Invalid tab for item (GUID: %u id: #%u) in guild bank, skipped.", ItemGuid,ItemEntry); - continue; - } - - if (SlotId >= GUILD_BANK_MAX_SLOTS) - { - sLog.outError( "Guild::LoadGuildBankFromDB: Invalid slot for item (GUID: %u id: #%u) in guild bank, skipped.", ItemGuid,ItemEntry); - continue; - } - - ItemPrototype const *proto = objmgr.GetItemPrototype(ItemEntry); - - if(!proto) - { - sLog.outError( "Guild::LoadGuildBankFromDB: Unknown item (GUID: %u id: #%u) in guild bank, skipped.", ItemGuid,ItemEntry); - continue; - } - - Item *pItem = NewItemOrBag(proto); - if(!pItem->LoadFromDB(ItemGuid, 0)) - { - CharacterDatabase.PExecute("DELETE FROM guild_bank_item WHERE guildid='%u' AND TabId='%u' AND SlotId='%u'", Id, uint32(TabId), uint32(SlotId)); - sLog.outError("Item GUID %u not found in item_instance, deleting from Guild Bank!", ItemGuid); - delete pItem; - continue; - } - - pItem->AddToWorld(); - m_TabListMap[TabId]->Slots[SlotId] = pItem; - }while( result->NextRow() ); - - delete result; -} - -// This unload should be called when the last member of the guild gets offline -void Guild::UnloadGuildBank() -{ - if (!m_bankloaded) - return; - for (uint8 i = 0 ; i < purchased_tabs ; ++i ) - { - for (uint8 j = 0 ; j < GUILD_BANK_MAX_SLOTS ; ++j) - { - if (m_TabListMap[i]->Slots[j]) - { - m_TabListMap[i]->Slots[j]->RemoveFromWorld(); - delete m_TabListMap[i]->Slots[j]; - } - } - delete m_TabListMap[i]; - } - m_TabListMap.clear(); - - UnloadGuildBankEventLog(); - m_bankloaded = false; -} - -// ************************************************* -// Money deposit/withdraw related - -void Guild::SendMoneyInfo(WorldSession *session, uint32 LowGuid) -{ - WorldPacket data(MSG_GUILD_BANK_MONEY_WITHDRAWN, 4); - data << uint32(GetMemberMoneyWithdrawRem(LowGuid)); - session->SendPacket(&data); - sLog.outDebug("WORLD: Sent MSG_GUILD_BANK_MONEY_WITHDRAWN"); -} - -bool Guild::MemberMoneyWithdraw(uint32 amount, uint32 LowGuid) -{ - uint32 MoneyWithDrawRight = GetMemberMoneyWithdrawRem(LowGuid); - - if (MoneyWithDrawRight < amount || GetGuildBankMoney() < amount) - return false; - - SetBankMoney(GetGuildBankMoney()-amount); - - if (MoneyWithDrawRight < WITHDRAW_MONEY_UNLIMITED) - { - MemberList::iterator itr = members.find(LowGuid); - if (itr == members.end() ) - return false; - itr->second.BankRemMoney -= amount; - CharacterDatabase.PExecute("UPDATE guild_member SET BankRemMoney='%u' WHERE guildid='%u' AND guid='%u'", - itr->second.BankRemMoney, Id, LowGuid); - } - return true; -} - -void Guild::SetBankMoney(int64 money) -{ - if (money < 0) // I don't know how this happens, it does!! - money = 0; - guildbank_money = money; - - CharacterDatabase.PExecute("UPDATE guild SET BankMoney='" I64FMTD "' WHERE guildid='%u'", money, Id); -} - -// ************************************************* -// Item per day and money per day related - -bool Guild::MemberItemWithdraw(uint8 TabId, uint32 LowGuid) -{ - uint32 SlotsWithDrawRight = GetMemberSlotWithdrawRem(LowGuid, TabId); - - if (SlotsWithDrawRight == 0) - return false; - - if (SlotsWithDrawRight < WITHDRAW_SLOT_UNLIMITED) - { - MemberList::iterator itr = members.find(LowGuid); - if (itr == members.end() ) - return false; - --itr->second.BankRemSlotsTab[TabId]; - CharacterDatabase.PExecute("UPDATE guild_member SET BankRemSlotsTab%u='%u' WHERE guildid='%u' AND guid='%u'", - uint32(TabId), itr->second.BankRemSlotsTab[TabId], Id, LowGuid); - } - return true; -} - -bool Guild::IsMemberHaveRights(uint32 LowGuid, uint8 TabId, uint32 rights) const -{ - MemberList::const_iterator itr = members.find(LowGuid); - if (itr == members.end() ) - return false; - - if (itr->second.RankId == GR_GUILDMASTER) - return true; - - return (GetBankRights(itr->second.RankId,TabId) & rights)==rights; -} - -uint32 Guild::GetMemberSlotWithdrawRem(uint32 LowGuid, uint8 TabId) -{ - MemberList::iterator itr = members.find(LowGuid); - if (itr == members.end() ) - return 0; - - if (itr->second.RankId == GR_GUILDMASTER) - return WITHDRAW_SLOT_UNLIMITED; - - if((GetBankRights(itr->second.RankId,TabId) & GUILD_BANK_RIGHT_VIEW_TAB)!=GUILD_BANK_RIGHT_VIEW_TAB) - return 0; - - uint32 curTime = uint32(time(NULL)/MINUTE); - if (curTime - itr->second.BankResetTimeTab[TabId] >= 24*HOUR/MINUTE) - { - itr->second.BankResetTimeTab[TabId] = curTime; - itr->second.BankRemSlotsTab[TabId] = GetBankSlotPerDay(itr->second.RankId, TabId); - CharacterDatabase.PExecute("UPDATE guild_member SET BankResetTimeTab%u='%u',BankRemSlotsTab%u='%u' WHERE guildid='%u' AND guid='%u'", - uint32(TabId), itr->second.BankResetTimeTab[TabId], uint32(TabId), itr->second.BankRemSlotsTab[TabId], Id, LowGuid); - } - return itr->second.BankRemSlotsTab[TabId]; -} - -uint32 Guild::GetMemberMoneyWithdrawRem(uint32 LowGuid) -{ - MemberList::iterator itr = members.find(LowGuid); - if (itr == members.end() ) - return 0; - - if (itr->second.RankId == GR_GUILDMASTER) - return WITHDRAW_MONEY_UNLIMITED; - - uint32 curTime = uint32(time(NULL)/MINUTE); // minutes - // 24 hours - if (curTime > itr->second.BankResetTimeMoney + 24*HOUR/MINUTE) - { - itr->second.BankResetTimeMoney = curTime; - itr->second.BankRemMoney = GetBankMoneyPerDay(itr->second.RankId); - CharacterDatabase.PExecute("UPDATE guild_member SET BankResetTimeMoney='%u',BankRemMoney='%u' WHERE guildid='%u' AND guid='%u'", - itr->second.BankResetTimeMoney, itr->second.BankRemMoney, Id, LowGuid); - } - return itr->second.BankRemMoney; -} - -void Guild::SetBankMoneyPerDay(uint32 rankId, uint32 money) -{ - if (rankId >= m_ranks.size()) - return; - - if (rankId == GR_GUILDMASTER) - money = WITHDRAW_MONEY_UNLIMITED; - - m_ranks[rankId].BankMoneyPerDay = money; - - for (MemberList::iterator itr = members.begin(); itr != members.end(); ++itr) - if (itr->second.RankId == rankId) - itr->second.BankResetTimeMoney = 0; - - CharacterDatabase.PExecute("UPDATE guild_rank SET BankMoneyPerDay='%u' WHERE rid='%u' AND guildid='%u'", money, (rankId+1), Id); - CharacterDatabase.PExecute("UPDATE guild_member SET BankResetTimeMoney='0' WHERE guildid='%u' AND rank='%u'", Id, rankId); -} - -void Guild::SetBankRightsAndSlots(uint32 rankId, uint8 TabId, uint32 right, uint32 nbSlots, bool db) -{ - if(rankId >= m_ranks.size() || - TabId >= GUILD_BANK_MAX_TABS || - TabId >= purchased_tabs) - return; - - if (rankId == GR_GUILDMASTER) - { - nbSlots = WITHDRAW_SLOT_UNLIMITED; - right = GUILD_BANK_RIGHT_FULL; - } - - m_ranks[rankId].TabSlotPerDay[TabId]=nbSlots; - m_ranks[rankId].TabRight[TabId]=right; - - if (db) - { - for (MemberList::iterator itr = members.begin(); itr != members.end(); ++itr) - if (itr->second.RankId == rankId) - for (int i = 0; i < GUILD_BANK_MAX_TABS; ++i) - itr->second.BankResetTimeTab[i] = 0; - - CharacterDatabase.PExecute("DELETE FROM guild_bank_right WHERE guildid='%u' AND TabId='%u' AND rid='%u'", Id, uint32(TabId), rankId); - CharacterDatabase.PExecute("INSERT INTO guild_bank_right (guildid,TabId,rid,gbright,SlotPerDay) VALUES " - "('%u','%u','%u','%u','%u')", Id, uint32(TabId), rankId, m_ranks[rankId].TabRight[TabId], m_ranks[rankId].TabSlotPerDay[TabId]); - CharacterDatabase.PExecute("UPDATE guild_member SET BankResetTimeTab%u='0' WHERE guildid='%u' AND rank='%u'", uint32(TabId), Id, rankId); - } -} - -uint32 Guild::GetBankMoneyPerDay(uint32 rankId) -{ - if(rankId >= m_ranks.size()) - return 0; - - if (rankId == GR_GUILDMASTER) - return WITHDRAW_MONEY_UNLIMITED; - return m_ranks[rankId].BankMoneyPerDay; -} - -uint32 Guild::GetBankSlotPerDay(uint32 rankId, uint8 TabId) -{ - if(rankId >= m_ranks.size() || TabId >= GUILD_BANK_MAX_TABS) - return 0; - - if (rankId == GR_GUILDMASTER) - return WITHDRAW_SLOT_UNLIMITED; - return m_ranks[rankId].TabSlotPerDay[TabId]; -} - -// ************************************************* -// Rights per day related - -void Guild::LoadBankRightsFromDB(uint32 GuildId) -{ - // 0 1 2 3 - QueryResult *result = CharacterDatabase.PQuery("SELECT TabId, rid, gbright, SlotPerDay FROM guild_bank_right WHERE guildid = '%u' ORDER BY TabId", GuildId); - - if(!result) - return; - - do - { - Field *fields = result->Fetch(); - uint8 TabId = fields[0].GetUInt8(); - uint32 rankId = fields[1].GetUInt32(); - uint16 right = fields[2].GetUInt16(); - uint16 SlotPerDay = fields[3].GetUInt16(); - - SetBankRightsAndSlots(rankId, TabId, right, SlotPerDay, false); - - }while( result->NextRow() ); - delete result; - - return; -} - -// ************************************************* -// Bank log related - -void Guild::LoadGuildBankEventLogFromDB() -{ - // We can't add a limit as in Guild::LoadGuildEventLogFromDB since we fetch both money and bank log and know nothing about the composition - // 0 1 2 3 4 5 6 7 - QueryResult *result = CharacterDatabase.PQuery("SELECT LogGuid, LogEntry, TabId, PlayerGuid, ItemOrMoney, ItemStackCount, DestTabId, TimeStamp FROM guild_bank_eventlog WHERE guildid='%u' ORDER BY TimeStamp DESC", Id); - if(!result) - return; - - do - { - Field *fields = result->Fetch(); - GuildBankEvent *NewEvent = new GuildBankEvent; - - NewEvent->LogGuid = fields[0].GetUInt32(); - NewEvent->LogEntry = fields[1].GetUInt8(); - uint8 TabId = fields[2].GetUInt8(); - NewEvent->PlayerGuid = fields[3].GetUInt32(); - NewEvent->ItemOrMoney = fields[4].GetUInt32(); - NewEvent->ItemStackCount = fields[5].GetUInt8(); - NewEvent->DestTabId = fields[6].GetUInt8(); - NewEvent->TimeStamp = fields[7].GetUInt64(); - - if (TabId >= GUILD_BANK_MAX_TABS) - { - sLog.outError( "Guild::LoadGuildBankEventLogFromDB: Invalid tabid '%u' for guild bank log entry (guild: '%s', LogGuid: %u), skipped.", TabId, GetName().c_str(), NewEvent->LogGuid); - delete NewEvent; - continue; - } - if (NewEvent->isMoneyEvent() && m_GuildBankEventLog_Money.size() >= GUILD_BANK_MAX_LOGS - || m_GuildBankEventLog_Item[TabId].size() >= GUILD_BANK_MAX_LOGS) - { - delete NewEvent; - continue; - } - if (NewEvent->isMoneyEvent()) - m_GuildBankEventLog_Money.push_front(NewEvent); - else - m_GuildBankEventLog_Item[TabId].push_front(NewEvent); - - }while( result->NextRow() ); - delete result; - - // Check lists size in case to many event entries in db for a tab or for money - // This cases can happen only if a crash occured somewhere and table has too many log entries - if (!m_GuildBankEventLog_Money.empty()) - { - CharacterDatabase.PExecute("DELETE FROM guild_bank_eventlog WHERE guildid=%u AND LogGuid < %u", - Id, m_GuildBankEventLog_Money.front()->LogGuid); - } - for (int i = 0; i < GUILD_BANK_MAX_TABS; ++i) - { - if (!m_GuildBankEventLog_Item[i].empty()) - { - CharacterDatabase.PExecute("DELETE FROM guild_bank_eventlog WHERE guildid=%u AND LogGuid < %u", - Id, m_GuildBankEventLog_Item[i].front()->LogGuid); - } - } -} - -void Guild::UnloadGuildBankEventLog() -{ - GuildBankEvent *EventLogEntry; - if( !m_GuildBankEventLog_Money.empty() ) - { - do - { - EventLogEntry = *(m_GuildBankEventLog_Money.begin()); - m_GuildBankEventLog_Money.pop_front(); - delete EventLogEntry; - }while( !m_GuildBankEventLog_Money.empty() ); - } - - for (int i = 0; i < GUILD_BANK_MAX_TABS; ++i) - { - if( !m_GuildBankEventLog_Item[i].empty() ) - { - do - { - EventLogEntry = *(m_GuildBankEventLog_Item[i].begin()); - m_GuildBankEventLog_Item[i].pop_front(); - delete EventLogEntry; - }while( !m_GuildBankEventLog_Item[i].empty() ); - } - } -} - -void Guild::DisplayGuildBankLogs(WorldSession *session, uint8 TabId) -{ - if (TabId > GUILD_BANK_MAX_TABS) - return; - - if (TabId == GUILD_BANK_MAX_TABS) - { - // Here we display money logs - WorldPacket data(MSG_GUILD_BANK_LOG_QUERY, m_GuildBankEventLog_Money.size()*(4*4+1)+1+1); - data << uint8(TabId); // Here GUILD_BANK_MAX_TABS - data << uint8(m_GuildBankEventLog_Money.size()); // number of log entries - for (GuildBankEventLog::const_iterator itr = m_GuildBankEventLog_Money.begin(); itr != m_GuildBankEventLog_Money.end(); ++itr) - { - data << uint8((*itr)->LogEntry); - data << uint64(MAKE_NEW_GUID((*itr)->PlayerGuid,0,HIGHGUID_PLAYER)); - data << uint32((*itr)->ItemOrMoney); - data << uint32(time(NULL)-(*itr)->TimeStamp); - } - session->SendPacket(&data); - } - else - { - // here we display current tab logs - WorldPacket data(MSG_GUILD_BANK_LOG_QUERY, m_GuildBankEventLog_Item[TabId].size()*(4*4+1+1)+1+1); - data << uint8(TabId); // Here a real Tab Id - // number of log entries - data << uint8(m_GuildBankEventLog_Item[TabId].size()); - for (GuildBankEventLog::const_iterator itr = m_GuildBankEventLog_Item[TabId].begin(); itr != m_GuildBankEventLog_Item[TabId].end(); ++itr) - { - data << uint8((*itr)->LogEntry); - data << uint64(MAKE_NEW_GUID((*itr)->PlayerGuid,0,HIGHGUID_PLAYER)); - data << uint32((*itr)->ItemOrMoney); - data << uint8((*itr)->ItemStackCount); - if ((*itr)->LogEntry == GUILD_BANK_LOG_MOVE_ITEM || (*itr)->LogEntry == GUILD_BANK_LOG_MOVE_ITEM2) - data << uint8((*itr)->DestTabId); // moved tab - data << uint32(time(NULL)-(*itr)->TimeStamp); - } - session->SendPacket(&data); - } - sLog.outDebug("WORLD: Sent (MSG_GUILD_BANK_LOG_QUERY)"); -} - -void Guild::LogBankEvent(uint8 LogEntry, uint8 TabId, uint32 PlayerGuidLow, uint32 ItemOrMoney, uint8 ItemStackCount, uint8 DestTabId) -{ - GuildBankEvent *NewEvent = new GuildBankEvent; - - NewEvent->LogGuid = LogMaxGuid++; - NewEvent->LogEntry = LogEntry; - NewEvent->PlayerGuid = PlayerGuidLow; - NewEvent->ItemOrMoney = ItemOrMoney; - NewEvent->ItemStackCount = ItemStackCount; - NewEvent->DestTabId = DestTabId; - NewEvent->TimeStamp = uint32(time(NULL)); - - if (NewEvent->isMoneyEvent()) - { - if (m_GuildBankEventLog_Money.size() > GUILD_BANK_MAX_LOGS) - { - GuildBankEvent *OldEvent = *(m_GuildBankEventLog_Money.begin()); - m_GuildBankEventLog_Money.pop_front(); - CharacterDatabase.PExecute("DELETE FROM guild_bank_eventlog WHERE guildid='%u' AND LogGuid='%u'", Id, OldEvent->LogGuid); - delete OldEvent; - } - m_GuildBankEventLog_Money.push_back(NewEvent); - } - else - { - if (m_GuildBankEventLog_Item[TabId].size() > GUILD_BANK_MAX_LOGS) - { - GuildBankEvent *OldEvent = *(m_GuildBankEventLog_Item[TabId].begin()); - m_GuildBankEventLog_Item[TabId].pop_front(); - CharacterDatabase.PExecute("DELETE FROM guild_bank_eventlog WHERE guildid='%u' AND LogGuid='%u'", Id, OldEvent->LogGuid); - delete OldEvent; - } - m_GuildBankEventLog_Item[TabId].push_back(NewEvent); - } - CharacterDatabase.PExecute("INSERT INTO guild_bank_eventlog (guildid,LogGuid,LogEntry,TabId,PlayerGuid,ItemOrMoney,ItemStackCount,DestTabId,TimeStamp) VALUES ('%u','%u','%u','%u','%u','%u','%u','%u','" I64FMTD "')", - Id, NewEvent->LogGuid, uint32(NewEvent->LogEntry), uint32(TabId), NewEvent->PlayerGuid, NewEvent->ItemOrMoney, uint32(NewEvent->ItemStackCount), uint32(NewEvent->DestTabId), NewEvent->TimeStamp); -} - -// This will renum guids used at load to prevent always going up until infinit -void Guild::RenumBankLogs() -{ - QueryResult *result = CharacterDatabase.PQuery("SELECT Min(LogGuid), Max(LogGuid) FROM guild_bank_eventlog WHERE guildid = %u", Id); - if(!result) - return; - - Field *fields = result->Fetch(); - CharacterDatabase.PExecute("UPDATE guild_bank_eventlog SET LogGuid=LogGuid-%u+1 WHERE guildid=%u ORDER BY LogGuid %s",fields[0].GetUInt32(), Id, fields[0].GetUInt32()?"ASC":"DESC"); - LogMaxGuid = fields[1].GetUInt32()+1; - delete result; -} - -bool Guild::AddGBankItemToDB(uint32 GuildId, uint32 BankTab , uint32 BankTabSlot , uint32 GUIDLow, uint32 Entry ) -{ - CharacterDatabase.PExecute("DELETE FROM guild_bank_item WHERE guildid = '%u' AND TabId = '%u'AND SlotId = '%u'", GuildId, BankTab, BankTabSlot); - CharacterDatabase.PExecute("INSERT INTO guild_bank_item (guildid,TabId,SlotId,item_guid,item_entry) " - "VALUES ('%u', '%u', '%u', '%u', '%u')", GuildId, BankTab, BankTabSlot, GUIDLow, Entry); - return true; -} - -void Guild::AppendDisplayGuildBankSlot( WorldPacket& data, GuildBankTab const *tab, int slot ) -{ - Item *pItem = tab->Slots[slot]; - uint32 entry = pItem ? pItem->GetEntry() : 0; - - data << uint8(slot); - data << uint32(entry); - if (entry) - { - // random item property id +8 - data << (uint32) pItem->GetItemRandomPropertyId(); - if (pItem->GetItemRandomPropertyId()) - // SuffixFactor +4 - data << (uint32) pItem->GetItemSuffixFactor(); - // +12 // ITEM_FIELD_STACK_COUNT - data << uint8(pItem->GetCount()); - data << uint32(0); // +16 // Unknown value - data << uint8(0); // unknown 2.4.2 - if (uint32 Enchant0 = pItem->GetEnchantmentId(PERM_ENCHANTMENT_SLOT)) - { - data << uint8(1); // number of enchantments (max 3) why max 3? - data << uint8(PERM_ENCHANTMENT_SLOT); // enchantment slot (range: 0:2) - data << uint32(Enchant0); // enchantment id - } - else - data << uint8(0); // no enchantments (0) - } -} - -Item* Guild::StoreItem(uint8 tabId, GuildItemPosCountVec const& dest, Item* pItem ) -{ - if( !pItem ) - return NULL; - - Item* lastItem = pItem; - - for(GuildItemPosCountVec::const_iterator itr = dest.begin(); itr != dest.end(); ) - { - uint8 slot = itr->slot; - uint32 count = itr->count; - - ++itr; - - if(itr == dest.end()) - { - lastItem = _StoreItem(tabId,slot,pItem,count,false); - break; - } - - lastItem = _StoreItem(tabId,slot,pItem,count,true); - } - - return lastItem; -} - -// Return stored item (if stored to stack, it can diff. from pItem). And pItem ca be deleted in this case. -Item* Guild::_StoreItem( uint8 tab, uint8 slot, Item *pItem, uint32 count, bool clone ) -{ - if( !pItem ) - return NULL; - - sLog.outDebug( "GUILD STORAGE: StoreItem tab = %u, slot = %u, item = %u, count = %u", tab, slot, pItem->GetEntry(), count); - - Item* pItem2 = m_TabListMap[tab]->Slots[slot]; - - if( !pItem2 ) - { - if(clone) - pItem = pItem->CloneItem(count); - else - pItem->SetCount(count); - - if(!pItem) - return NULL; - - m_TabListMap[tab]->Slots[slot] = pItem; - - pItem->SetUInt64Value(ITEM_FIELD_CONTAINED, 0); - pItem->SetUInt64Value(ITEM_FIELD_OWNER, 0); - AddGBankItemToDB(GetId(), tab, slot, pItem->GetGUIDLow(), pItem->GetEntry()); - pItem->FSetState(ITEM_NEW); - pItem->SaveToDB(); // not in onventory and can be save standalone - - return pItem; - } - else - { - pItem2->SetCount( pItem2->GetCount() + count ); - pItem2->FSetState(ITEM_CHANGED); - pItem2->SaveToDB(); // not in onventory and can be save standalone - - if(!clone) - { - pItem->RemoveFromWorld(); - pItem->DeleteFromDB(); - delete pItem; - } - - return pItem2; - } -} - -void Guild::RemoveItem(uint8 tab, uint8 slot ) -{ - m_TabListMap[tab]->Slots[slot] = NULL; - CharacterDatabase.PExecute("DELETE FROM guild_bank_item WHERE guildid='%u' AND TabId='%u' AND SlotId='%u'", - GetId(), uint32(tab), uint32(slot)); -} - -uint8 Guild::_CanStoreItem_InSpecificSlot( uint8 tab, uint8 slot, GuildItemPosCountVec &dest, uint32& count, bool swap, Item* pSrcItem ) const -{ - Item* pItem2 = m_TabListMap[tab]->Slots[slot]; - - // ignore move item (this slot will be empty at move) - if(pItem2==pSrcItem) - pItem2 = NULL; - - uint32 need_space; - - // empty specific slot - check item fit to slot - if( !pItem2 || swap ) - { - // non empty stack with space - need_space = pSrcItem->GetMaxStackCount(); - } - // non empty slot, check item type - else - { - // check item type - if(pItem2->GetEntry() != pSrcItem->GetEntry()) - return EQUIP_ERR_ITEM_CANT_STACK; - - // check free space - if(pItem2->GetCount() >= pSrcItem->GetMaxStackCount()) - return EQUIP_ERR_ITEM_CANT_STACK; - - need_space = pSrcItem->GetMaxStackCount() - pItem2->GetCount(); - } - - if(need_space > count) - need_space = count; - - dest.push_back(GuildItemPosCount(slot,need_space)); - count -= need_space; - return EQUIP_ERR_OK; -} - -uint8 Guild::_CanStoreItem_InTab( uint8 tab, GuildItemPosCountVec &dest, uint32& count, bool merge, Item* pSrcItem, uint8 skip_slot ) const -{ - for(uint32 j = 0; j < GUILD_BANK_MAX_SLOTS; j++) - { - // skip specific slot already processed in first called _CanStoreItem_InSpecificSlot - if(j==skip_slot) - continue; - - Item* pItem2 = m_TabListMap[tab]->Slots[j]; - - // ignore move item (this slot will be empty at move) - if(pItem2==pSrcItem) - pItem2 = NULL; - - // if merge skip empty, if !merge skip non-empty - if((pItem2!=NULL)!=merge) - continue; - - if( pItem2 ) - { - if(pItem2->GetEntry() == pSrcItem->GetEntry() && pItem2->GetCount() < pSrcItem->GetMaxStackCount() ) - { - uint32 need_space = pSrcItem->GetMaxStackCount() - pItem2->GetCount(); - if(need_space > count) - need_space = count; - - dest.push_back(GuildItemPosCount(j,need_space)); - count -= need_space; - - if(count==0) - return EQUIP_ERR_OK; - } - } - else - { - uint32 need_space = pSrcItem->GetMaxStackCount(); - if(need_space > count) - need_space = count; - - dest.push_back(GuildItemPosCount(j,need_space)); - count -= need_space; - - if(count==0) - return EQUIP_ERR_OK; - } - } - return EQUIP_ERR_OK; -} - -uint8 Guild::CanStoreItem( uint8 tab, uint8 slot, GuildItemPosCountVec &dest, uint32 count, Item *pItem, bool swap ) const -{ - sLog.outDebug( "GUILD STORAGE: CanStoreItem tab = %u, slot = %u, item = %u, count = %u", tab, slot, pItem->GetEntry(), count); - - if(count > pItem->GetCount()) - return EQUIP_ERR_COULDNT_SPLIT_ITEMS; - - if(pItem->IsSoulBound()) - return EQUIP_ERR_CANT_DROP_SOULBOUND; - - // in specific slot - if( slot != NULL_SLOT ) - { - uint8 res = _CanStoreItem_InSpecificSlot(tab,slot,dest,count,swap,pItem); - if(res!=EQUIP_ERR_OK) - return res; - - if(count==0) - return EQUIP_ERR_OK; - } - - // not specific slot or have spece for partly store only in specific slot - - // search stack in tab for merge to - if( pItem->GetMaxStackCount() > 1 ) - { - uint8 res = _CanStoreItem_InTab(tab,dest,count,true,pItem,slot); - if(res!=EQUIP_ERR_OK) - return res; - - if(count==0) - return EQUIP_ERR_OK; - } - - // search free slot in bag for place to - uint8 res = _CanStoreItem_InTab(tab,dest,count,false,pItem,slot); - if(res!=EQUIP_ERR_OK) - return res; - - if(count==0) - return EQUIP_ERR_OK; - - return EQUIP_ERR_BANK_FULL; -} - -void Guild::SetGuildBankTabText(uint8 TabId, std::string text) -{ - if (TabId >= GUILD_BANK_MAX_TABS) - return; - if (TabId >= m_TabListMap.size()) - return; - if (!m_TabListMap[TabId]) - return; - - if(m_TabListMap[TabId]->Text==text) - return; - - utf8truncate(text,500); // DB and client size limitation - - m_TabListMap[TabId]->Text = text; - - CharacterDatabase.escape_string(text); - CharacterDatabase.PExecute("UPDATE guild_bank_tab SET TabText='%s' WHERE guildid='%u' AND TabId='%u'", text.c_str(), Id, uint32(TabId)); -} - -void Guild::SendGuildBankTabText(WorldSession *session, uint8 TabId) -{ - if (TabId > GUILD_BANK_MAX_TABS) - return; - - GuildBankTab const *tab = GetBankTab(TabId); - if (!tab) - return; - - WorldPacket data(MSG_QUERY_GUILD_BANK_TEXT, 1+tab->Text.size()+1); - data << uint8(TabId); - data << tab->Text; - session->SendPacket(&data); -} +/* + * Copyright (C) 2005-2008 MaNGOS + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "Database/DatabaseEnv.h" +#include "WorldPacket.h" +#include "WorldSession.h" +#include "MapManager.h" +#include "Player.h" +#include "Opcodes.h" +#include "ObjectMgr.h" +#include "Guild.h" +#include "Chat.h" +#include "SocialMgr.h" +#include "Util.h" + +Guild::Guild() +{ + Id = 0; + name = ""; + leaderGuid = 0; + GINFO = MOTD = ""; + EmblemStyle = 0; + EmblemColor = 0; + BorderStyle = 0; + BorderColor = 0; + BackgroundColor = 0; + + CreatedYear = 0; + CreatedMonth = 0; + CreatedDay = 0; +} + +Guild::~Guild() +{ + +} + +bool Guild::create(uint64 lGuid, std::string gname) +{ + std::string rname; + std::string lName; + + if(!objmgr.GetPlayerNameByGUID(lGuid, lName)) + return false; + if(objmgr.GetGuildByName(gname)) + return false; + + sLog.outDebug("GUILD: creating guild %s to leader: %u", gname.c_str(), GUID_LOPART(lGuid)); + + leaderGuid = lGuid; + name = gname; + GINFO = ""; + MOTD = "No message set."; + guildbank_money = 0; + purchased_tabs = 0; + + QueryResult *result = CharacterDatabase.Query( "SELECT MAX(guildid) FROM guild" ); + if( result ) + { + Id = (*result)[0].GetUInt32()+1; + delete result; + } + else Id = 1; + + // gname already assigned to Guild::name, use it to encode string for DB + CharacterDatabase.escape_string(gname); + + std::string dbGINFO = GINFO; + std::string dbMOTD = MOTD; + CharacterDatabase.escape_string(dbGINFO); + CharacterDatabase.escape_string(dbMOTD); + + CharacterDatabase.BeginTransaction(); + // CharacterDatabase.PExecute("DELETE FROM guild WHERE guildid='%u'", Id); - MAX(guildid)+1 not exist + CharacterDatabase.PExecute("DELETE FROM guild_rank WHERE guildid='%u'", Id); + CharacterDatabase.PExecute("DELETE FROM guild_member WHERE guildid='%u'", Id); + CharacterDatabase.PExecute("INSERT INTO guild (guildid,name,leaderguid,info,motd,createdate,EmblemStyle,EmblemColor,BorderStyle,BorderColor,BackgroundColor,BankMoney) " + "VALUES('%u','%s','%u', '%s', '%s', NOW(),'%u','%u','%u','%u','%u','" I64FMTD "')", + Id, gname.c_str(), GUID_LOPART(leaderGuid), dbGINFO.c_str(), dbMOTD.c_str(), EmblemStyle, EmblemColor, BorderStyle, BorderColor, BackgroundColor, guildbank_money); + CharacterDatabase.CommitTransaction(); + + rname = "Guild Master"; + CreateRank(rname,GR_RIGHT_ALL); + rname = "Officer"; + CreateRank(rname,GR_RIGHT_ALL); + rname = "Veteran"; + CreateRank(rname,GR_RIGHT_GCHATLISTEN | GR_RIGHT_GCHATSPEAK); + rname = "Member"; + CreateRank(rname,GR_RIGHT_GCHATLISTEN | GR_RIGHT_GCHATSPEAK); + rname = "Initiate"; + CreateRank(rname,GR_RIGHT_GCHATLISTEN | GR_RIGHT_GCHATSPEAK); + + return AddMember(lGuid, (uint32)GR_GUILDMASTER); +} + +bool Guild::AddMember(uint64 plGuid, uint32 plRank) +{ + if(Player::GetGuildIdFromDB(plGuid) != 0) // player already in guild + return false; + + // remove all player signs from another petitions + // this will be prevent attempt joining player to many guilds and corrupt guild data integrity + Player::RemovePetitionsAndSigns(plGuid, 9); + + // fill player data + MemberSlot newmember; + + if(!FillPlayerData(plGuid, &newmember)) // problems with player data collection + return false; + + newmember.RankId = plRank; + newmember.OFFnote = (std::string)""; + newmember.Pnote = (std::string)""; + newmember.logout_time = time(NULL); + newmember.BankResetTimeMoney = 0; // this will force update at first query + for (int i = 0; i < GUILD_BANK_MAX_TABS; ++i) + newmember.BankResetTimeTab[i] = 0; + members[GUID_LOPART(plGuid)] = newmember; + + std::string dbPnote = newmember.Pnote; + std::string dbOFFnote = newmember.OFFnote; + CharacterDatabase.escape_string(dbPnote); + CharacterDatabase.escape_string(dbOFFnote); + + CharacterDatabase.PExecute("INSERT INTO guild_member (guildid,guid,rank,pnote,offnote) VALUES ('%u', '%u', '%u','%s','%s')", + Id, GUID_LOPART(plGuid), newmember.RankId, dbPnote.c_str(), dbOFFnote.c_str()); + + Player* pl = objmgr.GetPlayer(plGuid); + if(pl) + { + pl->SetInGuild(Id); + pl->SetRank(newmember.RankId); + pl->SetGuildIdInvited(0); + } + else + { + Player::SetUInt32ValueInDB(PLAYER_GUILDID, Id, plGuid); + Player::SetUInt32ValueInDB(PLAYER_GUILDRANK, newmember.RankId, plGuid); + } + return true; +} + +void Guild::SetMOTD(std::string motd) +{ + MOTD = motd; + + // motd now can be used for encoding to DB + CharacterDatabase.escape_string(motd); + CharacterDatabase.PExecute("UPDATE guild SET motd='%s' WHERE guildid='%u'", motd.c_str(), Id); +} + +void Guild::SetGINFO(std::string ginfo) +{ + GINFO = ginfo; + + // ginfo now can be used for encoding to DB + CharacterDatabase.escape_string(ginfo); + CharacterDatabase.PExecute("UPDATE guild SET info='%s' WHERE guildid='%u'", ginfo.c_str(), Id); +} + +bool Guild::LoadGuildFromDB(uint32 GuildId) +{ + if(!LoadRanksFromDB(GuildId)) + return false; + + if(!LoadMembersFromDB(GuildId)) + return false; + + QueryResult *result = CharacterDatabase.PQuery("SELECT MAX(TabId) FROM guild_bank_tab WHERE guildid='%u'", GuildId); + if(result) + { + Field *fields = result->Fetch(); + purchased_tabs = fields[0].GetUInt8()+1; // Because TabId begins at 0 + delete result; + } + else + purchased_tabs = 0; + + LoadBankRightsFromDB(GuildId); // Must be after LoadRanksFromDB because it populates rank struct + + // 0 1 2 3 4 5 6 + result = CharacterDatabase.PQuery("SELECT guildid, name, leaderguid, EmblemStyle, EmblemColor, BorderStyle, BorderColor," + // 7 8 9 10 11 + "BackgroundColor, info, motd, createdate, BankMoney FROM guild WHERE guildid = '%u'", GuildId); + + if(!result) + return false; + + Field *fields = result->Fetch(); + + Id = fields[0].GetUInt32(); + name = fields[1].GetCppString(); + leaderGuid = MAKE_NEW_GUID(fields[2].GetUInt32(), 0, HIGHGUID_PLAYER); + + EmblemStyle = fields[3].GetUInt32(); + EmblemColor = fields[4].GetUInt32(); + BorderStyle = fields[5].GetUInt32(); + BorderColor = fields[6].GetUInt32(); + BackgroundColor = fields[7].GetUInt32(); + GINFO = fields[8].GetCppString(); + MOTD = fields[9].GetCppString(); + uint64 time = fields[10].GetUInt64(); //datetime is uint64 type ... YYYYmmdd:hh:mm:ss + guildbank_money = fields[11].GetUInt64(); + + delete result; + + uint64 dTime = time /1000000; + CreatedDay = dTime%100; + CreatedMonth = (dTime/100)%100; + CreatedYear = (dTime/10000)%10000; + + // If the leader does not exist attempt to promote another member + if(!objmgr.GetPlayerAccountIdByGUID(leaderGuid )) + { + DelMember(leaderGuid); + + // check no members case (disbanded) + if(members.empty()) + return false; + } + + sLog.outDebug("Guild %u Creation time Loaded day: %u, month: %u, year: %u", GuildId, CreatedDay, CreatedMonth, CreatedYear); + m_bankloaded = false; + m_eventlogloaded = false; + m_onlinemembers = 0; + RenumBankLogs(); + RenumGuildEventlog(); + return true; +} + +bool Guild::LoadRanksFromDB(uint32 GuildId) +{ + Field *fields; + QueryResult *result = CharacterDatabase.PQuery("SELECT rname,rights,BankMoneyPerDay,rid FROM guild_rank WHERE guildid = '%u' ORDER BY rid ASC", GuildId); + + if(!result) + return false; + + bool broken_ranks = false; + + do + { + fields = result->Fetch(); + + std::string rankName = fields[0].GetCppString(); + uint32 rankRights = fields[1].GetUInt32(); + uint32 rankMoney = fields[2].GetUInt32(); + uint32 rankRID = fields[3].GetUInt32(); + + if(rankRID != m_ranks.size()+1) // guild_rank.rid always store rank+1 + broken_ranks = true; + + if(m_ranks.size()==GR_GUILDMASTER) // prevent loss leader rights + rankRights |= GR_RIGHT_ALL; + + AddRank(rankName,rankRights,rankMoney); + }while( result->NextRow() ); + delete result; + + if(m_ranks.size()==0) // empty rank table? + { + AddRank("Guild Master",GR_RIGHT_ALL,0); + broken_ranks = true; + } + + // guild_rank have wrong numbered ranks, repair + if(broken_ranks) + { + sLog.outError("Guild %u have broken `guild_rank` data, repairing...",GuildId); + CharacterDatabase.BeginTransaction(); + CharacterDatabase.PExecute("DELETE FROM guild_rank WHERE guildid='%u'", GuildId); + for(size_t i =0; i < m_ranks.size(); ++i) + { + // guild_rank.rid always store rank+1 + std::string name = m_ranks[i].name; + uint32 rights = m_ranks[i].rights; + CharacterDatabase.escape_string(name); + CharacterDatabase.PExecute( "INSERT INTO guild_rank (guildid,rid,rname,rights) VALUES ('%u', '%u', '%s', '%u')", GuildId, i+1, name.c_str(), rights); + } + CharacterDatabase.CommitTransaction(); + } + + return true; +} + +bool Guild::LoadMembersFromDB(uint32 GuildId) +{ + // 0 1 2 3 4 5 + QueryResult *result = CharacterDatabase.PQuery("SELECT guild_member.guid,rank, pnote, offnote, BankResetTimeMoney,BankRemMoney," + // 6 7 8 9 10 11 + "BankResetTimeTab0, BankRemSlotsTab0, BankResetTimeTab1, BankRemSlotsTab1, BankResetTimeTab2, BankRemSlotsTab2," + // 12 13 14 15 16 17 + "BankResetTimeTab3, BankRemSlotsTab3, BankResetTimeTab4, BankRemSlotsTab4, BankResetTimeTab5, BankRemSlotsTab5," + // 18 + "logout_time FROM guild_member LEFT JOIN characters ON characters.guid = guild_member.guid WHERE guildid = '%u'", GuildId); + + if(!result) + return false; + + do + { + Field *fields = result->Fetch(); + MemberSlot newmember; + newmember.RankId = fields[1].GetUInt32(); + uint64 guid = MAKE_NEW_GUID(fields[0].GetUInt32(), 0, HIGHGUID_PLAYER); + + // Player does not exist + if(!FillPlayerData(guid, &newmember)) + continue; + + newmember.Pnote = fields[2].GetCppString(); + newmember.OFFnote = fields[3].GetCppString(); + newmember.BankResetTimeMoney = fields[4].GetUInt32(); + newmember.BankRemMoney = fields[5].GetUInt32(); + for (int i = 0; i < GUILD_BANK_MAX_TABS; ++i) + { + newmember.BankResetTimeTab[i] = fields[6+(2*i)].GetUInt32(); + newmember.BankRemSlotsTab[i] = fields[7+(2*i)].GetUInt32(); + } + newmember.logout_time = fields[18].GetUInt64(); + members[GUID_LOPART(guid)] = newmember; + + }while( result->NextRow() ); + delete result; + + if(members.empty()) + return false; + + return true; +} + +bool Guild::FillPlayerData(uint64 guid, MemberSlot* memslot) +{ + std::string plName; + uint32 plLevel; + uint32 plClass; + uint32 plZone; + + Player* pl = objmgr.GetPlayer(guid); + if(pl) + { + plName = pl->GetName(); + plLevel = pl->getLevel(); + plClass = pl->getClass(); + plZone = pl->GetZoneId(); + } + else + { + if(!objmgr.GetPlayerNameByGUID(guid, plName)) // player doesn't exist + return false; + + plLevel = Player::GetUInt32ValueFromDB(UNIT_FIELD_LEVEL, guid); + if(plLevel<1||plLevel>255) // can be at broken `data` field + { + sLog.outError("Player (GUID: %u) has a broken data in field `characters`.`data`.",GUID_LOPART(guid)); + return false; + } + plZone = Player::GetZoneIdFromDB(guid); + + QueryResult *result = CharacterDatabase.PQuery("SELECT class FROM characters WHERE guid='%u'", GUID_LOPART(guid)); + if(!result) + return false; + plClass = (*result)[0].GetUInt32(); + if(plClass=MAX_CLASSES) // can be at broken `class` field + { + sLog.outError("Player (GUID: %u) has a broken data in field `characters`.`class`.",GUID_LOPART(guid)); + return false; + } + + delete result; + } + + memslot->name = plName; + memslot->level = plLevel; + memslot->Class = plClass; + memslot->zoneId = plZone; + + return(true); +} + +void Guild::LoadPlayerStatsByGuid(uint64 guid) +{ + MemberList::iterator itr = members.find(GUID_LOPART(guid)); + if (itr == members.end() ) + return; + + Player *pl = ObjectAccessor::FindPlayer(guid); + if(!pl) + return; + itr->second.name = pl->GetName(); + itr->second.level = pl->getLevel(); + itr->second.Class = pl->getClass(); +} + +void Guild::SetLeader(uint64 guid) +{ + leaderGuid = guid; + this->ChangeRank(guid, GR_GUILDMASTER); + + CharacterDatabase.PExecute("UPDATE guild SET leaderguid='%u' WHERE guildid='%u'", GUID_LOPART(guid), Id); +} + +void Guild::DelMember(uint64 guid, bool isDisbanding) +{ + if(this->leaderGuid == guid && !isDisbanding) + { + std::ostringstream ss; + ss<<"SELECT guid FROM guild_member WHERE guildid='"<SetLeader(newLeaderGUID); + + newLeader = objmgr.GetPlayer(newLeaderGUID); + if(newLeader) + { + newLeader->SetRank(GR_GUILDMASTER); + newLeaderName = newLeader->GetName(); + } + else + { + Player::SetUInt32ValueInDB(PLAYER_GUILDRANK, GR_GUILDMASTER, newLeaderGUID); + objmgr.GetPlayerNameByGUID(newLeaderGUID, newLeaderName); + } + + // when leader non-exist (at guild load with deleted leader only) not send broadcasts + if(objmgr.GetPlayerNameByGUID(guid, oldLeaderName)) + { + WorldPacket data(SMSG_GUILD_EVENT, (1+1+oldLeaderName.size()+1+newLeaderName.size()+1)); + data << (uint8)GE_LEADER_CHANGED; + data << (uint8)2; + data << oldLeaderName; + data << newLeaderName; + this->BroadcastPacket(&data); + + data.Initialize(SMSG_GUILD_EVENT, (1+1+oldLeaderName.size()+1)); + data << (uint8)GE_LEFT; + data << (uint8)1; + data << oldLeaderName; + this->BroadcastPacket(&data); + } + + sLog.outDebug( "WORLD: Sent (SMSG_GUILD_EVENT)" ); + } + else + { + this->Disband(); + return; + } + } + + members.erase(GUID_LOPART(guid)); + + Player *player = objmgr.GetPlayer(guid); + if(player) + { + player->SetInGuild(0); + player->SetRank(0); + } + else + { + Player::SetUInt32ValueInDB(PLAYER_GUILDID, 0, guid); + Player::SetUInt32ValueInDB(PLAYER_GUILDRANK, GR_GUILDMASTER, guid); + } + + CharacterDatabase.PExecute("DELETE FROM guild_member WHERE guid = '%u'", GUID_LOPART(guid)); +} + +void Guild::ChangeRank(uint64 guid, uint32 newRank) +{ + MemberList::iterator itr = members.find(GUID_LOPART(guid)); + if( itr != members.end() ) + itr->second.RankId = newRank; + + Player *player = objmgr.GetPlayer(guid); + if(player) + player->SetRank(newRank); + else + Player::SetUInt32ValueInDB(PLAYER_GUILDRANK, newRank, guid); + + CharacterDatabase.PExecute( "UPDATE guild_member SET rank='%u' WHERE guid='%u'", newRank, GUID_LOPART(guid) ); +} + +void Guild::SetPNOTE(uint64 guid,std::string pnote) +{ + MemberList::iterator itr = members.find(GUID_LOPART(guid)); + if( itr == members.end() ) + return; + + itr->second.Pnote = pnote; + + // pnote now can be used for encoding to DB + CharacterDatabase.escape_string(pnote); + CharacterDatabase.PExecute("UPDATE guild_member SET pnote = '%s' WHERE guid = '%u'", pnote.c_str(), itr->first); +} + +void Guild::SetOFFNOTE(uint64 guid,std::string offnote) +{ + MemberList::iterator itr = members.find(GUID_LOPART(guid)); + if( itr == members.end() ) + return; + itr->second.OFFnote = offnote; + // offnote now can be used for encoding to DB + CharacterDatabase.escape_string(offnote); + CharacterDatabase.PExecute("UPDATE guild_member SET offnote = '%s' WHERE guid = '%u'", offnote.c_str(), itr->first); +} + +void Guild::BroadcastToGuild(WorldSession *session, std::string msg, uint32 language) +{ + if (session && session->GetPlayer() && HasRankRight(session->GetPlayer()->GetRank(),GR_RIGHT_GCHATSPEAK)) + { + WorldPacket data; + ChatHandler(session).FillMessageData(&data, CHAT_MSG_GUILD, language, 0, msg.c_str()); + + for (MemberList::const_iterator itr = members.begin(); itr != members.end(); ++itr) + { + Player *pl = ObjectAccessor::FindPlayer(MAKE_NEW_GUID(itr->first, 0, HIGHGUID_PLAYER)); + + if (pl && pl->GetSession() && HasRankRight(pl->GetRank(),GR_RIGHT_GCHATLISTEN) && !pl->GetSocial()->HasIgnore(session->GetPlayer()->GetGUIDLow()) ) + pl->GetSession()->SendPacket(&data); + } + } +} + +void Guild::BroadcastToOfficers(WorldSession *session, std::string msg, uint32 language) +{ + if (session && session->GetPlayer() && HasRankRight(session->GetPlayer()->GetRank(),GR_RIGHT_OFFCHATSPEAK)) + { + for(MemberList::iterator itr = members.begin(); itr != members.end(); ++itr) + { + WorldPacket data; + ChatHandler::FillMessageData(&data, session, CHAT_MSG_OFFICER, language, NULL, 0, msg.c_str(),NULL); + + Player *pl = ObjectAccessor::FindPlayer(MAKE_NEW_GUID(itr->first, 0, HIGHGUID_PLAYER)); + + if (pl && pl->GetSession() && HasRankRight(pl->GetRank(),GR_RIGHT_OFFCHATLISTEN) && !pl->GetSocial()->HasIgnore(session->GetPlayer()->GetGUIDLow())) + pl->GetSession()->SendPacket(&data); + } + } +} + +void Guild::BroadcastPacket(WorldPacket *packet) +{ + for(MemberList::iterator itr = members.begin(); itr != members.end(); ++itr) + { + Player *player = ObjectAccessor::FindPlayer(MAKE_NEW_GUID(itr->first, 0, HIGHGUID_PLAYER)); + if(player) + player->GetSession()->SendPacket(packet); + } +} + +void Guild::BroadcastPacketToRank(WorldPacket *packet, uint32 rankId) +{ + for(MemberList::iterator itr = members.begin(); itr != members.end(); ++itr) + { + if (itr->second.RankId == rankId) + { + Player *player = ObjectAccessor::FindPlayer(MAKE_NEW_GUID(itr->first, 0, HIGHGUID_PLAYER)); + if(player) + player->GetSession()->SendPacket(packet); + } + } +} + +void Guild::CreateRank(std::string name_,uint32 rights) +{ + if(m_ranks.size() >= GUILD_MAX_RANKS) + return; + + AddRank(name_,rights,0); + + for (int i = 0; i < purchased_tabs; ++i) + { + CreateBankRightForTab(m_ranks.size()-1, uint8(i)); + } + + // guild_rank.rid always store rank+1 value + + // name now can be used for encoding to DB + CharacterDatabase.escape_string(name_); + CharacterDatabase.PExecute( "INSERT INTO guild_rank (guildid,rid,rname,rights) VALUES ('%u', '%u', '%s', '%u')", Id, m_ranks.size(), name_.c_str(), rights ); +} + +void Guild::AddRank(std::string name_,uint32 rights, uint32 money) +{ + m_ranks.push_back(RankInfo(name_,rights,money)); +} + +void Guild::DelRank() +{ + if(m_ranks.empty()) + return; + + // guild_rank.rid always store rank+1 value + uint32 rank = m_ranks.size()-1; + CharacterDatabase.PExecute("DELETE FROM guild_rank WHERE rid>='%u' AND guildid='%u'", (rank+1), Id); + + m_ranks.pop_back(); +} + +std::string Guild::GetRankName(uint32 rankId) +{ + if(rankId >= m_ranks.size()) + return ""; + + return m_ranks[rankId].name; +} + +uint32 Guild::GetRankRights(uint32 rankId) +{ + if(rankId >= m_ranks.size()) + return 0; + + return m_ranks[rankId].rights; +} + +void Guild::SetRankName(uint32 rankId, std::string name_) +{ + if(rankId >= m_ranks.size()) + return; + + m_ranks[rankId].name = name_; + + // name now can be used for encoding to DB + CharacterDatabase.escape_string(name_); + CharacterDatabase.PExecute("UPDATE guild_rank SET rname='%s' WHERE rid='%u' AND guildid='%u'", name_.c_str(), (rankId+1), Id); +} + +void Guild::SetRankRights(uint32 rankId, uint32 rights) +{ + if(rankId >= m_ranks.size()) + return; + + m_ranks[rankId].rights = rights; + + CharacterDatabase.PExecute("UPDATE guild_rank SET rights='%u' WHERE rid='%u' AND guildid='%u'", rights, (rankId+1), Id); +} + +void Guild::Disband() +{ + WorldPacket data(SMSG_GUILD_EVENT, 1); + data << (uint8)GE_DISBANDED; + this->BroadcastPacket(&data); + + while (!members.empty()) + { + MemberList::iterator itr = members.begin(); + DelMember(MAKE_NEW_GUID(itr->first, 0, HIGHGUID_PLAYER), true); + } + + CharacterDatabase.BeginTransaction(); + CharacterDatabase.PExecute("DELETE FROM guild WHERE guildid = '%u'",Id); + CharacterDatabase.PExecute("DELETE FROM guild_rank WHERE guildid = '%u'",Id); + CharacterDatabase.PExecute("DELETE FROM guild_bank_tab WHERE guildid = '%u'",Id); + CharacterDatabase.PExecute("DELETE FROM guild_bank_item WHERE guildid = '%u'",Id); + CharacterDatabase.PExecute("DELETE FROM guild_bank_right WHERE guildid = '%u'",Id); + CharacterDatabase.PExecute("DELETE FROM guild_bank_eventlog WHERE guildid = '%u'",Id); + CharacterDatabase.PExecute("DELETE FROM guild_eventlog WHERE guildid = '%u'",Id); + CharacterDatabase.CommitTransaction(); + objmgr.RemoveGuild(this); +} + +void Guild::Roster(WorldSession *session) +{ + // we can only guess size + WorldPacket data(SMSG_GUILD_ROSTER, (4+MOTD.length()+1+GINFO.length()+1+4+m_ranks.size()*(4+4+GUILD_BANK_MAX_TABS*(4+4))+members.size()*50)); + data << (uint32)members.size(); + data << MOTD; + data << GINFO; + + data << (uint32)m_ranks.size(); + for (RankList::iterator ritr = m_ranks.begin(); ritr != m_ranks.end();++ritr) + { + data << (uint32)ritr->rights; + data << (uint32)ritr->BankMoneyPerDay; // count of: withdraw gold(gold/day) Note: in game set gold, in packet set bronze. + for (int i = 0; i < GUILD_BANK_MAX_TABS; ++i) + { + data << (uint32)ritr->TabRight[i]; // for TAB_i rights: view tabs = 0x01, deposit items =0x02 + data << (uint32)ritr->TabSlotPerDay[i]; // for TAB_i count of: withdraw items(stack/day) + } + } + for (MemberList::iterator itr = members.begin(); itr != members.end(); ++itr) + { + if (Player *pl = ObjectAccessor::FindPlayer(MAKE_NEW_GUID(itr->first, 0, HIGHGUID_PLAYER))) + { + data << (uint64)pl->GetGUID(); + data << (uint8)1; + data << (std::string)pl->GetName(); + data << (uint32)itr->second.RankId; + data << (uint8)pl->getLevel(); + data << (uint8)pl->getClass(); + data << (uint8)0; // new 2.4.0 + data << (uint32)pl->GetZoneId(); + data << itr->second.Pnote; + data << itr->second.OFFnote; + } + else + { + data << uint64(MAKE_NEW_GUID(itr->first, 0, HIGHGUID_PLAYER)); + data << (uint8)0; + data << itr->second.name; + data << (uint32)itr->second.RankId; + data << (uint8)itr->second.level; + data << (uint8)itr->second.Class; + data << (uint8)0; // new 2.4.0 + data << (uint32)itr->second.zoneId; + data << (float(time(NULL)-itr->second.logout_time) / DAY); + data << itr->second.Pnote; + data << itr->second.OFFnote; + } + } + session->SendPacket(&data);; + sLog.outDebug( "WORLD: Sent (SMSG_GUILD_ROSTER)" ); +} + +void Guild::Query(WorldSession *session) +{ + WorldPacket data(SMSG_GUILD_QUERY_RESPONSE, (8*32+200));// we can only guess size + + data << Id; + data << name; + RankList::iterator itr; + for (size_t i = 0 ; i < 10; ++i) // show always 10 ranks + { + if(i < m_ranks.size()) + data << m_ranks[i].name; + else + data << (uint8)0; // null string + } + + data << uint32(EmblemStyle); + data << uint32(EmblemColor); + data << uint32(BorderStyle); + data << uint32(BorderColor); + data << uint32(BackgroundColor); + + session->SendPacket( &data ); + sLog.outDebug( "WORLD: Sent (SMSG_GUILD_QUERY_RESPONSE)" ); +} + +void Guild::SetEmblem(uint32 emblemStyle, uint32 emblemColor, uint32 borderStyle, uint32 borderColor, uint32 backgroundColor) +{ + this->EmblemStyle = emblemStyle; + this->EmblemColor = emblemColor; + this->BorderStyle = borderStyle; + this->BorderColor = borderColor; + this->BackgroundColor = backgroundColor; + + CharacterDatabase.PExecute("UPDATE guild SET EmblemStyle=%u, EmblemColor=%u, BorderStyle=%u, BorderColor=%u, BackgroundColor=%u WHERE guildid = %u", EmblemStyle, EmblemColor, BorderStyle, BorderColor, BackgroundColor, Id); +} + +void Guild::UpdateLogoutTime(uint64 guid) +{ + MemberList::iterator itr = members.find(GUID_LOPART(guid)); + if (itr == members.end() ) + return; + + itr->second.logout_time = time(NULL); + + if (m_onlinemembers > 0) + --m_onlinemembers; + else + { + UnloadGuildBank(); + UnloadGuildEventlog(); + } +} + +// ************************************************* +// Guild Eventlog part +// ************************************************* +// Display guild eventlog +void Guild::DisplayGuildEventlog(WorldSession *session) +{ + // Load guild eventlog, if not already done + if (!m_eventlogloaded) + LoadGuildEventLogFromDB(); + + // Sending result + WorldPacket data(MSG_GUILD_EVENT_LOG_QUERY, 0); + // count, max count == 100 + data << uint8(m_GuildEventlog.size()); + for (GuildEventlog::const_iterator itr = m_GuildEventlog.begin(); itr != m_GuildEventlog.end(); ++itr) + { + // Event type + data << uint8((*itr)->EventType); + // Player 1 + data << uint64((*itr)->PlayerGuid1); + // Player 2 not for left/join guild events + if( (*itr)->EventType != GUILD_EVENT_LOG_JOIN_GUILD && (*itr)->EventType != GUILD_EVENT_LOG_LEAVE_GUILD ) + data << uint64((*itr)->PlayerGuid2); + // New Rank - only for promote/demote guild events + if( (*itr)->EventType == GUILD_EVENT_LOG_PROMOTE_PLAYER || (*itr)->EventType == GUILD_EVENT_LOG_DEMOTE_PLAYER ) + data << uint8((*itr)->NewRank); + // Event timestamp + data << uint32(time(NULL)-(*itr)->TimeStamp); + } + session->SendPacket(&data); + sLog.outDebug("WORLD: Sent (MSG_GUILD_EVENT_LOG_QUERY)"); +} + +// Load guild eventlog from DB +void Guild::LoadGuildEventLogFromDB() +{ + // Return if already loaded + if (m_eventlogloaded) + return; + + QueryResult *result = CharacterDatabase.PQuery("SELECT LogGuid, EventType, PlayerGuid1, PlayerGuid2, NewRank, TimeStamp FROM guild_eventlog WHERE guildid=%u ORDER BY LogGuid DESC LIMIT %u", Id, GUILD_EVENTLOG_MAX_ENTRIES); + if(!result) + return; + do + { + Field *fields = result->Fetch(); + GuildEventlogEntry *NewEvent = new GuildEventlogEntry; + // Fill entry + NewEvent->LogGuid = fields[0].GetUInt32(); + NewEvent->EventType = fields[1].GetUInt8(); + NewEvent->PlayerGuid1 = fields[2].GetUInt32(); + NewEvent->PlayerGuid2 = fields[3].GetUInt32(); + NewEvent->NewRank = fields[4].GetUInt8(); + NewEvent->TimeStamp = fields[5].GetUInt64(); + // Add entry to map + m_GuildEventlog.push_front(NewEvent); + + } while( result->NextRow() ); + delete result; + + // Check lists size in case to many event entries in db + // This cases can happen only if a crash occured somewhere and table has too many log entries + if (!m_GuildEventlog.empty()) + { + CharacterDatabase.PExecute("DELETE FROM guild_eventlog WHERE guildid=%u AND LogGuid < %u", Id, m_GuildEventlog.front()->LogGuid); + } + m_eventlogloaded = true; +} + +// Unload guild eventlog +void Guild::UnloadGuildEventlog() +{ + if (!m_eventlogloaded) + return; + GuildEventlogEntry *EventLogEntry; + if( !m_GuildEventlog.empty() ) + { + do + { + EventLogEntry = *(m_GuildEventlog.begin()); + m_GuildEventlog.pop_front(); + delete EventLogEntry; + }while( !m_GuildEventlog.empty() ); + } + m_eventlogloaded = false; +} + +// This will renum guids used at load to prevent always going up until infinit +void Guild::RenumGuildEventlog() +{ + QueryResult *result = CharacterDatabase.PQuery("SELECT Min(LogGuid), Max(LogGuid) FROM guild_eventlog WHERE guildid = %u", Id); + if(!result) + return; + + Field *fields = result->Fetch(); + CharacterDatabase.PExecute("UPDATE guild_eventlog SET LogGuid=LogGuid-%u+1 WHERE guildid=%u ORDER BY LogGuid %s",fields[0].GetUInt32(), Id, fields[0].GetUInt32()?"ASC":"DESC"); + GuildEventlogMaxGuid = fields[1].GetUInt32()+1; + delete result; +} + +// Add entry to guild eventlog +void Guild::LogGuildEvent(uint8 EventType, uint32 PlayerGuid1, uint32 PlayerGuid2, uint8 NewRank) +{ + GuildEventlogEntry *NewEvent = new GuildEventlogEntry; + // Fill entry + NewEvent->LogGuid = GuildEventlogMaxGuid++; + NewEvent->EventType = EventType; + NewEvent->PlayerGuid1 = PlayerGuid1; + NewEvent->PlayerGuid2 = PlayerGuid2; + NewEvent->NewRank = NewRank; + NewEvent->TimeStamp = uint32(time(NULL)); + // Check max entry limit and delete from db if needed + if (m_GuildEventlog.size() > GUILD_EVENTLOG_MAX_ENTRIES) + { + GuildEventlogEntry *OldEvent = *(m_GuildEventlog.begin()); + m_GuildEventlog.pop_front(); + CharacterDatabase.PExecute("DELETE FROM guild_eventlog WHERE guildid='%u' AND LogGuid='%u'", Id, OldEvent->LogGuid); + delete OldEvent; + } + // Add entry to map + m_GuildEventlog.push_back(NewEvent); + // Add new eventlog entry into DB + CharacterDatabase.PExecute("INSERT INTO guild_eventlog (guildid, LogGuid, EventType, PlayerGuid1, PlayerGuid2, NewRank, TimeStamp) VALUES ('%u','%u','%u','%u','%u','%u','" I64FMTD "')", + Id, NewEvent->LogGuid, uint32(NewEvent->EventType), NewEvent->PlayerGuid1, NewEvent->PlayerGuid2, uint32(NewEvent->NewRank), NewEvent->TimeStamp); +} + +// ************************************************* +// Guild Bank part +// ************************************************* +// Bank content related +void Guild::DisplayGuildBankContent(WorldSession *session, uint8 TabId) +{ + WorldPacket data(SMSG_GUILD_BANK_LIST,1200); + + GuildBankTab const* tab = GetBankTab(TabId); + if (!tab) + return; + + if(!IsMemberHaveRights(session->GetPlayer()->GetGUIDLow(),TabId,GUILD_BANK_RIGHT_VIEW_TAB)) + return; + + data << uint64(GetGuildBankMoney()); + data << uint8(TabId); + // remaining slots for today + data << uint32(GetMemberSlotWithdrawRem(session->GetPlayer()->GetGUIDLow(), TabId)); + data << uint8(0); // Tell client this is a tab content packet + + data << uint8(GUILD_BANK_MAX_SLOTS); + + for (int i=0; iSendPacket(&data); + + sLog.outDebug("WORLD: Sent (SMSG_GUILD_BANK_LIST)"); +} + +void Guild::DisplayGuildBankMoneyUpdate() +{ + WorldPacket data(SMSG_GUILD_BANK_LIST, 8+1+4+1+1); + + data << uint64(GetGuildBankMoney()); + data << uint8(0); + // remaining slots for today + + size_t rempos = data.wpos(); + data << uint32(0); // will be filled later + data << uint8(0); // Tell client this is a tab content packet + + data << uint8(0); // not send items + + BroadcastPacket(&data); + + sLog.outDebug("WORLD: Sent (SMSG_GUILD_BANK_LIST)"); +} + +void Guild::DisplayGuildBankContentUpdate(uint8 TabId, int32 slot1, int32 slot2) +{ + GuildBankTab const* tab = GetBankTab(TabId); + if (!tab) + return; + + WorldPacket data(SMSG_GUILD_BANK_LIST,1200); + + data << uint64(GetGuildBankMoney()); + data << uint8(TabId); + // remaining slots for today + + size_t rempos = data.wpos(); + data << uint32(0); // will be filled later + data << uint8(0); // Tell client this is a tab content packet + + if(slot2==-1) // single item in slot1 + { + data << uint8(1); + + AppendDisplayGuildBankSlot(data, tab, slot1); + } + else // 2 items (in slot1 and slot2) + { + data << uint8(2); + + if(slot1 > slot2) + std::swap(slot1,slot2); + + AppendDisplayGuildBankSlot(data, tab, slot1); + AppendDisplayGuildBankSlot(data, tab, slot2); + } + + for(MemberList::iterator itr = members.begin(); itr != members.end(); ++itr) + { + Player *player = ObjectAccessor::FindPlayer(MAKE_NEW_GUID(itr->first, 0, HIGHGUID_PLAYER)); + if(!player) + continue; + + if(!IsMemberHaveRights(itr->first,TabId,GUILD_BANK_RIGHT_VIEW_TAB)) + continue; + + data.put(rempos,uint32(GetMemberSlotWithdrawRem(player->GetGUIDLow(), TabId))); + + player->GetSession()->SendPacket(&data); + } + + sLog.outDebug("WORLD: Sent (SMSG_GUILD_BANK_LIST)"); +} + +void Guild::DisplayGuildBankContentUpdate(uint8 TabId, GuildItemPosCountVec const& slots) +{ + GuildBankTab const* tab = GetBankTab(TabId); + if (!tab) + return; + + WorldPacket data(SMSG_GUILD_BANK_LIST,1200); + + data << uint64(GetGuildBankMoney()); + data << uint8(TabId); + // remaining slots for today + + size_t rempos = data.wpos(); + data << uint32(0); // will be filled later + data << uint8(0); // Tell client this is a tab content packet + + data << uint8(slots.size()); // updates count + + for(GuildItemPosCountVec::const_iterator itr = slots.begin(); itr != slots.end(); ++itr) + AppendDisplayGuildBankSlot(data, tab, itr->slot); + + for(MemberList::iterator itr = members.begin(); itr != members.end(); ++itr) + { + Player *player = ObjectAccessor::FindPlayer(MAKE_NEW_GUID(itr->first, 0, HIGHGUID_PLAYER)); + if(!player) + continue; + + if(!IsMemberHaveRights(itr->first,TabId,GUILD_BANK_RIGHT_VIEW_TAB)) + continue; + + data.put(rempos,uint32(GetMemberSlotWithdrawRem(player->GetGUIDLow(), TabId))); + + player->GetSession()->SendPacket(&data); + } + + sLog.outDebug("WORLD: Sent (SMSG_GUILD_BANK_LIST)"); +} + +Item* Guild::GetItem(uint8 TabId, uint8 SlotId) +{ + if (TabId >= m_TabListMap.size() || SlotId >= GUILD_BANK_MAX_SLOTS) + return NULL; + return m_TabListMap[TabId]->Slots[SlotId]; +} + +// ************************************************* +// Tab related + +void Guild::DisplayGuildBankTabsInfo(WorldSession *session) +{ + // Time to load bank if not already done + if (!m_bankloaded) + LoadGuildBankFromDB(); + + WorldPacket data(SMSG_GUILD_BANK_LIST, 500); + + data << uint64(GetGuildBankMoney()); + data << uint8(0); // TabInfo packet must be for TabId 0 + data << uint32(0xFFFFFFFF); // bit 9 must be set for this packet to work + data << uint8(1); // Tell Client this is a TabInfo packet + + data << uint8(purchased_tabs); // here is the number of tabs + + for(int i = 0; i < purchased_tabs; ++i) + { + data << m_TabListMap[i]->Name.c_str(); + data << m_TabListMap[i]->Icon.c_str(); + } + data << uint8(0); // Do not send tab content + session->SendPacket(&data); + + sLog.outDebug("WORLD: Sent (SMSG_GUILD_BANK_LIST)"); +} + +void Guild::CreateNewBankTab() +{ + if (purchased_tabs >= GUILD_BANK_MAX_TABS) + return; + + ++purchased_tabs; + + GuildBankTab* AnotherTab = new GuildBankTab; + memset(AnotherTab->Slots, 0, GUILD_BANK_MAX_SLOTS * sizeof(Item*)); + m_TabListMap.resize(purchased_tabs); + m_TabListMap[purchased_tabs-1] = AnotherTab; + + CharacterDatabase.BeginTransaction(); + CharacterDatabase.PExecute("DELETE FROM guild_bank_tab WHERE guildid='%u' AND TabId='%u'", Id, uint32(purchased_tabs-1)); + CharacterDatabase.PExecute("INSERT INTO guild_bank_tab (guildid,TabId) VALUES ('%u','%u')", Id, uint32(purchased_tabs-1)); + CharacterDatabase.CommitTransaction(); +} + +void Guild::SetGuildBankTabInfo(uint8 TabId, std::string Name, std::string Icon) +{ + if (TabId >= GUILD_BANK_MAX_TABS) + return; + if (TabId >= m_TabListMap.size()) + return; + + if (!m_TabListMap[TabId]) + return; + + if(m_TabListMap[TabId]->Name == Name && m_TabListMap[TabId]->Icon == Icon) + return; + + m_TabListMap[TabId]->Name = Name; + m_TabListMap[TabId]->Icon = Icon; + + CharacterDatabase.escape_string(Name); + CharacterDatabase.escape_string(Icon); + CharacterDatabase.PExecute("UPDATE guild_bank_tab SET TabName='%s',TabIcon='%s' WHERE guildid='%u' AND TabId='%u'", Name.c_str(), Icon.c_str(), Id, uint32(TabId)); +} + +void Guild::CreateBankRightForTab(uint32 rankId, uint8 TabId) +{ + sLog.outDebug("CreateBankRightForTab. rank: %u, TabId: %u", rankId, uint32(TabId)); + if (rankId >= m_ranks.size() || TabId >= GUILD_BANK_MAX_TABS) + return; + + m_ranks[rankId].TabRight[TabId]=0; + m_ranks[rankId].TabSlotPerDay[TabId]=0; + CharacterDatabase.BeginTransaction(); + CharacterDatabase.PExecute("DELETE FROM guild_bank_right WHERE guildid = '%u' AND TabId = '%u' AND rid = '%u'", Id, uint32(TabId), rankId); + CharacterDatabase.PExecute("INSERT INTO guild_bank_right (guildid,TabId,rid) VALUES ('%u','%u','%u')", Id, uint32(TabId), rankId); + CharacterDatabase.CommitTransaction(); +} + +uint32 Guild::GetBankRights(uint32 rankId, uint8 TabId) const +{ + if(rankId >= m_ranks.size() || TabId >= GUILD_BANK_MAX_TABS) + return 0; + + return m_ranks[rankId].TabRight[TabId]; +} + +// ************************************************* +// Guild bank loading/unloading related + +// This load should be called when the bank is first accessed by a guild member +void Guild::LoadGuildBankFromDB() +{ + if (m_bankloaded) + return; + + m_bankloaded = true; + LoadGuildBankEventLogFromDB(); + + // 0 1 2 3 + QueryResult *result = CharacterDatabase.PQuery("SELECT TabId, TabName, TabIcon, TabText FROM guild_bank_tab WHERE guildid='%u' ORDER BY TabId", Id); + if(!result) + { + purchased_tabs = 0; + return; + } + + m_TabListMap.resize(purchased_tabs); + do + { + Field *fields = result->Fetch(); + uint8 TabId = fields[0].GetUInt8(); + + GuildBankTab *NewTab = new GuildBankTab; + memset(NewTab->Slots, 0, GUILD_BANK_MAX_SLOTS * sizeof(Item*)); + + NewTab->Name = fields[1].GetCppString(); + NewTab->Icon = fields[2].GetCppString(); + NewTab->Text = fields[3].GetCppString(); + + m_TabListMap[TabId] = NewTab; + }while( result->NextRow() ); + + delete result; + + // 0 1 2 3 + result = CharacterDatabase.PQuery("SELECT TabId, SlotId, item_guid, item_entry FROM guild_bank_item WHERE guildid='%u' ORDER BY TabId", Id); + if(!result) + return; + + do + { + Field *fields = result->Fetch(); + uint8 TabId = fields[0].GetUInt8(); + uint8 SlotId = fields[1].GetUInt8(); + uint32 ItemGuid = fields[2].GetUInt32(); + uint32 ItemEntry = fields[3].GetUInt32(); + + if (TabId >= purchased_tabs || TabId >= GUILD_BANK_MAX_TABS) + { + sLog.outError( "Guild::LoadGuildBankFromDB: Invalid tab for item (GUID: %u id: #%u) in guild bank, skipped.", ItemGuid,ItemEntry); + continue; + } + + if (SlotId >= GUILD_BANK_MAX_SLOTS) + { + sLog.outError( "Guild::LoadGuildBankFromDB: Invalid slot for item (GUID: %u id: #%u) in guild bank, skipped.", ItemGuid,ItemEntry); + continue; + } + + ItemPrototype const *proto = objmgr.GetItemPrototype(ItemEntry); + + if(!proto) + { + sLog.outError( "Guild::LoadGuildBankFromDB: Unknown item (GUID: %u id: #%u) in guild bank, skipped.", ItemGuid,ItemEntry); + continue; + } + + Item *pItem = NewItemOrBag(proto); + if(!pItem->LoadFromDB(ItemGuid, 0)) + { + CharacterDatabase.PExecute("DELETE FROM guild_bank_item WHERE guildid='%u' AND TabId='%u' AND SlotId='%u'", Id, uint32(TabId), uint32(SlotId)); + sLog.outError("Item GUID %u not found in item_instance, deleting from Guild Bank!", ItemGuid); + delete pItem; + continue; + } + + pItem->AddToWorld(); + m_TabListMap[TabId]->Slots[SlotId] = pItem; + }while( result->NextRow() ); + + delete result; +} + +// This unload should be called when the last member of the guild gets offline +void Guild::UnloadGuildBank() +{ + if (!m_bankloaded) + return; + for (uint8 i = 0 ; i < purchased_tabs ; ++i ) + { + for (uint8 j = 0 ; j < GUILD_BANK_MAX_SLOTS ; ++j) + { + if (m_TabListMap[i]->Slots[j]) + { + m_TabListMap[i]->Slots[j]->RemoveFromWorld(); + delete m_TabListMap[i]->Slots[j]; + } + } + delete m_TabListMap[i]; + } + m_TabListMap.clear(); + + UnloadGuildBankEventLog(); + m_bankloaded = false; +} + +// ************************************************* +// Money deposit/withdraw related + +void Guild::SendMoneyInfo(WorldSession *session, uint32 LowGuid) +{ + WorldPacket data(MSG_GUILD_BANK_MONEY_WITHDRAWN, 4); + data << uint32(GetMemberMoneyWithdrawRem(LowGuid)); + session->SendPacket(&data); + sLog.outDebug("WORLD: Sent MSG_GUILD_BANK_MONEY_WITHDRAWN"); +} + +bool Guild::MemberMoneyWithdraw(uint32 amount, uint32 LowGuid) +{ + uint32 MoneyWithDrawRight = GetMemberMoneyWithdrawRem(LowGuid); + + if (MoneyWithDrawRight < amount || GetGuildBankMoney() < amount) + return false; + + SetBankMoney(GetGuildBankMoney()-amount); + + if (MoneyWithDrawRight < WITHDRAW_MONEY_UNLIMITED) + { + MemberList::iterator itr = members.find(LowGuid); + if (itr == members.end() ) + return false; + itr->second.BankRemMoney -= amount; + CharacterDatabase.PExecute("UPDATE guild_member SET BankRemMoney='%u' WHERE guildid='%u' AND guid='%u'", + itr->second.BankRemMoney, Id, LowGuid); + } + return true; +} + +void Guild::SetBankMoney(int64 money) +{ + if (money < 0) // I don't know how this happens, it does!! + money = 0; + guildbank_money = money; + + CharacterDatabase.PExecute("UPDATE guild SET BankMoney='" I64FMTD "' WHERE guildid='%u'", money, Id); +} + +// ************************************************* +// Item per day and money per day related + +bool Guild::MemberItemWithdraw(uint8 TabId, uint32 LowGuid) +{ + uint32 SlotsWithDrawRight = GetMemberSlotWithdrawRem(LowGuid, TabId); + + if (SlotsWithDrawRight == 0) + return false; + + if (SlotsWithDrawRight < WITHDRAW_SLOT_UNLIMITED) + { + MemberList::iterator itr = members.find(LowGuid); + if (itr == members.end() ) + return false; + --itr->second.BankRemSlotsTab[TabId]; + CharacterDatabase.PExecute("UPDATE guild_member SET BankRemSlotsTab%u='%u' WHERE guildid='%u' AND guid='%u'", + uint32(TabId), itr->second.BankRemSlotsTab[TabId], Id, LowGuid); + } + return true; +} + +bool Guild::IsMemberHaveRights(uint32 LowGuid, uint8 TabId, uint32 rights) const +{ + MemberList::const_iterator itr = members.find(LowGuid); + if (itr == members.end() ) + return false; + + if (itr->second.RankId == GR_GUILDMASTER) + return true; + + return (GetBankRights(itr->second.RankId,TabId) & rights)==rights; +} + +uint32 Guild::GetMemberSlotWithdrawRem(uint32 LowGuid, uint8 TabId) +{ + MemberList::iterator itr = members.find(LowGuid); + if (itr == members.end() ) + return 0; + + if (itr->second.RankId == GR_GUILDMASTER) + return WITHDRAW_SLOT_UNLIMITED; + + if((GetBankRights(itr->second.RankId,TabId) & GUILD_BANK_RIGHT_VIEW_TAB)!=GUILD_BANK_RIGHT_VIEW_TAB) + return 0; + + uint32 curTime = uint32(time(NULL)/MINUTE); + if (curTime - itr->second.BankResetTimeTab[TabId] >= 24*HOUR/MINUTE) + { + itr->second.BankResetTimeTab[TabId] = curTime; + itr->second.BankRemSlotsTab[TabId] = GetBankSlotPerDay(itr->second.RankId, TabId); + CharacterDatabase.PExecute("UPDATE guild_member SET BankResetTimeTab%u='%u',BankRemSlotsTab%u='%u' WHERE guildid='%u' AND guid='%u'", + uint32(TabId), itr->second.BankResetTimeTab[TabId], uint32(TabId), itr->second.BankRemSlotsTab[TabId], Id, LowGuid); + } + return itr->second.BankRemSlotsTab[TabId]; +} + +uint32 Guild::GetMemberMoneyWithdrawRem(uint32 LowGuid) +{ + MemberList::iterator itr = members.find(LowGuid); + if (itr == members.end() ) + return 0; + + if (itr->second.RankId == GR_GUILDMASTER) + return WITHDRAW_MONEY_UNLIMITED; + + uint32 curTime = uint32(time(NULL)/MINUTE); // minutes + // 24 hours + if (curTime > itr->second.BankResetTimeMoney + 24*HOUR/MINUTE) + { + itr->second.BankResetTimeMoney = curTime; + itr->second.BankRemMoney = GetBankMoneyPerDay(itr->second.RankId); + CharacterDatabase.PExecute("UPDATE guild_member SET BankResetTimeMoney='%u',BankRemMoney='%u' WHERE guildid='%u' AND guid='%u'", + itr->second.BankResetTimeMoney, itr->second.BankRemMoney, Id, LowGuid); + } + return itr->second.BankRemMoney; +} + +void Guild::SetBankMoneyPerDay(uint32 rankId, uint32 money) +{ + if (rankId >= m_ranks.size()) + return; + + if (rankId == GR_GUILDMASTER) + money = WITHDRAW_MONEY_UNLIMITED; + + m_ranks[rankId].BankMoneyPerDay = money; + + for (MemberList::iterator itr = members.begin(); itr != members.end(); ++itr) + if (itr->second.RankId == rankId) + itr->second.BankResetTimeMoney = 0; + + CharacterDatabase.PExecute("UPDATE guild_rank SET BankMoneyPerDay='%u' WHERE rid='%u' AND guildid='%u'", money, (rankId+1), Id); + CharacterDatabase.PExecute("UPDATE guild_member SET BankResetTimeMoney='0' WHERE guildid='%u' AND rank='%u'", Id, rankId); +} + +void Guild::SetBankRightsAndSlots(uint32 rankId, uint8 TabId, uint32 right, uint32 nbSlots, bool db) +{ + if(rankId >= m_ranks.size() || + TabId >= GUILD_BANK_MAX_TABS || + TabId >= purchased_tabs) + return; + + if (rankId == GR_GUILDMASTER) + { + nbSlots = WITHDRAW_SLOT_UNLIMITED; + right = GUILD_BANK_RIGHT_FULL; + } + + m_ranks[rankId].TabSlotPerDay[TabId]=nbSlots; + m_ranks[rankId].TabRight[TabId]=right; + + if (db) + { + for (MemberList::iterator itr = members.begin(); itr != members.end(); ++itr) + if (itr->second.RankId == rankId) + for (int i = 0; i < GUILD_BANK_MAX_TABS; ++i) + itr->second.BankResetTimeTab[i] = 0; + + CharacterDatabase.PExecute("DELETE FROM guild_bank_right WHERE guildid='%u' AND TabId='%u' AND rid='%u'", Id, uint32(TabId), rankId); + CharacterDatabase.PExecute("INSERT INTO guild_bank_right (guildid,TabId,rid,gbright,SlotPerDay) VALUES " + "('%u','%u','%u','%u','%u')", Id, uint32(TabId), rankId, m_ranks[rankId].TabRight[TabId], m_ranks[rankId].TabSlotPerDay[TabId]); + CharacterDatabase.PExecute("UPDATE guild_member SET BankResetTimeTab%u='0' WHERE guildid='%u' AND rank='%u'", uint32(TabId), Id, rankId); + } +} + +uint32 Guild::GetBankMoneyPerDay(uint32 rankId) +{ + if(rankId >= m_ranks.size()) + return 0; + + if (rankId == GR_GUILDMASTER) + return WITHDRAW_MONEY_UNLIMITED; + return m_ranks[rankId].BankMoneyPerDay; +} + +uint32 Guild::GetBankSlotPerDay(uint32 rankId, uint8 TabId) +{ + if(rankId >= m_ranks.size() || TabId >= GUILD_BANK_MAX_TABS) + return 0; + + if (rankId == GR_GUILDMASTER) + return WITHDRAW_SLOT_UNLIMITED; + return m_ranks[rankId].TabSlotPerDay[TabId]; +} + +// ************************************************* +// Rights per day related + +void Guild::LoadBankRightsFromDB(uint32 GuildId) +{ + // 0 1 2 3 + QueryResult *result = CharacterDatabase.PQuery("SELECT TabId, rid, gbright, SlotPerDay FROM guild_bank_right WHERE guildid = '%u' ORDER BY TabId", GuildId); + + if(!result) + return; + + do + { + Field *fields = result->Fetch(); + uint8 TabId = fields[0].GetUInt8(); + uint32 rankId = fields[1].GetUInt32(); + uint16 right = fields[2].GetUInt16(); + uint16 SlotPerDay = fields[3].GetUInt16(); + + SetBankRightsAndSlots(rankId, TabId, right, SlotPerDay, false); + + }while( result->NextRow() ); + delete result; + + return; +} + +// ************************************************* +// Bank log related + +void Guild::LoadGuildBankEventLogFromDB() +{ + // We can't add a limit as in Guild::LoadGuildEventLogFromDB since we fetch both money and bank log and know nothing about the composition + // 0 1 2 3 4 5 6 7 + QueryResult *result = CharacterDatabase.PQuery("SELECT LogGuid, LogEntry, TabId, PlayerGuid, ItemOrMoney, ItemStackCount, DestTabId, TimeStamp FROM guild_bank_eventlog WHERE guildid='%u' ORDER BY TimeStamp DESC", Id); + if(!result) + return; + + do + { + Field *fields = result->Fetch(); + GuildBankEvent *NewEvent = new GuildBankEvent; + + NewEvent->LogGuid = fields[0].GetUInt32(); + NewEvent->LogEntry = fields[1].GetUInt8(); + uint8 TabId = fields[2].GetUInt8(); + NewEvent->PlayerGuid = fields[3].GetUInt32(); + NewEvent->ItemOrMoney = fields[4].GetUInt32(); + NewEvent->ItemStackCount = fields[5].GetUInt8(); + NewEvent->DestTabId = fields[6].GetUInt8(); + NewEvent->TimeStamp = fields[7].GetUInt64(); + + if (TabId >= GUILD_BANK_MAX_TABS) + { + sLog.outError( "Guild::LoadGuildBankEventLogFromDB: Invalid tabid '%u' for guild bank log entry (guild: '%s', LogGuid: %u), skipped.", TabId, GetName().c_str(), NewEvent->LogGuid); + delete NewEvent; + continue; + } + if (NewEvent->isMoneyEvent() && m_GuildBankEventLog_Money.size() >= GUILD_BANK_MAX_LOGS + || m_GuildBankEventLog_Item[TabId].size() >= GUILD_BANK_MAX_LOGS) + { + delete NewEvent; + continue; + } + if (NewEvent->isMoneyEvent()) + m_GuildBankEventLog_Money.push_front(NewEvent); + else + m_GuildBankEventLog_Item[TabId].push_front(NewEvent); + + }while( result->NextRow() ); + delete result; + + // Check lists size in case to many event entries in db for a tab or for money + // This cases can happen only if a crash occured somewhere and table has too many log entries + if (!m_GuildBankEventLog_Money.empty()) + { + CharacterDatabase.PExecute("DELETE FROM guild_bank_eventlog WHERE guildid=%u AND LogGuid < %u", + Id, m_GuildBankEventLog_Money.front()->LogGuid); + } + for (int i = 0; i < GUILD_BANK_MAX_TABS; ++i) + { + if (!m_GuildBankEventLog_Item[i].empty()) + { + CharacterDatabase.PExecute("DELETE FROM guild_bank_eventlog WHERE guildid=%u AND LogGuid < %u", + Id, m_GuildBankEventLog_Item[i].front()->LogGuid); + } + } +} + +void Guild::UnloadGuildBankEventLog() +{ + GuildBankEvent *EventLogEntry; + if( !m_GuildBankEventLog_Money.empty() ) + { + do + { + EventLogEntry = *(m_GuildBankEventLog_Money.begin()); + m_GuildBankEventLog_Money.pop_front(); + delete EventLogEntry; + }while( !m_GuildBankEventLog_Money.empty() ); + } + + for (int i = 0; i < GUILD_BANK_MAX_TABS; ++i) + { + if( !m_GuildBankEventLog_Item[i].empty() ) + { + do + { + EventLogEntry = *(m_GuildBankEventLog_Item[i].begin()); + m_GuildBankEventLog_Item[i].pop_front(); + delete EventLogEntry; + }while( !m_GuildBankEventLog_Item[i].empty() ); + } + } +} + +void Guild::DisplayGuildBankLogs(WorldSession *session, uint8 TabId) +{ + if (TabId > GUILD_BANK_MAX_TABS) + return; + + if (TabId == GUILD_BANK_MAX_TABS) + { + // Here we display money logs + WorldPacket data(MSG_GUILD_BANK_LOG_QUERY, m_GuildBankEventLog_Money.size()*(4*4+1)+1+1); + data << uint8(TabId); // Here GUILD_BANK_MAX_TABS + data << uint8(m_GuildBankEventLog_Money.size()); // number of log entries + for (GuildBankEventLog::const_iterator itr = m_GuildBankEventLog_Money.begin(); itr != m_GuildBankEventLog_Money.end(); ++itr) + { + data << uint8((*itr)->LogEntry); + data << uint64(MAKE_NEW_GUID((*itr)->PlayerGuid,0,HIGHGUID_PLAYER)); + data << uint32((*itr)->ItemOrMoney); + data << uint32(time(NULL)-(*itr)->TimeStamp); + } + session->SendPacket(&data); + } + else + { + // here we display current tab logs + WorldPacket data(MSG_GUILD_BANK_LOG_QUERY, m_GuildBankEventLog_Item[TabId].size()*(4*4+1+1)+1+1); + data << uint8(TabId); // Here a real Tab Id + // number of log entries + data << uint8(m_GuildBankEventLog_Item[TabId].size()); + for (GuildBankEventLog::const_iterator itr = m_GuildBankEventLog_Item[TabId].begin(); itr != m_GuildBankEventLog_Item[TabId].end(); ++itr) + { + data << uint8((*itr)->LogEntry); + data << uint64(MAKE_NEW_GUID((*itr)->PlayerGuid,0,HIGHGUID_PLAYER)); + data << uint32((*itr)->ItemOrMoney); + data << uint8((*itr)->ItemStackCount); + if ((*itr)->LogEntry == GUILD_BANK_LOG_MOVE_ITEM || (*itr)->LogEntry == GUILD_BANK_LOG_MOVE_ITEM2) + data << uint8((*itr)->DestTabId); // moved tab + data << uint32(time(NULL)-(*itr)->TimeStamp); + } + session->SendPacket(&data); + } + sLog.outDebug("WORLD: Sent (MSG_GUILD_BANK_LOG_QUERY)"); +} + +void Guild::LogBankEvent(uint8 LogEntry, uint8 TabId, uint32 PlayerGuidLow, uint32 ItemOrMoney, uint8 ItemStackCount, uint8 DestTabId) +{ + GuildBankEvent *NewEvent = new GuildBankEvent; + + NewEvent->LogGuid = LogMaxGuid++; + NewEvent->LogEntry = LogEntry; + NewEvent->PlayerGuid = PlayerGuidLow; + NewEvent->ItemOrMoney = ItemOrMoney; + NewEvent->ItemStackCount = ItemStackCount; + NewEvent->DestTabId = DestTabId; + NewEvent->TimeStamp = uint32(time(NULL)); + + if (NewEvent->isMoneyEvent()) + { + if (m_GuildBankEventLog_Money.size() > GUILD_BANK_MAX_LOGS) + { + GuildBankEvent *OldEvent = *(m_GuildBankEventLog_Money.begin()); + m_GuildBankEventLog_Money.pop_front(); + CharacterDatabase.PExecute("DELETE FROM guild_bank_eventlog WHERE guildid='%u' AND LogGuid='%u'", Id, OldEvent->LogGuid); + delete OldEvent; + } + m_GuildBankEventLog_Money.push_back(NewEvent); + } + else + { + if (m_GuildBankEventLog_Item[TabId].size() > GUILD_BANK_MAX_LOGS) + { + GuildBankEvent *OldEvent = *(m_GuildBankEventLog_Item[TabId].begin()); + m_GuildBankEventLog_Item[TabId].pop_front(); + CharacterDatabase.PExecute("DELETE FROM guild_bank_eventlog WHERE guildid='%u' AND LogGuid='%u'", Id, OldEvent->LogGuid); + delete OldEvent; + } + m_GuildBankEventLog_Item[TabId].push_back(NewEvent); + } + CharacterDatabase.PExecute("INSERT INTO guild_bank_eventlog (guildid,LogGuid,LogEntry,TabId,PlayerGuid,ItemOrMoney,ItemStackCount,DestTabId,TimeStamp) VALUES ('%u','%u','%u','%u','%u','%u','%u','%u','" I64FMTD "')", + Id, NewEvent->LogGuid, uint32(NewEvent->LogEntry), uint32(TabId), NewEvent->PlayerGuid, NewEvent->ItemOrMoney, uint32(NewEvent->ItemStackCount), uint32(NewEvent->DestTabId), NewEvent->TimeStamp); +} + +// This will renum guids used at load to prevent always going up until infinit +void Guild::RenumBankLogs() +{ + QueryResult *result = CharacterDatabase.PQuery("SELECT Min(LogGuid), Max(LogGuid) FROM guild_bank_eventlog WHERE guildid = %u", Id); + if(!result) + return; + + Field *fields = result->Fetch(); + CharacterDatabase.PExecute("UPDATE guild_bank_eventlog SET LogGuid=LogGuid-%u+1 WHERE guildid=%u ORDER BY LogGuid %s",fields[0].GetUInt32(), Id, fields[0].GetUInt32()?"ASC":"DESC"); + LogMaxGuid = fields[1].GetUInt32()+1; + delete result; +} + +bool Guild::AddGBankItemToDB(uint32 GuildId, uint32 BankTab , uint32 BankTabSlot , uint32 GUIDLow, uint32 Entry ) +{ + CharacterDatabase.PExecute("DELETE FROM guild_bank_item WHERE guildid = '%u' AND TabId = '%u'AND SlotId = '%u'", GuildId, BankTab, BankTabSlot); + CharacterDatabase.PExecute("INSERT INTO guild_bank_item (guildid,TabId,SlotId,item_guid,item_entry) " + "VALUES ('%u', '%u', '%u', '%u', '%u')", GuildId, BankTab, BankTabSlot, GUIDLow, Entry); + return true; +} + +void Guild::AppendDisplayGuildBankSlot( WorldPacket& data, GuildBankTab const *tab, int slot ) +{ + Item *pItem = tab->Slots[slot]; + uint32 entry = pItem ? pItem->GetEntry() : 0; + + data << uint8(slot); + data << uint32(entry); + if (entry) + { + // random item property id +8 + data << (uint32) pItem->GetItemRandomPropertyId(); + if (pItem->GetItemRandomPropertyId()) + // SuffixFactor +4 + data << (uint32) pItem->GetItemSuffixFactor(); + // +12 // ITEM_FIELD_STACK_COUNT + data << uint8(pItem->GetCount()); + data << uint32(0); // +16 // Unknown value + data << uint8(0); // unknown 2.4.2 + if (uint32 Enchant0 = pItem->GetEnchantmentId(PERM_ENCHANTMENT_SLOT)) + { + data << uint8(1); // number of enchantments (max 3) why max 3? + data << uint8(PERM_ENCHANTMENT_SLOT); // enchantment slot (range: 0:2) + data << uint32(Enchant0); // enchantment id + } + else + data << uint8(0); // no enchantments (0) + } +} + +Item* Guild::StoreItem(uint8 tabId, GuildItemPosCountVec const& dest, Item* pItem ) +{ + if( !pItem ) + return NULL; + + Item* lastItem = pItem; + + for(GuildItemPosCountVec::const_iterator itr = dest.begin(); itr != dest.end(); ) + { + uint8 slot = itr->slot; + uint32 count = itr->count; + + ++itr; + + if(itr == dest.end()) + { + lastItem = _StoreItem(tabId,slot,pItem,count,false); + break; + } + + lastItem = _StoreItem(tabId,slot,pItem,count,true); + } + + return lastItem; +} + +// Return stored item (if stored to stack, it can diff. from pItem). And pItem ca be deleted in this case. +Item* Guild::_StoreItem( uint8 tab, uint8 slot, Item *pItem, uint32 count, bool clone ) +{ + if( !pItem ) + return NULL; + + sLog.outDebug( "GUILD STORAGE: StoreItem tab = %u, slot = %u, item = %u, count = %u", tab, slot, pItem->GetEntry(), count); + + Item* pItem2 = m_TabListMap[tab]->Slots[slot]; + + if( !pItem2 ) + { + if(clone) + pItem = pItem->CloneItem(count); + else + pItem->SetCount(count); + + if(!pItem) + return NULL; + + m_TabListMap[tab]->Slots[slot] = pItem; + + pItem->SetUInt64Value(ITEM_FIELD_CONTAINED, 0); + pItem->SetUInt64Value(ITEM_FIELD_OWNER, 0); + AddGBankItemToDB(GetId(), tab, slot, pItem->GetGUIDLow(), pItem->GetEntry()); + pItem->FSetState(ITEM_NEW); + pItem->SaveToDB(); // not in onventory and can be save standalone + + return pItem; + } + else + { + pItem2->SetCount( pItem2->GetCount() + count ); + pItem2->FSetState(ITEM_CHANGED); + pItem2->SaveToDB(); // not in onventory and can be save standalone + + if(!clone) + { + pItem->RemoveFromWorld(); + pItem->DeleteFromDB(); + delete pItem; + } + + return pItem2; + } +} + +void Guild::RemoveItem(uint8 tab, uint8 slot ) +{ + m_TabListMap[tab]->Slots[slot] = NULL; + CharacterDatabase.PExecute("DELETE FROM guild_bank_item WHERE guildid='%u' AND TabId='%u' AND SlotId='%u'", + GetId(), uint32(tab), uint32(slot)); +} + +uint8 Guild::_CanStoreItem_InSpecificSlot( uint8 tab, uint8 slot, GuildItemPosCountVec &dest, uint32& count, bool swap, Item* pSrcItem ) const +{ + Item* pItem2 = m_TabListMap[tab]->Slots[slot]; + + // ignore move item (this slot will be empty at move) + if(pItem2==pSrcItem) + pItem2 = NULL; + + uint32 need_space; + + // empty specific slot - check item fit to slot + if( !pItem2 || swap ) + { + // non empty stack with space + need_space = pSrcItem->GetMaxStackCount(); + } + // non empty slot, check item type + else + { + // check item type + if(pItem2->GetEntry() != pSrcItem->GetEntry()) + return EQUIP_ERR_ITEM_CANT_STACK; + + // check free space + if(pItem2->GetCount() >= pSrcItem->GetMaxStackCount()) + return EQUIP_ERR_ITEM_CANT_STACK; + + need_space = pSrcItem->GetMaxStackCount() - pItem2->GetCount(); + } + + if(need_space > count) + need_space = count; + + GuildItemPosCount newPosition = GuildItemPosCount(slot,need_space); + if(!newPosition.isContainedIn(dest)) + { + dest.push_back(newPosition); + count -= need_space; + } + + return EQUIP_ERR_OK; +} + +uint8 Guild::_CanStoreItem_InTab( uint8 tab, GuildItemPosCountVec &dest, uint32& count, bool merge, Item* pSrcItem, uint8 skip_slot ) const +{ + for(uint32 j = 0; j < GUILD_BANK_MAX_SLOTS; j++) + { + // skip specific slot already processed in first called _CanStoreItem_InSpecificSlot + if(j==skip_slot) + continue; + + Item* pItem2 = m_TabListMap[tab]->Slots[j]; + + // ignore move item (this slot will be empty at move) + if(pItem2==pSrcItem) + pItem2 = NULL; + + // if merge skip empty, if !merge skip non-empty + if((pItem2!=NULL)!=merge) + continue; + + if( pItem2 ) + { + if(pItem2->GetEntry() == pSrcItem->GetEntry() && pItem2->GetCount() < pSrcItem->GetMaxStackCount() ) + { + uint32 need_space = pSrcItem->GetMaxStackCount() - pItem2->GetCount(); + if(need_space > count) + need_space = count; + + GuildItemPosCount newPosition = GuildItemPosCount(j,need_space); + if(!newPosition.isContainedIn(dest)) + { + dest.push_back(newPosition); + count -= need_space; + + if(count==0) + return EQUIP_ERR_OK; + } + } + } + else + { + uint32 need_space = pSrcItem->GetMaxStackCount(); + if(need_space > count) + need_space = count; + + GuildItemPosCount newPosition = GuildItemPosCount(j,need_space); + if(!newPosition.isContainedIn(dest)) + { + dest.push_back(newPosition); + count -= need_space; + + if(count==0) + return EQUIP_ERR_OK; + } + } + } + return EQUIP_ERR_OK; +} + +uint8 Guild::CanStoreItem( uint8 tab, uint8 slot, GuildItemPosCountVec &dest, uint32 count, Item *pItem, bool swap ) const +{ + sLog.outDebug( "GUILD STORAGE: CanStoreItem tab = %u, slot = %u, item = %u, count = %u", tab, slot, pItem->GetEntry(), count); + + if(count > pItem->GetCount()) + return EQUIP_ERR_COULDNT_SPLIT_ITEMS; + + if(pItem->IsSoulBound()) + return EQUIP_ERR_CANT_DROP_SOULBOUND; + + // in specific slot + if( slot != NULL_SLOT ) + { + uint8 res = _CanStoreItem_InSpecificSlot(tab,slot,dest,count,swap,pItem); + if(res!=EQUIP_ERR_OK) + return res; + + if(count==0) + return EQUIP_ERR_OK; + } + + // not specific slot or have spece for partly store only in specific slot + + // search stack in tab for merge to + if( pItem->GetMaxStackCount() > 1 ) + { + uint8 res = _CanStoreItem_InTab(tab,dest,count,true,pItem,slot); + if(res!=EQUIP_ERR_OK) + return res; + + if(count==0) + return EQUIP_ERR_OK; + } + + // search free slot in bag for place to + uint8 res = _CanStoreItem_InTab(tab,dest,count,false,pItem,slot); + if(res!=EQUIP_ERR_OK) + return res; + + if(count==0) + return EQUIP_ERR_OK; + + return EQUIP_ERR_BANK_FULL; +} + +void Guild::SetGuildBankTabText(uint8 TabId, std::string text) +{ + if (TabId >= GUILD_BANK_MAX_TABS) + return; + if (TabId >= m_TabListMap.size()) + return; + if (!m_TabListMap[TabId]) + return; + + if(m_TabListMap[TabId]->Text==text) + return; + + utf8truncate(text,500); // DB and client size limitation + + m_TabListMap[TabId]->Text = text; + + CharacterDatabase.escape_string(text); + CharacterDatabase.PExecute("UPDATE guild_bank_tab SET TabText='%s' WHERE guildid='%u' AND TabId='%u'", text.c_str(), Id, uint32(TabId)); +} + +void Guild::SendGuildBankTabText(WorldSession *session, uint8 TabId) +{ + if (TabId > GUILD_BANK_MAX_TABS) + return; + + GuildBankTab const *tab = GetBankTab(TabId); + if (!tab) + return; + + WorldPacket data(MSG_QUERY_GUILD_BANK_TEXT, 1+tab->Text.size()+1); + data << uint8(TabId); + data << tab->Text; + session->SendPacket(&data); +} + +bool GuildItemPosCount::isContainedIn(GuildItemPosCountVec const &vec) const +{ + for(GuildItemPosCountVec::const_iterator itr = vec.begin(); itr != vec.end();++itr) + if(itr->slot == this->slot) + return true; + + return false; +} + diff --git a/src/game/Guild.h b/src/game/Guild.h index 3f16d80987d..6ec58efb196 100644 --- a/src/game/Guild.h +++ b/src/game/Guild.h @@ -1,435 +1,437 @@ -/* - * Copyright (C) 2005-2008 MaNGOS - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef MANGOSSERVER_GUILD_H -#define MANGOSSERVER_GUILD_H - -#define WITHDRAW_MONEY_UNLIMITED 0xFFFFFFFF -#define WITHDRAW_SLOT_UNLIMITED 0xFFFFFFFF - -#include "Item.h" - -class Item; - -enum GuildDefaultRanks -{ - GR_GUILDMASTER = 0, - GR_OFFICER = 1, - //GR_VETERAN = 2, -- not used anywhere and possible incorrect in modified rank list - //GR_MEMBER = 3, - //GR_INITIATE = 4, -- use Guild::GetLowestRank() instead for lowest rank -}; - -enum GuildRankRights -{ - GR_RIGHT_EMPTY = 0x00000040, - GR_RIGHT_GCHATLISTEN = 0x00000041, - GR_RIGHT_GCHATSPEAK = 0x00000042, - GR_RIGHT_OFFCHATLISTEN = 0x00000044, - GR_RIGHT_OFFCHATSPEAK = 0x00000048, - GR_RIGHT_PROMOTE = 0x000000C0, - GR_RIGHT_DEMOTE = 0x00000140, - GR_RIGHT_INVITE = 0x00000050, - GR_RIGHT_REMOVE = 0x00000060, - GR_RIGHT_SETMOTD = 0x00001040, - GR_RIGHT_EPNOTE = 0x00002040, - GR_RIGHT_VIEWOFFNOTE = 0x00004040, - GR_RIGHT_EOFFNOTE = 0x00008040, - GR_RIGHT_MODIFY_GUILD_INFO = 0x00010040, - GR_RIGHT_REPAIR_FROM_GUILD = 0x00020000, // unused in 2.4.x?, Remove money withdraw capacity - GR_RIGHT_WITHDRAW_REPAIR = 0x00040000, // withdraw for repair - GR_RIGHT_WITHDRAW_GOLD = 0x00080000, // withdraw gold - GR_RIGHT_ALL = 0x000FF1FF -}; - -enum Typecommand -{ - GUILD_CREATE_S = 0x00, - GUILD_INVITE_S = 0x01, - GUILD_QUIT_S = 0x03, - GUILD_FOUNDER_S = 0x0E, - GUILD_UNK1 = 0x10, - GUILD_BANK_S = 0x15, - GUILD_UNK3 = 0x16 -}; - -enum CommandErrors -{ - GUILD_PLAYER_NO_MORE_IN_GUILD = 0x00, - GUILD_INTERNAL = 0x01, - GUILD_ALREADY_IN_GUILD = 0x02, - ALREADY_IN_GUILD = 0x03, - INVITED_TO_GUILD = 0x04, - ALREADY_INVITED_TO_GUILD = 0x05, - GUILD_NAME_INVALID = 0x06, - GUILD_NAME_EXISTS = 0x07, - GUILD_LEADER_LEAVE = 0x08, - GUILD_PERMISSIONS = 0x08, - GUILD_PLAYER_NOT_IN_GUILD = 0x09, - GUILD_PLAYER_NOT_IN_GUILD_S = 0x0A, - GUILD_PLAYER_NOT_FOUND = 0x0B, - GUILD_NOT_ALLIED = 0x0C, - GUILD_RANK_TOO_HIGH_S = 0x0D, - GUILD_ALREADY_LOWEST_RANK_S = 0x0E, - GUILD_TEMP_ERROR = 0x11, - GUILD_RANK_IN_USE = 0x12, - GUILD_IGNORE = 0x13, - GUILD_ERR_UNK1 = 0x17, - GUILD_WITHDRAW_TOO_MUCH = 0x18, - GUILD_BANK_NO_MONEY = 0x19, - GUILD_BANK_TAB_IS_FULL = 0x1B, - GUILD_BANK_ITEM_NOT_FOUND = 0x1C -}; - -enum GuildEvents -{ - GE_PROMOTION = 0x00, - GE_DEMOTION = 0x01, - GE_MOTD = 0x02, - GE_JOINED = 0x03, - GE_LEFT = 0x04, - GE_REMOVED = 0x05, - GE_LEADER_IS = 0x06, - GE_LEADER_CHANGED = 0x07, - GE_DISBANDED = 0x08, - GE_TABARDCHANGE = 0x09, - GE_UNK1 = 0x0A, // string, string - GE_UNK2 = 0x0B, - GE_SIGNED_ON = 0x0C, - GE_SIGNED_OFF = 0x0D, - GE_UNK3 = 0x0E, - GE_BANKTAB_PURCHASED= 0x0F, - GE_UNK5 = 0x10, - GE_UNK6 = 0x11, // string 0000000000002710 is 1 gold - GE_UNK7 = 0x12 -}; - -enum PetitionTurns -{ - PETITION_TURN_OK = 0, - PETITION_TURN_ALREADY_IN_GUILD = 2, - PETITION_TURN_NEED_MORE_SIGNATURES = 4, -}; - -enum PetitionSigns -{ - PETITION_SIGN_OK = 0, - PETITION_SIGN_ALREADY_SIGNED = 1, - PETITION_SIGN_ALREADY_IN_GUILD = 2, - PETITION_SIGN_CANT_SIGN_OWN = 3, - PETITION_SIGN_NOT_SERVER = 4, -}; - -enum GuildBankRights -{ - GUILD_BANK_RIGHT_VIEW_TAB = 0x01, - GUILD_BANK_RIGHT_PUT_ITEM = 0x02, - GUILD_BANK_RIGHT_UPDATE_TEXT = 0x04, - - GUILD_BANK_RIGHT_DEPOSIT_ITEM = GUILD_BANK_RIGHT_VIEW_TAB | GUILD_BANK_RIGHT_PUT_ITEM, - GUILD_BANK_RIGHT_FULL = 0xFF, -}; - -enum GuildBankLogEntries -{ - GUILD_BANK_LOG_DEPOSIT_ITEM = 1, - GUILD_BANK_LOG_WITHDRAW_ITEM = 2, - GUILD_BANK_LOG_MOVE_ITEM = 3, - GUILD_BANK_LOG_DEPOSIT_MONEY = 4, - GUILD_BANK_LOG_WITHDRAW_MONEY = 5, - GUILD_BANK_LOG_REPAIR_MONEY = 6, - GUILD_BANK_LOG_MOVE_ITEM2 = 7, -}; - -enum GuildEventLogEntryTypes -{ - GUILD_EVENT_LOG_INVITE_PLAYER = 1, - GUILD_EVENT_LOG_JOIN_GUILD = 2, - GUILD_EVENT_LOG_PROMOTE_PLAYER = 3, - GUILD_EVENT_LOG_DEMOTE_PLAYER = 4, - GUILD_EVENT_LOG_UNINVITE_PLAYER = 5, - GUILD_EVENT_LOG_LEAVE_GUILD = 6, -}; - -struct GuildEventlogEntry -{ - uint32 LogGuid; - uint8 EventType; - uint32 PlayerGuid1; - uint32 PlayerGuid2; - uint8 NewRank; - uint64 TimeStamp; -}; - -enum GuildEmblem -{ - ERR_GUILDEMBLEM_SUCCESS = 0, - ERR_GUILDEMBLEM_INVALID_TABARD_COLORS = 1, - ERR_GUILDEMBLEM_NOGUILD = 2, - ERR_GUILDEMBLEM_NOTGUILDMASTER = 3, - ERR_GUILDEMBLEM_NOTENOUGHMONEY = 4, - ERR_GUILDEMBLEM_INVALIDVENDOR = 5 -}; - -struct GuildBankEvent -{ - uint32 LogGuid; - uint8 LogEntry; - uint8 TabId; - uint32 PlayerGuid; - uint32 ItemOrMoney; - uint8 ItemStackCount; - uint8 DestTabId; - uint64 TimeStamp; - - const bool isMoneyEvent() - { - return LogEntry == GUILD_BANK_LOG_DEPOSIT_MONEY || - LogEntry == GUILD_BANK_LOG_WITHDRAW_MONEY || - LogEntry == GUILD_BANK_LOG_REPAIR_MONEY; - } -}; - -struct GuildBankTab -{ - Item* Slots[GUILD_BANK_MAX_SLOTS]; - std::string Name; - std::string Icon; - std::string Text; -}; - -struct GuildItemPosCount -{ - GuildItemPosCount(uint8 _slot, uint8 _count) : slot(_slot), count(_count) {} - - uint8 slot; - uint8 count; -}; -typedef std::vector GuildItemPosCountVec; - -struct MemberSlot -{ - uint64 logout_time; - std::string name; - std::string Pnote; - std::string OFFnote; - uint32 RankId; - uint32 zoneId; - uint8 level; - uint8 Class; - uint32 BankResetTimeMoney; - uint32 BankRemMoney; - uint32 BankResetTimeTab[GUILD_BANK_MAX_TABS]; - uint32 BankRemSlotsTab[GUILD_BANK_MAX_TABS]; -}; - -struct RankInfo -{ - RankInfo(std::string _name, uint32 _rights, uint32 _money) : name(_name), rights(_rights), BankMoneyPerDay(_money) - { - for(uint8 i = 0; i < GUILD_BANK_MAX_TABS; ++i) - { - TabRight[i] = 0; - TabSlotPerDay[i] = 0; - } - } - - std::string name; - uint32 rights; - uint32 BankMoneyPerDay; - uint32 TabRight[GUILD_BANK_MAX_TABS]; - uint32 TabSlotPerDay[GUILD_BANK_MAX_TABS]; -}; - -class Guild -{ - public: - Guild(); - ~Guild(); - - bool create(uint64 lGuid, std::string gname); - void Disband(); - - typedef std::map MemberList; - typedef std::vector RankList; - - uint32 GetId(){ return Id; } - const uint64& GetLeader(){ return leaderGuid; } - std::string GetName(){ return name; } - std::string GetMOTD(){ return MOTD; } - std::string GetGINFO(){ return GINFO; } - - uint32 GetCreatedYear(){ return CreatedYear; } - uint32 GetCreatedMonth(){ return CreatedMonth; } - uint32 GetCreatedDay(){ return CreatedDay; } - - uint32 GetEmblemStyle(){ return EmblemStyle; } - uint32 GetEmblemColor(){ return EmblemColor; } - uint32 GetBorderStyle(){ return BorderStyle; } - uint32 GetBorderColor(){ return BorderColor; } - uint32 GetBackgroundColor(){ return BackgroundColor; } - - void SetLeader(uint64 guid); - bool AddMember(uint64 plGuid, uint32 plRank); - void ChangeRank(uint64 guid, uint32 newRank); - void DelMember(uint64 guid, bool isDisbanding=false); - uint32 GetLowestRank() const { return GetNrRanks()-1; } - - void SetMOTD(std::string motd); - void SetGINFO(std::string ginfo); - void SetPNOTE(uint64 guid,std::string pnote); - void SetOFFNOTE(uint64 guid,std::string offnote); - void SetEmblem(uint32 emblemStyle, uint32 emblemColor, uint32 borderStyle, uint32 borderColor, uint32 backgroundColor); - - uint32 GetMemberSize() const { return members.size(); } - - bool LoadGuildFromDB(uint32 GuildId); - bool LoadRanksFromDB(uint32 GuildId); - bool LoadMembersFromDB(uint32 GuildId); - - bool FillPlayerData(uint64 guid, MemberSlot* memslot); - void LoadPlayerStatsByGuid(uint64 guid); - - void BroadcastToGuild(WorldSession *session, std::string msg, uint32 language = LANG_UNIVERSAL); - void BroadcastToOfficers(WorldSession *session, std::string msg, uint32 language = LANG_UNIVERSAL); - void BroadcastPacketToRank(WorldPacket *packet, uint32 rankId); - void BroadcastPacket(WorldPacket *packet); - - void CreateRank(std::string name,uint32 rights); - void DelRank(); - std::string GetRankName(uint32 rankId); - uint32 GetRankRights(uint32 rankId); - uint32 GetNrRanks() const { return m_ranks.size(); } - - void SetRankName(uint32 rankId, std::string name); - void SetRankRights(uint32 rankId, uint32 rights); - bool HasRankRight(uint32 rankId, uint32 right) - { - return ((GetRankRights(rankId) & right) != GR_RIGHT_EMPTY) ? true : false; - } - - void Roster(WorldSession *session); - void Query(WorldSession *session); - - void UpdateLogoutTime(uint64 guid); - // Guild eventlog - void LoadGuildEventLogFromDB(); - void UnloadGuildEventlog(); - void DisplayGuildEventlog(WorldSession *session); - void LogGuildEvent(uint8 EventType, uint32 PlayerGuid1, uint32 PlayerGuid2, uint8 NewRank); - void RenumGuildEventlog(); - - // ** Guild bank ** - // Content & item deposit/withdraw - void DisplayGuildBankContent(WorldSession *session, uint8 TabId); - void DisplayGuildBankContentUpdate(uint8 TabId, int32 slot1, int32 slot2 = -1); - void DisplayGuildBankContentUpdate(uint8 TabId, GuildItemPosCountVec const& slots); - void DisplayGuildBankMoneyUpdate(); - - Item* GetItem(uint8 TabId, uint8 SlotId); - uint8 CanStoreItem( uint8 tab, uint8 slot, GuildItemPosCountVec& dest, uint32 count, Item *pItem, bool swap = false) const; - Item* StoreItem( uint8 tab, GuildItemPosCountVec const& pos, Item *pItem ); - void RemoveItem(uint8 tab, uint8 slot ); - - // Tabs - void DisplayGuildBankTabsInfo(WorldSession *session); - void CreateNewBankTab(); - void SetGuildBankTabText(uint8 TabId, std::string text); - void SendGuildBankTabText(WorldSession *session, uint8 TabId); - void SetGuildBankTabInfo(uint8 TabId, std::string name, std::string icon); - void CreateBankRightForTab(uint32 rankid, uint8 TabId); - const GuildBankTab *GetBankTab(uint8 index) { if(index >= m_TabListMap.size()) return NULL; return m_TabListMap[index]; } - const uint8 GetPurchasedTabs() const { return purchased_tabs; } - uint32 GetBankRights(uint32 rankId, uint8 TabId) const; - bool IsMemberHaveRights(uint32 LowGuid, uint8 TabId,uint32 rights) const; - bool CanMemberViewTab(uint32 LowGuid, uint8 TabId) const; - // Load/unload - void LoadGuildBankFromDB(); - void UnloadGuildBank(); - void IncOnlineMemberCount() { ++m_onlinemembers; } - // Money deposit/withdraw - void SendMoneyInfo(WorldSession *session, uint32 LowGuid); - bool MemberMoneyWithdraw(uint32 amount, uint32 LowGuid); - uint64 GetGuildBankMoney() { return guildbank_money; } - void SetBankMoney(int64 money); - // per days - bool MemberItemWithdraw(uint8 TabId, uint32 LowGuid); - uint32 GetMemberSlotWithdrawRem(uint32 LowGuid, uint8 TabId); - uint32 GetMemberMoneyWithdrawRem(uint32 LowGuid); - void SetBankMoneyPerDay(uint32 rankId, uint32 money); - void SetBankRightsAndSlots(uint32 rankId, uint8 TabId, uint32 right, uint32 SlotPerDay, bool db); - uint32 GetBankMoneyPerDay(uint32 rankId); - uint32 GetBankSlotPerDay(uint32 rankId, uint8 TabId); - // rights per day - void LoadBankRightsFromDB(uint32 GuildId); - // logs - void LoadGuildBankEventLogFromDB(); - void UnloadGuildBankEventLog(); - void DisplayGuildBankLogs(WorldSession *session, uint8 TabId); - void LogBankEvent(uint8 LogEntry, uint8 TabId, uint32 PlayerGuidLow, uint32 ItemOrMoney, uint8 ItemStackCount=0, uint8 DestTabId=0); - void RenumBankLogs(); - bool AddGBankItemToDB(uint32 GuildId, uint32 BankTab , uint32 BankTabSlot , uint32 GUIDLow, uint32 Entry ); - - protected: - void AddRank(std::string name,uint32 rights,uint32 money); - - uint32 Id; - std::string name; - uint64 leaderGuid; - std::string MOTD; - std::string GINFO; - uint32 CreatedYear; - uint32 CreatedMonth; - uint32 CreatedDay; - - uint32 EmblemStyle; - uint32 EmblemColor; - uint32 BorderStyle; - uint32 BorderColor; - uint32 BackgroundColor; - - RankList m_ranks; - - MemberList members; - - typedef std::vector TabListMap; - TabListMap m_TabListMap; - - /** These are actually ordered lists. The first element is the oldest entry.*/ - typedef std::list GuildEventlog; - typedef std::list GuildBankEventLog; - GuildEventlog m_GuildEventlog; - GuildBankEventLog m_GuildBankEventLog_Money; - GuildBankEventLog m_GuildBankEventLog_Item[GUILD_BANK_MAX_TABS]; - - bool m_bankloaded; - bool m_eventlogloaded; - uint32 m_onlinemembers; - uint64 guildbank_money; - uint8 purchased_tabs; - - uint32 LogMaxGuid; - uint32 GuildEventlogMaxGuid; - private: - // internal common parts for CanStore/StoreItem functions - void AppendDisplayGuildBankSlot( WorldPacket& data, GuildBankTab const *tab, int32 slot ); - uint8 _CanStoreItem_InSpecificSlot( uint8 tab, uint8 slot, GuildItemPosCountVec& dest, uint32& count, bool swap, Item *pSrcItem ) const; - uint8 _CanStoreItem_InTab( uint8 tab, GuildItemPosCountVec& dest, uint32& count, bool merge, Item *pSrcItem, uint8 skip_slot ) const; - Item* _StoreItem( uint8 tab, uint8 slot, Item *pItem, uint32 count, bool clone ); -}; -#endif +/* + * Copyright (C) 2005-2008 MaNGOS + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef MANGOSSERVER_GUILD_H +#define MANGOSSERVER_GUILD_H + +#define WITHDRAW_MONEY_UNLIMITED 0xFFFFFFFF +#define WITHDRAW_SLOT_UNLIMITED 0xFFFFFFFF + +#include "Item.h" + +class Item; + +enum GuildDefaultRanks +{ + GR_GUILDMASTER = 0, + GR_OFFICER = 1, + //GR_VETERAN = 2, -- not used anywhere and possible incorrect in modified rank list + //GR_MEMBER = 3, + //GR_INITIATE = 4, -- use Guild::GetLowestRank() instead for lowest rank +}; + +enum GuildRankRights +{ + GR_RIGHT_EMPTY = 0x00000040, + GR_RIGHT_GCHATLISTEN = 0x00000041, + GR_RIGHT_GCHATSPEAK = 0x00000042, + GR_RIGHT_OFFCHATLISTEN = 0x00000044, + GR_RIGHT_OFFCHATSPEAK = 0x00000048, + GR_RIGHT_PROMOTE = 0x000000C0, + GR_RIGHT_DEMOTE = 0x00000140, + GR_RIGHT_INVITE = 0x00000050, + GR_RIGHT_REMOVE = 0x00000060, + GR_RIGHT_SETMOTD = 0x00001040, + GR_RIGHT_EPNOTE = 0x00002040, + GR_RIGHT_VIEWOFFNOTE = 0x00004040, + GR_RIGHT_EOFFNOTE = 0x00008040, + GR_RIGHT_MODIFY_GUILD_INFO = 0x00010040, + GR_RIGHT_REPAIR_FROM_GUILD = 0x00020000, // unused in 2.4.x?, Remove money withdraw capacity + GR_RIGHT_WITHDRAW_REPAIR = 0x00040000, // withdraw for repair + GR_RIGHT_WITHDRAW_GOLD = 0x00080000, // withdraw gold + GR_RIGHT_ALL = 0x000FF1FF +}; + +enum Typecommand +{ + GUILD_CREATE_S = 0x00, + GUILD_INVITE_S = 0x01, + GUILD_QUIT_S = 0x03, + GUILD_FOUNDER_S = 0x0E, + GUILD_UNK1 = 0x10, + GUILD_BANK_S = 0x15, + GUILD_UNK3 = 0x16 +}; + +enum CommandErrors +{ + GUILD_PLAYER_NO_MORE_IN_GUILD = 0x00, + GUILD_INTERNAL = 0x01, + GUILD_ALREADY_IN_GUILD = 0x02, + ALREADY_IN_GUILD = 0x03, + INVITED_TO_GUILD = 0x04, + ALREADY_INVITED_TO_GUILD = 0x05, + GUILD_NAME_INVALID = 0x06, + GUILD_NAME_EXISTS = 0x07, + GUILD_LEADER_LEAVE = 0x08, + GUILD_PERMISSIONS = 0x08, + GUILD_PLAYER_NOT_IN_GUILD = 0x09, + GUILD_PLAYER_NOT_IN_GUILD_S = 0x0A, + GUILD_PLAYER_NOT_FOUND = 0x0B, + GUILD_NOT_ALLIED = 0x0C, + GUILD_RANK_TOO_HIGH_S = 0x0D, + GUILD_ALREADY_LOWEST_RANK_S = 0x0E, + GUILD_TEMP_ERROR = 0x11, + GUILD_RANK_IN_USE = 0x12, + GUILD_IGNORE = 0x13, + GUILD_ERR_UNK1 = 0x17, + GUILD_WITHDRAW_TOO_MUCH = 0x18, + GUILD_BANK_NO_MONEY = 0x19, + GUILD_BANK_TAB_IS_FULL = 0x1B, + GUILD_BANK_ITEM_NOT_FOUND = 0x1C +}; + +enum GuildEvents +{ + GE_PROMOTION = 0x00, + GE_DEMOTION = 0x01, + GE_MOTD = 0x02, + GE_JOINED = 0x03, + GE_LEFT = 0x04, + GE_REMOVED = 0x05, + GE_LEADER_IS = 0x06, + GE_LEADER_CHANGED = 0x07, + GE_DISBANDED = 0x08, + GE_TABARDCHANGE = 0x09, + GE_UNK1 = 0x0A, // string, string + GE_UNK2 = 0x0B, + GE_SIGNED_ON = 0x0C, + GE_SIGNED_OFF = 0x0D, + GE_UNK3 = 0x0E, + GE_BANKTAB_PURCHASED= 0x0F, + GE_UNK5 = 0x10, + GE_UNK6 = 0x11, // string 0000000000002710 is 1 gold + GE_UNK7 = 0x12 +}; + +enum PetitionTurns +{ + PETITION_TURN_OK = 0, + PETITION_TURN_ALREADY_IN_GUILD = 2, + PETITION_TURN_NEED_MORE_SIGNATURES = 4, +}; + +enum PetitionSigns +{ + PETITION_SIGN_OK = 0, + PETITION_SIGN_ALREADY_SIGNED = 1, + PETITION_SIGN_ALREADY_IN_GUILD = 2, + PETITION_SIGN_CANT_SIGN_OWN = 3, + PETITION_SIGN_NOT_SERVER = 4, +}; + +enum GuildBankRights +{ + GUILD_BANK_RIGHT_VIEW_TAB = 0x01, + GUILD_BANK_RIGHT_PUT_ITEM = 0x02, + GUILD_BANK_RIGHT_UPDATE_TEXT = 0x04, + + GUILD_BANK_RIGHT_DEPOSIT_ITEM = GUILD_BANK_RIGHT_VIEW_TAB | GUILD_BANK_RIGHT_PUT_ITEM, + GUILD_BANK_RIGHT_FULL = 0xFF, +}; + +enum GuildBankLogEntries +{ + GUILD_BANK_LOG_DEPOSIT_ITEM = 1, + GUILD_BANK_LOG_WITHDRAW_ITEM = 2, + GUILD_BANK_LOG_MOVE_ITEM = 3, + GUILD_BANK_LOG_DEPOSIT_MONEY = 4, + GUILD_BANK_LOG_WITHDRAW_MONEY = 5, + GUILD_BANK_LOG_REPAIR_MONEY = 6, + GUILD_BANK_LOG_MOVE_ITEM2 = 7, +}; + +enum GuildEventLogEntryTypes +{ + GUILD_EVENT_LOG_INVITE_PLAYER = 1, + GUILD_EVENT_LOG_JOIN_GUILD = 2, + GUILD_EVENT_LOG_PROMOTE_PLAYER = 3, + GUILD_EVENT_LOG_DEMOTE_PLAYER = 4, + GUILD_EVENT_LOG_UNINVITE_PLAYER = 5, + GUILD_EVENT_LOG_LEAVE_GUILD = 6, +}; + +struct GuildEventlogEntry +{ + uint32 LogGuid; + uint8 EventType; + uint32 PlayerGuid1; + uint32 PlayerGuid2; + uint8 NewRank; + uint64 TimeStamp; +}; + +enum GuildEmblem +{ + ERR_GUILDEMBLEM_SUCCESS = 0, + ERR_GUILDEMBLEM_INVALID_TABARD_COLORS = 1, + ERR_GUILDEMBLEM_NOGUILD = 2, + ERR_GUILDEMBLEM_NOTGUILDMASTER = 3, + ERR_GUILDEMBLEM_NOTENOUGHMONEY = 4, + ERR_GUILDEMBLEM_INVALIDVENDOR = 5 +}; + +struct GuildBankEvent +{ + uint32 LogGuid; + uint8 LogEntry; + uint8 TabId; + uint32 PlayerGuid; + uint32 ItemOrMoney; + uint8 ItemStackCount; + uint8 DestTabId; + uint64 TimeStamp; + + const bool isMoneyEvent() + { + return LogEntry == GUILD_BANK_LOG_DEPOSIT_MONEY || + LogEntry == GUILD_BANK_LOG_WITHDRAW_MONEY || + LogEntry == GUILD_BANK_LOG_REPAIR_MONEY; + } +}; + +struct GuildBankTab +{ + Item* Slots[GUILD_BANK_MAX_SLOTS]; + std::string Name; + std::string Icon; + std::string Text; +}; + +struct GuildItemPosCount +{ + GuildItemPosCount(uint8 _slot, uint8 _count) : slot(_slot), count(_count) {} + + bool isContainedIn(std::vector const& vec) const; + + uint8 slot; + uint8 count; +}; +typedef std::vector GuildItemPosCountVec; + +struct MemberSlot +{ + uint64 logout_time; + std::string name; + std::string Pnote; + std::string OFFnote; + uint32 RankId; + uint32 zoneId; + uint8 level; + uint8 Class; + uint32 BankResetTimeMoney; + uint32 BankRemMoney; + uint32 BankResetTimeTab[GUILD_BANK_MAX_TABS]; + uint32 BankRemSlotsTab[GUILD_BANK_MAX_TABS]; +}; + +struct RankInfo +{ + RankInfo(std::string _name, uint32 _rights, uint32 _money) : name(_name), rights(_rights), BankMoneyPerDay(_money) + { + for(uint8 i = 0; i < GUILD_BANK_MAX_TABS; ++i) + { + TabRight[i] = 0; + TabSlotPerDay[i] = 0; + } + } + + std::string name; + uint32 rights; + uint32 BankMoneyPerDay; + uint32 TabRight[GUILD_BANK_MAX_TABS]; + uint32 TabSlotPerDay[GUILD_BANK_MAX_TABS]; +}; + +class Guild +{ + public: + Guild(); + ~Guild(); + + bool create(uint64 lGuid, std::string gname); + void Disband(); + + typedef std::map MemberList; + typedef std::vector RankList; + + uint32 GetId(){ return Id; } + const uint64& GetLeader(){ return leaderGuid; } + std::string GetName(){ return name; } + std::string GetMOTD(){ return MOTD; } + std::string GetGINFO(){ return GINFO; } + + uint32 GetCreatedYear(){ return CreatedYear; } + uint32 GetCreatedMonth(){ return CreatedMonth; } + uint32 GetCreatedDay(){ return CreatedDay; } + + uint32 GetEmblemStyle(){ return EmblemStyle; } + uint32 GetEmblemColor(){ return EmblemColor; } + uint32 GetBorderStyle(){ return BorderStyle; } + uint32 GetBorderColor(){ return BorderColor; } + uint32 GetBackgroundColor(){ return BackgroundColor; } + + void SetLeader(uint64 guid); + bool AddMember(uint64 plGuid, uint32 plRank); + void ChangeRank(uint64 guid, uint32 newRank); + void DelMember(uint64 guid, bool isDisbanding=false); + uint32 GetLowestRank() const { return GetNrRanks()-1; } + + void SetMOTD(std::string motd); + void SetGINFO(std::string ginfo); + void SetPNOTE(uint64 guid,std::string pnote); + void SetOFFNOTE(uint64 guid,std::string offnote); + void SetEmblem(uint32 emblemStyle, uint32 emblemColor, uint32 borderStyle, uint32 borderColor, uint32 backgroundColor); + + uint32 GetMemberSize() const { return members.size(); } + + bool LoadGuildFromDB(uint32 GuildId); + bool LoadRanksFromDB(uint32 GuildId); + bool LoadMembersFromDB(uint32 GuildId); + + bool FillPlayerData(uint64 guid, MemberSlot* memslot); + void LoadPlayerStatsByGuid(uint64 guid); + + void BroadcastToGuild(WorldSession *session, std::string msg, uint32 language = LANG_UNIVERSAL); + void BroadcastToOfficers(WorldSession *session, std::string msg, uint32 language = LANG_UNIVERSAL); + void BroadcastPacketToRank(WorldPacket *packet, uint32 rankId); + void BroadcastPacket(WorldPacket *packet); + + void CreateRank(std::string name,uint32 rights); + void DelRank(); + std::string GetRankName(uint32 rankId); + uint32 GetRankRights(uint32 rankId); + uint32 GetNrRanks() const { return m_ranks.size(); } + + void SetRankName(uint32 rankId, std::string name); + void SetRankRights(uint32 rankId, uint32 rights); + bool HasRankRight(uint32 rankId, uint32 right) + { + return ((GetRankRights(rankId) & right) != GR_RIGHT_EMPTY) ? true : false; + } + + void Roster(WorldSession *session); + void Query(WorldSession *session); + + void UpdateLogoutTime(uint64 guid); + // Guild eventlog + void LoadGuildEventLogFromDB(); + void UnloadGuildEventlog(); + void DisplayGuildEventlog(WorldSession *session); + void LogGuildEvent(uint8 EventType, uint32 PlayerGuid1, uint32 PlayerGuid2, uint8 NewRank); + void RenumGuildEventlog(); + + // ** Guild bank ** + // Content & item deposit/withdraw + void DisplayGuildBankContent(WorldSession *session, uint8 TabId); + void DisplayGuildBankContentUpdate(uint8 TabId, int32 slot1, int32 slot2 = -1); + void DisplayGuildBankContentUpdate(uint8 TabId, GuildItemPosCountVec const& slots); + void DisplayGuildBankMoneyUpdate(); + + Item* GetItem(uint8 TabId, uint8 SlotId); + uint8 CanStoreItem( uint8 tab, uint8 slot, GuildItemPosCountVec& dest, uint32 count, Item *pItem, bool swap = false) const; + Item* StoreItem( uint8 tab, GuildItemPosCountVec const& pos, Item *pItem ); + void RemoveItem(uint8 tab, uint8 slot ); + + // Tabs + void DisplayGuildBankTabsInfo(WorldSession *session); + void CreateNewBankTab(); + void SetGuildBankTabText(uint8 TabId, std::string text); + void SendGuildBankTabText(WorldSession *session, uint8 TabId); + void SetGuildBankTabInfo(uint8 TabId, std::string name, std::string icon); + void CreateBankRightForTab(uint32 rankid, uint8 TabId); + const GuildBankTab *GetBankTab(uint8 index) { if(index >= m_TabListMap.size()) return NULL; return m_TabListMap[index]; } + const uint8 GetPurchasedTabs() const { return purchased_tabs; } + uint32 GetBankRights(uint32 rankId, uint8 TabId) const; + bool IsMemberHaveRights(uint32 LowGuid, uint8 TabId,uint32 rights) const; + bool CanMemberViewTab(uint32 LowGuid, uint8 TabId) const; + // Load/unload + void LoadGuildBankFromDB(); + void UnloadGuildBank(); + void IncOnlineMemberCount() { ++m_onlinemembers; } + // Money deposit/withdraw + void SendMoneyInfo(WorldSession *session, uint32 LowGuid); + bool MemberMoneyWithdraw(uint32 amount, uint32 LowGuid); + uint64 GetGuildBankMoney() { return guildbank_money; } + void SetBankMoney(int64 money); + // per days + bool MemberItemWithdraw(uint8 TabId, uint32 LowGuid); + uint32 GetMemberSlotWithdrawRem(uint32 LowGuid, uint8 TabId); + uint32 GetMemberMoneyWithdrawRem(uint32 LowGuid); + void SetBankMoneyPerDay(uint32 rankId, uint32 money); + void SetBankRightsAndSlots(uint32 rankId, uint8 TabId, uint32 right, uint32 SlotPerDay, bool db); + uint32 GetBankMoneyPerDay(uint32 rankId); + uint32 GetBankSlotPerDay(uint32 rankId, uint8 TabId); + // rights per day + void LoadBankRightsFromDB(uint32 GuildId); + // logs + void LoadGuildBankEventLogFromDB(); + void UnloadGuildBankEventLog(); + void DisplayGuildBankLogs(WorldSession *session, uint8 TabId); + void LogBankEvent(uint8 LogEntry, uint8 TabId, uint32 PlayerGuidLow, uint32 ItemOrMoney, uint8 ItemStackCount=0, uint8 DestTabId=0); + void RenumBankLogs(); + bool AddGBankItemToDB(uint32 GuildId, uint32 BankTab , uint32 BankTabSlot , uint32 GUIDLow, uint32 Entry ); + + protected: + void AddRank(std::string name,uint32 rights,uint32 money); + + uint32 Id; + std::string name; + uint64 leaderGuid; + std::string MOTD; + std::string GINFO; + uint32 CreatedYear; + uint32 CreatedMonth; + uint32 CreatedDay; + + uint32 EmblemStyle; + uint32 EmblemColor; + uint32 BorderStyle; + uint32 BorderColor; + uint32 BackgroundColor; + + RankList m_ranks; + + MemberList members; + + typedef std::vector TabListMap; + TabListMap m_TabListMap; + + /** These are actually ordered lists. The first element is the oldest entry.*/ + typedef std::list GuildEventlog; + typedef std::list GuildBankEventLog; + GuildEventlog m_GuildEventlog; + GuildBankEventLog m_GuildBankEventLog_Money; + GuildBankEventLog m_GuildBankEventLog_Item[GUILD_BANK_MAX_TABS]; + + bool m_bankloaded; + bool m_eventlogloaded; + uint32 m_onlinemembers; + uint64 guildbank_money; + uint8 purchased_tabs; + + uint32 LogMaxGuid; + uint32 GuildEventlogMaxGuid; + private: + // internal common parts for CanStore/StoreItem functions + void AppendDisplayGuildBankSlot( WorldPacket& data, GuildBankTab const *tab, int32 slot ); + uint8 _CanStoreItem_InSpecificSlot( uint8 tab, uint8 slot, GuildItemPosCountVec& dest, uint32& count, bool swap, Item *pSrcItem ) const; + uint8 _CanStoreItem_InTab( uint8 tab, GuildItemPosCountVec& dest, uint32& count, bool merge, Item *pSrcItem, uint8 skip_slot ) const; + Item* _StoreItem( uint8 tab, uint8 slot, Item *pItem, uint32 count, bool clone ); +}; +#endif diff --git a/src/game/Language.h b/src/game/Language.h index bb36bffcee6..5fe11e44c57 100644 --- a/src/game/Language.h +++ b/src/game/Language.h @@ -1,665 +1,668 @@ -/* - * Copyright (C) 2005-2008 MaNGOS - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef __MANGOS_LANGUAGE_H -#define __MANGOS_LANGUAGE_H - -enum MangosStrings -{ - // for chat commands - LANG_SELECT_CHAR_OR_CREATURE = 1, - LANG_SELECT_CREATURE = 2, - - // level 0 chat - LANG_SYSTEMMESSAGE = 3, - LANG_EVENTMESSAGE = 4, - LANG_NO_HELP_CMD = 5, - LANG_NO_CMD = 6, - LANG_NO_SUBCMD = 7, - LANG_SUBCMDS_LIST = 8, - LANG_AVIABLE_CMD = 9, - LANG_CMD_SYNTAX = 10, - LANG_ACCOUNT_LEVEL = 11, - LANG_CONNECTED_USERS = 12, - LANG_UPTIME = 13, - LANG_PLAYER_SAVED = 14, - LANG_PLAYERS_SAVED = 15, - LANG_GMS_ON_SRV = 16, - LANG_GMS_NOT_LOGGED = 17, - LANG_YOU_IN_FLIGHT = 18, - //LANG_YOU_IN_BATTLEGROUND = 19, not used - //LANG_TARGET_IN_FLIGHT = 20, not used - LANG_CHAR_IN_FLIGHT = 21, - LANG_CHAR_NON_MOUNTED = 22, - LANG_YOU_IN_COMBAT = 23, - LANG_YOU_USED_IT_RECENTLY = 24, - LANG_COMMAND_NOTCHANGEPASSWORD = 25, - LANG_COMMAND_PASSWORD = 26, - LANG_COMMAND_WRONGOLDPASSWORD = 27, - LANG_COMMAND_ACCLOCKLOCKED = 28, - LANG_COMMAND_ACCLOCKUNLOCKED = 29, - LANG_SPELL_RANK = 30, - LANG_KNOWN = 31, - LANG_LEARN = 32, - LANG_PASSIVE = 33, - LANG_TALENT = 34, - LANG_ACTIVE = 35, - LANG_COMPLETE = 36, - LANG_OFFLINE = 37, - LANG_ON = 38, - LANG_OFF = 39, - LANG_YOU_ARE = 40, - LANG_VISIBLE = 41, - LANG_INVISIBLE = 42, - LANG_DONE = 43, - LANG_YOU = 44, - LANG_UNKNOWN = 45, - LANG_ERROR = 46, - LANG_NON_EXIST_CHARACTER = 47, - LANG_FRIEND_IGNORE_UNKNOWN = 48, - LANG_LEVEL_MINREQUIRED = 49, - LANG_LEVEL_MINREQUIRED_AND_ITEM = 50, - LANG_NPC_TAINER_HELLO = 51, - // Room for more level 0 - - // level 1 chat - LANG_GLOBAL_NOTIFY = 100, - LANG_MAP_POSITION = 101, - LANG_IS_TELEPORTED = 102, - LANG_CANNOT_SUMMON_TO_INST = 103, - LANG_CANNOT_GO_TO_INST_PARTY = 104, - LANG_CANNOT_GO_TO_INST_GM = 105, - LANG_CANNOT_GO_INST_INST = 106, - LANG_CANNOT_SUMMON_INST_INST = 107, - - LANG_SUMMONING = 108, - LANG_SUMMONED_BY = 109, - LANG_TELEPORTING_TO = 110, - LANG_TELEPORTED_TO_BY = 111, - LANG_NO_PLAYER = 112, - LANG_APPEARING_AT = 113, - LANG_APPEARING_TO = 114, - - LANG_BAD_VALUE = 115, - LANG_NO_CHAR_SELECTED = 116, - LANG_NOT_IN_GROUP = 117, - - LANG_YOU_CHANGE_HP = 118, - LANG_YOURS_HP_CHANGED = 119, - LANG_YOU_CHANGE_MANA = 120, - LANG_YOURS_MANA_CHANGED = 121, - LANG_YOU_CHANGE_ENERGY = 122, - LANG_YOURS_ENERGY_CHANGED = 123, - - LANG_CURRENT_ENERGY = 124, //log - LANG_YOU_CHANGE_RAGE = 125, - LANG_YOURS_RAGE_CHANGED = 126, - LANG_YOU_CHANGE_LVL = 127, - LANG_CURRENT_FACTION = 128, - LANG_WRONG_FACTION = 129, - LANG_YOU_CHANGE_FACTION = 130, - LANG_YOU_CHANGE_SPELLFLATID = 131, - LANG_YOURS_SPELLFLATID_CHANGED = 132, - LANG_YOU_GIVE_TAXIS = 133, - LANG_YOU_REMOVE_TAXIS = 134, - LANG_YOURS_TAXIS_ADDED = 135, - LANG_YOURS_TAXIS_REMOVED = 136, - - LANG_YOU_CHANGE_ASPEED = 137, - LANG_YOURS_ASPEED_CHANGED = 138, - LANG_YOU_CHANGE_SPEED = 139, - LANG_YOURS_SPEED_CHANGED = 140, - LANG_YOU_CHANGE_SWIM_SPEED = 141, - LANG_YOURS_SWIM_SPEED_CHANGED = 142, - LANG_YOU_CHANGE_BACK_SPEED = 143, - LANG_YOURS_BACK_SPEED_CHANGED = 144, - LANG_YOU_CHANGE_FLY_SPEED = 145, - LANG_YOURS_FLY_SPEED_CHANGED = 146, - - LANG_YOU_CHANGE_SIZE = 147, - LANG_YOURS_SIZE_CHANGED = 148, - LANG_NO_MOUNT = 149, - LANG_YOU_GIVE_MOUNT = 150, - LANG_MOUNT_GIVED = 151, - - LANG_CURRENT_MONEY = 152, - LANG_YOU_TAKE_ALL_MONEY = 153, - LANG_YOURS_ALL_MONEY_GONE = 154, - LANG_YOU_TAKE_MONEY = 155, - LANG_YOURS_MONEY_TAKEN = 156, - LANG_YOU_GIVE_MONEY = 157, - LANG_YOURS_MONEY_GIVEN = 158, - LANG_YOU_HEAR_SOUND = 159, - - LANG_NEW_MONEY = 160, // Log - - LANG_REMOVE_BIT = 161, - LANG_SET_BIT = 162, - LANG_COMMAND_TELE_TABLEEMPTY = 163, - LANG_COMMAND_TELE_NOTFOUND = 164, - LANG_COMMAND_TELE_PARAMETER = 165, - LANG_COMMAND_TELE_NOREQUEST = 166, - LANG_COMMAND_TELE_NOLOCATION = 167, - LANG_COMMAND_TELE_LOCATION = 168, - - LANG_MAIL_SENT = 169, - LANG_SOUND_NOT_EXIST = 170, - // Room for more level 1 - - // level 2 chat - LANG_NO_SELECTION = 200, - LANG_OBJECT_GUID = 201, - LANG_TOO_LONG_NAME = 202, - LANG_CHARS_ONLY = 203, - LANG_TOO_LONG_SUBNAME = 204, - LANG_NOT_IMPLEMENTED = 205, - - LANG_ITEM_ADDED_TO_LIST = 206, - LANG_ITEM_NOT_FOUND = 207, - LANG_ITEM_DELETED_FROM_LIST = 208, - LANG_ITEM_NOT_IN_LIST = 209, - LANG_ITEM_ALREADY_IN_LIST = 210, - - LANG_RESET_SPELLS_ONLINE = 211, - LANG_RESET_SPELLS_OFFLINE = 212, - LANG_RESET_TALENTS_ONLINE = 213, - LANG_RESET_TALENTS_OFFLINE = 214, - LANG_RESET_SPELLS = 215, - LANG_RESET_TALENTS = 216, - - LANG_RESETALL_UNKNOWN_CASE = 217, - LANG_RESETALL_SPELLS = 218, - LANG_RESETALL_TALENTS = 219, - - LANG_WAYPOINT_NOTFOUND = 220, - LANG_WAYPOINT_NOTFOUNDLAST = 221, - LANG_WAYPOINT_NOTFOUNDSEARCH = 222, - LANG_WAYPOINT_NOTFOUNDDBPROBLEM = 223, - LANG_WAYPOINT_CREATSELECTED = 224, - LANG_WAYPOINT_CREATNOTFOUND = 225, - LANG_WAYPOINT_VP_SELECT = 226, - LANG_WAYPOINT_VP_NOTFOUND = 227, - LANG_WAYPOINT_VP_NOTCREATED = 228, - LANG_WAYPOINT_VP_ALLREMOVED = 229, - LANG_WAYPOINT_NOTCREATED = 230, - LANG_WAYPOINT_NOGUID = 231, - LANG_WAYPOINT_NOWAYPOINTGIVEN = 232, - LANG_WAYPOINT_ARGUMENTREQ = 233, - LANG_WAYPOINT_ADDED = 234, - LANG_WAYPOINT_ADDED_NO = 235, - LANG_WAYPOINT_CHANGED = 236, - LANG_WAYPOINT_CHANGED_NO = 237, - LANG_WAYPOINT_EXPORTED = 238, - LANG_WAYPOINT_NOTHINGTOEXPORT = 239, - LANG_WAYPOINT_IMPORTED = 240, - LANG_WAYPOINT_REMOVED = 241, - LANG_WAYPOINT_NOTREMOVED = 242, - LANG_WAYPOINT_TOOFAR1 = 243, - LANG_WAYPOINT_TOOFAR2 = 244, - LANG_WAYPOINT_TOOFAR3 = 245, - LANG_WAYPOINT_INFO_TITLE = 246, - LANG_WAYPOINT_INFO_WAITTIME = 247, - LANG_WAYPOINT_INFO_MODEL = 248, - LANG_WAYPOINT_INFO_EMOTE = 249, - LANG_WAYPOINT_INFO_SPELL = 250, - LANG_WAYPOINT_INFO_TEXT = 251, - LANG_WAYPOINT_INFO_AISCRIPT = 252, - - LANG_RENAME_PLAYER = 253, - LANG_RENAME_PLAYER_GUID = 254, - - LANG_WAYPOINT_WPCREATNOTFOUND = 255, - LANG_WAYPOINT_NPCNOTFOUND = 256, - - LANG_MOVE_TYPE_SET = 257, - LANG_MOVE_TYPE_SET_NODEL = 258, - LANG_USE_BOL = 259, - LANG_VALUE_SAVED = 260, - LANG_VALUE_SAVED_REJOIN = 261, - - LANG_COMMAND_GOAREATRNOTFOUND = 262, - LANG_INVALID_TARGET_COORD = 263, - LANG_INVALID_ZONE_COORD = 264, - LANG_INVALID_ZONE_MAP = 265, - LANG_COMMAND_TARGETOBJNOTFOUND = 266, - LANG_COMMAND_GOOBJNOTFOUND = 267, - LANG_COMMAND_GOCREATNOTFOUND = 268, - LANG_COMMAND_GOCREATMULTIPLE = 269, - LANG_COMMAND_DELCREATMESSAGE = 270, - LANG_COMMAND_CREATUREMOVED = 271, - LANG_COMMAND_CREATUREATSAMEMAP = 272, - LANG_COMMAND_OBJNOTFOUND = 273, - LANG_COMMAND_DELOBJREFERCREATURE = 274, - LANG_COMMAND_DELOBJMESSAGE = 275, - LANG_COMMAND_TURNOBJMESSAGE = 276, - LANG_COMMAND_MOVEOBJMESSAGE = 277, - LANG_COMMAND_VENDORSELECTION = 278, - LANG_COMMAND_NEEDITEMSEND = 279, - LANG_COMMAND_ADDVENDORITEMITEMS = 280, - LANG_COMMAND_KICKSELF = 281, - LANG_COMMAND_KICKMESSAGE = 282, - LANG_COMMAND_KICKNOTFOUNDPLAYER = 283, - LANG_COMMAND_WHISPERACCEPTING = 284, - LANG_COMMAND_WHISPERON = 285, - LANG_COMMAND_WHISPEROFF = 286, - LANG_COMMAND_CREATGUIDNOTFOUND = 287, - LANG_COMMAND_TICKETCOUNT = 288, - LANG_COMMAND_TICKETNEW = 289, - LANG_COMMAND_TICKETVIEW = 290, - LANG_COMMAND_TICKETON = 291, - LANG_COMMAND_TICKETOFF = 292, - LANG_COMMAND_TICKENOTEXIST = 293, - LANG_COMMAND_ALLTICKETDELETED = 294, - LANG_COMMAND_TICKETPLAYERDEL = 295, - LANG_COMMAND_TICKETDEL = 296, - LANG_COMMAND_SPAWNDIST = 297, - LANG_COMMAND_SPAWNTIME = 298, - LANG_COMMAND_MODIFY_HONOR = 299, - - LANG_YOUR_CHAT_DISABLED = 300, - LANG_YOU_DISABLE_CHAT = 301, - LANG_CHAT_ALREADY_ENABLED = 302, - LANG_YOUR_CHAT_ENABLED = 303, - LANG_YOU_ENABLE_CHAT = 304, - - LANG_COMMAND_MODIFY_REP = 305, - LANG_COMMAND_MODIFY_ARENA = 306, - LANG_COMMAND_FACTION_NOTFOUND = 307, - LANG_COMMAND_FACTION_UNKNOWN = 308, - LANG_COMMAND_FACTION_INVPARAM = 309, - LANG_COMMAND_FACTION_DELTA = 310, - LANG_FACTION_LIST = 311, - LANG_FACTION_VISIBLE = 312, - LANG_FACTION_ATWAR = 313, - LANG_FACTION_PEACE_FORCED = 314, - LANG_FACTION_HIDDEN = 315, - LANG_FACTION_INVISIBLE_FORCED = 316, - LANG_FACTION_INACTIVE = 317, - LANG_REP_HATED = 318, - LANG_REP_HOSTILE = 319, - LANG_REP_UNFRIENDLY = 320, - LANG_REP_NEUTRAL = 321, - LANG_REP_FRIENDLY = 322, - LANG_REP_HONORED = 323, - LANG_REP_REVERED = 324, - LANG_REP_EXALTED = 325, - LANG_COMMAND_FACTION_NOREP_ERROR = 326, - LANG_FACTION_NOREPUTATION = 327, - - // Room for more level 2 - - // level 3 chat - LANG_SCRIPTS_RELOADED = 400, - LANG_YOU_CHANGE_SECURITY = 401, - LANG_YOURS_SECURITY_CHANGED = 402, - LANG_YOURS_SECURITY_IS_LOW = 403, - LANG_CREATURE_MOVE_DISABLED = 404, - LANG_CREATURE_MOVE_ENABLED = 405, - LANG_NO_WEATHER = 406, - LANG_WEATHER_DISABLED = 407, - - LANG_BAN_YOUBANNED = 408, - LANG_BAN_YOUPERMBANNED = 409, - LANG_BAN_NOTFOUND = 410, - - LANG_UNBAN_UNBANNED = 411, - LANG_UNBAN_ERROR = 412, - - LANG_BANINFO_NOACCOUNT = 413, - LANG_BANINFO_NOCHARACTER = 414, - LANG_BANINFO_NOIP = 415, - LANG_BANINFO_NOACCOUNTBAN = 416, - LANG_BANINFO_BANHISTORY = 417, - LANG_BANINFO_HISTORYENTRY = 418, - LANG_BANINFO_INFINITE = 419, - LANG_BANINFO_NEVER = 420, - LANG_BANINFO_YES = 421, - LANG_BANINFO_NO = 422, - LANG_BANINFO_IPENTRY = 423, - - LANG_BANLIST_NOIP = 424, - LANG_BANLIST_NOACCOUNT = 425, - LANG_BANLIST_NOCHARACTER = 426, - LANG_BANLIST_MATCHINGIP = 427, - LANG_BANLIST_MATCHINGACCOUNT = 428, - - LANG_COMMAND_LEARN_MANY_SPELLS = 429, - LANG_COMMAND_LEARN_CLASS_SPELLS = 430, - LANG_COMMAND_LEARN_CLASS_TALENTS = 431, - LANG_COMMAND_LEARN_ALL_LANG = 432, - LANG_COMMAND_LEARN_ALL_CRAFT = 433, - LANG_COMMAND_COULDNOTFIND = 434, - LANG_COMMAND_ITEMIDINVALID = 435, - LANG_COMMAND_NOITEMFOUND = 436, - LANG_COMMAND_LISTOBJINVALIDID = 437, - LANG_COMMAND_LISTITEMMESSAGE = 438, - LANG_COMMAND_LISTOBJMESSAGE = 439, - LANG_COMMAND_INVALIDCREATUREID = 440, - LANG_COMMAND_LISTCREATUREMESSAGE = 441, - LANG_COMMAND_NOAREAFOUND = 442, - LANG_COMMAND_NOITEMSETFOUND = 443, - LANG_COMMAND_NOSKILLFOUND = 444, - LANG_COMMAND_NOSPELLFOUND = 445, - LANG_COMMAND_NOQUESTFOUND = 446, - LANG_COMMAND_NOCREATUREFOUND = 447, - LANG_COMMAND_NOGAMEOBJECTFOUND = 448, - LANG_COMMAND_GRAVEYARDNOEXIST = 449, - LANG_COMMAND_GRAVEYARDALRLINKED = 450, - LANG_COMMAND_GRAVEYARDLINKED = 451, - LANG_COMMAND_GRAVEYARDWRONGZONE = 452, - LANG_COMMAND_GRAVEYARDWRONGTEAM = 453, - LANG_COMMAND_GRAVEYARDERROR = 454, - LANG_COMMAND_GRAVEYARD_NOTEAM = 455, - LANG_COMMAND_GRAVEYARD_ANY = 456, - LANG_COMMAND_GRAVEYARD_ALLIANCE = 457, - LANG_COMMAND_GRAVEYARD_HORDE = 458, - LANG_COMMAND_GRAVEYARDNEAREST = 459, - LANG_COMMAND_ZONENOGRAVEYARDS = 460, - LANG_COMMAND_ZONENOGRAFACTION = 461, - LANG_COMMAND_TP_ALREADYEXIST = 462, - LANG_COMMAND_TP_ADDED = 463, - LANG_COMMAND_TP_ADDEDERR = 464, - LANG_COMMAND_TP_DELETED = 465, - LANG_COMMAND_TP_DELETEERR = 466, - - LANG_COMMAND_TARGET_LISTAURAS = 467, - LANG_COMMAND_TARGET_AURADETAIL = 468, - LANG_COMMAND_TARGET_LISTAURATYPE = 469, - LANG_COMMAND_TARGET_AURASIMPLE = 470, - - LANG_COMMAND_QUEST_NOTFOUND = 471, - LANG_COMMAND_QUEST_STARTFROMITEM = 472, - LANG_COMMAND_QUEST_REMOVED = 473, - LANG_COMMAND_QUEST_REWARDED = 474, - LANG_COMMAND_QUEST_COMPLETE = 475, - LANG_COMMAND_QUEST_ACTIVE = 476, - - LANG_COMMAND_FLYMODE_STATUS = 477, - - LANG_COMMAND_OPCODESENT = 478, - - LANG_COMMAND_IMPORT_SUCCESS = 479, - LANG_COMMAND_IMPORT_FAILED = 480, - LANG_COMMAND_EXPORT_SUCCESS = 481, - LANG_COMMAND_EXPORT_FAILED = 482, - - LANG_COMMAND_SPELL_BROKEN = 483, - - LANG_SET_SKILL = 484, - LANG_SET_SKILL_ERROR = 485, - - LANG_INVALID_SKILL_ID = 486, - LANG_LEARNING_GM_SKILLS = 487, - LANG_YOU_KNOWN_SPELL = 488, - LANG_TARGET_KNOWN_SPELL = 489, - LANG_UNKNOWN_SPELL = 490, - LANG_FORGET_SPELL = 491, - LANG_REMOVEALL_COOLDOWN = 492, - LANG_REMOVE_COOLDOWN = 493, - - LANG_ADDITEM = 494, //log - LANG_ADDITEMSET = 495, //log - LANG_REMOVEITEM = 496, - LANG_ITEM_CANNOT_CREATE = 497, - LANG_INSERT_GUILD_NAME = 498, - LANG_PLAYER_NOT_FOUND = 499, - LANG_PLAYER_IN_GUILD = 500, - LANG_GUILD_NOT_CREATED = 501, - LANG_NO_ITEMS_FROM_ITEMSET_FOUND = 502, - - LANG_DISTANCE = 503, - - LANG_ITEM_SLOT = 504, - LANG_ITEM_SLOT_NOT_EXIST = 505, - LANG_ITEM_ADDED_TO_SLOT = 506, - LANG_ITEM_SAVE_FAILED = 507, - LANG_ITEMLIST_SLOT = 508, - LANG_ITEMLIST_MAIL = 509, - LANG_ITEMLIST_AUCTION = 510, - - LANG_WRONG_LINK_TYPE = 511, - LANG_ITEM_LIST = 512, - LANG_QUEST_LIST = 513, - LANG_CREATURE_ENTRY_LIST = 514, - LANG_CREATURE_LIST = 515, - LANG_GO_ENTRY_LIST = 516, - LANG_GO_LIST = 517, - LANG_ITEMSET_LIST = 518, - LANG_TELE_LIST = 519, - LANG_SPELL_LIST = 520, - LANG_SKILL_LIST = 521, - - LANG_GAMEOBJECT_NOT_EXIST = 522, - - LANG_GAMEOBJECT_CURRENT = 523, //log - LANG_GAMEOBJECT_DETAIL = 524, - LANG_GAMEOBJECT_ADD = 525, - - LANG_MOVEGENS_LIST = 526, - LANG_MOVEGENS_IDLE = 527, - LANG_MOVEGENS_RANDOM = 528, - LANG_MOVEGENS_WAYPOINT = 529, - LANG_MOVEGENS_ANIMAL_RANDOM = 530, - LANG_MOVEGENS_CONFUSED = 531, - LANG_MOVEGENS_TARGETED_PLAYER = 532, - LANG_MOVEGENS_TARGETED_CREATURE = 533, - LANG_MOVEGENS_TARGETED_NULL = 534, - LANG_MOVEGENS_HOME_CREATURE = 535, - LANG_MOVEGENS_HOME_PLAYER = 536, - LANG_MOVEGENS_FLIGHT = 537, - LANG_MOVEGENS_UNKNOWN = 538, - - LANG_NPCINFO_CHAR = 539, - LANG_NPCINFO_LEVEL = 540, - LANG_NPCINFO_HEALTH = 541, - LANG_NPCINFO_FLAGS = 542, - LANG_NPCINFO_LOOT = 543, - LANG_NPCINFO_POSITION = 544, - LANG_NPCINFO_VENDOR = 545, - LANG_NPCINFO_TRAINER = 546, - LANG_NPCINFO_DUNGEON_ID = 547, - - LANG_PINFO_ACCOUNT = 548, - LANG_PINFO_LEVEL = 549, - LANG_PINFO_NO_REP = 550, - - LANG_YOU_SET_EXPLORE_ALL = 551, - LANG_YOU_SET_EXPLORE_NOTHING = 552, - LANG_YOURS_EXPLORE_SET_ALL = 553, - LANG_YOURS_EXPLORE_SET_NOTHING = 554, - - LANG_HOVER_ENABLED = 555, - LANG_HOVER_DISABLED = 556, - LANG_YOURS_LEVEL_UP = 557, - LANG_YOURS_LEVEL_DOWN = 558, - LANG_YOURS_LEVEL_PROGRESS_RESET = 559, - LANG_EXPLORE_AREA = 560, - LANG_UNEXPLORE_AREA = 561, - - LANG_UPDATE = 562, - LANG_UPDATE_CHANGE = 563, - LANG_TOO_BIG_INDEX = 564, - LANG_SET_UINT = 565, //log - LANG_SET_UINT_FIELD = 566, - LANG_SET_FLOAT = 567, //log - LANG_SET_FLOAT_FIELD = 568, - LANG_GET_UINT = 569, //log - LANG_GET_UINT_FIELD = 570, - LANG_GET_FLOAT = 571, //log - LANG_GET_FLOAT_FIELD = 572, - LANG_SET_32BIT = 573, //log - LANG_SET_32BIT_FIELD = 574, - LANG_CHANGE_32BIT = 575, //log - LANG_CHANGE_32BIT_FIELD = 576, - - LANG_INVISIBLE_INVISIBLE = 577, - LANG_INVISIBLE_VISIBLE = 578, - LANG_SELECTED_TARGET_NOT_HAVE_VICTIM = 579, - - LANG_COMMAND_LEARN_ALL_DEFAULT_AND_QUEST = 580, - LANG_COMMAND_NEAROBJMESSAGE = 581, - LANG_COMMAND_RAWPAWNTIMES = 582, - - LANG_EVENT_ENTRY_LIST = 583, - LANG_NOEVENTFOUND = 584, - LANG_EVENT_NOT_EXIST = 585, - LANG_EVENT_INFO = 586, - LANG_EVENT_ALREADY_ACTIVE = 587, - LANG_EVENT_NOT_ACTIVE = 588, - - LANG_MOVEGENS_POINT = 589, - LANG_MOVEGENS_FEAR = 590, - LANG_MOVEGENS_DISTRACT = 591, - - LANG_COMMAND_LEARN_ALL_RECIPES = 592, - - // Battleground - LANG_BG_A_WINS = 600, - LANG_BG_H_WINS = 601, - LANG_BG_WS_ONE_MINUTE = 602, - LANG_BG_WS_HALF_MINUTE = 603, - LANG_BG_WS_BEGIN = 604, - - LANG_BG_WS_CAPTURED_HF = 605, - LANG_BG_WS_CAPTURED_AF = 606, - LANG_BG_WS_DROPPED_HF = 607, - LANG_BG_WS_DROPPED_AF = 608, - LANG_BG_WS_RETURNED_AF = 609, - LANG_BG_WS_RETURNED_HF = 610, - LANG_BG_WS_PICKEDUP_HF = 611, - LANG_BG_WS_PICKEDUP_AF = 612, - LANG_BG_WS_F_PLACED = 613, - LANG_BG_WS_ALLIANCE_FLAG_RESPAWNED = 614, - LANG_BG_WS_HORDE_FLAG_RESPAWNED = 615, - - LANG_BG_EY_ONE_MINUTE = 636, - LANG_BG_EY_HALF_MINUTE = 637, - LANG_BG_EY_BEGIN = 638, - - LANG_BG_AB_ALLY = 650, - LANG_BG_AB_HORDE = 651, - LANG_BG_AB_NODE_STABLES = 652, - LANG_BG_AB_NODE_BLACKSMITH = 653, - LANG_BG_AB_NODE_FARM = 654, - LANG_BG_AB_NODE_LUMBER_MILL = 655, - LANG_BG_AB_NODE_GOLD_MINE = 656, - LANG_BG_AB_NODE_TAKEN = 657, - LANG_BG_AB_NODE_DEFENDED = 658, - LANG_BG_AB_NODE_ASSAULTED = 659, - LANG_BG_AB_NODE_CLAIMED = 660, - LANG_BG_AB_ONEMINTOSTART = 661, - LANG_BG_AB_HALFMINTOSTART = 662, - LANG_BG_AB_STARTED = 663, - LANG_BG_AB_A_NEAR_VICTORY = 664, - LANG_BG_AB_H_NEAR_VICTORY = 665, - LANG_BG_MARK_BY_MAIL = 666, - - LANG_BG_EY_HAS_TAKEN_A_M_TOWER = 667, - LANG_BG_EY_HAS_TAKEN_H_M_TOWER = 668, - LANG_BG_EY_HAS_TAKEN_A_D_RUINS = 669, - LANG_BG_EY_HAS_TAKEN_H_D_RUINS = 670, - LANG_BG_EY_HAS_TAKEN_A_B_TOWER = 671, - LANG_BG_EY_HAS_TAKEN_H_B_TOWER = 672, - LANG_BG_EY_HAS_TAKEN_A_F_RUINS = 673, - LANG_BG_EY_HAS_TAKEN_H_F_RUINS = 674, - LANG_BG_EY_HAS_LOST_A_M_TOWER = 675, - LANG_BG_EY_HAS_LOST_H_M_TOWER = 676, - LANG_BG_EY_HAS_LOST_A_D_RUINS = 677, - LANG_BG_EY_HAS_LOST_H_D_RUINS = 678, - LANG_BG_EY_HAS_LOST_A_B_TOWER = 679, - LANG_BG_EY_HAS_LOST_H_B_TOWER = 680, - LANG_BG_EY_HAS_LOST_A_F_RUINS = 681, - LANG_BG_EY_HAS_LOST_H_F_RUINS = 682, - LANG_BG_EY_HAS_TAKEN_FLAG = 683, - LANG_BG_EY_CAPTURED_FLAG_A = 684, - LANG_BG_EY_CAPTURED_FLAG_H = 685, - LANG_BG_EY_DROPPED_FLAG = 686, - LANG_BG_EY_RESETED_FLAG = 687, - - LANG_ARENA_ONE_TOOLOW = 700, - LANG_ARENA_ONE_MINUTE = 701, - LANG_ARENA_THIRTY_SECONDS = 702, - LANG_ARENA_FIFTEEN_SECONDS = 703, - LANG_ARENA_BEGUN = 704, - - LANG_WAIT_BEFORE_SPEAKING = 705, - LANG_NOT_EQUIPPED_ITEM = 706, - LANG_PLAYER_DND = 707, - LANG_PLAYER_AFK = 708, - LANG_PLAYER_DND_DEFAULT = 709, - LANG_PLAYER_AFK_DEFAULT = 710, - - LANG_BG_QUEUE_ANNOUNCE_SELF = 711, - LANG_BG_QUEUE_ANNOUNCE_WORLD = 712, -}; -#endif - -/* NOT USED VALUES -// alliance ranks -#define LANG_ALI_PRIVATE "Private " -#define LANG_ALI_CORPORAL "Corporal " -#define LANG_ALI_SERGEANT "Sergeant " -#define LANG_ALI_MASTER_SERGEANT "Master Sergeant " -#define LANG_ALI_SERGEANT_MAJOR "Sergeant Major " -#define LANG_ALI_KNIGHT "Knight " -#define LANG_ALI_KNIGHT_LIEUTENANT "Knight-Lieutenant " -#define LANG_ALI_KNIGHT_CAPTAIN "Knight-Captain " -#define LANG_ALI_KNIGHT_CHAMPION "Knight-Champion " -#define LANG_ALI_LIEUTENANT_COMMANDER "Lieutenant Commander " -#define LANG_ALI_COMMANDER "Commander " -#define LANG_ALI_MARSHAL "Marshal " -#define LANG_ALI_FIELD_MARSHAL "Field Marshal " -#define LANG_ALI_GRAND_MARSHAL "Grand Marshal " -#define LANG_ALI_GAME_MASTER "Game Master " - -// horde ranks -#define LANG_HRD_SCOUT "Scout " -#define LANG_HRD_GRUNT "Grunt " -#define LANG_HRD_SERGEANT "Sergeant " -#define LANG_HRD_SENIOR_SERGEANT "Senior Sergeant " -#define LANG_HRD_FIRST_SERGEANT "First Sergeant " -#define LANG_HRD_STONE_GUARD "Stone Guard " -#define LANG_HRD_BLOOD_GUARD "Blood Guard " -#define LANG_HRD_LEGIONNARE "Legionnaire " -#define LANG_HRD_CENTURION "Centurion " -#define LANG_HRD_CHAMPION "Champion " -#define LANG_HRD_LIEUTENANT_GENERAL "Lieutenant General " -#define LANG_HRD_GENERAL "General " -#define LANG_HRD_WARLORD "Warlord " -#define LANG_HRD_HIGH_WARLORD "High Warlord " -#define LANG_HRD_GAME_MASTER "Game Master " - -#define LANG_NO_RANK "No rank " -#define LANG_RANK "%s (Rank %u)" -#define LANG_HONOR_TODAY "Today: [Honorable kills: |c0000ff00%u|r] [Dishonorable kills: |c00ff0000%u|r]" -#define LANG_HONOR_YESTERDAY "Yesterday: [Kills: |c0000ff00%u|r] [Honor: %u]" -#define LANG_HONOR_THIS_WEEK "This week: [Kills: |c0000ff00%u|r] [Honor: %u]" -#define LANG_HONOR_LAST_WEEK "Last week: [Kills: |c0000ff00%u|r] [Honor: %u] [Standing: %u]" -#define LANG_HONOR_LIFE "Lifetime: [Honorable kills: |c0000ff00%u|r] [Dishonorable kills: |c00ff0000%u|r] [Highest rank %u: %s]" - -// level 2 -#define LANG_ADD_OBJ "AddObject at Chat.cpp" //log -#define LANG_DEMORPHED "Demorphed %s" //log - -// level 3 -#define LANG_SPAWNING_SPIRIT_HEAL "Spawning spirit healers\n" -#define LANG_NO_SPIRIT_HEAL_DB "No spirit healers in database, exiting." - -#define LANG_ADD_OBJ_LV3 "AddObject at Level3.cpp line 1176" - -*/ +/* + * Copyright (C) 2005-2008 MaNGOS + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef __MANGOS_LANGUAGE_H +#define __MANGOS_LANGUAGE_H + +enum MangosStrings +{ + // for chat commands + LANG_SELECT_CHAR_OR_CREATURE = 1, + LANG_SELECT_CREATURE = 2, + + // level 0 chat + LANG_SYSTEMMESSAGE = 3, + LANG_EVENTMESSAGE = 4, + LANG_NO_HELP_CMD = 5, + LANG_NO_CMD = 6, + LANG_NO_SUBCMD = 7, + LANG_SUBCMDS_LIST = 8, + LANG_AVIABLE_CMD = 9, + LANG_CMD_SYNTAX = 10, + LANG_ACCOUNT_LEVEL = 11, + LANG_CONNECTED_USERS = 12, + LANG_UPTIME = 13, + LANG_PLAYER_SAVED = 14, + LANG_PLAYERS_SAVED = 15, + LANG_GMS_ON_SRV = 16, + LANG_GMS_NOT_LOGGED = 17, + LANG_YOU_IN_FLIGHT = 18, + //LANG_YOU_IN_BATTLEGROUND = 19, not used + //LANG_TARGET_IN_FLIGHT = 20, not used + LANG_CHAR_IN_FLIGHT = 21, + LANG_CHAR_NON_MOUNTED = 22, + LANG_YOU_IN_COMBAT = 23, + LANG_YOU_USED_IT_RECENTLY = 24, + LANG_COMMAND_NOTCHANGEPASSWORD = 25, + LANG_COMMAND_PASSWORD = 26, + LANG_COMMAND_WRONGOLDPASSWORD = 27, + LANG_COMMAND_ACCLOCKLOCKED = 28, + LANG_COMMAND_ACCLOCKUNLOCKED = 29, + LANG_SPELL_RANK = 30, + LANG_KNOWN = 31, + LANG_LEARN = 32, + LANG_PASSIVE = 33, + LANG_TALENT = 34, + LANG_ACTIVE = 35, + LANG_COMPLETE = 36, + LANG_OFFLINE = 37, + LANG_ON = 38, + LANG_OFF = 39, + LANG_YOU_ARE = 40, + LANG_VISIBLE = 41, + LANG_INVISIBLE = 42, + LANG_DONE = 43, + LANG_YOU = 44, + LANG_UNKNOWN = 45, + LANG_ERROR = 46, + LANG_NON_EXIST_CHARACTER = 47, + LANG_FRIEND_IGNORE_UNKNOWN = 48, + LANG_LEVEL_MINREQUIRED = 49, + LANG_LEVEL_MINREQUIRED_AND_ITEM = 50, + LANG_NPC_TAINER_HELLO = 51, + // Room for more level 0 + + // level 1 chat + LANG_GLOBAL_NOTIFY = 100, + LANG_MAP_POSITION = 101, + LANG_IS_TELEPORTED = 102, + LANG_CANNOT_SUMMON_TO_INST = 103, + LANG_CANNOT_GO_TO_INST_PARTY = 104, + LANG_CANNOT_GO_TO_INST_GM = 105, + LANG_CANNOT_GO_INST_INST = 106, + LANG_CANNOT_SUMMON_INST_INST = 107, + + LANG_SUMMONING = 108, + LANG_SUMMONED_BY = 109, + LANG_TELEPORTING_TO = 110, + LANG_TELEPORTED_TO_BY = 111, + LANG_NO_PLAYER = 112, + LANG_APPEARING_AT = 113, + LANG_APPEARING_TO = 114, + + LANG_BAD_VALUE = 115, + LANG_NO_CHAR_SELECTED = 116, + LANG_NOT_IN_GROUP = 117, + + LANG_YOU_CHANGE_HP = 118, + LANG_YOURS_HP_CHANGED = 119, + LANG_YOU_CHANGE_MANA = 120, + LANG_YOURS_MANA_CHANGED = 121, + LANG_YOU_CHANGE_ENERGY = 122, + LANG_YOURS_ENERGY_CHANGED = 123, + + LANG_CURRENT_ENERGY = 124, //log + LANG_YOU_CHANGE_RAGE = 125, + LANG_YOURS_RAGE_CHANGED = 126, + LANG_YOU_CHANGE_LVL = 127, + LANG_CURRENT_FACTION = 128, + LANG_WRONG_FACTION = 129, + LANG_YOU_CHANGE_FACTION = 130, + LANG_YOU_CHANGE_SPELLFLATID = 131, + LANG_YOURS_SPELLFLATID_CHANGED = 132, + LANG_YOU_GIVE_TAXIS = 133, + LANG_YOU_REMOVE_TAXIS = 134, + LANG_YOURS_TAXIS_ADDED = 135, + LANG_YOURS_TAXIS_REMOVED = 136, + + LANG_YOU_CHANGE_ASPEED = 137, + LANG_YOURS_ASPEED_CHANGED = 138, + LANG_YOU_CHANGE_SPEED = 139, + LANG_YOURS_SPEED_CHANGED = 140, + LANG_YOU_CHANGE_SWIM_SPEED = 141, + LANG_YOURS_SWIM_SPEED_CHANGED = 142, + LANG_YOU_CHANGE_BACK_SPEED = 143, + LANG_YOURS_BACK_SPEED_CHANGED = 144, + LANG_YOU_CHANGE_FLY_SPEED = 145, + LANG_YOURS_FLY_SPEED_CHANGED = 146, + + LANG_YOU_CHANGE_SIZE = 147, + LANG_YOURS_SIZE_CHANGED = 148, + LANG_NO_MOUNT = 149, + LANG_YOU_GIVE_MOUNT = 150, + LANG_MOUNT_GIVED = 151, + + LANG_CURRENT_MONEY = 152, + LANG_YOU_TAKE_ALL_MONEY = 153, + LANG_YOURS_ALL_MONEY_GONE = 154, + LANG_YOU_TAKE_MONEY = 155, + LANG_YOURS_MONEY_TAKEN = 156, + LANG_YOU_GIVE_MONEY = 157, + LANG_YOURS_MONEY_GIVEN = 158, + LANG_YOU_HEAR_SOUND = 159, + + LANG_NEW_MONEY = 160, // Log + + LANG_REMOVE_BIT = 161, + LANG_SET_BIT = 162, + LANG_COMMAND_TELE_TABLEEMPTY = 163, + LANG_COMMAND_TELE_NOTFOUND = 164, + LANG_COMMAND_TELE_PARAMETER = 165, + LANG_COMMAND_TELE_NOLOCATION = 166, + // 167 // not used + LANG_COMMAND_TELE_LOCATION = 168, + + LANG_MAIL_SENT = 169, + LANG_SOUND_NOT_EXIST = 170, + // Room for more level 1 + + // level 2 chat + LANG_NO_SELECTION = 200, + LANG_OBJECT_GUID = 201, + LANG_TOO_LONG_NAME = 202, + LANG_CHARS_ONLY = 203, + LANG_TOO_LONG_SUBNAME = 204, + LANG_NOT_IMPLEMENTED = 205, + + LANG_ITEM_ADDED_TO_LIST = 206, + LANG_ITEM_NOT_FOUND = 207, + LANG_ITEM_DELETED_FROM_LIST = 208, + LANG_ITEM_NOT_IN_LIST = 209, + LANG_ITEM_ALREADY_IN_LIST = 210, + + LANG_RESET_SPELLS_ONLINE = 211, + LANG_RESET_SPELLS_OFFLINE = 212, + LANG_RESET_TALENTS_ONLINE = 213, + LANG_RESET_TALENTS_OFFLINE = 214, + LANG_RESET_SPELLS = 215, + LANG_RESET_TALENTS = 216, + + LANG_RESETALL_UNKNOWN_CASE = 217, + LANG_RESETALL_SPELLS = 218, + LANG_RESETALL_TALENTS = 219, + + LANG_WAYPOINT_NOTFOUND = 220, + LANG_WAYPOINT_NOTFOUNDLAST = 221, + LANG_WAYPOINT_NOTFOUNDSEARCH = 222, + LANG_WAYPOINT_NOTFOUNDDBPROBLEM = 223, + LANG_WAYPOINT_CREATSELECTED = 224, + LANG_WAYPOINT_CREATNOTFOUND = 225, + LANG_WAYPOINT_VP_SELECT = 226, + LANG_WAYPOINT_VP_NOTFOUND = 227, + LANG_WAYPOINT_VP_NOTCREATED = 228, + LANG_WAYPOINT_VP_ALLREMOVED = 229, + LANG_WAYPOINT_NOTCREATED = 230, + LANG_WAYPOINT_NOGUID = 231, + LANG_WAYPOINT_NOWAYPOINTGIVEN = 232, + LANG_WAYPOINT_ARGUMENTREQ = 233, + LANG_WAYPOINT_ADDED = 234, + LANG_WAYPOINT_ADDED_NO = 235, + LANG_WAYPOINT_CHANGED = 236, + LANG_WAYPOINT_CHANGED_NO = 237, + LANG_WAYPOINT_EXPORTED = 238, + LANG_WAYPOINT_NOTHINGTOEXPORT = 239, + LANG_WAYPOINT_IMPORTED = 240, + LANG_WAYPOINT_REMOVED = 241, + LANG_WAYPOINT_NOTREMOVED = 242, + LANG_WAYPOINT_TOOFAR1 = 243, + LANG_WAYPOINT_TOOFAR2 = 244, + LANG_WAYPOINT_TOOFAR3 = 245, + LANG_WAYPOINT_INFO_TITLE = 246, + LANG_WAYPOINT_INFO_WAITTIME = 247, + LANG_WAYPOINT_INFO_MODEL = 248, + LANG_WAYPOINT_INFO_EMOTE = 249, + LANG_WAYPOINT_INFO_SPELL = 250, + LANG_WAYPOINT_INFO_TEXT = 251, + LANG_WAYPOINT_INFO_AISCRIPT = 252, + + LANG_RENAME_PLAYER = 253, + LANG_RENAME_PLAYER_GUID = 254, + + LANG_WAYPOINT_WPCREATNOTFOUND = 255, + LANG_WAYPOINT_NPCNOTFOUND = 256, + + LANG_MOVE_TYPE_SET = 257, + LANG_MOVE_TYPE_SET_NODEL = 258, + LANG_USE_BOL = 259, + LANG_VALUE_SAVED = 260, + LANG_VALUE_SAVED_REJOIN = 261, + + LANG_COMMAND_GOAREATRNOTFOUND = 262, + LANG_INVALID_TARGET_COORD = 263, + LANG_INVALID_ZONE_COORD = 264, + LANG_INVALID_ZONE_MAP = 265, + LANG_COMMAND_TARGETOBJNOTFOUND = 266, + LANG_COMMAND_GOOBJNOTFOUND = 267, + LANG_COMMAND_GOCREATNOTFOUND = 268, + LANG_COMMAND_GOCREATMULTIPLE = 269, + LANG_COMMAND_DELCREATMESSAGE = 270, + LANG_COMMAND_CREATUREMOVED = 271, + LANG_COMMAND_CREATUREATSAMEMAP = 272, + LANG_COMMAND_OBJNOTFOUND = 273, + LANG_COMMAND_DELOBJREFERCREATURE = 274, + LANG_COMMAND_DELOBJMESSAGE = 275, + LANG_COMMAND_TURNOBJMESSAGE = 276, + LANG_COMMAND_MOVEOBJMESSAGE = 277, + LANG_COMMAND_VENDORSELECTION = 278, + LANG_COMMAND_NEEDITEMSEND = 279, + LANG_COMMAND_ADDVENDORITEMITEMS = 280, + LANG_COMMAND_KICKSELF = 281, + LANG_COMMAND_KICKMESSAGE = 282, + LANG_COMMAND_KICKNOTFOUNDPLAYER = 283, + LANG_COMMAND_WHISPERACCEPTING = 284, + LANG_COMMAND_WHISPERON = 285, + LANG_COMMAND_WHISPEROFF = 286, + LANG_COMMAND_CREATGUIDNOTFOUND = 287, + LANG_COMMAND_TICKETCOUNT = 288, + LANG_COMMAND_TICKETNEW = 289, + LANG_COMMAND_TICKETVIEW = 290, + LANG_COMMAND_TICKETON = 291, + LANG_COMMAND_TICKETOFF = 292, + LANG_COMMAND_TICKENOTEXIST = 293, + LANG_COMMAND_ALLTICKETDELETED = 294, + LANG_COMMAND_TICKETPLAYERDEL = 295, + LANG_COMMAND_TICKETDEL = 296, + LANG_COMMAND_SPAWNDIST = 297, + LANG_COMMAND_SPAWNTIME = 298, + LANG_COMMAND_MODIFY_HONOR = 299, + + LANG_YOUR_CHAT_DISABLED = 300, + LANG_YOU_DISABLE_CHAT = 301, + LANG_CHAT_ALREADY_ENABLED = 302, + LANG_YOUR_CHAT_ENABLED = 303, + LANG_YOU_ENABLE_CHAT = 304, + + LANG_COMMAND_MODIFY_REP = 305, + LANG_COMMAND_MODIFY_ARENA = 306, + LANG_COMMAND_FACTION_NOTFOUND = 307, + LANG_COMMAND_FACTION_UNKNOWN = 308, + LANG_COMMAND_FACTION_INVPARAM = 309, + LANG_COMMAND_FACTION_DELTA = 310, + LANG_FACTION_LIST = 311, + LANG_FACTION_VISIBLE = 312, + LANG_FACTION_ATWAR = 313, + LANG_FACTION_PEACE_FORCED = 314, + LANG_FACTION_HIDDEN = 315, + LANG_FACTION_INVISIBLE_FORCED = 316, + LANG_FACTION_INACTIVE = 317, + LANG_REP_HATED = 318, + LANG_REP_HOSTILE = 319, + LANG_REP_UNFRIENDLY = 320, + LANG_REP_NEUTRAL = 321, + LANG_REP_FRIENDLY = 322, + LANG_REP_HONORED = 323, + LANG_REP_REVERED = 324, + LANG_REP_EXALTED = 325, + LANG_COMMAND_FACTION_NOREP_ERROR = 326, + LANG_FACTION_NOREPUTATION = 327, + LANG_LOOKUP_PLAYER_ACCOUNT = 328, + LANG_LOOKUP_PLAYER_CHARACTER = 329, + LANG_NO_PLAYERS_FOUND = 330, + + // Room for more level 2 + + // level 3 chat + LANG_SCRIPTS_RELOADED = 400, + LANG_YOU_CHANGE_SECURITY = 401, + LANG_YOURS_SECURITY_CHANGED = 402, + LANG_YOURS_SECURITY_IS_LOW = 403, + LANG_CREATURE_MOVE_DISABLED = 404, + LANG_CREATURE_MOVE_ENABLED = 405, + LANG_NO_WEATHER = 406, + LANG_WEATHER_DISABLED = 407, + + LANG_BAN_YOUBANNED = 408, + LANG_BAN_YOUPERMBANNED = 409, + LANG_BAN_NOTFOUND = 410, + + LANG_UNBAN_UNBANNED = 411, + LANG_UNBAN_ERROR = 412, + + LANG_BANINFO_NOACCOUNT = 413, + LANG_BANINFO_NOCHARACTER = 414, + LANG_BANINFO_NOIP = 415, + LANG_BANINFO_NOACCOUNTBAN = 416, + LANG_BANINFO_BANHISTORY = 417, + LANG_BANINFO_HISTORYENTRY = 418, + LANG_BANINFO_INFINITE = 419, + LANG_BANINFO_NEVER = 420, + LANG_BANINFO_YES = 421, + LANG_BANINFO_NO = 422, + LANG_BANINFO_IPENTRY = 423, + + LANG_BANLIST_NOIP = 424, + LANG_BANLIST_NOACCOUNT = 425, + LANG_BANLIST_NOCHARACTER = 426, + LANG_BANLIST_MATCHINGIP = 427, + LANG_BANLIST_MATCHINGACCOUNT = 428, + + LANG_COMMAND_LEARN_MANY_SPELLS = 429, + LANG_COMMAND_LEARN_CLASS_SPELLS = 430, + LANG_COMMAND_LEARN_CLASS_TALENTS = 431, + LANG_COMMAND_LEARN_ALL_LANG = 432, + LANG_COMMAND_LEARN_ALL_CRAFT = 433, + LANG_COMMAND_COULDNOTFIND = 434, + LANG_COMMAND_ITEMIDINVALID = 435, + LANG_COMMAND_NOITEMFOUND = 436, + LANG_COMMAND_LISTOBJINVALIDID = 437, + LANG_COMMAND_LISTITEMMESSAGE = 438, + LANG_COMMAND_LISTOBJMESSAGE = 439, + LANG_COMMAND_INVALIDCREATUREID = 440, + LANG_COMMAND_LISTCREATUREMESSAGE = 441, + LANG_COMMAND_NOAREAFOUND = 442, + LANG_COMMAND_NOITEMSETFOUND = 443, + LANG_COMMAND_NOSKILLFOUND = 444, + LANG_COMMAND_NOSPELLFOUND = 445, + LANG_COMMAND_NOQUESTFOUND = 446, + LANG_COMMAND_NOCREATUREFOUND = 447, + LANG_COMMAND_NOGAMEOBJECTFOUND = 448, + LANG_COMMAND_GRAVEYARDNOEXIST = 449, + LANG_COMMAND_GRAVEYARDALRLINKED = 450, + LANG_COMMAND_GRAVEYARDLINKED = 451, + LANG_COMMAND_GRAVEYARDWRONGZONE = 452, + LANG_COMMAND_GRAVEYARDWRONGTEAM = 453, + LANG_COMMAND_GRAVEYARDERROR = 454, + LANG_COMMAND_GRAVEYARD_NOTEAM = 455, + LANG_COMMAND_GRAVEYARD_ANY = 456, + LANG_COMMAND_GRAVEYARD_ALLIANCE = 457, + LANG_COMMAND_GRAVEYARD_HORDE = 458, + LANG_COMMAND_GRAVEYARDNEAREST = 459, + LANG_COMMAND_ZONENOGRAVEYARDS = 460, + LANG_COMMAND_ZONENOGRAFACTION = 461, + LANG_COMMAND_TP_ALREADYEXIST = 462, + LANG_COMMAND_TP_ADDED = 463, + LANG_COMMAND_TP_ADDEDERR = 464, + LANG_COMMAND_TP_DELETED = 465, + // 466, // not used + + LANG_COMMAND_TARGET_LISTAURAS = 467, + LANG_COMMAND_TARGET_AURADETAIL = 468, + LANG_COMMAND_TARGET_LISTAURATYPE = 469, + LANG_COMMAND_TARGET_AURASIMPLE = 470, + + LANG_COMMAND_QUEST_NOTFOUND = 471, + LANG_COMMAND_QUEST_STARTFROMITEM = 472, + LANG_COMMAND_QUEST_REMOVED = 473, + LANG_COMMAND_QUEST_REWARDED = 474, + LANG_COMMAND_QUEST_COMPLETE = 475, + LANG_COMMAND_QUEST_ACTIVE = 476, + + LANG_COMMAND_FLYMODE_STATUS = 477, + + LANG_COMMAND_OPCODESENT = 478, + + LANG_COMMAND_IMPORT_SUCCESS = 479, + LANG_COMMAND_IMPORT_FAILED = 480, + LANG_COMMAND_EXPORT_SUCCESS = 481, + LANG_COMMAND_EXPORT_FAILED = 482, + + LANG_COMMAND_SPELL_BROKEN = 483, + + LANG_SET_SKILL = 484, + LANG_SET_SKILL_ERROR = 485, + + LANG_INVALID_SKILL_ID = 486, + LANG_LEARNING_GM_SKILLS = 487, + LANG_YOU_KNOWN_SPELL = 488, + LANG_TARGET_KNOWN_SPELL = 489, + LANG_UNKNOWN_SPELL = 490, + LANG_FORGET_SPELL = 491, + LANG_REMOVEALL_COOLDOWN = 492, + LANG_REMOVE_COOLDOWN = 493, + + LANG_ADDITEM = 494, //log + LANG_ADDITEMSET = 495, //log + LANG_REMOVEITEM = 496, + LANG_ITEM_CANNOT_CREATE = 497, + LANG_INSERT_GUILD_NAME = 498, + LANG_PLAYER_NOT_FOUND = 499, + LANG_PLAYER_IN_GUILD = 500, + LANG_GUILD_NOT_CREATED = 501, + LANG_NO_ITEMS_FROM_ITEMSET_FOUND = 502, + + LANG_DISTANCE = 503, + + LANG_ITEM_SLOT = 504, + LANG_ITEM_SLOT_NOT_EXIST = 505, + LANG_ITEM_ADDED_TO_SLOT = 506, + LANG_ITEM_SAVE_FAILED = 507, + LANG_ITEMLIST_SLOT = 508, + LANG_ITEMLIST_MAIL = 509, + LANG_ITEMLIST_AUCTION = 510, + + LANG_WRONG_LINK_TYPE = 511, + LANG_ITEM_LIST = 512, + LANG_QUEST_LIST = 513, + LANG_CREATURE_ENTRY_LIST = 514, + LANG_CREATURE_LIST = 515, + LANG_GO_ENTRY_LIST = 516, + LANG_GO_LIST = 517, + LANG_ITEMSET_LIST = 518, + LANG_TELE_LIST = 519, + LANG_SPELL_LIST = 520, + LANG_SKILL_LIST = 521, + + LANG_GAMEOBJECT_NOT_EXIST = 522, + + LANG_GAMEOBJECT_CURRENT = 523, //log + LANG_GAMEOBJECT_DETAIL = 524, + LANG_GAMEOBJECT_ADD = 525, + + LANG_MOVEGENS_LIST = 526, + LANG_MOVEGENS_IDLE = 527, + LANG_MOVEGENS_RANDOM = 528, + LANG_MOVEGENS_WAYPOINT = 529, + LANG_MOVEGENS_ANIMAL_RANDOM = 530, + LANG_MOVEGENS_CONFUSED = 531, + LANG_MOVEGENS_TARGETED_PLAYER = 532, + LANG_MOVEGENS_TARGETED_CREATURE = 533, + LANG_MOVEGENS_TARGETED_NULL = 534, + LANG_MOVEGENS_HOME_CREATURE = 535, + LANG_MOVEGENS_HOME_PLAYER = 536, + LANG_MOVEGENS_FLIGHT = 537, + LANG_MOVEGENS_UNKNOWN = 538, + + LANG_NPCINFO_CHAR = 539, + LANG_NPCINFO_LEVEL = 540, + LANG_NPCINFO_HEALTH = 541, + LANG_NPCINFO_FLAGS = 542, + LANG_NPCINFO_LOOT = 543, + LANG_NPCINFO_POSITION = 544, + LANG_NPCINFO_VENDOR = 545, + LANG_NPCINFO_TRAINER = 546, + LANG_NPCINFO_DUNGEON_ID = 547, + + LANG_PINFO_ACCOUNT = 548, + LANG_PINFO_LEVEL = 549, + LANG_PINFO_NO_REP = 550, + + LANG_YOU_SET_EXPLORE_ALL = 551, + LANG_YOU_SET_EXPLORE_NOTHING = 552, + LANG_YOURS_EXPLORE_SET_ALL = 553, + LANG_YOURS_EXPLORE_SET_NOTHING = 554, + + LANG_HOVER_ENABLED = 555, + LANG_HOVER_DISABLED = 556, + LANG_YOURS_LEVEL_UP = 557, + LANG_YOURS_LEVEL_DOWN = 558, + LANG_YOURS_LEVEL_PROGRESS_RESET = 559, + LANG_EXPLORE_AREA = 560, + LANG_UNEXPLORE_AREA = 561, + + LANG_UPDATE = 562, + LANG_UPDATE_CHANGE = 563, + LANG_TOO_BIG_INDEX = 564, + LANG_SET_UINT = 565, //log + LANG_SET_UINT_FIELD = 566, + LANG_SET_FLOAT = 567, //log + LANG_SET_FLOAT_FIELD = 568, + LANG_GET_UINT = 569, //log + LANG_GET_UINT_FIELD = 570, + LANG_GET_FLOAT = 571, //log + LANG_GET_FLOAT_FIELD = 572, + LANG_SET_32BIT = 573, //log + LANG_SET_32BIT_FIELD = 574, + LANG_CHANGE_32BIT = 575, //log + LANG_CHANGE_32BIT_FIELD = 576, + + LANG_INVISIBLE_INVISIBLE = 577, + LANG_INVISIBLE_VISIBLE = 578, + LANG_SELECTED_TARGET_NOT_HAVE_VICTIM = 579, + + LANG_COMMAND_LEARN_ALL_DEFAULT_AND_QUEST = 580, + LANG_COMMAND_NEAROBJMESSAGE = 581, + LANG_COMMAND_RAWPAWNTIMES = 582, + + LANG_EVENT_ENTRY_LIST = 583, + LANG_NOEVENTFOUND = 584, + LANG_EVENT_NOT_EXIST = 585, + LANG_EVENT_INFO = 586, + LANG_EVENT_ALREADY_ACTIVE = 587, + LANG_EVENT_NOT_ACTIVE = 588, + + LANG_MOVEGENS_POINT = 589, + LANG_MOVEGENS_FEAR = 590, + LANG_MOVEGENS_DISTRACT = 591, + + LANG_COMMAND_LEARN_ALL_RECIPES = 592, + + // Battleground + LANG_BG_A_WINS = 600, + LANG_BG_H_WINS = 601, + LANG_BG_WS_ONE_MINUTE = 602, + LANG_BG_WS_HALF_MINUTE = 603, + LANG_BG_WS_BEGIN = 604, + + LANG_BG_WS_CAPTURED_HF = 605, + LANG_BG_WS_CAPTURED_AF = 606, + LANG_BG_WS_DROPPED_HF = 607, + LANG_BG_WS_DROPPED_AF = 608, + LANG_BG_WS_RETURNED_AF = 609, + LANG_BG_WS_RETURNED_HF = 610, + LANG_BG_WS_PICKEDUP_HF = 611, + LANG_BG_WS_PICKEDUP_AF = 612, + LANG_BG_WS_F_PLACED = 613, + LANG_BG_WS_ALLIANCE_FLAG_RESPAWNED = 614, + LANG_BG_WS_HORDE_FLAG_RESPAWNED = 615, + + LANG_BG_EY_ONE_MINUTE = 636, + LANG_BG_EY_HALF_MINUTE = 637, + LANG_BG_EY_BEGIN = 638, + + LANG_BG_AB_ALLY = 650, + LANG_BG_AB_HORDE = 651, + LANG_BG_AB_NODE_STABLES = 652, + LANG_BG_AB_NODE_BLACKSMITH = 653, + LANG_BG_AB_NODE_FARM = 654, + LANG_BG_AB_NODE_LUMBER_MILL = 655, + LANG_BG_AB_NODE_GOLD_MINE = 656, + LANG_BG_AB_NODE_TAKEN = 657, + LANG_BG_AB_NODE_DEFENDED = 658, + LANG_BG_AB_NODE_ASSAULTED = 659, + LANG_BG_AB_NODE_CLAIMED = 660, + LANG_BG_AB_ONEMINTOSTART = 661, + LANG_BG_AB_HALFMINTOSTART = 662, + LANG_BG_AB_STARTED = 663, + LANG_BG_AB_A_NEAR_VICTORY = 664, + LANG_BG_AB_H_NEAR_VICTORY = 665, + LANG_BG_MARK_BY_MAIL = 666, + + LANG_BG_EY_HAS_TAKEN_A_M_TOWER = 667, + LANG_BG_EY_HAS_TAKEN_H_M_TOWER = 668, + LANG_BG_EY_HAS_TAKEN_A_D_RUINS = 669, + LANG_BG_EY_HAS_TAKEN_H_D_RUINS = 670, + LANG_BG_EY_HAS_TAKEN_A_B_TOWER = 671, + LANG_BG_EY_HAS_TAKEN_H_B_TOWER = 672, + LANG_BG_EY_HAS_TAKEN_A_F_RUINS = 673, + LANG_BG_EY_HAS_TAKEN_H_F_RUINS = 674, + LANG_BG_EY_HAS_LOST_A_M_TOWER = 675, + LANG_BG_EY_HAS_LOST_H_M_TOWER = 676, + LANG_BG_EY_HAS_LOST_A_D_RUINS = 677, + LANG_BG_EY_HAS_LOST_H_D_RUINS = 678, + LANG_BG_EY_HAS_LOST_A_B_TOWER = 679, + LANG_BG_EY_HAS_LOST_H_B_TOWER = 680, + LANG_BG_EY_HAS_LOST_A_F_RUINS = 681, + LANG_BG_EY_HAS_LOST_H_F_RUINS = 682, + LANG_BG_EY_HAS_TAKEN_FLAG = 683, + LANG_BG_EY_CAPTURED_FLAG_A = 684, + LANG_BG_EY_CAPTURED_FLAG_H = 685, + LANG_BG_EY_DROPPED_FLAG = 686, + LANG_BG_EY_RESETED_FLAG = 687, + + LANG_ARENA_ONE_TOOLOW = 700, + LANG_ARENA_ONE_MINUTE = 701, + LANG_ARENA_THIRTY_SECONDS = 702, + LANG_ARENA_FIFTEEN_SECONDS = 703, + LANG_ARENA_BEGUN = 704, + + LANG_WAIT_BEFORE_SPEAKING = 705, + LANG_NOT_EQUIPPED_ITEM = 706, + LANG_PLAYER_DND = 707, + LANG_PLAYER_AFK = 708, + LANG_PLAYER_DND_DEFAULT = 709, + LANG_PLAYER_AFK_DEFAULT = 710, + + LANG_BG_QUEUE_ANNOUNCE_SELF = 711, + LANG_BG_QUEUE_ANNOUNCE_WORLD = 712, +}; +#endif + +/* NOT USED VALUES +// alliance ranks +#define LANG_ALI_PRIVATE "Private " +#define LANG_ALI_CORPORAL "Corporal " +#define LANG_ALI_SERGEANT "Sergeant " +#define LANG_ALI_MASTER_SERGEANT "Master Sergeant " +#define LANG_ALI_SERGEANT_MAJOR "Sergeant Major " +#define LANG_ALI_KNIGHT "Knight " +#define LANG_ALI_KNIGHT_LIEUTENANT "Knight-Lieutenant " +#define LANG_ALI_KNIGHT_CAPTAIN "Knight-Captain " +#define LANG_ALI_KNIGHT_CHAMPION "Knight-Champion " +#define LANG_ALI_LIEUTENANT_COMMANDER "Lieutenant Commander " +#define LANG_ALI_COMMANDER "Commander " +#define LANG_ALI_MARSHAL "Marshal " +#define LANG_ALI_FIELD_MARSHAL "Field Marshal " +#define LANG_ALI_GRAND_MARSHAL "Grand Marshal " +#define LANG_ALI_GAME_MASTER "Game Master " + +// horde ranks +#define LANG_HRD_SCOUT "Scout " +#define LANG_HRD_GRUNT "Grunt " +#define LANG_HRD_SERGEANT "Sergeant " +#define LANG_HRD_SENIOR_SERGEANT "Senior Sergeant " +#define LANG_HRD_FIRST_SERGEANT "First Sergeant " +#define LANG_HRD_STONE_GUARD "Stone Guard " +#define LANG_HRD_BLOOD_GUARD "Blood Guard " +#define LANG_HRD_LEGIONNARE "Legionnaire " +#define LANG_HRD_CENTURION "Centurion " +#define LANG_HRD_CHAMPION "Champion " +#define LANG_HRD_LIEUTENANT_GENERAL "Lieutenant General " +#define LANG_HRD_GENERAL "General " +#define LANG_HRD_WARLORD "Warlord " +#define LANG_HRD_HIGH_WARLORD "High Warlord " +#define LANG_HRD_GAME_MASTER "Game Master " + +#define LANG_NO_RANK "No rank " +#define LANG_RANK "%s (Rank %u)" +#define LANG_HONOR_TODAY "Today: [Honorable kills: |c0000ff00%u|r] [Dishonorable kills: |c00ff0000%u|r]" +#define LANG_HONOR_YESTERDAY "Yesterday: [Kills: |c0000ff00%u|r] [Honor: %u]" +#define LANG_HONOR_THIS_WEEK "This week: [Kills: |c0000ff00%u|r] [Honor: %u]" +#define LANG_HONOR_LAST_WEEK "Last week: [Kills: |c0000ff00%u|r] [Honor: %u] [Standing: %u]" +#define LANG_HONOR_LIFE "Lifetime: [Honorable kills: |c0000ff00%u|r] [Dishonorable kills: |c00ff0000%u|r] [Highest rank %u: %s]" + +// level 2 +#define LANG_ADD_OBJ "AddObject at Chat.cpp" //log +#define LANG_DEMORPHED "Demorphed %s" //log + +// level 3 +#define LANG_SPAWNING_SPIRIT_HEAL "Spawning spirit healers\n" +#define LANG_NO_SPIRIT_HEAL_DB "No spirit healers in database, exiting." + +#define LANG_ADD_OBJ_LV3 "AddObject at Level3.cpp line 1176" + +*/ diff --git a/src/game/Level1.cpp b/src/game/Level1.cpp index 21c1eec9f16..93e44cd9802 100644 --- a/src/game/Level1.cpp +++ b/src/game/Level1.cpp @@ -1,2351 +1,2291 @@ -/* - * Copyright (C) 2005-2008 MaNGOS - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "Common.h" -#include "Database/DatabaseEnv.h" -#include "WorldPacket.h" -#include "WorldSession.h" -#include "World.h" -#include "ObjectMgr.h" -#include "Player.h" -#include "Opcodes.h" -#include "Chat.h" -#include "Log.h" -#include "MapManager.h" -#include "ObjectAccessor.h" -#include "Language.h" -#include "CellImpl.h" -#include "InstanceSaveMgr.h" -#include "Util.h" -#ifdef _DEBUG_VMAPS -#include "VMapFactory.h" -#endif - -bool ChatHandler::HandleSayCommand(const char* args) -{ - if(!*args) - return false; - - Creature* pCreature = getSelectedCreature(); - if(!pCreature) - { - SendSysMessage(LANG_SELECT_CREATURE); - SetSentErrorMessage(true); - return false; - } - - pCreature->Say(args, LANG_UNIVERSAL, 0); - - return true; -} - -bool ChatHandler::HandleYellCommand(const char* args) -{ - if(!*args) - return false; - - Creature* pCreature = getSelectedCreature(); - if(!pCreature) - { - SendSysMessage(LANG_SELECT_CREATURE); - SetSentErrorMessage(true); - return false; - } - - pCreature->Yell(args, LANG_UNIVERSAL, 0); - - return true; -} - -//show text emote by creature in chat -bool ChatHandler::HandleTextEmoteCommand(const char* args) -{ - if(!*args) - return false; - - Creature* pCreature = getSelectedCreature(); - - if(!pCreature) - { - SendSysMessage(LANG_SELECT_CREATURE); - SetSentErrorMessage(true); - return false; - } - - pCreature->TextEmote(args, 0); - - return true; -} - -// make npc whisper to player -bool ChatHandler::HandleNpcWhisperCommand(const char* args) -{ - if(!*args) - return false; - - char* receiver_str = strtok((char*)args, " "); - char* text = strtok(NULL, ""); - - uint64 guid = m_session->GetPlayer()->GetSelection(); - Creature* pCreature = ObjectAccessor::GetCreature(*m_session->GetPlayer(), guid); - - if(!pCreature || !receiver_str || !text) - { - return false; - } - - uint64 receiver_guid= atol(receiver_str); - - pCreature->Whisper(text,receiver_guid); - - return true; -} - -// global announce -bool ChatHandler::HandleAnnounceCommand(const char* args) -{ - if(!*args) - return false; - - sWorld.SendWorldText(LANG_SYSTEMMESSAGE,args); - return true; -} - -//notification player at the screen -bool ChatHandler::HandleNotifyCommand(const char* args) -{ - if(!*args) - return false; - - std::string str = GetMangosString(LANG_GLOBAL_NOTIFY); - str += args; - - WorldPacket data(SMSG_NOTIFICATION, (str.size()+1)); - data << str; - sWorld.SendGlobalMessage(&data); - - return true; -} - -//Enable\Dissable GM Mode -bool ChatHandler::HandleGMmodeCommand(const char* args) -{ - if(!*args) - { - SendSysMessage(LANG_USE_BOL); - SetSentErrorMessage(true); - return false; - } - - std::string argstr = (char*)args; - - if (argstr == "on") - { - m_session->GetPlayer()->SetGameMaster(true); - m_session->SendNotification("GM mode is ON"); - #ifdef _DEBUG_VMAPS - VMAP::IVMapManager *vMapManager = VMAP::VMapFactory::createOrGetVMapManager(); - vMapManager->processCommand("stoplog"); - #endif - return true; - } - - if (argstr == "off") - { - m_session->GetPlayer()->SetGameMaster(false); - m_session->SendNotification("GM mode is OFF"); - #ifdef _DEBUG_VMAPS - VMAP::IVMapManager *vMapManager = VMAP::VMapFactory::createOrGetVMapManager(); - vMapManager->processCommand("startlog"); - #endif - return true; - } - - SendSysMessage(LANG_USE_BOL); - SetSentErrorMessage(true); - return false; -} - -//Enable\Dissable Invisible mode -bool ChatHandler::HandleVisibleCommand(const char* args) -{ - if (!*args) - { - PSendSysMessage(LANG_YOU_ARE, m_session->GetPlayer()->isGMVisible() ? GetMangosString(LANG_VISIBLE) : GetMangosString(LANG_INVISIBLE)); - return true; - } - - std::string argstr = (char*)args; - - if (argstr == "on") - { - m_session->GetPlayer()->SetGMVisible(true); - m_session->SendNotification(GetMangosString(LANG_INVISIBLE_VISIBLE)); - return true; - } - - if (argstr == "off") - { - m_session->SendNotification(GetMangosString(LANG_INVISIBLE_INVISIBLE)); - m_session->GetPlayer()->SetGMVisible(false); - return true; - } - - SendSysMessage(LANG_USE_BOL); - SetSentErrorMessage(true); - return false; -} - -bool ChatHandler::HandleGPSCommand(const char* args) -{ - WorldObject *obj = NULL; - if (*args) - { - std::string name = args; - if(normalizePlayerName(name)) - obj = objmgr.GetPlayer(name.c_str()); - - if(!obj) - { - SendSysMessage(LANG_PLAYER_NOT_FOUND); - SetSentErrorMessage(true); - return false; - } - } - else - { - obj = getSelectedUnit(); - - if(!obj) - { - SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE); - SetSentErrorMessage(true); - return false; - } - } - CellPair cell_val = MaNGOS::ComputeCellPair(obj->GetPositionX(), obj->GetPositionY()); - Cell cell(cell_val); - - uint32 zone_id = obj->GetZoneId(); - uint32 area_id = obj->GetAreaId(); - - MapEntry const* mapEntry = sMapStore.LookupEntry(obj->GetMapId()); - AreaTableEntry const* zoneEntry = GetAreaEntryByAreaID(zone_id); - AreaTableEntry const* areaEntry = GetAreaEntryByAreaID(area_id); - - float zone_x = obj->GetPositionX(); - float zone_y = obj->GetPositionY(); - - Map2ZoneCoordinates(zone_x,zone_y,zone_id); - - Map const *map = MapManager::Instance().GetMap(obj->GetMapId(), obj); - float ground_z = map->GetHeight(obj->GetPositionX(), obj->GetPositionY(), MAX_HEIGHT); - float floor_z = map->GetHeight(obj->GetPositionX(), obj->GetPositionY(), obj->GetPositionZ()); - - GridPair p = MaNGOS::ComputeGridPair(obj->GetPositionX(), obj->GetPositionY()); - - int gx=63-p.x_coord; - int gy=63-p.y_coord; - - uint32 have_map = Map::ExistMap(obj->GetMapId(),gx,gy) ? 1 : 0; - uint32 have_vmap = Map::ExistVMap(obj->GetMapId(),gx,gy) ? 1 : 0; - - PSendSysMessage(LANG_MAP_POSITION, - obj->GetMapId(), (mapEntry ? mapEntry->name[m_session->GetSessionDbcLocale()] : "" ), - zone_id, (zoneEntry ? zoneEntry->area_name[m_session->GetSessionDbcLocale()] : "" ), - area_id, (areaEntry ? areaEntry->area_name[m_session->GetSessionDbcLocale()] : "" ), - obj->GetPositionX(), obj->GetPositionY(), obj->GetPositionZ(), obj->GetOrientation(), - cell.GridX(), cell.GridY(), cell.CellX(), cell.CellY(), obj->GetInstanceId(), - zone_x, zone_y, ground_z, floor_z, have_map, have_vmap ); - - sLog.outDebug("Player %s GPS call for %s '%s' (%s: %u):", - m_session->GetPlayer()->GetName(), - (obj->GetTypeId() == TYPEID_PLAYER ? "player" : "creature"), obj->GetName(), - (obj->GetTypeId() == TYPEID_PLAYER ? "GUID" : "Entry"), (obj->GetTypeId() == TYPEID_PLAYER ? obj->GetGUIDLow(): obj->GetEntry()) ); - sLog.outDebug(GetMangosString(LANG_MAP_POSITION), - obj->GetMapId(), (mapEntry ? mapEntry->name[sWorld.GetDefaultDbcLocale()] : "" ), - zone_id, (zoneEntry ? zoneEntry->area_name[sWorld.GetDefaultDbcLocale()] : "" ), - area_id, (areaEntry ? areaEntry->area_name[sWorld.GetDefaultDbcLocale()] : "" ), - obj->GetPositionX(), obj->GetPositionY(), obj->GetPositionZ(), obj->GetOrientation(), - cell.GridX(), cell.GridY(), cell.CellX(), cell.CellY(), obj->GetInstanceId(), - zone_x, zone_y, ground_z, floor_z, have_map, have_vmap ); - - return true; -} - -//Summon Player -bool ChatHandler::HandleNamegoCommand(const char* args) -{ - if(!*args) - return false; - - std::string name = args; - - if(!normalizePlayerName(name)) - { - SendSysMessage(LANG_PLAYER_NOT_FOUND); - SetSentErrorMessage(true); - return false; - } - - Player *chr = objmgr.GetPlayer(name.c_str()); - if (chr) - { - if(chr->IsBeingTeleported()==true) - { - PSendSysMessage(LANG_IS_TELEPORTED, chr->GetName()); - SetSentErrorMessage(true); - return false; - } - - Map* pMap = MapManager::Instance().GetMap(m_session->GetPlayer()->GetMapId(),m_session->GetPlayer()); - - if(pMap->Instanceable()) - { - Map* cMap = MapManager::Instance().GetMap(chr->GetMapId(),chr); - if( cMap->Instanceable() && cMap->GetInstanceId() != pMap->GetInstanceId() ) - { - // cannot summon from instance to instance - PSendSysMessage(LANG_CANNOT_SUMMON_TO_INST,chr->GetName()); - SetSentErrorMessage(true); - return false; - } - - // we are in instance, and can summon only player in our group with us as lead - if ( !m_session->GetPlayer()->GetGroup() || !chr->GetGroup() || - (chr->GetGroup()->GetLeaderGUID() != m_session->GetPlayer()->GetGUID()) || - (m_session->GetPlayer()->GetGroup()->GetLeaderGUID() != m_session->GetPlayer()->GetGUID()) ) - // the last check is a bit excessive, but let it be, just in case - { - PSendSysMessage(LANG_CANNOT_SUMMON_TO_INST,chr->GetName()); - SetSentErrorMessage(true); - return false; - } - } - - PSendSysMessage(LANG_SUMMONING, chr->GetName(),""); - - if (m_session->GetPlayer()->IsVisibleGloballyFor(chr)) - ChatHandler(chr).PSendSysMessage(LANG_SUMMONED_BY, m_session->GetPlayer()->GetName()); - - // stop flight if need - if(chr->isInFlight()) - { - chr->GetMotionMaster()->MovementExpired(); - chr->m_taxi.ClearTaxiDestinations(); - } - // save only in non-flight case - else - chr->SaveRecallPosition(); - - // before GM - float x,y,z; - m_session->GetPlayer()->GetClosePoint(x,y,z,chr->GetObjectSize()); - chr->TeleportTo(m_session->GetPlayer()->GetMapId(),x,y,z,chr->GetOrientation()); - } - else if (uint64 guid = objmgr.GetPlayerGUIDByName(name)) - { - PSendSysMessage(LANG_SUMMONING, name.c_str(),GetMangosString(LANG_OFFLINE)); - - // in point where GM stay - Player::SavePositionInDB(m_session->GetPlayer()->GetMapId(), - m_session->GetPlayer()->GetPositionX(), - m_session->GetPlayer()->GetPositionY(), - m_session->GetPlayer()->GetPositionZ(), - m_session->GetPlayer()->GetOrientation(), - m_session->GetPlayer()->GetZoneId(), - guid); - } - else - { - PSendSysMessage(LANG_NO_PLAYER, args); - SetSentErrorMessage(true); - } - - return true; -} - -//Teleport to Player -bool ChatHandler::HandleGonameCommand(const char* args) -{ - if(!*args) - return false; - - Player* _player = m_session->GetPlayer(); - - std::string name = args; - - if(!normalizePlayerName(name)) - { - SendSysMessage(LANG_PLAYER_NOT_FOUND); - SetSentErrorMessage(true); - return false; - } - - Player *chr = objmgr.GetPlayer(name.c_str()); - if (chr) - { - Map* cMap = MapManager::Instance().GetMap(chr->GetMapId(),chr); - if(cMap->Instanceable()) - { - Map* pMap = MapManager::Instance().GetMap(_player->GetMapId(),_player); - - // we have to go to instance, and can go to player only if: - // 1) we are in his group (either as leader or as member) - // 2) we are not bound to any group and have GM mode on - if (_player->GetGroup()) - { - // we are in group, we can go only if we are in the player group - if (_player->GetGroup() != chr->GetGroup()) - { - PSendSysMessage(LANG_CANNOT_GO_TO_INST_PARTY,chr->GetName()); - SetSentErrorMessage(true); - return false; - } - } - else - { - // we are not in group, let's verify our GM mode - if (!_player->isGameMaster()) - { - PSendSysMessage(LANG_CANNOT_GO_TO_INST_GM,chr->GetName()); - SetSentErrorMessage(true); - return false; - } - } - - // if the player or the player's group is bound to another instance - // the player will not be bound to another one - InstancePlayerBind *pBind = _player->GetBoundInstance(chr->GetMapId(), chr->GetDifficulty()); - if(!pBind) - { - Group *group = _player->GetGroup(); - InstanceGroupBind *gBind = group ? group->GetBoundInstance(chr->GetMapId(), chr->GetDifficulty()) : NULL; - if(!gBind) - { - // if no bind exists, create a solo bind - InstanceSave *save = sInstanceSaveManager.GetInstanceSave(chr->GetInstanceId()); - if(save) _player->BindToInstance(save, !save->CanReset()); - } - } - - _player->SetDifficulty(chr->GetDifficulty()); - } - - PSendSysMessage(LANG_APPEARING_AT, chr->GetName()); - - if (_player->IsVisibleGloballyFor(chr)) - ChatHandler(chr).PSendSysMessage(LANG_APPEARING_TO, _player->GetName()); - - // stop flight if need - if(_player->isInFlight()) - { - _player->GetMotionMaster()->MovementExpired(); - _player->m_taxi.ClearTaxiDestinations(); - } - // save only in non-flight case - else - _player->SaveRecallPosition(); - - // to point to see at target with same orientation - float x,y,z; - chr->GetContactPoint(m_session->GetPlayer(),x,y,z); - - _player->TeleportTo(chr->GetMapId(), x, y, z, _player->GetAngle( chr ), TELE_TO_GM_MODE); - - return true; - } - - if (uint64 guid = objmgr.GetPlayerGUIDByName(name)) - { - PSendSysMessage(LANG_APPEARING_AT, name.c_str()); - - // to point where player stay (if loaded) - float x,y,z,o; - uint32 map; - bool in_flight; - if(Player::LoadPositionFromDB(map,x,y,z,o,in_flight,guid)) - { - // stop flight if need - if(_player->isInFlight()) - { - _player->GetMotionMaster()->MovementExpired(); - _player->m_taxi.ClearTaxiDestinations(); - } - // save only in non-flight case - else - _player->SaveRecallPosition(); - - _player->TeleportTo(map, x, y, z,_player->GetOrientation()); - return true; - } - } - - PSendSysMessage(LANG_NO_PLAYER, args); - - SetSentErrorMessage(true); - return false; -} - -// Teleport player to last position -bool ChatHandler::HandleRecallCommand(const char* args) -{ - Player* chr = NULL; - - if(!*args) - { - chr = getSelectedPlayer(); - if(!chr) - chr = m_session->GetPlayer(); - } - else - { - std::string name = args; - - if(!normalizePlayerName(name)) - { - SendSysMessage(LANG_PLAYER_NOT_FOUND); - SetSentErrorMessage(true); - return false; - } - - chr = objmgr.GetPlayer(name.c_str()); - - if(!chr) - { - PSendSysMessage(LANG_NO_PLAYER, args); - SetSentErrorMessage(true); - return false; - } - } - - if(chr->IsBeingTeleported()) - { - PSendSysMessage(LANG_IS_TELEPORTED, chr->GetName()); - SetSentErrorMessage(true); - return false; - } - - // stop flight if need - if(chr->isInFlight()) - { - chr->GetMotionMaster()->MovementExpired(); - chr->m_taxi.ClearTaxiDestinations(); - } - - chr->TeleportTo(chr->m_recallMap, chr->m_recallX, chr->m_recallY, chr->m_recallZ, chr->m_recallO); - return true; -} - -//Edit Player KnownTitles -bool ChatHandler::HandleModifyKnownTitlesCommand(const char* args) -{ - if(!*args) - return false; - - uint64 titles = 0; - - sscanf((char*)args, I64FMTD, &titles); - - Player *chr = getSelectedPlayer(); - if (!chr) - { - SendSysMessage(LANG_NO_CHAR_SELECTED); - SetSentErrorMessage(true); - return false; - } - - uint64 titles2 = titles; - - for(int i=1; i < sCharTitlesStore.GetNumRows(); ++i) - if(CharTitlesEntry const* tEntry = sCharTitlesStore.LookupEntry(i)) - titles2 &= ~(uint64(1) << tEntry->bit_index); - - titles &= ~titles2; // remove not existed titles - - chr->SetUInt64Value(PLAYER__FIELD_KNOWN_TITLES, titles); - SendSysMessage(LANG_DONE); - - return true; -} - -//Edit Player HP -bool ChatHandler::HandleModifyHPCommand(const char* args) -{ - if(!*args) - return false; - - // char* pHp = strtok((char*)args, " "); - // if (!pHp) - // return false; - - // char* pHpMax = strtok(NULL, " "); - // if (!pHpMax) - // return false; - - // int32 hpm = atoi(pHpMax); - // int32 hp = atoi(pHp); - - int32 hp = atoi((char*)args); - int32 hpm = atoi((char*)args); - - if (hp <= 0 || hpm <= 0 || hpm < hp) - { - SendSysMessage(LANG_BAD_VALUE); - SetSentErrorMessage(true); - return false; - } - - Player *chr = getSelectedPlayer(); - if (chr == NULL) - { - SendSysMessage(LANG_NO_CHAR_SELECTED); - SetSentErrorMessage(true); - return false; - } - - PSendSysMessage(LANG_YOU_CHANGE_HP, chr->GetName(), hp, hpm); - ChatHandler(chr).PSendSysMessage(LANG_YOURS_HP_CHANGED, m_session->GetPlayer()->GetName(), hp, hpm); - - chr->SetMaxHealth( hpm ); - chr->SetHealth( hp ); - - return true; -} - -//Edit Player Mana -bool ChatHandler::HandleModifyManaCommand(const char* args) -{ - if(!*args) - return false; - - // char* pmana = strtok((char*)args, " "); - // if (!pmana) - // return false; - - // char* pmanaMax = strtok(NULL, " "); - // if (!pmanaMax) - // return false; - - // int32 manam = atoi(pmanaMax); - // int32 mana = atoi(pmana); - int32 mana = atoi((char*)args); - int32 manam = atoi((char*)args); - - if (mana <= 0 || manam <= 0 || manam < mana) - { - SendSysMessage(LANG_BAD_VALUE); - SetSentErrorMessage(true); - return false; - } - - Player *chr = getSelectedPlayer(); - if (chr == NULL) - { - SendSysMessage(LANG_NO_CHAR_SELECTED); - SetSentErrorMessage(true); - return false; - } - - PSendSysMessage(LANG_YOU_CHANGE_MANA, chr->GetName(), mana, manam); - ChatHandler(chr).PSendSysMessage(LANG_YOURS_MANA_CHANGED, m_session->GetPlayer()->GetName(), mana, manam); - - chr->SetMaxPower(POWER_MANA,manam ); - chr->SetPower(POWER_MANA, mana ); - - return true; -} - -//Edit Player Energy -bool ChatHandler::HandleModifyEnergyCommand(const char* args) -{ - if(!*args) - return false; - - // char* pmana = strtok((char*)args, " "); - // if (!pmana) - // return false; - - // char* pmanaMax = strtok(NULL, " "); - // if (!pmanaMax) - // return false; - - // int32 manam = atoi(pmanaMax); - // int32 mana = atoi(pmana); - - int32 energy = atoi((char*)args)*10; - int32 energym = atoi((char*)args)*10; - - if (energy <= 0 || energym <= 0 || energym < energy) - { - SendSysMessage(LANG_BAD_VALUE); - SetSentErrorMessage(true); - return false; - } - - Player *chr = getSelectedPlayer(); - if (!chr) - { - SendSysMessage(LANG_NO_CHAR_SELECTED); - SetSentErrorMessage(true); - return false; - } - - PSendSysMessage(LANG_YOU_CHANGE_ENERGY, chr->GetName(), energy/10, energym/10); - ChatHandler(chr).PSendSysMessage(LANG_YOURS_ENERGY_CHANGED, m_session->GetPlayer()->GetName(), energy/10, energym/10); - - chr->SetMaxPower(POWER_ENERGY,energym ); - chr->SetPower(POWER_ENERGY, energy ); - - sLog.outDetail(GetMangosString(LANG_CURRENT_ENERGY),chr->GetMaxPower(POWER_ENERGY)); - - return true; -} - -//Edit Player Rage -bool ChatHandler::HandleModifyRageCommand(const char* args) -{ - if(!*args) - return false; - - // char* pmana = strtok((char*)args, " "); - // if (!pmana) - // return false; - - // char* pmanaMax = strtok(NULL, " "); - // if (!pmanaMax) - // return false; - - // int32 manam = atoi(pmanaMax); - // int32 mana = atoi(pmana); - - int32 rage = atoi((char*)args)*10; - int32 ragem = atoi((char*)args)*10; - - if (rage <= 0 || ragem <= 0 || ragem < rage) - { - SendSysMessage(LANG_BAD_VALUE); - SetSentErrorMessage(true); - return false; - } - - Player *chr = getSelectedPlayer(); - if (chr == NULL) - { - SendSysMessage(LANG_NO_CHAR_SELECTED); - SetSentErrorMessage(true); - return false; - } - - PSendSysMessage(LANG_YOU_CHANGE_RAGE, chr->GetName(), rage/10, ragem/10); - // Special case: I use GetMangosString here to get local of destination char ;) - ChatHandler(chr).PSendSysMessage(ChatHandler(chr).GetMangosString(LANG_YOURS_RAGE_CHANGED), m_session->GetPlayer()->GetName(), rage/10, ragem/10); - - chr->SetMaxPower(POWER_RAGE,ragem ); - chr->SetPower(POWER_RAGE, rage ); - - return true; -} - -//Edit Player Faction -bool ChatHandler::HandleModifyFactionCommand(const char* args) -{ - if(!*args) - return false; - - char* pfactionid = extractKeyFromLink((char*)args,"Hfaction"); - - Creature* chr = getSelectedCreature(); - if(!chr) - { - SendSysMessage(LANG_SELECT_CREATURE); - SetSentErrorMessage(true); - return false; - } - - if(!pfactionid) - { - if(chr) - { - uint32 factionid = chr->getFaction(); - uint32 flag = chr->GetUInt32Value(UNIT_FIELD_FLAGS); - uint32 npcflag = chr->GetUInt32Value(UNIT_NPC_FLAGS); - uint32 dyflag = chr->GetUInt32Value(UNIT_DYNAMIC_FLAGS); - PSendSysMessage(LANG_CURRENT_FACTION,chr->GetGUIDLow(),factionid,flag,npcflag,dyflag); - } - return true; - } - - if( !chr ) - { - SendSysMessage(LANG_NO_CHAR_SELECTED); - SetSentErrorMessage(true); - return false; - } - - uint32 factionid = atoi(pfactionid); - uint32 flag; - - char *pflag = strtok(NULL, " "); - if (!pflag) - flag = chr->GetUInt32Value(UNIT_FIELD_FLAGS); - else - flag = atoi(pflag); - - char* pnpcflag = strtok(NULL, " "); - - uint32 npcflag; - if(!pnpcflag) - npcflag = chr->GetUInt32Value(UNIT_NPC_FLAGS); - else - npcflag = atoi(pnpcflag); - - char* pdyflag = strtok(NULL, " "); - - uint32 dyflag; - if(!pdyflag) - dyflag = chr->GetUInt32Value(UNIT_DYNAMIC_FLAGS); - else - dyflag = atoi(pdyflag); - - if(!sFactionTemplateStore.LookupEntry(factionid)) - { - PSendSysMessage(LANG_WRONG_FACTION, factionid); - SetSentErrorMessage(true); - return false; - } - - PSendSysMessage(LANG_YOU_CHANGE_FACTION, chr->GetGUIDLow(),factionid,flag,npcflag,dyflag); - - //sprintf((char*)buf,"%s changed your Faction to %i.", m_session->GetPlayer()->GetName(), factionid); - //FillSystemMessageData(&data, m_session, buf); - - //chr->GetSession()->SendPacket(&data); - - chr->setFaction(factionid); - chr->SetUInt32Value(UNIT_FIELD_FLAGS,flag); - chr->SetUInt32Value(UNIT_NPC_FLAGS,npcflag); - chr->SetUInt32Value(UNIT_DYNAMIC_FLAGS,dyflag); - - return true; -} - -//Edit Player Spell -bool ChatHandler::HandleModifySpellCommand(const char* args) -{ - if(!*args) return false; - char* pspellflatid = strtok((char*)args, " "); - if (!pspellflatid) - return false; - - char* pop = strtok(NULL, " "); - if (!pop) - return false; - - char* pval = strtok(NULL, " "); - if (!pval) - return false; - - uint16 mark; - - char* pmark = strtok(NULL, " "); - - uint8 spellflatid = atoi(pspellflatid); - uint8 op = atoi(pop); - uint16 val = atoi(pval); - if(!pmark) - mark = 65535; - else - mark = atoi(pmark); - - Player *chr = getSelectedPlayer(); - if (chr == NULL) - { - SendSysMessage(LANG_NO_CHAR_SELECTED); - SetSentErrorMessage(true); - return false; - } - - PSendSysMessage(LANG_YOU_CHANGE_SPELLFLATID, spellflatid, val, mark, chr->GetName()); - if(chr != m_session->GetPlayer()) - ChatHandler(chr).PSendSysMessage(LANG_YOURS_SPELLFLATID_CHANGED, m_session->GetPlayer()->GetName(), spellflatid, val, mark); - - WorldPacket data(SMSG_SET_FLAT_SPELL_MODIFIER, (1+1+2+2)); - data << uint8(spellflatid); - data << uint8(op); - data << uint16(val); - data << uint16(mark); - chr->GetSession()->SendPacket(&data); - - return true; -} - -//Edit Player TP -bool ChatHandler::HandleModifyTalentCommand (const char* args) -{ - if (!*args) - return false; - - int tp = atoi((char*)args); - if (tp>0) - { - Player* player = getSelectedPlayer(); - if(!player) - { - SendSysMessage(LANG_NO_CHAR_SELECTED); - SetSentErrorMessage(true); - return false; - } - player->SetFreeTalentPoints(tp); - return true; - } - return false; -} - -//Enable On\OFF all taxi paths -bool ChatHandler::HandleTaxiCheatCommand(const char* args) -{ - if (!*args) - { - SendSysMessage(LANG_USE_BOL); - SetSentErrorMessage(true); - return false; - } - - std::string argstr = (char*)args; - - Player *chr = getSelectedPlayer(); - if (!chr) - { - chr=m_session->GetPlayer(); - } - - if (argstr == "on") - { - chr->SetTaxiCheater(true); - PSendSysMessage(LANG_YOU_GIVE_TAXIS, chr->GetName()); - - if(chr != m_session->GetPlayer()) - // to send localized data to target - ChatHandler(chr).PSendSysMessage(ChatHandler(chr).GetMangosString(LANG_YOURS_TAXIS_ADDED), m_session->GetPlayer()->GetName()); - return true; - } - - if (argstr == "off") - { - chr->SetTaxiCheater(false); - PSendSysMessage(LANG_YOU_REMOVE_TAXIS, chr->GetName()); - - if(chr != m_session->GetPlayer()) - ChatHandler(chr).PSendSysMessage(ChatHandler(chr).GetMangosString(LANG_YOURS_TAXIS_REMOVED), m_session->GetPlayer()->GetName()); - - return true; - } - - SendSysMessage(LANG_USE_BOL); - SetSentErrorMessage(true); - return false; -} - -//Edit Player Aspeed -bool ChatHandler::HandleModifyASpeedCommand(const char* args) -{ - if (!*args) - return false; - - float ASpeed = (float)atof((char*)args); - - if (ASpeed > 10 || ASpeed < 0.1) - { - SendSysMessage(LANG_BAD_VALUE); - SetSentErrorMessage(true); - return false; - } - - Player *chr = getSelectedPlayer(); - if (chr == NULL) - { - SendSysMessage(LANG_NO_CHAR_SELECTED); - SetSentErrorMessage(true); - return false; - } - - if(chr->isInFlight()) - { - PSendSysMessage(LANG_CHAR_IN_FLIGHT,chr->GetName()); - SetSentErrorMessage(true); - return false; - } - - PSendSysMessage(LANG_YOU_CHANGE_ASPEED, ASpeed, chr->GetName()); - - if(chr != m_session->GetPlayer()) - ChatHandler(chr).PSendSysMessage(ChatHandler(chr).GetMangosString(LANG_YOURS_ASPEED_CHANGED), m_session->GetPlayer()->GetName(), ASpeed); - - chr->SetSpeed(MOVE_WALK, ASpeed,true); - chr->SetSpeed(MOVE_RUN, ASpeed,true); - chr->SetSpeed(MOVE_SWIM, ASpeed,true); - //chr->SetSpeed(MOVE_TURN, ASpeed,true); - chr->SetSpeed(MOVE_FLY, ASpeed,true); - return true; -} - -//Edit Player Speed -bool ChatHandler::HandleModifySpeedCommand(const char* args) -{ - if (!*args) - return false; - - float Speed = (float)atof((char*)args); - - if (Speed > 10 || Speed < 0.1) - { - SendSysMessage(LANG_BAD_VALUE); - SetSentErrorMessage(true); - return false; - } - - Player *chr = getSelectedPlayer(); - if (chr == NULL) - { - SendSysMessage(LANG_NO_CHAR_SELECTED); - SetSentErrorMessage(true); - return false; - } - - if(chr->isInFlight()) - { - PSendSysMessage(LANG_CHAR_IN_FLIGHT,chr->GetName()); - SetSentErrorMessage(true); - return false; - } - - PSendSysMessage(LANG_YOU_CHANGE_SPEED, Speed, chr->GetName()); - - if(chr != m_session->GetPlayer()) - ChatHandler(chr).PSendSysMessage(ChatHandler(chr).GetMangosString(LANG_YOURS_SPEED_CHANGED), m_session->GetPlayer()->GetName(), Speed); - - chr->SetSpeed(MOVE_RUN,Speed,true); - - return true; -} - -//Edit Player Swim Speed -bool ChatHandler::HandleModifySwimCommand(const char* args) -{ - if (!*args) - return false; - - float Swim = (float)atof((char*)args); - - if (Swim > 10.0f || Swim < 0.01f) - { - SendSysMessage(LANG_BAD_VALUE); - SetSentErrorMessage(true); - return false; - } - - Player *chr = getSelectedPlayer(); - if (chr == NULL) - { - SendSysMessage(LANG_NO_CHAR_SELECTED); - SetSentErrorMessage(true); - return false; - } - - if(chr->isInFlight()) - { - PSendSysMessage(LANG_CHAR_IN_FLIGHT,chr->GetName()); - SetSentErrorMessage(true); - return false; - } - - PSendSysMessage(LANG_YOU_CHANGE_SWIM_SPEED, Swim, chr->GetName()); - - if(chr != m_session->GetPlayer()) - ChatHandler(chr).PSendSysMessage(ChatHandler(chr).GetMangosString(LANG_YOURS_SWIM_SPEED_CHANGED), m_session->GetPlayer()->GetName(), Swim); - - chr->SetSpeed(MOVE_SWIM,Swim,true); - - return true; -} - -//Edit Player Walk Speed -bool ChatHandler::HandleModifyBWalkCommand(const char* args) -{ - if (!*args) - return false; - - float BSpeed = (float)atof((char*)args); - - if (BSpeed > 10.0f || BSpeed < 0.1f) - { - SendSysMessage(LANG_BAD_VALUE); - SetSentErrorMessage(true); - return false; - } - - Player *chr = getSelectedPlayer(); - if (chr == NULL) - { - SendSysMessage(LANG_NO_CHAR_SELECTED); - SetSentErrorMessage(true); - return false; - } - - if(chr->isInFlight()) - { - PSendSysMessage(LANG_CHAR_IN_FLIGHT,chr->GetName()); - SetSentErrorMessage(true); - return false; - } - - PSendSysMessage(LANG_YOU_CHANGE_BACK_SPEED, BSpeed, chr->GetName()); - - if(chr != m_session->GetPlayer()) - ChatHandler(chr).PSendSysMessage(ChatHandler(chr).GetMangosString(LANG_YOURS_BACK_SPEED_CHANGED), m_session->GetPlayer()->GetName(), BSpeed); - - chr->SetSpeed(MOVE_WALKBACK,BSpeed,true); - - return true; -} - -//Edit Player Fly -bool ChatHandler::HandleModifyFlyCommand(const char* args) -{ - if (!*args) - return false; - - float FSpeed = (float)atof((char*)args); - - if (FSpeed > 10.0f || FSpeed < 0.1f) - { - SendSysMessage(LANG_BAD_VALUE); - SetSentErrorMessage(true); - return false; - } - - Player *chr = getSelectedPlayer(); - if (chr == NULL) - { - SendSysMessage(LANG_NO_CHAR_SELECTED); - SetSentErrorMessage(true); - return false; - } - - PSendSysMessage(LANG_YOU_CHANGE_FLY_SPEED, FSpeed, chr->GetName()); - - if(chr != m_session->GetPlayer()) - ChatHandler(chr).PSendSysMessage(ChatHandler(chr).GetMangosString(LANG_YOURS_FLY_SPEED_CHANGED), m_session->GetPlayer()->GetName(), FSpeed); - - chr->SetSpeed(MOVE_FLY,FSpeed,true); - - return true; -} - -//Edit Player Scale -bool ChatHandler::HandleModifyScaleCommand(const char* args) -{ - if (!*args) - return false; - - float Scale = (float)atof((char*)args); - if (Scale > 3.0f || Scale <= 0.0f) - { - SendSysMessage(LANG_BAD_VALUE); - SetSentErrorMessage(true); - return false; - } - - Player *chr = getSelectedPlayer(); - if (chr == NULL) - { - SendSysMessage(LANG_NO_CHAR_SELECTED); - SetSentErrorMessage(true); - return false; - } - - PSendSysMessage(LANG_YOU_CHANGE_SIZE, Scale, chr->GetName()); - - if(chr != m_session->GetPlayer()) - ChatHandler(chr).PSendSysMessage(ChatHandler(chr).GetMangosString(LANG_YOURS_SIZE_CHANGED), m_session->GetPlayer()->GetName(), Scale); - - chr->SetFloatValue(OBJECT_FIELD_SCALE_X, Scale); - - return true; -} - -//Enable Player mount -bool ChatHandler::HandleModifyMountCommand(const char* args) -{ - if(!*args) - return false; - - uint16 mId = 1147; - float speed = (float)15; - uint32 num = 0; - - num = atoi((char*)args); - switch(num) - { - case 1: - mId=14340; - break; - case 2: - mId=4806; - break; - case 3: - mId=6471; - break; - case 4: - mId=12345; - break; - case 5: - mId=6472; - break; - case 6: - mId=6473; - break; - case 7: - mId=10670; - break; - case 8: - mId=10719; - break; - case 9: - mId=10671; - break; - case 10: - mId=10672; - break; - case 11: - mId=10720; - break; - case 12: - mId=14349; - break; - case 13: - mId=11641; - break; - case 14: - mId=12244; - break; - case 15: - mId=12242; - break; - case 16: - mId=14578; - break; - case 17: - mId=14579; - break; - case 18: - mId=14349; - break; - case 19: - mId=12245; - break; - case 20: - mId=14335; - break; - case 21: - mId=207; - break; - case 22: - mId=2328; - break; - case 23: - mId=2327; - break; - case 24: - mId=2326; - break; - case 25: - mId=14573; - break; - case 26: - mId=14574; - break; - case 27: - mId=14575; - break; - case 28: - mId=604; - break; - case 29: - mId=1166; - break; - case 30: - mId=2402; - break; - case 31: - mId=2410; - break; - case 32: - mId=2409; - break; - case 33: - mId=2408; - break; - case 34: - mId=2405; - break; - case 35: - mId=14337; - break; - case 36: - mId=6569; - break; - case 37: - mId=10661; - break; - case 38: - mId=10666; - break; - case 39: - mId=9473; - break; - case 40: - mId=9476; - break; - case 41: - mId=9474; - break; - case 42: - mId=14374; - break; - case 43: - mId=14376; - break; - case 44: - mId=14377; - break; - case 45: - mId=2404; - break; - case 46: - mId=2784; - break; - case 47: - mId=2787; - break; - case 48: - mId=2785; - break; - case 49: - mId=2736; - break; - case 50: - mId=2786; - break; - case 51: - mId=14347; - break; - case 52: - mId=14346; - break; - case 53: - mId=14576; - break; - case 54: - mId=9695; - break; - case 55: - mId=9991; - break; - case 56: - mId=6448; - break; - case 57: - mId=6444; - break; - case 58: - mId=6080; - break; - case 59: - mId=6447; - break; - case 60: - mId=4805; - break; - case 61: - mId=9714; - break; - case 62: - mId=6448; - break; - case 63: - mId=6442; - break; - case 64: - mId=14632; - break; - case 65: - mId=14332; - break; - case 66: - mId=14331; - break; - case 67: - mId=8469; - break; - case 68: - mId=2830; - break; - case 69: - mId=2346; - break; - default: - SendSysMessage(LANG_NO_MOUNT); - SetSentErrorMessage(true); - return false; - } - - Player *chr = getSelectedPlayer(); - if (chr == NULL) - { - SendSysMessage(LANG_NO_CHAR_SELECTED); - SetSentErrorMessage(true); - return false; - } - - PSendSysMessage(LANG_YOU_GIVE_MOUNT, chr->GetName()); - - if(chr != m_session->GetPlayer()) - ChatHandler(chr).PSendSysMessage(ChatHandler(chr).GetMangosString(LANG_MOUNT_GIVED), m_session->GetPlayer()->GetName()); - - chr->SetUInt32Value( UNIT_FIELD_FLAGS , 0x001000 ); - chr->Mount(mId); - - WorldPacket data( SMSG_FORCE_RUN_SPEED_CHANGE, (8+4+1+4) ); - data.append(chr->GetPackGUID()); - data << (uint32)0; - data << (uint8)0; //new 2.1.0 - data << float(speed); - chr->SendMessageToSet( &data, true ); - - data.Initialize( SMSG_FORCE_SWIM_SPEED_CHANGE, (8+4+4) ); - data.append(chr->GetPackGUID()); - data << (uint32)0; - data << float(speed); - chr->SendMessageToSet( &data, true ); - - return true; -} - -//Edit Player money -bool ChatHandler::HandleModifyMoneyCommand(const char* args) -{ - if (!*args) - return false; - - Player *chr = getSelectedPlayer(); - if (chr == NULL) - { - SendSysMessage(LANG_NO_CHAR_SELECTED); - SetSentErrorMessage(true); - return false; - } - - int32 addmoney = atoi((char*)args); - - uint32 moneyuser = chr->GetMoney(); - - if(addmoney < 0) - { - int32 newmoney = moneyuser + addmoney; - - sLog.outDetail(GetMangosString(LANG_CURRENT_MONEY), moneyuser, addmoney, newmoney); - if(newmoney <= 0 ) - { - PSendSysMessage(LANG_YOU_TAKE_ALL_MONEY, chr->GetName()); - - if(chr != m_session->GetPlayer()) - ChatHandler(chr).PSendSysMessage(ChatHandler(chr).GetMangosString(LANG_YOURS_ALL_MONEY_GONE), m_session->GetPlayer()->GetName()); - - chr->SetMoney(0); - } - else - { - PSendSysMessage(LANG_YOU_TAKE_MONEY, abs(addmoney), chr->GetName()); - if(chr != m_session->GetPlayer()) - ChatHandler(chr).PSendSysMessage(ChatHandler(chr).GetMangosString(LANG_YOURS_MONEY_TAKEN), m_session->GetPlayer()->GetName(), abs(addmoney)); - chr->SetMoney( newmoney ); - } - } - else - { - PSendSysMessage(LANG_YOU_GIVE_MONEY, addmoney, chr->GetName()); - if(chr != m_session->GetPlayer()) - ChatHandler(chr).PSendSysMessage(ChatHandler(chr).GetMangosString(LANG_YOURS_MONEY_GIVEN), m_session->GetPlayer()->GetName(), addmoney); - chr->ModifyMoney( addmoney ); - } - - sLog.outDetail(GetMangosString(LANG_NEW_MONEY), moneyuser, addmoney, chr->GetMoney() ); - - return true; -} - -//Edit Player field -bool ChatHandler::HandleModifyBitCommand(const char* args) -{ - if( !*args ) - return false; - - Player *chr = getSelectedPlayer(); - if (chr == NULL) - { - SendSysMessage(LANG_NO_CHAR_SELECTED); - SetSentErrorMessage(true); - return false; - } - - char* pField = strtok((char*)args, " "); - if (!pField) - return false; - - char* pBit = strtok(NULL, " "); - if (!pBit) - return false; - - uint16 field = atoi(pField); - uint32 bit = atoi(pBit); - - if (field < 1 || field >= PLAYER_END) - { - SendSysMessage(LANG_BAD_VALUE); - SetSentErrorMessage(true); - return false; - } - - if (bit < 1 || bit > 32) - { - SendSysMessage(LANG_BAD_VALUE); - SetSentErrorMessage(true); - return false; - } - - if ( chr->HasFlag( field, (1<<(bit-1)) ) ) - { - chr->RemoveFlag( field, (1<<(bit-1)) ); - PSendSysMessage(LANG_REMOVE_BIT, bit, field); - } - else - { - chr->SetFlag( field, (1<<(bit-1)) ); - PSendSysMessage(LANG_SET_BIT, bit, field); - } - - return true; -} - -//Teleport by game_tele entry -bool ChatHandler::HandleModifyHonorCommand (const char* args) -{ - if (!*args) - return false; - - Player *target = getSelectedPlayer(); - if(!target) - { - SendSysMessage(LANG_PLAYER_NOT_FOUND); - SetSentErrorMessage(true); - return false; - } - - int32 amount = (uint32)atoi(args); - - target->ModifyHonorPoints(amount); - - PSendSysMessage(LANG_COMMAND_MODIFY_HONOR, target->GetName(), target->GetHonorPoints()); - - return true; -} - -bool ChatHandler::HandleTeleCommand(const char * args) -{ - if(!*args) - return false; - - Player* _player = m_session->GetPlayer(); - - char* cId = extractKeyFromLink((char*)args,"Htele"); // string or [name] Shift-click form |color|Htele:name|h[name]|h|r - if(!cId) - return false; - - std::string name = cId; - WorldDatabase.escape_string(name); - - QueryResult *result = WorldDatabase.PQuery("SELECT position_x,position_y,position_z,orientation,map FROM game_tele WHERE name = '%s'",name.c_str()); - if (!result) - { - SendSysMessage(LANG_COMMAND_TELE_NOTFOUND); - SetSentErrorMessage(true); - return false; - } - Field *fields = result->Fetch(); - float x = fields[0].GetFloat(); - float y = fields[1].GetFloat(); - float z = fields[2].GetFloat(); - float ort = fields[3].GetFloat(); - int mapid = fields[4].GetUInt16(); - delete result; - - if(!MapManager::IsValidMapCoord(mapid,x,y,x,ort)) - { - PSendSysMessage(LANG_INVALID_TARGET_COORD,x,y,mapid); - SetSentErrorMessage(true); - return false; - } - - // stop flight if need - if(_player->isInFlight()) - { - _player->GetMotionMaster()->MovementExpired(); - _player->m_taxi.ClearTaxiDestinations(); - } - // save only in non-flight case - else - _player->SaveRecallPosition(); - - _player->TeleportTo(mapid, x, y, z, ort); - return true; -} - -bool ChatHandler::HandleLookupAreaCommand(const char* args) -{ - if(!*args) - return false; - - std::string namepart = args; - std::wstring wnamepart; - - if(!Utf8toWStr(namepart,wnamepart)) - return false; - - uint32 counter = 0; // Counter for figure out that we found smth. - - // converting string that we try to find to lower case - wstrToLower( wnamepart ); - - // Search in AreaTable.dbc - for (uint32 areaflag = 0; areaflag < sAreaStore.GetNumRows(); ++areaflag) - { - AreaTableEntry const *areaEntry = sAreaStore.LookupEntry(areaflag); - if(areaEntry) - { - int loc = m_session->GetSessionDbcLocale(); - std::string name = areaEntry->area_name[loc]; - if(name.empty()) - continue; - - if(!Utf8FitTo(name, wnamepart)) - { - loc = 0; - for(; loc < MAX_LOCALE; ++loc) - { - if(loc==m_session->GetSessionDbcLocale()) - continue; - - name = areaEntry->area_name[loc]; - if(name.empty()) - continue; - - if (Utf8FitTo(name, wnamepart)) - break; - } - } - - if(loc < MAX_LOCALE) - { - // send area in "id - [name]" format - std::ostringstream ss; - ss << areaEntry->ID << " - |cffffffff|Harea:" << areaEntry->ID << "|h[" << name << " " << localeNames[loc]<< "]|h|r"; - - SendSysMessage(ss.str().c_str()); - - ++counter; - } - } - } - if (counter == 0) // if counter == 0 then we found nth - SendSysMessage(LANG_COMMAND_NOAREAFOUND); - return true; -} - -//Find tele in game_tele order by name -bool ChatHandler::HandleLookupTeleCommand(const char * args) -{ - if(!*args) - { - SendSysMessage(LANG_COMMAND_TELE_PARAMETER); - SetSentErrorMessage(true); - return false; - } - char const* str = strtok((char*)args, " "); - if(!str) - return false; - - std::string namepart = str; - WorldDatabase.escape_string(namepart); - QueryResult *result = WorldDatabase.PQuery("SELECT name FROM game_tele WHERE name "_LIKE_" '""%%%s%%""'",namepart.c_str()); - if (!result) - { - SendSysMessage(LANG_COMMAND_TELE_NOREQUEST); - SetSentErrorMessage(true); - return false; - } - std::string reply; - for (uint64 i=0; i < result->GetRowCount(); i++) - { - Field *fields = result->Fetch(); - reply += " |cffffffff|Htele:"; - reply += fields[0].GetCppString(); - reply += "|h["; - reply += fields[0].GetCppString(); - reply += "]|h|r\n"; - result->NextRow(); - } - delete result; - - if(reply.empty()) - SendSysMessage(LANG_COMMAND_TELE_NOLOCATION); - else - { - reply = GetMangosString(LANG_COMMAND_TELE_LOCATION) + reply; - SendSysMessage(reply.c_str()); - } - return true; -} - -//Enable\Dissable accept whispers (for GM) -bool ChatHandler::HandleWhispersCommand(const char* args) -{ - if(!*args) - { - PSendSysMessage(LANG_COMMAND_WHISPERACCEPTING, m_session->GetPlayer()->isAcceptWhispers() ? GetMangosString(LANG_ON) : GetMangosString(LANG_OFF)); - return true; - } - - std::string argstr = (char*)args; - // whisper on - if (argstr == "on") - { - m_session->GetPlayer()->SetAcceptWhispers(true); - SendSysMessage(LANG_COMMAND_WHISPERON); - return true; - } - - // whisper off - if (argstr == "off") - { - m_session->GetPlayer()->SetAcceptWhispers(false); - SendSysMessage(LANG_COMMAND_WHISPEROFF); - return true; - } - - SendSysMessage(LANG_USE_BOL); - SetSentErrorMessage(true); - return false; -} - -//Play sound -bool ChatHandler::HandlePlaySoundCommand(const char* args) -{ - // USAGE: .debug playsound #soundid - // #soundid - ID decimal number from SoundEntries.dbc (1st column) - // this file have about 5000 sounds. - // In this realization only caller can hear this sound. - if( *args ) - { - uint32 dwSoundId = atoi((char*)args); - - if( !sSoundEntriesStore.LookupEntry(dwSoundId) ) - { - PSendSysMessage(LANG_SOUND_NOT_EXIST, dwSoundId); - SetSentErrorMessage(true); - return false; - } - - WorldPacket data(SMSG_PLAY_OBJECT_SOUND,4+8); - data << uint32(dwSoundId) << m_session->GetPlayer()->GetGUID(); - m_session->SendPacket(&data); - - PSendSysMessage(LANG_YOU_HEAR_SOUND, dwSoundId); - return true; - } - - return false; -} - -//Save all players in the world -bool ChatHandler::HandleSaveAllCommand(const char* /*args*/) -{ - ObjectAccessor::Instance().SaveAllPlayers(); - SendSysMessage(LANG_PLAYERS_SAVED); - return true; -} - -//Send mail by command -bool ChatHandler::HandleSendMailCommand(const char* args) -{ - if(!*args) - return false; - - char* pName = strtok((char*)args, " "); - char* msgSubject = strtok(NULL, " "); - char* msgText = strtok(NULL, ""); - - if (!msgText) - return false; - - // pName, msgSubject, msgText isn't NUL after prev. check - - std::string name = pName; - std::string subject = msgSubject; - std::string text = msgText; - - if(!normalizePlayerName(name)) - { - SendSysMessage(LANG_PLAYER_NOT_FOUND); - SetSentErrorMessage(true); - return false; - } - - uint64 receiver_guid = objmgr.GetPlayerGUIDByName(name); - - if(!receiver_guid) - return false; - - uint32 mailId = objmgr.GenerateMailID(); - uint32 sender_guidlo = m_session->GetPlayer()->GetGUIDLow(); - uint32 messagetype = MAIL_NORMAL; - uint32 stationery = MAIL_STATIONERY_GM; - uint32 itemTextId = 0; - if (!text.empty()) - { - itemTextId = objmgr.CreateItemText( text ); - } - - Player *receiver = objmgr.GetPlayer(receiver_guid); - - WorldSession::SendMailTo(receiver,messagetype, stationery, sender_guidlo, GUID_LOPART(receiver_guid), subject, itemTextId, NULL, 0, 0, MAIL_CHECK_MASK_NONE); - - PSendSysMessage(LANG_MAIL_SENT, name.c_str()); - return true; -} - -// teleport player to given game_tele.entry -bool ChatHandler::HandleNameTeleCommand(const char * args) -{ - if(!*args) - return false; - - char* pName = strtok((char*)args, " "); - - if(!pName) - return false; - - char* tail = strtok(NULL, ""); - if(!tail) - return false; - - char* cId = extractKeyFromLink((char*)tail,"Htele"); // string or [name] Shift-click form |color|Htele:name|h[name]|h|r - if(!cId) - return false; - - std::string location = cId; - - std::string name = pName; - - if(!normalizePlayerName(name)) - { - SendSysMessage(LANG_PLAYER_NOT_FOUND); - SetSentErrorMessage(true); - return false; - } - - WorldDatabase.escape_string(location); - QueryResult *result = WorldDatabase.PQuery("SELECT position_x,position_y,position_z,orientation,map FROM game_tele WHERE name = '%s'",location.c_str()); - if (!result) - { - SendSysMessage(LANG_COMMAND_TELE_NOTFOUND); - SetSentErrorMessage(true); - return false; - } - - Field *fields = result->Fetch(); - float x = fields[0].GetFloat(); - float y = fields[1].GetFloat(); - float z = fields[2].GetFloat(); - float ort = fields[3].GetFloat(); - int mapid = fields[4].GetUInt16(); - delete result; - - if(!MapManager::IsValidMapCoord(mapid,x,y,x,ort)) - { - PSendSysMessage(LANG_INVALID_TARGET_COORD,x,y,mapid); - SetSentErrorMessage(true); - return false; - } - - Player *chr = objmgr.GetPlayer(name.c_str()); - if (chr) - { - - if(chr->IsBeingTeleported()==true) - { - PSendSysMessage(LANG_IS_TELEPORTED, chr->GetName()); - SetSentErrorMessage(true); - return false; - } - - PSendSysMessage(LANG_TELEPORTING_TO, chr->GetName(),"", location.c_str()); - - if (m_session->GetPlayer()->IsVisibleGloballyFor(chr)) - ChatHandler(chr).PSendSysMessage(LANG_TELEPORTED_TO_BY, m_session->GetPlayer()->GetName()); - - // stop flight if need - if(chr->isInFlight()) - { - chr->GetMotionMaster()->MovementExpired(); - chr->m_taxi.ClearTaxiDestinations(); - } - // save only in non-flight case - else - chr->SaveRecallPosition(); - - chr->TeleportTo(mapid,x,y,z,chr->GetOrientation()); - } - else if (uint64 guid = objmgr.GetPlayerGUIDByName(name.c_str())) - { - PSendSysMessage(LANG_TELEPORTING_TO, name.c_str(), GetMangosString(LANG_OFFLINE), location.c_str()); - Player::SavePositionInDB(mapid,x,y,z,ort,MapManager::Instance().GetZoneId(mapid,x,y),guid); - } - else - PSendSysMessage(LANG_NO_PLAYER, name.c_str()); - - return true; -} - -//Teleport group to given game_tele.entry -bool ChatHandler::HandleGroupTeleCommand(const char * args) -{ - if(!*args) - return false; - - Player *player = getSelectedPlayer(); - if (!player) - { - SendSysMessage(LANG_NO_CHAR_SELECTED); - SetSentErrorMessage(true); - return false; - } - - char* cId = extractKeyFromLink((char*)args,"Htele"); // string or [name] Shift-click form |color|Htele:name|h[name]|h|r - if(!cId) - return false; - - std::string location = cId; - - WorldDatabase.escape_string(location); - QueryResult *result = WorldDatabase.PQuery("SELECT position_x,position_y,position_z,orientation,map FROM game_tele WHERE name = '%s'",location.c_str()); - if (!result) - { - SendSysMessage(LANG_COMMAND_TELE_NOTFOUND); - SetSentErrorMessage(true); - return false; - } - Field *fields = result->Fetch(); - float x = fields[0].GetFloat(); - float y = fields[1].GetFloat(); - float z = fields[2].GetFloat(); - float ort = fields[3].GetFloat(); - int mapid = fields[4].GetUInt16(); - delete result; - - if(!MapManager::IsValidMapCoord(mapid,x,y,z,ort)) - { - PSendSysMessage(LANG_INVALID_TARGET_COORD,x,y,mapid); - SetSentErrorMessage(true); - return false; - } - - Group *grp = player->GetGroup(); - - if(!grp) - { - PSendSysMessage(LANG_NOT_IN_GROUP,player->GetName()); - SetSentErrorMessage(true); - return false; - } - - for(GroupReference *itr = grp->GetFirstMember(); itr != NULL; itr = itr->next()) - { - Player *pl = itr->getSource(); - - if(!pl || !pl->GetSession() ) - continue; - - if(pl->IsBeingTeleported()) - { - PSendSysMessage(LANG_IS_TELEPORTED, pl->GetName()); - continue; - } - - PSendSysMessage(LANG_TELEPORTING_TO, pl->GetName(),"", location.c_str()); - - if (m_session->GetPlayer() != pl && m_session->GetPlayer()->IsVisibleGloballyFor(pl)) - ChatHandler(pl).PSendSysMessage(LANG_TELEPORTED_TO_BY, m_session->GetPlayer()->GetName()); - - // stop flight if need - if(pl->isInFlight()) - { - pl->GetMotionMaster()->MovementExpired(); - pl->m_taxi.ClearTaxiDestinations(); - } - // save only in non-flight case - else - pl->SaveRecallPosition(); - - pl->TeleportTo(mapid, x, y, z, ort); - } - - return true; -} - -//Summon group of player -bool ChatHandler::HandleGroupgoCommand(const char* args) -{ - if(!*args) - return false; - - std::string name = args; - - if(!normalizePlayerName(name)) - { - SendSysMessage(LANG_PLAYER_NOT_FOUND); - SetSentErrorMessage(true); - return false; - } - - Player *player = objmgr.GetPlayer(name.c_str()); - if (!player) - { - PSendSysMessage(LANG_NO_PLAYER, args); - SetSentErrorMessage(true); - return false; - } - - Group *grp = player->GetGroup(); - - if(!grp) - { - PSendSysMessage(LANG_NOT_IN_GROUP,player->GetName()); - SetSentErrorMessage(true); - return false; - } - - Map* gmMap = MapManager::Instance().GetMap(m_session->GetPlayer()->GetMapId(),m_session->GetPlayer()); - bool to_instance = gmMap->Instanceable(); - - // we are in instance, and can summon only player in our group with us as lead - if ( to_instance && ( - !m_session->GetPlayer()->GetGroup() || (grp->GetLeaderGUID() != m_session->GetPlayer()->GetGUID()) || - (m_session->GetPlayer()->GetGroup()->GetLeaderGUID() != m_session->GetPlayer()->GetGUID()) ) ) - // the last check is a bit excessive, but let it be, just in case - { - SendSysMessage(LANG_CANNOT_SUMMON_TO_INST); - SetSentErrorMessage(true); - return false; - } - - for(GroupReference *itr = grp->GetFirstMember(); itr != NULL; itr = itr->next()) - { - Player *pl = itr->getSource(); - - if(!pl || pl==m_session->GetPlayer() || !pl->GetSession() ) - continue; - - if(pl->IsBeingTeleported()==true) - { - PSendSysMessage(LANG_IS_TELEPORTED, pl->GetName()); - SetSentErrorMessage(true); - return false; - } - - if (to_instance) - { - Map* plMap = MapManager::Instance().GetMap(pl->GetMapId(),pl); - - if ( plMap->Instanceable() && plMap->GetInstanceId() != gmMap->GetInstanceId() ) - { - // cannot summon from instance to instance - PSendSysMessage(LANG_CANNOT_SUMMON_TO_INST,pl->GetName()); - SetSentErrorMessage(true); - return false; - } - } - - PSendSysMessage(LANG_SUMMONING, pl->GetName(),""); - - if (m_session->GetPlayer()->IsVisibleGloballyFor(pl)) - ChatHandler(pl).PSendSysMessage(LANG_SUMMONED_BY, m_session->GetPlayer()->GetName()); - - // stop flight if need - if(pl->isInFlight()) - { - pl->GetMotionMaster()->MovementExpired(); - pl->m_taxi.ClearTaxiDestinations(); - } - // save only in non-flight case - else - pl->SaveRecallPosition(); - - // before GM - float x,y,z; - m_session->GetPlayer()->GetClosePoint(x,y,z,pl->GetObjectSize()); - pl->TeleportTo(m_session->GetPlayer()->GetMapId(),x,y,z,pl->GetOrientation()); - } - - return true; -} - -//teleport at coordinates -bool ChatHandler::HandleGoXYCommand(const char* args) -{ - if(!*args) - return false; - - Player* _player = m_session->GetPlayer(); - - char* px = strtok((char*)args, " "); - char* py = strtok(NULL, " "); - char* pmapid = strtok(NULL, " "); - - if (!px || !py) - return false; - - float x = (float)atof(px); - float y = (float)atof(py); - uint32 mapid; - if (pmapid) - mapid = (uint32)atoi(pmapid); - else mapid = _player->GetMapId(); - - if(!MapManager::IsValidMapCoord(mapid,x,y)) - { - PSendSysMessage(LANG_INVALID_TARGET_COORD,x,y,mapid); - SetSentErrorMessage(true); - return false; - } - - // stop flight if need - if(_player->isInFlight()) - { - _player->GetMotionMaster()->MovementExpired(); - _player->m_taxi.ClearTaxiDestinations(); - } - // save only in non-flight case - else - _player->SaveRecallPosition(); - - Map const *map = MapManager::Instance().GetBaseMap(mapid); - float z = std::max(map->GetHeight(x, y, MAX_HEIGHT), map->GetWaterLevel(x, y)); - - _player->TeleportTo(mapid, x, y, z, _player->GetOrientation()); - - return true; -} - -//teleport at coordinates, including Z -bool ChatHandler::HandleGoXYZCommand(const char* args) -{ - if(!*args) - return false; - - Player* _player = m_session->GetPlayer(); - - char* px = strtok((char*)args, " "); - char* py = strtok(NULL, " "); - char* pz = strtok(NULL, " "); - char* pmapid = strtok(NULL, " "); - - if (!px || !py || !pz) - return false; - - float x = (float)atof(px); - float y = (float)atof(py); - float z = (float)atof(pz); - uint32 mapid; - if (pmapid) - mapid = (uint32)atoi(pmapid); - else - mapid = _player->GetMapId(); - - if(!MapManager::IsValidMapCoord(mapid,x,y,z)) - { - PSendSysMessage(LANG_INVALID_TARGET_COORD,x,y,mapid); - SetSentErrorMessage(true); - return false; - } - - // stop flight if need - if(_player->isInFlight()) - { - _player->GetMotionMaster()->MovementExpired(); - _player->m_taxi.ClearTaxiDestinations(); - } - // save only in non-flight case - else - _player->SaveRecallPosition(); - - _player->TeleportTo(mapid, x, y, z, _player->GetOrientation()); - - return true; -} - -//teleport at coordinates -bool ChatHandler::HandleGoZoneXYCommand(const char* args) -{ - if(!*args) - return false; - - Player* _player = m_session->GetPlayer(); - - char* px = strtok((char*)args, " "); - char* py = strtok(NULL, " "); - char* tail = strtok(NULL,""); - - char* cAreaId = extractKeyFromLink(tail,"Harea"); // string or [name] Shift-click form |color|Harea:area_id|h[name]|h|r - - if (!px || !py) - return false; - - float x = (float)atof(px); - float y = (float)atof(py); - uint32 areaid = cAreaId ? (uint32)atoi(cAreaId) : _player->GetZoneId(); - - AreaTableEntry const* areaEntry = GetAreaEntryByAreaID(areaid); - - if( x<0 || x>100 || y<0 || y>100 || !areaEntry ) - { - PSendSysMessage(LANG_INVALID_ZONE_COORD,x,y,areaid); - SetSentErrorMessage(true); - return false; - } - - // update to parent zone if exist (client map show only zones without parents) - AreaTableEntry const* zoneEntry = areaEntry->zone ? GetAreaEntryByAreaID(areaEntry->zone) : areaEntry; - - Map const *map = MapManager::Instance().GetBaseMap(zoneEntry->mapid); - - if(map->Instanceable()) - { - PSendSysMessage(LANG_INVALID_ZONE_MAP,areaEntry->ID,areaEntry->area_name[m_session->GetSessionDbcLocale()],map->GetId(),map->GetMapName()); - SetSentErrorMessage(true); - return false; - } - - Zone2MapCoordinates(x,y,zoneEntry->ID); - - if(!MapManager::IsValidMapCoord(zoneEntry->mapid,x,y)) - { - PSendSysMessage(LANG_INVALID_TARGET_COORD,x,y,zoneEntry->mapid); - SetSentErrorMessage(true); - return false; - } - - // stop flight if need - if(_player->isInFlight()) - { - _player->GetMotionMaster()->MovementExpired(); - _player->m_taxi.ClearTaxiDestinations(); - } - // save only in non-flight case - else - _player->SaveRecallPosition(); - - float z = std::max(map->GetHeight(x, y, MAX_HEIGHT), map->GetWaterLevel(x, y)); - _player->TeleportTo(zoneEntry->mapid, x, y, z, _player->GetOrientation()); - - return true; -} - -//teleport to grid -bool ChatHandler::HandleGoGridCommand(const char* args) -{ - if(!*args) return false; - Player* _player = m_session->GetPlayer(); - - char* px = strtok((char*)args, " "); - char* py = strtok(NULL, " "); - char* pmapid = strtok(NULL, " "); - - if (!px || !py) - return false; - - float grid_x = (float)atof(px); - float grid_y = (float)atof(py); - uint32 mapid; - if (pmapid) - mapid = (uint32)atoi(pmapid); - else mapid = _player->GetMapId(); - - // center of grid - float x = (grid_x-CENTER_GRID_ID+0.5f)*SIZE_OF_GRIDS; - float y = (grid_y-CENTER_GRID_ID+0.5f)*SIZE_OF_GRIDS; - - if(!MapManager::IsValidMapCoord(mapid,x,y)) - { - PSendSysMessage(LANG_INVALID_TARGET_COORD,x,y,mapid); - SetSentErrorMessage(true); - return false; - } - - // stop flight if need - if(_player->isInFlight()) - { - _player->GetMotionMaster()->MovementExpired(); - _player->m_taxi.ClearTaxiDestinations(); - } - // save only in non-flight case - else - _player->SaveRecallPosition(); - - Map const *map = MapManager::Instance().GetBaseMap(mapid); - float z = std::max(map->GetHeight(x, y, MAX_HEIGHT), map->GetWaterLevel(x, y)); - _player->TeleportTo(mapid, x, y, z, _player->GetOrientation()); - - return true; -} - -bool ChatHandler::HandleDrunkCommand(const char* args) -{ - if(!*args) return false; - - uint32 drunklevel = (uint32)atoi(args); - if(drunklevel > 100) - drunklevel = 100; - - uint16 drunkMod = drunklevel * 0xFFFF / 100; - - m_session->GetPlayer()->SetDrunkValue(drunkMod); - - return true; -} +/* + * Copyright (C) 2005-2008 MaNGOS + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "Common.h" +#include "Database/DatabaseEnv.h" +#include "WorldPacket.h" +#include "WorldSession.h" +#include "World.h" +#include "ObjectMgr.h" +#include "Player.h" +#include "Opcodes.h" +#include "Chat.h" +#include "Log.h" +#include "MapManager.h" +#include "ObjectAccessor.h" +#include "Language.h" +#include "CellImpl.h" +#include "InstanceSaveMgr.h" +#include "Util.h" +#ifdef _DEBUG_VMAPS +#include "VMapFactory.h" +#endif + +bool ChatHandler::HandleSayCommand(const char* args) +{ + if(!*args) + return false; + + Creature* pCreature = getSelectedCreature(); + if(!pCreature) + { + SendSysMessage(LANG_SELECT_CREATURE); + SetSentErrorMessage(true); + return false; + } + + pCreature->Say(args, LANG_UNIVERSAL, 0); + + return true; +} + +bool ChatHandler::HandleYellCommand(const char* args) +{ + if(!*args) + return false; + + Creature* pCreature = getSelectedCreature(); + if(!pCreature) + { + SendSysMessage(LANG_SELECT_CREATURE); + SetSentErrorMessage(true); + return false; + } + + pCreature->Yell(args, LANG_UNIVERSAL, 0); + + return true; +} + +//show text emote by creature in chat +bool ChatHandler::HandleTextEmoteCommand(const char* args) +{ + if(!*args) + return false; + + Creature* pCreature = getSelectedCreature(); + + if(!pCreature) + { + SendSysMessage(LANG_SELECT_CREATURE); + SetSentErrorMessage(true); + return false; + } + + pCreature->TextEmote(args, 0); + + return true; +} + +// make npc whisper to player +bool ChatHandler::HandleNpcWhisperCommand(const char* args) +{ + if(!*args) + return false; + + char* receiver_str = strtok((char*)args, " "); + char* text = strtok(NULL, ""); + + uint64 guid = m_session->GetPlayer()->GetSelection(); + Creature* pCreature = ObjectAccessor::GetCreature(*m_session->GetPlayer(), guid); + + if(!pCreature || !receiver_str || !text) + { + return false; + } + + uint64 receiver_guid= atol(receiver_str); + + pCreature->Whisper(text,receiver_guid); + + return true; +} + +// global announce +bool ChatHandler::HandleAnnounceCommand(const char* args) +{ + if(!*args) + return false; + + sWorld.SendWorldText(LANG_SYSTEMMESSAGE,args); + return true; +} + +//notification player at the screen +bool ChatHandler::HandleNotifyCommand(const char* args) +{ + if(!*args) + return false; + + std::string str = GetMangosString(LANG_GLOBAL_NOTIFY); + str += args; + + WorldPacket data(SMSG_NOTIFICATION, (str.size()+1)); + data << str; + sWorld.SendGlobalMessage(&data); + + return true; +} + +//Enable\Dissable GM Mode +bool ChatHandler::HandleGMmodeCommand(const char* args) +{ + if(!*args) + { + SendSysMessage(LANG_USE_BOL); + SetSentErrorMessage(true); + return false; + } + + std::string argstr = (char*)args; + + if (argstr == "on") + { + m_session->GetPlayer()->SetGameMaster(true); + m_session->SendNotification("GM mode is ON"); + #ifdef _DEBUG_VMAPS + VMAP::IVMapManager *vMapManager = VMAP::VMapFactory::createOrGetVMapManager(); + vMapManager->processCommand("stoplog"); + #endif + return true; + } + + if (argstr == "off") + { + m_session->GetPlayer()->SetGameMaster(false); + m_session->SendNotification("GM mode is OFF"); + #ifdef _DEBUG_VMAPS + VMAP::IVMapManager *vMapManager = VMAP::VMapFactory::createOrGetVMapManager(); + vMapManager->processCommand("startlog"); + #endif + return true; + } + + SendSysMessage(LANG_USE_BOL); + SetSentErrorMessage(true); + return false; +} + +//Enable\Dissable Invisible mode +bool ChatHandler::HandleVisibleCommand(const char* args) +{ + if (!*args) + { + PSendSysMessage(LANG_YOU_ARE, m_session->GetPlayer()->isGMVisible() ? GetMangosString(LANG_VISIBLE) : GetMangosString(LANG_INVISIBLE)); + return true; + } + + std::string argstr = (char*)args; + + if (argstr == "on") + { + m_session->GetPlayer()->SetGMVisible(true); + m_session->SendNotification(GetMangosString(LANG_INVISIBLE_VISIBLE)); + return true; + } + + if (argstr == "off") + { + m_session->SendNotification(GetMangosString(LANG_INVISIBLE_INVISIBLE)); + m_session->GetPlayer()->SetGMVisible(false); + return true; + } + + SendSysMessage(LANG_USE_BOL); + SetSentErrorMessage(true); + return false; +} + +bool ChatHandler::HandleGPSCommand(const char* args) +{ + WorldObject *obj = NULL; + if (*args) + { + std::string name = args; + if(normalizePlayerName(name)) + obj = objmgr.GetPlayer(name.c_str()); + + if(!obj) + { + SendSysMessage(LANG_PLAYER_NOT_FOUND); + SetSentErrorMessage(true); + return false; + } + } + else + { + obj = getSelectedUnit(); + + if(!obj) + { + SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE); + SetSentErrorMessage(true); + return false; + } + } + CellPair cell_val = MaNGOS::ComputeCellPair(obj->GetPositionX(), obj->GetPositionY()); + Cell cell(cell_val); + + uint32 zone_id = obj->GetZoneId(); + uint32 area_id = obj->GetAreaId(); + + MapEntry const* mapEntry = sMapStore.LookupEntry(obj->GetMapId()); + AreaTableEntry const* zoneEntry = GetAreaEntryByAreaID(zone_id); + AreaTableEntry const* areaEntry = GetAreaEntryByAreaID(area_id); + + float zone_x = obj->GetPositionX(); + float zone_y = obj->GetPositionY(); + + Map2ZoneCoordinates(zone_x,zone_y,zone_id); + + Map const *map = MapManager::Instance().GetMap(obj->GetMapId(), obj); + float ground_z = map->GetHeight(obj->GetPositionX(), obj->GetPositionY(), MAX_HEIGHT); + float floor_z = map->GetHeight(obj->GetPositionX(), obj->GetPositionY(), obj->GetPositionZ()); + + GridPair p = MaNGOS::ComputeGridPair(obj->GetPositionX(), obj->GetPositionY()); + + int gx=63-p.x_coord; + int gy=63-p.y_coord; + + uint32 have_map = Map::ExistMap(obj->GetMapId(),gx,gy) ? 1 : 0; + uint32 have_vmap = Map::ExistVMap(obj->GetMapId(),gx,gy) ? 1 : 0; + + PSendSysMessage(LANG_MAP_POSITION, + obj->GetMapId(), (mapEntry ? mapEntry->name[m_session->GetSessionDbcLocale()] : "" ), + zone_id, (zoneEntry ? zoneEntry->area_name[m_session->GetSessionDbcLocale()] : "" ), + area_id, (areaEntry ? areaEntry->area_name[m_session->GetSessionDbcLocale()] : "" ), + obj->GetPositionX(), obj->GetPositionY(), obj->GetPositionZ(), obj->GetOrientation(), + cell.GridX(), cell.GridY(), cell.CellX(), cell.CellY(), obj->GetInstanceId(), + zone_x, zone_y, ground_z, floor_z, have_map, have_vmap ); + + sLog.outDebug("Player %s GPS call for %s '%s' (%s: %u):", + m_session->GetPlayer()->GetName(), + (obj->GetTypeId() == TYPEID_PLAYER ? "player" : "creature"), obj->GetName(), + (obj->GetTypeId() == TYPEID_PLAYER ? "GUID" : "Entry"), (obj->GetTypeId() == TYPEID_PLAYER ? obj->GetGUIDLow(): obj->GetEntry()) ); + sLog.outDebug(GetMangosString(LANG_MAP_POSITION), + obj->GetMapId(), (mapEntry ? mapEntry->name[sWorld.GetDefaultDbcLocale()] : "" ), + zone_id, (zoneEntry ? zoneEntry->area_name[sWorld.GetDefaultDbcLocale()] : "" ), + area_id, (areaEntry ? areaEntry->area_name[sWorld.GetDefaultDbcLocale()] : "" ), + obj->GetPositionX(), obj->GetPositionY(), obj->GetPositionZ(), obj->GetOrientation(), + cell.GridX(), cell.GridY(), cell.CellX(), cell.CellY(), obj->GetInstanceId(), + zone_x, zone_y, ground_z, floor_z, have_map, have_vmap ); + + return true; +} + +//Summon Player +bool ChatHandler::HandleNamegoCommand(const char* args) +{ + if(!*args) + return false; + + std::string name = args; + + if(!normalizePlayerName(name)) + { + SendSysMessage(LANG_PLAYER_NOT_FOUND); + SetSentErrorMessage(true); + return false; + } + + Player *chr = objmgr.GetPlayer(name.c_str()); + if (chr) + { + if(chr->IsBeingTeleported()==true) + { + PSendSysMessage(LANG_IS_TELEPORTED, chr->GetName()); + SetSentErrorMessage(true); + return false; + } + + Map* pMap = MapManager::Instance().GetMap(m_session->GetPlayer()->GetMapId(),m_session->GetPlayer()); + + if(pMap->Instanceable()) + { + Map* cMap = MapManager::Instance().GetMap(chr->GetMapId(),chr); + if( cMap->Instanceable() && cMap->GetInstanceId() != pMap->GetInstanceId() ) + { + // cannot summon from instance to instance + PSendSysMessage(LANG_CANNOT_SUMMON_TO_INST,chr->GetName()); + SetSentErrorMessage(true); + return false; + } + + // we are in instance, and can summon only player in our group with us as lead + if ( !m_session->GetPlayer()->GetGroup() || !chr->GetGroup() || + (chr->GetGroup()->GetLeaderGUID() != m_session->GetPlayer()->GetGUID()) || + (m_session->GetPlayer()->GetGroup()->GetLeaderGUID() != m_session->GetPlayer()->GetGUID()) ) + // the last check is a bit excessive, but let it be, just in case + { + PSendSysMessage(LANG_CANNOT_SUMMON_TO_INST,chr->GetName()); + SetSentErrorMessage(true); + return false; + } + } + + PSendSysMessage(LANG_SUMMONING, chr->GetName(),""); + + if (m_session->GetPlayer()->IsVisibleGloballyFor(chr)) + ChatHandler(chr).PSendSysMessage(LANG_SUMMONED_BY, m_session->GetPlayer()->GetName()); + + // stop flight if need + if(chr->isInFlight()) + { + chr->GetMotionMaster()->MovementExpired(); + chr->m_taxi.ClearTaxiDestinations(); + } + // save only in non-flight case + else + chr->SaveRecallPosition(); + + // before GM + float x,y,z; + m_session->GetPlayer()->GetClosePoint(x,y,z,chr->GetObjectSize()); + chr->TeleportTo(m_session->GetPlayer()->GetMapId(),x,y,z,chr->GetOrientation()); + } + else if (uint64 guid = objmgr.GetPlayerGUIDByName(name)) + { + PSendSysMessage(LANG_SUMMONING, name.c_str(),GetMangosString(LANG_OFFLINE)); + + // in point where GM stay + Player::SavePositionInDB(m_session->GetPlayer()->GetMapId(), + m_session->GetPlayer()->GetPositionX(), + m_session->GetPlayer()->GetPositionY(), + m_session->GetPlayer()->GetPositionZ(), + m_session->GetPlayer()->GetOrientation(), + m_session->GetPlayer()->GetZoneId(), + guid); + } + else + { + PSendSysMessage(LANG_NO_PLAYER, args); + SetSentErrorMessage(true); + } + + return true; +} + +//Teleport to Player +bool ChatHandler::HandleGonameCommand(const char* args) +{ + if(!*args) + return false; + + Player* _player = m_session->GetPlayer(); + + std::string name = args; + + if(!normalizePlayerName(name)) + { + SendSysMessage(LANG_PLAYER_NOT_FOUND); + SetSentErrorMessage(true); + return false; + } + + Player *chr = objmgr.GetPlayer(name.c_str()); + if (chr) + { + Map* cMap = MapManager::Instance().GetMap(chr->GetMapId(),chr); + if(cMap->Instanceable()) + { + Map* pMap = MapManager::Instance().GetMap(_player->GetMapId(),_player); + + // we have to go to instance, and can go to player only if: + // 1) we are in his group (either as leader or as member) + // 2) we are not bound to any group and have GM mode on + if (_player->GetGroup()) + { + // we are in group, we can go only if we are in the player group + if (_player->GetGroup() != chr->GetGroup()) + { + PSendSysMessage(LANG_CANNOT_GO_TO_INST_PARTY,chr->GetName()); + SetSentErrorMessage(true); + return false; + } + } + else + { + // we are not in group, let's verify our GM mode + if (!_player->isGameMaster()) + { + PSendSysMessage(LANG_CANNOT_GO_TO_INST_GM,chr->GetName()); + SetSentErrorMessage(true); + return false; + } + } + + // if the player or the player's group is bound to another instance + // the player will not be bound to another one + InstancePlayerBind *pBind = _player->GetBoundInstance(chr->GetMapId(), chr->GetDifficulty()); + if(!pBind) + { + Group *group = _player->GetGroup(); + InstanceGroupBind *gBind = group ? group->GetBoundInstance(chr->GetMapId(), chr->GetDifficulty()) : NULL; + if(!gBind) + { + // if no bind exists, create a solo bind + InstanceSave *save = sInstanceSaveManager.GetInstanceSave(chr->GetInstanceId()); + if(save) _player->BindToInstance(save, !save->CanReset()); + } + } + + _player->SetDifficulty(chr->GetDifficulty()); + } + + PSendSysMessage(LANG_APPEARING_AT, chr->GetName()); + + if (_player->IsVisibleGloballyFor(chr)) + ChatHandler(chr).PSendSysMessage(LANG_APPEARING_TO, _player->GetName()); + + // stop flight if need + if(_player->isInFlight()) + { + _player->GetMotionMaster()->MovementExpired(); + _player->m_taxi.ClearTaxiDestinations(); + } + // save only in non-flight case + else + _player->SaveRecallPosition(); + + // to point to see at target with same orientation + float x,y,z; + chr->GetContactPoint(m_session->GetPlayer(),x,y,z); + + _player->TeleportTo(chr->GetMapId(), x, y, z, _player->GetAngle( chr ), TELE_TO_GM_MODE); + + return true; + } + + if (uint64 guid = objmgr.GetPlayerGUIDByName(name)) + { + PSendSysMessage(LANG_APPEARING_AT, name.c_str()); + + // to point where player stay (if loaded) + float x,y,z,o; + uint32 map; + bool in_flight; + if(Player::LoadPositionFromDB(map,x,y,z,o,in_flight,guid)) + { + // stop flight if need + if(_player->isInFlight()) + { + _player->GetMotionMaster()->MovementExpired(); + _player->m_taxi.ClearTaxiDestinations(); + } + // save only in non-flight case + else + _player->SaveRecallPosition(); + + _player->TeleportTo(map, x, y, z,_player->GetOrientation()); + return true; + } + } + + PSendSysMessage(LANG_NO_PLAYER, args); + + SetSentErrorMessage(true); + return false; +} + +// Teleport player to last position +bool ChatHandler::HandleRecallCommand(const char* args) +{ + Player* chr = NULL; + + if(!*args) + { + chr = getSelectedPlayer(); + if(!chr) + chr = m_session->GetPlayer(); + } + else + { + std::string name = args; + + if(!normalizePlayerName(name)) + { + SendSysMessage(LANG_PLAYER_NOT_FOUND); + SetSentErrorMessage(true); + return false; + } + + chr = objmgr.GetPlayer(name.c_str()); + + if(!chr) + { + PSendSysMessage(LANG_NO_PLAYER, args); + SetSentErrorMessage(true); + return false; + } + } + + if(chr->IsBeingTeleported()) + { + PSendSysMessage(LANG_IS_TELEPORTED, chr->GetName()); + SetSentErrorMessage(true); + return false; + } + + // stop flight if need + if(chr->isInFlight()) + { + chr->GetMotionMaster()->MovementExpired(); + chr->m_taxi.ClearTaxiDestinations(); + } + + chr->TeleportTo(chr->m_recallMap, chr->m_recallX, chr->m_recallY, chr->m_recallZ, chr->m_recallO); + return true; +} + +//Edit Player KnownTitles +bool ChatHandler::HandleModifyKnownTitlesCommand(const char* args) +{ + if(!*args) + return false; + + uint64 titles = 0; + + sscanf((char*)args, I64FMTD, &titles); + + Player *chr = getSelectedPlayer(); + if (!chr) + { + SendSysMessage(LANG_NO_CHAR_SELECTED); + SetSentErrorMessage(true); + return false; + } + + uint64 titles2 = titles; + + for(int i=1; i < sCharTitlesStore.GetNumRows(); ++i) + if(CharTitlesEntry const* tEntry = sCharTitlesStore.LookupEntry(i)) + titles2 &= ~(uint64(1) << tEntry->bit_index); + + titles &= ~titles2; // remove not existed titles + + chr->SetUInt64Value(PLAYER__FIELD_KNOWN_TITLES, titles); + SendSysMessage(LANG_DONE); + + return true; +} + +//Edit Player HP +bool ChatHandler::HandleModifyHPCommand(const char* args) +{ + if(!*args) + return false; + + // char* pHp = strtok((char*)args, " "); + // if (!pHp) + // return false; + + // char* pHpMax = strtok(NULL, " "); + // if (!pHpMax) + // return false; + + // int32 hpm = atoi(pHpMax); + // int32 hp = atoi(pHp); + + int32 hp = atoi((char*)args); + int32 hpm = atoi((char*)args); + + if (hp <= 0 || hpm <= 0 || hpm < hp) + { + SendSysMessage(LANG_BAD_VALUE); + SetSentErrorMessage(true); + return false; + } + + Player *chr = getSelectedPlayer(); + if (chr == NULL) + { + SendSysMessage(LANG_NO_CHAR_SELECTED); + SetSentErrorMessage(true); + return false; + } + + PSendSysMessage(LANG_YOU_CHANGE_HP, chr->GetName(), hp, hpm); + ChatHandler(chr).PSendSysMessage(LANG_YOURS_HP_CHANGED, m_session->GetPlayer()->GetName(), hp, hpm); + + chr->SetMaxHealth( hpm ); + chr->SetHealth( hp ); + + return true; +} + +//Edit Player Mana +bool ChatHandler::HandleModifyManaCommand(const char* args) +{ + if(!*args) + return false; + + // char* pmana = strtok((char*)args, " "); + // if (!pmana) + // return false; + + // char* pmanaMax = strtok(NULL, " "); + // if (!pmanaMax) + // return false; + + // int32 manam = atoi(pmanaMax); + // int32 mana = atoi(pmana); + int32 mana = atoi((char*)args); + int32 manam = atoi((char*)args); + + if (mana <= 0 || manam <= 0 || manam < mana) + { + SendSysMessage(LANG_BAD_VALUE); + SetSentErrorMessage(true); + return false; + } + + Player *chr = getSelectedPlayer(); + if (chr == NULL) + { + SendSysMessage(LANG_NO_CHAR_SELECTED); + SetSentErrorMessage(true); + return false; + } + + PSendSysMessage(LANG_YOU_CHANGE_MANA, chr->GetName(), mana, manam); + ChatHandler(chr).PSendSysMessage(LANG_YOURS_MANA_CHANGED, m_session->GetPlayer()->GetName(), mana, manam); + + chr->SetMaxPower(POWER_MANA,manam ); + chr->SetPower(POWER_MANA, mana ); + + return true; +} + +//Edit Player Energy +bool ChatHandler::HandleModifyEnergyCommand(const char* args) +{ + if(!*args) + return false; + + // char* pmana = strtok((char*)args, " "); + // if (!pmana) + // return false; + + // char* pmanaMax = strtok(NULL, " "); + // if (!pmanaMax) + // return false; + + // int32 manam = atoi(pmanaMax); + // int32 mana = atoi(pmana); + + int32 energy = atoi((char*)args)*10; + int32 energym = atoi((char*)args)*10; + + if (energy <= 0 || energym <= 0 || energym < energy) + { + SendSysMessage(LANG_BAD_VALUE); + SetSentErrorMessage(true); + return false; + } + + Player *chr = getSelectedPlayer(); + if (!chr) + { + SendSysMessage(LANG_NO_CHAR_SELECTED); + SetSentErrorMessage(true); + return false; + } + + PSendSysMessage(LANG_YOU_CHANGE_ENERGY, chr->GetName(), energy/10, energym/10); + ChatHandler(chr).PSendSysMessage(LANG_YOURS_ENERGY_CHANGED, m_session->GetPlayer()->GetName(), energy/10, energym/10); + + chr->SetMaxPower(POWER_ENERGY,energym ); + chr->SetPower(POWER_ENERGY, energy ); + + sLog.outDetail(GetMangosString(LANG_CURRENT_ENERGY),chr->GetMaxPower(POWER_ENERGY)); + + return true; +} + +//Edit Player Rage +bool ChatHandler::HandleModifyRageCommand(const char* args) +{ + if(!*args) + return false; + + // char* pmana = strtok((char*)args, " "); + // if (!pmana) + // return false; + + // char* pmanaMax = strtok(NULL, " "); + // if (!pmanaMax) + // return false; + + // int32 manam = atoi(pmanaMax); + // int32 mana = atoi(pmana); + + int32 rage = atoi((char*)args)*10; + int32 ragem = atoi((char*)args)*10; + + if (rage <= 0 || ragem <= 0 || ragem < rage) + { + SendSysMessage(LANG_BAD_VALUE); + SetSentErrorMessage(true); + return false; + } + + Player *chr = getSelectedPlayer(); + if (chr == NULL) + { + SendSysMessage(LANG_NO_CHAR_SELECTED); + SetSentErrorMessage(true); + return false; + } + + PSendSysMessage(LANG_YOU_CHANGE_RAGE, chr->GetName(), rage/10, ragem/10); + // Special case: I use GetMangosString here to get local of destination char ;) + ChatHandler(chr).PSendSysMessage(ChatHandler(chr).GetMangosString(LANG_YOURS_RAGE_CHANGED), m_session->GetPlayer()->GetName(), rage/10, ragem/10); + + chr->SetMaxPower(POWER_RAGE,ragem ); + chr->SetPower(POWER_RAGE, rage ); + + return true; +} + +//Edit Player Faction +bool ChatHandler::HandleModifyFactionCommand(const char* args) +{ + if(!*args) + return false; + + char* pfactionid = extractKeyFromLink((char*)args,"Hfaction"); + + Creature* chr = getSelectedCreature(); + if(!chr) + { + SendSysMessage(LANG_SELECT_CREATURE); + SetSentErrorMessage(true); + return false; + } + + if(!pfactionid) + { + if(chr) + { + uint32 factionid = chr->getFaction(); + uint32 flag = chr->GetUInt32Value(UNIT_FIELD_FLAGS); + uint32 npcflag = chr->GetUInt32Value(UNIT_NPC_FLAGS); + uint32 dyflag = chr->GetUInt32Value(UNIT_DYNAMIC_FLAGS); + PSendSysMessage(LANG_CURRENT_FACTION,chr->GetGUIDLow(),factionid,flag,npcflag,dyflag); + } + return true; + } + + if( !chr ) + { + SendSysMessage(LANG_NO_CHAR_SELECTED); + SetSentErrorMessage(true); + return false; + } + + uint32 factionid = atoi(pfactionid); + uint32 flag; + + char *pflag = strtok(NULL, " "); + if (!pflag) + flag = chr->GetUInt32Value(UNIT_FIELD_FLAGS); + else + flag = atoi(pflag); + + char* pnpcflag = strtok(NULL, " "); + + uint32 npcflag; + if(!pnpcflag) + npcflag = chr->GetUInt32Value(UNIT_NPC_FLAGS); + else + npcflag = atoi(pnpcflag); + + char* pdyflag = strtok(NULL, " "); + + uint32 dyflag; + if(!pdyflag) + dyflag = chr->GetUInt32Value(UNIT_DYNAMIC_FLAGS); + else + dyflag = atoi(pdyflag); + + if(!sFactionTemplateStore.LookupEntry(factionid)) + { + PSendSysMessage(LANG_WRONG_FACTION, factionid); + SetSentErrorMessage(true); + return false; + } + + PSendSysMessage(LANG_YOU_CHANGE_FACTION, chr->GetGUIDLow(),factionid,flag,npcflag,dyflag); + + //sprintf((char*)buf,"%s changed your Faction to %i.", m_session->GetPlayer()->GetName(), factionid); + //FillSystemMessageData(&data, m_session, buf); + + //chr->GetSession()->SendPacket(&data); + + chr->setFaction(factionid); + chr->SetUInt32Value(UNIT_FIELD_FLAGS,flag); + chr->SetUInt32Value(UNIT_NPC_FLAGS,npcflag); + chr->SetUInt32Value(UNIT_DYNAMIC_FLAGS,dyflag); + + return true; +} + +//Edit Player Spell +bool ChatHandler::HandleModifySpellCommand(const char* args) +{ + if(!*args) return false; + char* pspellflatid = strtok((char*)args, " "); + if (!pspellflatid) + return false; + + char* pop = strtok(NULL, " "); + if (!pop) + return false; + + char* pval = strtok(NULL, " "); + if (!pval) + return false; + + uint16 mark; + + char* pmark = strtok(NULL, " "); + + uint8 spellflatid = atoi(pspellflatid); + uint8 op = atoi(pop); + uint16 val = atoi(pval); + if(!pmark) + mark = 65535; + else + mark = atoi(pmark); + + Player *chr = getSelectedPlayer(); + if (chr == NULL) + { + SendSysMessage(LANG_NO_CHAR_SELECTED); + SetSentErrorMessage(true); + return false; + } + + PSendSysMessage(LANG_YOU_CHANGE_SPELLFLATID, spellflatid, val, mark, chr->GetName()); + if(chr != m_session->GetPlayer()) + ChatHandler(chr).PSendSysMessage(LANG_YOURS_SPELLFLATID_CHANGED, m_session->GetPlayer()->GetName(), spellflatid, val, mark); + + WorldPacket data(SMSG_SET_FLAT_SPELL_MODIFIER, (1+1+2+2)); + data << uint8(spellflatid); + data << uint8(op); + data << uint16(val); + data << uint16(mark); + chr->GetSession()->SendPacket(&data); + + return true; +} + +//Edit Player TP +bool ChatHandler::HandleModifyTalentCommand (const char* args) +{ + if (!*args) + return false; + + int tp = atoi((char*)args); + if (tp>0) + { + Player* player = getSelectedPlayer(); + if(!player) + { + SendSysMessage(LANG_NO_CHAR_SELECTED); + SetSentErrorMessage(true); + return false; + } + player->SetFreeTalentPoints(tp); + return true; + } + return false; +} + +//Enable On\OFF all taxi paths +bool ChatHandler::HandleTaxiCheatCommand(const char* args) +{ + if (!*args) + { + SendSysMessage(LANG_USE_BOL); + SetSentErrorMessage(true); + return false; + } + + std::string argstr = (char*)args; + + Player *chr = getSelectedPlayer(); + if (!chr) + { + chr=m_session->GetPlayer(); + } + + if (argstr == "on") + { + chr->SetTaxiCheater(true); + PSendSysMessage(LANG_YOU_GIVE_TAXIS, chr->GetName()); + + if(chr != m_session->GetPlayer()) + // to send localized data to target + ChatHandler(chr).PSendSysMessage(ChatHandler(chr).GetMangosString(LANG_YOURS_TAXIS_ADDED), m_session->GetPlayer()->GetName()); + return true; + } + + if (argstr == "off") + { + chr->SetTaxiCheater(false); + PSendSysMessage(LANG_YOU_REMOVE_TAXIS, chr->GetName()); + + if(chr != m_session->GetPlayer()) + ChatHandler(chr).PSendSysMessage(ChatHandler(chr).GetMangosString(LANG_YOURS_TAXIS_REMOVED), m_session->GetPlayer()->GetName()); + + return true; + } + + SendSysMessage(LANG_USE_BOL); + SetSentErrorMessage(true); + return false; +} + +//Edit Player Aspeed +bool ChatHandler::HandleModifyASpeedCommand(const char* args) +{ + if (!*args) + return false; + + float ASpeed = (float)atof((char*)args); + + if (ASpeed > 10 || ASpeed < 0.1) + { + SendSysMessage(LANG_BAD_VALUE); + SetSentErrorMessage(true); + return false; + } + + Player *chr = getSelectedPlayer(); + if (chr == NULL) + { + SendSysMessage(LANG_NO_CHAR_SELECTED); + SetSentErrorMessage(true); + return false; + } + + if(chr->isInFlight()) + { + PSendSysMessage(LANG_CHAR_IN_FLIGHT,chr->GetName()); + SetSentErrorMessage(true); + return false; + } + + PSendSysMessage(LANG_YOU_CHANGE_ASPEED, ASpeed, chr->GetName()); + + if(chr != m_session->GetPlayer()) + ChatHandler(chr).PSendSysMessage(ChatHandler(chr).GetMangosString(LANG_YOURS_ASPEED_CHANGED), m_session->GetPlayer()->GetName(), ASpeed); + + chr->SetSpeed(MOVE_WALK, ASpeed,true); + chr->SetSpeed(MOVE_RUN, ASpeed,true); + chr->SetSpeed(MOVE_SWIM, ASpeed,true); + //chr->SetSpeed(MOVE_TURN, ASpeed,true); + chr->SetSpeed(MOVE_FLY, ASpeed,true); + return true; +} + +//Edit Player Speed +bool ChatHandler::HandleModifySpeedCommand(const char* args) +{ + if (!*args) + return false; + + float Speed = (float)atof((char*)args); + + if (Speed > 10 || Speed < 0.1) + { + SendSysMessage(LANG_BAD_VALUE); + SetSentErrorMessage(true); + return false; + } + + Player *chr = getSelectedPlayer(); + if (chr == NULL) + { + SendSysMessage(LANG_NO_CHAR_SELECTED); + SetSentErrorMessage(true); + return false; + } + + if(chr->isInFlight()) + { + PSendSysMessage(LANG_CHAR_IN_FLIGHT,chr->GetName()); + SetSentErrorMessage(true); + return false; + } + + PSendSysMessage(LANG_YOU_CHANGE_SPEED, Speed, chr->GetName()); + + if(chr != m_session->GetPlayer()) + ChatHandler(chr).PSendSysMessage(ChatHandler(chr).GetMangosString(LANG_YOURS_SPEED_CHANGED), m_session->GetPlayer()->GetName(), Speed); + + chr->SetSpeed(MOVE_RUN,Speed,true); + + return true; +} + +//Edit Player Swim Speed +bool ChatHandler::HandleModifySwimCommand(const char* args) +{ + if (!*args) + return false; + + float Swim = (float)atof((char*)args); + + if (Swim > 10.0f || Swim < 0.01f) + { + SendSysMessage(LANG_BAD_VALUE); + SetSentErrorMessage(true); + return false; + } + + Player *chr = getSelectedPlayer(); + if (chr == NULL) + { + SendSysMessage(LANG_NO_CHAR_SELECTED); + SetSentErrorMessage(true); + return false; + } + + if(chr->isInFlight()) + { + PSendSysMessage(LANG_CHAR_IN_FLIGHT,chr->GetName()); + SetSentErrorMessage(true); + return false; + } + + PSendSysMessage(LANG_YOU_CHANGE_SWIM_SPEED, Swim, chr->GetName()); + + if(chr != m_session->GetPlayer()) + ChatHandler(chr).PSendSysMessage(ChatHandler(chr).GetMangosString(LANG_YOURS_SWIM_SPEED_CHANGED), m_session->GetPlayer()->GetName(), Swim); + + chr->SetSpeed(MOVE_SWIM,Swim,true); + + return true; +} + +//Edit Player Walk Speed +bool ChatHandler::HandleModifyBWalkCommand(const char* args) +{ + if (!*args) + return false; + + float BSpeed = (float)atof((char*)args); + + if (BSpeed > 10.0f || BSpeed < 0.1f) + { + SendSysMessage(LANG_BAD_VALUE); + SetSentErrorMessage(true); + return false; + } + + Player *chr = getSelectedPlayer(); + if (chr == NULL) + { + SendSysMessage(LANG_NO_CHAR_SELECTED); + SetSentErrorMessage(true); + return false; + } + + if(chr->isInFlight()) + { + PSendSysMessage(LANG_CHAR_IN_FLIGHT,chr->GetName()); + SetSentErrorMessage(true); + return false; + } + + PSendSysMessage(LANG_YOU_CHANGE_BACK_SPEED, BSpeed, chr->GetName()); + + if(chr != m_session->GetPlayer()) + ChatHandler(chr).PSendSysMessage(ChatHandler(chr).GetMangosString(LANG_YOURS_BACK_SPEED_CHANGED), m_session->GetPlayer()->GetName(), BSpeed); + + chr->SetSpeed(MOVE_WALKBACK,BSpeed,true); + + return true; +} + +//Edit Player Fly +bool ChatHandler::HandleModifyFlyCommand(const char* args) +{ + if (!*args) + return false; + + float FSpeed = (float)atof((char*)args); + + if (FSpeed > 10.0f || FSpeed < 0.1f) + { + SendSysMessage(LANG_BAD_VALUE); + SetSentErrorMessage(true); + return false; + } + + Player *chr = getSelectedPlayer(); + if (chr == NULL) + { + SendSysMessage(LANG_NO_CHAR_SELECTED); + SetSentErrorMessage(true); + return false; + } + + PSendSysMessage(LANG_YOU_CHANGE_FLY_SPEED, FSpeed, chr->GetName()); + + if(chr != m_session->GetPlayer()) + ChatHandler(chr).PSendSysMessage(ChatHandler(chr).GetMangosString(LANG_YOURS_FLY_SPEED_CHANGED), m_session->GetPlayer()->GetName(), FSpeed); + + chr->SetSpeed(MOVE_FLY,FSpeed,true); + + return true; +} + +//Edit Player Scale +bool ChatHandler::HandleModifyScaleCommand(const char* args) +{ + if (!*args) + return false; + + float Scale = (float)atof((char*)args); + if (Scale > 3.0f || Scale <= 0.0f) + { + SendSysMessage(LANG_BAD_VALUE); + SetSentErrorMessage(true); + return false; + } + + Player *chr = getSelectedPlayer(); + if (chr == NULL) + { + SendSysMessage(LANG_NO_CHAR_SELECTED); + SetSentErrorMessage(true); + return false; + } + + PSendSysMessage(LANG_YOU_CHANGE_SIZE, Scale, chr->GetName()); + + if(chr != m_session->GetPlayer()) + ChatHandler(chr).PSendSysMessage(ChatHandler(chr).GetMangosString(LANG_YOURS_SIZE_CHANGED), m_session->GetPlayer()->GetName(), Scale); + + chr->SetFloatValue(OBJECT_FIELD_SCALE_X, Scale); + + return true; +} + +//Enable Player mount +bool ChatHandler::HandleModifyMountCommand(const char* args) +{ + if(!*args) + return false; + + uint16 mId = 1147; + float speed = (float)15; + uint32 num = 0; + + num = atoi((char*)args); + switch(num) + { + case 1: + mId=14340; + break; + case 2: + mId=4806; + break; + case 3: + mId=6471; + break; + case 4: + mId=12345; + break; + case 5: + mId=6472; + break; + case 6: + mId=6473; + break; + case 7: + mId=10670; + break; + case 8: + mId=10719; + break; + case 9: + mId=10671; + break; + case 10: + mId=10672; + break; + case 11: + mId=10720; + break; + case 12: + mId=14349; + break; + case 13: + mId=11641; + break; + case 14: + mId=12244; + break; + case 15: + mId=12242; + break; + case 16: + mId=14578; + break; + case 17: + mId=14579; + break; + case 18: + mId=14349; + break; + case 19: + mId=12245; + break; + case 20: + mId=14335; + break; + case 21: + mId=207; + break; + case 22: + mId=2328; + break; + case 23: + mId=2327; + break; + case 24: + mId=2326; + break; + case 25: + mId=14573; + break; + case 26: + mId=14574; + break; + case 27: + mId=14575; + break; + case 28: + mId=604; + break; + case 29: + mId=1166; + break; + case 30: + mId=2402; + break; + case 31: + mId=2410; + break; + case 32: + mId=2409; + break; + case 33: + mId=2408; + break; + case 34: + mId=2405; + break; + case 35: + mId=14337; + break; + case 36: + mId=6569; + break; + case 37: + mId=10661; + break; + case 38: + mId=10666; + break; + case 39: + mId=9473; + break; + case 40: + mId=9476; + break; + case 41: + mId=9474; + break; + case 42: + mId=14374; + break; + case 43: + mId=14376; + break; + case 44: + mId=14377; + break; + case 45: + mId=2404; + break; + case 46: + mId=2784; + break; + case 47: + mId=2787; + break; + case 48: + mId=2785; + break; + case 49: + mId=2736; + break; + case 50: + mId=2786; + break; + case 51: + mId=14347; + break; + case 52: + mId=14346; + break; + case 53: + mId=14576; + break; + case 54: + mId=9695; + break; + case 55: + mId=9991; + break; + case 56: + mId=6448; + break; + case 57: + mId=6444; + break; + case 58: + mId=6080; + break; + case 59: + mId=6447; + break; + case 60: + mId=4805; + break; + case 61: + mId=9714; + break; + case 62: + mId=6448; + break; + case 63: + mId=6442; + break; + case 64: + mId=14632; + break; + case 65: + mId=14332; + break; + case 66: + mId=14331; + break; + case 67: + mId=8469; + break; + case 68: + mId=2830; + break; + case 69: + mId=2346; + break; + default: + SendSysMessage(LANG_NO_MOUNT); + SetSentErrorMessage(true); + return false; + } + + Player *chr = getSelectedPlayer(); + if (chr == NULL) + { + SendSysMessage(LANG_NO_CHAR_SELECTED); + SetSentErrorMessage(true); + return false; + } + + PSendSysMessage(LANG_YOU_GIVE_MOUNT, chr->GetName()); + + if(chr != m_session->GetPlayer()) + ChatHandler(chr).PSendSysMessage(ChatHandler(chr).GetMangosString(LANG_MOUNT_GIVED), m_session->GetPlayer()->GetName()); + + chr->SetUInt32Value( UNIT_FIELD_FLAGS , 0x001000 ); + chr->Mount(mId); + + WorldPacket data( SMSG_FORCE_RUN_SPEED_CHANGE, (8+4+1+4) ); + data.append(chr->GetPackGUID()); + data << (uint32)0; + data << (uint8)0; //new 2.1.0 + data << float(speed); + chr->SendMessageToSet( &data, true ); + + data.Initialize( SMSG_FORCE_SWIM_SPEED_CHANGE, (8+4+4) ); + data.append(chr->GetPackGUID()); + data << (uint32)0; + data << float(speed); + chr->SendMessageToSet( &data, true ); + + return true; +} + +//Edit Player money +bool ChatHandler::HandleModifyMoneyCommand(const char* args) +{ + if (!*args) + return false; + + Player *chr = getSelectedPlayer(); + if (chr == NULL) + { + SendSysMessage(LANG_NO_CHAR_SELECTED); + SetSentErrorMessage(true); + return false; + } + + int32 addmoney = atoi((char*)args); + + uint32 moneyuser = chr->GetMoney(); + + if(addmoney < 0) + { + int32 newmoney = moneyuser + addmoney; + + sLog.outDetail(GetMangosString(LANG_CURRENT_MONEY), moneyuser, addmoney, newmoney); + if(newmoney <= 0 ) + { + PSendSysMessage(LANG_YOU_TAKE_ALL_MONEY, chr->GetName()); + + if(chr != m_session->GetPlayer()) + ChatHandler(chr).PSendSysMessage(ChatHandler(chr).GetMangosString(LANG_YOURS_ALL_MONEY_GONE), m_session->GetPlayer()->GetName()); + + chr->SetMoney(0); + } + else + { + PSendSysMessage(LANG_YOU_TAKE_MONEY, abs(addmoney), chr->GetName()); + if(chr != m_session->GetPlayer()) + ChatHandler(chr).PSendSysMessage(ChatHandler(chr).GetMangosString(LANG_YOURS_MONEY_TAKEN), m_session->GetPlayer()->GetName(), abs(addmoney)); + chr->SetMoney( newmoney ); + } + } + else + { + PSendSysMessage(LANG_YOU_GIVE_MONEY, addmoney, chr->GetName()); + if(chr != m_session->GetPlayer()) + ChatHandler(chr).PSendSysMessage(ChatHandler(chr).GetMangosString(LANG_YOURS_MONEY_GIVEN), m_session->GetPlayer()->GetName(), addmoney); + chr->ModifyMoney( addmoney ); + } + + sLog.outDetail(GetMangosString(LANG_NEW_MONEY), moneyuser, addmoney, chr->GetMoney() ); + + return true; +} + +//Edit Player field +bool ChatHandler::HandleModifyBitCommand(const char* args) +{ + if( !*args ) + return false; + + Player *chr = getSelectedPlayer(); + if (chr == NULL) + { + SendSysMessage(LANG_NO_CHAR_SELECTED); + SetSentErrorMessage(true); + return false; + } + + char* pField = strtok((char*)args, " "); + if (!pField) + return false; + + char* pBit = strtok(NULL, " "); + if (!pBit) + return false; + + uint16 field = atoi(pField); + uint32 bit = atoi(pBit); + + if (field < 1 || field >= PLAYER_END) + { + SendSysMessage(LANG_BAD_VALUE); + SetSentErrorMessage(true); + return false; + } + + if (bit < 1 || bit > 32) + { + SendSysMessage(LANG_BAD_VALUE); + SetSentErrorMessage(true); + return false; + } + + if ( chr->HasFlag( field, (1<<(bit-1)) ) ) + { + chr->RemoveFlag( field, (1<<(bit-1)) ); + PSendSysMessage(LANG_REMOVE_BIT, bit, field); + } + else + { + chr->SetFlag( field, (1<<(bit-1)) ); + PSendSysMessage(LANG_SET_BIT, bit, field); + } + + return true; +} + +bool ChatHandler::HandleModifyHonorCommand (const char* args) +{ + if (!*args) + return false; + + Player *target = getSelectedPlayer(); + if(!target) + { + SendSysMessage(LANG_PLAYER_NOT_FOUND); + SetSentErrorMessage(true); + return false; + } + + int32 amount = (uint32)atoi(args); + + target->ModifyHonorPoints(amount); + + PSendSysMessage(LANG_COMMAND_MODIFY_HONOR, target->GetName(), target->GetHonorPoints()); + + return true; +} + +bool ChatHandler::HandleTeleCommand(const char * args) +{ + if(!*args) + return false; + + Player* _player = m_session->GetPlayer(); + + // id, or string, or [name] Shift-click form |color|Htele:id|h[name]|h|r + GameTele const* tele = extractGameTeleFromLink((char*)args); + + if (!tele) + { + SendSysMessage(LANG_COMMAND_TELE_NOTFOUND); + SetSentErrorMessage(true); + return false; + } + + // stop flight if need + if(_player->isInFlight()) + { + _player->GetMotionMaster()->MovementExpired(); + _player->m_taxi.ClearTaxiDestinations(); + } + // save only in non-flight case + else + _player->SaveRecallPosition(); + + _player->TeleportTo(tele->mapId, tele->position_x, tele->position_y, tele->position_z, tele->orientation); + return true; +} + +bool ChatHandler::HandleLookupAreaCommand(const char* args) +{ + if(!*args) + return false; + + std::string namepart = args; + std::wstring wnamepart; + + if(!Utf8toWStr(namepart,wnamepart)) + return false; + + uint32 counter = 0; // Counter for figure out that we found smth. + + // converting string that we try to find to lower case + wstrToLower( wnamepart ); + + // Search in AreaTable.dbc + for (uint32 areaflag = 0; areaflag < sAreaStore.GetNumRows(); ++areaflag) + { + AreaTableEntry const *areaEntry = sAreaStore.LookupEntry(areaflag); + if(areaEntry) + { + int loc = m_session->GetSessionDbcLocale(); + std::string name = areaEntry->area_name[loc]; + if(name.empty()) + continue; + + if(!Utf8FitTo(name, wnamepart)) + { + loc = 0; + for(; loc < MAX_LOCALE; ++loc) + { + if(loc==m_session->GetSessionDbcLocale()) + continue; + + name = areaEntry->area_name[loc]; + if(name.empty()) + continue; + + if (Utf8FitTo(name, wnamepart)) + break; + } + } + + if(loc < MAX_LOCALE) + { + // send area in "id - [name]" format + std::ostringstream ss; + ss << areaEntry->ID << " - |cffffffff|Harea:" << areaEntry->ID << "|h[" << name << " " << localeNames[loc]<< "]|h|r"; + + SendSysMessage(ss.str().c_str()); + + ++counter; + } + } + } + if (counter == 0) // if counter == 0 then we found nth + SendSysMessage(LANG_COMMAND_NOAREAFOUND); + return true; +} + +//Find tele in game_tele order by name +bool ChatHandler::HandleLookupTeleCommand(const char * args) +{ + if(!*args) + { + SendSysMessage(LANG_COMMAND_TELE_PARAMETER); + SetSentErrorMessage(true); + return false; + } + char const* str = strtok((char*)args, " "); + if(!str) + return false; + + std::string namepart = str; + std::wstring wnamepart; + + if(!Utf8toWStr(namepart,wnamepart)) + return false; + + // converting string that we try to find to lower case + wstrToLower( wnamepart ); + + GameTeleMap const & teleMap = objmgr.GetGameTeleMap(); + + std::ostringstream reply; + for(GameTeleMap::const_iterator itr = teleMap.begin(); itr != teleMap.end(); ++itr) + { + GameTele const* tele = &itr->second; + + if(tele->wnameLow.find(wnamepart) == std::wstring::npos) + continue; + + reply << " |cffffffff|Htele:"; + reply << itr->first; + reply << "|h["; + reply << tele->name; + reply << "]|h|r\n"; + } + + if(reply.str().empty()) + SendSysMessage(LANG_COMMAND_TELE_NOLOCATION); + else + PSendSysMessage(LANG_COMMAND_TELE_LOCATION,reply.str().c_str()); + + return true; +} + +//Enable\Dissable accept whispers (for GM) +bool ChatHandler::HandleWhispersCommand(const char* args) +{ + if(!*args) + { + PSendSysMessage(LANG_COMMAND_WHISPERACCEPTING, m_session->GetPlayer()->isAcceptWhispers() ? GetMangosString(LANG_ON) : GetMangosString(LANG_OFF)); + return true; + } + + std::string argstr = (char*)args; + // whisper on + if (argstr == "on") + { + m_session->GetPlayer()->SetAcceptWhispers(true); + SendSysMessage(LANG_COMMAND_WHISPERON); + return true; + } + + // whisper off + if (argstr == "off") + { + m_session->GetPlayer()->SetAcceptWhispers(false); + SendSysMessage(LANG_COMMAND_WHISPEROFF); + return true; + } + + SendSysMessage(LANG_USE_BOL); + SetSentErrorMessage(true); + return false; +} + +//Play sound +bool ChatHandler::HandlePlaySoundCommand(const char* args) +{ + // USAGE: .debug playsound #soundid + // #soundid - ID decimal number from SoundEntries.dbc (1st column) + // this file have about 5000 sounds. + // In this realization only caller can hear this sound. + if( *args ) + { + uint32 dwSoundId = atoi((char*)args); + + if( !sSoundEntriesStore.LookupEntry(dwSoundId) ) + { + PSendSysMessage(LANG_SOUND_NOT_EXIST, dwSoundId); + SetSentErrorMessage(true); + return false; + } + + WorldPacket data(SMSG_PLAY_OBJECT_SOUND,4+8); + data << uint32(dwSoundId) << m_session->GetPlayer()->GetGUID(); + m_session->SendPacket(&data); + + PSendSysMessage(LANG_YOU_HEAR_SOUND, dwSoundId); + return true; + } + + return false; +} + +//Save all players in the world +bool ChatHandler::HandleSaveAllCommand(const char* /*args*/) +{ + ObjectAccessor::Instance().SaveAllPlayers(); + SendSysMessage(LANG_PLAYERS_SAVED); + return true; +} + +//Send mail by command +bool ChatHandler::HandleSendMailCommand(const char* args) +{ + if(!*args) + return false; + + char* pName = strtok((char*)args, " "); + char* msgSubject = strtok(NULL, " "); + char* msgText = strtok(NULL, ""); + + if (!msgText) + return false; + + // pName, msgSubject, msgText isn't NUL after prev. check + + std::string name = pName; + std::string subject = msgSubject; + std::string text = msgText; + + if(!normalizePlayerName(name)) + { + SendSysMessage(LANG_PLAYER_NOT_FOUND); + SetSentErrorMessage(true); + return false; + } + + uint64 receiver_guid = objmgr.GetPlayerGUIDByName(name); + + if(!receiver_guid) + return false; + + uint32 mailId = objmgr.GenerateMailID(); + uint32 sender_guidlo = m_session->GetPlayer()->GetGUIDLow(); + uint32 messagetype = MAIL_NORMAL; + uint32 stationery = MAIL_STATIONERY_GM; + uint32 itemTextId = 0; + if (!text.empty()) + { + itemTextId = objmgr.CreateItemText( text ); + } + + Player *receiver = objmgr.GetPlayer(receiver_guid); + + WorldSession::SendMailTo(receiver,messagetype, stationery, sender_guidlo, GUID_LOPART(receiver_guid), subject, itemTextId, NULL, 0, 0, MAIL_CHECK_MASK_NONE); + + PSendSysMessage(LANG_MAIL_SENT, name.c_str()); + return true; +} + +// teleport player to given game_tele.entry +bool ChatHandler::HandleNameTeleCommand(const char * args) +{ + if(!*args) + return false; + + char* pName = strtok((char*)args, " "); + + if(!pName) + return false; + + std::string name = pName; + + if(!normalizePlayerName(name)) + { + SendSysMessage(LANG_PLAYER_NOT_FOUND); + SetSentErrorMessage(true); + return false; + } + + char* tail = strtok(NULL, ""); + if(!tail) + return false; + + // id, or string, or [name] Shift-click form |color|Htele:id|h[name]|h|r + GameTele const* tele = extractGameTeleFromLink(tail); + if(!tele) + { + SendSysMessage(LANG_COMMAND_TELE_NOTFOUND); + SetSentErrorMessage(true); + return false; + } + + Player *chr = objmgr.GetPlayer(name.c_str()); + if (chr) + { + + if(chr->IsBeingTeleported()==true) + { + PSendSysMessage(LANG_IS_TELEPORTED, chr->GetName()); + SetSentErrorMessage(true); + return false; + } + + PSendSysMessage(LANG_TELEPORTING_TO, chr->GetName(),"", tele->name.c_str()); + + if (m_session->GetPlayer()->IsVisibleGloballyFor(chr)) + ChatHandler(chr).PSendSysMessage(LANG_TELEPORTED_TO_BY, m_session->GetPlayer()->GetName()); + + // stop flight if need + if(chr->isInFlight()) + { + chr->GetMotionMaster()->MovementExpired(); + chr->m_taxi.ClearTaxiDestinations(); + } + // save only in non-flight case + else + chr->SaveRecallPosition(); + + chr->TeleportTo(tele->mapId,tele->position_x,tele->position_y,tele->position_z,tele->orientation); + } + else if (uint64 guid = objmgr.GetPlayerGUIDByName(name.c_str())) + { + PSendSysMessage(LANG_TELEPORTING_TO, name.c_str(), GetMangosString(LANG_OFFLINE), tele->name.c_str()); + Player::SavePositionInDB(tele->mapId,tele->position_x,tele->position_y,tele->position_z,tele->orientation,MapManager::Instance().GetZoneId(tele->mapId,tele->position_x,tele->position_y),guid); + } + else + PSendSysMessage(LANG_NO_PLAYER, name.c_str()); + + return true; +} + +//Teleport group to given game_tele.entry +bool ChatHandler::HandleGroupTeleCommand(const char * args) +{ + if(!*args) + return false; + + Player *player = getSelectedPlayer(); + if (!player) + { + SendSysMessage(LANG_NO_CHAR_SELECTED); + SetSentErrorMessage(true); + return false; + } + + // id, or string, or [name] Shift-click form |color|Htele:id|h[name]|h|r + GameTele const* tele = extractGameTeleFromLink((char*)args); + if(!tele) + { + SendSysMessage(LANG_COMMAND_TELE_NOTFOUND); + SetSentErrorMessage(true); + return false; + } + + Group *grp = player->GetGroup(); + if(!grp) + { + PSendSysMessage(LANG_NOT_IN_GROUP,player->GetName()); + SetSentErrorMessage(true); + return false; + } + + for(GroupReference *itr = grp->GetFirstMember(); itr != NULL; itr = itr->next()) + { + Player *pl = itr->getSource(); + + if(!pl || !pl->GetSession() ) + continue; + + if(pl->IsBeingTeleported()) + { + PSendSysMessage(LANG_IS_TELEPORTED, pl->GetName()); + continue; + } + + PSendSysMessage(LANG_TELEPORTING_TO, pl->GetName(),"", tele->name.c_str()); + + if (m_session->GetPlayer() != pl && m_session->GetPlayer()->IsVisibleGloballyFor(pl)) + ChatHandler(pl).PSendSysMessage(LANG_TELEPORTED_TO_BY, m_session->GetPlayer()->GetName()); + + // stop flight if need + if(pl->isInFlight()) + { + pl->GetMotionMaster()->MovementExpired(); + pl->m_taxi.ClearTaxiDestinations(); + } + // save only in non-flight case + else + pl->SaveRecallPosition(); + + pl->TeleportTo(tele->mapId, tele->position_x, tele->position_y, tele->position_z, tele->orientation); + } + + return true; +} + +//Summon group of player +bool ChatHandler::HandleGroupgoCommand(const char* args) +{ + if(!*args) + return false; + + std::string name = args; + + if(!normalizePlayerName(name)) + { + SendSysMessage(LANG_PLAYER_NOT_FOUND); + SetSentErrorMessage(true); + return false; + } + + Player *player = objmgr.GetPlayer(name.c_str()); + if (!player) + { + PSendSysMessage(LANG_NO_PLAYER, args); + SetSentErrorMessage(true); + return false; + } + + Group *grp = player->GetGroup(); + + if(!grp) + { + PSendSysMessage(LANG_NOT_IN_GROUP,player->GetName()); + SetSentErrorMessage(true); + return false; + } + + Map* gmMap = MapManager::Instance().GetMap(m_session->GetPlayer()->GetMapId(),m_session->GetPlayer()); + bool to_instance = gmMap->Instanceable(); + + // we are in instance, and can summon only player in our group with us as lead + if ( to_instance && ( + !m_session->GetPlayer()->GetGroup() || (grp->GetLeaderGUID() != m_session->GetPlayer()->GetGUID()) || + (m_session->GetPlayer()->GetGroup()->GetLeaderGUID() != m_session->GetPlayer()->GetGUID()) ) ) + // the last check is a bit excessive, but let it be, just in case + { + SendSysMessage(LANG_CANNOT_SUMMON_TO_INST); + SetSentErrorMessage(true); + return false; + } + + for(GroupReference *itr = grp->GetFirstMember(); itr != NULL; itr = itr->next()) + { + Player *pl = itr->getSource(); + + if(!pl || pl==m_session->GetPlayer() || !pl->GetSession() ) + continue; + + if(pl->IsBeingTeleported()==true) + { + PSendSysMessage(LANG_IS_TELEPORTED, pl->GetName()); + SetSentErrorMessage(true); + return false; + } + + if (to_instance) + { + Map* plMap = MapManager::Instance().GetMap(pl->GetMapId(),pl); + + if ( plMap->Instanceable() && plMap->GetInstanceId() != gmMap->GetInstanceId() ) + { + // cannot summon from instance to instance + PSendSysMessage(LANG_CANNOT_SUMMON_TO_INST,pl->GetName()); + SetSentErrorMessage(true); + return false; + } + } + + PSendSysMessage(LANG_SUMMONING, pl->GetName(),""); + + if (m_session->GetPlayer()->IsVisibleGloballyFor(pl)) + ChatHandler(pl).PSendSysMessage(LANG_SUMMONED_BY, m_session->GetPlayer()->GetName()); + + // stop flight if need + if(pl->isInFlight()) + { + pl->GetMotionMaster()->MovementExpired(); + pl->m_taxi.ClearTaxiDestinations(); + } + // save only in non-flight case + else + pl->SaveRecallPosition(); + + // before GM + float x,y,z; + m_session->GetPlayer()->GetClosePoint(x,y,z,pl->GetObjectSize()); + pl->TeleportTo(m_session->GetPlayer()->GetMapId(),x,y,z,pl->GetOrientation()); + } + + return true; +} + +//teleport at coordinates +bool ChatHandler::HandleGoXYCommand(const char* args) +{ + if(!*args) + return false; + + Player* _player = m_session->GetPlayer(); + + char* px = strtok((char*)args, " "); + char* py = strtok(NULL, " "); + char* pmapid = strtok(NULL, " "); + + if (!px || !py) + return false; + + float x = (float)atof(px); + float y = (float)atof(py); + uint32 mapid; + if (pmapid) + mapid = (uint32)atoi(pmapid); + else mapid = _player->GetMapId(); + + if(!MapManager::IsValidMapCoord(mapid,x,y)) + { + PSendSysMessage(LANG_INVALID_TARGET_COORD,x,y,mapid); + SetSentErrorMessage(true); + return false; + } + + // stop flight if need + if(_player->isInFlight()) + { + _player->GetMotionMaster()->MovementExpired(); + _player->m_taxi.ClearTaxiDestinations(); + } + // save only in non-flight case + else + _player->SaveRecallPosition(); + + Map const *map = MapManager::Instance().GetBaseMap(mapid); + float z = std::max(map->GetHeight(x, y, MAX_HEIGHT), map->GetWaterLevel(x, y)); + + _player->TeleportTo(mapid, x, y, z, _player->GetOrientation()); + + return true; +} + +//teleport at coordinates, including Z +bool ChatHandler::HandleGoXYZCommand(const char* args) +{ + if(!*args) + return false; + + Player* _player = m_session->GetPlayer(); + + char* px = strtok((char*)args, " "); + char* py = strtok(NULL, " "); + char* pz = strtok(NULL, " "); + char* pmapid = strtok(NULL, " "); + + if (!px || !py || !pz) + return false; + + float x = (float)atof(px); + float y = (float)atof(py); + float z = (float)atof(pz); + uint32 mapid; + if (pmapid) + mapid = (uint32)atoi(pmapid); + else + mapid = _player->GetMapId(); + + if(!MapManager::IsValidMapCoord(mapid,x,y,z)) + { + PSendSysMessage(LANG_INVALID_TARGET_COORD,x,y,mapid); + SetSentErrorMessage(true); + return false; + } + + // stop flight if need + if(_player->isInFlight()) + { + _player->GetMotionMaster()->MovementExpired(); + _player->m_taxi.ClearTaxiDestinations(); + } + // save only in non-flight case + else + _player->SaveRecallPosition(); + + _player->TeleportTo(mapid, x, y, z, _player->GetOrientation()); + + return true; +} + +//teleport at coordinates +bool ChatHandler::HandleGoZoneXYCommand(const char* args) +{ + if(!*args) + return false; + + Player* _player = m_session->GetPlayer(); + + char* px = strtok((char*)args, " "); + char* py = strtok(NULL, " "); + char* tail = strtok(NULL,""); + + char* cAreaId = extractKeyFromLink(tail,"Harea"); // string or [name] Shift-click form |color|Harea:area_id|h[name]|h|r + + if (!px || !py) + return false; + + float x = (float)atof(px); + float y = (float)atof(py); + uint32 areaid = cAreaId ? (uint32)atoi(cAreaId) : _player->GetZoneId(); + + AreaTableEntry const* areaEntry = GetAreaEntryByAreaID(areaid); + + if( x<0 || x>100 || y<0 || y>100 || !areaEntry ) + { + PSendSysMessage(LANG_INVALID_ZONE_COORD,x,y,areaid); + SetSentErrorMessage(true); + return false; + } + + // update to parent zone if exist (client map show only zones without parents) + AreaTableEntry const* zoneEntry = areaEntry->zone ? GetAreaEntryByAreaID(areaEntry->zone) : areaEntry; + + Map const *map = MapManager::Instance().GetBaseMap(zoneEntry->mapid); + + if(map->Instanceable()) + { + PSendSysMessage(LANG_INVALID_ZONE_MAP,areaEntry->ID,areaEntry->area_name[m_session->GetSessionDbcLocale()],map->GetId(),map->GetMapName()); + SetSentErrorMessage(true); + return false; + } + + Zone2MapCoordinates(x,y,zoneEntry->ID); + + if(!MapManager::IsValidMapCoord(zoneEntry->mapid,x,y)) + { + PSendSysMessage(LANG_INVALID_TARGET_COORD,x,y,zoneEntry->mapid); + SetSentErrorMessage(true); + return false; + } + + // stop flight if need + if(_player->isInFlight()) + { + _player->GetMotionMaster()->MovementExpired(); + _player->m_taxi.ClearTaxiDestinations(); + } + // save only in non-flight case + else + _player->SaveRecallPosition(); + + float z = std::max(map->GetHeight(x, y, MAX_HEIGHT), map->GetWaterLevel(x, y)); + _player->TeleportTo(zoneEntry->mapid, x, y, z, _player->GetOrientation()); + + return true; +} + +//teleport to grid +bool ChatHandler::HandleGoGridCommand(const char* args) +{ + if(!*args) return false; + Player* _player = m_session->GetPlayer(); + + char* px = strtok((char*)args, " "); + char* py = strtok(NULL, " "); + char* pmapid = strtok(NULL, " "); + + if (!px || !py) + return false; + + float grid_x = (float)atof(px); + float grid_y = (float)atof(py); + uint32 mapid; + if (pmapid) + mapid = (uint32)atoi(pmapid); + else mapid = _player->GetMapId(); + + // center of grid + float x = (grid_x-CENTER_GRID_ID+0.5f)*SIZE_OF_GRIDS; + float y = (grid_y-CENTER_GRID_ID+0.5f)*SIZE_OF_GRIDS; + + if(!MapManager::IsValidMapCoord(mapid,x,y)) + { + PSendSysMessage(LANG_INVALID_TARGET_COORD,x,y,mapid); + SetSentErrorMessage(true); + return false; + } + + // stop flight if need + if(_player->isInFlight()) + { + _player->GetMotionMaster()->MovementExpired(); + _player->m_taxi.ClearTaxiDestinations(); + } + // save only in non-flight case + else + _player->SaveRecallPosition(); + + Map const *map = MapManager::Instance().GetBaseMap(mapid); + float z = std::max(map->GetHeight(x, y, MAX_HEIGHT), map->GetWaterLevel(x, y)); + _player->TeleportTo(mapid, x, y, z, _player->GetOrientation()); + + return true; +} + +bool ChatHandler::HandleDrunkCommand(const char* args) +{ + if(!*args) return false; + + uint32 drunklevel = (uint32)atoi(args); + if(drunklevel > 100) + drunklevel = 100; + + uint16 drunkMod = drunklevel * 0xFFFF / 100; + + m_session->GetPlayer()->SetDrunkValue(drunkMod); + + return true; +} diff --git a/src/game/Level2.cpp b/src/game/Level2.cpp index 63ad2a7a0b9..d3457d19493 100644 --- a/src/game/Level2.cpp +++ b/src/game/Level2.cpp @@ -1,3948 +1,4046 @@ -/* - * Copyright (C) 2005-2008 MaNGOS - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "Common.h" -#include "Database/DatabaseEnv.h" -#include "WorldPacket.h" -#include "WorldSession.h" -#include "World.h" -#include "ObjectMgr.h" -#include "Player.h" -#include "Item.h" -#include "GameObject.h" -#include "Opcodes.h" -#include "Chat.h" -#include "ObjectAccessor.h" -#include "MapManager.h" -#include "Language.h" -#include "World.h" -#include "GameEvent.h" -#include "SpellMgr.h" -#include "WaypointManager.h" -#include "Util.h" -#include -#include -#include -#include - -static uint32 ReputationRankStrIndex[MAX_REPUTATION_RANK] = -{ - LANG_REP_HATED, LANG_REP_HOSTILE, LANG_REP_UNFRIENDLY, LANG_REP_NEUTRAL, - LANG_REP_FRIENDLY, LANG_REP_HONORED, LANG_REP_REVERED, LANG_REP_EXALTED -}; - -//mute player for some times -bool ChatHandler::HandleMuteCommand(const char* args) -{ - if (!*args) - return false; - - char *charname = strtok((char*)args, " "); - if (!charname) - return false; - - std::string cname = charname; - - char *timetonotspeak = strtok(NULL, " "); - if(!timetonotspeak) - return false; - - uint32 notspeaktime = (uint32) atoi(timetonotspeak); - - if(!normalizePlayerName(cname)) - { - SendSysMessage(LANG_PLAYER_NOT_FOUND); - SetSentErrorMessage(true); - return false; - } - - uint64 guid = objmgr.GetPlayerGUIDByName(cname.c_str()); - if(!guid) - { - SendSysMessage(LANG_PLAYER_NOT_FOUND); - SetSentErrorMessage(true); - return false; - } - - Player *chr = objmgr.GetPlayer(guid); - - // check security - uint32 account_id = 0; - uint32 security = 0; - - if (chr) - { - account_id = chr->GetSession()->GetAccountId(); - security = chr->GetSession()->GetSecurity(); - } - else - { - account_id = objmgr.GetPlayerAccountIdByGUID(guid); - security = objmgr.GetSecurityByAccount(account_id); - } - - if(security >= m_session->GetSecurity()) - { - SendSysMessage(LANG_YOURS_SECURITY_IS_LOW); - SetSentErrorMessage(true); - return false; - } - - time_t mutetime = time(NULL) + notspeaktime*60; - - if (chr) - chr->GetSession()->m_muteTime = mutetime; - - loginDatabase.PExecute("UPDATE account SET mutetime = " I64FMTD " WHERE id = '%u'",uint64(mutetime), account_id ); - - if(chr) - ChatHandler(chr).PSendSysMessage(LANG_YOUR_CHAT_DISABLED, notspeaktime); - - PSendSysMessage(LANG_YOU_DISABLE_CHAT, cname.c_str(), notspeaktime); - - return true; -} - -//unmute player -bool ChatHandler::HandleUnmuteCommand(const char* args) -{ - if (!*args) - return false; - - char *charname = strtok((char*)args, " "); - if (!charname) - return false; - - std::string cname = charname; - - if(!normalizePlayerName(cname)) - { - SendSysMessage(LANG_PLAYER_NOT_FOUND); - SetSentErrorMessage(true); - return false; - } - - uint64 guid = objmgr.GetPlayerGUIDByName(cname.c_str()); - if(!guid) - { - SendSysMessage(LANG_PLAYER_NOT_FOUND); - SetSentErrorMessage(true); - return false; - } - - Player *chr = objmgr.GetPlayer(guid); - - // check security - uint32 account_id = 0; - uint32 security = 0; - - if (chr) - { - account_id = chr->GetSession()->GetAccountId(); - security = chr->GetSession()->GetSecurity(); - } - else - { - account_id = objmgr.GetPlayerAccountIdByGUID(guid); - security = objmgr.GetSecurityByAccount(account_id); - } - - if(security >= m_session->GetSecurity()) - { - SendSysMessage(LANG_YOURS_SECURITY_IS_LOW); - SetSentErrorMessage(true); - return false; - } - - if (chr) - { - if(chr->CanSpeak()) - { - SendSysMessage(LANG_CHAT_ALREADY_ENABLED); - SetSentErrorMessage(true); - return false; - } - - chr->GetSession()->m_muteTime = 0; - } - - loginDatabase.PExecute("UPDATE account SET mutetime = '0' WHERE id = '%u'", account_id ); - - if(chr) - ChatHandler(chr).PSendSysMessage(LANG_YOUR_CHAT_ENABLED); - - PSendSysMessage(LANG_YOU_ENABLE_CHAT, cname.c_str()); - return true; -} - -bool ChatHandler::HandleTargetObjectCommand(const char* args) -{ - Player* pl = m_session->GetPlayer(); - QueryResult *result; - GameEvent::ActiveEvents const& activeEventsList = gameeventmgr.GetActiveEventList(); - if(*args) - { - int32 id = atoi((char*)args); - if(id) - result = WorldDatabase.PQuery("SELECT guid, id, position_x, position_y, position_z, orientation, map, (POW(position_x - '%f', 2) + POW(position_y - '%f', 2) + POW(position_z - '%f', 2)) AS order_ FROM gameobject WHERE map = '%i' AND id = '%u' ORDER BY order_ ASC LIMIT 1", - pl->GetPositionX(), pl->GetPositionY(), pl->GetPositionZ(), pl->GetMapId(),id); - else - { - std::string name = args; - WorldDatabase.escape_string(name); - result = WorldDatabase.PQuery( - "SELECT guid, id, position_x, position_y, position_z, orientation, map, (POW(position_x - %f, 2) + POW(position_y - %f, 2) + POW(position_z - %f, 2)) AS order_ " - "FROM gameobject,gameobject_template WHERE gameobject_template.entry = gameobject.id AND map = %i AND name "_LIKE_" '""%%%s%%""' ORDER BY order_ ASC LIMIT 1", - pl->GetPositionX(), pl->GetPositionY(), pl->GetPositionZ(), pl->GetMapId(),name.c_str()); - } - } - else - { - std::ostringstream eventFilter; - eventFilter << " AND (event IS NULL "; - bool initString = true; - - for (GameEvent::ActiveEvents::const_iterator itr = activeEventsList.begin(); itr != activeEventsList.end(); ++itr) - { - if (initString) - { - eventFilter << "OR event IN (" <<*itr; - initString =false; - } - else - eventFilter << "," << *itr; - } - - if (!initString) - eventFilter << "))"; - else - eventFilter << ")"; - - result = WorldDatabase.PQuery("SELECT gameobject.guid, id, position_x, position_y, position_z, orientation, map, " - "(POW(position_x - %f, 2) + POW(position_y - %f, 2) + POW(position_z - %f, 2)) AS order_ FROM gameobject " - "LEFT OUTER JOIN game_event_gameobject on gameobject.guid=game_event_gameobject.guid WHERE map = '%i' %s ORDER BY order_ ASC LIMIT 1", - m_session->GetPlayer()->GetPositionX(), m_session->GetPlayer()->GetPositionY(), m_session->GetPlayer()->GetPositionZ(), m_session->GetPlayer()->GetMapId(),eventFilter.str().c_str()); - } - - if (!result) - { - SendSysMessage(LANG_COMMAND_TARGETOBJNOTFOUND); - return true; - } - - Field *fields = result->Fetch(); - uint32 lowguid = fields[0].GetUInt32(); - uint32 id = fields[1].GetUInt32(); - float x = fields[2].GetFloat(); - float y = fields[3].GetFloat(); - float z = fields[4].GetFloat(); - float o = fields[5].GetFloat(); - int mapid = fields[6].GetUInt16(); - delete result; - - GameObjectInfo const* goI = objmgr.GetGameObjectInfo(id); - - if (!goI) - { - PSendSysMessage(LANG_GAMEOBJECT_NOT_EXIST,id); - return false; - } - - GameObject* target = ObjectAccessor::GetGameObject(*m_session->GetPlayer(),MAKE_NEW_GUID(lowguid,id,HIGHGUID_GAMEOBJECT)); - - PSendSysMessage(LANG_GAMEOBJECT_DETAIL, lowguid, goI->name, lowguid, id, x, y, z, mapid, o); - - if(target) - { - int32 curRespawnDelay = target->GetRespawnTimeEx()-time(NULL); - if(curRespawnDelay < 0) - curRespawnDelay = 0; - - std::string curRespawnDelayStr = secsToTimeString(curRespawnDelay,true); - std::string defRespawnDelayStr = secsToTimeString(target->GetRespawnDelay(),true); - - PSendSysMessage(LANG_COMMAND_RAWPAWNTIMES, defRespawnDelayStr.c_str(),curRespawnDelayStr.c_str()); - } - return true; -} - -//teleport to gameobject -bool ChatHandler::HandleGoObjectCommand(const char* args) -{ - if(!*args) - return false; - - Player* _player = m_session->GetPlayer(); - - // number or [name] Shift-click form |color|Hgameobject:go_guid|h[name]|h|r - char* cId = extractKeyFromLink((char*)args,"Hgameobject"); - if(!cId) - return false; - - int32 guid = atoi(cId); - if(!guid) - return false; - - float x, y, z, ort; - int mapid; - - // by DB guid - if (GameObjectData const* go_data = objmgr.GetGOData(guid)) - { - x = go_data->posX; - y = go_data->posY; - z = go_data->posZ; - ort = go_data->orientation; - mapid = go_data->mapid; - } - else - { - SendSysMessage(LANG_COMMAND_GOOBJNOTFOUND); - SetSentErrorMessage(true); - return false; - } - - if(!MapManager::IsValidMapCoord(mapid,x,y,z,ort)) - { - PSendSysMessage(LANG_INVALID_TARGET_COORD,x,y,mapid); - SetSentErrorMessage(true); - return false; - } - - // stop flight if need - if(_player->isInFlight()) - { - _player->GetMotionMaster()->MovementExpired(); - _player->m_taxi.ClearTaxiDestinations(); - } - // save only in non-flight case - else - _player->SaveRecallPosition(); - - _player->TeleportTo(mapid, x, y, z, ort); - return true; -} - -bool ChatHandler::HandleGoTriggerCommand(const char* args) -{ - Player* _player = m_session->GetPlayer(); - - if (!*args) - return false; - - char *atId = strtok((char*)args, " "); - if (!atId) - return false; - - int32 i_atId = atoi(atId); - - if(!i_atId) - return false; - - AreaTriggerEntry const* at = sAreaTriggerStore.LookupEntry(i_atId); - if (!at) - { - PSendSysMessage(LANG_COMMAND_GOAREATRNOTFOUND,i_atId); - SetSentErrorMessage(true); - return false; - } - - if(!MapManager::IsValidMapCoord(at->mapid,at->x,at->y,at->z)) - { - PSendSysMessage(LANG_INVALID_TARGET_COORD,at->x,at->y,at->mapid); - SetSentErrorMessage(true); - return false; - } - - // stop flight if need - if(_player->isInFlight()) - { - _player->GetMotionMaster()->MovementExpired(); - _player->m_taxi.ClearTaxiDestinations(); - } - // save only in non-flight case - else - _player->SaveRecallPosition(); - - _player->TeleportTo(at->mapid, at->x, at->y, at->z, _player->GetOrientation()); - return true; -} - -bool ChatHandler::HandleGoGraveyardCommand(const char* args) -{ - Player* _player = m_session->GetPlayer(); - - if (!*args) - return false; - - char *gyId = strtok((char*)args, " "); - if (!gyId) - return false; - - int32 i_gyId = atoi(gyId); - - if(!i_gyId) - return false; - - WorldSafeLocsEntry const* gy = sWorldSafeLocsStore.LookupEntry(i_gyId); - if (!gy) - { - PSendSysMessage(LANG_COMMAND_GRAVEYARDNOEXIST,i_gyId); - SetSentErrorMessage(true); - return false; - } - - if(!MapManager::IsValidMapCoord(gy->map_id,gy->x,gy->y,gy->z)) - { - PSendSysMessage(LANG_INVALID_TARGET_COORD,gy->x,gy->y,gy->map_id); - SetSentErrorMessage(true); - return false; - } - - // stop flight if need - if(_player->isInFlight()) - { - _player->GetMotionMaster()->MovementExpired(); - _player->m_taxi.ClearTaxiDestinations(); - } - // save only in non-flight case - else - _player->SaveRecallPosition(); - - _player->TeleportTo(gy->map_id, gy->x, gy->y, gy->z, _player->GetOrientation()); - return true; -} - -/** \brief Teleport the GM to the specified creature - * - * .gocreature --> TP using creature.guid - * .gocreature azuregos --> TP player to the mob with this name - * Warning: If there is more than one mob with this name - * you will be teleported to the first one that is found. - * .gocreature id 6109 --> TP player to the mob, that has this creature_template.entry - * Warning: If there is more than one mob with this "id" - * you will be teleported to the first one that is found. - */ -//teleport to creature -bool ChatHandler::HandleGoCreatureCommand(const char* args) -{ - if(!*args) - return false; - Player* _player = m_session->GetPlayer(); - - // "id" or number or [name] Shift-click form |color|Hcreature_entry:creature_id|h[name]|h|r - char* pParam1 = extractKeyFromLink((char*)args,"Hcreature"); - if (!pParam1) - return false; - - std::ostringstream whereClause; - - // User wants to teleport to the NPC's template entry - if( strcmp(pParam1, "id") == 0 ) - { - //sLog.outError("DEBUG: ID found"); - - // Get the "creature_template.entry" - // number or [name] Shift-click form |color|Hcreature_entry:creature_id|h[name]|h|r - char* tail = strtok(NULL,""); - if(!tail) - return false; - char* cId = extractKeyFromLink(tail,"Hcreature_entry"); - if(!cId) - return false; - - int32 tEntry = atoi(cId); - //sLog.outError("DEBUG: ID value: %d", tEntry); - if(!tEntry) - return false; - - whereClause << "WHERE id = '" << tEntry << "'"; - } - else - { - //sLog.outError("DEBUG: ID *not found*"); - - int32 guid = atoi(pParam1); - - // Number is invalid - maybe the user specified the mob's name - if(!guid) - { - std::string name = pParam1; - WorldDatabase.escape_string(name); - whereClause << ", creature_template WHERE creature.id = creature_template.entry AND creature_template.name "_LIKE_" '" << name << "'"; - } - else - { - whereClause << "WHERE guid = '" << guid << "'"; - } - } - //sLog.outError("DEBUG: %s", whereClause.c_str()); - - QueryResult *result = WorldDatabase.PQuery("SELECT position_x,position_y,position_z,orientation,map FROM creature %s", whereClause.str().c_str() ); - if (!result) - { - SendSysMessage(LANG_COMMAND_GOCREATNOTFOUND); - SetSentErrorMessage(true); - return false; - } - if( result->GetRowCount() > 1 ) - { - SendSysMessage(LANG_COMMAND_GOCREATMULTIPLE); - } - - Field *fields = result->Fetch(); - float x = fields[0].GetFloat(); - float y = fields[1].GetFloat(); - float z = fields[2].GetFloat(); - float ort = fields[3].GetFloat(); - int mapid = fields[4].GetUInt16(); - - delete result; - - if(!MapManager::IsValidMapCoord(mapid,x,y,z,ort)) - { - PSendSysMessage(LANG_INVALID_TARGET_COORD,x,y,mapid); - SetSentErrorMessage(true); - return false; - } - - // stop flight if need - if(_player->isInFlight()) - { - _player->GetMotionMaster()->MovementExpired(); - _player->m_taxi.ClearTaxiDestinations(); - } - // save only in non-flight case - else - _player->SaveRecallPosition(); - - _player->TeleportTo(mapid, x, y, z, ort); - return true; -} - -bool ChatHandler::HandleGUIDCommand(const char* /*args*/) -{ - uint64 guid = m_session->GetPlayer()->GetSelection(); - - if (guid == 0) - { - SendSysMessage(LANG_NO_SELECTION); - SetSentErrorMessage(true); - return false; - } - - PSendSysMessage(LANG_OBJECT_GUID, GUID_LOPART(guid), GUID_HIPART(guid)); - return true; -} - -bool ChatHandler::HandleLookupFactionCommand(const char* args) -{ - if(!*args) - return false; - - Player *target = getSelectedPlayer(); - if (!target) - { - SendSysMessage(LANG_NO_CHAR_SELECTED); - SetSentErrorMessage(true); - return false; - } - - std::string namepart = args; - std::wstring wnamepart; - - if(!Utf8toWStr(namepart,wnamepart)) - return false; - - // converting string that we try to find to lower case - wstrToLower( wnamepart ); - - uint32 counter = 0; // Counter for figure out that we found smth. - - for (uint32 id = 0; id < sFactionStore.GetNumRows(); id++) - //for(FactionStateList::const_iterator itr = target->m_factions.begin(); itr != target->m_factions.end(); ++itr) - { - FactionEntry const *factionEntry = sFactionStore.LookupEntry(id); - //FactionEntry const *factionEntry = sFactionStore.LookupEntry(itr->second.ID); - if (factionEntry) - { - FactionStateList::const_iterator repItr = target->m_factions.find(factionEntry->reputationListID); - - int loc = m_session->GetSessionDbcLocale(); - std::string name = factionEntry->name[loc]; - if(name.empty()) - continue; - - if (!Utf8FitTo(name, wnamepart)) - { - loc = 0; - for(; loc < MAX_LOCALE; ++loc) - { - if(loc==m_session->GetSessionDbcLocale()) - continue; - - name = factionEntry->name[loc]; - if(name.empty()) - continue; - - if (Utf8FitTo(name, wnamepart)) - break; - } - } - - if(loc < MAX_LOCALE) - { - // send faction in "id - [faction] rank reputation [visible] [at war] [own team] [unknown] [invisible] [inactive]" format - // or "id - [faction] [no reputation]" format - std::ostringstream ss; - ss << id << " - |cffffffff|Hfaction:" << id << "|h[" << name << " " << localeNames[loc] << "]|h|r"; - - if (repItr != target->m_factions.end()) - { - ReputationRank rank = target->GetReputationRank(factionEntry); - std::string rankName = GetMangosString(ReputationRankStrIndex[rank]); - - ss << " " << rankName << "|h|r (" << target->GetReputation(factionEntry) << ")"; - - if(repItr->second.Flags & FACTION_FLAG_VISIBLE) - ss << GetMangosString(LANG_FACTION_VISIBLE); - if(repItr->second.Flags & FACTION_FLAG_AT_WAR) - ss << GetMangosString(LANG_FACTION_ATWAR); - if(repItr->second.Flags & FACTION_FLAG_PEACE_FORCED) - ss << GetMangosString(LANG_FACTION_PEACE_FORCED); - if(repItr->second.Flags & FACTION_FLAG_HIDDEN) - ss << GetMangosString(LANG_FACTION_HIDDEN); - if(repItr->second.Flags & FACTION_FLAG_INVISIBLE_FORCED) - ss << GetMangosString(LANG_FACTION_INVISIBLE_FORCED); - if(repItr->second.Flags & FACTION_FLAG_INACTIVE) - ss << GetMangosString(LANG_FACTION_INACTIVE); - } - else - ss << GetMangosString(LANG_FACTION_NOREPUTATION); - - SendSysMessage(ss.str().c_str()); - counter++; - } - } - } - - if (counter == 0) // if counter == 0 then we found nth - SendSysMessage(LANG_COMMAND_FACTION_NOTFOUND); - return true; -} - -bool ChatHandler::HandleModifyRepCommand(const char * args) -{ - if (!*args) return false; - - Player* target = NULL; - target = getSelectedPlayer(); - - if(!target) - { - SendSysMessage(LANG_PLAYER_NOT_FOUND); - SetSentErrorMessage(true); - return false; - } - - char* factionTxt = extractKeyFromLink((char*)args,"Hfaction"); - if(!factionTxt) - return false; - - uint32 factionId = atoi(factionTxt); - - int32 amount = 0; - char *rankTxt = strtok(NULL, " "); - if (!factionTxt || !rankTxt) - return false; - - amount = atoi(rankTxt); - if ((amount == 0) && (rankTxt[0] != '-') && !isdigit(rankTxt[0])) - { - std::string rankStr = rankTxt; - std::wstring wrankStr; - if(!Utf8toWStr(rankStr,wrankStr)) - return false; - wstrToLower( wrankStr ); - - int r = 0; - amount = -42000; - for (; r < MAX_REPUTATION_RANK; ++r) - { - std::string rank = GetMangosString(ReputationRankStrIndex[r]); - if(rank.empty()) - continue; - - std::wstring wrank; - if(!Utf8toWStr(rank,wrank)) - continue; - - wstrToLower(wrank); - - if(wrank.substr(0,wrankStr.size())==wrankStr) - { - char *deltaTxt = strtok(NULL, " "); - if (deltaTxt) - { - int32 delta = atoi(deltaTxt); - if ((delta < 0) || (delta > Player::ReputationRank_Length[r] -1)) - { - PSendSysMessage(LANG_COMMAND_FACTION_DELTA, (Player::ReputationRank_Length[r]-1)); - SetSentErrorMessage(true); - return false; - } - amount += delta; - } - break; - } - amount += Player::ReputationRank_Length[r]; - } - if (r >= MAX_REPUTATION_RANK) - { - PSendSysMessage(LANG_COMMAND_FACTION_INVPARAM, rankTxt); - SetSentErrorMessage(true); - return false; - } - } - - FactionEntry const *factionEntry = sFactionStore.LookupEntry(factionId); - - if (!factionEntry) - { - PSendSysMessage(LANG_COMMAND_FACTION_UNKNOWN, factionId); - SetSentErrorMessage(true); - return false; - } - - if (factionEntry->reputationListID < 0) - { - PSendSysMessage(LANG_COMMAND_FACTION_NOREP_ERROR, factionEntry->name[m_session->GetSessionDbcLocale()], factionId); - SetSentErrorMessage(true); - return false; - } - - target->SetFactionReputation(factionEntry,amount); - PSendSysMessage(LANG_COMMAND_MODIFY_REP, factionEntry->name[m_session->GetSessionDbcLocale()], factionId, target->GetName(), target->GetReputation(factionId)); - return true; -} - -bool ChatHandler::HandleNameCommand(const char* args) -{ - /* Temp. disabled - if(!*args) - return false; - - if(strlen((char*)args)>75) - { - PSendSysMessage(LANG_TOO_LONG_NAME, strlen((char*)args)-75); - return true; - } - - for (uint8 i = 0; i < strlen(args); i++) - { - if(!isalpha(args[i]) && args[i]!=' ') - { - SendSysMessage(LANG_CHARS_ONLY); - return false; - } - } - - uint64 guid; - guid = m_session->GetPlayer()->GetSelection(); - if (guid == 0) - { - SendSysMessage(LANG_NO_SELECTION); - return true; - } - - Creature* pCreature = ObjectAccessor::GetCreature(*m_session->GetPlayer(), guid); - - if(!pCreature) - { - SendSysMessage(LANG_SELECT_CREATURE); - return true; - } - - pCreature->SetName(args); - uint32 idname = objmgr.AddCreatureTemplate(pCreature->GetName()); - pCreature->SetUInt32Value(OBJECT_FIELD_ENTRY, idname); - - pCreature->SaveToDB(); - */ - - return true; -} - -bool ChatHandler::HandleSubNameCommand(const char* /*args*/) -{ - /* Temp. disabled - - if(!*args) - args = ""; - - if(strlen((char*)args)>75) - { - - PSendSysMessage(LANG_TOO_LONG_SUBNAME, strlen((char*)args)-75); - return true; - } - - for (uint8 i = 0; i < strlen(args); i++) - { - if(!isalpha(args[i]) && args[i]!=' ') - { - SendSysMessage(LANG_CHARS_ONLY); - return false; - } - } - uint64 guid; - guid = m_session->GetPlayer()->GetSelection(); - if (guid == 0) - { - SendSysMessage(LANG_NO_SELECTION); - return true; - } - - Creature* pCreature = ObjectAccessor::GetCreature(*m_session->GetPlayer(), guid); - - if(!pCreature) - { - SendSysMessage(LANG_SELECT_CREATURE); - return true; - } - - uint32 idname = objmgr.AddCreatureSubName(pCreature->GetName(),args,pCreature->GetUInt32Value(UNIT_FIELD_DISPLAYID)); - pCreature->SetUInt32Value(OBJECT_FIELD_ENTRY, idname); - - pCreature->SaveToDB(); - */ - return true; -} - -//move item to other slot -bool ChatHandler::HandleItemMoveCommand(const char* args) -{ - if(!*args) - return false; - uint8 srcslot, dstslot; - - char* pParam1 = strtok((char*)args, " "); - if (!pParam1) - return false; - - char* pParam2 = strtok(NULL, " "); - if (!pParam2) - return false; - - srcslot = (uint8)atoi(pParam1); - dstslot = (uint8)atoi(pParam2); - - uint16 src = ((INVENTORY_SLOT_BAG_0 << 8) | srcslot); - uint16 dst = ((INVENTORY_SLOT_BAG_0 << 8) | dstslot); - - if(srcslot==dstslot) - return true; - - m_session->GetPlayer()->SwapItem( src, dst ); - - return true; -} - -//add spawn of creature -bool ChatHandler::HandleAddSpwCommand(const char* args) -{ - if(!*args) - return false; - char* charID = strtok((char*)args, " "); - if (!charID) - return false; - - char* team = strtok(NULL, " "); - int32 teamval = 0; - if (team) { teamval = atoi(team); } - if (teamval < 0) { teamval = 0; } - - uint32 id = atoi(charID); - - Player *chr = m_session->GetPlayer(); - float x = chr->GetPositionX(); - float y = chr->GetPositionY(); - float z = chr->GetPositionZ(); - float o = chr->GetOrientation(); - Map *map = chr->GetMap(); - - Creature* pCreature = new Creature; - if (!pCreature->Create(objmgr.GenerateLowGuid(HIGHGUID_UNIT), map, id, (uint32)teamval)) - { - delete pCreature; - return false; - } - - pCreature->Relocate(x,y,z,o); - - if(!pCreature->IsPositionValid()) - { - sLog.outError("ERROR: Creature (guidlow %d, entry %d) not created. Suggested coordinates isn't valid (X: %f Y: %f)",pCreature->GetGUIDLow(),pCreature->GetEntry(),pCreature->GetPositionX(),pCreature->GetPositionY()); - delete pCreature; - return false; - } - - pCreature->SaveToDB(map->GetId(), (1 << map->GetSpawnMode())); - - uint32 db_guid = pCreature->GetDBTableGUIDLow(); - - // To call _LoadGoods(); _LoadQuests(); CreateTrainerSpells(); - pCreature->LoadFromDB(db_guid, map); - - map->Add(pCreature); - objmgr.AddCreatureToGrid(db_guid, objmgr.GetCreatureData(db_guid)); - return true; -} - -bool ChatHandler::HandleDelCreatureCommand(const char* args) -{ - Creature* unit = NULL; - - if(*args) - { - // number or [name] Shift-click form |color|Hcreature:creature_guid|h[name]|h|r - char* cId = extractKeyFromLink((char*)args,"Hcreature"); - if(!cId) - return false; - - uint32 lowguid = atoi(cId); - if(!lowguid) - return false; - - if (CreatureData const* cr_data = objmgr.GetCreatureData(lowguid)) - unit = ObjectAccessor::GetCreature(*m_session->GetPlayer(), MAKE_NEW_GUID(lowguid, cr_data->id, HIGHGUID_UNIT)); - } - else - unit = getSelectedCreature(); - - if(!unit || unit->isPet() || unit->isTotem()) - { - SendSysMessage(LANG_SELECT_CREATURE); - SetSentErrorMessage(true); - return false; - } - - // Delete the creature - unit->CombatStop(); - unit->DeleteFromDB(); - unit->CleanupsBeforeDelete(); - unit->AddObjectToRemoveList(); - - SendSysMessage(LANG_COMMAND_DELCREATMESSAGE); - - return true; -} - -//delete object by selection or guid -bool ChatHandler::HandleDelObjectCommand(const char* args) -{ - // number or [name] Shift-click form |color|Hgameobject:go_guid|h[name]|h|r - char* cId = extractKeyFromLink((char*)args,"Hgameobject"); - if(!cId) - return false; - - uint32 lowguid = atoi(cId); - if(!lowguid) - return false; - - GameObject* obj = NULL; - - // by DB guid - if (GameObjectData const* go_data = objmgr.GetGOData(lowguid)) - obj = GetObjectGlobalyWithGuidOrNearWithDbGuid(lowguid,go_data->id); - - if(!obj) - { - PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, lowguid); - SetSentErrorMessage(true); - return false; - } - - uint64 owner_guid = obj->GetOwnerGUID(); - if(owner_guid) - { - Unit* owner = ObjectAccessor::GetUnit(*m_session->GetPlayer(),owner_guid); - if(!owner && !IS_PLAYER_GUID(owner_guid)) - { - PSendSysMessage(LANG_COMMAND_DELOBJREFERCREATURE, GUID_LOPART(owner_guid), obj->GetGUIDLow()); - SetSentErrorMessage(true); - return false; - } - - owner->RemoveGameObject(obj,false); - } - - obj->SetRespawnTime(0); // not save respawn time - obj->Delete(); - obj->DeleteFromDB(); - - PSendSysMessage(LANG_COMMAND_DELOBJMESSAGE, obj->GetGUIDLow()); - - return true; -} - -//turn selected object -bool ChatHandler::HandleTurnObjectCommand(const char* args) -{ - // number or [name] Shift-click form |color|Hgameobject:go_id|h[name]|h|r - char* cId = extractKeyFromLink((char*)args,"Hgameobject"); - if(!cId) - return false; - - uint32 lowguid = atoi(cId); - if(!lowguid) - return false; - - GameObject* obj = NULL; - - // by DB guid - if (GameObjectData const* go_data = objmgr.GetGOData(lowguid)) - obj = GetObjectGlobalyWithGuidOrNearWithDbGuid(lowguid,go_data->id); - - if(!obj) - { - PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, lowguid); - SetSentErrorMessage(true); - return false; - } - - char* po = strtok(NULL, " "); - float o; - - if (po) - { - o = (float)atof(po); - } - else - { - Player *chr = m_session->GetPlayer(); - o = chr->GetOrientation(); - } - - float rot2 = sin(o/2); - float rot3 = cos(o/2); - - Map* map = MapManager::Instance().GetMap(obj->GetMapId(),obj); - map->Remove(obj,false); - - obj->Relocate(obj->GetPositionX(), obj->GetPositionY(), obj->GetPositionZ(), o); - - obj->SetFloatValue(GAMEOBJECT_FACING, o); - obj->SetFloatValue(GAMEOBJECT_ROTATION+2, rot2); - obj->SetFloatValue(GAMEOBJECT_ROTATION+3, rot3); - - map->Add(obj); - - obj->SaveToDB(); - obj->Refresh(); - - PSendSysMessage(LANG_COMMAND_TURNOBJMESSAGE, obj->GetGUIDLow(), o); - - return true; -} - -//move selected creature -bool ChatHandler::HandleMoveCreatureCommand(const char* args) -{ - uint32 lowguid = 0; - - Creature* pCreature = getSelectedCreature(); - - if(!pCreature) - { - // number or [name] Shift-click form |color|Hcreature:creature_guid|h[name]|h|r - char* cId = extractKeyFromLink((char*)args,"Hcreature"); - if(!cId) - return false; - - uint32 lowguid = atoi(cId); - - /* FIXME: impossibel without entry - if(lowguid) - pCreature = ObjectAccessor::GetCreature(*m_session->GetPlayer(),MAKE_GUID(lowguid,HIGHGUID_UNIT)); - */ - - // Attempting creature load from DB data - if(!pCreature) - { - CreatureData const* data = objmgr.GetCreatureData(lowguid); - if(!data) - { - PSendSysMessage(LANG_COMMAND_CREATGUIDNOTFOUND, lowguid); - SetSentErrorMessage(true); - return false; - } - - uint32 map_id = data->mapid; - - if(m_session->GetPlayer()->GetMapId()!=map_id) - { - PSendSysMessage(LANG_COMMAND_CREATUREATSAMEMAP, lowguid); - SetSentErrorMessage(true); - return false; - } - } - else - { - lowguid = pCreature->GetDBTableGUIDLow(); - } - } - else - { - lowguid = pCreature->GetDBTableGUIDLow(); - } - - float x = m_session->GetPlayer()->GetPositionX(); - float y = m_session->GetPlayer()->GetPositionY(); - float z = m_session->GetPlayer()->GetPositionZ(); - float o = m_session->GetPlayer()->GetOrientation(); - - if (pCreature) - { - if(CreatureData const* data = objmgr.GetCreatureData(pCreature->GetDBTableGUIDLow())) - { - const_cast(data)->posX = x; - const_cast(data)->posY = y; - const_cast(data)->posZ = z; - const_cast(data)->orientation = o; - } - MapManager::Instance().GetMap(pCreature->GetMapId(),pCreature)->CreatureRelocation(pCreature,x, y, z,o); - pCreature->GetMotionMaster()->Initialize(); - if(pCreature->isAlive()) // dead creature will reset movement generator at respawn - { - pCreature->setDeathState(JUST_DIED); - pCreature->Respawn(); - } - } - - WorldDatabase.PExecuteLog("UPDATE creature SET position_x = '%f', position_y = '%f', position_z = '%f', orientation = '%f' WHERE guid = '%u'", x, y, z, o, lowguid); - PSendSysMessage(LANG_COMMAND_CREATUREMOVED); - return true; -} - -//move selected object -bool ChatHandler::HandleMoveObjectCommand(const char* args) -{ - // number or [name] Shift-click form |color|Hgameobject:go_guid|h[name]|h|r - char* cId = extractKeyFromLink((char*)args,"Hgameobject"); - if(!cId) - return false; - - uint32 lowguid = atoi(cId); - if(!lowguid) - return false; - - GameObject* obj = NULL; - - // by DB guid - if (GameObjectData const* go_data = objmgr.GetGOData(lowguid)) - obj = GetObjectGlobalyWithGuidOrNearWithDbGuid(lowguid,go_data->id); - - if(!obj) - { - PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, lowguid); - SetSentErrorMessage(true); - return false; - } - - char* px = strtok(NULL, " "); - char* py = strtok(NULL, " "); - char* pz = strtok(NULL, " "); - - if (!px) - { - Player *chr = m_session->GetPlayer(); - - Map* map = MapManager::Instance().GetMap(obj->GetMapId(),obj); - map->Remove(obj,false); - - obj->Relocate(chr->GetPositionX(), chr->GetPositionY(), chr->GetPositionZ(), obj->GetOrientation()); - obj->SetFloatValue(GAMEOBJECT_POS_X, chr->GetPositionX()); - obj->SetFloatValue(GAMEOBJECT_POS_Y, chr->GetPositionY()); - obj->SetFloatValue(GAMEOBJECT_POS_Z, chr->GetPositionZ()); - - map->Add(obj); - } - else - { - if(!py || !pz) - return false; - - float x = (float)atof(px); - float y = (float)atof(py); - float z = (float)atof(pz); - - if(!MapManager::IsValidMapCoord(obj->GetMapId(),x,y,z)) - { - PSendSysMessage(LANG_INVALID_TARGET_COORD,x,y,obj->GetMapId()); - SetSentErrorMessage(true); - return false; - } - - Map* map = MapManager::Instance().GetMap(obj->GetMapId(),obj); - map->Remove(obj,false); - - obj->Relocate(x, y, z, obj->GetOrientation()); - obj->SetFloatValue(GAMEOBJECT_POS_X, x); - obj->SetFloatValue(GAMEOBJECT_POS_Y, y); - obj->SetFloatValue(GAMEOBJECT_POS_Z, z); - - map->Add(obj); - } - - obj->SaveToDB(); - obj->Refresh(); - - PSendSysMessage(LANG_COMMAND_MOVEOBJMESSAGE, obj->GetGUIDLow()); - - return true; -} - -//demorph player or unit -bool ChatHandler::HandleDeMorphCommand(const char* /*args*/) -{ - Unit *target = getSelectedUnit(); - if(!target) - target = m_session->GetPlayer(); - - target->DeMorph(); - - return true; -} - -//add item in vendorlist -bool ChatHandler::HandleAddVendorItemCommand(const char* args) -{ - if (!*args) - return false; - - Creature* vendor = getSelectedCreature(); - if (!vendor || !vendor->isVendor()) - { - SendSysMessage(LANG_COMMAND_VENDORSELECTION); - SetSentErrorMessage(true); - return false; - } - - char* pitem = extractKeyFromLink((char*)args,"Hitem"); - if (!pitem) - { - SendSysMessage(LANG_COMMAND_NEEDITEMSEND); - SetSentErrorMessage(true); - return false; - } - uint32 itemId = atol(pitem); - - char* fmaxcount = strtok(NULL, " "); //add maxcount, default: 0 - uint32 maxcount = 0; - if (fmaxcount) - maxcount = atol(fmaxcount); - - char* fincrtime = strtok(NULL, " "); //add incrtime, default: 0 - uint32 incrtime = 0; - if (fincrtime) - incrtime = atol(fincrtime); - - char* fextendedcost = strtok(NULL, " "); //add ExtendedCost, default: 0 - uint32 extendedcost = fextendedcost ? atol(fextendedcost) : 0; - - ItemPrototype const *pProto = objmgr.GetItemPrototype(itemId); - if(!pProto) - { - PSendSysMessage(LANG_ITEM_NOT_FOUND, itemId); - SetSentErrorMessage(true); - return false; - } - - if(extendedcost && !sItemExtendedCostStore.LookupEntry(extendedcost)) - { - PSendSysMessage(LANG_BAD_VALUE, extendedcost); - SetSentErrorMessage(true); - return false; - } - - // load vendor items if not yet - vendor->LoadGoods(); - - if(vendor->FindItem(itemId)) - { - PSendSysMessage(LANG_ITEM_ALREADY_IN_LIST,itemId); - SetSentErrorMessage(true); - return false; - } - - if (vendor->GetItemCount() >= MAX_VENDOR_ITEMS) - { - SendSysMessage(LANG_COMMAND_ADDVENDORITEMITEMS); - SetSentErrorMessage(true); - return false; - } - - // add to DB and to current ingame vendor - WorldDatabase.PExecuteLog("INSERT INTO npc_vendor (entry,item,maxcount,incrtime,extendedcost) VALUES('%u','%u','%u','%u','%u')",vendor->GetEntry(), itemId, maxcount,incrtime,extendedcost); - vendor->AddItem(itemId,maxcount,incrtime,extendedcost); - PSendSysMessage(LANG_ITEM_ADDED_TO_LIST,itemId,pProto->Name1,maxcount,incrtime,extendedcost); - return true; -} - -//del item from vendor list -bool ChatHandler::HandleDelVendorItemCommand(const char* args) -{ - if (!*args) - return false; - - Creature* vendor = getSelectedCreature(); - if (!vendor || !vendor->isVendor()) - { - SendSysMessage(LANG_COMMAND_VENDORSELECTION); - SetSentErrorMessage(true); - return false; - } - - char* pitem = extractKeyFromLink((char*)args,"Hitem"); - if (!pitem) - { - SendSysMessage(LANG_COMMAND_NEEDITEMSEND); - SetSentErrorMessage(true); - return false; - } - uint32 itemId = atol(pitem); - - ItemPrototype const *pProto = objmgr.GetItemPrototype(itemId); - if(!pProto) - { - PSendSysMessage(LANG_ITEM_NOT_FOUND, itemId); - SetSentErrorMessage(true); - return false; - } - - // load vendor items if not yet - vendor->LoadGoods(); - - if (!vendor->RemoveItem(itemId)) - { - PSendSysMessage(LANG_ITEM_NOT_IN_LIST,itemId); - SetSentErrorMessage(true); - return false; - } - - WorldDatabase.PExecuteLog("DELETE FROM npc_vendor WHERE entry='%u' AND item='%u'",vendor->GetEntry(), itemId); - PSendSysMessage(LANG_ITEM_DELETED_FROM_LIST,itemId,pProto->Name1); - return true; -} - -//add move for creature -bool ChatHandler::HandleAddMoveCommand(const char* args) -{ - if(!*args) - return false; - - char* guid_str = strtok((char*)args, " "); - char* wait_str = strtok((char*)NULL, " "); - - uint32 lowguid = atoi((char*)guid_str); - - Creature* pCreature = NULL; - - /* FIXME: impossible without entry - if(lowguid) - pCreature = ObjectAccessor::GetCreature(*m_session->GetPlayer(),MAKE_GUID(lowguid,HIGHGUID_UNIT)); - */ - - // attempt check creature existence by DB data - if(!pCreature) - { - CreatureData const* data = objmgr.GetCreatureData(lowguid); - if(!data) - { - PSendSysMessage(LANG_COMMAND_CREATGUIDNOTFOUND, lowguid); - SetSentErrorMessage(true); - return false; - } - } - else - { - // obtain real GUID for DB operations - lowguid = pCreature->GetDBTableGUIDLow(); - } - - int wait = wait_str ? atoi(wait_str) : 0; - - if(wait < 0) - wait = 0; - - Player* player = m_session->GetPlayer(); - - WaypointMgr.AddLastNode(lowguid, player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), player->GetOrientation(), wait, 0); - - // update movement type - WorldDatabase.PExecuteLog("UPDATE creature SET MovementType = '%u' WHERE guid = '%u'", WAYPOINT_MOTION_TYPE,lowguid); - if(pCreature) - { - pCreature->SetDefaultMovementType(WAYPOINT_MOTION_TYPE); - pCreature->GetMotionMaster()->Initialize(); - if(pCreature->isAlive()) // dead creature will reset movement generator at respawn - { - pCreature->setDeathState(JUST_DIED); - pCreature->Respawn(); - } - pCreature->SaveToDB(); - } - - SendSysMessage(LANG_WAYPOINT_ADDED); - - return true; -} - -/** - * Set the movement type for an NPC.
- *
- * Valid movement types are: - *
    - *
  • stay - NPC wont move
  • - *
  • random - NPC will move randomly according to the spawndist
  • - *
  • way - NPC will move with given waypoints set
  • - *
- * additional parameter: NODEL - so no waypoints are deleted, if you - * change the movement type - */ -bool ChatHandler::HandleSetMoveTypeCommand(const char* args) -{ - if(!*args) - return false; - - // 3 arguments: - // GUID (optional - you can also select the creature) - // stay|random|way (determines the kind of movement) - // NODEL (optional - tells the system NOT to delete any waypoints) - // this is very handy if you want to do waypoints, that are - // later switched on/off according to special events (like escort - // quests, etc) - char* guid_str = strtok((char*)args, " "); - char* type_str = strtok((char*)NULL, " "); - char* dontdel_str = strtok((char*)NULL, " "); - - bool doNotDelete = false; - - if(!guid_str) - return false; - - uint32 lowguid = 0; - Creature* pCreature = NULL; - - if( dontdel_str ) - { - //sLog.outError("DEBUG: All 3 params are set"); - - // All 3 params are set - // GUID - // type - // doNotDEL - if( stricmp( dontdel_str, "NODEL" ) == 0 ) - { - //sLog.outError("DEBUG: doNotDelete = true;"); - doNotDelete = true; - } - } - else - { - // Only 2 params - but maybe NODEL is set - if( type_str ) - { - sLog.outError("DEBUG: Only 2 params "); - if( stricmp( type_str, "NODEL" ) == 0 ) - { - //sLog.outError("DEBUG: type_str, NODEL "); - doNotDelete = true; - type_str = NULL; - } - } - } - - if(!type_str) // case .setmovetype $move_type (with selected creature) - { - type_str = guid_str; - pCreature = getSelectedCreature(); - if(!pCreature) - return false; - lowguid = pCreature->GetDBTableGUIDLow(); - } - else // case .setmovetype #creature_guid $move_type (with selected creature) - { - lowguid = atoi((char*)guid_str); - - /* impossible without entry - if(lowguid) - pCreature = ObjectAccessor::GetCreature(*m_session->GetPlayer(),MAKE_GUID(lowguid,HIGHGUID_UNIT)); - */ - - // attempt check creature existence by DB data - if(!pCreature) - { - CreatureData const* data = objmgr.GetCreatureData(lowguid); - if(!data) - { - PSendSysMessage(LANG_COMMAND_CREATGUIDNOTFOUND, lowguid); - SetSentErrorMessage(true); - return false; - } - } - else - { - lowguid = pCreature->GetDBTableGUIDLow(); - } - } - - // now lowguid is low guid really existed creature - // and pCreature point (maybe) to this creature or NULL - - MovementGeneratorType move_type; - - std::string type = type_str; - - if(type == "stay") - move_type = IDLE_MOTION_TYPE; - else if(type == "random") - move_type = RANDOM_MOTION_TYPE; - else if(type == "way") - move_type = WAYPOINT_MOTION_TYPE; - else - return false; - - // update movement type - if(doNotDelete == false) - WaypointMgr.DeletePath(lowguid); - - if(pCreature) - { - pCreature->SetDefaultMovementType(move_type); - pCreature->GetMotionMaster()->Initialize(); - if(pCreature->isAlive()) // dead creature will reset movement generator at respawn - { - pCreature->setDeathState(JUST_DIED); - pCreature->Respawn(); - } - pCreature->SaveToDB(); - } - if( doNotDelete == false ) - { - PSendSysMessage(LANG_MOVE_TYPE_SET,type_str); - } - else - { - PSendSysMessage(LANG_MOVE_TYPE_SET_NODEL,type_str); - } - - return true; -} // HandleSetMoveTypeCommand - -//change level of creature or pet -bool ChatHandler::HandleChangeLevelCommand(const char* args) -{ - if (!*args) - return false; - - uint8 lvl = (uint8) atoi((char*)args); - if ( lvl < 1 || lvl > sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL) + 3) - { - SendSysMessage(LANG_BAD_VALUE); - SetSentErrorMessage(true); - return false; - } - - Creature* pCreature = getSelectedCreature(); - if(!pCreature) - { - SendSysMessage(LANG_SELECT_CREATURE); - SetSentErrorMessage(true); - return false; - } - - if(pCreature->isPet()) - { - ((Pet*)pCreature)->GivePetLevel(lvl); - } - else - { - pCreature->SetMaxHealth( 100 + 30*lvl); - pCreature->SetHealth( 100 + 30*lvl); - pCreature->SetLevel( lvl); - pCreature->SaveToDB(); - } - - return true; -} - -//set npcflag of creature -bool ChatHandler::HandleNPCFlagCommand(const char* args) -{ - if (!*args) - return false; - - uint32 npcFlags = (uint32) atoi((char*)args); - - Creature* pCreature = getSelectedCreature(); - - if(!pCreature) - { - SendSysMessage(LANG_SELECT_CREATURE); - SetSentErrorMessage(true); - return false; - } - - pCreature->SetUInt32Value(UNIT_NPC_FLAGS, npcFlags); - - WorldDatabase.PExecuteLog("UPDATE creature_template SET npcflag = '%u' WHERE entry = '%u'", npcFlags, pCreature->GetEntry()); - - SendSysMessage(LANG_VALUE_SAVED_REJOIN); - - return true; -} - -//set model of creature -bool ChatHandler::HandleSetModelCommand(const char* args) -{ - if (!*args) - return false; - - uint32 displayId = (uint32) atoi((char*)args); - - Creature *pCreature = getSelectedCreature(); - - if(!pCreature) - { - SendSysMessage(LANG_SELECT_CREATURE); - SetSentErrorMessage(true); - return false; - } - - pCreature->SetDisplayId(displayId); - pCreature->SetNativeDisplayId(displayId); - - pCreature->SaveToDB(); - - return true; -} - -//morph creature or player -bool ChatHandler::HandleMorphCommand(const char* args) -{ - if (!*args) - return false; - - uint16 display_id = (uint16)atoi((char*)args); - - Unit *target = getSelectedUnit(); - if(!target) - target = m_session->GetPlayer(); - - target->SetDisplayId(display_id); - - return true; -} - -//set faction of creature or go -bool ChatHandler::HandleFactionIdCommand(const char* args) -{ - if (!*args) - return false; - - uint32 factionId = (uint32) atoi((char*)args); - - if (!sFactionTemplateStore.LookupEntry(factionId)) - { - PSendSysMessage(LANG_WRONG_FACTION, factionId); - SetSentErrorMessage(true); - return false; - } - - Creature* pCreature = getSelectedCreature(); - - if(!pCreature) - { - SendSysMessage(LANG_SELECT_CREATURE); - SetSentErrorMessage(true); - return false; - } - - pCreature->setFaction(factionId); - - // faction is set in creature_template - not inside creature - - // update in memory - if(CreatureInfo const *cinfo = pCreature->GetCreatureInfo()) - { - const_cast(cinfo)->faction_A = factionId; - const_cast(cinfo)->faction_H = factionId; - } - - // and DB - WorldDatabase.PExecuteLog("UPDATE creature_template SET faction_A = '%u', faction_H = '%u' WHERE entry = '%u'", factionId, factionId, pCreature->GetEntry()); - - return true; -} - -//kick player -bool ChatHandler::HandleKickPlayerCommand(const char *args) -{ - char* kickName = strtok((char*)args, " "); - if (!kickName) - { - Player* player = getSelectedPlayer(); - - if(!player) - { - SendSysMessage(LANG_NO_CHAR_SELECTED); - SetSentErrorMessage(true); - return false; - } - - if(player==m_session->GetPlayer()) - { - SendSysMessage(LANG_COMMAND_KICKSELF); - SetSentErrorMessage(true); - return false; - } - - player->GetSession()->KickPlayer(); - } - else - { - std::string name = kickName; - if(!normalizePlayerName(name)) - { - SendSysMessage(LANG_PLAYER_NOT_FOUND); - SetSentErrorMessage(true); - return false; - } - - if(name==m_session->GetPlayer()->GetName()) - { - SendSysMessage(LANG_COMMAND_KICKSELF); - SetSentErrorMessage(true); - return false; - } - - if(sWorld.KickPlayer(name)) - { - PSendSysMessage(LANG_COMMAND_KICKMESSAGE,name.c_str()); - } - else - PSendSysMessage(LANG_COMMAND_KICKNOTFOUNDPLAYER,name.c_str()); - } - - return true; -} - -//show info of player -bool ChatHandler::HandlePInfoCommand(const char* args) -{ - Player* target = NULL; - uint64 targetGUID = 0; - - char* px = strtok((char*)args, " "); - char* py = NULL; - - std::string name; - - if (px) - { - name = px; - - if(name.empty()) - return false; - - if(!normalizePlayerName(name)) - { - SendSysMessage(LANG_PLAYER_NOT_FOUND); - SetSentErrorMessage(true); - return false; - } - - target = objmgr.GetPlayer(name.c_str()); - if (target) - py = strtok(NULL, " "); - else - { - targetGUID = objmgr.GetPlayerGUIDByName(name); - if(targetGUID) - py = strtok(NULL, " "); - else - py = px; - } - } - - if(!target && !targetGUID) - { - target = getSelectedPlayer(); - } - - if(!target && !targetGUID) - { - SendSysMessage(LANG_PLAYER_NOT_FOUND); - SetSentErrorMessage(true); - return false; - } - - uint32 accId = 0; - uint32 money = 0; - uint32 total_player_time = 0; - uint32 level = 0; - uint32 latency = 0; - - // get additional information from Player object - if(target) - { - targetGUID = target->GetGUID(); - name = target->GetName(); // re-read for case getSelectedPlayer() target - accId = target->GetSession()->GetAccountId(); - money = target->GetMoney(); - total_player_time = target->GetTotalPlayedTime(); - level = target->getLevel(); - latency = target->GetSession()->GetLatency(); - } - // get additional information from DB - else - { - accId = objmgr.GetPlayerAccountIdByGUID(targetGUID); - Player plr(m_session); // use current session for temporary load - plr.MinimalLoadFromDB(NULL, targetGUID); - money = plr.GetMoney(); - total_player_time = plr.GetTotalPlayedTime(); - level = plr.getLevel(); - } - - std::string username = GetMangosString(LANG_ERROR); - std::string last_ip = GetMangosString(LANG_ERROR); - uint32 security = 0; - std::string last_login = GetMangosString(LANG_ERROR); - - QueryResult* result = loginDatabase.PQuery("SELECT username,gmlevel,last_ip,last_login FROM account WHERE id = '%u'",accId); - if(result) - { - Field* fields = result->Fetch(); - username = fields[0].GetCppString(); - security = fields[1].GetUInt32(); - if(m_session->GetSecurity() >= security) - { - last_ip = fields[2].GetCppString(); - last_login = fields[3].GetCppString(); - } - else - { - last_ip = "-"; - last_login = "-"; - } - - delete result; - } - - PSendSysMessage(LANG_PINFO_ACCOUNT, (target?"":GetMangosString(LANG_OFFLINE)), name.c_str(), GUID_LOPART(targetGUID), username.c_str(), accId, security, last_ip.c_str(), last_login.c_str(), latency); - - std::string timeStr = secsToTimeString(total_player_time,true,true); - uint32 gold = money /GOLD; - uint32 silv = (money % GOLD) / SILVER; - uint32 copp = (money % GOLD) % SILVER; - PSendSysMessage(LANG_PINFO_LEVEL, timeStr.c_str(), level, gold,silv,copp ); - - if ( py && strncmp(py, "rep", 3) == 0 ) - { - if(!target) - { - // rep option not implemented for offline case - SendSysMessage(LANG_PINFO_NO_REP); - SetSentErrorMessage(true); - return false; - } - - char* FactionName; - for(FactionStateList::const_iterator itr = target->m_factions.begin(); itr != target->m_factions.end(); ++itr) - { - FactionEntry const *factionEntry = sFactionStore.LookupEntry(itr->second.ID); - if (factionEntry) - FactionName = factionEntry->name[m_session->GetSessionDbcLocale()]; - else - FactionName = "#Not found#"; - ReputationRank rank = target->GetReputationRank(factionEntry); - std::string rankName = GetMangosString(ReputationRankStrIndex[rank]); - std::ostringstream ss; - ss << itr->second.ID << ": |cffffffff|Hfaction:" << itr->second.ID << "|h[" << FactionName << "]|h|r " << rankName << "|h|r (" << target->GetReputation(factionEntry) << ")"; - - if(itr->second.Flags & FACTION_FLAG_VISIBLE) - ss << GetMangosString(LANG_FACTION_VISIBLE); - if(itr->second.Flags & FACTION_FLAG_AT_WAR) - ss << GetMangosString(LANG_FACTION_ATWAR); - if(itr->second.Flags & FACTION_FLAG_PEACE_FORCED) - ss << GetMangosString(LANG_FACTION_PEACE_FORCED); - if(itr->second.Flags & FACTION_FLAG_HIDDEN) - ss << GetMangosString(LANG_FACTION_HIDDEN); - if(itr->second.Flags & FACTION_FLAG_INVISIBLE_FORCED) - ss << GetMangosString(LANG_FACTION_INVISIBLE_FORCED); - if(itr->second.Flags & FACTION_FLAG_INACTIVE) - ss << GetMangosString(LANG_FACTION_INACTIVE); - - SendSysMessage(ss.str().c_str()); - } - } - return true; -} - -//show tickets -void ChatHandler::ShowTicket(uint64 guid, char const* text, char const* time) -{ - std::string name; - if(!objmgr.GetPlayerNameByGUID(guid,name)) - name = GetMangosString(LANG_UNKNOWN); - - PSendSysMessage(LANG_COMMAND_TICKETVIEW, name.c_str(),time,text); -} - -//ticket commands -bool ChatHandler::HandleTicketCommand(const char* args) -{ - char* px = strtok((char*)args, " "); - - // ticket - if (!px) - { - size_t count; - QueryResult *result = CharacterDatabase.Query("SELECT COUNT(ticket_id) FROM character_ticket"); - if(result) - { - count = (*result)[0].GetUInt32(); - delete result; - } - else - count = 0; - - PSendSysMessage(LANG_COMMAND_TICKETCOUNT, count, m_session->GetPlayer()->isAcceptTickets() ? GetMangosString(LANG_ON) : GetMangosString(LANG_OFF)); - return true; - } - - // ticket on - if(strncmp(px,"on",3) == 0) - { - m_session->GetPlayer()->SetAcceptTicket(true); - SendSysMessage(LANG_COMMAND_TICKETON); - return true; - } - - // ticket off - if(strncmp(px,"off",4) == 0) - { - m_session->GetPlayer()->SetAcceptTicket(false); - SendSysMessage(LANG_COMMAND_TICKETOFF); - return true; - } - - // ticket #num - int num = atoi(px); - if(num > 0) - { - QueryResult *result = CharacterDatabase.PQuery("SELECT guid,ticket_text,ticket_lastchange FROM character_ticket ORDER BY ticket_id ASC LIMIT %d,1",num-1); - - if(!result) - { - PSendSysMessage(LANG_COMMAND_TICKENOTEXIST, num); - delete result; - SetSentErrorMessage(true); - return false; - } - - Field* fields = result->Fetch(); - - uint64 guid = fields[0].GetUInt64(); - char const* text = fields[1].GetString(); - char const* time = fields[2].GetString(); - - ShowTicket(guid,text,time); - delete result; - return true; - } - - std::string name = px; - - if(!normalizePlayerName(name)) - { - SendSysMessage(LANG_PLAYER_NOT_FOUND); - SetSentErrorMessage(true); - return false; - } - - uint64 guid = objmgr.GetPlayerGUIDByName(name); - - if(!guid) - return false; - - // ticket $char_name - QueryResult *result = CharacterDatabase.PQuery("SELECT ticket_text,ticket_lastchange FROM character_ticket WHERE guid = '%u' ORDER BY ticket_id ASC",GUID_LOPART(guid)); - - if(!result) - return false; - - Field* fields = result->Fetch(); - - char const* text = fields[0].GetString(); - char const* time = fields[1].GetString(); - - ShowTicket(guid,text,time); - delete result; - - return true; -} - -uint32 ChatHandler::GetTicketIDByNum(uint32 num) -{ - QueryResult *result = CharacterDatabase.Query("SELECT ticket_id FROM character_ticket"); - - if(!result || num > result->GetRowCount()) - { - PSendSysMessage(LANG_COMMAND_TICKENOTEXIST, num); - delete result; - return 0; - } - - for(uint32 i = 1; i < num; ++i) - result->NextRow(); - - Field* fields = result->Fetch(); - - uint32 id = fields[0].GetUInt32(); - delete result; - return id; -} - -//dell all tickets -bool ChatHandler::HandleDelTicketCommand(const char *args) -{ - char* px = strtok((char*)args, " "); - if (!px) - return false; - - // delticket all - if(strncmp(px,"all",4) == 0) - { - QueryResult *result = CharacterDatabase.Query("SELECT guid FROM character_ticket"); - - if(!result) - return true; - - // notify players about ticket deleting - do - { - Field* fields = result->Fetch(); - - uint64 guid = fields[0].GetUInt64(); - - if(Player* sender = objmgr.GetPlayer(guid)) - sender->GetSession()->SendGMTicketGetTicket(0x0A,0); - - }while(result->NextRow()); - - delete result; - - CharacterDatabase.PExecute("DELETE FROM character_ticket"); - SendSysMessage(LANG_COMMAND_ALLTICKETDELETED); - return true; - } - - int num = (uint32)atoi(px); - - // delticket #num - if(num > 0) - { - QueryResult *result = CharacterDatabase.PQuery("SELECT ticket_id,guid FROM character_ticket LIMIT %i",num); - - if(!result || uint64(num) > result->GetRowCount()) - { - PSendSysMessage(LANG_COMMAND_TICKENOTEXIST, num); - delete result; - SetSentErrorMessage(true); - return false; - } - - for(int i = 1; i < num; ++i) - result->NextRow(); - - Field* fields = result->Fetch(); - - uint32 id = fields[0].GetUInt32(); - uint64 guid = fields[1].GetUInt64(); - delete result; - - CharacterDatabase.PExecute("DELETE FROM character_ticket WHERE ticket_id = '%u'", id); - - // notify players about ticket deleting - if(Player* sender = objmgr.GetPlayer(guid)) - { - sender->GetSession()->SendGMTicketGetTicket(0x0A,0); - PSendSysMessage(LANG_COMMAND_TICKETPLAYERDEL,sender->GetName()); - } - else - SendSysMessage(LANG_COMMAND_TICKETDEL); - - return true; - } - - std::string name = px; - - if(!normalizePlayerName(name)) - { - SendSysMessage(LANG_PLAYER_NOT_FOUND); - SetSentErrorMessage(true); - return false; - } - - uint64 guid = objmgr.GetPlayerGUIDByName(name); - - if(!guid) - return false; - - // delticket $char_name - CharacterDatabase.PExecute("DELETE FROM character_ticket WHERE guid = '%u'",GUID_LOPART(guid)); - - // notify players about ticket deleting - if(Player* sender = objmgr.GetPlayer(guid)) - sender->GetSession()->SendGMTicketGetTicket(0x0A,0); - - PSendSysMessage(LANG_COMMAND_TICKETPLAYERDEL,px); - return true; -} - -//set spawn dist of creature -bool ChatHandler::HandleSpawnDistCommand(const char* args) -{ - if(!*args) - return false; - - float option = atof((char*)args); - if (option < 0.0f) - { - SendSysMessage(LANG_BAD_VALUE); - return false; - } - - MovementGeneratorType mtype = IDLE_MOTION_TYPE; - if (option >0.0f) - mtype = RANDOM_MOTION_TYPE; - - Creature *pCreature = getSelectedCreature(); - uint32 u_guidlow = 0; - - if (pCreature) - u_guidlow = pCreature->GetDBTableGUIDLow(); - else - return false; - - pCreature->SetRespawnRadius((float)option); - pCreature->SetDefaultMovementType(mtype); - pCreature->GetMotionMaster()->Initialize(); - if(pCreature->isAlive()) // dead creature will reset movement generator at respawn - { - pCreature->setDeathState(JUST_DIED); - pCreature->Respawn(); - } - - WorldDatabase.PExecuteLog("UPDATE creature SET spawndist=%f, MovementType=%i WHERE guid=%u",option,mtype,u_guidlow); - PSendSysMessage(LANG_COMMAND_SPAWNDIST,option); - return true; -} - -bool ChatHandler::HandleSpawnTimeCommand(const char* args) -{ - if(!*args) - return false; - - char* stime = strtok((char*)args, " "); - - if (!stime) - return false; - - int i_stime = atoi((char*)stime); - - if (i_stime < 0) - { - SendSysMessage(LANG_BAD_VALUE); - SetSentErrorMessage(true); - return false; - } - - Creature *pCreature = getSelectedCreature(); - uint32 u_guidlow = 0; - - if (pCreature) - u_guidlow = pCreature->GetDBTableGUIDLow(); - else - return false; - - WorldDatabase.PExecuteLog("UPDATE creature SET spawntimesecs=%i WHERE guid=%u",i_stime,u_guidlow); - pCreature->SetRespawnDelay((uint32)i_stime); - PSendSysMessage(LANG_COMMAND_SPAWNTIME,i_stime); - - return true; -} - -/** - * Add a waypoint to a creature. - * - * The user can either select an npc or provide its GUID. - * - * The user can even select a visual waypoint - then the new waypoint - * is placed *after* the selected one - this makes insertion of new - * waypoints possible. - * - * eg: - * .wp add 12345 - * -> adds a waypoint to the npc with the GUID 12345 - * - * .wp add - * -> adds a waypoint to the currently selected creature - * - * - * @param args if the user did not provide a GUID, it is NULL - * - * @return true - command did succeed, false - something went wrong - */ -bool ChatHandler::HandleWpAddCommand(const char* args) -{ - sLog.outDebug("DEBUG: HandleWpAddCommand"); - - // optional - char* guid_str = NULL; - - if(*args) - { - guid_str = strtok((char*)args, " "); - } - - uint32 lowguid = 0; - uint32 point = 0; - Creature* target = getSelectedCreature(); - // Did player provide a GUID? - if (!guid_str) - { - sLog.outDebug("DEBUG: HandleWpAddCommand - No GUID provided"); - - // No GUID provided - // -> Player must have selected a creature - - if(!target) - { - SendSysMessage(LANG_SELECT_CREATURE); - SetSentErrorMessage(true); - return false; - } - if (target->GetEntry() == VISUAL_WAYPOINT ) - { - sLog.outDebug("DEBUG: HandleWpAddCommand - target->GetEntry() == VISUAL_WAYPOINT (1) "); - - QueryResult *result = - WorldDatabase.PQuery( "SELECT id, point FROM creature_movement WHERE wpguid = %u", - target->GetGUIDLow() ); - if(!result) - { - PSendSysMessage(LANG_WAYPOINT_NOTFOUNDSEARCH, target->GetGUIDLow()); - // User selected a visual spawnpoint -> get the NPC - // Select NPC GUID - // Since we compare float values, we have to deal with - // some difficulties. - // Here we search for all waypoints that only differ in one from 1 thousand - // (0.001) - There is no other way to compare C++ floats with mySQL floats - // See also: http://dev.mysql.com/doc/refman/5.0/en/problems-with-float.html - const char* maxDIFF = "0.01"; - result = WorldDatabase.PQuery( "SELECT id, point FROM creature_movement WHERE (abs(position_x - %f) <= %s ) and (abs(position_y - %f) <= %s ) and (abs(position_z - %f) <= %s )", - target->GetPositionX(), maxDIFF, target->GetPositionY(), maxDIFF, target->GetPositionZ(), maxDIFF); - if(!result) - { - PSendSysMessage(LANG_WAYPOINT_NOTFOUNDDBPROBLEM, target->GetGUIDLow()); - SetSentErrorMessage(true); - return false; - } - } - do - { - Field *fields = result->Fetch(); - lowguid = fields[0].GetUInt32(); - point = fields[1].GetUInt32(); - }while( result->NextRow() ); - delete result; - - CreatureData const* data = objmgr.GetCreatureData(lowguid); - if(!data) - { - PSendSysMessage(LANG_WAYPOINT_CREATNOTFOUND, lowguid); - SetSentErrorMessage(true); - return false; - } - - target = ObjectAccessor::GetCreature(*m_session->GetPlayer(),MAKE_NEW_GUID(lowguid,data->id,HIGHGUID_UNIT)); - if(!target) - { - PSendSysMessage(LANG_WAYPOINT_NOTFOUNDDBPROBLEM, lowguid); - SetSentErrorMessage(true); - return false; - } - } - else - { - lowguid = target->GetDBTableGUIDLow(); - } - } - else - { - sLog.outDebug("DEBUG: HandleWpAddCommand - GUID provided"); - - // GUID provided - // Warn if player also selected a creature - // -> Creature selection is ignored <- - if(target) - { - SendSysMessage(LANG_WAYPOINT_CREATSELECTED); - } - lowguid = atoi((char*)guid_str); - - CreatureData const* data = objmgr.GetCreatureData(lowguid); - if(!data) - { - PSendSysMessage(LANG_WAYPOINT_CREATNOTFOUND, lowguid); - SetSentErrorMessage(true); - return false; - } - - target = ObjectAccessor::GetCreature(*m_session->GetPlayer(),MAKE_NEW_GUID(lowguid,data->id,HIGHGUID_UNIT)); - if(!target) - { - PSendSysMessage(LANG_WAYPOINT_CREATNOTFOUND, lowguid); - SetSentErrorMessage(true); - return false; - } - } - // lowguid -> GUID of the NPC - // point -> number of the waypoint (if not 0) - sLog.outDebug("DEBUG: HandleWpAddCommand - danach"); - - sLog.outDebug("DEBUG: HandleWpAddCommand - point == 0"); - - Player* player = m_session->GetPlayer(); - WaypointMgr.AddLastNode(lowguid, player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), player->GetOrientation(), 0, 0); - - // update movement type - if(target) - { - target->SetDefaultMovementType(WAYPOINT_MOTION_TYPE); - target->GetMotionMaster()->Initialize(); - if(target->isAlive()) // dead creature will reset movement generator at respawn - { - target->setDeathState(JUST_DIED); - target->Respawn(); - } - target->SaveToDB(); - } - else - WorldDatabase.PExecuteLog("UPDATE creature SET MovementType = '%u' WHERE guid = '%u'", WAYPOINT_MOTION_TYPE,lowguid); - - PSendSysMessage(LANG_WAYPOINT_ADDED, point, lowguid); - - return true; -} // HandleWpAddCommand - -/** - * .wp modify emote | spell | text | del | move | add - * - * add -> add a WP after the selected visual waypoint - * User must select a visual waypoint and then issue ".wp modify add" - * - * emote - * User has selected a visual waypoint before. - * is added to this waypoint. Everytime the - * NPC comes to this waypoint, the emote is called. - * - * emote - * User has not selected visual waypoint before. - * For the waypoint for the NPC with - * an emote is added. - * Everytime the NPC comes to this waypoint, the emote is called. - * - * - * info -> User did not select a visual waypoint and - */ -bool ChatHandler::HandleWpModifyCommand(const char* args) -{ - sLog.outDebug("DEBUG: HandleWpModifyCommand"); - - if(!*args) - return false; - - // first arg: add del text emote spell waittime move - char* show_str = strtok((char*)args, " "); - if (!show_str) - { - return false; - } - - std::string show = show_str; - // Check - // Remember: "show" must also be the name of a column! - if( (show != "emote") && (show != "spell") && (show != "text1") && (show != "text2") - && (show != "text3") && (show != "text4") && (show != "text5") - && (show != "waittime") && (show != "del") && (show != "move") && (show != "add") - && (show != "model1") && (show != "model2") && (show != "orientation")) - { - return false; - } - - // Next arg is: - - // Did user provide a GUID - // or did the user select a creature? - // -> variable lowguid is filled with the GUID of the NPC - uint32 lowguid = 0; - uint32 point = 0; - uint32 wpGuid = 0; - Creature* target = getSelectedCreature(); - - if(target) - { - sLog.outDebug("DEBUG: HandleWpModifyCommand - User did select an NPC"); - - // Did the user select a visual spawnpoint? - if (target->GetEntry() != VISUAL_WAYPOINT ) - { - PSendSysMessage(LANG_WAYPOINT_VP_SELECT); - SetSentErrorMessage(true); - return false; - } - - wpGuid = target->GetGUIDLow(); - - // The visual waypoint - QueryResult *result = - WorldDatabase.PQuery( "SELECT id, point FROM creature_movement WHERE wpguid = %u LIMIT 1", - target->GetGUIDLow() ); - if(!result) - { - PSendSysMessage(LANG_WAYPOINT_NOTFOUNDDBPROBLEM, wpGuid); - SetSentErrorMessage(true); - return false; - } - sLog.outDebug("DEBUG: HandleWpModifyCommand - After getting wpGuid"); - - Field *fields = result->Fetch(); - lowguid = fields[0].GetUInt32(); - point = fields[1].GetUInt32(); - - // Cleanup memory - sLog.outDebug("DEBUG: HandleWpModifyCommand - Cleanup memory"); - delete result; - } - else - { - // User did provide - - char* guid_str = strtok((char*)NULL, " "); - if( !guid_str ) - { - SendSysMessage(LANG_WAYPOINT_NOGUID); - return false; - } - lowguid = atoi((char*)guid_str); - - CreatureData const* data = objmgr.GetCreatureData(lowguid); - if(!data) - { - PSendSysMessage(LANG_WAYPOINT_CREATNOTFOUND, lowguid); - SetSentErrorMessage(true); - return false; - } - - PSendSysMessage("DEBUG: GUID provided: %d", lowguid); - - char* point_str = strtok((char*)NULL, " "); - if( !point_str ) - { - SendSysMessage(LANG_WAYPOINT_NOWAYPOINTGIVEN); - return false; - } - point = atoi((char*)point_str); - - PSendSysMessage("DEBUG: wpNumber provided: %d", point); - - // Now we need the GUID of the visual waypoint - // -> "del", "move", "add" command - - QueryResult *result = WorldDatabase.PQuery( "SELECT wpguid FROM creature_movement WHERE id = '%u' AND point = '%u' LIMIT 1", lowguid, point); - if (!result) - { - PSendSysMessage(LANG_WAYPOINT_NOTFOUNDSEARCH, lowguid, point); - SetSentErrorMessage(true); - return false; - } - - Field *fields = result->Fetch(); - wpGuid = fields[0].GetUInt32(); - - // Free memory - delete result; - } - - char* arg_str = NULL; - // Check for argument - if( (show.find("text") == std::string::npos ) && (show != "del") && (show != "move") && (show != "add")) - { - // Text is enclosed in "<>", all other arguments not - if( show.find("text") != std::string::npos ) - arg_str = strtok((char*)NULL, "<>"); - else - arg_str = strtok((char*)NULL, " "); - - if( !arg_str) - { - PSendSysMessage(LANG_WAYPOINT_ARGUMENTREQ, show_str); - return false; - } - } - - sLog.outDebug("DEBUG: HandleWpModifyCommand - Parameters parsed - now execute the command"); - - // wpGuid -> GUID of the waypoint creature - // lowguid -> GUID of the NPC - // point -> waypoint number - - // Special functions: - // add - move - del -> no args commands - // Add a waypoint after the selected visual - if(show == "add" && target) - { - PSendSysMessage("DEBUG: wp modify add, GUID: %u", lowguid); - - // Get the creature for which we read the waypoint - CreatureData const* data = objmgr.GetCreatureData(lowguid); - if(!data) - { - PSendSysMessage(LANG_WAYPOINT_CREATNOTFOUND, lowguid); - SetSentErrorMessage(true); - return false; - } - - Creature* npcCreature = ObjectAccessor::GetCreature(*m_session->GetPlayer(), MAKE_NEW_GUID(lowguid, data->id, HIGHGUID_UNIT)); - - if( !npcCreature ) - { - PSendSysMessage(LANG_WAYPOINT_NPCNOTFOUND); - SetSentErrorMessage(true); - return false; - } - - sLog.outDebug("DEBUG: HandleWpModifyCommand - add -- npcCreature"); - - // What to do: - // Add the visual spawnpoint (DB only) - // Adjust the waypoints - // Respawn the owner of the waypoints - sLog.outDebug("DEBUG: HandleWpModifyCommand - add"); - - Player* chr = m_session->GetPlayer(); - Map *map = chr->GetMap(); - - if(npcCreature) - { - npcCreature->GetMotionMaster()->Initialize(); - if(npcCreature->isAlive()) // dead creature will reset movement generator at respawn - { - npcCreature->setDeathState(JUST_DIED); - npcCreature->Respawn(); - } - } - - // create the waypoint creature - wpGuid = 0; - Creature* wpCreature = new Creature; - if (!wpCreature->Create(objmgr.GenerateLowGuid(HIGHGUID_UNIT), map,VISUAL_WAYPOINT,0)) - { - PSendSysMessage(LANG_WAYPOINT_VP_NOTCREATED, VISUAL_WAYPOINT); - delete wpCreature; - } - else - { - wpCreature->Relocate(chr->GetPositionX(), chr->GetPositionY(), chr->GetPositionZ(), chr->GetOrientation()); - - if(!wpCreature->IsPositionValid()) - { - sLog.outError("ERROR: Creature (guidlow %d, entry %d) not created. Suggested coordinates isn't valid (X: %f Y: %f)",wpCreature->GetGUIDLow(),wpCreature->GetEntry(),wpCreature->GetPositionX(),wpCreature->GetPositionY()); - delete wpCreature; - } - else - { - wpCreature->SaveToDB(map->GetId(), (1 << map->GetSpawnMode())); - // To call _LoadGoods(); _LoadQuests(); CreateTrainerSpells(); - wpCreature->LoadFromDB(wpCreature->GetDBTableGUIDLow(), map); - map->Add(wpCreature); - wpGuid = wpCreature->GetGUIDLow(); - } - } - - WaypointMgr.AddAfterNode(lowguid, point, chr->GetPositionX(), chr->GetPositionY(), chr->GetPositionZ(), 0, 0, wpGuid); - - if(!wpGuid) - return false; - - PSendSysMessage(LANG_WAYPOINT_ADDED_NO, point+1); - return true; - } // add - - if(show == "del" && target) - { - PSendSysMessage("DEBUG: wp modify del, GUID: %u", lowguid); - - // Get the creature for which we read the waypoint - CreatureData const* data = objmgr.GetCreatureData(lowguid); - if(!data) - { - PSendSysMessage(LANG_WAYPOINT_CREATNOTFOUND, lowguid); - SetSentErrorMessage(true); - return false; - } - - Creature* npcCreature = ObjectAccessor::GetCreature(*m_session->GetPlayer(), MAKE_NEW_GUID(lowguid, data->id, HIGHGUID_UNIT)); - - // wpCreature - Creature* wpCreature = NULL; - if( wpGuid != 0 ) - { - wpCreature = ObjectAccessor::GetCreature(*m_session->GetPlayer(),MAKE_NEW_GUID(wpGuid, VISUAL_WAYPOINT, HIGHGUID_UNIT)); - wpCreature->DeleteFromDB(); - wpCreature->CleanupsBeforeDelete(); - wpCreature->AddObjectToRemoveList(); - } - - // What to do: - // Remove the visual spawnpoint - // Adjust the waypoints - // Respawn the owner of the waypoints - - WaypointMgr.DeleteNode(lowguid, point); - - if(npcCreature) - { - // Any waypoints left? - QueryResult *result2 = WorldDatabase.PQuery( "SELECT point FROM creature_movement WHERE id = '%u'",lowguid); - if(!result2) - { - npcCreature->SetDefaultMovementType(RANDOM_MOTION_TYPE); - } - else - { - npcCreature->SetDefaultMovementType(WAYPOINT_MOTION_TYPE); - delete result2; - } - npcCreature->GetMotionMaster()->Initialize(); - if(npcCreature->isAlive()) // dead creature will reset movement generator at respawn - { - npcCreature->setDeathState(JUST_DIED); - npcCreature->Respawn(); - } - npcCreature->SaveToDB(); - } - - PSendSysMessage(LANG_WAYPOINT_REMOVED); - return true; - } // del - - if(show == "move" && target) - { - PSendSysMessage("DEBUG: wp move, GUID: %u", lowguid); - - Player *chr = m_session->GetPlayer(); - Map *map = chr->GetMap(); - { - // Get the creature for which we read the waypoint - CreatureData const* data = objmgr.GetCreatureData(lowguid); - if(!data) - { - PSendSysMessage(LANG_WAYPOINT_CREATNOTFOUND, lowguid); - SetSentErrorMessage(true); - return false; - } - - Creature* npcCreature = ObjectAccessor::GetCreature(*m_session->GetPlayer(), MAKE_NEW_GUID(lowguid, data->id, HIGHGUID_UNIT)); - - // wpCreature - Creature* wpCreature = NULL; - // What to do: - // Move the visual spawnpoint - // Respawn the owner of the waypoints - if( wpGuid != 0 ) - { - wpCreature = ObjectAccessor::GetCreature(*m_session->GetPlayer(),MAKE_NEW_GUID(wpGuid, VISUAL_WAYPOINT, HIGHGUID_UNIT)); - wpCreature->DeleteFromDB(); - wpCreature->CleanupsBeforeDelete(); - wpCreature->AddObjectToRemoveList(); - // re-create - Creature* wpCreature2 = new Creature; - if (!wpCreature2->Create(objmgr.GenerateLowGuid(HIGHGUID_UNIT), map, VISUAL_WAYPOINT, 0)) - { - PSendSysMessage(LANG_WAYPOINT_VP_NOTCREATED, VISUAL_WAYPOINT); - delete wpCreature2; - return false; - } - - wpCreature2->Relocate(chr->GetPositionX(), chr->GetPositionY(), chr->GetPositionZ(), chr->GetOrientation()); - - if(!wpCreature2->IsPositionValid()) - { - sLog.outError("ERROR: Creature (guidlow %d, entry %d) not created. Suggested coordinates isn't valid (X: %f Y: %f)",wpCreature2->GetGUIDLow(),wpCreature2->GetEntry(),wpCreature2->GetPositionX(),wpCreature2->GetPositionY()); - delete wpCreature2; - return false; - } - - wpCreature2->SaveToDB(map->GetId(), (1 << map->GetSpawnMode())); - // To call _LoadGoods(); _LoadQuests(); CreateTrainerSpells(); - wpCreature2->LoadFromDB(wpCreature2->GetDBTableGUIDLow(), map); - map->Add(wpCreature2); - //MapManager::Instance().GetMap(npcCreature->GetMapId())->Add(wpCreature2); - } - - WaypointMgr.SetNodePosition(lowguid, point, chr->GetPositionX(), chr->GetPositionY(), chr->GetPositionZ()); - - if(npcCreature) - { - npcCreature->GetMotionMaster()->Initialize(); - if(npcCreature->isAlive()) // dead creature will reset movement generator at respawn - { - npcCreature->setDeathState(JUST_DIED); - npcCreature->Respawn(); - } - } - PSendSysMessage(LANG_WAYPOINT_CHANGED); - } - return true; - } // move - - // Create creature - npc that has the waypoint - CreatureData const* data = objmgr.GetCreatureData(lowguid); - if(!data) - { - PSendSysMessage(LANG_WAYPOINT_CREATNOTFOUND, lowguid); - SetSentErrorMessage(true); - return false; - } - - WaypointMgr.SetNodeText(lowguid, point, show_str, arg_str); - - Creature* npcCreature = ObjectAccessor::GetCreature(*m_session->GetPlayer(), MAKE_NEW_GUID(lowguid, data->id, HIGHGUID_UNIT)); - if(npcCreature) - { - npcCreature->SetDefaultMovementType(WAYPOINT_MOTION_TYPE); - npcCreature->GetMotionMaster()->Initialize(); - if(npcCreature->isAlive()) // dead creature will reset movement generator at respawn - { - npcCreature->setDeathState(JUST_DIED); - npcCreature->Respawn(); - } - } - PSendSysMessage(LANG_WAYPOINT_CHANGED_NO, show_str); - - return true; -} - -/** - * .wp show info | on | off - * - * info -> User has selected a visual waypoint before - * - * info -> User did not select a visual waypoint and - * provided the GUID of the NPC and the number of - * the waypoint. - * - * on -> User has selected an NPC; all visual waypoints for this - * NPC are added to the world - * - * on -> User did not select an NPC - instead the GUID of the - * NPC is provided. All visual waypoints for this NPC - * are added from the world. - * - * off -> User has selected an NPC; all visual waypoints for this - * NPC are removed from the world. - * - * on -> User did not select an NPC - instead the GUID of the - * NPC is provided. All visual waypoints for this NPC - * are removed from the world. - * - * - */ -bool ChatHandler::HandleWpShowCommand(const char* args) -{ - sLog.outDebug("DEBUG: HandleWpShowCommand"); - - if(!*args) - return false; - - // first arg: on, off, first, last - char* show_str = strtok((char*)args, " "); - if (!show_str) - { - return false; - } - // second arg: GUID (optional, if a creature is selected) - char* guid_str = strtok((char*)NULL, " "); - sLog.outDebug("DEBUG: HandleWpShowCommand: show_str: %s guid_str: %s", show_str, guid_str); - //if (!guid_str) { - // return false; - //} - - // Did user provide a GUID - // or did the user select a creature? - // -> variable lowguid is filled with the GUID - Creature* target = getSelectedCreature(); - // Did player provide a GUID? - if (!guid_str) - { - sLog.outDebug("DEBUG: HandleWpShowCommand: !guid_str"); - // No GUID provided - // -> Player must have selected a creature - - if(!target) - { - SendSysMessage(LANG_SELECT_CREATURE); - SetSentErrorMessage(true); - return false; - } - } - else - { - sLog.outDebug("DEBUG: HandleWpShowCommand: GUID provided"); - // GUID provided - // Warn if player also selected a creature - // -> Creature selection is ignored <- - if(target) - { - SendSysMessage(LANG_WAYPOINT_CREATSELECTED); - } - - uint32 lowguid = atoi((char*)guid_str); - - CreatureData const* data = objmgr.GetCreatureData(lowguid); - if(!data) - { - PSendSysMessage(LANG_WAYPOINT_CREATNOTFOUND, lowguid); - SetSentErrorMessage(true); - return false; - } - - target = ObjectAccessor::GetCreature(*m_session->GetPlayer(),MAKE_NEW_GUID(lowguid,data->id,HIGHGUID_UNIT)); - - if(!target) - { - PSendSysMessage(LANG_WAYPOINT_CREATNOTFOUND, lowguid); - SetSentErrorMessage(true); - return false; - } - } - - uint32 lowguid = target->GetDBTableGUIDLow(); - - std::string show = show_str; - uint32 Maxpoint; - - sLog.outDebug("DEBUG: HandleWpShowCommand: lowguid: %u", lowguid); - - sLog.outDebug("DEBUG: HandleWpShowCommand: Habe creature: %ld", target ); - - sLog.outDebug("DEBUG: HandleWpShowCommand: wpshow - show: %s", show_str); - //PSendSysMessage("wpshow - show: %s", show); - - // Show info for the selected waypoint - if(show == "info") - { - PSendSysMessage("DEBUG: wp info, GUID: %u", lowguid); - - // Check if the user did specify a visual waypoint - if( target->GetEntry() != VISUAL_WAYPOINT ) - { - PSendSysMessage(LANG_WAYPOINT_VP_SELECT); - SetSentErrorMessage(true); - return false; - } - - //PSendSysMessage("wp on, GUID: %u", lowguid); - - //pCreature->GetPositionX(); - - QueryResult *result = - WorldDatabase.PQuery( "SELECT id, point, waittime, emote, spell, text1, text2, text3, text4, text5, model1, model2 FROM creature_movement WHERE wpguid = %u", - target->GetGUID() ); - if(!result) - { - // Since we compare float values, we have to deal with - // some difficulties. - // Here we search for all waypoints that only differ in one from 1 thousand - // (0.001) - There is no other way to compare C++ floats with mySQL floats - // See also: http://dev.mysql.com/doc/refman/5.0/en/problems-with-float.html - const char* maxDIFF = "0.01"; - PSendSysMessage(LANG_WAYPOINT_NOTFOUNDSEARCH, target->GetGUID()); - - result = WorldDatabase.PQuery( "SELECT id, point, waittime, emote, spell, text1, text2, text3, text4, text5, model1, model2 FROM creature_movement WHERE (abs(position_x - %f) <= %s ) and (abs(position_y - %f) <= %s ) and (abs(position_z - %f) <= %s )", - target->GetPositionX(), maxDIFF, target->GetPositionY(), maxDIFF, target->GetPositionZ(), maxDIFF); - if(!result) - { - PSendSysMessage(LANG_WAYPOINT_NOTFOUNDDBPROBLEM, lowguid); - SetSentErrorMessage(true); - return false; - } - } - do - { - Field *fields = result->Fetch(); - uint32 creGUID = fields[0].GetUInt32(); - uint32 point = fields[1].GetUInt32(); - int waittime = fields[2].GetUInt32(); - uint32 emote = fields[3].GetUInt32(); - uint32 spell = fields[4].GetUInt32(); - const char * text1 = fields[5].GetString(); - const char * text2 = fields[6].GetString(); - const char * text3 = fields[7].GetString(); - const char * text4 = fields[8].GetString(); - const char * text5 = fields[9].GetString(); - uint32 model1 = fields[10].GetUInt32(); - uint32 model2 = fields[11].GetUInt32(); - - // Get the creature for which we read the waypoint - Creature* wpCreature = ObjectAccessor::GetCreature(*m_session->GetPlayer(),MAKE_NEW_GUID(creGUID,VISUAL_WAYPOINT,HIGHGUID_UNIT)); - - PSendSysMessage(LANG_WAYPOINT_INFO_TITLE, point, (wpCreature ? wpCreature->GetName() : ""), creGUID); - PSendSysMessage(LANG_WAYPOINT_INFO_WAITTIME, waittime); - PSendSysMessage(LANG_WAYPOINT_INFO_MODEL, 1, model1); - PSendSysMessage(LANG_WAYPOINT_INFO_MODEL, 2, model2); - PSendSysMessage(LANG_WAYPOINT_INFO_EMOTE, emote); - PSendSysMessage(LANG_WAYPOINT_INFO_SPELL, spell); - PSendSysMessage(LANG_WAYPOINT_INFO_TEXT, 1, text1); - PSendSysMessage(LANG_WAYPOINT_INFO_TEXT, 2, text2); - PSendSysMessage(LANG_WAYPOINT_INFO_TEXT, 3, text3); - PSendSysMessage(LANG_WAYPOINT_INFO_TEXT, 4, text4); - PSendSysMessage(LANG_WAYPOINT_INFO_TEXT, 5, text5); - - }while( result->NextRow() ); - // Cleanup memory - delete result; - return true; - } - - if(show == "on") - { - PSendSysMessage("DEBUG: wp on, GUID: %u", lowguid); - - QueryResult *result = WorldDatabase.PQuery( "SELECT point, position_x,position_y,position_z FROM creature_movement WHERE id = '%u'",lowguid); - if(!result) - { - PSendSysMessage(LANG_WAYPOINT_NOTFOUND, lowguid); - SetSentErrorMessage(true); - return false; - } - // Delete all visuals for this NPC - QueryResult *result2 = WorldDatabase.PQuery( "SELECT wpguid FROM creature_movement WHERE id = '%u' and wpguid <> 0", lowguid); - if(result2) - { - bool hasError = false; - do - { - Field *fields = result2->Fetch(); - uint32 wpguid = fields[0].GetUInt32(); - Creature* pCreature = ObjectAccessor::GetCreature(*m_session->GetPlayer(),MAKE_NEW_GUID(wpguid,VISUAL_WAYPOINT,HIGHGUID_UNIT)); - - if(!pCreature) - { - PSendSysMessage(LANG_WAYPOINT_NOTREMOVED, wpguid); - hasError = true; - WorldDatabase.PExecuteLog("DELETE FROM creature WHERE guid = '%u'", wpguid); - } - else - { - pCreature->DeleteFromDB(); - pCreature->CleanupsBeforeDelete(); - pCreature->AddObjectToRemoveList(); - } - - }while( result2->NextRow() ); - delete result2; - if( hasError ) - { - PSendSysMessage(LANG_WAYPOINT_TOOFAR1); - PSendSysMessage(LANG_WAYPOINT_TOOFAR2); - PSendSysMessage(LANG_WAYPOINT_TOOFAR3); - } - } - - do - { - Field *fields = result->Fetch(); - uint32 point = fields[0].GetUInt32(); - float x = fields[1].GetFloat(); - float y = fields[2].GetFloat(); - float z = fields[3].GetFloat(); - - uint32 id = VISUAL_WAYPOINT; - - Player *chr = m_session->GetPlayer(); - Map *map = chr->GetMap(); - float o = chr->GetOrientation(); - - Creature* wpCreature = new Creature; - if (!wpCreature->Create(objmgr.GenerateLowGuid(HIGHGUID_UNIT), map, id, 0)) - { - PSendSysMessage(LANG_WAYPOINT_VP_NOTCREATED, id); - delete wpCreature; - delete result; - return false; - } - - wpCreature->Relocate(x, y, z, o); - - if(!wpCreature->IsPositionValid()) - { - sLog.outError("ERROR: Creature (guidlow %d, entry %d) not created. Suggested coordinates isn't valid (X: %f Y: %f)",wpCreature->GetGUIDLow(),wpCreature->GetEntry(),wpCreature->GetPositionX(),wpCreature->GetPositionY()); - delete wpCreature; - delete result; - return false; - } - - wpCreature->SetVisibility(VISIBILITY_OFF); - sLog.outDebug("DEBUG: UPDATE creature_movement SET wpguid = '%u"); - // set "wpguid" column to the visual waypoint - WorldDatabase.PExecuteLog("UPDATE creature_movement SET wpguid = '%u' WHERE id = '%u' and point = '%u'", wpCreature->GetGUIDLow(), lowguid, point); - - wpCreature->SaveToDB(map->GetId(), (1 << map->GetSpawnMode())); - // To call _LoadGoods(); _LoadQuests(); CreateTrainerSpells(); - wpCreature->LoadFromDB(wpCreature->GetDBTableGUIDLow(),map); - map->Add(wpCreature); - //MapManager::Instance().GetMap(wpCreature->GetMapId())->Add(wpCreature); - }while( result->NextRow() ); - - // Cleanup memory - delete result; - return true; - } - - if(show == "first") - { - PSendSysMessage("DEBUG: wp first, GUID: %u", lowguid); - - QueryResult *result = WorldDatabase.PQuery( "SELECT position_x,position_y,position_z FROM creature_movement WHERE point='1' AND id = '%u'",lowguid); - if(!result) - { - PSendSysMessage(LANG_WAYPOINT_NOTFOUND, lowguid); - SetSentErrorMessage(true); - return false; - } - - Field *fields = result->Fetch(); - float x = fields[0].GetFloat(); - float y = fields[1].GetFloat(); - float z = fields[2].GetFloat(); - uint32 id = VISUAL_WAYPOINT; - - Player *chr = m_session->GetPlayer(); - float o = chr->GetOrientation(); - Map *map = chr->GetMap(); - - Creature* pCreature = new Creature; - if (!pCreature->Create(objmgr.GenerateLowGuid(HIGHGUID_UNIT),map, id, 0)) - { - PSendSysMessage(LANG_WAYPOINT_VP_NOTCREATED, id); - delete pCreature; - delete result; - return false; - } - - pCreature->Relocate(x, y, z, o); - - if(!pCreature->IsPositionValid()) - { - sLog.outError("ERROR: Creature (guidlow %d, entry %d) not created. Suggested coordinates isn't valid (X: %f Y: %f)",pCreature->GetGUIDLow(),pCreature->GetEntry(),pCreature->GetPositionX(),pCreature->GetPositionY()); - delete pCreature; - delete result; - return false; - } - - pCreature->SaveToDB(map->GetId(), (1 << map->GetSpawnMode())); - pCreature->LoadFromDB(pCreature->GetDBTableGUIDLow(), map); - map->Add(pCreature); - //player->PlayerTalkClass->SendPointOfInterest(x, y, 6, 6, 0, "First Waypoint"); - - // Cleanup memory - delete result; - return true; - } - - if(show == "last") - { - PSendSysMessage("DEBUG: wp last, GUID: %u", lowguid); - - QueryResult *result = WorldDatabase.PQuery( "SELECT MAX(point) FROM creature_movement WHERE id = '%u'",lowguid); - if( result ) - { - Maxpoint = (*result)[0].GetUInt32(); - - delete result; - } - else - Maxpoint = 0; - - result = WorldDatabase.PQuery( "SELECT position_x,position_y,position_z FROM creature_movement WHERE point ='%u' AND id = '%u'",Maxpoint, lowguid); - if(!result) - { - PSendSysMessage(LANG_WAYPOINT_NOTFOUNDLAST, lowguid); - SetSentErrorMessage(true); - return false; - } - Field *fields = result->Fetch(); - float x = fields[0].GetFloat(); - float y = fields[1].GetFloat(); - float z = fields[2].GetFloat(); - uint32 id = VISUAL_WAYPOINT; - - Player *chr = m_session->GetPlayer(); - float o = chr->GetOrientation(); - Map *map = chr->GetMap(); - - Creature* pCreature = new Creature; - if (!pCreature->Create(objmgr.GenerateLowGuid(HIGHGUID_UNIT), map, id, 0)) - { - PSendSysMessage(LANG_WAYPOINT_NOTCREATED, id); - delete pCreature; - delete result; - return false; - } - - pCreature->Relocate(x, y, z, o); - - if(!pCreature->IsPositionValid()) - { - sLog.outError("ERROR: Creature (guidlow %d, entry %d) not created. Suggested coordinates isn't valid (X: %f Y: %f)",pCreature->GetGUIDLow(),pCreature->GetEntry(),pCreature->GetPositionX(),pCreature->GetPositionY()); - delete pCreature; - delete result; - return false; - } - - pCreature->SaveToDB(map->GetId(), (1 << map->GetSpawnMode())); - pCreature->LoadFromDB(pCreature->GetDBTableGUIDLow(), map); - map->Add(pCreature); - //player->PlayerTalkClass->SendPointOfInterest(x, y, 6, 6, 0, "Last Waypoint"); - // Cleanup memory - delete result; - return true; - } - - if(show == "off") - { - QueryResult *result = WorldDatabase.PQuery("SELECT guid FROM creature WHERE id = '%d'", VISUAL_WAYPOINT); - if(!result) - { - SendSysMessage(LANG_WAYPOINT_VP_NOTFOUND); - SetSentErrorMessage(true); - return false; - } - bool hasError = false; - do - { - Field *fields = result->Fetch(); - uint32 guid = fields[0].GetUInt32(); - Creature* pCreature = ObjectAccessor::GetCreature(*m_session->GetPlayer(),MAKE_NEW_GUID(guid,VISUAL_WAYPOINT,HIGHGUID_UNIT)); - - //Creature* pCreature = ObjectAccessor::GetCreature(*m_session->GetPlayer(), guid); - - if(!pCreature) - { - PSendSysMessage(LANG_WAYPOINT_NOTREMOVED, guid); - hasError = true; - WorldDatabase.PExecuteLog("DELETE FROM creature WHERE guid = '%u'", guid); - } - else - { - pCreature->DeleteFromDB(); - pCreature->CleanupsBeforeDelete(); - pCreature->AddObjectToRemoveList(); - } - }while(result->NextRow()); - // set "wpguid" column to "empty" - no visual waypoint spawned - WorldDatabase.PExecuteLog("UPDATE creature_movement SET wpguid = '0'"); - - if( hasError ) - { - PSendSysMessage(LANG_WAYPOINT_TOOFAR1); - PSendSysMessage(LANG_WAYPOINT_TOOFAR2); - PSendSysMessage(LANG_WAYPOINT_TOOFAR3); - } - - SendSysMessage(LANG_WAYPOINT_VP_ALLREMOVED); - // Cleanup memory - delete result; - - return true; - } - - PSendSysMessage("DEBUG: wpshow - no valid command found"); - - return true; -} // HandleWpShowCommand - -bool ChatHandler::HandleWpExportCommand(const char *args) -{ - if(!*args) - return false; - - // Next arg is: - - // Did user provide a GUID - // or did the user select a creature? - // -> variable lowguid is filled with the GUID of the NPC - uint32 lowguid = 0; - Creature* target = getSelectedCreature(); - char* arg_str = NULL; - if (target) - { - if (target->GetEntry() != VISUAL_WAYPOINT) - lowguid = target->GetGUIDLow(); - else - { - QueryResult *result = WorldDatabase.PQuery( "SELECT id FROM creature_movement WHERE wpguid = %u LIMIT 1", target->GetGUIDLow() ); - if (!result) - { - PSendSysMessage(LANG_WAYPOINT_NOTFOUNDDBPROBLEM, target->GetGUIDLow()); - return true; - } - Field *fields = result->Fetch(); - lowguid = fields[0].GetUInt32();; - delete result; - } - - arg_str = strtok((char*)args, " "); - } - else - { - // user provided - char* guid_str = strtok((char*)args, " "); - if( !guid_str ) - { - SendSysMessage(LANG_WAYPOINT_NOGUID); - return false; - } - lowguid = atoi((char*)guid_str); - - arg_str = strtok((char*)NULL, " "); - } - - if( !arg_str) - { - PSendSysMessage(LANG_WAYPOINT_ARGUMENTREQ, "export"); - return false; - } - - PSendSysMessage("DEBUG: wp export, GUID: %u", lowguid); - - QueryResult *result = WorldDatabase.PQuery( - // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 - "SELECT point, position_x, position_y, position_z, orientation, model1, model2, waittime, emote, spell, text1, text2, text3, text4, text5, id FROM creature_movement WHERE id = '%u' ORDER BY point", lowguid ); - - if (!result) - { - PSendSysMessage(LANG_WAYPOINT_NOTHINGTOEXPORT); - SetSentErrorMessage(true); - return false; - } - - std::ofstream outfile; - outfile.open (arg_str); - - do - { - Field *fields = result->Fetch(); - - outfile << "INSERT INTO creature_movement "; - outfile << "( id, point, position_x, position_y, position_z, orientation, model1, model2, waittime, emote, spell, text1, text2, text3, text4, text5 ) VALUES "; - - outfile << "( "; - outfile << fields[15].GetUInt32(); // id - outfile << ", "; - outfile << fields[0].GetUInt32(); // point - outfile << ", "; - outfile << fields[1].GetFloat(); // position_x - outfile << ", "; - outfile << fields[2].GetFloat(); // position_y - outfile << ", "; - outfile << fields[3].GetUInt32(); // position_z - outfile << ", "; - outfile << fields[4].GetUInt32(); // orientation - outfile << ", "; - outfile << fields[5].GetUInt32(); // model1 - outfile << ", "; - outfile << fields[6].GetUInt32(); // model2 - outfile << ", "; - outfile << fields[7].GetUInt16(); // waittime - outfile << ", "; - outfile << fields[8].GetUInt32(); // emote - outfile << ", "; - outfile << fields[9].GetUInt32(); // spell - outfile << ", "; - const char *tmpChar = fields[10].GetString(); - if( !tmpChar ) - { - outfile << "NULL"; // text1 - } - else - { - outfile << "'"; - outfile << tmpChar; // text1 - outfile << "'"; - } - outfile << ", "; - tmpChar = fields[11].GetString(); - if( !tmpChar ) - { - outfile << "NULL"; // text2 - } - else - { - outfile << "'"; - outfile << tmpChar; // text2 - outfile << "'"; - } - outfile << ", "; - tmpChar = fields[12].GetString(); - if( !tmpChar ) - { - outfile << "NULL"; // text3 - } - else - { - outfile << "'"; - outfile << tmpChar; // text3 - outfile << "'"; - } - outfile << ", "; - tmpChar = fields[13].GetString(); - if( !tmpChar ) - { - outfile << "NULL"; // text4 - } - else - { - outfile << "'"; - outfile << tmpChar; // text4 - outfile << "'"; - } - outfile << ", "; - tmpChar = fields[14].GetString(); - if( !tmpChar ) - { - outfile << "NULL"; // text5 - } - else - { - outfile << "'"; - outfile << tmpChar; // text5 - outfile << "'"; - } - outfile << ");\n "; - - } while( result->NextRow() ); - delete result; - - PSendSysMessage(LANG_WAYPOINT_EXPORTED); - outfile.close(); - - return true; -} - -bool ChatHandler::HandleWpImportCommand(const char *args) -{ - if(!*args) - return false; - - char* arg_str = strtok((char*)args, " "); - if (!arg_str) - return false; - - std::string line; - std::ifstream infile (arg_str); - if (infile.is_open()) - { - while (! infile.eof() ) - { - getline (infile,line); - //cout << line << endl; - QueryResult *result = WorldDatabase.PQuery(line.c_str()); - delete result; - } - infile.close(); - } - PSendSysMessage(LANG_WAYPOINT_IMPORTED); - - return true; -} - -//rename characters -bool ChatHandler::HandleRenameCommand(const char* args) -{ - Player* target = NULL; - uint64 targetGUID = 0; - std::string oldname; - - char* px = strtok((char*)args, " "); - - if(px) - { - oldname = px; - - if(!normalizePlayerName(oldname)) - { - SendSysMessage(LANG_PLAYER_NOT_FOUND); - SetSentErrorMessage(true); - return false; - } - - target = objmgr.GetPlayer(oldname.c_str()); - - if (!target) - targetGUID = objmgr.GetPlayerGUIDByName(oldname); - } - - if(!target && !targetGUID) - { - target = getSelectedPlayer(); - } - - if(!target && !targetGUID) - { - SendSysMessage(LANG_PLAYER_NOT_FOUND); - SetSentErrorMessage(true); - return false; - } - - if(target) - { - PSendSysMessage(LANG_RENAME_PLAYER, target->GetName()); - target->SetAtLoginFlag(AT_LOGIN_RENAME); - CharacterDatabase.PExecute("UPDATE characters SET at_login = at_login | '1' WHERE guid = '%u'", target->GetGUIDLow()); - } - else - { - PSendSysMessage(LANG_RENAME_PLAYER_GUID, oldname.c_str(), GUID_LOPART(targetGUID)); - CharacterDatabase.PExecute("UPDATE characters SET at_login = at_login | '1' WHERE guid = '%u'", GUID_LOPART(targetGUID)); - } - - return true; -} - -//spawn go -bool ChatHandler::HandleGameObjectCommand(const char* args) -{ - if (!*args) - return false; - - char* pParam1 = strtok((char*)args, " "); - if (!pParam1) - return false; - - uint32 id = atoi((char*)pParam1); - if(!id) - return false; - - char* spawntimeSecs = strtok(NULL, " "); - - const GameObjectInfo *goI = objmgr.GetGameObjectInfo(id); - - if (!goI) - { - PSendSysMessage(LANG_GAMEOBJECT_NOT_EXIST,id); - SetSentErrorMessage(true); - return false; - } - - Player *chr = m_session->GetPlayer(); - float x = float(chr->GetPositionX()); - float y = float(chr->GetPositionY()); - float z = float(chr->GetPositionZ()); - float o = float(chr->GetOrientation()); - Map *map = chr->GetMap(); - - float rot2 = sin(o/2); - float rot3 = cos(o/2); - - GameObject* pGameObj = new GameObject; - uint32 db_lowGUID = objmgr.GenerateLowGuid(HIGHGUID_GAMEOBJECT); - - if(!pGameObj->Create(db_lowGUID, goI->id, map, x, y, z, o, 0, 0, rot2, rot3, 0, 1)) - { - delete pGameObj; - return false; - } - - if( spawntimeSecs ) - { - uint32 value = atoi((char*)spawntimeSecs); - pGameObj->SetRespawnTime(value); - //sLog.outDebug("*** spawntimeSecs: %d", value); - } - - // fill the gameobject data and save to the db - pGameObj->SaveToDB(map->GetId(), (1 << map->GetSpawnMode())); - - // this will generate a new guid if the object is in an instance - if(!pGameObj->LoadFromDB(db_lowGUID, map)) - { - delete pGameObj; - return false; - } - - sLog.outDebug(GetMangosString(LANG_GAMEOBJECT_CURRENT), goI->name, db_lowGUID, x, y, z, o); - - map->Add(pGameObj); - - // TODO: is it really necessary to add both the real and DB table guid here ? - objmgr.AddGameobjectToGrid(db_lowGUID, objmgr.GetGOData(db_lowGUID)); - - PSendSysMessage(LANG_GAMEOBJECT_ADD,id,goI->name,db_lowGUID,x,y,z); - return true; -} - -//show animation -bool ChatHandler::HandleAnimCommand(const char* args) -{ - if (!*args) - return false; - - uint32 anim_id = atoi((char*)args); - m_session->GetPlayer()->HandleEmoteCommand(anim_id); - return true; -} - -//change standstate -bool ChatHandler::HandleStandStateCommand(const char* args) -{ - if (!*args) - return false; - - uint32 anim_id = atoi((char*)args); - m_session->GetPlayer( )->SetUInt32Value( UNIT_NPC_EMOTESTATE , anim_id ); - - return true; -} - -bool ChatHandler::HandleAddHonorCommand(const char* args) -{ - if (!*args) - return false; - - Player *target = getSelectedPlayer(); - if(!target) - { - SendSysMessage(LANG_PLAYER_NOT_FOUND); - SetSentErrorMessage(true); - return false; - } - - uint32 amount = (uint32)atoi(args); - target->RewardHonor(NULL, 1, amount); - return true; -} - -bool ChatHandler::HandleHonorAddKillCommand(const char* /*args*/) -{ - Unit *target = getSelectedUnit(); - if(!target) - { - SendSysMessage(LANG_PLAYER_NOT_FOUND); - SetSentErrorMessage(true); - return false; - } - - m_session->GetPlayer()->RewardHonor(target, 1); - return true; -} - -bool ChatHandler::HandleUpdateHonorFieldsCommand(const char* /*args*/) -{ - Player *target = getSelectedPlayer(); - if(!target) - { - SendSysMessage(LANG_PLAYER_NOT_FOUND); - SetSentErrorMessage(true); - return false; - } - - target->UpdateHonorFields(); - return true; -} - -bool ChatHandler::HandleLookupEventCommand(const char* args) -{ - if(!*args) - return false; - - std::string namepart = args; - std::wstring wnamepart; - - // converting string that we try to find to lower case - if(!Utf8toWStr(namepart,wnamepart)) - return false; - - wstrToLower(wnamepart); - - uint32 counter = 0; - - GameEvent::GameEventDataMap const& events = gameeventmgr.GetEventMap(); - GameEvent::ActiveEvents const& activeEvents = gameeventmgr.GetActiveEventList(); - - for(uint32 id = 0; id < events.size(); ++id ) - { - GameEventData const& eventData = events[id]; - - std::string descr = eventData.description; - if(descr.empty()) - continue; - - if (Utf8FitTo(descr, wnamepart)) - { - char const* active = activeEvents.find(id) != activeEvents.end() ? GetMangosString(LANG_ACTIVE) : ""; - PSendSysMessage(LANG_EVENT_ENTRY_LIST,id,id,descr.c_str(),active ); - ++counter; - } - } - - if (counter==0) - SendSysMessage(LANG_NOEVENTFOUND); - - return true; -} - -bool ChatHandler::HandleEventActiveListCommand(const char* args) -{ - uint32 counter = 0; - - GameEvent::GameEventDataMap const& events = gameeventmgr.GetEventMap(); - GameEvent::ActiveEvents const& activeEvents = gameeventmgr.GetActiveEventList(); - - char const* active = GetMangosString(LANG_ACTIVE); - - for(GameEvent::ActiveEvents::const_iterator itr = activeEvents.begin(); itr != activeEvents.end(); ++itr ) - { - uint32 event_id = *itr; - GameEventData const& eventData = events[event_id]; - - PSendSysMessage(LANG_EVENT_ENTRY_LIST,event_id,event_id,eventData.description.c_str(),active ); - ++counter; - } - - if (counter==0) - SendSysMessage(LANG_NOEVENTFOUND); - - return true; -} - -bool ChatHandler::HandleEventInfoCommand(const char* args) -{ - if(!*args) - return false; - - // id or [name] Shift-click form |color|Hgameevent:id|h[name]|h|r - char* cId = extractKeyFromLink((char*)args,"Hgameevent"); - if(!cId) - return false; - - uint32 event_id = atoi(cId); - - GameEvent::GameEventDataMap const& events = gameeventmgr.GetEventMap(); - - if(event_id >=events.size()) - { - SendSysMessage(LANG_EVENT_NOT_EXIST); - SetSentErrorMessage(true); - return false; - } - - GameEventData const& eventData = events[event_id]; - if(!eventData.isValid()) - { - SendSysMessage(LANG_EVENT_NOT_EXIST); - SetSentErrorMessage(true); - return false; - } - - GameEvent::ActiveEvents const& activeEvents = gameeventmgr.GetActiveEventList(); - bool active = activeEvents.find(event_id) != activeEvents.end(); - char const* activeStr = active ? GetMangosString(LANG_ACTIVE) : ""; - - std::string startTimeStr = TimeToTimestampStr(eventData.start); - std::string endTimeStr = TimeToTimestampStr(eventData.end); - - uint32 delay = gameeventmgr.NextCheck(event_id); - time_t nextTime = time(NULL)+delay; - std::string nextStr = nextTime >= eventData.start && nextTime < eventData.end ? TimeToTimestampStr(time(NULL)+delay) : "-"; - - std::string occurenceStr = secsToTimeString(eventData.occurence * MINUTE); - std::string lengthStr = secsToTimeString(eventData.length * MINUTE); - - PSendSysMessage(LANG_EVENT_INFO,event_id,eventData.description.c_str(),activeStr, - startTimeStr.c_str(),endTimeStr.c_str(),occurenceStr.c_str(),lengthStr.c_str(), - nextStr.c_str()); - return true; -} - -bool ChatHandler::HandleEventStartCommand(const char* args) -{ - if(!*args) - return false; - - // id or [name] Shift-click form |color|Hgameevent:id|h[name]|h|r - char* cId = extractKeyFromLink((char*)args,"Hgameevent"); - if(!cId) - return false; - - int32 event_id = atoi(cId); - - GameEvent::GameEventDataMap const& events = gameeventmgr.GetEventMap(); - - if(event_id < 1 || event_id >=events.size()) - { - SendSysMessage(LANG_EVENT_NOT_EXIST); - SetSentErrorMessage(true); - return false; - } - - GameEventData const& eventData = events[event_id]; - if(!eventData.isValid()) - { - SendSysMessage(LANG_EVENT_NOT_EXIST); - SetSentErrorMessage(true); - return false; - } - - GameEvent::ActiveEvents const& activeEvents = gameeventmgr.GetActiveEventList(); - if(activeEvents.find(event_id) != activeEvents.end()) - { - PSendSysMessage(LANG_EVENT_ALREADY_ACTIVE,event_id); - SetSentErrorMessage(true); - return false; - } - - gameeventmgr.StartEvent(event_id,true); - return true; -} - -bool ChatHandler::HandleEventStopCommand(const char* args) -{ - if(!*args) - return false; - - // id or [name] Shift-click form |color|Hgameevent:id|h[name]|h|r - char* cId = extractKeyFromLink((char*)args,"Hgameevent"); - if(!cId) - return false; - - int32 event_id = atoi(cId); - - GameEvent::GameEventDataMap const& events = gameeventmgr.GetEventMap(); - - if(event_id < 1 || event_id >=events.size()) - { - SendSysMessage(LANG_EVENT_NOT_EXIST); - SetSentErrorMessage(true); - return false; - } - - GameEventData const& eventData = events[event_id]; - if(!eventData.isValid()) - { - SendSysMessage(LANG_EVENT_NOT_EXIST); - SetSentErrorMessage(true); - return false; - } - - GameEvent::ActiveEvents const& activeEvents = gameeventmgr.GetActiveEventList(); - - if(activeEvents.find(event_id) == activeEvents.end()) - { - PSendSysMessage(LANG_EVENT_NOT_ACTIVE,event_id); - SetSentErrorMessage(true); - return false; - } - - gameeventmgr.StopEvent(event_id,true); - return true; -} - -bool ChatHandler::HandleCombatStopCommand(const char* args) -{ - Player *player; - - if(*args) - { - std::string playername = args; - - if(!normalizePlayerName(playername)) - { - SendSysMessage(LANG_PLAYER_NOT_FOUND); - SetSentErrorMessage(true); - return false; - } - - player = objmgr.GetPlayer(playername.c_str()); - - if(!player) - { - SendSysMessage(LANG_PLAYER_NOT_FOUND); - SetSentErrorMessage(true); - return false; - } - } - else - { - player = getSelectedPlayer(); - - if (!player) - player = m_session->GetPlayer(); - } - - player->CombatStop(); - player->getHostilRefManager().deleteReferences(); - return true; -} - -bool ChatHandler::HandleLearnAllCraftsCommand(const char* /*args*/) -{ - uint32 classmask = m_session->GetPlayer()->getClassMask(); - - for (uint32 i = 0; i < sSkillLineStore.GetNumRows(); ++i) - { - SkillLineEntry const *skillInfo = sSkillLineStore.LookupEntry(i); - if( !skillInfo ) - continue; - - if( skillInfo->categoryId == SKILL_CATEGORY_PROFESSION || skillInfo->categoryId == SKILL_CATEGORY_SECONDARY ) - { - for (uint32 j = 0; j < sSkillLineAbilityStore.GetNumRows(); ++j) - { - SkillLineAbilityEntry const *skillLine = sSkillLineAbilityStore.LookupEntry(j); - if( !skillLine ) - continue; - - // skip racial skills - if( skillLine->racemask != 0 ) - continue; - - // skip wrong class skills - if( skillLine->classmask && (skillLine->classmask & classmask) == 0) - continue; - - if( skillLine->skillId != i || skillLine->forward_spellid ) - continue; - - SpellEntry const* spellInfo = sSpellStore.LookupEntry(skillLine->spellId); - if(!spellInfo || !SpellMgr::IsSpellValid(spellInfo,m_session->GetPlayer(),false)) - continue; - - m_session->GetPlayer()->learnSpell(skillLine->spellId); - } - } - } - - SendSysMessage(LANG_COMMAND_LEARN_ALL_CRAFT); - return true; -} - -bool ChatHandler::HandleLearnAllRecipesCommand(const char* args) -{ - // Learns all recipes of specified profession and sets skill to max - // Example: .learn all_recipes enchanting - - Player* target = getSelectedPlayer(); - if( !target ) - { - SendSysMessage(LANG_PLAYER_NOT_FOUND); - return false; - } - - if(!*args) - return false; - - std::wstring wnamepart; - - if(!Utf8toWStr(args,wnamepart)) - return false; - - uint32 counter = 0; // Counter for figure out that we found smth. - - // converting string that we try to find to lower case - wstrToLower( wnamepart ); - - uint32 classmask = m_session->GetPlayer()->getClassMask(); - - for (uint32 i = 0; i < sSkillLineStore.GetNumRows(); ++i) - { - SkillLineEntry const *skillInfo = sSkillLineStore.LookupEntry(i); - if( !skillInfo ) - continue; - - if( skillInfo->categoryId != SKILL_CATEGORY_PROFESSION && - skillInfo->categoryId != SKILL_CATEGORY_SECONDARY ) - continue; - - int loc = m_session->GetSessionDbcLocale(); - std::string name = skillInfo->name[loc]; - - if(Utf8FitTo(name, wnamepart)) - { - for (uint32 j = 0; j < sSkillLineAbilityStore.GetNumRows(); ++j) - { - SkillLineAbilityEntry const *skillLine = sSkillLineAbilityStore.LookupEntry(j); - if( !skillLine ) - continue; - - if( skillLine->skillId != i || skillLine->forward_spellid ) - continue; - - // skip racial skills - if( skillLine->racemask != 0 ) - continue; - - // skip wrong class skills - if( skillLine->classmask && (skillLine->classmask & classmask) == 0) - continue; - - SpellEntry const* spellInfo = sSpellStore.LookupEntry(skillLine->spellId); - if(!spellInfo || !SpellMgr::IsSpellValid(spellInfo,m_session->GetPlayer(),false)) - continue; - - if( !target->HasSpell(spellInfo->Id) ) - m_session->GetPlayer()->learnSpell(skillLine->spellId); - } - - uint16 maxLevel = target->GetPureMaxSkillValue(skillInfo->id); - target->SetSkill(skillInfo->id, maxLevel, maxLevel); - PSendSysMessage(LANG_COMMAND_LEARN_ALL_RECIPES, name.c_str()); - return true; - } - } - - return false; -} +/* + * Copyright (C) 2005-2008 MaNGOS + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "Common.h" +#include "Database/DatabaseEnv.h" +#include "WorldPacket.h" +#include "WorldSession.h" +#include "World.h" +#include "ObjectMgr.h" +#include "Player.h" +#include "Item.h" +#include "GameObject.h" +#include "Opcodes.h" +#include "Chat.h" +#include "ObjectAccessor.h" +#include "MapManager.h" +#include "Language.h" +#include "World.h" +#include "GameEvent.h" +#include "SpellMgr.h" +#include "AccountMgr.h" +#include "WaypointManager.h" +#include "Util.h" +#include +#include +#include +#include + +static uint32 ReputationRankStrIndex[MAX_REPUTATION_RANK] = +{ + LANG_REP_HATED, LANG_REP_HOSTILE, LANG_REP_UNFRIENDLY, LANG_REP_NEUTRAL, + LANG_REP_FRIENDLY, LANG_REP_HONORED, LANG_REP_REVERED, LANG_REP_EXALTED +}; + +//mute player for some times +bool ChatHandler::HandleMuteCommand(const char* args) +{ + if (!*args) + return false; + + char *charname = strtok((char*)args, " "); + if (!charname) + return false; + + std::string cname = charname; + + char *timetonotspeak = strtok(NULL, " "); + if(!timetonotspeak) + return false; + + uint32 notspeaktime = (uint32) atoi(timetonotspeak); + + if(!normalizePlayerName(cname)) + { + SendSysMessage(LANG_PLAYER_NOT_FOUND); + SetSentErrorMessage(true); + return false; + } + + uint64 guid = objmgr.GetPlayerGUIDByName(cname.c_str()); + if(!guid) + { + SendSysMessage(LANG_PLAYER_NOT_FOUND); + SetSentErrorMessage(true); + return false; + } + + Player *chr = objmgr.GetPlayer(guid); + + // check security + uint32 account_id = 0; + uint32 security = 0; + + if (chr) + { + account_id = chr->GetSession()->GetAccountId(); + security = chr->GetSession()->GetSecurity(); + } + else + { + account_id = objmgr.GetPlayerAccountIdByGUID(guid); + security = objmgr.GetSecurityByAccount(account_id); + } + + if(security >= m_session->GetSecurity()) + { + SendSysMessage(LANG_YOURS_SECURITY_IS_LOW); + SetSentErrorMessage(true); + return false; + } + + time_t mutetime = time(NULL) + notspeaktime*60; + + if (chr) + chr->GetSession()->m_muteTime = mutetime; + + loginDatabase.PExecute("UPDATE account SET mutetime = " I64FMTD " WHERE id = '%u'",uint64(mutetime), account_id ); + + if(chr) + ChatHandler(chr).PSendSysMessage(LANG_YOUR_CHAT_DISABLED, notspeaktime); + + PSendSysMessage(LANG_YOU_DISABLE_CHAT, cname.c_str(), notspeaktime); + + return true; +} + +//unmute player +bool ChatHandler::HandleUnmuteCommand(const char* args) +{ + if (!*args) + return false; + + char *charname = strtok((char*)args, " "); + if (!charname) + return false; + + std::string cname = charname; + + if(!normalizePlayerName(cname)) + { + SendSysMessage(LANG_PLAYER_NOT_FOUND); + SetSentErrorMessage(true); + return false; + } + + uint64 guid = objmgr.GetPlayerGUIDByName(cname.c_str()); + if(!guid) + { + SendSysMessage(LANG_PLAYER_NOT_FOUND); + SetSentErrorMessage(true); + return false; + } + + Player *chr = objmgr.GetPlayer(guid); + + // check security + uint32 account_id = 0; + uint32 security = 0; + + if (chr) + { + account_id = chr->GetSession()->GetAccountId(); + security = chr->GetSession()->GetSecurity(); + } + else + { + account_id = objmgr.GetPlayerAccountIdByGUID(guid); + security = objmgr.GetSecurityByAccount(account_id); + } + + if(security >= m_session->GetSecurity()) + { + SendSysMessage(LANG_YOURS_SECURITY_IS_LOW); + SetSentErrorMessage(true); + return false; + } + + if (chr) + { + if(chr->CanSpeak()) + { + SendSysMessage(LANG_CHAT_ALREADY_ENABLED); + SetSentErrorMessage(true); + return false; + } + + chr->GetSession()->m_muteTime = 0; + } + + loginDatabase.PExecute("UPDATE account SET mutetime = '0' WHERE id = '%u'", account_id ); + + if(chr) + ChatHandler(chr).PSendSysMessage(LANG_YOUR_CHAT_ENABLED); + + PSendSysMessage(LANG_YOU_ENABLE_CHAT, cname.c_str()); + return true; +} + +bool ChatHandler::HandleTargetObjectCommand(const char* args) +{ + Player* pl = m_session->GetPlayer(); + QueryResult *result; + GameEvent::ActiveEvents const& activeEventsList = gameeventmgr.GetActiveEventList(); + if(*args) + { + int32 id = atoi((char*)args); + if(id) + result = WorldDatabase.PQuery("SELECT guid, id, position_x, position_y, position_z, orientation, map, (POW(position_x - '%f', 2) + POW(position_y - '%f', 2) + POW(position_z - '%f', 2)) AS order_ FROM gameobject WHERE map = '%i' AND id = '%u' ORDER BY order_ ASC LIMIT 1", + pl->GetPositionX(), pl->GetPositionY(), pl->GetPositionZ(), pl->GetMapId(),id); + else + { + std::string name = args; + WorldDatabase.escape_string(name); + result = WorldDatabase.PQuery( + "SELECT guid, id, position_x, position_y, position_z, orientation, map, (POW(position_x - %f, 2) + POW(position_y - %f, 2) + POW(position_z - %f, 2)) AS order_ " + "FROM gameobject,gameobject_template WHERE gameobject_template.entry = gameobject.id AND map = %i AND name "_LIKE_" "_CONCAT3_("'%%'","'%s'","'%%'")" ORDER BY order_ ASC LIMIT 1", + pl->GetPositionX(), pl->GetPositionY(), pl->GetPositionZ(), pl->GetMapId(),name.c_str()); + } + } + else + { + std::ostringstream eventFilter; + eventFilter << " AND (event IS NULL "; + bool initString = true; + + for (GameEvent::ActiveEvents::const_iterator itr = activeEventsList.begin(); itr != activeEventsList.end(); ++itr) + { + if (initString) + { + eventFilter << "OR event IN (" <<*itr; + initString =false; + } + else + eventFilter << "," << *itr; + } + + if (!initString) + eventFilter << "))"; + else + eventFilter << ")"; + + result = WorldDatabase.PQuery("SELECT gameobject.guid, id, position_x, position_y, position_z, orientation, map, " + "(POW(position_x - %f, 2) + POW(position_y - %f, 2) + POW(position_z - %f, 2)) AS order_ FROM gameobject " + "LEFT OUTER JOIN game_event_gameobject on gameobject.guid=game_event_gameobject.guid WHERE map = '%i' %s ORDER BY order_ ASC LIMIT 1", + m_session->GetPlayer()->GetPositionX(), m_session->GetPlayer()->GetPositionY(), m_session->GetPlayer()->GetPositionZ(), m_session->GetPlayer()->GetMapId(),eventFilter.str().c_str()); + } + + if (!result) + { + SendSysMessage(LANG_COMMAND_TARGETOBJNOTFOUND); + return true; + } + + Field *fields = result->Fetch(); + uint32 lowguid = fields[0].GetUInt32(); + uint32 id = fields[1].GetUInt32(); + float x = fields[2].GetFloat(); + float y = fields[3].GetFloat(); + float z = fields[4].GetFloat(); + float o = fields[5].GetFloat(); + int mapid = fields[6].GetUInt16(); + delete result; + + GameObjectInfo const* goI = objmgr.GetGameObjectInfo(id); + + if (!goI) + { + PSendSysMessage(LANG_GAMEOBJECT_NOT_EXIST,id); + return false; + } + + GameObject* target = ObjectAccessor::GetGameObject(*m_session->GetPlayer(),MAKE_NEW_GUID(lowguid,id,HIGHGUID_GAMEOBJECT)); + + PSendSysMessage(LANG_GAMEOBJECT_DETAIL, lowguid, goI->name, lowguid, id, x, y, z, mapid, o); + + if(target) + { + int32 curRespawnDelay = target->GetRespawnTimeEx()-time(NULL); + if(curRespawnDelay < 0) + curRespawnDelay = 0; + + std::string curRespawnDelayStr = secsToTimeString(curRespawnDelay,true); + std::string defRespawnDelayStr = secsToTimeString(target->GetRespawnDelay(),true); + + PSendSysMessage(LANG_COMMAND_RAWPAWNTIMES, defRespawnDelayStr.c_str(),curRespawnDelayStr.c_str()); + } + return true; +} + +//teleport to gameobject +bool ChatHandler::HandleGoObjectCommand(const char* args) +{ + if(!*args) + return false; + + Player* _player = m_session->GetPlayer(); + + // number or [name] Shift-click form |color|Hgameobject:go_guid|h[name]|h|r + char* cId = extractKeyFromLink((char*)args,"Hgameobject"); + if(!cId) + return false; + + int32 guid = atoi(cId); + if(!guid) + return false; + + float x, y, z, ort; + int mapid; + + // by DB guid + if (GameObjectData const* go_data = objmgr.GetGOData(guid)) + { + x = go_data->posX; + y = go_data->posY; + z = go_data->posZ; + ort = go_data->orientation; + mapid = go_data->mapid; + } + else + { + SendSysMessage(LANG_COMMAND_GOOBJNOTFOUND); + SetSentErrorMessage(true); + return false; + } + + if(!MapManager::IsValidMapCoord(mapid,x,y,z,ort)) + { + PSendSysMessage(LANG_INVALID_TARGET_COORD,x,y,mapid); + SetSentErrorMessage(true); + return false; + } + + // stop flight if need + if(_player->isInFlight()) + { + _player->GetMotionMaster()->MovementExpired(); + _player->m_taxi.ClearTaxiDestinations(); + } + // save only in non-flight case + else + _player->SaveRecallPosition(); + + _player->TeleportTo(mapid, x, y, z, ort); + return true; +} + +bool ChatHandler::HandleGoTriggerCommand(const char* args) +{ + Player* _player = m_session->GetPlayer(); + + if (!*args) + return false; + + char *atId = strtok((char*)args, " "); + if (!atId) + return false; + + int32 i_atId = atoi(atId); + + if(!i_atId) + return false; + + AreaTriggerEntry const* at = sAreaTriggerStore.LookupEntry(i_atId); + if (!at) + { + PSendSysMessage(LANG_COMMAND_GOAREATRNOTFOUND,i_atId); + SetSentErrorMessage(true); + return false; + } + + if(!MapManager::IsValidMapCoord(at->mapid,at->x,at->y,at->z)) + { + PSendSysMessage(LANG_INVALID_TARGET_COORD,at->x,at->y,at->mapid); + SetSentErrorMessage(true); + return false; + } + + // stop flight if need + if(_player->isInFlight()) + { + _player->GetMotionMaster()->MovementExpired(); + _player->m_taxi.ClearTaxiDestinations(); + } + // save only in non-flight case + else + _player->SaveRecallPosition(); + + _player->TeleportTo(at->mapid, at->x, at->y, at->z, _player->GetOrientation()); + return true; +} + +bool ChatHandler::HandleGoGraveyardCommand(const char* args) +{ + Player* _player = m_session->GetPlayer(); + + if (!*args) + return false; + + char *gyId = strtok((char*)args, " "); + if (!gyId) + return false; + + int32 i_gyId = atoi(gyId); + + if(!i_gyId) + return false; + + WorldSafeLocsEntry const* gy = sWorldSafeLocsStore.LookupEntry(i_gyId); + if (!gy) + { + PSendSysMessage(LANG_COMMAND_GRAVEYARDNOEXIST,i_gyId); + SetSentErrorMessage(true); + return false; + } + + if(!MapManager::IsValidMapCoord(gy->map_id,gy->x,gy->y,gy->z)) + { + PSendSysMessage(LANG_INVALID_TARGET_COORD,gy->x,gy->y,gy->map_id); + SetSentErrorMessage(true); + return false; + } + + // stop flight if need + if(_player->isInFlight()) + { + _player->GetMotionMaster()->MovementExpired(); + _player->m_taxi.ClearTaxiDestinations(); + } + // save only in non-flight case + else + _player->SaveRecallPosition(); + + _player->TeleportTo(gy->map_id, gy->x, gy->y, gy->z, _player->GetOrientation()); + return true; +} + +/** \brief Teleport the GM to the specified creature + * + * .gocreature --> TP using creature.guid + * .gocreature azuregos --> TP player to the mob with this name + * Warning: If there is more than one mob with this name + * you will be teleported to the first one that is found. + * .gocreature id 6109 --> TP player to the mob, that has this creature_template.entry + * Warning: If there is more than one mob with this "id" + * you will be teleported to the first one that is found. + */ +//teleport to creature +bool ChatHandler::HandleGoCreatureCommand(const char* args) +{ + if(!*args) + return false; + Player* _player = m_session->GetPlayer(); + + // "id" or number or [name] Shift-click form |color|Hcreature_entry:creature_id|h[name]|h|r + char* pParam1 = extractKeyFromLink((char*)args,"Hcreature"); + if (!pParam1) + return false; + + std::ostringstream whereClause; + + // User wants to teleport to the NPC's template entry + if( strcmp(pParam1, "id") == 0 ) + { + //sLog.outError("DEBUG: ID found"); + + // Get the "creature_template.entry" + // number or [name] Shift-click form |color|Hcreature_entry:creature_id|h[name]|h|r + char* tail = strtok(NULL,""); + if(!tail) + return false; + char* cId = extractKeyFromLink(tail,"Hcreature_entry"); + if(!cId) + return false; + + int32 tEntry = atoi(cId); + //sLog.outError("DEBUG: ID value: %d", tEntry); + if(!tEntry) + return false; + + whereClause << "WHERE id = '" << tEntry << "'"; + } + else + { + //sLog.outError("DEBUG: ID *not found*"); + + int32 guid = atoi(pParam1); + + // Number is invalid - maybe the user specified the mob's name + if(!guid) + { + std::string name = pParam1; + WorldDatabase.escape_string(name); + whereClause << ", creature_template WHERE creature.id = creature_template.entry AND creature_template.name "_LIKE_" '" << name << "'"; + } + else + { + whereClause << "WHERE guid = '" << guid << "'"; + } + } + //sLog.outError("DEBUG: %s", whereClause.c_str()); + + QueryResult *result = WorldDatabase.PQuery("SELECT position_x,position_y,position_z,orientation,map FROM creature %s", whereClause.str().c_str() ); + if (!result) + { + SendSysMessage(LANG_COMMAND_GOCREATNOTFOUND); + SetSentErrorMessage(true); + return false; + } + if( result->GetRowCount() > 1 ) + { + SendSysMessage(LANG_COMMAND_GOCREATMULTIPLE); + } + + Field *fields = result->Fetch(); + float x = fields[0].GetFloat(); + float y = fields[1].GetFloat(); + float z = fields[2].GetFloat(); + float ort = fields[3].GetFloat(); + int mapid = fields[4].GetUInt16(); + + delete result; + + if(!MapManager::IsValidMapCoord(mapid,x,y,z,ort)) + { + PSendSysMessage(LANG_INVALID_TARGET_COORD,x,y,mapid); + SetSentErrorMessage(true); + return false; + } + + // stop flight if need + if(_player->isInFlight()) + { + _player->GetMotionMaster()->MovementExpired(); + _player->m_taxi.ClearTaxiDestinations(); + } + // save only in non-flight case + else + _player->SaveRecallPosition(); + + _player->TeleportTo(mapid, x, y, z, ort); + return true; +} + +bool ChatHandler::HandleGUIDCommand(const char* /*args*/) +{ + uint64 guid = m_session->GetPlayer()->GetSelection(); + + if (guid == 0) + { + SendSysMessage(LANG_NO_SELECTION); + SetSentErrorMessage(true); + return false; + } + + PSendSysMessage(LANG_OBJECT_GUID, GUID_LOPART(guid), GUID_HIPART(guid)); + return true; +} + +bool ChatHandler::HandleLookupFactionCommand(const char* args) +{ + if(!*args) + return false; + + Player *target = getSelectedPlayer(); + if (!target) + { + SendSysMessage(LANG_NO_CHAR_SELECTED); + SetSentErrorMessage(true); + return false; + } + + std::string namepart = args; + std::wstring wnamepart; + + if(!Utf8toWStr(namepart,wnamepart)) + return false; + + // converting string that we try to find to lower case + wstrToLower( wnamepart ); + + uint32 counter = 0; // Counter for figure out that we found smth. + + for (uint32 id = 0; id < sFactionStore.GetNumRows(); id++) + //for(FactionStateList::const_iterator itr = target->m_factions.begin(); itr != target->m_factions.end(); ++itr) + { + FactionEntry const *factionEntry = sFactionStore.LookupEntry(id); + //FactionEntry const *factionEntry = sFactionStore.LookupEntry(itr->second.ID); + if (factionEntry) + { + FactionStateList::const_iterator repItr = target->m_factions.find(factionEntry->reputationListID); + + int loc = m_session->GetSessionDbcLocale(); + std::string name = factionEntry->name[loc]; + if(name.empty()) + continue; + + if (!Utf8FitTo(name, wnamepart)) + { + loc = 0; + for(; loc < MAX_LOCALE; ++loc) + { + if(loc==m_session->GetSessionDbcLocale()) + continue; + + name = factionEntry->name[loc]; + if(name.empty()) + continue; + + if (Utf8FitTo(name, wnamepart)) + break; + } + } + + if(loc < MAX_LOCALE) + { + // send faction in "id - [faction] rank reputation [visible] [at war] [own team] [unknown] [invisible] [inactive]" format + // or "id - [faction] [no reputation]" format + std::ostringstream ss; + ss << id << " - |cffffffff|Hfaction:" << id << "|h[" << name << " " << localeNames[loc] << "]|h|r"; + + if (repItr != target->m_factions.end()) + { + ReputationRank rank = target->GetReputationRank(factionEntry); + std::string rankName = GetMangosString(ReputationRankStrIndex[rank]); + + ss << " " << rankName << "|h|r (" << target->GetReputation(factionEntry) << ")"; + + if(repItr->second.Flags & FACTION_FLAG_VISIBLE) + ss << GetMangosString(LANG_FACTION_VISIBLE); + if(repItr->second.Flags & FACTION_FLAG_AT_WAR) + ss << GetMangosString(LANG_FACTION_ATWAR); + if(repItr->second.Flags & FACTION_FLAG_PEACE_FORCED) + ss << GetMangosString(LANG_FACTION_PEACE_FORCED); + if(repItr->second.Flags & FACTION_FLAG_HIDDEN) + ss << GetMangosString(LANG_FACTION_HIDDEN); + if(repItr->second.Flags & FACTION_FLAG_INVISIBLE_FORCED) + ss << GetMangosString(LANG_FACTION_INVISIBLE_FORCED); + if(repItr->second.Flags & FACTION_FLAG_INACTIVE) + ss << GetMangosString(LANG_FACTION_INACTIVE); + } + else + ss << GetMangosString(LANG_FACTION_NOREPUTATION); + + SendSysMessage(ss.str().c_str()); + counter++; + } + } + } + + if (counter == 0) // if counter == 0 then we found nth + SendSysMessage(LANG_COMMAND_FACTION_NOTFOUND); + return true; +} + +bool ChatHandler::HandleModifyRepCommand(const char * args) +{ + if (!*args) return false; + + Player* target = NULL; + target = getSelectedPlayer(); + + if(!target) + { + SendSysMessage(LANG_PLAYER_NOT_FOUND); + SetSentErrorMessage(true); + return false; + } + + char* factionTxt = extractKeyFromLink((char*)args,"Hfaction"); + if(!factionTxt) + return false; + + uint32 factionId = atoi(factionTxt); + + int32 amount = 0; + char *rankTxt = strtok(NULL, " "); + if (!factionTxt || !rankTxt) + return false; + + amount = atoi(rankTxt); + if ((amount == 0) && (rankTxt[0] != '-') && !isdigit(rankTxt[0])) + { + std::string rankStr = rankTxt; + std::wstring wrankStr; + if(!Utf8toWStr(rankStr,wrankStr)) + return false; + wstrToLower( wrankStr ); + + int r = 0; + amount = -42000; + for (; r < MAX_REPUTATION_RANK; ++r) + { + std::string rank = GetMangosString(ReputationRankStrIndex[r]); + if(rank.empty()) + continue; + + std::wstring wrank; + if(!Utf8toWStr(rank,wrank)) + continue; + + wstrToLower(wrank); + + if(wrank.substr(0,wrankStr.size())==wrankStr) + { + char *deltaTxt = strtok(NULL, " "); + if (deltaTxt) + { + int32 delta = atoi(deltaTxt); + if ((delta < 0) || (delta > Player::ReputationRank_Length[r] -1)) + { + PSendSysMessage(LANG_COMMAND_FACTION_DELTA, (Player::ReputationRank_Length[r]-1)); + SetSentErrorMessage(true); + return false; + } + amount += delta; + } + break; + } + amount += Player::ReputationRank_Length[r]; + } + if (r >= MAX_REPUTATION_RANK) + { + PSendSysMessage(LANG_COMMAND_FACTION_INVPARAM, rankTxt); + SetSentErrorMessage(true); + return false; + } + } + + FactionEntry const *factionEntry = sFactionStore.LookupEntry(factionId); + + if (!factionEntry) + { + PSendSysMessage(LANG_COMMAND_FACTION_UNKNOWN, factionId); + SetSentErrorMessage(true); + return false; + } + + if (factionEntry->reputationListID < 0) + { + PSendSysMessage(LANG_COMMAND_FACTION_NOREP_ERROR, factionEntry->name[m_session->GetSessionDbcLocale()], factionId); + SetSentErrorMessage(true); + return false; + } + + target->SetFactionReputation(factionEntry,amount); + PSendSysMessage(LANG_COMMAND_MODIFY_REP, factionEntry->name[m_session->GetSessionDbcLocale()], factionId, target->GetName(), target->GetReputation(factionId)); + return true; +} + +bool ChatHandler::HandleNameCommand(const char* args) +{ + /* Temp. disabled + if(!*args) + return false; + + if(strlen((char*)args)>75) + { + PSendSysMessage(LANG_TOO_LONG_NAME, strlen((char*)args)-75); + return true; + } + + for (uint8 i = 0; i < strlen(args); i++) + { + if(!isalpha(args[i]) && args[i]!=' ') + { + SendSysMessage(LANG_CHARS_ONLY); + return false; + } + } + + uint64 guid; + guid = m_session->GetPlayer()->GetSelection(); + if (guid == 0) + { + SendSysMessage(LANG_NO_SELECTION); + return true; + } + + Creature* pCreature = ObjectAccessor::GetCreature(*m_session->GetPlayer(), guid); + + if(!pCreature) + { + SendSysMessage(LANG_SELECT_CREATURE); + return true; + } + + pCreature->SetName(args); + uint32 idname = objmgr.AddCreatureTemplate(pCreature->GetName()); + pCreature->SetUInt32Value(OBJECT_FIELD_ENTRY, idname); + + pCreature->SaveToDB(); + */ + + return true; +} + +bool ChatHandler::HandleSubNameCommand(const char* /*args*/) +{ + /* Temp. disabled + + if(!*args) + args = ""; + + if(strlen((char*)args)>75) + { + + PSendSysMessage(LANG_TOO_LONG_SUBNAME, strlen((char*)args)-75); + return true; + } + + for (uint8 i = 0; i < strlen(args); i++) + { + if(!isalpha(args[i]) && args[i]!=' ') + { + SendSysMessage(LANG_CHARS_ONLY); + return false; + } + } + uint64 guid; + guid = m_session->GetPlayer()->GetSelection(); + if (guid == 0) + { + SendSysMessage(LANG_NO_SELECTION); + return true; + } + + Creature* pCreature = ObjectAccessor::GetCreature(*m_session->GetPlayer(), guid); + + if(!pCreature) + { + SendSysMessage(LANG_SELECT_CREATURE); + return true; + } + + uint32 idname = objmgr.AddCreatureSubName(pCreature->GetName(),args,pCreature->GetUInt32Value(UNIT_FIELD_DISPLAYID)); + pCreature->SetUInt32Value(OBJECT_FIELD_ENTRY, idname); + + pCreature->SaveToDB(); + */ + return true; +} + +//move item to other slot +bool ChatHandler::HandleItemMoveCommand(const char* args) +{ + if(!*args) + return false; + uint8 srcslot, dstslot; + + char* pParam1 = strtok((char*)args, " "); + if (!pParam1) + return false; + + char* pParam2 = strtok(NULL, " "); + if (!pParam2) + return false; + + srcslot = (uint8)atoi(pParam1); + dstslot = (uint8)atoi(pParam2); + + uint16 src = ((INVENTORY_SLOT_BAG_0 << 8) | srcslot); + uint16 dst = ((INVENTORY_SLOT_BAG_0 << 8) | dstslot); + + if(srcslot==dstslot) + return true; + + m_session->GetPlayer()->SwapItem( src, dst ); + + return true; +} + +//add spawn of creature +bool ChatHandler::HandleAddSpwCommand(const char* args) +{ + if(!*args) + return false; + char* charID = strtok((char*)args, " "); + if (!charID) + return false; + + char* team = strtok(NULL, " "); + int32 teamval = 0; + if (team) { teamval = atoi(team); } + if (teamval < 0) { teamval = 0; } + + uint32 id = atoi(charID); + + Player *chr = m_session->GetPlayer(); + float x = chr->GetPositionX(); + float y = chr->GetPositionY(); + float z = chr->GetPositionZ(); + float o = chr->GetOrientation(); + Map *map = chr->GetMap(); + + Creature* pCreature = new Creature; + if (!pCreature->Create(objmgr.GenerateLowGuid(HIGHGUID_UNIT), map, id, (uint32)teamval)) + { + delete pCreature; + return false; + } + + pCreature->Relocate(x,y,z,o); + + if(!pCreature->IsPositionValid()) + { + sLog.outError("ERROR: Creature (guidlow %d, entry %d) not created. Suggested coordinates isn't valid (X: %f Y: %f)",pCreature->GetGUIDLow(),pCreature->GetEntry(),pCreature->GetPositionX(),pCreature->GetPositionY()); + delete pCreature; + return false; + } + + pCreature->SaveToDB(map->GetId(), (1 << map->GetSpawnMode())); + + uint32 db_guid = pCreature->GetDBTableGUIDLow(); + + // To call _LoadGoods(); _LoadQuests(); CreateTrainerSpells(); + pCreature->LoadFromDB(db_guid, map); + + map->Add(pCreature); + objmgr.AddCreatureToGrid(db_guid, objmgr.GetCreatureData(db_guid)); + return true; +} + +bool ChatHandler::HandleDelCreatureCommand(const char* args) +{ + Creature* unit = NULL; + + if(*args) + { + // number or [name] Shift-click form |color|Hcreature:creature_guid|h[name]|h|r + char* cId = extractKeyFromLink((char*)args,"Hcreature"); + if(!cId) + return false; + + uint32 lowguid = atoi(cId); + if(!lowguid) + return false; + + if (CreatureData const* cr_data = objmgr.GetCreatureData(lowguid)) + unit = ObjectAccessor::GetCreature(*m_session->GetPlayer(), MAKE_NEW_GUID(lowguid, cr_data->id, HIGHGUID_UNIT)); + } + else + unit = getSelectedCreature(); + + if(!unit || unit->isPet() || unit->isTotem()) + { + SendSysMessage(LANG_SELECT_CREATURE); + SetSentErrorMessage(true); + return false; + } + + // Delete the creature + unit->CombatStop(); + unit->DeleteFromDB(); + unit->CleanupsBeforeDelete(); + unit->AddObjectToRemoveList(); + + SendSysMessage(LANG_COMMAND_DELCREATMESSAGE); + + return true; +} + +//delete object by selection or guid +bool ChatHandler::HandleDelObjectCommand(const char* args) +{ + // number or [name] Shift-click form |color|Hgameobject:go_guid|h[name]|h|r + char* cId = extractKeyFromLink((char*)args,"Hgameobject"); + if(!cId) + return false; + + uint32 lowguid = atoi(cId); + if(!lowguid) + return false; + + GameObject* obj = NULL; + + // by DB guid + if (GameObjectData const* go_data = objmgr.GetGOData(lowguid)) + obj = GetObjectGlobalyWithGuidOrNearWithDbGuid(lowguid,go_data->id); + + if(!obj) + { + PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, lowguid); + SetSentErrorMessage(true); + return false; + } + + uint64 owner_guid = obj->GetOwnerGUID(); + if(owner_guid) + { + Unit* owner = ObjectAccessor::GetUnit(*m_session->GetPlayer(),owner_guid); + if(!owner && !IS_PLAYER_GUID(owner_guid)) + { + PSendSysMessage(LANG_COMMAND_DELOBJREFERCREATURE, GUID_LOPART(owner_guid), obj->GetGUIDLow()); + SetSentErrorMessage(true); + return false; + } + + owner->RemoveGameObject(obj,false); + } + + obj->SetRespawnTime(0); // not save respawn time + obj->Delete(); + obj->DeleteFromDB(); + + PSendSysMessage(LANG_COMMAND_DELOBJMESSAGE, obj->GetGUIDLow()); + + return true; +} + +//turn selected object +bool ChatHandler::HandleTurnObjectCommand(const char* args) +{ + // number or [name] Shift-click form |color|Hgameobject:go_id|h[name]|h|r + char* cId = extractKeyFromLink((char*)args,"Hgameobject"); + if(!cId) + return false; + + uint32 lowguid = atoi(cId); + if(!lowguid) + return false; + + GameObject* obj = NULL; + + // by DB guid + if (GameObjectData const* go_data = objmgr.GetGOData(lowguid)) + obj = GetObjectGlobalyWithGuidOrNearWithDbGuid(lowguid,go_data->id); + + if(!obj) + { + PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, lowguid); + SetSentErrorMessage(true); + return false; + } + + char* po = strtok(NULL, " "); + float o; + + if (po) + { + o = (float)atof(po); + } + else + { + Player *chr = m_session->GetPlayer(); + o = chr->GetOrientation(); + } + + float rot2 = sin(o/2); + float rot3 = cos(o/2); + + Map* map = MapManager::Instance().GetMap(obj->GetMapId(),obj); + map->Remove(obj,false); + + obj->Relocate(obj->GetPositionX(), obj->GetPositionY(), obj->GetPositionZ(), o); + + obj->SetFloatValue(GAMEOBJECT_FACING, o); + obj->SetFloatValue(GAMEOBJECT_ROTATION+2, rot2); + obj->SetFloatValue(GAMEOBJECT_ROTATION+3, rot3); + + map->Add(obj); + + obj->SaveToDB(); + obj->Refresh(); + + PSendSysMessage(LANG_COMMAND_TURNOBJMESSAGE, obj->GetGUIDLow(), o); + + return true; +} + +//move selected creature +bool ChatHandler::HandleMoveCreatureCommand(const char* args) +{ + uint32 lowguid = 0; + + Creature* pCreature = getSelectedCreature(); + + if(!pCreature) + { + // number or [name] Shift-click form |color|Hcreature:creature_guid|h[name]|h|r + char* cId = extractKeyFromLink((char*)args,"Hcreature"); + if(!cId) + return false; + + uint32 lowguid = atoi(cId); + + /* FIXME: impossibel without entry + if(lowguid) + pCreature = ObjectAccessor::GetCreature(*m_session->GetPlayer(),MAKE_GUID(lowguid,HIGHGUID_UNIT)); + */ + + // Attempting creature load from DB data + if(!pCreature) + { + CreatureData const* data = objmgr.GetCreatureData(lowguid); + if(!data) + { + PSendSysMessage(LANG_COMMAND_CREATGUIDNOTFOUND, lowguid); + SetSentErrorMessage(true); + return false; + } + + uint32 map_id = data->mapid; + + if(m_session->GetPlayer()->GetMapId()!=map_id) + { + PSendSysMessage(LANG_COMMAND_CREATUREATSAMEMAP, lowguid); + SetSentErrorMessage(true); + return false; + } + } + else + { + lowguid = pCreature->GetDBTableGUIDLow(); + } + } + else + { + lowguid = pCreature->GetDBTableGUIDLow(); + } + + float x = m_session->GetPlayer()->GetPositionX(); + float y = m_session->GetPlayer()->GetPositionY(); + float z = m_session->GetPlayer()->GetPositionZ(); + float o = m_session->GetPlayer()->GetOrientation(); + + if (pCreature) + { + if(CreatureData const* data = objmgr.GetCreatureData(pCreature->GetDBTableGUIDLow())) + { + const_cast(data)->posX = x; + const_cast(data)->posY = y; + const_cast(data)->posZ = z; + const_cast(data)->orientation = o; + } + MapManager::Instance().GetMap(pCreature->GetMapId(),pCreature)->CreatureRelocation(pCreature,x, y, z,o); + pCreature->GetMotionMaster()->Initialize(); + if(pCreature->isAlive()) // dead creature will reset movement generator at respawn + { + pCreature->setDeathState(JUST_DIED); + pCreature->Respawn(); + } + } + + WorldDatabase.PExecuteLog("UPDATE creature SET position_x = '%f', position_y = '%f', position_z = '%f', orientation = '%f' WHERE guid = '%u'", x, y, z, o, lowguid); + PSendSysMessage(LANG_COMMAND_CREATUREMOVED); + return true; +} + +//move selected object +bool ChatHandler::HandleMoveObjectCommand(const char* args) +{ + // number or [name] Shift-click form |color|Hgameobject:go_guid|h[name]|h|r + char* cId = extractKeyFromLink((char*)args,"Hgameobject"); + if(!cId) + return false; + + uint32 lowguid = atoi(cId); + if(!lowguid) + return false; + + GameObject* obj = NULL; + + // by DB guid + if (GameObjectData const* go_data = objmgr.GetGOData(lowguid)) + obj = GetObjectGlobalyWithGuidOrNearWithDbGuid(lowguid,go_data->id); + + if(!obj) + { + PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, lowguid); + SetSentErrorMessage(true); + return false; + } + + char* px = strtok(NULL, " "); + char* py = strtok(NULL, " "); + char* pz = strtok(NULL, " "); + + if (!px) + { + Player *chr = m_session->GetPlayer(); + + Map* map = MapManager::Instance().GetMap(obj->GetMapId(),obj); + map->Remove(obj,false); + + obj->Relocate(chr->GetPositionX(), chr->GetPositionY(), chr->GetPositionZ(), obj->GetOrientation()); + obj->SetFloatValue(GAMEOBJECT_POS_X, chr->GetPositionX()); + obj->SetFloatValue(GAMEOBJECT_POS_Y, chr->GetPositionY()); + obj->SetFloatValue(GAMEOBJECT_POS_Z, chr->GetPositionZ()); + + map->Add(obj); + } + else + { + if(!py || !pz) + return false; + + float x = (float)atof(px); + float y = (float)atof(py); + float z = (float)atof(pz); + + if(!MapManager::IsValidMapCoord(obj->GetMapId(),x,y,z)) + { + PSendSysMessage(LANG_INVALID_TARGET_COORD,x,y,obj->GetMapId()); + SetSentErrorMessage(true); + return false; + } + + Map* map = MapManager::Instance().GetMap(obj->GetMapId(),obj); + map->Remove(obj,false); + + obj->Relocate(x, y, z, obj->GetOrientation()); + obj->SetFloatValue(GAMEOBJECT_POS_X, x); + obj->SetFloatValue(GAMEOBJECT_POS_Y, y); + obj->SetFloatValue(GAMEOBJECT_POS_Z, z); + + map->Add(obj); + } + + obj->SaveToDB(); + obj->Refresh(); + + PSendSysMessage(LANG_COMMAND_MOVEOBJMESSAGE, obj->GetGUIDLow()); + + return true; +} + +//demorph player or unit +bool ChatHandler::HandleDeMorphCommand(const char* /*args*/) +{ + Unit *target = getSelectedUnit(); + if(!target) + target = m_session->GetPlayer(); + + target->DeMorph(); + + return true; +} + +//add item in vendorlist +bool ChatHandler::HandleAddVendorItemCommand(const char* args) +{ + if (!*args) + return false; + + Creature* vendor = getSelectedCreature(); + if (!vendor || !vendor->isVendor()) + { + SendSysMessage(LANG_COMMAND_VENDORSELECTION); + SetSentErrorMessage(true); + return false; + } + + char* pitem = extractKeyFromLink((char*)args,"Hitem"); + if (!pitem) + { + SendSysMessage(LANG_COMMAND_NEEDITEMSEND); + SetSentErrorMessage(true); + return false; + } + uint32 itemId = atol(pitem); + + char* fmaxcount = strtok(NULL, " "); //add maxcount, default: 0 + uint32 maxcount = 0; + if (fmaxcount) + maxcount = atol(fmaxcount); + + char* fincrtime = strtok(NULL, " "); //add incrtime, default: 0 + uint32 incrtime = 0; + if (fincrtime) + incrtime = atol(fincrtime); + + char* fextendedcost = strtok(NULL, " "); //add ExtendedCost, default: 0 + uint32 extendedcost = fextendedcost ? atol(fextendedcost) : 0; + + ItemPrototype const *pProto = objmgr.GetItemPrototype(itemId); + if(!pProto) + { + PSendSysMessage(LANG_ITEM_NOT_FOUND, itemId); + SetSentErrorMessage(true); + return false; + } + + if(extendedcost && !sItemExtendedCostStore.LookupEntry(extendedcost)) + { + PSendSysMessage(LANG_BAD_VALUE, extendedcost); + SetSentErrorMessage(true); + return false; + } + + // load vendor items if not yet + vendor->LoadGoods(); + + if(vendor->FindItem(itemId)) + { + PSendSysMessage(LANG_ITEM_ALREADY_IN_LIST,itemId); + SetSentErrorMessage(true); + return false; + } + + if (vendor->GetItemCount() >= MAX_VENDOR_ITEMS) + { + SendSysMessage(LANG_COMMAND_ADDVENDORITEMITEMS); + SetSentErrorMessage(true); + return false; + } + + // add to DB and to current ingame vendor + WorldDatabase.PExecuteLog("INSERT INTO npc_vendor (entry,item,maxcount,incrtime,extendedcost) VALUES('%u','%u','%u','%u','%u')",vendor->GetEntry(), itemId, maxcount,incrtime,extendedcost); + vendor->AddItem(itemId,maxcount,incrtime,extendedcost); + PSendSysMessage(LANG_ITEM_ADDED_TO_LIST,itemId,pProto->Name1,maxcount,incrtime,extendedcost); + return true; +} + +//del item from vendor list +bool ChatHandler::HandleDelVendorItemCommand(const char* args) +{ + if (!*args) + return false; + + Creature* vendor = getSelectedCreature(); + if (!vendor || !vendor->isVendor()) + { + SendSysMessage(LANG_COMMAND_VENDORSELECTION); + SetSentErrorMessage(true); + return false; + } + + char* pitem = extractKeyFromLink((char*)args,"Hitem"); + if (!pitem) + { + SendSysMessage(LANG_COMMAND_NEEDITEMSEND); + SetSentErrorMessage(true); + return false; + } + uint32 itemId = atol(pitem); + + ItemPrototype const *pProto = objmgr.GetItemPrototype(itemId); + if(!pProto) + { + PSendSysMessage(LANG_ITEM_NOT_FOUND, itemId); + SetSentErrorMessage(true); + return false; + } + + // load vendor items if not yet + vendor->LoadGoods(); + + if (!vendor->RemoveItem(itemId)) + { + PSendSysMessage(LANG_ITEM_NOT_IN_LIST,itemId); + SetSentErrorMessage(true); + return false; + } + + WorldDatabase.PExecuteLog("DELETE FROM npc_vendor WHERE entry='%u' AND item='%u'",vendor->GetEntry(), itemId); + PSendSysMessage(LANG_ITEM_DELETED_FROM_LIST,itemId,pProto->Name1); + return true; +} + +//add move for creature +bool ChatHandler::HandleAddMoveCommand(const char* args) +{ + if(!*args) + return false; + + char* guid_str = strtok((char*)args, " "); + char* wait_str = strtok((char*)NULL, " "); + + uint32 lowguid = atoi((char*)guid_str); + + Creature* pCreature = NULL; + + /* FIXME: impossible without entry + if(lowguid) + pCreature = ObjectAccessor::GetCreature(*m_session->GetPlayer(),MAKE_GUID(lowguid,HIGHGUID_UNIT)); + */ + + // attempt check creature existence by DB data + if(!pCreature) + { + CreatureData const* data = objmgr.GetCreatureData(lowguid); + if(!data) + { + PSendSysMessage(LANG_COMMAND_CREATGUIDNOTFOUND, lowguid); + SetSentErrorMessage(true); + return false; + } + } + else + { + // obtain real GUID for DB operations + lowguid = pCreature->GetDBTableGUIDLow(); + } + + int wait = wait_str ? atoi(wait_str) : 0; + + if(wait < 0) + wait = 0; + + Player* player = m_session->GetPlayer(); + + WaypointMgr.AddLastNode(lowguid, player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), player->GetOrientation(), wait, 0); + + // update movement type + WorldDatabase.PExecuteLog("UPDATE creature SET MovementType = '%u' WHERE guid = '%u'", WAYPOINT_MOTION_TYPE,lowguid); + if(pCreature) + { + pCreature->SetDefaultMovementType(WAYPOINT_MOTION_TYPE); + pCreature->GetMotionMaster()->Initialize(); + if(pCreature->isAlive()) // dead creature will reset movement generator at respawn + { + pCreature->setDeathState(JUST_DIED); + pCreature->Respawn(); + } + pCreature->SaveToDB(); + } + + SendSysMessage(LANG_WAYPOINT_ADDED); + + return true; +} + +/** + * Set the movement type for an NPC.
+ *
+ * Valid movement types are: + *
    + *
  • stay - NPC wont move
  • + *
  • random - NPC will move randomly according to the spawndist
  • + *
  • way - NPC will move with given waypoints set
  • + *
+ * additional parameter: NODEL - so no waypoints are deleted, if you + * change the movement type + */ +bool ChatHandler::HandleSetMoveTypeCommand(const char* args) +{ + if(!*args) + return false; + + // 3 arguments: + // GUID (optional - you can also select the creature) + // stay|random|way (determines the kind of movement) + // NODEL (optional - tells the system NOT to delete any waypoints) + // this is very handy if you want to do waypoints, that are + // later switched on/off according to special events (like escort + // quests, etc) + char* guid_str = strtok((char*)args, " "); + char* type_str = strtok((char*)NULL, " "); + char* dontdel_str = strtok((char*)NULL, " "); + + bool doNotDelete = false; + + if(!guid_str) + return false; + + uint32 lowguid = 0; + Creature* pCreature = NULL; + + if( dontdel_str ) + { + //sLog.outError("DEBUG: All 3 params are set"); + + // All 3 params are set + // GUID + // type + // doNotDEL + if( stricmp( dontdel_str, "NODEL" ) == 0 ) + { + //sLog.outError("DEBUG: doNotDelete = true;"); + doNotDelete = true; + } + } + else + { + // Only 2 params - but maybe NODEL is set + if( type_str ) + { + sLog.outError("DEBUG: Only 2 params "); + if( stricmp( type_str, "NODEL" ) == 0 ) + { + //sLog.outError("DEBUG: type_str, NODEL "); + doNotDelete = true; + type_str = NULL; + } + } + } + + if(!type_str) // case .setmovetype $move_type (with selected creature) + { + type_str = guid_str; + pCreature = getSelectedCreature(); + if(!pCreature) + return false; + lowguid = pCreature->GetDBTableGUIDLow(); + } + else // case .setmovetype #creature_guid $move_type (with selected creature) + { + lowguid = atoi((char*)guid_str); + + /* impossible without entry + if(lowguid) + pCreature = ObjectAccessor::GetCreature(*m_session->GetPlayer(),MAKE_GUID(lowguid,HIGHGUID_UNIT)); + */ + + // attempt check creature existence by DB data + if(!pCreature) + { + CreatureData const* data = objmgr.GetCreatureData(lowguid); + if(!data) + { + PSendSysMessage(LANG_COMMAND_CREATGUIDNOTFOUND, lowguid); + SetSentErrorMessage(true); + return false; + } + } + else + { + lowguid = pCreature->GetDBTableGUIDLow(); + } + } + + // now lowguid is low guid really existed creature + // and pCreature point (maybe) to this creature or NULL + + MovementGeneratorType move_type; + + std::string type = type_str; + + if(type == "stay") + move_type = IDLE_MOTION_TYPE; + else if(type == "random") + move_type = RANDOM_MOTION_TYPE; + else if(type == "way") + move_type = WAYPOINT_MOTION_TYPE; + else + return false; + + // update movement type + if(doNotDelete == false) + WaypointMgr.DeletePath(lowguid); + + if(pCreature) + { + pCreature->SetDefaultMovementType(move_type); + pCreature->GetMotionMaster()->Initialize(); + if(pCreature->isAlive()) // dead creature will reset movement generator at respawn + { + pCreature->setDeathState(JUST_DIED); + pCreature->Respawn(); + } + pCreature->SaveToDB(); + } + if( doNotDelete == false ) + { + PSendSysMessage(LANG_MOVE_TYPE_SET,type_str); + } + else + { + PSendSysMessage(LANG_MOVE_TYPE_SET_NODEL,type_str); + } + + return true; +} // HandleSetMoveTypeCommand + +//change level of creature or pet +bool ChatHandler::HandleChangeLevelCommand(const char* args) +{ + if (!*args) + return false; + + uint8 lvl = (uint8) atoi((char*)args); + if ( lvl < 1 || lvl > sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL) + 3) + { + SendSysMessage(LANG_BAD_VALUE); + SetSentErrorMessage(true); + return false; + } + + Creature* pCreature = getSelectedCreature(); + if(!pCreature) + { + SendSysMessage(LANG_SELECT_CREATURE); + SetSentErrorMessage(true); + return false; + } + + if(pCreature->isPet()) + { + ((Pet*)pCreature)->GivePetLevel(lvl); + } + else + { + pCreature->SetMaxHealth( 100 + 30*lvl); + pCreature->SetHealth( 100 + 30*lvl); + pCreature->SetLevel( lvl); + pCreature->SaveToDB(); + } + + return true; +} + +//set npcflag of creature +bool ChatHandler::HandleNPCFlagCommand(const char* args) +{ + if (!*args) + return false; + + uint32 npcFlags = (uint32) atoi((char*)args); + + Creature* pCreature = getSelectedCreature(); + + if(!pCreature) + { + SendSysMessage(LANG_SELECT_CREATURE); + SetSentErrorMessage(true); + return false; + } + + pCreature->SetUInt32Value(UNIT_NPC_FLAGS, npcFlags); + + WorldDatabase.PExecuteLog("UPDATE creature_template SET npcflag = '%u' WHERE entry = '%u'", npcFlags, pCreature->GetEntry()); + + SendSysMessage(LANG_VALUE_SAVED_REJOIN); + + return true; +} + +//set model of creature +bool ChatHandler::HandleSetModelCommand(const char* args) +{ + if (!*args) + return false; + + uint32 displayId = (uint32) atoi((char*)args); + + Creature *pCreature = getSelectedCreature(); + + if(!pCreature) + { + SendSysMessage(LANG_SELECT_CREATURE); + SetSentErrorMessage(true); + return false; + } + + pCreature->SetDisplayId(displayId); + pCreature->SetNativeDisplayId(displayId); + + pCreature->SaveToDB(); + + return true; +} + +//morph creature or player +bool ChatHandler::HandleMorphCommand(const char* args) +{ + if (!*args) + return false; + + uint16 display_id = (uint16)atoi((char*)args); + + Unit *target = getSelectedUnit(); + if(!target) + target = m_session->GetPlayer(); + + target->SetDisplayId(display_id); + + return true; +} + +//set faction of creature or go +bool ChatHandler::HandleFactionIdCommand(const char* args) +{ + if (!*args) + return false; + + uint32 factionId = (uint32) atoi((char*)args); + + if (!sFactionTemplateStore.LookupEntry(factionId)) + { + PSendSysMessage(LANG_WRONG_FACTION, factionId); + SetSentErrorMessage(true); + return false; + } + + Creature* pCreature = getSelectedCreature(); + + if(!pCreature) + { + SendSysMessage(LANG_SELECT_CREATURE); + SetSentErrorMessage(true); + return false; + } + + pCreature->setFaction(factionId); + + // faction is set in creature_template - not inside creature + + // update in memory + if(CreatureInfo const *cinfo = pCreature->GetCreatureInfo()) + { + const_cast(cinfo)->faction_A = factionId; + const_cast(cinfo)->faction_H = factionId; + } + + // and DB + WorldDatabase.PExecuteLog("UPDATE creature_template SET faction_A = '%u', faction_H = '%u' WHERE entry = '%u'", factionId, factionId, pCreature->GetEntry()); + + return true; +} + +//kick player +bool ChatHandler::HandleKickPlayerCommand(const char *args) +{ + char* kickName = strtok((char*)args, " "); + if (!kickName) + { + Player* player = getSelectedPlayer(); + + if(!player) + { + SendSysMessage(LANG_NO_CHAR_SELECTED); + SetSentErrorMessage(true); + return false; + } + + if(player==m_session->GetPlayer()) + { + SendSysMessage(LANG_COMMAND_KICKSELF); + SetSentErrorMessage(true); + return false; + } + + player->GetSession()->KickPlayer(); + } + else + { + std::string name = kickName; + if(!normalizePlayerName(name)) + { + SendSysMessage(LANG_PLAYER_NOT_FOUND); + SetSentErrorMessage(true); + return false; + } + + if(name==m_session->GetPlayer()->GetName()) + { + SendSysMessage(LANG_COMMAND_KICKSELF); + SetSentErrorMessage(true); + return false; + } + + if(sWorld.KickPlayer(name)) + { + PSendSysMessage(LANG_COMMAND_KICKMESSAGE,name.c_str()); + } + else + PSendSysMessage(LANG_COMMAND_KICKNOTFOUNDPLAYER,name.c_str()); + } + + return true; +} + +//show info of player +bool ChatHandler::HandlePInfoCommand(const char* args) +{ + Player* target = NULL; + uint64 targetGUID = 0; + + char* px = strtok((char*)args, " "); + char* py = NULL; + + std::string name; + + if (px) + { + name = px; + + if(name.empty()) + return false; + + if(!normalizePlayerName(name)) + { + SendSysMessage(LANG_PLAYER_NOT_FOUND); + SetSentErrorMessage(true); + return false; + } + + target = objmgr.GetPlayer(name.c_str()); + if (target) + py = strtok(NULL, " "); + else + { + targetGUID = objmgr.GetPlayerGUIDByName(name); + if(targetGUID) + py = strtok(NULL, " "); + else + py = px; + } + } + + if(!target && !targetGUID) + { + target = getSelectedPlayer(); + } + + if(!target && !targetGUID) + { + SendSysMessage(LANG_PLAYER_NOT_FOUND); + SetSentErrorMessage(true); + return false; + } + + uint32 accId = 0; + uint32 money = 0; + uint32 total_player_time = 0; + uint32 level = 0; + uint32 latency = 0; + + // get additional information from Player object + if(target) + { + targetGUID = target->GetGUID(); + name = target->GetName(); // re-read for case getSelectedPlayer() target + accId = target->GetSession()->GetAccountId(); + money = target->GetMoney(); + total_player_time = target->GetTotalPlayedTime(); + level = target->getLevel(); + latency = target->GetSession()->GetLatency(); + } + // get additional information from DB + else + { + accId = objmgr.GetPlayerAccountIdByGUID(targetGUID); + Player plr(m_session); // use current session for temporary load + plr.MinimalLoadFromDB(NULL, targetGUID); + money = plr.GetMoney(); + total_player_time = plr.GetTotalPlayedTime(); + level = plr.getLevel(); + } + + std::string username = GetMangosString(LANG_ERROR); + std::string last_ip = GetMangosString(LANG_ERROR); + uint32 security = 0; + std::string last_login = GetMangosString(LANG_ERROR); + + QueryResult* result = loginDatabase.PQuery("SELECT username,gmlevel,last_ip,last_login FROM account WHERE id = '%u'",accId); + if(result) + { + Field* fields = result->Fetch(); + username = fields[0].GetCppString(); + security = fields[1].GetUInt32(); + if(m_session->GetSecurity() >= security) + { + last_ip = fields[2].GetCppString(); + last_login = fields[3].GetCppString(); + } + else + { + last_ip = "-"; + last_login = "-"; + } + + delete result; + } + + PSendSysMessage(LANG_PINFO_ACCOUNT, (target?"":GetMangosString(LANG_OFFLINE)), name.c_str(), GUID_LOPART(targetGUID), username.c_str(), accId, security, last_ip.c_str(), last_login.c_str(), latency); + + std::string timeStr = secsToTimeString(total_player_time,true,true); + uint32 gold = money /GOLD; + uint32 silv = (money % GOLD) / SILVER; + uint32 copp = (money % GOLD) % SILVER; + PSendSysMessage(LANG_PINFO_LEVEL, timeStr.c_str(), level, gold,silv,copp ); + + if ( py && strncmp(py, "rep", 3) == 0 ) + { + if(!target) + { + // rep option not implemented for offline case + SendSysMessage(LANG_PINFO_NO_REP); + SetSentErrorMessage(true); + return false; + } + + char* FactionName; + for(FactionStateList::const_iterator itr = target->m_factions.begin(); itr != target->m_factions.end(); ++itr) + { + FactionEntry const *factionEntry = sFactionStore.LookupEntry(itr->second.ID); + if (factionEntry) + FactionName = factionEntry->name[m_session->GetSessionDbcLocale()]; + else + FactionName = "#Not found#"; + ReputationRank rank = target->GetReputationRank(factionEntry); + std::string rankName = GetMangosString(ReputationRankStrIndex[rank]); + std::ostringstream ss; + ss << itr->second.ID << ": |cffffffff|Hfaction:" << itr->second.ID << "|h[" << FactionName << "]|h|r " << rankName << "|h|r (" << target->GetReputation(factionEntry) << ")"; + + if(itr->second.Flags & FACTION_FLAG_VISIBLE) + ss << GetMangosString(LANG_FACTION_VISIBLE); + if(itr->second.Flags & FACTION_FLAG_AT_WAR) + ss << GetMangosString(LANG_FACTION_ATWAR); + if(itr->second.Flags & FACTION_FLAG_PEACE_FORCED) + ss << GetMangosString(LANG_FACTION_PEACE_FORCED); + if(itr->second.Flags & FACTION_FLAG_HIDDEN) + ss << GetMangosString(LANG_FACTION_HIDDEN); + if(itr->second.Flags & FACTION_FLAG_INVISIBLE_FORCED) + ss << GetMangosString(LANG_FACTION_INVISIBLE_FORCED); + if(itr->second.Flags & FACTION_FLAG_INACTIVE) + ss << GetMangosString(LANG_FACTION_INACTIVE); + + SendSysMessage(ss.str().c_str()); + } + } + return true; +} + +//show tickets +void ChatHandler::ShowTicket(uint64 guid, char const* text, char const* time) +{ + std::string name; + if(!objmgr.GetPlayerNameByGUID(guid,name)) + name = GetMangosString(LANG_UNKNOWN); + + PSendSysMessage(LANG_COMMAND_TICKETVIEW, name.c_str(),time,text); +} + +//ticket commands +bool ChatHandler::HandleTicketCommand(const char* args) +{ + char* px = strtok((char*)args, " "); + + // ticket + if (!px) + { + size_t count; + QueryResult *result = CharacterDatabase.Query("SELECT COUNT(ticket_id) FROM character_ticket"); + if(result) + { + count = (*result)[0].GetUInt32(); + delete result; + } + else + count = 0; + + PSendSysMessage(LANG_COMMAND_TICKETCOUNT, count, m_session->GetPlayer()->isAcceptTickets() ? GetMangosString(LANG_ON) : GetMangosString(LANG_OFF)); + return true; + } + + // ticket on + if(strncmp(px,"on",3) == 0) + { + m_session->GetPlayer()->SetAcceptTicket(true); + SendSysMessage(LANG_COMMAND_TICKETON); + return true; + } + + // ticket off + if(strncmp(px,"off",4) == 0) + { + m_session->GetPlayer()->SetAcceptTicket(false); + SendSysMessage(LANG_COMMAND_TICKETOFF); + return true; + } + + // ticket #num + int num = atoi(px); + if(num > 0) + { + QueryResult *result = CharacterDatabase.PQuery("SELECT guid,ticket_text,ticket_lastchange FROM character_ticket ORDER BY ticket_id ASC LIMIT %d,1",num-1); + + if(!result) + { + PSendSysMessage(LANG_COMMAND_TICKENOTEXIST, num); + delete result; + SetSentErrorMessage(true); + return false; + } + + Field* fields = result->Fetch(); + + uint64 guid = fields[0].GetUInt64(); + char const* text = fields[1].GetString(); + char const* time = fields[2].GetString(); + + ShowTicket(guid,text,time); + delete result; + return true; + } + + std::string name = px; + + if(!normalizePlayerName(name)) + { + SendSysMessage(LANG_PLAYER_NOT_FOUND); + SetSentErrorMessage(true); + return false; + } + + uint64 guid = objmgr.GetPlayerGUIDByName(name); + + if(!guid) + return false; + + // ticket $char_name + QueryResult *result = CharacterDatabase.PQuery("SELECT ticket_text,ticket_lastchange FROM character_ticket WHERE guid = '%u' ORDER BY ticket_id ASC",GUID_LOPART(guid)); + + if(!result) + return false; + + Field* fields = result->Fetch(); + + char const* text = fields[0].GetString(); + char const* time = fields[1].GetString(); + + ShowTicket(guid,text,time); + delete result; + + return true; +} + +uint32 ChatHandler::GetTicketIDByNum(uint32 num) +{ + QueryResult *result = CharacterDatabase.Query("SELECT ticket_id FROM character_ticket"); + + if(!result || num > result->GetRowCount()) + { + PSendSysMessage(LANG_COMMAND_TICKENOTEXIST, num); + delete result; + return 0; + } + + for(uint32 i = 1; i < num; ++i) + result->NextRow(); + + Field* fields = result->Fetch(); + + uint32 id = fields[0].GetUInt32(); + delete result; + return id; +} + +//dell all tickets +bool ChatHandler::HandleDelTicketCommand(const char *args) +{ + char* px = strtok((char*)args, " "); + if (!px) + return false; + + // delticket all + if(strncmp(px,"all",4) == 0) + { + QueryResult *result = CharacterDatabase.Query("SELECT guid FROM character_ticket"); + + if(!result) + return true; + + // notify players about ticket deleting + do + { + Field* fields = result->Fetch(); + + uint64 guid = fields[0].GetUInt64(); + + if(Player* sender = objmgr.GetPlayer(guid)) + sender->GetSession()->SendGMTicketGetTicket(0x0A,0); + + }while(result->NextRow()); + + delete result; + + CharacterDatabase.PExecute("DELETE FROM character_ticket"); + SendSysMessage(LANG_COMMAND_ALLTICKETDELETED); + return true; + } + + int num = (uint32)atoi(px); + + // delticket #num + if(num > 0) + { + QueryResult *result = CharacterDatabase.PQuery("SELECT ticket_id,guid FROM character_ticket LIMIT %i",num); + + if(!result || uint64(num) > result->GetRowCount()) + { + PSendSysMessage(LANG_COMMAND_TICKENOTEXIST, num); + delete result; + SetSentErrorMessage(true); + return false; + } + + for(int i = 1; i < num; ++i) + result->NextRow(); + + Field* fields = result->Fetch(); + + uint32 id = fields[0].GetUInt32(); + uint64 guid = fields[1].GetUInt64(); + delete result; + + CharacterDatabase.PExecute("DELETE FROM character_ticket WHERE ticket_id = '%u'", id); + + // notify players about ticket deleting + if(Player* sender = objmgr.GetPlayer(guid)) + { + sender->GetSession()->SendGMTicketGetTicket(0x0A,0); + PSendSysMessage(LANG_COMMAND_TICKETPLAYERDEL,sender->GetName()); + } + else + SendSysMessage(LANG_COMMAND_TICKETDEL); + + return true; + } + + std::string name = px; + + if(!normalizePlayerName(name)) + { + SendSysMessage(LANG_PLAYER_NOT_FOUND); + SetSentErrorMessage(true); + return false; + } + + uint64 guid = objmgr.GetPlayerGUIDByName(name); + + if(!guid) + return false; + + // delticket $char_name + CharacterDatabase.PExecute("DELETE FROM character_ticket WHERE guid = '%u'",GUID_LOPART(guid)); + + // notify players about ticket deleting + if(Player* sender = objmgr.GetPlayer(guid)) + sender->GetSession()->SendGMTicketGetTicket(0x0A,0); + + PSendSysMessage(LANG_COMMAND_TICKETPLAYERDEL,px); + return true; +} + +//set spawn dist of creature +bool ChatHandler::HandleSpawnDistCommand(const char* args) +{ + if(!*args) + return false; + + float option = atof((char*)args); + if (option < 0.0f) + { + SendSysMessage(LANG_BAD_VALUE); + return false; + } + + MovementGeneratorType mtype = IDLE_MOTION_TYPE; + if (option >0.0f) + mtype = RANDOM_MOTION_TYPE; + + Creature *pCreature = getSelectedCreature(); + uint32 u_guidlow = 0; + + if (pCreature) + u_guidlow = pCreature->GetDBTableGUIDLow(); + else + return false; + + pCreature->SetRespawnRadius((float)option); + pCreature->SetDefaultMovementType(mtype); + pCreature->GetMotionMaster()->Initialize(); + if(pCreature->isAlive()) // dead creature will reset movement generator at respawn + { + pCreature->setDeathState(JUST_DIED); + pCreature->Respawn(); + } + + WorldDatabase.PExecuteLog("UPDATE creature SET spawndist=%f, MovementType=%i WHERE guid=%u",option,mtype,u_guidlow); + PSendSysMessage(LANG_COMMAND_SPAWNDIST,option); + return true; +} + +bool ChatHandler::HandleSpawnTimeCommand(const char* args) +{ + if(!*args) + return false; + + char* stime = strtok((char*)args, " "); + + if (!stime) + return false; + + int i_stime = atoi((char*)stime); + + if (i_stime < 0) + { + SendSysMessage(LANG_BAD_VALUE); + SetSentErrorMessage(true); + return false; + } + + Creature *pCreature = getSelectedCreature(); + uint32 u_guidlow = 0; + + if (pCreature) + u_guidlow = pCreature->GetDBTableGUIDLow(); + else + return false; + + WorldDatabase.PExecuteLog("UPDATE creature SET spawntimesecs=%i WHERE guid=%u",i_stime,u_guidlow); + pCreature->SetRespawnDelay((uint32)i_stime); + PSendSysMessage(LANG_COMMAND_SPAWNTIME,i_stime); + + return true; +} + +/** + * Add a waypoint to a creature. + * + * The user can either select an npc or provide its GUID. + * + * The user can even select a visual waypoint - then the new waypoint + * is placed *after* the selected one - this makes insertion of new + * waypoints possible. + * + * eg: + * .wp add 12345 + * -> adds a waypoint to the npc with the GUID 12345 + * + * .wp add + * -> adds a waypoint to the currently selected creature + * + * + * @param args if the user did not provide a GUID, it is NULL + * + * @return true - command did succeed, false - something went wrong + */ +bool ChatHandler::HandleWpAddCommand(const char* args) +{ + sLog.outDebug("DEBUG: HandleWpAddCommand"); + + // optional + char* guid_str = NULL; + + if(*args) + { + guid_str = strtok((char*)args, " "); + } + + uint32 lowguid = 0; + uint32 point = 0; + Creature* target = getSelectedCreature(); + // Did player provide a GUID? + if (!guid_str) + { + sLog.outDebug("DEBUG: HandleWpAddCommand - No GUID provided"); + + // No GUID provided + // -> Player must have selected a creature + + if(!target) + { + SendSysMessage(LANG_SELECT_CREATURE); + SetSentErrorMessage(true); + return false; + } + if (target->GetEntry() == VISUAL_WAYPOINT ) + { + sLog.outDebug("DEBUG: HandleWpAddCommand - target->GetEntry() == VISUAL_WAYPOINT (1) "); + + QueryResult *result = + WorldDatabase.PQuery( "SELECT id, point FROM creature_movement WHERE wpguid = %u", + target->GetGUIDLow() ); + if(!result) + { + PSendSysMessage(LANG_WAYPOINT_NOTFOUNDSEARCH, target->GetGUIDLow()); + // User selected a visual spawnpoint -> get the NPC + // Select NPC GUID + // Since we compare float values, we have to deal with + // some difficulties. + // Here we search for all waypoints that only differ in one from 1 thousand + // (0.001) - There is no other way to compare C++ floats with mySQL floats + // See also: http://dev.mysql.com/doc/refman/5.0/en/problems-with-float.html + const char* maxDIFF = "0.01"; + result = WorldDatabase.PQuery( "SELECT id, point FROM creature_movement WHERE (abs(position_x - %f) <= %s ) and (abs(position_y - %f) <= %s ) and (abs(position_z - %f) <= %s )", + target->GetPositionX(), maxDIFF, target->GetPositionY(), maxDIFF, target->GetPositionZ(), maxDIFF); + if(!result) + { + PSendSysMessage(LANG_WAYPOINT_NOTFOUNDDBPROBLEM, target->GetGUIDLow()); + SetSentErrorMessage(true); + return false; + } + } + do + { + Field *fields = result->Fetch(); + lowguid = fields[0].GetUInt32(); + point = fields[1].GetUInt32(); + }while( result->NextRow() ); + delete result; + + CreatureData const* data = objmgr.GetCreatureData(lowguid); + if(!data) + { + PSendSysMessage(LANG_WAYPOINT_CREATNOTFOUND, lowguid); + SetSentErrorMessage(true); + return false; + } + + target = ObjectAccessor::GetCreature(*m_session->GetPlayer(),MAKE_NEW_GUID(lowguid,data->id,HIGHGUID_UNIT)); + if(!target) + { + PSendSysMessage(LANG_WAYPOINT_NOTFOUNDDBPROBLEM, lowguid); + SetSentErrorMessage(true); + return false; + } + } + else + { + lowguid = target->GetDBTableGUIDLow(); + } + } + else + { + sLog.outDebug("DEBUG: HandleWpAddCommand - GUID provided"); + + // GUID provided + // Warn if player also selected a creature + // -> Creature selection is ignored <- + if(target) + { + SendSysMessage(LANG_WAYPOINT_CREATSELECTED); + } + lowguid = atoi((char*)guid_str); + + CreatureData const* data = objmgr.GetCreatureData(lowguid); + if(!data) + { + PSendSysMessage(LANG_WAYPOINT_CREATNOTFOUND, lowguid); + SetSentErrorMessage(true); + return false; + } + + target = ObjectAccessor::GetCreature(*m_session->GetPlayer(),MAKE_NEW_GUID(lowguid,data->id,HIGHGUID_UNIT)); + if(!target) + { + PSendSysMessage(LANG_WAYPOINT_CREATNOTFOUND, lowguid); + SetSentErrorMessage(true); + return false; + } + } + // lowguid -> GUID of the NPC + // point -> number of the waypoint (if not 0) + sLog.outDebug("DEBUG: HandleWpAddCommand - danach"); + + sLog.outDebug("DEBUG: HandleWpAddCommand - point == 0"); + + Player* player = m_session->GetPlayer(); + WaypointMgr.AddLastNode(lowguid, player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), player->GetOrientation(), 0, 0); + + // update movement type + if(target) + { + target->SetDefaultMovementType(WAYPOINT_MOTION_TYPE); + target->GetMotionMaster()->Initialize(); + if(target->isAlive()) // dead creature will reset movement generator at respawn + { + target->setDeathState(JUST_DIED); + target->Respawn(); + } + target->SaveToDB(); + } + else + WorldDatabase.PExecuteLog("UPDATE creature SET MovementType = '%u' WHERE guid = '%u'", WAYPOINT_MOTION_TYPE,lowguid); + + PSendSysMessage(LANG_WAYPOINT_ADDED, point, lowguid); + + return true; +} // HandleWpAddCommand + +/** + * .wp modify emote | spell | text | del | move | add + * + * add -> add a WP after the selected visual waypoint + * User must select a visual waypoint and then issue ".wp modify add" + * + * emote + * User has selected a visual waypoint before. + * is added to this waypoint. Everytime the + * NPC comes to this waypoint, the emote is called. + * + * emote + * User has not selected visual waypoint before. + * For the waypoint for the NPC with + * an emote is added. + * Everytime the NPC comes to this waypoint, the emote is called. + * + * + * info -> User did not select a visual waypoint and + */ +bool ChatHandler::HandleWpModifyCommand(const char* args) +{ + sLog.outDebug("DEBUG: HandleWpModifyCommand"); + + if(!*args) + return false; + + // first arg: add del text emote spell waittime move + char* show_str = strtok((char*)args, " "); + if (!show_str) + { + return false; + } + + std::string show = show_str; + // Check + // Remember: "show" must also be the name of a column! + if( (show != "emote") && (show != "spell") && (show != "text1") && (show != "text2") + && (show != "text3") && (show != "text4") && (show != "text5") + && (show != "waittime") && (show != "del") && (show != "move") && (show != "add") + && (show != "model1") && (show != "model2") && (show != "orientation")) + { + return false; + } + + // Next arg is: + + // Did user provide a GUID + // or did the user select a creature? + // -> variable lowguid is filled with the GUID of the NPC + uint32 lowguid = 0; + uint32 point = 0; + uint32 wpGuid = 0; + Creature* target = getSelectedCreature(); + + if(target) + { + sLog.outDebug("DEBUG: HandleWpModifyCommand - User did select an NPC"); + + // Did the user select a visual spawnpoint? + if (target->GetEntry() != VISUAL_WAYPOINT ) + { + PSendSysMessage(LANG_WAYPOINT_VP_SELECT); + SetSentErrorMessage(true); + return false; + } + + wpGuid = target->GetGUIDLow(); + + // The visual waypoint + QueryResult *result = + WorldDatabase.PQuery( "SELECT id, point FROM creature_movement WHERE wpguid = %u LIMIT 1", + target->GetGUIDLow() ); + if(!result) + { + PSendSysMessage(LANG_WAYPOINT_NOTFOUNDDBPROBLEM, wpGuid); + SetSentErrorMessage(true); + return false; + } + sLog.outDebug("DEBUG: HandleWpModifyCommand - After getting wpGuid"); + + Field *fields = result->Fetch(); + lowguid = fields[0].GetUInt32(); + point = fields[1].GetUInt32(); + + // Cleanup memory + sLog.outDebug("DEBUG: HandleWpModifyCommand - Cleanup memory"); + delete result; + } + else + { + // User did provide + + char* guid_str = strtok((char*)NULL, " "); + if( !guid_str ) + { + SendSysMessage(LANG_WAYPOINT_NOGUID); + return false; + } + lowguid = atoi((char*)guid_str); + + CreatureData const* data = objmgr.GetCreatureData(lowguid); + if(!data) + { + PSendSysMessage(LANG_WAYPOINT_CREATNOTFOUND, lowguid); + SetSentErrorMessage(true); + return false; + } + + PSendSysMessage("DEBUG: GUID provided: %d", lowguid); + + char* point_str = strtok((char*)NULL, " "); + if( !point_str ) + { + SendSysMessage(LANG_WAYPOINT_NOWAYPOINTGIVEN); + return false; + } + point = atoi((char*)point_str); + + PSendSysMessage("DEBUG: wpNumber provided: %d", point); + + // Now we need the GUID of the visual waypoint + // -> "del", "move", "add" command + + QueryResult *result = WorldDatabase.PQuery( "SELECT wpguid FROM creature_movement WHERE id = '%u' AND point = '%u' LIMIT 1", lowguid, point); + if (!result) + { + PSendSysMessage(LANG_WAYPOINT_NOTFOUNDSEARCH, lowguid, point); + SetSentErrorMessage(true); + return false; + } + + Field *fields = result->Fetch(); + wpGuid = fields[0].GetUInt32(); + + // Free memory + delete result; + } + + char* arg_str = NULL; + // Check for argument + if( (show.find("text") == std::string::npos ) && (show != "del") && (show != "move") && (show != "add")) + { + // Text is enclosed in "<>", all other arguments not + if( show.find("text") != std::string::npos ) + arg_str = strtok((char*)NULL, "<>"); + else + arg_str = strtok((char*)NULL, " "); + + if( !arg_str) + { + PSendSysMessage(LANG_WAYPOINT_ARGUMENTREQ, show_str); + return false; + } + } + + sLog.outDebug("DEBUG: HandleWpModifyCommand - Parameters parsed - now execute the command"); + + // wpGuid -> GUID of the waypoint creature + // lowguid -> GUID of the NPC + // point -> waypoint number + + // Special functions: + // add - move - del -> no args commands + // Add a waypoint after the selected visual + if(show == "add" && target) + { + PSendSysMessage("DEBUG: wp modify add, GUID: %u", lowguid); + + // Get the creature for which we read the waypoint + CreatureData const* data = objmgr.GetCreatureData(lowguid); + if(!data) + { + PSendSysMessage(LANG_WAYPOINT_CREATNOTFOUND, lowguid); + SetSentErrorMessage(true); + return false; + } + + Creature* npcCreature = ObjectAccessor::GetCreature(*m_session->GetPlayer(), MAKE_NEW_GUID(lowguid, data->id, HIGHGUID_UNIT)); + + if( !npcCreature ) + { + PSendSysMessage(LANG_WAYPOINT_NPCNOTFOUND); + SetSentErrorMessage(true); + return false; + } + + sLog.outDebug("DEBUG: HandleWpModifyCommand - add -- npcCreature"); + + // What to do: + // Add the visual spawnpoint (DB only) + // Adjust the waypoints + // Respawn the owner of the waypoints + sLog.outDebug("DEBUG: HandleWpModifyCommand - add"); + + Player* chr = m_session->GetPlayer(); + Map *map = chr->GetMap(); + + if(npcCreature) + { + npcCreature->GetMotionMaster()->Initialize(); + if(npcCreature->isAlive()) // dead creature will reset movement generator at respawn + { + npcCreature->setDeathState(JUST_DIED); + npcCreature->Respawn(); + } + } + + // create the waypoint creature + wpGuid = 0; + Creature* wpCreature = new Creature; + if (!wpCreature->Create(objmgr.GenerateLowGuid(HIGHGUID_UNIT), map,VISUAL_WAYPOINT,0)) + { + PSendSysMessage(LANG_WAYPOINT_VP_NOTCREATED, VISUAL_WAYPOINT); + delete wpCreature; + } + else + { + wpCreature->Relocate(chr->GetPositionX(), chr->GetPositionY(), chr->GetPositionZ(), chr->GetOrientation()); + + if(!wpCreature->IsPositionValid()) + { + sLog.outError("ERROR: Creature (guidlow %d, entry %d) not created. Suggested coordinates isn't valid (X: %f Y: %f)",wpCreature->GetGUIDLow(),wpCreature->GetEntry(),wpCreature->GetPositionX(),wpCreature->GetPositionY()); + delete wpCreature; + } + else + { + wpCreature->SaveToDB(map->GetId(), (1 << map->GetSpawnMode())); + // To call _LoadGoods(); _LoadQuests(); CreateTrainerSpells(); + wpCreature->LoadFromDB(wpCreature->GetDBTableGUIDLow(), map); + map->Add(wpCreature); + wpGuid = wpCreature->GetGUIDLow(); + } + } + + WaypointMgr.AddAfterNode(lowguid, point, chr->GetPositionX(), chr->GetPositionY(), chr->GetPositionZ(), 0, 0, wpGuid); + + if(!wpGuid) + return false; + + PSendSysMessage(LANG_WAYPOINT_ADDED_NO, point+1); + return true; + } // add + + if(show == "del" && target) + { + PSendSysMessage("DEBUG: wp modify del, GUID: %u", lowguid); + + // Get the creature for which we read the waypoint + CreatureData const* data = objmgr.GetCreatureData(lowguid); + if(!data) + { + PSendSysMessage(LANG_WAYPOINT_CREATNOTFOUND, lowguid); + SetSentErrorMessage(true); + return false; + } + + Creature* npcCreature = ObjectAccessor::GetCreature(*m_session->GetPlayer(), MAKE_NEW_GUID(lowguid, data->id, HIGHGUID_UNIT)); + + // wpCreature + Creature* wpCreature = NULL; + if( wpGuid != 0 ) + { + wpCreature = ObjectAccessor::GetCreature(*m_session->GetPlayer(),MAKE_NEW_GUID(wpGuid, VISUAL_WAYPOINT, HIGHGUID_UNIT)); + wpCreature->DeleteFromDB(); + wpCreature->CleanupsBeforeDelete(); + wpCreature->AddObjectToRemoveList(); + } + + // What to do: + // Remove the visual spawnpoint + // Adjust the waypoints + // Respawn the owner of the waypoints + + WaypointMgr.DeleteNode(lowguid, point); + + if(npcCreature) + { + // Any waypoints left? + QueryResult *result2 = WorldDatabase.PQuery( "SELECT point FROM creature_movement WHERE id = '%u'",lowguid); + if(!result2) + { + npcCreature->SetDefaultMovementType(RANDOM_MOTION_TYPE); + } + else + { + npcCreature->SetDefaultMovementType(WAYPOINT_MOTION_TYPE); + delete result2; + } + npcCreature->GetMotionMaster()->Initialize(); + if(npcCreature->isAlive()) // dead creature will reset movement generator at respawn + { + npcCreature->setDeathState(JUST_DIED); + npcCreature->Respawn(); + } + npcCreature->SaveToDB(); + } + + PSendSysMessage(LANG_WAYPOINT_REMOVED); + return true; + } // del + + if(show == "move" && target) + { + PSendSysMessage("DEBUG: wp move, GUID: %u", lowguid); + + Player *chr = m_session->GetPlayer(); + Map *map = chr->GetMap(); + { + // Get the creature for which we read the waypoint + CreatureData const* data = objmgr.GetCreatureData(lowguid); + if(!data) + { + PSendSysMessage(LANG_WAYPOINT_CREATNOTFOUND, lowguid); + SetSentErrorMessage(true); + return false; + } + + Creature* npcCreature = ObjectAccessor::GetCreature(*m_session->GetPlayer(), MAKE_NEW_GUID(lowguid, data->id, HIGHGUID_UNIT)); + + // wpCreature + Creature* wpCreature = NULL; + // What to do: + // Move the visual spawnpoint + // Respawn the owner of the waypoints + if( wpGuid != 0 ) + { + wpCreature = ObjectAccessor::GetCreature(*m_session->GetPlayer(),MAKE_NEW_GUID(wpGuid, VISUAL_WAYPOINT, HIGHGUID_UNIT)); + wpCreature->DeleteFromDB(); + wpCreature->CleanupsBeforeDelete(); + wpCreature->AddObjectToRemoveList(); + // re-create + Creature* wpCreature2 = new Creature; + if (!wpCreature2->Create(objmgr.GenerateLowGuid(HIGHGUID_UNIT), map, VISUAL_WAYPOINT, 0)) + { + PSendSysMessage(LANG_WAYPOINT_VP_NOTCREATED, VISUAL_WAYPOINT); + delete wpCreature2; + return false; + } + + wpCreature2->Relocate(chr->GetPositionX(), chr->GetPositionY(), chr->GetPositionZ(), chr->GetOrientation()); + + if(!wpCreature2->IsPositionValid()) + { + sLog.outError("ERROR: Creature (guidlow %d, entry %d) not created. Suggested coordinates isn't valid (X: %f Y: %f)",wpCreature2->GetGUIDLow(),wpCreature2->GetEntry(),wpCreature2->GetPositionX(),wpCreature2->GetPositionY()); + delete wpCreature2; + return false; + } + + wpCreature2->SaveToDB(map->GetId(), (1 << map->GetSpawnMode())); + // To call _LoadGoods(); _LoadQuests(); CreateTrainerSpells(); + wpCreature2->LoadFromDB(wpCreature2->GetDBTableGUIDLow(), map); + map->Add(wpCreature2); + //MapManager::Instance().GetMap(npcCreature->GetMapId())->Add(wpCreature2); + } + + WaypointMgr.SetNodePosition(lowguid, point, chr->GetPositionX(), chr->GetPositionY(), chr->GetPositionZ()); + + if(npcCreature) + { + npcCreature->GetMotionMaster()->Initialize(); + if(npcCreature->isAlive()) // dead creature will reset movement generator at respawn + { + npcCreature->setDeathState(JUST_DIED); + npcCreature->Respawn(); + } + } + PSendSysMessage(LANG_WAYPOINT_CHANGED); + } + return true; + } // move + + // Create creature - npc that has the waypoint + CreatureData const* data = objmgr.GetCreatureData(lowguid); + if(!data) + { + PSendSysMessage(LANG_WAYPOINT_CREATNOTFOUND, lowguid); + SetSentErrorMessage(true); + return false; + } + + WaypointMgr.SetNodeText(lowguid, point, show_str, arg_str); + + Creature* npcCreature = ObjectAccessor::GetCreature(*m_session->GetPlayer(), MAKE_NEW_GUID(lowguid, data->id, HIGHGUID_UNIT)); + if(npcCreature) + { + npcCreature->SetDefaultMovementType(WAYPOINT_MOTION_TYPE); + npcCreature->GetMotionMaster()->Initialize(); + if(npcCreature->isAlive()) // dead creature will reset movement generator at respawn + { + npcCreature->setDeathState(JUST_DIED); + npcCreature->Respawn(); + } + } + PSendSysMessage(LANG_WAYPOINT_CHANGED_NO, show_str); + + return true; +} + +/** + * .wp show info | on | off + * + * info -> User has selected a visual waypoint before + * + * info -> User did not select a visual waypoint and + * provided the GUID of the NPC and the number of + * the waypoint. + * + * on -> User has selected an NPC; all visual waypoints for this + * NPC are added to the world + * + * on -> User did not select an NPC - instead the GUID of the + * NPC is provided. All visual waypoints for this NPC + * are added from the world. + * + * off -> User has selected an NPC; all visual waypoints for this + * NPC are removed from the world. + * + * on -> User did not select an NPC - instead the GUID of the + * NPC is provided. All visual waypoints for this NPC + * are removed from the world. + * + * + */ +bool ChatHandler::HandleWpShowCommand(const char* args) +{ + sLog.outDebug("DEBUG: HandleWpShowCommand"); + + if(!*args) + return false; + + // first arg: on, off, first, last + char* show_str = strtok((char*)args, " "); + if (!show_str) + { + return false; + } + // second arg: GUID (optional, if a creature is selected) + char* guid_str = strtok((char*)NULL, " "); + sLog.outDebug("DEBUG: HandleWpShowCommand: show_str: %s guid_str: %s", show_str, guid_str); + //if (!guid_str) { + // return false; + //} + + // Did user provide a GUID + // or did the user select a creature? + // -> variable lowguid is filled with the GUID + Creature* target = getSelectedCreature(); + // Did player provide a GUID? + if (!guid_str) + { + sLog.outDebug("DEBUG: HandleWpShowCommand: !guid_str"); + // No GUID provided + // -> Player must have selected a creature + + if(!target) + { + SendSysMessage(LANG_SELECT_CREATURE); + SetSentErrorMessage(true); + return false; + } + } + else + { + sLog.outDebug("DEBUG: HandleWpShowCommand: GUID provided"); + // GUID provided + // Warn if player also selected a creature + // -> Creature selection is ignored <- + if(target) + { + SendSysMessage(LANG_WAYPOINT_CREATSELECTED); + } + + uint32 lowguid = atoi((char*)guid_str); + + CreatureData const* data = objmgr.GetCreatureData(lowguid); + if(!data) + { + PSendSysMessage(LANG_WAYPOINT_CREATNOTFOUND, lowguid); + SetSentErrorMessage(true); + return false; + } + + target = ObjectAccessor::GetCreature(*m_session->GetPlayer(),MAKE_NEW_GUID(lowguid,data->id,HIGHGUID_UNIT)); + + if(!target) + { + PSendSysMessage(LANG_WAYPOINT_CREATNOTFOUND, lowguid); + SetSentErrorMessage(true); + return false; + } + } + + uint32 lowguid = target->GetDBTableGUIDLow(); + + std::string show = show_str; + uint32 Maxpoint; + + sLog.outDebug("DEBUG: HandleWpShowCommand: lowguid: %u", lowguid); + + sLog.outDebug("DEBUG: HandleWpShowCommand: Habe creature: %ld", target ); + + sLog.outDebug("DEBUG: HandleWpShowCommand: wpshow - show: %s", show_str); + //PSendSysMessage("wpshow - show: %s", show); + + // Show info for the selected waypoint + if(show == "info") + { + PSendSysMessage("DEBUG: wp info, GUID: %u", lowguid); + + // Check if the user did specify a visual waypoint + if( target->GetEntry() != VISUAL_WAYPOINT ) + { + PSendSysMessage(LANG_WAYPOINT_VP_SELECT); + SetSentErrorMessage(true); + return false; + } + + //PSendSysMessage("wp on, GUID: %u", lowguid); + + //pCreature->GetPositionX(); + + QueryResult *result = + WorldDatabase.PQuery( "SELECT id, point, waittime, emote, spell, text1, text2, text3, text4, text5, model1, model2 FROM creature_movement WHERE wpguid = %u", + target->GetGUID() ); + if(!result) + { + // Since we compare float values, we have to deal with + // some difficulties. + // Here we search for all waypoints that only differ in one from 1 thousand + // (0.001) - There is no other way to compare C++ floats with mySQL floats + // See also: http://dev.mysql.com/doc/refman/5.0/en/problems-with-float.html + const char* maxDIFF = "0.01"; + PSendSysMessage(LANG_WAYPOINT_NOTFOUNDSEARCH, target->GetGUID()); + + result = WorldDatabase.PQuery( "SELECT id, point, waittime, emote, spell, text1, text2, text3, text4, text5, model1, model2 FROM creature_movement WHERE (abs(position_x - %f) <= %s ) and (abs(position_y - %f) <= %s ) and (abs(position_z - %f) <= %s )", + target->GetPositionX(), maxDIFF, target->GetPositionY(), maxDIFF, target->GetPositionZ(), maxDIFF); + if(!result) + { + PSendSysMessage(LANG_WAYPOINT_NOTFOUNDDBPROBLEM, lowguid); + SetSentErrorMessage(true); + return false; + } + } + do + { + Field *fields = result->Fetch(); + uint32 creGUID = fields[0].GetUInt32(); + uint32 point = fields[1].GetUInt32(); + int waittime = fields[2].GetUInt32(); + uint32 emote = fields[3].GetUInt32(); + uint32 spell = fields[4].GetUInt32(); + const char * text1 = fields[5].GetString(); + const char * text2 = fields[6].GetString(); + const char * text3 = fields[7].GetString(); + const char * text4 = fields[8].GetString(); + const char * text5 = fields[9].GetString(); + uint32 model1 = fields[10].GetUInt32(); + uint32 model2 = fields[11].GetUInt32(); + + // Get the creature for which we read the waypoint + Creature* wpCreature = ObjectAccessor::GetCreature(*m_session->GetPlayer(),MAKE_NEW_GUID(creGUID,VISUAL_WAYPOINT,HIGHGUID_UNIT)); + + PSendSysMessage(LANG_WAYPOINT_INFO_TITLE, point, (wpCreature ? wpCreature->GetName() : ""), creGUID); + PSendSysMessage(LANG_WAYPOINT_INFO_WAITTIME, waittime); + PSendSysMessage(LANG_WAYPOINT_INFO_MODEL, 1, model1); + PSendSysMessage(LANG_WAYPOINT_INFO_MODEL, 2, model2); + PSendSysMessage(LANG_WAYPOINT_INFO_EMOTE, emote); + PSendSysMessage(LANG_WAYPOINT_INFO_SPELL, spell); + PSendSysMessage(LANG_WAYPOINT_INFO_TEXT, 1, text1); + PSendSysMessage(LANG_WAYPOINT_INFO_TEXT, 2, text2); + PSendSysMessage(LANG_WAYPOINT_INFO_TEXT, 3, text3); + PSendSysMessage(LANG_WAYPOINT_INFO_TEXT, 4, text4); + PSendSysMessage(LANG_WAYPOINT_INFO_TEXT, 5, text5); + + }while( result->NextRow() ); + // Cleanup memory + delete result; + return true; + } + + if(show == "on") + { + PSendSysMessage("DEBUG: wp on, GUID: %u", lowguid); + + QueryResult *result = WorldDatabase.PQuery( "SELECT point, position_x,position_y,position_z FROM creature_movement WHERE id = '%u'",lowguid); + if(!result) + { + PSendSysMessage(LANG_WAYPOINT_NOTFOUND, lowguid); + SetSentErrorMessage(true); + return false; + } + // Delete all visuals for this NPC + QueryResult *result2 = WorldDatabase.PQuery( "SELECT wpguid FROM creature_movement WHERE id = '%u' and wpguid <> 0", lowguid); + if(result2) + { + bool hasError = false; + do + { + Field *fields = result2->Fetch(); + uint32 wpguid = fields[0].GetUInt32(); + Creature* pCreature = ObjectAccessor::GetCreature(*m_session->GetPlayer(),MAKE_NEW_GUID(wpguid,VISUAL_WAYPOINT,HIGHGUID_UNIT)); + + if(!pCreature) + { + PSendSysMessage(LANG_WAYPOINT_NOTREMOVED, wpguid); + hasError = true; + WorldDatabase.PExecuteLog("DELETE FROM creature WHERE guid = '%u'", wpguid); + } + else + { + pCreature->DeleteFromDB(); + pCreature->CleanupsBeforeDelete(); + pCreature->AddObjectToRemoveList(); + } + + }while( result2->NextRow() ); + delete result2; + if( hasError ) + { + PSendSysMessage(LANG_WAYPOINT_TOOFAR1); + PSendSysMessage(LANG_WAYPOINT_TOOFAR2); + PSendSysMessage(LANG_WAYPOINT_TOOFAR3); + } + } + + do + { + Field *fields = result->Fetch(); + uint32 point = fields[0].GetUInt32(); + float x = fields[1].GetFloat(); + float y = fields[2].GetFloat(); + float z = fields[3].GetFloat(); + + uint32 id = VISUAL_WAYPOINT; + + Player *chr = m_session->GetPlayer(); + Map *map = chr->GetMap(); + float o = chr->GetOrientation(); + + Creature* wpCreature = new Creature; + if (!wpCreature->Create(objmgr.GenerateLowGuid(HIGHGUID_UNIT), map, id, 0)) + { + PSendSysMessage(LANG_WAYPOINT_VP_NOTCREATED, id); + delete wpCreature; + delete result; + return false; + } + + wpCreature->Relocate(x, y, z, o); + + if(!wpCreature->IsPositionValid()) + { + sLog.outError("ERROR: Creature (guidlow %d, entry %d) not created. Suggested coordinates isn't valid (X: %f Y: %f)",wpCreature->GetGUIDLow(),wpCreature->GetEntry(),wpCreature->GetPositionX(),wpCreature->GetPositionY()); + delete wpCreature; + delete result; + return false; + } + + wpCreature->SetVisibility(VISIBILITY_OFF); + sLog.outDebug("DEBUG: UPDATE creature_movement SET wpguid = '%u"); + // set "wpguid" column to the visual waypoint + WorldDatabase.PExecuteLog("UPDATE creature_movement SET wpguid = '%u' WHERE id = '%u' and point = '%u'", wpCreature->GetGUIDLow(), lowguid, point); + + wpCreature->SaveToDB(map->GetId(), (1 << map->GetSpawnMode())); + // To call _LoadGoods(); _LoadQuests(); CreateTrainerSpells(); + wpCreature->LoadFromDB(wpCreature->GetDBTableGUIDLow(),map); + map->Add(wpCreature); + //MapManager::Instance().GetMap(wpCreature->GetMapId())->Add(wpCreature); + }while( result->NextRow() ); + + // Cleanup memory + delete result; + return true; + } + + if(show == "first") + { + PSendSysMessage("DEBUG: wp first, GUID: %u", lowguid); + + QueryResult *result = WorldDatabase.PQuery( "SELECT position_x,position_y,position_z FROM creature_movement WHERE point='1' AND id = '%u'",lowguid); + if(!result) + { + PSendSysMessage(LANG_WAYPOINT_NOTFOUND, lowguid); + SetSentErrorMessage(true); + return false; + } + + Field *fields = result->Fetch(); + float x = fields[0].GetFloat(); + float y = fields[1].GetFloat(); + float z = fields[2].GetFloat(); + uint32 id = VISUAL_WAYPOINT; + + Player *chr = m_session->GetPlayer(); + float o = chr->GetOrientation(); + Map *map = chr->GetMap(); + + Creature* pCreature = new Creature; + if (!pCreature->Create(objmgr.GenerateLowGuid(HIGHGUID_UNIT),map, id, 0)) + { + PSendSysMessage(LANG_WAYPOINT_VP_NOTCREATED, id); + delete pCreature; + delete result; + return false; + } + + pCreature->Relocate(x, y, z, o); + + if(!pCreature->IsPositionValid()) + { + sLog.outError("ERROR: Creature (guidlow %d, entry %d) not created. Suggested coordinates isn't valid (X: %f Y: %f)",pCreature->GetGUIDLow(),pCreature->GetEntry(),pCreature->GetPositionX(),pCreature->GetPositionY()); + delete pCreature; + delete result; + return false; + } + + pCreature->SaveToDB(map->GetId(), (1 << map->GetSpawnMode())); + pCreature->LoadFromDB(pCreature->GetDBTableGUIDLow(), map); + map->Add(pCreature); + //player->PlayerTalkClass->SendPointOfInterest(x, y, 6, 6, 0, "First Waypoint"); + + // Cleanup memory + delete result; + return true; + } + + if(show == "last") + { + PSendSysMessage("DEBUG: wp last, GUID: %u", lowguid); + + QueryResult *result = WorldDatabase.PQuery( "SELECT MAX(point) FROM creature_movement WHERE id = '%u'",lowguid); + if( result ) + { + Maxpoint = (*result)[0].GetUInt32(); + + delete result; + } + else + Maxpoint = 0; + + result = WorldDatabase.PQuery( "SELECT position_x,position_y,position_z FROM creature_movement WHERE point ='%u' AND id = '%u'",Maxpoint, lowguid); + if(!result) + { + PSendSysMessage(LANG_WAYPOINT_NOTFOUNDLAST, lowguid); + SetSentErrorMessage(true); + return false; + } + Field *fields = result->Fetch(); + float x = fields[0].GetFloat(); + float y = fields[1].GetFloat(); + float z = fields[2].GetFloat(); + uint32 id = VISUAL_WAYPOINT; + + Player *chr = m_session->GetPlayer(); + float o = chr->GetOrientation(); + Map *map = chr->GetMap(); + + Creature* pCreature = new Creature; + if (!pCreature->Create(objmgr.GenerateLowGuid(HIGHGUID_UNIT), map, id, 0)) + { + PSendSysMessage(LANG_WAYPOINT_NOTCREATED, id); + delete pCreature; + delete result; + return false; + } + + pCreature->Relocate(x, y, z, o); + + if(!pCreature->IsPositionValid()) + { + sLog.outError("ERROR: Creature (guidlow %d, entry %d) not created. Suggested coordinates isn't valid (X: %f Y: %f)",pCreature->GetGUIDLow(),pCreature->GetEntry(),pCreature->GetPositionX(),pCreature->GetPositionY()); + delete pCreature; + delete result; + return false; + } + + pCreature->SaveToDB(map->GetId(), (1 << map->GetSpawnMode())); + pCreature->LoadFromDB(pCreature->GetDBTableGUIDLow(), map); + map->Add(pCreature); + //player->PlayerTalkClass->SendPointOfInterest(x, y, 6, 6, 0, "Last Waypoint"); + // Cleanup memory + delete result; + return true; + } + + if(show == "off") + { + QueryResult *result = WorldDatabase.PQuery("SELECT guid FROM creature WHERE id = '%d'", VISUAL_WAYPOINT); + if(!result) + { + SendSysMessage(LANG_WAYPOINT_VP_NOTFOUND); + SetSentErrorMessage(true); + return false; + } + bool hasError = false; + do + { + Field *fields = result->Fetch(); + uint32 guid = fields[0].GetUInt32(); + Creature* pCreature = ObjectAccessor::GetCreature(*m_session->GetPlayer(),MAKE_NEW_GUID(guid,VISUAL_WAYPOINT,HIGHGUID_UNIT)); + + //Creature* pCreature = ObjectAccessor::GetCreature(*m_session->GetPlayer(), guid); + + if(!pCreature) + { + PSendSysMessage(LANG_WAYPOINT_NOTREMOVED, guid); + hasError = true; + WorldDatabase.PExecuteLog("DELETE FROM creature WHERE guid = '%u'", guid); + } + else + { + pCreature->DeleteFromDB(); + pCreature->CleanupsBeforeDelete(); + pCreature->AddObjectToRemoveList(); + } + }while(result->NextRow()); + // set "wpguid" column to "empty" - no visual waypoint spawned + WorldDatabase.PExecuteLog("UPDATE creature_movement SET wpguid = '0'"); + + if( hasError ) + { + PSendSysMessage(LANG_WAYPOINT_TOOFAR1); + PSendSysMessage(LANG_WAYPOINT_TOOFAR2); + PSendSysMessage(LANG_WAYPOINT_TOOFAR3); + } + + SendSysMessage(LANG_WAYPOINT_VP_ALLREMOVED); + // Cleanup memory + delete result; + + return true; + } + + PSendSysMessage("DEBUG: wpshow - no valid command found"); + + return true; +} // HandleWpShowCommand + +bool ChatHandler::HandleWpExportCommand(const char *args) +{ + if(!*args) + return false; + + // Next arg is: + + // Did user provide a GUID + // or did the user select a creature? + // -> variable lowguid is filled with the GUID of the NPC + uint32 lowguid = 0; + Creature* target = getSelectedCreature(); + char* arg_str = NULL; + if (target) + { + if (target->GetEntry() != VISUAL_WAYPOINT) + lowguid = target->GetGUIDLow(); + else + { + QueryResult *result = WorldDatabase.PQuery( "SELECT id FROM creature_movement WHERE wpguid = %u LIMIT 1", target->GetGUIDLow() ); + if (!result) + { + PSendSysMessage(LANG_WAYPOINT_NOTFOUNDDBPROBLEM, target->GetGUIDLow()); + return true; + } + Field *fields = result->Fetch(); + lowguid = fields[0].GetUInt32();; + delete result; + } + + arg_str = strtok((char*)args, " "); + } + else + { + // user provided + char* guid_str = strtok((char*)args, " "); + if( !guid_str ) + { + SendSysMessage(LANG_WAYPOINT_NOGUID); + return false; + } + lowguid = atoi((char*)guid_str); + + arg_str = strtok((char*)NULL, " "); + } + + if( !arg_str) + { + PSendSysMessage(LANG_WAYPOINT_ARGUMENTREQ, "export"); + return false; + } + + PSendSysMessage("DEBUG: wp export, GUID: %u", lowguid); + + QueryResult *result = WorldDatabase.PQuery( + // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 + "SELECT point, position_x, position_y, position_z, orientation, model1, model2, waittime, emote, spell, text1, text2, text3, text4, text5, id FROM creature_movement WHERE id = '%u' ORDER BY point", lowguid ); + + if (!result) + { + PSendSysMessage(LANG_WAYPOINT_NOTHINGTOEXPORT); + SetSentErrorMessage(true); + return false; + } + + std::ofstream outfile; + outfile.open (arg_str); + + do + { + Field *fields = result->Fetch(); + + outfile << "INSERT INTO creature_movement "; + outfile << "( id, point, position_x, position_y, position_z, orientation, model1, model2, waittime, emote, spell, text1, text2, text3, text4, text5 ) VALUES "; + + outfile << "( "; + outfile << fields[15].GetUInt32(); // id + outfile << ", "; + outfile << fields[0].GetUInt32(); // point + outfile << ", "; + outfile << fields[1].GetFloat(); // position_x + outfile << ", "; + outfile << fields[2].GetFloat(); // position_y + outfile << ", "; + outfile << fields[3].GetUInt32(); // position_z + outfile << ", "; + outfile << fields[4].GetUInt32(); // orientation + outfile << ", "; + outfile << fields[5].GetUInt32(); // model1 + outfile << ", "; + outfile << fields[6].GetUInt32(); // model2 + outfile << ", "; + outfile << fields[7].GetUInt16(); // waittime + outfile << ", "; + outfile << fields[8].GetUInt32(); // emote + outfile << ", "; + outfile << fields[9].GetUInt32(); // spell + outfile << ", "; + const char *tmpChar = fields[10].GetString(); + if( !tmpChar ) + { + outfile << "NULL"; // text1 + } + else + { + outfile << "'"; + outfile << tmpChar; // text1 + outfile << "'"; + } + outfile << ", "; + tmpChar = fields[11].GetString(); + if( !tmpChar ) + { + outfile << "NULL"; // text2 + } + else + { + outfile << "'"; + outfile << tmpChar; // text2 + outfile << "'"; + } + outfile << ", "; + tmpChar = fields[12].GetString(); + if( !tmpChar ) + { + outfile << "NULL"; // text3 + } + else + { + outfile << "'"; + outfile << tmpChar; // text3 + outfile << "'"; + } + outfile << ", "; + tmpChar = fields[13].GetString(); + if( !tmpChar ) + { + outfile << "NULL"; // text4 + } + else + { + outfile << "'"; + outfile << tmpChar; // text4 + outfile << "'"; + } + outfile << ", "; + tmpChar = fields[14].GetString(); + if( !tmpChar ) + { + outfile << "NULL"; // text5 + } + else + { + outfile << "'"; + outfile << tmpChar; // text5 + outfile << "'"; + } + outfile << ");\n "; + + } while( result->NextRow() ); + delete result; + + PSendSysMessage(LANG_WAYPOINT_EXPORTED); + outfile.close(); + + return true; +} + +bool ChatHandler::HandleWpImportCommand(const char *args) +{ + if(!*args) + return false; + + char* arg_str = strtok((char*)args, " "); + if (!arg_str) + return false; + + std::string line; + std::ifstream infile (arg_str); + if (infile.is_open()) + { + while (! infile.eof() ) + { + getline (infile,line); + //cout << line << endl; + QueryResult *result = WorldDatabase.PQuery(line.c_str()); + delete result; + } + infile.close(); + } + PSendSysMessage(LANG_WAYPOINT_IMPORTED); + + return true; +} + +//rename characters +bool ChatHandler::HandleRenameCommand(const char* args) +{ + Player* target = NULL; + uint64 targetGUID = 0; + std::string oldname; + + char* px = strtok((char*)args, " "); + + if(px) + { + oldname = px; + + if(!normalizePlayerName(oldname)) + { + SendSysMessage(LANG_PLAYER_NOT_FOUND); + SetSentErrorMessage(true); + return false; + } + + target = objmgr.GetPlayer(oldname.c_str()); + + if (!target) + targetGUID = objmgr.GetPlayerGUIDByName(oldname); + } + + if(!target && !targetGUID) + { + target = getSelectedPlayer(); + } + + if(!target && !targetGUID) + { + SendSysMessage(LANG_PLAYER_NOT_FOUND); + SetSentErrorMessage(true); + return false; + } + + if(target) + { + PSendSysMessage(LANG_RENAME_PLAYER, target->GetName()); + target->SetAtLoginFlag(AT_LOGIN_RENAME); + CharacterDatabase.PExecute("UPDATE characters SET at_login = at_login | '1' WHERE guid = '%u'", target->GetGUIDLow()); + } + else + { + PSendSysMessage(LANG_RENAME_PLAYER_GUID, oldname.c_str(), GUID_LOPART(targetGUID)); + CharacterDatabase.PExecute("UPDATE characters SET at_login = at_login | '1' WHERE guid = '%u'", GUID_LOPART(targetGUID)); + } + + return true; +} + +//spawn go +bool ChatHandler::HandleGameObjectCommand(const char* args) +{ + if (!*args) + return false; + + char* pParam1 = strtok((char*)args, " "); + if (!pParam1) + return false; + + uint32 id = atoi((char*)pParam1); + if(!id) + return false; + + char* spawntimeSecs = strtok(NULL, " "); + + const GameObjectInfo *goI = objmgr.GetGameObjectInfo(id); + + if (!goI) + { + PSendSysMessage(LANG_GAMEOBJECT_NOT_EXIST,id); + SetSentErrorMessage(true); + return false; + } + + Player *chr = m_session->GetPlayer(); + float x = float(chr->GetPositionX()); + float y = float(chr->GetPositionY()); + float z = float(chr->GetPositionZ()); + float o = float(chr->GetOrientation()); + Map *map = chr->GetMap(); + + float rot2 = sin(o/2); + float rot3 = cos(o/2); + + GameObject* pGameObj = new GameObject; + uint32 db_lowGUID = objmgr.GenerateLowGuid(HIGHGUID_GAMEOBJECT); + + if(!pGameObj->Create(db_lowGUID, goI->id, map, x, y, z, o, 0, 0, rot2, rot3, 0, 1)) + { + delete pGameObj; + return false; + } + + if( spawntimeSecs ) + { + uint32 value = atoi((char*)spawntimeSecs); + pGameObj->SetRespawnTime(value); + //sLog.outDebug("*** spawntimeSecs: %d", value); + } + + // fill the gameobject data and save to the db + pGameObj->SaveToDB(map->GetId(), (1 << map->GetSpawnMode())); + + // this will generate a new guid if the object is in an instance + if(!pGameObj->LoadFromDB(db_lowGUID, map)) + { + delete pGameObj; + return false; + } + + sLog.outDebug(GetMangosString(LANG_GAMEOBJECT_CURRENT), goI->name, db_lowGUID, x, y, z, o); + + map->Add(pGameObj); + + // TODO: is it really necessary to add both the real and DB table guid here ? + objmgr.AddGameobjectToGrid(db_lowGUID, objmgr.GetGOData(db_lowGUID)); + + PSendSysMessage(LANG_GAMEOBJECT_ADD,id,goI->name,db_lowGUID,x,y,z); + return true; +} + +//show animation +bool ChatHandler::HandleAnimCommand(const char* args) +{ + if (!*args) + return false; + + uint32 anim_id = atoi((char*)args); + m_session->GetPlayer()->HandleEmoteCommand(anim_id); + return true; +} + +//change standstate +bool ChatHandler::HandleStandStateCommand(const char* args) +{ + if (!*args) + return false; + + uint32 anim_id = atoi((char*)args); + m_session->GetPlayer( )->SetUInt32Value( UNIT_NPC_EMOTESTATE , anim_id ); + + return true; +} + +bool ChatHandler::HandleAddHonorCommand(const char* args) +{ + if (!*args) + return false; + + Player *target = getSelectedPlayer(); + if(!target) + { + SendSysMessage(LANG_PLAYER_NOT_FOUND); + SetSentErrorMessage(true); + return false; + } + + uint32 amount = (uint32)atoi(args); + target->RewardHonor(NULL, 1, amount); + return true; +} + +bool ChatHandler::HandleHonorAddKillCommand(const char* /*args*/) +{ + Unit *target = getSelectedUnit(); + if(!target) + { + SendSysMessage(LANG_PLAYER_NOT_FOUND); + SetSentErrorMessage(true); + return false; + } + + m_session->GetPlayer()->RewardHonor(target, 1); + return true; +} + +bool ChatHandler::HandleUpdateHonorFieldsCommand(const char* /*args*/) +{ + Player *target = getSelectedPlayer(); + if(!target) + { + SendSysMessage(LANG_PLAYER_NOT_FOUND); + SetSentErrorMessage(true); + return false; + } + + target->UpdateHonorFields(); + return true; +} + +bool ChatHandler::HandleLookupEventCommand(const char* args) +{ + if(!*args) + return false; + + std::string namepart = args; + std::wstring wnamepart; + + // converting string that we try to find to lower case + if(!Utf8toWStr(namepart,wnamepart)) + return false; + + wstrToLower(wnamepart); + + uint32 counter = 0; + + GameEvent::GameEventDataMap const& events = gameeventmgr.GetEventMap(); + GameEvent::ActiveEvents const& activeEvents = gameeventmgr.GetActiveEventList(); + + for(uint32 id = 0; id < events.size(); ++id ) + { + GameEventData const& eventData = events[id]; + + std::string descr = eventData.description; + if(descr.empty()) + continue; + + if (Utf8FitTo(descr, wnamepart)) + { + char const* active = activeEvents.find(id) != activeEvents.end() ? GetMangosString(LANG_ACTIVE) : ""; + PSendSysMessage(LANG_EVENT_ENTRY_LIST,id,id,descr.c_str(),active ); + ++counter; + } + } + + if (counter==0) + SendSysMessage(LANG_NOEVENTFOUND); + + return true; +} + +bool ChatHandler::HandleEventActiveListCommand(const char* args) +{ + uint32 counter = 0; + + GameEvent::GameEventDataMap const& events = gameeventmgr.GetEventMap(); + GameEvent::ActiveEvents const& activeEvents = gameeventmgr.GetActiveEventList(); + + char const* active = GetMangosString(LANG_ACTIVE); + + for(GameEvent::ActiveEvents::const_iterator itr = activeEvents.begin(); itr != activeEvents.end(); ++itr ) + { + uint32 event_id = *itr; + GameEventData const& eventData = events[event_id]; + + PSendSysMessage(LANG_EVENT_ENTRY_LIST,event_id,event_id,eventData.description.c_str(),active ); + ++counter; + } + + if (counter==0) + SendSysMessage(LANG_NOEVENTFOUND); + + return true; +} + +bool ChatHandler::HandleEventInfoCommand(const char* args) +{ + if(!*args) + return false; + + // id or [name] Shift-click form |color|Hgameevent:id|h[name]|h|r + char* cId = extractKeyFromLink((char*)args,"Hgameevent"); + if(!cId) + return false; + + uint32 event_id = atoi(cId); + + GameEvent::GameEventDataMap const& events = gameeventmgr.GetEventMap(); + + if(event_id >=events.size()) + { + SendSysMessage(LANG_EVENT_NOT_EXIST); + SetSentErrorMessage(true); + return false; + } + + GameEventData const& eventData = events[event_id]; + if(!eventData.isValid()) + { + SendSysMessage(LANG_EVENT_NOT_EXIST); + SetSentErrorMessage(true); + return false; + } + + GameEvent::ActiveEvents const& activeEvents = gameeventmgr.GetActiveEventList(); + bool active = activeEvents.find(event_id) != activeEvents.end(); + char const* activeStr = active ? GetMangosString(LANG_ACTIVE) : ""; + + std::string startTimeStr = TimeToTimestampStr(eventData.start); + std::string endTimeStr = TimeToTimestampStr(eventData.end); + + uint32 delay = gameeventmgr.NextCheck(event_id); + time_t nextTime = time(NULL)+delay; + std::string nextStr = nextTime >= eventData.start && nextTime < eventData.end ? TimeToTimestampStr(time(NULL)+delay) : "-"; + + std::string occurenceStr = secsToTimeString(eventData.occurence * MINUTE); + std::string lengthStr = secsToTimeString(eventData.length * MINUTE); + + PSendSysMessage(LANG_EVENT_INFO,event_id,eventData.description.c_str(),activeStr, + startTimeStr.c_str(),endTimeStr.c_str(),occurenceStr.c_str(),lengthStr.c_str(), + nextStr.c_str()); + return true; +} + +bool ChatHandler::HandleEventStartCommand(const char* args) +{ + if(!*args) + return false; + + // id or [name] Shift-click form |color|Hgameevent:id|h[name]|h|r + char* cId = extractKeyFromLink((char*)args,"Hgameevent"); + if(!cId) + return false; + + int32 event_id = atoi(cId); + + GameEvent::GameEventDataMap const& events = gameeventmgr.GetEventMap(); + + if(event_id < 1 || event_id >=events.size()) + { + SendSysMessage(LANG_EVENT_NOT_EXIST); + SetSentErrorMessage(true); + return false; + } + + GameEventData const& eventData = events[event_id]; + if(!eventData.isValid()) + { + SendSysMessage(LANG_EVENT_NOT_EXIST); + SetSentErrorMessage(true); + return false; + } + + GameEvent::ActiveEvents const& activeEvents = gameeventmgr.GetActiveEventList(); + if(activeEvents.find(event_id) != activeEvents.end()) + { + PSendSysMessage(LANG_EVENT_ALREADY_ACTIVE,event_id); + SetSentErrorMessage(true); + return false; + } + + gameeventmgr.StartEvent(event_id,true); + return true; +} + +bool ChatHandler::HandleEventStopCommand(const char* args) +{ + if(!*args) + return false; + + // id or [name] Shift-click form |color|Hgameevent:id|h[name]|h|r + char* cId = extractKeyFromLink((char*)args,"Hgameevent"); + if(!cId) + return false; + + int32 event_id = atoi(cId); + + GameEvent::GameEventDataMap const& events = gameeventmgr.GetEventMap(); + + if(event_id < 1 || event_id >=events.size()) + { + SendSysMessage(LANG_EVENT_NOT_EXIST); + SetSentErrorMessage(true); + return false; + } + + GameEventData const& eventData = events[event_id]; + if(!eventData.isValid()) + { + SendSysMessage(LANG_EVENT_NOT_EXIST); + SetSentErrorMessage(true); + return false; + } + + GameEvent::ActiveEvents const& activeEvents = gameeventmgr.GetActiveEventList(); + + if(activeEvents.find(event_id) == activeEvents.end()) + { + PSendSysMessage(LANG_EVENT_NOT_ACTIVE,event_id); + SetSentErrorMessage(true); + return false; + } + + gameeventmgr.StopEvent(event_id,true); + return true; +} + +bool ChatHandler::HandleCombatStopCommand(const char* args) +{ + Player *player; + + if(*args) + { + std::string playername = args; + + if(!normalizePlayerName(playername)) + { + SendSysMessage(LANG_PLAYER_NOT_FOUND); + SetSentErrorMessage(true); + return false; + } + + player = objmgr.GetPlayer(playername.c_str()); + + if(!player) + { + SendSysMessage(LANG_PLAYER_NOT_FOUND); + SetSentErrorMessage(true); + return false; + } + } + else + { + player = getSelectedPlayer(); + + if (!player) + player = m_session->GetPlayer(); + } + + player->CombatStop(); + player->getHostilRefManager().deleteReferences(); + return true; +} + +bool ChatHandler::HandleLearnAllCraftsCommand(const char* /*args*/) +{ + uint32 classmask = m_session->GetPlayer()->getClassMask(); + + for (uint32 i = 0; i < sSkillLineStore.GetNumRows(); ++i) + { + SkillLineEntry const *skillInfo = sSkillLineStore.LookupEntry(i); + if( !skillInfo ) + continue; + + if( skillInfo->categoryId == SKILL_CATEGORY_PROFESSION || skillInfo->categoryId == SKILL_CATEGORY_SECONDARY ) + { + for (uint32 j = 0; j < sSkillLineAbilityStore.GetNumRows(); ++j) + { + SkillLineAbilityEntry const *skillLine = sSkillLineAbilityStore.LookupEntry(j); + if( !skillLine ) + continue; + + // skip racial skills + if( skillLine->racemask != 0 ) + continue; + + // skip wrong class skills + if( skillLine->classmask && (skillLine->classmask & classmask) == 0) + continue; + + if( skillLine->skillId != i || skillLine->forward_spellid ) + continue; + + SpellEntry const* spellInfo = sSpellStore.LookupEntry(skillLine->spellId); + if(!spellInfo || !SpellMgr::IsSpellValid(spellInfo,m_session->GetPlayer(),false)) + continue; + + m_session->GetPlayer()->learnSpell(skillLine->spellId); + } + } + } + + SendSysMessage(LANG_COMMAND_LEARN_ALL_CRAFT); + return true; +} + +bool ChatHandler::HandleLearnAllRecipesCommand(const char* args) +{ + // Learns all recipes of specified profession and sets skill to max + // Example: .learn all_recipes enchanting + + Player* target = getSelectedPlayer(); + if( !target ) + { + SendSysMessage(LANG_PLAYER_NOT_FOUND); + return false; + } + + if(!*args) + return false; + + std::wstring wnamepart; + + if(!Utf8toWStr(args,wnamepart)) + return false; + + uint32 counter = 0; // Counter for figure out that we found smth. + + // converting string that we try to find to lower case + wstrToLower( wnamepart ); + + uint32 classmask = m_session->GetPlayer()->getClassMask(); + + for (uint32 i = 0; i < sSkillLineStore.GetNumRows(); ++i) + { + SkillLineEntry const *skillInfo = sSkillLineStore.LookupEntry(i); + if( !skillInfo ) + continue; + + if( skillInfo->categoryId != SKILL_CATEGORY_PROFESSION && + skillInfo->categoryId != SKILL_CATEGORY_SECONDARY ) + continue; + + int loc = m_session->GetSessionDbcLocale(); + std::string name = skillInfo->name[loc]; + + if(Utf8FitTo(name, wnamepart)) + { + for (uint32 j = 0; j < sSkillLineAbilityStore.GetNumRows(); ++j) + { + SkillLineAbilityEntry const *skillLine = sSkillLineAbilityStore.LookupEntry(j); + if( !skillLine ) + continue; + + if( skillLine->skillId != i || skillLine->forward_spellid ) + continue; + + // skip racial skills + if( skillLine->racemask != 0 ) + continue; + + // skip wrong class skills + if( skillLine->classmask && (skillLine->classmask & classmask) == 0) + continue; + + SpellEntry const* spellInfo = sSpellStore.LookupEntry(skillLine->spellId); + if(!spellInfo || !SpellMgr::IsSpellValid(spellInfo,m_session->GetPlayer(),false)) + continue; + + if( !target->HasSpell(spellInfo->Id) ) + m_session->GetPlayer()->learnSpell(skillLine->spellId); + } + + uint16 maxLevel = target->GetPureMaxSkillValue(skillInfo->id); + target->SetSkill(skillInfo->id, maxLevel, maxLevel); + PSendSysMessage(LANG_COMMAND_LEARN_ALL_RECIPES, name.c_str()); + return true; + } + } + + return false; +} + +bool ChatHandler::HandleLookupPlayerIpCommand(const char* args) +{ + + if(!*args) + return false; + + std::string ip = strtok((char*)args, " "); + char* limit_str = strtok(NULL, " "); + int32 limit = limit_str ? atoi(limit_str) : -1; + + loginDatabase.escape_string(ip); + + QueryResult* result = loginDatabase.PQuery("SELECT id,username FROM account WHERE last_ip = '%s'", ip.c_str()); + + return LookupPlayerSearchCommand(result,limit); +} + +bool ChatHandler::HandleLookupPlayerAccountCommand(const char* args) +{ + if(!*args) + return false; + + std::string account = strtok((char*)args, " "); + char* limit_str = strtok(NULL, " "); + int32 limit = limit_str ? atoi(limit_str) : -1; + + if(!AccountMgr::normilizeString(account)) + return false; + + loginDatabase.escape_string(account); + + QueryResult* result = loginDatabase.PQuery("SELECT id,username FROM account WHERE username = '%s'", account.c_str()); + + return LookupPlayerSearchCommand(result,limit); +} + +bool ChatHandler::HandleLookupPlayerEmailCommand(const char* args) +{ + + if(!*args) + return false; + + std::string email = strtok((char*)args, " "); + char* limit_str = strtok(NULL, " "); + int32 limit = limit_str ? atoi(limit_str) : -1; + + loginDatabase.escape_string(email); + + QueryResult* result = loginDatabase.PQuery("SELECT id,username FROM account WHERE email = '%s'", email.c_str()); + + return LookupPlayerSearchCommand(result,limit); +} + +bool ChatHandler::LookupPlayerSearchCommand(QueryResult* result, int32 limit) +{ + if(!result) + { + PSendSysMessage(LANG_NO_PLAYERS_FOUND); + SetSentErrorMessage(true); + return false; + } + + int i =0; + do + { + Field* fields = result->Fetch(); + uint32 acc_id = fields[0].GetUInt32(); + std::string acc_name = fields[1].GetCppString(); + + QueryResult* chars = CharacterDatabase.PQuery("SELECT guid,name FROM characters WHERE account = '%u'", acc_id); + if(chars) + { + PSendSysMessage(LANG_LOOKUP_PLAYER_ACCOUNT,acc_name.c_str(),acc_id); + + uint64 guid = 0; + std::string name; + + do + { + Field* charfields = chars->Fetch(); + guid = charfields[0].GetUInt64(); + name = charfields[1].GetCppString(); + + PSendSysMessage(LANG_LOOKUP_PLAYER_CHARACTER,name.c_str(),guid); + ++i; + + } while( chars->NextRow() && ( limit == -1 || i < limit ) ); + + delete chars; + } + } while(result->NextRow()); + + delete result; + + return true; +} diff --git a/src/game/Level3.cpp b/src/game/Level3.cpp index 93f39229b7d..5984dbbfe21 100644 --- a/src/game/Level3.cpp +++ b/src/game/Level3.cpp @@ -1,5424 +1,5459 @@ -/* - * Copyright (C) 2005-2008 MaNGOS - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "Common.h" -#include "Database/DatabaseEnv.h" -#include "WorldPacket.h" -#include "WorldSession.h" -#include "World.h" -#include "ObjectMgr.h" -#include "PlayerDump.h" -#include "SpellMgr.h" -#include "Player.h" -#include "Opcodes.h" -#include "GameObject.h" -#include "Chat.h" -#include "Log.h" -#include "Guild.h" -#include "ObjectAccessor.h" -#include "MapManager.h" -#include "SpellAuras.h" -#include "ScriptCalls.h" -#include "Language.h" -#include "GridNotifiersImpl.h" -#include "CellImpl.h" -#include "Weather.h" -#include "PointMovementGenerator.h" -#include "TargetedMovementGenerator.h" -#include "SkillDiscovery.h" -#include "SkillExtraItems.h" -#include "SystemConfig.h" -#include "Config/ConfigEnv.h" -#include "Util.h" -#include "ItemEnchantmentMgr.h" -#include "InstanceSaveMgr.h" -#include "InstanceData.h" - -//reload commands -bool ChatHandler::HandleReloadCommand(const char* arg) -{ - // this is error catcher for wrong table name in .reload commands - PSendSysMessage("Db table with name starting from '%s' not found and can't be reloaded.",arg); - SetSentErrorMessage(true); - return false; -} - -bool ChatHandler::HandleReloadAllCommand(const char*) -{ - HandleReloadAreaTriggerTeleportCommand(""); - //HandleReloadAreaTriggerTavernCommand(""); -- reloaded in HandleReloadAreaTriggerTavernCommand - //HandleReloadQuestAreaTriggersCommand(""); -- reloaded in HandleReloadAllQuestCommand - HandleReloadSkillFishingBaseLevelCommand(""); - - HandleReloadAllLootCommand(""); - HandleReloadAllQuestCommand(""); - HandleReloadAllSpellCommand(""); - HandleReloadAllItemCommand(""); - - HandleReloadCommandCommand(""); - HandleReloadReservedNameCommand(""); - HandleReloadMangosStringCommand(""); - return true; -} - -bool ChatHandler::HandleReloadAllAreaCommand(const char*) -{ - HandleReloadAreaTriggerTeleportCommand(""); - //HandleReloadAreaTriggerTavernCommand(""); -- reloaded in HandleReloadAreaTriggerTavernCommand - return true; -} - -bool ChatHandler::HandleReloadAllQuestCommand(const char* /*args*/) -{ - HandleReloadQuestAreaTriggersCommand("a"); - HandleReloadQuestTemplateCommand("a"); - - sLog.outString( "Re-Loading Quests Relations..." ); - objmgr.LoadQuestRelations(); - SendGlobalSysMessage("DB tables `*_questrelation` and `*_involvedrelation` reloaded."); - return true; -} - -bool ChatHandler::HandleReloadAllLootCommand(const char*) -{ - sLog.outString( "Re-Loading Loot Tables..." ); - LoadLootTables(); - SendGlobalSysMessage("DB tables `*_loot_template` reloaded."); - return true; -} - -bool ChatHandler::HandleReloadAllScriptsCommand(const char*) -{ - if(sWorld.IsScriptScheduled()) - { - PSendSysMessage("DB scripts used currently, please attempt reload later."); - SetSentErrorMessage(true); - return false; - } - - sLog.outString( "Re-Loading Scripts..." ); - HandleReloadGameObjectScriptsCommand("a"); - HandleReloadEventScriptsCommand("a"); - HandleReloadQuestEndScriptsCommand("a"); - HandleReloadQuestStartScriptsCommand("a"); - HandleReloadSpellScriptsCommand("a"); - SendGlobalSysMessage("DB tables `*_scripts` reloaded."); - return true; -} - -bool ChatHandler::HandleReloadAllSpellCommand(const char*) -{ - HandleReloadSkillDiscoveryTemplateCommand("a"); - HandleReloadSkillExtraItemTemplateCommand("a"); - HandleReloadSpellAffectCommand("a"); - HandleReloadSpellChainCommand("a"); - HandleReloadSpellElixirCommand("a"); - HandleReloadSpellLearnSpellCommand("a"); - HandleReloadSpellProcEventCommand("a"); - HandleReloadSpellScriptTargetCommand("a"); - HandleReloadSpellTargetPositionCommand("a"); - HandleReloadSpellThreatsCommand("a"); - HandleReloadSpellPetAurasCommand("a"); - return true; -} - -bool ChatHandler::HandleReloadAllItemCommand(const char*) -{ - HandleReloadPageTextsCommand("a"); - HandleReloadItemEnchantementsCommand("a"); - return true; -} - -bool ChatHandler::HandleReloadConfigCommand(const char* arg) -{ - sLog.outString( "Re-Loading config settings..." ); - sWorld.LoadConfigSettings(true); - SendGlobalSysMessage("World config settings reloaded."); - return true; -} - -bool ChatHandler::HandleReloadAreaTriggerTavernCommand(const char*) -{ - sLog.outString( "Re-Loading Tavern Area Triggers..." ); - objmgr.LoadTavernAreaTriggers(); - SendGlobalSysMessage("DB table `areatrigger_tavern` reloaded."); - return true; -} - -bool ChatHandler::HandleReloadAreaTriggerTeleportCommand(const char*) -{ - sLog.outString( "Re-Loading AreaTrigger teleport definitions..." ); - objmgr.LoadAreaTriggerTeleports(); - SendGlobalSysMessage("DB table `areatrigger_teleport` reloaded."); - return true; -} - -bool ChatHandler::HandleReloadCommandCommand(const char*) -{ - load_command_table = true; - SendGlobalSysMessage("DB table `command` will be reloaded at next chat command use."); - return true; -} - -bool ChatHandler::HandleReloadCreatureQuestRelationsCommand(const char*) -{ - sLog.outString( "Loading Quests Relations... (`creature_questrelation`)" ); - objmgr.LoadCreatureQuestRelations(); - SendGlobalSysMessage("DB table `creature_questrelation` (creature quest givers) reloaded."); - return true; -} - -bool ChatHandler::HandleReloadCreatureQuestInvRelationsCommand(const char*) -{ - sLog.outString( "Loading Quests Relations... (`creature_involvedrelation`)" ); - objmgr.LoadCreatureInvolvedRelations(); - SendGlobalSysMessage("DB table `creature_involvedrelation` (creature quest takers) reloaded."); - return true; -} - -bool ChatHandler::HandleReloadGOQuestRelationsCommand(const char*) -{ - sLog.outString( "Loading Quests Relations... (`gameobject_questrelation`)" ); - objmgr.LoadGameobjectQuestRelations(); - SendGlobalSysMessage("DB table `gameobject_questrelation` (gameobject quest givers) reloaded."); - return true; -} - -bool ChatHandler::HandleReloadGOQuestInvRelationsCommand(const char*) -{ - sLog.outString( "Loading Quests Relations... (`gameobject_involvedrelation`)" ); - objmgr.LoadGameobjectInvolvedRelations(); - SendGlobalSysMessage("DB table `gameobject_involvedrelation` (gameobject quest takers) reloaded."); - return true; -} - -bool ChatHandler::HandleReloadQuestAreaTriggersCommand(const char*) -{ - sLog.outString( "Re-Loading Quest Area Triggers..." ); - objmgr.LoadQuestAreaTriggers(); - SendGlobalSysMessage("DB table `areatrigger_involvedrelation` (quest area triggers) reloaded."); - return true; -} - -bool ChatHandler::HandleReloadQuestTemplateCommand(const char*) -{ - sLog.outString( "Re-Loading Quest Templates..." ); - objmgr.LoadQuests(); - SendGlobalSysMessage("DB table `quest_template` (quest definitions) reloaded."); - return true; -} - -bool ChatHandler::HandleReloadLootTemplatesCreatureCommand(const char*) -{ - sLog.outString( "Re-Loading Loot Tables... (`creature_loot_template`)" ); - LoadLootTemplates_Creature(); - LootTemplates_Creature.CheckLootRefs(); - SendGlobalSysMessage("DB table `creature_loot_template` reloaded."); - return true; -} - -bool ChatHandler::HandleReloadLootTemplatesDisenchantCommand(const char*) -{ - sLog.outString( "Re-Loading Loot Tables... (`disenchant_loot_template`)" ); - LoadLootTemplates_Disenchant(); - LootTemplates_Disenchant.CheckLootRefs(); - SendGlobalSysMessage("DB table `disenchant_loot_template` reloaded."); - return true; -} - -bool ChatHandler::HandleReloadLootTemplatesFishingCommand(const char*) -{ - sLog.outString( "Re-Loading Loot Tables... (`fishing_loot_template`)" ); - LoadLootTemplates_Fishing(); - LootTemplates_Fishing.CheckLootRefs(); - SendGlobalSysMessage("DB table `fishing_loot_template` reloaded."); - return true; -} - -bool ChatHandler::HandleReloadLootTemplatesGameobjectCommand(const char*) -{ - sLog.outString( "Re-Loading Loot Tables... (`gameobject_loot_template`)" ); - LoadLootTemplates_Gameobject(); - LootTemplates_Gameobject.CheckLootRefs(); - SendGlobalSysMessage("DB table `gameobject_loot_template` reloaded."); - return true; -} - -bool ChatHandler::HandleReloadLootTemplatesItemCommand(const char*) -{ - sLog.outString( "Re-Loading Loot Tables... (`item_loot_template`)" ); - LoadLootTemplates_Item(); - LootTemplates_Item.CheckLootRefs(); - SendGlobalSysMessage("DB table `item_loot_template` reloaded."); - return true; -} - -bool ChatHandler::HandleReloadLootTemplatesPickpocketingCommand(const char*) -{ - sLog.outString( "Re-Loading Loot Tables... (`pickpocketing_loot_template`)" ); - LoadLootTemplates_Pickpocketing(); - LootTemplates_Pickpocketing.CheckLootRefs(); - SendGlobalSysMessage("DB table `pickpocketing_loot_template` reloaded."); - return true; -} - -bool ChatHandler::HandleReloadLootTemplatesProspectingCommand(const char*) -{ - sLog.outString( "Re-Loading Loot Tables... (`prospecting_loot_template`)" ); - LoadLootTemplates_Prospecting(); - LootTemplates_Prospecting.CheckLootRefs(); - SendGlobalSysMessage("DB table `prospecting_loot_template` reloaded."); - return true; -} - -bool ChatHandler::HandleReloadLootTemplatesQuestMailCommand(const char*) -{ - sLog.outString( "Re-Loading Loot Tables... (`quest_mail_loot_template`)" ); - LoadLootTemplates_QuestMail(); - LootTemplates_QuestMail.CheckLootRefs(); - SendGlobalSysMessage("DB table `quest_mail_loot_template` reloaded."); - return true; -} - -bool ChatHandler::HandleReloadLootTemplatesReferenceCommand(const char*) -{ - sLog.outString( "Re-Loading Loot Tables... (`reference_loot_template`)" ); - LoadLootTemplates_Reference(); - SendGlobalSysMessage("DB table `reference_loot_template` reloaded."); - return true; -} - -bool ChatHandler::HandleReloadLootTemplatesSkinningCommand(const char*) -{ - sLog.outString( "Re-Loading Loot Tables... (`skinning_loot_template`)" ); - LoadLootTemplates_Skinning(); - LootTemplates_Skinning.CheckLootRefs(); - SendGlobalSysMessage("DB table `skinning_loot_template` reloaded."); - return true; -} - -bool ChatHandler::HandleReloadMangosStringCommand(const char*) -{ - sLog.outString( "Re-Loading mangos_string Table!" ); - objmgr.LoadMangosStrings(); - SendGlobalSysMessage("DB table `mangos_string` reloaded."); - return true; -} - -bool ChatHandler::HandleReloadReservedNameCommand(const char*) -{ - sLog.outString( "Loading ReservedNames... (`reserved_name`)" ); - objmgr.LoadReservedPlayersNames(); - SendGlobalSysMessage("DB table `reserved_name` (player reserved names) reloaded."); - return true; -} - -bool ChatHandler::HandleReloadSkillDiscoveryTemplateCommand(const char* /*args*/) -{ - sLog.outString( "Re-Loading Skill Discovery Table..." ); - LoadSkillDiscoveryTable(); - SendGlobalSysMessage("DB table `skill_discovery_template` (recipes discovered at crafting) reloaded."); - return true; -} - -bool ChatHandler::HandleReloadSkillExtraItemTemplateCommand(const char* /*args*/) -{ - sLog.outString( "Re-Loading Skill Extra Item Table..." ); - LoadSkillExtraItemTable(); - SendGlobalSysMessage("DB table `skill_extra_item_template` (extra item creation when crafting) reloaded."); - return true; -} - -bool ChatHandler::HandleReloadSkillFishingBaseLevelCommand(const char* /*args*/) -{ - sLog.outString( "Re-Loading Skill Fishing base level requirements..." ); - objmgr.LoadFishingBaseSkillLevel(); - SendGlobalSysMessage("DB table `skill_fishing_base_level` (fishing base level for zone/subzone) reloaded."); - return true; -} - -bool ChatHandler::HandleReloadSpellAffectCommand(const char*) -{ - sLog.outString( "Re-Loading SpellAffect definitions..." ); - spellmgr.LoadSpellAffects(); - SendGlobalSysMessage("DB table `spell_affect` (spell mods apply requirements) reloaded."); - return true; -} - -bool ChatHandler::HandleReloadSpellChainCommand(const char*) -{ - sLog.outString( "Re-Loading Spell Chain Data... " ); - spellmgr.LoadSpellChains(); - SendGlobalSysMessage("DB table `spell_chain` (spell ranks) reloaded."); - return true; -} - -bool ChatHandler::HandleReloadSpellElixirCommand(const char*) -{ - sLog.outString( "Re-Loading Spell Elixir types..." ); - spellmgr.LoadSpellElixirs(); - SendGlobalSysMessage("DB table `spell_elixir` (spell exlixir types) reloaded."); - return true; -} - -bool ChatHandler::HandleReloadSpellLearnSpellCommand(const char*) -{ - sLog.outString( "Re-Loading Spell Learn Spells..." ); - spellmgr.LoadSpellLearnSpells(); - SendGlobalSysMessage("DB table `spell_learn_spell` reloaded."); - return true; -} - -bool ChatHandler::HandleReloadSpellProcEventCommand(const char*) -{ - sLog.outString( "Re-Loading Spell Proc Event conditions..." ); - spellmgr.LoadSpellProcEvents(); - SendGlobalSysMessage("DB table `spell_proc_event` (spell proc trigger requirements) reloaded."); - return true; -} - -bool ChatHandler::HandleReloadSpellScriptTargetCommand(const char*) -{ - sLog.outString( "Re-Loading SpellsScriptTarget..." ); - spellmgr.LoadSpellScriptTarget(); - SendGlobalSysMessage("DB table `spell_script_target` (spell targets selection in case specific creature/GO requirements) reloaded."); - return true; -} - -bool ChatHandler::HandleReloadSpellTargetPositionCommand(const char*) -{ - sLog.outString( "Re-Loading Spell target coordinates..." ); - spellmgr.LoadSpellTargetPositions(); - SendGlobalSysMessage("DB table `spell_target_position` (destination coordinates for spell targets) reloaded."); - return true; -} - -bool ChatHandler::HandleReloadSpellThreatsCommand(const char*) -{ - sLog.outString( "Re-Loading Aggro Spells Definitions..."); - spellmgr.LoadSpellThreats(); - SendGlobalSysMessage("DB table `spell_threat` (spell aggro definitions) reloaded."); - return true; -} - -bool ChatHandler::HandleReloadSpellPetAurasCommand(const char*) -{ - sLog.outString( "Re-Loading Spell pet auras..."); - spellmgr.LoadSpellPetAuras(); - SendGlobalSysMessage("DB table `spell_pet_auras` reloaded."); - return true; -} - -bool ChatHandler::HandleReloadPageTextsCommand(const char*) -{ - sLog.outString( "Re-Loading Page Texts..." ); - objmgr.LoadPageTexts(); - SendGlobalSysMessage("DB table `page_texts` reloaded."); - return true; -} - -bool ChatHandler::HandleReloadItemEnchantementsCommand(const char*) -{ - sLog.outString( "Re-Loading Item Random Enchantments Table..." ); - LoadRandomEnchantmentsTable(); - SendGlobalSysMessage("DB table `item_enchantment_template` reloaded."); - return true; -} - -bool ChatHandler::HandleReloadGameObjectScriptsCommand(const char* arg) -{ - if(sWorld.IsScriptScheduled()) - { - SendSysMessage("DB scripts used currently, please attempt reload later."); - SetSentErrorMessage(true); - return false; - } - - if(*arg!='a') - sLog.outString( "Re-Loading Scripts from `gameobject_scripts`..."); - - objmgr.LoadGameObjectScripts(); - - if(*arg!='a') - SendGlobalSysMessage("DB table `gameobject_scripts` reloaded."); - - return true; -} - -bool ChatHandler::HandleReloadEventScriptsCommand(const char* arg) -{ - if(sWorld.IsScriptScheduled()) - { - SendSysMessage("DB scripts used currently, please attempt reload later."); - SetSentErrorMessage(true); - return false; - } - - if(*arg!='a') - sLog.outString( "Re-Loading Scripts from `event_scripts`..."); - - objmgr.LoadEventScripts(); - - if(*arg!='a') - SendGlobalSysMessage("DB table `event_scripts` reloaded."); - - return true; -} - -bool ChatHandler::HandleReloadQuestEndScriptsCommand(const char* arg) -{ - if(sWorld.IsScriptScheduled()) - { - SendSysMessage("DB scripts used currently, please attempt reload later."); - SetSentErrorMessage(true); - return false; - } - - if(*arg!='a') - sLog.outString( "Re-Loading Scripts from `quest_end_scripts`..."); - - objmgr.LoadQuestEndScripts(); - - if(*arg!='a') - SendGlobalSysMessage("DB table `quest_end_scripts` reloaded."); - - return true; -} - -bool ChatHandler::HandleReloadQuestStartScriptsCommand(const char* arg) -{ - if(sWorld.IsScriptScheduled()) - { - SendSysMessage("DB scripts used currently, please attempt reload later."); - SetSentErrorMessage(true); - return false; - } - - if(*arg!='a') - sLog.outString( "Re-Loading Scripts from `quest_start_scripts`..."); - - objmgr.LoadQuestStartScripts(); - - if(*arg!='a') - SendGlobalSysMessage("DB table `quest_start_scripts` reloaded."); - - return true; -} - -bool ChatHandler::HandleReloadSpellScriptsCommand(const char* arg) -{ - if(sWorld.IsScriptScheduled()) - { - SendSysMessage("DB scripts used currently, please attempt reload later."); - SetSentErrorMessage(true); - return false; - } - - if(*arg!='a') - sLog.outString( "Re-Loading Scripts from `spell_scripts`..."); - - objmgr.LoadSpellScripts(); - - if(*arg!='a') - SendGlobalSysMessage("DB table `spell_scripts` reloaded."); - - return true; -} - -bool ChatHandler::HandleReloadGameGraveyardZoneCommand(const char* /*arg*/) -{ - sLog.outString( "Re-Loading Graveyard-zone links..."); - - objmgr.LoadGraveyardZones(); - - SendGlobalSysMessage("DB table `game_graveyard_zone` reloaded."); - - return true; -} - -bool ChatHandler::HandleLoadScriptsCommand(const char* args) -{ - if(!LoadScriptingModule(args)) return true; - - sWorld.SendWorldText(LANG_SCRIPTS_RELOADED); - return true; -} - -bool ChatHandler::HandleSecurityCommand(const char* args) -{ - char* arg1 = strtok((char*)args, " "); - if( !arg1 ) - return false; - - char* arg2 = 0; - - std::string targetName; - uint32 targetAccountId = 0; - uint32 targetSecurity = 0; - - Player* targetPlayer = getSelectedPlayer(); - if(targetPlayer) - { - targetName = targetPlayer->GetName(); - targetAccountId = targetPlayer->GetSession()->GetAccountId(); - targetSecurity = targetPlayer->GetSession()->GetSecurity(); - arg2 = arg1; - } - else - { - targetName = arg1; - if(!normalizePlayerName(targetName)) - { - SendSysMessage(LANG_PLAYER_NOT_FOUND); - SetSentErrorMessage(true); - return false; - } - - targetPlayer = ObjectAccessor::Instance().FindPlayerByName(targetName.c_str()); - if(targetPlayer) - { - targetAccountId = targetPlayer->GetSession()->GetAccountId(); - targetSecurity = targetPlayer->GetSession()->GetSecurity(); - } - else - { - uint64 targetGUID = objmgr.GetPlayerGUIDByName(targetName.c_str()); - if(!targetGUID) - { - SendSysMessage(LANG_PLAYER_NOT_FOUND); - SetSentErrorMessage(true); - return false; - } - targetAccountId = objmgr.GetPlayerAccountIdByGUID(targetGUID); - targetSecurity = objmgr.GetSecurityByAccount(targetAccountId); - } - - arg2 = strtok(NULL, " "); - } - - int32 gm = (int32)atoi(arg2); - if ( gm < SEC_PLAYER || gm > SEC_ADMINISTRATOR ) - { - SendSysMessage(LANG_BAD_VALUE); - SetSentErrorMessage(true); - return false; - } - - // can set security level only for target with less security and to less security that we have - if(targetSecurity >= m_session->GetSecurity() || uint32(gm) >= m_session->GetSecurity() ) - { - SendSysMessage(LANG_YOURS_SECURITY_IS_LOW); - SetSentErrorMessage(true); - return false; - } - - if(targetPlayer) - { - if( targetPlayer != m_session->GetPlayer() ) - ChatHandler(targetPlayer).PSendSysMessage(LANG_YOURS_SECURITY_CHANGED,m_session->GetPlayer()->GetName(), gm); - - targetPlayer->GetSession()->SetSecurity(gm); - } - - PSendSysMessage(LANG_YOU_CHANGE_SECURITY, targetName.c_str(), gm); - loginDatabase.PExecute("UPDATE account SET gmlevel = '%i' WHERE id = '%u'", gm, targetAccountId); - - return true; -} - -bool ChatHandler::HandleAllowMovementCommand(const char* /*args*/) -{ - if(sWorld.getAllowMovement()) - { - sWorld.SetAllowMovement(false); - SendSysMessage(LANG_CREATURE_MOVE_DISABLED); - } - else - { - sWorld.SetAllowMovement(true); - SendSysMessage(LANG_CREATURE_MOVE_ENABLED); - } - return true; -} - -bool ChatHandler::HandleMaxSkillCommand(const char* /*args*/) -{ - Player* SelectedPlayer = getSelectedPlayer(); - if(!SelectedPlayer) - { - SendSysMessage(LANG_NO_CHAR_SELECTED); - SetSentErrorMessage(true); - return false; - } - - // each skills that have max skill value dependent from level seted to current level max skill value - SelectedPlayer->UpdateSkillsToMaxSkillsForLevel(); - return true; -} - -bool ChatHandler::HandleSetSkillCommand(const char* args) -{ - // number or [name] Shift-click form |color|Hskill:skill_id|h[name]|h|r - char* skill_p = extractKeyFromLink((char*)args,"Hskill"); - if(!skill_p) - return false; - - char *level_p = strtok (NULL, " "); - - if( !level_p) - return false; - - char *max_p = strtok (NULL, " "); - - int32 skill = atoi(skill_p); - - if (skill <= 0) - { - PSendSysMessage(LANG_INVALID_SKILL_ID, skill); - SetSentErrorMessage(true); - return false; - } - - int32 level = atol (level_p); - - Player * target = getSelectedPlayer(); - if(!target) - { - SendSysMessage(LANG_NO_CHAR_SELECTED); - SetSentErrorMessage(true); - return false; - } - - SkillLineEntry const* sl = sSkillLineStore.LookupEntry(skill); - if(!sl) - { - PSendSysMessage(LANG_INVALID_SKILL_ID, skill); - SetSentErrorMessage(true); - return false; - } - - if(!target->GetSkillValue(skill)) - { - PSendSysMessage(LANG_SET_SKILL_ERROR, target->GetName(), skill, sl->name[0]); - SetSentErrorMessage(true); - return false; - } - - int32 max = max_p ? atol (max_p) : target->GetPureMaxSkillValue(skill); - - if( level <= 0 || level > max || max <= 0 ) - return false; - - target->SetSkill(skill, level, max); - PSendSysMessage(LANG_SET_SKILL, skill, sl->name[0], target->GetName(), level, max); - - return true; -} - -bool ChatHandler::HandleUnLearnCommand(const char* args) -{ - if (!*args) - return false; - - - // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r - uint32 min_id = extractSpellIdFromLink((char*)args); - if(!min_id) - return false; - - // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r - char* tail = strtok(NULL,""); - - uint32 max_id = extractSpellIdFromLink(tail); - - if (!max_id) - { - // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r - max_id = min_id+1; - } - else - { - if (max_id < min_id) - std::swap(min_id,max_id); - - max_id=max_id+1; - } - - Player* target = getSelectedPlayer(); - if(!target) - { - SendSysMessage(LANG_NO_CHAR_SELECTED); - SetSentErrorMessage(true); - return false; - } - - for(uint32 spell=min_id;spellHasSpell(spell)) - target->removeSpell(spell); - else - SendSysMessage(LANG_FORGET_SPELL); - } - - return true; -} - -bool ChatHandler::HandleCooldownCommand(const char* args) -{ - Player* target = getSelectedPlayer(); - if(!target) - { - SendSysMessage(LANG_PLAYER_NOT_FOUND); - SetSentErrorMessage(true); - return false; - } - - if (!*args) - { - target->RemoveAllSpellCooldown(); - PSendSysMessage(LANG_REMOVEALL_COOLDOWN, target->GetName()); - } - else - { - // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form - uint32 spell_id = extractSpellIdFromLink((char*)args); - if(!spell_id) - return false; - - if(!sSpellStore.LookupEntry(spell_id)) - { - PSendSysMessage(LANG_UNKNOWN_SPELL, target==m_session->GetPlayer() ? GetMangosString(LANG_YOU) : target->GetName()); - SetSentErrorMessage(true); - return false; - } - - WorldPacket data( SMSG_CLEAR_COOLDOWN, (4+8) ); - data << uint32(spell_id); - data << uint64(target->GetGUID()); - target->GetSession()->SendPacket(&data); - target->RemoveSpellCooldown(spell_id); - PSendSysMessage(LANG_REMOVE_COOLDOWN, spell_id, target==m_session->GetPlayer() ? GetMangosString(LANG_YOU) : target->GetName()); - } - return true; -} - -bool ChatHandler::HandleLearnAllCommand(const char* /*args*/) -{ - static const char *allSpellList[] = - { - "3365", - "6233", - "6247", - "6246", - "6477", - "6478", - "22810", - "8386", - "21651", - "21652", - "522", - "7266", - "8597", - "2479", - "22027", - "6603", - "5019", - "133", - "168", - "227", - "5009", - "9078", - "668", - "203", - "20599", - "20600", - "81", - "20597", - "20598", - "20864", - "1459", - "5504", - "587", - "5143", - "118", - "5505", - "597", - "604", - "1449", - "1460", - "2855", - "1008", - "475", - "5506", - "1463", - "12824", - "8437", - "990", - "5145", - "8450", - "1461", - "759", - "8494", - "8455", - "8438", - "6127", - "8416", - "6129", - "8451", - "8495", - "8439", - "3552", - "8417", - "10138", - "12825", - "10169", - "10156", - "10144", - "10191", - "10201", - "10211", - "10053", - "10173", - "10139", - "10145", - "10192", - "10170", - "10202", - "10054", - "10174", - "10193", - "12826", - "2136", - "143", - "145", - "2137", - "2120", - "3140", - "543", - "2138", - "2948", - "8400", - "2121", - "8444", - "8412", - "8457", - "8401", - "8422", - "8445", - "8402", - "8413", - "8458", - "8423", - "8446", - "10148", - "10197", - "10205", - "10149", - "10215", - "10223", - "10206", - "10199", - "10150", - "10216", - "10207", - "10225", - "10151", - "116", - "205", - "7300", - "122", - "837", - "10", - "7301", - "7322", - "6143", - "120", - "865", - "8406", - "6141", - "7302", - "8461", - "8407", - "8492", - "8427", - "8408", - "6131", - "7320", - "10159", - "8462", - "10185", - "10179", - "10160", - "10180", - "10219", - "10186", - "10177", - "10230", - "10181", - "10161", - "10187", - "10220", - "2018", - "2663", - "12260", - "2660", - "3115", - "3326", - "2665", - "3116", - "2738", - "3293", - "2661", - "3319", - "2662", - "9983", - "8880", - "2737", - "2739", - "7408", - "3320", - "2666", - "3323", - "3324", - "3294", - "22723", - "23219", - "23220", - "23221", - "23228", - "23338", - "10788", - "10790", - "5611", - "5016", - "5609", - "2060", - "10963", - "10964", - "10965", - "22593", - "22594", - "596", - "996", - "499", - "768", - "17002", - "1448", - "1082", - "16979", - "1079", - "5215", - "20484", - "5221", - "15590", - "17007", - "6795", - "6807", - "5487", - "1446", - "1066", - "5421", - "3139", - "779", - "6811", - "6808", - "1445", - "5216", - "1737", - "5222", - "5217", - "1432", - "6812", - "9492", - "5210", - "3030", - "1441", - "783", - "6801", - "20739", - "8944", - "9491", - "22569", - "5226", - "6786", - "1433", - "8973", - "1828", - "9495", - "9006", - "6794", - "8993", - "5203", - "16914", - "6784", - "9635", - "22830", - "20722", - "9748", - "6790", - "9753", - "9493", - "9752", - "9831", - "9825", - "9822", - "5204", - "5401", - "22831", - "6793", - "9845", - "17401", - "9882", - "9868", - "20749", - "9893", - "9899", - "9895", - "9832", - "9902", - "9909", - "22832", - "9828", - "9851", - "9883", - "9869", - "17406", - "17402", - "9914", - "20750", - "9897", - "9848", - "3127", - "107", - "204", - "9116", - "2457", - "78", - "18848", - "331", - "403", - "2098", - "1752", - "11278", - "11288", - "11284", - "6461", - "2344", - "2345", - "6463", - "2346", - "2352", - "775", - "1434", - "1612", - "71", - "2468", - "2458", - "2467", - "7164", - "7178", - "7367", - "7376", - "7381", - "21156", - "5209", - "3029", - "5201", - "9849", - "9850", - "20719", - "22568", - "22827", - "22828", - "22829", - "6809", - "8972", - "9005", - "9823", - "9827", - "6783", - "9913", - "6785", - "6787", - "9866", - "9867", - "9894", - "9896", - "6800", - "8992", - "9829", - "9830", - "780", - "769", - "6749", - "6750", - "9755", - "9754", - "9908", - "20745", - "20742", - "20747", - "20748", - "9746", - "9745", - "9880", - "9881", - "5391", - "842", - "3025", - "3031", - "3287", - "3329", - "1945", - "3559", - "4933", - "4934", - "4935", - "4936", - "5142", - "5390", - "5392", - "5404", - "5420", - "6405", - "7293", - "7965", - "8041", - "8153", - "9033", - "9034", - //"9036", problems with ghost state - "16421", - "21653", - "22660", - "5225", - "9846", - "2426", - "5916", - "6634", - //"6718", phasing stealth, annoing for learn all case. - "6719", - "8822", - "9591", - "9590", - "10032", - "17746", - "17747", - "8203", - "11392", - "12495", - "16380", - "23452", - "4079", - "4996", - "4997", - "4998", - "4999", - "5000", - "6348", - "6349", - "6481", - "6482", - "6483", - "6484", - "11362", - "11410", - "11409", - "12510", - "12509", - "12885", - "13142", - "21463", - "23460", - "11421", - "11416", - "11418", - "1851", - "10059", - "11423", - "11417", - "11422", - "11419", - "11424", - "11420", - "27", - "31", - "33", - "34", - "35", - "15125", - "21127", - "22950", - "1180", - "201", - "12593", - "12842", - "16770", - "6057", - "12051", - "18468", - "12606", - "12605", - "18466", - "12502", - "12043", - "15060", - "12042", - "12341", - "12848", - "12344", - "12353", - "18460", - "11366", - "12350", - "12352", - "13043", - "11368", - "11113", - "12400", - "11129", - "16766", - "12573", - "15053", - "12580", - "12475", - "12472", - "12953", - "12488", - "11189", - "12985", - "12519", - "16758", - "11958", - "12490", - "11426", - "3565", - "3562", - "18960", - "3567", - "3561", - "3566", - "3563", - "1953", - "2139", - "12505", - "13018", - "12522", - "12523", - "5146", - "5144", - "5148", - "8419", - "8418", - "10213", - "10212", - "10157", - "12524", - "13019", - "12525", - "13020", - "12526", - "13021", - "18809", - "13031", - "13032", - "13033", - "4036", - "3920", - "3919", - "3918", - "7430", - "3922", - "3923", - "7411", - "7418", - "7421", - "13262", - "7412", - "7415", - "7413", - "7416", - "13920", - "13921", - "7745", - "7779", - "7428", - "7457", - "7857", - "7748", - "7426", - "13421", - "7454", - "13378", - "7788", - "14807", - "14293", - "7795", - "6296", - "20608", - "755", - "444", - "427", - "428", - "442", - "447", - "3578", - "3581", - "19027", - "3580", - "665", - "3579", - "3577", - "6755", - "3576", - "2575", - "2577", - "2578", - "2579", - "2580", - "2656", - "2657", - "2576", - "3564", - "10248", - "8388", - "2659", - "14891", - "3308", - "3307", - "10097", - "2658", - "3569", - "16153", - "3304", - "10098", - "4037", - "3929", - "3931", - "3926", - "3924", - "3930", - "3977", - "3925", - "136", - "228", - "5487", - "43", - "202", - "0" - }; - - int loop = 0; - while(strcmp(allSpellList[loop], "0")) - { - uint32 spell = atol((char*)allSpellList[loop++]); - - if (m_session->GetPlayer()->HasSpell(spell)) - continue; - - SpellEntry const* spellInfo = sSpellStore.LookupEntry(spell); - if(!spellInfo || !SpellMgr::IsSpellValid(spellInfo,m_session->GetPlayer())) - { - PSendSysMessage(LANG_COMMAND_SPELL_BROKEN,spell); - continue; - } - - m_session->GetPlayer()->learnSpell(spell); - } - - SendSysMessage(LANG_COMMAND_LEARN_MANY_SPELLS); - - return true; -} - -bool ChatHandler::HandleLearnAllGMCommand(const char* /*args*/) -{ - static const char *gmSpellList[] = - { - "24347", // Become A Fish, No Breath Bar - "35132", // Visual Boom - "38488", // Attack 4000-8000 AOE - "38795", // Attack 2000 AOE + Slow Down 90% - "15712", // Attack 200 - "1852", // GM Spell Silence - "31899", // Kill - "31924", // Kill - "29878", // Kill My Self - "26644", // More Kill - - "28550", //Invisible 24 - "23452", //Invisible + Target - "0" - }; - - uint16 gmSpellIter = 0; - while( strcmp(gmSpellList[gmSpellIter], "0") ) - { - uint32 spell = atol((char*)gmSpellList[gmSpellIter++]); - - SpellEntry const* spellInfo = sSpellStore.LookupEntry(spell); - if(!spellInfo || !SpellMgr::IsSpellValid(spellInfo,m_session->GetPlayer())) - { - PSendSysMessage(LANG_COMMAND_SPELL_BROKEN,spell); - continue; - } - - m_session->GetPlayer()->learnSpell(spell); - } - - SendSysMessage(LANG_LEARNING_GM_SKILLS); - return true; -} - -bool ChatHandler::HandleLearnAllMyClassCommand(const char* /*args*/) -{ - HandleLearnAllMySpellsCommand(""); - HandleLearnAllMyTalentsCommand(""); - return true; -} - -bool ChatHandler::HandleLearnAllMySpellsCommand(const char* /*args*/) -{ - ChrClassesEntry const* clsEntry = sChrClassesStore.LookupEntry(m_session->GetPlayer()->getClass()); - if(!clsEntry) - return true; - uint32 family = clsEntry->spellfamily; - - for (uint32 i = 0; i < sSpellStore.GetNumRows(); i++) - { - SpellEntry const *spellInfo = sSpellStore.LookupEntry(i); - if(!spellInfo) - continue; - - // skip wrong class/race skills - if(!m_session->GetPlayer()->IsSpellFitByClassAndRace(spellInfo->Id)) - continue; - - // skip other spell families - if( spellInfo->SpellFamilyName != family) - continue; - - //TODO: skip triggered spells - - // skip spells with first rank learned as talent (and all talents then also) - uint32 first_rank = spellmgr.GetFirstSpellInChain(spellInfo->Id); - if(GetTalentSpellCost(first_rank) > 0 ) - continue; - - // skip broken spells - if(!SpellMgr::IsSpellValid(spellInfo,m_session->GetPlayer(),false)) - continue; - - m_session->GetPlayer()->learnSpell(i); - } - - SendSysMessage(LANG_COMMAND_LEARN_CLASS_SPELLS); - return true; -} - -static void learnAllHighRanks(Player* player, uint32 spellid) -{ - SpellChainMapNext const& nextMap = spellmgr.GetSpellChainNext(); - for(SpellChainMapNext::const_iterator itr = nextMap.lower_bound(spellid); itr != nextMap.upper_bound(spellid); ++itr) - { - player->learnSpell(itr->second); - learnAllHighRanks(player,itr->second); - } -} - -bool ChatHandler::HandleLearnAllMyTalentsCommand(const char* /*args*/) -{ - Player* player = m_session->GetPlayer(); - uint32 classMask = player->getClassMask(); - - for (uint32 i = 0; i < sTalentStore.GetNumRows(); i++) - { - TalentEntry const *talentInfo = sTalentStore.LookupEntry(i); - if(!talentInfo) - continue; - - TalentTabEntry const *talentTabInfo = sTalentTabStore.LookupEntry( talentInfo->TalentTab ); - if(!talentTabInfo) - continue; - - if( (classMask & talentTabInfo->ClassMask) == 0 ) - continue; - - // search highest talent rank - uint32 spellid = 0; - int rank = 4; - for(; rank >= 0; --rank) - { - if(talentInfo->RankID[rank]!=0) - { - spellid = talentInfo->RankID[rank]; - break; - } - } - - if(!spellid) // ??? none spells in telent - continue; - - SpellEntry const* spellInfo = sSpellStore.LookupEntry(spellid); - if(!spellInfo || !SpellMgr::IsSpellValid(spellInfo,m_session->GetPlayer(),false)) - continue; - - // learn highest rank of talent - player->learnSpell(spellid); - - // and learn all non-talent spell ranks (recursive by tree) - learnAllHighRanks(player,spellid); - } - - SendSysMessage(LANG_COMMAND_LEARN_CLASS_TALENTS); - return true; -} - -bool ChatHandler::HandleLearnAllLangCommand(const char* /*args*/) -{ - // skipping UNIVERSAL language (0) - for(int i = 1; i < LANGUAGES_COUNT; ++i) - m_session->GetPlayer()->learnSpell(lang_description[i].spell_id); - - SendSysMessage(LANG_COMMAND_LEARN_ALL_LANG); - return true; -} - -bool ChatHandler::HandleLearnAllDefaultCommand(const char* args) -{ - char* pName = strtok((char*)args, ""); - Player *player = NULL; - if (pName) - { - std::string name = pName; - - if(!normalizePlayerName(name)) - { - SendSysMessage(LANG_PLAYER_NOT_FOUND); - SetSentErrorMessage(true); - return false; - } - - player = objmgr.GetPlayer(name.c_str()); - } - else - player = getSelectedPlayer(); - - if(!player) - { - SendSysMessage(LANG_NO_CHAR_SELECTED); - SetSentErrorMessage(true); - return false; - } - - player->learnDefaultSpells(); - player->learnQuestRewardedSpells(); - - PSendSysMessage(LANG_COMMAND_LEARN_ALL_DEFAULT_AND_QUEST,player->GetName()); - return true; -} - -bool ChatHandler::HandleLearnCommand(const char* args) -{ - Player* targetPlayer = getSelectedPlayer(); - - if(!targetPlayer) - { - SendSysMessage(LANG_PLAYER_NOT_FOUND); - SetSentErrorMessage(true); - return false; - } - - // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form - uint32 spell = extractSpellIdFromLink((char*)args); - if(!spell || !sSpellStore.LookupEntry(spell)) - return false; - - if (targetPlayer->HasSpell(spell)) - { - if(targetPlayer == m_session->GetPlayer()) - SendSysMessage(LANG_YOU_KNOWN_SPELL); - else - PSendSysMessage(LANG_TARGET_KNOWN_SPELL,targetPlayer->GetName()); - SetSentErrorMessage(true); - return false; - } - - SpellEntry const* spellInfo = sSpellStore.LookupEntry(spell); - if(!spellInfo || !SpellMgr::IsSpellValid(spellInfo,m_session->GetPlayer())) - { - PSendSysMessage(LANG_COMMAND_SPELL_BROKEN,spell); - SetSentErrorMessage(true); - return false; - } - - targetPlayer->learnSpell(spell); - - return true; -} - -bool ChatHandler::HandleAddItemCommand(const char* args) -{ - if (!*args) - return false; - - uint32 itemId = 0; - - if(args[0]=='[') // [name] manual form - { - char* citemName = citemName = strtok((char*)args, "]"); - - if(citemName && citemName[0]) - { - std::string itemName = citemName+1; - WorldDatabase.escape_string(itemName); - QueryResult *result = WorldDatabase.PQuery("SELECT entry FROM item_template WHERE name = '%s'", itemName.c_str()); - if (!result) - { - PSendSysMessage(LANG_COMMAND_COULDNOTFIND, citemName+1); - SetSentErrorMessage(true); - return false; - } - itemId = result->Fetch()->GetUInt16(); - delete result; - } - else - return false; - } - else // item_id or [name] Shift-click form |color|Hitem:item_id:0:0:0|h[name]|h|r - { - char* cId = extractKeyFromLink((char*)args,"Hitem"); - if(!cId) - return false; - itemId = atol(cId); - } - - char* ccount = strtok(NULL, " "); - - int32 count = 1; - - if (ccount) - count = strtol(ccount, NULL, 10); - - if (count == 0) - count = 1; - - Player* pl = m_session->GetPlayer(); - Player* plTarget = getSelectedPlayer(); - if(!plTarget) - plTarget = pl; - - sLog.outDetail(GetMangosString(LANG_ADDITEM), itemId, count); - - ItemPrototype const *pProto = objmgr.GetItemPrototype(itemId); - if(!pProto) - { - PSendSysMessage(LANG_COMMAND_ITEMIDINVALID, itemId); - SetSentErrorMessage(true); - return false; - } - - //Subtract - if (count < 0) - { - plTarget->DestroyItemCount(itemId, -count, true, false); - PSendSysMessage(LANG_REMOVEITEM, itemId, -count, plTarget->GetName()); - return true; - } - - //Adding items - uint32 noSpaceForCount = 0; - - // check space and find places - ItemPosCountVec dest; - uint8 msg = plTarget->CanStoreNewItem( NULL_BAG, NULL_SLOT, dest, itemId, count, &noSpaceForCount ); - if( msg != EQUIP_ERR_OK ) // convert to possible store amount - count -= noSpaceForCount; - - if( count == 0 || dest.empty()) // can't add any - { - PSendSysMessage(LANG_ITEM_CANNOT_CREATE, itemId, noSpaceForCount ); - SetSentErrorMessage(true); - return false; - } - - Item* item = plTarget->StoreNewItem( dest, itemId, true, Item::GenerateItemRandomPropertyId(itemId)); - - // remove binding (let GM give it to another player later) - if(pl==plTarget) - for(ItemPosCountVec::const_iterator itr = dest.begin(); itr != dest.end(); ++itr) - if(Item* item1 = pl->GetItemByPos(itr->pos)) - item1->SetBinding( false ); - - if(count > 0 && item) - { - pl->SendNewItem(item,count,false,true); - if(pl!=plTarget) - plTarget->SendNewItem(item,count,true,false); - } - - if(noSpaceForCount > 0) - PSendSysMessage(LANG_ITEM_CANNOT_CREATE, itemId, noSpaceForCount); - - return true; -} - -bool ChatHandler::HandleAddItemSetCommand(const char* args) -{ - if (!*args) - return false; - - char* cId = extractKeyFromLink((char*)args,"Hitemset"); // number or [name] Shift-click form |color|Hitemset:itemset_id|h[name]|h|r - if (!cId) - return false; - - uint32 itemsetId = atol(cId); - - // prevent generation all items with itemset field value '0' - if (itemsetId == 0) - { - PSendSysMessage(LANG_NO_ITEMS_FROM_ITEMSET_FOUND,itemsetId); - SetSentErrorMessage(true); - return false; - } - - Player* pl = m_session->GetPlayer(); - Player* plTarget = getSelectedPlayer(); - if(!plTarget) - plTarget = pl; - - sLog.outDetail(GetMangosString(LANG_ADDITEMSET), itemsetId); - - QueryResult *result = WorldDatabase.PQuery("SELECT entry FROM item_template WHERE itemset = %u",itemsetId); - - if(!result) - { - PSendSysMessage(LANG_NO_ITEMS_FROM_ITEMSET_FOUND,itemsetId); - - SetSentErrorMessage(true); - return false; - } - - do - { - Field *fields = result->Fetch(); - uint32 itemId = fields[0].GetUInt32(); - - ItemPosCountVec dest; - uint8 msg = plTarget->CanStoreNewItem( NULL_BAG, NULL_SLOT, dest, itemId, 1 ); - if( msg == EQUIP_ERR_OK ) - { - Item* item = plTarget->StoreNewItem( dest, itemId, true); - - // remove binding (let GM give it to another player later) - if(pl==plTarget) - item->SetBinding( false ); - - pl->SendNewItem(item,1,false,true); - if(pl!=plTarget) - plTarget->SendNewItem(item,1,true,false); - } - else - { - pl->SendEquipError( msg, NULL, NULL ); - PSendSysMessage(LANG_ITEM_CANNOT_CREATE, itemId, 1); - } - - }while( result->NextRow() ); - - delete result; - - return true; -} - -bool ChatHandler::HandleListItemCommand(const char* args) -{ - if(!*args) - return false; - - char* cId = extractKeyFromLink((char*)args,"Hitem"); - if(!cId) - return false; - uint32 item_id = atol(cId); - - ItemPrototype const* itemProto = item_id ? itemProto = objmgr.GetItemPrototype(item_id) : NULL; - - if(!itemProto) - { - PSendSysMessage(LANG_COMMAND_ITEMIDINVALID, item_id); - SetSentErrorMessage(true); - return false; - } - - char* c_count = strtok(NULL, " "); - int count = c_count ? atol(c_count) : 10; - - if(count < 0) - return false; - - QueryResult *result; - - // inventory case - uint32 inv_count = 0; - result=CharacterDatabase.PQuery("SELECT COUNT(item_template) FROM character_inventory WHERE item_template='%u'",item_id); - if(result) - { - inv_count = (*result)[0].GetUInt32(); - delete result; - } - - result=CharacterDatabase.PQuery( - // 0 1 2 3 4 5 - "SELECT ci.item, cibag.slot AS bag, ci.slot, ci.guid, characters.account,characters.name " - "FROM character_inventory AS ci LEFT JOIN character_inventory AS cibag ON (cibag.item=ci.bag),characters " - "WHERE ci.item_template='%u' AND ci.guid = characters.guid LIMIT %u ", - item_id,uint32(count)); - - if(result) - { - do - { - Field *fields = result->Fetch(); - uint32 item_guid = fields[0].GetUInt32(); - uint32 item_bag = fields[1].GetUInt32(); - uint32 item_slot = fields[2].GetUInt32(); - uint32 owner_guid = fields[3].GetUInt32(); - uint32 owner_acc = fields[4].GetUInt32(); - std::string owner_name = fields[5].GetCppString(); - - char const* item_pos = 0; - if(Player::IsEquipmentPos(item_bag,item_slot)) - item_pos = "[equipped]"; - else if(Player::IsInventoryPos(item_bag,item_slot)) - item_pos = "[in inventory]"; - else if(Player::IsBankPos(item_bag,item_slot)) - item_pos = "[in bank]"; - else - item_pos = ""; - - PSendSysMessage(LANG_ITEMLIST_SLOT, - item_guid,owner_name.c_str(),owner_guid,owner_acc,item_pos); - } while (result->NextRow()); - - int64 res_count = result->GetRowCount(); - - delete result; - - if(count > res_count) - count-=res_count; - else if(count) - count = 0; - } - - // mail case - uint32 mail_count = 0; - result=CharacterDatabase.PQuery("SELECT COUNT(item_template) FROM mail_items WHERE item_template='%u'", item_id); - if(result) - { - mail_count = (*result)[0].GetUInt32(); - delete result; - } - - if(count > 0) - { - result=CharacterDatabase.PQuery( - // 0 1 2 3 4 5 6 - "SELECT mail_items.item_guid, mail.sender, mail.receiver, char_s.account, char_s.name, char_r.account, char_r.name " - "FROM mail,mail_items,characters as char_s,characters as char_r " - "WHERE mail_items.item_template='%u' AND char_s.guid = mail.sender AND char_r.guid = mail.receiver AND mail.id=mail_items.mail_id LIMIT %u", - item_id,uint32(count)); - } - else - result = NULL; - - if(result) - { - do - { - Field *fields = result->Fetch(); - uint32 item_guid = fields[0].GetUInt32(); - uint32 item_s = fields[1].GetUInt32(); - uint32 item_r = fields[2].GetUInt32(); - uint32 item_s_acc = fields[3].GetUInt32(); - std::string item_s_name = fields[4].GetCppString(); - uint32 item_r_acc = fields[5].GetUInt32(); - std::string item_r_name = fields[6].GetCppString(); - - char const* item_pos = "[in mail]"; - - PSendSysMessage(LANG_ITEMLIST_MAIL, - item_guid,item_s_name.c_str(),item_s,item_s_acc,item_r_name.c_str(),item_r,item_r_acc,item_pos); - } while (result->NextRow()); - - int64 res_count = result->GetRowCount(); - - delete result; - - if(count > res_count) - count-=res_count; - else if(count) - count = 0; - } - - // auction case - uint32 auc_count = 0; - result=CharacterDatabase.PQuery("SELECT COUNT(item_template) FROM auctionhouse WHERE item_template='%u'",item_id); - if(result) - { - auc_count = (*result)[0].GetUInt32(); - delete result; - } - - if(count > 0) - { - result=CharacterDatabase.PQuery( - // 0 1 2 3 - "SELECT auctionhouse.itemguid, auctionhouse.itemowner, characters.account, characters.name " - "FROM auctionhouse,characters WHERE auctionhouse.item_template='%u' AND characters.guid = auctionhouse.itemowner LIMIT %u", - item_id,uint32(count)); - } - else - result = NULL; - - if(result) - { - do - { - Field *fields = result->Fetch(); - uint32 item_guid = fields[0].GetUInt32(); - uint32 owner = fields[1].GetUInt32(); - uint32 owner_acc = fields[2].GetUInt32(); - std::string owner_name = fields[3].GetCppString(); - - char const* item_pos = "[in auction]"; - - PSendSysMessage(LANG_ITEMLIST_AUCTION, item_guid, owner_name.c_str(), owner, owner_acc,item_pos); - } while (result->NextRow()); - - delete result; - } - - if(inv_count+mail_count+auc_count == 0) - { - SendSysMessage(LANG_COMMAND_NOITEMFOUND); - SetSentErrorMessage(true); - return false; - } - - PSendSysMessage(LANG_COMMAND_LISTITEMMESSAGE,item_id,inv_count+mail_count+auc_count,inv_count,mail_count,auc_count); - - return true; -} - -bool ChatHandler::HandleListObjectCommand(const char* args) -{ - if(!*args) - return false; - - // number or [name] Shift-click form |color|Hgameobject_entry:go_id|h[name]|h|r - char* cId = extractKeyFromLink((char*)args,"Hgameobject_entry"); - if(!cId) - return false; - - uint32 go_id = atol(cId); - - GameObjectInfo const * gInfo = objmgr.GetGameObjectInfo(go_id); - - if(!go_id || !gInfo) - { - PSendSysMessage(LANG_COMMAND_LISTOBJINVALIDID, go_id); - SetSentErrorMessage(true); - return false; - } - - char* c_count = strtok(NULL, " "); - int count = c_count ? atol(c_count) : 10; - - if(count < 0) - return false; - - Player* pl = m_session->GetPlayer(); - QueryResult *result; - - uint32 obj_count = 0; - result=WorldDatabase.PQuery("SELECT COUNT(guid) FROM gameobject WHERE id='%u'",go_id); - if(result) - { - obj_count = (*result)[0].GetUInt32(); - delete result; - } - - result = WorldDatabase.PQuery("SELECT guid, position_x, position_y, position_z, map, (POW(position_x - '%f', 2) + POW(position_y - '%f', 2) + POW(position_z - '%f', 2)) AS order_ FROM gameobject WHERE id = '%u' ORDER BY order_ ASC LIMIT %u", - pl->GetPositionX(), pl->GetPositionY(), pl->GetPositionZ(),go_id,uint32(count)); - - if (result) - { - do - { - Field *fields = result->Fetch(); - uint32 guid = fields[0].GetUInt32(); - float x = fields[1].GetFloat(); - float y = fields[2].GetFloat(); - float z = fields[3].GetFloat(); - int mapid = fields[4].GetUInt16(); - - PSendSysMessage(LANG_GO_LIST, guid, guid, gInfo->name, x, y, z, mapid); - } while (result->NextRow()); - - delete result; - } - - PSendSysMessage(LANG_COMMAND_LISTOBJMESSAGE,go_id,obj_count); - return true; -} - -bool ChatHandler::HandleNearObjectCommand(const char* args) -{ - float distance = (!*args) ? 10 : atol(args); - uint32 count = 0; - - Player* pl = m_session->GetPlayer(); - QueryResult *result = WorldDatabase.PQuery("SELECT guid, id, position_x, position_y, position_z, map, " - "(POW(position_x - '%f', 2) + POW(position_y - '%f', 2) + POW(position_z - '%f', 2)) AS order_ " - "FROM gameobject WHERE map='%u' AND (POW(position_x - '%f', 2) + POW(position_y - '%f', 2) + POW(position_z - '%f', 2)) <= '%f' ORDER BY order_", - pl->GetPositionX(), pl->GetPositionY(), pl->GetPositionZ(), - pl->GetMapId(),pl->GetPositionX(), pl->GetPositionY(), pl->GetPositionZ(),distance*distance); - - if (result) - { - do - { - Field *fields = result->Fetch(); - uint32 guid = fields[0].GetUInt32(); - uint32 entry = fields[1].GetUInt32(); - float x = fields[2].GetFloat(); - float y = fields[3].GetFloat(); - float z = fields[4].GetFloat(); - int mapid = fields[5].GetUInt16(); - - GameObjectInfo const * gInfo = objmgr.GetGameObjectInfo(entry); - - if(!gInfo) - continue; - - PSendSysMessage(LANG_GO_LIST, guid, guid, gInfo->name, x, y, z, mapid); - - ++count; - } while (result->NextRow()); - - delete result; - } - - PSendSysMessage(LANG_COMMAND_NEAROBJMESSAGE,distance,count); - return true; -} - -bool ChatHandler::HandleListCreatureCommand(const char* args) -{ - if(!*args) - return false; - - // number or [name] Shift-click form |color|Hcreature_entry:creature_id|h[name]|h|r - char* cId = extractKeyFromLink((char*)args,"Hcreature_entry"); - if(!cId) - return false; - - uint32 cr_id = atol(cId); - - CreatureInfo const* cInfo = objmgr.GetCreatureTemplate(cr_id); - - if(!cr_id || !cInfo) - { - PSendSysMessage(LANG_COMMAND_INVALIDCREATUREID, cr_id); - SetSentErrorMessage(true); - return false; - } - - char* c_count = strtok(NULL, " "); - int count = c_count ? atol(c_count) : 10; - - if(count < 0) - return false; - - Player* pl = m_session->GetPlayer(); - QueryResult *result; - - uint32 cr_count = 0; - result=WorldDatabase.PQuery("SELECT COUNT(guid) FROM creature WHERE id='%u'",cr_id); - if(result) - { - cr_count = (*result)[0].GetUInt32(); - delete result; - } - - result = WorldDatabase.PQuery("SELECT guid, position_x, position_y, position_z, map, (POW(position_x - '%f', 2) + POW(position_y - '%f', 2) + POW(position_z - '%f', 2)) AS order_ FROM creature WHERE id = '%u' ORDER BY order_ ASC LIMIT %u", - pl->GetPositionX(), pl->GetPositionY(), pl->GetPositionZ(), cr_id,uint32(count)); - - if (result) - { - do - { - Field *fields = result->Fetch(); - uint32 guid = fields[0].GetUInt32(); - float x = fields[1].GetFloat(); - float y = fields[2].GetFloat(); - float z = fields[3].GetFloat(); - int mapid = fields[4].GetUInt16(); - - PSendSysMessage(LANG_CREATURE_LIST, guid, guid, cInfo->Name, x, y, z, mapid); - } while (result->NextRow()); - - delete result; - } - - PSendSysMessage(LANG_COMMAND_LISTCREATUREMESSAGE,cr_id,cr_count); - return true; -} - -bool ChatHandler::HandleLookupItemCommand(const char* args) -{ - if(!*args) - return false; - - std::string namepart = args; - std::wstring wnamepart; - - // converting string that we try to find to lower case - if(!Utf8toWStr(namepart,wnamepart)) - return false; - - wstrToLower(wnamepart); - - uint32 counter = 0; - - // Search in `item_template` - for (uint32 id = 0; id < sItemStorage.MaxEntry; id++) - { - ItemPrototype const *pProto = sItemStorage.LookupEntry(id); - if(!pProto) - continue; - - int loc_idx = m_session->GetSessionDbLocaleIndex(); - if ( loc_idx >= 0 ) - { - ItemLocale const *il = objmgr.GetItemLocale(pProto->ItemId); - if (il) - { - if (il->Name.size() > loc_idx && !il->Name[loc_idx].empty()) - { - std::string name = il->Name[loc_idx]; - - if (Utf8FitTo(name, wnamepart)) - { - PSendSysMessage(LANG_ITEM_LIST, id, id, name.c_str()); - ++counter; - continue; - } - } - } - } - - std::string name = pProto->Name1; - if(name.empty()) - continue; - - if (Utf8FitTo(name, wnamepart)) - { - PSendSysMessage(LANG_ITEM_LIST, id, id, name.c_str()); - ++counter; - } - } - - if (counter==0) - SendSysMessage(LANG_COMMAND_NOITEMFOUND); - - return true; -} - -bool ChatHandler::HandleLookupItemSetCommand(const char* args) -{ - if(!*args) - return false; - - std::string namepart = args; - std::wstring wnamepart; - - if(!Utf8toWStr(namepart,wnamepart)) - return false; - - // converting string that we try to find to lower case - wstrToLower( wnamepart ); - - uint32 counter = 0; // Counter for figure out that we found smth. - - // Search in ItemSet.dbc - for (uint32 id = 0; id < sItemSetStore.GetNumRows(); id++) - { - ItemSetEntry const *set = sItemSetStore.LookupEntry(id); - if(set) - { - int loc = m_session->GetSessionDbcLocale(); - std::string name = set->name[m_session->GetSessionDbcLocale()]; - if(name.empty()) - continue; - - if (!Utf8FitTo(name, wnamepart)) - { - loc = 0; - for(; loc < MAX_LOCALE; ++loc) - { - if(loc==m_session->GetSessionDbcLocale()) - continue; - - name = set->name[m_session->GetSessionDbcLocale()]; - if(name.empty()) - continue; - - if (Utf8FitTo(name, wnamepart)) - break; - } - } - - if(loc < MAX_LOCALE) - { - // send item set in "id - [namedlink locale]" format - PSendSysMessage(LANG_ITEMSET_LIST,id,id,name.c_str(),localeNames[loc]); - ++counter; - } - } - } - if (counter == 0) // if counter == 0 then we found nth - SendSysMessage(LANG_COMMAND_NOITEMSETFOUND); - return true; -} - -bool ChatHandler::HandleLookupSkillCommand(const char* args) -{ - Player* target = getSelectedPlayer(); - if(!target) - { - SendSysMessage(LANG_PLAYER_NOT_FOUND); - SetSentErrorMessage(true); - return false; - } - - if(!*args) - return false; - - std::string namepart = args; - std::wstring wnamepart; - - if(!Utf8toWStr(namepart,wnamepart)) - return false; - - // converting string that we try to find to lower case - wstrToLower( wnamepart ); - - uint32 counter = 0; // Counter for figure out that we found smth. - - // Search in SkillLine.dbc - for (uint32 id = 0; id < sSkillLineStore.GetNumRows(); id++) - { - SkillLineEntry const *skillInfo = sSkillLineStore.LookupEntry(id); - if(skillInfo) - { - int loc = m_session->GetSessionDbcLocale(); - std::string name = skillInfo->name[loc]; - if(name.empty()) - continue; - - if (!Utf8FitTo(name, wnamepart)) - { - loc = 0; - for(; loc < MAX_LOCALE; ++loc) - { - if(loc==m_session->GetSessionDbcLocale()) - continue; - - name = skillInfo->name[loc]; - if(name.empty()) - continue; - - if (Utf8FitTo(name, wnamepart)) - break; - } - } - - if(loc < MAX_LOCALE) - { - // send skill in "id - [namedlink locale]" format - PSendSysMessage(LANG_SKILL_LIST,id,id,name.c_str(),localeNames[loc],(target->HasSkill(id) ? m_session->GetMangosString(LANG_KNOWN) : "")); - - ++counter; - } - } - } - if (counter == 0) // if counter == 0 then we found nth - SendSysMessage(LANG_COMMAND_NOSKILLFOUND); - return true; -} - -bool ChatHandler::HandleLookupSpellCommand(const char* args) -{ - Player* target = getSelectedPlayer(); - if( !target ) - { - SendSysMessage(LANG_PLAYER_NOT_FOUND); - SetSentErrorMessage(true); - return false; - } - - if(!*args) - return false; - - std::string namepart = args; - std::wstring wnamepart; - - if(!Utf8toWStr(namepart,wnamepart)) - return false; - - // converting string that we try to find to lower case - wstrToLower( wnamepart ); - - uint32 counter = 0; // Counter for figure out that we found smth. - - // Search in Spell.dbc - for (uint32 id = 0; id < sSpellStore.GetNumRows(); id++) - { - SpellEntry const *spellInfo = sSpellStore.LookupEntry(id); - if(spellInfo) - { - int loc = m_session->GetSessionDbcLocale(); - std::string name = spellInfo->SpellName[loc]; - if(name.empty()) - continue; - - if (!Utf8FitTo(name, wnamepart)) - { - loc = 0; - for(; loc < MAX_LOCALE; ++loc) - { - if(loc==m_session->GetSessionDbcLocale()) - continue; - - name = spellInfo->SpellName[loc]; - if(name.empty()) - continue; - - if (Utf8FitTo(name, wnamepart)) - break; - } - } - - if(loc < MAX_LOCALE) - { - bool known = target->HasSpell(id); - bool learn = (spellInfo->Effect[0] == SPELL_EFFECT_LEARN_SPELL); - - uint32 telentCost = GetTalentSpellCost(id); - - bool talent = (telentCost > 0); - bool passive = IsPassiveSpell(id); - bool active = target->HasAura(id,0) || target->HasAura(id,1) || target->HasAura(id,2); - - // unit32 used to prevent interpreting uint8 as char at output - // find rank of learned spell for learning spell, or talent rank - uint32 rank = telentCost ? telentCost : spellmgr.GetSpellRank(learn ? spellInfo->EffectTriggerSpell[0] : id); - - // send spell in "id - [name, rank N] [talent] [passive] [learn] [known]" format - std::ostringstream ss; - ss << id << " - |cffffffff|Hspell:" << id << "|h[" << name; - - // include rank in link name - if(rank) - ss << GetMangosString(LANG_SPELL_RANK) << rank; - - ss << " " << localeNames[loc] << "]|h|r"; - - if(talent) - ss << GetMangosString(LANG_TALENT); - if(passive) - ss << GetMangosString(LANG_PASSIVE); - if(learn) - ss << GetMangosString(LANG_LEARN); - if(known) - ss << GetMangosString(LANG_KNOWN); - if(active) - ss << GetMangosString(LANG_ACTIVE); - - SendSysMessage(ss.str().c_str()); - - ++counter; - } - } - } - if (counter == 0) // if counter == 0 then we found nth - SendSysMessage(LANG_COMMAND_NOSPELLFOUND); - return true; -} - -bool ChatHandler::HandleLookupQuestCommand(const char* args) -{ - Player* target = getSelectedPlayer(); - if( !target ) - { - SendSysMessage(LANG_PLAYER_NOT_FOUND); - SetSentErrorMessage(true); - return false; - } - - if(!*args) - return false; - - std::string namepart = args; - std::wstring wnamepart; - - // converting string that we try to find to lower case - if(!Utf8toWStr(namepart,wnamepart)) - return false; - - wstrToLower(wnamepart); - - uint32 counter = 0 ; - - ObjectMgr::QuestMap const& qTemplates = objmgr.GetQuestTemplates(); - for (ObjectMgr::QuestMap::const_iterator iter = qTemplates.begin(); iter != qTemplates.end(); ++iter) - { - Quest * qinfo = iter->second; - - int loc_idx = m_session->GetSessionDbLocaleIndex(); - if ( loc_idx >= 0 ) - { - QuestLocale const *il = objmgr.GetQuestLocale(qinfo->GetQuestId()); - if (il) - { - if (il->Title.size() > loc_idx && !il->Title[loc_idx].empty()) - { - std::string title = il->Title[loc_idx]; - - if (Utf8FitTo(title, wnamepart)) - { - QuestStatus status = target->GetQuestStatus(qinfo->GetQuestId()); - - char const* statusStr = ""; - if(status == QUEST_STATUS_COMPLETE) - { - if(target->GetQuestRewardStatus(qinfo->GetQuestId())) - statusStr = GetMangosString(LANG_COMMAND_QUEST_REWARDED); - else - statusStr = GetMangosString(LANG_COMMAND_QUEST_COMPLETE); - } - else if(status == QUEST_STATUS_INCOMPLETE) - statusStr = GetMangosString(LANG_COMMAND_QUEST_ACTIVE); - - PSendSysMessage(LANG_QUEST_LIST,qinfo->GetQuestId(),qinfo->GetQuestId(),title.c_str(),(status == QUEST_STATUS_COMPLETE ? GetMangosString(LANG_COMPLETE) : (status == QUEST_STATUS_INCOMPLETE ? GetMangosString(LANG_ACTIVE) : "") )); - ++counter; - continue; - } - } - } - } - - std::string title = qinfo->GetTitle(); - if(title.empty()) - continue; - - if (Utf8FitTo(title, wnamepart)) - { - QuestStatus status = target->GetQuestStatus(qinfo->GetQuestId()); - - char const* statusStr = ""; - if(status == QUEST_STATUS_COMPLETE) - { - if(target->GetQuestRewardStatus(qinfo->GetQuestId())) - statusStr = GetMangosString(LANG_COMMAND_QUEST_REWARDED); - else - statusStr = GetMangosString(LANG_COMMAND_QUEST_COMPLETE); - } - else if(status == QUEST_STATUS_INCOMPLETE) - statusStr = GetMangosString(LANG_COMMAND_QUEST_ACTIVE); - - PSendSysMessage(LANG_QUEST_LIST,qinfo->GetQuestId(),qinfo->GetQuestId(), title.c_str(),(status == QUEST_STATUS_COMPLETE ? GetMangosString(LANG_COMPLETE) : (status == QUEST_STATUS_INCOMPLETE ? GetMangosString(LANG_ACTIVE) : "") )); - ++counter; - } - } - - if (counter==0) - SendSysMessage(LANG_COMMAND_NOQUESTFOUND); - - return true; -} - -bool ChatHandler::HandleLookupCreatureCommand(const char* args) -{ - if(!*args) - return false; - - std::string namepart = args; - std::wstring wnamepart; - - // converting string that we try to find to lower case - if(!Utf8toWStr(namepart,wnamepart)) - return false; - - wstrToLower(wnamepart); - - uint32 counter = 0; - - for (uint32 id = 0; id< sCreatureStorage.MaxEntry; id++ ) - { - CreatureInfo const* cInfo = sCreatureStorage.LookupEntry(id); - if(!cInfo) - continue; - - int loc_idx = m_session->GetSessionDbLocaleIndex(); - if ( loc_idx >= 0 ) - { - CreatureLocale const *cl = objmgr.GetCreatureLocale(id); - if (cl) - { - if (cl->Name.size() > loc_idx && !cl->Name[loc_idx].empty()) - { - std::string name = cl->Name[loc_idx]; - - if (Utf8FitTo(name, wnamepart)) - { - PSendSysMessage(LANG_CREATURE_ENTRY_LIST, id, id, name.c_str()); - ++counter; - continue; - } - } - } - } - - std::string name = cInfo->Name; - if(name.empty()) - continue; - - if (Utf8FitTo(name, wnamepart)) - { - PSendSysMessage(LANG_CREATURE_ENTRY_LIST,id,id,name.c_str()); - ++counter; - } - } - - if (counter==0) - SendSysMessage(LANG_COMMAND_NOCREATUREFOUND); - - return true; -} - -bool ChatHandler::HandleLookupObjectCommand(const char* args) -{ - if(!*args) - return false; - - std::string namepart = args; - std::wstring wnamepart; - - // converting string that we try to find to lower case - if(!Utf8toWStr(namepart,wnamepart)) - return false; - - wstrToLower(wnamepart); - - uint32 counter = 0; - - for (uint32 id = 0; id< sGOStorage.MaxEntry; id++ ) - { - GameObjectInfo const* gInfo = sGOStorage.LookupEntry(id); - if(!gInfo) - continue; - - int loc_idx = m_session->GetSessionDbLocaleIndex(); - if ( loc_idx >= 0 ) - { - GameObjectLocale const *gl = objmgr.GetGameObjectLocale(id); - if (gl) - { - if (gl->Name.size() > loc_idx && !gl->Name[loc_idx].empty()) - { - std::string name = gl->Name[loc_idx]; - - if (Utf8FitTo(name, wnamepart)) - { - PSendSysMessage(LANG_GO_ENTRY_LIST, id, id, name.c_str()); - ++counter; - continue; - } - } - } - } - - std::string name = gInfo->name; - if(name.empty()) - continue; - - if(Utf8FitTo(name, wnamepart)) - { - PSendSysMessage(LANG_GO_ENTRY_LIST, id, id, name.c_str()); - ++counter; - } - } - - if(counter==0) - SendSysMessage(LANG_COMMAND_NOGAMEOBJECTFOUND); - - return true; -} - -/** \brief GM command level 3 - Create a guild. - * - * This command allows a GM (level 3) to create a guild. - * - * The "args" parameter contains the name of the guild leader - * and then the name of the guild. - * - */ -bool ChatHandler::HandleGuildCreateCommand(const char* args) -{ - - if (!*args) - return false; - - Guild *guild; - Player * player; - char *lname,*gname; - std::string guildname; - - lname = strtok((char*)args, " "); - gname = strtok(NULL, ""); - - if(!lname) - return false; - else if(!gname) - { - SendSysMessage(LANG_INSERT_GUILD_NAME); - SetSentErrorMessage(true); - return false; - } - - guildname = gname; - player = ObjectAccessor::Instance().FindPlayerByName(lname); - - if(!player) - { - SendSysMessage(LANG_PLAYER_NOT_FOUND); - SetSentErrorMessage(true); - return false; - } - - if(!player->GetGuildId()) - { - guild = new Guild; - if(!guild->create(player->GetGUID(),guildname)) - { - delete guild; - SendSysMessage(LANG_GUILD_NOT_CREATED); - SetSentErrorMessage(true); - return false; - } - - objmgr.AddGuild(guild); - } - else - SendSysMessage(LANG_PLAYER_IN_GUILD); - - return true; -} - -bool ChatHandler::HandleGuildInviteCommand(const char *args) -{ - if(!*args) - return false; - - char* par1 = strtok((char*)args, " "); - char* par2 = strtok (NULL, ""); - if(!par1 || !par2) - return false; - - std::string glName = par2; - Guild* targetGuild = objmgr.GetGuildByName(glName); - if(!targetGuild) - return false; - - std::string plName = par1; - if(!normalizePlayerName(plName)) - { - SendSysMessage(LANG_PLAYER_NOT_FOUND); - SetSentErrorMessage(true); - return false; - } - - uint64 plGuid = 0; - if(Player* targetPlayer = ObjectAccessor::Instance().FindPlayerByName(plName.c_str())) - plGuid = targetPlayer->GetGUID(); - else - plGuid = objmgr.GetPlayerGUIDByName(plName.c_str()); - - if(!plGuid) - false; - - // players's guild membership checked in AddMember before add - if(!targetGuild->AddMember(plGuid,targetGuild->GetLowestRank())) - return false; - - return true; -} - -bool ChatHandler::HandleGuildUninviteCommand(const char *args) -{ - if(!*args) - return false; - - char* par1 = strtok((char*)args, " "); - if(!par1) - return false; - std::string plName = par1; - if(!normalizePlayerName(plName)) - { - SendSysMessage(LANG_PLAYER_NOT_FOUND); - SetSentErrorMessage(true); - return false; - } - - uint64 plGuid = 0; - uint32 glId = 0; - if(Player* targetPlayer = ObjectAccessor::Instance().FindPlayerByName(plName.c_str())) - { - plGuid = targetPlayer->GetGUID(); - glId = targetPlayer->GetGuildId(); - } - else - { - plGuid = objmgr.GetPlayerGUIDByName(plName.c_str()); - glId = Player::GetGuildIdFromDB(plGuid); - } - - if(!plGuid || !glId) - return false; - - Guild* targetGuild = objmgr.GetGuildById(glId); - if(!targetGuild) - return false; - - targetGuild->DelMember(plGuid); - - return true; -} - -bool ChatHandler::HandleGuildRankCommand(const char *args) -{ - if(!*args) - return false; - - char* par1 = strtok((char*)args, " "); - char* par2 = strtok(NULL, " "); - if(!par1 || !par2) - return false; - std::string plName = par1; - if(!normalizePlayerName(plName)) - { - SendSysMessage(LANG_PLAYER_NOT_FOUND); - SetSentErrorMessage(true); - return false; - } - - uint64 plGuid = 0; - uint32 glId = 0; - if(Player* targetPlayer = ObjectAccessor::Instance().FindPlayerByName(plName.c_str())) - { - plGuid = targetPlayer->GetGUID(); - glId = targetPlayer->GetGuildId(); - } - else - { - plGuid = objmgr.GetPlayerGUIDByName(plName.c_str()); - glId = Player::GetGuildIdFromDB(plGuid); - } - - if(!plGuid || !glId) - return false; - - Guild* targetGuild = objmgr.GetGuildById(glId); - if(!targetGuild) - return false; - - uint32 newrank = uint32(atoi(par2)); - if(newrank > targetGuild->GetLowestRank()) - return false; - - targetGuild->ChangeRank(plGuid,newrank); - - return true; -} - -bool ChatHandler::HandleGuildDeleteCommand(const char* args) -{ - if(!*args) - return false; - - char* par1 = strtok((char*)args, " "); - if(!par1) - return false; - - std::string gld = par1; - - Guild* targetGuild = objmgr.GetGuildByName(gld); - if(!targetGuild) - return false; - - targetGuild->Disband(); - - return true; -} - -bool ChatHandler::HandleGetDistanceCommand(const char* /*args*/) -{ - Unit* pUnit = getSelectedUnit(); - - if(!pUnit) - { - SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE); - SetSentErrorMessage(true); - return false; - } - - PSendSysMessage(LANG_DISTANCE, m_session->GetPlayer()->GetDistance(pUnit),m_session->GetPlayer()->GetDistance2d(pUnit)); - - return true; -} - -// FIX-ME!!! - -bool ChatHandler::HandleAddWeaponCommand(const char* /*args*/) -{ - /*if (!*args) - return false; - - uint64 guid = m_session->GetPlayer()->GetSelection(); - if (guid == 0) - { - SendSysMessage(LANG_NO_SELECTION); - return true; - } - - Creature *pCreature = ObjectAccessor::GetCreature(*m_session->GetPlayer(), guid); - - if(!pCreature) - { - SendSysMessage(LANG_SELECT_CREATURE); - return true; - } - - char* pSlotID = strtok((char*)args, " "); - if (!pSlotID) - return false; - - char* pItemID = strtok(NULL, " "); - if (!pItemID) - return false; - - uint32 ItemID = atoi(pItemID); - uint32 SlotID = atoi(pSlotID); - - ItemPrototype* tmpItem = objmgr.GetItemPrototype(ItemID); - - bool added = false; - if(tmpItem) - { - switch(SlotID) - { - case 1: - pCreature->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_DISPLAY, ItemID); - added = true; - break; - case 2: - pCreature->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_DISPLAY_01, ItemID); - added = true; - break; - case 3: - pCreature->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_DISPLAY_02, ItemID); - added = true; - break; - default: - PSendSysMessage(LANG_ITEM_SLOT_NOT_EXIST,SlotID); - added = false; - break; - } - if(added) - { - PSendSysMessage(LANG_ITEM_ADDED_TO_SLOT,ItemID,tmpItem->Name1,SlotID); - } - } - else - { - PSendSysMessage(LANG_ITEM_NOT_FOUND,ItemID); - return true; - } - */ - return true; -} - -bool ChatHandler::HandleDieCommand(const char* /*args*/) -{ - Unit* target = getSelectedUnit(); - - if(!target || !m_session->GetPlayer()->GetSelection()) - { - SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE); - SetSentErrorMessage(true); - return false; - } - - if( target->isAlive() ) - { - m_session->GetPlayer()->DealDamage(target, target->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); - } - - return true; -} - -bool ChatHandler::HandleDamageCommand(const char * args) -{ - if (!*args) - return false; - - Unit* target = getSelectedUnit(); - - if(!target || !m_session->GetPlayer()->GetSelection()) - { - SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE); - SetSentErrorMessage(true); - return false; - } - - if( !target->isAlive() ) - return true; - - char* damageStr = strtok((char*)args, " "); - if(!damageStr) - return false; - - int32 damage = atoi((char*)damageStr); - if(damage <=0) - return true; - - char* schoolStr = strtok((char*)NULL, " "); - - // flat melee damage without resistence/etc reduction - if(!schoolStr) - { - m_session->GetPlayer()->DealDamage(target, damage, NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); - m_session->GetPlayer()->SendAttackStateUpdate (HITINFO_NORMALSWING2, target, 1, SPELL_SCHOOL_MASK_NORMAL, damage, 0, 0, VICTIMSTATE_NORMAL, 0); - return true; - } - - uint32 school = schoolStr ? atoi((char*)schoolStr) : SPELL_SCHOOL_NORMAL; - if(school >= MAX_SPELL_SCHOOL) - return false; - - SpellSchoolMask schoolmask = SpellSchoolMask(1 << school); - - if ( schoolmask & SPELL_SCHOOL_MASK_NORMAL ) - damage = m_session->GetPlayer()->CalcArmorReducedDamage(target, damage); - - char* spellStr = strtok((char*)NULL, " "); - - // melee damage by specific school - if(!spellStr) - { - uint32 absorb = 0; - uint32 resist = 0; - - m_session->GetPlayer()->CalcAbsorbResist(target,schoolmask, SPELL_DIRECT_DAMAGE, damage, &absorb, &resist); - - if (damage <= absorb + resist) - return true; - - damage -= absorb + resist; - - m_session->GetPlayer()->DealDamage(target, damage, NULL, DIRECT_DAMAGE, schoolmask, NULL, false); - m_session->GetPlayer()->SendAttackStateUpdate (HITINFO_NORMALSWING2, target, 1, schoolmask, damage, absorb, resist, VICTIMSTATE_NORMAL, 0); - return true; - } - - // non-melee damage - - // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form - uint32 spellid = extractSpellIdFromLink((char*)args); - if(!spellid || !sSpellStore.LookupEntry(spellid)) - return false; - - m_session->GetPlayer()->SpellNonMeleeDamageLog(target, spellid, damage, false); - return true; -} - -bool ChatHandler::HandleModifyArenaCommand(const char * args) -{ - if (!*args) - return false; - - Player *target = getSelectedPlayer(); - if(!target) - { - SendSysMessage(LANG_PLAYER_NOT_FOUND); - SetSentErrorMessage(true); - return false; - } - - int32 amount = (uint32)atoi(args); - - target->ModifyArenaPoints(amount); - - PSendSysMessage(LANG_COMMAND_MODIFY_ARENA, target->GetName(), target->GetArenaPoints()); - - return true; -} - -bool ChatHandler::HandleReviveCommand(const char* args) -{ - Player* SelectedPlayer = NULL; - - if (*args) - { - std::string name = args; - if(!normalizePlayerName(name)) - { - SendSysMessage(LANG_PLAYER_NOT_FOUND); - SetSentErrorMessage(true); - return false; - } - - SelectedPlayer = objmgr.GetPlayer(name.c_str()); - } - else - SelectedPlayer = getSelectedPlayer(); - - if(!SelectedPlayer) - { - SendSysMessage(LANG_NO_CHAR_SELECTED); - SetSentErrorMessage(true); - return false; - } - - SelectedPlayer->ResurrectPlayer(0.5f); - SelectedPlayer->SpawnCorpseBones(); - SelectedPlayer->SaveToDB(); - return true; -} - -bool ChatHandler::HandleAuraCommand(const char* args) -{ - char* px = strtok((char*)args, " "); - if (!px) - return false; - - Unit *target = getSelectedUnit(); - if(!target) - { - SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE); - SetSentErrorMessage(true); - return false; - } - - uint32 spellID = (uint32)atoi(px); - SpellEntry const *spellInfo = sSpellStore.LookupEntry( spellID ); - if(spellInfo) - { - for(uint32 i = 0;i<3;i++) - { - uint8 eff = spellInfo->Effect[i]; - if (eff>=TOTAL_SPELL_EFFECTS) - continue; - if( IsAreaAuraEffect(eff) || - eff == SPELL_EFFECT_APPLY_AURA || - eff == SPELL_EFFECT_PERSISTENT_AREA_AURA ) - { - Aura *Aur = CreateAura(spellInfo, i, NULL, target); - target->AddAura(Aur); - } - } - } - - return true; -} - -bool ChatHandler::HandleUnAuraCommand(const char* args) -{ - char* px = strtok((char*)args, " "); - if (!px) - return false; - - Unit *target = getSelectedUnit(); - if(!target) - { - SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE); - SetSentErrorMessage(true); - return false; - } - - std::string argstr = args; - if (argstr == "all") - { - target->RemoveAllAuras(); - return true; - } - - uint32 spellID = (uint32)atoi(px); - target->RemoveAurasDueToSpell(spellID); - - return true; -} - -bool ChatHandler::HandleLinkGraveCommand(const char* args) -{ - if(!*args) - return false; - - char* px = strtok((char*)args, " "); - if (!px) - return false; - - uint32 g_id = (uint32)atoi(px); - - uint32 g_team; - - char* px2 = strtok(NULL, " "); - - if (!px2) - g_team = 0; - else if (strncmp(px2,"horde",6)==0) - g_team = HORDE; - else if (strncmp(px2,"alliance",9)==0) - g_team = ALLIANCE; - else - return false; - - WorldSafeLocsEntry const* graveyard = sWorldSafeLocsStore.LookupEntry(g_id); - - if(!graveyard ) - { - PSendSysMessage(LANG_COMMAND_GRAVEYARDNOEXIST, g_id); - SetSentErrorMessage(true); - return false; - } - - Player* player = m_session->GetPlayer(); - - uint32 zoneId = player->GetZoneId(); - - AreaTableEntry const *areaEntry = GetAreaEntryByAreaID(zoneId); - if(!areaEntry || areaEntry->zone !=0 ) - { - PSendSysMessage(LANG_COMMAND_GRAVEYARDWRONGZONE, g_id,zoneId); - SetSentErrorMessage(true); - return false; - } - - if(graveyard->map_id != areaEntry->mapid && g_team != 0) - { - SendSysMessage(LANG_COMMAND_GRAVEYARDWRONGTEAM); - SetSentErrorMessage(true); - return false; - } - - if(objmgr.AddGraveYardLink(g_id,player->GetZoneId(),g_team)) - PSendSysMessage(LANG_COMMAND_GRAVEYARDLINKED, g_id,zoneId); - else - PSendSysMessage(LANG_COMMAND_GRAVEYARDALRLINKED, g_id,zoneId); - - return true; -} - -bool ChatHandler::HandleNearGraveCommand(const char* args) -{ - uint32 g_team; - - size_t argslen = strlen(args); - - if(!*args) - g_team = 0; - else if (strncmp((char*)args,"horde",argslen)==0) - g_team = HORDE; - else if (strncmp((char*)args,"alliance",argslen)==0) - g_team = ALLIANCE; - else - return false; - - Player* player = m_session->GetPlayer(); - - WorldSafeLocsEntry const* graveyard = objmgr.GetClosestGraveYard( - player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(),player->GetMapId(),g_team); - - if(graveyard) - { - uint32 g_id = graveyard->ID; - - GraveYardData const* data = objmgr.FindGraveYardData(g_id,player->GetZoneId()); - if (!data) - { - PSendSysMessage(LANG_COMMAND_GRAVEYARDERROR,g_id); - SetSentErrorMessage(true); - return false; - } - - g_team = data->team; - - std::string team_name = GetMangosString(LANG_COMMAND_GRAVEYARD_NOTEAM); - - if(g_team == 0) - team_name = GetMangosString(LANG_COMMAND_GRAVEYARD_ANY); - else if(g_team == HORDE) - team_name = GetMangosString(LANG_COMMAND_GRAVEYARD_HORDE); - else if(g_team == ALLIANCE) - team_name = GetMangosString(LANG_COMMAND_GRAVEYARD_ALLIANCE); - - PSendSysMessage(LANG_COMMAND_GRAVEYARDNEAREST, g_id,team_name.c_str(),player->GetZoneId()); - } - else - { - std::string team_name; - - if(g_team == 0) - team_name = GetMangosString(LANG_COMMAND_GRAVEYARD_ANY); - else if(g_team == HORDE) - team_name = GetMangosString(LANG_COMMAND_GRAVEYARD_HORDE); - else if(g_team == ALLIANCE) - team_name = GetMangosString(LANG_COMMAND_GRAVEYARD_ALLIANCE); - - if(g_team == ~uint32(0)) - PSendSysMessage(LANG_COMMAND_ZONENOGRAVEYARDS, player->GetZoneId()); - else - PSendSysMessage(LANG_COMMAND_ZONENOGRAFACTION, player->GetZoneId(),team_name.c_str()); - } - - return true; -} - -bool ChatHandler::HandleSpawnTransportCommand(const char* /*args*/) -{ - return true; -} - -//play npc emote -bool ChatHandler::HandlePlayEmoteCommand(const char* args) -{ - uint32 emote = atoi((char*)args); - - Creature* target = getSelectedCreature(); - if(!target) - { - SendSysMessage(LANG_SELECT_CREATURE); - SetSentErrorMessage(true); - return false; - } - - target->SetUInt32Value(UNIT_NPC_EMOTESTATE,emote); - - return true; -} - -bool ChatHandler::HandleNpcInfoCommand(const char* /*args*/) -{ - Creature* target = getSelectedCreature(); - - if(!target) - { - SendSysMessage(LANG_SELECT_CREATURE); - SetSentErrorMessage(true); - return false; - } - - uint32 faction = target->getFaction(); - uint32 npcflags = target->GetUInt32Value(UNIT_NPC_FLAGS); - uint32 displayid = target->GetDisplayId(); - uint32 nativeid = target->GetNativeDisplayId(); - uint32 Entry = target->GetEntry(); - CreatureInfo const* cInfo = target->GetCreatureInfo(); - - int32 curRespawnDelay = target->GetRespawnTimeEx()-time(NULL); - if(curRespawnDelay < 0) - curRespawnDelay = 0; - std::string curRespawnDelayStr = secsToTimeString(curRespawnDelay,true); - std::string defRespawnDelayStr = secsToTimeString(target->GetRespawnDelay(),true); - - PSendSysMessage(LANG_NPCINFO_CHAR, target->GetDBTableGUIDLow(), faction, npcflags, Entry, displayid, nativeid); - PSendSysMessage(LANG_NPCINFO_LEVEL, target->getLevel()); - PSendSysMessage(LANG_NPCINFO_HEALTH,target->GetCreateHealth(), target->GetMaxHealth(), target->GetHealth()); - PSendSysMessage(LANG_NPCINFO_FLAGS, target->GetUInt32Value(UNIT_FIELD_FLAGS), target->GetUInt32Value(UNIT_DYNAMIC_FLAGS), target->getFaction()); - PSendSysMessage(LANG_COMMAND_RAWPAWNTIMES, defRespawnDelayStr.c_str(),curRespawnDelayStr.c_str()); - PSendSysMessage(LANG_NPCINFO_LOOT, cInfo->lootid,cInfo->pickpocketLootId,cInfo->SkinLootId); - PSendSysMessage(LANG_NPCINFO_DUNGEON_ID, target->GetInstanceId()); - PSendSysMessage(LANG_NPCINFO_POSITION,float(target->GetPositionX()), float(target->GetPositionY()), float(target->GetPositionZ())); - - if ((npcflags & UNIT_NPC_FLAG_VENDOR) ) - { - SendSysMessage(LANG_NPCINFO_VENDOR); - } - if ((npcflags & UNIT_NPC_FLAG_TRAINER) ) - { - SendSysMessage(LANG_NPCINFO_TRAINER); - } - - return true; -} - -bool ChatHandler::HandleExploreCheatCommand(const char* args) -{ - if (!*args) - return false; - - int flag = atoi((char*)args); - - Player *chr = getSelectedPlayer(); - if (chr == NULL) - { - SendSysMessage(LANG_NO_CHAR_SELECTED); - SetSentErrorMessage(true); - return false; - } - - if (flag != 0) - { - PSendSysMessage(LANG_YOU_SET_EXPLORE_ALL, chr->GetName()); - if(chr!=m_session->GetPlayer()) - ChatHandler(chr).PSendSysMessage(LANG_YOURS_EXPLORE_SET_ALL,m_session->GetPlayer()->GetName()); - } - else - { - PSendSysMessage(LANG_YOU_SET_EXPLORE_NOTHING, chr->GetName()); - if(chr!=m_session->GetPlayer()) - ChatHandler(chr).PSendSysMessage(LANG_YOURS_EXPLORE_SET_NOTHING,m_session->GetPlayer()->GetName()); - } - - for (uint8 i=0; i<128; i++) - { - if (flag != 0) - { - m_session->GetPlayer()->SetFlag(PLAYER_EXPLORED_ZONES_1+i,0xFFFFFFFF); - } - else - { - m_session->GetPlayer()->SetFlag(PLAYER_EXPLORED_ZONES_1+i,0); - } - } - - return true; -} - -bool ChatHandler::HandleHoverCommand(const char* args) -{ - char* px = strtok((char*)args, " "); - uint32 flag; - if (!px) - flag = 1; - else - flag = atoi(px); - - m_session->GetPlayer()->SetHover(flag); - - if (flag) - SendSysMessage(LANG_HOVER_ENABLED); - else - SendSysMessage(LANG_HOVER_DISABLED); - - return true; -} - -bool ChatHandler::HandleLevelUpCommand(const char* args) -{ - char* px = strtok((char*)args, " "); - char* py = strtok((char*)NULL, " "); - - // command format parsing - char* pname = (char*)NULL; - int addlevel = 1; - - if(px && py) // .levelup name level - { - addlevel = atoi(py); - pname = px; - } - else if(px && !py) // .levelup name OR .levelup level - { - if(isalpha(px[0])) // .levelup name - pname = px; - else // .levelup level - addlevel = atoi(px); - } - // else .levelup - nothing do for prepering - - // player - Player *chr = NULL; - uint64 chr_guid = 0; - - std::string name; - - if(pname) // player by name - { - name = pname; - if(!normalizePlayerName(name)) - { - SendSysMessage(LANG_PLAYER_NOT_FOUND); - SetSentErrorMessage(true); - return false; - } - - chr = objmgr.GetPlayer(name.c_str()); - if(!chr) // not in game - { - chr_guid = objmgr.GetPlayerGUIDByName(name); - if (chr_guid == 0) - { - SendSysMessage(LANG_PLAYER_NOT_FOUND); - SetSentErrorMessage(true); - return false; - } - } - } - else // player by selection - { - chr = getSelectedPlayer(); - - if (chr == NULL) - { - SendSysMessage(LANG_NO_CHAR_SELECTED); - SetSentErrorMessage(true); - return false; - } - - name = chr->GetName(); - } - - assert(chr || chr_guid); - - int32 oldlevel = chr ? chr->getLevel() : Player::GetUInt32ValueFromDB(UNIT_FIELD_LEVEL,chr_guid); - int32 newlevel = oldlevel + addlevel; - if(newlevel < 1) - newlevel = 1; - if(newlevel > 255) // hardcoded maximum level - newlevel = 255; - - if(chr) - { - chr->GiveLevel(newlevel); - chr->InitTalentForLevel(); - chr->SetUInt32Value(PLAYER_XP,0); - - if(oldlevel == newlevel) - ChatHandler(chr).SendSysMessage(LANG_YOURS_LEVEL_PROGRESS_RESET); - else - if(oldlevel < newlevel) - ChatHandler(chr).PSendSysMessage(LANG_YOURS_LEVEL_UP,newlevel-oldlevel); - else - if(oldlevel > newlevel) - ChatHandler(chr).PSendSysMessage(LANG_YOURS_LEVEL_DOWN,newlevel-oldlevel); - } - else - { - // update levle and XP at level, all other will be updated at loading - Tokens values; - Player::LoadValuesArrayFromDB(values,chr_guid); - Player::SetUInt32ValueInArray(values,UNIT_FIELD_LEVEL,newlevel); - Player::SetUInt32ValueInArray(values,PLAYER_XP,0); - Player::SaveValuesArrayInDB(values,chr_guid); - } - - if(m_session->GetPlayer() != chr) // including chr==NULL - PSendSysMessage(LANG_YOU_CHANGE_LVL,name.c_str(),newlevel); - return true; -} - -bool ChatHandler::HandleShowAreaCommand(const char* args) -{ - if (!*args) - return false; - - int area = atoi((char*)args); - - Player *chr = getSelectedPlayer(); - if (chr == NULL) - { - SendSysMessage(LANG_NO_CHAR_SELECTED); - SetSentErrorMessage(true); - return false; - } - - int offset = area / 32; - uint32 val = (uint32)(1 << (area % 32)); - - if(offset >= 128) - { - SendSysMessage(LANG_BAD_VALUE); - SetSentErrorMessage(true); - return false; - } - - uint32 currFields = chr->GetUInt32Value(PLAYER_EXPLORED_ZONES_1 + offset); - chr->SetUInt32Value(PLAYER_EXPLORED_ZONES_1 + offset, (uint32)(currFields | val)); - - SendSysMessage(LANG_EXPLORE_AREA); - return true; -} - -bool ChatHandler::HandleHideAreaCommand(const char* args) -{ - if (!*args) - return false; - - int area = atoi((char*)args); - - Player *chr = getSelectedPlayer(); - if (chr == NULL) - { - SendSysMessage(LANG_NO_CHAR_SELECTED); - SetSentErrorMessage(true); - return false; - } - - int offset = area / 32; - uint32 val = (uint32)(1 << (area % 32)); - - if(offset >= 128) - { - SendSysMessage(LANG_BAD_VALUE); - SetSentErrorMessage(true); - return false; - } - - uint32 currFields = chr->GetUInt32Value(PLAYER_EXPLORED_ZONES_1 + offset); - chr->SetUInt32Value(PLAYER_EXPLORED_ZONES_1 + offset, (uint32)(currFields ^ val)); - - SendSysMessage(LANG_UNEXPLORE_AREA); - return true; -} - -bool ChatHandler::HandleUpdate(const char* args) -{ - if(!*args) - return false; - - uint32 updateIndex; - uint32 value; - - char* pUpdateIndex = strtok((char*)args, " "); - - Unit* chr = getSelectedUnit(); - if (chr == NULL) - { - SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE); - SetSentErrorMessage(true); - return false; - } - - if(!pUpdateIndex) - { - return true; - } - updateIndex = atoi(pUpdateIndex); - //check updateIndex - if(chr->GetTypeId() == TYPEID_PLAYER) - { - if (updateIndex>=PLAYER_END) return true; - } - else - { - if (updateIndex>=UNIT_END) return true; - } - - char* pvalue = strtok(NULL, " "); - if (!pvalue) - { - value=chr->GetUInt32Value(updateIndex); - - PSendSysMessage(LANG_UPDATE, chr->GetGUIDLow(),updateIndex,value); - return true; - } - - value=atoi(pvalue); - - PSendSysMessage(LANG_UPDATE_CHANGE, chr->GetGUIDLow(),updateIndex,value); - - chr->SetUInt32Value(updateIndex,value); - - return true; -} - -bool ChatHandler::HandleBankCommand(const char* /*args*/) -{ - m_session->SendShowBank( m_session->GetPlayer()->GetGUID() ); - - return true; -} - -bool ChatHandler::HandleChangeWeather(const char* args) -{ - if(!*args) - return false; - - //Weather is OFF - if (!sWorld.getConfig(CONFIG_WEATHER)) - { - SendSysMessage(LANG_WEATHER_DISABLED); - SetSentErrorMessage(true); - return false; - } - - //*Change the weather of a cell - char* px = strtok((char*)args, " "); - char* py = strtok(NULL, " "); - - if (!px || !py) - return false; - - uint32 type = (uint32)atoi(px); //0 to 3, 0: fine, 1: rain, 2: snow, 3: sand - float grade = (float)atof(py); //0 to 1, sending -1 is instand good weather - - Player *player = m_session->GetPlayer(); - uint32 zoneid = player->GetZoneId(); - - Weather* wth = sWorld.FindWeather(zoneid); - - if(!wth) - wth = sWorld.AddWeather(zoneid); - if(!wth) - { - SendSysMessage(LANG_NO_WEATHER); - SetSentErrorMessage(true); - return false; - } - - wth->SetWeather(WeatherType(type), grade); - - return true; -} - -bool ChatHandler::HandleSetValue(const char* args) -{ - if(!*args) - return false; - - char* px = strtok((char*)args, " "); - char* py = strtok(NULL, " "); - char* pz = strtok(NULL, " "); - - if (!px || !py) - return false; - - Unit* target = getSelectedUnit(); - if(!target) - { - SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE); - SetSentErrorMessage(true); - return false; - } - - uint64 guid = target->GetGUID(); - - uint32 Opcode = (uint32)atoi(px); - if(Opcode >= target->GetValuesCount()) - { - PSendSysMessage(LANG_TOO_BIG_INDEX, Opcode, GUID_LOPART(guid), target->GetValuesCount()); - return false; - } - uint32 iValue; - float fValue; - bool isint32 = true; - if(pz) - isint32 = (bool)atoi(pz); - if(isint32) - { - iValue = (uint32)atoi(py); - sLog.outDebug(GetMangosString(LANG_SET_UINT), GUID_LOPART(guid), Opcode, iValue); - target->SetUInt32Value( Opcode , iValue ); - PSendSysMessage(LANG_SET_UINT_FIELD, GUID_LOPART(guid), Opcode,iValue); - } - else - { - fValue = (float)atof(py); - sLog.outDebug(GetMangosString(LANG_SET_FLOAT), GUID_LOPART(guid), Opcode, fValue); - target->SetFloatValue( Opcode , fValue ); - PSendSysMessage(LANG_SET_FLOAT_FIELD, GUID_LOPART(guid), Opcode,fValue); - } - - return true; -} - -bool ChatHandler::HandleGetValue(const char* args) -{ - if(!*args) - return false; - - char* px = strtok((char*)args, " "); - char* pz = strtok(NULL, " "); - - if (!px) - return false; - - Unit* target = getSelectedUnit(); - if(!target) - { - SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE); - SetSentErrorMessage(true); - return false; - } - - uint64 guid = target->GetGUID(); - - uint32 Opcode = (uint32)atoi(px); - if(Opcode >= target->GetValuesCount()) - { - PSendSysMessage(LANG_TOO_BIG_INDEX, Opcode, GUID_LOPART(guid), target->GetValuesCount()); - return false; - } - uint32 iValue; - float fValue; - bool isint32 = true; - if(pz) - isint32 = (bool)atoi(pz); - - if(isint32) - { - iValue = target->GetUInt32Value( Opcode ); - sLog.outDebug(GetMangosString(LANG_GET_UINT), GUID_LOPART(guid), Opcode, iValue); - PSendSysMessage(LANG_GET_UINT_FIELD, GUID_LOPART(guid), Opcode, iValue); - } - else - { - fValue = target->GetFloatValue( Opcode ); - sLog.outDebug(GetMangosString(LANG_GET_FLOAT), GUID_LOPART(guid), Opcode, fValue); - PSendSysMessage(LANG_GET_FLOAT_FIELD, GUID_LOPART(guid), Opcode, fValue); - } - - return true; -} - -bool ChatHandler::HandleSet32Bit(const char* args) -{ - if(!*args) - return false; - - char* px = strtok((char*)args, " "); - char* py = strtok(NULL, " "); - - if (!px || !py) - return false; - - uint32 Opcode = (uint32)atoi(px); - uint32 Value = (uint32)atoi(py); - if (Value > 32) //uint32 = 32 bits - return false; - - sLog.outDebug(GetMangosString(LANG_SET_32BIT), Opcode, Value); - - m_session->GetPlayer( )->SetUInt32Value( Opcode , 2^Value ); - - PSendSysMessage(LANG_SET_32BIT_FIELD, Opcode,1); - return true; -} - -bool ChatHandler::HandleMod32Value(const char* args) -{ - if(!*args) - return false; - - char* px = strtok((char*)args, " "); - char* py = strtok(NULL, " "); - - if (!px || !py) - return false; - - uint32 Opcode = (uint32)atoi(px); - int Value = atoi(py); - - if(Opcode >= m_session->GetPlayer()->GetValuesCount()) - { - PSendSysMessage(LANG_TOO_BIG_INDEX, Opcode, m_session->GetPlayer()->GetGUIDLow(), m_session->GetPlayer( )->GetValuesCount()); - return false; - } - - sLog.outDebug(GetMangosString(LANG_CHANGE_32BIT), Opcode, Value); - - int CurrentValue = (int)m_session->GetPlayer( )->GetUInt32Value( Opcode ); - - CurrentValue += Value; - m_session->GetPlayer( )->SetUInt32Value( Opcode , (uint32)CurrentValue ); - - PSendSysMessage(LANG_CHANGE_32BIT_FIELD, Opcode,CurrentValue); - - return true; -} - -bool ChatHandler::HandleAddTeleCommand(const char * args) -{ - if(!*args) - return false; - QueryResult *result; - Player *player=m_session->GetPlayer(); - if (!player) return false; - - std::string name = args; - WorldDatabase.escape_string(name); - result = WorldDatabase.PQuery("SELECT id FROM game_tele WHERE name = '%s'",name.c_str()); - if (result) - { - SendSysMessage(LANG_COMMAND_TP_ALREADYEXIST); - delete result; - SetSentErrorMessage(true); - return false; - } - - float x = player->GetPositionX(); - float y = player->GetPositionY(); - float z = player->GetPositionZ(); - float ort = player->GetOrientation(); - int mapid = player->GetMapId(); - - if(WorldDatabase.PExecuteLog("INSERT INTO game_tele (position_x,position_y,position_z,orientation,map,name) VALUES (%f,%f,%f,%f,%d,'%s')",x,y,z,ort,mapid,name.c_str())) - { - SendSysMessage(LANG_COMMAND_TP_ADDED); - } - else - { - SendSysMessage(LANG_COMMAND_TP_ADDEDERR); - SetSentErrorMessage(true); - return false; - } - - return true; -} - -bool ChatHandler::HandleDelTeleCommand(const char * args) -{ - if(!*args) - return false; - - std::string name = args; - WorldDatabase.escape_string(name); - - QueryResult *result=WorldDatabase.PQuery("SELECT id FROM game_tele WHERE name = '%s'",name.c_str()); - if (!result) - { - SendSysMessage(LANG_COMMAND_TELE_NOTFOUND); - SetSentErrorMessage(true); - return false; - } - delete result; - - if(WorldDatabase.PExecuteLog("DELETE FROM game_tele WHERE name = '%s'",name.c_str())) - { - SendSysMessage(LANG_COMMAND_TP_DELETED); - } - else - { - SendSysMessage(LANG_COMMAND_TP_DELETEERR); - SetSentErrorMessage(true); - return false; - } - return true; -} - -bool ChatHandler::HandleListAurasCommand (const char * /*args*/) -{ - Unit *unit = getSelectedUnit(); - if(!unit) - { - SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE); - SetSentErrorMessage(true); - return false; - } - - char const* talentStr = GetMangosString(LANG_TALENT); - char const* passiveStr = GetMangosString(LANG_PASSIVE); - - Unit::AuraMap const& uAuras = unit->GetAuras(); - PSendSysMessage(LANG_COMMAND_TARGET_LISTAURAS, uAuras.size()); - for (Unit::AuraMap::const_iterator itr = uAuras.begin(); itr != uAuras.end(); ++itr) - { - bool talent = GetTalentSpellCost(itr->second->GetId()) > 0; - PSendSysMessage(LANG_COMMAND_TARGET_AURADETAIL, itr->second->GetId(), itr->second->GetEffIndex(), - itr->second->GetModifier()->m_auraname, itr->second->GetAuraDuration(), itr->second->GetAuraMaxDuration(), - itr->second->GetSpellProto()->SpellName[m_session->GetSessionDbcLocale()], - (itr->second->IsPassive() ? passiveStr : ""),(talent ? talentStr : ""), - IS_PLAYER_GUID(itr->second->GetCasterGUID()) ? "player" : "creature",GUID_LOPART(itr->second->GetCasterGUID())); - } - for (int i = 0; i < TOTAL_AURAS; i++) - { - Unit::AuraList const& uAuraList = unit->GetAurasByType(AuraType(i)); - if (uAuraList.empty()) continue; - PSendSysMessage(LANG_COMMAND_TARGET_LISTAURATYPE, uAuraList.size(), i); - for (Unit::AuraList::const_iterator itr = uAuraList.begin(); itr != uAuraList.end(); ++itr) - { - bool talent = GetTalentSpellCost((*itr)->GetId()) > 0; - PSendSysMessage(LANG_COMMAND_TARGET_AURASIMPLE, (*itr)->GetId(), (*itr)->GetEffIndex(), - (*itr)->GetSpellProto()->SpellName[m_session->GetSessionDbcLocale()],((*itr)->IsPassive() ? passiveStr : ""),(talent ? talentStr : ""), - IS_PLAYER_GUID((*itr)->GetCasterGUID()) ? "player" : "creature",GUID_LOPART((*itr)->GetCasterGUID())); - } - } - return true; -} - -bool ChatHandler::HandleResetHonorCommand (const char * args) -{ - char* pName = strtok((char*)args, ""); - Player *player = NULL; - if (pName) - { - std::string name = pName; - if(!normalizePlayerName(name)) - { - SendSysMessage(LANG_PLAYER_NOT_FOUND); - SetSentErrorMessage(true); - return false; - } - - uint64 guid = objmgr.GetPlayerGUIDByName(name.c_str()); - player = objmgr.GetPlayer(guid); - } - else - player = getSelectedPlayer(); - - if(!player) - { - SendSysMessage(LANG_NO_CHAR_SELECTED); - return true; - } - - player->SetUInt32Value(PLAYER_FIELD_KILLS, 0); - player->SetUInt32Value(PLAYER_FIELD_LIFETIME_HONORBALE_KILLS, 0); - player->SetUInt32Value(PLAYER_FIELD_HONOR_CURRENCY, 0); - player->SetUInt32Value(PLAYER_FIELD_TODAY_CONTRIBUTION, 0); - player->SetUInt32Value(PLAYER_FIELD_YESTERDAY_CONTRIBUTION, 0); - - return true; -} - -static bool HandleResetStatsOrLevelHelper(Player* player) -{ - PlayerInfo const *info = objmgr.GetPlayerInfo(player->getRace(), player->getClass()); - if(!info) return false; - - ChrClassesEntry const* cEntry = sChrClassesStore.LookupEntry(player->getClass()); - if(!cEntry) - { - sLog.outError("Class %u not found in DBC (Wrong DBC files?)",player->getClass()); - return false; - } - - uint8 powertype = cEntry->powerType; - - uint32 unitfield; - if(powertype == POWER_RAGE) - unitfield = 0x1100EE00; - else if(powertype == POWER_ENERGY) - unitfield = 0x00000000; - else if(powertype == POWER_MANA) - unitfield = 0x0000EE00; - else - { - sLog.outError("Invalid default powertype %u for player (class %u)",powertype,player->getClass()); - return false; - } - - // reset m_form if no aura - if(!player->HasAuraType(SPELL_AURA_MOD_SHAPESHIFT)) - player->m_form = FORM_NONE; - - player->SetFloatValue(UNIT_FIELD_BOUNDINGRADIUS, DEFAULT_WORLD_OBJECT_SIZE ); - player->SetFloatValue(UNIT_FIELD_COMBATREACH, 1.5f ); - - player->setFactionForRace(player->getRace()); - - player->SetUInt32Value(UNIT_FIELD_BYTES_0, ( ( player->getRace() ) | ( player->getClass() << 8 ) | ( player->getGender() << 16 ) | ( powertype << 24 ) ) ); - - // reset only if player not in some form; - if(player->m_form==FORM_NONE) - { - switch(player->getGender()) - { - case GENDER_FEMALE: - player->SetDisplayId(info->displayId_f); - player->SetNativeDisplayId(info->displayId_f); - break; - case GENDER_MALE: - player->SetDisplayId(info->displayId_m); - player->SetNativeDisplayId(info->displayId_m); - break; - default: - break; - } - } - - // set UNIT_FIELD_BYTES_1 to init state but preserve m_form value - player->SetUInt32Value(UNIT_FIELD_BYTES_1, unitfield); - player->SetByteValue(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_UNK3 | UNIT_BYTE2_FLAG_UNK5 ); - player->SetByteValue(UNIT_FIELD_BYTES_2, 3, player->m_form); - - player->SetUInt32Value(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE); - - //-1 is default value - player->SetUInt32Value(PLAYER_FIELD_WATCHED_FACTION_INDEX, uint32(-1)); - - //player->SetUInt32Value(PLAYER_FIELD_BYTES, 0xEEE00000 ); - return true; -} - -bool ChatHandler::HandleResetLevelCommand(const char * args) -{ - char* pName = strtok((char*)args, ""); - Player *player = NULL; - if (pName) - { - std::string name = pName; - if(!normalizePlayerName(name)) - { - SendSysMessage(LANG_PLAYER_NOT_FOUND); - SetSentErrorMessage(true); - return false; - } - - uint64 guid = objmgr.GetPlayerGUIDByName(name.c_str()); - player = objmgr.GetPlayer(guid); - } - else - player = getSelectedPlayer(); - - if(!player) - { - SendSysMessage(LANG_NO_CHAR_SELECTED); - SetSentErrorMessage(true); - return false; - } - - if(!HandleResetStatsOrLevelHelper(player)) - return false; - - player->SetLevel(1); - player->InitStatsForLevel(true); - player->InitTaxiNodesForLevel(); - player->InitTalentForLevel(); - player->SetUInt32Value(PLAYER_XP,0); - - // reset level to summoned pet - Pet* pet = player->GetPet(); - if(pet && pet->getPetType()==SUMMON_PET) - pet->InitStatsForLevel(1); - - return true; -} - -bool ChatHandler::HandleResetStatsCommand(const char * args) -{ - char* pName = strtok((char*)args, ""); - Player *player = NULL; - if (pName) - { - std::string name = pName; - if(!normalizePlayerName(name)) - { - SendSysMessage(LANG_PLAYER_NOT_FOUND); - SetSentErrorMessage(true); - return false; - } - - uint64 guid = objmgr.GetPlayerGUIDByName(name.c_str()); - player = objmgr.GetPlayer(guid); - } - else - player = getSelectedPlayer(); - - if(!player) - { - SendSysMessage(LANG_NO_CHAR_SELECTED); - SetSentErrorMessage(true); - return false; - } - - if(!HandleResetStatsOrLevelHelper(player)) - return false; - - player->InitStatsForLevel(true); - player->InitTaxiNodesForLevel(); - player->InitTalentForLevel(); - - return true; -} - -bool ChatHandler::HandleResetSpellsCommand(const char * args) -{ - char* pName = strtok((char*)args, ""); - Player *player = NULL; - uint64 playerGUID = 0; - if (pName) - { - std::string name = pName; - - if(!normalizePlayerName(name)) - { - SendSysMessage(LANG_PLAYER_NOT_FOUND); - SetSentErrorMessage(true); - return false; - } - - player = objmgr.GetPlayer(name.c_str()); - if(!player) - playerGUID = objmgr.GetPlayerGUIDByName(name.c_str()); - } - else - player = getSelectedPlayer(); - - if(!player && !playerGUID) - { - SendSysMessage(LANG_NO_CHAR_SELECTED); - SetSentErrorMessage(true); - return false; - } - - if(player) - { - player->resetSpells(); - - ChatHandler(player).SendSysMessage(LANG_RESET_SPELLS); - - if(m_session->GetPlayer()!=player) - PSendSysMessage(LANG_RESET_SPELLS_ONLINE,player->GetName()); - } - else - { - CharacterDatabase.PExecute("UPDATE characters SET at_login = at_login | '%u' WHERE guid = '%u'",uint32(AT_LOGIN_RESET_SPELLS), GUID_LOPART(playerGUID)); - PSendSysMessage(LANG_RESET_SPELLS_OFFLINE,pName); - } - - return true; -} - -bool ChatHandler::HandleResetTalentsCommand(const char * args) -{ - char* pName = strtok((char*)args, ""); - Player *player = NULL; - uint64 playerGUID = 0; - if (pName) - { - std::string name = pName; - if(!normalizePlayerName(name)) - { - SendSysMessage(LANG_PLAYER_NOT_FOUND); - SetSentErrorMessage(true); - return false; - } - - player = objmgr.GetPlayer(name.c_str()); - if(!player) - playerGUID = objmgr.GetPlayerGUIDByName(name.c_str()); - } - else - player = getSelectedPlayer(); - - if(!player && !playerGUID) - { - SendSysMessage(LANG_NO_CHAR_SELECTED); - SetSentErrorMessage(true); - return false; - } - - if(player) - { - player->resetTalents(true); - - ChatHandler(player).SendSysMessage(LANG_RESET_TALENTS); - - if(m_session->GetPlayer()!=player) - PSendSysMessage(LANG_RESET_TALENTS_ONLINE,player->GetName()); - } - else - { - CharacterDatabase.PExecute("UPDATE characters SET at_login = at_login | '%u' WHERE guid = '%u'",uint32(AT_LOGIN_RESET_TALENTS), GUID_LOPART(playerGUID) ); - PSendSysMessage(LANG_RESET_TALENTS_OFFLINE,pName); - } - - return true; -} - -bool ChatHandler::HandleResetAllCommand(const char * args) -{ - if(!*args) - return false; - - std::string casename = args; - - AtLoginFlags atLogin; - - // Command specially created as single command to prevent using short case names - if(casename=="spells") - { - atLogin = AT_LOGIN_RESET_SPELLS; - sWorld.SendWorldText(LANG_RESETALL_SPELLS); - } - else if(casename=="talents") - { - atLogin = AT_LOGIN_RESET_TALENTS; - sWorld.SendWorldText(LANG_RESETALL_TALENTS); - } - else - { - PSendSysMessage(LANG_RESETALL_UNKNOWN_CASE,args); - SetSentErrorMessage(true); - return false; - } - - CharacterDatabase.PExecute("UPDATE characters SET at_login = at_login | '%u'",atLogin); - HashMapHolder::MapType const& plist = ObjectAccessor::Instance().GetPlayers(); - for(HashMapHolder::MapType::const_iterator itr = plist.begin(); itr != plist.end(); ++itr) - itr->second->SetAtLoginFlag(atLogin); - - return true; -} - -bool ChatHandler::HandleShutDownCommand(const char* args) -{ - if(!*args) - return false; - - if(std::string(args)=="cancel") - { - sWorld.ShutdownCancel(); - } - else - { - int32 time = atoi(args); - - ///- Prevent interpret wrong arg value as 0 secs shutdown time - if(time == 0 && (args[0]!='0' || args[1]!='\0') || time < 0) - return false; - - sWorld.ShutdownServ(time); - } - return true; -} - -bool ChatHandler::HandleRestartCommand(const char* args) -{ - if(!*args) - return false; - - if(std::string(args)=="cancel") - { - sWorld.ShutdownCancel(); - } - else - { - int32 time = atoi(args); - - ///- Prevent interpret wrong arg value as 0 secs shutdown time - if(time == 0 && (args[0]!='0' || args[1]!='\0') || time < 0) - return false; - - sWorld.ShutdownServ(time, SHUTDOWN_MASK_RESTART); - } - return true; -} - -bool ChatHandler::HandleIdleRestartCommand(const char* args) -{ - if(!*args) - return false; - - if(std::string(args)=="cancel") - { - sWorld.ShutdownCancel(); - } - else - { - int32 time = atoi(args); - - ///- Prevent interpret wrong arg value as 0 secs shutdown time - if(time == 0 && (args[0]!='0' || args[1]!='\0') || time < 0) - return false; - - sWorld.ShutdownServ(time,SHUTDOWN_MASK_RESTART+SHUTDOWN_MASK_IDLE); - } - return true; -} - -bool ChatHandler::HandleIdleShutDownCommand(const char* args) -{ - if(!*args) - return false; - - if(std::string(args)=="cancel") - { - sWorld.ShutdownCancel(); - } - else - { - int32 time = atoi(args); - - ///- Prevent interpret wrong arg value as 0 secs shutdown time - if(time == 0 && (args[0]!='0' || args[1]!='\0') || time < 0) - return false; - - sWorld.ShutdownServ(time,SHUTDOWN_MASK_IDLE); - } - return true; -} - -bool ChatHandler::HandleAddQuest(const char* args) -{ - Player* player = getSelectedPlayer(); - if(!player) - { - SendSysMessage(LANG_NO_CHAR_SELECTED); - SetSentErrorMessage(true); - return false; - } - - // .addquest #entry' - // number or [name] Shift-click form |color|Hquest:quest_id|h[name]|h|r - char* cId = extractKeyFromLink((char*)args,"Hquest"); - if(!cId) - return false; - - uint32 entry = atol(cId); - - Quest const* pQuest = objmgr.GetQuestTemplate(entry); - - if(!pQuest) - { - PSendSysMessage(LANG_COMMAND_QUEST_NOTFOUND,entry); - SetSentErrorMessage(true); - return false; - } - - // check item starting quest (it can work incorrectly if added without item in inventory) - QueryResult *result = WorldDatabase.PQuery("SELECT entry FROM item_template WHERE startquest = '%u' LIMIT 1",entry); - if(result) - { - Field* fields = result->Fetch(); - uint32 item_id = fields[0].GetUInt32(); - delete result; - - PSendSysMessage(LANG_COMMAND_QUEST_STARTFROMITEM, entry,item_id); - SetSentErrorMessage(true); - return false; - } - - // ok, normal (creature/GO starting) quest - if( player->CanAddQuest( pQuest, true ) ) - { - player->AddQuest( pQuest, NULL ); - - if ( player->CanCompleteQuest( entry ) ) - player->CompleteQuest( entry ); - } - - return true; -} - -bool ChatHandler::HandleRemoveQuest(const char* args) -{ - Player* player = getSelectedPlayer(); - if(!player) - { - SendSysMessage(LANG_NO_CHAR_SELECTED); - SetSentErrorMessage(true); - return false; - } - - // .removequest #entry' - // number or [name] Shift-click form |color|Hquest:quest_id|h[name]|h|r - char* cId = extractKeyFromLink((char*)args,"Hquest"); - if(!cId) - return false; - - uint32 entry = atol(cId); - - Quest const* pQuest = objmgr.GetQuestTemplate(entry); - - if(!pQuest) - { - PSendSysMessage(LANG_COMMAND_QUEST_NOTFOUND, entry); - SetSentErrorMessage(true); - return false; - } - - // remove all quest entries for 'entry' from quest log - for(uint8 slot = 0; slot < MAX_QUEST_LOG_SIZE; ++slot ) - { - uint32 quest = player->GetQuestSlotQuestId(slot); - if(quest==entry) - { - player->SetQuestSlot(slot,0); - - // we ignore unequippable quest items in this case, its' still be equipped - player->TakeQuestSourceItem( quest, false ); - } - } - - // set quest status to not started (will updated in DB at next save) - player->SetQuestStatus( entry, QUEST_STATUS_NONE); - - // reset rewarded for restart repeatable quest - player->getQuestStatusMap()[entry].m_rewarded = false; - - SendSysMessage(LANG_COMMAND_QUEST_REMOVED); - return true; -} - -bool ChatHandler::HandleCompleteQuest(const char* args) -{ - Player* player = getSelectedPlayer(); - if(!player) - { - SendSysMessage(LANG_NO_CHAR_SELECTED); - SetSentErrorMessage(true); - return false; - } - - // .quest complete #entry - // number or [name] Shift-click form |color|Hquest:quest_id|h[name]|h|r - char* cId = extractKeyFromLink((char*)args,"Hquest"); - if(!cId) - return false; - - uint32 entry = atol(cId); - - Quest const* pQuest = objmgr.GetQuestTemplate(entry); - - // If player doesn't have the quest - if(!pQuest || player->GetQuestStatus(entry) == QUEST_STATUS_NONE) - { - PSendSysMessage(LANG_COMMAND_QUEST_NOTFOUND, entry); - SetSentErrorMessage(true); - return false; - } - - // Add quest items for quests that require items - for(uint8 x = 0; x < QUEST_OBJECTIVES_COUNT; ++x) - { - uint32 id = pQuest->ReqItemId[x]; - uint32 count = pQuest->ReqItemCount[x]; - if(!id || !count) - continue; - - uint32 curItemCount = player->GetItemCount(id,true); - - ItemPosCountVec dest; - uint8 msg = player->CanStoreNewItem( NULL_BAG, NULL_SLOT, dest, id, count-curItemCount ); - if( msg == EQUIP_ERR_OK ) - { - Item* item = player->StoreNewItem( dest, id, true); - player->SendNewItem(item,count-curItemCount,true,false); - } - } - - // All creature/GO slain/casted (not required, but otherwise it will display "Creature slain 0/10") - for(uint8 i = 0; i < QUEST_OBJECTIVES_COUNT; i++) - { - uint32 creature = pQuest->ReqCreatureOrGOId[i]; - uint32 creaturecount = pQuest->ReqCreatureOrGOCount[i]; - - if(uint32 spell_id = pQuest->ReqSpell[i]) - { - for(uint16 z = 0; z < creaturecount; ++z) - player->CastedCreatureOrGO(creature,0,spell_id); - } - else if(creature > 0) - { - for(uint16 z = 0; z < creaturecount; ++z) - player->KilledMonster(creature,0); - } - else if(creature < 0) - { - for(uint16 z = 0; z < creaturecount; ++z) - player->CastedCreatureOrGO(creature,0,0); - } - } - - // If the quest requires reputation to complete - if(uint32 repFaction = pQuest->GetRepObjectiveFaction()) - { - uint32 repValue = pQuest->GetRepObjectiveValue(); - uint32 curRep = player->GetReputation(repFaction); - if(curRep < repValue) - { - FactionEntry const *factionEntry = sFactionStore.LookupEntry(repFaction); - player->SetFactionReputation(factionEntry,repValue); - } - } - - // If the quest requires money - int32 ReqOrRewMoney = pQuest->GetRewOrReqMoney(); - if(ReqOrRewMoney < 0) - player->ModifyMoney(-ReqOrRewMoney); - - player->CompleteQuest(entry); - return true; -} - -bool ChatHandler::HandleBanCommand(const char* args) -{ - if(!args) - return false; - - char* type = strtok((char*)args, " "); - - if(!type) - return false; - char* nameOrIP = strtok(NULL, " "); - - if(!nameOrIP) - return false; - - char* duration = strtok(NULL," "); - if(!duration || !atoi(duration)) - return false; - - char* reason = strtok(NULL,""); - if(!reason) - return false; - - switch(sWorld.BanAccount(type, nameOrIP, duration, reason,m_session->GetPlayerName())) - { - case BAN_SUCCESS: - if(atoi(duration)>0) - PSendSysMessage(LANG_BAN_YOUBANNED,nameOrIP,secsToTimeString(TimeStringToSecs(duration),true).c_str(),reason); - else - PSendSysMessage(LANG_BAN_YOUPERMBANNED,nameOrIP,reason); - break; - case BAN_SYNTAX_ERROR: - return false; - case BAN_NOTFOUND: - PSendSysMessage(LANG_BAN_NOTFOUND,type,nameOrIP); - break; - } - - return true; -} - -bool ChatHandler::HandleUnBanCommand(const char* args) -{ - if(!args) - return false; - char* type = strtok((char*)args, " "); - if(!type) - return false; - char* nameOrIP = strtok(NULL, " "); - - if(!nameOrIP) - return false; - - if(sWorld.RemoveBanAccount(type,nameOrIP)) - PSendSysMessage(LANG_UNBAN_UNBANNED,nameOrIP); - else - PSendSysMessage(LANG_UNBAN_ERROR,nameOrIP); - - return true; -} - -bool ChatHandler::HandleBanInfoCommand(const char* args) -{ - if(!args) - return false; - - char* cType = strtok((char*)args, " "); - char* cnameOrIP = strtok(NULL, ""); - if(!cType || !cnameOrIP) - return false; - - std::string nameOrIP = cnameOrIP; - std::string type = cType; - if (!IsIPAddress(cnameOrIP) && type=="ip") - return false; - - Field *fields; - if(type != "ip") - { - //look the accountid up - uint32 accountid; - std::string accountname; - if(type == "account") - { - loginDatabase.escape_string(nameOrIP); - QueryResult *result = loginDatabase.PQuery("SELECT id, username FROM account WHERE username = '%s'",nameOrIP.c_str()); - if (!result) - { - PSendSysMessage(LANG_BANINFO_NOACCOUNT); - return true; - } - fields = result->Fetch(); - accountid = fields[0].GetUInt32(); - accountname = fields[1].GetCppString(); - delete result; - } - else if(type == "character") - { - if(!normalizePlayerName(nameOrIP)) - { - SendSysMessage(LANG_PLAYER_NOT_FOUND); - SetSentErrorMessage(true); - return false; - } - - loginDatabase.escape_string(nameOrIP); - QueryResult *result = CharacterDatabase.PQuery("SELECT account FROM characters WHERE name = '%s'", nameOrIP.c_str()); - if (!result) - { - PSendSysMessage(LANG_BANINFO_NOCHARACTER); - return true; - } - fields = result->Fetch(); - accountid = fields[0].GetUInt32(); - delete result; - result = loginDatabase.PQuery("SELECT username FROM account WHERE id = '%u'", accountid); - if (!result) - { - PSendSysMessage(LANG_BANINFO_NOCHARACTER); - return true; - } - fields = result->Fetch(); - accountname = fields[0].GetCppString(); - delete result; - } - else - return false; - - QueryResult *result = loginDatabase.PQuery("SELECT FROM_UNIXTIME(bandate), unbandate-bandate, active, unbandate,banreason,bannedby FROM account_banned WHERE id = '%u' ORDER BY bandate ASC",accountid); - if(!result) - { - PSendSysMessage(LANG_BANINFO_NOACCOUNTBAN, accountname.c_str()); - return true; - } - - PSendSysMessage(LANG_BANINFO_BANHISTORY,accountname.c_str()); - do - { - fields = result->Fetch(); - - time_t unbandate = time_t(fields[3].GetUInt64()); - bool active = false; - if(fields[2].GetBool() && (fields[1].GetUInt64() == (uint64)0 ||unbandate >= time(NULL)) ) - active = true; - bool permanent = (fields[1].GetUInt64() == (uint64)0); - std::string bantime = permanent?GetMangosString(LANG_BANINFO_INFINITE):secsToTimeString(fields[1].GetUInt64(), true); - PSendSysMessage(LANG_BANINFO_HISTORYENTRY, - fields[0].GetString(), bantime.c_str(), active ? GetMangosString(LANG_BANINFO_YES):GetMangosString(LANG_BANINFO_NO), fields[4].GetString(), fields[5].GetString()); - }while (result->NextRow()); - - delete result; - } - else - { - loginDatabase.escape_string(nameOrIP); - QueryResult *result = loginDatabase.PQuery("SELECT ip, FROM_UNIXTIME(bandate), FROM_UNIXTIME(unbandate), unbandate-UNIX_TIMESTAMP(), banreason,bannedby,unbandate-bandate FROM ip_banned WHERE ip = '%s'",nameOrIP.c_str()); - if(!result) - { - PSendSysMessage(LANG_BANINFO_NOIP); - return true; - } - fields = result->Fetch(); - bool permanent = (fields[6].GetUInt64()==(uint64)0); - PSendSysMessage(LANG_BANINFO_IPENTRY, - fields[0].GetString(), fields[1].GetString(), permanent ? GetMangosString(LANG_BANINFO_NEVER):fields[2].GetString(), - permanent ? GetMangosString(LANG_BANINFO_INFINITE):secsToTimeString(fields[3].GetUInt64(), true).c_str(), fields[4].GetString(), fields[5].GetString()); - delete result; - } - return true; -} - -bool ChatHandler::HandleBanListCommand(const char* args) -{ - loginDatabase.Execute("DELETE FROM ip_banned WHERE unbandate<=UNIX_TIMESTAMP() AND unbandate<>bandate"); - if(!*args) - return false; - char* cType = strtok((char*)args, " "); - char* cFilter = strtok(NULL, ""); - if(!cType || !cFilter) - return false; - std::string Filter = cFilter; - std::string Type = cType; - loginDatabase.escape_string(Filter); - - QueryResult* result = NULL; - Field *fields = NULL; - if(Type == "ip") - { - result = loginDatabase.PQuery("SELECT ip FROM ip_banned WHERE ip "_LIKE_" '""%%%s%%""'",Filter.c_str()); - if(!result) - { - PSendSysMessage(LANG_BANLIST_NOIP); - return true; - } - PSendSysMessage(LANG_BANLIST_MATCHINGIP); - do - { - fields = result->Fetch(); - PSendSysMessage("%s",fields[0].GetString()); - } while (result->NextRow()); - - delete result; - return true; - } - //lookup accountid - if(Type == "account") - { - result = loginDatabase.PQuery("SELECT id FROM account WHERE username "_LIKE_" '""%%%s%%""' ",Filter.c_str()); - if (!result) - { - PSendSysMessage(LANG_BANLIST_NOACCOUNT); - return true; - } - //do not delete result - } - else if(Type == "characters") - { - result = CharacterDatabase.PQuery("SELECT account FROM characters, WHERE name "_LIKE_" '""%%%s%%""' ",Filter.c_str()); - if (!result) - { - PSendSysMessage(LANG_BANLIST_NOCHARACTER); - return true; - } - } - else - return false; - - PSendSysMessage(LANG_BANLIST_MATCHINGACCOUNT); - do - { - fields = result->Fetch(); - uint32 accountid = fields[0].GetUInt32(); - QueryResult* banresult = loginDatabase.PQuery("SELECT account.username FROM account,account_banned WHERE account_banned.id='%u' AND account_banned.active = '1' AND account_banned.id=account.id",accountid); - if(banresult) - { - Field* fields2 = banresult->Fetch(); - PSendSysMessage("%s",fields2[0].GetString()); - delete banresult; - } - } while (result->NextRow()); - - delete result; - return true; -} - -bool ChatHandler::HandleRespawnCommand(const char* /*args*/) -{ - Player* pl = m_session->GetPlayer(); - - CellPair p(MaNGOS::ComputeCellPair(pl->GetPositionX(), pl->GetPositionY())); - Cell cell(p); - cell.data.Part.reserved = ALL_DISTRICT; - cell.SetNoCreate(); - - MaNGOS::RespawnDo u_do; - MaNGOS::WorldObjectWorker worker(u_do); - - TypeContainerVisitor, GridTypeMapContainer > obj_worker(worker); - CellLock cell_lock(cell, p); - cell_lock->Visit(cell_lock, obj_worker, *MapManager::Instance().GetMap(pl->GetMapId(), pl)); - - return true; -} - -bool ChatHandler::HandleFlyModeCommand(const char* args) -{ - if(!args) - return false; - - Unit *unit = getSelectedUnit(); - if (!unit || (unit->GetTypeId() != TYPEID_PLAYER)) - unit = m_session->GetPlayer(); - - WorldPacket data(12); - if (strncmp(args, "on", 3) == 0) - data.SetOpcode(SMSG_MOVE_SET_CAN_FLY); - else if (strncmp(args, "off", 4) == 0) - data.SetOpcode(SMSG_MOVE_UNSET_CAN_FLY); - else - { - SendSysMessage(LANG_USE_BOL); - return false; - } - data.append(unit->GetPackGUID()); - data << uint32(0); // unknown - unit->SendMessageToSet(&data, true); - PSendSysMessage(LANG_COMMAND_FLYMODE_STATUS, unit->GetName(), args); - return true; -} - -bool ChatHandler::HandleLoadPDumpCommand(const char *args) -{ - if(!args) - return false; - - char * file = strtok((char*)args, " "); if(!file) return false; - char * acc = strtok(NULL, " "); if(!acc) return false; - if(!file || !acc) - return false; - - uint32 account_id = objmgr.GetAccountByAccountName(acc); - if(!account_id) - { - account_id = atoi(acc); - if(account_id) - { - std::string acc_name; - if(!objmgr.GetAccountNameByAccount(account_id,acc_name)) - return false; - } - else - return false; - } - - char * name = strtok(NULL, " "); - char * guid_str = name ? strtok(NULL, " ") : NULL; - - uint32 guid = guid_str ? atoi(guid_str) : 0; - - if(PlayerDumpReader().LoadDump(file, account_id, name ? name : "", guid)) - PSendSysMessage(LANG_COMMAND_IMPORT_SUCCESS); - else - PSendSysMessage(LANG_COMMAND_IMPORT_FAILED); - - return true; -} - -bool ChatHandler::HandleChangeEntryCommand(const char *args) -{ - if(!args) - return false; - - uint32 newEntryNum = atoi(args); - if(!newEntryNum) - return false; - - Unit* unit = getSelectedUnit(); - if(!unit || unit->GetTypeId() != TYPEID_UNIT) - { - SendSysMessage(LANG_SELECT_CREATURE); - SetSentErrorMessage(true); - return false; - } - Creature* creature = (Creature*)unit; - if(creature->UpdateEntry(newEntryNum)) - SendSysMessage(LANG_DONE); - else - SendSysMessage(LANG_ERROR); - return true; -} - -bool ChatHandler::HandleWritePDumpCommand(const char *args) -{ - if(!args) - return false; - - char* file = strtok((char*)args, " "); - char* p2 = strtok(NULL, " "); - - if(!file || !p2) - return false; - - uint32 guid = objmgr.GetPlayerGUIDByName(p2); - if(!guid) - guid = atoi(p2); - - if (PlayerDumpWriter().WriteDump(file, guid)) - PSendSysMessage(LANG_COMMAND_EXPORT_SUCCESS); - else - PSendSysMessage(LANG_COMMAND_EXPORT_FAILED); - - return true; -} - -bool ChatHandler::HandleMovegensCommand(const char* /*args*/) -{ - Unit* unit = getSelectedUnit(); - if(!unit) - { - SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE); - SetSentErrorMessage(true); - return false; - } - - PSendSysMessage(LANG_MOVEGENS_LIST,(unit->GetTypeId()==TYPEID_PLAYER ? "Player" : "Creature" ),unit->GetGUIDLow()); - - MotionMaster* mm = unit->GetMotionMaster(); - for(MotionMaster::const_iterator itr = mm->begin(); itr != mm->end(); ++itr) - { - switch((*itr)->GetMovementGeneratorType()) - { - case IDLE_MOTION_TYPE: SendSysMessage(LANG_MOVEGENS_IDLE); break; - case RANDOM_MOTION_TYPE: SendSysMessage(LANG_MOVEGENS_RANDOM); break; - case WAYPOINT_MOTION_TYPE: SendSysMessage(LANG_MOVEGENS_WAYPOINT); break; - case ANIMAL_RANDOM_MOTION_TYPE: SendSysMessage(LANG_MOVEGENS_ANIMAL_RANDOM); break; - case CONFUSED_MOTION_TYPE: SendSysMessage(LANG_MOVEGENS_CONFUSED); break; - case TARGETED_MOTION_TYPE: - { - if(unit->GetTypeId()==TYPEID_PLAYER) - { - TargetedMovementGenerator const* mgen = static_cast const*>(*itr); - Unit* target = mgen->GetTarget(); - if(target) - PSendSysMessage(LANG_MOVEGENS_TARGETED_PLAYER,target->GetName(),target->GetGUIDLow()); - else - SendSysMessage(LANG_MOVEGENS_TARGETED_NULL); - } - else - { - TargetedMovementGenerator const* mgen = static_cast const*>(*itr); - Unit* target = mgen->GetTarget(); - if(target) - PSendSysMessage(LANG_MOVEGENS_TARGETED_CREATURE,target->GetName(),target->GetGUIDLow()); - else - SendSysMessage(LANG_MOVEGENS_TARGETED_NULL); - } - break; - } - case HOME_MOTION_TYPE: - if(unit->GetTypeId()==TYPEID_UNIT) - { - float x,y,z; - (*itr)->GetDestination(x,y,z); - PSendSysMessage(LANG_MOVEGENS_HOME_CREATURE,x,y,z); - } - else - SendSysMessage(LANG_MOVEGENS_HOME_PLAYER); - break; - case FLIGHT_MOTION_TYPE: SendSysMessage(LANG_MOVEGENS_FLIGHT); break; - case POINT_MOTION_TYPE: - { - float x,y,z; - (*itr)->GetDestination(x,y,z); - PSendSysMessage(LANG_MOVEGENS_POINT,x,y,z); - break; - } - case FLEEING_MOTION_TYPE: SendSysMessage(LANG_MOVEGENS_FEAR); break; - case DISTRACT_MOTION_TYPE: SendSysMessage(LANG_MOVEGENS_DISTRACT); break; - default: - PSendSysMessage(LANG_MOVEGENS_UNKNOWN,(*itr)->GetMovementGeneratorType()); - break; - } - } - return true; -} - -bool ChatHandler::HandlePLimitCommand(const char *args) -{ - if(*args) - { - char* param = strtok((char*)args, " "); - if(!param) - return false; - - int l = strlen(param); - - if( strncmp(param,"player",l) == 0 ) - sWorld.SetPlayerLimit(-SEC_PLAYER); - else if(strncmp(param,"moderator",l) == 0 ) - sWorld.SetPlayerLimit(-SEC_MODERATOR); - else if(strncmp(param,"gamemaster",l) == 0 ) - sWorld.SetPlayerLimit(-SEC_GAMEMASTER); - else if(strncmp(param,"administrator",l) == 0 ) - sWorld.SetPlayerLimit(-SEC_ADMINISTRATOR); - else if(strncmp(param,"reset",l) == 0 ) - sWorld.SetPlayerLimit( sConfig.GetIntDefault("PlayerLimit", DEFAULT_PLAYER_LIMIT) ); - else - { - int val = atoi(param); - if(val < -SEC_ADMINISTRATOR) val = -SEC_ADMINISTRATOR; - - sWorld.SetPlayerLimit(val); - } - - // kick all low security level players - if(sWorld.GetPlayerAmountLimit() > SEC_PLAYER) - sWorld.KickAllLess(sWorld.GetPlayerSecurityLimit()); - } - - uint32 pLimit = sWorld.GetPlayerAmountLimit(); - AccountTypes allowedAccountType = sWorld.GetPlayerSecurityLimit(); - char const* secName = ""; - switch(allowedAccountType) - { - case SEC_PLAYER: secName = "Player"; break; - case SEC_MODERATOR: secName = "Moderator"; break; - case SEC_GAMEMASTER: secName = "Gamemaster"; break; - case SEC_ADMINISTRATOR: secName = "Administrator"; break; - default: secName = ""; break; - } - - PSendSysMessage("Player limits: amount %u, min. security level %s.",pLimit,secName); - - return true; -} - -bool ChatHandler::HandleCastCommand(const char* args) -{ - if(!*args) - return false; - - Unit* target = getSelectedUnit(); - - if(!target) - { - SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE); - SetSentErrorMessage(true); - return false; - } - - // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form - uint32 spell = extractSpellIdFromLink((char*)args); - if(!spell) - return false; - - SpellEntry const* spellInfo = sSpellStore.LookupEntry(spell); - if(!spellInfo) - return false; - - if(!SpellMgr::IsSpellValid(spellInfo,m_session->GetPlayer())) - { - PSendSysMessage(LANG_COMMAND_SPELL_BROKEN,spell); - SetSentErrorMessage(true); - return false; - } - - char* trig_str = strtok(NULL, " "); - if(trig_str) - { - int l = strlen(trig_str); - if(strncmp(trig_str,"triggered",l) != 0 ) - return false; - } - - bool triggered = (trig_str != NULL); - - m_session->GetPlayer()->CastSpell(target,spell,triggered); - - return true; -} - -bool ChatHandler::HandleCastBackCommand(const char* args) -{ - Creature* caster = getSelectedCreature(); - - if(!caster) - { - SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE); - SetSentErrorMessage(true); - return false; - } - - // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r - // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form - uint32 spell = extractSpellIdFromLink((char*)args); - if(!spell || !sSpellStore.LookupEntry(spell)) - return false; - - char* trig_str = strtok(NULL, " "); - if(trig_str) - { - int l = strlen(trig_str); - if(strncmp(trig_str,"triggered",l) != 0 ) - return false; - } - - bool triggered = (trig_str != NULL); - - // update orientation at server - caster->SetOrientation(caster->GetAngle(m_session->GetPlayer())); - - // and client - WorldPacket data; - caster->BuildHeartBeatMsg(&data); - caster->SendMessageToSet(&data,true); - - caster->CastSpell(m_session->GetPlayer(),spell,false); - - return true; -} - -bool ChatHandler::HandleCastDistCommand(const char* args) -{ - if(!*args) - return false; - - - // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form - uint32 spell = extractSpellIdFromLink((char*)args); - if(!spell) - return false; - - SpellEntry const* spellInfo = sSpellStore.LookupEntry(spell); - if(!spellInfo) - return false; - - if(!SpellMgr::IsSpellValid(spellInfo,m_session->GetPlayer())) - { - PSendSysMessage(LANG_COMMAND_SPELL_BROKEN,spell); - SetSentErrorMessage(true); - return false; - } - - char *distStr = strtok(NULL, " "); - - float dist = 0; - - if(distStr) - sscanf(distStr, "%f", &dist); - - char* trig_str = strtok(NULL, " "); - if(trig_str) - { - int l = strlen(trig_str); - if(strncmp(trig_str,"triggered",l) != 0 ) - return false; - } - - bool triggered = (trig_str != NULL); - - float x,y,z; - m_session->GetPlayer()->GetClosePoint(x,y,z,dist); - - m_session->GetPlayer()->CastSpell(x,y,z,spell,triggered); - return true; -} - -bool ChatHandler::HandleCastTargetCommand(const char* args) -{ - Creature* caster = getSelectedCreature(); - - if(!caster) - { - SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE); - SetSentErrorMessage(true); - return false; - } - - if(!caster->getVictim()) - { - SendSysMessage(LANG_SELECTED_TARGET_NOT_HAVE_VICTIM); - SetSentErrorMessage(true); - return false; - } - - // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form - uint32 spell = extractSpellIdFromLink((char*)args); - if(!spell || !sSpellStore.LookupEntry(spell)) - return false; - - char* trig_str = strtok(NULL, " "); - if(trig_str) - { - int l = strlen(trig_str); - if(strncmp(trig_str,"triggered",l) != 0 ) - return false; - } - - bool triggered = (trig_str != NULL); - - // update orientation at server - caster->SetOrientation(caster->GetAngle(m_session->GetPlayer())); - - // and client - WorldPacket data; - caster->BuildHeartBeatMsg(&data); - caster->SendMessageToSet(&data,true); - - caster->CastSpell(caster->getVictim(),spell,false); - - return true; -} - -/* -ComeToMe command REQUIRED for 3rd party scripting library to have access to PointMovementGenerator -Without this function 3rd party scripting library will get linking errors (unresolved external) -when attempting to use the PointMovementGenerator -*/ -bool ChatHandler::HandleComeToMeCommand(const char *args) -{ - Creature* caster = getSelectedCreature(); - - if(!caster) - { - SendSysMessage(LANG_SELECT_CREATURE); - SetSentErrorMessage(true); - return false; - } - - char* newFlagStr = strtok((char*)args, " "); - - if(!newFlagStr) - return false; - - uint32 newFlags = atoi(newFlagStr); - - caster->SetUnitMovementFlags(newFlags); - - Player* pl = m_session->GetPlayer(); - - caster->GetMotionMaster()->MovePoint(0, pl->GetPositionX(), pl->GetPositionY(), pl->GetPositionZ()); - return true; -} - -bool ChatHandler::HandleCastSelfCommand(const char* args) -{ - if(!*args) - return false; - - Unit* target = getSelectedUnit(); - - if(!target) - { - SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE); - SetSentErrorMessage(true); - return false; - } - - // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form - uint32 spell = extractSpellIdFromLink((char*)args); - if(!spell) - return false; - - SpellEntry const* spellInfo = sSpellStore.LookupEntry(spell); - if(!spellInfo) - return false; - - if(!SpellMgr::IsSpellValid(spellInfo,m_session->GetPlayer())) - { - PSendSysMessage(LANG_COMMAND_SPELL_BROKEN,spell); - SetSentErrorMessage(true); - return false; - } - - target->CastSpell(target,spell,false); - - return true; -} - -std::string GetTimeString(uint32 time) -{ - uint16 days = time / DAY, hours = (time % DAY) / HOUR, minute = (time % HOUR) / MINUTE; - std::ostringstream ss; - if(days) ss << days << "d "; - if(hours) ss << hours << "h "; - ss << minute << "m"; - return ss.str(); -} - -bool ChatHandler::HandleInstanceListBindsCommand(const char* /*args*/) -{ - Player* player = getSelectedPlayer(); - if (!player) player = m_session->GetPlayer(); - uint32 counter = 0; - for(uint8 i = 0; i < TOTAL_DIFFICULTIES; i++) - { - Player::BoundInstancesMap &binds = player->GetBoundInstances(i); - for(Player::BoundInstancesMap::iterator itr = binds.begin(); itr != binds.end(); ++itr) - { - InstanceSave *save = itr->second.save; - std::string timeleft = GetTimeString(save->GetResetTime() - time(NULL)); - PSendSysMessage("map: %d inst: %d perm: %s diff: %s canReset: %s TTR: %s", itr->first, save->GetInstanceId(), itr->second.perm ? "yes" : "no", save->GetDifficulty() == DIFFICULTY_NORMAL ? "normal" : "heroic", save->CanReset() ? "yes" : "no", timeleft.c_str()); - counter++; - } - } - PSendSysMessage("player binds: %d", counter); - counter = 0; - Group *group = player->GetGroup(); - if(group) - { - for(uint8 i = 0; i < TOTAL_DIFFICULTIES; i++) - { - Group::BoundInstancesMap &binds = group->GetBoundInstances(i); - for(Group::BoundInstancesMap::iterator itr = binds.begin(); itr != binds.end(); ++itr) - { - InstanceSave *save = itr->second.save; - std::string timeleft = GetTimeString(save->GetResetTime() - time(NULL)); - PSendSysMessage("map: %d inst: %d perm: %s diff: %s canReset: %s TTR: %s", itr->first, save->GetInstanceId(), itr->second.perm ? "yes" : "no", save->GetDifficulty() == DIFFICULTY_NORMAL ? "normal" : "heroic", save->CanReset() ? "yes" : "no", timeleft.c_str()); - counter++; - } - } - } - PSendSysMessage("group binds: %d", counter); - - return true; -} - -bool ChatHandler::HandleInstanceUnbindCommand(const char* args) -{ - if(!*args) - return false; - - std::string cmd = args; - if(cmd == "all") - { - Player* player = getSelectedPlayer(); - if (!player) player = m_session->GetPlayer(); - uint32 counter = 0; - for(uint8 i = 0; i < TOTAL_DIFFICULTIES; i++) - { - Player::BoundInstancesMap &binds = player->GetBoundInstances(i); - for(Player::BoundInstancesMap::iterator itr = binds.begin(); itr != binds.end();) - { - if(itr->first != player->GetMapId()) - { - InstanceSave *save = itr->second.save; - std::string timeleft = GetTimeString(save->GetResetTime() - time(NULL)); - PSendSysMessage("unbinding map: %d inst: %d perm: %s diff: %s canReset: %s TTR: %s", itr->first, save->GetInstanceId(), itr->second.perm ? "yes" : "no", save->GetDifficulty() == DIFFICULTY_NORMAL ? "normal" : "heroic", save->CanReset() ? "yes" : "no", timeleft.c_str()); - player->UnbindInstance(itr, i); - counter++; - } - else - ++itr; - } - } - PSendSysMessage("instances unbound: %d", counter); - } - return true; -} - -bool ChatHandler::HandleInstanceStatsCommand(const char* /*args*/) -{ - PSendSysMessage("instances loaded: %d", MapManager::Instance().GetNumInstances()); - PSendSysMessage("players in instances: %d", MapManager::Instance().GetNumPlayersInInstances()); - PSendSysMessage("instance saves: %d", sInstanceSaveManager.GetNumInstanceSaves()); - PSendSysMessage("players bound: %d", sInstanceSaveManager.GetNumBoundPlayersTotal()); - PSendSysMessage("groups bound: %d", sInstanceSaveManager.GetNumBoundGroupsTotal()); - return true; -} - -bool ChatHandler::HandleInstanceSaveDataCommand(const char * /*args*/) -{ - Player* pl = m_session->GetPlayer(); - - Map* map = pl->GetMap(); - if (!map->IsDungeon()) - { - PSendSysMessage("Map is not a dungeon."); - SetSentErrorMessage(true); - return false; - } - - if (!((InstanceMap*)map)->GetInstanceData()) - { - PSendSysMessage("Map has no instance data."); - SetSentErrorMessage(true); - return false; - } - - ((InstanceMap*)map)->GetInstanceData()->SaveToDB(); - return true; -} +/* + * Copyright (C) 2005-2008 MaNGOS + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "Common.h" +#include "Database/DatabaseEnv.h" +#include "WorldPacket.h" +#include "WorldSession.h" +#include "World.h" +#include "ObjectMgr.h" +#include "PlayerDump.h" +#include "SpellMgr.h" +#include "Player.h" +#include "Opcodes.h" +#include "GameObject.h" +#include "Chat.h" +#include "Log.h" +#include "Guild.h" +#include "ObjectAccessor.h" +#include "MapManager.h" +#include "SpellAuras.h" +#include "ScriptCalls.h" +#include "Language.h" +#include "GridNotifiersImpl.h" +#include "CellImpl.h" +#include "Weather.h" +#include "PointMovementGenerator.h" +#include "TargetedMovementGenerator.h" +#include "SkillDiscovery.h" +#include "SkillExtraItems.h" +#include "SystemConfig.h" +#include "Config/ConfigEnv.h" +#include "Util.h" +#include "ItemEnchantmentMgr.h" +#include "InstanceSaveMgr.h" +#include "InstanceData.h" + +//reload commands +bool ChatHandler::HandleReloadCommand(const char* arg) +{ + // this is error catcher for wrong table name in .reload commands + PSendSysMessage("Db table with name starting from '%s' not found and can't be reloaded.",arg); + SetSentErrorMessage(true); + return false; +} + +bool ChatHandler::HandleReloadAllCommand(const char*) +{ + HandleReloadAreaTriggerTeleportCommand(""); + HandleReloadSkillFishingBaseLevelCommand(""); + + HandleReloadAllAreaCommand(""); + HandleReloadAllLootCommand(""); + HandleReloadAllNpcCommand(""); + HandleReloadAllQuestCommand(""); + HandleReloadAllSpellCommand(""); + HandleReloadAllItemCommand(""); + + HandleReloadCommandCommand(""); + HandleReloadReservedNameCommand(""); + HandleReloadMangosStringCommand(""); + HandleReloadGameTeleCommand(""); + return true; +} + +bool ChatHandler::HandleReloadAllAreaCommand(const char*) +{ + //HandleReloadQuestAreaTriggersCommand(""); -- reloaded in HandleReloadAllQuestCommand + HandleReloadAreaTriggerTeleportCommand(""); + HandleReloadAreaTriggerTavernCommand(""); + HandleReloadGameGraveyardZoneCommand(""); + return true; +} + +bool ChatHandler::HandleReloadAllLootCommand(const char*) +{ + sLog.outString( "Re-Loading Loot Tables..." ); + LoadLootTables(); + SendGlobalSysMessage("DB tables `*_loot_template` reloaded."); + return true; +} + +bool ChatHandler::HandleReloadAllNpcCommand(const char* /*args*/) +{ + HandleReloadNpcGossipCommand("a"); + HandleReloadNpcTrainerCommand("a"); + HandleReloadNpcVendorCommand("a"); + return true; +} + +bool ChatHandler::HandleReloadAllQuestCommand(const char* /*args*/) +{ + HandleReloadQuestAreaTriggersCommand("a"); + HandleReloadQuestTemplateCommand("a"); + + sLog.outString( "Re-Loading Quests Relations..." ); + objmgr.LoadQuestRelations(); + SendGlobalSysMessage("DB tables `*_questrelation` and `*_involvedrelation` reloaded."); + return true; +} + +bool ChatHandler::HandleReloadAllScriptsCommand(const char*) +{ + if(sWorld.IsScriptScheduled()) + { + PSendSysMessage("DB scripts used currently, please attempt reload later."); + SetSentErrorMessage(true); + return false; + } + + sLog.outString( "Re-Loading Scripts..." ); + HandleReloadGameObjectScriptsCommand("a"); + HandleReloadEventScriptsCommand("a"); + HandleReloadQuestEndScriptsCommand("a"); + HandleReloadQuestStartScriptsCommand("a"); + HandleReloadSpellScriptsCommand("a"); + SendGlobalSysMessage("DB tables `*_scripts` reloaded."); + return true; +} + +bool ChatHandler::HandleReloadAllSpellCommand(const char*) +{ + HandleReloadSkillDiscoveryTemplateCommand("a"); + HandleReloadSkillExtraItemTemplateCommand("a"); + HandleReloadSpellAffectCommand("a"); + HandleReloadSpellChainCommand("a"); + HandleReloadSpellElixirCommand("a"); + HandleReloadSpellLearnSpellCommand("a"); + HandleReloadSpellProcEventCommand("a"); + HandleReloadSpellScriptTargetCommand("a"); + HandleReloadSpellTargetPositionCommand("a"); + HandleReloadSpellThreatsCommand("a"); + HandleReloadSpellPetAurasCommand("a"); + return true; +} + +bool ChatHandler::HandleReloadAllItemCommand(const char*) +{ + HandleReloadPageTextsCommand("a"); + HandleReloadItemEnchantementsCommand("a"); + return true; +} + +bool ChatHandler::HandleReloadConfigCommand(const char* arg) +{ + sLog.outString( "Re-Loading config settings..." ); + sWorld.LoadConfigSettings(true); + SendGlobalSysMessage("World config settings reloaded."); + return true; +} + +bool ChatHandler::HandleReloadAreaTriggerTavernCommand(const char*) +{ + sLog.outString( "Re-Loading Tavern Area Triggers..." ); + objmgr.LoadTavernAreaTriggers(); + SendGlobalSysMessage("DB table `areatrigger_tavern` reloaded."); + return true; +} + +bool ChatHandler::HandleReloadAreaTriggerTeleportCommand(const char*) +{ + sLog.outString( "Re-Loading AreaTrigger teleport definitions..." ); + objmgr.LoadAreaTriggerTeleports(); + SendGlobalSysMessage("DB table `areatrigger_teleport` reloaded."); + return true; +} + +bool ChatHandler::HandleReloadCommandCommand(const char*) +{ + load_command_table = true; + SendGlobalSysMessage("DB table `command` will be reloaded at next chat command use."); + return true; +} + +bool ChatHandler::HandleReloadCreatureQuestRelationsCommand(const char*) +{ + sLog.outString( "Loading Quests Relations... (`creature_questrelation`)" ); + objmgr.LoadCreatureQuestRelations(); + SendGlobalSysMessage("DB table `creature_questrelation` (creature quest givers) reloaded."); + return true; +} + +bool ChatHandler::HandleReloadCreatureQuestInvRelationsCommand(const char*) +{ + sLog.outString( "Loading Quests Relations... (`creature_involvedrelation`)" ); + objmgr.LoadCreatureInvolvedRelations(); + SendGlobalSysMessage("DB table `creature_involvedrelation` (creature quest takers) reloaded."); + return true; +} + +bool ChatHandler::HandleReloadGOQuestRelationsCommand(const char*) +{ + sLog.outString( "Loading Quests Relations... (`gameobject_questrelation`)" ); + objmgr.LoadGameobjectQuestRelations(); + SendGlobalSysMessage("DB table `gameobject_questrelation` (gameobject quest givers) reloaded."); + return true; +} + +bool ChatHandler::HandleReloadGOQuestInvRelationsCommand(const char*) +{ + sLog.outString( "Loading Quests Relations... (`gameobject_involvedrelation`)" ); + objmgr.LoadGameobjectInvolvedRelations(); + SendGlobalSysMessage("DB table `gameobject_involvedrelation` (gameobject quest takers) reloaded."); + return true; +} + +bool ChatHandler::HandleReloadQuestAreaTriggersCommand(const char*) +{ + sLog.outString( "Re-Loading Quest Area Triggers..." ); + objmgr.LoadQuestAreaTriggers(); + SendGlobalSysMessage("DB table `areatrigger_involvedrelation` (quest area triggers) reloaded."); + return true; +} + +bool ChatHandler::HandleReloadQuestTemplateCommand(const char*) +{ + sLog.outString( "Re-Loading Quest Templates..." ); + objmgr.LoadQuests(); + SendGlobalSysMessage("DB table `quest_template` (quest definitions) reloaded."); + return true; +} + +bool ChatHandler::HandleReloadLootTemplatesCreatureCommand(const char*) +{ + sLog.outString( "Re-Loading Loot Tables... (`creature_loot_template`)" ); + LoadLootTemplates_Creature(); + LootTemplates_Creature.CheckLootRefs(); + SendGlobalSysMessage("DB table `creature_loot_template` reloaded."); + return true; +} + +bool ChatHandler::HandleReloadLootTemplatesDisenchantCommand(const char*) +{ + sLog.outString( "Re-Loading Loot Tables... (`disenchant_loot_template`)" ); + LoadLootTemplates_Disenchant(); + LootTemplates_Disenchant.CheckLootRefs(); + SendGlobalSysMessage("DB table `disenchant_loot_template` reloaded."); + return true; +} + +bool ChatHandler::HandleReloadLootTemplatesFishingCommand(const char*) +{ + sLog.outString( "Re-Loading Loot Tables... (`fishing_loot_template`)" ); + LoadLootTemplates_Fishing(); + LootTemplates_Fishing.CheckLootRefs(); + SendGlobalSysMessage("DB table `fishing_loot_template` reloaded."); + return true; +} + +bool ChatHandler::HandleReloadLootTemplatesGameobjectCommand(const char*) +{ + sLog.outString( "Re-Loading Loot Tables... (`gameobject_loot_template`)" ); + LoadLootTemplates_Gameobject(); + LootTemplates_Gameobject.CheckLootRefs(); + SendGlobalSysMessage("DB table `gameobject_loot_template` reloaded."); + return true; +} + +bool ChatHandler::HandleReloadLootTemplatesItemCommand(const char*) +{ + sLog.outString( "Re-Loading Loot Tables... (`item_loot_template`)" ); + LoadLootTemplates_Item(); + LootTemplates_Item.CheckLootRefs(); + SendGlobalSysMessage("DB table `item_loot_template` reloaded."); + return true; +} + +bool ChatHandler::HandleReloadLootTemplatesPickpocketingCommand(const char*) +{ + sLog.outString( "Re-Loading Loot Tables... (`pickpocketing_loot_template`)" ); + LoadLootTemplates_Pickpocketing(); + LootTemplates_Pickpocketing.CheckLootRefs(); + SendGlobalSysMessage("DB table `pickpocketing_loot_template` reloaded."); + return true; +} + +bool ChatHandler::HandleReloadLootTemplatesProspectingCommand(const char*) +{ + sLog.outString( "Re-Loading Loot Tables... (`prospecting_loot_template`)" ); + LoadLootTemplates_Prospecting(); + LootTemplates_Prospecting.CheckLootRefs(); + SendGlobalSysMessage("DB table `prospecting_loot_template` reloaded."); + return true; +} + +bool ChatHandler::HandleReloadLootTemplatesQuestMailCommand(const char*) +{ + sLog.outString( "Re-Loading Loot Tables... (`quest_mail_loot_template`)" ); + LoadLootTemplates_QuestMail(); + LootTemplates_QuestMail.CheckLootRefs(); + SendGlobalSysMessage("DB table `quest_mail_loot_template` reloaded."); + return true; +} + +bool ChatHandler::HandleReloadLootTemplatesReferenceCommand(const char*) +{ + sLog.outString( "Re-Loading Loot Tables... (`reference_loot_template`)" ); + LoadLootTemplates_Reference(); + SendGlobalSysMessage("DB table `reference_loot_template` reloaded."); + return true; +} + +bool ChatHandler::HandleReloadLootTemplatesSkinningCommand(const char*) +{ + sLog.outString( "Re-Loading Loot Tables... (`skinning_loot_template`)" ); + LoadLootTemplates_Skinning(); + LootTemplates_Skinning.CheckLootRefs(); + SendGlobalSysMessage("DB table `skinning_loot_template` reloaded."); + return true; +} + +bool ChatHandler::HandleReloadMangosStringCommand(const char*) +{ + sLog.outString( "Re-Loading mangos_string Table!" ); + objmgr.LoadMangosStrings(); + SendGlobalSysMessage("DB table `mangos_string` reloaded."); + return true; +} + +bool ChatHandler::HandleReloadNpcGossipCommand(const char*) +{ + sLog.outString( "Re-Loading `npc_gossip` Table!" ); + objmgr.LoadNpcTextId(); + SendGlobalSysMessage("DB table `npc_gossip` reloaded."); + return true; +} + +bool ChatHandler::HandleReloadNpcTrainerCommand(const char*) +{ + sLog.outString( "Re-Loading `npc_trainer` Table!" ); + objmgr.LoadTrainerSpell(); + SendGlobalSysMessage("DB table `npc_trainer` reloaded."); + return true; +} + +bool ChatHandler::HandleReloadNpcVendorCommand(const char*) +{ + sLog.outString( "Re-Loading `npc_vendor` Table!" ); + objmgr.LoadVendors(); + SendGlobalSysMessage("DB table `npc_vendor` reloaded."); + return true; +} + +bool ChatHandler::HandleReloadReservedNameCommand(const char*) +{ + sLog.outString( "Loading ReservedNames... (`reserved_name`)" ); + objmgr.LoadReservedPlayersNames(); + SendGlobalSysMessage("DB table `reserved_name` (player reserved names) reloaded."); + return true; +} + +bool ChatHandler::HandleReloadSkillDiscoveryTemplateCommand(const char* /*args*/) +{ + sLog.outString( "Re-Loading Skill Discovery Table..." ); + LoadSkillDiscoveryTable(); + SendGlobalSysMessage("DB table `skill_discovery_template` (recipes discovered at crafting) reloaded."); + return true; +} + +bool ChatHandler::HandleReloadSkillExtraItemTemplateCommand(const char* /*args*/) +{ + sLog.outString( "Re-Loading Skill Extra Item Table..." ); + LoadSkillExtraItemTable(); + SendGlobalSysMessage("DB table `skill_extra_item_template` (extra item creation when crafting) reloaded."); + return true; +} + +bool ChatHandler::HandleReloadSkillFishingBaseLevelCommand(const char* /*args*/) +{ + sLog.outString( "Re-Loading Skill Fishing base level requirements..." ); + objmgr.LoadFishingBaseSkillLevel(); + SendGlobalSysMessage("DB table `skill_fishing_base_level` (fishing base level for zone/subzone) reloaded."); + return true; +} + +bool ChatHandler::HandleReloadSpellAffectCommand(const char*) +{ + sLog.outString( "Re-Loading SpellAffect definitions..." ); + spellmgr.LoadSpellAffects(); + SendGlobalSysMessage("DB table `spell_affect` (spell mods apply requirements) reloaded."); + return true; +} + +bool ChatHandler::HandleReloadSpellChainCommand(const char*) +{ + sLog.outString( "Re-Loading Spell Chain Data... " ); + spellmgr.LoadSpellChains(); + SendGlobalSysMessage("DB table `spell_chain` (spell ranks) reloaded."); + return true; +} + +bool ChatHandler::HandleReloadSpellElixirCommand(const char*) +{ + sLog.outString( "Re-Loading Spell Elixir types..." ); + spellmgr.LoadSpellElixirs(); + SendGlobalSysMessage("DB table `spell_elixir` (spell exlixir types) reloaded."); + return true; +} + +bool ChatHandler::HandleReloadSpellLearnSpellCommand(const char*) +{ + sLog.outString( "Re-Loading Spell Learn Spells..." ); + spellmgr.LoadSpellLearnSpells(); + SendGlobalSysMessage("DB table `spell_learn_spell` reloaded."); + return true; +} + +bool ChatHandler::HandleReloadSpellProcEventCommand(const char*) +{ + sLog.outString( "Re-Loading Spell Proc Event conditions..." ); + spellmgr.LoadSpellProcEvents(); + SendGlobalSysMessage("DB table `spell_proc_event` (spell proc trigger requirements) reloaded."); + return true; +} + +bool ChatHandler::HandleReloadSpellScriptTargetCommand(const char*) +{ + sLog.outString( "Re-Loading SpellsScriptTarget..." ); + spellmgr.LoadSpellScriptTarget(); + SendGlobalSysMessage("DB table `spell_script_target` (spell targets selection in case specific creature/GO requirements) reloaded."); + return true; +} + +bool ChatHandler::HandleReloadSpellTargetPositionCommand(const char*) +{ + sLog.outString( "Re-Loading Spell target coordinates..." ); + spellmgr.LoadSpellTargetPositions(); + SendGlobalSysMessage("DB table `spell_target_position` (destination coordinates for spell targets) reloaded."); + return true; +} + +bool ChatHandler::HandleReloadSpellThreatsCommand(const char*) +{ + sLog.outString( "Re-Loading Aggro Spells Definitions..."); + spellmgr.LoadSpellThreats(); + SendGlobalSysMessage("DB table `spell_threat` (spell aggro definitions) reloaded."); + return true; +} + +bool ChatHandler::HandleReloadSpellPetAurasCommand(const char*) +{ + sLog.outString( "Re-Loading Spell pet auras..."); + spellmgr.LoadSpellPetAuras(); + SendGlobalSysMessage("DB table `spell_pet_auras` reloaded."); + return true; +} + +bool ChatHandler::HandleReloadPageTextsCommand(const char*) +{ + sLog.outString( "Re-Loading Page Texts..." ); + objmgr.LoadPageTexts(); + SendGlobalSysMessage("DB table `page_texts` reloaded."); + return true; +} + +bool ChatHandler::HandleReloadItemEnchantementsCommand(const char*) +{ + sLog.outString( "Re-Loading Item Random Enchantments Table..." ); + LoadRandomEnchantmentsTable(); + SendGlobalSysMessage("DB table `item_enchantment_template` reloaded."); + return true; +} + +bool ChatHandler::HandleReloadGameObjectScriptsCommand(const char* arg) +{ + if(sWorld.IsScriptScheduled()) + { + SendSysMessage("DB scripts used currently, please attempt reload later."); + SetSentErrorMessage(true); + return false; + } + + if(*arg!='a') + sLog.outString( "Re-Loading Scripts from `gameobject_scripts`..."); + + objmgr.LoadGameObjectScripts(); + + if(*arg!='a') + SendGlobalSysMessage("DB table `gameobject_scripts` reloaded."); + + return true; +} + +bool ChatHandler::HandleReloadEventScriptsCommand(const char* arg) +{ + if(sWorld.IsScriptScheduled()) + { + SendSysMessage("DB scripts used currently, please attempt reload later."); + SetSentErrorMessage(true); + return false; + } + + if(*arg!='a') + sLog.outString( "Re-Loading Scripts from `event_scripts`..."); + + objmgr.LoadEventScripts(); + + if(*arg!='a') + SendGlobalSysMessage("DB table `event_scripts` reloaded."); + + return true; +} + +bool ChatHandler::HandleReloadQuestEndScriptsCommand(const char* arg) +{ + if(sWorld.IsScriptScheduled()) + { + SendSysMessage("DB scripts used currently, please attempt reload later."); + SetSentErrorMessage(true); + return false; + } + + if(*arg!='a') + sLog.outString( "Re-Loading Scripts from `quest_end_scripts`..."); + + objmgr.LoadQuestEndScripts(); + + if(*arg!='a') + SendGlobalSysMessage("DB table `quest_end_scripts` reloaded."); + + return true; +} + +bool ChatHandler::HandleReloadQuestStartScriptsCommand(const char* arg) +{ + if(sWorld.IsScriptScheduled()) + { + SendSysMessage("DB scripts used currently, please attempt reload later."); + SetSentErrorMessage(true); + return false; + } + + if(*arg!='a') + sLog.outString( "Re-Loading Scripts from `quest_start_scripts`..."); + + objmgr.LoadQuestStartScripts(); + + if(*arg!='a') + SendGlobalSysMessage("DB table `quest_start_scripts` reloaded."); + + return true; +} + +bool ChatHandler::HandleReloadSpellScriptsCommand(const char* arg) +{ + if(sWorld.IsScriptScheduled()) + { + SendSysMessage("DB scripts used currently, please attempt reload later."); + SetSentErrorMessage(true); + return false; + } + + if(*arg!='a') + sLog.outString( "Re-Loading Scripts from `spell_scripts`..."); + + objmgr.LoadSpellScripts(); + + if(*arg!='a') + SendGlobalSysMessage("DB table `spell_scripts` reloaded."); + + return true; +} + +bool ChatHandler::HandleReloadGameGraveyardZoneCommand(const char* /*arg*/) +{ + sLog.outString( "Re-Loading Graveyard-zone links..."); + + objmgr.LoadGraveyardZones(); + + SendGlobalSysMessage("DB table `game_graveyard_zone` reloaded."); + + return true; +} + +bool ChatHandler::HandleReloadGameTeleCommand(const char* /*arg*/) +{ + sLog.outString( "Re-Loading Game Tele coordinates..."); + + objmgr.LoadGameTele(); + + SendGlobalSysMessage("DB table `game_tele` reloaded."); + + return true; +} + +bool ChatHandler::HandleLoadScriptsCommand(const char* args) +{ + if(!LoadScriptingModule(args)) return true; + + sWorld.SendWorldText(LANG_SCRIPTS_RELOADED); + return true; +} + +bool ChatHandler::HandleSecurityCommand(const char* args) +{ + char* arg1 = strtok((char*)args, " "); + if( !arg1 ) + return false; + + char* arg2 = 0; + + std::string targetName; + uint32 targetAccountId = 0; + uint32 targetSecurity = 0; + + Player* targetPlayer = getSelectedPlayer(); + if(targetPlayer) + { + targetName = targetPlayer->GetName(); + targetAccountId = targetPlayer->GetSession()->GetAccountId(); + targetSecurity = targetPlayer->GetSession()->GetSecurity(); + arg2 = arg1; + } + else + { + targetName = arg1; + if(!normalizePlayerName(targetName)) + { + SendSysMessage(LANG_PLAYER_NOT_FOUND); + SetSentErrorMessage(true); + return false; + } + + targetPlayer = ObjectAccessor::Instance().FindPlayerByName(targetName.c_str()); + if(targetPlayer) + { + targetAccountId = targetPlayer->GetSession()->GetAccountId(); + targetSecurity = targetPlayer->GetSession()->GetSecurity(); + } + else + { + uint64 targetGUID = objmgr.GetPlayerGUIDByName(targetName.c_str()); + if(!targetGUID) + { + SendSysMessage(LANG_PLAYER_NOT_FOUND); + SetSentErrorMessage(true); + return false; + } + targetAccountId = objmgr.GetPlayerAccountIdByGUID(targetGUID); + targetSecurity = objmgr.GetSecurityByAccount(targetAccountId); + } + + arg2 = strtok(NULL, " "); + } + + int32 gm = (int32)atoi(arg2); + if ( gm < SEC_PLAYER || gm > SEC_ADMINISTRATOR ) + { + SendSysMessage(LANG_BAD_VALUE); + SetSentErrorMessage(true); + return false; + } + + // can set security level only for target with less security and to less security that we have + if(targetSecurity >= m_session->GetSecurity() || uint32(gm) >= m_session->GetSecurity() ) + { + SendSysMessage(LANG_YOURS_SECURITY_IS_LOW); + SetSentErrorMessage(true); + return false; + } + + if(targetPlayer) + { + if( targetPlayer != m_session->GetPlayer() ) + ChatHandler(targetPlayer).PSendSysMessage(LANG_YOURS_SECURITY_CHANGED,m_session->GetPlayer()->GetName(), gm); + + targetPlayer->GetSession()->SetSecurity(gm); + } + + PSendSysMessage(LANG_YOU_CHANGE_SECURITY, targetName.c_str(), gm); + loginDatabase.PExecute("UPDATE account SET gmlevel = '%i' WHERE id = '%u'", gm, targetAccountId); + + return true; +} + +bool ChatHandler::HandleAllowMovementCommand(const char* /*args*/) +{ + if(sWorld.getAllowMovement()) + { + sWorld.SetAllowMovement(false); + SendSysMessage(LANG_CREATURE_MOVE_DISABLED); + } + else + { + sWorld.SetAllowMovement(true); + SendSysMessage(LANG_CREATURE_MOVE_ENABLED); + } + return true; +} + +bool ChatHandler::HandleMaxSkillCommand(const char* /*args*/) +{ + Player* SelectedPlayer = getSelectedPlayer(); + if(!SelectedPlayer) + { + SendSysMessage(LANG_NO_CHAR_SELECTED); + SetSentErrorMessage(true); + return false; + } + + // each skills that have max skill value dependent from level seted to current level max skill value + SelectedPlayer->UpdateSkillsToMaxSkillsForLevel(); + return true; +} + +bool ChatHandler::HandleSetSkillCommand(const char* args) +{ + // number or [name] Shift-click form |color|Hskill:skill_id|h[name]|h|r + char* skill_p = extractKeyFromLink((char*)args,"Hskill"); + if(!skill_p) + return false; + + char *level_p = strtok (NULL, " "); + + if( !level_p) + return false; + + char *max_p = strtok (NULL, " "); + + int32 skill = atoi(skill_p); + + if (skill <= 0) + { + PSendSysMessage(LANG_INVALID_SKILL_ID, skill); + SetSentErrorMessage(true); + return false; + } + + int32 level = atol (level_p); + + Player * target = getSelectedPlayer(); + if(!target) + { + SendSysMessage(LANG_NO_CHAR_SELECTED); + SetSentErrorMessage(true); + return false; + } + + SkillLineEntry const* sl = sSkillLineStore.LookupEntry(skill); + if(!sl) + { + PSendSysMessage(LANG_INVALID_SKILL_ID, skill); + SetSentErrorMessage(true); + return false; + } + + if(!target->GetSkillValue(skill)) + { + PSendSysMessage(LANG_SET_SKILL_ERROR, target->GetName(), skill, sl->name[0]); + SetSentErrorMessage(true); + return false; + } + + int32 max = max_p ? atol (max_p) : target->GetPureMaxSkillValue(skill); + + if( level <= 0 || level > max || max <= 0 ) + return false; + + target->SetSkill(skill, level, max); + PSendSysMessage(LANG_SET_SKILL, skill, sl->name[0], target->GetName(), level, max); + + return true; +} + +bool ChatHandler::HandleUnLearnCommand(const char* args) +{ + if (!*args) + return false; + + + // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r + uint32 min_id = extractSpellIdFromLink((char*)args); + if(!min_id) + return false; + + // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r + char* tail = strtok(NULL,""); + + uint32 max_id = extractSpellIdFromLink(tail); + + if (!max_id) + { + // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r + max_id = min_id+1; + } + else + { + if (max_id < min_id) + std::swap(min_id,max_id); + + max_id=max_id+1; + } + + Player* target = getSelectedPlayer(); + if(!target) + { + SendSysMessage(LANG_NO_CHAR_SELECTED); + SetSentErrorMessage(true); + return false; + } + + for(uint32 spell=min_id;spellHasSpell(spell)) + target->removeSpell(spell); + else + SendSysMessage(LANG_FORGET_SPELL); + } + + return true; +} + +bool ChatHandler::HandleCooldownCommand(const char* args) +{ + Player* target = getSelectedPlayer(); + if(!target) + { + SendSysMessage(LANG_PLAYER_NOT_FOUND); + SetSentErrorMessage(true); + return false; + } + + if (!*args) + { + target->RemoveAllSpellCooldown(); + PSendSysMessage(LANG_REMOVEALL_COOLDOWN, target->GetName()); + } + else + { + // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form + uint32 spell_id = extractSpellIdFromLink((char*)args); + if(!spell_id) + return false; + + if(!sSpellStore.LookupEntry(spell_id)) + { + PSendSysMessage(LANG_UNKNOWN_SPELL, target==m_session->GetPlayer() ? GetMangosString(LANG_YOU) : target->GetName()); + SetSentErrorMessage(true); + return false; + } + + WorldPacket data( SMSG_CLEAR_COOLDOWN, (4+8) ); + data << uint32(spell_id); + data << uint64(target->GetGUID()); + target->GetSession()->SendPacket(&data); + target->RemoveSpellCooldown(spell_id); + PSendSysMessage(LANG_REMOVE_COOLDOWN, spell_id, target==m_session->GetPlayer() ? GetMangosString(LANG_YOU) : target->GetName()); + } + return true; +} + +bool ChatHandler::HandleLearnAllCommand(const char* /*args*/) +{ + static const char *allSpellList[] = + { + "3365", + "6233", + "6247", + "6246", + "6477", + "6478", + "22810", + "8386", + "21651", + "21652", + "522", + "7266", + "8597", + "2479", + "22027", + "6603", + "5019", + "133", + "168", + "227", + "5009", + "9078", + "668", + "203", + "20599", + "20600", + "81", + "20597", + "20598", + "20864", + "1459", + "5504", + "587", + "5143", + "118", + "5505", + "597", + "604", + "1449", + "1460", + "2855", + "1008", + "475", + "5506", + "1463", + "12824", + "8437", + "990", + "5145", + "8450", + "1461", + "759", + "8494", + "8455", + "8438", + "6127", + "8416", + "6129", + "8451", + "8495", + "8439", + "3552", + "8417", + "10138", + "12825", + "10169", + "10156", + "10144", + "10191", + "10201", + "10211", + "10053", + "10173", + "10139", + "10145", + "10192", + "10170", + "10202", + "10054", + "10174", + "10193", + "12826", + "2136", + "143", + "145", + "2137", + "2120", + "3140", + "543", + "2138", + "2948", + "8400", + "2121", + "8444", + "8412", + "8457", + "8401", + "8422", + "8445", + "8402", + "8413", + "8458", + "8423", + "8446", + "10148", + "10197", + "10205", + "10149", + "10215", + "10223", + "10206", + "10199", + "10150", + "10216", + "10207", + "10225", + "10151", + "116", + "205", + "7300", + "122", + "837", + "10", + "7301", + "7322", + "6143", + "120", + "865", + "8406", + "6141", + "7302", + "8461", + "8407", + "8492", + "8427", + "8408", + "6131", + "7320", + "10159", + "8462", + "10185", + "10179", + "10160", + "10180", + "10219", + "10186", + "10177", + "10230", + "10181", + "10161", + "10187", + "10220", + "2018", + "2663", + "12260", + "2660", + "3115", + "3326", + "2665", + "3116", + "2738", + "3293", + "2661", + "3319", + "2662", + "9983", + "8880", + "2737", + "2739", + "7408", + "3320", + "2666", + "3323", + "3324", + "3294", + "22723", + "23219", + "23220", + "23221", + "23228", + "23338", + "10788", + "10790", + "5611", + "5016", + "5609", + "2060", + "10963", + "10964", + "10965", + "22593", + "22594", + "596", + "996", + "499", + "768", + "17002", + "1448", + "1082", + "16979", + "1079", + "5215", + "20484", + "5221", + "15590", + "17007", + "6795", + "6807", + "5487", + "1446", + "1066", + "5421", + "3139", + "779", + "6811", + "6808", + "1445", + "5216", + "1737", + "5222", + "5217", + "1432", + "6812", + "9492", + "5210", + "3030", + "1441", + "783", + "6801", + "20739", + "8944", + "9491", + "22569", + "5226", + "6786", + "1433", + "8973", + "1828", + "9495", + "9006", + "6794", + "8993", + "5203", + "16914", + "6784", + "9635", + "22830", + "20722", + "9748", + "6790", + "9753", + "9493", + "9752", + "9831", + "9825", + "9822", + "5204", + "5401", + "22831", + "6793", + "9845", + "17401", + "9882", + "9868", + "20749", + "9893", + "9899", + "9895", + "9832", + "9902", + "9909", + "22832", + "9828", + "9851", + "9883", + "9869", + "17406", + "17402", + "9914", + "20750", + "9897", + "9848", + "3127", + "107", + "204", + "9116", + "2457", + "78", + "18848", + "331", + "403", + "2098", + "1752", + "11278", + "11288", + "11284", + "6461", + "2344", + "2345", + "6463", + "2346", + "2352", + "775", + "1434", + "1612", + "71", + "2468", + "2458", + "2467", + "7164", + "7178", + "7367", + "7376", + "7381", + "21156", + "5209", + "3029", + "5201", + "9849", + "9850", + "20719", + "22568", + "22827", + "22828", + "22829", + "6809", + "8972", + "9005", + "9823", + "9827", + "6783", + "9913", + "6785", + "6787", + "9866", + "9867", + "9894", + "9896", + "6800", + "8992", + "9829", + "9830", + "780", + "769", + "6749", + "6750", + "9755", + "9754", + "9908", + "20745", + "20742", + "20747", + "20748", + "9746", + "9745", + "9880", + "9881", + "5391", + "842", + "3025", + "3031", + "3287", + "3329", + "1945", + "3559", + "4933", + "4934", + "4935", + "4936", + "5142", + "5390", + "5392", + "5404", + "5420", + "6405", + "7293", + "7965", + "8041", + "8153", + "9033", + "9034", + //"9036", problems with ghost state + "16421", + "21653", + "22660", + "5225", + "9846", + "2426", + "5916", + "6634", + //"6718", phasing stealth, annoing for learn all case. + "6719", + "8822", + "9591", + "9590", + "10032", + "17746", + "17747", + "8203", + "11392", + "12495", + "16380", + "23452", + "4079", + "4996", + "4997", + "4998", + "4999", + "5000", + "6348", + "6349", + "6481", + "6482", + "6483", + "6484", + "11362", + "11410", + "11409", + "12510", + "12509", + "12885", + "13142", + "21463", + "23460", + "11421", + "11416", + "11418", + "1851", + "10059", + "11423", + "11417", + "11422", + "11419", + "11424", + "11420", + "27", + "31", + "33", + "34", + "35", + "15125", + "21127", + "22950", + "1180", + "201", + "12593", + "12842", + "16770", + "6057", + "12051", + "18468", + "12606", + "12605", + "18466", + "12502", + "12043", + "15060", + "12042", + "12341", + "12848", + "12344", + "12353", + "18460", + "11366", + "12350", + "12352", + "13043", + "11368", + "11113", + "12400", + "11129", + "16766", + "12573", + "15053", + "12580", + "12475", + "12472", + "12953", + "12488", + "11189", + "12985", + "12519", + "16758", + "11958", + "12490", + "11426", + "3565", + "3562", + "18960", + "3567", + "3561", + "3566", + "3563", + "1953", + "2139", + "12505", + "13018", + "12522", + "12523", + "5146", + "5144", + "5148", + "8419", + "8418", + "10213", + "10212", + "10157", + "12524", + "13019", + "12525", + "13020", + "12526", + "13021", + "18809", + "13031", + "13032", + "13033", + "4036", + "3920", + "3919", + "3918", + "7430", + "3922", + "3923", + "7411", + "7418", + "7421", + "13262", + "7412", + "7415", + "7413", + "7416", + "13920", + "13921", + "7745", + "7779", + "7428", + "7457", + "7857", + "7748", + "7426", + "13421", + "7454", + "13378", + "7788", + "14807", + "14293", + "7795", + "6296", + "20608", + "755", + "444", + "427", + "428", + "442", + "447", + "3578", + "3581", + "19027", + "3580", + "665", + "3579", + "3577", + "6755", + "3576", + "2575", + "2577", + "2578", + "2579", + "2580", + "2656", + "2657", + "2576", + "3564", + "10248", + "8388", + "2659", + "14891", + "3308", + "3307", + "10097", + "2658", + "3569", + "16153", + "3304", + "10098", + "4037", + "3929", + "3931", + "3926", + "3924", + "3930", + "3977", + "3925", + "136", + "228", + "5487", + "43", + "202", + "0" + }; + + int loop = 0; + while(strcmp(allSpellList[loop], "0")) + { + uint32 spell = atol((char*)allSpellList[loop++]); + + if (m_session->GetPlayer()->HasSpell(spell)) + continue; + + SpellEntry const* spellInfo = sSpellStore.LookupEntry(spell); + if(!spellInfo || !SpellMgr::IsSpellValid(spellInfo,m_session->GetPlayer())) + { + PSendSysMessage(LANG_COMMAND_SPELL_BROKEN,spell); + continue; + } + + m_session->GetPlayer()->learnSpell(spell); + } + + SendSysMessage(LANG_COMMAND_LEARN_MANY_SPELLS); + + return true; +} + +bool ChatHandler::HandleLearnAllGMCommand(const char* /*args*/) +{ + static const char *gmSpellList[] = + { + "24347", // Become A Fish, No Breath Bar + "35132", // Visual Boom + "38488", // Attack 4000-8000 AOE + "38795", // Attack 2000 AOE + Slow Down 90% + "15712", // Attack 200 + "1852", // GM Spell Silence + "31899", // Kill + "31924", // Kill + "29878", // Kill My Self + "26644", // More Kill + + "28550", //Invisible 24 + "23452", //Invisible + Target + "0" + }; + + uint16 gmSpellIter = 0; + while( strcmp(gmSpellList[gmSpellIter], "0") ) + { + uint32 spell = atol((char*)gmSpellList[gmSpellIter++]); + + SpellEntry const* spellInfo = sSpellStore.LookupEntry(spell); + if(!spellInfo || !SpellMgr::IsSpellValid(spellInfo,m_session->GetPlayer())) + { + PSendSysMessage(LANG_COMMAND_SPELL_BROKEN,spell); + continue; + } + + m_session->GetPlayer()->learnSpell(spell); + } + + SendSysMessage(LANG_LEARNING_GM_SKILLS); + return true; +} + +bool ChatHandler::HandleLearnAllMyClassCommand(const char* /*args*/) +{ + HandleLearnAllMySpellsCommand(""); + HandleLearnAllMyTalentsCommand(""); + return true; +} + +bool ChatHandler::HandleLearnAllMySpellsCommand(const char* /*args*/) +{ + ChrClassesEntry const* clsEntry = sChrClassesStore.LookupEntry(m_session->GetPlayer()->getClass()); + if(!clsEntry) + return true; + uint32 family = clsEntry->spellfamily; + + for (uint32 i = 0; i < sSpellStore.GetNumRows(); i++) + { + SpellEntry const *spellInfo = sSpellStore.LookupEntry(i); + if(!spellInfo) + continue; + + // skip wrong class/race skills + if(!m_session->GetPlayer()->IsSpellFitByClassAndRace(spellInfo->Id)) + continue; + + // skip other spell families + if( spellInfo->SpellFamilyName != family) + continue; + + //TODO: skip triggered spells + + // skip spells with first rank learned as talent (and all talents then also) + uint32 first_rank = spellmgr.GetFirstSpellInChain(spellInfo->Id); + if(GetTalentSpellCost(first_rank) > 0 ) + continue; + + // skip broken spells + if(!SpellMgr::IsSpellValid(spellInfo,m_session->GetPlayer(),false)) + continue; + + m_session->GetPlayer()->learnSpell(i); + } + + SendSysMessage(LANG_COMMAND_LEARN_CLASS_SPELLS); + return true; +} + +static void learnAllHighRanks(Player* player, uint32 spellid) +{ + SpellChainMapNext const& nextMap = spellmgr.GetSpellChainNext(); + for(SpellChainMapNext::const_iterator itr = nextMap.lower_bound(spellid); itr != nextMap.upper_bound(spellid); ++itr) + { + player->learnSpell(itr->second); + learnAllHighRanks(player,itr->second); + } +} + +bool ChatHandler::HandleLearnAllMyTalentsCommand(const char* /*args*/) +{ + Player* player = m_session->GetPlayer(); + uint32 classMask = player->getClassMask(); + + for (uint32 i = 0; i < sTalentStore.GetNumRows(); i++) + { + TalentEntry const *talentInfo = sTalentStore.LookupEntry(i); + if(!talentInfo) + continue; + + TalentTabEntry const *talentTabInfo = sTalentTabStore.LookupEntry( talentInfo->TalentTab ); + if(!talentTabInfo) + continue; + + if( (classMask & talentTabInfo->ClassMask) == 0 ) + continue; + + // search highest talent rank + uint32 spellid = 0; + int rank = 4; + for(; rank >= 0; --rank) + { + if(talentInfo->RankID[rank]!=0) + { + spellid = talentInfo->RankID[rank]; + break; + } + } + + if(!spellid) // ??? none spells in telent + continue; + + SpellEntry const* spellInfo = sSpellStore.LookupEntry(spellid); + if(!spellInfo || !SpellMgr::IsSpellValid(spellInfo,m_session->GetPlayer(),false)) + continue; + + // learn highest rank of talent + player->learnSpell(spellid); + + // and learn all non-talent spell ranks (recursive by tree) + learnAllHighRanks(player,spellid); + } + + SendSysMessage(LANG_COMMAND_LEARN_CLASS_TALENTS); + return true; +} + +bool ChatHandler::HandleLearnAllLangCommand(const char* /*args*/) +{ + // skipping UNIVERSAL language (0) + for(int i = 1; i < LANGUAGES_COUNT; ++i) + m_session->GetPlayer()->learnSpell(lang_description[i].spell_id); + + SendSysMessage(LANG_COMMAND_LEARN_ALL_LANG); + return true; +} + +bool ChatHandler::HandleLearnAllDefaultCommand(const char* args) +{ + char* pName = strtok((char*)args, ""); + Player *player = NULL; + if (pName) + { + std::string name = pName; + + if(!normalizePlayerName(name)) + { + SendSysMessage(LANG_PLAYER_NOT_FOUND); + SetSentErrorMessage(true); + return false; + } + + player = objmgr.GetPlayer(name.c_str()); + } + else + player = getSelectedPlayer(); + + if(!player) + { + SendSysMessage(LANG_NO_CHAR_SELECTED); + SetSentErrorMessage(true); + return false; + } + + player->learnDefaultSpells(); + player->learnQuestRewardedSpells(); + + PSendSysMessage(LANG_COMMAND_LEARN_ALL_DEFAULT_AND_QUEST,player->GetName()); + return true; +} + +bool ChatHandler::HandleLearnCommand(const char* args) +{ + Player* targetPlayer = getSelectedPlayer(); + + if(!targetPlayer) + { + SendSysMessage(LANG_PLAYER_NOT_FOUND); + SetSentErrorMessage(true); + return false; + } + + // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form + uint32 spell = extractSpellIdFromLink((char*)args); + if(!spell || !sSpellStore.LookupEntry(spell)) + return false; + + if (targetPlayer->HasSpell(spell)) + { + if(targetPlayer == m_session->GetPlayer()) + SendSysMessage(LANG_YOU_KNOWN_SPELL); + else + PSendSysMessage(LANG_TARGET_KNOWN_SPELL,targetPlayer->GetName()); + SetSentErrorMessage(true); + return false; + } + + SpellEntry const* spellInfo = sSpellStore.LookupEntry(spell); + if(!spellInfo || !SpellMgr::IsSpellValid(spellInfo,m_session->GetPlayer())) + { + PSendSysMessage(LANG_COMMAND_SPELL_BROKEN,spell); + SetSentErrorMessage(true); + return false; + } + + targetPlayer->learnSpell(spell); + + return true; +} + +bool ChatHandler::HandleAddItemCommand(const char* args) +{ + if (!*args) + return false; + + uint32 itemId = 0; + + if(args[0]=='[') // [name] manual form + { + char* citemName = citemName = strtok((char*)args, "]"); + + if(citemName && citemName[0]) + { + std::string itemName = citemName+1; + WorldDatabase.escape_string(itemName); + QueryResult *result = WorldDatabase.PQuery("SELECT entry FROM item_template WHERE name = '%s'", itemName.c_str()); + if (!result) + { + PSendSysMessage(LANG_COMMAND_COULDNOTFIND, citemName+1); + SetSentErrorMessage(true); + return false; + } + itemId = result->Fetch()->GetUInt16(); + delete result; + } + else + return false; + } + else // item_id or [name] Shift-click form |color|Hitem:item_id:0:0:0|h[name]|h|r + { + char* cId = extractKeyFromLink((char*)args,"Hitem"); + if(!cId) + return false; + itemId = atol(cId); + } + + char* ccount = strtok(NULL, " "); + + int32 count = 1; + + if (ccount) + count = strtol(ccount, NULL, 10); + + if (count == 0) + count = 1; + + Player* pl = m_session->GetPlayer(); + Player* plTarget = getSelectedPlayer(); + if(!plTarget) + plTarget = pl; + + sLog.outDetail(GetMangosString(LANG_ADDITEM), itemId, count); + + ItemPrototype const *pProto = objmgr.GetItemPrototype(itemId); + if(!pProto) + { + PSendSysMessage(LANG_COMMAND_ITEMIDINVALID, itemId); + SetSentErrorMessage(true); + return false; + } + + //Subtract + if (count < 0) + { + plTarget->DestroyItemCount(itemId, -count, true, false); + PSendSysMessage(LANG_REMOVEITEM, itemId, -count, plTarget->GetName()); + return true; + } + + //Adding items + uint32 noSpaceForCount = 0; + + // check space and find places + ItemPosCountVec dest; + uint8 msg = plTarget->CanStoreNewItem( NULL_BAG, NULL_SLOT, dest, itemId, count, &noSpaceForCount ); + if( msg != EQUIP_ERR_OK ) // convert to possible store amount + count -= noSpaceForCount; + + if( count == 0 || dest.empty()) // can't add any + { + PSendSysMessage(LANG_ITEM_CANNOT_CREATE, itemId, noSpaceForCount ); + SetSentErrorMessage(true); + return false; + } + + Item* item = plTarget->StoreNewItem( dest, itemId, true, Item::GenerateItemRandomPropertyId(itemId)); + + // remove binding (let GM give it to another player later) + if(pl==plTarget) + for(ItemPosCountVec::const_iterator itr = dest.begin(); itr != dest.end(); ++itr) + if(Item* item1 = pl->GetItemByPos(itr->pos)) + item1->SetBinding( false ); + + if(count > 0 && item) + { + pl->SendNewItem(item,count,false,true); + if(pl!=plTarget) + plTarget->SendNewItem(item,count,true,false); + } + + if(noSpaceForCount > 0) + PSendSysMessage(LANG_ITEM_CANNOT_CREATE, itemId, noSpaceForCount); + + return true; +} + +bool ChatHandler::HandleAddItemSetCommand(const char* args) +{ + if (!*args) + return false; + + char* cId = extractKeyFromLink((char*)args,"Hitemset"); // number or [name] Shift-click form |color|Hitemset:itemset_id|h[name]|h|r + if (!cId) + return false; + + uint32 itemsetId = atol(cId); + + // prevent generation all items with itemset field value '0' + if (itemsetId == 0) + { + PSendSysMessage(LANG_NO_ITEMS_FROM_ITEMSET_FOUND,itemsetId); + SetSentErrorMessage(true); + return false; + } + + Player* pl = m_session->GetPlayer(); + Player* plTarget = getSelectedPlayer(); + if(!plTarget) + plTarget = pl; + + sLog.outDetail(GetMangosString(LANG_ADDITEMSET), itemsetId); + + QueryResult *result = WorldDatabase.PQuery("SELECT entry FROM item_template WHERE itemset = %u",itemsetId); + + if(!result) + { + PSendSysMessage(LANG_NO_ITEMS_FROM_ITEMSET_FOUND,itemsetId); + + SetSentErrorMessage(true); + return false; + } + + do + { + Field *fields = result->Fetch(); + uint32 itemId = fields[0].GetUInt32(); + + ItemPosCountVec dest; + uint8 msg = plTarget->CanStoreNewItem( NULL_BAG, NULL_SLOT, dest, itemId, 1 ); + if( msg == EQUIP_ERR_OK ) + { + Item* item = plTarget->StoreNewItem( dest, itemId, true); + + // remove binding (let GM give it to another player later) + if(pl==plTarget) + item->SetBinding( false ); + + pl->SendNewItem(item,1,false,true); + if(pl!=plTarget) + plTarget->SendNewItem(item,1,true,false); + } + else + { + pl->SendEquipError( msg, NULL, NULL ); + PSendSysMessage(LANG_ITEM_CANNOT_CREATE, itemId, 1); + } + + }while( result->NextRow() ); + + delete result; + + return true; +} + +bool ChatHandler::HandleListItemCommand(const char* args) +{ + if(!*args) + return false; + + char* cId = extractKeyFromLink((char*)args,"Hitem"); + if(!cId) + return false; + uint32 item_id = atol(cId); + + ItemPrototype const* itemProto = item_id ? itemProto = objmgr.GetItemPrototype(item_id) : NULL; + + if(!itemProto) + { + PSendSysMessage(LANG_COMMAND_ITEMIDINVALID, item_id); + SetSentErrorMessage(true); + return false; + } + + char* c_count = strtok(NULL, " "); + int count = c_count ? atol(c_count) : 10; + + if(count < 0) + return false; + + QueryResult *result; + + // inventory case + uint32 inv_count = 0; + result=CharacterDatabase.PQuery("SELECT COUNT(item_template) FROM character_inventory WHERE item_template='%u'",item_id); + if(result) + { + inv_count = (*result)[0].GetUInt32(); + delete result; + } + + result=CharacterDatabase.PQuery( + // 0 1 2 3 4 5 + "SELECT ci.item, cibag.slot AS bag, ci.slot, ci.guid, characters.account,characters.name " + "FROM character_inventory AS ci LEFT JOIN character_inventory AS cibag ON (cibag.item=ci.bag),characters " + "WHERE ci.item_template='%u' AND ci.guid = characters.guid LIMIT %u ", + item_id,uint32(count)); + + if(result) + { + do + { + Field *fields = result->Fetch(); + uint32 item_guid = fields[0].GetUInt32(); + uint32 item_bag = fields[1].GetUInt32(); + uint32 item_slot = fields[2].GetUInt32(); + uint32 owner_guid = fields[3].GetUInt32(); + uint32 owner_acc = fields[4].GetUInt32(); + std::string owner_name = fields[5].GetCppString(); + + char const* item_pos = 0; + if(Player::IsEquipmentPos(item_bag,item_slot)) + item_pos = "[equipped]"; + else if(Player::IsInventoryPos(item_bag,item_slot)) + item_pos = "[in inventory]"; + else if(Player::IsBankPos(item_bag,item_slot)) + item_pos = "[in bank]"; + else + item_pos = ""; + + PSendSysMessage(LANG_ITEMLIST_SLOT, + item_guid,owner_name.c_str(),owner_guid,owner_acc,item_pos); + } while (result->NextRow()); + + int64 res_count = result->GetRowCount(); + + delete result; + + if(count > res_count) + count-=res_count; + else if(count) + count = 0; + } + + // mail case + uint32 mail_count = 0; + result=CharacterDatabase.PQuery("SELECT COUNT(item_template) FROM mail_items WHERE item_template='%u'", item_id); + if(result) + { + mail_count = (*result)[0].GetUInt32(); + delete result; + } + + if(count > 0) + { + result=CharacterDatabase.PQuery( + // 0 1 2 3 4 5 6 + "SELECT mail_items.item_guid, mail.sender, mail.receiver, char_s.account, char_s.name, char_r.account, char_r.name " + "FROM mail,mail_items,characters as char_s,characters as char_r " + "WHERE mail_items.item_template='%u' AND char_s.guid = mail.sender AND char_r.guid = mail.receiver AND mail.id=mail_items.mail_id LIMIT %u", + item_id,uint32(count)); + } + else + result = NULL; + + if(result) + { + do + { + Field *fields = result->Fetch(); + uint32 item_guid = fields[0].GetUInt32(); + uint32 item_s = fields[1].GetUInt32(); + uint32 item_r = fields[2].GetUInt32(); + uint32 item_s_acc = fields[3].GetUInt32(); + std::string item_s_name = fields[4].GetCppString(); + uint32 item_r_acc = fields[5].GetUInt32(); + std::string item_r_name = fields[6].GetCppString(); + + char const* item_pos = "[in mail]"; + + PSendSysMessage(LANG_ITEMLIST_MAIL, + item_guid,item_s_name.c_str(),item_s,item_s_acc,item_r_name.c_str(),item_r,item_r_acc,item_pos); + } while (result->NextRow()); + + int64 res_count = result->GetRowCount(); + + delete result; + + if(count > res_count) + count-=res_count; + else if(count) + count = 0; + } + + // auction case + uint32 auc_count = 0; + result=CharacterDatabase.PQuery("SELECT COUNT(item_template) FROM auctionhouse WHERE item_template='%u'",item_id); + if(result) + { + auc_count = (*result)[0].GetUInt32(); + delete result; + } + + if(count > 0) + { + result=CharacterDatabase.PQuery( + // 0 1 2 3 + "SELECT auctionhouse.itemguid, auctionhouse.itemowner, characters.account, characters.name " + "FROM auctionhouse,characters WHERE auctionhouse.item_template='%u' AND characters.guid = auctionhouse.itemowner LIMIT %u", + item_id,uint32(count)); + } + else + result = NULL; + + if(result) + { + do + { + Field *fields = result->Fetch(); + uint32 item_guid = fields[0].GetUInt32(); + uint32 owner = fields[1].GetUInt32(); + uint32 owner_acc = fields[2].GetUInt32(); + std::string owner_name = fields[3].GetCppString(); + + char const* item_pos = "[in auction]"; + + PSendSysMessage(LANG_ITEMLIST_AUCTION, item_guid, owner_name.c_str(), owner, owner_acc,item_pos); + } while (result->NextRow()); + + delete result; + } + + if(inv_count+mail_count+auc_count == 0) + { + SendSysMessage(LANG_COMMAND_NOITEMFOUND); + SetSentErrorMessage(true); + return false; + } + + PSendSysMessage(LANG_COMMAND_LISTITEMMESSAGE,item_id,inv_count+mail_count+auc_count,inv_count,mail_count,auc_count); + + return true; +} + +bool ChatHandler::HandleListObjectCommand(const char* args) +{ + if(!*args) + return false; + + // number or [name] Shift-click form |color|Hgameobject_entry:go_id|h[name]|h|r + char* cId = extractKeyFromLink((char*)args,"Hgameobject_entry"); + if(!cId) + return false; + + uint32 go_id = atol(cId); + + GameObjectInfo const * gInfo = objmgr.GetGameObjectInfo(go_id); + + if(!go_id || !gInfo) + { + PSendSysMessage(LANG_COMMAND_LISTOBJINVALIDID, go_id); + SetSentErrorMessage(true); + return false; + } + + char* c_count = strtok(NULL, " "); + int count = c_count ? atol(c_count) : 10; + + if(count < 0) + return false; + + Player* pl = m_session->GetPlayer(); + QueryResult *result; + + uint32 obj_count = 0; + result=WorldDatabase.PQuery("SELECT COUNT(guid) FROM gameobject WHERE id='%u'",go_id); + if(result) + { + obj_count = (*result)[0].GetUInt32(); + delete result; + } + + result = WorldDatabase.PQuery("SELECT guid, position_x, position_y, position_z, map, (POW(position_x - '%f', 2) + POW(position_y - '%f', 2) + POW(position_z - '%f', 2)) AS order_ FROM gameobject WHERE id = '%u' ORDER BY order_ ASC LIMIT %u", + pl->GetPositionX(), pl->GetPositionY(), pl->GetPositionZ(),go_id,uint32(count)); + + if (result) + { + do + { + Field *fields = result->Fetch(); + uint32 guid = fields[0].GetUInt32(); + float x = fields[1].GetFloat(); + float y = fields[2].GetFloat(); + float z = fields[3].GetFloat(); + int mapid = fields[4].GetUInt16(); + + PSendSysMessage(LANG_GO_LIST, guid, guid, gInfo->name, x, y, z, mapid); + } while (result->NextRow()); + + delete result; + } + + PSendSysMessage(LANG_COMMAND_LISTOBJMESSAGE,go_id,obj_count); + return true; +} + +bool ChatHandler::HandleNearObjectCommand(const char* args) +{ + float distance = (!*args) ? 10 : atol(args); + uint32 count = 0; + + Player* pl = m_session->GetPlayer(); + QueryResult *result = WorldDatabase.PQuery("SELECT guid, id, position_x, position_y, position_z, map, " + "(POW(position_x - '%f', 2) + POW(position_y - '%f', 2) + POW(position_z - '%f', 2)) AS order_ " + "FROM gameobject WHERE map='%u' AND (POW(position_x - '%f', 2) + POW(position_y - '%f', 2) + POW(position_z - '%f', 2)) <= '%f' ORDER BY order_", + pl->GetPositionX(), pl->GetPositionY(), pl->GetPositionZ(), + pl->GetMapId(),pl->GetPositionX(), pl->GetPositionY(), pl->GetPositionZ(),distance*distance); + + if (result) + { + do + { + Field *fields = result->Fetch(); + uint32 guid = fields[0].GetUInt32(); + uint32 entry = fields[1].GetUInt32(); + float x = fields[2].GetFloat(); + float y = fields[3].GetFloat(); + float z = fields[4].GetFloat(); + int mapid = fields[5].GetUInt16(); + + GameObjectInfo const * gInfo = objmgr.GetGameObjectInfo(entry); + + if(!gInfo) + continue; + + PSendSysMessage(LANG_GO_LIST, guid, guid, gInfo->name, x, y, z, mapid); + + ++count; + } while (result->NextRow()); + + delete result; + } + + PSendSysMessage(LANG_COMMAND_NEAROBJMESSAGE,distance,count); + return true; +} + +bool ChatHandler::HandleListCreatureCommand(const char* args) +{ + if(!*args) + return false; + + // number or [name] Shift-click form |color|Hcreature_entry:creature_id|h[name]|h|r + char* cId = extractKeyFromLink((char*)args,"Hcreature_entry"); + if(!cId) + return false; + + uint32 cr_id = atol(cId); + + CreatureInfo const* cInfo = objmgr.GetCreatureTemplate(cr_id); + + if(!cr_id || !cInfo) + { + PSendSysMessage(LANG_COMMAND_INVALIDCREATUREID, cr_id); + SetSentErrorMessage(true); + return false; + } + + char* c_count = strtok(NULL, " "); + int count = c_count ? atol(c_count) : 10; + + if(count < 0) + return false; + + Player* pl = m_session->GetPlayer(); + QueryResult *result; + + uint32 cr_count = 0; + result=WorldDatabase.PQuery("SELECT COUNT(guid) FROM creature WHERE id='%u'",cr_id); + if(result) + { + cr_count = (*result)[0].GetUInt32(); + delete result; + } + + result = WorldDatabase.PQuery("SELECT guid, position_x, position_y, position_z, map, (POW(position_x - '%f', 2) + POW(position_y - '%f', 2) + POW(position_z - '%f', 2)) AS order_ FROM creature WHERE id = '%u' ORDER BY order_ ASC LIMIT %u", + pl->GetPositionX(), pl->GetPositionY(), pl->GetPositionZ(), cr_id,uint32(count)); + + if (result) + { + do + { + Field *fields = result->Fetch(); + uint32 guid = fields[0].GetUInt32(); + float x = fields[1].GetFloat(); + float y = fields[2].GetFloat(); + float z = fields[3].GetFloat(); + int mapid = fields[4].GetUInt16(); + + PSendSysMessage(LANG_CREATURE_LIST, guid, guid, cInfo->Name, x, y, z, mapid); + } while (result->NextRow()); + + delete result; + } + + PSendSysMessage(LANG_COMMAND_LISTCREATUREMESSAGE,cr_id,cr_count); + return true; +} + +bool ChatHandler::HandleLookupItemCommand(const char* args) +{ + if(!*args) + return false; + + std::string namepart = args; + std::wstring wnamepart; + + // converting string that we try to find to lower case + if(!Utf8toWStr(namepart,wnamepart)) + return false; + + wstrToLower(wnamepart); + + uint32 counter = 0; + + // Search in `item_template` + for (uint32 id = 0; id < sItemStorage.MaxEntry; id++) + { + ItemPrototype const *pProto = sItemStorage.LookupEntry(id); + if(!pProto) + continue; + + int loc_idx = m_session->GetSessionDbLocaleIndex(); + if ( loc_idx >= 0 ) + { + ItemLocale const *il = objmgr.GetItemLocale(pProto->ItemId); + if (il) + { + if (il->Name.size() > loc_idx && !il->Name[loc_idx].empty()) + { + std::string name = il->Name[loc_idx]; + + if (Utf8FitTo(name, wnamepart)) + { + PSendSysMessage(LANG_ITEM_LIST, id, id, name.c_str()); + ++counter; + continue; + } + } + } + } + + std::string name = pProto->Name1; + if(name.empty()) + continue; + + if (Utf8FitTo(name, wnamepart)) + { + PSendSysMessage(LANG_ITEM_LIST, id, id, name.c_str()); + ++counter; + } + } + + if (counter==0) + SendSysMessage(LANG_COMMAND_NOITEMFOUND); + + return true; +} + +bool ChatHandler::HandleLookupItemSetCommand(const char* args) +{ + if(!*args) + return false; + + std::string namepart = args; + std::wstring wnamepart; + + if(!Utf8toWStr(namepart,wnamepart)) + return false; + + // converting string that we try to find to lower case + wstrToLower( wnamepart ); + + uint32 counter = 0; // Counter for figure out that we found smth. + + // Search in ItemSet.dbc + for (uint32 id = 0; id < sItemSetStore.GetNumRows(); id++) + { + ItemSetEntry const *set = sItemSetStore.LookupEntry(id); + if(set) + { + int loc = m_session->GetSessionDbcLocale(); + std::string name = set->name[m_session->GetSessionDbcLocale()]; + if(name.empty()) + continue; + + if (!Utf8FitTo(name, wnamepart)) + { + loc = 0; + for(; loc < MAX_LOCALE; ++loc) + { + if(loc==m_session->GetSessionDbcLocale()) + continue; + + name = set->name[m_session->GetSessionDbcLocale()]; + if(name.empty()) + continue; + + if (Utf8FitTo(name, wnamepart)) + break; + } + } + + if(loc < MAX_LOCALE) + { + // send item set in "id - [namedlink locale]" format + PSendSysMessage(LANG_ITEMSET_LIST,id,id,name.c_str(),localeNames[loc]); + ++counter; + } + } + } + if (counter == 0) // if counter == 0 then we found nth + SendSysMessage(LANG_COMMAND_NOITEMSETFOUND); + return true; +} + +bool ChatHandler::HandleLookupSkillCommand(const char* args) +{ + Player* target = getSelectedPlayer(); + if(!target) + { + SendSysMessage(LANG_PLAYER_NOT_FOUND); + SetSentErrorMessage(true); + return false; + } + + if(!*args) + return false; + + std::string namepart = args; + std::wstring wnamepart; + + if(!Utf8toWStr(namepart,wnamepart)) + return false; + + // converting string that we try to find to lower case + wstrToLower( wnamepart ); + + uint32 counter = 0; // Counter for figure out that we found smth. + + // Search in SkillLine.dbc + for (uint32 id = 0; id < sSkillLineStore.GetNumRows(); id++) + { + SkillLineEntry const *skillInfo = sSkillLineStore.LookupEntry(id); + if(skillInfo) + { + int loc = m_session->GetSessionDbcLocale(); + std::string name = skillInfo->name[loc]; + if(name.empty()) + continue; + + if (!Utf8FitTo(name, wnamepart)) + { + loc = 0; + for(; loc < MAX_LOCALE; ++loc) + { + if(loc==m_session->GetSessionDbcLocale()) + continue; + + name = skillInfo->name[loc]; + if(name.empty()) + continue; + + if (Utf8FitTo(name, wnamepart)) + break; + } + } + + if(loc < MAX_LOCALE) + { + // send skill in "id - [namedlink locale]" format + PSendSysMessage(LANG_SKILL_LIST,id,id,name.c_str(),localeNames[loc],(target->HasSkill(id) ? m_session->GetMangosString(LANG_KNOWN) : "")); + + ++counter; + } + } + } + if (counter == 0) // if counter == 0 then we found nth + SendSysMessage(LANG_COMMAND_NOSKILLFOUND); + return true; +} + +bool ChatHandler::HandleLookupSpellCommand(const char* args) +{ + Player* target = getSelectedPlayer(); + if( !target ) + { + SendSysMessage(LANG_PLAYER_NOT_FOUND); + SetSentErrorMessage(true); + return false; + } + + if(!*args) + return false; + + std::string namepart = args; + std::wstring wnamepart; + + if(!Utf8toWStr(namepart,wnamepart)) + return false; + + // converting string that we try to find to lower case + wstrToLower( wnamepart ); + + uint32 counter = 0; // Counter for figure out that we found smth. + + // Search in Spell.dbc + for (uint32 id = 0; id < sSpellStore.GetNumRows(); id++) + { + SpellEntry const *spellInfo = sSpellStore.LookupEntry(id); + if(spellInfo) + { + int loc = m_session->GetSessionDbcLocale(); + std::string name = spellInfo->SpellName[loc]; + if(name.empty()) + continue; + + if (!Utf8FitTo(name, wnamepart)) + { + loc = 0; + for(; loc < MAX_LOCALE; ++loc) + { + if(loc==m_session->GetSessionDbcLocale()) + continue; + + name = spellInfo->SpellName[loc]; + if(name.empty()) + continue; + + if (Utf8FitTo(name, wnamepart)) + break; + } + } + + if(loc < MAX_LOCALE) + { + bool known = target->HasSpell(id); + bool learn = (spellInfo->Effect[0] == SPELL_EFFECT_LEARN_SPELL); + + uint32 telentCost = GetTalentSpellCost(id); + + bool talent = (telentCost > 0); + bool passive = IsPassiveSpell(id); + bool active = target->HasAura(id,0) || target->HasAura(id,1) || target->HasAura(id,2); + + // unit32 used to prevent interpreting uint8 as char at output + // find rank of learned spell for learning spell, or talent rank + uint32 rank = telentCost ? telentCost : spellmgr.GetSpellRank(learn ? spellInfo->EffectTriggerSpell[0] : id); + + // send spell in "id - [name, rank N] [talent] [passive] [learn] [known]" format + std::ostringstream ss; + ss << id << " - |cffffffff|Hspell:" << id << "|h[" << name; + + // include rank in link name + if(rank) + ss << GetMangosString(LANG_SPELL_RANK) << rank; + + ss << " " << localeNames[loc] << "]|h|r"; + + if(talent) + ss << GetMangosString(LANG_TALENT); + if(passive) + ss << GetMangosString(LANG_PASSIVE); + if(learn) + ss << GetMangosString(LANG_LEARN); + if(known) + ss << GetMangosString(LANG_KNOWN); + if(active) + ss << GetMangosString(LANG_ACTIVE); + + SendSysMessage(ss.str().c_str()); + + ++counter; + } + } + } + if (counter == 0) // if counter == 0 then we found nth + SendSysMessage(LANG_COMMAND_NOSPELLFOUND); + return true; +} + +bool ChatHandler::HandleLookupQuestCommand(const char* args) +{ + Player* target = getSelectedPlayer(); + if( !target ) + { + SendSysMessage(LANG_PLAYER_NOT_FOUND); + SetSentErrorMessage(true); + return false; + } + + if(!*args) + return false; + + std::string namepart = args; + std::wstring wnamepart; + + // converting string that we try to find to lower case + if(!Utf8toWStr(namepart,wnamepart)) + return false; + + wstrToLower(wnamepart); + + uint32 counter = 0 ; + + ObjectMgr::QuestMap const& qTemplates = objmgr.GetQuestTemplates(); + for (ObjectMgr::QuestMap::const_iterator iter = qTemplates.begin(); iter != qTemplates.end(); ++iter) + { + Quest * qinfo = iter->second; + + int loc_idx = m_session->GetSessionDbLocaleIndex(); + if ( loc_idx >= 0 ) + { + QuestLocale const *il = objmgr.GetQuestLocale(qinfo->GetQuestId()); + if (il) + { + if (il->Title.size() > loc_idx && !il->Title[loc_idx].empty()) + { + std::string title = il->Title[loc_idx]; + + if (Utf8FitTo(title, wnamepart)) + { + QuestStatus status = target->GetQuestStatus(qinfo->GetQuestId()); + + char const* statusStr = ""; + if(status == QUEST_STATUS_COMPLETE) + { + if(target->GetQuestRewardStatus(qinfo->GetQuestId())) + statusStr = GetMangosString(LANG_COMMAND_QUEST_REWARDED); + else + statusStr = GetMangosString(LANG_COMMAND_QUEST_COMPLETE); + } + else if(status == QUEST_STATUS_INCOMPLETE) + statusStr = GetMangosString(LANG_COMMAND_QUEST_ACTIVE); + + PSendSysMessage(LANG_QUEST_LIST,qinfo->GetQuestId(),qinfo->GetQuestId(),title.c_str(),(status == QUEST_STATUS_COMPLETE ? GetMangosString(LANG_COMPLETE) : (status == QUEST_STATUS_INCOMPLETE ? GetMangosString(LANG_ACTIVE) : "") )); + ++counter; + continue; + } + } + } + } + + std::string title = qinfo->GetTitle(); + if(title.empty()) + continue; + + if (Utf8FitTo(title, wnamepart)) + { + QuestStatus status = target->GetQuestStatus(qinfo->GetQuestId()); + + char const* statusStr = ""; + if(status == QUEST_STATUS_COMPLETE) + { + if(target->GetQuestRewardStatus(qinfo->GetQuestId())) + statusStr = GetMangosString(LANG_COMMAND_QUEST_REWARDED); + else + statusStr = GetMangosString(LANG_COMMAND_QUEST_COMPLETE); + } + else if(status == QUEST_STATUS_INCOMPLETE) + statusStr = GetMangosString(LANG_COMMAND_QUEST_ACTIVE); + + PSendSysMessage(LANG_QUEST_LIST,qinfo->GetQuestId(),qinfo->GetQuestId(), title.c_str(),(status == QUEST_STATUS_COMPLETE ? GetMangosString(LANG_COMPLETE) : (status == QUEST_STATUS_INCOMPLETE ? GetMangosString(LANG_ACTIVE) : "") )); + ++counter; + } + } + + if (counter==0) + SendSysMessage(LANG_COMMAND_NOQUESTFOUND); + + return true; +} + +bool ChatHandler::HandleLookupCreatureCommand(const char* args) +{ + if(!*args) + return false; + + std::string namepart = args; + std::wstring wnamepart; + + // converting string that we try to find to lower case + if(!Utf8toWStr(namepart,wnamepart)) + return false; + + wstrToLower(wnamepart); + + uint32 counter = 0; + + for (uint32 id = 0; id< sCreatureStorage.MaxEntry; id++ ) + { + CreatureInfo const* cInfo = sCreatureStorage.LookupEntry(id); + if(!cInfo) + continue; + + int loc_idx = m_session->GetSessionDbLocaleIndex(); + if ( loc_idx >= 0 ) + { + CreatureLocale const *cl = objmgr.GetCreatureLocale(id); + if (cl) + { + if (cl->Name.size() > loc_idx && !cl->Name[loc_idx].empty()) + { + std::string name = cl->Name[loc_idx]; + + if (Utf8FitTo(name, wnamepart)) + { + PSendSysMessage(LANG_CREATURE_ENTRY_LIST, id, id, name.c_str()); + ++counter; + continue; + } + } + } + } + + std::string name = cInfo->Name; + if(name.empty()) + continue; + + if (Utf8FitTo(name, wnamepart)) + { + PSendSysMessage(LANG_CREATURE_ENTRY_LIST,id,id,name.c_str()); + ++counter; + } + } + + if (counter==0) + SendSysMessage(LANG_COMMAND_NOCREATUREFOUND); + + return true; +} + +bool ChatHandler::HandleLookupObjectCommand(const char* args) +{ + if(!*args) + return false; + + std::string namepart = args; + std::wstring wnamepart; + + // converting string that we try to find to lower case + if(!Utf8toWStr(namepart,wnamepart)) + return false; + + wstrToLower(wnamepart); + + uint32 counter = 0; + + for (uint32 id = 0; id< sGOStorage.MaxEntry; id++ ) + { + GameObjectInfo const* gInfo = sGOStorage.LookupEntry(id); + if(!gInfo) + continue; + + int loc_idx = m_session->GetSessionDbLocaleIndex(); + if ( loc_idx >= 0 ) + { + GameObjectLocale const *gl = objmgr.GetGameObjectLocale(id); + if (gl) + { + if (gl->Name.size() > loc_idx && !gl->Name[loc_idx].empty()) + { + std::string name = gl->Name[loc_idx]; + + if (Utf8FitTo(name, wnamepart)) + { + PSendSysMessage(LANG_GO_ENTRY_LIST, id, id, name.c_str()); + ++counter; + continue; + } + } + } + } + + std::string name = gInfo->name; + if(name.empty()) + continue; + + if(Utf8FitTo(name, wnamepart)) + { + PSendSysMessage(LANG_GO_ENTRY_LIST, id, id, name.c_str()); + ++counter; + } + } + + if(counter==0) + SendSysMessage(LANG_COMMAND_NOGAMEOBJECTFOUND); + + return true; +} + +/** \brief GM command level 3 - Create a guild. + * + * This command allows a GM (level 3) to create a guild. + * + * The "args" parameter contains the name of the guild leader + * and then the name of the guild. + * + */ +bool ChatHandler::HandleGuildCreateCommand(const char* args) +{ + + if (!*args) + return false; + + Guild *guild; + Player * player; + char *lname,*gname; + std::string guildname; + + lname = strtok((char*)args, " "); + gname = strtok(NULL, ""); + + if(!lname) + return false; + else if(!gname) + { + SendSysMessage(LANG_INSERT_GUILD_NAME); + SetSentErrorMessage(true); + return false; + } + + guildname = gname; + player = ObjectAccessor::Instance().FindPlayerByName(lname); + + if(!player) + { + SendSysMessage(LANG_PLAYER_NOT_FOUND); + SetSentErrorMessage(true); + return false; + } + + if(!player->GetGuildId()) + { + guild = new Guild; + if(!guild->create(player->GetGUID(),guildname)) + { + delete guild; + SendSysMessage(LANG_GUILD_NOT_CREATED); + SetSentErrorMessage(true); + return false; + } + + objmgr.AddGuild(guild); + } + else + SendSysMessage(LANG_PLAYER_IN_GUILD); + + return true; +} + +bool ChatHandler::HandleGuildInviteCommand(const char *args) +{ + if(!*args) + return false; + + char* par1 = strtok((char*)args, " "); + char* par2 = strtok (NULL, ""); + if(!par1 || !par2) + return false; + + std::string glName = par2; + Guild* targetGuild = objmgr.GetGuildByName(glName); + if(!targetGuild) + return false; + + std::string plName = par1; + if(!normalizePlayerName(plName)) + { + SendSysMessage(LANG_PLAYER_NOT_FOUND); + SetSentErrorMessage(true); + return false; + } + + uint64 plGuid = 0; + if(Player* targetPlayer = ObjectAccessor::Instance().FindPlayerByName(plName.c_str())) + plGuid = targetPlayer->GetGUID(); + else + plGuid = objmgr.GetPlayerGUIDByName(plName.c_str()); + + if(!plGuid) + false; + + // players's guild membership checked in AddMember before add + if(!targetGuild->AddMember(plGuid,targetGuild->GetLowestRank())) + return false; + + return true; +} + +bool ChatHandler::HandleGuildUninviteCommand(const char *args) +{ + if(!*args) + return false; + + char* par1 = strtok((char*)args, " "); + if(!par1) + return false; + std::string plName = par1; + if(!normalizePlayerName(plName)) + { + SendSysMessage(LANG_PLAYER_NOT_FOUND); + SetSentErrorMessage(true); + return false; + } + + uint64 plGuid = 0; + uint32 glId = 0; + if(Player* targetPlayer = ObjectAccessor::Instance().FindPlayerByName(plName.c_str())) + { + plGuid = targetPlayer->GetGUID(); + glId = targetPlayer->GetGuildId(); + } + else + { + plGuid = objmgr.GetPlayerGUIDByName(plName.c_str()); + glId = Player::GetGuildIdFromDB(plGuid); + } + + if(!plGuid || !glId) + return false; + + Guild* targetGuild = objmgr.GetGuildById(glId); + if(!targetGuild) + return false; + + targetGuild->DelMember(plGuid); + + return true; +} + +bool ChatHandler::HandleGuildRankCommand(const char *args) +{ + if(!*args) + return false; + + char* par1 = strtok((char*)args, " "); + char* par2 = strtok(NULL, " "); + if(!par1 || !par2) + return false; + std::string plName = par1; + if(!normalizePlayerName(plName)) + { + SendSysMessage(LANG_PLAYER_NOT_FOUND); + SetSentErrorMessage(true); + return false; + } + + uint64 plGuid = 0; + uint32 glId = 0; + if(Player* targetPlayer = ObjectAccessor::Instance().FindPlayerByName(plName.c_str())) + { + plGuid = targetPlayer->GetGUID(); + glId = targetPlayer->GetGuildId(); + } + else + { + plGuid = objmgr.GetPlayerGUIDByName(plName.c_str()); + glId = Player::GetGuildIdFromDB(plGuid); + } + + if(!plGuid || !glId) + return false; + + Guild* targetGuild = objmgr.GetGuildById(glId); + if(!targetGuild) + return false; + + uint32 newrank = uint32(atoi(par2)); + if(newrank > targetGuild->GetLowestRank()) + return false; + + targetGuild->ChangeRank(plGuid,newrank); + + return true; +} + +bool ChatHandler::HandleGuildDeleteCommand(const char* args) +{ + if(!*args) + return false; + + char* par1 = strtok((char*)args, " "); + if(!par1) + return false; + + std::string gld = par1; + + Guild* targetGuild = objmgr.GetGuildByName(gld); + if(!targetGuild) + return false; + + targetGuild->Disband(); + + return true; +} + +bool ChatHandler::HandleGetDistanceCommand(const char* /*args*/) +{ + Unit* pUnit = getSelectedUnit(); + + if(!pUnit) + { + SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE); + SetSentErrorMessage(true); + return false; + } + + PSendSysMessage(LANG_DISTANCE, m_session->GetPlayer()->GetDistance(pUnit),m_session->GetPlayer()->GetDistance2d(pUnit)); + + return true; +} + +// FIX-ME!!! + +bool ChatHandler::HandleAddWeaponCommand(const char* /*args*/) +{ + /*if (!*args) + return false; + + uint64 guid = m_session->GetPlayer()->GetSelection(); + if (guid == 0) + { + SendSysMessage(LANG_NO_SELECTION); + return true; + } + + Creature *pCreature = ObjectAccessor::GetCreature(*m_session->GetPlayer(), guid); + + if(!pCreature) + { + SendSysMessage(LANG_SELECT_CREATURE); + return true; + } + + char* pSlotID = strtok((char*)args, " "); + if (!pSlotID) + return false; + + char* pItemID = strtok(NULL, " "); + if (!pItemID) + return false; + + uint32 ItemID = atoi(pItemID); + uint32 SlotID = atoi(pSlotID); + + ItemPrototype* tmpItem = objmgr.GetItemPrototype(ItemID); + + bool added = false; + if(tmpItem) + { + switch(SlotID) + { + case 1: + pCreature->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_DISPLAY, ItemID); + added = true; + break; + case 2: + pCreature->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_DISPLAY_01, ItemID); + added = true; + break; + case 3: + pCreature->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_DISPLAY_02, ItemID); + added = true; + break; + default: + PSendSysMessage(LANG_ITEM_SLOT_NOT_EXIST,SlotID); + added = false; + break; + } + if(added) + { + PSendSysMessage(LANG_ITEM_ADDED_TO_SLOT,ItemID,tmpItem->Name1,SlotID); + } + } + else + { + PSendSysMessage(LANG_ITEM_NOT_FOUND,ItemID); + return true; + } + */ + return true; +} + +bool ChatHandler::HandleDieCommand(const char* /*args*/) +{ + Unit* target = getSelectedUnit(); + + if(!target || !m_session->GetPlayer()->GetSelection()) + { + SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE); + SetSentErrorMessage(true); + return false; + } + + if( target->isAlive() ) + { + m_session->GetPlayer()->DealDamage(target, target->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); + } + + return true; +} + +bool ChatHandler::HandleDamageCommand(const char * args) +{ + if (!*args) + return false; + + Unit* target = getSelectedUnit(); + + if(!target || !m_session->GetPlayer()->GetSelection()) + { + SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE); + SetSentErrorMessage(true); + return false; + } + + if( !target->isAlive() ) + return true; + + char* damageStr = strtok((char*)args, " "); + if(!damageStr) + return false; + + int32 damage = atoi((char*)damageStr); + if(damage <=0) + return true; + + char* schoolStr = strtok((char*)NULL, " "); + + // flat melee damage without resistence/etc reduction + if(!schoolStr) + { + m_session->GetPlayer()->DealDamage(target, damage, NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); + m_session->GetPlayer()->SendAttackStateUpdate (HITINFO_NORMALSWING2, target, 1, SPELL_SCHOOL_MASK_NORMAL, damage, 0, 0, VICTIMSTATE_NORMAL, 0); + return true; + } + + uint32 school = schoolStr ? atoi((char*)schoolStr) : SPELL_SCHOOL_NORMAL; + if(school >= MAX_SPELL_SCHOOL) + return false; + + SpellSchoolMask schoolmask = SpellSchoolMask(1 << school); + + if ( schoolmask & SPELL_SCHOOL_MASK_NORMAL ) + damage = m_session->GetPlayer()->CalcArmorReducedDamage(target, damage); + + char* spellStr = strtok((char*)NULL, " "); + + // melee damage by specific school + if(!spellStr) + { + uint32 absorb = 0; + uint32 resist = 0; + + m_session->GetPlayer()->CalcAbsorbResist(target,schoolmask, SPELL_DIRECT_DAMAGE, damage, &absorb, &resist); + + if (damage <= absorb + resist) + return true; + + damage -= absorb + resist; + + m_session->GetPlayer()->DealDamage(target, damage, NULL, DIRECT_DAMAGE, schoolmask, NULL, false); + m_session->GetPlayer()->SendAttackStateUpdate (HITINFO_NORMALSWING2, target, 1, schoolmask, damage, absorb, resist, VICTIMSTATE_NORMAL, 0); + return true; + } + + // non-melee damage + + // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form + uint32 spellid = extractSpellIdFromLink((char*)args); + if(!spellid || !sSpellStore.LookupEntry(spellid)) + return false; + + m_session->GetPlayer()->SpellNonMeleeDamageLog(target, spellid, damage, false); + return true; +} + +bool ChatHandler::HandleModifyArenaCommand(const char * args) +{ + if (!*args) + return false; + + Player *target = getSelectedPlayer(); + if(!target) + { + SendSysMessage(LANG_PLAYER_NOT_FOUND); + SetSentErrorMessage(true); + return false; + } + + int32 amount = (uint32)atoi(args); + + target->ModifyArenaPoints(amount); + + PSendSysMessage(LANG_COMMAND_MODIFY_ARENA, target->GetName(), target->GetArenaPoints()); + + return true; +} + +bool ChatHandler::HandleReviveCommand(const char* args) +{ + Player* SelectedPlayer = NULL; + + if (*args) + { + std::string name = args; + if(!normalizePlayerName(name)) + { + SendSysMessage(LANG_PLAYER_NOT_FOUND); + SetSentErrorMessage(true); + return false; + } + + SelectedPlayer = objmgr.GetPlayer(name.c_str()); + } + else + SelectedPlayer = getSelectedPlayer(); + + if(!SelectedPlayer) + { + SendSysMessage(LANG_NO_CHAR_SELECTED); + SetSentErrorMessage(true); + return false; + } + + SelectedPlayer->ResurrectPlayer(0.5f); + SelectedPlayer->SpawnCorpseBones(); + SelectedPlayer->SaveToDB(); + return true; +} + +bool ChatHandler::HandleAuraCommand(const char* args) +{ + char* px = strtok((char*)args, " "); + if (!px) + return false; + + Unit *target = getSelectedUnit(); + if(!target) + { + SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE); + SetSentErrorMessage(true); + return false; + } + + uint32 spellID = (uint32)atoi(px); + SpellEntry const *spellInfo = sSpellStore.LookupEntry( spellID ); + if(spellInfo) + { + for(uint32 i = 0;i<3;i++) + { + uint8 eff = spellInfo->Effect[i]; + if (eff>=TOTAL_SPELL_EFFECTS) + continue; + if( IsAreaAuraEffect(eff) || + eff == SPELL_EFFECT_APPLY_AURA || + eff == SPELL_EFFECT_PERSISTENT_AREA_AURA ) + { + Aura *Aur = CreateAura(spellInfo, i, NULL, target); + target->AddAura(Aur); + } + } + } + + return true; +} + +bool ChatHandler::HandleUnAuraCommand(const char* args) +{ + char* px = strtok((char*)args, " "); + if (!px) + return false; + + Unit *target = getSelectedUnit(); + if(!target) + { + SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE); + SetSentErrorMessage(true); + return false; + } + + std::string argstr = args; + if (argstr == "all") + { + target->RemoveAllAuras(); + return true; + } + + uint32 spellID = (uint32)atoi(px); + target->RemoveAurasDueToSpell(spellID); + + return true; +} + +bool ChatHandler::HandleLinkGraveCommand(const char* args) +{ + if(!*args) + return false; + + char* px = strtok((char*)args, " "); + if (!px) + return false; + + uint32 g_id = (uint32)atoi(px); + + uint32 g_team; + + char* px2 = strtok(NULL, " "); + + if (!px2) + g_team = 0; + else if (strncmp(px2,"horde",6)==0) + g_team = HORDE; + else if (strncmp(px2,"alliance",9)==0) + g_team = ALLIANCE; + else + return false; + + WorldSafeLocsEntry const* graveyard = sWorldSafeLocsStore.LookupEntry(g_id); + + if(!graveyard ) + { + PSendSysMessage(LANG_COMMAND_GRAVEYARDNOEXIST, g_id); + SetSentErrorMessage(true); + return false; + } + + Player* player = m_session->GetPlayer(); + + uint32 zoneId = player->GetZoneId(); + + AreaTableEntry const *areaEntry = GetAreaEntryByAreaID(zoneId); + if(!areaEntry || areaEntry->zone !=0 ) + { + PSendSysMessage(LANG_COMMAND_GRAVEYARDWRONGZONE, g_id,zoneId); + SetSentErrorMessage(true); + return false; + } + + if(graveyard->map_id != areaEntry->mapid && g_team != 0) + { + SendSysMessage(LANG_COMMAND_GRAVEYARDWRONGTEAM); + SetSentErrorMessage(true); + return false; + } + + if(objmgr.AddGraveYardLink(g_id,player->GetZoneId(),g_team)) + PSendSysMessage(LANG_COMMAND_GRAVEYARDLINKED, g_id,zoneId); + else + PSendSysMessage(LANG_COMMAND_GRAVEYARDALRLINKED, g_id,zoneId); + + return true; +} + +bool ChatHandler::HandleNearGraveCommand(const char* args) +{ + uint32 g_team; + + size_t argslen = strlen(args); + + if(!*args) + g_team = 0; + else if (strncmp((char*)args,"horde",argslen)==0) + g_team = HORDE; + else if (strncmp((char*)args,"alliance",argslen)==0) + g_team = ALLIANCE; + else + return false; + + Player* player = m_session->GetPlayer(); + + WorldSafeLocsEntry const* graveyard = objmgr.GetClosestGraveYard( + player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(),player->GetMapId(),g_team); + + if(graveyard) + { + uint32 g_id = graveyard->ID; + + GraveYardData const* data = objmgr.FindGraveYardData(g_id,player->GetZoneId()); + if (!data) + { + PSendSysMessage(LANG_COMMAND_GRAVEYARDERROR,g_id); + SetSentErrorMessage(true); + return false; + } + + g_team = data->team; + + std::string team_name = GetMangosString(LANG_COMMAND_GRAVEYARD_NOTEAM); + + if(g_team == 0) + team_name = GetMangosString(LANG_COMMAND_GRAVEYARD_ANY); + else if(g_team == HORDE) + team_name = GetMangosString(LANG_COMMAND_GRAVEYARD_HORDE); + else if(g_team == ALLIANCE) + team_name = GetMangosString(LANG_COMMAND_GRAVEYARD_ALLIANCE); + + PSendSysMessage(LANG_COMMAND_GRAVEYARDNEAREST, g_id,team_name.c_str(),player->GetZoneId()); + } + else + { + std::string team_name; + + if(g_team == 0) + team_name = GetMangosString(LANG_COMMAND_GRAVEYARD_ANY); + else if(g_team == HORDE) + team_name = GetMangosString(LANG_COMMAND_GRAVEYARD_HORDE); + else if(g_team == ALLIANCE) + team_name = GetMangosString(LANG_COMMAND_GRAVEYARD_ALLIANCE); + + if(g_team == ~uint32(0)) + PSendSysMessage(LANG_COMMAND_ZONENOGRAVEYARDS, player->GetZoneId()); + else + PSendSysMessage(LANG_COMMAND_ZONENOGRAFACTION, player->GetZoneId(),team_name.c_str()); + } + + return true; +} + +bool ChatHandler::HandleSpawnTransportCommand(const char* /*args*/) +{ + return true; +} + +//play npc emote +bool ChatHandler::HandlePlayEmoteCommand(const char* args) +{ + uint32 emote = atoi((char*)args); + + Creature* target = getSelectedCreature(); + if(!target) + { + SendSysMessage(LANG_SELECT_CREATURE); + SetSentErrorMessage(true); + return false; + } + + target->SetUInt32Value(UNIT_NPC_EMOTESTATE,emote); + + return true; +} + +bool ChatHandler::HandleNpcInfoCommand(const char* /*args*/) +{ + Creature* target = getSelectedCreature(); + + if(!target) + { + SendSysMessage(LANG_SELECT_CREATURE); + SetSentErrorMessage(true); + return false; + } + + uint32 faction = target->getFaction(); + uint32 npcflags = target->GetUInt32Value(UNIT_NPC_FLAGS); + uint32 displayid = target->GetDisplayId(); + uint32 nativeid = target->GetNativeDisplayId(); + uint32 Entry = target->GetEntry(); + CreatureInfo const* cInfo = target->GetCreatureInfo(); + + int32 curRespawnDelay = target->GetRespawnTimeEx()-time(NULL); + if(curRespawnDelay < 0) + curRespawnDelay = 0; + std::string curRespawnDelayStr = secsToTimeString(curRespawnDelay,true); + std::string defRespawnDelayStr = secsToTimeString(target->GetRespawnDelay(),true); + + PSendSysMessage(LANG_NPCINFO_CHAR, target->GetDBTableGUIDLow(), faction, npcflags, Entry, displayid, nativeid); + PSendSysMessage(LANG_NPCINFO_LEVEL, target->getLevel()); + PSendSysMessage(LANG_NPCINFO_HEALTH,target->GetCreateHealth(), target->GetMaxHealth(), target->GetHealth()); + PSendSysMessage(LANG_NPCINFO_FLAGS, target->GetUInt32Value(UNIT_FIELD_FLAGS), target->GetUInt32Value(UNIT_DYNAMIC_FLAGS), target->getFaction()); + PSendSysMessage(LANG_COMMAND_RAWPAWNTIMES, defRespawnDelayStr.c_str(),curRespawnDelayStr.c_str()); + PSendSysMessage(LANG_NPCINFO_LOOT, cInfo->lootid,cInfo->pickpocketLootId,cInfo->SkinLootId); + PSendSysMessage(LANG_NPCINFO_DUNGEON_ID, target->GetInstanceId()); + PSendSysMessage(LANG_NPCINFO_POSITION,float(target->GetPositionX()), float(target->GetPositionY()), float(target->GetPositionZ())); + + if ((npcflags & UNIT_NPC_FLAG_VENDOR) ) + { + SendSysMessage(LANG_NPCINFO_VENDOR); + } + if ((npcflags & UNIT_NPC_FLAG_TRAINER) ) + { + SendSysMessage(LANG_NPCINFO_TRAINER); + } + + return true; +} + +bool ChatHandler::HandleExploreCheatCommand(const char* args) +{ + if (!*args) + return false; + + int flag = atoi((char*)args); + + Player *chr = getSelectedPlayer(); + if (chr == NULL) + { + SendSysMessage(LANG_NO_CHAR_SELECTED); + SetSentErrorMessage(true); + return false; + } + + if (flag != 0) + { + PSendSysMessage(LANG_YOU_SET_EXPLORE_ALL, chr->GetName()); + if(chr!=m_session->GetPlayer()) + ChatHandler(chr).PSendSysMessage(LANG_YOURS_EXPLORE_SET_ALL,m_session->GetPlayer()->GetName()); + } + else + { + PSendSysMessage(LANG_YOU_SET_EXPLORE_NOTHING, chr->GetName()); + if(chr!=m_session->GetPlayer()) + ChatHandler(chr).PSendSysMessage(LANG_YOURS_EXPLORE_SET_NOTHING,m_session->GetPlayer()->GetName()); + } + + for (uint8 i=0; i<128; i++) + { + if (flag != 0) + { + m_session->GetPlayer()->SetFlag(PLAYER_EXPLORED_ZONES_1+i,0xFFFFFFFF); + } + else + { + m_session->GetPlayer()->SetFlag(PLAYER_EXPLORED_ZONES_1+i,0); + } + } + + return true; +} + +bool ChatHandler::HandleHoverCommand(const char* args) +{ + char* px = strtok((char*)args, " "); + uint32 flag; + if (!px) + flag = 1; + else + flag = atoi(px); + + m_session->GetPlayer()->SetHover(flag); + + if (flag) + SendSysMessage(LANG_HOVER_ENABLED); + else + SendSysMessage(LANG_HOVER_DISABLED); + + return true; +} + +bool ChatHandler::HandleLevelUpCommand(const char* args) +{ + char* px = strtok((char*)args, " "); + char* py = strtok((char*)NULL, " "); + + // command format parsing + char* pname = (char*)NULL; + int addlevel = 1; + + if(px && py) // .levelup name level + { + addlevel = atoi(py); + pname = px; + } + else if(px && !py) // .levelup name OR .levelup level + { + if(isalpha(px[0])) // .levelup name + pname = px; + else // .levelup level + addlevel = atoi(px); + } + // else .levelup - nothing do for prepering + + // player + Player *chr = NULL; + uint64 chr_guid = 0; + + std::string name; + + if(pname) // player by name + { + name = pname; + if(!normalizePlayerName(name)) + { + SendSysMessage(LANG_PLAYER_NOT_FOUND); + SetSentErrorMessage(true); + return false; + } + + chr = objmgr.GetPlayer(name.c_str()); + if(!chr) // not in game + { + chr_guid = objmgr.GetPlayerGUIDByName(name); + if (chr_guid == 0) + { + SendSysMessage(LANG_PLAYER_NOT_FOUND); + SetSentErrorMessage(true); + return false; + } + } + } + else // player by selection + { + chr = getSelectedPlayer(); + + if (chr == NULL) + { + SendSysMessage(LANG_NO_CHAR_SELECTED); + SetSentErrorMessage(true); + return false; + } + + name = chr->GetName(); + } + + assert(chr || chr_guid); + + int32 oldlevel = chr ? chr->getLevel() : Player::GetUInt32ValueFromDB(UNIT_FIELD_LEVEL,chr_guid); + int32 newlevel = oldlevel + addlevel; + if(newlevel < 1) + newlevel = 1; + if(newlevel > 255) // hardcoded maximum level + newlevel = 255; + + if(chr) + { + chr->GiveLevel(newlevel); + chr->InitTalentForLevel(); + chr->SetUInt32Value(PLAYER_XP,0); + + if(oldlevel == newlevel) + ChatHandler(chr).SendSysMessage(LANG_YOURS_LEVEL_PROGRESS_RESET); + else + if(oldlevel < newlevel) + ChatHandler(chr).PSendSysMessage(LANG_YOURS_LEVEL_UP,newlevel-oldlevel); + else + if(oldlevel > newlevel) + ChatHandler(chr).PSendSysMessage(LANG_YOURS_LEVEL_DOWN,newlevel-oldlevel); + } + else + { + // update levle and XP at level, all other will be updated at loading + Tokens values; + Player::LoadValuesArrayFromDB(values,chr_guid); + Player::SetUInt32ValueInArray(values,UNIT_FIELD_LEVEL,newlevel); + Player::SetUInt32ValueInArray(values,PLAYER_XP,0); + Player::SaveValuesArrayInDB(values,chr_guid); + } + + if(m_session->GetPlayer() != chr) // including chr==NULL + PSendSysMessage(LANG_YOU_CHANGE_LVL,name.c_str(),newlevel); + return true; +} + +bool ChatHandler::HandleShowAreaCommand(const char* args) +{ + if (!*args) + return false; + + int area = atoi((char*)args); + + Player *chr = getSelectedPlayer(); + if (chr == NULL) + { + SendSysMessage(LANG_NO_CHAR_SELECTED); + SetSentErrorMessage(true); + return false; + } + + int offset = area / 32; + uint32 val = (uint32)(1 << (area % 32)); + + if(offset >= 128) + { + SendSysMessage(LANG_BAD_VALUE); + SetSentErrorMessage(true); + return false; + } + + uint32 currFields = chr->GetUInt32Value(PLAYER_EXPLORED_ZONES_1 + offset); + chr->SetUInt32Value(PLAYER_EXPLORED_ZONES_1 + offset, (uint32)(currFields | val)); + + SendSysMessage(LANG_EXPLORE_AREA); + return true; +} + +bool ChatHandler::HandleHideAreaCommand(const char* args) +{ + if (!*args) + return false; + + int area = atoi((char*)args); + + Player *chr = getSelectedPlayer(); + if (chr == NULL) + { + SendSysMessage(LANG_NO_CHAR_SELECTED); + SetSentErrorMessage(true); + return false; + } + + int offset = area / 32; + uint32 val = (uint32)(1 << (area % 32)); + + if(offset >= 128) + { + SendSysMessage(LANG_BAD_VALUE); + SetSentErrorMessage(true); + return false; + } + + uint32 currFields = chr->GetUInt32Value(PLAYER_EXPLORED_ZONES_1 + offset); + chr->SetUInt32Value(PLAYER_EXPLORED_ZONES_1 + offset, (uint32)(currFields ^ val)); + + SendSysMessage(LANG_UNEXPLORE_AREA); + return true; +} + +bool ChatHandler::HandleUpdate(const char* args) +{ + if(!*args) + return false; + + uint32 updateIndex; + uint32 value; + + char* pUpdateIndex = strtok((char*)args, " "); + + Unit* chr = getSelectedUnit(); + if (chr == NULL) + { + SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE); + SetSentErrorMessage(true); + return false; + } + + if(!pUpdateIndex) + { + return true; + } + updateIndex = atoi(pUpdateIndex); + //check updateIndex + if(chr->GetTypeId() == TYPEID_PLAYER) + { + if (updateIndex>=PLAYER_END) return true; + } + else + { + if (updateIndex>=UNIT_END) return true; + } + + char* pvalue = strtok(NULL, " "); + if (!pvalue) + { + value=chr->GetUInt32Value(updateIndex); + + PSendSysMessage(LANG_UPDATE, chr->GetGUIDLow(),updateIndex,value); + return true; + } + + value=atoi(pvalue); + + PSendSysMessage(LANG_UPDATE_CHANGE, chr->GetGUIDLow(),updateIndex,value); + + chr->SetUInt32Value(updateIndex,value); + + return true; +} + +bool ChatHandler::HandleBankCommand(const char* /*args*/) +{ + m_session->SendShowBank( m_session->GetPlayer()->GetGUID() ); + + return true; +} + +bool ChatHandler::HandleChangeWeather(const char* args) +{ + if(!*args) + return false; + + //Weather is OFF + if (!sWorld.getConfig(CONFIG_WEATHER)) + { + SendSysMessage(LANG_WEATHER_DISABLED); + SetSentErrorMessage(true); + return false; + } + + //*Change the weather of a cell + char* px = strtok((char*)args, " "); + char* py = strtok(NULL, " "); + + if (!px || !py) + return false; + + uint32 type = (uint32)atoi(px); //0 to 3, 0: fine, 1: rain, 2: snow, 3: sand + float grade = (float)atof(py); //0 to 1, sending -1 is instand good weather + + Player *player = m_session->GetPlayer(); + uint32 zoneid = player->GetZoneId(); + + Weather* wth = sWorld.FindWeather(zoneid); + + if(!wth) + wth = sWorld.AddWeather(zoneid); + if(!wth) + { + SendSysMessage(LANG_NO_WEATHER); + SetSentErrorMessage(true); + return false; + } + + wth->SetWeather(WeatherType(type), grade); + + return true; +} + +bool ChatHandler::HandleSetValue(const char* args) +{ + if(!*args) + return false; + + char* px = strtok((char*)args, " "); + char* py = strtok(NULL, " "); + char* pz = strtok(NULL, " "); + + if (!px || !py) + return false; + + Unit* target = getSelectedUnit(); + if(!target) + { + SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE); + SetSentErrorMessage(true); + return false; + } + + uint64 guid = target->GetGUID(); + + uint32 Opcode = (uint32)atoi(px); + if(Opcode >= target->GetValuesCount()) + { + PSendSysMessage(LANG_TOO_BIG_INDEX, Opcode, GUID_LOPART(guid), target->GetValuesCount()); + return false; + } + uint32 iValue; + float fValue; + bool isint32 = true; + if(pz) + isint32 = (bool)atoi(pz); + if(isint32) + { + iValue = (uint32)atoi(py); + sLog.outDebug(GetMangosString(LANG_SET_UINT), GUID_LOPART(guid), Opcode, iValue); + target->SetUInt32Value( Opcode , iValue ); + PSendSysMessage(LANG_SET_UINT_FIELD, GUID_LOPART(guid), Opcode,iValue); + } + else + { + fValue = (float)atof(py); + sLog.outDebug(GetMangosString(LANG_SET_FLOAT), GUID_LOPART(guid), Opcode, fValue); + target->SetFloatValue( Opcode , fValue ); + PSendSysMessage(LANG_SET_FLOAT_FIELD, GUID_LOPART(guid), Opcode,fValue); + } + + return true; +} + +bool ChatHandler::HandleGetValue(const char* args) +{ + if(!*args) + return false; + + char* px = strtok((char*)args, " "); + char* pz = strtok(NULL, " "); + + if (!px) + return false; + + Unit* target = getSelectedUnit(); + if(!target) + { + SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE); + SetSentErrorMessage(true); + return false; + } + + uint64 guid = target->GetGUID(); + + uint32 Opcode = (uint32)atoi(px); + if(Opcode >= target->GetValuesCount()) + { + PSendSysMessage(LANG_TOO_BIG_INDEX, Opcode, GUID_LOPART(guid), target->GetValuesCount()); + return false; + } + uint32 iValue; + float fValue; + bool isint32 = true; + if(pz) + isint32 = (bool)atoi(pz); + + if(isint32) + { + iValue = target->GetUInt32Value( Opcode ); + sLog.outDebug(GetMangosString(LANG_GET_UINT), GUID_LOPART(guid), Opcode, iValue); + PSendSysMessage(LANG_GET_UINT_FIELD, GUID_LOPART(guid), Opcode, iValue); + } + else + { + fValue = target->GetFloatValue( Opcode ); + sLog.outDebug(GetMangosString(LANG_GET_FLOAT), GUID_LOPART(guid), Opcode, fValue); + PSendSysMessage(LANG_GET_FLOAT_FIELD, GUID_LOPART(guid), Opcode, fValue); + } + + return true; +} + +bool ChatHandler::HandleSet32Bit(const char* args) +{ + if(!*args) + return false; + + char* px = strtok((char*)args, " "); + char* py = strtok(NULL, " "); + + if (!px || !py) + return false; + + uint32 Opcode = (uint32)atoi(px); + uint32 Value = (uint32)atoi(py); + if (Value > 32) //uint32 = 32 bits + return false; + + sLog.outDebug(GetMangosString(LANG_SET_32BIT), Opcode, Value); + + m_session->GetPlayer( )->SetUInt32Value( Opcode , 2^Value ); + + PSendSysMessage(LANG_SET_32BIT_FIELD, Opcode,1); + return true; +} + +bool ChatHandler::HandleMod32Value(const char* args) +{ + if(!*args) + return false; + + char* px = strtok((char*)args, " "); + char* py = strtok(NULL, " "); + + if (!px || !py) + return false; + + uint32 Opcode = (uint32)atoi(px); + int Value = atoi(py); + + if(Opcode >= m_session->GetPlayer()->GetValuesCount()) + { + PSendSysMessage(LANG_TOO_BIG_INDEX, Opcode, m_session->GetPlayer()->GetGUIDLow(), m_session->GetPlayer( )->GetValuesCount()); + return false; + } + + sLog.outDebug(GetMangosString(LANG_CHANGE_32BIT), Opcode, Value); + + int CurrentValue = (int)m_session->GetPlayer( )->GetUInt32Value( Opcode ); + + CurrentValue += Value; + m_session->GetPlayer( )->SetUInt32Value( Opcode , (uint32)CurrentValue ); + + PSendSysMessage(LANG_CHANGE_32BIT_FIELD, Opcode,CurrentValue); + + return true; +} + +bool ChatHandler::HandleAddTeleCommand(const char * args) +{ + if(!*args) + return false; + + Player *player=m_session->GetPlayer(); + if (!player) + return false; + + std::string name = args; + + if(objmgr.GetGameTele(name)) + { + SendSysMessage(LANG_COMMAND_TP_ALREADYEXIST); + SetSentErrorMessage(true); + return false; + } + + GameTele tele; + tele.position_x = player->GetPositionX(); + tele.position_y = player->GetPositionY(); + tele.position_z = player->GetPositionZ(); + tele.orientation = player->GetOrientation(); + tele.mapId = player->GetMapId(); + tele.name = name; + + if(objmgr.AddGameTele(tele)) + { + SendSysMessage(LANG_COMMAND_TP_ADDED); + } + else + { + SendSysMessage(LANG_COMMAND_TP_ADDEDERR); + SetSentErrorMessage(true); + return false; + } + + return true; +} + +bool ChatHandler::HandleDelTeleCommand(const char * args) +{ + if(!*args) + return false; + + std::string name = args; + + if(!objmgr.DeleteGameTele(name)) + { + SendSysMessage(LANG_COMMAND_TELE_NOTFOUND); + SetSentErrorMessage(true); + return false; + } + + SendSysMessage(LANG_COMMAND_TP_DELETED); + return true; +} + +bool ChatHandler::HandleListAurasCommand (const char * /*args*/) +{ + Unit *unit = getSelectedUnit(); + if(!unit) + { + SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE); + SetSentErrorMessage(true); + return false; + } + + char const* talentStr = GetMangosString(LANG_TALENT); + char const* passiveStr = GetMangosString(LANG_PASSIVE); + + Unit::AuraMap const& uAuras = unit->GetAuras(); + PSendSysMessage(LANG_COMMAND_TARGET_LISTAURAS, uAuras.size()); + for (Unit::AuraMap::const_iterator itr = uAuras.begin(); itr != uAuras.end(); ++itr) + { + bool talent = GetTalentSpellCost(itr->second->GetId()) > 0; + PSendSysMessage(LANG_COMMAND_TARGET_AURADETAIL, itr->second->GetId(), itr->second->GetEffIndex(), + itr->second->GetModifier()->m_auraname, itr->second->GetAuraDuration(), itr->second->GetAuraMaxDuration(), + itr->second->GetSpellProto()->SpellName[m_session->GetSessionDbcLocale()], + (itr->second->IsPassive() ? passiveStr : ""),(talent ? talentStr : ""), + IS_PLAYER_GUID(itr->second->GetCasterGUID()) ? "player" : "creature",GUID_LOPART(itr->second->GetCasterGUID())); + } + for (int i = 0; i < TOTAL_AURAS; i++) + { + Unit::AuraList const& uAuraList = unit->GetAurasByType(AuraType(i)); + if (uAuraList.empty()) continue; + PSendSysMessage(LANG_COMMAND_TARGET_LISTAURATYPE, uAuraList.size(), i); + for (Unit::AuraList::const_iterator itr = uAuraList.begin(); itr != uAuraList.end(); ++itr) + { + bool talent = GetTalentSpellCost((*itr)->GetId()) > 0; + PSendSysMessage(LANG_COMMAND_TARGET_AURASIMPLE, (*itr)->GetId(), (*itr)->GetEffIndex(), + (*itr)->GetSpellProto()->SpellName[m_session->GetSessionDbcLocale()],((*itr)->IsPassive() ? passiveStr : ""),(talent ? talentStr : ""), + IS_PLAYER_GUID((*itr)->GetCasterGUID()) ? "player" : "creature",GUID_LOPART((*itr)->GetCasterGUID())); + } + } + return true; +} + +bool ChatHandler::HandleResetHonorCommand (const char * args) +{ + char* pName = strtok((char*)args, ""); + Player *player = NULL; + if (pName) + { + std::string name = pName; + if(!normalizePlayerName(name)) + { + SendSysMessage(LANG_PLAYER_NOT_FOUND); + SetSentErrorMessage(true); + return false; + } + + uint64 guid = objmgr.GetPlayerGUIDByName(name.c_str()); + player = objmgr.GetPlayer(guid); + } + else + player = getSelectedPlayer(); + + if(!player) + { + SendSysMessage(LANG_NO_CHAR_SELECTED); + return true; + } + + player->SetUInt32Value(PLAYER_FIELD_KILLS, 0); + player->SetUInt32Value(PLAYER_FIELD_LIFETIME_HONORBALE_KILLS, 0); + player->SetUInt32Value(PLAYER_FIELD_HONOR_CURRENCY, 0); + player->SetUInt32Value(PLAYER_FIELD_TODAY_CONTRIBUTION, 0); + player->SetUInt32Value(PLAYER_FIELD_YESTERDAY_CONTRIBUTION, 0); + + return true; +} + +static bool HandleResetStatsOrLevelHelper(Player* player) +{ + PlayerInfo const *info = objmgr.GetPlayerInfo(player->getRace(), player->getClass()); + if(!info) return false; + + ChrClassesEntry const* cEntry = sChrClassesStore.LookupEntry(player->getClass()); + if(!cEntry) + { + sLog.outError("Class %u not found in DBC (Wrong DBC files?)",player->getClass()); + return false; + } + + uint8 powertype = cEntry->powerType; + + uint32 unitfield; + if(powertype == POWER_RAGE) + unitfield = 0x1100EE00; + else if(powertype == POWER_ENERGY) + unitfield = 0x00000000; + else if(powertype == POWER_MANA) + unitfield = 0x0000EE00; + else + { + sLog.outError("Invalid default powertype %u for player (class %u)",powertype,player->getClass()); + return false; + } + + // reset m_form if no aura + if(!player->HasAuraType(SPELL_AURA_MOD_SHAPESHIFT)) + player->m_form = FORM_NONE; + + player->SetFloatValue(UNIT_FIELD_BOUNDINGRADIUS, DEFAULT_WORLD_OBJECT_SIZE ); + player->SetFloatValue(UNIT_FIELD_COMBATREACH, 1.5f ); + + player->setFactionForRace(player->getRace()); + + player->SetUInt32Value(UNIT_FIELD_BYTES_0, ( ( player->getRace() ) | ( player->getClass() << 8 ) | ( player->getGender() << 16 ) | ( powertype << 24 ) ) ); + + // reset only if player not in some form; + if(player->m_form==FORM_NONE) + { + switch(player->getGender()) + { + case GENDER_FEMALE: + player->SetDisplayId(info->displayId_f); + player->SetNativeDisplayId(info->displayId_f); + break; + case GENDER_MALE: + player->SetDisplayId(info->displayId_m); + player->SetNativeDisplayId(info->displayId_m); + break; + default: + break; + } + } + + // set UNIT_FIELD_BYTES_1 to init state but preserve m_form value + player->SetUInt32Value(UNIT_FIELD_BYTES_1, unitfield); + player->SetByteValue(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_UNK3 | UNIT_BYTE2_FLAG_UNK5 ); + player->SetByteValue(UNIT_FIELD_BYTES_2, 3, player->m_form); + + player->SetUInt32Value(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE); + + //-1 is default value + player->SetUInt32Value(PLAYER_FIELD_WATCHED_FACTION_INDEX, uint32(-1)); + + //player->SetUInt32Value(PLAYER_FIELD_BYTES, 0xEEE00000 ); + return true; +} + +bool ChatHandler::HandleResetLevelCommand(const char * args) +{ + char* pName = strtok((char*)args, ""); + Player *player = NULL; + if (pName) + { + std::string name = pName; + if(!normalizePlayerName(name)) + { + SendSysMessage(LANG_PLAYER_NOT_FOUND); + SetSentErrorMessage(true); + return false; + } + + uint64 guid = objmgr.GetPlayerGUIDByName(name.c_str()); + player = objmgr.GetPlayer(guid); + } + else + player = getSelectedPlayer(); + + if(!player) + { + SendSysMessage(LANG_NO_CHAR_SELECTED); + SetSentErrorMessage(true); + return false; + } + + if(!HandleResetStatsOrLevelHelper(player)) + return false; + + player->SetLevel(1); + player->InitStatsForLevel(true); + player->InitTaxiNodesForLevel(); + player->InitTalentForLevel(); + player->SetUInt32Value(PLAYER_XP,0); + + // reset level to summoned pet + Pet* pet = player->GetPet(); + if(pet && pet->getPetType()==SUMMON_PET) + pet->InitStatsForLevel(1); + + return true; +} + +bool ChatHandler::HandleResetStatsCommand(const char * args) +{ + char* pName = strtok((char*)args, ""); + Player *player = NULL; + if (pName) + { + std::string name = pName; + if(!normalizePlayerName(name)) + { + SendSysMessage(LANG_PLAYER_NOT_FOUND); + SetSentErrorMessage(true); + return false; + } + + uint64 guid = objmgr.GetPlayerGUIDByName(name.c_str()); + player = objmgr.GetPlayer(guid); + } + else + player = getSelectedPlayer(); + + if(!player) + { + SendSysMessage(LANG_NO_CHAR_SELECTED); + SetSentErrorMessage(true); + return false; + } + + if(!HandleResetStatsOrLevelHelper(player)) + return false; + + player->InitStatsForLevel(true); + player->InitTaxiNodesForLevel(); + player->InitTalentForLevel(); + + return true; +} + +bool ChatHandler::HandleResetSpellsCommand(const char * args) +{ + char* pName = strtok((char*)args, ""); + Player *player = NULL; + uint64 playerGUID = 0; + if (pName) + { + std::string name = pName; + + if(!normalizePlayerName(name)) + { + SendSysMessage(LANG_PLAYER_NOT_FOUND); + SetSentErrorMessage(true); + return false; + } + + player = objmgr.GetPlayer(name.c_str()); + if(!player) + playerGUID = objmgr.GetPlayerGUIDByName(name.c_str()); + } + else + player = getSelectedPlayer(); + + if(!player && !playerGUID) + { + SendSysMessage(LANG_NO_CHAR_SELECTED); + SetSentErrorMessage(true); + return false; + } + + if(player) + { + player->resetSpells(); + + ChatHandler(player).SendSysMessage(LANG_RESET_SPELLS); + + if(m_session->GetPlayer()!=player) + PSendSysMessage(LANG_RESET_SPELLS_ONLINE,player->GetName()); + } + else + { + CharacterDatabase.PExecute("UPDATE characters SET at_login = at_login | '%u' WHERE guid = '%u'",uint32(AT_LOGIN_RESET_SPELLS), GUID_LOPART(playerGUID)); + PSendSysMessage(LANG_RESET_SPELLS_OFFLINE,pName); + } + + return true; +} + +bool ChatHandler::HandleResetTalentsCommand(const char * args) +{ + char* pName = strtok((char*)args, ""); + Player *player = NULL; + uint64 playerGUID = 0; + if (pName) + { + std::string name = pName; + if(!normalizePlayerName(name)) + { + SendSysMessage(LANG_PLAYER_NOT_FOUND); + SetSentErrorMessage(true); + return false; + } + + player = objmgr.GetPlayer(name.c_str()); + if(!player) + playerGUID = objmgr.GetPlayerGUIDByName(name.c_str()); + } + else + player = getSelectedPlayer(); + + if(!player && !playerGUID) + { + SendSysMessage(LANG_NO_CHAR_SELECTED); + SetSentErrorMessage(true); + return false; + } + + if(player) + { + player->resetTalents(true); + + ChatHandler(player).SendSysMessage(LANG_RESET_TALENTS); + + if(m_session->GetPlayer()!=player) + PSendSysMessage(LANG_RESET_TALENTS_ONLINE,player->GetName()); + } + else + { + CharacterDatabase.PExecute("UPDATE characters SET at_login = at_login | '%u' WHERE guid = '%u'",uint32(AT_LOGIN_RESET_TALENTS), GUID_LOPART(playerGUID) ); + PSendSysMessage(LANG_RESET_TALENTS_OFFLINE,pName); + } + + return true; +} + +bool ChatHandler::HandleResetAllCommand(const char * args) +{ + if(!*args) + return false; + + std::string casename = args; + + AtLoginFlags atLogin; + + // Command specially created as single command to prevent using short case names + if(casename=="spells") + { + atLogin = AT_LOGIN_RESET_SPELLS; + sWorld.SendWorldText(LANG_RESETALL_SPELLS); + } + else if(casename=="talents") + { + atLogin = AT_LOGIN_RESET_TALENTS; + sWorld.SendWorldText(LANG_RESETALL_TALENTS); + } + else + { + PSendSysMessage(LANG_RESETALL_UNKNOWN_CASE,args); + SetSentErrorMessage(true); + return false; + } + + CharacterDatabase.PExecute("UPDATE characters SET at_login = at_login | '%u'",atLogin); + HashMapHolder::MapType const& plist = ObjectAccessor::Instance().GetPlayers(); + for(HashMapHolder::MapType::const_iterator itr = plist.begin(); itr != plist.end(); ++itr) + itr->second->SetAtLoginFlag(atLogin); + + return true; +} + +bool ChatHandler::HandleShutDownCommand(const char* args) +{ + if(!*args) + return false; + + if(std::string(args)=="cancel") + { + sWorld.ShutdownCancel(); + } + else + { + int32 time = atoi(args); + + ///- Prevent interpret wrong arg value as 0 secs shutdown time + if(time == 0 && (args[0]!='0' || args[1]!='\0') || time < 0) + return false; + + sWorld.ShutdownServ(time); + } + return true; +} + +bool ChatHandler::HandleRestartCommand(const char* args) +{ + if(!*args) + return false; + + if(std::string(args)=="cancel") + { + sWorld.ShutdownCancel(); + } + else + { + int32 time = atoi(args); + + ///- Prevent interpret wrong arg value as 0 secs shutdown time + if(time == 0 && (args[0]!='0' || args[1]!='\0') || time < 0) + return false; + + sWorld.ShutdownServ(time, SHUTDOWN_MASK_RESTART); + } + return true; +} + +bool ChatHandler::HandleIdleRestartCommand(const char* args) +{ + if(!*args) + return false; + + if(std::string(args)=="cancel") + { + sWorld.ShutdownCancel(); + } + else + { + int32 time = atoi(args); + + ///- Prevent interpret wrong arg value as 0 secs shutdown time + if(time == 0 && (args[0]!='0' || args[1]!='\0') || time < 0) + return false; + + sWorld.ShutdownServ(time,SHUTDOWN_MASK_RESTART+SHUTDOWN_MASK_IDLE); + } + return true; +} + +bool ChatHandler::HandleIdleShutDownCommand(const char* args) +{ + if(!*args) + return false; + + if(std::string(args)=="cancel") + { + sWorld.ShutdownCancel(); + } + else + { + int32 time = atoi(args); + + ///- Prevent interpret wrong arg value as 0 secs shutdown time + if(time == 0 && (args[0]!='0' || args[1]!='\0') || time < 0) + return false; + + sWorld.ShutdownServ(time,SHUTDOWN_MASK_IDLE); + } + return true; +} + +bool ChatHandler::HandleAddQuest(const char* args) +{ + Player* player = getSelectedPlayer(); + if(!player) + { + SendSysMessage(LANG_NO_CHAR_SELECTED); + SetSentErrorMessage(true); + return false; + } + + // .addquest #entry' + // number or [name] Shift-click form |color|Hquest:quest_id|h[name]|h|r + char* cId = extractKeyFromLink((char*)args,"Hquest"); + if(!cId) + return false; + + uint32 entry = atol(cId); + + Quest const* pQuest = objmgr.GetQuestTemplate(entry); + + if(!pQuest) + { + PSendSysMessage(LANG_COMMAND_QUEST_NOTFOUND,entry); + SetSentErrorMessage(true); + return false; + } + + // check item starting quest (it can work incorrectly if added without item in inventory) + QueryResult *result = WorldDatabase.PQuery("SELECT entry FROM item_template WHERE startquest = '%u' LIMIT 1",entry); + if(result) + { + Field* fields = result->Fetch(); + uint32 item_id = fields[0].GetUInt32(); + delete result; + + PSendSysMessage(LANG_COMMAND_QUEST_STARTFROMITEM, entry,item_id); + SetSentErrorMessage(true); + return false; + } + + // ok, normal (creature/GO starting) quest + if( player->CanAddQuest( pQuest, true ) ) + { + player->AddQuest( pQuest, NULL ); + + if ( player->CanCompleteQuest( entry ) ) + player->CompleteQuest( entry ); + } + + return true; +} + +bool ChatHandler::HandleRemoveQuest(const char* args) +{ + Player* player = getSelectedPlayer(); + if(!player) + { + SendSysMessage(LANG_NO_CHAR_SELECTED); + SetSentErrorMessage(true); + return false; + } + + // .removequest #entry' + // number or [name] Shift-click form |color|Hquest:quest_id|h[name]|h|r + char* cId = extractKeyFromLink((char*)args,"Hquest"); + if(!cId) + return false; + + uint32 entry = atol(cId); + + Quest const* pQuest = objmgr.GetQuestTemplate(entry); + + if(!pQuest) + { + PSendSysMessage(LANG_COMMAND_QUEST_NOTFOUND, entry); + SetSentErrorMessage(true); + return false; + } + + // remove all quest entries for 'entry' from quest log + for(uint8 slot = 0; slot < MAX_QUEST_LOG_SIZE; ++slot ) + { + uint32 quest = player->GetQuestSlotQuestId(slot); + if(quest==entry) + { + player->SetQuestSlot(slot,0); + + // we ignore unequippable quest items in this case, its' still be equipped + player->TakeQuestSourceItem( quest, false ); + } + } + + // set quest status to not started (will updated in DB at next save) + player->SetQuestStatus( entry, QUEST_STATUS_NONE); + + // reset rewarded for restart repeatable quest + player->getQuestStatusMap()[entry].m_rewarded = false; + + SendSysMessage(LANG_COMMAND_QUEST_REMOVED); + return true; +} + +bool ChatHandler::HandleCompleteQuest(const char* args) +{ + Player* player = getSelectedPlayer(); + if(!player) + { + SendSysMessage(LANG_NO_CHAR_SELECTED); + SetSentErrorMessage(true); + return false; + } + + // .quest complete #entry + // number or [name] Shift-click form |color|Hquest:quest_id|h[name]|h|r + char* cId = extractKeyFromLink((char*)args,"Hquest"); + if(!cId) + return false; + + uint32 entry = atol(cId); + + Quest const* pQuest = objmgr.GetQuestTemplate(entry); + + // If player doesn't have the quest + if(!pQuest || player->GetQuestStatus(entry) == QUEST_STATUS_NONE) + { + PSendSysMessage(LANG_COMMAND_QUEST_NOTFOUND, entry); + SetSentErrorMessage(true); + return false; + } + + // Add quest items for quests that require items + for(uint8 x = 0; x < QUEST_OBJECTIVES_COUNT; ++x) + { + uint32 id = pQuest->ReqItemId[x]; + uint32 count = pQuest->ReqItemCount[x]; + if(!id || !count) + continue; + + uint32 curItemCount = player->GetItemCount(id,true); + + ItemPosCountVec dest; + uint8 msg = player->CanStoreNewItem( NULL_BAG, NULL_SLOT, dest, id, count-curItemCount ); + if( msg == EQUIP_ERR_OK ) + { + Item* item = player->StoreNewItem( dest, id, true); + player->SendNewItem(item,count-curItemCount,true,false); + } + } + + // All creature/GO slain/casted (not required, but otherwise it will display "Creature slain 0/10") + for(uint8 i = 0; i < QUEST_OBJECTIVES_COUNT; i++) + { + uint32 creature = pQuest->ReqCreatureOrGOId[i]; + uint32 creaturecount = pQuest->ReqCreatureOrGOCount[i]; + + if(uint32 spell_id = pQuest->ReqSpell[i]) + { + for(uint16 z = 0; z < creaturecount; ++z) + player->CastedCreatureOrGO(creature,0,spell_id); + } + else if(creature > 0) + { + for(uint16 z = 0; z < creaturecount; ++z) + player->KilledMonster(creature,0); + } + else if(creature < 0) + { + for(uint16 z = 0; z < creaturecount; ++z) + player->CastedCreatureOrGO(creature,0,0); + } + } + + // If the quest requires reputation to complete + if(uint32 repFaction = pQuest->GetRepObjectiveFaction()) + { + uint32 repValue = pQuest->GetRepObjectiveValue(); + uint32 curRep = player->GetReputation(repFaction); + if(curRep < repValue) + { + FactionEntry const *factionEntry = sFactionStore.LookupEntry(repFaction); + player->SetFactionReputation(factionEntry,repValue); + } + } + + // If the quest requires money + int32 ReqOrRewMoney = pQuest->GetRewOrReqMoney(); + if(ReqOrRewMoney < 0) + player->ModifyMoney(-ReqOrRewMoney); + + player->CompleteQuest(entry); + return true; +} + +bool ChatHandler::HandleBanCommand(const char* args) +{ + if(!args) + return false; + + char* type = strtok((char*)args, " "); + + if(!type) + return false; + char* nameOrIP = strtok(NULL, " "); + + if(!nameOrIP) + return false; + + char* duration = strtok(NULL," "); + if(!duration || !atoi(duration)) + return false; + + char* reason = strtok(NULL,""); + if(!reason) + return false; + + switch(sWorld.BanAccount(type, nameOrIP, duration, reason,m_session->GetPlayerName())) + { + case BAN_SUCCESS: + if(atoi(duration)>0) + PSendSysMessage(LANG_BAN_YOUBANNED,nameOrIP,secsToTimeString(TimeStringToSecs(duration),true).c_str(),reason); + else + PSendSysMessage(LANG_BAN_YOUPERMBANNED,nameOrIP,reason); + break; + case BAN_SYNTAX_ERROR: + return false; + case BAN_NOTFOUND: + PSendSysMessage(LANG_BAN_NOTFOUND,type,nameOrIP); + break; + } + + return true; +} + +bool ChatHandler::HandleUnBanCommand(const char* args) +{ + if(!args) + return false; + char* type = strtok((char*)args, " "); + if(!type) + return false; + char* nameOrIP = strtok(NULL, " "); + + if(!nameOrIP) + return false; + + if(sWorld.RemoveBanAccount(type,nameOrIP)) + PSendSysMessage(LANG_UNBAN_UNBANNED,nameOrIP); + else + PSendSysMessage(LANG_UNBAN_ERROR,nameOrIP); + + return true; +} + +bool ChatHandler::HandleBanInfoCommand(const char* args) +{ + if(!args) + return false; + + char* cType = strtok((char*)args, " "); + char* cnameOrIP = strtok(NULL, ""); + if(!cType || !cnameOrIP) + return false; + + std::string nameOrIP = cnameOrIP; + std::string type = cType; + if (!IsIPAddress(cnameOrIP) && type=="ip") + return false; + + Field *fields; + if(type != "ip") + { + //look the accountid up + uint32 accountid; + std::string accountname; + if(type == "account") + { + loginDatabase.escape_string(nameOrIP); + QueryResult *result = loginDatabase.PQuery("SELECT id, username FROM account WHERE username = '%s'",nameOrIP.c_str()); + if (!result) + { + PSendSysMessage(LANG_BANINFO_NOACCOUNT); + return true; + } + fields = result->Fetch(); + accountid = fields[0].GetUInt32(); + accountname = fields[1].GetCppString(); + delete result; + } + else if(type == "character") + { + if(!normalizePlayerName(nameOrIP)) + { + SendSysMessage(LANG_PLAYER_NOT_FOUND); + SetSentErrorMessage(true); + return false; + } + + loginDatabase.escape_string(nameOrIP); + QueryResult *result = CharacterDatabase.PQuery("SELECT account FROM characters WHERE name = '%s'", nameOrIP.c_str()); + if (!result) + { + PSendSysMessage(LANG_BANINFO_NOCHARACTER); + return true; + } + fields = result->Fetch(); + accountid = fields[0].GetUInt32(); + delete result; + result = loginDatabase.PQuery("SELECT username FROM account WHERE id = '%u'", accountid); + if (!result) + { + PSendSysMessage(LANG_BANINFO_NOCHARACTER); + return true; + } + fields = result->Fetch(); + accountname = fields[0].GetCppString(); + delete result; + } + else + return false; + + QueryResult *result = loginDatabase.PQuery("SELECT FROM_UNIXTIME(bandate), unbandate-bandate, active, unbandate,banreason,bannedby FROM account_banned WHERE id = '%u' ORDER BY bandate ASC",accountid); + if(!result) + { + PSendSysMessage(LANG_BANINFO_NOACCOUNTBAN, accountname.c_str()); + return true; + } + + PSendSysMessage(LANG_BANINFO_BANHISTORY,accountname.c_str()); + do + { + fields = result->Fetch(); + + time_t unbandate = time_t(fields[3].GetUInt64()); + bool active = false; + if(fields[2].GetBool() && (fields[1].GetUInt64() == (uint64)0 ||unbandate >= time(NULL)) ) + active = true; + bool permanent = (fields[1].GetUInt64() == (uint64)0); + std::string bantime = permanent?GetMangosString(LANG_BANINFO_INFINITE):secsToTimeString(fields[1].GetUInt64(), true); + PSendSysMessage(LANG_BANINFO_HISTORYENTRY, + fields[0].GetString(), bantime.c_str(), active ? GetMangosString(LANG_BANINFO_YES):GetMangosString(LANG_BANINFO_NO), fields[4].GetString(), fields[5].GetString()); + }while (result->NextRow()); + + delete result; + } + else + { + loginDatabase.escape_string(nameOrIP); + QueryResult *result = loginDatabase.PQuery("SELECT ip, FROM_UNIXTIME(bandate), FROM_UNIXTIME(unbandate), unbandate-UNIX_TIMESTAMP(), banreason,bannedby,unbandate-bandate FROM ip_banned WHERE ip = '%s'",nameOrIP.c_str()); + if(!result) + { + PSendSysMessage(LANG_BANINFO_NOIP); + return true; + } + fields = result->Fetch(); + bool permanent = (fields[6].GetUInt64()==(uint64)0); + PSendSysMessage(LANG_BANINFO_IPENTRY, + fields[0].GetString(), fields[1].GetString(), permanent ? GetMangosString(LANG_BANINFO_NEVER):fields[2].GetString(), + permanent ? GetMangosString(LANG_BANINFO_INFINITE):secsToTimeString(fields[3].GetUInt64(), true).c_str(), fields[4].GetString(), fields[5].GetString()); + delete result; + } + return true; +} + +bool ChatHandler::HandleBanListCommand(const char* args) +{ + loginDatabase.Execute("DELETE FROM ip_banned WHERE unbandate<=UNIX_TIMESTAMP() AND unbandate<>bandate"); + if(!*args) + return false; + char* cType = strtok((char*)args, " "); + char* cFilter = strtok(NULL, ""); + if(!cType || !cFilter) + return false; + std::string Filter = cFilter; + std::string Type = cType; + loginDatabase.escape_string(Filter); + + QueryResult* result = NULL; + Field *fields = NULL; + if(Type == "ip") + { + result = loginDatabase.PQuery("SELECT ip FROM ip_banned WHERE ip "_LIKE_" "_CONCAT3_("'%%'","'%s'","'%%'"),Filter.c_str()); + if(!result) + { + PSendSysMessage(LANG_BANLIST_NOIP); + return true; + } + PSendSysMessage(LANG_BANLIST_MATCHINGIP); + do + { + fields = result->Fetch(); + PSendSysMessage("%s",fields[0].GetString()); + } while (result->NextRow()); + + delete result; + return true; + } + //lookup accountid + if(Type == "account") + { + result = loginDatabase.PQuery("SELECT id FROM account WHERE username "_LIKE_" "_CONCAT3_("'%%'","'%s'","'%%'"),Filter.c_str()); + if (!result) + { + PSendSysMessage(LANG_BANLIST_NOACCOUNT); + return true; + } + //do not delete result + } + else if(Type == "characters") + { + result = CharacterDatabase.PQuery("SELECT account FROM characters, WHERE name "_LIKE_" "_CONCAT3_("'%%'","'%s'","'%%'"),Filter.c_str()); + if (!result) + { + PSendSysMessage(LANG_BANLIST_NOCHARACTER); + return true; + } + } + else + return false; + + PSendSysMessage(LANG_BANLIST_MATCHINGACCOUNT); + do + { + fields = result->Fetch(); + uint32 accountid = fields[0].GetUInt32(); + QueryResult* banresult = loginDatabase.PQuery("SELECT account.username FROM account,account_banned WHERE account_banned.id='%u' AND account_banned.active = '1' AND account_banned.id=account.id",accountid); + if(banresult) + { + Field* fields2 = banresult->Fetch(); + PSendSysMessage("%s",fields2[0].GetString()); + delete banresult; + } + } while (result->NextRow()); + + delete result; + return true; +} + +bool ChatHandler::HandleRespawnCommand(const char* /*args*/) +{ + Player* pl = m_session->GetPlayer(); + + CellPair p(MaNGOS::ComputeCellPair(pl->GetPositionX(), pl->GetPositionY())); + Cell cell(p); + cell.data.Part.reserved = ALL_DISTRICT; + cell.SetNoCreate(); + + MaNGOS::RespawnDo u_do; + MaNGOS::WorldObjectWorker worker(u_do); + + TypeContainerVisitor, GridTypeMapContainer > obj_worker(worker); + CellLock cell_lock(cell, p); + cell_lock->Visit(cell_lock, obj_worker, *MapManager::Instance().GetMap(pl->GetMapId(), pl)); + + return true; +} + +bool ChatHandler::HandleFlyModeCommand(const char* args) +{ + if(!args) + return false; + + Unit *unit = getSelectedUnit(); + if (!unit || (unit->GetTypeId() != TYPEID_PLAYER)) + unit = m_session->GetPlayer(); + + WorldPacket data(12); + if (strncmp(args, "on", 3) == 0) + data.SetOpcode(SMSG_MOVE_SET_CAN_FLY); + else if (strncmp(args, "off", 4) == 0) + data.SetOpcode(SMSG_MOVE_UNSET_CAN_FLY); + else + { + SendSysMessage(LANG_USE_BOL); + return false; + } + data.append(unit->GetPackGUID()); + data << uint32(0); // unknown + unit->SendMessageToSet(&data, true); + PSendSysMessage(LANG_COMMAND_FLYMODE_STATUS, unit->GetName(), args); + return true; +} + +bool ChatHandler::HandleLoadPDumpCommand(const char *args) +{ + if(!args) + return false; + + char * file = strtok((char*)args, " "); if(!file) return false; + char * acc = strtok(NULL, " "); if(!acc) return false; + if(!file || !acc) + return false; + + uint32 account_id = objmgr.GetAccountByAccountName(acc); + if(!account_id) + { + account_id = atoi(acc); + if(account_id) + { + std::string acc_name; + if(!objmgr.GetAccountNameByAccount(account_id,acc_name)) + return false; + } + else + return false; + } + + char * name = strtok(NULL, " "); + char * guid_str = name ? strtok(NULL, " ") : NULL; + + uint32 guid = guid_str ? atoi(guid_str) : 0; + + if(PlayerDumpReader().LoadDump(file, account_id, name ? name : "", guid)) + PSendSysMessage(LANG_COMMAND_IMPORT_SUCCESS); + else + PSendSysMessage(LANG_COMMAND_IMPORT_FAILED); + + return true; +} + +bool ChatHandler::HandleChangeEntryCommand(const char *args) +{ + if(!args) + return false; + + uint32 newEntryNum = atoi(args); + if(!newEntryNum) + return false; + + Unit* unit = getSelectedUnit(); + if(!unit || unit->GetTypeId() != TYPEID_UNIT) + { + SendSysMessage(LANG_SELECT_CREATURE); + SetSentErrorMessage(true); + return false; + } + Creature* creature = (Creature*)unit; + if(creature->UpdateEntry(newEntryNum)) + SendSysMessage(LANG_DONE); + else + SendSysMessage(LANG_ERROR); + return true; +} + +bool ChatHandler::HandleWritePDumpCommand(const char *args) +{ + if(!args) + return false; + + char* file = strtok((char*)args, " "); + char* p2 = strtok(NULL, " "); + + if(!file || !p2) + return false; + + uint32 guid = objmgr.GetPlayerGUIDByName(p2); + if(!guid) + guid = atoi(p2); + + if (PlayerDumpWriter().WriteDump(file, guid)) + PSendSysMessage(LANG_COMMAND_EXPORT_SUCCESS); + else + PSendSysMessage(LANG_COMMAND_EXPORT_FAILED); + + return true; +} + +bool ChatHandler::HandleMovegensCommand(const char* /*args*/) +{ + Unit* unit = getSelectedUnit(); + if(!unit) + { + SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE); + SetSentErrorMessage(true); + return false; + } + + PSendSysMessage(LANG_MOVEGENS_LIST,(unit->GetTypeId()==TYPEID_PLAYER ? "Player" : "Creature" ),unit->GetGUIDLow()); + + MotionMaster* mm = unit->GetMotionMaster(); + for(MotionMaster::const_iterator itr = mm->begin(); itr != mm->end(); ++itr) + { + switch((*itr)->GetMovementGeneratorType()) + { + case IDLE_MOTION_TYPE: SendSysMessage(LANG_MOVEGENS_IDLE); break; + case RANDOM_MOTION_TYPE: SendSysMessage(LANG_MOVEGENS_RANDOM); break; + case WAYPOINT_MOTION_TYPE: SendSysMessage(LANG_MOVEGENS_WAYPOINT); break; + case ANIMAL_RANDOM_MOTION_TYPE: SendSysMessage(LANG_MOVEGENS_ANIMAL_RANDOM); break; + case CONFUSED_MOTION_TYPE: SendSysMessage(LANG_MOVEGENS_CONFUSED); break; + case TARGETED_MOTION_TYPE: + { + if(unit->GetTypeId()==TYPEID_PLAYER) + { + TargetedMovementGenerator const* mgen = static_cast const*>(*itr); + Unit* target = mgen->GetTarget(); + if(target) + PSendSysMessage(LANG_MOVEGENS_TARGETED_PLAYER,target->GetName(),target->GetGUIDLow()); + else + SendSysMessage(LANG_MOVEGENS_TARGETED_NULL); + } + else + { + TargetedMovementGenerator const* mgen = static_cast const*>(*itr); + Unit* target = mgen->GetTarget(); + if(target) + PSendSysMessage(LANG_MOVEGENS_TARGETED_CREATURE,target->GetName(),target->GetGUIDLow()); + else + SendSysMessage(LANG_MOVEGENS_TARGETED_NULL); + } + break; + } + case HOME_MOTION_TYPE: + if(unit->GetTypeId()==TYPEID_UNIT) + { + float x,y,z; + (*itr)->GetDestination(x,y,z); + PSendSysMessage(LANG_MOVEGENS_HOME_CREATURE,x,y,z); + } + else + SendSysMessage(LANG_MOVEGENS_HOME_PLAYER); + break; + case FLIGHT_MOTION_TYPE: SendSysMessage(LANG_MOVEGENS_FLIGHT); break; + case POINT_MOTION_TYPE: + { + float x,y,z; + (*itr)->GetDestination(x,y,z); + PSendSysMessage(LANG_MOVEGENS_POINT,x,y,z); + break; + } + case FLEEING_MOTION_TYPE: SendSysMessage(LANG_MOVEGENS_FEAR); break; + case DISTRACT_MOTION_TYPE: SendSysMessage(LANG_MOVEGENS_DISTRACT); break; + default: + PSendSysMessage(LANG_MOVEGENS_UNKNOWN,(*itr)->GetMovementGeneratorType()); + break; + } + } + return true; +} + +bool ChatHandler::HandlePLimitCommand(const char *args) +{ + if(*args) + { + char* param = strtok((char*)args, " "); + if(!param) + return false; + + int l = strlen(param); + + if( strncmp(param,"player",l) == 0 ) + sWorld.SetPlayerLimit(-SEC_PLAYER); + else if(strncmp(param,"moderator",l) == 0 ) + sWorld.SetPlayerLimit(-SEC_MODERATOR); + else if(strncmp(param,"gamemaster",l) == 0 ) + sWorld.SetPlayerLimit(-SEC_GAMEMASTER); + else if(strncmp(param,"administrator",l) == 0 ) + sWorld.SetPlayerLimit(-SEC_ADMINISTRATOR); + else if(strncmp(param,"reset",l) == 0 ) + sWorld.SetPlayerLimit( sConfig.GetIntDefault("PlayerLimit", DEFAULT_PLAYER_LIMIT) ); + else + { + int val = atoi(param); + if(val < -SEC_ADMINISTRATOR) val = -SEC_ADMINISTRATOR; + + sWorld.SetPlayerLimit(val); + } + + // kick all low security level players + if(sWorld.GetPlayerAmountLimit() > SEC_PLAYER) + sWorld.KickAllLess(sWorld.GetPlayerSecurityLimit()); + } + + uint32 pLimit = sWorld.GetPlayerAmountLimit(); + AccountTypes allowedAccountType = sWorld.GetPlayerSecurityLimit(); + char const* secName = ""; + switch(allowedAccountType) + { + case SEC_PLAYER: secName = "Player"; break; + case SEC_MODERATOR: secName = "Moderator"; break; + case SEC_GAMEMASTER: secName = "Gamemaster"; break; + case SEC_ADMINISTRATOR: secName = "Administrator"; break; + default: secName = ""; break; + } + + PSendSysMessage("Player limits: amount %u, min. security level %s.",pLimit,secName); + + return true; +} + +bool ChatHandler::HandleCastCommand(const char* args) +{ + if(!*args) + return false; + + Unit* target = getSelectedUnit(); + + if(!target) + { + SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE); + SetSentErrorMessage(true); + return false; + } + + // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form + uint32 spell = extractSpellIdFromLink((char*)args); + if(!spell) + return false; + + SpellEntry const* spellInfo = sSpellStore.LookupEntry(spell); + if(!spellInfo) + return false; + + if(!SpellMgr::IsSpellValid(spellInfo,m_session->GetPlayer())) + { + PSendSysMessage(LANG_COMMAND_SPELL_BROKEN,spell); + SetSentErrorMessage(true); + return false; + } + + char* trig_str = strtok(NULL, " "); + if(trig_str) + { + int l = strlen(trig_str); + if(strncmp(trig_str,"triggered",l) != 0 ) + return false; + } + + bool triggered = (trig_str != NULL); + + m_session->GetPlayer()->CastSpell(target,spell,triggered); + + return true; +} + +bool ChatHandler::HandleCastBackCommand(const char* args) +{ + Creature* caster = getSelectedCreature(); + + if(!caster) + { + SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE); + SetSentErrorMessage(true); + return false; + } + + // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r + // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form + uint32 spell = extractSpellIdFromLink((char*)args); + if(!spell || !sSpellStore.LookupEntry(spell)) + return false; + + char* trig_str = strtok(NULL, " "); + if(trig_str) + { + int l = strlen(trig_str); + if(strncmp(trig_str,"triggered",l) != 0 ) + return false; + } + + bool triggered = (trig_str != NULL); + + // update orientation at server + caster->SetOrientation(caster->GetAngle(m_session->GetPlayer())); + + // and client + WorldPacket data; + caster->BuildHeartBeatMsg(&data); + caster->SendMessageToSet(&data,true); + + caster->CastSpell(m_session->GetPlayer(),spell,false); + + return true; +} + +bool ChatHandler::HandleCastDistCommand(const char* args) +{ + if(!*args) + return false; + + + // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form + uint32 spell = extractSpellIdFromLink((char*)args); + if(!spell) + return false; + + SpellEntry const* spellInfo = sSpellStore.LookupEntry(spell); + if(!spellInfo) + return false; + + if(!SpellMgr::IsSpellValid(spellInfo,m_session->GetPlayer())) + { + PSendSysMessage(LANG_COMMAND_SPELL_BROKEN,spell); + SetSentErrorMessage(true); + return false; + } + + char *distStr = strtok(NULL, " "); + + float dist = 0; + + if(distStr) + sscanf(distStr, "%f", &dist); + + char* trig_str = strtok(NULL, " "); + if(trig_str) + { + int l = strlen(trig_str); + if(strncmp(trig_str,"triggered",l) != 0 ) + return false; + } + + bool triggered = (trig_str != NULL); + + float x,y,z; + m_session->GetPlayer()->GetClosePoint(x,y,z,dist); + + m_session->GetPlayer()->CastSpell(x,y,z,spell,triggered); + return true; +} + +bool ChatHandler::HandleCastTargetCommand(const char* args) +{ + Creature* caster = getSelectedCreature(); + + if(!caster) + { + SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE); + SetSentErrorMessage(true); + return false; + } + + if(!caster->getVictim()) + { + SendSysMessage(LANG_SELECTED_TARGET_NOT_HAVE_VICTIM); + SetSentErrorMessage(true); + return false; + } + + // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form + uint32 spell = extractSpellIdFromLink((char*)args); + if(!spell || !sSpellStore.LookupEntry(spell)) + return false; + + char* trig_str = strtok(NULL, " "); + if(trig_str) + { + int l = strlen(trig_str); + if(strncmp(trig_str,"triggered",l) != 0 ) + return false; + } + + bool triggered = (trig_str != NULL); + + // update orientation at server + caster->SetOrientation(caster->GetAngle(m_session->GetPlayer())); + + // and client + WorldPacket data; + caster->BuildHeartBeatMsg(&data); + caster->SendMessageToSet(&data,true); + + caster->CastSpell(caster->getVictim(),spell,false); + + return true; +} + +/* +ComeToMe command REQUIRED for 3rd party scripting library to have access to PointMovementGenerator +Without this function 3rd party scripting library will get linking errors (unresolved external) +when attempting to use the PointMovementGenerator +*/ +bool ChatHandler::HandleComeToMeCommand(const char *args) +{ + Creature* caster = getSelectedCreature(); + + if(!caster) + { + SendSysMessage(LANG_SELECT_CREATURE); + SetSentErrorMessage(true); + return false; + } + + char* newFlagStr = strtok((char*)args, " "); + + if(!newFlagStr) + return false; + + uint32 newFlags = atoi(newFlagStr); + + caster->SetUnitMovementFlags(newFlags); + + Player* pl = m_session->GetPlayer(); + + caster->GetMotionMaster()->MovePoint(0, pl->GetPositionX(), pl->GetPositionY(), pl->GetPositionZ()); + return true; +} + +bool ChatHandler::HandleCastSelfCommand(const char* args) +{ + if(!*args) + return false; + + Unit* target = getSelectedUnit(); + + if(!target) + { + SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE); + SetSentErrorMessage(true); + return false; + } + + // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form + uint32 spell = extractSpellIdFromLink((char*)args); + if(!spell) + return false; + + SpellEntry const* spellInfo = sSpellStore.LookupEntry(spell); + if(!spellInfo) + return false; + + if(!SpellMgr::IsSpellValid(spellInfo,m_session->GetPlayer())) + { + PSendSysMessage(LANG_COMMAND_SPELL_BROKEN,spell); + SetSentErrorMessage(true); + return false; + } + + target->CastSpell(target,spell,false); + + return true; +} + +std::string GetTimeString(uint32 time) +{ + uint16 days = time / DAY, hours = (time % DAY) / HOUR, minute = (time % HOUR) / MINUTE; + std::ostringstream ss; + if(days) ss << days << "d "; + if(hours) ss << hours << "h "; + ss << minute << "m"; + return ss.str(); +} + +bool ChatHandler::HandleInstanceListBindsCommand(const char* /*args*/) +{ + Player* player = getSelectedPlayer(); + if (!player) player = m_session->GetPlayer(); + uint32 counter = 0; + for(uint8 i = 0; i < TOTAL_DIFFICULTIES; i++) + { + Player::BoundInstancesMap &binds = player->GetBoundInstances(i); + for(Player::BoundInstancesMap::iterator itr = binds.begin(); itr != binds.end(); ++itr) + { + InstanceSave *save = itr->second.save; + std::string timeleft = GetTimeString(save->GetResetTime() - time(NULL)); + PSendSysMessage("map: %d inst: %d perm: %s diff: %s canReset: %s TTR: %s", itr->first, save->GetInstanceId(), itr->second.perm ? "yes" : "no", save->GetDifficulty() == DIFFICULTY_NORMAL ? "normal" : "heroic", save->CanReset() ? "yes" : "no", timeleft.c_str()); + counter++; + } + } + PSendSysMessage("player binds: %d", counter); + counter = 0; + Group *group = player->GetGroup(); + if(group) + { + for(uint8 i = 0; i < TOTAL_DIFFICULTIES; i++) + { + Group::BoundInstancesMap &binds = group->GetBoundInstances(i); + for(Group::BoundInstancesMap::iterator itr = binds.begin(); itr != binds.end(); ++itr) + { + InstanceSave *save = itr->second.save; + std::string timeleft = GetTimeString(save->GetResetTime() - time(NULL)); + PSendSysMessage("map: %d inst: %d perm: %s diff: %s canReset: %s TTR: %s", itr->first, save->GetInstanceId(), itr->second.perm ? "yes" : "no", save->GetDifficulty() == DIFFICULTY_NORMAL ? "normal" : "heroic", save->CanReset() ? "yes" : "no", timeleft.c_str()); + counter++; + } + } + } + PSendSysMessage("group binds: %d", counter); + + return true; +} + +bool ChatHandler::HandleInstanceUnbindCommand(const char* args) +{ + if(!*args) + return false; + + std::string cmd = args; + if(cmd == "all") + { + Player* player = getSelectedPlayer(); + if (!player) player = m_session->GetPlayer(); + uint32 counter = 0; + for(uint8 i = 0; i < TOTAL_DIFFICULTIES; i++) + { + Player::BoundInstancesMap &binds = player->GetBoundInstances(i); + for(Player::BoundInstancesMap::iterator itr = binds.begin(); itr != binds.end();) + { + if(itr->first != player->GetMapId()) + { + InstanceSave *save = itr->second.save; + std::string timeleft = GetTimeString(save->GetResetTime() - time(NULL)); + PSendSysMessage("unbinding map: %d inst: %d perm: %s diff: %s canReset: %s TTR: %s", itr->first, save->GetInstanceId(), itr->second.perm ? "yes" : "no", save->GetDifficulty() == DIFFICULTY_NORMAL ? "normal" : "heroic", save->CanReset() ? "yes" : "no", timeleft.c_str()); + player->UnbindInstance(itr, i); + counter++; + } + else + ++itr; + } + } + PSendSysMessage("instances unbound: %d", counter); + } + return true; +} + +bool ChatHandler::HandleInstanceStatsCommand(const char* /*args*/) +{ + PSendSysMessage("instances loaded: %d", MapManager::Instance().GetNumInstances()); + PSendSysMessage("players in instances: %d", MapManager::Instance().GetNumPlayersInInstances()); + PSendSysMessage("instance saves: %d", sInstanceSaveManager.GetNumInstanceSaves()); + PSendSysMessage("players bound: %d", sInstanceSaveManager.GetNumBoundPlayersTotal()); + PSendSysMessage("groups bound: %d", sInstanceSaveManager.GetNumBoundGroupsTotal()); + return true; +} + +bool ChatHandler::HandleInstanceSaveDataCommand(const char * /*args*/) +{ + Player* pl = m_session->GetPlayer(); + + Map* map = pl->GetMap(); + if (!map->IsDungeon()) + { + PSendSysMessage("Map is not a dungeon."); + SetSentErrorMessage(true); + return false; + } + + if (!((InstanceMap*)map)->GetInstanceData()) + { + PSendSysMessage("Map has no instance data."); + SetSentErrorMessage(true); + return false; + } + + ((InstanceMap*)map)->GetInstanceData()->SaveToDB(); + return true; +} diff --git a/src/game/Makefile.am b/src/game/Makefile.am index cffd1f7b093..6d9fc63af82 100644 --- a/src/game/Makefile.am +++ b/src/game/Makefile.am @@ -30,6 +30,8 @@ libgame_a_CPPFLAGS = \ $(MYSQL_INCLUDES) \ $(POSTGRE_INCLUDES) \ -I$(top_srcdir)/dep/include \ +-I$(top_srcdir)/dep/ACE_wrappers \ +-I$(top_builddir)/dep/ACE_wrappers \ -I$(top_srcdir)/src/framework \ -I$(top_srcdir)/src/shared \ -I$(top_srcdir)/src/shared/vmap diff --git a/src/game/NPCHandler.cpp b/src/game/NPCHandler.cpp index 5739f56e328..5d3e9b61aa2 100644 --- a/src/game/NPCHandler.cpp +++ b/src/game/NPCHandler.cpp @@ -1,832 +1,826 @@ -/* - * Copyright (C) 2005-2008 MaNGOS - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "Common.h" -#include "Language.h" -#include "Database/DatabaseEnv.h" -#include "WorldPacket.h" -#include "WorldSession.h" -#include "Opcodes.h" -#include "Log.h" -#include "World.h" -#include "ObjectMgr.h" -#include "SpellMgr.h" -#include "Player.h" -#include "GossipDef.h" -#include "SpellAuras.h" -#include "UpdateMask.h" -#include "ScriptCalls.h" -#include "ObjectAccessor.h" -#include "Creature.h" -#include "MapManager.h" -#include "Pet.h" -#include "BattleGroundMgr.h" -#include "BattleGround.h" -#include "Guild.h" - -void WorldSession::HandleTabardVendorActivateOpcode( WorldPacket & recv_data ) -{ - CHECK_PACKET_SIZE(recv_data,8); - - uint64 guid; - recv_data >> guid; - - Creature *unit = ObjectAccessor::GetNPCIfCanInteractWith(*_player, guid,UNIT_NPC_FLAG_TABARDDESIGNER); - if (!unit) - { - sLog.outDebug( "WORLD: HandleTabardVendorActivateOpcode - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(guid)) ); - return; - } - - // remove fake death - if(GetPlayer()->hasUnitState(UNIT_STAT_DIED)) - GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH); - - SendTabardVendorActivate(guid); -} - -void WorldSession::SendTabardVendorActivate( uint64 guid ) -{ - WorldPacket data( MSG_TABARDVENDOR_ACTIVATE, 8 ); - data << guid; - SendPacket( &data ); -} - -void WorldSession::HandleBankerActivateOpcode( WorldPacket & recv_data ) -{ - CHECK_PACKET_SIZE(recv_data,8); - - uint64 guid; - - sLog.outDebug( "WORLD: Received CMSG_BANKER_ACTIVATE" ); - - recv_data >> guid; - - Creature *unit = ObjectAccessor::GetNPCIfCanInteractWith(*_player, guid,UNIT_NPC_FLAG_BANKER); - if (!unit) - { - sLog.outDebug( "WORLD: HandleBankerActivateOpcode - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(guid)) ); - return; - } - - // remove fake death - if(GetPlayer()->hasUnitState(UNIT_STAT_DIED)) - GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH); - - SendShowBank(guid); -} - -void WorldSession::SendShowBank( uint64 guid ) -{ - WorldPacket data( SMSG_SHOW_BANK, 8 ); - data << guid; - SendPacket( &data ); -} - -void WorldSession::HandleTrainerListOpcode( WorldPacket & recv_data ) -{ - CHECK_PACKET_SIZE(recv_data,8); - - uint64 guid; - - recv_data >> guid; - SendTrainerList( guid ); -} - -void WorldSession::SendTrainerList( uint64 guid ) -{ - std::string str = GetMangosString(LANG_NPC_TAINER_HELLO); - SendTrainerList( guid, str ); -} - -void WorldSession::SendTrainerList( uint64 guid,std::string strTitle ) -{ - sLog.outDebug( "WORLD: SendTrainerList" ); - - Creature *unit = ObjectAccessor::GetNPCIfCanInteractWith(*_player, guid,UNIT_NPC_FLAG_TRAINER); - if (!unit) - { - sLog.outDebug( "WORLD: SendTrainerList - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(guid)) ); - return; - } - - // remove fake death - if(GetPlayer()->hasUnitState(UNIT_STAT_DIED)) - GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH); - - // Lazy loading at first access - unit->LoadTrainerSpells(); - - // trainer list loaded at check; - if(!unit->isCanTrainingOf(_player,true)) - return; - - CreatureInfo const *ci = unit->GetCreatureInfo(); - - if (!ci) - { - sLog.outDebug( "WORLD: SendTrainerList - (%u) NO CREATUREINFO! (GUID: %u)", uint32(GUID_LOPART(guid)), guid ); - return; - } - - Creature::SpellsList const& trainer_spells = unit->GetTrainerSpells(); - - WorldPacket data( SMSG_TRAINER_LIST, 8+4+4+trainer_spells.size()*38 + strTitle.size()+1); - data << guid; - data << uint32(unit->GetTrainerType()); - - size_t count_pos = data.wpos(); - data << uint32(trainer_spells.size()); - - // reputation discount - float fDiscountMod = _player->GetReputationPriceDiscount(unit); - - uint32 count = 0; - for(Creature::SpellsList::const_iterator itr = trainer_spells.begin(); itr != trainer_spells.end(); ++itr) - { - if(!_player->IsSpellFitByClassAndRace(itr->spell->Id)) - continue; - - ++count; - - bool primary_prof_first_rank = spellmgr.IsPrimaryProfessionFirstRankSpell(itr->spell->Id); - - SpellChainNode const* chain_node = spellmgr.GetSpellChainNode(itr->spell->Id); - - data << uint32(itr->spell->Id); - data << uint8(_player->GetTrainerSpellState(&*itr)); - data << uint32(floor(itr->spellcost * fDiscountMod)); - - data << uint32(primary_prof_first_rank ? 1 : 0); // primary prof. learn confirmation dialog - data << uint32(primary_prof_first_rank ? 1 : 0); // must be equal prev. field to have learn button in enabled state - data << uint8(itr->reqlevel ? itr->reqlevel : itr->spell->spellLevel); - data << uint32(itr->reqskill); - data << uint32(itr->reqskillvalue); - data << uint32(chain_node ? (chain_node->prev ? chain_node->prev : chain_node->req) : 0); - data << uint32(chain_node && chain_node->prev ? chain_node->req : 0); - data << uint32(0); - } - - data << strTitle; - - data.put(count_pos,count); - SendPacket( &data ); -} - -void WorldSession::HandleTrainerBuySpellOpcode( WorldPacket & recv_data ) -{ - CHECK_PACKET_SIZE(recv_data,8+4); - - uint64 guid; - uint32 spellId = 0; - - recv_data >> guid >> spellId; - sLog.outDebug( "WORLD: Received CMSG_TRAINER_BUY_SPELL NpcGUID=%u, learn spell id is: %u",uint32(GUID_LOPART(guid)), spellId ); - - Creature *unit = ObjectAccessor::GetNPCIfCanInteractWith(*_player, guid, UNIT_NPC_FLAG_TRAINER); - if (!unit) - { - sLog.outDebug( "WORLD: HandleTrainerBuySpellOpcode - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(guid)) ); - return; - } - - // remove fake death - if(GetPlayer()->hasUnitState(UNIT_STAT_DIED)) - GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH); - - // Lazy loading at first access - unit->LoadTrainerSpells(); - - if(!unit->isCanTrainingOf(_player,true)) - return; - - TrainerSpell const* trainer_spell = NULL; - - // check present spell in trainer spell list - Creature::SpellsList const& trainer_spells = unit->GetTrainerSpells(); - for(Creature::SpellsList::const_iterator itr = trainer_spells.begin(); itr != trainer_spells.end(); ++itr) - { - if(itr->spell->Id == spellId) - { - trainer_spell = &*itr; - break; - } - } - - // not found, cheat? - if(!trainer_spell) - return; - - // can't be learn, cheat? Or double learn with lags... - if(_player->GetTrainerSpellState(trainer_spell) != TRAINER_SPELL_GREEN) - return; - - // apply reputation discount - uint32 nSpellCost = uint32(floor(trainer_spell->spellcost * _player->GetReputationPriceDiscount(unit))); - - // check money requirement - if(_player->GetMoney() < nSpellCost ) - return; - - WorldPacket data(SMSG_PLAY_SPELL_VISUAL, 12); // visual effect on trainer - data << uint64(guid) << uint32(0xB3); - SendPacket(&data); - - data.Initialize(SMSG_PLAY_SPELL_IMPACT, 12); // visual effect on player - data << uint64(_player->GetGUID()) << uint32(0x016A); - SendPacket(&data); - - _player->ModifyMoney( -int32(nSpellCost) ); - - // learn explicitly to prevent lost money at lags, learning spell will be only show spell animation - _player->learnSpell(trainer_spell->spell->Id); - - data.Initialize(SMSG_TRAINER_BUY_SUCCEEDED, 12); - data << uint64(guid) << uint32(spellId); - SendPacket(&data); -} - -void WorldSession::HandleGossipHelloOpcode( WorldPacket & recv_data ) -{ - CHECK_PACKET_SIZE(recv_data,8); - - sLog.outDebug( "WORLD: Received CMSG_GOSSIP_HELLO" ); - - uint64 guid; - recv_data >> guid; - - Creature *unit = ObjectAccessor::GetNPCIfCanInteractWith(*_player, guid, UNIT_NPC_FLAG_NONE); - if (!unit) - { - sLog.outDebug( "WORLD: HandleGossipHelloOpcode - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(guid)) ); - return; - } - - // remove fake death - if(GetPlayer()->hasUnitState(UNIT_STAT_DIED)) - GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH); - - if( unit->isArmorer() || unit->isCivilian() || unit->isQuestGiver() || unit->isServiceProvider()) - { - unit->StopMoving(); - } - - // If spiritguide, no need for gossip menu, just put player into resurrect queue - if (unit->isSpiritGuide()) - { - BattleGround *bg = _player->GetBattleGround(); - if(bg) - { - bg->AddPlayerToResurrectQueue(unit->GetGUID(), _player->GetGUID()); - sBattleGroundMgr.SendAreaSpiritHealerQueryOpcode(_player, bg, unit->GetGUID()); - return; - } - } - - if(!Script->GossipHello( _player, unit )) - { - _player->TalkedToCreature(unit->GetEntry(),unit->GetGUID()); - unit->prepareGossipMenu(_player,0); - unit->sendPreparedGossip( _player ); - } -} - -void WorldSession::HandleGossipSelectOptionOpcode( WorldPacket & recv_data ) -{ - CHECK_PACKET_SIZE(recv_data,8+4+4); - - sLog.outDebug("WORLD: CMSG_GOSSIP_SELECT_OPTION"); - - uint32 option; - uint32 unk; - uint64 guid; - std::string code = ""; - - recv_data >> guid >> unk >> option; - - if(_player->PlayerTalkClass->GossipOptionCoded( option )) - { - // recheck - CHECK_PACKET_SIZE(recv_data,8+4+1); - sLog.outBasic("reading string"); - recv_data >> code; - sLog.outBasic("string read: %s", code.c_str()); - } - - Creature *unit = ObjectAccessor::GetNPCIfCanInteractWith(*_player, guid, UNIT_NPC_FLAG_NONE); - if (!unit) - { - sLog.outDebug( "WORLD: HandleGossipSelectOptionOpcode - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(guid)) ); - return; - } - - // remove fake death - if(GetPlayer()->hasUnitState(UNIT_STAT_DIED)) - GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH); - - if(!code.empty()) - { - - if(!Script->GossipSelectWithCode( _player, unit, _player->PlayerTalkClass->GossipOptionSender( option ), _player->PlayerTalkClass->GossipOptionAction( option ), code.c_str()) ) - unit->OnGossipSelect( _player, option ); - } - else - - if(!Script->GossipSelect( _player, unit, _player->PlayerTalkClass->GossipOptionSender( option ), _player->PlayerTalkClass->GossipOptionAction( option )) ) - unit->OnGossipSelect( _player, option ); -} - -void WorldSession::HandleSpiritHealerActivateOpcode( WorldPacket & recv_data ) -{ - CHECK_PACKET_SIZE(recv_data,8); - - sLog.outDebug("WORLD: CMSG_SPIRIT_HEALER_ACTIVATE"); - - uint64 guid; - - recv_data >> guid; - - Creature *unit = ObjectAccessor::GetNPCIfCanInteractWith(*_player, guid, UNIT_NPC_FLAG_SPIRITHEALER); - if (!unit) - { - sLog.outDebug( "WORLD: HandleSpiritHealerActivateOpcode - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(guid)) ); - return; - } - - // remove fake death - if(GetPlayer()->hasUnitState(UNIT_STAT_DIED)) - GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH); - - SendSpiritResurrect(); -} - -void WorldSession::SendSpiritResurrect() -{ - _player->ResurrectPlayer(0.5f,false, true); - - _player->DurabilityLossAll(0.25f,true); - - // get corpse nearest graveyard - WorldSafeLocsEntry const *corpseGrave = NULL; - Corpse *corpse = _player->GetCorpse(); - if(corpse) - corpseGrave = objmgr.GetClosestGraveYard( - corpse->GetPositionX(), corpse->GetPositionY(), corpse->GetPositionZ(), corpse->GetMapId(), _player->GetTeam() ); - - // now can spawn bones - _player->SpawnCorpseBones(); - - // teleport to nearest from corpse graveyard, if different from nearest to player ghost - if(corpseGrave) - { - WorldSafeLocsEntry const *ghostGrave = objmgr.GetClosestGraveYard( - _player->GetPositionX(), _player->GetPositionY(), _player->GetPositionZ(), _player->GetMapId(), _player->GetTeam() ); - - if(corpseGrave != ghostGrave) - _player->TeleportTo(corpseGrave->map_id, corpseGrave->x, corpseGrave->y, corpseGrave->z, _player->GetOrientation()); - // or update at original position - else - ObjectAccessor::UpdateVisibilityForPlayer(_player); - } - // or update at original position - else - ObjectAccessor::UpdateVisibilityForPlayer(_player); - - _player->SaveToDB(); -} - -void WorldSession::HandleBinderActivateOpcode( WorldPacket & recv_data ) -{ - CHECK_PACKET_SIZE(recv_data,8); - - uint64 npcGUID; - recv_data >> npcGUID; - - if(!GetPlayer()->isAlive()) - return; - - Creature *unit = ObjectAccessor::GetNPCIfCanInteractWith(*_player, npcGUID,UNIT_NPC_FLAG_INNKEEPER); - if (!unit) - { - sLog.outDebug( "WORLD: HandleBinderActivateOpcode - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(npcGUID)) ); - return; - } - - // remove fake death - if(GetPlayer()->hasUnitState(UNIT_STAT_DIED)) - GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH); - - SendBindPoint(unit); -} - -void WorldSession::SendBindPoint(Creature *npc) -{ - uint32 bindspell = 3286; - - // update sql homebind - CharacterDatabase.PExecute("UPDATE character_homebind SET map = '%u', zone = '%u', position_x = '%f', position_y = '%f', position_z = '%f' WHERE guid = '%u'", _player->GetMapId(), _player->GetZoneId(), _player->GetPositionX(), _player->GetPositionY(), _player->GetPositionZ(), _player->GetGUIDLow()); - _player->m_homebindMapId = _player->GetMapId(); - _player->m_homebindZoneId = _player->GetZoneId(); - _player->m_homebindX = _player->GetPositionX(); - _player->m_homebindY = _player->GetPositionY(); - _player->m_homebindZ = _player->GetPositionZ(); - - // send spell for bind 3286 bind magic - npc->CastSpell(_player, bindspell, true); - - WorldPacket data( SMSG_TRAINER_BUY_SUCCEEDED, (8+4)); - data << npc->GetGUID(); - data << bindspell; - SendPacket( &data ); - - // binding - data.Initialize( SMSG_BINDPOINTUPDATE, (4+4+4+4+4) ); - data << float(_player->GetPositionX()); - data << float(_player->GetPositionY()); - data << float(_player->GetPositionZ()); - data << uint32(_player->GetMapId()); - data << uint32(_player->GetZoneId()); - SendPacket( &data ); - - DEBUG_LOG("New Home Position X is %f",_player->GetPositionX()); - DEBUG_LOG("New Home Position Y is %f",_player->GetPositionY()); - DEBUG_LOG("New Home Position Z is %f",_player->GetPositionZ()); - DEBUG_LOG("New Home MapId is %u",_player->GetMapId()); - DEBUG_LOG("New Home ZoneId is %u",_player->GetZoneId()); - - // zone update - data.Initialize( SMSG_PLAYERBOUND, 8+4 ); - data << uint64(_player->GetGUID()); - data << uint32(_player->GetZoneId()); - SendPacket( &data ); - - _player->PlayerTalkClass->CloseGossip(); -} - -//Need fix -void WorldSession::HandleListStabledPetsOpcode( WorldPacket & recv_data ) -{ - CHECK_PACKET_SIZE(recv_data,8); - - sLog.outDebug("WORLD: Recv MSG_LIST_STABLED_PETS"); - uint64 npcGUID; - - recv_data >> npcGUID; - - Creature *unit = ObjectAccessor::GetNPCIfCanInteractWith(*_player, npcGUID, UNIT_NPC_FLAG_STABLEMASTER); - if (!unit) - { - sLog.outDebug( "WORLD: HandleListStabledPetsOpcode - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(npcGUID)) ); - return; - } - - // remove fake death - if(GetPlayer()->hasUnitState(UNIT_STAT_DIED)) - GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH); - - SendStablePet(npcGUID); -} - -void WorldSession::SendStablePet(uint64 guid ) -{ - sLog.outDebug("WORLD: Recv MSG_LIST_STABLED_PETS Send."); - - WorldPacket data(MSG_LIST_STABLED_PETS, 200); // guess size - data << uint64 ( guid ); - - Pet *pet = _player->GetPet(); - - data << uint8(0); // place holder for slot show number - data << uint8(GetPlayer()->m_stableSlots); - - uint8 num = 0; // counter for place holder - - // not let move dead pet in slot - if(pet && pet->isAlive() && pet->getPetType()==HUNTER_PET) - { - data << uint32(pet->GetCharmInfo()->GetPetNumber()); - data << uint32(pet->GetEntry()); - data << uint32(pet->getLevel()); - data << pet->GetName(); // petname - data << uint32(pet->GetLoyaltyLevel()); // loyalty - data << uint8(0x01); // client slot 1 == current pet (0) - ++num; - } - - // 0 1 2 3 4 5 6 - QueryResult* result = CharacterDatabase.PQuery("SELECT owner, slot, id, entry, level, loyalty, name FROM character_pet WHERE owner = '%u' AND slot > 0 AND slot < 3",_player->GetGUIDLow()); - - if(result) - { - do - { - Field *fields = result->Fetch(); - - data << uint32(fields[2].GetUInt32()); // petnumber - data << uint32(fields[3].GetUInt32()); // creature entry - data << uint32(fields[4].GetUInt32()); // level - data << fields[6].GetString(); // name - data << uint32(fields[5].GetUInt32()); // loyalty - data << uint8(fields[1].GetUInt32()+1); // slot - - ++num; - }while( result->NextRow() ); - - delete result; - } - - data.put(8, num); // set real data to placeholder - SendPacket(&data); -} - -void WorldSession::HandleStablePet( WorldPacket & recv_data ) -{ - CHECK_PACKET_SIZE(recv_data,8); - - sLog.outDebug("WORLD: Recv CMSG_STABLE_PET not dispose."); - uint64 npcGUID; - - recv_data >> npcGUID; - - if(!GetPlayer()->isAlive()) - return; - - Creature *unit = ObjectAccessor::GetNPCIfCanInteractWith(*_player, npcGUID, UNIT_NPC_FLAG_STABLEMASTER); - if (!unit) - { - sLog.outDebug( "WORLD: HandleStablePet - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(npcGUID)) ); - return; - } - - // remove fake death - if(GetPlayer()->hasUnitState(UNIT_STAT_DIED)) - GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH); - - Pet *pet = _player->GetPet(); - - WorldPacket data(SMSG_STABLE_RESULT, 200); // guess size - - // can't place in stable dead pet - if(!pet||!pet->isAlive()||pet->getPetType()!=HUNTER_PET) - { - data << uint8(0x06); - SendPacket(&data); - return; - } - - uint32 free_slot = 1; - - QueryResult *result = CharacterDatabase.PQuery("SELECT owner,slot,id FROM character_pet WHERE owner = '%u' AND slot > 0 AND slot < 3 ORDER BY slot ",_player->GetGUIDLow()); - if(result) - { - do - { - Field *fields = result->Fetch(); - - uint32 slot = fields[1].GetUInt32(); - - if(slot==free_slot) // this slot not free - ++free_slot; - }while( result->NextRow() ); - } - delete result; - - if( free_slot > 0 && free_slot <= GetPlayer()->m_stableSlots) - { - _player->RemovePet(pet,PetSaveMode(free_slot)); - data << uint8(0x08); - } - else - data << uint8(0x06); - - SendPacket(&data); -} - -void WorldSession::HandleUnstablePet( WorldPacket & recv_data ) -{ - CHECK_PACKET_SIZE(recv_data,8+4); - - sLog.outDebug("WORLD: Recv CMSG_UNSTABLE_PET."); - uint64 npcGUID; - uint32 petnumber; - - recv_data >> npcGUID >> petnumber; - - Creature *unit = ObjectAccessor::GetNPCIfCanInteractWith(*_player, npcGUID, UNIT_NPC_FLAG_STABLEMASTER); - if (!unit) - { - sLog.outDebug( "WORLD: HandleUnstablePet - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(npcGUID)) ); - return; - } - - // remove fake death - if(GetPlayer()->hasUnitState(UNIT_STAT_DIED)) - GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH); - - WorldPacket data(SMSG_STABLE_RESULT, 200); // guess size - - Pet* pet = _player->GetPet(); - if(pet && pet->isAlive()) - { - uint8 i = 0x06; - data << uint8(i); - SendPacket(&data); - return; - } - - // delete dead pet - if(pet) - _player->RemovePet(pet,PET_SAVE_AS_DELETED); - - Pet *newpet = NULL; - - QueryResult *result = CharacterDatabase.PQuery("SELECT entry FROM character_pet WHERE owner = '%u' AND id = '%u' AND slot > 0 AND slot < 3",_player->GetGUIDLow(),petnumber); - if(result) - { - Field *fields = result->Fetch(); - uint32 petentry = fields[0].GetUInt32(); - - newpet = new Pet(HUNTER_PET); - if(!newpet->LoadPetFromDB(_player,petentry,petnumber)) - { - delete newpet; - newpet = NULL; - } - delete result; - } - - if(newpet) - data << uint8(0x09); - else - data << uint8(0x06); - SendPacket(&data); -} - -void WorldSession::HandleBuyStableSlot( WorldPacket & recv_data ) -{ - CHECK_PACKET_SIZE(recv_data,8); - - sLog.outDebug("WORLD: Recv CMSG_BUY_STABLE_SLOT."); - uint64 npcGUID; - - recv_data >> npcGUID; - - Creature *unit = ObjectAccessor::GetNPCIfCanInteractWith(*_player, npcGUID, UNIT_NPC_FLAG_STABLEMASTER); - if (!unit) - { - sLog.outDebug( "WORLD: HandleBuyStableSlot - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(npcGUID)) ); - return; - } - - // remove fake death - if(GetPlayer()->hasUnitState(UNIT_STAT_DIED)) - GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH); - - WorldPacket data(SMSG_STABLE_RESULT, 200); - - if(GetPlayer()->m_stableSlots < 2) // max slots amount = 2 - { - StableSlotPricesEntry const *SlotPrice = sStableSlotPricesStore.LookupEntry(GetPlayer()->m_stableSlots+1); - if(_player->GetMoney() >= SlotPrice->Price) - { - ++GetPlayer()->m_stableSlots; - _player->ModifyMoney(-int32(SlotPrice->Price)); - data << uint8(0x0A); // success buy - } - else - data << uint8(0x06); - } - else - data << uint8(0x06); - - SendPacket(&data); -} - -void WorldSession::HandleStableRevivePet( WorldPacket &/* recv_data */) -{ - sLog.outDebug("HandleStableRevivePet: Not implemented"); -} - -void WorldSession::HandleStableSwapPet( WorldPacket & recv_data ) -{ - CHECK_PACKET_SIZE(recv_data,8+4); - - sLog.outDebug("WORLD: Recv CMSG_STABLE_SWAP_PET."); - uint64 npcGUID; - uint32 pet_number; - - recv_data >> npcGUID >> pet_number; - - Creature *unit = ObjectAccessor::GetNPCIfCanInteractWith(*_player, npcGUID, UNIT_NPC_FLAG_STABLEMASTER); - if (!unit) - { - sLog.outDebug( "WORLD: HandleStableSwapPet - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(npcGUID)) ); - return; - } - - // remove fake death - if(GetPlayer()->hasUnitState(UNIT_STAT_DIED)) - GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH); - - WorldPacket data(SMSG_STABLE_RESULT, 200); // guess size - - Pet* pet = _player->GetPet(); - - if(!pet || pet->getPetType()!=HUNTER_PET) - return; - - // find swapped pet slot in stable - QueryResult *result = CharacterDatabase.PQuery("SELECT slot,entry FROM character_pet WHERE owner = '%u' AND id = '%u'",_player->GetGUIDLow(),pet_number); - if(!result) - return; - - Field *fields = result->Fetch(); - - uint32 slot = fields[0].GetUInt32(); - uint32 petentry = fields[1].GetUInt32(); - delete result; - - // move alive pet to slot or delele dead pet - _player->RemovePet(pet,pet->isAlive() ? PetSaveMode(slot) : PET_SAVE_AS_DELETED); - - // summon unstabled pet - Pet *newpet = new Pet; - if(!newpet->LoadPetFromDB(_player,petentry,pet_number)) - { - delete newpet; - data << uint8(0x06); - } - else - data << uint8(0x09); - - SendPacket(&data); -} - -void WorldSession::HandleRepairItemOpcode( WorldPacket & recv_data ) -{ - CHECK_PACKET_SIZE(recv_data,8+8+1); - - sLog.outDebug("WORLD: CMSG_REPAIR_ITEM"); - - uint64 npcGUID, itemGUID; - uint8 guildBank; // new in 2.3.2, bool that means from guild bank money - - recv_data >> npcGUID >> itemGUID >> guildBank; - - Creature *unit = ObjectAccessor::GetNPCIfCanInteractWith(*_player, npcGUID, UNIT_NPC_FLAG_REPAIR); - if (!unit) - { - sLog.outDebug( "WORLD: HandleRepairItemOpcode - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(npcGUID)) ); - return; - } - - // remove fake death - if(GetPlayer()->hasUnitState(UNIT_STAT_DIED)) - GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH); - - // reputation discount - float discountMod = _player->GetReputationPriceDiscount(unit); - - uint32 TotalCost = 0; - if (itemGUID) - { - sLog.outDebug("ITEM: Repair item, itemGUID = %u, npcGUID = %u", GUID_LOPART(itemGUID), GUID_LOPART(npcGUID)); - - Item* item = _player->GetItemByGuid(itemGUID); - - if(item) - TotalCost= _player->DurabilityRepair(item->GetPos(),true,discountMod,guildBank>0?true:false); - } - else - { - sLog.outDebug("ITEM: Repair all items, npcGUID = %u", GUID_LOPART(npcGUID)); - - TotalCost = _player->DurabilityRepairAll(true,discountMod,guildBank>0?true:false); - } - if (guildBank) - { - uint32 GuildId = _player->GetGuildId(); - if (!GuildId) - return; - Guild *pGuild = objmgr.GetGuildById(GuildId); - if (!pGuild) - return; - pGuild->LogBankEvent(GUILD_BANK_LOG_REPAIR_MONEY, 0, _player->GetGUIDLow(), TotalCost); - pGuild->SendMoneyInfo(this, _player->GetGUIDLow()); - } -} +/* + * Copyright (C) 2005-2008 MaNGOS + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "Common.h" +#include "Language.h" +#include "Database/DatabaseEnv.h" +#include "WorldPacket.h" +#include "WorldSession.h" +#include "Opcodes.h" +#include "Log.h" +#include "World.h" +#include "ObjectMgr.h" +#include "SpellMgr.h" +#include "Player.h" +#include "GossipDef.h" +#include "SpellAuras.h" +#include "UpdateMask.h" +#include "ScriptCalls.h" +#include "ObjectAccessor.h" +#include "Creature.h" +#include "MapManager.h" +#include "Pet.h" +#include "BattleGroundMgr.h" +#include "BattleGround.h" +#include "Guild.h" + +void WorldSession::HandleTabardVendorActivateOpcode( WorldPacket & recv_data ) +{ + CHECK_PACKET_SIZE(recv_data,8); + + uint64 guid; + recv_data >> guid; + + Creature *unit = ObjectAccessor::GetNPCIfCanInteractWith(*_player, guid,UNIT_NPC_FLAG_TABARDDESIGNER); + if (!unit) + { + sLog.outDebug( "WORLD: HandleTabardVendorActivateOpcode - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(guid)) ); + return; + } + + // remove fake death + if(GetPlayer()->hasUnitState(UNIT_STAT_DIED)) + GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH); + + SendTabardVendorActivate(guid); +} + +void WorldSession::SendTabardVendorActivate( uint64 guid ) +{ + WorldPacket data( MSG_TABARDVENDOR_ACTIVATE, 8 ); + data << guid; + SendPacket( &data ); +} + +void WorldSession::HandleBankerActivateOpcode( WorldPacket & recv_data ) +{ + CHECK_PACKET_SIZE(recv_data,8); + + uint64 guid; + + sLog.outDebug( "WORLD: Received CMSG_BANKER_ACTIVATE" ); + + recv_data >> guid; + + Creature *unit = ObjectAccessor::GetNPCIfCanInteractWith(*_player, guid,UNIT_NPC_FLAG_BANKER); + if (!unit) + { + sLog.outDebug( "WORLD: HandleBankerActivateOpcode - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(guid)) ); + return; + } + + // remove fake death + if(GetPlayer()->hasUnitState(UNIT_STAT_DIED)) + GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH); + + SendShowBank(guid); +} + +void WorldSession::SendShowBank( uint64 guid ) +{ + WorldPacket data( SMSG_SHOW_BANK, 8 ); + data << guid; + SendPacket( &data ); +} + +void WorldSession::HandleTrainerListOpcode( WorldPacket & recv_data ) +{ + CHECK_PACKET_SIZE(recv_data,8); + + uint64 guid; + + recv_data >> guid; + SendTrainerList( guid ); +} + +void WorldSession::SendTrainerList( uint64 guid ) +{ + std::string str = GetMangosString(LANG_NPC_TAINER_HELLO); + SendTrainerList( guid, str ); +} + +void WorldSession::SendTrainerList( uint64 guid,std::string strTitle ) +{ + sLog.outDebug( "WORLD: SendTrainerList" ); + + Creature *unit = ObjectAccessor::GetNPCIfCanInteractWith(*_player, guid,UNIT_NPC_FLAG_TRAINER); + if (!unit) + { + sLog.outDebug( "WORLD: SendTrainerList - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(guid)) ); + return; + } + + // remove fake death + if(GetPlayer()->hasUnitState(UNIT_STAT_DIED)) + GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH); + + // trainer list loaded at check; + if(!unit->isCanTrainingOf(_player,true)) + return; + + CreatureInfo const *ci = unit->GetCreatureInfo(); + + if (!ci) + { + sLog.outDebug( "WORLD: SendTrainerList - (%u) NO CREATUREINFO! (GUID: %u)", uint32(GUID_LOPART(guid)), guid ); + return; + } + + TrainerSpellData const* trainer_spells = unit->GetTrainerSpells(); + if(!trainer_spells) + { + sLog.outDebug( "WORLD: SendTrainerList - Training spells not found for creature (GUID: %u Entry: %u)", guid, unit->GetEntry()); + return; + } + + WorldPacket data( SMSG_TRAINER_LIST, 8+4+4+trainer_spells->spellList.size()*38 + strTitle.size()+1); + data << guid; + data << uint32(trainer_spells->trainerType); + + size_t count_pos = data.wpos(); + data << uint32(trainer_spells->spellList.size()); + + // reputation discount + float fDiscountMod = _player->GetReputationPriceDiscount(unit); + + uint32 count = 0; + for(TrainerSpellList::const_iterator itr = trainer_spells->spellList.begin(); itr != trainer_spells->spellList.end(); ++itr) + { + TrainerSpell const* tSpell = *itr; + + if(!_player->IsSpellFitByClassAndRace(tSpell->spell)) + continue; + + ++count; + + bool primary_prof_first_rank = spellmgr.IsPrimaryProfessionFirstRankSpell(tSpell->spell); + + SpellChainNode const* chain_node = spellmgr.GetSpellChainNode(tSpell->spell); + + data << uint32(tSpell->spell); + data << uint8(_player->GetTrainerSpellState(tSpell)); + data << uint32(floor(tSpell->spellcost * fDiscountMod)); + + data << uint32(primary_prof_first_rank ? 1 : 0); // primary prof. learn confirmation dialog + data << uint32(primary_prof_first_rank ? 1 : 0); // must be equal prev. field to have learn button in enabled state + data << uint8(tSpell->reqlevel); + data << uint32(tSpell->reqskill); + data << uint32(tSpell->reqskillvalue); + data << uint32(chain_node ? (chain_node->prev ? chain_node->prev : chain_node->req) : 0); + data << uint32(chain_node && chain_node->prev ? chain_node->req : 0); + data << uint32(0); + } + + data << strTitle; + + data.put(count_pos,count); + SendPacket( &data ); +} + +void WorldSession::HandleTrainerBuySpellOpcode( WorldPacket & recv_data ) +{ + CHECK_PACKET_SIZE(recv_data,8+4); + + uint64 guid; + uint32 spellId = 0; + + recv_data >> guid >> spellId; + sLog.outDebug( "WORLD: Received CMSG_TRAINER_BUY_SPELL NpcGUID=%u, learn spell id is: %u",uint32(GUID_LOPART(guid)), spellId ); + + Creature *unit = ObjectAccessor::GetNPCIfCanInteractWith(*_player, guid, UNIT_NPC_FLAG_TRAINER); + if (!unit) + { + sLog.outDebug( "WORLD: HandleTrainerBuySpellOpcode - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(guid)) ); + return; + } + + // remove fake death + if(GetPlayer()->hasUnitState(UNIT_STAT_DIED)) + GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH); + + if(!unit->isCanTrainingOf(_player,true)) + return; + + // check present spell in trainer spell list + TrainerSpellData const* trainer_spells = unit->GetTrainerSpells(); + if(!trainer_spells) + return; + + // not found, cheat? + TrainerSpell const* trainer_spell = trainer_spells->Find(spellId); + if(!trainer_spell) + return; + + // can't be learn, cheat? Or double learn with lags... + if(_player->GetTrainerSpellState(trainer_spell) != TRAINER_SPELL_GREEN) + return; + + // apply reputation discount + uint32 nSpellCost = uint32(floor(trainer_spell->spellcost * _player->GetReputationPriceDiscount(unit))); + + // check money requirement + if(_player->GetMoney() < nSpellCost ) + return; + + WorldPacket data(SMSG_PLAY_SPELL_VISUAL, 12); // visual effect on trainer + data << uint64(guid) << uint32(0xB3); + SendPacket(&data); + + data.Initialize(SMSG_PLAY_SPELL_IMPACT, 12); // visual effect on player + data << uint64(_player->GetGUID()) << uint32(0x016A); + SendPacket(&data); + + _player->ModifyMoney( -int32(nSpellCost) ); + + // learn explicitly to prevent lost money at lags, learning spell will be only show spell animation + _player->learnSpell(trainer_spell->spell); + + data.Initialize(SMSG_TRAINER_BUY_SUCCEEDED, 12); + data << uint64(guid) << uint32(spellId); + SendPacket(&data); +} + +void WorldSession::HandleGossipHelloOpcode( WorldPacket & recv_data ) +{ + CHECK_PACKET_SIZE(recv_data,8); + + sLog.outDebug( "WORLD: Received CMSG_GOSSIP_HELLO" ); + + uint64 guid; + recv_data >> guid; + + Creature *unit = ObjectAccessor::GetNPCIfCanInteractWith(*_player, guid, UNIT_NPC_FLAG_NONE); + if (!unit) + { + sLog.outDebug( "WORLD: HandleGossipHelloOpcode - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(guid)) ); + return; + } + + // remove fake death + if(GetPlayer()->hasUnitState(UNIT_STAT_DIED)) + GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH); + + if( unit->isArmorer() || unit->isCivilian() || unit->isQuestGiver() || unit->isServiceProvider()) + { + unit->StopMoving(); + } + + // If spiritguide, no need for gossip menu, just put player into resurrect queue + if (unit->isSpiritGuide()) + { + BattleGround *bg = _player->GetBattleGround(); + if(bg) + { + bg->AddPlayerToResurrectQueue(unit->GetGUID(), _player->GetGUID()); + sBattleGroundMgr.SendAreaSpiritHealerQueryOpcode(_player, bg, unit->GetGUID()); + return; + } + } + + if(!Script->GossipHello( _player, unit )) + { + _player->TalkedToCreature(unit->GetEntry(),unit->GetGUID()); + unit->prepareGossipMenu(_player,0); + unit->sendPreparedGossip( _player ); + } +} + +void WorldSession::HandleGossipSelectOptionOpcode( WorldPacket & recv_data ) +{ + CHECK_PACKET_SIZE(recv_data,8+4+4); + + sLog.outDebug("WORLD: CMSG_GOSSIP_SELECT_OPTION"); + + uint32 option; + uint32 unk; + uint64 guid; + std::string code = ""; + + recv_data >> guid >> unk >> option; + + if(_player->PlayerTalkClass->GossipOptionCoded( option )) + { + // recheck + CHECK_PACKET_SIZE(recv_data,8+4+1); + sLog.outBasic("reading string"); + recv_data >> code; + sLog.outBasic("string read: %s", code.c_str()); + } + + Creature *unit = ObjectAccessor::GetNPCIfCanInteractWith(*_player, guid, UNIT_NPC_FLAG_NONE); + if (!unit) + { + sLog.outDebug( "WORLD: HandleGossipSelectOptionOpcode - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(guid)) ); + return; + } + + // remove fake death + if(GetPlayer()->hasUnitState(UNIT_STAT_DIED)) + GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH); + + if(!code.empty()) + { + + if(!Script->GossipSelectWithCode( _player, unit, _player->PlayerTalkClass->GossipOptionSender( option ), _player->PlayerTalkClass->GossipOptionAction( option ), code.c_str()) ) + unit->OnGossipSelect( _player, option ); + } + else + + if(!Script->GossipSelect( _player, unit, _player->PlayerTalkClass->GossipOptionSender( option ), _player->PlayerTalkClass->GossipOptionAction( option )) ) + unit->OnGossipSelect( _player, option ); +} + +void WorldSession::HandleSpiritHealerActivateOpcode( WorldPacket & recv_data ) +{ + CHECK_PACKET_SIZE(recv_data,8); + + sLog.outDebug("WORLD: CMSG_SPIRIT_HEALER_ACTIVATE"); + + uint64 guid; + + recv_data >> guid; + + Creature *unit = ObjectAccessor::GetNPCIfCanInteractWith(*_player, guid, UNIT_NPC_FLAG_SPIRITHEALER); + if (!unit) + { + sLog.outDebug( "WORLD: HandleSpiritHealerActivateOpcode - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(guid)) ); + return; + } + + // remove fake death + if(GetPlayer()->hasUnitState(UNIT_STAT_DIED)) + GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH); + + SendSpiritResurrect(); +} + +void WorldSession::SendSpiritResurrect() +{ + _player->ResurrectPlayer(0.5f,false, true); + + _player->DurabilityLossAll(0.25f,true); + + // get corpse nearest graveyard + WorldSafeLocsEntry const *corpseGrave = NULL; + Corpse *corpse = _player->GetCorpse(); + if(corpse) + corpseGrave = objmgr.GetClosestGraveYard( + corpse->GetPositionX(), corpse->GetPositionY(), corpse->GetPositionZ(), corpse->GetMapId(), _player->GetTeam() ); + + // now can spawn bones + _player->SpawnCorpseBones(); + + // teleport to nearest from corpse graveyard, if different from nearest to player ghost + if(corpseGrave) + { + WorldSafeLocsEntry const *ghostGrave = objmgr.GetClosestGraveYard( + _player->GetPositionX(), _player->GetPositionY(), _player->GetPositionZ(), _player->GetMapId(), _player->GetTeam() ); + + if(corpseGrave != ghostGrave) + _player->TeleportTo(corpseGrave->map_id, corpseGrave->x, corpseGrave->y, corpseGrave->z, _player->GetOrientation()); + // or update at original position + else + ObjectAccessor::UpdateVisibilityForPlayer(_player); + } + // or update at original position + else + ObjectAccessor::UpdateVisibilityForPlayer(_player); + + _player->SaveToDB(); +} + +void WorldSession::HandleBinderActivateOpcode( WorldPacket & recv_data ) +{ + CHECK_PACKET_SIZE(recv_data,8); + + uint64 npcGUID; + recv_data >> npcGUID; + + if(!GetPlayer()->isAlive()) + return; + + Creature *unit = ObjectAccessor::GetNPCIfCanInteractWith(*_player, npcGUID,UNIT_NPC_FLAG_INNKEEPER); + if (!unit) + { + sLog.outDebug( "WORLD: HandleBinderActivateOpcode - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(npcGUID)) ); + return; + } + + // remove fake death + if(GetPlayer()->hasUnitState(UNIT_STAT_DIED)) + GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH); + + SendBindPoint(unit); +} + +void WorldSession::SendBindPoint(Creature *npc) +{ + uint32 bindspell = 3286; + + // update sql homebind + CharacterDatabase.PExecute("UPDATE character_homebind SET map = '%u', zone = '%u', position_x = '%f', position_y = '%f', position_z = '%f' WHERE guid = '%u'", _player->GetMapId(), _player->GetZoneId(), _player->GetPositionX(), _player->GetPositionY(), _player->GetPositionZ(), _player->GetGUIDLow()); + _player->m_homebindMapId = _player->GetMapId(); + _player->m_homebindZoneId = _player->GetZoneId(); + _player->m_homebindX = _player->GetPositionX(); + _player->m_homebindY = _player->GetPositionY(); + _player->m_homebindZ = _player->GetPositionZ(); + + // send spell for bind 3286 bind magic + npc->CastSpell(_player, bindspell, true); + + WorldPacket data( SMSG_TRAINER_BUY_SUCCEEDED, (8+4)); + data << npc->GetGUID(); + data << bindspell; + SendPacket( &data ); + + // binding + data.Initialize( SMSG_BINDPOINTUPDATE, (4+4+4+4+4) ); + data << float(_player->GetPositionX()); + data << float(_player->GetPositionY()); + data << float(_player->GetPositionZ()); + data << uint32(_player->GetMapId()); + data << uint32(_player->GetZoneId()); + SendPacket( &data ); + + DEBUG_LOG("New Home Position X is %f",_player->GetPositionX()); + DEBUG_LOG("New Home Position Y is %f",_player->GetPositionY()); + DEBUG_LOG("New Home Position Z is %f",_player->GetPositionZ()); + DEBUG_LOG("New Home MapId is %u",_player->GetMapId()); + DEBUG_LOG("New Home ZoneId is %u",_player->GetZoneId()); + + // zone update + data.Initialize( SMSG_PLAYERBOUND, 8+4 ); + data << uint64(_player->GetGUID()); + data << uint32(_player->GetZoneId()); + SendPacket( &data ); + + _player->PlayerTalkClass->CloseGossip(); +} + +//Need fix +void WorldSession::HandleListStabledPetsOpcode( WorldPacket & recv_data ) +{ + CHECK_PACKET_SIZE(recv_data,8); + + sLog.outDebug("WORLD: Recv MSG_LIST_STABLED_PETS"); + uint64 npcGUID; + + recv_data >> npcGUID; + + Creature *unit = ObjectAccessor::GetNPCIfCanInteractWith(*_player, npcGUID, UNIT_NPC_FLAG_STABLEMASTER); + if (!unit) + { + sLog.outDebug( "WORLD: HandleListStabledPetsOpcode - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(npcGUID)) ); + return; + } + + // remove fake death + if(GetPlayer()->hasUnitState(UNIT_STAT_DIED)) + GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH); + + SendStablePet(npcGUID); +} + +void WorldSession::SendStablePet(uint64 guid ) +{ + sLog.outDebug("WORLD: Recv MSG_LIST_STABLED_PETS Send."); + + WorldPacket data(MSG_LIST_STABLED_PETS, 200); // guess size + data << uint64 ( guid ); + + Pet *pet = _player->GetPet(); + + data << uint8(0); // place holder for slot show number + data << uint8(GetPlayer()->m_stableSlots); + + uint8 num = 0; // counter for place holder + + // not let move dead pet in slot + if(pet && pet->isAlive() && pet->getPetType()==HUNTER_PET) + { + data << uint32(pet->GetCharmInfo()->GetPetNumber()); + data << uint32(pet->GetEntry()); + data << uint32(pet->getLevel()); + data << pet->GetName(); // petname + data << uint32(pet->GetLoyaltyLevel()); // loyalty + data << uint8(0x01); // client slot 1 == current pet (0) + ++num; + } + + // 0 1 2 3 4 5 6 + QueryResult* result = CharacterDatabase.PQuery("SELECT owner, slot, id, entry, level, loyalty, name FROM character_pet WHERE owner = '%u' AND slot > 0 AND slot < 3",_player->GetGUIDLow()); + + if(result) + { + do + { + Field *fields = result->Fetch(); + + data << uint32(fields[2].GetUInt32()); // petnumber + data << uint32(fields[3].GetUInt32()); // creature entry + data << uint32(fields[4].GetUInt32()); // level + data << fields[6].GetString(); // name + data << uint32(fields[5].GetUInt32()); // loyalty + data << uint8(fields[1].GetUInt32()+1); // slot + + ++num; + }while( result->NextRow() ); + + delete result; + } + + data.put(8, num); // set real data to placeholder + SendPacket(&data); +} + +void WorldSession::HandleStablePet( WorldPacket & recv_data ) +{ + CHECK_PACKET_SIZE(recv_data,8); + + sLog.outDebug("WORLD: Recv CMSG_STABLE_PET not dispose."); + uint64 npcGUID; + + recv_data >> npcGUID; + + if(!GetPlayer()->isAlive()) + return; + + Creature *unit = ObjectAccessor::GetNPCIfCanInteractWith(*_player, npcGUID, UNIT_NPC_FLAG_STABLEMASTER); + if (!unit) + { + sLog.outDebug( "WORLD: HandleStablePet - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(npcGUID)) ); + return; + } + + // remove fake death + if(GetPlayer()->hasUnitState(UNIT_STAT_DIED)) + GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH); + + Pet *pet = _player->GetPet(); + + WorldPacket data(SMSG_STABLE_RESULT, 200); // guess size + + // can't place in stable dead pet + if(!pet||!pet->isAlive()||pet->getPetType()!=HUNTER_PET) + { + data << uint8(0x06); + SendPacket(&data); + return; + } + + uint32 free_slot = 1; + + QueryResult *result = CharacterDatabase.PQuery("SELECT owner,slot,id FROM character_pet WHERE owner = '%u' AND slot > 0 AND slot < 3 ORDER BY slot ",_player->GetGUIDLow()); + if(result) + { + do + { + Field *fields = result->Fetch(); + + uint32 slot = fields[1].GetUInt32(); + + if(slot==free_slot) // this slot not free + ++free_slot; + }while( result->NextRow() ); + } + delete result; + + if( free_slot > 0 && free_slot <= GetPlayer()->m_stableSlots) + { + _player->RemovePet(pet,PetSaveMode(free_slot)); + data << uint8(0x08); + } + else + data << uint8(0x06); + + SendPacket(&data); +} + +void WorldSession::HandleUnstablePet( WorldPacket & recv_data ) +{ + CHECK_PACKET_SIZE(recv_data,8+4); + + sLog.outDebug("WORLD: Recv CMSG_UNSTABLE_PET."); + uint64 npcGUID; + uint32 petnumber; + + recv_data >> npcGUID >> petnumber; + + Creature *unit = ObjectAccessor::GetNPCIfCanInteractWith(*_player, npcGUID, UNIT_NPC_FLAG_STABLEMASTER); + if (!unit) + { + sLog.outDebug( "WORLD: HandleUnstablePet - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(npcGUID)) ); + return; + } + + // remove fake death + if(GetPlayer()->hasUnitState(UNIT_STAT_DIED)) + GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH); + + WorldPacket data(SMSG_STABLE_RESULT, 200); // guess size + + Pet* pet = _player->GetPet(); + if(pet && pet->isAlive()) + { + uint8 i = 0x06; + data << uint8(i); + SendPacket(&data); + return; + } + + // delete dead pet + if(pet) + _player->RemovePet(pet,PET_SAVE_AS_DELETED); + + Pet *newpet = NULL; + + QueryResult *result = CharacterDatabase.PQuery("SELECT entry FROM character_pet WHERE owner = '%u' AND id = '%u' AND slot > 0 AND slot < 3",_player->GetGUIDLow(),petnumber); + if(result) + { + Field *fields = result->Fetch(); + uint32 petentry = fields[0].GetUInt32(); + + newpet = new Pet(HUNTER_PET); + if(!newpet->LoadPetFromDB(_player,petentry,petnumber)) + { + delete newpet; + newpet = NULL; + } + delete result; + } + + if(newpet) + data << uint8(0x09); + else + data << uint8(0x06); + SendPacket(&data); +} + +void WorldSession::HandleBuyStableSlot( WorldPacket & recv_data ) +{ + CHECK_PACKET_SIZE(recv_data,8); + + sLog.outDebug("WORLD: Recv CMSG_BUY_STABLE_SLOT."); + uint64 npcGUID; + + recv_data >> npcGUID; + + Creature *unit = ObjectAccessor::GetNPCIfCanInteractWith(*_player, npcGUID, UNIT_NPC_FLAG_STABLEMASTER); + if (!unit) + { + sLog.outDebug( "WORLD: HandleBuyStableSlot - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(npcGUID)) ); + return; + } + + // remove fake death + if(GetPlayer()->hasUnitState(UNIT_STAT_DIED)) + GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH); + + WorldPacket data(SMSG_STABLE_RESULT, 200); + + if(GetPlayer()->m_stableSlots < 2) // max slots amount = 2 + { + StableSlotPricesEntry const *SlotPrice = sStableSlotPricesStore.LookupEntry(GetPlayer()->m_stableSlots+1); + if(_player->GetMoney() >= SlotPrice->Price) + { + ++GetPlayer()->m_stableSlots; + _player->ModifyMoney(-int32(SlotPrice->Price)); + data << uint8(0x0A); // success buy + } + else + data << uint8(0x06); + } + else + data << uint8(0x06); + + SendPacket(&data); +} + +void WorldSession::HandleStableRevivePet( WorldPacket &/* recv_data */) +{ + sLog.outDebug("HandleStableRevivePet: Not implemented"); +} + +void WorldSession::HandleStableSwapPet( WorldPacket & recv_data ) +{ + CHECK_PACKET_SIZE(recv_data,8+4); + + sLog.outDebug("WORLD: Recv CMSG_STABLE_SWAP_PET."); + uint64 npcGUID; + uint32 pet_number; + + recv_data >> npcGUID >> pet_number; + + Creature *unit = ObjectAccessor::GetNPCIfCanInteractWith(*_player, npcGUID, UNIT_NPC_FLAG_STABLEMASTER); + if (!unit) + { + sLog.outDebug( "WORLD: HandleStableSwapPet - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(npcGUID)) ); + return; + } + + // remove fake death + if(GetPlayer()->hasUnitState(UNIT_STAT_DIED)) + GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH); + + WorldPacket data(SMSG_STABLE_RESULT, 200); // guess size + + Pet* pet = _player->GetPet(); + + if(!pet || pet->getPetType()!=HUNTER_PET) + return; + + // find swapped pet slot in stable + QueryResult *result = CharacterDatabase.PQuery("SELECT slot,entry FROM character_pet WHERE owner = '%u' AND id = '%u'",_player->GetGUIDLow(),pet_number); + if(!result) + return; + + Field *fields = result->Fetch(); + + uint32 slot = fields[0].GetUInt32(); + uint32 petentry = fields[1].GetUInt32(); + delete result; + + // move alive pet to slot or delele dead pet + _player->RemovePet(pet,pet->isAlive() ? PetSaveMode(slot) : PET_SAVE_AS_DELETED); + + // summon unstabled pet + Pet *newpet = new Pet; + if(!newpet->LoadPetFromDB(_player,petentry,pet_number)) + { + delete newpet; + data << uint8(0x06); + } + else + data << uint8(0x09); + + SendPacket(&data); +} + +void WorldSession::HandleRepairItemOpcode( WorldPacket & recv_data ) +{ + CHECK_PACKET_SIZE(recv_data,8+8+1); + + sLog.outDebug("WORLD: CMSG_REPAIR_ITEM"); + + uint64 npcGUID, itemGUID; + uint8 guildBank; // new in 2.3.2, bool that means from guild bank money + + recv_data >> npcGUID >> itemGUID >> guildBank; + + Creature *unit = ObjectAccessor::GetNPCIfCanInteractWith(*_player, npcGUID, UNIT_NPC_FLAG_REPAIR); + if (!unit) + { + sLog.outDebug( "WORLD: HandleRepairItemOpcode - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(npcGUID)) ); + return; + } + + // remove fake death + if(GetPlayer()->hasUnitState(UNIT_STAT_DIED)) + GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH); + + // reputation discount + float discountMod = _player->GetReputationPriceDiscount(unit); + + uint32 TotalCost = 0; + if (itemGUID) + { + sLog.outDebug("ITEM: Repair item, itemGUID = %u, npcGUID = %u", GUID_LOPART(itemGUID), GUID_LOPART(npcGUID)); + + Item* item = _player->GetItemByGuid(itemGUID); + + if(item) + TotalCost= _player->DurabilityRepair(item->GetPos(),true,discountMod,guildBank>0?true:false); + } + else + { + sLog.outDebug("ITEM: Repair all items, npcGUID = %u", GUID_LOPART(npcGUID)); + + TotalCost = _player->DurabilityRepairAll(true,discountMod,guildBank>0?true:false); + } + if (guildBank) + { + uint32 GuildId = _player->GetGuildId(); + if (!GuildId) + return; + Guild *pGuild = objmgr.GetGuildById(GuildId); + if (!pGuild) + return; + pGuild->LogBankEvent(GUILD_BANK_LOG_REPAIR_MONEY, 0, _player->GetGUIDLow(), TotalCost); + pGuild->SendMoneyInfo(this, _player->GetGUIDLow()); + } +} diff --git a/src/game/ObjectMgr.cpp b/src/game/ObjectMgr.cpp index 982ae3c4bc4..a6cbb0e653d 100644 --- a/src/game/ObjectMgr.cpp +++ b/src/game/ObjectMgr.cpp @@ -1,6512 +1,6858 @@ -/* - * Copyright (C) 2005-2008 MaNGOS - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "Common.h" -#include "Database/DatabaseEnv.h" -#include "Database/SQLStorage.h" - -#include "Log.h" -#include "MapManager.h" -#include "ObjectMgr.h" -#include "SpellMgr.h" -#include "UpdateMask.h" -#include "World.h" -#include "WorldSession.h" -#include "Group.h" -#include "Guild.h" -#include "ArenaTeam.h" -#include "Transports.h" -#include "ProgressBar.h" -#include "Policies/SingletonImp.h" -#include "Language.h" -#include "GameEvent.h" -#include "Spell.h" -#include "Chat.h" -#include "InstanceSaveMgr.h" -#include "SpellAuras.h" -#include "Util.h" - -INSTANTIATE_SINGLETON_1(ObjectMgr); - -ScriptMapMap sQuestEndScripts; -ScriptMapMap sQuestStartScripts; -ScriptMapMap sSpellScripts; -ScriptMapMap sGameObjectScripts; -ScriptMapMap sEventScripts; - -bool normalizePlayerName(std::string& name) -{ - if(name.empty()) - return false; - - wchar_t wstr_buf[MAX_INTERNAL_PLAYER_NAME+1]; - size_t wstr_len = MAX_INTERNAL_PLAYER_NAME; - - if(!Utf8toWStr(name,&wstr_buf[0],wstr_len)) - return false; - - wstr_buf[0] = wcharToUpper(wstr_buf[0]); - for(size_t i = 1; i < wstr_len; ++i) - wstr_buf[i] = wcharToLower(wstr_buf[i]); - - if(!WStrToUtf8(wstr_buf,wstr_len,name)) - return false; - - return true; -} - -ObjectMgr::ObjectMgr() -{ - m_hiCharGuid = 1; - m_hiCreatureGuid = 1; - m_hiPetGuid = 1; - m_hiItemGuid = 1; - m_hiGoGuid = 1; - m_hiDoGuid = 1; - m_hiCorpseGuid = 1; - - m_hiPetNumber = 1; - - mGuildBankTabPrice.resize(GUILD_BANK_MAX_TABS); - mGuildBankTabPrice[0] = 100; - mGuildBankTabPrice[1] = 250; - mGuildBankTabPrice[2] = 500; - mGuildBankTabPrice[3] = 1000; - mGuildBankTabPrice[4] = 2500; - mGuildBankTabPrice[5] = 5000; - - // Only zero condition left, others will be added while loading DB tables - mConditions.resize(1); -} - -ObjectMgr::~ObjectMgr() -{ - for( QuestMap::iterator i = mQuestTemplates.begin( ); i != mQuestTemplates.end( ); ++ i ) - { - delete i->second; - } - mQuestTemplates.clear( ); - - for( GossipTextMap::iterator i = mGossipText.begin( ); i != mGossipText.end( ); ++ i ) - { - delete i->second; - } - mGossipText.clear( ); - - mAreaTriggers.clear(); - - for(PetLevelInfoMap::iterator i = petInfo.begin( ); i != petInfo.end( ); ++ i ) - { - delete[] i->second; - } - petInfo.clear(); - - // free only if loaded - for (int class_ = 0; class_ < MAX_CLASSES; ++class_) - delete[] playerClassInfo[class_].levelInfo; - - for (int race = 0; race < MAX_RACES; ++race) - for (int class_ = 0; class_ < MAX_CLASSES; ++class_) - delete[] playerInfo[race][class_].levelInfo; - - // free group and guild objects - for (GroupSet::iterator itr = mGroupSet.begin(); itr != mGroupSet.end(); ++itr) - delete (*itr); - for (GuildSet::iterator itr = mGuildSet.begin(); itr != mGuildSet.end(); ++itr) - delete (*itr); - - for(ItemMap::iterator itr = mAitems.begin(); itr != mAitems.end(); ++itr) - delete itr->second; -} - -Group * ObjectMgr::GetGroupByLeader(const uint64 &guid) const -{ - for(GroupSet::const_iterator itr = mGroupSet.begin(); itr != mGroupSet.end(); ++itr) - if ((*itr)->GetLeaderGUID() == guid) - return *itr; - - return NULL; -} - -Guild * ObjectMgr::GetGuildById(const uint32 GuildId) const -{ - for(GuildSet::const_iterator itr = mGuildSet.begin(); itr != mGuildSet.end(); itr++) - if ((*itr)->GetId() == GuildId) - return *itr; - - return NULL; -} - -Guild * ObjectMgr::GetGuildByName(std::string guildname) const -{ - for(GuildSet::const_iterator itr = mGuildSet.begin(); itr != mGuildSet.end(); itr++) - if ((*itr)->GetName() == guildname) - return *itr; - - return NULL; -} - -std::string ObjectMgr::GetGuildNameById(const uint32 GuildId) const -{ - for(GuildSet::const_iterator itr = mGuildSet.begin(); itr != mGuildSet.end(); itr++) - if ((*itr)->GetId() == GuildId) - return (*itr)->GetName(); - - return ""; -} - -Guild* ObjectMgr::GetGuildByLeader(const uint64 &guid) const -{ - for(GuildSet::const_iterator itr = mGuildSet.begin(); itr != mGuildSet.end(); ++itr) - if( (*itr)->GetLeader() == guid) - return *itr; - - return NULL; -} - -ArenaTeam* ObjectMgr::GetArenaTeamById(const uint32 ArenaTeamId) const -{ - for(ArenaTeamSet::const_iterator itr = mArenaTeamSet.begin(); itr != mArenaTeamSet.end(); itr++) - if ((*itr)->GetId() == ArenaTeamId) - return *itr; - - return NULL; -} - -ArenaTeam* ObjectMgr::GetArenaTeamByName(std::string arenateamname) const -{ - for(ArenaTeamSet::const_iterator itr = mArenaTeamSet.begin(); itr != mArenaTeamSet.end(); itr++) - if ((*itr)->GetName() == arenateamname) - return *itr; - - return NULL; -} - -ArenaTeam* ObjectMgr::GetArenaTeamByCapitan(uint64 const& guid) const -{ - for(ArenaTeamSet::const_iterator itr = mArenaTeamSet.begin(); itr != mArenaTeamSet.end(); itr++) - if ((*itr)->GetCaptain() == guid) - return *itr; - - return NULL; -} - -AuctionHouseObject * ObjectMgr::GetAuctionsMap( uint32 location ) -{ - switch ( location ) - { - case 6: //horde - return & mHordeAuctions; - break; - case 2: //alliance - return & mAllianceAuctions; - break; - default: //neutral - return & mNeutralAuctions; - } -} - -uint32 ObjectMgr::GetAuctionCut(uint32 location, uint32 highBid) -{ - if (location == 7 && !sWorld.getConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_AUCTION)) - return (uint32) (0.15f * highBid * sWorld.getRate(RATE_AUCTION_CUT)); - else - return (uint32) (0.05f * highBid * sWorld.getRate(RATE_AUCTION_CUT)); -} - -uint32 ObjectMgr::GetAuctionDeposit(uint32 location, uint32 time, Item *pItem) -{ - float percentance; // in 0..1 - if ( location == 7 && !sWorld.getConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_AUCTION)) - percentance = 0.75f; - else - percentance = 0.15f; - - percentance *= sWorld.getRate(RATE_AUCTION_DEPOSIT); - - return uint32( percentance * pItem->GetProto()->SellPrice * pItem->GetCount() * (time / MIN_AUCTION_TIME ) ); -} - -/// the sum of outbid is (1% from current bid)*5, if bid is very small, it is 1c -uint32 ObjectMgr::GetAuctionOutBid(uint32 currentBid) -{ - uint32 outbid = (currentBid / 100) * 5; - if (!outbid) - outbid = 1; - return outbid; -} - -//does not clear ram -void ObjectMgr::SendAuctionWonMail( AuctionEntry *auction ) -{ - Item *pItem = objmgr.GetAItem(auction->item_guidlow); - if(!pItem) - return; - - uint64 bidder_guid = MAKE_NEW_GUID(auction->bidder, 0, HIGHGUID_PLAYER); - Player *bidder = objmgr.GetPlayer(bidder_guid); - - uint32 bidder_accId = 0; - - // data for gm.log - if( sWorld.getConfig(CONFIG_GM_LOG_TRADE) ) - { - uint32 bidder_security = 0; - std::string bidder_name; - if (bidder) - { - bidder_accId = bidder->GetSession()->GetAccountId(); - bidder_security = bidder->GetSession()->GetSecurity(); - bidder_name = bidder->GetName(); - } - else - { - bidder_accId = GetPlayerAccountIdByGUID(bidder_guid); - bidder_security = GetSecurityByAccount(bidder_accId); - - if(bidder_security > SEC_PLAYER ) // not do redundant DB requests - { - if(!GetPlayerNameByGUID(bidder_guid,bidder_name)) - bidder_name = GetMangosStringForDBCLocale(LANG_UNKNOWN); - } - } - - if( bidder_security > SEC_PLAYER ) - { - std::string owner_name; - if(!GetPlayerNameByGUID(auction->owner,owner_name)) - owner_name = GetMangosStringForDBCLocale(LANG_UNKNOWN); - - uint32 owner_accid = GetPlayerAccountIdByGUID(auction->owner); - - sLog.outCommand("GM %s (Account: %u) won item in auction: %s (Entry: %u Count: %u) and pay money: %u. Original owner %s (Account: %u)", - bidder_name.c_str(),bidder_accId,pItem->GetProto()->Name1,pItem->GetEntry(),pItem->GetCount(),auction->bid,owner_name.c_str(),owner_accid); - } - } - else if(!bidder) - bidder_accId = GetPlayerAccountIdByGUID(bidder_guid); - - // receiver exist - if(bidder || bidder_accId) - { - std::ostringstream msgAuctionWonSubject; - msgAuctionWonSubject << auction->item_template << ":0:" << AUCTION_WON; - - std::ostringstream msgAuctionWonBody; - msgAuctionWonBody.width(16); - msgAuctionWonBody << std::right << std::hex << auction->owner; - msgAuctionWonBody << std::dec << ":" << auction->bid << ":" << auction->buyout; - sLog.outDebug( "AuctionWon body string : %s", msgAuctionWonBody.str().c_str() ); - - //prepare mail data... : - uint32 itemTextId = this->CreateItemText( msgAuctionWonBody.str() ); - - // set owner to bidder (to prevent delete item with sender char deleting) - // owner in `data` will set at mail receive and item extracting - CharacterDatabase.PExecute("UPDATE item_instance SET owner_guid = '%u' WHERE guid='%u'",auction->bidder,pItem->GetGUIDLow()); - CharacterDatabase.CommitTransaction(); - - MailItemsInfo mi; - mi.AddItem(auction->item_guidlow, auction->item_template, pItem); - - if (bidder) - bidder->GetSession()->SendAuctionBidderNotification( auction->location, auction->Id, bidder_guid, 0, 0, auction->item_template); - else - objmgr.RemoveAItem(pItem->GetGUIDLow()); // we have to remove the item, before we delete it !! - - // will delete item or place to receiver mail list - WorldSession::SendMailTo(bidder, MAIL_AUCTION, MAIL_STATIONERY_AUCTION, auction->location, auction->bidder, msgAuctionWonSubject.str(), itemTextId, &mi, 0, 0, MAIL_CHECK_MASK_AUCTION); - } - // receiver not exist - else - { - CharacterDatabase.PExecute("DELETE FROM item_instance WHERE guid='%u'", pItem->GetGUIDLow()); - objmgr.RemoveAItem(pItem->GetGUIDLow()); // we have to remove the item, before we delete it !! - delete pItem; - } -} - -void ObjectMgr::SendAuctionSalePendingMail( AuctionEntry * auction ) -{ - uint64 owner_guid = MAKE_NEW_GUID(auction->owner, 0, HIGHGUID_PLAYER); - Player *owner = objmgr.GetPlayer(owner_guid); - - // owner exist (online or offline) - if(owner || GetPlayerAccountIdByGUID(owner_guid)) - { - std::ostringstream msgAuctionSalePendingSubject; - msgAuctionSalePendingSubject << auction->item_template << ":0:" << AUCTION_SALE_PENDING; - - std::ostringstream msgAuctionSalePendingBody; - uint32 auctionCut = GetAuctionCut(auction->location, auction->bid); - - time_t distrTime = time(NULL) + HOUR; - - msgAuctionSalePendingBody.width(16); - msgAuctionSalePendingBody << std::right << std::hex << auction->bidder; - msgAuctionSalePendingBody << std::dec << ":" << auction->bid << ":" << auction->buyout; - msgAuctionSalePendingBody << ":" << auction->deposit << ":" << auctionCut << ":0:"; - msgAuctionSalePendingBody << secsToTimeBitFields(distrTime); - - sLog.outDebug("AuctionSalePending body string : %s", msgAuctionSalePendingBody.str().c_str()); - - uint32 itemTextId = this->CreateItemText( msgAuctionSalePendingBody.str() ); - - WorldSession::SendMailTo(owner, MAIL_AUCTION, MAIL_STATIONERY_AUCTION, auction->location, auction->owner, msgAuctionSalePendingSubject.str(), itemTextId, NULL, 0, 0, MAIL_CHECK_MASK_AUCTION); - } -} - -//call this method to send mail to auction owner, when auction is successful, it does not clear ram -void ObjectMgr::SendAuctionSuccessfulMail( AuctionEntry * auction ) -{ - uint64 owner_guid = MAKE_NEW_GUID(auction->owner, 0, HIGHGUID_PLAYER); - Player *owner = objmgr.GetPlayer(owner_guid); - - uint32 owner_accId = 0; - if(!owner) - owner_accId = GetPlayerAccountIdByGUID(owner_guid); - - // owner exist - if(owner || owner_accId) - { - std::ostringstream msgAuctionSuccessfulSubject; - msgAuctionSuccessfulSubject << auction->item_template << ":0:" << AUCTION_SUCCESSFUL; - - std::ostringstream auctionSuccessfulBody; - uint32 auctionCut = GetAuctionCut(auction->location, auction->bid); - - auctionSuccessfulBody.width(16); - auctionSuccessfulBody << std::right << std::hex << auction->bidder; - auctionSuccessfulBody << std::dec << ":" << auction->bid << ":" << auction->buyout; - auctionSuccessfulBody << ":" << auction->deposit << ":" << auctionCut; - - sLog.outDebug("AuctionSuccessful body string : %s", auctionSuccessfulBody.str().c_str()); - - uint32 itemTextId = this->CreateItemText( auctionSuccessfulBody.str() ); - - uint32 profit = auction->bid + auction->deposit - auctionCut; - - if (owner) - { - //send auction owner notification, bidder must be current! - owner->GetSession()->SendAuctionOwnerNotification( auction ); - } - - WorldSession::SendMailTo(owner, MAIL_AUCTION, MAIL_STATIONERY_AUCTION, auction->location, auction->owner, msgAuctionSuccessfulSubject.str(), itemTextId, NULL, profit, 0, MAIL_CHECK_MASK_AUCTION, HOUR); - } -} - -//does not clear ram -void ObjectMgr::SendAuctionExpiredMail( AuctionEntry * auction ) -{ //return an item in auction to its owner by mail - Item *pItem = objmgr.GetAItem(auction->item_guidlow); - if(!pItem) - { - sLog.outError("Auction item (GUID: %u) not found, and lost.",auction->item_guidlow); - return; - } - - uint64 owner_guid = MAKE_NEW_GUID(auction->owner, 0, HIGHGUID_PLAYER); - Player *owner = objmgr.GetPlayer(owner_guid); - - uint32 owner_accId = 0; - if(!owner) - owner_accId = GetPlayerAccountIdByGUID(owner_guid); - - // owner exist - if(owner || owner_accId) - { - std::ostringstream subject; - subject << auction->item_template << ":0:" << AUCTION_EXPIRED; - - if ( owner ) - owner->GetSession()->SendAuctionOwnerNotification( auction ); - else - objmgr.RemoveAItem(pItem->GetGUIDLow()); // we have to remove the item, before we delete it !! - - MailItemsInfo mi; - mi.AddItem(auction->item_guidlow, auction->item_template, pItem); - - // will delete item or place to receiver mail list - WorldSession::SendMailTo(owner, MAIL_AUCTION, MAIL_STATIONERY_AUCTION, auction->location, GUID_LOPART(owner_guid), subject.str(), 0, &mi, 0, 0, MAIL_CHECK_MASK_NONE); - - } - // owner not found - else - { - CharacterDatabase.PExecute("DELETE FROM item_instance WHERE guid='%u'",pItem->GetGUIDLow()); - objmgr.RemoveAItem(pItem->GetGUIDLow()); // we have to remove the item, before we delete it !! - delete pItem; - } -} - -CreatureInfo const* ObjectMgr::GetCreatureTemplate(uint32 id) -{ - return sCreatureStorage.LookupEntry(id); -} - -void ObjectMgr::LoadCreatureLocales() -{ - QueryResult *result = WorldDatabase.Query("SELECT entry,name_loc1,subname_loc1,name_loc2,subname_loc2,name_loc3,subname_loc3,name_loc4,subname_loc4,name_loc5,subname_loc5,name_loc6,subname_loc6,name_loc7,subname_loc7,name_loc8,subname_loc8 FROM locales_creature"); - - if(!result) - { - barGoLink bar(1); - - bar.step(); - - sLog.outString(""); - sLog.outString(">> Loaded 0 creature locale strings. DB table `locales_creature` is empty."); - return; - } - - barGoLink bar(result->GetRowCount()); - - do - { - Field *fields = result->Fetch(); - bar.step(); - - uint32 entry = fields[0].GetUInt32(); - - CreatureLocale& data = mCreatureLocaleMap[entry]; - - for(int i = 1; i < MAX_LOCALE; ++i) - { - std::string str = fields[1+2*(i-1)].GetCppString(); - if(!str.empty()) - { - int idx = GetOrNewIndexForLocale(LocaleConstant(i)); - if(idx >= 0) - { - if(data.Name.size() <= idx) - data.Name.resize(idx+1); - - data.Name[idx] = str; - } - } - str = fields[1+2*(i-1)+1].GetCppString(); - if(!str.empty()) - { - int idx = GetOrNewIndexForLocale(LocaleConstant(i)); - if(idx >= 0) - { - if(data.SubName.size() <= idx) - data.SubName.resize(idx+1); - - data.SubName[idx] = str; - } - } - } - } while (result->NextRow()); - - delete result; - - sLog.outString(); - sLog.outString( ">> Loaded %u creature locale strings", mCreatureLocaleMap.size() ); -} - -void ObjectMgr::LoadCreatureTemplates() -{ - sCreatureStorage.Load(); - - sLog.outString( ">> Loaded %u creature definitions", sCreatureStorage.RecordCount ); - sLog.outString(); - - std::set heroicEntries; // already loaded heroic value in creatures - std::set hasHeroicEntries; // already loaded creatures with heroic entry values - - // check data correctness - for(uint32 i = 1; i < sCreatureStorage.MaxEntry; ++i) - { - CreatureInfo const* cInfo = sCreatureStorage.LookupEntry(i); - if(!cInfo) - continue; - - if(cInfo->HeroicEntry) - { - CreatureInfo const* heroicInfo = GetCreatureTemplate(cInfo->HeroicEntry); - if(!heroicInfo) - { - sLog.outErrorDb("Creature (Entry: %u) have `heroic_entry`=%u but creature entry %u not exist.",cInfo->HeroicEntry,cInfo->HeroicEntry); - continue; - } - - if(heroicEntries.find(i)!=heroicEntries.end()) - { - sLog.outErrorDb("Creature (Entry: %u) listed as heroic but have value in `heroic_entry`.",i); - continue; - } - - if(heroicEntries.find(cInfo->HeroicEntry)!=heroicEntries.end()) - { - sLog.outErrorDb("Creature (Entry: %u) already listed as heroic for another entry.",cInfo->HeroicEntry); - continue; - } - - if(hasHeroicEntries.find(cInfo->HeroicEntry)!=hasHeroicEntries.end()) - { - sLog.outErrorDb("Creature (Entry: %u) have `heroic_entry`=%u but creature entry %u have heroic entry also.",i,cInfo->HeroicEntry,cInfo->HeroicEntry); - continue; - } - - if(cInfo->npcflag != heroicInfo->npcflag) - { - sLog.outErrorDb("Creature (Entry: %u) listed in `creature_template_substitution` has different `npcflag` in heroic mode.",i); - continue; - } - - if(cInfo->classNum != heroicInfo->classNum) - { - sLog.outErrorDb("Creature (Entry: %u) listed in `creature_template_substitution` has different `classNum` in heroic mode.",i); - continue; - } - - if(cInfo->race != heroicInfo->race) - { - sLog.outErrorDb("Creature (Entry: %u) listed in `creature_template_substitution` has different `race` in heroic mode.",i); - continue; - } - - if(cInfo->trainer_type != heroicInfo->trainer_type) - { - sLog.outErrorDb("Creature (Entry: %u) listed in `creature_template_substitution` has different `trainer_type` in heroic mode.",i); - continue; - } - - if(cInfo->trainer_spell != heroicInfo->trainer_spell) - { - sLog.outErrorDb("Creature (Entry: %u) listed in `creature_template_substitution` has different `trainer_spell` in heroic mode.",i); - continue; - } - - hasHeroicEntries.insert(i); - heroicEntries.insert(cInfo->HeroicEntry); - } - - FactionTemplateEntry const* factionTemplate = sFactionTemplateStore.LookupEntry(cInfo->faction_A); - if(!factionTemplate) - sLog.outErrorDb("Creature (Entry: %u) has non-existing faction_A template (%u)", cInfo->Entry, cInfo->faction_A); - - factionTemplate = sFactionTemplateStore.LookupEntry(cInfo->faction_H); - if(!factionTemplate) - sLog.outErrorDb("Creature (Entry: %u) has non-existing faction_H template (%u)", cInfo->Entry, cInfo->faction_H); - - CreatureModelInfo const* minfo = sCreatureModelStorage.LookupEntry(cInfo->DisplayID_A); - if (!minfo) - sLog.outErrorDb("Creature (Entry: %u) has non-existing modelId_A (%u)", cInfo->Entry, cInfo->DisplayID_A); - minfo = sCreatureModelStorage.LookupEntry(cInfo->DisplayID_H); - if (!minfo) - sLog.outErrorDb("Creature (Entry: %u) has non-existing modelId_H (%u)", cInfo->Entry, cInfo->DisplayID_H); - - if(cInfo->dmgschool >= MAX_SPELL_SCHOOL) - { - sLog.outErrorDb("Creature (Entry: %u) has invalid spell school value (%u) in `dmgschool`",cInfo->Entry,cInfo->dmgschool); - const_cast(cInfo)->dmgschool = SPELL_SCHOOL_NORMAL; - } - - if(cInfo->baseattacktime == 0) - const_cast(cInfo)->baseattacktime = BASE_ATTACK_TIME; - - if(cInfo->rangeattacktime == 0) - const_cast(cInfo)->rangeattacktime = BASE_ATTACK_TIME; - - if((cInfo->npcflag & UNIT_NPC_FLAG_TRAINER) && cInfo->trainer_type >= MAX_TRAINER_TYPE) - sLog.outErrorDb("Creature (Entry: %u) has wrong trainer type %u",cInfo->Entry,cInfo->trainer_type); - - if(cInfo->InhabitType <= 0 || cInfo->InhabitType > INHABIT_ANYWHERE) - { - sLog.outErrorDb("Creature (Entry: %u) has wrong value (%u) in `InhabitType`, creature will not correctly walk/swim/fly",cInfo->Entry,cInfo->InhabitType); - const_cast(cInfo)->InhabitType = INHABIT_ANYWHERE; - } - - if(cInfo->PetSpellDataId) - { - CreatureSpellDataEntry const* spellDataId = sCreatureSpellDataStore.LookupEntry(cInfo->PetSpellDataId); - if(!spellDataId) - sLog.outErrorDb("Creature (Entry: %u) has non-existing PetSpellDataId (%u)", cInfo->Entry, cInfo->PetSpellDataId); - } - - if(cInfo->MovementType >= MAX_DB_MOTION_TYPE) - { - sLog.outErrorDb("Creature (Entry: %u) has wrong movement generator type (%u), ignore and set to IDLE.",cInfo->Entry,cInfo->MovementType); - const_cast(cInfo)->MovementType = IDLE_MOTION_TYPE; - } - - if(cInfo->equipmentId > 0) // 0 no equipment - { - if(!GetEquipmentInfo(cInfo->equipmentId)) - { - sLog.outErrorDb("Table `creature_template` have creature (Entry: %u) with equipment_id %u not found in table `creature_equip_template`, set to no equipment.", cInfo->Entry, cInfo->equipmentId); - const_cast(cInfo)->equipmentId = 0; - } - } - - /// if not set custom creature scale then load scale from CreatureDisplayInfo.dbc - if(cInfo->scale <= 0.0f) - { - CreatureDisplayInfoEntry const* ScaleEntry = sCreatureDisplayInfoStore.LookupEntry(cInfo->DisplayID_A); - const_cast(cInfo)->scale = ScaleEntry ? ScaleEntry->scale : 1.0f; - } - } -} - -void ObjectMgr::ConvertCreatureAddonAuras(CreatureDataAddon* addon, char const* table, char const* guidEntryStr) -{ - // Now add the auras, format "spellid effectindex spellid effectindex..." - char *p,*s; - std::vector val; - s=p=(char*)reinterpret_cast(addon->auras); - if(p) - { - while (p[0]!=0) - { - ++p; - if (p[0]==' ') - { - val.push_back(atoi(s)); - s=++p; - } - } - if (p!=s) - val.push_back(atoi(s)); - - // free char* loaded memory - delete[] (char*)reinterpret_cast(addon->auras); - - // wrong list - if (val.size()%2) - { - addon->auras = NULL; - sLog.outErrorDb("Creature (%s: %u) has wrong `auras` data in `%s`.",guidEntryStr,addon->guidOrEntry,table); - return; - } - } - - // empty list - if(val.empty()) - { - addon->auras = NULL; - return; - } - - // replace by new strucutres array - const_cast(addon->auras) = new CreatureDataAddonAura[val.size()/2+1]; - - int i=0; - for(int j=0;j(addon->auras[i]); - cAura.spell_id = (uint32)val[2*j+0]; - cAura.effect_idx = (uint32)val[2*j+1]; - if ( cAura.effect_idx > 2 ) - { - sLog.outErrorDb("Creature (%s: %u) has wrong effect %u for spell %u in `auras` field in `%s`.",guidEntryStr,addon->guidOrEntry,cAura.effect_idx,cAura.spell_id,table); - continue; - } - SpellEntry const *AdditionalSpellInfo = sSpellStore.LookupEntry(cAura.spell_id); - if (!AdditionalSpellInfo) - { - sLog.outErrorDb("Creature (%s: %u) has wrong spell %u defined in `auras` field in `%s`.",guidEntryStr,addon->guidOrEntry,cAura.spell_id,table); - continue; - } - - if (!AdditionalSpellInfo->Effect[cAura.effect_idx] || !AdditionalSpellInfo->EffectApplyAuraName[cAura.effect_idx]) - { - sLog.outErrorDb("Creature (%s: %u) has not aura effect %u of spell %u defined in `auras` field in `%s`.",guidEntryStr,addon->guidOrEntry,cAura.effect_idx,cAura.spell_id,table); - continue; - } - - ++i; - } - - // fill terminator element (after last added) - CreatureDataAddonAura& endAura = const_cast(addon->auras[i]); - endAura.spell_id = 0; - endAura.effect_idx = 0; -} - -void ObjectMgr::LoadCreatureAddons() -{ - sCreatureInfoAddonStorage.Load(); - - sLog.outString( ">> Loaded %u creature template addons", sCreatureInfoAddonStorage.RecordCount ); - sLog.outString(); - - // check data correctness and convert 'auras' - for(uint32 i = 1; i < sCreatureInfoAddonStorage.MaxEntry; ++i) - { - CreatureDataAddon const* addon = sCreatureInfoAddonStorage.LookupEntry(i); - if(!addon) - continue; - - ConvertCreatureAddonAuras(const_cast(addon), "creature_template_addon", "Entry"); - - if(!sCreatureStorage.LookupEntry(addon->guidOrEntry)) - sLog.outErrorDb("Creature (Entry: %u) does not exist but has a record in `creature_template_addon`",addon->guidOrEntry); - } - - sCreatureDataAddonStorage.Load(); - - sLog.outString( ">> Loaded %u creature addons", sCreatureDataAddonStorage.RecordCount ); - sLog.outString(); - - // check data correctness and convert 'auras' - for(uint32 i = 1; i < sCreatureDataAddonStorage.MaxEntry; ++i) - { - CreatureDataAddon const* addon = sCreatureDataAddonStorage.LookupEntry(i); - if(!addon) - continue; - - ConvertCreatureAddonAuras(const_cast(addon), "creature_addon", "GUIDLow"); - - if(mCreatureDataMap.find(addon->guidOrEntry)==mCreatureDataMap.end()) - sLog.outErrorDb("Creature (GUID: %u) does not exist but has a record in `creature_addon`",addon->guidOrEntry); - } -} - -EquipmentInfo const* ObjectMgr::GetEquipmentInfo(uint32 entry) -{ - return sEquipmentStorage.LookupEntry(entry); -} - -void ObjectMgr::LoadEquipmentTemplates() -{ - sEquipmentStorage.Load(); - - sLog.outString( ">> Loaded %u equipment template", sEquipmentStorage.RecordCount ); - sLog.outString(); -} - -CreatureModelInfo const* ObjectMgr::GetCreatureModelInfo(uint32 modelid) -{ - return sCreatureModelStorage.LookupEntry(modelid); -} - -uint32 ObjectMgr::ChooseDisplayId(uint32 team, const CreatureInfo *cinfo, const CreatureData *data) -{ - // Load creature model (display id) - uint32 display_id; - if (!data || data->displayid == 0) // use defaults from the template - { - // DisplayID_A is used if no team is given - if (team == HORDE) - display_id = (cinfo->DisplayID_H2 != 0 && urand(0,1) == 0) ? cinfo->DisplayID_H2 : cinfo->DisplayID_H; - else - display_id = (cinfo->DisplayID_A2 != 0 && urand(0,1) == 0) ? cinfo->DisplayID_A2 : cinfo->DisplayID_A; - } - else // overriden in creature data - display_id = data->displayid; - - return display_id; -} - -CreatureModelInfo const* ObjectMgr::GetCreatureModelRandomGender(uint32 display_id) -{ - CreatureModelInfo const *minfo = GetCreatureModelInfo(display_id); - if(!minfo) - return NULL; - - // If a model for another gender exists, 50% chance to use it - if(minfo->modelid_other_gender != 0 && urand(0,1) == 0) - { - CreatureModelInfo const *minfo_tmp = GetCreatureModelInfo(minfo->modelid_other_gender); - if(!minfo_tmp) - { - sLog.outErrorDb("Model (Entry: %u) has modelid_other_gender %u not found in table `creature_model_info`. ", minfo->modelid, minfo->modelid_other_gender); - return minfo; // not fatal, just use the previous one - } - else - return minfo_tmp; - } - else - return minfo; -} - -void ObjectMgr::LoadCreatureModelInfo() -{ - sCreatureModelStorage.Load(); - - sLog.outString( ">> Loaded %u creature model based info", sCreatureModelStorage.RecordCount ); - sLog.outString(); -} - -void ObjectMgr::LoadCreatures() -{ - uint32 count = 0; - // 0 1 2 3 - QueryResult *result = WorldDatabase.Query("SELECT creature.guid, id, map, modelid," - // 4 5 6 7 8 9 10 11 - "equipment_id, position_x, position_y, position_z, orientation, spawntimesecs, spawndist, currentwaypoint," - // 12 13 14 15 16 17 - "curhealth, curmana, DeathState, MovementType, spawnMask, event " - "FROM creature LEFT OUTER JOIN game_event_creature ON creature.guid = game_event_creature.guid"); - - if(!result) - { - barGoLink bar(1); - - bar.step(); - - sLog.outString(""); - sLog.outErrorDb(">> Loaded 0 creature. DB table `creature` is empty."); - return; - } - - // build single time for check creature data - std::set heroicCreatures; - for(uint32 i = 0; i < sCreatureStorage.MaxEntry; ++i) - if(CreatureInfo const* cInfo = sCreatureStorage.LookupEntry(i)) - if(cInfo->HeroicEntry) - heroicCreatures.insert(cInfo->HeroicEntry); - - barGoLink bar(result->GetRowCount()); - - do - { - Field *fields = result->Fetch(); - bar.step(); - - uint32 guid = fields[0].GetUInt32(); - - CreatureData& data = mCreatureDataMap[guid]; - - data.id = fields[ 1].GetUInt32(); - data.mapid = fields[ 2].GetUInt32(); - data.displayid = fields[ 3].GetUInt32(); - data.equipmentId = fields[ 4].GetUInt32(); - data.posX = fields[ 5].GetFloat(); - data.posY = fields[ 6].GetFloat(); - data.posZ = fields[ 7].GetFloat(); - data.orientation = fields[ 8].GetFloat(); - data.spawntimesecs = fields[ 9].GetUInt32(); - data.spawndist = fields[10].GetFloat(); - data.currentwaypoint= fields[11].GetUInt32(); - data.curhealth = fields[12].GetUInt32(); - data.curmana = fields[13].GetUInt32(); - data.is_dead = fields[14].GetBool(); - data.movementType = fields[15].GetUInt8(); - data.spawnMask = fields[16].GetUInt8(); - int16 gameEvent = fields[17].GetInt16(); - - CreatureInfo const* cInfo = GetCreatureTemplate(data.id); - if(!cInfo) - { - sLog.outErrorDb("Table `creature` have creature (GUID: %u) with not existed creature entry %u, skipped.",guid,data.id ); - continue; - } - - if(heroicCreatures.find(data.id)!=heroicCreatures.end()) - { - sLog.outErrorDb("Table `creature` have creature (GUID: %u) that listed as heroic template in `creature_template_substitution`, skipped.",guid,data.id ); - continue; - } - - if(data.equipmentId > 0) // -1 no equipment, 0 use default - { - if(!GetEquipmentInfo(data.equipmentId)) - { - sLog.outErrorDb("Table `creature` have creature (Entry: %u) with equipment_id %u not found in table `creature_equip_template`, set to no equipment.", data.id, data.equipmentId); - data.equipmentId = -1; - } - } - - if(cInfo->RegenHealth && data.curhealth < cInfo->minhealth) - { - sLog.outErrorDb("Table `creature` have creature (GUID: %u Entry: %u) with `creature_template`.`RegenHealth`=1 and low current health (%u), `creature_template`.`minhealth`=%u.",guid,data.id,data.curhealth, cInfo->minhealth ); - data.curhealth = cInfo->minhealth; - } - - if(data.curmana < cInfo->minmana) - { - sLog.outErrorDb("Table `creature` have creature (GUID: %u Entry: %u) with low current mana (%u), `creature_template`.`minmana`=%u.",guid,data.id,data.curmana, cInfo->minmana ); - data.curmana = cInfo->minmana; - } - - if(data.spawndist < 0.0f) - { - sLog.outErrorDb("Table `creature` have creature (GUID: %u Entry: %u) with `spawndist`< 0, set to 0.",guid,data.id ); - data.spawndist = 0.0f; - } - else if(data.movementType == RANDOM_MOTION_TYPE) - { - if(data.spawndist == 0.0f) - { - sLog.outErrorDb("Table `creature` have creature (GUID: %u Entry: %u) with `MovementType`=1 (random movement) but with `spawndist`=0, replace by idle movement type (0).",guid,data.id ); - data.movementType = IDLE_MOTION_TYPE; - } - } - else if(data.movementType == IDLE_MOTION_TYPE) - { - if(data.spawndist != 0.0f) - { - sLog.outErrorDb("Table `creature` have creature (GUID: %u Entry: %u) with `MovementType`=0 (idle) have `spawndist`<>0, set to 0.",guid,data.id ); - data.spawndist = 0.0f; - } - } - - if (gameEvent==0) // if not this is to be managed by GameEvent System - AddCreatureToGrid(guid, &data); - ++count; - - } while (result->NextRow()); - - delete result; - - sLog.outString(); - sLog.outString( ">> Loaded %u creatures", mCreatureDataMap.size() ); -} - -void ObjectMgr::AddCreatureToGrid(uint32 guid, CreatureData const* data) -{ - uint8 mask = data->spawnMask; - for(uint8 i = 0; mask != 0; i++, mask >>= 1) - { - if(mask & 1) - { - CellPair cell_pair = MaNGOS::ComputeCellPair(data->posX, data->posY); - uint32 cell_id = (cell_pair.y_coord*TOTAL_NUMBER_OF_CELLS_PER_MAP) + cell_pair.x_coord; - - CellObjectGuids& cell_guids = mMapObjectGuids[MAKE_PAIR32(data->mapid,i)][cell_id]; - cell_guids.creatures.insert(guid); - } - } -} - -void ObjectMgr::RemoveCreatureFromGrid(uint32 guid, CreatureData const* data) -{ - uint8 mask = data->spawnMask; - for(uint8 i = 0; mask != 0; i++, mask >>= 1) - { - if(mask & 1) - { - CellPair cell_pair = MaNGOS::ComputeCellPair(data->posX, data->posY); - uint32 cell_id = (cell_pair.y_coord*TOTAL_NUMBER_OF_CELLS_PER_MAP) + cell_pair.x_coord; - - CellObjectGuids& cell_guids = mMapObjectGuids[MAKE_PAIR32(data->mapid,i)][cell_id]; - cell_guids.creatures.erase(guid); - } - } -} - -void ObjectMgr::LoadGameobjects() -{ - uint32 count = 0; - - // 0 1 2 3 4 5 6 - QueryResult *result = WorldDatabase.Query("SELECT gameobject.guid, id, map, position_x, position_y, position_z, orientation," - // 7 8 9 10 11 12 13 14 15 - "rotation0, rotation1, rotation2, rotation3, spawntimesecs, animprogress, state, spawnMask, event " - "FROM gameobject LEFT OUTER JOIN game_event_gameobject ON gameobject.guid = game_event_gameobject.guid"); - - if(!result) - { - barGoLink bar(1); - - bar.step(); - - sLog.outString(); - sLog.outErrorDb(">> Loaded 0 gameobjects. DB table `gameobject` is empty."); - return; - } - - barGoLink bar(result->GetRowCount()); - - do - { - Field *fields = result->Fetch(); - bar.step(); - - uint32 guid = fields[0].GetUInt32(); - - GameObjectData& data = mGameObjectDataMap[guid]; - - data.id = fields[ 1].GetUInt32(); - data.mapid = fields[ 2].GetUInt32(); - data.posX = fields[ 3].GetFloat(); - data.posY = fields[ 4].GetFloat(); - data.posZ = fields[ 5].GetFloat(); - data.orientation = fields[ 6].GetFloat(); - data.rotation0 = fields[ 7].GetFloat(); - data.rotation1 = fields[ 8].GetFloat(); - data.rotation2 = fields[ 9].GetFloat(); - data.rotation3 = fields[10].GetFloat(); - data.spawntimesecs = fields[11].GetInt32(); - data.animprogress = fields[12].GetUInt32(); - data.go_state = fields[13].GetUInt32(); - data.spawnMask = fields[14].GetUInt8(); - int16 gameEvent = fields[15].GetInt16(); - - GameObjectInfo const* gInfo = GetGameObjectInfo(data.id); - if(!gInfo) - { - sLog.outErrorDb("Table `gameobject` have gameobject (GUID: %u) with not existed gameobject entry %u, skipped.",guid,data.id ); - continue; - } - - if (gameEvent==0) // if not this is to be managed by GameEvent System - AddGameobjectToGrid(guid, &data); - ++count; - - } while (result->NextRow()); - - delete result; - - sLog.outString(); - sLog.outString( ">> Loaded %u gameobjects", mGameObjectDataMap.size()); -} - -void ObjectMgr::AddGameobjectToGrid(uint32 guid, GameObjectData const* data) -{ - uint8 mask = data->spawnMask; - for(uint8 i = 0; mask != 0; i++, mask >>= 1) - { - if(mask & 1) - { - CellPair cell_pair = MaNGOS::ComputeCellPair(data->posX, data->posY); - uint32 cell_id = (cell_pair.y_coord*TOTAL_NUMBER_OF_CELLS_PER_MAP) + cell_pair.x_coord; - - CellObjectGuids& cell_guids = mMapObjectGuids[MAKE_PAIR32(data->mapid,i)][cell_id]; - cell_guids.gameobjects.insert(guid); - } - } -} - -void ObjectMgr::RemoveGameobjectFromGrid(uint32 guid, GameObjectData const* data) -{ - uint8 mask = data->spawnMask; - for(uint8 i = 0; mask != 0; i++, mask >>= 1) - { - if(mask & 1) - { - CellPair cell_pair = MaNGOS::ComputeCellPair(data->posX, data->posY); - uint32 cell_id = (cell_pair.y_coord*TOTAL_NUMBER_OF_CELLS_PER_MAP) + cell_pair.x_coord; - - CellObjectGuids& cell_guids = mMapObjectGuids[MAKE_PAIR32(data->mapid,i)][cell_id]; - cell_guids.gameobjects.erase(guid); - } - } -} - -void ObjectMgr::LoadCreatureRespawnTimes() -{ - // remove outdated data - WorldDatabase.DirectExecute("DELETE FROM creature_respawn WHERE respawntime <= UNIX_TIMESTAMP(NOW())"); - - uint32 count = 0; - - QueryResult *result = WorldDatabase.Query("SELECT guid,respawntime,instance FROM creature_respawn"); - - if(!result) - { - barGoLink bar(1); - - bar.step(); - - sLog.outString(); - sLog.outString(">> Loaded 0 creature respawn time."); - return; - } - - barGoLink bar(result->GetRowCount()); - - do - { - Field *fields = result->Fetch(); - bar.step(); - - uint32 loguid = fields[0].GetUInt32(); - uint64 respawn_time = fields[1].GetUInt64(); - uint32 instance = fields[2].GetUInt32(); - - mCreatureRespawnTimes[MAKE_PAIR64(loguid,instance)] = time_t(respawn_time); - - ++count; - } while (result->NextRow()); - - delete result; - - sLog.outString( ">> Loaded %u creature respawn times", mCreatureRespawnTimes.size() ); - sLog.outString(); -} - -void ObjectMgr::LoadGameobjectRespawnTimes() -{ - // remove outdated data - WorldDatabase.DirectExecute("DELETE FROM gameobject_respawn WHERE respawntime <= UNIX_TIMESTAMP(NOW())"); - - uint32 count = 0; - - QueryResult *result = WorldDatabase.Query("SELECT guid,respawntime,instance FROM gameobject_respawn"); - - if(!result) - { - barGoLink bar(1); - - bar.step(); - - sLog.outString(); - sLog.outString(">> Loaded 0 gameobject respawn time."); - return; - } - - barGoLink bar(result->GetRowCount()); - - do - { - Field *fields = result->Fetch(); - bar.step(); - - uint32 loguid = fields[0].GetUInt32(); - uint64 respawn_time = fields[1].GetUInt64(); - uint32 instance = fields[2].GetUInt32(); - - mGORespawnTimes[MAKE_PAIR64(loguid,instance)] = time_t(respawn_time); - - ++count; - } while (result->NextRow()); - - delete result; - - sLog.outString( ">> Loaded %u gameobject respawn times", mGORespawnTimes.size() ); - sLog.outString(); -} - -// name must be checked to correctness (if received) before call this function -uint64 ObjectMgr::GetPlayerGUIDByName(std::string name) const -{ - uint64 guid = 0; - - CharacterDatabase.escape_string(name); - - // Player name safe to sending to DB (checked at login) and this function using - QueryResult *result = CharacterDatabase.PQuery("SELECT guid FROM characters WHERE name = '%s'", name.c_str()); - if(result) - { - guid = MAKE_NEW_GUID((*result)[0].GetUInt32(), 0, HIGHGUID_PLAYER); - - delete result; - } - - return guid; -} - -bool ObjectMgr::GetPlayerNameByGUID(const uint64 &guid, std::string &name) const -{ - // prevent DB access for online player - if(Player* player = GetPlayer(guid)) - { - name = player->GetName(); - return true; - } - - QueryResult *result = CharacterDatabase.PQuery("SELECT name FROM characters WHERE guid = '%u'", GUID_LOPART(guid)); - - if(result) - { - name = (*result)[0].GetCppString(); - delete result; - return true; - } - - return false; -} - -uint32 ObjectMgr::GetPlayerTeamByGUID(const uint64 &guid) const -{ - QueryResult *result = CharacterDatabase.PQuery("SELECT race FROM characters WHERE guid = '%u'", GUID_LOPART(guid)); - - if(result) - { - uint8 race = (*result)[0].GetUInt8(); - delete result; - return Player::TeamForRace(race); - } - - return 0; -} - -uint32 ObjectMgr::GetPlayerAccountIdByGUID(const uint64 &guid) const -{ - QueryResult *result = CharacterDatabase.PQuery("SELECT account FROM characters WHERE guid = '%u'", GUID_LOPART(guid)); - if(result) - { - uint32 acc = (*result)[0].GetUInt32(); - delete result; - return acc; - } - - return 0; -} - -uint32 ObjectMgr::GetSecurityByAccount(uint32 acc_id) const -{ - QueryResult *result = loginDatabase.PQuery("SELECT gmlevel FROM account WHERE id = '%u'", acc_id); - if(result) - { - uint32 sec = (*result)[0].GetUInt32(); - delete result; - return sec; - } - - return 0; -} - -bool ObjectMgr::GetAccountNameByAccount(uint32 acc_id, std::string &name) const -{ - QueryResult *result = loginDatabase.PQuery("SELECT username FROM account WHERE id = '%u'", acc_id); - if(result) - { - name = (*result)[0].GetCppString(); - delete result; - return true; - } - - return false; -} - -uint32 ObjectMgr::GetAccountByAccountName(std::string name) const -{ - loginDatabase.escape_string(name); - QueryResult *result = loginDatabase.PQuery("SELECT id FROM account WHERE username = '%s'", name.c_str()); - if(result) - { - uint32 id = (*result)[0].GetUInt32(); - delete result; - return id; - } - - return 0; -} - -void ObjectMgr::LoadAuctions() -{ - QueryResult *result = CharacterDatabase.Query("SELECT COUNT(*) FROM auctionhouse"); - if( !result ) - return; - - Field *fields = result->Fetch(); - uint32 AuctionCount=fields[0].GetUInt32(); - delete result; - - if(!AuctionCount) - return; - - result = CharacterDatabase.Query( "SELECT id,auctioneerguid,itemguid,item_template,itemowner,buyoutprice,time,buyguid,lastbid,startbid,deposit,location FROM auctionhouse" ); - if( !result ) - return; - - barGoLink bar( AuctionCount ); - - AuctionEntry *aItem; - - do - { - fields = result->Fetch(); - - bar.step(); - - aItem = new AuctionEntry; - aItem->Id = fields[0].GetUInt32(); - aItem->auctioneer = fields[1].GetUInt32(); - aItem->item_guidlow = fields[2].GetUInt32(); - aItem->item_template = fields[3].GetUInt32(); - aItem->owner = fields[4].GetUInt32(); - aItem->buyout = fields[5].GetUInt32(); - aItem->time = fields[6].GetUInt32(); - aItem->bidder = fields[7].GetUInt32(); - aItem->bid = fields[8].GetUInt32(); - aItem->startbid = fields[9].GetUInt32(); - aItem->deposit = fields[10].GetUInt32(); - aItem->location = fields[11].GetUInt8(); - //check if sold item exists - if ( this->GetAItem( aItem->item_guidlow ) ) - { - GetAuctionsMap( aItem->location )->AddAuction(aItem); - } - else - { - CharacterDatabase.PExecute("DELETE FROM auctionhouse WHERE id = '%u'",aItem->Id); - sLog.outError("Auction %u has not a existing item : %u", aItem->Id, aItem->item_guidlow); - delete aItem; - } - } while (result->NextRow()); - delete result; - - sLog.outString(); - sLog.outString( ">> Loaded %u auctions", AuctionCount ); - sLog.outString(); -} - -void ObjectMgr::LoadItemLocales() -{ - QueryResult *result = WorldDatabase.Query("SELECT entry,name_loc1,description_loc1,name_loc2,description_loc2,name_loc3,description_loc3,name_loc4,description_loc4,name_loc5,description_loc5,name_loc6,description_loc6,name_loc7,description_loc7,name_loc8,description_loc8 FROM locales_item"); - - if(!result) - { - barGoLink bar(1); - - bar.step(); - - sLog.outString(""); - sLog.outString(">> Loaded 0 Item locale strings. DB table `locales_item` is empty."); - return; - } - - barGoLink bar(result->GetRowCount()); - - do - { - Field *fields = result->Fetch(); - bar.step(); - - uint32 entry = fields[0].GetUInt32(); - - ItemLocale& data = mItemLocaleMap[entry]; - - for(int i = 1; i < MAX_LOCALE; ++i) - { - std::string str = fields[1+2*(i-1)].GetCppString(); - if(!str.empty()) - { - int idx = GetOrNewIndexForLocale(LocaleConstant(i)); - if(idx >= 0) - { - if(data.Name.size() <= idx) - data.Name.resize(idx+1); - - data.Name[idx] = str; - } - } - - str = fields[1+2*(i-1)+1].GetCppString(); - if(!str.empty()) - { - int idx = GetOrNewIndexForLocale(LocaleConstant(i)); - if(idx >= 0) - { - if(data.Description.size() <= idx) - data.Description.resize(idx+1); - - data.Description[idx] = str; - } - } - } - } while (result->NextRow()); - - delete result; - - sLog.outString(); - sLog.outString( ">> Loaded %u Item locale strings", mItemLocaleMap.size() ); -} - -void ObjectMgr::LoadItemPrototypes() -{ - sItemStorage.Load (); - sLog.outString( ">> Loaded %u item prototypes", sItemStorage.RecordCount ); - sLog.outString(); - - // check data correctness - for(uint32 i = 1; i < sItemStorage.MaxEntry; ++i) - { - ItemPrototype const* proto = sItemStorage.LookupEntry(i); - ItemEntry const *dbcitem = sItemStore.LookupEntry(i); - if(!proto) - { - /* to many errors, and possible not all items really used in game - if (dbcitem) - sLog.outErrorDb("Item (Entry: %u) doesn't exists in DB, but must exist.",i); - */ - continue; - } - - if(dbcitem) - { - if(proto->InventoryType != dbcitem->InventoryType) - { - sLog.outErrorDb("Item (Entry: %u) not correct %u inventory type, must be %u (still using DB value).",i,proto->InventoryType,dbcitem->InventoryType); - // It safe let use InventoryType from DB - } - - if(proto->DisplayInfoID != dbcitem->DisplayId) - { - sLog.outErrorDb("Item (Entry: %u) not correct %u display id, must be %u (using it).",i,proto->DisplayInfoID,dbcitem->DisplayId); - const_cast(proto)->DisplayInfoID = dbcitem->DisplayId; - } - if(proto->Sheath != dbcitem->Sheath) - { - sLog.outErrorDb("Item (Entry: %u) not correct %u sheath, must be %u (using it).",i,proto->Sheath,dbcitem->Sheath); - const_cast(proto)->Sheath = dbcitem->Sheath; - } - } - else - { - sLog.outErrorDb("Item (Entry: %u) not correct (not listed in list of existed items).",i); - } - - if(proto->Class >= MAX_ITEM_CLASS) - { - sLog.outErrorDb("Item (Entry: %u) has wrong Class value (%u)",i,proto->Class); - const_cast(proto)->Class = ITEM_CLASS_JUNK; - } - - if(proto->SubClass >= MaxItemSubclassValues[proto->Class]) - { - sLog.outErrorDb("Item (Entry: %u) has wrong Subclass value (%u) for class %u",i,proto->SubClass,proto->Class); - const_cast(proto)->SubClass = 0;// exist for all item classes - } - - if(proto->Quality >= MAX_ITEM_QUALITY) - { - sLog.outErrorDb("Item (Entry: %u) has wrong Quality value (%u)",i,proto->Quality); - const_cast(proto)->Quality = ITEM_QUALITY_NORMAL; - } - - if(proto->BuyCount <= 0) - { - sLog.outErrorDb("Item (Entry: %u) has wrong BuyCount value (%u), set to default(1).",i,proto->BuyCount); - const_cast(proto)->BuyCount = 1; - } - - if(proto->InventoryType >= MAX_INVTYPE) - { - sLog.outErrorDb("Item (Entry: %u) has wrong InventoryType value (%u)",i,proto->InventoryType); - const_cast(proto)->InventoryType = INVTYPE_NON_EQUIP; - } - - if(proto->RequiredSkill >= MAX_SKILL_TYPE) - { - sLog.outErrorDb("Item (Entry: %u) has wrong RequiredSkill value (%u)",i,proto->RequiredSkill); - const_cast(proto)->RequiredSkill = 0; - } - - if(!(proto->AllowableClass & CLASSMASK_ALL_PLAYABLE)) - { - sLog.outErrorDb("Item (Entry: %u) not have in `AllowableClass` any playable classes (%u) and can't be equipped.",i,proto->AllowableClass); - } - - if(!(proto->AllowableRace & RACEMASK_ALL_PLAYABLE)) - { - sLog.outErrorDb("Item (Entry: %u) not have in `AllowableRace` any playable races (%u) and can't be equipped.",i,proto->AllowableRace); - } - - if(proto->RequiredSpell && !sSpellStore.LookupEntry(proto->RequiredSpell)) - { - sLog.outErrorDb("Item (Entry: %u) have wrong (non-existed) spell in RequiredSpell (%u)",i,proto->RequiredSpell); - const_cast(proto)->RequiredSpell = 0; - } - - if(proto->RequiredReputationRank >= MAX_REPUTATION_RANK) - sLog.outErrorDb("Item (Entry: %u) has wrong reputation rank in RequiredReputationRank (%u), item can't be used.",i,proto->RequiredReputationRank); - - if(proto->RequiredReputationFaction) - { - if(!sFactionStore.LookupEntry(proto->RequiredReputationFaction)) - { - sLog.outErrorDb("Item (Entry: %u) has wrong (not existing) faction in RequiredReputationFaction (%u)",i,proto->RequiredReputationFaction); - const_cast(proto)->RequiredReputationFaction = 0; - } - - if(proto->RequiredReputationRank == MIN_REPUTATION_RANK) - sLog.outErrorDb("Item (Entry: %u) has min. reputation rank in RequiredReputationRank (0) but RequiredReputationFaction > 0, faction setting is useless.",i); - } - else if(proto->RequiredReputationRank > MIN_REPUTATION_RANK) - sLog.outErrorDb("Item (Entry: %u) has RequiredReputationFaction ==0 but RequiredReputationRank > 0, rank setting is useless.",i); - - if(proto->Stackable==0) - { - sLog.outErrorDb("Item (Entry: %u) has wrong value in stackable (%u), replace by default 1.",i,proto->Stackable); - const_cast(proto)->Stackable = 1; - } - else if(proto->Stackable > 255) - { - sLog.outErrorDb("Item (Entry: %u) has too large value in stackable (%u), replace by hardcoded upper limit (255).",i,proto->Stackable); - const_cast(proto)->Stackable = 255; - } - - for (int j = 0; j < 10; j++) - { - // for ItemStatValue != 0 - if(proto->ItemStat[j].ItemStatValue && proto->ItemStat[j].ItemStatType >= MAX_ITEM_MOD) - { - sLog.outErrorDb("Item (Entry: %u) has wrong stat_type%d (%u)",i,j+1,proto->ItemStat[j].ItemStatType); - const_cast(proto)->ItemStat[j].ItemStatType = 0; - } - } - - for (int j = 0; j < 5; j++) - { - if(proto->Damage[j].DamageType >= MAX_SPELL_SCHOOL) - { - sLog.outErrorDb("Item (Entry: %u) has wrong dmg_type%d (%u)",i,j+1,proto->Damage[j].DamageType); - const_cast(proto)->Damage[j].DamageType = 0; - } - } - - // special format - if(proto->Spells[0].SpellId == SPELL_ID_GENERIC_LEARN) - { - // spell_1 - if(proto->Spells[0].SpellTrigger != ITEM_SPELLTRIGGER_ON_USE) - { - sLog.outErrorDb("Item (Entry: %u) has wrong item spell trigger value in spelltrigger_%d (%u) for special learning format",i,0+1,proto->Spells[0].SpellTrigger); - const_cast(proto)->Spells[0].SpellId = 0; - const_cast(proto)->Spells[0].SpellTrigger = ITEM_SPELLTRIGGER_ON_USE; - const_cast(proto)->Spells[1].SpellId = 0; - const_cast(proto)->Spells[1].SpellTrigger = ITEM_SPELLTRIGGER_ON_USE; - } - - // spell_2 have learning spell - if(proto->Spells[1].SpellTrigger != ITEM_SPELLTRIGGER_LEARN_SPELL_ID) - { - sLog.outErrorDb("Item (Entry: %u) has wrong item spell trigger value in spelltrigger_%d (%u) for special learning format.",i,1+1,proto->Spells[1].SpellTrigger); - const_cast(proto)->Spells[0].SpellId = 0; - const_cast(proto)->Spells[1].SpellId = 0; - const_cast(proto)->Spells[1].SpellTrigger = ITEM_SPELLTRIGGER_ON_USE; - } - else if(!proto->Spells[1].SpellId) - { - sLog.outErrorDb("Item (Entry: %u) not has expected spell in spellid_%d in special learning format.",i,1+1); - const_cast(proto)->Spells[0].SpellId = 0; - const_cast(proto)->Spells[1].SpellTrigger = ITEM_SPELLTRIGGER_ON_USE; - } - else - { - SpellEntry const* spellInfo = sSpellStore.LookupEntry(proto->Spells[1].SpellId); - if(!spellInfo) - { - sLog.outErrorDb("Item (Entry: %u) has wrong (not existing) spell in spellid_%d (%u)",i,1+1,proto->Spells[1].SpellId); - const_cast(proto)->Spells[0].SpellId = 0; - const_cast(proto)->Spells[1].SpellId = 0; - const_cast(proto)->Spells[1].SpellTrigger = ITEM_SPELLTRIGGER_ON_USE; - } - // allowed only in special format - else if(proto->Spells[1].SpellId==SPELL_ID_GENERIC_LEARN) - { - sLog.outErrorDb("Item (Entry: %u) has broken spell in spellid_%d (%u)",i,1+1,proto->Spells[1].SpellId); - const_cast(proto)->Spells[0].SpellId = 0; - const_cast(proto)->Spells[1].SpellId = 0; - const_cast(proto)->Spells[1].SpellTrigger = ITEM_SPELLTRIGGER_ON_USE; - } - } - - // spell_3*,spell_4*,spell_5* is empty - for (int j = 2; j < 5; j++) - { - if(proto->Spells[j].SpellTrigger != ITEM_SPELLTRIGGER_ON_USE) - { - sLog.outErrorDb("Item (Entry: %u) has wrong item spell trigger value in spelltrigger_%d (%u)",i,j+1,proto->Spells[j].SpellTrigger); - const_cast(proto)->Spells[j].SpellId = 0; - const_cast(proto)->Spells[j].SpellTrigger = ITEM_SPELLTRIGGER_ON_USE; - } - else if(proto->Spells[j].SpellId != 0) - { - sLog.outErrorDb("Item (Entry: %u) has wrong spell in spellid_%d (%u) for learning special format",i,j+1,proto->Spells[j].SpellId); - const_cast(proto)->Spells[j].SpellId = 0; - } - } - } - // normal spell list - else - { - for (int j = 0; j < 5; j++) - { - if(proto->Spells[j].SpellTrigger >= MAX_ITEM_SPELLTRIGGER || proto->Spells[j].SpellTrigger == ITEM_SPELLTRIGGER_LEARN_SPELL_ID) - { - sLog.outErrorDb("Item (Entry: %u) has wrong item spell trigger value in spelltrigger_%d (%u)",i,j+1,proto->Spells[j].SpellTrigger); - const_cast(proto)->Spells[j].SpellId = 0; - const_cast(proto)->Spells[j].SpellTrigger = ITEM_SPELLTRIGGER_ON_USE; - } - - if(proto->Spells[j].SpellId) - { - SpellEntry const* spellInfo = sSpellStore.LookupEntry(proto->Spells[j].SpellId); - if(!spellInfo) - { - sLog.outErrorDb("Item (Entry: %u) has wrong (not existing) spell in spellid_%d (%u)",i,j+1,proto->Spells[j].SpellId); - const_cast(proto)->Spells[j].SpellId = 0; - } - // allowed only in special format - else if(proto->Spells[j].SpellId==SPELL_ID_GENERIC_LEARN) - { - sLog.outErrorDb("Item (Entry: %u) has broken spell in spellid_%d (%u)",i,j+1,proto->Spells[j].SpellId); - const_cast(proto)->Spells[j].SpellId = 0; - } - } - } - } - - if(proto->Bonding >= MAX_BIND_TYPE) - sLog.outErrorDb("Item (Entry: %u) has wrong Bonding value (%u)",i,proto->Bonding); - - if(proto->PageText && !sPageTextStore.LookupEntry(proto->PageText)) - sLog.outErrorDb("Item (Entry: %u) has non existing first page (Id:%u)", i,proto->PageText); - - if(proto->LockID && !sLockStore.LookupEntry(proto->LockID)) - sLog.outErrorDb("Item (Entry: %u) has wrong LockID (%u)",i,proto->LockID); - - if(proto->Sheath >= MAX_SHEATHETYPE) - { - sLog.outErrorDb("Item (Entry: %u) has wrong Sheath (%u)",i,proto->Sheath); - const_cast(proto)->Sheath = SHEATHETYPE_NONE; - } - - if(proto->RandomProperty && !sItemRandomPropertiesStore.LookupEntry(GetItemEnchantMod(proto->RandomProperty))) - { - sLog.outErrorDb("Item (Entry: %u) has unknown (wrong or not listed in `item_enchantment_template`) RandomProperty (%u)",i,proto->RandomProperty); - const_cast(proto)->RandomProperty = 0; - } - - if(proto->RandomSuffix && !sItemRandomSuffixStore.LookupEntry(GetItemEnchantMod(proto->RandomSuffix))) - { - sLog.outErrorDb("Item (Entry: %u) has wrong RandomSuffix (%u)",i,proto->RandomSuffix); - const_cast(proto)->RandomSuffix = 0; - } - - if(proto->ItemSet && !sItemSetStore.LookupEntry(proto->ItemSet)) - { - sLog.outErrorDb("Item (Entry: %u) have wrong ItemSet (%u)",i,proto->ItemSet); - const_cast(proto)->ItemSet = 0; - } - - if(proto->Area && !GetAreaEntryByAreaID(proto->Area)) - sLog.outErrorDb("Item (Entry: %u) has wrong Area (%u)",i,proto->Area); - - if(proto->Map && !sMapStore.LookupEntry(proto->Map)) - sLog.outErrorDb("Item (Entry: %u) has wrong Map (%u)",i,proto->Map); - - if(proto->TotemCategory && !sTotemCategoryStore.LookupEntry(proto->TotemCategory)) - sLog.outErrorDb("Item (Entry: %u) has wrong TotemCategory (%u)",i,proto->TotemCategory); - - for (int j = 0; j < 3; j++) - { - if(proto->Socket[j].Color && (proto->Socket[j].Color & SOCKET_COLOR_ALL) != proto->Socket[j].Color) - { - sLog.outErrorDb("Item (Entry: %u) has wrong socketColor_%d (%u)",i,j+1,proto->Socket[j].Color); - const_cast(proto)->Socket[j].Color = 0; - } - } - - if(proto->GemProperties && !sGemPropertiesStore.LookupEntry(proto->GemProperties)) - sLog.outErrorDb("Item (Entry: %u) has wrong GemProperties (%u)",i,proto->GemProperties); - - if(proto->FoodType >= MAX_PET_DIET) - { - sLog.outErrorDb("Item (Entry: %u) has wrong FoodType value (%u)",i,proto->FoodType); - const_cast(proto)->FoodType = 0; - } - } - - // this DBC used currently only for check item templates in DB. - sItemStore.Clear(); -} - -void ObjectMgr::LoadAuctionItems() -{ - QueryResult *result = CharacterDatabase.Query( "SELECT itemguid,item_template FROM auctionhouse" ); - - if( !result ) - return; - - barGoLink bar( result->GetRowCount() ); - - uint32 count = 0; - - Field *fields; - do - { - bar.step(); - - fields = result->Fetch(); - uint32 item_guid = fields[0].GetUInt32(); - uint32 item_template = fields[1].GetUInt32(); - - ItemPrototype const *proto = objmgr.GetItemPrototype(item_template); - - if(!proto) - { - sLog.outError( "ObjectMgr::LoadAuctionItems: Unknown item (GUID: %u id: #%u) in auction, skipped.", item_guid,item_template); - continue; - } - - Item *item = NewItemOrBag(proto); - - if(!item->LoadFromDB(item_guid,0)) - { - delete item; - continue; - } - AddAItem(item); - - ++count; - } - while( result->NextRow() ); - - delete result; - - sLog.outString(); - sLog.outString( ">> Loaded %u auction items", count ); -} - -void ObjectMgr::LoadPetLevelInfo() -{ - // Loading levels data - { - // 0 1 2 3 4 5 6 7 8 9 - QueryResult *result = WorldDatabase.Query("SELECT creature_entry, level, hp, mana, str, agi, sta, inte, spi, armor FROM pet_levelstats"); - - uint32 count = 0; - - if (!result) - { - barGoLink bar( 1 ); - - sLog.outString(); - sLog.outString( ">> Loaded %u level pet stats definitions", count ); - sLog.outErrorDb( "Error loading `pet_levelstats` table or empty table."); - return; - } - - barGoLink bar( result->GetRowCount() ); - - do - { - Field* fields = result->Fetch(); - - uint32 creature_id = fields[0].GetUInt32(); - if(!sCreatureStorage.LookupEntry(creature_id)) - { - sLog.outErrorDb("Wrong creature id %u in `pet_levelstats` table, ignoring.",creature_id); - continue; - } - - uint32 current_level = fields[1].GetUInt32(); - if(current_level > sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL)) - { - if(current_level > 255) // hardcoded level maximum - sLog.outErrorDb("Wrong (> 255) level %u in `pet_levelstats` table, ignoring.",current_level); - else - sLog.outDetail("Unused (> MaxPlayerLevel in mangosd.conf) level %u in `pet_levelstats` table, ignoring.",current_level); - continue; - } - else if(current_level < 1) - { - sLog.outErrorDb("Wrong (<1) level %u in `pet_levelstats` table, ignoring.",current_level); - continue; - } - - PetLevelInfo*& pInfoMapEntry = petInfo[creature_id]; - - if(pInfoMapEntry==NULL) - pInfoMapEntry = new PetLevelInfo[sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL)]; - - // data for level 1 stored in [0] array element, ... - PetLevelInfo* pLevelInfo = &pInfoMapEntry[current_level-1]; - - pLevelInfo->health = fields[2].GetUInt16(); - pLevelInfo->mana = fields[3].GetUInt16(); - pLevelInfo->armor = fields[9].GetUInt16(); - - for (int i = 0; i < MAX_STATS; i++) - { - pLevelInfo->stats[i] = fields[i+4].GetUInt16(); - } - - bar.step(); - ++count; - } - while (result->NextRow()); - - delete result; - - sLog.outString(); - sLog.outString( ">> Loaded %u level pet stats definitions", count ); - } - - // Fill gaps and check integrity - for (PetLevelInfoMap::iterator itr = petInfo.begin(); itr != petInfo.end(); ++itr) - { - PetLevelInfo* pInfo = itr->second; - - // fatal error if no level 1 data - if(!pInfo || pInfo[0].health == 0 ) - { - sLog.outErrorDb("Creature %u does not have pet stats data for Level 1!",itr->first); - exit(1); - } - - // fill level gaps - for (uint32 level = 1; level < sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL); ++level) - { - if(pInfo[level].health == 0) - { - sLog.outErrorDb("Creature %u has no data for Level %i pet stats data, using data of Level %i.",itr->first,level+1, level); - pInfo[level] = pInfo[level-1]; - } - } - } -} - -PetLevelInfo const* ObjectMgr::GetPetLevelInfo(uint32 creature_id, uint32 level) const -{ - if(level > sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL)) - level = sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL); - - PetLevelInfoMap::const_iterator itr = petInfo.find(creature_id); - if(itr == petInfo.end()) - return NULL; - - return &itr->second[level-1]; // data for level 1 stored in [0] array element, ... -} - -void ObjectMgr::LoadPlayerInfo() -{ - // Load playercreate - { - // 0 1 2 3 4 5 6 - QueryResult *result = WorldDatabase.Query("SELECT race, class, map, zone, position_x, position_y, position_z FROM playercreateinfo"); - - uint32 count = 0; - - if (!result) - { - barGoLink bar( 1 ); - - sLog.outString(); - sLog.outString( ">> Loaded %u player create definitions", count ); - sLog.outErrorDb( "Error loading `playercreateinfo` table or empty table."); - exit(1); - } - - barGoLink bar( result->GetRowCount() ); - - do - { - Field* fields = result->Fetch(); - - uint32 current_race = fields[0].GetUInt32(); - uint32 current_class = fields[1].GetUInt32(); - uint32 mapId = fields[2].GetUInt32(); - uint32 zoneId = fields[3].GetUInt32(); - float positionX = fields[4].GetFloat(); - float positionY = fields[5].GetFloat(); - float positionZ = fields[6].GetFloat(); - - if(current_race >= MAX_RACES) - { - sLog.outErrorDb("Wrong race %u in `playercreateinfo` table, ignoring.",current_race); - continue; - } - - ChrRacesEntry const* rEntry = sChrRacesStore.LookupEntry(current_race); - if(!rEntry) - { - sLog.outErrorDb("Wrong race %u in `playercreateinfo` table, ignoring.",current_race); - continue; - } - - if(current_class >= MAX_CLASSES) - { - sLog.outErrorDb("Wrong class %u in `playercreateinfo` table, ignoring.",current_class); - continue; - } - - if(!sChrClassesStore.LookupEntry(current_class)) - { - sLog.outErrorDb("Wrong class %u in `playercreateinfo` table, ignoring.",current_class); - continue; - } - - // accept DB data only for valid position (and non instanceable) - if( !MapManager::IsValidMapCoord(mapId,positionX,positionY,positionZ) ) - { - sLog.outErrorDb("Wrong home position for class %u race %u pair in `playercreateinfo` table, ignoring.",current_class,current_race); - continue; - } - - if( sMapStore.LookupEntry(mapId)->Instanceable() ) - { - sLog.outErrorDb("Home position in instanceable map for class %u race %u pair in `playercreateinfo` table, ignoring.",current_class,current_race); - continue; - } - - PlayerInfo* pInfo = &playerInfo[current_race][current_class]; - - pInfo->mapId = mapId; - pInfo->zoneId = zoneId; - pInfo->positionX = positionX; - pInfo->positionY = positionY; - pInfo->positionZ = positionZ; - - pInfo->displayId_m = rEntry->model_m; - pInfo->displayId_f = rEntry->model_f; - - bar.step(); - ++count; - } - while (result->NextRow()); - - delete result; - - sLog.outString(); - sLog.outString( ">> Loaded %u player create definitions", count ); - } - - // Load playercreate items - { - // 0 1 2 3 - QueryResult *result = WorldDatabase.Query("SELECT race, class, itemid, amount FROM playercreateinfo_item"); - - uint32 count = 0; - - if (!result) - { - barGoLink bar( 1 ); - - sLog.outString(); - sLog.outString( ">> Loaded %u player create items", count ); - sLog.outErrorDb( "Error loading `playercreateinfo_item` table or empty table."); - } - else - { - barGoLink bar( result->GetRowCount() ); - - do - { - Field* fields = result->Fetch(); - - uint32 current_race = fields[0].GetUInt32(); - if(current_race >= MAX_RACES) - { - sLog.outErrorDb("Wrong race %u in `playercreateinfo_item` table, ignoring.",current_race); - continue; - } - - uint32 current_class = fields[1].GetUInt32(); - if(current_class >= MAX_CLASSES) - { - sLog.outErrorDb("Wrong class %u in `playercreateinfo_item` table, ignoring.",current_class); - continue; - } - - PlayerInfo* pInfo = &playerInfo[current_race][current_class]; - - uint32 item_id = fields[2].GetUInt32(); - - if(!GetItemPrototype(item_id)) - { - sLog.outErrorDb("Item id %u (race %u class %u) in `playercreateinfo_item` table but not listed in `item_template`, ignoring.",item_id,current_race,current_class); - continue; - } - - uint32 amount = fields[3].GetUInt32(); - - if(!amount) - { - sLog.outErrorDb("Item id %u (class %u race %u) have amount==0 in `playercreateinfo_item` table, ignoring.",item_id,current_race,current_class); - continue; - } - - pInfo->item.push_back(PlayerCreateInfoItem( item_id, amount)); - - bar.step(); - ++count; - } - while(result->NextRow()); - - delete result; - - sLog.outString(); - sLog.outString( ">> Loaded %u player create items", count ); - } - } - - // Load playercreate spells - { - // 0 1 2 3 - QueryResult *result = WorldDatabase.Query("SELECT race, class, Spell, Active FROM playercreateinfo_spell"); - - uint32 count = 0; - - if (!result) - { - barGoLink bar( 1 ); - - sLog.outString(); - sLog.outString( ">> Loaded %u player create spells", count ); - sLog.outErrorDb( "Error loading `playercreateinfo_spell` table or empty table."); - } - else - { - barGoLink bar( result->GetRowCount() ); - - do - { - Field* fields = result->Fetch(); - - uint32 current_race = fields[0].GetUInt32(); - if(current_race >= MAX_RACES) - { - sLog.outErrorDb("Wrong race %u in `playercreateinfo_spell` table, ignoring.",current_race); - continue; - } - - uint32 current_class = fields[1].GetUInt32(); - if(current_class >= MAX_CLASSES) - { - sLog.outErrorDb("Wrong class %u in `playercreateinfo_spell` table, ignoring.",current_class); - continue; - } - - PlayerInfo* pInfo = &playerInfo[current_race][current_class]; - pInfo->spell.push_back(CreateSpellPair(fields[2].GetUInt16(), fields[3].GetUInt8())); - - bar.step(); - ++count; - } - while( result->NextRow() ); - - delete result; - - sLog.outString(); - sLog.outString( ">> Loaded %u player create spells", count ); - } - } - - // Load playercreate actions - { - // 0 1 2 3 4 5 - QueryResult *result = WorldDatabase.Query("SELECT race, class, button, action, type, misc FROM playercreateinfo_action"); - - uint32 count = 0; - - if (!result) - { - barGoLink bar( 1 ); - - sLog.outString(); - sLog.outString( ">> Loaded %u player create actions", count ); - sLog.outErrorDb( "Error loading `playercreateinfo_action` table or empty table."); - } - else - { - barGoLink bar( result->GetRowCount() ); - - do - { - Field* fields = result->Fetch(); - - uint32 current_race = fields[0].GetUInt32(); - if(current_race >= MAX_RACES) - { - sLog.outErrorDb("Wrong race %u in `playercreateinfo_action` table, ignoring.",current_race); - continue; - } - - uint32 current_class = fields[1].GetUInt32(); - if(current_class >= MAX_CLASSES) - { - sLog.outErrorDb("Wrong class %u in `playercreateinfo_action` table, ignoring.",current_class); - continue; - } - - PlayerInfo* pInfo = &playerInfo[current_race][current_class]; - pInfo->action[0].push_back(fields[2].GetUInt16()); - pInfo->action[1].push_back(fields[3].GetUInt16()); - pInfo->action[2].push_back(fields[4].GetUInt16()); - pInfo->action[3].push_back(fields[5].GetUInt16()); - - bar.step(); - ++count; - } - while( result->NextRow() ); - - delete result; - - sLog.outString(); - sLog.outString( ">> Loaded %u player create actions", count ); - } - } - - // Loading levels data (class only dependent) - { - // 0 1 2 3 - QueryResult *result = WorldDatabase.Query("SELECT class, level, basehp, basemana FROM player_classlevelstats"); - - uint32 count = 0; - - if (!result) - { - barGoLink bar( 1 ); - - sLog.outString(); - sLog.outString( ">> Loaded %u level health/mana definitions", count ); - sLog.outErrorDb( "Error loading `player_classlevelstats` table or empty table."); - exit(1); - } - - barGoLink bar( result->GetRowCount() ); - - do - { - Field* fields = result->Fetch(); - - uint32 current_class = fields[0].GetUInt32(); - if(current_class >= MAX_CLASSES) - { - sLog.outErrorDb("Wrong class %u in `player_classlevelstats` table, ignoring.",current_class); - continue; - } - - uint32 current_level = fields[1].GetUInt32(); - if(current_level > sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL)) - { - if(current_level > 255) // hardcoded level maximum - sLog.outErrorDb("Wrong (> 255) level %u in `player_classlevelstats` table, ignoring.",current_level); - else - sLog.outDetail("Unused (> MaxPlayerLevel in mangosd.conf) level %u in `player_classlevelstats` table, ignoring.",current_level); - continue; - } - - PlayerClassInfo* pClassInfo = &playerClassInfo[current_class]; - - if(!pClassInfo->levelInfo) - pClassInfo->levelInfo = new PlayerClassLevelInfo[sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL)]; - - PlayerClassLevelInfo* pClassLevelInfo = &pClassInfo->levelInfo[current_level-1]; - - pClassLevelInfo->basehealth = fields[2].GetUInt16(); - pClassLevelInfo->basemana = fields[3].GetUInt16(); - - bar.step(); - ++count; - } - while (result->NextRow()); - - delete result; - - sLog.outString(); - sLog.outString( ">> Loaded %u level health/mana definitions", count ); - } - - // Fill gaps and check integrity - for (int class_ = 0; class_ < MAX_CLASSES; ++class_) - { - // skip non existed classes - if(!sChrClassesStore.LookupEntry(class_)) - continue; - - PlayerClassInfo* pClassInfo = &playerClassInfo[class_]; - - // fatal error if no level 1 data - if(!pClassInfo->levelInfo || pClassInfo->levelInfo[0].basehealth == 0 ) - { - sLog.outErrorDb("Class %i Level 1 does not have health/mana data!",class_); - exit(1); - } - - // fill level gaps - for (uint32 level = 1; level < sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL); ++level) - { - if(pClassInfo->levelInfo[level].basehealth == 0) - { - sLog.outErrorDb("Class %i Level %i does not have health/mana data. Using stats data of level %i.",class_,level+1, level); - pClassInfo->levelInfo[level] = pClassInfo->levelInfo[level-1]; - } - } - } - - // Loading levels data (class/race dependent) - { - // 0 1 2 3 4 5 6 7 - QueryResult *result = WorldDatabase.Query("SELECT race, class, level, str, agi, sta, inte, spi FROM player_levelstats"); - - uint32 count = 0; - - if (!result) - { - barGoLink bar( 1 ); - - sLog.outString(); - sLog.outString( ">> Loaded %u level stats definitions", count ); - sLog.outErrorDb( "Error loading `player_levelstats` table or empty table."); - exit(1); - } - - barGoLink bar( result->GetRowCount() ); - - do - { - Field* fields = result->Fetch(); - - uint32 current_race = fields[0].GetUInt32(); - if(current_race >= MAX_RACES) - { - sLog.outErrorDb("Wrong race %u in `player_levelstats` table, ignoring.",current_race); - continue; - } - - uint32 current_class = fields[1].GetUInt32(); - if(current_class >= MAX_CLASSES) - { - sLog.outErrorDb("Wrong class %u in `player_levelstats` table, ignoring.",current_class); - continue; - } - - uint32 current_level = fields[2].GetUInt32(); - if(current_level > sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL)) - { - if(current_level > 255) // hardcoded level maximum - sLog.outErrorDb("Wrong (> 255) level %u in `player_levelstats` table, ignoring.",current_level); - else - sLog.outDetail("Unused (> MaxPlayerLevel in mangosd.conf) level %u in `player_levelstats` table, ignoring.",current_level); - continue; - } - - PlayerInfo* pInfo = &playerInfo[current_race][current_class]; - - if(!pInfo->levelInfo) - pInfo->levelInfo = new PlayerLevelInfo[sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL)]; - - PlayerLevelInfo* pLevelInfo = &pInfo->levelInfo[current_level-1]; - - for (int i = 0; i < MAX_STATS; i++) - { - pLevelInfo->stats[i] = fields[i+3].GetUInt8(); - } - - bar.step(); - ++count; - } - while (result->NextRow()); - - delete result; - - sLog.outString(); - sLog.outString( ">> Loaded %u level stats definitions", count ); - } - - // Fill gaps and check integrity - for (int race = 0; race < MAX_RACES; ++race) - { - // skip non existed races - if(!sChrRacesStore.LookupEntry(race)) - continue; - - for (int class_ = 0; class_ < MAX_CLASSES; ++class_) - { - // skip non existed classes - if(!sChrClassesStore.LookupEntry(class_)) - continue; - - PlayerInfo* pInfo = &playerInfo[race][class_]; - - // skip non loaded combinations - if(!pInfo->displayId_m || !pInfo->displayId_f) - continue; - - // skip expansion races if not playing with expansion - if (sWorld.getConfig(CONFIG_EXPANSION) < 1 && (race == RACE_BLOODELF || race == RACE_DRAENEI)) - continue; - - // fatal error if no level 1 data - if(!pInfo->levelInfo || pInfo->levelInfo[0].stats[0] == 0 ) - { - sLog.outErrorDb("Race %i Class %i Level 1 does not have stats data!",race,class_); - exit(1); - } - - // fill level gaps - for (uint32 level = 1; level < sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL); ++level) - { - if(pInfo->levelInfo[level].stats[0] == 0) - { - sLog.outErrorDb("Race %i Class %i Level %i does not have stats data. Using stats data of level %i.",race,class_,level+1, level); - pInfo->levelInfo[level] = pInfo->levelInfo[level-1]; - } - } - } - } -} - -void ObjectMgr::GetPlayerClassLevelInfo(uint32 class_, uint32 level, PlayerClassLevelInfo* info) const -{ - if(level < 1 || class_ >= MAX_CLASSES) - return; - - PlayerClassInfo const* pInfo = &playerClassInfo[class_]; - - if(level > sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL)) - level = sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL); - - *info = pInfo->levelInfo[level-1]; -} - -void ObjectMgr::GetPlayerLevelInfo(uint32 race, uint32 class_, uint32 level, PlayerLevelInfo* info) const -{ - if(level < 1 || race >= MAX_RACES || class_ >= MAX_CLASSES) - return; - - PlayerInfo const* pInfo = &playerInfo[race][class_]; - if(pInfo->displayId_m==0 || pInfo->displayId_f==0) - return; - - if(level <= sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL)) - *info = pInfo->levelInfo[level-1]; - else - BuildPlayerLevelInfo(race,class_,level,info); -} - -void ObjectMgr::BuildPlayerLevelInfo(uint8 race, uint8 _class, uint8 level, PlayerLevelInfo* info) const -{ - // base data (last known level) - *info = playerInfo[race][_class].levelInfo[sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL)-1]; - - for(int lvl = sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL)-1; lvl < level; ++lvl) - { - switch(_class) - { - case CLASS_WARRIOR: - info->stats[STAT_STRENGTH] += (lvl > 23 ? 2: (lvl > 1 ? 1: 0)); - info->stats[STAT_STAMINA] += (lvl > 23 ? 2: (lvl > 1 ? 1: 0)); - info->stats[STAT_AGILITY] += (lvl > 36 ? 1: (lvl > 6 && (lvl%2) ? 1: 0)); - info->stats[STAT_INTELLECT] += (lvl > 9 && !(lvl%2) ? 1: 0); - info->stats[STAT_SPIRIT] += (lvl > 9 && !(lvl%2) ? 1: 0); - break; - case CLASS_PALADIN: - info->stats[STAT_STRENGTH] += (lvl > 3 ? 1: 0); - info->stats[STAT_STAMINA] += (lvl > 33 ? 2: (lvl > 1 ? 1: 0)); - info->stats[STAT_AGILITY] += (lvl > 38 ? 1: (lvl > 7 && !(lvl%2) ? 1: 0)); - info->stats[STAT_INTELLECT] += (lvl > 6 && (lvl%2) ? 1: 0); - info->stats[STAT_SPIRIT] += (lvl > 7 ? 1: 0); - break; - case CLASS_HUNTER: - info->stats[STAT_STRENGTH] += (lvl > 4 ? 1: 0); - info->stats[STAT_STAMINA] += (lvl > 4 ? 1: 0); - info->stats[STAT_AGILITY] += (lvl > 33 ? 2: (lvl > 1 ? 1: 0)); - info->stats[STAT_INTELLECT] += (lvl > 8 && (lvl%2) ? 1: 0); - info->stats[STAT_SPIRIT] += (lvl > 38 ? 1: (lvl > 9 && !(lvl%2) ? 1: 0)); - break; - case CLASS_ROGUE: - info->stats[STAT_STRENGTH] += (lvl > 5 ? 1: 0); - info->stats[STAT_STAMINA] += (lvl > 4 ? 1: 0); - info->stats[STAT_AGILITY] += (lvl > 16 ? 2: (lvl > 1 ? 1: 0)); - info->stats[STAT_INTELLECT] += (lvl > 8 && !(lvl%2) ? 1: 0); - info->stats[STAT_SPIRIT] += (lvl > 38 ? 1: (lvl > 9 && !(lvl%2) ? 1: 0)); - break; - case CLASS_PRIEST: - info->stats[STAT_STRENGTH] += (lvl > 9 && !(lvl%2) ? 1: 0); - info->stats[STAT_STAMINA] += (lvl > 5 ? 1: 0); - info->stats[STAT_AGILITY] += (lvl > 38 ? 1: (lvl > 8 && (lvl%2) ? 1: 0)); - info->stats[STAT_INTELLECT] += (lvl > 22 ? 2: (lvl > 1 ? 1: 0)); - info->stats[STAT_SPIRIT] += (lvl > 3 ? 1: 0); - break; - case CLASS_SHAMAN: - info->stats[STAT_STRENGTH] += (lvl > 34 ? 1: (lvl > 6 && (lvl%2) ? 1: 0)); - info->stats[STAT_STAMINA] += (lvl > 4 ? 1: 0); - info->stats[STAT_AGILITY] += (lvl > 7 && !(lvl%2) ? 1: 0); - info->stats[STAT_INTELLECT] += (lvl > 5 ? 1: 0); - info->stats[STAT_SPIRIT] += (lvl > 4 ? 1: 0); - break; - case CLASS_MAGE: - info->stats[STAT_STRENGTH] += (lvl > 9 && !(lvl%2) ? 1: 0); - info->stats[STAT_STAMINA] += (lvl > 5 ? 1: 0); - info->stats[STAT_AGILITY] += (lvl > 9 && !(lvl%2) ? 1: 0); - info->stats[STAT_INTELLECT] += (lvl > 24 ? 2: (lvl > 1 ? 1: 0)); - info->stats[STAT_SPIRIT] += (lvl > 33 ? 2: (lvl > 2 ? 1: 0)); - break; - case CLASS_WARLOCK: - info->stats[STAT_STRENGTH] += (lvl > 9 && !(lvl%2) ? 1: 0); - info->stats[STAT_STAMINA] += (lvl > 38 ? 2: (lvl > 3 ? 1: 0)); - info->stats[STAT_AGILITY] += (lvl > 9 && !(lvl%2) ? 1: 0); - info->stats[STAT_INTELLECT] += (lvl > 33 ? 2: (lvl > 2 ? 1: 0)); - info->stats[STAT_SPIRIT] += (lvl > 38 ? 2: (lvl > 3 ? 1: 0)); - break; - case CLASS_DRUID: - info->stats[STAT_STRENGTH] += (lvl > 38 ? 2: (lvl > 6 && (lvl%2) ? 1: 0)); - info->stats[STAT_STAMINA] += (lvl > 32 ? 2: (lvl > 4 ? 1: 0)); - info->stats[STAT_AGILITY] += (lvl > 38 ? 2: (lvl > 8 && (lvl%2) ? 1: 0)); - info->stats[STAT_INTELLECT] += (lvl > 38 ? 3: (lvl > 4 ? 1: 0)); - info->stats[STAT_SPIRIT] += (lvl > 38 ? 3: (lvl > 5 ? 1: 0)); - } - } -} - -void ObjectMgr::LoadGuilds() -{ - Guild *newguild; - uint32 count = 0; - - QueryResult *result = CharacterDatabase.Query( "SELECT guildid FROM guild" ); - - if( !result ) - { - - barGoLink bar( 1 ); - - bar.step(); - - sLog.outString(); - sLog.outString( ">> Loaded %u guild definitions", count ); - return; - } - - barGoLink bar( result->GetRowCount() ); - - do - { - Field *fields = result->Fetch(); - - bar.step(); - ++count; - - newguild = new Guild; - if(!newguild->LoadGuildFromDB(fields[0].GetUInt32())) - { - newguild->Disband(); - delete newguild; - continue; - } - AddGuild(newguild); - - }while( result->NextRow() ); - - delete result; - - sLog.outString(); - sLog.outString( ">> Loaded %u guild definitions", count ); -} - -void ObjectMgr::LoadArenaTeams() -{ - uint32 count = 0; - - QueryResult *result = CharacterDatabase.Query( "SELECT arenateamid FROM arena_team" ); - - if( !result ) - { - - barGoLink bar( 1 ); - - bar.step(); - - sLog.outString(); - sLog.outString( ">> Loaded %u arenateam definitions", count ); - return; - } - - barGoLink bar( result->GetRowCount() ); - - do - { - Field *fields = result->Fetch(); - - bar.step(); - ++count; - - ArenaTeam *newarenateam = new ArenaTeam; - if(!newarenateam->LoadArenaTeamFromDB(fields[0].GetUInt32())) - { - delete newarenateam; - continue; - } - AddArenaTeam(newarenateam); - }while( result->NextRow() ); - - delete result; - - sLog.outString(); - sLog.outString( ">> Loaded %u arenateam definitions", count ); -} - -void ObjectMgr::LoadGroups() -{ - // -- loading groups -- - Group *group = NULL; - uint64 leaderGuid = 0; - uint32 count = 0; - // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 - QueryResult *result = CharacterDatabase.PQuery("SELECT mainTank, mainAssistant, lootMethod, looterGuid, lootThreshold, icon1, icon2, icon3, icon4, icon5, icon6, icon7, icon8, isRaid, difficulty, leaderGuid FROM groups"); - - if( !result ) - { - barGoLink bar( 1 ); - - bar.step(); - - sLog.outString(); - sLog.outString( ">> Loaded %u group definitions", count ); - return; - } - - barGoLink bar( result->GetRowCount() ); - - do - { - bar.step(); - Field *fields = result->Fetch(); - ++count; - leaderGuid = MAKE_NEW_GUID(fields[15].GetUInt32(),0,HIGHGUID_PLAYER); - - group = new Group; - if(!group->LoadGroupFromDB(leaderGuid, result, false)) - { - group->Disband(); - delete group; - continue; - } - AddGroup(group); - }while( result->NextRow() ); - - delete result; - - sLog.outString(); - sLog.outString( ">> Loaded %u group definitions", count ); - - // -- loading members -- - count = 0; - group = NULL; - leaderGuid = 0; - // 0 1 2 3 - result = CharacterDatabase.PQuery("SELECT memberGuid, assistant, subgroup, leaderGuid FROM group_member ORDER BY leaderGuid"); - if(!result) - { - barGoLink bar( 1 ); - bar.step(); - } - else - { - barGoLink bar( result->GetRowCount() ); - do - { - bar.step(); - Field *fields = result->Fetch(); - count++; - leaderGuid = MAKE_NEW_GUID(fields[3].GetUInt32(), 0, HIGHGUID_PLAYER); - if(!group || group->GetLeaderGUID() != leaderGuid) - { - group = GetGroupByLeader(leaderGuid); - if(!group) - { - sLog.outErrorDb("Incorrect entry in group_member table : no group with leader %d for member %d!", fields[3].GetUInt32(), fields[0].GetUInt32()); - CharacterDatabase.PExecute("DELETE FROM group_member WHERE memberGuid = '%d'", fields[0].GetUInt32()); - continue; - } - } - - if(!group->LoadMemberFromDB(fields[0].GetUInt32(), fields[2].GetUInt8(), fields[1].GetBool())) - { - sLog.outErrorDb("Incorrect entry in group_member table : member %d cannot be added to player %d's group!", fields[0].GetUInt32(), fields[3].GetUInt32()); - CharacterDatabase.PExecute("DELETE FROM group_member WHERE memberGuid = '%d'", fields[0].GetUInt32()); - } - }while( result->NextRow() ); - delete result; - } - - // clean groups - // TODO: maybe delete from the DB before loading in this case - for(GroupSet::iterator itr = mGroupSet.begin(); itr != mGroupSet.end();) - { - if((*itr)->GetMembersCount() < 2) - { - (*itr)->Disband(); - delete *itr; - mGroupSet.erase(itr++); - } - else - ++itr; - } - - // -- loading instances -- - count = 0; - group = NULL; - leaderGuid = 0; - result = CharacterDatabase.PQuery( - // 0 1 2 3 4 5 - "SELECT leaderGuid, map, instance, permanent, difficulty, resettime, " - // 6 - "(SELECT COUNT(*) FROM character_instance WHERE guid = leaderGuid AND instance = group_instance.instance AND permanent = 1 LIMIT 1) " - "FROM group_instance LEFT JOIN instance ON instance = id ORDER BY leaderGuid" - ); - - if(!result) - { - barGoLink bar( 1 ); - bar.step(); - } - else - { - barGoLink bar( result->GetRowCount() ); - do - { - bar.step(); - Field *fields = result->Fetch(); - count++; - leaderGuid = MAKE_NEW_GUID(fields[0].GetUInt32(), 0, HIGHGUID_PLAYER); - if(!group || group->GetLeaderGUID() != leaderGuid) - { - group = GetGroupByLeader(leaderGuid); - if(!group) - { - sLog.outErrorDb("Incorrect entry in group_instance table : no group with leader %d", fields[0].GetUInt32()); - continue; - } - } - - InstanceSave *save = sInstanceSaveManager.AddInstanceSave(fields[1].GetUInt32(), fields[2].GetUInt32(), fields[4].GetUInt8(), (time_t)fields[5].GetUInt64(), (fields[6].GetUInt32() == 0), true); - group->BindToInstance(save, fields[3].GetBool(), true); - }while( result->NextRow() ); - delete result; - } - - sLog.outString(); - sLog.outString( ">> Loaded %u group-instance binds total", count ); - - sLog.outString(); - sLog.outString( ">> Loaded %u group members total", count ); -} - -void ObjectMgr::LoadQuests() -{ - // For reload case - for(QuestMap::const_iterator itr=mQuestTemplates.begin(); itr != mQuestTemplates.end(); ++itr) - delete itr->second; - mQuestTemplates.clear(); - - mExclusiveQuestGroups.clear(); - - // 0 1 2 3 4 5 6 7 - QueryResult *result = WorldDatabase.Query("SELECT entry, ZoneOrSort, SkillOrClass, MinLevel, QuestLevel, Type, RequiredRaces, RequiredSkillValue," - // 8 9 10 11 12 13 14 15 - "RepObjectiveFaction, RepObjectiveValue, RequiredMinRepFaction, RequiredMinRepValue, RequiredMaxRepFaction, RequiredMaxRepValue, SuggestedPlayers, LimitTime," - // 16 17 18 19 20 21 22 23 24 25 - "QuestFlags, SpecialFlags, CharTitleId, PrevQuestId, NextQuestId, ExclusiveGroup, NextQuestInChain, SrcItemId, SrcItemCount, SrcSpell," - // 26 27 28 29 30 31 32 33 34 35 - "Title, Details, Objectives, OfferRewardText, RequestItemsText, EndText, ObjectiveText1, ObjectiveText2, ObjectiveText3, ObjectiveText4," - // 36 37 38 39 40 41 42 43 - "ReqItemId1, ReqItemId2, ReqItemId3, ReqItemId4, ReqItemCount1, ReqItemCount2, ReqItemCount3, ReqItemCount4," - // 44 45 46 47 48 49 50 51 52 53 54 55 - "ReqSourceId1, ReqSourceId2, ReqSourceId3, ReqSourceId4, ReqSourceCount1, ReqSourceCount2, ReqSourceCount3, ReqSourceCount4, ReqSourceRef1, ReqSourceRef2, ReqSourceRef3, ReqSourceRef4," - // 56 57 58 59 60 61 62 63 - "ReqCreatureOrGOId1, ReqCreatureOrGOId2, ReqCreatureOrGOId3, ReqCreatureOrGOId4, ReqCreatureOrGOCount1, ReqCreatureOrGOCount2, ReqCreatureOrGOCount3, ReqCreatureOrGOCount4," - // 64 65 66 67 - "ReqSpellCast1, ReqSpellCast2, ReqSpellCast3, ReqSpellCast4," - // 68 69 70 71 72 73 - "RewChoiceItemId1, RewChoiceItemId2, RewChoiceItemId3, RewChoiceItemId4, RewChoiceItemId5, RewChoiceItemId6," - // 74 75 76 77 78 79 - "RewChoiceItemCount1, RewChoiceItemCount2, RewChoiceItemCount3, RewChoiceItemCount4, RewChoiceItemCount5, RewChoiceItemCount6," - // 80 81 82 83 84 85 86 87 - "RewItemId1, RewItemId2, RewItemId3, RewItemId4, RewItemCount1, RewItemCount2, RewItemCount3, RewItemCount4," - // 88 89 90 91 92 93 94 95 96 97 - "RewRepFaction1, RewRepFaction2, RewRepFaction3, RewRepFaction4, RewRepFaction5, RewRepValue1, RewRepValue2, RewRepValue3, RewRepValue4, RewRepValue5," - // 98 99 100 101 102 103 104 105 106 107 - "RewOrReqMoney, RewMoneyMaxLevel, RewSpell, RewSpellCast, RewMailTemplateId, RewMailDelaySecs, PointMapId, PointX, PointY, PointOpt," - // 108 109 110 111 112 113 114 115 116 117 - "DetailsEmote1, DetailsEmote2, DetailsEmote3, DetailsEmote4,IncompleteEmote, CompleteEmote, OfferRewardEmote1, OfferRewardEmote2, OfferRewardEmote3, OfferRewardEmote4," - // 118 119 - "StartScript, CompleteScript" - " FROM quest_template"); - if(result == NULL) - { - barGoLink bar( 1 ); - bar.step(); - - sLog.outString(); - sLog.outString( ">> Loaded 0 quests definitions" ); - sLog.outErrorDb("`quest_template` table is empty!"); - return; - } - - // create multimap previous quest for each existed quest - // some quests can have many previous maps set by NextQuestId in previous quest - // for example set of race quests can lead to single not race specific quest - barGoLink bar( result->GetRowCount() ); - do - { - bar.step(); - Field *fields = result->Fetch(); - - Quest * newQuest = new Quest(fields); - mQuestTemplates[newQuest->GetQuestId()] = newQuest; - } while( result->NextRow() ); - - delete result; - - // Post processing - for (QuestMap::iterator iter = mQuestTemplates.begin(); iter != mQuestTemplates.end(); iter++) - { - Quest * qinfo = iter->second; - - // additional quest integrity checks (GO, creature_template and item_template must be loaded already) - - if (qinfo->QuestFlags & ~QUEST_MANGOS_FLAGS_DB_ALLOWED) - { - sLog.outErrorDb("Quest %u has `SpecialFlags` = %u > max allowed value. Correct `SpecialFlags` to value <= %u", - qinfo->GetQuestId(),qinfo->QuestFlags,QUEST_MANGOS_FLAGS_DB_ALLOWED >> 16); - qinfo->QuestFlags &= QUEST_MANGOS_FLAGS_DB_ALLOWED; - } - - if(qinfo->QuestFlags & QUEST_FLAGS_DAILY) - { - if(!(qinfo->QuestFlags & QUEST_MANGOS_FLAGS_REPEATABLE)) - { - sLog.outErrorDb("Daily Quest %u not marked as repeatable in `SpecialFlags`, added.",qinfo->GetQuestId()); - qinfo->QuestFlags |= QUEST_MANGOS_FLAGS_REPEATABLE; - } - } - - if(qinfo->QuestFlags & QUEST_FLAGS_AUTO_REWARDED) - { - // at auto-reward can be rewarded only RewChoiceItemId[0] - for(int j = 1; j < QUEST_REWARD_CHOICES_COUNT; ++j ) - { - if(uint32 id = qinfo->RewChoiceItemId[j]) - { - sLog.outErrorDb("Quest %u has `RewChoiceItemId%d` = %u but item from `RewChoiceItemId%d` can't be rewarded with quest flag QUEST_FLAGS_AUTO_REWARDED.", - qinfo->GetQuestId(),j+1,id,j+1); - // no changes, quest ignore this data - } - } - } - - // client quest log visual (area case) - if( qinfo->ZoneOrSort > 0 ) - { - if(!GetAreaEntryByAreaID(qinfo->ZoneOrSort)) - { - sLog.outErrorDb("Quest %u has `ZoneOrSort` = %u (zone case) but zone with this id does not exist.", - qinfo->GetQuestId(),qinfo->ZoneOrSort); - // no changes, quest not dependent from this value but can have problems at client - } - } - // client quest log visual (sort case) - if( qinfo->ZoneOrSort < 0 ) - { - QuestSortEntry const* qSort = sQuestSortStore.LookupEntry(-int32(qinfo->ZoneOrSort)); - if( !qSort ) - { - sLog.outErrorDb("Quest %u has `ZoneOrSort` = %i (sort case) but quest sort with this id does not exist.", - qinfo->GetQuestId(),qinfo->ZoneOrSort); - // no changes, quest not dependent from this value but can have problems at client (note some may be 0, we must allow this so no check) - } - //check SkillOrClass value (class case). - if( ClassByQuestSort(-int32(qinfo->ZoneOrSort)) ) - { - // SkillOrClass should not have class case when class case already set in ZoneOrSort. - if(qinfo->SkillOrClass < 0) - { - sLog.outErrorDb("Quest %u has `ZoneOrSort` = %i (class sort case) and `SkillOrClass` = %i (class case), redundant.", - qinfo->GetQuestId(),qinfo->ZoneOrSort,qinfo->SkillOrClass); - } - } - //check for proper SkillOrClass value (skill case) - if(int32 skill_id = SkillByQuestSort(-int32(qinfo->ZoneOrSort))) - { - // skill is positive value in SkillOrClass - if(qinfo->SkillOrClass != skill_id ) - { - sLog.outErrorDb("Quest %u has `ZoneOrSort` = %i (skill sort case) but `SkillOrClass` does not have a corresponding value (%i).", - qinfo->GetQuestId(),qinfo->ZoneOrSort,skill_id); - //override, and force proper value here? - } - } - } - - // SkillOrClass (class case) - if( qinfo->SkillOrClass < 0 ) - { - if( !sChrClassesStore.LookupEntry(-int32(qinfo->SkillOrClass)) ) - { - sLog.outErrorDb("Quest %u has `SkillOrClass` = %i (class case) but class (%i) does not exist", - qinfo->GetQuestId(),qinfo->SkillOrClass,-qinfo->SkillOrClass); - } - } - // SkillOrClass (skill case) - if( qinfo->SkillOrClass > 0 ) - { - if( !sSkillLineStore.LookupEntry(qinfo->SkillOrClass) ) - { - sLog.outErrorDb("Quest %u has `SkillOrClass` = %u (skill case) but skill (%i) does not exist", - qinfo->GetQuestId(),qinfo->SkillOrClass,qinfo->SkillOrClass); - } - } - - if( qinfo->RequiredSkillValue ) - { - if( qinfo->RequiredSkillValue > sWorld.GetConfigMaxSkillValue() ) - { - sLog.outErrorDb("Quest %u has `RequiredSkillValue` = %u but max possible skill is %u, quest can't be done.", - qinfo->GetQuestId(),qinfo->RequiredSkillValue,sWorld.GetConfigMaxSkillValue()); - // no changes, quest can't be done for this requirement - } - - if( qinfo->SkillOrClass <= 0 ) - { - sLog.outErrorDb("Quest %u has `RequiredSkillValue` = %u but `SkillOrClass` = %i (class case), value ignored.", - qinfo->GetQuestId(),qinfo->RequiredSkillValue,qinfo->SkillOrClass); - // no changes, quest can't be done for this requirement (fail at wrong skill id) - } - } - // else Skill quests can have 0 skill level, this is ok - - if(qinfo->RepObjectiveFaction && !sFactionStore.LookupEntry(qinfo->RepObjectiveFaction)) - { - sLog.outErrorDb("Quest %u has `RepObjectiveFaction` = %u but faction template %u does not exist, quest can't be done.", - qinfo->GetQuestId(),qinfo->RepObjectiveFaction,qinfo->RepObjectiveFaction); - // no changes, quest can't be done for this requirement - } - - if(qinfo->RequiredMinRepFaction && !sFactionStore.LookupEntry(qinfo->RequiredMinRepFaction)) - { - sLog.outErrorDb("Quest %u has `RequiredMinRepFaction` = %u but faction template %u does not exist, quest can't be done.", - qinfo->GetQuestId(),qinfo->RequiredMinRepFaction,qinfo->RequiredMinRepFaction); - // no changes, quest can't be done for this requirement - } - - if(qinfo->RequiredMaxRepFaction && !sFactionStore.LookupEntry(qinfo->RequiredMaxRepFaction)) - { - sLog.outErrorDb("Quest %u has `RequiredMaxRepFaction` = %u but faction template %u does not exist, quest can't be done.", - qinfo->GetQuestId(),qinfo->RequiredMaxRepFaction,qinfo->RequiredMaxRepFaction); - // no changes, quest can't be done for this requirement - } - - if(qinfo->RequiredMinRepValue && qinfo->RequiredMinRepValue > Player::Reputation_Cap) - { - sLog.outErrorDb("Quest %u has `RequiredMinRepValue` = %d but max reputation is %u, quest can't be done.", - qinfo->GetQuestId(),qinfo->RequiredMinRepValue,Player::Reputation_Cap); - // no changes, quest can't be done for this requirement - } - - if(qinfo->RequiredMinRepValue && qinfo->RequiredMaxRepValue && qinfo->RequiredMaxRepValue <= qinfo->RequiredMinRepValue) - { - sLog.outErrorDb("Quest %u has `RequiredMaxRepValue` = %d and `RequiredMinRepValue` = %d, quest can't be done.", - qinfo->GetQuestId(),qinfo->RequiredMaxRepValue,qinfo->RequiredMinRepValue); - // no changes, quest can't be done for this requirement - } - - if(!qinfo->RepObjectiveFaction && qinfo->RepObjectiveValue > 0 ) - { - sLog.outErrorDb("Quest %u has `RepObjectiveValue` = %d but `RepObjectiveFaction` is 0, value has no effect", - qinfo->GetQuestId(),qinfo->RepObjectiveValue); - // warning - } - - if(!qinfo->RequiredMinRepFaction && qinfo->RequiredMinRepValue > 0 ) - { - sLog.outErrorDb("Quest %u has `RequiredMinRepValue` = %d but `RequiredMinRepFaction` is 0, value has no effect", - qinfo->GetQuestId(),qinfo->RequiredMinRepValue); - // warning - } - - if(!qinfo->RequiredMaxRepFaction && qinfo->RequiredMaxRepValue > 0 ) - { - sLog.outErrorDb("Quest %u has `RequiredMaxRepValue` = %d but `RequiredMaxRepFaction` is 0, value has no effect", - qinfo->GetQuestId(),qinfo->RequiredMaxRepValue); - // warning - } - - if(qinfo->CharTitleId && !sCharTitlesStore.LookupEntry(qinfo->CharTitleId)) - { - sLog.outErrorDb("Quest %u has `CharTitleId` = %u but CharTitle Id %u does not exist, quest can't be rewarded with title.", - qinfo->GetQuestId(),qinfo->GetCharTitleId(),qinfo->GetCharTitleId()); - qinfo->CharTitleId = 0; - // quest can't reward this title - } - - if(qinfo->SrcItemId) - { - if(!sItemStorage.LookupEntry(qinfo->SrcItemId)) - { - sLog.outErrorDb("Quest %u has `SrcItemId` = %u but item with entry %u does not exist, quest can't be done.", - qinfo->GetQuestId(),qinfo->SrcItemId,qinfo->SrcItemId); - qinfo->SrcItemId = 0; // quest can't be done for this requirement - } - else if(qinfo->SrcItemCount==0) - { - sLog.outErrorDb("Quest %u has `SrcItemId` = %u but `SrcItemCount` = 0, set to 1 but need fix in DB.", - qinfo->GetQuestId(),qinfo->SrcItemId); - qinfo->SrcItemCount = 1; // update to 1 for allow quest work for backward comptibility with DB - } - } - else if(qinfo->SrcItemCount>0) - { - sLog.outErrorDb("Quest %u has `SrcItemId` = 0 but `SrcItemCount` = %u, useless value.", - qinfo->GetQuestId(),qinfo->SrcItemCount); - qinfo->SrcItemCount=0; // no quest work changes in fact - } - - if(qinfo->SrcSpell) - { - SpellEntry const* spellInfo = sSpellStore.LookupEntry(qinfo->SrcSpell); - if(!spellInfo) - { - sLog.outErrorDb("Quest %u has `SrcSpell` = %u but spell %u doesn't exist, quest can't be done.", - qinfo->GetQuestId(),qinfo->SrcSpell,qinfo->SrcSpell); - qinfo->SrcSpell = 0; // quest can't be done for this requirement - } - else if(!SpellMgr::IsSpellValid(spellInfo)) - { - sLog.outErrorDb("Quest %u has `SrcSpell` = %u but spell %u is broken, quest can't be done.", - qinfo->GetQuestId(),qinfo->SrcSpell,qinfo->SrcSpell); - qinfo->SrcSpell = 0; // quest can't be done for this requirement - } - } - - for(int j = 0; j < QUEST_OBJECTIVES_COUNT; ++j ) - { - uint32 id = qinfo->ReqItemId[j]; - if(id) - { - if(qinfo->ReqItemCount[j]==0) - { - sLog.outErrorDb("Quest %u has `ReqItemId%d` = %u but `ReqItemCount%d` = 0, quest can't be done.", - qinfo->GetQuestId(),j+1,id,j+1); - // no changes, quest can't be done for this requirement - } - - qinfo->SetFlag(QUEST_MANGOS_FLAGS_DELIVER); - - if(!sItemStorage.LookupEntry(id)) - { - sLog.outErrorDb("Quest %u has `ReqItemId%d` = %u but item with entry %u does not exist, quest can't be done.", - qinfo->GetQuestId(),j+1,id,id); - qinfo->ReqItemCount[j] = 0; // prevent incorrect work of quest - } - } - else if(qinfo->ReqItemCount[j]>0) - { - sLog.outErrorDb("Quest %u has `ReqItemId%d` = 0 but `ReqItemCount%d` = %u, quest can't be done.", - qinfo->GetQuestId(),j+1,j+1,qinfo->ReqItemCount[j]); - qinfo->ReqItemCount[j] = 0; // prevent incorrect work of quest - } - } - - for(int j = 0; j < QUEST_SOURCE_ITEM_IDS_COUNT; ++j ) - { - uint32 id = qinfo->ReqSourceId[j]; - if(id) - { - if(!sItemStorage.LookupEntry(id)) - { - sLog.outErrorDb("Quest %u has `ReqSourceId%d` = %u but item with entry %u does not exist, quest can't be done.", - qinfo->GetQuestId(),j+1,id,id); - // no changes, quest can't be done for this requirement - } - - if(!qinfo->ReqSourceCount[j]) - { - sLog.outErrorDb("Quest %u has `ReqSourceId%d` = %u but `ReqSourceCount%d` = 0, quest can't be done.", - qinfo->GetQuestId(),j+1,id,j+1); - qinfo->ReqSourceId[j] = 0; // prevent incorrect work of quest - } - - if(!qinfo->ReqSourceRef[j]) - { - sLog.outErrorDb("Quest %u has `ReqSourceId%d` = %u but `ReqSourceRef%d` = 0, quest can't be done.", - qinfo->GetQuestId(),j+1,id,j+1); - qinfo->ReqSourceId[j] = 0; // prevent incorrect work of quest - } - } - else - { - if(qinfo->ReqSourceCount[j]>0) - { - sLog.outErrorDb("Quest %u has `ReqSourceId%d` = 0 but `ReqSourceCount%d` = %u.", - qinfo->GetQuestId(),j+1,j+1,qinfo->ReqSourceCount[j]); - // no changes, quest ignore this data - } - - if(qinfo->ReqSourceRef[j]>0) - { - sLog.outErrorDb("Quest %u has `ReqSourceId%d` = 0 but `ReqSourceRef%d` = %u.", - qinfo->GetQuestId(),j+1,j+1,qinfo->ReqSourceRef[j]); - // no changes, quest ignore this data - } - } - } - - for(int j = 0; j < QUEST_SOURCE_ITEM_IDS_COUNT; ++j ) - { - uint32 ref = qinfo->ReqSourceRef[j]; - if(ref) - { - if(ref > QUEST_OBJECTIVES_COUNT) - { - sLog.outErrorDb("Quest %u has `ReqSourceRef%d` = %u but max value in `ReqSourceRef%d` is %u, quest can't be done.", - qinfo->GetQuestId(),j+1,ref,j+1,QUEST_OBJECTIVES_COUNT); - // no changes, quest can't be done for this requirement - } - else - if(!qinfo->ReqItemId[ref-1] && !qinfo->ReqSpell[ref-1]) - { - sLog.outErrorDb("Quest %u has `ReqSourceRef%d` = %u but `ReqItemId%u` = 0 and `ReqSpellCast%u` = 0, quest can't be done.", - qinfo->GetQuestId(),j+1,ref,ref,ref); - // no changes, quest can't be done for this requirement - } - else if(qinfo->ReqItemId[ref-1] && qinfo->ReqSpell[ref-1]) - { - sLog.outErrorDb("Quest %u has `ReqItemId%u` = %u and `ReqSpellCast%u` = %u, quest can't have both fields <> 0, then can't be done.", - qinfo->GetQuestId(),ref,qinfo->ReqItemId[ref-1],ref,qinfo->ReqSpell[ref-1]); - // no changes, quest can't be done for this requirement - qinfo->ReqSourceId[j] = 0; // prevent incorrect work of quest - } - } - } - - for(int j = 0; j < QUEST_OBJECTIVES_COUNT; ++j ) - { - uint32 id = qinfo->ReqSpell[j]; - if(id) - { - SpellEntry const* spellInfo = sSpellStore.LookupEntry(id); - if(!spellInfo) - { - sLog.outErrorDb("Quest %u has `ReqSpellCast%d` = %u but spell %u does not exist, quest can't be done.", - qinfo->GetQuestId(),j+1,id,id); - // no changes, quest can't be done for this requirement - } - - if(!qinfo->ReqCreatureOrGOId[j]) - { - bool found = false; - for(int k = 0; k < 3; ++k) - { - if( spellInfo->Effect[k]==SPELL_EFFECT_QUEST_COMPLETE && uint32(spellInfo->EffectMiscValue[k])==qinfo->QuestId || - spellInfo->Effect[k]==SPELL_EFFECT_SEND_EVENT) - { - found = true; - break; - } - } - - if(found) - { - if(!qinfo->HasFlag(QUEST_MANGOS_FLAGS_EXPLORATION_OR_EVENT)) - { - sLog.outErrorDb("Spell (id: %u) have SPELL_EFFECT_QUEST_COMPLETE or SPELL_EFFECT_SEND_EVENT for quest %u and ReqCreatureOrGOId%d = 0, but quest not have flag QUEST_MANGOS_FLAGS_EXPLORATION_OR_EVENT. Quest flags or ReqCreatureOrGOId%d must be fixed, quest modified to enable objective.",spellInfo->Id,qinfo->QuestId,j+1,j+1); - - // this will prevent quest completing without objective - const_cast(qinfo)->SetFlag(QUEST_MANGOS_FLAGS_EXPLORATION_OR_EVENT); - } - } - else - { - sLog.outErrorDb("Quest %u has `ReqSpellCast%d` = %u and ReqCreatureOrGOId%d = 0 but spell %u does not have SPELL_EFFECT_QUEST_COMPLETE or SPELL_EFFECT_SEND_EVENT effect for this quest, quest can't be done.", - qinfo->GetQuestId(),j+1,id,j+1,id); - // no changes, quest can't be done for this requirement - } - } - } - } - - for(int j = 0; j < QUEST_OBJECTIVES_COUNT; ++j ) - { - int32 id = qinfo->ReqCreatureOrGOId[j]; - if(id < 0 && !sGOStorage.LookupEntry(-id)) - { - sLog.outErrorDb("Quest %u has `ReqCreatureOrGOId%d` = %i but gameobject %u does not exist, quest can't be done.", - qinfo->GetQuestId(),j+1,id,uint32(-id)); - qinfo->ReqCreatureOrGOId[j] = 0; // quest can't be done for this requirement - } - - if(id > 0 && !sCreatureStorage.LookupEntry(id)) - { - sLog.outErrorDb("Quest %u has `ReqCreatureOrGOId%d` = %i but creature with entry %u does not exist, quest can't be done.", - qinfo->GetQuestId(),j+1,id,uint32(id)); - qinfo->ReqCreatureOrGOId[j] = 0; // quest can't be done for this requirement - } - - if(id) - { - // In fact SpeakTo and Kill are quite same: either you can speak to mob:SpeakTo or you can't:Kill/Cast - - qinfo->SetFlag(QUEST_MANGOS_FLAGS_KILL_OR_CAST | QUEST_MANGOS_FLAGS_SPEAKTO); - - if(!qinfo->ReqCreatureOrGOCount[j]) - { - sLog.outErrorDb("Quest %u has `ReqCreatureOrGOId%d` = %u but `ReqCreatureOrGOCount%d` = 0, quest can't be done.", - qinfo->GetQuestId(),j+1,id,j+1); - // no changes, quest can be incorrectly done, but we already report this - } - } - else if(qinfo->ReqCreatureOrGOCount[j]>0) - { - sLog.outErrorDb("Quest %u has `ReqCreatureOrGOId%d` = 0 but `ReqCreatureOrGOCount%d` = %u.", - qinfo->GetQuestId(),j+1,j+1,qinfo->ReqCreatureOrGOCount[j]); - // no changes, quest ignore this data - } - } - - for(int j = 0; j < QUEST_REWARD_CHOICES_COUNT; ++j ) - { - uint32 id = qinfo->RewChoiceItemId[j]; - if(id) - { - if(!sItemStorage.LookupEntry(id)) - { - sLog.outErrorDb("Quest %u has `RewChoiceItemId%d` = %u but item with entry %u does not exist, quest will not reward this item.", - qinfo->GetQuestId(),j+1,id,id); - qinfo->RewChoiceItemId[j] = 0; // no changes, quest will not reward this - } - - if(!qinfo->RewChoiceItemCount[j]) - { - sLog.outErrorDb("Quest %u has `RewChoiceItemId%d` = %u but `RewChoiceItemCount%d` = 0, quest can't be done.", - qinfo->GetQuestId(),j+1,id,j+1); - // no changes, quest can't be done - } - } - else if(qinfo->RewChoiceItemCount[j]>0) - { - sLog.outErrorDb("Quest %u has `RewChoiceItemId%d` = 0 but `RewChoiceItemCount%d` = %u.", - qinfo->GetQuestId(),j+1,j+1,qinfo->RewChoiceItemCount[j]); - // no changes, quest ignore this data - } - } - - for(int j = 0; j < QUEST_REWARDS_COUNT; ++j ) - { - uint32 id = qinfo->RewItemId[j]; - if(id) - { - if(!sItemStorage.LookupEntry(id)) - { - sLog.outErrorDb("Quest %u has `RewItemId%d` = %u but item with entry %u does not exist, quest will not reward this item.", - qinfo->GetQuestId(),j+1,id,id); - qinfo->RewItemId[j] = 0; // no changes, quest will not reward this item - } - - if(!qinfo->RewItemCount[j]) - { - sLog.outErrorDb("Quest %u has `RewItemId%d` = %u but `RewItemCount%d` = 0, quest will not reward this item.", - qinfo->GetQuestId(),j+1,id,j+1); - // no changes - } - } - else if(qinfo->RewItemCount[j]>0) - { - sLog.outErrorDb("Quest %u has `RewItemId%d` = 0 but `RewItemCount%d` = %u.", - qinfo->GetQuestId(),j+1,j+1,qinfo->RewItemCount[j]); - // no changes, quest ignore this data - } - } - - for(int j = 0; j < QUEST_REPUTATIONS_COUNT; ++j) - { - if(qinfo->RewRepFaction[j]) - { - if(!qinfo->RewRepValue[j]) - { - sLog.outErrorDb("Quest %u has `RewRepFaction%d` = %u but `RewRepValue%d` = 0, quest will not reward this reputation.", - qinfo->GetQuestId(),j+1,qinfo->RewRepValue[j],j+1); - // no changes - } - - if(!sFactionStore.LookupEntry(qinfo->RewRepFaction[j])) - { - sLog.outErrorDb("Quest %u has `RewRepFaction%d` = %u but raw faction (faction.dbc) %u does not exist, quest will not reward reputation for this faction.", - qinfo->GetQuestId(),j+1,qinfo->RewRepFaction[j] ,qinfo->RewRepFaction[j] ); - qinfo->RewRepFaction[j] = 0; // quest will not reward this - } - } - else if(qinfo->RewRepValue[j]!=0) - { - sLog.outErrorDb("Quest %u has `RewRepFaction%d` = 0 but `RewRepValue%d` = %u.", - qinfo->GetQuestId(),j+1,j+1,qinfo->RewRepValue[j]); - // no changes, quest ignore this data - } - } - - if(qinfo->RewSpell) - { - SpellEntry const* spellInfo = sSpellStore.LookupEntry(qinfo->RewSpell); - - if(!spellInfo) - { - sLog.outErrorDb("Quest %u has `RewSpell` = %u but spell %u does not exist, spell removed as display reward.", - qinfo->GetQuestId(),qinfo->RewSpell,qinfo->RewSpell); - qinfo->RewSpell = 0; // no spell reward will display for this quest - } - - else if(!SpellMgr::IsSpellValid(spellInfo)) - { - sLog.outErrorDb("Quest %u has `RewSpell` = %u but spell %u is broken, quest can't be done.", - qinfo->GetQuestId(),qinfo->RewSpell,qinfo->RewSpell); - qinfo->RewSpell = 0; // no spell reward will display for this quest - } - - } - - if(qinfo->RewSpellCast) - { - SpellEntry const* spellInfo = sSpellStore.LookupEntry(qinfo->RewSpellCast); - - if(!spellInfo) - { - sLog.outErrorDb("Quest %u has `RewSpellCast` = %u but spell %u does not exist, quest will not have a spell reward.", - qinfo->GetQuestId(),qinfo->RewSpellCast,qinfo->RewSpellCast); - qinfo->RewSpellCast = 0; // no spell will be casted on player - } - - else if(!SpellMgr::IsSpellValid(spellInfo)) - { - sLog.outErrorDb("Quest %u has `RewSpellCast` = %u but spell %u is broken, quest can't be done.", - qinfo->GetQuestId(),qinfo->RewSpellCast,qinfo->RewSpellCast); - qinfo->RewSpellCast = 0; // no spell will be casted on player - } - - } - - if(qinfo->RewMailTemplateId) - { - if(!sMailTemplateStore.LookupEntry(qinfo->RewMailTemplateId)) - { - sLog.outErrorDb("Quest %u has `RewMailTemplateId` = %u but mail template %u does not exist, quest will not have a mail reward.", - qinfo->GetQuestId(),qinfo->RewMailTemplateId,qinfo->RewMailTemplateId); - qinfo->RewMailTemplateId = 0; // no mail will send to player - qinfo->RewMailDelaySecs = 0; // no mail will send to player - } - } - - if(qinfo->NextQuestInChain) - { - if(mQuestTemplates.find(qinfo->NextQuestInChain) == mQuestTemplates.end()) - { - sLog.outErrorDb("Quest %u has `NextQuestInChain` = %u but quest %u does not exist, quest chain will not work.", - qinfo->GetQuestId(),qinfo->NextQuestInChain ,qinfo->NextQuestInChain ); - qinfo->NextQuestInChain = 0; - } - else - mQuestTemplates[qinfo->NextQuestInChain]->prevChainQuests.push_back(qinfo->GetQuestId()); - } - - // fill additional data stores - if(qinfo->PrevQuestId) - { - if (mQuestTemplates.find(abs(qinfo->GetPrevQuestId())) == mQuestTemplates.end()) - { - sLog.outErrorDb("Quest %d has PrevQuestId %i, but no such quest", qinfo->GetQuestId(), qinfo->GetPrevQuestId()); - } - else - { - qinfo->prevQuests.push_back(qinfo->PrevQuestId); - } - } - - if(qinfo->NextQuestId) - { - if (mQuestTemplates.find(abs(qinfo->GetNextQuestId())) == mQuestTemplates.end()) - { - sLog.outErrorDb("Quest %d has NextQuestId %i, but no such quest", qinfo->GetQuestId(), qinfo->GetNextQuestId()); - } - else - { - int32 signedQuestId = qinfo->NextQuestId < 0 ? -int32(qinfo->GetQuestId()) : int32(qinfo->GetQuestId()); - mQuestTemplates[abs(qinfo->GetNextQuestId())]->prevQuests.push_back(signedQuestId); - } - } - - if(qinfo->ExclusiveGroup) - mExclusiveQuestGroups.insert(std::pair(qinfo->ExclusiveGroup, qinfo->GetQuestId())); - if(qinfo->LimitTime) - qinfo->SetFlag(QUEST_MANGOS_FLAGS_TIMED); - } - - // check QUEST_MANGOS_FLAGS_EXPLORATION_OR_EVENT for spell with SPELL_EFFECT_QUEST_COMPLETE - for (uint32 i = 0; i < sSpellStore.GetNumRows(); ++i) - { - SpellEntry const *spellInfo = sSpellStore.LookupEntry(i); - if(!spellInfo) - continue; - - for(int j = 0; j < 3; ++j) - { - if(spellInfo->Effect[j] != SPELL_EFFECT_QUEST_COMPLETE) - continue; - - uint32 quest_id = spellInfo->EffectMiscValue[j]; - - Quest const* quest = GetQuestTemplate(quest_id); - - // some quest referenced in spells not exist (outdataed spells) - if(!quest) - continue; - - if(!quest->HasFlag(QUEST_MANGOS_FLAGS_EXPLORATION_OR_EVENT)) - { - sLog.outErrorDb("Spell (id: %u) have SPELL_EFFECT_QUEST_COMPLETE for quest %u , but quest not have flag QUEST_MANGOS_FLAGS_EXPLORATION_OR_EVENT. Quest flags must be fixed, quest modified to enable objective.",spellInfo->Id,quest_id); - - // this will prevent quest completing without objective - const_cast(quest)->SetFlag(QUEST_MANGOS_FLAGS_EXPLORATION_OR_EVENT); - } - } - } - - sLog.outString(); - sLog.outString( ">> Loaded %u quests definitions", mQuestTemplates.size() ); -} - -void ObjectMgr::LoadQuestLocales() -{ - QueryResult *result = WorldDatabase.Query("SELECT entry," - "Title_loc1,Details_loc1,Objectives_loc1,OfferRewardText_loc1,RequestItemsText_loc1,EndText_loc1,ObjectiveText1_loc1,ObjectiveText2_loc1,ObjectiveText3_loc1,ObjectiveText4_loc1," - "Title_loc2,Details_loc2,Objectives_loc2,OfferRewardText_loc2,RequestItemsText_loc2,EndText_loc2,ObjectiveText1_loc2,ObjectiveText2_loc2,ObjectiveText3_loc2,ObjectiveText4_loc2," - "Title_loc3,Details_loc3,Objectives_loc3,OfferRewardText_loc3,RequestItemsText_loc3,EndText_loc3,ObjectiveText1_loc3,ObjectiveText2_loc3,ObjectiveText3_loc3,ObjectiveText4_loc3," - "Title_loc4,Details_loc4,Objectives_loc4,OfferRewardText_loc4,RequestItemsText_loc4,EndText_loc4,ObjectiveText1_loc4,ObjectiveText2_loc4,ObjectiveText3_loc4,ObjectiveText4_loc4," - "Title_loc5,Details_loc5,Objectives_loc5,OfferRewardText_loc5,RequestItemsText_loc5,EndText_loc5,ObjectiveText1_loc5,ObjectiveText2_loc5,ObjectiveText3_loc5,ObjectiveText4_loc5," - "Title_loc6,Details_loc6,Objectives_loc6,OfferRewardText_loc6,RequestItemsText_loc6,EndText_loc6,ObjectiveText1_loc6,ObjectiveText2_loc6,ObjectiveText3_loc6,ObjectiveText4_loc6," - "Title_loc7,Details_loc7,Objectives_loc7,OfferRewardText_loc7,RequestItemsText_loc7,EndText_loc7,ObjectiveText1_loc7,ObjectiveText2_loc7,ObjectiveText3_loc7,ObjectiveText4_loc7," - "Title_loc8,Details_loc8,Objectives_loc8,OfferRewardText_loc8,RequestItemsText_loc8,EndText_loc8,ObjectiveText1_loc8,ObjectiveText2_loc8,ObjectiveText3_loc8,ObjectiveText4_loc8" - " FROM locales_quest" - ); - - if(!result) - { - barGoLink bar(1); - - bar.step(); - - sLog.outString(""); - sLog.outString(">> Loaded 0 Quest locale strings. DB table `locales_quest` is empty."); - return; - } - - barGoLink bar(result->GetRowCount()); - - do - { - Field *fields = result->Fetch(); - bar.step(); - - uint32 entry = fields[0].GetUInt32(); - - QuestLocale& data = mQuestLocaleMap[entry]; - - for(int i = 1; i < MAX_LOCALE; ++i) - { - std::string str = fields[1+10*(i-1)].GetCppString(); - if(!str.empty()) - { - int idx = GetOrNewIndexForLocale(LocaleConstant(i)); - if(idx >= 0) - { - if(data.Title.size() <= idx) - data.Title.resize(idx+1); - - data.Title[idx] = str; - } - } - str = fields[1+10*(i-1)+1].GetCppString(); - if(!str.empty()) - { - int idx = GetOrNewIndexForLocale(LocaleConstant(i)); - if(idx >= 0) - { - if(data.Details.size() <= idx) - data.Details.resize(idx+1); - - data.Details[idx] = str; - } - } - str = fields[1+10*(i-1)+2].GetCppString(); - if(!str.empty()) - { - int idx = GetOrNewIndexForLocale(LocaleConstant(i)); - if(idx >= 0) - { - if(data.Objectives.size() <= idx) - data.Objectives.resize(idx+1); - - data.Objectives[idx] = str; - } - } - str = fields[1+10*(i-1)+3].GetCppString(); - if(!str.empty()) - { - int idx = GetOrNewIndexForLocale(LocaleConstant(i)); - if(idx >= 0) - { - if(data.OfferRewardText.size() <= idx) - data.OfferRewardText.resize(idx+1); - - data.OfferRewardText[idx] = str; - } - } - str = fields[1+10*(i-1)+4].GetCppString(); - if(!str.empty()) - { - int idx = GetOrNewIndexForLocale(LocaleConstant(i)); - if(idx >= 0) - { - if(data.RequestItemsText.size() <= idx) - data.RequestItemsText.resize(idx+1); - - data.RequestItemsText[idx] = str; - } - } - str = fields[1+10*(i-1)+5].GetCppString(); - if(!str.empty()) - { - int idx = GetOrNewIndexForLocale(LocaleConstant(i)); - if(idx >= 0) - { - if(data.EndText.size() <= idx) - data.EndText.resize(idx+1); - - data.EndText[idx] = str; - } - } - for(int k = 0; k < 4; ++k) - { - str = fields[1+10*(i-1)+6+k].GetCppString(); - if(!str.empty()) - { - int idx = GetOrNewIndexForLocale(LocaleConstant(i)); - if(idx >= 0) - { - if(data.ObjectiveText[k].size() <= idx) - data.ObjectiveText[k].resize(idx+1); - - data.ObjectiveText[k][idx] = str; - } - } - } - } - } while (result->NextRow()); - - delete result; - - sLog.outString(); - sLog.outString( ">> Loaded %u Quest locale strings", mQuestLocaleMap.size() ); -} - -void ObjectMgr::LoadPetCreateSpells() -{ - QueryResult *result = WorldDatabase.PQuery("SELECT entry, Spell1, Spell2, Spell3, Spell4 FROM petcreateinfo_spell"); - if(!result) - { - barGoLink bar( 1 ); - bar.step(); - - sLog.outString(); - sLog.outString( ">> Loaded 0 pet create spells" ); - sLog.outErrorDb("`petcreateinfo_spell` table is empty!"); - return; - } - - uint32 count = 0; - - barGoLink bar( result->GetRowCount() ); - - mPetCreateSpell.clear(); - - do - { - Field *fields = result->Fetch(); - bar.step(); - - uint32 creature_id = fields[0].GetUInt32(); - - if(!creature_id || !sCreatureStorage.LookupEntry(creature_id)) - continue; - - PetCreateSpellEntry PetCreateSpell; - for(int i = 0; i < 4; i++) - { - PetCreateSpell.spellid[i] = fields[i + 1].GetUInt32(); - - if(PetCreateSpell.spellid[i] && !sSpellStore.LookupEntry(PetCreateSpell.spellid[i])) - sLog.outErrorDb("Spell %u listed in `petcreateinfo_spell` does not exist",PetCreateSpell.spellid[i]); - } - - mPetCreateSpell[creature_id] = PetCreateSpell; - - ++count; - } - while (result->NextRow()); - - delete result; - - sLog.outString(); - sLog.outString( ">> Loaded %u pet create spells", count ); -} - -void ObjectMgr::LoadScripts(ScriptMapMap& scripts, char const* tablename) -{ - if(sWorld.IsScriptScheduled()) // function don't must be called in time scripts use. - return; - - sLog.outString( "%s :", tablename); - - scripts.clear(); // need for reload support - - QueryResult *result = WorldDatabase.PQuery( "SELECT id,delay,command,datalong,datalong2,datatext, x, y, z, o FROM %s", tablename ); - - uint32 count = 0; - - if( !result ) - { - barGoLink bar( 1 ); - bar.step(); - - sLog.outString(); - sLog.outString( ">> Loaded %u script definitions", count ); - return; - } - - barGoLink bar( result->GetRowCount() ); - - do - { - bar.step(); - - Field *fields = result->Fetch(); - ScriptInfo tmp; - tmp.id = fields[0].GetUInt32(); - tmp.delay = fields[1].GetUInt32(); - tmp.command = fields[2].GetUInt32(); - tmp.datalong = fields[3].GetUInt32(); - tmp.datalong2 = fields[4].GetUInt32(); - tmp.datatext = fields[5].GetCppString(); - tmp.x = fields[6].GetFloat(); - tmp.y = fields[7].GetFloat(); - tmp.z = fields[8].GetFloat(); - tmp.o = fields[9].GetFloat(); - - // generic command args check - switch(tmp.command) - { - case SCRIPT_COMMAND_TALK: - { - if(tmp.datalong > 3) - { - sLog.outErrorDb("Table `%s` has invalid talk type (datalong = %u) in SCRIPT_COMMAND_TALK for script id %u",tablename,tmp.datalong,tmp.id); - continue; - } - break; - } - - case SCRIPT_COMMAND_TELEPORT_TO: - { - if(!sMapStore.LookupEntry(tmp.datalong)) - { - sLog.outErrorDb("Table `%s` has invalid map (Id: %u) in SCRIPT_COMMAND_TELEPORT_TO for script id %u",tablename,tmp.datalong,tmp.id); - continue; - } - - if(!MaNGOS::IsValidMapCoord(tmp.x,tmp.y,tmp.z,tmp.o)) - { - sLog.outErrorDb("Table `%s` has invalid coordinates (X: %f Y: %f) in SCRIPT_COMMAND_TELEPORT_TO for script id %u",tablename,tmp.x,tmp.y,tmp.id); - continue; - } - break; - } - - case SCRIPT_COMMAND_TEMP_SUMMON_CREATURE: - { - if(!MaNGOS::IsValidMapCoord(tmp.x,tmp.y,tmp.z,tmp.o)) - { - sLog.outErrorDb("Table `%s` has invalid coordinates (X: %f Y: %f) in SCRIPT_COMMAND_TEMP_SUMMON_CREATURE for script id %u",tablename,tmp.x,tmp.y,tmp.id); - continue; - } - - if(!GetCreatureTemplate(tmp.datalong)) - { - sLog.outErrorDb("Table `%s` has invalid creature (Entry: %u) in SCRIPT_COMMAND_TEMP_SUMMON_CREATURE for script id %u",tablename,tmp.datalong,tmp.id); - continue; - } - break; - } - - case SCRIPT_COMMAND_RESPAWN_GAMEOBJECT: - { - GameObjectData const* data = GetGOData(tmp.datalong); - if(!data) - { - sLog.outErrorDb("Table `%s` has invalid gameobject (GUID: %u) in SCRIPT_COMMAND_RESPAWN_GAMEOBJECT for script id %u",tablename,tmp.datalong,tmp.id); - continue; - } - - GameObjectInfo const* info = GetGameObjectInfo(data->id); - if(!info) - { - sLog.outErrorDb("Table `%s` has gameobject with invalid entry (GUID: %u Entry: %u) in SCRIPT_COMMAND_RESPAWN_GAMEOBJECT for script id %u",tablename,tmp.datalong,data->id,tmp.id); - continue; - } - - if( info->type==GAMEOBJECT_TYPE_FISHINGNODE || - info->type==GAMEOBJECT_TYPE_FISHINGHOLE || - info->type==GAMEOBJECT_TYPE_DOOR || - info->type==GAMEOBJECT_TYPE_BUTTON || - info->type==GAMEOBJECT_TYPE_TRAP ) - { - sLog.outErrorDb("Table `%s` have gameobject type (%u) unsupported by command SCRIPT_COMMAND_RESPAWN_GAMEOBJECT for script id %u",tablename,info->id,tmp.id); - continue; - } - break; - } - case SCRIPT_COMMAND_OPEN_DOOR: - case SCRIPT_COMMAND_CLOSE_DOOR: - { - GameObjectData const* data = GetGOData(tmp.datalong); - if(!data) - { - sLog.outErrorDb("Table `%s` has invalid gameobject (GUID: %u) in %s for script id %u",tablename,tmp.datalong,(tmp.command==SCRIPT_COMMAND_OPEN_DOOR ? "SCRIPT_COMMAND_OPEN_DOOR" : "SCRIPT_COMMAND_CLOSE_DOOR"),tmp.id); - continue; - } - - GameObjectInfo const* info = GetGameObjectInfo(data->id); - if(!info) - { - sLog.outErrorDb("Table `%s` has gameobject with invalid entry (GUID: %u Entry: %u) in %s for script id %u",tablename,tmp.datalong,data->id,(tmp.command==SCRIPT_COMMAND_OPEN_DOOR ? "SCRIPT_COMMAND_OPEN_DOOR" : "SCRIPT_COMMAND_CLOSE_DOOR"),tmp.id); - continue; - } - - if( info->type!=GAMEOBJECT_TYPE_DOOR) - { - sLog.outErrorDb("Table `%s` has gameobject type (%u) non supported by command %s for script id %u",tablename,info->id,(tmp.command==SCRIPT_COMMAND_OPEN_DOOR ? "SCRIPT_COMMAND_OPEN_DOOR" : "SCRIPT_COMMAND_CLOSE_DOOR"),tmp.id); - continue; - } - - break; - } - case SCRIPT_COMMAND_QUEST_EXPLORED: - { - Quest const* quest = objmgr.GetQuestTemplate(tmp.datalong); - if(!quest) - { - sLog.outErrorDb("Table `%s` has invalid quest (ID: %u) in SCRIPT_COMMAND_QUEST_EXPLORED in `datalong` for script id %u",tablename,tmp.datalong,tmp.id); - continue; - } - - if(!quest->HasFlag(QUEST_MANGOS_FLAGS_EXPLORATION_OR_EVENT)) - { - sLog.outErrorDb("Table `%s` has quest (ID: %u) in SCRIPT_COMMAND_QUEST_EXPLORED in `datalong` for script id %u, but quest not have flag QUEST_MANGOS_FLAGS_EXPLORATION_OR_EVENT in quest flags. Script command or quest flags wrong. Quest modified to require objective.",tablename,tmp.datalong,tmp.id); - - // this will prevent quest completing without objective - const_cast(quest)->SetFlag(QUEST_MANGOS_FLAGS_EXPLORATION_OR_EVENT); - - // continue; - quest objective requiremet set and command can be allowed - } - - if(float(tmp.datalong2) > DEFAULT_VISIBILITY_DISTANCE) - { - sLog.outErrorDb("Table `%s` has too large distance (%u) for exploring objective complete in `datalong2` in SCRIPT_COMMAND_QUEST_EXPLORED in `datalong` for script id %u",tablename,tmp.datalong2,tmp.id); - continue; - } - - if(tmp.datalong2 && float(tmp.datalong2) > DEFAULT_VISIBILITY_DISTANCE) - { - sLog.outErrorDb("Table `%s` has too large distance (%u) for exploring objective complete in `datalong2` in SCRIPT_COMMAND_QUEST_EXPLORED in `datalong` for script id %u, max distance is %u or 0 for disable distance check",tablename,tmp.datalong2,tmp.id,uint32(DEFAULT_VISIBILITY_DISTANCE)); - continue; - } - - if(tmp.datalong2 && float(tmp.datalong2) < INTERACTION_DISTANCE) - { - sLog.outErrorDb("Table `%s` has too small distance (%u) for exploring objective complete in `datalong2` in SCRIPT_COMMAND_QUEST_EXPLORED in `datalong` for script id %u, min distance is %u or 0 for disable distance check",tablename,tmp.datalong2,tmp.id,uint32(INTERACTION_DISTANCE)); - continue; - } - - break; - } - - case SCRIPT_COMMAND_REMOVE_AURA: - case SCRIPT_COMMAND_CAST_SPELL: - { - if(!sSpellStore.LookupEntry(tmp.datalong)) - { - sLog.outErrorDb("Table `%s` using non-existent spell (id: %u) in SCRIPT_COMMAND_REMOVE_AURA or SCRIPT_COMMAND_CAST_SPELL for script id %u",tablename,tmp.datalong,tmp.id); - continue; - } - break; - } - } - - if (scripts.find(tmp.id) == scripts.end()) - { - ScriptMap emptyMap; - scripts[tmp.id] = emptyMap; - } - scripts[tmp.id].insert(std::pair(tmp.delay, tmp)); - - ++count; - } while( result->NextRow() ); - - delete result; - - sLog.outString(); - sLog.outString( ">> Loaded %u script definitions", count ); -} - -void ObjectMgr::LoadGameObjectScripts() -{ - LoadScripts(sGameObjectScripts, "gameobject_scripts"); - - // check ids - for(ScriptMapMap::const_iterator itr = sGameObjectScripts.begin(); itr != sGameObjectScripts.end(); ++itr) - { - if(!GetGOData(itr->first)) - sLog.outErrorDb("Table `gameobject_scripts` has not existing gameobject (GUID: %u) as script id",itr->first); - } -} - -void ObjectMgr::LoadQuestEndScripts() -{ - objmgr.LoadScripts(sQuestEndScripts, "quest_end_scripts"); - - // check ids - for(ScriptMapMap::const_iterator itr = sQuestEndScripts.begin(); itr != sQuestEndScripts.end(); ++itr) - { - if(!GetQuestTemplate(itr->first)) - sLog.outErrorDb("Table `quest_end_scripts` has not existing quest (Id: %u) as script id",itr->first); - } -} - -void ObjectMgr::LoadQuestStartScripts() -{ - objmgr.LoadScripts(sQuestStartScripts,"quest_start_scripts"); - - // check ids - for(ScriptMapMap::const_iterator itr = sQuestStartScripts.begin(); itr != sQuestStartScripts.end(); ++itr) - { - if(!GetQuestTemplate(itr->first)) - sLog.outErrorDb("Table `quest_start_scripts` has not existing quest (Id: %u) as script id",itr->first); - } -} - -void ObjectMgr::LoadSpellScripts() -{ - objmgr.LoadScripts(sSpellScripts, "spell_scripts"); - - // check ids - for(ScriptMapMap::const_iterator itr = sSpellScripts.begin(); itr != sSpellScripts.end(); ++itr) - { - SpellEntry const* spellInfo = sSpellStore.LookupEntry(itr->first); - - if(!spellInfo) - { - sLog.outErrorDb("Table `spell_scripts` has not existing spell (Id: %u) as script id",itr->first); - continue; - } - - //check for correct spellEffect - bool found = false; - for(int i=0; i<3; ++i) - { - // skip empty effects - if( !spellInfo->Effect[i] ) - continue; - - if( spellInfo->Effect[i] == SPELL_EFFECT_SCRIPT_EFFECT ) - { - found = true; - break; - } - } - - if(!found) - sLog.outErrorDb("Table `spell_scripts` has unsupported spell (Id: %u) without SPELL_EFFECT_SCRIPT_EFFECT (%u) spell effect",itr->first,SPELL_EFFECT_SCRIPT_EFFECT); - } -} - -void ObjectMgr::LoadEventScripts() -{ - objmgr.LoadScripts(sEventScripts, "event_scripts"); - - std::set evt_scripts; - // Load all possible script entries from gameobjects - for(uint32 i = 1; i < sGOStorage.MaxEntry; ++i) - { - GameObjectInfo const * goInfo = sGOStorage.LookupEntry(i); - if (goInfo) - { - switch(goInfo->type) - { - case GAMEOBJECT_TYPE_GOOBER: - if(goInfo->goober.eventId) - evt_scripts.insert(goInfo->goober.eventId); - break; - case GAMEOBJECT_TYPE_CHEST: - if(goInfo->chest.eventId) - evt_scripts.insert(goInfo->chest.eventId); - break; - default: - break; - } - } - } - // Load all possible script entries from spells - for(uint32 i = 1; i < sSpellStore.GetNumRows(); ++i) - { - SpellEntry const * spell = sSpellStore.LookupEntry(i); - if (spell) - { - for(int j=0; j<3; ++j) - { - if( spell->Effect[j] == SPELL_EFFECT_SEND_EVENT ) - { - if (spell->EffectMiscValue[j]) - evt_scripts.insert(spell->EffectMiscValue[j]); - } - } - } - } - // Then check if all scripts are in above list of possible script entries - for(ScriptMapMap::const_iterator itr = sEventScripts.begin(); itr != sEventScripts.end(); ++itr) - { - std::set::const_iterator itr2 = evt_scripts.find(itr->first); - if (itr2 == evt_scripts.end()) - sLog.outErrorDb("Table `event_scripts` has script (Id: %u) not refering to any gameobject_template type 10 data2 field or type 3 data6 field or any spell effect %u", itr->first, SPELL_EFFECT_SEND_EVENT); - } -} - -void ObjectMgr::LoadItemTexts() -{ - QueryResult *result = CharacterDatabase.PQuery("SELECT id, text FROM item_text"); - - uint32 count = 0; - - if( !result ) - { - barGoLink bar( 1 ); - bar.step(); - - sLog.outString(); - sLog.outString( ">> Loaded %u item pages", count ); - return; - } - - barGoLink bar( result->GetRowCount() ); - - Field* fields; - do - { - bar.step(); - - fields = result->Fetch(); - - mItemTexts[ fields[0].GetUInt32() ] = fields[1].GetCppString(); - - ++count; - - } while ( result->NextRow() ); - - delete result; - - sLog.outString(); - sLog.outString( ">> Loaded %u item texts", count ); -} - -void ObjectMgr::LoadPageTexts() -{ - sPageTextStore.Free(); // for reload case - - sPageTextStore.Load(); - sLog.outString( ">> Loaded %u page texts", sPageTextStore.RecordCount ); - sLog.outString(); - - for(uint32 i = 1; i < sPageTextStore.MaxEntry; ++i) - { - // check data correctness - PageText const* page = sPageTextStore.LookupEntry(i); - if(!page) - continue; - - if(page->Next_Page && !sPageTextStore.LookupEntry(page->Next_Page)) - { - sLog.outErrorDb("Page text (Id: %u) has not existing next page (Id:%u)", i,page->Next_Page); - continue; - } - - // detect circular reference - std::set checkedPages; - for(PageText const* pageItr = page; pageItr; pageItr = sPageTextStore.LookupEntry(pageItr->Next_Page)) - { - if(!pageItr->Next_Page) - break; - checkedPages.insert(pageItr->Page_ID); - if(checkedPages.find(pageItr->Next_Page)!=checkedPages.end()) - { - std::ostringstream ss; - ss<< "The text page(s) "; - for (std::set::iterator itr= checkedPages.begin();itr!=checkedPages.end(); itr++) - ss << *itr << " "; - ss << "create(s) a circular reference, which can cause the server to freeze. Changing Next_Page of page " - << pageItr->Page_ID <<" to 0"; - sLog.outErrorDb(ss.str().c_str()); - const_cast(pageItr)->Next_Page = 0; - break; - } - } - } -} - -void ObjectMgr::LoadPageTextLocales() -{ - QueryResult *result = WorldDatabase.PQuery("SELECT entry,text_loc1,text_loc2,text_loc3,text_loc4,text_loc5,text_loc6,text_loc7,text_loc8 FROM locales_page_text"); - - if(!result) - { - barGoLink bar(1); - - bar.step(); - - sLog.outString(""); - sLog.outString(">> Loaded 0 PageText locale strings. DB table `locales_page_text` is empty."); - return; - } - - barGoLink bar(result->GetRowCount()); - - do - { - Field *fields = result->Fetch(); - bar.step(); - - uint32 entry = fields[0].GetUInt32(); - - PageTextLocale& data = mPageTextLocaleMap[entry]; - - for(int i = 1; i < MAX_LOCALE; ++i) - { - std::string str = fields[i].GetCppString(); - if(str.empty()) - continue; - - int idx = GetOrNewIndexForLocale(LocaleConstant(i)); - if(idx >= 0) - { - if(data.Text.size() <= idx) - data.Text.resize(idx+1); - - data.Text[idx] = str; - } - } - - } while (result->NextRow()); - - delete result; - - sLog.outString(); - sLog.outString( ">> Loaded %u PageText locale strings", mPageTextLocaleMap.size() ); -} - -void ObjectMgr::LoadInstanceTemplate() -{ - sInstanceTemplate.Load(); - - for(uint32 i = 0; i < sInstanceTemplate.MaxEntry; i++) - { - InstanceTemplate* temp = (InstanceTemplate*)GetInstanceTemplate(i); - if(!temp) continue; - const MapEntry* entry = sMapStore.LookupEntry(temp->map); - if(!entry) - { - sLog.outErrorDb("ObjectMgr::LoadInstanceTemplate: bad mapid %d for template!", temp->map); - continue; - } - else if(!entry->HasResetTime()) - continue; - - if(temp->reset_delay == 0) - { - // use defaults from the DBC - if(entry->SupportsHeroicMode()) - { - temp->reset_delay = entry->resetTimeHeroic / DAY; - } - else if (entry->resetTimeRaid && entry->map_type == MAP_RAID) - { - temp->reset_delay = entry->resetTimeRaid / DAY; - } - } - - // the reset_delay must be atleast one day - temp->reset_delay = std::max((uint32)1, (uint32)(temp->reset_delay * sWorld.getRate(RATE_INSTANCE_RESET_TIME))); - } - - sLog.outString( ">> Loaded %u Instance Template definitions", sInstanceTemplate.RecordCount ); - sLog.outString(); -} - -void ObjectMgr::AddGossipText(GossipText *pGText) -{ - ASSERT( pGText->Text_ID ); - ASSERT( mGossipText.find(pGText->Text_ID) == mGossipText.end() ); - mGossipText[pGText->Text_ID] = pGText; -} - -GossipText *ObjectMgr::GetGossipText(uint32 Text_ID) -{ - GossipTextMap::const_iterator itr; - for (itr = mGossipText.begin(); itr != mGossipText.end(); itr++) - { - if(itr->second->Text_ID == Text_ID) - return itr->second; - } - return NULL; -} - -void ObjectMgr::LoadGossipText() -{ - GossipText *pGText; - QueryResult *result = WorldDatabase.Query( "SELECT * FROM npc_text" ); - - int count = 0; - if( !result ) - { - barGoLink bar( 1 ); - bar.step(); - - sLog.outString(); - sLog.outString( ">> Loaded %u npc texts", count ); - return; - } - - int cic; - - barGoLink bar( result->GetRowCount() ); - - do - { - ++count; - cic = 0; - - Field *fields = result->Fetch(); - - bar.step(); - - pGText = new GossipText; - pGText->Text_ID = fields[cic++].GetUInt32(); - - for (int i=0; i< 8; i++) - { - pGText->Options[i].Text_0 = fields[cic++].GetCppString(); - pGText->Options[i].Text_1 = fields[cic++].GetCppString(); - - pGText->Options[i].Language = fields[cic++].GetUInt32(); - pGText->Options[i].Probability = fields[cic++].GetFloat(); - - pGText->Options[i].Emotes[0]._Delay = fields[cic++].GetUInt32(); - pGText->Options[i].Emotes[0]._Emote = fields[cic++].GetUInt32(); - - pGText->Options[i].Emotes[1]._Delay = fields[cic++].GetUInt32(); - pGText->Options[i].Emotes[1]._Emote = fields[cic++].GetUInt32(); - - pGText->Options[i].Emotes[2]._Delay = fields[cic++].GetUInt32(); - pGText->Options[i].Emotes[2]._Emote = fields[cic++].GetUInt32(); - } - - if ( !pGText->Text_ID ) continue; - AddGossipText( pGText ); - - } while( result->NextRow() ); - - sLog.outString(); - sLog.outString( ">> Loaded %u npc texts", count ); - delete result; -} - -void ObjectMgr::LoadNpcTextLocales() -{ - QueryResult *result = WorldDatabase.Query("SELECT entry," - "Text0_0_loc1,Text0_1_loc1,Text1_0_loc1,Text1_1_loc1,Text2_0_loc1,Text2_1_loc1,Text3_0_loc1,Text3_1_loc1,Text4_0_loc1,Text4_1_loc1,Text5_0_loc1,Text5_1_loc1,Text6_0_loc1,Text6_1_loc1,Text7_0_loc1,Text7_1_loc1," - "Text0_0_loc2,Text0_1_loc2,Text1_0_loc2,Text1_1_loc2,Text2_0_loc2,Text2_1_loc2,Text3_0_loc2,Text3_1_loc1,Text4_0_loc2,Text4_1_loc2,Text5_0_loc2,Text5_1_loc2,Text6_0_loc2,Text6_1_loc2,Text7_0_loc2,Text7_1_loc2," - "Text0_0_loc3,Text0_1_loc3,Text1_0_loc3,Text1_1_loc3,Text2_0_loc3,Text2_1_loc3,Text3_0_loc3,Text3_1_loc1,Text4_0_loc3,Text4_1_loc3,Text5_0_loc3,Text5_1_loc3,Text6_0_loc3,Text6_1_loc3,Text7_0_loc3,Text7_1_loc3," - "Text0_0_loc4,Text0_1_loc4,Text1_0_loc4,Text1_1_loc4,Text2_0_loc4,Text2_1_loc4,Text3_0_loc4,Text3_1_loc1,Text4_0_loc4,Text4_1_loc4,Text5_0_loc4,Text5_1_loc4,Text6_0_loc4,Text6_1_loc4,Text7_0_loc4,Text7_1_loc4," - "Text0_0_loc5,Text0_1_loc5,Text1_0_loc5,Text1_1_loc5,Text2_0_loc5,Text2_1_loc5,Text3_0_loc5,Text3_1_loc1,Text4_0_loc5,Text4_1_loc5,Text5_0_loc5,Text5_1_loc5,Text6_0_loc5,Text6_1_loc5,Text7_0_loc5,Text7_1_loc5," - "Text0_0_loc6,Text0_1_loc6,Text1_0_loc6,Text1_1_loc6,Text2_0_loc6,Text2_1_loc6,Text3_0_loc6,Text3_1_loc1,Text4_0_loc6,Text4_1_loc6,Text5_0_loc6,Text5_1_loc6,Text6_0_loc6,Text6_1_loc6,Text7_0_loc6,Text7_1_loc6," - "Text0_0_loc7,Text0_1_loc7,Text1_0_loc7,Text1_1_loc7,Text2_0_loc7,Text2_1_loc7,Text3_0_loc7,Text3_1_loc1,Text4_0_loc7,Text4_1_loc7,Text5_0_loc7,Text5_1_loc7,Text6_0_loc7,Text6_1_loc7,Text7_0_loc7,Text7_1_loc7, " - "Text0_0_loc8,Text0_1_loc8,Text1_0_loc8,Text1_1_loc8,Text2_0_loc8,Text2_1_loc8,Text3_0_loc8,Text3_1_loc1,Text4_0_loc8,Text4_1_loc8,Text5_0_loc8,Text5_1_loc8,Text6_0_loc8,Text6_1_loc8,Text7_0_loc8,Text7_1_loc8 " - " FROM locales_npc_text"); - - if(!result) - { - barGoLink bar(1); - - bar.step(); - - sLog.outString(""); - sLog.outString(">> Loaded 0 Quest locale strings. DB table `locales_npc_text` is empty."); - return; - } - - barGoLink bar(result->GetRowCount()); - - do - { - Field *fields = result->Fetch(); - bar.step(); - - uint32 entry = fields[0].GetUInt32(); - - NpcTextLocale& data = mNpcTextLocaleMap[entry]; - - for(int i=1; i= 0) - { - if(data.Text_0[j].size() <= idx) - data.Text_0[j].resize(idx+1); - - data.Text_0[j][idx] = str0; - } - } - std::string str1 = fields[1+8*2*(i-1)+2*j+1].GetCppString(); - if(!str1.empty()) - { - int idx = GetOrNewIndexForLocale(LocaleConstant(i)); - if(idx >= 0) - { - if(data.Text_1[j].size() <= idx) - data.Text_1[j].resize(idx+1); - - data.Text_1[j][idx] = str1; - } - } - } - } - } while (result->NextRow()); - - delete result; - - sLog.outString(); - sLog.outString( ">> Loaded %u NpcText locale strings", mNpcTextLocaleMap.size() ); -} - -//not very fast function but it is called only once a day, or on starting-up -void ObjectMgr::ReturnOrDeleteOldMails(bool serverUp) -{ - time_t basetime = time(NULL); - sLog.outDebug("Returning mails current time: hour: %d, minute: %d, second: %d ", localtime(&basetime)->tm_hour, localtime(&basetime)->tm_min, localtime(&basetime)->tm_sec); - //delete all old mails without item and without body immediately, if starting server - if (!serverUp) - CharacterDatabase.PExecute("DELETE FROM mail WHERE expire_time < '" I64FMTD "' AND has_items = '0' AND itemTextId = 0", (uint64)basetime); - // 0 1 2 3 4 5 6 7 8 9 - QueryResult* result = CharacterDatabase.PQuery("SELECT id,messageType,sender,receiver,itemTextId,has_items,expire_time,cod,checked,mailTemplateId FROM mail WHERE expire_time < '" I64FMTD "'", (uint64)basetime); - if ( !result ) - return; // any mails need to be returned or deleted - Field *fields; - //std::ostringstream delitems, delmails; //will be here for optimization - //bool deletemail = false, deleteitem = false; - //delitems << "DELETE FROM item_instance WHERE guid IN ( "; - //delmails << "DELETE FROM mail WHERE id IN ( " - do - { - fields = result->Fetch(); - Mail *m = new Mail; - m->messageID = fields[0].GetUInt32(); - m->messageType = fields[1].GetUInt8(); - m->sender = fields[2].GetUInt32(); - m->receiver = fields[3].GetUInt32(); - m->itemTextId = fields[4].GetUInt32(); - bool has_items = fields[5].GetBool(); - m->expire_time = (time_t)fields[6].GetUInt64(); - m->deliver_time = 0; - m->COD = fields[7].GetUInt32(); - m->checked = fields[8].GetUInt32(); - m->mailTemplateId = fields[9].GetInt16(); - - Player *pl = 0; - if (serverUp) - pl = objmgr.GetPlayer((uint64)m->receiver); - if (pl && pl->m_mailsLoaded) - { //this code will run very improbably (the time is between 4 and 5 am, in game is online a player, who has old mail - //his in mailbox and he has already listed his mails ) - delete m; - continue; - } - //delete or return mail: - if (has_items) - { - QueryResult *resultItems = CharacterDatabase.PQuery("SELECT item_guid,item_template FROM mail_items WHERE mail_id='%u'", m->messageID); - if(resultItems) - { - do - { - Field *fields2 = resultItems->Fetch(); - - uint32 item_guid_low = fields2[0].GetUInt32(); - uint32 item_template = fields2[1].GetUInt32(); - - m->AddItem(item_guid_low, item_template); - } - while (resultItems->NextRow()); - - delete resultItems; - } - //if it is mail from AH, it shouldn't be returned, but deleted - if (m->messageType != MAIL_NORMAL || (m->checked & (MAIL_CHECK_MASK_AUCTION | MAIL_CHECK_MASK_COD_PAYMENT | MAIL_CHECK_MASK_RETURNED))) - { - // mail open and then not returned - for(std::vector::iterator itr2 = m->items.begin(); itr2 != m->items.end(); ++itr2) - CharacterDatabase.PExecute("DELETE FROM item_instance WHERE guid = '%u'", itr2->item_guid); - } - else - { - //mail will be returned: - CharacterDatabase.PExecute("UPDATE mail SET sender = '%u', receiver = '%u', expire_time = '" I64FMTD "', deliver_time = '" I64FMTD "',cod = '0', checked = '%u' WHERE id = '%u'", m->receiver, m->sender, (uint64)(basetime + 30*DAY), (uint64)basetime, MAIL_CHECK_MASK_RETURNED, m->messageID); - delete m; - continue; - } - } - - if (m->itemTextId) - CharacterDatabase.PExecute("DELETE FROM item_text WHERE id = '%u'", m->itemTextId); - - //deletemail = true; - //delmails << m->messageID << ", "; - CharacterDatabase.PExecute("DELETE FROM mail WHERE id = '%u'", m->messageID); - delete m; - } while (result->NextRow()); - delete result; -} - -void ObjectMgr::LoadQuestAreaTriggers() -{ - mQuestAreaTriggerMap.clear(); // need for reload case - - QueryResult *result = WorldDatabase.Query( "SELECT id,quest FROM areatrigger_involvedrelation" ); - - uint32 count = 0; - - if( !result ) - { - barGoLink bar( 1 ); - bar.step(); - - sLog.outString(); - sLog.outString( ">> Loaded %u quest trigger points", count ); - return; - } - - barGoLink bar( result->GetRowCount() ); - - do - { - ++count; - bar.step(); - - Field *fields = result->Fetch(); - - uint32 trigger_ID = fields[0].GetUInt32(); - uint32 quest_ID = fields[1].GetUInt32(); - - AreaTriggerEntry const* atEntry = sAreaTriggerStore.LookupEntry(trigger_ID); - if(!atEntry) - { - sLog.outErrorDb("Area trigger (ID:%u) does not exist in `AreaTrigger.dbc`.",trigger_ID); - continue; - } - - Quest const* quest = GetQuestTemplate(quest_ID); - - if(!quest) - { - sLog.outErrorDb("Table `areatrigger_involvedrelation` has record (id: %u) for not existing quest %u",trigger_ID,quest_ID); - continue; - } - - if(!quest->HasFlag(QUEST_MANGOS_FLAGS_EXPLORATION_OR_EVENT)) - { - sLog.outErrorDb("Table `areatrigger_involvedrelation` has record (id: %u) for not quest %u, but quest not have flag QUEST_MANGOS_FLAGS_EXPLORATION_OR_EVENT. Trigger or quest flags must be fixed, quest modified to require objective.",trigger_ID,quest_ID); - - // this will prevent quest completing without objective - const_cast(quest)->SetFlag(QUEST_MANGOS_FLAGS_EXPLORATION_OR_EVENT); - - // continue; - quest modified to required obkective and trigger can be allowed. - } - - mQuestAreaTriggerMap[trigger_ID] = quest_ID; - - } while( result->NextRow() ); - - delete result; - - sLog.outString(); - sLog.outString( ">> Loaded %u quest trigger points", count ); -} - -void ObjectMgr::LoadTavernAreaTriggers() -{ - mTavernAreaTriggerSet.clear(); // need for reload case - - QueryResult *result = WorldDatabase.Query("SELECT id FROM areatrigger_tavern"); - - uint32 count = 0; - - if( !result ) - { - barGoLink bar( 1 ); - bar.step(); - - sLog.outString(); - sLog.outString( ">> Loaded %u tavern triggers", count ); - return; - } - - barGoLink bar( result->GetRowCount() ); - - do - { - ++count; - bar.step(); - - Field *fields = result->Fetch(); - - uint32 Trigger_ID = fields[0].GetUInt32(); - - AreaTriggerEntry const* atEntry = sAreaTriggerStore.LookupEntry(Trigger_ID); - if(!atEntry) - { - sLog.outErrorDb("Area trigger (ID:%u) does not exist in `AreaTrigger.dbc`.",Trigger_ID); - continue; - } - - mTavernAreaTriggerSet.insert(Trigger_ID); - } while( result->NextRow() ); - - delete result; - - sLog.outString(); - sLog.outString( ">> Loaded %u tavern triggers", count ); -} - -void ObjectMgr::LoadAreaTriggerScripts() -{ - mAreaTriggerScripts.clear(); // need for reload case - QueryResult *result = WorldDatabase.Query("SELECT entry, ScriptName FROM areatrigger_scripts"); - - uint32 count = 0; - - if( !result ) - { - barGoLink bar( 1 ); - bar.step(); - - sLog.outString(); - sLog.outString( ">> Loaded %u areatrigger scripts", count ); - return; - } - - barGoLink bar( result->GetRowCount() ); - - do - { - ++count; - bar.step(); - - Field *fields = result->Fetch(); - - uint32 Trigger_ID = fields[0].GetUInt32(); - std::string scriptName = fields[1].GetCppString(); - - AreaTriggerEntry const* atEntry = sAreaTriggerStore.LookupEntry(Trigger_ID); - if(!atEntry) - { - sLog.outErrorDb("Area trigger (ID:%u) does not exist in `AreaTrigger.dbc`.",Trigger_ID); - continue; - } - mAreaTriggerScripts[Trigger_ID] = scriptName; - } while( result->NextRow() ); - - delete result; - - sLog.outString(); - sLog.outString( ">> Loaded %u areatrigger scripts", count ); -} -uint32 ObjectMgr::GetNearestTaxiNode( float x, float y, float z, uint32 mapid ) -{ - bool found = false; - float dist; - uint32 id = 0; - - for(uint32 i = 1; i < sTaxiNodesStore.GetNumRows(); ++i) - { - TaxiNodesEntry const* node = sTaxiNodesStore.LookupEntry(i); - if(node && node->map_id == mapid) - { - float dist2 = (node->x - x)*(node->x - x)+(node->y - y)*(node->y - y)+(node->z - z)*(node->z - z); - if(found) - { - if(dist2 < dist) - { - dist = dist2; - id = i; - } - } - else - { - found = true; - dist = dist2; - id = i; - } - } - } - - return id; -} - -void ObjectMgr::GetTaxiPath( uint32 source, uint32 destination, uint32 &path, uint32 &cost) -{ - TaxiPathSetBySource::iterator src_i = sTaxiPathSetBySource.find(source); - if(src_i==sTaxiPathSetBySource.end()) - { - path = 0; - cost = 0; - return; - } - - TaxiPathSetForSource& pathSet = src_i->second; - - TaxiPathSetForSource::iterator dest_i = pathSet.find(destination); - if(dest_i==pathSet.end()) - { - path = 0; - cost = 0; - return; - } - - cost = dest_i->second.price; - path = dest_i->second.ID; -} - -uint16 ObjectMgr::GetTaxiMount( uint32 id, uint32 team ) -{ - uint16 mount_entry = 0; - uint16 mount_id = 0; - - TaxiNodesEntry const* node = sTaxiNodesStore.LookupEntry(id); - if(node) - { - if (team == ALLIANCE) - { - mount_entry = node->alliance_mount_type; - CreatureInfo const *ci = objmgr.GetCreatureTemplate(mount_entry); - if(ci) - mount_id = ci->DisplayID_A; - } - if (team == HORDE) - { - mount_entry = node->horde_mount_type; - CreatureInfo const *ci = objmgr.GetCreatureTemplate(mount_entry); - if(ci) - mount_id = ci->DisplayID_H; - } - } - - CreatureModelInfo const *minfo = objmgr.GetCreatureModelInfo(mount_id); - if(!minfo) - { - sLog.outErrorDb("Taxi mount (Entry: %u) for taxi node (Id: %u) for team %u has model %u not found in table `creature_model_info`, can't load. ", - mount_entry,id,team,mount_id); - - return false; - } - if(minfo->modelid_other_gender!=0) - mount_id = urand(0,1) ? mount_id : minfo->modelid_other_gender; - - return mount_id; -} - -void ObjectMgr::GetTaxiPathNodes( uint32 path, Path &pathnodes, std::vector& mapIds) -{ - if(path >= sTaxiPathNodesByPath.size()) - return; - - TaxiPathNodeList& nodeList = sTaxiPathNodesByPath[path]; - - pathnodes.Resize(nodeList.size()); - mapIds.resize(nodeList.size()); - - for(size_t i = 0; i < nodeList.size(); ++i) - { - pathnodes[ i ].x = nodeList[i].x; - pathnodes[ i ].y = nodeList[i].y; - pathnodes[ i ].z = nodeList[i].z; - - mapIds[i] = nodeList[i].mapid; - } -} - -void ObjectMgr::GetTransportPathNodes( uint32 path, TransportPath &pathnodes ) -{ - if(path >= sTaxiPathNodesByPath.size()) - return; - - TaxiPathNodeList& nodeList = sTaxiPathNodesByPath[path]; - - pathnodes.Resize(nodeList.size()); - - for(size_t i = 0; i < nodeList.size(); ++i) - { - pathnodes[ i ].mapid = nodeList[i].mapid; - pathnodes[ i ].x = nodeList[i].x; - pathnodes[ i ].y = nodeList[i].y; - pathnodes[ i ].z = nodeList[i].z; - pathnodes[ i ].actionFlag = nodeList[i].actionFlag; - pathnodes[ i ].delay = nodeList[i].delay; - } -} - -void ObjectMgr::LoadGraveyardZones() -{ - mGraveYardMap.clear(); // need for reload case - - QueryResult *result = WorldDatabase.Query("SELECT id,ghost_zone,faction FROM game_graveyard_zone"); - - uint32 count = 0; - - if( !result ) - { - barGoLink bar( 1 ); - bar.step(); - - sLog.outString(); - sLog.outString( ">> Loaded %u graveyard-zone links", count ); - return; - } - - barGoLink bar( result->GetRowCount() ); - - do - { - ++count; - bar.step(); - - Field *fields = result->Fetch(); - - uint32 safeLocId = fields[0].GetUInt32(); - uint32 zoneId = fields[1].GetUInt32(); - uint32 team = fields[2].GetUInt32(); - - WorldSafeLocsEntry const* entry = sWorldSafeLocsStore.LookupEntry(safeLocId); - if(!entry) - { - sLog.outErrorDb("Table `game_graveyard_zone` has record for not existing graveyard (WorldSafeLocs.dbc id) %u, skipped.",safeLocId); - continue; - } - - AreaTableEntry const *areaEntry = GetAreaEntryByAreaID(zoneId); - if(!areaEntry) - { - sLog.outErrorDb("Table `game_graveyard_zone` has record for not existing zone id (%u), skipped.",zoneId); - continue; - } - - if(areaEntry->zone != 0) - { - sLog.outErrorDb("Table `game_graveyard_zone` has record subzone id (%u) instead of zone, skipped.",zoneId); - continue; - } - - if(team!=0 && team!=HORDE && team!=ALLIANCE) - { - sLog.outErrorDb("Table `game_graveyard_zone` has record for non player faction (%u), skipped.",team); - continue; - } - - if(entry->map_id != areaEntry->mapid && team != 0) - { - sLog.outErrorDb("Table `game_graveyard_zone` has record for ghost zone (%u) at map %u and graveyard (%u) at map %u for team %u, but in case maps are different, player faction setting is ignored. Use faction 0 instead.",zoneId,areaEntry->mapid, safeLocId, entry->map_id, team); - team = 0; - } - - if(!AddGraveYardLink(safeLocId,zoneId,team,false)) - sLog.outErrorDb("Table `game_graveyard_zone` has a duplicate record for Garveyard (ID: %u) and Zone (ID: %u), skipped.",safeLocId,zoneId); - } while( result->NextRow() ); - - delete result; - - sLog.outString(); - sLog.outString( ">> Loaded %u graveyard-zone links", count ); -} - -WorldSafeLocsEntry const *ObjectMgr::GetClosestGraveYard(float x, float y, float z, uint32 MapId, uint32 team) -{ - // search for zone associated closest graveyard - uint32 zoneId = MapManager::Instance().GetZoneId(MapId,x,y); - - // Simulate std. algorithm: - // found some graveyard associated to (ghost_zone,ghost_map) - // - // if mapId == graveyard.mapId (ghost in plain zone or city or battleground) and search graveyard at same map - // then check faction - // if mapId != graveyard.mapId (ghost in instance) and search any graveyard associated - // then skip check faction - GraveYardMap::const_iterator graveLow = mGraveYardMap.lower_bound(zoneId); - GraveYardMap::const_iterator graveUp = mGraveYardMap.upper_bound(zoneId); - if(graveLow==graveUp) - { - sLog.outErrorDb("Table `game_graveyard_zone` incomplete: Zone %u Team %u does not have a linked graveyard.",zoneId,team); - return NULL; - } - - bool foundNear = false; - float distNear; - WorldSafeLocsEntry const* entryNear = NULL; - WorldSafeLocsEntry const* entryFar = NULL; - - for(GraveYardMap::const_iterator itr = graveLow; itr != graveUp; ++itr) - { - GraveYardData const& data = itr->second; - - WorldSafeLocsEntry const* entry = sWorldSafeLocsStore.LookupEntry(data.safeLocId); - if(!entry) - { - sLog.outErrorDb("Table `game_graveyard_zone` has record for not existing graveyard (WorldSafeLocs.dbc id) %u, skipped.",data.safeLocId); - continue; - } - - // remember first graveyard at another map and ignore other - if(MapId != entry->map_id) - { - if(!entryFar) - entryFar = entry; - continue; - } - - // skip enemy faction graveyard at same map (normal area, city, or battleground) - // team == 0 case can be at call from .neargrave - if(data.team != 0 && team != 0 && data.team != team) - continue; - - // find now nearest graveyard at same map - float dist2 = (entry->x - x)*(entry->x - x)+(entry->y - y)*(entry->y - y)+(entry->z - z)*(entry->z - z); - if(foundNear) - { - if(dist2 < distNear) - { - distNear = dist2; - entryNear = entry; - } - } - else - { - foundNear = true; - distNear = dist2; - entryNear = entry; - } - } - - if(entryNear) - return entryNear; - - return entryFar; -} - -GraveYardData const* ObjectMgr::FindGraveYardData(uint32 id, uint32 zoneId) -{ - GraveYardMap::const_iterator graveLow = mGraveYardMap.lower_bound(zoneId); - GraveYardMap::const_iterator graveUp = mGraveYardMap.upper_bound(zoneId); - - for(GraveYardMap::const_iterator itr = graveLow; itr != graveUp; ++itr) - { - if(itr->second.safeLocId==id) - return &itr->second; - } - - return NULL; -} - -bool ObjectMgr::AddGraveYardLink(uint32 id, uint32 zoneId, uint32 team, bool inDB) -{ - if(FindGraveYardData(id,zoneId)) - return false; - - // add link to loaded data - GraveYardData data; - data.safeLocId = id; - data.team = team; - - mGraveYardMap.insert(GraveYardMap::value_type(zoneId,data)); - - // add link to DB - if(inDB) - { - WorldDatabase.PExecuteLog("INSERT INTO game_graveyard_zone ( id,ghost_zone,faction) " - "VALUES ('%u', '%u','%u')",id,zoneId,team); - } - - return true; -} - -void ObjectMgr::LoadAreaTriggerTeleports() -{ - mAreaTriggers.clear(); // need for reload case - - uint32 count = 0; - - // 0 1 2 3 4 5 6 7 8 9 10 11 12 - QueryResult *result = WorldDatabase.Query("SELECT id, required_level, required_item, required_item2, heroic_key, heroic_key2, required_quest_done, required_failed_text, target_map, target_position_x, target_position_y, target_position_z, target_orientation FROM areatrigger_teleport"); - if( !result ) - { - - barGoLink bar( 1 ); - - bar.step(); - - sLog.outString(); - sLog.outString( ">> Loaded %u area trigger teleport definitions", count ); - return; - } - - barGoLink bar( result->GetRowCount() ); - - do - { - Field *fields = result->Fetch(); - - bar.step(); - - ++count; - - uint32 Trigger_ID = fields[0].GetUInt32(); - - AreaTrigger at; - - at.requiredLevel = fields[1].GetUInt8(); - at.requiredItem = fields[2].GetUInt32(); - at.requiredItem2 = fields[3].GetUInt32(); - at.heroicKey = fields[4].GetUInt32(); - at.heroicKey2 = fields[5].GetUInt32(); - at.requiredQuest = fields[6].GetUInt32(); - at.requiredFailedText = fields[7].GetCppString(); - at.target_mapId = fields[8].GetUInt32(); - at.target_X = fields[9].GetFloat(); - at.target_Y = fields[10].GetFloat(); - at.target_Z = fields[11].GetFloat(); - at.target_Orientation = fields[12].GetFloat(); - - AreaTriggerEntry const* atEntry = sAreaTriggerStore.LookupEntry(Trigger_ID); - if(!atEntry) - { - sLog.outErrorDb("Area trigger (ID:%u) does not exist in `AreaTrigger.dbc`.",Trigger_ID); - continue; - } - - if(at.requiredItem) - { - ItemPrototype const *pProto = objmgr.GetItemPrototype(at.requiredItem); - if(!pProto) - { - sLog.outError("Key item %u does not exist for trigger %u, removing key requirement.", at.requiredItem, Trigger_ID); - at.requiredItem = 0; - } - } - if(at.requiredItem2) - { - ItemPrototype const *pProto = objmgr.GetItemPrototype(at.requiredItem2); - if(!pProto) - { - sLog.outError("Second item %u not exist for trigger %u, remove key requirement.", at.requiredItem2, Trigger_ID); - at.requiredItem2 = 0; - } - } - - if(at.heroicKey) - { - ItemPrototype const *pProto = objmgr.GetItemPrototype(at.heroicKey); - if(!pProto) - { - sLog.outError("Heroic key item %u not exist for trigger %u, remove key requirement.", at.heroicKey, Trigger_ID); - at.heroicKey = 0; - } - } - - if(at.heroicKey2) - { - ItemPrototype const *pProto = objmgr.GetItemPrototype(at.heroicKey2); - if(!pProto) - { - sLog.outError("Heroic second key item %u not exist for trigger %u, remove key requirement.", at.heroicKey2, Trigger_ID); - at.heroicKey2 = 0; - } - } - - if(at.requiredQuest) - { - if(!mQuestTemplates[at.requiredQuest]) - { - sLog.outErrorDb("Required Quest %u not exist for trigger %u, remove quest done requirement.",at.requiredQuest,Trigger_ID); - at.requiredQuest = 0; - } - } - - MapEntry const* mapEntry = sMapStore.LookupEntry(at.target_mapId); - if(!mapEntry) - { - sLog.outErrorDb("Area trigger (ID:%u) target map (ID: %u) does not exist in `Map.dbc`.",Trigger_ID,at.target_mapId); - continue; - } - - if(at.target_X==0 && at.target_Y==0 && at.target_Z==0) - { - sLog.outErrorDb("Area trigger (ID:%u) target coordinates not provided.",Trigger_ID); - continue; - } - - mAreaTriggers[Trigger_ID] = at; - - } while( result->NextRow() ); - - delete result; - - sLog.outString(); - sLog.outString( ">> Loaded %u area trigger teleport definitions", count ); -} - -AreaTrigger const* ObjectMgr::GetGoBackTrigger(uint32 Map) const -{ - const MapEntry *mapEntry = sMapStore.LookupEntry(Map); - if(!mapEntry) return NULL; - for (AreaTriggerMap::const_iterator itr = mAreaTriggers.begin(); itr != mAreaTriggers.end(); itr++) - { - if(itr->second.target_mapId == mapEntry->parent_map) - { - AreaTriggerEntry const* atEntry = sAreaTriggerStore.LookupEntry(itr->first); - if(atEntry && atEntry->mapid == Map) - return &itr->second; - } - } - return NULL; -} - -void ObjectMgr::SetHighestGuids() -{ - QueryResult *result = CharacterDatabase.Query( "SELECT MAX(guid) FROM characters" ); - if( result ) - { - m_hiCharGuid = (*result)[0].GetUInt32()+1; - - delete result; - } - - result = WorldDatabase.Query( "SELECT MAX(guid) FROM creature" ); - if( result ) - { - m_hiCreatureGuid = (*result)[0].GetUInt32()+1; - - delete result; - } - - result = CharacterDatabase.Query( "SELECT MAX(id) FROM character_pet" ); - if( result ) - { - m_hiPetGuid = (*result)[0].GetUInt32()+1; - - delete result; - } - - result = CharacterDatabase.Query( "SELECT MAX(guid) FROM item_instance" ); - if( result ) - { - m_hiItemGuid = (*result)[0].GetUInt32()+1; - - delete result; - } - - // Cleanup other tables from not existed guids (>=m_hiItemGuid) - CharacterDatabase.PExecute("DELETE FROM character_inventory WHERE item >= '%u'", m_hiItemGuid); - CharacterDatabase.PExecute("DELETE FROM mail_items WHERE item_guid >= '%u'", m_hiItemGuid); - CharacterDatabase.PExecute("DELETE FROM auctionhouse WHERE itemguid >= '%u'", m_hiItemGuid); - CharacterDatabase.PExecute("DELETE FROM guild_bank_item WHERE item_guid >= '%u'", m_hiItemGuid); - - result = WorldDatabase.Query("SELECT MAX(guid) FROM gameobject" ); - if( result ) - { - m_hiGoGuid = (*result)[0].GetUInt32()+1; - - delete result; - } - - result = CharacterDatabase.Query("SELECT MAX(id) FROM auctionhouse" ); - if( result ) - { - m_auctionid = (*result)[0].GetUInt32()+1; - - delete result; - } - else - { - m_auctionid = 0; - } - result = CharacterDatabase.Query( "SELECT MAX(id) FROM mail" ); - if( result ) - { - m_mailid = (*result)[0].GetUInt32()+1; - - delete result; - } - else - { - m_mailid = 0; - } - result = CharacterDatabase.Query( "SELECT MAX(id) FROM item_text" ); - if( result ) - { - m_ItemTextId = (*result)[0].GetUInt32(); - - delete result; - } - else - m_ItemTextId = 0; - - result = CharacterDatabase.Query( "SELECT MAX(guid) FROM corpse" ); - if( result ) - { - m_hiCorpseGuid = (*result)[0].GetUInt32()+1; - - delete result; - } -} - -uint32 ObjectMgr::GenerateAuctionID() -{ - ++m_auctionid; - if(m_auctionid>=0xFFFFFFFF) - { - sLog.outError("Auctions ids overflow!! Can't continue, shuting down server. "); - sWorld.m_stopEvent = true; - } - return m_auctionid; -} - -uint32 ObjectMgr::GenerateMailID() -{ - ++m_mailid; - if(m_mailid>=0xFFFFFFFF) - { - sLog.outError("Mail ids overflow!! Can't continue, shuting down server. "); - sWorld.m_stopEvent = true; - } - return m_mailid; -} - -uint32 ObjectMgr::GenerateItemTextID() -{ - ++m_ItemTextId; - if(m_ItemTextId>=0xFFFFFFFF) - { - sLog.outError("Item text ids overflow!! Can't continue, shuting down server. "); - sWorld.m_stopEvent = true; - } - return m_ItemTextId; -} - -uint32 ObjectMgr::CreateItemText(std::string text) -{ - uint32 newItemTextId = GenerateItemTextID(); - //insert new itempage to container - mItemTexts[ newItemTextId ] = text; - //save new itempage - CharacterDatabase.escape_string(text); - //any Delete query needed, itemTextId is maximum of all ids - std::ostringstream query; - query << "INSERT INTO item_text (id,text) VALUES ( '" << newItemTextId << "', '" << text << "')"; - CharacterDatabase.Execute(query.str().c_str()); //needs to be run this way, because mail body may be more than 1024 characters - return newItemTextId; -} - -uint32 ObjectMgr::GenerateLowGuid(HighGuid guidhigh) -{ - switch(guidhigh) - { - case HIGHGUID_ITEM: - ++m_hiItemGuid; - if(m_hiItemGuid>=0xFFFFFFFF) - { - sLog.outError("Item guid overflow!! Can't continue, shuting down server. "); - sWorld.m_stopEvent = true; - } - return m_hiItemGuid; - case HIGHGUID_UNIT: - ++m_hiCreatureGuid; - if(m_hiCreatureGuid>=0x00FFFFFF) - { - sLog.outError("Creature guid overflow!! Can't continue, shuting down server. "); - sWorld.m_stopEvent = true; - } - return m_hiCreatureGuid; - case HIGHGUID_PET: - ++m_hiPetGuid; - if(m_hiPetGuid>=0x00FFFFFF) - { - sLog.outError("Pet guid overflow!! Can't continue, shuting down server. "); - sWorld.m_stopEvent = true; - } - return m_hiPetGuid; - case HIGHGUID_PLAYER: - ++m_hiCharGuid; - if(m_hiCharGuid>=0xFFFFFFFF) - { - sLog.outError("Players guid overflow!! Can't continue, shuting down server. "); - sWorld.m_stopEvent = true; - } - return m_hiCharGuid; - case HIGHGUID_GAMEOBJECT: - ++m_hiGoGuid; - if(m_hiGoGuid>=0x00FFFFFF) - { - sLog.outError("Gameobject guid overflow!! Can't continue, shuting down server. "); - sWorld.m_stopEvent = true; - } - return m_hiGoGuid; - case HIGHGUID_CORPSE: - ++m_hiCorpseGuid; - if(m_hiCorpseGuid>=0xFFFFFFFF) - { - sLog.outError("Corpse guid overflow!! Can't continue, shuting down server. "); - sWorld.m_stopEvent = true; - } - return m_hiCorpseGuid; - case HIGHGUID_DYNAMICOBJECT: - ++m_hiDoGuid; - if(m_hiDoGuid>=0xFFFFFFFF) - { - sLog.outError("DynamicObject guid overflow!! Can't continue, shuting down server. "); - sWorld.m_stopEvent = true; - } - return m_hiDoGuid; - default: - ASSERT(0); - } - - ASSERT(0); - return 0; -} - -void ObjectMgr::LoadGameObjectLocales() -{ - QueryResult *result = WorldDatabase.Query("SELECT entry," - "name_loc1,name_loc2,name_loc3,name_loc4,name_loc5,name_loc6,name_loc7,name_loc8," - "castbarcaption_loc1,castbarcaption_loc2,castbarcaption_loc3,castbarcaption_loc4," - "castbarcaption_loc5,castbarcaption_loc6,castbarcaption_loc7,castbarcaption_loc8 FROM locales_gameobject"); - - if(!result) - { - barGoLink bar(1); - - bar.step(); - - sLog.outString(""); - sLog.outString(">> Loaded 0 gameobject locale strings. DB table `locales_gameobject` is empty."); - return; - } - - barGoLink bar(result->GetRowCount()); - - do - { - Field *fields = result->Fetch(); - bar.step(); - - uint32 entry = fields[0].GetUInt32(); - - GameObjectLocale& data = mGameObjectLocaleMap[entry]; - - for(int i = 1; i < MAX_LOCALE; ++i) - { - std::string str = fields[i].GetCppString(); - if(!str.empty()) - { - int idx = GetOrNewIndexForLocale(LocaleConstant(i)); - if(idx >= 0) - { - if(data.Name.size() <= idx) - data.Name.resize(idx+1); - - data.Name[idx] = str; - } - } - } - - for(int i = MAX_LOCALE; i < MAX_LOCALE*2-1; ++i) - { - std::string str = fields[i].GetCppString(); - if(!str.empty()) - { - int idx = GetOrNewIndexForLocale(LocaleConstant(i)); - if(idx >= 0) - { - if(data.CastBarCaption.size() <= idx) - data.CastBarCaption.resize(idx+1); - - data.CastBarCaption[idx] = str; - } - } - } - - } while (result->NextRow()); - - delete result; - - sLog.outString(); - sLog.outString( ">> Loaded %u gameobject locale strings", mGameObjectLocaleMap.size() ); -} - -void ObjectMgr::LoadGameobjectInfo() -{ - sGOStorage.Load(); - - // some checks - for(uint32 id = 1; id < sGOStorage.MaxEntry; id++) - { - GameObjectInfo const* goInfo = sGOStorage.LookupEntry(id); - if(!goInfo) - continue; - - switch(goInfo->type) - { - case GAMEOBJECT_TYPE_DOOR: //0 - { - if(goInfo->door.lockId) - { - if(!sLockStore.LookupEntry(goInfo->door.lockId)) - sLog.outErrorDb("Gameobject (Entry: %u GoType: %u) have data1=%u but lock (Id: %u) not found.", - id,goInfo->type,goInfo->door.lockId,goInfo->door.lockId); - } - break; - } - case GAMEOBJECT_TYPE_BUTTON: //1 - { - if(goInfo->button.lockId) - { - if(!sLockStore.LookupEntry(goInfo->button.lockId)) - sLog.outErrorDb("Gameobject (Entry: %u GoType: %u) have data1=%u but lock (Id: %u) not found.", - id,goInfo->type,goInfo->button.lockId,goInfo->button.lockId); - } - break; - } - case GAMEOBJECT_TYPE_CHEST: //3 - { - if(goInfo->chest.lockId) - { - if(!sLockStore.LookupEntry(goInfo->chest.lockId)) - sLog.outErrorDb("Gameobject (Entry: %u GoType: %u) have data0=%u but lock (Id: %u) not found.", - id,goInfo->type,goInfo->chest.lockId,goInfo->chest.lockId); - } - if(goInfo->chest.linkedTrapId) // linked trap - { - if(GameObjectInfo const* trapInfo = sGOStorage.LookupEntry(goInfo->chest.linkedTrapId)) - { - if(trapInfo->type!=GAMEOBJECT_TYPE_TRAP) - sLog.outErrorDb("Gameobject (Entry: %u GoType: %u) have data7=%u but GO (Entry %u) have not GAMEOBJECT_TYPE_TRAP (%u) type.", - id,goInfo->type,goInfo->chest.linkedTrapId,goInfo->chest.linkedTrapId,GAMEOBJECT_TYPE_TRAP); - } - /* disable check for while - else - sLog.outErrorDb("Gameobject (Entry: %u GoType: %u) have data2=%u but trap GO (Entry %u) not exist in `gameobject_template`.", - id,goInfo->type,goInfo->chest.linkedTrapId,goInfo->chest.linkedTrapId); - */ - } - break; - } - case GAMEOBJECT_TYPE_TRAP: //6 - { - /* disable check for while - if(goInfo->trap.spellId) // spell - { - if(!sSpellStore.LookupEntry(goInfo->trap.spellId)) - sLog.outErrorDb("Gameobject (Entry: %u GoType: %u) have data3=%u but Spell (Entry %u) not exist.", - id,goInfo->type,goInfo->trap.spellId,goInfo->trap.spellId); - } - */ - break; - } - case GAMEOBJECT_TYPE_CHAIR: //7 - if(goInfo->chair.height > 2) - { - sLog.outErrorDb("Gameobject (Entry: %u GoType: %u) have data1=%u but correct chair height in range 0..2.", - id,goInfo->type,goInfo->chair.height); - - // prevent client and server unexpected work - const_cast(goInfo)->chair.height = 0; - } - break; - case GAMEOBJECT_TYPE_SPELL_FOCUS: //8 - { - if(goInfo->spellFocus.focusId) - { - if(!sSpellFocusObjectStore.LookupEntry(goInfo->spellFocus.focusId)) - sLog.outErrorDb("Gameobject (Entry: %u GoType: %u) have data0=%u but SpellFocus (Id: %u) not exist.", - id,goInfo->type,goInfo->spellFocus.focusId,goInfo->spellFocus.focusId); - } - - if(goInfo->spellFocus.linkedTrapId) // linked trap - { - if(GameObjectInfo const* trapInfo = sGOStorage.LookupEntry(goInfo->spellFocus.linkedTrapId)) - { - if(trapInfo->type!=GAMEOBJECT_TYPE_TRAP) - sLog.outErrorDb("Gameobject (Entry: %u GoType: %u) have data2=%u but GO (Entry %u) have not GAMEOBJECT_TYPE_TRAP (%u) type.", - id,goInfo->type,goInfo->spellFocus.linkedTrapId,goInfo->spellFocus.linkedTrapId,GAMEOBJECT_TYPE_TRAP); - } - /* disable check for while - else - sLog.outErrorDb("Gameobject (Entry: %u GoType: %u) have data2=%u but trap GO (Entry %u) not exist in `gameobject_template`.", - id,goInfo->type,goInfo->spellFocus.linkedTrapId,goInfo->spellFocus.linkedTrapId); - */ - } - break; - } - case GAMEOBJECT_TYPE_GOOBER: //10 - { - if(goInfo->goober.pageId) // pageId - { - if(!sPageTextStore.LookupEntry(goInfo->goober.pageId)) - sLog.outErrorDb("Gameobject (Entry: %u GoType: %u) have data7=%u but PageText (Entry %u) not exist.", - id,goInfo->type,goInfo->goober.pageId,goInfo->goober.pageId); - } - /* disable check for while - if(goInfo->goober.spellId) // spell - { - if(!sSpellStore.LookupEntry(goInfo->goober.spellId)) - sLog.outErrorDb("Gameobject (Entry: %u GoType: %u) have data2=%u but Spell (Entry %u) not exist.", - id,goInfo->type,goInfo->goober.spellId,goInfo->goober.spellId); - } - */ - if(goInfo->goober.linkedTrapId) // linked trap - { - if(GameObjectInfo const* trapInfo = sGOStorage.LookupEntry(goInfo->goober.linkedTrapId)) - { - if(trapInfo->type!=GAMEOBJECT_TYPE_TRAP) - sLog.outErrorDb("Gameobject (Entry: %u GoType: %u) have data12=%u but GO (Entry %u) have not GAMEOBJECT_TYPE_TRAP (%u) type.", - id,goInfo->type,goInfo->goober.linkedTrapId,goInfo->goober.linkedTrapId,GAMEOBJECT_TYPE_TRAP); - } - /* disable check for while - else - sLog.outErrorDb("Gameobject (Entry: %u GoType: %u) have data12=%u but trap GO (Entry %u) not exist in `gameobject_template`.", - id,goInfo->type,goInfo->goober.linkedTrapId,goInfo->goober.linkedTrapId); - */ - } - break; - } - case GAMEOBJECT_TYPE_MO_TRANSPORT: //15 - { - if(goInfo->moTransport.taxiPathId) - { - if(goInfo->moTransport.taxiPathId >= sTaxiPathNodesByPath.size() || sTaxiPathNodesByPath[goInfo->moTransport.taxiPathId].empty()) - sLog.outErrorDb("Gameobject (Entry: %u GoType: %u) have data0=%u but TaxiPath (Id: %u) not exist.", - id,goInfo->type,goInfo->moTransport.taxiPathId,goInfo->moTransport.taxiPathId); - } - break; - } - case GAMEOBJECT_TYPE_SUMMONING_RITUAL: //18 - { - /* disabled - if(goInfo->summoningRitual.spellId) - { - if(!sSpellStore.LookupEntry(goInfo->summoningRitual.spellId)) - sLog.outErrorDb("Gameobject (Entry: %u GoType: %u) have data1=%u but Spell (Entry %u) not exist.", - id,goInfo->type,goInfo->summoningRitual.spellId,goInfo->summoningRitual.spellId); - } - */ - break; - } - case GAMEOBJECT_TYPE_SPELLCASTER: //22 - { - if(goInfo->spellcaster.spellId) // spell - { - if(!sSpellStore.LookupEntry(goInfo->spellcaster.spellId)) - sLog.outErrorDb("Gameobject (Entry: %u GoType: %u) have data3=%u but Spell (Entry %u) not exist.", - id,goInfo->type,goInfo->spellcaster.spellId,goInfo->spellcaster.spellId); - } - break; - } - } - } - - sLog.outString( ">> Loaded %u game object templates", sGOStorage.RecordCount ); - sLog.outString(); -} - -void ObjectMgr::LoadExplorationBaseXP() -{ - uint32 count = 0; - QueryResult *result = WorldDatabase.Query("SELECT level,basexp FROM exploration_basexp"); - - if( !result ) - { - barGoLink bar( 1 ); - - bar.step(); - - sLog.outString(); - sLog.outString( ">> Loaded %u BaseXP definitions", count ); - return; - } - - barGoLink bar( result->GetRowCount() ); - - do - { - bar.step(); - - Field *fields = result->Fetch(); - uint32 level = fields[0].GetUInt32(); - uint32 basexp = fields[1].GetUInt32(); - mBaseXPTable[level] = basexp; - ++count; - } - while (result->NextRow()); - - delete result; - - sLog.outString(); - sLog.outString( ">> Loaded %u BaseXP definitions", count ); -} - -uint32 ObjectMgr::GetBaseXP(uint32 level) -{ - return mBaseXPTable[level] ? mBaseXPTable[level] : 0; -} - -void ObjectMgr::LoadPetNames() -{ - uint32 count = 0; - QueryResult *result = WorldDatabase.Query("SELECT word,entry,half FROM pet_name_generation"); - - if( !result ) - { - barGoLink bar( 1 ); - - bar.step(); - - sLog.outString(); - sLog.outString( ">> Loaded %u pet name parts", count ); - return; - } - - barGoLink bar( result->GetRowCount() ); - - do - { - bar.step(); - - Field *fields = result->Fetch(); - std::string word = fields[0].GetString(); - uint32 entry = fields[1].GetUInt32(); - bool half = fields[2].GetBool(); - if(half) - PetHalfName1[entry].push_back(word); - else - PetHalfName0[entry].push_back(word); - ++count; - } - while (result->NextRow()); - delete result; - - sLog.outString(); - sLog.outString( ">> Loaded %u pet name parts", count ); -} - -void ObjectMgr::LoadPetNumber() -{ - QueryResult* result = CharacterDatabase.Query("SELECT MAX(id) FROM character_pet"); - if(result) - { - Field *fields = result->Fetch(); - m_hiPetNumber = fields[0].GetUInt32()+1; - delete result; - } - - barGoLink bar( 1 ); - bar.step(); - - sLog.outString(); - sLog.outString( ">> Loaded the max pet number: %d", m_hiPetNumber-1); -} - -std::string ObjectMgr::GeneratePetName(uint32 entry) -{ - std::vector & list0 = PetHalfName0[entry]; - std::vector & list1 = PetHalfName1[entry]; - - if(list0.empty() || list1.empty()) - { - CreatureInfo const *cinfo = objmgr.GetCreatureTemplate(entry); - char* petname = GetPetName(cinfo->family, sWorld.GetDefaultDbcLocale()); - if(!petname) - petname = cinfo->Name; - return std::string(petname); - } - - return *(list0.begin()+urand(0, list0.size()-1)) + *(list1.begin()+urand(0, list1.size()-1)); -} - -uint32 ObjectMgr::GeneratePetNumber() -{ - return ++m_hiPetNumber; -} - -void ObjectMgr::LoadCorpses() -{ - uint32 count = 0; - // 0 1 2 3 4 5 6 7 8 10 - QueryResult *result = CharacterDatabase.PQuery("SELECT position_x, position_y, position_z, orientation, map, data, time, corpse_type, instance, guid FROM corpse WHERE corpse_type <> 0"); - - if( !result ) - { - barGoLink bar( 1 ); - - bar.step(); - - sLog.outString(); - sLog.outString( ">> Loaded %u corpses", count ); - return; - } - - barGoLink bar( result->GetRowCount() ); - - do - { - bar.step(); - - Field *fields = result->Fetch(); - - uint32 guid = fields[result->GetFieldCount()-1].GetUInt32(); - - Corpse *corpse = new Corpse; - if(!corpse->LoadFromDB(guid,fields)) - { - delete corpse; - continue; - } - - ObjectAccessor::Instance().AddCorpse(corpse); - - ++count; - } - while (result->NextRow()); - delete result; - - sLog.outString(); - sLog.outString( ">> Loaded %u corpses", count ); -} - -void ObjectMgr::LoadReputationOnKill() -{ - uint32 count = 0; - - // 0 1 2 - QueryResult *result = WorldDatabase.Query("SELECT creature_id, RewOnKillRepFaction1, RewOnKillRepFaction2," - // 3 4 5 6 7 8 9 - "IsTeamAward1, MaxStanding1, RewOnKillRepValue1, IsTeamAward2, MaxStanding2, RewOnKillRepValue2, TeamDependent " - "FROM creature_onkill_reputation"); - - if(!result) - { - barGoLink bar(1); - - bar.step(); - - sLog.outString(); - sLog.outErrorDb(">> Loaded 0 creature award reputation definitions. DB table `creature_onkill_reputation` is empty."); - return; - } - - barGoLink bar(result->GetRowCount()); - - do - { - Field *fields = result->Fetch(); - bar.step(); - - uint32 creature_id = fields[0].GetUInt32(); - - ReputationOnKillEntry repOnKill; - repOnKill.repfaction1 = fields[1].GetUInt32(); - repOnKill.repfaction2 = fields[2].GetUInt32(); - repOnKill.is_teamaward1 = fields[3].GetBool(); - repOnKill.reputration_max_cap1 = fields[4].GetUInt32(); - repOnKill.repvalue1 = fields[5].GetInt32(); - repOnKill.is_teamaward2 = fields[6].GetBool(); - repOnKill.reputration_max_cap2 = fields[7].GetUInt32(); - repOnKill.repvalue2 = fields[8].GetInt32(); - repOnKill.team_dependent = fields[9].GetUInt8(); - - if(!GetCreatureTemplate(creature_id)) - { - sLog.outErrorDb("Table `creature_onkill_reputation` have data for not existed creature entry (%u), skipped",creature_id); - continue; - } - - if(repOnKill.repfaction1) - { - FactionEntry const *factionEntry1 = sFactionStore.LookupEntry(repOnKill.repfaction1); - if(!factionEntry1) - { - sLog.outErrorDb("Faction (faction.dbc) %u does not exist but is used in `creature_onkill_reputation`",repOnKill.repfaction1); - continue; - } - } - - if(repOnKill.repfaction2) - { - FactionEntry const *factionEntry2 = sFactionStore.LookupEntry(repOnKill.repfaction2); - if(!factionEntry2) - { - sLog.outErrorDb("Faction (faction.dbc) %u does not exist but is used in `creature_onkill_reputation`",repOnKill.repfaction2); - continue; - } - } - - mRepOnKill[creature_id] = repOnKill; - - ++count; - } while (result->NextRow()); - - delete result; - - sLog.outString(); - sLog.outString(">> Loaded %u creature award reputation definitions", count); -} - -void ObjectMgr::LoadWeatherZoneChances() -{ - uint32 count = 0; - - // 0 1 2 3 4 5 6 7 8 9 10 11 12 - QueryResult *result = WorldDatabase.Query("SELECT zone, spring_rain_chance, spring_snow_chance, spring_storm_chance, summer_rain_chance, summer_snow_chance, summer_storm_chance, fall_rain_chance, fall_snow_chance, fall_storm_chance, winter_rain_chance, winter_snow_chance, winter_storm_chance FROM game_weather"); - - if(!result) - { - barGoLink bar(1); - - bar.step(); - - sLog.outString(); - sLog.outErrorDb(">> Loaded 0 weather definitions. DB table `game_weather` is empty."); - return; - } - - barGoLink bar(result->GetRowCount()); - - do - { - Field *fields = result->Fetch(); - bar.step(); - - uint32 zone_id = fields[0].GetUInt32(); - - WeatherZoneChances& wzc = mWeatherZoneMap[zone_id]; - - for(int season = 0; season < WEATHER_SEASONS; ++season) - { - wzc.data[season].rainChance = fields[season * (MAX_WEATHER_TYPE-1) + 1].GetUInt32(); - wzc.data[season].snowChance = fields[season * (MAX_WEATHER_TYPE-1) + 2].GetUInt32(); - wzc.data[season].stormChance = fields[season * (MAX_WEATHER_TYPE-1) + 3].GetUInt32(); - - if(wzc.data[season].rainChance > 100) - { - wzc.data[season].rainChance = 25; - sLog.outErrorDb("Weather for zone %u season %u has wrong rain chance > 100%",zone_id,season); - } - - if(wzc.data[season].snowChance > 100) - { - wzc.data[season].snowChance = 25; - sLog.outErrorDb("Weather for zone %u season %u has wrong snow chance > 100%",zone_id,season); - } - - if(wzc.data[season].stormChance > 100) - { - wzc.data[season].stormChance = 25; - sLog.outErrorDb("Weather for zone %u season %u has wrong storm chance > 100%",zone_id,season); - } - } - - ++count; - } while (result->NextRow()); - - delete result; - - sLog.outString(); - sLog.outString(">> Loaded %u weather definitions", count); -} - -void ObjectMgr::SaveCreatureRespawnTime(uint32 loguid, uint32 instance, time_t t) -{ - mCreatureRespawnTimes[MAKE_PAIR64(loguid,instance)] = t; - WorldDatabase.PExecute("DELETE FROM creature_respawn WHERE guid = '%u' AND instance = '%u'", loguid, instance); - if(t) - WorldDatabase.PExecute("INSERT INTO creature_respawn VALUES ( '%u', '" I64FMTD "', '%u' )", loguid, uint64(t), instance); -} - -void ObjectMgr::DeleteCreatureData(uint32 guid) -{ - // remove mapid*cellid -> guid_set map - CreatureData const* data = GetCreatureData(guid); - if(data) - RemoveCreatureFromGrid(guid, data); - - mCreatureDataMap.erase(guid); -} - -void ObjectMgr::SaveGORespawnTime(uint32 loguid, uint32 instance, time_t t) -{ - mGORespawnTimes[MAKE_PAIR64(loguid,instance)] = t; - WorldDatabase.PExecute("DELETE FROM gameobject_respawn WHERE guid = '%u' AND instance = '%u'", loguid, instance); - if(t) - WorldDatabase.PExecute("INSERT INTO gameobject_respawn VALUES ( '%u', '" I64FMTD "', '%u' )", loguid, uint64(t), instance); -} - -void ObjectMgr::DeleteRespawnTimeForInstance(uint32 instance) -{ - RespawnTimes::iterator next; - - for(RespawnTimes::iterator itr = mGORespawnTimes.begin(); itr != mGORespawnTimes.end(); itr = next) - { - next = itr; - ++next; - - if(GUID_HIPART(itr->first)==instance) - mGORespawnTimes.erase(itr); - } - - for(RespawnTimes::iterator itr = mCreatureRespawnTimes.begin(); itr != mCreatureRespawnTimes.end(); itr = next) - { - next = itr; - ++next; - - if(GUID_HIPART(itr->first)==instance) - mCreatureRespawnTimes.erase(itr); - } - - WorldDatabase.PExecute("DELETE FROM creature_respawn WHERE instance = '%u'", instance); - WorldDatabase.PExecute("DELETE FROM gameobject_respawn WHERE instance = '%u'", instance); -} - -void ObjectMgr::DeleteGOData(uint32 guid) -{ - // remove mapid*cellid -> guid_set map - GameObjectData const* data = GetGOData(guid); - if(data) - RemoveGameobjectFromGrid(guid, data); - - mGameObjectDataMap.erase(guid); -} - -void ObjectMgr::AddCorpseCellData(uint32 mapid, uint32 cellid, uint32 player_guid, uint32 instance) -{ - // corpses are always added to spawn mode 0 and they are spawned by their instance id - CellObjectGuids& cell_guids = mMapObjectGuids[MAKE_PAIR32(mapid,0)][cellid]; - cell_guids.corpses[player_guid] = instance; -} - -void ObjectMgr::DeleteCorpseCellData(uint32 mapid, uint32 cellid, uint32 player_guid) -{ - // corpses are always added to spawn mode 0 and they are spawned by their instance id - CellObjectGuids& cell_guids = mMapObjectGuids[MAKE_PAIR32(mapid,0)][cellid]; - cell_guids.corpses.erase(player_guid); -} - -void ObjectMgr::LoadQuestRelationsHelper(QuestRelations& map,char const* table) -{ - map.clear(); // need for reload case - - uint32 count = 0; - - QueryResult *result = WorldDatabase.PQuery("SELECT id,quest FROM %s",table); - - if(!result) - { - barGoLink bar(1); - - bar.step(); - - sLog.outString(); - sLog.outErrorDb(">> Loaded 0 quest relations from %s. DB table `%s` is empty.",table,table); - return; - } - - barGoLink bar(result->GetRowCount()); - - do - { - Field *fields = result->Fetch(); - bar.step(); - - uint32 id = fields[0].GetUInt32(); - uint32 quest = fields[1].GetUInt32(); - - if(mQuestTemplates.find(quest) == mQuestTemplates.end()) - { - sLog.outErrorDb("Table `%s: Quest %u listed for entry %u does not exist.",table,quest,id); - continue; - } - - map.insert(QuestRelations::value_type(id,quest)); - - ++count; - } while (result->NextRow()); - - delete result; - - sLog.outString(); - sLog.outString(">> Loaded %u quest relations from %s", count,table); -} - -void ObjectMgr::LoadGameobjectQuestRelations() -{ - LoadQuestRelationsHelper(mGOQuestRelations,"gameobject_questrelation"); - - for(QuestRelations::iterator itr = mGOQuestRelations.begin(); itr != mGOQuestRelations.end(); ++itr) - { - GameObjectInfo const* goInfo = GetGameObjectInfo(itr->first); - if(!goInfo) - sLog.outErrorDb("Table `gameobject_questrelation` have data for not existed gameobject entry (%u) and existed quest %u",itr->first,itr->second); - else if(goInfo->type != GAMEOBJECT_TYPE_QUESTGIVER) - sLog.outErrorDb("Table `gameobject_questrelation` have data gameobject entry (%u) for quest %u, but GO is not GAMEOBJECT_TYPE_QUESTGIVER",itr->first,itr->second); - } -} - -void ObjectMgr::LoadGameobjectInvolvedRelations() -{ - LoadQuestRelationsHelper(mGOQuestInvolvedRelations,"gameobject_involvedrelation"); - - for(QuestRelations::iterator itr = mGOQuestInvolvedRelations.begin(); itr != mGOQuestInvolvedRelations.end(); ++itr) - { - GameObjectInfo const* goInfo = GetGameObjectInfo(itr->first); - if(!goInfo) - sLog.outErrorDb("Table `gameobject_involvedrelation` have data for not existed gameobject entry (%u) and existed quest %u",itr->first,itr->second); - else if(goInfo->type != GAMEOBJECT_TYPE_QUESTGIVER) - sLog.outErrorDb("Table `gameobject_involvedrelation` have data gameobject entry (%u) for quest %u, but GO is not GAMEOBJECT_TYPE_QUESTGIVER",itr->first,itr->second); - } -} - -void ObjectMgr::LoadCreatureQuestRelations() -{ - LoadQuestRelationsHelper(mCreatureQuestRelations,"creature_questrelation"); - - for(QuestRelations::iterator itr = mCreatureQuestRelations.begin(); itr != mCreatureQuestRelations.end(); ++itr) - { - CreatureInfo const* cInfo = GetCreatureTemplate(itr->first); - if(!cInfo) - sLog.outErrorDb("Table `creature_questrelation` have data for not existed creature entry (%u) and existed quest %u",itr->first,itr->second); - else if(!(cInfo->npcflag & UNIT_NPC_FLAG_QUESTGIVER)) - sLog.outErrorDb("Table `creature_questrelation` has creature entry (%u) for quest %u, but npcflag does not include UNIT_NPC_FLAG_QUESTGIVER",itr->first,itr->second); - } -} - -void ObjectMgr::LoadCreatureInvolvedRelations() -{ - LoadQuestRelationsHelper(mCreatureQuestInvolvedRelations,"creature_involvedrelation"); - - for(QuestRelations::iterator itr = mCreatureQuestInvolvedRelations.begin(); itr != mCreatureQuestInvolvedRelations.end(); ++itr) - { - CreatureInfo const* cInfo = GetCreatureTemplate(itr->first); - if(!cInfo) - sLog.outErrorDb("Table `creature_involvedrelation` have data for not existed creature entry (%u) and existed quest %u",itr->first,itr->second); - else if(!(cInfo->npcflag & UNIT_NPC_FLAG_QUESTGIVER)) - sLog.outErrorDb("Table `creature_involvedrelation` has creature entry (%u) for quest %u, but npcflag does not include UNIT_NPC_FLAG_QUESTGIVER",itr->first,itr->second); - } -} - -void ObjectMgr::LoadReservedPlayersNames() -{ - m_ReservedNames.clear(); // need for reload case - - QueryResult *result = WorldDatabase.PQuery("SELECT name FROM reserved_name"); - - uint32 count = 0; - - if( !result ) - { - barGoLink bar( 1 ); - bar.step(); - - sLog.outString(); - sLog.outString( ">> Loaded %u reserved player names", count ); - return; - } - - barGoLink bar( result->GetRowCount() ); - - Field* fields; - do - { - bar.step(); - fields = result->Fetch(); - std::string name= fields[0].GetCppString(); - if(normalizePlayerName(name)) - { - m_ReservedNames.insert(name); - ++count; - } - } while ( result->NextRow() ); - - delete result; - - sLog.outString(); - sLog.outString( ">> Loaded %u reserved player names", count ); -} - -enum LanguageType -{ - LT_BASIC_LATIN = 0x0000, - LT_EXTENDEN_LATIN = 0x0001, - LT_CYRILLIC = 0x0002, - LT_EAST_ASIA = 0x0004, - LT_ANY = 0xFFFF -}; - -static LanguageType GetRealmLanguageType(bool create) -{ - switch(sWorld.getConfig(CONFIG_REALM_ZONE)) - { - case REALM_ZONE_UNKNOWN: // any language - case REALM_ZONE_DEVELOPMENT: - case REALM_ZONE_TEST_SERVER: - case REALM_ZONE_QA_SERVER: - return LT_ANY; - case REALM_ZONE_UNITED_STATES: // extended-Latin - case REALM_ZONE_OCEANIC: - case REALM_ZONE_LATIN_AMERICA: - case REALM_ZONE_ENGLISH: - case REALM_ZONE_GERMAN: - case REALM_ZONE_FRENCH: - case REALM_ZONE_SPANISH: - return LT_EXTENDEN_LATIN; - case REALM_ZONE_KOREA: // East-Asian - case REALM_ZONE_TAIWAN: - case REALM_ZONE_CHINA: - return LT_EAST_ASIA; - case REALM_ZONE_RUSSIAN: // Cyrillic - return LT_CYRILLIC; - default: - return create ? LT_BASIC_LATIN : LT_ANY; // basic-Latin at create, any at login - } -} - -bool isValidString(std::wstring wstr, uint32 strictMask, bool numericOrSpace, bool create = false) -{ - if(strictMask==0) // any language, ignore realm - { - if(isExtendedLatinString(wstr,numericOrSpace)) - return true; - if(isCyrillicString(wstr,numericOrSpace)) - return true; - if(isEastAsianString(wstr,numericOrSpace)) - return true; - return false; - } - - if(strictMask & 0x2) // realm zone specific - { - LanguageType lt = GetRealmLanguageType(create); - if(lt & LT_EXTENDEN_LATIN) - if(isExtendedLatinString(wstr,numericOrSpace)) - return true; - if(lt & LT_CYRILLIC) - if(isCyrillicString(wstr,numericOrSpace)) - return true; - if(lt & LT_EAST_ASIA) - if(isEastAsianString(wstr,numericOrSpace)) - return true; - } - - if(strictMask & 0x1) // basic latin - { - if(isBasicLatinString(wstr,numericOrSpace)) - return true; - } - - return false; -} - -bool ObjectMgr::IsValidName( std::string name, bool create ) -{ - std::wstring wname; - if(!Utf8toWStr(name,wname)) - return false; - - if(wname.size() < 1 || wname.size() > MAX_PLAYER_NAME) - return false; - - uint32 strictMask = sWorld.getConfig(CONFIG_STRICT_PLAYER_NAMES); - - return isValidString(wname,strictMask,false,create); -} - -bool ObjectMgr::IsValidCharterName( std::string name ) -{ - std::wstring wname; - if(!Utf8toWStr(name,wname)) - return false; - - if(wname.size() < 1) - return false; - - uint32 strictMask = sWorld.getConfig(CONFIG_STRICT_CHARTER_NAMES); - - return isValidString(wname,strictMask,true); -} - -bool ObjectMgr::IsValidPetName( std::string name ) -{ - std::wstring wname; - if(!Utf8toWStr(name,wname)) - return false; - - if(wname.size() < 1) - return false; - - uint32 strictMask = sWorld.getConfig(CONFIG_STRICT_PET_NAMES); - - return isValidString(wname,strictMask,false); -} - -int ObjectMgr::GetIndexForLocale( LocaleConstant loc ) -{ - if(loc==LOCALE_enUS) - return -1; - - for(size_t i=0;i < m_LocalForIndex.size(); ++i) - if(m_LocalForIndex[i]==loc) - return i; - - return -1; -} - -LocaleConstant ObjectMgr::GetLocaleForIndex(int i) -{ - if (i<0 || i>=m_LocalForIndex.size()) - return LOCALE_enUS; - - return m_LocalForIndex[i]; -} - -int ObjectMgr::GetOrNewIndexForLocale( LocaleConstant loc ) -{ - if(loc==LOCALE_enUS) - return -1; - - for(size_t i=0;i < m_LocalForIndex.size(); ++i) - if(m_LocalForIndex[i]==loc) - return i; - - m_LocalForIndex.push_back(loc); - return m_LocalForIndex.size()-1; -} - -void ObjectMgr::LoadBattleMastersEntry() -{ - mBattleMastersMap.clear(); // need for reload case - - QueryResult *result = WorldDatabase.Query( "SELECT entry,bg_template FROM battlemaster_entry" ); - - uint32 count = 0; - - if( !result ) - { - barGoLink bar( 1 ); - bar.step(); - - sLog.outString(); - sLog.outString( ">> Loaded 0 battlemaster entries - table is empty!" ); - return; - } - - barGoLink bar( result->GetRowCount() ); - - do - { - ++count; - bar.step(); - - Field *fields = result->Fetch(); - - uint32 entry = fields[0].GetUInt32(); - uint32 bgTypeId = fields[1].GetUInt32(); - - mBattleMastersMap[entry] = bgTypeId; - - } while( result->NextRow() ); - - delete result; - - sLog.outString(); - sLog.outString( ">> Loaded %u battlemaster entries", count ); -} - -void ObjectMgr::LoadGameObjectForQuests() -{ - mGameObjectForQuestSet.clear(); // need for reload case - - uint32 count = 0; - - // collect GO entries for GO that must activated - for(uint32 go_entry = 1; go_entry < sGOStorage.MaxEntry; ++go_entry) - { - GameObjectInfo const* goInfo = sGOStorage.LookupEntry(go_entry); - if(!goInfo) - continue; - - switch(goInfo->type) - { - // scan GO chest with loot including quest items - case GAMEOBJECT_TYPE_CHEST: - { - uint32 loot_id = GameObject::GetLootId(goInfo); - - // find quest loot for GO - if(LootTemplates_Gameobject.HaveQuestLootFor(loot_id)) - { - mGameObjectForQuestSet.insert(go_entry); - ++count; - } - break; - } - case GAMEOBJECT_TYPE_GOOBER: - { - if(goInfo->goober.questId) //quests objects - { - mGameObjectForQuestSet.insert(go_entry); - count++; - } - break; - } - default: - break; - } - } - - sLog.outString(); - sLog.outString( ">> Loaded %u GameObject for quests", count ); -} - -bool ObjectMgr::LoadMangosStrings(DatabaseType& db, char const* table, bool positive_entries) -{ - // cleanup affected map part for reloading case - for(MangosStringLocaleMap::iterator itr = mMangosStringLocaleMap.begin(); itr != mMangosStringLocaleMap.end();) - { - if(itr->first > 0 && positive_entries || itr->first < 0 && !positive_entries) - { - MangosStringLocaleMap::iterator itr2 = itr; - ++itr; - mMangosStringLocaleMap.erase(itr2); - } - else - ++itr; - } - - QueryResult *result = db.PQuery("SELECT entry,content_default,content_loc1,content_loc2,content_loc3,content_loc4,content_loc5,content_loc6,content_loc7,content_loc8 FROM %s",table); - - if(!result) - { - barGoLink bar(1); - - bar.step(); - - sLog.outString(""); - if(positive_entries) // error only in case internal strings - sLog.outErrorDb(">> Loaded 0 mangos strings. DB table `%s` is empty. Cannot continue.",table); - else - sLog.outString(">> Loaded 0 mangos strings. DB table `%s` is empty.",table); - return false; - } - - barGoLink bar(result->GetRowCount()); - - do - { - Field *fields = result->Fetch(); - bar.step(); - - int32 entry = fields[0].GetInt32(); - - if(entry==0) - { - sLog.outString("Table `%s` contain reserved entry 0, ignored.",table); - continue; - } - else if(entry < 0) - { - if(positive_entries) - { - sLog.outString("Table `%s` contain unexpected negative entry %i, ignored.",table,entry); - continue; - } - } - else - { - if(!positive_entries) - { - sLog.outString("Table `%s` contain unexpected positive entry %i, ignored.",table,entry); - continue; - } - } - - MangosStringLocale& data = mMangosStringLocaleMap[entry]; - - if(data.Content.size() < 1) - data.Content.resize(1); - - // 0 -> default, idx in to idx+1 - data.Content[0] = fields[1].GetCppString(); - - for(int i = 1; i < MAX_LOCALE; ++i) - { - std::string str = fields[i+1].GetCppString(); - if(!str.empty()) - { - int idx = GetOrNewIndexForLocale(LocaleConstant(i)); - if(idx >= 0) - { - // 0 -> default, idx in to idx+1 - if(data.Content.size() <= idx+1) - data.Content.resize(idx+2); - - data.Content[idx+1] = str; - } - } - } - } while (result->NextRow()); - - delete result; - - sLog.outString(); - sLog.outString( ">> Loaded %u MaNGOS strings from table %s", mMangosStringLocaleMap.size(),table); - return true; -} - -const char *ObjectMgr::GetMangosString(int32 entry, int locale_idx) const -{ - // locale_idx==-1 -> default, locale_idx >= 0 in to idx+1 - // Content[0] always exist if exist MangosStringLocale - if(MangosStringLocale const *msl = GetMangosStringLocale(entry)) - { - if(msl->Content.size() > locale_idx+1 && !msl->Content[locale_idx+1].empty()) - return msl->Content[locale_idx+1].c_str(); - else - return msl->Content[0].c_str(); - } - - if(entry > 0) - sLog.outErrorDb("Entry %i not found in `mangos_string` table.",entry); - else - sLog.outErrorDb("Mangos string entry %i not found in DB.",entry); - return ""; -} - -void ObjectMgr::LoadFishingBaseSkillLevel() -{ - mFishingBaseForArea.clear(); // for relaod case - - uint32 count = 0; - QueryResult *result = WorldDatabase.Query("SELECT entry,skill FROM skill_fishing_base_level"); - - if( !result ) - { - barGoLink bar( 1 ); - - bar.step(); - - sLog.outString(); - sLog.outErrorDb(">> Loaded `skill_fishing_base_level`, table is empty!"); - return; - } - - barGoLink bar( result->GetRowCount() ); - - do - { - bar.step(); - - Field *fields = result->Fetch(); - uint32 entry = fields[0].GetUInt32(); - int32 skill = fields[1].GetInt32(); - - AreaTableEntry const* fArea = GetAreaEntryByAreaID(entry); - if(!fArea) - { - sLog.outErrorDb("AreaId %u defined in `skill_fishing_base_level` does not exist",entry); - continue; - } - - mFishingBaseForArea[entry] = skill; - ++count; - } - while (result->NextRow()); - - delete result; - - sLog.outString(); - sLog.outString( ">> Loaded %u areas for fishing base skill level", count ); -} - -// Searches for the same condition already in Conditions store -// Returns Id if found, else adds it to Conditions and returns Id -uint16 ObjectMgr::GetConditionId( ConditionType condition, uint32 value1, uint32 value2 ) -{ - PlayerCondition lc = PlayerCondition(condition, value1, value2); - for (uint16 i=0; i < mConditions.size(); ++i) - { - if (lc == mConditions[i]) - return i; - } - - mConditions.push_back(lc); - - if(mConditions.size() > 0xFFFF) - { - sLog.outError("Conditions store overflow! Current and later loaded conditions will ignored!"); - return 0; - } - - return mConditions.size() - 1; -} - -bool ObjectMgr::CheckDeclinedNames( std::wstring mainpart, DeclinedName const& names ) -{ - for(int i =0; i < MAX_DECLINED_NAME_CASES; ++i) - { - std::wstring wname; - if(!Utf8toWStr(names.name[i],wname)) - return false; - - if(mainpart!=GetMainPartOfName(wname,i+1)) - return false; - } - return true; -} - -const char* ObjectMgr::GetAreaTriggerScriptName(uint32 id) -{ - AreaTriggerScriptMap::const_iterator i = mAreaTriggerScripts.find(id); - if(i!= mAreaTriggerScripts.end()) - return i->second.c_str(); - return ""; -} - -// Checks if player meets the condition -bool PlayerCondition::Meets(Player const * player) const -{ - if( !player ) - return false; // player not present, return false - - switch (condition) - { - case CONDITION_NONE: - return true; // empty condition, always met - case CONDITION_AURA: - return player->HasAura(value1, value2); - case CONDITION_ITEM: - return player->HasItemCount(value1, value2); - case CONDITION_ITEM_EQUIPPED: - return player->GetItemOrItemWithGemEquipped(value1) != NULL; - case CONDITION_ZONEID: - return player->GetZoneId() == value1; - case CONDITION_REPUTATION_RANK: - { - FactionEntry const* faction = sFactionStore.LookupEntry(value1); - return faction && player->GetReputationRank(faction) >= value2; - } - case CONDITION_TEAM: - return player->GetTeam() == value1; - case CONDITION_SKILL: - return player->HasSkill(value1) && player->GetBaseSkillValue(value1) >= value2; - case CONDITION_QUESTREWARDED: - return player->GetQuestRewardStatus(value1); - case CONDITION_QUESTTAKEN: - { - QuestStatus status = player->GetQuestStatus(value1); - return (status == QUEST_STATUS_INCOMPLETE); - } - case CONDITION_AD_COMMISSION_AURA: - { - Unit::AuraMap const& auras = player->GetAuras(); - for(Unit::AuraMap::const_iterator itr = auras.begin(); itr != auras.end(); ++itr) - if((itr->second->GetSpellProto()->Attributes & 0x1000010) && itr->second->GetSpellProto()->SpellVisual==3580) - return true; - return false; - } - default: - return false; - } -} - -// Verification of condition values validity -bool PlayerCondition::IsValid(ConditionType condition, uint32 value1, uint32 value2) -{ - if( condition >= MAX_CONDITION) // Wrong condition type - { - sLog.outErrorDb("Condition has bad type of %u, skipped ", condition ); - return false; - } - - switch (condition) - { - case CONDITION_AURA: - { - if(!sSpellStore.LookupEntry(value1)) - { - sLog.outErrorDb("Aura condition requires to have non existing spell (Id: %d), skipped", value1); - return false; - } - if(value2 > 2) - { - sLog.outErrorDb("Aura condition requires to have non existing effect index (%u) (must be 0..2), skipped", value2); - return false; - } - break; - } - case CONDITION_ITEM: - { - ItemPrototype const *proto = objmgr.GetItemPrototype(value1); - if(!proto) - { - sLog.outErrorDb("Item condition requires to have non existing item (%u), skipped", value1); - return false; - } - break; - } - case CONDITION_ITEM_EQUIPPED: - { - ItemPrototype const *proto = objmgr.GetItemPrototype(value1); - if(!proto) - { - sLog.outErrorDb("ItemEquipped condition requires to have non existing item (%u) equipped, skipped", value1); - return false; - } - break; - } - case CONDITION_ZONEID: - { - AreaTableEntry const* areaEntry = GetAreaEntryByAreaID(value1); - if(!areaEntry) - { - sLog.outErrorDb("Zone condition requires to be in non existing area (%u), skipped", value1); - return false; - } - if(areaEntry->zone != 0) - { - sLog.outErrorDb("Zone condition requires to be in area (%u) which is a subzone but zone expected, skipped", value1); - return false; - } - break; - } - case CONDITION_REPUTATION_RANK: - { - FactionEntry const* factionEntry = sFactionStore.LookupEntry(value1); - if(!factionEntry) - { - sLog.outErrorDb("Reputation condition requires to have reputation non existing faction (%u), skipped", value1); - return false; - } - break; - } - case CONDITION_TEAM: - { - if (value1 != ALLIANCE && value1 != HORDE) - { - sLog.outErrorDb("Team condition specifies unknown team (%u), skipped", value1); - return false; - } - break; - } - case CONDITION_SKILL: - { - SkillLineEntry const *pSkill = sSkillLineStore.LookupEntry(value1); - if (!pSkill) - { - sLog.outErrorDb("Skill condition specifies non-existing skill (%u), skipped", value1); - return false; - } - if (value2 < 1 || value2 > sWorld.GetConfigMaxSkillValue() ) - { - sLog.outErrorDb("Skill condition specifies invalid skill value (%u), skipped", value2); - return false; - } - break; - } - case CONDITION_QUESTREWARDED: - case CONDITION_QUESTTAKEN: - { - Quest const *Quest = objmgr.GetQuestTemplate(value1); - if (!Quest) - { - sLog.outErrorDb("Quest condition specifies non-existing quest (%u), skipped", value1); - return false; - } - if(value2) - sLog.outErrorDb("Quest condition has useless data in value2 (%u)!", value2); - break; - } - case CONDITION_AD_COMMISSION_AURA: - { - if(value1) - sLog.outErrorDb("Quest condition has useless data in value1 (%u)!", value1); - if(value2) - sLog.outErrorDb("Quest condition has useless data in value2 (%u)!", value2); - break; - } - } - return true; -} - -SkillRangeType GetSkillRangeType(SkillLineEntry const *pSkill, bool racial) -{ - switch(pSkill->categoryId) - { - case SKILL_CATEGORY_LANGUAGES: return SKILL_RANGE_LANGUAGE; - case SKILL_CATEGORY_WEAPON: - if(pSkill->id!=SKILL_FIST_WEAPONS) - return SKILL_RANGE_LEVEL; - else - return SKILL_RANGE_MONO; - case SKILL_CATEGORY_ARMOR: - case SKILL_CATEGORY_CLASS: - if(pSkill->id != SKILL_POISONS && pSkill->id != SKILL_LOCKPICKING) - return SKILL_RANGE_MONO; - else - return SKILL_RANGE_LEVEL; - case SKILL_CATEGORY_SECONDARY: - case SKILL_CATEGORY_PROFESSION: - // not set skills for professions and racial abilities - if(IsProfessionSkill(pSkill->id)) - return SKILL_RANGE_RANK; - else if(racial) - return SKILL_RANGE_NONE; - else - return SKILL_RANGE_MONO; - default: - case SKILL_CATEGORY_ATTRIBUTES: //not found in dbc - case SKILL_CATEGORY_NOT_DISPLAYED: //only GENEREC(DND) - return SKILL_RANGE_NONE; - } -} - -const char* GetAreaTriggerScriptNameById(uint32 id) -{ - return objmgr.GetAreaTriggerScriptName(id); -} - - -bool LoadMangosStrings(DatabaseType& db, char const* table) -{ - // for scripting localized strings allowed use _only_ negative entries - return objmgr.LoadMangosStrings(db,table,false); -} +/* + * Copyright (C) 2005-2008 MaNGOS + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "Common.h" +#include "Database/DatabaseEnv.h" +#include "Database/SQLStorage.h" + +#include "Log.h" +#include "MapManager.h" +#include "ObjectMgr.h" +#include "SpellMgr.h" +#include "UpdateMask.h" +#include "World.h" +#include "WorldSession.h" +#include "Group.h" +#include "Guild.h" +#include "ArenaTeam.h" +#include "Transports.h" +#include "ProgressBar.h" +#include "Policies/SingletonImp.h" +#include "Language.h" +#include "GameEvent.h" +#include "Spell.h" +#include "Chat.h" +#include "InstanceSaveMgr.h" +#include "SpellAuras.h" +#include "Util.h" + +INSTANTIATE_SINGLETON_1(ObjectMgr); + +ScriptMapMap sQuestEndScripts; +ScriptMapMap sQuestStartScripts; +ScriptMapMap sSpellScripts; +ScriptMapMap sGameObjectScripts; +ScriptMapMap sEventScripts; + +bool normalizePlayerName(std::string& name) +{ + if(name.empty()) + return false; + + wchar_t wstr_buf[MAX_INTERNAL_PLAYER_NAME+1]; + size_t wstr_len = MAX_INTERNAL_PLAYER_NAME; + + if(!Utf8toWStr(name,&wstr_buf[0],wstr_len)) + return false; + + wstr_buf[0] = wcharToUpper(wstr_buf[0]); + for(size_t i = 1; i < wstr_len; ++i) + wstr_buf[i] = wcharToLower(wstr_buf[i]); + + if(!WStrToUtf8(wstr_buf,wstr_len,name)) + return false; + + return true; +} + +ObjectMgr::ObjectMgr() +{ + m_hiCharGuid = 1; + m_hiCreatureGuid = 1; + m_hiPetGuid = 1; + m_hiItemGuid = 1; + m_hiGoGuid = 1; + m_hiDoGuid = 1; + m_hiCorpseGuid = 1; + + m_hiPetNumber = 1; + + mGuildBankTabPrice.resize(GUILD_BANK_MAX_TABS); + mGuildBankTabPrice[0] = 100; + mGuildBankTabPrice[1] = 250; + mGuildBankTabPrice[2] = 500; + mGuildBankTabPrice[3] = 1000; + mGuildBankTabPrice[4] = 2500; + mGuildBankTabPrice[5] = 5000; + + // Only zero condition left, others will be added while loading DB tables + mConditions.resize(1); +} + +ObjectMgr::~ObjectMgr() +{ + for( QuestMap::iterator i = mQuestTemplates.begin( ); i != mQuestTemplates.end( ); ++ i ) + { + delete i->second; + } + mQuestTemplates.clear( ); + + for( GossipTextMap::iterator i = mGossipText.begin( ); i != mGossipText.end( ); ++ i ) + { + delete i->second; + } + mGossipText.clear( ); + + mAreaTriggers.clear(); + + for(PetLevelInfoMap::iterator i = petInfo.begin( ); i != petInfo.end( ); ++ i ) + { + delete[] i->second; + } + petInfo.clear(); + + // free only if loaded + for (int class_ = 0; class_ < MAX_CLASSES; ++class_) + delete[] playerClassInfo[class_].levelInfo; + + for (int race = 0; race < MAX_RACES; ++race) + for (int class_ = 0; class_ < MAX_CLASSES; ++class_) + delete[] playerInfo[race][class_].levelInfo; + + // free group and guild objects + for (GroupSet::iterator itr = mGroupSet.begin(); itr != mGroupSet.end(); ++itr) + delete (*itr); + for (GuildSet::iterator itr = mGuildSet.begin(); itr != mGuildSet.end(); ++itr) + delete (*itr); + + for(ItemMap::iterator itr = mAitems.begin(); itr != mAitems.end(); ++itr) + delete itr->second; + + for (CacheVendorItemMap::iterator itr = m_mCacheVendorItemMap.begin(); itr != m_mCacheVendorItemMap.end(); ++itr) + for (VendorItemList::iterator itr2 = itr->second.begin(); itr2 != itr->second.end(); ++itr2) + delete (*itr2); + + for (CacheTrainerSpellMap::iterator itr = m_mCacheTrainerSpellMap.begin(); itr != m_mCacheTrainerSpellMap.end(); ++itr) + itr->second.Clear(); +} + +Group * ObjectMgr::GetGroupByLeader(const uint64 &guid) const +{ + for(GroupSet::const_iterator itr = mGroupSet.begin(); itr != mGroupSet.end(); ++itr) + if ((*itr)->GetLeaderGUID() == guid) + return *itr; + + return NULL; +} + +Guild * ObjectMgr::GetGuildById(const uint32 GuildId) const +{ + for(GuildSet::const_iterator itr = mGuildSet.begin(); itr != mGuildSet.end(); itr++) + if ((*itr)->GetId() == GuildId) + return *itr; + + return NULL; +} + +Guild * ObjectMgr::GetGuildByName(std::string guildname) const +{ + for(GuildSet::const_iterator itr = mGuildSet.begin(); itr != mGuildSet.end(); itr++) + if ((*itr)->GetName() == guildname) + return *itr; + + return NULL; +} + +std::string ObjectMgr::GetGuildNameById(const uint32 GuildId) const +{ + for(GuildSet::const_iterator itr = mGuildSet.begin(); itr != mGuildSet.end(); itr++) + if ((*itr)->GetId() == GuildId) + return (*itr)->GetName(); + + return ""; +} + +Guild* ObjectMgr::GetGuildByLeader(const uint64 &guid) const +{ + for(GuildSet::const_iterator itr = mGuildSet.begin(); itr != mGuildSet.end(); ++itr) + if( (*itr)->GetLeader() == guid) + return *itr; + + return NULL; +} + +ArenaTeam* ObjectMgr::GetArenaTeamById(const uint32 ArenaTeamId) const +{ + for(ArenaTeamSet::const_iterator itr = mArenaTeamSet.begin(); itr != mArenaTeamSet.end(); itr++) + if ((*itr)->GetId() == ArenaTeamId) + return *itr; + + return NULL; +} + +ArenaTeam* ObjectMgr::GetArenaTeamByName(std::string arenateamname) const +{ + for(ArenaTeamSet::const_iterator itr = mArenaTeamSet.begin(); itr != mArenaTeamSet.end(); itr++) + if ((*itr)->GetName() == arenateamname) + return *itr; + + return NULL; +} + +ArenaTeam* ObjectMgr::GetArenaTeamByCapitan(uint64 const& guid) const +{ + for(ArenaTeamSet::const_iterator itr = mArenaTeamSet.begin(); itr != mArenaTeamSet.end(); itr++) + if ((*itr)->GetCaptain() == guid) + return *itr; + + return NULL; +} + +AuctionHouseObject * ObjectMgr::GetAuctionsMap( uint32 location ) +{ + switch ( location ) + { + case 6: //horde + return & mHordeAuctions; + break; + case 2: //alliance + return & mAllianceAuctions; + break; + default: //neutral + return & mNeutralAuctions; + } +} + +uint32 ObjectMgr::GetAuctionCut(uint32 location, uint32 highBid) +{ + if (location == 7 && !sWorld.getConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_AUCTION)) + return (uint32) (0.15f * highBid * sWorld.getRate(RATE_AUCTION_CUT)); + else + return (uint32) (0.05f * highBid * sWorld.getRate(RATE_AUCTION_CUT)); +} + +uint32 ObjectMgr::GetAuctionDeposit(uint32 location, uint32 time, Item *pItem) +{ + float percentance; // in 0..1 + if ( location == 7 && !sWorld.getConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_AUCTION)) + percentance = 0.75f; + else + percentance = 0.15f; + + percentance *= sWorld.getRate(RATE_AUCTION_DEPOSIT); + + return uint32( percentance * pItem->GetProto()->SellPrice * pItem->GetCount() * (time / MIN_AUCTION_TIME ) ); +} + +/// the sum of outbid is (1% from current bid)*5, if bid is very small, it is 1c +uint32 ObjectMgr::GetAuctionOutBid(uint32 currentBid) +{ + uint32 outbid = (currentBid / 100) * 5; + if (!outbid) + outbid = 1; + return outbid; +} + +//does not clear ram +void ObjectMgr::SendAuctionWonMail( AuctionEntry *auction ) +{ + Item *pItem = GetAItem(auction->item_guidlow); + if(!pItem) + return; + + uint64 bidder_guid = MAKE_NEW_GUID(auction->bidder, 0, HIGHGUID_PLAYER); + Player *bidder = GetPlayer(bidder_guid); + + uint32 bidder_accId = 0; + + // data for gm.log + if( sWorld.getConfig(CONFIG_GM_LOG_TRADE) ) + { + uint32 bidder_security = 0; + std::string bidder_name; + if (bidder) + { + bidder_accId = bidder->GetSession()->GetAccountId(); + bidder_security = bidder->GetSession()->GetSecurity(); + bidder_name = bidder->GetName(); + } + else + { + bidder_accId = GetPlayerAccountIdByGUID(bidder_guid); + bidder_security = GetSecurityByAccount(bidder_accId); + + if(bidder_security > SEC_PLAYER ) // not do redundant DB requests + { + if(!GetPlayerNameByGUID(bidder_guid,bidder_name)) + bidder_name = GetMangosStringForDBCLocale(LANG_UNKNOWN); + } + } + + if( bidder_security > SEC_PLAYER ) + { + std::string owner_name; + if(!GetPlayerNameByGUID(auction->owner,owner_name)) + owner_name = GetMangosStringForDBCLocale(LANG_UNKNOWN); + + uint32 owner_accid = GetPlayerAccountIdByGUID(auction->owner); + + sLog.outCommand("GM %s (Account: %u) won item in auction: %s (Entry: %u Count: %u) and pay money: %u. Original owner %s (Account: %u)", + bidder_name.c_str(),bidder_accId,pItem->GetProto()->Name1,pItem->GetEntry(),pItem->GetCount(),auction->bid,owner_name.c_str(),owner_accid); + } + } + else if(!bidder) + bidder_accId = GetPlayerAccountIdByGUID(bidder_guid); + + // receiver exist + if(bidder || bidder_accId) + { + std::ostringstream msgAuctionWonSubject; + msgAuctionWonSubject << auction->item_template << ":0:" << AUCTION_WON; + + std::ostringstream msgAuctionWonBody; + msgAuctionWonBody.width(16); + msgAuctionWonBody << std::right << std::hex << auction->owner; + msgAuctionWonBody << std::dec << ":" << auction->bid << ":" << auction->buyout; + sLog.outDebug( "AuctionWon body string : %s", msgAuctionWonBody.str().c_str() ); + + //prepare mail data... : + uint32 itemTextId = this->CreateItemText( msgAuctionWonBody.str() ); + + // set owner to bidder (to prevent delete item with sender char deleting) + // owner in `data` will set at mail receive and item extracting + CharacterDatabase.PExecute("UPDATE item_instance SET owner_guid = '%u' WHERE guid='%u'",auction->bidder,pItem->GetGUIDLow()); + CharacterDatabase.CommitTransaction(); + + MailItemsInfo mi; + mi.AddItem(auction->item_guidlow, auction->item_template, pItem); + + if (bidder) + bidder->GetSession()->SendAuctionBidderNotification( auction->location, auction->Id, bidder_guid, 0, 0, auction->item_template); + else + RemoveAItem(pItem->GetGUIDLow()); // we have to remove the item, before we delete it !! + + // will delete item or place to receiver mail list + WorldSession::SendMailTo(bidder, MAIL_AUCTION, MAIL_STATIONERY_AUCTION, auction->location, auction->bidder, msgAuctionWonSubject.str(), itemTextId, &mi, 0, 0, MAIL_CHECK_MASK_AUCTION); + } + // receiver not exist + else + { + CharacterDatabase.PExecute("DELETE FROM item_instance WHERE guid='%u'", pItem->GetGUIDLow()); + RemoveAItem(pItem->GetGUIDLow()); // we have to remove the item, before we delete it !! + delete pItem; + } +} + +void ObjectMgr::SendAuctionSalePendingMail( AuctionEntry * auction ) +{ + uint64 owner_guid = MAKE_NEW_GUID(auction->owner, 0, HIGHGUID_PLAYER); + Player *owner = GetPlayer(owner_guid); + + // owner exist (online or offline) + if(owner || GetPlayerAccountIdByGUID(owner_guid)) + { + std::ostringstream msgAuctionSalePendingSubject; + msgAuctionSalePendingSubject << auction->item_template << ":0:" << AUCTION_SALE_PENDING; + + std::ostringstream msgAuctionSalePendingBody; + uint32 auctionCut = GetAuctionCut(auction->location, auction->bid); + + time_t distrTime = time(NULL) + HOUR; + + msgAuctionSalePendingBody.width(16); + msgAuctionSalePendingBody << std::right << std::hex << auction->bidder; + msgAuctionSalePendingBody << std::dec << ":" << auction->bid << ":" << auction->buyout; + msgAuctionSalePendingBody << ":" << auction->deposit << ":" << auctionCut << ":0:"; + msgAuctionSalePendingBody << secsToTimeBitFields(distrTime); + + sLog.outDebug("AuctionSalePending body string : %s", msgAuctionSalePendingBody.str().c_str()); + + uint32 itemTextId = this->CreateItemText( msgAuctionSalePendingBody.str() ); + + WorldSession::SendMailTo(owner, MAIL_AUCTION, MAIL_STATIONERY_AUCTION, auction->location, auction->owner, msgAuctionSalePendingSubject.str(), itemTextId, NULL, 0, 0, MAIL_CHECK_MASK_AUCTION); + } +} + +//call this method to send mail to auction owner, when auction is successful, it does not clear ram +void ObjectMgr::SendAuctionSuccessfulMail( AuctionEntry * auction ) +{ + uint64 owner_guid = MAKE_NEW_GUID(auction->owner, 0, HIGHGUID_PLAYER); + Player *owner = GetPlayer(owner_guid); + + uint32 owner_accId = 0; + if(!owner) + owner_accId = GetPlayerAccountIdByGUID(owner_guid); + + // owner exist + if(owner || owner_accId) + { + std::ostringstream msgAuctionSuccessfulSubject; + msgAuctionSuccessfulSubject << auction->item_template << ":0:" << AUCTION_SUCCESSFUL; + + std::ostringstream auctionSuccessfulBody; + uint32 auctionCut = GetAuctionCut(auction->location, auction->bid); + + auctionSuccessfulBody.width(16); + auctionSuccessfulBody << std::right << std::hex << auction->bidder; + auctionSuccessfulBody << std::dec << ":" << auction->bid << ":" << auction->buyout; + auctionSuccessfulBody << ":" << auction->deposit << ":" << auctionCut; + + sLog.outDebug("AuctionSuccessful body string : %s", auctionSuccessfulBody.str().c_str()); + + uint32 itemTextId = this->CreateItemText( auctionSuccessfulBody.str() ); + + uint32 profit = auction->bid + auction->deposit - auctionCut; + + if (owner) + { + //send auction owner notification, bidder must be current! + owner->GetSession()->SendAuctionOwnerNotification( auction ); + } + + WorldSession::SendMailTo(owner, MAIL_AUCTION, MAIL_STATIONERY_AUCTION, auction->location, auction->owner, msgAuctionSuccessfulSubject.str(), itemTextId, NULL, profit, 0, MAIL_CHECK_MASK_AUCTION, HOUR); + } +} + +//does not clear ram +void ObjectMgr::SendAuctionExpiredMail( AuctionEntry * auction ) +{ //return an item in auction to its owner by mail + Item *pItem = GetAItem(auction->item_guidlow); + if(!pItem) + { + sLog.outError("Auction item (GUID: %u) not found, and lost.",auction->item_guidlow); + return; + } + + uint64 owner_guid = MAKE_NEW_GUID(auction->owner, 0, HIGHGUID_PLAYER); + Player *owner = GetPlayer(owner_guid); + + uint32 owner_accId = 0; + if(!owner) + owner_accId = GetPlayerAccountIdByGUID(owner_guid); + + // owner exist + if(owner || owner_accId) + { + std::ostringstream subject; + subject << auction->item_template << ":0:" << AUCTION_EXPIRED; + + if ( owner ) + owner->GetSession()->SendAuctionOwnerNotification( auction ); + else + RemoveAItem(pItem->GetGUIDLow()); // we have to remove the item, before we delete it !! + + MailItemsInfo mi; + mi.AddItem(auction->item_guidlow, auction->item_template, pItem); + + // will delete item or place to receiver mail list + WorldSession::SendMailTo(owner, MAIL_AUCTION, MAIL_STATIONERY_AUCTION, auction->location, GUID_LOPART(owner_guid), subject.str(), 0, &mi, 0, 0, MAIL_CHECK_MASK_NONE); + + } + // owner not found + else + { + CharacterDatabase.PExecute("DELETE FROM item_instance WHERE guid='%u'",pItem->GetGUIDLow()); + RemoveAItem(pItem->GetGUIDLow()); // we have to remove the item, before we delete it !! + delete pItem; + } +} + +CreatureInfo const* ObjectMgr::GetCreatureTemplate(uint32 id) +{ + return sCreatureStorage.LookupEntry(id); +} + +void ObjectMgr::LoadCreatureLocales() +{ + QueryResult *result = WorldDatabase.Query("SELECT entry,name_loc1,subname_loc1,name_loc2,subname_loc2,name_loc3,subname_loc3,name_loc4,subname_loc4,name_loc5,subname_loc5,name_loc6,subname_loc6,name_loc7,subname_loc7,name_loc8,subname_loc8 FROM locales_creature"); + + if(!result) + { + barGoLink bar(1); + + bar.step(); + + sLog.outString(""); + sLog.outString(">> Loaded 0 creature locale strings. DB table `locales_creature` is empty."); + return; + } + + barGoLink bar(result->GetRowCount()); + + do + { + Field *fields = result->Fetch(); + bar.step(); + + uint32 entry = fields[0].GetUInt32(); + + CreatureLocale& data = mCreatureLocaleMap[entry]; + + for(int i = 1; i < MAX_LOCALE; ++i) + { + std::string str = fields[1+2*(i-1)].GetCppString(); + if(!str.empty()) + { + int idx = GetOrNewIndexForLocale(LocaleConstant(i)); + if(idx >= 0) + { + if(data.Name.size() <= idx) + data.Name.resize(idx+1); + + data.Name[idx] = str; + } + } + str = fields[1+2*(i-1)+1].GetCppString(); + if(!str.empty()) + { + int idx = GetOrNewIndexForLocale(LocaleConstant(i)); + if(idx >= 0) + { + if(data.SubName.size() <= idx) + data.SubName.resize(idx+1); + + data.SubName[idx] = str; + } + } + } + } while (result->NextRow()); + + delete result; + + sLog.outString(); + sLog.outString( ">> Loaded %u creature locale strings", mCreatureLocaleMap.size() ); +} + +void ObjectMgr::LoadCreatureTemplates() +{ + sCreatureStorage.Load(); + + sLog.outString( ">> Loaded %u creature definitions", sCreatureStorage.RecordCount ); + sLog.outString(); + + std::set heroicEntries; // already loaded heroic value in creatures + std::set hasHeroicEntries; // already loaded creatures with heroic entry values + + // check data correctness + for(uint32 i = 1; i < sCreatureStorage.MaxEntry; ++i) + { + CreatureInfo const* cInfo = sCreatureStorage.LookupEntry(i); + if(!cInfo) + continue; + + if(cInfo->HeroicEntry) + { + CreatureInfo const* heroicInfo = GetCreatureTemplate(cInfo->HeroicEntry); + if(!heroicInfo) + { + sLog.outErrorDb("Creature (Entry: %u) have `heroic_entry`=%u but creature entry %u not exist.",cInfo->HeroicEntry,cInfo->HeroicEntry); + continue; + } + + if(heroicEntries.find(i)!=heroicEntries.end()) + { + sLog.outErrorDb("Creature (Entry: %u) listed as heroic but have value in `heroic_entry`.",i); + continue; + } + + if(heroicEntries.find(cInfo->HeroicEntry)!=heroicEntries.end()) + { + sLog.outErrorDb("Creature (Entry: %u) already listed as heroic for another entry.",cInfo->HeroicEntry); + continue; + } + + if(hasHeroicEntries.find(cInfo->HeroicEntry)!=hasHeroicEntries.end()) + { + sLog.outErrorDb("Creature (Entry: %u) have `heroic_entry`=%u but creature entry %u have heroic entry also.",i,cInfo->HeroicEntry,cInfo->HeroicEntry); + continue; + } + + if(cInfo->npcflag != heroicInfo->npcflag) + { + sLog.outErrorDb("Creature (Entry: %u) listed in `creature_template_substitution` has different `npcflag` in heroic mode.",i); + continue; + } + + if(cInfo->classNum != heroicInfo->classNum) + { + sLog.outErrorDb("Creature (Entry: %u) listed in `creature_template_substitution` has different `classNum` in heroic mode.",i); + continue; + } + + if(cInfo->race != heroicInfo->race) + { + sLog.outErrorDb("Creature (Entry: %u) listed in `creature_template_substitution` has different `race` in heroic mode.",i); + continue; + } + + if(cInfo->trainer_type != heroicInfo->trainer_type) + { + sLog.outErrorDb("Creature (Entry: %u) listed in `creature_template_substitution` has different `trainer_type` in heroic mode.",i); + continue; + } + + if(cInfo->trainer_spell != heroicInfo->trainer_spell) + { + sLog.outErrorDb("Creature (Entry: %u) listed in `creature_template_substitution` has different `trainer_spell` in heroic mode.",i); + continue; + } + + hasHeroicEntries.insert(i); + heroicEntries.insert(cInfo->HeroicEntry); + } + + FactionTemplateEntry const* factionTemplate = sFactionTemplateStore.LookupEntry(cInfo->faction_A); + if(!factionTemplate) + sLog.outErrorDb("Creature (Entry: %u) has non-existing faction_A template (%u)", cInfo->Entry, cInfo->faction_A); + + factionTemplate = sFactionTemplateStore.LookupEntry(cInfo->faction_H); + if(!factionTemplate) + sLog.outErrorDb("Creature (Entry: %u) has non-existing faction_H template (%u)", cInfo->Entry, cInfo->faction_H); + + CreatureModelInfo const* minfo = sCreatureModelStorage.LookupEntry(cInfo->DisplayID_A); + if (!minfo) + sLog.outErrorDb("Creature (Entry: %u) has non-existing modelId_A (%u)", cInfo->Entry, cInfo->DisplayID_A); + minfo = sCreatureModelStorage.LookupEntry(cInfo->DisplayID_H); + if (!minfo) + sLog.outErrorDb("Creature (Entry: %u) has non-existing modelId_H (%u)", cInfo->Entry, cInfo->DisplayID_H); + + if(cInfo->dmgschool >= MAX_SPELL_SCHOOL) + { + sLog.outErrorDb("Creature (Entry: %u) has invalid spell school value (%u) in `dmgschool`",cInfo->Entry,cInfo->dmgschool); + const_cast(cInfo)->dmgschool = SPELL_SCHOOL_NORMAL; + } + + if(cInfo->baseattacktime == 0) + const_cast(cInfo)->baseattacktime = BASE_ATTACK_TIME; + + if(cInfo->rangeattacktime == 0) + const_cast(cInfo)->rangeattacktime = BASE_ATTACK_TIME; + + if((cInfo->npcflag & UNIT_NPC_FLAG_TRAINER) && cInfo->trainer_type >= MAX_TRAINER_TYPE) + sLog.outErrorDb("Creature (Entry: %u) has wrong trainer type %u",cInfo->Entry,cInfo->trainer_type); + + if(cInfo->InhabitType <= 0 || cInfo->InhabitType > INHABIT_ANYWHERE) + { + sLog.outErrorDb("Creature (Entry: %u) has wrong value (%u) in `InhabitType`, creature will not correctly walk/swim/fly",cInfo->Entry,cInfo->InhabitType); + const_cast(cInfo)->InhabitType = INHABIT_ANYWHERE; + } + + if(cInfo->PetSpellDataId) + { + CreatureSpellDataEntry const* spellDataId = sCreatureSpellDataStore.LookupEntry(cInfo->PetSpellDataId); + if(!spellDataId) + sLog.outErrorDb("Creature (Entry: %u) has non-existing PetSpellDataId (%u)", cInfo->Entry, cInfo->PetSpellDataId); + } + + if(cInfo->MovementType >= MAX_DB_MOTION_TYPE) + { + sLog.outErrorDb("Creature (Entry: %u) has wrong movement generator type (%u), ignore and set to IDLE.",cInfo->Entry,cInfo->MovementType); + const_cast(cInfo)->MovementType = IDLE_MOTION_TYPE; + } + + if(cInfo->equipmentId > 0) // 0 no equipment + { + if(!GetEquipmentInfo(cInfo->equipmentId)) + { + sLog.outErrorDb("Table `creature_template` have creature (Entry: %u) with equipment_id %u not found in table `creature_equip_template`, set to no equipment.", cInfo->Entry, cInfo->equipmentId); + const_cast(cInfo)->equipmentId = 0; + } + } + + /// if not set custom creature scale then load scale from CreatureDisplayInfo.dbc + if(cInfo->scale <= 0.0f) + { + CreatureDisplayInfoEntry const* ScaleEntry = sCreatureDisplayInfoStore.LookupEntry(cInfo->DisplayID_A); + const_cast(cInfo)->scale = ScaleEntry ? ScaleEntry->scale : 1.0f; + } + } +} + +void ObjectMgr::ConvertCreatureAddonAuras(CreatureDataAddon* addon, char const* table, char const* guidEntryStr) +{ + // Now add the auras, format "spellid effectindex spellid effectindex..." + char *p,*s; + std::vector val; + s=p=(char*)reinterpret_cast(addon->auras); + if(p) + { + while (p[0]!=0) + { + ++p; + if (p[0]==' ') + { + val.push_back(atoi(s)); + s=++p; + } + } + if (p!=s) + val.push_back(atoi(s)); + + // free char* loaded memory + delete[] (char*)reinterpret_cast(addon->auras); + + // wrong list + if (val.size()%2) + { + addon->auras = NULL; + sLog.outErrorDb("Creature (%s: %u) has wrong `auras` data in `%s`.",guidEntryStr,addon->guidOrEntry,table); + return; + } + } + + // empty list + if(val.empty()) + { + addon->auras = NULL; + return; + } + + // replace by new strucutres array + const_cast(addon->auras) = new CreatureDataAddonAura[val.size()/2+1]; + + int i=0; + for(int j=0;j(addon->auras[i]); + cAura.spell_id = (uint32)val[2*j+0]; + cAura.effect_idx = (uint32)val[2*j+1]; + if ( cAura.effect_idx > 2 ) + { + sLog.outErrorDb("Creature (%s: %u) has wrong effect %u for spell %u in `auras` field in `%s`.",guidEntryStr,addon->guidOrEntry,cAura.effect_idx,cAura.spell_id,table); + continue; + } + SpellEntry const *AdditionalSpellInfo = sSpellStore.LookupEntry(cAura.spell_id); + if (!AdditionalSpellInfo) + { + sLog.outErrorDb("Creature (%s: %u) has wrong spell %u defined in `auras` field in `%s`.",guidEntryStr,addon->guidOrEntry,cAura.spell_id,table); + continue; + } + + if (!AdditionalSpellInfo->Effect[cAura.effect_idx] || !AdditionalSpellInfo->EffectApplyAuraName[cAura.effect_idx]) + { + sLog.outErrorDb("Creature (%s: %u) has not aura effect %u of spell %u defined in `auras` field in `%s`.",guidEntryStr,addon->guidOrEntry,cAura.effect_idx,cAura.spell_id,table); + continue; + } + + ++i; + } + + // fill terminator element (after last added) + CreatureDataAddonAura& endAura = const_cast(addon->auras[i]); + endAura.spell_id = 0; + endAura.effect_idx = 0; +} + +void ObjectMgr::LoadCreatureAddons() +{ + sCreatureInfoAddonStorage.Load(); + + sLog.outString( ">> Loaded %u creature template addons", sCreatureInfoAddonStorage.RecordCount ); + sLog.outString(); + + // check data correctness and convert 'auras' + for(uint32 i = 1; i < sCreatureInfoAddonStorage.MaxEntry; ++i) + { + CreatureDataAddon const* addon = sCreatureInfoAddonStorage.LookupEntry(i); + if(!addon) + continue; + + ConvertCreatureAddonAuras(const_cast(addon), "creature_template_addon", "Entry"); + + if(!sCreatureStorage.LookupEntry(addon->guidOrEntry)) + sLog.outErrorDb("Creature (Entry: %u) does not exist but has a record in `creature_template_addon`",addon->guidOrEntry); + } + + sCreatureDataAddonStorage.Load(); + + sLog.outString( ">> Loaded %u creature addons", sCreatureDataAddonStorage.RecordCount ); + sLog.outString(); + + // check data correctness and convert 'auras' + for(uint32 i = 1; i < sCreatureDataAddonStorage.MaxEntry; ++i) + { + CreatureDataAddon const* addon = sCreatureDataAddonStorage.LookupEntry(i); + if(!addon) + continue; + + ConvertCreatureAddonAuras(const_cast(addon), "creature_addon", "GUIDLow"); + + if(mCreatureDataMap.find(addon->guidOrEntry)==mCreatureDataMap.end()) + sLog.outErrorDb("Creature (GUID: %u) does not exist but has a record in `creature_addon`",addon->guidOrEntry); + } +} + +EquipmentInfo const* ObjectMgr::GetEquipmentInfo(uint32 entry) +{ + return sEquipmentStorage.LookupEntry(entry); +} + +void ObjectMgr::LoadEquipmentTemplates() +{ + sEquipmentStorage.Load(); + + sLog.outString( ">> Loaded %u equipment template", sEquipmentStorage.RecordCount ); + sLog.outString(); +} + +CreatureModelInfo const* ObjectMgr::GetCreatureModelInfo(uint32 modelid) +{ + return sCreatureModelStorage.LookupEntry(modelid); +} + +uint32 ObjectMgr::ChooseDisplayId(uint32 team, const CreatureInfo *cinfo, const CreatureData *data) +{ + // Load creature model (display id) + uint32 display_id; + if (!data || data->displayid == 0) // use defaults from the template + { + // DisplayID_A is used if no team is given + if (team == HORDE) + display_id = (cinfo->DisplayID_H2 != 0 && urand(0,1) == 0) ? cinfo->DisplayID_H2 : cinfo->DisplayID_H; + else + display_id = (cinfo->DisplayID_A2 != 0 && urand(0,1) == 0) ? cinfo->DisplayID_A2 : cinfo->DisplayID_A; + } + else // overriden in creature data + display_id = data->displayid; + + return display_id; +} + +CreatureModelInfo const* ObjectMgr::GetCreatureModelRandomGender(uint32 display_id) +{ + CreatureModelInfo const *minfo = GetCreatureModelInfo(display_id); + if(!minfo) + return NULL; + + // If a model for another gender exists, 50% chance to use it + if(minfo->modelid_other_gender != 0 && urand(0,1) == 0) + { + CreatureModelInfo const *minfo_tmp = GetCreatureModelInfo(minfo->modelid_other_gender); + if(!minfo_tmp) + { + sLog.outErrorDb("Model (Entry: %u) has modelid_other_gender %u not found in table `creature_model_info`. ", minfo->modelid, minfo->modelid_other_gender); + return minfo; // not fatal, just use the previous one + } + else + return minfo_tmp; + } + else + return minfo; +} + +void ObjectMgr::LoadCreatureModelInfo() +{ + sCreatureModelStorage.Load(); + + sLog.outString( ">> Loaded %u creature model based info", sCreatureModelStorage.RecordCount ); + sLog.outString(); +} + +void ObjectMgr::LoadCreatures() +{ + uint32 count = 0; + // 0 1 2 3 + QueryResult *result = WorldDatabase.Query("SELECT creature.guid, id, map, modelid," + // 4 5 6 7 8 9 10 11 + "equipment_id, position_x, position_y, position_z, orientation, spawntimesecs, spawndist, currentwaypoint," + // 12 13 14 15 16 17 + "curhealth, curmana, DeathState, MovementType, spawnMask, event " + "FROM creature LEFT OUTER JOIN game_event_creature ON creature.guid = game_event_creature.guid"); + + if(!result) + { + barGoLink bar(1); + + bar.step(); + + sLog.outString(""); + sLog.outErrorDb(">> Loaded 0 creature. DB table `creature` is empty."); + return; + } + + // build single time for check creature data + std::set heroicCreatures; + for(uint32 i = 0; i < sCreatureStorage.MaxEntry; ++i) + if(CreatureInfo const* cInfo = sCreatureStorage.LookupEntry(i)) + if(cInfo->HeroicEntry) + heroicCreatures.insert(cInfo->HeroicEntry); + + barGoLink bar(result->GetRowCount()); + + do + { + Field *fields = result->Fetch(); + bar.step(); + + uint32 guid = fields[0].GetUInt32(); + + CreatureData& data = mCreatureDataMap[guid]; + + data.id = fields[ 1].GetUInt32(); + data.mapid = fields[ 2].GetUInt32(); + data.displayid = fields[ 3].GetUInt32(); + data.equipmentId = fields[ 4].GetUInt32(); + data.posX = fields[ 5].GetFloat(); + data.posY = fields[ 6].GetFloat(); + data.posZ = fields[ 7].GetFloat(); + data.orientation = fields[ 8].GetFloat(); + data.spawntimesecs = fields[ 9].GetUInt32(); + data.spawndist = fields[10].GetFloat(); + data.currentwaypoint= fields[11].GetUInt32(); + data.curhealth = fields[12].GetUInt32(); + data.curmana = fields[13].GetUInt32(); + data.is_dead = fields[14].GetBool(); + data.movementType = fields[15].GetUInt8(); + data.spawnMask = fields[16].GetUInt8(); + int16 gameEvent = fields[17].GetInt16(); + + CreatureInfo const* cInfo = GetCreatureTemplate(data.id); + if(!cInfo) + { + sLog.outErrorDb("Table `creature` have creature (GUID: %u) with not existed creature entry %u, skipped.",guid,data.id ); + continue; + } + + if(heroicCreatures.find(data.id)!=heroicCreatures.end()) + { + sLog.outErrorDb("Table `creature` have creature (GUID: %u) that listed as heroic template in `creature_template_substitution`, skipped.",guid,data.id ); + continue; + } + + if(data.equipmentId > 0) // -1 no equipment, 0 use default + { + if(!GetEquipmentInfo(data.equipmentId)) + { + sLog.outErrorDb("Table `creature` have creature (Entry: %u) with equipment_id %u not found in table `creature_equip_template`, set to no equipment.", data.id, data.equipmentId); + data.equipmentId = -1; + } + } + + if(cInfo->RegenHealth && data.curhealth < cInfo->minhealth) + { + sLog.outErrorDb("Table `creature` have creature (GUID: %u Entry: %u) with `creature_template`.`RegenHealth`=1 and low current health (%u), `creature_template`.`minhealth`=%u.",guid,data.id,data.curhealth, cInfo->minhealth ); + data.curhealth = cInfo->minhealth; + } + + if(data.curmana < cInfo->minmana) + { + sLog.outErrorDb("Table `creature` have creature (GUID: %u Entry: %u) with low current mana (%u), `creature_template`.`minmana`=%u.",guid,data.id,data.curmana, cInfo->minmana ); + data.curmana = cInfo->minmana; + } + + if(data.spawndist < 0.0f) + { + sLog.outErrorDb("Table `creature` have creature (GUID: %u Entry: %u) with `spawndist`< 0, set to 0.",guid,data.id ); + data.spawndist = 0.0f; + } + else if(data.movementType == RANDOM_MOTION_TYPE) + { + if(data.spawndist == 0.0f) + { + sLog.outErrorDb("Table `creature` have creature (GUID: %u Entry: %u) with `MovementType`=1 (random movement) but with `spawndist`=0, replace by idle movement type (0).",guid,data.id ); + data.movementType = IDLE_MOTION_TYPE; + } + } + else if(data.movementType == IDLE_MOTION_TYPE) + { + if(data.spawndist != 0.0f) + { + sLog.outErrorDb("Table `creature` have creature (GUID: %u Entry: %u) with `MovementType`=0 (idle) have `spawndist`<>0, set to 0.",guid,data.id ); + data.spawndist = 0.0f; + } + } + + if (gameEvent==0) // if not this is to be managed by GameEvent System + AddCreatureToGrid(guid, &data); + ++count; + + } while (result->NextRow()); + + delete result; + + sLog.outString(); + sLog.outString( ">> Loaded %u creatures", mCreatureDataMap.size() ); +} + +void ObjectMgr::AddCreatureToGrid(uint32 guid, CreatureData const* data) +{ + uint8 mask = data->spawnMask; + for(uint8 i = 0; mask != 0; i++, mask >>= 1) + { + if(mask & 1) + { + CellPair cell_pair = MaNGOS::ComputeCellPair(data->posX, data->posY); + uint32 cell_id = (cell_pair.y_coord*TOTAL_NUMBER_OF_CELLS_PER_MAP) + cell_pair.x_coord; + + CellObjectGuids& cell_guids = mMapObjectGuids[MAKE_PAIR32(data->mapid,i)][cell_id]; + cell_guids.creatures.insert(guid); + } + } +} + +void ObjectMgr::RemoveCreatureFromGrid(uint32 guid, CreatureData const* data) +{ + uint8 mask = data->spawnMask; + for(uint8 i = 0; mask != 0; i++, mask >>= 1) + { + if(mask & 1) + { + CellPair cell_pair = MaNGOS::ComputeCellPair(data->posX, data->posY); + uint32 cell_id = (cell_pair.y_coord*TOTAL_NUMBER_OF_CELLS_PER_MAP) + cell_pair.x_coord; + + CellObjectGuids& cell_guids = mMapObjectGuids[MAKE_PAIR32(data->mapid,i)][cell_id]; + cell_guids.creatures.erase(guid); + } + } +} + +void ObjectMgr::LoadGameobjects() +{ + uint32 count = 0; + + // 0 1 2 3 4 5 6 + QueryResult *result = WorldDatabase.Query("SELECT gameobject.guid, id, map, position_x, position_y, position_z, orientation," + // 7 8 9 10 11 12 13 14 15 + "rotation0, rotation1, rotation2, rotation3, spawntimesecs, animprogress, state, spawnMask, event " + "FROM gameobject LEFT OUTER JOIN game_event_gameobject ON gameobject.guid = game_event_gameobject.guid"); + + if(!result) + { + barGoLink bar(1); + + bar.step(); + + sLog.outString(); + sLog.outErrorDb(">> Loaded 0 gameobjects. DB table `gameobject` is empty."); + return; + } + + barGoLink bar(result->GetRowCount()); + + do + { + Field *fields = result->Fetch(); + bar.step(); + + uint32 guid = fields[0].GetUInt32(); + + GameObjectData& data = mGameObjectDataMap[guid]; + + data.id = fields[ 1].GetUInt32(); + data.mapid = fields[ 2].GetUInt32(); + data.posX = fields[ 3].GetFloat(); + data.posY = fields[ 4].GetFloat(); + data.posZ = fields[ 5].GetFloat(); + data.orientation = fields[ 6].GetFloat(); + data.rotation0 = fields[ 7].GetFloat(); + data.rotation1 = fields[ 8].GetFloat(); + data.rotation2 = fields[ 9].GetFloat(); + data.rotation3 = fields[10].GetFloat(); + data.spawntimesecs = fields[11].GetInt32(); + data.animprogress = fields[12].GetUInt32(); + data.go_state = fields[13].GetUInt32(); + data.spawnMask = fields[14].GetUInt8(); + int16 gameEvent = fields[15].GetInt16(); + + GameObjectInfo const* gInfo = GetGameObjectInfo(data.id); + if(!gInfo) + { + sLog.outErrorDb("Table `gameobject` have gameobject (GUID: %u) with not existed gameobject entry %u, skipped.",guid,data.id ); + continue; + } + + if (gameEvent==0) // if not this is to be managed by GameEvent System + AddGameobjectToGrid(guid, &data); + ++count; + + } while (result->NextRow()); + + delete result; + + sLog.outString(); + sLog.outString( ">> Loaded %u gameobjects", mGameObjectDataMap.size()); +} + +void ObjectMgr::AddGameobjectToGrid(uint32 guid, GameObjectData const* data) +{ + uint8 mask = data->spawnMask; + for(uint8 i = 0; mask != 0; i++, mask >>= 1) + { + if(mask & 1) + { + CellPair cell_pair = MaNGOS::ComputeCellPair(data->posX, data->posY); + uint32 cell_id = (cell_pair.y_coord*TOTAL_NUMBER_OF_CELLS_PER_MAP) + cell_pair.x_coord; + + CellObjectGuids& cell_guids = mMapObjectGuids[MAKE_PAIR32(data->mapid,i)][cell_id]; + cell_guids.gameobjects.insert(guid); + } + } +} + +void ObjectMgr::RemoveGameobjectFromGrid(uint32 guid, GameObjectData const* data) +{ + uint8 mask = data->spawnMask; + for(uint8 i = 0; mask != 0; i++, mask >>= 1) + { + if(mask & 1) + { + CellPair cell_pair = MaNGOS::ComputeCellPair(data->posX, data->posY); + uint32 cell_id = (cell_pair.y_coord*TOTAL_NUMBER_OF_CELLS_PER_MAP) + cell_pair.x_coord; + + CellObjectGuids& cell_guids = mMapObjectGuids[MAKE_PAIR32(data->mapid,i)][cell_id]; + cell_guids.gameobjects.erase(guid); + } + } +} + +void ObjectMgr::LoadCreatureRespawnTimes() +{ + // remove outdated data + WorldDatabase.DirectExecute("DELETE FROM creature_respawn WHERE respawntime <= UNIX_TIMESTAMP(NOW())"); + + uint32 count = 0; + + QueryResult *result = WorldDatabase.Query("SELECT guid,respawntime,instance FROM creature_respawn"); + + if(!result) + { + barGoLink bar(1); + + bar.step(); + + sLog.outString(); + sLog.outString(">> Loaded 0 creature respawn time."); + return; + } + + barGoLink bar(result->GetRowCount()); + + do + { + Field *fields = result->Fetch(); + bar.step(); + + uint32 loguid = fields[0].GetUInt32(); + uint64 respawn_time = fields[1].GetUInt64(); + uint32 instance = fields[2].GetUInt32(); + + mCreatureRespawnTimes[MAKE_PAIR64(loguid,instance)] = time_t(respawn_time); + + ++count; + } while (result->NextRow()); + + delete result; + + sLog.outString( ">> Loaded %u creature respawn times", mCreatureRespawnTimes.size() ); + sLog.outString(); +} + +void ObjectMgr::LoadGameobjectRespawnTimes() +{ + // remove outdated data + WorldDatabase.DirectExecute("DELETE FROM gameobject_respawn WHERE respawntime <= UNIX_TIMESTAMP(NOW())"); + + uint32 count = 0; + + QueryResult *result = WorldDatabase.Query("SELECT guid,respawntime,instance FROM gameobject_respawn"); + + if(!result) + { + barGoLink bar(1); + + bar.step(); + + sLog.outString(); + sLog.outString(">> Loaded 0 gameobject respawn time."); + return; + } + + barGoLink bar(result->GetRowCount()); + + do + { + Field *fields = result->Fetch(); + bar.step(); + + uint32 loguid = fields[0].GetUInt32(); + uint64 respawn_time = fields[1].GetUInt64(); + uint32 instance = fields[2].GetUInt32(); + + mGORespawnTimes[MAKE_PAIR64(loguid,instance)] = time_t(respawn_time); + + ++count; + } while (result->NextRow()); + + delete result; + + sLog.outString( ">> Loaded %u gameobject respawn times", mGORespawnTimes.size() ); + sLog.outString(); +} + +// name must be checked to correctness (if received) before call this function +uint64 ObjectMgr::GetPlayerGUIDByName(std::string name) const +{ + uint64 guid = 0; + + CharacterDatabase.escape_string(name); + + // Player name safe to sending to DB (checked at login) and this function using + QueryResult *result = CharacterDatabase.PQuery("SELECT guid FROM characters WHERE name = '%s'", name.c_str()); + if(result) + { + guid = MAKE_NEW_GUID((*result)[0].GetUInt32(), 0, HIGHGUID_PLAYER); + + delete result; + } + + return guid; +} + +bool ObjectMgr::GetPlayerNameByGUID(const uint64 &guid, std::string &name) const +{ + // prevent DB access for online player + if(Player* player = GetPlayer(guid)) + { + name = player->GetName(); + return true; + } + + QueryResult *result = CharacterDatabase.PQuery("SELECT name FROM characters WHERE guid = '%u'", GUID_LOPART(guid)); + + if(result) + { + name = (*result)[0].GetCppString(); + delete result; + return true; + } + + return false; +} + +uint32 ObjectMgr::GetPlayerTeamByGUID(const uint64 &guid) const +{ + QueryResult *result = CharacterDatabase.PQuery("SELECT race FROM characters WHERE guid = '%u'", GUID_LOPART(guid)); + + if(result) + { + uint8 race = (*result)[0].GetUInt8(); + delete result; + return Player::TeamForRace(race); + } + + return 0; +} + +uint32 ObjectMgr::GetPlayerAccountIdByGUID(const uint64 &guid) const +{ + QueryResult *result = CharacterDatabase.PQuery("SELECT account FROM characters WHERE guid = '%u'", GUID_LOPART(guid)); + if(result) + { + uint32 acc = (*result)[0].GetUInt32(); + delete result; + return acc; + } + + return 0; +} + +uint32 ObjectMgr::GetSecurityByAccount(uint32 acc_id) const +{ + QueryResult *result = loginDatabase.PQuery("SELECT gmlevel FROM account WHERE id = '%u'", acc_id); + if(result) + { + uint32 sec = (*result)[0].GetUInt32(); + delete result; + return sec; + } + + return 0; +} + +bool ObjectMgr::GetAccountNameByAccount(uint32 acc_id, std::string &name) const +{ + QueryResult *result = loginDatabase.PQuery("SELECT username FROM account WHERE id = '%u'", acc_id); + if(result) + { + name = (*result)[0].GetCppString(); + delete result; + return true; + } + + return false; +} + +uint32 ObjectMgr::GetAccountByAccountName(std::string name) const +{ + loginDatabase.escape_string(name); + QueryResult *result = loginDatabase.PQuery("SELECT id FROM account WHERE username = '%s'", name.c_str()); + if(result) + { + uint32 id = (*result)[0].GetUInt32(); + delete result; + return id; + } + + return 0; +} + +void ObjectMgr::LoadAuctions() +{ + QueryResult *result = CharacterDatabase.Query("SELECT COUNT(*) FROM auctionhouse"); + if( !result ) + return; + + Field *fields = result->Fetch(); + uint32 AuctionCount=fields[0].GetUInt32(); + delete result; + + if(!AuctionCount) + return; + + result = CharacterDatabase.Query( "SELECT id,auctioneerguid,itemguid,item_template,itemowner,buyoutprice,time,buyguid,lastbid,startbid,deposit,location FROM auctionhouse" ); + if( !result ) + return; + + barGoLink bar( AuctionCount ); + + AuctionEntry *aItem; + + do + { + fields = result->Fetch(); + + bar.step(); + + aItem = new AuctionEntry; + aItem->Id = fields[0].GetUInt32(); + aItem->auctioneer = fields[1].GetUInt32(); + aItem->item_guidlow = fields[2].GetUInt32(); + aItem->item_template = fields[3].GetUInt32(); + aItem->owner = fields[4].GetUInt32(); + aItem->buyout = fields[5].GetUInt32(); + aItem->time = fields[6].GetUInt32(); + aItem->bidder = fields[7].GetUInt32(); + aItem->bid = fields[8].GetUInt32(); + aItem->startbid = fields[9].GetUInt32(); + aItem->deposit = fields[10].GetUInt32(); + aItem->location = fields[11].GetUInt8(); + //check if sold item exists + if ( this->GetAItem( aItem->item_guidlow ) ) + { + GetAuctionsMap( aItem->location )->AddAuction(aItem); + } + else + { + CharacterDatabase.PExecute("DELETE FROM auctionhouse WHERE id = '%u'",aItem->Id); + sLog.outError("Auction %u has not a existing item : %u", aItem->Id, aItem->item_guidlow); + delete aItem; + } + } while (result->NextRow()); + delete result; + + sLog.outString(); + sLog.outString( ">> Loaded %u auctions", AuctionCount ); + sLog.outString(); +} + +void ObjectMgr::LoadItemLocales() +{ + QueryResult *result = WorldDatabase.Query("SELECT entry,name_loc1,description_loc1,name_loc2,description_loc2,name_loc3,description_loc3,name_loc4,description_loc4,name_loc5,description_loc5,name_loc6,description_loc6,name_loc7,description_loc7,name_loc8,description_loc8 FROM locales_item"); + + if(!result) + { + barGoLink bar(1); + + bar.step(); + + sLog.outString(""); + sLog.outString(">> Loaded 0 Item locale strings. DB table `locales_item` is empty."); + return; + } + + barGoLink bar(result->GetRowCount()); + + do + { + Field *fields = result->Fetch(); + bar.step(); + + uint32 entry = fields[0].GetUInt32(); + + ItemLocale& data = mItemLocaleMap[entry]; + + for(int i = 1; i < MAX_LOCALE; ++i) + { + std::string str = fields[1+2*(i-1)].GetCppString(); + if(!str.empty()) + { + int idx = GetOrNewIndexForLocale(LocaleConstant(i)); + if(idx >= 0) + { + if(data.Name.size() <= idx) + data.Name.resize(idx+1); + + data.Name[idx] = str; + } + } + + str = fields[1+2*(i-1)+1].GetCppString(); + if(!str.empty()) + { + int idx = GetOrNewIndexForLocale(LocaleConstant(i)); + if(idx >= 0) + { + if(data.Description.size() <= idx) + data.Description.resize(idx+1); + + data.Description[idx] = str; + } + } + } + } while (result->NextRow()); + + delete result; + + sLog.outString(); + sLog.outString( ">> Loaded %u Item locale strings", mItemLocaleMap.size() ); +} + +void ObjectMgr::LoadItemPrototypes() +{ + sItemStorage.Load (); + sLog.outString( ">> Loaded %u item prototypes", sItemStorage.RecordCount ); + sLog.outString(); + + // check data correctness + for(uint32 i = 1; i < sItemStorage.MaxEntry; ++i) + { + ItemPrototype const* proto = sItemStorage.LookupEntry(i); + ItemEntry const *dbcitem = sItemStore.LookupEntry(i); + if(!proto) + { + /* to many errors, and possible not all items really used in game + if (dbcitem) + sLog.outErrorDb("Item (Entry: %u) doesn't exists in DB, but must exist.",i); + */ + continue; + } + + if(dbcitem) + { + if(proto->InventoryType != dbcitem->InventoryType) + { + sLog.outErrorDb("Item (Entry: %u) not correct %u inventory type, must be %u (still using DB value).",i,proto->InventoryType,dbcitem->InventoryType); + // It safe let use InventoryType from DB + } + + if(proto->DisplayInfoID != dbcitem->DisplayId) + { + sLog.outErrorDb("Item (Entry: %u) not correct %u display id, must be %u (using it).",i,proto->DisplayInfoID,dbcitem->DisplayId); + const_cast(proto)->DisplayInfoID = dbcitem->DisplayId; + } + if(proto->Sheath != dbcitem->Sheath) + { + sLog.outErrorDb("Item (Entry: %u) not correct %u sheath, must be %u (using it).",i,proto->Sheath,dbcitem->Sheath); + const_cast(proto)->Sheath = dbcitem->Sheath; + } + } + else + { + sLog.outErrorDb("Item (Entry: %u) not correct (not listed in list of existed items).",i); + } + + if(proto->Class >= MAX_ITEM_CLASS) + { + sLog.outErrorDb("Item (Entry: %u) has wrong Class value (%u)",i,proto->Class); + const_cast(proto)->Class = ITEM_CLASS_JUNK; + } + + if(proto->SubClass >= MaxItemSubclassValues[proto->Class]) + { + sLog.outErrorDb("Item (Entry: %u) has wrong Subclass value (%u) for class %u",i,proto->SubClass,proto->Class); + const_cast(proto)->SubClass = 0;// exist for all item classes + } + + if(proto->Quality >= MAX_ITEM_QUALITY) + { + sLog.outErrorDb("Item (Entry: %u) has wrong Quality value (%u)",i,proto->Quality); + const_cast(proto)->Quality = ITEM_QUALITY_NORMAL; + } + + if(proto->BuyCount <= 0) + { + sLog.outErrorDb("Item (Entry: %u) has wrong BuyCount value (%u), set to default(1).",i,proto->BuyCount); + const_cast(proto)->BuyCount = 1; + } + + if(proto->InventoryType >= MAX_INVTYPE) + { + sLog.outErrorDb("Item (Entry: %u) has wrong InventoryType value (%u)",i,proto->InventoryType); + const_cast(proto)->InventoryType = INVTYPE_NON_EQUIP; + } + + if(proto->RequiredSkill >= MAX_SKILL_TYPE) + { + sLog.outErrorDb("Item (Entry: %u) has wrong RequiredSkill value (%u)",i,proto->RequiredSkill); + const_cast(proto)->RequiredSkill = 0; + } + + if(!(proto->AllowableClass & CLASSMASK_ALL_PLAYABLE)) + { + sLog.outErrorDb("Item (Entry: %u) not have in `AllowableClass` any playable classes (%u) and can't be equipped.",i,proto->AllowableClass); + } + + if(!(proto->AllowableRace & RACEMASK_ALL_PLAYABLE)) + { + sLog.outErrorDb("Item (Entry: %u) not have in `AllowableRace` any playable races (%u) and can't be equipped.",i,proto->AllowableRace); + } + + if(proto->RequiredSpell && !sSpellStore.LookupEntry(proto->RequiredSpell)) + { + sLog.outErrorDb("Item (Entry: %u) have wrong (non-existed) spell in RequiredSpell (%u)",i,proto->RequiredSpell); + const_cast(proto)->RequiredSpell = 0; + } + + if(proto->RequiredReputationRank >= MAX_REPUTATION_RANK) + sLog.outErrorDb("Item (Entry: %u) has wrong reputation rank in RequiredReputationRank (%u), item can't be used.",i,proto->RequiredReputationRank); + + if(proto->RequiredReputationFaction) + { + if(!sFactionStore.LookupEntry(proto->RequiredReputationFaction)) + { + sLog.outErrorDb("Item (Entry: %u) has wrong (not existing) faction in RequiredReputationFaction (%u)",i,proto->RequiredReputationFaction); + const_cast(proto)->RequiredReputationFaction = 0; + } + + if(proto->RequiredReputationRank == MIN_REPUTATION_RANK) + sLog.outErrorDb("Item (Entry: %u) has min. reputation rank in RequiredReputationRank (0) but RequiredReputationFaction > 0, faction setting is useless.",i); + } + else if(proto->RequiredReputationRank > MIN_REPUTATION_RANK) + sLog.outErrorDb("Item (Entry: %u) has RequiredReputationFaction ==0 but RequiredReputationRank > 0, rank setting is useless.",i); + + if(proto->Stackable==0) + { + sLog.outErrorDb("Item (Entry: %u) has wrong value in stackable (%u), replace by default 1.",i,proto->Stackable); + const_cast(proto)->Stackable = 1; + } + else if(proto->Stackable > 255) + { + sLog.outErrorDb("Item (Entry: %u) has too large value in stackable (%u), replace by hardcoded upper limit (255).",i,proto->Stackable); + const_cast(proto)->Stackable = 255; + } + + for (int j = 0; j < 10; j++) + { + // for ItemStatValue != 0 + if(proto->ItemStat[j].ItemStatValue && proto->ItemStat[j].ItemStatType >= MAX_ITEM_MOD) + { + sLog.outErrorDb("Item (Entry: %u) has wrong stat_type%d (%u)",i,j+1,proto->ItemStat[j].ItemStatType); + const_cast(proto)->ItemStat[j].ItemStatType = 0; + } + } + + for (int j = 0; j < 5; j++) + { + if(proto->Damage[j].DamageType >= MAX_SPELL_SCHOOL) + { + sLog.outErrorDb("Item (Entry: %u) has wrong dmg_type%d (%u)",i,j+1,proto->Damage[j].DamageType); + const_cast(proto)->Damage[j].DamageType = 0; + } + } + + // special format + if(proto->Spells[0].SpellId == SPELL_ID_GENERIC_LEARN) + { + // spell_1 + if(proto->Spells[0].SpellTrigger != ITEM_SPELLTRIGGER_ON_USE) + { + sLog.outErrorDb("Item (Entry: %u) has wrong item spell trigger value in spelltrigger_%d (%u) for special learning format",i,0+1,proto->Spells[0].SpellTrigger); + const_cast(proto)->Spells[0].SpellId = 0; + const_cast(proto)->Spells[0].SpellTrigger = ITEM_SPELLTRIGGER_ON_USE; + const_cast(proto)->Spells[1].SpellId = 0; + const_cast(proto)->Spells[1].SpellTrigger = ITEM_SPELLTRIGGER_ON_USE; + } + + // spell_2 have learning spell + if(proto->Spells[1].SpellTrigger != ITEM_SPELLTRIGGER_LEARN_SPELL_ID) + { + sLog.outErrorDb("Item (Entry: %u) has wrong item spell trigger value in spelltrigger_%d (%u) for special learning format.",i,1+1,proto->Spells[1].SpellTrigger); + const_cast(proto)->Spells[0].SpellId = 0; + const_cast(proto)->Spells[1].SpellId = 0; + const_cast(proto)->Spells[1].SpellTrigger = ITEM_SPELLTRIGGER_ON_USE; + } + else if(!proto->Spells[1].SpellId) + { + sLog.outErrorDb("Item (Entry: %u) not has expected spell in spellid_%d in special learning format.",i,1+1); + const_cast(proto)->Spells[0].SpellId = 0; + const_cast(proto)->Spells[1].SpellTrigger = ITEM_SPELLTRIGGER_ON_USE; + } + else + { + SpellEntry const* spellInfo = sSpellStore.LookupEntry(proto->Spells[1].SpellId); + if(!spellInfo) + { + sLog.outErrorDb("Item (Entry: %u) has wrong (not existing) spell in spellid_%d (%u)",i,1+1,proto->Spells[1].SpellId); + const_cast(proto)->Spells[0].SpellId = 0; + const_cast(proto)->Spells[1].SpellId = 0; + const_cast(proto)->Spells[1].SpellTrigger = ITEM_SPELLTRIGGER_ON_USE; + } + // allowed only in special format + else if(proto->Spells[1].SpellId==SPELL_ID_GENERIC_LEARN) + { + sLog.outErrorDb("Item (Entry: %u) has broken spell in spellid_%d (%u)",i,1+1,proto->Spells[1].SpellId); + const_cast(proto)->Spells[0].SpellId = 0; + const_cast(proto)->Spells[1].SpellId = 0; + const_cast(proto)->Spells[1].SpellTrigger = ITEM_SPELLTRIGGER_ON_USE; + } + } + + // spell_3*,spell_4*,spell_5* is empty + for (int j = 2; j < 5; j++) + { + if(proto->Spells[j].SpellTrigger != ITEM_SPELLTRIGGER_ON_USE) + { + sLog.outErrorDb("Item (Entry: %u) has wrong item spell trigger value in spelltrigger_%d (%u)",i,j+1,proto->Spells[j].SpellTrigger); + const_cast(proto)->Spells[j].SpellId = 0; + const_cast(proto)->Spells[j].SpellTrigger = ITEM_SPELLTRIGGER_ON_USE; + } + else if(proto->Spells[j].SpellId != 0) + { + sLog.outErrorDb("Item (Entry: %u) has wrong spell in spellid_%d (%u) for learning special format",i,j+1,proto->Spells[j].SpellId); + const_cast(proto)->Spells[j].SpellId = 0; + } + } + } + // normal spell list + else + { + for (int j = 0; j < 5; j++) + { + if(proto->Spells[j].SpellTrigger >= MAX_ITEM_SPELLTRIGGER || proto->Spells[j].SpellTrigger == ITEM_SPELLTRIGGER_LEARN_SPELL_ID) + { + sLog.outErrorDb("Item (Entry: %u) has wrong item spell trigger value in spelltrigger_%d (%u)",i,j+1,proto->Spells[j].SpellTrigger); + const_cast(proto)->Spells[j].SpellId = 0; + const_cast(proto)->Spells[j].SpellTrigger = ITEM_SPELLTRIGGER_ON_USE; + } + + if(proto->Spells[j].SpellId) + { + SpellEntry const* spellInfo = sSpellStore.LookupEntry(proto->Spells[j].SpellId); + if(!spellInfo) + { + sLog.outErrorDb("Item (Entry: %u) has wrong (not existing) spell in spellid_%d (%u)",i,j+1,proto->Spells[j].SpellId); + const_cast(proto)->Spells[j].SpellId = 0; + } + // allowed only in special format + else if(proto->Spells[j].SpellId==SPELL_ID_GENERIC_LEARN) + { + sLog.outErrorDb("Item (Entry: %u) has broken spell in spellid_%d (%u)",i,j+1,proto->Spells[j].SpellId); + const_cast(proto)->Spells[j].SpellId = 0; + } + } + } + } + + if(proto->Bonding >= MAX_BIND_TYPE) + sLog.outErrorDb("Item (Entry: %u) has wrong Bonding value (%u)",i,proto->Bonding); + + if(proto->PageText && !sPageTextStore.LookupEntry(proto->PageText)) + sLog.outErrorDb("Item (Entry: %u) has non existing first page (Id:%u)", i,proto->PageText); + + if(proto->LockID && !sLockStore.LookupEntry(proto->LockID)) + sLog.outErrorDb("Item (Entry: %u) has wrong LockID (%u)",i,proto->LockID); + + if(proto->Sheath >= MAX_SHEATHETYPE) + { + sLog.outErrorDb("Item (Entry: %u) has wrong Sheath (%u)",i,proto->Sheath); + const_cast(proto)->Sheath = SHEATHETYPE_NONE; + } + + if(proto->RandomProperty && !sItemRandomPropertiesStore.LookupEntry(GetItemEnchantMod(proto->RandomProperty))) + { + sLog.outErrorDb("Item (Entry: %u) has unknown (wrong or not listed in `item_enchantment_template`) RandomProperty (%u)",i,proto->RandomProperty); + const_cast(proto)->RandomProperty = 0; + } + + if(proto->RandomSuffix && !sItemRandomSuffixStore.LookupEntry(GetItemEnchantMod(proto->RandomSuffix))) + { + sLog.outErrorDb("Item (Entry: %u) has wrong RandomSuffix (%u)",i,proto->RandomSuffix); + const_cast(proto)->RandomSuffix = 0; + } + + if(proto->ItemSet && !sItemSetStore.LookupEntry(proto->ItemSet)) + { + sLog.outErrorDb("Item (Entry: %u) have wrong ItemSet (%u)",i,proto->ItemSet); + const_cast(proto)->ItemSet = 0; + } + + if(proto->Area && !GetAreaEntryByAreaID(proto->Area)) + sLog.outErrorDb("Item (Entry: %u) has wrong Area (%u)",i,proto->Area); + + if(proto->Map && !sMapStore.LookupEntry(proto->Map)) + sLog.outErrorDb("Item (Entry: %u) has wrong Map (%u)",i,proto->Map); + + if(proto->TotemCategory && !sTotemCategoryStore.LookupEntry(proto->TotemCategory)) + sLog.outErrorDb("Item (Entry: %u) has wrong TotemCategory (%u)",i,proto->TotemCategory); + + for (int j = 0; j < 3; j++) + { + if(proto->Socket[j].Color && (proto->Socket[j].Color & SOCKET_COLOR_ALL) != proto->Socket[j].Color) + { + sLog.outErrorDb("Item (Entry: %u) has wrong socketColor_%d (%u)",i,j+1,proto->Socket[j].Color); + const_cast(proto)->Socket[j].Color = 0; + } + } + + if(proto->GemProperties && !sGemPropertiesStore.LookupEntry(proto->GemProperties)) + sLog.outErrorDb("Item (Entry: %u) has wrong GemProperties (%u)",i,proto->GemProperties); + + if(proto->FoodType >= MAX_PET_DIET) + { + sLog.outErrorDb("Item (Entry: %u) has wrong FoodType value (%u)",i,proto->FoodType); + const_cast(proto)->FoodType = 0; + } + } + + // this DBC used currently only for check item templates in DB. + sItemStore.Clear(); +} + +void ObjectMgr::LoadAuctionItems() +{ + QueryResult *result = CharacterDatabase.Query( "SELECT itemguid,item_template FROM auctionhouse" ); + + if( !result ) + return; + + barGoLink bar( result->GetRowCount() ); + + uint32 count = 0; + + Field *fields; + do + { + bar.step(); + + fields = result->Fetch(); + uint32 item_guid = fields[0].GetUInt32(); + uint32 item_template = fields[1].GetUInt32(); + + ItemPrototype const *proto = GetItemPrototype(item_template); + + if(!proto) + { + sLog.outError( "ObjectMgr::LoadAuctionItems: Unknown item (GUID: %u id: #%u) in auction, skipped.", item_guid,item_template); + continue; + } + + Item *item = NewItemOrBag(proto); + + if(!item->LoadFromDB(item_guid,0)) + { + delete item; + continue; + } + AddAItem(item); + + ++count; + } + while( result->NextRow() ); + + delete result; + + sLog.outString(); + sLog.outString( ">> Loaded %u auction items", count ); +} + +void ObjectMgr::LoadPetLevelInfo() +{ + // Loading levels data + { + // 0 1 2 3 4 5 6 7 8 9 + QueryResult *result = WorldDatabase.Query("SELECT creature_entry, level, hp, mana, str, agi, sta, inte, spi, armor FROM pet_levelstats"); + + uint32 count = 0; + + if (!result) + { + barGoLink bar( 1 ); + + sLog.outString(); + sLog.outString( ">> Loaded %u level pet stats definitions", count ); + sLog.outErrorDb( "Error loading `pet_levelstats` table or empty table."); + return; + } + + barGoLink bar( result->GetRowCount() ); + + do + { + Field* fields = result->Fetch(); + + uint32 creature_id = fields[0].GetUInt32(); + if(!sCreatureStorage.LookupEntry(creature_id)) + { + sLog.outErrorDb("Wrong creature id %u in `pet_levelstats` table, ignoring.",creature_id); + continue; + } + + uint32 current_level = fields[1].GetUInt32(); + if(current_level > sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL)) + { + if(current_level > 255) // hardcoded level maximum + sLog.outErrorDb("Wrong (> 255) level %u in `pet_levelstats` table, ignoring.",current_level); + else + sLog.outDetail("Unused (> MaxPlayerLevel in mangosd.conf) level %u in `pet_levelstats` table, ignoring.",current_level); + continue; + } + else if(current_level < 1) + { + sLog.outErrorDb("Wrong (<1) level %u in `pet_levelstats` table, ignoring.",current_level); + continue; + } + + PetLevelInfo*& pInfoMapEntry = petInfo[creature_id]; + + if(pInfoMapEntry==NULL) + pInfoMapEntry = new PetLevelInfo[sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL)]; + + // data for level 1 stored in [0] array element, ... + PetLevelInfo* pLevelInfo = &pInfoMapEntry[current_level-1]; + + pLevelInfo->health = fields[2].GetUInt16(); + pLevelInfo->mana = fields[3].GetUInt16(); + pLevelInfo->armor = fields[9].GetUInt16(); + + for (int i = 0; i < MAX_STATS; i++) + { + pLevelInfo->stats[i] = fields[i+4].GetUInt16(); + } + + bar.step(); + ++count; + } + while (result->NextRow()); + + delete result; + + sLog.outString(); + sLog.outString( ">> Loaded %u level pet stats definitions", count ); + } + + // Fill gaps and check integrity + for (PetLevelInfoMap::iterator itr = petInfo.begin(); itr != petInfo.end(); ++itr) + { + PetLevelInfo* pInfo = itr->second; + + // fatal error if no level 1 data + if(!pInfo || pInfo[0].health == 0 ) + { + sLog.outErrorDb("Creature %u does not have pet stats data for Level 1!",itr->first); + exit(1); + } + + // fill level gaps + for (uint32 level = 1; level < sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL); ++level) + { + if(pInfo[level].health == 0) + { + sLog.outErrorDb("Creature %u has no data for Level %i pet stats data, using data of Level %i.",itr->first,level+1, level); + pInfo[level] = pInfo[level-1]; + } + } + } +} + +PetLevelInfo const* ObjectMgr::GetPetLevelInfo(uint32 creature_id, uint32 level) const +{ + if(level > sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL)) + level = sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL); + + PetLevelInfoMap::const_iterator itr = petInfo.find(creature_id); + if(itr == petInfo.end()) + return NULL; + + return &itr->second[level-1]; // data for level 1 stored in [0] array element, ... +} + +void ObjectMgr::LoadPlayerInfo() +{ + // Load playercreate + { + // 0 1 2 3 4 5 6 + QueryResult *result = WorldDatabase.Query("SELECT race, class, map, zone, position_x, position_y, position_z FROM playercreateinfo"); + + uint32 count = 0; + + if (!result) + { + barGoLink bar( 1 ); + + sLog.outString(); + sLog.outString( ">> Loaded %u player create definitions", count ); + sLog.outErrorDb( "Error loading `playercreateinfo` table or empty table."); + exit(1); + } + + barGoLink bar( result->GetRowCount() ); + + do + { + Field* fields = result->Fetch(); + + uint32 current_race = fields[0].GetUInt32(); + uint32 current_class = fields[1].GetUInt32(); + uint32 mapId = fields[2].GetUInt32(); + uint32 zoneId = fields[3].GetUInt32(); + float positionX = fields[4].GetFloat(); + float positionY = fields[5].GetFloat(); + float positionZ = fields[6].GetFloat(); + + if(current_race >= MAX_RACES) + { + sLog.outErrorDb("Wrong race %u in `playercreateinfo` table, ignoring.",current_race); + continue; + } + + ChrRacesEntry const* rEntry = sChrRacesStore.LookupEntry(current_race); + if(!rEntry) + { + sLog.outErrorDb("Wrong race %u in `playercreateinfo` table, ignoring.",current_race); + continue; + } + + if(current_class >= MAX_CLASSES) + { + sLog.outErrorDb("Wrong class %u in `playercreateinfo` table, ignoring.",current_class); + continue; + } + + if(!sChrClassesStore.LookupEntry(current_class)) + { + sLog.outErrorDb("Wrong class %u in `playercreateinfo` table, ignoring.",current_class); + continue; + } + + // accept DB data only for valid position (and non instanceable) + if( !MapManager::IsValidMapCoord(mapId,positionX,positionY,positionZ) ) + { + sLog.outErrorDb("Wrong home position for class %u race %u pair in `playercreateinfo` table, ignoring.",current_class,current_race); + continue; + } + + if( sMapStore.LookupEntry(mapId)->Instanceable() ) + { + sLog.outErrorDb("Home position in instanceable map for class %u race %u pair in `playercreateinfo` table, ignoring.",current_class,current_race); + continue; + } + + PlayerInfo* pInfo = &playerInfo[current_race][current_class]; + + pInfo->mapId = mapId; + pInfo->zoneId = zoneId; + pInfo->positionX = positionX; + pInfo->positionY = positionY; + pInfo->positionZ = positionZ; + + pInfo->displayId_m = rEntry->model_m; + pInfo->displayId_f = rEntry->model_f; + + bar.step(); + ++count; + } + while (result->NextRow()); + + delete result; + + sLog.outString(); + sLog.outString( ">> Loaded %u player create definitions", count ); + } + + // Load playercreate items + { + // 0 1 2 3 + QueryResult *result = WorldDatabase.Query("SELECT race, class, itemid, amount FROM playercreateinfo_item"); + + uint32 count = 0; + + if (!result) + { + barGoLink bar( 1 ); + + sLog.outString(); + sLog.outString( ">> Loaded %u player create items", count ); + sLog.outErrorDb( "Error loading `playercreateinfo_item` table or empty table."); + } + else + { + barGoLink bar( result->GetRowCount() ); + + do + { + Field* fields = result->Fetch(); + + uint32 current_race = fields[0].GetUInt32(); + if(current_race >= MAX_RACES) + { + sLog.outErrorDb("Wrong race %u in `playercreateinfo_item` table, ignoring.",current_race); + continue; + } + + uint32 current_class = fields[1].GetUInt32(); + if(current_class >= MAX_CLASSES) + { + sLog.outErrorDb("Wrong class %u in `playercreateinfo_item` table, ignoring.",current_class); + continue; + } + + PlayerInfo* pInfo = &playerInfo[current_race][current_class]; + + uint32 item_id = fields[2].GetUInt32(); + + if(!GetItemPrototype(item_id)) + { + sLog.outErrorDb("Item id %u (race %u class %u) in `playercreateinfo_item` table but not listed in `item_template`, ignoring.",item_id,current_race,current_class); + continue; + } + + uint32 amount = fields[3].GetUInt32(); + + if(!amount) + { + sLog.outErrorDb("Item id %u (class %u race %u) have amount==0 in `playercreateinfo_item` table, ignoring.",item_id,current_race,current_class); + continue; + } + + pInfo->item.push_back(PlayerCreateInfoItem( item_id, amount)); + + bar.step(); + ++count; + } + while(result->NextRow()); + + delete result; + + sLog.outString(); + sLog.outString( ">> Loaded %u player create items", count ); + } + } + + // Load playercreate spells + { + // 0 1 2 3 + QueryResult *result = WorldDatabase.Query("SELECT race, class, Spell, Active FROM playercreateinfo_spell"); + + uint32 count = 0; + + if (!result) + { + barGoLink bar( 1 ); + + sLog.outString(); + sLog.outString( ">> Loaded %u player create spells", count ); + sLog.outErrorDb( "Error loading `playercreateinfo_spell` table or empty table."); + } + else + { + barGoLink bar( result->GetRowCount() ); + + do + { + Field* fields = result->Fetch(); + + uint32 current_race = fields[0].GetUInt32(); + if(current_race >= MAX_RACES) + { + sLog.outErrorDb("Wrong race %u in `playercreateinfo_spell` table, ignoring.",current_race); + continue; + } + + uint32 current_class = fields[1].GetUInt32(); + if(current_class >= MAX_CLASSES) + { + sLog.outErrorDb("Wrong class %u in `playercreateinfo_spell` table, ignoring.",current_class); + continue; + } + + PlayerInfo* pInfo = &playerInfo[current_race][current_class]; + pInfo->spell.push_back(CreateSpellPair(fields[2].GetUInt16(), fields[3].GetUInt8())); + + bar.step(); + ++count; + } + while( result->NextRow() ); + + delete result; + + sLog.outString(); + sLog.outString( ">> Loaded %u player create spells", count ); + } + } + + // Load playercreate actions + { + // 0 1 2 3 4 5 + QueryResult *result = WorldDatabase.Query("SELECT race, class, button, action, type, misc FROM playercreateinfo_action"); + + uint32 count = 0; + + if (!result) + { + barGoLink bar( 1 ); + + sLog.outString(); + sLog.outString( ">> Loaded %u player create actions", count ); + sLog.outErrorDb( "Error loading `playercreateinfo_action` table or empty table."); + } + else + { + barGoLink bar( result->GetRowCount() ); + + do + { + Field* fields = result->Fetch(); + + uint32 current_race = fields[0].GetUInt32(); + if(current_race >= MAX_RACES) + { + sLog.outErrorDb("Wrong race %u in `playercreateinfo_action` table, ignoring.",current_race); + continue; + } + + uint32 current_class = fields[1].GetUInt32(); + if(current_class >= MAX_CLASSES) + { + sLog.outErrorDb("Wrong class %u in `playercreateinfo_action` table, ignoring.",current_class); + continue; + } + + PlayerInfo* pInfo = &playerInfo[current_race][current_class]; + pInfo->action[0].push_back(fields[2].GetUInt16()); + pInfo->action[1].push_back(fields[3].GetUInt16()); + pInfo->action[2].push_back(fields[4].GetUInt16()); + pInfo->action[3].push_back(fields[5].GetUInt16()); + + bar.step(); + ++count; + } + while( result->NextRow() ); + + delete result; + + sLog.outString(); + sLog.outString( ">> Loaded %u player create actions", count ); + } + } + + // Loading levels data (class only dependent) + { + // 0 1 2 3 + QueryResult *result = WorldDatabase.Query("SELECT class, level, basehp, basemana FROM player_classlevelstats"); + + uint32 count = 0; + + if (!result) + { + barGoLink bar( 1 ); + + sLog.outString(); + sLog.outString( ">> Loaded %u level health/mana definitions", count ); + sLog.outErrorDb( "Error loading `player_classlevelstats` table or empty table."); + exit(1); + } + + barGoLink bar( result->GetRowCount() ); + + do + { + Field* fields = result->Fetch(); + + uint32 current_class = fields[0].GetUInt32(); + if(current_class >= MAX_CLASSES) + { + sLog.outErrorDb("Wrong class %u in `player_classlevelstats` table, ignoring.",current_class); + continue; + } + + uint32 current_level = fields[1].GetUInt32(); + if(current_level > sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL)) + { + if(current_level > 255) // hardcoded level maximum + sLog.outErrorDb("Wrong (> 255) level %u in `player_classlevelstats` table, ignoring.",current_level); + else + sLog.outDetail("Unused (> MaxPlayerLevel in mangosd.conf) level %u in `player_classlevelstats` table, ignoring.",current_level); + continue; + } + + PlayerClassInfo* pClassInfo = &playerClassInfo[current_class]; + + if(!pClassInfo->levelInfo) + pClassInfo->levelInfo = new PlayerClassLevelInfo[sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL)]; + + PlayerClassLevelInfo* pClassLevelInfo = &pClassInfo->levelInfo[current_level-1]; + + pClassLevelInfo->basehealth = fields[2].GetUInt16(); + pClassLevelInfo->basemana = fields[3].GetUInt16(); + + bar.step(); + ++count; + } + while (result->NextRow()); + + delete result; + + sLog.outString(); + sLog.outString( ">> Loaded %u level health/mana definitions", count ); + } + + // Fill gaps and check integrity + for (int class_ = 0; class_ < MAX_CLASSES; ++class_) + { + // skip non existed classes + if(!sChrClassesStore.LookupEntry(class_)) + continue; + + PlayerClassInfo* pClassInfo = &playerClassInfo[class_]; + + // fatal error if no level 1 data + if(!pClassInfo->levelInfo || pClassInfo->levelInfo[0].basehealth == 0 ) + { + sLog.outErrorDb("Class %i Level 1 does not have health/mana data!",class_); + exit(1); + } + + // fill level gaps + for (uint32 level = 1; level < sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL); ++level) + { + if(pClassInfo->levelInfo[level].basehealth == 0) + { + sLog.outErrorDb("Class %i Level %i does not have health/mana data. Using stats data of level %i.",class_,level+1, level); + pClassInfo->levelInfo[level] = pClassInfo->levelInfo[level-1]; + } + } + } + + // Loading levels data (class/race dependent) + { + // 0 1 2 3 4 5 6 7 + QueryResult *result = WorldDatabase.Query("SELECT race, class, level, str, agi, sta, inte, spi FROM player_levelstats"); + + uint32 count = 0; + + if (!result) + { + barGoLink bar( 1 ); + + sLog.outString(); + sLog.outString( ">> Loaded %u level stats definitions", count ); + sLog.outErrorDb( "Error loading `player_levelstats` table or empty table."); + exit(1); + } + + barGoLink bar( result->GetRowCount() ); + + do + { + Field* fields = result->Fetch(); + + uint32 current_race = fields[0].GetUInt32(); + if(current_race >= MAX_RACES) + { + sLog.outErrorDb("Wrong race %u in `player_levelstats` table, ignoring.",current_race); + continue; + } + + uint32 current_class = fields[1].GetUInt32(); + if(current_class >= MAX_CLASSES) + { + sLog.outErrorDb("Wrong class %u in `player_levelstats` table, ignoring.",current_class); + continue; + } + + uint32 current_level = fields[2].GetUInt32(); + if(current_level > sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL)) + { + if(current_level > 255) // hardcoded level maximum + sLog.outErrorDb("Wrong (> 255) level %u in `player_levelstats` table, ignoring.",current_level); + else + sLog.outDetail("Unused (> MaxPlayerLevel in mangosd.conf) level %u in `player_levelstats` table, ignoring.",current_level); + continue; + } + + PlayerInfo* pInfo = &playerInfo[current_race][current_class]; + + if(!pInfo->levelInfo) + pInfo->levelInfo = new PlayerLevelInfo[sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL)]; + + PlayerLevelInfo* pLevelInfo = &pInfo->levelInfo[current_level-1]; + + for (int i = 0; i < MAX_STATS; i++) + { + pLevelInfo->stats[i] = fields[i+3].GetUInt8(); + } + + bar.step(); + ++count; + } + while (result->NextRow()); + + delete result; + + sLog.outString(); + sLog.outString( ">> Loaded %u level stats definitions", count ); + } + + // Fill gaps and check integrity + for (int race = 0; race < MAX_RACES; ++race) + { + // skip non existed races + if(!sChrRacesStore.LookupEntry(race)) + continue; + + for (int class_ = 0; class_ < MAX_CLASSES; ++class_) + { + // skip non existed classes + if(!sChrClassesStore.LookupEntry(class_)) + continue; + + PlayerInfo* pInfo = &playerInfo[race][class_]; + + // skip non loaded combinations + if(!pInfo->displayId_m || !pInfo->displayId_f) + continue; + + // skip expansion races if not playing with expansion + if (sWorld.getConfig(CONFIG_EXPANSION) < 1 && (race == RACE_BLOODELF || race == RACE_DRAENEI)) + continue; + + // fatal error if no level 1 data + if(!pInfo->levelInfo || pInfo->levelInfo[0].stats[0] == 0 ) + { + sLog.outErrorDb("Race %i Class %i Level 1 does not have stats data!",race,class_); + exit(1); + } + + // fill level gaps + for (uint32 level = 1; level < sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL); ++level) + { + if(pInfo->levelInfo[level].stats[0] == 0) + { + sLog.outErrorDb("Race %i Class %i Level %i does not have stats data. Using stats data of level %i.",race,class_,level+1, level); + pInfo->levelInfo[level] = pInfo->levelInfo[level-1]; + } + } + } + } +} + +void ObjectMgr::GetPlayerClassLevelInfo(uint32 class_, uint32 level, PlayerClassLevelInfo* info) const +{ + if(level < 1 || class_ >= MAX_CLASSES) + return; + + PlayerClassInfo const* pInfo = &playerClassInfo[class_]; + + if(level > sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL)) + level = sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL); + + *info = pInfo->levelInfo[level-1]; +} + +void ObjectMgr::GetPlayerLevelInfo(uint32 race, uint32 class_, uint32 level, PlayerLevelInfo* info) const +{ + if(level < 1 || race >= MAX_RACES || class_ >= MAX_CLASSES) + return; + + PlayerInfo const* pInfo = &playerInfo[race][class_]; + if(pInfo->displayId_m==0 || pInfo->displayId_f==0) + return; + + if(level <= sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL)) + *info = pInfo->levelInfo[level-1]; + else + BuildPlayerLevelInfo(race,class_,level,info); +} + +void ObjectMgr::BuildPlayerLevelInfo(uint8 race, uint8 _class, uint8 level, PlayerLevelInfo* info) const +{ + // base data (last known level) + *info = playerInfo[race][_class].levelInfo[sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL)-1]; + + for(int lvl = sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL)-1; lvl < level; ++lvl) + { + switch(_class) + { + case CLASS_WARRIOR: + info->stats[STAT_STRENGTH] += (lvl > 23 ? 2: (lvl > 1 ? 1: 0)); + info->stats[STAT_STAMINA] += (lvl > 23 ? 2: (lvl > 1 ? 1: 0)); + info->stats[STAT_AGILITY] += (lvl > 36 ? 1: (lvl > 6 && (lvl%2) ? 1: 0)); + info->stats[STAT_INTELLECT] += (lvl > 9 && !(lvl%2) ? 1: 0); + info->stats[STAT_SPIRIT] += (lvl > 9 && !(lvl%2) ? 1: 0); + break; + case CLASS_PALADIN: + info->stats[STAT_STRENGTH] += (lvl > 3 ? 1: 0); + info->stats[STAT_STAMINA] += (lvl > 33 ? 2: (lvl > 1 ? 1: 0)); + info->stats[STAT_AGILITY] += (lvl > 38 ? 1: (lvl > 7 && !(lvl%2) ? 1: 0)); + info->stats[STAT_INTELLECT] += (lvl > 6 && (lvl%2) ? 1: 0); + info->stats[STAT_SPIRIT] += (lvl > 7 ? 1: 0); + break; + case CLASS_HUNTER: + info->stats[STAT_STRENGTH] += (lvl > 4 ? 1: 0); + info->stats[STAT_STAMINA] += (lvl > 4 ? 1: 0); + info->stats[STAT_AGILITY] += (lvl > 33 ? 2: (lvl > 1 ? 1: 0)); + info->stats[STAT_INTELLECT] += (lvl > 8 && (lvl%2) ? 1: 0); + info->stats[STAT_SPIRIT] += (lvl > 38 ? 1: (lvl > 9 && !(lvl%2) ? 1: 0)); + break; + case CLASS_ROGUE: + info->stats[STAT_STRENGTH] += (lvl > 5 ? 1: 0); + info->stats[STAT_STAMINA] += (lvl > 4 ? 1: 0); + info->stats[STAT_AGILITY] += (lvl > 16 ? 2: (lvl > 1 ? 1: 0)); + info->stats[STAT_INTELLECT] += (lvl > 8 && !(lvl%2) ? 1: 0); + info->stats[STAT_SPIRIT] += (lvl > 38 ? 1: (lvl > 9 && !(lvl%2) ? 1: 0)); + break; + case CLASS_PRIEST: + info->stats[STAT_STRENGTH] += (lvl > 9 && !(lvl%2) ? 1: 0); + info->stats[STAT_STAMINA] += (lvl > 5 ? 1: 0); + info->stats[STAT_AGILITY] += (lvl > 38 ? 1: (lvl > 8 && (lvl%2) ? 1: 0)); + info->stats[STAT_INTELLECT] += (lvl > 22 ? 2: (lvl > 1 ? 1: 0)); + info->stats[STAT_SPIRIT] += (lvl > 3 ? 1: 0); + break; + case CLASS_SHAMAN: + info->stats[STAT_STRENGTH] += (lvl > 34 ? 1: (lvl > 6 && (lvl%2) ? 1: 0)); + info->stats[STAT_STAMINA] += (lvl > 4 ? 1: 0); + info->stats[STAT_AGILITY] += (lvl > 7 && !(lvl%2) ? 1: 0); + info->stats[STAT_INTELLECT] += (lvl > 5 ? 1: 0); + info->stats[STAT_SPIRIT] += (lvl > 4 ? 1: 0); + break; + case CLASS_MAGE: + info->stats[STAT_STRENGTH] += (lvl > 9 && !(lvl%2) ? 1: 0); + info->stats[STAT_STAMINA] += (lvl > 5 ? 1: 0); + info->stats[STAT_AGILITY] += (lvl > 9 && !(lvl%2) ? 1: 0); + info->stats[STAT_INTELLECT] += (lvl > 24 ? 2: (lvl > 1 ? 1: 0)); + info->stats[STAT_SPIRIT] += (lvl > 33 ? 2: (lvl > 2 ? 1: 0)); + break; + case CLASS_WARLOCK: + info->stats[STAT_STRENGTH] += (lvl > 9 && !(lvl%2) ? 1: 0); + info->stats[STAT_STAMINA] += (lvl > 38 ? 2: (lvl > 3 ? 1: 0)); + info->stats[STAT_AGILITY] += (lvl > 9 && !(lvl%2) ? 1: 0); + info->stats[STAT_INTELLECT] += (lvl > 33 ? 2: (lvl > 2 ? 1: 0)); + info->stats[STAT_SPIRIT] += (lvl > 38 ? 2: (lvl > 3 ? 1: 0)); + break; + case CLASS_DRUID: + info->stats[STAT_STRENGTH] += (lvl > 38 ? 2: (lvl > 6 && (lvl%2) ? 1: 0)); + info->stats[STAT_STAMINA] += (lvl > 32 ? 2: (lvl > 4 ? 1: 0)); + info->stats[STAT_AGILITY] += (lvl > 38 ? 2: (lvl > 8 && (lvl%2) ? 1: 0)); + info->stats[STAT_INTELLECT] += (lvl > 38 ? 3: (lvl > 4 ? 1: 0)); + info->stats[STAT_SPIRIT] += (lvl > 38 ? 3: (lvl > 5 ? 1: 0)); + } + } +} + +void ObjectMgr::LoadGuilds() +{ + Guild *newguild; + uint32 count = 0; + + QueryResult *result = CharacterDatabase.Query( "SELECT guildid FROM guild" ); + + if( !result ) + { + + barGoLink bar( 1 ); + + bar.step(); + + sLog.outString(); + sLog.outString( ">> Loaded %u guild definitions", count ); + return; + } + + barGoLink bar( result->GetRowCount() ); + + do + { + Field *fields = result->Fetch(); + + bar.step(); + ++count; + + newguild = new Guild; + if(!newguild->LoadGuildFromDB(fields[0].GetUInt32())) + { + newguild->Disband(); + delete newguild; + continue; + } + AddGuild(newguild); + + }while( result->NextRow() ); + + delete result; + + sLog.outString(); + sLog.outString( ">> Loaded %u guild definitions", count ); +} + +void ObjectMgr::LoadArenaTeams() +{ + uint32 count = 0; + + QueryResult *result = CharacterDatabase.Query( "SELECT arenateamid FROM arena_team" ); + + if( !result ) + { + + barGoLink bar( 1 ); + + bar.step(); + + sLog.outString(); + sLog.outString( ">> Loaded %u arenateam definitions", count ); + return; + } + + barGoLink bar( result->GetRowCount() ); + + do + { + Field *fields = result->Fetch(); + + bar.step(); + ++count; + + ArenaTeam *newarenateam = new ArenaTeam; + if(!newarenateam->LoadArenaTeamFromDB(fields[0].GetUInt32())) + { + delete newarenateam; + continue; + } + AddArenaTeam(newarenateam); + }while( result->NextRow() ); + + delete result; + + sLog.outString(); + sLog.outString( ">> Loaded %u arenateam definitions", count ); +} + +void ObjectMgr::LoadGroups() +{ + // -- loading groups -- + Group *group = NULL; + uint64 leaderGuid = 0; + uint32 count = 0; + // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 + QueryResult *result = CharacterDatabase.PQuery("SELECT mainTank, mainAssistant, lootMethod, looterGuid, lootThreshold, icon1, icon2, icon3, icon4, icon5, icon6, icon7, icon8, isRaid, difficulty, leaderGuid FROM groups"); + + if( !result ) + { + barGoLink bar( 1 ); + + bar.step(); + + sLog.outString(); + sLog.outString( ">> Loaded %u group definitions", count ); + return; + } + + barGoLink bar( result->GetRowCount() ); + + do + { + bar.step(); + Field *fields = result->Fetch(); + ++count; + leaderGuid = MAKE_NEW_GUID(fields[15].GetUInt32(),0,HIGHGUID_PLAYER); + + group = new Group; + if(!group->LoadGroupFromDB(leaderGuid, result, false)) + { + group->Disband(); + delete group; + continue; + } + AddGroup(group); + }while( result->NextRow() ); + + delete result; + + sLog.outString(); + sLog.outString( ">> Loaded %u group definitions", count ); + + // -- loading members -- + count = 0; + group = NULL; + leaderGuid = 0; + // 0 1 2 3 + result = CharacterDatabase.PQuery("SELECT memberGuid, assistant, subgroup, leaderGuid FROM group_member ORDER BY leaderGuid"); + if(!result) + { + barGoLink bar( 1 ); + bar.step(); + } + else + { + barGoLink bar( result->GetRowCount() ); + do + { + bar.step(); + Field *fields = result->Fetch(); + count++; + leaderGuid = MAKE_NEW_GUID(fields[3].GetUInt32(), 0, HIGHGUID_PLAYER); + if(!group || group->GetLeaderGUID() != leaderGuid) + { + group = GetGroupByLeader(leaderGuid); + if(!group) + { + sLog.outErrorDb("Incorrect entry in group_member table : no group with leader %d for member %d!", fields[3].GetUInt32(), fields[0].GetUInt32()); + CharacterDatabase.PExecute("DELETE FROM group_member WHERE memberGuid = '%d'", fields[0].GetUInt32()); + continue; + } + } + + if(!group->LoadMemberFromDB(fields[0].GetUInt32(), fields[2].GetUInt8(), fields[1].GetBool())) + { + sLog.outErrorDb("Incorrect entry in group_member table : member %d cannot be added to player %d's group!", fields[0].GetUInt32(), fields[3].GetUInt32()); + CharacterDatabase.PExecute("DELETE FROM group_member WHERE memberGuid = '%d'", fields[0].GetUInt32()); + } + }while( result->NextRow() ); + delete result; + } + + // clean groups + // TODO: maybe delete from the DB before loading in this case + for(GroupSet::iterator itr = mGroupSet.begin(); itr != mGroupSet.end();) + { + if((*itr)->GetMembersCount() < 2) + { + (*itr)->Disband(); + delete *itr; + mGroupSet.erase(itr++); + } + else + ++itr; + } + + // -- loading instances -- + count = 0; + group = NULL; + leaderGuid = 0; + result = CharacterDatabase.PQuery( + // 0 1 2 3 4 5 + "SELECT leaderGuid, map, instance, permanent, difficulty, resettime, " + // 6 + "(SELECT COUNT(*) FROM character_instance WHERE guid = leaderGuid AND instance = group_instance.instance AND permanent = 1 LIMIT 1) " + "FROM group_instance LEFT JOIN instance ON instance = id ORDER BY leaderGuid" + ); + + if(!result) + { + barGoLink bar( 1 ); + bar.step(); + } + else + { + barGoLink bar( result->GetRowCount() ); + do + { + bar.step(); + Field *fields = result->Fetch(); + count++; + leaderGuid = MAKE_NEW_GUID(fields[0].GetUInt32(), 0, HIGHGUID_PLAYER); + if(!group || group->GetLeaderGUID() != leaderGuid) + { + group = GetGroupByLeader(leaderGuid); + if(!group) + { + sLog.outErrorDb("Incorrect entry in group_instance table : no group with leader %d", fields[0].GetUInt32()); + continue; + } + } + + InstanceSave *save = sInstanceSaveManager.AddInstanceSave(fields[1].GetUInt32(), fields[2].GetUInt32(), fields[4].GetUInt8(), (time_t)fields[5].GetUInt64(), (fields[6].GetUInt32() == 0), true); + group->BindToInstance(save, fields[3].GetBool(), true); + }while( result->NextRow() ); + delete result; + } + + sLog.outString(); + sLog.outString( ">> Loaded %u group-instance binds total", count ); + + sLog.outString(); + sLog.outString( ">> Loaded %u group members total", count ); +} + +void ObjectMgr::LoadQuests() +{ + // For reload case + for(QuestMap::const_iterator itr=mQuestTemplates.begin(); itr != mQuestTemplates.end(); ++itr) + delete itr->second; + mQuestTemplates.clear(); + + mExclusiveQuestGroups.clear(); + + // 0 1 2 3 4 5 6 7 + QueryResult *result = WorldDatabase.Query("SELECT entry, ZoneOrSort, SkillOrClass, MinLevel, QuestLevel, Type, RequiredRaces, RequiredSkillValue," + // 8 9 10 11 12 13 14 15 + "RepObjectiveFaction, RepObjectiveValue, RequiredMinRepFaction, RequiredMinRepValue, RequiredMaxRepFaction, RequiredMaxRepValue, SuggestedPlayers, LimitTime," + // 16 17 18 19 20 21 22 23 24 25 + "QuestFlags, SpecialFlags, CharTitleId, PrevQuestId, NextQuestId, ExclusiveGroup, NextQuestInChain, SrcItemId, SrcItemCount, SrcSpell," + // 26 27 28 29 30 31 32 33 34 35 + "Title, Details, Objectives, OfferRewardText, RequestItemsText, EndText, ObjectiveText1, ObjectiveText2, ObjectiveText3, ObjectiveText4," + // 36 37 38 39 40 41 42 43 + "ReqItemId1, ReqItemId2, ReqItemId3, ReqItemId4, ReqItemCount1, ReqItemCount2, ReqItemCount3, ReqItemCount4," + // 44 45 46 47 48 49 50 51 52 53 54 55 + "ReqSourceId1, ReqSourceId2, ReqSourceId3, ReqSourceId4, ReqSourceCount1, ReqSourceCount2, ReqSourceCount3, ReqSourceCount4, ReqSourceRef1, ReqSourceRef2, ReqSourceRef3, ReqSourceRef4," + // 56 57 58 59 60 61 62 63 + "ReqCreatureOrGOId1, ReqCreatureOrGOId2, ReqCreatureOrGOId3, ReqCreatureOrGOId4, ReqCreatureOrGOCount1, ReqCreatureOrGOCount2, ReqCreatureOrGOCount3, ReqCreatureOrGOCount4," + // 64 65 66 67 + "ReqSpellCast1, ReqSpellCast2, ReqSpellCast3, ReqSpellCast4," + // 68 69 70 71 72 73 + "RewChoiceItemId1, RewChoiceItemId2, RewChoiceItemId3, RewChoiceItemId4, RewChoiceItemId5, RewChoiceItemId6," + // 74 75 76 77 78 79 + "RewChoiceItemCount1, RewChoiceItemCount2, RewChoiceItemCount3, RewChoiceItemCount4, RewChoiceItemCount5, RewChoiceItemCount6," + // 80 81 82 83 84 85 86 87 + "RewItemId1, RewItemId2, RewItemId3, RewItemId4, RewItemCount1, RewItemCount2, RewItemCount3, RewItemCount4," + // 88 89 90 91 92 93 94 95 96 97 + "RewRepFaction1, RewRepFaction2, RewRepFaction3, RewRepFaction4, RewRepFaction5, RewRepValue1, RewRepValue2, RewRepValue3, RewRepValue4, RewRepValue5," + // 98 99 100 101 102 103 104 105 106 107 + "RewOrReqMoney, RewMoneyMaxLevel, RewSpell, RewSpellCast, RewMailTemplateId, RewMailDelaySecs, PointMapId, PointX, PointY, PointOpt," + // 108 109 110 111 112 113 114 115 116 117 + "DetailsEmote1, DetailsEmote2, DetailsEmote3, DetailsEmote4,IncompleteEmote, CompleteEmote, OfferRewardEmote1, OfferRewardEmote2, OfferRewardEmote3, OfferRewardEmote4," + // 118 119 + "StartScript, CompleteScript" + " FROM quest_template"); + if(result == NULL) + { + barGoLink bar( 1 ); + bar.step(); + + sLog.outString(); + sLog.outString( ">> Loaded 0 quests definitions" ); + sLog.outErrorDb("`quest_template` table is empty!"); + return; + } + + // create multimap previous quest for each existed quest + // some quests can have many previous maps set by NextQuestId in previous quest + // for example set of race quests can lead to single not race specific quest + barGoLink bar( result->GetRowCount() ); + do + { + bar.step(); + Field *fields = result->Fetch(); + + Quest * newQuest = new Quest(fields); + mQuestTemplates[newQuest->GetQuestId()] = newQuest; + } while( result->NextRow() ); + + delete result; + + // Post processing + for (QuestMap::iterator iter = mQuestTemplates.begin(); iter != mQuestTemplates.end(); iter++) + { + Quest * qinfo = iter->second; + + // additional quest integrity checks (GO, creature_template and item_template must be loaded already) + + if (qinfo->QuestFlags & ~QUEST_MANGOS_FLAGS_DB_ALLOWED) + { + sLog.outErrorDb("Quest %u has `SpecialFlags` = %u > max allowed value. Correct `SpecialFlags` to value <= %u", + qinfo->GetQuestId(),qinfo->QuestFlags,QUEST_MANGOS_FLAGS_DB_ALLOWED >> 16); + qinfo->QuestFlags &= QUEST_MANGOS_FLAGS_DB_ALLOWED; + } + + if(qinfo->QuestFlags & QUEST_FLAGS_DAILY) + { + if(!(qinfo->QuestFlags & QUEST_MANGOS_FLAGS_REPEATABLE)) + { + sLog.outErrorDb("Daily Quest %u not marked as repeatable in `SpecialFlags`, added.",qinfo->GetQuestId()); + qinfo->QuestFlags |= QUEST_MANGOS_FLAGS_REPEATABLE; + } + } + + if(qinfo->QuestFlags & QUEST_FLAGS_AUTO_REWARDED) + { + // at auto-reward can be rewarded only RewChoiceItemId[0] + for(int j = 1; j < QUEST_REWARD_CHOICES_COUNT; ++j ) + { + if(uint32 id = qinfo->RewChoiceItemId[j]) + { + sLog.outErrorDb("Quest %u has `RewChoiceItemId%d` = %u but item from `RewChoiceItemId%d` can't be rewarded with quest flag QUEST_FLAGS_AUTO_REWARDED.", + qinfo->GetQuestId(),j+1,id,j+1); + // no changes, quest ignore this data + } + } + } + + // client quest log visual (area case) + if( qinfo->ZoneOrSort > 0 ) + { + if(!GetAreaEntryByAreaID(qinfo->ZoneOrSort)) + { + sLog.outErrorDb("Quest %u has `ZoneOrSort` = %u (zone case) but zone with this id does not exist.", + qinfo->GetQuestId(),qinfo->ZoneOrSort); + // no changes, quest not dependent from this value but can have problems at client + } + } + // client quest log visual (sort case) + if( qinfo->ZoneOrSort < 0 ) + { + QuestSortEntry const* qSort = sQuestSortStore.LookupEntry(-int32(qinfo->ZoneOrSort)); + if( !qSort ) + { + sLog.outErrorDb("Quest %u has `ZoneOrSort` = %i (sort case) but quest sort with this id does not exist.", + qinfo->GetQuestId(),qinfo->ZoneOrSort); + // no changes, quest not dependent from this value but can have problems at client (note some may be 0, we must allow this so no check) + } + //check SkillOrClass value (class case). + if( ClassByQuestSort(-int32(qinfo->ZoneOrSort)) ) + { + // SkillOrClass should not have class case when class case already set in ZoneOrSort. + if(qinfo->SkillOrClass < 0) + { + sLog.outErrorDb("Quest %u has `ZoneOrSort` = %i (class sort case) and `SkillOrClass` = %i (class case), redundant.", + qinfo->GetQuestId(),qinfo->ZoneOrSort,qinfo->SkillOrClass); + } + } + //check for proper SkillOrClass value (skill case) + if(int32 skill_id = SkillByQuestSort(-int32(qinfo->ZoneOrSort))) + { + // skill is positive value in SkillOrClass + if(qinfo->SkillOrClass != skill_id ) + { + sLog.outErrorDb("Quest %u has `ZoneOrSort` = %i (skill sort case) but `SkillOrClass` does not have a corresponding value (%i).", + qinfo->GetQuestId(),qinfo->ZoneOrSort,skill_id); + //override, and force proper value here? + } + } + } + + // SkillOrClass (class case) + if( qinfo->SkillOrClass < 0 ) + { + if( !sChrClassesStore.LookupEntry(-int32(qinfo->SkillOrClass)) ) + { + sLog.outErrorDb("Quest %u has `SkillOrClass` = %i (class case) but class (%i) does not exist", + qinfo->GetQuestId(),qinfo->SkillOrClass,-qinfo->SkillOrClass); + } + } + // SkillOrClass (skill case) + if( qinfo->SkillOrClass > 0 ) + { + if( !sSkillLineStore.LookupEntry(qinfo->SkillOrClass) ) + { + sLog.outErrorDb("Quest %u has `SkillOrClass` = %u (skill case) but skill (%i) does not exist", + qinfo->GetQuestId(),qinfo->SkillOrClass,qinfo->SkillOrClass); + } + } + + if( qinfo->RequiredSkillValue ) + { + if( qinfo->RequiredSkillValue > sWorld.GetConfigMaxSkillValue() ) + { + sLog.outErrorDb("Quest %u has `RequiredSkillValue` = %u but max possible skill is %u, quest can't be done.", + qinfo->GetQuestId(),qinfo->RequiredSkillValue,sWorld.GetConfigMaxSkillValue()); + // no changes, quest can't be done for this requirement + } + + if( qinfo->SkillOrClass <= 0 ) + { + sLog.outErrorDb("Quest %u has `RequiredSkillValue` = %u but `SkillOrClass` = %i (class case), value ignored.", + qinfo->GetQuestId(),qinfo->RequiredSkillValue,qinfo->SkillOrClass); + // no changes, quest can't be done for this requirement (fail at wrong skill id) + } + } + // else Skill quests can have 0 skill level, this is ok + + if(qinfo->RepObjectiveFaction && !sFactionStore.LookupEntry(qinfo->RepObjectiveFaction)) + { + sLog.outErrorDb("Quest %u has `RepObjectiveFaction` = %u but faction template %u does not exist, quest can't be done.", + qinfo->GetQuestId(),qinfo->RepObjectiveFaction,qinfo->RepObjectiveFaction); + // no changes, quest can't be done for this requirement + } + + if(qinfo->RequiredMinRepFaction && !sFactionStore.LookupEntry(qinfo->RequiredMinRepFaction)) + { + sLog.outErrorDb("Quest %u has `RequiredMinRepFaction` = %u but faction template %u does not exist, quest can't be done.", + qinfo->GetQuestId(),qinfo->RequiredMinRepFaction,qinfo->RequiredMinRepFaction); + // no changes, quest can't be done for this requirement + } + + if(qinfo->RequiredMaxRepFaction && !sFactionStore.LookupEntry(qinfo->RequiredMaxRepFaction)) + { + sLog.outErrorDb("Quest %u has `RequiredMaxRepFaction` = %u but faction template %u does not exist, quest can't be done.", + qinfo->GetQuestId(),qinfo->RequiredMaxRepFaction,qinfo->RequiredMaxRepFaction); + // no changes, quest can't be done for this requirement + } + + if(qinfo->RequiredMinRepValue && qinfo->RequiredMinRepValue > Player::Reputation_Cap) + { + sLog.outErrorDb("Quest %u has `RequiredMinRepValue` = %d but max reputation is %u, quest can't be done.", + qinfo->GetQuestId(),qinfo->RequiredMinRepValue,Player::Reputation_Cap); + // no changes, quest can't be done for this requirement + } + + if(qinfo->RequiredMinRepValue && qinfo->RequiredMaxRepValue && qinfo->RequiredMaxRepValue <= qinfo->RequiredMinRepValue) + { + sLog.outErrorDb("Quest %u has `RequiredMaxRepValue` = %d and `RequiredMinRepValue` = %d, quest can't be done.", + qinfo->GetQuestId(),qinfo->RequiredMaxRepValue,qinfo->RequiredMinRepValue); + // no changes, quest can't be done for this requirement + } + + if(!qinfo->RepObjectiveFaction && qinfo->RepObjectiveValue > 0 ) + { + sLog.outErrorDb("Quest %u has `RepObjectiveValue` = %d but `RepObjectiveFaction` is 0, value has no effect", + qinfo->GetQuestId(),qinfo->RepObjectiveValue); + // warning + } + + if(!qinfo->RequiredMinRepFaction && qinfo->RequiredMinRepValue > 0 ) + { + sLog.outErrorDb("Quest %u has `RequiredMinRepValue` = %d but `RequiredMinRepFaction` is 0, value has no effect", + qinfo->GetQuestId(),qinfo->RequiredMinRepValue); + // warning + } + + if(!qinfo->RequiredMaxRepFaction && qinfo->RequiredMaxRepValue > 0 ) + { + sLog.outErrorDb("Quest %u has `RequiredMaxRepValue` = %d but `RequiredMaxRepFaction` is 0, value has no effect", + qinfo->GetQuestId(),qinfo->RequiredMaxRepValue); + // warning + } + + if(qinfo->CharTitleId && !sCharTitlesStore.LookupEntry(qinfo->CharTitleId)) + { + sLog.outErrorDb("Quest %u has `CharTitleId` = %u but CharTitle Id %u does not exist, quest can't be rewarded with title.", + qinfo->GetQuestId(),qinfo->GetCharTitleId(),qinfo->GetCharTitleId()); + qinfo->CharTitleId = 0; + // quest can't reward this title + } + + if(qinfo->SrcItemId) + { + if(!sItemStorage.LookupEntry(qinfo->SrcItemId)) + { + sLog.outErrorDb("Quest %u has `SrcItemId` = %u but item with entry %u does not exist, quest can't be done.", + qinfo->GetQuestId(),qinfo->SrcItemId,qinfo->SrcItemId); + qinfo->SrcItemId = 0; // quest can't be done for this requirement + } + else if(qinfo->SrcItemCount==0) + { + sLog.outErrorDb("Quest %u has `SrcItemId` = %u but `SrcItemCount` = 0, set to 1 but need fix in DB.", + qinfo->GetQuestId(),qinfo->SrcItemId); + qinfo->SrcItemCount = 1; // update to 1 for allow quest work for backward comptibility with DB + } + } + else if(qinfo->SrcItemCount>0) + { + sLog.outErrorDb("Quest %u has `SrcItemId` = 0 but `SrcItemCount` = %u, useless value.", + qinfo->GetQuestId(),qinfo->SrcItemCount); + qinfo->SrcItemCount=0; // no quest work changes in fact + } + + if(qinfo->SrcSpell) + { + SpellEntry const* spellInfo = sSpellStore.LookupEntry(qinfo->SrcSpell); + if(!spellInfo) + { + sLog.outErrorDb("Quest %u has `SrcSpell` = %u but spell %u doesn't exist, quest can't be done.", + qinfo->GetQuestId(),qinfo->SrcSpell,qinfo->SrcSpell); + qinfo->SrcSpell = 0; // quest can't be done for this requirement + } + else if(!SpellMgr::IsSpellValid(spellInfo)) + { + sLog.outErrorDb("Quest %u has `SrcSpell` = %u but spell %u is broken, quest can't be done.", + qinfo->GetQuestId(),qinfo->SrcSpell,qinfo->SrcSpell); + qinfo->SrcSpell = 0; // quest can't be done for this requirement + } + } + + for(int j = 0; j < QUEST_OBJECTIVES_COUNT; ++j ) + { + uint32 id = qinfo->ReqItemId[j]; + if(id) + { + if(qinfo->ReqItemCount[j]==0) + { + sLog.outErrorDb("Quest %u has `ReqItemId%d` = %u but `ReqItemCount%d` = 0, quest can't be done.", + qinfo->GetQuestId(),j+1,id,j+1); + // no changes, quest can't be done for this requirement + } + + qinfo->SetFlag(QUEST_MANGOS_FLAGS_DELIVER); + + if(!sItemStorage.LookupEntry(id)) + { + sLog.outErrorDb("Quest %u has `ReqItemId%d` = %u but item with entry %u does not exist, quest can't be done.", + qinfo->GetQuestId(),j+1,id,id); + qinfo->ReqItemCount[j] = 0; // prevent incorrect work of quest + } + } + else if(qinfo->ReqItemCount[j]>0) + { + sLog.outErrorDb("Quest %u has `ReqItemId%d` = 0 but `ReqItemCount%d` = %u, quest can't be done.", + qinfo->GetQuestId(),j+1,j+1,qinfo->ReqItemCount[j]); + qinfo->ReqItemCount[j] = 0; // prevent incorrect work of quest + } + } + + for(int j = 0; j < QUEST_SOURCE_ITEM_IDS_COUNT; ++j ) + { + uint32 id = qinfo->ReqSourceId[j]; + if(id) + { + if(!sItemStorage.LookupEntry(id)) + { + sLog.outErrorDb("Quest %u has `ReqSourceId%d` = %u but item with entry %u does not exist, quest can't be done.", + qinfo->GetQuestId(),j+1,id,id); + // no changes, quest can't be done for this requirement + } + + if(!qinfo->ReqSourceCount[j]) + { + sLog.outErrorDb("Quest %u has `ReqSourceId%d` = %u but `ReqSourceCount%d` = 0, quest can't be done.", + qinfo->GetQuestId(),j+1,id,j+1); + qinfo->ReqSourceId[j] = 0; // prevent incorrect work of quest + } + + if(!qinfo->ReqSourceRef[j]) + { + sLog.outErrorDb("Quest %u has `ReqSourceId%d` = %u but `ReqSourceRef%d` = 0, quest can't be done.", + qinfo->GetQuestId(),j+1,id,j+1); + qinfo->ReqSourceId[j] = 0; // prevent incorrect work of quest + } + } + else + { + if(qinfo->ReqSourceCount[j]>0) + { + sLog.outErrorDb("Quest %u has `ReqSourceId%d` = 0 but `ReqSourceCount%d` = %u.", + qinfo->GetQuestId(),j+1,j+1,qinfo->ReqSourceCount[j]); + // no changes, quest ignore this data + } + + if(qinfo->ReqSourceRef[j]>0) + { + sLog.outErrorDb("Quest %u has `ReqSourceId%d` = 0 but `ReqSourceRef%d` = %u.", + qinfo->GetQuestId(),j+1,j+1,qinfo->ReqSourceRef[j]); + // no changes, quest ignore this data + } + } + } + + for(int j = 0; j < QUEST_SOURCE_ITEM_IDS_COUNT; ++j ) + { + uint32 ref = qinfo->ReqSourceRef[j]; + if(ref) + { + if(ref > QUEST_OBJECTIVES_COUNT) + { + sLog.outErrorDb("Quest %u has `ReqSourceRef%d` = %u but max value in `ReqSourceRef%d` is %u, quest can't be done.", + qinfo->GetQuestId(),j+1,ref,j+1,QUEST_OBJECTIVES_COUNT); + // no changes, quest can't be done for this requirement + } + else + if(!qinfo->ReqItemId[ref-1] && !qinfo->ReqSpell[ref-1]) + { + sLog.outErrorDb("Quest %u has `ReqSourceRef%d` = %u but `ReqItemId%u` = 0 and `ReqSpellCast%u` = 0, quest can't be done.", + qinfo->GetQuestId(),j+1,ref,ref,ref); + // no changes, quest can't be done for this requirement + } + else if(qinfo->ReqItemId[ref-1] && qinfo->ReqSpell[ref-1]) + { + sLog.outErrorDb("Quest %u has `ReqItemId%u` = %u and `ReqSpellCast%u` = %u, quest can't have both fields <> 0, then can't be done.", + qinfo->GetQuestId(),ref,qinfo->ReqItemId[ref-1],ref,qinfo->ReqSpell[ref-1]); + // no changes, quest can't be done for this requirement + qinfo->ReqSourceId[j] = 0; // prevent incorrect work of quest + } + } + } + + for(int j = 0; j < QUEST_OBJECTIVES_COUNT; ++j ) + { + uint32 id = qinfo->ReqSpell[j]; + if(id) + { + SpellEntry const* spellInfo = sSpellStore.LookupEntry(id); + if(!spellInfo) + { + sLog.outErrorDb("Quest %u has `ReqSpellCast%d` = %u but spell %u does not exist, quest can't be done.", + qinfo->GetQuestId(),j+1,id,id); + // no changes, quest can't be done for this requirement + } + + if(!qinfo->ReqCreatureOrGOId[j]) + { + bool found = false; + for(int k = 0; k < 3; ++k) + { + if( spellInfo->Effect[k]==SPELL_EFFECT_QUEST_COMPLETE && uint32(spellInfo->EffectMiscValue[k])==qinfo->QuestId || + spellInfo->Effect[k]==SPELL_EFFECT_SEND_EVENT) + { + found = true; + break; + } + } + + if(found) + { + if(!qinfo->HasFlag(QUEST_MANGOS_FLAGS_EXPLORATION_OR_EVENT)) + { + sLog.outErrorDb("Spell (id: %u) have SPELL_EFFECT_QUEST_COMPLETE or SPELL_EFFECT_SEND_EVENT for quest %u and ReqCreatureOrGOId%d = 0, but quest not have flag QUEST_MANGOS_FLAGS_EXPLORATION_OR_EVENT. Quest flags or ReqCreatureOrGOId%d must be fixed, quest modified to enable objective.",spellInfo->Id,qinfo->QuestId,j+1,j+1); + + // this will prevent quest completing without objective + const_cast(qinfo)->SetFlag(QUEST_MANGOS_FLAGS_EXPLORATION_OR_EVENT); + } + } + else + { + sLog.outErrorDb("Quest %u has `ReqSpellCast%d` = %u and ReqCreatureOrGOId%d = 0 but spell %u does not have SPELL_EFFECT_QUEST_COMPLETE or SPELL_EFFECT_SEND_EVENT effect for this quest, quest can't be done.", + qinfo->GetQuestId(),j+1,id,j+1,id); + // no changes, quest can't be done for this requirement + } + } + } + } + + for(int j = 0; j < QUEST_OBJECTIVES_COUNT; ++j ) + { + int32 id = qinfo->ReqCreatureOrGOId[j]; + if(id < 0 && !sGOStorage.LookupEntry(-id)) + { + sLog.outErrorDb("Quest %u has `ReqCreatureOrGOId%d` = %i but gameobject %u does not exist, quest can't be done.", + qinfo->GetQuestId(),j+1,id,uint32(-id)); + qinfo->ReqCreatureOrGOId[j] = 0; // quest can't be done for this requirement + } + + if(id > 0 && !sCreatureStorage.LookupEntry(id)) + { + sLog.outErrorDb("Quest %u has `ReqCreatureOrGOId%d` = %i but creature with entry %u does not exist, quest can't be done.", + qinfo->GetQuestId(),j+1,id,uint32(id)); + qinfo->ReqCreatureOrGOId[j] = 0; // quest can't be done for this requirement + } + + if(id) + { + // In fact SpeakTo and Kill are quite same: either you can speak to mob:SpeakTo or you can't:Kill/Cast + + qinfo->SetFlag(QUEST_MANGOS_FLAGS_KILL_OR_CAST | QUEST_MANGOS_FLAGS_SPEAKTO); + + if(!qinfo->ReqCreatureOrGOCount[j]) + { + sLog.outErrorDb("Quest %u has `ReqCreatureOrGOId%d` = %u but `ReqCreatureOrGOCount%d` = 0, quest can't be done.", + qinfo->GetQuestId(),j+1,id,j+1); + // no changes, quest can be incorrectly done, but we already report this + } + } + else if(qinfo->ReqCreatureOrGOCount[j]>0) + { + sLog.outErrorDb("Quest %u has `ReqCreatureOrGOId%d` = 0 but `ReqCreatureOrGOCount%d` = %u.", + qinfo->GetQuestId(),j+1,j+1,qinfo->ReqCreatureOrGOCount[j]); + // no changes, quest ignore this data + } + } + + for(int j = 0; j < QUEST_REWARD_CHOICES_COUNT; ++j ) + { + uint32 id = qinfo->RewChoiceItemId[j]; + if(id) + { + if(!sItemStorage.LookupEntry(id)) + { + sLog.outErrorDb("Quest %u has `RewChoiceItemId%d` = %u but item with entry %u does not exist, quest will not reward this item.", + qinfo->GetQuestId(),j+1,id,id); + qinfo->RewChoiceItemId[j] = 0; // no changes, quest will not reward this + } + + if(!qinfo->RewChoiceItemCount[j]) + { + sLog.outErrorDb("Quest %u has `RewChoiceItemId%d` = %u but `RewChoiceItemCount%d` = 0, quest can't be done.", + qinfo->GetQuestId(),j+1,id,j+1); + // no changes, quest can't be done + } + } + else if(qinfo->RewChoiceItemCount[j]>0) + { + sLog.outErrorDb("Quest %u has `RewChoiceItemId%d` = 0 but `RewChoiceItemCount%d` = %u.", + qinfo->GetQuestId(),j+1,j+1,qinfo->RewChoiceItemCount[j]); + // no changes, quest ignore this data + } + } + + for(int j = 0; j < QUEST_REWARDS_COUNT; ++j ) + { + uint32 id = qinfo->RewItemId[j]; + if(id) + { + if(!sItemStorage.LookupEntry(id)) + { + sLog.outErrorDb("Quest %u has `RewItemId%d` = %u but item with entry %u does not exist, quest will not reward this item.", + qinfo->GetQuestId(),j+1,id,id); + qinfo->RewItemId[j] = 0; // no changes, quest will not reward this item + } + + if(!qinfo->RewItemCount[j]) + { + sLog.outErrorDb("Quest %u has `RewItemId%d` = %u but `RewItemCount%d` = 0, quest will not reward this item.", + qinfo->GetQuestId(),j+1,id,j+1); + // no changes + } + } + else if(qinfo->RewItemCount[j]>0) + { + sLog.outErrorDb("Quest %u has `RewItemId%d` = 0 but `RewItemCount%d` = %u.", + qinfo->GetQuestId(),j+1,j+1,qinfo->RewItemCount[j]); + // no changes, quest ignore this data + } + } + + for(int j = 0; j < QUEST_REPUTATIONS_COUNT; ++j) + { + if(qinfo->RewRepFaction[j]) + { + if(!qinfo->RewRepValue[j]) + { + sLog.outErrorDb("Quest %u has `RewRepFaction%d` = %u but `RewRepValue%d` = 0, quest will not reward this reputation.", + qinfo->GetQuestId(),j+1,qinfo->RewRepValue[j],j+1); + // no changes + } + + if(!sFactionStore.LookupEntry(qinfo->RewRepFaction[j])) + { + sLog.outErrorDb("Quest %u has `RewRepFaction%d` = %u but raw faction (faction.dbc) %u does not exist, quest will not reward reputation for this faction.", + qinfo->GetQuestId(),j+1,qinfo->RewRepFaction[j] ,qinfo->RewRepFaction[j] ); + qinfo->RewRepFaction[j] = 0; // quest will not reward this + } + } + else if(qinfo->RewRepValue[j]!=0) + { + sLog.outErrorDb("Quest %u has `RewRepFaction%d` = 0 but `RewRepValue%d` = %u.", + qinfo->GetQuestId(),j+1,j+1,qinfo->RewRepValue[j]); + // no changes, quest ignore this data + } + } + + if(qinfo->RewSpell) + { + SpellEntry const* spellInfo = sSpellStore.LookupEntry(qinfo->RewSpell); + + if(!spellInfo) + { + sLog.outErrorDb("Quest %u has `RewSpell` = %u but spell %u does not exist, spell removed as display reward.", + qinfo->GetQuestId(),qinfo->RewSpell,qinfo->RewSpell); + qinfo->RewSpell = 0; // no spell reward will display for this quest + } + + else if(!SpellMgr::IsSpellValid(spellInfo)) + { + sLog.outErrorDb("Quest %u has `RewSpell` = %u but spell %u is broken, quest can't be done.", + qinfo->GetQuestId(),qinfo->RewSpell,qinfo->RewSpell); + qinfo->RewSpell = 0; // no spell reward will display for this quest + } + + } + + if(qinfo->RewSpellCast) + { + SpellEntry const* spellInfo = sSpellStore.LookupEntry(qinfo->RewSpellCast); + + if(!spellInfo) + { + sLog.outErrorDb("Quest %u has `RewSpellCast` = %u but spell %u does not exist, quest will not have a spell reward.", + qinfo->GetQuestId(),qinfo->RewSpellCast,qinfo->RewSpellCast); + qinfo->RewSpellCast = 0; // no spell will be casted on player + } + + else if(!SpellMgr::IsSpellValid(spellInfo)) + { + sLog.outErrorDb("Quest %u has `RewSpellCast` = %u but spell %u is broken, quest can't be done.", + qinfo->GetQuestId(),qinfo->RewSpellCast,qinfo->RewSpellCast); + qinfo->RewSpellCast = 0; // no spell will be casted on player + } + + } + + if(qinfo->RewMailTemplateId) + { + if(!sMailTemplateStore.LookupEntry(qinfo->RewMailTemplateId)) + { + sLog.outErrorDb("Quest %u has `RewMailTemplateId` = %u but mail template %u does not exist, quest will not have a mail reward.", + qinfo->GetQuestId(),qinfo->RewMailTemplateId,qinfo->RewMailTemplateId); + qinfo->RewMailTemplateId = 0; // no mail will send to player + qinfo->RewMailDelaySecs = 0; // no mail will send to player + } + } + + if(qinfo->NextQuestInChain) + { + if(mQuestTemplates.find(qinfo->NextQuestInChain) == mQuestTemplates.end()) + { + sLog.outErrorDb("Quest %u has `NextQuestInChain` = %u but quest %u does not exist, quest chain will not work.", + qinfo->GetQuestId(),qinfo->NextQuestInChain ,qinfo->NextQuestInChain ); + qinfo->NextQuestInChain = 0; + } + else + mQuestTemplates[qinfo->NextQuestInChain]->prevChainQuests.push_back(qinfo->GetQuestId()); + } + + // fill additional data stores + if(qinfo->PrevQuestId) + { + if (mQuestTemplates.find(abs(qinfo->GetPrevQuestId())) == mQuestTemplates.end()) + { + sLog.outErrorDb("Quest %d has PrevQuestId %i, but no such quest", qinfo->GetQuestId(), qinfo->GetPrevQuestId()); + } + else + { + qinfo->prevQuests.push_back(qinfo->PrevQuestId); + } + } + + if(qinfo->NextQuestId) + { + if (mQuestTemplates.find(abs(qinfo->GetNextQuestId())) == mQuestTemplates.end()) + { + sLog.outErrorDb("Quest %d has NextQuestId %i, but no such quest", qinfo->GetQuestId(), qinfo->GetNextQuestId()); + } + else + { + int32 signedQuestId = qinfo->NextQuestId < 0 ? -int32(qinfo->GetQuestId()) : int32(qinfo->GetQuestId()); + mQuestTemplates[abs(qinfo->GetNextQuestId())]->prevQuests.push_back(signedQuestId); + } + } + + if(qinfo->ExclusiveGroup) + mExclusiveQuestGroups.insert(std::pair(qinfo->ExclusiveGroup, qinfo->GetQuestId())); + if(qinfo->LimitTime) + qinfo->SetFlag(QUEST_MANGOS_FLAGS_TIMED); + } + + // check QUEST_MANGOS_FLAGS_EXPLORATION_OR_EVENT for spell with SPELL_EFFECT_QUEST_COMPLETE + for (uint32 i = 0; i < sSpellStore.GetNumRows(); ++i) + { + SpellEntry const *spellInfo = sSpellStore.LookupEntry(i); + if(!spellInfo) + continue; + + for(int j = 0; j < 3; ++j) + { + if(spellInfo->Effect[j] != SPELL_EFFECT_QUEST_COMPLETE) + continue; + + uint32 quest_id = spellInfo->EffectMiscValue[j]; + + Quest const* quest = GetQuestTemplate(quest_id); + + // some quest referenced in spells not exist (outdataed spells) + if(!quest) + continue; + + if(!quest->HasFlag(QUEST_MANGOS_FLAGS_EXPLORATION_OR_EVENT)) + { + sLog.outErrorDb("Spell (id: %u) have SPELL_EFFECT_QUEST_COMPLETE for quest %u , but quest not have flag QUEST_MANGOS_FLAGS_EXPLORATION_OR_EVENT. Quest flags must be fixed, quest modified to enable objective.",spellInfo->Id,quest_id); + + // this will prevent quest completing without objective + const_cast(quest)->SetFlag(QUEST_MANGOS_FLAGS_EXPLORATION_OR_EVENT); + } + } + } + + sLog.outString(); + sLog.outString( ">> Loaded %u quests definitions", mQuestTemplates.size() ); +} + +void ObjectMgr::LoadQuestLocales() +{ + QueryResult *result = WorldDatabase.Query("SELECT entry," + "Title_loc1,Details_loc1,Objectives_loc1,OfferRewardText_loc1,RequestItemsText_loc1,EndText_loc1,ObjectiveText1_loc1,ObjectiveText2_loc1,ObjectiveText3_loc1,ObjectiveText4_loc1," + "Title_loc2,Details_loc2,Objectives_loc2,OfferRewardText_loc2,RequestItemsText_loc2,EndText_loc2,ObjectiveText1_loc2,ObjectiveText2_loc2,ObjectiveText3_loc2,ObjectiveText4_loc2," + "Title_loc3,Details_loc3,Objectives_loc3,OfferRewardText_loc3,RequestItemsText_loc3,EndText_loc3,ObjectiveText1_loc3,ObjectiveText2_loc3,ObjectiveText3_loc3,ObjectiveText4_loc3," + "Title_loc4,Details_loc4,Objectives_loc4,OfferRewardText_loc4,RequestItemsText_loc4,EndText_loc4,ObjectiveText1_loc4,ObjectiveText2_loc4,ObjectiveText3_loc4,ObjectiveText4_loc4," + "Title_loc5,Details_loc5,Objectives_loc5,OfferRewardText_loc5,RequestItemsText_loc5,EndText_loc5,ObjectiveText1_loc5,ObjectiveText2_loc5,ObjectiveText3_loc5,ObjectiveText4_loc5," + "Title_loc6,Details_loc6,Objectives_loc6,OfferRewardText_loc6,RequestItemsText_loc6,EndText_loc6,ObjectiveText1_loc6,ObjectiveText2_loc6,ObjectiveText3_loc6,ObjectiveText4_loc6," + "Title_loc7,Details_loc7,Objectives_loc7,OfferRewardText_loc7,RequestItemsText_loc7,EndText_loc7,ObjectiveText1_loc7,ObjectiveText2_loc7,ObjectiveText3_loc7,ObjectiveText4_loc7," + "Title_loc8,Details_loc8,Objectives_loc8,OfferRewardText_loc8,RequestItemsText_loc8,EndText_loc8,ObjectiveText1_loc8,ObjectiveText2_loc8,ObjectiveText3_loc8,ObjectiveText4_loc8" + " FROM locales_quest" + ); + + if(!result) + { + barGoLink bar(1); + + bar.step(); + + sLog.outString(""); + sLog.outString(">> Loaded 0 Quest locale strings. DB table `locales_quest` is empty."); + return; + } + + barGoLink bar(result->GetRowCount()); + + do + { + Field *fields = result->Fetch(); + bar.step(); + + uint32 entry = fields[0].GetUInt32(); + + QuestLocale& data = mQuestLocaleMap[entry]; + + for(int i = 1; i < MAX_LOCALE; ++i) + { + std::string str = fields[1+10*(i-1)].GetCppString(); + if(!str.empty()) + { + int idx = GetOrNewIndexForLocale(LocaleConstant(i)); + if(idx >= 0) + { + if(data.Title.size() <= idx) + data.Title.resize(idx+1); + + data.Title[idx] = str; + } + } + str = fields[1+10*(i-1)+1].GetCppString(); + if(!str.empty()) + { + int idx = GetOrNewIndexForLocale(LocaleConstant(i)); + if(idx >= 0) + { + if(data.Details.size() <= idx) + data.Details.resize(idx+1); + + data.Details[idx] = str; + } + } + str = fields[1+10*(i-1)+2].GetCppString(); + if(!str.empty()) + { + int idx = GetOrNewIndexForLocale(LocaleConstant(i)); + if(idx >= 0) + { + if(data.Objectives.size() <= idx) + data.Objectives.resize(idx+1); + + data.Objectives[idx] = str; + } + } + str = fields[1+10*(i-1)+3].GetCppString(); + if(!str.empty()) + { + int idx = GetOrNewIndexForLocale(LocaleConstant(i)); + if(idx >= 0) + { + if(data.OfferRewardText.size() <= idx) + data.OfferRewardText.resize(idx+1); + + data.OfferRewardText[idx] = str; + } + } + str = fields[1+10*(i-1)+4].GetCppString(); + if(!str.empty()) + { + int idx = GetOrNewIndexForLocale(LocaleConstant(i)); + if(idx >= 0) + { + if(data.RequestItemsText.size() <= idx) + data.RequestItemsText.resize(idx+1); + + data.RequestItemsText[idx] = str; + } + } + str = fields[1+10*(i-1)+5].GetCppString(); + if(!str.empty()) + { + int idx = GetOrNewIndexForLocale(LocaleConstant(i)); + if(idx >= 0) + { + if(data.EndText.size() <= idx) + data.EndText.resize(idx+1); + + data.EndText[idx] = str; + } + } + for(int k = 0; k < 4; ++k) + { + str = fields[1+10*(i-1)+6+k].GetCppString(); + if(!str.empty()) + { + int idx = GetOrNewIndexForLocale(LocaleConstant(i)); + if(idx >= 0) + { + if(data.ObjectiveText[k].size() <= idx) + data.ObjectiveText[k].resize(idx+1); + + data.ObjectiveText[k][idx] = str; + } + } + } + } + } while (result->NextRow()); + + delete result; + + sLog.outString(); + sLog.outString( ">> Loaded %u Quest locale strings", mQuestLocaleMap.size() ); +} + +void ObjectMgr::LoadPetCreateSpells() +{ + QueryResult *result = WorldDatabase.PQuery("SELECT entry, Spell1, Spell2, Spell3, Spell4 FROM petcreateinfo_spell"); + if(!result) + { + barGoLink bar( 1 ); + bar.step(); + + sLog.outString(); + sLog.outString( ">> Loaded 0 pet create spells" ); + sLog.outErrorDb("`petcreateinfo_spell` table is empty!"); + return; + } + + uint32 count = 0; + + barGoLink bar( result->GetRowCount() ); + + mPetCreateSpell.clear(); + + do + { + Field *fields = result->Fetch(); + bar.step(); + + uint32 creature_id = fields[0].GetUInt32(); + + if(!creature_id || !sCreatureStorage.LookupEntry(creature_id)) + continue; + + PetCreateSpellEntry PetCreateSpell; + for(int i = 0; i < 4; i++) + { + PetCreateSpell.spellid[i] = fields[i + 1].GetUInt32(); + + if(PetCreateSpell.spellid[i] && !sSpellStore.LookupEntry(PetCreateSpell.spellid[i])) + sLog.outErrorDb("Spell %u listed in `petcreateinfo_spell` does not exist",PetCreateSpell.spellid[i]); + } + + mPetCreateSpell[creature_id] = PetCreateSpell; + + ++count; + } + while (result->NextRow()); + + delete result; + + sLog.outString(); + sLog.outString( ">> Loaded %u pet create spells", count ); +} + +void ObjectMgr::LoadScripts(ScriptMapMap& scripts, char const* tablename) +{ + if(sWorld.IsScriptScheduled()) // function don't must be called in time scripts use. + return; + + sLog.outString( "%s :", tablename); + + scripts.clear(); // need for reload support + + QueryResult *result = WorldDatabase.PQuery( "SELECT id,delay,command,datalong,datalong2,datatext, x, y, z, o FROM %s", tablename ); + + uint32 count = 0; + + if( !result ) + { + barGoLink bar( 1 ); + bar.step(); + + sLog.outString(); + sLog.outString( ">> Loaded %u script definitions", count ); + return; + } + + barGoLink bar( result->GetRowCount() ); + + do + { + bar.step(); + + Field *fields = result->Fetch(); + ScriptInfo tmp; + tmp.id = fields[0].GetUInt32(); + tmp.delay = fields[1].GetUInt32(); + tmp.command = fields[2].GetUInt32(); + tmp.datalong = fields[3].GetUInt32(); + tmp.datalong2 = fields[4].GetUInt32(); + tmp.datatext = fields[5].GetCppString(); + tmp.x = fields[6].GetFloat(); + tmp.y = fields[7].GetFloat(); + tmp.z = fields[8].GetFloat(); + tmp.o = fields[9].GetFloat(); + + // generic command args check + switch(tmp.command) + { + case SCRIPT_COMMAND_TALK: + { + if(tmp.datalong > 3) + { + sLog.outErrorDb("Table `%s` has invalid talk type (datalong = %u) in SCRIPT_COMMAND_TALK for script id %u",tablename,tmp.datalong,tmp.id); + continue; + } + break; + } + + case SCRIPT_COMMAND_TELEPORT_TO: + { + if(!sMapStore.LookupEntry(tmp.datalong)) + { + sLog.outErrorDb("Table `%s` has invalid map (Id: %u) in SCRIPT_COMMAND_TELEPORT_TO for script id %u",tablename,tmp.datalong,tmp.id); + continue; + } + + if(!MaNGOS::IsValidMapCoord(tmp.x,tmp.y,tmp.z,tmp.o)) + { + sLog.outErrorDb("Table `%s` has invalid coordinates (X: %f Y: %f) in SCRIPT_COMMAND_TELEPORT_TO for script id %u",tablename,tmp.x,tmp.y,tmp.id); + continue; + } + break; + } + + case SCRIPT_COMMAND_TEMP_SUMMON_CREATURE: + { + if(!MaNGOS::IsValidMapCoord(tmp.x,tmp.y,tmp.z,tmp.o)) + { + sLog.outErrorDb("Table `%s` has invalid coordinates (X: %f Y: %f) in SCRIPT_COMMAND_TEMP_SUMMON_CREATURE for script id %u",tablename,tmp.x,tmp.y,tmp.id); + continue; + } + + if(!GetCreatureTemplate(tmp.datalong)) + { + sLog.outErrorDb("Table `%s` has invalid creature (Entry: %u) in SCRIPT_COMMAND_TEMP_SUMMON_CREATURE for script id %u",tablename,tmp.datalong,tmp.id); + continue; + } + break; + } + + case SCRIPT_COMMAND_RESPAWN_GAMEOBJECT: + { + GameObjectData const* data = GetGOData(tmp.datalong); + if(!data) + { + sLog.outErrorDb("Table `%s` has invalid gameobject (GUID: %u) in SCRIPT_COMMAND_RESPAWN_GAMEOBJECT for script id %u",tablename,tmp.datalong,tmp.id); + continue; + } + + GameObjectInfo const* info = GetGameObjectInfo(data->id); + if(!info) + { + sLog.outErrorDb("Table `%s` has gameobject with invalid entry (GUID: %u Entry: %u) in SCRIPT_COMMAND_RESPAWN_GAMEOBJECT for script id %u",tablename,tmp.datalong,data->id,tmp.id); + continue; + } + + if( info->type==GAMEOBJECT_TYPE_FISHINGNODE || + info->type==GAMEOBJECT_TYPE_FISHINGHOLE || + info->type==GAMEOBJECT_TYPE_DOOR || + info->type==GAMEOBJECT_TYPE_BUTTON || + info->type==GAMEOBJECT_TYPE_TRAP ) + { + sLog.outErrorDb("Table `%s` have gameobject type (%u) unsupported by command SCRIPT_COMMAND_RESPAWN_GAMEOBJECT for script id %u",tablename,info->id,tmp.id); + continue; + } + break; + } + case SCRIPT_COMMAND_OPEN_DOOR: + case SCRIPT_COMMAND_CLOSE_DOOR: + { + GameObjectData const* data = GetGOData(tmp.datalong); + if(!data) + { + sLog.outErrorDb("Table `%s` has invalid gameobject (GUID: %u) in %s for script id %u",tablename,tmp.datalong,(tmp.command==SCRIPT_COMMAND_OPEN_DOOR ? "SCRIPT_COMMAND_OPEN_DOOR" : "SCRIPT_COMMAND_CLOSE_DOOR"),tmp.id); + continue; + } + + GameObjectInfo const* info = GetGameObjectInfo(data->id); + if(!info) + { + sLog.outErrorDb("Table `%s` has gameobject with invalid entry (GUID: %u Entry: %u) in %s for script id %u",tablename,tmp.datalong,data->id,(tmp.command==SCRIPT_COMMAND_OPEN_DOOR ? "SCRIPT_COMMAND_OPEN_DOOR" : "SCRIPT_COMMAND_CLOSE_DOOR"),tmp.id); + continue; + } + + if( info->type!=GAMEOBJECT_TYPE_DOOR) + { + sLog.outErrorDb("Table `%s` has gameobject type (%u) non supported by command %s for script id %u",tablename,info->id,(tmp.command==SCRIPT_COMMAND_OPEN_DOOR ? "SCRIPT_COMMAND_OPEN_DOOR" : "SCRIPT_COMMAND_CLOSE_DOOR"),tmp.id); + continue; + } + + break; + } + case SCRIPT_COMMAND_QUEST_EXPLORED: + { + Quest const* quest = GetQuestTemplate(tmp.datalong); + if(!quest) + { + sLog.outErrorDb("Table `%s` has invalid quest (ID: %u) in SCRIPT_COMMAND_QUEST_EXPLORED in `datalong` for script id %u",tablename,tmp.datalong,tmp.id); + continue; + } + + if(!quest->HasFlag(QUEST_MANGOS_FLAGS_EXPLORATION_OR_EVENT)) + { + sLog.outErrorDb("Table `%s` has quest (ID: %u) in SCRIPT_COMMAND_QUEST_EXPLORED in `datalong` for script id %u, but quest not have flag QUEST_MANGOS_FLAGS_EXPLORATION_OR_EVENT in quest flags. Script command or quest flags wrong. Quest modified to require objective.",tablename,tmp.datalong,tmp.id); + + // this will prevent quest completing without objective + const_cast(quest)->SetFlag(QUEST_MANGOS_FLAGS_EXPLORATION_OR_EVENT); + + // continue; - quest objective requiremet set and command can be allowed + } + + if(float(tmp.datalong2) > DEFAULT_VISIBILITY_DISTANCE) + { + sLog.outErrorDb("Table `%s` has too large distance (%u) for exploring objective complete in `datalong2` in SCRIPT_COMMAND_QUEST_EXPLORED in `datalong` for script id %u",tablename,tmp.datalong2,tmp.id); + continue; + } + + if(tmp.datalong2 && float(tmp.datalong2) > DEFAULT_VISIBILITY_DISTANCE) + { + sLog.outErrorDb("Table `%s` has too large distance (%u) for exploring objective complete in `datalong2` in SCRIPT_COMMAND_QUEST_EXPLORED in `datalong` for script id %u, max distance is %u or 0 for disable distance check",tablename,tmp.datalong2,tmp.id,uint32(DEFAULT_VISIBILITY_DISTANCE)); + continue; + } + + if(tmp.datalong2 && float(tmp.datalong2) < INTERACTION_DISTANCE) + { + sLog.outErrorDb("Table `%s` has too small distance (%u) for exploring objective complete in `datalong2` in SCRIPT_COMMAND_QUEST_EXPLORED in `datalong` for script id %u, min distance is %u or 0 for disable distance check",tablename,tmp.datalong2,tmp.id,uint32(INTERACTION_DISTANCE)); + continue; + } + + break; + } + + case SCRIPT_COMMAND_REMOVE_AURA: + case SCRIPT_COMMAND_CAST_SPELL: + { + if(!sSpellStore.LookupEntry(tmp.datalong)) + { + sLog.outErrorDb("Table `%s` using non-existent spell (id: %u) in SCRIPT_COMMAND_REMOVE_AURA or SCRIPT_COMMAND_CAST_SPELL for script id %u",tablename,tmp.datalong,tmp.id); + continue; + } + break; + } + } + + if (scripts.find(tmp.id) == scripts.end()) + { + ScriptMap emptyMap; + scripts[tmp.id] = emptyMap; + } + scripts[tmp.id].insert(std::pair(tmp.delay, tmp)); + + ++count; + } while( result->NextRow() ); + + delete result; + + sLog.outString(); + sLog.outString( ">> Loaded %u script definitions", count ); +} + +void ObjectMgr::LoadGameObjectScripts() +{ + LoadScripts(sGameObjectScripts, "gameobject_scripts"); + + // check ids + for(ScriptMapMap::const_iterator itr = sGameObjectScripts.begin(); itr != sGameObjectScripts.end(); ++itr) + { + if(!GetGOData(itr->first)) + sLog.outErrorDb("Table `gameobject_scripts` has not existing gameobject (GUID: %u) as script id",itr->first); + } +} + +void ObjectMgr::LoadQuestEndScripts() +{ + LoadScripts(sQuestEndScripts, "quest_end_scripts"); + + // check ids + for(ScriptMapMap::const_iterator itr = sQuestEndScripts.begin(); itr != sQuestEndScripts.end(); ++itr) + { + if(!GetQuestTemplate(itr->first)) + sLog.outErrorDb("Table `quest_end_scripts` has not existing quest (Id: %u) as script id",itr->first); + } +} + +void ObjectMgr::LoadQuestStartScripts() +{ + LoadScripts(sQuestStartScripts,"quest_start_scripts"); + + // check ids + for(ScriptMapMap::const_iterator itr = sQuestStartScripts.begin(); itr != sQuestStartScripts.end(); ++itr) + { + if(!GetQuestTemplate(itr->first)) + sLog.outErrorDb("Table `quest_start_scripts` has not existing quest (Id: %u) as script id",itr->first); + } +} + +void ObjectMgr::LoadSpellScripts() +{ + LoadScripts(sSpellScripts, "spell_scripts"); + + // check ids + for(ScriptMapMap::const_iterator itr = sSpellScripts.begin(); itr != sSpellScripts.end(); ++itr) + { + SpellEntry const* spellInfo = sSpellStore.LookupEntry(itr->first); + + if(!spellInfo) + { + sLog.outErrorDb("Table `spell_scripts` has not existing spell (Id: %u) as script id",itr->first); + continue; + } + + //check for correct spellEffect + bool found = false; + for(int i=0; i<3; ++i) + { + // skip empty effects + if( !spellInfo->Effect[i] ) + continue; + + if( spellInfo->Effect[i] == SPELL_EFFECT_SCRIPT_EFFECT ) + { + found = true; + break; + } + } + + if(!found) + sLog.outErrorDb("Table `spell_scripts` has unsupported spell (Id: %u) without SPELL_EFFECT_SCRIPT_EFFECT (%u) spell effect",itr->first,SPELL_EFFECT_SCRIPT_EFFECT); + } +} + +void ObjectMgr::LoadEventScripts() +{ + LoadScripts(sEventScripts, "event_scripts"); + + std::set evt_scripts; + // Load all possible script entries from gameobjects + for(uint32 i = 1; i < sGOStorage.MaxEntry; ++i) + { + GameObjectInfo const * goInfo = sGOStorage.LookupEntry(i); + if (goInfo) + { + switch(goInfo->type) + { + case GAMEOBJECT_TYPE_GOOBER: + if(goInfo->goober.eventId) + evt_scripts.insert(goInfo->goober.eventId); + break; + case GAMEOBJECT_TYPE_CHEST: + if(goInfo->chest.eventId) + evt_scripts.insert(goInfo->chest.eventId); + break; + default: + break; + } + } + } + // Load all possible script entries from spells + for(uint32 i = 1; i < sSpellStore.GetNumRows(); ++i) + { + SpellEntry const * spell = sSpellStore.LookupEntry(i); + if (spell) + { + for(int j=0; j<3; ++j) + { + if( spell->Effect[j] == SPELL_EFFECT_SEND_EVENT ) + { + if (spell->EffectMiscValue[j]) + evt_scripts.insert(spell->EffectMiscValue[j]); + } + } + } + } + // Then check if all scripts are in above list of possible script entries + for(ScriptMapMap::const_iterator itr = sEventScripts.begin(); itr != sEventScripts.end(); ++itr) + { + std::set::const_iterator itr2 = evt_scripts.find(itr->first); + if (itr2 == evt_scripts.end()) + sLog.outErrorDb("Table `event_scripts` has script (Id: %u) not refering to any gameobject_template type 10 data2 field or type 3 data6 field or any spell effect %u", itr->first, SPELL_EFFECT_SEND_EVENT); + } +} + +void ObjectMgr::LoadItemTexts() +{ + QueryResult *result = CharacterDatabase.PQuery("SELECT id, text FROM item_text"); + + uint32 count = 0; + + if( !result ) + { + barGoLink bar( 1 ); + bar.step(); + + sLog.outString(); + sLog.outString( ">> Loaded %u item pages", count ); + return; + } + + barGoLink bar( result->GetRowCount() ); + + Field* fields; + do + { + bar.step(); + + fields = result->Fetch(); + + mItemTexts[ fields[0].GetUInt32() ] = fields[1].GetCppString(); + + ++count; + + } while ( result->NextRow() ); + + delete result; + + sLog.outString(); + sLog.outString( ">> Loaded %u item texts", count ); +} + +void ObjectMgr::LoadPageTexts() +{ + sPageTextStore.Free(); // for reload case + + sPageTextStore.Load(); + sLog.outString( ">> Loaded %u page texts", sPageTextStore.RecordCount ); + sLog.outString(); + + for(uint32 i = 1; i < sPageTextStore.MaxEntry; ++i) + { + // check data correctness + PageText const* page = sPageTextStore.LookupEntry(i); + if(!page) + continue; + + if(page->Next_Page && !sPageTextStore.LookupEntry(page->Next_Page)) + { + sLog.outErrorDb("Page text (Id: %u) has not existing next page (Id:%u)", i,page->Next_Page); + continue; + } + + // detect circular reference + std::set checkedPages; + for(PageText const* pageItr = page; pageItr; pageItr = sPageTextStore.LookupEntry(pageItr->Next_Page)) + { + if(!pageItr->Next_Page) + break; + checkedPages.insert(pageItr->Page_ID); + if(checkedPages.find(pageItr->Next_Page)!=checkedPages.end()) + { + std::ostringstream ss; + ss<< "The text page(s) "; + for (std::set::iterator itr= checkedPages.begin();itr!=checkedPages.end(); itr++) + ss << *itr << " "; + ss << "create(s) a circular reference, which can cause the server to freeze. Changing Next_Page of page " + << pageItr->Page_ID <<" to 0"; + sLog.outErrorDb(ss.str().c_str()); + const_cast(pageItr)->Next_Page = 0; + break; + } + } + } +} + +void ObjectMgr::LoadPageTextLocales() +{ + QueryResult *result = WorldDatabase.PQuery("SELECT entry,text_loc1,text_loc2,text_loc3,text_loc4,text_loc5,text_loc6,text_loc7,text_loc8 FROM locales_page_text"); + + if(!result) + { + barGoLink bar(1); + + bar.step(); + + sLog.outString(""); + sLog.outString(">> Loaded 0 PageText locale strings. DB table `locales_page_text` is empty."); + return; + } + + barGoLink bar(result->GetRowCount()); + + do + { + Field *fields = result->Fetch(); + bar.step(); + + uint32 entry = fields[0].GetUInt32(); + + PageTextLocale& data = mPageTextLocaleMap[entry]; + + for(int i = 1; i < MAX_LOCALE; ++i) + { + std::string str = fields[i].GetCppString(); + if(str.empty()) + continue; + + int idx = GetOrNewIndexForLocale(LocaleConstant(i)); + if(idx >= 0) + { + if(data.Text.size() <= idx) + data.Text.resize(idx+1); + + data.Text[idx] = str; + } + } + + } while (result->NextRow()); + + delete result; + + sLog.outString(); + sLog.outString( ">> Loaded %u PageText locale strings", mPageTextLocaleMap.size() ); +} + +void ObjectMgr::LoadInstanceTemplate() +{ + sInstanceTemplate.Load(); + + for(uint32 i = 0; i < sInstanceTemplate.MaxEntry; i++) + { + InstanceTemplate* temp = (InstanceTemplate*)GetInstanceTemplate(i); + if(!temp) continue; + const MapEntry* entry = sMapStore.LookupEntry(temp->map); + if(!entry) + { + sLog.outErrorDb("ObjectMgr::LoadInstanceTemplate: bad mapid %d for template!", temp->map); + continue; + } + else if(!entry->HasResetTime()) + continue; + + if(temp->reset_delay == 0) + { + // use defaults from the DBC + if(entry->SupportsHeroicMode()) + { + temp->reset_delay = entry->resetTimeHeroic / DAY; + } + else if (entry->resetTimeRaid && entry->map_type == MAP_RAID) + { + temp->reset_delay = entry->resetTimeRaid / DAY; + } + } + + // the reset_delay must be atleast one day + temp->reset_delay = std::max((uint32)1, (uint32)(temp->reset_delay * sWorld.getRate(RATE_INSTANCE_RESET_TIME))); + } + + sLog.outString( ">> Loaded %u Instance Template definitions", sInstanceTemplate.RecordCount ); + sLog.outString(); +} + +void ObjectMgr::AddGossipText(GossipText *pGText) +{ + ASSERT( pGText->Text_ID ); + ASSERT( mGossipText.find(pGText->Text_ID) == mGossipText.end() ); + mGossipText[pGText->Text_ID] = pGText; +} + +GossipText *ObjectMgr::GetGossipText(uint32 Text_ID) +{ + GossipTextMap::const_iterator itr; + for (itr = mGossipText.begin(); itr != mGossipText.end(); itr++) + { + if(itr->second->Text_ID == Text_ID) + return itr->second; + } + return NULL; +} + +void ObjectMgr::LoadGossipText() +{ + GossipText *pGText; + QueryResult *result = WorldDatabase.Query( "SELECT * FROM npc_text" ); + + int count = 0; + if( !result ) + { + barGoLink bar( 1 ); + bar.step(); + + sLog.outString(); + sLog.outString( ">> Loaded %u npc texts", count ); + return; + } + + int cic; + + barGoLink bar( result->GetRowCount() ); + + do + { + ++count; + cic = 0; + + Field *fields = result->Fetch(); + + bar.step(); + + pGText = new GossipText; + pGText->Text_ID = fields[cic++].GetUInt32(); + + for (int i=0; i< 8; i++) + { + pGText->Options[i].Text_0 = fields[cic++].GetCppString(); + pGText->Options[i].Text_1 = fields[cic++].GetCppString(); + + pGText->Options[i].Language = fields[cic++].GetUInt32(); + pGText->Options[i].Probability = fields[cic++].GetFloat(); + + pGText->Options[i].Emotes[0]._Delay = fields[cic++].GetUInt32(); + pGText->Options[i].Emotes[0]._Emote = fields[cic++].GetUInt32(); + + pGText->Options[i].Emotes[1]._Delay = fields[cic++].GetUInt32(); + pGText->Options[i].Emotes[1]._Emote = fields[cic++].GetUInt32(); + + pGText->Options[i].Emotes[2]._Delay = fields[cic++].GetUInt32(); + pGText->Options[i].Emotes[2]._Emote = fields[cic++].GetUInt32(); + } + + if ( !pGText->Text_ID ) continue; + AddGossipText( pGText ); + + } while( result->NextRow() ); + + sLog.outString(); + sLog.outString( ">> Loaded %u npc texts", count ); + delete result; +} + +void ObjectMgr::LoadNpcTextLocales() +{ + QueryResult *result = WorldDatabase.Query("SELECT entry," + "Text0_0_loc1,Text0_1_loc1,Text1_0_loc1,Text1_1_loc1,Text2_0_loc1,Text2_1_loc1,Text3_0_loc1,Text3_1_loc1,Text4_0_loc1,Text4_1_loc1,Text5_0_loc1,Text5_1_loc1,Text6_0_loc1,Text6_1_loc1,Text7_0_loc1,Text7_1_loc1," + "Text0_0_loc2,Text0_1_loc2,Text1_0_loc2,Text1_1_loc2,Text2_0_loc2,Text2_1_loc2,Text3_0_loc2,Text3_1_loc1,Text4_0_loc2,Text4_1_loc2,Text5_0_loc2,Text5_1_loc2,Text6_0_loc2,Text6_1_loc2,Text7_0_loc2,Text7_1_loc2," + "Text0_0_loc3,Text0_1_loc3,Text1_0_loc3,Text1_1_loc3,Text2_0_loc3,Text2_1_loc3,Text3_0_loc3,Text3_1_loc1,Text4_0_loc3,Text4_1_loc3,Text5_0_loc3,Text5_1_loc3,Text6_0_loc3,Text6_1_loc3,Text7_0_loc3,Text7_1_loc3," + "Text0_0_loc4,Text0_1_loc4,Text1_0_loc4,Text1_1_loc4,Text2_0_loc4,Text2_1_loc4,Text3_0_loc4,Text3_1_loc1,Text4_0_loc4,Text4_1_loc4,Text5_0_loc4,Text5_1_loc4,Text6_0_loc4,Text6_1_loc4,Text7_0_loc4,Text7_1_loc4," + "Text0_0_loc5,Text0_1_loc5,Text1_0_loc5,Text1_1_loc5,Text2_0_loc5,Text2_1_loc5,Text3_0_loc5,Text3_1_loc1,Text4_0_loc5,Text4_1_loc5,Text5_0_loc5,Text5_1_loc5,Text6_0_loc5,Text6_1_loc5,Text7_0_loc5,Text7_1_loc5," + "Text0_0_loc6,Text0_1_loc6,Text1_0_loc6,Text1_1_loc6,Text2_0_loc6,Text2_1_loc6,Text3_0_loc6,Text3_1_loc1,Text4_0_loc6,Text4_1_loc6,Text5_0_loc6,Text5_1_loc6,Text6_0_loc6,Text6_1_loc6,Text7_0_loc6,Text7_1_loc6," + "Text0_0_loc7,Text0_1_loc7,Text1_0_loc7,Text1_1_loc7,Text2_0_loc7,Text2_1_loc7,Text3_0_loc7,Text3_1_loc1,Text4_0_loc7,Text4_1_loc7,Text5_0_loc7,Text5_1_loc7,Text6_0_loc7,Text6_1_loc7,Text7_0_loc7,Text7_1_loc7, " + "Text0_0_loc8,Text0_1_loc8,Text1_0_loc8,Text1_1_loc8,Text2_0_loc8,Text2_1_loc8,Text3_0_loc8,Text3_1_loc1,Text4_0_loc8,Text4_1_loc8,Text5_0_loc8,Text5_1_loc8,Text6_0_loc8,Text6_1_loc8,Text7_0_loc8,Text7_1_loc8 " + " FROM locales_npc_text"); + + if(!result) + { + barGoLink bar(1); + + bar.step(); + + sLog.outString(""); + sLog.outString(">> Loaded 0 Quest locale strings. DB table `locales_npc_text` is empty."); + return; + } + + barGoLink bar(result->GetRowCount()); + + do + { + Field *fields = result->Fetch(); + bar.step(); + + uint32 entry = fields[0].GetUInt32(); + + NpcTextLocale& data = mNpcTextLocaleMap[entry]; + + for(int i=1; i= 0) + { + if(data.Text_0[j].size() <= idx) + data.Text_0[j].resize(idx+1); + + data.Text_0[j][idx] = str0; + } + } + std::string str1 = fields[1+8*2*(i-1)+2*j+1].GetCppString(); + if(!str1.empty()) + { + int idx = GetOrNewIndexForLocale(LocaleConstant(i)); + if(idx >= 0) + { + if(data.Text_1[j].size() <= idx) + data.Text_1[j].resize(idx+1); + + data.Text_1[j][idx] = str1; + } + } + } + } + } while (result->NextRow()); + + delete result; + + sLog.outString(); + sLog.outString( ">> Loaded %u NpcText locale strings", mNpcTextLocaleMap.size() ); +} + +//not very fast function but it is called only once a day, or on starting-up +void ObjectMgr::ReturnOrDeleteOldMails(bool serverUp) +{ + time_t basetime = time(NULL); + sLog.outDebug("Returning mails current time: hour: %d, minute: %d, second: %d ", localtime(&basetime)->tm_hour, localtime(&basetime)->tm_min, localtime(&basetime)->tm_sec); + //delete all old mails without item and without body immediately, if starting server + if (!serverUp) + CharacterDatabase.PExecute("DELETE FROM mail WHERE expire_time < '" I64FMTD "' AND has_items = '0' AND itemTextId = 0", (uint64)basetime); + // 0 1 2 3 4 5 6 7 8 9 + QueryResult* result = CharacterDatabase.PQuery("SELECT id,messageType,sender,receiver,itemTextId,has_items,expire_time,cod,checked,mailTemplateId FROM mail WHERE expire_time < '" I64FMTD "'", (uint64)basetime); + if ( !result ) + return; // any mails need to be returned or deleted + Field *fields; + //std::ostringstream delitems, delmails; //will be here for optimization + //bool deletemail = false, deleteitem = false; + //delitems << "DELETE FROM item_instance WHERE guid IN ( "; + //delmails << "DELETE FROM mail WHERE id IN ( " + do + { + fields = result->Fetch(); + Mail *m = new Mail; + m->messageID = fields[0].GetUInt32(); + m->messageType = fields[1].GetUInt8(); + m->sender = fields[2].GetUInt32(); + m->receiver = fields[3].GetUInt32(); + m->itemTextId = fields[4].GetUInt32(); + bool has_items = fields[5].GetBool(); + m->expire_time = (time_t)fields[6].GetUInt64(); + m->deliver_time = 0; + m->COD = fields[7].GetUInt32(); + m->checked = fields[8].GetUInt32(); + m->mailTemplateId = fields[9].GetInt16(); + + Player *pl = 0; + if (serverUp) + pl = GetPlayer((uint64)m->receiver); + if (pl && pl->m_mailsLoaded) + { //this code will run very improbably (the time is between 4 and 5 am, in game is online a player, who has old mail + //his in mailbox and he has already listed his mails ) + delete m; + continue; + } + //delete or return mail: + if (has_items) + { + QueryResult *resultItems = CharacterDatabase.PQuery("SELECT item_guid,item_template FROM mail_items WHERE mail_id='%u'", m->messageID); + if(resultItems) + { + do + { + Field *fields2 = resultItems->Fetch(); + + uint32 item_guid_low = fields2[0].GetUInt32(); + uint32 item_template = fields2[1].GetUInt32(); + + m->AddItem(item_guid_low, item_template); + } + while (resultItems->NextRow()); + + delete resultItems; + } + //if it is mail from AH, it shouldn't be returned, but deleted + if (m->messageType != MAIL_NORMAL || (m->checked & (MAIL_CHECK_MASK_AUCTION | MAIL_CHECK_MASK_COD_PAYMENT | MAIL_CHECK_MASK_RETURNED))) + { + // mail open and then not returned + for(std::vector::iterator itr2 = m->items.begin(); itr2 != m->items.end(); ++itr2) + CharacterDatabase.PExecute("DELETE FROM item_instance WHERE guid = '%u'", itr2->item_guid); + } + else + { + //mail will be returned: + CharacterDatabase.PExecute("UPDATE mail SET sender = '%u', receiver = '%u', expire_time = '" I64FMTD "', deliver_time = '" I64FMTD "',cod = '0', checked = '%u' WHERE id = '%u'", m->receiver, m->sender, (uint64)(basetime + 30*DAY), (uint64)basetime, MAIL_CHECK_MASK_RETURNED, m->messageID); + delete m; + continue; + } + } + + if (m->itemTextId) + CharacterDatabase.PExecute("DELETE FROM item_text WHERE id = '%u'", m->itemTextId); + + //deletemail = true; + //delmails << m->messageID << ", "; + CharacterDatabase.PExecute("DELETE FROM mail WHERE id = '%u'", m->messageID); + delete m; + } while (result->NextRow()); + delete result; +} + +void ObjectMgr::LoadQuestAreaTriggers() +{ + mQuestAreaTriggerMap.clear(); // need for reload case + + QueryResult *result = WorldDatabase.Query( "SELECT id,quest FROM areatrigger_involvedrelation" ); + + uint32 count = 0; + + if( !result ) + { + barGoLink bar( 1 ); + bar.step(); + + sLog.outString(); + sLog.outString( ">> Loaded %u quest trigger points", count ); + return; + } + + barGoLink bar( result->GetRowCount() ); + + do + { + ++count; + bar.step(); + + Field *fields = result->Fetch(); + + uint32 trigger_ID = fields[0].GetUInt32(); + uint32 quest_ID = fields[1].GetUInt32(); + + AreaTriggerEntry const* atEntry = sAreaTriggerStore.LookupEntry(trigger_ID); + if(!atEntry) + { + sLog.outErrorDb("Area trigger (ID:%u) does not exist in `AreaTrigger.dbc`.",trigger_ID); + continue; + } + + Quest const* quest = GetQuestTemplate(quest_ID); + + if(!quest) + { + sLog.outErrorDb("Table `areatrigger_involvedrelation` has record (id: %u) for not existing quest %u",trigger_ID,quest_ID); + continue; + } + + if(!quest->HasFlag(QUEST_MANGOS_FLAGS_EXPLORATION_OR_EVENT)) + { + sLog.outErrorDb("Table `areatrigger_involvedrelation` has record (id: %u) for not quest %u, but quest not have flag QUEST_MANGOS_FLAGS_EXPLORATION_OR_EVENT. Trigger or quest flags must be fixed, quest modified to require objective.",trigger_ID,quest_ID); + + // this will prevent quest completing without objective + const_cast(quest)->SetFlag(QUEST_MANGOS_FLAGS_EXPLORATION_OR_EVENT); + + // continue; - quest modified to required obkective and trigger can be allowed. + } + + mQuestAreaTriggerMap[trigger_ID] = quest_ID; + + } while( result->NextRow() ); + + delete result; + + sLog.outString(); + sLog.outString( ">> Loaded %u quest trigger points", count ); +} + +void ObjectMgr::LoadTavernAreaTriggers() +{ + mTavernAreaTriggerSet.clear(); // need for reload case + + QueryResult *result = WorldDatabase.Query("SELECT id FROM areatrigger_tavern"); + + uint32 count = 0; + + if( !result ) + { + barGoLink bar( 1 ); + bar.step(); + + sLog.outString(); + sLog.outString( ">> Loaded %u tavern triggers", count ); + return; + } + + barGoLink bar( result->GetRowCount() ); + + do + { + ++count; + bar.step(); + + Field *fields = result->Fetch(); + + uint32 Trigger_ID = fields[0].GetUInt32(); + + AreaTriggerEntry const* atEntry = sAreaTriggerStore.LookupEntry(Trigger_ID); + if(!atEntry) + { + sLog.outErrorDb("Area trigger (ID:%u) does not exist in `AreaTrigger.dbc`.",Trigger_ID); + continue; + } + + mTavernAreaTriggerSet.insert(Trigger_ID); + } while( result->NextRow() ); + + delete result; + + sLog.outString(); + sLog.outString( ">> Loaded %u tavern triggers", count ); +} + +void ObjectMgr::LoadAreaTriggerScripts() +{ + mAreaTriggerScripts.clear(); // need for reload case + QueryResult *result = WorldDatabase.Query("SELECT entry, ScriptName FROM areatrigger_scripts"); + + uint32 count = 0; + + if( !result ) + { + barGoLink bar( 1 ); + bar.step(); + + sLog.outString(); + sLog.outString( ">> Loaded %u areatrigger scripts", count ); + return; + } + + barGoLink bar( result->GetRowCount() ); + + do + { + ++count; + bar.step(); + + Field *fields = result->Fetch(); + + uint32 Trigger_ID = fields[0].GetUInt32(); + std::string scriptName = fields[1].GetCppString(); + + AreaTriggerEntry const* atEntry = sAreaTriggerStore.LookupEntry(Trigger_ID); + if(!atEntry) + { + sLog.outErrorDb("Area trigger (ID:%u) does not exist in `AreaTrigger.dbc`.",Trigger_ID); + continue; + } + mAreaTriggerScripts[Trigger_ID] = scriptName; + } while( result->NextRow() ); + + delete result; + + sLog.outString(); + sLog.outString( ">> Loaded %u areatrigger scripts", count ); +} +uint32 ObjectMgr::GetNearestTaxiNode( float x, float y, float z, uint32 mapid ) +{ + bool found = false; + float dist; + uint32 id = 0; + + for(uint32 i = 1; i < sTaxiNodesStore.GetNumRows(); ++i) + { + TaxiNodesEntry const* node = sTaxiNodesStore.LookupEntry(i); + if(node && node->map_id == mapid) + { + float dist2 = (node->x - x)*(node->x - x)+(node->y - y)*(node->y - y)+(node->z - z)*(node->z - z); + if(found) + { + if(dist2 < dist) + { + dist = dist2; + id = i; + } + } + else + { + found = true; + dist = dist2; + id = i; + } + } + } + + return id; +} + +void ObjectMgr::GetTaxiPath( uint32 source, uint32 destination, uint32 &path, uint32 &cost) +{ + TaxiPathSetBySource::iterator src_i = sTaxiPathSetBySource.find(source); + if(src_i==sTaxiPathSetBySource.end()) + { + path = 0; + cost = 0; + return; + } + + TaxiPathSetForSource& pathSet = src_i->second; + + TaxiPathSetForSource::iterator dest_i = pathSet.find(destination); + if(dest_i==pathSet.end()) + { + path = 0; + cost = 0; + return; + } + + cost = dest_i->second.price; + path = dest_i->second.ID; +} + +uint16 ObjectMgr::GetTaxiMount( uint32 id, uint32 team ) +{ + uint16 mount_entry = 0; + uint16 mount_id = 0; + + TaxiNodesEntry const* node = sTaxiNodesStore.LookupEntry(id); + if(node) + { + if (team == ALLIANCE) + { + mount_entry = node->alliance_mount_type; + CreatureInfo const *ci = GetCreatureTemplate(mount_entry); + if(ci) + mount_id = ci->DisplayID_A; + } + if (team == HORDE) + { + mount_entry = node->horde_mount_type; + CreatureInfo const *ci = GetCreatureTemplate(mount_entry); + if(ci) + mount_id = ci->DisplayID_H; + } + } + + CreatureModelInfo const *minfo = GetCreatureModelInfo(mount_id); + if(!minfo) + { + sLog.outErrorDb("Taxi mount (Entry: %u) for taxi node (Id: %u) for team %u has model %u not found in table `creature_model_info`, can't load. ", + mount_entry,id,team,mount_id); + + return false; + } + if(minfo->modelid_other_gender!=0) + mount_id = urand(0,1) ? mount_id : minfo->modelid_other_gender; + + return mount_id; +} + +void ObjectMgr::GetTaxiPathNodes( uint32 path, Path &pathnodes, std::vector& mapIds) +{ + if(path >= sTaxiPathNodesByPath.size()) + return; + + TaxiPathNodeList& nodeList = sTaxiPathNodesByPath[path]; + + pathnodes.Resize(nodeList.size()); + mapIds.resize(nodeList.size()); + + for(size_t i = 0; i < nodeList.size(); ++i) + { + pathnodes[ i ].x = nodeList[i].x; + pathnodes[ i ].y = nodeList[i].y; + pathnodes[ i ].z = nodeList[i].z; + + mapIds[i] = nodeList[i].mapid; + } +} + +void ObjectMgr::GetTransportPathNodes( uint32 path, TransportPath &pathnodes ) +{ + if(path >= sTaxiPathNodesByPath.size()) + return; + + TaxiPathNodeList& nodeList = sTaxiPathNodesByPath[path]; + + pathnodes.Resize(nodeList.size()); + + for(size_t i = 0; i < nodeList.size(); ++i) + { + pathnodes[ i ].mapid = nodeList[i].mapid; + pathnodes[ i ].x = nodeList[i].x; + pathnodes[ i ].y = nodeList[i].y; + pathnodes[ i ].z = nodeList[i].z; + pathnodes[ i ].actionFlag = nodeList[i].actionFlag; + pathnodes[ i ].delay = nodeList[i].delay; + } +} + +void ObjectMgr::LoadGraveyardZones() +{ + mGraveYardMap.clear(); // need for reload case + + QueryResult *result = WorldDatabase.Query("SELECT id,ghost_zone,faction FROM game_graveyard_zone"); + + uint32 count = 0; + + if( !result ) + { + barGoLink bar( 1 ); + bar.step(); + + sLog.outString(); + sLog.outString( ">> Loaded %u graveyard-zone links", count ); + return; + } + + barGoLink bar( result->GetRowCount() ); + + do + { + ++count; + bar.step(); + + Field *fields = result->Fetch(); + + uint32 safeLocId = fields[0].GetUInt32(); + uint32 zoneId = fields[1].GetUInt32(); + uint32 team = fields[2].GetUInt32(); + + WorldSafeLocsEntry const* entry = sWorldSafeLocsStore.LookupEntry(safeLocId); + if(!entry) + { + sLog.outErrorDb("Table `game_graveyard_zone` has record for not existing graveyard (WorldSafeLocs.dbc id) %u, skipped.",safeLocId); + continue; + } + + AreaTableEntry const *areaEntry = GetAreaEntryByAreaID(zoneId); + if(!areaEntry) + { + sLog.outErrorDb("Table `game_graveyard_zone` has record for not existing zone id (%u), skipped.",zoneId); + continue; + } + + if(areaEntry->zone != 0) + { + sLog.outErrorDb("Table `game_graveyard_zone` has record subzone id (%u) instead of zone, skipped.",zoneId); + continue; + } + + if(team!=0 && team!=HORDE && team!=ALLIANCE) + { + sLog.outErrorDb("Table `game_graveyard_zone` has record for non player faction (%u), skipped.",team); + continue; + } + + if(entry->map_id != areaEntry->mapid && team != 0) + { + sLog.outErrorDb("Table `game_graveyard_zone` has record for ghost zone (%u) at map %u and graveyard (%u) at map %u for team %u, but in case maps are different, player faction setting is ignored. Use faction 0 instead.",zoneId,areaEntry->mapid, safeLocId, entry->map_id, team); + team = 0; + } + + if(!AddGraveYardLink(safeLocId,zoneId,team,false)) + sLog.outErrorDb("Table `game_graveyard_zone` has a duplicate record for Garveyard (ID: %u) and Zone (ID: %u), skipped.",safeLocId,zoneId); + } while( result->NextRow() ); + + delete result; + + sLog.outString(); + sLog.outString( ">> Loaded %u graveyard-zone links", count ); +} + +WorldSafeLocsEntry const *ObjectMgr::GetClosestGraveYard(float x, float y, float z, uint32 MapId, uint32 team) +{ + // search for zone associated closest graveyard + uint32 zoneId = MapManager::Instance().GetZoneId(MapId,x,y); + + // Simulate std. algorithm: + // found some graveyard associated to (ghost_zone,ghost_map) + // + // if mapId == graveyard.mapId (ghost in plain zone or city or battleground) and search graveyard at same map + // then check faction + // if mapId != graveyard.mapId (ghost in instance) and search any graveyard associated + // then skip check faction + GraveYardMap::const_iterator graveLow = mGraveYardMap.lower_bound(zoneId); + GraveYardMap::const_iterator graveUp = mGraveYardMap.upper_bound(zoneId); + if(graveLow==graveUp) + { + sLog.outErrorDb("Table `game_graveyard_zone` incomplete: Zone %u Team %u does not have a linked graveyard.",zoneId,team); + return NULL; + } + + bool foundNear = false; + float distNear; + WorldSafeLocsEntry const* entryNear = NULL; + WorldSafeLocsEntry const* entryFar = NULL; + + for(GraveYardMap::const_iterator itr = graveLow; itr != graveUp; ++itr) + { + GraveYardData const& data = itr->second; + + WorldSafeLocsEntry const* entry = sWorldSafeLocsStore.LookupEntry(data.safeLocId); + if(!entry) + { + sLog.outErrorDb("Table `game_graveyard_zone` has record for not existing graveyard (WorldSafeLocs.dbc id) %u, skipped.",data.safeLocId); + continue; + } + + // remember first graveyard at another map and ignore other + if(MapId != entry->map_id) + { + if(!entryFar) + entryFar = entry; + continue; + } + + // skip enemy faction graveyard at same map (normal area, city, or battleground) + // team == 0 case can be at call from .neargrave + if(data.team != 0 && team != 0 && data.team != team) + continue; + + // find now nearest graveyard at same map + float dist2 = (entry->x - x)*(entry->x - x)+(entry->y - y)*(entry->y - y)+(entry->z - z)*(entry->z - z); + if(foundNear) + { + if(dist2 < distNear) + { + distNear = dist2; + entryNear = entry; + } + } + else + { + foundNear = true; + distNear = dist2; + entryNear = entry; + } + } + + if(entryNear) + return entryNear; + + return entryFar; +} + +GraveYardData const* ObjectMgr::FindGraveYardData(uint32 id, uint32 zoneId) +{ + GraveYardMap::const_iterator graveLow = mGraveYardMap.lower_bound(zoneId); + GraveYardMap::const_iterator graveUp = mGraveYardMap.upper_bound(zoneId); + + for(GraveYardMap::const_iterator itr = graveLow; itr != graveUp; ++itr) + { + if(itr->second.safeLocId==id) + return &itr->second; + } + + return NULL; +} + +bool ObjectMgr::AddGraveYardLink(uint32 id, uint32 zoneId, uint32 team, bool inDB) +{ + if(FindGraveYardData(id,zoneId)) + return false; + + // add link to loaded data + GraveYardData data; + data.safeLocId = id; + data.team = team; + + mGraveYardMap.insert(GraveYardMap::value_type(zoneId,data)); + + // add link to DB + if(inDB) + { + WorldDatabase.PExecuteLog("INSERT INTO game_graveyard_zone ( id,ghost_zone,faction) " + "VALUES ('%u', '%u','%u')",id,zoneId,team); + } + + return true; +} + +void ObjectMgr::LoadAreaTriggerTeleports() +{ + mAreaTriggers.clear(); // need for reload case + + uint32 count = 0; + + // 0 1 2 3 4 5 6 7 8 9 10 11 12 + QueryResult *result = WorldDatabase.Query("SELECT id, required_level, required_item, required_item2, heroic_key, heroic_key2, required_quest_done, required_failed_text, target_map, target_position_x, target_position_y, target_position_z, target_orientation FROM areatrigger_teleport"); + if( !result ) + { + + barGoLink bar( 1 ); + + bar.step(); + + sLog.outString(); + sLog.outString( ">> Loaded %u area trigger teleport definitions", count ); + return; + } + + barGoLink bar( result->GetRowCount() ); + + do + { + Field *fields = result->Fetch(); + + bar.step(); + + ++count; + + uint32 Trigger_ID = fields[0].GetUInt32(); + + AreaTrigger at; + + at.requiredLevel = fields[1].GetUInt8(); + at.requiredItem = fields[2].GetUInt32(); + at.requiredItem2 = fields[3].GetUInt32(); + at.heroicKey = fields[4].GetUInt32(); + at.heroicKey2 = fields[5].GetUInt32(); + at.requiredQuest = fields[6].GetUInt32(); + at.requiredFailedText = fields[7].GetCppString(); + at.target_mapId = fields[8].GetUInt32(); + at.target_X = fields[9].GetFloat(); + at.target_Y = fields[10].GetFloat(); + at.target_Z = fields[11].GetFloat(); + at.target_Orientation = fields[12].GetFloat(); + + AreaTriggerEntry const* atEntry = sAreaTriggerStore.LookupEntry(Trigger_ID); + if(!atEntry) + { + sLog.outErrorDb("Area trigger (ID:%u) does not exist in `AreaTrigger.dbc`.",Trigger_ID); + continue; + } + + if(at.requiredItem) + { + ItemPrototype const *pProto = GetItemPrototype(at.requiredItem); + if(!pProto) + { + sLog.outError("Key item %u does not exist for trigger %u, removing key requirement.", at.requiredItem, Trigger_ID); + at.requiredItem = 0; + } + } + if(at.requiredItem2) + { + ItemPrototype const *pProto = GetItemPrototype(at.requiredItem2); + if(!pProto) + { + sLog.outError("Second item %u not exist for trigger %u, remove key requirement.", at.requiredItem2, Trigger_ID); + at.requiredItem2 = 0; + } + } + + if(at.heroicKey) + { + ItemPrototype const *pProto = GetItemPrototype(at.heroicKey); + if(!pProto) + { + sLog.outError("Heroic key item %u not exist for trigger %u, remove key requirement.", at.heroicKey, Trigger_ID); + at.heroicKey = 0; + } + } + + if(at.heroicKey2) + { + ItemPrototype const *pProto = GetItemPrototype(at.heroicKey2); + if(!pProto) + { + sLog.outError("Heroic second key item %u not exist for trigger %u, remove key requirement.", at.heroicKey2, Trigger_ID); + at.heroicKey2 = 0; + } + } + + if(at.requiredQuest) + { + if(!mQuestTemplates[at.requiredQuest]) + { + sLog.outErrorDb("Required Quest %u not exist for trigger %u, remove quest done requirement.",at.requiredQuest,Trigger_ID); + at.requiredQuest = 0; + } + } + + MapEntry const* mapEntry = sMapStore.LookupEntry(at.target_mapId); + if(!mapEntry) + { + sLog.outErrorDb("Area trigger (ID:%u) target map (ID: %u) does not exist in `Map.dbc`.",Trigger_ID,at.target_mapId); + continue; + } + + if(at.target_X==0 && at.target_Y==0 && at.target_Z==0) + { + sLog.outErrorDb("Area trigger (ID:%u) target coordinates not provided.",Trigger_ID); + continue; + } + + mAreaTriggers[Trigger_ID] = at; + + } while( result->NextRow() ); + + delete result; + + sLog.outString(); + sLog.outString( ">> Loaded %u area trigger teleport definitions", count ); +} + +AreaTrigger const* ObjectMgr::GetGoBackTrigger(uint32 Map) const +{ + const MapEntry *mapEntry = sMapStore.LookupEntry(Map); + if(!mapEntry) return NULL; + for (AreaTriggerMap::const_iterator itr = mAreaTriggers.begin(); itr != mAreaTriggers.end(); itr++) + { + if(itr->second.target_mapId == mapEntry->parent_map) + { + AreaTriggerEntry const* atEntry = sAreaTriggerStore.LookupEntry(itr->first); + if(atEntry && atEntry->mapid == Map) + return &itr->second; + } + } + return NULL; +} + +void ObjectMgr::SetHighestGuids() +{ + QueryResult *result = CharacterDatabase.Query( "SELECT MAX(guid) FROM characters" ); + if( result ) + { + m_hiCharGuid = (*result)[0].GetUInt32()+1; + + delete result; + } + + result = WorldDatabase.Query( "SELECT MAX(guid) FROM creature" ); + if( result ) + { + m_hiCreatureGuid = (*result)[0].GetUInt32()+1; + + delete result; + } + + result = CharacterDatabase.Query( "SELECT MAX(id) FROM character_pet" ); + if( result ) + { + m_hiPetGuid = (*result)[0].GetUInt32()+1; + + delete result; + } + + result = CharacterDatabase.Query( "SELECT MAX(guid) FROM item_instance" ); + if( result ) + { + m_hiItemGuid = (*result)[0].GetUInt32()+1; + + delete result; + } + + // Cleanup other tables from not existed guids (>=m_hiItemGuid) + CharacterDatabase.PExecute("DELETE FROM character_inventory WHERE item >= '%u'", m_hiItemGuid); + CharacterDatabase.PExecute("DELETE FROM mail_items WHERE item_guid >= '%u'", m_hiItemGuid); + CharacterDatabase.PExecute("DELETE FROM auctionhouse WHERE itemguid >= '%u'", m_hiItemGuid); + CharacterDatabase.PExecute("DELETE FROM guild_bank_item WHERE item_guid >= '%u'", m_hiItemGuid); + + result = WorldDatabase.Query("SELECT MAX(guid) FROM gameobject" ); + if( result ) + { + m_hiGoGuid = (*result)[0].GetUInt32()+1; + + delete result; + } + + result = CharacterDatabase.Query("SELECT MAX(id) FROM auctionhouse" ); + if( result ) + { + m_auctionid = (*result)[0].GetUInt32()+1; + + delete result; + } + else + { + m_auctionid = 0; + } + result = CharacterDatabase.Query( "SELECT MAX(id) FROM mail" ); + if( result ) + { + m_mailid = (*result)[0].GetUInt32()+1; + + delete result; + } + else + { + m_mailid = 0; + } + result = CharacterDatabase.Query( "SELECT MAX(id) FROM item_text" ); + if( result ) + { + m_ItemTextId = (*result)[0].GetUInt32(); + + delete result; + } + else + m_ItemTextId = 0; + + result = CharacterDatabase.Query( "SELECT MAX(guid) FROM corpse" ); + if( result ) + { + m_hiCorpseGuid = (*result)[0].GetUInt32()+1; + + delete result; + } +} + +uint32 ObjectMgr::GenerateAuctionID() +{ + ++m_auctionid; + if(m_auctionid>=0xFFFFFFFF) + { + sLog.outError("Auctions ids overflow!! Can't continue, shuting down server. "); + sWorld.m_stopEvent = true; + } + return m_auctionid; +} + +uint32 ObjectMgr::GenerateMailID() +{ + ++m_mailid; + if(m_mailid>=0xFFFFFFFF) + { + sLog.outError("Mail ids overflow!! Can't continue, shuting down server. "); + sWorld.m_stopEvent = true; + } + return m_mailid; +} + +uint32 ObjectMgr::GenerateItemTextID() +{ + ++m_ItemTextId; + if(m_ItemTextId>=0xFFFFFFFF) + { + sLog.outError("Item text ids overflow!! Can't continue, shuting down server. "); + sWorld.m_stopEvent = true; + } + return m_ItemTextId; +} + +uint32 ObjectMgr::CreateItemText(std::string text) +{ + uint32 newItemTextId = GenerateItemTextID(); + //insert new itempage to container + mItemTexts[ newItemTextId ] = text; + //save new itempage + CharacterDatabase.escape_string(text); + //any Delete query needed, itemTextId is maximum of all ids + std::ostringstream query; + query << "INSERT INTO item_text (id,text) VALUES ( '" << newItemTextId << "', '" << text << "')"; + CharacterDatabase.Execute(query.str().c_str()); //needs to be run this way, because mail body may be more than 1024 characters + return newItemTextId; +} + +uint32 ObjectMgr::GenerateLowGuid(HighGuid guidhigh) +{ + switch(guidhigh) + { + case HIGHGUID_ITEM: + ++m_hiItemGuid; + if(m_hiItemGuid>=0xFFFFFFFF) + { + sLog.outError("Item guid overflow!! Can't continue, shuting down server. "); + sWorld.m_stopEvent = true; + } + return m_hiItemGuid; + case HIGHGUID_UNIT: + ++m_hiCreatureGuid; + if(m_hiCreatureGuid>=0x00FFFFFF) + { + sLog.outError("Creature guid overflow!! Can't continue, shuting down server. "); + sWorld.m_stopEvent = true; + } + return m_hiCreatureGuid; + case HIGHGUID_PET: + ++m_hiPetGuid; + if(m_hiPetGuid>=0x00FFFFFF) + { + sLog.outError("Pet guid overflow!! Can't continue, shuting down server. "); + sWorld.m_stopEvent = true; + } + return m_hiPetGuid; + case HIGHGUID_PLAYER: + ++m_hiCharGuid; + if(m_hiCharGuid>=0xFFFFFFFF) + { + sLog.outError("Players guid overflow!! Can't continue, shuting down server. "); + sWorld.m_stopEvent = true; + } + return m_hiCharGuid; + case HIGHGUID_GAMEOBJECT: + ++m_hiGoGuid; + if(m_hiGoGuid>=0x00FFFFFF) + { + sLog.outError("Gameobject guid overflow!! Can't continue, shuting down server. "); + sWorld.m_stopEvent = true; + } + return m_hiGoGuid; + case HIGHGUID_CORPSE: + ++m_hiCorpseGuid; + if(m_hiCorpseGuid>=0xFFFFFFFF) + { + sLog.outError("Corpse guid overflow!! Can't continue, shuting down server. "); + sWorld.m_stopEvent = true; + } + return m_hiCorpseGuid; + case HIGHGUID_DYNAMICOBJECT: + ++m_hiDoGuid; + if(m_hiDoGuid>=0xFFFFFFFF) + { + sLog.outError("DynamicObject guid overflow!! Can't continue, shuting down server. "); + sWorld.m_stopEvent = true; + } + return m_hiDoGuid; + default: + ASSERT(0); + } + + ASSERT(0); + return 0; +} + +void ObjectMgr::LoadGameObjectLocales() +{ + QueryResult *result = WorldDatabase.Query("SELECT entry," + "name_loc1,name_loc2,name_loc3,name_loc4,name_loc5,name_loc6,name_loc7,name_loc8," + "castbarcaption_loc1,castbarcaption_loc2,castbarcaption_loc3,castbarcaption_loc4," + "castbarcaption_loc5,castbarcaption_loc6,castbarcaption_loc7,castbarcaption_loc8 FROM locales_gameobject"); + + if(!result) + { + barGoLink bar(1); + + bar.step(); + + sLog.outString(""); + sLog.outString(">> Loaded 0 gameobject locale strings. DB table `locales_gameobject` is empty."); + return; + } + + barGoLink bar(result->GetRowCount()); + + do + { + Field *fields = result->Fetch(); + bar.step(); + + uint32 entry = fields[0].GetUInt32(); + + GameObjectLocale& data = mGameObjectLocaleMap[entry]; + + for(int i = 1; i < MAX_LOCALE; ++i) + { + std::string str = fields[i].GetCppString(); + if(!str.empty()) + { + int idx = GetOrNewIndexForLocale(LocaleConstant(i)); + if(idx >= 0) + { + if(data.Name.size() <= idx) + data.Name.resize(idx+1); + + data.Name[idx] = str; + } + } + } + + for(int i = MAX_LOCALE; i < MAX_LOCALE*2-1; ++i) + { + std::string str = fields[i].GetCppString(); + if(!str.empty()) + { + int idx = GetOrNewIndexForLocale(LocaleConstant(i)); + if(idx >= 0) + { + if(data.CastBarCaption.size() <= idx) + data.CastBarCaption.resize(idx+1); + + data.CastBarCaption[idx] = str; + } + } + } + + } while (result->NextRow()); + + delete result; + + sLog.outString(); + sLog.outString( ">> Loaded %u gameobject locale strings", mGameObjectLocaleMap.size() ); +} + +void ObjectMgr::LoadGameobjectInfo() +{ + sGOStorage.Load(); + + // some checks + for(uint32 id = 1; id < sGOStorage.MaxEntry; id++) + { + GameObjectInfo const* goInfo = sGOStorage.LookupEntry(id); + if(!goInfo) + continue; + + switch(goInfo->type) + { + case GAMEOBJECT_TYPE_DOOR: //0 + { + if(goInfo->door.lockId) + { + if(!sLockStore.LookupEntry(goInfo->door.lockId)) + sLog.outErrorDb("Gameobject (Entry: %u GoType: %u) have data1=%u but lock (Id: %u) not found.", + id,goInfo->type,goInfo->door.lockId,goInfo->door.lockId); + } + break; + } + case GAMEOBJECT_TYPE_BUTTON: //1 + { + if(goInfo->button.lockId) + { + if(!sLockStore.LookupEntry(goInfo->button.lockId)) + sLog.outErrorDb("Gameobject (Entry: %u GoType: %u) have data1=%u but lock (Id: %u) not found.", + id,goInfo->type,goInfo->button.lockId,goInfo->button.lockId); + } + break; + } + case GAMEOBJECT_TYPE_CHEST: //3 + { + if(goInfo->chest.lockId) + { + if(!sLockStore.LookupEntry(goInfo->chest.lockId)) + sLog.outErrorDb("Gameobject (Entry: %u GoType: %u) have data0=%u but lock (Id: %u) not found.", + id,goInfo->type,goInfo->chest.lockId,goInfo->chest.lockId); + } + if(goInfo->chest.linkedTrapId) // linked trap + { + if(GameObjectInfo const* trapInfo = sGOStorage.LookupEntry(goInfo->chest.linkedTrapId)) + { + if(trapInfo->type!=GAMEOBJECT_TYPE_TRAP) + sLog.outErrorDb("Gameobject (Entry: %u GoType: %u) have data7=%u but GO (Entry %u) have not GAMEOBJECT_TYPE_TRAP (%u) type.", + id,goInfo->type,goInfo->chest.linkedTrapId,goInfo->chest.linkedTrapId,GAMEOBJECT_TYPE_TRAP); + } + /* disable check for while + else + sLog.outErrorDb("Gameobject (Entry: %u GoType: %u) have data2=%u but trap GO (Entry %u) not exist in `gameobject_template`.", + id,goInfo->type,goInfo->chest.linkedTrapId,goInfo->chest.linkedTrapId); + */ + } + break; + } + case GAMEOBJECT_TYPE_TRAP: //6 + { + /* disable check for while + if(goInfo->trap.spellId) // spell + { + if(!sSpellStore.LookupEntry(goInfo->trap.spellId)) + sLog.outErrorDb("Gameobject (Entry: %u GoType: %u) have data3=%u but Spell (Entry %u) not exist.", + id,goInfo->type,goInfo->trap.spellId,goInfo->trap.spellId); + } + */ + break; + } + case GAMEOBJECT_TYPE_CHAIR: //7 + if(goInfo->chair.height > 2) + { + sLog.outErrorDb("Gameobject (Entry: %u GoType: %u) have data1=%u but correct chair height in range 0..2.", + id,goInfo->type,goInfo->chair.height); + + // prevent client and server unexpected work + const_cast(goInfo)->chair.height = 0; + } + break; + case GAMEOBJECT_TYPE_SPELL_FOCUS: //8 + { + if(goInfo->spellFocus.focusId) + { + if(!sSpellFocusObjectStore.LookupEntry(goInfo->spellFocus.focusId)) + sLog.outErrorDb("Gameobject (Entry: %u GoType: %u) have data0=%u but SpellFocus (Id: %u) not exist.", + id,goInfo->type,goInfo->spellFocus.focusId,goInfo->spellFocus.focusId); + } + + if(goInfo->spellFocus.linkedTrapId) // linked trap + { + if(GameObjectInfo const* trapInfo = sGOStorage.LookupEntry(goInfo->spellFocus.linkedTrapId)) + { + if(trapInfo->type!=GAMEOBJECT_TYPE_TRAP) + sLog.outErrorDb("Gameobject (Entry: %u GoType: %u) have data2=%u but GO (Entry %u) have not GAMEOBJECT_TYPE_TRAP (%u) type.", + id,goInfo->type,goInfo->spellFocus.linkedTrapId,goInfo->spellFocus.linkedTrapId,GAMEOBJECT_TYPE_TRAP); + } + /* disable check for while + else + sLog.outErrorDb("Gameobject (Entry: %u GoType: %u) have data2=%u but trap GO (Entry %u) not exist in `gameobject_template`.", + id,goInfo->type,goInfo->spellFocus.linkedTrapId,goInfo->spellFocus.linkedTrapId); + */ + } + break; + } + case GAMEOBJECT_TYPE_GOOBER: //10 + { + if(goInfo->goober.pageId) // pageId + { + if(!sPageTextStore.LookupEntry(goInfo->goober.pageId)) + sLog.outErrorDb("Gameobject (Entry: %u GoType: %u) have data7=%u but PageText (Entry %u) not exist.", + id,goInfo->type,goInfo->goober.pageId,goInfo->goober.pageId); + } + /* disable check for while + if(goInfo->goober.spellId) // spell + { + if(!sSpellStore.LookupEntry(goInfo->goober.spellId)) + sLog.outErrorDb("Gameobject (Entry: %u GoType: %u) have data2=%u but Spell (Entry %u) not exist.", + id,goInfo->type,goInfo->goober.spellId,goInfo->goober.spellId); + } + */ + if(goInfo->goober.linkedTrapId) // linked trap + { + if(GameObjectInfo const* trapInfo = sGOStorage.LookupEntry(goInfo->goober.linkedTrapId)) + { + if(trapInfo->type!=GAMEOBJECT_TYPE_TRAP) + sLog.outErrorDb("Gameobject (Entry: %u GoType: %u) have data12=%u but GO (Entry %u) have not GAMEOBJECT_TYPE_TRAP (%u) type.", + id,goInfo->type,goInfo->goober.linkedTrapId,goInfo->goober.linkedTrapId,GAMEOBJECT_TYPE_TRAP); + } + /* disable check for while + else + sLog.outErrorDb("Gameobject (Entry: %u GoType: %u) have data12=%u but trap GO (Entry %u) not exist in `gameobject_template`.", + id,goInfo->type,goInfo->goober.linkedTrapId,goInfo->goober.linkedTrapId); + */ + } + break; + } + case GAMEOBJECT_TYPE_MO_TRANSPORT: //15 + { + if(goInfo->moTransport.taxiPathId) + { + if(goInfo->moTransport.taxiPathId >= sTaxiPathNodesByPath.size() || sTaxiPathNodesByPath[goInfo->moTransport.taxiPathId].empty()) + sLog.outErrorDb("Gameobject (Entry: %u GoType: %u) have data0=%u but TaxiPath (Id: %u) not exist.", + id,goInfo->type,goInfo->moTransport.taxiPathId,goInfo->moTransport.taxiPathId); + } + break; + } + case GAMEOBJECT_TYPE_SUMMONING_RITUAL: //18 + { + /* disabled + if(goInfo->summoningRitual.spellId) + { + if(!sSpellStore.LookupEntry(goInfo->summoningRitual.spellId)) + sLog.outErrorDb("Gameobject (Entry: %u GoType: %u) have data1=%u but Spell (Entry %u) not exist.", + id,goInfo->type,goInfo->summoningRitual.spellId,goInfo->summoningRitual.spellId); + } + */ + break; + } + case GAMEOBJECT_TYPE_SPELLCASTER: //22 + { + if(goInfo->spellcaster.spellId) // spell + { + if(!sSpellStore.LookupEntry(goInfo->spellcaster.spellId)) + sLog.outErrorDb("Gameobject (Entry: %u GoType: %u) have data3=%u but Spell (Entry %u) not exist.", + id,goInfo->type,goInfo->spellcaster.spellId,goInfo->spellcaster.spellId); + } + break; + } + } + } + + sLog.outString( ">> Loaded %u game object templates", sGOStorage.RecordCount ); + sLog.outString(); +} + +void ObjectMgr::LoadExplorationBaseXP() +{ + uint32 count = 0; + QueryResult *result = WorldDatabase.Query("SELECT level,basexp FROM exploration_basexp"); + + if( !result ) + { + barGoLink bar( 1 ); + + bar.step(); + + sLog.outString(); + sLog.outString( ">> Loaded %u BaseXP definitions", count ); + return; + } + + barGoLink bar( result->GetRowCount() ); + + do + { + bar.step(); + + Field *fields = result->Fetch(); + uint32 level = fields[0].GetUInt32(); + uint32 basexp = fields[1].GetUInt32(); + mBaseXPTable[level] = basexp; + ++count; + } + while (result->NextRow()); + + delete result; + + sLog.outString(); + sLog.outString( ">> Loaded %u BaseXP definitions", count ); +} + +uint32 ObjectMgr::GetBaseXP(uint32 level) +{ + return mBaseXPTable[level] ? mBaseXPTable[level] : 0; +} + +void ObjectMgr::LoadPetNames() +{ + uint32 count = 0; + QueryResult *result = WorldDatabase.Query("SELECT word,entry,half FROM pet_name_generation"); + + if( !result ) + { + barGoLink bar( 1 ); + + bar.step(); + + sLog.outString(); + sLog.outString( ">> Loaded %u pet name parts", count ); + return; + } + + barGoLink bar( result->GetRowCount() ); + + do + { + bar.step(); + + Field *fields = result->Fetch(); + std::string word = fields[0].GetString(); + uint32 entry = fields[1].GetUInt32(); + bool half = fields[2].GetBool(); + if(half) + PetHalfName1[entry].push_back(word); + else + PetHalfName0[entry].push_back(word); + ++count; + } + while (result->NextRow()); + delete result; + + sLog.outString(); + sLog.outString( ">> Loaded %u pet name parts", count ); +} + +void ObjectMgr::LoadPetNumber() +{ + QueryResult* result = CharacterDatabase.Query("SELECT MAX(id) FROM character_pet"); + if(result) + { + Field *fields = result->Fetch(); + m_hiPetNumber = fields[0].GetUInt32()+1; + delete result; + } + + barGoLink bar( 1 ); + bar.step(); + + sLog.outString(); + sLog.outString( ">> Loaded the max pet number: %d", m_hiPetNumber-1); +} + +std::string ObjectMgr::GeneratePetName(uint32 entry) +{ + std::vector & list0 = PetHalfName0[entry]; + std::vector & list1 = PetHalfName1[entry]; + + if(list0.empty() || list1.empty()) + { + CreatureInfo const *cinfo = GetCreatureTemplate(entry); + char* petname = GetPetName(cinfo->family, sWorld.GetDefaultDbcLocale()); + if(!petname) + petname = cinfo->Name; + return std::string(petname); + } + + return *(list0.begin()+urand(0, list0.size()-1)) + *(list1.begin()+urand(0, list1.size()-1)); +} + +uint32 ObjectMgr::GeneratePetNumber() +{ + return ++m_hiPetNumber; +} + +void ObjectMgr::LoadCorpses() +{ + uint32 count = 0; + // 0 1 2 3 4 5 6 7 8 10 + QueryResult *result = CharacterDatabase.PQuery("SELECT position_x, position_y, position_z, orientation, map, data, time, corpse_type, instance, guid FROM corpse WHERE corpse_type <> 0"); + + if( !result ) + { + barGoLink bar( 1 ); + + bar.step(); + + sLog.outString(); + sLog.outString( ">> Loaded %u corpses", count ); + return; + } + + barGoLink bar( result->GetRowCount() ); + + do + { + bar.step(); + + Field *fields = result->Fetch(); + + uint32 guid = fields[result->GetFieldCount()-1].GetUInt32(); + + Corpse *corpse = new Corpse; + if(!corpse->LoadFromDB(guid,fields)) + { + delete corpse; + continue; + } + + ObjectAccessor::Instance().AddCorpse(corpse); + + ++count; + } + while (result->NextRow()); + delete result; + + sLog.outString(); + sLog.outString( ">> Loaded %u corpses", count ); +} + +void ObjectMgr::LoadReputationOnKill() +{ + uint32 count = 0; + + // 0 1 2 + QueryResult *result = WorldDatabase.Query("SELECT creature_id, RewOnKillRepFaction1, RewOnKillRepFaction2," + // 3 4 5 6 7 8 9 + "IsTeamAward1, MaxStanding1, RewOnKillRepValue1, IsTeamAward2, MaxStanding2, RewOnKillRepValue2, TeamDependent " + "FROM creature_onkill_reputation"); + + if(!result) + { + barGoLink bar(1); + + bar.step(); + + sLog.outString(); + sLog.outErrorDb(">> Loaded 0 creature award reputation definitions. DB table `creature_onkill_reputation` is empty."); + return; + } + + barGoLink bar(result->GetRowCount()); + + do + { + Field *fields = result->Fetch(); + bar.step(); + + uint32 creature_id = fields[0].GetUInt32(); + + ReputationOnKillEntry repOnKill; + repOnKill.repfaction1 = fields[1].GetUInt32(); + repOnKill.repfaction2 = fields[2].GetUInt32(); + repOnKill.is_teamaward1 = fields[3].GetBool(); + repOnKill.reputation_max_cap1 = fields[4].GetUInt32(); + repOnKill.repvalue1 = fields[5].GetInt32(); + repOnKill.is_teamaward2 = fields[6].GetBool(); + repOnKill.reputation_max_cap2 = fields[7].GetUInt32(); + repOnKill.repvalue2 = fields[8].GetInt32(); + repOnKill.team_dependent = fields[9].GetUInt8(); + + if(!GetCreatureTemplate(creature_id)) + { + sLog.outErrorDb("Table `creature_onkill_reputation` have data for not existed creature entry (%u), skipped",creature_id); + continue; + } + + if(repOnKill.repfaction1) + { + FactionEntry const *factionEntry1 = sFactionStore.LookupEntry(repOnKill.repfaction1); + if(!factionEntry1) + { + sLog.outErrorDb("Faction (faction.dbc) %u does not exist but is used in `creature_onkill_reputation`",repOnKill.repfaction1); + continue; + } + } + + if(repOnKill.repfaction2) + { + FactionEntry const *factionEntry2 = sFactionStore.LookupEntry(repOnKill.repfaction2); + if(!factionEntry2) + { + sLog.outErrorDb("Faction (faction.dbc) %u does not exist but is used in `creature_onkill_reputation`",repOnKill.repfaction2); + continue; + } + } + + mRepOnKill[creature_id] = repOnKill; + + ++count; + } while (result->NextRow()); + + delete result; + + sLog.outString(); + sLog.outString(">> Loaded %u creature award reputation definitions", count); +} + +void ObjectMgr::LoadWeatherZoneChances() +{ + uint32 count = 0; + + // 0 1 2 3 4 5 6 7 8 9 10 11 12 + QueryResult *result = WorldDatabase.Query("SELECT zone, spring_rain_chance, spring_snow_chance, spring_storm_chance, summer_rain_chance, summer_snow_chance, summer_storm_chance, fall_rain_chance, fall_snow_chance, fall_storm_chance, winter_rain_chance, winter_snow_chance, winter_storm_chance FROM game_weather"); + + if(!result) + { + barGoLink bar(1); + + bar.step(); + + sLog.outString(); + sLog.outErrorDb(">> Loaded 0 weather definitions. DB table `game_weather` is empty."); + return; + } + + barGoLink bar(result->GetRowCount()); + + do + { + Field *fields = result->Fetch(); + bar.step(); + + uint32 zone_id = fields[0].GetUInt32(); + + WeatherZoneChances& wzc = mWeatherZoneMap[zone_id]; + + for(int season = 0; season < WEATHER_SEASONS; ++season) + { + wzc.data[season].rainChance = fields[season * (MAX_WEATHER_TYPE-1) + 1].GetUInt32(); + wzc.data[season].snowChance = fields[season * (MAX_WEATHER_TYPE-1) + 2].GetUInt32(); + wzc.data[season].stormChance = fields[season * (MAX_WEATHER_TYPE-1) + 3].GetUInt32(); + + if(wzc.data[season].rainChance > 100) + { + wzc.data[season].rainChance = 25; + sLog.outErrorDb("Weather for zone %u season %u has wrong rain chance > 100%",zone_id,season); + } + + if(wzc.data[season].snowChance > 100) + { + wzc.data[season].snowChance = 25; + sLog.outErrorDb("Weather for zone %u season %u has wrong snow chance > 100%",zone_id,season); + } + + if(wzc.data[season].stormChance > 100) + { + wzc.data[season].stormChance = 25; + sLog.outErrorDb("Weather for zone %u season %u has wrong storm chance > 100%",zone_id,season); + } + } + + ++count; + } while (result->NextRow()); + + delete result; + + sLog.outString(); + sLog.outString(">> Loaded %u weather definitions", count); +} + +void ObjectMgr::SaveCreatureRespawnTime(uint32 loguid, uint32 instance, time_t t) +{ + mCreatureRespawnTimes[MAKE_PAIR64(loguid,instance)] = t; + WorldDatabase.PExecute("DELETE FROM creature_respawn WHERE guid = '%u' AND instance = '%u'", loguid, instance); + if(t) + WorldDatabase.PExecute("INSERT INTO creature_respawn VALUES ( '%u', '" I64FMTD "', '%u' )", loguid, uint64(t), instance); +} + +void ObjectMgr::DeleteCreatureData(uint32 guid) +{ + // remove mapid*cellid -> guid_set map + CreatureData const* data = GetCreatureData(guid); + if(data) + RemoveCreatureFromGrid(guid, data); + + mCreatureDataMap.erase(guid); +} + +void ObjectMgr::SaveGORespawnTime(uint32 loguid, uint32 instance, time_t t) +{ + mGORespawnTimes[MAKE_PAIR64(loguid,instance)] = t; + WorldDatabase.PExecute("DELETE FROM gameobject_respawn WHERE guid = '%u' AND instance = '%u'", loguid, instance); + if(t) + WorldDatabase.PExecute("INSERT INTO gameobject_respawn VALUES ( '%u', '" I64FMTD "', '%u' )", loguid, uint64(t), instance); +} + +void ObjectMgr::DeleteRespawnTimeForInstance(uint32 instance) +{ + RespawnTimes::iterator next; + + for(RespawnTimes::iterator itr = mGORespawnTimes.begin(); itr != mGORespawnTimes.end(); itr = next) + { + next = itr; + ++next; + + if(GUID_HIPART(itr->first)==instance) + mGORespawnTimes.erase(itr); + } + + for(RespawnTimes::iterator itr = mCreatureRespawnTimes.begin(); itr != mCreatureRespawnTimes.end(); itr = next) + { + next = itr; + ++next; + + if(GUID_HIPART(itr->first)==instance) + mCreatureRespawnTimes.erase(itr); + } + + WorldDatabase.PExecute("DELETE FROM creature_respawn WHERE instance = '%u'", instance); + WorldDatabase.PExecute("DELETE FROM gameobject_respawn WHERE instance = '%u'", instance); +} + +void ObjectMgr::DeleteGOData(uint32 guid) +{ + // remove mapid*cellid -> guid_set map + GameObjectData const* data = GetGOData(guid); + if(data) + RemoveGameobjectFromGrid(guid, data); + + mGameObjectDataMap.erase(guid); +} + +void ObjectMgr::AddCorpseCellData(uint32 mapid, uint32 cellid, uint32 player_guid, uint32 instance) +{ + // corpses are always added to spawn mode 0 and they are spawned by their instance id + CellObjectGuids& cell_guids = mMapObjectGuids[MAKE_PAIR32(mapid,0)][cellid]; + cell_guids.corpses[player_guid] = instance; +} + +void ObjectMgr::DeleteCorpseCellData(uint32 mapid, uint32 cellid, uint32 player_guid) +{ + // corpses are always added to spawn mode 0 and they are spawned by their instance id + CellObjectGuids& cell_guids = mMapObjectGuids[MAKE_PAIR32(mapid,0)][cellid]; + cell_guids.corpses.erase(player_guid); +} + +void ObjectMgr::LoadQuestRelationsHelper(QuestRelations& map,char const* table) +{ + map.clear(); // need for reload case + + uint32 count = 0; + + QueryResult *result = WorldDatabase.PQuery("SELECT id,quest FROM %s",table); + + if(!result) + { + barGoLink bar(1); + + bar.step(); + + sLog.outString(); + sLog.outErrorDb(">> Loaded 0 quest relations from %s. DB table `%s` is empty.",table,table); + return; + } + + barGoLink bar(result->GetRowCount()); + + do + { + Field *fields = result->Fetch(); + bar.step(); + + uint32 id = fields[0].GetUInt32(); + uint32 quest = fields[1].GetUInt32(); + + if(mQuestTemplates.find(quest) == mQuestTemplates.end()) + { + sLog.outErrorDb("Table `%s: Quest %u listed for entry %u does not exist.",table,quest,id); + continue; + } + + map.insert(QuestRelations::value_type(id,quest)); + + ++count; + } while (result->NextRow()); + + delete result; + + sLog.outString(); + sLog.outString(">> Loaded %u quest relations from %s", count,table); +} + +void ObjectMgr::LoadGameobjectQuestRelations() +{ + LoadQuestRelationsHelper(mGOQuestRelations,"gameobject_questrelation"); + + for(QuestRelations::iterator itr = mGOQuestRelations.begin(); itr != mGOQuestRelations.end(); ++itr) + { + GameObjectInfo const* goInfo = GetGameObjectInfo(itr->first); + if(!goInfo) + sLog.outErrorDb("Table `gameobject_questrelation` have data for not existed gameobject entry (%u) and existed quest %u",itr->first,itr->second); + else if(goInfo->type != GAMEOBJECT_TYPE_QUESTGIVER) + sLog.outErrorDb("Table `gameobject_questrelation` have data gameobject entry (%u) for quest %u, but GO is not GAMEOBJECT_TYPE_QUESTGIVER",itr->first,itr->second); + } +} + +void ObjectMgr::LoadGameobjectInvolvedRelations() +{ + LoadQuestRelationsHelper(mGOQuestInvolvedRelations,"gameobject_involvedrelation"); + + for(QuestRelations::iterator itr = mGOQuestInvolvedRelations.begin(); itr != mGOQuestInvolvedRelations.end(); ++itr) + { + GameObjectInfo const* goInfo = GetGameObjectInfo(itr->first); + if(!goInfo) + sLog.outErrorDb("Table `gameobject_involvedrelation` have data for not existed gameobject entry (%u) and existed quest %u",itr->first,itr->second); + else if(goInfo->type != GAMEOBJECT_TYPE_QUESTGIVER) + sLog.outErrorDb("Table `gameobject_involvedrelation` have data gameobject entry (%u) for quest %u, but GO is not GAMEOBJECT_TYPE_QUESTGIVER",itr->first,itr->second); + } +} + +void ObjectMgr::LoadCreatureQuestRelations() +{ + LoadQuestRelationsHelper(mCreatureQuestRelations,"creature_questrelation"); + + for(QuestRelations::iterator itr = mCreatureQuestRelations.begin(); itr != mCreatureQuestRelations.end(); ++itr) + { + CreatureInfo const* cInfo = GetCreatureTemplate(itr->first); + if(!cInfo) + sLog.outErrorDb("Table `creature_questrelation` have data for not existed creature entry (%u) and existed quest %u",itr->first,itr->second); + else if(!(cInfo->npcflag & UNIT_NPC_FLAG_QUESTGIVER)) + sLog.outErrorDb("Table `creature_questrelation` has creature entry (%u) for quest %u, but npcflag does not include UNIT_NPC_FLAG_QUESTGIVER",itr->first,itr->second); + } +} + +void ObjectMgr::LoadCreatureInvolvedRelations() +{ + LoadQuestRelationsHelper(mCreatureQuestInvolvedRelations,"creature_involvedrelation"); + + for(QuestRelations::iterator itr = mCreatureQuestInvolvedRelations.begin(); itr != mCreatureQuestInvolvedRelations.end(); ++itr) + { + CreatureInfo const* cInfo = GetCreatureTemplate(itr->first); + if(!cInfo) + sLog.outErrorDb("Table `creature_involvedrelation` have data for not existed creature entry (%u) and existed quest %u",itr->first,itr->second); + else if(!(cInfo->npcflag & UNIT_NPC_FLAG_QUESTGIVER)) + sLog.outErrorDb("Table `creature_involvedrelation` has creature entry (%u) for quest %u, but npcflag does not include UNIT_NPC_FLAG_QUESTGIVER",itr->first,itr->second); + } +} + +void ObjectMgr::LoadReservedPlayersNames() +{ + m_ReservedNames.clear(); // need for reload case + + QueryResult *result = WorldDatabase.PQuery("SELECT name FROM reserved_name"); + + uint32 count = 0; + + if( !result ) + { + barGoLink bar( 1 ); + bar.step(); + + sLog.outString(); + sLog.outString( ">> Loaded %u reserved player names", count ); + return; + } + + barGoLink bar( result->GetRowCount() ); + + Field* fields; + do + { + bar.step(); + fields = result->Fetch(); + std::string name= fields[0].GetCppString(); + if(normalizePlayerName(name)) + { + m_ReservedNames.insert(name); + ++count; + } + } while ( result->NextRow() ); + + delete result; + + sLog.outString(); + sLog.outString( ">> Loaded %u reserved player names", count ); +} + +enum LanguageType +{ + LT_BASIC_LATIN = 0x0000, + LT_EXTENDEN_LATIN = 0x0001, + LT_CYRILLIC = 0x0002, + LT_EAST_ASIA = 0x0004, + LT_ANY = 0xFFFF +}; + +static LanguageType GetRealmLanguageType(bool create) +{ + switch(sWorld.getConfig(CONFIG_REALM_ZONE)) + { + case REALM_ZONE_UNKNOWN: // any language + case REALM_ZONE_DEVELOPMENT: + case REALM_ZONE_TEST_SERVER: + case REALM_ZONE_QA_SERVER: + return LT_ANY; + case REALM_ZONE_UNITED_STATES: // extended-Latin + case REALM_ZONE_OCEANIC: + case REALM_ZONE_LATIN_AMERICA: + case REALM_ZONE_ENGLISH: + case REALM_ZONE_GERMAN: + case REALM_ZONE_FRENCH: + case REALM_ZONE_SPANISH: + return LT_EXTENDEN_LATIN; + case REALM_ZONE_KOREA: // East-Asian + case REALM_ZONE_TAIWAN: + case REALM_ZONE_CHINA: + return LT_EAST_ASIA; + case REALM_ZONE_RUSSIAN: // Cyrillic + return LT_CYRILLIC; + default: + return create ? LT_BASIC_LATIN : LT_ANY; // basic-Latin at create, any at login + } +} + +bool isValidString(std::wstring wstr, uint32 strictMask, bool numericOrSpace, bool create = false) +{ + if(strictMask==0) // any language, ignore realm + { + if(isExtendedLatinString(wstr,numericOrSpace)) + return true; + if(isCyrillicString(wstr,numericOrSpace)) + return true; + if(isEastAsianString(wstr,numericOrSpace)) + return true; + return false; + } + + if(strictMask & 0x2) // realm zone specific + { + LanguageType lt = GetRealmLanguageType(create); + if(lt & LT_EXTENDEN_LATIN) + if(isExtendedLatinString(wstr,numericOrSpace)) + return true; + if(lt & LT_CYRILLIC) + if(isCyrillicString(wstr,numericOrSpace)) + return true; + if(lt & LT_EAST_ASIA) + if(isEastAsianString(wstr,numericOrSpace)) + return true; + } + + if(strictMask & 0x1) // basic latin + { + if(isBasicLatinString(wstr,numericOrSpace)) + return true; + } + + return false; +} + +bool ObjectMgr::IsValidName( std::string name, bool create ) +{ + std::wstring wname; + if(!Utf8toWStr(name,wname)) + return false; + + if(wname.size() < 1 || wname.size() > MAX_PLAYER_NAME) + return false; + + uint32 strictMask = sWorld.getConfig(CONFIG_STRICT_PLAYER_NAMES); + + return isValidString(wname,strictMask,false,create); +} + +bool ObjectMgr::IsValidCharterName( std::string name ) +{ + std::wstring wname; + if(!Utf8toWStr(name,wname)) + return false; + + if(wname.size() < 1) + return false; + + uint32 strictMask = sWorld.getConfig(CONFIG_STRICT_CHARTER_NAMES); + + return isValidString(wname,strictMask,true); +} + +bool ObjectMgr::IsValidPetName( std::string name ) +{ + std::wstring wname; + if(!Utf8toWStr(name,wname)) + return false; + + if(wname.size() < 1) + return false; + + uint32 strictMask = sWorld.getConfig(CONFIG_STRICT_PET_NAMES); + + return isValidString(wname,strictMask,false); +} + +int ObjectMgr::GetIndexForLocale( LocaleConstant loc ) +{ + if(loc==LOCALE_enUS) + return -1; + + for(size_t i=0;i < m_LocalForIndex.size(); ++i) + if(m_LocalForIndex[i]==loc) + return i; + + return -1; +} + +LocaleConstant ObjectMgr::GetLocaleForIndex(int i) +{ + if (i<0 || i>=m_LocalForIndex.size()) + return LOCALE_enUS; + + return m_LocalForIndex[i]; +} + +int ObjectMgr::GetOrNewIndexForLocale( LocaleConstant loc ) +{ + if(loc==LOCALE_enUS) + return -1; + + for(size_t i=0;i < m_LocalForIndex.size(); ++i) + if(m_LocalForIndex[i]==loc) + return i; + + m_LocalForIndex.push_back(loc); + return m_LocalForIndex.size()-1; +} + +void ObjectMgr::LoadBattleMastersEntry() +{ + mBattleMastersMap.clear(); // need for reload case + + QueryResult *result = WorldDatabase.Query( "SELECT entry,bg_template FROM battlemaster_entry" ); + + uint32 count = 0; + + if( !result ) + { + barGoLink bar( 1 ); + bar.step(); + + sLog.outString(); + sLog.outString( ">> Loaded 0 battlemaster entries - table is empty!" ); + return; + } + + barGoLink bar( result->GetRowCount() ); + + do + { + ++count; + bar.step(); + + Field *fields = result->Fetch(); + + uint32 entry = fields[0].GetUInt32(); + uint32 bgTypeId = fields[1].GetUInt32(); + + mBattleMastersMap[entry] = bgTypeId; + + } while( result->NextRow() ); + + delete result; + + sLog.outString(); + sLog.outString( ">> Loaded %u battlemaster entries", count ); +} + +void ObjectMgr::LoadGameObjectForQuests() +{ + mGameObjectForQuestSet.clear(); // need for reload case + + uint32 count = 0; + + // collect GO entries for GO that must activated + for(uint32 go_entry = 1; go_entry < sGOStorage.MaxEntry; ++go_entry) + { + GameObjectInfo const* goInfo = sGOStorage.LookupEntry(go_entry); + if(!goInfo) + continue; + + switch(goInfo->type) + { + // scan GO chest with loot including quest items + case GAMEOBJECT_TYPE_CHEST: + { + uint32 loot_id = GameObject::GetLootId(goInfo); + + // find quest loot for GO + if(LootTemplates_Gameobject.HaveQuestLootFor(loot_id)) + { + mGameObjectForQuestSet.insert(go_entry); + ++count; + } + break; + } + case GAMEOBJECT_TYPE_GOOBER: + { + if(goInfo->goober.questId) //quests objects + { + mGameObjectForQuestSet.insert(go_entry); + count++; + } + break; + } + default: + break; + } + } + + sLog.outString(); + sLog.outString( ">> Loaded %u GameObject for quests", count ); +} + +bool ObjectMgr::LoadMangosStrings(DatabaseType& db, char const* table, int32 min_value, int32 max_value) +{ + // cleanup affected map part for reloading case + for(MangosStringLocaleMap::iterator itr = mMangosStringLocaleMap.begin(); itr != mMangosStringLocaleMap.end();) + { + if(itr->first >= min_value && itr->first <= max_value) + { + MangosStringLocaleMap::iterator itr2 = itr; + ++itr; + mMangosStringLocaleMap.erase(itr2); + } + else + ++itr; + } + + QueryResult *result = db.PQuery("SELECT entry,content_default,content_loc1,content_loc2,content_loc3,content_loc4,content_loc5,content_loc6,content_loc7,content_loc8 FROM %s",table); + + if(!result) + { + barGoLink bar(1); + + bar.step(); + + sLog.outString(""); + if(min_value > 0) // error only in case internal strings + sLog.outErrorDb(">> Loaded 0 mangos strings. DB table `%s` is empty. Cannot continue.",table); + else + sLog.outString(">> Loaded 0 string templates. DB table `%s` is empty.",table); + return false; + } + + uint32 count = 0; + + barGoLink bar(result->GetRowCount()); + + do + { + Field *fields = result->Fetch(); + bar.step(); + + int32 entry = fields[0].GetInt32(); + + if(entry==0) + { + sLog.outString("Table `%s` contain reserved entry 0, ignored.",table); + continue; + } + else if(entry < min_value || entry > max_value) + { + int32 start = min_value > 0 ? min_value : max_value; + int32 end = min_value > 0 ? max_value : min_value; + sLog.outString("Table `%s` contain entry %i out of allowed range (%d - %d), ignored.",table,entry,start,end); + continue; + } + + MangosStringLocale& data = mMangosStringLocaleMap[entry]; + + if(data.Content.size() > 0) + { + sLog.outString("Table `%s` contain data for already loaded entry %i (from another table?), ignored.",table,entry); + continue; + } + + data.Content.resize(1); + ++count; + + // 0 -> default, idx in to idx+1 + data.Content[0] = fields[1].GetCppString(); + + for(int i = 1; i < MAX_LOCALE; ++i) + { + std::string str = fields[i+1].GetCppString(); + if(!str.empty()) + { + int idx = GetOrNewIndexForLocale(LocaleConstant(i)); + if(idx >= 0) + { + // 0 -> default, idx in to idx+1 + if(data.Content.size() <= idx+1) + data.Content.resize(idx+2); + + data.Content[idx+1] = str; + } + } + } + } while (result->NextRow()); + + delete result; + + sLog.outString(); + if(min_value > 0) // internal mangos strings + sLog.outString( ">> Loaded %u MaNGOS strings from table %s", count,table); + else + sLog.outString( ">> Loaded %u string templates from %s", count,table); + + return true; +} + +const char *ObjectMgr::GetMangosString(int32 entry, int locale_idx) const +{ + // locale_idx==-1 -> default, locale_idx >= 0 in to idx+1 + // Content[0] always exist if exist MangosStringLocale + if(MangosStringLocale const *msl = GetMangosStringLocale(entry)) + { + if(msl->Content.size() > locale_idx+1 && !msl->Content[locale_idx+1].empty()) + return msl->Content[locale_idx+1].c_str(); + else + return msl->Content[0].c_str(); + } + + if(entry > 0) + sLog.outErrorDb("Entry %i not found in `mangos_string` table.",entry); + else + sLog.outErrorDb("Mangos string entry %i not found in DB.",entry); + return ""; +} + +void ObjectMgr::LoadFishingBaseSkillLevel() +{ + mFishingBaseForArea.clear(); // for relaod case + + uint32 count = 0; + QueryResult *result = WorldDatabase.Query("SELECT entry,skill FROM skill_fishing_base_level"); + + if( !result ) + { + barGoLink bar( 1 ); + + bar.step(); + + sLog.outString(); + sLog.outErrorDb(">> Loaded `skill_fishing_base_level`, table is empty!"); + return; + } + + barGoLink bar( result->GetRowCount() ); + + do + { + bar.step(); + + Field *fields = result->Fetch(); + uint32 entry = fields[0].GetUInt32(); + int32 skill = fields[1].GetInt32(); + + AreaTableEntry const* fArea = GetAreaEntryByAreaID(entry); + if(!fArea) + { + sLog.outErrorDb("AreaId %u defined in `skill_fishing_base_level` does not exist",entry); + continue; + } + + mFishingBaseForArea[entry] = skill; + ++count; + } + while (result->NextRow()); + + delete result; + + sLog.outString(); + sLog.outString( ">> Loaded %u areas for fishing base skill level", count ); +} + +// Searches for the same condition already in Conditions store +// Returns Id if found, else adds it to Conditions and returns Id +uint16 ObjectMgr::GetConditionId( ConditionType condition, uint32 value1, uint32 value2 ) +{ + PlayerCondition lc = PlayerCondition(condition, value1, value2); + for (uint16 i=0; i < mConditions.size(); ++i) + { + if (lc == mConditions[i]) + return i; + } + + mConditions.push_back(lc); + + if(mConditions.size() > 0xFFFF) + { + sLog.outError("Conditions store overflow! Current and later loaded conditions will ignored!"); + return 0; + } + + return mConditions.size() - 1; +} + +bool ObjectMgr::CheckDeclinedNames( std::wstring mainpart, DeclinedName const& names ) +{ + for(int i =0; i < MAX_DECLINED_NAME_CASES; ++i) + { + std::wstring wname; + if(!Utf8toWStr(names.name[i],wname)) + return false; + + if(mainpart!=GetMainPartOfName(wname,i+1)) + return false; + } + return true; +} + +const char* ObjectMgr::GetAreaTriggerScriptName(uint32 id) +{ + AreaTriggerScriptMap::const_iterator i = mAreaTriggerScripts.find(id); + if(i!= mAreaTriggerScripts.end()) + return i->second.c_str(); + return ""; +} + +// Checks if player meets the condition +bool PlayerCondition::Meets(Player const * player) const +{ + if( !player ) + return false; // player not present, return false + + switch (condition) + { + case CONDITION_NONE: + return true; // empty condition, always met + case CONDITION_AURA: + return player->HasAura(value1, value2); + case CONDITION_ITEM: + return player->HasItemCount(value1, value2); + case CONDITION_ITEM_EQUIPPED: + return player->GetItemOrItemWithGemEquipped(value1) != NULL; + case CONDITION_ZONEID: + return player->GetZoneId() == value1; + case CONDITION_REPUTATION_RANK: + { + FactionEntry const* faction = sFactionStore.LookupEntry(value1); + return faction && player->GetReputationRank(faction) >= value2; + } + case CONDITION_TEAM: + return player->GetTeam() == value1; + case CONDITION_SKILL: + return player->HasSkill(value1) && player->GetBaseSkillValue(value1) >= value2; + case CONDITION_QUESTREWARDED: + return player->GetQuestRewardStatus(value1); + case CONDITION_QUESTTAKEN: + { + QuestStatus status = player->GetQuestStatus(value1); + return (status == QUEST_STATUS_INCOMPLETE); + } + case CONDITION_AD_COMMISSION_AURA: + { + Unit::AuraMap const& auras = player->GetAuras(); + for(Unit::AuraMap::const_iterator itr = auras.begin(); itr != auras.end(); ++itr) + if((itr->second->GetSpellProto()->Attributes & 0x1000010) && itr->second->GetSpellProto()->SpellVisual==3580) + return true; + return false; + } + default: + return false; + } +} + +// Verification of condition values validity +bool PlayerCondition::IsValid(ConditionType condition, uint32 value1, uint32 value2) +{ + if( condition >= MAX_CONDITION) // Wrong condition type + { + sLog.outErrorDb("Condition has bad type of %u, skipped ", condition ); + return false; + } + + switch (condition) + { + case CONDITION_AURA: + { + if(!sSpellStore.LookupEntry(value1)) + { + sLog.outErrorDb("Aura condition requires to have non existing spell (Id: %d), skipped", value1); + return false; + } + if(value2 > 2) + { + sLog.outErrorDb("Aura condition requires to have non existing effect index (%u) (must be 0..2), skipped", value2); + return false; + } + break; + } + case CONDITION_ITEM: + { + ItemPrototype const *proto = objmgr.GetItemPrototype(value1); + if(!proto) + { + sLog.outErrorDb("Item condition requires to have non existing item (%u), skipped", value1); + return false; + } + break; + } + case CONDITION_ITEM_EQUIPPED: + { + ItemPrototype const *proto = objmgr.GetItemPrototype(value1); + if(!proto) + { + sLog.outErrorDb("ItemEquipped condition requires to have non existing item (%u) equipped, skipped", value1); + return false; + } + break; + } + case CONDITION_ZONEID: + { + AreaTableEntry const* areaEntry = GetAreaEntryByAreaID(value1); + if(!areaEntry) + { + sLog.outErrorDb("Zone condition requires to be in non existing area (%u), skipped", value1); + return false; + } + if(areaEntry->zone != 0) + { + sLog.outErrorDb("Zone condition requires to be in area (%u) which is a subzone but zone expected, skipped", value1); + return false; + } + break; + } + case CONDITION_REPUTATION_RANK: + { + FactionEntry const* factionEntry = sFactionStore.LookupEntry(value1); + if(!factionEntry) + { + sLog.outErrorDb("Reputation condition requires to have reputation non existing faction (%u), skipped", value1); + return false; + } + break; + } + case CONDITION_TEAM: + { + if (value1 != ALLIANCE && value1 != HORDE) + { + sLog.outErrorDb("Team condition specifies unknown team (%u), skipped", value1); + return false; + } + break; + } + case CONDITION_SKILL: + { + SkillLineEntry const *pSkill = sSkillLineStore.LookupEntry(value1); + if (!pSkill) + { + sLog.outErrorDb("Skill condition specifies non-existing skill (%u), skipped", value1); + return false; + } + if (value2 < 1 || value2 > sWorld.GetConfigMaxSkillValue() ) + { + sLog.outErrorDb("Skill condition specifies invalid skill value (%u), skipped", value2); + return false; + } + break; + } + case CONDITION_QUESTREWARDED: + case CONDITION_QUESTTAKEN: + { + Quest const *Quest = objmgr.GetQuestTemplate(value1); + if (!Quest) + { + sLog.outErrorDb("Quest condition specifies non-existing quest (%u), skipped", value1); + return false; + } + if(value2) + sLog.outErrorDb("Quest condition has useless data in value2 (%u)!", value2); + break; + } + case CONDITION_AD_COMMISSION_AURA: + { + if(value1) + sLog.outErrorDb("Quest condition has useless data in value1 (%u)!", value1); + if(value2) + sLog.outErrorDb("Quest condition has useless data in value2 (%u)!", value2); + break; + } + } + return true; +} + +SkillRangeType GetSkillRangeType(SkillLineEntry const *pSkill, bool racial) +{ + switch(pSkill->categoryId) + { + case SKILL_CATEGORY_LANGUAGES: return SKILL_RANGE_LANGUAGE; + case SKILL_CATEGORY_WEAPON: + if(pSkill->id!=SKILL_FIST_WEAPONS) + return SKILL_RANGE_LEVEL; + else + return SKILL_RANGE_MONO; + case SKILL_CATEGORY_ARMOR: + case SKILL_CATEGORY_CLASS: + if(pSkill->id != SKILL_POISONS && pSkill->id != SKILL_LOCKPICKING) + return SKILL_RANGE_MONO; + else + return SKILL_RANGE_LEVEL; + case SKILL_CATEGORY_SECONDARY: + case SKILL_CATEGORY_PROFESSION: + // not set skills for professions and racial abilities + if(IsProfessionSkill(pSkill->id)) + return SKILL_RANGE_RANK; + else if(racial) + return SKILL_RANGE_NONE; + else + return SKILL_RANGE_MONO; + default: + case SKILL_CATEGORY_ATTRIBUTES: //not found in dbc + case SKILL_CATEGORY_NOT_DISPLAYED: //only GENEREC(DND) + return SKILL_RANGE_NONE; + } +} + +void ObjectMgr::LoadGameTele() +{ + m_GameTeleMap.clear(); // for relaod case + + uint32 count = 0; + QueryResult *result = WorldDatabase.Query("SELECT id, position_x, position_y, position_z, orientation, map, name FROM game_tele"); + + if( !result ) + { + barGoLink bar( 1 ); + + bar.step(); + + sLog.outString(); + sLog.outErrorDb(">> Loaded `game_tele`, table is empty!"); + return; + } + + barGoLink bar( result->GetRowCount() ); + + do + { + bar.step(); + + Field *fields = result->Fetch(); + + uint32 id = fields[0].GetUInt32(); + + GameTele gt; + + gt.position_x = fields[1].GetFloat(); + gt.position_y = fields[2].GetFloat(); + gt.position_z = fields[3].GetFloat(); + gt.orientation = fields[4].GetFloat(); + gt.mapId = fields[5].GetUInt32(); + gt.name = fields[6].GetCppString(); + + if(!MapManager::IsValidMapCoord(gt.mapId,gt.position_x,gt.position_y,gt.position_z,gt.orientation)) + { + sLog.outErrorDb("Wrong position for id %u (name: %s) in `game_tele` table, ignoring.",id,gt.name.c_str()); + continue; + } + + if(!Utf8toWStr(gt.name,gt.wnameLow)) + { + sLog.outErrorDb("Wrong UTF8 name for id %u in `game_tele` table, ignoring.",id); + continue; + } + + wstrToLower( gt.wnameLow ); + + m_GameTeleMap[id] = gt; + + ++count; + } + while (result->NextRow()); + + delete result; + + sLog.outString(); + sLog.outString( ">> Loaded %u game tele's", count ); +} + +GameTele const* ObjectMgr::GetGameTele(std::string name) const +{ + // explicit name case + std::wstring wname; + if(!Utf8toWStr(name,wname)) + return false; + + // converting string that we try to find to lower case + wstrToLower( wname ); + + for(GameTeleMap::const_iterator itr = m_GameTeleMap.begin(); itr != m_GameTeleMap.end(); ++itr) + if(itr->second.wnameLow == wname) + return &itr->second; + + return NULL; +} + +bool ObjectMgr::AddGameTele(GameTele& tele) +{ + // find max id + uint32 new_id = 0; + for(GameTeleMap::const_iterator itr = m_GameTeleMap.begin(); itr != m_GameTeleMap.end(); ++itr) + if(itr->first > new_id) + new_id = itr->first; + + // use next + ++new_id; + + if(!Utf8toWStr(tele.name,tele.wnameLow)) + return false; + + wstrToLower( tele.wnameLow ); + + m_GameTeleMap[new_id] = tele; + + return WorldDatabase.PExecuteLog("INSERT INTO game_tele (id,position_x,position_y,position_z,orientation,map,name) VALUES (%u,%f,%f,%f,%f,%d,'%s')", + new_id,tele.position_x,tele.position_y,tele.position_z,tele.orientation,tele.mapId,tele.name.c_str()); +} + +bool ObjectMgr::DeleteGameTele(std::string name) +{ + // explicit name case + std::wstring wname; + if(!Utf8toWStr(name,wname)) + return false; + + // converting string that we try to find to lower case + wstrToLower( wname ); + + for(GameTeleMap::iterator itr = m_GameTeleMap.begin(); itr != m_GameTeleMap.end(); ++itr) + { + if(itr->second.wnameLow == wname) + { + WorldDatabase.PExecuteLog("DELETE FROM game_tele WHERE name = '%s'",itr->second.name.c_str()); + m_GameTeleMap.erase(itr); + return true; + } + } + + return false; +} + +void ObjectMgr::LoadTrainerSpell() +{ + // For reload case + for (CacheTrainerSpellMap::iterator itr = m_mCacheTrainerSpellMap.begin(); itr != m_mCacheTrainerSpellMap.end(); ++itr) + itr->second.Clear(); + m_mCacheTrainerSpellMap.clear(); + + QueryResult *result = WorldDatabase.PQuery("SELECT entry, spell,spellcost,reqskill,reqskillvalue,reqlevel FROM npc_trainer"); + + if( !result ) + { + barGoLink bar( 1 ); + + bar.step(); + + sLog.outString(); + sLog.outErrorDb(">> Loaded `npc_trainer`, table is empty!"); + return; + } + + barGoLink bar( result->GetRowCount() ); + + uint32 count = 0,entry,spell; + do + { + bar.step(); + + Field* fields = result->Fetch(); + + entry = fields[0].GetUInt32(); + spell = fields[1].GetUInt32(); + + if(!GetCreatureTemplate(entry)) + { + sLog.outErrorDb("Table `npc_trainer` have entry for not existed creature template (Entry: %u), ignore", entry); + continue; + } + + SpellEntry const *spellinfo = sSpellStore.LookupEntry(spell); + if(!spellinfo) + { + sLog.outErrorDb("Table `npc_trainer` for Trainer (Entry: %u ) has non existing spell %u, ignore", entry,spell); + continue; + } + + if(!SpellMgr::IsSpellValid(spellinfo)) + { + sLog.outErrorDb("Table `npc_trainer` for Trainer (Entry: %u) has broken learning spell %u, ignore", entry, spell); + continue; + } + + TrainerSpell* pTrainerSpell = new TrainerSpell(); + pTrainerSpell->spell = spell; + pTrainerSpell->spellcost = fields[2].GetUInt32(); + pTrainerSpell->reqskill = fields[3].GetUInt32(); + pTrainerSpell->reqskillvalue = fields[4].GetUInt32(); + pTrainerSpell->reqlevel = fields[5].GetUInt32(); + + if(!pTrainerSpell->reqlevel) + pTrainerSpell->reqlevel = spellinfo->spellLevel; + + + TrainerSpellData& data = m_mCacheTrainerSpellMap[entry]; + + if(SpellMgr::IsProfessionSpell(spell)) + data.trainerType = 2; + + data.spellList.push_back(pTrainerSpell); + ++count; + + } while (result->NextRow()); + delete result; + + sLog.outString(); + sLog.outString( ">> Loaded Trainers %d", count ); +} + +void ObjectMgr::LoadVendors() +{ + // For reload case + for (CacheVendorItemMap::iterator itr = m_mCacheVendorItemMap.begin(); itr != m_mCacheVendorItemMap.end(); ++itr) + { + for (VendorItemList::iterator itr2 = itr->second.begin(); itr2 != itr->second.end(); ++itr2) + delete (*itr2); + } + m_mCacheVendorItemMap.clear(); + + QueryResult *result = WorldDatabase.PQuery("SELECT entry, item, maxcount, incrtime, ExtendedCost FROM npc_vendor"); + if( !result ) + { + barGoLink bar( 1 ); + + bar.step(); + + sLog.outString(); + sLog.outErrorDb(">> Loaded `npc_vendor`, table is empty!"); + return; + } + + barGoLink bar( result->GetRowCount() ); + + uint32 count = 0; + uint32 entry, item_id, ExtendedCost; + do + { + bar.step(); + Field* fields = result->Fetch(); + + entry = fields[0].GetUInt32(); + if(!GetCreatureTemplate(entry)) + { + sLog.outErrorDb("Table `npc_vendor` have data for not existed creature template (Entry: %u), ignore", entry); + continue; + } + + item_id = fields[1].GetUInt32(); + if(!GetItemPrototype(item_id)) + { + sLog.outErrorDb("Table `npc_vendor` for Vendor (Entry: %u) have in item list non-existed item (%u), ignore",entry,item_id); + continue; + } + + ExtendedCost = fields[4].GetUInt32(); + if(ExtendedCost && !sItemExtendedCostStore.LookupEntry(ExtendedCost)) + { + sLog.outErrorDb("Table `npc_vendor` have Item (Entry: %u) with wrong ExtendedCost (%u) for vendor (%u), ignore",item_id,ExtendedCost,entry); + continue; + } + + VendorItemList& vList = m_mCacheVendorItemMap[entry]; + + if(vList.size() >= MAX_VENDOR_ITEMS) + { + sLog.outErrorDb( "Table `npc_vendor` has too many items (%u >= %i) for vendor (Entry: %u), ignore", vList.size(), MAX_VENDOR_ITEMS, entry); + continue; + } + + VendorItem* pVendorItem = new VendorItem(); + pVendorItem->item = item_id; + pVendorItem->maxcount = fields[2].GetUInt32(); + pVendorItem->incrtime = fields[3].GetUInt32(); + pVendorItem->ExtendedCost = ExtendedCost; + + vList.push_back(pVendorItem); + ++count; + + } while (result->NextRow()); + delete result; + + sLog.outString(); + sLog.outString( ">> Loaded %d Vendors ", count ); +} + +void ObjectMgr::LoadNpcTextId() +{ + + m_mCacheNpcTextIdMap.clear(); + + QueryResult* result = WorldDatabase.PQuery("SELECT npc_guid, textid FROM npc_gossip"); + if( !result ) + { + barGoLink bar( 1 ); + + bar.step(); + + sLog.outString(); + sLog.outErrorDb(">> Loaded `npc_gossip`, table is empty!"); + return; + } + + barGoLink bar( result->GetRowCount() ); + + uint32 count = 0; + uint32 guid,textid; + do + { + bar.step(); + + Field* fields = result->Fetch(); + + guid = fields[0].GetUInt32(); + textid = fields[1].GetUInt32(); + + if (!GetCreatureData(guid)) + { + sLog.outErrorDb("Table `npc_gossip` have not existed creature (GUID: %u) entry, ignore. ",guid); + continue; + } + if (!GetGossipText(textid)) + { + sLog.outErrorDb("Table `npc_gossip` for creature (GUID: %u) have wrong Textid (%u), ignore. ", guid, textid); + continue; + } + + m_mCacheNpcTextIdMap[guid] = textid ; + ++count; + + } while (result->NextRow()); + delete result; + + sLog.outString(); + sLog.outString( ">> Loaded %d NpcTextId ", count ); +} + +// Functions for scripting access +const char* GetAreaTriggerScriptNameById(uint32 id) +{ + return objmgr.GetAreaTriggerScriptName(id); +} + +bool LoadMangosStrings(DatabaseType& db, char const* table,int32 start_value, int32 end_value) +{ + if(start_value >= 0 || start_value <= end_value) // start/end reversed for negative values + { + sLog.outError("Table '%s' attempt loaded with invalid range (%d - %d), use (%d - %d) instead.",table,start_value,end_value,-1,std::numeric_limits::min()); + start_value = -1; + end_value = std::numeric_limits::min(); + } + + // for scripting localized strings allowed use _only_ negative entries + return objmgr.LoadMangosStrings(db,table,end_value,start_value); +} diff --git a/src/game/ObjectMgr.h b/src/game/ObjectMgr.h index f7b7d0a3cca..42d5d85e415 100644 --- a/src/game/ObjectMgr.h +++ b/src/game/ObjectMgr.h @@ -1,780 +1,860 @@ -/* - * Copyright (C) 2005-2008 MaNGOS - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef _OBJECTMGR_H -#define _OBJECTMGR_H - -#include "Log.h" -#include "Object.h" -#include "Bag.h" -#include "Creature.h" -#include "Player.h" -#include "DynamicObject.h" -#include "GameObject.h" -#include "Corpse.h" -#include "QuestDef.h" -#include "Path.h" -#include "ItemPrototype.h" -#include "NPCHandler.h" -#include "Database/DatabaseEnv.h" -#include "AuctionHouseObject.h" -#include "Mail.h" -#include "Map.h" -#include "ObjectAccessor.h" -#include "ObjectDefines.h" -#include "Policies/Singleton.h" -#include "Database/SQLStorage.h" - -#include -#include - -extern SQLStorage sCreatureStorage; -extern SQLStorage sCreatureDataAddonStorage; -extern SQLStorage sCreatureInfoAddonStorage; -extern SQLStorage sCreatureModelStorage; -extern SQLStorage sEquipmentStorage; -extern SQLStorage sGOStorage; -extern SQLStorage sPageTextStore; -extern SQLStorage sItemStorage; -extern SQLStorage sInstanceTemplate; - -class Group; -class Guild; -class ArenaTeam; -class Path; -class TransportPath; -class Item; - -struct ScriptInfo -{ - uint32 id; - uint32 delay; - uint32 command; - uint32 datalong; - uint32 datalong2; - std::string datatext; - float x; - float y; - float z; - float o; -}; - -typedef std::multimap ScriptMap; -typedef std::map ScriptMapMap; -extern ScriptMapMap sQuestEndScripts; -extern ScriptMapMap sQuestStartScripts; -extern ScriptMapMap sSpellScripts; -extern ScriptMapMap sGameObjectScripts; -extern ScriptMapMap sEventScripts; - -struct AreaTrigger -{ - uint8 requiredLevel; - uint32 requiredItem; - uint32 requiredItem2; - uint32 heroicKey; - uint32 heroicKey2; - uint32 requiredQuest; - std::string requiredFailedText; - uint32 target_mapId; - float target_X; - float target_Y; - float target_Z; - float target_Orientation; -}; - -typedef std::set CellGuidSet; -typedef std::map CellCorpseSet; -struct CellObjectGuids -{ - CellGuidSet creatures; - CellGuidSet gameobjects; - CellCorpseSet corpses; -}; -typedef HM_NAMESPACE::hash_map CellObjectGuidsMap; -typedef HM_NAMESPACE::hash_map MapObjectGuids; - -typedef HM_NAMESPACE::hash_map RespawnTimes; - -struct MangosStringLocale -{ - std::vector Content; // 0 -> default, i -> i-1 locale index -}; - -typedef HM_NAMESPACE::hash_map CreatureDataMap; -typedef HM_NAMESPACE::hash_map GameObjectDataMap; -typedef HM_NAMESPACE::hash_map CreatureLocaleMap; -typedef HM_NAMESPACE::hash_map GameObjectLocaleMap; -typedef HM_NAMESPACE::hash_map ItemLocaleMap; -typedef HM_NAMESPACE::hash_map QuestLocaleMap; -typedef HM_NAMESPACE::hash_map NpcTextLocaleMap; -typedef HM_NAMESPACE::hash_map PageTextLocaleMap; -typedef HM_NAMESPACE::hash_map MangosStringLocaleMap; - -typedef std::multimap QuestRelations; - -struct PetLevelInfo -{ - PetLevelInfo() : health(0), mana(0) { for(int i=0; i < MAX_STATS; ++i ) stats[i] = 0; } - - uint16 stats[MAX_STATS]; - uint16 health; - uint16 mana; - uint16 armor; -}; - -struct ReputationOnKillEntry -{ - uint32 repfaction1; - uint32 repfaction2; - bool is_teamaward1; - uint32 reputration_max_cap1; - int32 repvalue1; - bool is_teamaward2; - uint32 reputration_max_cap2; - int32 repvalue2; - bool team_dependent; -}; - -struct PetCreateSpellEntry -{ - uint32 spellid[4]; -}; - -#define WEATHER_SEASONS 4 -struct WeatherSeasonChances -{ - uint32 rainChance; - uint32 snowChance; - uint32 stormChance; -}; - -struct WeatherZoneChances -{ - WeatherSeasonChances data[WEATHER_SEASONS]; -}; - -struct GraveYardData -{ - uint32 safeLocId; - uint32 team; -}; -typedef std::multimap GraveYardMap; - -enum ConditionType -{ // value1 value2 for the Condition enumed - CONDITION_NONE = 0, // 0 0 - CONDITION_AURA = 1, // spell_id effindex - CONDITION_ITEM = 2, // item_id count - CONDITION_ITEM_EQUIPPED = 3, // item_id 0 - CONDITION_ZONEID = 4, // zone_id 0 - CONDITION_REPUTATION_RANK = 5, // faction_id min_rank - CONDITION_TEAM = 6, // player_team 0, (469 - Alliance 67 - Horde) - CONDITION_SKILL = 7, // skill_id skill_value - CONDITION_QUESTREWARDED = 8, // quest_id 0 - CONDITION_QUESTTAKEN = 9, // quest_id 0, for condition true while quest active. - CONDITION_AD_COMMISSION_AURA = 10, // 0 0, for condition true while one from AD ñommission aura active -}; - -#define MAX_CONDITION 11 // maximum value in ConditionType enum - -struct PlayerCondition -{ - ConditionType condition; // additional condition type - uint32 value1; // data for the condition - see ConditionType definition - uint32 value2; - - PlayerCondition(uint8 _condition = 0, uint32 _value1 = 0, uint32 _value2 = 0) - : condition(ConditionType(_condition)), value1(_value1), value2(_value2) {} - - static bool IsValid(ConditionType condition, uint32 value1, uint32 value2); - // Checks correctness of values - bool Meets(Player const * APlayer) const; // Checks if the player meets the condition - bool operator == (PlayerCondition const& lc) const - { - return (lc.condition == condition && lc.value1 == value1 && lc.value2 == value2); - } -}; - -enum SkillRangeType -{ - SKILL_RANGE_LANGUAGE, // 300..300 - SKILL_RANGE_LEVEL, // 1..max skill for level - SKILL_RANGE_MONO, // 1..1, grey monolite bar - SKILL_RANGE_RANK, // 1..skill for known rank - SKILL_RANGE_NONE, // 0..0 always -}; - -SkillRangeType GetSkillRangeType(SkillLineEntry const *pSkill, bool racial); - -#define MAX_PLAYER_NAME 12 // max allowed by client name length -#define MAX_INTERNAL_PLAYER_NAME 15 // max server internal player name length ( > MAX_PLAYER_NAME for support declined names ) - -bool normalizePlayerName(std::string& name); - -class PlayerDumpReader; - -class ObjectMgr -{ - friend class PlayerDumpReader; - - public: - ObjectMgr(); - ~ObjectMgr(); - - typedef HM_NAMESPACE::hash_map ItemMap; - - typedef std::set< Group * > GroupSet; - typedef std::set< Guild * > GuildSet; - typedef std::set< ArenaTeam * > ArenaTeamSet; - - typedef HM_NAMESPACE::hash_map QuestMap; - - typedef HM_NAMESPACE::hash_map AreaTriggerMap; - - typedef HM_NAMESPACE::hash_map AreaTriggerScriptMap; - - typedef HM_NAMESPACE::hash_map RepOnKillMap; - - typedef HM_NAMESPACE::hash_map WeatherZoneMap; - - typedef HM_NAMESPACE::hash_map PetCreateSpellMap; - - Player* GetPlayer(const char* name) const { return ObjectAccessor::Instance().FindPlayerByName(name);} - Player* GetPlayer(uint64 guid) const { return ObjectAccessor::FindPlayer(guid); } - - static GameObjectInfo const *GetGameObjectInfo(uint32 id) { return sGOStorage.LookupEntry(id); } - - void LoadGameobjectInfo(); - void AddGameobjectInfo(GameObjectInfo *goinfo); - - Group * GetGroupByLeader(const uint64 &guid) const; - void AddGroup(Group* group) { mGroupSet.insert( group ); } - void RemoveGroup(Group* group) { mGroupSet.erase( group ); } - - Guild* GetGuildByLeader(uint64 const&guid) const; - Guild* GetGuildById(const uint32 GuildId) const; - Guild* GetGuildByName(std::string guildname) const; - std::string GetGuildNameById(const uint32 GuildId) const; - void AddGuild(Guild* guild) { mGuildSet.insert( guild ); } - void RemoveGuild(Guild* guild) { mGuildSet.erase( guild ); } - - ArenaTeam* GetArenaTeamById(const uint32 ArenaTeamId) const; - ArenaTeam* GetArenaTeamByName(std::string ArenaTeamName) const; - ArenaTeam* GetArenaTeamByCapitan(uint64 const& guid) const; - void AddArenaTeam(ArenaTeam* arenateam) { mArenaTeamSet.insert( arenateam ); } - void RemoveArenaTeam(ArenaTeam* arenateam) { mArenaTeamSet.erase( arenateam ); } - - static CreatureInfo const *GetCreatureTemplate( uint32 id ); - CreatureModelInfo const *GetCreatureModelInfo( uint32 modelid ); - CreatureModelInfo const* GetCreatureModelRandomGender(uint32 display_id); - uint32 ChooseDisplayId(uint32 team, const CreatureInfo *cinfo, const CreatureData *data = NULL); - EquipmentInfo const *GetEquipmentInfo( uint32 entry ); - static CreatureDataAddon const *GetCreatureAddon( uint32 lowguid ) - { - return sCreatureDataAddonStorage.LookupEntry(lowguid); - } - - static CreatureDataAddon const *GetCreatureTemplateAddon( uint32 entry ) - { - return sCreatureInfoAddonStorage.LookupEntry(entry); - } - - static ItemPrototype const* GetItemPrototype(uint32 id) { return sItemStorage.LookupEntry(id); } - - static InstanceTemplate const* GetInstanceTemplate(uint32 map) - { - return sInstanceTemplate.LookupEntry(map); - } - - Item* GetAItem(uint32 id) - { - ItemMap::const_iterator itr = mAitems.find(id); - if (itr != mAitems.end()) - { - return itr->second; - } - return NULL; - } - void AddAItem(Item* it) - { - ASSERT( it ); - ASSERT( mAitems.find(it->GetGUIDLow()) == mAitems.end()); - mAitems[it->GetGUIDLow()] = it; - } - bool RemoveAItem(uint32 id) - { - ItemMap::iterator i = mAitems.find(id); - if (i == mAitems.end()) - { - return false; - } - mAitems.erase(i); - return true; - } - AuctionHouseObject * GetAuctionsMap( uint32 location ); - - //auction messages - void SendAuctionWonMail( AuctionEntry * auction ); - void SendAuctionSalePendingMail( AuctionEntry * auction ); - void SendAuctionSuccessfulMail( AuctionEntry * auction ); - void SendAuctionExpiredMail( AuctionEntry * auction ); - static uint32 GetAuctionCut( uint32 location, uint32 highBid ); - static uint32 GetAuctionDeposit(uint32 location, uint32 time, Item *pItem); - static uint32 GetAuctionOutBid(uint32 currentBid); - - PetLevelInfo const* GetPetLevelInfo(uint32 creature_id, uint32 level) const; - - PlayerClassInfo const* GetPlayerClassInfo(uint32 class_) const - { - if(class_ >= MAX_CLASSES) return NULL; - return &playerClassInfo[class_]; - } - void GetPlayerClassLevelInfo(uint32 class_,uint32 level, PlayerClassLevelInfo* info) const; - - PlayerInfo const* GetPlayerInfo(uint32 race, uint32 class_) const - { - if(race >= MAX_RACES) return NULL; - if(class_ >= MAX_CLASSES) return NULL; - PlayerInfo const* info = &playerInfo[race][class_]; - if(info->displayId_m==0 || info->displayId_f==0) return NULL; - return info; - } - void GetPlayerLevelInfo(uint32 race, uint32 class_,uint32 level, PlayerLevelInfo* info) const; - - uint64 GetPlayerGUIDByName(std::string name) const; - bool GetPlayerNameByGUID(const uint64 &guid, std::string &name) const; - uint32 GetPlayerTeamByGUID(const uint64 &guid) const; - uint32 GetPlayerAccountIdByGUID(const uint64 &guid) const; - uint32 GetSecurityByAccount(uint32 acc_id) const; - bool GetAccountNameByAccount(uint32 acc_id, std::string &name) const; - uint32 GetAccountByAccountName(std::string name) const; - - uint32 GetNearestTaxiNode( float x, float y, float z, uint32 mapid ); - void GetTaxiPath( uint32 source, uint32 destination, uint32 &path, uint32 &cost); - uint16 GetTaxiMount( uint32 id, uint32 team ); - void GetTaxiPathNodes( uint32 path, Path &pathnodes, std::vector& mapIds ); - void GetTransportPathNodes( uint32 path, TransportPath &pathnodes ); - - Quest const* GetQuestTemplate(uint32 quest_id) const - { - QuestMap::const_iterator itr = mQuestTemplates.find(quest_id); - return itr != mQuestTemplates.end() ? itr->second : NULL; - } - QuestMap const& GetQuestTemplates() const { return mQuestTemplates; } - - uint32 GetQuestForAreaTrigger(uint32 Trigger_ID) const - { - QuestAreaTriggerMap::const_iterator itr = mQuestAreaTriggerMap.find(Trigger_ID); - if(itr != mQuestAreaTriggerMap.end()) - return itr->second; - return 0; - } - bool IsTavernAreaTrigger(uint32 Trigger_ID) const { return mTavernAreaTriggerSet.count(Trigger_ID) != 0; } - bool IsGameObjectForQuests(uint32 entry) const { return mGameObjectForQuestSet.count(entry) != 0; } - bool IsGuildVaultGameObject(Player *player, uint64 guid) const - { - if(GameObject *go = ObjectAccessor::GetGameObject(*player, guid)) - if(go->GetGoType() == GAMEOBJECT_TYPE_GUILD_BANK) - return true; - return false; - } - - uint32 GetBattleMasterBG(uint32 entry) const - { - BattleMastersMap::const_iterator itr = mBattleMastersMap.find(entry); - if(itr != mBattleMastersMap.end()) - return itr->second; - return 2; //BATTLEGROUND_WS - i will not add include only for constant usage! - } - - void AddGossipText(GossipText *pGText); - GossipText *GetGossipText(uint32 Text_ID); - - WorldSafeLocsEntry const *GetClosestGraveYard(float x, float y, float z, uint32 MapId, uint32 team); - bool AddGraveYardLink(uint32 id, uint32 zone, uint32 team, bool inDB = true); - void LoadGraveyardZones(); - GraveYardData const* FindGraveYardData(uint32 id, uint32 zone); - - AreaTrigger const* GetAreaTrigger(uint32 trigger) const - { - AreaTriggerMap::const_iterator itr = mAreaTriggers.find( trigger ); - if( itr != mAreaTriggers.end( ) ) - return &itr->second; - return NULL; - } - - AreaTrigger const* GetGoBackTrigger(uint32 Map) const; - - const char* GetAreaTriggerScriptName(uint32 id); - - ReputationOnKillEntry const* GetReputationOnKilEntry(uint32 id) const - { - RepOnKillMap::const_iterator itr = mRepOnKill.find(id); - if(itr != mRepOnKill.end()) - return &itr->second; - return NULL; - } - - PetCreateSpellEntry const* GetPetCreateSpellEntry(uint32 id) const - { - PetCreateSpellMap::const_iterator itr = mPetCreateSpell.find(id); - if(itr != mPetCreateSpell.end()) - return &itr->second; - return NULL; - } - - void LoadGuilds(); - void LoadArenaTeams(); - void LoadGroups(); - void LoadQuests(); - void LoadQuestRelations() - { - LoadGameobjectQuestRelations(); - LoadGameobjectInvolvedRelations(); - LoadCreatureQuestRelations(); - LoadCreatureInvolvedRelations(); - } - void LoadGameobjectQuestRelations(); - void LoadGameobjectInvolvedRelations(); - void LoadCreatureQuestRelations(); - void LoadCreatureInvolvedRelations(); - - QuestRelations mGOQuestRelations; - QuestRelations mGOQuestInvolvedRelations; - QuestRelations mCreatureQuestRelations; - QuestRelations mCreatureQuestInvolvedRelations; - - void LoadGameObjectScripts(); - void LoadQuestEndScripts(); - void LoadQuestStartScripts(); - void LoadEventScripts(); - void LoadSpellScripts(); - - bool LoadMangosStrings(DatabaseType& db, char const* table, bool positive_entries); - bool LoadMangosStrings() { return LoadMangosStrings(WorldDatabase,"mangos_string",true); } - void LoadPetCreateSpells(); - void LoadCreatureLocales(); - void LoadCreatureTemplates(); - void LoadCreatures(); - void LoadCreatureRespawnTimes(); - void LoadCreatureAddons(); - void LoadCreatureModelInfo(); - void LoadEquipmentTemplates(); - void LoadGameObjectLocales(); - void LoadGameobjects(); - void LoadGameobjectRespawnTimes(); - void LoadItemPrototypes(); - void LoadItemLocales(); - void LoadQuestLocales(); - void LoadNpcTextLocales(); - void LoadPageTextLocales(); - void LoadInstanceTemplate(); - - void LoadGossipText(); - - void LoadAreaTriggerTeleports(); - void LoadQuestAreaTriggers(); - void LoadAreaTriggerScripts(); - void LoadTavernAreaTriggers(); - void LoadBattleMastersEntry(); - void LoadGameObjectForQuests(); - - void LoadItemTexts(); - void LoadPageTexts(); - - //load first auction items, because of check if item exists, when loading - void LoadAuctionItems(); - void LoadAuctions(); - void LoadPlayerInfo(); - void LoadPetLevelInfo(); - void LoadExplorationBaseXP(); - void LoadPetNames(); - void LoadPetNumber(); - void LoadCorpses(); - void LoadFishingBaseSkillLevel(); - - void LoadReputationOnKill(); - - void LoadWeatherZoneChances(); - - std::string GeneratePetName(uint32 entry); - uint32 GetBaseXP(uint32 level); - - int32 GetFishingBaseSkillLevel(uint32 entry) const - { - FishingBaseSkillMap::const_iterator itr = mFishingBaseForArea.find(entry); - return itr != mFishingBaseForArea.end() ? itr->second : 0; - } - - void ReturnOrDeleteOldMails(bool serverUp); - - void SetHighestGuids(); - uint32 GenerateLowGuid(HighGuid guidhigh); - uint32 GenerateAuctionID(); - uint32 GenerateMailID(); - uint32 GenerateItemTextID(); - uint32 GeneratePetNumber(); - - uint32 CreateItemText(std::string text); - std::string GetItemText( uint32 id ) - { - ItemTextMap::const_iterator itr = mItemTexts.find( id ); - if ( itr != mItemTexts.end() ) - return itr->second; - else - return "There is no info for this item"; - } - - typedef std::multimap ExclusiveQuestGroups; - ExclusiveQuestGroups mExclusiveQuestGroups; - - WeatherZoneChances const* GetWeatherChances(uint32 zone_id) const - { - WeatherZoneMap::const_iterator itr = mWeatherZoneMap.find(zone_id); - if(itr != mWeatherZoneMap.end()) - return &itr->second; - else - return NULL; - } - - CellObjectGuids const& GetCellObjectGuids(uint16 mapid, uint8 spawnMode, uint32 cell_id) - { - return mMapObjectGuids[MAKE_PAIR32(mapid,spawnMode)][cell_id]; - } - - CreatureData const* GetCreatureData(uint32 guid) const - { - CreatureDataMap::const_iterator itr = mCreatureDataMap.find(guid); - if(itr==mCreatureDataMap.end()) return NULL; - return &itr->second; - } - CreatureData& NewOrExistCreatureData(uint32 guid) { return mCreatureDataMap[guid]; } - void DeleteCreatureData(uint32 guid); - CreatureLocale const* GetCreatureLocale(uint32 entry) const - { - CreatureLocaleMap::const_iterator itr = mCreatureLocaleMap.find(entry); - if(itr==mCreatureLocaleMap.end()) return NULL; - return &itr->second; - } - GameObjectLocale const* GetGameObjectLocale(uint32 entry) const - { - GameObjectLocaleMap::const_iterator itr = mGameObjectLocaleMap.find(entry); - if(itr==mGameObjectLocaleMap.end()) return NULL; - return &itr->second; - } - ItemLocale const* GetItemLocale(uint32 entry) const - { - ItemLocaleMap::const_iterator itr = mItemLocaleMap.find(entry); - if(itr==mItemLocaleMap.end()) return NULL; - return &itr->second; - } - QuestLocale const* GetQuestLocale(uint32 entry) const - { - QuestLocaleMap::const_iterator itr = mQuestLocaleMap.find(entry); - if(itr==mQuestLocaleMap.end()) return NULL; - return &itr->second; - } - NpcTextLocale const* GetNpcTextLocale(uint32 entry) const - { - NpcTextLocaleMap::const_iterator itr = mNpcTextLocaleMap.find(entry); - if(itr==mNpcTextLocaleMap.end()) return NULL; - return &itr->second; - } - PageTextLocale const* GetPageTextLocale(uint32 entry) const - { - PageTextLocaleMap::const_iterator itr = mPageTextLocaleMap.find(entry); - if(itr==mPageTextLocaleMap.end()) return NULL; - return &itr->second; - } - - GameObjectData const* GetGOData(uint32 guid) const - { - GameObjectDataMap::const_iterator itr = mGameObjectDataMap.find(guid); - if(itr==mGameObjectDataMap.end()) return NULL; - return &itr->second; - } - GameObjectData& NewGOData(uint32 guid) { return mGameObjectDataMap[guid]; } - void DeleteGOData(uint32 guid); - - MangosStringLocale const* GetMangosStringLocale(int32 entry) const - { - MangosStringLocaleMap::const_iterator itr = mMangosStringLocaleMap.find(entry); - if(itr==mMangosStringLocaleMap.end()) return NULL; - return &itr->second; - } - const char *GetMangosString(int32 entry, int locale_idx) const; - const char *GetMangosStringForDBCLocale(int32 entry) const { return GetMangosString(entry,DBCLocaleIndex); } - void SetDBCLocaleIndex(uint32 lang) { DBCLocaleIndex = GetIndexForLocale(LocaleConstant(lang)); } - - void AddCorpseCellData(uint32 mapid, uint32 cellid, uint32 player_guid, uint32 instance); - void DeleteCorpseCellData(uint32 mapid, uint32 cellid, uint32 player_guid); - - time_t GetCreatureRespawnTime(uint32 loguid, uint32 instance) { return mCreatureRespawnTimes[MAKE_PAIR64(loguid,instance)]; } - void SaveCreatureRespawnTime(uint32 loguid, uint32 instance, time_t t); - time_t GetGORespawnTime(uint32 loguid, uint32 instance) { return mGORespawnTimes[MAKE_PAIR64(loguid,instance)]; } - void SaveGORespawnTime(uint32 loguid, uint32 instance, time_t t); - void DeleteRespawnTimeForInstance(uint32 instance); - - // grid objects - void AddCreatureToGrid(uint32 guid, CreatureData const* data); - void RemoveCreatureFromGrid(uint32 guid, CreatureData const* data); - void AddGameobjectToGrid(uint32 guid, GameObjectData const* data); - void RemoveGameobjectFromGrid(uint32 guid, GameObjectData const* data); - - // reserved names - void LoadReservedPlayersNames(); - bool IsReservedName(std::string name) const - { - return m_ReservedNames.find(name) != m_ReservedNames.end(); - } - - // name with valid structure and symbols - static bool IsValidName( std::string name, bool create = false ); - static bool IsValidCharterName( std::string name ); - static bool IsValidPetName( std::string name ); - - static bool CheckDeclinedNames(std::wstring mainpart, DeclinedName const& names); - - int GetIndexForLocale(LocaleConstant loc); - LocaleConstant GetLocaleForIndex(int i); - // guild bank tabs - const uint32 GetGuildBankTabPrice(uint8 Index) { return Index < GUILD_BANK_MAX_TABS ? mGuildBankTabPrice[Index] : 0; } - - uint16 GetConditionId(ConditionType condition, uint32 value1, uint32 value2); - bool IsPlayerMeetToCondition(Player const* player, uint16 condition_id) const - { - if(condition_id >= mConditions.size()) - return false; - - return mConditions[condition_id].Meets(player); - } - protected: - uint32 m_auctionid; - uint32 m_mailid; - uint32 m_ItemTextId; - - uint32 m_hiCharGuid; - uint32 m_hiCreatureGuid; - uint32 m_hiPetGuid; - uint32 m_hiItemGuid; - uint32 m_hiGoGuid; - uint32 m_hiDoGuid; - uint32 m_hiCorpseGuid; - - uint32 m_hiPetNumber; - - QuestMap mQuestTemplates; - - typedef HM_NAMESPACE::hash_map GossipTextMap; - typedef HM_NAMESPACE::hash_map QuestAreaTriggerMap; - typedef HM_NAMESPACE::hash_map BattleMastersMap; - typedef HM_NAMESPACE::hash_map ItemTextMap; - typedef std::set TavernAreaTriggerSet; - typedef std::set GameObjectForQuestSet; - - GroupSet mGroupSet; - GuildSet mGuildSet; - ArenaTeamSet mArenaTeamSet; - - ItemMap mItems; - ItemMap mAitems; - - ItemTextMap mItemTexts; - - AuctionHouseObject mHordeAuctions; - AuctionHouseObject mAllianceAuctions; - AuctionHouseObject mNeutralAuctions; - - QuestAreaTriggerMap mQuestAreaTriggerMap; - BattleMastersMap mBattleMastersMap; - TavernAreaTriggerSet mTavernAreaTriggerSet; - GameObjectForQuestSet mGameObjectForQuestSet; - GossipTextMap mGossipText; - AreaTriggerMap mAreaTriggers; - AreaTriggerScriptMap mAreaTriggerScripts; - - RepOnKillMap mRepOnKill; - - WeatherZoneMap mWeatherZoneMap; - - PetCreateSpellMap mPetCreateSpell; - - //character reserved names - typedef std::set ReservedNamesMap; - ReservedNamesMap m_ReservedNames; - - GraveYardMap mGraveYardMap; - - typedef std::vector LocalForIndex; - LocalForIndex m_LocalForIndex; - int GetOrNewIndexForLocale(LocaleConstant loc); - - int DBCLocaleIndex; - private: - void LoadScripts(ScriptMapMap& scripts, char const* tablename); - void ConvertCreatureAddonAuras(CreatureDataAddon* addon, char const* table, char const* guidEntryStr); - void LoadQuestRelationsHelper(QuestRelations& map,char const* table); - - typedef std::map PetLevelInfoMap; - // PetLevelInfoMap[creature_id][level] - PetLevelInfoMap petInfo; // [creature_id][level] - - PlayerClassInfo playerClassInfo[MAX_CLASSES]; - - void BuildPlayerLevelInfo(uint8 race, uint8 class_, uint8 level, PlayerLevelInfo* plinfo) const; - PlayerInfo playerInfo[MAX_RACES][MAX_CLASSES]; - - typedef std::map BaseXPMap; // [area level][base xp] - BaseXPMap mBaseXPTable; - - typedef std::map FishingBaseSkillMap; // [areaId][base skill level] - FishingBaseSkillMap mFishingBaseForArea; - - typedef std::map > HalfNameMap; - HalfNameMap PetHalfName0; - HalfNameMap PetHalfName1; - - MapObjectGuids mMapObjectGuids; - CreatureDataMap mCreatureDataMap; - CreatureLocaleMap mCreatureLocaleMap; - GameObjectDataMap mGameObjectDataMap; - GameObjectLocaleMap mGameObjectLocaleMap; - ItemLocaleMap mItemLocaleMap; - QuestLocaleMap mQuestLocaleMap; - NpcTextLocaleMap mNpcTextLocaleMap; - PageTextLocaleMap mPageTextLocaleMap; - MangosStringLocaleMap mMangosStringLocaleMap; - RespawnTimes mCreatureRespawnTimes; - RespawnTimes mGORespawnTimes; - - typedef std::vector GuildBankTabPriceMap; - GuildBankTabPriceMap mGuildBankTabPrice; - - // Storage for Conditions. First element (index 0) is reserved for zero-condition (nothing required) - typedef std::vector ConditionStore; - ConditionStore mConditions; - -}; - -#define objmgr MaNGOS::Singleton::Instance() -#endif - -// scripting access functions -bool MANGOS_DLL_SPEC LoadMangosStrings(DatabaseType& db, char const* table); -MANGOS_DLL_SPEC const char* GetAreaTriggerScriptNameById(uint32 id); +/* + * Copyright (C) 2005-2008 MaNGOS + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef _OBJECTMGR_H +#define _OBJECTMGR_H + +#include "Log.h" +#include "Object.h" +#include "Bag.h" +#include "Creature.h" +#include "Player.h" +#include "DynamicObject.h" +#include "GameObject.h" +#include "Corpse.h" +#include "QuestDef.h" +#include "Path.h" +#include "ItemPrototype.h" +#include "NPCHandler.h" +#include "Database/DatabaseEnv.h" +#include "AuctionHouseObject.h" +#include "Mail.h" +#include "Map.h" +#include "ObjectAccessor.h" +#include "ObjectDefines.h" +#include "Policies/Singleton.h" +#include "Database/SQLStorage.h" + +#include +#include +#include + +extern SQLStorage sCreatureStorage; +extern SQLStorage sCreatureDataAddonStorage; +extern SQLStorage sCreatureInfoAddonStorage; +extern SQLStorage sCreatureModelStorage; +extern SQLStorage sEquipmentStorage; +extern SQLStorage sGOStorage; +extern SQLStorage sPageTextStore; +extern SQLStorage sItemStorage; +extern SQLStorage sInstanceTemplate; + +class Group; +class Guild; +class ArenaTeam; +class Path; +class TransportPath; +class Item; + +struct GameTele +{ + float position_x; + float position_y; + float position_z; + float orientation; + uint32 mapId; + std::string name; + std::wstring wnameLow; +}; + +typedef HM_NAMESPACE::hash_map GameTeleMap; + +struct ScriptInfo +{ + uint32 id; + uint32 delay; + uint32 command; + uint32 datalong; + uint32 datalong2; + std::string datatext; + float x; + float y; + float z; + float o; +}; + +typedef std::multimap ScriptMap; +typedef std::map ScriptMapMap; +extern ScriptMapMap sQuestEndScripts; +extern ScriptMapMap sQuestStartScripts; +extern ScriptMapMap sSpellScripts; +extern ScriptMapMap sGameObjectScripts; +extern ScriptMapMap sEventScripts; + +struct AreaTrigger +{ + uint8 requiredLevel; + uint32 requiredItem; + uint32 requiredItem2; + uint32 heroicKey; + uint32 heroicKey2; + uint32 requiredQuest; + std::string requiredFailedText; + uint32 target_mapId; + float target_X; + float target_Y; + float target_Z; + float target_Orientation; +}; + +typedef std::set CellGuidSet; +typedef std::map CellCorpseSet; +struct CellObjectGuids +{ + CellGuidSet creatures; + CellGuidSet gameobjects; + CellCorpseSet corpses; +}; +typedef HM_NAMESPACE::hash_map CellObjectGuidsMap; +typedef HM_NAMESPACE::hash_map MapObjectGuids; + +typedef HM_NAMESPACE::hash_map RespawnTimes; + +struct MangosStringLocale +{ + std::vector Content; // 0 -> default, i -> i-1 locale index +}; + +typedef HM_NAMESPACE::hash_map CreatureDataMap; +typedef HM_NAMESPACE::hash_map GameObjectDataMap; +typedef HM_NAMESPACE::hash_map CreatureLocaleMap; +typedef HM_NAMESPACE::hash_map GameObjectLocaleMap; +typedef HM_NAMESPACE::hash_map ItemLocaleMap; +typedef HM_NAMESPACE::hash_map QuestLocaleMap; +typedef HM_NAMESPACE::hash_map NpcTextLocaleMap; +typedef HM_NAMESPACE::hash_map PageTextLocaleMap; +typedef HM_NAMESPACE::hash_map MangosStringLocaleMap; + +typedef std::multimap QuestRelations; + +struct PetLevelInfo +{ + PetLevelInfo() : health(0), mana(0) { for(int i=0; i < MAX_STATS; ++i ) stats[i] = 0; } + + uint16 stats[MAX_STATS]; + uint16 health; + uint16 mana; + uint16 armor; +}; + +struct ReputationOnKillEntry +{ + uint32 repfaction1; + uint32 repfaction2; + bool is_teamaward1; + uint32 reputation_max_cap1; + int32 repvalue1; + bool is_teamaward2; + uint32 reputation_max_cap2; + int32 repvalue2; + bool team_dependent; +}; + +struct PetCreateSpellEntry +{ + uint32 spellid[4]; +}; + +#define WEATHER_SEASONS 4 +struct WeatherSeasonChances +{ + uint32 rainChance; + uint32 snowChance; + uint32 stormChance; +}; + +struct WeatherZoneChances +{ + WeatherSeasonChances data[WEATHER_SEASONS]; +}; + +struct GraveYardData +{ + uint32 safeLocId; + uint32 team; +}; +typedef std::multimap GraveYardMap; + +enum ConditionType +{ // value1 value2 for the Condition enumed + CONDITION_NONE = 0, // 0 0 + CONDITION_AURA = 1, // spell_id effindex + CONDITION_ITEM = 2, // item_id count + CONDITION_ITEM_EQUIPPED = 3, // item_id 0 + CONDITION_ZONEID = 4, // zone_id 0 + CONDITION_REPUTATION_RANK = 5, // faction_id min_rank + CONDITION_TEAM = 6, // player_team 0, (469 - Alliance 67 - Horde) + CONDITION_SKILL = 7, // skill_id skill_value + CONDITION_QUESTREWARDED = 8, // quest_id 0 + CONDITION_QUESTTAKEN = 9, // quest_id 0, for condition true while quest active. + CONDITION_AD_COMMISSION_AURA = 10, // 0 0, for condition true while one from AD ñommission aura active +}; + +#define MAX_CONDITION 11 // maximum value in ConditionType enum + +struct PlayerCondition +{ + ConditionType condition; // additional condition type + uint32 value1; // data for the condition - see ConditionType definition + uint32 value2; + + PlayerCondition(uint8 _condition = 0, uint32 _value1 = 0, uint32 _value2 = 0) + : condition(ConditionType(_condition)), value1(_value1), value2(_value2) {} + + static bool IsValid(ConditionType condition, uint32 value1, uint32 value2); + // Checks correctness of values + bool Meets(Player const * APlayer) const; // Checks if the player meets the condition + bool operator == (PlayerCondition const& lc) const + { + return (lc.condition == condition && lc.value1 == value1 && lc.value2 == value2); + } +}; + +// NPC gossip text id +typedef HM_NAMESPACE::hash_map CacheNpcTextIdMap; + +// Vendors +struct VendorItem +{ + uint32 item; + uint32 maxcount; + uint32 incrtime; + uint32 ExtendedCost; +}; +typedef std::vector VendorItemList; + +typedef HM_NAMESPACE::hash_map CacheVendorItemMap; + +typedef HM_NAMESPACE::hash_map CacheTrainerSpellMap; + +enum SkillRangeType +{ + SKILL_RANGE_LANGUAGE, // 300..300 + SKILL_RANGE_LEVEL, // 1..max skill for level + SKILL_RANGE_MONO, // 1..1, grey monolite bar + SKILL_RANGE_RANK, // 1..skill for known rank + SKILL_RANGE_NONE, // 0..0 always +}; + +SkillRangeType GetSkillRangeType(SkillLineEntry const *pSkill, bool racial); + +#define MAX_PLAYER_NAME 12 // max allowed by client name length +#define MAX_INTERNAL_PLAYER_NAME 15 // max server internal player name length ( > MAX_PLAYER_NAME for support declined names ) + +bool normalizePlayerName(std::string& name); + +class PlayerDumpReader; + +class ObjectMgr +{ + friend class PlayerDumpReader; + + public: + ObjectMgr(); + ~ObjectMgr(); + + typedef HM_NAMESPACE::hash_map ItemMap; + + typedef std::set< Group * > GroupSet; + typedef std::set< Guild * > GuildSet; + typedef std::set< ArenaTeam * > ArenaTeamSet; + + typedef HM_NAMESPACE::hash_map QuestMap; + + typedef HM_NAMESPACE::hash_map AreaTriggerMap; + + typedef HM_NAMESPACE::hash_map AreaTriggerScriptMap; + + typedef HM_NAMESPACE::hash_map RepOnKillMap; + + typedef HM_NAMESPACE::hash_map WeatherZoneMap; + + typedef HM_NAMESPACE::hash_map PetCreateSpellMap; + + Player* GetPlayer(const char* name) const { return ObjectAccessor::Instance().FindPlayerByName(name);} + Player* GetPlayer(uint64 guid) const { return ObjectAccessor::FindPlayer(guid); } + + static GameObjectInfo const *GetGameObjectInfo(uint32 id) { return sGOStorage.LookupEntry(id); } + + void LoadGameobjectInfo(); + void AddGameobjectInfo(GameObjectInfo *goinfo); + + Group * GetGroupByLeader(const uint64 &guid) const; + void AddGroup(Group* group) { mGroupSet.insert( group ); } + void RemoveGroup(Group* group) { mGroupSet.erase( group ); } + + Guild* GetGuildByLeader(uint64 const&guid) const; + Guild* GetGuildById(const uint32 GuildId) const; + Guild* GetGuildByName(std::string guildname) const; + std::string GetGuildNameById(const uint32 GuildId) const; + void AddGuild(Guild* guild) { mGuildSet.insert( guild ); } + void RemoveGuild(Guild* guild) { mGuildSet.erase( guild ); } + + ArenaTeam* GetArenaTeamById(const uint32 ArenaTeamId) const; + ArenaTeam* GetArenaTeamByName(std::string ArenaTeamName) const; + ArenaTeam* GetArenaTeamByCapitan(uint64 const& guid) const; + void AddArenaTeam(ArenaTeam* arenateam) { mArenaTeamSet.insert( arenateam ); } + void RemoveArenaTeam(ArenaTeam* arenateam) { mArenaTeamSet.erase( arenateam ); } + + static CreatureInfo const *GetCreatureTemplate( uint32 id ); + CreatureModelInfo const *GetCreatureModelInfo( uint32 modelid ); + CreatureModelInfo const* GetCreatureModelRandomGender(uint32 display_id); + uint32 ChooseDisplayId(uint32 team, const CreatureInfo *cinfo, const CreatureData *data = NULL); + EquipmentInfo const *GetEquipmentInfo( uint32 entry ); + static CreatureDataAddon const *GetCreatureAddon( uint32 lowguid ) + { + return sCreatureDataAddonStorage.LookupEntry(lowguid); + } + + static CreatureDataAddon const *GetCreatureTemplateAddon( uint32 entry ) + { + return sCreatureInfoAddonStorage.LookupEntry(entry); + } + + static ItemPrototype const* GetItemPrototype(uint32 id) { return sItemStorage.LookupEntry(id); } + + static InstanceTemplate const* GetInstanceTemplate(uint32 map) + { + return sInstanceTemplate.LookupEntry(map); + } + + Item* GetAItem(uint32 id) + { + ItemMap::const_iterator itr = mAitems.find(id); + if (itr != mAitems.end()) + { + return itr->second; + } + return NULL; + } + void AddAItem(Item* it) + { + ASSERT( it ); + ASSERT( mAitems.find(it->GetGUIDLow()) == mAitems.end()); + mAitems[it->GetGUIDLow()] = it; + } + bool RemoveAItem(uint32 id) + { + ItemMap::iterator i = mAitems.find(id); + if (i == mAitems.end()) + { + return false; + } + mAitems.erase(i); + return true; + } + AuctionHouseObject * GetAuctionsMap( uint32 location ); + + //auction messages + void SendAuctionWonMail( AuctionEntry * auction ); + void SendAuctionSalePendingMail( AuctionEntry * auction ); + void SendAuctionSuccessfulMail( AuctionEntry * auction ); + void SendAuctionExpiredMail( AuctionEntry * auction ); + static uint32 GetAuctionCut( uint32 location, uint32 highBid ); + static uint32 GetAuctionDeposit(uint32 location, uint32 time, Item *pItem); + static uint32 GetAuctionOutBid(uint32 currentBid); + + PetLevelInfo const* GetPetLevelInfo(uint32 creature_id, uint32 level) const; + + PlayerClassInfo const* GetPlayerClassInfo(uint32 class_) const + { + if(class_ >= MAX_CLASSES) return NULL; + return &playerClassInfo[class_]; + } + void GetPlayerClassLevelInfo(uint32 class_,uint32 level, PlayerClassLevelInfo* info) const; + + PlayerInfo const* GetPlayerInfo(uint32 race, uint32 class_) const + { + if(race >= MAX_RACES) return NULL; + if(class_ >= MAX_CLASSES) return NULL; + PlayerInfo const* info = &playerInfo[race][class_]; + if(info->displayId_m==0 || info->displayId_f==0) return NULL; + return info; + } + void GetPlayerLevelInfo(uint32 race, uint32 class_,uint32 level, PlayerLevelInfo* info) const; + + uint64 GetPlayerGUIDByName(std::string name) const; + bool GetPlayerNameByGUID(const uint64 &guid, std::string &name) const; + uint32 GetPlayerTeamByGUID(const uint64 &guid) const; + uint32 GetPlayerAccountIdByGUID(const uint64 &guid) const; + uint32 GetSecurityByAccount(uint32 acc_id) const; + bool GetAccountNameByAccount(uint32 acc_id, std::string &name) const; + uint32 GetAccountByAccountName(std::string name) const; + + uint32 GetNearestTaxiNode( float x, float y, float z, uint32 mapid ); + void GetTaxiPath( uint32 source, uint32 destination, uint32 &path, uint32 &cost); + uint16 GetTaxiMount( uint32 id, uint32 team ); + void GetTaxiPathNodes( uint32 path, Path &pathnodes, std::vector& mapIds ); + void GetTransportPathNodes( uint32 path, TransportPath &pathnodes ); + + Quest const* GetQuestTemplate(uint32 quest_id) const + { + QuestMap::const_iterator itr = mQuestTemplates.find(quest_id); + return itr != mQuestTemplates.end() ? itr->second : NULL; + } + QuestMap const& GetQuestTemplates() const { return mQuestTemplates; } + + uint32 GetQuestForAreaTrigger(uint32 Trigger_ID) const + { + QuestAreaTriggerMap::const_iterator itr = mQuestAreaTriggerMap.find(Trigger_ID); + if(itr != mQuestAreaTriggerMap.end()) + return itr->second; + return 0; + } + bool IsTavernAreaTrigger(uint32 Trigger_ID) const { return mTavernAreaTriggerSet.count(Trigger_ID) != 0; } + bool IsGameObjectForQuests(uint32 entry) const { return mGameObjectForQuestSet.count(entry) != 0; } + bool IsGuildVaultGameObject(Player *player, uint64 guid) const + { + if(GameObject *go = ObjectAccessor::GetGameObject(*player, guid)) + if(go->GetGoType() == GAMEOBJECT_TYPE_GUILD_BANK) + return true; + return false; + } + + uint32 GetBattleMasterBG(uint32 entry) const + { + BattleMastersMap::const_iterator itr = mBattleMastersMap.find(entry); + if(itr != mBattleMastersMap.end()) + return itr->second; + return 2; //BATTLEGROUND_WS - i will not add include only for constant usage! + } + + void AddGossipText(GossipText *pGText); + GossipText *GetGossipText(uint32 Text_ID); + + WorldSafeLocsEntry const *GetClosestGraveYard(float x, float y, float z, uint32 MapId, uint32 team); + bool AddGraveYardLink(uint32 id, uint32 zone, uint32 team, bool inDB = true); + void LoadGraveyardZones(); + GraveYardData const* FindGraveYardData(uint32 id, uint32 zone); + + AreaTrigger const* GetAreaTrigger(uint32 trigger) const + { + AreaTriggerMap::const_iterator itr = mAreaTriggers.find( trigger ); + if( itr != mAreaTriggers.end( ) ) + return &itr->second; + return NULL; + } + + AreaTrigger const* GetGoBackTrigger(uint32 Map) const; + + const char* GetAreaTriggerScriptName(uint32 id); + + ReputationOnKillEntry const* GetReputationOnKilEntry(uint32 id) const + { + RepOnKillMap::const_iterator itr = mRepOnKill.find(id); + if(itr != mRepOnKill.end()) + return &itr->second; + return NULL; + } + + PetCreateSpellEntry const* GetPetCreateSpellEntry(uint32 id) const + { + PetCreateSpellMap::const_iterator itr = mPetCreateSpell.find(id); + if(itr != mPetCreateSpell.end()) + return &itr->second; + return NULL; + } + + void LoadGuilds(); + void LoadArenaTeams(); + void LoadGroups(); + void LoadQuests(); + void LoadQuestRelations() + { + LoadGameobjectQuestRelations(); + LoadGameobjectInvolvedRelations(); + LoadCreatureQuestRelations(); + LoadCreatureInvolvedRelations(); + } + void LoadGameobjectQuestRelations(); + void LoadGameobjectInvolvedRelations(); + void LoadCreatureQuestRelations(); + void LoadCreatureInvolvedRelations(); + + QuestRelations mGOQuestRelations; + QuestRelations mGOQuestInvolvedRelations; + QuestRelations mCreatureQuestRelations; + QuestRelations mCreatureQuestInvolvedRelations; + + void LoadGameObjectScripts(); + void LoadQuestEndScripts(); + void LoadQuestStartScripts(); + void LoadEventScripts(); + void LoadSpellScripts(); + + bool LoadMangosStrings(DatabaseType& db, char const* table, int32 min_value, int32 max_value); + bool LoadMangosStrings() { return LoadMangosStrings(WorldDatabase,"mangos_string",1,std::numeric_limits::max()); } + void LoadPetCreateSpells(); + void LoadCreatureLocales(); + void LoadCreatureTemplates(); + void LoadCreatures(); + void LoadCreatureRespawnTimes(); + void LoadCreatureAddons(); + void LoadCreatureModelInfo(); + void LoadEquipmentTemplates(); + void LoadGameObjectLocales(); + void LoadGameobjects(); + void LoadGameobjectRespawnTimes(); + void LoadItemPrototypes(); + void LoadItemLocales(); + void LoadQuestLocales(); + void LoadNpcTextLocales(); + void LoadPageTextLocales(); + void LoadInstanceTemplate(); + + void LoadGossipText(); + + void LoadAreaTriggerTeleports(); + void LoadQuestAreaTriggers(); + void LoadAreaTriggerScripts(); + void LoadTavernAreaTriggers(); + void LoadBattleMastersEntry(); + void LoadGameObjectForQuests(); + + void LoadItemTexts(); + void LoadPageTexts(); + + //load first auction items, because of check if item exists, when loading + void LoadAuctionItems(); + void LoadAuctions(); + void LoadPlayerInfo(); + void LoadPetLevelInfo(); + void LoadExplorationBaseXP(); + void LoadPetNames(); + void LoadPetNumber(); + void LoadCorpses(); + void LoadFishingBaseSkillLevel(); + + void LoadReputationOnKill(); + + void LoadWeatherZoneChances(); + void LoadGameTele(); + + void LoadNpcTextId(); + void LoadVendors(); + void LoadTrainerSpell(); + + std::string GeneratePetName(uint32 entry); + uint32 GetBaseXP(uint32 level); + + int32 GetFishingBaseSkillLevel(uint32 entry) const + { + FishingBaseSkillMap::const_iterator itr = mFishingBaseForArea.find(entry); + return itr != mFishingBaseForArea.end() ? itr->second : 0; + } + + void ReturnOrDeleteOldMails(bool serverUp); + + void SetHighestGuids(); + uint32 GenerateLowGuid(HighGuid guidhigh); + uint32 GenerateAuctionID(); + uint32 GenerateMailID(); + uint32 GenerateItemTextID(); + uint32 GeneratePetNumber(); + + uint32 CreateItemText(std::string text); + std::string GetItemText( uint32 id ) + { + ItemTextMap::const_iterator itr = mItemTexts.find( id ); + if ( itr != mItemTexts.end() ) + return itr->second; + else + return "There is no info for this item"; + } + + typedef std::multimap ExclusiveQuestGroups; + ExclusiveQuestGroups mExclusiveQuestGroups; + + WeatherZoneChances const* GetWeatherChances(uint32 zone_id) const + { + WeatherZoneMap::const_iterator itr = mWeatherZoneMap.find(zone_id); + if(itr != mWeatherZoneMap.end()) + return &itr->second; + else + return NULL; + } + + CellObjectGuids const& GetCellObjectGuids(uint16 mapid, uint8 spawnMode, uint32 cell_id) + { + return mMapObjectGuids[MAKE_PAIR32(mapid,spawnMode)][cell_id]; + } + + CreatureData const* GetCreatureData(uint32 guid) const + { + CreatureDataMap::const_iterator itr = mCreatureDataMap.find(guid); + if(itr==mCreatureDataMap.end()) return NULL; + return &itr->second; + } + CreatureData& NewOrExistCreatureData(uint32 guid) { return mCreatureDataMap[guid]; } + void DeleteCreatureData(uint32 guid); + CreatureLocale const* GetCreatureLocale(uint32 entry) const + { + CreatureLocaleMap::const_iterator itr = mCreatureLocaleMap.find(entry); + if(itr==mCreatureLocaleMap.end()) return NULL; + return &itr->second; + } + GameObjectLocale const* GetGameObjectLocale(uint32 entry) const + { + GameObjectLocaleMap::const_iterator itr = mGameObjectLocaleMap.find(entry); + if(itr==mGameObjectLocaleMap.end()) return NULL; + return &itr->second; + } + ItemLocale const* GetItemLocale(uint32 entry) const + { + ItemLocaleMap::const_iterator itr = mItemLocaleMap.find(entry); + if(itr==mItemLocaleMap.end()) return NULL; + return &itr->second; + } + QuestLocale const* GetQuestLocale(uint32 entry) const + { + QuestLocaleMap::const_iterator itr = mQuestLocaleMap.find(entry); + if(itr==mQuestLocaleMap.end()) return NULL; + return &itr->second; + } + NpcTextLocale const* GetNpcTextLocale(uint32 entry) const + { + NpcTextLocaleMap::const_iterator itr = mNpcTextLocaleMap.find(entry); + if(itr==mNpcTextLocaleMap.end()) return NULL; + return &itr->second; + } + PageTextLocale const* GetPageTextLocale(uint32 entry) const + { + PageTextLocaleMap::const_iterator itr = mPageTextLocaleMap.find(entry); + if(itr==mPageTextLocaleMap.end()) return NULL; + return &itr->second; + } + + GameObjectData const* GetGOData(uint32 guid) const + { + GameObjectDataMap::const_iterator itr = mGameObjectDataMap.find(guid); + if(itr==mGameObjectDataMap.end()) return NULL; + return &itr->second; + } + GameObjectData& NewGOData(uint32 guid) { return mGameObjectDataMap[guid]; } + void DeleteGOData(uint32 guid); + + MangosStringLocale const* GetMangosStringLocale(int32 entry) const + { + MangosStringLocaleMap::const_iterator itr = mMangosStringLocaleMap.find(entry); + if(itr==mMangosStringLocaleMap.end()) return NULL; + return &itr->second; + } + const char *GetMangosString(int32 entry, int locale_idx) const; + const char *GetMangosStringForDBCLocale(int32 entry) const { return GetMangosString(entry,DBCLocaleIndex); } + void SetDBCLocaleIndex(uint32 lang) { DBCLocaleIndex = GetIndexForLocale(LocaleConstant(lang)); } + + void AddCorpseCellData(uint32 mapid, uint32 cellid, uint32 player_guid, uint32 instance); + void DeleteCorpseCellData(uint32 mapid, uint32 cellid, uint32 player_guid); + + time_t GetCreatureRespawnTime(uint32 loguid, uint32 instance) { return mCreatureRespawnTimes[MAKE_PAIR64(loguid,instance)]; } + void SaveCreatureRespawnTime(uint32 loguid, uint32 instance, time_t t); + time_t GetGORespawnTime(uint32 loguid, uint32 instance) { return mGORespawnTimes[MAKE_PAIR64(loguid,instance)]; } + void SaveGORespawnTime(uint32 loguid, uint32 instance, time_t t); + void DeleteRespawnTimeForInstance(uint32 instance); + + // grid objects + void AddCreatureToGrid(uint32 guid, CreatureData const* data); + void RemoveCreatureFromGrid(uint32 guid, CreatureData const* data); + void AddGameobjectToGrid(uint32 guid, GameObjectData const* data); + void RemoveGameobjectFromGrid(uint32 guid, GameObjectData const* data); + + // reserved names + void LoadReservedPlayersNames(); + bool IsReservedName(std::string name) const + { + return m_ReservedNames.find(name) != m_ReservedNames.end(); + } + + // name with valid structure and symbols + static bool IsValidName( std::string name, bool create = false ); + static bool IsValidCharterName( std::string name ); + static bool IsValidPetName( std::string name ); + + static bool CheckDeclinedNames(std::wstring mainpart, DeclinedName const& names); + + int GetIndexForLocale(LocaleConstant loc); + LocaleConstant GetLocaleForIndex(int i); + // guild bank tabs + const uint32 GetGuildBankTabPrice(uint8 Index) { return Index < GUILD_BANK_MAX_TABS ? mGuildBankTabPrice[Index] : 0; } + + uint16 GetConditionId(ConditionType condition, uint32 value1, uint32 value2); + bool IsPlayerMeetToCondition(Player const* player, uint16 condition_id) const + { + if(condition_id >= mConditions.size()) + return false; + + return mConditions[condition_id].Meets(player); + } + + GameTele const* GetGameTele(uint32 id) const + { + GameTeleMap::const_iterator itr = m_GameTeleMap.find(id); + if(itr==m_GameTeleMap.end()) return NULL; + return &itr->second; + } + GameTele const* GetGameTele(std::string name) const; + GameTeleMap const& GetGameTeleMap() const { return m_GameTeleMap; } + bool AddGameTele(GameTele& data); + bool DeleteGameTele(std::string name); + + uint32 GetNpcGossip(uint32 entry) const + { + CacheNpcTextIdMap::const_iterator iter = m_mCacheNpcTextIdMap.find(entry); + if(iter == m_mCacheNpcTextIdMap.end()) + return 0; + + return iter->second; + } + + TrainerSpellData const* GetNpcTrainerSpells(uint32 entry) const + { + CacheTrainerSpellMap::const_iterator iter = m_mCacheTrainerSpellMap.find(entry); + if(iter == m_mCacheTrainerSpellMap.end()) + return NULL; + + return &iter->second; + } + + VendorItemList const* GetNpcVendorItemList(uint32 entry) const + { + CacheVendorItemMap::const_iterator iter = m_mCacheVendorItemMap.find(entry); + if(iter == m_mCacheVendorItemMap.end()) + return NULL; + + return &iter->second; + } + protected: + uint32 m_auctionid; + uint32 m_mailid; + uint32 m_ItemTextId; + + uint32 m_hiCharGuid; + uint32 m_hiCreatureGuid; + uint32 m_hiPetGuid; + uint32 m_hiItemGuid; + uint32 m_hiGoGuid; + uint32 m_hiDoGuid; + uint32 m_hiCorpseGuid; + + uint32 m_hiPetNumber; + + QuestMap mQuestTemplates; + + typedef HM_NAMESPACE::hash_map GossipTextMap; + typedef HM_NAMESPACE::hash_map QuestAreaTriggerMap; + typedef HM_NAMESPACE::hash_map BattleMastersMap; + typedef HM_NAMESPACE::hash_map ItemTextMap; + typedef std::set TavernAreaTriggerSet; + typedef std::set GameObjectForQuestSet; + + GroupSet mGroupSet; + GuildSet mGuildSet; + ArenaTeamSet mArenaTeamSet; + + ItemMap mItems; + ItemMap mAitems; + + ItemTextMap mItemTexts; + + AuctionHouseObject mHordeAuctions; + AuctionHouseObject mAllianceAuctions; + AuctionHouseObject mNeutralAuctions; + + QuestAreaTriggerMap mQuestAreaTriggerMap; + BattleMastersMap mBattleMastersMap; + TavernAreaTriggerSet mTavernAreaTriggerSet; + GameObjectForQuestSet mGameObjectForQuestSet; + GossipTextMap mGossipText; + AreaTriggerMap mAreaTriggers; + AreaTriggerScriptMap mAreaTriggerScripts; + + RepOnKillMap mRepOnKill; + + WeatherZoneMap mWeatherZoneMap; + + PetCreateSpellMap mPetCreateSpell; + + //character reserved names + typedef std::set ReservedNamesMap; + ReservedNamesMap m_ReservedNames; + + GraveYardMap mGraveYardMap; + + GameTeleMap m_GameTeleMap; + + typedef std::vector LocalForIndex; + LocalForIndex m_LocalForIndex; + int GetOrNewIndexForLocale(LocaleConstant loc); + + int DBCLocaleIndex; + private: + void LoadScripts(ScriptMapMap& scripts, char const* tablename); + void ConvertCreatureAddonAuras(CreatureDataAddon* addon, char const* table, char const* guidEntryStr); + void LoadQuestRelationsHelper(QuestRelations& map,char const* table); + + typedef std::map PetLevelInfoMap; + // PetLevelInfoMap[creature_id][level] + PetLevelInfoMap petInfo; // [creature_id][level] + + PlayerClassInfo playerClassInfo[MAX_CLASSES]; + + void BuildPlayerLevelInfo(uint8 race, uint8 class_, uint8 level, PlayerLevelInfo* plinfo) const; + PlayerInfo playerInfo[MAX_RACES][MAX_CLASSES]; + + typedef std::map BaseXPMap; // [area level][base xp] + BaseXPMap mBaseXPTable; + + typedef std::map FishingBaseSkillMap; // [areaId][base skill level] + FishingBaseSkillMap mFishingBaseForArea; + + typedef std::map > HalfNameMap; + HalfNameMap PetHalfName0; + HalfNameMap PetHalfName1; + + MapObjectGuids mMapObjectGuids; + CreatureDataMap mCreatureDataMap; + CreatureLocaleMap mCreatureLocaleMap; + GameObjectDataMap mGameObjectDataMap; + GameObjectLocaleMap mGameObjectLocaleMap; + ItemLocaleMap mItemLocaleMap; + QuestLocaleMap mQuestLocaleMap; + NpcTextLocaleMap mNpcTextLocaleMap; + PageTextLocaleMap mPageTextLocaleMap; + MangosStringLocaleMap mMangosStringLocaleMap; + RespawnTimes mCreatureRespawnTimes; + RespawnTimes mGORespawnTimes; + + typedef std::vector GuildBankTabPriceMap; + GuildBankTabPriceMap mGuildBankTabPrice; + + // Storage for Conditions. First element (index 0) is reserved for zero-condition (nothing required) + typedef std::vector ConditionStore; + ConditionStore mConditions; + + CacheNpcTextIdMap m_mCacheNpcTextIdMap; + CacheVendorItemMap m_mCacheVendorItemMap; + CacheTrainerSpellMap m_mCacheTrainerSpellMap; +}; + +#define objmgr MaNGOS::Singleton::Instance() + +// scripting access functions +bool MANGOS_DLL_SPEC LoadMangosStrings(DatabaseType& db, char const* table,int32 start_value = -1, int32 end_value = std::numeric_limits::min()); +MANGOS_DLL_SPEC const char* GetAreaTriggerScriptNameById(uint32 id); + +#endif diff --git a/src/game/Player.cpp b/src/game/Player.cpp index f93b44ba732..9ba6404cb5f 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -1,18130 +1,18133 @@ -/* - * Copyright (C) 2005-2008 MaNGOS - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "Common.h" -#include "Language.h" -#include "Database/DatabaseEnv.h" -#include "Log.h" -#include "Opcodes.h" -#include "ObjectMgr.h" -#include "SpellMgr.h" -#include "World.h" -#include "WorldPacket.h" -#include "WorldSession.h" -#include "UpdateMask.h" -#include "Player.h" -#include "SkillDiscovery.h" -#include "QuestDef.h" -#include "GossipDef.h" -#include "UpdateData.h" -#include "Channel.h" -#include "ChannelMgr.h" -#include "MapManager.h" -#include "MapInstanced.h" -#include "InstanceSaveMgr.h" -#include "GridNotifiers.h" -#include "GridNotifiersImpl.h" -#include "CellImpl.h" -#include "ObjectMgr.h" -#include "ObjectAccessor.h" -#include "CreatureAI.h" -#include "Formulas.h" -#include "Group.h" -#include "Guild.h" -#include "Pet.h" -#include "SpellAuras.h" -#include "Util.h" -#include "Transports.h" -#include "Weather.h" -#include "BattleGround.h" -#include "BattleGroundMgr.h" -#include "ArenaTeam.h" -#include "Chat.h" -#include "Database/DatabaseImpl.h" -#include "Spell.h" -#include "SocialMgr.h" - -#include - -#define ZONE_UPDATE_INTERVAL 1000 - -#define PLAYER_SKILL_INDEX(x) (PLAYER_SKILL_INFO_1_1 + ((x)*3)) -#define PLAYER_SKILL_VALUE_INDEX(x) (PLAYER_SKILL_INDEX(x)+1) -#define PLAYER_SKILL_BONUS_INDEX(x) (PLAYER_SKILL_INDEX(x)+2) - -#define SKILL_VALUE(x) PAIR32_LOPART(x) -#define SKILL_MAX(x) PAIR32_HIPART(x) -#define MAKE_SKILL_VALUE(v, m) MAKE_PAIR32(v,m) - -#define SKILL_TEMP_BONUS(x) int16(PAIR32_LOPART(x)) -#define SKILL_PERM_BONUS(x) int16(PAIR32_HIPART(x)) -#define MAKE_SKILL_BONUS(t, p) MAKE_PAIR32(t,p) - -enum CharacterFlags -{ - CHARACTER_FLAG_NONE = 0x00000000, - CHARACTER_FLAG_UNK1 = 0x00000001, - CHARACTER_FLAG_UNK2 = 0x00000002, - CHARACTER_LOCKED_FOR_TRANSFER = 0x00000004, - CHARACTER_FLAG_UNK4 = 0x00000008, - CHARACTER_FLAG_UNK5 = 0x00000010, - CHARACTER_FLAG_UNK6 = 0x00000020, - CHARACTER_FLAG_UNK7 = 0x00000040, - CHARACTER_FLAG_UNK8 = 0x00000080, - CHARACTER_FLAG_UNK9 = 0x00000100, - CHARACTER_FLAG_UNK10 = 0x00000200, - CHARACTER_FLAG_HIDE_HELM = 0x00000400, - CHARACTER_FLAG_HIDE_CLOAK = 0x00000800, - CHARACTER_FLAG_UNK13 = 0x00001000, - CHARACTER_FLAG_GHOST = 0x00002000, - CHARACTER_FLAG_RENAME = 0x00004000, - CHARACTER_FLAG_UNK16 = 0x00008000, - CHARACTER_FLAG_UNK17 = 0x00010000, - CHARACTER_FLAG_UNK18 = 0x00020000, - CHARACTER_FLAG_UNK19 = 0x00040000, - CHARACTER_FLAG_UNK20 = 0x00080000, - CHARACTER_FLAG_UNK21 = 0x00100000, - CHARACTER_FLAG_UNK22 = 0x00200000, - CHARACTER_FLAG_UNK23 = 0x00400000, - CHARACTER_FLAG_UNK24 = 0x00800000, - CHARACTER_FLAG_LOCKED_BY_BILLING = 0x01000000, - CHARACTER_FLAG_DECLINED = 0x02000000, - CHARACTER_FLAG_UNK27 = 0x04000000, - CHARACTER_FLAG_UNK28 = 0x08000000, - CHARACTER_FLAG_UNK29 = 0x10000000, - CHARACTER_FLAG_UNK30 = 0x20000000, - CHARACTER_FLAG_UNK31 = 0x40000000, - CHARACTER_FLAG_UNK32 = 0x80000000 -}; - -// corpse reclaim times -#define DEATH_EXPIRE_STEP (5*MINUTE) -#define MAX_DEATH_COUNT 3 - -static uint32 copseReclaimDelay[MAX_DEATH_COUNT] = { 30, 60, 120 }; - -//== PlayerTaxi ================================================ - -PlayerTaxi::PlayerTaxi() -{ - // Taxi nodes - memset(m_taximask, 0, sizeof(m_taximask)); -} - -void PlayerTaxi::InitTaxiNodesForLevel(uint32 race, uint32 level) -{ - // capital and taxi hub masks - switch(race) - { - case RACE_HUMAN: SetTaximaskNode(2); break; // Human - case RACE_ORC: SetTaximaskNode(23); break; // Orc - case RACE_DWARF: SetTaximaskNode(6); break; // Dwarf - case RACE_NIGHTELF: SetTaximaskNode(26); - SetTaximaskNode(27); break; // Night Elf - case RACE_UNDEAD_PLAYER: SetTaximaskNode(11); break;// Undead - case RACE_TAUREN: SetTaximaskNode(22); break; // Tauren - case RACE_GNOME: SetTaximaskNode(6); break; // Gnome - case RACE_TROLL: SetTaximaskNode(23); break; // Troll - case RACE_BLOODELF: SetTaximaskNode(82); break; // Blood Elf - case RACE_DRAENEI: SetTaximaskNode(94); break; // Draenei - } - // new continent starting masks (It will be accessible only at new map) - switch(Player::TeamForRace(race)) - { - case ALLIANCE: SetTaximaskNode(100); break; - case HORDE: SetTaximaskNode(99); break; - } - // level dependent taxi hubs - if(level>=68) - SetTaximaskNode(213); //Shattered Sun Staging Area -} - -void PlayerTaxi::LoadTaxiMask(const char* data) -{ - Tokens tokens = StrSplit(data, " "); - - int index; - Tokens::iterator iter; - for (iter = tokens.begin(), index = 0; - (index < TaxiMaskSize) && (iter != tokens.end()); ++iter, ++index) - { - // load and set bits only for existed taxi nodes - m_taximask[index] = sTaxiNodesMask[index] & uint32(atol((*iter).c_str())); - } -} - -void PlayerTaxi::AppendTaximaskTo( ByteBuffer& data, bool all ) -{ - if(all) - { - for (uint8 i=0; ic_str())); - AddTaxiDestination(node); - } - - if(m_TaxiDestinations.empty()) - return true; - - // Check integrity - if(m_TaxiDestinations.size() < 2) - return false; - - for(size_t i = 1; i < m_TaxiDestinations.size(); ++i) - { - uint32 cost; - uint32 path; - objmgr.GetTaxiPath(m_TaxiDestinations[i-1],m_TaxiDestinations[i],path,cost); - if(!path) - return false; - } - - return true; -} - -std::string PlayerTaxi::SaveTaxiDestinationsToString() -{ - if(m_TaxiDestinations.empty()) - return ""; - - std::ostringstream ss; - - for(size_t i=0; i < m_TaxiDestinations.size(); ++i) - ss << m_TaxiDestinations[i] << " "; - - return ss.str(); -} - -uint32 PlayerTaxi::GetCurrentTaxiPath() const -{ - if(m_TaxiDestinations.size() < 2) - return 0; - - uint32 path; - uint32 cost; - - objmgr.GetTaxiPath(m_TaxiDestinations[0],m_TaxiDestinations[1],path,cost); - - return path; -} - -//== Player ==================================================== - -const int32 Player::ReputationRank_Length[MAX_REPUTATION_RANK] = {36000, 3000, 3000, 3000, 6000, 12000, 21000, 1000}; - -UpdateMask Player::updateVisualBits; - -Player::Player (WorldSession *session): Unit() -{ - m_transport = 0; - - m_speakTime = 0; - m_speakCount = 0; - - m_objectType |= TYPEMASK_PLAYER; - m_objectTypeId = TYPEID_PLAYER; - - m_valuesCount = PLAYER_END; - - m_session = session; - - m_divider = 0; - - m_ExtraFlags = 0; - if(GetSession()->GetSecurity() >= SEC_GAMEMASTER) - SetAcceptTicket(true); - - // players always and GM if set in config accept whispers by default - if(GetSession()->GetSecurity() == SEC_PLAYER || sWorld.getConfig(CONFIG_GM_WISPERING_TO)) - SetAcceptWhispers(true); - - m_curSelection = 0; - m_lootGuid = 0; - - m_comboTarget = 0; - m_comboPoints = 0; - - m_usedTalentCount = 0; - - m_regenTimer = 0; - m_weaponChangeTimer = 0; - - m_zoneUpdateId = 0; - m_zoneUpdateTimer = 0; - - m_areaUpdateId = 0; - - m_nextSave = sWorld.getConfig(CONFIG_INTERVAL_SAVE); - - // randomize first save time in range [CONFIG_INTERVAL_SAVE] around [CONFIG_INTERVAL_SAVE] - // this must help in case next save after mass player load after server startup - m_nextSave = urand(m_nextSave/2,m_nextSave*3/2); - - clearResurrectRequestData(); - - m_SpellModRemoveCount = 0; - - memset(m_items, 0, sizeof(Item*)*PLAYER_SLOTS_COUNT); - - m_social = NULL; - - // group is initialized in the reference constructor - SetGroupInvite(NULL); - m_groupUpdateMask = 0; - m_auraUpdateMask = 0; - - duel = NULL; - - m_GuildIdInvited = 0; - m_ArenaTeamIdInvited = 0; - - m_atLoginFlags = AT_LOGIN_NONE; - - m_dontMove = false; - - pTrader = 0; - ClearTrade(); - - m_cinematic = 0; - - PlayerTalkClass = new PlayerMenu( GetSession() ); - m_currentBuybackSlot = BUYBACK_SLOT_START; - - for ( int aX = 0 ; aX < 8 ; aX++ ) - m_Tutorials[ aX ] = 0x00; - m_TutorialsChanged = false; - - m_DailyQuestChanged = false; - m_lastDailyQuestTime = 0; - - m_regenTimer = 0; - m_weaponChangeTimer = 0; - m_breathTimer = 0; - m_isunderwater = 0; - m_isInWater = false; - m_drunkTimer = 0; - m_drunk = 0; - m_restTime = 0; - m_deathTimer = 0; - m_deathExpireTime = 0; - - m_swingErrorMsg = 0; - - m_DetectInvTimer = 1000; - - m_bgBattleGroundID = 0; - for (int j=0; j < PLAYER_MAX_BATTLEGROUND_QUEUES; j++) - { - m_bgBattleGroundQueueID[j].bgType = 0; - m_bgBattleGroundQueueID[j].invited = false; - } - m_bgTeam = 0; - - m_logintime = time(NULL); - m_Last_tick = m_logintime; - m_WeaponProficiency = 0; - m_ArmorProficiency = 0; - m_canParry = false; - m_canDualWield = false; - m_ammoDPS = 0.0f; - - m_temporaryUnsummonedPetNumber = 0; - //cache for UNIT_CREATED_BY_SPELL to allow - //returning reagests for temporarily removed pets - //when dying/logging out - m_oldpetspell = 0; - - ////////////////////Rest System///////////////////// - time_inn_enter=0; - inn_pos_mapid=0; - inn_pos_x=0; - inn_pos_y=0; - inn_pos_z=0; - m_rest_bonus=0; - rest_type=REST_TYPE_NO; - ////////////////////Rest System///////////////////// - - m_mailsLoaded = false; - m_mailsUpdated = false; - unReadMails = 0; - m_nextMailDelivereTime = 0; - - m_resetTalentsCost = 0; - m_resetTalentsTime = 0; - m_itemUpdateQueueBlocked = false; - - for (int i = 0; i < MAX_MOVE_TYPE; ++i) - m_forced_speed_changes[i] = 0; - - m_stableSlots = 0; - - /////////////////// Instance System ///////////////////// - - m_HomebindTimer = 0; - m_InstanceValid = true; - m_dungeonDifficulty = DIFFICULTY_NORMAL; - - for (int i = 0; i < BASEMOD_END; i++) - { - m_auraBaseMod[i][FLAT_MOD] = 0.0f; - m_auraBaseMod[i][PCT_MOD] = 1.0f; - } - - // Honor System - m_lastHonorUpdateTime = time(NULL); - - // Player summoning - m_summon_expire = 0; - m_summon_mapid = 0; - m_summon_x = 0.0f; - m_summon_y = 0.0f; - m_summon_z = 0.0f; - - //Default movement to run mode - m_unit_movement_flags = 0; - - m_miniPet = 0; - m_bgAfkReportedTimer = 0; - m_contestedPvPTimer = 0; - - m_declinedname = NULL; -} - -Player::~Player () -{ - CleanupsBeforeDelete(); - - if(m_uint32Values) // only for fully created Object - { - sSocialMgr.RemovePlayerSocial(GetGUIDLow()); - } - - // Note: buy back item already deleted from DB when player was saved - for(int i = 0; i < PLAYER_SLOTS_COUNT; ++i) - { - if(m_items[i]) - delete m_items[i]; - } - CleanupChannels(); - - for (PlayerSpellMap::const_iterator itr = m_spells.begin(); itr != m_spells.end(); ++itr) - delete itr->second; - - //all mailed items should be deleted, also all mail should be deallocated - for (PlayerMails::iterator itr = m_mail.begin(); itr != m_mail.end();++itr) - delete *itr; - - for (ItemMap::iterator iter = mMitems.begin(); iter != mMitems.end(); ++iter) - delete iter->second; //if item is duplicated... then server may crash ... but that item should be deallocated - - delete PlayerTalkClass; - - if (m_transport) - { - m_transport->RemovePassenger(this); - } - - for(size_t x = 0; x < ItemSetEff.size(); x++) - if(ItemSetEff[x]) - delete ItemSetEff[x]; - - // clean up player-instance binds, may unload some instance saves - for(uint8 i = 0; i < TOTAL_DIFFICULTIES; i++) - for(BoundInstancesMap::iterator itr = m_boundInstances[i].begin(); itr != m_boundInstances[i].end(); ++itr) - itr->second.save->RemovePlayer(this); - - delete m_declinedname; -} - -void Player::CleanupsBeforeDelete() -{ - if(m_uint32Values) // only for fully created Object - { - TradeCancel(false); - DuelComplete(DUEL_INTERUPTED); - } - Unit::CleanupsBeforeDelete(); -} - -bool Player::Create( uint32 guidlow, std::string name, uint8 race, uint8 class_, uint8 gender, uint8 skin, uint8 face, uint8 hairStyle, uint8 hairColor, uint8 facialHair, uint8 outfitId ) -{ - Object::_Create(guidlow, 0, HIGHGUID_PLAYER); - - m_name = name; - - PlayerInfo const* info = objmgr.GetPlayerInfo(race, class_); - if(!info) - { - sLog.outError("Player have incorrect race/class pair. Can't be loaded."); - return false; - } - - for (int i = 0; i < PLAYER_SLOTS_COUNT; i++) - m_items[i] = NULL; - - //for(int j = BUYBACK_SLOT_START; j < BUYBACK_SLOT_END; j++) - //{ - // SetUInt64Value(PLAYER_FIELD_VENDORBUYBACK_SLOT_1+j*2,0); - // SetUInt32Value(PLAYER_FIELD_BUYBACK_PRICE_1+j,0); - // SetUInt32Value(PLAYER_FIELD_BUYBACK_TIMESTAMP_1+j,0); - //} - - m_race = race; - m_class = class_; - - SetMapId(info->mapId); - Relocate(info->positionX,info->positionY,info->positionZ); - - ChrClassesEntry const* cEntry = sChrClassesStore.LookupEntry(class_); - if(!cEntry) - { - sLog.outError("Class %u not found in DBC (Wrong DBC files?)",class_); - return false; - } - - uint8 powertype = cEntry->powerType; - - uint32 unitfield; - - switch(powertype) - { - case POWER_ENERGY: - case POWER_MANA: - unitfield = 0x00000000; - break; - case POWER_RAGE: - unitfield = 0x00110000; - break; - default: - sLog.outError("Invalid default powertype %u for player (class %u)",powertype,class_); - return false; - } - - SetFloatValue(UNIT_FIELD_BOUNDINGRADIUS, DEFAULT_WORLD_OBJECT_SIZE ); - SetFloatValue(UNIT_FIELD_COMBATREACH, 1.5f ); - - switch(gender) - { - case GENDER_FEMALE: - SetDisplayId(info->displayId_f ); - SetNativeDisplayId(info->displayId_f ); - break; - case GENDER_MALE: - SetDisplayId(info->displayId_m ); - SetNativeDisplayId(info->displayId_m ); - break; - default: - sLog.outError("Invalid gender %u for player",gender); - return false; - break; - } - - setFactionForRace(m_race); - - SetUInt32Value(UNIT_FIELD_BYTES_0, ( ( race ) | ( class_ << 8 ) | ( gender << 16 ) | ( powertype << 24 ) ) ); - SetUInt32Value(UNIT_FIELD_BYTES_1, unitfield); - SetByteValue(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_UNK3 | UNIT_BYTE2_FLAG_UNK5 ); - SetUInt32Value(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE ); - SetFloatValue(UNIT_MOD_CAST_SPEED, 1.0f); // fix cast time showed in spell tooltip on client - - //-1 is default value - SetUInt32Value(PLAYER_FIELD_WATCHED_FACTION_INDEX, uint32(-1)); - - SetUInt32Value(PLAYER_BYTES, (skin | (face << 8) | (hairStyle << 16) | (hairColor << 24))); - SetUInt32Value(PLAYER_BYTES_2, (facialHair | (0x00 << 8) | (0x00 << 16) | (0x02 << 24))); - SetByteValue(PLAYER_BYTES_3, 0, gender); - - SetUInt32Value( PLAYER_GUILDID, 0 ); - SetUInt32Value( PLAYER_GUILDRANK, 0 ); - SetUInt32Value( PLAYER_GUILD_TIMESTAMP, 0 ); - - SetUInt64Value( PLAYER__FIELD_KNOWN_TITLES, 0 ); // 0=disabled - SetUInt32Value( PLAYER_CHOSEN_TITLE, 0 ); - SetUInt32Value( PLAYER_FIELD_KILLS, 0 ); - SetUInt32Value( PLAYER_FIELD_LIFETIME_HONORBALE_KILLS, 0 ); - SetUInt32Value( PLAYER_FIELD_TODAY_CONTRIBUTION, 0 ); - SetUInt32Value( PLAYER_FIELD_YESTERDAY_CONTRIBUTION, 0 ); - - // set starting level - SetUInt32Value( UNIT_FIELD_LEVEL, sWorld.getConfig(CONFIG_START_PLAYER_LEVEL) ); - - // Played time - m_Last_tick = time(NULL); - m_Played_time[0] = 0; - m_Played_time[1] = 0; - - // base stats and related field values - InitStatsForLevel(); - InitTaxiNodesForLevel(); - InitTalentForLevel(); - InitPrimaryProffesions(); // to max set before any spell added - - // apply original stats mods before spell loading or item equipment that call before equip _RemoveStatsMods() - UpdateMaxHealth(); // Update max Health (for add bonus from stamina) - SetHealth(GetMaxHealth()); - if (getPowerType()==POWER_MANA) - { - UpdateMaxPower(POWER_MANA); // Update max Mana (for add bonus from intelect) - SetPower(POWER_MANA,GetMaxPower(POWER_MANA)); - } - - learnDefaultSpells(true); - - std::list::const_iterator action_itr[4]; - for(int i=0; i<4; i++) - action_itr[i] = info->action[i].begin(); - - for (; action_itr[0]!=info->action[0].end() && action_itr[1]!=info->action[1].end();) - { - uint16 taction[4]; - for(int i=0; i<4 ;i++) - taction[i] = (*action_itr[i]); - - addActionButton((uint8)taction[0], taction[1], (uint8)taction[2], (uint8)taction[3]); - - for(int i=0; i<4 ;i++) - ++action_itr[i]; - } - - UpdateBlockPercentage(); - - for (PlayerCreateInfoItems::const_iterator item_id_itr = info->item.begin(); item_id_itr!=info->item.end(); ++item_id_itr++) - { - uint32 titem_id = item_id_itr->item_id; - uint32 titem_amount = item_id_itr->item_amount; - - sLog.outDebug("STORAGE: Creating initial item, itemId = %u, count = %u",titem_id, titem_amount); - - // attempt equip - uint16 eDest; - uint8 msg = CanEquipNewItem( NULL_SLOT, eDest, titem_id, titem_amount, false ); - if( msg == EQUIP_ERR_OK ) - { - EquipNewItem( eDest, titem_id, titem_amount, true); - AutoUnequipOffhandIfNeed(); - continue; // equipped, to next - } - - // attempt store - ItemPosCountVec sDest; - // store in main bag to simplify second pass (special bags can be not equipped yet at this moment) - msg = CanStoreNewItem( INVENTORY_SLOT_BAG_0, NULL_SLOT, sDest, titem_id, titem_amount ); - if( msg == EQUIP_ERR_OK ) - { - StoreNewItem( sDest, titem_id, true, Item::GenerateItemRandomPropertyId(titem_id) ); - continue; // stored, to next - } - - // item can't be added - sLog.outError("STORAGE: Can't equip or store initial item %u for race %u class %u , error msg = %u",titem_id,race,class_,msg); - } - - // bags and main-hand weapon must equipped at this moment - // now second pass for not equipped (offhand weapon/shield if it attempt equipped before main-hand weapon) - // or ammo not equipped in special bag - for(int i = INVENTORY_SLOT_ITEM_START; i < INVENTORY_SLOT_ITEM_END; i++) - { - if(Item* pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i )) - { - uint16 eDest; - // equip offhand weapon/shield if it attempt equipped before main-hand weapon - uint8 msg = CanEquipItem( NULL_SLOT, eDest, pItem, false ); - if( msg == EQUIP_ERR_OK ) - { - RemoveItem(INVENTORY_SLOT_BAG_0, i,true); - EquipItem( eDest, pItem, true); - } - // move other items to more appropriate slots (ammo not equipped in special bag) - else - { - ItemPosCountVec sDest; - msg = CanStoreItem( NULL_BAG, NULL_SLOT, sDest, pItem, false ); - if( msg == EQUIP_ERR_OK ) - { - RemoveItem(INVENTORY_SLOT_BAG_0, i,true); - pItem = StoreItem( sDest, pItem, true); - } - - // if this is ammo then use it - uint8 msg = CanUseAmmo( pItem->GetProto()->ItemId ); - if( msg == EQUIP_ERR_OK ) - SetAmmo( pItem->GetProto()->ItemId ); - } - } - } - // all item positions resolved - - return true; -} - -void Player::StartMirrorTimer(MirrorTimerType Type, uint32 MaxValue) -{ - uint32 BreathRegen = (uint32)-1; - - WorldPacket data(SMSG_START_MIRROR_TIMER, (21)); - data << (uint32)Type; - data << MaxValue; - data << MaxValue; - data << BreathRegen; - data << (uint8)0; - data << (uint32)0; // spell id - GetSession()->SendPacket(&data); -} - -void Player::ModifyMirrorTimer(MirrorTimerType Type, uint32 MaxValue, uint32 CurrentValue, uint32 Regen) -{ - if(Type==BREATH_TIMER) - m_breathTimer = ((MaxValue + 1000) - CurrentValue) / Regen; - - WorldPacket data(SMSG_START_MIRROR_TIMER, (21)); - data << (uint32)Type; - data << CurrentValue; - data << MaxValue; - data << Regen; - data << (uint8)0; - data << (uint32)0; // spell id - GetSession()->SendPacket( &data ); -} - -void Player::StopMirrorTimer(MirrorTimerType Type) -{ - if(Type==BREATH_TIMER) - m_breathTimer = 0; - - WorldPacket data(SMSG_STOP_MIRROR_TIMER, 4); - data << (uint32)Type; - GetSession()->SendPacket( &data ); -} - -void Player::EnvironmentalDamage(uint64 guid, EnviromentalDamage type, uint32 damage) -{ - WorldPacket data(SMSG_ENVIRONMENTALDAMAGELOG, (21)); - data << (uint64)guid; - data << (uint8)(type!=DAMAGE_FALL_TO_VOID ? type : DAMAGE_FALL); - data << (uint32)damage; - data << (uint32)0; - data << (uint32)0; - //m_session->SendPacket(&data); - //Let other players see that you get damage - SendMessageToSet(&data, true); - DealDamage(this, damage, NULL, SELF_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); - - if(type==DAMAGE_FALL && !isAlive()) // DealDamage not apply item durability loss at self damage - { - DEBUG_LOG("We are fall to death, loosing 10 percents durability"); - DurabilityLossAll(0.10f,false); - // durability lost message - WorldPacket data(SMSG_DURABILITY_DAMAGE_DEATH, 0); - GetSession()->SendPacket(&data); - } -} - -void Player::HandleDrowning() -{ - if(!m_isunderwater) - return; - - //if have water breath , then remove bar - if(waterbreath || isGameMaster() || !isAlive()) - { - StopMirrorTimer(BREATH_TIMER); - m_isunderwater = 0; - return; - } - - uint32 UnderWaterTime = 1*MINUTE*1000; // default leangthL 1 min - - AuraList const& mModWaterBreathing = GetAurasByType(SPELL_AURA_MOD_WATER_BREATHING); - for(AuraList::const_iterator i = mModWaterBreathing.begin(); i != mModWaterBreathing.end(); ++i) - UnderWaterTime = uint32(UnderWaterTime * (100.0f + (*i)->GetModifier()->m_amount) / 100.0f); - - if ((m_isunderwater & 0x01) && !(m_isunderwater & 0x80) && isAlive()) - { - //single trigger timer - if (!(m_isunderwater & 0x02)) - { - m_isunderwater|= 0x02; - m_breathTimer = UnderWaterTime + 1000; - } - //single trigger "Breathbar" - if ( m_breathTimer <= UnderWaterTime && !(m_isunderwater & 0x04)) - { - m_isunderwater|= 0x04; - StartMirrorTimer(BREATH_TIMER, UnderWaterTime); - } - //continius trigger drowning "Damage" - if ((m_breathTimer == 0) && (m_isunderwater & 0x01)) - { - //TODO: Check this formula - uint64 guid = GetGUID(); - uint32 damage = GetMaxHealth() / 5 + urand(0, getLevel()-1); - - EnvironmentalDamage(guid, DAMAGE_DROWNING,damage); - m_breathTimer = 2000; - } - } - //single trigger retract bar - else if (!(m_isunderwater & 0x01) && !(m_isunderwater & 0x08) && (m_isunderwater & 0x02) && (m_breathTimer > 0) && isAlive()) - { - m_isunderwater = 0x08; - - uint32 BreathRegen = 10; - ModifyMirrorTimer(BREATH_TIMER, UnderWaterTime, m_breathTimer,BreathRegen); - m_isunderwater = 0x10; - } - //remove bar - else if ((m_breathTimer < 50) && !(m_isunderwater & 0x01) && (m_isunderwater == 0x10)) - { - StopMirrorTimer(BREATH_TIMER); - m_isunderwater = 0; - } -} - -void Player::HandleLava() -{ - bool ValidArea = false; - - if ((m_isunderwater & 0x80) && isAlive()) - { - //Single trigger Set BreathTimer - if (!(m_isunderwater & 0x80)) - { - m_isunderwater|= 0x04; - m_breathTimer = 1000; - } - //Reset BreathTimer and still in the lava - if (!m_breathTimer) - { - uint64 guid = GetGUID(); - uint32 damage = urand(600, 700); // TODO: Get more detailed information about lava damage - uint32 dmgZone = GetZoneId(); // TODO: Find correct "lava dealing zone" flag in Area Table - - // Deal lava damage only in lava zones. - switch(dmgZone) - { - case 0x8D: - ValidArea = false; - break; - case 0x94: - ValidArea = false; - break; - case 0x2CE: - ValidArea = false; - break; - case 0x2CF: - ValidArea = false; - break; - default: - if (dmgZone / 5 & 0x408) - ValidArea = true; - } - - // if is valid area and is not gamemaster then deal damage - if ( ValidArea && !isGameMaster() ) - EnvironmentalDamage(guid, DAMAGE_LAVA, damage); - - m_breathTimer = 1000; - } - - } - //Death timer disabled and WaterFlags reset - else if (m_deathState == DEAD) - { - m_breathTimer = 0; - m_isunderwater = 0; - } -} - -///The player sobers by 256 every 10 seconds -void Player::HandleSobering() -{ - m_drunkTimer = 0; - - uint32 drunk = (m_drunk <= 256) ? 0 : (m_drunk - 256); - SetDrunkValue(drunk); -} - -DrunkenState Player::GetDrunkenstateByValue(uint16 value) -{ - if(value >= 23000) - return DRUNKEN_SMASHED; - if(value >= 12800) - return DRUNKEN_DRUNK; - if(value & 0xFFFE) - return DRUNKEN_TIPSY; - return DRUNKEN_SOBER; -} - -void Player::SetDrunkValue(uint16 newDrunkenValue, uint32 itemId) -{ - uint32 oldDrunkenState = Player::GetDrunkenstateByValue(m_drunk); - - m_drunk = newDrunkenValue; - SetUInt32Value(PLAYER_BYTES_3,(GetUInt32Value(PLAYER_BYTES_3) & 0xFFFF0001) | (m_drunk & 0xFFFE)); - - uint32 newDrunkenState = Player::GetDrunkenstateByValue(m_drunk); - - // special drunk invisibility detection - if(newDrunkenState >= DRUNKEN_DRUNK) - m_detectInvisibilityMask |= (1<<6); - else - m_detectInvisibilityMask &= ~(1<<6); - - if(newDrunkenState == oldDrunkenState) - return; - - WorldPacket data(SMSG_CROSSED_INEBRIATION_THRESHOLD, (8+4+4)); - data << GetGUID(); - data << uint32(newDrunkenState); - data << uint32(itemId); - - SendMessageToSet(&data, true); -} - -void Player::Update( uint32 p_time ) -{ - if(!IsInWorld()) - return; - - // undelivered mail - if(m_nextMailDelivereTime && m_nextMailDelivereTime <= time(NULL)) - { - SendNewMail(); - ++unReadMails; - - // It will be recalculate at mailbox open (for unReadMails important non-0 until mailbox open, it also will be recalculated) - m_nextMailDelivereTime = 0; - } - - Unit::Update( p_time ); - - // update player only attacks - if(uint32 ranged_att = getAttackTimer(RANGED_ATTACK)) - { - setAttackTimer(RANGED_ATTACK, (p_time >= ranged_att ? 0 : ranged_att - p_time) ); - } - - if(uint32 off_att = getAttackTimer(OFF_ATTACK)) - { - setAttackTimer(OFF_ATTACK, (p_time >= off_att ? 0 : off_att - p_time) ); - } - - time_t now = time (NULL); - - UpdatePvPFlag(now); - - UpdateContestedPvP(p_time); - - UpdateDuelFlag(now); - - CheckDuelDistance(now); - - UpdateAfkReport(now); - - CheckExploreSystem(); - - // Update items that have just a limited lifetime - if (now>m_Last_tick) - UpdateItemDuration(uint32(now- m_Last_tick)); - - if (!m_timedquests.empty()) - { - std::set::iterator iter = m_timedquests.begin(); - while (iter != m_timedquests.end()) - { - QuestStatusData& q_status = mQuestStatus[*iter]; - if( q_status.m_timer <= p_time ) - { - uint32 quest_id = *iter; - ++iter; // current iter will be removed in FailTimedQuest - FailTimedQuest( quest_id ); - } - else - { - q_status.m_timer -= p_time; - if (q_status.uState != QUEST_NEW) q_status.uState = QUEST_CHANGED; - ++iter; - } - } - } - - if (hasUnitState(UNIT_STAT_MELEE_ATTACKING)) - { - Unit *pVictim = getVictim(); - if( !IsNonMeleeSpellCasted(false) && pVictim) - { - // default combat reach 10 - // TODO add weapon,skill check - - float pldistance = ATTACK_DISTANCE; - - if (isAttackReady(BASE_ATTACK)) - { - if(!IsWithinDistInMap(pVictim, pldistance)) - { - setAttackTimer(BASE_ATTACK,100); - if(m_swingErrorMsg != 1) // send single time (client auto repeat) - { - SendAttackSwingNotInRange(); - m_swingErrorMsg = 1; - } - } - //120 degrees of radiant range - else if( !HasInArc( 2*M_PI/3, pVictim )) - { - setAttackTimer(BASE_ATTACK,100); - if(m_swingErrorMsg != 2) // send single time (client auto repeat) - { - SendAttackSwingBadFacingAttack(); - m_swingErrorMsg = 2; - } - } - else - { - m_swingErrorMsg = 0; // reset swing error state - - // prevent base and off attack in same time, delay attack at 0.2 sec - if(haveOffhandWeapon()) - { - uint32 off_att = getAttackTimer(OFF_ATTACK); - if(off_att < ATTACK_DISPLAY_DELAY) - setAttackTimer(OFF_ATTACK,ATTACK_DISPLAY_DELAY); - } - AttackerStateUpdate(pVictim, BASE_ATTACK); - resetAttackTimer(BASE_ATTACK); - } - } - - if ( haveOffhandWeapon() && isAttackReady(OFF_ATTACK)) - { - if(!IsWithinDistInMap(pVictim, pldistance)) - { - setAttackTimer(OFF_ATTACK,100); - } - else if( !HasInArc( 2*M_PI/3, pVictim )) - { - setAttackTimer(OFF_ATTACK,100); - } - else - { - // prevent base and off attack in same time, delay attack at 0.2 sec - uint32 base_att = getAttackTimer(BASE_ATTACK); - if(base_att < ATTACK_DISPLAY_DELAY) - setAttackTimer(BASE_ATTACK,ATTACK_DISPLAY_DELAY); - // do attack - AttackerStateUpdate(pVictim, OFF_ATTACK); - resetAttackTimer(OFF_ATTACK); - } - } - - Unit *owner = pVictim->GetOwner(); - Unit *u = owner ? owner : pVictim; - if(u->IsPvP() && (!duel || duel->opponent != u)) - { - UpdatePvP(true); - RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_ENTER_PVP_COMBAT); - } - } - } - - if(HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_RESTING)) - { - if(roll_chance_i(3) && GetTimeInnEnter() > 0) //freeze update - { - int time_inn = time(NULL)-GetTimeInnEnter(); - if (time_inn >= 10) //freeze update - { - float bubble = 0.125*sWorld.getRate(RATE_REST_INGAME); - //speed collect rest bonus (section/in hour) - SetRestBonus( GetRestBonus()+ time_inn*((float)GetUInt32Value(PLAYER_NEXT_LEVEL_XP)/72000)*bubble ); - UpdateInnerTime(time(NULL)); - } - } - } - - if(m_regenTimer > 0) - { - if(p_time >= m_regenTimer) - m_regenTimer = 0; - else - m_regenTimer -= p_time; - } - - if (m_weaponChangeTimer > 0) - { - if(p_time >= m_weaponChangeTimer) - m_weaponChangeTimer = 0; - else - m_weaponChangeTimer -= p_time; - } - - if (m_zoneUpdateTimer > 0) - { - if(p_time >= m_zoneUpdateTimer) - { - uint32 newzone = GetZoneId(); - if( m_zoneUpdateId != newzone ) - UpdateZone(newzone); // also update area - else - { - // use area updates as well - // needed for free far all arenas for example - uint32 newarea = GetAreaId(); - if( m_areaUpdateId != newarea ) - UpdateArea(newarea); - - m_zoneUpdateTimer = ZONE_UPDATE_INTERVAL; - } - } - else - m_zoneUpdateTimer -= p_time; - } - - if (isAlive()) - { - RegenerateAll(); - } - - if (m_deathState == JUST_DIED) - { - KillPlayer(); - } - - if(m_nextSave > 0) - { - if(p_time >= m_nextSave) - { - // m_nextSave reseted in SaveToDB call - SaveToDB(); - sLog.outDetail("Player '%s' (GUID: %u) saved", GetName(), GetGUIDLow()); - } - else - { - m_nextSave -= p_time; - } - } - - //Breathtimer - if(m_breathTimer > 0) - { - if(p_time >= m_breathTimer) - m_breathTimer = 0; - else - m_breathTimer -= p_time; - - } - - //Handle Water/drowning - HandleDrowning(); - - //Handle lava - HandleLava(); - - //Handle detect stealth players - if (m_DetectInvTimer > 0) - { - if (p_time >= m_DetectInvTimer) - { - m_DetectInvTimer = 3000; - HandleStealthedUnitsDetection(); - } - else - m_DetectInvTimer -= p_time; - } - - // Played time - if (now > m_Last_tick) - { - uint32 elapsed = uint32(now - m_Last_tick); - m_Played_time[0] += elapsed; // Total played time - m_Played_time[1] += elapsed; // Level played time - m_Last_tick = now; - } - - if (m_drunk) - { - m_drunkTimer += p_time; - - if (m_drunkTimer > 10000) - HandleSobering(); - } - - // not auto-free ghost from body in instances - if(m_deathTimer > 0 && !GetBaseMap()->Instanceable()) - { - if(p_time >= m_deathTimer) - { - m_deathTimer = 0; - BuildPlayerRepop(); - RepopAtGraveyard(); - } - else - m_deathTimer -= p_time; - } - - UpdateEnchantTime(p_time); - UpdateHomebindTime(p_time); - - // group update - SendUpdateToOutOfRangeGroupMembers(); - - Pet* pet = GetPet(); - if(pet && !IsWithinDistInMap(pet, OWNER_MAX_DISTANCE)) - { - RemovePet(pet, PET_SAVE_NOT_IN_SLOT, true); - return; - } -} - -void Player::setDeathState(DeathState s) -{ - uint32 ressSpellId = 0; - - bool cur = isAlive(); - - if(s == JUST_DIED && cur) - { - // drunken state is cleared on death - SetDrunkValue(0); - // lost combo points at any target (targeted combo points clear in Unit::setDeathState) - ClearComboPoints(); - - clearResurrectRequestData(); - - // remove form before other mods to prevent incorrect stats calculation - RemoveAurasDueToSpell(m_ShapeShiftFormSpellId); - - //FIXME: is pet dismissed at dying or releasing spirit? if second, add setDeathState(DEAD) to HandleRepopRequestOpcode and define pet unsummon here with (s == DEAD) - RemovePet(NULL, PET_SAVE_NOT_IN_SLOT, true); - - // remove uncontrolled pets - RemoveMiniPet(); - RemoveGuardians(); - - // save value before aura remove in Unit::setDeathState - ressSpellId = GetUInt32Value(PLAYER_SELF_RES_SPELL); - - // passive spell - if(!ressSpellId) - ressSpellId = GetResurrectionSpellId(); - } - Unit::setDeathState(s); - - // restore resurrection spell id for player after aura remove - if(s == JUST_DIED && cur && ressSpellId) - SetUInt32Value(PLAYER_SELF_RES_SPELL, ressSpellId); - - if(isAlive() && !cur) - { - //clear aura case after resurrection by another way (spells will be applied before next death) - SetUInt32Value(PLAYER_SELF_RES_SPELL, 0); - - // restore default warrior stance - if(getClass()== CLASS_WARRIOR) - CastSpell(this,SPELL_ID_PASSIVE_BATTLE_STANCE,true); - } -} - -void Player::BuildEnumData( QueryResult * result, WorldPacket * p_data ) -{ - *p_data << GetGUID(); - *p_data << m_name; - - *p_data << getRace(); - uint8 pClass = getClass(); - *p_data << pClass; - *p_data << getGender(); - - uint32 bytes = GetUInt32Value(PLAYER_BYTES); - *p_data << uint8(bytes); - *p_data << uint8(bytes >> 8); - *p_data << uint8(bytes >> 16); - *p_data << uint8(bytes >> 24); - - bytes = GetUInt32Value(PLAYER_BYTES_2); - *p_data << uint8(bytes); - - *p_data << uint8(getLevel()); // player level - // do not use GetMap! it will spawn a new instance since the bound instances are not loaded - uint32 zoneId = MapManager::Instance().GetZoneId(GetMapId(), GetPositionX(),GetPositionY()); - - *p_data << zoneId; - *p_data << GetMapId(); - - *p_data << GetPositionX(); - *p_data << GetPositionY(); - *p_data << GetPositionZ(); - - *p_data << GetUInt32Value(PLAYER_GUILDID); // guild id - - uint32 char_flags = 0; - if(HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_HIDE_HELM)) - char_flags |= CHARACTER_FLAG_HIDE_HELM; - if(HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_HIDE_CLOAK)) - char_flags |= CHARACTER_FLAG_HIDE_CLOAK; - if(HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_GHOST)) - char_flags |= CHARACTER_FLAG_GHOST; - if(HasAtLoginFlag(AT_LOGIN_RENAME)) - char_flags |= CHARACTER_FLAG_RENAME; - // always send the flag if declined names aren't used - // to let the client select a default method of declining the name - if(!sWorld.getConfig(CONFIG_DECLINED_NAMES_USED) || (result && result->Fetch()[12].GetCppString() != "")) - char_flags |= CHARACTER_FLAG_DECLINED; - - *p_data << (uint32)char_flags; // character flags - - *p_data << (uint8)1; // unknown - - // Pets info - { - uint32 petDisplayId = 0; - uint32 petLevel = 0; - uint32 petFamily = 0; - - // show pet at selection character in character list only for non-ghost character - if(result && isAlive() && (pClass == CLASS_WARLOCK || pClass == CLASS_HUNTER)) - { - Field* fields = result->Fetch(); - - uint32 entry = fields[9].GetUInt32(); - CreatureInfo const* cInfo = sCreatureStorage.LookupEntry(entry); - if(cInfo) - { - petDisplayId = fields[10].GetUInt32(); - petLevel = fields[11].GetUInt32(); - petFamily = cInfo->family; - } - } - - *p_data << (uint32)petDisplayId; - *p_data << (uint32)petLevel; - *p_data << (uint32)petFamily; - } - - /*ItemPrototype const *items[EQUIPMENT_SLOT_END]; - for (int i = 0; i < EQUIPMENT_SLOT_END; i++) - items[i] = NULL; - - QueryResult *result = CharacterDatabase.PQuery("SELECT slot,item_template FROM character_inventory WHERE guid = '%u' AND bag = 0",GetGUIDLow()); - if (result) - { - do - { - Field *fields = result->Fetch(); - uint8 slot = fields[0].GetUInt8() & 255; - uint32 item_id = fields[1].GetUInt32(); - if( slot >= EQUIPMENT_SLOT_END ) - continue; - - items[slot] = objmgr.GetItemPrototype(item_id); - if(!items[slot]) - { - sLog.outError( "Player::BuildEnumData: Player %s have unknown item (id: #%u) in inventory, skipped.", GetName(),item_id ); - continue; - } - } while (result->NextRow()); - delete result; - }*/ - - for (uint8 slot = 0; slot < EQUIPMENT_SLOT_END; slot++) - { - uint32 visualbase = PLAYER_VISIBLE_ITEM_1_0 + (slot * MAX_VISIBLE_ITEM_OFFSET); - uint32 item_id = GetUInt32Value(visualbase); - const ItemPrototype * proto = objmgr.GetItemPrototype(item_id); - SpellItemEnchantmentEntry const *enchant = NULL; - - for(uint8 enchantSlot = PERM_ENCHANTMENT_SLOT; enchantSlot<=TEMP_ENCHANTMENT_SLOT; enchantSlot++) - { - uint32 enchantId = GetUInt32Value(visualbase+1+enchantSlot); - if(enchant = sSpellItemEnchantmentStore.LookupEntry(enchantId)) - break; - } - - if (proto != NULL) - { - *p_data << (uint32)proto->DisplayInfoID; - *p_data << (uint8)proto->InventoryType; - *p_data << (uint32)(enchant?enchant->aura_id:0); - } - else - { - *p_data << (uint32)0; - *p_data << (uint8)0; - *p_data << (uint32)0; // enchant? - } - } - *p_data << (uint32)0; // first bag display id - *p_data << (uint8)0; // first bag inventory type - *p_data << (uint32)0; // enchant? -} - -bool Player::ToggleAFK() -{ - ToggleFlag(PLAYER_FLAGS, PLAYER_FLAGS_AFK); - - bool state = HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_AFK); - - // afk player not allowed in battleground - if(state && InBattleGround()) - LeaveBattleground(); - - return state; -} - -bool Player::ToggleDND() -{ - ToggleFlag(PLAYER_FLAGS, PLAYER_FLAGS_DND); - - return HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_DND); -} - -uint8 Player::chatTag() const -{ - // it's bitmask - // 0x8 - ?? - // 0x4 - gm - // 0x2 - dnd - // 0x1 - afk - if(isGameMaster()) - return 4; - else if(isDND()) - return 3; - if(isAFK()) - return 1; - else - return 0; -} - -bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientation, uint32 options) -{ - if(!MapManager::IsValidMapCoord(mapid, x, y, z, orientation)) - { - sLog.outError("TeleportTo: invalid map %d or absent instance template.", mapid); - return false; - } - - // preparing unsummon pet if lost (we must get pet before teleportation or will not find it later) - Pet* pet = GetPet(); - - MapEntry const* mEntry = sMapStore.LookupEntry(mapid); - - // don't let enter battlegrounds without assigned battleground id (for example through areatrigger)... - if(!InBattleGround() && mEntry->IsBattleGround() && !GetSession()->GetSecurity()) - return false; - - bool tbc = GetSession()->IsTBC() && sWorld.getConfig(CONFIG_EXPANSION) > 0; - - // normal client and TBC map - if(!tbc && mEntry->IsExpansionMap()) - { - sLog.outDebug("Player %s using Normal client and tried teleport to non existing map %u", GetName(), mapid); - - if(GetTransport()) - RepopAtGraveyard(); // teleport to near graveyard if on transport, looks blizz like :) - - SendTransferAborted(mapid, TRANSFER_ABORT_INSUF_EXPAN_LVL1); - - return false; // normal client can't teleport to this map... - } - else if(tbc) // can teleport to any existing map - { - sLog.outDebug("Player %s have TBC client and will teleported to map %u", GetName(), mapid); - } - else - { - sLog.outDebug("Player %s have normal client and will teleported to standard map %u", GetName(), mapid); - } - /* - only TBC (no 0x80000 and 0x10 flags...) - 3604590=0x37006E=0x200000 + 0x100000 + 0x40000 + 0x20000 + 0x10000 + 0x40 + 0x20 + 0x8 + 0x4 + 0x2 - - Kharazan (normal/TBC??), but not have 0x10 flag (accessible by normal client?) - 4128878=0x3F006E=0x200000 + 0x100000 + 0x80000 + 0x40000 + 0x20000 + 0x10000 + 0x40 + 0x20 + 0x8 + 0x4 + 0x2 - - normal+TBC maps - 4128894=0x3F007E=0x200000 + 0x100000 + 0x80000 + 0x40000 + 0x20000 + 0x10000 + 0x40 + 0x20 + 0x10 + 0x8 + 0x4 + 0x2 - - normal+TBC maps - 8323198=0x7F007E=0x400000 + 0x200000 + 0x100000 + 0x80000 + 0x40000 + 0x20000 + 0x10000 + 0x40 + 0x20 + 0x10 + 0x8 + 0x4 + 0x2 - */ - - // if we were on a transport, leave - if (!(options & TELE_TO_NOT_LEAVE_TRANSPORT) && m_transport) - { - m_transport->RemovePassenger(this); - m_transport = NULL; - m_movementInfo.t_x = 0.0f; - m_movementInfo.t_y = 0.0f; - m_movementInfo.t_z = 0.0f; - m_movementInfo.t_o = 0.0f; - m_movementInfo.t_time = 0; - } - - SetSemaphoreTeleport(true); - - // The player was ported to another map and looses the duel immediatly. - // We have to perform this check before the teleport, otherwise the - // ObjectAccessor won't find the flag. - if (duel && this->GetMapId()!=mapid) - { - GameObject* obj = ObjectAccessor::GetGameObject(*this, GetUInt64Value(PLAYER_DUEL_ARBITER)); - if (obj) - DuelComplete(DUEL_FLED); - } - - // reset movement flags at teleport, because player will continue move with these flags after teleport - SetUnitMovementFlags(0); - - if ((this->GetMapId() == mapid) && (!m_transport)) - { - // prepare zone change detect - uint32 old_zone = GetZoneId(); - - // near teleport - if(!GetSession()->PlayerLogout()) - { - WorldPacket data; - BuildTeleportAckMsg(&data, x, y, z, orientation); - GetSession()->SendPacket(&data); - SetPosition( x, y, z, orientation, true); - } - else - // this will be used instead of the current location in SaveToDB - m_teleport_dest = WorldLocation(mapid, x, y, z, orientation); - - //BuildHeartBeatMsg(&data); - //SendMessageToSet(&data, true); - if (!(options & TELE_TO_NOT_UNSUMMON_PET)) - { - //same map, only remove pet if out of range - if(pet && !IsWithinDistInMap(pet, OWNER_MAX_DISTANCE)) - { - if(pet->isControlled() && !pet->isTemporarySummoned() ) - m_temporaryUnsummonedPetNumber = pet->GetCharmInfo()->GetPetNumber(); - else - m_temporaryUnsummonedPetNumber = 0; - - RemovePet(pet, PET_SAVE_NOT_IN_SLOT); - } - } - - if(!(options & TELE_TO_NOT_LEAVE_COMBAT)) - CombatStop(); - - if (!(options & TELE_TO_NOT_UNSUMMON_PET)) - { - // resummon pet - if(pet && m_temporaryUnsummonedPetNumber) - { - Pet* NewPet = new Pet; - if(!NewPet->LoadPetFromDB(this, 0, m_temporaryUnsummonedPetNumber, true)) - delete NewPet; - - m_temporaryUnsummonedPetNumber = 0; - } - } - - SetSemaphoreTeleport(false); - - if(!GetSession()->PlayerLogout()) - UpdateZone(GetZoneId()); - - // new zone - if(old_zone != GetZoneId()) - { - // honorless target - if(pvpInfo.inHostileArea) - CastSpell(this, 2479, true); - } - } - else - { - // far teleport to another map - Map* oldmap = IsInWorld() ? MapManager::Instance().GetMap(GetMapId(), this) : NULL; - // check if we can enter before stopping combat / removing pet / totems / interrupting spells - - // Check enter rights before map getting to avoid creating instance copy for player - // this check not dependent from map instance copy and same for all instance copies of selected map - if (!MapManager::Instance().CanPlayerEnter(mapid, this)) - { - SetSemaphoreTeleport(false); - return false; - } - - // If the map is not created, assume it is possible to enter it. - // It will be created in the WorldPortAck. - Map *map = MapManager::Instance().FindMap(mapid); - if (!map || map->CanEnter(this)) - { - SetSelection(0); - - CombatStop(); - - ResetContestedPvP(); - - // remove player from battleground on far teleport (when changing maps) - if(BattleGround const* bg = GetBattleGround()) - { - // Note: at battleground join battleground id set before teleport - // and we already will found "current" battleground - // just need check that this is targeted map or leave - if(bg->GetMapId() != mapid) - LeaveBattleground(false); // don't teleport to entry point - } - - // remove pet on map change - if (pet) - { - //leaving map -> delete pet right away (doing this later will cause problems) - if(pet->isControlled() && !pet->isTemporarySummoned()) - m_temporaryUnsummonedPetNumber = pet->GetCharmInfo()->GetPetNumber(); - else - m_temporaryUnsummonedPetNumber = 0; - - RemovePet(pet, PET_SAVE_NOT_IN_SLOT); - } - - // remove all dyn objects - RemoveAllDynObjects(); - - // stop spellcasting - // not attempt interrupt teleportation spell at caster teleport - if(!(options & TELE_TO_SPELL)) - if(IsNonMeleeSpellCasted(true)) - InterruptNonMeleeSpells(true); - - if(!GetSession()->PlayerLogout()) - { - // send transfer packets - WorldPacket data(SMSG_TRANSFER_PENDING, (4+4+4)); - data << uint32(mapid); - if (m_transport) - { - data << m_transport->GetEntry() << GetMapId(); - } - GetSession()->SendPacket(&data); - - data.Initialize(SMSG_NEW_WORLD, (20)); - if (m_transport) - { - data << (uint32)mapid << m_movementInfo.t_x << m_movementInfo.t_y << m_movementInfo.t_z << m_movementInfo.t_o; - } - else - { - data << (uint32)mapid << (float)x << (float)y << (float)z << (float)orientation; - } - GetSession()->SendPacket( &data ); - SendSavedInstances(); - - // remove from old map now - if(oldmap) oldmap->Remove(this, false); - } - - // new final coordinates - float final_x = x; - float final_y = y; - float final_z = z; - float final_o = orientation; - - if(m_transport) - { - final_x += m_movementInfo.t_x; - final_y += m_movementInfo.t_y; - final_z += m_movementInfo.t_z; - final_o += m_movementInfo.t_o; - } - - m_teleport_dest = WorldLocation(mapid, final_x, final_y, final_z, final_o); - // if the player is saved before worldportack (at logout for example) - // this will be used instead of the current location in SaveToDB - - RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_CHANGE_MAP); - - // move packet sent by client always after far teleport - // SetPosition(final_x, final_y, final_z, final_o, true); - SetDontMove(true); - - // code for finish transfer to new map called in WorldSession::HandleMoveWorldportAckOpcode at client packet - } - else - return false; - } - return true; -} - -void Player::AddToWorld() -{ - ///- Do not add/remove the player from the object storage - ///- It will crash when updating the ObjectAccessor - ///- The player should only be added when logging in - Unit::AddToWorld(); - - for(int i = PLAYER_SLOT_START; i < PLAYER_SLOT_END; i++) - { - if(m_items[i]) - m_items[i]->AddToWorld(); - } -} - -void Player::RemoveFromWorld() -{ - // cleanup - if(IsInWorld()) - { - ///- Release charmed creatures, unsummon totems and remove pets/guardians - Uncharm(); - UnsummonAllTotems(); - RemoveMiniPet(); - RemoveGuardians(); - } - - for(int i = PLAYER_SLOT_START; i < PLAYER_SLOT_END; i++) - { - if(m_items[i]) - m_items[i]->RemoveFromWorld(); - } - - ///- Do not add/remove the player from the object storage - ///- It will crash when updating the ObjectAccessor - ///- The player should only be removed when logging out - Unit::RemoveFromWorld(); -} - -void Player::RewardRage( uint32 damage, uint32 weaponSpeedHitFactor, bool attacker ) -{ - float addRage; - - float rageconversion = ((0.0091107836 * getLevel()*getLevel())+3.225598133*getLevel())+4.2652911; - - if(attacker) - { - addRage = ((damage/rageconversion*7.5 + weaponSpeedHitFactor)/2); - - // talent who gave more rage on attack - addRage *= 1.0f + GetTotalAuraModifier(SPELL_AURA_MOD_RAGE_FROM_DAMAGE_DEALT) / 100.0f; - } - else - { - addRage = damage/rageconversion*2.5; - - // Berserker Rage effect - if(HasAura(18499,0)) - addRage *= 1.3; - } - - addRage *= sWorld.getRate(RATE_POWER_RAGE_INCOME); - - ModifyPower(POWER_RAGE, uint32(addRage*10)); -} - -void Player::RegenerateAll() -{ - if (m_regenTimer != 0) - return; - uint32 regenDelay = 2000; - - // Not in combat or they have regeneration - if( !isInCombat() || HasAuraType(SPELL_AURA_MOD_REGEN_DURING_COMBAT) || - HasAuraType(SPELL_AURA_MOD_HEALTH_REGEN_IN_COMBAT) || IsPolymorphed() ) - { - RegenerateHealth(); - if (!isInCombat() && !HasAuraType(SPELL_AURA_INTERRUPT_REGEN)) - Regenerate(POWER_RAGE); - } - - Regenerate( POWER_ENERGY ); - - Regenerate( POWER_MANA ); - - m_regenTimer = regenDelay; -} - -void Player::Regenerate(Powers power) -{ - uint32 curValue = GetPower(power); - uint32 maxValue = GetMaxPower(power); - - float addvalue = 0.0f; - - switch (power) - { - case POWER_MANA: - { - bool recentCast = IsUnderLastManaUseEffect(); - float ManaIncreaseRate = sWorld.getRate(RATE_POWER_MANA); - if (recentCast) - { - // Mangos Updates Mana in intervals of 2s, which is correct - addvalue = GetFloatValue(PLAYER_FIELD_MOD_MANA_REGEN_INTERRUPT) * ManaIncreaseRate * 2.00f; - } - else - { - addvalue = GetFloatValue(PLAYER_FIELD_MOD_MANA_REGEN) * ManaIncreaseRate * 2.00f; - } - } break; - case POWER_RAGE: // Regenerate rage - { - float RageDecreaseRate = sWorld.getRate(RATE_POWER_RAGE_LOSS); - addvalue = 30 * RageDecreaseRate; // 3 rage by tick - } break; - case POWER_ENERGY: // Regenerate energy (rogue) - addvalue = 20; - break; - case POWER_FOCUS: - case POWER_HAPPINESS: - break; - } - - // Mana regen calculated in Player::UpdateManaRegen() - // Exist only for POWER_MANA, POWER_ENERGY, POWER_FOCUS auras - if(power != POWER_MANA) - { - AuraList const& ModPowerRegenPCTAuras = GetAurasByType(SPELL_AURA_MOD_POWER_REGEN_PERCENT); - for(AuraList::const_iterator i = ModPowerRegenPCTAuras.begin(); i != ModPowerRegenPCTAuras.end(); ++i) - if ((*i)->GetModifier()->m_miscvalue == power) - addvalue *= ((*i)->GetModifier()->m_amount + 100) / 100.0f; - } - - if (power != POWER_RAGE) - { - curValue += uint32(addvalue); - if (curValue > maxValue) - curValue = maxValue; - } - else - { - if(curValue <= uint32(addvalue)) - curValue = 0; - else - curValue -= uint32(addvalue); - } - SetPower(power, curValue); -} - -void Player::RegenerateHealth() -{ - uint32 curValue = GetHealth(); - uint32 maxValue = GetMaxHealth(); - - if (curValue >= maxValue) return; - - float HealthIncreaseRate = sWorld.getRate(RATE_HEALTH); - - float addvalue = 0.0f; - - // polymorphed case - if ( IsPolymorphed() ) - addvalue = GetMaxHealth()/3; - // normal regen case (maybe partly in combat case) - else if (!isInCombat() || HasAuraType(SPELL_AURA_MOD_REGEN_DURING_COMBAT) ) - { - addvalue = OCTRegenHPPerSpirit()* HealthIncreaseRate; - if (!isInCombat()) - { - AuraList const& mModHealthRegenPct = GetAurasByType(SPELL_AURA_MOD_HEALTH_REGEN_PERCENT); - for(AuraList::const_iterator i = mModHealthRegenPct.begin(); i != mModHealthRegenPct.end(); ++i) - addvalue *= (100.0f + (*i)->GetModifier()->m_amount) / 100.0f; - } - else if(HasAuraType(SPELL_AURA_MOD_REGEN_DURING_COMBAT)) - addvalue *= GetTotalAuraModifier(SPELL_AURA_MOD_REGEN_DURING_COMBAT) / 100.0f; - - if(!IsStandState()) - addvalue *= 1.5; - } - - // always regeneration bonus (including combat) - addvalue += GetTotalAuraModifier(SPELL_AURA_MOD_HEALTH_REGEN_IN_COMBAT); - - if(addvalue < 0) - addvalue = 0; - - ModifyHealth(int32(addvalue)); -} - -bool Player::CanInteractWithNPCs(bool alive) const -{ - if(alive && !isAlive()) - return false; - if(isInFlight()) - return false; - - return true; -} - -bool Player::IsUnderWater() const -{ - return IsInWater() && - GetPositionZ() < (MapManager::Instance().GetBaseMap(GetMapId())->GetWaterLevel(GetPositionX(),GetPositionY())-2); -} - -void Player::SetInWater(bool apply) -{ - if(m_isInWater==apply) - return; - - //define player in water by opcodes - //move player's guid into HateOfflineList of those mobs - //which can't swim and move guid back into ThreatList when - //on surface. - //TODO: exist also swimming mobs, and function must be symmetric to enter/leave water - m_isInWater = apply; - - // remove auras that need water/land - RemoveAurasWithInterruptFlags(apply ? AURA_INTERRUPT_FLAG_NOT_ABOVEWATER : AURA_INTERRUPT_FLAG_NOT_UNDERWATER); - - getHostilRefManager().updateThreatTables(); -} - -void Player::SetGameMaster(bool on) -{ - if(on) - { - m_ExtraFlags |= PLAYER_EXTRA_GM_ON; - setFaction(35); - SetFlag(PLAYER_FLAGS, PLAYER_FLAGS_GM); - - RemoveFlag(PLAYER_FLAGS, PLAYER_FLAGS_FFA_PVP); - ResetContestedPvP(); - - getHostilRefManager().setOnlineOfflineState(false); - CombatStop(); - } - else - { - m_ExtraFlags &= ~ PLAYER_EXTRA_GM_ON; - setFactionForRace(getRace()); - RemoveFlag(PLAYER_FLAGS, PLAYER_FLAGS_GM); - - // restore FFA PvP Server state - if(sWorld.IsFFAPvPRealm()) - SetFlag(PLAYER_FLAGS,PLAYER_FLAGS_FFA_PVP); - - // restore FFA PvP area state, remove not allowed for GM mounts - UpdateArea(m_areaUpdateId); - - getHostilRefManager().setOnlineOfflineState(true); - } - - ObjectAccessor::UpdateVisibilityForPlayer(this); -} - -void Player::SetGMVisible(bool on) -{ - if(on) - { - m_ExtraFlags &= ~PLAYER_EXTRA_GM_INVISIBLE; //remove flag - - // Reapply stealth/invisibility if active or show if not any - if(HasAuraType(SPELL_AURA_MOD_STEALTH)) - SetVisibility(VISIBILITY_GROUP_STEALTH); - else if(HasAuraType(SPELL_AURA_MOD_INVISIBILITY)) - SetVisibility(VISIBILITY_GROUP_INVISIBILITY); - else - SetVisibility(VISIBILITY_ON); - } - else - { - m_ExtraFlags |= PLAYER_EXTRA_GM_INVISIBLE; //add flag - - SetAcceptWhispers(false); - SetGameMaster(true); - - SetVisibility(VISIBILITY_OFF); - } -} - -bool Player::IsGroupVisibleFor(Player* p) const -{ - switch(sWorld.getConfig(CONFIG_GROUP_VISIBILITY)) - { - default: return IsInSameGroupWith(p); - case 1: return IsInSameRaidWith(p); - case 2: return GetTeam()==p->GetTeam(); - } -} - -bool Player::IsInSameGroupWith(Player const* p) const -{ - return p==this || GetGroup() != NULL && - GetGroup() == p->GetGroup() && - GetGroup()->SameSubGroup((Player*)this, (Player*)p); -} - -///- If the player is invited, remove him. If the group if then only 1 person, disband the group. -/// \todo Shouldn't we also check if there is no other invitees before disbanding the group? -void Player::UninviteFromGroup() -{ - if(GetGroupInvite()) // uninvited invitee - { - Group* group = GetGroupInvite(); - group->RemoveInvite(this); - - if(group->GetMembersCount() <= 1) // group has just 1 member => disband - { - if(group->IsCreated()) - { - group->Disband(true); - objmgr.RemoveGroup(group); - } - else - group->RemoveAllInvites(); - - delete group; - } - } -} - -void Player::RemoveFromGroup(Group* group, uint64 guid) -{ - if(group) - { - if (group->RemoveMember(guid, 0) <= 1) - { - // group->Disband(); already disbanded in RemoveMember - objmgr.RemoveGroup(group); - delete group; - // removemember sets the player's group pointer to NULL - } - } -} - -void Player::SendLogXPGain(uint32 GivenXP, Unit* victim, uint32 RestXP) -{ - WorldPacket data(SMSG_LOG_XPGAIN, 21); - data << uint64(victim ? victim->GetGUID() : 0); // guid - data << uint32(GivenXP+RestXP); // given experience - data << uint8(victim ? 0 : 1); // 00-kill_xp type, 01-non_kill_xp type - if(victim) - { - data << uint32(GivenXP); // experience without rested bonus - data << float(1); // 1 - none 0 - 100% group bonus output - } - data << uint8(0); // new 2.4.0 - GetSession()->SendPacket(&data); -} - -void Player::GiveXP(uint32 xp, Unit* victim) -{ - if ( xp < 1 ) - return; - - if(!isAlive()) - return; - - uint32 level = getLevel(); - - // XP to money conversion processed in Player::RewardQuest - if(level >= sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL)) - return; - - // handle SPELL_AURA_MOD_XP_PCT auras - Unit::AuraList const& ModXPPctAuras = GetAurasByType(SPELL_AURA_MOD_XP_PCT); - for(Unit::AuraList::const_iterator i = ModXPPctAuras.begin();i != ModXPPctAuras.end(); ++i) - xp = uint32(xp*(1.0f + (*i)->GetModifier()->m_amount / 100.0f)); - - // XP resting bonus for kill - uint32 rested_bonus_xp = victim ? GetXPRestBonus(xp) : 0; - - SendLogXPGain(xp,victim,rested_bonus_xp); - - uint32 curXP = GetUInt32Value(PLAYER_XP); - uint32 nextLvlXP = GetUInt32Value(PLAYER_NEXT_LEVEL_XP); - uint32 newXP = curXP + xp + rested_bonus_xp; - - while( newXP >= nextLvlXP && level < sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL) ) - { - newXP -= nextLvlXP; - - if ( level < sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL) ) - GiveLevel(level + 1); - - level = getLevel(); - nextLvlXP = GetUInt32Value(PLAYER_NEXT_LEVEL_XP); - } - - SetUInt32Value(PLAYER_XP, newXP); -} - -// Update player to next level -// Current player experience not update (must be update by caller) -void Player::GiveLevel(uint32 level) -{ - if ( level == getLevel() ) - return; - - PlayerLevelInfo info; - objmgr.GetPlayerLevelInfo(getRace(),getClass(),level,&info); - - PlayerClassLevelInfo classInfo; - objmgr.GetPlayerClassLevelInfo(getClass(),level,&classInfo); - - // send levelup info to client - WorldPacket data(SMSG_LEVELUP_INFO, (4+4+MAX_POWERS*4+MAX_STATS*4)); - data << uint32(level); - data << uint32(int32(classInfo.basehealth) - int32(GetCreateHealth())); - // for(int i = 0; i < MAX_POWERS; ++i) // Powers loop (0-6) - data << uint32(int32(classInfo.basemana) - int32(GetCreateMana())); - data << uint32(0); - data << uint32(0); - data << uint32(0); - data << uint32(0); - // end for - for(int i = STAT_STRENGTH; i < MAX_STATS; ++i) // Stats loop (0-4) - data << uint32(int32(info.stats[i]) - GetCreateStat(Stats(i))); - - GetSession()->SendPacket(&data); - - SetUInt32Value(PLAYER_NEXT_LEVEL_XP, MaNGOS::XP::xp_to_level(level)); - - //update level, max level of skills - if(getLevel()!= level) - m_Played_time[1] = 0; // Level Played Time reset - SetLevel(level); - UpdateMaxSkills(); - - // save base values (bonuses already included in stored stats - for(int i = STAT_STRENGTH; i < MAX_STATS; ++i) - SetCreateStat(Stats(i), info.stats[i]); - - SetCreateHealth(classInfo.basehealth); - SetCreateMana(classInfo.basemana); - - InitTalentForLevel(); - InitTaxiNodesForLevel(); - - UpdateAllStats(); - - // set current level health and mana/energy to maximum after applying all mods. - SetHealth(GetMaxHealth()); - SetPower(POWER_MANA, GetMaxPower(POWER_MANA)); - SetPower(POWER_ENERGY, GetMaxPower(POWER_ENERGY)); - if(GetPower(POWER_RAGE) > GetMaxPower(POWER_RAGE)) - SetPower(POWER_RAGE, GetMaxPower(POWER_RAGE)); - SetPower(POWER_FOCUS, 0); - SetPower(POWER_HAPPINESS, 0); - - // give level to summoned pet - Pet* pet = GetPet(); - if(pet && pet->getPetType()==SUMMON_PET) - pet->GivePetLevel(level); -} - -void Player::InitTalentForLevel() -{ - uint32 level = getLevel(); - // talents base at level diff ( talents = level - 9 but some can be used already) - if(level < 10) - { - // Remove all talent points - if(m_usedTalentCount > 0) // Free any used talents - { - resetTalents(true); - SetFreeTalentPoints(0); - } - } - else - { - uint32 talentPointsForLevel = uint32((level-9)*sWorld.getRate(RATE_TALENT)); - // if used more that have then reset - if(m_usedTalentCount > talentPointsForLevel) - { - if (GetSession()->GetSecurity() < SEC_ADMINISTRATOR) - resetTalents(true); - else - SetFreeTalentPoints(0); - } - // else update amount of free points - else - SetFreeTalentPoints(talentPointsForLevel-m_usedTalentCount); - } -} - -void Player::InitStatsForLevel(bool reapplyMods) -{ - if(reapplyMods) //reapply stats values only on .reset stats (level) command - _RemoveAllStatBonuses(); - - PlayerClassLevelInfo classInfo; - objmgr.GetPlayerClassLevelInfo(getClass(),getLevel(),&classInfo); - - PlayerLevelInfo info; - objmgr.GetPlayerLevelInfo(getRace(),getClass(),getLevel(),&info); - - SetUInt32Value(PLAYER_FIELD_MAX_LEVEL, sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL) ); - SetUInt32Value(PLAYER_NEXT_LEVEL_XP, MaNGOS::XP::xp_to_level(getLevel())); - - UpdateMaxSkills (); - - // set default cast time multiplier - SetFloatValue(UNIT_MOD_CAST_SPEED, 1.0f); - - // reset size before reapply auras - SetFloatValue(OBJECT_FIELD_SCALE_X,1.0f); - - // save base values (bonuses already included in stored stats - for(int i = STAT_STRENGTH; i < MAX_STATS; ++i) - SetCreateStat(Stats(i), info.stats[i]); - - for(int i = STAT_STRENGTH; i < MAX_STATS; ++i) - SetStat(Stats(i), info.stats[i]); - - SetCreateHealth(classInfo.basehealth); - - //set create powers - SetCreateMana(classInfo.basemana); - - SetArmor(int32(m_createStats[STAT_AGILITY]*2)); - - InitStatBuffMods(); - - //reset rating fields values - for(uint16 index = PLAYER_FIELD_COMBAT_RATING_1; index < PLAYER_FIELD_COMBAT_RATING_1 + MAX_COMBAT_RATING; ++index) - SetUInt32Value(index, 0); - - SetUInt32Value(PLAYER_FIELD_MOD_HEALING_DONE_POS,0); - for (int i = 0; i < 7; i++) - { - SetUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_NEG+i, 0); - SetUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS+i, 0); - SetFloatValue(PLAYER_FIELD_MOD_DAMAGE_DONE_PCT+i, 1.00f); - } - - //reset attack power, damage and attack speed fields - SetFloatValue(UNIT_FIELD_BASEATTACKTIME, 2000.0f ); - SetFloatValue(UNIT_FIELD_BASEATTACKTIME + 1, 2000.0f ); // offhand attack time - SetFloatValue(UNIT_FIELD_RANGEDATTACKTIME, 2000.0f ); - - SetFloatValue(UNIT_FIELD_MINDAMAGE, 0.0f ); - SetFloatValue(UNIT_FIELD_MAXDAMAGE, 0.0f ); - SetFloatValue(UNIT_FIELD_MINOFFHANDDAMAGE, 0.0f ); - SetFloatValue(UNIT_FIELD_MAXOFFHANDDAMAGE, 0.0f ); - SetFloatValue(UNIT_FIELD_MINRANGEDDAMAGE, 0.0f ); - SetFloatValue(UNIT_FIELD_MAXRANGEDDAMAGE, 0.0f ); - - SetUInt32Value(UNIT_FIELD_ATTACK_POWER, 0 ); - SetUInt32Value(UNIT_FIELD_ATTACK_POWER_MODS, 0 ); - SetFloatValue(UNIT_FIELD_ATTACK_POWER_MULTIPLIER,0.0f); - SetUInt32Value(UNIT_FIELD_RANGED_ATTACK_POWER, 0 ); - SetUInt32Value(UNIT_FIELD_RANGED_ATTACK_POWER_MODS,0 ); - SetFloatValue(UNIT_FIELD_RANGED_ATTACK_POWER_MULTIPLIER,0.0f); - - // Base crit values (will be recalculated in UpdateAllStats() at loading and in _ApplyAllStatBonuses() at reset - SetFloatValue(PLAYER_CRIT_PERCENTAGE,0.0f); - SetFloatValue(PLAYER_OFFHAND_CRIT_PERCENTAGE,0.0f); - SetFloatValue(PLAYER_RANGED_CRIT_PERCENTAGE,0.0f); - - // Init spell schools (will be recalculated in UpdateAllStats() at loading and in _ApplyAllStatBonuses() at reset - for (uint8 i = 0; i < 7; ++i) - SetFloatValue(PLAYER_SPELL_CRIT_PERCENTAGE1+i, 0.0f); - - // Base parry percents - SetFloatValue(PLAYER_PARRY_PERCENTAGE, 5.0f); - - //Base block percentage - SetFloatValue(PLAYER_BLOCK_PERCENTAGE, 5.0f); - - SetUInt32Value(PLAYER_SHIELD_BLOCK, 0); - - // Dodge percentage - SetFloatValue(PLAYER_DODGE_PERCENTAGE, 0.0f); - - // set armor (resistance 0) to original value (create_agility*2) - SetArmor(int32(m_createStats[STAT_AGILITY]*2)); - SetResistanceBuffMods(SpellSchools(0), true, 0.0f); - SetResistanceBuffMods(SpellSchools(0), false, 0.0f); - // set other resistance to original value (0) - for (int i = 1; i < MAX_SPELL_SCHOOL; i++) - { - SetResistance(SpellSchools(i), 0); - SetResistanceBuffMods(SpellSchools(i), true, 0.0f); - SetResistanceBuffMods(SpellSchools(i), false, 0.0f); - } - - SetUInt32Value(PLAYER_FIELD_MOD_TARGET_RESISTANCE,0); - SetUInt32Value(PLAYER_FIELD_MOD_TARGET_PHYSICAL_RESISTANCE,0); - for(int i = 0; i < MAX_SPELL_SCHOOL; ++i) - { - SetFloatValue(UNIT_FIELD_POWER_COST_MODIFIER+i,0.0f); - SetFloatValue(UNIT_FIELD_POWER_COST_MULTIPLIER+i,0.0f); - } - // Init data for form but skip reapply item mods for form - InitDataForForm(reapplyMods); - - // save new stats - for (int i = POWER_MANA; i < MAX_POWERS; i++) - SetMaxPower(Powers(i), uint32(GetCreatePowers(Powers(i)))); - - SetMaxHealth(classInfo.basehealth); // stamina bonus will applied later - - // cleanup mounted state (it will set correctly at aura loading if player saved at mount. - SetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID, 0); - - // cleanup unit flags (will be re-applied if need at aura load). - RemoveFlag( UNIT_FIELD_FLAGS, - UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_DISABLE_MOVE | UNIT_FLAG_NOT_ATTACKABLE_1 | - UNIT_FLAG_PET_IN_COMBAT | UNIT_FLAG_SILENCED | UNIT_FLAG_PACIFIED | - UNIT_FLAG_DISABLE_ROTATE | UNIT_FLAG_IN_COMBAT | UNIT_FLAG_DISARMED | - UNIT_FLAG_CONFUSED | UNIT_FLAG_FLEEING | UNIT_FLAG_NOT_SELECTABLE | - UNIT_FLAG_SKINNABLE | UNIT_FLAG_MOUNT | UNIT_FLAG_TAXI_FLIGHT ); - SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE ); // must be set - - // cleanup player flags (will be re-applied if need at aura load), to avoid have ghost flag without ghost aura, for example. - RemoveFlag(PLAYER_FLAGS, PLAYER_FLAGS_AFK | PLAYER_FLAGS_DND | PLAYER_FLAGS_GM | PLAYER_FLAGS_GHOST | PLAYER_FLAGS_FFA_PVP); - - SetByteValue(UNIT_FIELD_BYTES_1, 2, 0x00); // one form stealth modified bytes - - // restore if need some important flags - SetUInt32Value(PLAYER_FIELD_BYTES2, 0 ); // flags empty by default - - if(reapplyMods) //reapply stats values only on .reset stats (level) command - _ApplyAllStatBonuses(); - - // set current level health and mana/energy to maximum after applying all mods. - SetHealth(GetMaxHealth()); - SetPower(POWER_MANA, GetMaxPower(POWER_MANA)); - SetPower(POWER_ENERGY, GetMaxPower(POWER_ENERGY)); - if(GetPower(POWER_RAGE) > GetMaxPower(POWER_RAGE)) - SetPower(POWER_RAGE, GetMaxPower(POWER_RAGE)); - SetPower(POWER_FOCUS, 0); - SetPower(POWER_HAPPINESS, 0); -} - -void Player::SendInitialSpells() -{ - uint16 spellCount = 0; - - WorldPacket data(SMSG_INITIAL_SPELLS, (1+2+4*m_spells.size()+2+m_spellCooldowns.size()*(2+2+2+4+4))); - data << uint8(0); - - size_t countPos = data.wpos(); - data << uint16(spellCount); // spell count placeholder - - for (PlayerSpellMap::const_iterator itr = m_spells.begin(); itr != m_spells.end(); ++itr) - { - if(itr->second->state == PLAYERSPELL_REMOVED) - continue; - - if(!itr->second->active || itr->second->disabled) - continue; - - data << uint16(itr->first); - //data << uint16(itr->second->slotId); - data << uint16(0); // it's not slot id - - spellCount +=1; - } - - data.put(countPos,spellCount); // write real count value - - uint16 spellCooldowns = m_spellCooldowns.size(); - data << uint16(spellCooldowns); - for(SpellCooldowns::const_iterator itr=m_spellCooldowns.begin(); itr!=m_spellCooldowns.end(); itr++) - { - SpellEntry const *sEntry = sSpellStore.LookupEntry(itr->first); - if(!sEntry) - continue; - - data << uint16(itr->first); - - time_t cooldown = 0; - time_t curTime = time(NULL); - if(itr->second.end > curTime) - cooldown = (itr->second.end-curTime)*1000; - - data << uint16(itr->second.itemid); // cast item id - data << uint16(sEntry->Category); // spell category - if(sEntry->Category) // may be wrong, but anyway better than nothing... - { - data << uint32(0); - data << uint32(cooldown); - } - else - { - data << uint32(cooldown); - data << uint32(0); - } - } - - GetSession()->SendPacket(&data); - - sLog.outDetail( "CHARACTER: Sent Initial Spells" ); -} - -void Player::RemoveMail(uint32 id) -{ - for(PlayerMails::iterator itr = m_mail.begin(); itr != m_mail.end();++itr) - { - if ((*itr)->messageID == id) - { - //do not delete item, because Player::removeMail() is called when returning mail to sender. - m_mail.erase(itr); - return; - } - } -} - -void Player::SendMailResult(uint32 mailId, uint32 mailAction, uint32 mailError, uint32 equipError, uint32 item_guid, uint32 item_count) -{ - WorldPacket data(SMSG_SEND_MAIL_RESULT, (4+4+4+(mailError == MAIL_ERR_BAG_FULL?4:(mailAction == MAIL_ITEM_TAKEN?4+4:0)))); - data << (uint32) mailId; - data << (uint32) mailAction; - data << (uint32) mailError; - if ( mailError == MAIL_ERR_BAG_FULL ) - data << (uint32) equipError; - else if( mailAction == MAIL_ITEM_TAKEN ) - { - data << (uint32) item_guid; // item guid low? - data << (uint32) item_count; // item count? - } - GetSession()->SendPacket(&data); -} - -void Player::SendNewMail() -{ - // deliver undelivered mail - WorldPacket data(SMSG_RECEIVED_MAIL, 4); - data << (uint32) 0; - GetSession()->SendPacket(&data); -} - -void Player::UpdateNextMailTimeAndUnreads() -{ - // calculate next delivery time (min. from non-delivered mails - // and recalculate unReadMail - time_t cTime = time(NULL); - m_nextMailDelivereTime = 0; - unReadMails = 0; - for(PlayerMails::iterator itr = m_mail.begin(); itr != m_mail.end(); ++itr) - { - if((*itr)->deliver_time > cTime) - { - if(!m_nextMailDelivereTime || m_nextMailDelivereTime > (*itr)->deliver_time) - m_nextMailDelivereTime = (*itr)->deliver_time; - } - else if(((*itr)->checked & MAIL_CHECK_MASK_READ) == 0) - ++unReadMails; - } -} - -void Player::AddNewMailDeliverTime(time_t deliver_time) -{ - if(deliver_time <= time(NULL)) // ready now - { - ++unReadMails; - SendNewMail(); - } - else // not ready and no have ready mails - { - if(!m_nextMailDelivereTime || m_nextMailDelivereTime > deliver_time) - m_nextMailDelivereTime = deliver_time; - } -} - -bool Player::addSpell(uint32 spell_id, bool active, bool learning, bool loading, uint16 slot_id, bool disabled) -{ - SpellEntry const *spellInfo = sSpellStore.LookupEntry(spell_id); - if (!spellInfo) - { - // do character spell book cleanup (all characters) - if(loading && !learning) // spell load case - { - sLog.outError("Player::addSpell: Non-existed in SpellStore spell #%u request, deleting for all characters in `character_spell`.",spell_id); - CharacterDatabase.PExecute("DELETE FROM character_spell WHERE spell = '%u'",spell_id); - } - else - sLog.outError("Player::addSpell: Non-existed in SpellStore spell #%u request.",spell_id); - - return false; - } - - if(!SpellMgr::IsSpellValid(spellInfo,this,false)) - { - // do character spell book cleanup (all characters) - if(loading && !learning) // spell load case - { - sLog.outError("Player::addSpell: Broken spell #%u learning not allowed, deleting for all characters in `character_spell`.",spell_id); - CharacterDatabase.PExecute("DELETE FROM character_spell WHERE spell = '%u'",spell_id); - } - else - sLog.outError("Player::addSpell: Broken spell #%u learning not allowed.",spell_id); - - return false; - } - - PlayerSpellState state = learning ? PLAYERSPELL_NEW : PLAYERSPELL_UNCHANGED; - - bool disabled_case = false; - bool superceded_old = false; - - PlayerSpellMap::iterator itr = m_spells.find(spell_id); - if (itr != m_spells.end()) - { - // update active state for known spell - if(itr->second->active != active && itr->second->state != PLAYERSPELL_REMOVED && !itr->second->disabled) - { - itr->second->active = active; - - // loading && !learning == explicitly load from DB and then exist in it already and set correctly - if(loading && !learning) - itr->second->state = PLAYERSPELL_UNCHANGED; - else if(itr->second->state != PLAYERSPELL_NEW) - itr->second->state = PLAYERSPELL_CHANGED; - - if(!active) - { - WorldPacket data(SMSG_REMOVED_SPELL, 4); - data << uint16(spell_id); - GetSession()->SendPacket(&data); - } - return active; // learn (show in spell book if active now) - } - - if(itr->second->disabled != disabled && itr->second->state != PLAYERSPELL_REMOVED) - { - if(itr->second->state != PLAYERSPELL_NEW) - itr->second->state = PLAYERSPELL_CHANGED; - itr->second->disabled = disabled; - - if(disabled) - return false; - - disabled_case = true; - } - else switch(itr->second->state) - { - case PLAYERSPELL_UNCHANGED: // known saved spell - return false; - case PLAYERSPELL_REMOVED: // re-learning removed not saved spell - { - delete itr->second; - m_spells.erase(itr); - state = PLAYERSPELL_CHANGED; - break; // need re-add - } - default: // known not saved yet spell (new or modified) - { - // can be in case spell loading but learned at some previous spell loading - if(loading && !learning) - itr->second->state = PLAYERSPELL_UNCHANGED; - - return false; - } - } - } - - if(!disabled_case) // skip new spell adding if spell already known (disabled spells case) - { - // talent: unlearn all other talent ranks (high and low) - if(TalentSpellPos const* talentPos = GetTalentSpellPos(spell_id)) - { - if(TalentEntry const *talentInfo = sTalentStore.LookupEntry( talentPos->talent_id )) - { - for(int i=0; i <5; ++i) - { - // skip learning spell and no rank spell case - uint32 rankSpellId = talentInfo->RankID[i]; - if(!rankSpellId || rankSpellId==spell_id) - continue; - - // skip unknown ranks - if(!HasSpell(rankSpellId)) - continue; - - removeSpell(rankSpellId); - } - } - } - // non talent spell: learn low ranks (recursive call) - else if(uint32 prev_spell = spellmgr.GetPrevSpellInChain(spell_id)) - { - if(loading) // at spells loading, no output, but allow save - addSpell(prev_spell,active,true,loading,SPELL_WITHOUT_SLOT_ID,disabled); - else // at normal learning - learnSpell(prev_spell); - } - - PlayerSpell *newspell = new PlayerSpell; - newspell->active = active; - newspell->state = state; - newspell->disabled = disabled; - - // replace spells in action bars and spellbook to bigger rank if only one spell rank must be accessible - if(newspell->active && !newspell->disabled && !SpellMgr::canStackSpellRanks(spellInfo) && spellmgr.GetSpellRank(spellInfo->Id) != 0) - { - for( PlayerSpellMap::iterator itr = m_spells.begin(); itr != m_spells.end(); ++itr ) - { - if(itr->second->state == PLAYERSPELL_REMOVED) continue; - SpellEntry const *i_spellInfo = sSpellStore.LookupEntry(itr->first); - if(!i_spellInfo) continue; - - if( spellmgr.IsRankSpellDueToSpell(spellInfo,itr->first) ) - { - if(itr->second->active) - { - if(spellmgr.IsHighRankOfSpell(spell_id,itr->first)) - { - if(!loading) // not send spell (re-/over-)learn packets at loading - { - WorldPacket data(SMSG_SUPERCEDED_SPELL, (4)); - data << uint16(itr->first); - data << uint16(spell_id); - GetSession()->SendPacket( &data ); - } - - // mark old spell as disable (SMSG_SUPERCEDED_SPELL replace it in client by new) - itr->second->active = false; - itr->second->state = PLAYERSPELL_CHANGED; - superceded_old = true; // new spell replace old in action bars and spell book. - } - else if(spellmgr.IsHighRankOfSpell(itr->first,spell_id)) - { - if(!loading) // not send spell (re-/over-)learn packets at loading - { - WorldPacket data(SMSG_SUPERCEDED_SPELL, (4)); - data << uint16(spell_id); - data << uint16(itr->first); - GetSession()->SendPacket( &data ); - } - - // mark new spell as disable (not learned yet for client and will not learned) - newspell->active = false; - if(newspell->state != PLAYERSPELL_NEW) - newspell->state = PLAYERSPELL_CHANGED; - } - } - } - } - } - - uint16 tmpslot=slot_id; - - if (tmpslot == SPELL_WITHOUT_SLOT_ID) - { - uint16 maxid = 0; - PlayerSpellMap::iterator itr; - for (itr = m_spells.begin(); itr != m_spells.end(); ++itr) - { - if(itr->second->state == PLAYERSPELL_REMOVED) - continue; - if (itr->second->slotId > maxid) - maxid = itr->second->slotId; - } - tmpslot = maxid + 1; - } - - newspell->slotId = tmpslot; - m_spells[spell_id] = newspell; - - // return false if spell disabled - if (newspell->disabled) - return false; - } - - uint32 talentCost = GetTalentSpellCost(spell_id); - - // cast talents with SPELL_EFFECT_LEARN_SPELL (other dependent spells will learned later as not auto-learned) - // note: all spells with SPELL_EFFECT_LEARN_SPELL isn't passive - if( talentCost > 0 && IsSpellHaveEffect(spellInfo,SPELL_EFFECT_LEARN_SPELL) ) - { - // ignore stance requirement for talent learn spell (stance set for spell only for client spell description show) - CastSpell(this, spell_id, true); - } - // also cast passive spells (including all talents without SPELL_EFFECT_LEARN_SPELL) with additional checks - else if (IsPassiveSpell(spell_id)) - { - // if spell doesn't require a stance or the player is in the required stance - if( ( !spellInfo->Stances && - spell_id != 5420 && spell_id != 5419 && spell_id != 7376 && - spell_id != 7381 && spell_id != 21156 && spell_id != 21009 && - spell_id != 21178 && spell_id != 33948 && spell_id != 40121 ) || - m_form != 0 && (spellInfo->Stances & (1<<(m_form-1))) || - (spell_id == 5420 && m_form == FORM_TREE) || - (spell_id == 5419 && m_form == FORM_TRAVEL) || - (spell_id == 7376 && m_form == FORM_DEFENSIVESTANCE) || - (spell_id == 7381 && m_form == FORM_BERSERKERSTANCE) || - (spell_id == 21156 && m_form == FORM_BATTLESTANCE)|| - (spell_id == 21178 && (m_form == FORM_BEAR || m_form == FORM_DIREBEAR) ) || - (spell_id == 33948 && m_form == FORM_FLIGHT) || - (spell_id == 40121 && m_form == FORM_FLIGHT_EPIC) ) - //Check CasterAuraStates - if (!spellInfo->CasterAuraState || HasAuraState(AuraState(spellInfo->CasterAuraState))) - CastSpell(this, spell_id, true); - } - else if( IsSpellHaveEffect(spellInfo,SPELL_EFFECT_SKILL_STEP) ) - { - CastSpell(this, spell_id, true); - return false; - } - - // update used talent points count - m_usedTalentCount += talentCost; - - // update free primary prof.points (if any, can be none in case GM .learn prof. learning) - if(uint32 freeProfs = GetFreePrimaryProffesionPoints()) - { - if(spellmgr.IsPrimaryProfessionFirstRankSpell(spell_id)) - SetFreePrimaryProffesions(freeProfs-1); - } - - // add dependent skills - uint16 maxskill = GetMaxSkillValueForLevel(); - - SpellLearnSkillNode const* spellLearnSkill = spellmgr.GetSpellLearnSkill(spell_id); - - if(spellLearnSkill) - { - uint32 skill_value = GetPureSkillValue(spellLearnSkill->skill); - uint32 skill_max_value = GetPureMaxSkillValue(spellLearnSkill->skill); - - if(skill_value < spellLearnSkill->value) - skill_value = spellLearnSkill->value; - - uint32 new_skill_max_value = spellLearnSkill->maxvalue == 0 ? maxskill : spellLearnSkill->maxvalue; - - if(skill_max_value < new_skill_max_value) - skill_max_value = new_skill_max_value; - - SetSkill(spellLearnSkill->skill,skill_value,skill_max_value); - } - else - { - // not ranked skills - SkillLineAbilityMap::const_iterator lower = spellmgr.GetBeginSkillLineAbilityMap(spell_id); - SkillLineAbilityMap::const_iterator upper = spellmgr.GetEndSkillLineAbilityMap(spell_id); - - for(SkillLineAbilityMap::const_iterator _spell_idx = lower; _spell_idx != upper; ++_spell_idx) - { - SkillLineEntry const *pSkill = sSkillLineStore.LookupEntry(_spell_idx->second->skillId); - if(!pSkill) - continue; - - if(HasSkill(pSkill->id)) - continue; - - if(_spell_idx->second->learnOnGetSkill == ABILITY_LEARNED_ON_GET_RACE_OR_CLASS_SKILL || - // poison special case, not have ABILITY_LEARNED_ON_GET_RACE_OR_CLASS_SKILL - pSkill->id==SKILL_POISONS && _spell_idx->second->max_value==0 || - // lockpicking special case, not have ABILITY_LEARNED_ON_GET_RACE_OR_CLASS_SKILL - pSkill->id==SKILL_LOCKPICKING && _spell_idx->second->max_value==0 ) - { - switch(GetSkillRangeType(pSkill,_spell_idx->second->racemask!=0)) - { - case SKILL_RANGE_LANGUAGE: - SetSkill(pSkill->id, 300, 300 ); - break; - case SKILL_RANGE_LEVEL: - SetSkill(pSkill->id, 1, GetMaxSkillValueForLevel() ); - break; - case SKILL_RANGE_MONO: - SetSkill(pSkill->id, 1, 1 ); - break; - default: - break; - } - } - } - } - - // learn dependent spells - SpellLearnSpellMap::const_iterator spell_begin = spellmgr.GetBeginSpellLearnSpell(spell_id); - SpellLearnSpellMap::const_iterator spell_end = spellmgr.GetEndSpellLearnSpell(spell_id); - - for(SpellLearnSpellMap::const_iterator itr = spell_begin; itr != spell_end; ++itr) - { - if(!itr->second.autoLearned) - { - if(loading) // at spells loading, no output, but allow save - addSpell(itr->second.spell,true,true,loading); - else // at normal learning - learnSpell(itr->second.spell); - } - } - - // return true (for send learn packet) only if spell active (in case ranked spells) and not replace old spell - return active && !disabled && !superceded_old; -} - -void Player::learnSpell(uint32 spell_id) -{ - PlayerSpellMap::iterator itr = m_spells.find(spell_id); - - bool disabled = (itr != m_spells.end()) ? itr->second->disabled : false; - bool active = disabled ? itr->second->active : true; - - bool learning = addSpell(spell_id,active); - - // learn all disabled higher ranks (recursive) - SpellChainMapNext const& nextMap = spellmgr.GetSpellChainNext(); - for(SpellChainMapNext::const_iterator i = nextMap.lower_bound(spell_id); i != nextMap.upper_bound(spell_id); ++i) - { - PlayerSpellMap::iterator iter = m_spells.find(i->second); - if (disabled && iter != m_spells.end() && iter->second->disabled) - learnSpell(i->second); - } - - // prevent duplicated entires in spell book - if(!learning) - return; - - WorldPacket data(SMSG_LEARNED_SPELL, 4); - data << uint32(spell_id); - GetSession()->SendPacket(&data); -} - -void Player::removeSpell(uint32 spell_id, bool disabled) -{ - PlayerSpellMap::iterator itr = m_spells.find(spell_id); - if (itr == m_spells.end()) - return; - - if(itr->second->state == PLAYERSPELL_REMOVED || disabled && itr->second->disabled) - return; - - // unlearn non talent higher ranks (recursive) - SpellChainMapNext const& nextMap = spellmgr.GetSpellChainNext(); - for(SpellChainMapNext::const_iterator itr2 = nextMap.lower_bound(spell_id); itr2 != nextMap.upper_bound(spell_id); ++itr2) - if(HasSpell(itr2->second) && !GetTalentSpellPos(itr2->second)) - removeSpell(itr2->second,disabled); - - // removing - WorldPacket data(SMSG_REMOVED_SPELL, 4); - data << uint16(spell_id); - GetSession()->SendPacket(&data); - - if (disabled) - { - itr->second->disabled = disabled; - if(itr->second->state != PLAYERSPELL_NEW) - itr->second->state = PLAYERSPELL_CHANGED; - } - else - { - if(itr->second->state == PLAYERSPELL_NEW) - { - delete itr->second; - m_spells.erase(itr); - } - else - itr->second->state = PLAYERSPELL_REMOVED; - } - - RemoveAurasDueToSpell(spell_id); - - // remove pet auras - if(PetAura const* petSpell = spellmgr.GetPetAura(spell_id)) - RemovePetAura(petSpell); - - // free talent points - uint32 talentCosts = GetTalentSpellCost(spell_id); - if(talentCosts > 0) - { - if(talentCosts < m_usedTalentCount) - m_usedTalentCount -= talentCosts; - else - m_usedTalentCount = 0; - } - - // update free primary prof.points (if not overflow setting, can be in case GM use before .learn prof. learning) - if(spellmgr.IsPrimaryProfessionFirstRankSpell(spell_id)) - { - uint32 freeProfs = GetFreePrimaryProffesionPoints()+1; - if(freeProfs <= sWorld.getConfig(CONFIG_MAX_PRIMARY_TRADE_SKILL)) - SetFreePrimaryProffesions(freeProfs); - } - - // remove dependent skill - SpellLearnSkillNode const* spellLearnSkill = spellmgr.GetSpellLearnSkill(spell_id); - if(spellLearnSkill) - { - uint32 prev_spell = spellmgr.GetPrevSpellInChain(spell_id); - if(!prev_spell) // first rank, remove skill - SetSkill(spellLearnSkill->skill,0,0); - else - { - // search prev. skill setting by spell ranks chain - SpellLearnSkillNode const* prevSkill = spellmgr.GetSpellLearnSkill(prev_spell); - while(!prevSkill && prev_spell) - { - prev_spell = spellmgr.GetPrevSpellInChain(prev_spell); - prevSkill = spellmgr.GetSpellLearnSkill(spellmgr.GetFirstSpellInChain(prev_spell)); - } - - if(!prevSkill) // not found prev skill setting, remove skill - SetSkill(spellLearnSkill->skill,0,0); - else // set to prev. skill setting values - { - uint32 skill_value = GetPureSkillValue(prevSkill->skill); - uint32 skill_max_value = GetPureMaxSkillValue(prevSkill->skill); - - if(skill_value > prevSkill->value) - skill_value = prevSkill->value; - - uint32 new_skill_max_value = prevSkill->maxvalue == 0 ? GetMaxSkillValueForLevel() : prevSkill->maxvalue; - - if(skill_max_value > new_skill_max_value) - skill_max_value = new_skill_max_value; - - SetSkill(prevSkill->skill,skill_value,skill_max_value); - } - } - - } - else - { - // not ranked skills - SkillLineAbilityMap::const_iterator lower = spellmgr.GetBeginSkillLineAbilityMap(spell_id); - SkillLineAbilityMap::const_iterator upper = spellmgr.GetEndSkillLineAbilityMap(spell_id); - - for(SkillLineAbilityMap::const_iterator _spell_idx = lower; _spell_idx != upper; ++_spell_idx) - { - SkillLineEntry const *pSkill = sSkillLineStore.LookupEntry(_spell_idx->second->skillId); - if(!pSkill) - continue; - - if(_spell_idx->second->learnOnGetSkill == ABILITY_LEARNED_ON_GET_RACE_OR_CLASS_SKILL || - // poison special case, not have ABILITY_LEARNED_ON_GET_RACE_OR_CLASS_SKILL - pSkill->id==SKILL_POISONS && _spell_idx->second->max_value==0 || - // lockpicking special case, not have ABILITY_LEARNED_ON_GET_RACE_OR_CLASS_SKILL - pSkill->id==SKILL_LOCKPICKING && _spell_idx->second->max_value==0 ) - { - // not reset skills for professions and racial abilities - if( (pSkill->categoryId==SKILL_CATEGORY_SECONDARY || pSkill->categoryId==SKILL_CATEGORY_PROFESSION) && - (IsProfessionSkill(pSkill->id) || _spell_idx->second->racemask!=0) ) - continue; - - SetSkill(pSkill->id, 0, 0 ); - } - } - } - - // remove dependent spells - SpellLearnSpellMap::const_iterator spell_begin = spellmgr.GetBeginSpellLearnSpell(spell_id); - SpellLearnSpellMap::const_iterator spell_end = spellmgr.GetEndSpellLearnSpell(spell_id); - - for(SpellLearnSpellMap::const_iterator itr2 = spell_begin; itr2 != spell_end; ++itr2) - removeSpell(itr2->second.spell, disabled); -} - -void Player::RemoveArenaSpellCooldowns() -{ - // remove cooldowns on spells that has < 15 min CD - SpellCooldowns::iterator itr, next; - // iterate spell cooldowns - for(itr = m_spellCooldowns.begin();itr != m_spellCooldowns.end(); itr = next) - { - next = itr; - ++next; - SpellEntry const * entry = sSpellStore.LookupEntry(itr->first); - // check if spellentry is present and if the cooldown is less than 15 mins - if( entry && - entry->RecoveryTime <= 15 * MINUTE * 1000 && - entry->CategoryRecoveryTime <= 15 * MINUTE * 1000 ) - { - // notify player - WorldPacket data(SMSG_CLEAR_COOLDOWN, (4+8)); - data << uint32(itr->first); - data << GetGUID(); - GetSession()->SendPacket(&data); - // remove cooldown - m_spellCooldowns.erase(itr); - } - } -} - -void Player::RemoveAllSpellCooldown() -{ - if(!m_spellCooldowns.empty()) - { - for(SpellCooldowns::const_iterator itr = m_spellCooldowns.begin();itr != m_spellCooldowns.end(); ++itr) - { - WorldPacket data(SMSG_CLEAR_COOLDOWN, (4+8)); - data << uint32(itr->first); - data << uint64(GetGUID()); - GetSession()->SendPacket(&data); - } - m_spellCooldowns.clear(); - } -} - -void Player::_LoadSpellCooldowns(QueryResult *result) -{ - m_spellCooldowns.clear(); - - //QueryResult *result = CharacterDatabase.PQuery("SELECT spell,item,time FROM character_spell_cooldown WHERE guid = '%u'",GetGUIDLow()); - - if(result) - { - time_t curTime = time(NULL); - - do - { - Field *fields = result->Fetch(); - - uint32 spell_id = fields[0].GetUInt32(); - uint32 item_id = fields[1].GetUInt32(); - time_t db_time = (time_t)fields[2].GetUInt64(); - - if(!sSpellStore.LookupEntry(spell_id)) - { - sLog.outError("Player %u have unknown spell %u in `character_spell_cooldown`, skipping.",GetGUIDLow(),spell_id); - continue; - } - - // skip outdated cooldown - if(db_time <= curTime) - continue; - - AddSpellCooldown(spell_id, item_id, db_time); - - sLog.outDebug("Player (GUID: %u) spell %u, item %u cooldown loaded (%u secs).", GetGUIDLow(), spell_id, item_id, uint32(db_time-curTime)); - } - while( result->NextRow() ); - - delete result; - } -} - -void Player::_SaveSpellCooldowns() -{ - CharacterDatabase.PExecute("DELETE FROM character_spell_cooldown WHERE guid = '%u'", GetGUIDLow()); - - time_t curTime = time(NULL); - - // remove outdated and save active - for(SpellCooldowns::iterator itr = m_spellCooldowns.begin();itr != m_spellCooldowns.end();) - { - if(itr->second.end <= curTime) - m_spellCooldowns.erase(itr++); - else - { - CharacterDatabase.PExecute("INSERT INTO character_spell_cooldown (guid,spell,item,time) VALUES ('%u', '%u', '%u', '" I64FMTD "')", GetGUIDLow(), itr->first, itr->second.itemid, uint64(itr->second.end)); - ++itr; - } - } -} - -uint32 Player::resetTalentsCost() const -{ - // The first time reset costs 1 gold - if(m_resetTalentsCost < 1*GOLD) - return 1*GOLD; - // then 5 gold - else if(m_resetTalentsCost < 5*GOLD) - return 5*GOLD; - // After that it increases in increments of 5 gold - else if(m_resetTalentsCost < 10*GOLD) - return 10*GOLD; - else - { - uint32 months = (sWorld.GetGameTime() - m_resetTalentsTime)/MONTH; - if(months > 0) - { - // This cost will be reduced by a rate of 5 gold per month - int32 new_cost = int32(m_resetTalentsCost) - 5*GOLD*months; - // to a minimum of 10 gold. - return (new_cost < 10*GOLD ? 10*GOLD : new_cost); - } - else - { - // After that it increases in increments of 5 gold - int32 new_cost = m_resetTalentsCost + 5*GOLD; - // until it hits a cap of 50 gold. - if(new_cost > 50*GOLD) - new_cost = 50*GOLD; - return new_cost; - } - } -} - -bool Player::resetTalents(bool no_cost) -{ - // not need after this call - if(HasAtLoginFlag(AT_LOGIN_RESET_TALENTS)) - { - m_atLoginFlags = m_atLoginFlags & ~AT_LOGIN_RESET_TALENTS; - CharacterDatabase.PExecute("UPDATE characters set at_login = at_login & ~ %u WHERE guid ='%u'", uint32(AT_LOGIN_RESET_TALENTS), GetGUIDLow()); - } - - uint32 level = getLevel(); - uint32 talentPointsForLevel = level < 10 ? 0 : uint32((level-9)*sWorld.getRate(RATE_TALENT)); - - if (m_usedTalentCount == 0) - { - SetFreeTalentPoints(talentPointsForLevel); - return false; - } - - uint32 cost = 0; - - if(!no_cost) - { - cost = resetTalentsCost(); - - if (GetMoney() < cost) - { - SendBuyError( BUY_ERR_NOT_ENOUGHT_MONEY, 0, 0, 0); - return false; - } - } - - for (unsigned int i = 0; i < sTalentStore.GetNumRows(); i++) - { - TalentEntry const *talentInfo = sTalentStore.LookupEntry(i); - - if (!talentInfo) continue; - - TalentTabEntry const *talentTabInfo = sTalentTabStore.LookupEntry( talentInfo->TalentTab ); - - if(!talentTabInfo) - continue; - - // unlearn only talents for character class - // some spell learned by one class as normal spells or know at creation but another class learn it as talent, - // to prevent unexpected lost normal learned spell skip another class talents - if( (getClassMask() & talentTabInfo->ClassMask) == 0 ) - continue; - - for (int j = 0; j < 5; j++) - { - for(PlayerSpellMap::iterator itr = GetSpellMap().begin(); itr != GetSpellMap().end();) - { - if(itr->second->state == PLAYERSPELL_REMOVED || itr->second->disabled) - { - ++itr; - continue; - } - - // remove learned spells (all ranks) - uint32 itrFirstId = spellmgr.GetFirstSpellInChain(itr->first); - - // unlearn if first rank is talent or learned by talent - if (itrFirstId == talentInfo->RankID[j] || spellmgr.IsSpellLearnToSpell(talentInfo->RankID[j],itrFirstId)) - { - removeSpell(itr->first,!IsPassiveSpell(itr->first)); - itr = GetSpellMap().begin(); - continue; - } - else - ++itr; - } - } - } - - SetFreeTalentPoints(talentPointsForLevel); - - if(!no_cost) - { - ModifyMoney(-(int32)cost); - - m_resetTalentsCost = cost; - m_resetTalentsTime = time(NULL); - } - - //FIXME: remove pet before or after unlearn spells? for now after unlearn to allow removing of talent related, pet affecting auras - RemovePet(NULL,PET_SAVE_NOT_IN_SLOT, true); - - return true; -} - -bool Player::_removeSpell(uint16 spell_id) -{ - PlayerSpellMap::iterator itr = m_spells.find(spell_id); - if (itr != m_spells.end()) - { - delete itr->second; - m_spells.erase(itr); - return true; - } - return false; -} - -Mail* Player::GetMail(uint32 id) -{ - for(PlayerMails::iterator itr = m_mail.begin(); itr != m_mail.end(); itr++) - { - if ((*itr)->messageID == id) - { - return (*itr); - } - } - return NULL; -} - -void Player::_SetCreateBits(UpdateMask *updateMask, Player *target) const -{ - if(target == this) - { - Object::_SetCreateBits(updateMask, target); - } - else - { - for(uint16 index = 0; index < m_valuesCount; index++) - { - if(GetUInt32Value(index) != 0 && updateVisualBits.GetBit(index)) - updateMask->SetBit(index); - } - } -} - -void Player::_SetUpdateBits(UpdateMask *updateMask, Player *target) const -{ - if(target == this) - { - Object::_SetUpdateBits(updateMask, target); - } - else - { - Object::_SetUpdateBits(updateMask, target); - *updateMask &= updateVisualBits; - } -} - -void Player::InitVisibleBits() -{ - updateVisualBits.SetCount(PLAYER_END); - - updateVisualBits.SetBit(OBJECT_FIELD_GUID); - updateVisualBits.SetBit(OBJECT_FIELD_TYPE); - updateVisualBits.SetBit(OBJECT_FIELD_SCALE_X); - - updateVisualBits.SetBit(UNIT_FIELD_CHARM); - updateVisualBits.SetBit(UNIT_FIELD_CHARM+1); - - updateVisualBits.SetBit(UNIT_FIELD_SUMMON); - updateVisualBits.SetBit(UNIT_FIELD_SUMMON+1); - - updateVisualBits.SetBit(UNIT_FIELD_CHARMEDBY); - - updateVisualBits.SetBit(UNIT_FIELD_TARGET); - updateVisualBits.SetBit(UNIT_FIELD_TARGET+1); - - updateVisualBits.SetBit(UNIT_FIELD_CHANNEL_OBJECT); - updateVisualBits.SetBit(UNIT_FIELD_CHANNEL_OBJECT+1); - - updateVisualBits.SetBit(UNIT_FIELD_HEALTH); - updateVisualBits.SetBit(UNIT_FIELD_POWER1); - updateVisualBits.SetBit(UNIT_FIELD_POWER2); - updateVisualBits.SetBit(UNIT_FIELD_POWER3); - updateVisualBits.SetBit(UNIT_FIELD_POWER4); - updateVisualBits.SetBit(UNIT_FIELD_POWER5); - - updateVisualBits.SetBit(UNIT_FIELD_MAXHEALTH); - updateVisualBits.SetBit(UNIT_FIELD_MAXPOWER1); - updateVisualBits.SetBit(UNIT_FIELD_MAXPOWER2); - updateVisualBits.SetBit(UNIT_FIELD_MAXPOWER3); - updateVisualBits.SetBit(UNIT_FIELD_MAXPOWER4); - updateVisualBits.SetBit(UNIT_FIELD_MAXPOWER5); - - updateVisualBits.SetBit(UNIT_FIELD_LEVEL); - updateVisualBits.SetBit(UNIT_FIELD_FACTIONTEMPLATE); - updateVisualBits.SetBit(UNIT_FIELD_BYTES_0); - updateVisualBits.SetBit(UNIT_FIELD_FLAGS); - updateVisualBits.SetBit(UNIT_FIELD_FLAGS_2); - for(uint16 i = UNIT_FIELD_AURA; i < UNIT_FIELD_AURASTATE; ++i) - updateVisualBits.SetBit(i); - updateVisualBits.SetBit(UNIT_FIELD_AURASTATE); - updateVisualBits.SetBit(UNIT_FIELD_BASEATTACKTIME); - updateVisualBits.SetBit(UNIT_FIELD_BASEATTACKTIME + 1); - updateVisualBits.SetBit(UNIT_FIELD_RANGEDATTACKTIME); - updateVisualBits.SetBit(UNIT_FIELD_BOUNDINGRADIUS); - updateVisualBits.SetBit(UNIT_FIELD_COMBATREACH); - updateVisualBits.SetBit(UNIT_FIELD_DISPLAYID); - updateVisualBits.SetBit(UNIT_FIELD_NATIVEDISPLAYID); - updateVisualBits.SetBit(UNIT_FIELD_MOUNTDISPLAYID); - updateVisualBits.SetBit(UNIT_FIELD_BYTES_1); - updateVisualBits.SetBit(UNIT_FIELD_MOUNTDISPLAYID); - updateVisualBits.SetBit(UNIT_FIELD_PETNUMBER); - updateVisualBits.SetBit(UNIT_FIELD_PET_NAME_TIMESTAMP); - updateVisualBits.SetBit(UNIT_DYNAMIC_FLAGS); - updateVisualBits.SetBit(UNIT_CHANNEL_SPELL); - updateVisualBits.SetBit(UNIT_MOD_CAST_SPEED); - updateVisualBits.SetBit(UNIT_FIELD_BYTES_2); - - updateVisualBits.SetBit(PLAYER_FLAGS); - updateVisualBits.SetBit(PLAYER_BYTES); - updateVisualBits.SetBit(PLAYER_BYTES_2); - updateVisualBits.SetBit(PLAYER_BYTES_3); - updateVisualBits.SetBit(PLAYER_GUILDID); - updateVisualBits.SetBit(PLAYER_GUILDRANK); - updateVisualBits.SetBit(PLAYER_GUILD_TIMESTAMP); - updateVisualBits.SetBit(PLAYER_DUEL_TEAM); - updateVisualBits.SetBit(PLAYER_DUEL_ARBITER); - updateVisualBits.SetBit(PLAYER_DUEL_ARBITER+1); - - // PLAYER_QUEST_LOG_x also visible bit on official (but only on party/raid)... - for(uint16 i = PLAYER_QUEST_LOG_1_1; i < PLAYER_QUEST_LOG_25_2; i+=4) - updateVisualBits.SetBit(i); - - for(uint16 i = 0; i < INVENTORY_SLOT_BAG_END; i++) - { - updateVisualBits.SetBit((uint16)(PLAYER_FIELD_INV_SLOT_HEAD + i*2)); - updateVisualBits.SetBit((uint16)(PLAYER_FIELD_INV_SLOT_HEAD + (i*2) + 1)); - } - //Players visible items are not inventory stuff - //431) = 884 (0x374) = main weapon - for(uint16 i = 0; i < EQUIPMENT_SLOT_END; i++) - { - // item creator - updateVisualBits.SetBit(PLAYER_VISIBLE_ITEM_1_CREATOR + (i*MAX_VISIBLE_ITEM_OFFSET) + 0); - updateVisualBits.SetBit(PLAYER_VISIBLE_ITEM_1_CREATOR + (i*MAX_VISIBLE_ITEM_OFFSET) + 1); - - uint16 visual_base = PLAYER_VISIBLE_ITEM_1_0 + (i*MAX_VISIBLE_ITEM_OFFSET); - - // item entry - updateVisualBits.SetBit(visual_base + 0); - - // item enchantment IDs - for(uint8 j = 0; j < MAX_INSPECTED_ENCHANTMENT_SLOT; ++j) - updateVisualBits.SetBit(visual_base + 1 + j); - - // random properties - updateVisualBits.SetBit(PLAYER_VISIBLE_ITEM_1_PROPERTIES + 0 + (i*MAX_VISIBLE_ITEM_OFFSET)); - updateVisualBits.SetBit(PLAYER_VISIBLE_ITEM_1_PROPERTIES + 1 + (i*MAX_VISIBLE_ITEM_OFFSET)); - } - - updateVisualBits.SetBit(PLAYER_CHOSEN_TITLE); - - updateVisualBits.SetBit(UNIT_VIRTUAL_ITEM_SLOT_DISPLAY); - updateVisualBits.SetBit(UNIT_VIRTUAL_ITEM_SLOT_DISPLAY + 1); - updateVisualBits.SetBit(UNIT_VIRTUAL_ITEM_SLOT_DISPLAY + 2); - updateVisualBits.SetBit(UNIT_VIRTUAL_ITEM_INFO); - updateVisualBits.SetBit(UNIT_VIRTUAL_ITEM_INFO + 1); - updateVisualBits.SetBit(UNIT_VIRTUAL_ITEM_INFO + 2); - updateVisualBits.SetBit(UNIT_VIRTUAL_ITEM_INFO + 3); - updateVisualBits.SetBit(UNIT_VIRTUAL_ITEM_INFO + 4); - updateVisualBits.SetBit(UNIT_VIRTUAL_ITEM_INFO + 5); -} - -void Player::BuildCreateUpdateBlockForPlayer( UpdateData *data, Player *target ) const -{ - for(int i = 0; i < EQUIPMENT_SLOT_END; i++) - { - if(m_items[i] == NULL) - continue; - - m_items[i]->BuildCreateUpdateBlockForPlayer( data, target ); - } - - if(target == this) - { - - for(int i = INVENTORY_SLOT_BAG_START; i < BANK_SLOT_BAG_END; i++) - { - if(m_items[i] == NULL) - continue; - - m_items[i]->BuildCreateUpdateBlockForPlayer( data, target ); - } - for(int i = KEYRING_SLOT_START; i < KEYRING_SLOT_END; i++) - { - if(m_items[i] == NULL) - continue; - - m_items[i]->BuildCreateUpdateBlockForPlayer( data, target ); - } - } - - Unit::BuildCreateUpdateBlockForPlayer( data, target ); -} - -void Player::DestroyForPlayer( Player *target ) const -{ - Unit::DestroyForPlayer( target ); - - for(int i = 0; i < INVENTORY_SLOT_BAG_END; i++) - { - if(m_items[i] == NULL) - continue; - - m_items[i]->DestroyForPlayer( target ); - } - - if(target == this) - { - - for(int i = INVENTORY_SLOT_BAG_START; i < BANK_SLOT_BAG_END; i++) - { - if(m_items[i] == NULL) - continue; - - m_items[i]->DestroyForPlayer( target ); - } - for(int i = KEYRING_SLOT_START; i < KEYRING_SLOT_END; i++) - { - if(m_items[i] == NULL) - continue; - - m_items[i]->DestroyForPlayer( target ); - } - } -} - -bool Player::HasSpell(uint32 spell) const -{ - PlayerSpellMap::const_iterator itr = m_spells.find((uint16)spell); - return (itr != m_spells.end() && itr->second->state != PLAYERSPELL_REMOVED && !itr->second->disabled); -} - -TrainerSpellState Player::GetTrainerSpellState(TrainerSpell const* trainer_spell) const -{ - if (!trainer_spell) - return TRAINER_SPELL_RED; - - if (!trainer_spell->spell) - return TRAINER_SPELL_RED; - - // known spell - if(HasSpell(trainer_spell->spell->Id)) - return TRAINER_SPELL_GRAY; - - // check race/class requirement - if(!IsSpellFitByClassAndRace(trainer_spell->spell->Id)) - return TRAINER_SPELL_RED; - - // check level requirement - if(getLevel() < ( trainer_spell->reqlevel ? trainer_spell->reqlevel : trainer_spell->spell->spellLevel)) - return TRAINER_SPELL_RED; - - if(SpellChainNode const* spell_chain = spellmgr.GetSpellChainNode(trainer_spell->spell->Id)) - { - // check prev.rank requirement - if(spell_chain->prev && !HasSpell(spell_chain->prev)) - return TRAINER_SPELL_RED; - - // check additional spell requirement - if(spell_chain->req && !HasSpell(spell_chain->req)) - return TRAINER_SPELL_RED; - } - - // check skill requirement - if(trainer_spell->reqskill && GetBaseSkillValue(trainer_spell->reqskill) < trainer_spell->reqskillvalue) - return TRAINER_SPELL_RED; - - // secondary prof. or not prof. spell - uint32 skill = trainer_spell->spell->EffectMiscValue[1]; - - if(trainer_spell->spell->Effect[1] != SPELL_EFFECT_SKILL || !IsPrimaryProfessionSkill(skill)) - return TRAINER_SPELL_GREEN; - - // check primary prof. limit - if(spellmgr.IsPrimaryProfessionFirstRankSpell(trainer_spell->spell->Id) && GetFreePrimaryProffesionPoints() == 0) - return TRAINER_SPELL_RED; - - return TRAINER_SPELL_GREEN; -} - -void Player::DeleteFromDB(uint64 playerguid, uint32 accountId, bool updateRealmChars) -{ - uint32 guid = GUID_LOPART(playerguid); - - // convert corpse to bones if exist (to prevent exiting Corpse in World without DB entry) - // bones will be deleted by corpse/bones deleting thread shortly - ObjectAccessor::Instance().ConvertCorpseForPlayer(playerguid); - - // remove from guild - uint32 guildId = GetGuildIdFromDB(playerguid); - if(guildId != 0) - { - Guild* guild = objmgr.GetGuildById(guildId); - if(guild) - guild->DelMember(guid); - } - - // the player was uninvited already on logout so just remove from group - QueryResult *resultGroup = CharacterDatabase.PQuery("SELECT leaderGuid FROM group_member WHERE memberGuid='%u'", guid); - if(resultGroup) - { - uint64 leaderGuid = MAKE_NEW_GUID((*resultGroup)[0].GetUInt32(), 0, HIGHGUID_PLAYER); - delete resultGroup; - Group* group = objmgr.GetGroupByLeader(leaderGuid); - if(group) - { - RemoveFromGroup(group, playerguid); - } - } - - // remove signs from petitions (also remove petitions if owner); - RemovePetitionsAndSigns(playerguid, 10); - - // return back all mails with COD and Item 0 1 2 3 4 5 6 - QueryResult *resultMail = CharacterDatabase.PQuery("SELECT id,mailTemplateId,sender,subject,itemTextId,money,has_items FROM mail WHERE receiver='%u' AND has_items<>0 AND cod<>0", guid); - if(resultMail) - { - do - { - Field *fields = resultMail->Fetch(); - - uint32 mail_id = fields[0].GetUInt32(); - uint16 mailTemplateId= fields[1].GetUInt16(); - uint32 sender = fields[2].GetUInt32(); - std::string subject = fields[3].GetCppString(); - uint32 itemTextId = fields[4].GetUInt32(); - uint32 money = fields[5].GetUInt32(); - bool has_items = fields[6].GetBool(); - - //we can return mail now - //so firstly delete the old one - CharacterDatabase.PExecute("DELETE FROM mail WHERE id = '%u'", mail_id); - - MailItemsInfo mi; - if(has_items) - { - QueryResult *resultItems = CharacterDatabase.PQuery("SELECT item_guid,item_template FROM mail_items WHERE mail_id='%u'", mail_id); - if(resultItems) - { - do - { - Field *fields2 = resultItems->Fetch(); - - uint32 item_guidlow = fields2[0].GetUInt32(); - uint32 item_template = fields2[1].GetUInt32(); - - ItemPrototype const* itemProto = objmgr.GetItemPrototype(item_template); - if(!itemProto) - { - CharacterDatabase.PExecute("DELETE FROM item_instance WHERE guid = '%u'", item_guidlow); - continue; - } - - Item *pItem = NewItemOrBag(itemProto); - if(!pItem->LoadFromDB(item_guidlow, MAKE_NEW_GUID(guid, 0, HIGHGUID_PLAYER))) - { - pItem->FSetState(ITEM_REMOVED); - pItem->SaveToDB(); // it also deletes item object ! - continue; - } - - mi.AddItem(item_guidlow, item_template, pItem); - } - while (resultItems->NextRow()); - - delete resultItems; - } - } - - CharacterDatabase.PExecute("DELETE FROM mail_items WHERE mail_id = '%u'", mail_id); - - uint32 pl_account = objmgr.GetPlayerAccountIdByGUID(MAKE_NEW_GUID(guid, 0, HIGHGUID_PLAYER)); - - WorldSession::SendReturnToSender(MAIL_NORMAL, pl_account, guid, sender, subject, itemTextId, &mi, money, 0, mailTemplateId); - } - while (resultMail->NextRow()); - - delete resultMail; - } - - // unsummon and delete for pets in world is not required: player deleted from CLI or character list with not loaded pet. - // Get guids of character's pets, will deleted in transaction - QueryResult *resultPets = CharacterDatabase.PQuery("SELECT id FROM character_pet WHERE owner = '%u'",guid); - - // NOW we can finally clear other DB data related to character - CharacterDatabase.BeginTransaction(); - if (resultPets) - { - do - { - Field *fields3 = resultPets->Fetch(); - uint32 petguidlow = fields3[0].GetUInt32(); - Pet::DeleteFromDB(petguidlow); - } while (resultPets->NextRow()); - delete resultPets; - } - - CharacterDatabase.PExecute("DELETE FROM characters WHERE guid = '%u'",guid); - CharacterDatabase.PExecute("DELETE FROM character_declinedname WHERE guid = '%u'",guid); - CharacterDatabase.PExecute("DELETE FROM character_action WHERE guid = '%u'",guid); - CharacterDatabase.PExecute("DELETE FROM character_aura WHERE guid = '%u'",guid); - CharacterDatabase.PExecute("DELETE FROM character_gifts WHERE guid = '%u'",guid); - CharacterDatabase.PExecute("DELETE FROM character_homebind WHERE guid = '%u'",guid); - CharacterDatabase.PExecute("DELETE FROM character_instance WHERE guid = '%u'",guid); - CharacterDatabase.PExecute("DELETE FROM group_instance WHERE leaderGuid = '%u'",guid); - CharacterDatabase.PExecute("DELETE FROM character_inventory WHERE guid = '%u'",guid); - CharacterDatabase.PExecute("DELETE FROM character_queststatus WHERE guid = '%u'",guid); - CharacterDatabase.PExecute("DELETE FROM character_reputation WHERE guid = '%u'",guid); - CharacterDatabase.PExecute("DELETE FROM character_spell WHERE guid = '%u'",guid); - CharacterDatabase.PExecute("DELETE FROM character_spell_cooldown WHERE guid = '%u'",guid); - CharacterDatabase.PExecute("DELETE FROM character_ticket WHERE guid = '%u'",guid); - CharacterDatabase.PExecute("DELETE FROM item_instance WHERE owner_guid = '%u'",guid); - CharacterDatabase.PExecute("DELETE FROM character_social WHERE guid = '%u' OR friend='%u'",guid,guid); - CharacterDatabase.PExecute("DELETE FROM mail WHERE receiver = '%u'",guid); - CharacterDatabase.PExecute("DELETE FROM mail_items WHERE receiver = '%u'",guid); - CharacterDatabase.PExecute("DELETE FROM character_pet WHERE owner = '%u'",guid); - CharacterDatabase.PExecute("DELETE FROM character_pet_declinedname WHERE owner = '%u'",guid); - CharacterDatabase.CommitTransaction(); - - //loginDatabase.PExecute("UPDATE realmcharacters SET numchars = numchars - 1 WHERE acctid = %d AND realmid = %d", accountId, realmID); - if(updateRealmChars) sWorld.UpdateRealmCharCount(accountId); -} - -void Player::SetMovement(PlayerMovementType pType) -{ - WorldPacket data; - switch(pType) - { - case MOVE_ROOT: data.Initialize(SMSG_FORCE_MOVE_ROOT, GetPackGUID().size()+4); break; - case MOVE_UNROOT: data.Initialize(SMSG_FORCE_MOVE_UNROOT, GetPackGUID().size()+4); break; - case MOVE_WATER_WALK: data.Initialize(SMSG_MOVE_WATER_WALK, GetPackGUID().size()+4); break; - case MOVE_LAND_WALK: data.Initialize(SMSG_MOVE_LAND_WALK, GetPackGUID().size()+4); break; - default: - sLog.outError("Player::SetMovement: Unsupported move type (%d), data not sent to client.",pType); - return; - } - data.append(GetPackGUID()); - data << uint32(0); - GetSession()->SendPacket( &data ); -} - -/* Preconditions: - - a resurrectable corpse must not be loaded for the player (only bones) - - the player must be in world -*/ -void Player::BuildPlayerRepop() -{ - if(getRace() == RACE_NIGHTELF) - CastSpell(this, 20584, true); // auras SPELL_AURA_INCREASE_SPEED(+speed in wisp form), SPELL_AURA_INCREASE_SWIM_SPEED(+swim speed in wisp form), SPELL_AURA_TRANSFORM (to wisp form) - CastSpell(this, 8326, true); // auras SPELL_AURA_GHOST, SPELL_AURA_INCREASE_SPEED(why?), SPELL_AURA_INCREASE_SWIM_SPEED(why?) - - // there must be SMSG.FORCE_RUN_SPEED_CHANGE, SMSG.FORCE_SWIM_SPEED_CHANGE, SMSG.MOVE_WATER_WALK - // there must be SMSG.STOP_MIRROR_TIMER - // there we must send 888 opcode - - // the player cannot have a corpse already, only bones which are not returned by GetCorpse - if(GetCorpse()) - { - sLog.outError("BuildPlayerRepop: player %s(%d) already has a corpse", GetName(), GetGUIDLow()); - assert(false); - } - - // create a corpse and place it at the player's location - CreateCorpse(); - Corpse *corpse = GetCorpse(); - if(!corpse) - { - sLog.outError("Error creating corpse for Player %s [%u]", GetName(), GetGUIDLow()); - return; - } - GetMap()->Add(corpse); - - // convert player body to ghost - SetHealth( 1 ); - - SetMovement(MOVE_WATER_WALK); - if(!GetSession()->isLogingOut()) - SetMovement(MOVE_UNROOT); - - // BG - remove insignia related - RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SKINNABLE); - - SendCorpseReclaimDelay(); - - // to prevent cheating - corpse->ResetGhostTime(); - - StopMirrorTimers(); //disable timers(bars) - - SetFloatValue(UNIT_FIELD_BOUNDINGRADIUS, (float)1.0); //see radius of death player? - - SetByteValue(UNIT_FIELD_BYTES_1, 3, PLAYER_STATE_FLAG_ALWAYS_STAND); -} - -void Player::SendDelayResponse(const uint32 ml_seconds) -{ - WorldPacket data( SMSG_QUERY_TIME_RESPONSE, 4+4 ); - data << (uint32)time(NULL); - data << (uint32)0; - GetSession()->SendPacket( &data ); -} - -void Player::ResurrectPlayer(float restore_percent, bool updateToWorld, bool applySickness) -{ - WorldPacket data(SMSG_DEATH_RELEASE_LOC, 4*4); // remove spirit healer position - data << uint32(-1); - data << float(0); - data << float(0); - data << float(0); - GetSession()->SendPacket(&data); - - // speed change, land walk - - // remove death flag + set aura - SetByteValue(UNIT_FIELD_BYTES_1, 3, 0x00); - if(getRace() == RACE_NIGHTELF) - RemoveAurasDueToSpell(20584); // speed bonuses - RemoveAurasDueToSpell(8326); // SPELL_AURA_GHOST - - setDeathState(ALIVE); - - SetMovement(MOVE_LAND_WALK); - SetMovement(MOVE_UNROOT); - - m_deathTimer = 0; - - // set health/powers (0- will be set in caller) - if(restore_percent>0.0f) - { - SetHealth(uint32(GetMaxHealth()*restore_percent)); - SetPower(POWER_MANA, uint32(GetMaxPower(POWER_MANA)*restore_percent)); - SetPower(POWER_RAGE, 0); - SetPower(POWER_ENERGY, uint32(GetMaxPower(POWER_ENERGY)*restore_percent)); - } - - // update visbility - ObjectAccessor::UpdateVisibilityForPlayer(this); - - // some items limited to specific map - DestroyZoneLimitedItem( true, GetZoneId()); - - if(!applySickness || getLevel() <= 10) - return; - - //Characters from level 1-10 are not affected by resurrection sickness. - //Characters from level 11-19 will suffer from one minute of sickness - //for each level they are above 10. - //Characters level 20 and up suffer from ten minutes of sickness. - int32 startLevel = sWorld.getConfig(CONFIG_DEATH_SICKNESS_LEVEL); - - if(int32(getLevel()) >= startLevel) - { - // set resurrection sickness - CastSpell(this,SPELL_ID_PASSIVE_RESURRECTION_SICKNESS,true); - - // not full duration - if(int32(getLevel()) < startLevel+9) - { - int32 delta = (int32(getLevel()) - startLevel + 1)*MINUTE; - - for(int i =0; i < 3; ++i) - { - if(Aura* Aur = GetAura(SPELL_ID_PASSIVE_RESURRECTION_SICKNESS,i)) - { - Aur->SetAuraDuration(delta*1000); - Aur->UpdateAuraDuration(); - } - } - } - } -} - -void Player::KillPlayer() -{ - SetMovement(MOVE_ROOT); - - StopMirrorTimers(); //disable timers(bars) - - setDeathState(CORPSE); - //SetFlag( UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_IN_PVP ); - - SetFlag(UNIT_DYNAMIC_FLAGS, 0x00); - ApplyModFlag(PLAYER_FIELD_BYTES, PLAYER_FIELD_BYTE_RELEASE_TIMER, !sMapStore.LookupEntry(GetMapId())->Instanceable()); - - // 6 minutes until repop at graveyard - m_deathTimer = 6*MINUTE*1000; - - UpdateCorpseReclaimDelay(); // dependent at use SetDeathPvP() call before kill - - // don't create corpse at this moment, player might be falling - - // update visibility - ObjectAccessor::UpdateObjectVisibility(this); -} - -void Player::CreateCorpse() -{ - // prevent existence 2 corpse for player - SpawnCorpseBones(); - - uint32 _uf, _pb, _pb2, _cfb1, _cfb2; - - Corpse *corpse = new Corpse( (m_ExtraFlags & PLAYER_EXTRA_PVP_DEATH) ? CORPSE_RESURRECTABLE_PVP : CORPSE_RESURRECTABLE_PVE ); - SetPvPDeath(false); - - if(!corpse->Create(objmgr.GenerateLowGuid(HIGHGUID_CORPSE), this, GetMapId(), GetPositionX(), - GetPositionY(), GetPositionZ(), GetOrientation())) - { - delete corpse; - return; - } - - _uf = GetUInt32Value(UNIT_FIELD_BYTES_0); - _pb = GetUInt32Value(PLAYER_BYTES); - _pb2 = GetUInt32Value(PLAYER_BYTES_2); - - uint8 race = (uint8)(_uf); - uint8 skin = (uint8)(_pb); - uint8 face = (uint8)(_pb >> 8); - uint8 hairstyle = (uint8)(_pb >> 16); - uint8 haircolor = (uint8)(_pb >> 24); - uint8 facialhair = (uint8)(_pb2); - - _cfb1 = ((0x00) | (race << 8) | (getGender() << 16) | (skin << 24)); - _cfb2 = ((face) | (hairstyle << 8) | (haircolor << 16) | (facialhair << 24)); - - corpse->SetUInt32Value( CORPSE_FIELD_BYTES_1, _cfb1 ); - corpse->SetUInt32Value( CORPSE_FIELD_BYTES_2, _cfb2 ); - - uint32 flags = CORPSE_FLAG_UNK2; - if(HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_HIDE_HELM)) - flags |= CORPSE_FLAG_HIDE_HELM; - if(HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_HIDE_CLOAK)) - flags |= CORPSE_FLAG_HIDE_CLOAK; - if(InBattleGround()) - flags |= CORPSE_FLAG_LOOTABLE; // to be able to remove insignia - corpse->SetUInt32Value( CORPSE_FIELD_FLAGS, flags ); - - corpse->SetUInt32Value( CORPSE_FIELD_DISPLAY_ID, GetNativeDisplayId() ); - - corpse->SetUInt32Value( CORPSE_FIELD_GUILD, GetGuildId() ); - - uint32 iDisplayID; - uint16 iIventoryType; - uint32 _cfi; - for (int i = 0; i < EQUIPMENT_SLOT_END; i++) - { - if(m_items[i]) - { - iDisplayID = m_items[i]->GetProto()->DisplayInfoID; - iIventoryType = (uint16)m_items[i]->GetProto()->InventoryType; - - _cfi = (uint16(iDisplayID)) | (iIventoryType)<< 24; - corpse->SetUInt32Value(CORPSE_FIELD_ITEM + i,_cfi); - } - } - - // we don't SaveToDB for players in battlegrounds so don't do it for corpses either - const MapEntry *entry = sMapStore.LookupEntry(corpse->GetMapId()); - assert(entry); - if(entry->map_type != MAP_BATTLEGROUND) - corpse->SaveToDB(); - - // register for player, but not show - ObjectAccessor::Instance().AddCorpse(corpse); -} - -void Player::SpawnCorpseBones() -{ - if(ObjectAccessor::Instance().ConvertCorpseForPlayer(GetGUID())) - SaveToDB(); // prevent loading as ghost without corpse -} - -Corpse* Player::GetCorpse() const -{ - return ObjectAccessor::Instance().GetCorpseForPlayerGUID(GetGUID()); -} - -void Player::DurabilityLossAll(double percent, bool inventory) -{ - for(int i = EQUIPMENT_SLOT_START; i < EQUIPMENT_SLOT_END; i++) - if(Item *pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i )) - DurabilityLoss(pItem,percent); - - if(inventory) - { - // bags not have durability - // for(int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; i++) - - for(int i = INVENTORY_SLOT_ITEM_START; i < INVENTORY_SLOT_ITEM_END; i++) - if(Item *pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i )) - DurabilityLoss(pItem,percent); - - // keys not have durability - //for(int i = KEYRING_SLOT_START; i < KEYRING_SLOT_END; i++) - - for(int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; i++) - if(Bag* pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i )) - if(ItemPrototype const *pBagProto = pBag->GetProto()) - for(uint32 j = 0; j < pBagProto->ContainerSlots; j++) - if(Item* pItem = GetItemByPos( i, j )) - DurabilityLoss(pItem,percent); - } -} - -void Player::DurabilityLoss(Item* item, double percent) -{ - if(!item ) - return; - - uint32 pMaxDurability = item ->GetUInt32Value(ITEM_FIELD_MAXDURABILITY); - - if(!pMaxDurability) - return; - - uint32 pDurabilityLoss = uint32(pMaxDurability*percent); - - if(pDurabilityLoss < 1 ) - pDurabilityLoss = 1; - - DurabilityPointsLoss(item,pDurabilityLoss); -} - -void Player::DurabilityPointsLossAll(int32 points, bool inventory) -{ - for(int i = EQUIPMENT_SLOT_START; i < EQUIPMENT_SLOT_END; i++) - if(Item *pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i )) - DurabilityPointsLoss(pItem,points); - - if(inventory) - { - // bags not have durability - // for(int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; i++) - - for(int i = INVENTORY_SLOT_ITEM_START; i < INVENTORY_SLOT_ITEM_END; i++) - if(Item *pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i )) - DurabilityPointsLoss(pItem,points); - - // keys not have durability - //for(int i = KEYRING_SLOT_START; i < KEYRING_SLOT_END; i++) - - for(int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; i++) - if(Bag* pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i )) - if(ItemPrototype const *pBagProto = pBag->GetProto()) - for(uint32 j = 0; j < pBagProto->ContainerSlots; j++) - if(Item* pItem = GetItemByPos( i, j )) - DurabilityPointsLoss(pItem,points); - } -} - -void Player::DurabilityPointsLoss(Item* item, int32 points) -{ - int32 pMaxDurability = item->GetUInt32Value(ITEM_FIELD_MAXDURABILITY); - int32 pOldDurability = item->GetUInt32Value(ITEM_FIELD_DURABILITY); - int32 pNewDurability = pOldDurability - points; - - if (pNewDurability < 0) - pNewDurability = 0; - else if (pNewDurability > pMaxDurability) - pNewDurability = pMaxDurability; - - if (pOldDurability != pNewDurability) - { - // modify item stats _before_ Durability set to 0 to pass _ApplyItemMods internal check - if ( pNewDurability == 0 && pOldDurability > 0 && item->IsEquipped()) - _ApplyItemMods(item,item->GetSlot(), false); - - item->SetUInt32Value(ITEM_FIELD_DURABILITY, pNewDurability); - - // modify item stats _after_ restore durability to pass _ApplyItemMods internal check - if ( pNewDurability > 0 && pOldDurability == 0 && item->IsEquipped()) - _ApplyItemMods(item,item->GetSlot(), true); - - item->SetState(ITEM_CHANGED, this); - } -} - -void Player::DurabilityPointLossForEquipSlot(EquipmentSlots slot) -{ - if(Item *pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, slot )) - DurabilityPointsLoss(pItem,1); -} - -uint32 Player::DurabilityRepairAll(bool cost, float discountMod, bool guildBank) -{ - uint32 TotalCost = 0; - // equipped, backpack, bags itself - for(int i = EQUIPMENT_SLOT_START; i < INVENTORY_SLOT_ITEM_END; i++) - TotalCost += DurabilityRepair(( (INVENTORY_SLOT_BAG_0 << 8) | i ),cost,discountMod, guildBank); - - // bank, buyback and keys not repaired - - // items in inventory bags - for(int j = INVENTORY_SLOT_BAG_START; j < INVENTORY_SLOT_BAG_END; j++) - for(int i = 0; i < MAX_BAG_SIZE; i++) - TotalCost += DurabilityRepair(( (j << 8) | i ),cost,discountMod, guildBank); - return TotalCost; -} - -uint32 Player::DurabilityRepair(uint16 pos, bool cost, float discountMod, bool guildBank) -{ - Item* item = GetItemByPos(pos); - - uint32 TotalCost = 0; - if(!item) - return TotalCost; - - uint32 maxDurability = item->GetUInt32Value(ITEM_FIELD_MAXDURABILITY); - if(!maxDurability) - return TotalCost; - - uint32 curDurability = item->GetUInt32Value(ITEM_FIELD_DURABILITY); - - if(cost) - { - uint32 LostDurability = maxDurability - curDurability; - if(LostDurability>0) - { - ItemPrototype const *ditemProto = sItemStorage.LookupEntry(item->GetEntry()); - if(!ditemProto) - { - sLog.outError("ERROR: RepairDurability: Unknown item id %u", ditemProto); - return TotalCost; - } - - DurabilityCostsEntry const *dcost = sDurabilityCostsStore.LookupEntry(ditemProto->ItemLevel); - if(!dcost) - { - sLog.outError("ERROR: RepairDurability: Wrong item lvl %u", dcost); - return TotalCost; - } - - DurabilityQualityEntry const *dQualitymodEntry = sDurabilityQualityStore.LookupEntry((ditemProto->Quality+1)*2); - if(!dQualitymodEntry) - { - sLog.outError("ERROR: RepairDurability: Wrong dQualityModEntry %u", dQualitymodEntry); - return TotalCost; - } - - uint32 dmultiplier = dcost->multiplier[ItemSubClassToDurabilityMultiplierId(ditemProto->Class,ditemProto->SubClass)]; - uint32 costs = uint32(LostDurability*dmultiplier*double(dQualitymodEntry->quality_mod)); - - costs = uint32(costs * discountMod); - - if (costs==0) //fix for ITEM_QUALITY_ARTIFACT - costs = 1; - - if (guildBank) - { - if (GetGuildId()==0) - { - DEBUG_LOG("You are not member of a guild"); - return TotalCost; - } - - Guild *pGuild = objmgr.GetGuildById(GetGuildId()); - if (!pGuild) - return TotalCost; - - if (!pGuild->HasRankRight(GetRank(), GR_RIGHT_WITHDRAW_REPAIR)) - { - DEBUG_LOG("You do not have rights to withdraw for repairs"); - return TotalCost; - } - - if (pGuild->GetMemberMoneyWithdrawRem(GetGUIDLow()) < costs) - { - DEBUG_LOG("You do not have enough money withdraw amount remaining"); - return TotalCost; - } - - if (pGuild->GetGuildBankMoney() < costs) - { - DEBUG_LOG("There is not enough money in bank"); - return TotalCost; - } - - pGuild->MemberMoneyWithdraw(costs, GetGUIDLow()); - TotalCost = costs; - } - else if (GetMoney() < costs) - { - DEBUG_LOG("You do not have enough money"); - return TotalCost; - } - else - ModifyMoney( -int32(costs) ); - } - } - - item->SetUInt32Value(ITEM_FIELD_DURABILITY, maxDurability); - item->SetState(ITEM_CHANGED, this); - - // reapply mods for total broken and repaired item if equipped - if(IsEquipmentPos(pos) && !curDurability) - _ApplyItemMods(item,pos & 255, true); - return TotalCost; -} - -void Player::RepopAtGraveyard() -{ - // note: this can be called also when the player is alive - // for example from WorldSession::HandleMovementOpcodes - - AreaTableEntry const *zone = GetAreaEntryByAreaID(GetAreaId()); - - // Such zones are considered unreachable as a ghost and the player must be automatically revived - if(!isAlive() && zone && zone->flags & AREA_FLAG_NEED_FLY || GetTransport()) - { - ResurrectPlayer(0.5f); - SpawnCorpseBones(); - } - - WorldSafeLocsEntry const *ClosestGrave = NULL; - - // Special handle for battleground maps - BattleGround *bg = sBattleGroundMgr.GetBattleGround(GetBattleGroundId()); - - if(bg && (bg->GetTypeID() == BATTLEGROUND_AB || bg->GetTypeID() == BATTLEGROUND_EY)) - ClosestGrave = bg->GetClosestGraveYard(GetPositionX(), GetPositionY(), GetPositionZ(), GetTeam()); - else - ClosestGrave = objmgr.GetClosestGraveYard( GetPositionX(), GetPositionY(), GetPositionZ(), GetMapId(), GetTeam() ); - - // stop countdown until repop - m_deathTimer = 0; - - // if no grave found, stay at the current location - // and don't show spirit healer location - if(ClosestGrave) - { - TeleportTo(ClosestGrave->map_id, ClosestGrave->x, ClosestGrave->y, ClosestGrave->z, GetOrientation()); - if(isDead()) // not send if alive, because it used in TeleportTo() - { - WorldPacket data(SMSG_DEATH_RELEASE_LOC, 4*4); // show spirit healer position on minimap - data << ClosestGrave->map_id; - data << ClosestGrave->x; - data << ClosestGrave->y; - data << ClosestGrave->z; - GetSession()->SendPacket(&data); - } - } -} - -void Player::JoinedChannel(Channel *c) -{ - m_channels.push_back(c); -} - -void Player::LeftChannel(Channel *c) -{ - m_channels.remove(c); -} - -void Player::CleanupChannels() -{ - while(!m_channels.empty()) - { - Channel* ch = *m_channels.begin(); - m_channels.erase(m_channels.begin()); // remove from player's channel list - ch->Leave(GetGUID(), false); // not send to client, not remove from player's channel list - if (ChannelMgr* cMgr = channelMgr(GetTeam())) - cMgr->LeftChannel(ch->GetName()); // deleted channel if empty - - } - sLog.outDebug("Player: channels cleaned up!"); -} - -void Player::UpdateLocalChannels(uint32 newZone ) -{ - if(m_channels.empty()) - return; - - AreaTableEntry const* current_zone = GetAreaEntryByAreaID(newZone); - if(!current_zone) - return; - - ChannelMgr* cMgr = channelMgr(GetTeam()); - if(!cMgr) - return; - - std::string current_zone_name = current_zone->area_name[GetSession()->GetSessionDbcLocale()]; - - for(JoinedChannelsList::iterator i = m_channels.begin(), next; i != m_channels.end(); i = next) - { - next = i; ++next; - - // skip non built-in channels - if(!(*i)->IsConstant()) - continue; - - ChatChannelsEntry const* ch = GetChannelEntryFor((*i)->GetChannelId()); - if(!ch) - continue; - - if((ch->flags & 4) == 4) // global channel without zone name in pattern - continue; - - // new channel - char new_channel_name_buf[100]; - snprintf(new_channel_name_buf,100,ch->pattern[m_session->GetSessionDbcLocale()],current_zone_name.c_str()); - Channel* new_channel = cMgr->GetJoinChannel(new_channel_name_buf,ch->ChannelID); - - if((*i)!=new_channel) - { - new_channel->Join(GetGUID(),""); // will output Changed Channel: N. Name - - // leave old channel - (*i)->Leave(GetGUID(),false); // not send leave channel, it already replaced at client - std::string name = (*i)->GetName(); // stroe name, (*i)erase in LeftChannel - LeftChannel(*i); // remove from player's channel list - cMgr->LeftChannel(name); // delete if empty - } - } - sLog.outDebug("Player: channels cleaned up!"); -} - -void Player::LeaveLFGChannel() -{ - for(JoinedChannelsList::iterator i = m_channels.begin(); i != m_channels.end(); ++i ) - { - if((*i)->IsLFG()) - { - (*i)->Leave(GetGUID()); - break; - } - } -} - -void Player::UpdateDefense() -{ - uint32 defense_skill_gain = sWorld.getConfig(CONFIG_SKILL_GAIN_DEFENSE); - - if(UpdateSkill(SKILL_DEFENSE,defense_skill_gain)) - { - // update dependent from defense skill part - UpdateDefenseBonusesMod(); - } -} - -void Player::HandleBaseModValue(BaseModGroup modGroup, BaseModType modType, float amount, bool apply, bool affectStats) -{ - if(modGroup >= BASEMOD_END || modType >= MOD_END) - { - sLog.outError("ERROR in HandleBaseModValue(): nonexisted BaseModGroup of wrong BaseModType!"); - return; - } - - float val = 1.0f; - - switch(modType) - { - case FLAT_MOD: - m_auraBaseMod[modGroup][modType] += apply ? amount : -amount; - break; - case PCT_MOD: - if(amount <= -100.0f) - amount = -200.0f; - - val = (100.0f + amount) / 100.0f; - m_auraBaseMod[modGroup][modType] *= apply ? val : (1.0f/val); - break; - } - - if(!CanModifyStats()) - return; - - switch(modGroup) - { - case CRIT_PERCENTAGE: UpdateCritPercentage(BASE_ATTACK); break; - case RANGED_CRIT_PERCENTAGE: UpdateCritPercentage(RANGED_ATTACK); break; - case OFFHAND_CRIT_PERCENTAGE: UpdateCritPercentage(OFF_ATTACK); break; - case SHIELD_BLOCK_VALUE: UpdateShieldBlockValue(); break; - default: break; - } -} - -float Player::GetBaseModValue(BaseModGroup modGroup, BaseModType modType) const -{ - if(modGroup >= BASEMOD_END || modType > MOD_END) - { - sLog.outError("ERROR: trial to access nonexisted BaseModGroup or wrong BaseModType!"); - return 0.0f; - } - - if(modType == PCT_MOD && m_auraBaseMod[modGroup][PCT_MOD] <= 0.0f) - return 0.0f; - - return m_auraBaseMod[modGroup][modType]; -} - -float Player::GetTotalBaseModValue(BaseModGroup modGroup) const -{ - if(modGroup >= BASEMOD_END) - { - sLog.outError("ERROR: wrong BaseModGroup in GetTotalBaseModValue()!"); - return 0.0f; - } - - if(m_auraBaseMod[modGroup][PCT_MOD] <= 0.0f) - return 0.0f; - - return m_auraBaseMod[modGroup][FLAT_MOD] * m_auraBaseMod[modGroup][PCT_MOD]; -} - -uint32 Player::GetShieldBlockValue() const -{ - BaseModGroup modGroup = SHIELD_BLOCK_VALUE; - - float value = GetTotalBaseModValue(modGroup) + GetStat(STAT_STRENGTH)/20 - 1; - - value = (value < 0) ? 0 : value; - - return uint32(value); -} - -float Player::GetMeleeCritFromAgility() -{ - uint32 level = getLevel(); - uint32 pclass = getClass(); - - if (level>GT_MAX_LEVEL) level = GT_MAX_LEVEL; - - GtChanceToMeleeCritBaseEntry const *critBase = sGtChanceToMeleeCritBaseStore.LookupEntry(pclass-1); - GtChanceToMeleeCritEntry const *critRatio = sGtChanceToMeleeCritStore.LookupEntry((pclass-1)*GT_MAX_LEVEL + level-1); - if (critBase==NULL || critRatio==NULL) - return 0.0f; - - float crit=critBase->base + GetStat(STAT_AGILITY)*critRatio->ratio; - return crit*100.0f; -} - -float Player::GetDodgeFromAgility() -{ - // Table for base dodge values - float dodge_base[MAX_CLASSES] = { - 0.0075f, // Warrior - 0.00652f, // Paladin - -0.0545f, // Hunter - -0.0059f, // Rogue - 0.03183f, // Priest - 0.0114f, // DK - 0.0167f, // Shaman - 0.034575f, // Mage - 0.02011f, // Warlock - 0.0f, // ?? - -0.0187f // Druid - }; - // Crit/agility to dodge/agility coefficient multipliers - float crit_to_dodge[MAX_CLASSES] = { - 1.1f, // Warrior - 1.0f, // Paladin - 1.6f, // Hunter - 2.0f, // Rogue - 1.0f, // Priest - 1.0f, // DK? - 1.0f, // Shaman - 1.0f, // Mage - 1.0f, // Warlock - 0.0f, // ?? - 1.7f // Druid - }; - - uint32 level = getLevel(); - uint32 pclass = getClass(); - - if (level>GT_MAX_LEVEL) level = GT_MAX_LEVEL; - - // Dodge per agility for most classes equal crit per agility (but for some classes need apply some multiplier) - GtChanceToMeleeCritEntry const *dodgeRatio = sGtChanceToMeleeCritStore.LookupEntry((pclass-1)*GT_MAX_LEVEL + level-1); - if (dodgeRatio==NULL || pclass > MAX_CLASSES) - return 0.0f; - - float dodge=dodge_base[pclass-1] + GetStat(STAT_AGILITY) * dodgeRatio->ratio * crit_to_dodge[pclass-1]; - return dodge*100.0f; -} - -float Player::GetSpellCritFromIntellect() -{ - uint32 level = getLevel(); - uint32 pclass = getClass(); - - if (level>GT_MAX_LEVEL) level = GT_MAX_LEVEL; - - GtChanceToSpellCritBaseEntry const *critBase = sGtChanceToSpellCritBaseStore.LookupEntry(pclass-1); - GtChanceToSpellCritEntry const *critRatio = sGtChanceToSpellCritStore.LookupEntry((pclass-1)*GT_MAX_LEVEL + level-1); - if (critBase==NULL || critRatio==NULL) - return 0.0f; - - float crit=critBase->base + GetStat(STAT_INTELLECT)*critRatio->ratio; - return crit*100.0f; -} - -float Player::GetRatingCoefficient(CombatRating cr) const -{ - uint32 level = getLevel(); - - if (level>GT_MAX_LEVEL) level = GT_MAX_LEVEL; - - GtCombatRatingsEntry const *Rating = sGtCombatRatingsStore.LookupEntry(cr*GT_MAX_LEVEL+level-1); - if (Rating == NULL) - return 1.0f; // By default use minimum coefficient (not must be called) - - return Rating->ratio; -} - -float Player::GetRatingBonusValue(CombatRating cr) const -{ - return float(GetUInt32Value(PLAYER_FIELD_COMBAT_RATING_1 + cr)) / GetRatingCoefficient(cr); -} - -uint32 Player::GetMeleeCritDamageReduction(uint32 damage) const -{ - float melee = GetRatingBonusValue(CR_CRIT_TAKEN_MELEE)*2.0f; - if (melee>25.0f) melee = 25.0f; - return uint32 (melee * damage /100.0f); -} - -uint32 Player::GetRangedCritDamageReduction(uint32 damage) const -{ - float ranged = GetRatingBonusValue(CR_CRIT_TAKEN_RANGED)*2.0f; - if (ranged>25.0f) ranged=25.0f; - return uint32 (ranged * damage /100.0f); -} - -uint32 Player::GetSpellCritDamageReduction(uint32 damage) const -{ - float spell = GetRatingBonusValue(CR_CRIT_TAKEN_SPELL)*2.0f; - // In wow script resilience limited to 25% - if (spell>25.0f) - spell = 25.0f; - return uint32 (spell * damage / 100.0f); -} - -uint32 Player::GetDotDamageReduction(uint32 damage) const -{ - float spellDot = GetRatingBonusValue(CR_CRIT_TAKEN_SPELL); - // Dot resilience not limited (limit it by 100%) - if (spellDot > 100.0f) - spellDot = 100.0f; - return uint32 (spellDot * damage / 100.0f); -} - -float Player::GetExpertiseDodgeOrParryReduction(WeaponAttackType attType) const -{ - switch (attType) - { - case BASE_ATTACK: - return GetUInt32Value(PLAYER_EXPERTISE) / 4.0f; - case OFF_ATTACK: - return GetUInt32Value(PLAYER_OFFHAND_EXPERTISE) / 4.0f; - default: - break; - } - return 0.0f; -} - -float Player::OCTRegenHPPerSpirit() -{ - uint32 level = getLevel(); - uint32 pclass = getClass(); - - if (level>GT_MAX_LEVEL) level = GT_MAX_LEVEL; - - GtOCTRegenHPEntry const *baseRatio = sGtOCTRegenHPStore.LookupEntry((pclass-1)*GT_MAX_LEVEL + level-1); - GtRegenHPPerSptEntry const *moreRatio = sGtRegenHPPerSptStore.LookupEntry((pclass-1)*GT_MAX_LEVEL + level-1); - if (baseRatio==NULL || moreRatio==NULL) - return 0.0f; - - // Formula from PaperDollFrame script - float spirit = GetStat(STAT_SPIRIT); - float baseSpirit = spirit; - if (baseSpirit>50) baseSpirit = 50; - float moreSpirit = spirit - baseSpirit; - float regen = baseSpirit * baseRatio->ratio + moreSpirit * moreRatio->ratio; - return regen; -} - -float Player::OCTRegenMPPerSpirit() -{ - uint32 level = getLevel(); - uint32 pclass = getClass(); - - if (level>GT_MAX_LEVEL) level = GT_MAX_LEVEL; - -// GtOCTRegenMPEntry const *baseRatio = sGtOCTRegenMPStore.LookupEntry((pclass-1)*GT_MAX_LEVEL + level-1); - GtRegenMPPerSptEntry const *moreRatio = sGtRegenMPPerSptStore.LookupEntry((pclass-1)*GT_MAX_LEVEL + level-1); - if (moreRatio==NULL) - return 0.0f; - - // Formula get from PaperDollFrame script - float spirit = GetStat(STAT_SPIRIT); - float regen = spirit * moreRatio->ratio; - return regen; -} - -void Player::ApplyRatingMod(CombatRating cr, int32 value, bool apply) -{ - ApplyModUInt32Value(PLAYER_FIELD_COMBAT_RATING_1 + cr, value, apply); - - float RatingCoeffecient = GetRatingCoefficient(cr); - float RatingChange = 0.0f; - - bool affectStats = CanModifyStats(); - - switch (cr) - { - case CR_WEAPON_SKILL: // Implemented in Unit::RollMeleeOutcomeAgainst - case CR_DEFENSE_SKILL: - UpdateDefenseBonusesMod(); - break; - case CR_DODGE: - UpdateDodgePercentage(); - break; - case CR_PARRY: - UpdateParryPercentage(); - break; - case CR_BLOCK: - UpdateBlockPercentage(); - break; - case CR_HIT_MELEE: - RatingChange = value / RatingCoeffecient; - m_modMeleeHitChance += apply ? RatingChange : -RatingChange; - break; - case CR_HIT_RANGED: - RatingChange = value / RatingCoeffecient; - m_modRangedHitChance += apply ? RatingChange : -RatingChange; - break; - case CR_HIT_SPELL: - RatingChange = value / RatingCoeffecient; - m_modSpellHitChance += apply ? RatingChange : -RatingChange; - break; - case CR_CRIT_MELEE: - if(affectStats) - { - UpdateCritPercentage(BASE_ATTACK); - UpdateCritPercentage(OFF_ATTACK); - } - break; - case CR_CRIT_RANGED: - if(affectStats) - UpdateCritPercentage(RANGED_ATTACK); - break; - case CR_CRIT_SPELL: - if(affectStats) - UpdateAllSpellCritChances(); - break; - case CR_HIT_TAKEN_MELEE: // Implemented in Unit::MeleeMissChanceCalc - case CR_HIT_TAKEN_RANGED: - break; - case CR_HIT_TAKEN_SPELL: // Implemented in Unit::MagicSpellHitResult - break; - case CR_CRIT_TAKEN_MELEE: // Implemented in Unit::RollMeleeOutcomeAgainst (only for chance to crit) - case CR_CRIT_TAKEN_RANGED: - break; - case CR_CRIT_TAKEN_SPELL: // Implemented in Unit::SpellCriticalBonus (only for chance to crit) - break; - case CR_HASTE_MELEE: - RatingChange = value / RatingCoeffecient; - ApplyAttackTimePercentMod(BASE_ATTACK,RatingChange,apply); - ApplyAttackTimePercentMod(OFF_ATTACK,RatingChange,apply); - break; - case CR_HASTE_RANGED: - RatingChange = value / RatingCoeffecient; - ApplyAttackTimePercentMod(RANGED_ATTACK, RatingChange, apply); - break; - case CR_HASTE_SPELL: - RatingChange = value / RatingCoeffecient; - ApplyCastTimePercentMod(RatingChange,apply); - break; - case CR_WEAPON_SKILL_MAINHAND: // Implemented in Unit::RollMeleeOutcomeAgainst - case CR_WEAPON_SKILL_OFFHAND: - case CR_WEAPON_SKILL_RANGED: - break; - case CR_EXPERTISE: - if(affectStats) - { - UpdateExpertise(BASE_ATTACK); - UpdateExpertise(OFF_ATTACK); - } - break; - } -} - -void Player::SetRegularAttackTime() -{ - for(int i = 0; i < MAX_ATTACK; ++i) - { - Item *tmpitem = GetWeaponForAttack(WeaponAttackType(i)); - if(tmpitem && !tmpitem->IsBroken()) - { - ItemPrototype const *proto = tmpitem->GetProto(); - if(proto->Delay) - SetAttackTime(WeaponAttackType(i), proto->Delay); - else - SetAttackTime(WeaponAttackType(i), BASE_ATTACK_TIME); - } - } -} - -//skill+step, checking for max value -bool Player::UpdateSkill(uint32 skill_id, uint32 step) -{ - if(!skill_id) - return false; - - uint16 i=0; - for (; i < PLAYER_MAX_SKILLS; i++) - if ((GetUInt32Value(PLAYER_SKILL_INDEX(i)) & 0x0000FFFF) == skill_id) - break; - - if(i>=PLAYER_MAX_SKILLS) - return false; - - uint32 data = GetUInt32Value(PLAYER_SKILL_VALUE_INDEX(i)); - uint32 value = SKILL_VALUE(data); - uint32 max = SKILL_MAX(data); - - if ((!max) || (!value) || (value >= max)) - return false; - - if (value*512 < max*urand(0,512)) - { - uint32 new_value = value+step; - if(new_value > max) - new_value = max; - - SetUInt32Value(PLAYER_SKILL_VALUE_INDEX(i),MAKE_SKILL_VALUE(new_value,max)); - return true; - } - - return false; -} - -inline int SkillGainChance(uint32 SkillValue, uint32 GrayLevel, uint32 GreenLevel, uint32 YellowLevel) -{ - if ( SkillValue >= GrayLevel ) - return sWorld.getConfig(CONFIG_SKILL_CHANCE_GREY)*10; - if ( SkillValue >= GreenLevel ) - return sWorld.getConfig(CONFIG_SKILL_CHANCE_GREEN)*10; - if ( SkillValue >= YellowLevel ) - return sWorld.getConfig(CONFIG_SKILL_CHANCE_YELLOW)*10; - return sWorld.getConfig(CONFIG_SKILL_CHANCE_ORANGE)*10; -} - -bool Player::UpdateCraftSkill(uint32 spellid) -{ - sLog.outDebug("UpdateCraftSkill spellid %d", spellid); - - SkillLineAbilityMap::const_iterator lower = spellmgr.GetBeginSkillLineAbilityMap(spellid); - SkillLineAbilityMap::const_iterator upper = spellmgr.GetEndSkillLineAbilityMap(spellid); - - for(SkillLineAbilityMap::const_iterator _spell_idx = lower; _spell_idx != upper; ++_spell_idx) - { - if(_spell_idx->second->skillId) - { - uint32 SkillValue = GetPureSkillValue(_spell_idx->second->skillId); - - // Alchemy Discoveries here - SpellEntry const* spellEntry = sSpellStore.LookupEntry(spellid); - if(spellEntry && spellEntry->Mechanic==MECHANIC_DISCOVERY) - { - if(uint32 discoveredSpell = GetSkillDiscoverySpell(_spell_idx->second->skillId, spellid, this)) - learnSpell(discoveredSpell); - } - - uint32 craft_skill_gain = sWorld.getConfig(CONFIG_SKILL_GAIN_CRAFTING); - - return UpdateSkillPro(_spell_idx->second->skillId, SkillGainChance(SkillValue, - _spell_idx->second->max_value, - (_spell_idx->second->max_value + _spell_idx->second->min_value)/2, - _spell_idx->second->min_value), - craft_skill_gain); - } - } - return false; -} - -bool Player::UpdateGatherSkill(uint32 SkillId, uint32 SkillValue, uint32 RedLevel, uint32 Multiplicator ) -{ - sLog.outDebug("UpdateGatherSkill(SkillId %d SkillLevel %d RedLevel %d)", SkillId, SkillValue, RedLevel); - - uint32 gathering_skill_gain = sWorld.getConfig(CONFIG_SKILL_GAIN_GATHERING); - - // For skinning and Mining chance decrease with level. 1-74 - no decrease, 75-149 - 2 times, 225-299 - 8 times - switch (SkillId) - { - case SKILL_HERBALISM: - case SKILL_LOCKPICKING: - case SKILL_JEWELCRAFTING: - return UpdateSkillPro(SkillId, SkillGainChance(SkillValue, RedLevel+100, RedLevel+50, RedLevel+25)*Multiplicator,gathering_skill_gain); - case SKILL_SKINNING: - if( sWorld.getConfig(CONFIG_SKILL_CHANCE_SKINNING_STEPS)==0) - return UpdateSkillPro(SkillId, SkillGainChance(SkillValue, RedLevel+100, RedLevel+50, RedLevel+25)*Multiplicator,gathering_skill_gain); - else - return UpdateSkillPro(SkillId, (SkillGainChance(SkillValue, RedLevel+100, RedLevel+50, RedLevel+25)*Multiplicator) >> (SkillValue/sWorld.getConfig(CONFIG_SKILL_CHANCE_SKINNING_STEPS)), gathering_skill_gain); - case SKILL_MINING: - if (sWorld.getConfig(CONFIG_SKILL_CHANCE_MINING_STEPS)==0) - return UpdateSkillPro(SkillId, SkillGainChance(SkillValue, RedLevel+100, RedLevel+50, RedLevel+25)*Multiplicator,gathering_skill_gain); - else - return UpdateSkillPro(SkillId, (SkillGainChance(SkillValue, RedLevel+100, RedLevel+50, RedLevel+25)*Multiplicator) >> (SkillValue/sWorld.getConfig(CONFIG_SKILL_CHANCE_MINING_STEPS)),gathering_skill_gain); - } - return false; -} - -bool Player::UpdateFishingSkill() -{ - sLog.outDebug("UpdateFishingSkill"); - - uint32 SkillValue = GetPureSkillValue(SKILL_FISHING); - - int32 chance = SkillValue < 75 ? 100 : 2500/(SkillValue-50); - - uint32 gathering_skill_gain = sWorld.getConfig(CONFIG_SKILL_GAIN_GATHERING); - - return UpdateSkillPro(SKILL_FISHING,chance*10,gathering_skill_gain); -} - -bool Player::UpdateSkillPro(uint16 SkillId, int32 Chance, uint32 step) -{ - sLog.outDebug("UpdateSkillPro(SkillId %d, Chance %3.1f%%)", SkillId, Chance/10.0); - if ( !SkillId ) - return false; - - if(Chance <= 0) // speedup in 0 chance case - { - sLog.outDebug("Player::UpdateSkillPro Chance=%3.1f%% missed", Chance/10.0); - return false; - } - - uint16 i=0; - for (; i < PLAYER_MAX_SKILLS; i++) - if ( SKILL_VALUE(GetUInt32Value(PLAYER_SKILL_INDEX(i))) == SkillId ) break; - if ( i >= PLAYER_MAX_SKILLS ) - return false; - - uint32 data = GetUInt32Value(PLAYER_SKILL_VALUE_INDEX(i)); - uint16 SkillValue = SKILL_VALUE(data); - uint16 MaxValue = SKILL_MAX(data); - - if ( !MaxValue || !SkillValue || SkillValue >= MaxValue ) - return false; - - int32 Roll = irand(1,1000); - - if ( Roll <= Chance ) - { - uint32 new_value = SkillValue+step; - if(new_value > MaxValue) - new_value = MaxValue; - - SetUInt32Value(PLAYER_SKILL_VALUE_INDEX(i),MAKE_SKILL_VALUE(new_value,MaxValue)); - sLog.outDebug("Player::UpdateSkillPro Chance=%3.1f%% taken", Chance/10.0); - return true; - } - - sLog.outDebug("Player::UpdateSkillPro Chance=%3.1f%% missed", Chance/10.0); - return false; -} - -void Player::UpdateWeaponSkill (WeaponAttackType attType) -{ - // no skill gain in pvp - Unit *pVictim = getVictim(); - if(pVictim && pVictim->GetTypeId() == TYPEID_PLAYER) - return; - - if(IsInFeralForm()) - return; // always maximized SKILL_FERAL_COMBAT in fact - - if(m_form == FORM_TREE) - return; // use weapon but not skill up - - uint32 weapon_skill_gain = sWorld.getConfig(CONFIG_SKILL_GAIN_WEAPON); - - switch(attType) - { - case BASE_ATTACK: - { - Item *tmpitem = GetWeaponForAttack(attType,true); - - if (!tmpitem) - UpdateSkill(SKILL_UNARMED,weapon_skill_gain); - else if(tmpitem->GetProto()->SubClass != ITEM_SUBCLASS_WEAPON_FISHING_POLE) - UpdateSkill(tmpitem->GetSkill(),weapon_skill_gain); - break; - } - case OFF_ATTACK: - case RANGED_ATTACK: - { - Item *tmpitem = GetWeaponForAttack(attType,true); - if (tmpitem) - UpdateSkill(tmpitem->GetSkill(),weapon_skill_gain); - break; - } - } - UpdateAllCritPercentages(); -} - -void Player::UpdateCombatSkills(Unit *pVictim, WeaponAttackType attType, MeleeHitOutcome outcome, bool defence) -{ - switch(outcome) - { - case MELEE_HIT_CRIT: - case MELEE_HIT_DODGE: - case MELEE_HIT_PARRY: - case MELEE_HIT_BLOCK: - case MELEE_HIT_BLOCK_CRIT: - return; - - default: - break; - } - - uint32 plevel = getLevel(); // if defense than pVictim == attacker - uint32 greylevel = MaNGOS::XP::GetGrayLevel(plevel); - uint32 moblevel = pVictim->getLevelForTarget(this); - if(moblevel < greylevel) - return; - - if (moblevel > plevel + 5) - moblevel = plevel + 5; - - uint32 lvldif = moblevel - greylevel; - if(lvldif < 3) - lvldif = 3; - - uint32 skilldif = 5 * plevel - (defence ? GetBaseDefenseSkillValue() : GetBaseWeaponSkillValue(attType)); - if(skilldif <= 0) - return; - - float chance = float(3 * lvldif * skilldif) / plevel; - if(!defence) - { - if(getClass() == CLASS_WARRIOR || getClass() == CLASS_ROGUE) - chance *= 0.1f * GetStat(STAT_INTELLECT); - } - - chance = chance < 1.0f ? 1.0f : chance; //minimum chance to increase skill is 1% - - if(roll_chance_f(chance)) - { - if(defence) - UpdateDefense(); - else - UpdateWeaponSkill(attType); - } - else - return; -} - -void Player::ModifySkillBonus(uint32 skillid,int32 val, bool talent) -{ - for (uint16 i=0; i < PLAYER_MAX_SKILLS; i++) - if ((GetUInt32Value(PLAYER_SKILL_INDEX(i)) & 0x0000FFFF) == skillid) - { - uint32 bonus_val = GetUInt32Value(PLAYER_SKILL_BONUS_INDEX(i)); - int16 temp_bonus = SKILL_TEMP_BONUS(bonus_val); - int16 perm_bonus = SKILL_PERM_BONUS(bonus_val); - - if(talent) // permanent bonus stored in high part - SetUInt32Value(PLAYER_SKILL_BONUS_INDEX(i),MAKE_SKILL_BONUS(temp_bonus,perm_bonus+val)); - else // temporary/item bonus stored in low part - SetUInt32Value(PLAYER_SKILL_BONUS_INDEX(i),MAKE_SKILL_BONUS(temp_bonus+val,perm_bonus)); - return; - } -} - -void Player::UpdateMaxSkills() -{ - uint16 maxconfskill = sWorld.GetConfigMaxSkillValue(); - - for (uint16 i=0; i < PLAYER_MAX_SKILLS; i++) - if (GetUInt32Value(PLAYER_SKILL_INDEX(i))) - { - uint32 pskill = GetUInt32Value(PLAYER_SKILL_INDEX(i)) & 0x0000FFFF; - - SkillLineEntry const *pSkill = sSkillLineStore.LookupEntry(pskill); - if(!pSkill) - continue; - - if(GetSkillRangeType(pSkill,false) != SKILL_RANGE_LEVEL) - continue; - - uint32 data = GetUInt32Value(PLAYER_SKILL_VALUE_INDEX(i)); - uint32 max = SKILL_MAX(data); - uint32 val = SKILL_VALUE(data); - - // update only level dependent max skill values - if(max!=1 && max != maxconfskill) - { - uint32 max_Skill = GetMaxSkillValueForLevel(); - SetUInt32Value(PLAYER_SKILL_VALUE_INDEX(i),MAKE_SKILL_VALUE(val,max_Skill)); - } - } -} - -void Player::UpdateSkillsToMaxSkillsForLevel() -{ - for (uint16 i=0; i < PLAYER_MAX_SKILLS; i++) - if (GetUInt32Value(PLAYER_SKILL_INDEX(i))) - { - uint32 pskill = GetUInt32Value(PLAYER_SKILL_INDEX(i)) & 0x0000FFFF; - if( IsProfessionSkill(pskill) || pskill == SKILL_RIDING ) - continue; - uint32 data = GetUInt32Value(PLAYER_SKILL_VALUE_INDEX(i)); - - uint32 max = SKILL_MAX(data); - - if(max > 1) - SetUInt32Value(PLAYER_SKILL_VALUE_INDEX(i),MAKE_SKILL_VALUE(max,max)); - - if(pskill == SKILL_DEFENSE) - { - UpdateBlockPercentage(); - } - } -} - -// This functions sets a skill line value (and adds if doesn't exist yet) -// To "remove" a skill line, set it's values to zero -void Player::SetSkill(uint32 id, uint16 currVal, uint16 maxVal) -{ - if(!id) - return; - - uint16 i=0; - for (; i < PLAYER_MAX_SKILLS; i++) - if ((GetUInt32Value(PLAYER_SKILL_INDEX(i)) & 0x0000FFFF) == id) break; - - if(isecond->state == PLAYERSPELL_REMOVED) - continue; - - SkillLineAbilityMap::const_iterator lower = spellmgr.GetBeginSkillLineAbilityMap(itr->first); - SkillLineAbilityMap::const_iterator upper = spellmgr.GetEndSkillLineAbilityMap(itr->first); - - for(SkillLineAbilityMap::const_iterator _spell_idx = lower; _spell_idx != upper; ++_spell_idx) - { - if (_spell_idx->second->skillId == id) - { - // this may remove more than one spell (dependants) - removeSpell(itr->first); - next = m_spells.begin(); - break; - } - } - } - } - } - else if(currVal) //add - { - for (i=0; i < PLAYER_MAX_SKILLS; i++) - if (!GetUInt32Value(PLAYER_SKILL_INDEX(i))) - { - SkillLineEntry const *pSkill = sSkillLineStore.LookupEntry(id); - if(!pSkill) - { - sLog.outError("Skill not found in SkillLineStore: skill #%u", id); - return; - } - // enable unlearn button for primary professions only - if (pSkill->categoryId == SKILL_CATEGORY_PROFESSION) - SetUInt32Value(PLAYER_SKILL_INDEX(i), MAKE_PAIR32(id,1)); - else - SetUInt32Value(PLAYER_SKILL_INDEX(i), MAKE_PAIR32(id,0)); - SetUInt32Value(PLAYER_SKILL_VALUE_INDEX(i),MAKE_SKILL_VALUE(currVal,maxVal)); - - // apply skill bonuses - SetUInt32Value(PLAYER_SKILL_BONUS_INDEX(i),0); - - // temporary bonuses - AuraList const& mModSkill = GetAurasByType(SPELL_AURA_MOD_SKILL); - for(AuraList::const_iterator i = mModSkill.begin(); i != mModSkill.end(); ++i) - if ((*i)->GetModifier()->m_miscvalue == int32(id)) - (*i)->ApplyModifier(true); - - // permanent bonuses - AuraList const& mModSkillTalent = GetAurasByType(SPELL_AURA_MOD_SKILL_TALENT); - for(AuraList::const_iterator i = mModSkillTalent.begin(); i != mModSkillTalent.end(); ++i) - if ((*i)->GetModifier()->m_miscvalue == int32(id)) - (*i)->ApplyModifier(true); - - // Learn all spells for skill - learnSkillRewardedSpells(id); - return; - } - } -} - -bool Player::HasSkill(uint32 skill) const -{ - if(!skill)return false; - for (uint16 i=0; i < PLAYER_MAX_SKILLS; i++) - { - if ((GetUInt32Value(PLAYER_SKILL_INDEX(i)) & 0x0000FFFF) == skill) - { - return true; - } - } - return false; -} - -uint16 Player::GetSkillValue(uint32 skill) const -{ - if(!skill) - return 0; - - for (uint16 i=0; i < PLAYER_MAX_SKILLS; i++) - { - if ((GetUInt32Value(PLAYER_SKILL_INDEX(i)) & 0x0000FFFF) == skill) - { - uint32 bonus = GetUInt32Value(PLAYER_SKILL_BONUS_INDEX(i)); - - int32 result = int32(SKILL_VALUE(GetUInt32Value(PLAYER_SKILL_VALUE_INDEX(i)))); - result += SKILL_TEMP_BONUS(bonus); - result += SKILL_PERM_BONUS(bonus); - return result < 0 ? 0 : result; - } - } - return 0; -} - -uint16 Player::GetMaxSkillValue(uint32 skill) const -{ - if(!skill)return 0; - for (uint16 i=0; i < PLAYER_MAX_SKILLS; i++) - { - if ((GetUInt32Value(PLAYER_SKILL_INDEX(i)) & 0x0000FFFF) == skill) - { - uint32 bonus = GetUInt32Value(PLAYER_SKILL_BONUS_INDEX(i)); - - int32 result = int32(SKILL_MAX(GetUInt32Value(PLAYER_SKILL_VALUE_INDEX(i)))); - result += SKILL_TEMP_BONUS(bonus); - result += SKILL_PERM_BONUS(bonus); - return result < 0 ? 0 : result; - } - } - return 0; -} - -uint16 Player::GetPureMaxSkillValue(uint32 skill) const -{ - if(!skill)return 0; - for (uint16 i=0; i < PLAYER_MAX_SKILLS; i++) - { - if ((GetUInt32Value(PLAYER_SKILL_INDEX(i)) & 0x0000FFFF) == skill) - { - return SKILL_MAX(GetUInt32Value(PLAYER_SKILL_VALUE_INDEX(i))); - } - } - return 0; -} - -uint16 Player::GetBaseSkillValue(uint32 skill) const -{ - if(!skill)return 0; - for (uint16 i=0; i < PLAYER_MAX_SKILLS; i++) - { - if ((GetUInt32Value(PLAYER_SKILL_INDEX(i)) & 0x0000FFFF) == skill) - { - int32 result = int32(SKILL_VALUE(GetUInt32Value(PLAYER_SKILL_VALUE_INDEX(i)))); - result += SKILL_PERM_BONUS(GetUInt32Value(PLAYER_SKILL_BONUS_INDEX(i))); - return result < 0 ? 0 : result; - } - } - return 0; -} - -uint16 Player::GetPureSkillValue(uint32 skill) const -{ - if(!skill)return 0; - for (uint16 i=0; i < PLAYER_MAX_SKILLS; i++) - { - if ((GetUInt32Value(PLAYER_SKILL_INDEX(i)) & 0x0000FFFF) == skill) - { - return SKILL_VALUE(GetUInt32Value(PLAYER_SKILL_VALUE_INDEX(i))); - } - } - return 0; -} - -int16 Player::GetSkillTempBonusValue(uint32 skill) const -{ - if(!skill) - return 0; - - for (int i = 0; i < PLAYER_MAX_SKILLS; i++) - { - if ((GetUInt32Value(PLAYER_SKILL_INDEX(i)) & 0x0000FFFF) == skill) - { - return SKILL_TEMP_BONUS(GetUInt32Value(PLAYER_SKILL_BONUS_INDEX(i))); - } - } - - return 0; -} - -void Player::SendInitialActionButtons() -{ - sLog.outDetail( "Initializing Action Buttons for '%u'", GetGUIDLow() ); - - WorldPacket data(SMSG_ACTION_BUTTONS, (MAX_ACTION_BUTTONS*4)); - for(int button = 0; button < MAX_ACTION_BUTTONS; ++button) - { - ActionButtonList::const_iterator itr = m_actionButtons.find(button); - if(itr != m_actionButtons.end() && itr->second.uState != ACTIONBUTTON_DELETED) - { - data << uint16(itr->second.action); - data << uint8(itr->second.misc); - data << uint8(itr->second.type); - } - else - { - data << uint32(0); - } - } - - GetSession()->SendPacket( &data ); - sLog.outDetail( "Action Buttons for '%u' Initialized", GetGUIDLow() ); -} - -void Player::addActionButton(const uint8 button, const uint16 action, const uint8 type, const uint8 misc) -{ - if(button >= MAX_ACTION_BUTTONS) - { - sLog.outError( "Action %u not added into button %u for player %s: button must be < 132", action, button, GetName() ); - return; - } - - // check cheating with adding non-known spells to action bar - if(type==ACTION_BUTTON_SPELL) - { - if(!sSpellStore.LookupEntry(action)) - { - sLog.outError( "Action %u not added into button %u for player %s: spell not exist", action, button, GetName() ); - return; - } - - if(!HasSpell(action)) - { - sLog.outError( "Action %u not added into button %u for player %s: player don't known this spell", action, button, GetName() ); - return; - } - } - - ActionButtonList::iterator buttonItr = m_actionButtons.find(button); - - if (buttonItr==m_actionButtons.end()) - { // just add new button - m_actionButtons[button] = ActionButton(action,type,misc); - } - else - { // change state of current button - ActionButtonUpdateState uState = buttonItr->second.uState; - buttonItr->second = ActionButton(action,type,misc); - if (uState != ACTIONBUTTON_NEW) buttonItr->second.uState = ACTIONBUTTON_CHANGED; - }; - - sLog.outDetail( "Player '%u' Added Action '%u' to Button '%u'", GetGUIDLow(), action, button ); -} - -void Player::removeActionButton(uint8 button) -{ - ActionButtonList::iterator buttonItr = m_actionButtons.find(button); - if (buttonItr==m_actionButtons.end()) - return; - - if(buttonItr->second.uState==ACTIONBUTTON_NEW) - m_actionButtons.erase(buttonItr); // new and not saved - else - buttonItr->second.uState = ACTIONBUTTON_DELETED; // saved, will deleted at next save - - sLog.outDetail( "Action Button '%u' Removed from Player '%u'", button, GetGUIDLow() ); -} - -void Player::SetDontMove(bool dontMove) -{ - m_dontMove = dontMove; -} - -bool Player::SetPosition(float x, float y, float z, float orientation, bool teleport) -{ - // prevent crash when a bad coord is sent by the client - if(!MaNGOS::IsValidMapCoord(x,y,z,orientation)) - { - sLog.outDebug("Player::SetPosition(%f, %f, %f, %f, %d) .. bad coordinates for player %d!",x,y,z,orientation,teleport,GetGUIDLow()); - return false; - } - - Map *m = MapManager::Instance().GetMap(GetMapId(), this); - - const float old_x = GetPositionX(); - const float old_y = GetPositionY(); - const float old_z = GetPositionZ(); - const float old_r = GetOrientation(); - - if( teleport || old_x != x || old_y != y || old_z != z || old_r != orientation ) - { - if (teleport || old_x != x || old_y != y || old_z != z) - RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_MOVE | AURA_INTERRUPT_FLAG_TURNING); - else - RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_TURNING); - - // move and update visible state if need - m->PlayerRelocation(this, x, y, z, orientation); - - // reread after Map::Relocation - m = MapManager::Instance().GetMap(GetMapId(), this); - x = GetPositionX(); - y = GetPositionY(); - z = GetPositionZ(); - } - - // code block for underwater state update - UpdateUnderwaterState(m, x, y, z); - - - CheckExploreSystem(); - - // group update - if(GetGroup()) - SetGroupUpdateFlag(GROUP_UPDATE_FLAG_POSITION); - - return true; -} - -void Player::SaveRecallPosition() -{ - m_recallMap = GetMapId(); - m_recallX = GetPositionX(); - m_recallY = GetPositionY(); - m_recallZ = GetPositionZ(); - m_recallO = GetOrientation(); -} - -void Player::SendMessageToSet(WorldPacket *data, bool self) -{ - MapManager::Instance().GetMap(GetMapId(), this)->MessageBroadcast(this, data, self); -} - -void Player::SendMessageToSetInRange(WorldPacket *data, float dist, bool self) -{ - MapManager::Instance().GetMap(GetMapId(), this)->MessageDistBroadcast(this, data, dist, self); -} - -void Player::SendMessageToSetInRange(WorldPacket *data, float dist, bool self, bool own_team_only) -{ - MapManager::Instance().GetMap(GetMapId(), this)->MessageDistBroadcast(this, data, dist, self,own_team_only); -} - -void Player::SendDirectMessage(WorldPacket *data) -{ - GetSession()->SendPacket(data); -} - -void Player::CheckExploreSystem() -{ - if (!isAlive()) - return; - - if (isInFlight()) - return; - - uint16 areaFlag=MapManager::Instance().GetBaseMap(GetMapId())->GetAreaFlag(GetPositionX(),GetPositionY()); - if(areaFlag==0xffff) - return; - int offset = areaFlag / 32; - - if(offset >= 128) - { - sLog.outError("ERROR: Wrong area flag %u in map data for (X: %f Y: %f) point to field PLAYER_EXPLORED_ZONES_1 + %u ( %u must be < 64 ).",areaFlag,GetPositionX(),GetPositionY(),offset,offset); - return; - } - - uint32 val = (uint32)(1 << (areaFlag % 32)); - uint32 currFields = GetUInt32Value(PLAYER_EXPLORED_ZONES_1 + offset); - - if( !(currFields & val) ) - { - SetUInt32Value(PLAYER_EXPLORED_ZONES_1 + offset, (uint32)(currFields | val)); - - AreaTableEntry const *p = GetAreaEntryByAreaFlagAndMap(areaFlag,GetMapId()); - if(!p) - { - sLog.outError("PLAYER: Player %u discovered unknown area (x: %f y: %f map: %u", GetGUIDLow(), GetPositionX(),GetPositionY(),GetMapId()); - } - else if(p->area_level > 0) - { - uint32 area = p->ID; - if (getLevel() >= sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL)) - { - SendExplorationExperience(area,0); - } - else - { - int32 diff = int32(getLevel()) - p->area_level; - uint32 XP = 0; - if (diff < -5) - { - XP = uint32(objmgr.GetBaseXP(getLevel()+5)*sWorld.getRate(RATE_XP_EXPLORE)); - } - else if (diff > 5) - { - int32 exploration_percent = (100-((diff-5)*5)); - if (exploration_percent > 100) - exploration_percent = 100; - else if (exploration_percent < 0) - exploration_percent = 0; - - XP = uint32(objmgr.GetBaseXP(p->area_level)*exploration_percent/100*sWorld.getRate(RATE_XP_EXPLORE)); - } - else - { - XP = uint32(objmgr.GetBaseXP(p->area_level)*sWorld.getRate(RATE_XP_EXPLORE)); - } - - GiveXP( XP, NULL ); - SendExplorationExperience(area,XP); - } - sLog.outDetail("PLAYER: Player %u discovered a new area: %u", GetGUIDLow(), area); - } - } -} - -uint32 Player::TeamForRace(uint8 race) -{ - ChrRacesEntry const* rEntry = sChrRacesStore.LookupEntry(race); - if(!rEntry) - { - sLog.outError("Race %u not found in DBC: wrong DBC files?",uint32(race)); - return ALLIANCE; - } - - switch(rEntry->TeamID) - { - case 7: return ALLIANCE; - case 1: return HORDE; - } - - sLog.outError("Race %u have wrong team id in DBC: wrong DBC files?",uint32(race),rEntry->TeamID); - return ALLIANCE; -} - -uint32 Player::getFactionForRace(uint8 race) -{ - ChrRacesEntry const* rEntry = sChrRacesStore.LookupEntry(race); - if(!rEntry) - { - sLog.outError("Race %u not found in DBC: wrong DBC files?",uint32(race)); - return 0; - } - - return rEntry->FactionID; -} - -void Player::setFactionForRace(uint8 race) -{ - m_team = TeamForRace(race); - setFaction( getFactionForRace(race) ); -} - -void Player::UpdateReputation() const -{ - sLog.outDetail( "WORLD: Player::UpdateReputation" ); - - for(FactionStateList::const_iterator itr = m_factions.begin(); itr != m_factions.end(); ++itr) - { - SendFactionState(&(itr->second)); - } -} - -void Player::SendFactionState(FactionState const* faction) const -{ - if(faction->Flags & FACTION_FLAG_VISIBLE) //If faction is visible then update it - { - WorldPacket data(SMSG_SET_FACTION_STANDING, (16)); // last check 2.4.0 - data << (float) 0; // unk 2.4.0 - data << (uint32) 1; // count - // for - data << (uint32) faction->ReputationListID; - data << (uint32) faction->Standing; - // end for - GetSession()->SendPacket(&data); - } -} - -void Player::SendInitialReputations() -{ - WorldPacket data(SMSG_INITIALIZE_FACTIONS, (4+128*5)); - data << uint32 (0x00000080); - - RepListID a = 0; - - for (FactionStateList::const_iterator itr = m_factions.begin(); itr != m_factions.end(); itr++) - { - // fill in absent fields - for (; a != itr->first; a++) - { - data << uint8 (0x00); - data << uint32 (0x00000000); - } - - // fill in encountered data - data << uint8 (itr->second.Flags); - data << uint32 (itr->second.Standing); - - ++a; - } - - // fill in absent fields - for (; a != 128; a++) - { - data << uint8 (0x00); - data << uint32 (0x00000000); - } - - GetSession()->SendPacket(&data); -} - -FactionState const* Player::GetFactionState( FactionEntry const* factionEntry) const -{ - FactionStateList::const_iterator itr = m_factions.find(factionEntry->reputationListID); - if (itr != m_factions.end()) - return &itr->second; - - return NULL; -} - -void Player::SetFactionAtWar(FactionState* faction, bool atWar) -{ - // not allow declare war to own faction - if(atWar && (faction->Flags & FACTION_FLAG_PEACE_FORCED) ) - return; - - // already set - if(((faction->Flags & FACTION_FLAG_AT_WAR) != 0) == atWar) - return; - - if( atWar ) - faction->Flags |= FACTION_FLAG_AT_WAR; - else - faction->Flags &= ~FACTION_FLAG_AT_WAR; - - faction->Changed = true; -} - -void Player::SetFactionInactive(FactionState* faction, bool inactive) -{ - // always invisible or hidden faction can't be inactive - if(inactive && ((faction->Flags & (FACTION_FLAG_INVISIBLE_FORCED|FACTION_FLAG_HIDDEN)) || !(faction->Flags & FACTION_FLAG_VISIBLE) ) ) - return; - - // already set - if(((faction->Flags & FACTION_FLAG_INACTIVE) != 0) == inactive) - return; - - if(inactive) - faction->Flags |= FACTION_FLAG_INACTIVE; - else - faction->Flags &= ~FACTION_FLAG_INACTIVE; - - faction->Changed = true; -} - -void Player::SetFactionVisibleForFactionTemplateId(uint32 FactionTemplateId) -{ - FactionTemplateEntry const*factionTemplateEntry = sFactionTemplateStore.LookupEntry(FactionTemplateId); - - if(!factionTemplateEntry) - return; - - SetFactionVisibleForFactionId(factionTemplateEntry->faction); -} - -void Player::SetFactionVisibleForFactionId(uint32 FactionId) -{ - FactionEntry const *factionEntry = sFactionStore.LookupEntry(FactionId); - if(!factionEntry) - return; - - if(factionEntry->reputationListID < 0) - return; - - FactionStateList::iterator itr = m_factions.find(factionEntry->reputationListID); - if (itr == m_factions.end()) - return; - - SetFactionVisible(&itr->second); -} - -void Player::SetFactionVisible(FactionState* faction) -{ - // always invisible or hidden faction can't be make visible - if(faction->Flags & (FACTION_FLAG_INVISIBLE_FORCED|FACTION_FLAG_HIDDEN)) - return; - - // already set - if(faction->Flags & FACTION_FLAG_VISIBLE) - return; - - faction->Flags |= FACTION_FLAG_VISIBLE; - faction->Changed = true; - - if(!m_session->PlayerLoading()) - { - // make faction visible in reputation list at client - WorldPacket data(SMSG_SET_FACTION_VISIBLE, 4); - data << faction->ReputationListID; - GetSession()->SendPacket(&data); - } -} - -void Player::SetInitialFactions() -{ - for(unsigned int i = 1; i < sFactionStore.GetNumRows(); i++) - { - FactionEntry const *factionEntry = sFactionStore.LookupEntry(i); - - if( factionEntry && (factionEntry->reputationListID >= 0)) - { - FactionState newFaction; - newFaction.ID = factionEntry->ID; - newFaction.ReputationListID = factionEntry->reputationListID; - newFaction.Standing = 0; - newFaction.Flags = GetDefaultReputationFlags(factionEntry); - newFaction.Changed = true; - - m_factions[newFaction.ReputationListID] = newFaction; - } - } -} - -uint32 Player::GetDefaultReputationFlags(const FactionEntry *factionEntry) const -{ - if (!factionEntry) - return 0; - - uint32 raceMask = getRaceMask(); - uint32 classMask = getClassMask(); - for (int i=0; i < 4; i++) - { - if( (factionEntry->BaseRepRaceMask[i] & raceMask) && - (factionEntry->BaseRepClassMask[i]==0 || - (factionEntry->BaseRepClassMask[i] & classMask) ) ) - return factionEntry->ReputationFlags[i]; - } - return 0; -} - -int32 Player::GetBaseReputation(const FactionEntry *factionEntry) const -{ - if (!factionEntry) - return 0; - - uint32 raceMask = getRaceMask(); - uint32 classMask = getClassMask(); - for (int i=0; i < 4; i++) - { - if( (factionEntry->BaseRepRaceMask[i] & raceMask) && - (factionEntry->BaseRepClassMask[i]==0 || - (factionEntry->BaseRepClassMask[i] & classMask) ) ) - return factionEntry->BaseRepValue[i]; - } - - // in faction.dbc exist factions with (RepListId >=0, listed in character reputation list) with all BaseRepRaceMask[i]==0 - return 0; -} - -int32 Player::GetReputation(uint32 faction_id) const -{ - FactionEntry const *factionEntry = sFactionStore.LookupEntry(faction_id); - - if (!factionEntry) - { - sLog.outError("Player::GetReputation: Can't get reputation of %s for unknown faction (faction template id) #%u.",GetName(), faction_id); - return 0; - } - - return GetReputation(factionEntry); -} - -int32 Player::GetReputation(const FactionEntry *factionEntry) const -{ - // Faction without recorded reputation. Just ignore. - if(!factionEntry) - return 0; - - FactionStateList::const_iterator itr = m_factions.find(factionEntry->reputationListID); - if (itr != m_factions.end()) - return GetBaseReputation(factionEntry) + itr->second.Standing; - - return 0; -} - -ReputationRank Player::GetReputationRank(uint32 faction) const -{ - FactionEntry const*factionEntry = sFactionStore.LookupEntry(faction); - if(!factionEntry) - return MIN_REPUTATION_RANK; - - return GetReputationRank(factionEntry); -} - -ReputationRank Player::ReputationToRank(int32 standing) const -{ - int32 Limit = Reputation_Cap + 1; - for (int i = MAX_REPUTATION_RANK-1; i >= MIN_REPUTATION_RANK; --i) - { - Limit -= ReputationRank_Length[i]; - if (standing >= Limit ) - return ReputationRank(i); - } - return MIN_REPUTATION_RANK; -} - -ReputationRank Player::GetReputationRank(const FactionEntry *factionEntry) const -{ - int32 Reputation = GetReputation(factionEntry); - return ReputationToRank(Reputation); -} - -ReputationRank Player::GetBaseReputationRank(const FactionEntry *factionEntry) const -{ - int32 Reputation = GetBaseReputation(factionEntry); - return ReputationToRank(Reputation); -} - -bool Player::ModifyFactionReputation(uint32 FactionTemplateId, int32 DeltaReputation) -{ - FactionTemplateEntry const* factionTemplateEntry = sFactionTemplateStore.LookupEntry(FactionTemplateId); - - if(!factionTemplateEntry) - { - sLog.outError("Player::ModifyFactionReputation: Can't update reputation of %s for unknown faction (faction template id) #%u.", GetName(), FactionTemplateId); - return false; - } - - FactionEntry const *factionEntry = sFactionStore.LookupEntry(factionTemplateEntry->faction); - - // Faction without recorded reputation. Just ignore. - if(!factionEntry) - return false; - - return ModifyFactionReputation(factionEntry, DeltaReputation); -} - -bool Player::ModifyFactionReputation(FactionEntry const* factionEntry, int32 standing) -{ - SimpleFactionsList const* flist = GetFactionTeamList(factionEntry->ID); - if (flist) - { - bool res = false; - for (SimpleFactionsList::const_iterator itr = flist->begin();itr != flist->end();++itr) - { - FactionEntry const *factionEntryCalc = sFactionStore.LookupEntry(*itr); - if(factionEntryCalc) - res = ModifyOneFactionReputation(factionEntryCalc, standing); - } - return res; - } - else - return ModifyOneFactionReputation(factionEntry, standing); -} - -bool Player::ModifyOneFactionReputation(FactionEntry const* factionEntry, int32 standing) -{ - FactionStateList::iterator itr = m_factions.find(factionEntry->reputationListID); - if (itr != m_factions.end()) - { - int32 BaseRep = GetBaseReputation(factionEntry); - int32 new_rep = BaseRep + itr->second.Standing + standing; - - if (new_rep > Reputation_Cap) - new_rep = Reputation_Cap; - else - if (new_rep < Reputation_Bottom) - new_rep = Reputation_Bottom; - - if(ReputationToRank(new_rep) <= REP_HOSTILE) - SetFactionAtWar(&itr->second,true); - - itr->second.Standing = new_rep - BaseRep; - itr->second.Changed = true; - - SetFactionVisible(&itr->second); - - for( int i = 0; i < MAX_QUEST_LOG_SIZE; i++ ) - { - if(uint32 questid = GetQuestSlotQuestId(i)) - { - Quest const* qInfo = objmgr.GetQuestTemplate(questid); - if( qInfo && qInfo->GetRepObjectiveFaction() == factionEntry->ID ) - { - QuestStatusData& q_status = mQuestStatus[questid]; - if( q_status.m_status == QUEST_STATUS_INCOMPLETE ) - { - if(GetReputation(factionEntry) >= qInfo->GetRepObjectiveValue()) - if ( CanCompleteQuest( questid ) ) - CompleteQuest( questid ); - } - else if( q_status.m_status == QUEST_STATUS_COMPLETE ) - { - if(GetReputation(factionEntry) < qInfo->GetRepObjectiveValue()) - IncompleteQuest( questid ); - } - } - } - } - - SendFactionState(&(itr->second)); - - return true; - } - return false; -} - -bool Player::SetFactionReputation(uint32 FactionTemplateId, int32 standing) -{ - FactionTemplateEntry const* factionTemplateEntry = sFactionTemplateStore.LookupEntry(FactionTemplateId); - - if(!factionTemplateEntry) - { - sLog.outError("Player::SetFactionReputation: Can't set reputation of %s for unknown faction (faction template id) #%u.", GetName(), FactionTemplateId); - return false; - } - - FactionEntry const *factionEntry = sFactionStore.LookupEntry(factionTemplateEntry->faction); - - // Faction without recorded reputation. Just ignore. - if(!factionEntry) - return false; - - return SetFactionReputation(factionEntry, standing); -} - -bool Player::SetFactionReputation(FactionEntry const* factionEntry, int32 standing) -{ - SimpleFactionsList const* flist = GetFactionTeamList(factionEntry->ID); - if (flist) - { - bool res = false; - for (SimpleFactionsList::const_iterator itr = flist->begin();itr != flist->end();++itr) - { - FactionEntry const *factionEntryCalc = sFactionStore.LookupEntry(*itr); - if(factionEntryCalc) - res = SetOneFactionReputation(factionEntryCalc, standing); - } - return res; - } - else - return SetOneFactionReputation(factionEntry, standing); -} - -bool Player::SetOneFactionReputation(FactionEntry const* factionEntry, int32 standing) -{ - FactionStateList::iterator itr = m_factions.find(factionEntry->reputationListID); - if (itr != m_factions.end()) - { - if (standing > Reputation_Cap) - standing = Reputation_Cap; - else - if (standing < Reputation_Bottom) - standing = Reputation_Bottom; - - int32 BaseRep = GetBaseReputation(factionEntry); - itr->second.Standing = standing - BaseRep; - itr->second.Changed = true; - - SetFactionVisible(&itr->second); - - if(ReputationToRank(standing) <= REP_HOSTILE) - SetFactionAtWar(&itr->second,true); - - SendFactionState(&(itr->second)); - return true; - } - return false; -} - -//Calculate total reputation percent player gain with quest/creature level -int32 Player::CalculateReputationGain(uint32 creatureOrQuestLevel, int32 rep, bool for_quest) -{ - // for grey creature kill received 20%, in other case 100. - int32 percent = (!for_quest && (creatureOrQuestLevel <= MaNGOS::XP::GetGrayLevel(getLevel()))) ? 20 : 100; - - int32 repMod = GetTotalAuraModifier(SPELL_AURA_MOD_REPUTATION_GAIN); - - percent += rep > 0 ? repMod : -repMod; - - if(percent <=0) - return 0; - - return int32(sWorld.getRate(RATE_REPUTATION_GAIN)*rep*percent/100); -} - -//Calculates how many reputation points player gains in victim's enemy factions -void Player::RewardReputation(Unit *pVictim, float rate) -{ - if(!pVictim || pVictim->GetTypeId() == TYPEID_PLAYER) - return; - - ReputationOnKillEntry const* Rep = objmgr.GetReputationOnKilEntry(pVictim->GetEntry()); - - if(!Rep) - return; - - if(Rep->repfaction1 && (!Rep->team_dependent || GetTeam()==ALLIANCE)) - { - int32 donerep1 = CalculateReputationGain(pVictim->getLevel(),Rep->repvalue1,false); - donerep1 = int32(donerep1*rate); - FactionEntry const *factionEntry1 = sFactionStore.LookupEntry(Rep->repfaction1); - uint32 current_reputation_rank1 = GetReputationRank(factionEntry1); - if(factionEntry1 && current_reputation_rank1 <= Rep->reputration_max_cap1) - ModifyFactionReputation(factionEntry1, donerep1); - - // Wiki: Team factions value divided by 2 - if(Rep->is_teamaward1) - { - FactionEntry const *team1_factionEntry = sFactionStore.LookupEntry(factionEntry1->team); - if(team1_factionEntry) - ModifyFactionReputation(team1_factionEntry, donerep1 / 2); - } - } - - if(Rep->repfaction2 && (!Rep->team_dependent || GetTeam()==HORDE)) - { - int32 donerep2 = CalculateReputationGain(pVictim->getLevel(),Rep->repvalue2,false); - donerep2 = int32(donerep2*rate); - FactionEntry const *factionEntry2 = sFactionStore.LookupEntry(Rep->repfaction2); - uint32 current_reputation_rank2 = GetReputationRank(factionEntry2); - if(factionEntry2 && current_reputation_rank2 <= Rep->reputration_max_cap2) - ModifyFactionReputation(factionEntry2, donerep2); - - // Wiki: Team factions value divided by 2 - if(Rep->is_teamaward2) - { - FactionEntry const *team2_factionEntry = sFactionStore.LookupEntry(factionEntry2->team); - if(team2_factionEntry) - ModifyFactionReputation(team2_factionEntry, donerep2 / 2); - } - } -} - -//Calculate how many reputation points player gain with the quest -void Player::RewardReputation(Quest const *pQuest) -{ - // quest reputation reward/loss - for(int i = 0; i < QUEST_REPUTATIONS_COUNT; ++i) - { - if(pQuest->RewRepFaction[i] && pQuest->RewRepValue[i] ) - { - int32 rep = CalculateReputationGain(pQuest->GetQuestLevel(),pQuest->RewRepValue[i],true); - FactionEntry const* factionEntry = sFactionStore.LookupEntry(pQuest->RewRepFaction[i]); - if(factionEntry) - ModifyFactionReputation(factionEntry, rep); - } - } - - // TODO: implement reputation spillover -} - -void Player::UpdateArenaFields(void) -{ - /* arena calcs go here */ -} - -void Player::UpdateHonorFields() -{ - /// called when rewarding honor and at each save - uint64 now = time(NULL); - uint64 today = uint64(time(NULL) / DAY) * DAY; - - if(m_lastHonorUpdateTime < today) - { - uint64 yesterday = today - DAY; - - uint16 kills_today = PAIR32_LOPART(GetUInt32Value(PLAYER_FIELD_KILLS)); - - // update yesterday's contribution - if(m_lastHonorUpdateTime >= yesterday ) - { - SetUInt32Value(PLAYER_FIELD_YESTERDAY_CONTRIBUTION, GetUInt32Value(PLAYER_FIELD_TODAY_CONTRIBUTION)); - - // this is the first update today, reset today's contribution - SetUInt32Value(PLAYER_FIELD_TODAY_CONTRIBUTION, 0); - SetUInt32Value(PLAYER_FIELD_KILLS, MAKE_PAIR32(0,kills_today)); - } - else - { - // no honor/kills yesterday or today, reset - SetUInt32Value(PLAYER_FIELD_YESTERDAY_CONTRIBUTION, 0); - SetUInt32Value(PLAYER_FIELD_KILLS, 0); - } - } - - m_lastHonorUpdateTime = now; -} - -///Calculate the amount of honor gained based on the victim -///and the size of the group for which the honor is divided -///An exact honor value can also be given (overriding the calcs) -bool Player::RewardHonor(Unit *uVictim, uint32 groupsize, float honor) -{ - // 'Inactive' this aura prevents the player from gaining honor points and battleground tokens - if(GetDummyAura(SPELL_AURA_PLAYER_INACTIVE)) - return false; - - uint64 victim_guid = 0; - uint32 victim_rank = 0; - time_t now = time(NULL); - - // need call before fields update to have chance move yesterday data to appropriate fields before today data change. - UpdateHonorFields(); - - if(honor <= 0) - { - if(!uVictim || uVictim == this || uVictim->HasAuraType(SPELL_AURA_NO_PVP_CREDIT)) - return false; - - victim_guid = uVictim->GetGUID(); - - if( uVictim->GetTypeId() == TYPEID_PLAYER ) - { - Player *pVictim = (Player *)uVictim; - - if( GetTeam() == pVictim->GetTeam() && !sWorld.IsFFAPvPRealm() ) - return false; - - float f = 1; //need for total kills (?? need more info) - uint32 k_grey = 0; - uint32 k_level = getLevel(); - uint32 v_level = pVictim->getLevel(); - - { - // PLAYER_CHOSEN_TITLE VALUES DESCRIPTION - // [0] Just name - // [1..14] Alliance honor titles and player name - // [15..28] Horde honor titles and player name - // [29..38] Other title and player name - // [39+] Nothing - uint32 victim_title = pVictim->GetUInt32Value(PLAYER_CHOSEN_TITLE); - // Get Killer titles, CharTitlesEntry::bit_index - // Ranks: - // title[1..14] -> rank[5..18] - // title[15..28] -> rank[5..18] - // title[other] -> 0 - if (victim_title == 0) - victim_guid = 0; // Don't show HK: message, only log. - else if (victim_title < 15) - victim_rank = victim_title + 4; - else if (victim_title < 29) - victim_rank = victim_title - 14 + 4; - else - victim_guid = 0; // Don't show HK: message, only log. - } - - if(k_level <= 5) - k_grey = 0; - else if( k_level <= 39 ) - k_grey = k_level - 5 - k_level/10; - else - k_grey = k_level - 1 - k_level/5; - - if(v_level<=k_grey) - return false; - - float diff_level = (k_level == k_grey) ? 1 : ((float(v_level) - float(k_grey)) / (float(k_level) - float(k_grey))); - - int32 v_rank =1; //need more info - - honor = ((f * diff_level * (190 + v_rank*10))/6); - honor *= ((float)k_level) / 70.0f; //factor of dependence on levels of the killer - - // count the number of playerkills in one day - ApplyModUInt32Value(PLAYER_FIELD_KILLS, 1, true); - // and those in a lifetime - ApplyModUInt32Value(PLAYER_FIELD_LIFETIME_HONORBALE_KILLS, 1, true); - } - else - { - Creature *cVictim = (Creature *)uVictim; - - if (!cVictim->isRacialLeader()) - return false; - - honor = 100; // ??? need more info - victim_rank = 19; // HK: Leader - } - } - - if (uVictim != NULL) - { - honor *= sWorld.getRate(RATE_HONOR); - - if(groupsize > 1) - honor /= groupsize; - - honor *= (((float)urand(8,12))/10); // approx honor: 80% - 120% of real honor - } - - // honor - for show honor points in log - // victim_guid - for show victim name in log - // victim_rank [1..4] HK: - // victim_rank [5..19] HK: - // victim_rank [0,20+] HK: <> - WorldPacket data(SMSG_PVP_CREDIT,4+8+4); - data << (uint32) honor; - data << (uint64) victim_guid; - data << (uint32) victim_rank; - - GetSession()->SendPacket(&data); - - // add honor points - ModifyHonorPoints(int32(honor)); - - ApplyModUInt32Value(PLAYER_FIELD_TODAY_CONTRIBUTION, uint32(honor), true); - return true; -} - -void Player::ModifyHonorPoints( int32 value ) -{ - if(value < 0) - { - if (GetHonorPoints() > sWorld.getConfig(CONFIG_MAX_HONOR_POINTS)) - SetUInt32Value(PLAYER_FIELD_HONOR_CURRENCY, sWorld.getConfig(CONFIG_MAX_HONOR_POINTS) + value); - else - SetUInt32Value(PLAYER_FIELD_HONOR_CURRENCY, GetHonorPoints() > uint32(-value) ? GetHonorPoints() + value : 0); - } - else - SetUInt32Value(PLAYER_FIELD_HONOR_CURRENCY, GetHonorPoints() < sWorld.getConfig(CONFIG_MAX_HONOR_POINTS) - value ? GetHonorPoints() + value : sWorld.getConfig(CONFIG_MAX_HONOR_POINTS)); -} - -void Player::ModifyArenaPoints( int32 value ) -{ - if(value < 0) - { - if (GetArenaPoints() > sWorld.getConfig(CONFIG_MAX_ARENA_POINTS)) - SetUInt32Value(PLAYER_FIELD_ARENA_CURRENCY, sWorld.getConfig(CONFIG_MAX_ARENA_POINTS) + value); - else - SetUInt32Value(PLAYER_FIELD_ARENA_CURRENCY, GetArenaPoints() > uint32(-value) ? GetArenaPoints() + value : 0); - } - else - SetUInt32Value(PLAYER_FIELD_ARENA_CURRENCY, GetArenaPoints() < sWorld.getConfig(CONFIG_MAX_ARENA_POINTS) - value ? GetArenaPoints() + value : sWorld.getConfig(CONFIG_MAX_ARENA_POINTS)); -} - -uint32 Player::GetGuildIdFromDB(uint64 guid) -{ - std::ostringstream ss; - ss<<"SELECT guildid FROM guild_member WHERE guid='"<Fetch()[0].GetUInt32(); - delete result; - return v; - } - else - return 0; -} - -uint32 Player::GetRankFromDB(uint64 guid) -{ - std::ostringstream ss; - ss<<"SELECT rank FROM guild_member WHERE guid='"<Fetch()[0].GetUInt32(); - delete result; - return v; - } - else - return 0; -} - -uint32 Player::GetArenaTeamIdFromDB(uint64 guid, uint8 type) -{ - // need fix it! - QueryResult *result = CharacterDatabase.PQuery("SELECT arenateamid FROM arena_team_member WHERE guid='%u'", GUID_LOPART(guid)); - if(result) - { - // init id to 0, check the arena type before assigning a value to id - uint32 id = 0; - do - { - QueryResult *result2 = CharacterDatabase.PQuery("SELECT type FROM arena_team WHERE arenateamid='%u'", id); - if(result2) - { - uint8 dbtype = (*result2)[0].GetUInt32(); - delete result2; - if(dbtype == type) - { - // if the type matches, we've found the id - id = (*result)[0].GetUInt32(); - break; - } - } - } while(result->NextRow()); - delete result; - return id; - } - // no arenateam for the specified guid, return 0 - return 0; -} - -uint32 Player::GetZoneIdFromDB(uint64 guid) -{ - std::ostringstream ss; - - ss<<"SELECT zone FROM characters WHERE guid='"<Fetch(); - uint32 zone = fields[0].GetUInt32(); - delete result; - - if (!zone) - { - // stored zone is zero, use generic and slow zone detection - ss.str(""); - ss<<"SELECT map,position_x,position_y FROM characters WHERE guid='"<Fetch(); - uint32 map = fields[0].GetUInt32(); - float posx = fields[1].GetFloat(); - float posy = fields[2].GetFloat(); - delete result; - - zone = MapManager::Instance().GetZoneId(map,posx,posy); - - ss.str(""); - ss << "UPDATE characters SET zone='"<flags & AREA_FLAG_ARENA)) - { - if(!isGameMaster()) - SetFlag(PLAYER_FLAGS, PLAYER_FLAGS_FFA_PVP); - } - else - { - // remove ffa flag only if not ffapvp realm - // removal in sanctuaries and capitals is handled in zone update - if(HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_FFA_PVP) && !sWorld.IsFFAPvPRealm()) - RemoveFlag(PLAYER_FLAGS, PLAYER_FLAGS_FFA_PVP); - } - - UpdateAreaDependentAuras(newArea); -} - -void Player::UpdateZone(uint32 newZone) -{ - m_zoneUpdateId = newZone; - m_zoneUpdateTimer = ZONE_UPDATE_INTERVAL; - - // zone changed, so area changed as well, update it - UpdateArea(GetAreaId()); - - AreaTableEntry const* zone = GetAreaEntryByAreaID(newZone); - if(!zone) - return; - - if (sWorld.getConfig(CONFIG_WEATHER)) - { - Weather *wth = sWorld.FindWeather(zone->ID); - if(wth) - { - wth->SendWeatherUpdateToPlayer(this); - } - else - { - if(!sWorld.AddWeather(zone->ID)) - { - // send fine weather packet to remove old zone's weather - Weather::SendFineWeatherUpdateToPlayer(this); - } - } - } - - pvpInfo.inHostileArea = - GetTeam() == ALLIANCE && zone->team == AREATEAM_HORDE || - GetTeam() == HORDE && zone->team == AREATEAM_ALLY || - sWorld.IsPvPRealm() && zone->team == AREATEAM_NONE || - InBattleGround(); // overwrite for battlegrounds, maybe batter some zone flags but current known not 100% fit to this - - if(pvpInfo.inHostileArea) // in hostile area - { - if(!IsPvP() || pvpInfo.endTimer != 0) - UpdatePvP(true, true); - } - else // in friendly area - { - if(IsPvP() && !HasFlag(PLAYER_FLAGS,PLAYER_FLAGS_IN_PVP) && pvpInfo.endTimer == 0) - pvpInfo.endTimer = time(0); // start toggle-off - } - - if(zone->flags & AREA_FLAG_SANCTUARY) // in sanctuary - { - SetFlag(PLAYER_FLAGS, PLAYER_FLAGS_SANCTUARY); - if(sWorld.IsFFAPvPRealm()) - RemoveFlag(PLAYER_FLAGS,PLAYER_FLAGS_FFA_PVP); - } - else - { - RemoveFlag(PLAYER_FLAGS, PLAYER_FLAGS_SANCTUARY); - } - - if(zone->flags & AREA_FLAG_CAPITAL) // in capital city - { - SetFlag(PLAYER_FLAGS, PLAYER_FLAGS_RESTING); - SetRestType(REST_TYPE_IN_CITY); - InnEnter(time(0),GetMapId(),0,0,0); - - if(sWorld.IsFFAPvPRealm()) - RemoveFlag(PLAYER_FLAGS,PLAYER_FLAGS_FFA_PVP); - } - else // anywhere else - { - if(HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_RESTING)) // but resting (walk from city or maybe in tavern or leave tavern recently) - { - if(GetRestType()==REST_TYPE_IN_TAVERN) // has been in tavern. Is still in? - { - if(GetMapId()!=GetInnPosMapId() || sqrt((GetPositionX()-GetInnPosX())*(GetPositionX()-GetInnPosX())+(GetPositionY()-GetInnPosY())*(GetPositionY()-GetInnPosY())+(GetPositionZ()-GetInnPosZ())*(GetPositionZ()-GetInnPosZ()))>40) - { - RemoveFlag(PLAYER_FLAGS, PLAYER_FLAGS_RESTING); - SetRestType(REST_TYPE_NO); - - if(sWorld.IsFFAPvPRealm()) - SetFlag(PLAYER_FLAGS,PLAYER_FLAGS_FFA_PVP); - } - } - else // not in tavern (leave city then) - { - RemoveFlag(PLAYER_FLAGS, PLAYER_FLAGS_RESTING); - SetRestType(REST_TYPE_NO); - - // Set player to FFA PVP when not in rested enviroment. - if(sWorld.IsFFAPvPRealm()) - SetFlag(PLAYER_FLAGS,PLAYER_FLAGS_FFA_PVP); - } - } - } - - // remove items with area/map limitations (delete only for alive player to allow back in ghost mode) - // if player resurrected at teleport this will be applied in resurrect code - if(isAlive()) - DestroyZoneLimitedItem( true, newZone ); - - // recent client version not send leave/join channel packets for built-in local channels - UpdateLocalChannels( newZone ); - - // group update - if(GetGroup()) - SetGroupUpdateFlag(GROUP_UPDATE_FLAG_ZONE); - - UpdateZoneDependentAuras(newZone); -} - -//If players are too far way of duel flag... then player loose the duel -void Player::CheckDuelDistance(time_t currTime) -{ - if(!duel) - return; - - uint64 duelFlagGUID = GetUInt64Value(PLAYER_DUEL_ARBITER); - GameObject* obj = ObjectAccessor::GetGameObject(*this, duelFlagGUID); - if(!obj) - return; - - if(duel->outOfBound == 0) - { - if(!IsWithinDistInMap(obj, 50)) - { - duel->outOfBound = currTime; - - WorldPacket data(SMSG_DUEL_OUTOFBOUNDS, 0); - GetSession()->SendPacket(&data); - } - } - else - { - if(IsWithinDistInMap(obj, 40)) - { - duel->outOfBound = 0; - - WorldPacket data(SMSG_DUEL_INBOUNDS, 0); - GetSession()->SendPacket(&data); - } - else if(currTime >= (duel->outOfBound+10)) - { - DuelComplete(DUEL_FLED); - } - } -} - -void Player::DuelComplete(DuelCompleteType type) -{ - // duel not requested - if(!duel) - return; - - WorldPacket data(SMSG_DUEL_COMPLETE, (1)); - data << (uint8)((type != DUEL_INTERUPTED) ? 1 : 0); - GetSession()->SendPacket(&data); - duel->opponent->GetSession()->SendPacket(&data); - - if(type != DUEL_INTERUPTED) - { - data.Initialize(SMSG_DUEL_WINNER, (1+20)); // we guess size - data << (uint8)((type==DUEL_WON) ? 0 : 1); // 0 = just won; 1 = fled - data << duel->opponent->GetName(); - data << GetName(); - SendMessageToSet(&data,true); - } - - // cool-down duel spell - /*data.Initialize(SMSG_SPELL_COOLDOWN, 17); - - data<SendPacket(&data); - data.Initialize(SMSG_SPELL_COOLDOWN, 17); - data<opponent->GetGUID(); - data<opponent->GetSession()->SendPacket(&data);*/ - - //Remove Duel Flag object - GameObject* obj = ObjectAccessor::GetGameObject(*this, GetUInt64Value(PLAYER_DUEL_ARBITER)); - if(obj) - duel->initiator->RemoveGameObject(obj,true); - - /* remove auras */ - std::vector auras2remove; - AuraMap const& vAuras = duel->opponent->GetAuras(); - for (AuraMap::const_iterator i = vAuras.begin(); i != vAuras.end(); i++) - { - if (!i->second->IsPositive() && i->second->GetCasterGUID() == GetGUID() && i->second->GetAuraApplyTime() >= duel->startTime) - auras2remove.push_back(i->second->GetId()); - } - - for(size_t i=0; iopponent->RemoveAurasDueToSpell(auras2remove[i]); - - auras2remove.clear(); - AuraMap const& auras = GetAuras(); - for (AuraMap::const_iterator i = auras.begin(); i != auras.end(); i++) - { - if (!i->second->IsPositive() && i->second->GetCasterGUID() == duel->opponent->GetGUID() && i->second->GetAuraApplyTime() >= duel->startTime) - auras2remove.push_back(i->second->GetId()); - } - for(size_t i=0; iopponent->GetGUID()) - ClearComboPoints(); - else if(GetComboTarget()==duel->opponent->GetPetGUID()) - ClearComboPoints(); - - if(duel->opponent->GetComboTarget()==GetGUID()) - duel->opponent->ClearComboPoints(); - else if(duel->opponent->GetComboTarget()==GetPetGUID()) - duel->opponent->ClearComboPoints(); - - //cleanups - SetUInt64Value(PLAYER_DUEL_ARBITER, 0); - SetUInt32Value(PLAYER_DUEL_TEAM, 0); - duel->opponent->SetUInt64Value(PLAYER_DUEL_ARBITER, 0); - duel->opponent->SetUInt32Value(PLAYER_DUEL_TEAM, 0); - - delete duel->opponent->duel; - duel->opponent->duel = NULL; - delete duel; - duel = NULL; -} - -//---------------------------------------------------------// - -void Player::_ApplyItemMods(Item *item, uint8 slot,bool apply) -{ - if(slot >= INVENTORY_SLOT_BAG_END || !item) - return; - - // not apply/remove mods for broken item - if(item->IsBroken()) - return; - - ItemPrototype const *proto = item->GetProto(); - - if(!proto) - return; - - sLog.outDetail("applying mods for item %u ",item->GetGUIDLow()); - - uint32 attacktype = Player::GetAttackBySlot(slot); - if(attacktype < MAX_ATTACK) - _ApplyWeaponDependentAuraMods(item,WeaponAttackType(attacktype),apply); - - _ApplyItemBonuses(proto,slot,apply); - - if( slot==EQUIPMENT_SLOT_RANGED ) - _ApplyAmmoBonuses(); - - ApplyItemEquipSpell(item,apply); - ApplyEnchantment(item, apply); - - if(proto->Socket[0].Color) //only (un)equipping of items with sockets can influence metagems, so no need to waste time with normal items - CorrectMetaGemEnchants(slot, apply); - - sLog.outDebug("_ApplyItemMods complete."); -} - -void Player::_ApplyItemBonuses(ItemPrototype const *proto,uint8 slot,bool apply) -{ - if(slot >= INVENTORY_SLOT_BAG_END || !proto) - return; - - for (int i = 0; i < 10; i++) - { - float val = float (proto->ItemStat[i].ItemStatValue); - - if(val==0) - continue; - - switch (proto->ItemStat[i].ItemStatType) - { - case ITEM_MOD_MANA: - HandleStatModifier(UNIT_MOD_MANA, BASE_VALUE, float(val), apply); - break; - case ITEM_MOD_HEALTH: // modify HP - HandleStatModifier(UNIT_MOD_HEALTH, BASE_VALUE, float(val), apply); - break; - case ITEM_MOD_AGILITY: // modify agility - HandleStatModifier(UNIT_MOD_STAT_AGILITY, BASE_VALUE, float(val), apply); - ApplyStatBuffMod(STAT_AGILITY, val, apply); - break; - case ITEM_MOD_STRENGTH: //modify strength - HandleStatModifier(UNIT_MOD_STAT_STRENGTH, BASE_VALUE, float(val), apply); - ApplyStatBuffMod(STAT_STRENGTH, val, apply); - break; - case ITEM_MOD_INTELLECT: //modify intellect - HandleStatModifier(UNIT_MOD_STAT_INTELLECT, BASE_VALUE, float(val), apply); - ApplyStatBuffMod(STAT_INTELLECT, val, apply); - break; - case ITEM_MOD_SPIRIT: //modify spirit - HandleStatModifier(UNIT_MOD_STAT_SPIRIT, BASE_VALUE, float(val), apply); - ApplyStatBuffMod(STAT_SPIRIT, val, apply); - break; - case ITEM_MOD_STAMINA: //modify stamina - HandleStatModifier(UNIT_MOD_STAT_STAMINA, BASE_VALUE, float(val), apply); - ApplyStatBuffMod(STAT_STAMINA, val, apply); - break; - case ITEM_MOD_DEFENSE_SKILL_RATING: - ApplyRatingMod(CR_DEFENSE_SKILL, int32(val), apply); - break; - case ITEM_MOD_DODGE_RATING: - ApplyRatingMod(CR_DODGE, int32(val), apply); - break; - case ITEM_MOD_PARRY_RATING: - ApplyRatingMod(CR_PARRY, int32(val), apply); - break; - case ITEM_MOD_BLOCK_RATING: - ApplyRatingMod(CR_BLOCK, int32(val), apply); - break; - case ITEM_MOD_HIT_MELEE_RATING: - ApplyRatingMod(CR_HIT_MELEE, int32(val), apply); - break; - case ITEM_MOD_HIT_RANGED_RATING: - ApplyRatingMod(CR_HIT_RANGED, int32(val), apply); - break; - case ITEM_MOD_HIT_SPELL_RATING: - ApplyRatingMod(CR_HIT_SPELL, int32(val), apply); - break; - case ITEM_MOD_CRIT_MELEE_RATING: - ApplyRatingMod(CR_CRIT_MELEE, int32(val), apply); - break; - case ITEM_MOD_CRIT_RANGED_RATING: - ApplyRatingMod(CR_CRIT_RANGED, int32(val), apply); - break; - case ITEM_MOD_CRIT_SPELL_RATING: - ApplyRatingMod(CR_CRIT_SPELL, int32(val), apply); - break; - case ITEM_MOD_HIT_TAKEN_MELEE_RATING: - ApplyRatingMod(CR_HIT_TAKEN_MELEE, int32(val), apply); - break; - case ITEM_MOD_HIT_TAKEN_RANGED_RATING: - ApplyRatingMod(CR_HIT_TAKEN_RANGED, int32(val), apply); - break; - case ITEM_MOD_HIT_TAKEN_SPELL_RATING: - ApplyRatingMod(CR_HIT_TAKEN_SPELL, int32(val), apply); - break; - case ITEM_MOD_CRIT_TAKEN_MELEE_RATING: - ApplyRatingMod(CR_CRIT_TAKEN_MELEE, int32(val), apply); - break; - case ITEM_MOD_CRIT_TAKEN_RANGED_RATING: - ApplyRatingMod(CR_CRIT_TAKEN_RANGED, int32(val), apply); - break; - case ITEM_MOD_CRIT_TAKEN_SPELL_RATING: - ApplyRatingMod(CR_CRIT_TAKEN_SPELL, int32(val), apply); - break; - case ITEM_MOD_HASTE_MELEE_RATING: - ApplyRatingMod(CR_HASTE_MELEE, int32(val), apply); - break; - case ITEM_MOD_HASTE_RANGED_RATING: - ApplyRatingMod(CR_HASTE_RANGED, int32(val), apply); - break; - case ITEM_MOD_HASTE_SPELL_RATING: - ApplyRatingMod(CR_HASTE_SPELL, int32(val), apply); - break; - case ITEM_MOD_HIT_RATING: - ApplyRatingMod(CR_HIT_MELEE, int32(val), apply); - ApplyRatingMod(CR_HIT_RANGED, int32(val), apply); - ApplyRatingMod(CR_HIT_SPELL, int32(val), apply); - break; - case ITEM_MOD_CRIT_RATING: - ApplyRatingMod(CR_CRIT_MELEE, int32(val), apply); - ApplyRatingMod(CR_CRIT_RANGED, int32(val), apply); - ApplyRatingMod(CR_CRIT_SPELL, int32(val), apply); - break; - case ITEM_MOD_HIT_TAKEN_RATING: - ApplyRatingMod(CR_HIT_TAKEN_MELEE, int32(val), apply); - ApplyRatingMod(CR_HIT_TAKEN_RANGED, int32(val), apply); - ApplyRatingMod(CR_HIT_TAKEN_SPELL, int32(val), apply); - break; - case ITEM_MOD_CRIT_TAKEN_RATING: - ApplyRatingMod(CR_CRIT_TAKEN_MELEE, int32(val), apply); - ApplyRatingMod(CR_CRIT_TAKEN_RANGED, int32(val), apply); - ApplyRatingMod(CR_CRIT_TAKEN_SPELL, int32(val), apply); - break; - case ITEM_MOD_RESILIENCE_RATING: - ApplyRatingMod(CR_CRIT_TAKEN_MELEE, int32(val), apply); - ApplyRatingMod(CR_CRIT_TAKEN_RANGED, int32(val), apply); - ApplyRatingMod(CR_CRIT_TAKEN_SPELL, int32(val), apply); - break; - case ITEM_MOD_HASTE_RATING: - ApplyRatingMod(CR_HASTE_MELEE, int32(val), apply); - ApplyRatingMod(CR_HASTE_RANGED, int32(val), apply); - ApplyRatingMod(CR_HASTE_SPELL, int32(val), apply); - break; - case ITEM_MOD_EXPERTISE_RATING: - ApplyRatingMod(CR_EXPERTISE, int32(val), apply); - break; - } - } - - if (proto->Armor) - HandleStatModifier(UNIT_MOD_ARMOR, BASE_VALUE, float(proto->Armor), apply); - - if (proto->Block) - HandleBaseModValue(SHIELD_BLOCK_VALUE, FLAT_MOD, float(proto->Block), apply); - - if (proto->HolyRes) - HandleStatModifier(UNIT_MOD_RESISTANCE_HOLY, BASE_VALUE, float(proto->HolyRes), apply); - - if (proto->FireRes) - HandleStatModifier(UNIT_MOD_RESISTANCE_FIRE, BASE_VALUE, float(proto->FireRes), apply); - - if (proto->NatureRes) - HandleStatModifier(UNIT_MOD_RESISTANCE_NATURE, BASE_VALUE, float(proto->NatureRes), apply); - - if (proto->FrostRes) - HandleStatModifier(UNIT_MOD_RESISTANCE_FROST, BASE_VALUE, float(proto->FrostRes), apply); - - if (proto->ShadowRes) - HandleStatModifier(UNIT_MOD_RESISTANCE_SHADOW, BASE_VALUE, float(proto->ShadowRes), apply); - - if (proto->ArcaneRes) - HandleStatModifier(UNIT_MOD_RESISTANCE_ARCANE, BASE_VALUE, float(proto->ArcaneRes), apply); - - WeaponAttackType attType = BASE_ATTACK; - float damage = 0.0f; - - if( slot == EQUIPMENT_SLOT_RANGED && ( - proto->InventoryType == INVTYPE_RANGED || proto->InventoryType == INVTYPE_THROWN || - proto->InventoryType == INVTYPE_RANGEDRIGHT )) - { - attType = RANGED_ATTACK; - } - else if(slot==EQUIPMENT_SLOT_OFFHAND) - { - attType = OFF_ATTACK; - } - - if (proto->Damage[0].DamageMin > 0 ) - { - damage = apply ? proto->Damage[0].DamageMin : BASE_MINDAMAGE; - SetBaseWeaponDamage(attType, MINDAMAGE, damage); - //sLog.outError("applying mindam: assigning %f to weapon mindamage, now is: %f", damage, GetWeaponDamageRange(attType, MINDAMAGE)); - } - - if (proto->Damage[0].DamageMax > 0 ) - { - damage = apply ? proto->Damage[0].DamageMax : BASE_MAXDAMAGE; - SetBaseWeaponDamage(attType, MAXDAMAGE, damage); - } - - if(!IsUseEquipedWeapon(slot==EQUIPMENT_SLOT_MAINHAND)) - return; - - if (proto->Delay) - { - if(slot == EQUIPMENT_SLOT_RANGED) - SetAttackTime(RANGED_ATTACK, apply ? proto->Delay: BASE_ATTACK_TIME); - else if(slot==EQUIPMENT_SLOT_MAINHAND) - SetAttackTime(BASE_ATTACK, apply ? proto->Delay: BASE_ATTACK_TIME); - else if(slot==EQUIPMENT_SLOT_OFFHAND) - SetAttackTime(OFF_ATTACK, apply ? proto->Delay: BASE_ATTACK_TIME); - } - - if(CanModifyStats() && (damage || proto->Delay)) - UpdateDamagePhysical(attType); -} - -void Player::_ApplyWeaponDependentAuraMods(Item *item,WeaponAttackType attackType,bool apply) -{ - AuraList const& auraCritList = GetAurasByType(SPELL_AURA_MOD_CRIT_PERCENT); - for(AuraList::const_iterator itr = auraCritList.begin(); itr!=auraCritList.end();++itr) - _ApplyWeaponDependentAuraCritMod(item,attackType,*itr,apply); - - AuraList const& auraDamageFlatList = GetAurasByType(SPELL_AURA_MOD_DAMAGE_DONE); - for(AuraList::const_iterator itr = auraDamageFlatList.begin(); itr!=auraDamageFlatList.end();++itr) - _ApplyWeaponDependentAuraDamageMod(item,attackType,*itr,apply); - - AuraList const& auraDamagePCTList = GetAurasByType(SPELL_AURA_MOD_DAMAGE_PERCENT_DONE); - for(AuraList::const_iterator itr = auraDamagePCTList.begin(); itr!=auraDamagePCTList.end();++itr) - _ApplyWeaponDependentAuraDamageMod(item,attackType,*itr,apply); -} - -void Player::_ApplyWeaponDependentAuraCritMod(Item *item, WeaponAttackType attackType, Aura* aura, bool apply) -{ - // generic not weapon specific case processes in aura code - if(aura->GetSpellProto()->EquippedItemClass == -1) - return; - - BaseModGroup mod = BASEMOD_END; - switch(attackType) - { - case BASE_ATTACK: mod = CRIT_PERCENTAGE; break; - case OFF_ATTACK: mod = OFFHAND_CRIT_PERCENTAGE;break; - case RANGED_ATTACK: mod = RANGED_CRIT_PERCENTAGE; break; - default: return; - } - - if (item->IsFitToSpellRequirements(aura->GetSpellProto())) - { - HandleBaseModValue(mod, FLAT_MOD, float (aura->GetModifier()->m_amount), apply); - } -} - -void Player::_ApplyWeaponDependentAuraDamageMod(Item *item, WeaponAttackType attackType, Aura* aura, bool apply) -{ - // ignore spell mods for not wands - Modifier const* modifier = aura->GetModifier(); - if((modifier->m_miscvalue & SPELL_SCHOOL_MASK_NORMAL)==0 && (getClassMask() & CLASSMASK_WAND_USERS)==0) - return; - - // generic not weapon specific case processes in aura code - if(aura->GetSpellProto()->EquippedItemClass == -1) - return; - - UnitMods unitMod = UNIT_MOD_END; - switch(attackType) - { - case BASE_ATTACK: unitMod = UNIT_MOD_DAMAGE_MAINHAND; break; - case OFF_ATTACK: unitMod = UNIT_MOD_DAMAGE_OFFHAND; break; - case RANGED_ATTACK: unitMod = UNIT_MOD_DAMAGE_RANGED; break; - default: return; - } - - UnitModifierType unitModType = TOTAL_VALUE; - switch(modifier->m_auraname) - { - case SPELL_AURA_MOD_DAMAGE_DONE: unitModType = TOTAL_VALUE; break; - case SPELL_AURA_MOD_DAMAGE_PERCENT_DONE: unitModType = TOTAL_PCT; break; - default: return; - } - - if (item->IsFitToSpellRequirements(aura->GetSpellProto())) - { - HandleStatModifier(unitMod, unitModType, float(modifier->m_amount),apply); - } -} - -void Player::ApplyItemEquipSpell(Item *item, bool apply, bool form_change) -{ - if(!item) - return; - - ItemPrototype const *proto = item->GetProto(); - if(!proto) - return; - - for (int i = 0; i < 5; i++) - { - _Spell const& spellData = proto->Spells[i]; - - // no spell - if(!spellData.SpellId ) - continue; - - // wrong triggering type - if(apply && spellData.SpellTrigger != ITEM_SPELLTRIGGER_ON_EQUIP) - continue; - - // check if it is valid spell - SpellEntry const* spellproto = sSpellStore.LookupEntry(spellData.SpellId); - if(!spellproto) - continue; - - ApplyEquipSpell(spellproto,item,apply,form_change); - } -} - -void Player::ApplyEquipSpell(SpellEntry const* spellInfo, Item* item, bool apply, bool form_change) -{ - if(apply) - { - // Cannot be used in this stance/form - if(GetErrorAtShapeshiftedCast(spellInfo, m_form)!=0) - return; - - if(form_change) // check aura active state from other form - { - bool found = false; - for (int k=0; k < 3; ++k) - { - spellEffectPair spair = spellEffectPair(spellInfo->Id, k); - for (AuraMap::iterator iter = m_Auras.lower_bound(spair); iter != m_Auras.upper_bound(spair); ++iter) - { - if(!item || iter->second->GetCastItemGUID() == item->GetGUID()) - { - found = true; - break; - } - } - if(found) - break; - } - - if(found) // and skip re-cast already active aura at form change - return; - } - - DEBUG_LOG("WORLD: cast %s Equip spellId - %i", (item ? "item" : "itemset"), spellInfo->Id); - - CastSpell(this,spellInfo,true,item); - } - else - { - if(form_change) // check aura compatibility - { - // Cannot be used in this stance/form - if(GetErrorAtShapeshiftedCast(spellInfo, m_form)==0) - return; // and remove only not compatible at form change - } - - if(item) - RemoveAurasDueToItemSpell(item,spellInfo->Id); // un-apply all spells , not only at-equipped - else - RemoveAurasDueToSpell(spellInfo->Id); // un-apply spell (item set case) - } -} - -void Player::UpdateEquipSpellsAtFormChange() -{ - for (int i = 0; i < INVENTORY_SLOT_BAG_END; i++) - { - if(m_items[i] && !m_items[i]->IsBroken()) - { - ApplyItemEquipSpell(m_items[i],false,true); // remove spells that not fit to form - ApplyItemEquipSpell(m_items[i],true,true); // add spells that fit form but not active - } - } - - // item set bonuses not dependent from item broken state - for(size_t setindex = 0; setindex < ItemSetEff.size(); ++setindex) - { - ItemSetEffect* eff = ItemSetEff[setindex]; - if(!eff) - continue; - - for(uint32 y=0;y<8; ++y) - { - SpellEntry const* spellInfo = eff->spells[y]; - if(!spellInfo) - continue; - - ApplyEquipSpell(spellInfo,NULL,false,true); // remove spells that not fit to form - ApplyEquipSpell(spellInfo,NULL,true,true); // add spells that fit form but not active - } - } -} - -void Player::CastItemCombatSpell(Item *item,Unit* Target, WeaponAttackType attType) -{ - if(!item || item->IsBroken()) - return; - - ItemPrototype const *proto = item->GetProto(); - if(!proto) - return; - - if (!Target || Target == this ) - return; - - for (int i = 0; i < 5; i++) - { - _Spell const& spellData = proto->Spells[i]; - - // no spell - if(!spellData.SpellId ) - continue; - - // wrong triggering type - if(spellData.SpellTrigger != ITEM_SPELLTRIGGER_CHANCE_ON_HIT) - continue; - - SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellData.SpellId); - if(!spellInfo) - { - sLog.outError("WORLD: unknown Item spellid %i", spellData.SpellId); - continue; - } - - // not allow proc extra attack spell at extra attack - if( m_extraAttacks && IsSpellHaveEffect(spellInfo,SPELL_EFFECT_ADD_EXTRA_ATTACKS) ) - return; - - float chance = spellInfo->procChance; - - if(spellData.SpellPPMRate) - { - uint32 WeaponSpeed = GetAttackTime(attType); - chance = GetPPMProcChance(WeaponSpeed, spellData.SpellPPMRate); - } - else if(chance > 100.0f) - { - chance = GetWeaponProcChance(); - } - - if (roll_chance_f(chance)) - this->CastSpell(Target, spellInfo->Id, true, item); - } - - // item combat enchantments - for(int e_slot = 0; e_slot < MAX_ENCHANTMENT_SLOT; ++e_slot) - { - uint32 enchant_id = item->GetEnchantmentId(EnchantmentSlot(e_slot)); - SpellItemEnchantmentEntry const *pEnchant = sSpellItemEnchantmentStore.LookupEntry(enchant_id); - if(!pEnchant) continue; - for (int s=0;s<3;s++) - { - if(pEnchant->type[s]!=ITEM_ENCHANTMENT_TYPE_COMBAT_SPELL) - continue; - - SpellEntry const *spellInfo = sSpellStore.LookupEntry(pEnchant->spellid[s]); - if (!spellInfo) - { - sLog.outError("Player::CastItemCombatSpell Enchant %i, cast unknown spell %i", pEnchant->ID, pEnchant->spellid[s]); - continue; - } - - float chance = pEnchant->amount[s] != 0 ? float(pEnchant->amount[s]) : GetWeaponProcChance(); - if (roll_chance_f(chance)) - { - if(IsPositiveSpell(pEnchant->spellid[s])) - CastSpell(this, pEnchant->spellid[s], true, item); - else - CastSpell(Target, pEnchant->spellid[s], true, item); - } - } - } -} - -void Player::_RemoveAllItemMods() -{ - sLog.outDebug("_RemoveAllItemMods start."); - - for (int i = 0; i < INVENTORY_SLOT_BAG_END; i++) - { - if(m_items[i]) - { - ItemPrototype const *proto = m_items[i]->GetProto(); - if(!proto) - continue; - - // item set bonuses not dependent from item broken state - if(proto->ItemSet) - RemoveItemsSetItem(this,proto); - - if(m_items[i]->IsBroken()) - continue; - - ApplyItemEquipSpell(m_items[i],false); - ApplyEnchantment(m_items[i], false); - } - } - - for (int i = 0; i < INVENTORY_SLOT_BAG_END; i++) - { - if(m_items[i]) - { - if(m_items[i]->IsBroken()) - continue; - ItemPrototype const *proto = m_items[i]->GetProto(); - if(!proto) - continue; - - uint32 attacktype = Player::GetAttackBySlot(i); - if(attacktype < MAX_ATTACK) - _ApplyWeaponDependentAuraMods(m_items[i],WeaponAttackType(attacktype),false); - - _ApplyItemBonuses(proto,i, false); - - if( i == EQUIPMENT_SLOT_RANGED ) - _ApplyAmmoBonuses(); - } - } - - sLog.outDebug("_RemoveAllItemMods complete."); -} - -void Player::_ApplyAllItemMods() -{ - sLog.outDebug("_ApplyAllItemMods start."); - - for (int i = 0; i < INVENTORY_SLOT_BAG_END; i++) - { - if(m_items[i]) - { - if(m_items[i]->IsBroken()) - continue; - - ItemPrototype const *proto = m_items[i]->GetProto(); - if(!proto) - continue; - - uint32 attacktype = Player::GetAttackBySlot(i); - if(attacktype < MAX_ATTACK) - _ApplyWeaponDependentAuraMods(m_items[i],WeaponAttackType(attacktype),true); - - _ApplyItemBonuses(proto,i, true); - - if( i == EQUIPMENT_SLOT_RANGED ) - _ApplyAmmoBonuses(); - } - } - - for (int i = 0; i < INVENTORY_SLOT_BAG_END; i++) - { - if(m_items[i]) - { - ItemPrototype const *proto = m_items[i]->GetProto(); - if(!proto) - continue; - - // item set bonuses not dependent from item broken state - if(proto->ItemSet) - AddItemsSetItem(this,m_items[i]); - - if(m_items[i]->IsBroken()) - continue; - - ApplyItemEquipSpell(m_items[i],true); - ApplyEnchantment(m_items[i], true); - } - } - - sLog.outDebug("_ApplyAllItemMods complete."); -} - -void Player::_ApplyAmmoBonuses() -{ - // check ammo - uint32 ammo_id = GetUInt32Value(PLAYER_AMMO_ID); - if(!ammo_id) - return; - - float currentAmmoDPS; - - ItemPrototype const *ammo_proto = objmgr.GetItemPrototype( ammo_id ); - if( !ammo_proto || ammo_proto->Class!=ITEM_CLASS_PROJECTILE || !CheckAmmoCompatibility(ammo_proto)) - currentAmmoDPS = 0.0f; - else - currentAmmoDPS = ammo_proto->Damage[0].DamageMin; - - if(currentAmmoDPS == GetAmmoDPS()) - return; - - m_ammoDPS = currentAmmoDPS; - - if(CanModifyStats()) - UpdateDamagePhysical(RANGED_ATTACK); -} - -bool Player::CheckAmmoCompatibility(const ItemPrototype *ammo_proto) const -{ - if(!ammo_proto) - return false; - - // check ranged weapon - Item *weapon = GetWeaponForAttack( RANGED_ATTACK ); - if(!weapon || weapon->IsBroken() ) - return false; - - ItemPrototype const* weapon_proto = weapon->GetProto(); - if(!weapon_proto || weapon_proto->Class!=ITEM_CLASS_WEAPON ) - return false; - - // check ammo ws. weapon compatibility - switch(weapon_proto->SubClass) - { - case ITEM_SUBCLASS_WEAPON_BOW: - case ITEM_SUBCLASS_WEAPON_CROSSBOW: - if(ammo_proto->SubClass!=ITEM_SUBCLASS_ARROW) - return false; - break; - case ITEM_SUBCLASS_WEAPON_GUN: - if(ammo_proto->SubClass!=ITEM_SUBCLASS_BULLET) - return false; - break; - default: - return false; - } - - return true; -} - -/* If in a battleground a player dies, and an enemy removes the insignia, the player's bones is lootable - Called by remove insignia spell effect */ -void Player::RemovedInsignia(Player* looterPlr) -{ - if (!GetBattleGroundId()) - return; - - // If not released spirit, do it ! - if(m_deathTimer > 0) - { - m_deathTimer = 0; - BuildPlayerRepop(); - RepopAtGraveyard(); - } - - Corpse *corpse = GetCorpse(); - if (!corpse) - return; - - // We have to convert player corpse to bones, not to be able to resurrect there - // SpawnCorpseBones isn't handy, 'cos it saves player while he in BG - Corpse *bones = ObjectAccessor::Instance().ConvertCorpseForPlayer(GetGUID()); - if (!bones) - return; - - // Now we must make bones lootable, and send player loot - bones->SetFlag(CORPSE_FIELD_DYNAMIC_FLAGS, CORPSE_DYNFLAG_LOOTABLE); - - // We store the level of our player in the gold field - // We retrieve this information at Player::SendLoot() - bones->loot.gold = getLevel(); - bones->lootRecipient = looterPlr; - looterPlr->SendLoot(bones->GetGUID(), LOOT_INSIGNIA); -} - -/*Loot type MUST be -1-corpse, go -2-skinning -3-Fishing -*/ - -void Player::SendLootRelease( uint64 guid ) -{ - WorldPacket data( SMSG_LOOT_RELEASE_RESPONSE, (8+1) ); - data << uint64(guid) << uint8(1); - SendDirectMessage( &data ); -} - -void Player::SendLoot(uint64 guid, LootType loot_type) -{ - Loot *loot = 0; - PermissionTypes permission = ALL_PERMISSION; - - sLog.outDebug("Player::SendLoot"); - if (IS_GAMEOBJECT_GUID(guid)) - { - sLog.outDebug(" IS_GAMEOBJECT_GUID(guid)"); - GameObject *go = - ObjectAccessor::GetGameObject(*this, guid); - - // not check distance for GO in case owned GO (fishing bobber case, for example) - // And permit out of range GO with no owner in case fishing hole - if (!go || (loot_type != LOOT_FISHINGHOLE && (loot_type != LOOT_FISHING || go->GetOwnerGUID() != GetGUID()) && !go->IsWithinDistInMap(this,INTERACTION_DISTANCE))) - { - SendLootRelease(guid); - return; - } - - loot = &go->loot; - - if(go->getLootState() == GO_READY) - { - uint32 lootid = go->GetLootId(); - - if(lootid) - { - sLog.outDebug(" if(lootid)"); - loot->clear(); - loot->FillLoot(lootid, LootTemplates_Gameobject, this); - } - - if(loot_type == LOOT_FISHING) - go->getFishLoot(loot); - - go->SetLootState(GO_ACTIVATED); - } - } - else if (IS_ITEM_GUID(guid)) - { - Item *item = GetItemByGuid( guid ); - - if (!item) - { - SendLootRelease(guid); - return; - } - - if(loot_type == LOOT_DISENCHANTING) - { - loot = &item->loot; - - if(!item->m_lootGenerated) - { - item->m_lootGenerated = true; - loot->clear(); - loot->FillLoot(item->GetProto()->DisenchantID, LootTemplates_Disenchant, this); - } - } - else if(loot_type == LOOT_PROSPECTING) - { - loot = &item->loot; - - if(!item->m_lootGenerated) - { - item->m_lootGenerated = true; - loot->clear(); - loot->FillLoot(item->GetEntry(), LootTemplates_Prospecting, this); - } - } - else - { - loot = &item->loot; - - if(!item->m_lootGenerated) - { - item->m_lootGenerated = true; - loot->clear(); - loot->FillLoot(item->GetEntry(), LootTemplates_Item, this); - - loot->generateMoneyLoot(item->GetProto()->MinMoneyLoot,item->GetProto()->MaxMoneyLoot); - } - } - } - else if (IS_CORPSE_GUID(guid)) // remove insignia - { - Corpse *bones = ObjectAccessor::GetCorpse(*this, guid); - - if (!bones || !((loot_type == LOOT_CORPSE) || (loot_type == LOOT_INSIGNIA)) || (bones->GetType() != CORPSE_BONES) ) - { - SendLootRelease(guid); - return; - } - - loot = &bones->loot; - - if (!bones->lootForBody) - { - bones->lootForBody = true; - uint32 pLevel = bones->loot.gold; - bones->loot.clear(); - // It may need a better formula - // Now it works like this: lvl10: ~6copper, lvl70: ~9silver - bones->loot.gold = (uint32)( urand(50, 150) * 0.016f * pow( ((float)pLevel)/5.76f, 2.5f) * sWorld.getRate(RATE_DROP_MONEY) ); - } - - if (bones->lootRecipient != this) - permission = NONE_PERMISSION; - } - else - { - Creature *creature = ObjectAccessor::GetCreature(*this, guid); - - // must be in range and creature must be alive for pickpocket and must be dead for another loot - if (!creature || creature->isAlive()!=(loot_type == LOOT_PICKPOCKETING) || !creature->IsWithinDistInMap(this,INTERACTION_DISTANCE)) - { - SendLootRelease(guid); - return; - } - - if(loot_type == LOOT_PICKPOCKETING && IsFriendlyTo(creature)) - { - SendLootRelease(guid); - return; - } - - loot = &creature->loot; - - if(loot_type == LOOT_PICKPOCKETING) - { - if ( !creature->lootForPickPocketed ) - { - creature->lootForPickPocketed = true; - loot->clear(); - - if (uint32 lootid = creature->GetCreatureInfo()->pickpocketLootId) - loot->FillLoot(lootid, LootTemplates_Pickpocketing, this); - - // Generate extra money for pick pocket loot - const uint32 a = urand(0, creature->getLevel()/2); - const uint32 b = urand(0, getLevel()/2); - loot->gold = uint32(10 * (a + b) * sWorld.getRate(RATE_DROP_MONEY)); - } - } - else - { - // the player whose group may loot the corpse - Player *recipient = creature->GetLootRecipient(); - if (!recipient) - { - creature->SetLootRecipient(this); - recipient = this; - } - - if (creature->lootForPickPocketed) - { - creature->lootForPickPocketed = false; - loot->clear(); - } - - if(!creature->lootForBody) - { - creature->lootForBody = true; - loot->clear(); - - if (uint32 lootid = creature->GetCreatureInfo()->lootid) - loot->FillLoot(lootid, LootTemplates_Creature, recipient); - - loot->generateMoneyLoot(creature->GetCreatureInfo()->mingold,creature->GetCreatureInfo()->maxgold); - - if(Group* group = recipient->GetGroup()) - { - group->UpdateLooterGuid(creature,true); - - switch (group->GetLootMethod()) - { - case GROUP_LOOT: - // GroupLoot delete items over threshold (threshold even not implemented), and roll them. Items with qualityGroupLoot(recipient->GetGUID(), loot, creature); - break; - case NEED_BEFORE_GREED: - group->NeedBeforeGreed(recipient->GetGUID(), loot, creature); - break; - case MASTER_LOOT: - group->MasterLoot(recipient->GetGUID(), loot, creature); - break; - default: - break; - } - } - } - - // possible only if creature->lootForBody && loot->empty() at spell cast check - if (loot_type == LOOT_SKINNING) - { - loot->clear(); - loot->FillLoot(creature->GetCreatureInfo()->SkinLootId, LootTemplates_Skinning, this); - } - // set group rights only for loot_type != LOOT_SKINNING - else - { - if(Group* group = GetGroup()) - { - if( group == recipient->GetGroup() ) - { - if(group->GetLootMethod() == FREE_FOR_ALL) - permission = ALL_PERMISSION; - else if(group->GetLooterGuid() == GetGUID()) - { - if(group->GetLootMethod() == MASTER_LOOT) - permission = MASTER_PERMISSION; - else - permission = ALL_PERMISSION; - } - else - permission = GROUP_PERMISSION; - } - else - permission = NONE_PERMISSION; - } - else if(recipient == this) - permission = ALL_PERMISSION; - else - permission = NONE_PERMISSION; - } - } - } - - SetLootGUID(guid); - - QuestItemList *q_list = 0; - if (permission != NONE_PERMISSION) - { - QuestItemMap const& lootPlayerQuestItems = loot->GetPlayerQuestItems(); - QuestItemMap::const_iterator itr = lootPlayerQuestItems.find(GetGUIDLow()); - if (itr == lootPlayerQuestItems.end()) - q_list = loot->FillQuestLoot(this); - else - q_list = itr->second; - } - - QuestItemList *ffa_list = 0; - if (permission != NONE_PERMISSION) - { - QuestItemMap const& lootPlayerFFAItems = loot->GetPlayerFFAItems(); - QuestItemMap::const_iterator itr = lootPlayerFFAItems.find(GetGUIDLow()); - if (itr == lootPlayerFFAItems.end()) - ffa_list = loot->FillFFALoot(this); - else - ffa_list = itr->second; - } - - QuestItemList *conditional_list = 0; - if (permission != NONE_PERMISSION) - { - QuestItemMap const& lootPlayerNonQuestNonFFAConditionalItems = loot->GetPlayerNonQuestNonFFAConditionalItems(); - QuestItemMap::const_iterator itr = lootPlayerNonQuestNonFFAConditionalItems.find(GetGUIDLow()); - if (itr == lootPlayerNonQuestNonFFAConditionalItems.end()) - conditional_list = loot->FillNonQuestNonFFAConditionalLoot(this); - else - conditional_list = itr->second; - } - - // LOOT_PICKPOCKETING, LOOT_PROSPECTING, LOOT_DISENCHANTING and LOOT_INSIGNIA unsupported by client, sending LOOT_SKINNING instead - if(loot_type == LOOT_PICKPOCKETING || loot_type == LOOT_DISENCHANTING || loot_type == LOOT_PROSPECTING || loot_type == LOOT_INSIGNIA) - loot_type = LOOT_SKINNING; - - if(loot_type == LOOT_FISHINGHOLE) - loot_type = LOOT_FISHING; - - WorldPacket data(SMSG_LOOT_RESPONSE, (9+50)); // we guess size - - data << uint64(guid); - data << uint8(loot_type); - data << LootView(*loot, q_list, ffa_list, conditional_list, this, permission); - - SendDirectMessage(&data); - - // add 'this' player as one of the players that are looting 'loot' - if (permission != NONE_PERMISSION) - loot->AddLooter(GetGUID()); - - if ( loot_type == LOOT_CORPSE && !IS_ITEM_GUID(guid) ) - SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_LOOTING); -} - -void Player::SendNotifyLootMoneyRemoved() -{ - WorldPacket data(SMSG_LOOT_CLEAR_MONEY, 0); - GetSession()->SendPacket( &data ); -} - -void Player::SendNotifyLootItemRemoved(uint8 lootSlot) -{ - WorldPacket data(SMSG_LOOT_REMOVED, 1); - data << uint8(lootSlot); - GetSession()->SendPacket( &data ); -} - -void Player::SendUpdateWorldState(uint32 Field, uint32 Value) -{ - WorldPacket data(SMSG_UPDATE_WORLD_STATE, 8); - data << Field; - data << Value; - GetSession()->SendPacket(&data); -} - -void Player::SendInitWorldStates() -{ - // data depends on zoneid/mapid... - BattleGround* bg = GetBattleGround(); - uint16 NumberOfFields = 0; - uint32 mapid = GetMapId(); - uint32 zoneid = GetZoneId(); - uint32 areaid = GetAreaId(); - sLog.outDebug("Sending SMSG_INIT_WORLD_STATES to Map:%u, Zone: %u", mapid, zoneid); - // may be exist better way to do this... - switch(zoneid) - { - case 0: - case 1: - case 4: - case 8: - case 10: - case 11: - case 12: - case 36: - case 38: - case 40: - case 41: - case 51: - case 267: - case 1519: - case 1537: - case 2257: - case 2918: - NumberOfFields = 6; - break; - case 2597: - NumberOfFields = 81; - break; - case 3277: - NumberOfFields = 14; - break; - case 3358: - case 3820: - NumberOfFields = 38; - break; - case 3483: - NumberOfFields = 22; - break; - case 3519: - NumberOfFields = 36; - break; - case 3521: - NumberOfFields = 35; - break; - case 3698: - case 3702: - case 3968: - NumberOfFields = 9; - break; - case 3703: - NumberOfFields = 9; - break; - default: - NumberOfFields = 10; - break; - } - - WorldPacket data(SMSG_INIT_WORLD_STATES, (4+4+4+2+(NumberOfFields*8))); - data << uint32(mapid); // mapid - data << uint32(zoneid); // zone id - data << uint32(areaid); // area id, new 2.1.0 - data << uint16(NumberOfFields); // count of uint64 blocks - data << uint32(0x8d8) << uint32(0x0); // 1 - data << uint32(0x8d7) << uint32(0x0); // 2 - data << uint32(0x8d6) << uint32(0x0); // 3 - data << uint32(0x8d5) << uint32(0x0); // 4 - data << uint32(0x8d4) << uint32(0x0); // 5 - data << uint32(0x8d3) << uint32(0x0); // 6 - if(mapid == 530) // Outland - { - data << uint32(0x9bf) << uint32(0x0); // 7 - data << uint32(0x9bd) << uint32(0xF); // 8 - data << uint32(0x9bb) << uint32(0xF); // 9 - } - switch(zoneid) - { - case 1: - case 11: - case 12: - case 38: - case 40: - case 51: - case 1519: - case 1537: - case 2257: - break; - case 2597: // AV - data << uint32(0x7ae) << uint32(0x1); // 7 - data << uint32(0x532) << uint32(0x1); // 8 - data << uint32(0x531) << uint32(0x0); // 9 - data << uint32(0x52e) << uint32(0x0); // 10 - data << uint32(0x571) << uint32(0x0); // 11 - data << uint32(0x570) << uint32(0x0); // 12 - data << uint32(0x567) << uint32(0x1); // 13 - data << uint32(0x566) << uint32(0x1); // 14 - data << uint32(0x550) << uint32(0x1); // 15 - data << uint32(0x544) << uint32(0x0); // 16 - data << uint32(0x536) << uint32(0x0); // 17 - data << uint32(0x535) << uint32(0x1); // 18 - data << uint32(0x518) << uint32(0x0); // 19 - data << uint32(0x517) << uint32(0x0); // 20 - data << uint32(0x574) << uint32(0x0); // 21 - data << uint32(0x573) << uint32(0x0); // 22 - data << uint32(0x572) << uint32(0x0); // 23 - data << uint32(0x56f) << uint32(0x0); // 24 - data << uint32(0x56e) << uint32(0x0); // 25 - data << uint32(0x56d) << uint32(0x0); // 26 - data << uint32(0x56c) << uint32(0x0); // 27 - data << uint32(0x56b) << uint32(0x0); // 28 - data << uint32(0x56a) << uint32(0x1); // 29 - data << uint32(0x569) << uint32(0x1); // 30 - data << uint32(0x568) << uint32(0x1); // 13 - data << uint32(0x565) << uint32(0x0); // 32 - data << uint32(0x564) << uint32(0x0); // 33 - data << uint32(0x563) << uint32(0x0); // 34 - data << uint32(0x562) << uint32(0x0); // 35 - data << uint32(0x561) << uint32(0x0); // 36 - data << uint32(0x560) << uint32(0x0); // 37 - data << uint32(0x55f) << uint32(0x0); // 38 - data << uint32(0x55e) << uint32(0x0); // 39 - data << uint32(0x55d) << uint32(0x0); // 40 - data << uint32(0x3c6) << uint32(0x4); // 41 - data << uint32(0x3c4) << uint32(0x6); // 42 - data << uint32(0x3c2) << uint32(0x4); // 43 - data << uint32(0x516) << uint32(0x1); // 44 - data << uint32(0x515) << uint32(0x0); // 45 - data << uint32(0x3b6) << uint32(0x6); // 46 - data << uint32(0x55c) << uint32(0x0); // 47 - data << uint32(0x55b) << uint32(0x0); // 48 - data << uint32(0x55a) << uint32(0x0); // 49 - data << uint32(0x559) << uint32(0x0); // 50 - data << uint32(0x558) << uint32(0x0); // 51 - data << uint32(0x557) << uint32(0x0); // 52 - data << uint32(0x556) << uint32(0x0); // 53 - data << uint32(0x555) << uint32(0x0); // 54 - data << uint32(0x554) << uint32(0x1); // 55 - data << uint32(0x553) << uint32(0x1); // 56 - data << uint32(0x552) << uint32(0x1); // 57 - data << uint32(0x551) << uint32(0x1); // 58 - data << uint32(0x54f) << uint32(0x0); // 59 - data << uint32(0x54e) << uint32(0x0); // 60 - data << uint32(0x54d) << uint32(0x1); // 61 - data << uint32(0x54c) << uint32(0x0); // 62 - data << uint32(0x54b) << uint32(0x0); // 63 - data << uint32(0x545) << uint32(0x0); // 64 - data << uint32(0x543) << uint32(0x1); // 65 - data << uint32(0x542) << uint32(0x0); // 66 - data << uint32(0x540) << uint32(0x0); // 67 - data << uint32(0x53f) << uint32(0x0); // 68 - data << uint32(0x53e) << uint32(0x0); // 69 - data << uint32(0x53d) << uint32(0x0); // 70 - data << uint32(0x53c) << uint32(0x0); // 71 - data << uint32(0x53b) << uint32(0x0); // 72 - data << uint32(0x53a) << uint32(0x1); // 73 - data << uint32(0x539) << uint32(0x0); // 74 - data << uint32(0x538) << uint32(0x0); // 75 - data << uint32(0x537) << uint32(0x0); // 76 - data << uint32(0x534) << uint32(0x0); // 77 - data << uint32(0x533) << uint32(0x0); // 78 - data << uint32(0x530) << uint32(0x0); // 79 - data << uint32(0x52f) << uint32(0x0); // 80 - data << uint32(0x52d) << uint32(0x1); // 81 - break; - case 3277: // WS - if (bg && bg->GetTypeID() == BATTLEGROUND_WS) - bg->FillInitialWorldStates(data); - else - { - data << uint32(0x62d) << uint32(0x0); // 7 1581 alliance flag captures - data << uint32(0x62e) << uint32(0x0); // 8 1582 horde flag captures - data << uint32(0x609) << uint32(0x0); // 9 1545 unk, set to 1 on alliance flag pickup... - data << uint32(0x60a) << uint32(0x0); // 10 1546 unk, set to 1 on horde flag pickup, after drop it's -1 - data << uint32(0x60b) << uint32(0x2); // 11 1547 unk - data << uint32(0x641) << uint32(0x3); // 12 1601 unk (max flag captures?) - data << uint32(0x922) << uint32(0x1); // 13 2338 horde (0 - hide, 1 - flag ok, 2 - flag picked up (flashing), 3 - flag picked up (not flashing) - data << uint32(0x923) << uint32(0x1); // 14 2339 alliance (0 - hide, 1 - flag ok, 2 - flag picked up (flashing), 3 - flag picked up (not flashing) - } - break; - case 3358: // AB - if (bg && bg->GetTypeID() == BATTLEGROUND_AB) - bg->FillInitialWorldStates(data); - else - { - data << uint32(0x6e7) << uint32(0x0); // 7 1767 stables alliance - data << uint32(0x6e8) << uint32(0x0); // 8 1768 stables horde - data << uint32(0x6e9) << uint32(0x0); // 9 1769 unk, ST? - data << uint32(0x6ea) << uint32(0x0); // 10 1770 stables (show/hide) - data << uint32(0x6ec) << uint32(0x0); // 11 1772 farm (0 - horde controlled, 1 - alliance controlled) - data << uint32(0x6ed) << uint32(0x0); // 12 1773 farm (show/hide) - data << uint32(0x6ee) << uint32(0x0); // 13 1774 farm color - data << uint32(0x6ef) << uint32(0x0); // 14 1775 gold mine color, may be FM? - data << uint32(0x6f0) << uint32(0x0); // 15 1776 alliance resources - data << uint32(0x6f1) << uint32(0x0); // 16 1777 horde resources - data << uint32(0x6f2) << uint32(0x0); // 17 1778 horde bases - data << uint32(0x6f3) << uint32(0x0); // 18 1779 alliance bases - data << uint32(0x6f4) << uint32(0x7d0); // 19 1780 max resources (2000) - data << uint32(0x6f6) << uint32(0x0); // 20 1782 blacksmith color - data << uint32(0x6f7) << uint32(0x0); // 21 1783 blacksmith (show/hide) - data << uint32(0x6f8) << uint32(0x0); // 22 1784 unk, bs? - data << uint32(0x6f9) << uint32(0x0); // 23 1785 unk, bs? - data << uint32(0x6fb) << uint32(0x0); // 24 1787 gold mine (0 - horde contr, 1 - alliance contr) - data << uint32(0x6fc) << uint32(0x0); // 25 1788 gold mine (0 - conflict, 1 - horde) - data << uint32(0x6fd) << uint32(0x0); // 26 1789 gold mine (1 - show/0 - hide) - data << uint32(0x6fe) << uint32(0x0); // 27 1790 gold mine color - data << uint32(0x700) << uint32(0x0); // 28 1792 gold mine color, wtf?, may be LM? - data << uint32(0x701) << uint32(0x0); // 29 1793 lumber mill color (0 - conflict, 1 - horde contr) - data << uint32(0x702) << uint32(0x0); // 30 1794 lumber mill (show/hide) - data << uint32(0x703) << uint32(0x0); // 31 1795 lumber mill color color - data << uint32(0x732) << uint32(0x1); // 32 1842 stables (1 - uncontrolled) - data << uint32(0x733) << uint32(0x1); // 33 1843 gold mine (1 - uncontrolled) - data << uint32(0x734) << uint32(0x1); // 34 1844 lumber mill (1 - uncontrolled) - data << uint32(0x735) << uint32(0x1); // 35 1845 farm (1 - uncontrolled) - data << uint32(0x736) << uint32(0x1); // 36 1846 blacksmith (1 - uncontrolled) - data << uint32(0x745) << uint32(0x2); // 37 1861 unk - data << uint32(0x7a3) << uint32(0x708); // 38 1955 warning limit (1800) - } - break; - case 3820: // EY - if (bg && bg->GetTypeID() == BATTLEGROUND_EY) - bg->FillInitialWorldStates(data); - else - { - data << uint32(0xac1) << uint32(0x0); // 7 2753 Horde Bases - data << uint32(0xac0) << uint32(0x0); // 8 2752 Alliance Bases - data << uint32(0xab6) << uint32(0x0); // 9 2742 Mage Tower - Horde conflict - data << uint32(0xab5) << uint32(0x0); // 10 2741 Mage Tower - Alliance conflict - data << uint32(0xab4) << uint32(0x0); // 11 2740 Fel Reaver - Horde conflict - data << uint32(0xab3) << uint32(0x0); // 12 2739 Fel Reaver - Alliance conflict - data << uint32(0xab2) << uint32(0x0); // 13 2738 Draenei - Alliance conflict - data << uint32(0xab1) << uint32(0x0); // 14 2737 Draenei - Horde conflict - data << uint32(0xab0) << uint32(0x0); // 15 2736 unk // 0 at start - data << uint32(0xaaf) << uint32(0x0); // 16 2735 unk // 0 at start - data << uint32(0xaad) << uint32(0x0); // 17 2733 Draenei - Horde control - data << uint32(0xaac) << uint32(0x0); // 18 2732 Draenei - Alliance control - data << uint32(0xaab) << uint32(0x1); // 19 2731 Draenei uncontrolled (1 - yes, 0 - no) - data << uint32(0xaaa) << uint32(0x0); // 20 2730 Mage Tower - Alliance control - data << uint32(0xaa9) << uint32(0x0); // 21 2729 Mage Tower - Horde control - data << uint32(0xaa8) << uint32(0x1); // 22 2728 Mage Tower uncontrolled (1 - yes, 0 - no) - data << uint32(0xaa7) << uint32(0x0); // 23 2727 Fel Reaver - Horde control - data << uint32(0xaa6) << uint32(0x0); // 24 2726 Fel Reaver - Alliance control - data << uint32(0xaa5) << uint32(0x1); // 25 2725 Fel Reaver uncontroled (1 - yes, 0 - no) - data << uint32(0xaa4) << uint32(0x0); // 26 2724 Boold Elf - Horde control - data << uint32(0xaa3) << uint32(0x0); // 27 2723 Boold Elf - Alliance control - data << uint32(0xaa2) << uint32(0x1); // 28 2722 Boold Elf uncontrolled (1 - yes, 0 - no) - data << uint32(0xac5) << uint32(0x1); // 29 2757 Flag (1 - show, 0 - hide) - doesn't work exactly this way! - data << uint32(0xad2) << uint32(0x1); // 30 2770 Horde top-stats (1 - show, 0 - hide) // 02 -> horde picked up the flag - data << uint32(0xad1) << uint32(0x1); // 31 2769 Alliance top-stats (1 - show, 0 - hide) // 02 -> alliance picked up the flag - data << uint32(0xabe) << uint32(0x0); // 32 2750 Horde resources - data << uint32(0xabd) << uint32(0x0); // 33 2749 Alliance resources - data << uint32(0xa05) << uint32(0x8e); // 34 2565 unk, constant? - data << uint32(0xaa0) << uint32(0x0); // 35 2720 Capturing progress-bar (100 -> empty (only grey), 0 -> blue|red (no grey), default 0) - data << uint32(0xa9f) << uint32(0x0); // 36 2719 Capturing progress-bar (0 - left, 100 - right) - data << uint32(0xa9e) << uint32(0x0); // 37 2718 Capturing progress-bar (1 - show, 0 - hide) - data << uint32(0xc0d) << uint32(0x17b); // 38 3085 unk - // and some more ... unknown - } - break; - case 3483: // Hellfire Peninsula - data << uint32(0x9ba) << uint32(0x1); // 10 - data << uint32(0x9b9) << uint32(0x1); // 11 - data << uint32(0x9b5) << uint32(0x0); // 12 - data << uint32(0x9b4) << uint32(0x1); // 13 - data << uint32(0x9b3) << uint32(0x0); // 14 - data << uint32(0x9b2) << uint32(0x0); // 15 - data << uint32(0x9b1) << uint32(0x1); // 16 - data << uint32(0x9b0) << uint32(0x0); // 17 - data << uint32(0x9ae) << uint32(0x0); // 18 horde pvp objectives captured - data << uint32(0x9ac) << uint32(0x0); // 19 - data << uint32(0x9a8) << uint32(0x0); // 20 - data << uint32(0x9a7) << uint32(0x0); // 21 - data << uint32(0x9a6) << uint32(0x1); // 22 - break; - case 3519: // Terokkar Forest - data << uint32(0xa41) << uint32(0x0); // 10 - data << uint32(0xa40) << uint32(0x14); // 11 - data << uint32(0xa3f) << uint32(0x0); // 12 - data << uint32(0xa3e) << uint32(0x0); // 13 - data << uint32(0xa3d) << uint32(0x5); // 14 - data << uint32(0xa3c) << uint32(0x0); // 15 - data << uint32(0xa87) << uint32(0x0); // 16 - data << uint32(0xa86) << uint32(0x0); // 17 - data << uint32(0xa85) << uint32(0x0); // 18 - data << uint32(0xa84) << uint32(0x0); // 19 - data << uint32(0xa83) << uint32(0x0); // 20 - data << uint32(0xa82) << uint32(0x0); // 21 - data << uint32(0xa81) << uint32(0x0); // 22 - data << uint32(0xa80) << uint32(0x0); // 23 - data << uint32(0xa7e) << uint32(0x0); // 24 - data << uint32(0xa7d) << uint32(0x0); // 25 - data << uint32(0xa7c) << uint32(0x0); // 26 - data << uint32(0xa7b) << uint32(0x0); // 27 - data << uint32(0xa7a) << uint32(0x0); // 28 - data << uint32(0xa79) << uint32(0x0); // 29 - data << uint32(0x9d0) << uint32(0x5); // 30 - data << uint32(0x9ce) << uint32(0x0); // 31 - data << uint32(0x9cd) << uint32(0x0); // 32 - data << uint32(0x9cc) << uint32(0x0); // 33 - data << uint32(0xa88) << uint32(0x0); // 34 - data << uint32(0xad0) << uint32(0x0); // 35 - data << uint32(0xacf) << uint32(0x1); // 36 - break; - case 3521: // Zangarmarsh - data << uint32(0x9e1) << uint32(0x0); // 10 - data << uint32(0x9e0) << uint32(0x0); // 11 - data << uint32(0x9df) << uint32(0x0); // 12 - data << uint32(0xa5d) << uint32(0x1); // 13 - data << uint32(0xa5c) << uint32(0x0); // 14 - data << uint32(0xa5b) << uint32(0x1); // 15 - data << uint32(0xa5a) << uint32(0x0); // 16 - data << uint32(0xa59) << uint32(0x1); // 17 - data << uint32(0xa58) << uint32(0x0); // 18 - data << uint32(0xa57) << uint32(0x0); // 19 - data << uint32(0xa56) << uint32(0x0); // 20 - data << uint32(0xa55) << uint32(0x1); // 21 - data << uint32(0xa54) << uint32(0x0); // 22 - data << uint32(0x9e7) << uint32(0x0); // 23 - data << uint32(0x9e6) << uint32(0x0); // 24 - data << uint32(0x9e5) << uint32(0x0); // 25 - data << uint32(0xa00) << uint32(0x0); // 26 - data << uint32(0x9ff) << uint32(0x1); // 27 - data << uint32(0x9fe) << uint32(0x0); // 28 - data << uint32(0x9fd) << uint32(0x0); // 29 - data << uint32(0x9fc) << uint32(0x1); // 30 - data << uint32(0x9fb) << uint32(0x0); // 31 - data << uint32(0xa62) << uint32(0x0); // 32 - data << uint32(0xa61) << uint32(0x1); // 33 - data << uint32(0xa60) << uint32(0x1); // 34 - data << uint32(0xa5f) << uint32(0x0); // 35 - break; - case 3698: // Nagrand Arena - data << uint32(0xa0f) << uint32(0x0); // 7 - data << uint32(0xa10) << uint32(0x0); // 8 - data << uint32(0xa11) << uint32(0x0); // 9 - break; - case 3702: // Blade's Edge Arena - data << uint32(0x9f0) << uint32(0x0); // 7 - data << uint32(0x9f1) << uint32(0x0); // 8 - data << uint32(0x9f3) << uint32(0x0); // 9 - break; - case 3968: // Ruins of Lordaeron - data << uint32(0xbb8) << uint32(0x0); // 7 - data << uint32(0xbb9) << uint32(0x0); // 8 - data << uint32(0xbba) << uint32(0x0); // 9 - break; - case 3703: // Shattrath City - break; - default: - data << uint32(0x914) << uint32(0x0); // 7 - data << uint32(0x913) << uint32(0x0); // 8 - data << uint32(0x912) << uint32(0x0); // 9 - data << uint32(0x915) << uint32(0x0); // 10 - break; - } - GetSession()->SendPacket(&data); -} - -uint32 Player::GetXPRestBonus(uint32 xp) -{ - uint32 rested_bonus = (uint32)GetRestBonus(); // xp for each rested bonus - - if(rested_bonus > xp) // max rested_bonus == xp or (r+x) = 200% xp - rested_bonus = xp; - - SetRestBonus( GetRestBonus() - rested_bonus); - - sLog.outDetail("Player gain %u xp (+ %u Rested Bonus). Rested points=%f",xp+rested_bonus,rested_bonus,GetRestBonus()); - return rested_bonus; -} - -void Player::SetBindPoint(uint64 guid) -{ - WorldPacket data(SMSG_BINDER_CONFIRM, 8); - data << uint64(guid); - GetSession()->SendPacket( &data ); -} - -void Player::SendTalentWipeConfirm(uint64 guid) -{ - WorldPacket data(MSG_TALENT_WIPE_CONFIRM, (8+4)); - data << uint64(guid); - data << uint32(resetTalentsCost()); - GetSession()->SendPacket( &data ); -} - -void Player::SendPetSkillWipeConfirm() -{ - Pet* pet = GetPet(); - if(!pet) - return; - WorldPacket data(SMSG_PET_UNLEARN_CONFIRM, (8+4)); - data << pet->GetGUID(); - data << uint32(pet->resetTalentsCost()); - GetSession()->SendPacket( &data ); -} - -/*********************************************************/ -/*** STORAGE SYSTEM ***/ -/*********************************************************/ - -void Player::SetVirtualItemSlot( uint8 i, Item* item) -{ - assert(i < 3); - if(i < 2 && item) - { - if(!item->GetEnchantmentId(TEMP_ENCHANTMENT_SLOT)) - return; - uint32 charges = item->GetEnchantmentCharges(TEMP_ENCHANTMENT_SLOT); - if(charges == 0) - return; - if(charges > 1) - item->SetEnchantmentCharges(TEMP_ENCHANTMENT_SLOT,charges-1); - else if(charges <= 1) - { - ApplyEnchantment(item,TEMP_ENCHANTMENT_SLOT,false); - item->ClearEnchantment(TEMP_ENCHANTMENT_SLOT); - } - } -} - -void Player::SetSheath( uint32 sheathed ) -{ - switch (sheathed) - { - case SHEATH_STATE_UNARMED: // no prepared weapon - SetVirtualItemSlot(0,NULL); - SetVirtualItemSlot(1,NULL); - SetVirtualItemSlot(2,NULL); - break; - case SHEATH_STATE_MELEE: // prepared melee weapon - { - SetVirtualItemSlot(0,GetWeaponForAttack(BASE_ATTACK,true)); - SetVirtualItemSlot(1,GetWeaponForAttack(OFF_ATTACK,true)); - SetVirtualItemSlot(2,NULL); - }; break; - case SHEATH_STATE_RANGED: // prepared ranged weapon - SetVirtualItemSlot(0,NULL); - SetVirtualItemSlot(1,NULL); - SetVirtualItemSlot(2,GetWeaponForAttack(RANGED_ATTACK,true)); - break; - default: - SetVirtualItemSlot(0,NULL); - SetVirtualItemSlot(1,NULL); - SetVirtualItemSlot(2,NULL); - break; - } - SetByteValue(UNIT_FIELD_BYTES_2, 0, sheathed); // this must visualize Sheath changing for other players... -} - -uint8 Player::FindEquipSlot( ItemPrototype const* proto, uint32 slot, bool swap ) const -{ - uint8 pClass = getClass(); - - uint8 slots[4]; - slots[0] = NULL_SLOT; - slots[1] = NULL_SLOT; - slots[2] = NULL_SLOT; - slots[3] = NULL_SLOT; - switch( proto->InventoryType ) - { - case INVTYPE_HEAD: - slots[0] = EQUIPMENT_SLOT_HEAD; - break; - case INVTYPE_NECK: - slots[0] = EQUIPMENT_SLOT_NECK; - break; - case INVTYPE_SHOULDERS: - slots[0] = EQUIPMENT_SLOT_SHOULDERS; - break; - case INVTYPE_BODY: - slots[0] = EQUIPMENT_SLOT_BODY; - break; - case INVTYPE_CHEST: - slots[0] = EQUIPMENT_SLOT_CHEST; - break; - case INVTYPE_ROBE: - slots[0] = EQUIPMENT_SLOT_CHEST; - break; - case INVTYPE_WAIST: - slots[0] = EQUIPMENT_SLOT_WAIST; - break; - case INVTYPE_LEGS: - slots[0] = EQUIPMENT_SLOT_LEGS; - break; - case INVTYPE_FEET: - slots[0] = EQUIPMENT_SLOT_FEET; - break; - case INVTYPE_WRISTS: - slots[0] = EQUIPMENT_SLOT_WRISTS; - break; - case INVTYPE_HANDS: - slots[0] = EQUIPMENT_SLOT_HANDS; - break; - case INVTYPE_FINGER: - slots[0] = EQUIPMENT_SLOT_FINGER1; - slots[1] = EQUIPMENT_SLOT_FINGER2; - break; - case INVTYPE_TRINKET: - slots[0] = EQUIPMENT_SLOT_TRINKET1; - slots[1] = EQUIPMENT_SLOT_TRINKET2; - break; - case INVTYPE_CLOAK: - slots[0] = EQUIPMENT_SLOT_BACK; - break; - case INVTYPE_WEAPON: - { - slots[0] = EQUIPMENT_SLOT_MAINHAND; - - // suggest offhand slot only if know dual wielding - // (this will be replace mainhand weapon at auto equip instead unwonted "you don't known dual wielding" ... - if(CanDualWield()) - slots[1] = EQUIPMENT_SLOT_OFFHAND; - };break; - case INVTYPE_SHIELD: - slots[0] = EQUIPMENT_SLOT_OFFHAND; - break; - case INVTYPE_RANGED: - slots[0] = EQUIPMENT_SLOT_RANGED; - break; - case INVTYPE_2HWEAPON: - slots[0] = EQUIPMENT_SLOT_MAINHAND; - break; - case INVTYPE_TABARD: - slots[0] = EQUIPMENT_SLOT_TABARD; - break; - case INVTYPE_WEAPONMAINHAND: - slots[0] = EQUIPMENT_SLOT_MAINHAND; - break; - case INVTYPE_WEAPONOFFHAND: - slots[0] = EQUIPMENT_SLOT_OFFHAND; - break; - case INVTYPE_HOLDABLE: - slots[0] = EQUIPMENT_SLOT_OFFHAND; - break; - case INVTYPE_THROWN: - slots[0] = EQUIPMENT_SLOT_RANGED; - break; - case INVTYPE_RANGEDRIGHT: - slots[0] = EQUIPMENT_SLOT_RANGED; - break; - case INVTYPE_BAG: - slots[0] = INVENTORY_SLOT_BAG_1; - slots[1] = INVENTORY_SLOT_BAG_2; - slots[2] = INVENTORY_SLOT_BAG_3; - slots[3] = INVENTORY_SLOT_BAG_4; - break; - case INVTYPE_RELIC: - { - switch(proto->SubClass) - { - case ITEM_SUBCLASS_ARMOR_LIBRAM: - if (pClass == CLASS_PALADIN) - slots[0] = EQUIPMENT_SLOT_RANGED; - break; - case ITEM_SUBCLASS_ARMOR_IDOL: - if (pClass == CLASS_DRUID) - slots[0] = EQUIPMENT_SLOT_RANGED; - break; - case ITEM_SUBCLASS_ARMOR_TOTEM: - if (pClass == CLASS_SHAMAN) - slots[0] = EQUIPMENT_SLOT_RANGED; - break; - case ITEM_SUBCLASS_ARMOR_MISC: - if (pClass == CLASS_WARLOCK) - slots[0] = EQUIPMENT_SLOT_RANGED; - break; - } - break; - } - default : - return NULL_SLOT; - } - - if( slot != NULL_SLOT ) - { - if( swap || !GetItemByPos( INVENTORY_SLOT_BAG_0, slot ) ) - { - for (int i = 0; i < 4; i++) - { - if ( slots[i] == slot ) - return slot; - } - } - } - else - { - // search free slot at first - for (int i = 0; i < 4; i++) - { - if ( slots[i] != NULL_SLOT && !GetItemByPos( INVENTORY_SLOT_BAG_0, slots[i] ) ) - { - // in case 2hand equipped weapon offhand slot empty but not free - if(slots[i]==EQUIPMENT_SLOT_OFFHAND) - { - Item* mainItem = GetItemByPos( INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_MAINHAND ); - if(!mainItem || mainItem->GetProto()->InventoryType != INVTYPE_2HWEAPON) - return slots[i]; - } - else - return slots[i]; - } - } - - // if not found free and can swap return first appropriate from used - for (int i = 0; i < 4; i++) - { - if ( slots[i] != NULL_SLOT && swap ) - return slots[i]; - } - } - - // no free position - return NULL_SLOT; -} - -uint8 Player::CanUnequipItems( uint32 item, uint32 count ) const -{ - Item *pItem; - uint32 tempcount = 0; - - uint8 res = EQUIP_ERR_OK; - - for(int i = EQUIPMENT_SLOT_START; i < INVENTORY_SLOT_BAG_END; i++) - { - pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i ); - if( pItem && pItem->GetEntry() == item ) - { - uint8 ires = CanUnequipItem(INVENTORY_SLOT_BAG_0 << 8 | i, false); - if(ires==EQUIP_ERR_OK) - { - tempcount += pItem->GetCount(); - if( tempcount >= count ) - return EQUIP_ERR_OK; - } - else - res = ires; - } - } - for(int i = INVENTORY_SLOT_ITEM_START; i < INVENTORY_SLOT_ITEM_END; i++) - { - pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i ); - if( pItem && pItem->GetEntry() == item ) - { - tempcount += pItem->GetCount(); - if( tempcount >= count ) - return EQUIP_ERR_OK; - } - } - for(int i = KEYRING_SLOT_START; i < KEYRING_SLOT_END; i++) - { - pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i ); - if( pItem && pItem->GetEntry() == item ) - { - tempcount += pItem->GetCount(); - if( tempcount >= count ) - return EQUIP_ERR_OK; - } - } - Bag *pBag; - ItemPrototype const *pBagProto; - for(int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; i++) - { - pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i ); - if( pBag ) - { - pBagProto = pBag->GetProto(); - if( pBagProto ) - { - for(uint32 j = 0; j < pBagProto->ContainerSlots; j++) - { - pItem = GetItemByPos( i, j ); - if( pItem && pItem->GetEntry() == item ) - { - tempcount += pItem->GetCount(); - if( tempcount >= count ) - return EQUIP_ERR_OK; - } - } - } - } - } - - // not found req. item count and have unequippable items - return res; -} - -uint32 Player::GetItemCount( uint32 item, bool inBankAlso, Item* skipItem ) const -{ - uint32 count = 0; - for(int i = EQUIPMENT_SLOT_START; i < INVENTORY_SLOT_ITEM_END; i++) - { - Item *pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i ); - if( pItem && pItem != skipItem && pItem->GetEntry() == item ) - count += pItem->GetCount(); - } - for(int i = KEYRING_SLOT_START; i < KEYRING_SLOT_END; i++) - { - Item *pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i ); - if( pItem && pItem != skipItem && pItem->GetEntry() == item ) - count += pItem->GetCount(); - } - for(int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; i++) - { - Bag* pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i ); - if( pBag ) - count += pBag->GetItemCount(item,skipItem); - } - - if(skipItem && skipItem->GetProto()->GemProperties) - { - for(int i = EQUIPMENT_SLOT_START; i < INVENTORY_SLOT_ITEM_END; i++) - { - Item *pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i ); - if( pItem && pItem != skipItem && pItem->GetProto()->Socket[0].Color ) - count += pItem->GetGemCountWithID(item); - } - } - - if(inBankAlso) - { - for(int i = BANK_SLOT_ITEM_START; i < BANK_SLOT_ITEM_END; i++) - { - Item* pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i ); - if( pItem && pItem != skipItem && pItem->GetEntry() == item ) - count += pItem->GetCount(); - } - for(int i = BANK_SLOT_BAG_START; i < BANK_SLOT_BAG_END; i++) - { - Bag* pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i ); - if( pBag ) - count += pBag->GetItemCount(item,skipItem); - } - - if(skipItem && skipItem->GetProto()->GemProperties) - { - for(int i = BANK_SLOT_ITEM_START; i < BANK_SLOT_ITEM_END; i++) - { - Item* pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i ); - if( pItem && pItem != skipItem && pItem->GetProto()->Socket[0].Color ) - count += pItem->GetGemCountWithID(item); - } - } - } - - return count; -} - -Item* Player::GetItemByGuid( uint64 guid ) const -{ - for(int i = EQUIPMENT_SLOT_START; i < INVENTORY_SLOT_ITEM_END; i++) - { - Item *pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i ); - if( pItem && pItem->GetGUID() == guid ) - return pItem; - } - for(int i = KEYRING_SLOT_START; i < KEYRING_SLOT_END; i++) - { - Item *pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i ); - if( pItem && pItem->GetGUID() == guid ) - return pItem; - } - - for(int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; i++) - { - Bag *pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i ); - if( pBag ) - { - ItemPrototype const *pBagProto = pBag->GetProto(); - if( pBagProto ) - { - for(uint32 j = 0; j < pBagProto->ContainerSlots; j++) - { - Item* pItem = pBag->GetItemByPos( j ); - if( pItem && pItem->GetGUID() == guid ) - return pItem; - } - } - } - } - for(int i = BANK_SLOT_BAG_START; i < BANK_SLOT_BAG_END; i++) - { - Bag *pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i ); - if( pBag ) - { - ItemPrototype const *pBagProto = pBag->GetProto(); - if( pBagProto ) - { - for(uint32 j = 0; j < pBagProto->ContainerSlots; j++) - { - Item* pItem = pBag->GetItemByPos( j ); - if( pItem && pItem->GetGUID() == guid ) - return pItem; - } - } - } - } - - return NULL; -} - -Item* Player::GetItemByPos( uint16 pos ) const -{ - uint8 bag = pos >> 8; - uint8 slot = pos & 255; - return GetItemByPos( bag, slot ); -} - -Item* Player::GetItemByPos( uint8 bag, uint8 slot ) const -{ - if( bag == INVENTORY_SLOT_BAG_0 && ( slot < BANK_SLOT_BAG_END || slot >= KEYRING_SLOT_START && slot < KEYRING_SLOT_END ) ) - return m_items[slot]; - else if(bag >= INVENTORY_SLOT_BAG_START && bag < INVENTORY_SLOT_BAG_END - || bag >= BANK_SLOT_BAG_START && bag < BANK_SLOT_BAG_END ) - { - Bag *pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, bag ); - if ( pBag ) - return pBag->GetItemByPos(slot); - } - return NULL; -} - -Item* Player::GetWeaponForAttack(WeaponAttackType attackType, bool useable) const -{ - uint16 slot; - switch (attackType) - { - case BASE_ATTACK: slot = EQUIPMENT_SLOT_MAINHAND; break; - case OFF_ATTACK: slot = EQUIPMENT_SLOT_OFFHAND; break; - case RANGED_ATTACK: slot = EQUIPMENT_SLOT_RANGED; break; - default: return NULL; - } - - Item* item = GetItemByPos(INVENTORY_SLOT_BAG_0, slot); - if (!item || item->GetProto()->Class != ITEM_CLASS_WEAPON) - return NULL; - - if(!useable) - return item; - - if( item->IsBroken() || !IsUseEquipedWeapon(attackType==BASE_ATTACK) ) - return NULL; - - return item; -} - -Item* Player::GetShield(bool useable) const -{ - Item* item = GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND); - if (!item || item->GetProto()->Class != ITEM_CLASS_ARMOR) - return NULL; - - if(!useable) - return item; - - if( item->IsBroken()) - return NULL; - - return item; -} - -uint32 Player::GetAttackBySlot( uint8 slot ) -{ - switch(slot) - { - case EQUIPMENT_SLOT_MAINHAND: return BASE_ATTACK; - case EQUIPMENT_SLOT_OFFHAND: return OFF_ATTACK; - case EQUIPMENT_SLOT_RANGED: return RANGED_ATTACK; - default: return MAX_ATTACK; - } -} - -bool Player::HasBankBagSlot( uint8 slot ) const -{ - uint32 maxslot = GetByteValue(PLAYER_BYTES_2, 2) + BANK_SLOT_BAG_START; - if( slot < maxslot ) - return true; - return false; -} - -bool Player::IsInventoryPos( uint8 bag, uint8 slot ) -{ - if( bag == INVENTORY_SLOT_BAG_0 && slot == NULL_SLOT ) - return true; - if( bag == INVENTORY_SLOT_BAG_0 && ( slot >= INVENTORY_SLOT_ITEM_START && slot < INVENTORY_SLOT_ITEM_END ) ) - return true; - if( bag >= INVENTORY_SLOT_BAG_START && bag < INVENTORY_SLOT_BAG_END ) - return true; - if( bag == INVENTORY_SLOT_BAG_0 && ( slot >= KEYRING_SLOT_START && slot < KEYRING_SLOT_END ) ) - return true; - return false; -} - -bool Player::IsEquipmentPos( uint8 bag, uint8 slot ) -{ - if( bag == INVENTORY_SLOT_BAG_0 && ( slot < EQUIPMENT_SLOT_END ) ) - return true; - if( bag == INVENTORY_SLOT_BAG_0 && ( slot >= INVENTORY_SLOT_BAG_START && slot < INVENTORY_SLOT_BAG_END ) ) - return true; - return false; -} - -bool Player::IsBankPos( uint8 bag, uint8 slot ) -{ - if( bag == INVENTORY_SLOT_BAG_0 && ( slot >= BANK_SLOT_ITEM_START && slot < BANK_SLOT_ITEM_END ) ) - return true; - if( bag == INVENTORY_SLOT_BAG_0 && ( slot >= BANK_SLOT_BAG_START && slot < BANK_SLOT_BAG_END ) ) - return true; - if( bag >= BANK_SLOT_BAG_START && bag < BANK_SLOT_BAG_END ) - return true; - return false; -} - -bool Player::IsBagPos( uint16 pos ) -{ - uint8 bag = pos >> 8; - uint8 slot = pos & 255; - if( bag == INVENTORY_SLOT_BAG_0 && ( slot >= INVENTORY_SLOT_BAG_START && slot < INVENTORY_SLOT_BAG_END ) ) - return true; - if( bag == INVENTORY_SLOT_BAG_0 && ( slot >= BANK_SLOT_BAG_START && slot < BANK_SLOT_BAG_END ) ) - return true; - return false; -} - -bool Player::HasItemCount( uint32 item, uint32 count, bool inBankAlso ) const -{ - uint32 tempcount = 0; - for(int i = EQUIPMENT_SLOT_START; i < INVENTORY_SLOT_ITEM_END; i++) - { - Item *pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i ); - if( pItem && pItem->GetEntry() == item ) - { - tempcount += pItem->GetCount(); - if( tempcount >= count ) - return true; - } - } - for(int i = KEYRING_SLOT_START; i < KEYRING_SLOT_END; i++) - { - Item *pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i ); - if( pItem && pItem->GetEntry() == item ) - { - tempcount += pItem->GetCount(); - if( tempcount >= count ) - return true; - } - } - for(int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; i++) - { - if(Bag* pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i )) - { - if(ItemPrototype const *pBagProto = pBag->GetProto()) - { - for(uint32 j = 0; j < pBagProto->ContainerSlots; j++) - { - Item* pItem = GetItemByPos( i, j ); - if( pItem && pItem->GetEntry() == item ) - { - tempcount += pItem->GetCount(); - if( tempcount >= count ) - return true; - } - } - } - } - } - - if(inBankAlso) - { - for(int i = BANK_SLOT_ITEM_START; i < BANK_SLOT_ITEM_END; i++) - { - Item *pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i ); - if( pItem && pItem->GetEntry() == item ) - { - tempcount += pItem->GetCount(); - if( tempcount >= count ) - return true; - } - } - for(int i = BANK_SLOT_BAG_START; i < BANK_SLOT_BAG_END; i++) - { - if(Bag* pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i )) - { - if(ItemPrototype const *pBagProto = pBag->GetProto()) - { - for(uint32 j = 0; j < pBagProto->ContainerSlots; j++) - { - Item* pItem = GetItemByPos( i, j ); - if( pItem && pItem->GetEntry() == item ) - { - tempcount += pItem->GetCount(); - if( tempcount >= count ) - return true; - } - } - } - } - } - } - - return false; -} - -Item* Player::GetItemOrItemWithGemEquipped( uint32 item ) const -{ - Item *pItem; - for(int i = EQUIPMENT_SLOT_START; i < EQUIPMENT_SLOT_END; i++) - { - pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i ); - if( pItem && pItem->GetEntry() == item ) - return pItem; - } - - ItemPrototype const *pProto = objmgr.GetItemPrototype(item); - if (pProto && pProto->GemProperties) - { - for(int i = EQUIPMENT_SLOT_START; i < EQUIPMENT_SLOT_END; i++) - { - pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i ); - if( pItem && pItem->GetProto()->Socket[0].Color ) - { - if (pItem->GetGemCountWithID(item) > 0 ) - return pItem; - } - } - } - - return NULL; -} - -uint8 Player::_CanTakeMoreSimilarItems(uint32 entry, uint32 count, Item* pItem, uint32* no_space_count ) const -{ - ItemPrototype const *pProto = objmgr.GetItemPrototype(entry); - if( !pProto ) - { - if(no_space_count) - *no_space_count = count; - return EQUIP_ERR_CANT_CARRY_MORE_OF_THIS; - } - - // no maximum - if(pProto->MaxCount == 0) - return EQUIP_ERR_OK; - - uint32 curcount = GetItemCount(pProto->ItemId,true,pItem); - - if( curcount + count > pProto->MaxCount ) - { - if(no_space_count) - *no_space_count = count +curcount - pProto->MaxCount; - return EQUIP_ERR_CANT_CARRY_MORE_OF_THIS; - } - - return EQUIP_ERR_OK; -} - -bool Player::HasItemTotemCategory( uint32 TotemCategory ) const -{ - Item *pItem; - for(uint8 i = EQUIPMENT_SLOT_START; i < INVENTORY_SLOT_ITEM_END; ++i) - { - pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i ); - if( pItem && IsTotemCategoryCompatiableWith(pItem->GetProto()->TotemCategory,TotemCategory )) - return true; - } - for(uint8 i = KEYRING_SLOT_START; i < KEYRING_SLOT_END; ++i) - { - pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i ); - if( pItem && IsTotemCategoryCompatiableWith(pItem->GetProto()->TotemCategory,TotemCategory )) - return true; - } - Bag *pBag; - ItemPrototype const *pBagProto; - for(uint8 i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; ++i) - { - pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i ); - if( pBag ) - { - pBagProto = pBag->GetProto(); - if( pBagProto ) - { - for(uint32 j = 0; j < pBagProto->ContainerSlots; ++j) - { - pItem = GetItemByPos( i, j ); - if( pItem && IsTotemCategoryCompatiableWith(pItem->GetProto()->TotemCategory,TotemCategory )) - return true; - } - } - } - } - return false; -} - -uint8 Player::_CanStoreItem_InSpecificSlot( uint8 bag, uint8 slot, ItemPosCountVec &dest, ItemPrototype const *pProto, uint32& count, bool swap, Item* pSrcItem ) const -{ - Item* pItem2 = GetItemByPos( bag, slot ); - - // ignore move item (this slot will be empty at move) - if(pItem2==pSrcItem) - pItem2 = NULL; - - uint32 need_space; - - // empty specific slot - check item fit to slot - if( !pItem2 || swap ) - { - if( bag == INVENTORY_SLOT_BAG_0 ) - { - // keyring case - if(slot >= KEYRING_SLOT_START && slot < KEYRING_SLOT_START+GetMaxKeyringSize() && !(pProto->BagFamily & BAG_FAMILY_MASK_KEYS)) - return EQUIP_ERR_ITEM_DOESNT_GO_INTO_BAG; - - // prevent cheating - if(slot >= BUYBACK_SLOT_START && slot < BUYBACK_SLOT_END || slot >= PLAYER_SLOT_END) - return EQUIP_ERR_ITEM_DOESNT_GO_INTO_BAG; - } - else - { - Bag* pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, bag ); - if( !pBag ) - return EQUIP_ERR_ITEM_DOESNT_GO_INTO_BAG; - - ItemPrototype const* pBagProto = pBag->GetProto(); - if( !pBagProto ) - return EQUIP_ERR_ITEM_DOESNT_GO_INTO_BAG; - - if( !ItemCanGoIntoBag(pProto,pBagProto) ) - return EQUIP_ERR_ITEM_DOESNT_GO_INTO_BAG; - } - - // non empty stack with space - need_space = pProto->Stackable; - } - // non empty slot, check item type - else - { - // check item type - if(pItem2->GetEntry() != pProto->ItemId) - return EQUIP_ERR_ITEM_CANT_STACK; - - // check free space - if(pItem2->GetCount() >= pProto->Stackable) - return EQUIP_ERR_ITEM_CANT_STACK; - - need_space = pProto->Stackable - pItem2->GetCount(); - } - - if(need_space > count) - need_space = count; - - ItemPosCount newPosition = ItemPosCount((bag << 8) | slot, need_space); - if(!newPosition.isContainedIn(dest)) - { - dest.push_back(newPosition); - count -= need_space; - } - return EQUIP_ERR_OK; -} - -uint8 Player::_CanStoreItem_InBag( uint8 bag, ItemPosCountVec &dest, ItemPrototype const *pProto, uint32& count, bool merge, bool non_specialized, Item* pSrcItem, uint8 skip_bag, uint8 skip_slot ) const -{ - // skip specific bag already processed in first called _CanStoreItem_InBag - if(bag==skip_bag) - return EQUIP_ERR_ITEM_DOESNT_GO_INTO_BAG; - - Bag* pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, bag ); - if( !pBag ) - return EQUIP_ERR_ITEM_DOESNT_GO_INTO_BAG; - - ItemPrototype const* pBagProto = pBag->GetProto(); - if( !pBagProto ) - return EQUIP_ERR_ITEM_DOESNT_GO_INTO_BAG; - - // specialized bag mode or non-specilized - if( non_specialized != (pBagProto->Class == ITEM_CLASS_CONTAINER && pBagProto->SubClass == ITEM_SUBCLASS_CONTAINER) ) - return EQUIP_ERR_ITEM_DOESNT_GO_INTO_BAG; - - if( !ItemCanGoIntoBag(pProto,pBagProto) ) - return EQUIP_ERR_ITEM_DOESNT_GO_INTO_BAG; - - for(uint32 j = 0; j < pBagProto->ContainerSlots; j++) - { - // skip specific slot already processed in first called _CanStoreItem_InSpecificSlot - if(j==skip_slot) - continue; - - Item* pItem2 = GetItemByPos( bag, j ); - - // ignore move item (this slot will be empty at move) - if(pItem2==pSrcItem) - pItem2 = NULL; - - // if merge skip empty, if !merge skip non-empty - if((pItem2!=NULL)!=merge) - continue; - - if( pItem2 ) - { - if(pItem2->GetEntry() == pProto->ItemId && pItem2->GetCount() < pProto->Stackable ) - { - uint32 need_space = pProto->Stackable - pItem2->GetCount(); - if(need_space > count) - need_space = count; - - ItemPosCount newPosition = ItemPosCount((bag << 8) | j, need_space); - if(!newPosition.isContainedIn(dest)) - { - dest.push_back(newPosition); - count -= need_space; - - if(count==0) - return EQUIP_ERR_OK; - } - } - } - else - { - uint32 need_space = pProto->Stackable; - if(need_space > count) - need_space = count; - - ItemPosCount newPosition = ItemPosCount((bag << 8) | j, need_space); - if(!newPosition.isContainedIn(dest)) - { - dest.push_back(newPosition); - count -= need_space; - - if(count==0) - return EQUIP_ERR_OK; - } - } - } - return EQUIP_ERR_OK; -} - -uint8 Player::_CanStoreItem_InInventorySlots( uint8 slot_begin, uint8 slot_end, ItemPosCountVec &dest, ItemPrototype const *pProto, uint32& count, bool merge, Item* pSrcItem, uint8 skip_bag, uint8 skip_slot ) const -{ - for(uint32 j = slot_begin; j < slot_end; j++) - { - // skip specific slot already processed in first called _CanStoreItem_InSpecificSlot - if(INVENTORY_SLOT_BAG_0==skip_bag && j==skip_slot) - continue; - - Item* pItem2 = GetItemByPos( INVENTORY_SLOT_BAG_0, j ); - - // ignore move item (this slot will be empty at move) - if(pItem2==pSrcItem) - pItem2 = NULL; - - // if merge skip empty, if !merge skip non-empty - if((pItem2!=NULL)!=merge) - continue; - - if( pItem2 ) - { - if(pItem2->GetEntry() == pProto->ItemId && pItem2->GetCount() < pProto->Stackable ) - { - uint32 need_space = pProto->Stackable - pItem2->GetCount(); - if(need_space > count) - need_space = count; - ItemPosCount newPosition = ItemPosCount((INVENTORY_SLOT_BAG_0 << 8) | j, need_space); - if(!newPosition.isContainedIn(dest)) - { - dest.push_back(newPosition); - count -= need_space; - - if(count==0) - return EQUIP_ERR_OK; - } - } - } - else - { - uint32 need_space = pProto->Stackable; - if(need_space > count) - need_space = count; - - ItemPosCount newPosition = ItemPosCount((INVENTORY_SLOT_BAG_0 << 8) | j, need_space); - if(!newPosition.isContainedIn(dest)) - { - dest.push_back(newPosition); - count -= need_space; - - if(count==0) - return EQUIP_ERR_OK; - } - } - } - return EQUIP_ERR_OK; -} - -uint8 Player::_CanStoreItem( uint8 bag, uint8 slot, ItemPosCountVec &dest, uint32 entry, uint32 count, Item *pItem, bool swap, uint32* no_space_count ) const -{ - sLog.outDebug( "STORAGE: CanStoreItem bag = %u, slot = %u, item = %u, count = %u", bag, slot, entry, count); - - ItemPrototype const *pProto = objmgr.GetItemPrototype(entry); - if( !pProto ) - { - if(no_space_count) - *no_space_count = count; - return swap ? EQUIP_ERR_ITEMS_CANT_BE_SWAPPED :EQUIP_ERR_ITEM_NOT_FOUND; - } - - if(pItem && pItem->IsBindedNotWith(GetGUID())) - { - if(no_space_count) - *no_space_count = count; - return EQUIP_ERR_DONT_OWN_THAT_ITEM; - } - - // check count of items (skip for auto move for same player from bank) - uint32 no_similar_count = 0; // can't store this amount similar items - uint8 res = _CanTakeMoreSimilarItems(entry,count,pItem,&no_similar_count); - if(res!=EQUIP_ERR_OK) - { - if(count==no_similar_count) - { - if(no_space_count) - *no_space_count = no_similar_count; - return res; - } - count -= no_similar_count; - } - - // in specific slot - if( bag != NULL_BAG && slot != NULL_SLOT ) - { - res = _CanStoreItem_InSpecificSlot(bag,slot,dest,pProto,count,swap,pItem); - if(res!=EQUIP_ERR_OK) - { - if(no_space_count) - *no_space_count = count + no_similar_count; - return res; - } - - if(count==0) - { - if(no_similar_count==0) - return EQUIP_ERR_OK; - - if(no_space_count) - *no_space_count = count + no_similar_count; - return EQUIP_ERR_CANT_CARRY_MORE_OF_THIS; - } - } - - // not specific slot or have spece for partly store only in specific slot - - // in specific bag - if( bag != NULL_BAG ) - { - // search stack in bag for merge to - if( pProto->Stackable > 1 ) - { - if( bag == INVENTORY_SLOT_BAG_0 ) // inventory - { - res = _CanStoreItem_InInventorySlots(KEYRING_SLOT_START,KEYRING_SLOT_END,dest,pProto,count,true,pItem,bag,slot); - if(res!=EQUIP_ERR_OK) - { - if(no_space_count) - *no_space_count = count + no_similar_count; - return res; - } - - if(count==0) - { - if(no_similar_count==0) - return EQUIP_ERR_OK; - - if(no_space_count) - *no_space_count = count + no_similar_count; - return EQUIP_ERR_CANT_CARRY_MORE_OF_THIS; - } - - res = _CanStoreItem_InInventorySlots(INVENTORY_SLOT_ITEM_START,INVENTORY_SLOT_ITEM_END,dest,pProto,count,true,pItem,bag,slot); - if(res!=EQUIP_ERR_OK) - { - if(no_space_count) - *no_space_count = count + no_similar_count; - return res; - } - - if(count==0) - { - if(no_similar_count==0) - return EQUIP_ERR_OK; - - if(no_space_count) - *no_space_count = count + no_similar_count; - return EQUIP_ERR_CANT_CARRY_MORE_OF_THIS; - } - } - else // equipped bag - { - // we need check 2 time (specilized/non_specialized), use NULL_BAG to prevent skipping bag - res = _CanStoreItem_InBag(bag,dest,pProto,count,true,false,pItem,NULL_BAG,slot); - if(res!=EQUIP_ERR_OK) - res = _CanStoreItem_InBag(bag,dest,pProto,count,true,true,pItem,NULL_BAG,slot); - - if(res!=EQUIP_ERR_OK) - { - if(no_space_count) - *no_space_count = count + no_similar_count; - return res; - } - - if(count==0) - { - if(no_similar_count==0) - return EQUIP_ERR_OK; - - if(no_space_count) - *no_space_count = count + no_similar_count; - return EQUIP_ERR_CANT_CARRY_MORE_OF_THIS; - } - } - } - - // search free slot in bag for place to - if( bag == INVENTORY_SLOT_BAG_0 ) // inventory - { - // search free slot - keyring case - if(pProto->BagFamily & BAG_FAMILY_MASK_KEYS) - { - uint32 keyringSize = GetMaxKeyringSize(); - res = _CanStoreItem_InInventorySlots(KEYRING_SLOT_START,KEYRING_SLOT_START+keyringSize,dest,pProto,count,false,pItem,bag,slot); - if(res!=EQUIP_ERR_OK) - { - if(no_space_count) - *no_space_count = count + no_similar_count; - return res; - } - - if(count==0) - { - if(no_similar_count==0) - return EQUIP_ERR_OK; - - if(no_space_count) - *no_space_count = count + no_similar_count; - return EQUIP_ERR_CANT_CARRY_MORE_OF_THIS; - } - } - - res = _CanStoreItem_InInventorySlots(INVENTORY_SLOT_ITEM_START,INVENTORY_SLOT_ITEM_END,dest,pProto,count,false,pItem,bag,slot); - if(res!=EQUIP_ERR_OK) - { - if(no_space_count) - *no_space_count = count + no_similar_count; - return res; - } - - if(count==0) - { - if(no_similar_count==0) - return EQUIP_ERR_OK; - - if(no_space_count) - *no_space_count = count + no_similar_count; - return EQUIP_ERR_CANT_CARRY_MORE_OF_THIS; - } - } - else // equipped bag - { - res = _CanStoreItem_InBag(bag,dest,pProto,count,false,false,pItem,NULL_BAG,slot); - if(res!=EQUIP_ERR_OK) - res = _CanStoreItem_InBag(bag,dest,pProto,count,false,true,pItem,NULL_BAG,slot); - - if(res!=EQUIP_ERR_OK) - { - if(no_space_count) - *no_space_count = count + no_similar_count; - return res; - } - - if(count==0) - { - if(no_similar_count==0) - return EQUIP_ERR_OK; - - if(no_space_count) - *no_space_count = count + no_similar_count; - return EQUIP_ERR_CANT_CARRY_MORE_OF_THIS; - } - } - } - - // not specific bag or have space for partly store only in specific bag - - // search stack for merge to - if( pProto->Stackable > 1 ) - { - res = _CanStoreItem_InInventorySlots(KEYRING_SLOT_START,KEYRING_SLOT_END,dest,pProto,count,true,pItem,bag,slot); - if(res!=EQUIP_ERR_OK) - { - if(no_space_count) - *no_space_count = count + no_similar_count; - return res; - } - - if(count==0) - { - if(no_similar_count==0) - return EQUIP_ERR_OK; - - if(no_space_count) - *no_space_count = count + no_similar_count; - return EQUIP_ERR_CANT_CARRY_MORE_OF_THIS; - } - - res = _CanStoreItem_InInventorySlots(INVENTORY_SLOT_ITEM_START,INVENTORY_SLOT_ITEM_END,dest,pProto,count,true,pItem,bag,slot); - if(res!=EQUIP_ERR_OK) - { - if(no_space_count) - *no_space_count = count + no_similar_count; - return res; - } - - if(count==0) - { - if(no_similar_count==0) - return EQUIP_ERR_OK; - - if(no_space_count) - *no_space_count = count + no_similar_count; - return EQUIP_ERR_CANT_CARRY_MORE_OF_THIS; - } - - if( pProto->BagFamily ) - { - for(int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; i++) - { - res = _CanStoreItem_InBag(i,dest,pProto,count,true,false,pItem,bag,slot); - if(res!=EQUIP_ERR_OK) - continue; - - if(count==0) - { - if(no_similar_count==0) - return EQUIP_ERR_OK; - - if(no_space_count) - *no_space_count = count + no_similar_count; - return EQUIP_ERR_CANT_CARRY_MORE_OF_THIS; - } - } - } - - for(int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; i++) - { - res = _CanStoreItem_InBag(i,dest,pProto,count,true,true,pItem,bag,slot); - if(res!=EQUIP_ERR_OK) - continue; - - if(count==0) - { - if(no_similar_count==0) - return EQUIP_ERR_OK; - - if(no_space_count) - *no_space_count = count + no_similar_count; - return EQUIP_ERR_CANT_CARRY_MORE_OF_THIS; - } - } - } - - // search free slot - special bag case - if( pProto->BagFamily ) - { - if(pProto->BagFamily & BAG_FAMILY_MASK_KEYS) - { - uint32 keyringSize = GetMaxKeyringSize(); - res = _CanStoreItem_InInventorySlots(KEYRING_SLOT_START,KEYRING_SLOT_START+keyringSize,dest,pProto,count,false,pItem,bag,slot); - if(res!=EQUIP_ERR_OK) - { - if(no_space_count) - *no_space_count = count + no_similar_count; - return res; - } - - if(count==0) - { - if(no_similar_count==0) - return EQUIP_ERR_OK; - - if(no_space_count) - *no_space_count = count + no_similar_count; - return EQUIP_ERR_CANT_CARRY_MORE_OF_THIS; - } - } - - for(int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; i++) - { - res = _CanStoreItem_InBag(i,dest,pProto,count,false,false,pItem,bag,slot); - if(res!=EQUIP_ERR_OK) - continue; - - if(count==0) - { - if(no_similar_count==0) - return EQUIP_ERR_OK; - - if(no_space_count) - *no_space_count = count + no_similar_count; - return EQUIP_ERR_CANT_CARRY_MORE_OF_THIS; - } - } - } - - // search free slot - res = _CanStoreItem_InInventorySlots(INVENTORY_SLOT_ITEM_START,INVENTORY_SLOT_ITEM_END,dest,pProto,count,false,pItem,bag,slot); - if(res!=EQUIP_ERR_OK) - { - if(no_space_count) - *no_space_count = count + no_similar_count; - return res; - } - - if(count==0) - { - if(no_similar_count==0) - return EQUIP_ERR_OK; - - if(no_space_count) - *no_space_count = count + no_similar_count; - return EQUIP_ERR_CANT_CARRY_MORE_OF_THIS; - } - - for(int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; i++) - { - res = _CanStoreItem_InBag(i,dest,pProto,count,false,true,pItem,bag,slot); - if(res!=EQUIP_ERR_OK) - continue; - - if(count==0) - { - if(no_similar_count==0) - return EQUIP_ERR_OK; - - if(no_space_count) - *no_space_count = count + no_similar_count; - return EQUIP_ERR_CANT_CARRY_MORE_OF_THIS; - } - } - - if(no_space_count) - *no_space_count = count + no_similar_count; - - return EQUIP_ERR_INVENTORY_FULL; -} - -////////////////////////////////////////////////////////////////////////// -uint8 Player::CanStoreItems( Item **pItems,int count) const -{ - Item *pItem2; - - // fill space table - int inv_slot_items[INVENTORY_SLOT_ITEM_END-INVENTORY_SLOT_ITEM_START]; - int inv_bags[INVENTORY_SLOT_BAG_END-INVENTORY_SLOT_BAG_START][MAX_BAG_SIZE]; - int inv_keys[KEYRING_SLOT_END-KEYRING_SLOT_START]; - - memset(inv_slot_items,0,sizeof(int)*(INVENTORY_SLOT_ITEM_END-INVENTORY_SLOT_ITEM_START)); - memset(inv_bags,0,sizeof(int)*(INVENTORY_SLOT_BAG_END-INVENTORY_SLOT_BAG_START)*MAX_BAG_SIZE); - memset(inv_keys,0,sizeof(int)*(KEYRING_SLOT_END-KEYRING_SLOT_START)); - - for(int i = INVENTORY_SLOT_ITEM_START; i < INVENTORY_SLOT_ITEM_END; i++) - { - pItem2 = GetItemByPos( INVENTORY_SLOT_BAG_0, i ); - - if (pItem2 && !pItem2->IsInTrade()) - { - inv_slot_items[i-INVENTORY_SLOT_ITEM_START] = pItem2->GetCount(); - } - } - - for(int i = KEYRING_SLOT_START; i < KEYRING_SLOT_END; i++) - { - pItem2 = GetItemByPos( INVENTORY_SLOT_BAG_0, i ); - - if (pItem2 && !pItem2->IsInTrade()) - { - inv_keys[i-KEYRING_SLOT_START] = pItem2->GetCount(); - } - } - - for(int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; i++) - { - Bag *pBag; - ItemPrototype const *pBagProto; - - pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i ); - if( pBag ) - { - pBagProto = pBag->GetProto(); - - if( pBagProto ) - { - for(uint32 j = 0; j < pBagProto->ContainerSlots; j++) - { - pItem2 = GetItemByPos( i, j ); - if (pItem2 && !pItem2->IsInTrade()) - { - inv_bags[i-INVENTORY_SLOT_BAG_START][j] = pItem2->GetCount(); - } - } - } - } - } - - // check free space for all items - for (int k=0;kGetEntry(), pItem->GetCount()); - ItemPrototype const *pProto = pItem->GetProto(); - - // strange item - if( !pProto ) - return EQUIP_ERR_ITEM_NOT_FOUND; - - // item it 'bind' - if(pItem->IsBindedNotWith(GetGUID())) - return EQUIP_ERR_DONT_OWN_THAT_ITEM; - - Bag *pBag; - ItemPrototype const *pBagProto; - - // item is 'one item only' - uint8 res = CanTakeMoreSimilarItems(pItem); - if(res != EQUIP_ERR_OK) - return res; - - // search stack for merge to - if( pProto->Stackable > 1 ) - { - bool b_found = false; - - for(int t = KEYRING_SLOT_START; t < KEYRING_SLOT_END; t++) - { - pItem2 = GetItemByPos( INVENTORY_SLOT_BAG_0, t ); - if( pItem2 && pItem2->GetEntry() == pItem->GetEntry() && inv_keys[t-KEYRING_SLOT_START] + pItem->GetCount() <= pProto->Stackable ) - { - inv_keys[t-KEYRING_SLOT_START] += pItem->GetCount(); - b_found = true; - break; - } - } - if (b_found) continue; - - for(int t = INVENTORY_SLOT_ITEM_START; t < INVENTORY_SLOT_ITEM_END; t++) - { - pItem2 = GetItemByPos( INVENTORY_SLOT_BAG_0, t ); - if( pItem2 && pItem2->GetEntry() == pItem->GetEntry() && inv_slot_items[t-INVENTORY_SLOT_ITEM_START] + pItem->GetCount() <= pProto->Stackable ) - { - inv_slot_items[t-INVENTORY_SLOT_ITEM_START] += pItem->GetCount(); - b_found = true; - break; - } - } - if (b_found) continue; - - for(int t = INVENTORY_SLOT_BAG_START; !b_found && t < INVENTORY_SLOT_BAG_END; t++) - { - pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, t ); - if( pBag ) - { - pBagProto = pBag->GetProto(); - if( pBagProto ) - { - for(uint32 j = 0; j < pBagProto->ContainerSlots; j++) - { - pItem2 = GetItemByPos( t, j ); - if( pItem2 && pItem2->GetEntry() == pItem->GetEntry() && inv_bags[t-INVENTORY_SLOT_BAG_START][j] + pItem->GetCount() <= pProto->Stackable ) - { - inv_bags[t-INVENTORY_SLOT_BAG_START][j] += pItem->GetCount(); - b_found = true; - break; - } - } - } - } - } - if (b_found) continue; - } - - // special bag case - if( pProto->BagFamily ) - { - bool b_found = false; - if(pProto->BagFamily & BAG_FAMILY_MASK_KEYS) - { - uint32 keyringSize = GetMaxKeyringSize(); - for(uint32 t = KEYRING_SLOT_START; t < KEYRING_SLOT_START+keyringSize; ++t) - { - if( inv_keys[t-KEYRING_SLOT_START] == 0 ) - { - inv_keys[t-KEYRING_SLOT_START] = 1; - b_found = true; - break; - } - } - } - - if (b_found) continue; - - for(int t = INVENTORY_SLOT_BAG_START; !b_found && t < INVENTORY_SLOT_BAG_END; t++) - { - pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, t ); - if( pBag ) - { - pBagProto = pBag->GetProto(); - - // not plain container check - if( pBagProto && (pBagProto->Class != ITEM_CLASS_CONTAINER || pBagProto->SubClass != ITEM_SUBCLASS_CONTAINER) && - ItemCanGoIntoBag(pProto,pBagProto) ) - { - for(uint32 j = 0; j < pBagProto->ContainerSlots; j++) - { - if( inv_bags[t-INVENTORY_SLOT_BAG_START][j] == 0 ) - { - inv_bags[t-INVENTORY_SLOT_BAG_START][j] = 1; - b_found = true; - break; - } - } - } - } - } - if (b_found) continue; - } - - // search free slot - bool b_found = false; - for(int t = INVENTORY_SLOT_ITEM_START; t < INVENTORY_SLOT_ITEM_END; t++) - { - if( inv_slot_items[t-INVENTORY_SLOT_ITEM_START] == 0 ) - { - inv_slot_items[t-INVENTORY_SLOT_ITEM_START] = 1; - b_found = true; - break; - } - } - if (b_found) continue; - - // search free slot in bags - for(int t = INVENTORY_SLOT_BAG_START; !b_found && t < INVENTORY_SLOT_BAG_END; t++) - { - pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, t ); - if( pBag ) - { - pBagProto = pBag->GetProto(); - if( pBagProto && ItemCanGoIntoBag(pProto,pBagProto)) - { - for(uint32 j = 0; j < pBagProto->ContainerSlots; j++) - { - if( inv_bags[t-INVENTORY_SLOT_BAG_START][j] == 0 ) - { - inv_bags[t-INVENTORY_SLOT_BAG_START][j] = 1; - b_found = true; - break; - } - } - } - } - } - - // no free slot found? - if (!b_found) - return EQUIP_ERR_INVENTORY_FULL; - } - - return EQUIP_ERR_OK; -} - -////////////////////////////////////////////////////////////////////////// -uint8 Player::CanEquipNewItem( uint8 slot, uint16 &dest, uint32 item, uint32 count, bool swap ) const -{ - dest = 0; - Item *pItem = Item::CreateItem( item, count, this ); - if( pItem ) - { - uint8 result = CanEquipItem(slot, dest, pItem, swap ); - delete pItem; - return result; - } - - return EQUIP_ERR_ITEM_NOT_FOUND; -} - -uint8 Player::CanEquipItem( uint8 slot, uint16 &dest, Item *pItem, bool swap, bool not_loading ) const -{ - dest = 0; - if( pItem ) - { - sLog.outDebug( "STORAGE: CanEquipItem slot = %u, item = %u, count = %u", slot, pItem->GetEntry(), pItem->GetCount()); - ItemPrototype const *pProto = pItem->GetProto(); - if( pProto ) - { - if(pItem->IsBindedNotWith(GetGUID())) - return EQUIP_ERR_DONT_OWN_THAT_ITEM; - - // check count of items (skip for auto move for same player from bank) - uint8 res = CanTakeMoreSimilarItems(pItem); - if(res != EQUIP_ERR_OK) - return res; - - // do not allow equipping gear except weapons, offhands, projectiles, relics in - // - combat - // - in-progress arenas - if( !pProto->CanChangeEquipStateInCombat() ) - { - if( isInCombat() ) - return EQUIP_ERR_NOT_IN_COMBAT; - - if(BattleGround* bg = GetBattleGround()) - if( bg->isArena() && bg->GetStatus() == STATUS_IN_PROGRESS ) - return EQUIP_ERR_NOT_DURING_ARENA_MATCH; - } - - if(isInCombat()&& pProto->Class == ITEM_CLASS_WEAPON && m_weaponChangeTimer != 0) - return EQUIP_ERR_CANT_DO_RIGHT_NOW; // maybe exist better err - - uint8 eslot = FindEquipSlot( pProto, slot, swap ); - if( eslot == NULL_SLOT ) - return EQUIP_ERR_ITEM_CANT_BE_EQUIPPED; - - uint8 msg = CanUseItem( pItem , not_loading ); - if( msg != EQUIP_ERR_OK ) - return msg; - if( !swap && GetItemByPos( INVENTORY_SLOT_BAG_0, eslot ) ) - return EQUIP_ERR_NO_EQUIPMENT_SLOT_AVAILABLE; - - // check unique-equipped on item - if (pProto->Flags & ITEM_FLAGS_UNIQUE_EQUIPPED) - { - // there is an equip limit on this item - Item* tItem = GetItemOrItemWithGemEquipped(pProto->ItemId); - if (tItem && (!swap || tItem->GetSlot() != eslot ) ) - return EQUIP_ERR_ITEM_UNIQUE_EQUIPABLE; - } - - // check unique-equipped on gems - for(uint32 enchant_slot = SOCK_ENCHANTMENT_SLOT; enchant_slot < SOCK_ENCHANTMENT_SLOT+3; ++enchant_slot) - { - uint32 enchant_id = pItem->GetEnchantmentId(EnchantmentSlot(enchant_slot)); - if(!enchant_id) - continue; - SpellItemEnchantmentEntry const* enchantEntry = sSpellItemEnchantmentStore.LookupEntry(enchant_id); - if(!enchantEntry) - continue; - - ItemPrototype const* pGem = objmgr.GetItemPrototype(enchantEntry->GemID); - if(pGem && (pGem->Flags & ITEM_FLAGS_UNIQUE_EQUIPPED)) - { - Item* tItem = GetItemOrItemWithGemEquipped(enchantEntry->GemID); - if(tItem && (!swap || tItem->GetSlot() != eslot )) - return EQUIP_ERR_ITEM_UNIQUE_EQUIPABLE; - } - } - - // check unique-equipped special item classes - if (pProto->Class == ITEM_CLASS_QUIVER) - { - for(int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; ++i) - { - if( Item* pBag = GetItemByPos( INVENTORY_SLOT_BAG_0, i ) ) - { - if( ItemPrototype const* pBagProto = pBag->GetProto() ) - { - if( pBagProto->Class==pProto->Class && pBagProto->SubClass==pProto->SubClass && - (!swap || pBag->GetSlot() != eslot ) ) - { - if(pBagProto->SubClass == ITEM_SUBCLASS_AMMO_POUCH) - return EQUIP_ERR_CAN_EQUIP_ONLY1_AMMOPOUCH; - else - return EQUIP_ERR_CAN_EQUIP_ONLY1_QUIVER; - } - } - } - } - } - - uint32 type = pProto->InventoryType; - - if(eslot == EQUIPMENT_SLOT_OFFHAND) - { - if( type == INVTYPE_WEAPON || type == INVTYPE_WEAPONOFFHAND ) - { - if(!CanDualWield()) - return EQUIP_ERR_CANT_DUAL_WIELD; - } - - Item *mainItem = GetItemByPos( INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_MAINHAND ); - if(mainItem) - { - if(mainItem->GetProto()->InventoryType == INVTYPE_2HWEAPON) - return EQUIP_ERR_CANT_EQUIP_WITH_TWOHANDED; - } - } - - // equip two-hand weapon case (with possible unequip 2 items) - if( type == INVTYPE_2HWEAPON ) - { - if(eslot != EQUIPMENT_SLOT_MAINHAND) - return EQUIP_ERR_ITEM_CANT_BE_EQUIPPED; - - // offhand item must can be stored in inventitory for offhand item and it also must be unequipped - Item *offItem = GetItemByPos( INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND ); - ItemPosCountVec off_dest; - if( offItem && (!not_loading || - CanUnequipItem(uint16(INVENTORY_SLOT_BAG_0) << 8 | EQUIPMENT_SLOT_OFFHAND,false) != EQUIP_ERR_OK || - CanStoreItem( NULL_BAG, NULL_SLOT, off_dest, offItem, false ) != EQUIP_ERR_OK ) ) - return swap ? EQUIP_ERR_ITEMS_CANT_BE_SWAPPED : EQUIP_ERR_INVENTORY_FULL; - } - dest = ((INVENTORY_SLOT_BAG_0 << 8) | eslot); - return EQUIP_ERR_OK; - } - } - if( !swap ) - return EQUIP_ERR_ITEM_NOT_FOUND; - else - return EQUIP_ERR_ITEMS_CANT_BE_SWAPPED; -} - -uint8 Player::CanUnequipItem( uint16 pos, bool swap ) const -{ - // Applied only to equipped items and bank bags - if(!IsEquipmentPos(pos) && !IsBagPos(pos)) - return EQUIP_ERR_OK; - - Item* pItem = GetItemByPos(pos); - - // Applied only to existed equipped item - if( !pItem ) - return EQUIP_ERR_OK; - - sLog.outDebug( "STORAGE: CanUnequipItem slot = %u, item = %u, count = %u", pos, pItem->GetEntry(), pItem->GetCount()); - - ItemPrototype const *pProto = pItem->GetProto(); - if( !pProto ) - return EQUIP_ERR_ITEM_NOT_FOUND; - - // do not allow unequipping gear except weapons, offhands, projectiles, relics in - // - combat - // - in-progress arenas - if( !pProto->CanChangeEquipStateInCombat() ) - { - if( isInCombat() ) - return EQUIP_ERR_NOT_IN_COMBAT; - - if(BattleGround* bg = GetBattleGround()) - if( bg->isArena() && bg->GetStatus() == STATUS_IN_PROGRESS ) - return EQUIP_ERR_NOT_DURING_ARENA_MATCH; - } - - if(!swap && pItem->IsBag() && !((Bag*)pItem)->IsEmpty()) - return EQUIP_ERR_CAN_ONLY_DO_WITH_EMPTY_BAGS; - - return EQUIP_ERR_OK; -} - -uint8 Player::CanBankItem( uint8 bag, uint8 slot, ItemPosCountVec &dest, Item *pItem, bool swap, bool not_loading ) const -{ - if( !pItem ) - return swap ? EQUIP_ERR_ITEMS_CANT_BE_SWAPPED : EQUIP_ERR_ITEM_NOT_FOUND; - - uint32 count = pItem->GetCount(); - - sLog.outDebug( "STORAGE: CanBankItem bag = %u, slot = %u, item = %u, count = %u", bag, slot, pItem->GetEntry(), pItem->GetCount()); - ItemPrototype const *pProto = pItem->GetProto(); - if( !pProto ) - return swap ? EQUIP_ERR_ITEMS_CANT_BE_SWAPPED : EQUIP_ERR_ITEM_NOT_FOUND; - - if( pItem->IsBindedNotWith(GetGUID()) ) - return EQUIP_ERR_DONT_OWN_THAT_ITEM; - - // check count of items (skip for auto move for same player from bank) - uint8 res = CanTakeMoreSimilarItems(pItem); - if(res != EQUIP_ERR_OK) - return res; - - // in specific slot - if( bag != NULL_BAG && slot != NULL_SLOT ) - { - if( pProto->InventoryType == INVTYPE_BAG ) - { - Bag *pBag = (Bag*)pItem; - if( pBag ) - { - if( slot >= BANK_SLOT_BAG_START && slot < BANK_SLOT_BAG_END ) - { - if( !HasBankBagSlot( slot ) ) - return EQUIP_ERR_MUST_PURCHASE_THAT_BAG_SLOT; - if( uint8 cantuse = CanUseItem( pItem, not_loading ) != EQUIP_ERR_OK ) - return cantuse; - } - else - { - if( !pBag->IsEmpty() ) - return EQUIP_ERR_NONEMPTY_BAG_OVER_OTHER_BAG; - } - } - } - else - { - if( slot >= BANK_SLOT_BAG_START && slot < BANK_SLOT_BAG_END ) - return EQUIP_ERR_ITEM_DOESNT_GO_TO_SLOT; - } - - res = _CanStoreItem_InSpecificSlot(bag,slot,dest,pProto,count,swap,pItem); - if(res!=EQUIP_ERR_OK) - return res; - - if(count==0) - return EQUIP_ERR_OK; - } - - // not specific slot or have spece for partly store only in specific slot - - // in specific bag - if( bag != NULL_BAG ) - { - if( pProto->InventoryType == INVTYPE_BAG ) - { - Bag *pBag = (Bag*)pItem; - if( pBag && !pBag->IsEmpty() ) - return EQUIP_ERR_NONEMPTY_BAG_OVER_OTHER_BAG; - } - - // search stack in bag for merge to - if( pProto->Stackable > 1 ) - { - if( bag == INVENTORY_SLOT_BAG_0 ) - { - res = _CanStoreItem_InInventorySlots(BANK_SLOT_ITEM_START,BANK_SLOT_ITEM_END,dest,pProto,count,true,pItem,bag,slot); - if(res!=EQUIP_ERR_OK) - return res; - - if(count==0) - return EQUIP_ERR_OK; - } - else - { - res = _CanStoreItem_InBag(bag,dest,pProto,count,true,false,pItem,NULL_BAG,slot); - if(res!=EQUIP_ERR_OK) - res = _CanStoreItem_InBag(bag,dest,pProto,count,true,true,pItem,NULL_BAG,slot); - - if(res!=EQUIP_ERR_OK) - return res; - - if(count==0) - return EQUIP_ERR_OK; - } - } - - // search free slot in bag - if( bag == INVENTORY_SLOT_BAG_0 ) - { - res = _CanStoreItem_InInventorySlots(BANK_SLOT_ITEM_START,BANK_SLOT_ITEM_END,dest,pProto,count,false,pItem,bag,slot); - if(res!=EQUIP_ERR_OK) - return res; - - if(count==0) - return EQUIP_ERR_OK; - } - else - { - res = _CanStoreItem_InBag(bag,dest,pProto,count,false,false,pItem,NULL_BAG,slot); - if(res!=EQUIP_ERR_OK) - res = _CanStoreItem_InBag(bag,dest,pProto,count,false,true,pItem,NULL_BAG,slot); - - if(res!=EQUIP_ERR_OK) - return res; - - if(count==0) - return EQUIP_ERR_OK; - } - } - - // not specific bag or have spece for partly store only in specific bag - - // search stack for merge to - if( pProto->Stackable > 1 ) - { - // in slots - res = _CanStoreItem_InInventorySlots(BANK_SLOT_ITEM_START,BANK_SLOT_ITEM_END,dest,pProto,count,true,pItem,bag,slot); - if(res!=EQUIP_ERR_OK) - return res; - - if(count==0) - return EQUIP_ERR_OK; - - // in special bags - if( pProto->BagFamily ) - { - for(int i = BANK_SLOT_BAG_START; i < BANK_SLOT_BAG_END; i++) - { - res = _CanStoreItem_InBag(i,dest,pProto,count,true,false,pItem,bag,slot); - if(res!=EQUIP_ERR_OK) - continue; - - if(count==0) - return EQUIP_ERR_OK; - } - } - - for(int i = BANK_SLOT_BAG_START; i < BANK_SLOT_BAG_END; i++) - { - res = _CanStoreItem_InBag(i,dest,pProto,count,true,true,pItem,bag,slot); - if(res!=EQUIP_ERR_OK) - continue; - - if(count==0) - return EQUIP_ERR_OK; - } - } - - // search free place in special bag - if( pProto->BagFamily ) - { - for(int i = BANK_SLOT_BAG_START; i < BANK_SLOT_BAG_END; i++) - { - res = _CanStoreItem_InBag(i,dest,pProto,count,false,false,pItem,bag,slot); - if(res!=EQUIP_ERR_OK) - continue; - - if(count==0) - return EQUIP_ERR_OK; - } - } - - // search free space - res = _CanStoreItem_InInventorySlots(BANK_SLOT_ITEM_START,BANK_SLOT_ITEM_END,dest,pProto,count,false,pItem,bag,slot); - if(res!=EQUIP_ERR_OK) - return res; - - if(count==0) - return EQUIP_ERR_OK; - - for(int i = BANK_SLOT_BAG_START; i < BANK_SLOT_BAG_END; i++) - { - res = _CanStoreItem_InBag(i,dest,pProto,count,false,true,pItem,bag,slot); - if(res!=EQUIP_ERR_OK) - continue; - - if(count==0) - return EQUIP_ERR_OK; - } - return EQUIP_ERR_BANK_FULL; -} - -uint8 Player::CanUseItem( Item *pItem, bool not_loading ) const -{ - if( pItem ) - { - sLog.outDebug( "STORAGE: CanUseItem item = %u", pItem->GetEntry()); - if( !isAlive() && not_loading ) - return EQUIP_ERR_YOU_ARE_DEAD; - //if( isStunned() ) - // return EQUIP_ERR_YOU_ARE_STUNNED; - ItemPrototype const *pProto = pItem->GetProto(); - if( pProto ) - { - if( pItem->IsBindedNotWith(GetGUID()) ) - return EQUIP_ERR_DONT_OWN_THAT_ITEM; - if( (pProto->AllowableClass & getClassMask()) == 0 || (pProto->AllowableRace & getRaceMask()) == 0 ) - return EQUIP_ERR_YOU_CAN_NEVER_USE_THAT_ITEM; - if( pItem->GetSkill() != 0 ) - { - if( GetSkillValue( pItem->GetSkill() ) == 0 ) - return EQUIP_ERR_NO_REQUIRED_PROFICIENCY; - } - if( pProto->RequiredSkill != 0 ) - { - if( GetSkillValue( pProto->RequiredSkill ) == 0 ) - return EQUIP_ERR_NO_REQUIRED_PROFICIENCY; - else if( GetSkillValue( pProto->RequiredSkill ) < pProto->RequiredSkillRank ) - return EQUIP_ERR_ERR_CANT_EQUIP_SKILL; - } - if( pProto->RequiredSpell != 0 && !HasSpell( pProto->RequiredSpell ) ) - return EQUIP_ERR_NO_REQUIRED_PROFICIENCY; - if( pProto->RequiredReputationFaction && uint32(GetReputationRank(pProto->RequiredReputationFaction)) < pProto->RequiredReputationRank ) - return EQUIP_ERR_CANT_EQUIP_REPUTATION; - if( getLevel() < pProto->RequiredLevel ) - return EQUIP_ERR_CANT_EQUIP_LEVEL_I; - return EQUIP_ERR_OK; - } - } - return EQUIP_ERR_ITEM_NOT_FOUND; -} - -bool Player::CanUseItem( ItemPrototype const *pProto ) -{ - // Used by group, function NeedBeforeGreed, to know if a prototype can be used by a player - - if( pProto ) - { - if( (pProto->AllowableClass & getClassMask()) == 0 || (pProto->AllowableRace & getRaceMask()) == 0 ) - return false; - if( pProto->RequiredSkill != 0 ) - { - if( GetSkillValue( pProto->RequiredSkill ) == 0 ) - return false; - else if( GetSkillValue( pProto->RequiredSkill ) < pProto->RequiredSkillRank ) - return false; - } - if( pProto->RequiredSpell != 0 && !HasSpell( pProto->RequiredSpell ) ) - return false; - if( getLevel() < pProto->RequiredLevel ) - return false; - return true; - } - return false; -} - -uint8 Player::CanUseAmmo( uint32 item ) const -{ - sLog.outDebug( "STORAGE: CanUseAmmo item = %u", item); - if( !isAlive() ) - return EQUIP_ERR_YOU_ARE_DEAD; - //if( isStunned() ) - // return EQUIP_ERR_YOU_ARE_STUNNED; - ItemPrototype const *pProto = objmgr.GetItemPrototype( item ); - if( pProto ) - { - if( pProto->InventoryType!= INVTYPE_AMMO ) - return EQUIP_ERR_ONLY_AMMO_CAN_GO_HERE; - if( (pProto->AllowableClass & getClassMask()) == 0 || (pProto->AllowableRace & getRaceMask()) == 0 ) - return EQUIP_ERR_YOU_CAN_NEVER_USE_THAT_ITEM; - if( pProto->RequiredSkill != 0 ) - { - if( GetSkillValue( pProto->RequiredSkill ) == 0 ) - return EQUIP_ERR_NO_REQUIRED_PROFICIENCY; - else if( GetSkillValue( pProto->RequiredSkill ) < pProto->RequiredSkillRank ) - return EQUIP_ERR_ERR_CANT_EQUIP_SKILL; - } - if( pProto->RequiredSpell != 0 && !HasSpell( pProto->RequiredSpell ) ) - return EQUIP_ERR_NO_REQUIRED_PROFICIENCY; - /*if( GetReputation() < pProto->RequiredReputation ) - return EQUIP_ERR_CANT_EQUIP_REPUTATION; - */ - if( getLevel() < pProto->RequiredLevel ) - return EQUIP_ERR_CANT_EQUIP_LEVEL_I; - - // Requires No Ammo - if(GetDummyAura(46699)) - return EQUIP_ERR_BAG_FULL6; - - return EQUIP_ERR_OK; - } - return EQUIP_ERR_ITEM_NOT_FOUND; -} - -void Player::SetAmmo( uint32 item ) -{ - if(!item) - return; - - // already set - if( GetUInt32Value(PLAYER_AMMO_ID) == item ) - return; - - // check ammo - if(item) - { - uint8 msg = CanUseAmmo( item ); - if( msg != EQUIP_ERR_OK ) - { - SendEquipError( msg, NULL, NULL ); - return; - } - } - - SetUInt32Value(PLAYER_AMMO_ID, item); - - _ApplyAmmoBonuses(); -} - -void Player::RemoveAmmo() -{ - SetUInt32Value(PLAYER_AMMO_ID, 0); - - m_ammoDPS = 0.0f; - - if(CanModifyStats()) - UpdateDamagePhysical(RANGED_ATTACK); -} - -// Return stored item (if stored to stack, it can diff. from pItem). And pItem ca be deleted in this case. -Item* Player::StoreNewItem( ItemPosCountVec const& dest, uint32 item, bool update,int32 randomPropertyId ) -{ - uint32 count = 0; - for(ItemPosCountVec::const_iterator itr = dest.begin(); itr != dest.end(); ++itr) - count += itr->count; - - Item *pItem = Item::CreateItem( item, count, this ); - if( pItem ) - { - ItemAddedQuestCheck( item, count ); - if(randomPropertyId) - pItem->SetItemRandomProperties(randomPropertyId); - pItem = StoreItem( dest, pItem, update ); - } - return pItem; -} - -Item* Player::StoreItem( ItemPosCountVec const& dest, Item* pItem, bool update ) -{ - if( !pItem ) - return NULL; - - Item* lastItem = pItem; - - for(ItemPosCountVec::const_iterator itr = dest.begin(); itr != dest.end(); ) - { - uint16 pos = itr->pos; - uint32 count = itr->count; - - ++itr; - - if(itr == dest.end()) - { - lastItem = _StoreItem(pos,pItem,count,false,update); - break; - } - - lastItem = _StoreItem(pos,pItem,count,true,update); - } - - return lastItem; -} - -// Return stored item (if stored to stack, it can diff. from pItem). And pItem ca be deleted in this case. -Item* Player::_StoreItem( uint16 pos, Item *pItem, uint32 count, bool clone, bool update ) -{ - if( !pItem ) - return NULL; - - uint8 bag = pos >> 8; - uint8 slot = pos & 255; - - sLog.outDebug( "STORAGE: StoreItem bag = %u, slot = %u, item = %u, count = %u", bag, slot, pItem->GetEntry(), count); - - Item *pItem2 = GetItemByPos( bag, slot ); - - if( !pItem2 ) - { - if(clone) - pItem = pItem->CloneItem(count,this); - else - pItem->SetCount(count); - - if(!pItem) - return NULL; - - if( pItem->GetProto()->Bonding == BIND_WHEN_PICKED_UP || - pItem->GetProto()->Bonding == BIND_QUEST_ITEM || - pItem->GetProto()->Bonding == BIND_WHEN_EQUIPED && IsBagPos(pos) ) - pItem->SetBinding( true ); - - if( bag == INVENTORY_SLOT_BAG_0 ) - { - m_items[slot] = pItem; - SetUInt64Value( (uint16)(PLAYER_FIELD_INV_SLOT_HEAD + (slot * 2) ), pItem->GetGUID() ); - pItem->SetUInt64Value( ITEM_FIELD_CONTAINED, GetGUID() ); - pItem->SetUInt64Value( ITEM_FIELD_OWNER, GetGUID() ); - - pItem->SetSlot( slot ); - pItem->SetContainer( NULL ); - - if( IsInWorld() && update ) - { - pItem->AddToWorld(); - pItem->SendUpdateToPlayer( this ); - } - - pItem->SetState(ITEM_CHANGED, this); - } - else - { - Bag *pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, bag ); - if( pBag ) - { - pBag->StoreItem( slot, pItem, update ); - if( IsInWorld() && update ) - { - pItem->AddToWorld(); - pItem->SendUpdateToPlayer( this ); - } - pItem->SetState(ITEM_CHANGED, this); - pBag->SetState(ITEM_CHANGED, this); - } - } - - AddEnchantmentDurations(pItem); - AddItemDurations(pItem); - - return pItem; - } - else - { - if( pItem2->GetProto()->Bonding == BIND_WHEN_PICKED_UP || - pItem2->GetProto()->Bonding == BIND_QUEST_ITEM || - pItem2->GetProto()->Bonding == BIND_WHEN_EQUIPED && IsBagPos(pos) ) - pItem2->SetBinding( true ); - - pItem2->SetCount( pItem2->GetCount() + count ); - if( IsInWorld() && update ) - pItem2->SendUpdateToPlayer( this ); - - if(!clone) - { - // delete item (it not in any slot currently) - if( IsInWorld() && update ) - { - pItem->RemoveFromWorld(); - pItem->DestroyForPlayer( this ); - } - - RemoveEnchantmentDurations(pItem); - RemoveItemDurations(pItem); - - pItem->SetOwnerGUID(GetGUID()); // prevent error at next SetState in case trade/mail/buy from vendor - pItem->SetState(ITEM_REMOVED, this); - } - // AddItemDurations(pItem2); - pItem2 already have duration listed for player - AddEnchantmentDurations(pItem2); - - pItem2->SetState(ITEM_CHANGED, this); - - return pItem2; - } -} - -Item* Player::EquipNewItem( uint16 pos, uint32 item, uint32 count, bool update ) -{ - Item *pItem = Item::CreateItem( item, count, this ); - if( pItem ) - { - ItemAddedQuestCheck( item, count ); - Item * retItem = EquipItem( pos, pItem, update ); - - return retItem; - } - return NULL; -} - -Item* Player::EquipItem( uint16 pos, Item *pItem, bool update ) -{ - if( pItem ) - { - AddEnchantmentDurations(pItem); - AddItemDurations(pItem); - - uint8 bag = pos >> 8; - uint8 slot = pos & 255; - - Item *pItem2 = GetItemByPos( bag, slot ); - - if( !pItem2 ) - { - VisualizeItem( slot, pItem); - - if(isAlive()) - { - ItemPrototype const *pProto = pItem->GetProto(); - - // item set bonuses applied only at equip and removed at unequip, and still active for broken items - if(pProto && pProto->ItemSet) - AddItemsSetItem(this,pItem); - - _ApplyItemMods(pItem, slot, true); - - if(pProto && isInCombat()&& pProto->Class == ITEM_CLASS_WEAPON && m_weaponChangeTimer == 0) - { - m_weaponChangeTimer = DEFAULT_SWITCH_WEAPON; - if (getClass() == CLASS_ROGUE) - m_weaponChangeTimer = ROGUE_SWITCH_WEAPON; - } - } - - if( IsInWorld() && update ) - { - pItem->AddToWorld(); - pItem->SendUpdateToPlayer( this ); - } - - ApplyEquipCooldown(pItem); - - if( slot == EQUIPMENT_SLOT_MAINHAND ) - UpdateExpertise(BASE_ATTACK); - else if( slot == EQUIPMENT_SLOT_OFFHAND ) - UpdateExpertise(OFF_ATTACK); - } - else - { - pItem2->SetCount( pItem2->GetCount() + pItem->GetCount() ); - if( IsInWorld() && update ) - pItem2->SendUpdateToPlayer( this ); - - // delete item (it not in any slot currently) - //pItem->DeleteFromDB(); - if( IsInWorld() && update ) - { - pItem->RemoveFromWorld(); - pItem->DestroyForPlayer( this ); - } - - RemoveEnchantmentDurations(pItem); - RemoveItemDurations(pItem); - - pItem->SetOwnerGUID(GetGUID()); // prevent error at next SetState in case trade/mail/buy from vendor - pItem->SetState(ITEM_REMOVED, this); - pItem2->SetState(ITEM_CHANGED, this); - - ApplyEquipCooldown(pItem2); - - return pItem2; - } - } - - return pItem; -} - -void Player::QuickEquipItem( uint16 pos, Item *pItem) -{ - if( pItem ) - { - AddEnchantmentDurations(pItem); - AddItemDurations(pItem); - - uint8 slot = pos & 255; - VisualizeItem( slot, pItem); - - if( IsInWorld() ) - { - pItem->AddToWorld(); - pItem->SendUpdateToPlayer( this ); - } - } -} - -void Player::SetVisibleItemSlot(uint8 slot, Item *pItem) -{ - // PLAYER_VISIBLE_ITEM_i_CREATOR // Size: 2 - // PLAYER_VISIBLE_ITEM_i_0 // Size: 12 - // entry // Size: 1 - // inspected enchantments // Size: 6 - // ? // Size: 5 - // PLAYER_VISIBLE_ITEM_i_PROPERTIES // Size: 1 (property,suffix factor) - // PLAYER_VISIBLE_ITEM_i_PAD // Size: 1 - // // = 16 - - if(pItem) - { - SetUInt64Value(PLAYER_VISIBLE_ITEM_1_CREATOR + (slot * MAX_VISIBLE_ITEM_OFFSET), pItem->GetUInt64Value(ITEM_FIELD_CREATOR)); - - int VisibleBase = PLAYER_VISIBLE_ITEM_1_0 + (slot * MAX_VISIBLE_ITEM_OFFSET); - SetUInt32Value(VisibleBase + 0, pItem->GetEntry()); - - for(int i = 0; i < MAX_INSPECTED_ENCHANTMENT_SLOT; ++i) - SetUInt32Value(VisibleBase + 1 + i, pItem->GetEnchantmentId(EnchantmentSlot(i))); - - // Use SetInt16Value to prevent set high part to FFFF for negative value - SetInt16Value( PLAYER_VISIBLE_ITEM_1_PROPERTIES + (slot * MAX_VISIBLE_ITEM_OFFSET), 0, pItem->GetItemRandomPropertyId()); - SetUInt32Value(PLAYER_VISIBLE_ITEM_1_PROPERTIES + 1 + (slot * MAX_VISIBLE_ITEM_OFFSET), pItem->GetItemSuffixFactor()); - } - else - { - SetUInt64Value(PLAYER_VISIBLE_ITEM_1_CREATOR + (slot * MAX_VISIBLE_ITEM_OFFSET), 0); - - int VisibleBase = PLAYER_VISIBLE_ITEM_1_0 + (slot * MAX_VISIBLE_ITEM_OFFSET); - SetUInt32Value(VisibleBase + 0, 0); - - for(int i = 0; i < MAX_INSPECTED_ENCHANTMENT_SLOT; ++i) - SetUInt32Value(VisibleBase + 1 + i, 0); - - SetUInt32Value(PLAYER_VISIBLE_ITEM_1_PROPERTIES + 0 + (slot * MAX_VISIBLE_ITEM_OFFSET), 0); - SetUInt32Value(PLAYER_VISIBLE_ITEM_1_PROPERTIES + 1 + (slot * MAX_VISIBLE_ITEM_OFFSET), 0); - } -} - -void Player::VisualizeItem( uint8 slot, Item *pItem) -{ - if(!pItem) - return; - - // check also BIND_WHEN_PICKED_UP and BIND_QUEST_ITEM for .additem or .additemset case by GM (not binded at adding to inventory) - if( pItem->GetProto()->Bonding == BIND_WHEN_EQUIPED || pItem->GetProto()->Bonding == BIND_WHEN_PICKED_UP || pItem->GetProto()->Bonding == BIND_QUEST_ITEM ) - pItem->SetBinding( true ); - - sLog.outDebug( "STORAGE: EquipItem slot = %u, item = %u", slot, pItem->GetEntry()); - - m_items[slot] = pItem; - SetUInt64Value( (uint16)(PLAYER_FIELD_INV_SLOT_HEAD + (slot * 2) ), pItem->GetGUID() ); - pItem->SetUInt64Value( ITEM_FIELD_CONTAINED, GetGUID() ); - pItem->SetUInt64Value( ITEM_FIELD_OWNER, GetGUID() ); - pItem->SetSlot( slot ); - pItem->SetContainer( NULL ); - - if( slot < EQUIPMENT_SLOT_END ) - SetVisibleItemSlot(slot,pItem); - - pItem->SetState(ITEM_CHANGED, this); -} - -void Player::RemoveItem( uint8 bag, uint8 slot, bool update ) -{ - // note: removeitem does not actually change the item - // it only takes the item out of storage temporarily - // note2: if removeitem is to be used for delinking - // the item must be removed from the player's updatequeue - - Item *pItem = GetItemByPos( bag, slot ); - if( pItem ) - { - sLog.outDebug( "STORAGE: RemoveItem bag = %u, slot = %u, item = %u", bag, slot, pItem->GetEntry()); - - RemoveEnchantmentDurations(pItem); - RemoveItemDurations(pItem); - - if( bag == INVENTORY_SLOT_BAG_0 ) - { - if ( slot < INVENTORY_SLOT_BAG_END ) - { - ItemPrototype const *pProto = pItem->GetProto(); - // item set bonuses applied only at equip and removed at unequip, and still active for broken items - - if(pProto && pProto->ItemSet) - RemoveItemsSetItem(this,pProto); - - _ApplyItemMods(pItem, slot, false); - - // remove item dependent auras and casts (only weapon and armor slots) - if(slot < EQUIPMENT_SLOT_END) - RemoveItemDependentAurasAndCasts(pItem); - - // remove held enchantments - if ( slot == EQUIPMENT_SLOT_MAINHAND ) - { - if (pItem->GetItemSuffixFactor()) - { - pItem->ClearEnchantment(PROP_ENCHANTMENT_SLOT_3); - pItem->ClearEnchantment(PROP_ENCHANTMENT_SLOT_4); - } - else - { - pItem->ClearEnchantment(PROP_ENCHANTMENT_SLOT_0); - pItem->ClearEnchantment(PROP_ENCHANTMENT_SLOT_1); - } - } - } - - m_items[slot] = NULL; - SetUInt64Value((uint16)(PLAYER_FIELD_INV_SLOT_HEAD + (slot*2)), 0); - - if ( slot < EQUIPMENT_SLOT_END ) - SetVisibleItemSlot(slot,NULL); - } - else - { - Bag *pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, bag ); - if( pBag ) - pBag->RemoveItem(slot, update); - } - pItem->SetUInt64Value( ITEM_FIELD_CONTAINED, 0 ); - // pItem->SetUInt64Value( ITEM_FIELD_OWNER, 0 ); not clear owner at remove (it will be set at store). This used in mail and auction code - pItem->SetSlot( NULL_SLOT ); - if( IsInWorld() && update ) - pItem->SendUpdateToPlayer( this ); - - if( slot == EQUIPMENT_SLOT_MAINHAND ) - UpdateExpertise(BASE_ATTACK); - else if( slot == EQUIPMENT_SLOT_OFFHAND ) - UpdateExpertise(OFF_ATTACK); - } -} - -// Common operation need to remove item from inventory without delete in trade, auction, guild bank, mail.... -void Player::MoveItemFromInventory(uint8 bag, uint8 slot, bool update) -{ - if(Item* it = GetItemByPos(bag,slot)) - { - ItemRemovedQuestCheck(it->GetEntry(),it->GetCount()); - RemoveItem( bag,slot,update); - it->RemoveFromUpdateQueueOf(this); - if(it->IsInWorld()) - { - it->RemoveFromWorld(); - it->DestroyForPlayer( this ); - } - } -} - -// Common operation need to add item from inventory without delete in trade, guild bank, mail.... -void Player::MoveItemToInventory(ItemPosCountVec const& dest, Item* pItem, bool update, bool in_characterInventoryDB) -{ - // update quest counters - ItemAddedQuestCheck(pItem->GetEntry(),pItem->GetCount()); - - // store item - Item* pLastItem = StoreItem( dest, pItem, update); - - // only set if not merged to existed stack (pItem can be deleted already but we can compare pointers any way) - if(pLastItem==pItem) - { - // update owner for last item (this can be original item with wrong owner - if(pLastItem->GetOwnerGUID() != GetGUID()) - pLastItem->SetOwnerGUID(GetGUID()); - - // if this original item then it need create record in inventory - // in case trade we laready have item in other player inventory - pLastItem->SetState(in_characterInventoryDB ? ITEM_CHANGED : ITEM_NEW, this); - } -} - -void Player::DestroyItem( uint8 bag, uint8 slot, bool update ) -{ - Item *pItem = GetItemByPos( bag, slot ); - if( pItem ) - { - sLog.outDebug( "STORAGE: DestroyItem bag = %u, slot = %u, item = %u", bag, slot, pItem->GetEntry()); - - // start from destroy contained items (only equipped bag can have its) - if (pItem->IsBag() && pItem->IsEquipped()) // this also prevent infinity loop if empty bag stored in bag==slot - { - for (int i = 0; i < MAX_BAG_SIZE; i++) - DestroyItem(slot,i,update); - } - - if(pItem->HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAGS_WRAPPED)) - CharacterDatabase.PExecute("DELETE FROM character_gifts WHERE item_guid = '%u'", pItem->GetGUIDLow()); - - ItemPrototype const *pProto = pItem->GetProto(); - - RemoveEnchantmentDurations(pItem); - RemoveItemDurations(pItem); - - ItemRemovedQuestCheck( pItem->GetEntry(), pItem->GetCount() ); - - if( bag == INVENTORY_SLOT_BAG_0 ) - { - - SetUInt64Value((uint16)(PLAYER_FIELD_INV_SLOT_HEAD + (slot*2)), 0); - - // equipment and equipped bags can have applied bonuses - if ( slot < INVENTORY_SLOT_BAG_END ) - { - ItemPrototype const *pProto = pItem->GetProto(); - - // item set bonuses applied only at equip and removed at unequip, and still active for broken items - if(pProto && pProto->ItemSet) - RemoveItemsSetItem(this,pProto); - - _ApplyItemMods(pItem, slot, false); - } - - if ( slot < EQUIPMENT_SLOT_END ) - { - // remove item dependent auras and casts (only weapon and armor slots) - RemoveItemDependentAurasAndCasts(pItem); - - // equipment visual show - SetVisibleItemSlot(slot,NULL); - } - - m_items[slot] = NULL; - } - else if(Bag *pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, bag )) - pBag->RemoveItem(slot, update); - - if( IsInWorld() && update ) - { - pItem->RemoveFromWorld(); - pItem->DestroyForPlayer(this); - } - - //pItem->SetOwnerGUID(0); - pItem->SetUInt64Value( ITEM_FIELD_CONTAINED, 0 ); - pItem->SetSlot( NULL_SLOT ); - pItem->SetState(ITEM_REMOVED, this); - } -} - -void Player::DestroyItemCount( uint32 item, uint32 count, bool update, bool unequip_check) -{ - sLog.outDebug( "STORAGE: DestroyItemCount item = %u, count = %u", item, count); - Item *pItem; - ItemPrototype const *pProto; - uint32 remcount = 0; - - // in inventory - for(int i = INVENTORY_SLOT_ITEM_START; i < INVENTORY_SLOT_ITEM_END; i++) - { - pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i ); - if( pItem && pItem->GetEntry() == item ) - { - if( pItem->GetCount() + remcount <= count ) - { - // all items in inventory can unequipped - remcount += pItem->GetCount(); - DestroyItem( INVENTORY_SLOT_BAG_0, i, update); - - if(remcount >=count) - return; - } - else - { - pProto = pItem->GetProto(); - ItemRemovedQuestCheck( pItem->GetEntry(), count - remcount ); - pItem->SetCount( pItem->GetCount() - count + remcount ); - if( IsInWorld() & update ) - pItem->SendUpdateToPlayer( this ); - pItem->SetState(ITEM_CHANGED, this); - return; - } - } - } - for(int i = KEYRING_SLOT_START; i < KEYRING_SLOT_END; i++) - { - pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i ); - if( pItem && pItem->GetEntry() == item ) - { - if( pItem->GetCount() + remcount <= count ) - { - // all keys can be unequipped - remcount += pItem->GetCount(); - DestroyItem( INVENTORY_SLOT_BAG_0, i, update); - - if(remcount >=count) - return; - } - else - { - pProto = pItem->GetProto(); - ItemRemovedQuestCheck( pItem->GetEntry(), count - remcount ); - pItem->SetCount( pItem->GetCount() - count + remcount ); - if( IsInWorld() & update ) - pItem->SendUpdateToPlayer( this ); - pItem->SetState(ITEM_CHANGED, this); - return; - } - } - } - - // in inventory bags - Bag *pBag; - ItemPrototype const *pBagProto; - for(int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; i++) - { - pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i ); - if( pBag ) - { - pBagProto = pBag->GetProto(); - if( pBagProto ) - { - for(uint32 j = 0; j < pBagProto->ContainerSlots; j++) - { - pItem = pBag->GetItemByPos(j); - if( pItem && pItem->GetEntry() == item ) - { - // all items in bags can be unequipped - if( pItem->GetCount() + remcount <= count ) - { - remcount += pItem->GetCount(); - DestroyItem( i, j, update ); - - if(remcount >=count) - return; - } - else - { - pProto = pItem->GetProto(); - ItemRemovedQuestCheck( pItem->GetEntry(), count - remcount ); - pItem->SetCount( pItem->GetCount() - count + remcount ); - if( IsInWorld() && update ) - pItem->SendUpdateToPlayer( this ); - pItem->SetState(ITEM_CHANGED, this); - return; - } - } - } - } - } - } - - // in equipment and bag list - for(int i = EQUIPMENT_SLOT_START; i < INVENTORY_SLOT_BAG_END; i++) - { - pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i ); - if( pItem && pItem->GetEntry() == item ) - { - if( pItem->GetCount() + remcount <= count ) - { - if(!unequip_check || CanUnequipItem(INVENTORY_SLOT_BAG_0 << 8 | i,false) == EQUIP_ERR_OK ) - { - remcount += pItem->GetCount(); - DestroyItem( INVENTORY_SLOT_BAG_0, i, update); - - if(remcount >=count) - return; - } - } - else - { - pProto = pItem->GetProto(); - ItemRemovedQuestCheck( pItem->GetEntry(), count - remcount ); - pItem->SetCount( pItem->GetCount() - count + remcount ); - if( IsInWorld() & update ) - pItem->SendUpdateToPlayer( this ); - pItem->SetState(ITEM_CHANGED, this); - return; - } - } - } -} - -void Player::DestroyZoneLimitedItem( bool update, uint32 new_zone ) -{ - sLog.outDebug( "STORAGE: DestroyZoneLimitedItem in map %u and area %u", GetMapId(), new_zone ); - - // in inventory - for(int i = INVENTORY_SLOT_ITEM_START; i < INVENTORY_SLOT_ITEM_END; i++) - { - Item* pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i ); - if( pItem && pItem->IsLimitedToAnotherMapOrZone(GetMapId(),new_zone) ) - DestroyItem( INVENTORY_SLOT_BAG_0, i, update); - } - for(int i = KEYRING_SLOT_START; i < KEYRING_SLOT_END; i++) - { - Item* pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i ); - if( pItem && pItem->IsLimitedToAnotherMapOrZone(GetMapId(),new_zone) ) - DestroyItem( INVENTORY_SLOT_BAG_0, i, update); - } - - // in inventory bags - for(int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; i++) - { - Bag* pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i ); - if( pBag ) - { - ItemPrototype const *pBagProto = pBag->GetProto(); - if( pBagProto ) - { - for(uint32 j = 0; j < pBagProto->ContainerSlots; j++) - { - Item* pItem = pBag->GetItemByPos(j); - if( pItem && pItem->IsLimitedToAnotherMapOrZone(GetMapId(),new_zone) ) - DestroyItem( i, j, update); - } - } - } - } - - // in equipment and bag list - for(int i = EQUIPMENT_SLOT_START; i < INVENTORY_SLOT_BAG_END; i++) - { - Item* pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i ); - if( pItem && pItem->IsLimitedToAnotherMapOrZone(GetMapId(),new_zone) ) - DestroyItem( INVENTORY_SLOT_BAG_0, i, update); - } -} - -void Player::DestroyConjuredItems( bool update ) -{ - // used when entering arena - // distroys all conjured items - sLog.outDebug( "STORAGE: DestroyConjuredItems" ); - - // in inventory - for(int i = INVENTORY_SLOT_ITEM_START; i < INVENTORY_SLOT_ITEM_END; i++) - { - Item* pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i ); - if( pItem && pItem->GetProto() && - (pItem->GetProto()->Class == ITEM_CLASS_CONSUMABLE) && - (pItem->GetProto()->Flags & ITEM_FLAGS_CONJURED) ) - DestroyItem( INVENTORY_SLOT_BAG_0, i, update); - } - - // in inventory bags - for(int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; i++) - { - Bag* pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i ); - if( pBag ) - { - ItemPrototype const *pBagProto = pBag->GetProto(); - if( pBagProto ) - { - for(uint32 j = 0; j < pBagProto->ContainerSlots; j++) - { - Item* pItem = pBag->GetItemByPos(j); - if( pItem && pItem->GetProto() && - (pItem->GetProto()->Class == ITEM_CLASS_CONSUMABLE) && - (pItem->GetProto()->Flags & ITEM_FLAGS_CONJURED) ) - DestroyItem( i, j, update); - } - } - } - } - - // in equipment and bag list - for(int i = EQUIPMENT_SLOT_START; i < INVENTORY_SLOT_BAG_END; i++) - { - Item* pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i ); - if( pItem && pItem->GetProto() && - (pItem->GetProto()->Class == ITEM_CLASS_CONSUMABLE) && - (pItem->GetProto()->Flags & ITEM_FLAGS_CONJURED) ) - DestroyItem( INVENTORY_SLOT_BAG_0, i, update); - } -} - -void Player::DestroyItemCount( Item* pItem, uint32 &count, bool update ) -{ - if(!pItem) - return; - - sLog.outDebug( "STORAGE: DestroyItemCount item (GUID: %u, Entry: %u) count = %u", pItem->GetGUIDLow(),pItem->GetEntry(), count); - - if( pItem->GetCount() <= count ) - { - count-= pItem->GetCount(); - - DestroyItem( pItem->GetBagSlot(),pItem->GetSlot(), update); - } - else - { - ItemRemovedQuestCheck( pItem->GetEntry(), count); - pItem->SetCount( pItem->GetCount() - count ); - count = 0; - if( IsInWorld() & update ) - pItem->SendUpdateToPlayer( this ); - pItem->SetState(ITEM_CHANGED, this); - } -} - -void Player::SplitItem( uint16 src, uint16 dst, uint32 count ) -{ - uint8 srcbag = src >> 8; - uint8 srcslot = src & 255; - - uint8 dstbag = dst >> 8; - uint8 dstslot = dst & 255; - - Item *pSrcItem = GetItemByPos( srcbag, srcslot ); - if( !pSrcItem ) - { - SendEquipError( EQUIP_ERR_ITEM_NOT_FOUND, pSrcItem, NULL ); - return; - } - - // not let split all items (can be only at cheating) - if(pSrcItem->GetCount() == count) - { - SendEquipError( EQUIP_ERR_COULDNT_SPLIT_ITEMS, pSrcItem, NULL ); - return; - } - - // not let split more existed items (can be only at cheating) - if(pSrcItem->GetCount() < count) - { - SendEquipError( EQUIP_ERR_TRIED_TO_SPLIT_MORE_THAN_COUNT, pSrcItem, NULL ); - return; - } - - if(pSrcItem->m_lootGenerated) // prevent split looting item (item - { - //best error message found for attempting to split while looting - SendEquipError( EQUIP_ERR_COULDNT_SPLIT_ITEMS, pSrcItem, NULL ); - return; - } - - sLog.outDebug( "STORAGE: SplitItem bag = %u, slot = %u, item = %u, count = %u", dstbag, dstslot, pSrcItem->GetEntry(), count); - Item *pNewItem = pSrcItem->CloneItem( count, this ); - if( !pNewItem ) - { - SendEquipError( EQUIP_ERR_ITEM_NOT_FOUND, pSrcItem, NULL ); - return; - } - - if( IsInventoryPos( dst ) ) - { - // change item amount before check (for unique max count check) - pSrcItem->SetCount( pSrcItem->GetCount() - count ); - - ItemPosCountVec dest; - uint8 msg = CanStoreItem( dstbag, dstslot, dest, pNewItem, false ); - if( msg != EQUIP_ERR_OK ) - { - delete pNewItem; - pSrcItem->SetCount( pSrcItem->GetCount() + count ); - SendEquipError( msg, pSrcItem, NULL ); - return; - } - - if( IsInWorld() ) - pSrcItem->SendUpdateToPlayer( this ); - pSrcItem->SetState(ITEM_CHANGED, this); - StoreItem( dest, pNewItem, true); - } - else if( IsBankPos ( dst ) ) - { - // change item amount before check (for unique max count check) - pSrcItem->SetCount( pSrcItem->GetCount() - count ); - - ItemPosCountVec dest; - uint8 msg = CanBankItem( dstbag, dstslot, dest, pNewItem, false ); - if( msg != EQUIP_ERR_OK ) - { - delete pNewItem; - pSrcItem->SetCount( pSrcItem->GetCount() + count ); - SendEquipError( msg, pSrcItem, NULL ); - return; - } - - if( IsInWorld() ) - pSrcItem->SendUpdateToPlayer( this ); - pSrcItem->SetState(ITEM_CHANGED, this); - BankItem( dest, pNewItem, true); - } - else if( IsEquipmentPos ( dst ) ) - { - // change item amount before check (for unique max count check), provide space for splitted items - pSrcItem->SetCount( pSrcItem->GetCount() - count ); - - uint16 dest; - uint8 msg = CanEquipItem( dstslot, dest, pNewItem, false ); - if( msg != EQUIP_ERR_OK ) - { - delete pNewItem; - pSrcItem->SetCount( pSrcItem->GetCount() + count ); - SendEquipError( msg, pSrcItem, NULL ); - return; - } - - if( IsInWorld() ) - pSrcItem->SendUpdateToPlayer( this ); - pSrcItem->SetState(ITEM_CHANGED, this); - EquipItem( dest, pNewItem, true); - AutoUnequipOffhandIfNeed(); - } -} - -void Player::SwapItem( uint16 src, uint16 dst ) -{ - uint8 srcbag = src >> 8; - uint8 srcslot = src & 255; - - uint8 dstbag = dst >> 8; - uint8 dstslot = dst & 255; - - Item *pSrcItem = GetItemByPos( srcbag, srcslot ); - Item *pDstItem = GetItemByPos( dstbag, dstslot ); - - if( !pSrcItem ) - return; - - sLog.outDebug( "STORAGE: SwapItem bag = %u, slot = %u, item = %u", dstbag, dstslot, pSrcItem->GetEntry()); - - if(!isAlive() ) - { - SendEquipError( EQUIP_ERR_YOU_ARE_DEAD, pSrcItem, pDstItem ); - return; - } - - if(pSrcItem->m_lootGenerated) // prevent swap looting item - { - //best error message found for attempting to swap while looting - SendEquipError( EQUIP_ERR_CANT_DO_RIGHT_NOW, pSrcItem, NULL ); - return; - } - - // check unequip potability for equipped items and bank bags - if(IsEquipmentPos ( src ) || IsBagPos ( src )) - { - // bags can be swapped with empty bag slots - uint8 msg = CanUnequipItem( src, !IsBagPos ( src ) || IsBagPos ( dst )); - if(msg != EQUIP_ERR_OK) - { - SendEquipError( msg, pSrcItem, pDstItem ); - return; - } - } - - // prevent put equipped/bank bag in self - if( IsBagPos ( src ) && srcslot == dstbag) - { - SendEquipError( EQUIP_ERR_NONEMPTY_BAG_OVER_OTHER_BAG, pSrcItem, pDstItem ); - return; - } - - if( !pDstItem ) - { - if( IsInventoryPos( dst ) ) - { - ItemPosCountVec dest; - uint8 msg = CanStoreItem( dstbag, dstslot, dest, pSrcItem, false ); - if( msg != EQUIP_ERR_OK ) - { - SendEquipError( msg, pSrcItem, NULL ); - return; - } - - RemoveItem(srcbag, srcslot, true); - StoreItem( dest, pSrcItem, true); - } - else if( IsBankPos ( dst ) ) - { - ItemPosCountVec dest; - uint8 msg = CanBankItem( dstbag, dstslot, dest, pSrcItem, false); - if( msg != EQUIP_ERR_OK ) - { - SendEquipError( msg, pSrcItem, NULL ); - return; - } - - RemoveItem(srcbag, srcslot, true); - BankItem( dest, pSrcItem, true); - } - else if( IsEquipmentPos ( dst ) ) - { - uint16 dest; - uint8 msg = CanEquipItem( dstslot, dest, pSrcItem, false ); - if( msg != EQUIP_ERR_OK ) - { - SendEquipError( msg, pSrcItem, NULL ); - return; - } - - RemoveItem(srcbag, srcslot, true); - EquipItem( dest, pSrcItem, true); - AutoUnequipOffhandIfNeed(); - } - } - else // if (!pDstItem) - { - if(pDstItem->m_lootGenerated) // prevent swap looting item - { - //best error message found for attempting to swap while looting - SendEquipError( EQUIP_ERR_CANT_DO_RIGHT_NOW, pDstItem, NULL ); - return; - } - - // check unequip potability for equipped items and bank bags - if(IsEquipmentPos ( dst ) || IsBagPos ( dst )) - { - // bags can be swapped with empty bag slots - uint8 msg = CanUnequipItem( dst, !IsBagPos ( dst ) || IsBagPos ( src ) ); - if(msg != EQUIP_ERR_OK) - { - SendEquipError( msg, pSrcItem, pDstItem ); - return; - } - } - - // attempt merge to / fill target item - { - uint8 msg; - ItemPosCountVec sDest; - uint16 eDest; - if( IsInventoryPos( dst ) ) - msg = CanStoreItem( dstbag, dstslot, sDest, pSrcItem, false ); - else if( IsBankPos ( dst ) ) - msg = CanBankItem( dstbag, dstslot, sDest, pSrcItem, false ); - else if( IsEquipmentPos ( dst ) ) - msg = CanEquipItem( dstslot, eDest, pSrcItem, false ); - else - return; - - // can be merge/fill - if(msg == EQUIP_ERR_OK) - { - if( pSrcItem->GetCount() + pDstItem->GetCount() <= pSrcItem->GetProto()->Stackable ) - { - RemoveItem(srcbag, srcslot, true); - - if( IsInventoryPos( dst ) ) - StoreItem( sDest, pSrcItem, true); - else if( IsBankPos ( dst ) ) - BankItem( sDest, pSrcItem, true); - else if( IsEquipmentPos ( dst ) ) - { - EquipItem( eDest, pSrcItem, true); - AutoUnequipOffhandIfNeed(); - } - } - else - { - pSrcItem->SetCount( pSrcItem->GetCount() + pDstItem->GetCount() - pSrcItem->GetProto()->Stackable ); - pDstItem->SetCount( pSrcItem->GetProto()->Stackable ); - pSrcItem->SetState(ITEM_CHANGED, this); - pDstItem->SetState(ITEM_CHANGED, this); - if( IsInWorld() ) - { - pSrcItem->SendUpdateToPlayer( this ); - pDstItem->SendUpdateToPlayer( this ); - } - } - return; - } - } - - // impossible merge/fill, do real swap - uint8 msg; - - // check src->dest move possibility - ItemPosCountVec sDest; - uint16 eDest; - if( IsInventoryPos( dst ) ) - msg = CanStoreItem( dstbag, dstslot, sDest, pSrcItem, true ); - else if( IsBankPos( dst ) ) - msg = CanBankItem( dstbag, dstslot, sDest, pSrcItem, true ); - else if( IsEquipmentPos( dst ) ) - { - msg = CanEquipItem( dstslot, eDest, pSrcItem, true ); - if( msg == EQUIP_ERR_OK ) - msg = CanUnequipItem( eDest, true ); - } - - if( msg != EQUIP_ERR_OK ) - { - SendEquipError( msg, pSrcItem, pDstItem ); - return; - } - - // check dest->src move possibility - ItemPosCountVec sDest2; - uint16 eDest2; - if( IsInventoryPos( src ) ) - msg = CanStoreItem( srcbag, srcslot, sDest2, pDstItem, true ); - else if( IsBankPos( src ) ) - msg = CanBankItem( srcbag, srcslot, sDest2, pDstItem, true ); - else if( IsEquipmentPos( src ) ) - { - msg = CanEquipItem( srcslot, eDest2, pDstItem, true); - if( msg == EQUIP_ERR_OK ) - msg = CanUnequipItem( eDest2, true); - } - - if( msg != EQUIP_ERR_OK ) - { - SendEquipError( msg, pDstItem, pSrcItem ); - return; - } - - // now do moves, remove... - RemoveItem(dstbag, dstslot, false); - RemoveItem(srcbag, srcslot, false); - - // add to dest - if( IsInventoryPos( dst ) ) - StoreItem(sDest, pSrcItem, true); - else if( IsBankPos( dst ) ) - BankItem(sDest, pSrcItem, true); - else if( IsEquipmentPos( dst ) ) - EquipItem(eDest, pSrcItem, true); - - // add to src - if( IsInventoryPos( src ) ) - StoreItem(sDest2, pDstItem, true); - else if( IsBankPos( src ) ) - BankItem(sDest2, pDstItem, true); - else if( IsEquipmentPos( src ) ) - EquipItem(eDest2, pDstItem, true); - - AutoUnequipOffhandIfNeed(); - } -} - -void Player::AddItemToBuyBackSlot( Item *pItem ) -{ - if( pItem ) - { - uint32 slot = m_currentBuybackSlot; - // if current back slot non-empty search oldest or free - if(m_items[slot]) - { - uint32 oldest_time = GetUInt32Value( PLAYER_FIELD_BUYBACK_TIMESTAMP_1 ); - uint32 oldest_slot = BUYBACK_SLOT_START; - - for(uint32 i = BUYBACK_SLOT_START+1; i < BUYBACK_SLOT_END; ++i ) - { - // found empty - if(!m_items[i]) - { - slot = i; - break; - } - - uint32 i_time = GetUInt32Value( PLAYER_FIELD_BUYBACK_TIMESTAMP_1 + i - BUYBACK_SLOT_START); - - if(oldest_time > i_time) - { - oldest_time = i_time; - oldest_slot = i; - } - } - - // find oldest - slot = oldest_slot; - } - - RemoveItemFromBuyBackSlot( slot, true ); - sLog.outDebug( "STORAGE: AddItemToBuyBackSlot item = %u, slot = %u", pItem->GetEntry(), slot); - - m_items[slot] = pItem; - time_t base = time(NULL); - uint32 etime = uint32(base - m_logintime + (30 * 3600)); - uint32 eslot = slot - BUYBACK_SLOT_START; - - SetUInt64Value( PLAYER_FIELD_VENDORBUYBACK_SLOT_1 + eslot * 2, pItem->GetGUID() ); - ItemPrototype const *pProto = pItem->GetProto(); - if( pProto ) - SetUInt32Value( PLAYER_FIELD_BUYBACK_PRICE_1 + eslot, pProto->SellPrice * pItem->GetCount() ); - else - SetUInt32Value( PLAYER_FIELD_BUYBACK_PRICE_1 + eslot, 0 ); - SetUInt32Value( PLAYER_FIELD_BUYBACK_TIMESTAMP_1 + eslot, (uint32)etime ); - - // move to next (for non filled list is move most optimized choice) - if(m_currentBuybackSlot < BUYBACK_SLOT_END-1) - ++m_currentBuybackSlot; - } -} - -Item* Player::GetItemFromBuyBackSlot( uint32 slot ) -{ - sLog.outDebug( "STORAGE: GetItemFromBuyBackSlot slot = %u", slot); - if( slot >= BUYBACK_SLOT_START && slot < BUYBACK_SLOT_END ) - return m_items[slot]; - return NULL; -} - -void Player::RemoveItemFromBuyBackSlot( uint32 slot, bool del ) -{ - sLog.outDebug( "STORAGE: RemoveItemFromBuyBackSlot slot = %u", slot); - if( slot >= BUYBACK_SLOT_START && slot < BUYBACK_SLOT_END ) - { - Item *pItem = m_items[slot]; - if( pItem ) - { - pItem->RemoveFromWorld(); - if(del) pItem->SetState(ITEM_REMOVED, this); - } - - m_items[slot] = NULL; - - uint32 eslot = slot - BUYBACK_SLOT_START; - SetUInt64Value( PLAYER_FIELD_VENDORBUYBACK_SLOT_1 + eslot * 2, 0 ); - SetUInt32Value( PLAYER_FIELD_BUYBACK_PRICE_1 + eslot, 0 ); - SetUInt32Value( PLAYER_FIELD_BUYBACK_TIMESTAMP_1 + eslot, 0 ); - - // if current backslot is filled set to now free slot - if(m_items[m_currentBuybackSlot]) - m_currentBuybackSlot = slot; - } -} - -void Player::SendEquipError( uint8 msg, Item* pItem, Item *pItem2 ) -{ - sLog.outDebug( "WORLD: Sent SMSG_INVENTORY_CHANGE_FAILURE (%u)",msg); - WorldPacket data( SMSG_INVENTORY_CHANGE_FAILURE, (msg == EQUIP_ERR_CANT_EQUIP_LEVEL_I ? 22 : 18) ); - data << uint8(msg); - - if(msg) - { - data << uint64(pItem ? pItem->GetGUID() : 0); - data << uint64(pItem2 ? pItem2->GetGUID() : 0); - data << uint8(0); // not 0 there... - - if(msg == EQUIP_ERR_CANT_EQUIP_LEVEL_I) - { - uint32 level = 0; - - if(pItem) - if(ItemPrototype const* proto = pItem->GetProto()) - level = proto->RequiredLevel; - - data << uint32(level); // new 2.4.0 - } - } - GetSession()->SendPacket(&data); -} - -void Player::SendBuyError( uint8 msg, Creature* pCreature, uint32 item, uint32 param ) -{ - sLog.outDebug( "WORLD: Sent SMSG_BUY_FAILED" ); - WorldPacket data( SMSG_BUY_FAILED, (8+4+4+1) ); - data << uint64(pCreature ? pCreature->GetGUID() : 0); - data << uint32(item); - if( param > 0 ) - data << uint32(param); - data << uint8(msg); - GetSession()->SendPacket(&data); -} - -void Player::SendSellError( uint8 msg, Creature* pCreature, uint64 guid, uint32 param ) -{ - sLog.outDebug( "WORLD: Sent SMSG_SELL_ITEM" ); - WorldPacket data( SMSG_SELL_ITEM,(8+8+(param?4:0)+1)); // last check 2.0.10 - data << uint64(pCreature ? pCreature->GetGUID() : 0); - data << uint64(guid); - if( param > 0 ) - data << uint32(param); - data << uint8(msg); - GetSession()->SendPacket(&data); -} - -void Player::ClearTrade() -{ - tradeGold = 0; - acceptTrade = false; - for(int i = 0; i < TRADE_SLOT_COUNT; i++) - tradeItems[i] = NULL_SLOT; -} - -void Player::TradeCancel(bool sendback) -{ - if(pTrader) - { - // send yellow "Trade cancelled" message to both traders - WorldSession* ws; - ws = GetSession(); - if(sendback) - ws->SendCancelTrade(); - ws = pTrader->GetSession(); - if(!ws->PlayerLogout()) - ws->SendCancelTrade(); - - // cleanup - ClearTrade(); - pTrader->ClearTrade(); - // prevent loss of reference - pTrader->pTrader = NULL; - pTrader = NULL; - } -} - -void Player::UpdateItemDuration(uint32 time, bool realtimeonly) -{ - if(m_itemDuration.empty()) - return; - - sLog.outDebug("Player::UpdateItemDuration(%u,%u)", time,realtimeonly); - - for(ItemDurationList::iterator itr = m_itemDuration.begin();itr != m_itemDuration.end(); ) - { - Item* item = *itr; - ++itr; // current element can be erased in UpdateDuration - - if (realtimeonly && item->GetProto()->Duration < 0 || !realtimeonly) - item->UpdateDuration(this,time); - } -} - -void Player::UpdateEnchantTime(uint32 time) -{ - for(EnchantDurationList::iterator itr = m_enchantDuration.begin(),next;itr != m_enchantDuration.end();itr=next) - { - assert(itr->item); - next=itr; - if(!itr->item->GetEnchantmentId(itr->slot)) - { - next = m_enchantDuration.erase(itr); - } - else if(itr->leftduration <= time) - { - ApplyEnchantment(itr->item,itr->slot,false,false); - itr->item->ClearEnchantment(itr->slot); - next = m_enchantDuration.erase(itr); - } - else if(itr->leftduration > time) - { - itr->leftduration -= time; - ++next; - } - } -} - -void Player::AddEnchantmentDurations(Item *item) -{ - for(int x=0;xGetEnchantmentId(EnchantmentSlot(x))) - continue; - - uint32 duration = item->GetEnchantmentDuration(EnchantmentSlot(x)); - if( duration > 0 ) - AddEnchantmentDuration(item,EnchantmentSlot(x),duration); - } -} - -void Player::RemoveEnchantmentDurations(Item *item) -{ - for(EnchantDurationList::iterator itr = m_enchantDuration.begin();itr != m_enchantDuration.end();) - { - if(itr->item == item) - { - // save duration in item - item->SetEnchantmentDuration(EnchantmentSlot(itr->slot),itr->leftduration); - itr = m_enchantDuration.erase(itr); - } - else - ++itr; - } -} - - -void Player::RemoveAllEnchantments(EnchantmentSlot slot) -{ - // remove enchantments from equipped items first to clean up the m_enchantDuration list - for(EnchantDurationList::iterator itr = m_enchantDuration.begin(),next;itr != m_enchantDuration.end();itr=next) - { - next = itr; - if(itr->slot==slot) - { - if(itr->item && itr->item->GetEnchantmentId(slot)) - { - // remove from stats - ApplyEnchantment(itr->item,slot,false,false); - // remove visual - itr->item->ClearEnchantment(slot); - } - // remove from update list - next = m_enchantDuration.erase(itr); - } - else - ++next; - } - - // remove enchants from inventory items - // NOTE: no need to remove these from stats, since these aren't equipped - // in inventory - for(int i = INVENTORY_SLOT_ITEM_START; i < INVENTORY_SLOT_ITEM_END; i++) - { - Item* pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i ); - if( pItem && pItem->GetEnchantmentId(slot) ) - pItem->ClearEnchantment(slot); - } - - // in inventory bags - for(int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; i++) - { - Bag* pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i ); - if( pBag ) - { - ItemPrototype const *pBagProto = pBag->GetProto(); - if( pBagProto ) - { - for(uint32 j = 0; j < pBagProto->ContainerSlots; j++) - { - Item* pItem = pBag->GetItemByPos(j); - if( pItem && pItem->GetEnchantmentId(slot) ) - pItem->ClearEnchantment(slot); - } - } - } - } -} - -// duration == 0 will remove item enchant -void Player::AddEnchantmentDuration(Item *item,EnchantmentSlot slot,uint32 duration) -{ - if(!item) - return; - - if(slot >= MAX_ENCHANTMENT_SLOT) - return; - - for(EnchantDurationList::iterator itr = m_enchantDuration.begin();itr != m_enchantDuration.end();++itr) - { - if(itr->item == item && itr->slot == slot) - { - itr->item->SetEnchantmentDuration(itr->slot,itr->leftduration); - m_enchantDuration.erase(itr); - break; - } - } - if(item && duration > 0 ) - { - GetSession()->SendItemEnchantTimeUpdate(GetGUID(), item->GetGUID(),slot,uint32(duration/1000)); - m_enchantDuration.push_back(EnchantDuration(item,slot,duration)); - } -} - -void Player::ApplyEnchantment(Item *item,bool apply) -{ - for(uint32 slot = 0; slot < MAX_ENCHANTMENT_SLOT; ++slot) - ApplyEnchantment(item, EnchantmentSlot(slot), apply); -} - -void Player::ApplyEnchantment(Item *item,EnchantmentSlot slot,bool apply, bool apply_dur, bool ignore_condition) -{ - if(!item) - return; - - if(!item->IsEquipped()) - return; - - if(slot >= MAX_ENCHANTMENT_SLOT) - return; - - uint32 enchant_id = item->GetEnchantmentId(slot); - if(!enchant_id) - return; - - SpellItemEnchantmentEntry const *pEnchant = sSpellItemEnchantmentStore.LookupEntry(enchant_id); - if(!pEnchant) - return; - - if(!ignore_condition && pEnchant->EnchantmentCondition && !((Player*)this)->EnchantmentFitsRequirements(pEnchant->EnchantmentCondition, -1)) - return; - - for (int s=0; s<3; s++) - { - uint32 enchant_display_type = pEnchant->type[s]; - uint32 enchant_amount = pEnchant->amount[s]; - uint32 enchant_spell_id = pEnchant->spellid[s]; - - switch(enchant_display_type) - { - case ITEM_ENCHANTMENT_TYPE_NONE: - break; - case ITEM_ENCHANTMENT_TYPE_COMBAT_SPELL: - // processed in Player::CastItemCombatSpell - break; - case ITEM_ENCHANTMENT_TYPE_DAMAGE: - if (item->GetSlot() == EQUIPMENT_SLOT_MAINHAND) - HandleStatModifier(UNIT_MOD_DAMAGE_MAINHAND, TOTAL_VALUE, float(enchant_amount), apply); - else if (item->GetSlot() == EQUIPMENT_SLOT_OFFHAND) - HandleStatModifier(UNIT_MOD_DAMAGE_OFFHAND, TOTAL_VALUE, float(enchant_amount), apply); - else if (item->GetSlot() == EQUIPMENT_SLOT_RANGED) - HandleStatModifier(UNIT_MOD_DAMAGE_RANGED, TOTAL_VALUE, float(enchant_amount), apply); - break; - case ITEM_ENCHANTMENT_TYPE_EQUIP_SPELL: - if(enchant_spell_id) - { - if(apply) - { - int32 basepoints = int32(enchant_amount); - // Random Property Exist - try found basepoints for spell (basepoints depencs from item suffix factor) - if (item->GetItemRandomPropertyId() !=0 && !enchant_amount) - { - ItemRandomSuffixEntry const *item_rand = sItemRandomSuffixStore.LookupEntry(abs(item->GetItemRandomPropertyId())); - if (item_rand) - { - // Search enchant_amount - for (int k=0; k<3; k++) - { - if(item_rand->enchant_id[k] == enchant_id) - { - basepoints = int32((item_rand->prefix[k]*item->GetItemSuffixFactor()) / 10000 ); - break; - } - } - } - } - // Cast custom spell vs all equal basepoints getted from enchant_amount - if (basepoints) - CastCustomSpell(this,enchant_spell_id,&basepoints,&basepoints,&basepoints,true,item); - else - CastSpell(this,enchant_spell_id,true,item); - } - else - RemoveAurasDueToItemSpell(item,enchant_spell_id); - } - break; - case ITEM_ENCHANTMENT_TYPE_RESISTANCE: - if (!enchant_amount) - { - ItemRandomSuffixEntry const *item_rand = sItemRandomSuffixStore.LookupEntry(abs(item->GetItemRandomPropertyId())); - if(item_rand) - { - for (int k=0; k<3; k++) - { - if(item_rand->enchant_id[k] == enchant_id) - { - enchant_amount = uint32((item_rand->prefix[k]*item->GetItemSuffixFactor()) / 10000 ); - break; - } - } - } - } - - HandleStatModifier(UnitMods(UNIT_MOD_RESISTANCE_START + enchant_spell_id), TOTAL_VALUE, float(enchant_amount), apply); - break; - case ITEM_ENCHANTMENT_TYPE_STAT: - { - if (!enchant_amount) - { - ItemRandomSuffixEntry const *item_rand_suffix = sItemRandomSuffixStore.LookupEntry(abs(item->GetItemRandomPropertyId())); - if(item_rand_suffix) - { - for (int k=0; k<3; k++) - { - if(item_rand_suffix->enchant_id[k] == enchant_id) - { - enchant_amount = uint32((item_rand_suffix->prefix[k]*item->GetItemSuffixFactor()) / 10000 ); - break; - } - } - } - } - - sLog.outDebug("Adding %u to stat nb %u",enchant_amount,enchant_spell_id); - switch (enchant_spell_id) - { - case ITEM_MOD_AGILITY: - sLog.outDebug("+ %u AGILITY",enchant_amount); - HandleStatModifier(UNIT_MOD_STAT_AGILITY, TOTAL_VALUE, float(enchant_amount), apply); - ApplyStatBuffMod(STAT_AGILITY, enchant_amount, apply); - break; - case ITEM_MOD_STRENGTH: - sLog.outDebug("+ %u STRENGTH",enchant_amount); - HandleStatModifier(UNIT_MOD_STAT_STRENGTH, TOTAL_VALUE, float(enchant_amount), apply); - ApplyStatBuffMod(STAT_STRENGTH, enchant_amount, apply); - break; - case ITEM_MOD_INTELLECT: - sLog.outDebug("+ %u INTELLECT",enchant_amount); - HandleStatModifier(UNIT_MOD_STAT_INTELLECT, TOTAL_VALUE, float(enchant_amount), apply); - ApplyStatBuffMod(STAT_INTELLECT, enchant_amount, apply); - break; - case ITEM_MOD_SPIRIT: - sLog.outDebug("+ %u SPIRIT",enchant_amount); - HandleStatModifier(UNIT_MOD_STAT_SPIRIT, TOTAL_VALUE, float(enchant_amount), apply); - ApplyStatBuffMod(STAT_SPIRIT, enchant_amount, apply); - break; - case ITEM_MOD_STAMINA: - sLog.outDebug("+ %u STAMINA",enchant_amount); - HandleStatModifier(UNIT_MOD_STAT_STAMINA, TOTAL_VALUE, float(enchant_amount), apply); - ApplyStatBuffMod(STAT_STAMINA, enchant_amount, apply); - break; - case ITEM_MOD_DEFENSE_SKILL_RATING: - ((Player*)this)->ApplyRatingMod(CR_DEFENSE_SKILL, enchant_amount, apply); - sLog.outDebug("+ %u DEFENCE", enchant_amount); - break; - case ITEM_MOD_DODGE_RATING: - ((Player*)this)->ApplyRatingMod(CR_DODGE, enchant_amount, apply); - sLog.outDebug("+ %u DODGE", enchant_amount); - break; - case ITEM_MOD_PARRY_RATING: - ((Player*)this)->ApplyRatingMod(CR_PARRY, enchant_amount, apply); - sLog.outDebug("+ %u PARRY", enchant_amount); - break; - case ITEM_MOD_BLOCK_RATING: - ((Player*)this)->ApplyRatingMod(CR_BLOCK, enchant_amount, apply); - sLog.outDebug("+ %u SHIELD_BLOCK", enchant_amount); - break; - case ITEM_MOD_HIT_MELEE_RATING: - ((Player*)this)->ApplyRatingMod(CR_HIT_MELEE, enchant_amount, apply); - sLog.outDebug("+ %u MELEE_HIT", enchant_amount); - break; - case ITEM_MOD_HIT_RANGED_RATING: - ((Player*)this)->ApplyRatingMod(CR_HIT_RANGED, enchant_amount, apply); - sLog.outDebug("+ %u RANGED_HIT", enchant_amount); - break; - case ITEM_MOD_HIT_SPELL_RATING: - ((Player*)this)->ApplyRatingMod(CR_HIT_SPELL, enchant_amount, apply); - sLog.outDebug("+ %u SPELL_HIT", enchant_amount); - break; - case ITEM_MOD_CRIT_MELEE_RATING: - ((Player*)this)->ApplyRatingMod(CR_CRIT_MELEE, enchant_amount, apply); - sLog.outDebug("+ %u MELEE_CRIT", enchant_amount); - break; - case ITEM_MOD_CRIT_RANGED_RATING: - ((Player*)this)->ApplyRatingMod(CR_CRIT_RANGED, enchant_amount, apply); - sLog.outDebug("+ %u RANGED_CRIT", enchant_amount); - break; - case ITEM_MOD_CRIT_SPELL_RATING: - ((Player*)this)->ApplyRatingMod(CR_CRIT_SPELL, enchant_amount, apply); - sLog.outDebug("+ %u SPELL_CRIT", enchant_amount); - break; -// Values from ITEM_STAT_MELEE_HA_RATING to ITEM_MOD_HASTE_RANGED_RATING are never used -// in Enchantments -// case ITEM_MOD_HIT_TAKEN_MELEE_RATING: -// ((Player*)this)->ApplyRatingMod(CR_HIT_TAKEN_MELEE, enchant_amount, apply); -// break; -// case ITEM_MOD_HIT_TAKEN_RANGED_RATING: -// ((Player*)this)->ApplyRatingMod(CR_HIT_TAKEN_RANGED, enchant_amount, apply); -// break; -// case ITEM_MOD_HIT_TAKEN_SPELL_RATING: -// ((Player*)this)->ApplyRatingMod(CR_HIT_TAKEN_SPELL, enchant_amount, apply); -// break; -// case ITEM_MOD_CRIT_TAKEN_MELEE_RATING: -// ((Player*)this)->ApplyRatingMod(CR_CRIT_TAKEN_MELEE, enchant_amount, apply); -// break; -// case ITEM_MOD_CRIT_TAKEN_RANGED_RATING: -// ((Player*)this)->ApplyRatingMod(CR_CRIT_TAKEN_RANGED, enchant_amount, apply); -// break; -// case ITEM_MOD_CRIT_TAKEN_SPELL_RATING: -// ((Player*)this)->ApplyRatingMod(CR_CRIT_TAKEN_SPELL, enchant_amount, apply); -// break; -// case ITEM_MOD_HASTE_MELEE_RATING: -// ((Player*)this)->ApplyRatingMod(CR_HASTE_MELEE, enchant_amount, apply); -// break; -// case ITEM_MOD_HASTE_RANGED_RATING: -// ((Player*)this)->ApplyRatingMod(CR_HASTE_RANGED, enchant_amount, apply); -// break; - case ITEM_MOD_HASTE_SPELL_RATING: - ((Player*)this)->ApplyRatingMod(CR_HASTE_SPELL, enchant_amount, apply); - break; - case ITEM_MOD_HIT_RATING: - ((Player*)this)->ApplyRatingMod(CR_HIT_MELEE, enchant_amount, apply); - ((Player*)this)->ApplyRatingMod(CR_HIT_RANGED, enchant_amount, apply); - ((Player*)this)->ApplyRatingMod(CR_HIT_SPELL, enchant_amount, apply); - sLog.outDebug("+ %u HIT", enchant_amount); - break; - case ITEM_MOD_CRIT_RATING: - ((Player*)this)->ApplyRatingMod(CR_CRIT_MELEE, enchant_amount, apply); - ((Player*)this)->ApplyRatingMod(CR_CRIT_RANGED, enchant_amount, apply); - ((Player*)this)->ApplyRatingMod(CR_CRIT_SPELL, enchant_amount, apply); - sLog.outDebug("+ %u CRITICAL", enchant_amount); - break; -// Values ITEM_MOD_HIT_TAKEN_RATING and ITEM_MOD_CRIT_TAKEN_RATING are never used in Enchantment -// case ITEM_MOD_HIT_TAKEN_RATING: -// ((Player*)this)->ApplyRatingMod(CR_HIT_TAKEN_MELEE, enchant_amount, apply); -// ((Player*)this)->ApplyRatingMod(CR_HIT_TAKEN_RANGED, enchant_amount, apply); -// ((Player*)this)->ApplyRatingMod(CR_HIT_TAKEN_SPELL, enchant_amount, apply); -// break; -// case ITEM_MOD_CRIT_TAKEN_RATING: -// ((Player*)this)->ApplyRatingMod(CR_CRIT_TAKEN_MELEE, enchant_amount, apply); -// ((Player*)this)->ApplyRatingMod(CR_CRIT_TAKEN_RANGED, enchant_amount, apply); -// ((Player*)this)->ApplyRatingMod(CR_CRIT_TAKEN_SPELL, enchant_amount, apply); -// break; - case ITEM_MOD_RESILIENCE_RATING: - ((Player*)this)->ApplyRatingMod(CR_CRIT_TAKEN_MELEE, enchant_amount, apply); - ((Player*)this)->ApplyRatingMod(CR_CRIT_TAKEN_RANGED, enchant_amount, apply); - ((Player*)this)->ApplyRatingMod(CR_CRIT_TAKEN_SPELL, enchant_amount, apply); - sLog.outDebug("+ %u RESILIENCE", enchant_amount); - break; - case ITEM_MOD_HASTE_RATING: - ((Player*)this)->ApplyRatingMod(CR_HASTE_MELEE, enchant_amount, apply); - ((Player*)this)->ApplyRatingMod(CR_HASTE_RANGED, enchant_amount, apply); - ((Player*)this)->ApplyRatingMod(CR_HASTE_SPELL, enchant_amount, apply); - sLog.outDebug("+ %u HASTE", enchant_amount); - break; - case ITEM_MOD_EXPERTISE_RATING: - ((Player*)this)->ApplyRatingMod(CR_EXPERTISE, enchant_amount, apply); - sLog.outDebug("+ %u EXPERTISE", enchant_amount); - break; - default: - break; - } - break; - } - case ITEM_ENCHANTMENT_TYPE_TOTEM: // Shaman Rockbiter Weapon - { - if(getClass() == CLASS_SHAMAN) - { - float addValue = 0.0f; - if(item->GetSlot() == EQUIPMENT_SLOT_MAINHAND) - { - addValue = float(enchant_amount * item->GetProto()->Delay/1000.0f); - HandleStatModifier(UNIT_MOD_DAMAGE_MAINHAND, TOTAL_VALUE, addValue, apply); - } - else if(item->GetSlot() == EQUIPMENT_SLOT_OFFHAND ) - { - addValue = float(enchant_amount * item->GetProto()->Delay/1000.0f); - HandleStatModifier(UNIT_MOD_DAMAGE_OFFHAND, TOTAL_VALUE, addValue, apply); - } - } - break; - } - default: - sLog.outError("Unknown item enchantment display type: %d",enchant_display_type); - break; - } /*switch(enchant_display_type)*/ - } /*for*/ - - // visualize enchantment at player and equipped items - if(slot < MAX_INSPECTED_ENCHANTMENT_SLOT) - { - int VisibleBase = PLAYER_VISIBLE_ITEM_1_0 + (item->GetSlot() * MAX_VISIBLE_ITEM_OFFSET); - SetUInt32Value(VisibleBase + 1 + slot, apply? item->GetEnchantmentId(slot) : 0); - } - - if(apply_dur) - { - if(apply) - { - // set duration - uint32 duration = item->GetEnchantmentDuration(slot); - if(duration > 0) - AddEnchantmentDuration(item,slot,duration); - } - else - { - // duration == 0 will remove EnchantDuration - AddEnchantmentDuration(item,slot,0); - } - } -} - -void Player::SendEnchantmentDurations() -{ - for(EnchantDurationList::iterator itr = m_enchantDuration.begin();itr != m_enchantDuration.end();++itr) - { - GetSession()->SendItemEnchantTimeUpdate(GetGUID(), itr->item->GetGUID(),itr->slot,uint32(itr->leftduration)/1000); - } -} - -void Player::SendItemDurations() -{ - for(ItemDurationList::iterator itr = m_itemDuration.begin();itr != m_itemDuration.end();++itr) - { - (*itr)->SendTimeUpdate(this); - } -} - -void Player::SendNewItem(Item *item, uint32 count, bool received, bool created, bool broadcast) -{ - if(!item) // prevent crash - return; - - // last check 2.0.10 - WorldPacket data( SMSG_ITEM_PUSH_RESULT, (8+4+4+4+1+4+4+4+4+4) ); - data << GetGUID(); // player GUID - data << uint32(received); // 0=looted, 1=from npc - data << uint32(created); // 0=received, 1=created - data << uint32(1); // always 0x01 (probably meant to be count of listed items) - data << (uint8)item->GetBagSlot(); // bagslot - // item slot, but when added to stack: 0xFFFFFFFF - data << (uint32) ((item->GetCount()==count) ? item->GetSlot() : -1); - data << uint32(item->GetEntry()); // item id - data << uint32(item->GetItemSuffixFactor()); // SuffixFactor - data << uint32(item->GetItemRandomPropertyId()); // random item property id - data << uint32(count); // count of items - data << GetItemCount(item->GetEntry()); // count of items in inventory - - if (broadcast && GetGroup()) - GetGroup()->BroadcastPacket(&data); - else - GetSession()->SendPacket(&data); -} - -/*********************************************************/ -/*** QUEST SYSTEM ***/ -/*********************************************************/ - -void Player::PrepareQuestMenu( uint64 guid ) -{ - Object *pObject; - QuestRelations* pObjectQR; - QuestRelations* pObjectQIR; - Creature *pCreature = ObjectAccessor::GetCreature(*this, guid); - if( pCreature ) - { - pObject = (Object*)pCreature; - pObjectQR = &objmgr.mCreatureQuestRelations; - pObjectQIR = &objmgr.mCreatureQuestInvolvedRelations; - } - else - { - GameObject *pGameObject = ObjectAccessor::GetGameObject(*this, guid); - if( pGameObject ) - { - pObject = (Object*)pGameObject; - pObjectQR = &objmgr.mGOQuestRelations; - pObjectQIR = &objmgr.mGOQuestInvolvedRelations; - } - else - return; - } - - QuestMenu *qm = PlayerTalkClass->GetQuestMenu(); - qm->ClearMenu(); - - for(QuestRelations::const_iterator i = pObjectQIR->lower_bound(pObject->GetEntry()); i != pObjectQIR->upper_bound(pObject->GetEntry()); ++i) - { - uint32 quest_id = i->second; - QuestStatus status = GetQuestStatus( quest_id ); - if ( status == QUEST_STATUS_COMPLETE && !GetQuestRewardStatus( quest_id ) ) - qm->AddMenuItem(quest_id, DIALOG_STATUS_REWARD_REP); - else if ( status == QUEST_STATUS_INCOMPLETE ) - qm->AddMenuItem(quest_id, DIALOG_STATUS_INCOMPLETE); - else if (status == QUEST_STATUS_AVAILABLE ) - qm->AddMenuItem(quest_id, DIALOG_STATUS_CHAT); - } - - for(QuestRelations::const_iterator i = pObjectQR->lower_bound(pObject->GetEntry()); i != pObjectQR->upper_bound(pObject->GetEntry()); ++i) - { - uint32 quest_id = i->second; - Quest const* pQuest = objmgr.GetQuestTemplate(quest_id); - if(!pQuest) continue; - - QuestStatus status = GetQuestStatus( quest_id ); - - if (pQuest->IsAutoComplete() && CanTakeQuest(pQuest, false)) - qm->AddMenuItem(quest_id, DIALOG_STATUS_REWARD_REP); - else if ( status == QUEST_STATUS_NONE && CanTakeQuest( pQuest, false ) ) - qm->AddMenuItem(quest_id, DIALOG_STATUS_AVAILABLE); - } -} - -void Player::SendPreparedQuest( uint64 guid ) -{ - QuestMenu* pQuestMenu = PlayerTalkClass->GetQuestMenu(); - if( !pQuestMenu || pQuestMenu->MenuItemCount() < 1 ) - return; - - uint32 status = pQuestMenu->GetItem(0).m_qIcon; - if ( pQuestMenu->MenuItemCount() == 1 ) - { - // Auto open -- maybe also should verify there is no greeting - uint32 quest_id = pQuestMenu->GetItem(0).m_qId; - Quest const* pQuest = objmgr.GetQuestTemplate(quest_id); - if ( pQuest ) - { - if( status == DIALOG_STATUS_REWARD_REP && !GetQuestRewardStatus( quest_id ) ) - PlayerTalkClass->SendQuestGiverRequestItems( pQuest, guid, CanRewardQuest(pQuest,false), true ); - else if( status == DIALOG_STATUS_INCOMPLETE ) - PlayerTalkClass->SendQuestGiverRequestItems( pQuest, guid, false, true ); - // Send completable on repeatable quest if player don't have quest - else if( pQuest->IsRepeatable() ) - PlayerTalkClass->SendQuestGiverRequestItems( pQuest, guid, CanCompleteRepeatableQuest(pQuest), true ); - else - PlayerTalkClass->SendQuestGiverQuestDetails( pQuest, guid, true ); - } - } - else - { - QEmote qe; - qe._Delay = 0; - qe._Emote = 0; - std::string title = ""; - Creature *pCreature = ObjectAccessor::GetCreature(*this, guid); - if( pCreature ) - { - uint32 textid = pCreature->GetNpcTextId(); - GossipText * gossiptext = objmgr.GetGossipText(textid); - if( !gossiptext ) - { - qe._Delay = 0; //TEXTEMOTE_MESSAGE; //zyg: player emote - qe._Emote = 0; //TEXTEMOTE_HELLO; //zyg: NPC emote - title = ""; - } - else - { - qe = gossiptext->Options[0].Emotes[0]; - - if(!gossiptext->Options[0].Text_0.empty()) - { - title = gossiptext->Options[0].Text_0; - - int loc_idx = GetSession()->GetSessionDbLocaleIndex(); - if (loc_idx >= 0) - { - NpcTextLocale const *nl = objmgr.GetNpcTextLocale(textid); - if (nl) - { - if (nl->Text_0[0].size() > loc_idx && !nl->Text_0[0][loc_idx].empty()) - title = nl->Text_0[0][loc_idx]; - } - } - } - else - { - title = gossiptext->Options[0].Text_1; - - int loc_idx = GetSession()->GetSessionDbLocaleIndex(); - if (loc_idx >= 0) - { - NpcTextLocale const *nl = objmgr.GetNpcTextLocale(textid); - if (nl) - { - if (nl->Text_1[0].size() > loc_idx && !nl->Text_1[0][loc_idx].empty()) - title = nl->Text_1[0][loc_idx]; - } - } - } - } - } - PlayerTalkClass->SendQuestGiverQuestList( qe, title, guid ); - } -} - -bool Player::IsActiveQuest( uint32 quest_id ) const -{ - QuestStatusMap::const_iterator itr = mQuestStatus.find(quest_id); - - return itr != mQuestStatus.end() && itr->second.m_status != QUEST_STATUS_NONE; -} - -Quest const * Player::GetNextQuest( uint64 guid, Quest const *pQuest ) -{ - Object *pObject; - QuestRelations* pObjectQR; - QuestRelations* pObjectQIR; - - Creature *pCreature = ObjectAccessor::GetCreature(*this, guid); - if( pCreature ) - { - pObject = (Object*)pCreature; - pObjectQR = &objmgr.mCreatureQuestRelations; - pObjectQIR = &objmgr.mCreatureQuestInvolvedRelations; - } - else - { - GameObject *pGameObject = ObjectAccessor::GetGameObject(*this, guid); - if( pGameObject ) - { - pObject = (Object*)pGameObject; - pObjectQR = &objmgr.mGOQuestRelations; - pObjectQIR = &objmgr.mGOQuestInvolvedRelations; - } - else - return NULL; - } - - uint32 nextQuestID = pQuest->GetNextQuestInChain(); - for(QuestRelations::const_iterator itr = pObjectQR->lower_bound(pObject->GetEntry()); itr != pObjectQR->upper_bound(pObject->GetEntry()); ++itr) - { - if (itr->second == nextQuestID) - return objmgr.GetQuestTemplate(nextQuestID); - } - - return NULL; -} - -bool Player::CanSeeStartQuest( Quest const *pQuest ) -{ - if( SatisfyQuestRace( pQuest, false ) && SatisfyQuestSkillOrClass( pQuest, false ) && - SatisfyQuestExclusiveGroup( pQuest, false ) && SatisfyQuestReputation( pQuest, false ) && - SatisfyQuestPreviousQuest( pQuest, false ) && SatisfyQuestNextChain( pQuest, false ) && - SatisfyQuestPrevChain( pQuest, false ) && SatisfyQuestDay( pQuest, false ) ) - { - return getLevel() + sWorld.getConfig(CONFIG_QUEST_HIGH_LEVEL_HIDE_DIFF) >= pQuest->GetMinLevel(); - } - - return false; -} - -bool Player::CanTakeQuest( Quest const *pQuest, bool msg ) -{ - return SatisfyQuestStatus( pQuest, msg ) && SatisfyQuestExclusiveGroup( pQuest, msg ) - && SatisfyQuestRace( pQuest, msg ) && SatisfyQuestLevel( pQuest, msg ) - && SatisfyQuestSkillOrClass( pQuest, msg ) && SatisfyQuestReputation( pQuest, msg ) - && SatisfyQuestPreviousQuest( pQuest, msg ) && SatisfyQuestTimed( pQuest, msg ) - && SatisfyQuestNextChain( pQuest, msg ) && SatisfyQuestPrevChain( pQuest, msg ) - && SatisfyQuestDay( pQuest, msg ); -} - -bool Player::CanAddQuest( Quest const *pQuest, bool msg ) -{ - if( !SatisfyQuestLog( msg ) ) - return false; - - uint32 srcitem = pQuest->GetSrcItemId(); - if( srcitem > 0 ) - { - uint32 count = pQuest->GetSrcItemCount(); - ItemPosCountVec dest; - uint8 msg = CanStoreNewItem( NULL_BAG, NULL_SLOT, dest, srcitem, count ); - - // player already have max number (in most case 1) source item, no additional item needed and quest can be added. - if( msg == EQUIP_ERR_CANT_CARRY_MORE_OF_THIS ) - return true; - else if( msg != EQUIP_ERR_OK ) - { - SendEquipError( msg, NULL, NULL ); - return false; - } - } - return true; -} - -bool Player::CanCompleteQuest( uint32 quest_id ) -{ - if( quest_id ) - { - QuestStatusData& q_status = mQuestStatus[quest_id]; - if( q_status.m_status == QUEST_STATUS_COMPLETE ) - return false; // not allow re-complete quest - - Quest const* qInfo = objmgr.GetQuestTemplate(quest_id); - - if(!qInfo) - return false; - - // auto complete quest - if (qInfo->IsAutoComplete() && CanTakeQuest(qInfo, false)) - return true; - - if ( q_status.m_status == QUEST_STATUS_INCOMPLETE ) - { - - if ( qInfo->HasFlag( QUEST_MANGOS_FLAGS_DELIVER ) ) - { - for(int i = 0; i < QUEST_OBJECTIVES_COUNT; i++) - { - if( qInfo->ReqItemCount[i]!= 0 && q_status.m_itemcount[i] < qInfo->ReqItemCount[i] ) - return false; - } - } - - if ( qInfo->HasFlag(QUEST_MANGOS_FLAGS_KILL_OR_CAST | QUEST_MANGOS_FLAGS_SPEAKTO) ) - { - for(int i = 0; i < QUEST_OBJECTIVES_COUNT; i++) - { - if( qInfo->ReqCreatureOrGOId[i] == 0 ) - continue; - - if( qInfo->ReqCreatureOrGOCount[i] != 0 && q_status.m_creatureOrGOcount[i] < qInfo->ReqCreatureOrGOCount[i] ) - return false; - } - } - - if ( qInfo->HasFlag( QUEST_MANGOS_FLAGS_EXPLORATION_OR_EVENT ) && !q_status.m_explored ) - return false; - - if ( qInfo->HasFlag( QUEST_MANGOS_FLAGS_TIMED ) && q_status.m_timer == 0 ) - return false; - - if ( qInfo->GetRewOrReqMoney() < 0 ) - { - if ( GetMoney() < uint32(-qInfo->GetRewOrReqMoney()) ) - return false; - } - - uint32 repFacId = qInfo->GetRepObjectiveFaction(); - if ( repFacId && GetReputation(repFacId) < qInfo->GetRepObjectiveValue() ) - return false; - - return true; - } - } - return false; -} - -bool Player::CanCompleteRepeatableQuest( Quest const *pQuest ) -{ - // Solve problem that player don't have the quest and try complete it. - // if repeatable she must be able to complete event if player don't have it. - // Seem that all repeatable quest are DELIVER Flag so, no need to add more. - if( !CanTakeQuest(pQuest, false) ) - return false; - - if (pQuest->HasFlag( QUEST_MANGOS_FLAGS_DELIVER) ) - for(int i = 0; i < QUEST_OBJECTIVES_COUNT; i++) - if( pQuest->ReqItemId[i] && pQuest->ReqItemCount[i] && !HasItemCount(pQuest->ReqItemId[i],pQuest->ReqItemCount[i]) ) - return false; - - if( !CanRewardQuest(pQuest, false) ) - return false; - - return true; -} - -bool Player::CanRewardQuest( Quest const *pQuest, bool msg ) -{ - // not auto complete quest and not completed quest (only cheating case, then ignore without message) - if(!pQuest->IsAutoComplete() && GetQuestStatus(pQuest->GetQuestId()) != QUEST_STATUS_COMPLETE) - return false; - - // daily quest can't be rewarded (10 daily quest already completed) - if(!SatisfyQuestDay(pQuest,true)) - return false; - - // rewarded and not repeatable quest (only cheating case, then ignore without message) - if(GetQuestRewardStatus(pQuest->GetQuestId())) - return false; - - // prevent receive reward with quest items in bank - if ( pQuest->HasFlag( QUEST_MANGOS_FLAGS_DELIVER ) ) - { - for(int i = 0; i < QUEST_OBJECTIVES_COUNT; i++) - { - if( pQuest->ReqItemCount[i]!= 0 && - GetItemCount(pQuest->ReqItemId[i]) < pQuest->ReqItemCount[i] ) - { - if(msg) - SendEquipError( EQUIP_ERR_ITEM_NOT_FOUND, NULL, NULL ); - return false; - } - } - } - - // prevent receive reward with low money and GetRewOrReqMoney() < 0 - if(pQuest->GetRewOrReqMoney() < 0 && GetMoney() < uint32(-pQuest->GetRewOrReqMoney()) ) - return false; - - return true; -} - -bool Player::CanRewardQuest( Quest const *pQuest, uint32 reward, bool msg ) -{ - // prevent receive reward with quest items in bank or for not completed quest - if(!CanRewardQuest(pQuest,msg)) - return false; - - if ( pQuest->GetRewChoiceItemsCount() > 0 ) - { - if( pQuest->RewChoiceItemId[reward] ) - { - ItemPosCountVec dest; - uint8 res = CanStoreNewItem( NULL_BAG, NULL_SLOT, dest, pQuest->RewChoiceItemId[reward], pQuest->RewChoiceItemCount[reward] ); - if( res != EQUIP_ERR_OK ) - { - SendEquipError( res, NULL, NULL ); - return false; - } - } - } - - if ( pQuest->GetRewItemsCount() > 0 ) - { - for (uint32 i = 0; i < pQuest->GetRewItemsCount(); ++i) - { - if( pQuest->RewItemId[i] ) - { - ItemPosCountVec dest; - uint8 res = CanStoreNewItem( NULL_BAG, NULL_SLOT, dest, pQuest->RewItemId[i], pQuest->RewItemCount[i] ); - if( res != EQUIP_ERR_OK ) - { - SendEquipError( res, NULL, NULL ); - return false; - } - } - } - } - - return true; -} - -void Player::AddQuest( Quest const *pQuest, Object *questGiver ) -{ - uint16 log_slot = FindQuestSlot( 0 ); - assert(log_slot < MAX_QUEST_LOG_SIZE); - - uint32 quest_id = pQuest->GetQuestId(); - - // if not exist then created with set uState==NEW and rewarded=false - QuestStatusData& questStatusData = mQuestStatus[quest_id]; - if (questStatusData.uState != QUEST_NEW) - questStatusData.uState = QUEST_CHANGED; - - // check for repeatable quests status reset - questStatusData.m_status = QUEST_STATUS_INCOMPLETE; - questStatusData.m_explored = false; - - if ( pQuest->HasFlag( QUEST_MANGOS_FLAGS_DELIVER ) ) - { - for(int i = 0; i < QUEST_OBJECTIVES_COUNT; i++) - questStatusData.m_itemcount[i] = 0; - } - - if ( pQuest->HasFlag(QUEST_MANGOS_FLAGS_KILL_OR_CAST | QUEST_MANGOS_FLAGS_SPEAKTO) ) - { - for(int i = 0; i < QUEST_OBJECTIVES_COUNT; i++) - questStatusData.m_creatureOrGOcount[i] = 0; - } - - GiveQuestSourceItem( pQuest ); - AdjustQuestReqItemCount( pQuest ); - - if( pQuest->GetRepObjectiveFaction() ) - SetFactionVisibleForFactionId(pQuest->GetRepObjectiveFaction()); - - uint32 qtime = 0; - if( pQuest->HasFlag( QUEST_MANGOS_FLAGS_TIMED ) ) - { - uint32 limittime = pQuest->GetLimitTime(); - - // shared timed quest - if(questGiver && questGiver->GetTypeId()==TYPEID_PLAYER) - limittime = ((Player*)questGiver)->getQuestStatusMap()[quest_id].m_timer / 1000; - - AddTimedQuest( quest_id ); - questStatusData.m_timer = limittime * 1000; - qtime = static_cast(time(NULL)) + limittime; - } - else - questStatusData.m_timer = 0; - - SetQuestSlot(log_slot, quest_id, qtime); - - //starting initial quest script - if(questGiver && pQuest->GetQuestStartScript()!=0) - sWorld.ScriptsStart(sQuestStartScripts, pQuest->GetQuestStartScript(), questGiver, this); - - UpdateForQuestsGO(); -} - -void Player::CompleteQuest( uint32 quest_id ) -{ - if( quest_id ) - { - SetQuestStatus( quest_id, QUEST_STATUS_COMPLETE ); - - uint16 log_slot = FindQuestSlot( quest_id ); - if( log_slot < MAX_QUEST_LOG_SIZE) - SetQuestSlotState(log_slot,QUEST_STATE_COMPLETE); - - if(Quest const* qInfo = objmgr.GetQuestTemplate(quest_id)) - { - if( qInfo->HasFlag(QUEST_FLAGS_AUTO_REWARDED) ) - RewardQuest(qInfo,0,this,false); - else - SendQuestComplete( quest_id ); - } - } -} - -void Player::IncompleteQuest( uint32 quest_id ) -{ - if( quest_id ) - { - SetQuestStatus( quest_id, QUEST_STATUS_INCOMPLETE ); - - uint16 log_slot = FindQuestSlot( quest_id ); - if( log_slot < MAX_QUEST_LOG_SIZE) - RemoveQuestSlotState(log_slot,QUEST_STATE_COMPLETE); - } -} - -void Player::RewardQuest( Quest const *pQuest, uint32 reward, Object* questGiver, bool announce ) -{ - uint32 quest_id = pQuest->GetQuestId(); - - for (int i = 0; i < QUEST_OBJECTIVES_COUNT; i++ ) - { - if ( pQuest->ReqItemId[i] ) - DestroyItemCount( pQuest->ReqItemId[i], pQuest->ReqItemCount[i], true); - } - - //if( qInfo->HasSpecialFlag( QUEST_FLAGS_TIMED ) ) - // SetTimedQuest( 0 ); - m_timedquests.erase(pQuest->GetQuestId()); - - if ( pQuest->GetRewChoiceItemsCount() > 0 ) - { - if( pQuest->RewChoiceItemId[reward] ) - { - ItemPosCountVec dest; - if( CanStoreNewItem( NULL_BAG, NULL_SLOT, dest, pQuest->RewChoiceItemId[reward], pQuest->RewChoiceItemCount[reward] ) == EQUIP_ERR_OK ) - { - Item* item = StoreNewItem( dest, pQuest->RewChoiceItemId[reward], true); - SendNewItem(item, pQuest->RewChoiceItemCount[reward], true, false); - } - } - } - - if ( pQuest->GetRewItemsCount() > 0 ) - { - for (uint32 i=0; i < pQuest->GetRewItemsCount(); ++i) - { - if( pQuest->RewItemId[i] ) - { - ItemPosCountVec dest; - if( CanStoreNewItem( NULL_BAG, NULL_SLOT, dest, pQuest->RewItemId[i], pQuest->RewItemCount[i] ) == EQUIP_ERR_OK ) - { - Item* item = StoreNewItem( dest, pQuest->RewItemId[i], true); - SendNewItem(item, pQuest->RewItemCount[i], true, false); - } - } - } - } - - RewardReputation( pQuest ); - - if( pQuest->GetRewSpellCast() > 0 ) - CastSpell( this, pQuest->GetRewSpellCast(), true); - else if( pQuest->GetRewSpell() > 0) - CastSpell( this, pQuest->GetRewSpell(), true); - - uint16 log_slot = FindQuestSlot( quest_id ); - if( log_slot < MAX_QUEST_LOG_SIZE) - SetQuestSlot(log_slot,0); - - QuestStatusData& q_status = mQuestStatus[quest_id]; - - // Not give XP in case already completed once repeatable quest - uint32 XP = q_status.m_rewarded ? 0 : uint32(pQuest->XPValue( this )*sWorld.getRate(RATE_XP_QUEST)); - - if ( getLevel() < sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL) ) - GiveXP( XP , NULL ); - else - ModifyMoney( int32(pQuest->GetRewMoneyMaxLevel() * sWorld.getRate(RATE_DROP_MONEY)) ); - - // Give player extra money if GetRewOrReqMoney > 0 and get ReqMoney if negative - ModifyMoney( pQuest->GetRewOrReqMoney() ); - - // title reward - if(pQuest->GetCharTitleId()) - { - if(CharTitlesEntry const* titleEntry = sCharTitlesStore.LookupEntry(pQuest->GetCharTitleId())) - SetFlag64(PLAYER__FIELD_KNOWN_TITLES, (uint64(1) << titleEntry->bit_index)); - } - - // Send reward mail - if(pQuest->GetRewMailTemplateId()) - { - MailMessageType mailType; - uint32 senderGuidOrEntry; - switch(questGiver->GetTypeId()) - { - case TYPEID_UNIT: - mailType = MAIL_CREATURE; - senderGuidOrEntry = questGiver->GetEntry(); - break; - case TYPEID_GAMEOBJECT: - mailType = MAIL_GAMEOBJECT; - senderGuidOrEntry = questGiver->GetEntry(); - break; - case TYPEID_ITEM: - mailType = MAIL_ITEM; - senderGuidOrEntry = questGiver->GetEntry(); - break; - case TYPEID_PLAYER: - mailType = MAIL_NORMAL; - senderGuidOrEntry = questGiver->GetGUIDLow(); - break; - default: - mailType = MAIL_NORMAL; - senderGuidOrEntry = GetGUIDLow(); - break; - } - - Loot questMailLoot; - - questMailLoot.FillLoot(pQuest->GetQuestId(), LootTemplates_QuestMail, this); - - // fill mail - MailItemsInfo mi; // item list preparing - - for(size_t i = 0; mi.size() < MAX_MAIL_ITEMS && i < questMailLoot.items.size(); ++i) - { - if(LootItem* lootitem = questMailLoot.LootItemInSlot(i,this)) - { - if(Item* item = Item::CreateItem(lootitem->itemid,lootitem->count,this)) - { - item->SaveToDB(); // save for prevent lost at next mail load, if send fail then item will deleted - mi.AddItem(item->GetGUIDLow(), item->GetEntry(), item); - } - } - } - - for(size_t i = 0; mi.size() < MAX_MAIL_ITEMS && i < questMailLoot.quest_items.size(); ++i) - { - if(LootItem* lootitem = questMailLoot.LootItemInSlot(i+questMailLoot.items.size(),this)) - { - if(Item* item = Item::CreateItem(lootitem->itemid,lootitem->count,this)) - { - item->SaveToDB(); // save for prevent lost at next mail load, if send fail then item will deleted - mi.AddItem(item->GetGUIDLow(), item->GetEntry(), item); - } - } - } - - WorldSession::SendMailTo(this, mailType, MAIL_STATIONERY_NORMAL, senderGuidOrEntry, GetGUIDLow(), "", 0, &mi, 0, 0, MAIL_CHECK_MASK_NONE,pQuest->GetRewMailDelaySecs(),pQuest->GetRewMailTemplateId()); - } - - if(pQuest->IsDaily()) - SetDailyQuestStatus(quest_id); - - if ( !pQuest->IsRepeatable() ) - SetQuestStatus(quest_id, QUEST_STATUS_COMPLETE); - else - SetQuestStatus(quest_id, QUEST_STATUS_NONE); - - q_status.m_rewarded = true; - - if(announce) - SendQuestReward( pQuest, XP, questGiver ); - - if (q_status.uState != QUEST_NEW) q_status.uState = QUEST_CHANGED; -} - -void Player::FailQuest( uint32 quest_id ) -{ - if( quest_id ) - { - IncompleteQuest( quest_id ); - - uint16 log_slot = FindQuestSlot( quest_id ); - if( log_slot < MAX_QUEST_LOG_SIZE) - { - SetQuestSlotTimer(log_slot, 1 ); - SetQuestSlotState(log_slot,QUEST_STATE_FAIL); - } - SendQuestFailed( quest_id ); - } -} - -void Player::FailTimedQuest( uint32 quest_id ) -{ - if( quest_id ) - { - QuestStatusData& q_status = mQuestStatus[quest_id]; - - if (q_status.uState != QUEST_NEW) q_status.uState = QUEST_CHANGED; - q_status.m_timer = 0; - - IncompleteQuest( quest_id ); - - uint16 log_slot = FindQuestSlot( quest_id ); - if( log_slot < MAX_QUEST_LOG_SIZE) - { - SetQuestSlotTimer(log_slot, 1 ); - SetQuestSlotState(log_slot,QUEST_STATE_FAIL); - } - SendQuestTimerFailed( quest_id ); - } -} - -bool Player::SatisfyQuestSkillOrClass( Quest const* qInfo, bool msg ) -{ - int32 zoneOrSort = qInfo->GetZoneOrSort(); - int32 skillOrClass = qInfo->GetSkillOrClass(); - - // skip zone zoneOrSort and 0 case skillOrClass - if( zoneOrSort >= 0 && skillOrClass == 0 ) - return true; - - int32 questSort = -zoneOrSort; - uint8 reqSortClass = ClassByQuestSort(questSort); - - // check class sort cases in zoneOrSort - if( reqSortClass != 0 && getClass() != reqSortClass) - { - if( msg ) - SendCanTakeQuestResponse( INVALIDREASON_DONT_HAVE_REQ ); - return false; - } - - // check class - if( skillOrClass < 0 ) - { - uint8 reqClass = -int32(skillOrClass); - if(getClass() != reqClass) - { - if( msg ) - SendCanTakeQuestResponse( INVALIDREASON_DONT_HAVE_REQ ); - return false; - } - } - // check skill - else if( skillOrClass > 0 ) - { - uint32 reqSkill = skillOrClass; - if( GetSkillValue( reqSkill ) < qInfo->GetRequiredSkillValue() ) - { - if( msg ) - SendCanTakeQuestResponse( INVALIDREASON_DONT_HAVE_REQ ); - return false; - } - } - - return true; -} - -bool Player::SatisfyQuestLevel( Quest const* qInfo, bool msg ) -{ - if( getLevel() < qInfo->GetMinLevel() ) - { - if( msg ) - SendCanTakeQuestResponse( INVALIDREASON_DONT_HAVE_REQ ); - return false; - } - return true; -} - -bool Player::SatisfyQuestLog( bool msg ) -{ - // exist free slot - if( FindQuestSlot(0) < MAX_QUEST_LOG_SIZE ) - return true; - - if( msg ) - { - WorldPacket data( SMSG_QUESTLOG_FULL, 0 ); - GetSession()->SendPacket( &data ); - sLog.outDebug( "WORLD: Sent QUEST_LOG_FULL_MESSAGE" ); - } - return false; -} - -bool Player::SatisfyQuestPreviousQuest( Quest const* qInfo, bool msg ) -{ - // No previous quest (might be first quest in a series) - if( qInfo->prevQuests.empty()) - return true; - - for(Quest::PrevQuests::const_iterator iter = qInfo->prevQuests.begin(); iter != qInfo->prevQuests.end(); ++iter ) - { - uint32 prevId = abs(*iter); - - QuestStatusMap::iterator i_prevstatus = mQuestStatus.find( prevId ); - Quest const* qPrevInfo = objmgr.GetQuestTemplate(prevId); - - if( qPrevInfo && i_prevstatus != mQuestStatus.end() ) - { - // If any of the positive previous quests completed, return true - if( *iter > 0 && i_prevstatus->second.m_rewarded ) - { - // skip one-from-all exclusive group - if(qPrevInfo->GetExclusiveGroup() >= 0) - return true; - - // each-from-all exclusive group ( < 0) - // can be start if only all quests in prev quest exclusive group complited and rewarded - ObjectMgr::ExclusiveQuestGroups::iterator iter = objmgr.mExclusiveQuestGroups.lower_bound(qPrevInfo->GetExclusiveGroup()); - ObjectMgr::ExclusiveQuestGroups::iterator end = objmgr.mExclusiveQuestGroups.upper_bound(qPrevInfo->GetExclusiveGroup()); - - assert(iter!=end); // always must be found if qPrevInfo->ExclusiveGroup != 0 - - for(; iter != end; ++iter) - { - uint32 exclude_Id = iter->second; - - // skip checked quest id, only state of other quests in group is interesting - if(exclude_Id == prevId) - continue; - - QuestStatusMap::iterator i_exstatus = mQuestStatus.find( exclude_Id ); - - // alternative quest from group also must be completed and rewarded(reported) - if( i_exstatus == mQuestStatus.end() || !i_exstatus->second.m_rewarded ) - { - if( msg ) - SendCanTakeQuestResponse( INVALIDREASON_DONT_HAVE_REQ ); - return false; - } - } - return true; - } - // If any of the negative previous quests active, return true - if( *iter < 0 && (i_prevstatus->second.m_status == QUEST_STATUS_INCOMPLETE - || (i_prevstatus->second.m_status == QUEST_STATUS_COMPLETE && !GetQuestRewardStatus(prevId)))) - { - // skip one-from-all exclusive group - if(qPrevInfo->GetExclusiveGroup() >= 0) - return true; - - // each-from-all exclusive group ( < 0) - // can be start if only all quests in prev quest exclusive group active - ObjectMgr::ExclusiveQuestGroups::iterator iter = objmgr.mExclusiveQuestGroups.lower_bound(qPrevInfo->GetExclusiveGroup()); - ObjectMgr::ExclusiveQuestGroups::iterator end = objmgr.mExclusiveQuestGroups.upper_bound(qPrevInfo->GetExclusiveGroup()); - - assert(iter!=end); // always must be found if qPrevInfo->ExclusiveGroup != 0 - - for(; iter != end; ++iter) - { - uint32 exclude_Id = iter->second; - - // skip checked quest id, only state of other quests in group is interesting - if(exclude_Id == prevId) - continue; - - QuestStatusMap::iterator i_exstatus = mQuestStatus.find( exclude_Id ); - - // alternative quest from group also must be active - if( i_exstatus == mQuestStatus.end() || - i_exstatus->second.m_status != QUEST_STATUS_INCOMPLETE && - (i_prevstatus->second.m_status != QUEST_STATUS_COMPLETE || GetQuestRewardStatus(prevId)) ) - { - if( msg ) - SendCanTakeQuestResponse( INVALIDREASON_DONT_HAVE_REQ ); - return false; - } - } - return true; - } - } - } - - // Has only positive prev. quests in non-rewarded state - // and negative prev. quests in non-active state - if( msg ) - SendCanTakeQuestResponse( INVALIDREASON_DONT_HAVE_REQ ); - - return false; -} - -bool Player::SatisfyQuestRace( Quest const* qInfo, bool msg ) -{ - uint32 reqraces = qInfo->GetRequiredRaces(); - if ( reqraces == 0 ) - return true; - if( (reqraces & getRaceMask()) == 0 ) - { - if( msg ) - SendCanTakeQuestResponse( INVALIDREASON_QUEST_FAILED_WRONG_RACE ); - return false; - } - return true; -} - -bool Player::SatisfyQuestReputation( Quest const* qInfo, bool msg ) -{ - uint32 fIdMin = qInfo->GetRequiredMinRepFaction(); //Min required rep - if(fIdMin && GetReputation(fIdMin) < qInfo->GetRequiredMinRepValue()) - { - if( msg ) - SendCanTakeQuestResponse( INVALIDREASON_DONT_HAVE_REQ ); - return false; - } - - uint32 fIdMax = qInfo->GetRequiredMaxRepFaction(); //Max required rep - if(fIdMax && GetReputation(fIdMax) >= qInfo->GetRequiredMaxRepValue()) - { - if( msg ) - SendCanTakeQuestResponse( INVALIDREASON_DONT_HAVE_REQ ); - return false; - } - - return true; -} - -bool Player::SatisfyQuestStatus( Quest const* qInfo, bool msg ) -{ - QuestStatusMap::iterator itr = mQuestStatus.find( qInfo->GetQuestId() ); - if ( itr != mQuestStatus.end() && itr->second.m_status != QUEST_STATUS_NONE ) - { - if( msg ) - SendCanTakeQuestResponse( INVALIDREASON_QUEST_ALREADY_ON ); - return false; - } - return true; -} - -bool Player::SatisfyQuestTimed( Quest const* qInfo, bool msg ) -{ - if ( (find(m_timedquests.begin(), m_timedquests.end(), qInfo->GetQuestId()) != m_timedquests.end()) && qInfo->HasFlag(QUEST_MANGOS_FLAGS_TIMED) ) - { - if( msg ) - SendCanTakeQuestResponse( INVALIDREASON_QUEST_ONLY_ONE_TIMED ); - return false; - } - return true; -} - -bool Player::SatisfyQuestExclusiveGroup( Quest const* qInfo, bool msg ) -{ - // non positive exclusive group, if > 0 then can be start if any other quest in exclusive group already started/completed - if(qInfo->GetExclusiveGroup() <= 0) - return true; - - ObjectMgr::ExclusiveQuestGroups::iterator iter = objmgr.mExclusiveQuestGroups.lower_bound(qInfo->GetExclusiveGroup()); - ObjectMgr::ExclusiveQuestGroups::iterator end = objmgr.mExclusiveQuestGroups.upper_bound(qInfo->GetExclusiveGroup()); - - assert(iter!=end); // always must be found if qInfo->ExclusiveGroup != 0 - - for(; iter != end; ++iter) - { - uint32 exclude_Id = iter->second; - - // skip checked quest id, only state of other quests in group is interesting - if(exclude_Id == qInfo->GetQuestId()) - continue; - - QuestStatusMap::iterator i_exstatus = mQuestStatus.find( exclude_Id ); - - // alternative quest already started or completed - if( i_exstatus != mQuestStatus.end() - && (i_exstatus->second.m_status == QUEST_STATUS_COMPLETE || i_exstatus->second.m_status == QUEST_STATUS_INCOMPLETE) ) - { - if( msg ) - SendCanTakeQuestResponse( INVALIDREASON_DONT_HAVE_REQ ); - return false; - } - } - return true; -} - -bool Player::SatisfyQuestNextChain( Quest const* qInfo, bool msg ) -{ - if(!qInfo->GetNextQuestInChain()) - return true; - - // next quest in chain already started or completed - QuestStatusMap::iterator itr = mQuestStatus.find( qInfo->GetNextQuestInChain() ); - if( itr != mQuestStatus.end() - && (itr->second.m_status == QUEST_STATUS_COMPLETE || itr->second.m_status == QUEST_STATUS_INCOMPLETE) ) - { - if( msg ) - SendCanTakeQuestResponse( INVALIDREASON_DONT_HAVE_REQ ); - return false; - } - - // check for all quests further up the chain - // only necessary if there are quest chains with more than one quest that can be skipped - //return SatisfyQuestNextChain( qInfo->GetNextQuestInChain(), msg ); - return true; -} - -bool Player::SatisfyQuestPrevChain( Quest const* qInfo, bool msg ) -{ - // No previous quest in chain - if( qInfo->prevChainQuests.empty()) - return true; - - for(Quest::PrevChainQuests::const_iterator iter = qInfo->prevChainQuests.begin(); iter != qInfo->prevChainQuests.end(); ++iter ) - { - uint32 prevId = *iter; - - QuestStatusMap::iterator i_prevstatus = mQuestStatus.find( prevId ); - - if( i_prevstatus != mQuestStatus.end() ) - { - // If any of the previous quests in chain active, return false - if( i_prevstatus->second.m_status == QUEST_STATUS_INCOMPLETE - || (i_prevstatus->second.m_status == QUEST_STATUS_COMPLETE && !GetQuestRewardStatus(prevId))) - { - if( msg ) - SendCanTakeQuestResponse( INVALIDREASON_DONT_HAVE_REQ ); - return false; - } - } - - // check for all quests further down the chain - // only necessary if there are quest chains with more than one quest that can be skipped - //if( !SatisfyQuestPrevChain( prevId, msg ) ) - // return false; - } - - // No previous quest in chain active - return true; -} - -bool Player::SatisfyQuestDay( Quest const* qInfo, bool msg ) -{ - if(!qInfo->IsDaily()) - return true; - - bool have_slot = false; - for(uint32 quest_daily_idx = 0; quest_daily_idx < PLAYER_MAX_DAILY_QUESTS; ++quest_daily_idx) - { - uint32 id = GetUInt32Value(PLAYER_FIELD_DAILY_QUESTS_1+quest_daily_idx); - if(qInfo->GetQuestId()==id) - return false; - - if(!id) - have_slot = true; - } - - if(!have_slot) - { - if( msg ) - SendCanTakeQuestResponse( INVALIDREASON_DAILY_QUESTS_REMAINING ); - return false; - } - - return true; -} - -bool Player::GiveQuestSourceItem( Quest const *pQuest ) -{ - uint32 srcitem = pQuest->GetSrcItemId(); - if( srcitem > 0 ) - { - uint32 count = pQuest->GetSrcItemCount(); - if( count <= 0 ) - count = 1; - - ItemPosCountVec dest; - uint8 msg = CanStoreNewItem( NULL_BAG, NULL_SLOT, dest, srcitem, count ); - if( msg == EQUIP_ERR_OK ) - { - Item * item = StoreNewItem(dest, srcitem, true); - SendNewItem(item, count, true, false); - return true; - } - // player already have max amount required item, just report success - else if( msg == EQUIP_ERR_CANT_CARRY_MORE_OF_THIS ) - return true; - else - SendEquipError( msg, NULL, NULL ); - return false; - } - - return true; -} - -bool Player::TakeQuestSourceItem( uint32 quest_id, bool msg ) -{ - Quest const* qInfo = objmgr.GetQuestTemplate(quest_id); - if( qInfo ) - { - uint32 srcitem = qInfo->GetSrcItemId(); - if( srcitem > 0 ) - { - uint32 count = qInfo->GetSrcItemCount(); - if( count <= 0 ) - count = 1; - - // exist one case when destroy source quest item not possible: - // non un-equippable item (equipped non-empty bag, for example) - uint8 res = CanUnequipItems(srcitem,count); - if(res != EQUIP_ERR_OK) - { - if(msg) - SendEquipError( res, NULL, NULL ); - return false; - } - - DestroyItemCount(srcitem, count, true, true); - } - } - return true; -} - -bool Player::GetQuestRewardStatus( uint32 quest_id ) const -{ - Quest const* qInfo = objmgr.GetQuestTemplate(quest_id); - if( qInfo ) - { - // for repeatable quests: rewarded field is set after first reward only to prevent getting XP more than once - QuestStatusMap::const_iterator itr = mQuestStatus.find( quest_id ); - if( itr != mQuestStatus.end() && itr->second.m_status != QUEST_STATUS_NONE - && !qInfo->IsRepeatable() ) - return itr->second.m_rewarded; - - return false; - } - return false; -} - -QuestStatus Player::GetQuestStatus( uint32 quest_id ) const -{ - if( quest_id ) - { - QuestStatusMap::const_iterator itr = mQuestStatus.find( quest_id ); - if( itr != mQuestStatus.end() ) - return itr->second.m_status; - } - return QUEST_STATUS_NONE; -} - -bool Player::CanShareQuest(uint32 quest_id) const -{ - Quest const* qInfo = objmgr.GetQuestTemplate(quest_id); - if( qInfo && qInfo->HasFlag(QUEST_FLAGS_SHARABLE) ) - { - QuestStatusMap::const_iterator itr = mQuestStatus.find( quest_id ); - if( itr != mQuestStatus.end() ) - return itr->second.m_status == QUEST_STATUS_NONE || itr->second.m_status == QUEST_STATUS_INCOMPLETE; - } - return false; -} - -void Player::SetQuestStatus( uint32 quest_id, QuestStatus status ) -{ - Quest const* qInfo = objmgr.GetQuestTemplate(quest_id); - if( qInfo ) - { - if( status == QUEST_STATUS_NONE || status == QUEST_STATUS_INCOMPLETE || status == QUEST_STATUS_COMPLETE ) - { - if( qInfo->HasFlag( QUEST_MANGOS_FLAGS_TIMED ) ) - m_timedquests.erase(qInfo->GetQuestId()); - } - - QuestStatusData& q_status = mQuestStatus[quest_id]; - - q_status.m_status = status; - if (q_status.uState != QUEST_NEW) q_status.uState = QUEST_CHANGED; - } - - UpdateForQuestsGO(); -} - -// not used in MaNGOS, but used in scripting code -uint32 Player::GetReqKillOrCastCurrentCount(uint32 quest_id, int32 entry) -{ - Quest const* qInfo = objmgr.GetQuestTemplate(quest_id); - if( !qInfo ) - return 0; - - for (int j = 0; j < QUEST_OBJECTIVES_COUNT; j++) - if ( qInfo->ReqCreatureOrGOId[j] == entry ) - return mQuestStatus[quest_id].m_creatureOrGOcount[j]; - - return 0; -} - -void Player::AdjustQuestReqItemCount( Quest const* pQuest ) -{ - if ( pQuest->HasFlag( QUEST_MANGOS_FLAGS_DELIVER ) ) - { - for(int i = 0; i < QUEST_OBJECTIVES_COUNT; i++) - { - uint32 reqitemcount = pQuest->ReqItemCount[i]; - if( reqitemcount != 0 ) - { - uint32 quest_id = pQuest->GetQuestId(); - uint32 curitemcount = GetItemCount(pQuest->ReqItemId[i],true); - - QuestStatusData& q_status = mQuestStatus[quest_id]; - q_status.m_itemcount[i] = std::min(curitemcount, reqitemcount); - if (q_status.uState != QUEST_NEW) q_status.uState = QUEST_CHANGED; - } - } - } -} - -uint16 Player::FindQuestSlot( uint32 quest_id ) const -{ - for ( uint16 i = 0; i < MAX_QUEST_LOG_SIZE; i++ ) - if ( GetQuestSlotQuestId(i) == quest_id ) - return i; - - return MAX_QUEST_LOG_SIZE; -} - -void Player::AreaExploredOrEventHappens( uint32 questId ) -{ - if( questId ) - { - uint16 log_slot = FindQuestSlot( questId ); - if( log_slot < MAX_QUEST_LOG_SIZE) - { - QuestStatusData& q_status = mQuestStatus[questId]; - - if(!q_status.m_explored) - { - q_status.m_explored = true; - if (q_status.uState != QUEST_NEW) - q_status.uState = QUEST_CHANGED; - } - } - if( CanCompleteQuest( questId ) ) - CompleteQuest( questId ); - } -} - -//not used in mangosd, function for external script library -void Player::GroupEventHappens( uint32 questId, WorldObject const* pEventObject ) -{ - if( Group *pGroup = GetGroup() ) - { - for(GroupReference *itr = pGroup->GetFirstMember(); itr != NULL; itr = itr->next()) - { - Player *pGroupGuy = itr->getSource(); - - // for any leave or dead (with not released body) group member at appropriate distance - if( pGroupGuy && pGroupGuy->IsAtGroupRewardDistance(pEventObject) && !pGroupGuy->GetCorpse() ) - pGroupGuy->AreaExploredOrEventHappens(questId); - } - } - else - AreaExploredOrEventHappens(questId); -} - -void Player::ItemAddedQuestCheck( uint32 entry, uint32 count ) -{ - for( int i = 0; i < MAX_QUEST_LOG_SIZE; i++ ) - { - uint32 questid = GetQuestSlotQuestId(i); - if ( questid == 0 ) - continue; - - QuestStatusData& q_status = mQuestStatus[questid]; - - if ( q_status.m_status != QUEST_STATUS_INCOMPLETE ) - continue; - - Quest const* qInfo = objmgr.GetQuestTemplate(questid); - if( !qInfo || !qInfo->HasFlag( QUEST_MANGOS_FLAGS_DELIVER ) ) - continue; - - for (int j = 0; j < QUEST_OBJECTIVES_COUNT; j++) - { - uint32 reqitem = qInfo->ReqItemId[j]; - if ( reqitem == entry ) - { - uint32 reqitemcount = qInfo->ReqItemCount[j]; - uint32 curitemcount = q_status.m_itemcount[j]; - if ( curitemcount < reqitemcount ) - { - uint32 additemcount = ( curitemcount + count <= reqitemcount ? count : reqitemcount - curitemcount); - q_status.m_itemcount[j] += additemcount; - if (q_status.uState != QUEST_NEW) q_status.uState = QUEST_CHANGED; - - SendQuestUpdateAddItem( qInfo, j, additemcount ); - } - if ( CanCompleteQuest( questid ) ) - CompleteQuest( questid ); - return; - } - } - } - UpdateForQuestsGO(); -} - -void Player::ItemRemovedQuestCheck( uint32 entry, uint32 count ) -{ - for( int i = 0; i < MAX_QUEST_LOG_SIZE; i++ ) - { - uint32 questid = GetQuestSlotQuestId(i); - if(!questid) - continue; - Quest const* qInfo = objmgr.GetQuestTemplate(questid); - if ( !qInfo ) - continue; - if( !qInfo->HasFlag( QUEST_MANGOS_FLAGS_DELIVER ) ) - continue; - - for (int j = 0; j < QUEST_OBJECTIVES_COUNT; j++) - { - uint32 reqitem = qInfo->ReqItemId[j]; - if ( reqitem == entry ) - { - QuestStatusData& q_status = mQuestStatus[questid]; - - uint32 reqitemcount = qInfo->ReqItemCount[j]; - uint32 curitemcount; - if( q_status.m_status != QUEST_STATUS_COMPLETE ) - curitemcount = q_status.m_itemcount[j]; - else - curitemcount = GetItemCount(entry,true); - if ( curitemcount < reqitemcount + count ) - { - uint32 remitemcount = ( curitemcount <= reqitemcount ? count : count + reqitemcount - curitemcount); - q_status.m_itemcount[j] = curitemcount - remitemcount; - if (q_status.uState != QUEST_NEW) q_status.uState = QUEST_CHANGED; - - IncompleteQuest( questid ); - } - return; - } - } - } - UpdateForQuestsGO(); -} - -void Player::KilledMonster( uint32 entry, uint64 guid ) -{ - uint32 addkillcount = 1; - for( int i = 0; i < MAX_QUEST_LOG_SIZE; i++ ) - { - uint32 questid = GetQuestSlotQuestId(i); - if(!questid) - continue; - - Quest const* qInfo = objmgr.GetQuestTemplate(questid); - if( !qInfo ) - continue; - // just if !ingroup || !noraidgroup || raidgroup - QuestStatusData& q_status = mQuestStatus[questid]; - if( q_status.m_status == QUEST_STATUS_INCOMPLETE && (!GetGroup() || !GetGroup()->isRaidGroup() || qInfo->GetType() == QUEST_TYPE_RAID)) - { - if( qInfo->HasFlag( QUEST_MANGOS_FLAGS_KILL_OR_CAST) ) - { - for (int j = 0; j < QUEST_OBJECTIVES_COUNT; j++) - { - // skip GO activate objective or none - if(qInfo->ReqCreatureOrGOId[j] <=0) - continue; - - // skip Cast at creature objective - if(qInfo->ReqSpell[j] !=0 ) - continue; - - uint32 reqkill = qInfo->ReqCreatureOrGOId[j]; - - if ( reqkill == entry ) - { - uint32 reqkillcount = qInfo->ReqCreatureOrGOCount[j]; - uint32 curkillcount = q_status.m_creatureOrGOcount[j]; - if ( curkillcount < reqkillcount ) - { - q_status.m_creatureOrGOcount[j] = curkillcount + addkillcount; - if (q_status.uState != QUEST_NEW) q_status.uState = QUEST_CHANGED; - - SendQuestUpdateAddCreatureOrGo( qInfo, guid, j, curkillcount, addkillcount); - } - if ( CanCompleteQuest( questid ) ) - CompleteQuest( questid ); - - // same objective target can be in many active quests, but not in 2 objectives for single quest (code optimization). - continue; - } - } - } - } - } -} - -void Player::CastedCreatureOrGO( uint32 entry, uint64 guid, uint32 spell_id ) -{ - bool isCreature = IS_CREATURE_GUID(guid); - - uint32 addCastCount = 1; - for( int i = 0; i < MAX_QUEST_LOG_SIZE; i++ ) - { - uint32 questid = GetQuestSlotQuestId(i); - if(!questid) - continue; - - Quest const* qInfo = objmgr.GetQuestTemplate(questid); - if ( !qInfo ) - continue; - - QuestStatusData& q_status = mQuestStatus[questid]; - - if ( q_status.m_status == QUEST_STATUS_INCOMPLETE ) - { - if( qInfo->HasFlag( QUEST_MANGOS_FLAGS_KILL_OR_CAST ) ) - { - for (int j = 0; j < QUEST_OBJECTIVES_COUNT; j++) - { - // skip kill creature objective (0) or wrong spell casts - if(qInfo->ReqSpell[j] != spell_id ) - continue; - - uint32 reqTarget = 0; - - if(isCreature) - { - // creature activate objectives - if(qInfo->ReqCreatureOrGOId[j] > 0) - // checked at quest_template loading - reqTarget = qInfo->ReqCreatureOrGOId[j]; - } - else - { - // GO activate objective - if(qInfo->ReqCreatureOrGOId[j] < 0) - // checked at quest_template loading - reqTarget = - qInfo->ReqCreatureOrGOId[j]; - } - - // other not this creature/GO related objectives - if( reqTarget != entry ) - continue; - - uint32 reqCastCount = qInfo->ReqCreatureOrGOCount[j]; - uint32 curCastCount = q_status.m_creatureOrGOcount[j]; - if ( curCastCount < reqCastCount ) - { - q_status.m_creatureOrGOcount[j] = curCastCount + addCastCount; - if (q_status.uState != QUEST_NEW) q_status.uState = QUEST_CHANGED; - - SendQuestUpdateAddCreatureOrGo( qInfo, guid, j, curCastCount, addCastCount); - } - - if ( CanCompleteQuest( questid ) ) - CompleteQuest( questid ); - - // same objective target can be in many active quests, but not in 2 objectives for single quest (code optimization). - break; - } - } - } - } -} - -void Player::TalkedToCreature( uint32 entry, uint64 guid ) -{ - uint32 addTalkCount = 1; - for( int i = 0; i < MAX_QUEST_LOG_SIZE; i++ ) - { - uint32 questid = GetQuestSlotQuestId(i); - if(!questid) - continue; - - Quest const* qInfo = objmgr.GetQuestTemplate(questid); - if ( !qInfo ) - continue; - - QuestStatusData& q_status = mQuestStatus[questid]; - - if ( q_status.m_status == QUEST_STATUS_INCOMPLETE ) - { - if( qInfo->HasFlag( QUEST_MANGOS_FLAGS_KILL_OR_CAST | QUEST_MANGOS_FLAGS_SPEAKTO ) ) - { - for (int j = 0; j < QUEST_OBJECTIVES_COUNT; j++) - { - // skip spell casts and Gameobject objectives - if(qInfo->ReqSpell[j] > 0 || qInfo->ReqCreatureOrGOId[j] < 0) - continue; - - uint32 reqTarget = 0; - - if(qInfo->ReqCreatureOrGOId[j] > 0) // creature activate objectives - // checked at quest_template loading - reqTarget = qInfo->ReqCreatureOrGOId[j]; - else - continue; - - if ( reqTarget == entry ) - { - uint32 reqTalkCount = qInfo->ReqCreatureOrGOCount[j]; - uint32 curTalkCount = q_status.m_creatureOrGOcount[j]; - if ( curTalkCount < reqTalkCount ) - { - q_status.m_creatureOrGOcount[j] = curTalkCount + addTalkCount; - if (q_status.uState != QUEST_NEW) q_status.uState = QUEST_CHANGED; - - SendQuestUpdateAddCreatureOrGo( qInfo, guid, j, curTalkCount, addTalkCount); - } - if ( CanCompleteQuest( questid ) ) - CompleteQuest( questid ); - - // same objective target can be in many active quests, but not in 2 objectives for single quest (code optimization). - continue; - } - } - } - } - } -} - -void Player::MoneyChanged( uint32 count ) -{ - for( int i = 0; i < MAX_QUEST_LOG_SIZE; i++ ) - { - uint32 questid = GetQuestSlotQuestId(i); - if (!questid) - continue; - - Quest const* qInfo = objmgr.GetQuestTemplate(questid); - if( qInfo && qInfo->GetRewOrReqMoney() < 0 ) - { - QuestStatusData& q_status = mQuestStatus[questid]; - - if( q_status.m_status == QUEST_STATUS_INCOMPLETE ) - { - if(int32(count) >= -qInfo->GetRewOrReqMoney()) - { - if ( CanCompleteQuest( questid ) ) - CompleteQuest( questid ); - } - } - else if( q_status.m_status == QUEST_STATUS_COMPLETE ) - { - if(int32(count) < -qInfo->GetRewOrReqMoney()) - IncompleteQuest( questid ); - } - } - } -} - -bool Player::HasQuestForItem( uint32 itemid ) const -{ - for( QuestStatusMap::const_iterator i = mQuestStatus.begin( ); i != mQuestStatus.end( ); ++i ) - { - QuestStatusData const& q_status = i->second; - - if (q_status.m_status == QUEST_STATUS_INCOMPLETE) - { - Quest const* qinfo = objmgr.GetQuestTemplate(i->first); - if(!qinfo) - continue; - - // hide quest if player is in raid-group and quest is no raid quest - if(GetGroup() && GetGroup()->isRaidGroup() && qinfo->GetType() != QUEST_TYPE_RAID) - continue; - - // There should be no mixed ReqItem/ReqSource drop - // This part for ReqItem drop - for (int j = 0; j < QUEST_OBJECTIVES_COUNT; j++) - { - if(itemid == qinfo->ReqItemId[j] && q_status.m_itemcount[j] < qinfo->ReqItemCount[j] ) - return true; - } - // This part - for ReqSource - for (int j = 0; j < QUEST_SOURCE_ITEM_IDS_COUNT; j++) - { - // examined item is a source item - if (qinfo->ReqSourceId[j] == itemid && qinfo->ReqSourceRef[j] > 0 && qinfo->ReqSourceRef[j] <= QUEST_OBJECTIVES_COUNT) - { - uint32 idx = qinfo->ReqSourceRef[j]-1; - - // total count of created ReqItems and SourceItems is less than ReqItemCount - if(qinfo->ReqItemId[idx] != 0 && - q_status.m_itemcount[idx] * qinfo->ReqSourceCount[j] + GetItemCount(itemid,true) < qinfo->ReqItemCount[idx] * qinfo->ReqSourceCount[j]) - return true; - - // total count of casted ReqCreatureOrGOs and SourceItems is less than ReqCreatureOrGOCount - if (qinfo->ReqCreatureOrGOId[idx] != 0) - { - if(q_status.m_creatureOrGOcount[idx] * qinfo->ReqSourceCount[j] + GetItemCount(itemid,true) < qinfo->ReqCreatureOrGOCount[idx] * qinfo->ReqSourceCount[j]) - return true; - } - // spell with SPELL_EFFECT_QUEST_COMPLETE or SPELL_EFFECT_SEND_EVENT (with script) case - else if(qinfo->ReqSpell[idx] != 0) - { - // not casted and need more reagents/item for use. - if(!q_status.m_explored && GetItemCount(itemid,true) < qinfo->ReqSourceCount[j]) - return true; - } - } - } - } - } - return false; -} - -void Player::SendQuestComplete( uint32 quest_id ) -{ - if( quest_id ) - { - WorldPacket data( SMSG_QUESTUPDATE_COMPLETE, 4 ); - data << quest_id; - GetSession()->SendPacket( &data ); - sLog.outDebug( "WORLD: Sent SMSG_QUESTUPDATE_COMPLETE quest = %u", quest_id ); - } -} - -void Player::SendQuestReward( Quest const *pQuest, uint32 XP, Object * questGiver ) -{ - uint32 questid = pQuest->GetQuestId(); - sLog.outDebug( "WORLD: Sent SMSG_QUESTGIVER_QUEST_COMPLETE quest = %u", questid ); - WorldPacket data( SMSG_QUESTGIVER_QUEST_COMPLETE, (4+4+4+4+4+4+pQuest->GetRewItemsCount()*8) ); - data << questid; - data << uint32(0x03); - - if ( getLevel() < sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL) ) - { - data << XP; - data << uint32(pQuest->GetRewOrReqMoney()); - } - else - { - data << uint32(0); - data << uint32(pQuest->GetRewOrReqMoney() + int32(pQuest->GetRewMoneyMaxLevel() * sWorld.getRate(RATE_DROP_MONEY))); - } - data << uint32(0); // new 2.3.0, HonorPoints? - data << uint32( pQuest->GetRewItemsCount() ); // max is 5 - - for (uint32 i = 0; i < pQuest->GetRewItemsCount(); ++i) - { - if ( pQuest->RewItemId[i] > 0 ) - data << pQuest->RewItemId[i] << pQuest->RewItemCount[i]; - else - data << uint32(0) << uint32(0); - } - GetSession()->SendPacket( &data ); - - if (pQuest->GetQuestCompleteScript() != 0) - sWorld.ScriptsStart(sQuestEndScripts, pQuest->GetQuestCompleteScript(), questGiver, this); -} - -void Player::SendQuestFailed( uint32 quest_id ) -{ - if( quest_id ) - { - WorldPacket data( SMSG_QUESTGIVER_QUEST_FAILED, 4 ); - data << quest_id; - GetSession()->SendPacket( &data ); - sLog.outDebug("WORLD: Sent SMSG_QUESTGIVER_QUEST_FAILED"); - } -} - -void Player::SendQuestTimerFailed( uint32 quest_id ) -{ - if( quest_id ) - { - WorldPacket data( SMSG_QUESTUPDATE_FAILEDTIMER, 4 ); - data << quest_id; - GetSession()->SendPacket( &data ); - sLog.outDebug("WORLD: Sent SMSG_QUESTUPDATE_FAILEDTIMER"); - } -} - -void Player::SendCanTakeQuestResponse( uint32 msg ) -{ - WorldPacket data( SMSG_QUESTGIVER_QUEST_INVALID, 4 ); - data << uint32(msg); - GetSession()->SendPacket( &data ); - sLog.outDebug("WORLD: Sent SMSG_QUESTGIVER_QUEST_INVALID"); -} - -void Player::SendPushToPartyResponse( Player *pPlayer, uint32 msg ) -{ - if( pPlayer ) - { - WorldPacket data( MSG_QUEST_PUSH_RESULT, (8+1) ); - data << uint64(pPlayer->GetGUID()); - data << uint8(msg); // valid values: 0-8 - GetSession()->SendPacket( &data ); - sLog.outDebug("WORLD: Sent MSG_QUEST_PUSH_RESULT"); - } -} - -void Player::SendQuestUpdateAddItem( Quest const* pQuest, uint32 item_idx, uint32 count ) -{ - WorldPacket data( SMSG_QUESTUPDATE_ADD_ITEM, (4+4) ); - sLog.outDebug( "WORLD: Sent SMSG_QUESTUPDATE_ADD_ITEM" ); - data << pQuest->ReqItemId[item_idx]; - data << count; - GetSession()->SendPacket( &data ); -} - -void Player::SendQuestUpdateAddCreatureOrGo( Quest const* pQuest, uint64 guid, uint32 creatureOrGO_idx, uint32 old_count, uint32 add_count ) -{ - assert(old_count + add_count < 256 && "mob/GO count store in 8 bits 2^8 = 256 (0..256)"); - - int32 entry = pQuest->ReqCreatureOrGOId[ creatureOrGO_idx ]; - if (entry < 0) - // client expected gameobject template id in form (id|0x80000000) - entry = (-entry) | 0x80000000; - - WorldPacket data( SMSG_QUESTUPDATE_ADD_KILL, (4*4+8) ); - sLog.outDebug( "WORLD: Sent SMSG_QUESTUPDATE_ADD_KILL" ); - data << uint32(pQuest->GetQuestId()); - data << uint32(entry); - data << uint32(old_count + add_count); - data << uint32(pQuest->ReqCreatureOrGOCount[ creatureOrGO_idx ]); - data << uint64(guid); - GetSession()->SendPacket(&data); - - uint16 log_slot = FindQuestSlot( pQuest->GetQuestId() ); - if( log_slot < MAX_QUEST_LOG_SIZE) - SetQuestSlotCounter(log_slot,creatureOrGO_idx,GetQuestSlotCounter(log_slot,creatureOrGO_idx)+add_count); -} - -/*********************************************************/ -/*** LOAD SYSTEM ***/ -/*********************************************************/ - -bool Player::MinimalLoadFromDB( QueryResult *result, uint32 guid ) -{ - bool delete_result = true; - if(!result) - { - // 0 1 2 3 4 5 6 7 8 - result = CharacterDatabase.PQuery("SELECT data, name, position_x, position_y, position_z, map, totaltime, leveltime, at_login FROM characters WHERE guid = '%u'",guid); - if(!result) return false; - } - else delete_result = false; - - Field *fields = result->Fetch(); - - if(!LoadValues( fields[0].GetString())) - { - sLog.outError("ERROR: Player #%d have broken data in `data` field. Can't be loaded.",GUID_LOPART(guid)); - if(delete_result) delete result; - return false; - } - - // overwrite possible wrong/corrupted guid - SetUInt64Value(OBJECT_FIELD_GUID, MAKE_NEW_GUID(guid, 0, HIGHGUID_PLAYER)); - - m_name = fields[1].GetCppString(); - - Relocate(fields[2].GetFloat(),fields[3].GetFloat(),fields[4].GetFloat()); - SetMapId(fields[5].GetUInt32()); - // the instance id is not needed at character enum - - m_Played_time[0] = fields[6].GetUInt32(); - m_Played_time[1] = fields[7].GetUInt32(); - - m_atLoginFlags = fields[8].GetUInt32(); - - // I don't see these used anywhere .. - /*_LoadGroup(); - - _LoadBoundInstances();*/ - - if (delete_result) delete result; - - for (int i = 0; i < PLAYER_SLOTS_COUNT; i++) - m_items[i] = NULL; - - if( HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_GHOST) ) - m_deathState = DEAD; - - return true; -} - -void Player::_LoadDeclinedNames(QueryResult* result) -{ - if(!result) - return; - - if(m_declinedname) - delete m_declinedname; - - m_declinedname = new DeclinedName; - Field *fields = result->Fetch(); - for(int i = 0; i < MAX_DECLINED_NAME_CASES; ++i) - m_declinedname->name[i] = fields[i].GetCppString(); - - delete result; -} - -bool Player::LoadPositionFromDB(uint32& mapid, float& x,float& y,float& z,float& o, bool& in_flight, uint64 guid) -{ - QueryResult *result = CharacterDatabase.PQuery("SELECT position_x,position_y,position_z,orientation,map,taxi_path FROM characters WHERE guid = '%u'",GUID_LOPART(guid)); - if(!result) - return false; - - Field *fields = result->Fetch(); - - x = fields[0].GetFloat(); - y = fields[1].GetFloat(); - z = fields[2].GetFloat(); - o = fields[3].GetFloat(); - mapid = fields[4].GetUInt32(); - in_flight = !fields[5].GetCppString().empty(); - - delete result; - return true; -} - -bool Player::LoadValuesArrayFromDB(Tokens& data, uint64 guid) -{ - QueryResult *result = CharacterDatabase.PQuery("SELECT data FROM characters WHERE guid='%u'",GUID_LOPART(guid)); - if( !result ) - return false; - - Field *fields = result->Fetch(); - - data = StrSplit(fields[0].GetCppString(), " "); - - delete result; - - return true; -} - -uint32 Player::GetUInt32ValueFromArray(Tokens const& data, uint16 index) -{ - if(index >= data.size()) - return 0; - - return (uint32)atoi(data[index].c_str()); -} - -float Player::GetFloatValueFromArray(Tokens const& data, uint16 index) -{ - float result; - uint32 temp = Player::GetUInt32ValueFromArray(data,index); - memcpy(&result, &temp, sizeof(result)); - - return result; -} - -uint32 Player::GetUInt32ValueFromDB(uint16 index, uint64 guid) -{ - Tokens data; - if(!LoadValuesArrayFromDB(data,guid)) - return 0; - - return GetUInt32ValueFromArray(data,index); -} - -float Player::GetFloatValueFromDB(uint16 index, uint64 guid) -{ - float result; - uint32 temp = Player::GetUInt32ValueFromDB(index, guid); - memcpy(&result, &temp, sizeof(result)); - - return result; -} - -bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder ) -{ - //// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 [28] [29] 30 31 32 - //QueryResult *result = CharacterDatabase.PQuery("SELECT guid, account, data, name, race, class, position_x, position_y, position_z, map, orientation, taximask, cinematic, totaltime, leveltime, rest_bonus, logout_time, is_logout_resting, resettalents_cost, resettalents_time, trans_x, trans_y, trans_z, trans_o, transguid, gmstate, stable_slots, at_login, zone, online, death_expire_time, taxi_path, dungeon_difficulty FROM characters WHERE guid = '%u'", guid); - QueryResult *result = holder->GetResult(PLAYER_LOGIN_QUERY_LOADFROM); - - if(!result) - { - sLog.outError("ERROR: Player (GUID: %u) not found in table `characters`, can't load. ",guid); - return false; - } - - Field *fields = result->Fetch(); - - uint32 dbAccountId = fields[1].GetUInt32(); - - // check if the character's account in the db and the logged in account match. - // player should be able to load/delete character only with correct account! - if( dbAccountId != GetSession()->GetAccountId() ) - { - sLog.outError("ERROR: Player (GUID: %u) loading from wrong account (is: %u, should be: %u)",guid,GetSession()->GetAccountId(),dbAccountId); - delete result; - return false; - } - - Object::_Create( guid, 0, HIGHGUID_PLAYER ); - - m_name = fields[3].GetCppString(); - - // check name limitations - if(!ObjectMgr::IsValidName(m_name) || GetSession()->GetSecurity() == SEC_PLAYER && objmgr.IsReservedName(m_name)) - { - delete result; - CharacterDatabase.PExecute("UPDATE characters SET at_login = at_login | '%u' WHERE guid ='%u'", uint32(AT_LOGIN_RENAME),guid); - return false; - } - - if(!LoadValues( fields[2].GetString())) - { - sLog.outError("ERROR: Player #%d have broken data in `data` field. Can't be loaded.",GUID_LOPART(guid)); - delete result; - return false; - } - - // overwrite possible wrong/corrupted guid - SetUInt64Value(OBJECT_FIELD_GUID, MAKE_NEW_GUID(guid, 0, HIGHGUID_PLAYER)); - - // cleanup inventory related item value fields (its will be filled correctly in _LoadInventory) - for(uint8 slot = EQUIPMENT_SLOT_START; slot < EQUIPMENT_SLOT_END; ++slot) - { - SetUInt64Value( (uint16)(PLAYER_FIELD_INV_SLOT_HEAD + (slot * 2) ), 0 ); - SetVisibleItemSlot(slot,NULL); - - if (m_items[slot]) - { - delete m_items[slot]; - m_items[slot] = NULL; - } - } - - // update money limits - if(GetMoney() > MAX_MONEY_AMOUNT) - SetMoney(MAX_MONEY_AMOUNT); - - sLog.outDebug("Load Basic value of player %s is: ", m_name.c_str()); - outDebugValues(); - - m_race = fields[4].GetUInt8(); - //Need to call it to initialize m_team (m_team can be calculated from m_race) - //Other way is to saves m_team into characters table. - setFactionForRace(m_race); - SetCharm(0); - - m_class = fields[5].GetUInt8(); - - PlayerInfo const *info = objmgr.GetPlayerInfo(m_race, m_class); - if(!info) - { - sLog.outError("Player have incorrect race/class pair. Can't be loaded."); - delete result; - return false; - } - - InitPrimaryProffesions(); // to max set before any spell loaded - - uint32 transGUID = fields[24].GetUInt32(); - Relocate(fields[6].GetFloat(),fields[7].GetFloat(),fields[8].GetFloat(),fields[10].GetFloat()); - SetMapId(fields[9].GetUInt32()); - SetDifficulty(fields[32].GetUInt32()); // may be changed in _LoadGroup - - _LoadGroup(holder->GetResult(PLAYER_LOGIN_QUERY_LOADGROUP)); - - // check arena teams integrity - for(uint32 arena_slot = 0; arena_slot < MAX_ARENA_SLOT; ++arena_slot) - { - uint32 arena_team_id = GetArenaTeamId(arena_slot); - if(!arena_team_id) - continue; - - if(ArenaTeam * at = objmgr.GetArenaTeamById(arena_team_id)) - if(at->HaveMember(GetGUID())) - continue; - - // arena team not exist or not member, cleanup fields - for(int j =0; j < 6; ++j) - SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + arena_slot * 6 + j, 0); - } - - _LoadBoundInstances(holder->GetResult(PLAYER_LOGIN_QUERY_LOADBOUNDINSTANCES)); - - if(!IsPositionValid()) - { - sLog.outError("ERROR: Player (guidlow %d) have invalid coordinates (X: %f Y: %f Z: %f O: %f). Teleport to default race/class locations.",guid,GetPositionX(),GetPositionY(),GetPositionZ(),GetOrientation()); - - SetMapId(info->mapId); - Relocate(info->positionX,info->positionY,info->positionZ,0.0f); - - transGUID = 0; - - m_movementInfo.t_x = 0.0f; - m_movementInfo.t_y = 0.0f; - m_movementInfo.t_z = 0.0f; - m_movementInfo.t_o = 0.0f; - } - - // load the player's map here if it's not already loaded - Map *map = GetMap(); - // since the player may not be bound to the map yet, make sure subsequent - // getmap calls won't create new maps - SetInstanceId(map->GetInstanceId()); - - SaveRecallPosition(); - - if (transGUID != 0) - { - m_movementInfo.t_x = fields[20].GetFloat(); - m_movementInfo.t_y = fields[21].GetFloat(); - m_movementInfo.t_z = fields[22].GetFloat(); - m_movementInfo.t_o = fields[23].GetFloat(); - - if( !MaNGOS::IsValidMapCoord( - GetPositionX()+m_movementInfo.t_x,GetPositionY()+m_movementInfo.t_y, - GetPositionZ()+m_movementInfo.t_z,GetOrientation()+m_movementInfo.t_o) || - // transport size limited - m_movementInfo.t_x > 50 || m_movementInfo.t_y > 50 || m_movementInfo.t_z > 50 ) - { - sLog.outError("ERROR: Player (guidlow %d) have invalid transport coordinates (X: %f Y: %f Z: %f O: %f). Teleport to default race/class locations.", - guid,GetPositionX()+m_movementInfo.t_x,GetPositionY()+m_movementInfo.t_y, - GetPositionZ()+m_movementInfo.t_z,GetOrientation()+m_movementInfo.t_o); - - SetMapId(info->mapId); - Relocate(info->positionX,info->positionY,info->positionZ,0.0f); - - m_movementInfo.t_x = 0.0f; - m_movementInfo.t_y = 0.0f; - m_movementInfo.t_z = 0.0f; - m_movementInfo.t_o = 0.0f; - - transGUID = 0; - } - } - - if (transGUID != 0) - { - for (MapManager::TransportSet::iterator iter = MapManager::Instance().m_Transports.begin(); iter != MapManager::Instance().m_Transports.end(); ++iter) - { - if( (*iter)->GetGUIDLow() == transGUID) - { - m_transport = *iter; - m_transport->AddPassenger(this); - SetMapId(m_transport->GetMapId()); - break; - } - } - - if(!m_transport) - { - sLog.outError("ERROR: Player (guidlow %d) have invalid transport guid (%u). Teleport to default race/class locations.", - guid,transGUID); - - SetMapId(info->mapId); - Relocate(info->positionX,info->positionY,info->positionZ,0.0f); - - m_movementInfo.t_x = 0.0f; - m_movementInfo.t_y = 0.0f; - m_movementInfo.t_z = 0.0f; - m_movementInfo.t_o = 0.0f; - - transGUID = 0; - } - } - - time_t now = time(NULL); - time_t logoutTime = time_t(fields[16].GetUInt64()); - - // since last logout (in seconds) - uint64 time_diff = uint64(now - logoutTime); - - // set value, including drunk invisibility detection - // calculate sobering. after 15 minutes logged out, the player will be sober again - float soberFactor; - if(time_diff > 15*MINUTE) - soberFactor = 0; - else - soberFactor = 1-time_diff/(15.0f*MINUTE); - uint16 newDrunkenValue = uint16(soberFactor*(GetUInt32Value(PLAYER_BYTES_3) & 0xFFFE)); - SetDrunkValue(newDrunkenValue); - - m_rest_bonus = fields[15].GetFloat(); - //speed collect rest bonus in offline, in logout, far from tavern, city (section/in hour) - float bubble0 = 0.031; - //speed collect rest bonus in offline, in logout, in tavern, city (section/in hour) - float bubble1 = 0.125; - - if((int32)fields[16].GetUInt32() > 0) - { - float bubble = fields[17].GetUInt32() > 0 - ? bubble1*sWorld.getRate(RATE_REST_OFFLINE_IN_TAVERN_OR_CITY) - : bubble0*sWorld.getRate(RATE_REST_OFFLINE_IN_WILDERNESS); - - SetRestBonus(GetRestBonus()+ time_diff*((float)GetUInt32Value(PLAYER_NEXT_LEVEL_XP)/72000)*bubble); - } - - m_cinematic = fields[12].GetUInt32(); - m_Played_time[0]= fields[13].GetUInt32(); - m_Played_time[1]= fields[14].GetUInt32(); - - m_resetTalentsCost = fields[18].GetUInt32(); - m_resetTalentsTime = time_t(fields[19].GetUInt64()); - - // reserve some flags - uint32 old_safe_flags = GetUInt32Value(PLAYER_FLAGS) & ( PLAYER_FLAGS_HIDE_CLOAK | PLAYER_FLAGS_HIDE_HELM ); - - if( HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_GM) ) - SetUInt32Value(PLAYER_FLAGS, 0 | old_safe_flags); - - m_taxi.LoadTaxiMask( fields[11].GetString() ); // must be before InitTaxiNodesForLevel - - uint32 gmstate = fields[25].GetUInt32(); - - m_stableSlots = fields[26].GetUInt32(); - if(m_stableSlots > 2) - { - sLog.outError("Player can have not more 2 stable slots, but have in DB %u",uint32(m_stableSlots)); - m_stableSlots = 2; - } - - m_atLoginFlags = fields[27].GetUInt32(); - - // Honor system - // Update Honor kills data - m_lastHonorUpdateTime = logoutTime; - UpdateHonorFields(); - - m_deathExpireTime = (time_t)fields[30].GetUInt64(); - if(m_deathExpireTime > now+MAX_DEATH_COUNT*DEATH_EXPIRE_STEP) - m_deathExpireTime = now+MAX_DEATH_COUNT*DEATH_EXPIRE_STEP-1; - - std::string taxi_nodes = fields[31].GetCppString(); - - delete result; - - // clear channel spell data (if saved at channel spell casting) - SetUInt64Value(UNIT_FIELD_CHANNEL_OBJECT, 0); - SetUInt32Value(UNIT_CHANNEL_SPELL,0); - - // clear charm/summon related fields - SetUInt64Value(UNIT_FIELD_CHARM,0); - SetUInt64Value(UNIT_FIELD_SUMMON,0); - SetUInt64Value(UNIT_FIELD_CHARMEDBY,0); - SetUInt64Value(UNIT_FIELD_SUMMONEDBY,0); - SetUInt64Value(UNIT_FIELD_CREATEDBY,0); - - // reset some aura modifiers before aura apply - SetUInt64Value(PLAYER_FARSIGHT, 0); - SetUInt32Value(PLAYER_TRACK_CREATURES, 0 ); - SetUInt32Value(PLAYER_TRACK_RESOURCES, 0 ); - - // reset skill modifiers and set correct unlearn flags - for (uint32 i = 0; i < PLAYER_MAX_SKILLS; i++) - { - SetUInt32Value(PLAYER_SKILL_BONUS_INDEX(i),0); - - // set correct unlearn bit - uint32 id = GetUInt32Value(PLAYER_SKILL_INDEX(i)) & 0x0000FFFF; - if(!id) continue; - - SkillLineEntry const *pSkill = sSkillLineStore.LookupEntry(id); - if(!pSkill) continue; - - // enable unlearn button for primary professions only - if (pSkill->categoryId == SKILL_CATEGORY_PROFESSION) - SetUInt32Value(PLAYER_SKILL_INDEX(i), MAKE_PAIR32(id,1)); - else - SetUInt32Value(PLAYER_SKILL_INDEX(i), MAKE_PAIR32(id,0)); - } - - // make sure the unit is considered out of combat for proper loading - ClearInCombat(); - - // make sure the unit is considered not in duel for proper loading - SetUInt64Value(PLAYER_DUEL_ARBITER, 0); - SetUInt32Value(PLAYER_DUEL_TEAM, 0); - - // remember loaded power/health values to restore after stats initialization and modifier applying - uint32 savedHealth = GetHealth(); - uint32 savedPower[MAX_POWERS]; - for(uint32 i = 0; i < MAX_POWERS; ++i) - savedPower[i] = GetPower(Powers(i)); - - // reset stats before loading any modifiers - InitStatsForLevel(); - InitTaxiNodesForLevel(); - - // apply original stats mods before spell loading or item equipment that call before equip _RemoveStatsMods() - - //mails are loaded only when needed ;-) - when player in game click on mailbox. - //_LoadMail(); - - _LoadAuras(holder->GetResult(PLAYER_LOGIN_QUERY_LOADAURAS), time_diff); - - // add ghost flag (must be after aura load: PLAYER_FLAGS_GHOST set in aura) - if( HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_GHOST) ) - m_deathState = DEAD; - - _LoadSpells(holder->GetResult(PLAYER_LOGIN_QUERY_LOADSPELLS)); - - // after spell load - InitTalentForLevel(); - learnSkillRewardedSpells(); - - // after spell load, learn rewarded spell if need also - _LoadQuestStatus(holder->GetResult(PLAYER_LOGIN_QUERY_LOADQUESTSTATUS)); - _LoadDailyQuestStatus(holder->GetResult(PLAYER_LOGIN_QUERY_LOADDAILYQUESTSTATUS)); - - _LoadTutorials(holder->GetResult(PLAYER_LOGIN_QUERY_LOADTUTORIALS)); - - // must be before inventory (some items required reputation check) - _LoadReputation(holder->GetResult(PLAYER_LOGIN_QUERY_LOADREPUTATION)); - - _LoadInventory(holder->GetResult(PLAYER_LOGIN_QUERY_LOADINVENTORY), time_diff); - - // update items with duration and realtime - UpdateItemDuration(time_diff, true); - - _LoadActions(holder->GetResult(PLAYER_LOGIN_QUERY_LOADACTIONS)); - - // unread mails and next delivery time, actual mails not loaded - _LoadMailInit(holder->GetResult(PLAYER_LOGIN_QUERY_LOADMAILCOUNT), holder->GetResult(PLAYER_LOGIN_QUERY_LOADMAILDATE)); - - m_social = sSocialMgr.LoadFromDB(holder->GetResult(PLAYER_LOGIN_QUERY_LOADSOCIALLIST), GetGUIDLow()); - - if(!_LoadHomeBind(holder->GetResult(PLAYER_LOGIN_QUERY_LOADHOMEBIND))) - return false; - - // check PLAYER_CHOSEN_TITLE compatibility with PLAYER__FIELD_KNOWN_TITLES - // note: PLAYER__FIELD_KNOWN_TITLES updated at quest status loaded - if(uint32 curTitle = GetUInt32Value(PLAYER_CHOSEN_TITLE)) - { - if(!HasFlag64(PLAYER__FIELD_KNOWN_TITLES,uint64(1) << curTitle)) - SetUInt32Value(PLAYER_CHOSEN_TITLE,0); - } - - // Not finish taxi flight path - if(!m_taxi.LoadTaxiDestinationsFromString(taxi_nodes)) - { - // problems with taxi path loading - TaxiNodesEntry const* nodeEntry = NULL; - if(uint32 node_id = m_taxi.GetTaxiSource()) - nodeEntry = sTaxiNodesStore.LookupEntry(node_id); - - if(!nodeEntry) // don't know taxi start node, to homebind - { - sLog.outError("Character %u have wrong data in taxi destination list, teleport to homebind.",GetGUIDLow()); - SetMapId(m_homebindMapId); - Relocate( m_homebindX, m_homebindY, m_homebindZ,0.0f); - SaveRecallPosition(); // save as recall also to prevent recall and fall from sky - } - else // have start node, to it - { - sLog.outError("Character %u have too short taxi destination list, teleport to original node.",GetGUIDLow()); - SetMapId(nodeEntry->map_id); - Relocate(nodeEntry->x, nodeEntry->y, nodeEntry->z,0.0f); - SaveRecallPosition(); // save as recall also to prevent recall and fall from sky - } - m_taxi.ClearTaxiDestinations(); - } - else if(uint32 node_id = m_taxi.GetTaxiSource()) - { - // save source node as recall coord to prevent recall and fall from sky - TaxiNodesEntry const* nodeEntry = sTaxiNodesStore.LookupEntry(node_id); - assert(nodeEntry); // checked in m_taxi.LoadTaxiDestinationsFromString - m_recallMap = nodeEntry->map_id; - m_recallX = nodeEntry->x; - m_recallY = nodeEntry->y; - m_recallZ = nodeEntry->z; - - // flight will started later - } - - _LoadSpellCooldowns(holder->GetResult(PLAYER_LOGIN_QUERY_LOADSPELLCOOLDOWNS)); - - // Spell code allow apply any auras to dead character in load time in aura/spell/item loading - // Do now before stats re-calculation cleanup for ghost state unexpected auras - if(!isAlive()) - RemoveAllAurasOnDeath(); - - //apply all stat bonuses from items and auras - SetCanModifyStats(true); - UpdateAllStats(); - - // restore remembered power/health values (but not more max values) - SetHealth(savedHealth > GetMaxHealth() ? GetMaxHealth() : savedHealth); - for(uint32 i = 0; i < MAX_POWERS; ++i) - SetPower(Powers(i),savedPower[i] > GetMaxPower(Powers(i)) ? GetMaxPower(Powers(i)) : savedPower[i]); - - sLog.outDebug("The value of player %s after load item and aura is: ", m_name.c_str()); - outDebugValues(); - - // GM state - if(GetSession()->GetSecurity() > SEC_PLAYER) - { - switch(sWorld.getConfig(CONFIG_GM_LOGIN_STATE)) - { - case 0: // disable - break; - case 1: // enable - SetGameMaster(true); - break; - case 2: // save state - if(gmstate) - SetGameMaster(true); - break; - default: - break; - } - } - - //Unmount Player from previous mount, so speed bug with mount is no more... - if(IsMounted()) - { - Unmount(); - RemoveSpellsCausingAura(SPELL_AURA_MOUNTED); - } - - _LoadDeclinedNames(holder->GetResult(PLAYER_LOGIN_QUERY_LOADDECLINEDNAMES)); - - return true; -} - -bool Player::isAllowedToLoot(Creature* creature) -{ - if(Player* recipient = creature->GetLootRecipient()) - { - if (recipient == this) - return true; - if( Group* otherGroup = recipient->GetGroup()) - { - Group* thisGroup = GetGroup(); - if(!thisGroup) - return false; - return thisGroup == otherGroup; - } - return false; - } - else - // prevent other players from looting if the recipient got disconnected - return !creature->hasLootRecipient(); -} - -void Player::_LoadActions(QueryResult *result) -{ - m_actionButtons.clear(); - - //QueryResult *result = CharacterDatabase.PQuery("SELECT button,action,type,misc FROM character_action WHERE guid = '%u' ORDER BY button",GetGUIDLow()); - - if(result) - { - do - { - Field *fields = result->Fetch(); - - uint8 button = fields[0].GetUInt8(); - - addActionButton(button, fields[1].GetUInt16(), fields[2].GetUInt8(), fields[3].GetUInt8()); - - m_actionButtons[button].uState = ACTIONBUTTON_UNCHANGED; - } - while( result->NextRow() ); - - delete result; - } -} - -void Player::_LoadAuras(QueryResult *result, uint32 timediff) -{ - m_Auras.clear(); - for (int i = 0; i < TOTAL_AURAS; i++) - m_modAuras[i].clear(); - - // all aura related fields - for(int i = UNIT_FIELD_AURA; i <= UNIT_FIELD_AURASTATE; ++i) - SetUInt32Value(i, 0); - - //QueryResult *result = CharacterDatabase.PQuery("SELECT caster_guid,spell,effect_index,amount,maxduration,remaintime,remaincharges FROM character_aura WHERE guid = '%u'",GetGUIDLow()); - - if(result) - { - do - { - Field *fields = result->Fetch(); - uint64 caster_guid = fields[0].GetUInt64(); - uint32 spellid = fields[1].GetUInt32(); - uint32 effindex = fields[2].GetUInt32(); - int32 damage = (int32)fields[3].GetUInt32(); - int32 maxduration = (int32)fields[4].GetUInt32(); - int32 remaintime = (int32)fields[5].GetUInt32(); - int32 remaincharges = (int32)fields[6].GetUInt32(); - - SpellEntry const* spellproto = sSpellStore.LookupEntry(spellid); - if(!spellproto) - { - sLog.outError("Unknown aura (spellid %u, effindex %u), ignore.",spellid,effindex); - continue; - } - - if(effindex >= 3) - { - sLog.outError("Invalid effect index (spellid %u, effindex %u), ignore.",spellid,effindex); - continue; - } - - // negative effects should continue counting down after logout - if (remaintime != -1 && !IsPositiveEffect(spellid, effindex)) - { - if(remaintime <= int32(timediff)) - continue; - - remaintime -= timediff; - } - - // prevent wrong values of remaincharges - if(spellproto->procCharges) - { - if(remaincharges <= 0 || remaincharges > spellproto->procCharges) - remaincharges = spellproto->procCharges; - } - else - remaincharges = -1; - - //do not load single target auras (unless they were cast by the player) - if (caster_guid != GetGUID() && IsSingleTargetSpell(spellproto)) - continue; - - Aura* aura = CreateAura(spellproto, effindex, NULL, this, NULL); - if(!damage) - damage = aura->GetModifier()->m_amount; - aura->SetLoadedState(caster_guid,damage,maxduration,remaintime,remaincharges); - AddAura(aura); - } - while( result->NextRow() ); - - delete result; - } - - if(m_class == CLASS_WARRIOR) - CastSpell(this,SPELL_ID_PASSIVE_BATTLE_STANCE,true); -} - -void Player::LoadCorpse() -{ - if( isAlive() ) - { - ObjectAccessor::Instance().ConvertCorpseForPlayer(GetGUID()); - } - else - { - if(Corpse *corpse = GetCorpse()) - { - ApplyModFlag(PLAYER_FIELD_BYTES, PLAYER_FIELD_BYTE_RELEASE_TIMER, corpse && !sMapStore.LookupEntry(corpse->GetMapId())->Instanceable() ); - } - else - { - //Prevent Dead Player login without corpse - ResurrectPlayer(0.5f); - } - } -} - -void Player::_LoadInventory(QueryResult *result, uint32 timediff) -{ - //QueryResult *result = CharacterDatabase.PQuery("SELECT data,bag,slot,item,item_template FROM character_inventory JOIN item_instance ON character_inventory.item = item_instance.guid WHERE character_inventory.guid = '%u' ORDER BY bag,slot", GetGUIDLow()); - std::map bagMap; // fast guid lookup for bags - //NOTE: the "order by `bag`" is important because it makes sure - //the bagMap is filled before items in the bags are loaded - //NOTE2: the "order by `slot`" is needed becaue mainhand weapons are (wrongly?) - //expected to be equipped before offhand items (TODO: fixme) - - uint32 zone = GetZoneId(); - - if (result) - { - std::list problematicItems; - - // prevent items from being added to the queue when stored - m_itemUpdateQueueBlocked = true; - do - { - Field *fields = result->Fetch(); - uint32 bag_guid = fields[1].GetUInt32(); - uint8 slot = fields[2].GetUInt8(); - uint32 item_guid = fields[3].GetUInt32(); - uint32 item_id = fields[4].GetUInt32(); - - ItemPrototype const * proto = objmgr.GetItemPrototype(item_id); - - if(!proto) - { - CharacterDatabase.PExecute("DELETE FROM character_inventory WHERE item = '%u'", item_guid); - CharacterDatabase.PExecute("DELETE FROM item_instance WHERE guid = '%u'", item_guid); - sLog.outError( "Player::_LoadInventory: Player %s has an unknown item (id: #%u) in inventory, deleted.", GetName(),item_id ); - continue; - } - - Item *item = NewItemOrBag(proto); - - if(!item->LoadFromDB(item_guid, GetGUID(), result)) - { - sLog.outError( "Player::_LoadInventory: Player %s has broken item (id: #%u) in inventory, deleted.", GetName(),item_id ); - CharacterDatabase.PExecute("DELETE FROM character_inventory WHERE item = '%u'", item_guid); - item->FSetState(ITEM_REMOVED); - item->SaveToDB(); // it also deletes item object ! - continue; - } - - // not allow have in alive state item limited to another map/zone - if(isAlive() && item->IsLimitedToAnotherMapOrZone(GetMapId(),zone) ) - { - CharacterDatabase.PExecute("DELETE FROM character_inventory WHERE item = '%u'", item_guid); - item->FSetState(ITEM_REMOVED); - item->SaveToDB(); // it also deletes item object ! - continue; - } - - // "Conjured items disappear if you are logged out for more than 15 minutes" - if ((timediff > 15*60) && (item->HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAGS_CONJURED))) - { - CharacterDatabase.PExecute("DELETE FROM character_inventory WHERE item = '%u'", item_guid); - item->FSetState(ITEM_REMOVED); - item->SaveToDB(); // it also deletes item object ! - continue; - } - - bool success = true; - - if (!bag_guid) - { - // the item is not in a bag - item->SetContainer( NULL ); - item->SetSlot(slot); - - if( IsInventoryPos( INVENTORY_SLOT_BAG_0, slot ) ) - { - ItemPosCountVec dest; - if( CanStoreItem( INVENTORY_SLOT_BAG_0, slot, dest, item, false ) == EQUIP_ERR_OK ) - item = StoreItem(dest, item, true); - else - success = false; - } - else if( IsEquipmentPos( INVENTORY_SLOT_BAG_0, slot ) ) - { - uint16 dest; - if( CanEquipItem( slot, dest, item, false, false ) == EQUIP_ERR_OK ) - QuickEquipItem(dest, item); - else - success = false; - } - else if( IsBankPos( INVENTORY_SLOT_BAG_0, slot ) ) - { - ItemPosCountVec dest; - if( CanBankItem( INVENTORY_SLOT_BAG_0, slot, dest, item, false, false ) == EQUIP_ERR_OK ) - item = BankItem(dest, item, true); - else - success = false; - } - - if(success) - { - // store bags that may contain items in them - if(item->IsBag() && IsBagPos(item->GetPos())) - bagMap[item_guid] = (Bag*)item; - } - } - else - { - item->SetSlot(NULL_SLOT); - // the item is in a bag, find the bag - std::map::iterator itr = bagMap.find(bag_guid); - if(itr != bagMap.end()) - itr->second->StoreItem(slot, item, true ); - else - success = false; - } - - // item's state may have changed after stored - if (success) - item->SetState(ITEM_UNCHANGED, this); - else - { - sLog.outError("Player::_LoadInventory: Player %s has item (GUID: %u Entry: %u) can't be loaded to inventory (Bag GUID: %u Slot: %u) by some reason, will send by mail.", GetName(),item_guid, item_id, bag_guid, slot); - CharacterDatabase.PExecute("DELETE FROM character_inventory WHERE item = '%u'", item_guid); - problematicItems.push_back(item); - } - } while (result->NextRow()); - - delete result; - m_itemUpdateQueueBlocked = false; - - // send by mail problematic items - while(!problematicItems.empty()) - { - // fill mail - MailItemsInfo mi; // item list prepering - - for(int i = 0; !problematicItems.empty() && i < MAX_MAIL_ITEMS; ++i) - { - Item* item = problematicItems.front(); - problematicItems.pop_front(); - - mi.AddItem(item->GetGUIDLow(), item->GetEntry(), item); - } - - std::string subject = GetSession()->GetMangosString(LANG_NOT_EQUIPPED_ITEM); - - WorldSession::SendMailTo(this, MAIL_NORMAL, MAIL_STATIONERY_GM, GetGUIDLow(), GetGUIDLow(), subject, 0, &mi, 0, 0, MAIL_CHECK_MASK_NONE); - } - } - //if(isAlive()) - _ApplyAllItemMods(); -} - -// load mailed item which should receive current player -void Player::_LoadMailedItems(Mail *mail) -{ - QueryResult* result = CharacterDatabase.PQuery("SELECT item_guid, item_template FROM mail_items WHERE mail_id='%u'", mail->messageID); - if(!result) - return; - - do - { - Field *fields = result->Fetch(); - uint32 item_guid_low = fields[0].GetUInt32(); - uint32 item_template = fields[1].GetUInt32(); - - mail->AddItem(item_guid_low, item_template); - - ItemPrototype const *proto = objmgr.GetItemPrototype(item_template); - - if(!proto) - { - sLog.outError( "Player %u have unknown item_template (ProtoType) in mailed items(GUID: %u template: %u) in mail (%u), deleted.", GetGUIDLow(), item_guid_low, item_template,mail->messageID); - CharacterDatabase.PExecute("DELETE FROM mail_items WHERE item_guid = '%u'", item_guid_low); - CharacterDatabase.PExecute("DELETE FROM item_instance WHERE guid = '%u'", item_guid_low); - continue; - } - - Item *item = NewItemOrBag(proto); - - if(!item->LoadFromDB(item_guid_low, 0)) - { - sLog.outError( "Player::_LoadMailedItems - Item in mail (%u) doesn't exist !!!! - item guid: %u, deleted from mail", mail->messageID, item_guid_low); - CharacterDatabase.PExecute("DELETE FROM mail_items WHERE item_guid = '%u'", item_guid_low); - item->FSetState(ITEM_REMOVED); - item->SaveToDB(); // it also deletes item object ! - continue; - } - - AddMItem(item); - } while (result->NextRow()); - - delete result; -} - -void Player::_LoadMailInit(QueryResult *resultUnread, QueryResult *resultDelivery) -{ - //set a count of unread mails - //QueryResult *resultMails = CharacterDatabase.PQuery("SELECT COUNT(id) FROM mail WHERE receiver = '%u' AND (checked & 1)=0 AND deliver_time <= '" I64FMTD "'", GUID_LOPART(playerGuid),(uint64)cTime); - if (resultUnread) - { - Field *fieldMail = resultUnread->Fetch(); - unReadMails = fieldMail[0].GetUInt8(); - delete resultUnread; - } - - // store nearest delivery time (it > 0 and if it < current then at next player update SendNewMaill will be called) - //resultMails = CharacterDatabase.PQuery("SELECT MIN(deliver_time) FROM mail WHERE receiver = '%u' AND (checked & 1)=0", GUID_LOPART(playerGuid)); - if (resultDelivery) - { - Field *fieldMail = resultDelivery->Fetch(); - m_nextMailDelivereTime = (time_t)fieldMail[0].GetUInt64(); - delete resultDelivery; - } -} - -void Player::_LoadMail() -{ - m_mail.clear(); - //mails are in right order 0 1 2 3 4 5 6 7 8 9 10 11 12 13 - QueryResult *result = CharacterDatabase.PQuery("SELECT id,messageType,sender,receiver,subject,itemTextId,has_items,expire_time,deliver_time,money,cod,checked,stationery,mailTemplateId FROM mail WHERE receiver = '%u' ORDER BY id DESC",GetGUIDLow()); - if(result) - { - do - { - Field *fields = result->Fetch(); - Mail *m = new Mail; - m->messageID = fields[0].GetUInt32(); - m->messageType = fields[1].GetUInt8(); - m->sender = fields[2].GetUInt32(); - m->receiver = fields[3].GetUInt32(); - m->subject = fields[4].GetCppString(); - m->itemTextId = fields[5].GetUInt32(); - bool has_items = fields[6].GetBool(); - m->expire_time = (time_t)fields[7].GetUInt64(); - m->deliver_time = (time_t)fields[8].GetUInt64(); - m->money = fields[9].GetUInt32(); - m->COD = fields[10].GetUInt32(); - m->checked = fields[11].GetUInt32(); - m->stationery = fields[12].GetUInt8(); - m->mailTemplateId = fields[13].GetInt16(); - - if(m->mailTemplateId && !sMailTemplateStore.LookupEntry(m->mailTemplateId)) - { - sLog.outError( "Player::_LoadMail - Mail (%u) have not existed MailTemplateId (%u), remove at load", m->messageID, m->mailTemplateId); - m->mailTemplateId = 0; - } - - m->state = MAIL_STATE_UNCHANGED; - - if (has_items) - _LoadMailedItems(m); - - m_mail.push_back(m); - } while( result->NextRow() ); - delete result; - } - m_mailsLoaded = true; -} - -void Player::LoadPet() -{ - //fixme: the pet should still be loaded if the player is not in world - // just not added to the map - if(IsInWorld()) - { - Pet *pet = new Pet; - if(!pet->LoadPetFromDB(this,0,0,true)) - delete pet; - } -} - -void Player::_LoadQuestStatus(QueryResult *result) -{ - mQuestStatus.clear(); - - uint32 slot = 0; - - //// 0 1 2 3 4 5 6 7 8 9 10 11 12 - //QueryResult *result = CharacterDatabase.PQuery("SELECT quest, status, rewarded, explored, timer, mobcount1, mobcount2, mobcount3, mobcount4, itemcount1, itemcount2, itemcount3, itemcount4 FROM character_queststatus WHERE guid = '%u'", GetGUIDLow()); - - if(result) - { - do - { - Field *fields = result->Fetch(); - - uint32 quest_id = fields[0].GetUInt32(); - // used to be new, no delete? - Quest const* pQuest = objmgr.GetQuestTemplate(quest_id); - if( pQuest ) - { - // find or create - QuestStatusData& questStatusData = mQuestStatus[quest_id]; - - uint32 qstatus = fields[1].GetUInt32(); - if(qstatus < MAX_QUEST_STATUS) - questStatusData.m_status = QuestStatus(qstatus); - else - { - questStatusData.m_status = QUEST_STATUS_NONE; - sLog.outError("Player %s have invalid quest %d status (%d), replaced by QUEST_STATUS_NONE(0).",GetName(),quest_id,qstatus); - } - - questStatusData.m_rewarded = ( fields[2].GetUInt8() > 0 ); - questStatusData.m_explored = ( fields[3].GetUInt8() > 0 ); - - time_t quest_time = time_t(fields[4].GetUInt64()); - - if( pQuest->HasFlag( QUEST_MANGOS_FLAGS_TIMED ) && !GetQuestRewardStatus(quest_id) && questStatusData.m_status != QUEST_STATUS_NONE ) - { - AddTimedQuest( quest_id ); - - if (quest_time <= sWorld.GetGameTime()) - questStatusData.m_timer = 1; - else - questStatusData.m_timer = (quest_time - sWorld.GetGameTime()) * 1000; - } - else - quest_time = 0; - - questStatusData.m_creatureOrGOcount[0] = fields[5].GetUInt32(); - questStatusData.m_creatureOrGOcount[1] = fields[6].GetUInt32(); - questStatusData.m_creatureOrGOcount[2] = fields[7].GetUInt32(); - questStatusData.m_creatureOrGOcount[3] = fields[8].GetUInt32(); - questStatusData.m_itemcount[0] = fields[9].GetUInt32(); - questStatusData.m_itemcount[1] = fields[10].GetUInt32(); - questStatusData.m_itemcount[2] = fields[11].GetUInt32(); - questStatusData.m_itemcount[3] = fields[12].GetUInt32(); - - questStatusData.uState = QUEST_UNCHANGED; - - // add to quest log - if( slot < MAX_QUEST_LOG_SIZE && - ( questStatusData.m_status==QUEST_STATUS_INCOMPLETE || - questStatusData.m_status==QUEST_STATUS_COMPLETE && !questStatusData.m_rewarded ) ) - { - SetQuestSlot(slot,quest_id,quest_time); - - if(questStatusData.m_status == QUEST_STATUS_COMPLETE) - SetQuestSlotState(slot,QUEST_STATE_COMPLETE); - - for(uint8 idx = 0; idx < QUEST_OBJECTIVES_COUNT; ++idx) - if(questStatusData.m_creatureOrGOcount[idx]) - SetQuestSlotCounter(slot,idx,questStatusData.m_creatureOrGOcount[idx]); - - ++slot; - } - - if(questStatusData.m_rewarded) - { - // learn rewarded spell if unknown - learnQuestRewardedSpells(pQuest); - - // set rewarded title if any - if(pQuest->GetCharTitleId()) - { - if(CharTitlesEntry const* titleEntry = sCharTitlesStore.LookupEntry(pQuest->GetCharTitleId())) - SetFlag64(PLAYER__FIELD_KNOWN_TITLES, (uint64(1) << titleEntry->bit_index)); - } - } - - sLog.outDebug("Quest status is {%u} for quest {%u} for player (GUID: %u)", questStatusData.m_status, quest_id, GetGUIDLow()); - } - } - while( result->NextRow() ); - - delete result; - } - - // clear quest log tail - for ( uint16 i = slot; i < MAX_QUEST_LOG_SIZE; ++i ) - SetQuestSlot(i,0); -} - -void Player::_LoadDailyQuestStatus(QueryResult *result) -{ - for(uint32 quest_daily_idx = 0; quest_daily_idx < PLAYER_MAX_DAILY_QUESTS; ++quest_daily_idx) - SetUInt32Value(PLAYER_FIELD_DAILY_QUESTS_1+quest_daily_idx,0); - - //QueryResult *result = CharacterDatabase.PQuery("SELECT quest,time FROM character_queststatus_daily WHERE guid = '%u'", GetGUIDLow()); - - if(result) - { - uint32 quest_daily_idx = 0; - - do - { - if(quest_daily_idx >= PLAYER_MAX_DAILY_QUESTS) // max amount with exist data in query - { - sLog.outError("Player (GUID: %u) have more 25 daily quest records in `charcter_queststatus_daily`",GetGUIDLow()); - break; - } - - Field *fields = result->Fetch(); - - uint32 quest_id = fields[0].GetUInt32(); - - // save _any_ from daily quest times (it must be after last reset anyway) - m_lastDailyQuestTime = (time_t)fields[1].GetUInt64(); - - Quest const* pQuest = objmgr.GetQuestTemplate(quest_id); - if( !pQuest ) - continue; - - SetUInt32Value(PLAYER_FIELD_DAILY_QUESTS_1+quest_daily_idx,quest_id); - ++quest_daily_idx; - - sLog.outDebug("Daily quest {%u} cooldown for player (GUID: %u)", quest_id, GetGUIDLow()); - } - while( result->NextRow() ); - - delete result; - } - - m_DailyQuestChanged = false; -} - -void Player::_LoadReputation(QueryResult *result) -{ - m_factions.clear(); - - // Set initial reputations (so everything is nifty before DB data load) - SetInitialFactions(); - - //QueryResult *result = CharacterDatabase.PQuery("SELECT faction,standing,flags FROM character_reputation WHERE guid = '%u'",GetGUIDLow()); - - if(result) - { - do - { - Field *fields = result->Fetch(); - - FactionEntry const *factionEntry = sFactionStore.LookupEntry(fields[0].GetUInt32()); - if( factionEntry && (factionEntry->reputationListID >= 0)) - { - FactionState* faction = &m_factions[factionEntry->reputationListID]; - - // update standing to current - faction->Standing = int32(fields[1].GetUInt32()); - - uint32 dbFactionFlags = fields[2].GetUInt32(); - - if( dbFactionFlags & FACTION_FLAG_VISIBLE ) - SetFactionVisible(faction); // have internal checks for forced invisibility - - if( dbFactionFlags & FACTION_FLAG_INACTIVE) - SetFactionInactive(faction,true); // have internal checks for visibility requirement - - if( dbFactionFlags & FACTION_FLAG_AT_WAR ) // DB at war - SetFactionAtWar(faction,true); // have internal checks for FACTION_FLAG_PEACE_FORCED - else // DB not at war - { - // allow remove if visible (and then not FACTION_FLAG_INVISIBLE_FORCED or FACTION_FLAG_HIDDEN) - if( faction->Flags & FACTION_FLAG_VISIBLE ) - SetFactionAtWar(faction,false); // have internal checks for FACTION_FLAG_PEACE_FORCED - } - - // set atWar for hostile - if(GetReputationRank(factionEntry) <= REP_HOSTILE) - SetFactionAtWar(faction,true); - - // reset changed flag if values similar to saved in DB - if(faction->Flags==dbFactionFlags) - faction->Changed = false; - } - } - while( result->NextRow() ); - - delete result; - } -} - -void Player::_LoadSpells(QueryResult *result) -{ - for (PlayerSpellMap::iterator itr = m_spells.begin(); itr != m_spells.end(); ++itr) - delete itr->second; - m_spells.clear(); - - //QueryResult *result = CharacterDatabase.PQuery("SELECT spell,slot,active FROM character_spell WHERE guid = '%u'",GetGUIDLow()); - - if(result) - { - do - { - Field *fields = result->Fetch(); - - addSpell(fields[0].GetUInt16(), fields[2].GetBool(), false, true, fields[1].GetUInt16(), fields[3].GetBool()); - } - while( result->NextRow() ); - - delete result; - } -} - -void Player::_LoadTutorials(QueryResult *result) -{ - //QueryResult *result = CharacterDatabase.PQuery("SELECT tut0,tut1,tut2,tut3,tut4,tut5,tut6,tut7 FROM character_tutorial WHERE account = '%u' AND realmid = '%u'", GetAccountId(), realmid); - - if(result) - { - do - { - Field *fields = result->Fetch(); - - for (int iI=0; iI<8; iI++) - m_Tutorials[iI] = fields[iI].GetUInt32(); - } - while( result->NextRow() ); - - delete result; - } - - m_TutorialsChanged = false; -} - -void Player::_LoadGroup(QueryResult *result) -{ - //QueryResult *result = CharacterDatabase.PQuery("SELECT leaderGuid FROM group_member WHERE memberGuid='%u'", GetGUIDLow()); - if(result) - { - uint64 leaderGuid = MAKE_NEW_GUID((*result)[0].GetUInt32(), 0, HIGHGUID_PLAYER); - delete result; - Group* group = objmgr.GetGroupByLeader(leaderGuid); - if(group) - { - uint8 subgroup = group->GetMemberGroup(GetGUID()); - SetGroup(group, subgroup); - if(getLevel() >= LEVELREQUIREMENT_HEROIC) - { - // the group leader may change the instance difficulty while the player is offline - SetDifficulty(group->GetDifficulty()); - } - } - } -} - -void Player::_LoadBoundInstances(QueryResult *result) -{ - for(uint8 i = 0; i < TOTAL_DIFFICULTIES; i++) - m_boundInstances[i].clear(); - - Group *group = GetGroup(); - - //QueryResult *result = CharacterDatabase.PQuery("SELECT id, permanent, map, difficulty, resettime FROM character_instance LEFT JOIN instance ON instance = id WHERE guid = '%u'", GUID_LOPART(m_guid)); - if(result) - { - do - { - Field *fields = result->Fetch(); - bool perm = fields[1].GetBool(); - uint32 mapId = fields[2].GetUInt32(); - uint32 instanceId = fields[0].GetUInt32(); - uint8 difficulty = fields[3].GetUInt8(); - time_t resetTime = (time_t)fields[4].GetUInt64(); - // the resettime for normal instances is only saved when the InstanceSave is unloaded - // so the value read from the DB may be wrong here but only if the InstanceSave is loaded - // and in that case it is not used - - if(!perm && group) - { - sLog.outError("_LoadBoundInstances: player %s(%d) is in group %d but has a non-permanent character bind to map %d,%d,%d", GetName(), GetGUIDLow(), GUID_LOPART(group->GetLeaderGUID()), mapId, instanceId, difficulty); - CharacterDatabase.PExecute("DELETE FROM character_instance WHERE guid = '%d' AND instance = '%d'", GetGUIDLow(), instanceId); - continue; - } - - // since non permanent binds are always solo bind, they can always be reset - InstanceSave *save = sInstanceSaveManager.AddInstanceSave(mapId, instanceId, difficulty, resetTime, !perm, true); - if(save) BindToInstance(save, perm, true); - } while(result->NextRow()); - delete result; - } -} - -InstancePlayerBind* Player::GetBoundInstance(uint32 mapid, uint8 difficulty) -{ - // some instances only have one difficulty - const MapEntry* entry = sMapStore.LookupEntry(mapid); - if(!entry || !entry->SupportsHeroicMode()) difficulty = DIFFICULTY_NORMAL; - - BoundInstancesMap::iterator itr = m_boundInstances[difficulty].find(mapid); - if(itr != m_boundInstances[difficulty].end()) - return &itr->second; - else - return NULL; -} - -void Player::UnbindInstance(uint32 mapid, uint8 difficulty, bool unload) -{ - BoundInstancesMap::iterator itr = m_boundInstances[difficulty].find(mapid); - UnbindInstance(itr, difficulty, unload); -} - -void Player::UnbindInstance(BoundInstancesMap::iterator &itr, uint8 difficulty, bool unload) -{ - if(itr != m_boundInstances[difficulty].end()) - { - if(!unload) CharacterDatabase.PExecute("DELETE FROM character_instance WHERE guid = '%u' AND instance = '%u'", GetGUIDLow(), itr->second.save->GetInstanceId()); - itr->second.save->RemovePlayer(this); // save can become invalid - m_boundInstances[difficulty].erase(itr++); - } -} - -InstancePlayerBind* Player::BindToInstance(InstanceSave *save, bool permanent, bool load) -{ - if(save) - { - InstancePlayerBind& bind = m_boundInstances[save->GetDifficulty()][save->GetMapId()]; - if(bind.save) - { - // update the save when the group kills a boss - if(permanent != bind.perm || save != bind.save) - if(!load) CharacterDatabase.PExecute("UPDATE character_instance SET instance = '%u', permanent = '%u' WHERE guid = '%u' AND instance = '%u'", save->GetInstanceId(), permanent, GetGUIDLow(), bind.save->GetInstanceId()); - } - else - if(!load) CharacterDatabase.PExecute("INSERT INTO character_instance (guid, instance, permanent) VALUES ('%u', '%u', '%u')", GetGUIDLow(), save->GetInstanceId(), permanent); - - if(bind.save != save) - { - if(bind.save) bind.save->RemovePlayer(this); - save->AddPlayer(this); - } - - if(permanent) save->SetCanReset(false); - - bind.save = save; - bind.perm = permanent; - if(!load) sLog.outDebug("Player::BindToInstance: %s(%d) is now bound to map %d, instance %d, difficulty %d", GetName(), GetGUIDLow(), save->GetMapId(), save->GetInstanceId(), save->GetDifficulty()); - return &bind; - } - else - return NULL; -} - -void Player::SendRaidInfo() -{ - WorldPacket data(SMSG_RAID_INSTANCE_INFO, 4); - - uint32 counter = 0, i; - for(i = 0; i < TOTAL_DIFFICULTIES; i++) - for (BoundInstancesMap::iterator itr = m_boundInstances[i].begin(); itr != m_boundInstances[i].end(); itr++) - if(itr->second.perm) counter++; - - data << counter; - for(i = 0; i < TOTAL_DIFFICULTIES; i++) - { - for (BoundInstancesMap::iterator itr = m_boundInstances[i].begin(); itr != m_boundInstances[i].end(); itr++) - { - if(itr->second.perm) - { - InstanceSave *save = itr->second.save; - data << (save->GetMapId()); - data << (uint32)(save->GetResetTime() - time(NULL)); - data << save->GetInstanceId(); - data << uint32(counter); - counter--; - } - } - } - GetSession()->SendPacket(&data); -} - -/* -- called on every successful teleportation to a map -*/ -void Player::SendSavedInstances() -{ - bool hasBeenSaved = false; - WorldPacket data; - - for(uint8 i = 0; i < TOTAL_DIFFICULTIES; i++) - { - for (BoundInstancesMap::iterator itr = m_boundInstances[i].begin(); itr != m_boundInstances[i].end(); ++itr) - { - if(itr->second.perm) // only permanent binds are sent - { - hasBeenSaved = true; - break; - } - } - } - - //Send opcode 811. true or flase means, whether you have current raid/heroic instances - data.Initialize(SMSG_UPDATE_INSTANCE_OWNERSHIP); - data << uint32(hasBeenSaved); - GetSession()->SendPacket(&data); - - if(!hasBeenSaved) - return; - - for(uint8 i = 0; i < TOTAL_DIFFICULTIES; i++) - { - for (BoundInstancesMap::iterator itr = m_boundInstances[i].begin(); itr != m_boundInstances[i].end(); ++itr) - { - if(itr->second.perm) - { - data.Initialize(SMSG_UPDATE_LAST_INSTANCE); - data << uint32(itr->second.save->GetMapId()); - GetSession()->SendPacket(&data); - } - } - } -} - -/// convert the player's binds to the group -void Player::ConvertInstancesToGroup(Player *player, Group *group, uint64 player_guid) -{ - bool has_binds = false; - bool has_solo = false; - - if(player) { player_guid = player->GetGUID(); if(!group) group = player->GetGroup(); } - assert(player_guid); - - // copy all binds to the group, when changing leader it's assumed the character - // will not have any solo binds - - if(player) - { - for(uint8 i = 0; i < TOTAL_DIFFICULTIES; i++) - { - for (BoundInstancesMap::iterator itr = player->m_boundInstances[i].begin(); itr != player->m_boundInstances[i].end();) - { - has_binds = true; - if(group) group->BindToInstance(itr->second.save, itr->second.perm, true); - // permanent binds are not removed - if(!itr->second.perm) - { - player->UnbindInstance(itr, i, true); // increments itr - has_solo = true; - } - else - ++itr; - } - } - } - - // if the player's not online we don't know what binds it has - if(!player || !group || has_binds) CharacterDatabase.PExecute("INSERT INTO group_instance SELECT guid, instance, permanent FROM character_instance WHERE guid = '%u'", GUID_LOPART(player_guid)); - // the following should not get executed when changing leaders - if(!player || has_solo) CharacterDatabase.PExecute("DELETE FROM character_instance WHERE guid = '%d' AND permanent = 0", GUID_LOPART(player_guid)); -} - -bool Player::_LoadHomeBind(QueryResult *result) -{ - bool ok = false; - //QueryResult *result = CharacterDatabase.PQuery("SELECT map,zone,position_x,position_y,position_z FROM character_homebind WHERE guid = '%u'", GUID_LOPART(playerGuid)); - if (result) - { - Field *fields = result->Fetch(); - m_homebindMapId = fields[0].GetUInt32(); - m_homebindZoneId = fields[1].GetUInt16(); - m_homebindX = fields[2].GetFloat(); - m_homebindY = fields[3].GetFloat(); - m_homebindZ = fields[4].GetFloat(); - delete result; - - // accept saved data only for valid position (and non instanceable) - if( MapManager::IsValidMapCoord(m_homebindMapId,m_homebindX,m_homebindY,m_homebindZ) && - !sMapStore.LookupEntry(m_homebindMapId)->Instanceable() ) - { - ok = true; - } - else - CharacterDatabase.PExecute("DELETE FROM character_homebind WHERE guid = '%u'", GetGUIDLow()); - } - - if(!ok) - { - PlayerInfo const *info = objmgr.GetPlayerInfo(getRace(), getClass()); - if(!info) return false; - - m_homebindMapId = info->mapId; - m_homebindZoneId = info->zoneId; - m_homebindX = info->positionX; - m_homebindY = info->positionY; - m_homebindZ = info->positionZ; - - CharacterDatabase.PExecute("INSERT INTO character_homebind (guid,map,zone,position_x,position_y,position_z) VALUES ('%u', '%u', '%u', '%f', '%f', '%f')", GetGUIDLow(), m_homebindMapId, (uint32)m_homebindZoneId, m_homebindX, m_homebindY, m_homebindZ); - } - - DEBUG_LOG("Setting player home position: mapid is: %u, zoneid is %u, X is %f, Y is %f, Z is %f\n", - m_homebindMapId, m_homebindZoneId, m_homebindX, m_homebindY, m_homebindZ); - - return true; -} - -/*********************************************************/ -/*** SAVE SYSTEM ***/ -/*********************************************************/ - -void Player::SaveToDB() -{ - // delay auto save at any saves (manual, in code, or autosave) - m_nextSave = sWorld.getConfig(CONFIG_INTERVAL_SAVE); - - // first save/honor gain after midnight will also update the player's honor fields - UpdateHonorFields(); - - // Must saved before enter into BattleGround - if(InBattleGround()) - return; - - int is_save_resting = HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_RESTING) ? 1 : 0; - //save, far from tavern/city - //save, but in tavern/city - sLog.outDebug("The value of player %s at save: ", m_name.c_str()); - outDebugValues(); - - // save state (after auras removing), if aura remove some flags then it must set it back by self) - uint32 tmp_bytes = GetUInt32Value(UNIT_FIELD_BYTES_1); - uint32 tmp_bytes2 = GetUInt32Value(UNIT_FIELD_BYTES_2); - uint32 tmp_flags = GetUInt32Value(UNIT_FIELD_FLAGS); - uint32 tmp_pflags = GetUInt32Value(PLAYER_FLAGS); - uint32 tmp_displayid = GetDisplayId(); - - // Set player sit state to standing on save, also stealth and shifted form - SetByteValue(UNIT_FIELD_BYTES_1, 0, 0); // stand state - SetByteValue(UNIT_FIELD_BYTES_2, 3, 0); // shapeshift - SetByteValue(UNIT_FIELD_BYTES_1, 3, 0); // stand flags? - RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_ROTATE); - SetDisplayId(GetNativeDisplayId()); - - bool inworld = IsInWorld(); - - CharacterDatabase.BeginTransaction(); - - CharacterDatabase.PExecute("DELETE FROM characters WHERE guid = '%u'",GetGUIDLow()); - - std::string sql_name = m_name; - CharacterDatabase.escape_string(sql_name); - - std::ostringstream ss; - ss << "INSERT INTO characters (guid,account,name,race,class," - "map, dungeon_difficulty, position_x, position_y, position_z, orientation, data, " - "taximask, online, cinematic, " - "totaltime, leveltime, rest_bonus, logout_time, is_logout_resting, resettalents_cost, resettalents_time, " - "trans_x, trans_y, trans_z, trans_o, transguid, gmstate, stable_slots, at_login, zone, " - "death_expire_time, taxi_path) VALUES (" - << GetGUIDLow() << ", " - << GetSession()->GetAccountId() << ", '" - << sql_name << "', " - << m_race << ", " - << m_class << ", "; - - bool save_to_dest = false; - if(IsBeingTeleported()) - { - // don't save to battlegrounds or arenas - const MapEntry *entry = sMapStore.LookupEntry(GetTeleportDest().mapid); - if(entry && entry->map_type != MAP_BATTLEGROUND && entry->map_type != MAP_ARENA) - save_to_dest = true; - } - - if(!save_to_dest) - { - ss << GetMapId() << ", " - << (uint32)GetDifficulty() << ", " - << finiteAlways(GetPositionX()) << ", " - << finiteAlways(GetPositionY()) << ", " - << finiteAlways(GetPositionZ()) << ", " - << finiteAlways(GetOrientation()) << ", '"; - } - else - { - ss << GetTeleportDest().mapid << ", " - << (uint32)GetDifficulty() << ", " - << finiteAlways(GetTeleportDest().x) << ", " - << finiteAlways(GetTeleportDest().y) << ", " - << finiteAlways(GetTeleportDest().z) << ", " - << finiteAlways(GetTeleportDest().o) << ", '"; - } - - uint16 i; - for( i = 0; i < m_valuesCount; i++ ) - { - ss << GetUInt32Value(i) << " "; - } - - ss << "', '"; - - for( i = 0; i < 8; i++ ) - ss << m_taxi.GetTaximask(i) << " "; - - ss << "', "; - ss << (inworld ? 1 : 0); - - ss << ", "; - ss << m_cinematic; - - ss << ", "; - ss << m_Played_time[0]; - ss << ", "; - ss << m_Played_time[1]; - - ss << ", "; - ss << finiteAlways(m_rest_bonus); - ss << ", "; - ss << (uint64)time(NULL); - ss << ", "; - ss << is_save_resting; - ss << ", "; - ss << m_resetTalentsCost; - ss << ", "; - ss << (uint64)m_resetTalentsTime; - - ss << ", "; - ss << finiteAlways(m_movementInfo.t_x); - ss << ", "; - ss << finiteAlways(m_movementInfo.t_y); - ss << ", "; - ss << finiteAlways(m_movementInfo.t_z); - ss << ", "; - ss << finiteAlways(m_movementInfo.t_o); - ss << ", "; - if (m_transport) - ss << m_transport->GetGUIDLow(); - else - ss << "0"; - - ss << ", "; - ss << (isGameMaster()? 1 : 0); - - ss << ", "; - ss << uint32(m_stableSlots); // to prevent save uint8 as char - - ss << ", "; - ss << uint32(m_atLoginFlags); - - ss << ", "; - ss << GetZoneId(); - - ss << ", "; - ss << (uint64)m_deathExpireTime; - - ss << ", '"; - ss << m_taxi.SaveTaxiDestinationsToString(); - ss << "' )"; - - CharacterDatabase.Execute( ss.str().c_str() ); - - if(m_mailsUpdated) //save mails only when needed - _SaveMail(); - - _SaveInventory(); - _SaveQuestStatus(); - _SaveDailyQuestStatus(); - _SaveTutorials(); - _SaveSpells(); - _SaveSpellCooldowns(); - _SaveActions(); - _SaveAuras(); - _SaveReputation(); - - CharacterDatabase.CommitTransaction(); - - // restore state (before aura apply, if aura remove flag then aura must set it ack by self) - SetDisplayId(tmp_displayid); - SetUInt32Value(UNIT_FIELD_BYTES_1, tmp_bytes); - SetUInt32Value(UNIT_FIELD_BYTES_2, tmp_bytes2); - SetUInt32Value(UNIT_FIELD_FLAGS, tmp_flags); - SetUInt32Value(PLAYER_FLAGS, tmp_pflags); - - // save pet (hunter pet level and experience and all type pets health/mana). - if(Pet* pet = GetPet()) - pet->SavePetToDB(PET_SAVE_AS_CURRENT); -} - -// fast save function for item/money cheating preventing - save only inventory and money state -void Player::SaveInventoryAndGoldToDB() -{ - _SaveInventory(); - SetUInt32ValueInDB(PLAYER_FIELD_COINAGE,GetMoney(),GetGUID()); -} - -void Player::_SaveActions() -{ - for(ActionButtonList::iterator itr = m_actionButtons.begin(); itr != m_actionButtons.end(); ) - { - switch (itr->second.uState) - { - case ACTIONBUTTON_NEW: - CharacterDatabase.PExecute("INSERT INTO character_action (guid,button,action,type,misc) VALUES ('%u', '%u', '%u', '%u', '%u')", - GetGUIDLow(), (uint32)itr->first, (uint32)itr->second.action, (uint32)itr->second.type, (uint32)itr->second.misc ); - itr->second.uState = ACTIONBUTTON_UNCHANGED; - ++itr; - break; - case ACTIONBUTTON_CHANGED: - CharacterDatabase.PExecute("UPDATE character_action SET action = '%u', type = '%u', misc= '%u' WHERE guid= '%u' AND button= '%u' ", - (uint32)itr->second.action, (uint32)itr->second.type, (uint32)itr->second.misc, GetGUIDLow(), (uint32)itr->first ); - itr->second.uState = ACTIONBUTTON_UNCHANGED; - ++itr; - break; - case ACTIONBUTTON_DELETED: - CharacterDatabase.PExecute("DELETE FROM character_action WHERE guid = '%u' and button = '%u'", GetGUIDLow(), (uint32)itr->first ); - m_actionButtons.erase(itr++); - break; - default: - ++itr; - break; - }; - } -} - -void Player::_SaveAuras() -{ - CharacterDatabase.PExecute("DELETE FROM character_aura WHERE guid = '%u'",GetGUIDLow()); - - AuraMap const& auras = GetAuras(); - for(AuraMap::const_iterator itr = auras.begin(); itr != auras.end(); ++itr) - { - SpellEntry const *spellInfo = itr->second->GetSpellProto(); - - //skip all auras from spells that are passive or need a shapeshift - if (itr->second->IsPassive() || itr->second->IsRemovedOnShapeLost()) - continue; - - //do not save single target auras (unless they were cast by the player) - if (itr->second->GetCasterGUID() != GetGUID() && IsSingleTargetSpell(spellInfo)) - continue; - - uint8 i; - // or apply at cast SPELL_AURA_MOD_SHAPESHIFT or SPELL_AURA_MOD_STEALTH auras - for (i = 0; i < 3; i++) - if (spellInfo->EffectApplyAuraName[i] == SPELL_AURA_MOD_SHAPESHIFT || - spellInfo->EffectApplyAuraName[i] == SPELL_AURA_MOD_STEALTH) - break; - - if (i == 3) - { - CharacterDatabase.PExecute("DELETE FROM character_aura WHERE guid = '%u' and spell = '%u' and effect_index= '%u'",GetGUIDLow(),(uint32)(*itr).second->GetId(), (uint32)(*itr).second->GetEffIndex()); - CharacterDatabase.PExecute("INSERT INTO character_aura (guid,caster_guid,spell,effect_index,amount,maxduration,remaintime,remaincharges) " - "VALUES ('%u', '" I64FMTD "' ,'%u', '%u', '%d', '%d', '%d', '%d')", - GetGUIDLow(), itr->second->GetCasterGUID(), (uint32)(*itr).second->GetId(), (uint32)(*itr).second->GetEffIndex(), (*itr).second->GetModifier()->m_amount,int((*itr).second->GetAuraMaxDuration()),int((*itr).second->GetAuraDuration()),int((*itr).second->m_procCharges)); - } - } -} - -void Player::_SaveInventory() -{ - // force items in buyback slots to new state - // and remove those that aren't already - for (uint8 i = BUYBACK_SLOT_START; i < BUYBACK_SLOT_END; i++) - { - Item *item = m_items[i]; - if (!item || item->GetState() == ITEM_NEW) continue; - CharacterDatabase.PExecute("DELETE FROM character_inventory WHERE item = '%u'", item->GetGUIDLow()); - CharacterDatabase.PExecute("DELETE FROM item_instance WHERE guid = '%u'", item->GetGUIDLow()); - m_items[i]->FSetState(ITEM_NEW); - } - - // update enchantment durations - for(EnchantDurationList::iterator itr = m_enchantDuration.begin();itr != m_enchantDuration.end();++itr) - { - itr->item->SetEnchantmentDuration(itr->slot,itr->leftduration); - } - - // if no changes - if (m_itemUpdateQueue.empty()) return; - - // do not save if the update queue is corrupt - bool error = false; - for(size_t i = 0; i < m_itemUpdateQueue.size(); i++) - { - Item *item = m_itemUpdateQueue[i]; - if(!item || item->GetState() == ITEM_REMOVED) continue; - Item *test = GetItemByPos( item->GetBagSlot(), item->GetSlot()); - - if (test == NULL) - { - sLog.outError("Player(GUID: %u Name: %s)::_SaveInventory - the bag(%d) and slot(%d) values for the item with guid %d are incorrect, the player doesn't have an item at that position!", GetGUIDLow(), GetName(), item->GetBagSlot(), item->GetSlot(), item->GetGUIDLow()); - error = true; - } - else if (test != item) - { - sLog.outError("Player(GUID: %u Name: %s)::_SaveInventory - the bag(%d) and slot(%d) values for the item with guid %d are incorrect, the item with guid %d is there instead!", GetGUIDLow(), GetName(), item->GetBagSlot(), item->GetSlot(), item->GetGUIDLow(), test->GetGUIDLow()); - error = true; - } - } - - if (error) - { - sLog.outError("Player::_SaveInventory - one or more errors occurred save aborted!"); - ChatHandler(this).SendSysMessage(LANG_ITEM_SAVE_FAILED); - return; - } - - for(size_t i = 0; i < m_itemUpdateQueue.size(); i++) - { - Item *item = m_itemUpdateQueue[i]; - if(!item) continue; - - Bag *container = item->GetContainer(); - uint32 bag_guid = container ? container->GetGUIDLow() : 0; - - switch(item->GetState()) - { - case ITEM_NEW: - CharacterDatabase.PExecute("INSERT INTO character_inventory (guid,bag,slot,item,item_template) VALUES ('%u', '%u', '%u', '%u', '%u')", GetGUIDLow(), bag_guid, item->GetSlot(), item->GetGUIDLow(), item->GetEntry()); - break; - case ITEM_CHANGED: - CharacterDatabase.PExecute("UPDATE character_inventory SET guid='%u', bag='%u', slot='%u', item_template='%u' WHERE item='%u'", GetGUIDLow(), bag_guid, item->GetSlot(), item->GetEntry(), item->GetGUIDLow()); - break; - case ITEM_REMOVED: - CharacterDatabase.PExecute("DELETE FROM character_inventory WHERE item = '%u'", item->GetGUIDLow()); - break; - case ITEM_UNCHANGED: - break; - } - - item->SaveToDB(); // item have unchanged inventory record and can be save standalone - } - m_itemUpdateQueue.clear(); -} - -void Player::_SaveMail() -{ - if (!m_mailsLoaded) - return; - - for (PlayerMails::iterator itr = m_mail.begin(); itr != m_mail.end(); itr++) - { - Mail *m = (*itr); - if (m->state == MAIL_STATE_CHANGED) - { - CharacterDatabase.PExecute("UPDATE mail SET itemTextId = '%u',has_items = '%u',expire_time = '" I64FMTD "', deliver_time = '" I64FMTD "',money = '%u',cod = '%u',checked = '%u' WHERE id = '%u'", - m->itemTextId, m->HasItems() ? 1 : 0, (uint64)m->expire_time, (uint64)m->deliver_time, m->money, m->COD, m->checked, m->messageID); - if(m->removedItems.size()) - { - for(std::vector::iterator itr2 = m->removedItems.begin(); itr2 != m->removedItems.end(); ++itr2) - CharacterDatabase.PExecute("DELETE FROM mail_items WHERE item_guid = '%u'", *itr2); - m->removedItems.clear(); - } - m->state = MAIL_STATE_UNCHANGED; - } - else if (m->state == MAIL_STATE_DELETED) - { - if (m->HasItems()) - for(std::vector::iterator itr2 = m->items.begin(); itr2 != m->items.end(); ++itr2) - CharacterDatabase.PExecute("DELETE FROM item_instance WHERE guid = '%u'", itr2->item_guid); - if (m->itemTextId) - CharacterDatabase.PExecute("DELETE FROM item_text WHERE id = '%u'", m->itemTextId); - CharacterDatabase.PExecute("DELETE FROM mail WHERE id = '%u'", m->messageID); - CharacterDatabase.PExecute("DELETE FROM mail_items WHERE mail_id = '%u'", m->messageID); - } - } - - //deallocate deleted mails... - for (PlayerMails::iterator itr = m_mail.begin(); itr != m_mail.end(); ) - { - if ((*itr)->state == MAIL_STATE_DELETED) - { - Mail* m = *itr; - m_mail.erase(itr); - delete m; - itr = m_mail.begin(); - } - else - ++itr; - } - - m_mailsUpdated = false; -} - -void Player::_SaveQuestStatus() -{ - // we don't need transactions here. - for( QuestStatusMap::iterator i = mQuestStatus.begin( ); i != mQuestStatus.end( ); ++i ) - { - switch (i->second.uState) - { - case QUEST_NEW : - CharacterDatabase.PExecute("INSERT INTO character_queststatus (guid,quest,status,rewarded,explored,timer,mobcount1,mobcount2,mobcount3,mobcount4,itemcount1,itemcount2,itemcount3,itemcount4) " - "VALUES ('%u', '%u', '%u', '%u', '%u', '" I64FMTD "', '%u', '%u', '%u', '%u', '%u', '%u', '%u', '%u')", - GetGUIDLow(), i->first, i->second.m_status, i->second.m_rewarded, i->second.m_explored, uint64(i->second.m_timer / 1000 + sWorld.GetGameTime()), i->second.m_creatureOrGOcount[0], i->second.m_creatureOrGOcount[1], i->second.m_creatureOrGOcount[2], i->second.m_creatureOrGOcount[3], i->second.m_itemcount[0], i->second.m_itemcount[1], i->second.m_itemcount[2], i->second.m_itemcount[3]); - break; - case QUEST_CHANGED : - CharacterDatabase.PExecute("UPDATE character_queststatus SET status = '%u',rewarded = '%u',explored = '%u',timer = '" I64FMTD "',mobcount1 = '%u',mobcount2 = '%u',mobcount3 = '%u',mobcount4 = '%u',itemcount1 = '%u',itemcount2 = '%u',itemcount3 = '%u',itemcount4 = '%u' WHERE guid = '%u' AND quest = '%u' ", - i->second.m_status, i->second.m_rewarded, i->second.m_explored, uint64(i->second.m_timer / 1000 + sWorld.GetGameTime()), i->second.m_creatureOrGOcount[0], i->second.m_creatureOrGOcount[1], i->second.m_creatureOrGOcount[2], i->second.m_creatureOrGOcount[3], i->second.m_itemcount[0], i->second.m_itemcount[1], i->second.m_itemcount[2], i->second.m_itemcount[3], GetGUIDLow(), i->first ); - break; - case QUEST_UNCHANGED: - break; - }; - i->second.uState = QUEST_UNCHANGED; - } -} - -void Player::_SaveDailyQuestStatus() -{ - if(!m_DailyQuestChanged) - return; - - m_DailyQuestChanged = false; - - // save last daily quest time for all quests: we need only mostly reset time for reset check anyway - - // we don't need transactions here. - CharacterDatabase.PExecute("DELETE FROM character_queststatus_daily WHERE guid = '%u'",GetGUIDLow()); - for(uint32 quest_daily_idx = 0; quest_daily_idx < PLAYER_MAX_DAILY_QUESTS; ++quest_daily_idx) - if(GetUInt32Value(PLAYER_FIELD_DAILY_QUESTS_1+quest_daily_idx)) - CharacterDatabase.PExecute("INSERT INTO character_queststatus_daily (guid,quest,time) VALUES ('%u', '%u','" I64FMTD "')", - GetGUIDLow(), GetUInt32Value(PLAYER_FIELD_DAILY_QUESTS_1+quest_daily_idx),uint64(m_lastDailyQuestTime)); -} - -void Player::_SaveReputation() -{ - for(FactionStateList::iterator itr = m_factions.begin(); itr != m_factions.end(); ++itr) - { - if (itr->second.Changed) - { - CharacterDatabase.PExecute("DELETE FROM character_reputation WHERE guid = '%u' AND faction='%u'", GetGUIDLow(), itr->second.ID); - CharacterDatabase.PExecute("INSERT INTO character_reputation (guid,faction,standing,flags) VALUES ('%u', '%u', '%i', '%u')", GetGUIDLow(), itr->second.ID, itr->second.Standing, itr->second.Flags); - itr->second.Changed = false; - } - } -} - -void Player::_SaveSpells() -{ - for (PlayerSpellMap::const_iterator itr = m_spells.begin(), next = m_spells.begin(); itr != m_spells.end(); itr = next) - { - ++next; - if (itr->second->state == PLAYERSPELL_REMOVED || itr->second->state == PLAYERSPELL_CHANGED) - CharacterDatabase.PExecute("DELETE FROM character_spell WHERE guid = '%u' and spell = '%u'", GetGUIDLow(), itr->first); - if (itr->second->state == PLAYERSPELL_NEW || itr->second->state == PLAYERSPELL_CHANGED) - CharacterDatabase.PExecute("INSERT INTO character_spell (guid,spell,slot,active,disabled) VALUES ('%u', '%u', '%u','%u','%u')", GetGUIDLow(), itr->first, itr->second->slotId,itr->second->active ? 1 : 0,itr->second->disabled ? 1 : 0); - - if (itr->second->state == PLAYERSPELL_REMOVED) - _removeSpell(itr->first); - else - itr->second->state = PLAYERSPELL_UNCHANGED; - } -} - -void Player::_SaveTutorials() -{ - if(!m_TutorialsChanged) - return; - - uint32 Rows=0; - // it's better than rebuilding indexes multiple times - QueryResult *result = CharacterDatabase.PQuery("SELECT count(*) AS r FROM character_tutorial WHERE account = '%u' AND realmid = '%u'", GetSession()->GetAccountId(), realmID ); - if(result) - { - Rows = result->Fetch()[0].GetUInt32(); - delete result; - } - - if (Rows) - { - CharacterDatabase.PExecute("UPDATE character_tutorial SET tut0='%u', tut1='%u', tut2='%u', tut3='%u', tut4='%u', tut5='%u', tut6='%u', tut7='%u' WHERE account = '%u' AND realmid = '%u'", - m_Tutorials[0], m_Tutorials[1], m_Tutorials[2], m_Tutorials[3], m_Tutorials[4], m_Tutorials[5], m_Tutorials[6], m_Tutorials[7], GetSession()->GetAccountId(), realmID ); - } - else - { - CharacterDatabase.PExecute("INSERT INTO character_tutorial (account,realmid,tut0,tut1,tut2,tut3,tut4,tut5,tut6,tut7) VALUES ('%u', '%u', '%u', '%u', '%u', '%u', '%u', '%u', '%u', '%u')", GetSession()->GetAccountId(), realmID, m_Tutorials[0], m_Tutorials[1], m_Tutorials[2], m_Tutorials[3], m_Tutorials[4], m_Tutorials[5], m_Tutorials[6], m_Tutorials[7]); - }; - - m_TutorialsChanged = false; -} - -void Player::outDebugValues() const -{ - if(!sLog.IsOutDebug()) // optimize disabled debug output - return; - - sLog.outDebug("HP is: \t\t\t%u\t\tMP is: \t\t\t%u",GetMaxHealth(), GetMaxPower(POWER_MANA)); - sLog.outDebug("AGILITY is: \t\t%f\t\tSTRENGTH is: \t\t%f",GetStat(STAT_AGILITY), GetStat(STAT_STRENGTH)); - sLog.outDebug("INTELLECT is: \t\t%f\t\tSPIRIT is: \t\t%f",GetStat(STAT_INTELLECT), GetStat(STAT_SPIRIT)); - sLog.outDebug("STAMINA is: \t\t%f\t\tSPIRIT is: \t\t%f",GetStat(STAT_STAMINA), GetStat(STAT_SPIRIT)); - sLog.outDebug("Armor is: \t\t%u\t\tBlock is: \t\t%f",GetArmor(), GetFloatValue(PLAYER_BLOCK_PERCENTAGE)); - sLog.outDebug("HolyRes is: \t\t%u\t\tFireRes is: \t\t%u",GetResistance(SPELL_SCHOOL_HOLY), GetResistance(SPELL_SCHOOL_FIRE)); - sLog.outDebug("NatureRes is: \t\t%u\t\tFrostRes is: \t\t%u",GetResistance(SPELL_SCHOOL_NATURE), GetResistance(SPELL_SCHOOL_FROST)); - sLog.outDebug("ShadowRes is: \t\t%u\t\tArcaneRes is: \t\t%u",GetResistance(SPELL_SCHOOL_SHADOW), GetResistance(SPELL_SCHOOL_ARCANE)); - sLog.outDebug("MIN_DAMAGE is: \t\t%f\tMAX_DAMAGE is: \t\t%f",GetFloatValue(UNIT_FIELD_MINDAMAGE), GetFloatValue(UNIT_FIELD_MAXDAMAGE)); - sLog.outDebug("MIN_OFFHAND_DAMAGE is: \t%f\tMAX_OFFHAND_DAMAGE is: \t%f",GetFloatValue(UNIT_FIELD_MINOFFHANDDAMAGE), GetFloatValue(UNIT_FIELD_MAXOFFHANDDAMAGE)); - sLog.outDebug("MIN_RANGED_DAMAGE is: \t%f\tMAX_RANGED_DAMAGE is: \t%f",GetFloatValue(UNIT_FIELD_MINRANGEDDAMAGE), GetFloatValue(UNIT_FIELD_MAXRANGEDDAMAGE)); - sLog.outDebug("ATTACK_TIME is: \t%u\t\tRANGE_ATTACK_TIME is: \t%u",GetAttackTime(BASE_ATTACK), GetAttackTime(RANGED_ATTACK)); -} - -/*********************************************************/ -/*** FLOOD FILTER SYSTEM ***/ -/*********************************************************/ - -void Player::UpdateSpeakTime() -{ - // ignore chat spam protection for GMs in any mode - if(GetSession()->GetSecurity() > SEC_PLAYER) - return; - - time_t current = time (NULL); - if(m_speakTime > current) - { - uint32 max_count = sWorld.getConfig(CONFIG_CHATFLOOD_MESSAGE_COUNT); - if(!max_count) - return; - - ++m_speakCount; - if(m_speakCount >= max_count) - { - // prevent overwrite mute time, if message send just before mutes set, for example. - time_t new_mute = current + sWorld.getConfig(CONFIG_CHATFLOOD_MUTE_TIME); - if(GetSession()->m_muteTime < new_mute) - GetSession()->m_muteTime = new_mute; - - m_speakCount = 0; - } - } - else - m_speakCount = 0; - - m_speakTime = current + sWorld.getConfig(CONFIG_CHATFLOOD_MESSAGE_DELAY); -} - -bool Player::CanSpeak() const -{ - return GetSession()->m_muteTime <= time (NULL); -} - -/*********************************************************/ -/*** LOW LEVEL FUNCTIONS:Notifiers ***/ -/*********************************************************/ - -void Player::SendAttackSwingNotInRange() -{ - WorldPacket data(SMSG_ATTACKSWING_NOTINRANGE, 0); - GetSession()->SendPacket( &data ); -} - -void Player::SavePositionInDB(uint32 mapid, float x,float y,float z,float o,uint32 zone,uint64 guid) -{ - std::ostringstream ss; - ss << "UPDATE characters SET position_x='"<= tokens.size()) - return; - - tokens[index] = buf; -} - -void Player::SetUInt32ValueInDB(uint16 index, uint32 value, uint64 guid) -{ - Tokens tokens; - if(!LoadValuesArrayFromDB(tokens,guid)) - return; - - if(index >= tokens.size()) - return; - - char buf[11]; - snprintf(buf,11,"%u",value); - tokens[index] = buf; - - SaveValuesArrayInDB(tokens,guid); -} - -void Player::SetFloatValueInDB(uint16 index, float value, uint64 guid) -{ - uint32 temp; - memcpy(&temp, &value, sizeof(value)); - Player::SetUInt32ValueInDB(index, temp, guid); -} - -void Player::SendAttackSwingNotStanding() -{ - WorldPacket data(SMSG_ATTACKSWING_NOTSTANDING, 0); - GetSession()->SendPacket( &data ); -} - -void Player::SendAttackSwingDeadTarget() -{ - WorldPacket data(SMSG_ATTACKSWING_DEADTARGET, 0); - GetSession()->SendPacket( &data ); -} - -void Player::SendAttackSwingCantAttack() -{ - WorldPacket data(SMSG_ATTACKSWING_CANT_ATTACK, 0); - GetSession()->SendPacket( &data ); -} - -void Player::SendAttackSwingCancelAttack() -{ - WorldPacket data(SMSG_CANCEL_COMBAT, 0); - GetSession()->SendPacket( &data ); -} - -void Player::SendAttackSwingBadFacingAttack() -{ - WorldPacket data(SMSG_ATTACKSWING_BADFACING, 0); - GetSession()->SendPacket( &data ); -} - -void Player::SendAutoRepeatCancel() -{ - WorldPacket data(SMSG_CANCEL_AUTO_REPEAT, 0); - GetSession()->SendPacket( &data ); -} - -void Player::PlaySound(uint32 Sound, bool OnlySelf) -{ - WorldPacket data(SMSG_PLAY_SOUND, 4); - data << Sound; - if (OnlySelf) - GetSession()->SendPacket( &data ); - else - SendMessageToSet( &data, true ); -} - -void Player::SendExplorationExperience(uint32 Area, uint32 Experience) -{ - WorldPacket data( SMSG_EXPLORATION_EXPERIENCE, 8 ); - data << Area; - data << Experience; - GetSession()->SendPacket(&data); -} - -void Player::SendDungeonDifficulty(bool IsInGroup) -{ - uint8 val = 0x00000001; - WorldPacket data(MSG_SET_DUNGEON_DIFFICULTY, 12); - data << (uint32)GetDifficulty(); - data << uint32(val); - data << uint32(IsInGroup); - GetSession()->SendPacket(&data); -} - -void Player::SendResetFailedNotify(uint32 mapid) -{ - WorldPacket data(SMSG_RESET_FAILED_NOTIFY, 4); - data << uint32(mapid); - GetSession()->SendPacket(&data); -} - -/// Reset all solo instances and optionally send a message on success for each -void Player::ResetInstances(uint8 method) -{ - // method can be INSTANCE_RESET_ALL, INSTANCE_RESET_CHANGE_DIFFICULTY, INSTANCE_RESET_GROUP_JOIN - - // we assume that when the difficulty changes, all instances that can be reset will be - uint8 dif = GetDifficulty(); - - for (BoundInstancesMap::iterator itr = m_boundInstances[dif].begin(); itr != m_boundInstances[dif].end();) - { - InstanceSave *p = itr->second.save; - const MapEntry *entry = sMapStore.LookupEntry(itr->first); - if(!entry || !p->CanReset()) - { - ++itr; - continue; - } - - if(method == INSTANCE_RESET_ALL) - { - // the "reset all instances" method can only reset normal maps - if(dif == DIFFICULTY_HEROIC || entry->map_type == MAP_RAID) - { - ++itr; - continue; - } - } - - // if the map is loaded, reset it - Map *map = MapManager::Instance().FindMap(p->GetMapId(), p->GetInstanceId()); - if(map && map->IsDungeon()) - ((InstanceMap*)map)->Reset(method); - - // since this is a solo instance there should not be any players inside - if(method == INSTANCE_RESET_ALL || method == INSTANCE_RESET_CHANGE_DIFFICULTY) - SendResetInstanceSuccess(p->GetMapId()); - - p->DeleteFromDB(); - m_boundInstances[dif].erase(itr++); - - // the following should remove the instance save from the manager and delete it as well - p->RemovePlayer(this); - } -} - -void Player::SendResetInstanceSuccess(uint32 MapId) -{ - WorldPacket data(SMSG_INSTANCE_RESET, 4); - data << MapId; - GetSession()->SendPacket(&data); -} - -void Player::SendResetInstanceFailed(uint32 reason, uint32 MapId) -{ - // TODO: find what other fail reasons there are besides players in the instance - WorldPacket data(SMSG_INSTANCE_RESET_FAILED, 4); - data << reason; - data << MapId; - GetSession()->SendPacket(&data); -} - -/*********************************************************/ -/*** Update timers ***/ -/*********************************************************/ - -///checks the 15 afk reports per 5 minutes limit -void Player::UpdateAfkReport(time_t currTime) -{ - if(m_bgAfkReportedTimer <= currTime) - { - m_bgAfkReportedCount = 0; - m_bgAfkReportedTimer = currTime+5*MINUTE; - } -} - -void Player::UpdateContestedPvP(uint32 diff) -{ - if(!m_contestedPvPTimer||isInCombat()) - return; - if(m_contestedPvPTimer <= diff) - { - ResetContestedPvP(); - } - else - m_contestedPvPTimer -= diff; -} - -void Player::UpdatePvPFlag(time_t currTime) -{ - if(!IsPvP()) - return; - if(pvpInfo.endTimer == 0 || currTime < (pvpInfo.endTimer + 300)) - return; - - UpdatePvP(false); -} - -void Player::UpdateDuelFlag(time_t currTime) -{ - if(!duel || duel->startTimer == 0 ||currTime < duel->startTimer + 3) - return; - - SetUInt32Value(PLAYER_DUEL_TEAM, 1); - duel->opponent->SetUInt32Value(PLAYER_DUEL_TEAM, 2); - - duel->startTimer = 0; - duel->startTime = currTime; - duel->opponent->duel->startTimer = 0; - duel->opponent->duel->startTime = currTime; -} - -void Player::RemovePet(Pet* pet, PetSaveMode mode, bool returnreagent) -{ - if(!pet) - pet = GetPet(); - - if(returnreagent && (pet || m_temporaryUnsummonedPetNumber)) - { - //returning of reagents only for players, so best done here - uint32 spellId = pet ? pet->GetUInt32Value(UNIT_CREATED_BY_SPELL) : m_oldpetspell; - SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellId); - - if(spellInfo) - { - for(uint32 i = 0; i < 7; ++i) - { - if(spellInfo->Reagent[i] > 0) - { - ItemPosCountVec dest; //for succubus, voidwalker, felhunter and felguard credit soulshard when despawn reason other than death (out of range, logout) - uint8 msg = CanStoreNewItem( NULL_BAG, NULL_SLOT, dest, spellInfo->Reagent[i], spellInfo->ReagentCount[i] ); - if( msg == EQUIP_ERR_OK ) - { - Item* item = StoreNewItem( dest, spellInfo->Reagent[i], true); - if(IsInWorld()) - SendNewItem(item,spellInfo->ReagentCount[i],true,false); - } - } - } - } - m_temporaryUnsummonedPetNumber = 0; - } - - if(!pet || pet->GetOwnerGUID()!=GetGUID()) - return; - - // only if current pet in slot - switch(pet->getPetType()) - { - case MINI_PET: - m_miniPet = 0; - break; - case GUARDIAN_PET: - m_guardianPets.erase(pet->GetGUID()); - break; - default: - if(GetPetGUID()==pet->GetGUID()) - SetPet(0); - break; - } - - pet->CombatStop(); - - if(returnreagent) - { - switch(pet->GetEntry()) - { - //warlock pets except imp are removed(?) when logging out - case 1860: - case 1863: - case 417: - case 17252: - mode = PET_SAVE_NOT_IN_SLOT; - break; - } - } - - pet->SavePetToDB(mode); - - pet->CleanupsBeforeDelete(); - pet->AddObjectToRemoveList(); - pet->m_removed = true; - - if(pet->isControlled()) - { - WorldPacket data(SMSG_PET_SPELLS, 8); - data << uint64(0); - GetSession()->SendPacket(&data); - - if(GetGroup()) - SetGroupUpdateFlag(GROUP_UPDATE_PET); - } -} - - -void Player::RemoveMiniPet() -{ - if(Pet* pet = GetMiniPet()) - { - pet->Remove(PET_SAVE_AS_DELETED); - m_miniPet = 0; - } -} - -Pet* Player::GetMiniPet() -{ - if(!m_miniPet) - return NULL; - return ObjectAccessor::GetPet(m_miniPet); -} - -void Player::RemoveGuardians() -{ - while(!m_guardianPets.empty()) - { - uint64 guid = *m_guardianPets.begin(); - if(Pet* pet = ObjectAccessor::GetPet(guid)) - pet->Remove(PET_SAVE_AS_DELETED); - - m_guardianPets.erase(guid); - } -} - -bool Player::HasGuardianWithEntry(uint32 entry) -{ - // pet guid middle part is entry (and creature also) - // and in guardian list must be guardians with same entry _always_ - for(GuardianPetList::const_iterator itr = m_guardianPets.begin(); itr != m_guardianPets.end(); ++itr) - if(GUID_ENPART(*itr)==entry) - return true; - - return false; -} - -void Player::Uncharm() -{ - Unit* charm = GetCharm(); - if(!charm) - return; - - charm->RemoveSpellsCausingAura(SPELL_AURA_MOD_CHARM); - charm->RemoveSpellsCausingAura(SPELL_AURA_MOD_POSSESS); -} - -void Player::BuildPlayerChat(WorldPacket *data, uint8 msgtype, std::string text, uint32 language) const -{ - bool pre = (msgtype==CHAT_MSG_EMOTE); - - *data << (uint8)msgtype; - *data << (uint32)language; - *data << (uint64)GetGUID(); - *data << (uint32)language; //language 2.1.0 ? - *data << (uint64)GetGUID(); - *data << (uint32)(text.length()+1+(pre?3:0)); - if(pre) - data->append("%s ",3); - *data << text; - *data << (uint8)chatTag(); -} - -void Player::Say(const std::string text, const uint32 language) -{ - WorldPacket data(SMSG_MESSAGECHAT, 200); - BuildPlayerChat(&data, CHAT_MSG_SAY, text, language); - SendMessageToSetInRange(&data,sWorld.getConfig(CONFIG_LISTEN_RANGE_SAY),true); -} - -void Player::Yell(const std::string text, const uint32 language) -{ - WorldPacket data(SMSG_MESSAGECHAT, 200); - BuildPlayerChat(&data, CHAT_MSG_YELL, text, language); - SendMessageToSetInRange(&data,sWorld.getConfig(CONFIG_LISTEN_RANGE_YELL),true); -} - -void Player::TextEmote(const std::string text) -{ - WorldPacket data(SMSG_MESSAGECHAT, 200); - BuildPlayerChat(&data, CHAT_MSG_EMOTE, text, LANG_UNIVERSAL); - SendMessageToSetInRange(&data,sWorld.getConfig(CONFIG_LISTEN_RANGE_TEXTEMOTE),true, !sWorld.getConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHAT) ); -} - -void Player::Whisper(std::string text, uint32 language,uint64 receiver) -{ - if (language != LANG_ADDON) // if not addon data - language = LANG_UNIVERSAL; // whispers should always be readable - - Player *rPlayer = objmgr.GetPlayer(receiver); - - // when player you are whispering to is dnd, he cannot receive your message, unless you are in gm mode - if(!rPlayer->isDND() || isGameMaster()) - { - WorldPacket data(SMSG_MESSAGECHAT, 200); - BuildPlayerChat(&data, CHAT_MSG_WHISPER, text, language); - rPlayer->GetSession()->SendPacket(&data); - - data.Initialize(SMSG_MESSAGECHAT, 200); - rPlayer->BuildPlayerChat(&data, CHAT_MSG_REPLY, text, language); - GetSession()->SendPacket(&data); - } - else - { - // announce to player that player he is whispering to is dnd and cannot receive his message - ChatHandler(this).PSendSysMessage(LANG_PLAYER_DND, rPlayer->GetName(), rPlayer->dndMsg.c_str()); - } - - if(!isAcceptWhispers()) - { - SetAcceptWhispers(true); - ChatHandler(this).SendSysMessage(LANG_COMMAND_WHISPERON); - } - - // announce to player that player he is whispering to is afk - if(rPlayer->isAFK()) - ChatHandler(this).PSendSysMessage(LANG_PLAYER_AFK, rPlayer->GetName(), rPlayer->afkMsg.c_str()); - - // if player whisper someone, auto turn of dnd to be able to receive an answer - if(isDND() && !rPlayer->isGameMaster()) - ToggleDND(); -} - -void Player::PetSpellInitialize() -{ - Pet* pet = GetPet(); - - if(pet) - { - uint8 addlist = 0; - - sLog.outDebug("Pet Spells Groups"); - - CreatureInfo const *cinfo = pet->GetCreatureInfo(); - - if(pet->isControlled() && (pet->getPetType() == HUNTER_PET || cinfo && cinfo->type == CREATURE_TYPE_DEMON && getClass() == CLASS_WARLOCK)) - { - for(PetSpellMap::iterator itr = pet->m_spells.begin();itr != pet->m_spells.end();itr++) - { - if(itr->second->state == PETSPELL_REMOVED) - continue; - ++addlist; - } - } - - // first line + actionbar + spellcount + spells + last adds - WorldPacket data(SMSG_PET_SPELLS, 16+40+1+4*addlist+25); - - CharmInfo *charmInfo = pet->GetCharmInfo(); - - //16 - data << (uint64)pet->GetGUID() << uint32(0x00000000) << uint8(charmInfo->GetReactState()) << uint8(charmInfo->GetCommandState()) << uint16(0); - - for(uint32 i = 0; i < 10; i++) //40 - { - data << uint16(charmInfo->GetActionBarEntry(i)->SpellOrAction) << uint16(charmInfo->GetActionBarEntry(i)->Type); - } - - data << uint8(addlist); //1 - - if(addlist && pet->isControlled()) - { - for (PetSpellMap::iterator itr = pet->m_spells.begin(); itr != pet->m_spells.end(); ++itr) - { - if(itr->second->state == PETSPELL_REMOVED) - continue; - - data << uint16(itr->first); - data << uint16(itr->second->active); // pet spell active state isn't boolean - } - } - - //data << uint8(0x01) << uint32(0x6010) << uint32(0x01) << uint32(0x05) << uint16(0x00); //15 - uint8 count = 3; //1+8+8+8=25 - - // if count = 0, then end of packet... - data << count; - // uint32 value is spell id... - // uint64 value is constant 0, unknown... - data << uint32(0x6010) << uint64(0); // if count = 1, 2 or 3 - //data << uint32(0x5fd1) << uint64(0); // if count = 2 - data << uint32(0x8e8c) << uint64(0); // if count = 3 - data << uint32(0x8e8b) << uint64(0); // if count = 3 - - GetSession()->SendPacket(&data); - } -} - -void Player::PossessSpellInitialize() -{ - Unit* charm = GetCharm(); - - if(!charm) - return; - - CharmInfo *charmInfo = charm->GetCharmInfo(); - - if(!charmInfo) - { - sLog.outError("Player::PossessSpellInitialize(): charm ("I64FMTD") has no charminfo!", charm->GetGUID()); - return; - } - - uint8 addlist = 0; - WorldPacket data(SMSG_PET_SPELLS, 16+40+1+4*addlist+25);// first line + actionbar + spellcount + spells + last adds - - //16 - data << (uint64)charm->GetGUID() << uint32(0x00000000) << uint8(0) << uint8(0) << uint16(0); - - for(uint32 i = 0; i < 10; i++) //40 - { - data << uint16(charmInfo->GetActionBarEntry(i)->SpellOrAction) << uint16(charmInfo->GetActionBarEntry(i)->Type); - } - - data << uint8(addlist); //1 - - uint8 count = 3; - data << count; - data << uint32(0x6010) << uint64(0); // if count = 1, 2 or 3 - data << uint32(0x8e8c) << uint64(0); // if count = 3 - data << uint32(0x8e8b) << uint64(0); // if count = 3 - - GetSession()->SendPacket(&data); -} - -void Player::CharmSpellInitialize() -{ - Unit* charm = GetCharm(); - - if(!charm) - return; - - CharmInfo *charmInfo = charm->GetCharmInfo(); - if(!charmInfo) - { - sLog.outError("Player::CharmSpellInitialize(): the player's charm ("I64FMTD") has no charminfo!", charm->GetGUID()); - return; - } - - uint8 addlist = 0; - - if(charm->GetTypeId() != TYPEID_PLAYER) - { - CreatureInfo const *cinfo = ((Creature*)charm)->GetCreatureInfo(); - - if(cinfo && cinfo->type == CREATURE_TYPE_DEMON && getClass() == CLASS_WARLOCK) - { - for(uint32 i = 0; i < CREATURE_MAX_SPELLS; ++i) - { - if(charmInfo->GetCharmSpell(i)->spellId) - ++addlist; - } - } - } - - WorldPacket data(SMSG_PET_SPELLS, 16+40+1+4*addlist+25);// first line + actionbar + spellcount + spells + last adds - - data << (uint64)charm->GetGUID() << uint32(0x00000000); - - if(charm->GetTypeId() != TYPEID_PLAYER) - data << uint8(charmInfo->GetReactState()) << uint8(charmInfo->GetCommandState()); - else - data << uint8(0) << uint8(0); - - data << uint16(0); - - for(uint32 i = 0; i < 10; i++) //40 - { - data << uint16(charmInfo->GetActionBarEntry(i)->SpellOrAction) << uint16(charmInfo->GetActionBarEntry(i)->Type); - } - - data << uint8(addlist); //1 - - if(addlist) - { - for(uint32 i = 0; i < CREATURE_MAX_SPELLS; ++i) - { - CharmSpellEntry *cspell = charmInfo->GetCharmSpell(i); - if(cspell->spellId) - { - data << uint16(cspell->spellId); - data << uint16(cspell->active); - } - } - } - - uint8 count = 3; - data << count; - data << uint32(0x6010) << uint64(0); // if count = 1, 2 or 3 - data << uint32(0x8e8c) << uint64(0); // if count = 3 - data << uint32(0x8e8b) << uint64(0); // if count = 3 - - GetSession()->SendPacket(&data); -} - -int32 Player::GetTotalFlatMods(uint32 spellId, SpellModOp op) -{ - SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellId); - if (!spellInfo) return 0; - int32 total = 0; - for (SpellModList::iterator itr = m_spellMods[op].begin(); itr != m_spellMods[op].end(); ++itr) - { - SpellModifier *mod = *itr; - - if(!IsAffectedBySpellmod(spellInfo,mod)) - continue; - - if (mod->type == SPELLMOD_FLAT) - total += mod->value; - } - return total; -} - -int32 Player::GetTotalPctMods(uint32 spellId, SpellModOp op) -{ - SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellId); - if (!spellInfo) return 0; - int32 total = 0; - for (SpellModList::iterator itr = m_spellMods[op].begin(); itr != m_spellMods[op].end(); ++itr) - { - SpellModifier *mod = *itr; - - if(!IsAffectedBySpellmod(spellInfo,mod)) - continue; - - if (mod->type == SPELLMOD_PCT) - total += mod->value; - } - return total; -} - -bool Player::IsAffectedBySpellmod(SpellEntry const *spellInfo, SpellModifier *mod, Spell const* spell) -{ - if (!mod || !spellInfo) - return false; - - if(mod->charges == -1 && mod->lastAffected ) // marked as expired but locked until spell casting finish - { - // prevent apply to any spell except spell that trigger expire - if(spell) - { - if(mod->lastAffected != spell) - return false; - } - else if(mod->lastAffected != FindCurrentSpellBySpellId(spellInfo->Id)) - return false; - } - - return spellmgr.IsAffectedBySpell(spellInfo,mod->spellId,mod->effectId,mod->mask); -} - -void Player::AddSpellMod(SpellModifier* mod, bool apply) -{ - uint16 Opcode= (mod->type == SPELLMOD_FLAT) ? SMSG_SET_FLAT_SPELL_MODIFIER : SMSG_SET_PCT_SPELL_MODIFIER; - - for(int eff=0;eff<64;++eff) - { - uint64 _mask = uint64(1) << eff; - if ( mod->mask & _mask) - { - int32 val = 0; - for (SpellModList::iterator itr = m_spellMods[mod->op].begin(); itr != m_spellMods[mod->op].end(); ++itr) - { - if ((*itr)->type == mod->type && (*itr)->mask & _mask) - val += (*itr)->value; - } - val += apply ? mod->value : -(mod->value); - WorldPacket data(Opcode, (1+1+4)); - data << uint8(eff); - data << uint8(mod->op); - data << int32(val); - SendDirectMessage(&data); - } - } - - if (apply) - m_spellMods[mod->op].push_back(mod); - else - { - if (mod->charges == -1) - --m_SpellModRemoveCount; - m_spellMods[mod->op].remove(mod); - delete mod; - } -} - -void Player::RemoveSpellMods(Spell const* spell) -{ - if(!spell || (m_SpellModRemoveCount == 0)) - return; - - for(int i=0;icharges == -1 && (mod->lastAffected == spell || mod->lastAffected==NULL)) - { - RemoveAurasDueToSpell(mod->spellId); - if (m_spellMods[i].empty()) - break; - else - itr = m_spellMods[i].begin(); - } - } - } -} - -// send Proficiency -void Player::SendProficiency(uint8 pr1, uint32 pr2) -{ - WorldPacket data(SMSG_SET_PROFICIENCY, 8); - data << pr1 << pr2; - GetSession()->SendPacket (&data); -} - -void Player::RemovePetitionsAndSigns(uint64 guid, uint32 type) -{ - QueryResult *result = NULL; - if(type==10) - result = CharacterDatabase.PQuery("SELECT ownerguid,petitionguid FROM petition_sign WHERE playerguid = '%u'", GUID_LOPART(guid)); - else - result = CharacterDatabase.PQuery("SELECT ownerguid,petitionguid FROM petition_sign WHERE playerguid = '%u' AND type = '%u'", GUID_LOPART(guid), type); - if(result) - { - do // this part effectively does nothing, since the deletion / modification only takes place _after_ the PetitionQuery. Though I don't know if the result remains intact if I execute the delete query beforehand. - { // and SendPetitionQueryOpcode reads data from the DB - Field *fields = result->Fetch(); - uint64 ownerguid = MAKE_NEW_GUID(fields[0].GetUInt32(), 0, HIGHGUID_PLAYER); - uint64 petitionguid = MAKE_NEW_GUID(fields[1].GetUInt32(), 0, HIGHGUID_ITEM); - - // send update if charter owner in game - Player* owner = objmgr.GetPlayer(ownerguid); - if(owner) - owner->GetSession()->SendPetitionQueryOpcode(petitionguid); - - } while ( result->NextRow() ); - - delete result; - - if(type==10) - CharacterDatabase.PExecute("DELETE FROM petition_sign WHERE playerguid = '%u'", GUID_LOPART(guid)); - else - CharacterDatabase.PExecute("DELETE FROM petition_sign WHERE playerguid = '%u' AND type = '%u'", GUID_LOPART(guid), type); - } - - CharacterDatabase.BeginTransaction(); - if(type == 10) - { - CharacterDatabase.PExecute("DELETE FROM petition WHERE ownerguid = '%u'", GUID_LOPART(guid)); - CharacterDatabase.PExecute("DELETE FROM petition_sign WHERE ownerguid = '%u'", GUID_LOPART(guid)); - } - else - { - CharacterDatabase.PExecute("DELETE FROM petition WHERE ownerguid = '%u' AND type = '%u'", GUID_LOPART(guid), type); - CharacterDatabase.PExecute("DELETE FROM petition_sign WHERE ownerguid = '%u' AND type = '%u'", GUID_LOPART(guid), type); - } - CharacterDatabase.CommitTransaction(); -} - -void Player::SetRestBonus (float rest_bonus_new) -{ - // Prevent resting on max level - if(getLevel() >= sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL)) - rest_bonus_new = 0; - - if(rest_bonus_new < 0) - rest_bonus_new = 0; - - float rest_bonus_max = (float)GetUInt32Value(PLAYER_NEXT_LEVEL_XP)*1.5/2; - - if(rest_bonus_new > rest_bonus_max) - m_rest_bonus = rest_bonus_max; - else - m_rest_bonus = rest_bonus_new; - - // update data for client - if(m_rest_bonus>10) - SetByteValue(PLAYER_BYTES_2, 3, 0x01); // Set Reststate = Rested - else if(m_rest_bonus<=1) - SetByteValue(PLAYER_BYTES_2, 3, 0x02); // Set Reststate = Normal - - //RestTickUpdate - SetUInt32Value(PLAYER_REST_STATE_EXPERIENCE, uint32(m_rest_bonus)); -} - -void Player::HandleStealthedUnitsDetection() -{ - std::list stealthedUnits; - - CellPair p(MaNGOS::ComputeCellPair(GetPositionX(),GetPositionY())); - Cell cell(p); - cell.data.Part.reserved = ALL_DISTRICT; - cell.SetNoCreate(); - - MaNGOS::AnyStealthedCheck u_check; - MaNGOS::UnitListSearcher searcher(stealthedUnits, u_check); - - TypeContainerVisitor, WorldTypeMapContainer > world_unit_searcher(searcher); - TypeContainerVisitor, GridTypeMapContainer > grid_unit_searcher(searcher); - - CellLock cell_lock(cell, p); - cell_lock->Visit(cell_lock, world_unit_searcher, *MapManager::Instance().GetMap(GetMapId(), this)); - cell_lock->Visit(cell_lock, grid_unit_searcher, *MapManager::Instance().GetMap(GetMapId(), this)); - - for (std::list::iterator i = stealthedUnits.begin(); i != stealthedUnits.end();) - { - if((*i)==this) - { - i = stealthedUnits.erase(i); - continue; - } - - if ((*i)->isVisibleForOrDetect(this,true)) - { - - (*i)->SendUpdateToPlayer(this); - m_clientGUIDs.insert((*i)->GetGUID()); - - #ifdef MANGOS_DEBUG - if((sLog.getLogFilter() & LOG_FILTER_VISIBILITY_CHANGES)==0) - sLog.outDebug("Object %u (Type: %u) is detected in stealth by player %u. Distance = %f",(*i)->GetGUIDLow(),(*i)->GetTypeId(),GetGUIDLow(),GetDistance(*i)); - #endif - - // target aura duration for caster show only if target exist at caster client - // send data at target visibility change (adding to client) - if((*i)!=this && (*i)->isType(TYPEMASK_UNIT)) - SendAuraDurationsForTarget(*i); - - i = stealthedUnits.erase(i); - continue; - } - - ++i; - } -} - -bool Player::ActivateTaxiPathTo(std::vector const& nodes, uint32 mount_id, Creature* npc) -{ - if(nodes.size() < 2) - return false; - - // not let cheating with start flight mounted - if(IsMounted()) - { - WorldPacket data(SMSG_ACTIVATETAXIREPLY, 4); - data << uint32(ERR_TAXIPLAYERALREADYMOUNTED); - GetSession()->SendPacket(&data); - return false; - } - - if( m_ShapeShiftFormSpellId && m_form != FORM_BATTLESTANCE && m_form != FORM_BERSERKERSTANCE && m_form != FORM_DEFENSIVESTANCE && m_form != FORM_SHADOW ) - { - WorldPacket data(SMSG_ACTIVATETAXIREPLY, 4); - data << uint32(ERR_TAXIPLAYERSHAPESHIFTED); - GetSession()->SendPacket(&data); - return false; - } - - // not let cheating with start flight in time of logout process || if casting not finished || while in combat || if not use Spell's with EffectSendTaxi - if(GetSession()->isLogingOut() || - (!m_currentSpells[CURRENT_GENERIC_SPELL] || - m_currentSpells[CURRENT_GENERIC_SPELL]->m_spellInfo->Effect[0] != SPELL_EFFECT_SEND_TAXI)&& - IsNonMeleeSpellCasted(false) || - isInCombat()) - { - WorldPacket data(SMSG_ACTIVATETAXIREPLY, 4); - data << uint32(ERR_TAXIPLAYERBUSY); - GetSession()->SendPacket(&data); - return false; - } - - if(HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_MOVE)) - return false; - - uint32 sourcenode = nodes[0]; - - // starting node too far away (cheat?) - TaxiNodesEntry const* node = sTaxiNodesStore.LookupEntry(sourcenode); - if( !node || node->map_id != GetMapId() || - (node->x - GetPositionX())*(node->x - GetPositionX())+ - (node->y - GetPositionY())*(node->y - GetPositionY())+ - (node->z - GetPositionZ())*(node->z - GetPositionZ()) > - (2*INTERACTION_DISTANCE)*(2*INTERACTION_DISTANCE)*(2*INTERACTION_DISTANCE) ) - { - WorldPacket data(SMSG_ACTIVATETAXIREPLY, 4); - data << uint32(ERR_TAXIUNSPECIFIEDSERVERERROR); - GetSession()->SendPacket(&data); - return false; - } - - // Prepare to flight start now - - // stop combat at start taxi flight if any - CombatStop(); - - // stop trade (client cancel trade at taxi map open but cheating tools can be used for reopen it) - TradeCancel(true); - - // clean not finished taxi path if any - m_taxi.ClearTaxiDestinations(); - - // 0 element current node - m_taxi.AddTaxiDestination(sourcenode); - - // fill destinations path tail - uint32 sourcepath = 0; - uint32 totalcost = 0; - - uint32 prevnode = sourcenode; - uint32 lastnode = 0; - - for(uint32 i = 1; i < nodes.size(); ++i) - { - uint32 path, cost; - - lastnode = nodes[i]; - objmgr.GetTaxiPath(prevnode, lastnode, path, cost); - - if(!path) - { - m_taxi.ClearTaxiDestinations(); - return false; - } - - totalcost += cost; - - if(prevnode == sourcenode) - sourcepath = path; - - m_taxi.AddTaxiDestination(lastnode); - - prevnode = lastnode; - } - - if(!mount_id) // if not provide then attempt use default. - mount_id = objmgr.GetTaxiMount(sourcenode, GetTeam()); - - if (mount_id == 0 || sourcepath == 0) - { - WorldPacket data(SMSG_ACTIVATETAXIREPLY, 4); - data << uint32(ERR_TAXIUNSPECIFIEDSERVERERROR); - GetSession()->SendPacket(&data); - m_taxi.ClearTaxiDestinations(); - return false; - } - - uint32 money = GetMoney(); - - if(npc) - { - totalcost = (uint32)ceil(totalcost*GetReputationPriceDiscount(npc)); - } - - if(money < totalcost) - { - WorldPacket data(SMSG_ACTIVATETAXIREPLY, 4); - data << uint32(ERR_TAXINOTENOUGHMONEY); - GetSession()->SendPacket(&data); - m_taxi.ClearTaxiDestinations(); - return false; - } - - //Checks and preparations done, DO FLIGHT - ModifyMoney(-(int32)totalcost); - - // prevent stealth flight - RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); - - WorldPacket data(SMSG_ACTIVATETAXIREPLY, 4); - data << uint32(ERR_TAXIOK); - GetSession()->SendPacket(&data); - - sLog.outDebug("WORLD: Sent SMSG_ACTIVATETAXIREPLY"); - - GetSession()->SendDoFlight(mount_id, sourcepath); - - return true; -} - -void Player::ProhibitSpellScholl(SpellSchoolMask idSchoolMask, uint32 unTimeMs ) -{ - // last check 2.0.10 - WorldPacket data(SMSG_SPELL_COOLDOWN, 8+1+m_spells.size()*8); - data << GetGUID(); - data << uint8(0x0); - time_t curTime = time(NULL); - for(PlayerSpellMap::const_iterator itr = m_spells.begin(); itr != m_spells.end(); ++itr) - { - if (itr->second->state == PLAYERSPELL_REMOVED) - continue; - uint32 unSpellId = itr->first; - SpellEntry const *spellInfo = sSpellStore.LookupEntry(unSpellId); - if (!spellInfo) - { - ASSERT(spellInfo); - continue; - } - - // Not send cooldown for this spells - if (spellInfo->Attributes & SPELL_ATTR_DISABLED_WHILE_ACTIVE) - continue; - - if((idSchoolMask & GetSpellSchoolMask(spellInfo)) && GetSpellCooldownDelay(unSpellId) < unTimeMs ) - { - data << unSpellId; - data << unTimeMs; // in m.secs - AddSpellCooldown(unSpellId, 0, curTime + unTimeMs/1000); - } - } - GetSession()->SendPacket(&data); -} - -void Player::InitDataForForm(bool reapplyMods) -{ - SpellShapeshiftEntry const* ssEntry = sSpellShapeshiftStore.LookupEntry(m_form); - if(ssEntry && ssEntry->attackSpeed) - { - SetAttackTime(BASE_ATTACK,ssEntry->attackSpeed); - SetAttackTime(OFF_ATTACK,ssEntry->attackSpeed); - SetAttackTime(RANGED_ATTACK, BASE_ATTACK_TIME); - } - else - SetRegularAttackTime(); - - switch(m_form) - { - case FORM_CAT: - { - if(getPowerType()!=POWER_ENERGY) - setPowerType(POWER_ENERGY); - break; - } - case FORM_BEAR: - case FORM_DIREBEAR: - { - if(getPowerType()!=POWER_RAGE) - setPowerType(POWER_RAGE); - break; - } - default: // 0, for example - { - ChrClassesEntry const* cEntry = sChrClassesStore.LookupEntry(getClass()); - if(cEntry && cEntry->powerType < MAX_POWERS && uint32(getPowerType()) != cEntry->powerType) - setPowerType(Powers(cEntry->powerType)); - break; - } - } - - // update auras at form change, ignore this at mods reapply (.reset stats/etc) when form not change. - if (!reapplyMods) - UpdateEquipSpellsAtFormChange(); - - UpdateAttackPowerAndDamage(); - UpdateAttackPowerAndDamage(true); -} - -// Return true is the bought item has a max count to force refresh of window by caller -bool Player::BuyItemFromVendor(uint64 vendorguid, uint32 item, uint8 count, uint64 bagguid, uint8 slot) -{ - // cheating attempt - if(count < 1) count = 1; - - if(!isAlive()) - return false; - - ItemPrototype const *pProto = objmgr.GetItemPrototype( item ); - if( !pProto ) - { - SendBuyError( BUY_ERR_CANT_FIND_ITEM, NULL, item, 0); - return false; - } - - Creature *pCreature = ObjectAccessor::GetNPCIfCanInteractWith(*this, vendorguid,UNIT_NPC_FLAG_VENDOR); - if (!pCreature) - { - sLog.outDebug( "WORLD: BuyItemFromVendor - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(vendorguid)) ); - SendBuyError( BUY_ERR_DISTANCE_TOO_FAR, NULL, item, 0); - return false; - } - - // load vendor items if not yet - pCreature->LoadGoods(); - - CreatureItem* crItem = pCreature->FindItem(item); - if(!crItem) - { - SendBuyError( BUY_ERR_CANT_FIND_ITEM, pCreature, item, 0); - return false; - } - - if( crItem->maxcount != 0 && crItem->count < count ) - { - SendBuyError( BUY_ERR_ITEM_ALREADY_SOLD, pCreature, item, 0); - return false; - } - - if( uint32(GetReputationRank(pProto->RequiredReputationFaction)) < pProto->RequiredReputationRank) - { - SendBuyError( BUY_ERR_REPUTATION_REQUIRE, pCreature, item, 0); - return false; - } - - if(crItem->ExtendedCost) - { - ItemExtendedCostEntry const* iece = sItemExtendedCostStore.LookupEntry(crItem->ExtendedCost); - if(!iece) - { - sLog.outError("Item %u have wrong ExtendedCost field value %u", pProto->ItemId, crItem->ExtendedCost); - return false; - } - - // honor points price - if(GetHonorPoints() < (iece->reqhonorpoints * count)) - { - SendEquipError(EQUIP_ERR_NOT_ENOUGH_HONOR_POINTS, NULL, NULL); - return false; - } - - // arena points price - if(GetArenaPoints() < (iece->reqarenapoints * count)) - { - SendEquipError(EQUIP_ERR_NOT_ENOUGH_ARENA_POINTS, NULL, NULL); - return false; - } - - // item base price - for (uint8 i = 0; i < 5; ++i) - { - if(iece->reqitem[i] && !HasItemCount(iece->reqitem[i], (iece->reqitemcount[i] * count))) - { - SendEquipError(EQUIP_ERR_VENDOR_MISSING_TURNINS, NULL, NULL); - return false; - } - } - - // check for personal arena rating requirement - if( GetMaxPersonalArenaRatingRequirement() < iece->reqpersonalarenarating ) - { - // probably not the proper equip err - SendEquipError(EQUIP_ERR_CANT_EQUIP_RANK,NULL,NULL); - return false; - } - } - - uint32 price = pProto->BuyPrice * count; - - // reputation discount - price = uint32(floor(price * GetReputationPriceDiscount(pCreature))); - - if( GetMoney() < price ) - { - SendBuyError( BUY_ERR_NOT_ENOUGHT_MONEY, pCreature, item, 0); - return false; - } - - uint8 bag = 0; // init for case invalid bagGUID - - if (bagguid != NULL_BAG && slot != NULL_SLOT) - { - Bag *pBag; - if( bagguid == GetGUID() ) - { - bag = INVENTORY_SLOT_BAG_0; - } - else - { - for (int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END;i++) - { - pBag = (Bag*)GetItemByPos(INVENTORY_SLOT_BAG_0,i); - if( pBag ) - { - if( bagguid == pBag->GetGUID() ) - { - bag = i; - break; - } - } - } - } - } - - if( IsInventoryPos( bag, slot ) || (bagguid == NULL_BAG && slot == NULL_SLOT) ) - { - ItemPosCountVec dest; - uint8 msg = CanStoreNewItem( bag, slot, dest, item, pProto->BuyCount * count ); - if( msg != EQUIP_ERR_OK ) - { - SendEquipError( msg, NULL, NULL ); - return false; - } - - ModifyMoney( -(int32)price ); - if(crItem->ExtendedCost) // case for new honor system - { - ItemExtendedCostEntry const* iece = sItemExtendedCostStore.LookupEntry(crItem->ExtendedCost); - if(iece->reqhonorpoints) - ModifyHonorPoints( - int32(iece->reqhonorpoints * count)); - if(iece->reqarenapoints) - ModifyArenaPoints( - int32(iece->reqarenapoints * count)); - for (uint8 i = 0; i < 5; ++i) - { - if(iece->reqitem[i]) - DestroyItemCount(iece->reqitem[i], (iece->reqitemcount[i] * count), true); - } - } - - if(Item *it = StoreNewItem( dest, item, true )) - { - if( crItem->maxcount != 0 ) - crItem->count -= pProto->BuyCount * count; - - WorldPacket data(SMSG_BUY_ITEM, (8+4+4+4)); - data << pCreature->GetGUID(); - data << (uint32)crItem->id; // entry - data << (uint32)crItem->count; - data << (uint32)count; - GetSession()->SendPacket(&data); - - SendNewItem(it, count, true, false, false); - } - } - else if( IsEquipmentPos( bag, slot ) ) - { - uint16 dest; - uint8 msg = CanEquipNewItem( slot, dest, item, pProto->BuyCount * count, false ); - if( msg != EQUIP_ERR_OK ) - { - SendEquipError( msg, NULL, NULL ); - return false; - } - - ModifyMoney( -(int32)price ); - if(crItem->ExtendedCost) // case for new honor system - { - ItemExtendedCostEntry const* iece = sItemExtendedCostStore.LookupEntry(crItem->ExtendedCost); - if(iece->reqhonorpoints) - ModifyHonorPoints( - int32(iece->reqhonorpoints)); - if(iece->reqarenapoints) - ModifyArenaPoints( - int32(iece->reqarenapoints)); - for (uint8 i = 0; i < 5; ++i) - { - if(iece->reqitem[i]) - DestroyItemCount(iece->reqitem[i], iece->reqitemcount[i], true); - } - } - - if(Item *it = EquipNewItem( dest, item, pProto->BuyCount * count, true )) - { - if( crItem->maxcount != 0 ) - crItem->count -= pProto->BuyCount * count; - - WorldPacket data(SMSG_BUY_ITEM, (8+4+4+4)); - data << pCreature->GetGUID(); - data << (uint32)crItem->id; // entry - data << (uint32)crItem->count; - data << (uint32)count; - GetSession()->SendPacket(&data); - - SendNewItem(it, count, true, false, false); - - AutoUnequipOffhandIfNeed(); - } - } - else - { - SendEquipError( EQUIP_ERR_ITEM_DOESNT_GO_TO_SLOT, NULL, NULL ); - return false; - } - - return crItem->maxcount!=0?true:false; -} - -uint32 Player::GetMaxPersonalArenaRatingRequirement() -{ - // returns the maximal personal arena rating that can be used to purchase items requiring this condition - // the personal rating of the arena team must match the required limit as well - // so return max[in arenateams](min(personalrating[teamtype], teamrating[teamtype])) - uint32 max_personal_rating = 0; - for(int i = 0; i < MAX_ARENA_SLOT; ++i) - { - if(ArenaTeam * at = objmgr.GetArenaTeamById(GetArenaTeamId(i))) - { - uint32 p_rating = GetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (i * 6) + 5); - uint32 t_rating = at->GetRating(); - p_rating = p_ratingSendPacket(&data); - } - // instance is valid, reset homebind timer - m_HomebindTimer = 0; - } - else if (m_HomebindTimer > 0) - { - if (time >= m_HomebindTimer) - { - // teleport to homebind location - TeleportTo(m_homebindMapId, m_homebindX, m_homebindY, m_homebindZ, GetOrientation()); - } - else - m_HomebindTimer -= time; - } - else - { - // instance is invalid, start homebind timer - m_HomebindTimer = 60000; - // send message to player - WorldPacket data(SMSG_RAID_GROUP_ONLY, 4+4); - data << m_HomebindTimer; - data << uint32(1); - GetSession()->SendPacket(&data); - sLog.outDebug("PLAYER: Player '%s' (GUID: %u) will be teleported to homebind in 60 seconds", GetName(),GetGUIDLow()); - } -} - -void Player::UpdatePvP(bool state, bool ovrride) -{ - if(!state || ovrride) - { - SetPvP(state); - if(Pet* pet = GetPet()) - pet->SetPvP(state); - if(Unit* charmed = GetCharm()) - charmed->SetPvP(state); - - pvpInfo.endTimer = 0; - } - else - { - if(pvpInfo.endTimer != 0) - pvpInfo.endTimer = time(NULL); - else - { - SetPvP(state); - - if(Pet* pet = GetPet()) - pet->SetPvP(state); - if(Unit* charmed = GetCharm()) - charmed->SetPvP(state); - } - } -} - -void Player::AddSpellCooldown(uint32 spellid, uint32 itemid, time_t end_time) -{ - SpellCooldown sc; - sc.end = end_time; - sc.itemid = itemid; - m_spellCooldowns[spellid] = sc; -} - -void Player::SendCooldownEvent(SpellEntry const *spellInfo) -{ - if ( !(spellInfo->Attributes & SPELL_ATTR_DISABLED_WHILE_ACTIVE) ) - return; - - // Get spell cooldwn - int32 cooldown = GetSpellRecoveryTime(spellInfo); - // Apply spellmods - ApplySpellMod(spellInfo->Id, SPELLMOD_COOLDOWN, cooldown); - if (cooldown < 0) - cooldown = 0; - // Add cooldown - AddSpellCooldown(spellInfo->Id, 0, time(NULL) + cooldown / 1000); - // Send activate - WorldPacket data(SMSG_COOLDOWN_EVENT, (4+8)); - data << spellInfo->Id; - data << GetGUID(); - SendDirectMessage(&data); -} - //slot to be excluded while counting -bool Player::EnchantmentFitsRequirements(uint32 enchantmentcondition, int8 slot) -{ - if(!enchantmentcondition) - return true; - - SpellItemEnchantmentConditionEntry const *Condition = sSpellItemEnchantmentConditionStore.LookupEntry(enchantmentcondition); - - if(!Condition) - return true; - - uint8 curcount[4] = {0, 0, 0, 0}; - - //counting current equipped gem colors - for(uint8 i = EQUIPMENT_SLOT_START; i < EQUIPMENT_SLOT_END; ++i) - { - if(i == slot) - continue; - Item *pItem2 = GetItemByPos( INVENTORY_SLOT_BAG_0, i ); - if(pItem2 && pItem2->GetProto()->Socket[0].Color) - { - for(uint32 enchant_slot = SOCK_ENCHANTMENT_SLOT; enchant_slot < SOCK_ENCHANTMENT_SLOT+3; ++enchant_slot) - { - uint32 enchant_id = pItem2->GetEnchantmentId(EnchantmentSlot(enchant_slot)); - if(!enchant_id) - continue; - - SpellItemEnchantmentEntry const* enchantEntry = sSpellItemEnchantmentStore.LookupEntry(enchant_id); - if(!enchantEntry) - continue; - - uint32 gemid = enchantEntry->GemID; - if(!gemid) - continue; - - ItemPrototype const* gemProto = sItemStorage.LookupEntry(gemid); - if(!gemProto) - continue; - - GemPropertiesEntry const* gemProperty = sGemPropertiesStore.LookupEntry(gemProto->GemProperties); - if(!gemProperty) - continue; - - uint8 GemColor = gemProperty->color; - - for(uint8 b = 0, tmpcolormask = 1; b < 4; b++, tmpcolormask <<= 1) - { - if(tmpcolormask & GemColor) - ++curcount[b]; - } - } - } - } - - bool activate = true; - - for(int i = 0; i < 5; i++) - { - if(!Condition->Color[i]) - continue; - - uint32 _cur_gem = curcount[Condition->Color[i] - 1]; - - // if have use them as count, else use from Condition - uint32 _cmp_gem = Condition->CompareColor[i] ? curcount[Condition->CompareColor[i] - 1]: Condition->Value[i]; - - switch(Condition->Comparator[i]) - { - case 2: // requires less than ( || ) gems - activate &= (_cur_gem < _cmp_gem) ? true : false; - break; - case 3: // requires more than ( || ) gems - activate &= (_cur_gem > _cmp_gem) ? true : false; - break; - case 5: // requires at least than ( || ) gems - activate &= (_cur_gem >= _cmp_gem) ? true : false; - break; - } - } - - sLog.outDebug("Checking Condition %u, there are %u Meta Gems, %u Red Gems, %u Yellow Gems and %u Blue Gems, Activate:%s", enchantmentcondition, curcount[0], curcount[1], curcount[2], curcount[3], activate ? "yes" : "no"); - - return activate; -} - -void Player::CorrectMetaGemEnchants(uint8 exceptslot, bool apply) -{ - //cycle all equipped items - for(uint32 slot = EQUIPMENT_SLOT_START; slot < EQUIPMENT_SLOT_END; ++slot) - { - //enchants for the slot being socketed are handled by Player::ApplyItemMods - if(slot == exceptslot) - continue; - - Item* pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, slot ); - - if(!pItem || !pItem->GetProto()->Socket[0].Color) - continue; - - for(uint32 enchant_slot = SOCK_ENCHANTMENT_SLOT; enchant_slot < SOCK_ENCHANTMENT_SLOT+3; ++enchant_slot) - { - uint32 enchant_id = pItem->GetEnchantmentId(EnchantmentSlot(enchant_slot)); - if(!enchant_id) - continue; - - SpellItemEnchantmentEntry const* enchantEntry = sSpellItemEnchantmentStore.LookupEntry(enchant_id); - if(!enchantEntry) - continue; - - uint32 condition = enchantEntry->EnchantmentCondition; - if(condition) - { - //was enchant active with/without item? - bool wasactive = EnchantmentFitsRequirements(condition, apply ? exceptslot : -1); - //should it now be? - if(wasactive ^ EnchantmentFitsRequirements(condition, apply ? -1 : exceptslot)) - { - // ignore item gem conditions - //if state changed, (dis)apply enchant - ApplyEnchantment(pItem,EnchantmentSlot(enchant_slot),!wasactive,true,true); - } - } - } - } -} - - //if false -> then toggled off if was on| if true -> toggled on if was off AND meets requirements -void Player::ToggleMetaGemsActive(uint8 exceptslot, bool apply) -{ - //cycle all equipped items - for(int slot = EQUIPMENT_SLOT_START; slot < EQUIPMENT_SLOT_END; ++slot) - { - //enchants for the slot being socketed are handled by WorldSession::HandleSocketOpcode(WorldPacket& recv_data) - if(slot == exceptslot) - continue; - - Item *pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, slot ); - - if(!pItem || !pItem->GetProto()->Socket[0].Color) //if item has no sockets or no item is equipped go to next item - continue; - - //cycle all (gem)enchants - for(uint32 enchant_slot = SOCK_ENCHANTMENT_SLOT; enchant_slot < SOCK_ENCHANTMENT_SLOT+3; ++enchant_slot) - { - uint32 enchant_id = pItem->GetEnchantmentId(EnchantmentSlot(enchant_slot)); - if(!enchant_id) //if no enchant go to next enchant(slot) - continue; - - SpellItemEnchantmentEntry const* enchantEntry = sSpellItemEnchantmentStore.LookupEntry(enchant_id); - if(!enchantEntry) - continue; - - //only metagems to be (de)activated, so only enchants with condition - uint32 condition = enchantEntry->EnchantmentCondition; - if(condition) - ApplyEnchantment(pItem,EnchantmentSlot(enchant_slot), apply); - } - } -} - -void Player::LeaveBattleground(bool teleportToEntryPoint) -{ - if(BattleGround *bg = GetBattleGround()) - { - bool need_debuf = bg->isBattleGround() && (bg->GetStatus() == STATUS_IN_PROGRESS) && sWorld.getConfig(CONFIG_BATTLEGROUND_CAST_DESERTER); - - bg->RemovePlayerAtLeave(GetGUID(), teleportToEntryPoint, true); - - // call after remove to be sure that player resurrected for correct cast - if(need_debuf) - CastSpell(this, 26013, true); // Deserter - } -} - -bool Player::CanJoinToBattleground() const -{ - // check Deserter debuff - if(GetDummyAura(26013)) - return false; - - return true; -} - -bool Player::CanReportAfkDueToLimit() -{ - // a player can complain about 15 people per 5 minutes - if(m_bgAfkReportedCount >= 15) - return false; - ++m_bgAfkReportedCount; - return true; -} - -///This player has been blamed to be inactive in a battleground -void Player::ReportedAfkBy(Player* reporter) -{ - BattleGround *bg = GetBattleGround(); - if(!bg || bg != reporter->GetBattleGround() || GetTeam() != reporter->GetTeam()) - return; - - // check if player has 'Idle' or 'Inactive' debuff - if(m_bgAfkReporter.find(reporter->GetGUIDLow())==m_bgAfkReporter.end() && !HasAura(43680,0) && !HasAura(43681,0) && reporter->CanReportAfkDueToLimit()) - { - m_bgAfkReporter.insert(reporter->GetGUIDLow()); - // 3 players have to complain to apply debuff - if(m_bgAfkReporter.size() >= 3) - { - // cast 'Idle' spell - CastSpell(this, 43680, true); - m_bgAfkReporter.clear(); - } - } -} - -bool Player::IsVisibleInGridForPlayer( Player* pl ) const -{ - // gamemaster in GM mode see all, including ghosts - if(pl->isGameMaster() && GetSession()->GetSecurity() <= pl->GetSession()->GetSecurity()) - return true; - - // It seems in battleground everyone sees everyone, except the enemy-faction ghosts - if (InBattleGround()) - { - if (!(isAlive() || m_deathTimer > 0) && !IsFriendlyTo(pl) ) - return false; - return true; - } - - // Live player see live player or dead player with not realized corpse - if(pl->isAlive() || pl->m_deathTimer > 0) - { - return isAlive() || m_deathTimer > 0; - } - - // Ghost see other friendly ghosts, that's for sure - if(!(isAlive() || m_deathTimer > 0) && IsFriendlyTo(pl)) - return true; - - // Dead player see live players near own corpse - if(isAlive()) - { - Corpse *corpse = pl->GetCorpse(); - if(corpse) - { - // 20 - aggro distance for same level, 25 - max additional distance if player level less that creature level - if(corpse->IsWithinDistInMap(this,(20+25)*sWorld.getRate(RATE_CREATURE_AGGRO))) - return true; - } - } - - // and not see any other - return false; -} - -bool Player::IsVisibleGloballyFor( Player* u ) const -{ - if(!u) - return false; - - // Always can see self - if (u==this) - return true; - - // Visible units, always are visible for all players - if (GetVisibility() == VISIBILITY_ON) - return true; - - // GMs are visible for higher gms (or players are visible for gms) - if (u->GetSession()->GetSecurity() > SEC_PLAYER) - return GetSession()->GetSecurity() <= u->GetSession()->GetSecurity(); - - // non faction visibility non-breakable for non-GMs - if (GetVisibility() == VISIBILITY_OFF) - return false; - - // non-gm stealth/invisibility not hide from global player lists - return true; -} - -void Player::UpdateVisibilityOf(WorldObject* target) -{ - if(HaveAtClient(target)) - { - if(!target->isVisibleForInState(this,true)) - { - target->DestroyForPlayer(this); - m_clientGUIDs.erase(target->GetGUID()); - - #ifdef MANGOS_DEBUG - if((sLog.getLogFilter() & LOG_FILTER_VISIBILITY_CHANGES)==0) - sLog.outDebug("Object %u (Type: %u) out of range for player %u. Distance = %f",target->GetGUIDLow(),target->GetTypeId(),GetGUIDLow(),GetDistance(target)); - #endif - } - } - else - { - if(target->isVisibleForInState(this,false)) - { - target->SendUpdateToPlayer(this); - if(target->GetTypeId()!=TYPEID_GAMEOBJECT||!((GameObject*)target)->IsTransport()) - m_clientGUIDs.insert(target->GetGUID()); - - #ifdef MANGOS_DEBUG - if((sLog.getLogFilter() & LOG_FILTER_VISIBILITY_CHANGES)==0) - sLog.outDebug("Object %u (Type: %u) is visible now for player %u. Distance = %f",target->GetGUIDLow(),target->GetTypeId(),GetGUIDLow(),GetDistance(target)); - #endif - - // target aura duration for caster show only if target exist at caster client - // send data at target visibility change (adding to client) - if(target!=this && target->isType(TYPEMASK_UNIT)) - SendAuraDurationsForTarget((Unit*)target); - - if(target->GetTypeId()==TYPEID_UNIT && ((Creature*)target)->isAlive()) - ((Creature*)target)->SendMonsterMoveWithSpeedToCurrentDestination(this); - } - } -} - -template -inline void UpdateVisibilityOf_helper(std::set& s64, T* target) -{ - s64.insert(target->GetGUID()); -} - -template<> -inline void UpdateVisibilityOf_helper(std::set& s64, GameObject* target) -{ - if(!target->IsTransport()) - s64.insert(target->GetGUID()); -} - -template -void Player::UpdateVisibilityOf(T* target, UpdateData& data, UpdateDataMapType& data_updates, std::set& visibleNow) -{ - if(HaveAtClient(target)) - { - if(!target->isVisibleForInState(this,true)) - { - target->BuildOutOfRangeUpdateBlock(&data); - m_clientGUIDs.erase(target->GetGUID()); - - #ifdef MANGOS_DEBUG - if((sLog.getLogFilter() & LOG_FILTER_VISIBILITY_CHANGES)==0) - sLog.outDebug("Object %u (Type: %u, Entry: %u) is out of range for player %u. Distance = %f",target->GetGUIDLow(),target->GetTypeId(),target->GetEntry(),GetGUIDLow(),GetDistance(target)); - #endif - } - } - else - { - if(target->isVisibleForInState(this,false)) - { - visibleNow.insert(target); - target->BuildUpdate(data_updates); - target->BuildCreateUpdateBlockForPlayer(&data, this); - UpdateVisibilityOf_helper(m_clientGUIDs,target); - - #ifdef MANGOS_DEBUG - if((sLog.getLogFilter() & LOG_FILTER_VISIBILITY_CHANGES)==0) - sLog.outDebug("Object %u (Type: %u, Entry: %u) is visible now for player %u. Distance = %f",target->GetGUIDLow(),target->GetTypeId(),target->GetEntry(),GetGUIDLow(),GetDistance(target)); - #endif - } - } -} - -template void Player::UpdateVisibilityOf(Player* target, UpdateData& data, UpdateDataMapType& data_updates, std::set& visibleNow); -template void Player::UpdateVisibilityOf(Creature* target, UpdateData& data, UpdateDataMapType& data_updates, std::set& visibleNow); -template void Player::UpdateVisibilityOf(Corpse* target, UpdateData& data, UpdateDataMapType& data_updates, std::set& visibleNow); -template void Player::UpdateVisibilityOf(GameObject* target, UpdateData& data, UpdateDataMapType& data_updates, std::set& visibleNow); -template void Player::UpdateVisibilityOf(DynamicObject* target, UpdateData& data, UpdateDataMapType& data_updates, std::set& visibleNow); - -void Player::InitPrimaryProffesions() -{ - SetFreePrimaryProffesions(sWorld.getConfig(CONFIG_MAX_PRIMARY_TRADE_SKILL)); -} - -void Player::SendComboPoints() -{ - Unit *combotarget = ObjectAccessor::GetUnit(*this, m_comboTarget); - if (combotarget) - { - WorldPacket data(SMSG_UPDATE_COMBO_POINTS, combotarget->GetPackGUID().size()+1); - data.append(combotarget->GetPackGUID()); - data << uint8(m_comboPoints); - GetSession()->SendPacket(&data); - } -} - -void Player::AddComboPoints(Unit* target, int8 count) -{ - if(!count) - return; - - // without combo points lost (duration checked in aura) - RemoveSpellsCausingAura(SPELL_AURA_RETAIN_COMBO_POINTS); - - if(target->GetGUID() == m_comboTarget) - { - m_comboPoints += count; - } - else - { - if(m_comboTarget) - if(Unit* target = ObjectAccessor::GetUnit(*this,m_comboTarget)) - target->RemoveComboPointHolder(GetGUIDLow()); - - m_comboTarget = target->GetGUID(); - m_comboPoints = count; - - target->AddComboPointHolder(GetGUIDLow()); - } - - if (m_comboPoints > 5) m_comboPoints = 5; - if (m_comboPoints < 0) m_comboPoints = 0; - - SendComboPoints(); -} - -void Player::ClearComboPoints() -{ - if(!m_comboTarget) - return; - - // without combopoints lost (duration checked in aura) - RemoveSpellsCausingAura(SPELL_AURA_RETAIN_COMBO_POINTS); - - m_comboPoints = 0; - - SendComboPoints(); - - if(Unit* target = ObjectAccessor::GetUnit(*this,m_comboTarget)) - target->RemoveComboPointHolder(GetGUIDLow()); - - m_comboTarget = 0; -} - -void Player::SetGroup(Group *group, int8 subgroup) -{ - if(group == NULL) m_group.unlink(); - else - { - // never use SetGroup without a subgroup unless you specify NULL for group - assert(subgroup >= 0); - m_group.link(group, this); - m_group.setSubGroup((uint8)subgroup); - } -} - -void Player::SendInitialPacketsBeforeAddToMap() -{ - WorldPacket data(SMSG_SET_REST_START, 4); - data << uint32(0); // unknown, may be rest state time or expirience - GetSession()->SendPacket(&data); - - // Homebind - data.Initialize(SMSG_BINDPOINTUPDATE, 5*4); - data << m_homebindX << m_homebindY << m_homebindZ; - data << (uint32) m_homebindMapId; - data << (uint32) m_homebindZoneId; - GetSession()->SendPacket(&data); - - // SMSG_SET_PROFICIENCY - // SMSG_UPDATE_AURA_DURATION - - // tutorial stuff - data.Initialize(SMSG_TUTORIAL_FLAGS, 8*4); - for (int i = 0; i < 8; ++i) - data << uint32( GetTutorialInt(i) ); - GetSession()->SendPacket(&data); - - SendInitialSpells(); - - data.Initialize(SMSG_SEND_UNLEARN_SPELLS, 4); - data << uint32(0); // count, for(count) uint32; - GetSession()->SendPacket(&data); - - SendInitialActionButtons(); - SendInitialReputations(); - UpdateZone(GetZoneId()); - SendInitWorldStates(); - - // SMSG_SET_AURA_SINGLE - - data.Initialize(SMSG_LOGIN_SETTIMESPEED, 8); - data << uint32(secsToTimeBitFields(sWorld.GetGameTime())); - data << (float)0.01666667f; // game speed - GetSession()->SendPacket( &data ); -} - -void Player::SendInitialPacketsAfterAddToMap() -{ - CastSpell(this, 836, true); // LOGINEFFECT - - // set some aura effects that send packet to player client after add player to map - // SendMessageToSet not send it to player not it map, only for aura that not changed anything at re-apply - // same auras state lost at far teleport, send it one more time in this case also - static const AuraType auratypes[] = - { - SPELL_AURA_MOD_FEAR, SPELL_AURA_TRANSFORM, SPELL_AURA_WATER_WALK, - SPELL_AURA_FEATHER_FALL, SPELL_AURA_HOVER, SPELL_AURA_SAFE_FALL, - SPELL_AURA_FLY, SPELL_AURA_NONE - }; - for(AuraType const* itr = &auratypes[0]; itr && itr[0] != SPELL_AURA_NONE; ++itr) - { - Unit::AuraList const& auraList = GetAurasByType(*itr); - if(!auraList.empty()) - auraList.front()->ApplyModifier(true,true); - } - - if(HasAuraType(SPELL_AURA_MOD_STUN)) - SetMovement(MOVE_ROOT); - - // manual send package (have code in ApplyModifier(true,true); that don't must be re-applied. - if(HasAuraType(SPELL_AURA_MOD_ROOT)) - { - WorldPacket data(SMSG_FORCE_MOVE_ROOT, 10); - data.append(GetPackGUID()); - data << (uint32)2; - SendMessageToSet(&data,true); - } - - SendEnchantmentDurations(); // must be after add to map - SendItemDurations(); // must be after add to map -} - -void Player::SendUpdateToOutOfRangeGroupMembers() -{ - if (m_groupUpdateMask == GROUP_UPDATE_FLAG_NONE) - return; - if(Group* group = GetGroup()) - group->UpdatePlayerOutOfRange(this); - - m_groupUpdateMask = GROUP_UPDATE_FLAG_NONE; - m_auraUpdateMask = 0; - if(Pet *pet = GetPet()) - pet->ResetAuraUpdateMask(); -} - -void Player::SendTransferAborted(uint32 mapid, uint16 reason) -{ - WorldPacket data(SMSG_TRANSFER_ABORTED, 4+2); - data << uint32(mapid); - data << uint16(reason); // transfer abort reason - GetSession()->SendPacket(&data); -} - -void Player::SendInstanceResetWarning(uint32 mapid, uint32 time) -{ - // type of warning, based on the time remaining until reset - uint32 type; - if(time > 3600) - type = RAID_INSTANCE_WELCOME; - else if(time > 900 && time <= 3600) - type = RAID_INSTANCE_WARNING_HOURS; - else if(time > 300 && time <= 900) - type = RAID_INSTANCE_WARNING_MIN; - else - type = RAID_INSTANCE_WARNING_MIN_SOON; - WorldPacket data(SMSG_RAID_INSTANCE_MESSAGE, 4+4+4); - data << uint32(type); - data << uint32(mapid); - data << uint32(time); - GetSession()->SendPacket(&data); -} - -void Player::ApplyEquipCooldown( Item * pItem ) -{ - for(int i = 0; i <5; ++i) - { - _Spell const& spellData = pItem->GetProto()->Spells[i]; - - // no spell - if( !spellData.SpellId ) - continue; - - // wrong triggering type (note: ITEM_SPELLTRIGGER_ON_NO_DELAY_USE not have cooldown) - if( spellData.SpellTrigger != ITEM_SPELLTRIGGER_ON_USE ) - continue; - - AddSpellCooldown(spellData.SpellId, pItem->GetEntry(), time(NULL) + 30); - - WorldPacket data(SMSG_ITEM_COOLDOWN, 12); - data << pItem->GetGUID(); - data << uint32(spellData.SpellId); - GetSession()->SendPacket(&data); - } -} - -void Player::resetSpells() -{ - // not need after this call - if(HasAtLoginFlag(AT_LOGIN_RESET_SPELLS)) - { - m_atLoginFlags = m_atLoginFlags & ~AT_LOGIN_RESET_SPELLS; - CharacterDatabase.PExecute("UPDATE characters SET at_login = at_login & ~ %u WHERE guid ='%u'", uint32(AT_LOGIN_RESET_SPELLS), GetGUIDLow()); - } - - // make full copy of map (spells removed and marked as deleted at another spell remove - // and we can't use original map for safe iterative with visit each spell at loop end - PlayerSpellMap smap = GetSpellMap(); - - for(PlayerSpellMap::const_iterator iter = smap.begin();iter != smap.end(); ++iter) - removeSpell(iter->first); // only iter->first can be accessed, object by iter->second can be deleted already - - learnDefaultSpells(); - learnQuestRewardedSpells(); -} - -void Player::learnDefaultSpells(bool loading) -{ - // learn default race/class spells - PlayerInfo const *info = objmgr.GetPlayerInfo(getRace(),getClass()); - std::list::const_iterator spell_itr; - for (spell_itr = info->spell.begin(); spell_itr!=info->spell.end(); ++spell_itr) - { - uint16 tspell = spell_itr->first; - if (tspell) - { - sLog.outDebug("PLAYER: Adding initial spell, id = %u",tspell); - if(loading || !spell_itr->second) // not care about passive spells or loading case - addSpell(tspell,spell_itr->second); - else // but send in normal spell in game learn case - learnSpell(tspell); - } - } -} - -void Player::learnQuestRewardedSpells(Quest const* quest) -{ - uint32 spell_id = quest->GetRewSpellCast(); - - // skip quests without rewarded spell - if( !spell_id ) - return; - - SpellEntry const *spellInfo = sSpellStore.LookupEntry(spell_id); - if(!spellInfo) - return; - - // check learned spells state - bool found = false; - for(int i=0; i < 3; ++i) - { - if(spellInfo->Effect[i] == SPELL_EFFECT_LEARN_SPELL && !HasSpell(spellInfo->EffectTriggerSpell[i])) - { - found = true; - break; - } - } - - // skip quests with not teaching spell or already known spell - if(!found) - return; - - // prevent learn non first rank unknown profession and second specialization for same profession) - uint32 learned_0 = spellInfo->EffectTriggerSpell[0]; - if( spellmgr.GetSpellRank(learned_0) > 1 && !HasSpell(learned_0) ) - { - // not have first rank learned (unlearned prof?) - uint32 first_spell = spellmgr.GetFirstSpellInChain(learned_0); - if( !HasSpell(first_spell) ) - return; - - SpellEntry const *learnedInfo = sSpellStore.LookupEntry(learned_0); - if(!learnedInfo) - return; - - // specialization - if(learnedInfo->Effect[0]==SPELL_EFFECT_TRADE_SKILL && learnedInfo->Effect[1]==0) - { - // search other specialization for same prof - for(PlayerSpellMap::const_iterator itr = m_spells.begin(); itr != m_spells.end(); ++itr) - { - if(itr->second->state == PLAYERSPELL_REMOVED || itr->first==learned_0) - continue; - - SpellEntry const *itrInfo = sSpellStore.LookupEntry(itr->first); - if(!itrInfo) - return; - - // compare only specializations - if(itrInfo->Effect[0]!=SPELL_EFFECT_TRADE_SKILL || itrInfo->Effect[1]!=0) - continue; - - // compare same chain spells - if(spellmgr.GetFirstSpellInChain(itr->first) != first_spell) - continue; - - // now we have 2 specialization, learn possible only if found is lesser specialization rank - if(!spellmgr.IsHighRankOfSpell(learned_0,itr->first)) - return; - } - } - } - - CastSpell( this, spell_id, true); -} - -void Player::learnQuestRewardedSpells() -{ - // learn spells received from quest completing - for(QuestStatusMap::const_iterator itr = mQuestStatus.begin(); itr != mQuestStatus.end(); ++itr) - { - // skip no rewarded quests - if(!itr->second.m_rewarded) - continue; - - Quest const* quest = objmgr.GetQuestTemplate(itr->first); - if( !quest ) - continue; - - learnQuestRewardedSpells(quest); - } -} - -void Player::learnSkillRewardedSpells(uint32 skill_id ) -{ - uint32 raceMask = getRaceMask(); - uint32 classMask = getClassMask(); - for (uint32 j=0; jskillId!=skill_id || pAbility->learnOnGetSkill != ABILITY_LEARNED_ON_GET_PROFESSION_SKILL) - continue; - // Check race if set - if (pAbility->racemask && !(pAbility->racemask & raceMask)) - continue; - // Check class if set - if (pAbility->classmask && !(pAbility->classmask & classMask)) - continue; - - if (SpellEntry const* spellentry = sSpellStore.LookupEntry(pAbility->spellId)) - { - // Ok need learn spell - learnSpell(pAbility->spellId); - } - } -} - -void Player::learnSkillRewardedSpells() -{ - for (uint16 i=0; i < PLAYER_MAX_SKILLS; i++) - { - if(!GetUInt32Value(PLAYER_SKILL_INDEX(i))) - continue; - - uint32 pskill = GetUInt32Value(PLAYER_SKILL_INDEX(i)) & 0x0000FFFF; - - learnSkillRewardedSpells(pskill); - } -} - -void Player::SendAuraDurationsForTarget(Unit* target) -{ - for(Unit::AuraMap::const_iterator itr = target->GetAuras().begin(); itr != target->GetAuras().end(); ++itr) - { - Aura* aura = itr->second; - if(aura->GetAuraSlot() >= MAX_AURAS || aura->IsPassive() || aura->GetCasterGUID()!=GetGUID()) - continue; - - aura->SendAuraDurationForCaster(this); - } -} - -void Player::SetDailyQuestStatus( uint32 quest_id ) -{ - for(uint32 quest_daily_idx = 0; quest_daily_idx < PLAYER_MAX_DAILY_QUESTS; ++quest_daily_idx) - { - if(!GetUInt32Value(PLAYER_FIELD_DAILY_QUESTS_1+quest_daily_idx)) - { - SetUInt32Value(PLAYER_FIELD_DAILY_QUESTS_1+quest_daily_idx,quest_id); - m_lastDailyQuestTime = time(NULL); // last daily quest time - m_DailyQuestChanged = true; - break; - } - } -} - -void Player::ResetDailyQuestStatus() -{ - for(uint32 quest_daily_idx = 0; quest_daily_idx < PLAYER_MAX_DAILY_QUESTS; ++quest_daily_idx) - SetUInt32Value(PLAYER_FIELD_DAILY_QUESTS_1+quest_daily_idx,0); - - // DB data deleted in caller - m_DailyQuestChanged = false; - m_lastDailyQuestTime = 0; -} - -BattleGround* Player::GetBattleGround() const -{ - if(GetBattleGroundId()==0) - return NULL; - - return sBattleGroundMgr.GetBattleGround(GetBattleGroundId()); -} - -bool Player::InArena() const -{ - BattleGround *bg = GetBattleGround(); - if(!bg || !bg->isArena()) - return false; - - return true; -} - -bool Player::GetBGAccessByLevel(uint32 bgTypeId) const -{ - BattleGround *bg = sBattleGroundMgr.GetBattleGround(bgTypeId); - if(!bg) - return false; - - if(getLevel() < bg->GetMinLevel() || getLevel() > bg->GetMaxLevel()) - return false; - - return true; -} - -uint32 Player::GetMinLevelForBattleGroundQueueId(uint32 queue_id) -{ - if(queue_id < 1) - return 0; - - if(queue_id >=6) - queue_id = 6; - - return 10*(queue_id+1); -} - -uint32 Player::GetMaxLevelForBattleGroundQueueId(uint32 queue_id) -{ - if(queue_id >=6) - return 255; // hardcoded max level - - return 10*(queue_id+2)-1; -} - -uint32 Player::GetBattleGroundQueueIdFromLevel() const -{ - uint32 level = getLevel(); - if(level <= 19) - return 0; - else if (level > 69) - return 6; - else - return level/10 - 1; // 20..29 -> 1, 30-39 -> 2, ... -} - -float Player::GetReputationPriceDiscount( Creature const* pCreature ) const -{ - FactionTemplateEntry const* vendor_faction = pCreature->getFactionTemplateEntry(); - if(!vendor_faction) - return 1.0f; - - ReputationRank rank = GetReputationRank(vendor_faction->faction); - if(rank <= REP_NEUTRAL) - return 1.0f; - - return 1.0f - 0.05f* (rank - REP_NEUTRAL); -} - -bool Player::IsSpellFitByClassAndRace( uint32 spell_id ) const -{ - uint32 racemask = getRaceMask(); - uint32 classmask = getClassMask(); - - SkillLineAbilityMap::const_iterator lower = spellmgr.GetBeginSkillLineAbilityMap(spell_id); - SkillLineAbilityMap::const_iterator upper = spellmgr.GetEndSkillLineAbilityMap(spell_id); - - for(SkillLineAbilityMap::const_iterator _spell_idx = lower; _spell_idx != upper; ++_spell_idx) - { - // skip wrong race skills - if( _spell_idx->second->racemask && (_spell_idx->second->racemask & racemask) == 0) - return false; - - // skip wrong class skills - if( _spell_idx->second->classmask && (_spell_idx->second->classmask & classmask) == 0) - return false; - } - return true; -} - -bool Player::HasQuestForGO(int32 GOId) -{ - for( QuestStatusMap::iterator i = mQuestStatus.begin( ); i != mQuestStatus.end( ); ++i ) - { - QuestStatusData qs=i->second; - if (qs.m_status == QUEST_STATUS_INCOMPLETE) - { - Quest const* qinfo = objmgr.GetQuestTemplate(i->first); - if(!qinfo) - continue; - - if(GetGroup() && GetGroup()->isRaidGroup() && qinfo->GetType() != QUEST_TYPE_RAID) - continue; - - for (int j = 0; j < QUEST_OBJECTIVES_COUNT; j++) - { - if (qinfo->ReqCreatureOrGOId[j]>=0) //skip non GO case - continue; - - if((-1)*GOId == qinfo->ReqCreatureOrGOId[j] && qs.m_creatureOrGOcount[j] < qinfo->ReqCreatureOrGOCount[j]) - return true; - } - } - } - return false; -} - -void Player::UpdateForQuestsGO() -{ - if(m_clientGUIDs.empty()) - return; - - UpdateData udata; - WorldPacket packet; - for(ClientGUIDs::iterator itr=m_clientGUIDs.begin(); itr!=m_clientGUIDs.end(); ++itr) - { - if(IS_GAMEOBJECT_GUID(*itr)) - { - GameObject *obj = HashMapHolder::Find(*itr); - if(obj) - obj->BuildValuesUpdateBlockForPlayer(&udata,this); - } - } - udata.BuildPacket(&packet); - GetSession()->SendPacket(&packet); -} - -void Player::SummonIfPossible(bool agree) -{ - if(!agree) - { - m_summon_expire = 0; - return; - } - - // expire and auto declined - if(m_summon_expire < time(NULL)) - return; - - // stop taxi flight at summon - if(isInFlight()) - { - GetMotionMaster()->MovementExpired(); - m_taxi.ClearTaxiDestinations(); - } - - // drop flag at summon - if(BattleGround *bg = GetBattleGround()) - bg->EventPlayerDroppedFlag(this); - - m_summon_expire = 0; - - TeleportTo(m_summon_mapid, m_summon_x, m_summon_y, m_summon_z,GetOrientation()); -} - -void Player::RemoveItemDurations( Item *item ) -{ - for(ItemDurationList::iterator itr = m_itemDuration.begin();itr != m_itemDuration.end(); ++itr) - { - if(*itr==item) - { - m_itemDuration.erase(itr); - break; - } - } -} - -void Player::AddItemDurations( Item *item ) -{ - if(item->GetUInt32Value(ITEM_FIELD_DURATION)) - { - m_itemDuration.push_back(item); - item->SendTimeUpdate(this); - } -} - -void Player::AutoUnequipOffhandIfNeed() -{ - Item *offItem = GetItemByPos( INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND ); - if(!offItem) - return; - - Item *mainItem = GetItemByPos( INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_MAINHAND ); - - if(!mainItem || mainItem->GetProto()->InventoryType != INVTYPE_2HWEAPON) - return; - - ItemPosCountVec off_dest; - uint8 off_msg = CanStoreItem( NULL_BAG, NULL_SLOT, off_dest, offItem, false ); - if( off_msg == EQUIP_ERR_OK ) - { - RemoveItem(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND, true); - StoreItem( off_dest, offItem, true ); - } - else - { - sLog.outError("Player::EquipItem: Can's store offhand item at 2hand item equip for player (GUID: %u).",GetGUIDLow()); - } -} - -bool Player::HasItemFitToSpellReqirements(SpellEntry const* spellInfo, Item const* ignoreItem) -{ - if(spellInfo->EquippedItemClass < 0) - return true; - - // scan other equipped items for same requirements (mostly 2 daggers/etc) - // for optimize check 2 used cases only - switch(spellInfo->EquippedItemClass) - { - case ITEM_CLASS_WEAPON: - { - for(int i= EQUIPMENT_SLOT_MAINHAND; i < EQUIPMENT_SLOT_TABARD; ++i) - if(Item *item = GetItemByPos( INVENTORY_SLOT_BAG_0, i )) - if(item!=ignoreItem && item->IsFitToSpellRequirements(spellInfo)) - return true; - break; - } - case ITEM_CLASS_ARMOR: - { - // tabard not have dependent spells - for(int i= EQUIPMENT_SLOT_START; i< EQUIPMENT_SLOT_MAINHAND; ++i) - if(Item *item = GetItemByPos( INVENTORY_SLOT_BAG_0, i )) - if(item!=ignoreItem && item->IsFitToSpellRequirements(spellInfo)) - return true; - - // shields can be equipped to offhand slot - if(Item *item = GetItemByPos( INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND)) - if(item!=ignoreItem && item->IsFitToSpellRequirements(spellInfo)) - return true; - - // ranged slot can have some armor subclasses - if(Item *item = GetItemByPos( INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_RANGED)) - if(item!=ignoreItem && item->IsFitToSpellRequirements(spellInfo)) - return true; - - break; - } - default: - sLog.outError("HasItemFitToSpellReqirements: Not handeled spell reqirement for item class %u",spellInfo->EquippedItemClass); - break; - } - - return false; -} - -void Player::RemoveItemDependentAurasAndCasts( Item * pItem ) -{ - AuraMap& auras = GetAuras(); - for(AuraMap::iterator itr = auras.begin(); itr != auras.end(); ) - { - Aura* aura = itr->second; - - // skip passive (passive item dependent spells work in another way) and not self applied auras - SpellEntry const* spellInfo = aura->GetSpellProto(); - if(aura->IsPassive() || aura->GetCasterGUID()!=GetGUID()) - { - ++itr; - continue; - } - - // skip if not item dependent or have alternative item - if(HasItemFitToSpellReqirements(spellInfo,pItem)) - { - ++itr; - continue; - } - - // no alt item, remove aura, restart check - RemoveAurasDueToSpell(aura->GetId()); - itr = auras.begin(); - } - - // currently casted spells can be dependent from item - for (uint32 i = 0; i < CURRENT_MAX_SPELL; i++) - { - if( m_currentSpells[i] && m_currentSpells[i]->getState()!=SPELL_STATE_DELAYED && - !HasItemFitToSpellReqirements(m_currentSpells[i]->m_spellInfo,pItem) ) - InterruptSpell(i); - } -} - -uint32 Player::GetResurrectionSpellId() -{ - // search priceless resurrection possabilities - uint32 prio = 0; - uint32 spell_id = 0; - AuraList const& dummyAuras = GetAurasByType(SPELL_AURA_DUMMY); - for(AuraList::const_iterator itr = dummyAuras.begin(); itr != dummyAuras.end(); ++itr) - { - // Soulstone Resurrection // prio: 3 (max, non death persistent) - if( prio < 2 && (*itr)->GetSpellProto()->SpellVisual == 99 && (*itr)->GetSpellProto()->SpellIconID == 92 ) - { - switch((*itr)->GetId()) - { - case 20707: spell_id = 3026; break; // rank 1 - case 20762: spell_id = 20758; break; // rank 2 - case 20763: spell_id = 20759; break; // rank 3 - case 20764: spell_id = 20760; break; // rank 4 - case 20765: spell_id = 20761; break; // rank 5 - case 27239: spell_id = 27240; break; // rank 6 - default: - sLog.outError("Unhandled spell %%u: S.Resurrection",(*itr)->GetId()); - continue; - } - - prio = 3; - } - // Twisting Nether // prio: 2 (max) - else if((*itr)->GetId()==23701 && roll_chance_i(10)) - { - prio = 2; - spell_id = 23700; - } - } - - // Reincarnation (passive spell) // prio: 1 - if(prio < 1 && HasSpell(20608) && !HasSpellCooldown(21169) && HasItemCount(17030,1)) - spell_id = 21169; - - return spell_id; -} - -bool Player::RewardPlayerAndGroupAtKill(Unit* pVictim) -{ - bool PvP = pVictim->isCharmedOwnedByPlayerOrPlayer(); - - // prepare data for near group iteration (PvP and !PvP cases) - uint32 xp = 0; - bool honored_kill = false; - - if(Group *pGroup = GetGroup()) - { - uint32 count = 0; - uint32 sum_level = 0; - Player* member_with_max_level = NULL; - - pGroup->GetDataForXPAtKill(pVictim,count,sum_level,member_with_max_level); - - if(member_with_max_level) - { - xp = PvP ? 0 : MaNGOS::XP::Gain(member_with_max_level, pVictim); - - // skip in check PvP case (for speed, not used) - bool is_raid = PvP ? false : sMapStore.LookupEntry(GetMapId())->IsRaid() && pGroup->isRaidGroup(); - bool is_dungeon = PvP ? false : sMapStore.LookupEntry(GetMapId())->IsDungeon(); - float group_rate = MaNGOS::XP::xp_in_group_rate(count,is_raid); - - for(GroupReference *itr = pGroup->GetFirstMember(); itr != NULL; itr = itr->next()) - { - Player* pGroupGuy = itr->getSource(); - if(!pGroupGuy) - continue; - - if(!pGroupGuy->IsAtGroupRewardDistance(pVictim)) - continue; // member (alive or dead) or his corpse at req. distance - - // honor can be in PvP and !PvP (racial leader) cases (for alive) - if(pGroupGuy->isAlive() && pGroupGuy->RewardHonor(pVictim,count) && pGroupGuy==this) - honored_kill = true; - - // xp and reputation only in !PvP case - if(!PvP) - { - float rate = group_rate * float(pGroupGuy->getLevel()) / sum_level; - - // if is in dungeon then all receive full reputation at kill - // rewarded any alive/dead/near_corpse group member - pGroupGuy->RewardReputation(pVictim,is_dungeon ? 1.0f : rate); - - // XP updated only for alive group member - if(pGroupGuy->isAlive()) - { - uint32 itr_xp = uint32(xp*rate); - - pGroupGuy->GiveXP(itr_xp, pVictim); - if(Pet* pet = pGroupGuy->GetPet()) - pet->GivePetXP(itr_xp/2); - } - - // quest objectives updated only for alive group member or dead but with not released body - if(pGroupGuy->isAlive()|| !pGroupGuy->GetCorpse()) - { - // normal creature (not pet/etc) can be only in !PvP case - if(pVictim->GetTypeId()==TYPEID_UNIT) - pGroupGuy->KilledMonster(pVictim->GetEntry(), pVictim->GetGUID()); - } - } - } - } - } - else // if (!pGroup) - { - xp = PvP ? 0 : MaNGOS::XP::Gain(this, pVictim); - - // honor can be in PvP and !PvP (racial leader) cases - if(RewardHonor(pVictim,1)) - honored_kill = true; - - // xp and reputation only in !PvP case - if(!PvP) - { - RewardReputation(pVictim,1); - GiveXP(xp, pVictim); - - if(Pet* pet = GetPet()) - pet->GivePetXP(xp); - - // normal creature (not pet/etc) can be only in !PvP case - if(pVictim->GetTypeId()==TYPEID_UNIT) - KilledMonster(pVictim->GetEntry(),pVictim->GetGUID()); - } - } - return xp || honored_kill; -} - -bool Player::IsAtGroupRewardDistance(WorldObject const* pRewardSource) const -{ - if(pRewardSource->GetDistance(this) <= sWorld.getConfig(CONFIG_GROUP_XP_DISTANCE)) - return true; - - if(isAlive()) - return false; - - Corpse* corpse = GetCorpse(); - if(!corpse) - return false; - - return pRewardSource->GetDistance(corpse) <= sWorld.getConfig(CONFIG_GROUP_XP_DISTANCE); -} - -uint32 Player::GetBaseWeaponSkillValue (WeaponAttackType attType) const -{ - Item* item = GetWeaponForAttack(attType,true); - - // unarmmed only with base attack - if(attType != BASE_ATTACK && !item) - return 0; - - // weapon skill or (unarmed for base attack) - uint32 skill = item ? item->GetSkill() : SKILL_UNARMED; - return GetBaseSkillValue(skill); -} - -void Player::ResurectUsingRequestData() -{ - ResurrectPlayer(0.0f,false); - - if(GetMaxHealth() > m_resurrectHealth) - SetHealth( m_resurrectHealth ); - else - SetHealth( GetMaxHealth() ); - - if(GetMaxPower(POWER_MANA) > m_resurrectMana) - SetPower(POWER_MANA, m_resurrectMana ); - else - SetPower(POWER_MANA, GetMaxPower(POWER_MANA) ); - - SetPower(POWER_RAGE, 0 ); - - SetPower(POWER_ENERGY, GetMaxPower(POWER_ENERGY) ); - - SpawnCorpseBones(); - - TeleportTo(m_resurrectMap, m_resurrectX, m_resurrectY, m_resurrectZ, GetOrientation()); -} - -void Player::SetClientControl(Unit* target, uint8 allowMove) -{ - WorldPacket data(SMSG_CLIENT_CONTROL_UPDATE, target->GetPackGUID().size()+1); - data.append(target->GetPackGUID()); - data << uint8(allowMove); - GetSession()->SendPacket(&data); -} - -void Player::UpdateZoneDependentAuras( uint32 newZone ) -{ - // remove new continent flight forms - if( !isGameMaster() && - GetVirtualMapForMapAndZone(GetMapId(),newZone) != 530) - { - RemoveSpellsCausingAura(SPELL_AURA_MOD_INCREASE_FLIGHT_SPEED); - RemoveSpellsCausingAura(SPELL_AURA_FLY); - } - - // Some spells applied at enter into zone (with subzones) - // Human Illusion - // NOTE: these are removed by RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_CHANGE_MAP); - if ( newZone == 2367 ) // Old Hillsbrad Foothills - { - uint32 spellid = 0; - // all horde races - if( GetTeam() == HORDE ) - spellid = getGender() == GENDER_FEMALE ? 35481 : 35480; - // and some alliance races - else if( getRace() == RACE_NIGHTELF || getRace() == RACE_DRAENEI ) - spellid = getGender() == GENDER_FEMALE ? 35483 : 35482; - - if(spellid && !HasAura(spellid,0) ) - CastSpell(this,spellid,true); - } -} - -void Player::UpdateAreaDependentAuras( uint32 newArea ) -{ - // remove auras from spells with area limitations - for(AuraMap::iterator iter = m_Auras.begin(); iter != m_Auras.end();) - { - // use m_zoneUpdateId for speed: UpdateArea called from UpdateZone or instead UpdateZone in both cases m_zoneUpdateId up-to-date - if(!IsSpellAllowedInLocation(iter->second->GetSpellProto(),GetMapId(),m_zoneUpdateId,newArea)) - RemoveAura(iter); - else - ++iter; - } - - // unmount if enter in this subzone - if( newArea == 35) - RemoveSpellsCausingAura(SPELL_AURA_MOUNTED); - // Dragonmaw Illusion - else if( newArea == 3759 || newArea == 3966 || newArea == 3939 ) - { - if( GetDummyAura(40214) ) - { - if( !HasAura(40216,0) ) - CastSpell(this,40216,true); - if( !HasAura(42016,0) ) - CastSpell(this,42016,true); - } - } -} - -uint32 Player::GetCorpseReclaimDelay(bool pvp) const -{ - if( pvp && !sWorld.getConfig(CONFIG_DEATH_CORPSE_RECLAIM_DELAY_PVP) || - !pvp && !sWorld.getConfig(CONFIG_DEATH_CORPSE_RECLAIM_DELAY_PVE) ) - { - return copseReclaimDelay[0]; - } - - time_t now = time(NULL); - // 0..2 full period - uint32 count = (now < m_deathExpireTime) ? (m_deathExpireTime - now)/DEATH_EXPIRE_STEP : 0; - return copseReclaimDelay[count]; -} - -void Player::UpdateCorpseReclaimDelay() -{ - bool pvp = m_ExtraFlags & PLAYER_EXTRA_PVP_DEATH; - - if( pvp && !sWorld.getConfig(CONFIG_DEATH_CORPSE_RECLAIM_DELAY_PVP) || - !pvp && !sWorld.getConfig(CONFIG_DEATH_CORPSE_RECLAIM_DELAY_PVE) ) - return; - - time_t now = time(NULL); - if(now < m_deathExpireTime) - { - // full and partly periods 1..3 - uint32 count = (m_deathExpireTime - now)/DEATH_EXPIRE_STEP +1; - if(count < MAX_DEATH_COUNT) - m_deathExpireTime = now+(count+1)*DEATH_EXPIRE_STEP; - else - m_deathExpireTime = now+MAX_DEATH_COUNT*DEATH_EXPIRE_STEP; - } - else - m_deathExpireTime = now+DEATH_EXPIRE_STEP; -} - -void Player::SendCorpseReclaimDelay(bool load) -{ - Corpse* corpse = GetCorpse(); - if(!corpse) - return; - - uint32 delay; - if(load) - { - if(corpse->GetGhostTime() > m_deathExpireTime) - return; - - bool pvp = corpse->GetType()==CORPSE_RESURRECTABLE_PVP; - - uint32 count; - if( pvp && sWorld.getConfig(CONFIG_DEATH_CORPSE_RECLAIM_DELAY_PVP) || - !pvp && sWorld.getConfig(CONFIG_DEATH_CORPSE_RECLAIM_DELAY_PVE) ) - { - count = (m_deathExpireTime-corpse->GetGhostTime())/DEATH_EXPIRE_STEP; - if(count>=MAX_DEATH_COUNT) - count = MAX_DEATH_COUNT-1; - } - else - count=0; - - time_t expected_time = corpse->GetGhostTime()+copseReclaimDelay[count]; - - time_t now = time(NULL); - if(now >= expected_time) - return; - - delay = expected_time-now; - } - else - delay = GetCorpseReclaimDelay(corpse->GetType()==CORPSE_RESURRECTABLE_PVP); - - //! corpse reclaim delay 30 * 1000ms or longer at often deaths - WorldPacket data(SMSG_CORPSE_RECLAIM_DELAY, 4); - data << uint32(delay*1000); - GetSession()->SendPacket( &data ); -} - -Player* Player::GetNextRandomRaidMember(float radius) -{ - Group *pGroup = GetGroup(); - if(!pGroup) - return NULL; - - std::vector nearMembers; - nearMembers.reserve(pGroup->GetMembersCount()); - - for(GroupReference *itr = pGroup->GetFirstMember(); itr != NULL; itr = itr->next()) - { - Player* Target = itr->getSource(); - - // IsHostileTo check duel and controlled by enemy - if( Target && Target != this && IsWithinDistInMap(Target, radius) && - !Target->HasInvisibilityAura() && !IsHostileTo(Target) ) - nearMembers.push_back(Target); - } - - if (nearMembers.empty()) - return NULL; - - uint32 randTarget = urand(0,nearMembers.size()-1); - return nearMembers[randTarget]; -} - -void Player::UpdateUnderwaterState( Map* m, float x, float y, float z ) -{ - float water_z = m->GetWaterLevel(x,y); - float height_z = m->GetHeight(x,y,z, false); // use .map base surface height - uint8 flag1 = m->GetTerrainType(x,y); - - //!Underwater check, not in water if underground or above water level - if (height_z <= INVALID_HEIGHT || z < (height_z-2) || z > (water_z - 2) ) - m_isunderwater &= 0x7A; - else if ((z < (water_z - 2)) && (flag1 & 0x01)) - m_isunderwater |= 0x01; - - //!in lava check, anywhere under lava level - if ((height_z <= INVALID_HEIGHT || z < (height_z - 0)) && (flag1 == 0x00) && IsInWater()) - m_isunderwater |= 0x80; -} - -bool ItemPosCount::isContainedIn(ItemPosCountVec &vec) -{ - for(ItemPosCountVec::const_iterator itr = vec.begin(); itr != vec.end();++itr) - { - if(itr->pos == this->pos/* && itr->count == this.count*/) - { - return true; - } - } - return false; -} - +/* + * Copyright (C) 2005-2008 MaNGOS + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "Common.h" +#include "Language.h" +#include "Database/DatabaseEnv.h" +#include "Log.h" +#include "Opcodes.h" +#include "ObjectMgr.h" +#include "SpellMgr.h" +#include "World.h" +#include "WorldPacket.h" +#include "WorldSession.h" +#include "UpdateMask.h" +#include "Player.h" +#include "SkillDiscovery.h" +#include "QuestDef.h" +#include "GossipDef.h" +#include "UpdateData.h" +#include "Channel.h" +#include "ChannelMgr.h" +#include "MapManager.h" +#include "MapInstanced.h" +#include "InstanceSaveMgr.h" +#include "GridNotifiers.h" +#include "GridNotifiersImpl.h" +#include "CellImpl.h" +#include "ObjectMgr.h" +#include "ObjectAccessor.h" +#include "CreatureAI.h" +#include "Formulas.h" +#include "Group.h" +#include "Guild.h" +#include "Pet.h" +#include "SpellAuras.h" +#include "Util.h" +#include "Transports.h" +#include "Weather.h" +#include "BattleGround.h" +#include "BattleGroundMgr.h" +#include "ArenaTeam.h" +#include "Chat.h" +#include "Database/DatabaseImpl.h" +#include "Spell.h" +#include "SocialMgr.h" + +#include + +#define ZONE_UPDATE_INTERVAL 1000 + +#define PLAYER_SKILL_INDEX(x) (PLAYER_SKILL_INFO_1_1 + ((x)*3)) +#define PLAYER_SKILL_VALUE_INDEX(x) (PLAYER_SKILL_INDEX(x)+1) +#define PLAYER_SKILL_BONUS_INDEX(x) (PLAYER_SKILL_INDEX(x)+2) + +#define SKILL_VALUE(x) PAIR32_LOPART(x) +#define SKILL_MAX(x) PAIR32_HIPART(x) +#define MAKE_SKILL_VALUE(v, m) MAKE_PAIR32(v,m) + +#define SKILL_TEMP_BONUS(x) int16(PAIR32_LOPART(x)) +#define SKILL_PERM_BONUS(x) int16(PAIR32_HIPART(x)) +#define MAKE_SKILL_BONUS(t, p) MAKE_PAIR32(t,p) + +enum CharacterFlags +{ + CHARACTER_FLAG_NONE = 0x00000000, + CHARACTER_FLAG_UNK1 = 0x00000001, + CHARACTER_FLAG_UNK2 = 0x00000002, + CHARACTER_LOCKED_FOR_TRANSFER = 0x00000004, + CHARACTER_FLAG_UNK4 = 0x00000008, + CHARACTER_FLAG_UNK5 = 0x00000010, + CHARACTER_FLAG_UNK6 = 0x00000020, + CHARACTER_FLAG_UNK7 = 0x00000040, + CHARACTER_FLAG_UNK8 = 0x00000080, + CHARACTER_FLAG_UNK9 = 0x00000100, + CHARACTER_FLAG_UNK10 = 0x00000200, + CHARACTER_FLAG_HIDE_HELM = 0x00000400, + CHARACTER_FLAG_HIDE_CLOAK = 0x00000800, + CHARACTER_FLAG_UNK13 = 0x00001000, + CHARACTER_FLAG_GHOST = 0x00002000, + CHARACTER_FLAG_RENAME = 0x00004000, + CHARACTER_FLAG_UNK16 = 0x00008000, + CHARACTER_FLAG_UNK17 = 0x00010000, + CHARACTER_FLAG_UNK18 = 0x00020000, + CHARACTER_FLAG_UNK19 = 0x00040000, + CHARACTER_FLAG_UNK20 = 0x00080000, + CHARACTER_FLAG_UNK21 = 0x00100000, + CHARACTER_FLAG_UNK22 = 0x00200000, + CHARACTER_FLAG_UNK23 = 0x00400000, + CHARACTER_FLAG_UNK24 = 0x00800000, + CHARACTER_FLAG_LOCKED_BY_BILLING = 0x01000000, + CHARACTER_FLAG_DECLINED = 0x02000000, + CHARACTER_FLAG_UNK27 = 0x04000000, + CHARACTER_FLAG_UNK28 = 0x08000000, + CHARACTER_FLAG_UNK29 = 0x10000000, + CHARACTER_FLAG_UNK30 = 0x20000000, + CHARACTER_FLAG_UNK31 = 0x40000000, + CHARACTER_FLAG_UNK32 = 0x80000000 +}; + +// corpse reclaim times +#define DEATH_EXPIRE_STEP (5*MINUTE) +#define MAX_DEATH_COUNT 3 + +static uint32 copseReclaimDelay[MAX_DEATH_COUNT] = { 30, 60, 120 }; + +//== PlayerTaxi ================================================ + +PlayerTaxi::PlayerTaxi() +{ + // Taxi nodes + memset(m_taximask, 0, sizeof(m_taximask)); +} + +void PlayerTaxi::InitTaxiNodesForLevel(uint32 race, uint32 level) +{ + // capital and taxi hub masks + switch(race) + { + case RACE_HUMAN: SetTaximaskNode(2); break; // Human + case RACE_ORC: SetTaximaskNode(23); break; // Orc + case RACE_DWARF: SetTaximaskNode(6); break; // Dwarf + case RACE_NIGHTELF: SetTaximaskNode(26); + SetTaximaskNode(27); break; // Night Elf + case RACE_UNDEAD_PLAYER: SetTaximaskNode(11); break;// Undead + case RACE_TAUREN: SetTaximaskNode(22); break; // Tauren + case RACE_GNOME: SetTaximaskNode(6); break; // Gnome + case RACE_TROLL: SetTaximaskNode(23); break; // Troll + case RACE_BLOODELF: SetTaximaskNode(82); break; // Blood Elf + case RACE_DRAENEI: SetTaximaskNode(94); break; // Draenei + } + // new continent starting masks (It will be accessible only at new map) + switch(Player::TeamForRace(race)) + { + case ALLIANCE: SetTaximaskNode(100); break; + case HORDE: SetTaximaskNode(99); break; + } + // level dependent taxi hubs + if(level>=68) + SetTaximaskNode(213); //Shattered Sun Staging Area +} + +void PlayerTaxi::LoadTaxiMask(const char* data) +{ + Tokens tokens = StrSplit(data, " "); + + int index; + Tokens::iterator iter; + for (iter = tokens.begin(), index = 0; + (index < TaxiMaskSize) && (iter != tokens.end()); ++iter, ++index) + { + // load and set bits only for existed taxi nodes + m_taximask[index] = sTaxiNodesMask[index] & uint32(atol((*iter).c_str())); + } +} + +void PlayerTaxi::AppendTaximaskTo( ByteBuffer& data, bool all ) +{ + if(all) + { + for (uint8 i=0; ic_str())); + AddTaxiDestination(node); + } + + if(m_TaxiDestinations.empty()) + return true; + + // Check integrity + if(m_TaxiDestinations.size() < 2) + return false; + + for(size_t i = 1; i < m_TaxiDestinations.size(); ++i) + { + uint32 cost; + uint32 path; + objmgr.GetTaxiPath(m_TaxiDestinations[i-1],m_TaxiDestinations[i],path,cost); + if(!path) + return false; + } + + return true; +} + +std::string PlayerTaxi::SaveTaxiDestinationsToString() +{ + if(m_TaxiDestinations.empty()) + return ""; + + std::ostringstream ss; + + for(size_t i=0; i < m_TaxiDestinations.size(); ++i) + ss << m_TaxiDestinations[i] << " "; + + return ss.str(); +} + +uint32 PlayerTaxi::GetCurrentTaxiPath() const +{ + if(m_TaxiDestinations.size() < 2) + return 0; + + uint32 path; + uint32 cost; + + objmgr.GetTaxiPath(m_TaxiDestinations[0],m_TaxiDestinations[1],path,cost); + + return path; +} + +//== Player ==================================================== + +const int32 Player::ReputationRank_Length[MAX_REPUTATION_RANK] = {36000, 3000, 3000, 3000, 6000, 12000, 21000, 1000}; + +UpdateMask Player::updateVisualBits; + +Player::Player (WorldSession *session): Unit() +{ + m_transport = 0; + + m_speakTime = 0; + m_speakCount = 0; + + m_objectType |= TYPEMASK_PLAYER; + m_objectTypeId = TYPEID_PLAYER; + + m_valuesCount = PLAYER_END; + + m_session = session; + + m_divider = 0; + + m_ExtraFlags = 0; + if(GetSession()->GetSecurity() >= SEC_GAMEMASTER) + SetAcceptTicket(true); + + // players always and GM if set in config accept whispers by default + if(GetSession()->GetSecurity() == SEC_PLAYER || sWorld.getConfig(CONFIG_GM_WISPERING_TO)) + SetAcceptWhispers(true); + + m_curSelection = 0; + m_lootGuid = 0; + + m_comboTarget = 0; + m_comboPoints = 0; + + m_usedTalentCount = 0; + + m_regenTimer = 0; + m_weaponChangeTimer = 0; + + m_zoneUpdateId = 0; + m_zoneUpdateTimer = 0; + + m_areaUpdateId = 0; + + m_nextSave = sWorld.getConfig(CONFIG_INTERVAL_SAVE); + + // randomize first save time in range [CONFIG_INTERVAL_SAVE] around [CONFIG_INTERVAL_SAVE] + // this must help in case next save after mass player load after server startup + m_nextSave = urand(m_nextSave/2,m_nextSave*3/2); + + clearResurrectRequestData(); + + m_SpellModRemoveCount = 0; + + memset(m_items, 0, sizeof(Item*)*PLAYER_SLOTS_COUNT); + + m_social = NULL; + + // group is initialized in the reference constructor + SetGroupInvite(NULL); + m_groupUpdateMask = 0; + m_auraUpdateMask = 0; + + duel = NULL; + + m_GuildIdInvited = 0; + m_ArenaTeamIdInvited = 0; + + m_atLoginFlags = AT_LOGIN_NONE; + + m_dontMove = false; + + pTrader = 0; + ClearTrade(); + + m_cinematic = 0; + + PlayerTalkClass = new PlayerMenu( GetSession() ); + m_currentBuybackSlot = BUYBACK_SLOT_START; + + for ( int aX = 0 ; aX < 8 ; aX++ ) + m_Tutorials[ aX ] = 0x00; + m_TutorialsChanged = false; + + m_DailyQuestChanged = false; + m_lastDailyQuestTime = 0; + + m_regenTimer = 0; + m_weaponChangeTimer = 0; + m_breathTimer = 0; + m_isunderwater = 0; + m_isInWater = false; + m_drunkTimer = 0; + m_drunk = 0; + m_restTime = 0; + m_deathTimer = 0; + m_deathExpireTime = 0; + + m_swingErrorMsg = 0; + + m_DetectInvTimer = 1000; + + m_bgBattleGroundID = 0; + for (int j=0; j < PLAYER_MAX_BATTLEGROUND_QUEUES; j++) + { + m_bgBattleGroundQueueID[j].bgType = 0; + m_bgBattleGroundQueueID[j].invited = false; + } + m_bgTeam = 0; + + m_logintime = time(NULL); + m_Last_tick = m_logintime; + m_WeaponProficiency = 0; + m_ArmorProficiency = 0; + m_canParry = false; + m_canBlock = false; + m_canDualWield = false; + m_ammoDPS = 0.0f; + + m_temporaryUnsummonedPetNumber = 0; + //cache for UNIT_CREATED_BY_SPELL to allow + //returning reagests for temporarily removed pets + //when dying/logging out + m_oldpetspell = 0; + + ////////////////////Rest System///////////////////// + time_inn_enter=0; + inn_pos_mapid=0; + inn_pos_x=0; + inn_pos_y=0; + inn_pos_z=0; + m_rest_bonus=0; + rest_type=REST_TYPE_NO; + ////////////////////Rest System///////////////////// + + m_mailsLoaded = false; + m_mailsUpdated = false; + unReadMails = 0; + m_nextMailDelivereTime = 0; + + m_resetTalentsCost = 0; + m_resetTalentsTime = 0; + m_itemUpdateQueueBlocked = false; + + for (int i = 0; i < MAX_MOVE_TYPE; ++i) + m_forced_speed_changes[i] = 0; + + m_stableSlots = 0; + + /////////////////// Instance System ///////////////////// + + m_HomebindTimer = 0; + m_InstanceValid = true; + m_dungeonDifficulty = DIFFICULTY_NORMAL; + + for (int i = 0; i < BASEMOD_END; i++) + { + m_auraBaseMod[i][FLAT_MOD] = 0.0f; + m_auraBaseMod[i][PCT_MOD] = 1.0f; + } + + // Honor System + m_lastHonorUpdateTime = time(NULL); + + // Player summoning + m_summon_expire = 0; + m_summon_mapid = 0; + m_summon_x = 0.0f; + m_summon_y = 0.0f; + m_summon_z = 0.0f; + + //Default movement to run mode + m_unit_movement_flags = 0; + + m_miniPet = 0; + m_bgAfkReportedTimer = 0; + m_contestedPvPTimer = 0; + + m_declinedname = NULL; +} + +Player::~Player () +{ + CleanupsBeforeDelete(); + + if(m_uint32Values) // only for fully created Object + { + sSocialMgr.RemovePlayerSocial(GetGUIDLow()); + } + + // Note: buy back item already deleted from DB when player was saved + for(int i = 0; i < PLAYER_SLOTS_COUNT; ++i) + { + if(m_items[i]) + delete m_items[i]; + } + CleanupChannels(); + + for (PlayerSpellMap::const_iterator itr = m_spells.begin(); itr != m_spells.end(); ++itr) + delete itr->second; + + //all mailed items should be deleted, also all mail should be deallocated + for (PlayerMails::iterator itr = m_mail.begin(); itr != m_mail.end();++itr) + delete *itr; + + for (ItemMap::iterator iter = mMitems.begin(); iter != mMitems.end(); ++iter) + delete iter->second; //if item is duplicated... then server may crash ... but that item should be deallocated + + delete PlayerTalkClass; + + if (m_transport) + { + m_transport->RemovePassenger(this); + } + + for(size_t x = 0; x < ItemSetEff.size(); x++) + if(ItemSetEff[x]) + delete ItemSetEff[x]; + + // clean up player-instance binds, may unload some instance saves + for(uint8 i = 0; i < TOTAL_DIFFICULTIES; i++) + for(BoundInstancesMap::iterator itr = m_boundInstances[i].begin(); itr != m_boundInstances[i].end(); ++itr) + itr->second.save->RemovePlayer(this); + + delete m_declinedname; +} + +void Player::CleanupsBeforeDelete() +{ + if(m_uint32Values) // only for fully created Object + { + TradeCancel(false); + DuelComplete(DUEL_INTERUPTED); + } + Unit::CleanupsBeforeDelete(); +} + +bool Player::Create( uint32 guidlow, std::string name, uint8 race, uint8 class_, uint8 gender, uint8 skin, uint8 face, uint8 hairStyle, uint8 hairColor, uint8 facialHair, uint8 outfitId ) +{ + Object::_Create(guidlow, 0, HIGHGUID_PLAYER); + + m_name = name; + + PlayerInfo const* info = objmgr.GetPlayerInfo(race, class_); + if(!info) + { + sLog.outError("Player have incorrect race/class pair. Can't be loaded."); + return false; + } + + for (int i = 0; i < PLAYER_SLOTS_COUNT; i++) + m_items[i] = NULL; + + //for(int j = BUYBACK_SLOT_START; j < BUYBACK_SLOT_END; j++) + //{ + // SetUInt64Value(PLAYER_FIELD_VENDORBUYBACK_SLOT_1+j*2,0); + // SetUInt32Value(PLAYER_FIELD_BUYBACK_PRICE_1+j,0); + // SetUInt32Value(PLAYER_FIELD_BUYBACK_TIMESTAMP_1+j,0); + //} + + m_race = race; + m_class = class_; + + SetMapId(info->mapId); + Relocate(info->positionX,info->positionY,info->positionZ); + + ChrClassesEntry const* cEntry = sChrClassesStore.LookupEntry(class_); + if(!cEntry) + { + sLog.outError("Class %u not found in DBC (Wrong DBC files?)",class_); + return false; + } + + uint8 powertype = cEntry->powerType; + + uint32 unitfield; + + switch(powertype) + { + case POWER_ENERGY: + case POWER_MANA: + unitfield = 0x00000000; + break; + case POWER_RAGE: + unitfield = 0x00110000; + break; + default: + sLog.outError("Invalid default powertype %u for player (class %u)",powertype,class_); + return false; + } + + SetFloatValue(UNIT_FIELD_BOUNDINGRADIUS, DEFAULT_WORLD_OBJECT_SIZE ); + SetFloatValue(UNIT_FIELD_COMBATREACH, 1.5f ); + + switch(gender) + { + case GENDER_FEMALE: + SetDisplayId(info->displayId_f ); + SetNativeDisplayId(info->displayId_f ); + break; + case GENDER_MALE: + SetDisplayId(info->displayId_m ); + SetNativeDisplayId(info->displayId_m ); + break; + default: + sLog.outError("Invalid gender %u for player",gender); + return false; + break; + } + + setFactionForRace(m_race); + + SetUInt32Value(UNIT_FIELD_BYTES_0, ( ( race ) | ( class_ << 8 ) | ( gender << 16 ) | ( powertype << 24 ) ) ); + SetUInt32Value(UNIT_FIELD_BYTES_1, unitfield); + SetByteValue(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_UNK3 | UNIT_BYTE2_FLAG_UNK5 ); + SetUInt32Value(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE ); + SetFloatValue(UNIT_MOD_CAST_SPEED, 1.0f); // fix cast time showed in spell tooltip on client + + //-1 is default value + SetUInt32Value(PLAYER_FIELD_WATCHED_FACTION_INDEX, uint32(-1)); + + SetUInt32Value(PLAYER_BYTES, (skin | (face << 8) | (hairStyle << 16) | (hairColor << 24))); + SetUInt32Value(PLAYER_BYTES_2, (facialHair | (0x00 << 8) | (0x00 << 16) | (0x02 << 24))); + SetByteValue(PLAYER_BYTES_3, 0, gender); + + SetUInt32Value( PLAYER_GUILDID, 0 ); + SetUInt32Value( PLAYER_GUILDRANK, 0 ); + SetUInt32Value( PLAYER_GUILD_TIMESTAMP, 0 ); + + SetUInt64Value( PLAYER__FIELD_KNOWN_TITLES, 0 ); // 0=disabled + SetUInt32Value( PLAYER_CHOSEN_TITLE, 0 ); + SetUInt32Value( PLAYER_FIELD_KILLS, 0 ); + SetUInt32Value( PLAYER_FIELD_LIFETIME_HONORBALE_KILLS, 0 ); + SetUInt32Value( PLAYER_FIELD_TODAY_CONTRIBUTION, 0 ); + SetUInt32Value( PLAYER_FIELD_YESTERDAY_CONTRIBUTION, 0 ); + + // set starting level + SetUInt32Value( UNIT_FIELD_LEVEL, sWorld.getConfig(CONFIG_START_PLAYER_LEVEL) ); + + // Played time + m_Last_tick = time(NULL); + m_Played_time[0] = 0; + m_Played_time[1] = 0; + + // base stats and related field values + InitStatsForLevel(); + InitTaxiNodesForLevel(); + InitTalentForLevel(); + InitPrimaryProffesions(); // to max set before any spell added + + // apply original stats mods before spell loading or item equipment that call before equip _RemoveStatsMods() + UpdateMaxHealth(); // Update max Health (for add bonus from stamina) + SetHealth(GetMaxHealth()); + if (getPowerType()==POWER_MANA) + { + UpdateMaxPower(POWER_MANA); // Update max Mana (for add bonus from intelect) + SetPower(POWER_MANA,GetMaxPower(POWER_MANA)); + } + + learnDefaultSpells(true); + + std::list::const_iterator action_itr[4]; + for(int i=0; i<4; i++) + action_itr[i] = info->action[i].begin(); + + for (; action_itr[0]!=info->action[0].end() && action_itr[1]!=info->action[1].end();) + { + uint16 taction[4]; + for(int i=0; i<4 ;i++) + taction[i] = (*action_itr[i]); + + addActionButton((uint8)taction[0], taction[1], (uint8)taction[2], (uint8)taction[3]); + + for(int i=0; i<4 ;i++) + ++action_itr[i]; + } + + for (PlayerCreateInfoItems::const_iterator item_id_itr = info->item.begin(); item_id_itr!=info->item.end(); ++item_id_itr++) + { + uint32 titem_id = item_id_itr->item_id; + uint32 titem_amount = item_id_itr->item_amount; + + sLog.outDebug("STORAGE: Creating initial item, itemId = %u, count = %u",titem_id, titem_amount); + + // attempt equip + uint16 eDest; + uint8 msg = CanEquipNewItem( NULL_SLOT, eDest, titem_id, titem_amount, false ); + if( msg == EQUIP_ERR_OK ) + { + EquipNewItem( eDest, titem_id, titem_amount, true); + AutoUnequipOffhandIfNeed(); + continue; // equipped, to next + } + + // attempt store + ItemPosCountVec sDest; + // store in main bag to simplify second pass (special bags can be not equipped yet at this moment) + msg = CanStoreNewItem( INVENTORY_SLOT_BAG_0, NULL_SLOT, sDest, titem_id, titem_amount ); + if( msg == EQUIP_ERR_OK ) + { + StoreNewItem( sDest, titem_id, true, Item::GenerateItemRandomPropertyId(titem_id) ); + continue; // stored, to next + } + + // item can't be added + sLog.outError("STORAGE: Can't equip or store initial item %u for race %u class %u , error msg = %u",titem_id,race,class_,msg); + } + + // bags and main-hand weapon must equipped at this moment + // now second pass for not equipped (offhand weapon/shield if it attempt equipped before main-hand weapon) + // or ammo not equipped in special bag + for(int i = INVENTORY_SLOT_ITEM_START; i < INVENTORY_SLOT_ITEM_END; i++) + { + if(Item* pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i )) + { + uint16 eDest; + // equip offhand weapon/shield if it attempt equipped before main-hand weapon + uint8 msg = CanEquipItem( NULL_SLOT, eDest, pItem, false ); + if( msg == EQUIP_ERR_OK ) + { + RemoveItem(INVENTORY_SLOT_BAG_0, i,true); + EquipItem( eDest, pItem, true); + } + // move other items to more appropriate slots (ammo not equipped in special bag) + else + { + ItemPosCountVec sDest; + msg = CanStoreItem( NULL_BAG, NULL_SLOT, sDest, pItem, false ); + if( msg == EQUIP_ERR_OK ) + { + RemoveItem(INVENTORY_SLOT_BAG_0, i,true); + pItem = StoreItem( sDest, pItem, true); + } + + // if this is ammo then use it + uint8 msg = CanUseAmmo( pItem->GetProto()->ItemId ); + if( msg == EQUIP_ERR_OK ) + SetAmmo( pItem->GetProto()->ItemId ); + } + } + } + // all item positions resolved + + return true; +} + +void Player::StartMirrorTimer(MirrorTimerType Type, uint32 MaxValue) +{ + uint32 BreathRegen = (uint32)-1; + + WorldPacket data(SMSG_START_MIRROR_TIMER, (21)); + data << (uint32)Type; + data << MaxValue; + data << MaxValue; + data << BreathRegen; + data << (uint8)0; + data << (uint32)0; // spell id + GetSession()->SendPacket(&data); +} + +void Player::ModifyMirrorTimer(MirrorTimerType Type, uint32 MaxValue, uint32 CurrentValue, uint32 Regen) +{ + if(Type==BREATH_TIMER) + m_breathTimer = ((MaxValue + 1000) - CurrentValue) / Regen; + + WorldPacket data(SMSG_START_MIRROR_TIMER, (21)); + data << (uint32)Type; + data << CurrentValue; + data << MaxValue; + data << Regen; + data << (uint8)0; + data << (uint32)0; // spell id + GetSession()->SendPacket( &data ); +} + +void Player::StopMirrorTimer(MirrorTimerType Type) +{ + if(Type==BREATH_TIMER) + m_breathTimer = 0; + + WorldPacket data(SMSG_STOP_MIRROR_TIMER, 4); + data << (uint32)Type; + GetSession()->SendPacket( &data ); +} + +void Player::EnvironmentalDamage(uint64 guid, EnviromentalDamage type, uint32 damage) +{ + WorldPacket data(SMSG_ENVIRONMENTALDAMAGELOG, (21)); + data << (uint64)guid; + data << (uint8)(type!=DAMAGE_FALL_TO_VOID ? type : DAMAGE_FALL); + data << (uint32)damage; + data << (uint32)0; + data << (uint32)0; + //m_session->SendPacket(&data); + //Let other players see that you get damage + SendMessageToSet(&data, true); + DealDamage(this, damage, NULL, SELF_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); + + if(type==DAMAGE_FALL && !isAlive()) // DealDamage not apply item durability loss at self damage + { + DEBUG_LOG("We are fall to death, loosing 10 percents durability"); + DurabilityLossAll(0.10f,false); + // durability lost message + WorldPacket data(SMSG_DURABILITY_DAMAGE_DEATH, 0); + GetSession()->SendPacket(&data); + } +} + +void Player::HandleDrowning() +{ + if(!m_isunderwater) + return; + + //if have water breath , then remove bar + if(waterbreath || isGameMaster() || !isAlive()) + { + StopMirrorTimer(BREATH_TIMER); + m_isunderwater = 0; + return; + } + + uint32 UnderWaterTime = 1*MINUTE*1000; // default leangthL 1 min + + AuraList const& mModWaterBreathing = GetAurasByType(SPELL_AURA_MOD_WATER_BREATHING); + for(AuraList::const_iterator i = mModWaterBreathing.begin(); i != mModWaterBreathing.end(); ++i) + UnderWaterTime = uint32(UnderWaterTime * (100.0f + (*i)->GetModifier()->m_amount) / 100.0f); + + if ((m_isunderwater & 0x01) && !(m_isunderwater & 0x80) && isAlive()) + { + //single trigger timer + if (!(m_isunderwater & 0x02)) + { + m_isunderwater|= 0x02; + m_breathTimer = UnderWaterTime + 1000; + } + //single trigger "Breathbar" + if ( m_breathTimer <= UnderWaterTime && !(m_isunderwater & 0x04)) + { + m_isunderwater|= 0x04; + StartMirrorTimer(BREATH_TIMER, UnderWaterTime); + } + //continius trigger drowning "Damage" + if ((m_breathTimer == 0) && (m_isunderwater & 0x01)) + { + //TODO: Check this formula + uint64 guid = GetGUID(); + uint32 damage = GetMaxHealth() / 5 + urand(0, getLevel()-1); + + EnvironmentalDamage(guid, DAMAGE_DROWNING,damage); + m_breathTimer = 2000; + } + } + //single trigger retract bar + else if (!(m_isunderwater & 0x01) && !(m_isunderwater & 0x08) && (m_isunderwater & 0x02) && (m_breathTimer > 0) && isAlive()) + { + m_isunderwater = 0x08; + + uint32 BreathRegen = 10; + ModifyMirrorTimer(BREATH_TIMER, UnderWaterTime, m_breathTimer,BreathRegen); + m_isunderwater = 0x10; + } + //remove bar + else if ((m_breathTimer < 50) && !(m_isunderwater & 0x01) && (m_isunderwater == 0x10)) + { + StopMirrorTimer(BREATH_TIMER); + m_isunderwater = 0; + } +} + +void Player::HandleLava() +{ + bool ValidArea = false; + + if ((m_isunderwater & 0x80) && isAlive()) + { + //Single trigger Set BreathTimer + if (!(m_isunderwater & 0x80)) + { + m_isunderwater|= 0x04; + m_breathTimer = 1000; + } + //Reset BreathTimer and still in the lava + if (!m_breathTimer) + { + uint64 guid = GetGUID(); + uint32 damage = urand(600, 700); // TODO: Get more detailed information about lava damage + uint32 dmgZone = GetZoneId(); // TODO: Find correct "lava dealing zone" flag in Area Table + + // Deal lava damage only in lava zones. + switch(dmgZone) + { + case 0x8D: + ValidArea = false; + break; + case 0x94: + ValidArea = false; + break; + case 0x2CE: + ValidArea = false; + break; + case 0x2CF: + ValidArea = false; + break; + default: + if (dmgZone / 5 & 0x408) + ValidArea = true; + } + + // if is valid area and is not gamemaster then deal damage + if ( ValidArea && !isGameMaster() ) + EnvironmentalDamage(guid, DAMAGE_LAVA, damage); + + m_breathTimer = 1000; + } + + } + //Death timer disabled and WaterFlags reset + else if (m_deathState == DEAD) + { + m_breathTimer = 0; + m_isunderwater = 0; + } +} + +///The player sobers by 256 every 10 seconds +void Player::HandleSobering() +{ + m_drunkTimer = 0; + + uint32 drunk = (m_drunk <= 256) ? 0 : (m_drunk - 256); + SetDrunkValue(drunk); +} + +DrunkenState Player::GetDrunkenstateByValue(uint16 value) +{ + if(value >= 23000) + return DRUNKEN_SMASHED; + if(value >= 12800) + return DRUNKEN_DRUNK; + if(value & 0xFFFE) + return DRUNKEN_TIPSY; + return DRUNKEN_SOBER; +} + +void Player::SetDrunkValue(uint16 newDrunkenValue, uint32 itemId) +{ + uint32 oldDrunkenState = Player::GetDrunkenstateByValue(m_drunk); + + m_drunk = newDrunkenValue; + SetUInt32Value(PLAYER_BYTES_3,(GetUInt32Value(PLAYER_BYTES_3) & 0xFFFF0001) | (m_drunk & 0xFFFE)); + + uint32 newDrunkenState = Player::GetDrunkenstateByValue(m_drunk); + + // special drunk invisibility detection + if(newDrunkenState >= DRUNKEN_DRUNK) + m_detectInvisibilityMask |= (1<<6); + else + m_detectInvisibilityMask &= ~(1<<6); + + if(newDrunkenState == oldDrunkenState) + return; + + WorldPacket data(SMSG_CROSSED_INEBRIATION_THRESHOLD, (8+4+4)); + data << GetGUID(); + data << uint32(newDrunkenState); + data << uint32(itemId); + + SendMessageToSet(&data, true); +} + +void Player::Update( uint32 p_time ) +{ + if(!IsInWorld()) + return; + + // undelivered mail + if(m_nextMailDelivereTime && m_nextMailDelivereTime <= time(NULL)) + { + SendNewMail(); + ++unReadMails; + + // It will be recalculate at mailbox open (for unReadMails important non-0 until mailbox open, it also will be recalculated) + m_nextMailDelivereTime = 0; + } + + Unit::Update( p_time ); + + // update player only attacks + if(uint32 ranged_att = getAttackTimer(RANGED_ATTACK)) + { + setAttackTimer(RANGED_ATTACK, (p_time >= ranged_att ? 0 : ranged_att - p_time) ); + } + + if(uint32 off_att = getAttackTimer(OFF_ATTACK)) + { + setAttackTimer(OFF_ATTACK, (p_time >= off_att ? 0 : off_att - p_time) ); + } + + time_t now = time (NULL); + + UpdatePvPFlag(now); + + UpdateContestedPvP(p_time); + + UpdateDuelFlag(now); + + CheckDuelDistance(now); + + UpdateAfkReport(now); + + CheckExploreSystem(); + + // Update items that have just a limited lifetime + if (now>m_Last_tick) + UpdateItemDuration(uint32(now- m_Last_tick)); + + if (!m_timedquests.empty()) + { + std::set::iterator iter = m_timedquests.begin(); + while (iter != m_timedquests.end()) + { + QuestStatusData& q_status = mQuestStatus[*iter]; + if( q_status.m_timer <= p_time ) + { + uint32 quest_id = *iter; + ++iter; // current iter will be removed in FailTimedQuest + FailTimedQuest( quest_id ); + } + else + { + q_status.m_timer -= p_time; + if (q_status.uState != QUEST_NEW) q_status.uState = QUEST_CHANGED; + ++iter; + } + } + } + + if (hasUnitState(UNIT_STAT_MELEE_ATTACKING)) + { + Unit *pVictim = getVictim(); + if( !IsNonMeleeSpellCasted(false) && pVictim) + { + // default combat reach 10 + // TODO add weapon,skill check + + float pldistance = ATTACK_DISTANCE; + + if (isAttackReady(BASE_ATTACK)) + { + if(!IsWithinDistInMap(pVictim, pldistance)) + { + setAttackTimer(BASE_ATTACK,100); + if(m_swingErrorMsg != 1) // send single time (client auto repeat) + { + SendAttackSwingNotInRange(); + m_swingErrorMsg = 1; + } + } + //120 degrees of radiant range + else if( !HasInArc( 2*M_PI/3, pVictim )) + { + setAttackTimer(BASE_ATTACK,100); + if(m_swingErrorMsg != 2) // send single time (client auto repeat) + { + SendAttackSwingBadFacingAttack(); + m_swingErrorMsg = 2; + } + } + else + { + m_swingErrorMsg = 0; // reset swing error state + + // prevent base and off attack in same time, delay attack at 0.2 sec + if(haveOffhandWeapon()) + { + uint32 off_att = getAttackTimer(OFF_ATTACK); + if(off_att < ATTACK_DISPLAY_DELAY) + setAttackTimer(OFF_ATTACK,ATTACK_DISPLAY_DELAY); + } + AttackerStateUpdate(pVictim, BASE_ATTACK); + resetAttackTimer(BASE_ATTACK); + } + } + + if ( haveOffhandWeapon() && isAttackReady(OFF_ATTACK)) + { + if(!IsWithinDistInMap(pVictim, pldistance)) + { + setAttackTimer(OFF_ATTACK,100); + } + else if( !HasInArc( 2*M_PI/3, pVictim )) + { + setAttackTimer(OFF_ATTACK,100); + } + else + { + // prevent base and off attack in same time, delay attack at 0.2 sec + uint32 base_att = getAttackTimer(BASE_ATTACK); + if(base_att < ATTACK_DISPLAY_DELAY) + setAttackTimer(BASE_ATTACK,ATTACK_DISPLAY_DELAY); + // do attack + AttackerStateUpdate(pVictim, OFF_ATTACK); + resetAttackTimer(OFF_ATTACK); + } + } + + Unit *owner = pVictim->GetOwner(); + Unit *u = owner ? owner : pVictim; + if(u->IsPvP() && (!duel || duel->opponent != u)) + { + UpdatePvP(true); + RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_ENTER_PVP_COMBAT); + } + } + } + + if(HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_RESTING)) + { + if(roll_chance_i(3) && GetTimeInnEnter() > 0) //freeze update + { + int time_inn = time(NULL)-GetTimeInnEnter(); + if (time_inn >= 10) //freeze update + { + float bubble = 0.125*sWorld.getRate(RATE_REST_INGAME); + //speed collect rest bonus (section/in hour) + SetRestBonus( GetRestBonus()+ time_inn*((float)GetUInt32Value(PLAYER_NEXT_LEVEL_XP)/72000)*bubble ); + UpdateInnerTime(time(NULL)); + } + } + } + + if(m_regenTimer > 0) + { + if(p_time >= m_regenTimer) + m_regenTimer = 0; + else + m_regenTimer -= p_time; + } + + if (m_weaponChangeTimer > 0) + { + if(p_time >= m_weaponChangeTimer) + m_weaponChangeTimer = 0; + else + m_weaponChangeTimer -= p_time; + } + + if (m_zoneUpdateTimer > 0) + { + if(p_time >= m_zoneUpdateTimer) + { + uint32 newzone = GetZoneId(); + if( m_zoneUpdateId != newzone ) + UpdateZone(newzone); // also update area + else + { + // use area updates as well + // needed for free far all arenas for example + uint32 newarea = GetAreaId(); + if( m_areaUpdateId != newarea ) + UpdateArea(newarea); + + m_zoneUpdateTimer = ZONE_UPDATE_INTERVAL; + } + } + else + m_zoneUpdateTimer -= p_time; + } + + if (isAlive()) + { + RegenerateAll(); + } + + if (m_deathState == JUST_DIED) + { + KillPlayer(); + } + + if(m_nextSave > 0) + { + if(p_time >= m_nextSave) + { + // m_nextSave reseted in SaveToDB call + SaveToDB(); + sLog.outDetail("Player '%s' (GUID: %u) saved", GetName(), GetGUIDLow()); + } + else + { + m_nextSave -= p_time; + } + } + + //Breathtimer + if(m_breathTimer > 0) + { + if(p_time >= m_breathTimer) + m_breathTimer = 0; + else + m_breathTimer -= p_time; + + } + + //Handle Water/drowning + HandleDrowning(); + + //Handle lava + HandleLava(); + + //Handle detect stealth players + if (m_DetectInvTimer > 0) + { + if (p_time >= m_DetectInvTimer) + { + m_DetectInvTimer = 3000; + HandleStealthedUnitsDetection(); + } + else + m_DetectInvTimer -= p_time; + } + + // Played time + if (now > m_Last_tick) + { + uint32 elapsed = uint32(now - m_Last_tick); + m_Played_time[0] += elapsed; // Total played time + m_Played_time[1] += elapsed; // Level played time + m_Last_tick = now; + } + + if (m_drunk) + { + m_drunkTimer += p_time; + + if (m_drunkTimer > 10000) + HandleSobering(); + } + + // not auto-free ghost from body in instances + if(m_deathTimer > 0 && !GetBaseMap()->Instanceable()) + { + if(p_time >= m_deathTimer) + { + m_deathTimer = 0; + BuildPlayerRepop(); + RepopAtGraveyard(); + } + else + m_deathTimer -= p_time; + } + + UpdateEnchantTime(p_time); + UpdateHomebindTime(p_time); + + // group update + SendUpdateToOutOfRangeGroupMembers(); + + Pet* pet = GetPet(); + if(pet && !IsWithinDistInMap(pet, OWNER_MAX_DISTANCE)) + { + RemovePet(pet, PET_SAVE_NOT_IN_SLOT, true); + return; + } +} + +void Player::setDeathState(DeathState s) +{ + uint32 ressSpellId = 0; + + bool cur = isAlive(); + + if(s == JUST_DIED && cur) + { + // drunken state is cleared on death + SetDrunkValue(0); + // lost combo points at any target (targeted combo points clear in Unit::setDeathState) + ClearComboPoints(); + + clearResurrectRequestData(); + + // remove form before other mods to prevent incorrect stats calculation + RemoveAurasDueToSpell(m_ShapeShiftFormSpellId); + + //FIXME: is pet dismissed at dying or releasing spirit? if second, add setDeathState(DEAD) to HandleRepopRequestOpcode and define pet unsummon here with (s == DEAD) + RemovePet(NULL, PET_SAVE_NOT_IN_SLOT, true); + + // remove uncontrolled pets + RemoveMiniPet(); + RemoveGuardians(); + + // save value before aura remove in Unit::setDeathState + ressSpellId = GetUInt32Value(PLAYER_SELF_RES_SPELL); + + // passive spell + if(!ressSpellId) + ressSpellId = GetResurrectionSpellId(); + } + Unit::setDeathState(s); + + // restore resurrection spell id for player after aura remove + if(s == JUST_DIED && cur && ressSpellId) + SetUInt32Value(PLAYER_SELF_RES_SPELL, ressSpellId); + + if(isAlive() && !cur) + { + //clear aura case after resurrection by another way (spells will be applied before next death) + SetUInt32Value(PLAYER_SELF_RES_SPELL, 0); + + // restore default warrior stance + if(getClass()== CLASS_WARRIOR) + CastSpell(this,SPELL_ID_PASSIVE_BATTLE_STANCE,true); + } +} + +void Player::BuildEnumData( QueryResult * result, WorldPacket * p_data ) +{ + *p_data << GetGUID(); + *p_data << m_name; + + *p_data << getRace(); + uint8 pClass = getClass(); + *p_data << pClass; + *p_data << getGender(); + + uint32 bytes = GetUInt32Value(PLAYER_BYTES); + *p_data << uint8(bytes); + *p_data << uint8(bytes >> 8); + *p_data << uint8(bytes >> 16); + *p_data << uint8(bytes >> 24); + + bytes = GetUInt32Value(PLAYER_BYTES_2); + *p_data << uint8(bytes); + + *p_data << uint8(getLevel()); // player level + // do not use GetMap! it will spawn a new instance since the bound instances are not loaded + uint32 zoneId = MapManager::Instance().GetZoneId(GetMapId(), GetPositionX(),GetPositionY()); + + *p_data << zoneId; + *p_data << GetMapId(); + + *p_data << GetPositionX(); + *p_data << GetPositionY(); + *p_data << GetPositionZ(); + + *p_data << GetUInt32Value(PLAYER_GUILDID); // guild id + + uint32 char_flags = 0; + if(HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_HIDE_HELM)) + char_flags |= CHARACTER_FLAG_HIDE_HELM; + if(HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_HIDE_CLOAK)) + char_flags |= CHARACTER_FLAG_HIDE_CLOAK; + if(HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_GHOST)) + char_flags |= CHARACTER_FLAG_GHOST; + if(HasAtLoginFlag(AT_LOGIN_RENAME)) + char_flags |= CHARACTER_FLAG_RENAME; + // always send the flag if declined names aren't used + // to let the client select a default method of declining the name + if(!sWorld.getConfig(CONFIG_DECLINED_NAMES_USED) || (result && result->Fetch()[12].GetCppString() != "")) + char_flags |= CHARACTER_FLAG_DECLINED; + + *p_data << (uint32)char_flags; // character flags + + *p_data << (uint8)1; // unknown + + // Pets info + { + uint32 petDisplayId = 0; + uint32 petLevel = 0; + uint32 petFamily = 0; + + // show pet at selection character in character list only for non-ghost character + if(result && isAlive() && (pClass == CLASS_WARLOCK || pClass == CLASS_HUNTER)) + { + Field* fields = result->Fetch(); + + uint32 entry = fields[9].GetUInt32(); + CreatureInfo const* cInfo = sCreatureStorage.LookupEntry(entry); + if(cInfo) + { + petDisplayId = fields[10].GetUInt32(); + petLevel = fields[11].GetUInt32(); + petFamily = cInfo->family; + } + } + + *p_data << (uint32)petDisplayId; + *p_data << (uint32)petLevel; + *p_data << (uint32)petFamily; + } + + /*ItemPrototype const *items[EQUIPMENT_SLOT_END]; + for (int i = 0; i < EQUIPMENT_SLOT_END; i++) + items[i] = NULL; + + QueryResult *result = CharacterDatabase.PQuery("SELECT slot,item_template FROM character_inventory WHERE guid = '%u' AND bag = 0",GetGUIDLow()); + if (result) + { + do + { + Field *fields = result->Fetch(); + uint8 slot = fields[0].GetUInt8() & 255; + uint32 item_id = fields[1].GetUInt32(); + if( slot >= EQUIPMENT_SLOT_END ) + continue; + + items[slot] = objmgr.GetItemPrototype(item_id); + if(!items[slot]) + { + sLog.outError( "Player::BuildEnumData: Player %s have unknown item (id: #%u) in inventory, skipped.", GetName(),item_id ); + continue; + } + } while (result->NextRow()); + delete result; + }*/ + + for (uint8 slot = 0; slot < EQUIPMENT_SLOT_END; slot++) + { + uint32 visualbase = PLAYER_VISIBLE_ITEM_1_0 + (slot * MAX_VISIBLE_ITEM_OFFSET); + uint32 item_id = GetUInt32Value(visualbase); + const ItemPrototype * proto = objmgr.GetItemPrototype(item_id); + SpellItemEnchantmentEntry const *enchant = NULL; + + for(uint8 enchantSlot = PERM_ENCHANTMENT_SLOT; enchantSlot<=TEMP_ENCHANTMENT_SLOT; enchantSlot++) + { + uint32 enchantId = GetUInt32Value(visualbase+1+enchantSlot); + if(enchant = sSpellItemEnchantmentStore.LookupEntry(enchantId)) + break; + } + + if (proto != NULL) + { + *p_data << (uint32)proto->DisplayInfoID; + *p_data << (uint8)proto->InventoryType; + *p_data << (uint32)(enchant?enchant->aura_id:0); + } + else + { + *p_data << (uint32)0; + *p_data << (uint8)0; + *p_data << (uint32)0; // enchant? + } + } + *p_data << (uint32)0; // first bag display id + *p_data << (uint8)0; // first bag inventory type + *p_data << (uint32)0; // enchant? +} + +bool Player::ToggleAFK() +{ + ToggleFlag(PLAYER_FLAGS, PLAYER_FLAGS_AFK); + + bool state = HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_AFK); + + // afk player not allowed in battleground + if(state && InBattleGround()) + LeaveBattleground(); + + return state; +} + +bool Player::ToggleDND() +{ + ToggleFlag(PLAYER_FLAGS, PLAYER_FLAGS_DND); + + return HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_DND); +} + +uint8 Player::chatTag() const +{ + // it's bitmask + // 0x8 - ?? + // 0x4 - gm + // 0x2 - dnd + // 0x1 - afk + if(isGameMaster()) + return 4; + else if(isDND()) + return 3; + if(isAFK()) + return 1; + else + return 0; +} + +bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientation, uint32 options) +{ + if(!MapManager::IsValidMapCoord(mapid, x, y, z, orientation)) + { + sLog.outError("TeleportTo: invalid map %d or absent instance template.", mapid); + return false; + } + + // preparing unsummon pet if lost (we must get pet before teleportation or will not find it later) + Pet* pet = GetPet(); + + MapEntry const* mEntry = sMapStore.LookupEntry(mapid); + + // don't let enter battlegrounds without assigned battleground id (for example through areatrigger)... + if(!InBattleGround() && mEntry->IsBattleGround() && !GetSession()->GetSecurity()) + return false; + + bool tbc = GetSession()->IsTBC() && sWorld.getConfig(CONFIG_EXPANSION) > 0; + + // normal client and TBC map + if(!tbc && mEntry->IsExpansionMap()) + { + sLog.outDebug("Player %s using Normal client and tried teleport to non existing map %u", GetName(), mapid); + + if(GetTransport()) + RepopAtGraveyard(); // teleport to near graveyard if on transport, looks blizz like :) + + SendTransferAborted(mapid, TRANSFER_ABORT_INSUF_EXPAN_LVL1); + + return false; // normal client can't teleport to this map... + } + else if(tbc) // can teleport to any existing map + { + sLog.outDebug("Player %s have TBC client and will teleported to map %u", GetName(), mapid); + } + else + { + sLog.outDebug("Player %s have normal client and will teleported to standard map %u", GetName(), mapid); + } + /* + only TBC (no 0x80000 and 0x10 flags...) + 3604590=0x37006E=0x200000 + 0x100000 + 0x40000 + 0x20000 + 0x10000 + 0x40 + 0x20 + 0x8 + 0x4 + 0x2 + + Kharazan (normal/TBC??), but not have 0x10 flag (accessible by normal client?) + 4128878=0x3F006E=0x200000 + 0x100000 + 0x80000 + 0x40000 + 0x20000 + 0x10000 + 0x40 + 0x20 + 0x8 + 0x4 + 0x2 + + normal+TBC maps + 4128894=0x3F007E=0x200000 + 0x100000 + 0x80000 + 0x40000 + 0x20000 + 0x10000 + 0x40 + 0x20 + 0x10 + 0x8 + 0x4 + 0x2 + + normal+TBC maps + 8323198=0x7F007E=0x400000 + 0x200000 + 0x100000 + 0x80000 + 0x40000 + 0x20000 + 0x10000 + 0x40 + 0x20 + 0x10 + 0x8 + 0x4 + 0x2 + */ + + // if we were on a transport, leave + if (!(options & TELE_TO_NOT_LEAVE_TRANSPORT) && m_transport) + { + m_transport->RemovePassenger(this); + m_transport = NULL; + m_movementInfo.t_x = 0.0f; + m_movementInfo.t_y = 0.0f; + m_movementInfo.t_z = 0.0f; + m_movementInfo.t_o = 0.0f; + m_movementInfo.t_time = 0; + } + + SetSemaphoreTeleport(true); + + // The player was ported to another map and looses the duel immediatly. + // We have to perform this check before the teleport, otherwise the + // ObjectAccessor won't find the flag. + if (duel && this->GetMapId()!=mapid) + { + GameObject* obj = ObjectAccessor::GetGameObject(*this, GetUInt64Value(PLAYER_DUEL_ARBITER)); + if (obj) + DuelComplete(DUEL_FLED); + } + + // reset movement flags at teleport, because player will continue move with these flags after teleport + SetUnitMovementFlags(0); + + if ((this->GetMapId() == mapid) && (!m_transport)) + { + // prepare zone change detect + uint32 old_zone = GetZoneId(); + + // near teleport + if(!GetSession()->PlayerLogout()) + { + WorldPacket data; + BuildTeleportAckMsg(&data, x, y, z, orientation); + GetSession()->SendPacket(&data); + SetPosition( x, y, z, orientation, true); + } + else + // this will be used instead of the current location in SaveToDB + m_teleport_dest = WorldLocation(mapid, x, y, z, orientation); + + //BuildHeartBeatMsg(&data); + //SendMessageToSet(&data, true); + if (!(options & TELE_TO_NOT_UNSUMMON_PET)) + { + //same map, only remove pet if out of range + if(pet && !IsWithinDistInMap(pet, OWNER_MAX_DISTANCE)) + { + if(pet->isControlled() && !pet->isTemporarySummoned() ) + m_temporaryUnsummonedPetNumber = pet->GetCharmInfo()->GetPetNumber(); + else + m_temporaryUnsummonedPetNumber = 0; + + RemovePet(pet, PET_SAVE_NOT_IN_SLOT); + } + } + + if(!(options & TELE_TO_NOT_LEAVE_COMBAT)) + CombatStop(); + + if (!(options & TELE_TO_NOT_UNSUMMON_PET)) + { + // resummon pet + if(pet && m_temporaryUnsummonedPetNumber) + { + Pet* NewPet = new Pet; + if(!NewPet->LoadPetFromDB(this, 0, m_temporaryUnsummonedPetNumber, true)) + delete NewPet; + + m_temporaryUnsummonedPetNumber = 0; + } + } + + SetSemaphoreTeleport(false); + + if(!GetSession()->PlayerLogout()) + UpdateZone(GetZoneId()); + + // new zone + if(old_zone != GetZoneId()) + { + // honorless target + if(pvpInfo.inHostileArea) + CastSpell(this, 2479, true); + } + } + else + { + // far teleport to another map + Map* oldmap = IsInWorld() ? MapManager::Instance().GetMap(GetMapId(), this) : NULL; + // check if we can enter before stopping combat / removing pet / totems / interrupting spells + + // Check enter rights before map getting to avoid creating instance copy for player + // this check not dependent from map instance copy and same for all instance copies of selected map + if (!MapManager::Instance().CanPlayerEnter(mapid, this)) + { + SetSemaphoreTeleport(false); + return false; + } + + // If the map is not created, assume it is possible to enter it. + // It will be created in the WorldPortAck. + Map *map = MapManager::Instance().FindMap(mapid); + if (!map || map->CanEnter(this)) + { + SetSelection(0); + + CombatStop(); + + ResetContestedPvP(); + + // remove player from battleground on far teleport (when changing maps) + if(BattleGround const* bg = GetBattleGround()) + { + // Note: at battleground join battleground id set before teleport + // and we already will found "current" battleground + // just need check that this is targeted map or leave + if(bg->GetMapId() != mapid) + LeaveBattleground(false); // don't teleport to entry point + } + + // remove pet on map change + if (pet) + { + //leaving map -> delete pet right away (doing this later will cause problems) + if(pet->isControlled() && !pet->isTemporarySummoned()) + m_temporaryUnsummonedPetNumber = pet->GetCharmInfo()->GetPetNumber(); + else + m_temporaryUnsummonedPetNumber = 0; + + RemovePet(pet, PET_SAVE_NOT_IN_SLOT); + } + + // remove all dyn objects + RemoveAllDynObjects(); + + // stop spellcasting + // not attempt interrupt teleportation spell at caster teleport + if(!(options & TELE_TO_SPELL)) + if(IsNonMeleeSpellCasted(true)) + InterruptNonMeleeSpells(true); + + if(!GetSession()->PlayerLogout()) + { + // send transfer packets + WorldPacket data(SMSG_TRANSFER_PENDING, (4+4+4)); + data << uint32(mapid); + if (m_transport) + { + data << m_transport->GetEntry() << GetMapId(); + } + GetSession()->SendPacket(&data); + + data.Initialize(SMSG_NEW_WORLD, (20)); + if (m_transport) + { + data << (uint32)mapid << m_movementInfo.t_x << m_movementInfo.t_y << m_movementInfo.t_z << m_movementInfo.t_o; + } + else + { + data << (uint32)mapid << (float)x << (float)y << (float)z << (float)orientation; + } + GetSession()->SendPacket( &data ); + SendSavedInstances(); + + // remove from old map now + if(oldmap) oldmap->Remove(this, false); + } + + // new final coordinates + float final_x = x; + float final_y = y; + float final_z = z; + float final_o = orientation; + + if(m_transport) + { + final_x += m_movementInfo.t_x; + final_y += m_movementInfo.t_y; + final_z += m_movementInfo.t_z; + final_o += m_movementInfo.t_o; + } + + m_teleport_dest = WorldLocation(mapid, final_x, final_y, final_z, final_o); + // if the player is saved before worldportack (at logout for example) + // this will be used instead of the current location in SaveToDB + + RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_CHANGE_MAP); + + // move packet sent by client always after far teleport + // SetPosition(final_x, final_y, final_z, final_o, true); + SetDontMove(true); + + // code for finish transfer to new map called in WorldSession::HandleMoveWorldportAckOpcode at client packet + } + else + return false; + } + return true; +} + +void Player::AddToWorld() +{ + ///- Do not add/remove the player from the object storage + ///- It will crash when updating the ObjectAccessor + ///- The player should only be added when logging in + Unit::AddToWorld(); + + for(int i = PLAYER_SLOT_START; i < PLAYER_SLOT_END; i++) + { + if(m_items[i]) + m_items[i]->AddToWorld(); + } +} + +void Player::RemoveFromWorld() +{ + // cleanup + if(IsInWorld()) + { + ///- Release charmed creatures, unsummon totems and remove pets/guardians + Uncharm(); + UnsummonAllTotems(); + RemoveMiniPet(); + RemoveGuardians(); + } + + for(int i = PLAYER_SLOT_START; i < PLAYER_SLOT_END; i++) + { + if(m_items[i]) + m_items[i]->RemoveFromWorld(); + } + + ///- Do not add/remove the player from the object storage + ///- It will crash when updating the ObjectAccessor + ///- The player should only be removed when logging out + Unit::RemoveFromWorld(); +} + +void Player::RewardRage( uint32 damage, uint32 weaponSpeedHitFactor, bool attacker ) +{ + float addRage; + + float rageconversion = ((0.0091107836 * getLevel()*getLevel())+3.225598133*getLevel())+4.2652911; + + if(attacker) + { + addRage = ((damage/rageconversion*7.5 + weaponSpeedHitFactor)/2); + + // talent who gave more rage on attack + addRage *= 1.0f + GetTotalAuraModifier(SPELL_AURA_MOD_RAGE_FROM_DAMAGE_DEALT) / 100.0f; + } + else + { + addRage = damage/rageconversion*2.5; + + // Berserker Rage effect + if(HasAura(18499,0)) + addRage *= 1.3; + } + + addRage *= sWorld.getRate(RATE_POWER_RAGE_INCOME); + + ModifyPower(POWER_RAGE, uint32(addRage*10)); +} + +void Player::RegenerateAll() +{ + if (m_regenTimer != 0) + return; + uint32 regenDelay = 2000; + + // Not in combat or they have regeneration + if( !isInCombat() || HasAuraType(SPELL_AURA_MOD_REGEN_DURING_COMBAT) || + HasAuraType(SPELL_AURA_MOD_HEALTH_REGEN_IN_COMBAT) || IsPolymorphed() ) + { + RegenerateHealth(); + if (!isInCombat() && !HasAuraType(SPELL_AURA_INTERRUPT_REGEN)) + Regenerate(POWER_RAGE); + } + + Regenerate( POWER_ENERGY ); + + Regenerate( POWER_MANA ); + + m_regenTimer = regenDelay; +} + +void Player::Regenerate(Powers power) +{ + uint32 curValue = GetPower(power); + uint32 maxValue = GetMaxPower(power); + + float addvalue = 0.0f; + + switch (power) + { + case POWER_MANA: + { + bool recentCast = IsUnderLastManaUseEffect(); + float ManaIncreaseRate = sWorld.getRate(RATE_POWER_MANA); + if (recentCast) + { + // Mangos Updates Mana in intervals of 2s, which is correct + addvalue = GetFloatValue(PLAYER_FIELD_MOD_MANA_REGEN_INTERRUPT) * ManaIncreaseRate * 2.00f; + } + else + { + addvalue = GetFloatValue(PLAYER_FIELD_MOD_MANA_REGEN) * ManaIncreaseRate * 2.00f; + } + } break; + case POWER_RAGE: // Regenerate rage + { + float RageDecreaseRate = sWorld.getRate(RATE_POWER_RAGE_LOSS); + addvalue = 30 * RageDecreaseRate; // 3 rage by tick + } break; + case POWER_ENERGY: // Regenerate energy (rogue) + addvalue = 20; + break; + case POWER_FOCUS: + case POWER_HAPPINESS: + break; + } + + // Mana regen calculated in Player::UpdateManaRegen() + // Exist only for POWER_MANA, POWER_ENERGY, POWER_FOCUS auras + if(power != POWER_MANA) + { + AuraList const& ModPowerRegenPCTAuras = GetAurasByType(SPELL_AURA_MOD_POWER_REGEN_PERCENT); + for(AuraList::const_iterator i = ModPowerRegenPCTAuras.begin(); i != ModPowerRegenPCTAuras.end(); ++i) + if ((*i)->GetModifier()->m_miscvalue == power) + addvalue *= ((*i)->GetModifier()->m_amount + 100) / 100.0f; + } + + if (power != POWER_RAGE) + { + curValue += uint32(addvalue); + if (curValue > maxValue) + curValue = maxValue; + } + else + { + if(curValue <= uint32(addvalue)) + curValue = 0; + else + curValue -= uint32(addvalue); + } + SetPower(power, curValue); +} + +void Player::RegenerateHealth() +{ + uint32 curValue = GetHealth(); + uint32 maxValue = GetMaxHealth(); + + if (curValue >= maxValue) return; + + float HealthIncreaseRate = sWorld.getRate(RATE_HEALTH); + + float addvalue = 0.0f; + + // polymorphed case + if ( IsPolymorphed() ) + addvalue = GetMaxHealth()/3; + // normal regen case (maybe partly in combat case) + else if (!isInCombat() || HasAuraType(SPELL_AURA_MOD_REGEN_DURING_COMBAT) ) + { + addvalue = OCTRegenHPPerSpirit()* HealthIncreaseRate; + if (!isInCombat()) + { + AuraList const& mModHealthRegenPct = GetAurasByType(SPELL_AURA_MOD_HEALTH_REGEN_PERCENT); + for(AuraList::const_iterator i = mModHealthRegenPct.begin(); i != mModHealthRegenPct.end(); ++i) + addvalue *= (100.0f + (*i)->GetModifier()->m_amount) / 100.0f; + } + else if(HasAuraType(SPELL_AURA_MOD_REGEN_DURING_COMBAT)) + addvalue *= GetTotalAuraModifier(SPELL_AURA_MOD_REGEN_DURING_COMBAT) / 100.0f; + + if(!IsStandState()) + addvalue *= 1.5; + } + + // always regeneration bonus (including combat) + addvalue += GetTotalAuraModifier(SPELL_AURA_MOD_HEALTH_REGEN_IN_COMBAT); + + if(addvalue < 0) + addvalue = 0; + + ModifyHealth(int32(addvalue)); +} + +bool Player::CanInteractWithNPCs(bool alive) const +{ + if(alive && !isAlive()) + return false; + if(isInFlight()) + return false; + + return true; +} + +bool Player::IsUnderWater() const +{ + return IsInWater() && + GetPositionZ() < (MapManager::Instance().GetBaseMap(GetMapId())->GetWaterLevel(GetPositionX(),GetPositionY())-2); +} + +void Player::SetInWater(bool apply) +{ + if(m_isInWater==apply) + return; + + //define player in water by opcodes + //move player's guid into HateOfflineList of those mobs + //which can't swim and move guid back into ThreatList when + //on surface. + //TODO: exist also swimming mobs, and function must be symmetric to enter/leave water + m_isInWater = apply; + + // remove auras that need water/land + RemoveAurasWithInterruptFlags(apply ? AURA_INTERRUPT_FLAG_NOT_ABOVEWATER : AURA_INTERRUPT_FLAG_NOT_UNDERWATER); + + getHostilRefManager().updateThreatTables(); +} + +void Player::SetGameMaster(bool on) +{ + if(on) + { + m_ExtraFlags |= PLAYER_EXTRA_GM_ON; + setFaction(35); + SetFlag(PLAYER_FLAGS, PLAYER_FLAGS_GM); + + RemoveFlag(PLAYER_FLAGS, PLAYER_FLAGS_FFA_PVP); + ResetContestedPvP(); + + getHostilRefManager().setOnlineOfflineState(false); + CombatStop(); + } + else + { + m_ExtraFlags &= ~ PLAYER_EXTRA_GM_ON; + setFactionForRace(getRace()); + RemoveFlag(PLAYER_FLAGS, PLAYER_FLAGS_GM); + + // restore FFA PvP Server state + if(sWorld.IsFFAPvPRealm()) + SetFlag(PLAYER_FLAGS,PLAYER_FLAGS_FFA_PVP); + + // restore FFA PvP area state, remove not allowed for GM mounts + UpdateArea(m_areaUpdateId); + + getHostilRefManager().setOnlineOfflineState(true); + } + + ObjectAccessor::UpdateVisibilityForPlayer(this); +} + +void Player::SetGMVisible(bool on) +{ + if(on) + { + m_ExtraFlags &= ~PLAYER_EXTRA_GM_INVISIBLE; //remove flag + + // Reapply stealth/invisibility if active or show if not any + if(HasAuraType(SPELL_AURA_MOD_STEALTH)) + SetVisibility(VISIBILITY_GROUP_STEALTH); + else if(HasAuraType(SPELL_AURA_MOD_INVISIBILITY)) + SetVisibility(VISIBILITY_GROUP_INVISIBILITY); + else + SetVisibility(VISIBILITY_ON); + } + else + { + m_ExtraFlags |= PLAYER_EXTRA_GM_INVISIBLE; //add flag + + SetAcceptWhispers(false); + SetGameMaster(true); + + SetVisibility(VISIBILITY_OFF); + } +} + +bool Player::IsGroupVisibleFor(Player* p) const +{ + switch(sWorld.getConfig(CONFIG_GROUP_VISIBILITY)) + { + default: return IsInSameGroupWith(p); + case 1: return IsInSameRaidWith(p); + case 2: return GetTeam()==p->GetTeam(); + } +} + +bool Player::IsInSameGroupWith(Player const* p) const +{ + return p==this || GetGroup() != NULL && + GetGroup() == p->GetGroup() && + GetGroup()->SameSubGroup((Player*)this, (Player*)p); +} + +///- If the player is invited, remove him. If the group if then only 1 person, disband the group. +/// \todo Shouldn't we also check if there is no other invitees before disbanding the group? +void Player::UninviteFromGroup() +{ + if(GetGroupInvite()) // uninvited invitee + { + Group* group = GetGroupInvite(); + group->RemoveInvite(this); + + if(group->GetMembersCount() <= 1) // group has just 1 member => disband + { + if(group->IsCreated()) + { + group->Disband(true); + objmgr.RemoveGroup(group); + } + else + group->RemoveAllInvites(); + + delete group; + } + } +} + +void Player::RemoveFromGroup(Group* group, uint64 guid) +{ + if(group) + { + if (group->RemoveMember(guid, 0) <= 1) + { + // group->Disband(); already disbanded in RemoveMember + objmgr.RemoveGroup(group); + delete group; + // removemember sets the player's group pointer to NULL + } + } +} + +void Player::SendLogXPGain(uint32 GivenXP, Unit* victim, uint32 RestXP) +{ + WorldPacket data(SMSG_LOG_XPGAIN, 21); + data << uint64(victim ? victim->GetGUID() : 0); // guid + data << uint32(GivenXP+RestXP); // given experience + data << uint8(victim ? 0 : 1); // 00-kill_xp type, 01-non_kill_xp type + if(victim) + { + data << uint32(GivenXP); // experience without rested bonus + data << float(1); // 1 - none 0 - 100% group bonus output + } + data << uint8(0); // new 2.4.0 + GetSession()->SendPacket(&data); +} + +void Player::GiveXP(uint32 xp, Unit* victim) +{ + if ( xp < 1 ) + return; + + if(!isAlive()) + return; + + uint32 level = getLevel(); + + // XP to money conversion processed in Player::RewardQuest + if(level >= sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL)) + return; + + // handle SPELL_AURA_MOD_XP_PCT auras + Unit::AuraList const& ModXPPctAuras = GetAurasByType(SPELL_AURA_MOD_XP_PCT); + for(Unit::AuraList::const_iterator i = ModXPPctAuras.begin();i != ModXPPctAuras.end(); ++i) + xp = uint32(xp*(1.0f + (*i)->GetModifier()->m_amount / 100.0f)); + + // XP resting bonus for kill + uint32 rested_bonus_xp = victim ? GetXPRestBonus(xp) : 0; + + SendLogXPGain(xp,victim,rested_bonus_xp); + + uint32 curXP = GetUInt32Value(PLAYER_XP); + uint32 nextLvlXP = GetUInt32Value(PLAYER_NEXT_LEVEL_XP); + uint32 newXP = curXP + xp + rested_bonus_xp; + + while( newXP >= nextLvlXP && level < sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL) ) + { + newXP -= nextLvlXP; + + if ( level < sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL) ) + GiveLevel(level + 1); + + level = getLevel(); + nextLvlXP = GetUInt32Value(PLAYER_NEXT_LEVEL_XP); + } + + SetUInt32Value(PLAYER_XP, newXP); +} + +// Update player to next level +// Current player experience not update (must be update by caller) +void Player::GiveLevel(uint32 level) +{ + if ( level == getLevel() ) + return; + + PlayerLevelInfo info; + objmgr.GetPlayerLevelInfo(getRace(),getClass(),level,&info); + + PlayerClassLevelInfo classInfo; + objmgr.GetPlayerClassLevelInfo(getClass(),level,&classInfo); + + // send levelup info to client + WorldPacket data(SMSG_LEVELUP_INFO, (4+4+MAX_POWERS*4+MAX_STATS*4)); + data << uint32(level); + data << uint32(int32(classInfo.basehealth) - int32(GetCreateHealth())); + // for(int i = 0; i < MAX_POWERS; ++i) // Powers loop (0-6) + data << uint32(int32(classInfo.basemana) - int32(GetCreateMana())); + data << uint32(0); + data << uint32(0); + data << uint32(0); + data << uint32(0); + // end for + for(int i = STAT_STRENGTH; i < MAX_STATS; ++i) // Stats loop (0-4) + data << uint32(int32(info.stats[i]) - GetCreateStat(Stats(i))); + + GetSession()->SendPacket(&data); + + SetUInt32Value(PLAYER_NEXT_LEVEL_XP, MaNGOS::XP::xp_to_level(level)); + + //update level, max level of skills + if(getLevel()!= level) + m_Played_time[1] = 0; // Level Played Time reset + SetLevel(level); + UpdateMaxSkills(); + + // save base values (bonuses already included in stored stats + for(int i = STAT_STRENGTH; i < MAX_STATS; ++i) + SetCreateStat(Stats(i), info.stats[i]); + + SetCreateHealth(classInfo.basehealth); + SetCreateMana(classInfo.basemana); + + InitTalentForLevel(); + InitTaxiNodesForLevel(); + + UpdateAllStats(); + + // set current level health and mana/energy to maximum after applying all mods. + SetHealth(GetMaxHealth()); + SetPower(POWER_MANA, GetMaxPower(POWER_MANA)); + SetPower(POWER_ENERGY, GetMaxPower(POWER_ENERGY)); + if(GetPower(POWER_RAGE) > GetMaxPower(POWER_RAGE)) + SetPower(POWER_RAGE, GetMaxPower(POWER_RAGE)); + SetPower(POWER_FOCUS, 0); + SetPower(POWER_HAPPINESS, 0); + + // give level to summoned pet + Pet* pet = GetPet(); + if(pet && pet->getPetType()==SUMMON_PET) + pet->GivePetLevel(level); +} + +void Player::InitTalentForLevel() +{ + uint32 level = getLevel(); + // talents base at level diff ( talents = level - 9 but some can be used already) + if(level < 10) + { + // Remove all talent points + if(m_usedTalentCount > 0) // Free any used talents + { + resetTalents(true); + SetFreeTalentPoints(0); + } + } + else + { + uint32 talentPointsForLevel = uint32((level-9)*sWorld.getRate(RATE_TALENT)); + // if used more that have then reset + if(m_usedTalentCount > talentPointsForLevel) + { + if (GetSession()->GetSecurity() < SEC_ADMINISTRATOR) + resetTalents(true); + else + SetFreeTalentPoints(0); + } + // else update amount of free points + else + SetFreeTalentPoints(talentPointsForLevel-m_usedTalentCount); + } +} + +void Player::InitStatsForLevel(bool reapplyMods) +{ + if(reapplyMods) //reapply stats values only on .reset stats (level) command + _RemoveAllStatBonuses(); + + PlayerClassLevelInfo classInfo; + objmgr.GetPlayerClassLevelInfo(getClass(),getLevel(),&classInfo); + + PlayerLevelInfo info; + objmgr.GetPlayerLevelInfo(getRace(),getClass(),getLevel(),&info); + + SetUInt32Value(PLAYER_FIELD_MAX_LEVEL, sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL) ); + SetUInt32Value(PLAYER_NEXT_LEVEL_XP, MaNGOS::XP::xp_to_level(getLevel())); + + UpdateMaxSkills (); + + // set default cast time multiplier + SetFloatValue(UNIT_MOD_CAST_SPEED, 1.0f); + + // reset size before reapply auras + SetFloatValue(OBJECT_FIELD_SCALE_X,1.0f); + + // save base values (bonuses already included in stored stats + for(int i = STAT_STRENGTH; i < MAX_STATS; ++i) + SetCreateStat(Stats(i), info.stats[i]); + + for(int i = STAT_STRENGTH; i < MAX_STATS; ++i) + SetStat(Stats(i), info.stats[i]); + + SetCreateHealth(classInfo.basehealth); + + //set create powers + SetCreateMana(classInfo.basemana); + + SetArmor(int32(m_createStats[STAT_AGILITY]*2)); + + InitStatBuffMods(); + + //reset rating fields values + for(uint16 index = PLAYER_FIELD_COMBAT_RATING_1; index < PLAYER_FIELD_COMBAT_RATING_1 + MAX_COMBAT_RATING; ++index) + SetUInt32Value(index, 0); + + SetUInt32Value(PLAYER_FIELD_MOD_HEALING_DONE_POS,0); + for (int i = 0; i < 7; i++) + { + SetUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_NEG+i, 0); + SetUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS+i, 0); + SetFloatValue(PLAYER_FIELD_MOD_DAMAGE_DONE_PCT+i, 1.00f); + } + + //reset attack power, damage and attack speed fields + SetFloatValue(UNIT_FIELD_BASEATTACKTIME, 2000.0f ); + SetFloatValue(UNIT_FIELD_BASEATTACKTIME + 1, 2000.0f ); // offhand attack time + SetFloatValue(UNIT_FIELD_RANGEDATTACKTIME, 2000.0f ); + + SetFloatValue(UNIT_FIELD_MINDAMAGE, 0.0f ); + SetFloatValue(UNIT_FIELD_MAXDAMAGE, 0.0f ); + SetFloatValue(UNIT_FIELD_MINOFFHANDDAMAGE, 0.0f ); + SetFloatValue(UNIT_FIELD_MAXOFFHANDDAMAGE, 0.0f ); + SetFloatValue(UNIT_FIELD_MINRANGEDDAMAGE, 0.0f ); + SetFloatValue(UNIT_FIELD_MAXRANGEDDAMAGE, 0.0f ); + + SetUInt32Value(UNIT_FIELD_ATTACK_POWER, 0 ); + SetUInt32Value(UNIT_FIELD_ATTACK_POWER_MODS, 0 ); + SetFloatValue(UNIT_FIELD_ATTACK_POWER_MULTIPLIER,0.0f); + SetUInt32Value(UNIT_FIELD_RANGED_ATTACK_POWER, 0 ); + SetUInt32Value(UNIT_FIELD_RANGED_ATTACK_POWER_MODS,0 ); + SetFloatValue(UNIT_FIELD_RANGED_ATTACK_POWER_MULTIPLIER,0.0f); + + // Base crit values (will be recalculated in UpdateAllStats() at loading and in _ApplyAllStatBonuses() at reset + SetFloatValue(PLAYER_CRIT_PERCENTAGE,0.0f); + SetFloatValue(PLAYER_OFFHAND_CRIT_PERCENTAGE,0.0f); + SetFloatValue(PLAYER_RANGED_CRIT_PERCENTAGE,0.0f); + + // Init spell schools (will be recalculated in UpdateAllStats() at loading and in _ApplyAllStatBonuses() at reset + for (uint8 i = 0; i < 7; ++i) + SetFloatValue(PLAYER_SPELL_CRIT_PERCENTAGE1+i, 0.0f); + + SetFloatValue(PLAYER_PARRY_PERCENTAGE, 0.0f); + SetFloatValue(PLAYER_BLOCK_PERCENTAGE, 0.0f); + SetUInt32Value(PLAYER_SHIELD_BLOCK, 0); + + // Dodge percentage + SetFloatValue(PLAYER_DODGE_PERCENTAGE, 0.0f); + + // set armor (resistance 0) to original value (create_agility*2) + SetArmor(int32(m_createStats[STAT_AGILITY]*2)); + SetResistanceBuffMods(SpellSchools(0), true, 0.0f); + SetResistanceBuffMods(SpellSchools(0), false, 0.0f); + // set other resistance to original value (0) + for (int i = 1; i < MAX_SPELL_SCHOOL; i++) + { + SetResistance(SpellSchools(i), 0); + SetResistanceBuffMods(SpellSchools(i), true, 0.0f); + SetResistanceBuffMods(SpellSchools(i), false, 0.0f); + } + + SetUInt32Value(PLAYER_FIELD_MOD_TARGET_RESISTANCE,0); + SetUInt32Value(PLAYER_FIELD_MOD_TARGET_PHYSICAL_RESISTANCE,0); + for(int i = 0; i < MAX_SPELL_SCHOOL; ++i) + { + SetFloatValue(UNIT_FIELD_POWER_COST_MODIFIER+i,0.0f); + SetFloatValue(UNIT_FIELD_POWER_COST_MULTIPLIER+i,0.0f); + } + // Init data for form but skip reapply item mods for form + InitDataForForm(reapplyMods); + + // save new stats + for (int i = POWER_MANA; i < MAX_POWERS; i++) + SetMaxPower(Powers(i), uint32(GetCreatePowers(Powers(i)))); + + SetMaxHealth(classInfo.basehealth); // stamina bonus will applied later + + // cleanup mounted state (it will set correctly at aura loading if player saved at mount. + SetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID, 0); + + // cleanup unit flags (will be re-applied if need at aura load). + RemoveFlag( UNIT_FIELD_FLAGS, + UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_DISABLE_MOVE | UNIT_FLAG_NOT_ATTACKABLE_1 | + UNIT_FLAG_PET_IN_COMBAT | UNIT_FLAG_SILENCED | UNIT_FLAG_PACIFIED | + UNIT_FLAG_DISABLE_ROTATE | UNIT_FLAG_IN_COMBAT | UNIT_FLAG_DISARMED | + UNIT_FLAG_CONFUSED | UNIT_FLAG_FLEEING | UNIT_FLAG_NOT_SELECTABLE | + UNIT_FLAG_SKINNABLE | UNIT_FLAG_MOUNT | UNIT_FLAG_TAXI_FLIGHT ); + SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE ); // must be set + + // cleanup player flags (will be re-applied if need at aura load), to avoid have ghost flag without ghost aura, for example. + RemoveFlag(PLAYER_FLAGS, PLAYER_FLAGS_AFK | PLAYER_FLAGS_DND | PLAYER_FLAGS_GM | PLAYER_FLAGS_GHOST | PLAYER_FLAGS_FFA_PVP); + + SetByteValue(UNIT_FIELD_BYTES_1, 2, 0x00); // one form stealth modified bytes + + // restore if need some important flags + SetUInt32Value(PLAYER_FIELD_BYTES2, 0 ); // flags empty by default + + if(reapplyMods) //reapply stats values only on .reset stats (level) command + _ApplyAllStatBonuses(); + + // set current level health and mana/energy to maximum after applying all mods. + SetHealth(GetMaxHealth()); + SetPower(POWER_MANA, GetMaxPower(POWER_MANA)); + SetPower(POWER_ENERGY, GetMaxPower(POWER_ENERGY)); + if(GetPower(POWER_RAGE) > GetMaxPower(POWER_RAGE)) + SetPower(POWER_RAGE, GetMaxPower(POWER_RAGE)); + SetPower(POWER_FOCUS, 0); + SetPower(POWER_HAPPINESS, 0); +} + +void Player::SendInitialSpells() +{ + uint16 spellCount = 0; + + WorldPacket data(SMSG_INITIAL_SPELLS, (1+2+4*m_spells.size()+2+m_spellCooldowns.size()*(2+2+2+4+4))); + data << uint8(0); + + size_t countPos = data.wpos(); + data << uint16(spellCount); // spell count placeholder + + for (PlayerSpellMap::const_iterator itr = m_spells.begin(); itr != m_spells.end(); ++itr) + { + if(itr->second->state == PLAYERSPELL_REMOVED) + continue; + + if(!itr->second->active || itr->second->disabled) + continue; + + data << uint16(itr->first); + //data << uint16(itr->second->slotId); + data << uint16(0); // it's not slot id + + spellCount +=1; + } + + data.put(countPos,spellCount); // write real count value + + uint16 spellCooldowns = m_spellCooldowns.size(); + data << uint16(spellCooldowns); + for(SpellCooldowns::const_iterator itr=m_spellCooldowns.begin(); itr!=m_spellCooldowns.end(); itr++) + { + SpellEntry const *sEntry = sSpellStore.LookupEntry(itr->first); + if(!sEntry) + continue; + + data << uint16(itr->first); + + time_t cooldown = 0; + time_t curTime = time(NULL); + if(itr->second.end > curTime) + cooldown = (itr->second.end-curTime)*1000; + + data << uint16(itr->second.itemid); // cast item id + data << uint16(sEntry->Category); // spell category + if(sEntry->Category) // may be wrong, but anyway better than nothing... + { + data << uint32(0); + data << uint32(cooldown); + } + else + { + data << uint32(cooldown); + data << uint32(0); + } + } + + GetSession()->SendPacket(&data); + + sLog.outDetail( "CHARACTER: Sent Initial Spells" ); +} + +void Player::RemoveMail(uint32 id) +{ + for(PlayerMails::iterator itr = m_mail.begin(); itr != m_mail.end();++itr) + { + if ((*itr)->messageID == id) + { + //do not delete item, because Player::removeMail() is called when returning mail to sender. + m_mail.erase(itr); + return; + } + } +} + +void Player::SendMailResult(uint32 mailId, uint32 mailAction, uint32 mailError, uint32 equipError, uint32 item_guid, uint32 item_count) +{ + WorldPacket data(SMSG_SEND_MAIL_RESULT, (4+4+4+(mailError == MAIL_ERR_BAG_FULL?4:(mailAction == MAIL_ITEM_TAKEN?4+4:0)))); + data << (uint32) mailId; + data << (uint32) mailAction; + data << (uint32) mailError; + if ( mailError == MAIL_ERR_BAG_FULL ) + data << (uint32) equipError; + else if( mailAction == MAIL_ITEM_TAKEN ) + { + data << (uint32) item_guid; // item guid low? + data << (uint32) item_count; // item count? + } + GetSession()->SendPacket(&data); +} + +void Player::SendNewMail() +{ + // deliver undelivered mail + WorldPacket data(SMSG_RECEIVED_MAIL, 4); + data << (uint32) 0; + GetSession()->SendPacket(&data); +} + +void Player::UpdateNextMailTimeAndUnreads() +{ + // calculate next delivery time (min. from non-delivered mails + // and recalculate unReadMail + time_t cTime = time(NULL); + m_nextMailDelivereTime = 0; + unReadMails = 0; + for(PlayerMails::iterator itr = m_mail.begin(); itr != m_mail.end(); ++itr) + { + if((*itr)->deliver_time > cTime) + { + if(!m_nextMailDelivereTime || m_nextMailDelivereTime > (*itr)->deliver_time) + m_nextMailDelivereTime = (*itr)->deliver_time; + } + else if(((*itr)->checked & MAIL_CHECK_MASK_READ) == 0) + ++unReadMails; + } +} + +void Player::AddNewMailDeliverTime(time_t deliver_time) +{ + if(deliver_time <= time(NULL)) // ready now + { + ++unReadMails; + SendNewMail(); + } + else // not ready and no have ready mails + { + if(!m_nextMailDelivereTime || m_nextMailDelivereTime > deliver_time) + m_nextMailDelivereTime = deliver_time; + } +} + +bool Player::addSpell(uint32 spell_id, bool active, bool learning, bool loading, uint16 slot_id, bool disabled) +{ + SpellEntry const *spellInfo = sSpellStore.LookupEntry(spell_id); + if (!spellInfo) + { + // do character spell book cleanup (all characters) + if(loading && !learning) // spell load case + { + sLog.outError("Player::addSpell: Non-existed in SpellStore spell #%u request, deleting for all characters in `character_spell`.",spell_id); + CharacterDatabase.PExecute("DELETE FROM character_spell WHERE spell = '%u'",spell_id); + } + else + sLog.outError("Player::addSpell: Non-existed in SpellStore spell #%u request.",spell_id); + + return false; + } + + if(!SpellMgr::IsSpellValid(spellInfo,this,false)) + { + // do character spell book cleanup (all characters) + if(loading && !learning) // spell load case + { + sLog.outError("Player::addSpell: Broken spell #%u learning not allowed, deleting for all characters in `character_spell`.",spell_id); + CharacterDatabase.PExecute("DELETE FROM character_spell WHERE spell = '%u'",spell_id); + } + else + sLog.outError("Player::addSpell: Broken spell #%u learning not allowed.",spell_id); + + return false; + } + + PlayerSpellState state = learning ? PLAYERSPELL_NEW : PLAYERSPELL_UNCHANGED; + + bool disabled_case = false; + bool superceded_old = false; + + PlayerSpellMap::iterator itr = m_spells.find(spell_id); + if (itr != m_spells.end()) + { + // update active state for known spell + if(itr->second->active != active && itr->second->state != PLAYERSPELL_REMOVED && !itr->second->disabled) + { + itr->second->active = active; + + // loading && !learning == explicitly load from DB and then exist in it already and set correctly + if(loading && !learning) + itr->second->state = PLAYERSPELL_UNCHANGED; + else if(itr->second->state != PLAYERSPELL_NEW) + itr->second->state = PLAYERSPELL_CHANGED; + + if(!active) + { + WorldPacket data(SMSG_REMOVED_SPELL, 4); + data << uint16(spell_id); + GetSession()->SendPacket(&data); + } + return active; // learn (show in spell book if active now) + } + + if(itr->second->disabled != disabled && itr->second->state != PLAYERSPELL_REMOVED) + { + if(itr->second->state != PLAYERSPELL_NEW) + itr->second->state = PLAYERSPELL_CHANGED; + itr->second->disabled = disabled; + + if(disabled) + return false; + + disabled_case = true; + } + else switch(itr->second->state) + { + case PLAYERSPELL_UNCHANGED: // known saved spell + return false; + case PLAYERSPELL_REMOVED: // re-learning removed not saved spell + { + delete itr->second; + m_spells.erase(itr); + state = PLAYERSPELL_CHANGED; + break; // need re-add + } + default: // known not saved yet spell (new or modified) + { + // can be in case spell loading but learned at some previous spell loading + if(loading && !learning) + itr->second->state = PLAYERSPELL_UNCHANGED; + + return false; + } + } + } + + if(!disabled_case) // skip new spell adding if spell already known (disabled spells case) + { + // talent: unlearn all other talent ranks (high and low) + if(TalentSpellPos const* talentPos = GetTalentSpellPos(spell_id)) + { + if(TalentEntry const *talentInfo = sTalentStore.LookupEntry( talentPos->talent_id )) + { + for(int i=0; i <5; ++i) + { + // skip learning spell and no rank spell case + uint32 rankSpellId = talentInfo->RankID[i]; + if(!rankSpellId || rankSpellId==spell_id) + continue; + + // skip unknown ranks + if(!HasSpell(rankSpellId)) + continue; + + removeSpell(rankSpellId); + } + } + } + // non talent spell: learn low ranks (recursive call) + else if(uint32 prev_spell = spellmgr.GetPrevSpellInChain(spell_id)) + { + if(loading) // at spells loading, no output, but allow save + addSpell(prev_spell,active,true,loading,SPELL_WITHOUT_SLOT_ID,disabled); + else // at normal learning + learnSpell(prev_spell); + } + + PlayerSpell *newspell = new PlayerSpell; + newspell->active = active; + newspell->state = state; + newspell->disabled = disabled; + + // replace spells in action bars and spellbook to bigger rank if only one spell rank must be accessible + if(newspell->active && !newspell->disabled && !SpellMgr::canStackSpellRanks(spellInfo) && spellmgr.GetSpellRank(spellInfo->Id) != 0) + { + for( PlayerSpellMap::iterator itr = m_spells.begin(); itr != m_spells.end(); ++itr ) + { + if(itr->second->state == PLAYERSPELL_REMOVED) continue; + SpellEntry const *i_spellInfo = sSpellStore.LookupEntry(itr->first); + if(!i_spellInfo) continue; + + if( spellmgr.IsRankSpellDueToSpell(spellInfo,itr->first) ) + { + if(itr->second->active) + { + if(spellmgr.IsHighRankOfSpell(spell_id,itr->first)) + { + if(!loading) // not send spell (re-/over-)learn packets at loading + { + WorldPacket data(SMSG_SUPERCEDED_SPELL, (4)); + data << uint16(itr->first); + data << uint16(spell_id); + GetSession()->SendPacket( &data ); + } + + // mark old spell as disable (SMSG_SUPERCEDED_SPELL replace it in client by new) + itr->second->active = false; + itr->second->state = PLAYERSPELL_CHANGED; + superceded_old = true; // new spell replace old in action bars and spell book. + } + else if(spellmgr.IsHighRankOfSpell(itr->first,spell_id)) + { + if(!loading) // not send spell (re-/over-)learn packets at loading + { + WorldPacket data(SMSG_SUPERCEDED_SPELL, (4)); + data << uint16(spell_id); + data << uint16(itr->first); + GetSession()->SendPacket( &data ); + } + + // mark new spell as disable (not learned yet for client and will not learned) + newspell->active = false; + if(newspell->state != PLAYERSPELL_NEW) + newspell->state = PLAYERSPELL_CHANGED; + } + } + } + } + } + + uint16 tmpslot=slot_id; + + if (tmpslot == SPELL_WITHOUT_SLOT_ID) + { + uint16 maxid = 0; + PlayerSpellMap::iterator itr; + for (itr = m_spells.begin(); itr != m_spells.end(); ++itr) + { + if(itr->second->state == PLAYERSPELL_REMOVED) + continue; + if (itr->second->slotId > maxid) + maxid = itr->second->slotId; + } + tmpslot = maxid + 1; + } + + newspell->slotId = tmpslot; + m_spells[spell_id] = newspell; + + // return false if spell disabled + if (newspell->disabled) + return false; + } + + uint32 talentCost = GetTalentSpellCost(spell_id); + + // cast talents with SPELL_EFFECT_LEARN_SPELL (other dependent spells will learned later as not auto-learned) + // note: all spells with SPELL_EFFECT_LEARN_SPELL isn't passive + if( talentCost > 0 && IsSpellHaveEffect(spellInfo,SPELL_EFFECT_LEARN_SPELL) ) + { + // ignore stance requirement for talent learn spell (stance set for spell only for client spell description show) + CastSpell(this, spell_id, true); + } + // also cast passive spells (including all talents without SPELL_EFFECT_LEARN_SPELL) with additional checks + else if (IsPassiveSpell(spell_id)) + { + // if spell doesn't require a stance or the player is in the required stance + if( ( !spellInfo->Stances && + spell_id != 5420 && spell_id != 5419 && spell_id != 7376 && + spell_id != 7381 && spell_id != 21156 && spell_id != 21009 && + spell_id != 21178 && spell_id != 33948 && spell_id != 40121 ) || + m_form != 0 && (spellInfo->Stances & (1<<(m_form-1))) || + (spell_id == 5420 && m_form == FORM_TREE) || + (spell_id == 5419 && m_form == FORM_TRAVEL) || + (spell_id == 7376 && m_form == FORM_DEFENSIVESTANCE) || + (spell_id == 7381 && m_form == FORM_BERSERKERSTANCE) || + (spell_id == 21156 && m_form == FORM_BATTLESTANCE)|| + (spell_id == 21178 && (m_form == FORM_BEAR || m_form == FORM_DIREBEAR) ) || + (spell_id == 33948 && m_form == FORM_FLIGHT) || + (spell_id == 40121 && m_form == FORM_FLIGHT_EPIC) ) + //Check CasterAuraStates + if (!spellInfo->CasterAuraState || HasAuraState(AuraState(spellInfo->CasterAuraState))) + CastSpell(this, spell_id, true); + } + else if( IsSpellHaveEffect(spellInfo,SPELL_EFFECT_SKILL_STEP) ) + { + CastSpell(this, spell_id, true); + return false; + } + + // update used talent points count + m_usedTalentCount += talentCost; + + // update free primary prof.points (if any, can be none in case GM .learn prof. learning) + if(uint32 freeProfs = GetFreePrimaryProffesionPoints()) + { + if(spellmgr.IsPrimaryProfessionFirstRankSpell(spell_id)) + SetFreePrimaryProffesions(freeProfs-1); + } + + // add dependent skills + uint16 maxskill = GetMaxSkillValueForLevel(); + + SpellLearnSkillNode const* spellLearnSkill = spellmgr.GetSpellLearnSkill(spell_id); + + if(spellLearnSkill) + { + uint32 skill_value = GetPureSkillValue(spellLearnSkill->skill); + uint32 skill_max_value = GetPureMaxSkillValue(spellLearnSkill->skill); + + if(skill_value < spellLearnSkill->value) + skill_value = spellLearnSkill->value; + + uint32 new_skill_max_value = spellLearnSkill->maxvalue == 0 ? maxskill : spellLearnSkill->maxvalue; + + if(skill_max_value < new_skill_max_value) + skill_max_value = new_skill_max_value; + + SetSkill(spellLearnSkill->skill,skill_value,skill_max_value); + } + else + { + // not ranked skills + SkillLineAbilityMap::const_iterator lower = spellmgr.GetBeginSkillLineAbilityMap(spell_id); + SkillLineAbilityMap::const_iterator upper = spellmgr.GetEndSkillLineAbilityMap(spell_id); + + for(SkillLineAbilityMap::const_iterator _spell_idx = lower; _spell_idx != upper; ++_spell_idx) + { + SkillLineEntry const *pSkill = sSkillLineStore.LookupEntry(_spell_idx->second->skillId); + if(!pSkill) + continue; + + if(HasSkill(pSkill->id)) + continue; + + if(_spell_idx->second->learnOnGetSkill == ABILITY_LEARNED_ON_GET_RACE_OR_CLASS_SKILL || + // poison special case, not have ABILITY_LEARNED_ON_GET_RACE_OR_CLASS_SKILL + pSkill->id==SKILL_POISONS && _spell_idx->second->max_value==0 || + // lockpicking special case, not have ABILITY_LEARNED_ON_GET_RACE_OR_CLASS_SKILL + pSkill->id==SKILL_LOCKPICKING && _spell_idx->second->max_value==0 ) + { + switch(GetSkillRangeType(pSkill,_spell_idx->second->racemask!=0)) + { + case SKILL_RANGE_LANGUAGE: + SetSkill(pSkill->id, 300, 300 ); + break; + case SKILL_RANGE_LEVEL: + SetSkill(pSkill->id, 1, GetMaxSkillValueForLevel() ); + break; + case SKILL_RANGE_MONO: + SetSkill(pSkill->id, 1, 1 ); + break; + default: + break; + } + } + } + } + + // learn dependent spells + SpellLearnSpellMap::const_iterator spell_begin = spellmgr.GetBeginSpellLearnSpell(spell_id); + SpellLearnSpellMap::const_iterator spell_end = spellmgr.GetEndSpellLearnSpell(spell_id); + + for(SpellLearnSpellMap::const_iterator itr = spell_begin; itr != spell_end; ++itr) + { + if(!itr->second.autoLearned) + { + if(loading) // at spells loading, no output, but allow save + addSpell(itr->second.spell,true,true,loading); + else // at normal learning + learnSpell(itr->second.spell); + } + } + + // return true (for send learn packet) only if spell active (in case ranked spells) and not replace old spell + return active && !disabled && !superceded_old; +} + +void Player::learnSpell(uint32 spell_id) +{ + PlayerSpellMap::iterator itr = m_spells.find(spell_id); + + bool disabled = (itr != m_spells.end()) ? itr->second->disabled : false; + bool active = disabled ? itr->second->active : true; + + bool learning = addSpell(spell_id,active); + + // learn all disabled higher ranks (recursive) + SpellChainMapNext const& nextMap = spellmgr.GetSpellChainNext(); + for(SpellChainMapNext::const_iterator i = nextMap.lower_bound(spell_id); i != nextMap.upper_bound(spell_id); ++i) + { + PlayerSpellMap::iterator iter = m_spells.find(i->second); + if (disabled && iter != m_spells.end() && iter->second->disabled) + learnSpell(i->second); + } + + // prevent duplicated entires in spell book + if(!learning) + return; + + WorldPacket data(SMSG_LEARNED_SPELL, 4); + data << uint32(spell_id); + GetSession()->SendPacket(&data); +} + +void Player::removeSpell(uint32 spell_id, bool disabled) +{ + PlayerSpellMap::iterator itr = m_spells.find(spell_id); + if (itr == m_spells.end()) + return; + + if(itr->second->state == PLAYERSPELL_REMOVED || disabled && itr->second->disabled) + return; + + // unlearn non talent higher ranks (recursive) + SpellChainMapNext const& nextMap = spellmgr.GetSpellChainNext(); + for(SpellChainMapNext::const_iterator itr2 = nextMap.lower_bound(spell_id); itr2 != nextMap.upper_bound(spell_id); ++itr2) + if(HasSpell(itr2->second) && !GetTalentSpellPos(itr2->second)) + removeSpell(itr2->second,disabled); + + // removing + WorldPacket data(SMSG_REMOVED_SPELL, 4); + data << uint16(spell_id); + GetSession()->SendPacket(&data); + + if (disabled) + { + itr->second->disabled = disabled; + if(itr->second->state != PLAYERSPELL_NEW) + itr->second->state = PLAYERSPELL_CHANGED; + } + else + { + if(itr->second->state == PLAYERSPELL_NEW) + { + delete itr->second; + m_spells.erase(itr); + } + else + itr->second->state = PLAYERSPELL_REMOVED; + } + + RemoveAurasDueToSpell(spell_id); + + // remove pet auras + if(PetAura const* petSpell = spellmgr.GetPetAura(spell_id)) + RemovePetAura(petSpell); + + // free talent points + uint32 talentCosts = GetTalentSpellCost(spell_id); + if(talentCosts > 0) + { + if(talentCosts < m_usedTalentCount) + m_usedTalentCount -= talentCosts; + else + m_usedTalentCount = 0; + } + + // update free primary prof.points (if not overflow setting, can be in case GM use before .learn prof. learning) + if(spellmgr.IsPrimaryProfessionFirstRankSpell(spell_id)) + { + uint32 freeProfs = GetFreePrimaryProffesionPoints()+1; + if(freeProfs <= sWorld.getConfig(CONFIG_MAX_PRIMARY_TRADE_SKILL)) + SetFreePrimaryProffesions(freeProfs); + } + + // remove dependent skill + SpellLearnSkillNode const* spellLearnSkill = spellmgr.GetSpellLearnSkill(spell_id); + if(spellLearnSkill) + { + uint32 prev_spell = spellmgr.GetPrevSpellInChain(spell_id); + if(!prev_spell) // first rank, remove skill + SetSkill(spellLearnSkill->skill,0,0); + else + { + // search prev. skill setting by spell ranks chain + SpellLearnSkillNode const* prevSkill = spellmgr.GetSpellLearnSkill(prev_spell); + while(!prevSkill && prev_spell) + { + prev_spell = spellmgr.GetPrevSpellInChain(prev_spell); + prevSkill = spellmgr.GetSpellLearnSkill(spellmgr.GetFirstSpellInChain(prev_spell)); + } + + if(!prevSkill) // not found prev skill setting, remove skill + SetSkill(spellLearnSkill->skill,0,0); + else // set to prev. skill setting values + { + uint32 skill_value = GetPureSkillValue(prevSkill->skill); + uint32 skill_max_value = GetPureMaxSkillValue(prevSkill->skill); + + if(skill_value > prevSkill->value) + skill_value = prevSkill->value; + + uint32 new_skill_max_value = prevSkill->maxvalue == 0 ? GetMaxSkillValueForLevel() : prevSkill->maxvalue; + + if(skill_max_value > new_skill_max_value) + skill_max_value = new_skill_max_value; + + SetSkill(prevSkill->skill,skill_value,skill_max_value); + } + } + + } + else + { + // not ranked skills + SkillLineAbilityMap::const_iterator lower = spellmgr.GetBeginSkillLineAbilityMap(spell_id); + SkillLineAbilityMap::const_iterator upper = spellmgr.GetEndSkillLineAbilityMap(spell_id); + + for(SkillLineAbilityMap::const_iterator _spell_idx = lower; _spell_idx != upper; ++_spell_idx) + { + SkillLineEntry const *pSkill = sSkillLineStore.LookupEntry(_spell_idx->second->skillId); + if(!pSkill) + continue; + + if(_spell_idx->second->learnOnGetSkill == ABILITY_LEARNED_ON_GET_RACE_OR_CLASS_SKILL || + // poison special case, not have ABILITY_LEARNED_ON_GET_RACE_OR_CLASS_SKILL + pSkill->id==SKILL_POISONS && _spell_idx->second->max_value==0 || + // lockpicking special case, not have ABILITY_LEARNED_ON_GET_RACE_OR_CLASS_SKILL + pSkill->id==SKILL_LOCKPICKING && _spell_idx->second->max_value==0 ) + { + // not reset skills for professions and racial abilities + if( (pSkill->categoryId==SKILL_CATEGORY_SECONDARY || pSkill->categoryId==SKILL_CATEGORY_PROFESSION) && + (IsProfessionSkill(pSkill->id) || _spell_idx->second->racemask!=0) ) + continue; + + SetSkill(pSkill->id, 0, 0 ); + } + } + } + + // remove dependent spells + SpellLearnSpellMap::const_iterator spell_begin = spellmgr.GetBeginSpellLearnSpell(spell_id); + SpellLearnSpellMap::const_iterator spell_end = spellmgr.GetEndSpellLearnSpell(spell_id); + + for(SpellLearnSpellMap::const_iterator itr2 = spell_begin; itr2 != spell_end; ++itr2) + removeSpell(itr2->second.spell, disabled); +} + +void Player::RemoveArenaSpellCooldowns() +{ + // remove cooldowns on spells that has < 15 min CD + SpellCooldowns::iterator itr, next; + // iterate spell cooldowns + for(itr = m_spellCooldowns.begin();itr != m_spellCooldowns.end(); itr = next) + { + next = itr; + ++next; + SpellEntry const * entry = sSpellStore.LookupEntry(itr->first); + // check if spellentry is present and if the cooldown is less than 15 mins + if( entry && + entry->RecoveryTime <= 15 * MINUTE * 1000 && + entry->CategoryRecoveryTime <= 15 * MINUTE * 1000 ) + { + // notify player + WorldPacket data(SMSG_CLEAR_COOLDOWN, (4+8)); + data << uint32(itr->first); + data << GetGUID(); + GetSession()->SendPacket(&data); + // remove cooldown + m_spellCooldowns.erase(itr); + } + } +} + +void Player::RemoveAllSpellCooldown() +{ + if(!m_spellCooldowns.empty()) + { + for(SpellCooldowns::const_iterator itr = m_spellCooldowns.begin();itr != m_spellCooldowns.end(); ++itr) + { + WorldPacket data(SMSG_CLEAR_COOLDOWN, (4+8)); + data << uint32(itr->first); + data << uint64(GetGUID()); + GetSession()->SendPacket(&data); + } + m_spellCooldowns.clear(); + } +} + +void Player::_LoadSpellCooldowns(QueryResult *result) +{ + m_spellCooldowns.clear(); + + //QueryResult *result = CharacterDatabase.PQuery("SELECT spell,item,time FROM character_spell_cooldown WHERE guid = '%u'",GetGUIDLow()); + + if(result) + { + time_t curTime = time(NULL); + + do + { + Field *fields = result->Fetch(); + + uint32 spell_id = fields[0].GetUInt32(); + uint32 item_id = fields[1].GetUInt32(); + time_t db_time = (time_t)fields[2].GetUInt64(); + + if(!sSpellStore.LookupEntry(spell_id)) + { + sLog.outError("Player %u have unknown spell %u in `character_spell_cooldown`, skipping.",GetGUIDLow(),spell_id); + continue; + } + + // skip outdated cooldown + if(db_time <= curTime) + continue; + + AddSpellCooldown(spell_id, item_id, db_time); + + sLog.outDebug("Player (GUID: %u) spell %u, item %u cooldown loaded (%u secs).", GetGUIDLow(), spell_id, item_id, uint32(db_time-curTime)); + } + while( result->NextRow() ); + + delete result; + } +} + +void Player::_SaveSpellCooldowns() +{ + CharacterDatabase.PExecute("DELETE FROM character_spell_cooldown WHERE guid = '%u'", GetGUIDLow()); + + time_t curTime = time(NULL); + + // remove outdated and save active + for(SpellCooldowns::iterator itr = m_spellCooldowns.begin();itr != m_spellCooldowns.end();) + { + if(itr->second.end <= curTime) + m_spellCooldowns.erase(itr++); + else + { + CharacterDatabase.PExecute("INSERT INTO character_spell_cooldown (guid,spell,item,time) VALUES ('%u', '%u', '%u', '" I64FMTD "')", GetGUIDLow(), itr->first, itr->second.itemid, uint64(itr->second.end)); + ++itr; + } + } +} + +uint32 Player::resetTalentsCost() const +{ + // The first time reset costs 1 gold + if(m_resetTalentsCost < 1*GOLD) + return 1*GOLD; + // then 5 gold + else if(m_resetTalentsCost < 5*GOLD) + return 5*GOLD; + // After that it increases in increments of 5 gold + else if(m_resetTalentsCost < 10*GOLD) + return 10*GOLD; + else + { + uint32 months = (sWorld.GetGameTime() - m_resetTalentsTime)/MONTH; + if(months > 0) + { + // This cost will be reduced by a rate of 5 gold per month + int32 new_cost = int32(m_resetTalentsCost) - 5*GOLD*months; + // to a minimum of 10 gold. + return (new_cost < 10*GOLD ? 10*GOLD : new_cost); + } + else + { + // After that it increases in increments of 5 gold + int32 new_cost = m_resetTalentsCost + 5*GOLD; + // until it hits a cap of 50 gold. + if(new_cost > 50*GOLD) + new_cost = 50*GOLD; + return new_cost; + } + } +} + +bool Player::resetTalents(bool no_cost) +{ + // not need after this call + if(HasAtLoginFlag(AT_LOGIN_RESET_TALENTS)) + { + m_atLoginFlags = m_atLoginFlags & ~AT_LOGIN_RESET_TALENTS; + CharacterDatabase.PExecute("UPDATE characters set at_login = at_login & ~ %u WHERE guid ='%u'", uint32(AT_LOGIN_RESET_TALENTS), GetGUIDLow()); + } + + uint32 level = getLevel(); + uint32 talentPointsForLevel = level < 10 ? 0 : uint32((level-9)*sWorld.getRate(RATE_TALENT)); + + if (m_usedTalentCount == 0) + { + SetFreeTalentPoints(talentPointsForLevel); + return false; + } + + uint32 cost = 0; + + if(!no_cost) + { + cost = resetTalentsCost(); + + if (GetMoney() < cost) + { + SendBuyError( BUY_ERR_NOT_ENOUGHT_MONEY, 0, 0, 0); + return false; + } + } + + for (unsigned int i = 0; i < sTalentStore.GetNumRows(); i++) + { + TalentEntry const *talentInfo = sTalentStore.LookupEntry(i); + + if (!talentInfo) continue; + + TalentTabEntry const *talentTabInfo = sTalentTabStore.LookupEntry( talentInfo->TalentTab ); + + if(!talentTabInfo) + continue; + + // unlearn only talents for character class + // some spell learned by one class as normal spells or know at creation but another class learn it as talent, + // to prevent unexpected lost normal learned spell skip another class talents + if( (getClassMask() & talentTabInfo->ClassMask) == 0 ) + continue; + + for (int j = 0; j < 5; j++) + { + for(PlayerSpellMap::iterator itr = GetSpellMap().begin(); itr != GetSpellMap().end();) + { + if(itr->second->state == PLAYERSPELL_REMOVED || itr->second->disabled) + { + ++itr; + continue; + } + + // remove learned spells (all ranks) + uint32 itrFirstId = spellmgr.GetFirstSpellInChain(itr->first); + + // unlearn if first rank is talent or learned by talent + if (itrFirstId == talentInfo->RankID[j] || spellmgr.IsSpellLearnToSpell(talentInfo->RankID[j],itrFirstId)) + { + removeSpell(itr->first,!IsPassiveSpell(itr->first)); + itr = GetSpellMap().begin(); + continue; + } + else + ++itr; + } + } + } + + SetFreeTalentPoints(talentPointsForLevel); + + if(!no_cost) + { + ModifyMoney(-(int32)cost); + + m_resetTalentsCost = cost; + m_resetTalentsTime = time(NULL); + } + + //FIXME: remove pet before or after unlearn spells? for now after unlearn to allow removing of talent related, pet affecting auras + RemovePet(NULL,PET_SAVE_NOT_IN_SLOT, true); + + return true; +} + +bool Player::_removeSpell(uint16 spell_id) +{ + PlayerSpellMap::iterator itr = m_spells.find(spell_id); + if (itr != m_spells.end()) + { + delete itr->second; + m_spells.erase(itr); + return true; + } + return false; +} + +Mail* Player::GetMail(uint32 id) +{ + for(PlayerMails::iterator itr = m_mail.begin(); itr != m_mail.end(); itr++) + { + if ((*itr)->messageID == id) + { + return (*itr); + } + } + return NULL; +} + +void Player::_SetCreateBits(UpdateMask *updateMask, Player *target) const +{ + if(target == this) + { + Object::_SetCreateBits(updateMask, target); + } + else + { + for(uint16 index = 0; index < m_valuesCount; index++) + { + if(GetUInt32Value(index) != 0 && updateVisualBits.GetBit(index)) + updateMask->SetBit(index); + } + } +} + +void Player::_SetUpdateBits(UpdateMask *updateMask, Player *target) const +{ + if(target == this) + { + Object::_SetUpdateBits(updateMask, target); + } + else + { + Object::_SetUpdateBits(updateMask, target); + *updateMask &= updateVisualBits; + } +} + +void Player::InitVisibleBits() +{ + updateVisualBits.SetCount(PLAYER_END); + + updateVisualBits.SetBit(OBJECT_FIELD_GUID); + updateVisualBits.SetBit(OBJECT_FIELD_TYPE); + updateVisualBits.SetBit(OBJECT_FIELD_SCALE_X); + + updateVisualBits.SetBit(UNIT_FIELD_CHARM); + updateVisualBits.SetBit(UNIT_FIELD_CHARM+1); + + updateVisualBits.SetBit(UNIT_FIELD_SUMMON); + updateVisualBits.SetBit(UNIT_FIELD_SUMMON+1); + + updateVisualBits.SetBit(UNIT_FIELD_CHARMEDBY); + + updateVisualBits.SetBit(UNIT_FIELD_TARGET); + updateVisualBits.SetBit(UNIT_FIELD_TARGET+1); + + updateVisualBits.SetBit(UNIT_FIELD_CHANNEL_OBJECT); + updateVisualBits.SetBit(UNIT_FIELD_CHANNEL_OBJECT+1); + + updateVisualBits.SetBit(UNIT_FIELD_HEALTH); + updateVisualBits.SetBit(UNIT_FIELD_POWER1); + updateVisualBits.SetBit(UNIT_FIELD_POWER2); + updateVisualBits.SetBit(UNIT_FIELD_POWER3); + updateVisualBits.SetBit(UNIT_FIELD_POWER4); + updateVisualBits.SetBit(UNIT_FIELD_POWER5); + + updateVisualBits.SetBit(UNIT_FIELD_MAXHEALTH); + updateVisualBits.SetBit(UNIT_FIELD_MAXPOWER1); + updateVisualBits.SetBit(UNIT_FIELD_MAXPOWER2); + updateVisualBits.SetBit(UNIT_FIELD_MAXPOWER3); + updateVisualBits.SetBit(UNIT_FIELD_MAXPOWER4); + updateVisualBits.SetBit(UNIT_FIELD_MAXPOWER5); + + updateVisualBits.SetBit(UNIT_FIELD_LEVEL); + updateVisualBits.SetBit(UNIT_FIELD_FACTIONTEMPLATE); + updateVisualBits.SetBit(UNIT_FIELD_BYTES_0); + updateVisualBits.SetBit(UNIT_FIELD_FLAGS); + updateVisualBits.SetBit(UNIT_FIELD_FLAGS_2); + for(uint16 i = UNIT_FIELD_AURA; i < UNIT_FIELD_AURASTATE; ++i) + updateVisualBits.SetBit(i); + updateVisualBits.SetBit(UNIT_FIELD_AURASTATE); + updateVisualBits.SetBit(UNIT_FIELD_BASEATTACKTIME); + updateVisualBits.SetBit(UNIT_FIELD_BASEATTACKTIME + 1); + updateVisualBits.SetBit(UNIT_FIELD_RANGEDATTACKTIME); + updateVisualBits.SetBit(UNIT_FIELD_BOUNDINGRADIUS); + updateVisualBits.SetBit(UNIT_FIELD_COMBATREACH); + updateVisualBits.SetBit(UNIT_FIELD_DISPLAYID); + updateVisualBits.SetBit(UNIT_FIELD_NATIVEDISPLAYID); + updateVisualBits.SetBit(UNIT_FIELD_MOUNTDISPLAYID); + updateVisualBits.SetBit(UNIT_FIELD_BYTES_1); + updateVisualBits.SetBit(UNIT_FIELD_MOUNTDISPLAYID); + updateVisualBits.SetBit(UNIT_FIELD_PETNUMBER); + updateVisualBits.SetBit(UNIT_FIELD_PET_NAME_TIMESTAMP); + updateVisualBits.SetBit(UNIT_DYNAMIC_FLAGS); + updateVisualBits.SetBit(UNIT_CHANNEL_SPELL); + updateVisualBits.SetBit(UNIT_MOD_CAST_SPEED); + updateVisualBits.SetBit(UNIT_FIELD_BYTES_2); + + updateVisualBits.SetBit(PLAYER_FLAGS); + updateVisualBits.SetBit(PLAYER_BYTES); + updateVisualBits.SetBit(PLAYER_BYTES_2); + updateVisualBits.SetBit(PLAYER_BYTES_3); + updateVisualBits.SetBit(PLAYER_GUILDID); + updateVisualBits.SetBit(PLAYER_GUILDRANK); + updateVisualBits.SetBit(PLAYER_GUILD_TIMESTAMP); + updateVisualBits.SetBit(PLAYER_DUEL_TEAM); + updateVisualBits.SetBit(PLAYER_DUEL_ARBITER); + updateVisualBits.SetBit(PLAYER_DUEL_ARBITER+1); + + // PLAYER_QUEST_LOG_x also visible bit on official (but only on party/raid)... + for(uint16 i = PLAYER_QUEST_LOG_1_1; i < PLAYER_QUEST_LOG_25_2; i+=4) + updateVisualBits.SetBit(i); + + //Players visible items are not inventory stuff + //431) = 884 (0x374) = main weapon + for(uint16 i = 0; i < EQUIPMENT_SLOT_END; i++) + { + // item creator + updateVisualBits.SetBit(PLAYER_VISIBLE_ITEM_1_CREATOR + (i*MAX_VISIBLE_ITEM_OFFSET) + 0); + updateVisualBits.SetBit(PLAYER_VISIBLE_ITEM_1_CREATOR + (i*MAX_VISIBLE_ITEM_OFFSET) + 1); + + uint16 visual_base = PLAYER_VISIBLE_ITEM_1_0 + (i*MAX_VISIBLE_ITEM_OFFSET); + + // item entry + updateVisualBits.SetBit(visual_base + 0); + + // item enchantment IDs + for(uint8 j = 0; j < MAX_INSPECTED_ENCHANTMENT_SLOT; ++j) + updateVisualBits.SetBit(visual_base + 1 + j); + + // random properties + updateVisualBits.SetBit(PLAYER_VISIBLE_ITEM_1_PROPERTIES + 0 + (i*MAX_VISIBLE_ITEM_OFFSET)); + updateVisualBits.SetBit(PLAYER_VISIBLE_ITEM_1_PROPERTIES + 1 + (i*MAX_VISIBLE_ITEM_OFFSET)); + } + + updateVisualBits.SetBit(PLAYER_CHOSEN_TITLE); + + updateVisualBits.SetBit(UNIT_VIRTUAL_ITEM_SLOT_DISPLAY); + updateVisualBits.SetBit(UNIT_VIRTUAL_ITEM_SLOT_DISPLAY + 1); + updateVisualBits.SetBit(UNIT_VIRTUAL_ITEM_SLOT_DISPLAY + 2); + updateVisualBits.SetBit(UNIT_VIRTUAL_ITEM_INFO); + updateVisualBits.SetBit(UNIT_VIRTUAL_ITEM_INFO + 1); + updateVisualBits.SetBit(UNIT_VIRTUAL_ITEM_INFO + 2); + updateVisualBits.SetBit(UNIT_VIRTUAL_ITEM_INFO + 3); + updateVisualBits.SetBit(UNIT_VIRTUAL_ITEM_INFO + 4); + updateVisualBits.SetBit(UNIT_VIRTUAL_ITEM_INFO + 5); +} + +void Player::BuildCreateUpdateBlockForPlayer( UpdateData *data, Player *target ) const +{ + for(int i = 0; i < EQUIPMENT_SLOT_END; i++) + { + if(m_items[i] == NULL) + continue; + + m_items[i]->BuildCreateUpdateBlockForPlayer( data, target ); + } + + if(target == this) + { + + for(int i = INVENTORY_SLOT_BAG_START; i < BANK_SLOT_BAG_END; i++) + { + if(m_items[i] == NULL) + continue; + + m_items[i]->BuildCreateUpdateBlockForPlayer( data, target ); + } + for(int i = KEYRING_SLOT_START; i < KEYRING_SLOT_END; i++) + { + if(m_items[i] == NULL) + continue; + + m_items[i]->BuildCreateUpdateBlockForPlayer( data, target ); + } + } + + Unit::BuildCreateUpdateBlockForPlayer( data, target ); +} + +void Player::DestroyForPlayer( Player *target ) const +{ + Unit::DestroyForPlayer( target ); + + for(int i = 0; i < INVENTORY_SLOT_BAG_END; i++) + { + if(m_items[i] == NULL) + continue; + + m_items[i]->DestroyForPlayer( target ); + } + + if(target == this) + { + + for(int i = INVENTORY_SLOT_BAG_START; i < BANK_SLOT_BAG_END; i++) + { + if(m_items[i] == NULL) + continue; + + m_items[i]->DestroyForPlayer( target ); + } + for(int i = KEYRING_SLOT_START; i < KEYRING_SLOT_END; i++) + { + if(m_items[i] == NULL) + continue; + + m_items[i]->DestroyForPlayer( target ); + } + } +} + +bool Player::HasSpell(uint32 spell) const +{ + PlayerSpellMap::const_iterator itr = m_spells.find((uint16)spell); + return (itr != m_spells.end() && itr->second->state != PLAYERSPELL_REMOVED && !itr->second->disabled); +} + +TrainerSpellState Player::GetTrainerSpellState(TrainerSpell const* trainer_spell) const +{ + if (!trainer_spell) + return TRAINER_SPELL_RED; + + if (!trainer_spell->spell) + return TRAINER_SPELL_RED; + + // known spell + if(HasSpell(trainer_spell->spell)) + return TRAINER_SPELL_GRAY; + + // check race/class requirement + if(!IsSpellFitByClassAndRace(trainer_spell->spell)) + return TRAINER_SPELL_RED; + + // check level requirement + if(getLevel() < trainer_spell->reqlevel) + return TRAINER_SPELL_RED; + + if(SpellChainNode const* spell_chain = spellmgr.GetSpellChainNode(trainer_spell->spell)) + { + // check prev.rank requirement + if(spell_chain->prev && !HasSpell(spell_chain->prev)) + return TRAINER_SPELL_RED; + + // check additional spell requirement + if(spell_chain->req && !HasSpell(spell_chain->req)) + return TRAINER_SPELL_RED; + } + + // check skill requirement + if(trainer_spell->reqskill && GetBaseSkillValue(trainer_spell->reqskill) < trainer_spell->reqskillvalue) + return TRAINER_SPELL_RED; + + // exist, already checked at loading + SpellEntry const* spell = sSpellStore.LookupEntry(trainer_spell->spell); + + // secondary prof. or not prof. spell + uint32 skill = spell->EffectMiscValue[1]; + + if(spell->Effect[1] != SPELL_EFFECT_SKILL || !IsPrimaryProfessionSkill(skill)) + return TRAINER_SPELL_GREEN; + + // check primary prof. limit + if(spellmgr.IsPrimaryProfessionFirstRankSpell(spell->Id) && GetFreePrimaryProffesionPoints() == 0) + return TRAINER_SPELL_RED; + + return TRAINER_SPELL_GREEN; +} + +void Player::DeleteFromDB(uint64 playerguid, uint32 accountId, bool updateRealmChars) +{ + uint32 guid = GUID_LOPART(playerguid); + + // convert corpse to bones if exist (to prevent exiting Corpse in World without DB entry) + // bones will be deleted by corpse/bones deleting thread shortly + ObjectAccessor::Instance().ConvertCorpseForPlayer(playerguid); + + // remove from guild + uint32 guildId = GetGuildIdFromDB(playerguid); + if(guildId != 0) + { + Guild* guild = objmgr.GetGuildById(guildId); + if(guild) + guild->DelMember(guid); + } + + // the player was uninvited already on logout so just remove from group + QueryResult *resultGroup = CharacterDatabase.PQuery("SELECT leaderGuid FROM group_member WHERE memberGuid='%u'", guid); + if(resultGroup) + { + uint64 leaderGuid = MAKE_NEW_GUID((*resultGroup)[0].GetUInt32(), 0, HIGHGUID_PLAYER); + delete resultGroup; + Group* group = objmgr.GetGroupByLeader(leaderGuid); + if(group) + { + RemoveFromGroup(group, playerguid); + } + } + + // remove signs from petitions (also remove petitions if owner); + RemovePetitionsAndSigns(playerguid, 10); + + // return back all mails with COD and Item 0 1 2 3 4 5 6 + QueryResult *resultMail = CharacterDatabase.PQuery("SELECT id,mailTemplateId,sender,subject,itemTextId,money,has_items FROM mail WHERE receiver='%u' AND has_items<>0 AND cod<>0", guid); + if(resultMail) + { + do + { + Field *fields = resultMail->Fetch(); + + uint32 mail_id = fields[0].GetUInt32(); + uint16 mailTemplateId= fields[1].GetUInt16(); + uint32 sender = fields[2].GetUInt32(); + std::string subject = fields[3].GetCppString(); + uint32 itemTextId = fields[4].GetUInt32(); + uint32 money = fields[5].GetUInt32(); + bool has_items = fields[6].GetBool(); + + //we can return mail now + //so firstly delete the old one + CharacterDatabase.PExecute("DELETE FROM mail WHERE id = '%u'", mail_id); + + MailItemsInfo mi; + if(has_items) + { + QueryResult *resultItems = CharacterDatabase.PQuery("SELECT item_guid,item_template FROM mail_items WHERE mail_id='%u'", mail_id); + if(resultItems) + { + do + { + Field *fields2 = resultItems->Fetch(); + + uint32 item_guidlow = fields2[0].GetUInt32(); + uint32 item_template = fields2[1].GetUInt32(); + + ItemPrototype const* itemProto = objmgr.GetItemPrototype(item_template); + if(!itemProto) + { + CharacterDatabase.PExecute("DELETE FROM item_instance WHERE guid = '%u'", item_guidlow); + continue; + } + + Item *pItem = NewItemOrBag(itemProto); + if(!pItem->LoadFromDB(item_guidlow, MAKE_NEW_GUID(guid, 0, HIGHGUID_PLAYER))) + { + pItem->FSetState(ITEM_REMOVED); + pItem->SaveToDB(); // it also deletes item object ! + continue; + } + + mi.AddItem(item_guidlow, item_template, pItem); + } + while (resultItems->NextRow()); + + delete resultItems; + } + } + + CharacterDatabase.PExecute("DELETE FROM mail_items WHERE mail_id = '%u'", mail_id); + + uint32 pl_account = objmgr.GetPlayerAccountIdByGUID(MAKE_NEW_GUID(guid, 0, HIGHGUID_PLAYER)); + + WorldSession::SendReturnToSender(MAIL_NORMAL, pl_account, guid, sender, subject, itemTextId, &mi, money, 0, mailTemplateId); + } + while (resultMail->NextRow()); + + delete resultMail; + } + + // unsummon and delete for pets in world is not required: player deleted from CLI or character list with not loaded pet. + // Get guids of character's pets, will deleted in transaction + QueryResult *resultPets = CharacterDatabase.PQuery("SELECT id FROM character_pet WHERE owner = '%u'",guid); + + // NOW we can finally clear other DB data related to character + CharacterDatabase.BeginTransaction(); + if (resultPets) + { + do + { + Field *fields3 = resultPets->Fetch(); + uint32 petguidlow = fields3[0].GetUInt32(); + Pet::DeleteFromDB(petguidlow); + } while (resultPets->NextRow()); + delete resultPets; + } + + CharacterDatabase.PExecute("DELETE FROM characters WHERE guid = '%u'",guid); + CharacterDatabase.PExecute("DELETE FROM character_declinedname WHERE guid = '%u'",guid); + CharacterDatabase.PExecute("DELETE FROM character_action WHERE guid = '%u'",guid); + CharacterDatabase.PExecute("DELETE FROM character_aura WHERE guid = '%u'",guid); + CharacterDatabase.PExecute("DELETE FROM character_gifts WHERE guid = '%u'",guid); + CharacterDatabase.PExecute("DELETE FROM character_homebind WHERE guid = '%u'",guid); + CharacterDatabase.PExecute("DELETE FROM character_instance WHERE guid = '%u'",guid); + CharacterDatabase.PExecute("DELETE FROM group_instance WHERE leaderGuid = '%u'",guid); + CharacterDatabase.PExecute("DELETE FROM character_inventory WHERE guid = '%u'",guid); + CharacterDatabase.PExecute("DELETE FROM character_queststatus WHERE guid = '%u'",guid); + CharacterDatabase.PExecute("DELETE FROM character_reputation WHERE guid = '%u'",guid); + CharacterDatabase.PExecute("DELETE FROM character_spell WHERE guid = '%u'",guid); + CharacterDatabase.PExecute("DELETE FROM character_spell_cooldown WHERE guid = '%u'",guid); + CharacterDatabase.PExecute("DELETE FROM character_ticket WHERE guid = '%u'",guid); + CharacterDatabase.PExecute("DELETE FROM item_instance WHERE owner_guid = '%u'",guid); + CharacterDatabase.PExecute("DELETE FROM character_social WHERE guid = '%u' OR friend='%u'",guid,guid); + CharacterDatabase.PExecute("DELETE FROM mail WHERE receiver = '%u'",guid); + CharacterDatabase.PExecute("DELETE FROM mail_items WHERE receiver = '%u'",guid); + CharacterDatabase.PExecute("DELETE FROM character_pet WHERE owner = '%u'",guid); + CharacterDatabase.PExecute("DELETE FROM character_pet_declinedname WHERE owner = '%u'",guid); + CharacterDatabase.CommitTransaction(); + + //loginDatabase.PExecute("UPDATE realmcharacters SET numchars = numchars - 1 WHERE acctid = %d AND realmid = %d", accountId, realmID); + if(updateRealmChars) sWorld.UpdateRealmCharCount(accountId); +} + +void Player::SetMovement(PlayerMovementType pType) +{ + WorldPacket data; + switch(pType) + { + case MOVE_ROOT: data.Initialize(SMSG_FORCE_MOVE_ROOT, GetPackGUID().size()+4); break; + case MOVE_UNROOT: data.Initialize(SMSG_FORCE_MOVE_UNROOT, GetPackGUID().size()+4); break; + case MOVE_WATER_WALK: data.Initialize(SMSG_MOVE_WATER_WALK, GetPackGUID().size()+4); break; + case MOVE_LAND_WALK: data.Initialize(SMSG_MOVE_LAND_WALK, GetPackGUID().size()+4); break; + default: + sLog.outError("Player::SetMovement: Unsupported move type (%d), data not sent to client.",pType); + return; + } + data.append(GetPackGUID()); + data << uint32(0); + GetSession()->SendPacket( &data ); +} + +/* Preconditions: + - a resurrectable corpse must not be loaded for the player (only bones) + - the player must be in world +*/ +void Player::BuildPlayerRepop() +{ + if(getRace() == RACE_NIGHTELF) + CastSpell(this, 20584, true); // auras SPELL_AURA_INCREASE_SPEED(+speed in wisp form), SPELL_AURA_INCREASE_SWIM_SPEED(+swim speed in wisp form), SPELL_AURA_TRANSFORM (to wisp form) + CastSpell(this, 8326, true); // auras SPELL_AURA_GHOST, SPELL_AURA_INCREASE_SPEED(why?), SPELL_AURA_INCREASE_SWIM_SPEED(why?) + + // there must be SMSG.FORCE_RUN_SPEED_CHANGE, SMSG.FORCE_SWIM_SPEED_CHANGE, SMSG.MOVE_WATER_WALK + // there must be SMSG.STOP_MIRROR_TIMER + // there we must send 888 opcode + + // the player cannot have a corpse already, only bones which are not returned by GetCorpse + if(GetCorpse()) + { + sLog.outError("BuildPlayerRepop: player %s(%d) already has a corpse", GetName(), GetGUIDLow()); + assert(false); + } + + // create a corpse and place it at the player's location + CreateCorpse(); + Corpse *corpse = GetCorpse(); + if(!corpse) + { + sLog.outError("Error creating corpse for Player %s [%u]", GetName(), GetGUIDLow()); + return; + } + GetMap()->Add(corpse); + + // convert player body to ghost + SetHealth( 1 ); + + SetMovement(MOVE_WATER_WALK); + if(!GetSession()->isLogingOut()) + SetMovement(MOVE_UNROOT); + + // BG - remove insignia related + RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SKINNABLE); + + SendCorpseReclaimDelay(); + + // to prevent cheating + corpse->ResetGhostTime(); + + StopMirrorTimers(); //disable timers(bars) + + SetFloatValue(UNIT_FIELD_BOUNDINGRADIUS, (float)1.0); //see radius of death player? + + SetByteValue(UNIT_FIELD_BYTES_1, 3, PLAYER_STATE_FLAG_ALWAYS_STAND); +} + +void Player::SendDelayResponse(const uint32 ml_seconds) +{ + WorldPacket data( SMSG_QUERY_TIME_RESPONSE, 4+4 ); + data << (uint32)time(NULL); + data << (uint32)0; + GetSession()->SendPacket( &data ); +} + +void Player::ResurrectPlayer(float restore_percent, bool updateToWorld, bool applySickness) +{ + WorldPacket data(SMSG_DEATH_RELEASE_LOC, 4*4); // remove spirit healer position + data << uint32(-1); + data << float(0); + data << float(0); + data << float(0); + GetSession()->SendPacket(&data); + + // speed change, land walk + + // remove death flag + set aura + SetByteValue(UNIT_FIELD_BYTES_1, 3, 0x00); + if(getRace() == RACE_NIGHTELF) + RemoveAurasDueToSpell(20584); // speed bonuses + RemoveAurasDueToSpell(8326); // SPELL_AURA_GHOST + + setDeathState(ALIVE); + + SetMovement(MOVE_LAND_WALK); + SetMovement(MOVE_UNROOT); + + m_deathTimer = 0; + + // set health/powers (0- will be set in caller) + if(restore_percent>0.0f) + { + SetHealth(uint32(GetMaxHealth()*restore_percent)); + SetPower(POWER_MANA, uint32(GetMaxPower(POWER_MANA)*restore_percent)); + SetPower(POWER_RAGE, 0); + SetPower(POWER_ENERGY, uint32(GetMaxPower(POWER_ENERGY)*restore_percent)); + } + + // update visbility + ObjectAccessor::UpdateVisibilityForPlayer(this); + + // some items limited to specific map + DestroyZoneLimitedItem( true, GetZoneId()); + + if(!applySickness || getLevel() <= 10) + return; + + //Characters from level 1-10 are not affected by resurrection sickness. + //Characters from level 11-19 will suffer from one minute of sickness + //for each level they are above 10. + //Characters level 20 and up suffer from ten minutes of sickness. + int32 startLevel = sWorld.getConfig(CONFIG_DEATH_SICKNESS_LEVEL); + + if(int32(getLevel()) >= startLevel) + { + // set resurrection sickness + CastSpell(this,SPELL_ID_PASSIVE_RESURRECTION_SICKNESS,true); + + // not full duration + if(int32(getLevel()) < startLevel+9) + { + int32 delta = (int32(getLevel()) - startLevel + 1)*MINUTE; + + for(int i =0; i < 3; ++i) + { + if(Aura* Aur = GetAura(SPELL_ID_PASSIVE_RESURRECTION_SICKNESS,i)) + { + Aur->SetAuraDuration(delta*1000); + Aur->UpdateAuraDuration(); + } + } + } + } +} + +void Player::KillPlayer() +{ + SetMovement(MOVE_ROOT); + + StopMirrorTimers(); //disable timers(bars) + + setDeathState(CORPSE); + //SetFlag( UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_IN_PVP ); + + SetFlag(UNIT_DYNAMIC_FLAGS, 0x00); + ApplyModFlag(PLAYER_FIELD_BYTES, PLAYER_FIELD_BYTE_RELEASE_TIMER, !sMapStore.LookupEntry(GetMapId())->Instanceable()); + + // 6 minutes until repop at graveyard + m_deathTimer = 6*MINUTE*1000; + + UpdateCorpseReclaimDelay(); // dependent at use SetDeathPvP() call before kill + + // don't create corpse at this moment, player might be falling + + // update visibility + ObjectAccessor::UpdateObjectVisibility(this); +} + +void Player::CreateCorpse() +{ + // prevent existence 2 corpse for player + SpawnCorpseBones(); + + uint32 _uf, _pb, _pb2, _cfb1, _cfb2; + + Corpse *corpse = new Corpse( (m_ExtraFlags & PLAYER_EXTRA_PVP_DEATH) ? CORPSE_RESURRECTABLE_PVP : CORPSE_RESURRECTABLE_PVE ); + SetPvPDeath(false); + + if(!corpse->Create(objmgr.GenerateLowGuid(HIGHGUID_CORPSE), this, GetMapId(), GetPositionX(), + GetPositionY(), GetPositionZ(), GetOrientation())) + { + delete corpse; + return; + } + + _uf = GetUInt32Value(UNIT_FIELD_BYTES_0); + _pb = GetUInt32Value(PLAYER_BYTES); + _pb2 = GetUInt32Value(PLAYER_BYTES_2); + + uint8 race = (uint8)(_uf); + uint8 skin = (uint8)(_pb); + uint8 face = (uint8)(_pb >> 8); + uint8 hairstyle = (uint8)(_pb >> 16); + uint8 haircolor = (uint8)(_pb >> 24); + uint8 facialhair = (uint8)(_pb2); + + _cfb1 = ((0x00) | (race << 8) | (getGender() << 16) | (skin << 24)); + _cfb2 = ((face) | (hairstyle << 8) | (haircolor << 16) | (facialhair << 24)); + + corpse->SetUInt32Value( CORPSE_FIELD_BYTES_1, _cfb1 ); + corpse->SetUInt32Value( CORPSE_FIELD_BYTES_2, _cfb2 ); + + uint32 flags = CORPSE_FLAG_UNK2; + if(HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_HIDE_HELM)) + flags |= CORPSE_FLAG_HIDE_HELM; + if(HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_HIDE_CLOAK)) + flags |= CORPSE_FLAG_HIDE_CLOAK; + if(InBattleGround()) + flags |= CORPSE_FLAG_LOOTABLE; // to be able to remove insignia + corpse->SetUInt32Value( CORPSE_FIELD_FLAGS, flags ); + + corpse->SetUInt32Value( CORPSE_FIELD_DISPLAY_ID, GetNativeDisplayId() ); + + corpse->SetUInt32Value( CORPSE_FIELD_GUILD, GetGuildId() ); + + uint32 iDisplayID; + uint16 iIventoryType; + uint32 _cfi; + for (int i = 0; i < EQUIPMENT_SLOT_END; i++) + { + if(m_items[i]) + { + iDisplayID = m_items[i]->GetProto()->DisplayInfoID; + iIventoryType = (uint16)m_items[i]->GetProto()->InventoryType; + + _cfi = (uint16(iDisplayID)) | (iIventoryType)<< 24; + corpse->SetUInt32Value(CORPSE_FIELD_ITEM + i,_cfi); + } + } + + // we don't SaveToDB for players in battlegrounds so don't do it for corpses either + const MapEntry *entry = sMapStore.LookupEntry(corpse->GetMapId()); + assert(entry); + if(entry->map_type != MAP_BATTLEGROUND) + corpse->SaveToDB(); + + // register for player, but not show + ObjectAccessor::Instance().AddCorpse(corpse); +} + +void Player::SpawnCorpseBones() +{ + if(ObjectAccessor::Instance().ConvertCorpseForPlayer(GetGUID())) + SaveToDB(); // prevent loading as ghost without corpse +} + +Corpse* Player::GetCorpse() const +{ + return ObjectAccessor::Instance().GetCorpseForPlayerGUID(GetGUID()); +} + +void Player::DurabilityLossAll(double percent, bool inventory) +{ + for(int i = EQUIPMENT_SLOT_START; i < EQUIPMENT_SLOT_END; i++) + if(Item *pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i )) + DurabilityLoss(pItem,percent); + + if(inventory) + { + // bags not have durability + // for(int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; i++) + + for(int i = INVENTORY_SLOT_ITEM_START; i < INVENTORY_SLOT_ITEM_END; i++) + if(Item *pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i )) + DurabilityLoss(pItem,percent); + + // keys not have durability + //for(int i = KEYRING_SLOT_START; i < KEYRING_SLOT_END; i++) + + for(int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; i++) + if(Bag* pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i )) + if(ItemPrototype const *pBagProto = pBag->GetProto()) + for(uint32 j = 0; j < pBagProto->ContainerSlots; j++) + if(Item* pItem = GetItemByPos( i, j )) + DurabilityLoss(pItem,percent); + } +} + +void Player::DurabilityLoss(Item* item, double percent) +{ + if(!item ) + return; + + uint32 pMaxDurability = item ->GetUInt32Value(ITEM_FIELD_MAXDURABILITY); + + if(!pMaxDurability) + return; + + uint32 pDurabilityLoss = uint32(pMaxDurability*percent); + + if(pDurabilityLoss < 1 ) + pDurabilityLoss = 1; + + DurabilityPointsLoss(item,pDurabilityLoss); +} + +void Player::DurabilityPointsLossAll(int32 points, bool inventory) +{ + for(int i = EQUIPMENT_SLOT_START; i < EQUIPMENT_SLOT_END; i++) + if(Item *pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i )) + DurabilityPointsLoss(pItem,points); + + if(inventory) + { + // bags not have durability + // for(int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; i++) + + for(int i = INVENTORY_SLOT_ITEM_START; i < INVENTORY_SLOT_ITEM_END; i++) + if(Item *pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i )) + DurabilityPointsLoss(pItem,points); + + // keys not have durability + //for(int i = KEYRING_SLOT_START; i < KEYRING_SLOT_END; i++) + + for(int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; i++) + if(Bag* pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i )) + if(ItemPrototype const *pBagProto = pBag->GetProto()) + for(uint32 j = 0; j < pBagProto->ContainerSlots; j++) + if(Item* pItem = GetItemByPos( i, j )) + DurabilityPointsLoss(pItem,points); + } +} + +void Player::DurabilityPointsLoss(Item* item, int32 points) +{ + int32 pMaxDurability = item->GetUInt32Value(ITEM_FIELD_MAXDURABILITY); + int32 pOldDurability = item->GetUInt32Value(ITEM_FIELD_DURABILITY); + int32 pNewDurability = pOldDurability - points; + + if (pNewDurability < 0) + pNewDurability = 0; + else if (pNewDurability > pMaxDurability) + pNewDurability = pMaxDurability; + + if (pOldDurability != pNewDurability) + { + // modify item stats _before_ Durability set to 0 to pass _ApplyItemMods internal check + if ( pNewDurability == 0 && pOldDurability > 0 && item->IsEquipped()) + _ApplyItemMods(item,item->GetSlot(), false); + + item->SetUInt32Value(ITEM_FIELD_DURABILITY, pNewDurability); + + // modify item stats _after_ restore durability to pass _ApplyItemMods internal check + if ( pNewDurability > 0 && pOldDurability == 0 && item->IsEquipped()) + _ApplyItemMods(item,item->GetSlot(), true); + + item->SetState(ITEM_CHANGED, this); + } +} + +void Player::DurabilityPointLossForEquipSlot(EquipmentSlots slot) +{ + if(Item *pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, slot )) + DurabilityPointsLoss(pItem,1); +} + +uint32 Player::DurabilityRepairAll(bool cost, float discountMod, bool guildBank) +{ + uint32 TotalCost = 0; + // equipped, backpack, bags itself + for(int i = EQUIPMENT_SLOT_START; i < INVENTORY_SLOT_ITEM_END; i++) + TotalCost += DurabilityRepair(( (INVENTORY_SLOT_BAG_0 << 8) | i ),cost,discountMod, guildBank); + + // bank, buyback and keys not repaired + + // items in inventory bags + for(int j = INVENTORY_SLOT_BAG_START; j < INVENTORY_SLOT_BAG_END; j++) + for(int i = 0; i < MAX_BAG_SIZE; i++) + TotalCost += DurabilityRepair(( (j << 8) | i ),cost,discountMod, guildBank); + return TotalCost; +} + +uint32 Player::DurabilityRepair(uint16 pos, bool cost, float discountMod, bool guildBank) +{ + Item* item = GetItemByPos(pos); + + uint32 TotalCost = 0; + if(!item) + return TotalCost; + + uint32 maxDurability = item->GetUInt32Value(ITEM_FIELD_MAXDURABILITY); + if(!maxDurability) + return TotalCost; + + uint32 curDurability = item->GetUInt32Value(ITEM_FIELD_DURABILITY); + + if(cost) + { + uint32 LostDurability = maxDurability - curDurability; + if(LostDurability>0) + { + ItemPrototype const *ditemProto = sItemStorage.LookupEntry(item->GetEntry()); + if(!ditemProto) + { + sLog.outError("ERROR: RepairDurability: Unknown item id %u", ditemProto); + return TotalCost; + } + + DurabilityCostsEntry const *dcost = sDurabilityCostsStore.LookupEntry(ditemProto->ItemLevel); + if(!dcost) + { + sLog.outError("ERROR: RepairDurability: Wrong item lvl %u", dcost); + return TotalCost; + } + + DurabilityQualityEntry const *dQualitymodEntry = sDurabilityQualityStore.LookupEntry((ditemProto->Quality+1)*2); + if(!dQualitymodEntry) + { + sLog.outError("ERROR: RepairDurability: Wrong dQualityModEntry %u", dQualitymodEntry); + return TotalCost; + } + + uint32 dmultiplier = dcost->multiplier[ItemSubClassToDurabilityMultiplierId(ditemProto->Class,ditemProto->SubClass)]; + uint32 costs = uint32(LostDurability*dmultiplier*double(dQualitymodEntry->quality_mod)); + + costs = uint32(costs * discountMod); + + if (costs==0) //fix for ITEM_QUALITY_ARTIFACT + costs = 1; + + if (guildBank) + { + if (GetGuildId()==0) + { + DEBUG_LOG("You are not member of a guild"); + return TotalCost; + } + + Guild *pGuild = objmgr.GetGuildById(GetGuildId()); + if (!pGuild) + return TotalCost; + + if (!pGuild->HasRankRight(GetRank(), GR_RIGHT_WITHDRAW_REPAIR)) + { + DEBUG_LOG("You do not have rights to withdraw for repairs"); + return TotalCost; + } + + if (pGuild->GetMemberMoneyWithdrawRem(GetGUIDLow()) < costs) + { + DEBUG_LOG("You do not have enough money withdraw amount remaining"); + return TotalCost; + } + + if (pGuild->GetGuildBankMoney() < costs) + { + DEBUG_LOG("There is not enough money in bank"); + return TotalCost; + } + + pGuild->MemberMoneyWithdraw(costs, GetGUIDLow()); + TotalCost = costs; + } + else if (GetMoney() < costs) + { + DEBUG_LOG("You do not have enough money"); + return TotalCost; + } + else + ModifyMoney( -int32(costs) ); + } + } + + item->SetUInt32Value(ITEM_FIELD_DURABILITY, maxDurability); + item->SetState(ITEM_CHANGED, this); + + // reapply mods for total broken and repaired item if equipped + if(IsEquipmentPos(pos) && !curDurability) + _ApplyItemMods(item,pos & 255, true); + return TotalCost; +} + +void Player::RepopAtGraveyard() +{ + // note: this can be called also when the player is alive + // for example from WorldSession::HandleMovementOpcodes + + AreaTableEntry const *zone = GetAreaEntryByAreaID(GetAreaId()); + + // Such zones are considered unreachable as a ghost and the player must be automatically revived + if(!isAlive() && zone && zone->flags & AREA_FLAG_NEED_FLY || GetTransport()) + { + ResurrectPlayer(0.5f); + SpawnCorpseBones(); + } + + WorldSafeLocsEntry const *ClosestGrave = NULL; + + // Special handle for battleground maps + BattleGround *bg = sBattleGroundMgr.GetBattleGround(GetBattleGroundId()); + + if(bg && (bg->GetTypeID() == BATTLEGROUND_AB || bg->GetTypeID() == BATTLEGROUND_EY)) + ClosestGrave = bg->GetClosestGraveYard(GetPositionX(), GetPositionY(), GetPositionZ(), GetTeam()); + else + ClosestGrave = objmgr.GetClosestGraveYard( GetPositionX(), GetPositionY(), GetPositionZ(), GetMapId(), GetTeam() ); + + // stop countdown until repop + m_deathTimer = 0; + + // if no grave found, stay at the current location + // and don't show spirit healer location + if(ClosestGrave) + { + TeleportTo(ClosestGrave->map_id, ClosestGrave->x, ClosestGrave->y, ClosestGrave->z, GetOrientation()); + if(isDead()) // not send if alive, because it used in TeleportTo() + { + WorldPacket data(SMSG_DEATH_RELEASE_LOC, 4*4); // show spirit healer position on minimap + data << ClosestGrave->map_id; + data << ClosestGrave->x; + data << ClosestGrave->y; + data << ClosestGrave->z; + GetSession()->SendPacket(&data); + } + } +} + +void Player::JoinedChannel(Channel *c) +{ + m_channels.push_back(c); +} + +void Player::LeftChannel(Channel *c) +{ + m_channels.remove(c); +} + +void Player::CleanupChannels() +{ + while(!m_channels.empty()) + { + Channel* ch = *m_channels.begin(); + m_channels.erase(m_channels.begin()); // remove from player's channel list + ch->Leave(GetGUID(), false); // not send to client, not remove from player's channel list + if (ChannelMgr* cMgr = channelMgr(GetTeam())) + cMgr->LeftChannel(ch->GetName()); // deleted channel if empty + + } + sLog.outDebug("Player: channels cleaned up!"); +} + +void Player::UpdateLocalChannels(uint32 newZone ) +{ + if(m_channels.empty()) + return; + + AreaTableEntry const* current_zone = GetAreaEntryByAreaID(newZone); + if(!current_zone) + return; + + ChannelMgr* cMgr = channelMgr(GetTeam()); + if(!cMgr) + return; + + std::string current_zone_name = current_zone->area_name[GetSession()->GetSessionDbcLocale()]; + + for(JoinedChannelsList::iterator i = m_channels.begin(), next; i != m_channels.end(); i = next) + { + next = i; ++next; + + // skip non built-in channels + if(!(*i)->IsConstant()) + continue; + + ChatChannelsEntry const* ch = GetChannelEntryFor((*i)->GetChannelId()); + if(!ch) + continue; + + if((ch->flags & 4) == 4) // global channel without zone name in pattern + continue; + + // new channel + char new_channel_name_buf[100]; + snprintf(new_channel_name_buf,100,ch->pattern[m_session->GetSessionDbcLocale()],current_zone_name.c_str()); + Channel* new_channel = cMgr->GetJoinChannel(new_channel_name_buf,ch->ChannelID); + + if((*i)!=new_channel) + { + new_channel->Join(GetGUID(),""); // will output Changed Channel: N. Name + + // leave old channel + (*i)->Leave(GetGUID(),false); // not send leave channel, it already replaced at client + std::string name = (*i)->GetName(); // stroe name, (*i)erase in LeftChannel + LeftChannel(*i); // remove from player's channel list + cMgr->LeftChannel(name); // delete if empty + } + } + sLog.outDebug("Player: channels cleaned up!"); +} + +void Player::LeaveLFGChannel() +{ + for(JoinedChannelsList::iterator i = m_channels.begin(); i != m_channels.end(); ++i ) + { + if((*i)->IsLFG()) + { + (*i)->Leave(GetGUID()); + break; + } + } +} + +void Player::UpdateDefense() +{ + uint32 defense_skill_gain = sWorld.getConfig(CONFIG_SKILL_GAIN_DEFENSE); + + if(UpdateSkill(SKILL_DEFENSE,defense_skill_gain)) + { + // update dependent from defense skill part + UpdateDefenseBonusesMod(); + } +} + +void Player::HandleBaseModValue(BaseModGroup modGroup, BaseModType modType, float amount, bool apply, bool affectStats) +{ + if(modGroup >= BASEMOD_END || modType >= MOD_END) + { + sLog.outError("ERROR in HandleBaseModValue(): nonexisted BaseModGroup of wrong BaseModType!"); + return; + } + + float val = 1.0f; + + switch(modType) + { + case FLAT_MOD: + m_auraBaseMod[modGroup][modType] += apply ? amount : -amount; + break; + case PCT_MOD: + if(amount <= -100.0f) + amount = -200.0f; + + val = (100.0f + amount) / 100.0f; + m_auraBaseMod[modGroup][modType] *= apply ? val : (1.0f/val); + break; + } + + if(!CanModifyStats()) + return; + + switch(modGroup) + { + case CRIT_PERCENTAGE: UpdateCritPercentage(BASE_ATTACK); break; + case RANGED_CRIT_PERCENTAGE: UpdateCritPercentage(RANGED_ATTACK); break; + case OFFHAND_CRIT_PERCENTAGE: UpdateCritPercentage(OFF_ATTACK); break; + case SHIELD_BLOCK_VALUE: UpdateShieldBlockValue(); break; + default: break; + } +} + +float Player::GetBaseModValue(BaseModGroup modGroup, BaseModType modType) const +{ + if(modGroup >= BASEMOD_END || modType > MOD_END) + { + sLog.outError("ERROR: trial to access nonexisted BaseModGroup or wrong BaseModType!"); + return 0.0f; + } + + if(modType == PCT_MOD && m_auraBaseMod[modGroup][PCT_MOD] <= 0.0f) + return 0.0f; + + return m_auraBaseMod[modGroup][modType]; +} + +float Player::GetTotalBaseModValue(BaseModGroup modGroup) const +{ + if(modGroup >= BASEMOD_END) + { + sLog.outError("ERROR: wrong BaseModGroup in GetTotalBaseModValue()!"); + return 0.0f; + } + + if(m_auraBaseMod[modGroup][PCT_MOD] <= 0.0f) + return 0.0f; + + return m_auraBaseMod[modGroup][FLAT_MOD] * m_auraBaseMod[modGroup][PCT_MOD]; +} + +uint32 Player::GetShieldBlockValue() const +{ + BaseModGroup modGroup = SHIELD_BLOCK_VALUE; + + float value = GetTotalBaseModValue(modGroup) + GetStat(STAT_STRENGTH)/20 - 1; + + value = (value < 0) ? 0 : value; + + return uint32(value); +} + +float Player::GetMeleeCritFromAgility() +{ + uint32 level = getLevel(); + uint32 pclass = getClass(); + + if (level>GT_MAX_LEVEL) level = GT_MAX_LEVEL; + + GtChanceToMeleeCritBaseEntry const *critBase = sGtChanceToMeleeCritBaseStore.LookupEntry(pclass-1); + GtChanceToMeleeCritEntry const *critRatio = sGtChanceToMeleeCritStore.LookupEntry((pclass-1)*GT_MAX_LEVEL + level-1); + if (critBase==NULL || critRatio==NULL) + return 0.0f; + + float crit=critBase->base + GetStat(STAT_AGILITY)*critRatio->ratio; + return crit*100.0f; +} + +float Player::GetDodgeFromAgility() +{ + // Table for base dodge values + float dodge_base[MAX_CLASSES] = { + 0.0075f, // Warrior + 0.00652f, // Paladin + -0.0545f, // Hunter + -0.0059f, // Rogue + 0.03183f, // Priest + 0.0114f, // DK + 0.0167f, // Shaman + 0.034575f, // Mage + 0.02011f, // Warlock + 0.0f, // ?? + -0.0187f // Druid + }; + // Crit/agility to dodge/agility coefficient multipliers + float crit_to_dodge[MAX_CLASSES] = { + 1.1f, // Warrior + 1.0f, // Paladin + 1.6f, // Hunter + 2.0f, // Rogue + 1.0f, // Priest + 1.0f, // DK? + 1.0f, // Shaman + 1.0f, // Mage + 1.0f, // Warlock + 0.0f, // ?? + 1.7f // Druid + }; + + uint32 level = getLevel(); + uint32 pclass = getClass(); + + if (level>GT_MAX_LEVEL) level = GT_MAX_LEVEL; + + // Dodge per agility for most classes equal crit per agility (but for some classes need apply some multiplier) + GtChanceToMeleeCritEntry const *dodgeRatio = sGtChanceToMeleeCritStore.LookupEntry((pclass-1)*GT_MAX_LEVEL + level-1); + if (dodgeRatio==NULL || pclass > MAX_CLASSES) + return 0.0f; + + float dodge=dodge_base[pclass-1] + GetStat(STAT_AGILITY) * dodgeRatio->ratio * crit_to_dodge[pclass-1]; + return dodge*100.0f; +} + +float Player::GetSpellCritFromIntellect() +{ + uint32 level = getLevel(); + uint32 pclass = getClass(); + + if (level>GT_MAX_LEVEL) level = GT_MAX_LEVEL; + + GtChanceToSpellCritBaseEntry const *critBase = sGtChanceToSpellCritBaseStore.LookupEntry(pclass-1); + GtChanceToSpellCritEntry const *critRatio = sGtChanceToSpellCritStore.LookupEntry((pclass-1)*GT_MAX_LEVEL + level-1); + if (critBase==NULL || critRatio==NULL) + return 0.0f; + + float crit=critBase->base + GetStat(STAT_INTELLECT)*critRatio->ratio; + return crit*100.0f; +} + +float Player::GetRatingCoefficient(CombatRating cr) const +{ + uint32 level = getLevel(); + + if (level>GT_MAX_LEVEL) level = GT_MAX_LEVEL; + + GtCombatRatingsEntry const *Rating = sGtCombatRatingsStore.LookupEntry(cr*GT_MAX_LEVEL+level-1); + if (Rating == NULL) + return 1.0f; // By default use minimum coefficient (not must be called) + + return Rating->ratio; +} + +float Player::GetRatingBonusValue(CombatRating cr) const +{ + return float(GetUInt32Value(PLAYER_FIELD_COMBAT_RATING_1 + cr)) / GetRatingCoefficient(cr); +} + +uint32 Player::GetMeleeCritDamageReduction(uint32 damage) const +{ + float melee = GetRatingBonusValue(CR_CRIT_TAKEN_MELEE)*2.0f; + if (melee>25.0f) melee = 25.0f; + return uint32 (melee * damage /100.0f); +} + +uint32 Player::GetRangedCritDamageReduction(uint32 damage) const +{ + float ranged = GetRatingBonusValue(CR_CRIT_TAKEN_RANGED)*2.0f; + if (ranged>25.0f) ranged=25.0f; + return uint32 (ranged * damage /100.0f); +} + +uint32 Player::GetSpellCritDamageReduction(uint32 damage) const +{ + float spell = GetRatingBonusValue(CR_CRIT_TAKEN_SPELL)*2.0f; + // In wow script resilience limited to 25% + if (spell>25.0f) + spell = 25.0f; + return uint32 (spell * damage / 100.0f); +} + +uint32 Player::GetDotDamageReduction(uint32 damage) const +{ + float spellDot = GetRatingBonusValue(CR_CRIT_TAKEN_SPELL); + // Dot resilience not limited (limit it by 100%) + if (spellDot > 100.0f) + spellDot = 100.0f; + return uint32 (spellDot * damage / 100.0f); +} + +float Player::GetExpertiseDodgeOrParryReduction(WeaponAttackType attType) const +{ + switch (attType) + { + case BASE_ATTACK: + return GetUInt32Value(PLAYER_EXPERTISE) / 4.0f; + case OFF_ATTACK: + return GetUInt32Value(PLAYER_OFFHAND_EXPERTISE) / 4.0f; + default: + break; + } + return 0.0f; +} + +float Player::OCTRegenHPPerSpirit() +{ + uint32 level = getLevel(); + uint32 pclass = getClass(); + + if (level>GT_MAX_LEVEL) level = GT_MAX_LEVEL; + + GtOCTRegenHPEntry const *baseRatio = sGtOCTRegenHPStore.LookupEntry((pclass-1)*GT_MAX_LEVEL + level-1); + GtRegenHPPerSptEntry const *moreRatio = sGtRegenHPPerSptStore.LookupEntry((pclass-1)*GT_MAX_LEVEL + level-1); + if (baseRatio==NULL || moreRatio==NULL) + return 0.0f; + + // Formula from PaperDollFrame script + float spirit = GetStat(STAT_SPIRIT); + float baseSpirit = spirit; + if (baseSpirit>50) baseSpirit = 50; + float moreSpirit = spirit - baseSpirit; + float regen = baseSpirit * baseRatio->ratio + moreSpirit * moreRatio->ratio; + return regen; +} + +float Player::OCTRegenMPPerSpirit() +{ + uint32 level = getLevel(); + uint32 pclass = getClass(); + + if (level>GT_MAX_LEVEL) level = GT_MAX_LEVEL; + +// GtOCTRegenMPEntry const *baseRatio = sGtOCTRegenMPStore.LookupEntry((pclass-1)*GT_MAX_LEVEL + level-1); + GtRegenMPPerSptEntry const *moreRatio = sGtRegenMPPerSptStore.LookupEntry((pclass-1)*GT_MAX_LEVEL + level-1); + if (moreRatio==NULL) + return 0.0f; + + // Formula get from PaperDollFrame script + float spirit = GetStat(STAT_SPIRIT); + float regen = spirit * moreRatio->ratio; + return regen; +} + +void Player::ApplyRatingMod(CombatRating cr, int32 value, bool apply) +{ + ApplyModUInt32Value(PLAYER_FIELD_COMBAT_RATING_1 + cr, value, apply); + + float RatingCoeffecient = GetRatingCoefficient(cr); + float RatingChange = 0.0f; + + bool affectStats = CanModifyStats(); + + switch (cr) + { + case CR_WEAPON_SKILL: // Implemented in Unit::RollMeleeOutcomeAgainst + case CR_DEFENSE_SKILL: + UpdateDefenseBonusesMod(); + break; + case CR_DODGE: + UpdateDodgePercentage(); + break; + case CR_PARRY: + UpdateParryPercentage(); + break; + case CR_BLOCK: + UpdateBlockPercentage(); + break; + case CR_HIT_MELEE: + RatingChange = value / RatingCoeffecient; + m_modMeleeHitChance += apply ? RatingChange : -RatingChange; + break; + case CR_HIT_RANGED: + RatingChange = value / RatingCoeffecient; + m_modRangedHitChance += apply ? RatingChange : -RatingChange; + break; + case CR_HIT_SPELL: + RatingChange = value / RatingCoeffecient; + m_modSpellHitChance += apply ? RatingChange : -RatingChange; + break; + case CR_CRIT_MELEE: + if(affectStats) + { + UpdateCritPercentage(BASE_ATTACK); + UpdateCritPercentage(OFF_ATTACK); + } + break; + case CR_CRIT_RANGED: + if(affectStats) + UpdateCritPercentage(RANGED_ATTACK); + break; + case CR_CRIT_SPELL: + if(affectStats) + UpdateAllSpellCritChances(); + break; + case CR_HIT_TAKEN_MELEE: // Implemented in Unit::MeleeMissChanceCalc + case CR_HIT_TAKEN_RANGED: + break; + case CR_HIT_TAKEN_SPELL: // Implemented in Unit::MagicSpellHitResult + break; + case CR_CRIT_TAKEN_MELEE: // Implemented in Unit::RollMeleeOutcomeAgainst (only for chance to crit) + case CR_CRIT_TAKEN_RANGED: + break; + case CR_CRIT_TAKEN_SPELL: // Implemented in Unit::SpellCriticalBonus (only for chance to crit) + break; + case CR_HASTE_MELEE: + RatingChange = value / RatingCoeffecient; + ApplyAttackTimePercentMod(BASE_ATTACK,RatingChange,apply); + ApplyAttackTimePercentMod(OFF_ATTACK,RatingChange,apply); + break; + case CR_HASTE_RANGED: + RatingChange = value / RatingCoeffecient; + ApplyAttackTimePercentMod(RANGED_ATTACK, RatingChange, apply); + break; + case CR_HASTE_SPELL: + RatingChange = value / RatingCoeffecient; + ApplyCastTimePercentMod(RatingChange,apply); + break; + case CR_WEAPON_SKILL_MAINHAND: // Implemented in Unit::RollMeleeOutcomeAgainst + case CR_WEAPON_SKILL_OFFHAND: + case CR_WEAPON_SKILL_RANGED: + break; + case CR_EXPERTISE: + if(affectStats) + { + UpdateExpertise(BASE_ATTACK); + UpdateExpertise(OFF_ATTACK); + } + break; + } +} + +void Player::SetRegularAttackTime() +{ + for(int i = 0; i < MAX_ATTACK; ++i) + { + Item *tmpitem = GetWeaponForAttack(WeaponAttackType(i)); + if(tmpitem && !tmpitem->IsBroken()) + { + ItemPrototype const *proto = tmpitem->GetProto(); + if(proto->Delay) + SetAttackTime(WeaponAttackType(i), proto->Delay); + else + SetAttackTime(WeaponAttackType(i), BASE_ATTACK_TIME); + } + } +} + +//skill+step, checking for max value +bool Player::UpdateSkill(uint32 skill_id, uint32 step) +{ + if(!skill_id) + return false; + + uint16 i=0; + for (; i < PLAYER_MAX_SKILLS; i++) + if ((GetUInt32Value(PLAYER_SKILL_INDEX(i)) & 0x0000FFFF) == skill_id) + break; + + if(i>=PLAYER_MAX_SKILLS) + return false; + + uint32 data = GetUInt32Value(PLAYER_SKILL_VALUE_INDEX(i)); + uint32 value = SKILL_VALUE(data); + uint32 max = SKILL_MAX(data); + + if ((!max) || (!value) || (value >= max)) + return false; + + if (value*512 < max*urand(0,512)) + { + uint32 new_value = value+step; + if(new_value > max) + new_value = max; + + SetUInt32Value(PLAYER_SKILL_VALUE_INDEX(i),MAKE_SKILL_VALUE(new_value,max)); + return true; + } + + return false; +} + +inline int SkillGainChance(uint32 SkillValue, uint32 GrayLevel, uint32 GreenLevel, uint32 YellowLevel) +{ + if ( SkillValue >= GrayLevel ) + return sWorld.getConfig(CONFIG_SKILL_CHANCE_GREY)*10; + if ( SkillValue >= GreenLevel ) + return sWorld.getConfig(CONFIG_SKILL_CHANCE_GREEN)*10; + if ( SkillValue >= YellowLevel ) + return sWorld.getConfig(CONFIG_SKILL_CHANCE_YELLOW)*10; + return sWorld.getConfig(CONFIG_SKILL_CHANCE_ORANGE)*10; +} + +bool Player::UpdateCraftSkill(uint32 spellid) +{ + sLog.outDebug("UpdateCraftSkill spellid %d", spellid); + + SkillLineAbilityMap::const_iterator lower = spellmgr.GetBeginSkillLineAbilityMap(spellid); + SkillLineAbilityMap::const_iterator upper = spellmgr.GetEndSkillLineAbilityMap(spellid); + + for(SkillLineAbilityMap::const_iterator _spell_idx = lower; _spell_idx != upper; ++_spell_idx) + { + if(_spell_idx->second->skillId) + { + uint32 SkillValue = GetPureSkillValue(_spell_idx->second->skillId); + + // Alchemy Discoveries here + SpellEntry const* spellEntry = sSpellStore.LookupEntry(spellid); + if(spellEntry && spellEntry->Mechanic==MECHANIC_DISCOVERY) + { + if(uint32 discoveredSpell = GetSkillDiscoverySpell(_spell_idx->second->skillId, spellid, this)) + learnSpell(discoveredSpell); + } + + uint32 craft_skill_gain = sWorld.getConfig(CONFIG_SKILL_GAIN_CRAFTING); + + return UpdateSkillPro(_spell_idx->second->skillId, SkillGainChance(SkillValue, + _spell_idx->second->max_value, + (_spell_idx->second->max_value + _spell_idx->second->min_value)/2, + _spell_idx->second->min_value), + craft_skill_gain); + } + } + return false; +} + +bool Player::UpdateGatherSkill(uint32 SkillId, uint32 SkillValue, uint32 RedLevel, uint32 Multiplicator ) +{ + sLog.outDebug("UpdateGatherSkill(SkillId %d SkillLevel %d RedLevel %d)", SkillId, SkillValue, RedLevel); + + uint32 gathering_skill_gain = sWorld.getConfig(CONFIG_SKILL_GAIN_GATHERING); + + // For skinning and Mining chance decrease with level. 1-74 - no decrease, 75-149 - 2 times, 225-299 - 8 times + switch (SkillId) + { + case SKILL_HERBALISM: + case SKILL_LOCKPICKING: + case SKILL_JEWELCRAFTING: + return UpdateSkillPro(SkillId, SkillGainChance(SkillValue, RedLevel+100, RedLevel+50, RedLevel+25)*Multiplicator,gathering_skill_gain); + case SKILL_SKINNING: + if( sWorld.getConfig(CONFIG_SKILL_CHANCE_SKINNING_STEPS)==0) + return UpdateSkillPro(SkillId, SkillGainChance(SkillValue, RedLevel+100, RedLevel+50, RedLevel+25)*Multiplicator,gathering_skill_gain); + else + return UpdateSkillPro(SkillId, (SkillGainChance(SkillValue, RedLevel+100, RedLevel+50, RedLevel+25)*Multiplicator) >> (SkillValue/sWorld.getConfig(CONFIG_SKILL_CHANCE_SKINNING_STEPS)), gathering_skill_gain); + case SKILL_MINING: + if (sWorld.getConfig(CONFIG_SKILL_CHANCE_MINING_STEPS)==0) + return UpdateSkillPro(SkillId, SkillGainChance(SkillValue, RedLevel+100, RedLevel+50, RedLevel+25)*Multiplicator,gathering_skill_gain); + else + return UpdateSkillPro(SkillId, (SkillGainChance(SkillValue, RedLevel+100, RedLevel+50, RedLevel+25)*Multiplicator) >> (SkillValue/sWorld.getConfig(CONFIG_SKILL_CHANCE_MINING_STEPS)),gathering_skill_gain); + } + return false; +} + +bool Player::UpdateFishingSkill() +{ + sLog.outDebug("UpdateFishingSkill"); + + uint32 SkillValue = GetPureSkillValue(SKILL_FISHING); + + int32 chance = SkillValue < 75 ? 100 : 2500/(SkillValue-50); + + uint32 gathering_skill_gain = sWorld.getConfig(CONFIG_SKILL_GAIN_GATHERING); + + return UpdateSkillPro(SKILL_FISHING,chance*10,gathering_skill_gain); +} + +bool Player::UpdateSkillPro(uint16 SkillId, int32 Chance, uint32 step) +{ + sLog.outDebug("UpdateSkillPro(SkillId %d, Chance %3.1f%%)", SkillId, Chance/10.0); + if ( !SkillId ) + return false; + + if(Chance <= 0) // speedup in 0 chance case + { + sLog.outDebug("Player::UpdateSkillPro Chance=%3.1f%% missed", Chance/10.0); + return false; + } + + uint16 i=0; + for (; i < PLAYER_MAX_SKILLS; i++) + if ( SKILL_VALUE(GetUInt32Value(PLAYER_SKILL_INDEX(i))) == SkillId ) break; + if ( i >= PLAYER_MAX_SKILLS ) + return false; + + uint32 data = GetUInt32Value(PLAYER_SKILL_VALUE_INDEX(i)); + uint16 SkillValue = SKILL_VALUE(data); + uint16 MaxValue = SKILL_MAX(data); + + if ( !MaxValue || !SkillValue || SkillValue >= MaxValue ) + return false; + + int32 Roll = irand(1,1000); + + if ( Roll <= Chance ) + { + uint32 new_value = SkillValue+step; + if(new_value > MaxValue) + new_value = MaxValue; + + SetUInt32Value(PLAYER_SKILL_VALUE_INDEX(i),MAKE_SKILL_VALUE(new_value,MaxValue)); + sLog.outDebug("Player::UpdateSkillPro Chance=%3.1f%% taken", Chance/10.0); + return true; + } + + sLog.outDebug("Player::UpdateSkillPro Chance=%3.1f%% missed", Chance/10.0); + return false; +} + +void Player::UpdateWeaponSkill (WeaponAttackType attType) +{ + // no skill gain in pvp + Unit *pVictim = getVictim(); + if(pVictim && pVictim->GetTypeId() == TYPEID_PLAYER) + return; + + if(IsInFeralForm()) + return; // always maximized SKILL_FERAL_COMBAT in fact + + if(m_form == FORM_TREE) + return; // use weapon but not skill up + + uint32 weapon_skill_gain = sWorld.getConfig(CONFIG_SKILL_GAIN_WEAPON); + + switch(attType) + { + case BASE_ATTACK: + { + Item *tmpitem = GetWeaponForAttack(attType,true); + + if (!tmpitem) + UpdateSkill(SKILL_UNARMED,weapon_skill_gain); + else if(tmpitem->GetProto()->SubClass != ITEM_SUBCLASS_WEAPON_FISHING_POLE) + UpdateSkill(tmpitem->GetSkill(),weapon_skill_gain); + break; + } + case OFF_ATTACK: + case RANGED_ATTACK: + { + Item *tmpitem = GetWeaponForAttack(attType,true); + if (tmpitem) + UpdateSkill(tmpitem->GetSkill(),weapon_skill_gain); + break; + } + } + UpdateAllCritPercentages(); +} + +void Player::UpdateCombatSkills(Unit *pVictim, WeaponAttackType attType, MeleeHitOutcome outcome, bool defence) +{ + switch(outcome) + { + case MELEE_HIT_CRIT: + case MELEE_HIT_DODGE: + case MELEE_HIT_PARRY: + case MELEE_HIT_BLOCK: + case MELEE_HIT_BLOCK_CRIT: + return; + + default: + break; + } + + uint32 plevel = getLevel(); // if defense than pVictim == attacker + uint32 greylevel = MaNGOS::XP::GetGrayLevel(plevel); + uint32 moblevel = pVictim->getLevelForTarget(this); + if(moblevel < greylevel) + return; + + if (moblevel > plevel + 5) + moblevel = plevel + 5; + + uint32 lvldif = moblevel - greylevel; + if(lvldif < 3) + lvldif = 3; + + uint32 skilldif = 5 * plevel - (defence ? GetBaseDefenseSkillValue() : GetBaseWeaponSkillValue(attType)); + if(skilldif <= 0) + return; + + float chance = float(3 * lvldif * skilldif) / plevel; + if(!defence) + { + if(getClass() == CLASS_WARRIOR || getClass() == CLASS_ROGUE) + chance *= 0.1f * GetStat(STAT_INTELLECT); + } + + chance = chance < 1.0f ? 1.0f : chance; //minimum chance to increase skill is 1% + + if(roll_chance_f(chance)) + { + if(defence) + UpdateDefense(); + else + UpdateWeaponSkill(attType); + } + else + return; +} + +void Player::ModifySkillBonus(uint32 skillid,int32 val, bool talent) +{ + for (uint16 i=0; i < PLAYER_MAX_SKILLS; i++) + if ((GetUInt32Value(PLAYER_SKILL_INDEX(i)) & 0x0000FFFF) == skillid) + { + uint32 bonus_val = GetUInt32Value(PLAYER_SKILL_BONUS_INDEX(i)); + int16 temp_bonus = SKILL_TEMP_BONUS(bonus_val); + int16 perm_bonus = SKILL_PERM_BONUS(bonus_val); + + if(talent) // permanent bonus stored in high part + SetUInt32Value(PLAYER_SKILL_BONUS_INDEX(i),MAKE_SKILL_BONUS(temp_bonus,perm_bonus+val)); + else // temporary/item bonus stored in low part + SetUInt32Value(PLAYER_SKILL_BONUS_INDEX(i),MAKE_SKILL_BONUS(temp_bonus+val,perm_bonus)); + return; + } +} + +void Player::UpdateMaxSkills() +{ + uint16 maxconfskill = sWorld.GetConfigMaxSkillValue(); + + for (uint16 i=0; i < PLAYER_MAX_SKILLS; i++) + if (GetUInt32Value(PLAYER_SKILL_INDEX(i))) + { + uint32 pskill = GetUInt32Value(PLAYER_SKILL_INDEX(i)) & 0x0000FFFF; + + SkillLineEntry const *pSkill = sSkillLineStore.LookupEntry(pskill); + if(!pSkill) + continue; + + if(GetSkillRangeType(pSkill,false) != SKILL_RANGE_LEVEL) + continue; + + uint32 data = GetUInt32Value(PLAYER_SKILL_VALUE_INDEX(i)); + uint32 max = SKILL_MAX(data); + uint32 val = SKILL_VALUE(data); + + // update only level dependent max skill values + if(max!=1 && max != maxconfskill) + { + uint32 max_Skill = GetMaxSkillValueForLevel(); + SetUInt32Value(PLAYER_SKILL_VALUE_INDEX(i),MAKE_SKILL_VALUE(val,max_Skill)); + } + } +} + +void Player::UpdateSkillsToMaxSkillsForLevel() +{ + for (uint16 i=0; i < PLAYER_MAX_SKILLS; i++) + if (GetUInt32Value(PLAYER_SKILL_INDEX(i))) + { + uint32 pskill = GetUInt32Value(PLAYER_SKILL_INDEX(i)) & 0x0000FFFF; + if( IsProfessionSkill(pskill) || pskill == SKILL_RIDING ) + continue; + uint32 data = GetUInt32Value(PLAYER_SKILL_VALUE_INDEX(i)); + + uint32 max = SKILL_MAX(data); + + if(max > 1) + SetUInt32Value(PLAYER_SKILL_VALUE_INDEX(i),MAKE_SKILL_VALUE(max,max)); + + if(pskill == SKILL_DEFENSE) + UpdateDefenseBonusesMod(); + } +} + +// This functions sets a skill line value (and adds if doesn't exist yet) +// To "remove" a skill line, set it's values to zero +void Player::SetSkill(uint32 id, uint16 currVal, uint16 maxVal) +{ + if(!id) + return; + + uint16 i=0; + for (; i < PLAYER_MAX_SKILLS; i++) + if ((GetUInt32Value(PLAYER_SKILL_INDEX(i)) & 0x0000FFFF) == id) break; + + if(isecond->state == PLAYERSPELL_REMOVED) + continue; + + SkillLineAbilityMap::const_iterator lower = spellmgr.GetBeginSkillLineAbilityMap(itr->first); + SkillLineAbilityMap::const_iterator upper = spellmgr.GetEndSkillLineAbilityMap(itr->first); + + for(SkillLineAbilityMap::const_iterator _spell_idx = lower; _spell_idx != upper; ++_spell_idx) + { + if (_spell_idx->second->skillId == id) + { + // this may remove more than one spell (dependants) + removeSpell(itr->first); + next = m_spells.begin(); + break; + } + } + } + } + } + else if(currVal) //add + { + for (i=0; i < PLAYER_MAX_SKILLS; i++) + if (!GetUInt32Value(PLAYER_SKILL_INDEX(i))) + { + SkillLineEntry const *pSkill = sSkillLineStore.LookupEntry(id); + if(!pSkill) + { + sLog.outError("Skill not found in SkillLineStore: skill #%u", id); + return; + } + // enable unlearn button for primary professions only + if (pSkill->categoryId == SKILL_CATEGORY_PROFESSION) + SetUInt32Value(PLAYER_SKILL_INDEX(i), MAKE_PAIR32(id,1)); + else + SetUInt32Value(PLAYER_SKILL_INDEX(i), MAKE_PAIR32(id,0)); + SetUInt32Value(PLAYER_SKILL_VALUE_INDEX(i),MAKE_SKILL_VALUE(currVal,maxVal)); + + // apply skill bonuses + SetUInt32Value(PLAYER_SKILL_BONUS_INDEX(i),0); + + // temporary bonuses + AuraList const& mModSkill = GetAurasByType(SPELL_AURA_MOD_SKILL); + for(AuraList::const_iterator i = mModSkill.begin(); i != mModSkill.end(); ++i) + if ((*i)->GetModifier()->m_miscvalue == int32(id)) + (*i)->ApplyModifier(true); + + // permanent bonuses + AuraList const& mModSkillTalent = GetAurasByType(SPELL_AURA_MOD_SKILL_TALENT); + for(AuraList::const_iterator i = mModSkillTalent.begin(); i != mModSkillTalent.end(); ++i) + if ((*i)->GetModifier()->m_miscvalue == int32(id)) + (*i)->ApplyModifier(true); + + // Learn all spells for skill + learnSkillRewardedSpells(id); + return; + } + } +} + +bool Player::HasSkill(uint32 skill) const +{ + if(!skill)return false; + for (uint16 i=0; i < PLAYER_MAX_SKILLS; i++) + { + if ((GetUInt32Value(PLAYER_SKILL_INDEX(i)) & 0x0000FFFF) == skill) + { + return true; + } + } + return false; +} + +uint16 Player::GetSkillValue(uint32 skill) const +{ + if(!skill) + return 0; + + for (uint16 i=0; i < PLAYER_MAX_SKILLS; i++) + { + if ((GetUInt32Value(PLAYER_SKILL_INDEX(i)) & 0x0000FFFF) == skill) + { + uint32 bonus = GetUInt32Value(PLAYER_SKILL_BONUS_INDEX(i)); + + int32 result = int32(SKILL_VALUE(GetUInt32Value(PLAYER_SKILL_VALUE_INDEX(i)))); + result += SKILL_TEMP_BONUS(bonus); + result += SKILL_PERM_BONUS(bonus); + return result < 0 ? 0 : result; + } + } + return 0; +} + +uint16 Player::GetMaxSkillValue(uint32 skill) const +{ + if(!skill)return 0; + for (uint16 i=0; i < PLAYER_MAX_SKILLS; i++) + { + if ((GetUInt32Value(PLAYER_SKILL_INDEX(i)) & 0x0000FFFF) == skill) + { + uint32 bonus = GetUInt32Value(PLAYER_SKILL_BONUS_INDEX(i)); + + int32 result = int32(SKILL_MAX(GetUInt32Value(PLAYER_SKILL_VALUE_INDEX(i)))); + result += SKILL_TEMP_BONUS(bonus); + result += SKILL_PERM_BONUS(bonus); + return result < 0 ? 0 : result; + } + } + return 0; +} + +uint16 Player::GetPureMaxSkillValue(uint32 skill) const +{ + if(!skill)return 0; + for (uint16 i=0; i < PLAYER_MAX_SKILLS; i++) + { + if ((GetUInt32Value(PLAYER_SKILL_INDEX(i)) & 0x0000FFFF) == skill) + { + return SKILL_MAX(GetUInt32Value(PLAYER_SKILL_VALUE_INDEX(i))); + } + } + return 0; +} + +uint16 Player::GetBaseSkillValue(uint32 skill) const +{ + if(!skill)return 0; + for (uint16 i=0; i < PLAYER_MAX_SKILLS; i++) + { + if ((GetUInt32Value(PLAYER_SKILL_INDEX(i)) & 0x0000FFFF) == skill) + { + int32 result = int32(SKILL_VALUE(GetUInt32Value(PLAYER_SKILL_VALUE_INDEX(i)))); + result += SKILL_PERM_BONUS(GetUInt32Value(PLAYER_SKILL_BONUS_INDEX(i))); + return result < 0 ? 0 : result; + } + } + return 0; +} + +uint16 Player::GetPureSkillValue(uint32 skill) const +{ + if(!skill)return 0; + for (uint16 i=0; i < PLAYER_MAX_SKILLS; i++) + { + if ((GetUInt32Value(PLAYER_SKILL_INDEX(i)) & 0x0000FFFF) == skill) + { + return SKILL_VALUE(GetUInt32Value(PLAYER_SKILL_VALUE_INDEX(i))); + } + } + return 0; +} + +int16 Player::GetSkillTempBonusValue(uint32 skill) const +{ + if(!skill) + return 0; + + for (int i = 0; i < PLAYER_MAX_SKILLS; i++) + { + if ((GetUInt32Value(PLAYER_SKILL_INDEX(i)) & 0x0000FFFF) == skill) + { + return SKILL_TEMP_BONUS(GetUInt32Value(PLAYER_SKILL_BONUS_INDEX(i))); + } + } + + return 0; +} + +void Player::SendInitialActionButtons() +{ + sLog.outDetail( "Initializing Action Buttons for '%u'", GetGUIDLow() ); + + WorldPacket data(SMSG_ACTION_BUTTONS, (MAX_ACTION_BUTTONS*4)); + for(int button = 0; button < MAX_ACTION_BUTTONS; ++button) + { + ActionButtonList::const_iterator itr = m_actionButtons.find(button); + if(itr != m_actionButtons.end() && itr->second.uState != ACTIONBUTTON_DELETED) + { + data << uint16(itr->second.action); + data << uint8(itr->second.misc); + data << uint8(itr->second.type); + } + else + { + data << uint32(0); + } + } + + GetSession()->SendPacket( &data ); + sLog.outDetail( "Action Buttons for '%u' Initialized", GetGUIDLow() ); +} + +void Player::addActionButton(const uint8 button, const uint16 action, const uint8 type, const uint8 misc) +{ + if(button >= MAX_ACTION_BUTTONS) + { + sLog.outError( "Action %u not added into button %u for player %s: button must be < 132", action, button, GetName() ); + return; + } + + // check cheating with adding non-known spells to action bar + if(type==ACTION_BUTTON_SPELL) + { + if(!sSpellStore.LookupEntry(action)) + { + sLog.outError( "Action %u not added into button %u for player %s: spell not exist", action, button, GetName() ); + return; + } + + if(!HasSpell(action)) + { + sLog.outError( "Action %u not added into button %u for player %s: player don't known this spell", action, button, GetName() ); + return; + } + } + + ActionButtonList::iterator buttonItr = m_actionButtons.find(button); + + if (buttonItr==m_actionButtons.end()) + { // just add new button + m_actionButtons[button] = ActionButton(action,type,misc); + } + else + { // change state of current button + ActionButtonUpdateState uState = buttonItr->second.uState; + buttonItr->second = ActionButton(action,type,misc); + if (uState != ACTIONBUTTON_NEW) buttonItr->second.uState = ACTIONBUTTON_CHANGED; + }; + + sLog.outDetail( "Player '%u' Added Action '%u' to Button '%u'", GetGUIDLow(), action, button ); +} + +void Player::removeActionButton(uint8 button) +{ + ActionButtonList::iterator buttonItr = m_actionButtons.find(button); + if (buttonItr==m_actionButtons.end()) + return; + + if(buttonItr->second.uState==ACTIONBUTTON_NEW) + m_actionButtons.erase(buttonItr); // new and not saved + else + buttonItr->second.uState = ACTIONBUTTON_DELETED; // saved, will deleted at next save + + sLog.outDetail( "Action Button '%u' Removed from Player '%u'", button, GetGUIDLow() ); +} + +void Player::SetDontMove(bool dontMove) +{ + m_dontMove = dontMove; +} + +bool Player::SetPosition(float x, float y, float z, float orientation, bool teleport) +{ + // prevent crash when a bad coord is sent by the client + if(!MaNGOS::IsValidMapCoord(x,y,z,orientation)) + { + sLog.outDebug("Player::SetPosition(%f, %f, %f, %f, %d) .. bad coordinates for player %d!",x,y,z,orientation,teleport,GetGUIDLow()); + return false; + } + + Map *m = MapManager::Instance().GetMap(GetMapId(), this); + + const float old_x = GetPositionX(); + const float old_y = GetPositionY(); + const float old_z = GetPositionZ(); + const float old_r = GetOrientation(); + + if( teleport || old_x != x || old_y != y || old_z != z || old_r != orientation ) + { + if (teleport || old_x != x || old_y != y || old_z != z) + RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_MOVE | AURA_INTERRUPT_FLAG_TURNING); + else + RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_TURNING); + + // move and update visible state if need + m->PlayerRelocation(this, x, y, z, orientation); + + // reread after Map::Relocation + m = MapManager::Instance().GetMap(GetMapId(), this); + x = GetPositionX(); + y = GetPositionY(); + z = GetPositionZ(); + } + + // code block for underwater state update + UpdateUnderwaterState(m, x, y, z); + + + CheckExploreSystem(); + + // group update + if(GetGroup()) + SetGroupUpdateFlag(GROUP_UPDATE_FLAG_POSITION); + + return true; +} + +void Player::SaveRecallPosition() +{ + m_recallMap = GetMapId(); + m_recallX = GetPositionX(); + m_recallY = GetPositionY(); + m_recallZ = GetPositionZ(); + m_recallO = GetOrientation(); +} + +void Player::SendMessageToSet(WorldPacket *data, bool self) +{ + MapManager::Instance().GetMap(GetMapId(), this)->MessageBroadcast(this, data, self); +} + +void Player::SendMessageToSetInRange(WorldPacket *data, float dist, bool self) +{ + MapManager::Instance().GetMap(GetMapId(), this)->MessageDistBroadcast(this, data, dist, self); +} + +void Player::SendMessageToSetInRange(WorldPacket *data, float dist, bool self, bool own_team_only) +{ + MapManager::Instance().GetMap(GetMapId(), this)->MessageDistBroadcast(this, data, dist, self,own_team_only); +} + +void Player::SendDirectMessage(WorldPacket *data) +{ + GetSession()->SendPacket(data); +} + +void Player::CheckExploreSystem() +{ + if (!isAlive()) + return; + + if (isInFlight()) + return; + + uint16 areaFlag=MapManager::Instance().GetBaseMap(GetMapId())->GetAreaFlag(GetPositionX(),GetPositionY()); + if(areaFlag==0xffff) + return; + int offset = areaFlag / 32; + + if(offset >= 128) + { + sLog.outError("ERROR: Wrong area flag %u in map data for (X: %f Y: %f) point to field PLAYER_EXPLORED_ZONES_1 + %u ( %u must be < 64 ).",areaFlag,GetPositionX(),GetPositionY(),offset,offset); + return; + } + + uint32 val = (uint32)(1 << (areaFlag % 32)); + uint32 currFields = GetUInt32Value(PLAYER_EXPLORED_ZONES_1 + offset); + + if( !(currFields & val) ) + { + SetUInt32Value(PLAYER_EXPLORED_ZONES_1 + offset, (uint32)(currFields | val)); + + AreaTableEntry const *p = GetAreaEntryByAreaFlagAndMap(areaFlag,GetMapId()); + if(!p) + { + sLog.outError("PLAYER: Player %u discovered unknown area (x: %f y: %f map: %u", GetGUIDLow(), GetPositionX(),GetPositionY(),GetMapId()); + } + else if(p->area_level > 0) + { + uint32 area = p->ID; + if (getLevel() >= sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL)) + { + SendExplorationExperience(area,0); + } + else + { + int32 diff = int32(getLevel()) - p->area_level; + uint32 XP = 0; + if (diff < -5) + { + XP = uint32(objmgr.GetBaseXP(getLevel()+5)*sWorld.getRate(RATE_XP_EXPLORE)); + } + else if (diff > 5) + { + int32 exploration_percent = (100-((diff-5)*5)); + if (exploration_percent > 100) + exploration_percent = 100; + else if (exploration_percent < 0) + exploration_percent = 0; + + XP = uint32(objmgr.GetBaseXP(p->area_level)*exploration_percent/100*sWorld.getRate(RATE_XP_EXPLORE)); + } + else + { + XP = uint32(objmgr.GetBaseXP(p->area_level)*sWorld.getRate(RATE_XP_EXPLORE)); + } + + GiveXP( XP, NULL ); + SendExplorationExperience(area,XP); + } + sLog.outDetail("PLAYER: Player %u discovered a new area: %u", GetGUIDLow(), area); + } + } +} + +uint32 Player::TeamForRace(uint8 race) +{ + ChrRacesEntry const* rEntry = sChrRacesStore.LookupEntry(race); + if(!rEntry) + { + sLog.outError("Race %u not found in DBC: wrong DBC files?",uint32(race)); + return ALLIANCE; + } + + switch(rEntry->TeamID) + { + case 7: return ALLIANCE; + case 1: return HORDE; + } + + sLog.outError("Race %u have wrong team id in DBC: wrong DBC files?",uint32(race),rEntry->TeamID); + return ALLIANCE; +} + +uint32 Player::getFactionForRace(uint8 race) +{ + ChrRacesEntry const* rEntry = sChrRacesStore.LookupEntry(race); + if(!rEntry) + { + sLog.outError("Race %u not found in DBC: wrong DBC files?",uint32(race)); + return 0; + } + + return rEntry->FactionID; +} + +void Player::setFactionForRace(uint8 race) +{ + m_team = TeamForRace(race); + setFaction( getFactionForRace(race) ); +} + +void Player::UpdateReputation() const +{ + sLog.outDetail( "WORLD: Player::UpdateReputation" ); + + for(FactionStateList::const_iterator itr = m_factions.begin(); itr != m_factions.end(); ++itr) + { + SendFactionState(&(itr->second)); + } +} + +void Player::SendFactionState(FactionState const* faction) const +{ + if(faction->Flags & FACTION_FLAG_VISIBLE) //If faction is visible then update it + { + WorldPacket data(SMSG_SET_FACTION_STANDING, (16)); // last check 2.4.0 + data << (float) 0; // unk 2.4.0 + data << (uint32) 1; // count + // for + data << (uint32) faction->ReputationListID; + data << (uint32) faction->Standing; + // end for + GetSession()->SendPacket(&data); + } +} + +void Player::SendInitialReputations() +{ + WorldPacket data(SMSG_INITIALIZE_FACTIONS, (4+128*5)); + data << uint32 (0x00000080); + + RepListID a = 0; + + for (FactionStateList::const_iterator itr = m_factions.begin(); itr != m_factions.end(); itr++) + { + // fill in absent fields + for (; a != itr->first; a++) + { + data << uint8 (0x00); + data << uint32 (0x00000000); + } + + // fill in encountered data + data << uint8 (itr->second.Flags); + data << uint32 (itr->second.Standing); + + ++a; + } + + // fill in absent fields + for (; a != 128; a++) + { + data << uint8 (0x00); + data << uint32 (0x00000000); + } + + GetSession()->SendPacket(&data); +} + +FactionState const* Player::GetFactionState( FactionEntry const* factionEntry) const +{ + FactionStateList::const_iterator itr = m_factions.find(factionEntry->reputationListID); + if (itr != m_factions.end()) + return &itr->second; + + return NULL; +} + +void Player::SetFactionAtWar(FactionState* faction, bool atWar) +{ + // not allow declare war to own faction + if(atWar && (faction->Flags & FACTION_FLAG_PEACE_FORCED) ) + return; + + // already set + if(((faction->Flags & FACTION_FLAG_AT_WAR) != 0) == atWar) + return; + + if( atWar ) + faction->Flags |= FACTION_FLAG_AT_WAR; + else + faction->Flags &= ~FACTION_FLAG_AT_WAR; + + faction->Changed = true; +} + +void Player::SetFactionInactive(FactionState* faction, bool inactive) +{ + // always invisible or hidden faction can't be inactive + if(inactive && ((faction->Flags & (FACTION_FLAG_INVISIBLE_FORCED|FACTION_FLAG_HIDDEN)) || !(faction->Flags & FACTION_FLAG_VISIBLE) ) ) + return; + + // already set + if(((faction->Flags & FACTION_FLAG_INACTIVE) != 0) == inactive) + return; + + if(inactive) + faction->Flags |= FACTION_FLAG_INACTIVE; + else + faction->Flags &= ~FACTION_FLAG_INACTIVE; + + faction->Changed = true; +} + +void Player::SetFactionVisibleForFactionTemplateId(uint32 FactionTemplateId) +{ + FactionTemplateEntry const*factionTemplateEntry = sFactionTemplateStore.LookupEntry(FactionTemplateId); + + if(!factionTemplateEntry) + return; + + SetFactionVisibleForFactionId(factionTemplateEntry->faction); +} + +void Player::SetFactionVisibleForFactionId(uint32 FactionId) +{ + FactionEntry const *factionEntry = sFactionStore.LookupEntry(FactionId); + if(!factionEntry) + return; + + if(factionEntry->reputationListID < 0) + return; + + FactionStateList::iterator itr = m_factions.find(factionEntry->reputationListID); + if (itr == m_factions.end()) + return; + + SetFactionVisible(&itr->second); +} + +void Player::SetFactionVisible(FactionState* faction) +{ + // always invisible or hidden faction can't be make visible + if(faction->Flags & (FACTION_FLAG_INVISIBLE_FORCED|FACTION_FLAG_HIDDEN)) + return; + + // already set + if(faction->Flags & FACTION_FLAG_VISIBLE) + return; + + faction->Flags |= FACTION_FLAG_VISIBLE; + faction->Changed = true; + + if(!m_session->PlayerLoading()) + { + // make faction visible in reputation list at client + WorldPacket data(SMSG_SET_FACTION_VISIBLE, 4); + data << faction->ReputationListID; + GetSession()->SendPacket(&data); + } +} + +void Player::SetInitialFactions() +{ + for(unsigned int i = 1; i < sFactionStore.GetNumRows(); i++) + { + FactionEntry const *factionEntry = sFactionStore.LookupEntry(i); + + if( factionEntry && (factionEntry->reputationListID >= 0)) + { + FactionState newFaction; + newFaction.ID = factionEntry->ID; + newFaction.ReputationListID = factionEntry->reputationListID; + newFaction.Standing = 0; + newFaction.Flags = GetDefaultReputationFlags(factionEntry); + newFaction.Changed = true; + + m_factions[newFaction.ReputationListID] = newFaction; + } + } +} + +uint32 Player::GetDefaultReputationFlags(const FactionEntry *factionEntry) const +{ + if (!factionEntry) + return 0; + + uint32 raceMask = getRaceMask(); + uint32 classMask = getClassMask(); + for (int i=0; i < 4; i++) + { + if( (factionEntry->BaseRepRaceMask[i] & raceMask) && + (factionEntry->BaseRepClassMask[i]==0 || + (factionEntry->BaseRepClassMask[i] & classMask) ) ) + return factionEntry->ReputationFlags[i]; + } + return 0; +} + +int32 Player::GetBaseReputation(const FactionEntry *factionEntry) const +{ + if (!factionEntry) + return 0; + + uint32 raceMask = getRaceMask(); + uint32 classMask = getClassMask(); + for (int i=0; i < 4; i++) + { + if( (factionEntry->BaseRepRaceMask[i] & raceMask) && + (factionEntry->BaseRepClassMask[i]==0 || + (factionEntry->BaseRepClassMask[i] & classMask) ) ) + return factionEntry->BaseRepValue[i]; + } + + // in faction.dbc exist factions with (RepListId >=0, listed in character reputation list) with all BaseRepRaceMask[i]==0 + return 0; +} + +int32 Player::GetReputation(uint32 faction_id) const +{ + FactionEntry const *factionEntry = sFactionStore.LookupEntry(faction_id); + + if (!factionEntry) + { + sLog.outError("Player::GetReputation: Can't get reputation of %s for unknown faction (faction template id) #%u.",GetName(), faction_id); + return 0; + } + + return GetReputation(factionEntry); +} + +int32 Player::GetReputation(const FactionEntry *factionEntry) const +{ + // Faction without recorded reputation. Just ignore. + if(!factionEntry) + return 0; + + FactionStateList::const_iterator itr = m_factions.find(factionEntry->reputationListID); + if (itr != m_factions.end()) + return GetBaseReputation(factionEntry) + itr->second.Standing; + + return 0; +} + +ReputationRank Player::GetReputationRank(uint32 faction) const +{ + FactionEntry const*factionEntry = sFactionStore.LookupEntry(faction); + if(!factionEntry) + return MIN_REPUTATION_RANK; + + return GetReputationRank(factionEntry); +} + +ReputationRank Player::ReputationToRank(int32 standing) const +{ + int32 Limit = Reputation_Cap + 1; + for (int i = MAX_REPUTATION_RANK-1; i >= MIN_REPUTATION_RANK; --i) + { + Limit -= ReputationRank_Length[i]; + if (standing >= Limit ) + return ReputationRank(i); + } + return MIN_REPUTATION_RANK; +} + +ReputationRank Player::GetReputationRank(const FactionEntry *factionEntry) const +{ + int32 Reputation = GetReputation(factionEntry); + return ReputationToRank(Reputation); +} + +ReputationRank Player::GetBaseReputationRank(const FactionEntry *factionEntry) const +{ + int32 Reputation = GetBaseReputation(factionEntry); + return ReputationToRank(Reputation); +} + +bool Player::ModifyFactionReputation(uint32 FactionTemplateId, int32 DeltaReputation) +{ + FactionTemplateEntry const* factionTemplateEntry = sFactionTemplateStore.LookupEntry(FactionTemplateId); + + if(!factionTemplateEntry) + { + sLog.outError("Player::ModifyFactionReputation: Can't update reputation of %s for unknown faction (faction template id) #%u.", GetName(), FactionTemplateId); + return false; + } + + FactionEntry const *factionEntry = sFactionStore.LookupEntry(factionTemplateEntry->faction); + + // Faction without recorded reputation. Just ignore. + if(!factionEntry) + return false; + + return ModifyFactionReputation(factionEntry, DeltaReputation); +} + +bool Player::ModifyFactionReputation(FactionEntry const* factionEntry, int32 standing) +{ + SimpleFactionsList const* flist = GetFactionTeamList(factionEntry->ID); + if (flist) + { + bool res = false; + for (SimpleFactionsList::const_iterator itr = flist->begin();itr != flist->end();++itr) + { + FactionEntry const *factionEntryCalc = sFactionStore.LookupEntry(*itr); + if(factionEntryCalc) + res = ModifyOneFactionReputation(factionEntryCalc, standing); + } + return res; + } + else + return ModifyOneFactionReputation(factionEntry, standing); +} + +bool Player::ModifyOneFactionReputation(FactionEntry const* factionEntry, int32 standing) +{ + FactionStateList::iterator itr = m_factions.find(factionEntry->reputationListID); + if (itr != m_factions.end()) + { + int32 BaseRep = GetBaseReputation(factionEntry); + int32 new_rep = BaseRep + itr->second.Standing + standing; + + if (new_rep > Reputation_Cap) + new_rep = Reputation_Cap; + else + if (new_rep < Reputation_Bottom) + new_rep = Reputation_Bottom; + + if(ReputationToRank(new_rep) <= REP_HOSTILE) + SetFactionAtWar(&itr->second,true); + + itr->second.Standing = new_rep - BaseRep; + itr->second.Changed = true; + + SetFactionVisible(&itr->second); + + for( int i = 0; i < MAX_QUEST_LOG_SIZE; i++ ) + { + if(uint32 questid = GetQuestSlotQuestId(i)) + { + Quest const* qInfo = objmgr.GetQuestTemplate(questid); + if( qInfo && qInfo->GetRepObjectiveFaction() == factionEntry->ID ) + { + QuestStatusData& q_status = mQuestStatus[questid]; + if( q_status.m_status == QUEST_STATUS_INCOMPLETE ) + { + if(GetReputation(factionEntry) >= qInfo->GetRepObjectiveValue()) + if ( CanCompleteQuest( questid ) ) + CompleteQuest( questid ); + } + else if( q_status.m_status == QUEST_STATUS_COMPLETE ) + { + if(GetReputation(factionEntry) < qInfo->GetRepObjectiveValue()) + IncompleteQuest( questid ); + } + } + } + } + + SendFactionState(&(itr->second)); + + return true; + } + return false; +} + +bool Player::SetFactionReputation(uint32 FactionTemplateId, int32 standing) +{ + FactionTemplateEntry const* factionTemplateEntry = sFactionTemplateStore.LookupEntry(FactionTemplateId); + + if(!factionTemplateEntry) + { + sLog.outError("Player::SetFactionReputation: Can't set reputation of %s for unknown faction (faction template id) #%u.", GetName(), FactionTemplateId); + return false; + } + + FactionEntry const *factionEntry = sFactionStore.LookupEntry(factionTemplateEntry->faction); + + // Faction without recorded reputation. Just ignore. + if(!factionEntry) + return false; + + return SetFactionReputation(factionEntry, standing); +} + +bool Player::SetFactionReputation(FactionEntry const* factionEntry, int32 standing) +{ + SimpleFactionsList const* flist = GetFactionTeamList(factionEntry->ID); + if (flist) + { + bool res = false; + for (SimpleFactionsList::const_iterator itr = flist->begin();itr != flist->end();++itr) + { + FactionEntry const *factionEntryCalc = sFactionStore.LookupEntry(*itr); + if(factionEntryCalc) + res = SetOneFactionReputation(factionEntryCalc, standing); + } + return res; + } + else + return SetOneFactionReputation(factionEntry, standing); +} + +bool Player::SetOneFactionReputation(FactionEntry const* factionEntry, int32 standing) +{ + FactionStateList::iterator itr = m_factions.find(factionEntry->reputationListID); + if (itr != m_factions.end()) + { + if (standing > Reputation_Cap) + standing = Reputation_Cap; + else + if (standing < Reputation_Bottom) + standing = Reputation_Bottom; + + int32 BaseRep = GetBaseReputation(factionEntry); + itr->second.Standing = standing - BaseRep; + itr->second.Changed = true; + + SetFactionVisible(&itr->second); + + if(ReputationToRank(standing) <= REP_HOSTILE) + SetFactionAtWar(&itr->second,true); + + SendFactionState(&(itr->second)); + return true; + } + return false; +} + +//Calculate total reputation percent player gain with quest/creature level +int32 Player::CalculateReputationGain(uint32 creatureOrQuestLevel, int32 rep, bool for_quest) +{ + // for grey creature kill received 20%, in other case 100. + int32 percent = (!for_quest && (creatureOrQuestLevel <= MaNGOS::XP::GetGrayLevel(getLevel()))) ? 20 : 100; + + int32 repMod = GetTotalAuraModifier(SPELL_AURA_MOD_REPUTATION_GAIN); + + percent += rep > 0 ? repMod : -repMod; + + if(percent <=0) + return 0; + + return int32(sWorld.getRate(RATE_REPUTATION_GAIN)*rep*percent/100); +} + +//Calculates how many reputation points player gains in victim's enemy factions +void Player::RewardReputation(Unit *pVictim, float rate) +{ + if(!pVictim || pVictim->GetTypeId() == TYPEID_PLAYER) + return; + + ReputationOnKillEntry const* Rep = objmgr.GetReputationOnKilEntry(pVictim->GetEntry()); + + if(!Rep) + return; + + if(Rep->repfaction1 && (!Rep->team_dependent || GetTeam()==ALLIANCE)) + { + int32 donerep1 = CalculateReputationGain(pVictim->getLevel(),Rep->repvalue1,false); + donerep1 = int32(donerep1*rate); + FactionEntry const *factionEntry1 = sFactionStore.LookupEntry(Rep->repfaction1); + uint32 current_reputation_rank1 = GetReputationRank(factionEntry1); + if(factionEntry1 && current_reputation_rank1 <= Rep->reputation_max_cap1) + ModifyFactionReputation(factionEntry1, donerep1); + + // Wiki: Team factions value divided by 2 + if(Rep->is_teamaward1) + { + FactionEntry const *team1_factionEntry = sFactionStore.LookupEntry(factionEntry1->team); + if(team1_factionEntry) + ModifyFactionReputation(team1_factionEntry, donerep1 / 2); + } + } + + if(Rep->repfaction2 && (!Rep->team_dependent || GetTeam()==HORDE)) + { + int32 donerep2 = CalculateReputationGain(pVictim->getLevel(),Rep->repvalue2,false); + donerep2 = int32(donerep2*rate); + FactionEntry const *factionEntry2 = sFactionStore.LookupEntry(Rep->repfaction2); + uint32 current_reputation_rank2 = GetReputationRank(factionEntry2); + if(factionEntry2 && current_reputation_rank2 <= Rep->reputation_max_cap2) + ModifyFactionReputation(factionEntry2, donerep2); + + // Wiki: Team factions value divided by 2 + if(Rep->is_teamaward2) + { + FactionEntry const *team2_factionEntry = sFactionStore.LookupEntry(factionEntry2->team); + if(team2_factionEntry) + ModifyFactionReputation(team2_factionEntry, donerep2 / 2); + } + } +} + +//Calculate how many reputation points player gain with the quest +void Player::RewardReputation(Quest const *pQuest) +{ + // quest reputation reward/loss + for(int i = 0; i < QUEST_REPUTATIONS_COUNT; ++i) + { + if(pQuest->RewRepFaction[i] && pQuest->RewRepValue[i] ) + { + int32 rep = CalculateReputationGain(pQuest->GetQuestLevel(),pQuest->RewRepValue[i],true); + FactionEntry const* factionEntry = sFactionStore.LookupEntry(pQuest->RewRepFaction[i]); + if(factionEntry) + ModifyFactionReputation(factionEntry, rep); + } + } + + // TODO: implement reputation spillover +} + +void Player::UpdateArenaFields(void) +{ + /* arena calcs go here */ +} + +void Player::UpdateHonorFields() +{ + /// called when rewarding honor and at each save + uint64 now = time(NULL); + uint64 today = uint64(time(NULL) / DAY) * DAY; + + if(m_lastHonorUpdateTime < today) + { + uint64 yesterday = today - DAY; + + uint16 kills_today = PAIR32_LOPART(GetUInt32Value(PLAYER_FIELD_KILLS)); + + // update yesterday's contribution + if(m_lastHonorUpdateTime >= yesterday ) + { + SetUInt32Value(PLAYER_FIELD_YESTERDAY_CONTRIBUTION, GetUInt32Value(PLAYER_FIELD_TODAY_CONTRIBUTION)); + + // this is the first update today, reset today's contribution + SetUInt32Value(PLAYER_FIELD_TODAY_CONTRIBUTION, 0); + SetUInt32Value(PLAYER_FIELD_KILLS, MAKE_PAIR32(0,kills_today)); + } + else + { + // no honor/kills yesterday or today, reset + SetUInt32Value(PLAYER_FIELD_YESTERDAY_CONTRIBUTION, 0); + SetUInt32Value(PLAYER_FIELD_KILLS, 0); + } + } + + m_lastHonorUpdateTime = now; +} + +///Calculate the amount of honor gained based on the victim +///and the size of the group for which the honor is divided +///An exact honor value can also be given (overriding the calcs) +bool Player::RewardHonor(Unit *uVictim, uint32 groupsize, float honor) +{ + // 'Inactive' this aura prevents the player from gaining honor points and battleground tokens + if(GetDummyAura(SPELL_AURA_PLAYER_INACTIVE)) + return false; + + uint64 victim_guid = 0; + uint32 victim_rank = 0; + time_t now = time(NULL); + + // need call before fields update to have chance move yesterday data to appropriate fields before today data change. + UpdateHonorFields(); + + if(honor <= 0) + { + if(!uVictim || uVictim == this || uVictim->HasAuraType(SPELL_AURA_NO_PVP_CREDIT)) + return false; + + victim_guid = uVictim->GetGUID(); + + if( uVictim->GetTypeId() == TYPEID_PLAYER ) + { + Player *pVictim = (Player *)uVictim; + + if( GetTeam() == pVictim->GetTeam() && !sWorld.IsFFAPvPRealm() ) + return false; + + float f = 1; //need for total kills (?? need more info) + uint32 k_grey = 0; + uint32 k_level = getLevel(); + uint32 v_level = pVictim->getLevel(); + + { + // PLAYER_CHOSEN_TITLE VALUES DESCRIPTION + // [0] Just name + // [1..14] Alliance honor titles and player name + // [15..28] Horde honor titles and player name + // [29..38] Other title and player name + // [39+] Nothing + uint32 victim_title = pVictim->GetUInt32Value(PLAYER_CHOSEN_TITLE); + // Get Killer titles, CharTitlesEntry::bit_index + // Ranks: + // title[1..14] -> rank[5..18] + // title[15..28] -> rank[5..18] + // title[other] -> 0 + if (victim_title == 0) + victim_guid = 0; // Don't show HK: message, only log. + else if (victim_title < 15) + victim_rank = victim_title + 4; + else if (victim_title < 29) + victim_rank = victim_title - 14 + 4; + else + victim_guid = 0; // Don't show HK: message, only log. + } + + if(k_level <= 5) + k_grey = 0; + else if( k_level <= 39 ) + k_grey = k_level - 5 - k_level/10; + else + k_grey = k_level - 1 - k_level/5; + + if(v_level<=k_grey) + return false; + + float diff_level = (k_level == k_grey) ? 1 : ((float(v_level) - float(k_grey)) / (float(k_level) - float(k_grey))); + + int32 v_rank =1; //need more info + + honor = ((f * diff_level * (190 + v_rank*10))/6); + honor *= ((float)k_level) / 70.0f; //factor of dependence on levels of the killer + + // count the number of playerkills in one day + ApplyModUInt32Value(PLAYER_FIELD_KILLS, 1, true); + // and those in a lifetime + ApplyModUInt32Value(PLAYER_FIELD_LIFETIME_HONORBALE_KILLS, 1, true); + } + else + { + Creature *cVictim = (Creature *)uVictim; + + if (!cVictim->isRacialLeader()) + return false; + + honor = 100; // ??? need more info + victim_rank = 19; // HK: Leader + } + } + + if (uVictim != NULL) + { + honor *= sWorld.getRate(RATE_HONOR); + + if(groupsize > 1) + honor /= groupsize; + + honor *= (((float)urand(8,12))/10); // approx honor: 80% - 120% of real honor + } + + // honor - for show honor points in log + // victim_guid - for show victim name in log + // victim_rank [1..4] HK: + // victim_rank [5..19] HK: + // victim_rank [0,20+] HK: <> + WorldPacket data(SMSG_PVP_CREDIT,4+8+4); + data << (uint32) honor; + data << (uint64) victim_guid; + data << (uint32) victim_rank; + + GetSession()->SendPacket(&data); + + // add honor points + ModifyHonorPoints(int32(honor)); + + ApplyModUInt32Value(PLAYER_FIELD_TODAY_CONTRIBUTION, uint32(honor), true); + return true; +} + +void Player::ModifyHonorPoints( int32 value ) +{ + if(value < 0) + { + if (GetHonorPoints() > sWorld.getConfig(CONFIG_MAX_HONOR_POINTS)) + SetUInt32Value(PLAYER_FIELD_HONOR_CURRENCY, sWorld.getConfig(CONFIG_MAX_HONOR_POINTS) + value); + else + SetUInt32Value(PLAYER_FIELD_HONOR_CURRENCY, GetHonorPoints() > uint32(-value) ? GetHonorPoints() + value : 0); + } + else + SetUInt32Value(PLAYER_FIELD_HONOR_CURRENCY, GetHonorPoints() < sWorld.getConfig(CONFIG_MAX_HONOR_POINTS) - value ? GetHonorPoints() + value : sWorld.getConfig(CONFIG_MAX_HONOR_POINTS)); +} + +void Player::ModifyArenaPoints( int32 value ) +{ + if(value < 0) + { + if (GetArenaPoints() > sWorld.getConfig(CONFIG_MAX_ARENA_POINTS)) + SetUInt32Value(PLAYER_FIELD_ARENA_CURRENCY, sWorld.getConfig(CONFIG_MAX_ARENA_POINTS) + value); + else + SetUInt32Value(PLAYER_FIELD_ARENA_CURRENCY, GetArenaPoints() > uint32(-value) ? GetArenaPoints() + value : 0); + } + else + SetUInt32Value(PLAYER_FIELD_ARENA_CURRENCY, GetArenaPoints() < sWorld.getConfig(CONFIG_MAX_ARENA_POINTS) - value ? GetArenaPoints() + value : sWorld.getConfig(CONFIG_MAX_ARENA_POINTS)); +} + +uint32 Player::GetGuildIdFromDB(uint64 guid) +{ + std::ostringstream ss; + ss<<"SELECT guildid FROM guild_member WHERE guid='"<Fetch()[0].GetUInt32(); + delete result; + return v; + } + else + return 0; +} + +uint32 Player::GetRankFromDB(uint64 guid) +{ + std::ostringstream ss; + ss<<"SELECT rank FROM guild_member WHERE guid='"<Fetch()[0].GetUInt32(); + delete result; + return v; + } + else + return 0; +} + +uint32 Player::GetArenaTeamIdFromDB(uint64 guid, uint8 type) +{ + // need fix it! + QueryResult *result = CharacterDatabase.PQuery("SELECT arenateamid FROM arena_team_member WHERE guid='%u'", GUID_LOPART(guid)); + if(result) + { + // init id to 0, check the arena type before assigning a value to id + uint32 id = 0; + do + { + QueryResult *result2 = CharacterDatabase.PQuery("SELECT type FROM arena_team WHERE arenateamid='%u'", id); + if(result2) + { + uint8 dbtype = (*result2)[0].GetUInt32(); + delete result2; + if(dbtype == type) + { + // if the type matches, we've found the id + id = (*result)[0].GetUInt32(); + break; + } + } + } while(result->NextRow()); + delete result; + return id; + } + // no arenateam for the specified guid, return 0 + return 0; +} + +uint32 Player::GetZoneIdFromDB(uint64 guid) +{ + std::ostringstream ss; + + ss<<"SELECT zone FROM characters WHERE guid='"<Fetch(); + uint32 zone = fields[0].GetUInt32(); + delete result; + + if (!zone) + { + // stored zone is zero, use generic and slow zone detection + ss.str(""); + ss<<"SELECT map,position_x,position_y FROM characters WHERE guid='"<Fetch(); + uint32 map = fields[0].GetUInt32(); + float posx = fields[1].GetFloat(); + float posy = fields[2].GetFloat(); + delete result; + + zone = MapManager::Instance().GetZoneId(map,posx,posy); + + ss.str(""); + ss << "UPDATE characters SET zone='"<flags & AREA_FLAG_ARENA)) + { + if(!isGameMaster()) + SetFlag(PLAYER_FLAGS, PLAYER_FLAGS_FFA_PVP); + } + else + { + // remove ffa flag only if not ffapvp realm + // removal in sanctuaries and capitals is handled in zone update + if(HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_FFA_PVP) && !sWorld.IsFFAPvPRealm()) + RemoveFlag(PLAYER_FLAGS, PLAYER_FLAGS_FFA_PVP); + } + + UpdateAreaDependentAuras(newArea); +} + +void Player::UpdateZone(uint32 newZone) +{ + m_zoneUpdateId = newZone; + m_zoneUpdateTimer = ZONE_UPDATE_INTERVAL; + + // zone changed, so area changed as well, update it + UpdateArea(GetAreaId()); + + AreaTableEntry const* zone = GetAreaEntryByAreaID(newZone); + if(!zone) + return; + + if (sWorld.getConfig(CONFIG_WEATHER)) + { + Weather *wth = sWorld.FindWeather(zone->ID); + if(wth) + { + wth->SendWeatherUpdateToPlayer(this); + } + else + { + if(!sWorld.AddWeather(zone->ID)) + { + // send fine weather packet to remove old zone's weather + Weather::SendFineWeatherUpdateToPlayer(this); + } + } + } + + pvpInfo.inHostileArea = + GetTeam() == ALLIANCE && zone->team == AREATEAM_HORDE || + GetTeam() == HORDE && zone->team == AREATEAM_ALLY || + sWorld.IsPvPRealm() && zone->team == AREATEAM_NONE || + InBattleGround(); // overwrite for battlegrounds, maybe batter some zone flags but current known not 100% fit to this + + if(pvpInfo.inHostileArea) // in hostile area + { + if(!IsPvP() || pvpInfo.endTimer != 0) + UpdatePvP(true, true); + } + else // in friendly area + { + if(IsPvP() && !HasFlag(PLAYER_FLAGS,PLAYER_FLAGS_IN_PVP) && pvpInfo.endTimer == 0) + pvpInfo.endTimer = time(0); // start toggle-off + } + + if(zone->flags & AREA_FLAG_SANCTUARY) // in sanctuary + { + SetFlag(PLAYER_FLAGS, PLAYER_FLAGS_SANCTUARY); + if(sWorld.IsFFAPvPRealm()) + RemoveFlag(PLAYER_FLAGS,PLAYER_FLAGS_FFA_PVP); + } + else + { + RemoveFlag(PLAYER_FLAGS, PLAYER_FLAGS_SANCTUARY); + } + + if(zone->flags & AREA_FLAG_CAPITAL) // in capital city + { + SetFlag(PLAYER_FLAGS, PLAYER_FLAGS_RESTING); + SetRestType(REST_TYPE_IN_CITY); + InnEnter(time(0),GetMapId(),0,0,0); + + if(sWorld.IsFFAPvPRealm()) + RemoveFlag(PLAYER_FLAGS,PLAYER_FLAGS_FFA_PVP); + } + else // anywhere else + { + if(HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_RESTING)) // but resting (walk from city or maybe in tavern or leave tavern recently) + { + if(GetRestType()==REST_TYPE_IN_TAVERN) // has been in tavern. Is still in? + { + if(GetMapId()!=GetInnPosMapId() || sqrt((GetPositionX()-GetInnPosX())*(GetPositionX()-GetInnPosX())+(GetPositionY()-GetInnPosY())*(GetPositionY()-GetInnPosY())+(GetPositionZ()-GetInnPosZ())*(GetPositionZ()-GetInnPosZ()))>40) + { + RemoveFlag(PLAYER_FLAGS, PLAYER_FLAGS_RESTING); + SetRestType(REST_TYPE_NO); + + if(sWorld.IsFFAPvPRealm()) + SetFlag(PLAYER_FLAGS,PLAYER_FLAGS_FFA_PVP); + } + } + else // not in tavern (leave city then) + { + RemoveFlag(PLAYER_FLAGS, PLAYER_FLAGS_RESTING); + SetRestType(REST_TYPE_NO); + + // Set player to FFA PVP when not in rested enviroment. + if(sWorld.IsFFAPvPRealm()) + SetFlag(PLAYER_FLAGS,PLAYER_FLAGS_FFA_PVP); + } + } + } + + // remove items with area/map limitations (delete only for alive player to allow back in ghost mode) + // if player resurrected at teleport this will be applied in resurrect code + if(isAlive()) + DestroyZoneLimitedItem( true, newZone ); + + // recent client version not send leave/join channel packets for built-in local channels + UpdateLocalChannels( newZone ); + + // group update + if(GetGroup()) + SetGroupUpdateFlag(GROUP_UPDATE_FLAG_ZONE); + + UpdateZoneDependentAuras(newZone); +} + +//If players are too far way of duel flag... then player loose the duel +void Player::CheckDuelDistance(time_t currTime) +{ + if(!duel) + return; + + uint64 duelFlagGUID = GetUInt64Value(PLAYER_DUEL_ARBITER); + GameObject* obj = ObjectAccessor::GetGameObject(*this, duelFlagGUID); + if(!obj) + return; + + if(duel->outOfBound == 0) + { + if(!IsWithinDistInMap(obj, 50)) + { + duel->outOfBound = currTime; + + WorldPacket data(SMSG_DUEL_OUTOFBOUNDS, 0); + GetSession()->SendPacket(&data); + } + } + else + { + if(IsWithinDistInMap(obj, 40)) + { + duel->outOfBound = 0; + + WorldPacket data(SMSG_DUEL_INBOUNDS, 0); + GetSession()->SendPacket(&data); + } + else if(currTime >= (duel->outOfBound+10)) + { + DuelComplete(DUEL_FLED); + } + } +} + +void Player::DuelComplete(DuelCompleteType type) +{ + // duel not requested + if(!duel) + return; + + WorldPacket data(SMSG_DUEL_COMPLETE, (1)); + data << (uint8)((type != DUEL_INTERUPTED) ? 1 : 0); + GetSession()->SendPacket(&data); + duel->opponent->GetSession()->SendPacket(&data); + + if(type != DUEL_INTERUPTED) + { + data.Initialize(SMSG_DUEL_WINNER, (1+20)); // we guess size + data << (uint8)((type==DUEL_WON) ? 0 : 1); // 0 = just won; 1 = fled + data << duel->opponent->GetName(); + data << GetName(); + SendMessageToSet(&data,true); + } + + // cool-down duel spell + /*data.Initialize(SMSG_SPELL_COOLDOWN, 17); + + data<SendPacket(&data); + data.Initialize(SMSG_SPELL_COOLDOWN, 17); + data<opponent->GetGUID(); + data<opponent->GetSession()->SendPacket(&data);*/ + + //Remove Duel Flag object + GameObject* obj = ObjectAccessor::GetGameObject(*this, GetUInt64Value(PLAYER_DUEL_ARBITER)); + if(obj) + duel->initiator->RemoveGameObject(obj,true); + + /* remove auras */ + std::vector auras2remove; + AuraMap const& vAuras = duel->opponent->GetAuras(); + for (AuraMap::const_iterator i = vAuras.begin(); i != vAuras.end(); i++) + { + if (!i->second->IsPositive() && i->second->GetCasterGUID() == GetGUID() && i->second->GetAuraApplyTime() >= duel->startTime) + auras2remove.push_back(i->second->GetId()); + } + + for(size_t i=0; iopponent->RemoveAurasDueToSpell(auras2remove[i]); + + auras2remove.clear(); + AuraMap const& auras = GetAuras(); + for (AuraMap::const_iterator i = auras.begin(); i != auras.end(); i++) + { + if (!i->second->IsPositive() && i->second->GetCasterGUID() == duel->opponent->GetGUID() && i->second->GetAuraApplyTime() >= duel->startTime) + auras2remove.push_back(i->second->GetId()); + } + for(size_t i=0; iopponent->GetGUID()) + ClearComboPoints(); + else if(GetComboTarget()==duel->opponent->GetPetGUID()) + ClearComboPoints(); + + if(duel->opponent->GetComboTarget()==GetGUID()) + duel->opponent->ClearComboPoints(); + else if(duel->opponent->GetComboTarget()==GetPetGUID()) + duel->opponent->ClearComboPoints(); + + //cleanups + SetUInt64Value(PLAYER_DUEL_ARBITER, 0); + SetUInt32Value(PLAYER_DUEL_TEAM, 0); + duel->opponent->SetUInt64Value(PLAYER_DUEL_ARBITER, 0); + duel->opponent->SetUInt32Value(PLAYER_DUEL_TEAM, 0); + + delete duel->opponent->duel; + duel->opponent->duel = NULL; + delete duel; + duel = NULL; +} + +//---------------------------------------------------------// + +void Player::_ApplyItemMods(Item *item, uint8 slot,bool apply) +{ + if(slot >= INVENTORY_SLOT_BAG_END || !item) + return; + + // not apply/remove mods for broken item + if(item->IsBroken()) + return; + + ItemPrototype const *proto = item->GetProto(); + + if(!proto) + return; + + sLog.outDetail("applying mods for item %u ",item->GetGUIDLow()); + + uint32 attacktype = Player::GetAttackBySlot(slot); + if(attacktype < MAX_ATTACK) + _ApplyWeaponDependentAuraMods(item,WeaponAttackType(attacktype),apply); + + _ApplyItemBonuses(proto,slot,apply); + + if( slot==EQUIPMENT_SLOT_RANGED ) + _ApplyAmmoBonuses(); + + ApplyItemEquipSpell(item,apply); + ApplyEnchantment(item, apply); + + if(proto->Socket[0].Color) //only (un)equipping of items with sockets can influence metagems, so no need to waste time with normal items + CorrectMetaGemEnchants(slot, apply); + + sLog.outDebug("_ApplyItemMods complete."); +} + +void Player::_ApplyItemBonuses(ItemPrototype const *proto,uint8 slot,bool apply) +{ + if(slot >= INVENTORY_SLOT_BAG_END || !proto) + return; + + for (int i = 0; i < 10; i++) + { + float val = float (proto->ItemStat[i].ItemStatValue); + + if(val==0) + continue; + + switch (proto->ItemStat[i].ItemStatType) + { + case ITEM_MOD_MANA: + HandleStatModifier(UNIT_MOD_MANA, BASE_VALUE, float(val), apply); + break; + case ITEM_MOD_HEALTH: // modify HP + HandleStatModifier(UNIT_MOD_HEALTH, BASE_VALUE, float(val), apply); + break; + case ITEM_MOD_AGILITY: // modify agility + HandleStatModifier(UNIT_MOD_STAT_AGILITY, BASE_VALUE, float(val), apply); + ApplyStatBuffMod(STAT_AGILITY, val, apply); + break; + case ITEM_MOD_STRENGTH: //modify strength + HandleStatModifier(UNIT_MOD_STAT_STRENGTH, BASE_VALUE, float(val), apply); + ApplyStatBuffMod(STAT_STRENGTH, val, apply); + break; + case ITEM_MOD_INTELLECT: //modify intellect + HandleStatModifier(UNIT_MOD_STAT_INTELLECT, BASE_VALUE, float(val), apply); + ApplyStatBuffMod(STAT_INTELLECT, val, apply); + break; + case ITEM_MOD_SPIRIT: //modify spirit + HandleStatModifier(UNIT_MOD_STAT_SPIRIT, BASE_VALUE, float(val), apply); + ApplyStatBuffMod(STAT_SPIRIT, val, apply); + break; + case ITEM_MOD_STAMINA: //modify stamina + HandleStatModifier(UNIT_MOD_STAT_STAMINA, BASE_VALUE, float(val), apply); + ApplyStatBuffMod(STAT_STAMINA, val, apply); + break; + case ITEM_MOD_DEFENSE_SKILL_RATING: + ApplyRatingMod(CR_DEFENSE_SKILL, int32(val), apply); + break; + case ITEM_MOD_DODGE_RATING: + ApplyRatingMod(CR_DODGE, int32(val), apply); + break; + case ITEM_MOD_PARRY_RATING: + ApplyRatingMod(CR_PARRY, int32(val), apply); + break; + case ITEM_MOD_BLOCK_RATING: + ApplyRatingMod(CR_BLOCK, int32(val), apply); + break; + case ITEM_MOD_HIT_MELEE_RATING: + ApplyRatingMod(CR_HIT_MELEE, int32(val), apply); + break; + case ITEM_MOD_HIT_RANGED_RATING: + ApplyRatingMod(CR_HIT_RANGED, int32(val), apply); + break; + case ITEM_MOD_HIT_SPELL_RATING: + ApplyRatingMod(CR_HIT_SPELL, int32(val), apply); + break; + case ITEM_MOD_CRIT_MELEE_RATING: + ApplyRatingMod(CR_CRIT_MELEE, int32(val), apply); + break; + case ITEM_MOD_CRIT_RANGED_RATING: + ApplyRatingMod(CR_CRIT_RANGED, int32(val), apply); + break; + case ITEM_MOD_CRIT_SPELL_RATING: + ApplyRatingMod(CR_CRIT_SPELL, int32(val), apply); + break; + case ITEM_MOD_HIT_TAKEN_MELEE_RATING: + ApplyRatingMod(CR_HIT_TAKEN_MELEE, int32(val), apply); + break; + case ITEM_MOD_HIT_TAKEN_RANGED_RATING: + ApplyRatingMod(CR_HIT_TAKEN_RANGED, int32(val), apply); + break; + case ITEM_MOD_HIT_TAKEN_SPELL_RATING: + ApplyRatingMod(CR_HIT_TAKEN_SPELL, int32(val), apply); + break; + case ITEM_MOD_CRIT_TAKEN_MELEE_RATING: + ApplyRatingMod(CR_CRIT_TAKEN_MELEE, int32(val), apply); + break; + case ITEM_MOD_CRIT_TAKEN_RANGED_RATING: + ApplyRatingMod(CR_CRIT_TAKEN_RANGED, int32(val), apply); + break; + case ITEM_MOD_CRIT_TAKEN_SPELL_RATING: + ApplyRatingMod(CR_CRIT_TAKEN_SPELL, int32(val), apply); + break; + case ITEM_MOD_HASTE_MELEE_RATING: + ApplyRatingMod(CR_HASTE_MELEE, int32(val), apply); + break; + case ITEM_MOD_HASTE_RANGED_RATING: + ApplyRatingMod(CR_HASTE_RANGED, int32(val), apply); + break; + case ITEM_MOD_HASTE_SPELL_RATING: + ApplyRatingMod(CR_HASTE_SPELL, int32(val), apply); + break; + case ITEM_MOD_HIT_RATING: + ApplyRatingMod(CR_HIT_MELEE, int32(val), apply); + ApplyRatingMod(CR_HIT_RANGED, int32(val), apply); + ApplyRatingMod(CR_HIT_SPELL, int32(val), apply); + break; + case ITEM_MOD_CRIT_RATING: + ApplyRatingMod(CR_CRIT_MELEE, int32(val), apply); + ApplyRatingMod(CR_CRIT_RANGED, int32(val), apply); + ApplyRatingMod(CR_CRIT_SPELL, int32(val), apply); + break; + case ITEM_MOD_HIT_TAKEN_RATING: + ApplyRatingMod(CR_HIT_TAKEN_MELEE, int32(val), apply); + ApplyRatingMod(CR_HIT_TAKEN_RANGED, int32(val), apply); + ApplyRatingMod(CR_HIT_TAKEN_SPELL, int32(val), apply); + break; + case ITEM_MOD_CRIT_TAKEN_RATING: + ApplyRatingMod(CR_CRIT_TAKEN_MELEE, int32(val), apply); + ApplyRatingMod(CR_CRIT_TAKEN_RANGED, int32(val), apply); + ApplyRatingMod(CR_CRIT_TAKEN_SPELL, int32(val), apply); + break; + case ITEM_MOD_RESILIENCE_RATING: + ApplyRatingMod(CR_CRIT_TAKEN_MELEE, int32(val), apply); + ApplyRatingMod(CR_CRIT_TAKEN_RANGED, int32(val), apply); + ApplyRatingMod(CR_CRIT_TAKEN_SPELL, int32(val), apply); + break; + case ITEM_MOD_HASTE_RATING: + ApplyRatingMod(CR_HASTE_MELEE, int32(val), apply); + ApplyRatingMod(CR_HASTE_RANGED, int32(val), apply); + ApplyRatingMod(CR_HASTE_SPELL, int32(val), apply); + break; + case ITEM_MOD_EXPERTISE_RATING: + ApplyRatingMod(CR_EXPERTISE, int32(val), apply); + break; + } + } + + if (proto->Armor) + HandleStatModifier(UNIT_MOD_ARMOR, BASE_VALUE, float(proto->Armor), apply); + + if (proto->Block) + HandleBaseModValue(SHIELD_BLOCK_VALUE, FLAT_MOD, float(proto->Block), apply); + + if (proto->HolyRes) + HandleStatModifier(UNIT_MOD_RESISTANCE_HOLY, BASE_VALUE, float(proto->HolyRes), apply); + + if (proto->FireRes) + HandleStatModifier(UNIT_MOD_RESISTANCE_FIRE, BASE_VALUE, float(proto->FireRes), apply); + + if (proto->NatureRes) + HandleStatModifier(UNIT_MOD_RESISTANCE_NATURE, BASE_VALUE, float(proto->NatureRes), apply); + + if (proto->FrostRes) + HandleStatModifier(UNIT_MOD_RESISTANCE_FROST, BASE_VALUE, float(proto->FrostRes), apply); + + if (proto->ShadowRes) + HandleStatModifier(UNIT_MOD_RESISTANCE_SHADOW, BASE_VALUE, float(proto->ShadowRes), apply); + + if (proto->ArcaneRes) + HandleStatModifier(UNIT_MOD_RESISTANCE_ARCANE, BASE_VALUE, float(proto->ArcaneRes), apply); + + WeaponAttackType attType = BASE_ATTACK; + float damage = 0.0f; + + if( slot == EQUIPMENT_SLOT_RANGED && ( + proto->InventoryType == INVTYPE_RANGED || proto->InventoryType == INVTYPE_THROWN || + proto->InventoryType == INVTYPE_RANGEDRIGHT )) + { + attType = RANGED_ATTACK; + } + else if(slot==EQUIPMENT_SLOT_OFFHAND) + { + attType = OFF_ATTACK; + } + + if (proto->Damage[0].DamageMin > 0 ) + { + damage = apply ? proto->Damage[0].DamageMin : BASE_MINDAMAGE; + SetBaseWeaponDamage(attType, MINDAMAGE, damage); + //sLog.outError("applying mindam: assigning %f to weapon mindamage, now is: %f", damage, GetWeaponDamageRange(attType, MINDAMAGE)); + } + + if (proto->Damage[0].DamageMax > 0 ) + { + damage = apply ? proto->Damage[0].DamageMax : BASE_MAXDAMAGE; + SetBaseWeaponDamage(attType, MAXDAMAGE, damage); + } + + if(!IsUseEquipedWeapon(slot==EQUIPMENT_SLOT_MAINHAND)) + return; + + if (proto->Delay) + { + if(slot == EQUIPMENT_SLOT_RANGED) + SetAttackTime(RANGED_ATTACK, apply ? proto->Delay: BASE_ATTACK_TIME); + else if(slot==EQUIPMENT_SLOT_MAINHAND) + SetAttackTime(BASE_ATTACK, apply ? proto->Delay: BASE_ATTACK_TIME); + else if(slot==EQUIPMENT_SLOT_OFFHAND) + SetAttackTime(OFF_ATTACK, apply ? proto->Delay: BASE_ATTACK_TIME); + } + + if(CanModifyStats() && (damage || proto->Delay)) + UpdateDamagePhysical(attType); +} + +void Player::_ApplyWeaponDependentAuraMods(Item *item,WeaponAttackType attackType,bool apply) +{ + AuraList const& auraCritList = GetAurasByType(SPELL_AURA_MOD_CRIT_PERCENT); + for(AuraList::const_iterator itr = auraCritList.begin(); itr!=auraCritList.end();++itr) + _ApplyWeaponDependentAuraCritMod(item,attackType,*itr,apply); + + AuraList const& auraDamageFlatList = GetAurasByType(SPELL_AURA_MOD_DAMAGE_DONE); + for(AuraList::const_iterator itr = auraDamageFlatList.begin(); itr!=auraDamageFlatList.end();++itr) + _ApplyWeaponDependentAuraDamageMod(item,attackType,*itr,apply); + + AuraList const& auraDamagePCTList = GetAurasByType(SPELL_AURA_MOD_DAMAGE_PERCENT_DONE); + for(AuraList::const_iterator itr = auraDamagePCTList.begin(); itr!=auraDamagePCTList.end();++itr) + _ApplyWeaponDependentAuraDamageMod(item,attackType,*itr,apply); +} + +void Player::_ApplyWeaponDependentAuraCritMod(Item *item, WeaponAttackType attackType, Aura* aura, bool apply) +{ + // generic not weapon specific case processes in aura code + if(aura->GetSpellProto()->EquippedItemClass == -1) + return; + + BaseModGroup mod = BASEMOD_END; + switch(attackType) + { + case BASE_ATTACK: mod = CRIT_PERCENTAGE; break; + case OFF_ATTACK: mod = OFFHAND_CRIT_PERCENTAGE;break; + case RANGED_ATTACK: mod = RANGED_CRIT_PERCENTAGE; break; + default: return; + } + + if (item->IsFitToSpellRequirements(aura->GetSpellProto())) + { + HandleBaseModValue(mod, FLAT_MOD, float (aura->GetModifier()->m_amount), apply); + } +} + +void Player::_ApplyWeaponDependentAuraDamageMod(Item *item, WeaponAttackType attackType, Aura* aura, bool apply) +{ + // ignore spell mods for not wands + Modifier const* modifier = aura->GetModifier(); + if((modifier->m_miscvalue & SPELL_SCHOOL_MASK_NORMAL)==0 && (getClassMask() & CLASSMASK_WAND_USERS)==0) + return; + + // generic not weapon specific case processes in aura code + if(aura->GetSpellProto()->EquippedItemClass == -1) + return; + + UnitMods unitMod = UNIT_MOD_END; + switch(attackType) + { + case BASE_ATTACK: unitMod = UNIT_MOD_DAMAGE_MAINHAND; break; + case OFF_ATTACK: unitMod = UNIT_MOD_DAMAGE_OFFHAND; break; + case RANGED_ATTACK: unitMod = UNIT_MOD_DAMAGE_RANGED; break; + default: return; + } + + UnitModifierType unitModType = TOTAL_VALUE; + switch(modifier->m_auraname) + { + case SPELL_AURA_MOD_DAMAGE_DONE: unitModType = TOTAL_VALUE; break; + case SPELL_AURA_MOD_DAMAGE_PERCENT_DONE: unitModType = TOTAL_PCT; break; + default: return; + } + + if (item->IsFitToSpellRequirements(aura->GetSpellProto())) + { + HandleStatModifier(unitMod, unitModType, float(modifier->m_amount),apply); + } +} + +void Player::ApplyItemEquipSpell(Item *item, bool apply, bool form_change) +{ + if(!item) + return; + + ItemPrototype const *proto = item->GetProto(); + if(!proto) + return; + + for (int i = 0; i < 5; i++) + { + _Spell const& spellData = proto->Spells[i]; + + // no spell + if(!spellData.SpellId ) + continue; + + // wrong triggering type + if(apply && spellData.SpellTrigger != ITEM_SPELLTRIGGER_ON_EQUIP) + continue; + + // check if it is valid spell + SpellEntry const* spellproto = sSpellStore.LookupEntry(spellData.SpellId); + if(!spellproto) + continue; + + ApplyEquipSpell(spellproto,item,apply,form_change); + } +} + +void Player::ApplyEquipSpell(SpellEntry const* spellInfo, Item* item, bool apply, bool form_change) +{ + if(apply) + { + // Cannot be used in this stance/form + if(GetErrorAtShapeshiftedCast(spellInfo, m_form)!=0) + return; + + if(form_change) // check aura active state from other form + { + bool found = false; + for (int k=0; k < 3; ++k) + { + spellEffectPair spair = spellEffectPair(spellInfo->Id, k); + for (AuraMap::iterator iter = m_Auras.lower_bound(spair); iter != m_Auras.upper_bound(spair); ++iter) + { + if(!item || iter->second->GetCastItemGUID() == item->GetGUID()) + { + found = true; + break; + } + } + if(found) + break; + } + + if(found) // and skip re-cast already active aura at form change + return; + } + + DEBUG_LOG("WORLD: cast %s Equip spellId - %i", (item ? "item" : "itemset"), spellInfo->Id); + + CastSpell(this,spellInfo,true,item); + } + else + { + if(form_change) // check aura compatibility + { + // Cannot be used in this stance/form + if(GetErrorAtShapeshiftedCast(spellInfo, m_form)==0) + return; // and remove only not compatible at form change + } + + if(item) + RemoveAurasDueToItemSpell(item,spellInfo->Id); // un-apply all spells , not only at-equipped + else + RemoveAurasDueToSpell(spellInfo->Id); // un-apply spell (item set case) + } +} + +void Player::UpdateEquipSpellsAtFormChange() +{ + for (int i = 0; i < INVENTORY_SLOT_BAG_END; i++) + { + if(m_items[i] && !m_items[i]->IsBroken()) + { + ApplyItemEquipSpell(m_items[i],false,true); // remove spells that not fit to form + ApplyItemEquipSpell(m_items[i],true,true); // add spells that fit form but not active + } + } + + // item set bonuses not dependent from item broken state + for(size_t setindex = 0; setindex < ItemSetEff.size(); ++setindex) + { + ItemSetEffect* eff = ItemSetEff[setindex]; + if(!eff) + continue; + + for(uint32 y=0;y<8; ++y) + { + SpellEntry const* spellInfo = eff->spells[y]; + if(!spellInfo) + continue; + + ApplyEquipSpell(spellInfo,NULL,false,true); // remove spells that not fit to form + ApplyEquipSpell(spellInfo,NULL,true,true); // add spells that fit form but not active + } + } +} + +void Player::CastItemCombatSpell(Item *item,Unit* Target, WeaponAttackType attType) +{ + if(!item || item->IsBroken()) + return; + + ItemPrototype const *proto = item->GetProto(); + if(!proto) + return; + + if (!Target || Target == this ) + return; + + for (int i = 0; i < 5; i++) + { + _Spell const& spellData = proto->Spells[i]; + + // no spell + if(!spellData.SpellId ) + continue; + + // wrong triggering type + if(spellData.SpellTrigger != ITEM_SPELLTRIGGER_CHANCE_ON_HIT) + continue; + + SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellData.SpellId); + if(!spellInfo) + { + sLog.outError("WORLD: unknown Item spellid %i", spellData.SpellId); + continue; + } + + // not allow proc extra attack spell at extra attack + if( m_extraAttacks && IsSpellHaveEffect(spellInfo,SPELL_EFFECT_ADD_EXTRA_ATTACKS) ) + return; + + float chance = spellInfo->procChance; + + if(spellData.SpellPPMRate) + { + uint32 WeaponSpeed = GetAttackTime(attType); + chance = GetPPMProcChance(WeaponSpeed, spellData.SpellPPMRate); + } + else if(chance > 100.0f) + { + chance = GetWeaponProcChance(); + } + + if (roll_chance_f(chance)) + this->CastSpell(Target, spellInfo->Id, true, item); + } + + // item combat enchantments + for(int e_slot = 0; e_slot < MAX_ENCHANTMENT_SLOT; ++e_slot) + { + uint32 enchant_id = item->GetEnchantmentId(EnchantmentSlot(e_slot)); + SpellItemEnchantmentEntry const *pEnchant = sSpellItemEnchantmentStore.LookupEntry(enchant_id); + if(!pEnchant) continue; + for (int s=0;s<3;s++) + { + if(pEnchant->type[s]!=ITEM_ENCHANTMENT_TYPE_COMBAT_SPELL) + continue; + + SpellEntry const *spellInfo = sSpellStore.LookupEntry(pEnchant->spellid[s]); + if (!spellInfo) + { + sLog.outError("Player::CastItemCombatSpell Enchant %i, cast unknown spell %i", pEnchant->ID, pEnchant->spellid[s]); + continue; + } + + float chance = pEnchant->amount[s] != 0 ? float(pEnchant->amount[s]) : GetWeaponProcChance(); + if (roll_chance_f(chance)) + { + if(IsPositiveSpell(pEnchant->spellid[s])) + CastSpell(this, pEnchant->spellid[s], true, item); + else + CastSpell(Target, pEnchant->spellid[s], true, item); + } + } + } +} + +void Player::_RemoveAllItemMods() +{ + sLog.outDebug("_RemoveAllItemMods start."); + + for (int i = 0; i < INVENTORY_SLOT_BAG_END; i++) + { + if(m_items[i]) + { + ItemPrototype const *proto = m_items[i]->GetProto(); + if(!proto) + continue; + + // item set bonuses not dependent from item broken state + if(proto->ItemSet) + RemoveItemsSetItem(this,proto); + + if(m_items[i]->IsBroken()) + continue; + + ApplyItemEquipSpell(m_items[i],false); + ApplyEnchantment(m_items[i], false); + } + } + + for (int i = 0; i < INVENTORY_SLOT_BAG_END; i++) + { + if(m_items[i]) + { + if(m_items[i]->IsBroken()) + continue; + ItemPrototype const *proto = m_items[i]->GetProto(); + if(!proto) + continue; + + uint32 attacktype = Player::GetAttackBySlot(i); + if(attacktype < MAX_ATTACK) + _ApplyWeaponDependentAuraMods(m_items[i],WeaponAttackType(attacktype),false); + + _ApplyItemBonuses(proto,i, false); + + if( i == EQUIPMENT_SLOT_RANGED ) + _ApplyAmmoBonuses(); + } + } + + sLog.outDebug("_RemoveAllItemMods complete."); +} + +void Player::_ApplyAllItemMods() +{ + sLog.outDebug("_ApplyAllItemMods start."); + + for (int i = 0; i < INVENTORY_SLOT_BAG_END; i++) + { + if(m_items[i]) + { + if(m_items[i]->IsBroken()) + continue; + + ItemPrototype const *proto = m_items[i]->GetProto(); + if(!proto) + continue; + + uint32 attacktype = Player::GetAttackBySlot(i); + if(attacktype < MAX_ATTACK) + _ApplyWeaponDependentAuraMods(m_items[i],WeaponAttackType(attacktype),true); + + _ApplyItemBonuses(proto,i, true); + + if( i == EQUIPMENT_SLOT_RANGED ) + _ApplyAmmoBonuses(); + } + } + + for (int i = 0; i < INVENTORY_SLOT_BAG_END; i++) + { + if(m_items[i]) + { + ItemPrototype const *proto = m_items[i]->GetProto(); + if(!proto) + continue; + + // item set bonuses not dependent from item broken state + if(proto->ItemSet) + AddItemsSetItem(this,m_items[i]); + + if(m_items[i]->IsBroken()) + continue; + + ApplyItemEquipSpell(m_items[i],true); + ApplyEnchantment(m_items[i], true); + } + } + + sLog.outDebug("_ApplyAllItemMods complete."); +} + +void Player::_ApplyAmmoBonuses() +{ + // check ammo + uint32 ammo_id = GetUInt32Value(PLAYER_AMMO_ID); + if(!ammo_id) + return; + + float currentAmmoDPS; + + ItemPrototype const *ammo_proto = objmgr.GetItemPrototype( ammo_id ); + if( !ammo_proto || ammo_proto->Class!=ITEM_CLASS_PROJECTILE || !CheckAmmoCompatibility(ammo_proto)) + currentAmmoDPS = 0.0f; + else + currentAmmoDPS = ammo_proto->Damage[0].DamageMin; + + if(currentAmmoDPS == GetAmmoDPS()) + return; + + m_ammoDPS = currentAmmoDPS; + + if(CanModifyStats()) + UpdateDamagePhysical(RANGED_ATTACK); +} + +bool Player::CheckAmmoCompatibility(const ItemPrototype *ammo_proto) const +{ + if(!ammo_proto) + return false; + + // check ranged weapon + Item *weapon = GetWeaponForAttack( RANGED_ATTACK ); + if(!weapon || weapon->IsBroken() ) + return false; + + ItemPrototype const* weapon_proto = weapon->GetProto(); + if(!weapon_proto || weapon_proto->Class!=ITEM_CLASS_WEAPON ) + return false; + + // check ammo ws. weapon compatibility + switch(weapon_proto->SubClass) + { + case ITEM_SUBCLASS_WEAPON_BOW: + case ITEM_SUBCLASS_WEAPON_CROSSBOW: + if(ammo_proto->SubClass!=ITEM_SUBCLASS_ARROW) + return false; + break; + case ITEM_SUBCLASS_WEAPON_GUN: + if(ammo_proto->SubClass!=ITEM_SUBCLASS_BULLET) + return false; + break; + default: + return false; + } + + return true; +} + +/* If in a battleground a player dies, and an enemy removes the insignia, the player's bones is lootable + Called by remove insignia spell effect */ +void Player::RemovedInsignia(Player* looterPlr) +{ + if (!GetBattleGroundId()) + return; + + // If not released spirit, do it ! + if(m_deathTimer > 0) + { + m_deathTimer = 0; + BuildPlayerRepop(); + RepopAtGraveyard(); + } + + Corpse *corpse = GetCorpse(); + if (!corpse) + return; + + // We have to convert player corpse to bones, not to be able to resurrect there + // SpawnCorpseBones isn't handy, 'cos it saves player while he in BG + Corpse *bones = ObjectAccessor::Instance().ConvertCorpseForPlayer(GetGUID()); + if (!bones) + return; + + // Now we must make bones lootable, and send player loot + bones->SetFlag(CORPSE_FIELD_DYNAMIC_FLAGS, CORPSE_DYNFLAG_LOOTABLE); + + // We store the level of our player in the gold field + // We retrieve this information at Player::SendLoot() + bones->loot.gold = getLevel(); + bones->lootRecipient = looterPlr; + looterPlr->SendLoot(bones->GetGUID(), LOOT_INSIGNIA); +} + +/*Loot type MUST be +1-corpse, go +2-skinning +3-Fishing +*/ + +void Player::SendLootRelease( uint64 guid ) +{ + WorldPacket data( SMSG_LOOT_RELEASE_RESPONSE, (8+1) ); + data << uint64(guid) << uint8(1); + SendDirectMessage( &data ); +} + +void Player::SendLoot(uint64 guid, LootType loot_type) +{ + Loot *loot = 0; + PermissionTypes permission = ALL_PERMISSION; + + sLog.outDebug("Player::SendLoot"); + if (IS_GAMEOBJECT_GUID(guid)) + { + sLog.outDebug(" IS_GAMEOBJECT_GUID(guid)"); + GameObject *go = + ObjectAccessor::GetGameObject(*this, guid); + + // not check distance for GO in case owned GO (fishing bobber case, for example) + // And permit out of range GO with no owner in case fishing hole + if (!go || (loot_type != LOOT_FISHINGHOLE && (loot_type != LOOT_FISHING || go->GetOwnerGUID() != GetGUID()) && !go->IsWithinDistInMap(this,INTERACTION_DISTANCE))) + { + SendLootRelease(guid); + return; + } + + loot = &go->loot; + + if(go->getLootState() == GO_READY) + { + uint32 lootid = go->GetLootId(); + + if(lootid) + { + sLog.outDebug(" if(lootid)"); + loot->clear(); + loot->FillLoot(lootid, LootTemplates_Gameobject, this); + } + + if(loot_type == LOOT_FISHING) + go->getFishLoot(loot); + + go->SetLootState(GO_ACTIVATED); + } + } + else if (IS_ITEM_GUID(guid)) + { + Item *item = GetItemByGuid( guid ); + + if (!item) + { + SendLootRelease(guid); + return; + } + + if(loot_type == LOOT_DISENCHANTING) + { + loot = &item->loot; + + if(!item->m_lootGenerated) + { + item->m_lootGenerated = true; + loot->clear(); + loot->FillLoot(item->GetProto()->DisenchantID, LootTemplates_Disenchant, this); + } + } + else if(loot_type == LOOT_PROSPECTING) + { + loot = &item->loot; + + if(!item->m_lootGenerated) + { + item->m_lootGenerated = true; + loot->clear(); + loot->FillLoot(item->GetEntry(), LootTemplates_Prospecting, this); + } + } + else + { + loot = &item->loot; + + if(!item->m_lootGenerated) + { + item->m_lootGenerated = true; + loot->clear(); + loot->FillLoot(item->GetEntry(), LootTemplates_Item, this); + + loot->generateMoneyLoot(item->GetProto()->MinMoneyLoot,item->GetProto()->MaxMoneyLoot); + } + } + } + else if (IS_CORPSE_GUID(guid)) // remove insignia + { + Corpse *bones = ObjectAccessor::GetCorpse(*this, guid); + + if (!bones || !((loot_type == LOOT_CORPSE) || (loot_type == LOOT_INSIGNIA)) || (bones->GetType() != CORPSE_BONES) ) + { + SendLootRelease(guid); + return; + } + + loot = &bones->loot; + + if (!bones->lootForBody) + { + bones->lootForBody = true; + uint32 pLevel = bones->loot.gold; + bones->loot.clear(); + // It may need a better formula + // Now it works like this: lvl10: ~6copper, lvl70: ~9silver + bones->loot.gold = (uint32)( urand(50, 150) * 0.016f * pow( ((float)pLevel)/5.76f, 2.5f) * sWorld.getRate(RATE_DROP_MONEY) ); + } + + if (bones->lootRecipient != this) + permission = NONE_PERMISSION; + } + else + { + Creature *creature = ObjectAccessor::GetCreature(*this, guid); + + // must be in range and creature must be alive for pickpocket and must be dead for another loot + if (!creature || creature->isAlive()!=(loot_type == LOOT_PICKPOCKETING) || !creature->IsWithinDistInMap(this,INTERACTION_DISTANCE)) + { + SendLootRelease(guid); + return; + } + + if(loot_type == LOOT_PICKPOCKETING && IsFriendlyTo(creature)) + { + SendLootRelease(guid); + return; + } + + loot = &creature->loot; + + if(loot_type == LOOT_PICKPOCKETING) + { + if ( !creature->lootForPickPocketed ) + { + creature->lootForPickPocketed = true; + loot->clear(); + + if (uint32 lootid = creature->GetCreatureInfo()->pickpocketLootId) + loot->FillLoot(lootid, LootTemplates_Pickpocketing, this); + + // Generate extra money for pick pocket loot + const uint32 a = urand(0, creature->getLevel()/2); + const uint32 b = urand(0, getLevel()/2); + loot->gold = uint32(10 * (a + b) * sWorld.getRate(RATE_DROP_MONEY)); + } + } + else + { + // the player whose group may loot the corpse + Player *recipient = creature->GetLootRecipient(); + if (!recipient) + { + creature->SetLootRecipient(this); + recipient = this; + } + + if (creature->lootForPickPocketed) + { + creature->lootForPickPocketed = false; + loot->clear(); + } + + if(!creature->lootForBody) + { + creature->lootForBody = true; + loot->clear(); + + if (uint32 lootid = creature->GetCreatureInfo()->lootid) + loot->FillLoot(lootid, LootTemplates_Creature, recipient); + + loot->generateMoneyLoot(creature->GetCreatureInfo()->mingold,creature->GetCreatureInfo()->maxgold); + + if(Group* group = recipient->GetGroup()) + { + group->UpdateLooterGuid(creature,true); + + switch (group->GetLootMethod()) + { + case GROUP_LOOT: + // GroupLoot delete items over threshold (threshold even not implemented), and roll them. Items with qualityGroupLoot(recipient->GetGUID(), loot, creature); + break; + case NEED_BEFORE_GREED: + group->NeedBeforeGreed(recipient->GetGUID(), loot, creature); + break; + case MASTER_LOOT: + group->MasterLoot(recipient->GetGUID(), loot, creature); + break; + default: + break; + } + } + } + + // possible only if creature->lootForBody && loot->empty() at spell cast check + if (loot_type == LOOT_SKINNING) + { + loot->clear(); + loot->FillLoot(creature->GetCreatureInfo()->SkinLootId, LootTemplates_Skinning, this); + } + // set group rights only for loot_type != LOOT_SKINNING + else + { + if(Group* group = GetGroup()) + { + if( group == recipient->GetGroup() ) + { + if(group->GetLootMethod() == FREE_FOR_ALL) + permission = ALL_PERMISSION; + else if(group->GetLooterGuid() == GetGUID()) + { + if(group->GetLootMethod() == MASTER_LOOT) + permission = MASTER_PERMISSION; + else + permission = ALL_PERMISSION; + } + else + permission = GROUP_PERMISSION; + } + else + permission = NONE_PERMISSION; + } + else if(recipient == this) + permission = ALL_PERMISSION; + else + permission = NONE_PERMISSION; + } + } + } + + SetLootGUID(guid); + + QuestItemList *q_list = 0; + if (permission != NONE_PERMISSION) + { + QuestItemMap const& lootPlayerQuestItems = loot->GetPlayerQuestItems(); + QuestItemMap::const_iterator itr = lootPlayerQuestItems.find(GetGUIDLow()); + if (itr == lootPlayerQuestItems.end()) + q_list = loot->FillQuestLoot(this); + else + q_list = itr->second; + } + + QuestItemList *ffa_list = 0; + if (permission != NONE_PERMISSION) + { + QuestItemMap const& lootPlayerFFAItems = loot->GetPlayerFFAItems(); + QuestItemMap::const_iterator itr = lootPlayerFFAItems.find(GetGUIDLow()); + if (itr == lootPlayerFFAItems.end()) + ffa_list = loot->FillFFALoot(this); + else + ffa_list = itr->second; + } + + QuestItemList *conditional_list = 0; + if (permission != NONE_PERMISSION) + { + QuestItemMap const& lootPlayerNonQuestNonFFAConditionalItems = loot->GetPlayerNonQuestNonFFAConditionalItems(); + QuestItemMap::const_iterator itr = lootPlayerNonQuestNonFFAConditionalItems.find(GetGUIDLow()); + if (itr == lootPlayerNonQuestNonFFAConditionalItems.end()) + conditional_list = loot->FillNonQuestNonFFAConditionalLoot(this); + else + conditional_list = itr->second; + } + + // LOOT_PICKPOCKETING, LOOT_PROSPECTING, LOOT_DISENCHANTING and LOOT_INSIGNIA unsupported by client, sending LOOT_SKINNING instead + if(loot_type == LOOT_PICKPOCKETING || loot_type == LOOT_DISENCHANTING || loot_type == LOOT_PROSPECTING || loot_type == LOOT_INSIGNIA) + loot_type = LOOT_SKINNING; + + if(loot_type == LOOT_FISHINGHOLE) + loot_type = LOOT_FISHING; + + WorldPacket data(SMSG_LOOT_RESPONSE, (9+50)); // we guess size + + data << uint64(guid); + data << uint8(loot_type); + data << LootView(*loot, q_list, ffa_list, conditional_list, this, permission); + + SendDirectMessage(&data); + + // add 'this' player as one of the players that are looting 'loot' + if (permission != NONE_PERMISSION) + loot->AddLooter(GetGUID()); + + if ( loot_type == LOOT_CORPSE && !IS_ITEM_GUID(guid) ) + SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_LOOTING); +} + +void Player::SendNotifyLootMoneyRemoved() +{ + WorldPacket data(SMSG_LOOT_CLEAR_MONEY, 0); + GetSession()->SendPacket( &data ); +} + +void Player::SendNotifyLootItemRemoved(uint8 lootSlot) +{ + WorldPacket data(SMSG_LOOT_REMOVED, 1); + data << uint8(lootSlot); + GetSession()->SendPacket( &data ); +} + +void Player::SendUpdateWorldState(uint32 Field, uint32 Value) +{ + WorldPacket data(SMSG_UPDATE_WORLD_STATE, 8); + data << Field; + data << Value; + GetSession()->SendPacket(&data); +} + +void Player::SendInitWorldStates() +{ + // data depends on zoneid/mapid... + BattleGround* bg = GetBattleGround(); + uint16 NumberOfFields = 0; + uint32 mapid = GetMapId(); + uint32 zoneid = GetZoneId(); + uint32 areaid = GetAreaId(); + sLog.outDebug("Sending SMSG_INIT_WORLD_STATES to Map:%u, Zone: %u", mapid, zoneid); + // may be exist better way to do this... + switch(zoneid) + { + case 0: + case 1: + case 4: + case 8: + case 10: + case 11: + case 12: + case 36: + case 38: + case 40: + case 41: + case 51: + case 267: + case 1519: + case 1537: + case 2257: + case 2918: + NumberOfFields = 6; + break; + case 2597: + NumberOfFields = 81; + break; + case 3277: + NumberOfFields = 14; + break; + case 3358: + case 3820: + NumberOfFields = 38; + break; + case 3483: + NumberOfFields = 22; + break; + case 3519: + NumberOfFields = 36; + break; + case 3521: + NumberOfFields = 35; + break; + case 3698: + case 3702: + case 3968: + NumberOfFields = 9; + break; + case 3703: + NumberOfFields = 9; + break; + default: + NumberOfFields = 10; + break; + } + + WorldPacket data(SMSG_INIT_WORLD_STATES, (4+4+4+2+(NumberOfFields*8))); + data << uint32(mapid); // mapid + data << uint32(zoneid); // zone id + data << uint32(areaid); // area id, new 2.1.0 + data << uint16(NumberOfFields); // count of uint64 blocks + data << uint32(0x8d8) << uint32(0x0); // 1 + data << uint32(0x8d7) << uint32(0x0); // 2 + data << uint32(0x8d6) << uint32(0x0); // 3 + data << uint32(0x8d5) << uint32(0x0); // 4 + data << uint32(0x8d4) << uint32(0x0); // 5 + data << uint32(0x8d3) << uint32(0x0); // 6 + if(mapid == 530) // Outland + { + data << uint32(0x9bf) << uint32(0x0); // 7 + data << uint32(0x9bd) << uint32(0xF); // 8 + data << uint32(0x9bb) << uint32(0xF); // 9 + } + switch(zoneid) + { + case 1: + case 11: + case 12: + case 38: + case 40: + case 51: + case 1519: + case 1537: + case 2257: + break; + case 2597: // AV + data << uint32(0x7ae) << uint32(0x1); // 7 + data << uint32(0x532) << uint32(0x1); // 8 + data << uint32(0x531) << uint32(0x0); // 9 + data << uint32(0x52e) << uint32(0x0); // 10 + data << uint32(0x571) << uint32(0x0); // 11 + data << uint32(0x570) << uint32(0x0); // 12 + data << uint32(0x567) << uint32(0x1); // 13 + data << uint32(0x566) << uint32(0x1); // 14 + data << uint32(0x550) << uint32(0x1); // 15 + data << uint32(0x544) << uint32(0x0); // 16 + data << uint32(0x536) << uint32(0x0); // 17 + data << uint32(0x535) << uint32(0x1); // 18 + data << uint32(0x518) << uint32(0x0); // 19 + data << uint32(0x517) << uint32(0x0); // 20 + data << uint32(0x574) << uint32(0x0); // 21 + data << uint32(0x573) << uint32(0x0); // 22 + data << uint32(0x572) << uint32(0x0); // 23 + data << uint32(0x56f) << uint32(0x0); // 24 + data << uint32(0x56e) << uint32(0x0); // 25 + data << uint32(0x56d) << uint32(0x0); // 26 + data << uint32(0x56c) << uint32(0x0); // 27 + data << uint32(0x56b) << uint32(0x0); // 28 + data << uint32(0x56a) << uint32(0x1); // 29 + data << uint32(0x569) << uint32(0x1); // 30 + data << uint32(0x568) << uint32(0x1); // 13 + data << uint32(0x565) << uint32(0x0); // 32 + data << uint32(0x564) << uint32(0x0); // 33 + data << uint32(0x563) << uint32(0x0); // 34 + data << uint32(0x562) << uint32(0x0); // 35 + data << uint32(0x561) << uint32(0x0); // 36 + data << uint32(0x560) << uint32(0x0); // 37 + data << uint32(0x55f) << uint32(0x0); // 38 + data << uint32(0x55e) << uint32(0x0); // 39 + data << uint32(0x55d) << uint32(0x0); // 40 + data << uint32(0x3c6) << uint32(0x4); // 41 + data << uint32(0x3c4) << uint32(0x6); // 42 + data << uint32(0x3c2) << uint32(0x4); // 43 + data << uint32(0x516) << uint32(0x1); // 44 + data << uint32(0x515) << uint32(0x0); // 45 + data << uint32(0x3b6) << uint32(0x6); // 46 + data << uint32(0x55c) << uint32(0x0); // 47 + data << uint32(0x55b) << uint32(0x0); // 48 + data << uint32(0x55a) << uint32(0x0); // 49 + data << uint32(0x559) << uint32(0x0); // 50 + data << uint32(0x558) << uint32(0x0); // 51 + data << uint32(0x557) << uint32(0x0); // 52 + data << uint32(0x556) << uint32(0x0); // 53 + data << uint32(0x555) << uint32(0x0); // 54 + data << uint32(0x554) << uint32(0x1); // 55 + data << uint32(0x553) << uint32(0x1); // 56 + data << uint32(0x552) << uint32(0x1); // 57 + data << uint32(0x551) << uint32(0x1); // 58 + data << uint32(0x54f) << uint32(0x0); // 59 + data << uint32(0x54e) << uint32(0x0); // 60 + data << uint32(0x54d) << uint32(0x1); // 61 + data << uint32(0x54c) << uint32(0x0); // 62 + data << uint32(0x54b) << uint32(0x0); // 63 + data << uint32(0x545) << uint32(0x0); // 64 + data << uint32(0x543) << uint32(0x1); // 65 + data << uint32(0x542) << uint32(0x0); // 66 + data << uint32(0x540) << uint32(0x0); // 67 + data << uint32(0x53f) << uint32(0x0); // 68 + data << uint32(0x53e) << uint32(0x0); // 69 + data << uint32(0x53d) << uint32(0x0); // 70 + data << uint32(0x53c) << uint32(0x0); // 71 + data << uint32(0x53b) << uint32(0x0); // 72 + data << uint32(0x53a) << uint32(0x1); // 73 + data << uint32(0x539) << uint32(0x0); // 74 + data << uint32(0x538) << uint32(0x0); // 75 + data << uint32(0x537) << uint32(0x0); // 76 + data << uint32(0x534) << uint32(0x0); // 77 + data << uint32(0x533) << uint32(0x0); // 78 + data << uint32(0x530) << uint32(0x0); // 79 + data << uint32(0x52f) << uint32(0x0); // 80 + data << uint32(0x52d) << uint32(0x1); // 81 + break; + case 3277: // WS + if (bg && bg->GetTypeID() == BATTLEGROUND_WS) + bg->FillInitialWorldStates(data); + else + { + data << uint32(0x62d) << uint32(0x0); // 7 1581 alliance flag captures + data << uint32(0x62e) << uint32(0x0); // 8 1582 horde flag captures + data << uint32(0x609) << uint32(0x0); // 9 1545 unk, set to 1 on alliance flag pickup... + data << uint32(0x60a) << uint32(0x0); // 10 1546 unk, set to 1 on horde flag pickup, after drop it's -1 + data << uint32(0x60b) << uint32(0x2); // 11 1547 unk + data << uint32(0x641) << uint32(0x3); // 12 1601 unk (max flag captures?) + data << uint32(0x922) << uint32(0x1); // 13 2338 horde (0 - hide, 1 - flag ok, 2 - flag picked up (flashing), 3 - flag picked up (not flashing) + data << uint32(0x923) << uint32(0x1); // 14 2339 alliance (0 - hide, 1 - flag ok, 2 - flag picked up (flashing), 3 - flag picked up (not flashing) + } + break; + case 3358: // AB + if (bg && bg->GetTypeID() == BATTLEGROUND_AB) + bg->FillInitialWorldStates(data); + else + { + data << uint32(0x6e7) << uint32(0x0); // 7 1767 stables alliance + data << uint32(0x6e8) << uint32(0x0); // 8 1768 stables horde + data << uint32(0x6e9) << uint32(0x0); // 9 1769 unk, ST? + data << uint32(0x6ea) << uint32(0x0); // 10 1770 stables (show/hide) + data << uint32(0x6ec) << uint32(0x0); // 11 1772 farm (0 - horde controlled, 1 - alliance controlled) + data << uint32(0x6ed) << uint32(0x0); // 12 1773 farm (show/hide) + data << uint32(0x6ee) << uint32(0x0); // 13 1774 farm color + data << uint32(0x6ef) << uint32(0x0); // 14 1775 gold mine color, may be FM? + data << uint32(0x6f0) << uint32(0x0); // 15 1776 alliance resources + data << uint32(0x6f1) << uint32(0x0); // 16 1777 horde resources + data << uint32(0x6f2) << uint32(0x0); // 17 1778 horde bases + data << uint32(0x6f3) << uint32(0x0); // 18 1779 alliance bases + data << uint32(0x6f4) << uint32(0x7d0); // 19 1780 max resources (2000) + data << uint32(0x6f6) << uint32(0x0); // 20 1782 blacksmith color + data << uint32(0x6f7) << uint32(0x0); // 21 1783 blacksmith (show/hide) + data << uint32(0x6f8) << uint32(0x0); // 22 1784 unk, bs? + data << uint32(0x6f9) << uint32(0x0); // 23 1785 unk, bs? + data << uint32(0x6fb) << uint32(0x0); // 24 1787 gold mine (0 - horde contr, 1 - alliance contr) + data << uint32(0x6fc) << uint32(0x0); // 25 1788 gold mine (0 - conflict, 1 - horde) + data << uint32(0x6fd) << uint32(0x0); // 26 1789 gold mine (1 - show/0 - hide) + data << uint32(0x6fe) << uint32(0x0); // 27 1790 gold mine color + data << uint32(0x700) << uint32(0x0); // 28 1792 gold mine color, wtf?, may be LM? + data << uint32(0x701) << uint32(0x0); // 29 1793 lumber mill color (0 - conflict, 1 - horde contr) + data << uint32(0x702) << uint32(0x0); // 30 1794 lumber mill (show/hide) + data << uint32(0x703) << uint32(0x0); // 31 1795 lumber mill color color + data << uint32(0x732) << uint32(0x1); // 32 1842 stables (1 - uncontrolled) + data << uint32(0x733) << uint32(0x1); // 33 1843 gold mine (1 - uncontrolled) + data << uint32(0x734) << uint32(0x1); // 34 1844 lumber mill (1 - uncontrolled) + data << uint32(0x735) << uint32(0x1); // 35 1845 farm (1 - uncontrolled) + data << uint32(0x736) << uint32(0x1); // 36 1846 blacksmith (1 - uncontrolled) + data << uint32(0x745) << uint32(0x2); // 37 1861 unk + data << uint32(0x7a3) << uint32(0x708); // 38 1955 warning limit (1800) + } + break; + case 3820: // EY + if (bg && bg->GetTypeID() == BATTLEGROUND_EY) + bg->FillInitialWorldStates(data); + else + { + data << uint32(0xac1) << uint32(0x0); // 7 2753 Horde Bases + data << uint32(0xac0) << uint32(0x0); // 8 2752 Alliance Bases + data << uint32(0xab6) << uint32(0x0); // 9 2742 Mage Tower - Horde conflict + data << uint32(0xab5) << uint32(0x0); // 10 2741 Mage Tower - Alliance conflict + data << uint32(0xab4) << uint32(0x0); // 11 2740 Fel Reaver - Horde conflict + data << uint32(0xab3) << uint32(0x0); // 12 2739 Fel Reaver - Alliance conflict + data << uint32(0xab2) << uint32(0x0); // 13 2738 Draenei - Alliance conflict + data << uint32(0xab1) << uint32(0x0); // 14 2737 Draenei - Horde conflict + data << uint32(0xab0) << uint32(0x0); // 15 2736 unk // 0 at start + data << uint32(0xaaf) << uint32(0x0); // 16 2735 unk // 0 at start + data << uint32(0xaad) << uint32(0x0); // 17 2733 Draenei - Horde control + data << uint32(0xaac) << uint32(0x0); // 18 2732 Draenei - Alliance control + data << uint32(0xaab) << uint32(0x1); // 19 2731 Draenei uncontrolled (1 - yes, 0 - no) + data << uint32(0xaaa) << uint32(0x0); // 20 2730 Mage Tower - Alliance control + data << uint32(0xaa9) << uint32(0x0); // 21 2729 Mage Tower - Horde control + data << uint32(0xaa8) << uint32(0x1); // 22 2728 Mage Tower uncontrolled (1 - yes, 0 - no) + data << uint32(0xaa7) << uint32(0x0); // 23 2727 Fel Reaver - Horde control + data << uint32(0xaa6) << uint32(0x0); // 24 2726 Fel Reaver - Alliance control + data << uint32(0xaa5) << uint32(0x1); // 25 2725 Fel Reaver uncontroled (1 - yes, 0 - no) + data << uint32(0xaa4) << uint32(0x0); // 26 2724 Boold Elf - Horde control + data << uint32(0xaa3) << uint32(0x0); // 27 2723 Boold Elf - Alliance control + data << uint32(0xaa2) << uint32(0x1); // 28 2722 Boold Elf uncontrolled (1 - yes, 0 - no) + data << uint32(0xac5) << uint32(0x1); // 29 2757 Flag (1 - show, 0 - hide) - doesn't work exactly this way! + data << uint32(0xad2) << uint32(0x1); // 30 2770 Horde top-stats (1 - show, 0 - hide) // 02 -> horde picked up the flag + data << uint32(0xad1) << uint32(0x1); // 31 2769 Alliance top-stats (1 - show, 0 - hide) // 02 -> alliance picked up the flag + data << uint32(0xabe) << uint32(0x0); // 32 2750 Horde resources + data << uint32(0xabd) << uint32(0x0); // 33 2749 Alliance resources + data << uint32(0xa05) << uint32(0x8e); // 34 2565 unk, constant? + data << uint32(0xaa0) << uint32(0x0); // 35 2720 Capturing progress-bar (100 -> empty (only grey), 0 -> blue|red (no grey), default 0) + data << uint32(0xa9f) << uint32(0x0); // 36 2719 Capturing progress-bar (0 - left, 100 - right) + data << uint32(0xa9e) << uint32(0x0); // 37 2718 Capturing progress-bar (1 - show, 0 - hide) + data << uint32(0xc0d) << uint32(0x17b); // 38 3085 unk + // and some more ... unknown + } + break; + case 3483: // Hellfire Peninsula + data << uint32(0x9ba) << uint32(0x1); // 10 + data << uint32(0x9b9) << uint32(0x1); // 11 + data << uint32(0x9b5) << uint32(0x0); // 12 + data << uint32(0x9b4) << uint32(0x1); // 13 + data << uint32(0x9b3) << uint32(0x0); // 14 + data << uint32(0x9b2) << uint32(0x0); // 15 + data << uint32(0x9b1) << uint32(0x1); // 16 + data << uint32(0x9b0) << uint32(0x0); // 17 + data << uint32(0x9ae) << uint32(0x0); // 18 horde pvp objectives captured + data << uint32(0x9ac) << uint32(0x0); // 19 + data << uint32(0x9a8) << uint32(0x0); // 20 + data << uint32(0x9a7) << uint32(0x0); // 21 + data << uint32(0x9a6) << uint32(0x1); // 22 + break; + case 3519: // Terokkar Forest + data << uint32(0xa41) << uint32(0x0); // 10 + data << uint32(0xa40) << uint32(0x14); // 11 + data << uint32(0xa3f) << uint32(0x0); // 12 + data << uint32(0xa3e) << uint32(0x0); // 13 + data << uint32(0xa3d) << uint32(0x5); // 14 + data << uint32(0xa3c) << uint32(0x0); // 15 + data << uint32(0xa87) << uint32(0x0); // 16 + data << uint32(0xa86) << uint32(0x0); // 17 + data << uint32(0xa85) << uint32(0x0); // 18 + data << uint32(0xa84) << uint32(0x0); // 19 + data << uint32(0xa83) << uint32(0x0); // 20 + data << uint32(0xa82) << uint32(0x0); // 21 + data << uint32(0xa81) << uint32(0x0); // 22 + data << uint32(0xa80) << uint32(0x0); // 23 + data << uint32(0xa7e) << uint32(0x0); // 24 + data << uint32(0xa7d) << uint32(0x0); // 25 + data << uint32(0xa7c) << uint32(0x0); // 26 + data << uint32(0xa7b) << uint32(0x0); // 27 + data << uint32(0xa7a) << uint32(0x0); // 28 + data << uint32(0xa79) << uint32(0x0); // 29 + data << uint32(0x9d0) << uint32(0x5); // 30 + data << uint32(0x9ce) << uint32(0x0); // 31 + data << uint32(0x9cd) << uint32(0x0); // 32 + data << uint32(0x9cc) << uint32(0x0); // 33 + data << uint32(0xa88) << uint32(0x0); // 34 + data << uint32(0xad0) << uint32(0x0); // 35 + data << uint32(0xacf) << uint32(0x1); // 36 + break; + case 3521: // Zangarmarsh + data << uint32(0x9e1) << uint32(0x0); // 10 + data << uint32(0x9e0) << uint32(0x0); // 11 + data << uint32(0x9df) << uint32(0x0); // 12 + data << uint32(0xa5d) << uint32(0x1); // 13 + data << uint32(0xa5c) << uint32(0x0); // 14 + data << uint32(0xa5b) << uint32(0x1); // 15 + data << uint32(0xa5a) << uint32(0x0); // 16 + data << uint32(0xa59) << uint32(0x1); // 17 + data << uint32(0xa58) << uint32(0x0); // 18 + data << uint32(0xa57) << uint32(0x0); // 19 + data << uint32(0xa56) << uint32(0x0); // 20 + data << uint32(0xa55) << uint32(0x1); // 21 + data << uint32(0xa54) << uint32(0x0); // 22 + data << uint32(0x9e7) << uint32(0x0); // 23 + data << uint32(0x9e6) << uint32(0x0); // 24 + data << uint32(0x9e5) << uint32(0x0); // 25 + data << uint32(0xa00) << uint32(0x0); // 26 + data << uint32(0x9ff) << uint32(0x1); // 27 + data << uint32(0x9fe) << uint32(0x0); // 28 + data << uint32(0x9fd) << uint32(0x0); // 29 + data << uint32(0x9fc) << uint32(0x1); // 30 + data << uint32(0x9fb) << uint32(0x0); // 31 + data << uint32(0xa62) << uint32(0x0); // 32 + data << uint32(0xa61) << uint32(0x1); // 33 + data << uint32(0xa60) << uint32(0x1); // 34 + data << uint32(0xa5f) << uint32(0x0); // 35 + break; + case 3698: // Nagrand Arena + data << uint32(0xa0f) << uint32(0x0); // 7 + data << uint32(0xa10) << uint32(0x0); // 8 + data << uint32(0xa11) << uint32(0x0); // 9 + break; + case 3702: // Blade's Edge Arena + data << uint32(0x9f0) << uint32(0x0); // 7 + data << uint32(0x9f1) << uint32(0x0); // 8 + data << uint32(0x9f3) << uint32(0x0); // 9 + break; + case 3968: // Ruins of Lordaeron + data << uint32(0xbb8) << uint32(0x0); // 7 + data << uint32(0xbb9) << uint32(0x0); // 8 + data << uint32(0xbba) << uint32(0x0); // 9 + break; + case 3703: // Shattrath City + break; + default: + data << uint32(0x914) << uint32(0x0); // 7 + data << uint32(0x913) << uint32(0x0); // 8 + data << uint32(0x912) << uint32(0x0); // 9 + data << uint32(0x915) << uint32(0x0); // 10 + break; + } + GetSession()->SendPacket(&data); +} + +uint32 Player::GetXPRestBonus(uint32 xp) +{ + uint32 rested_bonus = (uint32)GetRestBonus(); // xp for each rested bonus + + if(rested_bonus > xp) // max rested_bonus == xp or (r+x) = 200% xp + rested_bonus = xp; + + SetRestBonus( GetRestBonus() - rested_bonus); + + sLog.outDetail("Player gain %u xp (+ %u Rested Bonus). Rested points=%f",xp+rested_bonus,rested_bonus,GetRestBonus()); + return rested_bonus; +} + +void Player::SetBindPoint(uint64 guid) +{ + WorldPacket data(SMSG_BINDER_CONFIRM, 8); + data << uint64(guid); + GetSession()->SendPacket( &data ); +} + +void Player::SendTalentWipeConfirm(uint64 guid) +{ + WorldPacket data(MSG_TALENT_WIPE_CONFIRM, (8+4)); + data << uint64(guid); + data << uint32(resetTalentsCost()); + GetSession()->SendPacket( &data ); +} + +void Player::SendPetSkillWipeConfirm() +{ + Pet* pet = GetPet(); + if(!pet) + return; + WorldPacket data(SMSG_PET_UNLEARN_CONFIRM, (8+4)); + data << pet->GetGUID(); + data << uint32(pet->resetTalentsCost()); + GetSession()->SendPacket( &data ); +} + +/*********************************************************/ +/*** STORAGE SYSTEM ***/ +/*********************************************************/ + +void Player::SetVirtualItemSlot( uint8 i, Item* item) +{ + assert(i < 3); + if(i < 2 && item) + { + if(!item->GetEnchantmentId(TEMP_ENCHANTMENT_SLOT)) + return; + uint32 charges = item->GetEnchantmentCharges(TEMP_ENCHANTMENT_SLOT); + if(charges == 0) + return; + if(charges > 1) + item->SetEnchantmentCharges(TEMP_ENCHANTMENT_SLOT,charges-1); + else if(charges <= 1) + { + ApplyEnchantment(item,TEMP_ENCHANTMENT_SLOT,false); + item->ClearEnchantment(TEMP_ENCHANTMENT_SLOT); + } + } +} + +void Player::SetSheath( uint32 sheathed ) +{ + switch (sheathed) + { + case SHEATH_STATE_UNARMED: // no prepared weapon + SetVirtualItemSlot(0,NULL); + SetVirtualItemSlot(1,NULL); + SetVirtualItemSlot(2,NULL); + break; + case SHEATH_STATE_MELEE: // prepared melee weapon + { + SetVirtualItemSlot(0,GetWeaponForAttack(BASE_ATTACK,true)); + SetVirtualItemSlot(1,GetWeaponForAttack(OFF_ATTACK,true)); + SetVirtualItemSlot(2,NULL); + }; break; + case SHEATH_STATE_RANGED: // prepared ranged weapon + SetVirtualItemSlot(0,NULL); + SetVirtualItemSlot(1,NULL); + SetVirtualItemSlot(2,GetWeaponForAttack(RANGED_ATTACK,true)); + break; + default: + SetVirtualItemSlot(0,NULL); + SetVirtualItemSlot(1,NULL); + SetVirtualItemSlot(2,NULL); + break; + } + SetByteValue(UNIT_FIELD_BYTES_2, 0, sheathed); // this must visualize Sheath changing for other players... +} + +uint8 Player::FindEquipSlot( ItemPrototype const* proto, uint32 slot, bool swap ) const +{ + uint8 pClass = getClass(); + + uint8 slots[4]; + slots[0] = NULL_SLOT; + slots[1] = NULL_SLOT; + slots[2] = NULL_SLOT; + slots[3] = NULL_SLOT; + switch( proto->InventoryType ) + { + case INVTYPE_HEAD: + slots[0] = EQUIPMENT_SLOT_HEAD; + break; + case INVTYPE_NECK: + slots[0] = EQUIPMENT_SLOT_NECK; + break; + case INVTYPE_SHOULDERS: + slots[0] = EQUIPMENT_SLOT_SHOULDERS; + break; + case INVTYPE_BODY: + slots[0] = EQUIPMENT_SLOT_BODY; + break; + case INVTYPE_CHEST: + slots[0] = EQUIPMENT_SLOT_CHEST; + break; + case INVTYPE_ROBE: + slots[0] = EQUIPMENT_SLOT_CHEST; + break; + case INVTYPE_WAIST: + slots[0] = EQUIPMENT_SLOT_WAIST; + break; + case INVTYPE_LEGS: + slots[0] = EQUIPMENT_SLOT_LEGS; + break; + case INVTYPE_FEET: + slots[0] = EQUIPMENT_SLOT_FEET; + break; + case INVTYPE_WRISTS: + slots[0] = EQUIPMENT_SLOT_WRISTS; + break; + case INVTYPE_HANDS: + slots[0] = EQUIPMENT_SLOT_HANDS; + break; + case INVTYPE_FINGER: + slots[0] = EQUIPMENT_SLOT_FINGER1; + slots[1] = EQUIPMENT_SLOT_FINGER2; + break; + case INVTYPE_TRINKET: + slots[0] = EQUIPMENT_SLOT_TRINKET1; + slots[1] = EQUIPMENT_SLOT_TRINKET2; + break; + case INVTYPE_CLOAK: + slots[0] = EQUIPMENT_SLOT_BACK; + break; + case INVTYPE_WEAPON: + { + slots[0] = EQUIPMENT_SLOT_MAINHAND; + + // suggest offhand slot only if know dual wielding + // (this will be replace mainhand weapon at auto equip instead unwonted "you don't known dual wielding" ... + if(CanDualWield()) + slots[1] = EQUIPMENT_SLOT_OFFHAND; + };break; + case INVTYPE_SHIELD: + slots[0] = EQUIPMENT_SLOT_OFFHAND; + break; + case INVTYPE_RANGED: + slots[0] = EQUIPMENT_SLOT_RANGED; + break; + case INVTYPE_2HWEAPON: + slots[0] = EQUIPMENT_SLOT_MAINHAND; + break; + case INVTYPE_TABARD: + slots[0] = EQUIPMENT_SLOT_TABARD; + break; + case INVTYPE_WEAPONMAINHAND: + slots[0] = EQUIPMENT_SLOT_MAINHAND; + break; + case INVTYPE_WEAPONOFFHAND: + slots[0] = EQUIPMENT_SLOT_OFFHAND; + break; + case INVTYPE_HOLDABLE: + slots[0] = EQUIPMENT_SLOT_OFFHAND; + break; + case INVTYPE_THROWN: + slots[0] = EQUIPMENT_SLOT_RANGED; + break; + case INVTYPE_RANGEDRIGHT: + slots[0] = EQUIPMENT_SLOT_RANGED; + break; + case INVTYPE_BAG: + slots[0] = INVENTORY_SLOT_BAG_1; + slots[1] = INVENTORY_SLOT_BAG_2; + slots[2] = INVENTORY_SLOT_BAG_3; + slots[3] = INVENTORY_SLOT_BAG_4; + break; + case INVTYPE_RELIC: + { + switch(proto->SubClass) + { + case ITEM_SUBCLASS_ARMOR_LIBRAM: + if (pClass == CLASS_PALADIN) + slots[0] = EQUIPMENT_SLOT_RANGED; + break; + case ITEM_SUBCLASS_ARMOR_IDOL: + if (pClass == CLASS_DRUID) + slots[0] = EQUIPMENT_SLOT_RANGED; + break; + case ITEM_SUBCLASS_ARMOR_TOTEM: + if (pClass == CLASS_SHAMAN) + slots[0] = EQUIPMENT_SLOT_RANGED; + break; + case ITEM_SUBCLASS_ARMOR_MISC: + if (pClass == CLASS_WARLOCK) + slots[0] = EQUIPMENT_SLOT_RANGED; + break; + } + break; + } + default : + return NULL_SLOT; + } + + if( slot != NULL_SLOT ) + { + if( swap || !GetItemByPos( INVENTORY_SLOT_BAG_0, slot ) ) + { + for (int i = 0; i < 4; i++) + { + if ( slots[i] == slot ) + return slot; + } + } + } + else + { + // search free slot at first + for (int i = 0; i < 4; i++) + { + if ( slots[i] != NULL_SLOT && !GetItemByPos( INVENTORY_SLOT_BAG_0, slots[i] ) ) + { + // in case 2hand equipped weapon offhand slot empty but not free + if(slots[i]==EQUIPMENT_SLOT_OFFHAND) + { + Item* mainItem = GetItemByPos( INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_MAINHAND ); + if(!mainItem || mainItem->GetProto()->InventoryType != INVTYPE_2HWEAPON) + return slots[i]; + } + else + return slots[i]; + } + } + + // if not found free and can swap return first appropriate from used + for (int i = 0; i < 4; i++) + { + if ( slots[i] != NULL_SLOT && swap ) + return slots[i]; + } + } + + // no free position + return NULL_SLOT; +} + +uint8 Player::CanUnequipItems( uint32 item, uint32 count ) const +{ + Item *pItem; + uint32 tempcount = 0; + + uint8 res = EQUIP_ERR_OK; + + for(int i = EQUIPMENT_SLOT_START; i < INVENTORY_SLOT_BAG_END; i++) + { + pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i ); + if( pItem && pItem->GetEntry() == item ) + { + uint8 ires = CanUnequipItem(INVENTORY_SLOT_BAG_0 << 8 | i, false); + if(ires==EQUIP_ERR_OK) + { + tempcount += pItem->GetCount(); + if( tempcount >= count ) + return EQUIP_ERR_OK; + } + else + res = ires; + } + } + for(int i = INVENTORY_SLOT_ITEM_START; i < INVENTORY_SLOT_ITEM_END; i++) + { + pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i ); + if( pItem && pItem->GetEntry() == item ) + { + tempcount += pItem->GetCount(); + if( tempcount >= count ) + return EQUIP_ERR_OK; + } + } + for(int i = KEYRING_SLOT_START; i < KEYRING_SLOT_END; i++) + { + pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i ); + if( pItem && pItem->GetEntry() == item ) + { + tempcount += pItem->GetCount(); + if( tempcount >= count ) + return EQUIP_ERR_OK; + } + } + Bag *pBag; + ItemPrototype const *pBagProto; + for(int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; i++) + { + pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i ); + if( pBag ) + { + pBagProto = pBag->GetProto(); + if( pBagProto ) + { + for(uint32 j = 0; j < pBagProto->ContainerSlots; j++) + { + pItem = GetItemByPos( i, j ); + if( pItem && pItem->GetEntry() == item ) + { + tempcount += pItem->GetCount(); + if( tempcount >= count ) + return EQUIP_ERR_OK; + } + } + } + } + } + + // not found req. item count and have unequippable items + return res; +} + +uint32 Player::GetItemCount( uint32 item, bool inBankAlso, Item* skipItem ) const +{ + uint32 count = 0; + for(int i = EQUIPMENT_SLOT_START; i < INVENTORY_SLOT_ITEM_END; i++) + { + Item *pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i ); + if( pItem && pItem != skipItem && pItem->GetEntry() == item ) + count += pItem->GetCount(); + } + for(int i = KEYRING_SLOT_START; i < KEYRING_SLOT_END; i++) + { + Item *pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i ); + if( pItem && pItem != skipItem && pItem->GetEntry() == item ) + count += pItem->GetCount(); + } + for(int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; i++) + { + Bag* pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i ); + if( pBag ) + count += pBag->GetItemCount(item,skipItem); + } + + if(skipItem && skipItem->GetProto()->GemProperties) + { + for(int i = EQUIPMENT_SLOT_START; i < INVENTORY_SLOT_ITEM_END; i++) + { + Item *pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i ); + if( pItem && pItem != skipItem && pItem->GetProto()->Socket[0].Color ) + count += pItem->GetGemCountWithID(item); + } + } + + if(inBankAlso) + { + for(int i = BANK_SLOT_ITEM_START; i < BANK_SLOT_ITEM_END; i++) + { + Item* pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i ); + if( pItem && pItem != skipItem && pItem->GetEntry() == item ) + count += pItem->GetCount(); + } + for(int i = BANK_SLOT_BAG_START; i < BANK_SLOT_BAG_END; i++) + { + Bag* pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i ); + if( pBag ) + count += pBag->GetItemCount(item,skipItem); + } + + if(skipItem && skipItem->GetProto()->GemProperties) + { + for(int i = BANK_SLOT_ITEM_START; i < BANK_SLOT_ITEM_END; i++) + { + Item* pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i ); + if( pItem && pItem != skipItem && pItem->GetProto()->Socket[0].Color ) + count += pItem->GetGemCountWithID(item); + } + } + } + + return count; +} + +Item* Player::GetItemByGuid( uint64 guid ) const +{ + for(int i = EQUIPMENT_SLOT_START; i < INVENTORY_SLOT_ITEM_END; i++) + { + Item *pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i ); + if( pItem && pItem->GetGUID() == guid ) + return pItem; + } + for(int i = KEYRING_SLOT_START; i < KEYRING_SLOT_END; i++) + { + Item *pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i ); + if( pItem && pItem->GetGUID() == guid ) + return pItem; + } + + for(int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; i++) + { + Bag *pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i ); + if( pBag ) + { + ItemPrototype const *pBagProto = pBag->GetProto(); + if( pBagProto ) + { + for(uint32 j = 0; j < pBagProto->ContainerSlots; j++) + { + Item* pItem = pBag->GetItemByPos( j ); + if( pItem && pItem->GetGUID() == guid ) + return pItem; + } + } + } + } + for(int i = BANK_SLOT_BAG_START; i < BANK_SLOT_BAG_END; i++) + { + Bag *pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i ); + if( pBag ) + { + ItemPrototype const *pBagProto = pBag->GetProto(); + if( pBagProto ) + { + for(uint32 j = 0; j < pBagProto->ContainerSlots; j++) + { + Item* pItem = pBag->GetItemByPos( j ); + if( pItem && pItem->GetGUID() == guid ) + return pItem; + } + } + } + } + + return NULL; +} + +Item* Player::GetItemByPos( uint16 pos ) const +{ + uint8 bag = pos >> 8; + uint8 slot = pos & 255; + return GetItemByPos( bag, slot ); +} + +Item* Player::GetItemByPos( uint8 bag, uint8 slot ) const +{ + if( bag == INVENTORY_SLOT_BAG_0 && ( slot < BANK_SLOT_BAG_END || slot >= KEYRING_SLOT_START && slot < KEYRING_SLOT_END ) ) + return m_items[slot]; + else if(bag >= INVENTORY_SLOT_BAG_START && bag < INVENTORY_SLOT_BAG_END + || bag >= BANK_SLOT_BAG_START && bag < BANK_SLOT_BAG_END ) + { + Bag *pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, bag ); + if ( pBag ) + return pBag->GetItemByPos(slot); + } + return NULL; +} + +Item* Player::GetWeaponForAttack(WeaponAttackType attackType, bool useable) const +{ + uint16 slot; + switch (attackType) + { + case BASE_ATTACK: slot = EQUIPMENT_SLOT_MAINHAND; break; + case OFF_ATTACK: slot = EQUIPMENT_SLOT_OFFHAND; break; + case RANGED_ATTACK: slot = EQUIPMENT_SLOT_RANGED; break; + default: return NULL; + } + + Item* item = GetItemByPos(INVENTORY_SLOT_BAG_0, slot); + if (!item || item->GetProto()->Class != ITEM_CLASS_WEAPON) + return NULL; + + if(!useable) + return item; + + if( item->IsBroken() || !IsUseEquipedWeapon(attackType==BASE_ATTACK) ) + return NULL; + + return item; +} + +Item* Player::GetShield(bool useable) const +{ + Item* item = GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND); + if (!item || item->GetProto()->Class != ITEM_CLASS_ARMOR) + return NULL; + + if(!useable) + return item; + + if( item->IsBroken()) + return NULL; + + return item; +} + +uint32 Player::GetAttackBySlot( uint8 slot ) +{ + switch(slot) + { + case EQUIPMENT_SLOT_MAINHAND: return BASE_ATTACK; + case EQUIPMENT_SLOT_OFFHAND: return OFF_ATTACK; + case EQUIPMENT_SLOT_RANGED: return RANGED_ATTACK; + default: return MAX_ATTACK; + } +} + +bool Player::HasBankBagSlot( uint8 slot ) const +{ + uint32 maxslot = GetByteValue(PLAYER_BYTES_2, 2) + BANK_SLOT_BAG_START; + if( slot < maxslot ) + return true; + return false; +} + +bool Player::IsInventoryPos( uint8 bag, uint8 slot ) +{ + if( bag == INVENTORY_SLOT_BAG_0 && slot == NULL_SLOT ) + return true; + if( bag == INVENTORY_SLOT_BAG_0 && ( slot >= INVENTORY_SLOT_ITEM_START && slot < INVENTORY_SLOT_ITEM_END ) ) + return true; + if( bag >= INVENTORY_SLOT_BAG_START && bag < INVENTORY_SLOT_BAG_END ) + return true; + if( bag == INVENTORY_SLOT_BAG_0 && ( slot >= KEYRING_SLOT_START && slot < KEYRING_SLOT_END ) ) + return true; + return false; +} + +bool Player::IsEquipmentPos( uint8 bag, uint8 slot ) +{ + if( bag == INVENTORY_SLOT_BAG_0 && ( slot < EQUIPMENT_SLOT_END ) ) + return true; + if( bag == INVENTORY_SLOT_BAG_0 && ( slot >= INVENTORY_SLOT_BAG_START && slot < INVENTORY_SLOT_BAG_END ) ) + return true; + return false; +} + +bool Player::IsBankPos( uint8 bag, uint8 slot ) +{ + if( bag == INVENTORY_SLOT_BAG_0 && ( slot >= BANK_SLOT_ITEM_START && slot < BANK_SLOT_ITEM_END ) ) + return true; + if( bag == INVENTORY_SLOT_BAG_0 && ( slot >= BANK_SLOT_BAG_START && slot < BANK_SLOT_BAG_END ) ) + return true; + if( bag >= BANK_SLOT_BAG_START && bag < BANK_SLOT_BAG_END ) + return true; + return false; +} + +bool Player::IsBagPos( uint16 pos ) +{ + uint8 bag = pos >> 8; + uint8 slot = pos & 255; + if( bag == INVENTORY_SLOT_BAG_0 && ( slot >= INVENTORY_SLOT_BAG_START && slot < INVENTORY_SLOT_BAG_END ) ) + return true; + if( bag == INVENTORY_SLOT_BAG_0 && ( slot >= BANK_SLOT_BAG_START && slot < BANK_SLOT_BAG_END ) ) + return true; + return false; +} + +bool Player::HasItemCount( uint32 item, uint32 count, bool inBankAlso ) const +{ + uint32 tempcount = 0; + for(int i = EQUIPMENT_SLOT_START; i < INVENTORY_SLOT_ITEM_END; i++) + { + Item *pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i ); + if( pItem && pItem->GetEntry() == item ) + { + tempcount += pItem->GetCount(); + if( tempcount >= count ) + return true; + } + } + for(int i = KEYRING_SLOT_START; i < KEYRING_SLOT_END; i++) + { + Item *pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i ); + if( pItem && pItem->GetEntry() == item ) + { + tempcount += pItem->GetCount(); + if( tempcount >= count ) + return true; + } + } + for(int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; i++) + { + if(Bag* pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i )) + { + if(ItemPrototype const *pBagProto = pBag->GetProto()) + { + for(uint32 j = 0; j < pBagProto->ContainerSlots; j++) + { + Item* pItem = GetItemByPos( i, j ); + if( pItem && pItem->GetEntry() == item ) + { + tempcount += pItem->GetCount(); + if( tempcount >= count ) + return true; + } + } + } + } + } + + if(inBankAlso) + { + for(int i = BANK_SLOT_ITEM_START; i < BANK_SLOT_ITEM_END; i++) + { + Item *pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i ); + if( pItem && pItem->GetEntry() == item ) + { + tempcount += pItem->GetCount(); + if( tempcount >= count ) + return true; + } + } + for(int i = BANK_SLOT_BAG_START; i < BANK_SLOT_BAG_END; i++) + { + if(Bag* pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i )) + { + if(ItemPrototype const *pBagProto = pBag->GetProto()) + { + for(uint32 j = 0; j < pBagProto->ContainerSlots; j++) + { + Item* pItem = GetItemByPos( i, j ); + if( pItem && pItem->GetEntry() == item ) + { + tempcount += pItem->GetCount(); + if( tempcount >= count ) + return true; + } + } + } + } + } + } + + return false; +} + +Item* Player::GetItemOrItemWithGemEquipped( uint32 item ) const +{ + Item *pItem; + for(int i = EQUIPMENT_SLOT_START; i < EQUIPMENT_SLOT_END; i++) + { + pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i ); + if( pItem && pItem->GetEntry() == item ) + return pItem; + } + + ItemPrototype const *pProto = objmgr.GetItemPrototype(item); + if (pProto && pProto->GemProperties) + { + for(int i = EQUIPMENT_SLOT_START; i < EQUIPMENT_SLOT_END; i++) + { + pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i ); + if( pItem && pItem->GetProto()->Socket[0].Color ) + { + if (pItem->GetGemCountWithID(item) > 0 ) + return pItem; + } + } + } + + return NULL; +} + +uint8 Player::_CanTakeMoreSimilarItems(uint32 entry, uint32 count, Item* pItem, uint32* no_space_count ) const +{ + ItemPrototype const *pProto = objmgr.GetItemPrototype(entry); + if( !pProto ) + { + if(no_space_count) + *no_space_count = count; + return EQUIP_ERR_CANT_CARRY_MORE_OF_THIS; + } + + // no maximum + if(pProto->MaxCount == 0) + return EQUIP_ERR_OK; + + uint32 curcount = GetItemCount(pProto->ItemId,true,pItem); + + if( curcount + count > pProto->MaxCount ) + { + if(no_space_count) + *no_space_count = count +curcount - pProto->MaxCount; + return EQUIP_ERR_CANT_CARRY_MORE_OF_THIS; + } + + return EQUIP_ERR_OK; +} + +bool Player::HasItemTotemCategory( uint32 TotemCategory ) const +{ + Item *pItem; + for(uint8 i = EQUIPMENT_SLOT_START; i < INVENTORY_SLOT_ITEM_END; ++i) + { + pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i ); + if( pItem && IsTotemCategoryCompatiableWith(pItem->GetProto()->TotemCategory,TotemCategory )) + return true; + } + for(uint8 i = KEYRING_SLOT_START; i < KEYRING_SLOT_END; ++i) + { + pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i ); + if( pItem && IsTotemCategoryCompatiableWith(pItem->GetProto()->TotemCategory,TotemCategory )) + return true; + } + Bag *pBag; + ItemPrototype const *pBagProto; + for(uint8 i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; ++i) + { + pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i ); + if( pBag ) + { + pBagProto = pBag->GetProto(); + if( pBagProto ) + { + for(uint32 j = 0; j < pBagProto->ContainerSlots; ++j) + { + pItem = GetItemByPos( i, j ); + if( pItem && IsTotemCategoryCompatiableWith(pItem->GetProto()->TotemCategory,TotemCategory )) + return true; + } + } + } + } + return false; +} + +uint8 Player::_CanStoreItem_InSpecificSlot( uint8 bag, uint8 slot, ItemPosCountVec &dest, ItemPrototype const *pProto, uint32& count, bool swap, Item* pSrcItem ) const +{ + Item* pItem2 = GetItemByPos( bag, slot ); + + // ignore move item (this slot will be empty at move) + if(pItem2==pSrcItem) + pItem2 = NULL; + + uint32 need_space; + + // empty specific slot - check item fit to slot + if( !pItem2 || swap ) + { + if( bag == INVENTORY_SLOT_BAG_0 ) + { + // keyring case + if(slot >= KEYRING_SLOT_START && slot < KEYRING_SLOT_START+GetMaxKeyringSize() && !(pProto->BagFamily & BAG_FAMILY_MASK_KEYS)) + return EQUIP_ERR_ITEM_DOESNT_GO_INTO_BAG; + + // prevent cheating + if(slot >= BUYBACK_SLOT_START && slot < BUYBACK_SLOT_END || slot >= PLAYER_SLOT_END) + return EQUIP_ERR_ITEM_DOESNT_GO_INTO_BAG; + } + else + { + Bag* pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, bag ); + if( !pBag ) + return EQUIP_ERR_ITEM_DOESNT_GO_INTO_BAG; + + ItemPrototype const* pBagProto = pBag->GetProto(); + if( !pBagProto ) + return EQUIP_ERR_ITEM_DOESNT_GO_INTO_BAG; + + if( !ItemCanGoIntoBag(pProto,pBagProto) ) + return EQUIP_ERR_ITEM_DOESNT_GO_INTO_BAG; + } + + // non empty stack with space + need_space = pProto->Stackable; + } + // non empty slot, check item type + else + { + // check item type + if(pItem2->GetEntry() != pProto->ItemId) + return EQUIP_ERR_ITEM_CANT_STACK; + + // check free space + if(pItem2->GetCount() >= pProto->Stackable) + return EQUIP_ERR_ITEM_CANT_STACK; + + need_space = pProto->Stackable - pItem2->GetCount(); + } + + if(need_space > count) + need_space = count; + + ItemPosCount newPosition = ItemPosCount((bag << 8) | slot, need_space); + if(!newPosition.isContainedIn(dest)) + { + dest.push_back(newPosition); + count -= need_space; + } + return EQUIP_ERR_OK; +} + +uint8 Player::_CanStoreItem_InBag( uint8 bag, ItemPosCountVec &dest, ItemPrototype const *pProto, uint32& count, bool merge, bool non_specialized, Item* pSrcItem, uint8 skip_bag, uint8 skip_slot ) const +{ + // skip specific bag already processed in first called _CanStoreItem_InBag + if(bag==skip_bag) + return EQUIP_ERR_ITEM_DOESNT_GO_INTO_BAG; + + Bag* pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, bag ); + if( !pBag ) + return EQUIP_ERR_ITEM_DOESNT_GO_INTO_BAG; + + ItemPrototype const* pBagProto = pBag->GetProto(); + if( !pBagProto ) + return EQUIP_ERR_ITEM_DOESNT_GO_INTO_BAG; + + // specialized bag mode or non-specilized + if( non_specialized != (pBagProto->Class == ITEM_CLASS_CONTAINER && pBagProto->SubClass == ITEM_SUBCLASS_CONTAINER) ) + return EQUIP_ERR_ITEM_DOESNT_GO_INTO_BAG; + + if( !ItemCanGoIntoBag(pProto,pBagProto) ) + return EQUIP_ERR_ITEM_DOESNT_GO_INTO_BAG; + + for(uint32 j = 0; j < pBagProto->ContainerSlots; j++) + { + // skip specific slot already processed in first called _CanStoreItem_InSpecificSlot + if(j==skip_slot) + continue; + + Item* pItem2 = GetItemByPos( bag, j ); + + // ignore move item (this slot will be empty at move) + if(pItem2==pSrcItem) + pItem2 = NULL; + + // if merge skip empty, if !merge skip non-empty + if((pItem2!=NULL)!=merge) + continue; + + if( pItem2 ) + { + if(pItem2->GetEntry() == pProto->ItemId && pItem2->GetCount() < pProto->Stackable ) + { + uint32 need_space = pProto->Stackable - pItem2->GetCount(); + if(need_space > count) + need_space = count; + + ItemPosCount newPosition = ItemPosCount((bag << 8) | j, need_space); + if(!newPosition.isContainedIn(dest)) + { + dest.push_back(newPosition); + count -= need_space; + + if(count==0) + return EQUIP_ERR_OK; + } + } + } + else + { + uint32 need_space = pProto->Stackable; + if(need_space > count) + need_space = count; + + ItemPosCount newPosition = ItemPosCount((bag << 8) | j, need_space); + if(!newPosition.isContainedIn(dest)) + { + dest.push_back(newPosition); + count -= need_space; + + if(count==0) + return EQUIP_ERR_OK; + } + } + } + return EQUIP_ERR_OK; +} + +uint8 Player::_CanStoreItem_InInventorySlots( uint8 slot_begin, uint8 slot_end, ItemPosCountVec &dest, ItemPrototype const *pProto, uint32& count, bool merge, Item* pSrcItem, uint8 skip_bag, uint8 skip_slot ) const +{ + for(uint32 j = slot_begin; j < slot_end; j++) + { + // skip specific slot already processed in first called _CanStoreItem_InSpecificSlot + if(INVENTORY_SLOT_BAG_0==skip_bag && j==skip_slot) + continue; + + Item* pItem2 = GetItemByPos( INVENTORY_SLOT_BAG_0, j ); + + // ignore move item (this slot will be empty at move) + if(pItem2==pSrcItem) + pItem2 = NULL; + + // if merge skip empty, if !merge skip non-empty + if((pItem2!=NULL)!=merge) + continue; + + if( pItem2 ) + { + if(pItem2->GetEntry() == pProto->ItemId && pItem2->GetCount() < pProto->Stackable ) + { + uint32 need_space = pProto->Stackable - pItem2->GetCount(); + if(need_space > count) + need_space = count; + ItemPosCount newPosition = ItemPosCount((INVENTORY_SLOT_BAG_0 << 8) | j, need_space); + if(!newPosition.isContainedIn(dest)) + { + dest.push_back(newPosition); + count -= need_space; + + if(count==0) + return EQUIP_ERR_OK; + } + } + } + else + { + uint32 need_space = pProto->Stackable; + if(need_space > count) + need_space = count; + + ItemPosCount newPosition = ItemPosCount((INVENTORY_SLOT_BAG_0 << 8) | j, need_space); + if(!newPosition.isContainedIn(dest)) + { + dest.push_back(newPosition); + count -= need_space; + + if(count==0) + return EQUIP_ERR_OK; + } + } + } + return EQUIP_ERR_OK; +} + +uint8 Player::_CanStoreItem( uint8 bag, uint8 slot, ItemPosCountVec &dest, uint32 entry, uint32 count, Item *pItem, bool swap, uint32* no_space_count ) const +{ + sLog.outDebug( "STORAGE: CanStoreItem bag = %u, slot = %u, item = %u, count = %u", bag, slot, entry, count); + + ItemPrototype const *pProto = objmgr.GetItemPrototype(entry); + if( !pProto ) + { + if(no_space_count) + *no_space_count = count; + return swap ? EQUIP_ERR_ITEMS_CANT_BE_SWAPPED :EQUIP_ERR_ITEM_NOT_FOUND; + } + + if(pItem && pItem->IsBindedNotWith(GetGUID())) + { + if(no_space_count) + *no_space_count = count; + return EQUIP_ERR_DONT_OWN_THAT_ITEM; + } + + // check count of items (skip for auto move for same player from bank) + uint32 no_similar_count = 0; // can't store this amount similar items + uint8 res = _CanTakeMoreSimilarItems(entry,count,pItem,&no_similar_count); + if(res!=EQUIP_ERR_OK) + { + if(count==no_similar_count) + { + if(no_space_count) + *no_space_count = no_similar_count; + return res; + } + count -= no_similar_count; + } + + // in specific slot + if( bag != NULL_BAG && slot != NULL_SLOT ) + { + res = _CanStoreItem_InSpecificSlot(bag,slot,dest,pProto,count,swap,pItem); + if(res!=EQUIP_ERR_OK) + { + if(no_space_count) + *no_space_count = count + no_similar_count; + return res; + } + + if(count==0) + { + if(no_similar_count==0) + return EQUIP_ERR_OK; + + if(no_space_count) + *no_space_count = count + no_similar_count; + return EQUIP_ERR_CANT_CARRY_MORE_OF_THIS; + } + } + + // not specific slot or have spece for partly store only in specific slot + + // in specific bag + if( bag != NULL_BAG ) + { + // search stack in bag for merge to + if( pProto->Stackable > 1 ) + { + if( bag == INVENTORY_SLOT_BAG_0 ) // inventory + { + res = _CanStoreItem_InInventorySlots(KEYRING_SLOT_START,KEYRING_SLOT_END,dest,pProto,count,true,pItem,bag,slot); + if(res!=EQUIP_ERR_OK) + { + if(no_space_count) + *no_space_count = count + no_similar_count; + return res; + } + + if(count==0) + { + if(no_similar_count==0) + return EQUIP_ERR_OK; + + if(no_space_count) + *no_space_count = count + no_similar_count; + return EQUIP_ERR_CANT_CARRY_MORE_OF_THIS; + } + + res = _CanStoreItem_InInventorySlots(INVENTORY_SLOT_ITEM_START,INVENTORY_SLOT_ITEM_END,dest,pProto,count,true,pItem,bag,slot); + if(res!=EQUIP_ERR_OK) + { + if(no_space_count) + *no_space_count = count + no_similar_count; + return res; + } + + if(count==0) + { + if(no_similar_count==0) + return EQUIP_ERR_OK; + + if(no_space_count) + *no_space_count = count + no_similar_count; + return EQUIP_ERR_CANT_CARRY_MORE_OF_THIS; + } + } + else // equipped bag + { + // we need check 2 time (specilized/non_specialized), use NULL_BAG to prevent skipping bag + res = _CanStoreItem_InBag(bag,dest,pProto,count,true,false,pItem,NULL_BAG,slot); + if(res!=EQUIP_ERR_OK) + res = _CanStoreItem_InBag(bag,dest,pProto,count,true,true,pItem,NULL_BAG,slot); + + if(res!=EQUIP_ERR_OK) + { + if(no_space_count) + *no_space_count = count + no_similar_count; + return res; + } + + if(count==0) + { + if(no_similar_count==0) + return EQUIP_ERR_OK; + + if(no_space_count) + *no_space_count = count + no_similar_count; + return EQUIP_ERR_CANT_CARRY_MORE_OF_THIS; + } + } + } + + // search free slot in bag for place to + if( bag == INVENTORY_SLOT_BAG_0 ) // inventory + { + // search free slot - keyring case + if(pProto->BagFamily & BAG_FAMILY_MASK_KEYS) + { + uint32 keyringSize = GetMaxKeyringSize(); + res = _CanStoreItem_InInventorySlots(KEYRING_SLOT_START,KEYRING_SLOT_START+keyringSize,dest,pProto,count,false,pItem,bag,slot); + if(res!=EQUIP_ERR_OK) + { + if(no_space_count) + *no_space_count = count + no_similar_count; + return res; + } + + if(count==0) + { + if(no_similar_count==0) + return EQUIP_ERR_OK; + + if(no_space_count) + *no_space_count = count + no_similar_count; + return EQUIP_ERR_CANT_CARRY_MORE_OF_THIS; + } + } + + res = _CanStoreItem_InInventorySlots(INVENTORY_SLOT_ITEM_START,INVENTORY_SLOT_ITEM_END,dest,pProto,count,false,pItem,bag,slot); + if(res!=EQUIP_ERR_OK) + { + if(no_space_count) + *no_space_count = count + no_similar_count; + return res; + } + + if(count==0) + { + if(no_similar_count==0) + return EQUIP_ERR_OK; + + if(no_space_count) + *no_space_count = count + no_similar_count; + return EQUIP_ERR_CANT_CARRY_MORE_OF_THIS; + } + } + else // equipped bag + { + res = _CanStoreItem_InBag(bag,dest,pProto,count,false,false,pItem,NULL_BAG,slot); + if(res!=EQUIP_ERR_OK) + res = _CanStoreItem_InBag(bag,dest,pProto,count,false,true,pItem,NULL_BAG,slot); + + if(res!=EQUIP_ERR_OK) + { + if(no_space_count) + *no_space_count = count + no_similar_count; + return res; + } + + if(count==0) + { + if(no_similar_count==0) + return EQUIP_ERR_OK; + + if(no_space_count) + *no_space_count = count + no_similar_count; + return EQUIP_ERR_CANT_CARRY_MORE_OF_THIS; + } + } + } + + // not specific bag or have space for partly store only in specific bag + + // search stack for merge to + if( pProto->Stackable > 1 ) + { + res = _CanStoreItem_InInventorySlots(KEYRING_SLOT_START,KEYRING_SLOT_END,dest,pProto,count,true,pItem,bag,slot); + if(res!=EQUIP_ERR_OK) + { + if(no_space_count) + *no_space_count = count + no_similar_count; + return res; + } + + if(count==0) + { + if(no_similar_count==0) + return EQUIP_ERR_OK; + + if(no_space_count) + *no_space_count = count + no_similar_count; + return EQUIP_ERR_CANT_CARRY_MORE_OF_THIS; + } + + res = _CanStoreItem_InInventorySlots(INVENTORY_SLOT_ITEM_START,INVENTORY_SLOT_ITEM_END,dest,pProto,count,true,pItem,bag,slot); + if(res!=EQUIP_ERR_OK) + { + if(no_space_count) + *no_space_count = count + no_similar_count; + return res; + } + + if(count==0) + { + if(no_similar_count==0) + return EQUIP_ERR_OK; + + if(no_space_count) + *no_space_count = count + no_similar_count; + return EQUIP_ERR_CANT_CARRY_MORE_OF_THIS; + } + + if( pProto->BagFamily ) + { + for(int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; i++) + { + res = _CanStoreItem_InBag(i,dest,pProto,count,true,false,pItem,bag,slot); + if(res!=EQUIP_ERR_OK) + continue; + + if(count==0) + { + if(no_similar_count==0) + return EQUIP_ERR_OK; + + if(no_space_count) + *no_space_count = count + no_similar_count; + return EQUIP_ERR_CANT_CARRY_MORE_OF_THIS; + } + } + } + + for(int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; i++) + { + res = _CanStoreItem_InBag(i,dest,pProto,count,true,true,pItem,bag,slot); + if(res!=EQUIP_ERR_OK) + continue; + + if(count==0) + { + if(no_similar_count==0) + return EQUIP_ERR_OK; + + if(no_space_count) + *no_space_count = count + no_similar_count; + return EQUIP_ERR_CANT_CARRY_MORE_OF_THIS; + } + } + } + + // search free slot - special bag case + if( pProto->BagFamily ) + { + if(pProto->BagFamily & BAG_FAMILY_MASK_KEYS) + { + uint32 keyringSize = GetMaxKeyringSize(); + res = _CanStoreItem_InInventorySlots(KEYRING_SLOT_START,KEYRING_SLOT_START+keyringSize,dest,pProto,count,false,pItem,bag,slot); + if(res!=EQUIP_ERR_OK) + { + if(no_space_count) + *no_space_count = count + no_similar_count; + return res; + } + + if(count==0) + { + if(no_similar_count==0) + return EQUIP_ERR_OK; + + if(no_space_count) + *no_space_count = count + no_similar_count; + return EQUIP_ERR_CANT_CARRY_MORE_OF_THIS; + } + } + + for(int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; i++) + { + res = _CanStoreItem_InBag(i,dest,pProto,count,false,false,pItem,bag,slot); + if(res!=EQUIP_ERR_OK) + continue; + + if(count==0) + { + if(no_similar_count==0) + return EQUIP_ERR_OK; + + if(no_space_count) + *no_space_count = count + no_similar_count; + return EQUIP_ERR_CANT_CARRY_MORE_OF_THIS; + } + } + } + + // search free slot + res = _CanStoreItem_InInventorySlots(INVENTORY_SLOT_ITEM_START,INVENTORY_SLOT_ITEM_END,dest,pProto,count,false,pItem,bag,slot); + if(res!=EQUIP_ERR_OK) + { + if(no_space_count) + *no_space_count = count + no_similar_count; + return res; + } + + if(count==0) + { + if(no_similar_count==0) + return EQUIP_ERR_OK; + + if(no_space_count) + *no_space_count = count + no_similar_count; + return EQUIP_ERR_CANT_CARRY_MORE_OF_THIS; + } + + for(int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; i++) + { + res = _CanStoreItem_InBag(i,dest,pProto,count,false,true,pItem,bag,slot); + if(res!=EQUIP_ERR_OK) + continue; + + if(count==0) + { + if(no_similar_count==0) + return EQUIP_ERR_OK; + + if(no_space_count) + *no_space_count = count + no_similar_count; + return EQUIP_ERR_CANT_CARRY_MORE_OF_THIS; + } + } + + if(no_space_count) + *no_space_count = count + no_similar_count; + + return EQUIP_ERR_INVENTORY_FULL; +} + +////////////////////////////////////////////////////////////////////////// +uint8 Player::CanStoreItems( Item **pItems,int count) const +{ + Item *pItem2; + + // fill space table + int inv_slot_items[INVENTORY_SLOT_ITEM_END-INVENTORY_SLOT_ITEM_START]; + int inv_bags[INVENTORY_SLOT_BAG_END-INVENTORY_SLOT_BAG_START][MAX_BAG_SIZE]; + int inv_keys[KEYRING_SLOT_END-KEYRING_SLOT_START]; + + memset(inv_slot_items,0,sizeof(int)*(INVENTORY_SLOT_ITEM_END-INVENTORY_SLOT_ITEM_START)); + memset(inv_bags,0,sizeof(int)*(INVENTORY_SLOT_BAG_END-INVENTORY_SLOT_BAG_START)*MAX_BAG_SIZE); + memset(inv_keys,0,sizeof(int)*(KEYRING_SLOT_END-KEYRING_SLOT_START)); + + for(int i = INVENTORY_SLOT_ITEM_START; i < INVENTORY_SLOT_ITEM_END; i++) + { + pItem2 = GetItemByPos( INVENTORY_SLOT_BAG_0, i ); + + if (pItem2 && !pItem2->IsInTrade()) + { + inv_slot_items[i-INVENTORY_SLOT_ITEM_START] = pItem2->GetCount(); + } + } + + for(int i = KEYRING_SLOT_START; i < KEYRING_SLOT_END; i++) + { + pItem2 = GetItemByPos( INVENTORY_SLOT_BAG_0, i ); + + if (pItem2 && !pItem2->IsInTrade()) + { + inv_keys[i-KEYRING_SLOT_START] = pItem2->GetCount(); + } + } + + for(int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; i++) + { + Bag *pBag; + ItemPrototype const *pBagProto; + + pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i ); + if( pBag ) + { + pBagProto = pBag->GetProto(); + + if( pBagProto ) + { + for(uint32 j = 0; j < pBagProto->ContainerSlots; j++) + { + pItem2 = GetItemByPos( i, j ); + if (pItem2 && !pItem2->IsInTrade()) + { + inv_bags[i-INVENTORY_SLOT_BAG_START][j] = pItem2->GetCount(); + } + } + } + } + } + + // check free space for all items + for (int k=0;kGetEntry(), pItem->GetCount()); + ItemPrototype const *pProto = pItem->GetProto(); + + // strange item + if( !pProto ) + return EQUIP_ERR_ITEM_NOT_FOUND; + + // item it 'bind' + if(pItem->IsBindedNotWith(GetGUID())) + return EQUIP_ERR_DONT_OWN_THAT_ITEM; + + Bag *pBag; + ItemPrototype const *pBagProto; + + // item is 'one item only' + uint8 res = CanTakeMoreSimilarItems(pItem); + if(res != EQUIP_ERR_OK) + return res; + + // search stack for merge to + if( pProto->Stackable > 1 ) + { + bool b_found = false; + + for(int t = KEYRING_SLOT_START; t < KEYRING_SLOT_END; t++) + { + pItem2 = GetItemByPos( INVENTORY_SLOT_BAG_0, t ); + if( pItem2 && pItem2->GetEntry() == pItem->GetEntry() && inv_keys[t-KEYRING_SLOT_START] + pItem->GetCount() <= pProto->Stackable ) + { + inv_keys[t-KEYRING_SLOT_START] += pItem->GetCount(); + b_found = true; + break; + } + } + if (b_found) continue; + + for(int t = INVENTORY_SLOT_ITEM_START; t < INVENTORY_SLOT_ITEM_END; t++) + { + pItem2 = GetItemByPos( INVENTORY_SLOT_BAG_0, t ); + if( pItem2 && pItem2->GetEntry() == pItem->GetEntry() && inv_slot_items[t-INVENTORY_SLOT_ITEM_START] + pItem->GetCount() <= pProto->Stackable ) + { + inv_slot_items[t-INVENTORY_SLOT_ITEM_START] += pItem->GetCount(); + b_found = true; + break; + } + } + if (b_found) continue; + + for(int t = INVENTORY_SLOT_BAG_START; !b_found && t < INVENTORY_SLOT_BAG_END; t++) + { + pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, t ); + if( pBag ) + { + pBagProto = pBag->GetProto(); + if( pBagProto ) + { + for(uint32 j = 0; j < pBagProto->ContainerSlots; j++) + { + pItem2 = GetItemByPos( t, j ); + if( pItem2 && pItem2->GetEntry() == pItem->GetEntry() && inv_bags[t-INVENTORY_SLOT_BAG_START][j] + pItem->GetCount() <= pProto->Stackable ) + { + inv_bags[t-INVENTORY_SLOT_BAG_START][j] += pItem->GetCount(); + b_found = true; + break; + } + } + } + } + } + if (b_found) continue; + } + + // special bag case + if( pProto->BagFamily ) + { + bool b_found = false; + if(pProto->BagFamily & BAG_FAMILY_MASK_KEYS) + { + uint32 keyringSize = GetMaxKeyringSize(); + for(uint32 t = KEYRING_SLOT_START; t < KEYRING_SLOT_START+keyringSize; ++t) + { + if( inv_keys[t-KEYRING_SLOT_START] == 0 ) + { + inv_keys[t-KEYRING_SLOT_START] = 1; + b_found = true; + break; + } + } + } + + if (b_found) continue; + + for(int t = INVENTORY_SLOT_BAG_START; !b_found && t < INVENTORY_SLOT_BAG_END; t++) + { + pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, t ); + if( pBag ) + { + pBagProto = pBag->GetProto(); + + // not plain container check + if( pBagProto && (pBagProto->Class != ITEM_CLASS_CONTAINER || pBagProto->SubClass != ITEM_SUBCLASS_CONTAINER) && + ItemCanGoIntoBag(pProto,pBagProto) ) + { + for(uint32 j = 0; j < pBagProto->ContainerSlots; j++) + { + if( inv_bags[t-INVENTORY_SLOT_BAG_START][j] == 0 ) + { + inv_bags[t-INVENTORY_SLOT_BAG_START][j] = 1; + b_found = true; + break; + } + } + } + } + } + if (b_found) continue; + } + + // search free slot + bool b_found = false; + for(int t = INVENTORY_SLOT_ITEM_START; t < INVENTORY_SLOT_ITEM_END; t++) + { + if( inv_slot_items[t-INVENTORY_SLOT_ITEM_START] == 0 ) + { + inv_slot_items[t-INVENTORY_SLOT_ITEM_START] = 1; + b_found = true; + break; + } + } + if (b_found) continue; + + // search free slot in bags + for(int t = INVENTORY_SLOT_BAG_START; !b_found && t < INVENTORY_SLOT_BAG_END; t++) + { + pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, t ); + if( pBag ) + { + pBagProto = pBag->GetProto(); + if( pBagProto && ItemCanGoIntoBag(pProto,pBagProto)) + { + for(uint32 j = 0; j < pBagProto->ContainerSlots; j++) + { + if( inv_bags[t-INVENTORY_SLOT_BAG_START][j] == 0 ) + { + inv_bags[t-INVENTORY_SLOT_BAG_START][j] = 1; + b_found = true; + break; + } + } + } + } + } + + // no free slot found? + if (!b_found) + return EQUIP_ERR_INVENTORY_FULL; + } + + return EQUIP_ERR_OK; +} + +////////////////////////////////////////////////////////////////////////// +uint8 Player::CanEquipNewItem( uint8 slot, uint16 &dest, uint32 item, uint32 count, bool swap ) const +{ + dest = 0; + Item *pItem = Item::CreateItem( item, count, this ); + if( pItem ) + { + uint8 result = CanEquipItem(slot, dest, pItem, swap ); + delete pItem; + return result; + } + + return EQUIP_ERR_ITEM_NOT_FOUND; +} + +uint8 Player::CanEquipItem( uint8 slot, uint16 &dest, Item *pItem, bool swap, bool not_loading ) const +{ + dest = 0; + if( pItem ) + { + sLog.outDebug( "STORAGE: CanEquipItem slot = %u, item = %u, count = %u", slot, pItem->GetEntry(), pItem->GetCount()); + ItemPrototype const *pProto = pItem->GetProto(); + if( pProto ) + { + if(pItem->IsBindedNotWith(GetGUID())) + return EQUIP_ERR_DONT_OWN_THAT_ITEM; + + // check count of items (skip for auto move for same player from bank) + uint8 res = CanTakeMoreSimilarItems(pItem); + if(res != EQUIP_ERR_OK) + return res; + + // do not allow equipping gear except weapons, offhands, projectiles, relics in + // - combat + // - in-progress arenas + if( !pProto->CanChangeEquipStateInCombat() ) + { + if( isInCombat() ) + return EQUIP_ERR_NOT_IN_COMBAT; + + if(BattleGround* bg = GetBattleGround()) + if( bg->isArena() && bg->GetStatus() == STATUS_IN_PROGRESS ) + return EQUIP_ERR_NOT_DURING_ARENA_MATCH; + } + + if(isInCombat()&& pProto->Class == ITEM_CLASS_WEAPON && m_weaponChangeTimer != 0) + return EQUIP_ERR_CANT_DO_RIGHT_NOW; // maybe exist better err + + uint8 eslot = FindEquipSlot( pProto, slot, swap ); + if( eslot == NULL_SLOT ) + return EQUIP_ERR_ITEM_CANT_BE_EQUIPPED; + + uint8 msg = CanUseItem( pItem , not_loading ); + if( msg != EQUIP_ERR_OK ) + return msg; + if( !swap && GetItemByPos( INVENTORY_SLOT_BAG_0, eslot ) ) + return EQUIP_ERR_NO_EQUIPMENT_SLOT_AVAILABLE; + + // check unique-equipped on item + if (pProto->Flags & ITEM_FLAGS_UNIQUE_EQUIPPED) + { + // there is an equip limit on this item + Item* tItem = GetItemOrItemWithGemEquipped(pProto->ItemId); + if (tItem && (!swap || tItem->GetSlot() != eslot ) ) + return EQUIP_ERR_ITEM_UNIQUE_EQUIPABLE; + } + + // check unique-equipped on gems + for(uint32 enchant_slot = SOCK_ENCHANTMENT_SLOT; enchant_slot < SOCK_ENCHANTMENT_SLOT+3; ++enchant_slot) + { + uint32 enchant_id = pItem->GetEnchantmentId(EnchantmentSlot(enchant_slot)); + if(!enchant_id) + continue; + SpellItemEnchantmentEntry const* enchantEntry = sSpellItemEnchantmentStore.LookupEntry(enchant_id); + if(!enchantEntry) + continue; + + ItemPrototype const* pGem = objmgr.GetItemPrototype(enchantEntry->GemID); + if(pGem && (pGem->Flags & ITEM_FLAGS_UNIQUE_EQUIPPED)) + { + Item* tItem = GetItemOrItemWithGemEquipped(enchantEntry->GemID); + if(tItem && (!swap || tItem->GetSlot() != eslot )) + return EQUIP_ERR_ITEM_UNIQUE_EQUIPABLE; + } + } + + // check unique-equipped special item classes + if (pProto->Class == ITEM_CLASS_QUIVER) + { + for(int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; ++i) + { + if( Item* pBag = GetItemByPos( INVENTORY_SLOT_BAG_0, i ) ) + { + if( ItemPrototype const* pBagProto = pBag->GetProto() ) + { + if( pBagProto->Class==pProto->Class && pBagProto->SubClass==pProto->SubClass && + (!swap || pBag->GetSlot() != eslot ) ) + { + if(pBagProto->SubClass == ITEM_SUBCLASS_AMMO_POUCH) + return EQUIP_ERR_CAN_EQUIP_ONLY1_AMMOPOUCH; + else + return EQUIP_ERR_CAN_EQUIP_ONLY1_QUIVER; + } + } + } + } + } + + uint32 type = pProto->InventoryType; + + if(eslot == EQUIPMENT_SLOT_OFFHAND) + { + if( type == INVTYPE_WEAPON || type == INVTYPE_WEAPONOFFHAND ) + { + if(!CanDualWield()) + return EQUIP_ERR_CANT_DUAL_WIELD; + } + + Item *mainItem = GetItemByPos( INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_MAINHAND ); + if(mainItem) + { + if(mainItem->GetProto()->InventoryType == INVTYPE_2HWEAPON) + return EQUIP_ERR_CANT_EQUIP_WITH_TWOHANDED; + } + } + + // equip two-hand weapon case (with possible unequip 2 items) + if( type == INVTYPE_2HWEAPON ) + { + if(eslot != EQUIPMENT_SLOT_MAINHAND) + return EQUIP_ERR_ITEM_CANT_BE_EQUIPPED; + + // offhand item must can be stored in inventitory for offhand item and it also must be unequipped + Item *offItem = GetItemByPos( INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND ); + ItemPosCountVec off_dest; + if( offItem && (!not_loading || + CanUnequipItem(uint16(INVENTORY_SLOT_BAG_0) << 8 | EQUIPMENT_SLOT_OFFHAND,false) != EQUIP_ERR_OK || + CanStoreItem( NULL_BAG, NULL_SLOT, off_dest, offItem, false ) != EQUIP_ERR_OK ) ) + return swap ? EQUIP_ERR_ITEMS_CANT_BE_SWAPPED : EQUIP_ERR_INVENTORY_FULL; + } + dest = ((INVENTORY_SLOT_BAG_0 << 8) | eslot); + return EQUIP_ERR_OK; + } + } + if( !swap ) + return EQUIP_ERR_ITEM_NOT_FOUND; + else + return EQUIP_ERR_ITEMS_CANT_BE_SWAPPED; +} + +uint8 Player::CanUnequipItem( uint16 pos, bool swap ) const +{ + // Applied only to equipped items and bank bags + if(!IsEquipmentPos(pos) && !IsBagPos(pos)) + return EQUIP_ERR_OK; + + Item* pItem = GetItemByPos(pos); + + // Applied only to existed equipped item + if( !pItem ) + return EQUIP_ERR_OK; + + sLog.outDebug( "STORAGE: CanUnequipItem slot = %u, item = %u, count = %u", pos, pItem->GetEntry(), pItem->GetCount()); + + ItemPrototype const *pProto = pItem->GetProto(); + if( !pProto ) + return EQUIP_ERR_ITEM_NOT_FOUND; + + // do not allow unequipping gear except weapons, offhands, projectiles, relics in + // - combat + // - in-progress arenas + if( !pProto->CanChangeEquipStateInCombat() ) + { + if( isInCombat() ) + return EQUIP_ERR_NOT_IN_COMBAT; + + if(BattleGround* bg = GetBattleGround()) + if( bg->isArena() && bg->GetStatus() == STATUS_IN_PROGRESS ) + return EQUIP_ERR_NOT_DURING_ARENA_MATCH; + } + + if(!swap && pItem->IsBag() && !((Bag*)pItem)->IsEmpty()) + return EQUIP_ERR_CAN_ONLY_DO_WITH_EMPTY_BAGS; + + return EQUIP_ERR_OK; +} + +uint8 Player::CanBankItem( uint8 bag, uint8 slot, ItemPosCountVec &dest, Item *pItem, bool swap, bool not_loading ) const +{ + if( !pItem ) + return swap ? EQUIP_ERR_ITEMS_CANT_BE_SWAPPED : EQUIP_ERR_ITEM_NOT_FOUND; + + uint32 count = pItem->GetCount(); + + sLog.outDebug( "STORAGE: CanBankItem bag = %u, slot = %u, item = %u, count = %u", bag, slot, pItem->GetEntry(), pItem->GetCount()); + ItemPrototype const *pProto = pItem->GetProto(); + if( !pProto ) + return swap ? EQUIP_ERR_ITEMS_CANT_BE_SWAPPED : EQUIP_ERR_ITEM_NOT_FOUND; + + if( pItem->IsBindedNotWith(GetGUID()) ) + return EQUIP_ERR_DONT_OWN_THAT_ITEM; + + // check count of items (skip for auto move for same player from bank) + uint8 res = CanTakeMoreSimilarItems(pItem); + if(res != EQUIP_ERR_OK) + return res; + + // in specific slot + if( bag != NULL_BAG && slot != NULL_SLOT ) + { + if( pProto->InventoryType == INVTYPE_BAG ) + { + Bag *pBag = (Bag*)pItem; + if( pBag ) + { + if( slot >= BANK_SLOT_BAG_START && slot < BANK_SLOT_BAG_END ) + { + if( !HasBankBagSlot( slot ) ) + return EQUIP_ERR_MUST_PURCHASE_THAT_BAG_SLOT; + if( uint8 cantuse = CanUseItem( pItem, not_loading ) != EQUIP_ERR_OK ) + return cantuse; + } + else + { + if( !pBag->IsEmpty() ) + return EQUIP_ERR_NONEMPTY_BAG_OVER_OTHER_BAG; + } + } + } + else + { + if( slot >= BANK_SLOT_BAG_START && slot < BANK_SLOT_BAG_END ) + return EQUIP_ERR_ITEM_DOESNT_GO_TO_SLOT; + } + + res = _CanStoreItem_InSpecificSlot(bag,slot,dest,pProto,count,swap,pItem); + if(res!=EQUIP_ERR_OK) + return res; + + if(count==0) + return EQUIP_ERR_OK; + } + + // not specific slot or have spece for partly store only in specific slot + + // in specific bag + if( bag != NULL_BAG ) + { + if( pProto->InventoryType == INVTYPE_BAG ) + { + Bag *pBag = (Bag*)pItem; + if( pBag && !pBag->IsEmpty() ) + return EQUIP_ERR_NONEMPTY_BAG_OVER_OTHER_BAG; + } + + // search stack in bag for merge to + if( pProto->Stackable > 1 ) + { + if( bag == INVENTORY_SLOT_BAG_0 ) + { + res = _CanStoreItem_InInventorySlots(BANK_SLOT_ITEM_START,BANK_SLOT_ITEM_END,dest,pProto,count,true,pItem,bag,slot); + if(res!=EQUIP_ERR_OK) + return res; + + if(count==0) + return EQUIP_ERR_OK; + } + else + { + res = _CanStoreItem_InBag(bag,dest,pProto,count,true,false,pItem,NULL_BAG,slot); + if(res!=EQUIP_ERR_OK) + res = _CanStoreItem_InBag(bag,dest,pProto,count,true,true,pItem,NULL_BAG,slot); + + if(res!=EQUIP_ERR_OK) + return res; + + if(count==0) + return EQUIP_ERR_OK; + } + } + + // search free slot in bag + if( bag == INVENTORY_SLOT_BAG_0 ) + { + res = _CanStoreItem_InInventorySlots(BANK_SLOT_ITEM_START,BANK_SLOT_ITEM_END,dest,pProto,count,false,pItem,bag,slot); + if(res!=EQUIP_ERR_OK) + return res; + + if(count==0) + return EQUIP_ERR_OK; + } + else + { + res = _CanStoreItem_InBag(bag,dest,pProto,count,false,false,pItem,NULL_BAG,slot); + if(res!=EQUIP_ERR_OK) + res = _CanStoreItem_InBag(bag,dest,pProto,count,false,true,pItem,NULL_BAG,slot); + + if(res!=EQUIP_ERR_OK) + return res; + + if(count==0) + return EQUIP_ERR_OK; + } + } + + // not specific bag or have spece for partly store only in specific bag + + // search stack for merge to + if( pProto->Stackable > 1 ) + { + // in slots + res = _CanStoreItem_InInventorySlots(BANK_SLOT_ITEM_START,BANK_SLOT_ITEM_END,dest,pProto,count,true,pItem,bag,slot); + if(res!=EQUIP_ERR_OK) + return res; + + if(count==0) + return EQUIP_ERR_OK; + + // in special bags + if( pProto->BagFamily ) + { + for(int i = BANK_SLOT_BAG_START; i < BANK_SLOT_BAG_END; i++) + { + res = _CanStoreItem_InBag(i,dest,pProto,count,true,false,pItem,bag,slot); + if(res!=EQUIP_ERR_OK) + continue; + + if(count==0) + return EQUIP_ERR_OK; + } + } + + for(int i = BANK_SLOT_BAG_START; i < BANK_SLOT_BAG_END; i++) + { + res = _CanStoreItem_InBag(i,dest,pProto,count,true,true,pItem,bag,slot); + if(res!=EQUIP_ERR_OK) + continue; + + if(count==0) + return EQUIP_ERR_OK; + } + } + + // search free place in special bag + if( pProto->BagFamily ) + { + for(int i = BANK_SLOT_BAG_START; i < BANK_SLOT_BAG_END; i++) + { + res = _CanStoreItem_InBag(i,dest,pProto,count,false,false,pItem,bag,slot); + if(res!=EQUIP_ERR_OK) + continue; + + if(count==0) + return EQUIP_ERR_OK; + } + } + + // search free space + res = _CanStoreItem_InInventorySlots(BANK_SLOT_ITEM_START,BANK_SLOT_ITEM_END,dest,pProto,count,false,pItem,bag,slot); + if(res!=EQUIP_ERR_OK) + return res; + + if(count==0) + return EQUIP_ERR_OK; + + for(int i = BANK_SLOT_BAG_START; i < BANK_SLOT_BAG_END; i++) + { + res = _CanStoreItem_InBag(i,dest,pProto,count,false,true,pItem,bag,slot); + if(res!=EQUIP_ERR_OK) + continue; + + if(count==0) + return EQUIP_ERR_OK; + } + return EQUIP_ERR_BANK_FULL; +} + +uint8 Player::CanUseItem( Item *pItem, bool not_loading ) const +{ + if( pItem ) + { + sLog.outDebug( "STORAGE: CanUseItem item = %u", pItem->GetEntry()); + if( !isAlive() && not_loading ) + return EQUIP_ERR_YOU_ARE_DEAD; + //if( isStunned() ) + // return EQUIP_ERR_YOU_ARE_STUNNED; + ItemPrototype const *pProto = pItem->GetProto(); + if( pProto ) + { + if( pItem->IsBindedNotWith(GetGUID()) ) + return EQUIP_ERR_DONT_OWN_THAT_ITEM; + if( (pProto->AllowableClass & getClassMask()) == 0 || (pProto->AllowableRace & getRaceMask()) == 0 ) + return EQUIP_ERR_YOU_CAN_NEVER_USE_THAT_ITEM; + if( pItem->GetSkill() != 0 ) + { + if( GetSkillValue( pItem->GetSkill() ) == 0 ) + return EQUIP_ERR_NO_REQUIRED_PROFICIENCY; + } + if( pProto->RequiredSkill != 0 ) + { + if( GetSkillValue( pProto->RequiredSkill ) == 0 ) + return EQUIP_ERR_NO_REQUIRED_PROFICIENCY; + else if( GetSkillValue( pProto->RequiredSkill ) < pProto->RequiredSkillRank ) + return EQUIP_ERR_ERR_CANT_EQUIP_SKILL; + } + if( pProto->RequiredSpell != 0 && !HasSpell( pProto->RequiredSpell ) ) + return EQUIP_ERR_NO_REQUIRED_PROFICIENCY; + if( pProto->RequiredReputationFaction && uint32(GetReputationRank(pProto->RequiredReputationFaction)) < pProto->RequiredReputationRank ) + return EQUIP_ERR_CANT_EQUIP_REPUTATION; + if( getLevel() < pProto->RequiredLevel ) + return EQUIP_ERR_CANT_EQUIP_LEVEL_I; + return EQUIP_ERR_OK; + } + } + return EQUIP_ERR_ITEM_NOT_FOUND; +} + +bool Player::CanUseItem( ItemPrototype const *pProto ) +{ + // Used by group, function NeedBeforeGreed, to know if a prototype can be used by a player + + if( pProto ) + { + if( (pProto->AllowableClass & getClassMask()) == 0 || (pProto->AllowableRace & getRaceMask()) == 0 ) + return false; + if( pProto->RequiredSkill != 0 ) + { + if( GetSkillValue( pProto->RequiredSkill ) == 0 ) + return false; + else if( GetSkillValue( pProto->RequiredSkill ) < pProto->RequiredSkillRank ) + return false; + } + if( pProto->RequiredSpell != 0 && !HasSpell( pProto->RequiredSpell ) ) + return false; + if( getLevel() < pProto->RequiredLevel ) + return false; + return true; + } + return false; +} + +uint8 Player::CanUseAmmo( uint32 item ) const +{ + sLog.outDebug( "STORAGE: CanUseAmmo item = %u", item); + if( !isAlive() ) + return EQUIP_ERR_YOU_ARE_DEAD; + //if( isStunned() ) + // return EQUIP_ERR_YOU_ARE_STUNNED; + ItemPrototype const *pProto = objmgr.GetItemPrototype( item ); + if( pProto ) + { + if( pProto->InventoryType!= INVTYPE_AMMO ) + return EQUIP_ERR_ONLY_AMMO_CAN_GO_HERE; + if( (pProto->AllowableClass & getClassMask()) == 0 || (pProto->AllowableRace & getRaceMask()) == 0 ) + return EQUIP_ERR_YOU_CAN_NEVER_USE_THAT_ITEM; + if( pProto->RequiredSkill != 0 ) + { + if( GetSkillValue( pProto->RequiredSkill ) == 0 ) + return EQUIP_ERR_NO_REQUIRED_PROFICIENCY; + else if( GetSkillValue( pProto->RequiredSkill ) < pProto->RequiredSkillRank ) + return EQUIP_ERR_ERR_CANT_EQUIP_SKILL; + } + if( pProto->RequiredSpell != 0 && !HasSpell( pProto->RequiredSpell ) ) + return EQUIP_ERR_NO_REQUIRED_PROFICIENCY; + /*if( GetReputation() < pProto->RequiredReputation ) + return EQUIP_ERR_CANT_EQUIP_REPUTATION; + */ + if( getLevel() < pProto->RequiredLevel ) + return EQUIP_ERR_CANT_EQUIP_LEVEL_I; + + // Requires No Ammo + if(GetDummyAura(46699)) + return EQUIP_ERR_BAG_FULL6; + + return EQUIP_ERR_OK; + } + return EQUIP_ERR_ITEM_NOT_FOUND; +} + +void Player::SetAmmo( uint32 item ) +{ + if(!item) + return; + + // already set + if( GetUInt32Value(PLAYER_AMMO_ID) == item ) + return; + + // check ammo + if(item) + { + uint8 msg = CanUseAmmo( item ); + if( msg != EQUIP_ERR_OK ) + { + SendEquipError( msg, NULL, NULL ); + return; + } + } + + SetUInt32Value(PLAYER_AMMO_ID, item); + + _ApplyAmmoBonuses(); +} + +void Player::RemoveAmmo() +{ + SetUInt32Value(PLAYER_AMMO_ID, 0); + + m_ammoDPS = 0.0f; + + if(CanModifyStats()) + UpdateDamagePhysical(RANGED_ATTACK); +} + +// Return stored item (if stored to stack, it can diff. from pItem). And pItem ca be deleted in this case. +Item* Player::StoreNewItem( ItemPosCountVec const& dest, uint32 item, bool update,int32 randomPropertyId ) +{ + uint32 count = 0; + for(ItemPosCountVec::const_iterator itr = dest.begin(); itr != dest.end(); ++itr) + count += itr->count; + + Item *pItem = Item::CreateItem( item, count, this ); + if( pItem ) + { + ItemAddedQuestCheck( item, count ); + if(randomPropertyId) + pItem->SetItemRandomProperties(randomPropertyId); + pItem = StoreItem( dest, pItem, update ); + } + return pItem; +} + +Item* Player::StoreItem( ItemPosCountVec const& dest, Item* pItem, bool update ) +{ + if( !pItem ) + return NULL; + + Item* lastItem = pItem; + + for(ItemPosCountVec::const_iterator itr = dest.begin(); itr != dest.end(); ) + { + uint16 pos = itr->pos; + uint32 count = itr->count; + + ++itr; + + if(itr == dest.end()) + { + lastItem = _StoreItem(pos,pItem,count,false,update); + break; + } + + lastItem = _StoreItem(pos,pItem,count,true,update); + } + + return lastItem; +} + +// Return stored item (if stored to stack, it can diff. from pItem). And pItem ca be deleted in this case. +Item* Player::_StoreItem( uint16 pos, Item *pItem, uint32 count, bool clone, bool update ) +{ + if( !pItem ) + return NULL; + + uint8 bag = pos >> 8; + uint8 slot = pos & 255; + + sLog.outDebug( "STORAGE: StoreItem bag = %u, slot = %u, item = %u, count = %u", bag, slot, pItem->GetEntry(), count); + + Item *pItem2 = GetItemByPos( bag, slot ); + + if( !pItem2 ) + { + if(clone) + pItem = pItem->CloneItem(count,this); + else + pItem->SetCount(count); + + if(!pItem) + return NULL; + + if( pItem->GetProto()->Bonding == BIND_WHEN_PICKED_UP || + pItem->GetProto()->Bonding == BIND_QUEST_ITEM || + pItem->GetProto()->Bonding == BIND_WHEN_EQUIPED && IsBagPos(pos) ) + pItem->SetBinding( true ); + + if( bag == INVENTORY_SLOT_BAG_0 ) + { + m_items[slot] = pItem; + SetUInt64Value( (uint16)(PLAYER_FIELD_INV_SLOT_HEAD + (slot * 2) ), pItem->GetGUID() ); + pItem->SetUInt64Value( ITEM_FIELD_CONTAINED, GetGUID() ); + pItem->SetUInt64Value( ITEM_FIELD_OWNER, GetGUID() ); + + pItem->SetSlot( slot ); + pItem->SetContainer( NULL ); + + if( IsInWorld() && update ) + { + pItem->AddToWorld(); + pItem->SendUpdateToPlayer( this ); + } + + pItem->SetState(ITEM_CHANGED, this); + } + else + { + Bag *pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, bag ); + if( pBag ) + { + pBag->StoreItem( slot, pItem, update ); + if( IsInWorld() && update ) + { + pItem->AddToWorld(); + pItem->SendUpdateToPlayer( this ); + } + pItem->SetState(ITEM_CHANGED, this); + pBag->SetState(ITEM_CHANGED, this); + } + } + + AddEnchantmentDurations(pItem); + AddItemDurations(pItem); + + return pItem; + } + else + { + if( pItem2->GetProto()->Bonding == BIND_WHEN_PICKED_UP || + pItem2->GetProto()->Bonding == BIND_QUEST_ITEM || + pItem2->GetProto()->Bonding == BIND_WHEN_EQUIPED && IsBagPos(pos) ) + pItem2->SetBinding( true ); + + pItem2->SetCount( pItem2->GetCount() + count ); + if( IsInWorld() && update ) + pItem2->SendUpdateToPlayer( this ); + + if(!clone) + { + // delete item (it not in any slot currently) + if( IsInWorld() && update ) + { + pItem->RemoveFromWorld(); + pItem->DestroyForPlayer( this ); + } + + RemoveEnchantmentDurations(pItem); + RemoveItemDurations(pItem); + + pItem->SetOwnerGUID(GetGUID()); // prevent error at next SetState in case trade/mail/buy from vendor + pItem->SetState(ITEM_REMOVED, this); + } + // AddItemDurations(pItem2); - pItem2 already have duration listed for player + AddEnchantmentDurations(pItem2); + + pItem2->SetState(ITEM_CHANGED, this); + + return pItem2; + } +} + +Item* Player::EquipNewItem( uint16 pos, uint32 item, uint32 count, bool update ) +{ + Item *pItem = Item::CreateItem( item, count, this ); + if( pItem ) + { + ItemAddedQuestCheck( item, count ); + Item * retItem = EquipItem( pos, pItem, update ); + + return retItem; + } + return NULL; +} + +Item* Player::EquipItem( uint16 pos, Item *pItem, bool update ) +{ + if( pItem ) + { + AddEnchantmentDurations(pItem); + AddItemDurations(pItem); + + uint8 bag = pos >> 8; + uint8 slot = pos & 255; + + Item *pItem2 = GetItemByPos( bag, slot ); + + if( !pItem2 ) + { + VisualizeItem( slot, pItem); + + if(isAlive()) + { + ItemPrototype const *pProto = pItem->GetProto(); + + // item set bonuses applied only at equip and removed at unequip, and still active for broken items + if(pProto && pProto->ItemSet) + AddItemsSetItem(this,pItem); + + _ApplyItemMods(pItem, slot, true); + + if(pProto && isInCombat()&& pProto->Class == ITEM_CLASS_WEAPON && m_weaponChangeTimer == 0) + { + m_weaponChangeTimer = DEFAULT_SWITCH_WEAPON; + if (getClass() == CLASS_ROGUE) + m_weaponChangeTimer = ROGUE_SWITCH_WEAPON; + } + } + + if( IsInWorld() && update ) + { + pItem->AddToWorld(); + pItem->SendUpdateToPlayer( this ); + } + + ApplyEquipCooldown(pItem); + + if( slot == EQUIPMENT_SLOT_MAINHAND ) + UpdateExpertise(BASE_ATTACK); + else if( slot == EQUIPMENT_SLOT_OFFHAND ) + UpdateExpertise(OFF_ATTACK); + } + else + { + pItem2->SetCount( pItem2->GetCount() + pItem->GetCount() ); + if( IsInWorld() && update ) + pItem2->SendUpdateToPlayer( this ); + + // delete item (it not in any slot currently) + //pItem->DeleteFromDB(); + if( IsInWorld() && update ) + { + pItem->RemoveFromWorld(); + pItem->DestroyForPlayer( this ); + } + + RemoveEnchantmentDurations(pItem); + RemoveItemDurations(pItem); + + pItem->SetOwnerGUID(GetGUID()); // prevent error at next SetState in case trade/mail/buy from vendor + pItem->SetState(ITEM_REMOVED, this); + pItem2->SetState(ITEM_CHANGED, this); + + ApplyEquipCooldown(pItem2); + + return pItem2; + } + } + + return pItem; +} + +void Player::QuickEquipItem( uint16 pos, Item *pItem) +{ + if( pItem ) + { + AddEnchantmentDurations(pItem); + AddItemDurations(pItem); + + uint8 slot = pos & 255; + VisualizeItem( slot, pItem); + + if( IsInWorld() ) + { + pItem->AddToWorld(); + pItem->SendUpdateToPlayer( this ); + } + } +} + +void Player::SetVisibleItemSlot(uint8 slot, Item *pItem) +{ + // PLAYER_VISIBLE_ITEM_i_CREATOR // Size: 2 + // PLAYER_VISIBLE_ITEM_i_0 // Size: 12 + // entry // Size: 1 + // inspected enchantments // Size: 6 + // ? // Size: 5 + // PLAYER_VISIBLE_ITEM_i_PROPERTIES // Size: 1 (property,suffix factor) + // PLAYER_VISIBLE_ITEM_i_PAD // Size: 1 + // // = 16 + + if(pItem) + { + SetUInt64Value(PLAYER_VISIBLE_ITEM_1_CREATOR + (slot * MAX_VISIBLE_ITEM_OFFSET), pItem->GetUInt64Value(ITEM_FIELD_CREATOR)); + + int VisibleBase = PLAYER_VISIBLE_ITEM_1_0 + (slot * MAX_VISIBLE_ITEM_OFFSET); + SetUInt32Value(VisibleBase + 0, pItem->GetEntry()); + + for(int i = 0; i < MAX_INSPECTED_ENCHANTMENT_SLOT; ++i) + SetUInt32Value(VisibleBase + 1 + i, pItem->GetEnchantmentId(EnchantmentSlot(i))); + + // Use SetInt16Value to prevent set high part to FFFF for negative value + SetInt16Value( PLAYER_VISIBLE_ITEM_1_PROPERTIES + (slot * MAX_VISIBLE_ITEM_OFFSET), 0, pItem->GetItemRandomPropertyId()); + SetUInt32Value(PLAYER_VISIBLE_ITEM_1_PROPERTIES + 1 + (slot * MAX_VISIBLE_ITEM_OFFSET), pItem->GetItemSuffixFactor()); + } + else + { + SetUInt64Value(PLAYER_VISIBLE_ITEM_1_CREATOR + (slot * MAX_VISIBLE_ITEM_OFFSET), 0); + + int VisibleBase = PLAYER_VISIBLE_ITEM_1_0 + (slot * MAX_VISIBLE_ITEM_OFFSET); + SetUInt32Value(VisibleBase + 0, 0); + + for(int i = 0; i < MAX_INSPECTED_ENCHANTMENT_SLOT; ++i) + SetUInt32Value(VisibleBase + 1 + i, 0); + + SetUInt32Value(PLAYER_VISIBLE_ITEM_1_PROPERTIES + 0 + (slot * MAX_VISIBLE_ITEM_OFFSET), 0); + SetUInt32Value(PLAYER_VISIBLE_ITEM_1_PROPERTIES + 1 + (slot * MAX_VISIBLE_ITEM_OFFSET), 0); + } +} + +void Player::VisualizeItem( uint8 slot, Item *pItem) +{ + if(!pItem) + return; + + // check also BIND_WHEN_PICKED_UP and BIND_QUEST_ITEM for .additem or .additemset case by GM (not binded at adding to inventory) + if( pItem->GetProto()->Bonding == BIND_WHEN_EQUIPED || pItem->GetProto()->Bonding == BIND_WHEN_PICKED_UP || pItem->GetProto()->Bonding == BIND_QUEST_ITEM ) + pItem->SetBinding( true ); + + sLog.outDebug( "STORAGE: EquipItem slot = %u, item = %u", slot, pItem->GetEntry()); + + m_items[slot] = pItem; + SetUInt64Value( (uint16)(PLAYER_FIELD_INV_SLOT_HEAD + (slot * 2) ), pItem->GetGUID() ); + pItem->SetUInt64Value( ITEM_FIELD_CONTAINED, GetGUID() ); + pItem->SetUInt64Value( ITEM_FIELD_OWNER, GetGUID() ); + pItem->SetSlot( slot ); + pItem->SetContainer( NULL ); + + if( slot < EQUIPMENT_SLOT_END ) + SetVisibleItemSlot(slot,pItem); + + pItem->SetState(ITEM_CHANGED, this); +} + +void Player::RemoveItem( uint8 bag, uint8 slot, bool update ) +{ + // note: removeitem does not actually change the item + // it only takes the item out of storage temporarily + // note2: if removeitem is to be used for delinking + // the item must be removed from the player's updatequeue + + Item *pItem = GetItemByPos( bag, slot ); + if( pItem ) + { + sLog.outDebug( "STORAGE: RemoveItem bag = %u, slot = %u, item = %u", bag, slot, pItem->GetEntry()); + + RemoveEnchantmentDurations(pItem); + RemoveItemDurations(pItem); + + if( bag == INVENTORY_SLOT_BAG_0 ) + { + if ( slot < INVENTORY_SLOT_BAG_END ) + { + ItemPrototype const *pProto = pItem->GetProto(); + // item set bonuses applied only at equip and removed at unequip, and still active for broken items + + if(pProto && pProto->ItemSet) + RemoveItemsSetItem(this,pProto); + + _ApplyItemMods(pItem, slot, false); + + // remove item dependent auras and casts (only weapon and armor slots) + if(slot < EQUIPMENT_SLOT_END) + RemoveItemDependentAurasAndCasts(pItem); + + // remove held enchantments + if ( slot == EQUIPMENT_SLOT_MAINHAND ) + { + if (pItem->GetItemSuffixFactor()) + { + pItem->ClearEnchantment(PROP_ENCHANTMENT_SLOT_3); + pItem->ClearEnchantment(PROP_ENCHANTMENT_SLOT_4); + } + else + { + pItem->ClearEnchantment(PROP_ENCHANTMENT_SLOT_0); + pItem->ClearEnchantment(PROP_ENCHANTMENT_SLOT_1); + } + } + } + + m_items[slot] = NULL; + SetUInt64Value((uint16)(PLAYER_FIELD_INV_SLOT_HEAD + (slot*2)), 0); + + if ( slot < EQUIPMENT_SLOT_END ) + SetVisibleItemSlot(slot,NULL); + } + else + { + Bag *pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, bag ); + if( pBag ) + pBag->RemoveItem(slot, update); + } + pItem->SetUInt64Value( ITEM_FIELD_CONTAINED, 0 ); + // pItem->SetUInt64Value( ITEM_FIELD_OWNER, 0 ); not clear owner at remove (it will be set at store). This used in mail and auction code + pItem->SetSlot( NULL_SLOT ); + if( IsInWorld() && update ) + pItem->SendUpdateToPlayer( this ); + + if( slot == EQUIPMENT_SLOT_MAINHAND ) + UpdateExpertise(BASE_ATTACK); + else if( slot == EQUIPMENT_SLOT_OFFHAND ) + UpdateExpertise(OFF_ATTACK); + } +} + +// Common operation need to remove item from inventory without delete in trade, auction, guild bank, mail.... +void Player::MoveItemFromInventory(uint8 bag, uint8 slot, bool update) +{ + if(Item* it = GetItemByPos(bag,slot)) + { + ItemRemovedQuestCheck(it->GetEntry(),it->GetCount()); + RemoveItem( bag,slot,update); + it->RemoveFromUpdateQueueOf(this); + if(it->IsInWorld()) + { + it->RemoveFromWorld(); + it->DestroyForPlayer( this ); + } + } +} + +// Common operation need to add item from inventory without delete in trade, guild bank, mail.... +void Player::MoveItemToInventory(ItemPosCountVec const& dest, Item* pItem, bool update, bool in_characterInventoryDB) +{ + // update quest counters + ItemAddedQuestCheck(pItem->GetEntry(),pItem->GetCount()); + + // store item + Item* pLastItem = StoreItem( dest, pItem, update); + + // only set if not merged to existed stack (pItem can be deleted already but we can compare pointers any way) + if(pLastItem==pItem) + { + // update owner for last item (this can be original item with wrong owner + if(pLastItem->GetOwnerGUID() != GetGUID()) + pLastItem->SetOwnerGUID(GetGUID()); + + // if this original item then it need create record in inventory + // in case trade we laready have item in other player inventory + pLastItem->SetState(in_characterInventoryDB ? ITEM_CHANGED : ITEM_NEW, this); + } +} + +void Player::DestroyItem( uint8 bag, uint8 slot, bool update ) +{ + Item *pItem = GetItemByPos( bag, slot ); + if( pItem ) + { + sLog.outDebug( "STORAGE: DestroyItem bag = %u, slot = %u, item = %u", bag, slot, pItem->GetEntry()); + + // start from destroy contained items (only equipped bag can have its) + if (pItem->IsBag() && pItem->IsEquipped()) // this also prevent infinity loop if empty bag stored in bag==slot + { + for (int i = 0; i < MAX_BAG_SIZE; i++) + DestroyItem(slot,i,update); + } + + if(pItem->HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAGS_WRAPPED)) + CharacterDatabase.PExecute("DELETE FROM character_gifts WHERE item_guid = '%u'", pItem->GetGUIDLow()); + + ItemPrototype const *pProto = pItem->GetProto(); + + RemoveEnchantmentDurations(pItem); + RemoveItemDurations(pItem); + + ItemRemovedQuestCheck( pItem->GetEntry(), pItem->GetCount() ); + + if( bag == INVENTORY_SLOT_BAG_0 ) + { + + SetUInt64Value((uint16)(PLAYER_FIELD_INV_SLOT_HEAD + (slot*2)), 0); + + // equipment and equipped bags can have applied bonuses + if ( slot < INVENTORY_SLOT_BAG_END ) + { + ItemPrototype const *pProto = pItem->GetProto(); + + // item set bonuses applied only at equip and removed at unequip, and still active for broken items + if(pProto && pProto->ItemSet) + RemoveItemsSetItem(this,pProto); + + _ApplyItemMods(pItem, slot, false); + } + + if ( slot < EQUIPMENT_SLOT_END ) + { + // remove item dependent auras and casts (only weapon and armor slots) + RemoveItemDependentAurasAndCasts(pItem); + + // equipment visual show + SetVisibleItemSlot(slot,NULL); + } + + m_items[slot] = NULL; + } + else if(Bag *pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, bag )) + pBag->RemoveItem(slot, update); + + if( IsInWorld() && update ) + { + pItem->RemoveFromWorld(); + pItem->DestroyForPlayer(this); + } + + //pItem->SetOwnerGUID(0); + pItem->SetUInt64Value( ITEM_FIELD_CONTAINED, 0 ); + pItem->SetSlot( NULL_SLOT ); + pItem->SetState(ITEM_REMOVED, this); + } +} + +void Player::DestroyItemCount( uint32 item, uint32 count, bool update, bool unequip_check) +{ + sLog.outDebug( "STORAGE: DestroyItemCount item = %u, count = %u", item, count); + Item *pItem; + ItemPrototype const *pProto; + uint32 remcount = 0; + + // in inventory + for(int i = INVENTORY_SLOT_ITEM_START; i < INVENTORY_SLOT_ITEM_END; i++) + { + pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i ); + if( pItem && pItem->GetEntry() == item ) + { + if( pItem->GetCount() + remcount <= count ) + { + // all items in inventory can unequipped + remcount += pItem->GetCount(); + DestroyItem( INVENTORY_SLOT_BAG_0, i, update); + + if(remcount >=count) + return; + } + else + { + pProto = pItem->GetProto(); + ItemRemovedQuestCheck( pItem->GetEntry(), count - remcount ); + pItem->SetCount( pItem->GetCount() - count + remcount ); + if( IsInWorld() & update ) + pItem->SendUpdateToPlayer( this ); + pItem->SetState(ITEM_CHANGED, this); + return; + } + } + } + for(int i = KEYRING_SLOT_START; i < KEYRING_SLOT_END; i++) + { + pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i ); + if( pItem && pItem->GetEntry() == item ) + { + if( pItem->GetCount() + remcount <= count ) + { + // all keys can be unequipped + remcount += pItem->GetCount(); + DestroyItem( INVENTORY_SLOT_BAG_0, i, update); + + if(remcount >=count) + return; + } + else + { + pProto = pItem->GetProto(); + ItemRemovedQuestCheck( pItem->GetEntry(), count - remcount ); + pItem->SetCount( pItem->GetCount() - count + remcount ); + if( IsInWorld() & update ) + pItem->SendUpdateToPlayer( this ); + pItem->SetState(ITEM_CHANGED, this); + return; + } + } + } + + // in inventory bags + Bag *pBag; + ItemPrototype const *pBagProto; + for(int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; i++) + { + pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i ); + if( pBag ) + { + pBagProto = pBag->GetProto(); + if( pBagProto ) + { + for(uint32 j = 0; j < pBagProto->ContainerSlots; j++) + { + pItem = pBag->GetItemByPos(j); + if( pItem && pItem->GetEntry() == item ) + { + // all items in bags can be unequipped + if( pItem->GetCount() + remcount <= count ) + { + remcount += pItem->GetCount(); + DestroyItem( i, j, update ); + + if(remcount >=count) + return; + } + else + { + pProto = pItem->GetProto(); + ItemRemovedQuestCheck( pItem->GetEntry(), count - remcount ); + pItem->SetCount( pItem->GetCount() - count + remcount ); + if( IsInWorld() && update ) + pItem->SendUpdateToPlayer( this ); + pItem->SetState(ITEM_CHANGED, this); + return; + } + } + } + } + } + } + + // in equipment and bag list + for(int i = EQUIPMENT_SLOT_START; i < INVENTORY_SLOT_BAG_END; i++) + { + pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i ); + if( pItem && pItem->GetEntry() == item ) + { + if( pItem->GetCount() + remcount <= count ) + { + if(!unequip_check || CanUnequipItem(INVENTORY_SLOT_BAG_0 << 8 | i,false) == EQUIP_ERR_OK ) + { + remcount += pItem->GetCount(); + DestroyItem( INVENTORY_SLOT_BAG_0, i, update); + + if(remcount >=count) + return; + } + } + else + { + pProto = pItem->GetProto(); + ItemRemovedQuestCheck( pItem->GetEntry(), count - remcount ); + pItem->SetCount( pItem->GetCount() - count + remcount ); + if( IsInWorld() & update ) + pItem->SendUpdateToPlayer( this ); + pItem->SetState(ITEM_CHANGED, this); + return; + } + } + } +} + +void Player::DestroyZoneLimitedItem( bool update, uint32 new_zone ) +{ + sLog.outDebug( "STORAGE: DestroyZoneLimitedItem in map %u and area %u", GetMapId(), new_zone ); + + // in inventory + for(int i = INVENTORY_SLOT_ITEM_START; i < INVENTORY_SLOT_ITEM_END; i++) + { + Item* pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i ); + if( pItem && pItem->IsLimitedToAnotherMapOrZone(GetMapId(),new_zone) ) + DestroyItem( INVENTORY_SLOT_BAG_0, i, update); + } + for(int i = KEYRING_SLOT_START; i < KEYRING_SLOT_END; i++) + { + Item* pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i ); + if( pItem && pItem->IsLimitedToAnotherMapOrZone(GetMapId(),new_zone) ) + DestroyItem( INVENTORY_SLOT_BAG_0, i, update); + } + + // in inventory bags + for(int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; i++) + { + Bag* pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i ); + if( pBag ) + { + ItemPrototype const *pBagProto = pBag->GetProto(); + if( pBagProto ) + { + for(uint32 j = 0; j < pBagProto->ContainerSlots; j++) + { + Item* pItem = pBag->GetItemByPos(j); + if( pItem && pItem->IsLimitedToAnotherMapOrZone(GetMapId(),new_zone) ) + DestroyItem( i, j, update); + } + } + } + } + + // in equipment and bag list + for(int i = EQUIPMENT_SLOT_START; i < INVENTORY_SLOT_BAG_END; i++) + { + Item* pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i ); + if( pItem && pItem->IsLimitedToAnotherMapOrZone(GetMapId(),new_zone) ) + DestroyItem( INVENTORY_SLOT_BAG_0, i, update); + } +} + +void Player::DestroyConjuredItems( bool update ) +{ + // used when entering arena + // distroys all conjured items + sLog.outDebug( "STORAGE: DestroyConjuredItems" ); + + // in inventory + for(int i = INVENTORY_SLOT_ITEM_START; i < INVENTORY_SLOT_ITEM_END; i++) + { + Item* pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i ); + if( pItem && pItem->GetProto() && + (pItem->GetProto()->Class == ITEM_CLASS_CONSUMABLE) && + (pItem->GetProto()->Flags & ITEM_FLAGS_CONJURED) ) + DestroyItem( INVENTORY_SLOT_BAG_0, i, update); + } + + // in inventory bags + for(int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; i++) + { + Bag* pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i ); + if( pBag ) + { + ItemPrototype const *pBagProto = pBag->GetProto(); + if( pBagProto ) + { + for(uint32 j = 0; j < pBagProto->ContainerSlots; j++) + { + Item* pItem = pBag->GetItemByPos(j); + if( pItem && pItem->GetProto() && + (pItem->GetProto()->Class == ITEM_CLASS_CONSUMABLE) && + (pItem->GetProto()->Flags & ITEM_FLAGS_CONJURED) ) + DestroyItem( i, j, update); + } + } + } + } + + // in equipment and bag list + for(int i = EQUIPMENT_SLOT_START; i < INVENTORY_SLOT_BAG_END; i++) + { + Item* pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i ); + if( pItem && pItem->GetProto() && + (pItem->GetProto()->Class == ITEM_CLASS_CONSUMABLE) && + (pItem->GetProto()->Flags & ITEM_FLAGS_CONJURED) ) + DestroyItem( INVENTORY_SLOT_BAG_0, i, update); + } +} + +void Player::DestroyItemCount( Item* pItem, uint32 &count, bool update ) +{ + if(!pItem) + return; + + sLog.outDebug( "STORAGE: DestroyItemCount item (GUID: %u, Entry: %u) count = %u", pItem->GetGUIDLow(),pItem->GetEntry(), count); + + if( pItem->GetCount() <= count ) + { + count-= pItem->GetCount(); + + DestroyItem( pItem->GetBagSlot(),pItem->GetSlot(), update); + } + else + { + ItemRemovedQuestCheck( pItem->GetEntry(), count); + pItem->SetCount( pItem->GetCount() - count ); + count = 0; + if( IsInWorld() & update ) + pItem->SendUpdateToPlayer( this ); + pItem->SetState(ITEM_CHANGED, this); + } +} + +void Player::SplitItem( uint16 src, uint16 dst, uint32 count ) +{ + uint8 srcbag = src >> 8; + uint8 srcslot = src & 255; + + uint8 dstbag = dst >> 8; + uint8 dstslot = dst & 255; + + Item *pSrcItem = GetItemByPos( srcbag, srcslot ); + if( !pSrcItem ) + { + SendEquipError( EQUIP_ERR_ITEM_NOT_FOUND, pSrcItem, NULL ); + return; + } + + // not let split all items (can be only at cheating) + if(pSrcItem->GetCount() == count) + { + SendEquipError( EQUIP_ERR_COULDNT_SPLIT_ITEMS, pSrcItem, NULL ); + return; + } + + // not let split more existed items (can be only at cheating) + if(pSrcItem->GetCount() < count) + { + SendEquipError( EQUIP_ERR_TRIED_TO_SPLIT_MORE_THAN_COUNT, pSrcItem, NULL ); + return; + } + + if(pSrcItem->m_lootGenerated) // prevent split looting item (item + { + //best error message found for attempting to split while looting + SendEquipError( EQUIP_ERR_COULDNT_SPLIT_ITEMS, pSrcItem, NULL ); + return; + } + + sLog.outDebug( "STORAGE: SplitItem bag = %u, slot = %u, item = %u, count = %u", dstbag, dstslot, pSrcItem->GetEntry(), count); + Item *pNewItem = pSrcItem->CloneItem( count, this ); + if( !pNewItem ) + { + SendEquipError( EQUIP_ERR_ITEM_NOT_FOUND, pSrcItem, NULL ); + return; + } + + if( IsInventoryPos( dst ) ) + { + // change item amount before check (for unique max count check) + pSrcItem->SetCount( pSrcItem->GetCount() - count ); + + ItemPosCountVec dest; + uint8 msg = CanStoreItem( dstbag, dstslot, dest, pNewItem, false ); + if( msg != EQUIP_ERR_OK ) + { + delete pNewItem; + pSrcItem->SetCount( pSrcItem->GetCount() + count ); + SendEquipError( msg, pSrcItem, NULL ); + return; + } + + if( IsInWorld() ) + pSrcItem->SendUpdateToPlayer( this ); + pSrcItem->SetState(ITEM_CHANGED, this); + StoreItem( dest, pNewItem, true); + } + else if( IsBankPos ( dst ) ) + { + // change item amount before check (for unique max count check) + pSrcItem->SetCount( pSrcItem->GetCount() - count ); + + ItemPosCountVec dest; + uint8 msg = CanBankItem( dstbag, dstslot, dest, pNewItem, false ); + if( msg != EQUIP_ERR_OK ) + { + delete pNewItem; + pSrcItem->SetCount( pSrcItem->GetCount() + count ); + SendEquipError( msg, pSrcItem, NULL ); + return; + } + + if( IsInWorld() ) + pSrcItem->SendUpdateToPlayer( this ); + pSrcItem->SetState(ITEM_CHANGED, this); + BankItem( dest, pNewItem, true); + } + else if( IsEquipmentPos ( dst ) ) + { + // change item amount before check (for unique max count check), provide space for splitted items + pSrcItem->SetCount( pSrcItem->GetCount() - count ); + + uint16 dest; + uint8 msg = CanEquipItem( dstslot, dest, pNewItem, false ); + if( msg != EQUIP_ERR_OK ) + { + delete pNewItem; + pSrcItem->SetCount( pSrcItem->GetCount() + count ); + SendEquipError( msg, pSrcItem, NULL ); + return; + } + + if( IsInWorld() ) + pSrcItem->SendUpdateToPlayer( this ); + pSrcItem->SetState(ITEM_CHANGED, this); + EquipItem( dest, pNewItem, true); + AutoUnequipOffhandIfNeed(); + } +} + +void Player::SwapItem( uint16 src, uint16 dst ) +{ + uint8 srcbag = src >> 8; + uint8 srcslot = src & 255; + + uint8 dstbag = dst >> 8; + uint8 dstslot = dst & 255; + + Item *pSrcItem = GetItemByPos( srcbag, srcslot ); + Item *pDstItem = GetItemByPos( dstbag, dstslot ); + + if( !pSrcItem ) + return; + + sLog.outDebug( "STORAGE: SwapItem bag = %u, slot = %u, item = %u", dstbag, dstslot, pSrcItem->GetEntry()); + + if(!isAlive() ) + { + SendEquipError( EQUIP_ERR_YOU_ARE_DEAD, pSrcItem, pDstItem ); + return; + } + + if(pSrcItem->m_lootGenerated) // prevent swap looting item + { + //best error message found for attempting to swap while looting + SendEquipError( EQUIP_ERR_CANT_DO_RIGHT_NOW, pSrcItem, NULL ); + return; + } + + // check unequip potability for equipped items and bank bags + if(IsEquipmentPos ( src ) || IsBagPos ( src )) + { + // bags can be swapped with empty bag slots + uint8 msg = CanUnequipItem( src, !IsBagPos ( src ) || IsBagPos ( dst )); + if(msg != EQUIP_ERR_OK) + { + SendEquipError( msg, pSrcItem, pDstItem ); + return; + } + } + + // prevent put equipped/bank bag in self + if( IsBagPos ( src ) && srcslot == dstbag) + { + SendEquipError( EQUIP_ERR_NONEMPTY_BAG_OVER_OTHER_BAG, pSrcItem, pDstItem ); + return; + } + + if( !pDstItem ) + { + if( IsInventoryPos( dst ) ) + { + ItemPosCountVec dest; + uint8 msg = CanStoreItem( dstbag, dstslot, dest, pSrcItem, false ); + if( msg != EQUIP_ERR_OK ) + { + SendEquipError( msg, pSrcItem, NULL ); + return; + } + + RemoveItem(srcbag, srcslot, true); + StoreItem( dest, pSrcItem, true); + } + else if( IsBankPos ( dst ) ) + { + ItemPosCountVec dest; + uint8 msg = CanBankItem( dstbag, dstslot, dest, pSrcItem, false); + if( msg != EQUIP_ERR_OK ) + { + SendEquipError( msg, pSrcItem, NULL ); + return; + } + + RemoveItem(srcbag, srcslot, true); + BankItem( dest, pSrcItem, true); + } + else if( IsEquipmentPos ( dst ) ) + { + uint16 dest; + uint8 msg = CanEquipItem( dstslot, dest, pSrcItem, false ); + if( msg != EQUIP_ERR_OK ) + { + SendEquipError( msg, pSrcItem, NULL ); + return; + } + + RemoveItem(srcbag, srcslot, true); + EquipItem( dest, pSrcItem, true); + AutoUnequipOffhandIfNeed(); + } + } + else // if (!pDstItem) + { + if(pDstItem->m_lootGenerated) // prevent swap looting item + { + //best error message found for attempting to swap while looting + SendEquipError( EQUIP_ERR_CANT_DO_RIGHT_NOW, pDstItem, NULL ); + return; + } + + // check unequip potability for equipped items and bank bags + if(IsEquipmentPos ( dst ) || IsBagPos ( dst )) + { + // bags can be swapped with empty bag slots + uint8 msg = CanUnequipItem( dst, !IsBagPos ( dst ) || IsBagPos ( src ) ); + if(msg != EQUIP_ERR_OK) + { + SendEquipError( msg, pSrcItem, pDstItem ); + return; + } + } + + // attempt merge to / fill target item + { + uint8 msg; + ItemPosCountVec sDest; + uint16 eDest; + if( IsInventoryPos( dst ) ) + msg = CanStoreItem( dstbag, dstslot, sDest, pSrcItem, false ); + else if( IsBankPos ( dst ) ) + msg = CanBankItem( dstbag, dstslot, sDest, pSrcItem, false ); + else if( IsEquipmentPos ( dst ) ) + msg = CanEquipItem( dstslot, eDest, pSrcItem, false ); + else + return; + + // can be merge/fill + if(msg == EQUIP_ERR_OK) + { + if( pSrcItem->GetCount() + pDstItem->GetCount() <= pSrcItem->GetProto()->Stackable ) + { + RemoveItem(srcbag, srcslot, true); + + if( IsInventoryPos( dst ) ) + StoreItem( sDest, pSrcItem, true); + else if( IsBankPos ( dst ) ) + BankItem( sDest, pSrcItem, true); + else if( IsEquipmentPos ( dst ) ) + { + EquipItem( eDest, pSrcItem, true); + AutoUnequipOffhandIfNeed(); + } + } + else + { + pSrcItem->SetCount( pSrcItem->GetCount() + pDstItem->GetCount() - pSrcItem->GetProto()->Stackable ); + pDstItem->SetCount( pSrcItem->GetProto()->Stackable ); + pSrcItem->SetState(ITEM_CHANGED, this); + pDstItem->SetState(ITEM_CHANGED, this); + if( IsInWorld() ) + { + pSrcItem->SendUpdateToPlayer( this ); + pDstItem->SendUpdateToPlayer( this ); + } + } + return; + } + } + + // impossible merge/fill, do real swap + uint8 msg; + + // check src->dest move possibility + ItemPosCountVec sDest; + uint16 eDest; + if( IsInventoryPos( dst ) ) + msg = CanStoreItem( dstbag, dstslot, sDest, pSrcItem, true ); + else if( IsBankPos( dst ) ) + msg = CanBankItem( dstbag, dstslot, sDest, pSrcItem, true ); + else if( IsEquipmentPos( dst ) ) + { + msg = CanEquipItem( dstslot, eDest, pSrcItem, true ); + if( msg == EQUIP_ERR_OK ) + msg = CanUnequipItem( eDest, true ); + } + + if( msg != EQUIP_ERR_OK ) + { + SendEquipError( msg, pSrcItem, pDstItem ); + return; + } + + // check dest->src move possibility + ItemPosCountVec sDest2; + uint16 eDest2; + if( IsInventoryPos( src ) ) + msg = CanStoreItem( srcbag, srcslot, sDest2, pDstItem, true ); + else if( IsBankPos( src ) ) + msg = CanBankItem( srcbag, srcslot, sDest2, pDstItem, true ); + else if( IsEquipmentPos( src ) ) + { + msg = CanEquipItem( srcslot, eDest2, pDstItem, true); + if( msg == EQUIP_ERR_OK ) + msg = CanUnequipItem( eDest2, true); + } + + if( msg != EQUIP_ERR_OK ) + { + SendEquipError( msg, pDstItem, pSrcItem ); + return; + } + + // now do moves, remove... + RemoveItem(dstbag, dstslot, false); + RemoveItem(srcbag, srcslot, false); + + // add to dest + if( IsInventoryPos( dst ) ) + StoreItem(sDest, pSrcItem, true); + else if( IsBankPos( dst ) ) + BankItem(sDest, pSrcItem, true); + else if( IsEquipmentPos( dst ) ) + EquipItem(eDest, pSrcItem, true); + + // add to src + if( IsInventoryPos( src ) ) + StoreItem(sDest2, pDstItem, true); + else if( IsBankPos( src ) ) + BankItem(sDest2, pDstItem, true); + else if( IsEquipmentPos( src ) ) + EquipItem(eDest2, pDstItem, true); + + AutoUnequipOffhandIfNeed(); + } +} + +void Player::AddItemToBuyBackSlot( Item *pItem ) +{ + if( pItem ) + { + uint32 slot = m_currentBuybackSlot; + // if current back slot non-empty search oldest or free + if(m_items[slot]) + { + uint32 oldest_time = GetUInt32Value( PLAYER_FIELD_BUYBACK_TIMESTAMP_1 ); + uint32 oldest_slot = BUYBACK_SLOT_START; + + for(uint32 i = BUYBACK_SLOT_START+1; i < BUYBACK_SLOT_END; ++i ) + { + // found empty + if(!m_items[i]) + { + slot = i; + break; + } + + uint32 i_time = GetUInt32Value( PLAYER_FIELD_BUYBACK_TIMESTAMP_1 + i - BUYBACK_SLOT_START); + + if(oldest_time > i_time) + { + oldest_time = i_time; + oldest_slot = i; + } + } + + // find oldest + slot = oldest_slot; + } + + RemoveItemFromBuyBackSlot( slot, true ); + sLog.outDebug( "STORAGE: AddItemToBuyBackSlot item = %u, slot = %u", pItem->GetEntry(), slot); + + m_items[slot] = pItem; + time_t base = time(NULL); + uint32 etime = uint32(base - m_logintime + (30 * 3600)); + uint32 eslot = slot - BUYBACK_SLOT_START; + + SetUInt64Value( PLAYER_FIELD_VENDORBUYBACK_SLOT_1 + eslot * 2, pItem->GetGUID() ); + ItemPrototype const *pProto = pItem->GetProto(); + if( pProto ) + SetUInt32Value( PLAYER_FIELD_BUYBACK_PRICE_1 + eslot, pProto->SellPrice * pItem->GetCount() ); + else + SetUInt32Value( PLAYER_FIELD_BUYBACK_PRICE_1 + eslot, 0 ); + SetUInt32Value( PLAYER_FIELD_BUYBACK_TIMESTAMP_1 + eslot, (uint32)etime ); + + // move to next (for non filled list is move most optimized choice) + if(m_currentBuybackSlot < BUYBACK_SLOT_END-1) + ++m_currentBuybackSlot; + } +} + +Item* Player::GetItemFromBuyBackSlot( uint32 slot ) +{ + sLog.outDebug( "STORAGE: GetItemFromBuyBackSlot slot = %u", slot); + if( slot >= BUYBACK_SLOT_START && slot < BUYBACK_SLOT_END ) + return m_items[slot]; + return NULL; +} + +void Player::RemoveItemFromBuyBackSlot( uint32 slot, bool del ) +{ + sLog.outDebug( "STORAGE: RemoveItemFromBuyBackSlot slot = %u", slot); + if( slot >= BUYBACK_SLOT_START && slot < BUYBACK_SLOT_END ) + { + Item *pItem = m_items[slot]; + if( pItem ) + { + pItem->RemoveFromWorld(); + if(del) pItem->SetState(ITEM_REMOVED, this); + } + + m_items[slot] = NULL; + + uint32 eslot = slot - BUYBACK_SLOT_START; + SetUInt64Value( PLAYER_FIELD_VENDORBUYBACK_SLOT_1 + eslot * 2, 0 ); + SetUInt32Value( PLAYER_FIELD_BUYBACK_PRICE_1 + eslot, 0 ); + SetUInt32Value( PLAYER_FIELD_BUYBACK_TIMESTAMP_1 + eslot, 0 ); + + // if current backslot is filled set to now free slot + if(m_items[m_currentBuybackSlot]) + m_currentBuybackSlot = slot; + } +} + +void Player::SendEquipError( uint8 msg, Item* pItem, Item *pItem2 ) +{ + sLog.outDebug( "WORLD: Sent SMSG_INVENTORY_CHANGE_FAILURE (%u)",msg); + WorldPacket data( SMSG_INVENTORY_CHANGE_FAILURE, (msg == EQUIP_ERR_CANT_EQUIP_LEVEL_I ? 22 : 18) ); + data << uint8(msg); + + if(msg) + { + data << uint64(pItem ? pItem->GetGUID() : 0); + data << uint64(pItem2 ? pItem2->GetGUID() : 0); + data << uint8(0); // not 0 there... + + if(msg == EQUIP_ERR_CANT_EQUIP_LEVEL_I) + { + uint32 level = 0; + + if(pItem) + if(ItemPrototype const* proto = pItem->GetProto()) + level = proto->RequiredLevel; + + data << uint32(level); // new 2.4.0 + } + } + GetSession()->SendPacket(&data); +} + +void Player::SendBuyError( uint8 msg, Creature* pCreature, uint32 item, uint32 param ) +{ + sLog.outDebug( "WORLD: Sent SMSG_BUY_FAILED" ); + WorldPacket data( SMSG_BUY_FAILED, (8+4+4+1) ); + data << uint64(pCreature ? pCreature->GetGUID() : 0); + data << uint32(item); + if( param > 0 ) + data << uint32(param); + data << uint8(msg); + GetSession()->SendPacket(&data); +} + +void Player::SendSellError( uint8 msg, Creature* pCreature, uint64 guid, uint32 param ) +{ + sLog.outDebug( "WORLD: Sent SMSG_SELL_ITEM" ); + WorldPacket data( SMSG_SELL_ITEM,(8+8+(param?4:0)+1)); // last check 2.0.10 + data << uint64(pCreature ? pCreature->GetGUID() : 0); + data << uint64(guid); + if( param > 0 ) + data << uint32(param); + data << uint8(msg); + GetSession()->SendPacket(&data); +} + +void Player::ClearTrade() +{ + tradeGold = 0; + acceptTrade = false; + for(int i = 0; i < TRADE_SLOT_COUNT; i++) + tradeItems[i] = NULL_SLOT; +} + +void Player::TradeCancel(bool sendback) +{ + if(pTrader) + { + // send yellow "Trade cancelled" message to both traders + WorldSession* ws; + ws = GetSession(); + if(sendback) + ws->SendCancelTrade(); + ws = pTrader->GetSession(); + if(!ws->PlayerLogout()) + ws->SendCancelTrade(); + + // cleanup + ClearTrade(); + pTrader->ClearTrade(); + // prevent loss of reference + pTrader->pTrader = NULL; + pTrader = NULL; + } +} + +void Player::UpdateItemDuration(uint32 time, bool realtimeonly) +{ + if(m_itemDuration.empty()) + return; + + sLog.outDebug("Player::UpdateItemDuration(%u,%u)", time,realtimeonly); + + for(ItemDurationList::iterator itr = m_itemDuration.begin();itr != m_itemDuration.end(); ) + { + Item* item = *itr; + ++itr; // current element can be erased in UpdateDuration + + if (realtimeonly && item->GetProto()->Duration < 0 || !realtimeonly) + item->UpdateDuration(this,time); + } +} + +void Player::UpdateEnchantTime(uint32 time) +{ + for(EnchantDurationList::iterator itr = m_enchantDuration.begin(),next;itr != m_enchantDuration.end();itr=next) + { + assert(itr->item); + next=itr; + if(!itr->item->GetEnchantmentId(itr->slot)) + { + next = m_enchantDuration.erase(itr); + } + else if(itr->leftduration <= time) + { + ApplyEnchantment(itr->item,itr->slot,false,false); + itr->item->ClearEnchantment(itr->slot); + next = m_enchantDuration.erase(itr); + } + else if(itr->leftduration > time) + { + itr->leftduration -= time; + ++next; + } + } +} + +void Player::AddEnchantmentDurations(Item *item) +{ + for(int x=0;xGetEnchantmentId(EnchantmentSlot(x))) + continue; + + uint32 duration = item->GetEnchantmentDuration(EnchantmentSlot(x)); + if( duration > 0 ) + AddEnchantmentDuration(item,EnchantmentSlot(x),duration); + } +} + +void Player::RemoveEnchantmentDurations(Item *item) +{ + for(EnchantDurationList::iterator itr = m_enchantDuration.begin();itr != m_enchantDuration.end();) + { + if(itr->item == item) + { + // save duration in item + item->SetEnchantmentDuration(EnchantmentSlot(itr->slot),itr->leftduration); + itr = m_enchantDuration.erase(itr); + } + else + ++itr; + } +} + + +void Player::RemoveAllEnchantments(EnchantmentSlot slot) +{ + // remove enchantments from equipped items first to clean up the m_enchantDuration list + for(EnchantDurationList::iterator itr = m_enchantDuration.begin(),next;itr != m_enchantDuration.end();itr=next) + { + next = itr; + if(itr->slot==slot) + { + if(itr->item && itr->item->GetEnchantmentId(slot)) + { + // remove from stats + ApplyEnchantment(itr->item,slot,false,false); + // remove visual + itr->item->ClearEnchantment(slot); + } + // remove from update list + next = m_enchantDuration.erase(itr); + } + else + ++next; + } + + // remove enchants from inventory items + // NOTE: no need to remove these from stats, since these aren't equipped + // in inventory + for(int i = INVENTORY_SLOT_ITEM_START; i < INVENTORY_SLOT_ITEM_END; i++) + { + Item* pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i ); + if( pItem && pItem->GetEnchantmentId(slot) ) + pItem->ClearEnchantment(slot); + } + + // in inventory bags + for(int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; i++) + { + Bag* pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i ); + if( pBag ) + { + ItemPrototype const *pBagProto = pBag->GetProto(); + if( pBagProto ) + { + for(uint32 j = 0; j < pBagProto->ContainerSlots; j++) + { + Item* pItem = pBag->GetItemByPos(j); + if( pItem && pItem->GetEnchantmentId(slot) ) + pItem->ClearEnchantment(slot); + } + } + } + } +} + +// duration == 0 will remove item enchant +void Player::AddEnchantmentDuration(Item *item,EnchantmentSlot slot,uint32 duration) +{ + if(!item) + return; + + if(slot >= MAX_ENCHANTMENT_SLOT) + return; + + for(EnchantDurationList::iterator itr = m_enchantDuration.begin();itr != m_enchantDuration.end();++itr) + { + if(itr->item == item && itr->slot == slot) + { + itr->item->SetEnchantmentDuration(itr->slot,itr->leftduration); + m_enchantDuration.erase(itr); + break; + } + } + if(item && duration > 0 ) + { + GetSession()->SendItemEnchantTimeUpdate(GetGUID(), item->GetGUID(),slot,uint32(duration/1000)); + m_enchantDuration.push_back(EnchantDuration(item,slot,duration)); + } +} + +void Player::ApplyEnchantment(Item *item,bool apply) +{ + for(uint32 slot = 0; slot < MAX_ENCHANTMENT_SLOT; ++slot) + ApplyEnchantment(item, EnchantmentSlot(slot), apply); +} + +void Player::ApplyEnchantment(Item *item,EnchantmentSlot slot,bool apply, bool apply_dur, bool ignore_condition) +{ + if(!item) + return; + + if(!item->IsEquipped()) + return; + + if(slot >= MAX_ENCHANTMENT_SLOT) + return; + + uint32 enchant_id = item->GetEnchantmentId(slot); + if(!enchant_id) + return; + + SpellItemEnchantmentEntry const *pEnchant = sSpellItemEnchantmentStore.LookupEntry(enchant_id); + if(!pEnchant) + return; + + if(!ignore_condition && pEnchant->EnchantmentCondition && !((Player*)this)->EnchantmentFitsRequirements(pEnchant->EnchantmentCondition, -1)) + return; + + for (int s=0; s<3; s++) + { + uint32 enchant_display_type = pEnchant->type[s]; + uint32 enchant_amount = pEnchant->amount[s]; + uint32 enchant_spell_id = pEnchant->spellid[s]; + + switch(enchant_display_type) + { + case ITEM_ENCHANTMENT_TYPE_NONE: + break; + case ITEM_ENCHANTMENT_TYPE_COMBAT_SPELL: + // processed in Player::CastItemCombatSpell + break; + case ITEM_ENCHANTMENT_TYPE_DAMAGE: + if (item->GetSlot() == EQUIPMENT_SLOT_MAINHAND) + HandleStatModifier(UNIT_MOD_DAMAGE_MAINHAND, TOTAL_VALUE, float(enchant_amount), apply); + else if (item->GetSlot() == EQUIPMENT_SLOT_OFFHAND) + HandleStatModifier(UNIT_MOD_DAMAGE_OFFHAND, TOTAL_VALUE, float(enchant_amount), apply); + else if (item->GetSlot() == EQUIPMENT_SLOT_RANGED) + HandleStatModifier(UNIT_MOD_DAMAGE_RANGED, TOTAL_VALUE, float(enchant_amount), apply); + break; + case ITEM_ENCHANTMENT_TYPE_EQUIP_SPELL: + if(enchant_spell_id) + { + if(apply) + { + int32 basepoints = int32(enchant_amount); + // Random Property Exist - try found basepoints for spell (basepoints depencs from item suffix factor) + if (item->GetItemRandomPropertyId() !=0 && !enchant_amount) + { + ItemRandomSuffixEntry const *item_rand = sItemRandomSuffixStore.LookupEntry(abs(item->GetItemRandomPropertyId())); + if (item_rand) + { + // Search enchant_amount + for (int k=0; k<3; k++) + { + if(item_rand->enchant_id[k] == enchant_id) + { + basepoints = int32((item_rand->prefix[k]*item->GetItemSuffixFactor()) / 10000 ); + break; + } + } + } + } + // Cast custom spell vs all equal basepoints getted from enchant_amount + if (basepoints) + CastCustomSpell(this,enchant_spell_id,&basepoints,&basepoints,&basepoints,true,item); + else + CastSpell(this,enchant_spell_id,true,item); + } + else + RemoveAurasDueToItemSpell(item,enchant_spell_id); + } + break; + case ITEM_ENCHANTMENT_TYPE_RESISTANCE: + if (!enchant_amount) + { + ItemRandomSuffixEntry const *item_rand = sItemRandomSuffixStore.LookupEntry(abs(item->GetItemRandomPropertyId())); + if(item_rand) + { + for (int k=0; k<3; k++) + { + if(item_rand->enchant_id[k] == enchant_id) + { + enchant_amount = uint32((item_rand->prefix[k]*item->GetItemSuffixFactor()) / 10000 ); + break; + } + } + } + } + + HandleStatModifier(UnitMods(UNIT_MOD_RESISTANCE_START + enchant_spell_id), TOTAL_VALUE, float(enchant_amount), apply); + break; + case ITEM_ENCHANTMENT_TYPE_STAT: + { + if (!enchant_amount) + { + ItemRandomSuffixEntry const *item_rand_suffix = sItemRandomSuffixStore.LookupEntry(abs(item->GetItemRandomPropertyId())); + if(item_rand_suffix) + { + for (int k=0; k<3; k++) + { + if(item_rand_suffix->enchant_id[k] == enchant_id) + { + enchant_amount = uint32((item_rand_suffix->prefix[k]*item->GetItemSuffixFactor()) / 10000 ); + break; + } + } + } + } + + sLog.outDebug("Adding %u to stat nb %u",enchant_amount,enchant_spell_id); + switch (enchant_spell_id) + { + case ITEM_MOD_AGILITY: + sLog.outDebug("+ %u AGILITY",enchant_amount); + HandleStatModifier(UNIT_MOD_STAT_AGILITY, TOTAL_VALUE, float(enchant_amount), apply); + ApplyStatBuffMod(STAT_AGILITY, enchant_amount, apply); + break; + case ITEM_MOD_STRENGTH: + sLog.outDebug("+ %u STRENGTH",enchant_amount); + HandleStatModifier(UNIT_MOD_STAT_STRENGTH, TOTAL_VALUE, float(enchant_amount), apply); + ApplyStatBuffMod(STAT_STRENGTH, enchant_amount, apply); + break; + case ITEM_MOD_INTELLECT: + sLog.outDebug("+ %u INTELLECT",enchant_amount); + HandleStatModifier(UNIT_MOD_STAT_INTELLECT, TOTAL_VALUE, float(enchant_amount), apply); + ApplyStatBuffMod(STAT_INTELLECT, enchant_amount, apply); + break; + case ITEM_MOD_SPIRIT: + sLog.outDebug("+ %u SPIRIT",enchant_amount); + HandleStatModifier(UNIT_MOD_STAT_SPIRIT, TOTAL_VALUE, float(enchant_amount), apply); + ApplyStatBuffMod(STAT_SPIRIT, enchant_amount, apply); + break; + case ITEM_MOD_STAMINA: + sLog.outDebug("+ %u STAMINA",enchant_amount); + HandleStatModifier(UNIT_MOD_STAT_STAMINA, TOTAL_VALUE, float(enchant_amount), apply); + ApplyStatBuffMod(STAT_STAMINA, enchant_amount, apply); + break; + case ITEM_MOD_DEFENSE_SKILL_RATING: + ((Player*)this)->ApplyRatingMod(CR_DEFENSE_SKILL, enchant_amount, apply); + sLog.outDebug("+ %u DEFENCE", enchant_amount); + break; + case ITEM_MOD_DODGE_RATING: + ((Player*)this)->ApplyRatingMod(CR_DODGE, enchant_amount, apply); + sLog.outDebug("+ %u DODGE", enchant_amount); + break; + case ITEM_MOD_PARRY_RATING: + ((Player*)this)->ApplyRatingMod(CR_PARRY, enchant_amount, apply); + sLog.outDebug("+ %u PARRY", enchant_amount); + break; + case ITEM_MOD_BLOCK_RATING: + ((Player*)this)->ApplyRatingMod(CR_BLOCK, enchant_amount, apply); + sLog.outDebug("+ %u SHIELD_BLOCK", enchant_amount); + break; + case ITEM_MOD_HIT_MELEE_RATING: + ((Player*)this)->ApplyRatingMod(CR_HIT_MELEE, enchant_amount, apply); + sLog.outDebug("+ %u MELEE_HIT", enchant_amount); + break; + case ITEM_MOD_HIT_RANGED_RATING: + ((Player*)this)->ApplyRatingMod(CR_HIT_RANGED, enchant_amount, apply); + sLog.outDebug("+ %u RANGED_HIT", enchant_amount); + break; + case ITEM_MOD_HIT_SPELL_RATING: + ((Player*)this)->ApplyRatingMod(CR_HIT_SPELL, enchant_amount, apply); + sLog.outDebug("+ %u SPELL_HIT", enchant_amount); + break; + case ITEM_MOD_CRIT_MELEE_RATING: + ((Player*)this)->ApplyRatingMod(CR_CRIT_MELEE, enchant_amount, apply); + sLog.outDebug("+ %u MELEE_CRIT", enchant_amount); + break; + case ITEM_MOD_CRIT_RANGED_RATING: + ((Player*)this)->ApplyRatingMod(CR_CRIT_RANGED, enchant_amount, apply); + sLog.outDebug("+ %u RANGED_CRIT", enchant_amount); + break; + case ITEM_MOD_CRIT_SPELL_RATING: + ((Player*)this)->ApplyRatingMod(CR_CRIT_SPELL, enchant_amount, apply); + sLog.outDebug("+ %u SPELL_CRIT", enchant_amount); + break; +// Values from ITEM_STAT_MELEE_HA_RATING to ITEM_MOD_HASTE_RANGED_RATING are never used +// in Enchantments +// case ITEM_MOD_HIT_TAKEN_MELEE_RATING: +// ((Player*)this)->ApplyRatingMod(CR_HIT_TAKEN_MELEE, enchant_amount, apply); +// break; +// case ITEM_MOD_HIT_TAKEN_RANGED_RATING: +// ((Player*)this)->ApplyRatingMod(CR_HIT_TAKEN_RANGED, enchant_amount, apply); +// break; +// case ITEM_MOD_HIT_TAKEN_SPELL_RATING: +// ((Player*)this)->ApplyRatingMod(CR_HIT_TAKEN_SPELL, enchant_amount, apply); +// break; +// case ITEM_MOD_CRIT_TAKEN_MELEE_RATING: +// ((Player*)this)->ApplyRatingMod(CR_CRIT_TAKEN_MELEE, enchant_amount, apply); +// break; +// case ITEM_MOD_CRIT_TAKEN_RANGED_RATING: +// ((Player*)this)->ApplyRatingMod(CR_CRIT_TAKEN_RANGED, enchant_amount, apply); +// break; +// case ITEM_MOD_CRIT_TAKEN_SPELL_RATING: +// ((Player*)this)->ApplyRatingMod(CR_CRIT_TAKEN_SPELL, enchant_amount, apply); +// break; +// case ITEM_MOD_HASTE_MELEE_RATING: +// ((Player*)this)->ApplyRatingMod(CR_HASTE_MELEE, enchant_amount, apply); +// break; +// case ITEM_MOD_HASTE_RANGED_RATING: +// ((Player*)this)->ApplyRatingMod(CR_HASTE_RANGED, enchant_amount, apply); +// break; + case ITEM_MOD_HASTE_SPELL_RATING: + ((Player*)this)->ApplyRatingMod(CR_HASTE_SPELL, enchant_amount, apply); + break; + case ITEM_MOD_HIT_RATING: + ((Player*)this)->ApplyRatingMod(CR_HIT_MELEE, enchant_amount, apply); + ((Player*)this)->ApplyRatingMod(CR_HIT_RANGED, enchant_amount, apply); + ((Player*)this)->ApplyRatingMod(CR_HIT_SPELL, enchant_amount, apply); + sLog.outDebug("+ %u HIT", enchant_amount); + break; + case ITEM_MOD_CRIT_RATING: + ((Player*)this)->ApplyRatingMod(CR_CRIT_MELEE, enchant_amount, apply); + ((Player*)this)->ApplyRatingMod(CR_CRIT_RANGED, enchant_amount, apply); + ((Player*)this)->ApplyRatingMod(CR_CRIT_SPELL, enchant_amount, apply); + sLog.outDebug("+ %u CRITICAL", enchant_amount); + break; +// Values ITEM_MOD_HIT_TAKEN_RATING and ITEM_MOD_CRIT_TAKEN_RATING are never used in Enchantment +// case ITEM_MOD_HIT_TAKEN_RATING: +// ((Player*)this)->ApplyRatingMod(CR_HIT_TAKEN_MELEE, enchant_amount, apply); +// ((Player*)this)->ApplyRatingMod(CR_HIT_TAKEN_RANGED, enchant_amount, apply); +// ((Player*)this)->ApplyRatingMod(CR_HIT_TAKEN_SPELL, enchant_amount, apply); +// break; +// case ITEM_MOD_CRIT_TAKEN_RATING: +// ((Player*)this)->ApplyRatingMod(CR_CRIT_TAKEN_MELEE, enchant_amount, apply); +// ((Player*)this)->ApplyRatingMod(CR_CRIT_TAKEN_RANGED, enchant_amount, apply); +// ((Player*)this)->ApplyRatingMod(CR_CRIT_TAKEN_SPELL, enchant_amount, apply); +// break; + case ITEM_MOD_RESILIENCE_RATING: + ((Player*)this)->ApplyRatingMod(CR_CRIT_TAKEN_MELEE, enchant_amount, apply); + ((Player*)this)->ApplyRatingMod(CR_CRIT_TAKEN_RANGED, enchant_amount, apply); + ((Player*)this)->ApplyRatingMod(CR_CRIT_TAKEN_SPELL, enchant_amount, apply); + sLog.outDebug("+ %u RESILIENCE", enchant_amount); + break; + case ITEM_MOD_HASTE_RATING: + ((Player*)this)->ApplyRatingMod(CR_HASTE_MELEE, enchant_amount, apply); + ((Player*)this)->ApplyRatingMod(CR_HASTE_RANGED, enchant_amount, apply); + ((Player*)this)->ApplyRatingMod(CR_HASTE_SPELL, enchant_amount, apply); + sLog.outDebug("+ %u HASTE", enchant_amount); + break; + case ITEM_MOD_EXPERTISE_RATING: + ((Player*)this)->ApplyRatingMod(CR_EXPERTISE, enchant_amount, apply); + sLog.outDebug("+ %u EXPERTISE", enchant_amount); + break; + default: + break; + } + break; + } + case ITEM_ENCHANTMENT_TYPE_TOTEM: // Shaman Rockbiter Weapon + { + if(getClass() == CLASS_SHAMAN) + { + float addValue = 0.0f; + if(item->GetSlot() == EQUIPMENT_SLOT_MAINHAND) + { + addValue = float(enchant_amount * item->GetProto()->Delay/1000.0f); + HandleStatModifier(UNIT_MOD_DAMAGE_MAINHAND, TOTAL_VALUE, addValue, apply); + } + else if(item->GetSlot() == EQUIPMENT_SLOT_OFFHAND ) + { + addValue = float(enchant_amount * item->GetProto()->Delay/1000.0f); + HandleStatModifier(UNIT_MOD_DAMAGE_OFFHAND, TOTAL_VALUE, addValue, apply); + } + } + break; + } + default: + sLog.outError("Unknown item enchantment display type: %d",enchant_display_type); + break; + } /*switch(enchant_display_type)*/ + } /*for*/ + + // visualize enchantment at player and equipped items + if(slot < MAX_INSPECTED_ENCHANTMENT_SLOT) + { + int VisibleBase = PLAYER_VISIBLE_ITEM_1_0 + (item->GetSlot() * MAX_VISIBLE_ITEM_OFFSET); + SetUInt32Value(VisibleBase + 1 + slot, apply? item->GetEnchantmentId(slot) : 0); + } + + if(apply_dur) + { + if(apply) + { + // set duration + uint32 duration = item->GetEnchantmentDuration(slot); + if(duration > 0) + AddEnchantmentDuration(item,slot,duration); + } + else + { + // duration == 0 will remove EnchantDuration + AddEnchantmentDuration(item,slot,0); + } + } +} + +void Player::SendEnchantmentDurations() +{ + for(EnchantDurationList::iterator itr = m_enchantDuration.begin();itr != m_enchantDuration.end();++itr) + { + GetSession()->SendItemEnchantTimeUpdate(GetGUID(), itr->item->GetGUID(),itr->slot,uint32(itr->leftduration)/1000); + } +} + +void Player::SendItemDurations() +{ + for(ItemDurationList::iterator itr = m_itemDuration.begin();itr != m_itemDuration.end();++itr) + { + (*itr)->SendTimeUpdate(this); + } +} + +void Player::SendNewItem(Item *item, uint32 count, bool received, bool created, bool broadcast) +{ + if(!item) // prevent crash + return; + + // last check 2.0.10 + WorldPacket data( SMSG_ITEM_PUSH_RESULT, (8+4+4+4+1+4+4+4+4+4) ); + data << GetGUID(); // player GUID + data << uint32(received); // 0=looted, 1=from npc + data << uint32(created); // 0=received, 1=created + data << uint32(1); // always 0x01 (probably meant to be count of listed items) + data << (uint8)item->GetBagSlot(); // bagslot + // item slot, but when added to stack: 0xFFFFFFFF + data << (uint32) ((item->GetCount()==count) ? item->GetSlot() : -1); + data << uint32(item->GetEntry()); // item id + data << uint32(item->GetItemSuffixFactor()); // SuffixFactor + data << uint32(item->GetItemRandomPropertyId()); // random item property id + data << uint32(count); // count of items + data << GetItemCount(item->GetEntry()); // count of items in inventory + + if (broadcast && GetGroup()) + GetGroup()->BroadcastPacket(&data); + else + GetSession()->SendPacket(&data); +} + +/*********************************************************/ +/*** QUEST SYSTEM ***/ +/*********************************************************/ + +void Player::PrepareQuestMenu( uint64 guid ) +{ + Object *pObject; + QuestRelations* pObjectQR; + QuestRelations* pObjectQIR; + Creature *pCreature = ObjectAccessor::GetCreature(*this, guid); + if( pCreature ) + { + pObject = (Object*)pCreature; + pObjectQR = &objmgr.mCreatureQuestRelations; + pObjectQIR = &objmgr.mCreatureQuestInvolvedRelations; + } + else + { + GameObject *pGameObject = ObjectAccessor::GetGameObject(*this, guid); + if( pGameObject ) + { + pObject = (Object*)pGameObject; + pObjectQR = &objmgr.mGOQuestRelations; + pObjectQIR = &objmgr.mGOQuestInvolvedRelations; + } + else + return; + } + + QuestMenu &qm = PlayerTalkClass->GetQuestMenu(); + qm.ClearMenu(); + + for(QuestRelations::const_iterator i = pObjectQIR->lower_bound(pObject->GetEntry()); i != pObjectQIR->upper_bound(pObject->GetEntry()); ++i) + { + uint32 quest_id = i->second; + QuestStatus status = GetQuestStatus( quest_id ); + if ( status == QUEST_STATUS_COMPLETE && !GetQuestRewardStatus( quest_id ) ) + qm.AddMenuItem(quest_id, DIALOG_STATUS_REWARD_REP); + else if ( status == QUEST_STATUS_INCOMPLETE ) + qm.AddMenuItem(quest_id, DIALOG_STATUS_INCOMPLETE); + else if (status == QUEST_STATUS_AVAILABLE ) + qm.AddMenuItem(quest_id, DIALOG_STATUS_CHAT); + } + + for(QuestRelations::const_iterator i = pObjectQR->lower_bound(pObject->GetEntry()); i != pObjectQR->upper_bound(pObject->GetEntry()); ++i) + { + uint32 quest_id = i->second; + Quest const* pQuest = objmgr.GetQuestTemplate(quest_id); + if(!pQuest) continue; + + QuestStatus status = GetQuestStatus( quest_id ); + + if (pQuest->IsAutoComplete() && CanTakeQuest(pQuest, false)) + qm.AddMenuItem(quest_id, DIALOG_STATUS_REWARD_REP); + else if ( status == QUEST_STATUS_NONE && CanTakeQuest( pQuest, false ) ) + qm.AddMenuItem(quest_id, DIALOG_STATUS_AVAILABLE); + } +} + +void Player::SendPreparedQuest( uint64 guid ) +{ + QuestMenu& questMenu = PlayerTalkClass->GetQuestMenu(); + if( questMenu.Empty() ) + return; + + QuestMenuItem const& qmi0 = questMenu.GetItem( 0 ); + + uint32 status = qmi0.m_qIcon; + + // single element case + if ( questMenu.MenuItemCount() == 1 ) + { + // Auto open -- maybe also should verify there is no greeting + uint32 quest_id = qmi0.m_qId; + Quest const* pQuest = objmgr.GetQuestTemplate(quest_id); + if ( pQuest ) + { + if( status == DIALOG_STATUS_REWARD_REP && !GetQuestRewardStatus( quest_id ) ) + PlayerTalkClass->SendQuestGiverRequestItems( pQuest, guid, CanRewardQuest(pQuest,false), true ); + else if( status == DIALOG_STATUS_INCOMPLETE ) + PlayerTalkClass->SendQuestGiverRequestItems( pQuest, guid, false, true ); + // Send completable on repeatable quest if player don't have quest + else if( pQuest->IsRepeatable() ) + PlayerTalkClass->SendQuestGiverRequestItems( pQuest, guid, CanCompleteRepeatableQuest(pQuest), true ); + else + PlayerTalkClass->SendQuestGiverQuestDetails( pQuest, guid, true ); + } + } + // multiply entries + else + { + QEmote qe; + qe._Delay = 0; + qe._Emote = 0; + std::string title = ""; + Creature *pCreature = ObjectAccessor::GetCreature(*this, guid); + if( pCreature ) + { + uint32 textid = pCreature->GetNpcTextId(); + GossipText * gossiptext = objmgr.GetGossipText(textid); + if( !gossiptext ) + { + qe._Delay = 0; //TEXTEMOTE_MESSAGE; //zyg: player emote + qe._Emote = 0; //TEXTEMOTE_HELLO; //zyg: NPC emote + title = ""; + } + else + { + qe = gossiptext->Options[0].Emotes[0]; + + if(!gossiptext->Options[0].Text_0.empty()) + { + title = gossiptext->Options[0].Text_0; + + int loc_idx = GetSession()->GetSessionDbLocaleIndex(); + if (loc_idx >= 0) + { + NpcTextLocale const *nl = objmgr.GetNpcTextLocale(textid); + if (nl) + { + if (nl->Text_0[0].size() > loc_idx && !nl->Text_0[0][loc_idx].empty()) + title = nl->Text_0[0][loc_idx]; + } + } + } + else + { + title = gossiptext->Options[0].Text_1; + + int loc_idx = GetSession()->GetSessionDbLocaleIndex(); + if (loc_idx >= 0) + { + NpcTextLocale const *nl = objmgr.GetNpcTextLocale(textid); + if (nl) + { + if (nl->Text_1[0].size() > loc_idx && !nl->Text_1[0][loc_idx].empty()) + title = nl->Text_1[0][loc_idx]; + } + } + } + } + } + PlayerTalkClass->SendQuestGiverQuestList( qe, title, guid ); + } +} + +bool Player::IsActiveQuest( uint32 quest_id ) const +{ + QuestStatusMap::const_iterator itr = mQuestStatus.find(quest_id); + + return itr != mQuestStatus.end() && itr->second.m_status != QUEST_STATUS_NONE; +} + +Quest const * Player::GetNextQuest( uint64 guid, Quest const *pQuest ) +{ + Object *pObject; + QuestRelations* pObjectQR; + QuestRelations* pObjectQIR; + + Creature *pCreature = ObjectAccessor::GetCreature(*this, guid); + if( pCreature ) + { + pObject = (Object*)pCreature; + pObjectQR = &objmgr.mCreatureQuestRelations; + pObjectQIR = &objmgr.mCreatureQuestInvolvedRelations; + } + else + { + GameObject *pGameObject = ObjectAccessor::GetGameObject(*this, guid); + if( pGameObject ) + { + pObject = (Object*)pGameObject; + pObjectQR = &objmgr.mGOQuestRelations; + pObjectQIR = &objmgr.mGOQuestInvolvedRelations; + } + else + return NULL; + } + + uint32 nextQuestID = pQuest->GetNextQuestInChain(); + for(QuestRelations::const_iterator itr = pObjectQR->lower_bound(pObject->GetEntry()); itr != pObjectQR->upper_bound(pObject->GetEntry()); ++itr) + { + if (itr->second == nextQuestID) + return objmgr.GetQuestTemplate(nextQuestID); + } + + return NULL; +} + +bool Player::CanSeeStartQuest( Quest const *pQuest ) +{ + if( SatisfyQuestRace( pQuest, false ) && SatisfyQuestSkillOrClass( pQuest, false ) && + SatisfyQuestExclusiveGroup( pQuest, false ) && SatisfyQuestReputation( pQuest, false ) && + SatisfyQuestPreviousQuest( pQuest, false ) && SatisfyQuestNextChain( pQuest, false ) && + SatisfyQuestPrevChain( pQuest, false ) && SatisfyQuestDay( pQuest, false ) ) + { + return getLevel() + sWorld.getConfig(CONFIG_QUEST_HIGH_LEVEL_HIDE_DIFF) >= pQuest->GetMinLevel(); + } + + return false; +} + +bool Player::CanTakeQuest( Quest const *pQuest, bool msg ) +{ + return SatisfyQuestStatus( pQuest, msg ) && SatisfyQuestExclusiveGroup( pQuest, msg ) + && SatisfyQuestRace( pQuest, msg ) && SatisfyQuestLevel( pQuest, msg ) + && SatisfyQuestSkillOrClass( pQuest, msg ) && SatisfyQuestReputation( pQuest, msg ) + && SatisfyQuestPreviousQuest( pQuest, msg ) && SatisfyQuestTimed( pQuest, msg ) + && SatisfyQuestNextChain( pQuest, msg ) && SatisfyQuestPrevChain( pQuest, msg ) + && SatisfyQuestDay( pQuest, msg ); +} + +bool Player::CanAddQuest( Quest const *pQuest, bool msg ) +{ + if( !SatisfyQuestLog( msg ) ) + return false; + + uint32 srcitem = pQuest->GetSrcItemId(); + if( srcitem > 0 ) + { + uint32 count = pQuest->GetSrcItemCount(); + ItemPosCountVec dest; + uint8 msg = CanStoreNewItem( NULL_BAG, NULL_SLOT, dest, srcitem, count ); + + // player already have max number (in most case 1) source item, no additional item needed and quest can be added. + if( msg == EQUIP_ERR_CANT_CARRY_MORE_OF_THIS ) + return true; + else if( msg != EQUIP_ERR_OK ) + { + SendEquipError( msg, NULL, NULL ); + return false; + } + } + return true; +} + +bool Player::CanCompleteQuest( uint32 quest_id ) +{ + if( quest_id ) + { + QuestStatusData& q_status = mQuestStatus[quest_id]; + if( q_status.m_status == QUEST_STATUS_COMPLETE ) + return false; // not allow re-complete quest + + Quest const* qInfo = objmgr.GetQuestTemplate(quest_id); + + if(!qInfo) + return false; + + // auto complete quest + if (qInfo->IsAutoComplete() && CanTakeQuest(qInfo, false)) + return true; + + if ( q_status.m_status == QUEST_STATUS_INCOMPLETE ) + { + + if ( qInfo->HasFlag( QUEST_MANGOS_FLAGS_DELIVER ) ) + { + for(int i = 0; i < QUEST_OBJECTIVES_COUNT; i++) + { + if( qInfo->ReqItemCount[i]!= 0 && q_status.m_itemcount[i] < qInfo->ReqItemCount[i] ) + return false; + } + } + + if ( qInfo->HasFlag(QUEST_MANGOS_FLAGS_KILL_OR_CAST | QUEST_MANGOS_FLAGS_SPEAKTO) ) + { + for(int i = 0; i < QUEST_OBJECTIVES_COUNT; i++) + { + if( qInfo->ReqCreatureOrGOId[i] == 0 ) + continue; + + if( qInfo->ReqCreatureOrGOCount[i] != 0 && q_status.m_creatureOrGOcount[i] < qInfo->ReqCreatureOrGOCount[i] ) + return false; + } + } + + if ( qInfo->HasFlag( QUEST_MANGOS_FLAGS_EXPLORATION_OR_EVENT ) && !q_status.m_explored ) + return false; + + if ( qInfo->HasFlag( QUEST_MANGOS_FLAGS_TIMED ) && q_status.m_timer == 0 ) + return false; + + if ( qInfo->GetRewOrReqMoney() < 0 ) + { + if ( GetMoney() < uint32(-qInfo->GetRewOrReqMoney()) ) + return false; + } + + uint32 repFacId = qInfo->GetRepObjectiveFaction(); + if ( repFacId && GetReputation(repFacId) < qInfo->GetRepObjectiveValue() ) + return false; + + return true; + } + } + return false; +} + +bool Player::CanCompleteRepeatableQuest( Quest const *pQuest ) +{ + // Solve problem that player don't have the quest and try complete it. + // if repeatable she must be able to complete event if player don't have it. + // Seem that all repeatable quest are DELIVER Flag so, no need to add more. + if( !CanTakeQuest(pQuest, false) ) + return false; + + if (pQuest->HasFlag( QUEST_MANGOS_FLAGS_DELIVER) ) + for(int i = 0; i < QUEST_OBJECTIVES_COUNT; i++) + if( pQuest->ReqItemId[i] && pQuest->ReqItemCount[i] && !HasItemCount(pQuest->ReqItemId[i],pQuest->ReqItemCount[i]) ) + return false; + + if( !CanRewardQuest(pQuest, false) ) + return false; + + return true; +} + +bool Player::CanRewardQuest( Quest const *pQuest, bool msg ) +{ + // not auto complete quest and not completed quest (only cheating case, then ignore without message) + if(!pQuest->IsAutoComplete() && GetQuestStatus(pQuest->GetQuestId()) != QUEST_STATUS_COMPLETE) + return false; + + // daily quest can't be rewarded (10 daily quest already completed) + if(!SatisfyQuestDay(pQuest,true)) + return false; + + // rewarded and not repeatable quest (only cheating case, then ignore without message) + if(GetQuestRewardStatus(pQuest->GetQuestId())) + return false; + + // prevent receive reward with quest items in bank + if ( pQuest->HasFlag( QUEST_MANGOS_FLAGS_DELIVER ) ) + { + for(int i = 0; i < QUEST_OBJECTIVES_COUNT; i++) + { + if( pQuest->ReqItemCount[i]!= 0 && + GetItemCount(pQuest->ReqItemId[i]) < pQuest->ReqItemCount[i] ) + { + if(msg) + SendEquipError( EQUIP_ERR_ITEM_NOT_FOUND, NULL, NULL ); + return false; + } + } + } + + // prevent receive reward with low money and GetRewOrReqMoney() < 0 + if(pQuest->GetRewOrReqMoney() < 0 && GetMoney() < uint32(-pQuest->GetRewOrReqMoney()) ) + return false; + + return true; +} + +bool Player::CanRewardQuest( Quest const *pQuest, uint32 reward, bool msg ) +{ + // prevent receive reward with quest items in bank or for not completed quest + if(!CanRewardQuest(pQuest,msg)) + return false; + + if ( pQuest->GetRewChoiceItemsCount() > 0 ) + { + if( pQuest->RewChoiceItemId[reward] ) + { + ItemPosCountVec dest; + uint8 res = CanStoreNewItem( NULL_BAG, NULL_SLOT, dest, pQuest->RewChoiceItemId[reward], pQuest->RewChoiceItemCount[reward] ); + if( res != EQUIP_ERR_OK ) + { + SendEquipError( res, NULL, NULL ); + return false; + } + } + } + + if ( pQuest->GetRewItemsCount() > 0 ) + { + for (uint32 i = 0; i < pQuest->GetRewItemsCount(); ++i) + { + if( pQuest->RewItemId[i] ) + { + ItemPosCountVec dest; + uint8 res = CanStoreNewItem( NULL_BAG, NULL_SLOT, dest, pQuest->RewItemId[i], pQuest->RewItemCount[i] ); + if( res != EQUIP_ERR_OK ) + { + SendEquipError( res, NULL, NULL ); + return false; + } + } + } + } + + return true; +} + +void Player::AddQuest( Quest const *pQuest, Object *questGiver ) +{ + uint16 log_slot = FindQuestSlot( 0 ); + assert(log_slot < MAX_QUEST_LOG_SIZE); + + uint32 quest_id = pQuest->GetQuestId(); + + // if not exist then created with set uState==NEW and rewarded=false + QuestStatusData& questStatusData = mQuestStatus[quest_id]; + if (questStatusData.uState != QUEST_NEW) + questStatusData.uState = QUEST_CHANGED; + + // check for repeatable quests status reset + questStatusData.m_status = QUEST_STATUS_INCOMPLETE; + questStatusData.m_explored = false; + + if ( pQuest->HasFlag( QUEST_MANGOS_FLAGS_DELIVER ) ) + { + for(int i = 0; i < QUEST_OBJECTIVES_COUNT; i++) + questStatusData.m_itemcount[i] = 0; + } + + if ( pQuest->HasFlag(QUEST_MANGOS_FLAGS_KILL_OR_CAST | QUEST_MANGOS_FLAGS_SPEAKTO) ) + { + for(int i = 0; i < QUEST_OBJECTIVES_COUNT; i++) + questStatusData.m_creatureOrGOcount[i] = 0; + } + + GiveQuestSourceItem( pQuest ); + AdjustQuestReqItemCount( pQuest ); + + if( pQuest->GetRepObjectiveFaction() ) + SetFactionVisibleForFactionId(pQuest->GetRepObjectiveFaction()); + + uint32 qtime = 0; + if( pQuest->HasFlag( QUEST_MANGOS_FLAGS_TIMED ) ) + { + uint32 limittime = pQuest->GetLimitTime(); + + // shared timed quest + if(questGiver && questGiver->GetTypeId()==TYPEID_PLAYER) + limittime = ((Player*)questGiver)->getQuestStatusMap()[quest_id].m_timer / 1000; + + AddTimedQuest( quest_id ); + questStatusData.m_timer = limittime * 1000; + qtime = static_cast(time(NULL)) + limittime; + } + else + questStatusData.m_timer = 0; + + SetQuestSlot(log_slot, quest_id, qtime); + + //starting initial quest script + if(questGiver && pQuest->GetQuestStartScript()!=0) + sWorld.ScriptsStart(sQuestStartScripts, pQuest->GetQuestStartScript(), questGiver, this); + + UpdateForQuestsGO(); +} + +void Player::CompleteQuest( uint32 quest_id ) +{ + if( quest_id ) + { + SetQuestStatus( quest_id, QUEST_STATUS_COMPLETE ); + + uint16 log_slot = FindQuestSlot( quest_id ); + if( log_slot < MAX_QUEST_LOG_SIZE) + SetQuestSlotState(log_slot,QUEST_STATE_COMPLETE); + + if(Quest const* qInfo = objmgr.GetQuestTemplate(quest_id)) + { + if( qInfo->HasFlag(QUEST_FLAGS_AUTO_REWARDED) ) + RewardQuest(qInfo,0,this,false); + else + SendQuestComplete( quest_id ); + } + } +} + +void Player::IncompleteQuest( uint32 quest_id ) +{ + if( quest_id ) + { + SetQuestStatus( quest_id, QUEST_STATUS_INCOMPLETE ); + + uint16 log_slot = FindQuestSlot( quest_id ); + if( log_slot < MAX_QUEST_LOG_SIZE) + RemoveQuestSlotState(log_slot,QUEST_STATE_COMPLETE); + } +} + +void Player::RewardQuest( Quest const *pQuest, uint32 reward, Object* questGiver, bool announce ) +{ + uint32 quest_id = pQuest->GetQuestId(); + + for (int i = 0; i < QUEST_OBJECTIVES_COUNT; i++ ) + { + if ( pQuest->ReqItemId[i] ) + DestroyItemCount( pQuest->ReqItemId[i], pQuest->ReqItemCount[i], true); + } + + //if( qInfo->HasSpecialFlag( QUEST_FLAGS_TIMED ) ) + // SetTimedQuest( 0 ); + m_timedquests.erase(pQuest->GetQuestId()); + + if ( pQuest->GetRewChoiceItemsCount() > 0 ) + { + if( pQuest->RewChoiceItemId[reward] ) + { + ItemPosCountVec dest; + if( CanStoreNewItem( NULL_BAG, NULL_SLOT, dest, pQuest->RewChoiceItemId[reward], pQuest->RewChoiceItemCount[reward] ) == EQUIP_ERR_OK ) + { + Item* item = StoreNewItem( dest, pQuest->RewChoiceItemId[reward], true); + SendNewItem(item, pQuest->RewChoiceItemCount[reward], true, false); + } + } + } + + if ( pQuest->GetRewItemsCount() > 0 ) + { + for (uint32 i=0; i < pQuest->GetRewItemsCount(); ++i) + { + if( pQuest->RewItemId[i] ) + { + ItemPosCountVec dest; + if( CanStoreNewItem( NULL_BAG, NULL_SLOT, dest, pQuest->RewItemId[i], pQuest->RewItemCount[i] ) == EQUIP_ERR_OK ) + { + Item* item = StoreNewItem( dest, pQuest->RewItemId[i], true); + SendNewItem(item, pQuest->RewItemCount[i], true, false); + } + } + } + } + + RewardReputation( pQuest ); + + if( pQuest->GetRewSpellCast() > 0 ) + CastSpell( this, pQuest->GetRewSpellCast(), true); + else if( pQuest->GetRewSpell() > 0) + CastSpell( this, pQuest->GetRewSpell(), true); + + uint16 log_slot = FindQuestSlot( quest_id ); + if( log_slot < MAX_QUEST_LOG_SIZE) + SetQuestSlot(log_slot,0); + + QuestStatusData& q_status = mQuestStatus[quest_id]; + + // Not give XP in case already completed once repeatable quest + uint32 XP = q_status.m_rewarded ? 0 : uint32(pQuest->XPValue( this )*sWorld.getRate(RATE_XP_QUEST)); + + if ( getLevel() < sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL) ) + GiveXP( XP , NULL ); + else + ModifyMoney( int32(pQuest->GetRewMoneyMaxLevel() * sWorld.getRate(RATE_DROP_MONEY)) ); + + // Give player extra money if GetRewOrReqMoney > 0 and get ReqMoney if negative + ModifyMoney( pQuest->GetRewOrReqMoney() ); + + // title reward + if(pQuest->GetCharTitleId()) + { + if(CharTitlesEntry const* titleEntry = sCharTitlesStore.LookupEntry(pQuest->GetCharTitleId())) + SetFlag64(PLAYER__FIELD_KNOWN_TITLES, (uint64(1) << titleEntry->bit_index)); + } + + // Send reward mail + if(pQuest->GetRewMailTemplateId()) + { + MailMessageType mailType; + uint32 senderGuidOrEntry; + switch(questGiver->GetTypeId()) + { + case TYPEID_UNIT: + mailType = MAIL_CREATURE; + senderGuidOrEntry = questGiver->GetEntry(); + break; + case TYPEID_GAMEOBJECT: + mailType = MAIL_GAMEOBJECT; + senderGuidOrEntry = questGiver->GetEntry(); + break; + case TYPEID_ITEM: + mailType = MAIL_ITEM; + senderGuidOrEntry = questGiver->GetEntry(); + break; + case TYPEID_PLAYER: + mailType = MAIL_NORMAL; + senderGuidOrEntry = questGiver->GetGUIDLow(); + break; + default: + mailType = MAIL_NORMAL; + senderGuidOrEntry = GetGUIDLow(); + break; + } + + Loot questMailLoot; + + questMailLoot.FillLoot(pQuest->GetQuestId(), LootTemplates_QuestMail, this); + + // fill mail + MailItemsInfo mi; // item list preparing + + for(size_t i = 0; mi.size() < MAX_MAIL_ITEMS && i < questMailLoot.items.size(); ++i) + { + if(LootItem* lootitem = questMailLoot.LootItemInSlot(i,this)) + { + if(Item* item = Item::CreateItem(lootitem->itemid,lootitem->count,this)) + { + item->SaveToDB(); // save for prevent lost at next mail load, if send fail then item will deleted + mi.AddItem(item->GetGUIDLow(), item->GetEntry(), item); + } + } + } + + for(size_t i = 0; mi.size() < MAX_MAIL_ITEMS && i < questMailLoot.quest_items.size(); ++i) + { + if(LootItem* lootitem = questMailLoot.LootItemInSlot(i+questMailLoot.items.size(),this)) + { + if(Item* item = Item::CreateItem(lootitem->itemid,lootitem->count,this)) + { + item->SaveToDB(); // save for prevent lost at next mail load, if send fail then item will deleted + mi.AddItem(item->GetGUIDLow(), item->GetEntry(), item); + } + } + } + + WorldSession::SendMailTo(this, mailType, MAIL_STATIONERY_NORMAL, senderGuidOrEntry, GetGUIDLow(), "", 0, &mi, 0, 0, MAIL_CHECK_MASK_NONE,pQuest->GetRewMailDelaySecs(),pQuest->GetRewMailTemplateId()); + } + + if(pQuest->IsDaily()) + SetDailyQuestStatus(quest_id); + + if ( !pQuest->IsRepeatable() ) + SetQuestStatus(quest_id, QUEST_STATUS_COMPLETE); + else + SetQuestStatus(quest_id, QUEST_STATUS_NONE); + + q_status.m_rewarded = true; + + if(announce) + SendQuestReward( pQuest, XP, questGiver ); + + if (q_status.uState != QUEST_NEW) q_status.uState = QUEST_CHANGED; +} + +void Player::FailQuest( uint32 quest_id ) +{ + if( quest_id ) + { + IncompleteQuest( quest_id ); + + uint16 log_slot = FindQuestSlot( quest_id ); + if( log_slot < MAX_QUEST_LOG_SIZE) + { + SetQuestSlotTimer(log_slot, 1 ); + SetQuestSlotState(log_slot,QUEST_STATE_FAIL); + } + SendQuestFailed( quest_id ); + } +} + +void Player::FailTimedQuest( uint32 quest_id ) +{ + if( quest_id ) + { + QuestStatusData& q_status = mQuestStatus[quest_id]; + + if (q_status.uState != QUEST_NEW) q_status.uState = QUEST_CHANGED; + q_status.m_timer = 0; + + IncompleteQuest( quest_id ); + + uint16 log_slot = FindQuestSlot( quest_id ); + if( log_slot < MAX_QUEST_LOG_SIZE) + { + SetQuestSlotTimer(log_slot, 1 ); + SetQuestSlotState(log_slot,QUEST_STATE_FAIL); + } + SendQuestTimerFailed( quest_id ); + } +} + +bool Player::SatisfyQuestSkillOrClass( Quest const* qInfo, bool msg ) +{ + int32 zoneOrSort = qInfo->GetZoneOrSort(); + int32 skillOrClass = qInfo->GetSkillOrClass(); + + // skip zone zoneOrSort and 0 case skillOrClass + if( zoneOrSort >= 0 && skillOrClass == 0 ) + return true; + + int32 questSort = -zoneOrSort; + uint8 reqSortClass = ClassByQuestSort(questSort); + + // check class sort cases in zoneOrSort + if( reqSortClass != 0 && getClass() != reqSortClass) + { + if( msg ) + SendCanTakeQuestResponse( INVALIDREASON_DONT_HAVE_REQ ); + return false; + } + + // check class + if( skillOrClass < 0 ) + { + uint8 reqClass = -int32(skillOrClass); + if(getClass() != reqClass) + { + if( msg ) + SendCanTakeQuestResponse( INVALIDREASON_DONT_HAVE_REQ ); + return false; + } + } + // check skill + else if( skillOrClass > 0 ) + { + uint32 reqSkill = skillOrClass; + if( GetSkillValue( reqSkill ) < qInfo->GetRequiredSkillValue() ) + { + if( msg ) + SendCanTakeQuestResponse( INVALIDREASON_DONT_HAVE_REQ ); + return false; + } + } + + return true; +} + +bool Player::SatisfyQuestLevel( Quest const* qInfo, bool msg ) +{ + if( getLevel() < qInfo->GetMinLevel() ) + { + if( msg ) + SendCanTakeQuestResponse( INVALIDREASON_DONT_HAVE_REQ ); + return false; + } + return true; +} + +bool Player::SatisfyQuestLog( bool msg ) +{ + // exist free slot + if( FindQuestSlot(0) < MAX_QUEST_LOG_SIZE ) + return true; + + if( msg ) + { + WorldPacket data( SMSG_QUESTLOG_FULL, 0 ); + GetSession()->SendPacket( &data ); + sLog.outDebug( "WORLD: Sent QUEST_LOG_FULL_MESSAGE" ); + } + return false; +} + +bool Player::SatisfyQuestPreviousQuest( Quest const* qInfo, bool msg ) +{ + // No previous quest (might be first quest in a series) + if( qInfo->prevQuests.empty()) + return true; + + for(Quest::PrevQuests::const_iterator iter = qInfo->prevQuests.begin(); iter != qInfo->prevQuests.end(); ++iter ) + { + uint32 prevId = abs(*iter); + + QuestStatusMap::iterator i_prevstatus = mQuestStatus.find( prevId ); + Quest const* qPrevInfo = objmgr.GetQuestTemplate(prevId); + + if( qPrevInfo && i_prevstatus != mQuestStatus.end() ) + { + // If any of the positive previous quests completed, return true + if( *iter > 0 && i_prevstatus->second.m_rewarded ) + { + // skip one-from-all exclusive group + if(qPrevInfo->GetExclusiveGroup() >= 0) + return true; + + // each-from-all exclusive group ( < 0) + // can be start if only all quests in prev quest exclusive group complited and rewarded + ObjectMgr::ExclusiveQuestGroups::iterator iter = objmgr.mExclusiveQuestGroups.lower_bound(qPrevInfo->GetExclusiveGroup()); + ObjectMgr::ExclusiveQuestGroups::iterator end = objmgr.mExclusiveQuestGroups.upper_bound(qPrevInfo->GetExclusiveGroup()); + + assert(iter!=end); // always must be found if qPrevInfo->ExclusiveGroup != 0 + + for(; iter != end; ++iter) + { + uint32 exclude_Id = iter->second; + + // skip checked quest id, only state of other quests in group is interesting + if(exclude_Id == prevId) + continue; + + QuestStatusMap::iterator i_exstatus = mQuestStatus.find( exclude_Id ); + + // alternative quest from group also must be completed and rewarded(reported) + if( i_exstatus == mQuestStatus.end() || !i_exstatus->second.m_rewarded ) + { + if( msg ) + SendCanTakeQuestResponse( INVALIDREASON_DONT_HAVE_REQ ); + return false; + } + } + return true; + } + // If any of the negative previous quests active, return true + if( *iter < 0 && (i_prevstatus->second.m_status == QUEST_STATUS_INCOMPLETE + || (i_prevstatus->second.m_status == QUEST_STATUS_COMPLETE && !GetQuestRewardStatus(prevId)))) + { + // skip one-from-all exclusive group + if(qPrevInfo->GetExclusiveGroup() >= 0) + return true; + + // each-from-all exclusive group ( < 0) + // can be start if only all quests in prev quest exclusive group active + ObjectMgr::ExclusiveQuestGroups::iterator iter = objmgr.mExclusiveQuestGroups.lower_bound(qPrevInfo->GetExclusiveGroup()); + ObjectMgr::ExclusiveQuestGroups::iterator end = objmgr.mExclusiveQuestGroups.upper_bound(qPrevInfo->GetExclusiveGroup()); + + assert(iter!=end); // always must be found if qPrevInfo->ExclusiveGroup != 0 + + for(; iter != end; ++iter) + { + uint32 exclude_Id = iter->second; + + // skip checked quest id, only state of other quests in group is interesting + if(exclude_Id == prevId) + continue; + + QuestStatusMap::iterator i_exstatus = mQuestStatus.find( exclude_Id ); + + // alternative quest from group also must be active + if( i_exstatus == mQuestStatus.end() || + i_exstatus->second.m_status != QUEST_STATUS_INCOMPLETE && + (i_prevstatus->second.m_status != QUEST_STATUS_COMPLETE || GetQuestRewardStatus(prevId)) ) + { + if( msg ) + SendCanTakeQuestResponse( INVALIDREASON_DONT_HAVE_REQ ); + return false; + } + } + return true; + } + } + } + + // Has only positive prev. quests in non-rewarded state + // and negative prev. quests in non-active state + if( msg ) + SendCanTakeQuestResponse( INVALIDREASON_DONT_HAVE_REQ ); + + return false; +} + +bool Player::SatisfyQuestRace( Quest const* qInfo, bool msg ) +{ + uint32 reqraces = qInfo->GetRequiredRaces(); + if ( reqraces == 0 ) + return true; + if( (reqraces & getRaceMask()) == 0 ) + { + if( msg ) + SendCanTakeQuestResponse( INVALIDREASON_QUEST_FAILED_WRONG_RACE ); + return false; + } + return true; +} + +bool Player::SatisfyQuestReputation( Quest const* qInfo, bool msg ) +{ + uint32 fIdMin = qInfo->GetRequiredMinRepFaction(); //Min required rep + if(fIdMin && GetReputation(fIdMin) < qInfo->GetRequiredMinRepValue()) + { + if( msg ) + SendCanTakeQuestResponse( INVALIDREASON_DONT_HAVE_REQ ); + return false; + } + + uint32 fIdMax = qInfo->GetRequiredMaxRepFaction(); //Max required rep + if(fIdMax && GetReputation(fIdMax) >= qInfo->GetRequiredMaxRepValue()) + { + if( msg ) + SendCanTakeQuestResponse( INVALIDREASON_DONT_HAVE_REQ ); + return false; + } + + return true; +} + +bool Player::SatisfyQuestStatus( Quest const* qInfo, bool msg ) +{ + QuestStatusMap::iterator itr = mQuestStatus.find( qInfo->GetQuestId() ); + if ( itr != mQuestStatus.end() && itr->second.m_status != QUEST_STATUS_NONE ) + { + if( msg ) + SendCanTakeQuestResponse( INVALIDREASON_QUEST_ALREADY_ON ); + return false; + } + return true; +} + +bool Player::SatisfyQuestTimed( Quest const* qInfo, bool msg ) +{ + if ( (find(m_timedquests.begin(), m_timedquests.end(), qInfo->GetQuestId()) != m_timedquests.end()) && qInfo->HasFlag(QUEST_MANGOS_FLAGS_TIMED) ) + { + if( msg ) + SendCanTakeQuestResponse( INVALIDREASON_QUEST_ONLY_ONE_TIMED ); + return false; + } + return true; +} + +bool Player::SatisfyQuestExclusiveGroup( Quest const* qInfo, bool msg ) +{ + // non positive exclusive group, if > 0 then can be start if any other quest in exclusive group already started/completed + if(qInfo->GetExclusiveGroup() <= 0) + return true; + + ObjectMgr::ExclusiveQuestGroups::iterator iter = objmgr.mExclusiveQuestGroups.lower_bound(qInfo->GetExclusiveGroup()); + ObjectMgr::ExclusiveQuestGroups::iterator end = objmgr.mExclusiveQuestGroups.upper_bound(qInfo->GetExclusiveGroup()); + + assert(iter!=end); // always must be found if qInfo->ExclusiveGroup != 0 + + for(; iter != end; ++iter) + { + uint32 exclude_Id = iter->second; + + // skip checked quest id, only state of other quests in group is interesting + if(exclude_Id == qInfo->GetQuestId()) + continue; + + QuestStatusMap::iterator i_exstatus = mQuestStatus.find( exclude_Id ); + + // alternative quest already started or completed + if( i_exstatus != mQuestStatus.end() + && (i_exstatus->second.m_status == QUEST_STATUS_COMPLETE || i_exstatus->second.m_status == QUEST_STATUS_INCOMPLETE) ) + { + if( msg ) + SendCanTakeQuestResponse( INVALIDREASON_DONT_HAVE_REQ ); + return false; + } + } + return true; +} + +bool Player::SatisfyQuestNextChain( Quest const* qInfo, bool msg ) +{ + if(!qInfo->GetNextQuestInChain()) + return true; + + // next quest in chain already started or completed + QuestStatusMap::iterator itr = mQuestStatus.find( qInfo->GetNextQuestInChain() ); + if( itr != mQuestStatus.end() + && (itr->second.m_status == QUEST_STATUS_COMPLETE || itr->second.m_status == QUEST_STATUS_INCOMPLETE) ) + { + if( msg ) + SendCanTakeQuestResponse( INVALIDREASON_DONT_HAVE_REQ ); + return false; + } + + // check for all quests further up the chain + // only necessary if there are quest chains with more than one quest that can be skipped + //return SatisfyQuestNextChain( qInfo->GetNextQuestInChain(), msg ); + return true; +} + +bool Player::SatisfyQuestPrevChain( Quest const* qInfo, bool msg ) +{ + // No previous quest in chain + if( qInfo->prevChainQuests.empty()) + return true; + + for(Quest::PrevChainQuests::const_iterator iter = qInfo->prevChainQuests.begin(); iter != qInfo->prevChainQuests.end(); ++iter ) + { + uint32 prevId = *iter; + + QuestStatusMap::iterator i_prevstatus = mQuestStatus.find( prevId ); + + if( i_prevstatus != mQuestStatus.end() ) + { + // If any of the previous quests in chain active, return false + if( i_prevstatus->second.m_status == QUEST_STATUS_INCOMPLETE + || (i_prevstatus->second.m_status == QUEST_STATUS_COMPLETE && !GetQuestRewardStatus(prevId))) + { + if( msg ) + SendCanTakeQuestResponse( INVALIDREASON_DONT_HAVE_REQ ); + return false; + } + } + + // check for all quests further down the chain + // only necessary if there are quest chains with more than one quest that can be skipped + //if( !SatisfyQuestPrevChain( prevId, msg ) ) + // return false; + } + + // No previous quest in chain active + return true; +} + +bool Player::SatisfyQuestDay( Quest const* qInfo, bool msg ) +{ + if(!qInfo->IsDaily()) + return true; + + bool have_slot = false; + for(uint32 quest_daily_idx = 0; quest_daily_idx < PLAYER_MAX_DAILY_QUESTS; ++quest_daily_idx) + { + uint32 id = GetUInt32Value(PLAYER_FIELD_DAILY_QUESTS_1+quest_daily_idx); + if(qInfo->GetQuestId()==id) + return false; + + if(!id) + have_slot = true; + } + + if(!have_slot) + { + if( msg ) + SendCanTakeQuestResponse( INVALIDREASON_DAILY_QUESTS_REMAINING ); + return false; + } + + return true; +} + +bool Player::GiveQuestSourceItem( Quest const *pQuest ) +{ + uint32 srcitem = pQuest->GetSrcItemId(); + if( srcitem > 0 ) + { + uint32 count = pQuest->GetSrcItemCount(); + if( count <= 0 ) + count = 1; + + ItemPosCountVec dest; + uint8 msg = CanStoreNewItem( NULL_BAG, NULL_SLOT, dest, srcitem, count ); + if( msg == EQUIP_ERR_OK ) + { + Item * item = StoreNewItem(dest, srcitem, true); + SendNewItem(item, count, true, false); + return true; + } + // player already have max amount required item, just report success + else if( msg == EQUIP_ERR_CANT_CARRY_MORE_OF_THIS ) + return true; + else + SendEquipError( msg, NULL, NULL ); + return false; + } + + return true; +} + +bool Player::TakeQuestSourceItem( uint32 quest_id, bool msg ) +{ + Quest const* qInfo = objmgr.GetQuestTemplate(quest_id); + if( qInfo ) + { + uint32 srcitem = qInfo->GetSrcItemId(); + if( srcitem > 0 ) + { + uint32 count = qInfo->GetSrcItemCount(); + if( count <= 0 ) + count = 1; + + // exist one case when destroy source quest item not possible: + // non un-equippable item (equipped non-empty bag, for example) + uint8 res = CanUnequipItems(srcitem,count); + if(res != EQUIP_ERR_OK) + { + if(msg) + SendEquipError( res, NULL, NULL ); + return false; + } + + DestroyItemCount(srcitem, count, true, true); + } + } + return true; +} + +bool Player::GetQuestRewardStatus( uint32 quest_id ) const +{ + Quest const* qInfo = objmgr.GetQuestTemplate(quest_id); + if( qInfo ) + { + // for repeatable quests: rewarded field is set after first reward only to prevent getting XP more than once + QuestStatusMap::const_iterator itr = mQuestStatus.find( quest_id ); + if( itr != mQuestStatus.end() && itr->second.m_status != QUEST_STATUS_NONE + && !qInfo->IsRepeatable() ) + return itr->second.m_rewarded; + + return false; + } + return false; +} + +QuestStatus Player::GetQuestStatus( uint32 quest_id ) const +{ + if( quest_id ) + { + QuestStatusMap::const_iterator itr = mQuestStatus.find( quest_id ); + if( itr != mQuestStatus.end() ) + return itr->second.m_status; + } + return QUEST_STATUS_NONE; +} + +bool Player::CanShareQuest(uint32 quest_id) const +{ + Quest const* qInfo = objmgr.GetQuestTemplate(quest_id); + if( qInfo && qInfo->HasFlag(QUEST_FLAGS_SHARABLE) ) + { + QuestStatusMap::const_iterator itr = mQuestStatus.find( quest_id ); + if( itr != mQuestStatus.end() ) + return itr->second.m_status == QUEST_STATUS_NONE || itr->second.m_status == QUEST_STATUS_INCOMPLETE; + } + return false; +} + +void Player::SetQuestStatus( uint32 quest_id, QuestStatus status ) +{ + Quest const* qInfo = objmgr.GetQuestTemplate(quest_id); + if( qInfo ) + { + if( status == QUEST_STATUS_NONE || status == QUEST_STATUS_INCOMPLETE || status == QUEST_STATUS_COMPLETE ) + { + if( qInfo->HasFlag( QUEST_MANGOS_FLAGS_TIMED ) ) + m_timedquests.erase(qInfo->GetQuestId()); + } + + QuestStatusData& q_status = mQuestStatus[quest_id]; + + q_status.m_status = status; + if (q_status.uState != QUEST_NEW) q_status.uState = QUEST_CHANGED; + } + + UpdateForQuestsGO(); +} + +// not used in MaNGOS, but used in scripting code +uint32 Player::GetReqKillOrCastCurrentCount(uint32 quest_id, int32 entry) +{ + Quest const* qInfo = objmgr.GetQuestTemplate(quest_id); + if( !qInfo ) + return 0; + + for (int j = 0; j < QUEST_OBJECTIVES_COUNT; j++) + if ( qInfo->ReqCreatureOrGOId[j] == entry ) + return mQuestStatus[quest_id].m_creatureOrGOcount[j]; + + return 0; +} + +void Player::AdjustQuestReqItemCount( Quest const* pQuest ) +{ + if ( pQuest->HasFlag( QUEST_MANGOS_FLAGS_DELIVER ) ) + { + for(int i = 0; i < QUEST_OBJECTIVES_COUNT; i++) + { + uint32 reqitemcount = pQuest->ReqItemCount[i]; + if( reqitemcount != 0 ) + { + uint32 quest_id = pQuest->GetQuestId(); + uint32 curitemcount = GetItemCount(pQuest->ReqItemId[i],true); + + QuestStatusData& q_status = mQuestStatus[quest_id]; + q_status.m_itemcount[i] = std::min(curitemcount, reqitemcount); + if (q_status.uState != QUEST_NEW) q_status.uState = QUEST_CHANGED; + } + } + } +} + +uint16 Player::FindQuestSlot( uint32 quest_id ) const +{ + for ( uint16 i = 0; i < MAX_QUEST_LOG_SIZE; i++ ) + if ( GetQuestSlotQuestId(i) == quest_id ) + return i; + + return MAX_QUEST_LOG_SIZE; +} + +void Player::AreaExploredOrEventHappens( uint32 questId ) +{ + if( questId ) + { + uint16 log_slot = FindQuestSlot( questId ); + if( log_slot < MAX_QUEST_LOG_SIZE) + { + QuestStatusData& q_status = mQuestStatus[questId]; + + if(!q_status.m_explored) + { + q_status.m_explored = true; + if (q_status.uState != QUEST_NEW) + q_status.uState = QUEST_CHANGED; + } + } + if( CanCompleteQuest( questId ) ) + CompleteQuest( questId ); + } +} + +//not used in mangosd, function for external script library +void Player::GroupEventHappens( uint32 questId, WorldObject const* pEventObject ) +{ + if( Group *pGroup = GetGroup() ) + { + for(GroupReference *itr = pGroup->GetFirstMember(); itr != NULL; itr = itr->next()) + { + Player *pGroupGuy = itr->getSource(); + + // for any leave or dead (with not released body) group member at appropriate distance + if( pGroupGuy && pGroupGuy->IsAtGroupRewardDistance(pEventObject) && !pGroupGuy->GetCorpse() ) + pGroupGuy->AreaExploredOrEventHappens(questId); + } + } + else + AreaExploredOrEventHappens(questId); +} + +void Player::ItemAddedQuestCheck( uint32 entry, uint32 count ) +{ + for( int i = 0; i < MAX_QUEST_LOG_SIZE; i++ ) + { + uint32 questid = GetQuestSlotQuestId(i); + if ( questid == 0 ) + continue; + + QuestStatusData& q_status = mQuestStatus[questid]; + + if ( q_status.m_status != QUEST_STATUS_INCOMPLETE ) + continue; + + Quest const* qInfo = objmgr.GetQuestTemplate(questid); + if( !qInfo || !qInfo->HasFlag( QUEST_MANGOS_FLAGS_DELIVER ) ) + continue; + + for (int j = 0; j < QUEST_OBJECTIVES_COUNT; j++) + { + uint32 reqitem = qInfo->ReqItemId[j]; + if ( reqitem == entry ) + { + uint32 reqitemcount = qInfo->ReqItemCount[j]; + uint32 curitemcount = q_status.m_itemcount[j]; + if ( curitemcount < reqitemcount ) + { + uint32 additemcount = ( curitemcount + count <= reqitemcount ? count : reqitemcount - curitemcount); + q_status.m_itemcount[j] += additemcount; + if (q_status.uState != QUEST_NEW) q_status.uState = QUEST_CHANGED; + + SendQuestUpdateAddItem( qInfo, j, additemcount ); + } + if ( CanCompleteQuest( questid ) ) + CompleteQuest( questid ); + return; + } + } + } + UpdateForQuestsGO(); +} + +void Player::ItemRemovedQuestCheck( uint32 entry, uint32 count ) +{ + for( int i = 0; i < MAX_QUEST_LOG_SIZE; i++ ) + { + uint32 questid = GetQuestSlotQuestId(i); + if(!questid) + continue; + Quest const* qInfo = objmgr.GetQuestTemplate(questid); + if ( !qInfo ) + continue; + if( !qInfo->HasFlag( QUEST_MANGOS_FLAGS_DELIVER ) ) + continue; + + for (int j = 0; j < QUEST_OBJECTIVES_COUNT; j++) + { + uint32 reqitem = qInfo->ReqItemId[j]; + if ( reqitem == entry ) + { + QuestStatusData& q_status = mQuestStatus[questid]; + + uint32 reqitemcount = qInfo->ReqItemCount[j]; + uint32 curitemcount; + if( q_status.m_status != QUEST_STATUS_COMPLETE ) + curitemcount = q_status.m_itemcount[j]; + else + curitemcount = GetItemCount(entry,true); + if ( curitemcount < reqitemcount + count ) + { + uint32 remitemcount = ( curitemcount <= reqitemcount ? count : count + reqitemcount - curitemcount); + q_status.m_itemcount[j] = curitemcount - remitemcount; + if (q_status.uState != QUEST_NEW) q_status.uState = QUEST_CHANGED; + + IncompleteQuest( questid ); + } + return; + } + } + } + UpdateForQuestsGO(); +} + +void Player::KilledMonster( uint32 entry, uint64 guid ) +{ + uint32 addkillcount = 1; + for( int i = 0; i < MAX_QUEST_LOG_SIZE; i++ ) + { + uint32 questid = GetQuestSlotQuestId(i); + if(!questid) + continue; + + Quest const* qInfo = objmgr.GetQuestTemplate(questid); + if( !qInfo ) + continue; + // just if !ingroup || !noraidgroup || raidgroup + QuestStatusData& q_status = mQuestStatus[questid]; + if( q_status.m_status == QUEST_STATUS_INCOMPLETE && (!GetGroup() || !GetGroup()->isRaidGroup() || qInfo->GetType() == QUEST_TYPE_RAID)) + { + if( qInfo->HasFlag( QUEST_MANGOS_FLAGS_KILL_OR_CAST) ) + { + for (int j = 0; j < QUEST_OBJECTIVES_COUNT; j++) + { + // skip GO activate objective or none + if(qInfo->ReqCreatureOrGOId[j] <=0) + continue; + + // skip Cast at creature objective + if(qInfo->ReqSpell[j] !=0 ) + continue; + + uint32 reqkill = qInfo->ReqCreatureOrGOId[j]; + + if ( reqkill == entry ) + { + uint32 reqkillcount = qInfo->ReqCreatureOrGOCount[j]; + uint32 curkillcount = q_status.m_creatureOrGOcount[j]; + if ( curkillcount < reqkillcount ) + { + q_status.m_creatureOrGOcount[j] = curkillcount + addkillcount; + if (q_status.uState != QUEST_NEW) q_status.uState = QUEST_CHANGED; + + SendQuestUpdateAddCreatureOrGo( qInfo, guid, j, curkillcount, addkillcount); + } + if ( CanCompleteQuest( questid ) ) + CompleteQuest( questid ); + + // same objective target can be in many active quests, but not in 2 objectives for single quest (code optimization). + continue; + } + } + } + } + } +} + +void Player::CastedCreatureOrGO( uint32 entry, uint64 guid, uint32 spell_id ) +{ + bool isCreature = IS_CREATURE_GUID(guid); + + uint32 addCastCount = 1; + for( int i = 0; i < MAX_QUEST_LOG_SIZE; i++ ) + { + uint32 questid = GetQuestSlotQuestId(i); + if(!questid) + continue; + + Quest const* qInfo = objmgr.GetQuestTemplate(questid); + if ( !qInfo ) + continue; + + QuestStatusData& q_status = mQuestStatus[questid]; + + if ( q_status.m_status == QUEST_STATUS_INCOMPLETE ) + { + if( qInfo->HasFlag( QUEST_MANGOS_FLAGS_KILL_OR_CAST ) ) + { + for (int j = 0; j < QUEST_OBJECTIVES_COUNT; j++) + { + // skip kill creature objective (0) or wrong spell casts + if(qInfo->ReqSpell[j] != spell_id ) + continue; + + uint32 reqTarget = 0; + + if(isCreature) + { + // creature activate objectives + if(qInfo->ReqCreatureOrGOId[j] > 0) + // checked at quest_template loading + reqTarget = qInfo->ReqCreatureOrGOId[j]; + } + else + { + // GO activate objective + if(qInfo->ReqCreatureOrGOId[j] < 0) + // checked at quest_template loading + reqTarget = - qInfo->ReqCreatureOrGOId[j]; + } + + // other not this creature/GO related objectives + if( reqTarget != entry ) + continue; + + uint32 reqCastCount = qInfo->ReqCreatureOrGOCount[j]; + uint32 curCastCount = q_status.m_creatureOrGOcount[j]; + if ( curCastCount < reqCastCount ) + { + q_status.m_creatureOrGOcount[j] = curCastCount + addCastCount; + if (q_status.uState != QUEST_NEW) q_status.uState = QUEST_CHANGED; + + SendQuestUpdateAddCreatureOrGo( qInfo, guid, j, curCastCount, addCastCount); + } + + if ( CanCompleteQuest( questid ) ) + CompleteQuest( questid ); + + // same objective target can be in many active quests, but not in 2 objectives for single quest (code optimization). + break; + } + } + } + } +} + +void Player::TalkedToCreature( uint32 entry, uint64 guid ) +{ + uint32 addTalkCount = 1; + for( int i = 0; i < MAX_QUEST_LOG_SIZE; i++ ) + { + uint32 questid = GetQuestSlotQuestId(i); + if(!questid) + continue; + + Quest const* qInfo = objmgr.GetQuestTemplate(questid); + if ( !qInfo ) + continue; + + QuestStatusData& q_status = mQuestStatus[questid]; + + if ( q_status.m_status == QUEST_STATUS_INCOMPLETE ) + { + if( qInfo->HasFlag( QUEST_MANGOS_FLAGS_KILL_OR_CAST | QUEST_MANGOS_FLAGS_SPEAKTO ) ) + { + for (int j = 0; j < QUEST_OBJECTIVES_COUNT; j++) + { + // skip spell casts and Gameobject objectives + if(qInfo->ReqSpell[j] > 0 || qInfo->ReqCreatureOrGOId[j] < 0) + continue; + + uint32 reqTarget = 0; + + if(qInfo->ReqCreatureOrGOId[j] > 0) // creature activate objectives + // checked at quest_template loading + reqTarget = qInfo->ReqCreatureOrGOId[j]; + else + continue; + + if ( reqTarget == entry ) + { + uint32 reqTalkCount = qInfo->ReqCreatureOrGOCount[j]; + uint32 curTalkCount = q_status.m_creatureOrGOcount[j]; + if ( curTalkCount < reqTalkCount ) + { + q_status.m_creatureOrGOcount[j] = curTalkCount + addTalkCount; + if (q_status.uState != QUEST_NEW) q_status.uState = QUEST_CHANGED; + + SendQuestUpdateAddCreatureOrGo( qInfo, guid, j, curTalkCount, addTalkCount); + } + if ( CanCompleteQuest( questid ) ) + CompleteQuest( questid ); + + // same objective target can be in many active quests, but not in 2 objectives for single quest (code optimization). + continue; + } + } + } + } + } +} + +void Player::MoneyChanged( uint32 count ) +{ + for( int i = 0; i < MAX_QUEST_LOG_SIZE; i++ ) + { + uint32 questid = GetQuestSlotQuestId(i); + if (!questid) + continue; + + Quest const* qInfo = objmgr.GetQuestTemplate(questid); + if( qInfo && qInfo->GetRewOrReqMoney() < 0 ) + { + QuestStatusData& q_status = mQuestStatus[questid]; + + if( q_status.m_status == QUEST_STATUS_INCOMPLETE ) + { + if(int32(count) >= -qInfo->GetRewOrReqMoney()) + { + if ( CanCompleteQuest( questid ) ) + CompleteQuest( questid ); + } + } + else if( q_status.m_status == QUEST_STATUS_COMPLETE ) + { + if(int32(count) < -qInfo->GetRewOrReqMoney()) + IncompleteQuest( questid ); + } + } + } +} + +bool Player::HasQuestForItem( uint32 itemid ) const +{ + for( QuestStatusMap::const_iterator i = mQuestStatus.begin( ); i != mQuestStatus.end( ); ++i ) + { + QuestStatusData const& q_status = i->second; + + if (q_status.m_status == QUEST_STATUS_INCOMPLETE) + { + Quest const* qinfo = objmgr.GetQuestTemplate(i->first); + if(!qinfo) + continue; + + // hide quest if player is in raid-group and quest is no raid quest + if(GetGroup() && GetGroup()->isRaidGroup() && qinfo->GetType() != QUEST_TYPE_RAID) + continue; + + // There should be no mixed ReqItem/ReqSource drop + // This part for ReqItem drop + for (int j = 0; j < QUEST_OBJECTIVES_COUNT; j++) + { + if(itemid == qinfo->ReqItemId[j] && q_status.m_itemcount[j] < qinfo->ReqItemCount[j] ) + return true; + } + // This part - for ReqSource + for (int j = 0; j < QUEST_SOURCE_ITEM_IDS_COUNT; j++) + { + // examined item is a source item + if (qinfo->ReqSourceId[j] == itemid && qinfo->ReqSourceRef[j] > 0 && qinfo->ReqSourceRef[j] <= QUEST_OBJECTIVES_COUNT) + { + uint32 idx = qinfo->ReqSourceRef[j]-1; + + // total count of created ReqItems and SourceItems is less than ReqItemCount + if(qinfo->ReqItemId[idx] != 0 && + q_status.m_itemcount[idx] * qinfo->ReqSourceCount[j] + GetItemCount(itemid,true) < qinfo->ReqItemCount[idx] * qinfo->ReqSourceCount[j]) + return true; + + // total count of casted ReqCreatureOrGOs and SourceItems is less than ReqCreatureOrGOCount + if (qinfo->ReqCreatureOrGOId[idx] != 0) + { + if(q_status.m_creatureOrGOcount[idx] * qinfo->ReqSourceCount[j] + GetItemCount(itemid,true) < qinfo->ReqCreatureOrGOCount[idx] * qinfo->ReqSourceCount[j]) + return true; + } + // spell with SPELL_EFFECT_QUEST_COMPLETE or SPELL_EFFECT_SEND_EVENT (with script) case + else if(qinfo->ReqSpell[idx] != 0) + { + // not casted and need more reagents/item for use. + if(!q_status.m_explored && GetItemCount(itemid,true) < qinfo->ReqSourceCount[j]) + return true; + } + } + } + } + } + return false; +} + +void Player::SendQuestComplete( uint32 quest_id ) +{ + if( quest_id ) + { + WorldPacket data( SMSG_QUESTUPDATE_COMPLETE, 4 ); + data << quest_id; + GetSession()->SendPacket( &data ); + sLog.outDebug( "WORLD: Sent SMSG_QUESTUPDATE_COMPLETE quest = %u", quest_id ); + } +} + +void Player::SendQuestReward( Quest const *pQuest, uint32 XP, Object * questGiver ) +{ + uint32 questid = pQuest->GetQuestId(); + sLog.outDebug( "WORLD: Sent SMSG_QUESTGIVER_QUEST_COMPLETE quest = %u", questid ); + WorldPacket data( SMSG_QUESTGIVER_QUEST_COMPLETE, (4+4+4+4+4+4+pQuest->GetRewItemsCount()*8) ); + data << questid; + data << uint32(0x03); + + if ( getLevel() < sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL) ) + { + data << XP; + data << uint32(pQuest->GetRewOrReqMoney()); + } + else + { + data << uint32(0); + data << uint32(pQuest->GetRewOrReqMoney() + int32(pQuest->GetRewMoneyMaxLevel() * sWorld.getRate(RATE_DROP_MONEY))); + } + data << uint32(0); // new 2.3.0, HonorPoints? + data << uint32( pQuest->GetRewItemsCount() ); // max is 5 + + for (uint32 i = 0; i < pQuest->GetRewItemsCount(); ++i) + { + if ( pQuest->RewItemId[i] > 0 ) + data << pQuest->RewItemId[i] << pQuest->RewItemCount[i]; + else + data << uint32(0) << uint32(0); + } + GetSession()->SendPacket( &data ); + + if (pQuest->GetQuestCompleteScript() != 0) + sWorld.ScriptsStart(sQuestEndScripts, pQuest->GetQuestCompleteScript(), questGiver, this); +} + +void Player::SendQuestFailed( uint32 quest_id ) +{ + if( quest_id ) + { + WorldPacket data( SMSG_QUESTGIVER_QUEST_FAILED, 4 ); + data << quest_id; + GetSession()->SendPacket( &data ); + sLog.outDebug("WORLD: Sent SMSG_QUESTGIVER_QUEST_FAILED"); + } +} + +void Player::SendQuestTimerFailed( uint32 quest_id ) +{ + if( quest_id ) + { + WorldPacket data( SMSG_QUESTUPDATE_FAILEDTIMER, 4 ); + data << quest_id; + GetSession()->SendPacket( &data ); + sLog.outDebug("WORLD: Sent SMSG_QUESTUPDATE_FAILEDTIMER"); + } +} + +void Player::SendCanTakeQuestResponse( uint32 msg ) +{ + WorldPacket data( SMSG_QUESTGIVER_QUEST_INVALID, 4 ); + data << uint32(msg); + GetSession()->SendPacket( &data ); + sLog.outDebug("WORLD: Sent SMSG_QUESTGIVER_QUEST_INVALID"); +} + +void Player::SendPushToPartyResponse( Player *pPlayer, uint32 msg ) +{ + if( pPlayer ) + { + WorldPacket data( MSG_QUEST_PUSH_RESULT, (8+1) ); + data << uint64(pPlayer->GetGUID()); + data << uint8(msg); // valid values: 0-8 + GetSession()->SendPacket( &data ); + sLog.outDebug("WORLD: Sent MSG_QUEST_PUSH_RESULT"); + } +} + +void Player::SendQuestUpdateAddItem( Quest const* pQuest, uint32 item_idx, uint32 count ) +{ + WorldPacket data( SMSG_QUESTUPDATE_ADD_ITEM, (4+4) ); + sLog.outDebug( "WORLD: Sent SMSG_QUESTUPDATE_ADD_ITEM" ); + data << pQuest->ReqItemId[item_idx]; + data << count; + GetSession()->SendPacket( &data ); +} + +void Player::SendQuestUpdateAddCreatureOrGo( Quest const* pQuest, uint64 guid, uint32 creatureOrGO_idx, uint32 old_count, uint32 add_count ) +{ + assert(old_count + add_count < 256 && "mob/GO count store in 8 bits 2^8 = 256 (0..256)"); + + int32 entry = pQuest->ReqCreatureOrGOId[ creatureOrGO_idx ]; + if (entry < 0) + // client expected gameobject template id in form (id|0x80000000) + entry = (-entry) | 0x80000000; + + WorldPacket data( SMSG_QUESTUPDATE_ADD_KILL, (4*4+8) ); + sLog.outDebug( "WORLD: Sent SMSG_QUESTUPDATE_ADD_KILL" ); + data << uint32(pQuest->GetQuestId()); + data << uint32(entry); + data << uint32(old_count + add_count); + data << uint32(pQuest->ReqCreatureOrGOCount[ creatureOrGO_idx ]); + data << uint64(guid); + GetSession()->SendPacket(&data); + + uint16 log_slot = FindQuestSlot( pQuest->GetQuestId() ); + if( log_slot < MAX_QUEST_LOG_SIZE) + SetQuestSlotCounter(log_slot,creatureOrGO_idx,GetQuestSlotCounter(log_slot,creatureOrGO_idx)+add_count); +} + +/*********************************************************/ +/*** LOAD SYSTEM ***/ +/*********************************************************/ + +bool Player::MinimalLoadFromDB( QueryResult *result, uint32 guid ) +{ + bool delete_result = true; + if(!result) + { + // 0 1 2 3 4 5 6 7 8 + result = CharacterDatabase.PQuery("SELECT data, name, position_x, position_y, position_z, map, totaltime, leveltime, at_login FROM characters WHERE guid = '%u'",guid); + if(!result) return false; + } + else delete_result = false; + + Field *fields = result->Fetch(); + + if(!LoadValues( fields[0].GetString())) + { + sLog.outError("ERROR: Player #%d have broken data in `data` field. Can't be loaded.",GUID_LOPART(guid)); + if(delete_result) delete result; + return false; + } + + // overwrite possible wrong/corrupted guid + SetUInt64Value(OBJECT_FIELD_GUID, MAKE_NEW_GUID(guid, 0, HIGHGUID_PLAYER)); + + m_name = fields[1].GetCppString(); + + Relocate(fields[2].GetFloat(),fields[3].GetFloat(),fields[4].GetFloat()); + SetMapId(fields[5].GetUInt32()); + // the instance id is not needed at character enum + + m_Played_time[0] = fields[6].GetUInt32(); + m_Played_time[1] = fields[7].GetUInt32(); + + m_atLoginFlags = fields[8].GetUInt32(); + + // I don't see these used anywhere .. + /*_LoadGroup(); + + _LoadBoundInstances();*/ + + if (delete_result) delete result; + + for (int i = 0; i < PLAYER_SLOTS_COUNT; i++) + m_items[i] = NULL; + + if( HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_GHOST) ) + m_deathState = DEAD; + + return true; +} + +void Player::_LoadDeclinedNames(QueryResult* result) +{ + if(!result) + return; + + if(m_declinedname) + delete m_declinedname; + + m_declinedname = new DeclinedName; + Field *fields = result->Fetch(); + for(int i = 0; i < MAX_DECLINED_NAME_CASES; ++i) + m_declinedname->name[i] = fields[i].GetCppString(); + + delete result; +} + +bool Player::LoadPositionFromDB(uint32& mapid, float& x,float& y,float& z,float& o, bool& in_flight, uint64 guid) +{ + QueryResult *result = CharacterDatabase.PQuery("SELECT position_x,position_y,position_z,orientation,map,taxi_path FROM characters WHERE guid = '%u'",GUID_LOPART(guid)); + if(!result) + return false; + + Field *fields = result->Fetch(); + + x = fields[0].GetFloat(); + y = fields[1].GetFloat(); + z = fields[2].GetFloat(); + o = fields[3].GetFloat(); + mapid = fields[4].GetUInt32(); + in_flight = !fields[5].GetCppString().empty(); + + delete result; + return true; +} + +bool Player::LoadValuesArrayFromDB(Tokens& data, uint64 guid) +{ + QueryResult *result = CharacterDatabase.PQuery("SELECT data FROM characters WHERE guid='%u'",GUID_LOPART(guid)); + if( !result ) + return false; + + Field *fields = result->Fetch(); + + data = StrSplit(fields[0].GetCppString(), " "); + + delete result; + + return true; +} + +uint32 Player::GetUInt32ValueFromArray(Tokens const& data, uint16 index) +{ + if(index >= data.size()) + return 0; + + return (uint32)atoi(data[index].c_str()); +} + +float Player::GetFloatValueFromArray(Tokens const& data, uint16 index) +{ + float result; + uint32 temp = Player::GetUInt32ValueFromArray(data,index); + memcpy(&result, &temp, sizeof(result)); + + return result; +} + +uint32 Player::GetUInt32ValueFromDB(uint16 index, uint64 guid) +{ + Tokens data; + if(!LoadValuesArrayFromDB(data,guid)) + return 0; + + return GetUInt32ValueFromArray(data,index); +} + +float Player::GetFloatValueFromDB(uint16 index, uint64 guid) +{ + float result; + uint32 temp = Player::GetUInt32ValueFromDB(index, guid); + memcpy(&result, &temp, sizeof(result)); + + return result; +} + +bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder ) +{ + //// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 [28] [29] 30 31 32 + //QueryResult *result = CharacterDatabase.PQuery("SELECT guid, account, data, name, race, class, position_x, position_y, position_z, map, orientation, taximask, cinematic, totaltime, leveltime, rest_bonus, logout_time, is_logout_resting, resettalents_cost, resettalents_time, trans_x, trans_y, trans_z, trans_o, transguid, gmstate, stable_slots, at_login, zone, online, death_expire_time, taxi_path, dungeon_difficulty FROM characters WHERE guid = '%u'", guid); + QueryResult *result = holder->GetResult(PLAYER_LOGIN_QUERY_LOADFROM); + + if(!result) + { + sLog.outError("ERROR: Player (GUID: %u) not found in table `characters`, can't load. ",guid); + return false; + } + + Field *fields = result->Fetch(); + + uint32 dbAccountId = fields[1].GetUInt32(); + + // check if the character's account in the db and the logged in account match. + // player should be able to load/delete character only with correct account! + if( dbAccountId != GetSession()->GetAccountId() ) + { + sLog.outError("ERROR: Player (GUID: %u) loading from wrong account (is: %u, should be: %u)",guid,GetSession()->GetAccountId(),dbAccountId); + delete result; + return false; + } + + Object::_Create( guid, 0, HIGHGUID_PLAYER ); + + m_name = fields[3].GetCppString(); + + // check name limitations + if(!ObjectMgr::IsValidName(m_name) || GetSession()->GetSecurity() == SEC_PLAYER && objmgr.IsReservedName(m_name)) + { + delete result; + CharacterDatabase.PExecute("UPDATE characters SET at_login = at_login | '%u' WHERE guid ='%u'", uint32(AT_LOGIN_RENAME),guid); + return false; + } + + if(!LoadValues( fields[2].GetString())) + { + sLog.outError("ERROR: Player #%d have broken data in `data` field. Can't be loaded.",GUID_LOPART(guid)); + delete result; + return false; + } + + // overwrite possible wrong/corrupted guid + SetUInt64Value(OBJECT_FIELD_GUID, MAKE_NEW_GUID(guid, 0, HIGHGUID_PLAYER)); + + // cleanup inventory related item value fields (its will be filled correctly in _LoadInventory) + for(uint8 slot = EQUIPMENT_SLOT_START; slot < EQUIPMENT_SLOT_END; ++slot) + { + SetUInt64Value( (uint16)(PLAYER_FIELD_INV_SLOT_HEAD + (slot * 2) ), 0 ); + SetVisibleItemSlot(slot,NULL); + + if (m_items[slot]) + { + delete m_items[slot]; + m_items[slot] = NULL; + } + } + + // update money limits + if(GetMoney() > MAX_MONEY_AMOUNT) + SetMoney(MAX_MONEY_AMOUNT); + + sLog.outDebug("Load Basic value of player %s is: ", m_name.c_str()); + outDebugValues(); + + m_race = fields[4].GetUInt8(); + //Need to call it to initialize m_team (m_team can be calculated from m_race) + //Other way is to saves m_team into characters table. + setFactionForRace(m_race); + SetCharm(0); + + m_class = fields[5].GetUInt8(); + + PlayerInfo const *info = objmgr.GetPlayerInfo(m_race, m_class); + if(!info) + { + sLog.outError("Player have incorrect race/class pair. Can't be loaded."); + delete result; + return false; + } + + InitPrimaryProffesions(); // to max set before any spell loaded + + uint32 transGUID = fields[24].GetUInt32(); + Relocate(fields[6].GetFloat(),fields[7].GetFloat(),fields[8].GetFloat(),fields[10].GetFloat()); + SetMapId(fields[9].GetUInt32()); + SetDifficulty(fields[32].GetUInt32()); // may be changed in _LoadGroup + + _LoadGroup(holder->GetResult(PLAYER_LOGIN_QUERY_LOADGROUP)); + + // check arena teams integrity + for(uint32 arena_slot = 0; arena_slot < MAX_ARENA_SLOT; ++arena_slot) + { + uint32 arena_team_id = GetArenaTeamId(arena_slot); + if(!arena_team_id) + continue; + + if(ArenaTeam * at = objmgr.GetArenaTeamById(arena_team_id)) + if(at->HaveMember(GetGUID())) + continue; + + // arena team not exist or not member, cleanup fields + for(int j =0; j < 6; ++j) + SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + arena_slot * 6 + j, 0); + } + + _LoadBoundInstances(holder->GetResult(PLAYER_LOGIN_QUERY_LOADBOUNDINSTANCES)); + + if(!IsPositionValid()) + { + sLog.outError("ERROR: Player (guidlow %d) have invalid coordinates (X: %f Y: %f Z: %f O: %f). Teleport to default race/class locations.",guid,GetPositionX(),GetPositionY(),GetPositionZ(),GetOrientation()); + + SetMapId(info->mapId); + Relocate(info->positionX,info->positionY,info->positionZ,0.0f); + + transGUID = 0; + + m_movementInfo.t_x = 0.0f; + m_movementInfo.t_y = 0.0f; + m_movementInfo.t_z = 0.0f; + m_movementInfo.t_o = 0.0f; + } + + // load the player's map here if it's not already loaded + Map *map = GetMap(); + // since the player may not be bound to the map yet, make sure subsequent + // getmap calls won't create new maps + SetInstanceId(map->GetInstanceId()); + + SaveRecallPosition(); + + if (transGUID != 0) + { + m_movementInfo.t_x = fields[20].GetFloat(); + m_movementInfo.t_y = fields[21].GetFloat(); + m_movementInfo.t_z = fields[22].GetFloat(); + m_movementInfo.t_o = fields[23].GetFloat(); + + if( !MaNGOS::IsValidMapCoord( + GetPositionX()+m_movementInfo.t_x,GetPositionY()+m_movementInfo.t_y, + GetPositionZ()+m_movementInfo.t_z,GetOrientation()+m_movementInfo.t_o) || + // transport size limited + m_movementInfo.t_x > 50 || m_movementInfo.t_y > 50 || m_movementInfo.t_z > 50 ) + { + sLog.outError("ERROR: Player (guidlow %d) have invalid transport coordinates (X: %f Y: %f Z: %f O: %f). Teleport to default race/class locations.", + guid,GetPositionX()+m_movementInfo.t_x,GetPositionY()+m_movementInfo.t_y, + GetPositionZ()+m_movementInfo.t_z,GetOrientation()+m_movementInfo.t_o); + + SetMapId(info->mapId); + Relocate(info->positionX,info->positionY,info->positionZ,0.0f); + + m_movementInfo.t_x = 0.0f; + m_movementInfo.t_y = 0.0f; + m_movementInfo.t_z = 0.0f; + m_movementInfo.t_o = 0.0f; + + transGUID = 0; + } + } + + if (transGUID != 0) + { + for (MapManager::TransportSet::iterator iter = MapManager::Instance().m_Transports.begin(); iter != MapManager::Instance().m_Transports.end(); ++iter) + { + if( (*iter)->GetGUIDLow() == transGUID) + { + m_transport = *iter; + m_transport->AddPassenger(this); + SetMapId(m_transport->GetMapId()); + break; + } + } + + if(!m_transport) + { + sLog.outError("ERROR: Player (guidlow %d) have invalid transport guid (%u). Teleport to default race/class locations.", + guid,transGUID); + + SetMapId(info->mapId); + Relocate(info->positionX,info->positionY,info->positionZ,0.0f); + + m_movementInfo.t_x = 0.0f; + m_movementInfo.t_y = 0.0f; + m_movementInfo.t_z = 0.0f; + m_movementInfo.t_o = 0.0f; + + transGUID = 0; + } + } + + time_t now = time(NULL); + time_t logoutTime = time_t(fields[16].GetUInt64()); + + // since last logout (in seconds) + uint64 time_diff = uint64(now - logoutTime); + + // set value, including drunk invisibility detection + // calculate sobering. after 15 minutes logged out, the player will be sober again + float soberFactor; + if(time_diff > 15*MINUTE) + soberFactor = 0; + else + soberFactor = 1-time_diff/(15.0f*MINUTE); + uint16 newDrunkenValue = uint16(soberFactor*(GetUInt32Value(PLAYER_BYTES_3) & 0xFFFE)); + SetDrunkValue(newDrunkenValue); + + m_rest_bonus = fields[15].GetFloat(); + //speed collect rest bonus in offline, in logout, far from tavern, city (section/in hour) + float bubble0 = 0.031; + //speed collect rest bonus in offline, in logout, in tavern, city (section/in hour) + float bubble1 = 0.125; + + if((int32)fields[16].GetUInt32() > 0) + { + float bubble = fields[17].GetUInt32() > 0 + ? bubble1*sWorld.getRate(RATE_REST_OFFLINE_IN_TAVERN_OR_CITY) + : bubble0*sWorld.getRate(RATE_REST_OFFLINE_IN_WILDERNESS); + + SetRestBonus(GetRestBonus()+ time_diff*((float)GetUInt32Value(PLAYER_NEXT_LEVEL_XP)/72000)*bubble); + } + + m_cinematic = fields[12].GetUInt32(); + m_Played_time[0]= fields[13].GetUInt32(); + m_Played_time[1]= fields[14].GetUInt32(); + + m_resetTalentsCost = fields[18].GetUInt32(); + m_resetTalentsTime = time_t(fields[19].GetUInt64()); + + // reserve some flags + uint32 old_safe_flags = GetUInt32Value(PLAYER_FLAGS) & ( PLAYER_FLAGS_HIDE_CLOAK | PLAYER_FLAGS_HIDE_HELM ); + + if( HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_GM) ) + SetUInt32Value(PLAYER_FLAGS, 0 | old_safe_flags); + + m_taxi.LoadTaxiMask( fields[11].GetString() ); // must be before InitTaxiNodesForLevel + + uint32 gmstate = fields[25].GetUInt32(); + + m_stableSlots = fields[26].GetUInt32(); + if(m_stableSlots > 2) + { + sLog.outError("Player can have not more 2 stable slots, but have in DB %u",uint32(m_stableSlots)); + m_stableSlots = 2; + } + + m_atLoginFlags = fields[27].GetUInt32(); + + // Honor system + // Update Honor kills data + m_lastHonorUpdateTime = logoutTime; + UpdateHonorFields(); + + m_deathExpireTime = (time_t)fields[30].GetUInt64(); + if(m_deathExpireTime > now+MAX_DEATH_COUNT*DEATH_EXPIRE_STEP) + m_deathExpireTime = now+MAX_DEATH_COUNT*DEATH_EXPIRE_STEP-1; + + std::string taxi_nodes = fields[31].GetCppString(); + + delete result; + + // clear channel spell data (if saved at channel spell casting) + SetUInt64Value(UNIT_FIELD_CHANNEL_OBJECT, 0); + SetUInt32Value(UNIT_CHANNEL_SPELL,0); + + // clear charm/summon related fields + SetUInt64Value(UNIT_FIELD_CHARM,0); + SetUInt64Value(UNIT_FIELD_SUMMON,0); + SetUInt64Value(UNIT_FIELD_CHARMEDBY,0); + SetUInt64Value(UNIT_FIELD_SUMMONEDBY,0); + SetUInt64Value(UNIT_FIELD_CREATEDBY,0); + + // reset some aura modifiers before aura apply + SetUInt64Value(PLAYER_FARSIGHT, 0); + SetUInt32Value(PLAYER_TRACK_CREATURES, 0 ); + SetUInt32Value(PLAYER_TRACK_RESOURCES, 0 ); + + // reset skill modifiers and set correct unlearn flags + for (uint32 i = 0; i < PLAYER_MAX_SKILLS; i++) + { + SetUInt32Value(PLAYER_SKILL_BONUS_INDEX(i),0); + + // set correct unlearn bit + uint32 id = GetUInt32Value(PLAYER_SKILL_INDEX(i)) & 0x0000FFFF; + if(!id) continue; + + SkillLineEntry const *pSkill = sSkillLineStore.LookupEntry(id); + if(!pSkill) continue; + + // enable unlearn button for primary professions only + if (pSkill->categoryId == SKILL_CATEGORY_PROFESSION) + SetUInt32Value(PLAYER_SKILL_INDEX(i), MAKE_PAIR32(id,1)); + else + SetUInt32Value(PLAYER_SKILL_INDEX(i), MAKE_PAIR32(id,0)); + } + + // make sure the unit is considered out of combat for proper loading + ClearInCombat(); + + // make sure the unit is considered not in duel for proper loading + SetUInt64Value(PLAYER_DUEL_ARBITER, 0); + SetUInt32Value(PLAYER_DUEL_TEAM, 0); + + // remember loaded power/health values to restore after stats initialization and modifier applying + uint32 savedHealth = GetHealth(); + uint32 savedPower[MAX_POWERS]; + for(uint32 i = 0; i < MAX_POWERS; ++i) + savedPower[i] = GetPower(Powers(i)); + + // reset stats before loading any modifiers + InitStatsForLevel(); + InitTaxiNodesForLevel(); + + // apply original stats mods before spell loading or item equipment that call before equip _RemoveStatsMods() + + //mails are loaded only when needed ;-) - when player in game click on mailbox. + //_LoadMail(); + + _LoadAuras(holder->GetResult(PLAYER_LOGIN_QUERY_LOADAURAS), time_diff); + + // add ghost flag (must be after aura load: PLAYER_FLAGS_GHOST set in aura) + if( HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_GHOST) ) + m_deathState = DEAD; + + _LoadSpells(holder->GetResult(PLAYER_LOGIN_QUERY_LOADSPELLS)); + + // after spell load + InitTalentForLevel(); + learnSkillRewardedSpells(); + + // after spell load, learn rewarded spell if need also + _LoadQuestStatus(holder->GetResult(PLAYER_LOGIN_QUERY_LOADQUESTSTATUS)); + _LoadDailyQuestStatus(holder->GetResult(PLAYER_LOGIN_QUERY_LOADDAILYQUESTSTATUS)); + + _LoadTutorials(holder->GetResult(PLAYER_LOGIN_QUERY_LOADTUTORIALS)); + + // must be before inventory (some items required reputation check) + _LoadReputation(holder->GetResult(PLAYER_LOGIN_QUERY_LOADREPUTATION)); + + _LoadInventory(holder->GetResult(PLAYER_LOGIN_QUERY_LOADINVENTORY), time_diff); + + // update items with duration and realtime + UpdateItemDuration(time_diff, true); + + _LoadActions(holder->GetResult(PLAYER_LOGIN_QUERY_LOADACTIONS)); + + // unread mails and next delivery time, actual mails not loaded + _LoadMailInit(holder->GetResult(PLAYER_LOGIN_QUERY_LOADMAILCOUNT), holder->GetResult(PLAYER_LOGIN_QUERY_LOADMAILDATE)); + + m_social = sSocialMgr.LoadFromDB(holder->GetResult(PLAYER_LOGIN_QUERY_LOADSOCIALLIST), GetGUIDLow()); + + if(!_LoadHomeBind(holder->GetResult(PLAYER_LOGIN_QUERY_LOADHOMEBIND))) + return false; + + // check PLAYER_CHOSEN_TITLE compatibility with PLAYER__FIELD_KNOWN_TITLES + // note: PLAYER__FIELD_KNOWN_TITLES updated at quest status loaded + if(uint32 curTitle = GetUInt32Value(PLAYER_CHOSEN_TITLE)) + { + if(!HasFlag64(PLAYER__FIELD_KNOWN_TITLES,uint64(1) << curTitle)) + SetUInt32Value(PLAYER_CHOSEN_TITLE,0); + } + + // Not finish taxi flight path + if(!m_taxi.LoadTaxiDestinationsFromString(taxi_nodes)) + { + // problems with taxi path loading + TaxiNodesEntry const* nodeEntry = NULL; + if(uint32 node_id = m_taxi.GetTaxiSource()) + nodeEntry = sTaxiNodesStore.LookupEntry(node_id); + + if(!nodeEntry) // don't know taxi start node, to homebind + { + sLog.outError("Character %u have wrong data in taxi destination list, teleport to homebind.",GetGUIDLow()); + SetMapId(m_homebindMapId); + Relocate( m_homebindX, m_homebindY, m_homebindZ,0.0f); + SaveRecallPosition(); // save as recall also to prevent recall and fall from sky + } + else // have start node, to it + { + sLog.outError("Character %u have too short taxi destination list, teleport to original node.",GetGUIDLow()); + SetMapId(nodeEntry->map_id); + Relocate(nodeEntry->x, nodeEntry->y, nodeEntry->z,0.0f); + SaveRecallPosition(); // save as recall also to prevent recall and fall from sky + } + m_taxi.ClearTaxiDestinations(); + } + else if(uint32 node_id = m_taxi.GetTaxiSource()) + { + // save source node as recall coord to prevent recall and fall from sky + TaxiNodesEntry const* nodeEntry = sTaxiNodesStore.LookupEntry(node_id); + assert(nodeEntry); // checked in m_taxi.LoadTaxiDestinationsFromString + m_recallMap = nodeEntry->map_id; + m_recallX = nodeEntry->x; + m_recallY = nodeEntry->y; + m_recallZ = nodeEntry->z; + + // flight will started later + } + + _LoadSpellCooldowns(holder->GetResult(PLAYER_LOGIN_QUERY_LOADSPELLCOOLDOWNS)); + + // Spell code allow apply any auras to dead character in load time in aura/spell/item loading + // Do now before stats re-calculation cleanup for ghost state unexpected auras + if(!isAlive()) + RemoveAllAurasOnDeath(); + + //apply all stat bonuses from items and auras + SetCanModifyStats(true); + UpdateAllStats(); + + // restore remembered power/health values (but not more max values) + SetHealth(savedHealth > GetMaxHealth() ? GetMaxHealth() : savedHealth); + for(uint32 i = 0; i < MAX_POWERS; ++i) + SetPower(Powers(i),savedPower[i] > GetMaxPower(Powers(i)) ? GetMaxPower(Powers(i)) : savedPower[i]); + + sLog.outDebug("The value of player %s after load item and aura is: ", m_name.c_str()); + outDebugValues(); + + // GM state + if(GetSession()->GetSecurity() > SEC_PLAYER) + { + switch(sWorld.getConfig(CONFIG_GM_LOGIN_STATE)) + { + case 0: // disable + break; + case 1: // enable + SetGameMaster(true); + break; + case 2: // save state + if(gmstate) + SetGameMaster(true); + break; + default: + break; + } + } + + _LoadDeclinedNames(holder->GetResult(PLAYER_LOGIN_QUERY_LOADDECLINEDNAMES)); + + return true; +} + +bool Player::isAllowedToLoot(Creature* creature) +{ + if(Player* recipient = creature->GetLootRecipient()) + { + if (recipient == this) + return true; + if( Group* otherGroup = recipient->GetGroup()) + { + Group* thisGroup = GetGroup(); + if(!thisGroup) + return false; + return thisGroup == otherGroup; + } + return false; + } + else + // prevent other players from looting if the recipient got disconnected + return !creature->hasLootRecipient(); +} + +void Player::_LoadActions(QueryResult *result) +{ + m_actionButtons.clear(); + + //QueryResult *result = CharacterDatabase.PQuery("SELECT button,action,type,misc FROM character_action WHERE guid = '%u' ORDER BY button",GetGUIDLow()); + + if(result) + { + do + { + Field *fields = result->Fetch(); + + uint8 button = fields[0].GetUInt8(); + + addActionButton(button, fields[1].GetUInt16(), fields[2].GetUInt8(), fields[3].GetUInt8()); + + m_actionButtons[button].uState = ACTIONBUTTON_UNCHANGED; + } + while( result->NextRow() ); + + delete result; + } +} + +void Player::_LoadAuras(QueryResult *result, uint32 timediff) +{ + m_Auras.clear(); + for (int i = 0; i < TOTAL_AURAS; i++) + m_modAuras[i].clear(); + + // all aura related fields + for(int i = UNIT_FIELD_AURA; i <= UNIT_FIELD_AURASTATE; ++i) + SetUInt32Value(i, 0); + + //QueryResult *result = CharacterDatabase.PQuery("SELECT caster_guid,spell,effect_index,amount,maxduration,remaintime,remaincharges FROM character_aura WHERE guid = '%u'",GetGUIDLow()); + + if(result) + { + do + { + Field *fields = result->Fetch(); + uint64 caster_guid = fields[0].GetUInt64(); + uint32 spellid = fields[1].GetUInt32(); + uint32 effindex = fields[2].GetUInt32(); + int32 damage = (int32)fields[3].GetUInt32(); + int32 maxduration = (int32)fields[4].GetUInt32(); + int32 remaintime = (int32)fields[5].GetUInt32(); + int32 remaincharges = (int32)fields[6].GetUInt32(); + + SpellEntry const* spellproto = sSpellStore.LookupEntry(spellid); + if(!spellproto) + { + sLog.outError("Unknown aura (spellid %u, effindex %u), ignore.",spellid,effindex); + continue; + } + + if(effindex >= 3) + { + sLog.outError("Invalid effect index (spellid %u, effindex %u), ignore.",spellid,effindex); + continue; + } + + // negative effects should continue counting down after logout + if (remaintime != -1 && !IsPositiveEffect(spellid, effindex)) + { + if(remaintime <= int32(timediff)) + continue; + + remaintime -= timediff; + } + + // prevent wrong values of remaincharges + if(spellproto->procCharges) + { + if(remaincharges <= 0 || remaincharges > spellproto->procCharges) + remaincharges = spellproto->procCharges; + } + else + remaincharges = -1; + + //do not load single target auras (unless they were cast by the player) + if (caster_guid != GetGUID() && IsSingleTargetSpell(spellproto)) + continue; + + Aura* aura = CreateAura(spellproto, effindex, NULL, this, NULL); + if(!damage) + damage = aura->GetModifier()->m_amount; + aura->SetLoadedState(caster_guid,damage,maxduration,remaintime,remaincharges); + AddAura(aura); + } + while( result->NextRow() ); + + delete result; + } + + if(m_class == CLASS_WARRIOR) + CastSpell(this,SPELL_ID_PASSIVE_BATTLE_STANCE,true); +} + +void Player::LoadCorpse() +{ + if( isAlive() ) + { + ObjectAccessor::Instance().ConvertCorpseForPlayer(GetGUID()); + } + else + { + if(Corpse *corpse = GetCorpse()) + { + ApplyModFlag(PLAYER_FIELD_BYTES, PLAYER_FIELD_BYTE_RELEASE_TIMER, corpse && !sMapStore.LookupEntry(corpse->GetMapId())->Instanceable() ); + } + else + { + //Prevent Dead Player login without corpse + ResurrectPlayer(0.5f); + } + } +} + +void Player::_LoadInventory(QueryResult *result, uint32 timediff) +{ + //QueryResult *result = CharacterDatabase.PQuery("SELECT data,bag,slot,item,item_template FROM character_inventory JOIN item_instance ON character_inventory.item = item_instance.guid WHERE character_inventory.guid = '%u' ORDER BY bag,slot", GetGUIDLow()); + std::map bagMap; // fast guid lookup for bags + //NOTE: the "order by `bag`" is important because it makes sure + //the bagMap is filled before items in the bags are loaded + //NOTE2: the "order by `slot`" is needed becaue mainhand weapons are (wrongly?) + //expected to be equipped before offhand items (TODO: fixme) + + uint32 zone = GetZoneId(); + + if (result) + { + std::list problematicItems; + + // prevent items from being added to the queue when stored + m_itemUpdateQueueBlocked = true; + do + { + Field *fields = result->Fetch(); + uint32 bag_guid = fields[1].GetUInt32(); + uint8 slot = fields[2].GetUInt8(); + uint32 item_guid = fields[3].GetUInt32(); + uint32 item_id = fields[4].GetUInt32(); + + ItemPrototype const * proto = objmgr.GetItemPrototype(item_id); + + if(!proto) + { + CharacterDatabase.PExecute("DELETE FROM character_inventory WHERE item = '%u'", item_guid); + CharacterDatabase.PExecute("DELETE FROM item_instance WHERE guid = '%u'", item_guid); + sLog.outError( "Player::_LoadInventory: Player %s has an unknown item (id: #%u) in inventory, deleted.", GetName(),item_id ); + continue; + } + + Item *item = NewItemOrBag(proto); + + if(!item->LoadFromDB(item_guid, GetGUID(), result)) + { + sLog.outError( "Player::_LoadInventory: Player %s has broken item (id: #%u) in inventory, deleted.", GetName(),item_id ); + CharacterDatabase.PExecute("DELETE FROM character_inventory WHERE item = '%u'", item_guid); + item->FSetState(ITEM_REMOVED); + item->SaveToDB(); // it also deletes item object ! + continue; + } + + // not allow have in alive state item limited to another map/zone + if(isAlive() && item->IsLimitedToAnotherMapOrZone(GetMapId(),zone) ) + { + CharacterDatabase.PExecute("DELETE FROM character_inventory WHERE item = '%u'", item_guid); + item->FSetState(ITEM_REMOVED); + item->SaveToDB(); // it also deletes item object ! + continue; + } + + // "Conjured items disappear if you are logged out for more than 15 minutes" + if ((timediff > 15*60) && (item->HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAGS_CONJURED))) + { + CharacterDatabase.PExecute("DELETE FROM character_inventory WHERE item = '%u'", item_guid); + item->FSetState(ITEM_REMOVED); + item->SaveToDB(); // it also deletes item object ! + continue; + } + + bool success = true; + + if (!bag_guid) + { + // the item is not in a bag + item->SetContainer( NULL ); + item->SetSlot(slot); + + if( IsInventoryPos( INVENTORY_SLOT_BAG_0, slot ) ) + { + ItemPosCountVec dest; + if( CanStoreItem( INVENTORY_SLOT_BAG_0, slot, dest, item, false ) == EQUIP_ERR_OK ) + item = StoreItem(dest, item, true); + else + success = false; + } + else if( IsEquipmentPos( INVENTORY_SLOT_BAG_0, slot ) ) + { + uint16 dest; + if( CanEquipItem( slot, dest, item, false, false ) == EQUIP_ERR_OK ) + QuickEquipItem(dest, item); + else + success = false; + } + else if( IsBankPos( INVENTORY_SLOT_BAG_0, slot ) ) + { + ItemPosCountVec dest; + if( CanBankItem( INVENTORY_SLOT_BAG_0, slot, dest, item, false, false ) == EQUIP_ERR_OK ) + item = BankItem(dest, item, true); + else + success = false; + } + + if(success) + { + // store bags that may contain items in them + if(item->IsBag() && IsBagPos(item->GetPos())) + bagMap[item_guid] = (Bag*)item; + } + } + else + { + item->SetSlot(NULL_SLOT); + // the item is in a bag, find the bag + std::map::iterator itr = bagMap.find(bag_guid); + if(itr != bagMap.end()) + itr->second->StoreItem(slot, item, true ); + else + success = false; + } + + // item's state may have changed after stored + if (success) + item->SetState(ITEM_UNCHANGED, this); + else + { + sLog.outError("Player::_LoadInventory: Player %s has item (GUID: %u Entry: %u) can't be loaded to inventory (Bag GUID: %u Slot: %u) by some reason, will send by mail.", GetName(),item_guid, item_id, bag_guid, slot); + CharacterDatabase.PExecute("DELETE FROM character_inventory WHERE item = '%u'", item_guid); + problematicItems.push_back(item); + } + } while (result->NextRow()); + + delete result; + m_itemUpdateQueueBlocked = false; + + // send by mail problematic items + while(!problematicItems.empty()) + { + // fill mail + MailItemsInfo mi; // item list prepering + + for(int i = 0; !problematicItems.empty() && i < MAX_MAIL_ITEMS; ++i) + { + Item* item = problematicItems.front(); + problematicItems.pop_front(); + + mi.AddItem(item->GetGUIDLow(), item->GetEntry(), item); + } + + std::string subject = GetSession()->GetMangosString(LANG_NOT_EQUIPPED_ITEM); + + WorldSession::SendMailTo(this, MAIL_NORMAL, MAIL_STATIONERY_GM, GetGUIDLow(), GetGUIDLow(), subject, 0, &mi, 0, 0, MAIL_CHECK_MASK_NONE); + } + } + //if(isAlive()) + _ApplyAllItemMods(); +} + +// load mailed item which should receive current player +void Player::_LoadMailedItems(Mail *mail) +{ + QueryResult* result = CharacterDatabase.PQuery("SELECT item_guid, item_template FROM mail_items WHERE mail_id='%u'", mail->messageID); + if(!result) + return; + + do + { + Field *fields = result->Fetch(); + uint32 item_guid_low = fields[0].GetUInt32(); + uint32 item_template = fields[1].GetUInt32(); + + mail->AddItem(item_guid_low, item_template); + + ItemPrototype const *proto = objmgr.GetItemPrototype(item_template); + + if(!proto) + { + sLog.outError( "Player %u have unknown item_template (ProtoType) in mailed items(GUID: %u template: %u) in mail (%u), deleted.", GetGUIDLow(), item_guid_low, item_template,mail->messageID); + CharacterDatabase.PExecute("DELETE FROM mail_items WHERE item_guid = '%u'", item_guid_low); + CharacterDatabase.PExecute("DELETE FROM item_instance WHERE guid = '%u'", item_guid_low); + continue; + } + + Item *item = NewItemOrBag(proto); + + if(!item->LoadFromDB(item_guid_low, 0)) + { + sLog.outError( "Player::_LoadMailedItems - Item in mail (%u) doesn't exist !!!! - item guid: %u, deleted from mail", mail->messageID, item_guid_low); + CharacterDatabase.PExecute("DELETE FROM mail_items WHERE item_guid = '%u'", item_guid_low); + item->FSetState(ITEM_REMOVED); + item->SaveToDB(); // it also deletes item object ! + continue; + } + + AddMItem(item); + } while (result->NextRow()); + + delete result; +} + +void Player::_LoadMailInit(QueryResult *resultUnread, QueryResult *resultDelivery) +{ + //set a count of unread mails + //QueryResult *resultMails = CharacterDatabase.PQuery("SELECT COUNT(id) FROM mail WHERE receiver = '%u' AND (checked & 1)=0 AND deliver_time <= '" I64FMTD "'", GUID_LOPART(playerGuid),(uint64)cTime); + if (resultUnread) + { + Field *fieldMail = resultUnread->Fetch(); + unReadMails = fieldMail[0].GetUInt8(); + delete resultUnread; + } + + // store nearest delivery time (it > 0 and if it < current then at next player update SendNewMaill will be called) + //resultMails = CharacterDatabase.PQuery("SELECT MIN(deliver_time) FROM mail WHERE receiver = '%u' AND (checked & 1)=0", GUID_LOPART(playerGuid)); + if (resultDelivery) + { + Field *fieldMail = resultDelivery->Fetch(); + m_nextMailDelivereTime = (time_t)fieldMail[0].GetUInt64(); + delete resultDelivery; + } +} + +void Player::_LoadMail() +{ + m_mail.clear(); + //mails are in right order 0 1 2 3 4 5 6 7 8 9 10 11 12 13 + QueryResult *result = CharacterDatabase.PQuery("SELECT id,messageType,sender,receiver,subject,itemTextId,has_items,expire_time,deliver_time,money,cod,checked,stationery,mailTemplateId FROM mail WHERE receiver = '%u' ORDER BY id DESC",GetGUIDLow()); + if(result) + { + do + { + Field *fields = result->Fetch(); + Mail *m = new Mail; + m->messageID = fields[0].GetUInt32(); + m->messageType = fields[1].GetUInt8(); + m->sender = fields[2].GetUInt32(); + m->receiver = fields[3].GetUInt32(); + m->subject = fields[4].GetCppString(); + m->itemTextId = fields[5].GetUInt32(); + bool has_items = fields[6].GetBool(); + m->expire_time = (time_t)fields[7].GetUInt64(); + m->deliver_time = (time_t)fields[8].GetUInt64(); + m->money = fields[9].GetUInt32(); + m->COD = fields[10].GetUInt32(); + m->checked = fields[11].GetUInt32(); + m->stationery = fields[12].GetUInt8(); + m->mailTemplateId = fields[13].GetInt16(); + + if(m->mailTemplateId && !sMailTemplateStore.LookupEntry(m->mailTemplateId)) + { + sLog.outError( "Player::_LoadMail - Mail (%u) have not existed MailTemplateId (%u), remove at load", m->messageID, m->mailTemplateId); + m->mailTemplateId = 0; + } + + m->state = MAIL_STATE_UNCHANGED; + + if (has_items) + _LoadMailedItems(m); + + m_mail.push_back(m); + } while( result->NextRow() ); + delete result; + } + m_mailsLoaded = true; +} + +void Player::LoadPet() +{ + //fixme: the pet should still be loaded if the player is not in world + // just not added to the map + if(IsInWorld()) + { + Pet *pet = new Pet; + if(!pet->LoadPetFromDB(this,0,0,true)) + delete pet; + } +} + +void Player::_LoadQuestStatus(QueryResult *result) +{ + mQuestStatus.clear(); + + uint32 slot = 0; + + //// 0 1 2 3 4 5 6 7 8 9 10 11 12 + //QueryResult *result = CharacterDatabase.PQuery("SELECT quest, status, rewarded, explored, timer, mobcount1, mobcount2, mobcount3, mobcount4, itemcount1, itemcount2, itemcount3, itemcount4 FROM character_queststatus WHERE guid = '%u'", GetGUIDLow()); + + if(result) + { + do + { + Field *fields = result->Fetch(); + + uint32 quest_id = fields[0].GetUInt32(); + // used to be new, no delete? + Quest const* pQuest = objmgr.GetQuestTemplate(quest_id); + if( pQuest ) + { + // find or create + QuestStatusData& questStatusData = mQuestStatus[quest_id]; + + uint32 qstatus = fields[1].GetUInt32(); + if(qstatus < MAX_QUEST_STATUS) + questStatusData.m_status = QuestStatus(qstatus); + else + { + questStatusData.m_status = QUEST_STATUS_NONE; + sLog.outError("Player %s have invalid quest %d status (%d), replaced by QUEST_STATUS_NONE(0).",GetName(),quest_id,qstatus); + } + + questStatusData.m_rewarded = ( fields[2].GetUInt8() > 0 ); + questStatusData.m_explored = ( fields[3].GetUInt8() > 0 ); + + time_t quest_time = time_t(fields[4].GetUInt64()); + + if( pQuest->HasFlag( QUEST_MANGOS_FLAGS_TIMED ) && !GetQuestRewardStatus(quest_id) && questStatusData.m_status != QUEST_STATUS_NONE ) + { + AddTimedQuest( quest_id ); + + if (quest_time <= sWorld.GetGameTime()) + questStatusData.m_timer = 1; + else + questStatusData.m_timer = (quest_time - sWorld.GetGameTime()) * 1000; + } + else + quest_time = 0; + + questStatusData.m_creatureOrGOcount[0] = fields[5].GetUInt32(); + questStatusData.m_creatureOrGOcount[1] = fields[6].GetUInt32(); + questStatusData.m_creatureOrGOcount[2] = fields[7].GetUInt32(); + questStatusData.m_creatureOrGOcount[3] = fields[8].GetUInt32(); + questStatusData.m_itemcount[0] = fields[9].GetUInt32(); + questStatusData.m_itemcount[1] = fields[10].GetUInt32(); + questStatusData.m_itemcount[2] = fields[11].GetUInt32(); + questStatusData.m_itemcount[3] = fields[12].GetUInt32(); + + questStatusData.uState = QUEST_UNCHANGED; + + // add to quest log + if( slot < MAX_QUEST_LOG_SIZE && + ( questStatusData.m_status==QUEST_STATUS_INCOMPLETE || + questStatusData.m_status==QUEST_STATUS_COMPLETE && !questStatusData.m_rewarded ) ) + { + SetQuestSlot(slot,quest_id,quest_time); + + if(questStatusData.m_status == QUEST_STATUS_COMPLETE) + SetQuestSlotState(slot,QUEST_STATE_COMPLETE); + + for(uint8 idx = 0; idx < QUEST_OBJECTIVES_COUNT; ++idx) + if(questStatusData.m_creatureOrGOcount[idx]) + SetQuestSlotCounter(slot,idx,questStatusData.m_creatureOrGOcount[idx]); + + ++slot; + } + + if(questStatusData.m_rewarded) + { + // learn rewarded spell if unknown + learnQuestRewardedSpells(pQuest); + + // set rewarded title if any + if(pQuest->GetCharTitleId()) + { + if(CharTitlesEntry const* titleEntry = sCharTitlesStore.LookupEntry(pQuest->GetCharTitleId())) + SetFlag64(PLAYER__FIELD_KNOWN_TITLES, (uint64(1) << titleEntry->bit_index)); + } + } + + sLog.outDebug("Quest status is {%u} for quest {%u} for player (GUID: %u)", questStatusData.m_status, quest_id, GetGUIDLow()); + } + } + while( result->NextRow() ); + + delete result; + } + + // clear quest log tail + for ( uint16 i = slot; i < MAX_QUEST_LOG_SIZE; ++i ) + SetQuestSlot(i,0); +} + +void Player::_LoadDailyQuestStatus(QueryResult *result) +{ + for(uint32 quest_daily_idx = 0; quest_daily_idx < PLAYER_MAX_DAILY_QUESTS; ++quest_daily_idx) + SetUInt32Value(PLAYER_FIELD_DAILY_QUESTS_1+quest_daily_idx,0); + + //QueryResult *result = CharacterDatabase.PQuery("SELECT quest,time FROM character_queststatus_daily WHERE guid = '%u'", GetGUIDLow()); + + if(result) + { + uint32 quest_daily_idx = 0; + + do + { + if(quest_daily_idx >= PLAYER_MAX_DAILY_QUESTS) // max amount with exist data in query + { + sLog.outError("Player (GUID: %u) have more 25 daily quest records in `charcter_queststatus_daily`",GetGUIDLow()); + break; + } + + Field *fields = result->Fetch(); + + uint32 quest_id = fields[0].GetUInt32(); + + // save _any_ from daily quest times (it must be after last reset anyway) + m_lastDailyQuestTime = (time_t)fields[1].GetUInt64(); + + Quest const* pQuest = objmgr.GetQuestTemplate(quest_id); + if( !pQuest ) + continue; + + SetUInt32Value(PLAYER_FIELD_DAILY_QUESTS_1+quest_daily_idx,quest_id); + ++quest_daily_idx; + + sLog.outDebug("Daily quest {%u} cooldown for player (GUID: %u)", quest_id, GetGUIDLow()); + } + while( result->NextRow() ); + + delete result; + } + + m_DailyQuestChanged = false; +} + +void Player::_LoadReputation(QueryResult *result) +{ + m_factions.clear(); + + // Set initial reputations (so everything is nifty before DB data load) + SetInitialFactions(); + + //QueryResult *result = CharacterDatabase.PQuery("SELECT faction,standing,flags FROM character_reputation WHERE guid = '%u'",GetGUIDLow()); + + if(result) + { + do + { + Field *fields = result->Fetch(); + + FactionEntry const *factionEntry = sFactionStore.LookupEntry(fields[0].GetUInt32()); + if( factionEntry && (factionEntry->reputationListID >= 0)) + { + FactionState* faction = &m_factions[factionEntry->reputationListID]; + + // update standing to current + faction->Standing = int32(fields[1].GetUInt32()); + + uint32 dbFactionFlags = fields[2].GetUInt32(); + + if( dbFactionFlags & FACTION_FLAG_VISIBLE ) + SetFactionVisible(faction); // have internal checks for forced invisibility + + if( dbFactionFlags & FACTION_FLAG_INACTIVE) + SetFactionInactive(faction,true); // have internal checks for visibility requirement + + if( dbFactionFlags & FACTION_FLAG_AT_WAR ) // DB at war + SetFactionAtWar(faction,true); // have internal checks for FACTION_FLAG_PEACE_FORCED + else // DB not at war + { + // allow remove if visible (and then not FACTION_FLAG_INVISIBLE_FORCED or FACTION_FLAG_HIDDEN) + if( faction->Flags & FACTION_FLAG_VISIBLE ) + SetFactionAtWar(faction,false); // have internal checks for FACTION_FLAG_PEACE_FORCED + } + + // set atWar for hostile + if(GetReputationRank(factionEntry) <= REP_HOSTILE) + SetFactionAtWar(faction,true); + + // reset changed flag if values similar to saved in DB + if(faction->Flags==dbFactionFlags) + faction->Changed = false; + } + } + while( result->NextRow() ); + + delete result; + } +} + +void Player::_LoadSpells(QueryResult *result) +{ + for (PlayerSpellMap::iterator itr = m_spells.begin(); itr != m_spells.end(); ++itr) + delete itr->second; + m_spells.clear(); + + //QueryResult *result = CharacterDatabase.PQuery("SELECT spell,slot,active FROM character_spell WHERE guid = '%u'",GetGUIDLow()); + + if(result) + { + do + { + Field *fields = result->Fetch(); + + addSpell(fields[0].GetUInt16(), fields[2].GetBool(), false, true, fields[1].GetUInt16(), fields[3].GetBool()); + } + while( result->NextRow() ); + + delete result; + } +} + +void Player::_LoadTutorials(QueryResult *result) +{ + //QueryResult *result = CharacterDatabase.PQuery("SELECT tut0,tut1,tut2,tut3,tut4,tut5,tut6,tut7 FROM character_tutorial WHERE account = '%u' AND realmid = '%u'", GetAccountId(), realmid); + + if(result) + { + do + { + Field *fields = result->Fetch(); + + for (int iI=0; iI<8; iI++) + m_Tutorials[iI] = fields[iI].GetUInt32(); + } + while( result->NextRow() ); + + delete result; + } + + m_TutorialsChanged = false; +} + +void Player::_LoadGroup(QueryResult *result) +{ + //QueryResult *result = CharacterDatabase.PQuery("SELECT leaderGuid FROM group_member WHERE memberGuid='%u'", GetGUIDLow()); + if(result) + { + uint64 leaderGuid = MAKE_NEW_GUID((*result)[0].GetUInt32(), 0, HIGHGUID_PLAYER); + delete result; + Group* group = objmgr.GetGroupByLeader(leaderGuid); + if(group) + { + uint8 subgroup = group->GetMemberGroup(GetGUID()); + SetGroup(group, subgroup); + if(getLevel() >= LEVELREQUIREMENT_HEROIC) + { + // the group leader may change the instance difficulty while the player is offline + SetDifficulty(group->GetDifficulty()); + } + } + } +} + +void Player::_LoadBoundInstances(QueryResult *result) +{ + for(uint8 i = 0; i < TOTAL_DIFFICULTIES; i++) + m_boundInstances[i].clear(); + + Group *group = GetGroup(); + + //QueryResult *result = CharacterDatabase.PQuery("SELECT id, permanent, map, difficulty, resettime FROM character_instance LEFT JOIN instance ON instance = id WHERE guid = '%u'", GUID_LOPART(m_guid)); + if(result) + { + do + { + Field *fields = result->Fetch(); + bool perm = fields[1].GetBool(); + uint32 mapId = fields[2].GetUInt32(); + uint32 instanceId = fields[0].GetUInt32(); + uint8 difficulty = fields[3].GetUInt8(); + time_t resetTime = (time_t)fields[4].GetUInt64(); + // the resettime for normal instances is only saved when the InstanceSave is unloaded + // so the value read from the DB may be wrong here but only if the InstanceSave is loaded + // and in that case it is not used + + if(!perm && group) + { + sLog.outError("_LoadBoundInstances: player %s(%d) is in group %d but has a non-permanent character bind to map %d,%d,%d", GetName(), GetGUIDLow(), GUID_LOPART(group->GetLeaderGUID()), mapId, instanceId, difficulty); + CharacterDatabase.PExecute("DELETE FROM character_instance WHERE guid = '%d' AND instance = '%d'", GetGUIDLow(), instanceId); + continue; + } + + // since non permanent binds are always solo bind, they can always be reset + InstanceSave *save = sInstanceSaveManager.AddInstanceSave(mapId, instanceId, difficulty, resetTime, !perm, true); + if(save) BindToInstance(save, perm, true); + } while(result->NextRow()); + delete result; + } +} + +InstancePlayerBind* Player::GetBoundInstance(uint32 mapid, uint8 difficulty) +{ + // some instances only have one difficulty + const MapEntry* entry = sMapStore.LookupEntry(mapid); + if(!entry || !entry->SupportsHeroicMode()) difficulty = DIFFICULTY_NORMAL; + + BoundInstancesMap::iterator itr = m_boundInstances[difficulty].find(mapid); + if(itr != m_boundInstances[difficulty].end()) + return &itr->second; + else + return NULL; +} + +void Player::UnbindInstance(uint32 mapid, uint8 difficulty, bool unload) +{ + BoundInstancesMap::iterator itr = m_boundInstances[difficulty].find(mapid); + UnbindInstance(itr, difficulty, unload); +} + +void Player::UnbindInstance(BoundInstancesMap::iterator &itr, uint8 difficulty, bool unload) +{ + if(itr != m_boundInstances[difficulty].end()) + { + if(!unload) CharacterDatabase.PExecute("DELETE FROM character_instance WHERE guid = '%u' AND instance = '%u'", GetGUIDLow(), itr->second.save->GetInstanceId()); + itr->second.save->RemovePlayer(this); // save can become invalid + m_boundInstances[difficulty].erase(itr++); + } +} + +InstancePlayerBind* Player::BindToInstance(InstanceSave *save, bool permanent, bool load) +{ + if(save) + { + InstancePlayerBind& bind = m_boundInstances[save->GetDifficulty()][save->GetMapId()]; + if(bind.save) + { + // update the save when the group kills a boss + if(permanent != bind.perm || save != bind.save) + if(!load) CharacterDatabase.PExecute("UPDATE character_instance SET instance = '%u', permanent = '%u' WHERE guid = '%u' AND instance = '%u'", save->GetInstanceId(), permanent, GetGUIDLow(), bind.save->GetInstanceId()); + } + else + if(!load) CharacterDatabase.PExecute("INSERT INTO character_instance (guid, instance, permanent) VALUES ('%u', '%u', '%u')", GetGUIDLow(), save->GetInstanceId(), permanent); + + if(bind.save != save) + { + if(bind.save) bind.save->RemovePlayer(this); + save->AddPlayer(this); + } + + if(permanent) save->SetCanReset(false); + + bind.save = save; + bind.perm = permanent; + if(!load) sLog.outDebug("Player::BindToInstance: %s(%d) is now bound to map %d, instance %d, difficulty %d", GetName(), GetGUIDLow(), save->GetMapId(), save->GetInstanceId(), save->GetDifficulty()); + return &bind; + } + else + return NULL; +} + +void Player::SendRaidInfo() +{ + WorldPacket data(SMSG_RAID_INSTANCE_INFO, 4); + + uint32 counter = 0, i; + for(i = 0; i < TOTAL_DIFFICULTIES; i++) + for (BoundInstancesMap::iterator itr = m_boundInstances[i].begin(); itr != m_boundInstances[i].end(); itr++) + if(itr->second.perm) counter++; + + data << counter; + for(i = 0; i < TOTAL_DIFFICULTIES; i++) + { + for (BoundInstancesMap::iterator itr = m_boundInstances[i].begin(); itr != m_boundInstances[i].end(); itr++) + { + if(itr->second.perm) + { + InstanceSave *save = itr->second.save; + data << (save->GetMapId()); + data << (uint32)(save->GetResetTime() - time(NULL)); + data << save->GetInstanceId(); + data << uint32(counter); + counter--; + } + } + } + GetSession()->SendPacket(&data); +} + +/* +- called on every successful teleportation to a map +*/ +void Player::SendSavedInstances() +{ + bool hasBeenSaved = false; + WorldPacket data; + + for(uint8 i = 0; i < TOTAL_DIFFICULTIES; i++) + { + for (BoundInstancesMap::iterator itr = m_boundInstances[i].begin(); itr != m_boundInstances[i].end(); ++itr) + { + if(itr->second.perm) // only permanent binds are sent + { + hasBeenSaved = true; + break; + } + } + } + + //Send opcode 811. true or flase means, whether you have current raid/heroic instances + data.Initialize(SMSG_UPDATE_INSTANCE_OWNERSHIP); + data << uint32(hasBeenSaved); + GetSession()->SendPacket(&data); + + if(!hasBeenSaved) + return; + + for(uint8 i = 0; i < TOTAL_DIFFICULTIES; i++) + { + for (BoundInstancesMap::iterator itr = m_boundInstances[i].begin(); itr != m_boundInstances[i].end(); ++itr) + { + if(itr->second.perm) + { + data.Initialize(SMSG_UPDATE_LAST_INSTANCE); + data << uint32(itr->second.save->GetMapId()); + GetSession()->SendPacket(&data); + } + } + } +} + +/// convert the player's binds to the group +void Player::ConvertInstancesToGroup(Player *player, Group *group, uint64 player_guid) +{ + bool has_binds = false; + bool has_solo = false; + + if(player) { player_guid = player->GetGUID(); if(!group) group = player->GetGroup(); } + assert(player_guid); + + // copy all binds to the group, when changing leader it's assumed the character + // will not have any solo binds + + if(player) + { + for(uint8 i = 0; i < TOTAL_DIFFICULTIES; i++) + { + for (BoundInstancesMap::iterator itr = player->m_boundInstances[i].begin(); itr != player->m_boundInstances[i].end();) + { + has_binds = true; + if(group) group->BindToInstance(itr->second.save, itr->second.perm, true); + // permanent binds are not removed + if(!itr->second.perm) + { + player->UnbindInstance(itr, i, true); // increments itr + has_solo = true; + } + else + ++itr; + } + } + } + + // if the player's not online we don't know what binds it has + if(!player || !group || has_binds) CharacterDatabase.PExecute("INSERT INTO group_instance SELECT guid, instance, permanent FROM character_instance WHERE guid = '%u'", GUID_LOPART(player_guid)); + // the following should not get executed when changing leaders + if(!player || has_solo) CharacterDatabase.PExecute("DELETE FROM character_instance WHERE guid = '%d' AND permanent = 0", GUID_LOPART(player_guid)); +} + +bool Player::_LoadHomeBind(QueryResult *result) +{ + bool ok = false; + //QueryResult *result = CharacterDatabase.PQuery("SELECT map,zone,position_x,position_y,position_z FROM character_homebind WHERE guid = '%u'", GUID_LOPART(playerGuid)); + if (result) + { + Field *fields = result->Fetch(); + m_homebindMapId = fields[0].GetUInt32(); + m_homebindZoneId = fields[1].GetUInt16(); + m_homebindX = fields[2].GetFloat(); + m_homebindY = fields[3].GetFloat(); + m_homebindZ = fields[4].GetFloat(); + delete result; + + // accept saved data only for valid position (and non instanceable) + if( MapManager::IsValidMapCoord(m_homebindMapId,m_homebindX,m_homebindY,m_homebindZ) && + !sMapStore.LookupEntry(m_homebindMapId)->Instanceable() ) + { + ok = true; + } + else + CharacterDatabase.PExecute("DELETE FROM character_homebind WHERE guid = '%u'", GetGUIDLow()); + } + + if(!ok) + { + PlayerInfo const *info = objmgr.GetPlayerInfo(getRace(), getClass()); + if(!info) return false; + + m_homebindMapId = info->mapId; + m_homebindZoneId = info->zoneId; + m_homebindX = info->positionX; + m_homebindY = info->positionY; + m_homebindZ = info->positionZ; + + CharacterDatabase.PExecute("INSERT INTO character_homebind (guid,map,zone,position_x,position_y,position_z) VALUES ('%u', '%u', '%u', '%f', '%f', '%f')", GetGUIDLow(), m_homebindMapId, (uint32)m_homebindZoneId, m_homebindX, m_homebindY, m_homebindZ); + } + + DEBUG_LOG("Setting player home position: mapid is: %u, zoneid is %u, X is %f, Y is %f, Z is %f\n", + m_homebindMapId, m_homebindZoneId, m_homebindX, m_homebindY, m_homebindZ); + + return true; +} + +/*********************************************************/ +/*** SAVE SYSTEM ***/ +/*********************************************************/ + +void Player::SaveToDB() +{ + // delay auto save at any saves (manual, in code, or autosave) + m_nextSave = sWorld.getConfig(CONFIG_INTERVAL_SAVE); + + // first save/honor gain after midnight will also update the player's honor fields + UpdateHonorFields(); + + // Must saved before enter into BattleGround + if(InBattleGround()) + return; + + int is_save_resting = HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_RESTING) ? 1 : 0; + //save, far from tavern/city + //save, but in tavern/city + sLog.outDebug("The value of player %s at save: ", m_name.c_str()); + outDebugValues(); + + // save state (after auras removing), if aura remove some flags then it must set it back by self) + uint32 tmp_bytes = GetUInt32Value(UNIT_FIELD_BYTES_1); + uint32 tmp_bytes2 = GetUInt32Value(UNIT_FIELD_BYTES_2); + uint32 tmp_flags = GetUInt32Value(UNIT_FIELD_FLAGS); + uint32 tmp_pflags = GetUInt32Value(PLAYER_FLAGS); + uint32 tmp_displayid = GetDisplayId(); + + // Set player sit state to standing on save, also stealth and shifted form + SetByteValue(UNIT_FIELD_BYTES_1, 0, 0); // stand state + SetByteValue(UNIT_FIELD_BYTES_2, 3, 0); // shapeshift + SetByteValue(UNIT_FIELD_BYTES_1, 3, 0); // stand flags? + RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_ROTATE); + SetDisplayId(GetNativeDisplayId()); + + bool inworld = IsInWorld(); + + CharacterDatabase.BeginTransaction(); + + CharacterDatabase.PExecute("DELETE FROM characters WHERE guid = '%u'",GetGUIDLow()); + + std::string sql_name = m_name; + CharacterDatabase.escape_string(sql_name); + + std::ostringstream ss; + ss << "INSERT INTO characters (guid,account,name,race,class," + "map, dungeon_difficulty, position_x, position_y, position_z, orientation, data, " + "taximask, online, cinematic, " + "totaltime, leveltime, rest_bonus, logout_time, is_logout_resting, resettalents_cost, resettalents_time, " + "trans_x, trans_y, trans_z, trans_o, transguid, gmstate, stable_slots, at_login, zone, " + "death_expire_time, taxi_path) VALUES (" + << GetGUIDLow() << ", " + << GetSession()->GetAccountId() << ", '" + << sql_name << "', " + << m_race << ", " + << m_class << ", "; + + bool save_to_dest = false; + if(IsBeingTeleported()) + { + // don't save to battlegrounds or arenas + const MapEntry *entry = sMapStore.LookupEntry(GetTeleportDest().mapid); + if(entry && entry->map_type != MAP_BATTLEGROUND && entry->map_type != MAP_ARENA) + save_to_dest = true; + } + + if(!save_to_dest) + { + ss << GetMapId() << ", " + << (uint32)GetDifficulty() << ", " + << finiteAlways(GetPositionX()) << ", " + << finiteAlways(GetPositionY()) << ", " + << finiteAlways(GetPositionZ()) << ", " + << finiteAlways(GetOrientation()) << ", '"; + } + else + { + ss << GetTeleportDest().mapid << ", " + << (uint32)GetDifficulty() << ", " + << finiteAlways(GetTeleportDest().x) << ", " + << finiteAlways(GetTeleportDest().y) << ", " + << finiteAlways(GetTeleportDest().z) << ", " + << finiteAlways(GetTeleportDest().o) << ", '"; + } + + uint16 i; + for( i = 0; i < m_valuesCount; i++ ) + { + ss << GetUInt32Value(i) << " "; + } + + ss << "', '"; + + for( i = 0; i < 8; i++ ) + ss << m_taxi.GetTaximask(i) << " "; + + ss << "', "; + ss << (inworld ? 1 : 0); + + ss << ", "; + ss << m_cinematic; + + ss << ", "; + ss << m_Played_time[0]; + ss << ", "; + ss << m_Played_time[1]; + + ss << ", "; + ss << finiteAlways(m_rest_bonus); + ss << ", "; + ss << (uint64)time(NULL); + ss << ", "; + ss << is_save_resting; + ss << ", "; + ss << m_resetTalentsCost; + ss << ", "; + ss << (uint64)m_resetTalentsTime; + + ss << ", "; + ss << finiteAlways(m_movementInfo.t_x); + ss << ", "; + ss << finiteAlways(m_movementInfo.t_y); + ss << ", "; + ss << finiteAlways(m_movementInfo.t_z); + ss << ", "; + ss << finiteAlways(m_movementInfo.t_o); + ss << ", "; + if (m_transport) + ss << m_transport->GetGUIDLow(); + else + ss << "0"; + + ss << ", "; + ss << (isGameMaster()? 1 : 0); + + ss << ", "; + ss << uint32(m_stableSlots); // to prevent save uint8 as char + + ss << ", "; + ss << uint32(m_atLoginFlags); + + ss << ", "; + ss << GetZoneId(); + + ss << ", "; + ss << (uint64)m_deathExpireTime; + + ss << ", '"; + ss << m_taxi.SaveTaxiDestinationsToString(); + ss << "' )"; + + CharacterDatabase.Execute( ss.str().c_str() ); + + if(m_mailsUpdated) //save mails only when needed + _SaveMail(); + + _SaveInventory(); + _SaveQuestStatus(); + _SaveDailyQuestStatus(); + _SaveTutorials(); + _SaveSpells(); + _SaveSpellCooldowns(); + _SaveActions(); + _SaveAuras(); + _SaveReputation(); + + CharacterDatabase.CommitTransaction(); + + // restore state (before aura apply, if aura remove flag then aura must set it ack by self) + SetDisplayId(tmp_displayid); + SetUInt32Value(UNIT_FIELD_BYTES_1, tmp_bytes); + SetUInt32Value(UNIT_FIELD_BYTES_2, tmp_bytes2); + SetUInt32Value(UNIT_FIELD_FLAGS, tmp_flags); + SetUInt32Value(PLAYER_FLAGS, tmp_pflags); + + // save pet (hunter pet level and experience and all type pets health/mana). + if(Pet* pet = GetPet()) + pet->SavePetToDB(PET_SAVE_AS_CURRENT); +} + +// fast save function for item/money cheating preventing - save only inventory and money state +void Player::SaveInventoryAndGoldToDB() +{ + _SaveInventory(); + SetUInt32ValueInDB(PLAYER_FIELD_COINAGE,GetMoney(),GetGUID()); +} + +void Player::_SaveActions() +{ + for(ActionButtonList::iterator itr = m_actionButtons.begin(); itr != m_actionButtons.end(); ) + { + switch (itr->second.uState) + { + case ACTIONBUTTON_NEW: + CharacterDatabase.PExecute("INSERT INTO character_action (guid,button,action,type,misc) VALUES ('%u', '%u', '%u', '%u', '%u')", + GetGUIDLow(), (uint32)itr->first, (uint32)itr->second.action, (uint32)itr->second.type, (uint32)itr->second.misc ); + itr->second.uState = ACTIONBUTTON_UNCHANGED; + ++itr; + break; + case ACTIONBUTTON_CHANGED: + CharacterDatabase.PExecute("UPDATE character_action SET action = '%u', type = '%u', misc= '%u' WHERE guid= '%u' AND button= '%u' ", + (uint32)itr->second.action, (uint32)itr->second.type, (uint32)itr->second.misc, GetGUIDLow(), (uint32)itr->first ); + itr->second.uState = ACTIONBUTTON_UNCHANGED; + ++itr; + break; + case ACTIONBUTTON_DELETED: + CharacterDatabase.PExecute("DELETE FROM character_action WHERE guid = '%u' and button = '%u'", GetGUIDLow(), (uint32)itr->first ); + m_actionButtons.erase(itr++); + break; + default: + ++itr; + break; + }; + } +} + +void Player::_SaveAuras() +{ + CharacterDatabase.PExecute("DELETE FROM character_aura WHERE guid = '%u'",GetGUIDLow()); + + AuraMap const& auras = GetAuras(); + for(AuraMap::const_iterator itr = auras.begin(); itr != auras.end(); ++itr) + { + SpellEntry const *spellInfo = itr->second->GetSpellProto(); + + //skip all auras from spells that are passive or need a shapeshift + if (itr->second->IsPassive() || itr->second->IsRemovedOnShapeLost()) + continue; + + //do not save single target auras (unless they were cast by the player) + if (itr->second->GetCasterGUID() != GetGUID() && IsSingleTargetSpell(spellInfo)) + continue; + + uint8 i; + // or apply at cast SPELL_AURA_MOD_SHAPESHIFT or SPELL_AURA_MOD_STEALTH auras + for (i = 0; i < 3; i++) + if (spellInfo->EffectApplyAuraName[i] == SPELL_AURA_MOD_SHAPESHIFT || + spellInfo->EffectApplyAuraName[i] == SPELL_AURA_MOD_STEALTH) + break; + + if (i == 3) + { + CharacterDatabase.PExecute("DELETE FROM character_aura WHERE guid = '%u' and spell = '%u' and effect_index= '%u'",GetGUIDLow(),(uint32)(*itr).second->GetId(), (uint32)(*itr).second->GetEffIndex()); + CharacterDatabase.PExecute("INSERT INTO character_aura (guid,caster_guid,spell,effect_index,amount,maxduration,remaintime,remaincharges) " + "VALUES ('%u', '" I64FMTD "' ,'%u', '%u', '%d', '%d', '%d', '%d')", + GetGUIDLow(), itr->second->GetCasterGUID(), (uint32)(*itr).second->GetId(), (uint32)(*itr).second->GetEffIndex(), (*itr).second->GetModifier()->m_amount,int((*itr).second->GetAuraMaxDuration()),int((*itr).second->GetAuraDuration()),int((*itr).second->m_procCharges)); + } + } +} + +void Player::_SaveInventory() +{ + // force items in buyback slots to new state + // and remove those that aren't already + for (uint8 i = BUYBACK_SLOT_START; i < BUYBACK_SLOT_END; i++) + { + Item *item = m_items[i]; + if (!item || item->GetState() == ITEM_NEW) continue; + CharacterDatabase.PExecute("DELETE FROM character_inventory WHERE item = '%u'", item->GetGUIDLow()); + CharacterDatabase.PExecute("DELETE FROM item_instance WHERE guid = '%u'", item->GetGUIDLow()); + m_items[i]->FSetState(ITEM_NEW); + } + + // update enchantment durations + for(EnchantDurationList::iterator itr = m_enchantDuration.begin();itr != m_enchantDuration.end();++itr) + { + itr->item->SetEnchantmentDuration(itr->slot,itr->leftduration); + } + + // if no changes + if (m_itemUpdateQueue.empty()) return; + + // do not save if the update queue is corrupt + bool error = false; + for(size_t i = 0; i < m_itemUpdateQueue.size(); i++) + { + Item *item = m_itemUpdateQueue[i]; + if(!item || item->GetState() == ITEM_REMOVED) continue; + Item *test = GetItemByPos( item->GetBagSlot(), item->GetSlot()); + + if (test == NULL) + { + sLog.outError("Player(GUID: %u Name: %s)::_SaveInventory - the bag(%d) and slot(%d) values for the item with guid %d are incorrect, the player doesn't have an item at that position!", GetGUIDLow(), GetName(), item->GetBagSlot(), item->GetSlot(), item->GetGUIDLow()); + error = true; + } + else if (test != item) + { + sLog.outError("Player(GUID: %u Name: %s)::_SaveInventory - the bag(%d) and slot(%d) values for the item with guid %d are incorrect, the item with guid %d is there instead!", GetGUIDLow(), GetName(), item->GetBagSlot(), item->GetSlot(), item->GetGUIDLow(), test->GetGUIDLow()); + error = true; + } + } + + if (error) + { + sLog.outError("Player::_SaveInventory - one or more errors occurred save aborted!"); + ChatHandler(this).SendSysMessage(LANG_ITEM_SAVE_FAILED); + return; + } + + for(size_t i = 0; i < m_itemUpdateQueue.size(); i++) + { + Item *item = m_itemUpdateQueue[i]; + if(!item) continue; + + Bag *container = item->GetContainer(); + uint32 bag_guid = container ? container->GetGUIDLow() : 0; + + switch(item->GetState()) + { + case ITEM_NEW: + CharacterDatabase.PExecute("INSERT INTO character_inventory (guid,bag,slot,item,item_template) VALUES ('%u', '%u', '%u', '%u', '%u')", GetGUIDLow(), bag_guid, item->GetSlot(), item->GetGUIDLow(), item->GetEntry()); + break; + case ITEM_CHANGED: + CharacterDatabase.PExecute("UPDATE character_inventory SET guid='%u', bag='%u', slot='%u', item_template='%u' WHERE item='%u'", GetGUIDLow(), bag_guid, item->GetSlot(), item->GetEntry(), item->GetGUIDLow()); + break; + case ITEM_REMOVED: + CharacterDatabase.PExecute("DELETE FROM character_inventory WHERE item = '%u'", item->GetGUIDLow()); + break; + case ITEM_UNCHANGED: + break; + } + + item->SaveToDB(); // item have unchanged inventory record and can be save standalone + } + m_itemUpdateQueue.clear(); +} + +void Player::_SaveMail() +{ + if (!m_mailsLoaded) + return; + + for (PlayerMails::iterator itr = m_mail.begin(); itr != m_mail.end(); itr++) + { + Mail *m = (*itr); + if (m->state == MAIL_STATE_CHANGED) + { + CharacterDatabase.PExecute("UPDATE mail SET itemTextId = '%u',has_items = '%u',expire_time = '" I64FMTD "', deliver_time = '" I64FMTD "',money = '%u',cod = '%u',checked = '%u' WHERE id = '%u'", + m->itemTextId, m->HasItems() ? 1 : 0, (uint64)m->expire_time, (uint64)m->deliver_time, m->money, m->COD, m->checked, m->messageID); + if(m->removedItems.size()) + { + for(std::vector::iterator itr2 = m->removedItems.begin(); itr2 != m->removedItems.end(); ++itr2) + CharacterDatabase.PExecute("DELETE FROM mail_items WHERE item_guid = '%u'", *itr2); + m->removedItems.clear(); + } + m->state = MAIL_STATE_UNCHANGED; + } + else if (m->state == MAIL_STATE_DELETED) + { + if (m->HasItems()) + for(std::vector::iterator itr2 = m->items.begin(); itr2 != m->items.end(); ++itr2) + CharacterDatabase.PExecute("DELETE FROM item_instance WHERE guid = '%u'", itr2->item_guid); + if (m->itemTextId) + CharacterDatabase.PExecute("DELETE FROM item_text WHERE id = '%u'", m->itemTextId); + CharacterDatabase.PExecute("DELETE FROM mail WHERE id = '%u'", m->messageID); + CharacterDatabase.PExecute("DELETE FROM mail_items WHERE mail_id = '%u'", m->messageID); + } + } + + //deallocate deleted mails... + for (PlayerMails::iterator itr = m_mail.begin(); itr != m_mail.end(); ) + { + if ((*itr)->state == MAIL_STATE_DELETED) + { + Mail* m = *itr; + m_mail.erase(itr); + delete m; + itr = m_mail.begin(); + } + else + ++itr; + } + + m_mailsUpdated = false; +} + +void Player::_SaveQuestStatus() +{ + // we don't need transactions here. + for( QuestStatusMap::iterator i = mQuestStatus.begin( ); i != mQuestStatus.end( ); ++i ) + { + switch (i->second.uState) + { + case QUEST_NEW : + CharacterDatabase.PExecute("INSERT INTO character_queststatus (guid,quest,status,rewarded,explored,timer,mobcount1,mobcount2,mobcount3,mobcount4,itemcount1,itemcount2,itemcount3,itemcount4) " + "VALUES ('%u', '%u', '%u', '%u', '%u', '" I64FMTD "', '%u', '%u', '%u', '%u', '%u', '%u', '%u', '%u')", + GetGUIDLow(), i->first, i->second.m_status, i->second.m_rewarded, i->second.m_explored, uint64(i->second.m_timer / 1000 + sWorld.GetGameTime()), i->second.m_creatureOrGOcount[0], i->second.m_creatureOrGOcount[1], i->second.m_creatureOrGOcount[2], i->second.m_creatureOrGOcount[3], i->second.m_itemcount[0], i->second.m_itemcount[1], i->second.m_itemcount[2], i->second.m_itemcount[3]); + break; + case QUEST_CHANGED : + CharacterDatabase.PExecute("UPDATE character_queststatus SET status = '%u',rewarded = '%u',explored = '%u',timer = '" I64FMTD "',mobcount1 = '%u',mobcount2 = '%u',mobcount3 = '%u',mobcount4 = '%u',itemcount1 = '%u',itemcount2 = '%u',itemcount3 = '%u',itemcount4 = '%u' WHERE guid = '%u' AND quest = '%u' ", + i->second.m_status, i->second.m_rewarded, i->second.m_explored, uint64(i->second.m_timer / 1000 + sWorld.GetGameTime()), i->second.m_creatureOrGOcount[0], i->second.m_creatureOrGOcount[1], i->second.m_creatureOrGOcount[2], i->second.m_creatureOrGOcount[3], i->second.m_itemcount[0], i->second.m_itemcount[1], i->second.m_itemcount[2], i->second.m_itemcount[3], GetGUIDLow(), i->first ); + break; + case QUEST_UNCHANGED: + break; + }; + i->second.uState = QUEST_UNCHANGED; + } +} + +void Player::_SaveDailyQuestStatus() +{ + if(!m_DailyQuestChanged) + return; + + m_DailyQuestChanged = false; + + // save last daily quest time for all quests: we need only mostly reset time for reset check anyway + + // we don't need transactions here. + CharacterDatabase.PExecute("DELETE FROM character_queststatus_daily WHERE guid = '%u'",GetGUIDLow()); + for(uint32 quest_daily_idx = 0; quest_daily_idx < PLAYER_MAX_DAILY_QUESTS; ++quest_daily_idx) + if(GetUInt32Value(PLAYER_FIELD_DAILY_QUESTS_1+quest_daily_idx)) + CharacterDatabase.PExecute("INSERT INTO character_queststatus_daily (guid,quest,time) VALUES ('%u', '%u','" I64FMTD "')", + GetGUIDLow(), GetUInt32Value(PLAYER_FIELD_DAILY_QUESTS_1+quest_daily_idx),uint64(m_lastDailyQuestTime)); +} + +void Player::_SaveReputation() +{ + for(FactionStateList::iterator itr = m_factions.begin(); itr != m_factions.end(); ++itr) + { + if (itr->second.Changed) + { + CharacterDatabase.PExecute("DELETE FROM character_reputation WHERE guid = '%u' AND faction='%u'", GetGUIDLow(), itr->second.ID); + CharacterDatabase.PExecute("INSERT INTO character_reputation (guid,faction,standing,flags) VALUES ('%u', '%u', '%i', '%u')", GetGUIDLow(), itr->second.ID, itr->second.Standing, itr->second.Flags); + itr->second.Changed = false; + } + } +} + +void Player::_SaveSpells() +{ + for (PlayerSpellMap::const_iterator itr = m_spells.begin(), next = m_spells.begin(); itr != m_spells.end(); itr = next) + { + ++next; + if (itr->second->state == PLAYERSPELL_REMOVED || itr->second->state == PLAYERSPELL_CHANGED) + CharacterDatabase.PExecute("DELETE FROM character_spell WHERE guid = '%u' and spell = '%u'", GetGUIDLow(), itr->first); + if (itr->second->state == PLAYERSPELL_NEW || itr->second->state == PLAYERSPELL_CHANGED) + CharacterDatabase.PExecute("INSERT INTO character_spell (guid,spell,slot,active,disabled) VALUES ('%u', '%u', '%u','%u','%u')", GetGUIDLow(), itr->first, itr->second->slotId,itr->second->active ? 1 : 0,itr->second->disabled ? 1 : 0); + + if (itr->second->state == PLAYERSPELL_REMOVED) + _removeSpell(itr->first); + else + itr->second->state = PLAYERSPELL_UNCHANGED; + } +} + +void Player::_SaveTutorials() +{ + if(!m_TutorialsChanged) + return; + + uint32 Rows=0; + // it's better than rebuilding indexes multiple times + QueryResult *result = CharacterDatabase.PQuery("SELECT count(*) AS r FROM character_tutorial WHERE account = '%u' AND realmid = '%u'", GetSession()->GetAccountId(), realmID ); + if(result) + { + Rows = result->Fetch()[0].GetUInt32(); + delete result; + } + + if (Rows) + { + CharacterDatabase.PExecute("UPDATE character_tutorial SET tut0='%u', tut1='%u', tut2='%u', tut3='%u', tut4='%u', tut5='%u', tut6='%u', tut7='%u' WHERE account = '%u' AND realmid = '%u'", + m_Tutorials[0], m_Tutorials[1], m_Tutorials[2], m_Tutorials[3], m_Tutorials[4], m_Tutorials[5], m_Tutorials[6], m_Tutorials[7], GetSession()->GetAccountId(), realmID ); + } + else + { + CharacterDatabase.PExecute("INSERT INTO character_tutorial (account,realmid,tut0,tut1,tut2,tut3,tut4,tut5,tut6,tut7) VALUES ('%u', '%u', '%u', '%u', '%u', '%u', '%u', '%u', '%u', '%u')", GetSession()->GetAccountId(), realmID, m_Tutorials[0], m_Tutorials[1], m_Tutorials[2], m_Tutorials[3], m_Tutorials[4], m_Tutorials[5], m_Tutorials[6], m_Tutorials[7]); + }; + + m_TutorialsChanged = false; +} + +void Player::outDebugValues() const +{ + if(!sLog.IsOutDebug()) // optimize disabled debug output + return; + + sLog.outDebug("HP is: \t\t\t%u\t\tMP is: \t\t\t%u",GetMaxHealth(), GetMaxPower(POWER_MANA)); + sLog.outDebug("AGILITY is: \t\t%f\t\tSTRENGTH is: \t\t%f",GetStat(STAT_AGILITY), GetStat(STAT_STRENGTH)); + sLog.outDebug("INTELLECT is: \t\t%f\t\tSPIRIT is: \t\t%f",GetStat(STAT_INTELLECT), GetStat(STAT_SPIRIT)); + sLog.outDebug("STAMINA is: \t\t%f\t\tSPIRIT is: \t\t%f",GetStat(STAT_STAMINA), GetStat(STAT_SPIRIT)); + sLog.outDebug("Armor is: \t\t%u\t\tBlock is: \t\t%f",GetArmor(), GetFloatValue(PLAYER_BLOCK_PERCENTAGE)); + sLog.outDebug("HolyRes is: \t\t%u\t\tFireRes is: \t\t%u",GetResistance(SPELL_SCHOOL_HOLY), GetResistance(SPELL_SCHOOL_FIRE)); + sLog.outDebug("NatureRes is: \t\t%u\t\tFrostRes is: \t\t%u",GetResistance(SPELL_SCHOOL_NATURE), GetResistance(SPELL_SCHOOL_FROST)); + sLog.outDebug("ShadowRes is: \t\t%u\t\tArcaneRes is: \t\t%u",GetResistance(SPELL_SCHOOL_SHADOW), GetResistance(SPELL_SCHOOL_ARCANE)); + sLog.outDebug("MIN_DAMAGE is: \t\t%f\tMAX_DAMAGE is: \t\t%f",GetFloatValue(UNIT_FIELD_MINDAMAGE), GetFloatValue(UNIT_FIELD_MAXDAMAGE)); + sLog.outDebug("MIN_OFFHAND_DAMAGE is: \t%f\tMAX_OFFHAND_DAMAGE is: \t%f",GetFloatValue(UNIT_FIELD_MINOFFHANDDAMAGE), GetFloatValue(UNIT_FIELD_MAXOFFHANDDAMAGE)); + sLog.outDebug("MIN_RANGED_DAMAGE is: \t%f\tMAX_RANGED_DAMAGE is: \t%f",GetFloatValue(UNIT_FIELD_MINRANGEDDAMAGE), GetFloatValue(UNIT_FIELD_MAXRANGEDDAMAGE)); + sLog.outDebug("ATTACK_TIME is: \t%u\t\tRANGE_ATTACK_TIME is: \t%u",GetAttackTime(BASE_ATTACK), GetAttackTime(RANGED_ATTACK)); +} + +/*********************************************************/ +/*** FLOOD FILTER SYSTEM ***/ +/*********************************************************/ + +void Player::UpdateSpeakTime() +{ + // ignore chat spam protection for GMs in any mode + if(GetSession()->GetSecurity() > SEC_PLAYER) + return; + + time_t current = time (NULL); + if(m_speakTime > current) + { + uint32 max_count = sWorld.getConfig(CONFIG_CHATFLOOD_MESSAGE_COUNT); + if(!max_count) + return; + + ++m_speakCount; + if(m_speakCount >= max_count) + { + // prevent overwrite mute time, if message send just before mutes set, for example. + time_t new_mute = current + sWorld.getConfig(CONFIG_CHATFLOOD_MUTE_TIME); + if(GetSession()->m_muteTime < new_mute) + GetSession()->m_muteTime = new_mute; + + m_speakCount = 0; + } + } + else + m_speakCount = 0; + + m_speakTime = current + sWorld.getConfig(CONFIG_CHATFLOOD_MESSAGE_DELAY); +} + +bool Player::CanSpeak() const +{ + return GetSession()->m_muteTime <= time (NULL); +} + +/*********************************************************/ +/*** LOW LEVEL FUNCTIONS:Notifiers ***/ +/*********************************************************/ + +void Player::SendAttackSwingNotInRange() +{ + WorldPacket data(SMSG_ATTACKSWING_NOTINRANGE, 0); + GetSession()->SendPacket( &data ); +} + +void Player::SavePositionInDB(uint32 mapid, float x,float y,float z,float o,uint32 zone,uint64 guid) +{ + std::ostringstream ss; + ss << "UPDATE characters SET position_x='"<= tokens.size()) + return; + + tokens[index] = buf; +} + +void Player::SetUInt32ValueInDB(uint16 index, uint32 value, uint64 guid) +{ + Tokens tokens; + if(!LoadValuesArrayFromDB(tokens,guid)) + return; + + if(index >= tokens.size()) + return; + + char buf[11]; + snprintf(buf,11,"%u",value); + tokens[index] = buf; + + SaveValuesArrayInDB(tokens,guid); +} + +void Player::SetFloatValueInDB(uint16 index, float value, uint64 guid) +{ + uint32 temp; + memcpy(&temp, &value, sizeof(value)); + Player::SetUInt32ValueInDB(index, temp, guid); +} + +void Player::SendAttackSwingNotStanding() +{ + WorldPacket data(SMSG_ATTACKSWING_NOTSTANDING, 0); + GetSession()->SendPacket( &data ); +} + +void Player::SendAttackSwingDeadTarget() +{ + WorldPacket data(SMSG_ATTACKSWING_DEADTARGET, 0); + GetSession()->SendPacket( &data ); +} + +void Player::SendAttackSwingCantAttack() +{ + WorldPacket data(SMSG_ATTACKSWING_CANT_ATTACK, 0); + GetSession()->SendPacket( &data ); +} + +void Player::SendAttackSwingCancelAttack() +{ + WorldPacket data(SMSG_CANCEL_COMBAT, 0); + GetSession()->SendPacket( &data ); +} + +void Player::SendAttackSwingBadFacingAttack() +{ + WorldPacket data(SMSG_ATTACKSWING_BADFACING, 0); + GetSession()->SendPacket( &data ); +} + +void Player::SendAutoRepeatCancel() +{ + WorldPacket data(SMSG_CANCEL_AUTO_REPEAT, 0); + GetSession()->SendPacket( &data ); +} + +void Player::PlaySound(uint32 Sound, bool OnlySelf) +{ + WorldPacket data(SMSG_PLAY_SOUND, 4); + data << Sound; + if (OnlySelf) + GetSession()->SendPacket( &data ); + else + SendMessageToSet( &data, true ); +} + +void Player::SendExplorationExperience(uint32 Area, uint32 Experience) +{ + WorldPacket data( SMSG_EXPLORATION_EXPERIENCE, 8 ); + data << Area; + data << Experience; + GetSession()->SendPacket(&data); +} + +void Player::SendDungeonDifficulty(bool IsInGroup) +{ + uint8 val = 0x00000001; + WorldPacket data(MSG_SET_DUNGEON_DIFFICULTY, 12); + data << (uint32)GetDifficulty(); + data << uint32(val); + data << uint32(IsInGroup); + GetSession()->SendPacket(&data); +} + +void Player::SendResetFailedNotify(uint32 mapid) +{ + WorldPacket data(SMSG_RESET_FAILED_NOTIFY, 4); + data << uint32(mapid); + GetSession()->SendPacket(&data); +} + +/// Reset all solo instances and optionally send a message on success for each +void Player::ResetInstances(uint8 method) +{ + // method can be INSTANCE_RESET_ALL, INSTANCE_RESET_CHANGE_DIFFICULTY, INSTANCE_RESET_GROUP_JOIN + + // we assume that when the difficulty changes, all instances that can be reset will be + uint8 dif = GetDifficulty(); + + for (BoundInstancesMap::iterator itr = m_boundInstances[dif].begin(); itr != m_boundInstances[dif].end();) + { + InstanceSave *p = itr->second.save; + const MapEntry *entry = sMapStore.LookupEntry(itr->first); + if(!entry || !p->CanReset()) + { + ++itr; + continue; + } + + if(method == INSTANCE_RESET_ALL) + { + // the "reset all instances" method can only reset normal maps + if(dif == DIFFICULTY_HEROIC || entry->map_type == MAP_RAID) + { + ++itr; + continue; + } + } + + // if the map is loaded, reset it + Map *map = MapManager::Instance().FindMap(p->GetMapId(), p->GetInstanceId()); + if(map && map->IsDungeon()) + ((InstanceMap*)map)->Reset(method); + + // since this is a solo instance there should not be any players inside + if(method == INSTANCE_RESET_ALL || method == INSTANCE_RESET_CHANGE_DIFFICULTY) + SendResetInstanceSuccess(p->GetMapId()); + + p->DeleteFromDB(); + m_boundInstances[dif].erase(itr++); + + // the following should remove the instance save from the manager and delete it as well + p->RemovePlayer(this); + } +} + +void Player::SendResetInstanceSuccess(uint32 MapId) +{ + WorldPacket data(SMSG_INSTANCE_RESET, 4); + data << MapId; + GetSession()->SendPacket(&data); +} + +void Player::SendResetInstanceFailed(uint32 reason, uint32 MapId) +{ + // TODO: find what other fail reasons there are besides players in the instance + WorldPacket data(SMSG_INSTANCE_RESET_FAILED, 4); + data << reason; + data << MapId; + GetSession()->SendPacket(&data); +} + +/*********************************************************/ +/*** Update timers ***/ +/*********************************************************/ + +///checks the 15 afk reports per 5 minutes limit +void Player::UpdateAfkReport(time_t currTime) +{ + if(m_bgAfkReportedTimer <= currTime) + { + m_bgAfkReportedCount = 0; + m_bgAfkReportedTimer = currTime+5*MINUTE; + } +} + +void Player::UpdateContestedPvP(uint32 diff) +{ + if(!m_contestedPvPTimer||isInCombat()) + return; + if(m_contestedPvPTimer <= diff) + { + ResetContestedPvP(); + } + else + m_contestedPvPTimer -= diff; +} + +void Player::UpdatePvPFlag(time_t currTime) +{ + if(!IsPvP()) + return; + if(pvpInfo.endTimer == 0 || currTime < (pvpInfo.endTimer + 300)) + return; + + UpdatePvP(false); +} + +void Player::UpdateDuelFlag(time_t currTime) +{ + if(!duel || duel->startTimer == 0 ||currTime < duel->startTimer + 3) + return; + + SetUInt32Value(PLAYER_DUEL_TEAM, 1); + duel->opponent->SetUInt32Value(PLAYER_DUEL_TEAM, 2); + + duel->startTimer = 0; + duel->startTime = currTime; + duel->opponent->duel->startTimer = 0; + duel->opponent->duel->startTime = currTime; +} + +void Player::RemovePet(Pet* pet, PetSaveMode mode, bool returnreagent) +{ + if(!pet) + pet = GetPet(); + + if(returnreagent && (pet || m_temporaryUnsummonedPetNumber)) + { + //returning of reagents only for players, so best done here + uint32 spellId = pet ? pet->GetUInt32Value(UNIT_CREATED_BY_SPELL) : m_oldpetspell; + SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellId); + + if(spellInfo) + { + for(uint32 i = 0; i < 7; ++i) + { + if(spellInfo->Reagent[i] > 0) + { + ItemPosCountVec dest; //for succubus, voidwalker, felhunter and felguard credit soulshard when despawn reason other than death (out of range, logout) + uint8 msg = CanStoreNewItem( NULL_BAG, NULL_SLOT, dest, spellInfo->Reagent[i], spellInfo->ReagentCount[i] ); + if( msg == EQUIP_ERR_OK ) + { + Item* item = StoreNewItem( dest, spellInfo->Reagent[i], true); + if(IsInWorld()) + SendNewItem(item,spellInfo->ReagentCount[i],true,false); + } + } + } + } + m_temporaryUnsummonedPetNumber = 0; + } + + if(!pet || pet->GetOwnerGUID()!=GetGUID()) + return; + + // only if current pet in slot + switch(pet->getPetType()) + { + case MINI_PET: + m_miniPet = 0; + break; + case GUARDIAN_PET: + m_guardianPets.erase(pet->GetGUID()); + break; + default: + if(GetPetGUID()==pet->GetGUID()) + SetPet(0); + break; + } + + pet->CombatStop(); + + if(returnreagent) + { + switch(pet->GetEntry()) + { + //warlock pets except imp are removed(?) when logging out + case 1860: + case 1863: + case 417: + case 17252: + mode = PET_SAVE_NOT_IN_SLOT; + break; + } + } + + pet->SavePetToDB(mode); + + pet->CleanupsBeforeDelete(); + pet->AddObjectToRemoveList(); + pet->m_removed = true; + + if(pet->isControlled()) + { + WorldPacket data(SMSG_PET_SPELLS, 8); + data << uint64(0); + GetSession()->SendPacket(&data); + + if(GetGroup()) + SetGroupUpdateFlag(GROUP_UPDATE_PET); + } +} + + +void Player::RemoveMiniPet() +{ + if(Pet* pet = GetMiniPet()) + { + pet->Remove(PET_SAVE_AS_DELETED); + m_miniPet = 0; + } +} + +Pet* Player::GetMiniPet() +{ + if(!m_miniPet) + return NULL; + return ObjectAccessor::GetPet(m_miniPet); +} + +void Player::RemoveGuardians() +{ + while(!m_guardianPets.empty()) + { + uint64 guid = *m_guardianPets.begin(); + if(Pet* pet = ObjectAccessor::GetPet(guid)) + pet->Remove(PET_SAVE_AS_DELETED); + + m_guardianPets.erase(guid); + } +} + +bool Player::HasGuardianWithEntry(uint32 entry) +{ + // pet guid middle part is entry (and creature also) + // and in guardian list must be guardians with same entry _always_ + for(GuardianPetList::const_iterator itr = m_guardianPets.begin(); itr != m_guardianPets.end(); ++itr) + if(GUID_ENPART(*itr)==entry) + return true; + + return false; +} + +void Player::Uncharm() +{ + Unit* charm = GetCharm(); + if(!charm) + return; + + charm->RemoveSpellsCausingAura(SPELL_AURA_MOD_CHARM); + charm->RemoveSpellsCausingAura(SPELL_AURA_MOD_POSSESS); +} + +void Player::BuildPlayerChat(WorldPacket *data, uint8 msgtype, std::string text, uint32 language) const +{ + *data << (uint8)msgtype; + *data << (uint32)language; + *data << (uint64)GetGUID(); + *data << (uint32)language; //language 2.1.0 ? + *data << (uint64)GetGUID(); + *data << (uint32)(text.length()+1); + *data << text; + *data << (uint8)chatTag(); +} + +void Player::Say(const std::string text, const uint32 language) +{ + WorldPacket data(SMSG_MESSAGECHAT, 200); + BuildPlayerChat(&data, CHAT_MSG_SAY, text, language); + SendMessageToSetInRange(&data,sWorld.getConfig(CONFIG_LISTEN_RANGE_SAY),true); +} + +void Player::Yell(const std::string text, const uint32 language) +{ + WorldPacket data(SMSG_MESSAGECHAT, 200); + BuildPlayerChat(&data, CHAT_MSG_YELL, text, language); + SendMessageToSetInRange(&data,sWorld.getConfig(CONFIG_LISTEN_RANGE_YELL),true); +} + +void Player::TextEmote(const std::string text) +{ + WorldPacket data(SMSG_MESSAGECHAT, 200); + BuildPlayerChat(&data, CHAT_MSG_EMOTE, text, LANG_UNIVERSAL); + SendMessageToSetInRange(&data,sWorld.getConfig(CONFIG_LISTEN_RANGE_TEXTEMOTE),true, !sWorld.getConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHAT) ); +} + +void Player::Whisper(std::string text, uint32 language,uint64 receiver) +{ + if (language != LANG_ADDON) // if not addon data + language = LANG_UNIVERSAL; // whispers should always be readable + + Player *rPlayer = objmgr.GetPlayer(receiver); + + // when player you are whispering to is dnd, he cannot receive your message, unless you are in gm mode + if(!rPlayer->isDND() || isGameMaster()) + { + WorldPacket data(SMSG_MESSAGECHAT, 200); + BuildPlayerChat(&data, CHAT_MSG_WHISPER, text, language); + rPlayer->GetSession()->SendPacket(&data); + + data.Initialize(SMSG_MESSAGECHAT, 200); + rPlayer->BuildPlayerChat(&data, CHAT_MSG_REPLY, text, language); + GetSession()->SendPacket(&data); + } + else + { + // announce to player that player he is whispering to is dnd and cannot receive his message + ChatHandler(this).PSendSysMessage(LANG_PLAYER_DND, rPlayer->GetName(), rPlayer->dndMsg.c_str()); + } + + if(!isAcceptWhispers()) + { + SetAcceptWhispers(true); + ChatHandler(this).SendSysMessage(LANG_COMMAND_WHISPERON); + } + + // announce to player that player he is whispering to is afk + if(rPlayer->isAFK()) + ChatHandler(this).PSendSysMessage(LANG_PLAYER_AFK, rPlayer->GetName(), rPlayer->afkMsg.c_str()); + + // if player whisper someone, auto turn of dnd to be able to receive an answer + if(isDND() && !rPlayer->isGameMaster()) + ToggleDND(); +} + +void Player::PetSpellInitialize() +{ + Pet* pet = GetPet(); + + if(pet) + { + uint8 addlist = 0; + + sLog.outDebug("Pet Spells Groups"); + + CreatureInfo const *cinfo = pet->GetCreatureInfo(); + + if(pet->isControlled() && (pet->getPetType() == HUNTER_PET || cinfo && cinfo->type == CREATURE_TYPE_DEMON && getClass() == CLASS_WARLOCK)) + { + for(PetSpellMap::iterator itr = pet->m_spells.begin();itr != pet->m_spells.end();itr++) + { + if(itr->second->state == PETSPELL_REMOVED) + continue; + ++addlist; + } + } + + // first line + actionbar + spellcount + spells + last adds + WorldPacket data(SMSG_PET_SPELLS, 16+40+1+4*addlist+25); + + CharmInfo *charmInfo = pet->GetCharmInfo(); + + //16 + data << (uint64)pet->GetGUID() << uint32(0x00000000) << uint8(charmInfo->GetReactState()) << uint8(charmInfo->GetCommandState()) << uint16(0); + + for(uint32 i = 0; i < 10; i++) //40 + { + data << uint16(charmInfo->GetActionBarEntry(i)->SpellOrAction) << uint16(charmInfo->GetActionBarEntry(i)->Type); + } + + data << uint8(addlist); //1 + + if(addlist && pet->isControlled()) + { + for (PetSpellMap::iterator itr = pet->m_spells.begin(); itr != pet->m_spells.end(); ++itr) + { + if(itr->second->state == PETSPELL_REMOVED) + continue; + + data << uint16(itr->first); + data << uint16(itr->second->active); // pet spell active state isn't boolean + } + } + + //data << uint8(0x01) << uint32(0x6010) << uint32(0x01) << uint32(0x05) << uint16(0x00); //15 + uint8 count = 3; //1+8+8+8=25 + + // if count = 0, then end of packet... + data << count; + // uint32 value is spell id... + // uint64 value is constant 0, unknown... + data << uint32(0x6010) << uint64(0); // if count = 1, 2 or 3 + //data << uint32(0x5fd1) << uint64(0); // if count = 2 + data << uint32(0x8e8c) << uint64(0); // if count = 3 + data << uint32(0x8e8b) << uint64(0); // if count = 3 + + GetSession()->SendPacket(&data); + } +} + +void Player::PossessSpellInitialize() +{ + Unit* charm = GetCharm(); + + if(!charm) + return; + + CharmInfo *charmInfo = charm->GetCharmInfo(); + + if(!charmInfo) + { + sLog.outError("Player::PossessSpellInitialize(): charm ("I64FMTD") has no charminfo!", charm->GetGUID()); + return; + } + + uint8 addlist = 0; + WorldPacket data(SMSG_PET_SPELLS, 16+40+1+4*addlist+25);// first line + actionbar + spellcount + spells + last adds + + //16 + data << (uint64)charm->GetGUID() << uint32(0x00000000) << uint8(0) << uint8(0) << uint16(0); + + for(uint32 i = 0; i < 10; i++) //40 + { + data << uint16(charmInfo->GetActionBarEntry(i)->SpellOrAction) << uint16(charmInfo->GetActionBarEntry(i)->Type); + } + + data << uint8(addlist); //1 + + uint8 count = 3; + data << count; + data << uint32(0x6010) << uint64(0); // if count = 1, 2 or 3 + data << uint32(0x8e8c) << uint64(0); // if count = 3 + data << uint32(0x8e8b) << uint64(0); // if count = 3 + + GetSession()->SendPacket(&data); +} + +void Player::CharmSpellInitialize() +{ + Unit* charm = GetCharm(); + + if(!charm) + return; + + CharmInfo *charmInfo = charm->GetCharmInfo(); + if(!charmInfo) + { + sLog.outError("Player::CharmSpellInitialize(): the player's charm ("I64FMTD") has no charminfo!", charm->GetGUID()); + return; + } + + uint8 addlist = 0; + + if(charm->GetTypeId() != TYPEID_PLAYER) + { + CreatureInfo const *cinfo = ((Creature*)charm)->GetCreatureInfo(); + + if(cinfo && cinfo->type == CREATURE_TYPE_DEMON && getClass() == CLASS_WARLOCK) + { + for(uint32 i = 0; i < CREATURE_MAX_SPELLS; ++i) + { + if(charmInfo->GetCharmSpell(i)->spellId) + ++addlist; + } + } + } + + WorldPacket data(SMSG_PET_SPELLS, 16+40+1+4*addlist+25);// first line + actionbar + spellcount + spells + last adds + + data << (uint64)charm->GetGUID() << uint32(0x00000000); + + if(charm->GetTypeId() != TYPEID_PLAYER) + data << uint8(charmInfo->GetReactState()) << uint8(charmInfo->GetCommandState()); + else + data << uint8(0) << uint8(0); + + data << uint16(0); + + for(uint32 i = 0; i < 10; i++) //40 + { + data << uint16(charmInfo->GetActionBarEntry(i)->SpellOrAction) << uint16(charmInfo->GetActionBarEntry(i)->Type); + } + + data << uint8(addlist); //1 + + if(addlist) + { + for(uint32 i = 0; i < CREATURE_MAX_SPELLS; ++i) + { + CharmSpellEntry *cspell = charmInfo->GetCharmSpell(i); + if(cspell->spellId) + { + data << uint16(cspell->spellId); + data << uint16(cspell->active); + } + } + } + + uint8 count = 3; + data << count; + data << uint32(0x6010) << uint64(0); // if count = 1, 2 or 3 + data << uint32(0x8e8c) << uint64(0); // if count = 3 + data << uint32(0x8e8b) << uint64(0); // if count = 3 + + GetSession()->SendPacket(&data); +} + +int32 Player::GetTotalFlatMods(uint32 spellId, SpellModOp op) +{ + SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellId); + if (!spellInfo) return 0; + int32 total = 0; + for (SpellModList::iterator itr = m_spellMods[op].begin(); itr != m_spellMods[op].end(); ++itr) + { + SpellModifier *mod = *itr; + + if(!IsAffectedBySpellmod(spellInfo,mod)) + continue; + + if (mod->type == SPELLMOD_FLAT) + total += mod->value; + } + return total; +} + +int32 Player::GetTotalPctMods(uint32 spellId, SpellModOp op) +{ + SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellId); + if (!spellInfo) return 0; + int32 total = 0; + for (SpellModList::iterator itr = m_spellMods[op].begin(); itr != m_spellMods[op].end(); ++itr) + { + SpellModifier *mod = *itr; + + if(!IsAffectedBySpellmod(spellInfo,mod)) + continue; + + if (mod->type == SPELLMOD_PCT) + total += mod->value; + } + return total; +} + +bool Player::IsAffectedBySpellmod(SpellEntry const *spellInfo, SpellModifier *mod, Spell const* spell) +{ + if (!mod || !spellInfo) + return false; + + if(mod->charges == -1 && mod->lastAffected ) // marked as expired but locked until spell casting finish + { + // prevent apply to any spell except spell that trigger expire + if(spell) + { + if(mod->lastAffected != spell) + return false; + } + else if(mod->lastAffected != FindCurrentSpellBySpellId(spellInfo->Id)) + return false; + } + + return spellmgr.IsAffectedBySpell(spellInfo,mod->spellId,mod->effectId,mod->mask); +} + +void Player::AddSpellMod(SpellModifier* mod, bool apply) +{ + uint16 Opcode= (mod->type == SPELLMOD_FLAT) ? SMSG_SET_FLAT_SPELL_MODIFIER : SMSG_SET_PCT_SPELL_MODIFIER; + + for(int eff=0;eff<64;++eff) + { + uint64 _mask = uint64(1) << eff; + if ( mod->mask & _mask) + { + int32 val = 0; + for (SpellModList::iterator itr = m_spellMods[mod->op].begin(); itr != m_spellMods[mod->op].end(); ++itr) + { + if ((*itr)->type == mod->type && (*itr)->mask & _mask) + val += (*itr)->value; + } + val += apply ? mod->value : -(mod->value); + WorldPacket data(Opcode, (1+1+4)); + data << uint8(eff); + data << uint8(mod->op); + data << int32(val); + SendDirectMessage(&data); + } + } + + if (apply) + m_spellMods[mod->op].push_back(mod); + else + { + if (mod->charges == -1) + --m_SpellModRemoveCount; + m_spellMods[mod->op].remove(mod); + delete mod; + } +} + +void Player::RemoveSpellMods(Spell const* spell) +{ + if(!spell || (m_SpellModRemoveCount == 0)) + return; + + for(int i=0;icharges == -1 && (mod->lastAffected == spell || mod->lastAffected==NULL)) + { + RemoveAurasDueToSpell(mod->spellId); + if (m_spellMods[i].empty()) + break; + else + itr = m_spellMods[i].begin(); + } + } + } +} + +// send Proficiency +void Player::SendProficiency(uint8 pr1, uint32 pr2) +{ + WorldPacket data(SMSG_SET_PROFICIENCY, 8); + data << pr1 << pr2; + GetSession()->SendPacket (&data); +} + +void Player::RemovePetitionsAndSigns(uint64 guid, uint32 type) +{ + QueryResult *result = NULL; + if(type==10) + result = CharacterDatabase.PQuery("SELECT ownerguid,petitionguid FROM petition_sign WHERE playerguid = '%u'", GUID_LOPART(guid)); + else + result = CharacterDatabase.PQuery("SELECT ownerguid,petitionguid FROM petition_sign WHERE playerguid = '%u' AND type = '%u'", GUID_LOPART(guid), type); + if(result) + { + do // this part effectively does nothing, since the deletion / modification only takes place _after_ the PetitionQuery. Though I don't know if the result remains intact if I execute the delete query beforehand. + { // and SendPetitionQueryOpcode reads data from the DB + Field *fields = result->Fetch(); + uint64 ownerguid = MAKE_NEW_GUID(fields[0].GetUInt32(), 0, HIGHGUID_PLAYER); + uint64 petitionguid = MAKE_NEW_GUID(fields[1].GetUInt32(), 0, HIGHGUID_ITEM); + + // send update if charter owner in game + Player* owner = objmgr.GetPlayer(ownerguid); + if(owner) + owner->GetSession()->SendPetitionQueryOpcode(petitionguid); + + } while ( result->NextRow() ); + + delete result; + + if(type==10) + CharacterDatabase.PExecute("DELETE FROM petition_sign WHERE playerguid = '%u'", GUID_LOPART(guid)); + else + CharacterDatabase.PExecute("DELETE FROM petition_sign WHERE playerguid = '%u' AND type = '%u'", GUID_LOPART(guid), type); + } + + CharacterDatabase.BeginTransaction(); + if(type == 10) + { + CharacterDatabase.PExecute("DELETE FROM petition WHERE ownerguid = '%u'", GUID_LOPART(guid)); + CharacterDatabase.PExecute("DELETE FROM petition_sign WHERE ownerguid = '%u'", GUID_LOPART(guid)); + } + else + { + CharacterDatabase.PExecute("DELETE FROM petition WHERE ownerguid = '%u' AND type = '%u'", GUID_LOPART(guid), type); + CharacterDatabase.PExecute("DELETE FROM petition_sign WHERE ownerguid = '%u' AND type = '%u'", GUID_LOPART(guid), type); + } + CharacterDatabase.CommitTransaction(); +} + +void Player::SetRestBonus (float rest_bonus_new) +{ + // Prevent resting on max level + if(getLevel() >= sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL)) + rest_bonus_new = 0; + + if(rest_bonus_new < 0) + rest_bonus_new = 0; + + float rest_bonus_max = (float)GetUInt32Value(PLAYER_NEXT_LEVEL_XP)*1.5/2; + + if(rest_bonus_new > rest_bonus_max) + m_rest_bonus = rest_bonus_max; + else + m_rest_bonus = rest_bonus_new; + + // update data for client + if(m_rest_bonus>10) + SetByteValue(PLAYER_BYTES_2, 3, 0x01); // Set Reststate = Rested + else if(m_rest_bonus<=1) + SetByteValue(PLAYER_BYTES_2, 3, 0x02); // Set Reststate = Normal + + //RestTickUpdate + SetUInt32Value(PLAYER_REST_STATE_EXPERIENCE, uint32(m_rest_bonus)); +} + +void Player::HandleStealthedUnitsDetection() +{ + std::list stealthedUnits; + + CellPair p(MaNGOS::ComputeCellPair(GetPositionX(),GetPositionY())); + Cell cell(p); + cell.data.Part.reserved = ALL_DISTRICT; + cell.SetNoCreate(); + + MaNGOS::AnyStealthedCheck u_check; + MaNGOS::UnitListSearcher searcher(stealthedUnits, u_check); + + TypeContainerVisitor, WorldTypeMapContainer > world_unit_searcher(searcher); + TypeContainerVisitor, GridTypeMapContainer > grid_unit_searcher(searcher); + + CellLock cell_lock(cell, p); + cell_lock->Visit(cell_lock, world_unit_searcher, *MapManager::Instance().GetMap(GetMapId(), this)); + cell_lock->Visit(cell_lock, grid_unit_searcher, *MapManager::Instance().GetMap(GetMapId(), this)); + + for (std::list::iterator i = stealthedUnits.begin(); i != stealthedUnits.end();) + { + if((*i)==this) + { + i = stealthedUnits.erase(i); + continue; + } + + if ((*i)->isVisibleForOrDetect(this,true)) + { + + (*i)->SendUpdateToPlayer(this); + m_clientGUIDs.insert((*i)->GetGUID()); + + #ifdef MANGOS_DEBUG + if((sLog.getLogFilter() & LOG_FILTER_VISIBILITY_CHANGES)==0) + sLog.outDebug("Object %u (Type: %u) is detected in stealth by player %u. Distance = %f",(*i)->GetGUIDLow(),(*i)->GetTypeId(),GetGUIDLow(),GetDistance(*i)); + #endif + + // target aura duration for caster show only if target exist at caster client + // send data at target visibility change (adding to client) + if((*i)!=this && (*i)->isType(TYPEMASK_UNIT)) + SendAuraDurationsForTarget(*i); + + i = stealthedUnits.erase(i); + continue; + } + + ++i; + } +} + +bool Player::ActivateTaxiPathTo(std::vector const& nodes, uint32 mount_id, Creature* npc) +{ + if(nodes.size() < 2) + return false; + + // not let cheating with start flight mounted + if(IsMounted()) + { + WorldPacket data(SMSG_ACTIVATETAXIREPLY, 4); + data << uint32(ERR_TAXIPLAYERALREADYMOUNTED); + GetSession()->SendPacket(&data); + return false; + } + + if( m_ShapeShiftFormSpellId && m_form != FORM_BATTLESTANCE && m_form != FORM_BERSERKERSTANCE && m_form != FORM_DEFENSIVESTANCE && m_form != FORM_SHADOW ) + { + WorldPacket data(SMSG_ACTIVATETAXIREPLY, 4); + data << uint32(ERR_TAXIPLAYERSHAPESHIFTED); + GetSession()->SendPacket(&data); + return false; + } + + // not let cheating with start flight in time of logout process || if casting not finished || while in combat || if not use Spell's with EffectSendTaxi + if(GetSession()->isLogingOut() || + (!m_currentSpells[CURRENT_GENERIC_SPELL] || + m_currentSpells[CURRENT_GENERIC_SPELL]->m_spellInfo->Effect[0] != SPELL_EFFECT_SEND_TAXI)&& + IsNonMeleeSpellCasted(false) || + isInCombat()) + { + WorldPacket data(SMSG_ACTIVATETAXIREPLY, 4); + data << uint32(ERR_TAXIPLAYERBUSY); + GetSession()->SendPacket(&data); + return false; + } + + if(HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_MOVE)) + return false; + + uint32 sourcenode = nodes[0]; + + // starting node too far away (cheat?) + TaxiNodesEntry const* node = sTaxiNodesStore.LookupEntry(sourcenode); + if( !node || node->map_id != GetMapId() || + (node->x - GetPositionX())*(node->x - GetPositionX())+ + (node->y - GetPositionY())*(node->y - GetPositionY())+ + (node->z - GetPositionZ())*(node->z - GetPositionZ()) > + (2*INTERACTION_DISTANCE)*(2*INTERACTION_DISTANCE)*(2*INTERACTION_DISTANCE) ) + { + WorldPacket data(SMSG_ACTIVATETAXIREPLY, 4); + data << uint32(ERR_TAXIUNSPECIFIEDSERVERERROR); + GetSession()->SendPacket(&data); + return false; + } + + // Prepare to flight start now + + // stop combat at start taxi flight if any + CombatStop(); + + // stop trade (client cancel trade at taxi map open but cheating tools can be used for reopen it) + TradeCancel(true); + + // clean not finished taxi path if any + m_taxi.ClearTaxiDestinations(); + + // 0 element current node + m_taxi.AddTaxiDestination(sourcenode); + + // fill destinations path tail + uint32 sourcepath = 0; + uint32 totalcost = 0; + + uint32 prevnode = sourcenode; + uint32 lastnode = 0; + + for(uint32 i = 1; i < nodes.size(); ++i) + { + uint32 path, cost; + + lastnode = nodes[i]; + objmgr.GetTaxiPath(prevnode, lastnode, path, cost); + + if(!path) + { + m_taxi.ClearTaxiDestinations(); + return false; + } + + totalcost += cost; + + if(prevnode == sourcenode) + sourcepath = path; + + m_taxi.AddTaxiDestination(lastnode); + + prevnode = lastnode; + } + + if(!mount_id) // if not provide then attempt use default. + mount_id = objmgr.GetTaxiMount(sourcenode, GetTeam()); + + if (mount_id == 0 || sourcepath == 0) + { + WorldPacket data(SMSG_ACTIVATETAXIREPLY, 4); + data << uint32(ERR_TAXIUNSPECIFIEDSERVERERROR); + GetSession()->SendPacket(&data); + m_taxi.ClearTaxiDestinations(); + return false; + } + + uint32 money = GetMoney(); + + if(npc) + { + totalcost = (uint32)ceil(totalcost*GetReputationPriceDiscount(npc)); + } + + if(money < totalcost) + { + WorldPacket data(SMSG_ACTIVATETAXIREPLY, 4); + data << uint32(ERR_TAXINOTENOUGHMONEY); + GetSession()->SendPacket(&data); + m_taxi.ClearTaxiDestinations(); + return false; + } + + //Checks and preparations done, DO FLIGHT + ModifyMoney(-(int32)totalcost); + + // prevent stealth flight + RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); + + WorldPacket data(SMSG_ACTIVATETAXIREPLY, 4); + data << uint32(ERR_TAXIOK); + GetSession()->SendPacket(&data); + + sLog.outDebug("WORLD: Sent SMSG_ACTIVATETAXIREPLY"); + + GetSession()->SendDoFlight(mount_id, sourcepath); + + return true; +} + +void Player::ProhibitSpellScholl(SpellSchoolMask idSchoolMask, uint32 unTimeMs ) +{ + // last check 2.0.10 + WorldPacket data(SMSG_SPELL_COOLDOWN, 8+1+m_spells.size()*8); + data << GetGUID(); + data << uint8(0x0); + time_t curTime = time(NULL); + for(PlayerSpellMap::const_iterator itr = m_spells.begin(); itr != m_spells.end(); ++itr) + { + if (itr->second->state == PLAYERSPELL_REMOVED) + continue; + uint32 unSpellId = itr->first; + SpellEntry const *spellInfo = sSpellStore.LookupEntry(unSpellId); + if (!spellInfo) + { + ASSERT(spellInfo); + continue; + } + + // Not send cooldown for this spells + if (spellInfo->Attributes & SPELL_ATTR_DISABLED_WHILE_ACTIVE) + continue; + + if((idSchoolMask & GetSpellSchoolMask(spellInfo)) && GetSpellCooldownDelay(unSpellId) < unTimeMs ) + { + data << unSpellId; + data << unTimeMs; // in m.secs + AddSpellCooldown(unSpellId, 0, curTime + unTimeMs/1000); + } + } + GetSession()->SendPacket(&data); +} + +void Player::InitDataForForm(bool reapplyMods) +{ + SpellShapeshiftEntry const* ssEntry = sSpellShapeshiftStore.LookupEntry(m_form); + if(ssEntry && ssEntry->attackSpeed) + { + SetAttackTime(BASE_ATTACK,ssEntry->attackSpeed); + SetAttackTime(OFF_ATTACK,ssEntry->attackSpeed); + SetAttackTime(RANGED_ATTACK, BASE_ATTACK_TIME); + } + else + SetRegularAttackTime(); + + switch(m_form) + { + case FORM_CAT: + { + if(getPowerType()!=POWER_ENERGY) + setPowerType(POWER_ENERGY); + break; + } + case FORM_BEAR: + case FORM_DIREBEAR: + { + if(getPowerType()!=POWER_RAGE) + setPowerType(POWER_RAGE); + break; + } + default: // 0, for example + { + ChrClassesEntry const* cEntry = sChrClassesStore.LookupEntry(getClass()); + if(cEntry && cEntry->powerType < MAX_POWERS && uint32(getPowerType()) != cEntry->powerType) + setPowerType(Powers(cEntry->powerType)); + break; + } + } + + // update auras at form change, ignore this at mods reapply (.reset stats/etc) when form not change. + if (!reapplyMods) + UpdateEquipSpellsAtFormChange(); + + UpdateAttackPowerAndDamage(); + UpdateAttackPowerAndDamage(true); +} + +// Return true is the bought item has a max count to force refresh of window by caller +bool Player::BuyItemFromVendor(uint64 vendorguid, uint32 item, uint8 count, uint64 bagguid, uint8 slot) +{ + // cheating attempt + if(count < 1) count = 1; + + if(!isAlive()) + return false; + + ItemPrototype const *pProto = objmgr.GetItemPrototype( item ); + if( !pProto ) + { + SendBuyError( BUY_ERR_CANT_FIND_ITEM, NULL, item, 0); + return false; + } + + Creature *pCreature = ObjectAccessor::GetNPCIfCanInteractWith(*this, vendorguid,UNIT_NPC_FLAG_VENDOR); + if (!pCreature) + { + sLog.outDebug( "WORLD: BuyItemFromVendor - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(vendorguid)) ); + SendBuyError( BUY_ERR_DISTANCE_TOO_FAR, NULL, item, 0); + return false; + } + + // load vendor items if not yet + pCreature->LoadGoods(); + + CreatureItem* crItem = pCreature->FindItem(item); + if(!crItem) + { + SendBuyError( BUY_ERR_CANT_FIND_ITEM, pCreature, item, 0); + return false; + } + + if( crItem->maxcount != 0 && crItem->count < count ) + { + SendBuyError( BUY_ERR_ITEM_ALREADY_SOLD, pCreature, item, 0); + return false; + } + + if( uint32(GetReputationRank(pProto->RequiredReputationFaction)) < pProto->RequiredReputationRank) + { + SendBuyError( BUY_ERR_REPUTATION_REQUIRE, pCreature, item, 0); + return false; + } + + if(crItem->ExtendedCost) + { + ItemExtendedCostEntry const* iece = sItemExtendedCostStore.LookupEntry(crItem->ExtendedCost); + if(!iece) + { + sLog.outError("Item %u have wrong ExtendedCost field value %u", pProto->ItemId, crItem->ExtendedCost); + return false; + } + + // honor points price + if(GetHonorPoints() < (iece->reqhonorpoints * count)) + { + SendEquipError(EQUIP_ERR_NOT_ENOUGH_HONOR_POINTS, NULL, NULL); + return false; + } + + // arena points price + if(GetArenaPoints() < (iece->reqarenapoints * count)) + { + SendEquipError(EQUIP_ERR_NOT_ENOUGH_ARENA_POINTS, NULL, NULL); + return false; + } + + // item base price + for (uint8 i = 0; i < 5; ++i) + { + if(iece->reqitem[i] && !HasItemCount(iece->reqitem[i], (iece->reqitemcount[i] * count))) + { + SendEquipError(EQUIP_ERR_VENDOR_MISSING_TURNINS, NULL, NULL); + return false; + } + } + + // check for personal arena rating requirement + if( GetMaxPersonalArenaRatingRequirement() < iece->reqpersonalarenarating ) + { + // probably not the proper equip err + SendEquipError(EQUIP_ERR_CANT_EQUIP_RANK,NULL,NULL); + return false; + } + } + + uint32 price = pProto->BuyPrice * count; + + // reputation discount + price = uint32(floor(price * GetReputationPriceDiscount(pCreature))); + + if( GetMoney() < price ) + { + SendBuyError( BUY_ERR_NOT_ENOUGHT_MONEY, pCreature, item, 0); + return false; + } + + uint8 bag = 0; // init for case invalid bagGUID + + if (bagguid != NULL_BAG && slot != NULL_SLOT) + { + Bag *pBag; + if( bagguid == GetGUID() ) + { + bag = INVENTORY_SLOT_BAG_0; + } + else + { + for (int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END;i++) + { + pBag = (Bag*)GetItemByPos(INVENTORY_SLOT_BAG_0,i); + if( pBag ) + { + if( bagguid == pBag->GetGUID() ) + { + bag = i; + break; + } + } + } + } + } + + if( IsInventoryPos( bag, slot ) || (bagguid == NULL_BAG && slot == NULL_SLOT) ) + { + ItemPosCountVec dest; + uint8 msg = CanStoreNewItem( bag, slot, dest, item, pProto->BuyCount * count ); + if( msg != EQUIP_ERR_OK ) + { + SendEquipError( msg, NULL, NULL ); + return false; + } + + ModifyMoney( -(int32)price ); + if(crItem->ExtendedCost) // case for new honor system + { + ItemExtendedCostEntry const* iece = sItemExtendedCostStore.LookupEntry(crItem->ExtendedCost); + if(iece->reqhonorpoints) + ModifyHonorPoints( - int32(iece->reqhonorpoints * count)); + if(iece->reqarenapoints) + ModifyArenaPoints( - int32(iece->reqarenapoints * count)); + for (uint8 i = 0; i < 5; ++i) + { + if(iece->reqitem[i]) + DestroyItemCount(iece->reqitem[i], (iece->reqitemcount[i] * count), true); + } + } + + if(Item *it = StoreNewItem( dest, item, true )) + { + if( crItem->maxcount != 0 ) + crItem->count -= pProto->BuyCount * count; + + WorldPacket data(SMSG_BUY_ITEM, (8+4+4+4)); + data << pCreature->GetGUID(); + data << (uint32)crItem->id; // entry + data << (uint32)crItem->count; + data << (uint32)count; + GetSession()->SendPacket(&data); + + SendNewItem(it, count, true, false, false); + } + } + else if( IsEquipmentPos( bag, slot ) ) + { + uint16 dest; + uint8 msg = CanEquipNewItem( slot, dest, item, pProto->BuyCount * count, false ); + if( msg != EQUIP_ERR_OK ) + { + SendEquipError( msg, NULL, NULL ); + return false; + } + + ModifyMoney( -(int32)price ); + if(crItem->ExtendedCost) // case for new honor system + { + ItemExtendedCostEntry const* iece = sItemExtendedCostStore.LookupEntry(crItem->ExtendedCost); + if(iece->reqhonorpoints) + ModifyHonorPoints( - int32(iece->reqhonorpoints)); + if(iece->reqarenapoints) + ModifyArenaPoints( - int32(iece->reqarenapoints)); + for (uint8 i = 0; i < 5; ++i) + { + if(iece->reqitem[i]) + DestroyItemCount(iece->reqitem[i], iece->reqitemcount[i], true); + } + } + + if(Item *it = EquipNewItem( dest, item, pProto->BuyCount * count, true )) + { + if( crItem->maxcount != 0 ) + crItem->count -= pProto->BuyCount * count; + + WorldPacket data(SMSG_BUY_ITEM, (8+4+4+4)); + data << pCreature->GetGUID(); + data << (uint32)crItem->id; // entry + data << (uint32)crItem->count; + data << (uint32)count; + GetSession()->SendPacket(&data); + + SendNewItem(it, count, true, false, false); + + AutoUnequipOffhandIfNeed(); + } + } + else + { + SendEquipError( EQUIP_ERR_ITEM_DOESNT_GO_TO_SLOT, NULL, NULL ); + return false; + } + + return crItem->maxcount!=0?true:false; +} + +uint32 Player::GetMaxPersonalArenaRatingRequirement() +{ + // returns the maximal personal arena rating that can be used to purchase items requiring this condition + // the personal rating of the arena team must match the required limit as well + // so return max[in arenateams](min(personalrating[teamtype], teamrating[teamtype])) + uint32 max_personal_rating = 0; + for(int i = 0; i < MAX_ARENA_SLOT; ++i) + { + if(ArenaTeam * at = objmgr.GetArenaTeamById(GetArenaTeamId(i))) + { + uint32 p_rating = GetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (i * 6) + 5); + uint32 t_rating = at->GetRating(); + p_rating = p_ratingSendPacket(&data); + } + // instance is valid, reset homebind timer + m_HomebindTimer = 0; + } + else if (m_HomebindTimer > 0) + { + if (time >= m_HomebindTimer) + { + // teleport to homebind location + TeleportTo(m_homebindMapId, m_homebindX, m_homebindY, m_homebindZ, GetOrientation()); + } + else + m_HomebindTimer -= time; + } + else + { + // instance is invalid, start homebind timer + m_HomebindTimer = 60000; + // send message to player + WorldPacket data(SMSG_RAID_GROUP_ONLY, 4+4); + data << m_HomebindTimer; + data << uint32(1); + GetSession()->SendPacket(&data); + sLog.outDebug("PLAYER: Player '%s' (GUID: %u) will be teleported to homebind in 60 seconds", GetName(),GetGUIDLow()); + } +} + +void Player::UpdatePvP(bool state, bool ovrride) +{ + if(!state || ovrride) + { + SetPvP(state); + if(Pet* pet = GetPet()) + pet->SetPvP(state); + if(Unit* charmed = GetCharm()) + charmed->SetPvP(state); + + pvpInfo.endTimer = 0; + } + else + { + if(pvpInfo.endTimer != 0) + pvpInfo.endTimer = time(NULL); + else + { + SetPvP(state); + + if(Pet* pet = GetPet()) + pet->SetPvP(state); + if(Unit* charmed = GetCharm()) + charmed->SetPvP(state); + } + } +} + +void Player::AddSpellCooldown(uint32 spellid, uint32 itemid, time_t end_time) +{ + SpellCooldown sc; + sc.end = end_time; + sc.itemid = itemid; + m_spellCooldowns[spellid] = sc; +} + +void Player::SendCooldownEvent(SpellEntry const *spellInfo) +{ + if ( !(spellInfo->Attributes & SPELL_ATTR_DISABLED_WHILE_ACTIVE) ) + return; + + // Get spell cooldwn + int32 cooldown = GetSpellRecoveryTime(spellInfo); + // Apply spellmods + ApplySpellMod(spellInfo->Id, SPELLMOD_COOLDOWN, cooldown); + if (cooldown < 0) + cooldown = 0; + // Add cooldown + AddSpellCooldown(spellInfo->Id, 0, time(NULL) + cooldown / 1000); + // Send activate + WorldPacket data(SMSG_COOLDOWN_EVENT, (4+8)); + data << spellInfo->Id; + data << GetGUID(); + SendDirectMessage(&data); +} + //slot to be excluded while counting +bool Player::EnchantmentFitsRequirements(uint32 enchantmentcondition, int8 slot) +{ + if(!enchantmentcondition) + return true; + + SpellItemEnchantmentConditionEntry const *Condition = sSpellItemEnchantmentConditionStore.LookupEntry(enchantmentcondition); + + if(!Condition) + return true; + + uint8 curcount[4] = {0, 0, 0, 0}; + + //counting current equipped gem colors + for(uint8 i = EQUIPMENT_SLOT_START; i < EQUIPMENT_SLOT_END; ++i) + { + if(i == slot) + continue; + Item *pItem2 = GetItemByPos( INVENTORY_SLOT_BAG_0, i ); + if(pItem2 && pItem2->GetProto()->Socket[0].Color) + { + for(uint32 enchant_slot = SOCK_ENCHANTMENT_SLOT; enchant_slot < SOCK_ENCHANTMENT_SLOT+3; ++enchant_slot) + { + uint32 enchant_id = pItem2->GetEnchantmentId(EnchantmentSlot(enchant_slot)); + if(!enchant_id) + continue; + + SpellItemEnchantmentEntry const* enchantEntry = sSpellItemEnchantmentStore.LookupEntry(enchant_id); + if(!enchantEntry) + continue; + + uint32 gemid = enchantEntry->GemID; + if(!gemid) + continue; + + ItemPrototype const* gemProto = sItemStorage.LookupEntry(gemid); + if(!gemProto) + continue; + + GemPropertiesEntry const* gemProperty = sGemPropertiesStore.LookupEntry(gemProto->GemProperties); + if(!gemProperty) + continue; + + uint8 GemColor = gemProperty->color; + + for(uint8 b = 0, tmpcolormask = 1; b < 4; b++, tmpcolormask <<= 1) + { + if(tmpcolormask & GemColor) + ++curcount[b]; + } + } + } + } + + bool activate = true; + + for(int i = 0; i < 5; i++) + { + if(!Condition->Color[i]) + continue; + + uint32 _cur_gem = curcount[Condition->Color[i] - 1]; + + // if have use them as count, else use from Condition + uint32 _cmp_gem = Condition->CompareColor[i] ? curcount[Condition->CompareColor[i] - 1]: Condition->Value[i]; + + switch(Condition->Comparator[i]) + { + case 2: // requires less than ( || ) gems + activate &= (_cur_gem < _cmp_gem) ? true : false; + break; + case 3: // requires more than ( || ) gems + activate &= (_cur_gem > _cmp_gem) ? true : false; + break; + case 5: // requires at least than ( || ) gems + activate &= (_cur_gem >= _cmp_gem) ? true : false; + break; + } + } + + sLog.outDebug("Checking Condition %u, there are %u Meta Gems, %u Red Gems, %u Yellow Gems and %u Blue Gems, Activate:%s", enchantmentcondition, curcount[0], curcount[1], curcount[2], curcount[3], activate ? "yes" : "no"); + + return activate; +} + +void Player::CorrectMetaGemEnchants(uint8 exceptslot, bool apply) +{ + //cycle all equipped items + for(uint32 slot = EQUIPMENT_SLOT_START; slot < EQUIPMENT_SLOT_END; ++slot) + { + //enchants for the slot being socketed are handled by Player::ApplyItemMods + if(slot == exceptslot) + continue; + + Item* pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, slot ); + + if(!pItem || !pItem->GetProto()->Socket[0].Color) + continue; + + for(uint32 enchant_slot = SOCK_ENCHANTMENT_SLOT; enchant_slot < SOCK_ENCHANTMENT_SLOT+3; ++enchant_slot) + { + uint32 enchant_id = pItem->GetEnchantmentId(EnchantmentSlot(enchant_slot)); + if(!enchant_id) + continue; + + SpellItemEnchantmentEntry const* enchantEntry = sSpellItemEnchantmentStore.LookupEntry(enchant_id); + if(!enchantEntry) + continue; + + uint32 condition = enchantEntry->EnchantmentCondition; + if(condition) + { + //was enchant active with/without item? + bool wasactive = EnchantmentFitsRequirements(condition, apply ? exceptslot : -1); + //should it now be? + if(wasactive ^ EnchantmentFitsRequirements(condition, apply ? -1 : exceptslot)) + { + // ignore item gem conditions + //if state changed, (dis)apply enchant + ApplyEnchantment(pItem,EnchantmentSlot(enchant_slot),!wasactive,true,true); + } + } + } + } +} + + //if false -> then toggled off if was on| if true -> toggled on if was off AND meets requirements +void Player::ToggleMetaGemsActive(uint8 exceptslot, bool apply) +{ + //cycle all equipped items + for(int slot = EQUIPMENT_SLOT_START; slot < EQUIPMENT_SLOT_END; ++slot) + { + //enchants for the slot being socketed are handled by WorldSession::HandleSocketOpcode(WorldPacket& recv_data) + if(slot == exceptslot) + continue; + + Item *pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, slot ); + + if(!pItem || !pItem->GetProto()->Socket[0].Color) //if item has no sockets or no item is equipped go to next item + continue; + + //cycle all (gem)enchants + for(uint32 enchant_slot = SOCK_ENCHANTMENT_SLOT; enchant_slot < SOCK_ENCHANTMENT_SLOT+3; ++enchant_slot) + { + uint32 enchant_id = pItem->GetEnchantmentId(EnchantmentSlot(enchant_slot)); + if(!enchant_id) //if no enchant go to next enchant(slot) + continue; + + SpellItemEnchantmentEntry const* enchantEntry = sSpellItemEnchantmentStore.LookupEntry(enchant_id); + if(!enchantEntry) + continue; + + //only metagems to be (de)activated, so only enchants with condition + uint32 condition = enchantEntry->EnchantmentCondition; + if(condition) + ApplyEnchantment(pItem,EnchantmentSlot(enchant_slot), apply); + } + } +} + +void Player::LeaveBattleground(bool teleportToEntryPoint) +{ + if(BattleGround *bg = GetBattleGround()) + { + bool need_debuf = bg->isBattleGround() && (bg->GetStatus() == STATUS_IN_PROGRESS) && sWorld.getConfig(CONFIG_BATTLEGROUND_CAST_DESERTER); + + bg->RemovePlayerAtLeave(GetGUID(), teleportToEntryPoint, true); + + // call after remove to be sure that player resurrected for correct cast + if(need_debuf) + CastSpell(this, 26013, true); // Deserter + } +} + +bool Player::CanJoinToBattleground() const +{ + // check Deserter debuff + if(GetDummyAura(26013)) + return false; + + return true; +} + +bool Player::CanReportAfkDueToLimit() +{ + // a player can complain about 15 people per 5 minutes + if(m_bgAfkReportedCount >= 15) + return false; + ++m_bgAfkReportedCount; + return true; +} + +///This player has been blamed to be inactive in a battleground +void Player::ReportedAfkBy(Player* reporter) +{ + BattleGround *bg = GetBattleGround(); + if(!bg || bg != reporter->GetBattleGround() || GetTeam() != reporter->GetTeam()) + return; + + // check if player has 'Idle' or 'Inactive' debuff + if(m_bgAfkReporter.find(reporter->GetGUIDLow())==m_bgAfkReporter.end() && !HasAura(43680,0) && !HasAura(43681,0) && reporter->CanReportAfkDueToLimit()) + { + m_bgAfkReporter.insert(reporter->GetGUIDLow()); + // 3 players have to complain to apply debuff + if(m_bgAfkReporter.size() >= 3) + { + // cast 'Idle' spell + CastSpell(this, 43680, true); + m_bgAfkReporter.clear(); + } + } +} + +bool Player::IsVisibleInGridForPlayer( Player* pl ) const +{ + // gamemaster in GM mode see all, including ghosts + if(pl->isGameMaster() && GetSession()->GetSecurity() <= pl->GetSession()->GetSecurity()) + return true; + + // It seems in battleground everyone sees everyone, except the enemy-faction ghosts + if (InBattleGround()) + { + if (!(isAlive() || m_deathTimer > 0) && !IsFriendlyTo(pl) ) + return false; + return true; + } + + // Live player see live player or dead player with not realized corpse + if(pl->isAlive() || pl->m_deathTimer > 0) + { + return isAlive() || m_deathTimer > 0; + } + + // Ghost see other friendly ghosts, that's for sure + if(!(isAlive() || m_deathTimer > 0) && IsFriendlyTo(pl)) + return true; + + // Dead player see live players near own corpse + if(isAlive()) + { + Corpse *corpse = pl->GetCorpse(); + if(corpse) + { + // 20 - aggro distance for same level, 25 - max additional distance if player level less that creature level + if(corpse->IsWithinDistInMap(this,(20+25)*sWorld.getRate(RATE_CREATURE_AGGRO))) + return true; + } + } + + // and not see any other + return false; +} + +bool Player::IsVisibleGloballyFor( Player* u ) const +{ + if(!u) + return false; + + // Always can see self + if (u==this) + return true; + + // Visible units, always are visible for all players + if (GetVisibility() == VISIBILITY_ON) + return true; + + // GMs are visible for higher gms (or players are visible for gms) + if (u->GetSession()->GetSecurity() > SEC_PLAYER) + return GetSession()->GetSecurity() <= u->GetSession()->GetSecurity(); + + // non faction visibility non-breakable for non-GMs + if (GetVisibility() == VISIBILITY_OFF) + return false; + + // non-gm stealth/invisibility not hide from global player lists + return true; +} + +void Player::UpdateVisibilityOf(WorldObject* target) +{ + if(HaveAtClient(target)) + { + if(!target->isVisibleForInState(this,true)) + { + target->DestroyForPlayer(this); + m_clientGUIDs.erase(target->GetGUID()); + + #ifdef MANGOS_DEBUG + if((sLog.getLogFilter() & LOG_FILTER_VISIBILITY_CHANGES)==0) + sLog.outDebug("Object %u (Type: %u) out of range for player %u. Distance = %f",target->GetGUIDLow(),target->GetTypeId(),GetGUIDLow(),GetDistance(target)); + #endif + } + } + else + { + if(target->isVisibleForInState(this,false)) + { + target->SendUpdateToPlayer(this); + if(target->GetTypeId()!=TYPEID_GAMEOBJECT||!((GameObject*)target)->IsTransport()) + m_clientGUIDs.insert(target->GetGUID()); + + #ifdef MANGOS_DEBUG + if((sLog.getLogFilter() & LOG_FILTER_VISIBILITY_CHANGES)==0) + sLog.outDebug("Object %u (Type: %u) is visible now for player %u. Distance = %f",target->GetGUIDLow(),target->GetTypeId(),GetGUIDLow(),GetDistance(target)); + #endif + + // target aura duration for caster show only if target exist at caster client + // send data at target visibility change (adding to client) + if(target!=this && target->isType(TYPEMASK_UNIT)) + SendAuraDurationsForTarget((Unit*)target); + + if(target->GetTypeId()==TYPEID_UNIT && ((Creature*)target)->isAlive()) + ((Creature*)target)->SendMonsterMoveWithSpeedToCurrentDestination(this); + } + } +} + +template +inline void UpdateVisibilityOf_helper(std::set& s64, T* target) +{ + s64.insert(target->GetGUID()); +} + +template<> +inline void UpdateVisibilityOf_helper(std::set& s64, GameObject* target) +{ + if(!target->IsTransport()) + s64.insert(target->GetGUID()); +} + +template +void Player::UpdateVisibilityOf(T* target, UpdateData& data, UpdateDataMapType& data_updates, std::set& visibleNow) +{ + if(HaveAtClient(target)) + { + if(!target->isVisibleForInState(this,true)) + { + target->BuildOutOfRangeUpdateBlock(&data); + m_clientGUIDs.erase(target->GetGUID()); + + #ifdef MANGOS_DEBUG + if((sLog.getLogFilter() & LOG_FILTER_VISIBILITY_CHANGES)==0) + sLog.outDebug("Object %u (Type: %u, Entry: %u) is out of range for player %u. Distance = %f",target->GetGUIDLow(),target->GetTypeId(),target->GetEntry(),GetGUIDLow(),GetDistance(target)); + #endif + } + } + else + { + if(target->isVisibleForInState(this,false)) + { + visibleNow.insert(target); + target->BuildUpdate(data_updates); + target->BuildCreateUpdateBlockForPlayer(&data, this); + UpdateVisibilityOf_helper(m_clientGUIDs,target); + + #ifdef MANGOS_DEBUG + if((sLog.getLogFilter() & LOG_FILTER_VISIBILITY_CHANGES)==0) + sLog.outDebug("Object %u (Type: %u, Entry: %u) is visible now for player %u. Distance = %f",target->GetGUIDLow(),target->GetTypeId(),target->GetEntry(),GetGUIDLow(),GetDistance(target)); + #endif + } + } +} + +template void Player::UpdateVisibilityOf(Player* target, UpdateData& data, UpdateDataMapType& data_updates, std::set& visibleNow); +template void Player::UpdateVisibilityOf(Creature* target, UpdateData& data, UpdateDataMapType& data_updates, std::set& visibleNow); +template void Player::UpdateVisibilityOf(Corpse* target, UpdateData& data, UpdateDataMapType& data_updates, std::set& visibleNow); +template void Player::UpdateVisibilityOf(GameObject* target, UpdateData& data, UpdateDataMapType& data_updates, std::set& visibleNow); +template void Player::UpdateVisibilityOf(DynamicObject* target, UpdateData& data, UpdateDataMapType& data_updates, std::set& visibleNow); + +void Player::InitPrimaryProffesions() +{ + SetFreePrimaryProffesions(sWorld.getConfig(CONFIG_MAX_PRIMARY_TRADE_SKILL)); +} + +void Player::SendComboPoints() +{ + Unit *combotarget = ObjectAccessor::GetUnit(*this, m_comboTarget); + if (combotarget) + { + WorldPacket data(SMSG_UPDATE_COMBO_POINTS, combotarget->GetPackGUID().size()+1); + data.append(combotarget->GetPackGUID()); + data << uint8(m_comboPoints); + GetSession()->SendPacket(&data); + } +} + +void Player::AddComboPoints(Unit* target, int8 count) +{ + if(!count) + return; + + // without combo points lost (duration checked in aura) + RemoveSpellsCausingAura(SPELL_AURA_RETAIN_COMBO_POINTS); + + if(target->GetGUID() == m_comboTarget) + { + m_comboPoints += count; + } + else + { + if(m_comboTarget) + if(Unit* target = ObjectAccessor::GetUnit(*this,m_comboTarget)) + target->RemoveComboPointHolder(GetGUIDLow()); + + m_comboTarget = target->GetGUID(); + m_comboPoints = count; + + target->AddComboPointHolder(GetGUIDLow()); + } + + if (m_comboPoints > 5) m_comboPoints = 5; + if (m_comboPoints < 0) m_comboPoints = 0; + + SendComboPoints(); +} + +void Player::ClearComboPoints() +{ + if(!m_comboTarget) + return; + + // without combopoints lost (duration checked in aura) + RemoveSpellsCausingAura(SPELL_AURA_RETAIN_COMBO_POINTS); + + m_comboPoints = 0; + + SendComboPoints(); + + if(Unit* target = ObjectAccessor::GetUnit(*this,m_comboTarget)) + target->RemoveComboPointHolder(GetGUIDLow()); + + m_comboTarget = 0; +} + +void Player::SetGroup(Group *group, int8 subgroup) +{ + if(group == NULL) m_group.unlink(); + else + { + // never use SetGroup without a subgroup unless you specify NULL for group + assert(subgroup >= 0); + m_group.link(group, this); + m_group.setSubGroup((uint8)subgroup); + } +} + +void Player::SendInitialPacketsBeforeAddToMap() +{ + WorldPacket data(SMSG_SET_REST_START, 4); + data << uint32(0); // unknown, may be rest state time or expirience + GetSession()->SendPacket(&data); + + // Homebind + data.Initialize(SMSG_BINDPOINTUPDATE, 5*4); + data << m_homebindX << m_homebindY << m_homebindZ; + data << (uint32) m_homebindMapId; + data << (uint32) m_homebindZoneId; + GetSession()->SendPacket(&data); + + // SMSG_SET_PROFICIENCY + // SMSG_UPDATE_AURA_DURATION + + // tutorial stuff + data.Initialize(SMSG_TUTORIAL_FLAGS, 8*4); + for (int i = 0; i < 8; ++i) + data << uint32( GetTutorialInt(i) ); + GetSession()->SendPacket(&data); + + SendInitialSpells(); + + data.Initialize(SMSG_SEND_UNLEARN_SPELLS, 4); + data << uint32(0); // count, for(count) uint32; + GetSession()->SendPacket(&data); + + SendInitialActionButtons(); + SendInitialReputations(); + UpdateZone(GetZoneId()); + SendInitWorldStates(); + + // SMSG_SET_AURA_SINGLE + + data.Initialize(SMSG_LOGIN_SETTIMESPEED, 8); + data << uint32(secsToTimeBitFields(sWorld.GetGameTime())); + data << (float)0.01666667f; // game speed + GetSession()->SendPacket( &data ); + + // set fly flag if in fly form or taxi flight to prevent visually drop at ground in showup moment + if(HasAuraType(SPELL_AURA_MOD_INCREASE_FLIGHT_SPEED) || isInFlight()) + SetUnitMovementFlags(GetUnitMovementFlags() | MOVEMENTFLAG_FLYING2); +} + +void Player::SendInitialPacketsAfterAddToMap() +{ + CastSpell(this, 836, true); // LOGINEFFECT + + // set some aura effects that send packet to player client after add player to map + // SendMessageToSet not send it to player not it map, only for aura that not changed anything at re-apply + // same auras state lost at far teleport, send it one more time in this case also + static const AuraType auratypes[] = + { + SPELL_AURA_MOD_FEAR, SPELL_AURA_TRANSFORM, SPELL_AURA_WATER_WALK, + SPELL_AURA_FEATHER_FALL, SPELL_AURA_HOVER, SPELL_AURA_SAFE_FALL, + SPELL_AURA_FLY, SPELL_AURA_MOD_INCREASE_FLIGHT_SPEED, SPELL_AURA_NONE + }; + for(AuraType const* itr = &auratypes[0]; itr && itr[0] != SPELL_AURA_NONE; ++itr) + { + Unit::AuraList const& auraList = GetAurasByType(*itr); + if(!auraList.empty()) + auraList.front()->ApplyModifier(true,true); + } + + if(HasAuraType(SPELL_AURA_MOD_STUN)) + SetMovement(MOVE_ROOT); + + // manual send package (have code in ApplyModifier(true,true); that don't must be re-applied. + if(HasAuraType(SPELL_AURA_MOD_ROOT)) + { + WorldPacket data(SMSG_FORCE_MOVE_ROOT, 10); + data.append(GetPackGUID()); + data << (uint32)2; + SendMessageToSet(&data,true); + } + + SendEnchantmentDurations(); // must be after add to map + SendItemDurations(); // must be after add to map +} + +void Player::SendUpdateToOutOfRangeGroupMembers() +{ + if (m_groupUpdateMask == GROUP_UPDATE_FLAG_NONE) + return; + if(Group* group = GetGroup()) + group->UpdatePlayerOutOfRange(this); + + m_groupUpdateMask = GROUP_UPDATE_FLAG_NONE; + m_auraUpdateMask = 0; + if(Pet *pet = GetPet()) + pet->ResetAuraUpdateMask(); +} + +void Player::SendTransferAborted(uint32 mapid, uint16 reason) +{ + WorldPacket data(SMSG_TRANSFER_ABORTED, 4+2); + data << uint32(mapid); + data << uint16(reason); // transfer abort reason + GetSession()->SendPacket(&data); +} + +void Player::SendInstanceResetWarning(uint32 mapid, uint32 time) +{ + // type of warning, based on the time remaining until reset + uint32 type; + if(time > 3600) + type = RAID_INSTANCE_WELCOME; + else if(time > 900 && time <= 3600) + type = RAID_INSTANCE_WARNING_HOURS; + else if(time > 300 && time <= 900) + type = RAID_INSTANCE_WARNING_MIN; + else + type = RAID_INSTANCE_WARNING_MIN_SOON; + WorldPacket data(SMSG_RAID_INSTANCE_MESSAGE, 4+4+4); + data << uint32(type); + data << uint32(mapid); + data << uint32(time); + GetSession()->SendPacket(&data); +} + +void Player::ApplyEquipCooldown( Item * pItem ) +{ + for(int i = 0; i <5; ++i) + { + _Spell const& spellData = pItem->GetProto()->Spells[i]; + + // no spell + if( !spellData.SpellId ) + continue; + + // wrong triggering type (note: ITEM_SPELLTRIGGER_ON_NO_DELAY_USE not have cooldown) + if( spellData.SpellTrigger != ITEM_SPELLTRIGGER_ON_USE ) + continue; + + AddSpellCooldown(spellData.SpellId, pItem->GetEntry(), time(NULL) + 30); + + WorldPacket data(SMSG_ITEM_COOLDOWN, 12); + data << pItem->GetGUID(); + data << uint32(spellData.SpellId); + GetSession()->SendPacket(&data); + } +} + +void Player::resetSpells() +{ + // not need after this call + if(HasAtLoginFlag(AT_LOGIN_RESET_SPELLS)) + { + m_atLoginFlags = m_atLoginFlags & ~AT_LOGIN_RESET_SPELLS; + CharacterDatabase.PExecute("UPDATE characters SET at_login = at_login & ~ %u WHERE guid ='%u'", uint32(AT_LOGIN_RESET_SPELLS), GetGUIDLow()); + } + + // make full copy of map (spells removed and marked as deleted at another spell remove + // and we can't use original map for safe iterative with visit each spell at loop end + PlayerSpellMap smap = GetSpellMap(); + + for(PlayerSpellMap::const_iterator iter = smap.begin();iter != smap.end(); ++iter) + removeSpell(iter->first); // only iter->first can be accessed, object by iter->second can be deleted already + + learnDefaultSpells(); + learnQuestRewardedSpells(); +} + +void Player::learnDefaultSpells(bool loading) +{ + // learn default race/class spells + PlayerInfo const *info = objmgr.GetPlayerInfo(getRace(),getClass()); + std::list::const_iterator spell_itr; + for (spell_itr = info->spell.begin(); spell_itr!=info->spell.end(); ++spell_itr) + { + uint16 tspell = spell_itr->first; + if (tspell) + { + sLog.outDebug("PLAYER: Adding initial spell, id = %u",tspell); + if(loading || !spell_itr->second) // not care about passive spells or loading case + addSpell(tspell,spell_itr->second); + else // but send in normal spell in game learn case + learnSpell(tspell); + } + } +} + +void Player::learnQuestRewardedSpells(Quest const* quest) +{ + uint32 spell_id = quest->GetRewSpellCast(); + + // skip quests without rewarded spell + if( !spell_id ) + return; + + SpellEntry const *spellInfo = sSpellStore.LookupEntry(spell_id); + if(!spellInfo) + return; + + // check learned spells state + bool found = false; + for(int i=0; i < 3; ++i) + { + if(spellInfo->Effect[i] == SPELL_EFFECT_LEARN_SPELL && !HasSpell(spellInfo->EffectTriggerSpell[i])) + { + found = true; + break; + } + } + + // skip quests with not teaching spell or already known spell + if(!found) + return; + + // prevent learn non first rank unknown profession and second specialization for same profession) + uint32 learned_0 = spellInfo->EffectTriggerSpell[0]; + if( spellmgr.GetSpellRank(learned_0) > 1 && !HasSpell(learned_0) ) + { + // not have first rank learned (unlearned prof?) + uint32 first_spell = spellmgr.GetFirstSpellInChain(learned_0); + if( !HasSpell(first_spell) ) + return; + + SpellEntry const *learnedInfo = sSpellStore.LookupEntry(learned_0); + if(!learnedInfo) + return; + + // specialization + if(learnedInfo->Effect[0]==SPELL_EFFECT_TRADE_SKILL && learnedInfo->Effect[1]==0) + { + // search other specialization for same prof + for(PlayerSpellMap::const_iterator itr = m_spells.begin(); itr != m_spells.end(); ++itr) + { + if(itr->second->state == PLAYERSPELL_REMOVED || itr->first==learned_0) + continue; + + SpellEntry const *itrInfo = sSpellStore.LookupEntry(itr->first); + if(!itrInfo) + return; + + // compare only specializations + if(itrInfo->Effect[0]!=SPELL_EFFECT_TRADE_SKILL || itrInfo->Effect[1]!=0) + continue; + + // compare same chain spells + if(spellmgr.GetFirstSpellInChain(itr->first) != first_spell) + continue; + + // now we have 2 specialization, learn possible only if found is lesser specialization rank + if(!spellmgr.IsHighRankOfSpell(learned_0,itr->first)) + return; + } + } + } + + CastSpell( this, spell_id, true); +} + +void Player::learnQuestRewardedSpells() +{ + // learn spells received from quest completing + for(QuestStatusMap::const_iterator itr = mQuestStatus.begin(); itr != mQuestStatus.end(); ++itr) + { + // skip no rewarded quests + if(!itr->second.m_rewarded) + continue; + + Quest const* quest = objmgr.GetQuestTemplate(itr->first); + if( !quest ) + continue; + + learnQuestRewardedSpells(quest); + } +} + +void Player::learnSkillRewardedSpells(uint32 skill_id ) +{ + uint32 raceMask = getRaceMask(); + uint32 classMask = getClassMask(); + for (uint32 j=0; jskillId!=skill_id || pAbility->learnOnGetSkill != ABILITY_LEARNED_ON_GET_PROFESSION_SKILL) + continue; + // Check race if set + if (pAbility->racemask && !(pAbility->racemask & raceMask)) + continue; + // Check class if set + if (pAbility->classmask && !(pAbility->classmask & classMask)) + continue; + + if (SpellEntry const* spellentry = sSpellStore.LookupEntry(pAbility->spellId)) + { + // Ok need learn spell + learnSpell(pAbility->spellId); + } + } +} + +void Player::learnSkillRewardedSpells() +{ + for (uint16 i=0; i < PLAYER_MAX_SKILLS; i++) + { + if(!GetUInt32Value(PLAYER_SKILL_INDEX(i))) + continue; + + uint32 pskill = GetUInt32Value(PLAYER_SKILL_INDEX(i)) & 0x0000FFFF; + + learnSkillRewardedSpells(pskill); + } +} + +void Player::SendAuraDurationsForTarget(Unit* target) +{ + for(Unit::AuraMap::const_iterator itr = target->GetAuras().begin(); itr != target->GetAuras().end(); ++itr) + { + Aura* aura = itr->second; + if(aura->GetAuraSlot() >= MAX_AURAS || aura->IsPassive() || aura->GetCasterGUID()!=GetGUID()) + continue; + + aura->SendAuraDurationForCaster(this); + } +} + +void Player::SetDailyQuestStatus( uint32 quest_id ) +{ + for(uint32 quest_daily_idx = 0; quest_daily_idx < PLAYER_MAX_DAILY_QUESTS; ++quest_daily_idx) + { + if(!GetUInt32Value(PLAYER_FIELD_DAILY_QUESTS_1+quest_daily_idx)) + { + SetUInt32Value(PLAYER_FIELD_DAILY_QUESTS_1+quest_daily_idx,quest_id); + m_lastDailyQuestTime = time(NULL); // last daily quest time + m_DailyQuestChanged = true; + break; + } + } +} + +void Player::ResetDailyQuestStatus() +{ + for(uint32 quest_daily_idx = 0; quest_daily_idx < PLAYER_MAX_DAILY_QUESTS; ++quest_daily_idx) + SetUInt32Value(PLAYER_FIELD_DAILY_QUESTS_1+quest_daily_idx,0); + + // DB data deleted in caller + m_DailyQuestChanged = false; + m_lastDailyQuestTime = 0; +} + +BattleGround* Player::GetBattleGround() const +{ + if(GetBattleGroundId()==0) + return NULL; + + return sBattleGroundMgr.GetBattleGround(GetBattleGroundId()); +} + +bool Player::InArena() const +{ + BattleGround *bg = GetBattleGround(); + if(!bg || !bg->isArena()) + return false; + + return true; +} + +bool Player::GetBGAccessByLevel(uint32 bgTypeId) const +{ + BattleGround *bg = sBattleGroundMgr.GetBattleGround(bgTypeId); + if(!bg) + return false; + + if(getLevel() < bg->GetMinLevel() || getLevel() > bg->GetMaxLevel()) + return false; + + return true; +} + +uint32 Player::GetMinLevelForBattleGroundQueueId(uint32 queue_id) +{ + if(queue_id < 1) + return 0; + + if(queue_id >=6) + queue_id = 6; + + return 10*(queue_id+1); +} + +uint32 Player::GetMaxLevelForBattleGroundQueueId(uint32 queue_id) +{ + if(queue_id >=6) + return 255; // hardcoded max level + + return 10*(queue_id+2)-1; +} + +uint32 Player::GetBattleGroundQueueIdFromLevel() const +{ + uint32 level = getLevel(); + if(level <= 19) + return 0; + else if (level > 69) + return 6; + else + return level/10 - 1; // 20..29 -> 1, 30-39 -> 2, ... +} + +float Player::GetReputationPriceDiscount( Creature const* pCreature ) const +{ + FactionTemplateEntry const* vendor_faction = pCreature->getFactionTemplateEntry(); + if(!vendor_faction) + return 1.0f; + + ReputationRank rank = GetReputationRank(vendor_faction->faction); + if(rank <= REP_NEUTRAL) + return 1.0f; + + return 1.0f - 0.05f* (rank - REP_NEUTRAL); +} + +bool Player::IsSpellFitByClassAndRace( uint32 spell_id ) const +{ + uint32 racemask = getRaceMask(); + uint32 classmask = getClassMask(); + + SkillLineAbilityMap::const_iterator lower = spellmgr.GetBeginSkillLineAbilityMap(spell_id); + SkillLineAbilityMap::const_iterator upper = spellmgr.GetEndSkillLineAbilityMap(spell_id); + + for(SkillLineAbilityMap::const_iterator _spell_idx = lower; _spell_idx != upper; ++_spell_idx) + { + // skip wrong race skills + if( _spell_idx->second->racemask && (_spell_idx->second->racemask & racemask) == 0) + return false; + + // skip wrong class skills + if( _spell_idx->second->classmask && (_spell_idx->second->classmask & classmask) == 0) + return false; + } + return true; +} + +bool Player::HasQuestForGO(int32 GOId) +{ + for( QuestStatusMap::iterator i = mQuestStatus.begin( ); i != mQuestStatus.end( ); ++i ) + { + QuestStatusData qs=i->second; + if (qs.m_status == QUEST_STATUS_INCOMPLETE) + { + Quest const* qinfo = objmgr.GetQuestTemplate(i->first); + if(!qinfo) + continue; + + if(GetGroup() && GetGroup()->isRaidGroup() && qinfo->GetType() != QUEST_TYPE_RAID) + continue; + + for (int j = 0; j < QUEST_OBJECTIVES_COUNT; j++) + { + if (qinfo->ReqCreatureOrGOId[j]>=0) //skip non GO case + continue; + + if((-1)*GOId == qinfo->ReqCreatureOrGOId[j] && qs.m_creatureOrGOcount[j] < qinfo->ReqCreatureOrGOCount[j]) + return true; + } + } + } + return false; +} + +void Player::UpdateForQuestsGO() +{ + if(m_clientGUIDs.empty()) + return; + + UpdateData udata; + WorldPacket packet; + for(ClientGUIDs::iterator itr=m_clientGUIDs.begin(); itr!=m_clientGUIDs.end(); ++itr) + { + if(IS_GAMEOBJECT_GUID(*itr)) + { + GameObject *obj = HashMapHolder::Find(*itr); + if(obj) + obj->BuildValuesUpdateBlockForPlayer(&udata,this); + } + } + udata.BuildPacket(&packet); + GetSession()->SendPacket(&packet); +} + +void Player::SummonIfPossible(bool agree) +{ + if(!agree) + { + m_summon_expire = 0; + return; + } + + // expire and auto declined + if(m_summon_expire < time(NULL)) + return; + + // stop taxi flight at summon + if(isInFlight()) + { + GetMotionMaster()->MovementExpired(); + m_taxi.ClearTaxiDestinations(); + } + + // drop flag at summon + if(BattleGround *bg = GetBattleGround()) + bg->EventPlayerDroppedFlag(this); + + m_summon_expire = 0; + + TeleportTo(m_summon_mapid, m_summon_x, m_summon_y, m_summon_z,GetOrientation()); +} + +void Player::RemoveItemDurations( Item *item ) +{ + for(ItemDurationList::iterator itr = m_itemDuration.begin();itr != m_itemDuration.end(); ++itr) + { + if(*itr==item) + { + m_itemDuration.erase(itr); + break; + } + } +} + +void Player::AddItemDurations( Item *item ) +{ + if(item->GetUInt32Value(ITEM_FIELD_DURATION)) + { + m_itemDuration.push_back(item); + item->SendTimeUpdate(this); + } +} + +void Player::AutoUnequipOffhandIfNeed() +{ + Item *offItem = GetItemByPos( INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND ); + if(!offItem) + return; + + Item *mainItem = GetItemByPos( INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_MAINHAND ); + + if(!mainItem || mainItem->GetProto()->InventoryType != INVTYPE_2HWEAPON) + return; + + ItemPosCountVec off_dest; + uint8 off_msg = CanStoreItem( NULL_BAG, NULL_SLOT, off_dest, offItem, false ); + if( off_msg == EQUIP_ERR_OK ) + { + RemoveItem(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND, true); + StoreItem( off_dest, offItem, true ); + } + else + { + sLog.outError("Player::EquipItem: Can's store offhand item at 2hand item equip for player (GUID: %u).",GetGUIDLow()); + } +} + +bool Player::HasItemFitToSpellReqirements(SpellEntry const* spellInfo, Item const* ignoreItem) +{ + if(spellInfo->EquippedItemClass < 0) + return true; + + // scan other equipped items for same requirements (mostly 2 daggers/etc) + // for optimize check 2 used cases only + switch(spellInfo->EquippedItemClass) + { + case ITEM_CLASS_WEAPON: + { + for(int i= EQUIPMENT_SLOT_MAINHAND; i < EQUIPMENT_SLOT_TABARD; ++i) + if(Item *item = GetItemByPos( INVENTORY_SLOT_BAG_0, i )) + if(item!=ignoreItem && item->IsFitToSpellRequirements(spellInfo)) + return true; + break; + } + case ITEM_CLASS_ARMOR: + { + // tabard not have dependent spells + for(int i= EQUIPMENT_SLOT_START; i< EQUIPMENT_SLOT_MAINHAND; ++i) + if(Item *item = GetItemByPos( INVENTORY_SLOT_BAG_0, i )) + if(item!=ignoreItem && item->IsFitToSpellRequirements(spellInfo)) + return true; + + // shields can be equipped to offhand slot + if(Item *item = GetItemByPos( INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND)) + if(item!=ignoreItem && item->IsFitToSpellRequirements(spellInfo)) + return true; + + // ranged slot can have some armor subclasses + if(Item *item = GetItemByPos( INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_RANGED)) + if(item!=ignoreItem && item->IsFitToSpellRequirements(spellInfo)) + return true; + + break; + } + default: + sLog.outError("HasItemFitToSpellReqirements: Not handeled spell reqirement for item class %u",spellInfo->EquippedItemClass); + break; + } + + return false; +} + +void Player::RemoveItemDependentAurasAndCasts( Item * pItem ) +{ + AuraMap& auras = GetAuras(); + for(AuraMap::iterator itr = auras.begin(); itr != auras.end(); ) + { + Aura* aura = itr->second; + + // skip passive (passive item dependent spells work in another way) and not self applied auras + SpellEntry const* spellInfo = aura->GetSpellProto(); + if(aura->IsPassive() || aura->GetCasterGUID()!=GetGUID()) + { + ++itr; + continue; + } + + // skip if not item dependent or have alternative item + if(HasItemFitToSpellReqirements(spellInfo,pItem)) + { + ++itr; + continue; + } + + // no alt item, remove aura, restart check + RemoveAurasDueToSpell(aura->GetId()); + itr = auras.begin(); + } + + // currently casted spells can be dependent from item + for (uint32 i = 0; i < CURRENT_MAX_SPELL; i++) + { + if( m_currentSpells[i] && m_currentSpells[i]->getState()!=SPELL_STATE_DELAYED && + !HasItemFitToSpellReqirements(m_currentSpells[i]->m_spellInfo,pItem) ) + InterruptSpell(i); + } +} + +uint32 Player::GetResurrectionSpellId() +{ + // search priceless resurrection possabilities + uint32 prio = 0; + uint32 spell_id = 0; + AuraList const& dummyAuras = GetAurasByType(SPELL_AURA_DUMMY); + for(AuraList::const_iterator itr = dummyAuras.begin(); itr != dummyAuras.end(); ++itr) + { + // Soulstone Resurrection // prio: 3 (max, non death persistent) + if( prio < 2 && (*itr)->GetSpellProto()->SpellVisual == 99 && (*itr)->GetSpellProto()->SpellIconID == 92 ) + { + switch((*itr)->GetId()) + { + case 20707: spell_id = 3026; break; // rank 1 + case 20762: spell_id = 20758; break; // rank 2 + case 20763: spell_id = 20759; break; // rank 3 + case 20764: spell_id = 20760; break; // rank 4 + case 20765: spell_id = 20761; break; // rank 5 + case 27239: spell_id = 27240; break; // rank 6 + default: + sLog.outError("Unhandled spell %%u: S.Resurrection",(*itr)->GetId()); + continue; + } + + prio = 3; + } + // Twisting Nether // prio: 2 (max) + else if((*itr)->GetId()==23701 && roll_chance_i(10)) + { + prio = 2; + spell_id = 23700; + } + } + + // Reincarnation (passive spell) // prio: 1 + if(prio < 1 && HasSpell(20608) && !HasSpellCooldown(21169) && HasItemCount(17030,1)) + spell_id = 21169; + + return spell_id; +} + +bool Player::RewardPlayerAndGroupAtKill(Unit* pVictim) +{ + bool PvP = pVictim->isCharmedOwnedByPlayerOrPlayer(); + + // prepare data for near group iteration (PvP and !PvP cases) + uint32 xp = 0; + bool honored_kill = false; + + if(Group *pGroup = GetGroup()) + { + uint32 count = 0; + uint32 sum_level = 0; + Player* member_with_max_level = NULL; + + pGroup->GetDataForXPAtKill(pVictim,count,sum_level,member_with_max_level); + + if(member_with_max_level) + { + xp = PvP ? 0 : MaNGOS::XP::Gain(member_with_max_level, pVictim); + + // skip in check PvP case (for speed, not used) + bool is_raid = PvP ? false : sMapStore.LookupEntry(GetMapId())->IsRaid() && pGroup->isRaidGroup(); + bool is_dungeon = PvP ? false : sMapStore.LookupEntry(GetMapId())->IsDungeon(); + float group_rate = MaNGOS::XP::xp_in_group_rate(count,is_raid); + + for(GroupReference *itr = pGroup->GetFirstMember(); itr != NULL; itr = itr->next()) + { + Player* pGroupGuy = itr->getSource(); + if(!pGroupGuy) + continue; + + if(!pGroupGuy->IsAtGroupRewardDistance(pVictim)) + continue; // member (alive or dead) or his corpse at req. distance + + // honor can be in PvP and !PvP (racial leader) cases (for alive) + if(pGroupGuy->isAlive() && pGroupGuy->RewardHonor(pVictim,count) && pGroupGuy==this) + honored_kill = true; + + // xp and reputation only in !PvP case + if(!PvP) + { + float rate = group_rate * float(pGroupGuy->getLevel()) / sum_level; + + // if is in dungeon then all receive full reputation at kill + // rewarded any alive/dead/near_corpse group member + pGroupGuy->RewardReputation(pVictim,is_dungeon ? 1.0f : rate); + + // XP updated only for alive group member + if(pGroupGuy->isAlive()) + { + uint32 itr_xp = uint32(xp*rate); + + pGroupGuy->GiveXP(itr_xp, pVictim); + if(Pet* pet = pGroupGuy->GetPet()) + pet->GivePetXP(itr_xp/2); + } + + // quest objectives updated only for alive group member or dead but with not released body + if(pGroupGuy->isAlive()|| !pGroupGuy->GetCorpse()) + { + // normal creature (not pet/etc) can be only in !PvP case + if(pVictim->GetTypeId()==TYPEID_UNIT) + pGroupGuy->KilledMonster(pVictim->GetEntry(), pVictim->GetGUID()); + } + } + } + } + } + else // if (!pGroup) + { + xp = PvP ? 0 : MaNGOS::XP::Gain(this, pVictim); + + // honor can be in PvP and !PvP (racial leader) cases + if(RewardHonor(pVictim,1)) + honored_kill = true; + + // xp and reputation only in !PvP case + if(!PvP) + { + RewardReputation(pVictim,1); + GiveXP(xp, pVictim); + + if(Pet* pet = GetPet()) + pet->GivePetXP(xp); + + // normal creature (not pet/etc) can be only in !PvP case + if(pVictim->GetTypeId()==TYPEID_UNIT) + KilledMonster(pVictim->GetEntry(),pVictim->GetGUID()); + } + } + return xp || honored_kill; +} + +bool Player::IsAtGroupRewardDistance(WorldObject const* pRewardSource) const +{ + if(pRewardSource->GetDistance(this) <= sWorld.getConfig(CONFIG_GROUP_XP_DISTANCE)) + return true; + + if(isAlive()) + return false; + + Corpse* corpse = GetCorpse(); + if(!corpse) + return false; + + return pRewardSource->GetDistance(corpse) <= sWorld.getConfig(CONFIG_GROUP_XP_DISTANCE); +} + +uint32 Player::GetBaseWeaponSkillValue (WeaponAttackType attType) const +{ + Item* item = GetWeaponForAttack(attType,true); + + // unarmmed only with base attack + if(attType != BASE_ATTACK && !item) + return 0; + + // weapon skill or (unarmed for base attack) + uint32 skill = item ? item->GetSkill() : SKILL_UNARMED; + return GetBaseSkillValue(skill); +} + +void Player::ResurectUsingRequestData() +{ + ResurrectPlayer(0.0f,false); + + if(GetMaxHealth() > m_resurrectHealth) + SetHealth( m_resurrectHealth ); + else + SetHealth( GetMaxHealth() ); + + if(GetMaxPower(POWER_MANA) > m_resurrectMana) + SetPower(POWER_MANA, m_resurrectMana ); + else + SetPower(POWER_MANA, GetMaxPower(POWER_MANA) ); + + SetPower(POWER_RAGE, 0 ); + + SetPower(POWER_ENERGY, GetMaxPower(POWER_ENERGY) ); + + SpawnCorpseBones(); + + TeleportTo(m_resurrectMap, m_resurrectX, m_resurrectY, m_resurrectZ, GetOrientation()); +} + +void Player::SetClientControl(Unit* target, uint8 allowMove) +{ + WorldPacket data(SMSG_CLIENT_CONTROL_UPDATE, target->GetPackGUID().size()+1); + data.append(target->GetPackGUID()); + data << uint8(allowMove); + GetSession()->SendPacket(&data); +} + +void Player::UpdateZoneDependentAuras( uint32 newZone ) +{ + // remove new continent flight forms + if( !isGameMaster() && + GetVirtualMapForMapAndZone(GetMapId(),newZone) != 530) + { + RemoveSpellsCausingAura(SPELL_AURA_MOD_INCREASE_FLIGHT_SPEED); + RemoveSpellsCausingAura(SPELL_AURA_FLY); + } + + // Some spells applied at enter into zone (with subzones) + // Human Illusion + // NOTE: these are removed by RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_CHANGE_MAP); + if ( newZone == 2367 ) // Old Hillsbrad Foothills + { + uint32 spellid = 0; + // all horde races + if( GetTeam() == HORDE ) + spellid = getGender() == GENDER_FEMALE ? 35481 : 35480; + // and some alliance races + else if( getRace() == RACE_NIGHTELF || getRace() == RACE_DRAENEI ) + spellid = getGender() == GENDER_FEMALE ? 35483 : 35482; + + if(spellid && !HasAura(spellid,0) ) + CastSpell(this,spellid,true); + } +} + +void Player::UpdateAreaDependentAuras( uint32 newArea ) +{ + // remove auras from spells with area limitations + for(AuraMap::iterator iter = m_Auras.begin(); iter != m_Auras.end();) + { + // use m_zoneUpdateId for speed: UpdateArea called from UpdateZone or instead UpdateZone in both cases m_zoneUpdateId up-to-date + if(!IsSpellAllowedInLocation(iter->second->GetSpellProto(),GetMapId(),m_zoneUpdateId,newArea)) + RemoveAura(iter); + else + ++iter; + } + + // unmount if enter in this subzone + if( newArea == 35) + RemoveSpellsCausingAura(SPELL_AURA_MOUNTED); + // Dragonmaw Illusion + else if( newArea == 3759 || newArea == 3966 || newArea == 3939 ) + { + if( GetDummyAura(40214) ) + { + if( !HasAura(40216,0) ) + CastSpell(this,40216,true); + if( !HasAura(42016,0) ) + CastSpell(this,42016,true); + } + } +} + +uint32 Player::GetCorpseReclaimDelay(bool pvp) const +{ + if( pvp && !sWorld.getConfig(CONFIG_DEATH_CORPSE_RECLAIM_DELAY_PVP) || + !pvp && !sWorld.getConfig(CONFIG_DEATH_CORPSE_RECLAIM_DELAY_PVE) ) + { + return copseReclaimDelay[0]; + } + + time_t now = time(NULL); + // 0..2 full period + uint32 count = (now < m_deathExpireTime) ? (m_deathExpireTime - now)/DEATH_EXPIRE_STEP : 0; + return copseReclaimDelay[count]; +} + +void Player::UpdateCorpseReclaimDelay() +{ + bool pvp = m_ExtraFlags & PLAYER_EXTRA_PVP_DEATH; + + if( pvp && !sWorld.getConfig(CONFIG_DEATH_CORPSE_RECLAIM_DELAY_PVP) || + !pvp && !sWorld.getConfig(CONFIG_DEATH_CORPSE_RECLAIM_DELAY_PVE) ) + return; + + time_t now = time(NULL); + if(now < m_deathExpireTime) + { + // full and partly periods 1..3 + uint32 count = (m_deathExpireTime - now)/DEATH_EXPIRE_STEP +1; + if(count < MAX_DEATH_COUNT) + m_deathExpireTime = now+(count+1)*DEATH_EXPIRE_STEP; + else + m_deathExpireTime = now+MAX_DEATH_COUNT*DEATH_EXPIRE_STEP; + } + else + m_deathExpireTime = now+DEATH_EXPIRE_STEP; +} + +void Player::SendCorpseReclaimDelay(bool load) +{ + Corpse* corpse = GetCorpse(); + if(!corpse) + return; + + uint32 delay; + if(load) + { + if(corpse->GetGhostTime() > m_deathExpireTime) + return; + + bool pvp = corpse->GetType()==CORPSE_RESURRECTABLE_PVP; + + uint32 count; + if( pvp && sWorld.getConfig(CONFIG_DEATH_CORPSE_RECLAIM_DELAY_PVP) || + !pvp && sWorld.getConfig(CONFIG_DEATH_CORPSE_RECLAIM_DELAY_PVE) ) + { + count = (m_deathExpireTime-corpse->GetGhostTime())/DEATH_EXPIRE_STEP; + if(count>=MAX_DEATH_COUNT) + count = MAX_DEATH_COUNT-1; + } + else + count=0; + + time_t expected_time = corpse->GetGhostTime()+copseReclaimDelay[count]; + + time_t now = time(NULL); + if(now >= expected_time) + return; + + delay = expected_time-now; + } + else + delay = GetCorpseReclaimDelay(corpse->GetType()==CORPSE_RESURRECTABLE_PVP); + + //! corpse reclaim delay 30 * 1000ms or longer at often deaths + WorldPacket data(SMSG_CORPSE_RECLAIM_DELAY, 4); + data << uint32(delay*1000); + GetSession()->SendPacket( &data ); +} + +Player* Player::GetNextRandomRaidMember(float radius) +{ + Group *pGroup = GetGroup(); + if(!pGroup) + return NULL; + + std::vector nearMembers; + nearMembers.reserve(pGroup->GetMembersCount()); + + for(GroupReference *itr = pGroup->GetFirstMember(); itr != NULL; itr = itr->next()) + { + Player* Target = itr->getSource(); + + // IsHostileTo check duel and controlled by enemy + if( Target && Target != this && IsWithinDistInMap(Target, radius) && + !Target->HasInvisibilityAura() && !IsHostileTo(Target) ) + nearMembers.push_back(Target); + } + + if (nearMembers.empty()) + return NULL; + + uint32 randTarget = urand(0,nearMembers.size()-1); + return nearMembers[randTarget]; +} + +void Player::UpdateUnderwaterState( Map* m, float x, float y, float z ) +{ + float water_z = m->GetWaterLevel(x,y); + float height_z = m->GetHeight(x,y,z, false); // use .map base surface height + uint8 flag1 = m->GetTerrainType(x,y); + + //!Underwater check, not in water if underground or above water level + if (height_z <= INVALID_HEIGHT || z < (height_z-2) || z > (water_z - 2) ) + m_isunderwater &= 0x7A; + else if ((z < (water_z - 2)) && (flag1 & 0x01)) + m_isunderwater |= 0x01; + + //!in lava check, anywhere under lava level + if ((height_z <= INVALID_HEIGHT || z < (height_z - 0)) && (flag1 == 0x00) && IsInWater()) + m_isunderwater |= 0x80; +} + +void Player::SetCanParry( bool value ) +{ + if(m_canParry==value) + return; + + m_canParry = value; + UpdateParryPercentage(); +} + +void Player::SetCanBlock( bool value ) +{ + if(m_canBlock==value) + return; + + m_canBlock = value; + UpdateBlockPercentage(); +} + +bool ItemPosCount::isContainedIn(ItemPosCountVec const& vec) const +{ + for(ItemPosCountVec::const_iterator itr = vec.begin(); itr != vec.end();++itr) + if(itr->pos == this->pos) + return true; + + return false; +} diff --git a/src/game/Player.h b/src/game/Player.h index d30d8e56622..199d816863a 100644 --- a/src/game/Player.h +++ b/src/game/Player.h @@ -1,2310 +1,2313 @@ -/* - * Copyright (C) 2005-2008 MaNGOS - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef _PLAYER_H -#define _PLAYER_H - -#include "Common.h" -#include "ItemPrototype.h" -#include "Unit.h" -#include "Item.h" - -#include "Database/DatabaseEnv.h" -#include "NPCHandler.h" -#include "QuestDef.h" -#include "Group.h" -#include "Bag.h" -#include "WorldSession.h" -#include "Pet.h" -#include "Util.h" // for Tokens typedef - -#include -#include - -struct Mail; -class Channel; -class DynamicObject; -class Creature; -class Pet; -class PlayerMenu; -class Transport; -class UpdateMask; -class PlayerSocial; - -typedef std::deque PlayerMails; - -#define PLAYER_MAX_SKILLS 127 -#define PLAYER_MAX_DAILY_QUESTS 25 - -// Note: SPELLMOD_* values is aura types in fact -enum SpellModType -{ - SPELLMOD_FLAT = 107, // SPELL_AURA_ADD_FLAT_MODIFIER - SPELLMOD_PCT = 108 // SPELL_AURA_ADD_PCT_MODIFIER -}; - -enum PlayerSpellState -{ - PLAYERSPELL_UNCHANGED = 0, - PLAYERSPELL_CHANGED = 1, - PLAYERSPELL_NEW = 2, - PLAYERSPELL_REMOVED = 3 -}; - -struct PlayerSpell -{ - uint16 slotId : 16; - PlayerSpellState state : 8; - bool active : 1; - bool disabled : 1; -}; - -#define SPELL_WITHOUT_SLOT_ID uint16(-1) - -struct SpellModifier -{ - SpellModOp op : 8; - SpellModType type : 8; - int16 charges : 16; - int32 value; - uint64 mask; - uint32 spellId; - uint32 effectId; - Spell const* lastAffected; -}; - -typedef HM_NAMESPACE::hash_map PlayerSpellMap; -typedef std::list SpellModList; - -struct SpellCooldown -{ - time_t end; - uint16 itemid; -}; - -typedef std::map SpellCooldowns; - -enum TrainerSpellState -{ - TRAINER_SPELL_GREEN = 0, - TRAINER_SPELL_RED = 1, - TRAINER_SPELL_GRAY = 2 -}; - -enum ActionButtonUpdateState -{ - ACTIONBUTTON_UNCHANGED = 0, - ACTIONBUTTON_CHANGED = 1, - ACTIONBUTTON_NEW = 2, - ACTIONBUTTON_DELETED = 3 -}; - -struct ActionButton -{ - ActionButton() : action(0), type(0), misc(0), uState( ACTIONBUTTON_NEW ) {} - ActionButton(uint16 _action, uint8 _type, uint8 _misc) : action(_action), type(_type), misc(_misc), uState( ACTIONBUTTON_NEW ) {} - - uint16 action; - uint8 type; - uint8 misc; - ActionButtonUpdateState uState; -}; - -enum ActionButtonType -{ - ACTION_BUTTON_SPELL = 0, - ACTION_BUTTON_MACRO = 64, - ACTION_BUTTON_CMACRO= 65, - ACTION_BUTTON_ITEM = 128 -}; - -#define MAX_ACTION_BUTTONS 132 //checked in 2.3.0 - -typedef std::map ActionButtonList; - -typedef std::pair CreateSpellPair; - -struct PlayerCreateInfoItem -{ - PlayerCreateInfoItem(uint32 id, uint32 amount) : item_id(id), item_amount(amount) {} - - uint32 item_id; - uint32 item_amount; -}; - -typedef std::list PlayerCreateInfoItems; - -struct PlayerClassLevelInfo -{ - PlayerClassLevelInfo() : basehealth(0), basemana(0) {} - uint16 basehealth; - uint16 basemana; -}; - -struct PlayerClassInfo -{ - PlayerClassInfo() : levelInfo(NULL) { } - - PlayerClassLevelInfo* levelInfo; //[level-1] 0..MaxPlayerLevel-1 -}; - -struct PlayerLevelInfo -{ - PlayerLevelInfo() { for(int i=0; i < MAX_STATS; ++i ) stats[i] = 0; } - - uint8 stats[MAX_STATS]; -}; - -struct PlayerInfo -{ - // existence checked by displayId != 0 // existence checked by displayId != 0 - PlayerInfo() : displayId_m(0),displayId_f(0),levelInfo(NULL) - { - } - - uint32 mapId; - uint32 zoneId; - float positionX; - float positionY; - float positionZ; - uint16 displayId_m; - uint16 displayId_f; - PlayerCreateInfoItems item; - std::list spell; - std::list action[4]; - - PlayerLevelInfo* levelInfo; //[level-1] 0..MaxPlayerLevel-1 -}; - -struct PvPInfo -{ - PvPInfo() : inHostileArea(false), endTimer(0) {} - - bool inHostileArea; - time_t endTimer; -}; - -struct DuelInfo -{ - DuelInfo() : initiator(NULL), opponent(NULL), startTimer(0), startTime(0), outOfBound(0) {} - - Player *initiator; - Player *opponent; - time_t startTimer; - time_t startTime; - time_t outOfBound; -}; - -struct Areas -{ - uint32 areaID; - uint32 areaFlag; - float x1; - float x2; - float y1; - float y2; -}; - -enum FactionFlags -{ - FACTION_FLAG_VISIBLE = 0x01, // makes visible in client (set or can be set at interaction with target of this faction) - FACTION_FLAG_AT_WAR = 0x02, // enable AtWar-button in client. player controlled (except opposition team always war state), Flag only set on initial creation - FACTION_FLAG_HIDDEN = 0x04, // hidden faction from reputation pane in client (player can gain reputation, but this update not sent to client) - FACTION_FLAG_INVISIBLE_FORCED = 0x08, // always overwrite FACTION_FLAG_VISIBLE and hide faction in rep.list, used for hide opposite team factions - FACTION_FLAG_PEACE_FORCED = 0x10, // always overwrite FACTION_FLAG_AT_WAR, used for prevent war with own team factions - FACTION_FLAG_INACTIVE = 0x20, // player controlled, state stored in characters.data ( CMSG_SET_FACTION_INACTIVE ) - FACTION_FLAG_RIVAL = 0x40 // flag for the two competing outland factions -}; - -typedef uint32 RepListID; -struct FactionState -{ - uint32 ID; - RepListID ReputationListID; - uint32 Flags; - int32 Standing; - bool Changed; -}; - -typedef std::map FactionStateList; - -typedef std::map ForcedReactions; - -typedef std::set GuardianPetList; - -struct EnchantDuration -{ - EnchantDuration() : item(NULL), slot(MAX_ENCHANTMENT_SLOT), leftduration(0) {}; - EnchantDuration(Item * _item, EnchantmentSlot _slot, uint32 _leftduration) : item(_item), slot(_slot), leftduration(_leftduration) { assert(item); }; - - Item * item; - EnchantmentSlot slot; - uint32 leftduration; -}; - -typedef std::list EnchantDurationList; -typedef std::list ItemDurationList; - -struct LookingForGroupSlot -{ - LookingForGroupSlot() : entry(0), type(0) {} - bool Empty() const { return !entry && !type; } - void Clear() { entry = 0; type = 0; } - void Set(uint32 _entry, uint32 _type ) { entry = _entry; type = _type; } - bool Is(uint32 _entry, uint32 _type) const { return entry==_entry && type==_type; } - bool canAutoJoin() const { return entry && (type == 1 || type == 5); } - - uint32 entry; - uint32 type; -}; - -#define MAX_LOOKING_FOR_GROUP_SLOT 3 - -struct LookingForGroup -{ - LookingForGroup() {} - bool HaveInSlot(LookingForGroupSlot const& slot) const { return HaveInSlot(slot.entry,slot.type); } - bool HaveInSlot(uint32 _entry, uint32 _type) const - { - for(int i = 0; i < MAX_LOOKING_FOR_GROUP_SLOT; ++i) - if(slots[i].Is(_entry,_type)) - return true; - return false; - } - - bool canAutoJoin() const - { - for(int i = 0; i < MAX_LOOKING_FOR_GROUP_SLOT; ++i) - if(slots[i].canAutoJoin()) - return true; - return false; - } - - bool Empty() const - { - for(int i = 0; i < MAX_LOOKING_FOR_GROUP_SLOT; ++i) - if(!slots[i].Empty()) - return false; - return more.Empty(); - } - - LookingForGroupSlot slots[MAX_LOOKING_FOR_GROUP_SLOT]; - LookingForGroupSlot more; - std::string comment; -}; - -enum PlayerMovementType -{ - MOVE_ROOT = 1, - MOVE_UNROOT = 2, - MOVE_WATER_WALK = 3, - MOVE_LAND_WALK = 4 -}; - -enum DrunkenState -{ - DRUNKEN_SOBER = 0, - DRUNKEN_TIPSY = 1, - DRUNKEN_DRUNK = 2, - DRUNKEN_SMASHED = 3 -}; - -enum PlayerStateType -{ - /* - PLAYER_STATE_DANCE - PLAYER_STATE_SLEEP - PLAYER_STATE_SIT - PLAYER_STATE_STAND - PLAYER_STATE_READYUNARMED - PLAYER_STATE_WORK - PLAYER_STATE_POINT(DNR) - PLAYER_STATE_NONE // not used or just no state, just standing there? - PLAYER_STATE_STUN - PLAYER_STATE_DEAD - PLAYER_STATE_KNEEL - PLAYER_STATE_USESTANDING - PLAYER_STATE_STUN_NOSHEATHE - PLAYER_STATE_USESTANDING_NOSHEATHE - PLAYER_STATE_WORK_NOSHEATHE - PLAYER_STATE_SPELLPRECAST - PLAYER_STATE_READYRIFLE - PLAYER_STATE_WORK_NOSHEATHE_MINING - PLAYER_STATE_WORK_NOSHEATHE_CHOPWOOD - PLAYER_STATE_AT_EASE - PLAYER_STATE_READY1H - PLAYER_STATE_SPELLKNEELSTART - PLAYER_STATE_SUBMERGED - */ - - PLAYER_STATE_NONE = 0, - PLAYER_STATE_SIT = 1, - PLAYER_STATE_SIT_CHAIR = 2, - PLAYER_STATE_SLEEP = 3, - PLAYER_STATE_SIT_LOW_CHAIR = 4, - PLAYER_STATE_SIT_MEDIUM_CHAIR = 5, - PLAYER_STATE_SIT_HIGH_CHAIR = 6, - PLAYER_STATE_DEAD = 7, - PLAYER_STATE_KNEEL = 8, - - PLAYER_STATE_FORM_ALL = 0x00FF0000, - - PLAYER_STATE_FLAG_ALWAYS_STAND = 0x01, // byte 4 - PLAYER_STATE_FLAG_CREEP = 0x02000000, - PLAYER_STATE_FLAG_UNTRACKABLE = 0x04000000, - PLAYER_STATE_FLAG_ALL = 0xFF000000, -}; - -enum PlayerFlags -{ - PLAYER_FLAGS_GROUP_LEADER = 0x00000001, - PLAYER_FLAGS_AFK = 0x00000002, - PLAYER_FLAGS_DND = 0x00000004, - PLAYER_FLAGS_GM = 0x00000008, - PLAYER_FLAGS_GHOST = 0x00000010, - PLAYER_FLAGS_RESTING = 0x00000020, - PLAYER_FLAGS_FFA_PVP = 0x00000080, - PLAYER_FLAGS_CONTESTED_PVP = 0x00000100, // Player has been involved in a PvP combat and will be attacked by contested guards - PLAYER_FLAGS_IN_PVP = 0x00000200, - PLAYER_FLAGS_HIDE_HELM = 0x00000400, - PLAYER_FLAGS_HIDE_CLOAK = 0x00000800, - PLAYER_FLAGS_UNK1 = 0x00001000, // played long time - PLAYER_FLAGS_UNK2 = 0x00002000, // played too long time - PLAYER_FLAGS_UNK3 = 0x00008000, // strange visual effect (2.0.1), looks like PLAYER_FLAGS_GHOST flag - PLAYER_FLAGS_SANCTUARY = 0x00010000, // player entered sanctuary - PLAYER_FLAGS_UNK4 = 0x00020000, // taxi benchmark mode (on/off) (2.0.1) - PLAYER_UNK = 0x00040000, // 2.0.8... -}; - -// used for PLAYER__FIELD_KNOWN_TITLES field (uint64), (1< QuestStatusMap; - -enum QuestSlotOffsets -{ - QUEST_ID_OFFSET = 0, - QUEST_STATE_OFFSET = 1, - QUEST_COUNTS_OFFSET = 2, - QUEST_TIME_OFFSET = 3 -}; - -#define MAX_QUEST_OFFSET 4 - -enum QuestSlotStateMask -{ - QUEST_STATE_NONE = 0x0000, - QUEST_STATE_COMPLETE = 0x0001, - QUEST_STATE_FAIL = 0x0002 -}; - -class Quest; -class Spell; -class Item; -class WorldSession; - -enum PlayerSlots -{ - // first slot for item stored (in any way in player m_items data) - PLAYER_SLOT_START = 0, - // last+1 slot for item stored (in any way in player m_items data) - PLAYER_SLOT_END = 118, - PLAYER_SLOTS_COUNT = (PLAYER_SLOT_END - PLAYER_SLOT_START) -}; - -enum EquipmentSlots -{ - EQUIPMENT_SLOT_START = 0, - EQUIPMENT_SLOT_HEAD = 0, - EQUIPMENT_SLOT_NECK = 1, - EQUIPMENT_SLOT_SHOULDERS = 2, - EQUIPMENT_SLOT_BODY = 3, - EQUIPMENT_SLOT_CHEST = 4, - EQUIPMENT_SLOT_WAIST = 5, - EQUIPMENT_SLOT_LEGS = 6, - EQUIPMENT_SLOT_FEET = 7, - EQUIPMENT_SLOT_WRISTS = 8, - EQUIPMENT_SLOT_HANDS = 9, - EQUIPMENT_SLOT_FINGER1 = 10, - EQUIPMENT_SLOT_FINGER2 = 11, - EQUIPMENT_SLOT_TRINKET1 = 12, - EQUIPMENT_SLOT_TRINKET2 = 13, - EQUIPMENT_SLOT_BACK = 14, - EQUIPMENT_SLOT_MAINHAND = 15, - EQUIPMENT_SLOT_OFFHAND = 16, - EQUIPMENT_SLOT_RANGED = 17, - EQUIPMENT_SLOT_TABARD = 18, - EQUIPMENT_SLOT_END = 19 -}; - -enum InventorySlots -{ - INVENTORY_SLOT_BAG_0 = 255, - INVENTORY_SLOT_BAG_START = 19, - INVENTORY_SLOT_BAG_1 = 19, - INVENTORY_SLOT_BAG_2 = 20, - INVENTORY_SLOT_BAG_3 = 21, - INVENTORY_SLOT_BAG_4 = 22, - INVENTORY_SLOT_BAG_END = 23, - - INVENTORY_SLOT_ITEM_START = 23, - INVENTORY_SLOT_ITEM_1 = 23, - INVENTORY_SLOT_ITEM_2 = 24, - INVENTORY_SLOT_ITEM_3 = 25, - INVENTORY_SLOT_ITEM_4 = 26, - INVENTORY_SLOT_ITEM_5 = 27, - INVENTORY_SLOT_ITEM_6 = 28, - INVENTORY_SLOT_ITEM_7 = 29, - INVENTORY_SLOT_ITEM_8 = 30, - INVENTORY_SLOT_ITEM_9 = 31, - INVENTORY_SLOT_ITEM_10 = 32, - INVENTORY_SLOT_ITEM_11 = 33, - INVENTORY_SLOT_ITEM_12 = 34, - INVENTORY_SLOT_ITEM_13 = 35, - INVENTORY_SLOT_ITEM_14 = 36, - INVENTORY_SLOT_ITEM_15 = 37, - INVENTORY_SLOT_ITEM_16 = 38, - INVENTORY_SLOT_ITEM_END = 39 -}; - -enum BankSlots -{ - BANK_SLOT_ITEM_START = 39, - BANK_SLOT_ITEM_1 = 39, - BANK_SLOT_ITEM_2 = 40, - BANK_SLOT_ITEM_3 = 41, - BANK_SLOT_ITEM_4 = 42, - BANK_SLOT_ITEM_5 = 43, - BANK_SLOT_ITEM_6 = 44, - BANK_SLOT_ITEM_7 = 45, - BANK_SLOT_ITEM_8 = 46, - BANK_SLOT_ITEM_9 = 47, - BANK_SLOT_ITEM_10 = 48, - BANK_SLOT_ITEM_11 = 49, - BANK_SLOT_ITEM_12 = 50, - BANK_SLOT_ITEM_13 = 51, - BANK_SLOT_ITEM_14 = 52, - BANK_SLOT_ITEM_15 = 53, - BANK_SLOT_ITEM_16 = 54, - BANK_SLOT_ITEM_17 = 55, - BANK_SLOT_ITEM_18 = 56, - BANK_SLOT_ITEM_19 = 57, - BANK_SLOT_ITEM_20 = 58, - BANK_SLOT_ITEM_21 = 59, - BANK_SLOT_ITEM_22 = 60, - BANK_SLOT_ITEM_23 = 61, - BANK_SLOT_ITEM_24 = 62, - BANK_SLOT_ITEM_25 = 63, - BANK_SLOT_ITEM_26 = 64, - BANK_SLOT_ITEM_27 = 65, - BANK_SLOT_ITEM_28 = 66, - BANK_SLOT_ITEM_END = 67, - - BANK_SLOT_BAG_START = 67, - BANK_SLOT_BAG_1 = 67, - BANK_SLOT_BAG_2 = 68, - BANK_SLOT_BAG_3 = 69, - BANK_SLOT_BAG_4 = 70, - BANK_SLOT_BAG_5 = 71, - BANK_SLOT_BAG_6 = 72, - BANK_SLOT_BAG_7 = 73, - BANK_SLOT_BAG_END = 74 -}; - -enum BuyBackSlots -{ - // stored in m_buybackitems - BUYBACK_SLOT_START = 74, - BUYBACK_SLOT_1 = 74, - BUYBACK_SLOT_2 = 75, - BUYBACK_SLOT_3 = 76, - BUYBACK_SLOT_4 = 77, - BUYBACK_SLOT_5 = 78, - BUYBACK_SLOT_6 = 79, - BUYBACK_SLOT_7 = 80, - BUYBACK_SLOT_8 = 81, - BUYBACK_SLOT_9 = 82, - BUYBACK_SLOT_10 = 83, - BUYBACK_SLOT_11 = 84, - BUYBACK_SLOT_12 = 85, - BUYBACK_SLOT_END = 86 -}; - -enum KeyRingSlots -{ - KEYRING_SLOT_START = 86, - KEYRING_SLOT_END = 118 -}; - -struct ItemPosCount -{ - ItemPosCount(uint16 _pos, uint8 _count) : pos(_pos), count(_count) {} - bool isContainedIn(std::vector&); - uint16 pos; - uint8 count; -}; -typedef std::vector ItemPosCountVec; - -enum SwitchWeapon -{ - DEFAULT_SWITCH_WEAPON = 1500, //cooldown in ms - ROGUE_SWITCH_WEAPON = 1000 -}; - -enum TradeSlots -{ - TRADE_SLOT_COUNT = 7, - TRADE_SLOT_TRADED_COUNT = 6, - TRADE_SLOT_NONTRADED = 6 -}; - -enum TransferAbortReason -{ - TRANSFER_ABORT_MAX_PLAYERS = 0x0001, // Transfer Aborted: instance is full - TRANSFER_ABORT_NOT_FOUND = 0x0002, // Transfer Aborted: instance not found - TRANSFER_ABORT_TOO_MANY_INSTANCES = 0x0003, // You have entered too many instances recently. - TRANSFER_ABORT_ZONE_IN_COMBAT = 0x0005, // Unable to zone in while an encounter is in progress. - TRANSFER_ABORT_INSUF_EXPAN_LVL1 = 0x0106, // You must have TBC expansion installed to access this area. - TRANSFER_ABORT_DIFFICULTY1 = 0x0007, // Normal difficulty mode is not available for %s. - TRANSFER_ABORT_DIFFICULTY2 = 0x0107, // Heroic difficulty mode is not available for %s. - TRANSFER_ABORT_DIFFICULTY3 = 0x0207 // Epic difficulty mode is not available for %s. -}; - -enum InstanceResetWarningType -{ - RAID_INSTANCE_WARNING_HOURS = 1, // WARNING! %s is scheduled to reset in %d hour(s). - RAID_INSTANCE_WARNING_MIN = 2, // WARNING! %s is scheduled to reset in %d minute(s)! - RAID_INSTANCE_WARNING_MIN_SOON = 3, // WARNING! %s is scheduled to reset in %d minute(s). Please exit the zone or you will be returned to your bind location! - RAID_INSTANCE_WELCOME = 4 // Welcome to %s. This raid instance is scheduled to reset in %s. -}; - -struct MovementInfo -{ - // common - //uint32 flags; - uint8 unk1; - uint32 time; - float x, y, z, o; - // transport - uint64 t_guid; - float t_x, t_y, t_z, t_o; - uint32 t_time; - // swimming and unk - float s_pitch; - // last fall time - uint32 fallTime; - // jumping - float j_unk, j_sinAngle, j_cosAngle, j_xyspeed; - // spline - float u_unk1; - - MovementInfo() - { - //flags = - time = t_time = fallTime = 0; - unk1 = 0; - x = y = z = o = t_x = t_y = t_z = t_o = s_pitch = j_unk = j_sinAngle = j_cosAngle = j_xyspeed = u_unk1 = 0.0f; - t_guid = 0; - } - - /*void SetMovementFlags(uint32 _flags) - { - flags = _flags; - }*/ -}; - -// flags that use in movement check for example at spell casting -MovementFlags const movementFlagsMask = MovementFlags( - MOVEMENTFLAG_FORWARD |MOVEMENTFLAG_BACKWARD |MOVEMENTFLAG_STRAFE_LEFT|MOVEMENTFLAG_STRAFE_RIGHT| - MOVEMENTFLAG_PITCH_UP|MOVEMENTFLAG_PITCH_DOWN|MOVEMENTFLAG_FLY_UNK1 | - MOVEMENTFLAG_JUMPING |MOVEMENTFLAG_FALLING |MOVEMENTFLAG_FLY_UP | - MOVEMENTFLAG_FLYING |MOVEMENTFLAG_SPLINE -); - -MovementFlags const movementOrTurningFlagsMask = MovementFlags( - movementFlagsMask | MOVEMENTFLAG_LEFT | MOVEMENTFLAG_RIGHT -); -class InstanceSave; - -enum RestType -{ - REST_TYPE_NO = 0, - REST_TYPE_IN_TAVERN = 1, - REST_TYPE_IN_CITY = 2 -}; - -enum DuelCompleteType -{ - DUEL_INTERUPTED = 0, - DUEL_WON = 1, - DUEL_FLED = 2 -}; - -enum TeleportToOptions -{ - TELE_TO_GM_MODE = 0x01, - TELE_TO_NOT_LEAVE_TRANSPORT = 0x02, - TELE_TO_NOT_LEAVE_COMBAT = 0x04, - TELE_TO_NOT_UNSUMMON_PET = 0x08, - TELE_TO_SPELL = 0x10, -}; - -/// Type of environmental damages -enum EnviromentalDamage -{ - DAMAGE_EXHAUSTED = 0, - DAMAGE_DROWNING = 1, - DAMAGE_FALL = 2, - DAMAGE_LAVA = 3, - DAMAGE_SLIME = 4, - DAMAGE_FIRE = 5, - DAMAGE_FALL_TO_VOID = 6 // custom case for fall without durability loss -}; - -// used at player loading query list preparing, and later result selection -enum PlayerLoginQueryIndex -{ - PLAYER_LOGIN_QUERY_LOADFROM = 0, - PLAYER_LOGIN_QUERY_LOADGROUP = 1, - PLAYER_LOGIN_QUERY_LOADBOUNDINSTANCES = 2, - PLAYER_LOGIN_QUERY_LOADAURAS = 3, - PLAYER_LOGIN_QUERY_LOADSPELLS = 4, - PLAYER_LOGIN_QUERY_LOADQUESTSTATUS = 5, - PLAYER_LOGIN_QUERY_LOADDAILYQUESTSTATUS = 6, - PLAYER_LOGIN_QUERY_LOADTUTORIALS = 7, // common for all characters for some account at specific realm - PLAYER_LOGIN_QUERY_LOADREPUTATION = 8, - PLAYER_LOGIN_QUERY_LOADINVENTORY = 9, - PLAYER_LOGIN_QUERY_LOADACTIONS = 10, - PLAYER_LOGIN_QUERY_LOADMAILCOUNT = 11, - PLAYER_LOGIN_QUERY_LOADMAILDATE = 12, - PLAYER_LOGIN_QUERY_LOADSOCIALLIST = 13, - PLAYER_LOGIN_QUERY_LOADHOMEBIND = 14, - PLAYER_LOGIN_QUERY_LOADSPELLCOOLDOWNS = 15, - PLAYER_LOGIN_QUERY_LOADDECLINEDNAMES = 16, - PLAYER_LOGIN_QUERY_LOADGUILD = 17, -}; - -#define MAX_PLAYER_LOGIN_QUERY 18 - -// Player summoning auto-decline time (in secs) -#define MAX_PLAYER_SUMMON_DELAY (2*MINUTE) -#define MAX_MONEY_AMOUNT (0x7FFFFFFF-1) - -struct InstancePlayerBind -{ - InstanceSave *save; - bool perm; - /* permanent PlayerInstanceBinds are created in Raid/Heroic instances for players - that aren't already permanently bound when they are inside when a boss is killed - or when they enter an instance that the group leader is permanently bound to. */ - InstancePlayerBind() : save(NULL), perm(false) {} -}; - -class MANGOS_DLL_SPEC PlayerTaxi -{ - public: - PlayerTaxi(); - ~PlayerTaxi() {} - // Nodes - void InitTaxiNodesForLevel(uint32 race, uint32 level); - void LoadTaxiMask(const char* data); - void SaveTaxiMask(const char* data); - - uint32 GetTaximask( uint8 index ) const { return m_taximask[index]; } - bool IsTaximaskNodeKnown(uint32 nodeidx) const - { - uint8 field = uint8((nodeidx - 1) / 32); - uint32 submask = 1<<((nodeidx-1)%32); - return (m_taximask[field] & submask) == submask; - } - bool SetTaximaskNode(uint32 nodeidx) - { - uint8 field = uint8((nodeidx - 1) / 32); - uint32 submask = 1<<((nodeidx-1)%32); - if ((m_taximask[field] & submask) != submask ) - { - m_taximask[field] |= submask; - return true; - } - else - return false; - } - void AppendTaximaskTo(ByteBuffer& data,bool all); - - // Destinations - bool LoadTaxiDestinationsFromString(std::string values); - std::string SaveTaxiDestinationsToString(); - - void ClearTaxiDestinations() { m_TaxiDestinations.clear(); } - void AddTaxiDestination(uint32 dest) { m_TaxiDestinations.push_back(dest); } - uint32 GetTaxiSource() const { return m_TaxiDestinations.empty() ? 0 : m_TaxiDestinations.front(); } - uint32 GetTaxiDestination() const { return m_TaxiDestinations.size() < 2 ? 0 : m_TaxiDestinations[1]; } - uint32 GetCurrentTaxiPath() const; - uint32 NextTaxiDestination() - { - m_TaxiDestinations.pop_front(); - return GetTaxiDestination(); - } - bool empty() const { return m_TaxiDestinations.empty(); } - private: - TaxiMask m_taximask; - std::deque m_TaxiDestinations; -}; - -class MANGOS_DLL_SPEC Player : public Unit -{ - friend class WorldSession; - friend void Item::AddToUpdateQueueOf(Player *player); - friend void Item::RemoveFromUpdateQueueOf(Player *player); - public: - explicit Player (WorldSession *session); - ~Player ( ); - - void CleanupsBeforeDelete(); - - static UpdateMask updateVisualBits; - static void InitVisibleBits(); - - void AddToWorld(); - void RemoveFromWorld(); - - bool TeleportTo(uint32 mapid, float x, float y, float z, float orientation, uint32 options = 0); - - bool TeleportTo(WorldLocation const &loc, uint32 options = 0) - { - return TeleportTo(loc.mapid, loc.x, loc.y, loc.z, options); - } - - void SetSummonPoint(uint32 mapid, float x, float y, float z) - { - m_summon_expire = time(NULL) + MAX_PLAYER_SUMMON_DELAY; - m_summon_mapid = mapid; - m_summon_x = x; - m_summon_y = y; - m_summon_z = z; - } - void SummonIfPossible(bool agree); - - bool Create( uint32 guidlow, std::string name, uint8 race, uint8 class_, uint8 gender, uint8 skin, uint8 face, uint8 hairStyle, uint8 hairColor, uint8 facialHair, uint8 outfitId ); - - void Update( uint32 time ); - - void BuildEnumData( QueryResult * result, WorldPacket * p_data ); - - void SetInWater(bool apply); - - bool IsInWater() const { return m_isInWater; } - bool IsUnderWater() const; - - void SendInitialPacketsBeforeAddToMap(); - void SendInitialPacketsAfterAddToMap(); - void SendTransferAborted(uint32 mapid, uint16 reason); - void SendInstanceResetWarning(uint32 mapid, uint32 time); - - bool CanInteractWithNPCs(bool alive = true) const; - - bool ToggleAFK(); - bool ToggleDND(); - bool isAFK() const { return HasFlag(PLAYER_FLAGS,PLAYER_FLAGS_AFK); }; - bool isDND() const { return HasFlag(PLAYER_FLAGS,PLAYER_FLAGS_DND); }; - uint8 chatTag() const; - std::string afkMsg; - std::string dndMsg; - - PlayerSocial *GetSocial() { return m_social; } - - PlayerTaxi m_taxi; - void InitTaxiNodesForLevel() { m_taxi.InitTaxiNodesForLevel(getRace(),getLevel()); } - bool ActivateTaxiPathTo(std::vector const& nodes, uint32 mount_id = 0 , Creature* npc = NULL); - // mount_id can be used in scripting calls - bool isAcceptTickets() const { return GetSession()->GetSecurity() >= SEC_GAMEMASTER && (m_ExtraFlags & PLAYER_EXTRA_GM_ACCEPT_TICKETS); } - void SetAcceptTicket(bool on) { if(on) m_ExtraFlags |= PLAYER_EXTRA_GM_ACCEPT_TICKETS; else m_ExtraFlags &= ~PLAYER_EXTRA_GM_ACCEPT_TICKETS; } - bool isAcceptWhispers() const { return m_ExtraFlags & PLAYER_EXTRA_ACCEPT_WHISPERS; } - void SetAcceptWhispers(bool on) { if(on) m_ExtraFlags |= PLAYER_EXTRA_ACCEPT_WHISPERS; else m_ExtraFlags &= ~PLAYER_EXTRA_ACCEPT_WHISPERS; } - bool isGameMaster() const { return m_ExtraFlags & PLAYER_EXTRA_GM_ON; } - void SetGameMaster(bool on); - bool isTaxiCheater() const { return m_ExtraFlags & PLAYER_EXTRA_TAXICHEAT; } - void SetTaxiCheater(bool on) { if(on) m_ExtraFlags |= PLAYER_EXTRA_TAXICHEAT; else m_ExtraFlags &= ~PLAYER_EXTRA_TAXICHEAT; } - bool isGMVisible() const { return !(m_ExtraFlags & PLAYER_EXTRA_GM_INVISIBLE); } - void SetGMVisible(bool on); - void SetPvPDeath(bool on) { if(on) m_ExtraFlags |= PLAYER_EXTRA_PVP_DEATH; else m_ExtraFlags &= ~PLAYER_EXTRA_PVP_DEATH; } - - void GiveXP(uint32 xp, Unit* victim); - void GiveLevel(uint32 level); - void InitStatsForLevel(bool reapplyMods = false); - - // Played Time Stuff - time_t m_logintime; - time_t m_Last_tick; - uint32 m_Played_time[2]; - uint32 GetTotalPlayedTime() { return m_Played_time[0]; }; - uint32 GetLevelPlayedTime() { return m_Played_time[1]; }; - - void setDeathState(DeathState s); // overwrite Unit::setDeathState - - void InnEnter (int time,uint32 mapid, float x,float y,float z) - { - inn_pos_mapid = mapid; - inn_pos_x = x; - inn_pos_y = y; - inn_pos_z = z; - time_inn_enter = time; - }; - - float GetRestBonus() const { return m_rest_bonus; }; - void SetRestBonus(float rest_bonus_new); - - RestType GetRestType() const { return rest_type; }; - void SetRestType(RestType n_r_type) { rest_type = n_r_type; }; - - uint32 GetInnPosMapId() const { return inn_pos_mapid; }; - float GetInnPosX() const { return inn_pos_x; }; - float GetInnPosY() const { return inn_pos_y; }; - float GetInnPosZ() const { return inn_pos_z; }; - - int GetTimeInnEnter() const { return time_inn_enter; }; - void UpdateInnerTime (int time) { time_inn_enter = time; }; - - void RemovePet(Pet* pet, PetSaveMode mode, bool returnreagent = false); - void RemoveMiniPet(); - Pet* GetMiniPet(); - void SetMiniPet(Pet* pet) { m_miniPet = pet->GetGUID(); } - void RemoveGuardians(); - bool HasGuardianWithEntry(uint32 entry); - void AddGuardian(Pet* pet) { m_guardianPets.insert(pet->GetGUID()); } - GuardianPetList const& GetGuardians() const { return m_guardianPets; } - void Uncharm(); - - void Say(std::string text, const uint32 language); - void Yell(std::string text, const uint32 language); - void TextEmote(std::string text); - void Whisper(std::string text, const uint32 language,uint64 receiver); - void BuildPlayerChat(WorldPacket *data, uint8 msgtype, std::string text, uint32 language) const; - - /*********************************************************/ - /*** STORAGE SYSTEM ***/ - /*********************************************************/ - - void SetVirtualItemSlot( uint8 i, Item* item); - void SetSheath( uint32 sheathed ); - uint8 FindEquipSlot( ItemPrototype const* proto, uint32 slot, bool swap ) const; - uint32 GetItemCount( uint32 item, bool inBankAlso = false, Item* skipItem = NULL ) const; - Item* GetItemByGuid( uint64 guid ) const; - Item* GetItemByPos( uint16 pos ) const; - Item* GetItemByPos( uint8 bag, uint8 slot ) const; - Item* GetWeaponForAttack(WeaponAttackType attackType, bool useable = false) const; - Item* GetShield(bool useable = false) const; - static uint32 GetAttackBySlot( uint8 slot ); // MAX_ATTACK if not weapon slot - std::vector &GetItemUpdateQueue() { return m_itemUpdateQueue; } - static bool IsInventoryPos( uint16 pos ) { return IsInventoryPos(pos >> 8,pos & 255); } - static bool IsInventoryPos( uint8 bag, uint8 slot ); - static bool IsEquipmentPos( uint16 pos ) { return IsEquipmentPos(pos >> 8,pos & 255); } - static bool IsEquipmentPos( uint8 bag, uint8 slot ); - static bool IsBagPos( uint16 pos ); - static bool IsBankPos( uint16 pos ) { return IsBankPos(pos >> 8,pos & 255); } - static bool IsBankPos( uint8 bag, uint8 slot ); - bool HasBankBagSlot( uint8 slot ) const; - bool HasItemCount( uint32 item, uint32 count, bool inBankAlso = false ) const; - bool HasItemFitToSpellReqirements(SpellEntry const* spellInfo, Item const* ignoreItem = NULL); - Item* GetItemOrItemWithGemEquipped( uint32 item ) const; - uint8 CanTakeMoreSimilarItems(Item* pItem) const { return _CanTakeMoreSimilarItems(pItem->GetEntry(),pItem->GetCount(),pItem); } - uint8 CanTakeMoreSimilarItems(uint32 entry, uint32 count) const { return _CanTakeMoreSimilarItems(entry,count,NULL); } - uint8 CanStoreNewItem( uint8 bag, uint8 slot, ItemPosCountVec& dest, uint32 item, uint32 count, uint32* no_space_count = NULL ) const - { - return _CanStoreItem(bag, slot, dest, item, count, NULL, false, no_space_count ); - } - uint8 CanStoreItem( uint8 bag, uint8 slot, ItemPosCountVec& dest, Item *pItem, bool swap = false ) const - { - if(!pItem) - return EQUIP_ERR_ITEM_NOT_FOUND; - uint32 count = pItem->GetCount(); - return _CanStoreItem( bag, slot, dest, pItem->GetEntry(), count, pItem, swap, NULL ); - - } - uint8 CanStoreItems( Item **pItem,int count) const; - uint8 CanEquipNewItem( uint8 slot, uint16 &dest, uint32 item, uint32 count, bool swap ) const; - uint8 CanEquipItem( uint8 slot, uint16 &dest, Item *pItem, bool swap, bool not_loading = true ) const; - uint8 CanUnequipItems( uint32 item, uint32 count ) const; - uint8 CanUnequipItem( uint16 src, bool swap ) const; - uint8 CanBankItem( uint8 bag, uint8 slot, ItemPosCountVec& dest, Item *pItem, bool swap, bool not_loading = true ) const; - uint8 CanUseItem( Item *pItem, bool not_loading = true ) const; - bool HasItemTotemCategory( uint32 TotemCategory ) const; - bool CanUseItem( ItemPrototype const *pItem ); - uint8 CanUseAmmo( uint32 item ) const; - Item* StoreNewItem( ItemPosCountVec const& pos, uint32 item, bool update,int32 randomPropertyId = 0 ); - Item* StoreItem( ItemPosCountVec const& pos, Item *pItem, bool update ); - Item* EquipNewItem( uint16 pos, uint32 item, uint32 count, bool update ); - Item* EquipItem( uint16 pos, Item *pItem, bool update ); - void AutoUnequipOffhandIfNeed(); - - uint8 _CanTakeMoreSimilarItems(uint32 entry, uint32 count, Item* pItem, uint32* no_space_count = NULL) const; - uint8 _CanStoreItem( uint8 bag, uint8 slot, ItemPosCountVec& dest, uint32 entry, uint32 count, Item *pItem = NULL, bool swap = false, uint32* no_space_count = NULL ) const; - - void ApplyEquipCooldown( Item * pItem ); - void SetAmmo( uint32 item ); - void RemoveAmmo(); - float GetAmmoDPS() const { return m_ammoDPS; } - bool CheckAmmoCompatibility(const ItemPrototype *ammo_proto) const; - void QuickEquipItem( uint16 pos, Item *pItem); - void VisualizeItem( uint8 slot, Item *pItem); - void SetVisibleItemSlot(uint8 slot, Item *pItem); - Item* BankItem( ItemPosCountVec const& dest, Item *pItem, bool update ) - { - return StoreItem( dest, pItem, update); - } - Item* BankItem( uint16 pos, Item *pItem, bool update ); - void RemoveItem( uint8 bag, uint8 slot, bool update ); - void MoveItemFromInventory(uint8 bag, uint8 slot, bool update); - // in trade, auction, guild bank, mail.... - void MoveItemToInventory(ItemPosCountVec const& dest, Item* pItem, bool update, bool in_characterInventoryDB = false); - // in trade, guild bank, mail.... - void RemoveItemDependentAurasAndCasts( Item * pItem ); - void DestroyItem( uint8 bag, uint8 slot, bool update ); - void DestroyItemCount( uint32 item, uint32 count, bool update, bool unequip_check = false); - void DestroyItemCount( Item* item, uint32& count, bool update ); - void DestroyConjuredItems( bool update ); - void DestroyZoneLimitedItem( bool update, uint32 new_zone ); - void SplitItem( uint16 src, uint16 dst, uint32 count ); - void SwapItem( uint16 src, uint16 dst ); - void AddItemToBuyBackSlot( Item *pItem ); - Item* GetItemFromBuyBackSlot( uint32 slot ); - void RemoveItemFromBuyBackSlot( uint32 slot, bool del ); - uint32 GetMaxKeyringSize() const { return KEYRING_SLOT_END-KEYRING_SLOT_START; } - void SendEquipError( uint8 msg, Item* pItem, Item *pItem2 ); - void SendBuyError( uint8 msg, Creature* pCreature, uint32 item, uint32 param ); - void SendSellError( uint8 msg, Creature* pCreature, uint64 guid, uint32 param ); - void AddWeaponProficiency(uint32 newflag) { m_WeaponProficiency |= newflag; } - void AddArmorProficiency(uint32 newflag) { m_ArmorProficiency |= newflag; } - uint32 GetWeaponProficiency() const { return m_WeaponProficiency; } - uint32 GetArmorProficiency() const { return m_ArmorProficiency; } - bool IsInFeralForm() const { return m_form == FORM_CAT || m_form == FORM_BEAR || m_form == FORM_DIREBEAR; } - bool IsUseEquipedWeapon( bool mainhand ) const - { - // disarm applied only to mainhand weapon - return !IsInFeralForm() && (!mainhand || !HasFlag(UNIT_FIELD_FLAGS,UNIT_FLAG_DISARMED) ); - } - void SendNewItem( Item *item, uint32 count, bool received, bool created, bool broadcast = false ); - bool BuyItemFromVendor(uint64 vendorguid, uint32 item, uint8 count, uint64 bagguid, uint8 slot); - - float GetReputationPriceDiscount( Creature const* pCreature ) const; - Player* GetTrader() const { return pTrader; } - void ClearTrade(); - void TradeCancel(bool sendback); - uint16 GetItemPosByTradeSlot(uint32 slot) const { return tradeItems[slot]; } - - void UpdateEnchantTime(uint32 time); - void UpdateItemDuration(uint32 time, bool realtimeonly=false); - void AddEnchantmentDurations(Item *item); - void RemoveEnchantmentDurations(Item *item); - void RemoveAllEnchantments(EnchantmentSlot slot); - void AddEnchantmentDuration(Item *item,EnchantmentSlot slot,uint32 duration); - void ApplyEnchantment(Item *item,EnchantmentSlot slot,bool apply, bool apply_dur = true, bool ignore_condition = false); - void ApplyEnchantment(Item *item,bool apply); - void SendEnchantmentDurations(); - void AddItemDurations(Item *item); - void RemoveItemDurations(Item *item); - void SendItemDurations(); - void LoadCorpse(); - void LoadPet(); - - uint32 m_stableSlots; - - /*********************************************************/ - /*** QUEST SYSTEM ***/ - /*********************************************************/ - - void PrepareQuestMenu( uint64 guid ); - void SendPreparedQuest( uint64 guid ); - bool IsActiveQuest( uint32 quest_id ) const; - Quest const *GetNextQuest( uint64 guid, Quest const *pQuest ); - bool CanSeeStartQuest( Quest const *pQuest ); - bool CanTakeQuest( Quest const *pQuest, bool msg ); - bool CanAddQuest( Quest const *pQuest, bool msg ); - bool CanCompleteQuest( uint32 quest_id ); - bool CanCompleteRepeatableQuest(Quest const *pQuest); - bool CanRewardQuest( Quest const *pQuest, bool msg ); - bool CanRewardQuest( Quest const *pQuest, uint32 reward, bool msg ); - void AddQuest( Quest const *pQuest, Object *questGiver ); - void CompleteQuest( uint32 quest_id ); - void IncompleteQuest( uint32 quest_id ); - void RewardQuest( Quest const *pQuest, uint32 reward, Object* questGiver, bool announce = true ); - void FailQuest( uint32 quest_id ); - void FailTimedQuest( uint32 quest_id ); - bool SatisfyQuestSkillOrClass( Quest const* qInfo, bool msg ); - bool SatisfyQuestLevel( Quest const* qInfo, bool msg ); - bool SatisfyQuestLog( bool msg ); - bool SatisfyQuestPreviousQuest( Quest const* qInfo, bool msg ); - bool SatisfyQuestRace( Quest const* qInfo, bool msg ); - bool SatisfyQuestReputation( Quest const* qInfo, bool msg ); - bool SatisfyQuestStatus( Quest const* qInfo, bool msg ); - bool SatisfyQuestTimed( Quest const* qInfo, bool msg ); - bool SatisfyQuestExclusiveGroup( Quest const* qInfo, bool msg ); - bool SatisfyQuestNextChain( Quest const* qInfo, bool msg ); - bool SatisfyQuestPrevChain( Quest const* qInfo, bool msg ); - bool SatisfyQuestDay( Quest const* qInfo, bool msg ); - bool GiveQuestSourceItem( Quest const *pQuest ); - bool TakeQuestSourceItem( uint32 quest_id, bool msg ); - bool GetQuestRewardStatus( uint32 quest_id ) const; - QuestStatus GetQuestStatus( uint32 quest_id ) const; - void SetQuestStatus( uint32 quest_id, QuestStatus status ); - - void SetDailyQuestStatus( uint32 quest_id ); - void ResetDailyQuestStatus(); - - uint16 FindQuestSlot( uint32 quest_id ) const; - uint32 GetQuestSlotQuestId(uint16 slot) const { return GetUInt32Value(PLAYER_QUEST_LOG_1_1 + slot*MAX_QUEST_OFFSET + QUEST_ID_OFFSET); } - uint32 GetQuestSlotState(uint16 slot) const { return GetUInt32Value(PLAYER_QUEST_LOG_1_1 + slot*MAX_QUEST_OFFSET + QUEST_STATE_OFFSET); } - uint32 GetQuestSlotCounters(uint16 slot)const { return GetUInt32Value(PLAYER_QUEST_LOG_1_1 + slot*MAX_QUEST_OFFSET + QUEST_COUNTS_OFFSET); } - uint8 GetQuestSlotCounter(uint16 slot,uint8 counter) const { return GetByteValue(PLAYER_QUEST_LOG_1_1 + slot*MAX_QUEST_OFFSET + QUEST_COUNTS_OFFSET,counter); } - uint32 GetQuestSlotTime(uint16 slot) const { return GetUInt32Value(PLAYER_QUEST_LOG_1_1 + slot*MAX_QUEST_OFFSET + QUEST_TIME_OFFSET); } - void SetQuestSlot(uint16 slot,uint32 quest_id, uint32 timer = 0) - { - SetUInt32Value(PLAYER_QUEST_LOG_1_1 + slot*MAX_QUEST_OFFSET + QUEST_ID_OFFSET,quest_id); - SetUInt32Value(PLAYER_QUEST_LOG_1_1 + slot*MAX_QUEST_OFFSET + QUEST_STATE_OFFSET,0); - SetUInt32Value(PLAYER_QUEST_LOG_1_1 + slot*MAX_QUEST_OFFSET + QUEST_COUNTS_OFFSET,0); - SetUInt32Value(PLAYER_QUEST_LOG_1_1 + slot*MAX_QUEST_OFFSET + QUEST_TIME_OFFSET,timer); - } - void SetQuestSlotCounter(uint16 slot,uint8 counter,uint8 count) { SetByteValue(PLAYER_QUEST_LOG_1_1 + slot*MAX_QUEST_OFFSET + QUEST_COUNTS_OFFSET,counter,count); } - void SetQuestSlotState(uint16 slot,uint32 state) { SetFlag(PLAYER_QUEST_LOG_1_1 + slot*MAX_QUEST_OFFSET + QUEST_STATE_OFFSET,state); } - void RemoveQuestSlotState(uint16 slot,uint32 state) { RemoveFlag(PLAYER_QUEST_LOG_1_1 + slot*MAX_QUEST_OFFSET + QUEST_STATE_OFFSET,state); } - void SetQuestSlotTimer(uint16 slot,uint32 timer) { SetUInt32Value(PLAYER_QUEST_LOG_1_1 + slot*MAX_QUEST_OFFSET + QUEST_TIME_OFFSET,timer); } - void SwapQuestSlot(uint16 slot1,uint16 slot2) - { - for (int i = 0; i < MAX_QUEST_OFFSET ; ++i ) - { - uint32 temp1 = GetUInt32Value(PLAYER_QUEST_LOG_1_1 + MAX_QUEST_OFFSET *slot1 + i); - uint32 temp2 = GetUInt32Value(PLAYER_QUEST_LOG_1_1 + MAX_QUEST_OFFSET *slot2 + i); - - SetUInt32Value(PLAYER_QUEST_LOG_1_1 + MAX_QUEST_OFFSET *slot1 + i, temp2); - SetUInt32Value(PLAYER_QUEST_LOG_1_1 + MAX_QUEST_OFFSET *slot2 + i, temp1); - } - } - uint32 GetReqKillOrCastCurrentCount(uint32 quest_id, int32 entry); - void AdjustQuestReqItemCount( Quest const* pQuest ); - void AreaExploredOrEventHappens( uint32 questId ); - void GroupEventHappens( uint32 questId, WorldObject const* pEventObject ); - void ItemAddedQuestCheck( uint32 entry, uint32 count ); - void ItemRemovedQuestCheck( uint32 entry, uint32 count ); - void KilledMonster( uint32 entry, uint64 guid ); - void CastedCreatureOrGO( uint32 entry, uint64 guid, uint32 spell_id ); - void TalkedToCreature( uint32 entry, uint64 guid ); - void MoneyChanged( uint32 value ); - bool HasQuestForItem( uint32 itemid ) const; - bool HasQuestForGO(int32 GOId); - void UpdateForQuestsGO(); - bool CanShareQuest(uint32 quest_id) const; - - void SendQuestComplete( uint32 quest_id ); - void SendQuestReward( Quest const *pQuest, uint32 XP, Object* questGiver ); - void SendQuestFailed( uint32 quest_id ); - void SendQuestTimerFailed( uint32 quest_id ); - void SendCanTakeQuestResponse( uint32 msg ); - void SendPushToPartyResponse( Player *pPlayer, uint32 msg ); - void SendQuestUpdateAddItem( Quest const* pQuest, uint32 item_idx, uint32 count ); - void SendQuestUpdateAddCreatureOrGo( Quest const* pQuest, uint64 guid, uint32 creatureOrGO_idx, uint32 old_count, uint32 add_count ); - - uint64 GetDivider() { return m_divider; }; - void SetDivider( uint64 guid ) { m_divider = guid; }; - - uint32 GetInGameTime() { return m_ingametime; }; - - void SetInGameTime( uint32 time ) { m_ingametime = time; }; - - void AddTimedQuest( uint32 quest_id ) { m_timedquests.insert(quest_id); } - - /*********************************************************/ - /*** LOAD SYSTEM ***/ - /*********************************************************/ - - bool LoadFromDB(uint32 guid, SqlQueryHolder *holder); - bool MinimalLoadFromDB(QueryResult *result, uint32 guid); - static bool LoadValuesArrayFromDB(Tokens& data,uint64 guid); - static uint32 GetUInt32ValueFromArray(Tokens const& data, uint16 index); - static float GetFloatValueFromArray(Tokens const& data, uint16 index); - static uint32 GetUInt32ValueFromDB(uint16 index, uint64 guid); - static float GetFloatValueFromDB(uint16 index, uint64 guid); - static uint32 GetZoneIdFromDB(uint64 guid); - static bool LoadPositionFromDB(uint32& mapid, float& x,float& y,float& z,float& o, bool& in_flight, uint64 guid); - - /*********************************************************/ - /*** SAVE SYSTEM ***/ - /*********************************************************/ - - void SaveToDB(); - void SaveInventoryAndGoldToDB(); // fast save function for item/money cheating preventing - void SaveGoldToDB() { SetUInt32ValueInDB(PLAYER_FIELD_COINAGE,GetMoney(),GetGUID()); } - static bool SaveValuesArrayInDB(Tokens const& data,uint64 guid); - static void SetUInt32ValueInArray(Tokens& data,uint16 index, uint32 value); - static void SetFloatValueInArray(Tokens& data,uint16 index, float value); - static void SetUInt32ValueInDB(uint16 index, uint32 value, uint64 guid); - static void SetFloatValueInDB(uint16 index, float value, uint64 guid); - static void SavePositionInDB(uint32 mapid, float x,float y,float z,float o,uint32 zone,uint64 guid); - - bool m_mailsLoaded; - bool m_mailsUpdated; - - void SetBindPoint(uint64 guid); - void SendTalentWipeConfirm(uint64 guid); - void RewardRage( uint32 damage, uint32 weaponSpeedHitFactor, bool attacker ); - void SendPetSkillWipeConfirm(); - void CalcRage( uint32 damage,bool attacker ); - void RegenerateAll(); - void Regenerate(Powers power); - void RegenerateHealth(); - void setRegenTimer(uint32 time) {m_regenTimer = time;} - void setWeaponChangeTimer(uint32 time) {m_weaponChangeTimer = time;} - - uint32 GetMoney() { return GetUInt32Value (PLAYER_FIELD_COINAGE); } - void ModifyMoney( int32 d ) - { - if(d < 0) - SetMoney (GetMoney() > uint32(-d) ? GetMoney() + d : 0); - else - SetMoney (GetMoney() < MAX_MONEY_AMOUNT - d ? GetMoney() + d : MAX_MONEY_AMOUNT); - - // "At Gold Limit" - if(GetMoney() >= MAX_MONEY_AMOUNT) - SendEquipError(EQUIP_ERR_TOO_MUCH_GOLD,NULL,NULL); - } - void SetMoney( uint32 value ) - { - SetUInt32Value (PLAYER_FIELD_COINAGE, value); - MoneyChanged( value ); - } - - uint32 GetTutorialInt(uint32 intId ) - { - ASSERT( (intId < 8) ); - return m_Tutorials[intId]; - } - - void SetTutorialInt(uint32 intId, uint32 value) - { - ASSERT( (intId < 8) ); - if(m_Tutorials[intId]!=value) - { - m_Tutorials[intId] = value; - m_TutorialsChanged = true; - } - } - - QuestStatusMap& getQuestStatusMap() { return mQuestStatus; }; - - const uint64& GetSelection( ) const { return m_curSelection; } - void SetSelection(const uint64 &guid) { m_curSelection = guid; SetUInt64Value(UNIT_FIELD_TARGET, guid); } - - uint8 GetComboPoints() { return m_comboPoints; } - uint64 GetComboTarget() { return m_comboTarget; } - - void AddComboPoints(Unit* target, int8 count); - void ClearComboPoints(); - void SendComboPoints(); - - void SendMailResult(uint32 mailId, uint32 mailAction, uint32 mailError, uint32 equipError = 0, uint32 item_guid = 0, uint32 item_count = 0); - void SendNewMail(); - void UpdateNextMailTimeAndUnreads(); - void AddNewMailDeliverTime(time_t deliver_time); - bool IsMailsLoaded() const { return m_mailsLoaded; } - - //void SetMail(Mail *m); - void RemoveMail(uint32 id); - - void AddMail(Mail* mail) { m_mail.push_front(mail);}// for call from WorldSession::SendMailTo - uint32 GetMailSize() { return m_mail.size();}; - Mail* GetMail(uint32 id); - - PlayerMails::iterator GetmailBegin() { return m_mail.begin();}; - PlayerMails::iterator GetmailEnd() { return m_mail.end();}; - - /*********************************************************/ - /*** MAILED ITEMS SYSTEM ***/ - /*********************************************************/ - - uint8 unReadMails; - time_t m_nextMailDelivereTime; - - typedef HM_NAMESPACE::hash_map ItemMap; - - ItemMap mMitems; //template defined in objectmgr.cpp - - Item* GetMItem(uint32 id) - { - ItemMap::const_iterator itr = mMitems.find(id); - if (itr != mMitems.end()) - return itr->second; - - return NULL; - } - - void AddMItem(Item* it) - { - ASSERT( it ); - //assert deleted, because items can be added before loading - mMitems[it->GetGUIDLow()] = it; - } - - bool RemoveMItem(uint32 id) - { - ItemMap::iterator i = mMitems.find(id); - if (i == mMitems.end()) - return false; - - mMitems.erase(i); - return true; - } - - void PetSpellInitialize(); - void CharmSpellInitialize(); - void PossessSpellInitialize(); - bool HasSpell(uint32 spell) const; - TrainerSpellState GetTrainerSpellState(TrainerSpell const* trainer_spell) const; - bool IsSpellFitByClassAndRace( uint32 spell_id ) const; - - void SendProficiency(uint8 pr1, uint32 pr2); - void SendInitialSpells(); - bool addSpell(uint32 spell_id, bool active, bool learning = true, bool loading = false, uint16 slot_id=SPELL_WITHOUT_SLOT_ID, bool disabled = false); - void learnSpell(uint32 spell_id); - void removeSpell(uint32 spell_id, bool disabled = false); - void resetSpells(); - void learnDefaultSpells(bool loading = false); - void learnQuestRewardedSpells(); - void learnQuestRewardedSpells(Quest const* quest); - - uint32 GetFreeTalentPoints() const { return GetUInt32Value(PLAYER_CHARACTER_POINTS1); } - void SetFreeTalentPoints(uint32 points) { SetUInt32Value(PLAYER_CHARACTER_POINTS1,points); } - bool resetTalents(bool no_cost = false); - uint32 resetTalentsCost() const; - void InitTalentForLevel(); - - uint32 GetFreePrimaryProffesionPoints() const { return GetUInt32Value(PLAYER_CHARACTER_POINTS2); } - void SetFreePrimaryProffesions(uint16 profs) { SetUInt32Value(PLAYER_CHARACTER_POINTS2,profs); } - void InitPrimaryProffesions(); - - PlayerSpellMap const& GetSpellMap() const { return m_spells; } - PlayerSpellMap & GetSpellMap() { return m_spells; } - - void AddSpellMod(SpellModifier* mod, bool apply); - int32 GetTotalFlatMods(uint32 spellId, SpellModOp op); - int32 GetTotalPctMods(uint32 spellId, SpellModOp op); - bool IsAffectedBySpellmod(SpellEntry const *spellInfo, SpellModifier *mod, Spell const* spell = NULL); - template T ApplySpellMod(uint32 spellId, SpellModOp op, T &basevalue, Spell const* spell = NULL); - void RemoveSpellMods(Spell const* spell); - - bool HasSpellCooldown(uint32 spell_id) const - { - SpellCooldowns::const_iterator itr = m_spellCooldowns.find(spell_id); - return itr != m_spellCooldowns.end() && itr->second.end > time(NULL); - } - uint32 GetSpellCooldownDelay(uint32 spell_id) const - { - SpellCooldowns::const_iterator itr = m_spellCooldowns.find(spell_id); - time_t t = time(NULL); - return itr != m_spellCooldowns.end() && itr->second.end > t ? itr->second.end - t : 0; - } - void AddSpellCooldown(uint32 spell_id, uint32 itemid, time_t end_time); - void SendCooldownEvent(SpellEntry const *spellInfo); - void ProhibitSpellScholl(SpellSchoolMask idSchoolMask, uint32 unTimeMs ); - void RemoveSpellCooldown(uint32 spell_id) { m_spellCooldowns.erase(spell_id); } - void RemoveArenaSpellCooldowns(); - void RemoveAllSpellCooldown(); - void _LoadSpellCooldowns(QueryResult *result); - void _SaveSpellCooldowns(); - - void setResurrectRequestData(uint64 guid, uint32 mapId, float X, float Y, float Z, uint32 health, uint32 mana) - { - m_resurrectGUID = guid; - m_resurrectMap = mapId; - m_resurrectX = X; - m_resurrectY = Y; - m_resurrectZ = Z; - m_resurrectHealth = health; - m_resurrectMana = mana; - }; - void clearResurrectRequestData() { setResurrectRequestData(0,0,0.0f,0.0f,0.0f,0,0); } - bool isRessurectRequestedBy(uint64 guid) const { return m_resurrectGUID == guid; } - bool isRessurectRequested() const { return m_resurrectGUID != 0; } - void ResurectUsingRequestData(); - - int getCinematic() - { - return m_cinematic; - } - void setCinematic(int cine) - { - m_cinematic = cine; - } - - void addActionButton(uint8 button, uint16 action, uint8 type, uint8 misc); - void removeActionButton(uint8 button); - void SendInitialActionButtons(); - - PvPInfo pvpInfo; - void UpdatePvP(bool state, bool ovrride=false); - void UpdateZone(uint32 newZone); - void UpdateArea(uint32 newArea); - - void UpdateZoneDependentAuras( uint32 zone_id ); // zones - void UpdateAreaDependentAuras( uint32 area_id ); // subzones - - void UpdateAfkReport(time_t currTime); - void UpdatePvPFlag(time_t currTime); - void UpdateContestedPvP(uint32 currTime); - void SetContestedPvPTimer(uint32 newTime) {m_contestedPvPTimer = newTime;} - void ResetContestedPvP() - { - clearUnitState(UNIT_STAT_ATTACK_PLAYER); - RemoveFlag(PLAYER_FLAGS, PLAYER_FLAGS_CONTESTED_PVP); - m_contestedPvPTimer = 0; - } - - /** todo: -maybe move UpdateDuelFlag+DuelComplete to independent DuelHandler.. **/ - DuelInfo *duel; - void UpdateDuelFlag(time_t currTime); - void CheckDuelDistance(time_t currTime); - void DuelComplete(DuelCompleteType type); - - bool IsGroupVisibleFor(Player* p) const; - bool IsInSameGroupWith(Player const* p) const; - bool IsInSameRaidWith(Player const* p) const { return p==this || (GetGroup() != NULL && GetGroup() == p->GetGroup()); } - void UninviteFromGroup(); - static void RemoveFromGroup(Group* group, uint64 guid); - void RemoveFromGroup() { RemoveFromGroup(GetGroup(),GetGUID()); } - void SendUpdateToOutOfRangeGroupMembers(); - - void SetInGuild(uint32 GuildId) { SetUInt32Value(PLAYER_GUILDID, GuildId); Player::SetUInt32ValueInDB(PLAYER_GUILDID, GuildId, this->GetGUID()); } - void SetRank(uint32 rankId){ SetUInt32Value(PLAYER_GUILDRANK, rankId); Player::SetUInt32ValueInDB(PLAYER_GUILDRANK, rankId, this->GetGUID()); } - void SetGuildIdInvited(uint32 GuildId) { m_GuildIdInvited = GuildId; } - uint32 GetGuildId() { return GetUInt32Value(PLAYER_GUILDID); } - static uint32 GetGuildIdFromDB(uint64 guid); - uint32 GetRank(){ return GetUInt32Value(PLAYER_GUILDRANK); } - static uint32 GetRankFromDB(uint64 guid); - int GetGuildIdInvited() { return m_GuildIdInvited; } - static void RemovePetitionsAndSigns(uint64 guid, uint32 type); - - // Arena Team - void SetInArenaTeam(uint32 ArenaTeamId, uint8 slot) - { - SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (slot * 6), ArenaTeamId); - SetUInt32ValueInDB(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (slot * 6), ArenaTeamId, this->GetGUID()); - } - uint32 GetArenaTeamId(uint8 slot) { return GetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (slot * 6)); } - static uint32 GetArenaTeamIdFromDB(uint64 guid, uint8 slot); - void SetArenaTeamIdInvited(uint32 ArenaTeamId) { m_ArenaTeamIdInvited = ArenaTeamId; } - uint32 GetArenaTeamIdInvited() { return m_ArenaTeamIdInvited; } - - void SetDifficulty(uint32 dungeon_difficulty) { m_dungeonDifficulty = dungeon_difficulty; } - uint8 GetDifficulty() { return m_dungeonDifficulty; } - - bool UpdateSkill(uint32 skill_id, uint32 step); - bool UpdateSkillPro(uint16 SkillId, int32 Chance, uint32 step); - - bool UpdateCraftSkill(uint32 spellid); - bool UpdateGatherSkill(uint32 SkillId, uint32 SkillValue, uint32 RedLevel, uint32 Multiplicator = 1); - bool UpdateFishingSkill(); - - uint32 GetBaseDefenseSkillValue() const { return GetBaseSkillValue(SKILL_DEFENSE); } - uint32 GetBaseWeaponSkillValue(WeaponAttackType attType) const; - - uint32 GetSpellByProto(ItemPrototype *proto); - - float GetHealthBonusFromStamina(); - float GetManaBonusFromIntellect(); - - bool UpdateStats(Stats stat); - bool UpdateAllStats(); - void UpdateResistances(uint32 school); - void UpdateArmor(); - void UpdateMaxHealth(); - void UpdateMaxPower(Powers power); - void UpdateAttackPowerAndDamage(bool ranged = false); - void UpdateShieldBlockValue(); - void UpdateDamagePhysical(WeaponAttackType attType); - void UpdateSpellDamageAndHealingBonus(); - - void CalculateMinMaxDamage(WeaponAttackType attType, bool normalized, float& min_damage, float& max_damage); - - void UpdateDefenseBonusesMod(); - void ApplyRatingMod(CombatRating cr, int32 value, bool apply); - float GetMeleeCritFromAgility(); - float GetDodgeFromAgility(); - float GetSpellCritFromIntellect(); - float OCTRegenHPPerSpirit(); - float OCTRegenMPPerSpirit(); - float GetRatingCoefficient(CombatRating cr) const; - float GetRatingBonusValue(CombatRating cr) const; - uint32 GetMeleeCritDamageReduction(uint32 damage) const; - uint32 GetRangedCritDamageReduction(uint32 damage) const; - uint32 GetSpellCritDamageReduction(uint32 damage) const; - uint32 GetDotDamageReduction(uint32 damage) const; - - float GetExpertiseDodgeOrParryReduction(WeaponAttackType attType) const; - void UpdateBlockPercentage(); - void UpdateCritPercentage(WeaponAttackType attType); - void UpdateAllCritPercentages(); - void UpdateParryPercentage(); - void UpdateDodgePercentage(); - void UpdateAllSpellCritChances(); - void UpdateSpellCritChance(uint32 school); - void UpdateExpertise(WeaponAttackType attType); - void UpdateManaRegen(); - - const uint64& GetLootGUID() const { return m_lootGuid; } - void SetLootGUID(const uint64 &guid) { m_lootGuid = guid; } - - void RemovedInsignia(Player* looterPlr); - - WorldSession* GetSession() const { return m_session; } - void SetSession(WorldSession *s) { m_session = s; } - - void BuildCreateUpdateBlockForPlayer( UpdateData *data, Player *target ) const; - void DestroyForPlayer( Player *target ) const; - void SendDelayResponse(const uint32); - void SendLogXPGain(uint32 GivenXP,Unit* victim,uint32 RestXP); - - //Low Level Packets - void PlaySound(uint32 Sound, bool OnlySelf); - //notifiers - void SendAttackSwingCantAttack(); - void SendAttackSwingCancelAttack(); - void SendAttackSwingDeadTarget(); - void SendAttackSwingNotStanding(); - void SendAttackSwingNotInRange(); - void SendAttackSwingBadFacingAttack(); - void SendAutoRepeatCancel(); - void SendExplorationExperience(uint32 Area, uint32 Experience); - - void SendDungeonDifficulty(bool IsInGroup); - void ResetInstances(uint8 method); - void SendResetInstanceSuccess(uint32 MapId); - void SendResetInstanceFailed(uint32 reason, uint32 MapId); - void SendResetFailedNotify(uint32 mapid); - - bool SetPosition(float x, float y, float z, float orientation, bool teleport = false); - void UpdateUnderwaterState( Map * m, float x, float y, float z ); - - void SendMessageToSet(WorldPacket *data, bool self);// overwrite Object::SendMessageToSet - void SendMessageToSetInRange(WorldPacket *data, float fist, bool self); - // overwrite Object::SendMessageToSetInRange - void SendMessageToSetInRange(WorldPacket *data, float dist, bool self, bool own_team_only); - - static void DeleteFromDB(uint64 playerguid, uint32 accountId, bool updateRealmChars = true); - - Corpse *GetCorpse() const; - void SpawnCorpseBones(); - void CreateCorpse(); - void KillPlayer(); - uint32 GetResurrectionSpellId(); - void ResurrectPlayer(float restore_percent, bool updateToWorld = true, bool applySickness = false); - void BuildPlayerRepop(); - void RepopAtGraveyard(); - - void DurabilityLossAll(double percent, bool inventory); - void DurabilityLoss(Item* item, double percent); - void DurabilityPointsLossAll(int32 points, bool inventory); - void DurabilityPointsLoss(Item* item, int32 points); - void DurabilityPointLossForEquipSlot(EquipmentSlots slot); - uint32 DurabilityRepairAll(bool cost, float discountMod, bool guildBank); - uint32 DurabilityRepair(uint16 pos, bool cost, float discountMod, bool guildBank); - - void StopMirrorTimers() - { - StopMirrorTimer(FATIGUE_TIMER); - StopMirrorTimer(BREATH_TIMER); - StopMirrorTimer(FIRE_TIMER); - } - - void SetMovement(PlayerMovementType pType); - - void JoinedChannel(Channel *c); - void LeftChannel(Channel *c); - void CleanupChannels(); - void UpdateLocalChannels( uint32 newZone ); - void LeaveLFGChannel(); - - void UpdateDefense(); - void UpdateWeaponSkill (WeaponAttackType attType); - void UpdateCombatSkills(Unit *pVictim, WeaponAttackType attType, MeleeHitOutcome outcome, bool defence); - - void SetSkill(uint32 id, uint16 currVal, uint16 maxVal); - uint16 GetMaxSkillValue(uint32 skill) const; // max + perm. bonus - uint16 GetPureMaxSkillValue(uint32 skill) const; // max - uint16 GetSkillValue(uint32 skill) const; // skill value + perm. bonus + temp bonus - uint16 GetBaseSkillValue(uint32 skill) const; // skill value + perm. bonus - uint16 GetPureSkillValue(uint32 skill) const; // skill value - int16 GetSkillTempBonusValue(uint32 skill) const; - bool HasSkill(uint32 skill) const; - void learnSkillRewardedSpells( uint32 id ); - void learnSkillRewardedSpells(); - - void SetDontMove(bool dontMove); - bool GetDontMove() const { return m_dontMove; } - - void CheckExploreSystem(void); - - static uint32 TeamForRace(uint8 race); - uint32 GetTeam() const { return m_team; } - static uint32 getFactionForRace(uint8 race); - void setFactionForRace(uint8 race); - - bool IsAtGroupRewardDistance(WorldObject const* pRewardSource) const; - bool RewardPlayerAndGroupAtKill(Unit* pVictim); - - FactionStateList m_factions; - ForcedReactions m_forcedReactions; - uint32 GetDefaultReputationFlags(const FactionEntry *factionEntry) const; - int32 GetBaseReputation(const FactionEntry *factionEntry) const; - int32 GetReputation(uint32 faction_id) const; - int32 GetReputation(const FactionEntry *factionEntry) const; - ReputationRank GetReputationRank(uint32 faction) const; - ReputationRank GetReputationRank(const FactionEntry *factionEntry) const; - ReputationRank GetBaseReputationRank(const FactionEntry *factionEntry) const; - ReputationRank ReputationToRank(int32 standing) const; - const static int32 ReputationRank_Length[MAX_REPUTATION_RANK]; - const static int32 Reputation_Cap = 42999; - const static int32 Reputation_Bottom = -42000; - bool ModifyFactionReputation(uint32 FactionTemplateId, int32 DeltaReputation); - bool ModifyFactionReputation(FactionEntry const* factionEntry, int32 standing); - bool ModifyOneFactionReputation(FactionEntry const* factionEntry, int32 standing); - bool SetFactionReputation(uint32 FactionTemplateId, int32 standing); - bool SetFactionReputation(FactionEntry const* factionEntry, int32 standing); - bool SetOneFactionReputation(FactionEntry const* factionEntry, int32 standing); - int32 CalculateReputationGain(uint32 creatureOrQuestLevel, int32 rep, bool for_quest); - void RewardReputation(Unit *pVictim, float rate); - void RewardReputation(Quest const *pQuest); - void SetInitialFactions(); - void UpdateReputation() const; - void SendFactionState(FactionState const* faction) const; - void SendInitialReputations(); - FactionState const* GetFactionState( FactionEntry const* factionEntry) const; - void SetFactionAtWar(FactionState* faction, bool atWar); - void SetFactionInactive(FactionState* faction, bool inactive); - void SetFactionVisible(FactionState* faction); - void SetFactionVisibleForFactionTemplateId(uint32 FactionTemplateId); - void SetFactionVisibleForFactionId(uint32 FactionId); - void UpdateMaxSkills(); - void UpdateSkillsToMaxSkillsForLevel(); // for .levelup - void ModifySkillBonus(uint32 skillid,int32 val, bool talent); - - /*********************************************************/ - /*** PVP SYSTEM ***/ - /*********************************************************/ - void UpdateArenaFields(); - void UpdateHonorFields(); - bool RewardHonor(Unit *pVictim, uint32 groupsize, float honor = -1); - uint32 GetHonorPoints() { return GetUInt32Value(PLAYER_FIELD_HONOR_CURRENCY); } - uint32 GetArenaPoints() { return GetUInt32Value(PLAYER_FIELD_ARENA_CURRENCY); } - void ModifyHonorPoints( int32 value ); - void ModifyArenaPoints( int32 value ); - uint32 GetMaxPersonalArenaRatingRequirement(); - - //End of PvP System - - void SetDrunkValue(uint16 newDrunkValue, uint32 itemid=0); - uint16 GetDrunkValue() const { return m_drunk; } - static DrunkenState GetDrunkenstateByValue(uint16 value); - - uint32 GetDeathTimer() const { return m_deathTimer; } - uint32 GetCorpseReclaimDelay(bool pvp) const; - void UpdateCorpseReclaimDelay(); - void SendCorpseReclaimDelay(bool load = false); - - uint32 GetShieldBlockValue() const; // overwrite Unit version (virtual) - bool CanParry() const { return m_canParry; } - void SetCanParry(bool value) { m_canParry = value; } - bool CanDualWield() const { return m_canDualWield; } - void SetCanDualWield(bool value) { m_canDualWield = value; } - - void SetRegularAttackTime(); - void SetBaseModValue(BaseModGroup modGroup, BaseModType modType, float value) { m_auraBaseMod[modGroup][modType] = value; } - void HandleBaseModValue(BaseModGroup modGroup, BaseModType modType, float amount, bool apply, bool affectStats = true); - float GetBaseModValue(BaseModGroup modGroup, BaseModType modType) const; - float GetTotalBaseModValue(BaseModGroup modGroup) const; - float GetTotalPercentageModValue(BaseModGroup modGroup) const { return m_auraBaseMod[modGroup][FLAT_MOD] + m_auraBaseMod[modGroup][PCT_MOD]; } - void _ApplyAllStatBonuses(); - void _RemoveAllStatBonuses(); - - void _ApplyWeaponDependentAuraMods(Item *item,WeaponAttackType attackType,bool apply); - void _ApplyWeaponDependentAuraCritMod(Item *item, WeaponAttackType attackType, Aura* aura, bool apply); - void _ApplyWeaponDependentAuraDamageMod(Item *item, WeaponAttackType attackType, Aura* aura, bool apply); - - void _ApplyItemMods(Item *item,uint8 slot,bool apply); - void _RemoveAllItemMods(); - void _ApplyAllItemMods(); - void _ApplyItemBonuses(ItemPrototype const *proto,uint8 slot,bool apply); - void _ApplyAmmoBonuses(); - bool EnchantmentFitsRequirements(uint32 enchantmentcondition, int8 slot); - void ToggleMetaGemsActive(uint8 exceptslot, bool apply); - void CorrectMetaGemEnchants(uint8 slot, bool apply); - void InitDataForForm(bool reapplyMods = false); - - void ApplyItemEquipSpell(Item *item, bool apply, bool form_change = false); - void ApplyEquipSpell(SpellEntry const* spellInfo, Item* item, bool apply, bool form_change = false); - void UpdateEquipSpellsAtFormChange(); - void CastItemCombatSpell(Item *item,Unit* Target, WeaponAttackType attType); - - void SendInitWorldStates(); - void SendUpdateWorldState(uint32 Field, uint32 Value); - void SendDirectMessage(WorldPacket *data); - - void SendAuraDurationsForTarget(Unit* target); - - PlayerMenu* PlayerTalkClass; - std::vector ItemSetEff; - - void SendLoot(uint64 guid, LootType loot_type); - void SendLootRelease( uint64 guid ); - void SendNotifyLootItemRemoved(uint8 lootSlot); - void SendNotifyLootMoneyRemoved(); - - /*********************************************************/ - /*** BATTLEGROUND SYSTEM ***/ - /*********************************************************/ - - bool InBattleGround() const { return m_bgBattleGroundID != 0; } - uint32 GetBattleGroundId() const { return m_bgBattleGroundID; } - BattleGround* GetBattleGround() const; - bool InArena() const; - - static uint32 GetMinLevelForBattleGroundQueueId(uint32 queue_id); - static uint32 GetMaxLevelForBattleGroundQueueId(uint32 queue_id); - uint32 GetBattleGroundQueueIdFromLevel() const; - - uint32 GetBattleGroundQueueId(uint32 index) const { return m_bgBattleGroundQueueID[index].bgType; } - uint32 GetBattleGroundQueueIndex(uint32 bgType) const - { - for (int i=0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; i++) - if (m_bgBattleGroundQueueID[i].bgType == bgType) - return i; - return PLAYER_MAX_BATTLEGROUND_QUEUES; - } - bool IsInvitedForBattleGroundType(uint32 bgType) const - { - for (int i=0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; i++) - if (m_bgBattleGroundQueueID[i].bgType == bgType) - return m_bgBattleGroundQueueID[i].invited; - return PLAYER_MAX_BATTLEGROUND_QUEUES; - } - bool InBattleGroundQueueForBattleGroundType(uint32 bgType) const - { - return GetBattleGroundQueueIndex(bgType) < PLAYER_MAX_BATTLEGROUND_QUEUES; - } - - void SetBattleGroundId(uint32 val) { m_bgBattleGroundID = val; } - uint32 AddBattleGroundQueueId(uint32 val) - { - for (int i=0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; i++) - { - if (m_bgBattleGroundQueueID[i].bgType == 0 || m_bgBattleGroundQueueID[i].bgType == val) - { - m_bgBattleGroundQueueID[i].bgType = val; - m_bgBattleGroundQueueID[i].invited = false; - return i; - } - } - return PLAYER_MAX_BATTLEGROUND_QUEUES; - } - void RemoveBattleGroundQueueId(uint32 val) - { - for (int i=0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; i++) - { - if (m_bgBattleGroundQueueID[i].bgType == val) - { - m_bgBattleGroundQueueID[i].bgType = 0; - m_bgBattleGroundQueueID[i].invited = false; - return; - } - } - } - void SetInviteForBattleGroundType(uint32 bgType) - { - for (int i=0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; i++) - if (m_bgBattleGroundQueueID[i].bgType == bgType) - m_bgBattleGroundQueueID[i].invited = true; - } - - uint32 GetBattleGroundEntryPointMap() const { return m_bgEntryPointMap; } - float GetBattleGroundEntryPointX() const { return m_bgEntryPointX; } - float GetBattleGroundEntryPointY() const { return m_bgEntryPointY; } - float GetBattleGroundEntryPointZ() const { return m_bgEntryPointZ; } - float GetBattleGroundEntryPointO() const { return m_bgEntryPointO; } - void SetBattleGroundEntryPoint(uint32 Map, float PosX, float PosY, float PosZ, float PosO ) - { - m_bgEntryPointMap = Map; - m_bgEntryPointX = PosX; - m_bgEntryPointY = PosY; - m_bgEntryPointZ = PosZ; - m_bgEntryPointO = PosO; - } - - void SetBGTeam(uint32 team) { m_bgTeam = team; } - uint32 GetBGTeam() const { return m_bgTeam ? m_bgTeam : GetTeam(); } - - void LeaveBattleground(bool teleportToEntryPoint = true); - bool CanJoinToBattleground() const; - bool CanReportAfkDueToLimit(); - void ReportedAfkBy(Player* reporter); - void ClearAfkReports() { m_bgAfkReporter.clear(); } - - bool GetBGAccessByLevel(uint32 bgTypeId) const; - - /*********************************************************/ - /*** REST SYSTEM ***/ - /*********************************************************/ - - bool isRested() const { return GetRestTime() >= 10000; } - uint32 GetXPRestBonus(uint32 xp); - uint32 GetRestTime() const { return m_restTime;}; - void SetRestTime(uint32 v) { m_restTime = v;}; - - /*********************************************************/ - /*** ENVIROMENTAL SYSTEM ***/ - /*********************************************************/ - - void EnvironmentalDamage(uint64 guid, EnviromentalDamage type, uint32 damage); - - /*********************************************************/ - /*** FLOOD FILTER SYSTEM ***/ - /*********************************************************/ - - void UpdateSpeakTime(); - bool CanSpeak() const; - void ChangeSpeakTime(int utime); - - /*********************************************************/ - /*** VARIOUS SYSTEMS ***/ - /*********************************************************/ - MovementInfo m_movementInfo; - bool isMoving() const { return HasUnitMovementFlag(movementFlagsMask); } - bool isMovingOrTurning() const { return HasUnitMovementFlag(movementOrTurningFlagsMask); } - - bool CanFly() const { return HasUnitMovementFlag(MOVEMENTFLAG_CAN_FLY); } - bool IsFlying() const { return HasUnitMovementFlag(MOVEMENTFLAG_FLYING); } - - void HandleDrowning(); - - void SetClientControl(Unit* target, uint8 allowMove); - - // Transports - Transport * GetTransport() const { return m_transport; } - void SetTransport(Transport * t) { m_transport = t; } - - float GetTransOffsetX() const { return m_movementInfo.t_x; } - float GetTransOffsetY() const { return m_movementInfo.t_y; } - float GetTransOffsetZ() const { return m_movementInfo.t_z; } - float GetTransOffsetO() const { return m_movementInfo.t_o; } - uint32 GetTransTime() const { return m_movementInfo.t_time; } - - uint32 GetSaveTimer() const { return m_nextSave; } - void SetSaveTimer(uint32 timer) { m_nextSave = timer; } - - // Recall position - uint32 m_recallMap; - float m_recallX; - float m_recallY; - float m_recallZ; - float m_recallO; - void SaveRecallPosition(); - - // Homebind coordinates - uint32 m_homebindMapId; - uint16 m_homebindZoneId; - float m_homebindX; - float m_homebindY; - float m_homebindZ; - - // currently visible objects at player client - typedef std::set ClientGUIDs; - ClientGUIDs m_clientGUIDs; - - bool HaveAtClient(WorldObject const* u) { return u==this || m_clientGUIDs.find(u->GetGUID())!=m_clientGUIDs.end(); } - - bool IsVisibleInGridForPlayer(Player* pl) const; - bool IsVisibleGloballyFor(Player* pl) const; - - void UpdateVisibilityOf(WorldObject* target); - - template - void UpdateVisibilityOf(T* target, UpdateData& data, UpdateDataMapType& data_updates, std::set& visibleNow); - - // Stealth detection system - uint32 m_DetectInvTimer; - void HandleStealthedUnitsDetection(); - - uint8 m_forced_speed_changes[MAX_MOVE_TYPE]; - - bool HasAtLoginFlag(AtLoginFlags f) const { return m_atLoginFlags & f; } - void SetAtLoginFlag(AtLoginFlags f) { m_atLoginFlags |= f; } - - LookingForGroup m_lookingForGroup; - - // Temporarily removed pet cache - uint32 GetTemporaryUnsummonedPetNumber() const { return m_temporaryUnsummonedPetNumber; } - void SetTemporaryUnsummonedPetNumber(uint32 petnumber) { m_temporaryUnsummonedPetNumber = petnumber; } - uint32 GetOldPetSpell() const { return m_oldpetspell; } - void SetOldPetSpell(uint32 petspell) { m_oldpetspell = petspell; } - - /*********************************************************/ - /*** INSTANCE SYSTEM ***/ - /*********************************************************/ - - typedef HM_NAMESPACE::hash_map< uint32 /*mapId*/, InstancePlayerBind > BoundInstancesMap; - - void UpdateHomebindTime(uint32 time); - - uint32 m_HomebindTimer; - bool m_InstanceValid; - // permanent binds and solo binds by difficulty - BoundInstancesMap m_boundInstances[TOTAL_DIFFICULTIES]; - InstancePlayerBind* GetBoundInstance(uint32 mapid, uint8 difficulty); - BoundInstancesMap& GetBoundInstances(uint8 difficulty) { return m_boundInstances[difficulty]; } - void UnbindInstance(uint32 mapid, uint8 difficulty, bool unload = false); - void UnbindInstance(BoundInstancesMap::iterator &itr, uint8 difficulty, bool unload = false); - InstancePlayerBind* BindToInstance(InstanceSave *save, bool permanent, bool load = false); - void SendRaidInfo(); - void SendSavedInstances(); - static void ConvertInstancesToGroup(Player *player, Group *group = NULL, uint64 player_guid = 0); - - /*********************************************************/ - /*** GROUP SYSTEM ***/ - /*********************************************************/ - - Group * GetGroupInvite() { return m_groupInvite; } - void SetGroupInvite(Group *group) { m_groupInvite = group; } - Group * GetGroup() { return m_group.getTarget(); } - const Group * GetGroup() const { return (const Group*)m_group.getTarget(); } - GroupReference& GetGroupRef() { return m_group; } - void SetGroup(Group *group, int8 subgroup = -1); - uint8 GetSubGroup() const { return m_group.getSubGroup(); } - uint32 GetGroupUpdateFlag() { return m_groupUpdateMask; } - void SetGroupUpdateFlag(uint32 flag) { m_groupUpdateMask |= flag; } - uint64 GetAuraUpdateMask() { return m_auraUpdateMask; } - void SetAuraUpdateMask(uint8 slot) { m_auraUpdateMask |= (uint64(1) << slot); } - Player* GetNextRandomRaidMember(float radius); - - GridReference &GetGridRef() { return m_gridRef; } - bool isAllowedToLoot(Creature* creature); - - WorldLocation& GetTeleportDest() { return m_teleport_dest; } - - DeclinedName const* GetDeclinedNames() const { return m_declinedname; } - - protected: - - /*********************************************************/ - /*** BATTLEGROUND SYSTEM ***/ - /*********************************************************/ - - /* this variable is set to bg->m_InstanceID, when player is teleported to BG - (it is battleground's GUID)*/ - uint32 m_bgBattleGroundID; - /* - this is an array of BG queues (BgTypeIDs) in which is player - */ - struct BgBattleGroundQueueID_Rec - { - uint32 bgType; - bool invited; - }; - BgBattleGroundQueueID_Rec m_bgBattleGroundQueueID[PLAYER_MAX_BATTLEGROUND_QUEUES]; - uint32 m_bgEntryPointMap; - float m_bgEntryPointX; - float m_bgEntryPointY; - float m_bgEntryPointZ; - float m_bgEntryPointO; - - std::set m_bgAfkReporter; - uint8 m_bgAfkReportedCount; - time_t m_bgAfkReportedTimer; - uint32 m_contestedPvPTimer; - - uint32 m_bgTeam; // what side the player will be added to - - /*********************************************************/ - /*** QUEST SYSTEM ***/ - /*********************************************************/ - - std::set m_timedquests; - - uint64 m_divider; - uint32 m_ingametime; - - /*********************************************************/ - /*** LOAD SYSTEM ***/ - /*********************************************************/ - - void _LoadActions(QueryResult *result); - void _LoadAuras(QueryResult *result, uint32 timediff); - void _LoadBoundInstances(QueryResult *result); - void _LoadInventory(QueryResult *result, uint32 timediff); - void _LoadMailInit(QueryResult *resultUnread, QueryResult *resultDelivery); - void _LoadMail(); - void _LoadMailedItems(Mail *mail); - void _LoadQuestStatus(QueryResult *result); - void _LoadDailyQuestStatus(QueryResult *result); - void _LoadGroup(QueryResult *result); - void _LoadReputation(QueryResult *result); - void _LoadSpells(QueryResult *result); - void _LoadTutorials(QueryResult *result); - void _LoadFriendList(QueryResult *result); - bool _LoadHomeBind(QueryResult *result); - void _LoadDeclinedNames(QueryResult *result); - - /*********************************************************/ - /*** SAVE SYSTEM ***/ - /*********************************************************/ - - void _SaveActions(); - void _SaveAuras(); - void _SaveInventory(); - void _SaveMail(); - void _SaveQuestStatus(); - void _SaveDailyQuestStatus(); - void _SaveReputation(); - void _SaveSpells(); - void _SaveTutorials(); - - void _SetCreateBits(UpdateMask *updateMask, Player *target) const; - void _SetUpdateBits(UpdateMask *updateMask, Player *target) const; - - /*********************************************************/ - /*** ENVIRONMENTAL SYSTEM ***/ - /*********************************************************/ - void HandleLava(); - void HandleSobering(); - void StartMirrorTimer(MirrorTimerType Type, uint32 MaxValue); - void ModifyMirrorTimer(MirrorTimerType Type, uint32 MaxValue, uint32 CurrentValue, uint32 Regen); - void StopMirrorTimer(MirrorTimerType Type); - uint8 m_isunderwater; - bool m_isInWater; - - /*********************************************************/ - /*** HONOR SYSTEM ***/ - /*********************************************************/ - time_t m_lastHonorUpdateTime; - - void outDebugValues() const; - bool _removeSpell(uint16 spell_id); - uint64 m_lootGuid; - - uint32 m_race; - uint32 m_class; - uint32 m_team; - uint32 m_nextSave; - time_t m_speakTime; - uint32 m_speakCount; - uint32 m_dungeonDifficulty; - - uint32 m_atLoginFlags; - - Item* m_items[PLAYER_SLOTS_COUNT]; - uint32 m_currentBuybackSlot; - - std::vector m_itemUpdateQueue; - bool m_itemUpdateQueueBlocked; - - uint32 m_ExtraFlags; - uint64 m_curSelection; - - uint64 m_comboTarget; - int8 m_comboPoints; - - QuestStatusMap mQuestStatus; - - uint32 m_GuildIdInvited; - uint32 m_ArenaTeamIdInvited; - - PlayerMails m_mail; - PlayerSpellMap m_spells; - SpellCooldowns m_spellCooldowns; - - ActionButtonList m_actionButtons; - - float m_auraBaseMod[BASEMOD_END][MOD_END]; - - SpellModList m_spellMods[MAX_SPELLMOD]; - int32 m_SpellModRemoveCount; - EnchantDurationList m_enchantDuration; - ItemDurationList m_itemDuration; - - uint64 m_resurrectGUID; - uint32 m_resurrectMap; - float m_resurrectX, m_resurrectY, m_resurrectZ; - uint32 m_resurrectHealth, m_resurrectMana; - - WorldSession *m_session; - - typedef std::list JoinedChannelsList; - JoinedChannelsList m_channels; - - bool m_dontMove; - - int m_cinematic; - - Player *pTrader; - bool acceptTrade; - uint16 tradeItems[TRADE_SLOT_COUNT]; - uint32 tradeGold; - - time_t m_nextThinkTime; - - uint32 m_Tutorials[8]; - bool m_TutorialsChanged; - - bool m_DailyQuestChanged; - time_t m_lastDailyQuestTime; - - uint32 m_regenTimer; - uint32 m_breathTimer; - uint32 m_drunkTimer; - uint16 m_drunk; - uint32 m_weaponChangeTimer; - - uint32 m_zoneUpdateId; - uint32 m_zoneUpdateTimer; - uint32 m_areaUpdateId; - - uint32 m_deathTimer; - time_t m_deathExpireTime; - - uint32 m_restTime; - - uint32 m_WeaponProficiency; - uint32 m_ArmorProficiency; - bool m_canParry; - bool m_canDualWield; - uint8 m_swingErrorMsg; - float m_ammoDPS; - ////////////////////Rest System///////////////////// - int time_inn_enter; - uint32 inn_pos_mapid; - float inn_pos_x; - float inn_pos_y; - float inn_pos_z; - float m_rest_bonus; - RestType rest_type; - ////////////////////Rest System///////////////////// - - // Transports - Transport * m_transport; - - uint32 m_resetTalentsCost; - time_t m_resetTalentsTime; - uint32 m_usedTalentCount; - - // Social - PlayerSocial *m_social; - - // Groups - GroupReference m_group; - Group *m_groupInvite; - uint32 m_groupUpdateMask; - uint64 m_auraUpdateMask; - - // Temporarily removed pet cache - uint32 m_temporaryUnsummonedPetNumber; - uint32 m_oldpetspell; - - uint64 m_miniPet; - GuardianPetList m_guardianPets; - - // Player summoning - time_t m_summon_expire; - uint32 m_summon_mapid; - float m_summon_x; - float m_summon_y; - float m_summon_z; - - // Far Teleport - WorldLocation m_teleport_dest; - - DeclinedName *m_declinedname; - private: - // internal common parts for CanStore/StoreItem functions - uint8 _CanStoreItem_InSpecificSlot( uint8 bag, uint8 slot, ItemPosCountVec& dest, ItemPrototype const *pProto, uint32& count, bool swap, Item *pSrcItem ) const; - uint8 _CanStoreItem_InBag( uint8 bag, ItemPosCountVec& dest, ItemPrototype const *pProto, uint32& count, bool merge, bool non_specialized, Item *pSrcItem, uint8 skip_bag, uint8 skip_slot ) const; - uint8 _CanStoreItem_InInventorySlots( uint8 slot_begin, uint8 slot_end, ItemPosCountVec& dest, ItemPrototype const *pProto, uint32& count, bool merge, Item *pSrcItem, uint8 skip_bag, uint8 skip_slot ) const; - Item* _StoreItem( uint16 pos, Item *pItem, uint32 count, bool clone, bool update ); - - GridReference m_gridRef; -}; - -void AddItemsSetItem(Player*player,Item *item); -void RemoveItemsSetItem(Player*player,ItemPrototype const *proto); - -// "the bodies of template functions must be made available in a header file" -template T Player::ApplySpellMod(uint32 spellId, SpellModOp op, T &basevalue, Spell const* spell) -{ - SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellId); - if (!spellInfo) return 0; - int32 totalpct = 0; - int32 totalflat = 0; - for (SpellModList::iterator itr = m_spellMods[op].begin(); itr != m_spellMods[op].end(); ++itr) - { - SpellModifier *mod = *itr; - - if(!IsAffectedBySpellmod(spellInfo,mod,spell)) - continue; - if (mod->type == SPELLMOD_FLAT) - totalflat += mod->value; - else if (mod->type == SPELLMOD_PCT) - { - // skip percent mods for null basevalue (most important for spell mods with charges ) - if(basevalue == T(0)) - continue; - - // special case (skip >10sec spell casts for instant cast setting) - if( mod->op==SPELLMOD_CASTING_TIME && basevalue >= T(10000) && mod->value <= -100) - continue; - - totalpct += mod->value; - } - - if (mod->charges > 0 ) - { - --mod->charges; - if (mod->charges == 0) - { - mod->charges = -1; - mod->lastAffected = spell; - if(!mod->lastAffected) - mod->lastAffected = FindCurrentSpellBySpellId(spellId); - ++m_SpellModRemoveCount; - } - } - } - - float diff = (float)basevalue*(float)totalpct/100.0f + (float)totalflat; - basevalue = T((float)basevalue + diff); - return T(diff); -} -#endif +/* + * Copyright (C) 2005-2008 MaNGOS + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef _PLAYER_H +#define _PLAYER_H + +#include "Common.h" +#include "ItemPrototype.h" +#include "Unit.h" +#include "Item.h" + +#include "Database/DatabaseEnv.h" +#include "NPCHandler.h" +#include "QuestDef.h" +#include "Group.h" +#include "Bag.h" +#include "WorldSession.h" +#include "Pet.h" +#include "Util.h" // for Tokens typedef + +#include +#include + +struct Mail; +class Channel; +class DynamicObject; +class Creature; +class Pet; +class PlayerMenu; +class Transport; +class UpdateMask; +class PlayerSocial; + +typedef std::deque PlayerMails; + +#define PLAYER_MAX_SKILLS 127 +#define PLAYER_MAX_DAILY_QUESTS 25 + +// Note: SPELLMOD_* values is aura types in fact +enum SpellModType +{ + SPELLMOD_FLAT = 107, // SPELL_AURA_ADD_FLAT_MODIFIER + SPELLMOD_PCT = 108 // SPELL_AURA_ADD_PCT_MODIFIER +}; + +enum PlayerSpellState +{ + PLAYERSPELL_UNCHANGED = 0, + PLAYERSPELL_CHANGED = 1, + PLAYERSPELL_NEW = 2, + PLAYERSPELL_REMOVED = 3 +}; + +struct PlayerSpell +{ + uint16 slotId : 16; + PlayerSpellState state : 8; + bool active : 1; + bool disabled : 1; +}; + +#define SPELL_WITHOUT_SLOT_ID uint16(-1) + +struct SpellModifier +{ + SpellModOp op : 8; + SpellModType type : 8; + int16 charges : 16; + int32 value; + uint64 mask; + uint32 spellId; + uint32 effectId; + Spell const* lastAffected; +}; + +typedef HM_NAMESPACE::hash_map PlayerSpellMap; +typedef std::list SpellModList; + +struct SpellCooldown +{ + time_t end; + uint16 itemid; +}; + +typedef std::map SpellCooldowns; + +enum TrainerSpellState +{ + TRAINER_SPELL_GREEN = 0, + TRAINER_SPELL_RED = 1, + TRAINER_SPELL_GRAY = 2 +}; + +enum ActionButtonUpdateState +{ + ACTIONBUTTON_UNCHANGED = 0, + ACTIONBUTTON_CHANGED = 1, + ACTIONBUTTON_NEW = 2, + ACTIONBUTTON_DELETED = 3 +}; + +struct ActionButton +{ + ActionButton() : action(0), type(0), misc(0), uState( ACTIONBUTTON_NEW ) {} + ActionButton(uint16 _action, uint8 _type, uint8 _misc) : action(_action), type(_type), misc(_misc), uState( ACTIONBUTTON_NEW ) {} + + uint16 action; + uint8 type; + uint8 misc; + ActionButtonUpdateState uState; +}; + +enum ActionButtonType +{ + ACTION_BUTTON_SPELL = 0, + ACTION_BUTTON_MACRO = 64, + ACTION_BUTTON_CMACRO= 65, + ACTION_BUTTON_ITEM = 128 +}; + +#define MAX_ACTION_BUTTONS 132 //checked in 2.3.0 + +typedef std::map ActionButtonList; + +typedef std::pair CreateSpellPair; + +struct PlayerCreateInfoItem +{ + PlayerCreateInfoItem(uint32 id, uint32 amount) : item_id(id), item_amount(amount) {} + + uint32 item_id; + uint32 item_amount; +}; + +typedef std::list PlayerCreateInfoItems; + +struct PlayerClassLevelInfo +{ + PlayerClassLevelInfo() : basehealth(0), basemana(0) {} + uint16 basehealth; + uint16 basemana; +}; + +struct PlayerClassInfo +{ + PlayerClassInfo() : levelInfo(NULL) { } + + PlayerClassLevelInfo* levelInfo; //[level-1] 0..MaxPlayerLevel-1 +}; + +struct PlayerLevelInfo +{ + PlayerLevelInfo() { for(int i=0; i < MAX_STATS; ++i ) stats[i] = 0; } + + uint8 stats[MAX_STATS]; +}; + +struct PlayerInfo +{ + // existence checked by displayId != 0 // existence checked by displayId != 0 + PlayerInfo() : displayId_m(0),displayId_f(0),levelInfo(NULL) + { + } + + uint32 mapId; + uint32 zoneId; + float positionX; + float positionY; + float positionZ; + uint16 displayId_m; + uint16 displayId_f; + PlayerCreateInfoItems item; + std::list spell; + std::list action[4]; + + PlayerLevelInfo* levelInfo; //[level-1] 0..MaxPlayerLevel-1 +}; + +struct PvPInfo +{ + PvPInfo() : inHostileArea(false), endTimer(0) {} + + bool inHostileArea; + time_t endTimer; +}; + +struct DuelInfo +{ + DuelInfo() : initiator(NULL), opponent(NULL), startTimer(0), startTime(0), outOfBound(0) {} + + Player *initiator; + Player *opponent; + time_t startTimer; + time_t startTime; + time_t outOfBound; +}; + +struct Areas +{ + uint32 areaID; + uint32 areaFlag; + float x1; + float x2; + float y1; + float y2; +}; + +enum FactionFlags +{ + FACTION_FLAG_VISIBLE = 0x01, // makes visible in client (set or can be set at interaction with target of this faction) + FACTION_FLAG_AT_WAR = 0x02, // enable AtWar-button in client. player controlled (except opposition team always war state), Flag only set on initial creation + FACTION_FLAG_HIDDEN = 0x04, // hidden faction from reputation pane in client (player can gain reputation, but this update not sent to client) + FACTION_FLAG_INVISIBLE_FORCED = 0x08, // always overwrite FACTION_FLAG_VISIBLE and hide faction in rep.list, used for hide opposite team factions + FACTION_FLAG_PEACE_FORCED = 0x10, // always overwrite FACTION_FLAG_AT_WAR, used for prevent war with own team factions + FACTION_FLAG_INACTIVE = 0x20, // player controlled, state stored in characters.data ( CMSG_SET_FACTION_INACTIVE ) + FACTION_FLAG_RIVAL = 0x40 // flag for the two competing outland factions +}; + +typedef uint32 RepListID; +struct FactionState +{ + uint32 ID; + RepListID ReputationListID; + uint32 Flags; + int32 Standing; + bool Changed; +}; + +typedef std::map FactionStateList; + +typedef std::map ForcedReactions; + +typedef std::set GuardianPetList; + +struct EnchantDuration +{ + EnchantDuration() : item(NULL), slot(MAX_ENCHANTMENT_SLOT), leftduration(0) {}; + EnchantDuration(Item * _item, EnchantmentSlot _slot, uint32 _leftduration) : item(_item), slot(_slot), leftduration(_leftduration) { assert(item); }; + + Item * item; + EnchantmentSlot slot; + uint32 leftduration; +}; + +typedef std::list EnchantDurationList; +typedef std::list ItemDurationList; + +struct LookingForGroupSlot +{ + LookingForGroupSlot() : entry(0), type(0) {} + bool Empty() const { return !entry && !type; } + void Clear() { entry = 0; type = 0; } + void Set(uint32 _entry, uint32 _type ) { entry = _entry; type = _type; } + bool Is(uint32 _entry, uint32 _type) const { return entry==_entry && type==_type; } + bool canAutoJoin() const { return entry && (type == 1 || type == 5); } + + uint32 entry; + uint32 type; +}; + +#define MAX_LOOKING_FOR_GROUP_SLOT 3 + +struct LookingForGroup +{ + LookingForGroup() {} + bool HaveInSlot(LookingForGroupSlot const& slot) const { return HaveInSlot(slot.entry,slot.type); } + bool HaveInSlot(uint32 _entry, uint32 _type) const + { + for(int i = 0; i < MAX_LOOKING_FOR_GROUP_SLOT; ++i) + if(slots[i].Is(_entry,_type)) + return true; + return false; + } + + bool canAutoJoin() const + { + for(int i = 0; i < MAX_LOOKING_FOR_GROUP_SLOT; ++i) + if(slots[i].canAutoJoin()) + return true; + return false; + } + + bool Empty() const + { + for(int i = 0; i < MAX_LOOKING_FOR_GROUP_SLOT; ++i) + if(!slots[i].Empty()) + return false; + return more.Empty(); + } + + LookingForGroupSlot slots[MAX_LOOKING_FOR_GROUP_SLOT]; + LookingForGroupSlot more; + std::string comment; +}; + +enum PlayerMovementType +{ + MOVE_ROOT = 1, + MOVE_UNROOT = 2, + MOVE_WATER_WALK = 3, + MOVE_LAND_WALK = 4 +}; + +enum DrunkenState +{ + DRUNKEN_SOBER = 0, + DRUNKEN_TIPSY = 1, + DRUNKEN_DRUNK = 2, + DRUNKEN_SMASHED = 3 +}; + +enum PlayerStateType +{ + /* + PLAYER_STATE_DANCE + PLAYER_STATE_SLEEP + PLAYER_STATE_SIT + PLAYER_STATE_STAND + PLAYER_STATE_READYUNARMED + PLAYER_STATE_WORK + PLAYER_STATE_POINT(DNR) + PLAYER_STATE_NONE // not used or just no state, just standing there? + PLAYER_STATE_STUN + PLAYER_STATE_DEAD + PLAYER_STATE_KNEEL + PLAYER_STATE_USESTANDING + PLAYER_STATE_STUN_NOSHEATHE + PLAYER_STATE_USESTANDING_NOSHEATHE + PLAYER_STATE_WORK_NOSHEATHE + PLAYER_STATE_SPELLPRECAST + PLAYER_STATE_READYRIFLE + PLAYER_STATE_WORK_NOSHEATHE_MINING + PLAYER_STATE_WORK_NOSHEATHE_CHOPWOOD + PLAYER_STATE_AT_EASE + PLAYER_STATE_READY1H + PLAYER_STATE_SPELLKNEELSTART + PLAYER_STATE_SUBMERGED + */ + + PLAYER_STATE_NONE = 0, + PLAYER_STATE_SIT = 1, + PLAYER_STATE_SIT_CHAIR = 2, + PLAYER_STATE_SLEEP = 3, + PLAYER_STATE_SIT_LOW_CHAIR = 4, + PLAYER_STATE_SIT_MEDIUM_CHAIR = 5, + PLAYER_STATE_SIT_HIGH_CHAIR = 6, + PLAYER_STATE_DEAD = 7, + PLAYER_STATE_KNEEL = 8, + + PLAYER_STATE_FORM_ALL = 0x00FF0000, + + PLAYER_STATE_FLAG_ALWAYS_STAND = 0x01, // byte 4 + PLAYER_STATE_FLAG_CREEP = 0x02000000, + PLAYER_STATE_FLAG_UNTRACKABLE = 0x04000000, + PLAYER_STATE_FLAG_ALL = 0xFF000000, +}; + +enum PlayerFlags +{ + PLAYER_FLAGS_GROUP_LEADER = 0x00000001, + PLAYER_FLAGS_AFK = 0x00000002, + PLAYER_FLAGS_DND = 0x00000004, + PLAYER_FLAGS_GM = 0x00000008, + PLAYER_FLAGS_GHOST = 0x00000010, + PLAYER_FLAGS_RESTING = 0x00000020, + PLAYER_FLAGS_FFA_PVP = 0x00000080, + PLAYER_FLAGS_CONTESTED_PVP = 0x00000100, // Player has been involved in a PvP combat and will be attacked by contested guards + PLAYER_FLAGS_IN_PVP = 0x00000200, + PLAYER_FLAGS_HIDE_HELM = 0x00000400, + PLAYER_FLAGS_HIDE_CLOAK = 0x00000800, + PLAYER_FLAGS_UNK1 = 0x00001000, // played long time + PLAYER_FLAGS_UNK2 = 0x00002000, // played too long time + PLAYER_FLAGS_UNK3 = 0x00008000, // strange visual effect (2.0.1), looks like PLAYER_FLAGS_GHOST flag + PLAYER_FLAGS_SANCTUARY = 0x00010000, // player entered sanctuary + PLAYER_FLAGS_UNK4 = 0x00020000, // taxi benchmark mode (on/off) (2.0.1) + PLAYER_UNK = 0x00040000, // 2.0.8... +}; + +// used for PLAYER__FIELD_KNOWN_TITLES field (uint64), (1< QuestStatusMap; + +enum QuestSlotOffsets +{ + QUEST_ID_OFFSET = 0, + QUEST_STATE_OFFSET = 1, + QUEST_COUNTS_OFFSET = 2, + QUEST_TIME_OFFSET = 3 +}; + +#define MAX_QUEST_OFFSET 4 + +enum QuestSlotStateMask +{ + QUEST_STATE_NONE = 0x0000, + QUEST_STATE_COMPLETE = 0x0001, + QUEST_STATE_FAIL = 0x0002 +}; + +class Quest; +class Spell; +class Item; +class WorldSession; + +enum PlayerSlots +{ + // first slot for item stored (in any way in player m_items data) + PLAYER_SLOT_START = 0, + // last+1 slot for item stored (in any way in player m_items data) + PLAYER_SLOT_END = 118, + PLAYER_SLOTS_COUNT = (PLAYER_SLOT_END - PLAYER_SLOT_START) +}; + +enum EquipmentSlots +{ + EQUIPMENT_SLOT_START = 0, + EQUIPMENT_SLOT_HEAD = 0, + EQUIPMENT_SLOT_NECK = 1, + EQUIPMENT_SLOT_SHOULDERS = 2, + EQUIPMENT_SLOT_BODY = 3, + EQUIPMENT_SLOT_CHEST = 4, + EQUIPMENT_SLOT_WAIST = 5, + EQUIPMENT_SLOT_LEGS = 6, + EQUIPMENT_SLOT_FEET = 7, + EQUIPMENT_SLOT_WRISTS = 8, + EQUIPMENT_SLOT_HANDS = 9, + EQUIPMENT_SLOT_FINGER1 = 10, + EQUIPMENT_SLOT_FINGER2 = 11, + EQUIPMENT_SLOT_TRINKET1 = 12, + EQUIPMENT_SLOT_TRINKET2 = 13, + EQUIPMENT_SLOT_BACK = 14, + EQUIPMENT_SLOT_MAINHAND = 15, + EQUIPMENT_SLOT_OFFHAND = 16, + EQUIPMENT_SLOT_RANGED = 17, + EQUIPMENT_SLOT_TABARD = 18, + EQUIPMENT_SLOT_END = 19 +}; + +enum InventorySlots +{ + INVENTORY_SLOT_BAG_0 = 255, + INVENTORY_SLOT_BAG_START = 19, + INVENTORY_SLOT_BAG_1 = 19, + INVENTORY_SLOT_BAG_2 = 20, + INVENTORY_SLOT_BAG_3 = 21, + INVENTORY_SLOT_BAG_4 = 22, + INVENTORY_SLOT_BAG_END = 23, + + INVENTORY_SLOT_ITEM_START = 23, + INVENTORY_SLOT_ITEM_1 = 23, + INVENTORY_SLOT_ITEM_2 = 24, + INVENTORY_SLOT_ITEM_3 = 25, + INVENTORY_SLOT_ITEM_4 = 26, + INVENTORY_SLOT_ITEM_5 = 27, + INVENTORY_SLOT_ITEM_6 = 28, + INVENTORY_SLOT_ITEM_7 = 29, + INVENTORY_SLOT_ITEM_8 = 30, + INVENTORY_SLOT_ITEM_9 = 31, + INVENTORY_SLOT_ITEM_10 = 32, + INVENTORY_SLOT_ITEM_11 = 33, + INVENTORY_SLOT_ITEM_12 = 34, + INVENTORY_SLOT_ITEM_13 = 35, + INVENTORY_SLOT_ITEM_14 = 36, + INVENTORY_SLOT_ITEM_15 = 37, + INVENTORY_SLOT_ITEM_16 = 38, + INVENTORY_SLOT_ITEM_END = 39 +}; + +enum BankSlots +{ + BANK_SLOT_ITEM_START = 39, + BANK_SLOT_ITEM_1 = 39, + BANK_SLOT_ITEM_2 = 40, + BANK_SLOT_ITEM_3 = 41, + BANK_SLOT_ITEM_4 = 42, + BANK_SLOT_ITEM_5 = 43, + BANK_SLOT_ITEM_6 = 44, + BANK_SLOT_ITEM_7 = 45, + BANK_SLOT_ITEM_8 = 46, + BANK_SLOT_ITEM_9 = 47, + BANK_SLOT_ITEM_10 = 48, + BANK_SLOT_ITEM_11 = 49, + BANK_SLOT_ITEM_12 = 50, + BANK_SLOT_ITEM_13 = 51, + BANK_SLOT_ITEM_14 = 52, + BANK_SLOT_ITEM_15 = 53, + BANK_SLOT_ITEM_16 = 54, + BANK_SLOT_ITEM_17 = 55, + BANK_SLOT_ITEM_18 = 56, + BANK_SLOT_ITEM_19 = 57, + BANK_SLOT_ITEM_20 = 58, + BANK_SLOT_ITEM_21 = 59, + BANK_SLOT_ITEM_22 = 60, + BANK_SLOT_ITEM_23 = 61, + BANK_SLOT_ITEM_24 = 62, + BANK_SLOT_ITEM_25 = 63, + BANK_SLOT_ITEM_26 = 64, + BANK_SLOT_ITEM_27 = 65, + BANK_SLOT_ITEM_28 = 66, + BANK_SLOT_ITEM_END = 67, + + BANK_SLOT_BAG_START = 67, + BANK_SLOT_BAG_1 = 67, + BANK_SLOT_BAG_2 = 68, + BANK_SLOT_BAG_3 = 69, + BANK_SLOT_BAG_4 = 70, + BANK_SLOT_BAG_5 = 71, + BANK_SLOT_BAG_6 = 72, + BANK_SLOT_BAG_7 = 73, + BANK_SLOT_BAG_END = 74 +}; + +enum BuyBackSlots +{ + // stored in m_buybackitems + BUYBACK_SLOT_START = 74, + BUYBACK_SLOT_1 = 74, + BUYBACK_SLOT_2 = 75, + BUYBACK_SLOT_3 = 76, + BUYBACK_SLOT_4 = 77, + BUYBACK_SLOT_5 = 78, + BUYBACK_SLOT_6 = 79, + BUYBACK_SLOT_7 = 80, + BUYBACK_SLOT_8 = 81, + BUYBACK_SLOT_9 = 82, + BUYBACK_SLOT_10 = 83, + BUYBACK_SLOT_11 = 84, + BUYBACK_SLOT_12 = 85, + BUYBACK_SLOT_END = 86 +}; + +enum KeyRingSlots +{ + KEYRING_SLOT_START = 86, + KEYRING_SLOT_END = 118 +}; + +struct ItemPosCount +{ + ItemPosCount(uint16 _pos, uint8 _count) : pos(_pos), count(_count) {} + bool isContainedIn(std::vector const& vec) const; + uint16 pos; + uint8 count; +}; +typedef std::vector ItemPosCountVec; + +enum SwitchWeapon +{ + DEFAULT_SWITCH_WEAPON = 1500, //cooldown in ms + ROGUE_SWITCH_WEAPON = 1000 +}; + +enum TradeSlots +{ + TRADE_SLOT_COUNT = 7, + TRADE_SLOT_TRADED_COUNT = 6, + TRADE_SLOT_NONTRADED = 6 +}; + +enum TransferAbortReason +{ + TRANSFER_ABORT_MAX_PLAYERS = 0x0001, // Transfer Aborted: instance is full + TRANSFER_ABORT_NOT_FOUND = 0x0002, // Transfer Aborted: instance not found + TRANSFER_ABORT_TOO_MANY_INSTANCES = 0x0003, // You have entered too many instances recently. + TRANSFER_ABORT_ZONE_IN_COMBAT = 0x0005, // Unable to zone in while an encounter is in progress. + TRANSFER_ABORT_INSUF_EXPAN_LVL1 = 0x0106, // You must have TBC expansion installed to access this area. + TRANSFER_ABORT_DIFFICULTY1 = 0x0007, // Normal difficulty mode is not available for %s. + TRANSFER_ABORT_DIFFICULTY2 = 0x0107, // Heroic difficulty mode is not available for %s. + TRANSFER_ABORT_DIFFICULTY3 = 0x0207 // Epic difficulty mode is not available for %s. +}; + +enum InstanceResetWarningType +{ + RAID_INSTANCE_WARNING_HOURS = 1, // WARNING! %s is scheduled to reset in %d hour(s). + RAID_INSTANCE_WARNING_MIN = 2, // WARNING! %s is scheduled to reset in %d minute(s)! + RAID_INSTANCE_WARNING_MIN_SOON = 3, // WARNING! %s is scheduled to reset in %d minute(s). Please exit the zone or you will be returned to your bind location! + RAID_INSTANCE_WELCOME = 4 // Welcome to %s. This raid instance is scheduled to reset in %s. +}; + +struct MovementInfo +{ + // common + //uint32 flags; + uint8 unk1; + uint32 time; + float x, y, z, o; + // transport + uint64 t_guid; + float t_x, t_y, t_z, t_o; + uint32 t_time; + // swimming and unk + float s_pitch; + // last fall time + uint32 fallTime; + // jumping + float j_unk, j_sinAngle, j_cosAngle, j_xyspeed; + // spline + float u_unk1; + + MovementInfo() + { + //flags = + time = t_time = fallTime = 0; + unk1 = 0; + x = y = z = o = t_x = t_y = t_z = t_o = s_pitch = j_unk = j_sinAngle = j_cosAngle = j_xyspeed = u_unk1 = 0.0f; + t_guid = 0; + } + + /*void SetMovementFlags(uint32 _flags) + { + flags = _flags; + }*/ +}; + +// flags that use in movement check for example at spell casting +MovementFlags const movementFlagsMask = MovementFlags( + MOVEMENTFLAG_FORWARD |MOVEMENTFLAG_BACKWARD |MOVEMENTFLAG_STRAFE_LEFT|MOVEMENTFLAG_STRAFE_RIGHT| + MOVEMENTFLAG_PITCH_UP|MOVEMENTFLAG_PITCH_DOWN|MOVEMENTFLAG_FLY_UNK1 | + MOVEMENTFLAG_JUMPING |MOVEMENTFLAG_FALLING |MOVEMENTFLAG_FLY_UP | + MOVEMENTFLAG_FLYING |MOVEMENTFLAG_SPLINE +); + +MovementFlags const movementOrTurningFlagsMask = MovementFlags( + movementFlagsMask | MOVEMENTFLAG_LEFT | MOVEMENTFLAG_RIGHT +); +class InstanceSave; + +enum RestType +{ + REST_TYPE_NO = 0, + REST_TYPE_IN_TAVERN = 1, + REST_TYPE_IN_CITY = 2 +}; + +enum DuelCompleteType +{ + DUEL_INTERUPTED = 0, + DUEL_WON = 1, + DUEL_FLED = 2 +}; + +enum TeleportToOptions +{ + TELE_TO_GM_MODE = 0x01, + TELE_TO_NOT_LEAVE_TRANSPORT = 0x02, + TELE_TO_NOT_LEAVE_COMBAT = 0x04, + TELE_TO_NOT_UNSUMMON_PET = 0x08, + TELE_TO_SPELL = 0x10, +}; + +/// Type of environmental damages +enum EnviromentalDamage +{ + DAMAGE_EXHAUSTED = 0, + DAMAGE_DROWNING = 1, + DAMAGE_FALL = 2, + DAMAGE_LAVA = 3, + DAMAGE_SLIME = 4, + DAMAGE_FIRE = 5, + DAMAGE_FALL_TO_VOID = 6 // custom case for fall without durability loss +}; + +// used at player loading query list preparing, and later result selection +enum PlayerLoginQueryIndex +{ + PLAYER_LOGIN_QUERY_LOADFROM = 0, + PLAYER_LOGIN_QUERY_LOADGROUP = 1, + PLAYER_LOGIN_QUERY_LOADBOUNDINSTANCES = 2, + PLAYER_LOGIN_QUERY_LOADAURAS = 3, + PLAYER_LOGIN_QUERY_LOADSPELLS = 4, + PLAYER_LOGIN_QUERY_LOADQUESTSTATUS = 5, + PLAYER_LOGIN_QUERY_LOADDAILYQUESTSTATUS = 6, + PLAYER_LOGIN_QUERY_LOADTUTORIALS = 7, // common for all characters for some account at specific realm + PLAYER_LOGIN_QUERY_LOADREPUTATION = 8, + PLAYER_LOGIN_QUERY_LOADINVENTORY = 9, + PLAYER_LOGIN_QUERY_LOADACTIONS = 10, + PLAYER_LOGIN_QUERY_LOADMAILCOUNT = 11, + PLAYER_LOGIN_QUERY_LOADMAILDATE = 12, + PLAYER_LOGIN_QUERY_LOADSOCIALLIST = 13, + PLAYER_LOGIN_QUERY_LOADHOMEBIND = 14, + PLAYER_LOGIN_QUERY_LOADSPELLCOOLDOWNS = 15, + PLAYER_LOGIN_QUERY_LOADDECLINEDNAMES = 16, + PLAYER_LOGIN_QUERY_LOADGUILD = 17, +}; + +#define MAX_PLAYER_LOGIN_QUERY 18 + +// Player summoning auto-decline time (in secs) +#define MAX_PLAYER_SUMMON_DELAY (2*MINUTE) +#define MAX_MONEY_AMOUNT (0x7FFFFFFF-1) + +struct InstancePlayerBind +{ + InstanceSave *save; + bool perm; + /* permanent PlayerInstanceBinds are created in Raid/Heroic instances for players + that aren't already permanently bound when they are inside when a boss is killed + or when they enter an instance that the group leader is permanently bound to. */ + InstancePlayerBind() : save(NULL), perm(false) {} +}; + +class MANGOS_DLL_SPEC PlayerTaxi +{ + public: + PlayerTaxi(); + ~PlayerTaxi() {} + // Nodes + void InitTaxiNodesForLevel(uint32 race, uint32 level); + void LoadTaxiMask(const char* data); + void SaveTaxiMask(const char* data); + + uint32 GetTaximask( uint8 index ) const { return m_taximask[index]; } + bool IsTaximaskNodeKnown(uint32 nodeidx) const + { + uint8 field = uint8((nodeidx - 1) / 32); + uint32 submask = 1<<((nodeidx-1)%32); + return (m_taximask[field] & submask) == submask; + } + bool SetTaximaskNode(uint32 nodeidx) + { + uint8 field = uint8((nodeidx - 1) / 32); + uint32 submask = 1<<((nodeidx-1)%32); + if ((m_taximask[field] & submask) != submask ) + { + m_taximask[field] |= submask; + return true; + } + else + return false; + } + void AppendTaximaskTo(ByteBuffer& data,bool all); + + // Destinations + bool LoadTaxiDestinationsFromString(std::string values); + std::string SaveTaxiDestinationsToString(); + + void ClearTaxiDestinations() { m_TaxiDestinations.clear(); } + void AddTaxiDestination(uint32 dest) { m_TaxiDestinations.push_back(dest); } + uint32 GetTaxiSource() const { return m_TaxiDestinations.empty() ? 0 : m_TaxiDestinations.front(); } + uint32 GetTaxiDestination() const { return m_TaxiDestinations.size() < 2 ? 0 : m_TaxiDestinations[1]; } + uint32 GetCurrentTaxiPath() const; + uint32 NextTaxiDestination() + { + m_TaxiDestinations.pop_front(); + return GetTaxiDestination(); + } + bool empty() const { return m_TaxiDestinations.empty(); } + private: + TaxiMask m_taximask; + std::deque m_TaxiDestinations; +}; + +class MANGOS_DLL_SPEC Player : public Unit +{ + friend class WorldSession; + friend void Item::AddToUpdateQueueOf(Player *player); + friend void Item::RemoveFromUpdateQueueOf(Player *player); + public: + explicit Player (WorldSession *session); + ~Player ( ); + + void CleanupsBeforeDelete(); + + static UpdateMask updateVisualBits; + static void InitVisibleBits(); + + void AddToWorld(); + void RemoveFromWorld(); + + bool TeleportTo(uint32 mapid, float x, float y, float z, float orientation, uint32 options = 0); + + bool TeleportTo(WorldLocation const &loc, uint32 options = 0) + { + return TeleportTo(loc.mapid, loc.x, loc.y, loc.z, options); + } + + void SetSummonPoint(uint32 mapid, float x, float y, float z) + { + m_summon_expire = time(NULL) + MAX_PLAYER_SUMMON_DELAY; + m_summon_mapid = mapid; + m_summon_x = x; + m_summon_y = y; + m_summon_z = z; + } + void SummonIfPossible(bool agree); + + bool Create( uint32 guidlow, std::string name, uint8 race, uint8 class_, uint8 gender, uint8 skin, uint8 face, uint8 hairStyle, uint8 hairColor, uint8 facialHair, uint8 outfitId ); + + void Update( uint32 time ); + + void BuildEnumData( QueryResult * result, WorldPacket * p_data ); + + void SetInWater(bool apply); + + bool IsInWater() const { return m_isInWater; } + bool IsUnderWater() const; + + void SendInitialPacketsBeforeAddToMap(); + void SendInitialPacketsAfterAddToMap(); + void SendTransferAborted(uint32 mapid, uint16 reason); + void SendInstanceResetWarning(uint32 mapid, uint32 time); + + bool CanInteractWithNPCs(bool alive = true) const; + + bool ToggleAFK(); + bool ToggleDND(); + bool isAFK() const { return HasFlag(PLAYER_FLAGS,PLAYER_FLAGS_AFK); }; + bool isDND() const { return HasFlag(PLAYER_FLAGS,PLAYER_FLAGS_DND); }; + uint8 chatTag() const; + std::string afkMsg; + std::string dndMsg; + + PlayerSocial *GetSocial() { return m_social; } + + PlayerTaxi m_taxi; + void InitTaxiNodesForLevel() { m_taxi.InitTaxiNodesForLevel(getRace(),getLevel()); } + bool ActivateTaxiPathTo(std::vector const& nodes, uint32 mount_id = 0 , Creature* npc = NULL); + // mount_id can be used in scripting calls + bool isAcceptTickets() const { return GetSession()->GetSecurity() >= SEC_GAMEMASTER && (m_ExtraFlags & PLAYER_EXTRA_GM_ACCEPT_TICKETS); } + void SetAcceptTicket(bool on) { if(on) m_ExtraFlags |= PLAYER_EXTRA_GM_ACCEPT_TICKETS; else m_ExtraFlags &= ~PLAYER_EXTRA_GM_ACCEPT_TICKETS; } + bool isAcceptWhispers() const { return m_ExtraFlags & PLAYER_EXTRA_ACCEPT_WHISPERS; } + void SetAcceptWhispers(bool on) { if(on) m_ExtraFlags |= PLAYER_EXTRA_ACCEPT_WHISPERS; else m_ExtraFlags &= ~PLAYER_EXTRA_ACCEPT_WHISPERS; } + bool isGameMaster() const { return m_ExtraFlags & PLAYER_EXTRA_GM_ON; } + void SetGameMaster(bool on); + bool isTaxiCheater() const { return m_ExtraFlags & PLAYER_EXTRA_TAXICHEAT; } + void SetTaxiCheater(bool on) { if(on) m_ExtraFlags |= PLAYER_EXTRA_TAXICHEAT; else m_ExtraFlags &= ~PLAYER_EXTRA_TAXICHEAT; } + bool isGMVisible() const { return !(m_ExtraFlags & PLAYER_EXTRA_GM_INVISIBLE); } + void SetGMVisible(bool on); + void SetPvPDeath(bool on) { if(on) m_ExtraFlags |= PLAYER_EXTRA_PVP_DEATH; else m_ExtraFlags &= ~PLAYER_EXTRA_PVP_DEATH; } + + void GiveXP(uint32 xp, Unit* victim); + void GiveLevel(uint32 level); + void InitStatsForLevel(bool reapplyMods = false); + + // Played Time Stuff + time_t m_logintime; + time_t m_Last_tick; + uint32 m_Played_time[2]; + uint32 GetTotalPlayedTime() { return m_Played_time[0]; }; + uint32 GetLevelPlayedTime() { return m_Played_time[1]; }; + + void setDeathState(DeathState s); // overwrite Unit::setDeathState + + void InnEnter (int time,uint32 mapid, float x,float y,float z) + { + inn_pos_mapid = mapid; + inn_pos_x = x; + inn_pos_y = y; + inn_pos_z = z; + time_inn_enter = time; + }; + + float GetRestBonus() const { return m_rest_bonus; }; + void SetRestBonus(float rest_bonus_new); + + RestType GetRestType() const { return rest_type; }; + void SetRestType(RestType n_r_type) { rest_type = n_r_type; }; + + uint32 GetInnPosMapId() const { return inn_pos_mapid; }; + float GetInnPosX() const { return inn_pos_x; }; + float GetInnPosY() const { return inn_pos_y; }; + float GetInnPosZ() const { return inn_pos_z; }; + + int GetTimeInnEnter() const { return time_inn_enter; }; + void UpdateInnerTime (int time) { time_inn_enter = time; }; + + void RemovePet(Pet* pet, PetSaveMode mode, bool returnreagent = false); + void RemoveMiniPet(); + Pet* GetMiniPet(); + void SetMiniPet(Pet* pet) { m_miniPet = pet->GetGUID(); } + void RemoveGuardians(); + bool HasGuardianWithEntry(uint32 entry); + void AddGuardian(Pet* pet) { m_guardianPets.insert(pet->GetGUID()); } + GuardianPetList const& GetGuardians() const { return m_guardianPets; } + void Uncharm(); + + void Say(std::string text, const uint32 language); + void Yell(std::string text, const uint32 language); + void TextEmote(std::string text); + void Whisper(std::string text, const uint32 language,uint64 receiver); + void BuildPlayerChat(WorldPacket *data, uint8 msgtype, std::string text, uint32 language) const; + + /*********************************************************/ + /*** STORAGE SYSTEM ***/ + /*********************************************************/ + + void SetVirtualItemSlot( uint8 i, Item* item); + void SetSheath( uint32 sheathed ); + uint8 FindEquipSlot( ItemPrototype const* proto, uint32 slot, bool swap ) const; + uint32 GetItemCount( uint32 item, bool inBankAlso = false, Item* skipItem = NULL ) const; + Item* GetItemByGuid( uint64 guid ) const; + Item* GetItemByPos( uint16 pos ) const; + Item* GetItemByPos( uint8 bag, uint8 slot ) const; + Item* GetWeaponForAttack(WeaponAttackType attackType, bool useable = false) const; + Item* GetShield(bool useable = false) const; + static uint32 GetAttackBySlot( uint8 slot ); // MAX_ATTACK if not weapon slot + std::vector &GetItemUpdateQueue() { return m_itemUpdateQueue; } + static bool IsInventoryPos( uint16 pos ) { return IsInventoryPos(pos >> 8,pos & 255); } + static bool IsInventoryPos( uint8 bag, uint8 slot ); + static bool IsEquipmentPos( uint16 pos ) { return IsEquipmentPos(pos >> 8,pos & 255); } + static bool IsEquipmentPos( uint8 bag, uint8 slot ); + static bool IsBagPos( uint16 pos ); + static bool IsBankPos( uint16 pos ) { return IsBankPos(pos >> 8,pos & 255); } + static bool IsBankPos( uint8 bag, uint8 slot ); + bool HasBankBagSlot( uint8 slot ) const; + bool HasItemCount( uint32 item, uint32 count, bool inBankAlso = false ) const; + bool HasItemFitToSpellReqirements(SpellEntry const* spellInfo, Item const* ignoreItem = NULL); + Item* GetItemOrItemWithGemEquipped( uint32 item ) const; + uint8 CanTakeMoreSimilarItems(Item* pItem) const { return _CanTakeMoreSimilarItems(pItem->GetEntry(),pItem->GetCount(),pItem); } + uint8 CanTakeMoreSimilarItems(uint32 entry, uint32 count) const { return _CanTakeMoreSimilarItems(entry,count,NULL); } + uint8 CanStoreNewItem( uint8 bag, uint8 slot, ItemPosCountVec& dest, uint32 item, uint32 count, uint32* no_space_count = NULL ) const + { + return _CanStoreItem(bag, slot, dest, item, count, NULL, false, no_space_count ); + } + uint8 CanStoreItem( uint8 bag, uint8 slot, ItemPosCountVec& dest, Item *pItem, bool swap = false ) const + { + if(!pItem) + return EQUIP_ERR_ITEM_NOT_FOUND; + uint32 count = pItem->GetCount(); + return _CanStoreItem( bag, slot, dest, pItem->GetEntry(), count, pItem, swap, NULL ); + + } + uint8 CanStoreItems( Item **pItem,int count) const; + uint8 CanEquipNewItem( uint8 slot, uint16 &dest, uint32 item, uint32 count, bool swap ) const; + uint8 CanEquipItem( uint8 slot, uint16 &dest, Item *pItem, bool swap, bool not_loading = true ) const; + uint8 CanUnequipItems( uint32 item, uint32 count ) const; + uint8 CanUnequipItem( uint16 src, bool swap ) const; + uint8 CanBankItem( uint8 bag, uint8 slot, ItemPosCountVec& dest, Item *pItem, bool swap, bool not_loading = true ) const; + uint8 CanUseItem( Item *pItem, bool not_loading = true ) const; + bool HasItemTotemCategory( uint32 TotemCategory ) const; + bool CanUseItem( ItemPrototype const *pItem ); + uint8 CanUseAmmo( uint32 item ) const; + Item* StoreNewItem( ItemPosCountVec const& pos, uint32 item, bool update,int32 randomPropertyId = 0 ); + Item* StoreItem( ItemPosCountVec const& pos, Item *pItem, bool update ); + Item* EquipNewItem( uint16 pos, uint32 item, uint32 count, bool update ); + Item* EquipItem( uint16 pos, Item *pItem, bool update ); + void AutoUnequipOffhandIfNeed(); + + uint8 _CanTakeMoreSimilarItems(uint32 entry, uint32 count, Item* pItem, uint32* no_space_count = NULL) const; + uint8 _CanStoreItem( uint8 bag, uint8 slot, ItemPosCountVec& dest, uint32 entry, uint32 count, Item *pItem = NULL, bool swap = false, uint32* no_space_count = NULL ) const; + + void ApplyEquipCooldown( Item * pItem ); + void SetAmmo( uint32 item ); + void RemoveAmmo(); + float GetAmmoDPS() const { return m_ammoDPS; } + bool CheckAmmoCompatibility(const ItemPrototype *ammo_proto) const; + void QuickEquipItem( uint16 pos, Item *pItem); + void VisualizeItem( uint8 slot, Item *pItem); + void SetVisibleItemSlot(uint8 slot, Item *pItem); + Item* BankItem( ItemPosCountVec const& dest, Item *pItem, bool update ) + { + return StoreItem( dest, pItem, update); + } + Item* BankItem( uint16 pos, Item *pItem, bool update ); + void RemoveItem( uint8 bag, uint8 slot, bool update ); + void MoveItemFromInventory(uint8 bag, uint8 slot, bool update); + // in trade, auction, guild bank, mail.... + void MoveItemToInventory(ItemPosCountVec const& dest, Item* pItem, bool update, bool in_characterInventoryDB = false); + // in trade, guild bank, mail.... + void RemoveItemDependentAurasAndCasts( Item * pItem ); + void DestroyItem( uint8 bag, uint8 slot, bool update ); + void DestroyItemCount( uint32 item, uint32 count, bool update, bool unequip_check = false); + void DestroyItemCount( Item* item, uint32& count, bool update ); + void DestroyConjuredItems( bool update ); + void DestroyZoneLimitedItem( bool update, uint32 new_zone ); + void SplitItem( uint16 src, uint16 dst, uint32 count ); + void SwapItem( uint16 src, uint16 dst ); + void AddItemToBuyBackSlot( Item *pItem ); + Item* GetItemFromBuyBackSlot( uint32 slot ); + void RemoveItemFromBuyBackSlot( uint32 slot, bool del ); + uint32 GetMaxKeyringSize() const { return KEYRING_SLOT_END-KEYRING_SLOT_START; } + void SendEquipError( uint8 msg, Item* pItem, Item *pItem2 ); + void SendBuyError( uint8 msg, Creature* pCreature, uint32 item, uint32 param ); + void SendSellError( uint8 msg, Creature* pCreature, uint64 guid, uint32 param ); + void AddWeaponProficiency(uint32 newflag) { m_WeaponProficiency |= newflag; } + void AddArmorProficiency(uint32 newflag) { m_ArmorProficiency |= newflag; } + uint32 GetWeaponProficiency() const { return m_WeaponProficiency; } + uint32 GetArmorProficiency() const { return m_ArmorProficiency; } + bool IsInFeralForm() const { return m_form == FORM_CAT || m_form == FORM_BEAR || m_form == FORM_DIREBEAR; } + bool IsUseEquipedWeapon( bool mainhand ) const + { + // disarm applied only to mainhand weapon + return !IsInFeralForm() && (!mainhand || !HasFlag(UNIT_FIELD_FLAGS,UNIT_FLAG_DISARMED) ); + } + void SendNewItem( Item *item, uint32 count, bool received, bool created, bool broadcast = false ); + bool BuyItemFromVendor(uint64 vendorguid, uint32 item, uint8 count, uint64 bagguid, uint8 slot); + + float GetReputationPriceDiscount( Creature const* pCreature ) const; + Player* GetTrader() const { return pTrader; } + void ClearTrade(); + void TradeCancel(bool sendback); + uint16 GetItemPosByTradeSlot(uint32 slot) const { return tradeItems[slot]; } + + void UpdateEnchantTime(uint32 time); + void UpdateItemDuration(uint32 time, bool realtimeonly=false); + void AddEnchantmentDurations(Item *item); + void RemoveEnchantmentDurations(Item *item); + void RemoveAllEnchantments(EnchantmentSlot slot); + void AddEnchantmentDuration(Item *item,EnchantmentSlot slot,uint32 duration); + void ApplyEnchantment(Item *item,EnchantmentSlot slot,bool apply, bool apply_dur = true, bool ignore_condition = false); + void ApplyEnchantment(Item *item,bool apply); + void SendEnchantmentDurations(); + void AddItemDurations(Item *item); + void RemoveItemDurations(Item *item); + void SendItemDurations(); + void LoadCorpse(); + void LoadPet(); + + uint32 m_stableSlots; + + /*********************************************************/ + /*** QUEST SYSTEM ***/ + /*********************************************************/ + + void PrepareQuestMenu( uint64 guid ); + void SendPreparedQuest( uint64 guid ); + bool IsActiveQuest( uint32 quest_id ) const; + Quest const *GetNextQuest( uint64 guid, Quest const *pQuest ); + bool CanSeeStartQuest( Quest const *pQuest ); + bool CanTakeQuest( Quest const *pQuest, bool msg ); + bool CanAddQuest( Quest const *pQuest, bool msg ); + bool CanCompleteQuest( uint32 quest_id ); + bool CanCompleteRepeatableQuest(Quest const *pQuest); + bool CanRewardQuest( Quest const *pQuest, bool msg ); + bool CanRewardQuest( Quest const *pQuest, uint32 reward, bool msg ); + void AddQuest( Quest const *pQuest, Object *questGiver ); + void CompleteQuest( uint32 quest_id ); + void IncompleteQuest( uint32 quest_id ); + void RewardQuest( Quest const *pQuest, uint32 reward, Object* questGiver, bool announce = true ); + void FailQuest( uint32 quest_id ); + void FailTimedQuest( uint32 quest_id ); + bool SatisfyQuestSkillOrClass( Quest const* qInfo, bool msg ); + bool SatisfyQuestLevel( Quest const* qInfo, bool msg ); + bool SatisfyQuestLog( bool msg ); + bool SatisfyQuestPreviousQuest( Quest const* qInfo, bool msg ); + bool SatisfyQuestRace( Quest const* qInfo, bool msg ); + bool SatisfyQuestReputation( Quest const* qInfo, bool msg ); + bool SatisfyQuestStatus( Quest const* qInfo, bool msg ); + bool SatisfyQuestTimed( Quest const* qInfo, bool msg ); + bool SatisfyQuestExclusiveGroup( Quest const* qInfo, bool msg ); + bool SatisfyQuestNextChain( Quest const* qInfo, bool msg ); + bool SatisfyQuestPrevChain( Quest const* qInfo, bool msg ); + bool SatisfyQuestDay( Quest const* qInfo, bool msg ); + bool GiveQuestSourceItem( Quest const *pQuest ); + bool TakeQuestSourceItem( uint32 quest_id, bool msg ); + bool GetQuestRewardStatus( uint32 quest_id ) const; + QuestStatus GetQuestStatus( uint32 quest_id ) const; + void SetQuestStatus( uint32 quest_id, QuestStatus status ); + + void SetDailyQuestStatus( uint32 quest_id ); + void ResetDailyQuestStatus(); + + uint16 FindQuestSlot( uint32 quest_id ) const; + uint32 GetQuestSlotQuestId(uint16 slot) const { return GetUInt32Value(PLAYER_QUEST_LOG_1_1 + slot*MAX_QUEST_OFFSET + QUEST_ID_OFFSET); } + uint32 GetQuestSlotState(uint16 slot) const { return GetUInt32Value(PLAYER_QUEST_LOG_1_1 + slot*MAX_QUEST_OFFSET + QUEST_STATE_OFFSET); } + uint32 GetQuestSlotCounters(uint16 slot)const { return GetUInt32Value(PLAYER_QUEST_LOG_1_1 + slot*MAX_QUEST_OFFSET + QUEST_COUNTS_OFFSET); } + uint8 GetQuestSlotCounter(uint16 slot,uint8 counter) const { return GetByteValue(PLAYER_QUEST_LOG_1_1 + slot*MAX_QUEST_OFFSET + QUEST_COUNTS_OFFSET,counter); } + uint32 GetQuestSlotTime(uint16 slot) const { return GetUInt32Value(PLAYER_QUEST_LOG_1_1 + slot*MAX_QUEST_OFFSET + QUEST_TIME_OFFSET); } + void SetQuestSlot(uint16 slot,uint32 quest_id, uint32 timer = 0) + { + SetUInt32Value(PLAYER_QUEST_LOG_1_1 + slot*MAX_QUEST_OFFSET + QUEST_ID_OFFSET,quest_id); + SetUInt32Value(PLAYER_QUEST_LOG_1_1 + slot*MAX_QUEST_OFFSET + QUEST_STATE_OFFSET,0); + SetUInt32Value(PLAYER_QUEST_LOG_1_1 + slot*MAX_QUEST_OFFSET + QUEST_COUNTS_OFFSET,0); + SetUInt32Value(PLAYER_QUEST_LOG_1_1 + slot*MAX_QUEST_OFFSET + QUEST_TIME_OFFSET,timer); + } + void SetQuestSlotCounter(uint16 slot,uint8 counter,uint8 count) { SetByteValue(PLAYER_QUEST_LOG_1_1 + slot*MAX_QUEST_OFFSET + QUEST_COUNTS_OFFSET,counter,count); } + void SetQuestSlotState(uint16 slot,uint32 state) { SetFlag(PLAYER_QUEST_LOG_1_1 + slot*MAX_QUEST_OFFSET + QUEST_STATE_OFFSET,state); } + void RemoveQuestSlotState(uint16 slot,uint32 state) { RemoveFlag(PLAYER_QUEST_LOG_1_1 + slot*MAX_QUEST_OFFSET + QUEST_STATE_OFFSET,state); } + void SetQuestSlotTimer(uint16 slot,uint32 timer) { SetUInt32Value(PLAYER_QUEST_LOG_1_1 + slot*MAX_QUEST_OFFSET + QUEST_TIME_OFFSET,timer); } + void SwapQuestSlot(uint16 slot1,uint16 slot2) + { + for (int i = 0; i < MAX_QUEST_OFFSET ; ++i ) + { + uint32 temp1 = GetUInt32Value(PLAYER_QUEST_LOG_1_1 + MAX_QUEST_OFFSET *slot1 + i); + uint32 temp2 = GetUInt32Value(PLAYER_QUEST_LOG_1_1 + MAX_QUEST_OFFSET *slot2 + i); + + SetUInt32Value(PLAYER_QUEST_LOG_1_1 + MAX_QUEST_OFFSET *slot1 + i, temp2); + SetUInt32Value(PLAYER_QUEST_LOG_1_1 + MAX_QUEST_OFFSET *slot2 + i, temp1); + } + } + uint32 GetReqKillOrCastCurrentCount(uint32 quest_id, int32 entry); + void AdjustQuestReqItemCount( Quest const* pQuest ); + void AreaExploredOrEventHappens( uint32 questId ); + void GroupEventHappens( uint32 questId, WorldObject const* pEventObject ); + void ItemAddedQuestCheck( uint32 entry, uint32 count ); + void ItemRemovedQuestCheck( uint32 entry, uint32 count ); + void KilledMonster( uint32 entry, uint64 guid ); + void CastedCreatureOrGO( uint32 entry, uint64 guid, uint32 spell_id ); + void TalkedToCreature( uint32 entry, uint64 guid ); + void MoneyChanged( uint32 value ); + bool HasQuestForItem( uint32 itemid ) const; + bool HasQuestForGO(int32 GOId); + void UpdateForQuestsGO(); + bool CanShareQuest(uint32 quest_id) const; + + void SendQuestComplete( uint32 quest_id ); + void SendQuestReward( Quest const *pQuest, uint32 XP, Object* questGiver ); + void SendQuestFailed( uint32 quest_id ); + void SendQuestTimerFailed( uint32 quest_id ); + void SendCanTakeQuestResponse( uint32 msg ); + void SendPushToPartyResponse( Player *pPlayer, uint32 msg ); + void SendQuestUpdateAddItem( Quest const* pQuest, uint32 item_idx, uint32 count ); + void SendQuestUpdateAddCreatureOrGo( Quest const* pQuest, uint64 guid, uint32 creatureOrGO_idx, uint32 old_count, uint32 add_count ); + + uint64 GetDivider() { return m_divider; }; + void SetDivider( uint64 guid ) { m_divider = guid; }; + + uint32 GetInGameTime() { return m_ingametime; }; + + void SetInGameTime( uint32 time ) { m_ingametime = time; }; + + void AddTimedQuest( uint32 quest_id ) { m_timedquests.insert(quest_id); } + + /*********************************************************/ + /*** LOAD SYSTEM ***/ + /*********************************************************/ + + bool LoadFromDB(uint32 guid, SqlQueryHolder *holder); + bool MinimalLoadFromDB(QueryResult *result, uint32 guid); + static bool LoadValuesArrayFromDB(Tokens& data,uint64 guid); + static uint32 GetUInt32ValueFromArray(Tokens const& data, uint16 index); + static float GetFloatValueFromArray(Tokens const& data, uint16 index); + static uint32 GetUInt32ValueFromDB(uint16 index, uint64 guid); + static float GetFloatValueFromDB(uint16 index, uint64 guid); + static uint32 GetZoneIdFromDB(uint64 guid); + static bool LoadPositionFromDB(uint32& mapid, float& x,float& y,float& z,float& o, bool& in_flight, uint64 guid); + + /*********************************************************/ + /*** SAVE SYSTEM ***/ + /*********************************************************/ + + void SaveToDB(); + void SaveInventoryAndGoldToDB(); // fast save function for item/money cheating preventing + void SaveGoldToDB() { SetUInt32ValueInDB(PLAYER_FIELD_COINAGE,GetMoney(),GetGUID()); } + static bool SaveValuesArrayInDB(Tokens const& data,uint64 guid); + static void SetUInt32ValueInArray(Tokens& data,uint16 index, uint32 value); + static void SetFloatValueInArray(Tokens& data,uint16 index, float value); + static void SetUInt32ValueInDB(uint16 index, uint32 value, uint64 guid); + static void SetFloatValueInDB(uint16 index, float value, uint64 guid); + static void SavePositionInDB(uint32 mapid, float x,float y,float z,float o,uint32 zone,uint64 guid); + + bool m_mailsLoaded; + bool m_mailsUpdated; + + void SetBindPoint(uint64 guid); + void SendTalentWipeConfirm(uint64 guid); + void RewardRage( uint32 damage, uint32 weaponSpeedHitFactor, bool attacker ); + void SendPetSkillWipeConfirm(); + void CalcRage( uint32 damage,bool attacker ); + void RegenerateAll(); + void Regenerate(Powers power); + void RegenerateHealth(); + void setRegenTimer(uint32 time) {m_regenTimer = time;} + void setWeaponChangeTimer(uint32 time) {m_weaponChangeTimer = time;} + + uint32 GetMoney() { return GetUInt32Value (PLAYER_FIELD_COINAGE); } + void ModifyMoney( int32 d ) + { + if(d < 0) + SetMoney (GetMoney() > uint32(-d) ? GetMoney() + d : 0); + else + SetMoney (GetMoney() < MAX_MONEY_AMOUNT - d ? GetMoney() + d : MAX_MONEY_AMOUNT); + + // "At Gold Limit" + if(GetMoney() >= MAX_MONEY_AMOUNT) + SendEquipError(EQUIP_ERR_TOO_MUCH_GOLD,NULL,NULL); + } + void SetMoney( uint32 value ) + { + SetUInt32Value (PLAYER_FIELD_COINAGE, value); + MoneyChanged( value ); + } + + uint32 GetTutorialInt(uint32 intId ) + { + ASSERT( (intId < 8) ); + return m_Tutorials[intId]; + } + + void SetTutorialInt(uint32 intId, uint32 value) + { + ASSERT( (intId < 8) ); + if(m_Tutorials[intId]!=value) + { + m_Tutorials[intId] = value; + m_TutorialsChanged = true; + } + } + + QuestStatusMap& getQuestStatusMap() { return mQuestStatus; }; + + const uint64& GetSelection( ) const { return m_curSelection; } + void SetSelection(const uint64 &guid) { m_curSelection = guid; SetUInt64Value(UNIT_FIELD_TARGET, guid); } + + uint8 GetComboPoints() { return m_comboPoints; } + uint64 GetComboTarget() { return m_comboTarget; } + + void AddComboPoints(Unit* target, int8 count); + void ClearComboPoints(); + void SendComboPoints(); + + void SendMailResult(uint32 mailId, uint32 mailAction, uint32 mailError, uint32 equipError = 0, uint32 item_guid = 0, uint32 item_count = 0); + void SendNewMail(); + void UpdateNextMailTimeAndUnreads(); + void AddNewMailDeliverTime(time_t deliver_time); + bool IsMailsLoaded() const { return m_mailsLoaded; } + + //void SetMail(Mail *m); + void RemoveMail(uint32 id); + + void AddMail(Mail* mail) { m_mail.push_front(mail);}// for call from WorldSession::SendMailTo + uint32 GetMailSize() { return m_mail.size();}; + Mail* GetMail(uint32 id); + + PlayerMails::iterator GetmailBegin() { return m_mail.begin();}; + PlayerMails::iterator GetmailEnd() { return m_mail.end();}; + + /*********************************************************/ + /*** MAILED ITEMS SYSTEM ***/ + /*********************************************************/ + + uint8 unReadMails; + time_t m_nextMailDelivereTime; + + typedef HM_NAMESPACE::hash_map ItemMap; + + ItemMap mMitems; //template defined in objectmgr.cpp + + Item* GetMItem(uint32 id) + { + ItemMap::const_iterator itr = mMitems.find(id); + if (itr != mMitems.end()) + return itr->second; + + return NULL; + } + + void AddMItem(Item* it) + { + ASSERT( it ); + //assert deleted, because items can be added before loading + mMitems[it->GetGUIDLow()] = it; + } + + bool RemoveMItem(uint32 id) + { + ItemMap::iterator i = mMitems.find(id); + if (i == mMitems.end()) + return false; + + mMitems.erase(i); + return true; + } + + void PetSpellInitialize(); + void CharmSpellInitialize(); + void PossessSpellInitialize(); + bool HasSpell(uint32 spell) const; + TrainerSpellState GetTrainerSpellState(TrainerSpell const* trainer_spell) const; + bool IsSpellFitByClassAndRace( uint32 spell_id ) const; + + void SendProficiency(uint8 pr1, uint32 pr2); + void SendInitialSpells(); + bool addSpell(uint32 spell_id, bool active, bool learning = true, bool loading = false, uint16 slot_id=SPELL_WITHOUT_SLOT_ID, bool disabled = false); + void learnSpell(uint32 spell_id); + void removeSpell(uint32 spell_id, bool disabled = false); + void resetSpells(); + void learnDefaultSpells(bool loading = false); + void learnQuestRewardedSpells(); + void learnQuestRewardedSpells(Quest const* quest); + + uint32 GetFreeTalentPoints() const { return GetUInt32Value(PLAYER_CHARACTER_POINTS1); } + void SetFreeTalentPoints(uint32 points) { SetUInt32Value(PLAYER_CHARACTER_POINTS1,points); } + bool resetTalents(bool no_cost = false); + uint32 resetTalentsCost() const; + void InitTalentForLevel(); + + uint32 GetFreePrimaryProffesionPoints() const { return GetUInt32Value(PLAYER_CHARACTER_POINTS2); } + void SetFreePrimaryProffesions(uint16 profs) { SetUInt32Value(PLAYER_CHARACTER_POINTS2,profs); } + void InitPrimaryProffesions(); + + PlayerSpellMap const& GetSpellMap() const { return m_spells; } + PlayerSpellMap & GetSpellMap() { return m_spells; } + + void AddSpellMod(SpellModifier* mod, bool apply); + int32 GetTotalFlatMods(uint32 spellId, SpellModOp op); + int32 GetTotalPctMods(uint32 spellId, SpellModOp op); + bool IsAffectedBySpellmod(SpellEntry const *spellInfo, SpellModifier *mod, Spell const* spell = NULL); + template T ApplySpellMod(uint32 spellId, SpellModOp op, T &basevalue, Spell const* spell = NULL); + void RemoveSpellMods(Spell const* spell); + + bool HasSpellCooldown(uint32 spell_id) const + { + SpellCooldowns::const_iterator itr = m_spellCooldowns.find(spell_id); + return itr != m_spellCooldowns.end() && itr->second.end > time(NULL); + } + uint32 GetSpellCooldownDelay(uint32 spell_id) const + { + SpellCooldowns::const_iterator itr = m_spellCooldowns.find(spell_id); + time_t t = time(NULL); + return itr != m_spellCooldowns.end() && itr->second.end > t ? itr->second.end - t : 0; + } + void AddSpellCooldown(uint32 spell_id, uint32 itemid, time_t end_time); + void SendCooldownEvent(SpellEntry const *spellInfo); + void ProhibitSpellScholl(SpellSchoolMask idSchoolMask, uint32 unTimeMs ); + void RemoveSpellCooldown(uint32 spell_id) { m_spellCooldowns.erase(spell_id); } + void RemoveArenaSpellCooldowns(); + void RemoveAllSpellCooldown(); + void _LoadSpellCooldowns(QueryResult *result); + void _SaveSpellCooldowns(); + + void setResurrectRequestData(uint64 guid, uint32 mapId, float X, float Y, float Z, uint32 health, uint32 mana) + { + m_resurrectGUID = guid; + m_resurrectMap = mapId; + m_resurrectX = X; + m_resurrectY = Y; + m_resurrectZ = Z; + m_resurrectHealth = health; + m_resurrectMana = mana; + }; + void clearResurrectRequestData() { setResurrectRequestData(0,0,0.0f,0.0f,0.0f,0,0); } + bool isRessurectRequestedBy(uint64 guid) const { return m_resurrectGUID == guid; } + bool isRessurectRequested() const { return m_resurrectGUID != 0; } + void ResurectUsingRequestData(); + + int getCinematic() + { + return m_cinematic; + } + void setCinematic(int cine) + { + m_cinematic = cine; + } + + void addActionButton(uint8 button, uint16 action, uint8 type, uint8 misc); + void removeActionButton(uint8 button); + void SendInitialActionButtons(); + + PvPInfo pvpInfo; + void UpdatePvP(bool state, bool ovrride=false); + void UpdateZone(uint32 newZone); + void UpdateArea(uint32 newArea); + + void UpdateZoneDependentAuras( uint32 zone_id ); // zones + void UpdateAreaDependentAuras( uint32 area_id ); // subzones + + void UpdateAfkReport(time_t currTime); + void UpdatePvPFlag(time_t currTime); + void UpdateContestedPvP(uint32 currTime); + void SetContestedPvPTimer(uint32 newTime) {m_contestedPvPTimer = newTime;} + void ResetContestedPvP() + { + clearUnitState(UNIT_STAT_ATTACK_PLAYER); + RemoveFlag(PLAYER_FLAGS, PLAYER_FLAGS_CONTESTED_PVP); + m_contestedPvPTimer = 0; + } + + /** todo: -maybe move UpdateDuelFlag+DuelComplete to independent DuelHandler.. **/ + DuelInfo *duel; + void UpdateDuelFlag(time_t currTime); + void CheckDuelDistance(time_t currTime); + void DuelComplete(DuelCompleteType type); + + bool IsGroupVisibleFor(Player* p) const; + bool IsInSameGroupWith(Player const* p) const; + bool IsInSameRaidWith(Player const* p) const { return p==this || (GetGroup() != NULL && GetGroup() == p->GetGroup()); } + void UninviteFromGroup(); + static void RemoveFromGroup(Group* group, uint64 guid); + void RemoveFromGroup() { RemoveFromGroup(GetGroup(),GetGUID()); } + void SendUpdateToOutOfRangeGroupMembers(); + + void SetInGuild(uint32 GuildId) { SetUInt32Value(PLAYER_GUILDID, GuildId); Player::SetUInt32ValueInDB(PLAYER_GUILDID, GuildId, this->GetGUID()); } + void SetRank(uint32 rankId){ SetUInt32Value(PLAYER_GUILDRANK, rankId); Player::SetUInt32ValueInDB(PLAYER_GUILDRANK, rankId, this->GetGUID()); } + void SetGuildIdInvited(uint32 GuildId) { m_GuildIdInvited = GuildId; } + uint32 GetGuildId() { return GetUInt32Value(PLAYER_GUILDID); } + static uint32 GetGuildIdFromDB(uint64 guid); + uint32 GetRank(){ return GetUInt32Value(PLAYER_GUILDRANK); } + static uint32 GetRankFromDB(uint64 guid); + int GetGuildIdInvited() { return m_GuildIdInvited; } + static void RemovePetitionsAndSigns(uint64 guid, uint32 type); + + // Arena Team + void SetInArenaTeam(uint32 ArenaTeamId, uint8 slot) + { + SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (slot * 6), ArenaTeamId); + SetUInt32ValueInDB(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (slot * 6), ArenaTeamId, this->GetGUID()); + } + uint32 GetArenaTeamId(uint8 slot) { return GetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (slot * 6)); } + static uint32 GetArenaTeamIdFromDB(uint64 guid, uint8 slot); + void SetArenaTeamIdInvited(uint32 ArenaTeamId) { m_ArenaTeamIdInvited = ArenaTeamId; } + uint32 GetArenaTeamIdInvited() { return m_ArenaTeamIdInvited; } + + void SetDifficulty(uint32 dungeon_difficulty) { m_dungeonDifficulty = dungeon_difficulty; } + uint8 GetDifficulty() { return m_dungeonDifficulty; } + + bool UpdateSkill(uint32 skill_id, uint32 step); + bool UpdateSkillPro(uint16 SkillId, int32 Chance, uint32 step); + + bool UpdateCraftSkill(uint32 spellid); + bool UpdateGatherSkill(uint32 SkillId, uint32 SkillValue, uint32 RedLevel, uint32 Multiplicator = 1); + bool UpdateFishingSkill(); + + uint32 GetBaseDefenseSkillValue() const { return GetBaseSkillValue(SKILL_DEFENSE); } + uint32 GetBaseWeaponSkillValue(WeaponAttackType attType) const; + + uint32 GetSpellByProto(ItemPrototype *proto); + + float GetHealthBonusFromStamina(); + float GetManaBonusFromIntellect(); + + bool UpdateStats(Stats stat); + bool UpdateAllStats(); + void UpdateResistances(uint32 school); + void UpdateArmor(); + void UpdateMaxHealth(); + void UpdateMaxPower(Powers power); + void UpdateAttackPowerAndDamage(bool ranged = false); + void UpdateShieldBlockValue(); + void UpdateDamagePhysical(WeaponAttackType attType); + void UpdateSpellDamageAndHealingBonus(); + + void CalculateMinMaxDamage(WeaponAttackType attType, bool normalized, float& min_damage, float& max_damage); + + void UpdateDefenseBonusesMod(); + void ApplyRatingMod(CombatRating cr, int32 value, bool apply); + float GetMeleeCritFromAgility(); + float GetDodgeFromAgility(); + float GetSpellCritFromIntellect(); + float OCTRegenHPPerSpirit(); + float OCTRegenMPPerSpirit(); + float GetRatingCoefficient(CombatRating cr) const; + float GetRatingBonusValue(CombatRating cr) const; + uint32 GetMeleeCritDamageReduction(uint32 damage) const; + uint32 GetRangedCritDamageReduction(uint32 damage) const; + uint32 GetSpellCritDamageReduction(uint32 damage) const; + uint32 GetDotDamageReduction(uint32 damage) const; + + float GetExpertiseDodgeOrParryReduction(WeaponAttackType attType) const; + void UpdateBlockPercentage(); + void UpdateCritPercentage(WeaponAttackType attType); + void UpdateAllCritPercentages(); + void UpdateParryPercentage(); + void UpdateDodgePercentage(); + void UpdateAllSpellCritChances(); + void UpdateSpellCritChance(uint32 school); + void UpdateExpertise(WeaponAttackType attType); + void UpdateManaRegen(); + + const uint64& GetLootGUID() const { return m_lootGuid; } + void SetLootGUID(const uint64 &guid) { m_lootGuid = guid; } + + void RemovedInsignia(Player* looterPlr); + + WorldSession* GetSession() const { return m_session; } + void SetSession(WorldSession *s) { m_session = s; } + + void BuildCreateUpdateBlockForPlayer( UpdateData *data, Player *target ) const; + void DestroyForPlayer( Player *target ) const; + void SendDelayResponse(const uint32); + void SendLogXPGain(uint32 GivenXP,Unit* victim,uint32 RestXP); + + //Low Level Packets + void PlaySound(uint32 Sound, bool OnlySelf); + //notifiers + void SendAttackSwingCantAttack(); + void SendAttackSwingCancelAttack(); + void SendAttackSwingDeadTarget(); + void SendAttackSwingNotStanding(); + void SendAttackSwingNotInRange(); + void SendAttackSwingBadFacingAttack(); + void SendAutoRepeatCancel(); + void SendExplorationExperience(uint32 Area, uint32 Experience); + + void SendDungeonDifficulty(bool IsInGroup); + void ResetInstances(uint8 method); + void SendResetInstanceSuccess(uint32 MapId); + void SendResetInstanceFailed(uint32 reason, uint32 MapId); + void SendResetFailedNotify(uint32 mapid); + + bool SetPosition(float x, float y, float z, float orientation, bool teleport = false); + void UpdateUnderwaterState( Map * m, float x, float y, float z ); + + void SendMessageToSet(WorldPacket *data, bool self);// overwrite Object::SendMessageToSet + void SendMessageToSetInRange(WorldPacket *data, float fist, bool self); + // overwrite Object::SendMessageToSetInRange + void SendMessageToSetInRange(WorldPacket *data, float dist, bool self, bool own_team_only); + + static void DeleteFromDB(uint64 playerguid, uint32 accountId, bool updateRealmChars = true); + + Corpse *GetCorpse() const; + void SpawnCorpseBones(); + void CreateCorpse(); + void KillPlayer(); + uint32 GetResurrectionSpellId(); + void ResurrectPlayer(float restore_percent, bool updateToWorld = true, bool applySickness = false); + void BuildPlayerRepop(); + void RepopAtGraveyard(); + + void DurabilityLossAll(double percent, bool inventory); + void DurabilityLoss(Item* item, double percent); + void DurabilityPointsLossAll(int32 points, bool inventory); + void DurabilityPointsLoss(Item* item, int32 points); + void DurabilityPointLossForEquipSlot(EquipmentSlots slot); + uint32 DurabilityRepairAll(bool cost, float discountMod, bool guildBank); + uint32 DurabilityRepair(uint16 pos, bool cost, float discountMod, bool guildBank); + + void StopMirrorTimers() + { + StopMirrorTimer(FATIGUE_TIMER); + StopMirrorTimer(BREATH_TIMER); + StopMirrorTimer(FIRE_TIMER); + } + + void SetMovement(PlayerMovementType pType); + + void JoinedChannel(Channel *c); + void LeftChannel(Channel *c); + void CleanupChannels(); + void UpdateLocalChannels( uint32 newZone ); + void LeaveLFGChannel(); + + void UpdateDefense(); + void UpdateWeaponSkill (WeaponAttackType attType); + void UpdateCombatSkills(Unit *pVictim, WeaponAttackType attType, MeleeHitOutcome outcome, bool defence); + + void SetSkill(uint32 id, uint16 currVal, uint16 maxVal); + uint16 GetMaxSkillValue(uint32 skill) const; // max + perm. bonus + uint16 GetPureMaxSkillValue(uint32 skill) const; // max + uint16 GetSkillValue(uint32 skill) const; // skill value + perm. bonus + temp bonus + uint16 GetBaseSkillValue(uint32 skill) const; // skill value + perm. bonus + uint16 GetPureSkillValue(uint32 skill) const; // skill value + int16 GetSkillTempBonusValue(uint32 skill) const; + bool HasSkill(uint32 skill) const; + void learnSkillRewardedSpells( uint32 id ); + void learnSkillRewardedSpells(); + + void SetDontMove(bool dontMove); + bool GetDontMove() const { return m_dontMove; } + + void CheckExploreSystem(void); + + static uint32 TeamForRace(uint8 race); + uint32 GetTeam() const { return m_team; } + static uint32 getFactionForRace(uint8 race); + void setFactionForRace(uint8 race); + + bool IsAtGroupRewardDistance(WorldObject const* pRewardSource) const; + bool RewardPlayerAndGroupAtKill(Unit* pVictim); + + FactionStateList m_factions; + ForcedReactions m_forcedReactions; + uint32 GetDefaultReputationFlags(const FactionEntry *factionEntry) const; + int32 GetBaseReputation(const FactionEntry *factionEntry) const; + int32 GetReputation(uint32 faction_id) const; + int32 GetReputation(const FactionEntry *factionEntry) const; + ReputationRank GetReputationRank(uint32 faction) const; + ReputationRank GetReputationRank(const FactionEntry *factionEntry) const; + ReputationRank GetBaseReputationRank(const FactionEntry *factionEntry) const; + ReputationRank ReputationToRank(int32 standing) const; + const static int32 ReputationRank_Length[MAX_REPUTATION_RANK]; + const static int32 Reputation_Cap = 42999; + const static int32 Reputation_Bottom = -42000; + bool ModifyFactionReputation(uint32 FactionTemplateId, int32 DeltaReputation); + bool ModifyFactionReputation(FactionEntry const* factionEntry, int32 standing); + bool ModifyOneFactionReputation(FactionEntry const* factionEntry, int32 standing); + bool SetFactionReputation(uint32 FactionTemplateId, int32 standing); + bool SetFactionReputation(FactionEntry const* factionEntry, int32 standing); + bool SetOneFactionReputation(FactionEntry const* factionEntry, int32 standing); + int32 CalculateReputationGain(uint32 creatureOrQuestLevel, int32 rep, bool for_quest); + void RewardReputation(Unit *pVictim, float rate); + void RewardReputation(Quest const *pQuest); + void SetInitialFactions(); + void UpdateReputation() const; + void SendFactionState(FactionState const* faction) const; + void SendInitialReputations(); + FactionState const* GetFactionState( FactionEntry const* factionEntry) const; + void SetFactionAtWar(FactionState* faction, bool atWar); + void SetFactionInactive(FactionState* faction, bool inactive); + void SetFactionVisible(FactionState* faction); + void SetFactionVisibleForFactionTemplateId(uint32 FactionTemplateId); + void SetFactionVisibleForFactionId(uint32 FactionId); + void UpdateMaxSkills(); + void UpdateSkillsToMaxSkillsForLevel(); // for .levelup + void ModifySkillBonus(uint32 skillid,int32 val, bool talent); + + /*********************************************************/ + /*** PVP SYSTEM ***/ + /*********************************************************/ + void UpdateArenaFields(); + void UpdateHonorFields(); + bool RewardHonor(Unit *pVictim, uint32 groupsize, float honor = -1); + uint32 GetHonorPoints() { return GetUInt32Value(PLAYER_FIELD_HONOR_CURRENCY); } + uint32 GetArenaPoints() { return GetUInt32Value(PLAYER_FIELD_ARENA_CURRENCY); } + void ModifyHonorPoints( int32 value ); + void ModifyArenaPoints( int32 value ); + uint32 GetMaxPersonalArenaRatingRequirement(); + + //End of PvP System + + void SetDrunkValue(uint16 newDrunkValue, uint32 itemid=0); + uint16 GetDrunkValue() const { return m_drunk; } + static DrunkenState GetDrunkenstateByValue(uint16 value); + + uint32 GetDeathTimer() const { return m_deathTimer; } + uint32 GetCorpseReclaimDelay(bool pvp) const; + void UpdateCorpseReclaimDelay(); + void SendCorpseReclaimDelay(bool load = false); + + uint32 GetShieldBlockValue() const; // overwrite Unit version (virtual) + bool CanParry() const { return m_canParry; } + void SetCanParry(bool value); + bool CanBlock() const { return m_canBlock; } + void SetCanBlock(bool value); + bool CanDualWield() const { return m_canDualWield; } + void SetCanDualWield(bool value) { m_canDualWield = value; } + + void SetRegularAttackTime(); + void SetBaseModValue(BaseModGroup modGroup, BaseModType modType, float value) { m_auraBaseMod[modGroup][modType] = value; } + void HandleBaseModValue(BaseModGroup modGroup, BaseModType modType, float amount, bool apply, bool affectStats = true); + float GetBaseModValue(BaseModGroup modGroup, BaseModType modType) const; + float GetTotalBaseModValue(BaseModGroup modGroup) const; + float GetTotalPercentageModValue(BaseModGroup modGroup) const { return m_auraBaseMod[modGroup][FLAT_MOD] + m_auraBaseMod[modGroup][PCT_MOD]; } + void _ApplyAllStatBonuses(); + void _RemoveAllStatBonuses(); + + void _ApplyWeaponDependentAuraMods(Item *item,WeaponAttackType attackType,bool apply); + void _ApplyWeaponDependentAuraCritMod(Item *item, WeaponAttackType attackType, Aura* aura, bool apply); + void _ApplyWeaponDependentAuraDamageMod(Item *item, WeaponAttackType attackType, Aura* aura, bool apply); + + void _ApplyItemMods(Item *item,uint8 slot,bool apply); + void _RemoveAllItemMods(); + void _ApplyAllItemMods(); + void _ApplyItemBonuses(ItemPrototype const *proto,uint8 slot,bool apply); + void _ApplyAmmoBonuses(); + bool EnchantmentFitsRequirements(uint32 enchantmentcondition, int8 slot); + void ToggleMetaGemsActive(uint8 exceptslot, bool apply); + void CorrectMetaGemEnchants(uint8 slot, bool apply); + void InitDataForForm(bool reapplyMods = false); + + void ApplyItemEquipSpell(Item *item, bool apply, bool form_change = false); + void ApplyEquipSpell(SpellEntry const* spellInfo, Item* item, bool apply, bool form_change = false); + void UpdateEquipSpellsAtFormChange(); + void CastItemCombatSpell(Item *item,Unit* Target, WeaponAttackType attType); + + void SendInitWorldStates(); + void SendUpdateWorldState(uint32 Field, uint32 Value); + void SendDirectMessage(WorldPacket *data); + + void SendAuraDurationsForTarget(Unit* target); + + PlayerMenu* PlayerTalkClass; + std::vector ItemSetEff; + + void SendLoot(uint64 guid, LootType loot_type); + void SendLootRelease( uint64 guid ); + void SendNotifyLootItemRemoved(uint8 lootSlot); + void SendNotifyLootMoneyRemoved(); + + /*********************************************************/ + /*** BATTLEGROUND SYSTEM ***/ + /*********************************************************/ + + bool InBattleGround() const { return m_bgBattleGroundID != 0; } + uint32 GetBattleGroundId() const { return m_bgBattleGroundID; } + BattleGround* GetBattleGround() const; + bool InArena() const; + + static uint32 GetMinLevelForBattleGroundQueueId(uint32 queue_id); + static uint32 GetMaxLevelForBattleGroundQueueId(uint32 queue_id); + uint32 GetBattleGroundQueueIdFromLevel() const; + + uint32 GetBattleGroundQueueId(uint32 index) const { return m_bgBattleGroundQueueID[index].bgType; } + uint32 GetBattleGroundQueueIndex(uint32 bgType) const + { + for (int i=0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; i++) + if (m_bgBattleGroundQueueID[i].bgType == bgType) + return i; + return PLAYER_MAX_BATTLEGROUND_QUEUES; + } + bool IsInvitedForBattleGroundType(uint32 bgType) const + { + for (int i=0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; i++) + if (m_bgBattleGroundQueueID[i].bgType == bgType) + return m_bgBattleGroundQueueID[i].invited; + return PLAYER_MAX_BATTLEGROUND_QUEUES; + } + bool InBattleGroundQueueForBattleGroundType(uint32 bgType) const + { + return GetBattleGroundQueueIndex(bgType) < PLAYER_MAX_BATTLEGROUND_QUEUES; + } + + void SetBattleGroundId(uint32 val) { m_bgBattleGroundID = val; } + uint32 AddBattleGroundQueueId(uint32 val) + { + for (int i=0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; i++) + { + if (m_bgBattleGroundQueueID[i].bgType == 0 || m_bgBattleGroundQueueID[i].bgType == val) + { + m_bgBattleGroundQueueID[i].bgType = val; + m_bgBattleGroundQueueID[i].invited = false; + return i; + } + } + return PLAYER_MAX_BATTLEGROUND_QUEUES; + } + void RemoveBattleGroundQueueId(uint32 val) + { + for (int i=0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; i++) + { + if (m_bgBattleGroundQueueID[i].bgType == val) + { + m_bgBattleGroundQueueID[i].bgType = 0; + m_bgBattleGroundQueueID[i].invited = false; + return; + } + } + } + void SetInviteForBattleGroundType(uint32 bgType) + { + for (int i=0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; i++) + if (m_bgBattleGroundQueueID[i].bgType == bgType) + m_bgBattleGroundQueueID[i].invited = true; + } + + uint32 GetBattleGroundEntryPointMap() const { return m_bgEntryPointMap; } + float GetBattleGroundEntryPointX() const { return m_bgEntryPointX; } + float GetBattleGroundEntryPointY() const { return m_bgEntryPointY; } + float GetBattleGroundEntryPointZ() const { return m_bgEntryPointZ; } + float GetBattleGroundEntryPointO() const { return m_bgEntryPointO; } + void SetBattleGroundEntryPoint(uint32 Map, float PosX, float PosY, float PosZ, float PosO ) + { + m_bgEntryPointMap = Map; + m_bgEntryPointX = PosX; + m_bgEntryPointY = PosY; + m_bgEntryPointZ = PosZ; + m_bgEntryPointO = PosO; + } + + void SetBGTeam(uint32 team) { m_bgTeam = team; } + uint32 GetBGTeam() const { return m_bgTeam ? m_bgTeam : GetTeam(); } + + void LeaveBattleground(bool teleportToEntryPoint = true); + bool CanJoinToBattleground() const; + bool CanReportAfkDueToLimit(); + void ReportedAfkBy(Player* reporter); + void ClearAfkReports() { m_bgAfkReporter.clear(); } + + bool GetBGAccessByLevel(uint32 bgTypeId) const; + + /*********************************************************/ + /*** REST SYSTEM ***/ + /*********************************************************/ + + bool isRested() const { return GetRestTime() >= 10000; } + uint32 GetXPRestBonus(uint32 xp); + uint32 GetRestTime() const { return m_restTime;}; + void SetRestTime(uint32 v) { m_restTime = v;}; + + /*********************************************************/ + /*** ENVIROMENTAL SYSTEM ***/ + /*********************************************************/ + + void EnvironmentalDamage(uint64 guid, EnviromentalDamage type, uint32 damage); + + /*********************************************************/ + /*** FLOOD FILTER SYSTEM ***/ + /*********************************************************/ + + void UpdateSpeakTime(); + bool CanSpeak() const; + void ChangeSpeakTime(int utime); + + /*********************************************************/ + /*** VARIOUS SYSTEMS ***/ + /*********************************************************/ + MovementInfo m_movementInfo; + bool isMoving() const { return HasUnitMovementFlag(movementFlagsMask); } + bool isMovingOrTurning() const { return HasUnitMovementFlag(movementOrTurningFlagsMask); } + + bool CanFly() const { return HasUnitMovementFlag(MOVEMENTFLAG_CAN_FLY); } + bool IsFlying() const { return HasUnitMovementFlag(MOVEMENTFLAG_FLYING); } + + void HandleDrowning(); + + void SetClientControl(Unit* target, uint8 allowMove); + + // Transports + Transport * GetTransport() const { return m_transport; } + void SetTransport(Transport * t) { m_transport = t; } + + float GetTransOffsetX() const { return m_movementInfo.t_x; } + float GetTransOffsetY() const { return m_movementInfo.t_y; } + float GetTransOffsetZ() const { return m_movementInfo.t_z; } + float GetTransOffsetO() const { return m_movementInfo.t_o; } + uint32 GetTransTime() const { return m_movementInfo.t_time; } + + uint32 GetSaveTimer() const { return m_nextSave; } + void SetSaveTimer(uint32 timer) { m_nextSave = timer; } + + // Recall position + uint32 m_recallMap; + float m_recallX; + float m_recallY; + float m_recallZ; + float m_recallO; + void SaveRecallPosition(); + + // Homebind coordinates + uint32 m_homebindMapId; + uint16 m_homebindZoneId; + float m_homebindX; + float m_homebindY; + float m_homebindZ; + + // currently visible objects at player client + typedef std::set ClientGUIDs; + ClientGUIDs m_clientGUIDs; + + bool HaveAtClient(WorldObject const* u) { return u==this || m_clientGUIDs.find(u->GetGUID())!=m_clientGUIDs.end(); } + + bool IsVisibleInGridForPlayer(Player* pl) const; + bool IsVisibleGloballyFor(Player* pl) const; + + void UpdateVisibilityOf(WorldObject* target); + + template + void UpdateVisibilityOf(T* target, UpdateData& data, UpdateDataMapType& data_updates, std::set& visibleNow); + + // Stealth detection system + uint32 m_DetectInvTimer; + void HandleStealthedUnitsDetection(); + + uint8 m_forced_speed_changes[MAX_MOVE_TYPE]; + + bool HasAtLoginFlag(AtLoginFlags f) const { return m_atLoginFlags & f; } + void SetAtLoginFlag(AtLoginFlags f) { m_atLoginFlags |= f; } + + LookingForGroup m_lookingForGroup; + + // Temporarily removed pet cache + uint32 GetTemporaryUnsummonedPetNumber() const { return m_temporaryUnsummonedPetNumber; } + void SetTemporaryUnsummonedPetNumber(uint32 petnumber) { m_temporaryUnsummonedPetNumber = petnumber; } + uint32 GetOldPetSpell() const { return m_oldpetspell; } + void SetOldPetSpell(uint32 petspell) { m_oldpetspell = petspell; } + + /*********************************************************/ + /*** INSTANCE SYSTEM ***/ + /*********************************************************/ + + typedef HM_NAMESPACE::hash_map< uint32 /*mapId*/, InstancePlayerBind > BoundInstancesMap; + + void UpdateHomebindTime(uint32 time); + + uint32 m_HomebindTimer; + bool m_InstanceValid; + // permanent binds and solo binds by difficulty + BoundInstancesMap m_boundInstances[TOTAL_DIFFICULTIES]; + InstancePlayerBind* GetBoundInstance(uint32 mapid, uint8 difficulty); + BoundInstancesMap& GetBoundInstances(uint8 difficulty) { return m_boundInstances[difficulty]; } + void UnbindInstance(uint32 mapid, uint8 difficulty, bool unload = false); + void UnbindInstance(BoundInstancesMap::iterator &itr, uint8 difficulty, bool unload = false); + InstancePlayerBind* BindToInstance(InstanceSave *save, bool permanent, bool load = false); + void SendRaidInfo(); + void SendSavedInstances(); + static void ConvertInstancesToGroup(Player *player, Group *group = NULL, uint64 player_guid = 0); + + /*********************************************************/ + /*** GROUP SYSTEM ***/ + /*********************************************************/ + + Group * GetGroupInvite() { return m_groupInvite; } + void SetGroupInvite(Group *group) { m_groupInvite = group; } + Group * GetGroup() { return m_group.getTarget(); } + const Group * GetGroup() const { return (const Group*)m_group.getTarget(); } + GroupReference& GetGroupRef() { return m_group; } + void SetGroup(Group *group, int8 subgroup = -1); + uint8 GetSubGroup() const { return m_group.getSubGroup(); } + uint32 GetGroupUpdateFlag() { return m_groupUpdateMask; } + void SetGroupUpdateFlag(uint32 flag) { m_groupUpdateMask |= flag; } + uint64 GetAuraUpdateMask() { return m_auraUpdateMask; } + void SetAuraUpdateMask(uint8 slot) { m_auraUpdateMask |= (uint64(1) << slot); } + Player* GetNextRandomRaidMember(float radius); + + GridReference &GetGridRef() { return m_gridRef; } + bool isAllowedToLoot(Creature* creature); + + WorldLocation& GetTeleportDest() { return m_teleport_dest; } + + DeclinedName const* GetDeclinedNames() const { return m_declinedname; } + + protected: + + /*********************************************************/ + /*** BATTLEGROUND SYSTEM ***/ + /*********************************************************/ + + /* this variable is set to bg->m_InstanceID, when player is teleported to BG - (it is battleground's GUID)*/ + uint32 m_bgBattleGroundID; + /* + this is an array of BG queues (BgTypeIDs) in which is player + */ + struct BgBattleGroundQueueID_Rec + { + uint32 bgType; + bool invited; + }; + BgBattleGroundQueueID_Rec m_bgBattleGroundQueueID[PLAYER_MAX_BATTLEGROUND_QUEUES]; + uint32 m_bgEntryPointMap; + float m_bgEntryPointX; + float m_bgEntryPointY; + float m_bgEntryPointZ; + float m_bgEntryPointO; + + std::set m_bgAfkReporter; + uint8 m_bgAfkReportedCount; + time_t m_bgAfkReportedTimer; + uint32 m_contestedPvPTimer; + + uint32 m_bgTeam; // what side the player will be added to + + /*********************************************************/ + /*** QUEST SYSTEM ***/ + /*********************************************************/ + + std::set m_timedquests; + + uint64 m_divider; + uint32 m_ingametime; + + /*********************************************************/ + /*** LOAD SYSTEM ***/ + /*********************************************************/ + + void _LoadActions(QueryResult *result); + void _LoadAuras(QueryResult *result, uint32 timediff); + void _LoadBoundInstances(QueryResult *result); + void _LoadInventory(QueryResult *result, uint32 timediff); + void _LoadMailInit(QueryResult *resultUnread, QueryResult *resultDelivery); + void _LoadMail(); + void _LoadMailedItems(Mail *mail); + void _LoadQuestStatus(QueryResult *result); + void _LoadDailyQuestStatus(QueryResult *result); + void _LoadGroup(QueryResult *result); + void _LoadReputation(QueryResult *result); + void _LoadSpells(QueryResult *result); + void _LoadTutorials(QueryResult *result); + void _LoadFriendList(QueryResult *result); + bool _LoadHomeBind(QueryResult *result); + void _LoadDeclinedNames(QueryResult *result); + + /*********************************************************/ + /*** SAVE SYSTEM ***/ + /*********************************************************/ + + void _SaveActions(); + void _SaveAuras(); + void _SaveInventory(); + void _SaveMail(); + void _SaveQuestStatus(); + void _SaveDailyQuestStatus(); + void _SaveReputation(); + void _SaveSpells(); + void _SaveTutorials(); + + void _SetCreateBits(UpdateMask *updateMask, Player *target) const; + void _SetUpdateBits(UpdateMask *updateMask, Player *target) const; + + /*********************************************************/ + /*** ENVIRONMENTAL SYSTEM ***/ + /*********************************************************/ + void HandleLava(); + void HandleSobering(); + void StartMirrorTimer(MirrorTimerType Type, uint32 MaxValue); + void ModifyMirrorTimer(MirrorTimerType Type, uint32 MaxValue, uint32 CurrentValue, uint32 Regen); + void StopMirrorTimer(MirrorTimerType Type); + uint8 m_isunderwater; + bool m_isInWater; + + /*********************************************************/ + /*** HONOR SYSTEM ***/ + /*********************************************************/ + time_t m_lastHonorUpdateTime; + + void outDebugValues() const; + bool _removeSpell(uint16 spell_id); + uint64 m_lootGuid; + + uint32 m_race; + uint32 m_class; + uint32 m_team; + uint32 m_nextSave; + time_t m_speakTime; + uint32 m_speakCount; + uint32 m_dungeonDifficulty; + + uint32 m_atLoginFlags; + + Item* m_items[PLAYER_SLOTS_COUNT]; + uint32 m_currentBuybackSlot; + + std::vector m_itemUpdateQueue; + bool m_itemUpdateQueueBlocked; + + uint32 m_ExtraFlags; + uint64 m_curSelection; + + uint64 m_comboTarget; + int8 m_comboPoints; + + QuestStatusMap mQuestStatus; + + uint32 m_GuildIdInvited; + uint32 m_ArenaTeamIdInvited; + + PlayerMails m_mail; + PlayerSpellMap m_spells; + SpellCooldowns m_spellCooldowns; + + ActionButtonList m_actionButtons; + + float m_auraBaseMod[BASEMOD_END][MOD_END]; + + SpellModList m_spellMods[MAX_SPELLMOD]; + int32 m_SpellModRemoveCount; + EnchantDurationList m_enchantDuration; + ItemDurationList m_itemDuration; + + uint64 m_resurrectGUID; + uint32 m_resurrectMap; + float m_resurrectX, m_resurrectY, m_resurrectZ; + uint32 m_resurrectHealth, m_resurrectMana; + + WorldSession *m_session; + + typedef std::list JoinedChannelsList; + JoinedChannelsList m_channels; + + bool m_dontMove; + + int m_cinematic; + + Player *pTrader; + bool acceptTrade; + uint16 tradeItems[TRADE_SLOT_COUNT]; + uint32 tradeGold; + + time_t m_nextThinkTime; + + uint32 m_Tutorials[8]; + bool m_TutorialsChanged; + + bool m_DailyQuestChanged; + time_t m_lastDailyQuestTime; + + uint32 m_regenTimer; + uint32 m_breathTimer; + uint32 m_drunkTimer; + uint16 m_drunk; + uint32 m_weaponChangeTimer; + + uint32 m_zoneUpdateId; + uint32 m_zoneUpdateTimer; + uint32 m_areaUpdateId; + + uint32 m_deathTimer; + time_t m_deathExpireTime; + + uint32 m_restTime; + + uint32 m_WeaponProficiency; + uint32 m_ArmorProficiency; + bool m_canParry; + bool m_canBlock; + bool m_canDualWield; + uint8 m_swingErrorMsg; + float m_ammoDPS; + ////////////////////Rest System///////////////////// + int time_inn_enter; + uint32 inn_pos_mapid; + float inn_pos_x; + float inn_pos_y; + float inn_pos_z; + float m_rest_bonus; + RestType rest_type; + ////////////////////Rest System///////////////////// + + // Transports + Transport * m_transport; + + uint32 m_resetTalentsCost; + time_t m_resetTalentsTime; + uint32 m_usedTalentCount; + + // Social + PlayerSocial *m_social; + + // Groups + GroupReference m_group; + Group *m_groupInvite; + uint32 m_groupUpdateMask; + uint64 m_auraUpdateMask; + + // Temporarily removed pet cache + uint32 m_temporaryUnsummonedPetNumber; + uint32 m_oldpetspell; + + uint64 m_miniPet; + GuardianPetList m_guardianPets; + + // Player summoning + time_t m_summon_expire; + uint32 m_summon_mapid; + float m_summon_x; + float m_summon_y; + float m_summon_z; + + // Far Teleport + WorldLocation m_teleport_dest; + + DeclinedName *m_declinedname; + private: + // internal common parts for CanStore/StoreItem functions + uint8 _CanStoreItem_InSpecificSlot( uint8 bag, uint8 slot, ItemPosCountVec& dest, ItemPrototype const *pProto, uint32& count, bool swap, Item *pSrcItem ) const; + uint8 _CanStoreItem_InBag( uint8 bag, ItemPosCountVec& dest, ItemPrototype const *pProto, uint32& count, bool merge, bool non_specialized, Item *pSrcItem, uint8 skip_bag, uint8 skip_slot ) const; + uint8 _CanStoreItem_InInventorySlots( uint8 slot_begin, uint8 slot_end, ItemPosCountVec& dest, ItemPrototype const *pProto, uint32& count, bool merge, Item *pSrcItem, uint8 skip_bag, uint8 skip_slot ) const; + Item* _StoreItem( uint16 pos, Item *pItem, uint32 count, bool clone, bool update ); + + GridReference m_gridRef; +}; + +void AddItemsSetItem(Player*player,Item *item); +void RemoveItemsSetItem(Player*player,ItemPrototype const *proto); + +// "the bodies of template functions must be made available in a header file" +template T Player::ApplySpellMod(uint32 spellId, SpellModOp op, T &basevalue, Spell const* spell) +{ + SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellId); + if (!spellInfo) return 0; + int32 totalpct = 0; + int32 totalflat = 0; + for (SpellModList::iterator itr = m_spellMods[op].begin(); itr != m_spellMods[op].end(); ++itr) + { + SpellModifier *mod = *itr; + + if(!IsAffectedBySpellmod(spellInfo,mod,spell)) + continue; + if (mod->type == SPELLMOD_FLAT) + totalflat += mod->value; + else if (mod->type == SPELLMOD_PCT) + { + // skip percent mods for null basevalue (most important for spell mods with charges ) + if(basevalue == T(0)) + continue; + + // special case (skip >10sec spell casts for instant cast setting) + if( mod->op==SPELLMOD_CASTING_TIME && basevalue >= T(10000) && mod->value <= -100) + continue; + + totalpct += mod->value; + } + + if (mod->charges > 0 ) + { + --mod->charges; + if (mod->charges == 0) + { + mod->charges = -1; + mod->lastAffected = spell; + if(!mod->lastAffected) + mod->lastAffected = FindCurrentSpellBySpellId(spellId); + ++m_SpellModRemoveCount; + } + } + } + + float diff = (float)basevalue*(float)totalpct/100.0f + (float)totalflat; + basevalue = T((float)basevalue + diff); + return T(diff); +} +#endif diff --git a/src/game/SharedDefines.h b/src/game/SharedDefines.h index 06c6daead2a..ab04389601b 100644 --- a/src/game/SharedDefines.h +++ b/src/game/SharedDefines.h @@ -1994,4 +1994,108 @@ enum SummonType SUMMON_TYPE_UNKNOWN2 = 427, SUMMON_TYPE_POSESSED2 = 428 }; + +enum ResponseCodes +{ + RESPONSE_SUCCESS = 0x00, + RESPONSE_FAILURE = 0x01, + RESPONSE_CANCELLED = 0x02, + RESPONSE_DISCONNECTED = 0x03, + RESPONSE_FAILED_TO_CONNECT = 0x04, + RESPONSE_CONNECTED = 0x05, + RESPONSE_VERSION_MISMATCH = 0x06, + + CSTATUS_CONNECTING = 0x07, + CSTATUS_NEGOTIATING_SECURITY = 0x08, + CSTATUS_NEGOTIATION_COMPLETE = 0x09, + CSTATUS_NEGOTIATION_FAILED = 0x0A, + CSTATUS_AUTHENTICATING = 0x0B, + + AUTH_OK = 0x0C, + AUTH_FAILED = 0x0D, + AUTH_REJECT = 0x0E, + AUTH_BAD_SERVER_PROOF = 0x0F, + AUTH_UNAVAILABLE = 0x10, + AUTH_SYSTEM_ERROR = 0x11, + AUTH_BILLING_ERROR = 0x12, + AUTH_BILLING_EXPIRED = 0x13, + AUTH_VERSION_MISMATCH = 0x14, + AUTH_UNKNOWN_ACCOUNT = 0x15, + AUTH_INCORRECT_PASSWORD = 0x16, + AUTH_SESSION_EXPIRED = 0x17, + AUTH_SERVER_SHUTTING_DOWN = 0x18, + AUTH_ALREADY_LOGGING_IN = 0x19, + AUTH_LOGIN_SERVER_NOT_FOUND = 0x1A, + AUTH_WAIT_QUEUE = 0x1B, + AUTH_BANNED = 0x1C, + AUTH_ALREADY_ONLINE = 0x1D, + AUTH_NO_TIME = 0x1E, + AUTH_DB_BUSY = 0x1F, + AUTH_SUSPENDED = 0x20, + AUTH_PARENTAL_CONTROL = 0x21, + AUTH_LOCKED_ENFORCED = 0x22, + + REALM_LIST_IN_PROGRESS = 0x23, + REALM_LIST_SUCCESS = 0x24, + REALM_LIST_FAILED = 0x25, + REALM_LIST_INVALID = 0x26, + REALM_LIST_REALM_NOT_FOUND = 0x27, + + ACCOUNT_CREATE_IN_PROGRESS = 0x28, + ACCOUNT_CREATE_SUCCESS = 0x29, + ACCOUNT_CREATE_FAILED = 0x2A, + + CHAR_LIST_RETRIEVING = 0x2B, + CHAR_LIST_RETRIEVED = 0x2C, + CHAR_LIST_FAILED = 0x2D, + + CHAR_CREATE_IN_PROGRESS = 0x2E, + CHAR_CREATE_SUCCESS = 0x2F, + CHAR_CREATE_ERROR = 0x30, + CHAR_CREATE_FAILED = 0x31, + CHAR_CREATE_NAME_IN_USE = 0x32, + CHAR_CREATE_DISABLED = 0x33, + CHAR_CREATE_PVP_TEAMS_VIOLATION = 0x34, + CHAR_CREATE_SERVER_LIMIT = 0x35, + CHAR_CREATE_ACCOUNT_LIMIT = 0x36, + CHAR_CREATE_SERVER_QUEUE = 0x37, + CHAR_CREATE_ONLY_EXISTING = 0x38, + CHAR_CREATE_EXPANSION = 0x39, + + CHAR_DELETE_IN_PROGRESS = 0x3A, + CHAR_DELETE_SUCCESS = 0x3B, + CHAR_DELETE_FAILED = 0x3C, + CHAR_DELETE_FAILED_LOCKED_FOR_TRANSFER = 0x3D, + CHAR_DELETE_FAILED_GUILD_LEADER = 0x3E, + CHAR_DELETE_FAILED_ARENA_CAPTAIN = 0x3F, + + CHAR_LOGIN_IN_PROGRESS = 0x40, + CHAR_LOGIN_SUCCESS = 0x41, + CHAR_LOGIN_NO_WORLD = 0x42, + CHAR_LOGIN_DUPLICATE_CHARACTER = 0x43, + CHAR_LOGIN_NO_INSTANCES = 0x44, + CHAR_LOGIN_FAILED = 0x45, + CHAR_LOGIN_DISABLED = 0x46, + CHAR_LOGIN_NO_CHARACTER = 0x47, + CHAR_LOGIN_LOCKED_FOR_TRANSFER = 0x48, + CHAR_LOGIN_LOCKED_BY_BILLING = 0x49, + + CHAR_NAME_SUCCESS = 0x4A, + CHAR_NAME_FAILURE = 0x4B, + CHAR_NAME_NO_NAME = 0x4C, + CHAR_NAME_TOO_SHORT = 0x4D, + CHAR_NAME_TOO_LONG = 0x4E, + CHAR_NAME_INVALID_CHARACTER = 0x4F, + CHAR_NAME_MIXED_LANGUAGES = 0x50, + CHAR_NAME_PROFANE = 0x51, + CHAR_NAME_RESERVED = 0x52, + CHAR_NAME_INVALID_APOSTROPHE = 0x53, + CHAR_NAME_MULTIPLE_APOSTROPHES = 0x54, + CHAR_NAME_THREE_CONSECUTIVE = 0x55, + CHAR_NAME_INVALID_SPACE = 0x56, + CHAR_NAME_CONSECUTIVE_SPACES = 0x57, + CHAR_NAME_RUSSIAN_CONSECUTIVE_SILENT_CHARACTERS = 0x58, + CHAR_NAME_RUSSIAN_SILENT_CHARACTER_AT_BEGINNING_OR_END = 0x59, + CHAR_NAME_DECLENSION_DOESNT_MATCH_BASE_NAME = 0x5A, +}; #endif diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp index 95e9ac1b745..d97cc2c6f0d 100644 --- a/src/game/Spell.cpp +++ b/src/game/Spell.cpp @@ -1,5115 +1,5070 @@ -/* - * Copyright (C) 2005-2008 MaNGOS - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "Common.h" -#include "Database/DatabaseEnv.h" -#include "WorldPacket.h" -#include "WorldSession.h" -#include "GridNotifiers.h" -#include "GridNotifiersImpl.h" -#include "Opcodes.h" -#include "Log.h" -#include "UpdateMask.h" -#include "World.h" -#include "ObjectMgr.h" -#include "SpellMgr.h" -#include "Player.h" -#include "Pet.h" -#include "Unit.h" -#include "Spell.h" -#include "DynamicObject.h" -#include "SpellAuras.h" -#include "Group.h" -#include "UpdateData.h" -#include "MapManager.h" -#include "ObjectAccessor.h" -#include "CellImpl.h" -#include "Policies/SingletonImp.h" -#include "SharedDefines.h" -#include "Tools.h" -#include "LootMgr.h" -#include "VMapFactory.h" -#include "BattleGround.h" -#include "Util.h" - -#define SPELL_CHANNEL_UPDATE_INTERVAL 1000 - -extern pEffect SpellEffects[TOTAL_SPELL_EFFECTS]; - -bool IsQuestTameSpell(uint32 spellId) -{ - SpellEntry const *spellproto = sSpellStore.LookupEntry(spellId); - if (!spellproto) return false; - - return spellproto->Effect[0] == SPELL_EFFECT_THREAT - && spellproto->Effect[1] == SPELL_EFFECT_APPLY_AURA && spellproto->EffectApplyAuraName[1] == SPELL_AURA_DUMMY; -} - -SpellCastTargets::SpellCastTargets() -{ - m_unitTarget = NULL; - m_itemTarget = NULL; - m_GOTarget = NULL; - - m_unitTargetGUID = 0; - m_GOTargetGUID = 0; - m_CorpseTargetGUID = 0; - m_itemTargetGUID = 0; - m_itemTargetEntry = 0; - - m_srcX = m_srcY = m_srcZ = m_destX = m_destY = m_destZ = 0; - m_strTarget = ""; - m_targetMask = 0; -} - -SpellCastTargets::~SpellCastTargets() -{ -} - -void SpellCastTargets::setUnitTarget(Unit *target) -{ - if (!target) - return; - - m_destX = target->GetPositionX(); - m_destY = target->GetPositionY(); - m_destZ = target->GetPositionZ(); - m_unitTarget = target; - m_unitTargetGUID = target->GetGUID(); - m_targetMask |= TARGET_FLAG_UNIT; -} - -void SpellCastTargets::setDestination(float x, float y, float z) -{ - m_destX = x; - m_destY = y; - m_destZ = z; - m_targetMask |= TARGET_FLAG_DEST_LOCATION; -} - -void SpellCastTargets::setGOTarget(GameObject *target) -{ - m_GOTarget = target; - m_GOTargetGUID = target->GetGUID(); - // m_targetMask |= TARGET_FLAG_OBJECT; -} - -void SpellCastTargets::setItemTarget(Item* item) -{ - if(!item) - return; - - m_itemTarget = item; - m_itemTargetGUID = item->GetGUID(); - m_itemTargetEntry = item->GetEntry(); - m_targetMask |= TARGET_FLAG_ITEM; -} - -void SpellCastTargets::setCorpseTarget(Corpse* corpse) -{ - m_CorpseTargetGUID = corpse->GetGUID(); -} - -void SpellCastTargets::Update(Unit* caster) -{ - m_GOTarget = m_GOTargetGUID ? ObjectAccessor::GetGameObject(*caster,m_GOTargetGUID) : NULL; - m_unitTarget = m_unitTargetGUID ? - ( m_unitTargetGUID==caster->GetGUID() ? caster : ObjectAccessor::GetUnit(*caster, m_unitTargetGUID) ) : - NULL; - - m_itemTarget = NULL; - if(caster->GetTypeId()==TYPEID_PLAYER) - { - if(m_targetMask & TARGET_FLAG_ITEM) - m_itemTarget = ((Player*)caster)->GetItemByGuid(m_itemTargetGUID); - else - { - Player* pTrader = ((Player*)caster)->GetTrader(); - if(pTrader && m_itemTargetGUID < TRADE_SLOT_COUNT) - m_itemTarget = pTrader->GetItemByPos(pTrader->GetItemPosByTradeSlot(m_itemTargetGUID)); - } - if(m_itemTarget) - m_itemTargetEntry = m_itemTarget->GetEntry(); - } -} - -bool SpellCastTargets::read ( WorldPacket * data, Unit *caster ) -{ - if(data->rpos()+4 > data->size()) - return false; - - *data >> m_targetMask; - - if(m_targetMask == TARGET_FLAG_SELF) - { - m_destX = caster->GetPositionX(); - m_destY = caster->GetPositionY(); - m_destZ = caster->GetPositionZ(); - m_unitTarget = caster; - m_unitTargetGUID = caster->GetGUID(); - return true; - } - // TARGET_FLAG_UNK2 is used for non-combat pets, maybe other? - if( m_targetMask & (TARGET_FLAG_UNIT|TARGET_FLAG_UNK2) ) - if(!readGUID(*data, m_unitTargetGUID)) - return false; - - if( m_targetMask & ( TARGET_FLAG_OBJECT | TARGET_FLAG_OBJECT_UNK )) - if(!readGUID(*data, m_GOTargetGUID)) - return false; - - if(( m_targetMask & ( TARGET_FLAG_ITEM | TARGET_FLAG_TRADE_ITEM )) && caster->GetTypeId() == TYPEID_PLAYER) - if(!readGUID(*data, m_itemTargetGUID)) - return false; - - if( m_targetMask & TARGET_FLAG_SOURCE_LOCATION ) - { - if(data->rpos()+4+4+4 > data->size()) - return false; - - *data >> m_srcX >> m_srcY >> m_srcZ; - if(!MaNGOS::IsValidMapCoord(m_srcX, m_srcY, m_srcZ)) - return false; - } - - if( m_targetMask & TARGET_FLAG_DEST_LOCATION ) - { - if(data->rpos()+4+4+4 > data->size()) - return false; - - *data >> m_destX >> m_destY >> m_destZ; - if(!MaNGOS::IsValidMapCoord(m_destX, m_destY, m_destZ)) - return false; - } - - if( m_targetMask & TARGET_FLAG_STRING ) - { - if(data->rpos()+1 > data->size()) - return false; - - *data >> m_strTarget; - } - - if( m_targetMask & (TARGET_FLAG_CORPSE | TARGET_FLAG_PVP_CORPSE ) ) - if(!readGUID(*data, m_CorpseTargetGUID)) - return false; - - // find real units/GOs - Update(caster); - return true; -} - -void SpellCastTargets::write ( WorldPacket * data ) -{ - *data << uint32(m_targetMask); - - if( m_targetMask & ( TARGET_FLAG_UNIT | TARGET_FLAG_PVP_CORPSE | TARGET_FLAG_OBJECT | TARGET_FLAG_CORPSE | TARGET_FLAG_UNK2 ) ) - { - if(m_targetMask & TARGET_FLAG_UNIT) - { - if(m_unitTarget) - data->append(m_unitTarget->GetPackGUID()); - else - *data << uint8(0); - } - else if( m_targetMask & ( TARGET_FLAG_OBJECT | TARGET_FLAG_OBJECT_UNK ) ) - { - if(m_GOTarget) - data->append(m_GOTarget->GetPackGUID()); - else - *data << uint8(0); - } - else if( m_targetMask & ( TARGET_FLAG_CORPSE | TARGET_FLAG_PVP_CORPSE ) ) - data->appendPackGUID(m_CorpseTargetGUID); - else - *data << uint8(0); - } - - if( m_targetMask & ( TARGET_FLAG_ITEM | TARGET_FLAG_TRADE_ITEM ) ) - { - if(m_itemTarget) - data->append(m_itemTarget->GetPackGUID()); - else - *data << uint8(0); - } - - if( m_targetMask & TARGET_FLAG_SOURCE_LOCATION ) - *data << m_srcX << m_srcY << m_srcZ; - - if( m_targetMask & TARGET_FLAG_DEST_LOCATION ) - *data << m_destX << m_destY << m_destZ; - - if( m_targetMask & TARGET_FLAG_STRING ) - *data << m_strTarget; -} - -Spell::Spell( Unit* Caster, SpellEntry const *info, bool triggered, uint64 originalCasterGUID, Spell** triggeringContainer ) -{ - ASSERT( Caster != NULL && info != NULL ); - ASSERT( info == sSpellStore.LookupEntry( info->Id ) && "`info` must be pointer to sSpellStore element"); - - m_spellInfo = info; - m_caster = Caster; - m_selfContainer = NULL; - m_triggeringContainer = triggeringContainer; - m_deletable = true; - m_delayAtDamageCount = 0; - - m_applyMultiplierMask = 0; - - // Get data for type of attack - switch (m_spellInfo->DmgClass) - { - case SPELL_DAMAGE_CLASS_MELEE: - if (m_spellInfo->AttributesEx3 & SPELL_ATTR_EX3_REQ_OFFHAND) - m_attackType = OFF_ATTACK; - else - m_attackType = BASE_ATTACK; - break; - case SPELL_DAMAGE_CLASS_RANGED: - m_attackType = RANGED_ATTACK; - break; - default: - // Wands - if (m_spellInfo->AttributesEx3 & SPELL_ATTR_EX3_REQ_WAND) - m_attackType = RANGED_ATTACK; - else - m_attackType = BASE_ATTACK; - break; - } - - m_spellSchoolMask = GetSpellSchoolMask(info); // Can be override for some spell (wand shoot for example) - - if(m_attackType == RANGED_ATTACK) - { - // wand case - if((m_caster->getClassMask() & CLASSMASK_WAND_USERS) != 0 && m_caster->GetTypeId()==TYPEID_PLAYER) - { - if(Item* pItem = ((Player*)m_caster)->GetWeaponForAttack(RANGED_ATTACK)) - m_spellSchoolMask = SpellSchoolMask(1 << pItem->GetProto()->Damage->DamageType); - } - } - - if(originalCasterGUID) - m_originalCasterGUID = originalCasterGUID; - else - m_originalCasterGUID = m_caster->GetGUID(); - - if(m_originalCasterGUID==m_caster->GetGUID()) - m_originalCaster = m_caster; - else - { - m_originalCaster = ObjectAccessor::GetUnit(*m_caster,m_originalCasterGUID); - if(m_originalCaster && !m_originalCaster->IsInWorld()) m_originalCaster = NULL; - } - - for(int i=0; i <3; ++i) - m_currentBasePoints[i] = m_spellInfo->EffectBasePoints[i]; - - m_spellState = SPELL_STATE_NULL; - - m_castPositionX = m_castPositionY = m_castPositionZ = 0; - m_TriggerSpells.clear(); - m_IsTriggeredSpell = triggered; - //m_AreaAura = false; - m_CastItem = NULL; - - unitTarget = NULL; - itemTarget = NULL; - gameObjTarget = NULL; - focusObject = NULL; - m_cast_count = 0; - m_triggeredByAuraSpell = NULL; - - //Auto Shot & Shoot - if( m_spellInfo->AttributesEx2 == 0x000020 && !triggered ) - m_autoRepeat = true; - else - m_autoRepeat = false; - - m_powerCost = 0; // setup to correct value in Spell::prepare, don't must be used before. - m_casttime = 0; // setup to correct value in Spell::prepare, don't must be used before. - m_timer = 0; // will set to castime in preper - - m_needAliveTargetMask = 0; - - // determine reflection - m_canReflect = false; - - if(m_spellInfo->DmgClass == SPELL_DAMAGE_CLASS_MAGIC && (m_spellInfo->AttributesEx2 & 0x4)==0) - { - for(int j=0;j<3;j++) - { - if (m_spellInfo->Effect[j]==0) - continue; - - if(!IsPositiveTarget(m_spellInfo->EffectImplicitTargetA[j],m_spellInfo->EffectImplicitTargetB[j])) - m_canReflect = true; - else - m_canReflect = (m_spellInfo->AttributesEx & (1<<7)) ? true : false; - - if(m_canReflect) - continue; - else - break; - } - } - - CleanupTargetList(); -} - -Spell::~Spell() -{ -} - -void Spell::FillTargetMap() -{ - // TODO: ADD the correct target FILLS!!!!!! - - for(uint32 i=0;i<3;i++) - { - // not call for empty effect. - // Also some spells use not used effect targets for store targets for dummy effect in triggered spells - if(m_spellInfo->Effect[i]==0) - continue; - - // targets for TARGET_SCRIPT_COORDINATES (A) and TARGET_SCRIPT filled in Spell::canCast call - if( m_spellInfo->EffectImplicitTargetA[i] == TARGET_SCRIPT_COORDINATES || - m_spellInfo->EffectImplicitTargetA[i] == TARGET_SCRIPT || - m_spellInfo->EffectImplicitTargetB[i] == TARGET_SCRIPT && m_spellInfo->EffectImplicitTargetA[i] != TARGET_SELF ) - continue; - - // TODO: find a way so this is not needed? - // for area auras always add caster as target (needed for totems for example) - if(IsAreaAuraEffect(m_spellInfo->Effect[i])) - AddUnitTarget(m_caster, i); - - std::list tmpUnitMap; - - // TargetA/TargetB dependent from each other, we not switch to full support this dependences - // but need it support in some know cases - switch(m_spellInfo->EffectImplicitTargetA[i]) - { - case TARGET_ALL_AROUND_CASTER: - if( m_spellInfo->EffectImplicitTargetB[i]==TARGET_ALL_PARTY || - m_spellInfo->EffectImplicitTargetB[i]==TARGET_ALL_FRIENDLY_UNITS_AROUND_CASTER || - m_spellInfo->EffectImplicitTargetB[i]==TARGET_RANDOM_RAID_MEMBER ) - { - SetTargetMap(i,m_spellInfo->EffectImplicitTargetB[i],tmpUnitMap); - } - // Note: this hack with search required until GO casting not implemented - // environment damage spells already have around enemies targeting but this not help in case not existed GO casting support - // currently each enemy selected explicitly and self cast damage - else if(m_spellInfo->EffectImplicitTargetB[i]==TARGET_ALL_ENEMY_IN_AREA && m_spellInfo->Effect[i]==SPELL_EFFECT_ENVIRONMENTAL_DAMAGE) - { - if(m_targets.getUnitTarget()) - tmpUnitMap.push_back(m_targets.getUnitTarget()); - } - else - { - SetTargetMap(i,m_spellInfo->EffectImplicitTargetA[i],tmpUnitMap); - SetTargetMap(i,m_spellInfo->EffectImplicitTargetB[i],tmpUnitMap); - } - break; - case TARGET_TABLE_X_Y_Z_COORDINATES: - // Only if target A, for target B (used in teleports) dest select in effect - SetTargetMap(i,m_spellInfo->EffectImplicitTargetA[i],tmpUnitMap); - break; - default: - switch(m_spellInfo->EffectImplicitTargetB[i]) - { - case TARGET_SCRIPT_COORDINATES: // B case filled in canCast but we need fill unit list base at A case - SetTargetMap(i,m_spellInfo->EffectImplicitTargetA[i],tmpUnitMap); - break; - default: - SetTargetMap(i,m_spellInfo->EffectImplicitTargetA[i],tmpUnitMap); - SetTargetMap(i,m_spellInfo->EffectImplicitTargetB[i],tmpUnitMap); - break; - } - break; - } - - if( (m_spellInfo->EffectImplicitTargetA[i]==0 || m_spellInfo->EffectImplicitTargetA[i]==TARGET_EFFECT_SELECT) && - (m_spellInfo->EffectImplicitTargetB[i]==0 || m_spellInfo->EffectImplicitTargetB[i]==TARGET_EFFECT_SELECT) ) - { - // add here custom effects that need default target. - // FOR EVERY TARGET TYPE THERE IS A DIFFERENT FILL!! - switch(m_spellInfo->Effect[i]) - { - case SPELL_EFFECT_DUMMY: - { - switch(m_spellInfo->Id) - { - case 20577: // Cannibalize - { - // non-standard target selection - SpellRangeEntry const* srange = sSpellRangeStore.LookupEntry(m_spellInfo->rangeIndex); - float max_range = GetSpellMaxRange(srange); - - CellPair p(MaNGOS::ComputeCellPair(m_caster->GetPositionX(), m_caster->GetPositionY())); - Cell cell(p); - cell.data.Part.reserved = ALL_DISTRICT; - cell.SetNoCreate(); - - WorldObject* result = NULL; - - MaNGOS::CannibalizeObjectCheck u_check(m_caster, max_range); - MaNGOS::WorldObjectSearcher searcher(result, u_check); - - TypeContainerVisitor, GridTypeMapContainer > grid_searcher(searcher); - CellLock cell_lock(cell, p); - cell_lock->Visit(cell_lock, grid_searcher, *MapManager::Instance().GetMap(m_caster->GetMapId(), m_caster)); - - if(!result) - { - TypeContainerVisitor, WorldTypeMapContainer > world_searcher(searcher); - cell_lock->Visit(cell_lock, world_searcher, *MapManager::Instance().GetMap(m_caster->GetMapId(), m_caster)); - } - - if(result) - { - switch(result->GetTypeId()) - { - case TYPEID_UNIT: - case TYPEID_PLAYER: - tmpUnitMap.push_back((Unit*)result); - break; - case TYPEID_CORPSE: - m_targets.setCorpseTarget((Corpse*)result); - if(Player* owner = ObjectAccessor::FindPlayer(((Corpse*)result)->GetOwnerGUID())) - tmpUnitMap.push_back(owner); - break; - } - } - else - { - // clear cooldown at fail - if(m_caster->GetTypeId()==TYPEID_PLAYER) - { - ((Player*)m_caster)->RemoveSpellCooldown(m_spellInfo->Id); - - WorldPacket data(SMSG_CLEAR_COOLDOWN, (4+8)); - data << uint32(m_spellInfo->Id); - data << uint64(m_caster->GetGUID()); - ((Player*)m_caster)->GetSession()->SendPacket(&data); - } - - SendCastResult(SPELL_FAILED_NO_EDIBLE_CORPSES); - finish(false); - } - break; - } - default: - if(m_targets.getUnitTarget()) - tmpUnitMap.push_back(m_targets.getUnitTarget()); - break; - } - break; - } - case SPELL_EFFECT_RESURRECT: - case SPELL_EFFECT_PARRY: - case SPELL_EFFECT_CREATE_ITEM: - case SPELL_EFFECT_TRIGGER_SPELL: - case SPELL_EFFECT_TRIGGER_MISSILE: - case SPELL_EFFECT_LEARN_SPELL: - case SPELL_EFFECT_SKILL_STEP: - case SPELL_EFFECT_PROFICIENCY: - case SPELL_EFFECT_SUMMON_POSSESSED: - case SPELL_EFFECT_SUMMON_OBJECT_WILD: - case SPELL_EFFECT_SELF_RESURRECT: - case SPELL_EFFECT_REPUTATION: - if(m_targets.getUnitTarget()) - tmpUnitMap.push_back(m_targets.getUnitTarget()); - break; - case SPELL_EFFECT_SUMMON_PLAYER: - if(m_caster->GetTypeId()==TYPEID_PLAYER && ((Player*)m_caster)->GetSelection()) - { - Player* target = objmgr.GetPlayer(((Player*)m_caster)->GetSelection()); - if(target) - tmpUnitMap.push_back(target); - } - break; - case SPELL_EFFECT_RESURRECT_NEW: - if(m_targets.getUnitTarget()) - tmpUnitMap.push_back(m_targets.getUnitTarget()); - if(m_targets.getCorpseTargetGUID()) - { - Corpse *corpse = ObjectAccessor::GetCorpse(*m_caster,m_targets.getCorpseTargetGUID()); - if(corpse) - { - Player* owner = ObjectAccessor::FindPlayer(corpse->GetOwnerGUID()); - if(owner) - tmpUnitMap.push_back(owner); - } - } - break; - case SPELL_EFFECT_SUMMON: - if(m_spellInfo->EffectMiscValueB[i] == SUMMON_TYPE_POSESSED || m_spellInfo->EffectMiscValueB[i] == SUMMON_TYPE_POSESSED2) - { - if(m_targets.getUnitTarget()) - tmpUnitMap.push_back(m_targets.getUnitTarget()); - } - else - tmpUnitMap.push_back(m_caster); - break; - case SPELL_EFFECT_SUMMON_CHANGE_ITEM: - case SPELL_EFFECT_SUMMON_WILD: - case SPELL_EFFECT_SUMMON_GUARDIAN: - case SPELL_EFFECT_TRANS_DOOR: - case SPELL_EFFECT_ADD_FARSIGHT: - case SPELL_EFFECT_STUCK: - case SPELL_EFFECT_DESTROY_ALL_TOTEMS: - case SPELL_EFFECT_SUMMON_DEMON: - case SPELL_EFFECT_SKILL: - tmpUnitMap.push_back(m_caster); - break; - case SPELL_EFFECT_LEARN_PET_SPELL: - if(Pet* pet = m_caster->GetPet()) - tmpUnitMap.push_back(pet); - break; - case SPELL_EFFECT_ENCHANT_ITEM: - case SPELL_EFFECT_ENCHANT_ITEM_TEMPORARY: - case SPELL_EFFECT_DISENCHANT: - case SPELL_EFFECT_FEED_PET: - case SPELL_EFFECT_PROSPECTING: - if(m_targets.getItemTarget()) - AddItemTarget(m_targets.getItemTarget(), i); - break; - case SPELL_EFFECT_APPLY_AURA: - switch(m_spellInfo->EffectApplyAuraName[i]) - { - case SPELL_AURA_ADD_FLAT_MODIFIER: // some spell mods auras have 0 target modes instead expected TARGET_SELF(1) (and present for other ranks for same spell for example) - case SPELL_AURA_ADD_PCT_MODIFIER: - tmpUnitMap.push_back(m_caster); - break; - default: // apply to target in other case - if(m_targets.getUnitTarget()) - tmpUnitMap.push_back(m_targets.getUnitTarget()); - break; - } - break; - case SPELL_EFFECT_APPLY_AREA_AURA_PARTY: - // AreaAura - if(m_spellInfo->Attributes == 0x9050000 || m_spellInfo->Attributes == 0x10000) - SetTargetMap(i,TARGET_AREAEFFECT_PARTY,tmpUnitMap); - break; - case SPELL_EFFECT_SKIN_PLAYER_CORPSE: - if(m_targets.getUnitTarget()) - { - tmpUnitMap.push_back(m_targets.getUnitTarget()); - } - else if (m_targets.getCorpseTargetGUID()) - { - Corpse *corpse = ObjectAccessor::GetCorpse(*m_caster,m_targets.getCorpseTargetGUID()); - if(corpse) - { - Player* owner = ObjectAccessor::FindPlayer(corpse->GetOwnerGUID()); - if(owner) - tmpUnitMap.push_back(owner); - } - } - break; - default: - break; - } - } - if(IsChanneledSpell(m_spellInfo) && !tmpUnitMap.empty()) - m_needAliveTargetMask |= (1<GetTypeId() == TYPEID_PLAYER) - { - Player *me = (Player*)m_caster; - for (std::list::const_iterator itr = tmpUnitMap.begin(); itr != tmpUnitMap.end(); itr++) - { - Unit *owner = (*itr)->GetOwner(); - Unit *u = owner ? owner : (*itr); - if(u!=m_caster && u->IsPvP() && (!me->duel || me->duel->opponent != u)) - { - me->UpdatePvP(true); - me->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_ENTER_PVP_COMBAT); - break; - } - } - } - - for (std::list::iterator itr = tmpUnitMap.begin() ; itr != tmpUnitMap.end();) - { - if(!CheckTarget(*itr, i, false )) - { - itr = tmpUnitMap.erase(itr); - continue; - } - else - ++itr; - } - - for(std::list::iterator iunit= tmpUnitMap.begin();iunit != tmpUnitMap.end();++iunit) - AddUnitTarget((*iunit), i); - } -} - -void Spell::CleanupTargetList() -{ - m_UniqueTargetInfo.clear(); - m_UniqueGOTargetInfo.clear(); - m_UniqueItemInfo.clear(); - m_countOfHit = 0; - m_countOfMiss = 0; - m_delayMoment = 0; -} - -void Spell::AddUnitTarget(Unit* pVictim, uint32 effIndex) -{ - if( m_spellInfo->Effect[effIndex]==0 ) - return; - - uint64 targetGUID = pVictim->GetGUID(); - - // Lookup target in already in list - for(std::list::iterator ihit= m_UniqueTargetInfo.begin();ihit != m_UniqueTargetInfo.end();++ihit) - { - if (targetGUID == ihit->targetGUID) // Found in list - { - ihit->effectMask |= 1<SpellHitResult(pVictim, m_spellInfo, m_canReflect); - if (target.missCondition == SPELL_MISS_NONE) - ++m_countOfHit; - else - ++m_countOfMiss; - - // Spell have speed - need calculate incoming time - if (m_spellInfo->speed > 0.0f) - { - // calculate spell incoming interval - float dist = m_caster->GetDistance(pVictim->GetPositionX(), pVictim->GetPositionY(), pVictim->GetPositionZ()); - if (dist < 5.0f) dist = 5.0f; - target.timeDelay = (uint64) floor(dist / m_spellInfo->speed * 1000.0f); - - // Calculate minimum incoming time - if (m_delayMoment==0 || m_delayMoment>target.timeDelay) - m_delayMoment = target.timeDelay; - } - else - target.timeDelay = 0LL; - - // If target reflect spell back to caster - if (target.missCondition==SPELL_MISS_REFLECT) - { - // Calculate reflected spell result on caster - target.reflectResult = m_caster->SpellHitResult(m_caster, m_spellInfo, m_canReflect); - - if (target.reflectResult == SPELL_MISS_REFLECT) // Impossible reflect again, so simply deflect spell - target.reflectResult = SPELL_MISS_PARRY; - - // Increase time interval for reflected spells by 1.5 - target.timeDelay+=target.timeDelay>>1; - } - else - target.reflectResult = SPELL_MISS_NONE; - - // Add target to list - m_UniqueTargetInfo.push_back(target); -} - -void Spell::AddUnitTarget(uint64 unitGUID, uint32 effIndex) -{ - Unit* unit = m_caster->GetGUID()==unitGUID ? m_caster : ObjectAccessor::GetUnit(*m_caster, unitGUID); - if (unit) - AddUnitTarget(unit, effIndex); -} - -void Spell::AddGOTarget(GameObject* pVictim, uint32 effIndex) -{ - if( m_spellInfo->Effect[effIndex]==0 ) - return; - - uint64 targetGUID = pVictim->GetGUID(); - - // Lookup target in already in list - for(std::list::iterator ihit= m_UniqueGOTargetInfo.begin();ihit != m_UniqueGOTargetInfo.end();++ihit) - { - if (targetGUID == ihit->targetGUID) // Found in list - { - ihit->effectMask |= 1<speed > 0.0f) - { - // calculate spell incoming interval - float dist = m_caster->GetDistance(pVictim->GetPositionX(), pVictim->GetPositionY(), pVictim->GetPositionZ()); - if (dist < 5.0f) dist = 5.0f; - target.timeDelay = (uint64) floor(dist / m_spellInfo->speed * 1000.0f); - if (m_delayMoment==0 || m_delayMoment>target.timeDelay) - m_delayMoment = target.timeDelay; - } - else - target.timeDelay = 0LL; - - ++m_countOfHit; - - // Add target to list - m_UniqueGOTargetInfo.push_back(target); -} - -void Spell::AddGOTarget(uint64 goGUID, uint32 effIndex) -{ - GameObject* go = ObjectAccessor::GetGameObject(*m_caster, goGUID); - if (go) - AddGOTarget(go, effIndex); -} - -void Spell::AddItemTarget(Item* pitem, uint32 effIndex) -{ - if( m_spellInfo->Effect[effIndex]==0 ) - return; - - // Lookup target in already in list - for(std::list::iterator ihit= m_UniqueItemInfo.begin();ihit != m_UniqueItemInfo.end();++ihit) - { - if (pitem == ihit->item) // Found in list - { - ihit->effectMask |= 1<GetTypeId()== TYPEID_PLAYER) - ((Player*)m_caster)->UpdateWeaponSkill(BASE_ATTACK); - - m_caster->CastMeleeProcDamageAndSpell(unitTarget, 0, damageSchoolMask, m_attackType, MELEE_HIT_MISS, m_spellInfo, m_IsTriggeredSpell); - break; - case SPELL_MISS_RESIST: - m_caster->ProcDamageAndSpell(unitTarget, PROC_FLAG_TARGET_RESISTS, PROC_FLAG_RESIST_SPELL, 0, damageSchoolMask, m_spellInfo, m_IsTriggeredSpell); - break; - case SPELL_MISS_DODGE: - if(unitTarget->GetTypeId() == TYPEID_PLAYER) - ((Player*)unitTarget)->UpdateDefense(); - - // Overpower - if (m_caster->GetTypeId() == TYPEID_PLAYER && m_caster->getClass() == CLASS_WARRIOR) - { - ((Player*) m_caster)->AddComboPoints(unitTarget, 1); - m_caster->StartReactiveTimer( REACTIVE_OVERPOWER ); - } - - // Riposte - if (unitTarget->getClass() != CLASS_ROGUE) - { - unitTarget->ModifyAuraState(AURA_STATE_DEFENSE, true); - unitTarget->StartReactiveTimer( REACTIVE_DEFENSE ); - } - - m_caster->CastMeleeProcDamageAndSpell(unitTarget, 0, damageSchoolMask, m_attackType, MELEE_HIT_DODGE, m_spellInfo, m_IsTriggeredSpell); - break; - case SPELL_MISS_PARRY: - // Update victim defense ? - if(unitTarget->GetTypeId() == TYPEID_PLAYER) - ((Player*)unitTarget)->UpdateDefense(); - // Mongoose bite - set only Counterattack here - if (unitTarget->getClass() == CLASS_HUNTER) - { - unitTarget->ModifyAuraState(AURA_STATE_HUNTER_PARRY,true); - unitTarget->StartReactiveTimer( REACTIVE_HUNTER_PARRY ); - } - else - { - unitTarget->ModifyAuraState(AURA_STATE_DEFENSE, true); - unitTarget->StartReactiveTimer( REACTIVE_DEFENSE ); - } - m_caster->CastMeleeProcDamageAndSpell(unitTarget, 0, damageSchoolMask, m_attackType, MELEE_HIT_PARRY, m_spellInfo, m_IsTriggeredSpell); - break; - case SPELL_MISS_BLOCK: - unitTarget->ModifyAuraState(AURA_STATE_DEFENSE, true); - unitTarget->StartReactiveTimer( REACTIVE_DEFENSE ); - - m_caster->CastMeleeProcDamageAndSpell(unitTarget, 0, damageSchoolMask, m_attackType, MELEE_HIT_BLOCK, m_spellInfo, m_IsTriggeredSpell); - break; - // Trigger from this events not supported - case SPELL_MISS_EVADE: - case SPELL_MISS_IMMUNE: - case SPELL_MISS_IMMUNE2: - case SPELL_MISS_DEFLECT: - case SPELL_MISS_ABSORB: - // Trigger from reflects need do after get reflect result - case SPELL_MISS_REFLECT: - break; - default: - break; - } - } -} - -void Spell::DoAllEffectOnTarget(TargetInfo *target) -{ - if (target->processed) // Check target - return; - target->processed = true; // Target checked in apply effects procedure - - // Get mask of effects for target - uint32 mask = target->effectMask; - if (mask == 0) // No effects - return; - - Unit* unit = m_caster->GetGUID()==target->targetGUID ? m_caster : ObjectAccessor::GetUnit(*m_caster,target->targetGUID); - if (!unit) - return; - - SpellMissInfo missInfo = target->missCondition; - // Need init unitTarget by default unit (can changed in code on reflect) - // Or on missInfo!=SPELL_MISS_NONE unitTarget undefined (but need in trigger subsystem) - unitTarget = unit; - - if (missInfo==SPELL_MISS_NONE) // In case spell hit target, do all effect on that target - DoSpellHitOnUnit(unit, mask); - else if (missInfo == SPELL_MISS_REFLECT) // In case spell reflect from target, do all effect on caster (if hit) - { - if (target->reflectResult == SPELL_MISS_NONE) // If reflected spell hit caster -> do all effect on him - DoSpellHitOnUnit(m_caster, mask); - } - - // Do triggers only on miss/resist/parry/dodge - if (missInfo!=SPELL_MISS_NONE) - doTriggers(missInfo); - - // Call scripted function for AI if this spell is casted upon a creature (except pets) - if(IS_CREATURE_GUID(target->targetGUID)) - { - // cast at creature (or GO) quest objectives update at successful cast finished (+channel finished) - // ignore autorepeat/melee casts for speed (not exist quest for spells (hm... ) - if( m_caster->GetTypeId() == TYPEID_PLAYER && !IsAutoRepeat() && !IsNextMeleeSwingSpell() && !IsChannelActive() ) - ((Player*)m_caster)->CastedCreatureOrGO(unit->GetEntry(),unit->GetGUID(),m_spellInfo->Id); - - if(((Creature*)unit)->AI()) - ((Creature*)unit)->AI()->SpellHit(m_caster ,m_spellInfo); - } -} - -void Spell::DoSpellHitOnUnit(Unit *unit, const uint32 effectMask) -{ - if(!unit || !effectMask) - return; - - // Recheck immune (only for delayed spells) - if( m_spellInfo->speed && ( - unit->IsImmunedToDamage(GetSpellSchoolMask(m_spellInfo),true) || - unit->IsImmunedToSpell(m_spellInfo,true) )) - { - m_caster->SendSpellMiss(unit, m_spellInfo->Id, SPELL_MISS_IMMUNE); - return; - } - - if( m_caster != unit ) - { - if( !m_caster->IsFriendlyTo(unit) ) - { - // for delayed spells ignore not visible explicit target - if(m_spellInfo->speed > 0.0f && unit==m_targets.getUnitTarget() && !unit->isVisibleForOrDetect(m_caster,false)) - { - m_caster->SendSpellMiss(unit, m_spellInfo->Id, SPELL_MISS_EVADE); - return; - } - - // exclude Arcane Missiles Dummy Aura aura for now (attack on hit) - // TODO: find way to not need this? - if(!(m_spellInfo->SpellFamilyName == SPELLFAMILY_MAGE && - m_spellInfo->SpellFamilyFlags & 0x800LL)) - { - unit->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); - - if( !(m_spellInfo->AttributesEx3 & SPELL_ATTR_EX3_NO_INITIAL_AGGRO) ) - { - if(!unit->IsStandState() && !unit->hasUnitState(UNIT_STAT_STUNDED)) - unit->SetStandState(PLAYER_STATE_NONE); - - if(!unit->isInCombat() && unit->GetTypeId() != TYPEID_PLAYER && ((Creature*)unit)->AI()) - ((Creature*)unit)->AI()->AttackStart(m_caster); - - unit->SetInCombatWith(m_caster); - m_caster->SetInCombatWith(unit); - - if(Player *attackedPlayer = unit->GetCharmerOrOwnerPlayerOrPlayerItself()) - { - m_caster->SetContestedPvP(attackedPlayer); - } - unit->AddThreat(m_caster, 0.0f); - } - } - } - else - { - // for delayed spells ignore negative spells (after duel end) for friendly targets - if(m_spellInfo->speed > 0.0f && !IsPositiveSpell(m_spellInfo->Id)) - { - m_caster->SendSpellMiss(unit, m_spellInfo->Id, SPELL_MISS_EVADE); - return; - } - - // assisting case, healing and resurrection - if(unit->hasUnitState(UNIT_STAT_ATTACK_PLAYER)) - m_caster->SetContestedPvP(); - if( unit->isInCombat() && !(m_spellInfo->AttributesEx3 & SPELL_ATTR_EX3_NO_INITIAL_AGGRO) ) - { - m_caster->SetInCombatState(unit->GetCombatTimer() > 0); - unit->getHostilRefManager().threatAssist(m_caster, 0.0f); - } - } - } - - // Get Data Needed for Diminishing Returns, some effects may have multiple auras, so this must be done on spell hit, not aura add - m_diminishGroup = GetDiminishingReturnsGroupForSpell(m_spellInfo,m_triggeredByAuraSpell); - m_diminishLevel = unit->GetDiminishing(m_diminishGroup); - // Increase Diminishing on unit, current informations for actually casts will use values above - if((GetDiminishingReturnsGroupType(m_diminishGroup) == DRTYPE_PLAYER && unit->GetTypeId() == TYPEID_PLAYER) || GetDiminishingReturnsGroupType(m_diminishGroup) == DRTYPE_ALL) - unit->IncrDiminishing(m_diminishGroup); - - for(uint32 effectNumber=0;effectNumber<3;effectNumber++) - { - if (effectMask & (1<DmgMultiplier[effectNumber]; - // Apply multiplier mods - if(Player* modOwner = m_originalCaster->GetSpellModOwner()) - modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_EFFECT_PAST_FIRST, multiplier,this); - m_damageMultipliers[effectNumber] *= multiplier; - } - } - } -} - -void Spell::DoAllEffectOnTarget(GOTargetInfo *target) -{ - if (target->processed) // Check target - return; - target->processed = true; // Target checked in apply effects procedure - - uint32 effectMask = target->effectMask; - if(!effectMask) - return; - - GameObject* go = ObjectAccessor::GetGameObject(*m_caster, target->targetGUID); - if(!go) - return; - - for(uint32 effectNumber=0;effectNumber<3;effectNumber++) - if (effectMask & (1<GetTypeId() == TYPEID_PLAYER && !IsAutoRepeat() && !IsNextMeleeSwingSpell() && !IsChannelActive() ) - ((Player*)m_caster)->CastedCreatureOrGO(go->GetEntry(),go->GetGUID(),m_spellInfo->Id); -} - -void Spell::DoAllEffectOnTarget(ItemTargetInfo *target) -{ - uint32 effectMask = target->effectMask; - if(!target->item || !effectMask) - return; - - for(uint32 effectNumber=0;effectNumber<3;effectNumber++) - if (effectMask & (1<item, NULL, effectNumber); -} - -bool Spell::IsAliveUnitPresentInTargetList() -{ - // Not need check return true - if (m_needAliveTargetMask == 0) - return true; - - uint8 needAliveTargetMask = m_needAliveTargetMask; - - for(std::list::iterator ihit= m_UniqueTargetInfo.begin();ihit != m_UniqueTargetInfo.end();++ihit) - { - if( ihit->missCondition == SPELL_MISS_NONE && (needAliveTargetMask & ihit->effectMask) ) - { - Unit *unit = m_caster->GetGUID()==ihit->targetGUID ? m_caster : ObjectAccessor::GetUnit(*m_caster, ihit->targetGUID); - - if (unit && unit->isAlive()) - needAliveTargetMask &= ~ihit->effectMask; // remove from need alive mask effect that have alive target - } - } - - // is all effects from m_needAliveTargetMask have alive targets - return needAliveTargetMask==0; -} - -// Helper for Chain Healing -// Spell target first -// Raidmates then descending by injury suffered (MaxHealth - Health) -// Other players/mobs then descending by injury suffered (MaxHealth - Health) -struct ChainHealingOrder : public std::binary_function -{ - const Unit* MainTarget; - ChainHealingOrder(Unit const* Target) : MainTarget(Target) {}; - // functor for operator ">" - bool operator()(Unit const* _Left, Unit const* _Right) const - { - return (ChainHealingHash(_Left) < ChainHealingHash(_Right)); - } - int32 ChainHealingHash(Unit const* Target) const - { - if (Target == MainTarget) - return 0; - else if (Target->GetTypeId() == TYPEID_PLAYER && MainTarget->GetTypeId() == TYPEID_PLAYER && - ((Player const*)Target)->IsInSameRaidWith((Player const*)MainTarget)) - { - if (Target->GetHealth() == Target->GetMaxHealth()) - return 40000; - else - return 20000 - Target->GetMaxHealth() + Target->GetHealth(); - } - else - return 40000 - Target->GetMaxHealth() + Target->GetHealth(); - } -}; - -class ChainHealingFullHealth: std::unary_function -{ - public: - const Unit* MainTarget; - ChainHealingFullHealth(const Unit* Target) : MainTarget(Target) {}; - - bool operator()(const Unit* Target) - { - return (Target != MainTarget && Target->GetHealth() == Target->GetMaxHealth()); - } -}; - -// Helper for targets nearest to the spell target -// The spell target is always first unless there is a target at _completely_ the same position (unbelievable case) -struct TargetDistanceOrder : public std::binary_function -{ - const Unit* MainTarget; - TargetDistanceOrder(const Unit* Target) : MainTarget(Target) {}; - // functor for operator ">" - bool operator()(const Unit* _Left, const Unit* _Right) const - { - return (MainTarget->GetDistance(_Left) < MainTarget->GetDistance(_Right)); - } -}; - -void Spell::SetTargetMap(uint32 i,uint32 cur,std::list &TagUnitMap) -{ - float radius; - if (m_spellInfo->EffectRadiusIndex[i]) - radius = GetSpellRadius(sSpellRadiusStore.LookupEntry(m_spellInfo->EffectRadiusIndex[i])); - else - radius = GetSpellMaxRange(sSpellRangeStore.LookupEntry(m_spellInfo->rangeIndex)); - - if(m_originalCaster) - if(Player* modOwner = m_originalCaster->GetSpellModOwner()) - modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_RADIUS, radius,this); - - uint32 EffectChainTarget = m_spellInfo->EffectChainTarget[i]; - if(m_originalCaster) - if(Player* modOwner = m_originalCaster->GetSpellModOwner()) - modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_JUMP_TARGETS, EffectChainTarget, this); - - uint32 unMaxTargets = m_spellInfo->MaxAffectedTargets; - switch(cur) - { - case TARGET_TOTEM_EARTH: - case TARGET_TOTEM_WATER: - case TARGET_TOTEM_AIR: - case TARGET_TOTEM_FIRE: - case TARGET_SELF: - case TARGET_SELF2: - case TARGET_DYNAMIC_OBJECT: - case TARGET_AREAEFFECT_CUSTOM: - case TARGET_AREAEFFECT_CUSTOM_2: - case TARGET_SUMMON: - { - TagUnitMap.push_back(m_caster); - break; - } - case TARGET_RANDOM_ENEMY_CHAIN_IN_AREA: - { - m_targets.m_targetMask = 0; - unMaxTargets = EffectChainTarget; - float max_range = radius + unMaxTargets * CHAIN_SPELL_JUMP_RADIUS; - - CellPair p(MaNGOS::ComputeCellPair(m_caster->GetPositionX(), m_caster->GetPositionY())); - Cell cell(p); - cell.data.Part.reserved = ALL_DISTRICT; - cell.SetNoCreate(); - - std::list tempUnitMap; - - { - MaNGOS::AnyAoETargetUnitInObjectRangeCheck u_check(m_caster, m_caster, max_range); - MaNGOS::UnitListSearcher searcher(tempUnitMap, u_check); - - TypeContainerVisitor, WorldTypeMapContainer > world_unit_searcher(searcher); - TypeContainerVisitor, GridTypeMapContainer > grid_unit_searcher(searcher); - - CellLock cell_lock(cell, p); - cell_lock->Visit(cell_lock, world_unit_searcher, *MapManager::Instance().GetMap(m_caster->GetMapId(), m_caster)); - cell_lock->Visit(cell_lock, grid_unit_searcher, *MapManager::Instance().GetMap(m_caster->GetMapId(), m_caster)); - } - - if(tempUnitMap.empty()) - break; - - tempUnitMap.sort(TargetDistanceOrder(m_caster)); - - //Now to get us a random target that's in the initial range of the spell - uint32 t = 0; - std::list::iterator itr = tempUnitMap.begin(); - while(itr!= tempUnitMap.end() && (*itr)->GetDistance(m_caster) < radius) - ++t, ++itr; - - if(!t) - break; - - itr = tempUnitMap.begin(); - std::advance(itr, rand()%t); - Unit *pUnitTarget = *itr; - TagUnitMap.push_back(pUnitTarget); - - tempUnitMap.erase(itr); - - tempUnitMap.sort(TargetDistanceOrder(pUnitTarget)); - - t = unMaxTargets - 1; - Unit *prev = pUnitTarget; - std::list::iterator next = tempUnitMap.begin(); - - while(t && next != tempUnitMap.end() ) - { - if(prev->GetDistance(*next) > CHAIN_SPELL_JUMP_RADIUS) - break; - - if(!prev->IsWithinLOSInMap(*next)) - { - ++next; - continue; - } - - prev = *next; - TagUnitMap.push_back(prev); - tempUnitMap.erase(next); - tempUnitMap.sort(TargetDistanceOrder(prev)); - next = tempUnitMap.begin(); - - --t; - } - }break; - case TARGET_PET: - { - Pet* tmpUnit = m_caster->GetPet(); - if (!tmpUnit) break; - TagUnitMap.push_back(tmpUnit); - break; - } - case TARGET_CHAIN_DAMAGE: - { - if (EffectChainTarget <= 1) - { - Unit* pUnitTarget = SelectMagnetTarget(); - if(pUnitTarget) - TagUnitMap.push_back(pUnitTarget); - } - else - { - Unit* pUnitTarget = m_targets.getUnitTarget(); - if(!pUnitTarget) - break; - - unMaxTargets = EffectChainTarget; - - float max_range; - if(m_spellInfo->DmgClass==SPELL_DAMAGE_CLASS_MELEE) - max_range = radius; // - else - //FIXME: This very like horrible hack and wrong for most spells - max_range = radius + unMaxTargets * CHAIN_SPELL_JUMP_RADIUS; - - CellPair p(MaNGOS::ComputeCellPair(m_caster->GetPositionX(), m_caster->GetPositionY())); - Cell cell(p); - cell.data.Part.reserved = ALL_DISTRICT; - cell.SetNoCreate(); - - Unit* originalCaster = GetOriginalCaster(); - if(originalCaster) - { - std::list tempUnitMap; - - { - MaNGOS::AnyAoETargetUnitInObjectRangeCheck u_check(pUnitTarget, originalCaster, max_range); - MaNGOS::UnitListSearcher searcher(tempUnitMap, u_check); - - TypeContainerVisitor, WorldTypeMapContainer > world_unit_searcher(searcher); - TypeContainerVisitor, GridTypeMapContainer > grid_unit_searcher(searcher); - - CellLock cell_lock(cell, p); - cell_lock->Visit(cell_lock, world_unit_searcher, *MapManager::Instance().GetMap(m_caster->GetMapId(), m_caster)); - cell_lock->Visit(cell_lock, grid_unit_searcher, *MapManager::Instance().GetMap(m_caster->GetMapId(), m_caster)); - } - - tempUnitMap.sort(TargetDistanceOrder(pUnitTarget)); - - if(tempUnitMap.empty()) - break; - - if(*tempUnitMap.begin() == pUnitTarget) - tempUnitMap.erase(tempUnitMap.begin()); - - TagUnitMap.push_back(pUnitTarget); - uint32 t = unMaxTargets - 1; - Unit *prev = pUnitTarget; - std::list::iterator next = tempUnitMap.begin(); - - while(t && next != tempUnitMap.end() ) - { - if(prev->GetDistance(*next) > CHAIN_SPELL_JUMP_RADIUS) - break; - - if(!prev->IsWithinLOSInMap(*next)) - { - ++next; - continue; - } - - prev = *next; - TagUnitMap.push_back(prev); - tempUnitMap.erase(next); - tempUnitMap.sort(TargetDistanceOrder(prev)); - next = tempUnitMap.begin(); - - --t; - } - } - } - }break; - case TARGET_ALL_ENEMY_IN_AREA: - { - }break; - case TARGET_ALL_ENEMY_IN_AREA_INSTANT: - { - // targets the ground, not the units in the area - if (m_spellInfo->Effect[i]!=SPELL_EFFECT_PERSISTENT_AREA_AURA) - { - CellPair p(MaNGOS::ComputeCellPair(m_targets.m_destX, m_targets.m_destY)); - Cell cell(p); - cell.data.Part.reserved = ALL_DISTRICT; - cell.SetNoCreate(); - - MaNGOS::SpellNotifierCreatureAndPlayer notifier(*this, TagUnitMap, radius, PUSH_DEST_CENTER,SPELL_TARGETS_AOE_DAMAGE); - - TypeContainerVisitor world_object_notifier(notifier); - TypeContainerVisitor grid_object_notifier(notifier); - - CellLock cell_lock(cell, p); - cell_lock->Visit(cell_lock, world_object_notifier, *MapManager::Instance().GetMap(m_caster->GetMapId(), m_caster)); - cell_lock->Visit(cell_lock, grid_object_notifier, *MapManager::Instance().GetMap(m_caster->GetMapId(), m_caster)); - - // exclude caster (this can be important if this not original caster) - TagUnitMap.remove(m_caster); - } - }break; - case TARGET_DUELVSPLAYER_COORDINATES: - { - if(Unit* currentTarget = m_targets.getUnitTarget()) - { - m_targets.setDestination(currentTarget->GetPositionX(), currentTarget->GetPositionY(), currentTarget->GetPositionZ()); - TagUnitMap.push_back(currentTarget); - } - }break; - case TARGET_ALL_PARTY_AROUND_CASTER: - case TARGET_ALL_PARTY_AROUND_CASTER_2: - case TARGET_ALL_PARTY: - { - Player *pTarget = m_caster->GetCharmerOrOwnerPlayerOrPlayerItself(); - Group *pGroup = pTarget ? pTarget->GetGroup() : NULL; - - if(pGroup) - { - uint8 subgroup = pTarget->GetSubGroup(); - - for(GroupReference *itr = pGroup->GetFirstMember(); itr != NULL; itr = itr->next()) - { - Player* Target = itr->getSource(); - - // IsHostileTo check duel and controlled by enemy - if( Target && Target->GetSubGroup()==subgroup && !m_caster->IsHostileTo(Target) ) - { - if( m_caster->IsWithinDistInMap(Target, radius) ) - TagUnitMap.push_back(Target); - - if(Pet* pet = Target->GetPet()) - if( m_caster->IsWithinDistInMap(pet, radius) ) - TagUnitMap.push_back(pet); - } - } - } - else - { - Unit* ownerOrSelf = pTarget ? pTarget : m_caster->GetCharmerOrOwnerOrSelf(); - if(ownerOrSelf==m_caster || m_caster->IsWithinDistInMap(ownerOrSelf, radius)) - TagUnitMap.push_back(ownerOrSelf); - if(Pet* pet = ownerOrSelf->GetPet()) - if( m_caster->IsWithinDistInMap(pet, radius) ) - TagUnitMap.push_back(pet); - } - }break; - case TARGET_RANDOM_RAID_MEMBER: - { - if (m_caster->GetTypeId() == TYPEID_PLAYER) - if(Player* target = ((Player*)m_caster)->GetNextRandomRaidMember(radius)) - TagUnitMap.push_back(target); - }break; - case TARGET_SINGLE_FRIEND: - case TARGET_SINGLE_FRIEND_2: - { - if(m_targets.getUnitTarget()) - TagUnitMap.push_back(m_targets.getUnitTarget()); - }break; - case TARGET_NONCOMBAT_PET: - { - if(Unit* target = m_targets.getUnitTarget()) - if( target->GetTypeId() == TYPEID_UNIT && ((Creature*)target)->isPet() && ((Pet*)target)->getPetType() == MINI_PET) - TagUnitMap.push_back(target); - }break; - case TARGET_ALL_AROUND_CASTER: - { - CellPair p(MaNGOS::ComputeCellPair(m_caster->GetPositionX(), m_caster->GetPositionY())); - Cell cell(p); - cell.data.Part.reserved = ALL_DISTRICT; - cell.SetNoCreate(); - - MaNGOS::SpellNotifierCreatureAndPlayer notifier(*this, TagUnitMap, radius, PUSH_SELF_CENTER,SPELL_TARGETS_AOE_DAMAGE); - - TypeContainerVisitor world_object_notifier(notifier); - TypeContainerVisitor grid_object_notifier(notifier); - - CellLock cell_lock(cell, p); - cell_lock->Visit(cell_lock, world_object_notifier, *MapManager::Instance().GetMap(m_caster->GetMapId(), m_caster)); - cell_lock->Visit(cell_lock, grid_object_notifier, *MapManager::Instance().GetMap(m_caster->GetMapId(), m_caster)); - }break; - case TARGET_ALL_FRIENDLY_UNITS_AROUND_CASTER: - { - CellPair p(MaNGOS::ComputeCellPair(m_caster->GetPositionX(), m_caster->GetPositionY())); - Cell cell(p); - cell.data.Part.reserved = ALL_DISTRICT; - cell.SetNoCreate(); - - MaNGOS::SpellNotifierCreatureAndPlayer notifier(*this, TagUnitMap, radius, PUSH_SELF_CENTER,SPELL_TARGETS_FRIENDLY); - - TypeContainerVisitor world_object_notifier(notifier); - TypeContainerVisitor grid_object_notifier(notifier); - - CellLock cell_lock(cell, p); - cell_lock->Visit(cell_lock, world_object_notifier, *MapManager::Instance().GetMap(m_caster->GetMapId(), m_caster)); - cell_lock->Visit(cell_lock, grid_object_notifier, *MapManager::Instance().GetMap(m_caster->GetMapId(), m_caster)); - }break; - case TARGET_ALL_FRIENDLY_UNITS_IN_AREA: - { - CellPair p(MaNGOS::ComputeCellPair(m_targets.m_destX, m_targets.m_destY)); - Cell cell(p); - cell.data.Part.reserved = ALL_DISTRICT; - cell.SetNoCreate(); - - MaNGOS::SpellNotifierCreatureAndPlayer notifier(*this, TagUnitMap, radius, PUSH_DEST_CENTER,SPELL_TARGETS_FRIENDLY); - - TypeContainerVisitor world_object_notifier(notifier); - TypeContainerVisitor grid_object_notifier(notifier); - - CellLock cell_lock(cell, p); - cell_lock->Visit(cell_lock, world_object_notifier, *MapManager::Instance().GetMap(m_caster->GetMapId(), m_caster)); - cell_lock->Visit(cell_lock, grid_object_notifier, *MapManager::Instance().GetMap(m_caster->GetMapId(), m_caster)); - }break; - // TARGET_SINGLE_PARTY means that the spells can only be casted on a party member and not on the caster (some sceals, fire shield from imp, etc..) - case TARGET_SINGLE_PARTY: - { - Unit *target = m_targets.getUnitTarget(); - // Thoses spells apparently can't be casted on the caster. - if( target && target != m_caster) - { - // Can only be casted on group's members or its pets - Group *pGroup = NULL; - - Unit* owner = m_caster->GetCharmerOrOwner(); - Unit *targetOwner = target->GetCharmerOrOwner(); - if(owner) - { - if(owner->GetTypeId() == TYPEID_PLAYER) - { - if( target == owner ) - { - TagUnitMap.push_back(target); - break; - } - pGroup = ((Player*)owner)->GetGroup(); - } - } - else if (m_caster->GetTypeId() == TYPEID_PLAYER) - { - if( targetOwner == m_caster && target->GetTypeId()==TYPEID_UNIT && ((Creature*)target)->isPet()) - { - TagUnitMap.push_back(target); - break; - } - pGroup = ((Player*)m_caster)->GetGroup(); - } - - if(pGroup) - { - // Our target can also be a player's pet who's grouped with us or our pet. But can't be controlled player - if(targetOwner) - { - if( targetOwner->GetTypeId() == TYPEID_PLAYER && - target->GetTypeId()==TYPEID_UNIT && (((Creature*)target)->isPet()) && - target->GetOwnerGUID()==targetOwner->GetGUID() && - pGroup->IsMember(((Player*)targetOwner)->GetGUID())) - { - TagUnitMap.push_back(target); - } - } - // 1Our target can be a player who is on our group - else if (target->GetTypeId() == TYPEID_PLAYER && pGroup->IsMember(((Player*)target)->GetGUID())) - { - TagUnitMap.push_back(target); - } - } - } - }break; - case TARGET_GAMEOBJECT: - { - if(m_targets.getGOTarget()) - AddGOTarget(m_targets.getGOTarget(), i); - }break; - case TARGET_IN_FRONT_OF_CASTER: - { - CellPair p(MaNGOS::ComputeCellPair(m_caster->GetPositionX(), m_caster->GetPositionY())); - Cell cell(p); - cell.data.Part.reserved = ALL_DISTRICT; - cell.SetNoCreate(); - - bool inFront = m_spellInfo->SpellVisual != 3879; - MaNGOS::SpellNotifierCreatureAndPlayer notifier(*this, TagUnitMap, radius, inFront ? PUSH_IN_FRONT : PUSH_IN_BACK,SPELL_TARGETS_AOE_DAMAGE); - - TypeContainerVisitor world_object_notifier(notifier); - TypeContainerVisitor grid_object_notifier(notifier); - - CellLock cell_lock(cell, p); - cell_lock->Visit(cell_lock, world_object_notifier, *MapManager::Instance().GetMap(m_caster->GetMapId(), m_caster)); - cell_lock->Visit(cell_lock, grid_object_notifier, *MapManager::Instance().GetMap(m_caster->GetMapId(), m_caster)); - }break; - case TARGET_DUELVSPLAYER: - { - Unit *target = m_targets.getUnitTarget(); - if(target) - { - if(m_caster->IsFriendlyTo(target)) - { - TagUnitMap.push_back(target); - } - else - { - Unit* pUnitTarget = SelectMagnetTarget(); - if(pUnitTarget) - TagUnitMap.push_back(pUnitTarget); - } - } - }break; - case TARGET_GAMEOBJECT_ITEM: - { - if(m_targets.getGOTargetGUID()) - AddGOTarget(m_targets.getGOTarget(), i); - else if(m_targets.getItemTarget()) - AddItemTarget(m_targets.getItemTarget(), i); - break; - } - case TARGET_MASTER: - { - if(Unit* owner = m_caster->GetCharmerOrOwner()) - TagUnitMap.push_back(owner); - break; - } - case TARGET_ALL_ENEMY_IN_AREA_CHANNELED: - { - // targets the ground, not the units in the area - if (m_spellInfo->Effect[i]!=SPELL_EFFECT_PERSISTENT_AREA_AURA) - { - CellPair p(MaNGOS::ComputeCellPair(m_caster->GetPositionX(), m_caster->GetPositionY())); - Cell cell(p); - cell.data.Part.reserved = ALL_DISTRICT; - cell.SetNoCreate(); - - MaNGOS::SpellNotifierCreatureAndPlayer notifier(*this, TagUnitMap, radius, PUSH_DEST_CENTER,SPELL_TARGETS_AOE_DAMAGE); - - TypeContainerVisitor world_object_notifier(notifier); - TypeContainerVisitor grid_object_notifier(notifier); - - CellLock cell_lock(cell, p); - cell_lock->Visit(cell_lock, world_object_notifier, *MapManager::Instance().GetMap(m_caster->GetMapId(), m_caster)); - cell_lock->Visit(cell_lock, grid_object_notifier, *MapManager::Instance().GetMap(m_caster->GetMapId(), m_caster)); - } - }break; - case TARGET_MINION: - { - if(m_spellInfo->Effect[i] != SPELL_EFFECT_DUEL) - TagUnitMap.push_back(m_caster); - }break; - case TARGET_SINGLE_ENEMY: - { - Unit* pUnitTarget = SelectMagnetTarget(); - if(pUnitTarget) - TagUnitMap.push_back(pUnitTarget); - }break; - case TARGET_AREAEFFECT_PARTY: - { - Unit* owner = m_caster->GetCharmerOrOwner(); - Player *pTarget = NULL; - - if(owner) - { - TagUnitMap.push_back(m_caster); - if(owner->GetTypeId() == TYPEID_PLAYER) - pTarget = (Player*)owner; - } - else if (m_caster->GetTypeId() == TYPEID_PLAYER) - { - if(Unit* target = m_targets.getUnitTarget()) - { - if( target->GetTypeId() != TYPEID_PLAYER) - { - if(((Creature*)target)->isPet()) - { - Unit *targetOwner = target->GetOwner(); - if(targetOwner->GetTypeId() == TYPEID_PLAYER) - pTarget = (Player*)targetOwner; - } - } - else - pTarget = (Player*)target; - } - } - - Group* pGroup = pTarget ? pTarget->GetGroup() : NULL; - - if(pGroup) - { - uint8 subgroup = pTarget->GetSubGroup(); - - for(GroupReference *itr = pGroup->GetFirstMember(); itr != NULL; itr = itr->next()) - { - Player* Target = itr->getSource(); - - // IsHostileTo check duel and controlled by enemy - if(Target && Target->GetSubGroup()==subgroup && !m_caster->IsHostileTo(Target)) - { - if( pTarget->IsWithinDistInMap(Target, radius) ) - TagUnitMap.push_back(Target); - - if(Pet* pet = Target->GetPet()) - if( pTarget->IsWithinDistInMap(pet, radius) ) - TagUnitMap.push_back(pet); - } - } - } - else if (owner) - { - if(m_caster->IsWithinDistInMap(owner, radius)) - TagUnitMap.push_back(owner); - } - else if(pTarget) - { - TagUnitMap.push_back(pTarget); - - if(Pet* pet = pTarget->GetPet()) - if( m_caster->IsWithinDistInMap(pet, radius) ) - TagUnitMap.push_back(pet); - } - - }break; - case TARGET_SCRIPT: - { - if(m_targets.getUnitTarget()) - TagUnitMap.push_back(m_targets.getUnitTarget()); - if(m_targets.getItemTarget()) - AddItemTarget(m_targets.getItemTarget(), i); - }break; - case TARGET_SELF_FISHING: - { - TagUnitMap.push_back(m_caster); - }break; - case TARGET_CHAIN_HEAL: - { - Unit* pUnitTarget = m_targets.getUnitTarget(); - if(!pUnitTarget) - break; - - if (EffectChainTarget <= 1) - TagUnitMap.push_back(pUnitTarget); - else - { - unMaxTargets = EffectChainTarget; - float max_range = radius + unMaxTargets * CHAIN_SPELL_JUMP_RADIUS; - - std::list tempUnitMap; - - { - CellPair p(MaNGOS::ComputeCellPair(m_caster->GetPositionX(), m_caster->GetPositionY())); - Cell cell(p); - cell.data.Part.reserved = ALL_DISTRICT; - cell.SetNoCreate(); - - MaNGOS::SpellNotifierCreatureAndPlayer notifier(*this, tempUnitMap, max_range, PUSH_SELF_CENTER, SPELL_TARGETS_FRIENDLY); - - TypeContainerVisitor world_object_notifier(notifier); - TypeContainerVisitor grid_object_notifier(notifier); - - CellLock cell_lock(cell, p); - cell_lock->Visit(cell_lock, world_object_notifier, *MapManager::Instance().GetMap(m_caster->GetMapId(), m_caster)); - cell_lock->Visit(cell_lock, grid_object_notifier, *MapManager::Instance().GetMap(m_caster->GetMapId(), m_caster)); - - } - - if(m_caster != pUnitTarget && std::find(tempUnitMap.begin(),tempUnitMap.end(),m_caster) == tempUnitMap.end() ) - tempUnitMap.push_front(m_caster); - - tempUnitMap.sort(TargetDistanceOrder(pUnitTarget)); - - if(tempUnitMap.empty()) - break; - - if(*tempUnitMap.begin() == pUnitTarget) - tempUnitMap.erase(tempUnitMap.begin()); - - TagUnitMap.push_back(pUnitTarget); - uint32 t = unMaxTargets - 1; - Unit *prev = pUnitTarget; - std::list::iterator next = tempUnitMap.begin(); - - while(t && next != tempUnitMap.end() ) - { - if(prev->GetDistance(*next) > CHAIN_SPELL_JUMP_RADIUS) - break; - - if(!prev->IsWithinLOSInMap(*next)) - { - ++next; - continue; - } - - if((*next)->GetHealth() == (*next)->GetMaxHealth()) - { - next = tempUnitMap.erase(next); - continue; - } - - prev = *next; - TagUnitMap.push_back(prev); - tempUnitMap.erase(next); - tempUnitMap.sort(TargetDistanceOrder(prev)); - next = tempUnitMap.begin(); - - --t; - } - } - }break; - case TARGET_CURRENT_ENEMY_COORDINATES: - { - Unit* currentTarget = m_targets.getUnitTarget(); - if(currentTarget) - { - TagUnitMap.push_back(currentTarget); - m_targets.setDestination(currentTarget->GetPositionX(), currentTarget->GetPositionY(), currentTarget->GetPositionZ()); - if(m_spellInfo->EffectImplicitTargetB[i]==TARGET_ALL_ENEMY_IN_AREA_INSTANT) - { - CellPair p(MaNGOS::ComputeCellPair(currentTarget->GetPositionX(), currentTarget->GetPositionY())); - Cell cell(p); - cell.data.Part.reserved = ALL_DISTRICT; - cell.SetNoCreate(); - MaNGOS::SpellNotifierCreatureAndPlayer notifier(*this, TagUnitMap, radius,PUSH_TARGET_CENTER, SPELL_TARGETS_AOE_DAMAGE); - TypeContainerVisitor world_notifier(notifier); - TypeContainerVisitor grid_notifier(notifier); - CellLock cell_lock(cell, p); - cell_lock->Visit(cell_lock, world_notifier, *MapManager::Instance().GetMap(m_caster->GetMapId(), m_caster)); - cell_lock->Visit(cell_lock, grid_notifier, *MapManager::Instance().GetMap(m_caster->GetMapId(), m_caster)); - } - } - }break; - case TARGET_AREAEFFECT_PARTY_AND_CLASS: - { - Player* targetPlayer = m_targets.getUnitTarget() && m_targets.getUnitTarget()->GetTypeId() == TYPEID_PLAYER - ? (Player*)m_targets.getUnitTarget() : NULL; - - Group* pGroup = targetPlayer ? targetPlayer->GetGroup() : NULL; - if(pGroup) - { - for(GroupReference *itr = pGroup->GetFirstMember(); itr != NULL; itr = itr->next()) - { - Player* Target = itr->getSource(); - - // IsHostileTo check duel and controlled by enemy - if( Target && targetPlayer->IsWithinDistInMap(Target, radius) && - targetPlayer->getClass() == Target->getClass() && - !m_caster->IsHostileTo(Target) ) - { - TagUnitMap.push_back(Target); - } - } - } - else if(m_targets.getUnitTarget()) - TagUnitMap.push_back(m_targets.getUnitTarget()); - break; - } - case TARGET_TABLE_X_Y_Z_COORDINATES: - { - SpellTargetPosition const* st = spellmgr.GetSpellTargetPosition(m_spellInfo->Id); - if(st) - { - if (st->target_mapId == m_caster->GetMapId()) - m_targets.setDestination(st->target_X, st->target_Y, st->target_Z); - - // if B==TARGET_TABLE_X_Y_Z_COORDINATES then A already fill all required targets - if (m_spellInfo->EffectImplicitTargetB[i] && m_spellInfo->EffectImplicitTargetB[i]!=TARGET_TABLE_X_Y_Z_COORDINATES) - { - CellPair p(MaNGOS::ComputeCellPair(m_caster->GetPositionX(), m_caster->GetPositionY())); - Cell cell(p); - cell.data.Part.reserved = ALL_DISTRICT; - cell.SetNoCreate(); - - SpellTargets targetB = SPELL_TARGETS_AOE_DAMAGE; - // Select friendly targets for positive effect - if (IsPositiveEffect(m_spellInfo->Id, i)) - targetB = SPELL_TARGETS_FRIENDLY; - - MaNGOS::SpellNotifierCreatureAndPlayer notifier(*this, TagUnitMap, radius,PUSH_DEST_CENTER, targetB); - - TypeContainerVisitor world_notifier(notifier); - TypeContainerVisitor grid_notifier(notifier); - - CellLock cell_lock(cell, p); - cell_lock->Visit(cell_lock, world_notifier, *MapManager::Instance().GetMap(m_caster->GetMapId(), m_caster)); - cell_lock->Visit(cell_lock, grid_notifier, *MapManager::Instance().GetMap(m_caster->GetMapId(), m_caster)); - } - } - else - sLog.outError( "SPELL: unknown target coordinates for spell ID %u\n", m_spellInfo->Id ); - }break; - case TARGET_BEHIND_VICTIM: - { - Unit *pTarget = m_caster->getVictim(); - if(!pTarget && m_caster->GetTypeId() == TYPEID_PLAYER) - pTarget = ObjectAccessor::GetUnit(*m_caster, ((Player*)m_caster)->GetSelection()); - - if(pTarget) - { - float _target_x, _target_y, _target_z; - pTarget->GetClosePoint(_target_x, _target_y, _target_z, m_caster->GetObjectSize(), CONTACT_DISTANCE, M_PI); - if(pTarget->IsWithinLOS(_target_x,_target_y,_target_z)) - m_targets.setDestination(_target_x, _target_y, _target_z); - } - }break; - default: - break; - } - - if (unMaxTargets && TagUnitMap.size() > unMaxTargets) - { - // make sure one unit is always removed per iteration - uint32 removed_utarget = 0; - for (std::list::iterator itr = TagUnitMap.begin(), next; itr != TagUnitMap.end(); itr = next) - { - next = itr; - ++next; - if (!*itr) continue; - if ((*itr) == m_targets.getUnitTarget()) - { - TagUnitMap.erase(itr); - removed_utarget = 1; - // break; - } - } - // remove random units from the map - while (TagUnitMap.size() > unMaxTargets - removed_utarget) - { - uint32 poz = urand(0, TagUnitMap.size()-1); - for (std::list::iterator itr = TagUnitMap.begin(); itr != TagUnitMap.end(); ++itr, --poz) - { - if (!*itr) continue; - if (!poz) - { - TagUnitMap.erase(itr); - break; - } - } - } - // the player's target will always be added to the map - if (removed_utarget && m_targets.getUnitTarget()) - TagUnitMap.push_back(m_targets.getUnitTarget()); - } -} - -void Spell::prepare(SpellCastTargets * targets, Aura* triggeredByAura) -{ - m_targets = *targets; - - m_spellState = SPELL_STATE_PREPARING; - - m_castPositionX = m_caster->GetPositionX(); - m_castPositionY = m_caster->GetPositionY(); - m_castPositionZ = m_caster->GetPositionZ(); - m_castOrientation = m_caster->GetOrientation(); - - if(triggeredByAura) - m_triggeredByAuraSpell = triggeredByAura->GetSpellProto(); - - // create and add update event for this spell - SpellEvent* Event = new SpellEvent(this); - m_caster->m_Events.AddEvent(Event, m_caster->m_Events.CalculateTime(1)); - - //Prevent casting at cast another spell (ServerSide check) - if(m_caster->IsNonMeleeSpellCasted(false, true) && m_cast_count) - { - SendCastResult(SPELL_FAILED_SPELL_IN_PROGRESS); - finish(false); - return; - } - - // Fill cost data - m_powerCost = CalculatePowerCost(); - - uint8 result = CanCast(true); - if(result != 0 && !IsAutoRepeat()) //always cast autorepeat dummy for triggering - { - if(triggeredByAura) - { - SendChannelUpdate(0); - triggeredByAura->SetAuraDuration(0); - } - SendCastResult(result); - finish(false); - return; - } - - // calculate cast time (calculated after first CanCast check to prevent charge counting for first CanCast fail) - m_casttime = GetSpellCastTime(m_spellInfo, this); - - // set timer base at cast time - ReSetTimer(); - - // stealth must be removed at cast starting (at show channel bar) - // skip triggered spell (item equip spell casting and other not explicit character casts/item uses) - if ( !m_IsTriggeredSpell && isSpellBreakStealth(m_spellInfo) ) - { - m_caster->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); - m_caster->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH); - } - - if(m_IsTriggeredSpell) - cast(true); - else - { - m_caster->SetCurrentCastedSpell( this ); - m_selfContainer = &(m_caster->m_currentSpells[GetCurrentContainer()]); - SendSpellStart(); - } -} - -void Spell::cancel() -{ - if(m_spellState == SPELL_STATE_FINISHED) - return; - - m_autoRepeat = false; - switch (m_spellState) - { - case SPELL_STATE_PREPARING: - case SPELL_STATE_DELAYED: - { - SendInterrupted(0); - SendCastResult(SPELL_FAILED_INTERRUPTED); - } break; - - case SPELL_STATE_CASTING: - { - for(std::list::iterator ihit= m_UniqueTargetInfo.begin();ihit != m_UniqueTargetInfo.end();++ihit) - { - if( ihit->missCondition == SPELL_MISS_NONE ) - { - Unit* unit = m_caster->GetGUID()==(*ihit).targetGUID ? m_caster : ObjectAccessor::GetUnit(*m_caster, ihit->targetGUID); - if( unit && unit->isAlive() ) - unit->RemoveAurasDueToSpell(m_spellInfo->Id); - } - } - - m_caster->RemoveAurasDueToSpell(m_spellInfo->Id); - SendChannelUpdate(0); - SendInterrupted(0); - SendCastResult(SPELL_FAILED_INTERRUPTED); - } break; - - default: - { - } break; - } - - finish(false); - m_caster->RemoveDynObject(m_spellInfo->Id); - m_caster->RemoveGameObject(m_spellInfo->Id,true); -} - -void Spell::cast(bool skipCheck) -{ - uint8 castResult = 0; - - // update pointers base at GUIDs to prevent access to non-existed already object - UpdatePointers(); - - // cancel at lost main target unit - if(!m_targets.getUnitTarget() && m_targets.getUnitTargetGUID() && m_targets.getUnitTargetGUID() != m_caster->GetGUID()) - { - cancel(); - return; - } - - if(m_caster->GetTypeId() != TYPEID_PLAYER && m_targets.getUnitTarget() && m_targets.getUnitTarget() != m_caster) - m_caster->SetInFront(m_targets.getUnitTarget()); - - castResult = CheckPower(); - if(castResult != 0) - { - SendCastResult(castResult); - finish(false); - return; - } - - // triggered cast called from Spell::prepare where it was already checked - if(!skipCheck) - { - castResult = CanCast(false); - if(castResult != 0) - { - SendCastResult(castResult); - finish(false); - return; - } - } - - // Conflagrate - consumes immolate - if ((m_spellInfo->TargetAuraState == AURA_STATE_IMMOLATE) && m_targets.getUnitTarget()) - { - // for caster applied auras only - Unit::AuraList const &mPeriodic = m_targets.getUnitTarget()->GetAurasByType(SPELL_AURA_PERIODIC_DAMAGE); - for(Unit::AuraList::const_iterator i = mPeriodic.begin(); i != mPeriodic.end(); ++i) - { - if( (*i)->GetSpellProto()->SpellFamilyName == SPELLFAMILY_WARLOCK && ((*i)->GetSpellProto()->SpellFamilyFlags & 4) && - (*i)->GetCasterGUID()==m_caster->GetGUID() ) - { - m_targets.getUnitTarget()->RemoveAura((*i)->GetId(), (*i)->GetEffIndex()); - break; - } - } - } - - // traded items have trade slot instead of guid in m_itemTargetGUID - // set to real guid to be sent later to the client - m_targets.updateTradeSlotItem(); - - // CAST SPELL - SendSpellCooldown(); - - TakePower(); - TakeReagents(); // we must remove reagents before HandleEffects to allow place crafted item in same slot - FillTargetMap(); - - if(m_spellState == SPELL_STATE_FINISHED) // stop cast if spell marked as finish somewhere in Take*/FillTargetMap - return; - - SendCastResult(castResult); - SendSpellGo(); // we must send smsg_spell_go packet before m_castItem delete in TakeCastItem()... - - // Pass cast spell event to handler (not send triggered by aura spells) - if (m_spellInfo->DmgClass != SPELL_DAMAGE_CLASS_MELEE && m_spellInfo->DmgClass != SPELL_DAMAGE_CLASS_RANGED && !m_triggeredByAuraSpell) - { - m_caster->ProcDamageAndSpell(m_targets.getUnitTarget(), PROC_FLAG_CAST_SPELL, PROC_FLAG_NONE, 0, SPELL_SCHOOL_MASK_NONE, m_spellInfo, m_IsTriggeredSpell); - - // update pointers base at GUIDs to prevent access to non-existed already object - UpdatePointers(); // pointers can be invalidate at triggered spell casting - } - - // Okay, everything is prepared. Now we need to distinguish between immediate and evented delayed spells - if (m_spellInfo->speed > 0.0f) - { - - // Remove used for cast item if need (it can be already NULL after TakeReagents call - // in case delayed spell remove item at cast delay start - TakeCastItem(); - - // Okay, maps created, now prepare flags - m_immediateHandled = false; - m_spellState = SPELL_STATE_DELAYED; - SetDelayStart(0); - } - else - { - // Immediate spell, no big deal - handle_immediate(); - } -} - -void Spell::handle_immediate() -{ - // start channeling if applicable - if(IsChanneledSpell(m_spellInfo)) - { - m_spellState = SPELL_STATE_CASTING; - SendChannelStart(GetSpellDuration(m_spellInfo)); - } - - // process immediate effects (items, ground, etc.) also initialize some variables - _handle_immediate_phase(); - - for(std::list::iterator ihit= m_UniqueTargetInfo.begin();ihit != m_UniqueTargetInfo.end();++ihit) - DoAllEffectOnTarget(&(*ihit)); - - for(std::list::iterator ihit= m_UniqueGOTargetInfo.begin();ihit != m_UniqueGOTargetInfo.end();++ihit) - DoAllEffectOnTarget(&(*ihit)); - - // spell is finished, perform some last features of the spell here - _handle_finish_phase(); - - // Remove used for cast item if need (it can be already NULL after TakeReagents call - TakeCastItem(); - - if(m_spellState != SPELL_STATE_CASTING) - finish(true); // successfully finish spell cast (not last in case autorepeat or channel spell) -} - -uint64 Spell::handle_delayed(uint64 t_offset) -{ - uint64 next_time = 0; - - if (!m_immediateHandled) - { - _handle_immediate_phase(); - m_immediateHandled = true; - } - - // now recheck units targeting correctness (need before any effects apply to prevent adding immunity at first effect not allow apply second spell effect and similar cases) - for(std::list::iterator ihit= m_UniqueTargetInfo.begin(); ihit != m_UniqueTargetInfo.end();++ihit) - { - if (ihit->processed == false) - { - if ( ihit->timeDelay <= t_offset ) - DoAllEffectOnTarget(&(*ihit)); - else if( next_time == 0 || ihit->timeDelay < next_time ) - next_time = ihit->timeDelay; - } - } - - // now recheck gameobject targeting correctness - for(std::list::iterator ighit= m_UniqueGOTargetInfo.begin(); ighit != m_UniqueGOTargetInfo.end();++ighit) - { - if (ighit->processed == false) - { - if ( ighit->timeDelay <= t_offset ) - DoAllEffectOnTarget(&(*ighit)); - else if( next_time == 0 || ighit->timeDelay < next_time ) - next_time = ighit->timeDelay; - } - } - // All targets passed - need finish phase - if (next_time == 0) - { - // spell is finished, perform some last features of the spell here - _handle_finish_phase(); - - finish(true); // successfully finish spell cast - - // return zero, spell is finished now - return 0; - } - else - { - // spell is unfinished, return next execution time - return next_time; - } -} - -void Spell::_handle_immediate_phase() -{ - // handle some immediate features of the spell here - HandleThreatSpells(m_spellInfo->Id); - - m_needSpellLog = IsNeedSendToClient(); - for(uint32 j = 0;j<3;j++) - { - if(m_spellInfo->Effect[j]==0) - continue; - - // apply Send Event effect to ground in case empty target lists - if( m_spellInfo->Effect[j] == SPELL_EFFECT_SEND_EVENT && !HaveTargetsForEffect(j) ) - { - HandleEffects(NULL,NULL,NULL, j); - continue; - } - - // Don't do spell log, if is school damage spell - if(m_spellInfo->Effect[j] == SPELL_EFFECT_SCHOOL_DAMAGE || m_spellInfo->Effect[j] == 0) - m_needSpellLog = false; - - uint32 EffectChainTarget = m_spellInfo->EffectChainTarget[j]; - if(m_originalCaster) - if(Player* modOwner = m_originalCaster->GetSpellModOwner()) - modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_JUMP_TARGETS, EffectChainTarget, this); - - // initialize multipliers - m_damageMultipliers[j] = 1.0f; - if( (m_spellInfo->EffectImplicitTargetA[j] == TARGET_CHAIN_DAMAGE || m_spellInfo->EffectImplicitTargetA[j] == TARGET_CHAIN_HEAL) && - (EffectChainTarget > 1) ) - m_applyMultiplierMask |= 1 << j; - } - - // initialize Diminishing Returns Data - m_diminishLevel = DIMINISHING_LEVEL_1; - m_diminishGroup = DIMINISHING_NONE; - - // process items - for(std::list::iterator ihit= m_UniqueItemInfo.begin();ihit != m_UniqueItemInfo.end();++ihit) - DoAllEffectOnTarget(&(*ihit)); - - // process ground - for(uint32 j = 0;j<3;j++) - { - // persistent area auras target only the ground - if(m_spellInfo->Effect[j] == SPELL_EFFECT_PERSISTENT_AREA_AURA) - HandleEffects(NULL,NULL,NULL, j); - } -} - -void Spell::_handle_finish_phase() -{ - // spell log - if(m_needSpellLog) - SendLogExecute(); -} - -void Spell::SendSpellCooldown() -{ - if(m_caster->GetTypeId() != TYPEID_PLAYER) - return; - - Player* _player = (Player*)m_caster; - // Add cooldown for max (disable spell) - // Cooldown started on SendCooldownEvent call - if (m_spellInfo->Attributes & SPELL_ATTR_DISABLED_WHILE_ACTIVE) - { - _player->AddSpellCooldown(m_spellInfo->Id, 0, time(NULL) - 1); - return; - } - - // init cooldown values - uint32 cat = 0; - int32 rec = -1; - int32 catrec = -1; - - // some special item spells without correct cooldown in SpellInfo - // cooldown information stored in item prototype - // This used in same way in WorldSession::HandleItemQuerySingleOpcode data sending to client. - - if(m_CastItem) - { - ItemPrototype const* proto = m_CastItem->GetProto(); - if(proto) - { - for(int idx = 0; idx < 5; ++idx) - { - if(proto->Spells[idx].SpellId == m_spellInfo->Id) - { - cat = proto->Spells[idx].SpellCategory; - rec = proto->Spells[idx].SpellCooldown; - catrec = proto->Spells[idx].SpellCategoryCooldown; - break; - } - } - } - } - - // if no cooldown found above then base at DBC data - if(rec < 0 && catrec < 0) - { - cat = m_spellInfo->Category; - rec = m_spellInfo->RecoveryTime; - catrec = m_spellInfo->CategoryRecoveryTime; - } - - // shoot spells used equipped item cooldown values already assigned in GetAttackTime(RANGED_ATTACK) - // prevent 0 cooldowns set by another way - if (rec <= 0 && catrec <= 0 && (cat == 76 || cat == 351)) - rec = _player->GetAttackTime(RANGED_ATTACK); - - // Now we have cooldown data (if found any), time to apply mods - if(rec > 0) - _player->ApplySpellMod(m_spellInfo->Id, SPELLMOD_COOLDOWN, rec, this); - - if(catrec > 0) - _player->ApplySpellMod(m_spellInfo->Id, SPELLMOD_COOLDOWN, catrec, this); - - // replace negative cooldowns by 0 - if (rec < 0) rec = 0; - if (catrec < 0) catrec = 0; - - // no cooldown after applying spell mods - if( rec == 0 && catrec == 0) - return; - - time_t curTime = time(NULL); - - time_t catrecTime = catrec ? curTime+catrec/1000 : 0; // in secs - time_t recTime = rec ? curTime+rec/1000 : catrecTime;// in secs - - // self spell cooldown - if(recTime > 0) - _player->AddSpellCooldown(m_spellInfo->Id, m_CastItem ? m_CastItem->GetEntry() : 0, recTime); - - // category spells - if (catrec > 0) - { - SpellCategoryStore::const_iterator i_scstore = sSpellCategoryStore.find(cat); - if(i_scstore != sSpellCategoryStore.end()) - { - for(SpellCategorySet::const_iterator i_scset = i_scstore->second.begin(); i_scset != i_scstore->second.end(); ++i_scset) - { - if(*i_scset == m_spellInfo->Id) // skip main spell, already handled above - continue; - - _player->AddSpellCooldown(m_spellInfo->Id, m_CastItem ? m_CastItem->GetEntry() : 0, catrecTime); - } - } - } -} - -void Spell::update(uint32 difftime) -{ - // update pointers based at it's GUIDs - UpdatePointers(); - - if(m_targets.getUnitTargetGUID() && !m_targets.getUnitTarget()) - { - cancel(); - return; - } - - // check if the player caster has moved before the spell finished - if ((m_caster->GetTypeId() == TYPEID_PLAYER && m_timer != 0) && - (m_castPositionX != m_caster->GetPositionX() || m_castPositionY != m_caster->GetPositionY() || m_castPositionZ != m_caster->GetPositionZ()) && - (m_spellInfo->Effect[0] != SPELL_EFFECT_STUCK || !m_caster->HasUnitMovementFlag(MOVEMENTFLAG_FALLING))) - { - // always cancel for channeled spells - if( m_spellState == SPELL_STATE_CASTING ) - cancel(); - // don't cancel for melee, autorepeat, triggered and instant spells - else if(!IsNextMeleeSwingSpell() && !IsAutoRepeat() && !m_IsTriggeredSpell && (m_spellInfo->InterruptFlags & SPELL_INTERRUPT_FLAG_MOVEMENT)) - cancel(); - } - - switch(m_spellState) - { - case SPELL_STATE_PREPARING: - { - if(m_timer) - { - if(difftime >= m_timer) - m_timer = 0; - else - m_timer -= difftime; - } - - if(m_timer == 0 && !IsNextMeleeSwingSpell() && !IsAutoRepeat()) - cast(); - } break; - case SPELL_STATE_CASTING: - { - if(m_timer > 0) - { - if( m_caster->GetTypeId() == TYPEID_PLAYER ) - { - // check if player has jumped before the channeling finished - if(m_caster->HasUnitMovementFlag(MOVEMENTFLAG_JUMPING)) - cancel(); - - // check for incapacitating player states - if( m_caster->hasUnitState(UNIT_STAT_STUNDED | UNIT_STAT_CONFUSED)) - cancel(); - - // check if player has turned if flag is set - if( m_spellInfo->ChannelInterruptFlags & CHANNEL_FLAG_TURNING && m_castOrientation != m_caster->GetOrientation() ) - cancel(); - } - - // check if there are alive targets left - if (!IsAliveUnitPresentInTargetList()) - { - SendChannelUpdate(0); - finish(); - } - - if(difftime >= m_timer) - m_timer = 0; - else - m_timer -= difftime; - } - - if(m_timer == 0) - { - SendChannelUpdate(0); - - // channeled spell processed independently for quest targeting - // cast at creature (or GO) quest objectives update at successful cast channel finished - // ignore autorepeat/melee casts for speed (not exist quest for spells (hm... ) - if( m_caster->GetTypeId() == TYPEID_PLAYER && !IsAutoRepeat() && !IsNextMeleeSwingSpell() ) - { - for(std::list::iterator ihit= m_UniqueTargetInfo.begin();ihit != m_UniqueTargetInfo.end();++ihit) - { - TargetInfo* target = &*ihit; - if(!IS_CREATURE_GUID(target->targetGUID)) - continue; - - Unit* unit = m_caster->GetGUID()==target->targetGUID ? m_caster : ObjectAccessor::GetUnit(*m_caster,target->targetGUID); - if (unit==NULL) - continue; - - ((Player*)m_caster)->CastedCreatureOrGO(unit->GetEntry(),unit->GetGUID(),m_spellInfo->Id); - } - - for(std::list::iterator ihit= m_UniqueGOTargetInfo.begin();ihit != m_UniqueGOTargetInfo.end();++ihit) - { - GOTargetInfo* target = &*ihit; - - GameObject* go = ObjectAccessor::GetGameObject(*m_caster, target->targetGUID); - if(!go) - continue; - - ((Player*)m_caster)->CastedCreatureOrGO(go->GetEntry(),go->GetGUID(),m_spellInfo->Id); - } - } - - finish(); - } - } break; - default: - { - }break; - } -} - -void Spell::finish(bool ok) -{ - if(!m_caster) - return; - - if(m_spellState == SPELL_STATE_FINISHED) - return; - - m_spellState = SPELL_STATE_FINISHED; - - //remove spell mods - if (m_caster->GetTypeId() == TYPEID_PLAYER) - ((Player*)m_caster)->RemoveSpellMods(this); - - // other code related only to successfully finished spells - if(!ok) - return; - - //handle SPELL_AURA_ADD_TARGET_TRIGGER auras - Unit::AuraList const& targetTriggers = m_caster->GetAurasByType(SPELL_AURA_ADD_TARGET_TRIGGER); - for(Unit::AuraList::const_iterator i = targetTriggers.begin(); i != targetTriggers.end(); ++i) - { - SpellEntry const *auraSpellInfo = (*i)->GetSpellProto(); - uint32 auraSpellIdx = (*i)->GetEffIndex(); - if (IsAffectedBy(auraSpellInfo, auraSpellIdx)) - { - for(std::list::iterator ihit= m_UniqueTargetInfo.begin();ihit != m_UniqueTargetInfo.end();++ihit) - if( ihit->effectMask & (1<GetGUID() let load auras at login and speedup most often case - Unit *unit = m_caster->GetGUID()== ihit->targetGUID ? m_caster : ObjectAccessor::GetUnit(*m_caster, ihit->targetGUID); - if (unit && unit->isAlive()) - { - // Calculate chance at that moment (can be depend for example from combo points) - int32 chance = m_caster->CalculateSpellDamage(auraSpellInfo, auraSpellIdx, (*i)->GetBasePoints(),unit); - - if(roll_chance_i(chance)) - m_caster->CastSpell(unit, auraSpellInfo->EffectTriggerSpell[auraSpellIdx], true, NULL, (*i)); - } - } - } - } - - if (IsMeleeAttackResetSpell()) - { - m_caster->resetAttackTimer(BASE_ATTACK); - if(m_caster->haveOffhandWeapon()) - m_caster->resetAttackTimer(OFF_ATTACK); - } - - /*if (IsRangedAttackResetSpell()) - m_caster->resetAttackTimer(RANGED_ATTACK);*/ - - // Clear combo at finish state - if(m_caster->GetTypeId() == TYPEID_PLAYER && NeedsComboPoints(m_spellInfo)) - ((Player*)m_caster)->ClearComboPoints(); - - // call triggered spell only at successful cast (after clear combo points -> for add some if need) - if(!m_TriggerSpells.empty()) - TriggerSpell(); - - // Stop Attack for some spells - if( m_spellInfo->Attributes & SPELL_ATTR_STOP_ATTACK_TARGET ) - m_caster->AttackStop(); -} - -void Spell::SendCastResult(uint8 result) -{ - if (m_caster->GetTypeId() != TYPEID_PLAYER) - return; - - if(((Player*)m_caster)->GetSession()->PlayerLoading()) // don't send cast results at loading time - return; - - if(result != 0) - { - WorldPacket data(SMSG_CAST_FAILED, (4+1+1)); - data << uint32(m_spellInfo->Id); - data << uint8(result); // problem - data << uint8(m_cast_count); // single cast or multi 2.3 (0/1) - switch (result) - { - case SPELL_FAILED_REQUIRES_SPELL_FOCUS: - data << uint32(m_spellInfo->RequiresSpellFocus); - break; - case SPELL_FAILED_REQUIRES_AREA: - // hardcode areas limitation case - if( m_spellInfo->Id==41618 || m_spellInfo->Id==41620 ) - data << uint32(3842); - else if( m_spellInfo->Id==41617 || m_spellInfo->Id==41619 ) - data << uint32(3905); - // normal case - else - data << uint32(m_spellInfo->AreaId); - break; - case SPELL_FAILED_TOTEMS: - if(m_spellInfo->Totem[0]) - data << uint32(m_spellInfo->Totem[0]); - if(m_spellInfo->Totem[1]) - data << uint32(m_spellInfo->Totem[1]); - break; - case SPELL_FAILED_TOTEM_CATEGORY: - if(m_spellInfo->TotemCategory[0]) - data << uint32(m_spellInfo->TotemCategory[0]); - if(m_spellInfo->TotemCategory[1]) - data << uint32(m_spellInfo->TotemCategory[1]); - break; - case SPELL_FAILED_EQUIPPED_ITEM_CLASS: - data << uint32(m_spellInfo->EquippedItemClass); - data << uint32(m_spellInfo->EquippedItemSubClassMask); - data << uint32(m_spellInfo->EquippedItemInventoryTypeMask); - break; - } - ((Player*)m_caster)->GetSession()->SendPacket(&data); - } - else - { - WorldPacket data(SMSG_CLEAR_EXTRA_AURA_INFO, (8+4)); - data.append(m_caster->GetPackGUID()); - data << uint32(m_spellInfo->Id); - ((Player*)m_caster)->GetSession()->SendPacket(&data); - } -} - -void Spell::SendSpellStart() -{ - if(!IsNeedSendToClient()) - return; - - sLog.outDebug("Sending SMSG_SPELL_START id=%u",m_spellInfo->Id); - - uint16 castFlags = CAST_FLAG_UNKNOWN1; - if(IsRangedSpell()) - castFlags |= CAST_FLAG_AMMO; - - Unit * target; - if(!m_targets.getUnitTarget()) - target = m_caster; - else - target = m_targets.getUnitTarget(); - - WorldPacket data(SMSG_SPELL_START, (8+8+4+4+2)); - if(m_CastItem) - data.append(m_CastItem->GetPackGUID()); - else - data.append(m_caster->GetPackGUID()); - - data.append(m_caster->GetPackGUID()); - data << uint32(m_spellInfo->Id); - data << uint8(m_cast_count); // single cast or multi 2.3 (0/1) - data << uint16(castFlags); - data << uint32(m_timer); - - m_targets.write(&data); - - if( castFlags & CAST_FLAG_AMMO ) - WriteAmmoToPacket(&data); - - m_caster->SendMessageToSet(&data, true); -} - -void Spell::SendSpellGo() -{ - // not send invisible spell casting - if(!IsNeedSendToClient()) - return; - - sLog.outDebug("Sending SMSG_SPELL_GO id=%u",m_spellInfo->Id); - - Unit * target; - if(!m_targets.getUnitTarget()) - target = m_caster; - else - target = m_targets.getUnitTarget(); - - uint16 castFlags = CAST_FLAG_UNKNOWN3; - if(IsRangedSpell()) - castFlags |= CAST_FLAG_AMMO; - - WorldPacket data(SMSG_SPELL_GO, 50); // guess size - if(m_CastItem) - data.append(m_CastItem->GetPackGUID()); - else - data.append(m_caster->GetPackGUID()); - - data.append(m_caster->GetPackGUID()); - data << uint32(m_spellInfo->Id); - data << uint16(castFlags); - data << uint32(getMSTime()); // timestamp - - WriteSpellGoTargets(&data); - - m_targets.write(&data); - - if( castFlags & CAST_FLAG_AMMO ) - WriteAmmoToPacket(&data); - - m_caster->SendMessageToSet(&data, true); -} - -void Spell::WriteAmmoToPacket( WorldPacket * data ) -{ - uint32 ammoInventoryType = 0; - uint32 ammoDisplayID = 0; - - if (m_caster->GetTypeId() == TYPEID_PLAYER) - { - Item *pItem = ((Player*)m_caster)->GetWeaponForAttack( RANGED_ATTACK ); - if(pItem) - { - ammoInventoryType = pItem->GetProto()->InventoryType; - if( ammoInventoryType == INVTYPE_THROWN ) - ammoDisplayID = pItem->GetProto()->DisplayInfoID; - else - { - uint32 ammoID = ((Player*)m_caster)->GetUInt32Value(PLAYER_AMMO_ID); - if(ammoID) - { - ItemPrototype const *pProto = objmgr.GetItemPrototype( ammoID ); - if(pProto) - { - ammoDisplayID = pProto->DisplayInfoID; - ammoInventoryType = pProto->InventoryType; - } - } - else if(m_caster->GetDummyAura(46699)) // Requires No Ammo - { - ammoDisplayID = 5996; // normal arrow - ammoInventoryType = INVTYPE_AMMO; - } - } - } - } - // TODO: implement selection ammo data based at ranged weapon stored in equipmodel/equipinfo/equipslot fields - - *data << uint32(ammoDisplayID); - *data << uint32(ammoInventoryType); -} - -void Spell::WriteSpellGoTargets( WorldPacket * data ) -{ - *data << (uint8)m_countOfHit; - for(std::list::iterator ihit= m_UniqueTargetInfo.begin();ihit != m_UniqueTargetInfo.end();++ihit) - if ((*ihit).missCondition == SPELL_MISS_NONE) // Add only hits - *data << uint64(ihit->targetGUID); - - for(std::list::iterator ighit= m_UniqueGOTargetInfo.begin();ighit != m_UniqueGOTargetInfo.end();++ighit) - *data << uint64(ighit->targetGUID); // Always hits - - *data << (uint8)m_countOfMiss; - for(std::list::iterator ihit= m_UniqueTargetInfo.begin();ihit != m_UniqueTargetInfo.end();++ihit) - { - if( ihit->missCondition != SPELL_MISS_NONE ) // Add only miss - { - *data << uint64(ihit->targetGUID); - *data << uint8(ihit->missCondition); - if( ihit->missCondition == SPELL_MISS_REFLECT ) - *data << uint8(ihit->reflectResult); - } - } -} - -void Spell::SendLogExecute() -{ - Unit *target = m_targets.getUnitTarget() ? m_targets.getUnitTarget() : m_caster; - - WorldPacket data(SMSG_SPELLLOGEXECUTE, (8+4+4+4+4+8)); - - if(m_caster->GetTypeId() == TYPEID_PLAYER) - data.append(m_caster->GetPackGUID()); - else - data.append(target->GetPackGUID()); - - data << uint32(m_spellInfo->Id); - uint32 count1 = 1; - data << uint32(count1); // count1 (effect count?) - for(uint32 i = 0; i < count1; ++i) - { - data << uint32(m_spellInfo->Effect[0]); // spell effect? - uint32 count2 = 1; - data << uint32(count2); // count2 (target count?) - for(uint32 j = 0; j < count2; ++j) - { - switch(m_spellInfo->Effect[0]) - { - case SPELL_EFFECT_POWER_DRAIN: - if(Unit *unit = m_targets.getUnitTarget()) - data.append(unit->GetPackGUID()); - else - data << uint8(0); - data << uint32(0); - data << uint32(0); - data << float(0); - break; - case SPELL_EFFECT_ADD_EXTRA_ATTACKS: - if(Unit *unit = m_targets.getUnitTarget()) - data.append(unit->GetPackGUID()); - else - data << uint8(0); - data << uint32(0); // count? - break; - case SPELL_EFFECT_INTERRUPT_CAST: - if(Unit *unit = m_targets.getUnitTarget()) - data.append(unit->GetPackGUID()); - else - data << uint8(0); - data << uint32(0); // spellid - break; - case SPELL_EFFECT_DURABILITY_DAMAGE: - if(Unit *unit = m_targets.getUnitTarget()) - data.append(unit->GetPackGUID()); - else - data << uint8(0); - data << uint32(0); - data << uint32(0); - break; - case SPELL_EFFECT_OPEN_LOCK: - case SPELL_EFFECT_OPEN_LOCK_ITEM: - if(Item *item = m_targets.getItemTarget()) - data.append(item->GetPackGUID()); - else - data << uint8(0); - break; - case SPELL_EFFECT_CREATE_ITEM: - data << uint32(m_spellInfo->EffectItemType[0]); - break; - case SPELL_EFFECT_SUMMON: - case SPELL_EFFECT_SUMMON_WILD: - case SPELL_EFFECT_SUMMON_GUARDIAN: - case SPELL_EFFECT_TRANS_DOOR: - case SPELL_EFFECT_SUMMON_PET: - case SPELL_EFFECT_SUMMON_POSSESSED: - case SPELL_EFFECT_SUMMON_TOTEM: - case SPELL_EFFECT_SUMMON_OBJECT_WILD: - case SPELL_EFFECT_CREATE_HOUSE: - case SPELL_EFFECT_DUEL: - case SPELL_EFFECT_SUMMON_TOTEM_SLOT1: - case SPELL_EFFECT_SUMMON_TOTEM_SLOT2: - case SPELL_EFFECT_SUMMON_TOTEM_SLOT3: - case SPELL_EFFECT_SUMMON_TOTEM_SLOT4: - case SPELL_EFFECT_SUMMON_PHANTASM: - case SPELL_EFFECT_SUMMON_CRITTER: - case SPELL_EFFECT_SUMMON_OBJECT_SLOT1: - case SPELL_EFFECT_SUMMON_OBJECT_SLOT2: - case SPELL_EFFECT_SUMMON_OBJECT_SLOT3: - case SPELL_EFFECT_SUMMON_OBJECT_SLOT4: - case SPELL_EFFECT_SUMMON_DEMON: - case SPELL_EFFECT_150: - if(Unit *unit = m_targets.getUnitTarget()) - data.append(unit->GetPackGUID()); - else if(m_targets.getItemTargetGUID()) - data.appendPackGUID(m_targets.getItemTargetGUID()); - else if(GameObject *go = m_targets.getGOTarget()) - data.append(go->GetPackGUID()); - else - data << uint8(0); // guid - break; - case SPELL_EFFECT_FEED_PET: - data << uint32(m_targets.getItemTargetEntry()); - break; - case SPELL_EFFECT_DISMISS_PET: - if(Unit *unit = m_targets.getUnitTarget()) - data.append(unit->GetPackGUID()); - else - data << uint8(0); - break; - default: - return; - } - } - } - - m_caster->SendMessageToSet(&data, true); -} - -void Spell::SendInterrupted(uint8 result) -{ - WorldPacket data(SMSG_SPELL_FAILURE, (8+4+1)); - data.append(m_caster->GetPackGUID()); - data << m_spellInfo->Id; - data << result; - m_caster->SendMessageToSet(&data, true); - - data.Initialize(SMSG_SPELL_FAILED_OTHER, (8+4)); - data.append(m_caster->GetPackGUID()); - data << m_spellInfo->Id; - m_caster->SendMessageToSet(&data, true); -} - -void Spell::SendChannelUpdate(uint32 time) -{ - if(time == 0) - { - m_caster->SetUInt64Value(UNIT_FIELD_CHANNEL_OBJECT,0); - m_caster->SetUInt32Value(UNIT_CHANNEL_SPELL,0); - } - - if (m_caster->GetTypeId() != TYPEID_PLAYER) - return; - - WorldPacket data( MSG_CHANNEL_UPDATE, 8+4 ); - data.append(m_caster->GetPackGUID()); - data << time; - - ((Player*)m_caster)->GetSession()->SendPacket( &data ); -} - -void Spell::SendChannelStart(uint32 duration) -{ - WorldObject* target = NULL; - - // select first not rsusted target from target list for _0_ effect - if(!m_UniqueTargetInfo.empty()) - { - for(std::list::iterator itr= m_UniqueTargetInfo.begin();itr != m_UniqueTargetInfo.end();++itr) - { - if( (itr->effectMask & (1<<0)) && itr->reflectResult==SPELL_MISS_NONE && itr->targetGUID != m_caster->GetGUID()) - { - target = ObjectAccessor::GetUnit(*m_caster, itr->targetGUID); - break; - } - } - } - else if(!m_UniqueGOTargetInfo.empty()) - { - for(std::list::iterator itr= m_UniqueGOTargetInfo.begin();itr != m_UniqueGOTargetInfo.end();++itr) - { - if(itr->effectMask & (1<<0) ) - { - target = ObjectAccessor::GetGameObject(*m_caster, itr->targetGUID); - break; - } - } - } - - if (m_caster->GetTypeId() == TYPEID_PLAYER) - { - WorldPacket data( MSG_CHANNEL_START, (8+4+4) ); - data.append(m_caster->GetPackGUID()); - data << m_spellInfo->Id; - data << duration; - - ((Player*)m_caster)->GetSession()->SendPacket( &data ); - } - - m_timer = duration; - if(target) - m_caster->SetUInt64Value(UNIT_FIELD_CHANNEL_OBJECT, target->GetGUID()); - m_caster->SetUInt32Value(UNIT_CHANNEL_SPELL, m_spellInfo->Id); -} - -void Spell::SendResurrectRequest(Player* target) -{ - WorldPacket data(SMSG_RESURRECT_REQUEST, (8+4+2+4)); - data << m_caster->GetGUID(); - data << uint32(1) << uint16(0) << uint32(1); - - target->GetSession()->SendPacket(&data); -} - -void Spell::SendPlaySpellVisual(uint32 SpellID) -{ - if (m_caster->GetTypeId() != TYPEID_PLAYER) - return; - - WorldPacket data(SMSG_PLAY_SPELL_VISUAL, 12); - data << m_caster->GetGUID(); - data << SpellID; - ((Player*)m_caster)->GetSession()->SendPacket(&data); -} - -void Spell::TakeCastItem() -{ - if(!m_CastItem || m_caster->GetTypeId() != TYPEID_PLAYER) - return; - - // not remove cast item at triggered spell (equipping, weapon damage, etc) - if(m_IsTriggeredSpell) - return; - - ItemPrototype const *proto = m_CastItem->GetProto(); - - if(!proto) - { - // This code is to avoid a crash - // I'm not sure, if this is really an error, but I guess every item needs a prototype - sLog.outError("Cast item has no item prototype highId=%d, lowId=%d",m_CastItem->GetGUIDHigh(), m_CastItem->GetGUIDLow()); - return; - } - - bool expendable = false; - bool withoutCharges = false; - - for (int i = 0; i<5; i++) - { - if (proto->Spells[i].SpellId) - { - // item has limited charges - if (proto->Spells[i].SpellCharges) - { - if (proto->Spells[i].SpellCharges < 0) - expendable = true; - - int32 charges = m_CastItem->GetSpellCharges(i); - - // item has charges left - if (charges) - { - (charges > 0) ? --charges : ++charges; // abs(charges) less at 1 after use - if (proto->Stackable < 2) - m_CastItem->SetSpellCharges(i, charges); - m_CastItem->SetState(ITEM_CHANGED, (Player*)m_caster); - } - - // all charges used - withoutCharges = (charges == 0); - } - } - } - - if (expendable && withoutCharges) - { - uint32 count = 1; - ((Player*)m_caster)->DestroyItemCount(m_CastItem, count, true); - - // prevent crash at access to deleted m_targets.getItemTarget - if(m_CastItem==m_targets.getItemTarget()) - m_targets.setItemTarget(NULL); - - m_CastItem = NULL; - } -} - -void Spell::TakePower() -{ - if(m_CastItem || m_triggeredByAuraSpell) - return; - - // health as power used - if(m_spellInfo->powerType == POWER_HEALTH) - { - m_caster->ModifyHealth( -(int32)m_powerCost ); - return; - } - - if(m_spellInfo->powerType >= MAX_POWERS) - { - sLog.outError("Spell::TakePower: Unknown power type '%d'", m_spellInfo->powerType); - return; - } - - Powers powerType = Powers(m_spellInfo->powerType); - - m_caster->ModifyPower(powerType, -(int32)m_powerCost); - - // Set the five second timer - if (powerType == POWER_MANA && m_powerCost > 0) - m_caster->SetLastManaUse(getMSTime()); -} - -void Spell::TakeReagents() -{ - if(m_IsTriggeredSpell) // reagents used in triggered spell removed by original spell or don't must be removed. - return; - - if (m_caster->GetTypeId() != TYPEID_PLAYER) - return; - - if (m_spellInfo->AttributesEx5 & SPELL_ATTR_EX5_NO_REAGENT_WHILE_PREP && - m_caster->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PREPARATION)) - return; - - Player* p_caster = (Player*)m_caster; - - for(uint32 x=0;x<8;x++) - { - if(m_spellInfo->Reagent[x] <= 0) - continue; - - uint32 itemid = m_spellInfo->Reagent[x]; - uint32 itemcount = m_spellInfo->ReagentCount[x]; - - // if CastItem is also spell reagent - if (m_CastItem) - { - ItemPrototype const *proto = m_CastItem->GetProto(); - if( proto && proto->ItemId == itemid ) - { - for(int s=0;s<5;s++) - { - // CastItem will be used up and does not count as reagent - int32 charges = m_CastItem->GetSpellCharges(s); - if (proto->Spells[s].SpellCharges < 0 && abs(charges) < 2) - { - ++itemcount; - break; - } - } - - m_CastItem = NULL; - } - } - - // if getItemTarget is also spell reagent - if (m_targets.getItemTargetEntry()==itemid) - m_targets.setItemTarget(NULL); - - p_caster->DestroyItemCount(itemid, itemcount, true); - } -} - -void Spell::HandleThreatSpells(uint32 spellId) -{ - if(!m_targets.getUnitTarget() || !spellId) - return; - - if(!m_targets.getUnitTarget()->CanHaveThreatList()) - return; - - SpellThreatEntry const *threatSpell = sSpellThreatStore.LookupEntry(spellId); - if(!threatSpell) - return; - - m_targets.getUnitTarget()->AddThreat(m_caster, float(threatSpell->threat)); - - DEBUG_LOG("Spell %u, rank %u, added an additional %i threat", spellId, spellmgr.GetSpellRank(spellId), threatSpell->threat); -} - -void Spell::HandleEffects(Unit *pUnitTarget,Item *pItemTarget,GameObject *pGOTarget,uint32 i, float DamageMultiplier) -{ - unitTarget = pUnitTarget; - itemTarget = pItemTarget; - gameObjTarget = pGOTarget; - - uint8 eff = m_spellInfo->Effect[i]; - uint32 mechanic = m_spellInfo->EffectMechanic[i]; - - damage = int32(CalculateDamage((uint8)i,unitTarget)*DamageMultiplier); - - sLog.outDebug( "Spell: Effect : %u", eff); - - //Simply return. Do not display "immune" in red text on client - if(unitTarget && unitTarget->IsImmunedToSpellEffect(eff, mechanic)) - return; - - if(eff TOTAL_SPELL_EFFECTS ", eff); - if (m_CastItem) - EffectEnchantItemTmp(i); - else - { - sLog.outError("SPELL: unknown effect %u spell id %u\n", - eff, m_spellInfo->Id); - } - } - */ -} - -void Spell::TriggerSpell() -{ - for(TriggerSpells::iterator si=m_TriggerSpells.begin(); si!=m_TriggerSpells.end(); ++si) - { - Spell* spell = new Spell(m_caster, (*si), true, m_originalCasterGUID, this->m_selfContainer); - spell->prepare(&m_targets); // use original spell original targets - } -} - -uint8 Spell::CanCast(bool strict) -{ - // check cooldowns to prevent cheating - if(m_caster->GetTypeId()==TYPEID_PLAYER && ((Player*)m_caster)->HasSpellCooldown(m_spellInfo->Id)) - { - if(m_triggeredByAuraSpell) - return SPELL_FAILED_DONT_REPORT; - else - return SPELL_FAILED_NOT_READY; - } - - // only allow triggered spells if at an ended battleground - if( !m_IsTriggeredSpell && m_caster->GetTypeId() == TYPEID_PLAYER) - if(BattleGround * bg = ((Player*)m_caster)->GetBattleGround()) - if(bg->GetStatus() == STATUS_WAIT_LEAVE) - return SPELL_FAILED_DONT_REPORT; - - // only check at first call, Stealth auras are already removed at second call - // for now, ignore triggered spells - if( strict && !m_IsTriggeredSpell) - { - // Cannot be used in this stance/form - if(uint8 shapeError = GetErrorAtShapeshiftedCast(m_spellInfo, m_caster->m_form)) - return shapeError; - - if ((m_spellInfo->Attributes & SPELL_ATTR_ONLY_STEALTHED) && !(m_caster->HasStealthAura())) - return SPELL_FAILED_ONLY_STEALTHED; - } - - // caster state requirements - if(m_spellInfo->CasterAuraState && !m_caster->HasAuraState(AuraState(m_spellInfo->CasterAuraState))) - return SPELL_FAILED_CASTER_AURASTATE; - if(m_spellInfo->CasterAuraStateNot && m_caster->HasAuraState(AuraState(m_spellInfo->CasterAuraStateNot))) - return SPELL_FAILED_CASTER_AURASTATE; - - // cancel autorepeat spells if cast start when moving - // (not wand currently autorepeat cast delayed to moving stop anyway in spell update code) - if( m_caster->GetTypeId()==TYPEID_PLAYER && ((Player*)m_caster)->isMoving() ) - { - // skip stuck spell to allow use it in falling case and apply spell limitations at movement - if( (!m_caster->HasUnitMovementFlag(MOVEMENTFLAG_FALLING) || m_spellInfo->Effect[0] != SPELL_EFFECT_STUCK) && - (IsAutoRepeat() || (m_spellInfo->AuraInterruptFlags & AURA_INTERRUPT_FLAG_NOT_SEATED) != 0) ) - return SPELL_FAILED_MOVING; - } - - Unit *target = m_targets.getUnitTarget(); - - if(target) - { - // target state requirements (not allowed state), apply to self also - if(m_spellInfo->TargetAuraStateNot && target->HasAuraState(AuraState(m_spellInfo->TargetAuraStateNot))) - return SPELL_FAILED_TARGET_AURASTATE; - - - if(target != m_caster) - { - // target state requirements (apply to non-self only), to allow cast affects to self like Dirty Deeds - if(m_spellInfo->TargetAuraState && !target->HasAuraState(AuraState(m_spellInfo->TargetAuraState))) - return SPELL_FAILED_TARGET_AURASTATE; - - // Not allow casting on flying player - if (target->isInFlight()) - return SPELL_FAILED_BAD_TARGETS; - - if(VMAP::VMapFactory::checkSpellForLoS(m_spellInfo->Id) && !m_caster->IsWithinLOSInMap(target)) - return SPELL_FAILED_LINE_OF_SIGHT; - - // auto selection spell rank implemented in WorldSession::HandleCastSpellOpcode - // this case can be triggered if rank not found (too low-level target for first rank) - if(m_caster->GetTypeId() == TYPEID_PLAYER && !IsPassiveSpell(m_spellInfo->Id) && !m_CastItem) - { - for(int i=0;i<3;i++) - { - if(IsPositiveEffect(m_spellInfo->Id, i) && m_spellInfo->Effect[i] == SPELL_EFFECT_APPLY_AURA) - if(target->getLevel() + 10 < m_spellInfo->spellLevel) - return SPELL_FAILED_LOWLEVEL; - } - } - } - - // check pet presents - for(int j=0;j<3;j++) - { - if(m_spellInfo->EffectImplicitTargetA[j] == TARGET_PET) - { - target = m_caster->GetPet(); - if(!target) - { - if(m_triggeredByAuraSpell) // not report pet not existence for triggered spells - return SPELL_FAILED_DONT_REPORT; - else - return SPELL_FAILED_NO_PET; - } - break; - } - } - - //check creature type - //ignore self casts (including area casts when caster selected as target) - if(target != m_caster) - { - if(!CheckTargetCreatureType(target)) - { - if(target->GetTypeId()==TYPEID_PLAYER) - return SPELL_FAILED_TARGET_IS_PLAYER; - else - return SPELL_FAILED_BAD_TARGETS; - } - } - - // TODO: this check can be applied and for player to prevent cheating when IsPositiveSpell will return always correct result. - // check target for pet/charmed casts (not self targeted), self targeted cast used for area effects and etc - if(m_caster != target && m_caster->GetTypeId()==TYPEID_UNIT && m_caster->GetCharmerOrOwnerGUID()) - { - // check correctness positive/negative cast target (pet cast real check and cheating check) - if(IsPositiveSpell(m_spellInfo->Id)) - { - if(m_caster->IsHostileTo(target)) - return SPELL_FAILED_BAD_TARGETS; - } - else - { - if(m_caster->IsFriendlyTo(target)) - return SPELL_FAILED_BAD_TARGETS; - } - } - - if(IsPositiveSpell(m_spellInfo->Id)) - { - if(target->IsImmunedToSpell(m_spellInfo,false)) - return SPELL_FAILED_TARGET_AURASTATE; - } - - //Must be behind the target. - if( m_spellInfo->AttributesEx2 == 0x100000 && (m_spellInfo->AttributesEx & 0x200) == 0x200 && target->HasInArc(M_PI, m_caster) ) - { - SendInterrupted(2); - return SPELL_FAILED_NOT_BEHIND; - } - - //Target must be facing you. - if((m_spellInfo->Attributes == 0x150010) && !target->HasInArc(M_PI, m_caster) ) - { - SendInterrupted(2); - return SPELL_FAILED_NOT_INFRONT; - } - - // check if target is in combat - if (target != m_caster && (m_spellInfo->AttributesEx & SPELL_ATTR_EX_NOT_IN_COMBAT_TARGET) && target->isInCombat()) - { - return SPELL_FAILED_TARGET_AFFECTING_COMBAT; - } - } - // Spell casted only on battleground - if((m_spellInfo->AttributesEx3 & SPELL_ATTR_EX3_BATTLEGROUND) && m_caster->GetTypeId()==TYPEID_PLAYER) - if(!((Player*)m_caster)->InBattleGround()) - return SPELL_FAILED_ONLY_BATTLEGROUNDS; - - // do not allow spells to be cast in arenas - // - with greater than 15 min CD without SPELL_ATTR_EX4_USABLE_IN_ARENA flag - // - with SPELL_ATTR_EX4_NOT_USABLE_IN_ARENA flag - if( (m_spellInfo->AttributesEx4 & SPELL_ATTR_EX4_NOT_USABLE_IN_ARENA) || - GetSpellRecoveryTime(m_spellInfo) > 15 * MINUTE * 1000 && !(m_spellInfo->AttributesEx4 & SPELL_ATTR_EX4_USABLE_IN_ARENA) ) - if(MapEntry const* mapEntry = sMapStore.LookupEntry(m_caster->GetMapId())) - if(mapEntry->IsBattleArena()) - return SPELL_FAILED_NOT_IN_ARENA; - - // zone check - if(!IsSpellAllowedInLocation(m_spellInfo,m_caster->GetMapId(),m_caster->GetZoneId(),m_caster->GetAreaId())) - return SPELL_FAILED_REQUIRES_AREA; - - // not let players cast spells at mount (and let do it to creatures) - if( m_caster->IsMounted() && m_caster->GetTypeId()==TYPEID_PLAYER && !m_IsTriggeredSpell && - !IsPassiveSpell(m_spellInfo->Id) && !(m_spellInfo->Attributes & SPELL_ATTR_CASTABLE_WHILE_MOUNTED) ) - { - if(m_caster->isInFlight()) - return SPELL_FAILED_NOT_FLYING; - else - return SPELL_FAILED_NOT_MOUNTED; - } - - // always (except passive spells) check items (focus object can be required for any type casts) - if(!IsPassiveSpell(m_spellInfo->Id)) - if(uint8 castResult = CheckItems()) - return castResult; - - //ImpliciteTargetA-B = 38, If fact there is 0 Spell with ImpliciteTargetB=38 - if(m_UniqueTargetInfo.empty()) // skip second canCast apply (for delayed spells for example) - { - for(uint8 j = 0; j < 3; j++) - { - if( m_spellInfo->EffectImplicitTargetA[j] == TARGET_SCRIPT || - m_spellInfo->EffectImplicitTargetB[j] == TARGET_SCRIPT && m_spellInfo->EffectImplicitTargetA[j] != TARGET_SELF || - m_spellInfo->EffectImplicitTargetA[j] == TARGET_SCRIPT_COORDINATES || - m_spellInfo->EffectImplicitTargetB[j] == TARGET_SCRIPT_COORDINATES ) - { - bool okDoo = false; - - SpellScriptTarget::const_iterator lower = spellmgr.GetBeginSpellScriptTarget(m_spellInfo->Id); - SpellScriptTarget::const_iterator upper = spellmgr.GetEndSpellScriptTarget(m_spellInfo->Id); - if(lower==upper) - sLog.outErrorDb("Spell (ID: %u) has effect EffectImplicitTargetA/EffectImplicitTargetB = TARGET_SCRIPT or TARGET_SCRIPT_COORDINATES, but does not have record in `spell_script_target`",m_spellInfo->Id); - - SpellRangeEntry const* srange = sSpellRangeStore.LookupEntry(m_spellInfo->rangeIndex); - float range = GetSpellMaxRange(srange); - - Creature* creatureScriptTarget = NULL; - GameObject* goScriptTarget = NULL; - - for(SpellScriptTarget::const_iterator i_spellST = lower; i_spellST != upper; ++i_spellST) - { - switch(i_spellST->second.type) - { - case SPELL_TARGET_TYPE_GAMEOBJECT: - { - GameObject* p_GameObject = NULL; - - if(i_spellST->second.targetEntry) - { - CellPair p(MaNGOS::ComputeCellPair(m_caster->GetPositionX(), m_caster->GetPositionY())); - Cell cell(p); - cell.data.Part.reserved = ALL_DISTRICT; - - MaNGOS::NearestGameObjectEntryInObjectRangeCheck go_check(*m_caster,i_spellST->second.targetEntry,range); - MaNGOS::GameObjectLastSearcher checker(p_GameObject,go_check); - - TypeContainerVisitor, GridTypeMapContainer > object_checker(checker); - CellLock cell_lock(cell, p); - cell_lock->Visit(cell_lock, object_checker, *MapManager::Instance().GetMap(m_caster->GetMapId(), m_caster)); - - if(p_GameObject) - { - // remember found target and range, next attempt will find more near target with another entry - creatureScriptTarget = NULL; - goScriptTarget = p_GameObject; - range = go_check.GetLastRange(); - } - } - else if( focusObject ) //Focus Object - { - float frange = m_caster->GetDistance(focusObject); - if(range >= frange) - { - creatureScriptTarget = NULL; - goScriptTarget = focusObject; - range = frange; - } - } - break; - } - case SPELL_TARGET_TYPE_CREATURE: - case SPELL_TARGET_TYPE_DEAD: - default: - { - Creature *p_Creature = NULL; - - CellPair p(MaNGOS::ComputeCellPair(m_caster->GetPositionX(), m_caster->GetPositionY())); - Cell cell(p); - cell.data.Part.reserved = ALL_DISTRICT; - cell.SetNoCreate(); // Really don't know what is that??? - - MaNGOS::NearestCreatureEntryWithLiveStateInObjectRangeCheck u_check(*m_caster,i_spellST->second.targetEntry,i_spellST->second.type!=SPELL_TARGET_TYPE_DEAD,range); - MaNGOS::CreatureLastSearcher searcher(p_Creature, u_check); - - TypeContainerVisitor, GridTypeMapContainer > grid_creature_searcher(searcher); - - CellLock cell_lock(cell, p); - cell_lock->Visit(cell_lock, grid_creature_searcher, *MapManager::Instance().GetMap(m_caster->GetMapId(), m_caster)); - - if(p_Creature ) - { - creatureScriptTarget = p_Creature; - goScriptTarget = NULL; - range = u_check.GetLastRange(); - } - break; - } - } - } - - if(creatureScriptTarget) - { - // store coordinates for TARGET_SCRIPT_COORDINATES - if (m_spellInfo->EffectImplicitTargetA[j] == TARGET_SCRIPT_COORDINATES || - m_spellInfo->EffectImplicitTargetB[j] == TARGET_SCRIPT_COORDINATES ) - { - m_targets.setDestination(creatureScriptTarget->GetPositionX(),creatureScriptTarget->GetPositionY(),creatureScriptTarget->GetPositionZ()); - - if(m_spellInfo->EffectImplicitTargetA[j] == TARGET_SCRIPT_COORDINATES && m_spellInfo->EffectImplicitTargetB[j] == 0 && m_spellInfo->Effect[j]!=SPELL_EFFECT_PERSISTENT_AREA_AURA) - AddUnitTarget(creatureScriptTarget, j); - } - // store explicit target for TARGET_SCRIPT - else - AddUnitTarget(creatureScriptTarget, j); - } - else if(goScriptTarget) - { - // store coordinates for TARGET_SCRIPT_COORDINATES - if (m_spellInfo->EffectImplicitTargetA[j] == TARGET_SCRIPT_COORDINATES || - m_spellInfo->EffectImplicitTargetB[j] == TARGET_SCRIPT_COORDINATES ) - { - m_targets.setDestination(goScriptTarget->GetPositionX(),goScriptTarget->GetPositionY(),goScriptTarget->GetPositionZ()); - - if(m_spellInfo->EffectImplicitTargetA[j] == TARGET_SCRIPT_COORDINATES && m_spellInfo->EffectImplicitTargetB[j] == 0 && m_spellInfo->Effect[j]!=SPELL_EFFECT_PERSISTENT_AREA_AURA) - AddGOTarget(goScriptTarget, j); - } - // store explicit target for TARGET_SCRIPT - else - AddGOTarget(goScriptTarget, j); - } - //Missing DB Entry or targets for this spellEffect. - else - { - // not report target not existence for triggered spells - if(m_triggeredByAuraSpell || m_IsTriggeredSpell) - return SPELL_FAILED_DONT_REPORT; - else - return SPELL_FAILED_BAD_TARGETS; - } - } - } - } - - if(uint8 castResult = CheckRange(strict)) - return castResult; - - { - if(uint8 castResult = CheckPower()) - return castResult; - } - - if(!m_triggeredByAuraSpell) // triggered spell not affected by stun/etc - if(uint8 castResult = CheckCasterAuras()) - return castResult; - - for (int i = 0; i < 3; i++) - { - // for effects of spells that have only one target - switch(m_spellInfo->Effect[i]) - { - case SPELL_EFFECT_DUMMY: - { - // Execute - if(m_spellInfo->SpellIconID == 1648) - { - if(!m_targets.getUnitTarget() || m_targets.getUnitTarget()->GetHealth() > m_targets.getUnitTarget()->GetMaxHealth()*0.2) - return SPELL_FAILED_BAD_TARGETS; - } - else if (m_spellInfo->Id == 51582) - { - if(m_caster->IsInWater()) - return SPELL_FAILED_ONLY_ABOVEWATER; - } - break; - } - case SPELL_EFFECT_SCHOOL_DAMAGE: - { - // Hammer of Wrath - if(m_spellInfo->SpellVisual == 7250) - { - if (!m_targets.getUnitTarget()) - return SPELL_FAILED_BAD_IMPLICIT_TARGETS; - - if(m_targets.getUnitTarget()->GetHealth() > m_targets.getUnitTarget()->GetMaxHealth()*0.2) - return SPELL_FAILED_BAD_TARGETS; - } - break; - } - case SPELL_EFFECT_TAMECREATURE: - { - if (!m_targets.getUnitTarget() || m_targets.getUnitTarget()->GetTypeId() == TYPEID_PLAYER) - return SPELL_FAILED_BAD_IMPLICIT_TARGETS; - - if (m_targets.getUnitTarget()->getLevel() > m_caster->getLevel()) - return SPELL_FAILED_HIGHLEVEL; - - CreatureInfo const *cinfo = ((Creature*)m_targets.getUnitTarget())->GetCreatureInfo(); - if( cinfo->type != CREATURE_TYPE_BEAST ) - return SPELL_FAILED_BAD_TARGETS; - - // use SMSG_PET_TAME_FAILURE? - if( !(cinfo->flag1 & 1) || !(cinfo->family) ) - return SPELL_FAILED_BAD_TARGETS; - - if(m_caster->GetPetGUID()) - return SPELL_FAILED_ALREADY_HAVE_SUMMON; - - if(m_caster->GetCharmGUID()) - return SPELL_FAILED_ALREADY_HAVE_CHARM; - - break; - } - case SPELL_EFFECT_LEARN_SPELL: - { - if(m_spellInfo->EffectImplicitTargetA[i] != TARGET_PET) - break; - - Pet* pet = m_caster->GetPet(); - - if(!pet) - return SPELL_FAILED_NO_PET; - - SpellEntry const *learn_spellproto = sSpellStore.LookupEntry(m_spellInfo->EffectTriggerSpell[i]); - - if(!learn_spellproto) - return SPELL_FAILED_NOT_KNOWN; - - if(!pet->CanTakeMoreActiveSpells(learn_spellproto->Id)) - return SPELL_FAILED_TOO_MANY_SKILLS; - - if(m_spellInfo->spellLevel > pet->getLevel()) - return SPELL_FAILED_LOWLEVEL; - - if(!pet->HasTPForSpell(learn_spellproto->Id)) - return SPELL_FAILED_TRAINING_POINTS; - - break; - } - case SPELL_EFFECT_LEARN_PET_SPELL: - { - Pet* pet = m_caster->GetPet(); - - if(!pet) - return SPELL_FAILED_NO_PET; - - SpellEntry const *learn_spellproto = sSpellStore.LookupEntry(m_spellInfo->EffectTriggerSpell[i]); - - if(!learn_spellproto) - return SPELL_FAILED_NOT_KNOWN; - - if(!pet->CanTakeMoreActiveSpells(learn_spellproto->Id)) - return SPELL_FAILED_TOO_MANY_SKILLS; - - if(m_spellInfo->spellLevel > pet->getLevel()) - return SPELL_FAILED_LOWLEVEL; - - if(!pet->HasTPForSpell(learn_spellproto->Id)) - return SPELL_FAILED_TRAINING_POINTS; - - break; - } - case SPELL_EFFECT_FEED_PET: - { - if (m_caster->GetTypeId() != TYPEID_PLAYER || !m_targets.getItemTarget() ) - return SPELL_FAILED_BAD_TARGETS; - - Pet* pet = m_caster->GetPet(); - - if(!pet) - return SPELL_FAILED_NO_PET; - - if(!pet->HaveInDiet(m_targets.getItemTarget()->GetProto())) - return SPELL_FAILED_WRONG_PET_FOOD; - - if(!pet->GetCurrentFoodBenefitLevel(m_targets.getItemTarget()->GetProto()->ItemLevel)) - return SPELL_FAILED_FOOD_LOWLEVEL; - - if(m_caster->isInCombat() || pet->isInCombat()) - return SPELL_FAILED_AFFECTING_COMBAT; - - break; - } - case SPELL_EFFECT_POWER_BURN: - case SPELL_EFFECT_POWER_DRAIN: - { - // Can be area effect, Check only for players and not check if target - caster (spell can have multiply drain/burn effects) - if(m_caster->GetTypeId() == TYPEID_PLAYER) - if(Unit* target = m_targets.getUnitTarget()) - if(target!=m_caster && target->getPowerType()!=m_spellInfo->EffectMiscValue[i]) - return SPELL_FAILED_BAD_TARGETS; - break; - } - case SPELL_EFFECT_CHARGE: - { - if (m_caster->hasUnitState(UNIT_STAT_ROOT)) - return SPELL_FAILED_ROOTED; - - break; - } - case SPELL_EFFECT_SKINNING: - { - if (m_caster->GetTypeId() != TYPEID_PLAYER || !m_targets.getUnitTarget() || m_targets.getUnitTarget()->GetTypeId() != TYPEID_UNIT) - return SPELL_FAILED_BAD_TARGETS; - - if( !(m_targets.getUnitTarget()->GetUInt32Value(UNIT_FIELD_FLAGS) & UNIT_FLAG_SKINNABLE) ) - return SPELL_FAILED_TARGET_UNSKINNABLE; - - Creature* creature = (Creature*)m_targets.getUnitTarget(); - if ( creature->GetCreatureType() != CREATURE_TYPE_CRITTER && ( !creature->lootForBody || !creature->loot.empty() ) ) - { - return SPELL_FAILED_TARGET_NOT_LOOTED; - } - - uint32 skill; - if(creature->GetCreatureInfo()->flag1 & 256) - skill = SKILL_HERBALISM; // special case - else if(creature->GetCreatureInfo()->flag1 & 512) - skill = SKILL_MINING; // special case - else - skill = SKILL_SKINNING; // normal case - - int32 skillValue = ((Player*)m_caster)->GetSkillValue(skill); - int32 TargetLevel = m_targets.getUnitTarget()->getLevel(); - int32 ReqValue = (skillValue < 100 ? (TargetLevel-10)*10 : TargetLevel*5); - if (ReqValue > skillValue) - return SPELL_FAILED_LOW_CASTLEVEL; - - // chance for fail at orange skinning attempt - if( (m_selfContainer && (*m_selfContainer) == this) && - skillValue < sWorld.GetConfigMaxSkillValue() && - (ReqValue < 0 ? 0 : ReqValue) > irand(skillValue-25, skillValue+37) ) - return SPELL_FAILED_TRY_AGAIN; - - break; - } - case SPELL_EFFECT_OPEN_LOCK_ITEM: - case SPELL_EFFECT_OPEN_LOCK: - { - if( m_spellInfo->EffectImplicitTargetA[i] != TARGET_GAMEOBJECT && - m_spellInfo->EffectImplicitTargetA[i] != TARGET_GAMEOBJECT_ITEM ) - break; - - if( m_caster->GetTypeId() != TYPEID_PLAYER // only players can open locks, gather etc. - // we need a go target in case of TARGET_GAMEOBJECT - || m_spellInfo->EffectImplicitTargetA[i] == TARGET_GAMEOBJECT && !m_targets.getGOTarget() - // we need a go target, or an openable item target in case of TARGET_GAMEOBJECT_ITEM - || m_spellInfo->EffectImplicitTargetA[i] == TARGET_GAMEOBJECT_ITEM && !m_targets.getGOTarget() && - (!m_targets.getItemTarget() || !m_targets.getItemTarget()->GetProto()->LockID || m_targets.getItemTarget()->GetOwner() != m_caster ) ) - return SPELL_FAILED_BAD_TARGETS; - - // get the lock entry - LockEntry const *lockInfo = NULL; - if (GameObject* go=m_targets.getGOTarget()) - lockInfo = sLockStore.LookupEntry(go->GetLockId()); - else if(Item* itm=m_targets.getItemTarget()) - lockInfo = sLockStore.LookupEntry(itm->GetProto()->LockID); - - // check lock compatibility - if (lockInfo) - { - // check for lock - key pair (checked by client also, just prevent cheating - bool ok_key = false; - for(int it = 0; it < 5; ++it) - { - switch(lockInfo->keytype[it]) - { - case LOCK_KEY_NONE: - break; - case LOCK_KEY_ITEM: - { - if(lockInfo->key[it]) - { - if(m_CastItem && m_CastItem->GetEntry()==lockInfo->key[it]) - ok_key =true; - break; - } - } - case LOCK_KEY_SKILL: - { - if(uint32(m_spellInfo->EffectMiscValue[i])!=lockInfo->key[it]) - break; - - switch(lockInfo->key[it]) - { - case LOCKTYPE_HERBALISM: - if(((Player*)m_caster)->HasSkill(SKILL_HERBALISM)) - ok_key =true; - break; - case LOCKTYPE_MINING: - if(((Player*)m_caster)->HasSkill(SKILL_MINING)) - ok_key =true; - break; - default: - ok_key =true; - break; - } - } - } - if(ok_key) - break; - } - - if(!ok_key) - return SPELL_FAILED_BAD_TARGETS; - } - - // chance for fail at orange mining/herb/LockPicking gathering attempt - if (!m_selfContainer || ((*m_selfContainer) != this)) - break; - - // get the skill value of the player - int32 SkillValue = 0; - bool canFailAtMax = true; - if (m_spellInfo->EffectMiscValue[i] == LOCKTYPE_HERBALISM) - { - SkillValue = ((Player*)m_caster)->GetSkillValue(SKILL_HERBALISM); - canFailAtMax = false; - } - else if (m_spellInfo->EffectMiscValue[i] == LOCKTYPE_MINING) - { - SkillValue = ((Player*)m_caster)->GetSkillValue(SKILL_MINING); - canFailAtMax = false; - } - else if (m_spellInfo->EffectMiscValue[i] == LOCKTYPE_PICKLOCK) - SkillValue = ((Player*)m_caster)->GetSkillValue(SKILL_LOCKPICKING); - - // castitem check: rogue using skeleton keys. the skill values should not be added in this case. - if(m_CastItem) - SkillValue = 0; - - // add the damage modifier from the spell casted (cheat lock / skeleton key etc.) (use m_currentBasePoints, CalculateDamage returns wrong value) - SkillValue += m_currentBasePoints[i]+1; - - // get the required lock value - int32 ReqValue=0; - if (lockInfo) - { - // check for lock - key pair - bool ok = false; - for(int it = 0; it < 5; ++it) - { - if(lockInfo->keytype[it]==LOCK_KEY_ITEM && lockInfo->key[it] && m_CastItem && m_CastItem->GetEntry()==lockInfo->key[it]) - { - // if so, we're good to go - ok = true; - break; - } - } - if(ok) - break; - - if (m_spellInfo->EffectMiscValue[i] == LOCKTYPE_PICKLOCK) - ReqValue = lockInfo->requiredlockskill; - else - ReqValue = lockInfo->requiredminingskill; - } - - // skill doesn't meet the required value - if (ReqValue > SkillValue) - return SPELL_FAILED_LOW_CASTLEVEL; - - // chance for failure in orange gather / lockpick (gathering skill can't fail at maxskill) - if((canFailAtMax || SkillValue < sWorld.GetConfigMaxSkillValue()) && ReqValue > irand(SkillValue-25, SkillValue+37)) - return SPELL_FAILED_TRY_AGAIN; - - break; - } - case SPELL_EFFECT_SUMMON_DEAD_PET: - { - Creature *pet = m_caster->GetPet(); - if(!pet) - return SPELL_FAILED_NO_PET; - - if(pet->isAlive()) - return SPELL_FAILED_ALREADY_HAVE_SUMMON; - - break; - } - // This is generic summon effect now and don't make this check for summon types similar - // SPELL_EFFECT_SUMMON_CRITTER, SPELL_EFFECT_SUMMON_WILD or SPELL_EFFECT_SUMMON_GUARDIAN. - // These won't show up in m_caster->GetPetGUID() - case SPELL_EFFECT_SUMMON: - { - switch(m_spellInfo->EffectMiscValueB[i]) - { - case SUMMON_TYPE_POSESSED: - case SUMMON_TYPE_POSESSED2: - case SUMMON_TYPE_DEMON: - case SUMMON_TYPE_SUMMON: - { - if(m_caster->GetPetGUID()) - return SPELL_FAILED_ALREADY_HAVE_SUMMON; - - if(m_caster->GetCharmGUID()) - return SPELL_FAILED_ALREADY_HAVE_CHARM; - break; - } - } - break; - } - // Don't make this check for SPELL_EFFECT_SUMMON_CRITTER, SPELL_EFFECT_SUMMON_WILD or SPELL_EFFECT_SUMMON_GUARDIAN. - // These won't show up in m_caster->GetPetGUID() - case SPELL_EFFECT_SUMMON_POSSESSED: - case SPELL_EFFECT_SUMMON_PHANTASM: - case SPELL_EFFECT_SUMMON_DEMON: - { - if(m_caster->GetPetGUID()) - return SPELL_FAILED_ALREADY_HAVE_SUMMON; - - if(m_caster->GetCharmGUID()) - return SPELL_FAILED_ALREADY_HAVE_CHARM; - - break; - } - case SPELL_EFFECT_SUMMON_PET: - { - if(m_caster->GetPetGUID()) //let warlock do a replacement summon - { - - Pet* pet = ((Player*)m_caster)->GetPet(); - - if (m_caster->GetTypeId()==TYPEID_PLAYER && m_caster->getClass()==CLASS_WARLOCK) - { - if (strict) //starting cast, trigger pet stun (cast by pet so it doesn't attack player) - pet->CastSpell(pet, 32752, true, NULL, NULL, pet->GetGUID()); - } - else - return SPELL_FAILED_ALREADY_HAVE_SUMMON; - } - - if(m_caster->GetCharmGUID()) - return SPELL_FAILED_ALREADY_HAVE_CHARM; - - break; - } - case SPELL_EFFECT_SUMMON_PLAYER: - { - if(m_caster->GetTypeId()!=TYPEID_PLAYER) - return SPELL_FAILED_BAD_TARGETS; - if(!((Player*)m_caster)->GetSelection()) - return SPELL_FAILED_BAD_TARGETS; - - Player* target = objmgr.GetPlayer(((Player*)m_caster)->GetSelection()); - if( !target || ((Player*)m_caster)==target || !target->IsInSameRaidWith((Player*)m_caster) ) - return SPELL_FAILED_BAD_TARGETS; - - // check if our map is dungeon - if( sMapStore.LookupEntry(m_caster->GetMapId())->IsDungeon() ) - { - InstanceTemplate const* instance = ObjectMgr::GetInstanceTemplate(m_caster->GetMapId()); - if(!instance) - return SPELL_FAILED_TARGET_NOT_IN_INSTANCE; - if ( instance->levelMin > target->getLevel() ) - return SPELL_FAILED_LOWLEVEL; - if ( instance->levelMax && instance->levelMax < target->getLevel() ) - return SPELL_FAILED_HIGHLEVEL; - } - break; - } - case SPELL_EFFECT_LEAP: - case SPELL_EFFECT_TELEPORT_UNITS_FACE_CASTER: - { - float dis = GetSpellRadius(sSpellRadiusStore.LookupEntry(m_spellInfo->EffectRadiusIndex[i])); - float fx = m_caster->GetPositionX() + dis * cos(m_caster->GetOrientation()); - float fy = m_caster->GetPositionY() + dis * sin(m_caster->GetOrientation()); - // teleport a bit above terrain level to avoid falling below it - float fz = MapManager::Instance().GetBaseMap(m_caster->GetMapId())->GetHeight(fx,fy,m_caster->GetPositionZ(),true); - if(fz <= INVALID_HEIGHT) // note: this also will prevent use effect in instances without vmaps height enabled - return SPELL_FAILED_TRY_AGAIN; - - float caster_pos_z = m_caster->GetPositionZ(); - // Control the caster to not climb or drop when +-fz > 8 - if(!(fz<=caster_pos_z+8 && fz>=caster_pos_z-8)) - return SPELL_FAILED_TRY_AGAIN; - - // not allow use this effect at battleground until battleground start - if(m_caster->GetTypeId()==TYPEID_PLAYER) - if(BattleGround const *bg = ((Player*)m_caster)->GetBattleGround()) - if(bg->GetStatus() != STATUS_IN_PROGRESS) - return SPELL_FAILED_TRY_AGAIN; - break; - } - case SPELL_EFFECT_STEAL_BENEFICIAL_BUFF: - { - if (m_targets.getUnitTarget()==m_caster) - return SPELL_FAILED_BAD_TARGETS; - break; - } - default:break; - } - } - - for (int i = 0; i < 3; i++) - { - switch(m_spellInfo->EffectApplyAuraName[i]) - { - case SPELL_AURA_MOD_POSSESS: - case SPELL_AURA_MOD_CHARM: - { - if(m_caster->GetPetGUID()) - return SPELL_FAILED_ALREADY_HAVE_SUMMON; - - if(m_caster->GetCharmGUID()) - return SPELL_FAILED_ALREADY_HAVE_CHARM; - - if(m_caster->GetCharmerGUID()) - return SPELL_FAILED_CHARMED; - - if(!m_targets.getUnitTarget()) - return SPELL_FAILED_BAD_IMPLICIT_TARGETS; - - if(m_targets.getUnitTarget()->GetCharmerGUID()) - return SPELL_FAILED_CHARMED; - - if(int32(m_targets.getUnitTarget()->getLevel()) > CalculateDamage(i,m_targets.getUnitTarget())) - return SPELL_FAILED_HIGHLEVEL; - };break; - case SPELL_AURA_MOUNTED: - { - if (m_caster->IsInWater()) - return SPELL_FAILED_ONLY_ABOVEWATER; - - if (m_caster->GetTypeId()==TYPEID_PLAYER && ((Player*)m_caster)->GetTransport()) - return SPELL_FAILED_NO_MOUNTS_ALLOWED; - - // Ignore map check if spell have AreaId. AreaId already checked and this prevent special mount spells - if (m_caster->GetTypeId()==TYPEID_PLAYER && !sMapStore.LookupEntry(m_caster->GetMapId())->IsMountAllowed() && !m_IsTriggeredSpell && !m_spellInfo->AreaId) - return SPELL_FAILED_NO_MOUNTS_ALLOWED; - - if (m_caster->GetAreaId()==35) - return SPELL_FAILED_NO_MOUNTS_ALLOWED; - - ShapeshiftForm form = m_caster->m_form; - if( form == FORM_CAT || form == FORM_TREE || form == FORM_TRAVEL || - form == FORM_AQUA || form == FORM_BEAR || form == FORM_DIREBEAR || - form == FORM_CREATUREBEAR || form == FORM_GHOSTWOLF || form == FORM_FLIGHT || - form == FORM_FLIGHT_EPIC || form == FORM_MOONKIN ) - return SPELL_FAILED_NOT_SHAPESHIFT; - - break; - } - case SPELL_AURA_RANGED_ATTACK_POWER_ATTACKER_BONUS: - { - if(!m_targets.getUnitTarget()) - return SPELL_FAILED_BAD_IMPLICIT_TARGETS; - - // can be casted at non-friendly unit or own pet/charm - if(m_caster->IsFriendlyTo(m_targets.getUnitTarget())) - return SPELL_FAILED_TARGET_FRIENDLY; - };break; - case SPELL_AURA_MOD_INCREASE_FLIGHT_SPEED: - case SPELL_AURA_FLY: - { - // not allow cast fly spells at old maps by players (all spells is self target) - if(m_caster->GetTypeId()==TYPEID_PLAYER) - { - if( !((Player*)m_caster)->isGameMaster() && - GetVirtualMapForMapAndZone(m_caster->GetMapId(),m_caster->GetZoneId()) != 530) - return SPELL_FAILED_NOT_HERE; - } - };break; - case SPELL_AURA_PERIODIC_MANA_LEECH: - { - if (!m_targets.getUnitTarget()) - return SPELL_FAILED_BAD_IMPLICIT_TARGETS; - - if (m_caster->GetTypeId()!=TYPEID_PLAYER || m_CastItem) - break; - - if(m_targets.getUnitTarget()->getPowerType()!=POWER_MANA) - return SPELL_FAILED_BAD_TARGETS; - break; - } - default:break; - } - } - - // all ok - return 0; -} - -int16 Spell::PetCanCast(Unit* target) -{ - if(!m_caster->isAlive()) - return SPELL_FAILED_CASTER_DEAD; - - if(m_caster->IsNonMeleeSpellCasted(false)) //prevent spellcast interuption by another spellcast - return SPELL_FAILED_SPELL_IN_PROGRESS; - if(m_caster->isInCombat() && IsNonCombatSpell(m_spellInfo)) - return SPELL_FAILED_AFFECTING_COMBAT; - - if(m_caster->GetTypeId()==TYPEID_UNIT && (((Creature*)m_caster)->isPet() || m_caster->isCharmed())) - { - //dead owner (pets still alive when owners ressed?) - if(m_caster->GetCharmerOrOwner() && !m_caster->GetCharmerOrOwner()->isAlive()) - return SPELL_FAILED_CASTER_DEAD; - - if(!target && m_targets.getUnitTarget()) - target = m_targets.getUnitTarget(); - - bool need = false; - for(uint32 i = 0;i<3;i++) - { - if(m_spellInfo->EffectImplicitTargetA[i] == TARGET_CHAIN_DAMAGE || m_spellInfo->EffectImplicitTargetA[i] == TARGET_SINGLE_FRIEND || m_spellInfo->EffectImplicitTargetA[i] == TARGET_DUELVSPLAYER || m_spellInfo->EffectImplicitTargetA[i] == TARGET_SINGLE_PARTY || m_spellInfo->EffectImplicitTargetA[i] == TARGET_CURRENT_ENEMY_COORDINATES) - { - need = true; - if(!target) - return SPELL_FAILED_BAD_IMPLICIT_TARGETS; - break; - } - } - if(need) - m_targets.setUnitTarget(target); - - Unit* _target = m_targets.getUnitTarget(); - - if(_target) //for target dead/target not valid - { - if(!_target->isAlive()) - return SPELL_FAILED_BAD_TARGETS; - - if(IsPositiveSpell(m_spellInfo->Id)) - { - if(m_caster->IsHostileTo(_target)) - return SPELL_FAILED_BAD_TARGETS; - } - else - { - bool duelvsplayertar = false; - for(int j=0;j<3;j++) - { - //TARGET_DUELVSPLAYER is positive AND negative - duelvsplayertar |= (m_spellInfo->EffectImplicitTargetA[j] == TARGET_DUELVSPLAYER); - } - if(m_caster->IsFriendlyTo(target) && !duelvsplayertar) - { - return SPELL_FAILED_BAD_TARGETS; - } - } - } - //cooldown - if(((Creature*)m_caster)->HasSpellCooldown(m_spellInfo->Id)) - return SPELL_FAILED_NOT_READY; - } - - uint16 result = CanCast(true); - if(result != 0) - return result; - else - return -1; //this allows to check spell fail 0, in combat -} - -uint8 Spell::CheckCasterAuras() const -{ - // Flag drop spells totally immuned to caster auras - // FIXME: find more nice check for all totally immuned spells - // AttributesEx3 & 0x10000000? - if(m_spellInfo->Id==23336 || m_spellInfo->Id==23334 || m_spellInfo->Id==34991) - return 0; - - uint8 school_immune = 0; - uint32 mechanic_immune = 0; - uint32 dispel_immune = 0; - - //Check if the spell grants school or mechanic immunity. - //We use bitmasks so the loop is done only once and not on every aura check below. - if ( m_spellInfo->AttributesEx & SPELL_ATTR_EX_DISPEL_AURAS_ON_IMMUNITY ) - { - for(int i = 0;i < 3; i ++) - { - if(m_spellInfo->EffectApplyAuraName[i] == SPELL_AURA_SCHOOL_IMMUNITY) - school_immune |= uint32(m_spellInfo->EffectMiscValue[i]); - else if(m_spellInfo->EffectApplyAuraName[i] == SPELL_AURA_MECHANIC_IMMUNITY) - mechanic_immune |= 1 << uint32(m_spellInfo->EffectMiscValue[i]); - else if(m_spellInfo->EffectApplyAuraName[i] == SPELL_AURA_DISPEL_IMMUNITY) - dispel_immune |= GetDispellMask(DispelType(m_spellInfo->EffectMiscValue[i])); - } - //immune movement impairement and loss of control - if(m_spellInfo->Id==(uint32)42292) - mechanic_immune = IMMUNE_TO_MOVEMENT_IMPAIRMENT_AND_LOSS_CONTROL_MASK; - } - - //Check whether the cast should be prevented by any state you might have. - uint8 prevented_reason = 0; - // Have to check if there is a stun aura. Otherwise will have problems with ghost aura apply while logging out - if(!(m_spellInfo->AttributesEx5 & SPELL_ATTR_EX5_USABLE_WHILE_STUNNED) && m_caster->HasAuraType(SPELL_AURA_MOD_STUN)) - prevented_reason = SPELL_FAILED_STUNNED; - else if(m_caster->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_CONFUSED) && !(m_spellInfo->AttributesEx5 & SPELL_ATTR_EX5_USABLE_WHILE_CONFUSED)) - prevented_reason = SPELL_FAILED_CONFUSED; - else if(m_caster->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_FLEEING) && !(m_spellInfo->AttributesEx5 & SPELL_ATTR_EX5_USABLE_WHILE_FEARED)) - prevented_reason = SPELL_FAILED_FLEEING; - else if(m_caster->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SILENCED) && m_spellInfo->PreventionType==SPELL_PREVENTION_TYPE_SILENCE) - prevented_reason = SPELL_FAILED_SILENCED; - else if(m_caster->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PACIFIED) && m_spellInfo->PreventionType==SPELL_PREVENTION_TYPE_PACIFY) - prevented_reason = SPELL_FAILED_PACIFIED; - - // Attr must make flag drop spell totally immuned from all effects - if(prevented_reason) - { - if(school_immune || mechanic_immune || dispel_immune) - { - //Checking auras is needed now, because you are prevented by some state but the spell grants immunity. - Unit::AuraMap const& auras = m_caster->GetAuras(); - for(Unit::AuraMap::const_iterator itr = auras.begin(); itr != auras.end(); itr++) - { - if(itr->second) - { - if( GetSpellMechanicMask(itr->second->GetSpellProto(), itr->second->GetEffIndex()) & mechanic_immune ) - continue; - if( GetSpellSchoolMask(itr->second->GetSpellProto()) & school_immune ) - continue; - if( (1<<(itr->second->GetSpellProto()->Dispel)) & dispel_immune) - continue; - - //Make a second check for spell failed so the right SPELL_FAILED message is returned. - //That is needed when your casting is prevented by multiple states and you are only immune to some of them. - switch(itr->second->GetModifier()->m_auraname) - { - case SPELL_AURA_MOD_STUN: - if (!(m_spellInfo->AttributesEx5 & SPELL_ATTR_EX5_USABLE_WHILE_STUNNED)) - return SPELL_FAILED_STUNNED; - break; - case SPELL_AURA_MOD_CONFUSE: - if (!(m_spellInfo->AttributesEx5 & SPELL_ATTR_EX5_USABLE_WHILE_CONFUSED)) - return SPELL_FAILED_CONFUSED; - break; - case SPELL_AURA_MOD_FEAR: - if (!(m_spellInfo->AttributesEx5 & SPELL_ATTR_EX5_USABLE_WHILE_FEARED)) - return SPELL_FAILED_FLEEING; - break; - case SPELL_AURA_MOD_SILENCE: - case SPELL_AURA_MOD_PACIFY: - case SPELL_AURA_MOD_PACIFY_SILENCE: - if( m_spellInfo->PreventionType==SPELL_PREVENTION_TYPE_PACIFY) - return SPELL_FAILED_PACIFIED; - else if ( m_spellInfo->PreventionType==SPELL_PREVENTION_TYPE_SILENCE) - return SPELL_FAILED_SILENCED; - break; - } - } - } - } - //You are prevented from casting and the spell casted does not grant immunity. Return a failed error. - else - return prevented_reason; - } - return 0; // all ok -} - -bool Spell::CanAutoCast(Unit* target) -{ - uint64 targetguid = target->GetGUID(); - - for(uint32 j = 0;j<3;j++) - { - if(m_spellInfo->Effect[j] == SPELL_EFFECT_APPLY_AURA) - { - if( m_spellInfo->StackAmount <= 1) - { - if( target->HasAura(m_spellInfo->Id, j) ) - return false; - } - else - { - if( target->GetAuras().count(Unit::spellEffectPair(m_spellInfo->Id, j)) >= m_spellInfo->StackAmount) - return false; - } - } - else if ( IsAreaAuraEffect( m_spellInfo->Effect[j] )) - { - if( target->HasAura(m_spellInfo->Id, j) ) - return false; - } - } - - int16 result = PetCanCast(target); - - if(result == -1 || result == SPELL_FAILED_UNIT_NOT_INFRONT) - { - FillTargetMap(); - //check if among target units, our WANTED target is as well (->only self cast spells return false) - for(std::list::iterator ihit= m_UniqueTargetInfo.begin();ihit != m_UniqueTargetInfo.end();++ihit) - if( ihit->targetGUID == targetguid ) - return true; - } - return false; //target invalid -} - -uint8 Spell::CheckRange(bool strict) -{ - float range_mod; - - // self cast doesn't need range checking -- also for Starshards fix - if (m_spellInfo->rangeIndex == 1) return 0; - - if (strict) //add radius of caster - range_mod = 1.25; - else //add radius of caster and ~5 yds "give" - range_mod = 6.25; - - SpellRangeEntry const* srange = sSpellRangeStore.LookupEntry(m_spellInfo->rangeIndex); - float max_range = GetSpellMaxRange(srange) + range_mod; - float min_range = GetSpellMinRange(srange); - - if(Player* modOwner = m_caster->GetSpellModOwner()) - modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_RANGE, max_range, this); - - Unit *target = m_targets.getUnitTarget(); - - if(target && target != m_caster) - { - // distance from target center in checks - float dist = m_caster->GetDistance(target->GetPositionX(),target->GetPositionY(),target->GetPositionZ()); - if(dist > max_range) - return SPELL_FAILED_OUT_OF_RANGE; //0x5A; - if(dist < min_range) - return SPELL_FAILED_TOO_CLOSE; - if( !m_IsTriggeredSpell && m_caster->GetTypeId() == TYPEID_PLAYER && - !IsPositiveSpell(m_spellInfo->Id) && !m_caster->HasInArc( M_PI, target ) ) - { - // Spell-Family Related Checks - switch (m_spellInfo->SpellFamilyName) - { - case SPELLFAMILY_PRIEST: - { - // Shadow Word: Death, castable without facing - if (m_spellInfo->SpellFamilyFlags & 0x200000000LL) - return 0; // this is not TARGET_FLAG_DEST_LOCATION so we can return safely - break; - } - case SPELLFAMILY_PALADIN: - { - // Holy Shock, require facing - if (m_spellInfo->SpellFamilyFlags & 0x200000LL) - return SPELL_FAILED_UNIT_NOT_INFRONT; - break; - } - case SPELLFAMILY_WARRIOR: - { - // Charge, require facing - if (m_spellInfo->SpellFamilyFlags & 1) - return SPELL_FAILED_UNIT_NOT_INFRONT; - break; - } - } - - // Ranged Weapon - if (IsRangedSpell()) - return SPELL_FAILED_UNIT_NOT_INFRONT; - - // Melee Combat - if (m_spellInfo->rangeIndex == 2) - return SPELL_FAILED_UNIT_NOT_INFRONT; - - // Missile Effect - if (m_spellInfo->speed > 0) - return SPELL_FAILED_UNIT_NOT_INFRONT; - - // Channeled Spells need facing - if (IsChanneledSpell(m_spellInfo)) - return SPELL_FAILED_UNIT_NOT_INFRONT; - - // Direct Damage and charge effects - for (uint8 i=0;i<3;++i) - { - if (m_spellInfo->Effect[i] == SPELL_EFFECT_SCHOOL_DAMAGE || - m_spellInfo->Effect[i] == SPELL_EFFECT_POWER_BURN || - m_spellInfo->Effect[i] == SPELL_EFFECT_HEALTH_LEECH || - m_spellInfo->Effect[i] == SPELL_EFFECT_CHARGE) - return SPELL_FAILED_UNIT_NOT_INFRONT; - } - } - } - - if(m_targets.m_targetMask == TARGET_FLAG_DEST_LOCATION && m_targets.m_destX != 0 && m_targets.m_destY != 0 && m_targets.m_destZ != 0) - { - float dist = m_caster->GetDistance(m_targets.m_destX, m_targets.m_destY, m_targets.m_destZ); - if(dist > max_range) - return SPELL_FAILED_OUT_OF_RANGE; - if(dist < min_range) - return SPELL_FAILED_TOO_CLOSE; - } - - return 0; // ok -} - -int32 Spell::CalculatePowerCost() -{ - // item cast not used power - if(m_CastItem) - return 0; - - // Spell drain all exist power on cast (Only paladin lay of Hands) - if (m_spellInfo->AttributesEx & SPELL_ATTR_EX_DRAIN_ALL_POWER) - { - // If power type - health drain all - if (m_spellInfo->powerType == POWER_HEALTH) - return m_caster->GetHealth(); - // Else drain all power - if (m_spellInfo->powerType < MAX_POWERS) - return m_caster->GetPower(Powers(m_spellInfo->powerType)); - sLog.outError("Spell::CalculateManaCost: Unknown power type '%d' in spell %d", m_spellInfo->powerType, m_spellInfo->Id); - return 0; - } - - // Base powerCost - int32 powerCost = m_spellInfo->manaCost; - // PCT cost from total amount - if (m_spellInfo->ManaCostPercentage) - { - switch (m_spellInfo->powerType) - { - // health as power used - case POWER_HEALTH: - powerCost += m_spellInfo->ManaCostPercentage * m_caster->GetCreateHealth() / 100; - break; - case POWER_MANA: - powerCost += m_spellInfo->ManaCostPercentage * m_caster->GetCreateMana() / 100; - break; - case POWER_RAGE: - case POWER_FOCUS: - case POWER_ENERGY: - case POWER_HAPPINESS: - // case POWER_RUNES: - powerCost += m_spellInfo->ManaCostPercentage * m_caster->GetMaxPower(Powers(m_spellInfo->powerType)) / 100; - break; - default: - sLog.outError("Spell::CalculateManaCost: Unknown power type '%d' in spell %d", m_spellInfo->powerType, m_spellInfo->Id); - return 0; - } - } - SpellSchools school = GetFirstSchoolInMask(m_spellSchoolMask); - // Flat mod from caster auras by spell school - powerCost += m_caster->GetInt32Value(UNIT_FIELD_POWER_COST_MODIFIER + school); - // Shiv - costs 20 + weaponSpeed*10 energy (apply only to non-triggered spell with energy cost) - if ( m_spellInfo->AttributesEx4 & SPELL_ATTR_EX4_SPELL_VS_EXTEND_COST ) - powerCost += m_caster->GetAttackTime(OFF_ATTACK)/100; - // Apply cost mod by spell - if(Player* modOwner = m_caster->GetSpellModOwner()) - modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_COST, powerCost, this); - - if(m_spellInfo->Attributes & SPELL_ATTR_LEVEL_DAMAGE_CALCULATION) - powerCost = int32(powerCost/ (1.117f* m_spellInfo->spellLevel / m_caster->getLevel() -0.1327f)); - - // PCT mod from user auras by school - powerCost = int32(powerCost * (1.0f+m_caster->GetFloatValue(UNIT_FIELD_POWER_COST_MULTIPLIER+school))); - if (powerCost < 0) - powerCost = 0; - return powerCost; -} - -uint8 Spell::CheckPower() -{ - // item cast not used power - if(m_CastItem) - return 0; - - // health as power used - need check health amount - if(m_spellInfo->powerType == POWER_HEALTH) - { - if(m_caster->GetHealth() <= m_powerCost) - return SPELL_FAILED_CASTER_AURASTATE; - return 0; - } - // Check valid power type - if( m_spellInfo->powerType >= MAX_POWERS ) - { - sLog.outError("Spell::CheckMana: Unknown power type '%d'", m_spellInfo->powerType); - return SPELL_FAILED_UNKNOWN; - } - // Check power amount - Powers powerType = Powers(m_spellInfo->powerType); - if(m_caster->GetPower(powerType) < m_powerCost) - return SPELL_FAILED_NO_POWER; - else - return 0; -} - -uint8 Spell::CheckItems() -{ - if (m_caster->GetTypeId() != TYPEID_PLAYER) - return 0; - - uint32 itemid, itemcount; - Player* p_caster = (Player*)m_caster; - - if(m_CastItem) - { - itemid = m_CastItem->GetEntry(); - if( !p_caster->HasItemCount(itemid,1) ) - return SPELL_FAILED_ITEM_NOT_READY; - else - { - ItemPrototype const *proto = m_CastItem->GetProto(); - if(!proto) - return SPELL_FAILED_ITEM_NOT_READY; - - for (int i = 0; i<5; i++) - { - if (proto->Spells[i].SpellCharges) - { - if(m_CastItem->GetSpellCharges(i)==0) - return SPELL_FAILED_NO_CHARGES_REMAIN; - } - } - - uint32 ItemClass = proto->Class; - if (ItemClass == ITEM_CLASS_CONSUMABLE && m_targets.getUnitTarget()) - { - for (int i = 0; i < 3; i++) - { - // skip check, pet not required like checks, and for TARGET_PET m_targets.getUnitTarget() is not the real target but the caster - if (m_spellInfo->EffectImplicitTargetA[i] == TARGET_PET) - continue; - - if (m_spellInfo->Effect[i] == SPELL_EFFECT_HEAL) - if (m_targets.getUnitTarget()->GetHealth() == m_targets.getUnitTarget()->GetMaxHealth()) - return (uint8)SPELL_FAILED_ALREADY_AT_FULL_HEALTH; - - // Mana Potion, Rage Potion, Thistle Tea(Rogue), ... - if (m_spellInfo->Effect[i] == SPELL_EFFECT_ENERGIZE) - { - if(m_spellInfo->EffectMiscValue[i] < 0 || m_spellInfo->EffectMiscValue[i] >= MAX_POWERS) - return (uint8)SPELL_FAILED_ALREADY_AT_FULL_POWER; - - Powers power = Powers(m_spellInfo->EffectMiscValue[i]); - - if (m_targets.getUnitTarget()->GetPower(power) == m_targets.getUnitTarget()->GetMaxPower(power)) - return (uint8)SPELL_FAILED_ALREADY_AT_FULL_POWER; - } - } - } - } - } - - if(m_targets.getItemTargetGUID()) - { - if(m_caster->GetTypeId() != TYPEID_PLAYER) - return SPELL_FAILED_BAD_TARGETS; - - if(!m_targets.getItemTarget()) - return SPELL_FAILED_ITEM_GONE; - - if(!m_targets.getItemTarget()->IsFitToSpellRequirements(m_spellInfo)) - return SPELL_FAILED_EQUIPPED_ITEM_CLASS; - } - // if not item target then required item must be equipped - else - { - if(m_caster->GetTypeId() == TYPEID_PLAYER && !((Player*)m_caster)->HasItemFitToSpellReqirements(m_spellInfo)) - return SPELL_FAILED_EQUIPPED_ITEM_CLASS; - } - - if(m_spellInfo->RequiresSpellFocus) - { - CellPair p(MaNGOS::ComputeCellPair(m_caster->GetPositionX(), m_caster->GetPositionY())); - Cell cell(p); - cell.data.Part.reserved = ALL_DISTRICT; - - GameObject* ok = NULL; - MaNGOS::GameObjectFocusCheck go_check(m_caster,m_spellInfo->RequiresSpellFocus); - MaNGOS::GameObjectSearcher checker(ok,go_check); - - TypeContainerVisitor, GridTypeMapContainer > object_checker(checker); - CellLock cell_lock(cell, p); - cell_lock->Visit(cell_lock, object_checker, *MapManager::Instance().GetMap(m_caster->GetMapId(), m_caster)); - - if(!ok) - return (uint8)SPELL_FAILED_REQUIRES_SPELL_FOCUS; - - focusObject = ok; // game object found in range - } - - if (!(m_spellInfo->AttributesEx5 & SPELL_ATTR_EX5_NO_REAGENT_WHILE_PREP && - m_caster->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PREPARATION))) - { - for(uint32 i=0;i<8;i++) - { - if(m_spellInfo->Reagent[i] <= 0) - continue; - - itemid = m_spellInfo->Reagent[i]; - itemcount = m_spellInfo->ReagentCount[i]; - - // if CastItem is also spell reagent - if( m_CastItem && m_CastItem->GetEntry() == itemid ) - { - ItemPrototype const *proto = m_CastItem->GetProto(); - if(!proto) - return SPELL_FAILED_ITEM_NOT_READY; - for(int s=0;s<5;s++) - { - // CastItem will be used up and does not count as reagent - int32 charges = m_CastItem->GetSpellCharges(s); - if (proto->Spells[s].SpellCharges < 0 && abs(charges) < 2) - { - ++itemcount; - break; - } - } - } - if( !p_caster->HasItemCount(itemid,itemcount) ) - return (uint8)SPELL_FAILED_ITEM_NOT_READY; //0x54 - } - } - - uint32 totems = 2; - for(int i=0;i<2;++i) - { - if(m_spellInfo->Totem[i] != 0) - { - if( p_caster->HasItemCount(m_spellInfo->Totem[i],1) ) - { - totems -= 1; - continue; - } - }else - totems -= 1; - } - if(totems != 0) - return (uint8)SPELL_FAILED_TOTEMS; //0x7C - - //Check items for TotemCategory - uint32 TotemCategory = 2; - for(int i=0;i<2;++i) - { - if(m_spellInfo->TotemCategory[i] != 0) - { - if( p_caster->HasItemTotemCategory(m_spellInfo->TotemCategory[i]) ) - { - TotemCategory -= 1; - continue; - } - } - else - TotemCategory -= 1; - } - if(TotemCategory != 0) - return (uint8)SPELL_FAILED_TOTEM_CATEGORY; //0x7B - - for(int i = 0; i < 3; i++) - { - switch (m_spellInfo->Effect[i]) - { - case SPELL_EFFECT_CREATE_ITEM: - { - if (!m_IsTriggeredSpell && m_spellInfo->EffectItemType[i]) - { - ItemPosCountVec dest; - uint8 msg = p_caster->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, m_spellInfo->EffectItemType[i], 1 ); - if (msg != EQUIP_ERR_OK ) - { - p_caster->SendEquipError( msg, NULL, NULL ); - return SPELL_FAILED_DONT_REPORT; - } - } - break; - } - case SPELL_EFFECT_ENCHANT_ITEM: - { - Item* targetItem = m_targets.getItemTarget(); - if(!targetItem) - return SPELL_FAILED_ITEM_NOT_FOUND; - - if( targetItem->GetProto()->ItemLevel < m_spellInfo->baseLevel ) - return SPELL_FAILED_LOWLEVEL; - // Not allow enchant in trade slot for some enchant type - if( targetItem->GetOwner() != m_caster ) - { - uint32 enchant_id = m_spellInfo->EffectMiscValue[i]; - SpellItemEnchantmentEntry const *pEnchant = sSpellItemEnchantmentStore.LookupEntry(enchant_id); - if(!pEnchant) - return SPELL_FAILED_ERROR; - if (pEnchant->slot & ENCHANTMENT_CAN_SOULBOUND) - return SPELL_FAILED_NOT_TRADEABLE; - } - break; - } - case SPELL_EFFECT_ENCHANT_ITEM_TEMPORARY: - { - Item *item = m_targets.getItemTarget(); - if(!item) - return SPELL_FAILED_ITEM_NOT_FOUND; - // Not allow enchant in trade slot for some enchant type - if( item->GetOwner() != m_caster ) - { - uint32 enchant_id = m_spellInfo->EffectMiscValue[i]; - SpellItemEnchantmentEntry const *pEnchant = sSpellItemEnchantmentStore.LookupEntry(enchant_id); - if(!pEnchant) - return SPELL_FAILED_ERROR; - if (pEnchant->slot & ENCHANTMENT_CAN_SOULBOUND) - return SPELL_FAILED_NOT_TRADEABLE; - } - break; - } - case SPELL_EFFECT_ENCHANT_HELD_ITEM: - // check item existence in effect code (not output errors at offhand hold item effect to main hand for example - break; - case SPELL_EFFECT_DISENCHANT: - { - if(!m_targets.getItemTarget()) - return SPELL_FAILED_CANT_BE_DISENCHANTED; - - // prevent disenchanting in trade slot - if( m_targets.getItemTarget()->GetOwnerGUID() != m_caster->GetGUID() ) - return SPELL_FAILED_CANT_BE_DISENCHANTED; - - ItemPrototype const* itemProto = m_targets.getItemTarget()->GetProto(); - if(!itemProto) - return SPELL_FAILED_CANT_BE_DISENCHANTED; - - uint32 item_quality = itemProto->Quality; - // 2.0.x addon: Check player enchanting level agains the item desenchanting requirements - uint32 item_disenchantskilllevel = itemProto->RequiredDisenchantSkill; - if (item_disenchantskilllevel == uint32(-1)) - return SPELL_FAILED_CANT_BE_DISENCHANTED; - if (item_disenchantskilllevel > p_caster->GetSkillValue(SKILL_ENCHANTING)) - return SPELL_FAILED_LOW_CASTLEVEL; - if(item_quality > 4 || item_quality < 2) - return SPELL_FAILED_CANT_BE_DISENCHANTED; - if(itemProto->Class != ITEM_CLASS_WEAPON && itemProto->Class != ITEM_CLASS_ARMOR) - return SPELL_FAILED_CANT_BE_DISENCHANTED; - if (!itemProto->DisenchantID) - return SPELL_FAILED_CANT_BE_DISENCHANTED; - break; - } - case SPELL_EFFECT_PROSPECTING: - { - if(!m_targets.getItemTarget()) - return SPELL_FAILED_CANT_BE_PROSPECTED; - //ensure item is a prospectable ore - if(!(m_targets.getItemTarget()->GetProto()->BagFamily & BAG_FAMILY_MASK_MINING_SUPP) || m_targets.getItemTarget()->GetProto()->Class != ITEM_CLASS_TRADE_GOODS) - return SPELL_FAILED_CANT_BE_PROSPECTED; - //prevent prospecting in trade slot - if( m_targets.getItemTarget()->GetOwnerGUID() != m_caster->GetGUID() ) - return SPELL_FAILED_CANT_BE_PROSPECTED; - //Check for enough skill in jewelcrafting - uint32 item_prospectingskilllevel = m_targets.getItemTarget()->GetProto()->RequiredSkillRank; - if(item_prospectingskilllevel >p_caster->GetSkillValue(SKILL_JEWELCRAFTING)) - return SPELL_FAILED_LOW_CASTLEVEL; - //make sure the player has the required ores in inventory - if(m_targets.getItemTarget()->GetCount() < 5) - return SPELL_FAILED_PROSPECT_NEED_MORE; - - if(!LootTemplates_Prospecting.HaveLootFor(m_targets.getItemTargetEntry())) - return SPELL_FAILED_CANT_BE_PROSPECTED; - - break; - } - case SPELL_EFFECT_WEAPON_DAMAGE: - case SPELL_EFFECT_WEAPON_DAMAGE_NOSCHOOL: - { - if(m_caster->GetTypeId() != TYPEID_PLAYER) return SPELL_FAILED_TARGET_NOT_PLAYER; - if( m_attackType != RANGED_ATTACK ) - break; - Item *pItem = ((Player*)m_caster)->GetWeaponForAttack(m_attackType); - if(!pItem || pItem->IsBroken()) - return SPELL_FAILED_EQUIPPED_ITEM; - - switch(pItem->GetProto()->SubClass) - { - case ITEM_SUBCLASS_WEAPON_THROWN: - { - uint32 ammo = pItem->GetEntry(); - if( !((Player*)m_caster)->HasItemCount( ammo, 1 ) ) - return SPELL_FAILED_NO_AMMO; - }; break; - case ITEM_SUBCLASS_WEAPON_GUN: - case ITEM_SUBCLASS_WEAPON_BOW: - case ITEM_SUBCLASS_WEAPON_CROSSBOW: - { - uint32 ammo = ((Player*)m_caster)->GetUInt32Value(PLAYER_AMMO_ID); - if(!ammo) - { - // Requires No Ammo - if(m_caster->GetDummyAura(46699)) - break; // skip other checks - - return SPELL_FAILED_NO_AMMO; - } - - ItemPrototype const *ammoProto = objmgr.GetItemPrototype( ammo ); - if(!ammoProto) - return SPELL_FAILED_NO_AMMO; - - if(ammoProto->Class != ITEM_CLASS_PROJECTILE) - return SPELL_FAILED_NO_AMMO; - - // check ammo ws. weapon compatibility - switch(pItem->GetProto()->SubClass) - { - case ITEM_SUBCLASS_WEAPON_BOW: - case ITEM_SUBCLASS_WEAPON_CROSSBOW: - if(ammoProto->SubClass!=ITEM_SUBCLASS_ARROW) - return SPELL_FAILED_NO_AMMO; - break; - case ITEM_SUBCLASS_WEAPON_GUN: - if(ammoProto->SubClass!=ITEM_SUBCLASS_BULLET) - return SPELL_FAILED_NO_AMMO; - break; - default: - return SPELL_FAILED_NO_AMMO; - } - - if( !((Player*)m_caster)->HasItemCount( ammo, 1 ) ) - return SPELL_FAILED_NO_AMMO; - }; break; - case ITEM_SUBCLASS_WEAPON_WAND: - default: - break; - } - break; - } - default:break; - } - } - - return uint8(0); -} - -void Spell::Delayed() -{ - if(!m_caster || m_caster->GetTypeId() != TYPEID_PLAYER) - return; - - if (m_spellState == SPELL_STATE_DELAYED) - return; // spell is active and can't be time-backed - - // spells not loosing casting time ( slam, dynamites, bombs.. ) - if(!(m_spellInfo->InterruptFlags & SPELL_INTERRUPT_FLAG_DAMAGE)) - return; - - //check resist chance - int32 resistChance = 100; //must be initialized to 100 for percent modifiers - ((Player*)m_caster)->ApplySpellMod(m_spellInfo->Id,SPELLMOD_NOT_LOSE_CASTING_TIME,resistChance, this); - resistChance += m_caster->GetTotalAuraModifier(SPELL_AURA_RESIST_PUSHBACK) - 100; - if (roll_chance_i(resistChance)) - return; - - int32 delaytime = GetNextDelayAtDamageMsTime(); - - if(int32(m_timer) + delaytime > m_casttime) - { - delaytime = m_casttime - m_timer; - m_timer = m_casttime; - } - else - m_timer += delaytime; - - sLog.outDetail("Spell %u partially interrupted for (%d) ms at damage",m_spellInfo->Id,delaytime); - - WorldPacket data(SMSG_SPELL_DELAYED, 8+4); - data.append(m_caster->GetPackGUID()); - data << uint32(delaytime); - - m_caster->SendMessageToSet(&data,true); -} - -void Spell::DelayedChannel() -{ - if(!m_caster || m_caster->GetTypeId() != TYPEID_PLAYER || getState() != SPELL_STATE_CASTING) - return; - - //check resist chance - int32 resistChance = 100; //must be initialized to 100 for percent modifiers - ((Player*)m_caster)->ApplySpellMod(m_spellInfo->Id,SPELLMOD_NOT_LOSE_CASTING_TIME,resistChance, this); - resistChance += m_caster->GetTotalAuraModifier(SPELL_AURA_RESIST_PUSHBACK) - 100; - if (roll_chance_i(resistChance)) - return; - - int32 delaytime = GetNextDelayAtDamageMsTime(); - - if(int32(m_timer) < delaytime) - { - delaytime = m_timer; - m_timer = 0; - } - else - m_timer -= delaytime; - - sLog.outDebug("Spell %u partially interrupted for %i ms, new duration: %u ms", m_spellInfo->Id, delaytime, m_timer); - - for(std::list::iterator ihit= m_UniqueTargetInfo.begin();ihit != m_UniqueTargetInfo.end();++ihit) - { - if ((*ihit).missCondition == SPELL_MISS_NONE) - { - Unit* unit = m_caster->GetGUID()==ihit->targetGUID ? m_caster : ObjectAccessor::GetUnit(*m_caster, ihit->targetGUID); - if (unit) - { - for (int j=0;j<3;j++) - if( ihit->effectMask & (1<DelayAura(m_spellInfo->Id, j, delaytime); - } - - } - } - - for(int j = 0; j < 3; j++) - { - // partially interrupt persistent area auras - DynamicObject* dynObj = m_caster->GetDynObject(m_spellInfo->Id, j); - if(dynObj) - dynObj->Delay(delaytime); - } - - SendChannelUpdate(m_timer); -} - -void Spell::UpdatePointers() -{ - if(m_originalCasterGUID==m_caster->GetGUID()) - m_originalCaster = m_caster; - else - { - m_originalCaster = ObjectAccessor::GetUnit(*m_caster,m_originalCasterGUID); - if(m_originalCaster && !m_originalCaster->IsInWorld()) m_originalCaster = NULL; - } - - m_targets.Update(m_caster); -} - -bool Spell::IsAffectedBy(SpellEntry const *spellInfo, uint32 effectId) -{ - return spellmgr.IsAffectedBySpell(m_spellInfo,spellInfo->Id,effectId,spellInfo->EffectItemType[effectId]); -} - -bool Spell::CheckTargetCreatureType(Unit* target) const -{ - uint32 spellCreatureTargetMask = m_spellInfo->TargetCreatureType; - - // Curse of Doom : not find another way to fix spell target check :/ - if(m_spellInfo->SpellFamilyName==SPELLFAMILY_WARLOCK && m_spellInfo->SpellFamilyFlags == 0x0200000000LL) - { - // not allow cast at player - if(target->GetTypeId()==TYPEID_PLAYER) - return false; - - spellCreatureTargetMask = 0x7FF; - } - - // Dismiss Pet and Taming Lesson skipped - if(m_spellInfo->Id == 2641 || m_spellInfo->Id == 23356) - spellCreatureTargetMask = 0; - - if (spellCreatureTargetMask) - { - uint32 TargetCreatureType = target->GetCreatureTypeMask(); - - return !TargetCreatureType || (spellCreatureTargetMask & TargetCreatureType); - } - return true; -} - -CurrentSpellTypes Spell::GetCurrentContainer() -{ - if (IsNextMeleeSwingSpell()) - return(CURRENT_MELEE_SPELL); - else if (IsAutoRepeat()) - return(CURRENT_AUTOREPEAT_SPELL); - else if (IsChanneledSpell(m_spellInfo)) - return(CURRENT_CHANNELED_SPELL); - else - return(CURRENT_GENERIC_SPELL); -} - -bool Spell::CheckTarget( Unit* target, uint32 eff, bool hitPhase ) -{ - // Check targets for creature type mask and remove not appropriate (skip explicit self target case, maybe need other explicit targets) - if(m_spellInfo->EffectImplicitTargetA[eff]!=TARGET_SELF ) - { - if (!CheckTargetCreatureType(target)) - return false; - } - - // Check targets for not_selectable unit flag and remove - // A player can cast spells on his pet (or other controlled unit) though in any state - if (target != m_caster && target->GetCharmerOrOwnerGUID() != m_caster->GetGUID()) - { - // any unattackable target skipped - if (target->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE)) - return false; - - // unselectable targets skipped in all cases except TARGET_SCRIPT targeting - // in case TARGET_SCRIPT target selected by server always and can't be cheated - if( target->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE) && - m_spellInfo->EffectImplicitTargetA[eff] != TARGET_SCRIPT && - m_spellInfo->EffectImplicitTargetB[eff] != TARGET_SCRIPT ) - return false; - } - - //Check player targets and remove if in GM mode or GM invisibility (for not self casting case) - if( target != m_caster && target->GetTypeId()==TYPEID_PLAYER) - { - if(((Player*)target)->GetVisibility()==VISIBILITY_OFF) - return false; - - if(((Player*)target)->isGameMaster() && !IsPositiveSpell(m_spellInfo->Id)) - return false; - } - - //Check targets for LOS visibility (except spells without range limitations ) - switch(m_spellInfo->Effect[eff]) - { - case SPELL_EFFECT_SUMMON_PLAYER: // from anywhere - break; - case SPELL_EFFECT_DUMMY: - if(m_spellInfo->Id!=20577) // Cannibalize - break; - //fall through - case SPELL_EFFECT_RESURRECT_NEW: - // player far away, maybe his corpse near? - if(target!=m_caster && !target->IsWithinLOSInMap(m_caster)) - { - if(!m_targets.getCorpseTargetGUID()) - return false; - - Corpse *corpse = ObjectAccessor::GetCorpse(*m_caster,m_targets.getCorpseTargetGUID()); - if(!corpse) - return false; - - if(target->GetGUID()!=corpse->GetOwnerGUID()) - return false; - - if(!corpse->IsWithinLOSInMap(m_caster)) - return false; - } - - // all ok by some way or another, skip normal check - break; - default: // normal case - if(target!=m_caster && !target->IsWithinLOSInMap(m_caster)) - return false; - break; - } - - return true; -} - -Unit* Spell::SelectMagnetTarget() -{ - Unit* target = m_targets.getUnitTarget(); - - if(target && target->HasAuraType(SPELL_AURA_SPELL_MAGNET) && !(m_spellInfo->Attributes & 0x10)) - { - Unit::AuraList const& magnetAuras = target->GetAurasByType(SPELL_AURA_SPELL_MAGNET); - for(Unit::AuraList::const_iterator itr = magnetAuras.begin(); itr != magnetAuras.end(); ++itr) - { - if(Unit* magnet = (*itr)->GetCaster()) - { - if(magnet->IsWithinLOSInMap(m_caster)) - { - target = magnet; - m_targets.setUnitTarget(target); - break; - } - } - } - } - - return target; -} - -bool Spell::IsNeedSendToClient() const -{ - return m_spellInfo->SpellVisual!=0 || IsChanneledSpell(m_spellInfo) || - m_spellInfo->speed > 0.0f || !m_triggeredByAuraSpell && !m_IsTriggeredSpell; -} - -bool Spell::HaveTargetsForEffect( uint8 effect ) const -{ - for(std::list::const_iterator itr= m_UniqueTargetInfo.begin();itr != m_UniqueTargetInfo.end();++itr) - if(itr->effectMask & (1<::const_iterator itr= m_UniqueGOTargetInfo.begin();itr != m_UniqueGOTargetInfo.end();++itr) - if(itr->effectMask & (1<::const_iterator itr= m_UniqueItemInfo.begin();itr != m_UniqueItemInfo.end();++itr) - if(itr->effectMask & (1<getState() != SPELL_STATE_FINISHED) - m_Spell->cancel(); - - if (m_Spell->IsDeletable()) - { - delete m_Spell; - } - else - { - sLog.outError("~SpellEvent: %s %u tried to delete non-deletable spell %u. Was not deleted, causes memory leak.", - (m_Spell->GetCaster()->GetTypeId()==TYPEID_PLAYER?"Player":"Creature"), m_Spell->GetCaster()->GetGUIDLow(),m_Spell->m_spellInfo->Id); - } -} - -bool SpellEvent::Execute(uint64 e_time, uint32 p_time) -{ - // update spell if it is not finished - if (m_Spell->getState() != SPELL_STATE_FINISHED) - m_Spell->update(p_time); - - // check spell state to process - switch (m_Spell->getState()) - { - case SPELL_STATE_FINISHED: - { - // spell was finished, check deletable state - if (m_Spell->IsDeletable()) - { - // check, if we do have unfinished triggered spells - - return(true); // spell is deletable, finish event - } - // event will be re-added automatically at the end of routine) - } break; - - case SPELL_STATE_CASTING: - { - // this spell is in channeled state, process it on the next update - // event will be re-added automatically at the end of routine) - } break; - - case SPELL_STATE_DELAYED: - { - // first, check, if we have just started - if (m_Spell->GetDelayStart() != 0) - { - // no, we aren't, do the typical update - // check, if we have channeled spell on our hands - if (IsChanneledSpell(m_Spell->m_spellInfo)) - { - // evented channeled spell is processed separately, casted once after delay, and not destroyed till finish - // check, if we have casting anything else except this channeled spell and autorepeat - if (m_Spell->GetCaster()->IsNonMeleeSpellCasted(false, true, true)) - { - // another non-melee non-delayed spell is casted now, abort - m_Spell->cancel(); - } - else - { - // do the action (pass spell to channeling state) - m_Spell->handle_immediate(); - } - // event will be re-added automatically at the end of routine) - } - else - { - // run the spell handler and think about what we can do next - uint64 t_offset = e_time - m_Spell->GetDelayStart(); - uint64 n_offset = m_Spell->handle_delayed(t_offset); - if (n_offset) - { - // re-add us to the queue - m_Spell->GetCaster()->m_Events.AddEvent(this, m_Spell->GetDelayStart() + n_offset, false); - return(false); // event not complete - } - // event complete - // finish update event will be re-added automatically at the end of routine) - } - } - else - { - // delaying had just started, record the moment - m_Spell->SetDelayStart(e_time); - // re-plan the event for the delay moment - m_Spell->GetCaster()->m_Events.AddEvent(this, e_time + m_Spell->GetDelayMoment(), false); - return(false); // event not complete - } - } break; - - default: - { - // all other states - // event will be re-added automatically at the end of routine) - } break; - } - - // spell processing not complete, plan event on the next update interval - m_Spell->GetCaster()->m_Events.AddEvent(this, e_time + 1, false); - return(false); // event not complete -} - -void SpellEvent::Abort(uint64 /*e_time*/) -{ - // oops, the spell we try to do is aborted - if (m_Spell->getState() != SPELL_STATE_FINISHED) - m_Spell->cancel(); -} +/* + * Copyright (C) 2005-2008 MaNGOS + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "Common.h" +#include "Database/DatabaseEnv.h" +#include "WorldPacket.h" +#include "WorldSession.h" +#include "GridNotifiers.h" +#include "GridNotifiersImpl.h" +#include "Opcodes.h" +#include "Log.h" +#include "UpdateMask.h" +#include "World.h" +#include "ObjectMgr.h" +#include "SpellMgr.h" +#include "Player.h" +#include "Pet.h" +#include "Unit.h" +#include "Spell.h" +#include "DynamicObject.h" +#include "SpellAuras.h" +#include "Group.h" +#include "UpdateData.h" +#include "MapManager.h" +#include "ObjectAccessor.h" +#include "CellImpl.h" +#include "Policies/SingletonImp.h" +#include "SharedDefines.h" +#include "Tools.h" +#include "LootMgr.h" +#include "VMapFactory.h" +#include "BattleGround.h" +#include "Util.h" + +#define SPELL_CHANNEL_UPDATE_INTERVAL 1000 + +extern pEffect SpellEffects[TOTAL_SPELL_EFFECTS]; + +bool IsQuestTameSpell(uint32 spellId) +{ + SpellEntry const *spellproto = sSpellStore.LookupEntry(spellId); + if (!spellproto) return false; + + return spellproto->Effect[0] == SPELL_EFFECT_THREAT + && spellproto->Effect[1] == SPELL_EFFECT_APPLY_AURA && spellproto->EffectApplyAuraName[1] == SPELL_AURA_DUMMY; +} + +SpellCastTargets::SpellCastTargets() +{ + m_unitTarget = NULL; + m_itemTarget = NULL; + m_GOTarget = NULL; + + m_unitTargetGUID = 0; + m_GOTargetGUID = 0; + m_CorpseTargetGUID = 0; + m_itemTargetGUID = 0; + m_itemTargetEntry = 0; + + m_srcX = m_srcY = m_srcZ = m_destX = m_destY = m_destZ = 0; + m_strTarget = ""; + m_targetMask = 0; +} + +SpellCastTargets::~SpellCastTargets() +{ +} + +void SpellCastTargets::setUnitTarget(Unit *target) +{ + if (!target) + return; + + m_destX = target->GetPositionX(); + m_destY = target->GetPositionY(); + m_destZ = target->GetPositionZ(); + m_unitTarget = target; + m_unitTargetGUID = target->GetGUID(); + m_targetMask |= TARGET_FLAG_UNIT; +} + +void SpellCastTargets::setDestination(float x, float y, float z) +{ + m_destX = x; + m_destY = y; + m_destZ = z; + m_targetMask |= TARGET_FLAG_DEST_LOCATION; +} + +void SpellCastTargets::setGOTarget(GameObject *target) +{ + m_GOTarget = target; + m_GOTargetGUID = target->GetGUID(); + // m_targetMask |= TARGET_FLAG_OBJECT; +} + +void SpellCastTargets::setItemTarget(Item* item) +{ + if(!item) + return; + + m_itemTarget = item; + m_itemTargetGUID = item->GetGUID(); + m_itemTargetEntry = item->GetEntry(); + m_targetMask |= TARGET_FLAG_ITEM; +} + +void SpellCastTargets::setCorpseTarget(Corpse* corpse) +{ + m_CorpseTargetGUID = corpse->GetGUID(); +} + +void SpellCastTargets::Update(Unit* caster) +{ + m_GOTarget = m_GOTargetGUID ? ObjectAccessor::GetGameObject(*caster,m_GOTargetGUID) : NULL; + m_unitTarget = m_unitTargetGUID ? + ( m_unitTargetGUID==caster->GetGUID() ? caster : ObjectAccessor::GetUnit(*caster, m_unitTargetGUID) ) : + NULL; + + m_itemTarget = NULL; + if(caster->GetTypeId()==TYPEID_PLAYER) + { + if(m_targetMask & TARGET_FLAG_ITEM) + m_itemTarget = ((Player*)caster)->GetItemByGuid(m_itemTargetGUID); + else + { + Player* pTrader = ((Player*)caster)->GetTrader(); + if(pTrader && m_itemTargetGUID < TRADE_SLOT_COUNT) + m_itemTarget = pTrader->GetItemByPos(pTrader->GetItemPosByTradeSlot(m_itemTargetGUID)); + } + if(m_itemTarget) + m_itemTargetEntry = m_itemTarget->GetEntry(); + } +} + +bool SpellCastTargets::read ( WorldPacket * data, Unit *caster ) +{ + if(data->rpos()+4 > data->size()) + return false; + + *data >> m_targetMask; + + if(m_targetMask == TARGET_FLAG_SELF) + { + m_destX = caster->GetPositionX(); + m_destY = caster->GetPositionY(); + m_destZ = caster->GetPositionZ(); + m_unitTarget = caster; + m_unitTargetGUID = caster->GetGUID(); + return true; + } + // TARGET_FLAG_UNK2 is used for non-combat pets, maybe other? + if( m_targetMask & (TARGET_FLAG_UNIT|TARGET_FLAG_UNK2) ) + if(!readGUID(*data, m_unitTargetGUID)) + return false; + + if( m_targetMask & ( TARGET_FLAG_OBJECT | TARGET_FLAG_OBJECT_UNK )) + if(!readGUID(*data, m_GOTargetGUID)) + return false; + + if(( m_targetMask & ( TARGET_FLAG_ITEM | TARGET_FLAG_TRADE_ITEM )) && caster->GetTypeId() == TYPEID_PLAYER) + if(!readGUID(*data, m_itemTargetGUID)) + return false; + + if( m_targetMask & TARGET_FLAG_SOURCE_LOCATION ) + { + if(data->rpos()+4+4+4 > data->size()) + return false; + + *data >> m_srcX >> m_srcY >> m_srcZ; + if(!MaNGOS::IsValidMapCoord(m_srcX, m_srcY, m_srcZ)) + return false; + } + + if( m_targetMask & TARGET_FLAG_DEST_LOCATION ) + { + if(data->rpos()+4+4+4 > data->size()) + return false; + + *data >> m_destX >> m_destY >> m_destZ; + if(!MaNGOS::IsValidMapCoord(m_destX, m_destY, m_destZ)) + return false; + } + + if( m_targetMask & TARGET_FLAG_STRING ) + { + if(data->rpos()+1 > data->size()) + return false; + + *data >> m_strTarget; + } + + if( m_targetMask & (TARGET_FLAG_CORPSE | TARGET_FLAG_PVP_CORPSE ) ) + if(!readGUID(*data, m_CorpseTargetGUID)) + return false; + + // find real units/GOs + Update(caster); + return true; +} + +void SpellCastTargets::write ( WorldPacket * data ) +{ + *data << uint32(m_targetMask); + + if( m_targetMask & ( TARGET_FLAG_UNIT | TARGET_FLAG_PVP_CORPSE | TARGET_FLAG_OBJECT | TARGET_FLAG_CORPSE | TARGET_FLAG_UNK2 ) ) + { + if(m_targetMask & TARGET_FLAG_UNIT) + { + if(m_unitTarget) + data->append(m_unitTarget->GetPackGUID()); + else + *data << uint8(0); + } + else if( m_targetMask & ( TARGET_FLAG_OBJECT | TARGET_FLAG_OBJECT_UNK ) ) + { + if(m_GOTarget) + data->append(m_GOTarget->GetPackGUID()); + else + *data << uint8(0); + } + else if( m_targetMask & ( TARGET_FLAG_CORPSE | TARGET_FLAG_PVP_CORPSE ) ) + data->appendPackGUID(m_CorpseTargetGUID); + else + *data << uint8(0); + } + + if( m_targetMask & ( TARGET_FLAG_ITEM | TARGET_FLAG_TRADE_ITEM ) ) + { + if(m_itemTarget) + data->append(m_itemTarget->GetPackGUID()); + else + *data << uint8(0); + } + + if( m_targetMask & TARGET_FLAG_SOURCE_LOCATION ) + *data << m_srcX << m_srcY << m_srcZ; + + if( m_targetMask & TARGET_FLAG_DEST_LOCATION ) + *data << m_destX << m_destY << m_destZ; + + if( m_targetMask & TARGET_FLAG_STRING ) + *data << m_strTarget; +} + +Spell::Spell( Unit* Caster, SpellEntry const *info, bool triggered, uint64 originalCasterGUID, Spell** triggeringContainer ) +{ + ASSERT( Caster != NULL && info != NULL ); + ASSERT( info == sSpellStore.LookupEntry( info->Id ) && "`info` must be pointer to sSpellStore element"); + + m_spellInfo = info; + m_caster = Caster; + m_selfContainer = NULL; + m_triggeringContainer = triggeringContainer; + m_deletable = true; + m_delayAtDamageCount = 0; + + m_applyMultiplierMask = 0; + + // Get data for type of attack + switch (m_spellInfo->DmgClass) + { + case SPELL_DAMAGE_CLASS_MELEE: + if (m_spellInfo->AttributesEx3 & SPELL_ATTR_EX3_REQ_OFFHAND) + m_attackType = OFF_ATTACK; + else + m_attackType = BASE_ATTACK; + break; + case SPELL_DAMAGE_CLASS_RANGED: + m_attackType = RANGED_ATTACK; + break; + default: + // Wands + if (m_spellInfo->AttributesEx3 & SPELL_ATTR_EX3_REQ_WAND) + m_attackType = RANGED_ATTACK; + else + m_attackType = BASE_ATTACK; + break; + } + + m_spellSchoolMask = GetSpellSchoolMask(info); // Can be override for some spell (wand shoot for example) + + if(m_attackType == RANGED_ATTACK) + { + // wand case + if((m_caster->getClassMask() & CLASSMASK_WAND_USERS) != 0 && m_caster->GetTypeId()==TYPEID_PLAYER) + { + if(Item* pItem = ((Player*)m_caster)->GetWeaponForAttack(RANGED_ATTACK)) + m_spellSchoolMask = SpellSchoolMask(1 << pItem->GetProto()->Damage->DamageType); + } + } + + if(originalCasterGUID) + m_originalCasterGUID = originalCasterGUID; + else + m_originalCasterGUID = m_caster->GetGUID(); + + if(m_originalCasterGUID==m_caster->GetGUID()) + m_originalCaster = m_caster; + else + { + m_originalCaster = ObjectAccessor::GetUnit(*m_caster,m_originalCasterGUID); + if(m_originalCaster && !m_originalCaster->IsInWorld()) m_originalCaster = NULL; + } + + for(int i=0; i <3; ++i) + m_currentBasePoints[i] = m_spellInfo->EffectBasePoints[i]; + + m_spellState = SPELL_STATE_NULL; + + m_castPositionX = m_castPositionY = m_castPositionZ = 0; + m_TriggerSpells.clear(); + m_IsTriggeredSpell = triggered; + //m_AreaAura = false; + m_CastItem = NULL; + + unitTarget = NULL; + itemTarget = NULL; + gameObjTarget = NULL; + focusObject = NULL; + m_cast_count = 0; + m_triggeredByAuraSpell = NULL; + + //Auto Shot & Shoot + if( m_spellInfo->AttributesEx2 == 0x000020 && !triggered ) + m_autoRepeat = true; + else + m_autoRepeat = false; + + m_powerCost = 0; // setup to correct value in Spell::prepare, don't must be used before. + m_casttime = 0; // setup to correct value in Spell::prepare, don't must be used before. + m_timer = 0; // will set to castime in preper + + m_needAliveTargetMask = 0; + + // determine reflection + m_canReflect = false; + + if(m_spellInfo->DmgClass == SPELL_DAMAGE_CLASS_MAGIC && (m_spellInfo->AttributesEx2 & 0x4)==0) + { + for(int j=0;j<3;j++) + { + if (m_spellInfo->Effect[j]==0) + continue; + + if(!IsPositiveTarget(m_spellInfo->EffectImplicitTargetA[j],m_spellInfo->EffectImplicitTargetB[j])) + m_canReflect = true; + else + m_canReflect = (m_spellInfo->AttributesEx & (1<<7)) ? true : false; + + if(m_canReflect) + continue; + else + break; + } + } + + CleanupTargetList(); +} + +Spell::~Spell() +{ +} + +void Spell::FillTargetMap() +{ + // TODO: ADD the correct target FILLS!!!!!! + + for(uint32 i=0;i<3;i++) + { + // not call for empty effect. + // Also some spells use not used effect targets for store targets for dummy effect in triggered spells + if(m_spellInfo->Effect[i]==0) + continue; + + // targets for TARGET_SCRIPT_COORDINATES (A) and TARGET_SCRIPT filled in Spell::canCast call + if( m_spellInfo->EffectImplicitTargetA[i] == TARGET_SCRIPT_COORDINATES || + m_spellInfo->EffectImplicitTargetA[i] == TARGET_SCRIPT || + m_spellInfo->EffectImplicitTargetB[i] == TARGET_SCRIPT && m_spellInfo->EffectImplicitTargetA[i] != TARGET_SELF ) + continue; + + // TODO: find a way so this is not needed? + // for area auras always add caster as target (needed for totems for example) + if(IsAreaAuraEffect(m_spellInfo->Effect[i])) + AddUnitTarget(m_caster, i); + + std::list tmpUnitMap; + + // TargetA/TargetB dependent from each other, we not switch to full support this dependences + // but need it support in some know cases + switch(m_spellInfo->EffectImplicitTargetA[i]) + { + case TARGET_ALL_AROUND_CASTER: + if( m_spellInfo->EffectImplicitTargetB[i]==TARGET_ALL_PARTY || + m_spellInfo->EffectImplicitTargetB[i]==TARGET_ALL_FRIENDLY_UNITS_AROUND_CASTER || + m_spellInfo->EffectImplicitTargetB[i]==TARGET_RANDOM_RAID_MEMBER ) + { + SetTargetMap(i,m_spellInfo->EffectImplicitTargetB[i],tmpUnitMap); + } + // Note: this hack with search required until GO casting not implemented + // environment damage spells already have around enemies targeting but this not help in case not existed GO casting support + // currently each enemy selected explicitly and self cast damage + else if(m_spellInfo->EffectImplicitTargetB[i]==TARGET_ALL_ENEMY_IN_AREA && m_spellInfo->Effect[i]==SPELL_EFFECT_ENVIRONMENTAL_DAMAGE) + { + if(m_targets.getUnitTarget()) + tmpUnitMap.push_back(m_targets.getUnitTarget()); + } + else + { + SetTargetMap(i,m_spellInfo->EffectImplicitTargetA[i],tmpUnitMap); + SetTargetMap(i,m_spellInfo->EffectImplicitTargetB[i],tmpUnitMap); + } + break; + case TARGET_TABLE_X_Y_Z_COORDINATES: + // Only if target A, for target B (used in teleports) dest select in effect + SetTargetMap(i,m_spellInfo->EffectImplicitTargetA[i],tmpUnitMap); + break; + default: + switch(m_spellInfo->EffectImplicitTargetB[i]) + { + case TARGET_SCRIPT_COORDINATES: // B case filled in canCast but we need fill unit list base at A case + SetTargetMap(i,m_spellInfo->EffectImplicitTargetA[i],tmpUnitMap); + break; + default: + SetTargetMap(i,m_spellInfo->EffectImplicitTargetA[i],tmpUnitMap); + SetTargetMap(i,m_spellInfo->EffectImplicitTargetB[i],tmpUnitMap); + break; + } + break; + } + + if( (m_spellInfo->EffectImplicitTargetA[i]==0 || m_spellInfo->EffectImplicitTargetA[i]==TARGET_EFFECT_SELECT) && + (m_spellInfo->EffectImplicitTargetB[i]==0 || m_spellInfo->EffectImplicitTargetB[i]==TARGET_EFFECT_SELECT) ) + { + // add here custom effects that need default target. + // FOR EVERY TARGET TYPE THERE IS A DIFFERENT FILL!! + switch(m_spellInfo->Effect[i]) + { + case SPELL_EFFECT_DUMMY: + { + switch(m_spellInfo->Id) + { + case 20577: // Cannibalize + { + // non-standard target selection + SpellRangeEntry const* srange = sSpellRangeStore.LookupEntry(m_spellInfo->rangeIndex); + float max_range = GetSpellMaxRange(srange); + + CellPair p(MaNGOS::ComputeCellPair(m_caster->GetPositionX(), m_caster->GetPositionY())); + Cell cell(p); + cell.data.Part.reserved = ALL_DISTRICT; + cell.SetNoCreate(); + + WorldObject* result = NULL; + + MaNGOS::CannibalizeObjectCheck u_check(m_caster, max_range); + MaNGOS::WorldObjectSearcher searcher(result, u_check); + + TypeContainerVisitor, GridTypeMapContainer > grid_searcher(searcher); + CellLock cell_lock(cell, p); + cell_lock->Visit(cell_lock, grid_searcher, *MapManager::Instance().GetMap(m_caster->GetMapId(), m_caster)); + + if(!result) + { + TypeContainerVisitor, WorldTypeMapContainer > world_searcher(searcher); + cell_lock->Visit(cell_lock, world_searcher, *MapManager::Instance().GetMap(m_caster->GetMapId(), m_caster)); + } + + if(result) + { + switch(result->GetTypeId()) + { + case TYPEID_UNIT: + case TYPEID_PLAYER: + tmpUnitMap.push_back((Unit*)result); + break; + case TYPEID_CORPSE: + m_targets.setCorpseTarget((Corpse*)result); + if(Player* owner = ObjectAccessor::FindPlayer(((Corpse*)result)->GetOwnerGUID())) + tmpUnitMap.push_back(owner); + break; + } + } + else + { + // clear cooldown at fail + if(m_caster->GetTypeId()==TYPEID_PLAYER) + { + ((Player*)m_caster)->RemoveSpellCooldown(m_spellInfo->Id); + + WorldPacket data(SMSG_CLEAR_COOLDOWN, (4+8)); + data << uint32(m_spellInfo->Id); + data << uint64(m_caster->GetGUID()); + ((Player*)m_caster)->GetSession()->SendPacket(&data); + } + + SendCastResult(SPELL_FAILED_NO_EDIBLE_CORPSES); + finish(false); + } + break; + } + default: + if(m_targets.getUnitTarget()) + tmpUnitMap.push_back(m_targets.getUnitTarget()); + break; + } + break; + } + case SPELL_EFFECT_RESURRECT: + case SPELL_EFFECT_PARRY: + case SPELL_EFFECT_BLOCK: + case SPELL_EFFECT_CREATE_ITEM: + case SPELL_EFFECT_TRIGGER_SPELL: + case SPELL_EFFECT_TRIGGER_MISSILE: + case SPELL_EFFECT_LEARN_SPELL: + case SPELL_EFFECT_SKILL_STEP: + case SPELL_EFFECT_PROFICIENCY: + case SPELL_EFFECT_SUMMON_POSSESSED: + case SPELL_EFFECT_SUMMON_OBJECT_WILD: + case SPELL_EFFECT_SELF_RESURRECT: + case SPELL_EFFECT_REPUTATION: + if(m_targets.getUnitTarget()) + tmpUnitMap.push_back(m_targets.getUnitTarget()); + break; + case SPELL_EFFECT_SUMMON_PLAYER: + if(m_caster->GetTypeId()==TYPEID_PLAYER && ((Player*)m_caster)->GetSelection()) + { + Player* target = objmgr.GetPlayer(((Player*)m_caster)->GetSelection()); + if(target) + tmpUnitMap.push_back(target); + } + break; + case SPELL_EFFECT_RESURRECT_NEW: + if(m_targets.getUnitTarget()) + tmpUnitMap.push_back(m_targets.getUnitTarget()); + if(m_targets.getCorpseTargetGUID()) + { + Corpse *corpse = ObjectAccessor::GetCorpse(*m_caster,m_targets.getCorpseTargetGUID()); + if(corpse) + { + Player* owner = ObjectAccessor::FindPlayer(corpse->GetOwnerGUID()); + if(owner) + tmpUnitMap.push_back(owner); + } + } + break; + case SPELL_EFFECT_SUMMON: + if(m_spellInfo->EffectMiscValueB[i] == SUMMON_TYPE_POSESSED || m_spellInfo->EffectMiscValueB[i] == SUMMON_TYPE_POSESSED2) + { + if(m_targets.getUnitTarget()) + tmpUnitMap.push_back(m_targets.getUnitTarget()); + } + else + tmpUnitMap.push_back(m_caster); + break; + case SPELL_EFFECT_SUMMON_CHANGE_ITEM: + case SPELL_EFFECT_SUMMON_WILD: + case SPELL_EFFECT_SUMMON_GUARDIAN: + case SPELL_EFFECT_TRANS_DOOR: + case SPELL_EFFECT_ADD_FARSIGHT: + case SPELL_EFFECT_STUCK: + case SPELL_EFFECT_DESTROY_ALL_TOTEMS: + case SPELL_EFFECT_SUMMON_DEMON: + case SPELL_EFFECT_SKILL: + tmpUnitMap.push_back(m_caster); + break; + case SPELL_EFFECT_LEARN_PET_SPELL: + if(Pet* pet = m_caster->GetPet()) + tmpUnitMap.push_back(pet); + break; + case SPELL_EFFECT_ENCHANT_ITEM: + case SPELL_EFFECT_ENCHANT_ITEM_TEMPORARY: + case SPELL_EFFECT_DISENCHANT: + case SPELL_EFFECT_FEED_PET: + case SPELL_EFFECT_PROSPECTING: + if(m_targets.getItemTarget()) + AddItemTarget(m_targets.getItemTarget(), i); + break; + case SPELL_EFFECT_APPLY_AURA: + switch(m_spellInfo->EffectApplyAuraName[i]) + { + case SPELL_AURA_ADD_FLAT_MODIFIER: // some spell mods auras have 0 target modes instead expected TARGET_SELF(1) (and present for other ranks for same spell for example) + case SPELL_AURA_ADD_PCT_MODIFIER: + tmpUnitMap.push_back(m_caster); + break; + default: // apply to target in other case + if(m_targets.getUnitTarget()) + tmpUnitMap.push_back(m_targets.getUnitTarget()); + break; + } + break; + case SPELL_EFFECT_APPLY_AREA_AURA_PARTY: + // AreaAura + if(m_spellInfo->Attributes == 0x9050000 || m_spellInfo->Attributes == 0x10000) + SetTargetMap(i,TARGET_AREAEFFECT_PARTY,tmpUnitMap); + break; + case SPELL_EFFECT_SKIN_PLAYER_CORPSE: + if(m_targets.getUnitTarget()) + { + tmpUnitMap.push_back(m_targets.getUnitTarget()); + } + else if (m_targets.getCorpseTargetGUID()) + { + Corpse *corpse = ObjectAccessor::GetCorpse(*m_caster,m_targets.getCorpseTargetGUID()); + if(corpse) + { + Player* owner = ObjectAccessor::FindPlayer(corpse->GetOwnerGUID()); + if(owner) + tmpUnitMap.push_back(owner); + } + } + break; + default: + break; + } + } + if(IsChanneledSpell(m_spellInfo) && !tmpUnitMap.empty()) + m_needAliveTargetMask |= (1<GetTypeId() == TYPEID_PLAYER) + { + Player *me = (Player*)m_caster; + for (std::list::const_iterator itr = tmpUnitMap.begin(); itr != tmpUnitMap.end(); itr++) + { + Unit *owner = (*itr)->GetOwner(); + Unit *u = owner ? owner : (*itr); + if(u!=m_caster && u->IsPvP() && (!me->duel || me->duel->opponent != u)) + { + me->UpdatePvP(true); + me->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_ENTER_PVP_COMBAT); + break; + } + } + } + + for (std::list::iterator itr = tmpUnitMap.begin() ; itr != tmpUnitMap.end();) + { + if(!CheckTarget(*itr, i, false )) + { + itr = tmpUnitMap.erase(itr); + continue; + } + else + ++itr; + } + + for(std::list::iterator iunit= tmpUnitMap.begin();iunit != tmpUnitMap.end();++iunit) + AddUnitTarget((*iunit), i); + } +} + +void Spell::CleanupTargetList() +{ + m_UniqueTargetInfo.clear(); + m_UniqueGOTargetInfo.clear(); + m_UniqueItemInfo.clear(); + m_countOfHit = 0; + m_countOfMiss = 0; + m_delayMoment = 0; +} + +void Spell::AddUnitTarget(Unit* pVictim, uint32 effIndex) +{ + if( m_spellInfo->Effect[effIndex]==0 ) + return; + + uint64 targetGUID = pVictim->GetGUID(); + + // Lookup target in already in list + for(std::list::iterator ihit= m_UniqueTargetInfo.begin();ihit != m_UniqueTargetInfo.end();++ihit) + { + if (targetGUID == ihit->targetGUID) // Found in list + { + ihit->effectMask |= 1<SpellHitResult(pVictim, m_spellInfo, m_canReflect); + if (target.missCondition == SPELL_MISS_NONE) + ++m_countOfHit; + else + ++m_countOfMiss; + + // Spell have speed - need calculate incoming time + if (m_spellInfo->speed > 0.0f) + { + // calculate spell incoming interval + float dist = m_caster->GetDistance(pVictim->GetPositionX(), pVictim->GetPositionY(), pVictim->GetPositionZ()); + if (dist < 5.0f) dist = 5.0f; + target.timeDelay = (uint64) floor(dist / m_spellInfo->speed * 1000.0f); + + // Calculate minimum incoming time + if (m_delayMoment==0 || m_delayMoment>target.timeDelay) + m_delayMoment = target.timeDelay; + } + else + target.timeDelay = 0LL; + + // If target reflect spell back to caster + if (target.missCondition==SPELL_MISS_REFLECT) + { + // Calculate reflected spell result on caster + target.reflectResult = m_caster->SpellHitResult(m_caster, m_spellInfo, m_canReflect); + + if (target.reflectResult == SPELL_MISS_REFLECT) // Impossible reflect again, so simply deflect spell + target.reflectResult = SPELL_MISS_PARRY; + + // Increase time interval for reflected spells by 1.5 + target.timeDelay+=target.timeDelay>>1; + } + else + target.reflectResult = SPELL_MISS_NONE; + + // Add target to list + m_UniqueTargetInfo.push_back(target); +} + +void Spell::AddUnitTarget(uint64 unitGUID, uint32 effIndex) +{ + Unit* unit = m_caster->GetGUID()==unitGUID ? m_caster : ObjectAccessor::GetUnit(*m_caster, unitGUID); + if (unit) + AddUnitTarget(unit, effIndex); +} + +void Spell::AddGOTarget(GameObject* pVictim, uint32 effIndex) +{ + if( m_spellInfo->Effect[effIndex]==0 ) + return; + + uint64 targetGUID = pVictim->GetGUID(); + + // Lookup target in already in list + for(std::list::iterator ihit= m_UniqueGOTargetInfo.begin();ihit != m_UniqueGOTargetInfo.end();++ihit) + { + if (targetGUID == ihit->targetGUID) // Found in list + { + ihit->effectMask |= 1<speed > 0.0f) + { + // calculate spell incoming interval + float dist = m_caster->GetDistance(pVictim->GetPositionX(), pVictim->GetPositionY(), pVictim->GetPositionZ()); + if (dist < 5.0f) dist = 5.0f; + target.timeDelay = (uint64) floor(dist / m_spellInfo->speed * 1000.0f); + if (m_delayMoment==0 || m_delayMoment>target.timeDelay) + m_delayMoment = target.timeDelay; + } + else + target.timeDelay = 0LL; + + ++m_countOfHit; + + // Add target to list + m_UniqueGOTargetInfo.push_back(target); +} + +void Spell::AddGOTarget(uint64 goGUID, uint32 effIndex) +{ + GameObject* go = ObjectAccessor::GetGameObject(*m_caster, goGUID); + if (go) + AddGOTarget(go, effIndex); +} + +void Spell::AddItemTarget(Item* pitem, uint32 effIndex) +{ + if( m_spellInfo->Effect[effIndex]==0 ) + return; + + // Lookup target in already in list + for(std::list::iterator ihit= m_UniqueItemInfo.begin();ihit != m_UniqueItemInfo.end();++ihit) + { + if (pitem == ihit->item) // Found in list + { + ihit->effectMask |= 1<GetTypeId()== TYPEID_PLAYER) + ((Player*)m_caster)->UpdateWeaponSkill(BASE_ATTACK); + + m_caster->CastMeleeProcDamageAndSpell(unitTarget, 0, damageSchoolMask, m_attackType, MELEE_HIT_MISS, m_spellInfo, m_IsTriggeredSpell); + break; + case SPELL_MISS_RESIST: + m_caster->ProcDamageAndSpell(unitTarget, PROC_FLAG_TARGET_RESISTS, PROC_FLAG_RESIST_SPELL, 0, damageSchoolMask, m_spellInfo, m_IsTriggeredSpell); + break; + case SPELL_MISS_DODGE: + if(unitTarget->GetTypeId() == TYPEID_PLAYER) + ((Player*)unitTarget)->UpdateDefense(); + + // Overpower + if (m_caster->GetTypeId() == TYPEID_PLAYER && m_caster->getClass() == CLASS_WARRIOR) + { + ((Player*) m_caster)->AddComboPoints(unitTarget, 1); + m_caster->StartReactiveTimer( REACTIVE_OVERPOWER ); + } + + // Riposte + if (unitTarget->getClass() != CLASS_ROGUE) + { + unitTarget->ModifyAuraState(AURA_STATE_DEFENSE, true); + unitTarget->StartReactiveTimer( REACTIVE_DEFENSE ); + } + + m_caster->CastMeleeProcDamageAndSpell(unitTarget, 0, damageSchoolMask, m_attackType, MELEE_HIT_DODGE, m_spellInfo, m_IsTriggeredSpell); + break; + case SPELL_MISS_PARRY: + // Update victim defense ? + if(unitTarget->GetTypeId() == TYPEID_PLAYER) + ((Player*)unitTarget)->UpdateDefense(); + // Mongoose bite - set only Counterattack here + if (unitTarget->getClass() == CLASS_HUNTER) + { + unitTarget->ModifyAuraState(AURA_STATE_HUNTER_PARRY,true); + unitTarget->StartReactiveTimer( REACTIVE_HUNTER_PARRY ); + } + else + { + unitTarget->ModifyAuraState(AURA_STATE_DEFENSE, true); + unitTarget->StartReactiveTimer( REACTIVE_DEFENSE ); + } + m_caster->CastMeleeProcDamageAndSpell(unitTarget, 0, damageSchoolMask, m_attackType, MELEE_HIT_PARRY, m_spellInfo, m_IsTriggeredSpell); + break; + case SPELL_MISS_BLOCK: + unitTarget->ModifyAuraState(AURA_STATE_DEFENSE, true); + unitTarget->StartReactiveTimer( REACTIVE_DEFENSE ); + + m_caster->CastMeleeProcDamageAndSpell(unitTarget, 0, damageSchoolMask, m_attackType, MELEE_HIT_BLOCK, m_spellInfo, m_IsTriggeredSpell); + break; + // Trigger from this events not supported + case SPELL_MISS_EVADE: + case SPELL_MISS_IMMUNE: + case SPELL_MISS_IMMUNE2: + case SPELL_MISS_DEFLECT: + case SPELL_MISS_ABSORB: + // Trigger from reflects need do after get reflect result + case SPELL_MISS_REFLECT: + break; + default: + break; + } + } +} + +void Spell::DoAllEffectOnTarget(TargetInfo *target) +{ + if (target->processed) // Check target + return; + target->processed = true; // Target checked in apply effects procedure + + // Get mask of effects for target + uint32 mask = target->effectMask; + if (mask == 0) // No effects + return; + + Unit* unit = m_caster->GetGUID()==target->targetGUID ? m_caster : ObjectAccessor::GetUnit(*m_caster,target->targetGUID); + if (!unit) + return; + + SpellMissInfo missInfo = target->missCondition; + // Need init unitTarget by default unit (can changed in code on reflect) + // Or on missInfo!=SPELL_MISS_NONE unitTarget undefined (but need in trigger subsystem) + unitTarget = unit; + + if (missInfo==SPELL_MISS_NONE) // In case spell hit target, do all effect on that target + DoSpellHitOnUnit(unit, mask); + else if (missInfo == SPELL_MISS_REFLECT) // In case spell reflect from target, do all effect on caster (if hit) + { + if (target->reflectResult == SPELL_MISS_NONE) // If reflected spell hit caster -> do all effect on him + DoSpellHitOnUnit(m_caster, mask); + } + + // Do triggers only on miss/resist/parry/dodge + if (missInfo!=SPELL_MISS_NONE) + doTriggers(missInfo); + + // Call scripted function for AI if this spell is casted upon a creature (except pets) + if(IS_CREATURE_GUID(target->targetGUID)) + { + // cast at creature (or GO) quest objectives update at successful cast finished (+channel finished) + // ignore autorepeat/melee casts for speed (not exist quest for spells (hm... ) + if( m_caster->GetTypeId() == TYPEID_PLAYER && !IsAutoRepeat() && !IsNextMeleeSwingSpell() && !IsChannelActive() ) + ((Player*)m_caster)->CastedCreatureOrGO(unit->GetEntry(),unit->GetGUID(),m_spellInfo->Id); + + if(((Creature*)unit)->AI()) + ((Creature*)unit)->AI()->SpellHit(m_caster ,m_spellInfo); + } +} + +void Spell::DoSpellHitOnUnit(Unit *unit, const uint32 effectMask) +{ + if(!unit || !effectMask) + return; + + // Recheck immune (only for delayed spells) + if( m_spellInfo->speed && ( + unit->IsImmunedToDamage(GetSpellSchoolMask(m_spellInfo),true) || + unit->IsImmunedToSpell(m_spellInfo,true) )) + { + m_caster->SendSpellMiss(unit, m_spellInfo->Id, SPELL_MISS_IMMUNE); + return; + } + + if( m_caster != unit ) + { + if( !m_caster->IsFriendlyTo(unit) ) + { + // for delayed spells ignore not visible explicit target + if(m_spellInfo->speed > 0.0f && unit==m_targets.getUnitTarget() && !unit->isVisibleForOrDetect(m_caster,false)) + { + m_caster->SendSpellMiss(unit, m_spellInfo->Id, SPELL_MISS_EVADE); + return; + } + + // exclude Arcane Missiles Dummy Aura aura for now (attack on hit) + // TODO: find way to not need this? + if(!(m_spellInfo->SpellFamilyName == SPELLFAMILY_MAGE && + m_spellInfo->SpellFamilyFlags & 0x800LL)) + { + unit->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); + + if( !(m_spellInfo->AttributesEx3 & SPELL_ATTR_EX3_NO_INITIAL_AGGRO) ) + { + if(!unit->IsStandState() && !unit->hasUnitState(UNIT_STAT_STUNDED)) + unit->SetStandState(PLAYER_STATE_NONE); + + if(!unit->isInCombat() && unit->GetTypeId() != TYPEID_PLAYER && ((Creature*)unit)->AI()) + ((Creature*)unit)->AI()->AttackStart(m_caster); + + unit->SetInCombatWith(m_caster); + m_caster->SetInCombatWith(unit); + + if(Player *attackedPlayer = unit->GetCharmerOrOwnerPlayerOrPlayerItself()) + { + m_caster->SetContestedPvP(attackedPlayer); + } + unit->AddThreat(m_caster, 0.0f); + } + } + } + else + { + // for delayed spells ignore negative spells (after duel end) for friendly targets + if(m_spellInfo->speed > 0.0f && !IsPositiveSpell(m_spellInfo->Id)) + { + m_caster->SendSpellMiss(unit, m_spellInfo->Id, SPELL_MISS_EVADE); + return; + } + + // assisting case, healing and resurrection + if(unit->hasUnitState(UNIT_STAT_ATTACK_PLAYER)) + m_caster->SetContestedPvP(); + if( unit->isInCombat() && !(m_spellInfo->AttributesEx3 & SPELL_ATTR_EX3_NO_INITIAL_AGGRO) ) + { + m_caster->SetInCombatState(unit->GetCombatTimer() > 0); + unit->getHostilRefManager().threatAssist(m_caster, 0.0f); + } + } + } + + // Get Data Needed for Diminishing Returns, some effects may have multiple auras, so this must be done on spell hit, not aura add + m_diminishGroup = GetDiminishingReturnsGroupForSpell(m_spellInfo,m_triggeredByAuraSpell); + m_diminishLevel = unit->GetDiminishing(m_diminishGroup); + // Increase Diminishing on unit, current informations for actually casts will use values above + if((GetDiminishingReturnsGroupType(m_diminishGroup) == DRTYPE_PLAYER && unit->GetTypeId() == TYPEID_PLAYER) || GetDiminishingReturnsGroupType(m_diminishGroup) == DRTYPE_ALL) + unit->IncrDiminishing(m_diminishGroup); + + for(uint32 effectNumber=0;effectNumber<3;effectNumber++) + { + if (effectMask & (1<DmgMultiplier[effectNumber]; + // Apply multiplier mods + if(Player* modOwner = m_originalCaster->GetSpellModOwner()) + modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_EFFECT_PAST_FIRST, multiplier,this); + m_damageMultipliers[effectNumber] *= multiplier; + } + } + } +} + +void Spell::DoAllEffectOnTarget(GOTargetInfo *target) +{ + if (target->processed) // Check target + return; + target->processed = true; // Target checked in apply effects procedure + + uint32 effectMask = target->effectMask; + if(!effectMask) + return; + + GameObject* go = ObjectAccessor::GetGameObject(*m_caster, target->targetGUID); + if(!go) + return; + + for(uint32 effectNumber=0;effectNumber<3;effectNumber++) + if (effectMask & (1<GetTypeId() == TYPEID_PLAYER && !IsAutoRepeat() && !IsNextMeleeSwingSpell() && !IsChannelActive() ) + ((Player*)m_caster)->CastedCreatureOrGO(go->GetEntry(),go->GetGUID(),m_spellInfo->Id); +} + +void Spell::DoAllEffectOnTarget(ItemTargetInfo *target) +{ + uint32 effectMask = target->effectMask; + if(!target->item || !effectMask) + return; + + for(uint32 effectNumber=0;effectNumber<3;effectNumber++) + if (effectMask & (1<item, NULL, effectNumber); +} + +bool Spell::IsAliveUnitPresentInTargetList() +{ + // Not need check return true + if (m_needAliveTargetMask == 0) + return true; + + uint8 needAliveTargetMask = m_needAliveTargetMask; + + for(std::list::iterator ihit= m_UniqueTargetInfo.begin();ihit != m_UniqueTargetInfo.end();++ihit) + { + if( ihit->missCondition == SPELL_MISS_NONE && (needAliveTargetMask & ihit->effectMask) ) + { + Unit *unit = m_caster->GetGUID()==ihit->targetGUID ? m_caster : ObjectAccessor::GetUnit(*m_caster, ihit->targetGUID); + + if (unit && unit->isAlive()) + needAliveTargetMask &= ~ihit->effectMask; // remove from need alive mask effect that have alive target + } + } + + // is all effects from m_needAliveTargetMask have alive targets + return needAliveTargetMask==0; +} + +// Helper for Chain Healing +// Spell target first +// Raidmates then descending by injury suffered (MaxHealth - Health) +// Other players/mobs then descending by injury suffered (MaxHealth - Health) +struct ChainHealingOrder : public std::binary_function +{ + const Unit* MainTarget; + ChainHealingOrder(Unit const* Target) : MainTarget(Target) {}; + // functor for operator ">" + bool operator()(Unit const* _Left, Unit const* _Right) const + { + return (ChainHealingHash(_Left) < ChainHealingHash(_Right)); + } + int32 ChainHealingHash(Unit const* Target) const + { + if (Target == MainTarget) + return 0; + else if (Target->GetTypeId() == TYPEID_PLAYER && MainTarget->GetTypeId() == TYPEID_PLAYER && + ((Player const*)Target)->IsInSameRaidWith((Player const*)MainTarget)) + { + if (Target->GetHealth() == Target->GetMaxHealth()) + return 40000; + else + return 20000 - Target->GetMaxHealth() + Target->GetHealth(); + } + else + return 40000 - Target->GetMaxHealth() + Target->GetHealth(); + } +}; + +class ChainHealingFullHealth: std::unary_function +{ + public: + const Unit* MainTarget; + ChainHealingFullHealth(const Unit* Target) : MainTarget(Target) {}; + + bool operator()(const Unit* Target) + { + return (Target != MainTarget && Target->GetHealth() == Target->GetMaxHealth()); + } +}; + +// Helper for targets nearest to the spell target +// The spell target is always first unless there is a target at _completely_ the same position (unbelievable case) +struct TargetDistanceOrder : public std::binary_function +{ + const Unit* MainTarget; + TargetDistanceOrder(const Unit* Target) : MainTarget(Target) {}; + // functor for operator ">" + bool operator()(const Unit* _Left, const Unit* _Right) const + { + return (MainTarget->GetDistance(_Left) < MainTarget->GetDistance(_Right)); + } +}; + +void Spell::SetTargetMap(uint32 i,uint32 cur,std::list &TagUnitMap) +{ + float radius; + if (m_spellInfo->EffectRadiusIndex[i]) + radius = GetSpellRadius(sSpellRadiusStore.LookupEntry(m_spellInfo->EffectRadiusIndex[i])); + else + radius = GetSpellMaxRange(sSpellRangeStore.LookupEntry(m_spellInfo->rangeIndex)); + + if(m_originalCaster) + if(Player* modOwner = m_originalCaster->GetSpellModOwner()) + modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_RADIUS, radius,this); + + uint32 EffectChainTarget = m_spellInfo->EffectChainTarget[i]; + if(m_originalCaster) + if(Player* modOwner = m_originalCaster->GetSpellModOwner()) + modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_JUMP_TARGETS, EffectChainTarget, this); + + uint32 unMaxTargets = m_spellInfo->MaxAffectedTargets; + switch(cur) + { + case TARGET_TOTEM_EARTH: + case TARGET_TOTEM_WATER: + case TARGET_TOTEM_AIR: + case TARGET_TOTEM_FIRE: + case TARGET_SELF: + case TARGET_SELF2: + case TARGET_DYNAMIC_OBJECT: + case TARGET_AREAEFFECT_CUSTOM: + case TARGET_AREAEFFECT_CUSTOM_2: + case TARGET_SUMMON: + { + TagUnitMap.push_back(m_caster); + break; + } + case TARGET_RANDOM_ENEMY_CHAIN_IN_AREA: + { + m_targets.m_targetMask = 0; + unMaxTargets = EffectChainTarget; + float max_range = radius + unMaxTargets * CHAIN_SPELL_JUMP_RADIUS; + + CellPair p(MaNGOS::ComputeCellPair(m_caster->GetPositionX(), m_caster->GetPositionY())); + Cell cell(p); + cell.data.Part.reserved = ALL_DISTRICT; + cell.SetNoCreate(); + + std::list tempUnitMap; + + { + MaNGOS::AnyAoETargetUnitInObjectRangeCheck u_check(m_caster, m_caster, max_range); + MaNGOS::UnitListSearcher searcher(tempUnitMap, u_check); + + TypeContainerVisitor, WorldTypeMapContainer > world_unit_searcher(searcher); + TypeContainerVisitor, GridTypeMapContainer > grid_unit_searcher(searcher); + + CellLock cell_lock(cell, p); + cell_lock->Visit(cell_lock, world_unit_searcher, *MapManager::Instance().GetMap(m_caster->GetMapId(), m_caster)); + cell_lock->Visit(cell_lock, grid_unit_searcher, *MapManager::Instance().GetMap(m_caster->GetMapId(), m_caster)); + } + + if(tempUnitMap.empty()) + break; + + tempUnitMap.sort(TargetDistanceOrder(m_caster)); + + //Now to get us a random target that's in the initial range of the spell + uint32 t = 0; + std::list::iterator itr = tempUnitMap.begin(); + while(itr!= tempUnitMap.end() && (*itr)->GetDistance(m_caster) < radius) + ++t, ++itr; + + if(!t) + break; + + itr = tempUnitMap.begin(); + std::advance(itr, rand()%t); + Unit *pUnitTarget = *itr; + TagUnitMap.push_back(pUnitTarget); + + tempUnitMap.erase(itr); + + tempUnitMap.sort(TargetDistanceOrder(pUnitTarget)); + + t = unMaxTargets - 1; + Unit *prev = pUnitTarget; + std::list::iterator next = tempUnitMap.begin(); + + while(t && next != tempUnitMap.end() ) + { + if(prev->GetDistance(*next) > CHAIN_SPELL_JUMP_RADIUS) + break; + + if(!prev->IsWithinLOSInMap(*next)) + { + ++next; + continue; + } + + prev = *next; + TagUnitMap.push_back(prev); + tempUnitMap.erase(next); + tempUnitMap.sort(TargetDistanceOrder(prev)); + next = tempUnitMap.begin(); + + --t; + } + }break; + case TARGET_PET: + { + Pet* tmpUnit = m_caster->GetPet(); + if (!tmpUnit) break; + TagUnitMap.push_back(tmpUnit); + break; + } + case TARGET_CHAIN_DAMAGE: + { + if (EffectChainTarget <= 1) + { + Unit* pUnitTarget = SelectMagnetTarget(); + if(pUnitTarget) + TagUnitMap.push_back(pUnitTarget); + } + else + { + Unit* pUnitTarget = m_targets.getUnitTarget(); + if(!pUnitTarget) + break; + + unMaxTargets = EffectChainTarget; + + float max_range; + if(m_spellInfo->DmgClass==SPELL_DAMAGE_CLASS_MELEE) + max_range = radius; // + else + //FIXME: This very like horrible hack and wrong for most spells + max_range = radius + unMaxTargets * CHAIN_SPELL_JUMP_RADIUS; + + CellPair p(MaNGOS::ComputeCellPair(m_caster->GetPositionX(), m_caster->GetPositionY())); + Cell cell(p); + cell.data.Part.reserved = ALL_DISTRICT; + cell.SetNoCreate(); + + Unit* originalCaster = GetOriginalCaster(); + if(originalCaster) + { + std::list tempUnitMap; + + { + MaNGOS::AnyAoETargetUnitInObjectRangeCheck u_check(pUnitTarget, originalCaster, max_range); + MaNGOS::UnitListSearcher searcher(tempUnitMap, u_check); + + TypeContainerVisitor, WorldTypeMapContainer > world_unit_searcher(searcher); + TypeContainerVisitor, GridTypeMapContainer > grid_unit_searcher(searcher); + + CellLock cell_lock(cell, p); + cell_lock->Visit(cell_lock, world_unit_searcher, *MapManager::Instance().GetMap(m_caster->GetMapId(), m_caster)); + cell_lock->Visit(cell_lock, grid_unit_searcher, *MapManager::Instance().GetMap(m_caster->GetMapId(), m_caster)); + } + + tempUnitMap.sort(TargetDistanceOrder(pUnitTarget)); + + if(tempUnitMap.empty()) + break; + + if(*tempUnitMap.begin() == pUnitTarget) + tempUnitMap.erase(tempUnitMap.begin()); + + TagUnitMap.push_back(pUnitTarget); + uint32 t = unMaxTargets - 1; + Unit *prev = pUnitTarget; + std::list::iterator next = tempUnitMap.begin(); + + while(t && next != tempUnitMap.end() ) + { + if(prev->GetDistance(*next) > CHAIN_SPELL_JUMP_RADIUS) + break; + + if(!prev->IsWithinLOSInMap(*next)) + { + ++next; + continue; + } + + prev = *next; + TagUnitMap.push_back(prev); + tempUnitMap.erase(next); + tempUnitMap.sort(TargetDistanceOrder(prev)); + next = tempUnitMap.begin(); + + --t; + } + } + } + }break; + case TARGET_ALL_ENEMY_IN_AREA: + { + }break; + case TARGET_ALL_ENEMY_IN_AREA_INSTANT: + { + // targets the ground, not the units in the area + if (m_spellInfo->Effect[i]!=SPELL_EFFECT_PERSISTENT_AREA_AURA) + { + CellPair p(MaNGOS::ComputeCellPair(m_targets.m_destX, m_targets.m_destY)); + Cell cell(p); + cell.data.Part.reserved = ALL_DISTRICT; + cell.SetNoCreate(); + + MaNGOS::SpellNotifierCreatureAndPlayer notifier(*this, TagUnitMap, radius, PUSH_DEST_CENTER,SPELL_TARGETS_AOE_DAMAGE); + + TypeContainerVisitor world_object_notifier(notifier); + TypeContainerVisitor grid_object_notifier(notifier); + + CellLock cell_lock(cell, p); + cell_lock->Visit(cell_lock, world_object_notifier, *MapManager::Instance().GetMap(m_caster->GetMapId(), m_caster)); + cell_lock->Visit(cell_lock, grid_object_notifier, *MapManager::Instance().GetMap(m_caster->GetMapId(), m_caster)); + + // exclude caster (this can be important if this not original caster) + TagUnitMap.remove(m_caster); + } + }break; + case TARGET_DUELVSPLAYER_COORDINATES: + { + if(Unit* currentTarget = m_targets.getUnitTarget()) + { + m_targets.setDestination(currentTarget->GetPositionX(), currentTarget->GetPositionY(), currentTarget->GetPositionZ()); + TagUnitMap.push_back(currentTarget); + } + }break; + case TARGET_ALL_PARTY_AROUND_CASTER: + case TARGET_ALL_PARTY_AROUND_CASTER_2: + case TARGET_ALL_PARTY: + { + Player *pTarget = m_caster->GetCharmerOrOwnerPlayerOrPlayerItself(); + Group *pGroup = pTarget ? pTarget->GetGroup() : NULL; + + if(pGroup) + { + uint8 subgroup = pTarget->GetSubGroup(); + + for(GroupReference *itr = pGroup->GetFirstMember(); itr != NULL; itr = itr->next()) + { + Player* Target = itr->getSource(); + + // IsHostileTo check duel and controlled by enemy + if( Target && Target->GetSubGroup()==subgroup && !m_caster->IsHostileTo(Target) ) + { + if( m_caster->IsWithinDistInMap(Target, radius) ) + TagUnitMap.push_back(Target); + + if(Pet* pet = Target->GetPet()) + if( m_caster->IsWithinDistInMap(pet, radius) ) + TagUnitMap.push_back(pet); + } + } + } + else + { + Unit* ownerOrSelf = pTarget ? pTarget : m_caster->GetCharmerOrOwnerOrSelf(); + if(ownerOrSelf==m_caster || m_caster->IsWithinDistInMap(ownerOrSelf, radius)) + TagUnitMap.push_back(ownerOrSelf); + if(Pet* pet = ownerOrSelf->GetPet()) + if( m_caster->IsWithinDistInMap(pet, radius) ) + TagUnitMap.push_back(pet); + } + }break; + case TARGET_RANDOM_RAID_MEMBER: + { + if (m_caster->GetTypeId() == TYPEID_PLAYER) + if(Player* target = ((Player*)m_caster)->GetNextRandomRaidMember(radius)) + TagUnitMap.push_back(target); + }break; + case TARGET_SINGLE_FRIEND: + case TARGET_SINGLE_FRIEND_2: + { + if(m_targets.getUnitTarget()) + TagUnitMap.push_back(m_targets.getUnitTarget()); + }break; + case TARGET_NONCOMBAT_PET: + { + if(Unit* target = m_targets.getUnitTarget()) + if( target->GetTypeId() == TYPEID_UNIT && ((Creature*)target)->isPet() && ((Pet*)target)->getPetType() == MINI_PET) + TagUnitMap.push_back(target); + }break; + case TARGET_ALL_AROUND_CASTER: + { + CellPair p(MaNGOS::ComputeCellPair(m_caster->GetPositionX(), m_caster->GetPositionY())); + Cell cell(p); + cell.data.Part.reserved = ALL_DISTRICT; + cell.SetNoCreate(); + + MaNGOS::SpellNotifierCreatureAndPlayer notifier(*this, TagUnitMap, radius, PUSH_SELF_CENTER,SPELL_TARGETS_AOE_DAMAGE); + + TypeContainerVisitor world_object_notifier(notifier); + TypeContainerVisitor grid_object_notifier(notifier); + + CellLock cell_lock(cell, p); + cell_lock->Visit(cell_lock, world_object_notifier, *MapManager::Instance().GetMap(m_caster->GetMapId(), m_caster)); + cell_lock->Visit(cell_lock, grid_object_notifier, *MapManager::Instance().GetMap(m_caster->GetMapId(), m_caster)); + }break; + case TARGET_ALL_FRIENDLY_UNITS_AROUND_CASTER: + { + CellPair p(MaNGOS::ComputeCellPair(m_caster->GetPositionX(), m_caster->GetPositionY())); + Cell cell(p); + cell.data.Part.reserved = ALL_DISTRICT; + cell.SetNoCreate(); + + MaNGOS::SpellNotifierCreatureAndPlayer notifier(*this, TagUnitMap, radius, PUSH_SELF_CENTER,SPELL_TARGETS_FRIENDLY); + + TypeContainerVisitor world_object_notifier(notifier); + TypeContainerVisitor grid_object_notifier(notifier); + + CellLock cell_lock(cell, p); + cell_lock->Visit(cell_lock, world_object_notifier, *MapManager::Instance().GetMap(m_caster->GetMapId(), m_caster)); + cell_lock->Visit(cell_lock, grid_object_notifier, *MapManager::Instance().GetMap(m_caster->GetMapId(), m_caster)); + }break; + case TARGET_ALL_FRIENDLY_UNITS_IN_AREA: + { + CellPair p(MaNGOS::ComputeCellPair(m_targets.m_destX, m_targets.m_destY)); + Cell cell(p); + cell.data.Part.reserved = ALL_DISTRICT; + cell.SetNoCreate(); + + MaNGOS::SpellNotifierCreatureAndPlayer notifier(*this, TagUnitMap, radius, PUSH_DEST_CENTER,SPELL_TARGETS_FRIENDLY); + + TypeContainerVisitor world_object_notifier(notifier); + TypeContainerVisitor grid_object_notifier(notifier); + + CellLock cell_lock(cell, p); + cell_lock->Visit(cell_lock, world_object_notifier, *MapManager::Instance().GetMap(m_caster->GetMapId(), m_caster)); + cell_lock->Visit(cell_lock, grid_object_notifier, *MapManager::Instance().GetMap(m_caster->GetMapId(), m_caster)); + }break; + // TARGET_SINGLE_PARTY means that the spells can only be casted on a party member and not on the caster (some sceals, fire shield from imp, etc..) + case TARGET_SINGLE_PARTY: + { + Unit *target = m_targets.getUnitTarget(); + // Thoses spells apparently can't be casted on the caster. + if( target && target != m_caster) + { + // Can only be casted on group's members or its pets + Group *pGroup = NULL; + + Unit* owner = m_caster->GetCharmerOrOwner(); + Unit *targetOwner = target->GetCharmerOrOwner(); + if(owner) + { + if(owner->GetTypeId() == TYPEID_PLAYER) + { + if( target == owner ) + { + TagUnitMap.push_back(target); + break; + } + pGroup = ((Player*)owner)->GetGroup(); + } + } + else if (m_caster->GetTypeId() == TYPEID_PLAYER) + { + if( targetOwner == m_caster && target->GetTypeId()==TYPEID_UNIT && ((Creature*)target)->isPet()) + { + TagUnitMap.push_back(target); + break; + } + pGroup = ((Player*)m_caster)->GetGroup(); + } + + if(pGroup) + { + // Our target can also be a player's pet who's grouped with us or our pet. But can't be controlled player + if(targetOwner) + { + if( targetOwner->GetTypeId() == TYPEID_PLAYER && + target->GetTypeId()==TYPEID_UNIT && (((Creature*)target)->isPet()) && + target->GetOwnerGUID()==targetOwner->GetGUID() && + pGroup->IsMember(((Player*)targetOwner)->GetGUID())) + { + TagUnitMap.push_back(target); + } + } + // 1Our target can be a player who is on our group + else if (target->GetTypeId() == TYPEID_PLAYER && pGroup->IsMember(((Player*)target)->GetGUID())) + { + TagUnitMap.push_back(target); + } + } + } + }break; + case TARGET_GAMEOBJECT: + { + if(m_targets.getGOTarget()) + AddGOTarget(m_targets.getGOTarget(), i); + }break; + case TARGET_IN_FRONT_OF_CASTER: + { + CellPair p(MaNGOS::ComputeCellPair(m_caster->GetPositionX(), m_caster->GetPositionY())); + Cell cell(p); + cell.data.Part.reserved = ALL_DISTRICT; + cell.SetNoCreate(); + + bool inFront = m_spellInfo->SpellVisual != 3879; + MaNGOS::SpellNotifierCreatureAndPlayer notifier(*this, TagUnitMap, radius, inFront ? PUSH_IN_FRONT : PUSH_IN_BACK,SPELL_TARGETS_AOE_DAMAGE); + + TypeContainerVisitor world_object_notifier(notifier); + TypeContainerVisitor grid_object_notifier(notifier); + + CellLock cell_lock(cell, p); + cell_lock->Visit(cell_lock, world_object_notifier, *MapManager::Instance().GetMap(m_caster->GetMapId(), m_caster)); + cell_lock->Visit(cell_lock, grid_object_notifier, *MapManager::Instance().GetMap(m_caster->GetMapId(), m_caster)); + }break; + case TARGET_DUELVSPLAYER: + { + Unit *target = m_targets.getUnitTarget(); + if(target) + { + if(m_caster->IsFriendlyTo(target)) + { + TagUnitMap.push_back(target); + } + else + { + Unit* pUnitTarget = SelectMagnetTarget(); + if(pUnitTarget) + TagUnitMap.push_back(pUnitTarget); + } + } + }break; + case TARGET_GAMEOBJECT_ITEM: + { + if(m_targets.getGOTargetGUID()) + AddGOTarget(m_targets.getGOTarget(), i); + else if(m_targets.getItemTarget()) + AddItemTarget(m_targets.getItemTarget(), i); + break; + } + case TARGET_MASTER: + { + if(Unit* owner = m_caster->GetCharmerOrOwner()) + TagUnitMap.push_back(owner); + break; + } + case TARGET_ALL_ENEMY_IN_AREA_CHANNELED: + { + // targets the ground, not the units in the area + if (m_spellInfo->Effect[i]!=SPELL_EFFECT_PERSISTENT_AREA_AURA) + { + CellPair p(MaNGOS::ComputeCellPair(m_caster->GetPositionX(), m_caster->GetPositionY())); + Cell cell(p); + cell.data.Part.reserved = ALL_DISTRICT; + cell.SetNoCreate(); + + MaNGOS::SpellNotifierCreatureAndPlayer notifier(*this, TagUnitMap, radius, PUSH_DEST_CENTER,SPELL_TARGETS_AOE_DAMAGE); + + TypeContainerVisitor world_object_notifier(notifier); + TypeContainerVisitor grid_object_notifier(notifier); + + CellLock cell_lock(cell, p); + cell_lock->Visit(cell_lock, world_object_notifier, *MapManager::Instance().GetMap(m_caster->GetMapId(), m_caster)); + cell_lock->Visit(cell_lock, grid_object_notifier, *MapManager::Instance().GetMap(m_caster->GetMapId(), m_caster)); + } + }break; + case TARGET_MINION: + { + if(m_spellInfo->Effect[i] != SPELL_EFFECT_DUEL) + TagUnitMap.push_back(m_caster); + }break; + case TARGET_SINGLE_ENEMY: + { + Unit* pUnitTarget = SelectMagnetTarget(); + if(pUnitTarget) + TagUnitMap.push_back(pUnitTarget); + }break; + case TARGET_AREAEFFECT_PARTY: + { + Unit* owner = m_caster->GetCharmerOrOwner(); + Player *pTarget = NULL; + + if(owner) + { + TagUnitMap.push_back(m_caster); + if(owner->GetTypeId() == TYPEID_PLAYER) + pTarget = (Player*)owner; + } + else if (m_caster->GetTypeId() == TYPEID_PLAYER) + { + if(Unit* target = m_targets.getUnitTarget()) + { + if( target->GetTypeId() != TYPEID_PLAYER) + { + if(((Creature*)target)->isPet()) + { + Unit *targetOwner = target->GetOwner(); + if(targetOwner->GetTypeId() == TYPEID_PLAYER) + pTarget = (Player*)targetOwner; + } + } + else + pTarget = (Player*)target; + } + } + + Group* pGroup = pTarget ? pTarget->GetGroup() : NULL; + + if(pGroup) + { + uint8 subgroup = pTarget->GetSubGroup(); + + for(GroupReference *itr = pGroup->GetFirstMember(); itr != NULL; itr = itr->next()) + { + Player* Target = itr->getSource(); + + // IsHostileTo check duel and controlled by enemy + if(Target && Target->GetSubGroup()==subgroup && !m_caster->IsHostileTo(Target)) + { + if( pTarget->IsWithinDistInMap(Target, radius) ) + TagUnitMap.push_back(Target); + + if(Pet* pet = Target->GetPet()) + if( pTarget->IsWithinDistInMap(pet, radius) ) + TagUnitMap.push_back(pet); + } + } + } + else if (owner) + { + if(m_caster->IsWithinDistInMap(owner, radius)) + TagUnitMap.push_back(owner); + } + else if(pTarget) + { + TagUnitMap.push_back(pTarget); + + if(Pet* pet = pTarget->GetPet()) + if( m_caster->IsWithinDistInMap(pet, radius) ) + TagUnitMap.push_back(pet); + } + + }break; + case TARGET_SCRIPT: + { + if(m_targets.getUnitTarget()) + TagUnitMap.push_back(m_targets.getUnitTarget()); + if(m_targets.getItemTarget()) + AddItemTarget(m_targets.getItemTarget(), i); + }break; + case TARGET_SELF_FISHING: + { + TagUnitMap.push_back(m_caster); + }break; + case TARGET_CHAIN_HEAL: + { + Unit* pUnitTarget = m_targets.getUnitTarget(); + if(!pUnitTarget) + break; + + if (EffectChainTarget <= 1) + TagUnitMap.push_back(pUnitTarget); + else + { + unMaxTargets = EffectChainTarget; + float max_range = radius + unMaxTargets * CHAIN_SPELL_JUMP_RADIUS; + + std::list tempUnitMap; + + { + CellPair p(MaNGOS::ComputeCellPair(m_caster->GetPositionX(), m_caster->GetPositionY())); + Cell cell(p); + cell.data.Part.reserved = ALL_DISTRICT; + cell.SetNoCreate(); + + MaNGOS::SpellNotifierCreatureAndPlayer notifier(*this, tempUnitMap, max_range, PUSH_SELF_CENTER, SPELL_TARGETS_FRIENDLY); + + TypeContainerVisitor world_object_notifier(notifier); + TypeContainerVisitor grid_object_notifier(notifier); + + CellLock cell_lock(cell, p); + cell_lock->Visit(cell_lock, world_object_notifier, *MapManager::Instance().GetMap(m_caster->GetMapId(), m_caster)); + cell_lock->Visit(cell_lock, grid_object_notifier, *MapManager::Instance().GetMap(m_caster->GetMapId(), m_caster)); + + } + + if(m_caster != pUnitTarget && std::find(tempUnitMap.begin(),tempUnitMap.end(),m_caster) == tempUnitMap.end() ) + tempUnitMap.push_front(m_caster); + + tempUnitMap.sort(TargetDistanceOrder(pUnitTarget)); + + if(tempUnitMap.empty()) + break; + + if(*tempUnitMap.begin() == pUnitTarget) + tempUnitMap.erase(tempUnitMap.begin()); + + TagUnitMap.push_back(pUnitTarget); + uint32 t = unMaxTargets - 1; + Unit *prev = pUnitTarget; + std::list::iterator next = tempUnitMap.begin(); + + while(t && next != tempUnitMap.end() ) + { + if(prev->GetDistance(*next) > CHAIN_SPELL_JUMP_RADIUS) + break; + + if(!prev->IsWithinLOSInMap(*next)) + { + ++next; + continue; + } + + if((*next)->GetHealth() == (*next)->GetMaxHealth()) + { + next = tempUnitMap.erase(next); + continue; + } + + prev = *next; + TagUnitMap.push_back(prev); + tempUnitMap.erase(next); + tempUnitMap.sort(TargetDistanceOrder(prev)); + next = tempUnitMap.begin(); + + --t; + } + } + }break; + case TARGET_CURRENT_ENEMY_COORDINATES: + { + Unit* currentTarget = m_targets.getUnitTarget(); + if(currentTarget) + { + TagUnitMap.push_back(currentTarget); + m_targets.setDestination(currentTarget->GetPositionX(), currentTarget->GetPositionY(), currentTarget->GetPositionZ()); + if(m_spellInfo->EffectImplicitTargetB[i]==TARGET_ALL_ENEMY_IN_AREA_INSTANT) + { + CellPair p(MaNGOS::ComputeCellPair(currentTarget->GetPositionX(), currentTarget->GetPositionY())); + Cell cell(p); + cell.data.Part.reserved = ALL_DISTRICT; + cell.SetNoCreate(); + MaNGOS::SpellNotifierCreatureAndPlayer notifier(*this, TagUnitMap, radius,PUSH_TARGET_CENTER, SPELL_TARGETS_AOE_DAMAGE); + TypeContainerVisitor world_notifier(notifier); + TypeContainerVisitor grid_notifier(notifier); + CellLock cell_lock(cell, p); + cell_lock->Visit(cell_lock, world_notifier, *MapManager::Instance().GetMap(m_caster->GetMapId(), m_caster)); + cell_lock->Visit(cell_lock, grid_notifier, *MapManager::Instance().GetMap(m_caster->GetMapId(), m_caster)); + } + } + }break; + case TARGET_AREAEFFECT_PARTY_AND_CLASS: + { + Player* targetPlayer = m_targets.getUnitTarget() && m_targets.getUnitTarget()->GetTypeId() == TYPEID_PLAYER + ? (Player*)m_targets.getUnitTarget() : NULL; + + Group* pGroup = targetPlayer ? targetPlayer->GetGroup() : NULL; + if(pGroup) + { + for(GroupReference *itr = pGroup->GetFirstMember(); itr != NULL; itr = itr->next()) + { + Player* Target = itr->getSource(); + + // IsHostileTo check duel and controlled by enemy + if( Target && targetPlayer->IsWithinDistInMap(Target, radius) && + targetPlayer->getClass() == Target->getClass() && + !m_caster->IsHostileTo(Target) ) + { + TagUnitMap.push_back(Target); + } + } + } + else if(m_targets.getUnitTarget()) + TagUnitMap.push_back(m_targets.getUnitTarget()); + break; + } + case TARGET_TABLE_X_Y_Z_COORDINATES: + { + SpellTargetPosition const* st = spellmgr.GetSpellTargetPosition(m_spellInfo->Id); + if(st) + { + if (st->target_mapId == m_caster->GetMapId()) + m_targets.setDestination(st->target_X, st->target_Y, st->target_Z); + + // if B==TARGET_TABLE_X_Y_Z_COORDINATES then A already fill all required targets + if (m_spellInfo->EffectImplicitTargetB[i] && m_spellInfo->EffectImplicitTargetB[i]!=TARGET_TABLE_X_Y_Z_COORDINATES) + { + CellPair p(MaNGOS::ComputeCellPair(m_caster->GetPositionX(), m_caster->GetPositionY())); + Cell cell(p); + cell.data.Part.reserved = ALL_DISTRICT; + cell.SetNoCreate(); + + SpellTargets targetB = SPELL_TARGETS_AOE_DAMAGE; + // Select friendly targets for positive effect + if (IsPositiveEffect(m_spellInfo->Id, i)) + targetB = SPELL_TARGETS_FRIENDLY; + + MaNGOS::SpellNotifierCreatureAndPlayer notifier(*this, TagUnitMap, radius,PUSH_DEST_CENTER, targetB); + + TypeContainerVisitor world_notifier(notifier); + TypeContainerVisitor grid_notifier(notifier); + + CellLock cell_lock(cell, p); + cell_lock->Visit(cell_lock, world_notifier, *MapManager::Instance().GetMap(m_caster->GetMapId(), m_caster)); + cell_lock->Visit(cell_lock, grid_notifier, *MapManager::Instance().GetMap(m_caster->GetMapId(), m_caster)); + } + } + else + sLog.outError( "SPELL: unknown target coordinates for spell ID %u\n", m_spellInfo->Id ); + }break; + case TARGET_BEHIND_VICTIM: + { + Unit *pTarget = m_caster->getVictim(); + if(!pTarget && m_caster->GetTypeId() == TYPEID_PLAYER) + pTarget = ObjectAccessor::GetUnit(*m_caster, ((Player*)m_caster)->GetSelection()); + + if(pTarget) + { + float _target_x, _target_y, _target_z; + pTarget->GetClosePoint(_target_x, _target_y, _target_z, m_caster->GetObjectSize(), CONTACT_DISTANCE, M_PI); + if(pTarget->IsWithinLOS(_target_x,_target_y,_target_z)) + m_targets.setDestination(_target_x, _target_y, _target_z); + } + }break; + default: + break; + } + + if (unMaxTargets && TagUnitMap.size() > unMaxTargets) + { + // make sure one unit is always removed per iteration + uint32 removed_utarget = 0; + for (std::list::iterator itr = TagUnitMap.begin(), next; itr != TagUnitMap.end(); itr = next) + { + next = itr; + ++next; + if (!*itr) continue; + if ((*itr) == m_targets.getUnitTarget()) + { + TagUnitMap.erase(itr); + removed_utarget = 1; + // break; + } + } + // remove random units from the map + while (TagUnitMap.size() > unMaxTargets - removed_utarget) + { + uint32 poz = urand(0, TagUnitMap.size()-1); + for (std::list::iterator itr = TagUnitMap.begin(); itr != TagUnitMap.end(); ++itr, --poz) + { + if (!*itr) continue; + if (!poz) + { + TagUnitMap.erase(itr); + break; + } + } + } + // the player's target will always be added to the map + if (removed_utarget && m_targets.getUnitTarget()) + TagUnitMap.push_back(m_targets.getUnitTarget()); + } +} + +void Spell::prepare(SpellCastTargets * targets, Aura* triggeredByAura) +{ + m_targets = *targets; + + m_spellState = SPELL_STATE_PREPARING; + + m_castPositionX = m_caster->GetPositionX(); + m_castPositionY = m_caster->GetPositionY(); + m_castPositionZ = m_caster->GetPositionZ(); + m_castOrientation = m_caster->GetOrientation(); + + if(triggeredByAura) + m_triggeredByAuraSpell = triggeredByAura->GetSpellProto(); + + // create and add update event for this spell + SpellEvent* Event = new SpellEvent(this); + m_caster->m_Events.AddEvent(Event, m_caster->m_Events.CalculateTime(1)); + + //Prevent casting at cast another spell (ServerSide check) + if(m_caster->IsNonMeleeSpellCasted(false, true) && m_cast_count) + { + SendCastResult(SPELL_FAILED_SPELL_IN_PROGRESS); + finish(false); + return; + } + + // Fill cost data + m_powerCost = CalculatePowerCost(); + + uint8 result = CanCast(true); + if(result != 0 && !IsAutoRepeat()) //always cast autorepeat dummy for triggering + { + if(triggeredByAura) + { + SendChannelUpdate(0); + triggeredByAura->SetAuraDuration(0); + } + SendCastResult(result); + finish(false); + return; + } + + // calculate cast time (calculated after first CanCast check to prevent charge counting for first CanCast fail) + m_casttime = GetSpellCastTime(m_spellInfo, this); + + // set timer base at cast time + ReSetTimer(); + + // stealth must be removed at cast starting (at show channel bar) + // skip triggered spell (item equip spell casting and other not explicit character casts/item uses) + if ( !m_IsTriggeredSpell && isSpellBreakStealth(m_spellInfo) ) + { + m_caster->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); + m_caster->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH); + } + + if(m_IsTriggeredSpell) + cast(true); + else + { + m_caster->SetCurrentCastedSpell( this ); + m_selfContainer = &(m_caster->m_currentSpells[GetCurrentContainer()]); + SendSpellStart(); + } +} + +void Spell::cancel() +{ + if(m_spellState == SPELL_STATE_FINISHED) + return; + + m_autoRepeat = false; + switch (m_spellState) + { + case SPELL_STATE_PREPARING: + case SPELL_STATE_DELAYED: + { + SendInterrupted(0); + SendCastResult(SPELL_FAILED_INTERRUPTED); + } break; + + case SPELL_STATE_CASTING: + { + for(std::list::iterator ihit= m_UniqueTargetInfo.begin();ihit != m_UniqueTargetInfo.end();++ihit) + { + if( ihit->missCondition == SPELL_MISS_NONE ) + { + Unit* unit = m_caster->GetGUID()==(*ihit).targetGUID ? m_caster : ObjectAccessor::GetUnit(*m_caster, ihit->targetGUID); + if( unit && unit->isAlive() ) + unit->RemoveAurasDueToSpell(m_spellInfo->Id); + } + } + + m_caster->RemoveAurasDueToSpell(m_spellInfo->Id); + SendChannelUpdate(0); + SendInterrupted(0); + SendCastResult(SPELL_FAILED_INTERRUPTED); + } break; + + default: + { + } break; + } + + finish(false); + m_caster->RemoveDynObject(m_spellInfo->Id); + m_caster->RemoveGameObject(m_spellInfo->Id,true); +} + +void Spell::cast(bool skipCheck) +{ + uint8 castResult = 0; + + // update pointers base at GUIDs to prevent access to non-existed already object + UpdatePointers(); + + // cancel at lost main target unit + if(!m_targets.getUnitTarget() && m_targets.getUnitTargetGUID() && m_targets.getUnitTargetGUID() != m_caster->GetGUID()) + { + cancel(); + return; + } + + if(m_caster->GetTypeId() != TYPEID_PLAYER && m_targets.getUnitTarget() && m_targets.getUnitTarget() != m_caster) + m_caster->SetInFront(m_targets.getUnitTarget()); + + castResult = CheckPower(); + if(castResult != 0) + { + SendCastResult(castResult); + finish(false); + return; + } + + // triggered cast called from Spell::prepare where it was already checked + if(!skipCheck) + { + castResult = CanCast(false); + if(castResult != 0) + { + SendCastResult(castResult); + finish(false); + return; + } + } + + // Conflagrate - consumes immolate + if ((m_spellInfo->TargetAuraState == AURA_STATE_IMMOLATE) && m_targets.getUnitTarget()) + { + // for caster applied auras only + Unit::AuraList const &mPeriodic = m_targets.getUnitTarget()->GetAurasByType(SPELL_AURA_PERIODIC_DAMAGE); + for(Unit::AuraList::const_iterator i = mPeriodic.begin(); i != mPeriodic.end(); ++i) + { + if( (*i)->GetSpellProto()->SpellFamilyName == SPELLFAMILY_WARLOCK && ((*i)->GetSpellProto()->SpellFamilyFlags & 4) && + (*i)->GetCasterGUID()==m_caster->GetGUID() ) + { + m_targets.getUnitTarget()->RemoveAura((*i)->GetId(), (*i)->GetEffIndex()); + break; + } + } + } + + // traded items have trade slot instead of guid in m_itemTargetGUID + // set to real guid to be sent later to the client + m_targets.updateTradeSlotItem(); + + // CAST SPELL + SendSpellCooldown(); + + TakePower(); + TakeReagents(); // we must remove reagents before HandleEffects to allow place crafted item in same slot + FillTargetMap(); + + if(m_spellState == SPELL_STATE_FINISHED) // stop cast if spell marked as finish somewhere in Take*/FillTargetMap + return; + + SendCastResult(castResult); + SendSpellGo(); // we must send smsg_spell_go packet before m_castItem delete in TakeCastItem()... + + // Pass cast spell event to handler (not send triggered by aura spells) + if (m_spellInfo->DmgClass != SPELL_DAMAGE_CLASS_MELEE && m_spellInfo->DmgClass != SPELL_DAMAGE_CLASS_RANGED && !m_triggeredByAuraSpell) + { + m_caster->ProcDamageAndSpell(m_targets.getUnitTarget(), PROC_FLAG_CAST_SPELL, PROC_FLAG_NONE, 0, SPELL_SCHOOL_MASK_NONE, m_spellInfo, m_IsTriggeredSpell); + + // update pointers base at GUIDs to prevent access to non-existed already object + UpdatePointers(); // pointers can be invalidate at triggered spell casting + } + + // Okay, everything is prepared. Now we need to distinguish between immediate and evented delayed spells + if (m_spellInfo->speed > 0.0f) + { + + // Remove used for cast item if need (it can be already NULL after TakeReagents call + // in case delayed spell remove item at cast delay start + TakeCastItem(); + + // Okay, maps created, now prepare flags + m_immediateHandled = false; + m_spellState = SPELL_STATE_DELAYED; + SetDelayStart(0); + } + else + { + // Immediate spell, no big deal + handle_immediate(); + } +} + +void Spell::handle_immediate() +{ + // start channeling if applicable + if(IsChanneledSpell(m_spellInfo)) + { + m_spellState = SPELL_STATE_CASTING; + SendChannelStart(GetSpellDuration(m_spellInfo)); + } + + // process immediate effects (items, ground, etc.) also initialize some variables + _handle_immediate_phase(); + + for(std::list::iterator ihit= m_UniqueTargetInfo.begin();ihit != m_UniqueTargetInfo.end();++ihit) + DoAllEffectOnTarget(&(*ihit)); + + for(std::list::iterator ihit= m_UniqueGOTargetInfo.begin();ihit != m_UniqueGOTargetInfo.end();++ihit) + DoAllEffectOnTarget(&(*ihit)); + + // spell is finished, perform some last features of the spell here + _handle_finish_phase(); + + // Remove used for cast item if need (it can be already NULL after TakeReagents call + TakeCastItem(); + + if(m_spellState != SPELL_STATE_CASTING) + finish(true); // successfully finish spell cast (not last in case autorepeat or channel spell) +} + +uint64 Spell::handle_delayed(uint64 t_offset) +{ + uint64 next_time = 0; + + if (!m_immediateHandled) + { + _handle_immediate_phase(); + m_immediateHandled = true; + } + + // now recheck units targeting correctness (need before any effects apply to prevent adding immunity at first effect not allow apply second spell effect and similar cases) + for(std::list::iterator ihit= m_UniqueTargetInfo.begin(); ihit != m_UniqueTargetInfo.end();++ihit) + { + if (ihit->processed == false) + { + if ( ihit->timeDelay <= t_offset ) + DoAllEffectOnTarget(&(*ihit)); + else if( next_time == 0 || ihit->timeDelay < next_time ) + next_time = ihit->timeDelay; + } + } + + // now recheck gameobject targeting correctness + for(std::list::iterator ighit= m_UniqueGOTargetInfo.begin(); ighit != m_UniqueGOTargetInfo.end();++ighit) + { + if (ighit->processed == false) + { + if ( ighit->timeDelay <= t_offset ) + DoAllEffectOnTarget(&(*ighit)); + else if( next_time == 0 || ighit->timeDelay < next_time ) + next_time = ighit->timeDelay; + } + } + // All targets passed - need finish phase + if (next_time == 0) + { + // spell is finished, perform some last features of the spell here + _handle_finish_phase(); + + finish(true); // successfully finish spell cast + + // return zero, spell is finished now + return 0; + } + else + { + // spell is unfinished, return next execution time + return next_time; + } +} + +void Spell::_handle_immediate_phase() +{ + // handle some immediate features of the spell here + HandleThreatSpells(m_spellInfo->Id); + + m_needSpellLog = IsNeedSendToClient(); + for(uint32 j = 0;j<3;j++) + { + if(m_spellInfo->Effect[j]==0) + continue; + + // apply Send Event effect to ground in case empty target lists + if( m_spellInfo->Effect[j] == SPELL_EFFECT_SEND_EVENT && !HaveTargetsForEffect(j) ) + { + HandleEffects(NULL,NULL,NULL, j); + continue; + } + + // Don't do spell log, if is school damage spell + if(m_spellInfo->Effect[j] == SPELL_EFFECT_SCHOOL_DAMAGE || m_spellInfo->Effect[j] == 0) + m_needSpellLog = false; + + uint32 EffectChainTarget = m_spellInfo->EffectChainTarget[j]; + if(m_originalCaster) + if(Player* modOwner = m_originalCaster->GetSpellModOwner()) + modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_JUMP_TARGETS, EffectChainTarget, this); + + // initialize multipliers + m_damageMultipliers[j] = 1.0f; + if( (m_spellInfo->EffectImplicitTargetA[j] == TARGET_CHAIN_DAMAGE || m_spellInfo->EffectImplicitTargetA[j] == TARGET_CHAIN_HEAL) && + (EffectChainTarget > 1) ) + m_applyMultiplierMask |= 1 << j; + } + + // initialize Diminishing Returns Data + m_diminishLevel = DIMINISHING_LEVEL_1; + m_diminishGroup = DIMINISHING_NONE; + + // process items + for(std::list::iterator ihit= m_UniqueItemInfo.begin();ihit != m_UniqueItemInfo.end();++ihit) + DoAllEffectOnTarget(&(*ihit)); + + // process ground + for(uint32 j = 0;j<3;j++) + { + // persistent area auras target only the ground + if(m_spellInfo->Effect[j] == SPELL_EFFECT_PERSISTENT_AREA_AURA) + HandleEffects(NULL,NULL,NULL, j); + } +} + +void Spell::_handle_finish_phase() +{ + // spell log + if(m_needSpellLog) + SendLogExecute(); +} + +void Spell::SendSpellCooldown() +{ + if(m_caster->GetTypeId() != TYPEID_PLAYER) + return; + + Player* _player = (Player*)m_caster; + // Add cooldown for max (disable spell) + // Cooldown started on SendCooldownEvent call + if (m_spellInfo->Attributes & SPELL_ATTR_DISABLED_WHILE_ACTIVE) + { + _player->AddSpellCooldown(m_spellInfo->Id, 0, time(NULL) - 1); + return; + } + + // init cooldown values + uint32 cat = 0; + int32 rec = -1; + int32 catrec = -1; + + // some special item spells without correct cooldown in SpellInfo + // cooldown information stored in item prototype + // This used in same way in WorldSession::HandleItemQuerySingleOpcode data sending to client. + + if(m_CastItem) + { + ItemPrototype const* proto = m_CastItem->GetProto(); + if(proto) + { + for(int idx = 0; idx < 5; ++idx) + { + if(proto->Spells[idx].SpellId == m_spellInfo->Id) + { + cat = proto->Spells[idx].SpellCategory; + rec = proto->Spells[idx].SpellCooldown; + catrec = proto->Spells[idx].SpellCategoryCooldown; + break; + } + } + } + } + + // if no cooldown found above then base at DBC data + if(rec < 0 && catrec < 0) + { + cat = m_spellInfo->Category; + rec = m_spellInfo->RecoveryTime; + catrec = m_spellInfo->CategoryRecoveryTime; + } + + // shoot spells used equipped item cooldown values already assigned in GetAttackTime(RANGED_ATTACK) + // prevent 0 cooldowns set by another way + if (rec <= 0 && catrec <= 0 && (cat == 76 || cat == 351)) + rec = _player->GetAttackTime(RANGED_ATTACK); + + // Now we have cooldown data (if found any), time to apply mods + if(rec > 0) + _player->ApplySpellMod(m_spellInfo->Id, SPELLMOD_COOLDOWN, rec, this); + + if(catrec > 0) + _player->ApplySpellMod(m_spellInfo->Id, SPELLMOD_COOLDOWN, catrec, this); + + // replace negative cooldowns by 0 + if (rec < 0) rec = 0; + if (catrec < 0) catrec = 0; + + // no cooldown after applying spell mods + if( rec == 0 && catrec == 0) + return; + + time_t curTime = time(NULL); + + time_t catrecTime = catrec ? curTime+catrec/1000 : 0; // in secs + time_t recTime = rec ? curTime+rec/1000 : catrecTime;// in secs + + // self spell cooldown + if(recTime > 0) + _player->AddSpellCooldown(m_spellInfo->Id, m_CastItem ? m_CastItem->GetEntry() : 0, recTime); + + // category spells + if (catrec > 0) + { + SpellCategoryStore::const_iterator i_scstore = sSpellCategoryStore.find(cat); + if(i_scstore != sSpellCategoryStore.end()) + { + for(SpellCategorySet::const_iterator i_scset = i_scstore->second.begin(); i_scset != i_scstore->second.end(); ++i_scset) + { + if(*i_scset == m_spellInfo->Id) // skip main spell, already handled above + continue; + + _player->AddSpellCooldown(m_spellInfo->Id, m_CastItem ? m_CastItem->GetEntry() : 0, catrecTime); + } + } + } +} + +void Spell::update(uint32 difftime) +{ + // update pointers based at it's GUIDs + UpdatePointers(); + + if(m_targets.getUnitTargetGUID() && !m_targets.getUnitTarget()) + { + cancel(); + return; + } + + // check if the player caster has moved before the spell finished + if ((m_caster->GetTypeId() == TYPEID_PLAYER && m_timer != 0) && + (m_castPositionX != m_caster->GetPositionX() || m_castPositionY != m_caster->GetPositionY() || m_castPositionZ != m_caster->GetPositionZ()) && + (m_spellInfo->Effect[0] != SPELL_EFFECT_STUCK || !m_caster->HasUnitMovementFlag(MOVEMENTFLAG_FALLING))) + { + // always cancel for channeled spells + if( m_spellState == SPELL_STATE_CASTING ) + cancel(); + // don't cancel for melee, autorepeat, triggered and instant spells + else if(!IsNextMeleeSwingSpell() && !IsAutoRepeat() && !m_IsTriggeredSpell && (m_spellInfo->InterruptFlags & SPELL_INTERRUPT_FLAG_MOVEMENT)) + cancel(); + } + + switch(m_spellState) + { + case SPELL_STATE_PREPARING: + { + if(m_timer) + { + if(difftime >= m_timer) + m_timer = 0; + else + m_timer -= difftime; + } + + if(m_timer == 0 && !IsNextMeleeSwingSpell() && !IsAutoRepeat()) + cast(); + } break; + case SPELL_STATE_CASTING: + { + if(m_timer > 0) + { + if( m_caster->GetTypeId() == TYPEID_PLAYER ) + { + // check if player has jumped before the channeling finished + if(m_caster->HasUnitMovementFlag(MOVEMENTFLAG_JUMPING)) + cancel(); + + // check for incapacitating player states + if( m_caster->hasUnitState(UNIT_STAT_STUNDED | UNIT_STAT_CONFUSED)) + cancel(); + + // check if player has turned if flag is set + if( m_spellInfo->ChannelInterruptFlags & CHANNEL_FLAG_TURNING && m_castOrientation != m_caster->GetOrientation() ) + cancel(); + } + + // check if there are alive targets left + if (!IsAliveUnitPresentInTargetList()) + { + SendChannelUpdate(0); + finish(); + } + + if(difftime >= m_timer) + m_timer = 0; + else + m_timer -= difftime; + } + + if(m_timer == 0) + { + SendChannelUpdate(0); + + // channeled spell processed independently for quest targeting + // cast at creature (or GO) quest objectives update at successful cast channel finished + // ignore autorepeat/melee casts for speed (not exist quest for spells (hm... ) + if( m_caster->GetTypeId() == TYPEID_PLAYER && !IsAutoRepeat() && !IsNextMeleeSwingSpell() ) + { + for(std::list::iterator ihit= m_UniqueTargetInfo.begin();ihit != m_UniqueTargetInfo.end();++ihit) + { + TargetInfo* target = &*ihit; + if(!IS_CREATURE_GUID(target->targetGUID)) + continue; + + Unit* unit = m_caster->GetGUID()==target->targetGUID ? m_caster : ObjectAccessor::GetUnit(*m_caster,target->targetGUID); + if (unit==NULL) + continue; + + ((Player*)m_caster)->CastedCreatureOrGO(unit->GetEntry(),unit->GetGUID(),m_spellInfo->Id); + } + + for(std::list::iterator ihit= m_UniqueGOTargetInfo.begin();ihit != m_UniqueGOTargetInfo.end();++ihit) + { + GOTargetInfo* target = &*ihit; + + GameObject* go = ObjectAccessor::GetGameObject(*m_caster, target->targetGUID); + if(!go) + continue; + + ((Player*)m_caster)->CastedCreatureOrGO(go->GetEntry(),go->GetGUID(),m_spellInfo->Id); + } + } + + finish(); + } + } break; + default: + { + }break; + } +} + +void Spell::finish(bool ok) +{ + if(!m_caster) + return; + + if(m_spellState == SPELL_STATE_FINISHED) + return; + + m_spellState = SPELL_STATE_FINISHED; + + //remove spell mods + if (m_caster->GetTypeId() == TYPEID_PLAYER) + ((Player*)m_caster)->RemoveSpellMods(this); + + // other code related only to successfully finished spells + if(!ok) + return; + + //handle SPELL_AURA_ADD_TARGET_TRIGGER auras + Unit::AuraList const& targetTriggers = m_caster->GetAurasByType(SPELL_AURA_ADD_TARGET_TRIGGER); + for(Unit::AuraList::const_iterator i = targetTriggers.begin(); i != targetTriggers.end(); ++i) + { + SpellEntry const *auraSpellInfo = (*i)->GetSpellProto(); + uint32 auraSpellIdx = (*i)->GetEffIndex(); + if (IsAffectedBy(auraSpellInfo, auraSpellIdx)) + { + for(std::list::iterator ihit= m_UniqueTargetInfo.begin();ihit != m_UniqueTargetInfo.end();++ihit) + if( ihit->effectMask & (1<GetGUID() let load auras at login and speedup most often case + Unit *unit = m_caster->GetGUID()== ihit->targetGUID ? m_caster : ObjectAccessor::GetUnit(*m_caster, ihit->targetGUID); + if (unit && unit->isAlive()) + { + // Calculate chance at that moment (can be depend for example from combo points) + int32 chance = m_caster->CalculateSpellDamage(auraSpellInfo, auraSpellIdx, (*i)->GetBasePoints(),unit); + + if(roll_chance_i(chance)) + m_caster->CastSpell(unit, auraSpellInfo->EffectTriggerSpell[auraSpellIdx], true, NULL, (*i)); + } + } + } + } + + if (IsMeleeAttackResetSpell()) + { + m_caster->resetAttackTimer(BASE_ATTACK); + if(m_caster->haveOffhandWeapon()) + m_caster->resetAttackTimer(OFF_ATTACK); + } + + /*if (IsRangedAttackResetSpell()) + m_caster->resetAttackTimer(RANGED_ATTACK);*/ + + // Clear combo at finish state + if(m_caster->GetTypeId() == TYPEID_PLAYER && NeedsComboPoints(m_spellInfo)) + ((Player*)m_caster)->ClearComboPoints(); + + // call triggered spell only at successful cast (after clear combo points -> for add some if need) + if(!m_TriggerSpells.empty()) + TriggerSpell(); + + // Stop Attack for some spells + if( m_spellInfo->Attributes & SPELL_ATTR_STOP_ATTACK_TARGET ) + m_caster->AttackStop(); +} + +void Spell::SendCastResult(uint8 result) +{ + if (m_caster->GetTypeId() != TYPEID_PLAYER) + return; + + if(((Player*)m_caster)->GetSession()->PlayerLoading()) // don't send cast results at loading time + return; + + if(result != 0) + { + WorldPacket data(SMSG_CAST_FAILED, (4+1+1)); + data << uint32(m_spellInfo->Id); + data << uint8(result); // problem + data << uint8(m_cast_count); // single cast or multi 2.3 (0/1) + switch (result) + { + case SPELL_FAILED_REQUIRES_SPELL_FOCUS: + data << uint32(m_spellInfo->RequiresSpellFocus); + break; + case SPELL_FAILED_REQUIRES_AREA: + // hardcode areas limitation case + if( m_spellInfo->Id==41618 || m_spellInfo->Id==41620 ) + data << uint32(3842); + else if( m_spellInfo->Id==41617 || m_spellInfo->Id==41619 ) + data << uint32(3905); + // normal case + else + data << uint32(m_spellInfo->AreaId); + break; + case SPELL_FAILED_TOTEMS: + if(m_spellInfo->Totem[0]) + data << uint32(m_spellInfo->Totem[0]); + if(m_spellInfo->Totem[1]) + data << uint32(m_spellInfo->Totem[1]); + break; + case SPELL_FAILED_TOTEM_CATEGORY: + if(m_spellInfo->TotemCategory[0]) + data << uint32(m_spellInfo->TotemCategory[0]); + if(m_spellInfo->TotemCategory[1]) + data << uint32(m_spellInfo->TotemCategory[1]); + break; + case SPELL_FAILED_EQUIPPED_ITEM_CLASS: + data << uint32(m_spellInfo->EquippedItemClass); + data << uint32(m_spellInfo->EquippedItemSubClassMask); + data << uint32(m_spellInfo->EquippedItemInventoryTypeMask); + break; + } + ((Player*)m_caster)->GetSession()->SendPacket(&data); + } + else + { + WorldPacket data(SMSG_CLEAR_EXTRA_AURA_INFO, (8+4)); + data.append(m_caster->GetPackGUID()); + data << uint32(m_spellInfo->Id); + ((Player*)m_caster)->GetSession()->SendPacket(&data); + } +} + +void Spell::SendSpellStart() +{ + if(!IsNeedSendToClient()) + return; + + sLog.outDebug("Sending SMSG_SPELL_START id=%u",m_spellInfo->Id); + + uint16 castFlags = CAST_FLAG_UNKNOWN1; + if(IsRangedSpell()) + castFlags |= CAST_FLAG_AMMO; + + Unit * target; + if(!m_targets.getUnitTarget()) + target = m_caster; + else + target = m_targets.getUnitTarget(); + + WorldPacket data(SMSG_SPELL_START, (8+8+4+4+2)); + if(m_CastItem) + data.append(m_CastItem->GetPackGUID()); + else + data.append(m_caster->GetPackGUID()); + + data.append(m_caster->GetPackGUID()); + data << uint32(m_spellInfo->Id); + data << uint8(m_cast_count); // single cast or multi 2.3 (0/1) + data << uint16(castFlags); + data << uint32(m_timer); + + m_targets.write(&data); + + if( castFlags & CAST_FLAG_AMMO ) + WriteAmmoToPacket(&data); + + m_caster->SendMessageToSet(&data, true); +} + +void Spell::SendSpellGo() +{ + // not send invisible spell casting + if(!IsNeedSendToClient()) + return; + + sLog.outDebug("Sending SMSG_SPELL_GO id=%u",m_spellInfo->Id); + + Unit * target; + if(!m_targets.getUnitTarget()) + target = m_caster; + else + target = m_targets.getUnitTarget(); + + uint16 castFlags = CAST_FLAG_UNKNOWN3; + if(IsRangedSpell()) + castFlags |= CAST_FLAG_AMMO; + + WorldPacket data(SMSG_SPELL_GO, 50); // guess size + if(m_CastItem) + data.append(m_CastItem->GetPackGUID()); + else + data.append(m_caster->GetPackGUID()); + + data.append(m_caster->GetPackGUID()); + data << uint32(m_spellInfo->Id); + data << uint16(castFlags); + data << uint32(getMSTime()); // timestamp + + WriteSpellGoTargets(&data); + + m_targets.write(&data); + + if( castFlags & CAST_FLAG_AMMO ) + WriteAmmoToPacket(&data); + + m_caster->SendMessageToSet(&data, true); +} + +void Spell::WriteAmmoToPacket( WorldPacket * data ) +{ + uint32 ammoInventoryType = 0; + uint32 ammoDisplayID = 0; + + if (m_caster->GetTypeId() == TYPEID_PLAYER) + { + Item *pItem = ((Player*)m_caster)->GetWeaponForAttack( RANGED_ATTACK ); + if(pItem) + { + ammoInventoryType = pItem->GetProto()->InventoryType; + if( ammoInventoryType == INVTYPE_THROWN ) + ammoDisplayID = pItem->GetProto()->DisplayInfoID; + else + { + uint32 ammoID = ((Player*)m_caster)->GetUInt32Value(PLAYER_AMMO_ID); + if(ammoID) + { + ItemPrototype const *pProto = objmgr.GetItemPrototype( ammoID ); + if(pProto) + { + ammoDisplayID = pProto->DisplayInfoID; + ammoInventoryType = pProto->InventoryType; + } + } + else if(m_caster->GetDummyAura(46699)) // Requires No Ammo + { + ammoDisplayID = 5996; // normal arrow + ammoInventoryType = INVTYPE_AMMO; + } + } + } + } + // TODO: implement selection ammo data based at ranged weapon stored in equipmodel/equipinfo/equipslot fields + + *data << uint32(ammoDisplayID); + *data << uint32(ammoInventoryType); +} + +void Spell::WriteSpellGoTargets( WorldPacket * data ) +{ + *data << (uint8)m_countOfHit; + for(std::list::iterator ihit= m_UniqueTargetInfo.begin();ihit != m_UniqueTargetInfo.end();++ihit) + if ((*ihit).missCondition == SPELL_MISS_NONE) // Add only hits + *data << uint64(ihit->targetGUID); + + for(std::list::iterator ighit= m_UniqueGOTargetInfo.begin();ighit != m_UniqueGOTargetInfo.end();++ighit) + *data << uint64(ighit->targetGUID); // Always hits + + *data << (uint8)m_countOfMiss; + for(std::list::iterator ihit= m_UniqueTargetInfo.begin();ihit != m_UniqueTargetInfo.end();++ihit) + { + if( ihit->missCondition != SPELL_MISS_NONE ) // Add only miss + { + *data << uint64(ihit->targetGUID); + *data << uint8(ihit->missCondition); + if( ihit->missCondition == SPELL_MISS_REFLECT ) + *data << uint8(ihit->reflectResult); + } + } +} + +void Spell::SendLogExecute() +{ + Unit *target = m_targets.getUnitTarget() ? m_targets.getUnitTarget() : m_caster; + + WorldPacket data(SMSG_SPELLLOGEXECUTE, (8+4+4+4+4+8)); + + if(m_caster->GetTypeId() == TYPEID_PLAYER) + data.append(m_caster->GetPackGUID()); + else + data.append(target->GetPackGUID()); + + data << uint32(m_spellInfo->Id); + uint32 count1 = 1; + data << uint32(count1); // count1 (effect count?) + for(uint32 i = 0; i < count1; ++i) + { + data << uint32(m_spellInfo->Effect[0]); // spell effect? + uint32 count2 = 1; + data << uint32(count2); // count2 (target count?) + for(uint32 j = 0; j < count2; ++j) + { + switch(m_spellInfo->Effect[0]) + { + case SPELL_EFFECT_POWER_DRAIN: + if(Unit *unit = m_targets.getUnitTarget()) + data.append(unit->GetPackGUID()); + else + data << uint8(0); + data << uint32(0); + data << uint32(0); + data << float(0); + break; + case SPELL_EFFECT_ADD_EXTRA_ATTACKS: + if(Unit *unit = m_targets.getUnitTarget()) + data.append(unit->GetPackGUID()); + else + data << uint8(0); + data << uint32(0); // count? + break; + case SPELL_EFFECT_INTERRUPT_CAST: + if(Unit *unit = m_targets.getUnitTarget()) + data.append(unit->GetPackGUID()); + else + data << uint8(0); + data << uint32(0); // spellid + break; + case SPELL_EFFECT_DURABILITY_DAMAGE: + if(Unit *unit = m_targets.getUnitTarget()) + data.append(unit->GetPackGUID()); + else + data << uint8(0); + data << uint32(0); + data << uint32(0); + break; + case SPELL_EFFECT_OPEN_LOCK: + case SPELL_EFFECT_OPEN_LOCK_ITEM: + if(Item *item = m_targets.getItemTarget()) + data.append(item->GetPackGUID()); + else + data << uint8(0); + break; + case SPELL_EFFECT_CREATE_ITEM: + data << uint32(m_spellInfo->EffectItemType[0]); + break; + case SPELL_EFFECT_SUMMON: + case SPELL_EFFECT_SUMMON_WILD: + case SPELL_EFFECT_SUMMON_GUARDIAN: + case SPELL_EFFECT_TRANS_DOOR: + case SPELL_EFFECT_SUMMON_PET: + case SPELL_EFFECT_SUMMON_POSSESSED: + case SPELL_EFFECT_SUMMON_TOTEM: + case SPELL_EFFECT_SUMMON_OBJECT_WILD: + case SPELL_EFFECT_CREATE_HOUSE: + case SPELL_EFFECT_DUEL: + case SPELL_EFFECT_SUMMON_TOTEM_SLOT1: + case SPELL_EFFECT_SUMMON_TOTEM_SLOT2: + case SPELL_EFFECT_SUMMON_TOTEM_SLOT3: + case SPELL_EFFECT_SUMMON_TOTEM_SLOT4: + case SPELL_EFFECT_SUMMON_PHANTASM: + case SPELL_EFFECT_SUMMON_CRITTER: + case SPELL_EFFECT_SUMMON_OBJECT_SLOT1: + case SPELL_EFFECT_SUMMON_OBJECT_SLOT2: + case SPELL_EFFECT_SUMMON_OBJECT_SLOT3: + case SPELL_EFFECT_SUMMON_OBJECT_SLOT4: + case SPELL_EFFECT_SUMMON_DEMON: + case SPELL_EFFECT_150: + if(Unit *unit = m_targets.getUnitTarget()) + data.append(unit->GetPackGUID()); + else if(m_targets.getItemTargetGUID()) + data.appendPackGUID(m_targets.getItemTargetGUID()); + else if(GameObject *go = m_targets.getGOTarget()) + data.append(go->GetPackGUID()); + else + data << uint8(0); // guid + break; + case SPELL_EFFECT_FEED_PET: + data << uint32(m_targets.getItemTargetEntry()); + break; + case SPELL_EFFECT_DISMISS_PET: + if(Unit *unit = m_targets.getUnitTarget()) + data.append(unit->GetPackGUID()); + else + data << uint8(0); + break; + default: + return; + } + } + } + + m_caster->SendMessageToSet(&data, true); +} + +void Spell::SendInterrupted(uint8 result) +{ + WorldPacket data(SMSG_SPELL_FAILURE, (8+4+1)); + data.append(m_caster->GetPackGUID()); + data << m_spellInfo->Id; + data << result; + m_caster->SendMessageToSet(&data, true); + + data.Initialize(SMSG_SPELL_FAILED_OTHER, (8+4)); + data.append(m_caster->GetPackGUID()); + data << m_spellInfo->Id; + m_caster->SendMessageToSet(&data, true); +} + +void Spell::SendChannelUpdate(uint32 time) +{ + if(time == 0) + { + m_caster->SetUInt64Value(UNIT_FIELD_CHANNEL_OBJECT,0); + m_caster->SetUInt32Value(UNIT_CHANNEL_SPELL,0); + } + + if (m_caster->GetTypeId() != TYPEID_PLAYER) + return; + + WorldPacket data( MSG_CHANNEL_UPDATE, 8+4 ); + data.append(m_caster->GetPackGUID()); + data << time; + + ((Player*)m_caster)->GetSession()->SendPacket( &data ); +} + +void Spell::SendChannelStart(uint32 duration) +{ + WorldObject* target = NULL; + + // select first not rsusted target from target list for _0_ effect + if(!m_UniqueTargetInfo.empty()) + { + for(std::list::iterator itr= m_UniqueTargetInfo.begin();itr != m_UniqueTargetInfo.end();++itr) + { + if( (itr->effectMask & (1<<0)) && itr->reflectResult==SPELL_MISS_NONE && itr->targetGUID != m_caster->GetGUID()) + { + target = ObjectAccessor::GetUnit(*m_caster, itr->targetGUID); + break; + } + } + } + else if(!m_UniqueGOTargetInfo.empty()) + { + for(std::list::iterator itr= m_UniqueGOTargetInfo.begin();itr != m_UniqueGOTargetInfo.end();++itr) + { + if(itr->effectMask & (1<<0) ) + { + target = ObjectAccessor::GetGameObject(*m_caster, itr->targetGUID); + break; + } + } + } + + if (m_caster->GetTypeId() == TYPEID_PLAYER) + { + WorldPacket data( MSG_CHANNEL_START, (8+4+4) ); + data.append(m_caster->GetPackGUID()); + data << m_spellInfo->Id; + data << duration; + + ((Player*)m_caster)->GetSession()->SendPacket( &data ); + } + + m_timer = duration; + if(target) + m_caster->SetUInt64Value(UNIT_FIELD_CHANNEL_OBJECT, target->GetGUID()); + m_caster->SetUInt32Value(UNIT_CHANNEL_SPELL, m_spellInfo->Id); +} + +void Spell::SendResurrectRequest(Player* target) +{ + WorldPacket data(SMSG_RESURRECT_REQUEST, (8+4+2+4)); + data << m_caster->GetGUID(); + data << uint32(1) << uint16(0) << uint32(1); + + target->GetSession()->SendPacket(&data); +} + +void Spell::SendPlaySpellVisual(uint32 SpellID) +{ + if (m_caster->GetTypeId() != TYPEID_PLAYER) + return; + + WorldPacket data(SMSG_PLAY_SPELL_VISUAL, 12); + data << m_caster->GetGUID(); + data << SpellID; + ((Player*)m_caster)->GetSession()->SendPacket(&data); +} + +void Spell::TakeCastItem() +{ + if(!m_CastItem || m_caster->GetTypeId() != TYPEID_PLAYER) + return; + + // not remove cast item at triggered spell (equipping, weapon damage, etc) + if(m_IsTriggeredSpell) + return; + + ItemPrototype const *proto = m_CastItem->GetProto(); + + if(!proto) + { + // This code is to avoid a crash + // I'm not sure, if this is really an error, but I guess every item needs a prototype + sLog.outError("Cast item has no item prototype highId=%d, lowId=%d",m_CastItem->GetGUIDHigh(), m_CastItem->GetGUIDLow()); + return; + } + + bool expendable = false; + bool withoutCharges = false; + + for (int i = 0; i<5; i++) + { + if (proto->Spells[i].SpellId) + { + // item has limited charges + if (proto->Spells[i].SpellCharges) + { + if (proto->Spells[i].SpellCharges < 0) + expendable = true; + + int32 charges = m_CastItem->GetSpellCharges(i); + + // item has charges left + if (charges) + { + (charges > 0) ? --charges : ++charges; // abs(charges) less at 1 after use + if (proto->Stackable < 2) + m_CastItem->SetSpellCharges(i, charges); + m_CastItem->SetState(ITEM_CHANGED, (Player*)m_caster); + } + + // all charges used + withoutCharges = (charges == 0); + } + } + } + + if (expendable && withoutCharges) + { + uint32 count = 1; + ((Player*)m_caster)->DestroyItemCount(m_CastItem, count, true); + + // prevent crash at access to deleted m_targets.getItemTarget + if(m_CastItem==m_targets.getItemTarget()) + m_targets.setItemTarget(NULL); + + m_CastItem = NULL; + } +} + +void Spell::TakePower() +{ + if(m_CastItem || m_triggeredByAuraSpell) + return; + + // health as power used + if(m_spellInfo->powerType == POWER_HEALTH) + { + m_caster->ModifyHealth( -(int32)m_powerCost ); + return; + } + + if(m_spellInfo->powerType >= MAX_POWERS) + { + sLog.outError("Spell::TakePower: Unknown power type '%d'", m_spellInfo->powerType); + return; + } + + Powers powerType = Powers(m_spellInfo->powerType); + + m_caster->ModifyPower(powerType, -(int32)m_powerCost); + + // Set the five second timer + if (powerType == POWER_MANA && m_powerCost > 0) + m_caster->SetLastManaUse(getMSTime()); +} + +void Spell::TakeReagents() +{ + if(m_IsTriggeredSpell) // reagents used in triggered spell removed by original spell or don't must be removed. + return; + + if (m_caster->GetTypeId() != TYPEID_PLAYER) + return; + + if (m_spellInfo->AttributesEx5 & SPELL_ATTR_EX5_NO_REAGENT_WHILE_PREP && + m_caster->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PREPARATION)) + return; + + Player* p_caster = (Player*)m_caster; + + for(uint32 x=0;x<8;x++) + { + if(m_spellInfo->Reagent[x] <= 0) + continue; + + uint32 itemid = m_spellInfo->Reagent[x]; + uint32 itemcount = m_spellInfo->ReagentCount[x]; + + // if CastItem is also spell reagent + if (m_CastItem) + { + ItemPrototype const *proto = m_CastItem->GetProto(); + if( proto && proto->ItemId == itemid ) + { + for(int s=0;s<5;s++) + { + // CastItem will be used up and does not count as reagent + int32 charges = m_CastItem->GetSpellCharges(s); + if (proto->Spells[s].SpellCharges < 0 && abs(charges) < 2) + { + ++itemcount; + break; + } + } + + m_CastItem = NULL; + } + } + + // if getItemTarget is also spell reagent + if (m_targets.getItemTargetEntry()==itemid) + m_targets.setItemTarget(NULL); + + p_caster->DestroyItemCount(itemid, itemcount, true); + } +} + +void Spell::HandleThreatSpells(uint32 spellId) +{ + if(!m_targets.getUnitTarget() || !spellId) + return; + + if(!m_targets.getUnitTarget()->CanHaveThreatList()) + return; + + SpellThreatEntry const *threatSpell = sSpellThreatStore.LookupEntry(spellId); + if(!threatSpell) + return; + + m_targets.getUnitTarget()->AddThreat(m_caster, float(threatSpell->threat)); + + DEBUG_LOG("Spell %u, rank %u, added an additional %i threat", spellId, spellmgr.GetSpellRank(spellId), threatSpell->threat); +} + +void Spell::HandleEffects(Unit *pUnitTarget,Item *pItemTarget,GameObject *pGOTarget,uint32 i, float DamageMultiplier) +{ + unitTarget = pUnitTarget; + itemTarget = pItemTarget; + gameObjTarget = pGOTarget; + + uint8 eff = m_spellInfo->Effect[i]; + uint32 mechanic = m_spellInfo->EffectMechanic[i]; + + damage = int32(CalculateDamage((uint8)i,unitTarget)*DamageMultiplier); + + sLog.outDebug( "Spell: Effect : %u", eff); + + //Simply return. Do not display "immune" in red text on client + if(unitTarget && unitTarget->IsImmunedToSpellEffect(eff, mechanic)) + return; + + if(eff TOTAL_SPELL_EFFECTS ", eff); + if (m_CastItem) + EffectEnchantItemTmp(i); + else + { + sLog.outError("SPELL: unknown effect %u spell id %u\n", + eff, m_spellInfo->Id); + } + } + */ +} + +void Spell::TriggerSpell() +{ + for(TriggerSpells::iterator si=m_TriggerSpells.begin(); si!=m_TriggerSpells.end(); ++si) + { + Spell* spell = new Spell(m_caster, (*si), true, m_originalCasterGUID, this->m_selfContainer); + spell->prepare(&m_targets); // use original spell original targets + } +} + +uint8 Spell::CanCast(bool strict) +{ + // check cooldowns to prevent cheating + if(m_caster->GetTypeId()==TYPEID_PLAYER && ((Player*)m_caster)->HasSpellCooldown(m_spellInfo->Id)) + { + if(m_triggeredByAuraSpell) + return SPELL_FAILED_DONT_REPORT; + else + return SPELL_FAILED_NOT_READY; + } + + // only allow triggered spells if at an ended battleground + if( !m_IsTriggeredSpell && m_caster->GetTypeId() == TYPEID_PLAYER) + if(BattleGround * bg = ((Player*)m_caster)->GetBattleGround()) + if(bg->GetStatus() == STATUS_WAIT_LEAVE) + return SPELL_FAILED_DONT_REPORT; + + // only check at first call, Stealth auras are already removed at second call + // for now, ignore triggered spells + if( strict && !m_IsTriggeredSpell) + { + // Cannot be used in this stance/form + if(uint8 shapeError = GetErrorAtShapeshiftedCast(m_spellInfo, m_caster->m_form)) + return shapeError; + + if ((m_spellInfo->Attributes & SPELL_ATTR_ONLY_STEALTHED) && !(m_caster->HasStealthAura())) + return SPELL_FAILED_ONLY_STEALTHED; + } + + // caster state requirements + if(m_spellInfo->CasterAuraState && !m_caster->HasAuraState(AuraState(m_spellInfo->CasterAuraState))) + return SPELL_FAILED_CASTER_AURASTATE; + if(m_spellInfo->CasterAuraStateNot && m_caster->HasAuraState(AuraState(m_spellInfo->CasterAuraStateNot))) + return SPELL_FAILED_CASTER_AURASTATE; + + // cancel autorepeat spells if cast start when moving + // (not wand currently autorepeat cast delayed to moving stop anyway in spell update code) + if( m_caster->GetTypeId()==TYPEID_PLAYER && ((Player*)m_caster)->isMoving() ) + { + // skip stuck spell to allow use it in falling case and apply spell limitations at movement + if( (!m_caster->HasUnitMovementFlag(MOVEMENTFLAG_FALLING) || m_spellInfo->Effect[0] != SPELL_EFFECT_STUCK) && + (IsAutoRepeat() || (m_spellInfo->AuraInterruptFlags & AURA_INTERRUPT_FLAG_NOT_SEATED) != 0) ) + return SPELL_FAILED_MOVING; + } + + Unit *target = m_targets.getUnitTarget(); + + if(target) + { + // target state requirements (not allowed state), apply to self also + if(m_spellInfo->TargetAuraStateNot && target->HasAuraState(AuraState(m_spellInfo->TargetAuraStateNot))) + return SPELL_FAILED_TARGET_AURASTATE; + + + if(target != m_caster) + { + // target state requirements (apply to non-self only), to allow cast affects to self like Dirty Deeds + if(m_spellInfo->TargetAuraState && !target->HasAuraState(AuraState(m_spellInfo->TargetAuraState))) + return SPELL_FAILED_TARGET_AURASTATE; + + // Not allow casting on flying player + if (target->isInFlight()) + return SPELL_FAILED_BAD_TARGETS; + + if(VMAP::VMapFactory::checkSpellForLoS(m_spellInfo->Id) && !m_caster->IsWithinLOSInMap(target)) + return SPELL_FAILED_LINE_OF_SIGHT; + + // auto selection spell rank implemented in WorldSession::HandleCastSpellOpcode + // this case can be triggered if rank not found (too low-level target for first rank) + if(m_caster->GetTypeId() == TYPEID_PLAYER && !IsPassiveSpell(m_spellInfo->Id) && !m_CastItem) + { + for(int i=0;i<3;i++) + { + if(IsPositiveEffect(m_spellInfo->Id, i) && m_spellInfo->Effect[i] == SPELL_EFFECT_APPLY_AURA) + if(target->getLevel() + 10 < m_spellInfo->spellLevel) + return SPELL_FAILED_LOWLEVEL; + } + } + } + + // check pet presents + for(int j=0;j<3;j++) + { + if(m_spellInfo->EffectImplicitTargetA[j] == TARGET_PET) + { + target = m_caster->GetPet(); + if(!target) + { + if(m_triggeredByAuraSpell) // not report pet not existence for triggered spells + return SPELL_FAILED_DONT_REPORT; + else + return SPELL_FAILED_NO_PET; + } + break; + } + } + + //check creature type + //ignore self casts (including area casts when caster selected as target) + if(target != m_caster) + { + if(!CheckTargetCreatureType(target)) + { + if(target->GetTypeId()==TYPEID_PLAYER) + return SPELL_FAILED_TARGET_IS_PLAYER; + else + return SPELL_FAILED_BAD_TARGETS; + } + } + + // TODO: this check can be applied and for player to prevent cheating when IsPositiveSpell will return always correct result. + // check target for pet/charmed casts (not self targeted), self targeted cast used for area effects and etc + if(m_caster != target && m_caster->GetTypeId()==TYPEID_UNIT && m_caster->GetCharmerOrOwnerGUID()) + { + // check correctness positive/negative cast target (pet cast real check and cheating check) + if(IsPositiveSpell(m_spellInfo->Id)) + { + if(m_caster->IsHostileTo(target)) + return SPELL_FAILED_BAD_TARGETS; + } + else + { + if(m_caster->IsFriendlyTo(target)) + return SPELL_FAILED_BAD_TARGETS; + } + } + + if(IsPositiveSpell(m_spellInfo->Id)) + { + if(target->IsImmunedToSpell(m_spellInfo,false)) + return SPELL_FAILED_TARGET_AURASTATE; + } + + //Must be behind the target. + if( m_spellInfo->AttributesEx2 == 0x100000 && (m_spellInfo->AttributesEx & 0x200) == 0x200 && target->HasInArc(M_PI, m_caster) ) + { + SendInterrupted(2); + return SPELL_FAILED_NOT_BEHIND; + } + + //Target must be facing you. + if((m_spellInfo->Attributes == 0x150010) && !target->HasInArc(M_PI, m_caster) ) + { + SendInterrupted(2); + return SPELL_FAILED_NOT_INFRONT; + } + + // check if target is in combat + if (target != m_caster && (m_spellInfo->AttributesEx & SPELL_ATTR_EX_NOT_IN_COMBAT_TARGET) && target->isInCombat()) + { + return SPELL_FAILED_TARGET_AFFECTING_COMBAT; + } + } + // Spell casted only on battleground + if((m_spellInfo->AttributesEx3 & SPELL_ATTR_EX3_BATTLEGROUND) && m_caster->GetTypeId()==TYPEID_PLAYER) + if(!((Player*)m_caster)->InBattleGround()) + return SPELL_FAILED_ONLY_BATTLEGROUNDS; + + // do not allow spells to be cast in arenas + // - with greater than 15 min CD without SPELL_ATTR_EX4_USABLE_IN_ARENA flag + // - with SPELL_ATTR_EX4_NOT_USABLE_IN_ARENA flag + if( (m_spellInfo->AttributesEx4 & SPELL_ATTR_EX4_NOT_USABLE_IN_ARENA) || + GetSpellRecoveryTime(m_spellInfo) > 15 * MINUTE * 1000 && !(m_spellInfo->AttributesEx4 & SPELL_ATTR_EX4_USABLE_IN_ARENA) ) + if(MapEntry const* mapEntry = sMapStore.LookupEntry(m_caster->GetMapId())) + if(mapEntry->IsBattleArena()) + return SPELL_FAILED_NOT_IN_ARENA; + + // zone check + if(!IsSpellAllowedInLocation(m_spellInfo,m_caster->GetMapId(),m_caster->GetZoneId(),m_caster->GetAreaId())) + return SPELL_FAILED_REQUIRES_AREA; + + // not let players cast spells at mount (and let do it to creatures) + if( m_caster->IsMounted() && m_caster->GetTypeId()==TYPEID_PLAYER && !m_IsTriggeredSpell && + !IsPassiveSpell(m_spellInfo->Id) && !(m_spellInfo->Attributes & SPELL_ATTR_CASTABLE_WHILE_MOUNTED) ) + { + if(m_caster->isInFlight()) + return SPELL_FAILED_NOT_FLYING; + else + return SPELL_FAILED_NOT_MOUNTED; + } + + // always (except passive spells) check items (focus object can be required for any type casts) + if(!IsPassiveSpell(m_spellInfo->Id)) + if(uint8 castResult = CheckItems()) + return castResult; + + //ImpliciteTargetA-B = 38, If fact there is 0 Spell with ImpliciteTargetB=38 + if(m_UniqueTargetInfo.empty()) // skip second canCast apply (for delayed spells for example) + { + for(uint8 j = 0; j < 3; j++) + { + if( m_spellInfo->EffectImplicitTargetA[j] == TARGET_SCRIPT || + m_spellInfo->EffectImplicitTargetB[j] == TARGET_SCRIPT && m_spellInfo->EffectImplicitTargetA[j] != TARGET_SELF || + m_spellInfo->EffectImplicitTargetA[j] == TARGET_SCRIPT_COORDINATES || + m_spellInfo->EffectImplicitTargetB[j] == TARGET_SCRIPT_COORDINATES ) + { + bool okDoo = false; + + SpellScriptTarget::const_iterator lower = spellmgr.GetBeginSpellScriptTarget(m_spellInfo->Id); + SpellScriptTarget::const_iterator upper = spellmgr.GetEndSpellScriptTarget(m_spellInfo->Id); + if(lower==upper) + sLog.outErrorDb("Spell (ID: %u) has effect EffectImplicitTargetA/EffectImplicitTargetB = TARGET_SCRIPT or TARGET_SCRIPT_COORDINATES, but does not have record in `spell_script_target`",m_spellInfo->Id); + + SpellRangeEntry const* srange = sSpellRangeStore.LookupEntry(m_spellInfo->rangeIndex); + float range = GetSpellMaxRange(srange); + + Creature* creatureScriptTarget = NULL; + GameObject* goScriptTarget = NULL; + + for(SpellScriptTarget::const_iterator i_spellST = lower; i_spellST != upper; ++i_spellST) + { + switch(i_spellST->second.type) + { + case SPELL_TARGET_TYPE_GAMEOBJECT: + { + GameObject* p_GameObject = NULL; + + if(i_spellST->second.targetEntry) + { + CellPair p(MaNGOS::ComputeCellPair(m_caster->GetPositionX(), m_caster->GetPositionY())); + Cell cell(p); + cell.data.Part.reserved = ALL_DISTRICT; + + MaNGOS::NearestGameObjectEntryInObjectRangeCheck go_check(*m_caster,i_spellST->second.targetEntry,range); + MaNGOS::GameObjectLastSearcher checker(p_GameObject,go_check); + + TypeContainerVisitor, GridTypeMapContainer > object_checker(checker); + CellLock cell_lock(cell, p); + cell_lock->Visit(cell_lock, object_checker, *MapManager::Instance().GetMap(m_caster->GetMapId(), m_caster)); + + if(p_GameObject) + { + // remember found target and range, next attempt will find more near target with another entry + creatureScriptTarget = NULL; + goScriptTarget = p_GameObject; + range = go_check.GetLastRange(); + } + } + else if( focusObject ) //Focus Object + { + float frange = m_caster->GetDistance(focusObject); + if(range >= frange) + { + creatureScriptTarget = NULL; + goScriptTarget = focusObject; + range = frange; + } + } + break; + } + case SPELL_TARGET_TYPE_CREATURE: + case SPELL_TARGET_TYPE_DEAD: + default: + { + Creature *p_Creature = NULL; + + CellPair p(MaNGOS::ComputeCellPair(m_caster->GetPositionX(), m_caster->GetPositionY())); + Cell cell(p); + cell.data.Part.reserved = ALL_DISTRICT; + cell.SetNoCreate(); // Really don't know what is that??? + + MaNGOS::NearestCreatureEntryWithLiveStateInObjectRangeCheck u_check(*m_caster,i_spellST->second.targetEntry,i_spellST->second.type!=SPELL_TARGET_TYPE_DEAD,range); + MaNGOS::CreatureLastSearcher searcher(p_Creature, u_check); + + TypeContainerVisitor, GridTypeMapContainer > grid_creature_searcher(searcher); + + CellLock cell_lock(cell, p); + cell_lock->Visit(cell_lock, grid_creature_searcher, *MapManager::Instance().GetMap(m_caster->GetMapId(), m_caster)); + + if(p_Creature ) + { + creatureScriptTarget = p_Creature; + goScriptTarget = NULL; + range = u_check.GetLastRange(); + } + break; + } + } + } + + if(creatureScriptTarget) + { + // store coordinates for TARGET_SCRIPT_COORDINATES + if (m_spellInfo->EffectImplicitTargetA[j] == TARGET_SCRIPT_COORDINATES || + m_spellInfo->EffectImplicitTargetB[j] == TARGET_SCRIPT_COORDINATES ) + { + m_targets.setDestination(creatureScriptTarget->GetPositionX(),creatureScriptTarget->GetPositionY(),creatureScriptTarget->GetPositionZ()); + + if(m_spellInfo->EffectImplicitTargetA[j] == TARGET_SCRIPT_COORDINATES && m_spellInfo->EffectImplicitTargetB[j] == 0 && m_spellInfo->Effect[j]!=SPELL_EFFECT_PERSISTENT_AREA_AURA) + AddUnitTarget(creatureScriptTarget, j); + } + // store explicit target for TARGET_SCRIPT + else + AddUnitTarget(creatureScriptTarget, j); + } + else if(goScriptTarget) + { + // store coordinates for TARGET_SCRIPT_COORDINATES + if (m_spellInfo->EffectImplicitTargetA[j] == TARGET_SCRIPT_COORDINATES || + m_spellInfo->EffectImplicitTargetB[j] == TARGET_SCRIPT_COORDINATES ) + { + m_targets.setDestination(goScriptTarget->GetPositionX(),goScriptTarget->GetPositionY(),goScriptTarget->GetPositionZ()); + + if(m_spellInfo->EffectImplicitTargetA[j] == TARGET_SCRIPT_COORDINATES && m_spellInfo->EffectImplicitTargetB[j] == 0 && m_spellInfo->Effect[j]!=SPELL_EFFECT_PERSISTENT_AREA_AURA) + AddGOTarget(goScriptTarget, j); + } + // store explicit target for TARGET_SCRIPT + else + AddGOTarget(goScriptTarget, j); + } + //Missing DB Entry or targets for this spellEffect. + else + { + // not report target not existence for triggered spells + if(m_triggeredByAuraSpell || m_IsTriggeredSpell) + return SPELL_FAILED_DONT_REPORT; + else + return SPELL_FAILED_BAD_TARGETS; + } + } + } + } + + if(uint8 castResult = CheckRange(strict)) + return castResult; + + { + if(uint8 castResult = CheckPower()) + return castResult; + } + + if(!m_triggeredByAuraSpell) // triggered spell not affected by stun/etc + if(uint8 castResult = CheckCasterAuras()) + return castResult; + + for (int i = 0; i < 3; i++) + { + // for effects of spells that have only one target + switch(m_spellInfo->Effect[i]) + { + case SPELL_EFFECT_DUMMY: + { + if(m_spellInfo->SpellIconID == 1648) // Execute + { + if(!m_targets.getUnitTarget() || m_targets.getUnitTarget()->GetHealth() > m_targets.getUnitTarget()->GetMaxHealth()*0.2) + return SPELL_FAILED_BAD_TARGETS; + } + else if (m_spellInfo->Id == 51582) // Rocket Boots Engaged + { + if(m_caster->IsInWater()) + return SPELL_FAILED_ONLY_ABOVEWATER; + } + else if(m_spellInfo->SpellIconID==156) // Holy Shock + { + // spell different for friends and enemies + // hart version required facing + if(m_targets.getUnitTarget() && !m_caster->IsFriendlyTo(m_targets.getUnitTarget()) && !m_caster->HasInArc( M_PI, target )) + return SPELL_FAILED_UNIT_NOT_INFRONT; + } + break; + } + case SPELL_EFFECT_SCHOOL_DAMAGE: + { + // Hammer of Wrath + if(m_spellInfo->SpellVisual == 7250) + { + if (!m_targets.getUnitTarget()) + return SPELL_FAILED_BAD_IMPLICIT_TARGETS; + + if(m_targets.getUnitTarget()->GetHealth() > m_targets.getUnitTarget()->GetMaxHealth()*0.2) + return SPELL_FAILED_BAD_TARGETS; + } + break; + } + case SPELL_EFFECT_TAMECREATURE: + { + if (!m_targets.getUnitTarget() || m_targets.getUnitTarget()->GetTypeId() == TYPEID_PLAYER) + return SPELL_FAILED_BAD_IMPLICIT_TARGETS; + + if (m_targets.getUnitTarget()->getLevel() > m_caster->getLevel()) + return SPELL_FAILED_HIGHLEVEL; + + CreatureInfo const *cinfo = ((Creature*)m_targets.getUnitTarget())->GetCreatureInfo(); + if( cinfo->type != CREATURE_TYPE_BEAST ) + return SPELL_FAILED_BAD_TARGETS; + + // use SMSG_PET_TAME_FAILURE? + if( !(cinfo->flag1 & 1) || !(cinfo->family) ) + return SPELL_FAILED_BAD_TARGETS; + + if(m_caster->GetPetGUID()) + return SPELL_FAILED_ALREADY_HAVE_SUMMON; + + if(m_caster->GetCharmGUID()) + return SPELL_FAILED_ALREADY_HAVE_CHARM; + + break; + } + case SPELL_EFFECT_LEARN_SPELL: + { + if(m_spellInfo->EffectImplicitTargetA[i] != TARGET_PET) + break; + + Pet* pet = m_caster->GetPet(); + + if(!pet) + return SPELL_FAILED_NO_PET; + + SpellEntry const *learn_spellproto = sSpellStore.LookupEntry(m_spellInfo->EffectTriggerSpell[i]); + + if(!learn_spellproto) + return SPELL_FAILED_NOT_KNOWN; + + if(!pet->CanTakeMoreActiveSpells(learn_spellproto->Id)) + return SPELL_FAILED_TOO_MANY_SKILLS; + + if(m_spellInfo->spellLevel > pet->getLevel()) + return SPELL_FAILED_LOWLEVEL; + + if(!pet->HasTPForSpell(learn_spellproto->Id)) + return SPELL_FAILED_TRAINING_POINTS; + + break; + } + case SPELL_EFFECT_LEARN_PET_SPELL: + { + Pet* pet = m_caster->GetPet(); + + if(!pet) + return SPELL_FAILED_NO_PET; + + SpellEntry const *learn_spellproto = sSpellStore.LookupEntry(m_spellInfo->EffectTriggerSpell[i]); + + if(!learn_spellproto) + return SPELL_FAILED_NOT_KNOWN; + + if(!pet->CanTakeMoreActiveSpells(learn_spellproto->Id)) + return SPELL_FAILED_TOO_MANY_SKILLS; + + if(m_spellInfo->spellLevel > pet->getLevel()) + return SPELL_FAILED_LOWLEVEL; + + if(!pet->HasTPForSpell(learn_spellproto->Id)) + return SPELL_FAILED_TRAINING_POINTS; + + break; + } + case SPELL_EFFECT_FEED_PET: + { + if (m_caster->GetTypeId() != TYPEID_PLAYER || !m_targets.getItemTarget() ) + return SPELL_FAILED_BAD_TARGETS; + + Pet* pet = m_caster->GetPet(); + + if(!pet) + return SPELL_FAILED_NO_PET; + + if(!pet->HaveInDiet(m_targets.getItemTarget()->GetProto())) + return SPELL_FAILED_WRONG_PET_FOOD; + + if(!pet->GetCurrentFoodBenefitLevel(m_targets.getItemTarget()->GetProto()->ItemLevel)) + return SPELL_FAILED_FOOD_LOWLEVEL; + + if(m_caster->isInCombat() || pet->isInCombat()) + return SPELL_FAILED_AFFECTING_COMBAT; + + break; + } + case SPELL_EFFECT_POWER_BURN: + case SPELL_EFFECT_POWER_DRAIN: + { + // Can be area effect, Check only for players and not check if target - caster (spell can have multiply drain/burn effects) + if(m_caster->GetTypeId() == TYPEID_PLAYER) + if(Unit* target = m_targets.getUnitTarget()) + if(target!=m_caster && target->getPowerType()!=m_spellInfo->EffectMiscValue[i]) + return SPELL_FAILED_BAD_TARGETS; + break; + } + case SPELL_EFFECT_CHARGE: + { + if (m_caster->hasUnitState(UNIT_STAT_ROOT)) + return SPELL_FAILED_ROOTED; + + break; + } + case SPELL_EFFECT_SKINNING: + { + if (m_caster->GetTypeId() != TYPEID_PLAYER || !m_targets.getUnitTarget() || m_targets.getUnitTarget()->GetTypeId() != TYPEID_UNIT) + return SPELL_FAILED_BAD_TARGETS; + + if( !(m_targets.getUnitTarget()->GetUInt32Value(UNIT_FIELD_FLAGS) & UNIT_FLAG_SKINNABLE) ) + return SPELL_FAILED_TARGET_UNSKINNABLE; + + Creature* creature = (Creature*)m_targets.getUnitTarget(); + if ( creature->GetCreatureType() != CREATURE_TYPE_CRITTER && ( !creature->lootForBody || !creature->loot.empty() ) ) + { + return SPELL_FAILED_TARGET_NOT_LOOTED; + } + + uint32 skill; + if(creature->GetCreatureInfo()->flag1 & 256) + skill = SKILL_HERBALISM; // special case + else if(creature->GetCreatureInfo()->flag1 & 512) + skill = SKILL_MINING; // special case + else + skill = SKILL_SKINNING; // normal case + + int32 skillValue = ((Player*)m_caster)->GetSkillValue(skill); + int32 TargetLevel = m_targets.getUnitTarget()->getLevel(); + int32 ReqValue = (skillValue < 100 ? (TargetLevel-10)*10 : TargetLevel*5); + if (ReqValue > skillValue) + return SPELL_FAILED_LOW_CASTLEVEL; + + // chance for fail at orange skinning attempt + if( (m_selfContainer && (*m_selfContainer) == this) && + skillValue < sWorld.GetConfigMaxSkillValue() && + (ReqValue < 0 ? 0 : ReqValue) > irand(skillValue-25, skillValue+37) ) + return SPELL_FAILED_TRY_AGAIN; + + break; + } + case SPELL_EFFECT_OPEN_LOCK_ITEM: + case SPELL_EFFECT_OPEN_LOCK: + { + if( m_spellInfo->EffectImplicitTargetA[i] != TARGET_GAMEOBJECT && + m_spellInfo->EffectImplicitTargetA[i] != TARGET_GAMEOBJECT_ITEM ) + break; + + if( m_caster->GetTypeId() != TYPEID_PLAYER // only players can open locks, gather etc. + // we need a go target in case of TARGET_GAMEOBJECT + || m_spellInfo->EffectImplicitTargetA[i] == TARGET_GAMEOBJECT && !m_targets.getGOTarget() + // we need a go target, or an openable item target in case of TARGET_GAMEOBJECT_ITEM + || m_spellInfo->EffectImplicitTargetA[i] == TARGET_GAMEOBJECT_ITEM && !m_targets.getGOTarget() && + (!m_targets.getItemTarget() || !m_targets.getItemTarget()->GetProto()->LockID || m_targets.getItemTarget()->GetOwner() != m_caster ) ) + return SPELL_FAILED_BAD_TARGETS; + + // get the lock entry + LockEntry const *lockInfo = NULL; + if (GameObject* go=m_targets.getGOTarget()) + lockInfo = sLockStore.LookupEntry(go->GetLockId()); + else if(Item* itm=m_targets.getItemTarget()) + lockInfo = sLockStore.LookupEntry(itm->GetProto()->LockID); + + // check lock compatibility + if (lockInfo) + { + // check for lock - key pair (checked by client also, just prevent cheating + bool ok_key = false; + for(int it = 0; it < 5; ++it) + { + switch(lockInfo->keytype[it]) + { + case LOCK_KEY_NONE: + break; + case LOCK_KEY_ITEM: + { + if(lockInfo->key[it]) + { + if(m_CastItem && m_CastItem->GetEntry()==lockInfo->key[it]) + ok_key =true; + break; + } + } + case LOCK_KEY_SKILL: + { + if(uint32(m_spellInfo->EffectMiscValue[i])!=lockInfo->key[it]) + break; + + switch(lockInfo->key[it]) + { + case LOCKTYPE_HERBALISM: + if(((Player*)m_caster)->HasSkill(SKILL_HERBALISM)) + ok_key =true; + break; + case LOCKTYPE_MINING: + if(((Player*)m_caster)->HasSkill(SKILL_MINING)) + ok_key =true; + break; + default: + ok_key =true; + break; + } + } + } + if(ok_key) + break; + } + + if(!ok_key) + return SPELL_FAILED_BAD_TARGETS; + } + + // chance for fail at orange mining/herb/LockPicking gathering attempt + if (!m_selfContainer || ((*m_selfContainer) != this)) + break; + + // get the skill value of the player + int32 SkillValue = 0; + bool canFailAtMax = true; + if (m_spellInfo->EffectMiscValue[i] == LOCKTYPE_HERBALISM) + { + SkillValue = ((Player*)m_caster)->GetSkillValue(SKILL_HERBALISM); + canFailAtMax = false; + } + else if (m_spellInfo->EffectMiscValue[i] == LOCKTYPE_MINING) + { + SkillValue = ((Player*)m_caster)->GetSkillValue(SKILL_MINING); + canFailAtMax = false; + } + else if (m_spellInfo->EffectMiscValue[i] == LOCKTYPE_PICKLOCK) + SkillValue = ((Player*)m_caster)->GetSkillValue(SKILL_LOCKPICKING); + + // castitem check: rogue using skeleton keys. the skill values should not be added in this case. + if(m_CastItem) + SkillValue = 0; + + // add the damage modifier from the spell casted (cheat lock / skeleton key etc.) (use m_currentBasePoints, CalculateDamage returns wrong value) + SkillValue += m_currentBasePoints[i]+1; + + // get the required lock value + int32 ReqValue=0; + if (lockInfo) + { + // check for lock - key pair + bool ok = false; + for(int it = 0; it < 5; ++it) + { + if(lockInfo->keytype[it]==LOCK_KEY_ITEM && lockInfo->key[it] && m_CastItem && m_CastItem->GetEntry()==lockInfo->key[it]) + { + // if so, we're good to go + ok = true; + break; + } + } + if(ok) + break; + + if (m_spellInfo->EffectMiscValue[i] == LOCKTYPE_PICKLOCK) + ReqValue = lockInfo->requiredlockskill; + else + ReqValue = lockInfo->requiredminingskill; + } + + // skill doesn't meet the required value + if (ReqValue > SkillValue) + return SPELL_FAILED_LOW_CASTLEVEL; + + // chance for failure in orange gather / lockpick (gathering skill can't fail at maxskill) + if((canFailAtMax || SkillValue < sWorld.GetConfigMaxSkillValue()) && ReqValue > irand(SkillValue-25, SkillValue+37)) + return SPELL_FAILED_TRY_AGAIN; + + break; + } + case SPELL_EFFECT_SUMMON_DEAD_PET: + { + Creature *pet = m_caster->GetPet(); + if(!pet) + return SPELL_FAILED_NO_PET; + + if(pet->isAlive()) + return SPELL_FAILED_ALREADY_HAVE_SUMMON; + + break; + } + // This is generic summon effect now and don't make this check for summon types similar + // SPELL_EFFECT_SUMMON_CRITTER, SPELL_EFFECT_SUMMON_WILD or SPELL_EFFECT_SUMMON_GUARDIAN. + // These won't show up in m_caster->GetPetGUID() + case SPELL_EFFECT_SUMMON: + { + switch(m_spellInfo->EffectMiscValueB[i]) + { + case SUMMON_TYPE_POSESSED: + case SUMMON_TYPE_POSESSED2: + case SUMMON_TYPE_DEMON: + case SUMMON_TYPE_SUMMON: + { + if(m_caster->GetPetGUID()) + return SPELL_FAILED_ALREADY_HAVE_SUMMON; + + if(m_caster->GetCharmGUID()) + return SPELL_FAILED_ALREADY_HAVE_CHARM; + break; + } + } + break; + } + // Don't make this check for SPELL_EFFECT_SUMMON_CRITTER, SPELL_EFFECT_SUMMON_WILD or SPELL_EFFECT_SUMMON_GUARDIAN. + // These won't show up in m_caster->GetPetGUID() + case SPELL_EFFECT_SUMMON_POSSESSED: + case SPELL_EFFECT_SUMMON_PHANTASM: + case SPELL_EFFECT_SUMMON_DEMON: + { + if(m_caster->GetPetGUID()) + return SPELL_FAILED_ALREADY_HAVE_SUMMON; + + if(m_caster->GetCharmGUID()) + return SPELL_FAILED_ALREADY_HAVE_CHARM; + + break; + } + case SPELL_EFFECT_SUMMON_PET: + { + if(m_caster->GetPetGUID()) //let warlock do a replacement summon + { + + Pet* pet = ((Player*)m_caster)->GetPet(); + + if (m_caster->GetTypeId()==TYPEID_PLAYER && m_caster->getClass()==CLASS_WARLOCK) + { + if (strict) //starting cast, trigger pet stun (cast by pet so it doesn't attack player) + pet->CastSpell(pet, 32752, true, NULL, NULL, pet->GetGUID()); + } + else + return SPELL_FAILED_ALREADY_HAVE_SUMMON; + } + + if(m_caster->GetCharmGUID()) + return SPELL_FAILED_ALREADY_HAVE_CHARM; + + break; + } + case SPELL_EFFECT_SUMMON_PLAYER: + { + if(m_caster->GetTypeId()!=TYPEID_PLAYER) + return SPELL_FAILED_BAD_TARGETS; + if(!((Player*)m_caster)->GetSelection()) + return SPELL_FAILED_BAD_TARGETS; + + Player* target = objmgr.GetPlayer(((Player*)m_caster)->GetSelection()); + if( !target || ((Player*)m_caster)==target || !target->IsInSameRaidWith((Player*)m_caster) ) + return SPELL_FAILED_BAD_TARGETS; + + // check if our map is dungeon + if( sMapStore.LookupEntry(m_caster->GetMapId())->IsDungeon() ) + { + InstanceTemplate const* instance = ObjectMgr::GetInstanceTemplate(m_caster->GetMapId()); + if(!instance) + return SPELL_FAILED_TARGET_NOT_IN_INSTANCE; + if ( instance->levelMin > target->getLevel() ) + return SPELL_FAILED_LOWLEVEL; + if ( instance->levelMax && instance->levelMax < target->getLevel() ) + return SPELL_FAILED_HIGHLEVEL; + } + break; + } + case SPELL_EFFECT_LEAP: + case SPELL_EFFECT_TELEPORT_UNITS_FACE_CASTER: + { + float dis = GetSpellRadius(sSpellRadiusStore.LookupEntry(m_spellInfo->EffectRadiusIndex[i])); + float fx = m_caster->GetPositionX() + dis * cos(m_caster->GetOrientation()); + float fy = m_caster->GetPositionY() + dis * sin(m_caster->GetOrientation()); + // teleport a bit above terrain level to avoid falling below it + float fz = MapManager::Instance().GetBaseMap(m_caster->GetMapId())->GetHeight(fx,fy,m_caster->GetPositionZ(),true); + if(fz <= INVALID_HEIGHT) // note: this also will prevent use effect in instances without vmaps height enabled + return SPELL_FAILED_TRY_AGAIN; + + float caster_pos_z = m_caster->GetPositionZ(); + // Control the caster to not climb or drop when +-fz > 8 + if(!(fz<=caster_pos_z+8 && fz>=caster_pos_z-8)) + return SPELL_FAILED_TRY_AGAIN; + + // not allow use this effect at battleground until battleground start + if(m_caster->GetTypeId()==TYPEID_PLAYER) + if(BattleGround const *bg = ((Player*)m_caster)->GetBattleGround()) + if(bg->GetStatus() != STATUS_IN_PROGRESS) + return SPELL_FAILED_TRY_AGAIN; + break; + } + case SPELL_EFFECT_STEAL_BENEFICIAL_BUFF: + { + if (m_targets.getUnitTarget()==m_caster) + return SPELL_FAILED_BAD_TARGETS; + break; + } + default:break; + } + } + + for (int i = 0; i < 3; i++) + { + switch(m_spellInfo->EffectApplyAuraName[i]) + { + case SPELL_AURA_MOD_POSSESS: + case SPELL_AURA_MOD_CHARM: + { + if(m_caster->GetPetGUID()) + return SPELL_FAILED_ALREADY_HAVE_SUMMON; + + if(m_caster->GetCharmGUID()) + return SPELL_FAILED_ALREADY_HAVE_CHARM; + + if(m_caster->GetCharmerGUID()) + return SPELL_FAILED_CHARMED; + + if(!m_targets.getUnitTarget()) + return SPELL_FAILED_BAD_IMPLICIT_TARGETS; + + if(m_targets.getUnitTarget()->GetCharmerGUID()) + return SPELL_FAILED_CHARMED; + + if(int32(m_targets.getUnitTarget()->getLevel()) > CalculateDamage(i,m_targets.getUnitTarget())) + return SPELL_FAILED_HIGHLEVEL; + };break; + case SPELL_AURA_MOUNTED: + { + if (m_caster->IsInWater()) + return SPELL_FAILED_ONLY_ABOVEWATER; + + if (m_caster->GetTypeId()==TYPEID_PLAYER && ((Player*)m_caster)->GetTransport()) + return SPELL_FAILED_NO_MOUNTS_ALLOWED; + + // Ignore map check if spell have AreaId. AreaId already checked and this prevent special mount spells + if (m_caster->GetTypeId()==TYPEID_PLAYER && !sMapStore.LookupEntry(m_caster->GetMapId())->IsMountAllowed() && !m_IsTriggeredSpell && !m_spellInfo->AreaId) + return SPELL_FAILED_NO_MOUNTS_ALLOWED; + + if (m_caster->GetAreaId()==35) + return SPELL_FAILED_NO_MOUNTS_ALLOWED; + + ShapeshiftForm form = m_caster->m_form; + if( form == FORM_CAT || form == FORM_TREE || form == FORM_TRAVEL || + form == FORM_AQUA || form == FORM_BEAR || form == FORM_DIREBEAR || + form == FORM_CREATUREBEAR || form == FORM_GHOSTWOLF || form == FORM_FLIGHT || + form == FORM_FLIGHT_EPIC || form == FORM_MOONKIN ) + return SPELL_FAILED_NOT_SHAPESHIFT; + + break; + } + case SPELL_AURA_RANGED_ATTACK_POWER_ATTACKER_BONUS: + { + if(!m_targets.getUnitTarget()) + return SPELL_FAILED_BAD_IMPLICIT_TARGETS; + + // can be casted at non-friendly unit or own pet/charm + if(m_caster->IsFriendlyTo(m_targets.getUnitTarget())) + return SPELL_FAILED_TARGET_FRIENDLY; + };break; + case SPELL_AURA_MOD_INCREASE_FLIGHT_SPEED: + case SPELL_AURA_FLY: + { + // not allow cast fly spells at old maps by players (all spells is self target) + if(m_caster->GetTypeId()==TYPEID_PLAYER) + { + if( !((Player*)m_caster)->isGameMaster() && + GetVirtualMapForMapAndZone(m_caster->GetMapId(),m_caster->GetZoneId()) != 530) + return SPELL_FAILED_NOT_HERE; + } + };break; + case SPELL_AURA_PERIODIC_MANA_LEECH: + { + if (!m_targets.getUnitTarget()) + return SPELL_FAILED_BAD_IMPLICIT_TARGETS; + + if (m_caster->GetTypeId()!=TYPEID_PLAYER || m_CastItem) + break; + + if(m_targets.getUnitTarget()->getPowerType()!=POWER_MANA) + return SPELL_FAILED_BAD_TARGETS; + break; + } + default:break; + } + } + + // all ok + return 0; +} + +int16 Spell::PetCanCast(Unit* target) +{ + if(!m_caster->isAlive()) + return SPELL_FAILED_CASTER_DEAD; + + if(m_caster->IsNonMeleeSpellCasted(false)) //prevent spellcast interuption by another spellcast + return SPELL_FAILED_SPELL_IN_PROGRESS; + if(m_caster->isInCombat() && IsNonCombatSpell(m_spellInfo)) + return SPELL_FAILED_AFFECTING_COMBAT; + + if(m_caster->GetTypeId()==TYPEID_UNIT && (((Creature*)m_caster)->isPet() || m_caster->isCharmed())) + { + //dead owner (pets still alive when owners ressed?) + if(m_caster->GetCharmerOrOwner() && !m_caster->GetCharmerOrOwner()->isAlive()) + return SPELL_FAILED_CASTER_DEAD; + + if(!target && m_targets.getUnitTarget()) + target = m_targets.getUnitTarget(); + + bool need = false; + for(uint32 i = 0;i<3;i++) + { + if(m_spellInfo->EffectImplicitTargetA[i] == TARGET_CHAIN_DAMAGE || m_spellInfo->EffectImplicitTargetA[i] == TARGET_SINGLE_FRIEND || m_spellInfo->EffectImplicitTargetA[i] == TARGET_DUELVSPLAYER || m_spellInfo->EffectImplicitTargetA[i] == TARGET_SINGLE_PARTY || m_spellInfo->EffectImplicitTargetA[i] == TARGET_CURRENT_ENEMY_COORDINATES) + { + need = true; + if(!target) + return SPELL_FAILED_BAD_IMPLICIT_TARGETS; + break; + } + } + if(need) + m_targets.setUnitTarget(target); + + Unit* _target = m_targets.getUnitTarget(); + + if(_target) //for target dead/target not valid + { + if(!_target->isAlive()) + return SPELL_FAILED_BAD_TARGETS; + + if(IsPositiveSpell(m_spellInfo->Id)) + { + if(m_caster->IsHostileTo(_target)) + return SPELL_FAILED_BAD_TARGETS; + } + else + { + bool duelvsplayertar = false; + for(int j=0;j<3;j++) + { + //TARGET_DUELVSPLAYER is positive AND negative + duelvsplayertar |= (m_spellInfo->EffectImplicitTargetA[j] == TARGET_DUELVSPLAYER); + } + if(m_caster->IsFriendlyTo(target) && !duelvsplayertar) + { + return SPELL_FAILED_BAD_TARGETS; + } + } + } + //cooldown + if(((Creature*)m_caster)->HasSpellCooldown(m_spellInfo->Id)) + return SPELL_FAILED_NOT_READY; + } + + uint16 result = CanCast(true); + if(result != 0) + return result; + else + return -1; //this allows to check spell fail 0, in combat +} + +uint8 Spell::CheckCasterAuras() const +{ + // Flag drop spells totally immuned to caster auras + // FIXME: find more nice check for all totally immuned spells + // AttributesEx3 & 0x10000000? + if(m_spellInfo->Id==23336 || m_spellInfo->Id==23334 || m_spellInfo->Id==34991) + return 0; + + uint8 school_immune = 0; + uint32 mechanic_immune = 0; + uint32 dispel_immune = 0; + + //Check if the spell grants school or mechanic immunity. + //We use bitmasks so the loop is done only once and not on every aura check below. + if ( m_spellInfo->AttributesEx & SPELL_ATTR_EX_DISPEL_AURAS_ON_IMMUNITY ) + { + for(int i = 0;i < 3; i ++) + { + if(m_spellInfo->EffectApplyAuraName[i] == SPELL_AURA_SCHOOL_IMMUNITY) + school_immune |= uint32(m_spellInfo->EffectMiscValue[i]); + else if(m_spellInfo->EffectApplyAuraName[i] == SPELL_AURA_MECHANIC_IMMUNITY) + mechanic_immune |= 1 << uint32(m_spellInfo->EffectMiscValue[i]); + else if(m_spellInfo->EffectApplyAuraName[i] == SPELL_AURA_DISPEL_IMMUNITY) + dispel_immune |= GetDispellMask(DispelType(m_spellInfo->EffectMiscValue[i])); + } + //immune movement impairement and loss of control + if(m_spellInfo->Id==(uint32)42292) + mechanic_immune = IMMUNE_TO_MOVEMENT_IMPAIRMENT_AND_LOSS_CONTROL_MASK; + } + + //Check whether the cast should be prevented by any state you might have. + uint8 prevented_reason = 0; + // Have to check if there is a stun aura. Otherwise will have problems with ghost aura apply while logging out + if(!(m_spellInfo->AttributesEx5 & SPELL_ATTR_EX5_USABLE_WHILE_STUNNED) && m_caster->HasAuraType(SPELL_AURA_MOD_STUN)) + prevented_reason = SPELL_FAILED_STUNNED; + else if(m_caster->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_CONFUSED) && !(m_spellInfo->AttributesEx5 & SPELL_ATTR_EX5_USABLE_WHILE_CONFUSED)) + prevented_reason = SPELL_FAILED_CONFUSED; + else if(m_caster->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_FLEEING) && !(m_spellInfo->AttributesEx5 & SPELL_ATTR_EX5_USABLE_WHILE_FEARED)) + prevented_reason = SPELL_FAILED_FLEEING; + else if(m_caster->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SILENCED) && m_spellInfo->PreventionType==SPELL_PREVENTION_TYPE_SILENCE) + prevented_reason = SPELL_FAILED_SILENCED; + else if(m_caster->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PACIFIED) && m_spellInfo->PreventionType==SPELL_PREVENTION_TYPE_PACIFY) + prevented_reason = SPELL_FAILED_PACIFIED; + + // Attr must make flag drop spell totally immuned from all effects + if(prevented_reason) + { + if(school_immune || mechanic_immune || dispel_immune) + { + //Checking auras is needed now, because you are prevented by some state but the spell grants immunity. + Unit::AuraMap const& auras = m_caster->GetAuras(); + for(Unit::AuraMap::const_iterator itr = auras.begin(); itr != auras.end(); itr++) + { + if(itr->second) + { + if( GetSpellMechanicMask(itr->second->GetSpellProto(), itr->second->GetEffIndex()) & mechanic_immune ) + continue; + if( GetSpellSchoolMask(itr->second->GetSpellProto()) & school_immune ) + continue; + if( (1<<(itr->second->GetSpellProto()->Dispel)) & dispel_immune) + continue; + + //Make a second check for spell failed so the right SPELL_FAILED message is returned. + //That is needed when your casting is prevented by multiple states and you are only immune to some of them. + switch(itr->second->GetModifier()->m_auraname) + { + case SPELL_AURA_MOD_STUN: + if (!(m_spellInfo->AttributesEx5 & SPELL_ATTR_EX5_USABLE_WHILE_STUNNED)) + return SPELL_FAILED_STUNNED; + break; + case SPELL_AURA_MOD_CONFUSE: + if (!(m_spellInfo->AttributesEx5 & SPELL_ATTR_EX5_USABLE_WHILE_CONFUSED)) + return SPELL_FAILED_CONFUSED; + break; + case SPELL_AURA_MOD_FEAR: + if (!(m_spellInfo->AttributesEx5 & SPELL_ATTR_EX5_USABLE_WHILE_FEARED)) + return SPELL_FAILED_FLEEING; + break; + case SPELL_AURA_MOD_SILENCE: + case SPELL_AURA_MOD_PACIFY: + case SPELL_AURA_MOD_PACIFY_SILENCE: + if( m_spellInfo->PreventionType==SPELL_PREVENTION_TYPE_PACIFY) + return SPELL_FAILED_PACIFIED; + else if ( m_spellInfo->PreventionType==SPELL_PREVENTION_TYPE_SILENCE) + return SPELL_FAILED_SILENCED; + break; + } + } + } + } + //You are prevented from casting and the spell casted does not grant immunity. Return a failed error. + else + return prevented_reason; + } + return 0; // all ok +} + +bool Spell::CanAutoCast(Unit* target) +{ + uint64 targetguid = target->GetGUID(); + + for(uint32 j = 0;j<3;j++) + { + if(m_spellInfo->Effect[j] == SPELL_EFFECT_APPLY_AURA) + { + if( m_spellInfo->StackAmount <= 1) + { + if( target->HasAura(m_spellInfo->Id, j) ) + return false; + } + else + { + if( target->GetAuras().count(Unit::spellEffectPair(m_spellInfo->Id, j)) >= m_spellInfo->StackAmount) + return false; + } + } + else if ( IsAreaAuraEffect( m_spellInfo->Effect[j] )) + { + if( target->HasAura(m_spellInfo->Id, j) ) + return false; + } + } + + int16 result = PetCanCast(target); + + if(result == -1 || result == SPELL_FAILED_UNIT_NOT_INFRONT) + { + FillTargetMap(); + //check if among target units, our WANTED target is as well (->only self cast spells return false) + for(std::list::iterator ihit= m_UniqueTargetInfo.begin();ihit != m_UniqueTargetInfo.end();++ihit) + if( ihit->targetGUID == targetguid ) + return true; + } + return false; //target invalid +} + +uint8 Spell::CheckRange(bool strict) +{ + float range_mod; + + // self cast doesn't need range checking -- also for Starshards fix + if (m_spellInfo->rangeIndex == 1) return 0; + + if (strict) //add radius of caster + range_mod = 1.25; + else //add radius of caster and ~5 yds "give" + range_mod = 6.25; + + SpellRangeEntry const* srange = sSpellRangeStore.LookupEntry(m_spellInfo->rangeIndex); + float max_range = GetSpellMaxRange(srange) + range_mod; + float min_range = GetSpellMinRange(srange); + + if(Player* modOwner = m_caster->GetSpellModOwner()) + modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_RANGE, max_range, this); + + Unit *target = m_targets.getUnitTarget(); + + if(target && target != m_caster) + { + // distance from target center in checks + float dist = m_caster->GetDistance(target->GetPositionX(),target->GetPositionY(),target->GetPositionZ()); + if(dist > max_range) + return SPELL_FAILED_OUT_OF_RANGE; //0x5A; + if(dist < min_range) + return SPELL_FAILED_TOO_CLOSE; + if( m_caster->GetTypeId() == TYPEID_PLAYER && + (m_spellInfo->FacingCasterFlags & SPELL_FACING_FLAG_INFRONT) && !m_caster->HasInArc( M_PI, target ) ) + return SPELL_FAILED_UNIT_NOT_INFRONT; + } + + if(m_targets.m_targetMask == TARGET_FLAG_DEST_LOCATION && m_targets.m_destX != 0 && m_targets.m_destY != 0 && m_targets.m_destZ != 0) + { + float dist = m_caster->GetDistance(m_targets.m_destX, m_targets.m_destY, m_targets.m_destZ); + if(dist > max_range) + return SPELL_FAILED_OUT_OF_RANGE; + if(dist < min_range) + return SPELL_FAILED_TOO_CLOSE; + } + + return 0; // ok +} + +int32 Spell::CalculatePowerCost() +{ + // item cast not used power + if(m_CastItem) + return 0; + + // Spell drain all exist power on cast (Only paladin lay of Hands) + if (m_spellInfo->AttributesEx & SPELL_ATTR_EX_DRAIN_ALL_POWER) + { + // If power type - health drain all + if (m_spellInfo->powerType == POWER_HEALTH) + return m_caster->GetHealth(); + // Else drain all power + if (m_spellInfo->powerType < MAX_POWERS) + return m_caster->GetPower(Powers(m_spellInfo->powerType)); + sLog.outError("Spell::CalculateManaCost: Unknown power type '%d' in spell %d", m_spellInfo->powerType, m_spellInfo->Id); + return 0; + } + + // Base powerCost + int32 powerCost = m_spellInfo->manaCost; + // PCT cost from total amount + if (m_spellInfo->ManaCostPercentage) + { + switch (m_spellInfo->powerType) + { + // health as power used + case POWER_HEALTH: + powerCost += m_spellInfo->ManaCostPercentage * m_caster->GetCreateHealth() / 100; + break; + case POWER_MANA: + powerCost += m_spellInfo->ManaCostPercentage * m_caster->GetCreateMana() / 100; + break; + case POWER_RAGE: + case POWER_FOCUS: + case POWER_ENERGY: + case POWER_HAPPINESS: + // case POWER_RUNES: + powerCost += m_spellInfo->ManaCostPercentage * m_caster->GetMaxPower(Powers(m_spellInfo->powerType)) / 100; + break; + default: + sLog.outError("Spell::CalculateManaCost: Unknown power type '%d' in spell %d", m_spellInfo->powerType, m_spellInfo->Id); + return 0; + } + } + SpellSchools school = GetFirstSchoolInMask(m_spellSchoolMask); + // Flat mod from caster auras by spell school + powerCost += m_caster->GetInt32Value(UNIT_FIELD_POWER_COST_MODIFIER + school); + // Shiv - costs 20 + weaponSpeed*10 energy (apply only to non-triggered spell with energy cost) + if ( m_spellInfo->AttributesEx4 & SPELL_ATTR_EX4_SPELL_VS_EXTEND_COST ) + powerCost += m_caster->GetAttackTime(OFF_ATTACK)/100; + // Apply cost mod by spell + if(Player* modOwner = m_caster->GetSpellModOwner()) + modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_COST, powerCost, this); + + if(m_spellInfo->Attributes & SPELL_ATTR_LEVEL_DAMAGE_CALCULATION) + powerCost = int32(powerCost/ (1.117f* m_spellInfo->spellLevel / m_caster->getLevel() -0.1327f)); + + // PCT mod from user auras by school + powerCost = int32(powerCost * (1.0f+m_caster->GetFloatValue(UNIT_FIELD_POWER_COST_MULTIPLIER+school))); + if (powerCost < 0) + powerCost = 0; + return powerCost; +} + +uint8 Spell::CheckPower() +{ + // item cast not used power + if(m_CastItem) + return 0; + + // health as power used - need check health amount + if(m_spellInfo->powerType == POWER_HEALTH) + { + if(m_caster->GetHealth() <= m_powerCost) + return SPELL_FAILED_CASTER_AURASTATE; + return 0; + } + // Check valid power type + if( m_spellInfo->powerType >= MAX_POWERS ) + { + sLog.outError("Spell::CheckMana: Unknown power type '%d'", m_spellInfo->powerType); + return SPELL_FAILED_UNKNOWN; + } + // Check power amount + Powers powerType = Powers(m_spellInfo->powerType); + if(m_caster->GetPower(powerType) < m_powerCost) + return SPELL_FAILED_NO_POWER; + else + return 0; +} + +uint8 Spell::CheckItems() +{ + if (m_caster->GetTypeId() != TYPEID_PLAYER) + return 0; + + uint32 itemid, itemcount; + Player* p_caster = (Player*)m_caster; + + if(m_CastItem) + { + itemid = m_CastItem->GetEntry(); + if( !p_caster->HasItemCount(itemid,1) ) + return SPELL_FAILED_ITEM_NOT_READY; + else + { + ItemPrototype const *proto = m_CastItem->GetProto(); + if(!proto) + return SPELL_FAILED_ITEM_NOT_READY; + + for (int i = 0; i<5; i++) + { + if (proto->Spells[i].SpellCharges) + { + if(m_CastItem->GetSpellCharges(i)==0) + return SPELL_FAILED_NO_CHARGES_REMAIN; + } + } + + uint32 ItemClass = proto->Class; + if (ItemClass == ITEM_CLASS_CONSUMABLE && m_targets.getUnitTarget()) + { + for (int i = 0; i < 3; i++) + { + // skip check, pet not required like checks, and for TARGET_PET m_targets.getUnitTarget() is not the real target but the caster + if (m_spellInfo->EffectImplicitTargetA[i] == TARGET_PET) + continue; + + if (m_spellInfo->Effect[i] == SPELL_EFFECT_HEAL) + if (m_targets.getUnitTarget()->GetHealth() == m_targets.getUnitTarget()->GetMaxHealth()) + return (uint8)SPELL_FAILED_ALREADY_AT_FULL_HEALTH; + + // Mana Potion, Rage Potion, Thistle Tea(Rogue), ... + if (m_spellInfo->Effect[i] == SPELL_EFFECT_ENERGIZE) + { + if(m_spellInfo->EffectMiscValue[i] < 0 || m_spellInfo->EffectMiscValue[i] >= MAX_POWERS) + return (uint8)SPELL_FAILED_ALREADY_AT_FULL_POWER; + + Powers power = Powers(m_spellInfo->EffectMiscValue[i]); + + if (m_targets.getUnitTarget()->GetPower(power) == m_targets.getUnitTarget()->GetMaxPower(power)) + return (uint8)SPELL_FAILED_ALREADY_AT_FULL_POWER; + } + } + } + } + } + + if(m_targets.getItemTargetGUID()) + { + if(m_caster->GetTypeId() != TYPEID_PLAYER) + return SPELL_FAILED_BAD_TARGETS; + + if(!m_targets.getItemTarget()) + return SPELL_FAILED_ITEM_GONE; + + if(!m_targets.getItemTarget()->IsFitToSpellRequirements(m_spellInfo)) + return SPELL_FAILED_EQUIPPED_ITEM_CLASS; + } + // if not item target then required item must be equipped + else + { + if(m_caster->GetTypeId() == TYPEID_PLAYER && !((Player*)m_caster)->HasItemFitToSpellReqirements(m_spellInfo)) + return SPELL_FAILED_EQUIPPED_ITEM_CLASS; + } + + if(m_spellInfo->RequiresSpellFocus) + { + CellPair p(MaNGOS::ComputeCellPair(m_caster->GetPositionX(), m_caster->GetPositionY())); + Cell cell(p); + cell.data.Part.reserved = ALL_DISTRICT; + + GameObject* ok = NULL; + MaNGOS::GameObjectFocusCheck go_check(m_caster,m_spellInfo->RequiresSpellFocus); + MaNGOS::GameObjectSearcher checker(ok,go_check); + + TypeContainerVisitor, GridTypeMapContainer > object_checker(checker); + CellLock cell_lock(cell, p); + cell_lock->Visit(cell_lock, object_checker, *MapManager::Instance().GetMap(m_caster->GetMapId(), m_caster)); + + if(!ok) + return (uint8)SPELL_FAILED_REQUIRES_SPELL_FOCUS; + + focusObject = ok; // game object found in range + } + + if (!(m_spellInfo->AttributesEx5 & SPELL_ATTR_EX5_NO_REAGENT_WHILE_PREP && + m_caster->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PREPARATION))) + { + for(uint32 i=0;i<8;i++) + { + if(m_spellInfo->Reagent[i] <= 0) + continue; + + itemid = m_spellInfo->Reagent[i]; + itemcount = m_spellInfo->ReagentCount[i]; + + // if CastItem is also spell reagent + if( m_CastItem && m_CastItem->GetEntry() == itemid ) + { + ItemPrototype const *proto = m_CastItem->GetProto(); + if(!proto) + return SPELL_FAILED_ITEM_NOT_READY; + for(int s=0;s<5;s++) + { + // CastItem will be used up and does not count as reagent + int32 charges = m_CastItem->GetSpellCharges(s); + if (proto->Spells[s].SpellCharges < 0 && abs(charges) < 2) + { + ++itemcount; + break; + } + } + } + if( !p_caster->HasItemCount(itemid,itemcount) ) + return (uint8)SPELL_FAILED_ITEM_NOT_READY; //0x54 + } + } + + uint32 totems = 2; + for(int i=0;i<2;++i) + { + if(m_spellInfo->Totem[i] != 0) + { + if( p_caster->HasItemCount(m_spellInfo->Totem[i],1) ) + { + totems -= 1; + continue; + } + }else + totems -= 1; + } + if(totems != 0) + return (uint8)SPELL_FAILED_TOTEMS; //0x7C + + //Check items for TotemCategory + uint32 TotemCategory = 2; + for(int i=0;i<2;++i) + { + if(m_spellInfo->TotemCategory[i] != 0) + { + if( p_caster->HasItemTotemCategory(m_spellInfo->TotemCategory[i]) ) + { + TotemCategory -= 1; + continue; + } + } + else + TotemCategory -= 1; + } + if(TotemCategory != 0) + return (uint8)SPELL_FAILED_TOTEM_CATEGORY; //0x7B + + for(int i = 0; i < 3; i++) + { + switch (m_spellInfo->Effect[i]) + { + case SPELL_EFFECT_CREATE_ITEM: + { + if (!m_IsTriggeredSpell && m_spellInfo->EffectItemType[i]) + { + ItemPosCountVec dest; + uint8 msg = p_caster->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, m_spellInfo->EffectItemType[i], 1 ); + if (msg != EQUIP_ERR_OK ) + { + p_caster->SendEquipError( msg, NULL, NULL ); + return SPELL_FAILED_DONT_REPORT; + } + } + break; + } + case SPELL_EFFECT_ENCHANT_ITEM: + { + Item* targetItem = m_targets.getItemTarget(); + if(!targetItem) + return SPELL_FAILED_ITEM_NOT_FOUND; + + if( targetItem->GetProto()->ItemLevel < m_spellInfo->baseLevel ) + return SPELL_FAILED_LOWLEVEL; + // Not allow enchant in trade slot for some enchant type + if( targetItem->GetOwner() != m_caster ) + { + uint32 enchant_id = m_spellInfo->EffectMiscValue[i]; + SpellItemEnchantmentEntry const *pEnchant = sSpellItemEnchantmentStore.LookupEntry(enchant_id); + if(!pEnchant) + return SPELL_FAILED_ERROR; + if (pEnchant->slot & ENCHANTMENT_CAN_SOULBOUND) + return SPELL_FAILED_NOT_TRADEABLE; + } + break; + } + case SPELL_EFFECT_ENCHANT_ITEM_TEMPORARY: + { + Item *item = m_targets.getItemTarget(); + if(!item) + return SPELL_FAILED_ITEM_NOT_FOUND; + // Not allow enchant in trade slot for some enchant type + if( item->GetOwner() != m_caster ) + { + uint32 enchant_id = m_spellInfo->EffectMiscValue[i]; + SpellItemEnchantmentEntry const *pEnchant = sSpellItemEnchantmentStore.LookupEntry(enchant_id); + if(!pEnchant) + return SPELL_FAILED_ERROR; + if (pEnchant->slot & ENCHANTMENT_CAN_SOULBOUND) + return SPELL_FAILED_NOT_TRADEABLE; + } + break; + } + case SPELL_EFFECT_ENCHANT_HELD_ITEM: + // check item existence in effect code (not output errors at offhand hold item effect to main hand for example + break; + case SPELL_EFFECT_DISENCHANT: + { + if(!m_targets.getItemTarget()) + return SPELL_FAILED_CANT_BE_DISENCHANTED; + + // prevent disenchanting in trade slot + if( m_targets.getItemTarget()->GetOwnerGUID() != m_caster->GetGUID() ) + return SPELL_FAILED_CANT_BE_DISENCHANTED; + + ItemPrototype const* itemProto = m_targets.getItemTarget()->GetProto(); + if(!itemProto) + return SPELL_FAILED_CANT_BE_DISENCHANTED; + + uint32 item_quality = itemProto->Quality; + // 2.0.x addon: Check player enchanting level agains the item desenchanting requirements + uint32 item_disenchantskilllevel = itemProto->RequiredDisenchantSkill; + if (item_disenchantskilllevel == uint32(-1)) + return SPELL_FAILED_CANT_BE_DISENCHANTED; + if (item_disenchantskilllevel > p_caster->GetSkillValue(SKILL_ENCHANTING)) + return SPELL_FAILED_LOW_CASTLEVEL; + if(item_quality > 4 || item_quality < 2) + return SPELL_FAILED_CANT_BE_DISENCHANTED; + if(itemProto->Class != ITEM_CLASS_WEAPON && itemProto->Class != ITEM_CLASS_ARMOR) + return SPELL_FAILED_CANT_BE_DISENCHANTED; + if (!itemProto->DisenchantID) + return SPELL_FAILED_CANT_BE_DISENCHANTED; + break; + } + case SPELL_EFFECT_PROSPECTING: + { + if(!m_targets.getItemTarget()) + return SPELL_FAILED_CANT_BE_PROSPECTED; + //ensure item is a prospectable ore + if(!(m_targets.getItemTarget()->GetProto()->BagFamily & BAG_FAMILY_MASK_MINING_SUPP) || m_targets.getItemTarget()->GetProto()->Class != ITEM_CLASS_TRADE_GOODS) + return SPELL_FAILED_CANT_BE_PROSPECTED; + //prevent prospecting in trade slot + if( m_targets.getItemTarget()->GetOwnerGUID() != m_caster->GetGUID() ) + return SPELL_FAILED_CANT_BE_PROSPECTED; + //Check for enough skill in jewelcrafting + uint32 item_prospectingskilllevel = m_targets.getItemTarget()->GetProto()->RequiredSkillRank; + if(item_prospectingskilllevel >p_caster->GetSkillValue(SKILL_JEWELCRAFTING)) + return SPELL_FAILED_LOW_CASTLEVEL; + //make sure the player has the required ores in inventory + if(m_targets.getItemTarget()->GetCount() < 5) + return SPELL_FAILED_PROSPECT_NEED_MORE; + + if(!LootTemplates_Prospecting.HaveLootFor(m_targets.getItemTargetEntry())) + return SPELL_FAILED_CANT_BE_PROSPECTED; + + break; + } + case SPELL_EFFECT_WEAPON_DAMAGE: + case SPELL_EFFECT_WEAPON_DAMAGE_NOSCHOOL: + { + if(m_caster->GetTypeId() != TYPEID_PLAYER) return SPELL_FAILED_TARGET_NOT_PLAYER; + if( m_attackType != RANGED_ATTACK ) + break; + Item *pItem = ((Player*)m_caster)->GetWeaponForAttack(m_attackType); + if(!pItem || pItem->IsBroken()) + return SPELL_FAILED_EQUIPPED_ITEM; + + switch(pItem->GetProto()->SubClass) + { + case ITEM_SUBCLASS_WEAPON_THROWN: + { + uint32 ammo = pItem->GetEntry(); + if( !((Player*)m_caster)->HasItemCount( ammo, 1 ) ) + return SPELL_FAILED_NO_AMMO; + }; break; + case ITEM_SUBCLASS_WEAPON_GUN: + case ITEM_SUBCLASS_WEAPON_BOW: + case ITEM_SUBCLASS_WEAPON_CROSSBOW: + { + uint32 ammo = ((Player*)m_caster)->GetUInt32Value(PLAYER_AMMO_ID); + if(!ammo) + { + // Requires No Ammo + if(m_caster->GetDummyAura(46699)) + break; // skip other checks + + return SPELL_FAILED_NO_AMMO; + } + + ItemPrototype const *ammoProto = objmgr.GetItemPrototype( ammo ); + if(!ammoProto) + return SPELL_FAILED_NO_AMMO; + + if(ammoProto->Class != ITEM_CLASS_PROJECTILE) + return SPELL_FAILED_NO_AMMO; + + // check ammo ws. weapon compatibility + switch(pItem->GetProto()->SubClass) + { + case ITEM_SUBCLASS_WEAPON_BOW: + case ITEM_SUBCLASS_WEAPON_CROSSBOW: + if(ammoProto->SubClass!=ITEM_SUBCLASS_ARROW) + return SPELL_FAILED_NO_AMMO; + break; + case ITEM_SUBCLASS_WEAPON_GUN: + if(ammoProto->SubClass!=ITEM_SUBCLASS_BULLET) + return SPELL_FAILED_NO_AMMO; + break; + default: + return SPELL_FAILED_NO_AMMO; + } + + if( !((Player*)m_caster)->HasItemCount( ammo, 1 ) ) + return SPELL_FAILED_NO_AMMO; + }; break; + case ITEM_SUBCLASS_WEAPON_WAND: + default: + break; + } + break; + } + default:break; + } + } + + return uint8(0); +} + +void Spell::Delayed() +{ + if(!m_caster || m_caster->GetTypeId() != TYPEID_PLAYER) + return; + + if (m_spellState == SPELL_STATE_DELAYED) + return; // spell is active and can't be time-backed + + // spells not loosing casting time ( slam, dynamites, bombs.. ) + if(!(m_spellInfo->InterruptFlags & SPELL_INTERRUPT_FLAG_DAMAGE)) + return; + + //check resist chance + int32 resistChance = 100; //must be initialized to 100 for percent modifiers + ((Player*)m_caster)->ApplySpellMod(m_spellInfo->Id,SPELLMOD_NOT_LOSE_CASTING_TIME,resistChance, this); + resistChance += m_caster->GetTotalAuraModifier(SPELL_AURA_RESIST_PUSHBACK) - 100; + if (roll_chance_i(resistChance)) + return; + + int32 delaytime = GetNextDelayAtDamageMsTime(); + + if(int32(m_timer) + delaytime > m_casttime) + { + delaytime = m_casttime - m_timer; + m_timer = m_casttime; + } + else + m_timer += delaytime; + + sLog.outDetail("Spell %u partially interrupted for (%d) ms at damage",m_spellInfo->Id,delaytime); + + WorldPacket data(SMSG_SPELL_DELAYED, 8+4); + data.append(m_caster->GetPackGUID()); + data << uint32(delaytime); + + m_caster->SendMessageToSet(&data,true); +} + +void Spell::DelayedChannel() +{ + if(!m_caster || m_caster->GetTypeId() != TYPEID_PLAYER || getState() != SPELL_STATE_CASTING) + return; + + //check resist chance + int32 resistChance = 100; //must be initialized to 100 for percent modifiers + ((Player*)m_caster)->ApplySpellMod(m_spellInfo->Id,SPELLMOD_NOT_LOSE_CASTING_TIME,resistChance, this); + resistChance += m_caster->GetTotalAuraModifier(SPELL_AURA_RESIST_PUSHBACK) - 100; + if (roll_chance_i(resistChance)) + return; + + int32 delaytime = GetNextDelayAtDamageMsTime(); + + if(int32(m_timer) < delaytime) + { + delaytime = m_timer; + m_timer = 0; + } + else + m_timer -= delaytime; + + sLog.outDebug("Spell %u partially interrupted for %i ms, new duration: %u ms", m_spellInfo->Id, delaytime, m_timer); + + for(std::list::iterator ihit= m_UniqueTargetInfo.begin();ihit != m_UniqueTargetInfo.end();++ihit) + { + if ((*ihit).missCondition == SPELL_MISS_NONE) + { + Unit* unit = m_caster->GetGUID()==ihit->targetGUID ? m_caster : ObjectAccessor::GetUnit(*m_caster, ihit->targetGUID); + if (unit) + { + for (int j=0;j<3;j++) + if( ihit->effectMask & (1<DelayAura(m_spellInfo->Id, j, delaytime); + } + + } + } + + for(int j = 0; j < 3; j++) + { + // partially interrupt persistent area auras + DynamicObject* dynObj = m_caster->GetDynObject(m_spellInfo->Id, j); + if(dynObj) + dynObj->Delay(delaytime); + } + + SendChannelUpdate(m_timer); +} + +void Spell::UpdatePointers() +{ + if(m_originalCasterGUID==m_caster->GetGUID()) + m_originalCaster = m_caster; + else + { + m_originalCaster = ObjectAccessor::GetUnit(*m_caster,m_originalCasterGUID); + if(m_originalCaster && !m_originalCaster->IsInWorld()) m_originalCaster = NULL; + } + + m_targets.Update(m_caster); +} + +bool Spell::IsAffectedBy(SpellEntry const *spellInfo, uint32 effectId) +{ + return spellmgr.IsAffectedBySpell(m_spellInfo,spellInfo->Id,effectId,spellInfo->EffectItemType[effectId]); +} + +bool Spell::CheckTargetCreatureType(Unit* target) const +{ + uint32 spellCreatureTargetMask = m_spellInfo->TargetCreatureType; + + // Curse of Doom : not find another way to fix spell target check :/ + if(m_spellInfo->SpellFamilyName==SPELLFAMILY_WARLOCK && m_spellInfo->SpellFamilyFlags == 0x0200000000LL) + { + // not allow cast at player + if(target->GetTypeId()==TYPEID_PLAYER) + return false; + + spellCreatureTargetMask = 0x7FF; + } + + // Dismiss Pet and Taming Lesson skipped + if(m_spellInfo->Id == 2641 || m_spellInfo->Id == 23356) + spellCreatureTargetMask = 0; + + if (spellCreatureTargetMask) + { + uint32 TargetCreatureType = target->GetCreatureTypeMask(); + + return !TargetCreatureType || (spellCreatureTargetMask & TargetCreatureType); + } + return true; +} + +CurrentSpellTypes Spell::GetCurrentContainer() +{ + if (IsNextMeleeSwingSpell()) + return(CURRENT_MELEE_SPELL); + else if (IsAutoRepeat()) + return(CURRENT_AUTOREPEAT_SPELL); + else if (IsChanneledSpell(m_spellInfo)) + return(CURRENT_CHANNELED_SPELL); + else + return(CURRENT_GENERIC_SPELL); +} + +bool Spell::CheckTarget( Unit* target, uint32 eff, bool hitPhase ) +{ + // Check targets for creature type mask and remove not appropriate (skip explicit self target case, maybe need other explicit targets) + if(m_spellInfo->EffectImplicitTargetA[eff]!=TARGET_SELF ) + { + if (!CheckTargetCreatureType(target)) + return false; + } + + // Check targets for not_selectable unit flag and remove + // A player can cast spells on his pet (or other controlled unit) though in any state + if (target != m_caster && target->GetCharmerOrOwnerGUID() != m_caster->GetGUID()) + { + // any unattackable target skipped + if (target->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE)) + return false; + + // unselectable targets skipped in all cases except TARGET_SCRIPT targeting + // in case TARGET_SCRIPT target selected by server always and can't be cheated + if( target->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE) && + m_spellInfo->EffectImplicitTargetA[eff] != TARGET_SCRIPT && + m_spellInfo->EffectImplicitTargetB[eff] != TARGET_SCRIPT ) + return false; + } + + //Check player targets and remove if in GM mode or GM invisibility (for not self casting case) + if( target != m_caster && target->GetTypeId()==TYPEID_PLAYER) + { + if(((Player*)target)->GetVisibility()==VISIBILITY_OFF) + return false; + + if(((Player*)target)->isGameMaster() && !IsPositiveSpell(m_spellInfo->Id)) + return false; + } + + //Check targets for LOS visibility (except spells without range limitations ) + switch(m_spellInfo->Effect[eff]) + { + case SPELL_EFFECT_SUMMON_PLAYER: // from anywhere + break; + case SPELL_EFFECT_DUMMY: + if(m_spellInfo->Id!=20577) // Cannibalize + break; + //fall through + case SPELL_EFFECT_RESURRECT_NEW: + // player far away, maybe his corpse near? + if(target!=m_caster && !target->IsWithinLOSInMap(m_caster)) + { + if(!m_targets.getCorpseTargetGUID()) + return false; + + Corpse *corpse = ObjectAccessor::GetCorpse(*m_caster,m_targets.getCorpseTargetGUID()); + if(!corpse) + return false; + + if(target->GetGUID()!=corpse->GetOwnerGUID()) + return false; + + if(!corpse->IsWithinLOSInMap(m_caster)) + return false; + } + + // all ok by some way or another, skip normal check + break; + default: // normal case + if(target!=m_caster && !target->IsWithinLOSInMap(m_caster)) + return false; + break; + } + + return true; +} + +Unit* Spell::SelectMagnetTarget() +{ + Unit* target = m_targets.getUnitTarget(); + + if(target && target->HasAuraType(SPELL_AURA_SPELL_MAGNET) && !(m_spellInfo->Attributes & 0x10)) + { + Unit::AuraList const& magnetAuras = target->GetAurasByType(SPELL_AURA_SPELL_MAGNET); + for(Unit::AuraList::const_iterator itr = magnetAuras.begin(); itr != magnetAuras.end(); ++itr) + { + if(Unit* magnet = (*itr)->GetCaster()) + { + if(magnet->IsWithinLOSInMap(m_caster)) + { + target = magnet; + m_targets.setUnitTarget(target); + break; + } + } + } + } + + return target; +} + +bool Spell::IsNeedSendToClient() const +{ + return m_spellInfo->SpellVisual!=0 || IsChanneledSpell(m_spellInfo) || + m_spellInfo->speed > 0.0f || !m_triggeredByAuraSpell && !m_IsTriggeredSpell; +} + +bool Spell::HaveTargetsForEffect( uint8 effect ) const +{ + for(std::list::const_iterator itr= m_UniqueTargetInfo.begin();itr != m_UniqueTargetInfo.end();++itr) + if(itr->effectMask & (1<::const_iterator itr= m_UniqueGOTargetInfo.begin();itr != m_UniqueGOTargetInfo.end();++itr) + if(itr->effectMask & (1<::const_iterator itr= m_UniqueItemInfo.begin();itr != m_UniqueItemInfo.end();++itr) + if(itr->effectMask & (1<getState() != SPELL_STATE_FINISHED) + m_Spell->cancel(); + + if (m_Spell->IsDeletable()) + { + delete m_Spell; + } + else + { + sLog.outError("~SpellEvent: %s %u tried to delete non-deletable spell %u. Was not deleted, causes memory leak.", + (m_Spell->GetCaster()->GetTypeId()==TYPEID_PLAYER?"Player":"Creature"), m_Spell->GetCaster()->GetGUIDLow(),m_Spell->m_spellInfo->Id); + } +} + +bool SpellEvent::Execute(uint64 e_time, uint32 p_time) +{ + // update spell if it is not finished + if (m_Spell->getState() != SPELL_STATE_FINISHED) + m_Spell->update(p_time); + + // check spell state to process + switch (m_Spell->getState()) + { + case SPELL_STATE_FINISHED: + { + // spell was finished, check deletable state + if (m_Spell->IsDeletable()) + { + // check, if we do have unfinished triggered spells + + return(true); // spell is deletable, finish event + } + // event will be re-added automatically at the end of routine) + } break; + + case SPELL_STATE_CASTING: + { + // this spell is in channeled state, process it on the next update + // event will be re-added automatically at the end of routine) + } break; + + case SPELL_STATE_DELAYED: + { + // first, check, if we have just started + if (m_Spell->GetDelayStart() != 0) + { + // no, we aren't, do the typical update + // check, if we have channeled spell on our hands + if (IsChanneledSpell(m_Spell->m_spellInfo)) + { + // evented channeled spell is processed separately, casted once after delay, and not destroyed till finish + // check, if we have casting anything else except this channeled spell and autorepeat + if (m_Spell->GetCaster()->IsNonMeleeSpellCasted(false, true, true)) + { + // another non-melee non-delayed spell is casted now, abort + m_Spell->cancel(); + } + else + { + // do the action (pass spell to channeling state) + m_Spell->handle_immediate(); + } + // event will be re-added automatically at the end of routine) + } + else + { + // run the spell handler and think about what we can do next + uint64 t_offset = e_time - m_Spell->GetDelayStart(); + uint64 n_offset = m_Spell->handle_delayed(t_offset); + if (n_offset) + { + // re-add us to the queue + m_Spell->GetCaster()->m_Events.AddEvent(this, m_Spell->GetDelayStart() + n_offset, false); + return(false); // event not complete + } + // event complete + // finish update event will be re-added automatically at the end of routine) + } + } + else + { + // delaying had just started, record the moment + m_Spell->SetDelayStart(e_time); + // re-plan the event for the delay moment + m_Spell->GetCaster()->m_Events.AddEvent(this, e_time + m_Spell->GetDelayMoment(), false); + return(false); // event not complete + } + } break; + + default: + { + // all other states + // event will be re-added automatically at the end of routine) + } break; + } + + // spell processing not complete, plan event on the next update interval + m_Spell->GetCaster()->m_Events.AddEvent(this, e_time + 1, false); + return(false); // event not complete +} + +void SpellEvent::Abort(uint64 /*e_time*/) +{ + // oops, the spell we try to do is aborted + if (m_Spell->getState() != SPELL_STATE_FINISHED) + m_Spell->cancel(); +} diff --git a/src/game/Spell.h b/src/game/Spell.h index 898d74de0f2..d606fd71f34 100644 --- a/src/game/Spell.h +++ b/src/game/Spell.h @@ -1,694 +1,695 @@ -/* - * Copyright (C) 2005-2008 MaNGOS - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef __SPELL_H -#define __SPELL_H - -#include "GridDefines.h" - -class WorldSession; -class Unit; -class DynamicObj; -class Player; -class GameObject; -class Group; -class Aura; - -enum SpellCastTargetFlags -{ - /*TARGET_FLAG_NONE = 0x0000, - TARGET_FLAG_SWIMMER = 0x0002, - TARGET_FLAG_ITEM = 0x0010, - TARGET_FLAG_SOURCE_AREA = 0x0020, - TARGET_FLAG_DEST_AREA = 0x0040, - TARGET_FLAG_UNKNOWN = 0x0080, - TARGET_FLAG_SELF = 0x0100, - TARGET_FLAG_PVP_CORPSE = 0x0200, - TARGET_FLAG_MASS_SPIRIT_HEAL = 0x0400, - TARGET_FLAG_BEAST_CORPSE = 0x0402, - TARGET_FLAG_OBJECT = 0x4000, - TARGET_FLAG_RESURRECTABLE = 0x8000*/ - - TARGET_FLAG_SELF = 0x00000000, - TARGET_FLAG_UNIT = 0x00000002, // pguid - TARGET_FLAG_ITEM = 0x00000010, // pguid - TARGET_FLAG_SOURCE_LOCATION = 0x00000020, // 3 float - TARGET_FLAG_DEST_LOCATION = 0x00000040, // 3 float - TARGET_FLAG_OBJECT_UNK = 0x00000080, // ? - TARGET_FLAG_PVP_CORPSE = 0x00000200, // pguid - TARGET_FLAG_OBJECT = 0x00000800, // pguid - TARGET_FLAG_TRADE_ITEM = 0x00001000, // pguid - TARGET_FLAG_STRING = 0x00002000, // string - TARGET_FLAG_UNK1 = 0x00004000, // ? - TARGET_FLAG_CORPSE = 0x00008000, // pguid - TARGET_FLAG_UNK2 = 0x00010000 // pguid -}; - -enum SpellCastFlags -{ - CAST_FLAG_UNKNOWN1 = 0x00000002, - CAST_FLAG_UNKNOWN2 = 0x00000010, - CAST_FLAG_AMMO = 0x00000020, - CAST_FLAG_UNKNOWN3 = 0x00000100 -}; - -enum SpellNotifyPushType -{ - PUSH_IN_FRONT, - PUSH_IN_BACK, - PUSH_SELF_CENTER, - PUSH_DEST_CENTER, - PUSH_TARGET_CENTER -}; - -bool IsQuestTameSpell(uint32 spellId); - -namespace MaNGOS -{ - struct SpellNotifierPlayer; - struct SpellNotifierCreatureAndPlayer; -} - -class SpellCastTargets -{ - public: - SpellCastTargets(); - ~SpellCastTargets(); - - bool read ( WorldPacket * data, Unit *caster ); - void write ( WorldPacket * data ); - - SpellCastTargets& operator=(const SpellCastTargets &target) - { - m_unitTarget = target.m_unitTarget; - m_itemTarget = target.m_itemTarget; - m_GOTarget = target.m_GOTarget; - - m_unitTargetGUID = target.m_unitTargetGUID; - m_GOTargetGUID = target.m_GOTargetGUID; - m_CorpseTargetGUID = target.m_CorpseTargetGUID; - m_itemTargetGUID = target.m_itemTargetGUID; - - m_itemTargetEntry = target.m_itemTargetEntry; - - m_srcX = target.m_srcX; - m_srcY = target.m_srcY; - m_srcZ = target.m_srcZ; - - m_destX = target.m_destX; - m_destY = target.m_destY; - m_destZ = target.m_destZ; - - m_strTarget = target.m_strTarget; - - m_targetMask = target.m_targetMask; - - return *this; - } - - uint64 getUnitTargetGUID() const { return m_unitTargetGUID; } - Unit *getUnitTarget() const { return m_unitTarget; } - void setUnitTarget(Unit *target); - void setDestination(float x, float y, float z); - - uint64 getGOTargetGUID() const { return m_GOTargetGUID; } - GameObject *getGOTarget() const { return m_GOTarget; } - void setGOTarget(GameObject *target); - - uint64 getCorpseTargetGUID() const { return m_CorpseTargetGUID; } - void setCorpseTarget(Corpse* corpse); - uint64 getItemTargetGUID() const { return m_itemTargetGUID; } - Item* getItemTarget() const { return m_itemTarget; } - uint32 getItemTargetEntry() const { return m_itemTargetEntry; } - void setItemTarget(Item* item); - void updateTradeSlotItem() - { - if(m_itemTarget && (m_targetMask & TARGET_FLAG_TRADE_ITEM)) - { - m_itemTargetGUID = m_itemTarget->GetGUID(); - m_itemTargetEntry = m_itemTarget->GetEntry(); - } - } - - bool IsEmpty() const { return m_GOTargetGUID==0 && m_unitTargetGUID==0 && m_itemTarget==0 && m_CorpseTargetGUID==0; } - - void Update(Unit* caster); - - float m_srcX, m_srcY, m_srcZ; - float m_destX, m_destY, m_destZ; - std::string m_strTarget; - - uint32 m_targetMask; - private: - // objects (can be used at spell creating and after Update at casting - Unit *m_unitTarget; - GameObject *m_GOTarget; - Item *m_itemTarget; - - // object GUID/etc, can be used always - uint64 m_unitTargetGUID; - uint64 m_GOTargetGUID; - uint64 m_CorpseTargetGUID; - uint64 m_itemTargetGUID; - uint32 m_itemTargetEntry; -}; - -enum SpellState -{ - SPELL_STATE_NULL = 0, - SPELL_STATE_PREPARING = 1, - SPELL_STATE_CASTING = 2, - SPELL_STATE_FINISHED = 3, - SPELL_STATE_IDLE = 4, - SPELL_STATE_DELAYED = 5 -}; - -#define SPELL_SPELL_CHANNEL_UPDATE_INTERVAL 1000 - -typedef std::multimap SpellTargetTimeMap; - -class Spell -{ - friend struct MaNGOS::SpellNotifierPlayer; - friend struct MaNGOS::SpellNotifierCreatureAndPlayer; - public: - - void EffectNULL(uint32 ); - void EffectUnused(uint32 ); - void EffectDistract(uint32 i); - void EffectPull(uint32 i); - void EffectSchoolDMG(uint32 i); - void EffectEnvirinmentalDMG(uint32 i); - void EffectInstaKill(uint32 i); - void EffectDummy(uint32 i); - void EffectTeleportUnits(uint32 i); - void EffectApplyAura(uint32 i); - void EffectSendEvent(uint32 i); - void EffectPowerBurn(uint32 i); - void EffectPowerDrain(uint32 i); - void EffectHeal(uint32 i); - void EffectHealthLeech(uint32 i); - void EffectQuestComplete(uint32 i); - void EffectCreateItem(uint32 i); - void EffectPersistentAA(uint32 i); - void EffectEnergize(uint32 i); - void EffectOpenLock(uint32 i); - void EffectSummonChangeItem(uint32 i); - void EffectOpenSecretSafe(uint32 i); - void EffectProficiency(uint32 i); - void EffectApplyAreaAura(uint32 i); - void EffectSummonType(uint32 i); - void EffectSummon(uint32 i); - void EffectLearnSpell(uint32 i); - void EffectDispel(uint32 i); - void EffectDualWield(uint32 i); - void EffectPickPocket(uint32 i); - void EffectAddFarsight(uint32 i); - void EffectSummonWild(uint32 i); - void EffectSummonGuardian(uint32 i); - void EffectHealMechanical(uint32 i); - void EffectTeleUnitsFaceCaster(uint32 i); - void EffectLearnSkill(uint32 i); - void EffectAddHonor(uint32 i); - void EffectTradeSkill(uint32 i); - void EffectEnchantItemPerm(uint32 i); - void EffectEnchantItemTmp(uint32 i); - void EffectTameCreature(uint32 i); - void EffectSummonPet(uint32 i); - void EffectLearnPetSpell(uint32 i); - void EffectWeaponDmg(uint32 i); - void EffectForceCast(uint32 i); - void EffectTriggerSpell(uint32 i); - void EffectTriggerMissileSpell(uint32 i); - void EffectThreat(uint32 i); - void EffectHealMaxHealth(uint32 i); - void EffectInterruptCast(uint32 i); - void EffectSummonObjectWild(uint32 i); - void EffectScriptEffect(uint32 i); - void EffectSanctuary(uint32 i); - void EffectAddComboPoints(uint32 i); - void EffectDuel(uint32 i); - void EffectStuck(uint32 i); - void EffectSummonPlayer(uint32 i); - void EffectActivateObject(uint32 i); - void EffectSummonTotem(uint32 i); - void EffectEnchantHeldItem(uint32 i); - void EffectSummonObject(uint32 i); - void EffectResurrect(uint32 i); - void EffectParry(uint32 i); - void EffectMomentMove(uint32 i); - void EffectTransmitted(uint32 i); - void EffectDisEnchant(uint32 i); - void EffectInebriate(uint32 i); - void EffectFeedPet(uint32 i); - void EffectDismissPet(uint32 i); - void EffectReputation(uint32 i); - void EffectSelfResurrect(uint32 i); - void EffectSkinning(uint32 i); - void EffectCharge(uint32 i); - void EffectProspecting(uint32 i); - void EffectSendTaxi(uint32 i); - void EffectSummonCritter(uint32 i); - void EffectKnockBack(uint32 i); - void EffectPlayerPull(uint32 i); - void EffectDispelMechanic(uint32 i); - void EffectSummonDeadPet(uint32 i); - void EffectDestroyAllTotems(uint32 i); - void EffectDurabilityDamage(uint32 i); - void EffectSkill(uint32 i); - void EffectTaunt(uint32 i); - void EffectDurabilityDamagePCT(uint32 i); - void EffectModifyThreatPercent(uint32 i); - void EffectResurrectNew(uint32 i); - void EffectAddExtraAttacks(uint32 i); - void EffectSpiritHeal(uint32 i); - void EffectSkinPlayerCorpse(uint32 i); - void EffectSummonDemon(uint32 i); - void EffectStealBeneficialBuff(uint32 i); - void EffectUnlearnSpecialization(uint32 i); - void EffectHealPct(uint32 i); - void EffectEnergisePct(uint32 i); - void EffectTriggerSpellWithValue(uint32 i); - void EffectTriggerRitualOfSummoning(uint32 i); - void EffectKillCredit(uint32 i); - void EffectQuestFail(uint32 i); - - Spell( Unit* Caster, SpellEntry const *info, bool triggered, uint64 originalCasterGUID = 0, Spell** triggeringContainer = NULL ); - ~Spell(); - - void prepare(SpellCastTargets * targets, Aura* triggeredByAura = NULL); - void cancel(); - void update(uint32 difftime); - void cast(bool skipCheck = false); - void finish(bool ok = true); - void TakePower(); - void TakeReagents(); - void TakeCastItem(); - void TriggerSpell(); - uint8 CanCast(bool strict); - int16 PetCanCast(Unit* target); - bool CanAutoCast(Unit* target); - - // handlers - void handle_immediate(); - uint64 handle_delayed(uint64 t_offset); - // handler helpers - void _handle_immediate_phase(); - void _handle_finish_phase(); - - uint8 CheckItems(); - uint8 CheckRange(bool strict); - uint8 CheckPower(); - uint8 CheckCasterAuras() const; - - int32 CalculateDamage(uint8 i, Unit* target) { return m_caster->CalculateSpellDamage(m_spellInfo,i,m_currentBasePoints[i],target); } - int32 CalculatePowerCost(); - - bool HaveTargetsForEffect(uint8 effect) const; - void Delayed(); - void DelayedChannel(); - inline uint32 getState() const { return m_spellState; } - void setState(uint32 state) { m_spellState = state; } - - void DoCreateItem(uint32 i, uint32 itemtype); - - void WriteSpellGoTargets( WorldPacket * data ); - void WriteAmmoToPacket( WorldPacket * data ); - void FillTargetMap(); - - void SetTargetMap(uint32 i,uint32 cur,std::list &TagUnitMap); - - Unit* SelectMagnetTarget(); - bool CheckTarget( Unit* target, uint32 eff, bool hitPhase ); - - void SendCastResult(uint8 result); - void SendSpellStart(); - void SendSpellGo(); - void SendSpellCooldown(); - void SendLogExecute(); - void SendInterrupted(uint8 result); - void SendChannelUpdate(uint32 time); - void SendChannelStart(uint32 duration); - void SendResurrectRequest(Player* target); - void SendPlaySpellVisual(uint32 SpellID); - - void HandleEffects(Unit *pUnitTarget,Item *pItemTarget,GameObject *pGOTarget,uint32 i, float DamageMultiplier = 1.0); - void HandleThreatSpells(uint32 spellId); - //void HandleAddAura(Unit* Target); - - SpellEntry const* m_spellInfo; - int32 m_currentBasePoints[3]; // cache SpellEntry::EffectBasePoints and use for set custom base points - Item* m_CastItem; - uint8 m_cast_count; - SpellCastTargets m_targets; - - int32 GetCastTime() const { return m_casttime; } - bool IsAutoRepeat() const { return m_autoRepeat; } - void SetAutoRepeat(bool rep) { m_autoRepeat = rep; } - void ReSetTimer() { m_timer = m_casttime > 0 ? m_casttime : 0; } - bool IsNextMeleeSwingSpell() const - { - return m_spellInfo->Attributes & (SPELL_ATTR_ON_NEXT_SWING_1|SPELL_ATTR_ON_NEXT_SWING_2); - } - bool IsRangedSpell() const - { - return m_spellInfo->Attributes & SPELL_ATTR_RANGED; - } - bool IsChannelActive() const { return m_caster->GetUInt32Value(UNIT_CHANNEL_SPELL) != 0; } - bool IsMeleeAttackResetSpell() const { return !m_IsTriggeredSpell && (m_spellInfo->InterruptFlags & SPELL_INTERRUPT_FLAG_AUTOATTACK); } - bool IsRangedAttackResetSpell() const { return !m_IsTriggeredSpell && IsRangedSpell() && (m_spellInfo->InterruptFlags & SPELL_INTERRUPT_FLAG_AUTOATTACK); } - - bool IsDeletable() const { return m_deletable; } - void SetDeletable(bool deletable) { m_deletable = deletable; } - uint64 GetDelayStart() const { return m_delayStart; } - void SetDelayStart(uint64 m_time) { m_delayStart = m_time; } - uint64 GetDelayMoment() const { return m_delayMoment; } - - bool IsNeedSendToClient() const; - - CurrentSpellTypes GetCurrentContainer(); - - Unit* GetCaster() const { return m_caster; } - Unit* GetOriginalCaster() const { return m_originalCaster; } - int32 GetPowerCost() const { return m_powerCost; } - - void UpdatePointers(); // must be used at call Spell code after time delay (non triggered spell cast/update spell call/etc) - - bool IsAffectedBy(SpellEntry const *spellInfo, uint32 effectId); - - bool CheckTargetCreatureType(Unit* target) const; - - void AddTriggeredSpell(SpellEntry const* spell) { m_TriggerSpells.push_back(spell); } - - void CleanupTargetList(); - protected: - - void SendLoot(uint64 guid, LootType loottype); - - Unit* m_caster; - - uint64 m_originalCasterGUID; // real source of cast (aura caster/etc), used for spell targets selection - // e.g. damage around area spell trigered by victim aura and da,age emeies of aura caster - Unit* m_originalCaster; // cached pointer for m_originalCaster, updated at Spell::UpdatePointers() - - Spell** m_selfContainer; // pointer to our spell container (if applicable) - Spell** m_triggeringContainer; // pointer to container with spell that has triggered us - - //Spell data - SpellSchoolMask m_spellSchoolMask; // Spell school (can be overwrite for some spells (wand shoot for example) - WeaponAttackType m_attackType; // For weapon based attack - int32 m_powerCost; // Calculated spell cost initialized only in Spell::prepare - int32 m_casttime; // Calculated spell cast time initialized only in Spell::prepare - bool m_canReflect; // can reflect this spell? - bool m_autoRepeat; - - uint8 m_delayAtDamageCount; - int32 GetNextDelayAtDamageMsTime() { return m_delayAtDamageCount < 5 ? 1000 - (m_delayAtDamageCount++)* 200 : 200; } - - // Delayed spells system - uint64 m_delayStart; // time of spell delay start, filled by event handler, zero = just started - uint64 m_delayMoment; // moment of next delay call, used internally - bool m_immediateHandled; // were immediate actions handled? (used by delayed spells only) - - // These vars are used in both delayed spell system and modified immediate spell system - bool m_deletable; // is the spell pending deletion or must be updated till permitted to delete? - bool m_needSpellLog; // need to send spell log? - uint8 m_applyMultiplierMask; // by effect: damage multiplier needed? - float m_damageMultipliers[3]; // by effect: damage multiplier - - // Current targets, to be used in SpellEffects (MUST BE USED ONLY IN SPELL EFFECTS) - Unit* unitTarget; - Item* itemTarget; - GameObject* gameObjTarget; - int32 damage; - - // this is set in Spell Hit, but used in Apply Aura handler - DiminishingLevels m_diminishLevel; - DiminishingGroup m_diminishGroup; - - // ------------------------------------------- - GameObject* focusObject; - - //****************************************** - // Spell trigger system - //****************************************** - void doTriggers(SpellMissInfo missInfo, uint32 damage=0, SpellSchoolMask damageSchoolMask = SPELL_SCHOOL_MASK_NONE, uint32 block=0, uint32 absorb=0, bool crit=false); - - //***************************************** - // Spell target subsystem - //***************************************** - // Targets store structures and data - uint32 m_countOfHit; - uint32 m_countOfMiss; - struct TargetInfo - { - uint64 targetGUID; - uint64 timeDelay; - SpellMissInfo missCondition:8; - SpellMissInfo reflectResult:8; - uint8 effectMask:8; - bool processed:1; - }; - std::list m_UniqueTargetInfo; - uint8 m_needAliveTargetMask; // Mask req. alive targets - - struct GOTargetInfo - { - uint64 targetGUID; - uint64 timeDelay; - uint8 effectMask:8; - bool processed:1; - }; - std::list m_UniqueGOTargetInfo; - - struct ItemTargetInfo - { - Item *item; - uint8 effectMask; - }; - std::list m_UniqueItemInfo; - - void AddUnitTarget(Unit* target, uint32 effIndex); - void AddUnitTarget(uint64 unitGUID, uint32 effIndex); - void AddGOTarget(GameObject* target, uint32 effIndex); - void AddGOTarget(uint64 goGUID, uint32 effIndex); - void AddItemTarget(Item* target, uint32 effIndex); - void DoAllEffectOnTarget(TargetInfo *target); - void DoSpellHitOnUnit(Unit *unit, uint32 effectMask); - void DoAllEffectOnTarget(GOTargetInfo *target); - void DoAllEffectOnTarget(ItemTargetInfo *target); - bool IsAliveUnitPresentInTargetList(); - // ------------------------------------------- - - //List For Triggered Spells - typedef std::list TriggerSpells; - TriggerSpells m_TriggerSpells; - - uint32 m_spellState; - uint32 m_timer; - - float m_castPositionX; - float m_castPositionY; - float m_castPositionZ; - float m_castOrientation; - bool m_IsTriggeredSpell; - - // if need this can be replaced by Aura copy - // we can't store original aura link to prevent access to deleted auras - // and in same time need aura data and after aura deleting. - SpellEntry const* m_triggeredByAuraSpell; -}; - -enum ReplenishType -{ - REPLENISH_UNDEFINED = 0, - REPLENISH_HEALTH = 20, - REPLENISH_MANA = 21, - REPLENISH_RAGE = 22 -}; - -enum SpellTargets -{ - SPELL_TARGETS_HOSTILE, - SPELL_TARGETS_NOT_FRIENDLY, - SPELL_TARGETS_NOT_HOSTILE, - SPELL_TARGETS_FRIENDLY, - SPELL_TARGETS_AOE_DAMAGE -}; - -namespace MaNGOS -{ - struct MANGOS_DLL_DECL SpellNotifierPlayer - { - std::list &i_data; - Spell &i_spell; - const uint32& i_index; - float i_radius; - Unit* i_originalCaster; - - SpellNotifierPlayer(Spell &spell, std::list &data, const uint32 &i, float radius) - : i_data(data), i_spell(spell), i_index(i), i_radius(radius) - { - i_originalCaster = i_spell.GetOriginalCaster(); - } - - void Visit(PlayerMapType &m) - { - if(!i_originalCaster) - return; - - for(PlayerMapType::iterator itr=m.begin(); itr != m.end(); ++itr) - { - Player * pPlayer = itr->getSource(); - if( !pPlayer->isAlive() || pPlayer->isInFlight()) - continue; - - if( i_originalCaster->IsFriendlyTo(pPlayer) ) - continue; - - if( pPlayer->GetDistance(i_spell.m_targets.m_destX, i_spell.m_targets.m_destY, i_spell.m_targets.m_destZ) < i_radius ) - i_data.push_back(pPlayer); - } - } - template void Visit(GridRefManager &) {} - }; - - struct MANGOS_DLL_DECL SpellNotifierCreatureAndPlayer - { - std::list *i_data; - Spell &i_spell; - const uint32& i_push_type; - float i_radius; - SpellTargets i_TargetType; - Unit* i_originalCaster; - - SpellNotifierCreatureAndPlayer(Spell &spell, std::list &data, float radius, const uint32 &type, - SpellTargets TargetType = SPELL_TARGETS_NOT_FRIENDLY) - : i_data(&data), i_spell(spell), i_push_type(type), i_radius(radius), i_TargetType(TargetType) - { - i_originalCaster = spell.GetOriginalCaster(); - } - - template inline void Visit(GridRefManager &m) - { - assert(i_data); - - if(!i_originalCaster) - return; - - for(typename GridRefManager::iterator itr = m.begin(); itr != m.end(); ++itr) - { - if( !itr->getSource()->isAlive() || (itr->getSource()->GetTypeId() == TYPEID_PLAYER && ((Player*)itr->getSource())->isInFlight())) - continue; - - switch (i_TargetType) - { - case SPELL_TARGETS_HOSTILE: - if (!itr->getSource()->isTargetableForAttack() || !i_originalCaster->IsHostileTo( itr->getSource() )) - continue; - break; - case SPELL_TARGETS_NOT_FRIENDLY: - if (!itr->getSource()->isTargetableForAttack() || i_originalCaster->IsFriendlyTo( itr->getSource() )) - continue; - break; - case SPELL_TARGETS_NOT_HOSTILE: - if (!itr->getSource()->isTargetableForAttack() || i_originalCaster->IsHostileTo( itr->getSource() )) - continue; - break; - case SPELL_TARGETS_FRIENDLY: - if (!itr->getSource()->isTargetableForAttack() || !i_originalCaster->IsFriendlyTo( itr->getSource() )) - continue; - break; - case SPELL_TARGETS_AOE_DAMAGE: - { - if(itr->getSource()->GetTypeId()==TYPEID_UNIT && ((Creature*)itr->getSource())->isTotem()) - continue; - if(!itr->getSource()->isTargetableForAttack()) - continue; - - Unit* check = i_originalCaster->GetCharmerOrOwnerOrSelf(); - - if( check->GetTypeId()==TYPEID_PLAYER ) - { - if (check->IsFriendlyTo( itr->getSource() )) - continue; - } - else - { - if (!check->IsHostileTo( itr->getSource() )) - continue; - } - } - break; - default: continue; - } - - switch(i_push_type) - { - case PUSH_IN_FRONT: - if(i_spell.GetCaster()->isInFront((Unit*)(itr->getSource()), i_radius, 2*M_PI/3 )) - i_data->push_back(itr->getSource()); - break; - case PUSH_IN_BACK: - if(i_spell.GetCaster()->isInBack((Unit*)(itr->getSource()), i_radius, 2*M_PI/3 )) - i_data->push_back(itr->getSource()); - break; - case PUSH_SELF_CENTER: - if(i_spell.GetCaster()->IsWithinDistInMap((Unit*)(itr->getSource()), i_radius)) - i_data->push_back(itr->getSource()); - break; - case PUSH_DEST_CENTER: - if((itr->getSource()->GetDistance(i_spell.m_targets.m_destX, i_spell.m_targets.m_destY, i_spell.m_targets.m_destZ) < i_radius )) - i_data->push_back(itr->getSource()); - break; - case PUSH_TARGET_CENTER: - if(i_spell.m_targets.getUnitTarget()->IsWithinDistInMap((Unit*)(itr->getSource()), i_radius)) - i_data->push_back(itr->getSource()); - break; - } - } - } - - #ifdef WIN32 - template<> inline void Visit(CorpseMapType & ) {} - template<> inline void Visit(GameObjectMapType & ) {} - template<> inline void Visit(DynamicObjectMapType & ) {} - #endif - }; - - #ifndef WIN32 - template<> inline void SpellNotifierCreatureAndPlayer::Visit(CorpseMapType& ) {} - template<> inline void SpellNotifierCreatureAndPlayer::Visit(GameObjectMapType& ) {} - template<> inline void SpellNotifierCreatureAndPlayer::Visit(DynamicObjectMapType& ) {} - #endif -} - -typedef void(Spell::*pEffect)(uint32 i); - -class SpellEvent : public BasicEvent -{ - public: - SpellEvent(Spell* spell); - virtual ~SpellEvent(); - - virtual bool Execute(uint64 e_time, uint32 p_time); - virtual void Abort(uint64 e_time); - protected: - Spell* m_Spell; -}; -#endif +/* + * Copyright (C) 2005-2008 MaNGOS + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef __SPELL_H +#define __SPELL_H + +#include "GridDefines.h" + +class WorldSession; +class Unit; +class DynamicObj; +class Player; +class GameObject; +class Group; +class Aura; + +enum SpellCastTargetFlags +{ + /*TARGET_FLAG_NONE = 0x0000, + TARGET_FLAG_SWIMMER = 0x0002, + TARGET_FLAG_ITEM = 0x0010, + TARGET_FLAG_SOURCE_AREA = 0x0020, + TARGET_FLAG_DEST_AREA = 0x0040, + TARGET_FLAG_UNKNOWN = 0x0080, + TARGET_FLAG_SELF = 0x0100, + TARGET_FLAG_PVP_CORPSE = 0x0200, + TARGET_FLAG_MASS_SPIRIT_HEAL = 0x0400, + TARGET_FLAG_BEAST_CORPSE = 0x0402, + TARGET_FLAG_OBJECT = 0x4000, + TARGET_FLAG_RESURRECTABLE = 0x8000*/ + + TARGET_FLAG_SELF = 0x00000000, + TARGET_FLAG_UNIT = 0x00000002, // pguid + TARGET_FLAG_ITEM = 0x00000010, // pguid + TARGET_FLAG_SOURCE_LOCATION = 0x00000020, // 3 float + TARGET_FLAG_DEST_LOCATION = 0x00000040, // 3 float + TARGET_FLAG_OBJECT_UNK = 0x00000080, // ? + TARGET_FLAG_PVP_CORPSE = 0x00000200, // pguid + TARGET_FLAG_OBJECT = 0x00000800, // pguid + TARGET_FLAG_TRADE_ITEM = 0x00001000, // pguid + TARGET_FLAG_STRING = 0x00002000, // string + TARGET_FLAG_UNK1 = 0x00004000, // ? + TARGET_FLAG_CORPSE = 0x00008000, // pguid + TARGET_FLAG_UNK2 = 0x00010000 // pguid +}; + +enum SpellCastFlags +{ + CAST_FLAG_UNKNOWN1 = 0x00000002, + CAST_FLAG_UNKNOWN2 = 0x00000010, + CAST_FLAG_AMMO = 0x00000020, + CAST_FLAG_UNKNOWN3 = 0x00000100 +}; + +enum SpellNotifyPushType +{ + PUSH_IN_FRONT, + PUSH_IN_BACK, + PUSH_SELF_CENTER, + PUSH_DEST_CENTER, + PUSH_TARGET_CENTER +}; + +bool IsQuestTameSpell(uint32 spellId); + +namespace MaNGOS +{ + struct SpellNotifierPlayer; + struct SpellNotifierCreatureAndPlayer; +} + +class SpellCastTargets +{ + public: + SpellCastTargets(); + ~SpellCastTargets(); + + bool read ( WorldPacket * data, Unit *caster ); + void write ( WorldPacket * data ); + + SpellCastTargets& operator=(const SpellCastTargets &target) + { + m_unitTarget = target.m_unitTarget; + m_itemTarget = target.m_itemTarget; + m_GOTarget = target.m_GOTarget; + + m_unitTargetGUID = target.m_unitTargetGUID; + m_GOTargetGUID = target.m_GOTargetGUID; + m_CorpseTargetGUID = target.m_CorpseTargetGUID; + m_itemTargetGUID = target.m_itemTargetGUID; + + m_itemTargetEntry = target.m_itemTargetEntry; + + m_srcX = target.m_srcX; + m_srcY = target.m_srcY; + m_srcZ = target.m_srcZ; + + m_destX = target.m_destX; + m_destY = target.m_destY; + m_destZ = target.m_destZ; + + m_strTarget = target.m_strTarget; + + m_targetMask = target.m_targetMask; + + return *this; + } + + uint64 getUnitTargetGUID() const { return m_unitTargetGUID; } + Unit *getUnitTarget() const { return m_unitTarget; } + void setUnitTarget(Unit *target); + void setDestination(float x, float y, float z); + + uint64 getGOTargetGUID() const { return m_GOTargetGUID; } + GameObject *getGOTarget() const { return m_GOTarget; } + void setGOTarget(GameObject *target); + + uint64 getCorpseTargetGUID() const { return m_CorpseTargetGUID; } + void setCorpseTarget(Corpse* corpse); + uint64 getItemTargetGUID() const { return m_itemTargetGUID; } + Item* getItemTarget() const { return m_itemTarget; } + uint32 getItemTargetEntry() const { return m_itemTargetEntry; } + void setItemTarget(Item* item); + void updateTradeSlotItem() + { + if(m_itemTarget && (m_targetMask & TARGET_FLAG_TRADE_ITEM)) + { + m_itemTargetGUID = m_itemTarget->GetGUID(); + m_itemTargetEntry = m_itemTarget->GetEntry(); + } + } + + bool IsEmpty() const { return m_GOTargetGUID==0 && m_unitTargetGUID==0 && m_itemTarget==0 && m_CorpseTargetGUID==0; } + + void Update(Unit* caster); + + float m_srcX, m_srcY, m_srcZ; + float m_destX, m_destY, m_destZ; + std::string m_strTarget; + + uint32 m_targetMask; + private: + // objects (can be used at spell creating and after Update at casting + Unit *m_unitTarget; + GameObject *m_GOTarget; + Item *m_itemTarget; + + // object GUID/etc, can be used always + uint64 m_unitTargetGUID; + uint64 m_GOTargetGUID; + uint64 m_CorpseTargetGUID; + uint64 m_itemTargetGUID; + uint32 m_itemTargetEntry; +}; + +enum SpellState +{ + SPELL_STATE_NULL = 0, + SPELL_STATE_PREPARING = 1, + SPELL_STATE_CASTING = 2, + SPELL_STATE_FINISHED = 3, + SPELL_STATE_IDLE = 4, + SPELL_STATE_DELAYED = 5 +}; + +#define SPELL_SPELL_CHANNEL_UPDATE_INTERVAL 1000 + +typedef std::multimap SpellTargetTimeMap; + +class Spell +{ + friend struct MaNGOS::SpellNotifierPlayer; + friend struct MaNGOS::SpellNotifierCreatureAndPlayer; + public: + + void EffectNULL(uint32 ); + void EffectUnused(uint32 ); + void EffectDistract(uint32 i); + void EffectPull(uint32 i); + void EffectSchoolDMG(uint32 i); + void EffectEnvirinmentalDMG(uint32 i); + void EffectInstaKill(uint32 i); + void EffectDummy(uint32 i); + void EffectTeleportUnits(uint32 i); + void EffectApplyAura(uint32 i); + void EffectSendEvent(uint32 i); + void EffectPowerBurn(uint32 i); + void EffectPowerDrain(uint32 i); + void EffectHeal(uint32 i); + void EffectHealthLeech(uint32 i); + void EffectQuestComplete(uint32 i); + void EffectCreateItem(uint32 i); + void EffectPersistentAA(uint32 i); + void EffectEnergize(uint32 i); + void EffectOpenLock(uint32 i); + void EffectSummonChangeItem(uint32 i); + void EffectOpenSecretSafe(uint32 i); + void EffectProficiency(uint32 i); + void EffectApplyAreaAura(uint32 i); + void EffectSummonType(uint32 i); + void EffectSummon(uint32 i); + void EffectLearnSpell(uint32 i); + void EffectDispel(uint32 i); + void EffectDualWield(uint32 i); + void EffectPickPocket(uint32 i); + void EffectAddFarsight(uint32 i); + void EffectSummonWild(uint32 i); + void EffectSummonGuardian(uint32 i); + void EffectHealMechanical(uint32 i); + void EffectTeleUnitsFaceCaster(uint32 i); + void EffectLearnSkill(uint32 i); + void EffectAddHonor(uint32 i); + void EffectTradeSkill(uint32 i); + void EffectEnchantItemPerm(uint32 i); + void EffectEnchantItemTmp(uint32 i); + void EffectTameCreature(uint32 i); + void EffectSummonPet(uint32 i); + void EffectLearnPetSpell(uint32 i); + void EffectWeaponDmg(uint32 i); + void EffectForceCast(uint32 i); + void EffectTriggerSpell(uint32 i); + void EffectTriggerMissileSpell(uint32 i); + void EffectThreat(uint32 i); + void EffectHealMaxHealth(uint32 i); + void EffectInterruptCast(uint32 i); + void EffectSummonObjectWild(uint32 i); + void EffectScriptEffect(uint32 i); + void EffectSanctuary(uint32 i); + void EffectAddComboPoints(uint32 i); + void EffectDuel(uint32 i); + void EffectStuck(uint32 i); + void EffectSummonPlayer(uint32 i); + void EffectActivateObject(uint32 i); + void EffectSummonTotem(uint32 i); + void EffectEnchantHeldItem(uint32 i); + void EffectSummonObject(uint32 i); + void EffectResurrect(uint32 i); + void EffectParry(uint32 i); + void EffectBlock(uint32 i); + void EffectMomentMove(uint32 i); + void EffectTransmitted(uint32 i); + void EffectDisEnchant(uint32 i); + void EffectInebriate(uint32 i); + void EffectFeedPet(uint32 i); + void EffectDismissPet(uint32 i); + void EffectReputation(uint32 i); + void EffectSelfResurrect(uint32 i); + void EffectSkinning(uint32 i); + void EffectCharge(uint32 i); + void EffectProspecting(uint32 i); + void EffectSendTaxi(uint32 i); + void EffectSummonCritter(uint32 i); + void EffectKnockBack(uint32 i); + void EffectPlayerPull(uint32 i); + void EffectDispelMechanic(uint32 i); + void EffectSummonDeadPet(uint32 i); + void EffectDestroyAllTotems(uint32 i); + void EffectDurabilityDamage(uint32 i); + void EffectSkill(uint32 i); + void EffectTaunt(uint32 i); + void EffectDurabilityDamagePCT(uint32 i); + void EffectModifyThreatPercent(uint32 i); + void EffectResurrectNew(uint32 i); + void EffectAddExtraAttacks(uint32 i); + void EffectSpiritHeal(uint32 i); + void EffectSkinPlayerCorpse(uint32 i); + void EffectSummonDemon(uint32 i); + void EffectStealBeneficialBuff(uint32 i); + void EffectUnlearnSpecialization(uint32 i); + void EffectHealPct(uint32 i); + void EffectEnergisePct(uint32 i); + void EffectTriggerSpellWithValue(uint32 i); + void EffectTriggerRitualOfSummoning(uint32 i); + void EffectKillCredit(uint32 i); + void EffectQuestFail(uint32 i); + + Spell( Unit* Caster, SpellEntry const *info, bool triggered, uint64 originalCasterGUID = 0, Spell** triggeringContainer = NULL ); + ~Spell(); + + void prepare(SpellCastTargets * targets, Aura* triggeredByAura = NULL); + void cancel(); + void update(uint32 difftime); + void cast(bool skipCheck = false); + void finish(bool ok = true); + void TakePower(); + void TakeReagents(); + void TakeCastItem(); + void TriggerSpell(); + uint8 CanCast(bool strict); + int16 PetCanCast(Unit* target); + bool CanAutoCast(Unit* target); + + // handlers + void handle_immediate(); + uint64 handle_delayed(uint64 t_offset); + // handler helpers + void _handle_immediate_phase(); + void _handle_finish_phase(); + + uint8 CheckItems(); + uint8 CheckRange(bool strict); + uint8 CheckPower(); + uint8 CheckCasterAuras() const; + + int32 CalculateDamage(uint8 i, Unit* target) { return m_caster->CalculateSpellDamage(m_spellInfo,i,m_currentBasePoints[i],target); } + int32 CalculatePowerCost(); + + bool HaveTargetsForEffect(uint8 effect) const; + void Delayed(); + void DelayedChannel(); + inline uint32 getState() const { return m_spellState; } + void setState(uint32 state) { m_spellState = state; } + + void DoCreateItem(uint32 i, uint32 itemtype); + + void WriteSpellGoTargets( WorldPacket * data ); + void WriteAmmoToPacket( WorldPacket * data ); + void FillTargetMap(); + + void SetTargetMap(uint32 i,uint32 cur,std::list &TagUnitMap); + + Unit* SelectMagnetTarget(); + bool CheckTarget( Unit* target, uint32 eff, bool hitPhase ); + + void SendCastResult(uint8 result); + void SendSpellStart(); + void SendSpellGo(); + void SendSpellCooldown(); + void SendLogExecute(); + void SendInterrupted(uint8 result); + void SendChannelUpdate(uint32 time); + void SendChannelStart(uint32 duration); + void SendResurrectRequest(Player* target); + void SendPlaySpellVisual(uint32 SpellID); + + void HandleEffects(Unit *pUnitTarget,Item *pItemTarget,GameObject *pGOTarget,uint32 i, float DamageMultiplier = 1.0); + void HandleThreatSpells(uint32 spellId); + //void HandleAddAura(Unit* Target); + + SpellEntry const* m_spellInfo; + int32 m_currentBasePoints[3]; // cache SpellEntry::EffectBasePoints and use for set custom base points + Item* m_CastItem; + uint8 m_cast_count; + SpellCastTargets m_targets; + + int32 GetCastTime() const { return m_casttime; } + bool IsAutoRepeat() const { return m_autoRepeat; } + void SetAutoRepeat(bool rep) { m_autoRepeat = rep; } + void ReSetTimer() { m_timer = m_casttime > 0 ? m_casttime : 0; } + bool IsNextMeleeSwingSpell() const + { + return m_spellInfo->Attributes & (SPELL_ATTR_ON_NEXT_SWING_1|SPELL_ATTR_ON_NEXT_SWING_2); + } + bool IsRangedSpell() const + { + return m_spellInfo->Attributes & SPELL_ATTR_RANGED; + } + bool IsChannelActive() const { return m_caster->GetUInt32Value(UNIT_CHANNEL_SPELL) != 0; } + bool IsMeleeAttackResetSpell() const { return !m_IsTriggeredSpell && (m_spellInfo->InterruptFlags & SPELL_INTERRUPT_FLAG_AUTOATTACK); } + bool IsRangedAttackResetSpell() const { return !m_IsTriggeredSpell && IsRangedSpell() && (m_spellInfo->InterruptFlags & SPELL_INTERRUPT_FLAG_AUTOATTACK); } + + bool IsDeletable() const { return m_deletable; } + void SetDeletable(bool deletable) { m_deletable = deletable; } + uint64 GetDelayStart() const { return m_delayStart; } + void SetDelayStart(uint64 m_time) { m_delayStart = m_time; } + uint64 GetDelayMoment() const { return m_delayMoment; } + + bool IsNeedSendToClient() const; + + CurrentSpellTypes GetCurrentContainer(); + + Unit* GetCaster() const { return m_caster; } + Unit* GetOriginalCaster() const { return m_originalCaster; } + int32 GetPowerCost() const { return m_powerCost; } + + void UpdatePointers(); // must be used at call Spell code after time delay (non triggered spell cast/update spell call/etc) + + bool IsAffectedBy(SpellEntry const *spellInfo, uint32 effectId); + + bool CheckTargetCreatureType(Unit* target) const; + + void AddTriggeredSpell(SpellEntry const* spell) { m_TriggerSpells.push_back(spell); } + + void CleanupTargetList(); + protected: + + void SendLoot(uint64 guid, LootType loottype); + + Unit* m_caster; + + uint64 m_originalCasterGUID; // real source of cast (aura caster/etc), used for spell targets selection + // e.g. damage around area spell trigered by victim aura and da,age emeies of aura caster + Unit* m_originalCaster; // cached pointer for m_originalCaster, updated at Spell::UpdatePointers() + + Spell** m_selfContainer; // pointer to our spell container (if applicable) + Spell** m_triggeringContainer; // pointer to container with spell that has triggered us + + //Spell data + SpellSchoolMask m_spellSchoolMask; // Spell school (can be overwrite for some spells (wand shoot for example) + WeaponAttackType m_attackType; // For weapon based attack + int32 m_powerCost; // Calculated spell cost initialized only in Spell::prepare + int32 m_casttime; // Calculated spell cast time initialized only in Spell::prepare + bool m_canReflect; // can reflect this spell? + bool m_autoRepeat; + + uint8 m_delayAtDamageCount; + int32 GetNextDelayAtDamageMsTime() { return m_delayAtDamageCount < 5 ? 1000 - (m_delayAtDamageCount++)* 200 : 200; } + + // Delayed spells system + uint64 m_delayStart; // time of spell delay start, filled by event handler, zero = just started + uint64 m_delayMoment; // moment of next delay call, used internally + bool m_immediateHandled; // were immediate actions handled? (used by delayed spells only) + + // These vars are used in both delayed spell system and modified immediate spell system + bool m_deletable; // is the spell pending deletion or must be updated till permitted to delete? + bool m_needSpellLog; // need to send spell log? + uint8 m_applyMultiplierMask; // by effect: damage multiplier needed? + float m_damageMultipliers[3]; // by effect: damage multiplier + + // Current targets, to be used in SpellEffects (MUST BE USED ONLY IN SPELL EFFECTS) + Unit* unitTarget; + Item* itemTarget; + GameObject* gameObjTarget; + int32 damage; + + // this is set in Spell Hit, but used in Apply Aura handler + DiminishingLevels m_diminishLevel; + DiminishingGroup m_diminishGroup; + + // ------------------------------------------- + GameObject* focusObject; + + //****************************************** + // Spell trigger system + //****************************************** + void doTriggers(SpellMissInfo missInfo, uint32 damage=0, SpellSchoolMask damageSchoolMask = SPELL_SCHOOL_MASK_NONE, uint32 block=0, uint32 absorb=0, bool crit=false); + + //***************************************** + // Spell target subsystem + //***************************************** + // Targets store structures and data + uint32 m_countOfHit; + uint32 m_countOfMiss; + struct TargetInfo + { + uint64 targetGUID; + uint64 timeDelay; + SpellMissInfo missCondition:8; + SpellMissInfo reflectResult:8; + uint8 effectMask:8; + bool processed:1; + }; + std::list m_UniqueTargetInfo; + uint8 m_needAliveTargetMask; // Mask req. alive targets + + struct GOTargetInfo + { + uint64 targetGUID; + uint64 timeDelay; + uint8 effectMask:8; + bool processed:1; + }; + std::list m_UniqueGOTargetInfo; + + struct ItemTargetInfo + { + Item *item; + uint8 effectMask; + }; + std::list m_UniqueItemInfo; + + void AddUnitTarget(Unit* target, uint32 effIndex); + void AddUnitTarget(uint64 unitGUID, uint32 effIndex); + void AddGOTarget(GameObject* target, uint32 effIndex); + void AddGOTarget(uint64 goGUID, uint32 effIndex); + void AddItemTarget(Item* target, uint32 effIndex); + void DoAllEffectOnTarget(TargetInfo *target); + void DoSpellHitOnUnit(Unit *unit, uint32 effectMask); + void DoAllEffectOnTarget(GOTargetInfo *target); + void DoAllEffectOnTarget(ItemTargetInfo *target); + bool IsAliveUnitPresentInTargetList(); + // ------------------------------------------- + + //List For Triggered Spells + typedef std::list TriggerSpells; + TriggerSpells m_TriggerSpells; + + uint32 m_spellState; + uint32 m_timer; + + float m_castPositionX; + float m_castPositionY; + float m_castPositionZ; + float m_castOrientation; + bool m_IsTriggeredSpell; + + // if need this can be replaced by Aura copy + // we can't store original aura link to prevent access to deleted auras + // and in same time need aura data and after aura deleting. + SpellEntry const* m_triggeredByAuraSpell; +}; + +enum ReplenishType +{ + REPLENISH_UNDEFINED = 0, + REPLENISH_HEALTH = 20, + REPLENISH_MANA = 21, + REPLENISH_RAGE = 22 +}; + +enum SpellTargets +{ + SPELL_TARGETS_HOSTILE, + SPELL_TARGETS_NOT_FRIENDLY, + SPELL_TARGETS_NOT_HOSTILE, + SPELL_TARGETS_FRIENDLY, + SPELL_TARGETS_AOE_DAMAGE +}; + +namespace MaNGOS +{ + struct MANGOS_DLL_DECL SpellNotifierPlayer + { + std::list &i_data; + Spell &i_spell; + const uint32& i_index; + float i_radius; + Unit* i_originalCaster; + + SpellNotifierPlayer(Spell &spell, std::list &data, const uint32 &i, float radius) + : i_data(data), i_spell(spell), i_index(i), i_radius(radius) + { + i_originalCaster = i_spell.GetOriginalCaster(); + } + + void Visit(PlayerMapType &m) + { + if(!i_originalCaster) + return; + + for(PlayerMapType::iterator itr=m.begin(); itr != m.end(); ++itr) + { + Player * pPlayer = itr->getSource(); + if( !pPlayer->isAlive() || pPlayer->isInFlight()) + continue; + + if( i_originalCaster->IsFriendlyTo(pPlayer) ) + continue; + + if( pPlayer->GetDistance(i_spell.m_targets.m_destX, i_spell.m_targets.m_destY, i_spell.m_targets.m_destZ) < i_radius ) + i_data.push_back(pPlayer); + } + } + template void Visit(GridRefManager &) {} + }; + + struct MANGOS_DLL_DECL SpellNotifierCreatureAndPlayer + { + std::list *i_data; + Spell &i_spell; + const uint32& i_push_type; + float i_radius; + SpellTargets i_TargetType; + Unit* i_originalCaster; + + SpellNotifierCreatureAndPlayer(Spell &spell, std::list &data, float radius, const uint32 &type, + SpellTargets TargetType = SPELL_TARGETS_NOT_FRIENDLY) + : i_data(&data), i_spell(spell), i_push_type(type), i_radius(radius), i_TargetType(TargetType) + { + i_originalCaster = spell.GetOriginalCaster(); + } + + template inline void Visit(GridRefManager &m) + { + assert(i_data); + + if(!i_originalCaster) + return; + + for(typename GridRefManager::iterator itr = m.begin(); itr != m.end(); ++itr) + { + if( !itr->getSource()->isAlive() || (itr->getSource()->GetTypeId() == TYPEID_PLAYER && ((Player*)itr->getSource())->isInFlight())) + continue; + + switch (i_TargetType) + { + case SPELL_TARGETS_HOSTILE: + if (!itr->getSource()->isTargetableForAttack() || !i_originalCaster->IsHostileTo( itr->getSource() )) + continue; + break; + case SPELL_TARGETS_NOT_FRIENDLY: + if (!itr->getSource()->isTargetableForAttack() || i_originalCaster->IsFriendlyTo( itr->getSource() )) + continue; + break; + case SPELL_TARGETS_NOT_HOSTILE: + if (!itr->getSource()->isTargetableForAttack() || i_originalCaster->IsHostileTo( itr->getSource() )) + continue; + break; + case SPELL_TARGETS_FRIENDLY: + if (!itr->getSource()->isTargetableForAttack() || !i_originalCaster->IsFriendlyTo( itr->getSource() )) + continue; + break; + case SPELL_TARGETS_AOE_DAMAGE: + { + if(itr->getSource()->GetTypeId()==TYPEID_UNIT && ((Creature*)itr->getSource())->isTotem()) + continue; + if(!itr->getSource()->isTargetableForAttack()) + continue; + + Unit* check = i_originalCaster->GetCharmerOrOwnerOrSelf(); + + if( check->GetTypeId()==TYPEID_PLAYER ) + { + if (check->IsFriendlyTo( itr->getSource() )) + continue; + } + else + { + if (!check->IsHostileTo( itr->getSource() )) + continue; + } + } + break; + default: continue; + } + + switch(i_push_type) + { + case PUSH_IN_FRONT: + if(i_spell.GetCaster()->isInFront((Unit*)(itr->getSource()), i_radius, 2*M_PI/3 )) + i_data->push_back(itr->getSource()); + break; + case PUSH_IN_BACK: + if(i_spell.GetCaster()->isInBack((Unit*)(itr->getSource()), i_radius, 2*M_PI/3 )) + i_data->push_back(itr->getSource()); + break; + case PUSH_SELF_CENTER: + if(i_spell.GetCaster()->IsWithinDistInMap((Unit*)(itr->getSource()), i_radius)) + i_data->push_back(itr->getSource()); + break; + case PUSH_DEST_CENTER: + if((itr->getSource()->GetDistance(i_spell.m_targets.m_destX, i_spell.m_targets.m_destY, i_spell.m_targets.m_destZ) < i_radius )) + i_data->push_back(itr->getSource()); + break; + case PUSH_TARGET_CENTER: + if(i_spell.m_targets.getUnitTarget()->IsWithinDistInMap((Unit*)(itr->getSource()), i_radius)) + i_data->push_back(itr->getSource()); + break; + } + } + } + + #ifdef WIN32 + template<> inline void Visit(CorpseMapType & ) {} + template<> inline void Visit(GameObjectMapType & ) {} + template<> inline void Visit(DynamicObjectMapType & ) {} + #endif + }; + + #ifndef WIN32 + template<> inline void SpellNotifierCreatureAndPlayer::Visit(CorpseMapType& ) {} + template<> inline void SpellNotifierCreatureAndPlayer::Visit(GameObjectMapType& ) {} + template<> inline void SpellNotifierCreatureAndPlayer::Visit(DynamicObjectMapType& ) {} + #endif +} + +typedef void(Spell::*pEffect)(uint32 i); + +class SpellEvent : public BasicEvent +{ + public: + SpellEvent(Spell* spell); + virtual ~SpellEvent(); + + virtual bool Execute(uint64 e_time, uint32 p_time); + virtual void Abort(uint64 e_time); + protected: + Spell* m_Spell; +}; +#endif diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp index fa037fcdb24..32be3d65065 100644 --- a/src/game/SpellEffects.cpp +++ b/src/game/SpellEffects.cpp @@ -1,6090 +1,6098 @@ -/* - * Copyright (C) 2005-2008 MaNGOS - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "Common.h" -#include "SharedDefines.h" -#include "Database/DatabaseEnv.h" -#include "WorldPacket.h" -#include "WorldSession.h" -#include "Opcodes.h" -#include "Log.h" -#include "UpdateMask.h" -#include "World.h" -#include "ObjectMgr.h" -#include "SpellMgr.h" -#include "Player.h" -#include "SkillExtraItems.h" -#include "Unit.h" -#include "CreatureAI.h" -#include "Spell.h" -#include "DynamicObject.h" -#include "SpellAuras.h" -#include "Group.h" -#include "UpdateData.h" -#include "MapManager.h" -#include "ObjectAccessor.h" -#include "SharedDefines.h" -#include "Pet.h" -#include "GameObject.h" -#include "GossipDef.h" -#include "Creature.h" -#include "Totem.h" -#include "CreatureAI.h" -#include "BattleGround.h" -#include "BattleGroundEY.h" -#include "BattleGroundWS.h" -#include "VMapFactory.h" -#include "Language.h" -#include "SocialMgr.h" -#include "Util.h" - -pEffect SpellEffects[TOTAL_SPELL_EFFECTS]= -{ - &Spell::EffectNULL, // 0 - &Spell::EffectInstaKill, // 1 SPELL_EFFECT_INSTAKILL - &Spell::EffectSchoolDMG, // 2 SPELL_EFFECT_SCHOOL_DAMAGE - &Spell::EffectDummy, // 3 SPELL_EFFECT_DUMMY - &Spell::EffectUnused, // 4 SPELL_EFFECT_PORTAL_TELEPORT unused - &Spell::EffectTeleportUnits, // 5 SPELL_EFFECT_TELEPORT_UNITS - &Spell::EffectApplyAura, // 6 SPELL_EFFECT_APPLY_AURA - &Spell::EffectEnvirinmentalDMG, // 7 SPELL_EFFECT_ENVIRONMENTAL_DAMAGE - &Spell::EffectPowerDrain, // 8 SPELL_EFFECT_POWER_DRAIN - &Spell::EffectHealthLeech, // 9 SPELL_EFFECT_HEALTH_LEECH - &Spell::EffectHeal, // 10 SPELL_EFFECT_HEAL - &Spell::EffectUnused, // 11 SPELL_EFFECT_BIND - &Spell::EffectNULL, // 12 SPELL_EFFECT_PORTAL - &Spell::EffectUnused, // 13 SPELL_EFFECT_RITUAL_BASE unused - &Spell::EffectUnused, // 14 SPELL_EFFECT_RITUAL_SPECIALIZE unused - &Spell::EffectUnused, // 15 SPELL_EFFECT_RITUAL_ACTIVATE_PORTAL unused - &Spell::EffectQuestComplete, // 16 SPELL_EFFECT_QUEST_COMPLETE - &Spell::EffectWeaponDmg, // 17 SPELL_EFFECT_WEAPON_DAMAGE_NOSCHOOL - &Spell::EffectResurrect, // 18 SPELL_EFFECT_RESURRECT - &Spell::EffectAddExtraAttacks, // 19 SPELL_EFFECT_ADD_EXTRA_ATTACKS - &Spell::EffectUnused, // 20 SPELL_EFFECT_DODGE one spell: Dodge - &Spell::EffectUnused, // 21 SPELL_EFFECT_EVADE one spell: Evade (DND) - &Spell::EffectParry, // 22 SPELL_EFFECT_PARRY - &Spell::EffectUnused, // 23 SPELL_EFFECT_BLOCK one spell: Block - &Spell::EffectCreateItem, // 24 SPELL_EFFECT_CREATE_ITEM - &Spell::EffectUnused, // 25 SPELL_EFFECT_WEAPON - &Spell::EffectUnused, // 26 SPELL_EFFECT_DEFENSE one spell: Defense - &Spell::EffectPersistentAA, // 27 SPELL_EFFECT_PERSISTENT_AREA_AURA - &Spell::EffectSummonType, // 28 SPELL_EFFECT_SUMMON - &Spell::EffectMomentMove, // 29 SPELL_EFFECT_LEAP - &Spell::EffectEnergize, // 30 SPELL_EFFECT_ENERGIZE - &Spell::EffectWeaponDmg, // 31 SPELL_EFFECT_WEAPON_PERCENT_DAMAGE - &Spell::EffectTriggerMissileSpell, // 32 SPELL_EFFECT_TRIGGER_MISSILE - &Spell::EffectOpenLock, // 33 SPELL_EFFECT_OPEN_LOCK - &Spell::EffectSummonChangeItem, // 34 SPELL_EFFECT_SUMMON_CHANGE_ITEM - &Spell::EffectApplyAreaAura, // 35 SPELL_EFFECT_APPLY_AREA_AURA_PARTY - &Spell::EffectLearnSpell, // 36 SPELL_EFFECT_LEARN_SPELL - &Spell::EffectUnused, // 37 SPELL_EFFECT_SPELL_DEFENSE one spell: SPELLDEFENSE (DND) - &Spell::EffectDispel, // 38 SPELL_EFFECT_DISPEL - &Spell::EffectUnused, // 39 SPELL_EFFECT_LANGUAGE - &Spell::EffectDualWield, // 40 SPELL_EFFECT_DUAL_WIELD - &Spell::EffectSummonWild, // 41 SPELL_EFFECT_SUMMON_WILD - &Spell::EffectSummonGuardian, // 42 SPELL_EFFECT_SUMMON_GUARDIAN - &Spell::EffectTeleUnitsFaceCaster, // 43 SPELL_EFFECT_TELEPORT_UNITS_FACE_CASTER - &Spell::EffectLearnSkill, // 44 SPELL_EFFECT_SKILL_STEP - &Spell::EffectAddHonor, // 45 SPELL_EFFECT_ADD_HONOR honor/pvp related - &Spell::EffectNULL, // 46 SPELL_EFFECT_SPAWN we must spawn pet there - &Spell::EffectTradeSkill, // 47 SPELL_EFFECT_TRADE_SKILL - &Spell::EffectUnused, // 48 SPELL_EFFECT_STEALTH one spell: Base Stealth - &Spell::EffectUnused, // 49 SPELL_EFFECT_DETECT one spell: Detect - &Spell::EffectTransmitted, // 50 SPELL_EFFECT_TRANS_DOOR - &Spell::EffectUnused, // 51 SPELL_EFFECT_FORCE_CRITICAL_HIT unused - &Spell::EffectUnused, // 52 SPELL_EFFECT_GUARANTEE_HIT one spell: zzOLDCritical Shot - &Spell::EffectEnchantItemPerm, // 53 SPELL_EFFECT_ENCHANT_ITEM - &Spell::EffectEnchantItemTmp, // 54 SPELL_EFFECT_ENCHANT_ITEM_TEMPORARY - &Spell::EffectTameCreature, // 55 SPELL_EFFECT_TAMECREATURE - &Spell::EffectSummonPet, // 56 SPELL_EFFECT_SUMMON_PET - &Spell::EffectLearnPetSpell, // 57 SPELL_EFFECT_LEARN_PET_SPELL - &Spell::EffectWeaponDmg, // 58 SPELL_EFFECT_WEAPON_DAMAGE - &Spell::EffectOpenSecretSafe, // 59 SPELL_EFFECT_OPEN_LOCK_ITEM - &Spell::EffectProficiency, // 60 SPELL_EFFECT_PROFICIENCY - &Spell::EffectSendEvent, // 61 SPELL_EFFECT_SEND_EVENT - &Spell::EffectPowerBurn, // 62 SPELL_EFFECT_POWER_BURN - &Spell::EffectThreat, // 63 SPELL_EFFECT_THREAT - &Spell::EffectTriggerSpell, // 64 SPELL_EFFECT_TRIGGER_SPELL - &Spell::EffectUnused, // 65 SPELL_EFFECT_HEALTH_FUNNEL unused - &Spell::EffectUnused, // 66 SPELL_EFFECT_POWER_FUNNEL unused - &Spell::EffectHealMaxHealth, // 67 SPELL_EFFECT_HEAL_MAX_HEALTH - &Spell::EffectInterruptCast, // 68 SPELL_EFFECT_INTERRUPT_CAST - &Spell::EffectDistract, // 69 SPELL_EFFECT_DISTRACT - &Spell::EffectPull, // 70 SPELL_EFFECT_PULL one spell: Distract Move - &Spell::EffectPickPocket, // 71 SPELL_EFFECT_PICKPOCKET - &Spell::EffectAddFarsight, // 72 SPELL_EFFECT_ADD_FARSIGHT - &Spell::EffectSummonGuardian, // 73 SPELL_EFFECT_SUMMON_POSSESSED - &Spell::EffectSummonTotem, // 74 SPELL_EFFECT_SUMMON_TOTEM - &Spell::EffectHealMechanical, // 75 SPELL_EFFECT_HEAL_MECHANICAL one spell: Mechanical Patch Kit - &Spell::EffectSummonObjectWild, // 76 SPELL_EFFECT_SUMMON_OBJECT_WILD - &Spell::EffectScriptEffect, // 77 SPELL_EFFECT_SCRIPT_EFFECT - &Spell::EffectUnused, // 78 SPELL_EFFECT_ATTACK - &Spell::EffectSanctuary, // 79 SPELL_EFFECT_SANCTUARY - &Spell::EffectAddComboPoints, // 80 SPELL_EFFECT_ADD_COMBO_POINTS - &Spell::EffectUnused, // 81 SPELL_EFFECT_CREATE_HOUSE one spell: Create House (TEST) - &Spell::EffectNULL, // 82 SPELL_EFFECT_BIND_SIGHT - &Spell::EffectDuel, // 83 SPELL_EFFECT_DUEL - &Spell::EffectStuck, // 84 SPELL_EFFECT_STUCK - &Spell::EffectSummonPlayer, // 85 SPELL_EFFECT_SUMMON_PLAYER - &Spell::EffectActivateObject, // 86 SPELL_EFFECT_ACTIVATE_OBJECT - &Spell::EffectSummonTotem, // 87 SPELL_EFFECT_SUMMON_TOTEM_SLOT1 - &Spell::EffectSummonTotem, // 88 SPELL_EFFECT_SUMMON_TOTEM_SLOT2 - &Spell::EffectSummonTotem, // 89 SPELL_EFFECT_SUMMON_TOTEM_SLOT3 - &Spell::EffectSummonTotem, // 90 SPELL_EFFECT_SUMMON_TOTEM_SLOT4 - &Spell::EffectUnused, // 91 SPELL_EFFECT_THREAT_ALL one spell: zzOLDBrainwash - &Spell::EffectEnchantHeldItem, // 92 SPELL_EFFECT_ENCHANT_HELD_ITEM - &Spell::EffectUnused, // 93 SPELL_EFFECT_SUMMON_PHANTASM - &Spell::EffectSelfResurrect, // 94 SPELL_EFFECT_SELF_RESURRECT - &Spell::EffectSkinning, // 95 SPELL_EFFECT_SKINNING - &Spell::EffectCharge, // 96 SPELL_EFFECT_CHARGE - &Spell::EffectSummonCritter, // 97 SPELL_EFFECT_SUMMON_CRITTER - &Spell::EffectKnockBack, // 98 SPELL_EFFECT_KNOCK_BACK - &Spell::EffectDisEnchant, // 99 SPELL_EFFECT_DISENCHANT - &Spell::EffectInebriate, //100 SPELL_EFFECT_INEBRIATE - &Spell::EffectFeedPet, //101 SPELL_EFFECT_FEED_PET - &Spell::EffectDismissPet, //102 SPELL_EFFECT_DISMISS_PET - &Spell::EffectReputation, //103 SPELL_EFFECT_REPUTATION - &Spell::EffectSummonObject, //104 SPELL_EFFECT_SUMMON_OBJECT_SLOT1 - &Spell::EffectSummonObject, //105 SPELL_EFFECT_SUMMON_OBJECT_SLOT2 - &Spell::EffectSummonObject, //106 SPELL_EFFECT_SUMMON_OBJECT_SLOT3 - &Spell::EffectSummonObject, //107 SPELL_EFFECT_SUMMON_OBJECT_SLOT4 - &Spell::EffectDispelMechanic, //108 SPELL_EFFECT_DISPEL_MECHANIC - &Spell::EffectSummonDeadPet, //109 SPELL_EFFECT_SUMMON_DEAD_PET - &Spell::EffectDestroyAllTotems, //110 SPELL_EFFECT_DESTROY_ALL_TOTEMS - &Spell::EffectDurabilityDamage, //111 SPELL_EFFECT_DURABILITY_DAMAGE - &Spell::EffectSummonDemon, //112 SPELL_EFFECT_SUMMON_DEMON - &Spell::EffectResurrectNew, //113 SPELL_EFFECT_RESURRECT_NEW - &Spell::EffectTaunt, //114 SPELL_EFFECT_ATTACK_ME - &Spell::EffectDurabilityDamagePCT, //115 SPELL_EFFECT_DURABILITY_DAMAGE_PCT - &Spell::EffectSkinPlayerCorpse, //116 SPELL_EFFECT_SKIN_PLAYER_CORPSE one spell: Remove Insignia, bg usage, required special corpse flags... - &Spell::EffectSpiritHeal, //117 SPELL_EFFECT_SPIRIT_HEAL one spell: Spirit Heal - &Spell::EffectSkill, //118 SPELL_EFFECT_SKILL professions and more - &Spell::EffectApplyAreaAura, //119 SPELL_EFFECT_APPLY_AREA_AURA_PET - &Spell::EffectUnused, //120 SPELL_EFFECT_TELEPORT_GRAVEYARD one spell: Graveyard Teleport Test - &Spell::EffectWeaponDmg, //121 SPELL_EFFECT_NORMALIZED_WEAPON_DMG - &Spell::EffectUnused, //122 SPELL_EFFECT_122 unused - &Spell::EffectSendTaxi, //123 SPELL_EFFECT_SEND_TAXI taxi/flight related (misc value is taxi path id) - &Spell::EffectPlayerPull, //124 SPELL_EFFECT_PLAYER_PULL opposite of knockback effect (pulls player twoard caster) - &Spell::EffectModifyThreatPercent, //125 SPELL_EFFECT_MODIFY_THREAT_PERCENT - &Spell::EffectStealBeneficialBuff, //126 SPELL_EFFECT_STEAL_BENEFICIAL_BUFF spell steal effect? - &Spell::EffectProspecting, //127 SPELL_EFFECT_PROSPECTING Prospecting spell - &Spell::EffectApplyAreaAura, //128 SPELL_EFFECT_APPLY_AREA_AURA_FRIEND - &Spell::EffectApplyAreaAura, //129 SPELL_EFFECT_APPLY_AREA_AURA_ENEMY - &Spell::EffectNULL, //130 SPELL_EFFECT_REDIRECT_THREAT - &Spell::EffectUnused, //131 SPELL_EFFECT_131 used in some test spells - &Spell::EffectNULL, //132 SPELL_EFFECT_PLAY_MUSIC sound id in misc value - &Spell::EffectUnlearnSpecialization, //133 SPELL_EFFECT_UNLEARN_SPECIALIZATION unlearn profession specialization - &Spell::EffectKillCredit, //134 SPELL_EFFECT_KILL_CREDIT misc value is creature entry - &Spell::EffectNULL, //135 SPELL_EFFECT_CALL_PET - &Spell::EffectHealPct, //136 SPELL_EFFECT_HEAL_PCT - &Spell::EffectEnergisePct, //137 SPELL_EFFECT_ENERGIZE_PCT - &Spell::EffectNULL, //138 SPELL_EFFECT_138 Leap - &Spell::EffectUnused, //139 SPELL_EFFECT_139 unused - &Spell::EffectForceCast, //140 SPELL_EFFECT_FORCE_CAST - &Spell::EffectNULL, //141 SPELL_EFFECT_141 damage and reduce speed? - &Spell::EffectTriggerSpellWithValue, //142 SPELL_EFFECT_TRIGGER_SPELL_WITH_VALUE - &Spell::EffectApplyAreaAura, //143 SPELL_EFFECT_APPLY_AREA_AURA_OWNER - &Spell::EffectNULL, //144 SPELL_EFFECT_144 Spectral Blast - &Spell::EffectNULL, //145 SPELL_EFFECT_145 Black Hole Effect - &Spell::EffectUnused, //146 SPELL_EFFECT_146 unused - &Spell::EffectQuestFail, //147 SPELL_EFFECT_QUEST_FAIL quest fail - &Spell::EffectUnused, //148 SPELL_EFFECT_148 unused - &Spell::EffectNULL, //149 SPELL_EFFECT_149 swoop - &Spell::EffectUnused, //150 SPELL_EFFECT_150 unused - &Spell::EffectTriggerRitualOfSummoning, //151 SPELL_EFFECT_TRIGGER_SPELL_2 - &Spell::EffectNULL, //152 SPELL_EFFECT_152 summon Refer-a-Friend - &Spell::EffectNULL, //153 SPELL_EFFECT_CREATE_PET misc value is creature entry -}; - -void Spell::EffectNULL(uint32 /*i*/) -{ - sLog.outDebug("WORLD: Spell Effect DUMMY"); -} - -void Spell::EffectUnused(uint32 /*i*/) -{ - // NOT USED BY ANY SPELL OR USELESS OR IMPLEMENTED IN DIFFERENT WAY IN MANGOS -} - -void Spell::EffectResurrectNew(uint32 i) -{ - if(!unitTarget || unitTarget->isAlive()) - return; - - if(unitTarget->GetTypeId() != TYPEID_PLAYER) - return; - - if(!unitTarget->IsInWorld()) - return; - - Player* pTarget = ((Player*)unitTarget); - - if(pTarget->isRessurectRequested()) // already have one active request - return; - - uint32 health = damage; - uint32 mana = m_spellInfo->EffectMiscValue[i]; - pTarget->setResurrectRequestData(m_caster->GetGUID(), m_caster->GetMapId(), m_caster->GetPositionX(), m_caster->GetPositionY(), m_caster->GetPositionZ(), health, mana); - SendResurrectRequest(pTarget); -} - -void Spell::EffectInstaKill(uint32 /*i*/) -{ - if( !unitTarget || !unitTarget->isAlive() ) - return; - - // Demonic Sacrifice - if(m_spellInfo->Id==18788 && unitTarget->GetTypeId()==TYPEID_UNIT) - { - uint32 entry = unitTarget->GetEntry(); - uint32 spellID; - switch(entry) - { - case 416: spellID=18789; break; //imp - case 417: spellID=18792; break; //fellhunter - case 1860: spellID=18790; break; //void - case 1863: spellID=18791; break; //succubus - case 17252: spellID=35701; break; //fellguard - default: - sLog.outError("EffectInstaKill: Unhandled creature entry (%u) case.",entry); - return; - } - - m_caster->CastSpell(m_caster,spellID,true); - } - - if(m_caster==unitTarget) // prevent interrupt message - finish(); - - uint32 health = unitTarget->GetHealth(); - m_caster->DealDamage(unitTarget, health, NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); -} - -void Spell::EffectEnvirinmentalDMG(uint32 i) -{ - uint32 absorb = 0; - uint32 resist = 0; - - // Note: this hack with damage replace required until GO casting not implemented - // environment damage spells already have around enemies targeting but this not help in case not existed GO casting support - // currently each enemy selected explicitly and self cast damage, we prevent apply self casted spell bonuses/etc - damage = m_spellInfo->EffectBasePoints[i]+m_spellInfo->EffectBaseDice[i]; - - m_caster->CalcAbsorbResist(m_caster,GetSpellSchoolMask(m_spellInfo), SPELL_DIRECT_DAMAGE, damage, &absorb, &resist); - - m_caster->SendSpellNonMeleeDamageLog(m_caster, m_spellInfo->Id, damage, GetSpellSchoolMask(m_spellInfo), absorb, resist, false, 0, false); - if(m_caster->GetTypeId() == TYPEID_PLAYER) - ((Player*)m_caster)->EnvironmentalDamage(m_caster->GetGUID(),DAMAGE_FIRE,damage); -} - -void Spell::EffectSchoolDMG(uint32 effect_idx) -{ - if( unitTarget && unitTarget->isAlive()) - { - switch(m_spellInfo->SpellFamilyName) - { - case SPELLFAMILY_GENERIC: - { - //Gore - if(m_spellInfo->SpellIconID == 2269 ) - { - damage+= rand()%2 ? damage : 0; - } - - switch(m_spellInfo->Id) // better way to check unknown - { - // Meteor like spells (divided damage to targets) - case 24340: case 26558: case 28884: // Meteor - case 36837: case 38903: case 41276: // Meteor - case 26789: // Shard of the Fallen Star - case 31436: // Malevolent Cleave - case 35181: // Dive Bomb - case 40810: case 43267: case 43268: // Saber Lash - case 42384: // Brutal Swipe - case 45150: // Meteor Slash - { - uint32 count = 0; - for(std::list::iterator ihit= m_UniqueTargetInfo.begin();ihit != m_UniqueTargetInfo.end();++ihit) - if(ihit->effectMask & (1<GetHealth() / 2; - if(damage < 200) - damage = 200; - break; - } - } - break; - } - - case SPELLFAMILY_MAGE: - { - // Arcane Blast - if(m_spellInfo->SpellFamilyFlags & 0x20000000LL) - { - m_caster->CastSpell(m_caster,36032,true); - } - break; - } - case SPELLFAMILY_WARRIOR: - { - // Bloodthirst - if(m_spellInfo->SpellFamilyFlags & 0x40000000000LL) - { - damage = uint32(damage * (m_caster->GetTotalAttackPowerValue(BASE_ATTACK)) / 100); - } - // Shield Slam - else if(m_spellInfo->SpellFamilyFlags & 0x100000000LL) - damage += int32(m_caster->GetShieldBlockValue()); - // Victory Rush - else if(m_spellInfo->SpellFamilyFlags & 0x10000000000LL) - { - damage = uint32(damage * m_caster->GetTotalAttackPowerValue(BASE_ATTACK) / 100); - m_caster->ModifyAuraState(AURA_STATE_WARRIOR_VICTORY_RUSH, false); - } - break; - } - case SPELLFAMILY_WARLOCK: - { - // Incinerate Rank 1 & 2 - if((m_spellInfo->SpellFamilyFlags & 0x00004000000000LL) && m_spellInfo->SpellIconID==2128) - { - // Incinerate does more dmg (dmg*0.25) if the target is Immolated. - if(unitTarget->HasAuraState(AURA_STATE_IMMOLATE)) - damage += int32(damage*0.25); - } - break; - } - case SPELLFAMILY_DRUID: - { - // Ferocious Bite - if((m_spellInfo->SpellFamilyFlags & 0x000800000) && m_spellInfo->SpellVisual==6587) - { - // converts each extra point of energy into ($f1+$AP/630) additional damage - float multiple = m_caster->GetTotalAttackPowerValue(BASE_ATTACK) / 630 + m_spellInfo->DmgMultiplier[effect_idx]; - damage += int32(m_caster->GetPower(POWER_ENERGY) * multiple); - m_caster->SetPower(POWER_ENERGY,0); - } - // Rake - else if(m_spellInfo->SpellFamilyFlags & 0x0000000000001000LL) - { - damage += int32(m_caster->GetTotalAttackPowerValue(BASE_ATTACK) / 100); - } - // Swipe - else if(m_spellInfo->SpellFamilyFlags & 0x0010000000000000LL) - { - damage += int32(m_caster->GetTotalAttackPowerValue(BASE_ATTACK)*0.08f); - } - // Starfire - else if ( m_spellInfo->SpellFamilyFlags & 0x0004LL ) - { - Unit::AuraList const& m_OverrideClassScript = m_caster->GetAurasByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS); - for(Unit::AuraList::const_iterator i = m_OverrideClassScript.begin(); i != m_OverrideClassScript.end(); ++i) - { - // Starfire Bonus (caster) - switch((*i)->GetModifier()->m_miscvalue) - { - case 5481: // Nordrassil Regalia - bonus - { - Unit::AuraList const& m_periodicDamageAuras = unitTarget->GetAurasByType(SPELL_AURA_PERIODIC_DAMAGE); - for(Unit::AuraList::const_iterator itr = m_periodicDamageAuras.begin(); itr != m_periodicDamageAuras.end(); ++itr) - { - // Moonfire or Insect Swarm (target debuff from any casters) - if ( (*itr)->GetSpellProto()->SpellFamilyFlags & 0x00200002LL ) - { - int32 mod = (*i)->GetModifier()->m_amount; - damage += damage*mod/100; - break; - } - } - break; - } - case 5148: //Improved Starfire - Ivory Idol of the Moongoddes Aura - { - damage += (*i)->GetModifier()->m_amount; - break; - } - } - } - } - //Mangle Bonus for the initial damage of Lacerate and Rake - if((m_spellInfo->SpellFamilyFlags==0x0000000000001000LL && m_spellInfo->SpellIconID==494) || - (m_spellInfo->SpellFamilyFlags==0x0000010000000000LL && m_spellInfo->SpellIconID==2246)) - { - Unit::AuraList const& mDummyAuras = unitTarget->GetAurasByType(SPELL_AURA_DUMMY); - for(Unit::AuraList::const_iterator i = mDummyAuras.begin(); i != mDummyAuras.end(); ++i) - if((*i)->GetSpellProto()->SpellFamilyFlags & 0x0000044000000000LL && (*i)->GetSpellProto()->SpellFamilyName==SPELLFAMILY_DRUID) - { - damage = int32(damage*(100.0f+(*i)->GetModifier()->m_amount)/100.0f); - break; - } - } - break; - } - case SPELLFAMILY_ROGUE: - { - // Envenom - if(m_caster->GetTypeId()==TYPEID_PLAYER && (m_spellInfo->SpellFamilyFlags & 0x800000000LL)) - { - // consume from stack dozes not more that have combo-points - if(uint32 combo = ((Player*)m_caster)->GetComboPoints()) - { - // count consumed deadly poison doses at target - uint32 doses = 0; - - // remove consumed poison doses - Unit::AuraList const& auras = unitTarget->GetAurasByType(SPELL_AURA_PERIODIC_DAMAGE); - for(Unit::AuraList::const_iterator itr = auras.begin(); itr!=auras.end() && combo;) - { - // Deadly poison (only attacker applied) - if( (*itr)->GetSpellProto()->SpellFamilyName==SPELLFAMILY_ROGUE && ((*itr)->GetSpellProto()->SpellFamilyFlags & 0x10000) && - (*itr)->GetSpellProto()->SpellVisual==5100 && (*itr)->GetCasterGUID()==m_caster->GetGUID() ) - { - --combo; - ++doses; - - unitTarget->RemoveSingleAuraFromStack((*itr)->GetId(), (*itr)->GetEffIndex()); - - itr = auras.begin(); - } - else - ++itr; - } - - damage *= doses; - damage += int32(((Player*)m_caster)->GetTotalAttackPowerValue(BASE_ATTACK) * 0.03f * doses); - - // Eviscerate and Envenom Bonus Damage (item set effect) - if(m_caster->GetDummyAura(37169)) - damage += ((Player*)m_caster)->GetComboPoints()*40; - } - } - // Eviscerate - else if((m_spellInfo->SpellFamilyFlags & 0x00020000LL) && m_caster->GetTypeId()==TYPEID_PLAYER) - { - if(uint32 combo = ((Player*)m_caster)->GetComboPoints()) - { - damage += int32(m_caster->GetTotalAttackPowerValue(BASE_ATTACK) * combo * 0.03f); - - // Eviscerate and Envenom Bonus Damage (item set effect) - if(m_caster->GetDummyAura(37169)) - damage += combo*40; - } - } - break; - } - case SPELLFAMILY_HUNTER: - { - // Mongoose Bite - if((m_spellInfo->SpellFamilyFlags & 0x000000002) && m_spellInfo->SpellVisual==342) - { - damage += int32(m_caster->GetTotalAttackPowerValue(BASE_ATTACK)*0.2); - } - // Arcane Shot - else if((m_spellInfo->SpellFamilyFlags & 0x00000800) && m_spellInfo->maxLevel > 0) - { - damage += int32(m_caster->GetTotalAttackPowerValue(RANGED_ATTACK)*0.15); - } - // Steady Shot - else if(m_spellInfo->SpellFamilyFlags & 0x100000000LL) - { - int32 base = irand((int32)m_caster->GetWeaponDamageRange(RANGED_ATTACK, MINDAMAGE),(int32)m_caster->GetWeaponDamageRange(RANGED_ATTACK, MAXDAMAGE)); - damage += int32(float(base)/m_caster->GetAttackTime(RANGED_ATTACK)*2800 + m_caster->GetTotalAttackPowerValue(RANGED_ATTACK)*0.2f); - } - //Explosive Trap Effect - else if(m_spellInfo->SpellFamilyFlags & 0x00000004) - { - damage += int32(m_caster->GetTotalAttackPowerValue(RANGED_ATTACK)*0.1); - } - break; - } - case SPELLFAMILY_PALADIN: - { - //Judgement of Vengeance - if((m_spellInfo->SpellFamilyFlags & 0x800000000LL) && m_spellInfo->SpellIconID==2292) - { - uint32 stacks = 0; - Unit::AuraList const& auras = unitTarget->GetAurasByType(SPELL_AURA_PERIODIC_DAMAGE); - for(Unit::AuraList::const_iterator itr = auras.begin(); itr!=auras.end(); ++itr) - if((*itr)->GetId() == 31803 && (*itr)->GetCasterGUID()==m_caster->GetGUID()) - ++stacks; - if(!stacks) - //No damage if the target isn't affected by this - damage = -1; - else - damage *= stacks; - } - break; - } - } - - if(damage >= 0) - { - uint32 finalDamage; - if(m_originalCaster) // m_caster only passive source of cast - finalDamage = m_originalCaster->SpellNonMeleeDamageLog(unitTarget, m_spellInfo->Id, damage, m_IsTriggeredSpell, true); - else - finalDamage = m_caster->SpellNonMeleeDamageLog(unitTarget, m_spellInfo->Id, damage, m_IsTriggeredSpell, true); - - // post effects - switch(m_spellInfo->SpellFamilyName) - { - case SPELLFAMILY_WARRIOR: - { - // Bloodthirst - if(m_spellInfo->SpellFamilyFlags & 0x40000000000LL) - { - uint32 BTAura = 0; - switch(m_spellInfo->Id) - { - case 23881: BTAura = 23885; break; - case 23892: BTAura = 23886; break; - case 23893: BTAura = 23887; break; - case 23894: BTAura = 23888; break; - case 25251: BTAura = 25252; break; - case 30335: BTAura = 30339; break; - default: - sLog.outError("Spell::EffectSchoolDMG: Spell %u not handled in BTAura",m_spellInfo->Id); - break; - } - - if (BTAura) - m_caster->CastSpell(m_caster,BTAura,true); - } - break; - } - case SPELLFAMILY_PRIEST: - { - // Shadow Word: Death - if(finalDamage > 0 && (m_spellInfo->SpellFamilyFlags & 0x0000000200000000LL) && unitTarget->isAlive()) - // deals damage equal to damage done to caster if victim is not killed - m_caster->SpellNonMeleeDamageLog( m_caster, m_spellInfo->Id, finalDamage, m_IsTriggeredSpell, false); - - break; - } - case SPELLFAMILY_PALADIN: - { - // Judgement of Blood - if(finalDamage > 0 && (m_spellInfo->SpellFamilyFlags & 0x0000000800000000LL) && m_spellInfo->SpellIconID==153) - { - int32 damagePoint = finalDamage * 33 / 100; - m_caster->CastCustomSpell(m_caster, 32220, &damagePoint, NULL, NULL, true); - } - break; - } - } - } - } -} - -void Spell::EffectDummy(uint32 i) -{ - if(!unitTarget && !gameObjTarget && !itemTarget) - return; - - // selection by spell family - switch(m_spellInfo->SpellFamilyName) - { - case SPELLFAMILY_GENERIC: - // Gnomish Poultryizer trinket - switch(m_spellInfo->Id ) - { - case 8063: // Deviate Fish - { - if(m_caster->GetTypeId() != TYPEID_PLAYER) - return; - - uint32 spell_id = 0; - switch(urand(1,5)) - { - case 1: spell_id = 8064; break; // Sleepy - case 2: spell_id = 8065; break; // Invigorate - case 3: spell_id = 8066; break; // Shrink - case 4: spell_id = 8067; break; // Party Time! - case 5: spell_id = 8068; break; // Healthy Spirit - } - m_caster->CastSpell(m_caster,spell_id,true,NULL); - return; - } - case 8213: // Savory Deviate Delight - { - if(m_caster->GetTypeId() != TYPEID_PLAYER) - return; - - uint32 spell_id = 0; - switch(urand(1,2)) - { - // Flip Out - ninja - case 1: spell_id = (m_caster->getGender() == GENDER_MALE ? 8219 : 8220); break; - // Yaaarrrr - pirate - case 2: spell_id = (m_caster->getGender() == GENDER_MALE ? 8221 : 8222); break; - } - m_caster->CastSpell(m_caster,spell_id,true,NULL); - return; - } - case 8593: // Symbol of life (restore creature to life) - case 31225: // Shimmering Vessel (restore creature to life) - { - if(!unitTarget || unitTarget->GetTypeId()!=TYPEID_UNIT) - return; - ((Creature*)unitTarget)->setDeathState(JUST_ALIVED); - return; - } - case 12162: // Deep wounds - case 12850: // (now good common check for this spells) - case 12868: - { - if(!unitTarget) - return; - - float damage; - // DW should benefit of attack power, damage percent mods etc. - // TODO: check if using offhand damage is correct and if it should be divided by 2 - if (m_caster->haveOffhandWeapon() && m_caster->getAttackTimer(BASE_ATTACK) > m_caster->getAttackTimer(OFF_ATTACK)) - damage = (m_caster->GetFloatValue(UNIT_FIELD_MINOFFHANDDAMAGE) + m_caster->GetFloatValue(UNIT_FIELD_MAXOFFHANDDAMAGE))/2; - else - damage = (m_caster->GetFloatValue(UNIT_FIELD_MINDAMAGE) + m_caster->GetFloatValue(UNIT_FIELD_MAXDAMAGE))/2; - - switch (m_spellInfo->Id) - { - case 12850: damage *= 0.2f; break; - case 12162: damage *= 0.4f; break; - case 12868: damage *= 0.6f; break; - default: - sLog.outError("Spell::EffectDummy: Spell %u not handled in DW",m_spellInfo->Id); - return; - }; - - int32 deepWoundsDotBasePoints0 = int32(damage / 4); - m_caster->CastCustomSpell(unitTarget, 12721, &deepWoundsDotBasePoints0, NULL, NULL, true, NULL); - return; - } - case 12975: //Last Stand - { - int32 healthModSpellBasePoints0 = int32(m_caster->GetMaxHealth()*0.3); - m_caster->CastCustomSpell(m_caster, 12976, &healthModSpellBasePoints0, NULL, NULL, true, NULL); - return; - } - case 13120: // net-o-matic - { - if(!unitTarget) - return; - - uint32 spell_id = 0; - - uint32 roll = urand(0, 99); - - if(roll < 2) // 2% for 30 sec self root (off-like chance unknown) - spell_id = 16566; - else if(roll < 4) // 2% for 20 sec root, charge to target (off-like chance unknown) - spell_id = 13119; - else // normal root - spell_id = 13099; - - m_caster->CastSpell(unitTarget,spell_id,true,NULL); - return; - } - case 13567: // Dummy Trigger - { - // can be used for different aura triggreing, so select by aura - if(!m_triggeredByAuraSpell || !unitTarget) - return; - - switch(m_triggeredByAuraSpell->Id) - { - case 26467: // Persistent Shield - m_caster->CastCustomSpell(unitTarget, 26470, &damage, NULL, NULL, true); - break; - default: - sLog.outError("EffectDummy: Non-handled case for spell 13567 for triggered aura %u",m_triggeredByAuraSpell->Id); - break; - } - return; - } - case 14185: // Preparation Rogue - { - if(m_caster->GetTypeId()!=TYPEID_PLAYER) - return; - - //immediately finishes the cooldown on certain Rogue abilities - const PlayerSpellMap& sp_list = ((Player *)m_caster)->GetSpellMap(); - for (PlayerSpellMap::const_iterator itr = sp_list.begin(); itr != sp_list.end(); ++itr) - { - uint32 classspell = itr->first; - SpellEntry const *spellInfo = sSpellStore.LookupEntry(classspell); - - if (spellInfo->SpellFamilyName == SPELLFAMILY_ROGUE && (spellInfo->SpellFamilyFlags & 0x26000000860LL)) - { - ((Player*)m_caster)->RemoveSpellCooldown(classspell); - - WorldPacket data(SMSG_CLEAR_COOLDOWN, (4+8)); - data << uint32(classspell); - data << uint64(m_caster->GetGUID()); - ((Player*)m_caster)->GetSession()->SendPacket(&data); - } - } - return; - } - case 15998: // Capture Worg Pup - case 29435: // Capture Female Kaliri Hatchling - { - if(!unitTarget || unitTarget->GetTypeId() != TYPEID_UNIT) - return; - - Creature* creatureTarget = (Creature*)unitTarget; - creatureTarget->setDeathState(JUST_DIED); - creatureTarget->RemoveCorpse(); - creatureTarget->SetHealth(0); // just for nice GM-mode view - return; - } - case 16589: // Noggenfogger Elixir - { - if(m_caster->GetTypeId()!=TYPEID_PLAYER) - return; - - uint32 spell_id = 0; - switch(urand(1,3)) - { - case 1: spell_id = 16595; break; - case 2: spell_id = 16593; break; - default:spell_id = 16591; break; - } - - m_caster->CastSpell(m_caster,spell_id,true,NULL); - return; - } - case 17251: // Spirit Healer Res - { - if(!unitTarget || !m_originalCaster) - return; - - if(m_originalCaster->GetTypeId() == TYPEID_PLAYER) - { - WorldPacket data(SMSG_SPIRIT_HEALER_CONFIRM, 8); - data << unitTarget->GetGUID(); - ((Player*)m_originalCaster)->GetSession()->SendPacket( &data ); - } - return; - } - case 17271: // Test Fetid Skull - { - if(!itemTarget && m_caster->GetTypeId()!=TYPEID_PLAYER) - return; - - uint32 spell_id = roll_chance_i(50) ? 17269 : 17270; - - m_caster->CastSpell(m_caster,spell_id,true,NULL); - return; - } - case 20577: // Cannibalize - if (unitTarget) - m_caster->CastSpell(m_caster,20578,false,NULL); - return; - case 23019: // Crystal Prison Dummy DND - { - if(!unitTarget || !unitTarget->isAlive() || unitTarget->GetTypeId() != TYPEID_UNIT || ((Creature*)unitTarget)->isPet()) - return; - - Creature* creatureTarget = (Creature*)unitTarget; - if(creatureTarget->isPet()) - return; - - creatureTarget->setDeathState(JUST_DIED); - creatureTarget->RemoveCorpse(); - creatureTarget->SetHealth(0); // just for nice GM-mode view - - GameObject* pGameObj = new GameObject; - - Map *map = creatureTarget->GetMap(); - - if(!pGameObj->Create(objmgr.GenerateLowGuid(HIGHGUID_GAMEOBJECT), 179644, map, - creatureTarget->GetPositionX(), creatureTarget->GetPositionY(), creatureTarget->GetPositionZ(), - creatureTarget->GetOrientation(), 0, 0, 0, 0, 100, 1) ) - { - delete pGameObj; - return; - } - - pGameObj->SetRespawnTime(creatureTarget->GetRespawnTime()-time(NULL)); - pGameObj->SetOwnerGUID(m_caster->GetGUID() ); - pGameObj->SetUInt32Value(GAMEOBJECT_LEVEL, m_caster->getLevel() ); - pGameObj->SetSpellId(m_spellInfo->Id); - - DEBUG_LOG("AddObject at SpellEfects.cpp EffectDummy\n"); - map->Add(pGameObj); - - WorldPacket data(SMSG_GAMEOBJECT_SPAWN_ANIM_OBSOLETE, 8); - data << uint64(pGameObj->GetGUID()); - m_caster->SendMessageToSet(&data,true); - - return; - } - case 23074: // Arc. Dragonling - if (!m_CastItem) return; - m_caster->CastSpell(m_caster,19804,true,m_CastItem); - return; - case 23075: // Mithril Mechanical Dragonling - if (!m_CastItem) return; - m_caster->CastSpell(m_caster,12749,true,m_CastItem); - return; - case 23076: // Mechanical Dragonling - if (!m_CastItem) return; - m_caster->CastSpell(m_caster,4073,true,m_CastItem); - return; - case 23133: // Gnomish Battle Chicken - if (!m_CastItem) return; - m_caster->CastSpell(m_caster,13166,true,m_CastItem); - return; - case 23448: // Ultrasafe Transporter: Gadgetzan - backfires - { - int32 r = irand(0, 119); - if ( r < 20 ) // 1/6 polymorph - m_caster->CastSpell(m_caster,23444,true); - else if ( r < 100 ) // 4/6 evil twin - m_caster->CastSpell(m_caster,23445,true); - else // 1/6 miss the target - m_caster->CastSpell(m_caster,36902,true); - return; - } - case 23453: // Ultrasafe Transporter: Gadgetzan - if ( roll_chance_i(50) ) // success - m_caster->CastSpell(m_caster,23441,true); - else // failure - m_caster->CastSpell(m_caster,23446,true); - return; - case 23645: // Hourglass Sand - m_caster->RemoveAurasDueToSpell(23170); - return; - case 23725: // Gift of Life (warrior bwl trinket) - m_caster->CastSpell(m_caster,23782,true); - m_caster->CastSpell(m_caster,23783,true); - return; - case 25860: // Reindeer Transformation - { - if (!m_caster->HasAuraType(SPELL_AURA_MOUNTED)) - return; - - float flyspeed = m_caster->GetSpeedRate(MOVE_FLY); - float speed = m_caster->GetSpeedRate(MOVE_RUN); - - m_caster->RemoveSpellsCausingAura(SPELL_AURA_MOUNTED); - - //5 different spells used depending on mounted speed and if mount can fly or not - if (flyspeed >= 4.1f) - m_caster->CastSpell(m_caster, 44827, true); //310% flying Reindeer - else if (flyspeed >= 3.8f) - m_caster->CastSpell(m_caster, 44825, true); //280% flying Reindeer - else if (flyspeed >= 1.6f) - m_caster->CastSpell(m_caster, 44824, true); //60% flying Reindeer - else if (speed >= 2.0f) - m_caster->CastSpell(m_caster, 25859, true); //100% ground Reindeer - else - m_caster->CastSpell(m_caster, 25858, true); //60% ground Reindeer - - return; - } - //case 26074: // Holiday Cheer - // return; -- implemented at client side - case 28006: // Arcane Cloaking - { - if( unitTarget->GetTypeId() == TYPEID_PLAYER ) - m_caster->CastSpell(unitTarget,29294,true); - return; - } - case 28730: // Arcane Torrent (Mana) - { - int32 count = 0; - Unit::AuraList const& m_dummyAuras = m_caster->GetAurasByType(SPELL_AURA_DUMMY); - for(Unit::AuraList::const_iterator i = m_dummyAuras.begin(); i != m_dummyAuras.end(); ++i) - if ((*i)->GetId() == 28734) - ++count; - if (count) - { - m_caster->RemoveAurasDueToSpell(28734); - int32 bp = damage * count; - m_caster->CastCustomSpell(m_caster, 28733, &bp, NULL, NULL, true); - } - return; - } - case 29200: // Purify Helboar Meat - { - if( m_caster->GetTypeId() != TYPEID_PLAYER ) - return; - - uint32 spell_id = roll_chance_i(50) ? 29277 : 29278; - - m_caster->CastSpell(m_caster,spell_id,true,NULL); - return; - } - case 29858: // Soulshatter - if (unitTarget && unitTarget->GetTypeId() == TYPEID_UNIT && unitTarget->IsHostileTo(m_caster)) - m_caster->CastSpell(unitTarget,32835,true); - return; - case 30458: // Nigh Invulnerability - if (!m_CastItem) return; - if(roll_chance_i(86)) // success - m_caster->CastSpell(m_caster, 30456, true, m_CastItem); - else // backfire in 14% casts - m_caster->CastSpell(m_caster, 30457, true, m_CastItem); - return; - case 30507: // Poultryizer - if (!m_CastItem) return; - if(roll_chance_i(80)) // success - m_caster->CastSpell(unitTarget, 30501, true, m_CastItem); - else // backfire 20% - m_caster->CastSpell(unitTarget, 30504, true, m_CastItem); - return; - case 33060: // Make a Wish - { - if(m_caster->GetTypeId()!=TYPEID_PLAYER) - return; - - uint32 spell_id = 0; - - switch(urand(1,5)) - { - case 1: spell_id = 33053; break; - case 2: spell_id = 33057; break; - case 3: spell_id = 33059; break; - case 4: spell_id = 33062; break; - case 5: spell_id = 33064; break; - } - - m_caster->CastSpell(m_caster,spell_id,true,NULL); - return; - } - case 35745: - { - uint32 spell_id; - switch(m_caster->GetAreaId()) - { - case 3900: spell_id = 35743; break; - case 3742: spell_id = 35744; break; - default: return; - } - - m_caster->CastSpell(m_caster,spell_id,true); - return; - } - case 37674: // Chaos Blast - if(unitTarget) - m_caster->CastSpell(unitTarget,37675,true); - return; - case 44875: // Complete Raptor Capture - { - if(!unitTarget || unitTarget->GetTypeId() != TYPEID_UNIT) - return; - - Creature* creatureTarget = (Creature*)unitTarget; - - creatureTarget->setDeathState(JUST_DIED); - creatureTarget->RemoveCorpse(); - creatureTarget->SetHealth(0); // just for nice GM-mode view - - //cast spell Raptor Capture Credit - m_caster->CastSpell(m_caster,42337,true,NULL); - return; - } - case 45030: // Impale Emissary - { - // Emissary of Hate Credit - m_caster->CastSpell(m_caster,45088,true); - return; - } - case 50243: // Teach Language - { - if(m_caster->GetTypeId() != TYPEID_PLAYER) - return; - - // spell has a 1/3 chance to trigger one of the below - if(roll_chance_i(66)) - return; - if(((Player*)m_caster)->GetTeam() == ALLIANCE) - { - // 1000001 - gnomish binary - m_caster->CastSpell(m_caster, 50242, true); - } - else - { - // 01001000 - goblin binary - m_caster->CastSpell(m_caster, 50246, true); - } - - return; - } - case 51582: //Rocket Boots Engaged (Rocket Boots Xtreme and Rocket Boots Xtreme Lite) - { - if(m_caster->GetTypeId() != TYPEID_PLAYER) - return; - - if(BattleGround* bg = ((Player*)m_caster)->GetBattleGround()) - bg->EventPlayerDroppedFlag((Player*)m_caster); - - m_caster->CastSpell(m_caster, 30452, true, NULL); - return; - } - } - - //All IconID Check in there - switch(m_spellInfo->SpellIconID) - { - // Berserking (troll racial traits) - case 1661: - { - uint32 healthPerc = uint32((float(m_caster->GetHealth())/m_caster->GetMaxHealth())*100); - int32 melee_mod = 10; - if (healthPerc <= 40) - melee_mod = 30; - if (healthPerc < 100 && healthPerc > 40) - melee_mod = 10+(100-healthPerc)/3; - - int32 hasteModBasePoints0 = melee_mod; // (EffectBasePoints[0]+1)-1+(5-melee_mod) = (melee_mod-1+1)-1+5-melee_mod = 5-1 - int32 hasteModBasePoints1 = (5-melee_mod); - int32 hasteModBasePoints2 = 5; - - // FIXME: custom spell required this aura state by some unknown reason, we not need remove it anyway - m_caster->ModifyAuraState(AURA_STATE_BERSERKING,true); - m_caster->CastCustomSpell(m_caster,26635,&hasteModBasePoints0,&hasteModBasePoints1,&hasteModBasePoints2,true,NULL); - return; - } - } - break; - case SPELLFAMILY_MAGE: - switch(m_spellInfo->Id ) - { - case 11958: // Cold Snap - { - if(m_caster->GetTypeId()!=TYPEID_PLAYER) - return; - - // immediately finishes the cooldown on Frost spells - const PlayerSpellMap& sp_list = ((Player *)m_caster)->GetSpellMap(); - for (PlayerSpellMap::const_iterator itr = sp_list.begin(); itr != sp_list.end(); ++itr) - { - if (itr->second->state == PLAYERSPELL_REMOVED) - continue; - - uint32 classspell = itr->first; - SpellEntry const *spellInfo = sSpellStore.LookupEntry(classspell); - - if( spellInfo->SpellFamilyName == SPELLFAMILY_MAGE && - (GetSpellSchoolMask(spellInfo) & SPELL_SCHOOL_MASK_FROST) && - spellInfo->Id != 11958 && GetSpellRecoveryTime(spellInfo) > 0 ) - { - ((Player*)m_caster)->RemoveSpellCooldown(classspell); - - WorldPacket data(SMSG_CLEAR_COOLDOWN, (4+8)); - data << uint32(classspell); - data << uint64(m_caster->GetGUID()); - ((Player*)m_caster)->GetSession()->SendPacket(&data); - } - } - return; - } - } - break; - case SPELLFAMILY_WARRIOR: - // Charge - if(m_spellInfo->SpellFamilyFlags & 0x1 && m_spellInfo->SpellVisual == 867) - { - int32 chargeBasePoints0 = damage; - m_caster->CastCustomSpell(m_caster,34846,&chargeBasePoints0,NULL,NULL,true); - return; - } - // Execute - if(m_spellInfo->SpellFamilyFlags & 0x20000000) - { - if(!unitTarget) - return; - - int32 basePoints0 = damage+int32(m_caster->GetPower(POWER_RAGE) * m_spellInfo->DmgMultiplier[i]); - m_caster->CastCustomSpell(unitTarget, 20647, &basePoints0, NULL, NULL, true, 0); - m_caster->SetPower(POWER_RAGE,0); - return; - } - if(m_spellInfo->Id==21977) //Warrior's Wrath - { - if(!unitTarget) - return; - - m_caster->CastSpell(unitTarget,21887,true); // spell mod - return; - } - break; - case SPELLFAMILY_WARLOCK: - //Life Tap (only it have this with dummy effect) - if (m_spellInfo->SpellFamilyFlags == 0x40000) - { - float cost = m_currentBasePoints[0]+1; - - if(Player* modOwner = m_caster->GetSpellModOwner()) - modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_COST, cost,this); - - int32 dmg = m_caster->SpellDamageBonus(m_caster, m_spellInfo,uint32(cost > 0 ? cost : 0), SPELL_DIRECT_DAMAGE); - - if(int32(m_caster->GetHealth()) > dmg) - { - // Shouldn't Appear in Combat Log - m_caster->ModifyHealth(-dmg); - - int32 mana = dmg; - - Unit::AuraList const& auraDummy = m_caster->GetAurasByType(SPELL_AURA_DUMMY); - for(Unit::AuraList::const_iterator itr = auraDummy.begin(); itr != auraDummy.end(); ++itr) - { - // only Imp. Life Tap have this in combination with dummy aura - if((*itr)->GetSpellProto()->SpellFamilyName==SPELLFAMILY_WARLOCK && (*itr)->GetSpellProto()->SpellIconID == 208) - mana = ((*itr)->GetModifier()->m_amount + 100)* mana / 100; - } - - m_caster->CastCustomSpell(m_caster,31818,&mana,NULL,NULL,true,NULL); - - // Mana Feed - int32 manaFeedVal = m_caster->CalculateSpellDamage(m_spellInfo,1, m_spellInfo->EffectBasePoints[1],m_caster); - manaFeedVal = manaFeedVal * mana / 100; - if(manaFeedVal > 0) - m_caster->CastCustomSpell(m_caster,32553,&manaFeedVal,NULL,NULL,true,NULL); - } - else - SendCastResult(SPELL_FAILED_FIZZLE); - return; - } - break; - case SPELLFAMILY_PRIEST: - switch(m_spellInfo->Id ) - { - case 28598: // Touch of Weakness triggered spell - { - if(!unitTarget || !m_triggeredByAuraSpell) - return; - - uint32 spellid = 0; - switch(m_triggeredByAuraSpell->Id) - { - case 2652: spellid = 2943; break; // Rank 1 - case 19261: spellid = 19249; break; // Rank 2 - case 19262: spellid = 19251; break; // Rank 3 - case 19264: spellid = 19252; break; // Rank 4 - case 19265: spellid = 19253; break; // Rank 5 - case 19266: spellid = 19254; break; // Rank 6 - case 25461: spellid = 25460; break; // Rank 7 - default: - sLog.outError("Spell::EffectDummy: Spell 28598 triggered by unhandeled spell %u",m_triggeredByAuraSpell->Id); - return; - } - m_caster->CastSpell(unitTarget, spellid, true, NULL); - return; - } - } - break; - case SPELLFAMILY_DRUID: - switch(m_spellInfo->Id ) - { - case 5420: // Tree of Life passive - { - // Tree of Life area effect - int32 health_mod = int32(m_caster->GetStat(STAT_SPIRIT)/4); - m_caster->CastCustomSpell(m_caster,34123,&health_mod,NULL,NULL,true,NULL); - return; - } - } - break; - case SPELLFAMILY_ROGUE: - switch(m_spellInfo->Id ) - { - case 31231: // Cheat Death - { - m_caster->CastSpell(m_caster,45182,true); - return; - } - case 5938: // Shiv - { - if(m_caster->GetTypeId() != TYPEID_PLAYER) - return; - - Player *pCaster = ((Player*)m_caster); - - Item *item = pCaster->GetWeaponForAttack(OFF_ATTACK); - if(!item) - return; - - // all poison enchantments is temporary - uint32 enchant_id = item->GetEnchantmentId(TEMP_ENCHANTMENT_SLOT); - if(!enchant_id) - return; - - SpellItemEnchantmentEntry const *pEnchant = sSpellItemEnchantmentStore.LookupEntry(enchant_id); - if(!pEnchant) - return; - - for (int s=0;s<3;s++) - { - if(pEnchant->type[s]!=ITEM_ENCHANTMENT_TYPE_COMBAT_SPELL) - continue; - - SpellEntry const* combatEntry = sSpellStore.LookupEntry(pEnchant->spellid[s]); - if(!combatEntry || combatEntry->Dispel != DISPEL_POISON) - continue; - - m_caster->CastSpell(unitTarget, combatEntry, true, item); - } - - m_caster->CastSpell(unitTarget, 5940, true); - return; - } - } - break; - case SPELLFAMILY_HUNTER: - // Steady Shot - if(m_spellInfo->SpellFamilyFlags & 0x100000000LL) - { - if( !unitTarget || !unitTarget->isAlive()) - return; - - bool found = false; - - // check dazed affect - Unit::AuraList const& decSpeedList = unitTarget->GetAurasByType(SPELL_AURA_MOD_DECREASE_SPEED); - for(Unit::AuraList::const_iterator iter = decSpeedList.begin(); iter != decSpeedList.end(); ++iter) - { - if((*iter)->GetSpellProto()->SpellIconID==15 && (*iter)->GetSpellProto()->Dispel==0) - { - found = true; - break; - } - } - - if(found) - m_caster->SpellNonMeleeDamageLog(unitTarget, m_spellInfo->Id, damage, m_IsTriggeredSpell, true); - return; - } - // Kill command - if(m_spellInfo->SpellFamilyFlags & 0x00080000000000LL) - { - if(m_caster->getClass()!=CLASS_HUNTER) - return; - - // clear hunter crit aura state - m_caster->ModifyAuraState(AURA_STATE_HUNTER_CRIT_STRIKE,false); - - // additional damage from pet to pet target - Pet* pet = m_caster->GetPet(); - if(!pet || !pet->getVictim()) - return; - - uint32 spell_id = 0; - switch (m_spellInfo->Id) - { - case 34026: spell_id = 34027; break; // rank 1 - default: - sLog.outError("Spell::EffectDummy: Spell %u not handled in KC",m_spellInfo->Id); - return; - } - - pet->CastSpell(pet->getVictim(), spell_id, true); - return; - } - - switch(m_spellInfo->Id) - { - case 23989: //Readiness talent - { - if(m_caster->GetTypeId()!=TYPEID_PLAYER) - return; - - //immediately finishes the cooldown for hunter abilities - const PlayerSpellMap& sp_list = ((Player *)m_caster)->GetSpellMap(); - for (PlayerSpellMap::const_iterator itr = sp_list.begin(); itr != sp_list.end(); ++itr) - { - uint32 classspell = itr->first; - SpellEntry const *spellInfo = sSpellStore.LookupEntry(classspell); - - if (spellInfo->SpellFamilyName == SPELLFAMILY_HUNTER && spellInfo->Id != 23989 && GetSpellRecoveryTime(spellInfo) > 0 ) - { - ((Player*)m_caster)->RemoveSpellCooldown(classspell); - - WorldPacket data(SMSG_CLEAR_COOLDOWN, (4+8)); - data << uint32(classspell); - data << uint64(m_caster->GetGUID()); - ((Player*)m_caster)->GetSession()->SendPacket(&data); - } - } - return; - } - case 37506: // Scatter Shot - { - if (m_caster->GetTypeId()!=TYPEID_PLAYER) - return; - - // break Auto Shot and autohit - m_caster->InterruptSpell(CURRENT_AUTOREPEAT_SPELL); - m_caster->AttackStop(); - ((Player*)m_caster)->SendAttackSwingCancelAttack(); - return; - } - } - break; - case SPELLFAMILY_PALADIN: - switch(m_spellInfo->SpellIconID) - { - case 156: // Holy Shock - { - if(!unitTarget) - return; - - int hurt = 0; - int heal = 0; - - switch(m_spellInfo->Id) - { - case 20473: hurt = 25912; heal = 25914; break; - case 20929: hurt = 25911; heal = 25913; break; - case 20930: hurt = 25902; heal = 25903; break; - case 27174: hurt = 27176; heal = 27175; break; - case 33072: hurt = 33073; heal = 33074; break; - default: - sLog.outError("Spell::EffectDummy: Spell %u not handled in HS",m_spellInfo->Id); - return; - } - - if(m_caster->IsFriendlyTo(unitTarget)) - m_caster->CastSpell(unitTarget, heal, true, 0); - else - m_caster->CastSpell(unitTarget, hurt, true, 0); - - return; - } - case 561: // Judgement of command - { - if(!unitTarget) - return; - - uint32 spell_id = m_currentBasePoints[i]+1; - SpellEntry const* spell_proto = sSpellStore.LookupEntry(spell_id); - if(!spell_proto) - return; - - if( !unitTarget->hasUnitState(UNIT_STAT_STUNDED) && m_caster->GetTypeId()==TYPEID_PLAYER) - { - // decreased damage (/2) for non-stunned target. - SpellModifier *mod = new SpellModifier; - mod->op = SPELLMOD_DAMAGE; - mod->value = -50; - mod->type = SPELLMOD_PCT; - mod->spellId = m_spellInfo->Id; - mod->effectId = i; - mod->lastAffected = NULL; - mod->mask = 0x0000020000000000LL; - mod->charges = 0; - - ((Player*)m_caster)->AddSpellMod(mod, true); - m_caster->CastSpell(unitTarget,spell_proto,true,NULL); - // mod deleted - ((Player*)m_caster)->AddSpellMod(mod, false); - } - else - m_caster->CastSpell(unitTarget,spell_proto,true,NULL); - - return; - } - } - - switch(m_spellInfo->Id) - { - case 31789: // Righteous Defense (step 1) - { - // 31989 -> dummy effect (step 1) + dummy effect (step 2) -> 31709 (taunt like spell for each target) - - // non-standard cast requirement check - if (!unitTarget || unitTarget->getAttackers().empty()) - { - // clear cooldown at fail - if(m_caster->GetTypeId()==TYPEID_PLAYER) - { - ((Player*)m_caster)->RemoveSpellCooldown(m_spellInfo->Id); - - WorldPacket data(SMSG_CLEAR_COOLDOWN, (4+8)); - data << uint32(m_spellInfo->Id); - data << uint64(m_caster->GetGUID()); - ((Player*)m_caster)->GetSession()->SendPacket(&data); - } - - SendCastResult(SPELL_FAILED_TARGET_AFFECTING_COMBAT); - return; - } - - // Righteous Defense (step 2) (in old version 31980 dummy effect) - // Clear targets for eff 1 - for(std::list::iterator ihit= m_UniqueTargetInfo.begin();ihit != m_UniqueTargetInfo.end();++ihit) - ihit->effectMask &= ~(1<<1); - - // not empty (checked) - Unit::AttackerSet const& attackers = unitTarget->getAttackers(); - - // chance to be selected from list - float chance = 100.0f/attackers.size(); - uint32 count=0; - for(Unit::AttackerSet::const_iterator aItr = attackers.begin(); aItr != attackers.end() && count < 3; ++aItr) - { - if(!roll_chance_f(chance)) - continue; - ++count; - AddUnitTarget((*aItr), 1); - } - - // now let next effect cast spell at each target. - return; - } - case 37877: // Blessing of Faith - { - if(!unitTarget) - return; - - uint32 spell_id = 0; - switch(unitTarget->getClass()) - { - case CLASS_DRUID: spell_id = 37878; break; - case CLASS_PALADIN: spell_id = 37879; break; - case CLASS_PRIEST: spell_id = 37880; break; - case CLASS_SHAMAN: spell_id = 37881; break; - default: return; // ignore for not healing classes - } - - m_caster->CastSpell(m_caster,spell_id,true); - return; - } - } - break; - case SPELLFAMILY_SHAMAN: - //Shaman Rockbiter Weapon - if (m_spellInfo->SpellFamilyFlags == 0x400000) - { - uint32 spell_id = 0; - switch(m_spellInfo->Id) - { - case 8017: spell_id = 36494; break; // Rank 1 - case 8018: spell_id = 36750; break; // Rank 2 - case 8019: spell_id = 36755; break; // Rank 3 - case 10399: spell_id = 36759; break; // Rank 4 - case 16314: spell_id = 36763; break; // Rank 5 - case 16315: spell_id = 36766; break; // Rank 6 - case 16316: spell_id = 36771; break; // Rank 7 - case 25479: spell_id = 36775; break; // Rank 8 - case 25485: spell_id = 36499; break; // Rank 9 - default: - sLog.outError("Spell::EffectDummy: Spell %u not handled in RW",m_spellInfo->Id); - return; - } - - SpellEntry const *spellInfo = sSpellStore.LookupEntry( spell_id ); - - if(!spellInfo) - { - sLog.outError("WORLD: unknown spell id %i\n", spell_id); - return; - } - - if(m_caster->GetTypeId() != TYPEID_PLAYER) - return; - - for(int i = BASE_ATTACK; i <= OFF_ATTACK; ++i) - { - if(Item* item = ((Player*)m_caster)->GetWeaponForAttack(WeaponAttackType(i))) - { - if(item->IsFitToSpellRequirements(m_spellInfo)) - { - Spell *spell = new Spell(m_caster, spellInfo, true); - - // enchanting spell selected by calculated damage-per-sec in enchanting effect - // at calculation applied affect from Elemental Weapons talent - // real enchantment damage-1 - spell->m_currentBasePoints[1] = damage-1; - - SpellCastTargets targets; - targets.setItemTarget( item ); - spell->prepare(&targets); - } - } - } - return; - } - - if(m_spellInfo->Id == 39610) // Mana-Tide Totem effect - { - if(!unitTarget || unitTarget->getPowerType() != POWER_MANA) - return; - - // Regenerate 6% of Total Mana Every 3 secs - int32 EffectBasePoints0 = unitTarget->GetMaxPower(POWER_MANA) * damage / 100; - m_caster->CastCustomSpell(unitTarget,39609,&EffectBasePoints0,NULL,NULL,true,NULL,NULL,m_originalCasterGUID); - return; - } - - break; - } - - // pet auras - if(PetAura const* petSpell = spellmgr.GetPetAura(m_spellInfo->Id)) - { - m_caster->AddPetAura(petSpell); - return; - } -} - -void Spell::EffectTriggerSpellWithValue(uint32 i) -{ - uint32 triggered_spell_id = m_spellInfo->EffectTriggerSpell[i]; - - // normal case - SpellEntry const *spellInfo = sSpellStore.LookupEntry( triggered_spell_id ); - - if(!spellInfo) - { - sLog.outError("EffectTriggerSpellWithValue of spell %u: triggering unknown spell id %i\n", m_spellInfo->Id,triggered_spell_id); - return; - } - - int32 bp = damage; - m_caster->CastCustomSpell(unitTarget,triggered_spell_id,&bp,&bp,&bp,true,NULL,NULL,m_originalCasterGUID); -} - -void Spell::EffectTriggerRitualOfSummoning(uint32 i) -{ - uint32 triggered_spell_id = m_spellInfo->EffectTriggerSpell[i]; - SpellEntry const *spellInfo = sSpellStore.LookupEntry( triggered_spell_id ); - - if(!spellInfo) - { - sLog.outError("EffectTriggerRitualOfSummoning of spell %u: triggering unknown spell id %i", m_spellInfo->Id,triggered_spell_id); - return; - } - - finish(); - Spell *spell = new Spell(m_caster, spellInfo, true); - - SpellCastTargets targets; - targets.setUnitTarget( unitTarget); - spell->prepare(&targets); - - m_caster->SetCurrentCastedSpell(spell); - spell->m_selfContainer = &(m_caster->m_currentSpells[spell->GetCurrentContainer()]); - -} - -void Spell::EffectForceCast(uint32 i) -{ - if( !unitTarget ) - return; - - uint32 triggered_spell_id = m_spellInfo->EffectTriggerSpell[i]; - - // normal case - SpellEntry const *spellInfo = sSpellStore.LookupEntry( triggered_spell_id ); - - if(!spellInfo) - { - sLog.outError("EffectForceCast of spell %u: triggering unknown spell id %i", m_spellInfo->Id,triggered_spell_id); - return; - } - - unitTarget->CastSpell(unitTarget,spellInfo,true,NULL,NULL,m_originalCasterGUID); -} - -void Spell::EffectTriggerSpell(uint32 i) -{ - uint32 triggered_spell_id = m_spellInfo->EffectTriggerSpell[i]; - - // special cases - switch(triggered_spell_id) - { - // Vanish - case 18461: - { - m_caster->RemoveSpellsCausingAura(SPELL_AURA_MOD_ROOT); - m_caster->RemoveSpellsCausingAura(SPELL_AURA_MOD_DECREASE_SPEED); - m_caster->RemoveSpellsCausingAura(SPELL_AURA_MOD_STALKED); - - // if this spell is given to NPC it must handle rest by it's own AI - if ( m_caster->GetTypeId() != TYPEID_PLAYER ) - return; - - // get highest rank of the Stealth spell - uint32 spellId = 0; - const PlayerSpellMap& sp_list = ((Player*)m_caster)->GetSpellMap(); - for (PlayerSpellMap::const_iterator itr = sp_list.begin(); itr != sp_list.end(); ++itr) - { - // only highest rank is shown in spell book, so simply check if shown in spell book - if(!itr->second->active || itr->second->disabled || itr->second->state == PLAYERSPELL_REMOVED) - continue; - - SpellEntry const *spellInfo = sSpellStore.LookupEntry(itr->first); - if (!spellInfo) - continue; - - if (spellInfo->SpellFamilyName == SPELLFAMILY_ROGUE && spellInfo->SpellFamilyFlags & SPELLFAMILYFLAG_ROGUE_STEALTH) - { - spellId = spellInfo->Id; - break; - } - } - - // no Stealth spell found - if (!spellId) - return; - - // reset cooldown on it if needed - if(((Player*)m_caster)->HasSpellCooldown(spellId)) - ((Player*)m_caster)->RemoveSpellCooldown(spellId); - - m_caster->CastSpell(m_caster, spellId, true); - return; - } - // just skip - case 23770: // Sayge's Dark Fortune of * - // not exist, common cooldown can be implemented in scripts if need. - return; - // Brittle Armor - (need add max stack of 24575 Brittle Armor) - case 29284: - { - const SpellEntry *spell = sSpellStore.LookupEntry(24575); - if (!spell) - return; - - for (int i=0; i < spell->StackAmount; ++i) - m_caster->CastSpell(unitTarget,spell->Id, true, m_CastItem, NULL, m_originalCasterGUID); - return; - } - // Mercurial Shield - (need add max stack of 26464 Mercurial Shield) - case 29286: - { - const SpellEntry *spell = sSpellStore.LookupEntry(26464); - if (!spell) - return; - - for (int i=0; i < spell->StackAmount; ++i) - m_caster->CastSpell(unitTarget,spell->Id, true, m_CastItem, NULL, m_originalCasterGUID); - return; - } - // Righteous Defense - case 31980: - { - m_caster->CastSpell(unitTarget, 31790, true,m_CastItem,NULL,m_originalCasterGUID); - return; - } - // Cloak of Shadows - case 35729 : - { - Unit::AuraMap& Auras = m_caster->GetAuras(); - for(Unit::AuraMap::iterator iter = Auras.begin(); iter != Auras.end(); ++iter) - { - // remove all harmful spells on you... - if( // ignore positive and passive auras - !iter->second->IsPositive() && !iter->second->IsPassive() && - // ignore physical auras - (GetSpellSchoolMask(iter->second->GetSpellProto()) & SPELL_SCHOOL_MASK_NORMAL)==0 && - // ignore immunity persistent spells - !( iter->second->GetSpellProto()->AttributesEx & 0x10000 ) ) - { - m_caster->RemoveAurasDueToSpell(iter->second->GetSpellProto()->Id); - iter = Auras.begin(); - } - } - return; - } - // Priest Shadowfiend (34433) need apply mana gain trigger aura on pet - case 41967: - { - if (Unit *pet = m_caster->GetPet()) - pet->CastSpell(pet, 28305, true); - return; - } - } - - // normal case - SpellEntry const *spellInfo = sSpellStore.LookupEntry( triggered_spell_id ); - - if(!spellInfo) - { - sLog.outError("EffectTriggerSpell of spell %u: triggering unknown spell id %i", m_spellInfo->Id,triggered_spell_id); - return; - } - - // some triggered spells require specific equipment - if(spellInfo->EquippedItemClass >=0 && m_caster->GetTypeId()==TYPEID_PLAYER) - { - // main hand weapon required - if(spellInfo->AttributesEx3 & SPELL_ATTR_EX3_MAIN_HAND) - { - Item* item = ((Player*)m_caster)->GetWeaponForAttack(BASE_ATTACK); - - // skip spell if no weapon in slot or broken - if(!item || item->IsBroken() ) - return; - - // skip spell if weapon not fit to triggered spell - if(!item->IsFitToSpellRequirements(spellInfo)) - return; - } - - // offhand hand weapon required - if(spellInfo->AttributesEx3 & SPELL_ATTR_EX3_REQ_OFFHAND) - { - Item* item = ((Player*)m_caster)->GetWeaponForAttack(OFF_ATTACK); - - // skip spell if no weapon in slot or broken - if(!item || item->IsBroken() ) - return; - - // skip spell if weapon not fit to triggered spell - if(!item->IsFitToSpellRequirements(spellInfo)) - return; - } - } - - // some triggered spells must be casted instantly (for example, if next effect case instant kill caster) - bool instant = false; - for(uint32 j = i+1; j < 3; ++j) - { - if(m_spellInfo->Effect[j]==SPELL_EFFECT_INSTAKILL && m_spellInfo->EffectImplicitTargetA[j]==TARGET_SELF) - { - instant = true; - break; - } - } - - if(instant) - { - if (unitTarget) - m_caster->CastSpell(unitTarget,spellInfo,true,m_CastItem,NULL,m_originalCasterGUID); - } - else - m_TriggerSpells.push_back(spellInfo); -} - -void Spell::EffectTriggerMissileSpell(uint32 effect_idx) -{ - uint32 triggered_spell_id = m_spellInfo->EffectTriggerSpell[effect_idx]; - - // normal case - SpellEntry const *spellInfo = sSpellStore.LookupEntry( triggered_spell_id ); - - if(!spellInfo) - { - sLog.outError("EffectTriggerMissileSpell of spell %u: triggering unknown spell id %effect_idx", m_spellInfo->Id,triggered_spell_id); - return; - } - - if (m_CastItem) - DEBUG_LOG("WORLD: cast Item spellId - %i", spellInfo->Id); - - Spell *spell = new Spell(m_caster, spellInfo, true, m_originalCasterGUID ); - - SpellCastTargets targets; - targets.setDestination(m_targets.m_destX,m_targets.m_destY,m_targets.m_destZ); - spell->m_CastItem = m_CastItem; - spell->prepare(&targets, NULL); -} - -void Spell::EffectTeleportUnits(uint32 i) -{ - if(!unitTarget || unitTarget->isInFlight()) - return; - - switch (m_spellInfo->EffectImplicitTargetB[i]) - { - case TARGET_INNKEEPER_COORDINATES: - { - // Only players can teleport to innkeeper - if (unitTarget->GetTypeId() != TYPEID_PLAYER) - return; - - ((Player*)unitTarget)->TeleportTo(((Player*)unitTarget)->m_homebindMapId,((Player*)unitTarget)->m_homebindX,((Player*)unitTarget)->m_homebindY,((Player*)unitTarget)->m_homebindZ,unitTarget->GetOrientation(),unitTarget==m_caster ? TELE_TO_SPELL : 0); - return; - } - case TARGET_TABLE_X_Y_Z_COORDINATES: - { - // TODO: Only players can teleport? - if (unitTarget->GetTypeId() != TYPEID_PLAYER) - return; - SpellTargetPosition const* st = spellmgr.GetSpellTargetPosition(m_spellInfo->Id); - if(!st) - { - sLog.outError( "Spell::EffectTeleportUnits - unknown Teleport coordinates for spell ID %u\n", m_spellInfo->Id ); - return; - } - ((Player*)unitTarget)->TeleportTo(st->target_mapId,st->target_X,st->target_Y,st->target_Z,st->target_Orientation,unitTarget==m_caster ? TELE_TO_SPELL : 0); - break; - } - case TARGET_BEHIND_VICTIM: - { - // Get selected target for player (or victim for units) - Unit *pTarget = NULL; - if(m_caster->GetTypeId() == TYPEID_PLAYER) - pTarget = ObjectAccessor::GetUnit(*m_caster, ((Player*)m_caster)->GetSelection()); - else - pTarget = m_caster->getVictim(); - // No target present - return - if (!pTarget) - return; - // Init dest coordinates - uint32 mapid = m_caster->GetMapId(); - float x = m_targets.m_destX; - float y = m_targets.m_destY; - float z = m_targets.m_destZ; - float orientation = pTarget->GetOrientation(); - // Teleport - if(unitTarget->GetTypeId() == TYPEID_PLAYER) - ((Player*)unitTarget)->TeleportTo(mapid, x, y, z, orientation, TELE_TO_NOT_LEAVE_COMBAT | TELE_TO_NOT_UNSUMMON_PET | (unitTarget==m_caster ? TELE_TO_SPELL : 0)); - else - { - MapManager::Instance().GetMap(mapid, m_caster)->CreatureRelocation((Creature*)unitTarget, x, y, z, orientation); - WorldPacket data; - unitTarget->BuildTeleportAckMsg(&data, x, y, z, orientation); - unitTarget->SendMessageToSet(&data, false); - } - return; - } - default: - { - // If not exist data for dest location - return - if(!(m_targets.m_targetMask & TARGET_FLAG_DEST_LOCATION)) - { - sLog.outError( "Spell::EffectTeleportUnits - unknown EffectImplicitTargetB[%u] = %u for spell ID %u\n", i, m_spellInfo->EffectImplicitTargetB[i], m_spellInfo->Id ); - return; - } - // Init dest coordinates - uint32 mapid = m_caster->GetMapId(); - float x = m_targets.m_destX; - float y = m_targets.m_destY; - float z = m_targets.m_destZ; - float orientation = unitTarget->GetOrientation(); - // Teleport - if(unitTarget->GetTypeId() == TYPEID_PLAYER) - ((Player*)unitTarget)->TeleportTo(mapid, x, y, z, orientation, TELE_TO_NOT_LEAVE_COMBAT | TELE_TO_NOT_UNSUMMON_PET | (unitTarget==m_caster ? TELE_TO_SPELL : 0)); - else - { - MapManager::Instance().GetMap(mapid, m_caster)->CreatureRelocation((Creature*)unitTarget, x, y, z, orientation); - WorldPacket data; - unitTarget->BuildTeleportAckMsg(&data, x, y, z, orientation); - unitTarget->SendMessageToSet(&data, false); - } - return; - } - } - - // post effects for TARGET_TABLE_X_Y_Z_COORDINATES - switch ( m_spellInfo->Id ) - { - // Dimensional Ripper - Everlook - case 23442: - { - int32 r = irand(0, 119); - if ( r >= 70 ) // 7/12 success - { - if ( r < 100 ) // 4/12 evil twin - m_caster->CastSpell(m_caster,23445,true); - else // 1/12 fire - m_caster->CastSpell(m_caster,23449,true); - } - return; - } - // Ultrasafe Transporter: Toshley's Station - case 36941: - { - if ( roll_chance_i(50) ) // 50% success - { - int32 rand_eff = urand(1,7); - switch ( rand_eff ) - { - case 1: - // soul split - evil - m_caster->CastSpell(m_caster,36900,true); - break; - case 2: - // soul split - good - m_caster->CastSpell(m_caster,36901,true); - break; - case 3: - // Increase the size - m_caster->CastSpell(m_caster,36895,true); - break; - case 4: - // Decrease the size - m_caster->CastSpell(m_caster,36893,true); - break; - case 5: - // Transform - { - if (((Player*)m_caster)->GetTeam() == ALLIANCE ) - m_caster->CastSpell(m_caster,36897,true); - else - m_caster->CastSpell(m_caster,36899,true); - break; - } - case 6: - // chicken - m_caster->CastSpell(m_caster,36940,true); - break; - case 7: - // evil twin - m_caster->CastSpell(m_caster,23445,true); - break; - } - } - return; - } - // Dimensional Ripper - Area 52 - case 36890: - { - if ( roll_chance_i(50) ) // 50% success - { - int32 rand_eff = urand(1,4); - switch ( rand_eff ) - { - case 1: - // soul split - evil - m_caster->CastSpell(m_caster,36900,true); - break; - case 2: - // soul split - good - m_caster->CastSpell(m_caster,36901,true); - break; - case 3: - // Increase the size - m_caster->CastSpell(m_caster,36895,true); - break; - case 4: - // Transform - { - if (((Player*)m_caster)->GetTeam() == ALLIANCE ) - m_caster->CastSpell(m_caster,36897,true); - else - m_caster->CastSpell(m_caster,36899,true); - break; - } - } - } - return; - } - } -} - -void Spell::EffectApplyAura(uint32 i) -{ - if(!unitTarget) - return; - - SpellImmuneList const& list = unitTarget->m_spellImmune[IMMUNITY_STATE]; - for(SpellImmuneList::const_iterator itr = list.begin(); itr != list.end(); ++itr) - if(itr->type == m_spellInfo->EffectApplyAuraName[i]) - return; - - // ghost spell check, allow apply any auras at player loading in ghost mode (will be cleanup after load) - if( !unitTarget->isAlive() && m_spellInfo->Id != 20584 && m_spellInfo->Id != 8326 && - (unitTarget->GetTypeId()!=TYPEID_PLAYER || !((Player*)unitTarget)->GetSession()->PlayerLoading()) ) - return; - - Unit* caster = m_originalCasterGUID ? m_originalCaster : m_caster; - if(!caster) - return; - - sLog.outDebug("Spell: Aura is: %u", m_spellInfo->EffectApplyAuraName[i]); - - Aura* Aur = CreateAura(m_spellInfo, i, &m_currentBasePoints[i], unitTarget, caster, m_CastItem); - - // Now Reduce spell duration using data received at spell hit - int32 duration = Aur->GetAuraMaxDuration(); - unitTarget->ApplyDiminishingToDuration(m_diminishGroup,duration,m_caster,m_diminishLevel); - Aur->setDiminishGroup(m_diminishGroup); - - // if Aura removed and deleted, do not continue. - if(duration== 0 && !(Aur->IsPermanent())) - { - delete Aur; - return; - } - - if(duration != Aur->GetAuraMaxDuration()) - { - Aur->SetAuraMaxDuration(duration); - Aur->SetAuraDuration(duration); - } - - bool added = unitTarget->AddAura(Aur); - - // Aura not added and deleted in AddAura call; - if (!added) - return; - - // found crash at character loading, broken pointer to Aur... - // Aur was deleted in AddAura()... - if(!Aur) - return; - - // TODO Make a way so it works for every related spell! - if(unitTarget->GetTypeId()==TYPEID_PLAYER) // Negative buff should only be applied on players - { - uint32 spellId = 0; - if(m_spellInfo->CasterAuraStateNot==AURA_STATE_WEAKENED_SOUL || m_spellInfo->TargetAuraStateNot==AURA_STATE_WEAKENED_SOUL) - spellId = 6788; // Weakened Soul - else if(m_spellInfo->CasterAuraStateNot==AURA_STATE_FORBEARANCE || m_spellInfo->TargetAuraStateNot==AURA_STATE_FORBEARANCE) - spellId = 25771; // Forbearance - else if(m_spellInfo->CasterAuraStateNot==AURA_STATE_HYPOTHERMIA) - spellId = 41425; // Hypothermia - else if (m_spellInfo->Mechanic == MECHANIC_BANDAGE) // Bandages - spellId = 11196; // Recently Bandaged - else if( (m_spellInfo->AttributesEx & 0x20) && (m_spellInfo->AttributesEx2 & 0x20000) ) - spellId = 23230; // Blood Fury - Healing Reduction - - SpellEntry const *AdditionalSpellInfo = sSpellStore.LookupEntry(spellId); - if (AdditionalSpellInfo) - { - // applied at target by target - Aura* AdditionalAura = CreateAura(AdditionalSpellInfo, 0, &m_currentBasePoints[0], unitTarget,unitTarget, 0); - unitTarget->AddAura(AdditionalAura); - sLog.outDebug("Spell: Additional Aura is: %u", AdditionalSpellInfo->EffectApplyAuraName[0]); - } - } - - // Prayer of Mending (jump animation), we need formal caster instead original for correct animation - if( m_spellInfo->SpellFamilyName == SPELLFAMILY_PRIEST && (m_spellInfo->SpellFamilyFlags & 0x00002000000000LL)) - m_caster->CastSpell(unitTarget,41637,true,NULL,Aur); -} - -void Spell::EffectUnlearnSpecialization( uint32 i ) -{ - if(!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) - return; - - Player *_player = (Player*)unitTarget; - uint32 spellToUnlearn = m_spellInfo->EffectTriggerSpell[i]; - - _player->removeSpell(spellToUnlearn); - - sLog.outDebug( "Spell: Player %u have unlearned spell %u from NpcGUID: %u", _player->GetGUIDLow(), spellToUnlearn, m_caster->GetGUIDLow() ); -} - -void Spell::EffectPowerDrain(uint32 i) -{ - if(m_spellInfo->EffectMiscValue[i] < 0 || m_spellInfo->EffectMiscValue[i] >= MAX_POWERS) - return; - - Powers drain_power = Powers(m_spellInfo->EffectMiscValue[i]); - - if(!unitTarget) - return; - if(!unitTarget->isAlive()) - return; - if(unitTarget->getPowerType() != drain_power) - return; - if(damage < 0) - return; - - uint32 curPower = unitTarget->GetPower(drain_power); - - //add spell damage bonus - damage=m_caster->SpellDamageBonus(unitTarget,m_spellInfo,uint32(damage),SPELL_DIRECT_DAMAGE); - - // resilience reduce mana draining effect at spell crit damage reduction (added in 2.4) - uint32 power = damage; - if ( drain_power == POWER_MANA && unitTarget->GetTypeId() == TYPEID_PLAYER ) - power -= ((Player*)unitTarget)->GetSpellCritDamageReduction(power); - - int32 new_damage; - if(curPower < power) - new_damage = curPower; - else - new_damage = power; - - unitTarget->ModifyPower(drain_power,-new_damage); - - if(drain_power == POWER_MANA) - { - float manaMultiplier = m_spellInfo->EffectMultipleValue[i]; - if(manaMultiplier==0) - manaMultiplier = 1; - - if(Player *modOwner = m_caster->GetSpellModOwner()) - modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_MULTIPLE_VALUE, manaMultiplier); - - int32 gain = int32(new_damage*manaMultiplier); - - m_caster->ModifyPower(POWER_MANA,gain); - //send log - m_caster->SendEnergizeSpellLog(m_caster, m_spellInfo->Id,gain,POWER_MANA,false); - } -} - -void Spell::EffectSendEvent(uint32 EffectIndex) -{ - if (m_caster->GetTypeId() == TYPEID_PLAYER && ((Player*)m_caster)->InBattleGround()) - { - BattleGround* bg = ((Player *)m_caster)->GetBattleGround(); - if(bg && bg->GetStatus() == STATUS_IN_PROGRESS) - { - switch(m_spellInfo->Id) - { - case 23333: // Pickup Horde Flag - /*do not uncomment . - if(bg->GetTypeID()==BATTLEGROUND_WS) - bg->EventPlayerClickedOnFlag((Player*)m_caster, this->gameObjTarget); - sLog.outDebug("Send Event Horde Flag Picked Up"); - break; - /* not used : - case 23334: // Drop Horde Flag - if(bg->GetTypeID()==BATTLEGROUND_WS) - bg->EventPlayerDroppedFlag((Player*)m_caster); - sLog.outDebug("Drop Horde Flag"); - break; - */ - case 23335: // Pickup Alliance Flag - /*do not uncomment ... (it will cause crash, because of null targetobject!) anyway this is a bad way to call that event, because it would cause recursion - if(bg->GetTypeID()==BATTLEGROUND_WS) - bg->EventPlayerClickedOnFlag((Player*)m_caster, this->gameObjTarget); - sLog.outDebug("Send Event Alliance Flag Picked Up"); - break; - /* not used : - case 23336: // Drop Alliance Flag - if(bg->GetTypeID()==BATTLEGROUND_WS) - bg->EventPlayerDroppedFlag((Player*)m_caster); - sLog.outDebug("Drop Alliance Flag"); - break; - case 23385: // Alliance Flag Returns - if(bg->GetTypeID()==BATTLEGROUND_WS) - bg->EventPlayerClickedOnFlag((Player*)m_caster, this->gameObjTarget); - sLog.outDebug("Alliance Flag Returned"); - break; - case 23386: // Horde Flag Returns - if(bg->GetTypeID()==BATTLEGROUND_WS) - bg->EventPlayerClickedOnFlag((Player*)m_caster, this->gameObjTarget); - sLog.outDebug("Horde Flag Returned"); - break;*/ - case 34976: - /* - if(bg->GetTypeID()==BATTLEGROUND_EY) - bg->EventPlayerClickedOnFlag((Player*)m_caster, this->gameObjTarget); - */ - break; - default: - sLog.outDebug("Unknown spellid %u in BG event", m_spellInfo->Id); - break; - } - } - } - sLog.outDebug("Spell ScriptStart %u for spellid %u in EffectSendEvent ", m_spellInfo->EffectMiscValue[EffectIndex], m_spellInfo->Id); - sWorld.ScriptsStart(sEventScripts, m_spellInfo->EffectMiscValue[EffectIndex], m_caster, focusObject); -} - -void Spell::EffectPowerBurn(uint32 i) -{ - if(m_spellInfo->EffectMiscValue[i] < 0 || m_spellInfo->EffectMiscValue[i] >= MAX_POWERS) - return; - - Powers powertype = Powers(m_spellInfo->EffectMiscValue[i]); - - if(!unitTarget) - return; - if(!unitTarget->isAlive()) - return; - if(unitTarget->getPowerType()!=powertype) - return; - if(damage < 0) - return; - - int32 curPower = int32(unitTarget->GetPower(powertype)); - - // resilience reduce mana draining effect at spell crit damage reduction (added in 2.4) - uint32 power = damage; - if ( powertype == POWER_MANA && unitTarget->GetTypeId() == TYPEID_PLAYER ) - power -= ((Player*)unitTarget)->GetSpellCritDamageReduction(power); - - int32 new_damage = (curPower < power) ? curPower : power; - - unitTarget->ModifyPower(powertype,-new_damage); - float multiplier = m_spellInfo->EffectMultipleValue[i]; - - if(Player *modOwner = m_caster->GetSpellModOwner()) - modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_MULTIPLE_VALUE, multiplier); - - new_damage = int32(new_damage*multiplier); - m_caster->SpellNonMeleeDamageLog(unitTarget, m_spellInfo->Id, new_damage, m_IsTriggeredSpell, true); -} - -void Spell::EffectHeal( uint32 /*i*/ ) -{ - if( unitTarget && unitTarget->isAlive() && damage >= 0) - { - // Try to get original caster - Unit *caster = m_originalCasterGUID ? m_originalCaster : m_caster; - - // Skip if m_originalCaster not available - if (!caster) - return; - - int32 addhealth = damage; - - // Vessel of the Naaru (Vial of the Sunwell trinket) - if (m_spellInfo->Id == 45064) - { - // Amount of heal - depends from stacked Holy Energy - int damageAmount = 0; - Unit::AuraList const& mDummyAuras = m_caster->GetAurasByType(SPELL_AURA_DUMMY); - for(Unit::AuraList::const_iterator i = mDummyAuras.begin();i != mDummyAuras.end(); ++i) - if((*i)->GetId() == 45062) - damageAmount+=(*i)->GetModifier()->m_amount; - if (damageAmount) - m_caster->RemoveAurasDueToSpell(45062); - - addhealth += damageAmount; - } - // Swiftmend - consumes Regrowth or Rejuvenation - else if (m_spellInfo->TargetAuraState == AURA_STATE_SWIFTMEND && unitTarget->HasAuraState(AURA_STATE_SWIFTMEND)) - { - Unit::AuraList const& RejorRegr = unitTarget->GetAurasByType(SPELL_AURA_PERIODIC_HEAL); - // find most short by duration - Aura *targetAura = NULL; - for(Unit::AuraList::const_iterator i = RejorRegr.begin(); i != RejorRegr.end(); ++i) - { - if((*i)->GetSpellProto()->SpellFamilyName == SPELLFAMILY_DRUID - && ((*i)->GetSpellProto()->SpellFamilyFlags == 0x40 || (*i)->GetSpellProto()->SpellFamilyFlags == 0x10) ) - { - if(!targetAura || (*i)->GetAuraDuration() < targetAura->GetAuraDuration()) - targetAura = *i; - } - } - - if(!targetAura) - { - sLog.outError("Target(GUID:" I64FMTD ") has aurastate AURA_STATE_SWIFTMEND but no matching aura.", unitTarget->GetGUID()); - return; - } - int idx = 0; - while(idx < 3) - { - if(targetAura->GetSpellProto()->EffectApplyAuraName[idx] == SPELL_AURA_PERIODIC_HEAL) - break; - idx++; - } - - int32 tickheal = caster->SpellHealingBonus(targetAura->GetSpellProto(), targetAura->GetModifier()->m_amount, DOT, unitTarget); - int32 tickcount = GetSpellDuration(targetAura->GetSpellProto()) / targetAura->GetSpellProto()->EffectAmplitude[idx]; - unitTarget->RemoveAurasDueToSpell(targetAura->GetId()); - - addhealth += tickheal * tickcount; - } - else - addhealth = caster->SpellHealingBonus(m_spellInfo, addhealth,HEAL, unitTarget); - - bool crit = caster->isSpellCrit(unitTarget, m_spellInfo, m_spellSchoolMask, m_attackType); - if (crit) - addhealth = caster->SpellCriticalBonus(m_spellInfo, addhealth, unitTarget); - caster->SendHealSpellLog(unitTarget, m_spellInfo->Id, addhealth, crit); - - int32 gain = unitTarget->ModifyHealth( int32(addhealth) ); - unitTarget->getHostilRefManager().threatAssist(m_caster, float(gain) * 0.5f, m_spellInfo); - - if(caster->GetTypeId()==TYPEID_PLAYER) - if(BattleGround *bg = ((Player*)caster)->GetBattleGround()) - bg->UpdatePlayerScore(((Player*)caster), SCORE_HEALING_DONE, gain); - - // ignore item heals - if(m_CastItem) - return; - - uint32 procHealer = PROC_FLAG_HEAL; - if (crit) - procHealer |= PROC_FLAG_CRIT_HEAL; - - m_caster->ProcDamageAndSpell(unitTarget,procHealer,PROC_FLAG_HEALED,addhealth,SPELL_SCHOOL_MASK_NONE,m_spellInfo,m_IsTriggeredSpell); - } -} - -void Spell::EffectHealPct( uint32 /*i*/ ) -{ - if( unitTarget && unitTarget->isAlive() && damage >= 0) - { - // Try to get original caster - Unit *caster = m_originalCasterGUID ? m_originalCaster : m_caster; - - // Skip if m_originalCaster not available - if (!caster) - return; - - uint32 addhealth = unitTarget->GetMaxHealth() * damage / 100; - caster->SendHealSpellLog(unitTarget, m_spellInfo->Id, addhealth, false); - - int32 gain = unitTarget->ModifyHealth( int32(addhealth) ); - unitTarget->getHostilRefManager().threatAssist(m_caster, float(gain) * 0.5f, m_spellInfo); - - if(caster->GetTypeId()==TYPEID_PLAYER) - if(BattleGround *bg = ((Player*)caster)->GetBattleGround()) - bg->UpdatePlayerScore(((Player*)caster), SCORE_HEALING_DONE, gain); - } -} - -void Spell::EffectHealMechanical( uint32 /*i*/ ) -{ - // Mechanic creature type should be correctly checked by targetCreatureType field - if( unitTarget && unitTarget->isAlive() && damage >= 0) - { - // Try to get original caster - Unit *caster = m_originalCasterGUID ? m_originalCaster : m_caster; - - // Skip if m_originalCaster not available - if (!caster) - return; - - uint32 addhealth = caster->SpellHealingBonus(m_spellInfo, uint32(damage), HEAL, unitTarget); - caster->SendHealSpellLog(unitTarget, m_spellInfo->Id, addhealth, false); - unitTarget->ModifyHealth( int32(damage) ); - } -} - -void Spell::EffectHealthLeech(uint32 i) -{ - if(!unitTarget) - return; - if(!unitTarget->isAlive()) - return; - - if(damage < 0) - return; - - sLog.outDebug("HealthLeech :%i", damage); - - float multiplier = m_spellInfo->EffectMultipleValue[i]; - - if(Player *modOwner = m_caster->GetSpellModOwner()) - modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_MULTIPLE_VALUE, multiplier); - - int32 new_damage = int32(damage*multiplier); - uint32 curHealth = unitTarget->GetHealth(); - new_damage = m_caster->SpellNonMeleeDamageLog(unitTarget, m_spellInfo->Id, new_damage, m_IsTriggeredSpell, true); - if(curHealth < new_damage) - new_damage = curHealth; - - if(m_caster->isAlive()) - { - new_damage = m_caster->SpellHealingBonus(m_spellInfo, new_damage, HEAL, m_caster); - - m_caster->ModifyHealth(new_damage); - - if(m_caster->GetTypeId() == TYPEID_PLAYER) - m_caster->SendHealSpellLog(m_caster, m_spellInfo->Id, uint32(new_damage)); - } -} - -void Spell::DoCreateItem(uint32 i, uint32 itemtype) -{ - if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) - return; - - Player* player = (Player*)unitTarget; - - uint32 newitemid = itemtype; - ItemPrototype const *pProto = objmgr.GetItemPrototype( newitemid ); - if(!pProto) - { - player->SendEquipError( EQUIP_ERR_ITEM_NOT_FOUND, NULL, NULL ); - return; - } - - uint32 num_to_add; - - // TODO: maybe all this can be replaced by using correct calculated `damage` value - if(pProto->Class != ITEM_CLASS_CONSUMABLE || m_spellInfo->SpellFamilyName != SPELLFAMILY_MAGE) - { - int32 basePoints = m_currentBasePoints[i]; - int32 randomPoints = m_spellInfo->EffectDieSides[i]; - if (randomPoints) - num_to_add = basePoints + irand(1, randomPoints); - else - num_to_add = basePoints + 1; - } - else if (pProto->MaxCount == 1) - num_to_add = 1; - else if(player->getLevel() >= m_spellInfo->spellLevel) - { - int32 basePoints = m_currentBasePoints[i]; - float pointPerLevel = m_spellInfo->EffectRealPointsPerLevel[i]; - num_to_add = basePoints + 1 + uint32((player->getLevel() - m_spellInfo->spellLevel)*pointPerLevel); - } - else - num_to_add = 2; - - if (num_to_add < 1) - num_to_add = 1; - if (num_to_add > pProto->Stackable) - num_to_add = pProto->Stackable; - - // init items_count to 1, since 1 item will be created regardless of specialization - int items_count=1; - // the chance to create additional items - float additionalCreateChance=0.0f; - // the maximum number of created additional items - uint8 additionalMaxNum=0; - // get the chance and maximum number for creating extra items - if ( canCreateExtraItems(player, m_spellInfo->Id, additionalCreateChance, additionalMaxNum) ) - { - // roll with this chance till we roll not to create or we create the max num - while ( roll_chance_f(additionalCreateChance) && items_count<=additionalMaxNum ) - ++items_count; - } - - // really will be created more items - num_to_add *= items_count; - - // can the player store the new item? - ItemPosCountVec dest; - uint32 no_space = 0; - uint8 msg = player->CanStoreNewItem( NULL_BAG, NULL_SLOT, dest, newitemid, num_to_add, &no_space ); - if( msg != EQUIP_ERR_OK ) - { - // convert to possible store amount - if( msg == EQUIP_ERR_INVENTORY_FULL || msg == EQUIP_ERR_CANT_CARRY_MORE_OF_THIS ) - num_to_add -= no_space; - else - { - // if not created by another reason from full inventory or unique items amount limitation - player->SendEquipError( msg, NULL, NULL ); - return; - } - } - - if(num_to_add) - { - // create the new item and store it - Item* pItem = player->StoreNewItem( dest, newitemid, true, Item::GenerateItemRandomPropertyId(newitemid)); - - // was it successful? return error if not - if(!pItem) - { - player->SendEquipError( EQUIP_ERR_ITEM_NOT_FOUND, NULL, NULL ); - return; - } - - // set the "Crafted by ..." property of the item - if( pItem->GetProto()->Class != ITEM_CLASS_CONSUMABLE && pItem->GetProto()->Class != ITEM_CLASS_QUEST) - pItem->SetUInt32Value(ITEM_FIELD_CREATOR,player->GetGUIDLow()); - - // send info to the client - if(pItem) - player->SendNewItem(pItem, num_to_add, true, true); - - // we succeeded in creating at least one item, so a levelup is possible - player->UpdateCraftSkill(m_spellInfo->Id); - } - - // for battleground marks send by mail if not add all expected - if(no_space > 0 ) - { - BattleGroundTypeId bgType; - switch(m_spellInfo->Id) - { - case SPELL_AV_MARK_WINNER: - case SPELL_AV_MARK_LOSER: - bgType = BATTLEGROUND_AV; - break; - case SPELL_WS_MARK_WINNER: - case SPELL_WS_MARK_LOSER: - bgType = BATTLEGROUND_WS; - break; - case SPELL_AB_MARK_WINNER: - case SPELL_AB_MARK_LOSER: - bgType = BATTLEGROUND_AB; - break; - default: - return; - } - - if(BattleGround* bg = sBattleGroundMgr.GetBattleGround(bgType)) - bg->SendRewardMarkByMail(player,newitemid,no_space); - } -} - -void Spell::EffectCreateItem(uint32 i) -{ - DoCreateItem(i,m_spellInfo->EffectItemType[i]); -} - -void Spell::EffectPersistentAA(uint32 i) -{ - float radius = GetSpellRadius(sSpellRadiusStore.LookupEntry(m_spellInfo->EffectRadiusIndex[i])); - - if(Player* modOwner = m_caster->GetSpellModOwner()) - modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_RADIUS, radius); - - int32 duration = GetSpellDuration(m_spellInfo); - DynamicObject* dynObj = new DynamicObject; - if(!dynObj->Create(objmgr.GenerateLowGuid(HIGHGUID_DYNAMICOBJECT), m_caster, m_spellInfo->Id, i, m_targets.m_destX, m_targets.m_destY, m_targets.m_destZ, duration, radius)) - { - delete dynObj; - return; - } - dynObj->SetUInt32Value(OBJECT_FIELD_TYPE, 65); - dynObj->SetUInt32Value(GAMEOBJECT_DISPLAYID, 368003); - dynObj->SetUInt32Value(DYNAMICOBJECT_BYTES, 0x01eeeeee); - m_caster->AddDynObject(dynObj); - MapManager::Instance().GetMap(dynObj->GetMapId(), dynObj)->Add(dynObj); -} - -void Spell::EffectEnergize(uint32 i) -{ - if(!unitTarget) - return; - if(!unitTarget->isAlive()) - return; - - if(m_spellInfo->EffectMiscValue[i] < 0 || m_spellInfo->EffectMiscValue[i] >= MAX_POWERS) - return; - - // Some level depends spells - int multipler = 0; - int level_diff = 0; - switch (m_spellInfo->Id) - { - // Restore Energy - case 9512: - level_diff = m_caster->getLevel() - 40; - multipler = 2; - break; - // Blood Fury - case 24571: - level_diff = m_caster->getLevel() - 60; - multipler = 10; - break; - // Burst of Energy - case 24532: - level_diff = m_caster->getLevel() - 60; - multipler = 4; - break; - default: - break; - } - - if (level_diff > 0) - damage -= multipler * level_diff; - - if(damage < 0) - return; - - Powers power = Powers(m_spellInfo->EffectMiscValue[i]); - - if(unitTarget->GetMaxPower(power) == 0) - return; - - unitTarget->ModifyPower(power,damage); - m_caster->SendEnergizeSpellLog(unitTarget, m_spellInfo->Id, damage, power); - - // Mad Alchemist's Potion - if (m_spellInfo->Id == 45051) - { - // find elixirs on target - uint32 elixir_mask = 0; - Unit::AuraMap& Auras = unitTarget->GetAuras(); - for(Unit::AuraMap::iterator itr = Auras.begin(); itr != Auras.end(); ++itr) - { - uint32 spell_id = itr->second->GetId(); - if(uint32 mask = spellmgr.GetSpellElixirMask(spell_id)) - elixir_mask |= mask; - } - - // get available elixir mask any not active type from battle/guardian (and flask if no any) - elixir_mask = (elixir_mask & ELIXIR_FLASK_MASK) ^ ELIXIR_FLASK_MASK; - - // get all available elixirs by mask and spell level - std::vector elixirs; - SpellElixirMap const& m_spellElixirs = spellmgr.GetSpellElixirMap(); - for(SpellElixirMap::const_iterator itr = m_spellElixirs.begin(); itr != m_spellElixirs.end(); ++itr) - { - if (itr->second & elixir_mask) - { - if (itr->second & (ELIXIR_UNSTABLE_MASK | ELIXIR_SHATTRATH_MASK)) - continue; - - SpellEntry const *spellInfo = sSpellStore.LookupEntry(itr->first); - if (spellInfo && (spellInfo->spellLevel < m_spellInfo->spellLevel || spellInfo->spellLevel > unitTarget->getLevel())) - continue; - - elixirs.push_back(itr->first); - } - } - - if (!elixirs.empty()) - { - // cast random elixir on target - uint32 rand_spell = urand(0,elixirs.size()-1); - m_caster->CastSpell(unitTarget,elixirs[rand_spell],true,m_CastItem); - } - } -} - -void Spell::EffectEnergisePct(uint32 i) -{ - if(!unitTarget) - return; - if(!unitTarget->isAlive()) - return; - - if(m_spellInfo->EffectMiscValue[i] < 0 || m_spellInfo->EffectMiscValue[i] >= MAX_POWERS) - return; - - Powers power = Powers(m_spellInfo->EffectMiscValue[i]); - - uint32 maxPower = unitTarget->GetMaxPower(power); - if(maxPower == 0) - return; - - uint32 gain = damage * maxPower / 100; - unitTarget->ModifyPower(power, gain); - m_caster->SendEnergizeSpellLog(unitTarget, m_spellInfo->Id, damage, power); -} - -void Spell::SendLoot(uint64 guid, LootType loottype) -{ - Player* player = (Player*)m_caster; - if (!player) - return; - - if (gameObjTarget) - { - switch (gameObjTarget->GetGoType()) - { - case GAMEOBJECT_TYPE_DOOR: - case GAMEOBJECT_TYPE_BUTTON: - gameObjTarget->UseDoorOrButton(); - sWorld.ScriptsStart(sGameObjectScripts, gameObjTarget->GetDBTableGUIDLow(), player, gameObjTarget); - return; - - case GAMEOBJECT_TYPE_QUESTGIVER: - // start or end quest - player->PrepareQuestMenu(guid); - player->SendPreparedQuest(guid); - return; - - case GAMEOBJECT_TYPE_SPELL_FOCUS: - // triggering linked GO - if(uint32 trapEntry = gameObjTarget->GetGOInfo()->spellFocus.linkedTrapId) - gameObjTarget->TriggeringLinkedGameObject(trapEntry,m_caster); - return; - - case GAMEOBJECT_TYPE_GOOBER: - // goober_scripts can be triggered if the player don't have the quest - if (gameObjTarget->GetGOInfo()->goober.eventId) - { - sLog.outDebug("Goober ScriptStart id %u for GO %u", gameObjTarget->GetGOInfo()->goober.eventId,gameObjTarget->GetDBTableGUIDLow()); - sWorld.ScriptsStart(sEventScripts, gameObjTarget->GetGOInfo()->goober.eventId, player, gameObjTarget); - } - - // cast goober spell - if (gameObjTarget->GetGOInfo()->goober.questId) - ///Quest require to be active for GO using - if(player->GetQuestStatus(gameObjTarget->GetGOInfo()->goober.questId) != QUEST_STATUS_INCOMPLETE) - return; - - gameObjTarget->AddUniqueUse(player); - gameObjTarget->SetLootState(GO_JUST_DEACTIVATED); - - //TODO? Objective counting called without spell check but with quest objective check - // if send spell id then this line will duplicate to spell casting call (double counting) - // So we or have this line and not required in quest_template have reqSpellIdN - // or must remove this line and required in DB have data in quest_template have reqSpellIdN for all quest using cases. - player->CastedCreatureOrGO(gameObjTarget->GetEntry(), gameObjTarget->GetGUID(), 0); - - // triggering linked GO - if(uint32 trapEntry = gameObjTarget->GetGOInfo()->goober.linkedTrapId) - gameObjTarget->TriggeringLinkedGameObject(trapEntry,m_caster); - - return; - - case GAMEOBJECT_TYPE_CHEST: - // TODO: possible must be moved to loot release (in different from linked triggering) - if (gameObjTarget->GetGOInfo()->chest.eventId) - { - sLog.outDebug("Chest ScriptStart id %u for GO %u", gameObjTarget->GetGOInfo()->chest.eventId,gameObjTarget->GetDBTableGUIDLow()); - sWorld.ScriptsStart(sEventScripts, gameObjTarget->GetGOInfo()->chest.eventId, player, gameObjTarget); - } - - // triggering linked GO - if(uint32 trapEntry = gameObjTarget->GetGOInfo()->chest.linkedTrapId) - gameObjTarget->TriggeringLinkedGameObject(trapEntry,m_caster); - - // Don't return, let loots been taken - } - } - - // Send loot - player->SendLoot(guid, loottype); -} - -void Spell::EffectOpenLock(uint32 /*i*/) -{ - if(!m_caster || m_caster->GetTypeId() != TYPEID_PLAYER) - { - sLog.outDebug( "WORLD: Open Lock - No Player Caster!"); - return; - } - - Player* player = (Player*)m_caster; - - LootType loottype = LOOT_CORPSE; - uint32 lockId = 0; - uint64 guid = 0; - - // Get lockId - if(gameObjTarget) - { - GameObjectInfo const* goInfo = gameObjTarget->GetGOInfo(); - // Arathi Basin banner opening ! - if( goInfo->type == GAMEOBJECT_TYPE_BUTTON && goInfo->button.noDamageImmune || - goInfo->type == GAMEOBJECT_TYPE_GOOBER && goInfo->goober.losOK ) - { - if(BattleGround *bg = player->GetBattleGround())// in battleground - { - if( !player->IsMounted() && // not mounted - !player->HasStealthAura() && // not stealthed - !player->HasInvisibilityAura() && // not invisible - player->isAlive() ) // live player - { - // check if it's correct bg - if(bg && bg->GetTypeID() == BATTLEGROUND_AB) - bg->EventPlayerClickedOnFlag(player, gameObjTarget); - - return; - } - } - } - else if (goInfo->type == GAMEOBJECT_TYPE_FLAGSTAND) - { - if(BattleGround *bg = player->GetBattleGround()) - if(bg->GetTypeID() == BATTLEGROUND_EY) - bg->EventPlayerClickedOnFlag(player, gameObjTarget); - return; - } - lockId = gameObjTarget->GetLockId(); - guid = gameObjTarget->GetGUID(); - } - else if(itemTarget) - { - lockId = itemTarget->GetProto()->LockID; - guid = itemTarget->GetGUID(); - } - else - { - sLog.outDebug( "WORLD: Open Lock - No GameObject/Item Target!"); - return; - } - - if(!lockId) // possible case for GO and maybe for items. - { - SendLoot(guid, loottype); - return; - } - - // Get LockInfo - LockEntry const *lockInfo = sLockStore.LookupEntry(lockId); - - if (!lockInfo) - { - sLog.outError( "Spell::EffectOpenLock: %s [guid = %u] has an unknown lockId: %u!", - (gameObjTarget ? "gameobject" : "item"), GUID_LOPART(guid), lockId); - SendCastResult(SPELL_FAILED_BAD_TARGETS); - return; - } - - // check key - for(int i = 0; i < 5; ++i) - { - // type==1 This means lockInfo->key[i] is an item - if(lockInfo->keytype[i]==LOCK_KEY_ITEM && lockInfo->key[i] && m_CastItem && m_CastItem->GetEntry()==lockInfo->key[i]) - { - SendLoot(guid, loottype); - return; - } - } - - uint32 SkillId = 0; - // Check and skill-up skill - if( m_spellInfo->Effect[1] == SPELL_EFFECT_SKILL ) - SkillId = m_spellInfo->EffectMiscValue[1]; - // pickpocketing spells - else if( m_spellInfo->EffectMiscValue[0] == LOCKTYPE_PICKLOCK ) - SkillId = SKILL_LOCKPICKING; - - // skill bonus provided by casting spell (mostly item spells) - uint32 spellSkillBonus = uint32(m_currentBasePoints[0]+1); - - uint32 reqSkillValue = lockInfo->requiredminingskill; - - if(lockInfo->requiredlockskill) // required pick lock skill applying - { - if(SkillId != SKILL_LOCKPICKING) // wrong skill (cheating?) - { - SendCastResult(SPELL_FAILED_FIZZLE); - return; - } - - reqSkillValue = lockInfo->requiredlockskill; - } - else if(SkillId == SKILL_LOCKPICKING) // apply picklock skill to wrong target - { - SendCastResult(SPELL_FAILED_BAD_TARGETS); - return; - } - - if ( SkillId ) - { - loottype = LOOT_SKINNING; - if ( player->GetSkillValue(SkillId) + spellSkillBonus < reqSkillValue ) - { - SendCastResult(SPELL_FAILED_LOW_CASTLEVEL); - return; - } - - // update skill if really known - uint32 SkillValue = player->GetPureSkillValue(SkillId); - if(SkillValue) // non only item base skill - { - if(gameObjTarget) - { - // Allow one skill-up until respawned - if ( !gameObjTarget->IsInSkillupList( player->GetGUIDLow() ) && - player->UpdateGatherSkill(SkillId, SkillValue, reqSkillValue) ) - gameObjTarget->AddToSkillupList( player->GetGUIDLow() ); - } - else if(itemTarget) - { - // Do one skill-up - uint32 SkillValue = player->GetPureSkillValue(SkillId); - player->UpdateGatherSkill(SkillId, SkillValue, reqSkillValue); - } - } - } - - SendLoot(guid, loottype); -} - -void Spell::EffectSummonChangeItem(uint32 i) -{ - if(m_caster->GetTypeId() != TYPEID_PLAYER) - return; - - Player *player = (Player*)m_caster; - - // applied only to using item - if(!m_CastItem) - return; - - // ... only to item in own inventory/bank/equip_slot - if(m_CastItem->GetOwnerGUID()!=player->GetGUID()) - return; - - uint32 newitemid = m_spellInfo->EffectItemType[i]; - if(!newitemid) - return; - - uint16 pos = m_CastItem->GetPos(); - - Item *pNewItem = Item::CreateItem( newitemid, 1, player); - if( !pNewItem ) - return; - - for(uint8 i= PERM_ENCHANTMENT_SLOT; i<=TEMP_ENCHANTMENT_SLOT; ++i) - { - if(m_CastItem->GetEnchantmentId(EnchantmentSlot(i))) - pNewItem->SetEnchantment(EnchantmentSlot(i), m_CastItem->GetEnchantmentId(EnchantmentSlot(i)), m_CastItem->GetEnchantmentDuration(EnchantmentSlot(i)), m_CastItem->GetEnchantmentCharges(EnchantmentSlot(i))); - } - - if(m_CastItem->GetUInt32Value(ITEM_FIELD_DURABILITY) < m_CastItem->GetUInt32Value(ITEM_FIELD_MAXDURABILITY)) - { - double loosePercent = 1 - m_CastItem->GetUInt32Value(ITEM_FIELD_DURABILITY) / double(m_CastItem->GetUInt32Value(ITEM_FIELD_MAXDURABILITY)); - player->DurabilityLoss(pNewItem, loosePercent); - } - - if( player->IsInventoryPos( pos ) ) - { - ItemPosCountVec dest; - uint8 msg = player->CanStoreItem( m_CastItem->GetBagSlot(), m_CastItem->GetSlot(), dest, pNewItem, true ); - if( msg == EQUIP_ERR_OK ) - { - player->DestroyItem(m_CastItem->GetBagSlot(), m_CastItem->GetSlot(),true); - - // prevent crash at access and unexpected charges counting with item update queue corrupt - if(m_CastItem==m_targets.getItemTarget()) - m_targets.setItemTarget(NULL); - - m_CastItem = NULL; - - player->StoreItem( dest, pNewItem, true); - return; - } - } - else if( player->IsBankPos ( pos ) ) - { - ItemPosCountVec dest; - uint8 msg = player->CanBankItem( m_CastItem->GetBagSlot(), m_CastItem->GetSlot(), dest, pNewItem, true ); - if( msg == EQUIP_ERR_OK ) - { - player->DestroyItem(m_CastItem->GetBagSlot(), m_CastItem->GetSlot(),true); - - // prevent crash at access and unexpected charges counting with item update queue corrupt - if(m_CastItem==m_targets.getItemTarget()) - m_targets.setItemTarget(NULL); - - m_CastItem = NULL; - - player->BankItem( dest, pNewItem, true); - return; - } - } - else if( player->IsEquipmentPos ( pos ) ) - { - uint16 dest; - uint8 msg = player->CanEquipItem( m_CastItem->GetSlot(), dest, pNewItem, true ); - if( msg == EQUIP_ERR_OK ) - { - player->DestroyItem(m_CastItem->GetBagSlot(), m_CastItem->GetSlot(),true); - - // prevent crash at access and unexpected charges counting with item update queue corrupt - if(m_CastItem==m_targets.getItemTarget()) - m_targets.setItemTarget(NULL); - - m_CastItem = NULL; - - player->EquipItem( dest, pNewItem, true); - player->AutoUnequipOffhandIfNeed(); - return; - } - } - - // fail - delete pNewItem; -} - -void Spell::EffectOpenSecretSafe(uint32 i) -{ - EffectOpenLock(i); //no difference for now -} - -void Spell::EffectProficiency(uint32 /*i*/) -{ - if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) - return; - Player *p_target = (Player*)unitTarget; - - uint32 subClassMask = m_spellInfo->EquippedItemSubClassMask; - if(m_spellInfo->EquippedItemClass == 2 && !(p_target->GetWeaponProficiency() & subClassMask)) - { - p_target->AddWeaponProficiency(subClassMask); - p_target->SendProficiency(uint8(0x02),p_target->GetWeaponProficiency()); - } - if(m_spellInfo->EquippedItemClass == 4 && !(p_target->GetArmorProficiency() & subClassMask)) - { - p_target->AddArmorProficiency(subClassMask); - p_target->SendProficiency(uint8(0x04),p_target->GetArmorProficiency()); - } -} - -void Spell::EffectApplyAreaAura(uint32 i) -{ - if(!unitTarget) - return; - if(!unitTarget->isAlive()) - return; - - AreaAura* Aur = new AreaAura(m_spellInfo, i, &m_currentBasePoints[i], unitTarget, m_caster, m_CastItem); - unitTarget->AddAura(Aur); -} - -void Spell::EffectSummonType(uint32 i) -{ - switch(m_spellInfo->EffectMiscValueB[i]) - { - case SUMMON_TYPE_GUARDIAN: - case SUMMON_TYPE_POSESSED: - case SUMMON_TYPE_POSESSED2: - EffectSummonGuardian(i); - break; - case SUMMON_TYPE_WILD: - EffectSummonWild(i); - break; - case SUMMON_TYPE_DEMON: - EffectSummonDemon(i); - break; - case SUMMON_TYPE_SUMMON: - EffectSummon(i); - break; - case SUMMON_TYPE_CRITTER: - case SUMMON_TYPE_CRITTER2: - EffectSummonCritter(i); - break; - case SUMMON_TYPE_TOTEM_SLOT1: - case SUMMON_TYPE_TOTEM_SLOT2: - case SUMMON_TYPE_TOTEM_SLOT3: - case SUMMON_TYPE_TOTEM_SLOT4: - case SUMMON_TYPE_TOTEM: - EffectSummonTotem(i); - break; - case SUMMON_TYPE_UNKNOWN1: - case SUMMON_TYPE_UNKNOWN2: - case SUMMON_TYPE_UNKNOWN3: - case SUMMON_TYPE_UNKNOWN4: - case SUMMON_TYPE_UNKNOWN5: - case SUMMON_TYPE_UNKNOWN6: - break; - default: - sLog.outError("EffectSummonType: Unhandled summon type %u", m_spellInfo->EffectMiscValueB[i]); - break; - } -} - -void Spell::EffectSummon(uint32 i) -{ - if(m_caster->GetPetGUID()) - return; - - if(!unitTarget) - return; - uint32 pet_entry = m_spellInfo->EffectMiscValue[i]; - if(!pet_entry) - return; - uint32 level = m_caster->getLevel(); - Pet* spawnCreature = new Pet(SUMMON_PET); - - if(spawnCreature->LoadPetFromDB(m_caster,pet_entry)) - { - // set timer for unsummon - int32 duration = GetSpellDuration(m_spellInfo); - if(duration > 0) - spawnCreature->SetDuration(duration); - - return; - } - - Map *map = m_caster->GetMap(); - uint32 pet_number = objmgr.GeneratePetNumber(); - if(!spawnCreature->Create(objmgr.GenerateLowGuid(HIGHGUID_PET),map,m_spellInfo->EffectMiscValue[i], pet_number)) - { - sLog.outErrorDb("Spell::EffectSummon: no such creature entry %u",m_spellInfo->EffectMiscValue[i]); - delete spawnCreature; - return; - } - - // Summon in dest location - float x,y,z; - if(m_targets.m_targetMask & TARGET_FLAG_DEST_LOCATION) - { - x = m_targets.m_destX; - y = m_targets.m_destY; - z = m_targets.m_destZ; - } - else - m_caster->GetClosePoint(x,y,z,spawnCreature->GetObjectSize()); - - spawnCreature->Relocate(x,y,z,-m_caster->GetOrientation()); - - if(!spawnCreature->IsPositionValid()) - { - sLog.outError("ERROR: Pet (guidlow %d, entry %d) not summoned. Suggested coordinates isn't valid (X: %d Y: ^%d)", spawnCreature->GetGUIDLow(), spawnCreature->GetEntry(), spawnCreature->GetPositionX(), spawnCreature->GetPositionY()); - delete spawnCreature; - return; - } - - // set timer for unsummon - int32 duration = GetSpellDuration(m_spellInfo); - if(duration > 0) - spawnCreature->SetDuration(duration); - - spawnCreature->SetUInt64Value(UNIT_FIELD_SUMMONEDBY,m_caster->GetGUID()); - spawnCreature->SetUInt32Value(UNIT_NPC_FLAGS , 0); - spawnCreature->setPowerType(POWER_MANA); - spawnCreature->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE,m_caster->getFaction()); - spawnCreature->SetUInt32Value(UNIT_FIELD_FLAGS,0); - spawnCreature->SetUInt32Value(UNIT_FIELD_BYTES_0,2048); - spawnCreature->SetUInt32Value(UNIT_FIELD_BYTES_1,0); - spawnCreature->SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP,0); - spawnCreature->SetUInt32Value(UNIT_FIELD_PETEXPERIENCE,0); - spawnCreature->SetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP,1000); - spawnCreature->SetUInt64Value(UNIT_FIELD_CREATEDBY, m_caster->GetGUID()); - spawnCreature->SetUInt32Value(UNIT_CREATED_BY_SPELL, m_spellInfo->Id); - - spawnCreature->InitStatsForLevel(level); - - spawnCreature->GetCharmInfo()->SetPetNumber(pet_number, false); - - spawnCreature->AIM_Initialize(); - spawnCreature->InitPetCreateSpells(); - spawnCreature->SetHealth(spawnCreature->GetMaxHealth()); - spawnCreature->SetPower(POWER_MANA, spawnCreature->GetMaxPower(POWER_MANA)); - - std::string name = m_caster->GetName(); - name.append(petTypeSuffix[spawnCreature->getPetType()]); - spawnCreature->SetName( name ); - - map->Add((Creature*)spawnCreature); - - if(m_caster->GetTypeId() == TYPEID_PLAYER) - { - m_caster->SetPet(spawnCreature); - spawnCreature->GetCharmInfo()->SetReactState( REACT_DEFENSIVE ); - spawnCreature->SavePetToDB(PET_SAVE_AS_CURRENT); - ((Player*)m_caster)->PetSpellInitialize(); - } -} - -void Spell::EffectLearnSpell(uint32 i) -{ - if(!unitTarget) - return; - - if(unitTarget->GetTypeId() != TYPEID_PLAYER) - { - if(m_caster->GetTypeId() == TYPEID_PLAYER) - EffectLearnPetSpell(i); - - return; - } - - Player *player = (Player*)unitTarget; - - uint32 spellToLearn = (m_spellInfo->Id==SPELL_ID_GENERIC_LEARN) ? damage : m_spellInfo->EffectTriggerSpell[i]; - player->learnSpell(spellToLearn); - - sLog.outDebug( "Spell: Player %u have learned spell %u from NpcGUID=%u", player->GetGUIDLow(), spellToLearn, m_caster->GetGUIDLow() ); -} - -void Spell::EffectDispel(uint32 i) -{ - if(!unitTarget) - return; - - // Fill possible dispell list - std::vector dispel_list; - - // Create dispel mask by dispel type - uint32 dispel_type = m_spellInfo->EffectMiscValue[i]; - uint32 dispelMask = GetDispellMask( DispelType(dispel_type) ); - Unit::AuraMap const& auras = unitTarget->GetAuras(); - for(Unit::AuraMap::const_iterator itr = auras.begin(); itr != auras.end(); ++itr) - { - Aura *aur = (*itr).second; - if (aur && (1<GetSpellProto()->Dispel) & dispelMask) - { - if(aur->GetSpellProto()->Dispel == DISPEL_MAGIC) - { - bool positive = true; - if (!aur->IsPositive()) - positive = false; - else - positive = (aur->GetSpellProto()->AttributesEx & SPELL_ATTR_EX_NEGATIVE)==0; - - // do not remove positive auras if friendly target - // negative auras if non-friendly target - if(positive == unitTarget->IsFriendlyTo(m_caster)) - continue; - } - // Add aura to dispel list - dispel_list.push_back(aur); - } - } - // Ok if exist some buffs for dispel try dispel it - if (!dispel_list.empty()) - { - std::list < std::pair > success_list;// (spell_id,casterGuid) - std::list < uint32 > fail_list; // spell_id - int32 list_size = dispel_list.size(); - // Dispell N = damage buffs (or while exist buffs for dispel) - for (int32 count=0; count < damage && list_size > 0; ++count) - { - // Random select buff for dispel - Aura *aur = dispel_list[urand(0, list_size-1)]; - - SpellEntry const* spellInfo = aur->GetSpellProto(); - // Base dispel chance - // TODO: possible chance depend from spell level?? - int32 miss_chance = 0; - // Apply dispel mod from aura caster - if (Unit *caster = aur->GetCaster()) - { - if ( Player* modOwner = caster->GetSpellModOwner() ) - modOwner->ApplySpellMod(spellInfo->Id, SPELLMOD_RESIST_DISPEL_CHANCE, miss_chance, this); - } - // Try dispel - if (roll_chance_i(miss_chance)) - fail_list.push_back(aur->GetId()); - else - success_list.push_back(std::pair(aur->GetId(),aur->GetCasterGUID())); - // Remove buff from list for prevent doubles - for (std::vector::iterator j = dispel_list.begin(); j != dispel_list.end(); ) - { - Aura *dispeled = *j; - if (dispeled->GetId() == aur->GetId() && dispeled->GetCasterGUID() == aur->GetCasterGUID()) - { - j = dispel_list.erase(j); - --list_size; - } - else - ++j; - } - } - // Send success log and really remove auras - if (!success_list.empty()) - { - int32 count = success_list.size(); - WorldPacket data(SMSG_SPELLDISPELLOG, 8+8+4+1+4+count*5); - data.append(unitTarget->GetPackGUID()); // Victim GUID - data.append(m_caster->GetPackGUID()); // Caster GUID - data << uint32(m_spellInfo->Id); // Dispell spell id - data << uint8(0); // not used - data << uint32(count); // count - for (std::list >::iterator j = success_list.begin(); j != success_list.end(); ++j) - { - SpellEntry const* spellInfo = sSpellStore.LookupEntry(j->first); - data << uint32(spellInfo->Id); // Spell Id - data << uint8(0); // 0 - dispeled !=0 cleansed - unitTarget->RemoveAurasDueToSpellByDispel(spellInfo->Id, j->second, m_caster); - } - m_caster->SendMessageToSet(&data, true); - - // On succes dispel - // Devour Magic - if (m_spellInfo->SpellFamilyName == SPELLFAMILY_WARLOCK && m_spellInfo->Category == 12) - { - uint32 heal_spell = 0; - switch (m_spellInfo->Id) - { - case 19505: heal_spell = 19658; break; - case 19731: heal_spell = 19732; break; - case 19734: heal_spell = 19733; break; - case 19736: heal_spell = 19735; break; - case 27276: heal_spell = 27278; break; - case 27277: heal_spell = 27279; break; - default: - sLog.outDebug("Spell for Devour Magic %d not handled in Spell::EffectDispel", m_spellInfo->Id); - break; - } - if (heal_spell) - m_caster->CastSpell(m_caster, heal_spell, true); - } - } - // Send fail log to client - if (!fail_list.empty()) - { - // Failed to dispell - WorldPacket data(SMSG_DISPEL_FAILED, 8+8+4+4*fail_list.size()); - data << uint64(m_caster->GetGUID()); // Caster GUID - data << uint64(unitTarget->GetGUID()); // Victim GUID - data << uint32(m_spellInfo->Id); // Dispell spell id - for (std::list< uint32 >::iterator j = fail_list.begin(); j != fail_list.end(); ++j) - data << uint32(*j); // Spell Id - m_caster->SendMessageToSet(&data, true); - } - } -} - -void Spell::EffectDualWield(uint32 /*i*/) -{ - if (unitTarget->GetTypeId() == TYPEID_PLAYER) - ((Player*)unitTarget)->SetCanDualWield(true); -} - -void Spell::EffectPull(uint32 /*i*/) -{ - // TODO: create a proper pull towards distract spell center for distract - sLog.outDebug("WORLD: Spell Effect DUMMY"); -} - -void Spell::EffectDistract(uint32 /*i*/) -{ - // Check for possible target - if (!unitTarget || unitTarget->isInCombat()) - return; - - // target must be OK to do this - if( unitTarget->hasUnitState(UNIT_STAT_CONFUSED | UNIT_STAT_STUNDED | UNIT_STAT_FLEEING ) ) - return; - - float angle = unitTarget->GetAngle(m_targets.m_destX, m_targets.m_destY); - - if ( unitTarget->GetTypeId() == TYPEID_PLAYER ) - { - // For players just turn them - WorldPacket data; - ((Player*)unitTarget)->BuildTeleportAckMsg(&data, unitTarget->GetPositionX(), unitTarget->GetPositionY(), unitTarget->GetPositionZ(), angle); - ((Player*)unitTarget)->GetSession()->SendPacket( &data ); - ((Player*)unitTarget)->SetPosition(unitTarget->GetPositionX(), unitTarget->GetPositionY(), unitTarget->GetPositionZ(), angle, false); - } - else - { - // Set creature Distracted, Stop it, And turn it - unitTarget->SetOrientation(angle); - unitTarget->StopMoving(); - unitTarget->GetMotionMaster()->MoveDistract(damage*1000); - } -} - -void Spell::EffectPickPocket(uint32 /*i*/) -{ - if( m_caster->GetTypeId() != TYPEID_PLAYER ) - return; - - // victim must be creature and attackable - if( !unitTarget || unitTarget->GetTypeId() != TYPEID_UNIT || m_caster->IsFriendlyTo(unitTarget) ) - return; - - // victim have to be alive and humanoid or undead - if( unitTarget->isAlive() && (unitTarget->GetCreatureTypeMask() &CREATURE_TYPEMASK_HUMANOID_OR_UNDEAD) != 0) - { - int32 chance = 10 + int32(m_caster->getLevel()) - int32(unitTarget->getLevel()); - - if (chance > irand(0, 19)) - { - // Stealing successful - //sLog.outDebug("Sending loot from pickpocket"); - ((Player*)m_caster)->SendLoot(unitTarget->GetGUID(),LOOT_PICKPOCKETING); - } - else - { - // Reveal action + get attack - m_caster->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); - if (((Creature*)unitTarget)->AI()) - ((Creature*)unitTarget)->AI()->AttackStart(m_caster); - } - } -} - -void Spell::EffectAddFarsight(uint32 i) -{ - float radius = GetSpellRadius(sSpellRadiusStore.LookupEntry(m_spellInfo->EffectRadiusIndex[i])); - int32 duration = GetSpellDuration(m_spellInfo); - DynamicObject* dynObj = new DynamicObject; - if(!dynObj->Create(objmgr.GenerateLowGuid(HIGHGUID_DYNAMICOBJECT), m_caster, m_spellInfo->Id, i, m_targets.m_destX, m_targets.m_destY, m_targets.m_destZ, duration, radius)) - { - delete dynObj; - return; - } - dynObj->SetUInt32Value(OBJECT_FIELD_TYPE, 65); - dynObj->SetUInt32Value(DYNAMICOBJECT_BYTES, 0x80000002); - m_caster->AddDynObject(dynObj); - MapManager::Instance().GetMap(dynObj->GetMapId(), dynObj)->Add(dynObj); - m_caster->SetUInt64Value(PLAYER_FARSIGHT, dynObj->GetGUID()); -} - -void Spell::EffectSummonWild(uint32 i) -{ - uint32 creature_entry = m_spellInfo->EffectMiscValue[i]; - if(!creature_entry) - return; - - uint32 level = m_caster->getLevel(); - - // level of creature summoned using engineering item based at engineering skill level - if(m_caster->GetTypeId()==TYPEID_PLAYER && m_CastItem) - { - ItemPrototype const *proto = m_CastItem->GetProto(); - if(proto && proto->RequiredSkill == SKILL_ENGINERING) - { - uint16 skill202 = ((Player*)m_caster)->GetSkillValue(SKILL_ENGINERING); - if(skill202) - { - level = skill202/5; - } - } - } - - // select center of summon position - float center_x = m_targets.m_destX; - float center_y = m_targets.m_destY; - float center_z = m_targets.m_destZ; - - float radius = GetSpellRadius(sSpellRadiusStore.LookupEntry(m_spellInfo->EffectRadiusIndex[i])); - - int32 amount = damage > 0 ? damage : 1; - - for(int32 count = 0; count < amount; ++count) - { - float px, py, pz; - // If dest location if present - if (m_targets.m_targetMask & TARGET_FLAG_DEST_LOCATION) - { - // Summon 1 unit in dest location - if (count == 0) - { - px = m_targets.m_destX; - py = m_targets.m_destY; - pz = m_targets.m_destZ; - } - // Summon in random point all other units if location present - else - m_caster->GetRandomPoint(center_x,center_y,center_z,radius,px,py,pz); - } - // Summon if dest location not present near caster - else - m_caster->GetClosePoint(px,py,pz,3.0f); - - int32 duration = GetSpellDuration(m_spellInfo); - - TempSummonType summonType = (duration == 0) ? TEMPSUMMON_DEAD_DESPAWN : TEMPSUMMON_TIMED_OR_DEAD_DESPAWN; - - m_caster->SummonCreature(creature_entry,px,py,pz,m_caster->GetOrientation(),summonType,duration); - } -} - -void Spell::EffectSummonGuardian(uint32 i) -{ - uint32 pet_entry = m_spellInfo->EffectMiscValue[i]; - if(!pet_entry) - return; - - // Jewelery statue case (totem like) - if(m_spellInfo->SpellIconID==2056) - { - EffectSummonTotem(i); - return; - } - - // set timer for unsummon - int32 duration = GetSpellDuration(m_spellInfo); - - // Search old Guardian only for players (if casted spell not have duration or cooldown) - // FIXME: some guardians have control spell applied and controlled by player and anyway player can't summon in this time - // so this code hack in fact - if( m_caster->GetTypeId() == TYPEID_PLAYER && (duration <= 0 || GetSpellRecoveryTime(m_spellInfo)==0) ) - if(((Player*)m_caster)->HasGuardianWithEntry(pet_entry)) - return; // find old guardian, ignore summon - - // in another case summon new - uint32 level = m_caster->getLevel(); - - // level of pet summoned using engineering item based at engineering skill level - if(m_caster->GetTypeId()==TYPEID_PLAYER && m_CastItem) - { - ItemPrototype const *proto = m_CastItem->GetProto(); - if(proto && proto->RequiredSkill == SKILL_ENGINERING) - { - uint16 skill202 = ((Player*)m_caster)->GetSkillValue(SKILL_ENGINERING); - if(skill202) - { - level = skill202/5; - } - } - } - - // select center of summon position - float center_x = m_targets.m_destX; - float center_y = m_targets.m_destY; - float center_z = m_targets.m_destZ; - - float radius = GetSpellRadius(sSpellRadiusStore.LookupEntry(m_spellInfo->EffectRadiusIndex[i])); - - int32 amount = damage > 0 ? damage : 1; - - for(int32 count = 0; count < amount; ++count) - { - Pet* spawnCreature = new Pet(GUARDIAN_PET); - - Map *map = m_caster->GetMap(); - uint32 pet_number = objmgr.GeneratePetNumber(); - if(!spawnCreature->Create(objmgr.GenerateLowGuid(HIGHGUID_PET), map,m_spellInfo->EffectMiscValue[i], pet_number)) - { - sLog.outError("no such creature entry %u",m_spellInfo->EffectMiscValue[i]); - delete spawnCreature; - return; - } - - float px, py, pz; - // If dest location if present - if (m_targets.m_targetMask & TARGET_FLAG_DEST_LOCATION) - { - // Summon 1 unit in dest location - if (count == 0) - { - px = m_targets.m_destX; - py = m_targets.m_destY; - pz = m_targets.m_destZ; - } - // Summon in random point all other units if location present - else - m_caster->GetRandomPoint(center_x,center_y,center_z,radius,px,py,pz); - } - // Summon if dest location not present near caster - else - m_caster->GetClosePoint(px,py,pz,spawnCreature->GetObjectSize()); - - spawnCreature->Relocate(px,py,pz,m_caster->GetOrientation()); - - if(!spawnCreature->IsPositionValid()) - { - sLog.outError("ERROR: Pet (guidlow %d, entry %d) not created base at creature. Suggested coordinates isn't valid (X: %d Y: ^%d)", spawnCreature->GetGUIDLow(), spawnCreature->GetEntry(), spawnCreature->GetPositionX(), spawnCreature->GetPositionY()); - delete spawnCreature; - return; - } - - if(duration > 0) - spawnCreature->SetDuration(duration); - - spawnCreature->SetUInt64Value(UNIT_FIELD_SUMMONEDBY,m_caster->GetGUID()); - spawnCreature->setPowerType(POWER_MANA); - spawnCreature->SetUInt32Value(UNIT_NPC_FLAGS , 0); - spawnCreature->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE,m_caster->getFaction()); - spawnCreature->SetUInt32Value(UNIT_FIELD_FLAGS,0); - spawnCreature->SetUInt32Value(UNIT_FIELD_BYTES_1,0); - spawnCreature->SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP,0); - spawnCreature->SetUInt64Value(UNIT_FIELD_CREATEDBY, m_caster->GetGUID()); - spawnCreature->SetUInt32Value(UNIT_CREATED_BY_SPELL, m_spellInfo->Id); - - spawnCreature->InitStatsForLevel(level); - spawnCreature->GetCharmInfo()->SetPetNumber(pet_number, false); - - spawnCreature->AIM_Initialize(); - - if(m_caster->GetTypeId()==TYPEID_PLAYER) - ((Player*)m_caster)->AddGuardian(spawnCreature); - - map->Add((Creature*)spawnCreature); - } -} - -void Spell::EffectTeleUnitsFaceCaster(uint32 i) -{ - if(!unitTarget) - return; - - if(unitTarget->isInFlight()) - return; - - uint32 mapid = m_caster->GetMapId(); - float dis = GetSpellRadius(sSpellRadiusStore.LookupEntry(m_spellInfo->EffectRadiusIndex[i])); - - float fx,fy,fz; - m_caster->GetClosePoint(fx,fy,fz,unitTarget->GetObjectSize(),dis); - - if(unitTarget->GetTypeId() == TYPEID_PLAYER) - ((Player*)unitTarget)->TeleportTo(mapid, fx, fy, fz, -m_caster->GetOrientation(), TELE_TO_NOT_LEAVE_COMBAT | TELE_TO_NOT_UNSUMMON_PET | (unitTarget==m_caster ? TELE_TO_SPELL : 0)); - else - MapManager::Instance().GetMap(mapid, m_caster)->CreatureRelocation((Creature*)m_caster, fx, fy, fz, -m_caster->GetOrientation()); -} - -void Spell::EffectLearnSkill(uint32 i) -{ - if(unitTarget->GetTypeId() != TYPEID_PLAYER) - return; - - if(damage < 0) - return; - - uint32 skillid = m_spellInfo->EffectMiscValue[i]; - uint16 skillval = ((Player*)unitTarget)->GetPureSkillValue(skillid); - ((Player*)unitTarget)->SetSkill(skillid, skillval?skillval:1, damage*75); -} - -void Spell::EffectAddHonor(uint32 /*i*/) -{ - if(unitTarget->GetTypeId() != TYPEID_PLAYER) - return; - - sLog.outDebug("SpellEffect::AddHonor called for spell_id %u , that rewards %d honor points to player: %u", m_spellInfo->Id, this->damage, ((Player*)unitTarget)->GetGUIDLow()); - - // TODO: find formula for honor reward based on player's level! - - // now fixed only for level 70 players: - if (((Player*)unitTarget)->getLevel() == 70) - ((Player*)unitTarget)->RewardHonor(NULL, 1, this->damage); -} - -void Spell::EffectTradeSkill(uint32 /*i*/) -{ - if(unitTarget->GetTypeId() != TYPEID_PLAYER) - return; - // uint32 skillid = m_spellInfo->EffectMiscValue[i]; - // uint16 skillmax = ((Player*)unitTarget)->(skillid); - // ((Player*)unitTarget)->SetSkill(skillid,skillval?skillval:1,skillmax+75); -} - -void Spell::EffectEnchantItemPerm(uint32 i) -{ - if(m_caster->GetTypeId() != TYPEID_PLAYER) - return; - if (!itemTarget) - return; - - Player* p_caster = (Player*)m_caster; - - p_caster->UpdateCraftSkill(m_spellInfo->Id); - - if (m_spellInfo->EffectMiscValue[i]) - { - uint32 enchant_id = m_spellInfo->EffectMiscValue[i]; - - SpellItemEnchantmentEntry const *pEnchant = sSpellItemEnchantmentStore.LookupEntry(enchant_id); - if(!pEnchant) - return; - - // item can be in trade slot and have owner diff. from caster - Player* item_owner = itemTarget->GetOwner(); - if(!item_owner) - return; - - if(item_owner!=p_caster && p_caster->GetSession()->GetSecurity() > SEC_PLAYER && sWorld.getConfig(CONFIG_GM_LOG_TRADE) ) - sLog.outCommand("GM %s (Account: %u) enchanting(perm): %s (Entry: %d) for player: %s (Account: %u)", - p_caster->GetName(),p_caster->GetSession()->GetAccountId(), - itemTarget->GetProto()->Name1,itemTarget->GetEntry(), - item_owner->GetName(),item_owner->GetSession()->GetAccountId()); - - // remove old enchanting before applying new if equipped - item_owner->ApplyEnchantment(itemTarget,PERM_ENCHANTMENT_SLOT,false); - - itemTarget->SetEnchantment(PERM_ENCHANTMENT_SLOT, enchant_id, 0, 0); - - // add new enchanting if equipped - item_owner->ApplyEnchantment(itemTarget,PERM_ENCHANTMENT_SLOT,true); - } -} - -void Spell::EffectEnchantItemTmp(uint32 i) -{ - if(m_caster->GetTypeId() != TYPEID_PLAYER) - return; - - Player* p_caster = (Player*)m_caster; - - if(!itemTarget) - return; - - uint32 enchant_id = m_spellInfo->EffectMiscValue[i]; - - // Shaman Rockbiter Weapon - if(i==0 && m_spellInfo->Effect[1]==SPELL_EFFECT_DUMMY) - { - int32 enchnting_damage = m_currentBasePoints[1]+1; - - // enchanting id selected by calculated damage-per-sec stored in Effect[1] base value - // with already applied percent bonus from Elemental Weapons talent - // Note: damage calculated (correctly) with rounding int32(float(v)) but - // RW enchantments applied damage int32(float(v)+0.5), this create 0..1 difference sometime - switch(enchnting_damage) - { - // Rank 1 - case 2: enchant_id = 29; break; // 0% [ 7% == 2, 14% == 2, 20% == 2] - // Rank 2 - case 4: enchant_id = 6; break; // 0% [ 7% == 4, 14% == 4] - case 5: enchant_id = 3025; break; // 20% - // Rank 3 - case 6: enchant_id = 1; break; // 0% [ 7% == 6, 14% == 6] - case 7: enchant_id = 3027; break; // 20% - // Rank 4 - case 9: enchant_id = 3032; break; // 0% [ 7% == 6] - case 10: enchant_id = 503; break; // 14% - case 11: enchant_id = 3031; break; // 20% - // Rank 5 - case 15: enchant_id = 3035; break; // 0% - case 16: enchant_id = 1663; break; // 7% - case 17: enchant_id = 3033; break; // 14% - case 18: enchant_id = 3034; break; // 20% - // Rank 6 - case 28: enchant_id = 3038; break; // 0% - case 29: enchant_id = 683; break; // 7% - case 31: enchant_id = 3036; break; // 14% - case 33: enchant_id = 3037; break; // 20% - // Rank 7 - case 40: enchant_id = 3041; break; // 0% - case 42: enchant_id = 1664; break; // 7% - case 45: enchant_id = 3039; break; // 14% - case 48: enchant_id = 3040; break; // 20% - // Rank 8 - case 49: enchant_id = 3044; break; // 0% - case 52: enchant_id = 2632; break; // 7% - case 55: enchant_id = 3042; break; // 14% - case 58: enchant_id = 3043; break; // 20% - // Rank 9 - case 62: enchant_id = 2633; break; // 0% - case 66: enchant_id = 3018; break; // 7% - case 70: enchant_id = 3019; break; // 14% - case 74: enchant_id = 3020; break; // 20% - default: - sLog.outError("Spell::EffectEnchantItemTmp: Damage %u not handled in S'RW",enchnting_damage); - return; - } - } - - if (!enchant_id) - { - sLog.outError("Spell %u Effect %u (SPELL_EFFECT_ENCHANT_ITEM_TEMPORARY) have 0 as enchanting id",m_spellInfo->Id,i); - return; - } - - SpellItemEnchantmentEntry const *pEnchant = sSpellItemEnchantmentStore.LookupEntry(enchant_id); - if(!pEnchant) - { - sLog.outError("Spell %u Effect %u (SPELL_EFFECT_ENCHANT_ITEM_TEMPORARY) have not existed enchanting id %u ",m_spellInfo->Id,i,enchant_id); - return; - } - - // select enchantment duration - uint32 duration; - - // rogue family enchantments exception by duration - if(m_spellInfo->Id==38615) - duration = 1800; // 30 mins - // other rogue family enchantments always 1 hour (some have spell damage=0, but some have wrong data in EffBasePoints) - else if(m_spellInfo->SpellFamilyName==SPELLFAMILY_ROGUE) - duration = 3600; // 1 hour - // shaman family enchantments - else if(m_spellInfo->SpellFamilyName==SPELLFAMILY_SHAMAN) - duration = 1800; // 30 mins - // other cases with this SpellVisual already selected - else if(m_spellInfo->SpellVisual==215) - duration = 1800; // 30 mins - // some fishing pole bonuses - else if(m_spellInfo->SpellVisual==563) - duration = 600; // 10 mins - // shaman rockbiter enchantments - else if(m_spellInfo->SpellVisual==0) - duration = 1800; // 30 mins - else if(m_spellInfo->Id==29702) - duration = 300; // 5 mins - else if(m_spellInfo->Id==37360) - duration = 300; // 5 mins - // default case - else - duration = 3600; // 1 hour - - // item can be in trade slot and have owner diff. from caster - Player* item_owner = itemTarget->GetOwner(); - if(!item_owner) - return; - - if(item_owner!=p_caster && p_caster->GetSession()->GetSecurity() > SEC_PLAYER && sWorld.getConfig(CONFIG_GM_LOG_TRADE) ) - sLog.outCommand("GM %s (Account: %u) enchanting(temp): %s (Entry: %d) for player: %s (Account: %u)", - p_caster->GetName(),p_caster->GetSession()->GetAccountId(), - itemTarget->GetProto()->Name1,itemTarget->GetEntry(), - item_owner->GetName(),item_owner->GetSession()->GetAccountId()); - - // remove old enchanting before applying new if equipped - item_owner->ApplyEnchantment(itemTarget,TEMP_ENCHANTMENT_SLOT,false); - - itemTarget->SetEnchantment(TEMP_ENCHANTMENT_SLOT, enchant_id, duration*1000, 0); - - // add new enchanting if equipped - item_owner->ApplyEnchantment(itemTarget,TEMP_ENCHANTMENT_SLOT,true); -} - -void Spell::EffectTameCreature(uint32 /*i*/) -{ - if(m_caster->GetPetGUID()) - return; - - if(!unitTarget) - return; - - if(unitTarget->GetTypeId() == TYPEID_PLAYER) - return; - - Creature* creatureTarget = (Creature*)unitTarget; - - if(creatureTarget->isPet()) - return; - - if(m_caster->getClass() == CLASS_HUNTER) - { - // cast finish successfully - //SendChannelUpdate(0); - finish(); - - Pet* pet = new Pet(HUNTER_PET); - - if(!pet->CreateBaseAtCreature(creatureTarget)) - { - delete pet; - return; - } - - creatureTarget->setDeathState(JUST_DIED); - creatureTarget->RemoveCorpse(); - creatureTarget->SetHealth(0); // just for nice GM-mode view - - pet->SetUInt64Value(UNIT_FIELD_SUMMONEDBY, m_caster->GetGUID()); - pet->SetUInt64Value(UNIT_FIELD_CREATEDBY, m_caster->GetGUID()); - pet->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE,m_caster->getFaction()); - pet->SetUInt32Value(UNIT_CREATED_BY_SPELL, m_spellInfo->Id); - - if(!pet->InitStatsForLevel(creatureTarget->getLevel())) - { - sLog.outError("ERROR: InitStatsForLevel() in EffectTameCreature failed! Pet deleted."); - delete pet; - return; - } - - // prepare visual effect for levelup - pet->SetUInt32Value(UNIT_FIELD_LEVEL,creatureTarget->getLevel()-1); - - pet->GetCharmInfo()->SetPetNumber(objmgr.GeneratePetNumber(), true); - // this enables pet details window (Shift+P) - pet->AIM_Initialize(); - pet->InitPetCreateSpells(); - pet->SetHealth(pet->GetMaxHealth()); - - MapManager::Instance().GetMap(pet->GetMapId(), pet)->Add((Creature*)pet); - - // visual effect for levelup - pet->SetUInt32Value(UNIT_FIELD_LEVEL,creatureTarget->getLevel()); - - if(m_caster->GetTypeId() == TYPEID_PLAYER) - { - m_caster->SetPet(pet); - pet->SavePetToDB(PET_SAVE_AS_CURRENT); - ((Player*)m_caster)->PetSpellInitialize(); - } - } -} - -void Spell::EffectSummonPet(uint32 i) -{ - uint32 petentry = m_spellInfo->EffectMiscValue[i]; - - Pet *OldSummon = m_caster->GetPet(); - - // if pet requested type already exist - if( OldSummon ) - { - if(petentry == 0 || OldSummon->GetEntry() == petentry) - { - // pet in corpse state can't be summoned - if( OldSummon->isDead() ) - return; - - MapManager::Instance().GetMap(OldSummon->GetMapId(), OldSummon)->Remove((Creature*)OldSummon,false); - OldSummon->SetMapId(m_caster->GetMapId()); - - float px, py, pz; - m_caster->GetClosePoint(px, py, pz, OldSummon->GetObjectSize()); - - OldSummon->Relocate(px, py, pz, OldSummon->GetOrientation()); - MapManager::Instance().GetMap(m_caster->GetMapId(), m_caster)->Add((Creature*)OldSummon); - - if(m_caster->GetTypeId() == TYPEID_PLAYER && OldSummon->isControlled() ) - { - ((Player*)m_caster)->PetSpellInitialize(); - } - return; - } - - if(m_caster->GetTypeId() == TYPEID_PLAYER) - ((Player*)m_caster)->RemovePet(OldSummon,(OldSummon->getPetType()==HUNTER_PET ? PET_SAVE_AS_DELETED : PET_SAVE_NOT_IN_SLOT),false); - else - return; - } - - Pet* NewSummon = new Pet; - - // petentry==0 for hunter "call pet" (current pet summoned if any) - if(NewSummon->LoadPetFromDB(m_caster,petentry)) - { - if(NewSummon->getPetType()==SUMMON_PET) - { - // Remove Demonic Sacrifice auras (known pet) - Unit::AuraList const& auraClassScripts = m_caster->GetAurasByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS); - for(Unit::AuraList::const_iterator itr = auraClassScripts.begin();itr!=auraClassScripts.end();) - { - if((*itr)->GetModifier()->m_miscvalue==2228) - { - m_caster->RemoveAurasDueToSpell((*itr)->GetId()); - itr = auraClassScripts.begin(); - } - else - ++itr; - } - } - - return; - } - - // not error in case fail hunter call pet - if(!petentry) - { - delete NewSummon; - return; - } - - CreatureInfo const* cInfo = sCreatureStorage.LookupEntry(petentry); - - if(!cInfo) - { - sLog.outError("EffectSummonPet: creature entry %u not found.",petentry); - delete NewSummon; - return; - } - - Map *map = m_caster->GetMap(); - uint32 pet_number = objmgr.GeneratePetNumber(); - if(!NewSummon->Create(objmgr.GenerateLowGuid(HIGHGUID_PET), map, petentry, pet_number)) - { - delete NewSummon; - return; - } - - float px, py, pz; - m_caster->GetClosePoint(px, py, pz, NewSummon->GetObjectSize()); - - NewSummon->Relocate(px, py, pz, m_caster->GetOrientation()); - - if(!NewSummon->IsPositionValid()) - { - sLog.outError("ERROR: Pet (guidlow %d, entry %d) not summoned. Suggested coordinates isn't valid (X: %d Y: ^%d)", NewSummon->GetGUIDLow(), NewSummon->GetEntry(), NewSummon->GetPositionX(), NewSummon->GetPositionY()); - delete NewSummon; - return; - } - - uint32 petlevel = m_caster->getLevel(); - NewSummon->setPetType(SUMMON_PET); - - uint32 faction = m_caster->getFaction(); - if(m_caster->GetTypeId() == TYPEID_UNIT && ((Creature*)m_caster)->isTotem()) - { - Unit* owner = ((Totem*)m_caster)->GetOwner(); - if(owner) - faction = owner->getFaction(); - NewSummon->GetCharmInfo()->SetReactState(REACT_AGGRESSIVE); - } - - NewSummon->SetUInt64Value(UNIT_FIELD_SUMMONEDBY, m_caster->GetGUID()); - NewSummon->SetUInt64Value(UNIT_FIELD_CREATEDBY, m_caster->GetGUID()); - NewSummon->SetUInt32Value(UNIT_NPC_FLAGS , 0); - NewSummon->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE, faction); - NewSummon->SetUInt32Value(UNIT_FIELD_BYTES_0,2048); - NewSummon->SetUInt32Value(UNIT_FIELD_BYTES_1,0); - NewSummon->SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP,time(NULL)); - NewSummon->SetUInt32Value(UNIT_FIELD_PETEXPERIENCE,0); - NewSummon->SetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP,1000); - NewSummon->SetUInt32Value(UNIT_CREATED_BY_SPELL, m_spellInfo->Id); - - NewSummon->GetCharmInfo()->SetPetNumber(pet_number, true); - // this enables pet details window (Shift+P) - - // this enables popup window (pet dismiss, cancel), hunter pet additional flags set later - NewSummon->SetUInt32Value(UNIT_FIELD_FLAGS,UNIT_FLAG_PVP_ATTACKABLE); - - NewSummon->InitStatsForLevel( petlevel); - NewSummon->InitPetCreateSpells(); - - if(NewSummon->getPetType()==SUMMON_PET) - { - // Remove Demonic Sacrifice auras (new pet) - Unit::AuraList const& auraClassScripts = m_caster->GetAurasByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS); - for(Unit::AuraList::const_iterator itr = auraClassScripts.begin();itr!=auraClassScripts.end();) - { - if((*itr)->GetModifier()->m_miscvalue==2228) - { - m_caster->RemoveAurasDueToSpell((*itr)->GetId()); - itr = auraClassScripts.begin(); - } - else - ++itr; - } - - // generate new name for summon pet - std::string new_name=objmgr.GeneratePetName(petentry); - if(!new_name.empty()) - NewSummon->SetName(new_name); - } - else if(NewSummon->getPetType()==HUNTER_PET) - NewSummon->SetByteValue(UNIT_FIELD_BYTES_2, 2, UNIT_RENAME_NOT_ALLOWED); - - NewSummon->AIM_Initialize(); - NewSummon->SetHealth(NewSummon->GetMaxHealth()); - NewSummon->SetPower(POWER_MANA, NewSummon->GetMaxPower(POWER_MANA)); - - map->Add((Creature*)NewSummon); - - m_caster->SetPet(NewSummon); - sLog.outDebug("New Pet has guid %u", NewSummon->GetGUIDLow()); - - if(m_caster->GetTypeId() == TYPEID_PLAYER) - { - NewSummon->SavePetToDB(PET_SAVE_AS_CURRENT); - ((Player*)m_caster)->PetSpellInitialize(); - } -} - -void Spell::EffectLearnPetSpell(uint32 i) -{ - if(m_caster->GetTypeId() != TYPEID_PLAYER) - return; - - Player *_player = (Player*)m_caster; - - Pet *pet = _player->GetPet(); - if(!pet) - return; - if(!pet->isAlive()) - return; - - SpellEntry const *learn_spellproto = sSpellStore.LookupEntry(m_spellInfo->EffectTriggerSpell[i]); - if(!learn_spellproto) - return; - - pet->SetTP(pet->m_TrainingPoints - pet->GetTPForSpell(learn_spellproto->Id)); - pet->learnSpell(learn_spellproto->Id); - - pet->SavePetToDB(PET_SAVE_AS_CURRENT); - _player->PetSpellInitialize(); -} - -void Spell::EffectTaunt(uint32 /*i*/) -{ - // this effect use before aura Taunt apply for prevent taunt already attacking target - // for spell as marked "non effective at already attacking target" - if(unitTarget && unitTarget->GetTypeId() != TYPEID_PLAYER) - { - if(unitTarget->getVictim()==m_caster) - { - SendCastResult(SPELL_FAILED_DONT_REPORT); - return; - } - } - - // Also use this effect to set the taunter's threat to the taunted creature's highest value - if(unitTarget->CanHaveThreatList() && unitTarget->getThreatManager().getCurrentVictim()) - unitTarget->getThreatManager().addThreat(m_caster,unitTarget->getThreatManager().getCurrentVictim()->getThreat()); -} - -void Spell::EffectWeaponDmg(uint32 i) -{ - if(!unitTarget) - return; - if(!unitTarget->isAlive()) - return; - - // multiple weapon dmg effect workaround - // execute only the last weapon damage - // and handle all effects at once - for (int j = 0; j < 3; j++) - { - switch(m_spellInfo->Effect[j]) - { - case SPELL_EFFECT_WEAPON_DAMAGE: - case SPELL_EFFECT_WEAPON_DAMAGE_NOSCHOOL: - case SPELL_EFFECT_NORMALIZED_WEAPON_DMG: - case SPELL_EFFECT_WEAPON_PERCENT_DAMAGE: - if (j < i) // we must calculate only at last weapon effect - return; - break; - } - } - - // some spell specific modifiers - bool customBonusDamagePercentMod = false; - float bonusDamagePercentMod = 1.0f; // applied to fixed effect damage bonus if set customBonusDamagePercentMod - float weaponDamagePercentMod = 1.0f; // applied to weapon damage (and to fixed effect damage bonus if customBonusDamagePercentMod not set - float totalDamagePercentMod = 1.0f; // applied to final bonus+weapon damage - bool normalized = false; - - int32 spell_bonus = 0; // bonus specific for spell - switch(m_spellInfo->SpellFamilyName) - { - case SPELLFAMILY_WARRIOR: - { - // Whirlwind, single only spell with 2 weapon white damage apply if have - if(m_caster->GetTypeId()==TYPEID_PLAYER && (m_spellInfo->SpellFamilyFlags & 0x00000400000000LL)) - { - if(((Player*)m_caster)->GetWeaponForAttack(OFF_ATTACK,true)) - spell_bonus += m_caster->CalculateDamage (OFF_ATTACK, normalized); - } - // Devastate bonus and sunder armor refresh - else if(m_spellInfo->SpellVisual == 671 && m_spellInfo->SpellIconID == 1508) - { - customBonusDamagePercentMod = true; - bonusDamagePercentMod = 0.0f; // only applied if auras found - - Unit::AuraList const& list = unitTarget->GetAurasByType(SPELL_AURA_MOD_RESISTANCE); - for(Unit::AuraList::const_iterator itr=list.begin();itr!=list.end();++itr) - { - SpellEntry const *proto = (*itr)->GetSpellProto(); - if(proto->SpellVisual == 406 && proto->SpellIconID == 565) - { - int32 duration = GetSpellDuration(proto); - (*itr)->SetAuraDuration(duration); - (*itr)->UpdateAuraDuration(); - bonusDamagePercentMod += 1.0f; // +100% - } - } - } - break; - } - case SPELLFAMILY_ROGUE: - { - // Ambush - if(m_spellInfo->SpellFamilyFlags & 0x00000200LL) - { - customBonusDamagePercentMod = true; - bonusDamagePercentMod = 2.5f; // 250% - } - // Mutilate (for each hand) - else if(m_spellInfo->SpellFamilyFlags & 0x600000000LL) - { - bool found = false; - // fast check - if(unitTarget->HasAuraState(AURA_STATE_DEADLY_POISON)) - found = true; - // full aura scan - else - { - Unit::AuraMap const& auras = unitTarget->GetAuras(); - for(Unit::AuraMap::const_iterator itr = auras.begin(); itr!=auras.end(); ++itr) - { - if(itr->second->GetSpellProto()->Dispel == DISPEL_POISON) - { - found = true; - break; - } - } - } - - if(found) - totalDamagePercentMod *= 1.5f; // 150% if poisoned - } - break; - } - case SPELLFAMILY_PALADIN: - { - // Seal of Command - receive benefit from Spell Damage and Healing - if(m_spellInfo->SpellFamilyFlags & 0x00000002000000LL) - { - spell_bonus += int32(0.20f*m_caster->SpellBaseDamageBonus(GetSpellSchoolMask(m_spellInfo))); - spell_bonus += int32(0.29f*m_caster->SpellBaseDamageBonusForVictim(GetSpellSchoolMask(m_spellInfo), unitTarget)); - } - break; - } - case SPELLFAMILY_SHAMAN: - { - // Skyshatter Harness item set bonus - // Stormstrike - if(m_spellInfo->SpellFamilyFlags & 0x001000000000LL) - { - Unit::AuraList const& m_OverrideClassScript = m_caster->GetAurasByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS); - for(Unit::AuraList::const_iterator i = m_OverrideClassScript.begin(); i != m_OverrideClassScript.end(); ++i) - { - // Stormstrike AP Buff - if ( (*i)->GetModifier()->m_miscvalue == 5634 ) - { - m_caster->CastSpell(m_caster,38430,true,NULL,*i); - break; - } - } - } - } - } - - int32 fixed_bonus = 0; - for (int j = 0; j < 3; j++) - { - switch(m_spellInfo->Effect[j]) - { - case SPELL_EFFECT_WEAPON_DAMAGE: - case SPELL_EFFECT_WEAPON_DAMAGE_NOSCHOOL: - fixed_bonus += CalculateDamage(j,unitTarget); - break; - case SPELL_EFFECT_NORMALIZED_WEAPON_DMG: - fixed_bonus += CalculateDamage(j,unitTarget); - normalized = true; - break; - case SPELL_EFFECT_WEAPON_PERCENT_DAMAGE: - weaponDamagePercentMod *= float(CalculateDamage(j,unitTarget)) / 100.0f; - - // applied only to prev.effects fixed damage - if(customBonusDamagePercentMod) - fixed_bonus = int32(fixed_bonus*bonusDamagePercentMod); - else - fixed_bonus = int32(fixed_bonus*weaponDamagePercentMod); - break; - default: - break; // not weapon damage effect, just skip - } - } - - // non-weapon damage - int32 bonus = spell_bonus + fixed_bonus; - - // apply to non-weapon bonus weapon total pct effect, weapon total flat effect included in weapon damage - if(bonus) - { - UnitMods unitMod; - switch(m_attackType) - { - default: - case BASE_ATTACK: unitMod = UNIT_MOD_DAMAGE_MAINHAND; break; - case OFF_ATTACK: unitMod = UNIT_MOD_DAMAGE_OFFHAND; break; - case RANGED_ATTACK: unitMod = UNIT_MOD_DAMAGE_RANGED; break; - } - - float weapon_total_pct = m_caster->GetModifierValue(unitMod, TOTAL_PCT); - bonus = int32(bonus*weapon_total_pct); - } - - // + weapon damage with applied weapon% dmg to base weapon damage in call - bonus += int32(m_caster->CalculateDamage(m_attackType, normalized)*weaponDamagePercentMod); - - // total damage - bonus = int32(bonus*totalDamagePercentMod); - - // prevent negative damage - uint32 eff_damage = uint32(bonus > 0 ? bonus : 0); - - const uint32 nohitMask = HITINFO_ABSORB | HITINFO_RESIST | HITINFO_MISS; - - uint32 hitInfo = 0; - VictimState victimState = VICTIMSTATE_NORMAL; - uint32 blocked_dmg = 0; - uint32 absorbed_dmg = 0; - uint32 resisted_dmg = 0; - CleanDamage cleanDamage = CleanDamage(0, BASE_ATTACK, MELEE_HIT_NORMAL ); - - m_caster->DoAttackDamage(unitTarget, &eff_damage, &cleanDamage, &blocked_dmg, m_spellSchoolMask, &hitInfo, &victimState, &absorbed_dmg, &resisted_dmg, m_attackType, m_spellInfo, m_IsTriggeredSpell); - - if ((hitInfo & nohitMask) && m_attackType != RANGED_ATTACK) // not send ranged miss/etc - m_caster->SendAttackStateUpdate(hitInfo & nohitMask, unitTarget, 1, m_spellSchoolMask, eff_damage, absorbed_dmg, resisted_dmg, VICTIMSTATE_NORMAL, blocked_dmg); - - bool criticalhit = (hitInfo & HITINFO_CRITICALHIT); - m_caster->SendSpellNonMeleeDamageLog(unitTarget, m_spellInfo->Id, eff_damage, m_spellSchoolMask, absorbed_dmg, resisted_dmg, false, blocked_dmg, criticalhit); - - if (eff_damage > (absorbed_dmg + resisted_dmg + blocked_dmg)) - { - eff_damage -= (absorbed_dmg + resisted_dmg + blocked_dmg); - } - else - { - cleanDamage.damage += eff_damage; - eff_damage = 0; - } - - // SPELL_SCHOOL_NORMAL use for weapon-like threat and rage calculation - m_caster->DealDamage(unitTarget, eff_damage, &cleanDamage, SPELL_DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, true); - - // Hemorrhage - if(m_spellInfo->SpellFamilyName==SPELLFAMILY_ROGUE && (m_spellInfo->SpellFamilyFlags & 0x2000000)) - { - if(m_caster->GetTypeId()==TYPEID_PLAYER) - ((Player*)m_caster)->AddComboPoints(unitTarget, 1); - } - // Mangle (Cat): CP - if(m_spellInfo->SpellFamilyName==SPELLFAMILY_DRUID && (m_spellInfo->SpellFamilyFlags==0x0000040000000000LL)) - { - if(m_caster->GetTypeId()==TYPEID_PLAYER) - ((Player*)m_caster)->AddComboPoints(unitTarget,1); - } - - - // take ammo - if(m_attackType == RANGED_ATTACK && m_caster->GetTypeId() == TYPEID_PLAYER) - { - Item *pItem = ((Player*)m_caster)->GetWeaponForAttack( RANGED_ATTACK ); - - // wands don't have ammo - if(!pItem || pItem->IsBroken() || pItem->GetProto()->SubClass==ITEM_SUBCLASS_WEAPON_WAND) - return; - - if( pItem->GetProto()->InventoryType == INVTYPE_THROWN ) - { - if(pItem->GetMaxStackCount()==1) - { - // decrease durability for non-stackable throw weapon - ((Player*)m_caster)->DurabilityPointLossForEquipSlot(EQUIPMENT_SLOT_RANGED); - } - else - { - // decrease items amount for stackable throw weapon - uint32 count = 1; - ((Player*)m_caster)->DestroyItemCount( pItem, count, true); - } - } - else if(uint32 ammo = ((Player*)m_caster)->GetUInt32Value(PLAYER_AMMO_ID)) - ((Player*)m_caster)->DestroyItemCount(ammo, 1, true); - } -} - -void Spell::EffectThreat(uint32 /*i*/) -{ - if(!unitTarget || !unitTarget->isAlive() || !m_caster->isAlive()) - return; - - if(!unitTarget->CanHaveThreatList()) - return; - - unitTarget->AddThreat(m_caster, float(damage)); -} - -void Spell::EffectHealMaxHealth(uint32 /*i*/) -{ - if(!unitTarget) - return; - if(!unitTarget->isAlive()) - return; - - uint32 heal = m_caster->GetMaxHealth(); - - int32 gain = unitTarget->ModifyHealth(heal); - unitTarget->getHostilRefManager().threatAssist(m_caster, float(gain) * 0.5f, m_spellInfo); - - m_caster->SendHealSpellLog(unitTarget, m_spellInfo->Id, heal); -} - -void Spell::EffectInterruptCast(uint32 /*i*/) -{ - if(!unitTarget) - return; - if(!unitTarget->isAlive()) - return; - - // TODO: not all spells that used this effect apply cooldown at school spells - // also exist case: apply cooldown to interrupted cast only and to all spells - for (uint32 i = CURRENT_FIRST_NON_MELEE_SPELL; i < CURRENT_MAX_SPELL; i++) - { - if (unitTarget->m_currentSpells[i]) - { - // check if we can interrupt spell - if ( unitTarget->m_currentSpells[i]->m_spellInfo->InterruptFlags & SPELL_INTERRUPT_FLAG_INTERRUPT && unitTarget->m_currentSpells[i]->m_spellInfo->PreventionType == SPELL_PREVENTION_TYPE_SILENCE ) - { - unitTarget->ProhibitSpellScholl(GetSpellSchoolMask(unitTarget->m_currentSpells[i]->m_spellInfo), GetSpellDuration(m_spellInfo)); - unitTarget->InterruptSpell(i,false); - } - } - } -} - -void Spell::EffectSummonObjectWild(uint32 i) -{ - uint32 gameobject_id = m_spellInfo->EffectMiscValue[i]; - - GameObject* pGameObj = new GameObject; - - WorldObject* target = focusObject; - if( !target ) - target = m_caster; - - float x,y,z; - if(m_targets.m_targetMask & TARGET_FLAG_DEST_LOCATION) - { - x = m_targets.m_destX; - y = m_targets.m_destY; - z = m_targets.m_destZ; - } - else - m_caster->GetClosePoint(x,y,z,DEFAULT_WORLD_OBJECT_SIZE); - - Map *map = target->GetMap(); - - if(!pGameObj->Create(objmgr.GenerateLowGuid(HIGHGUID_GAMEOBJECT), gameobject_id, map, - x, y, z, target->GetOrientation(), 0, 0, 0, 0, 100, 1)) - { - delete pGameObj; - return; - } - - int32 duration = GetSpellDuration(m_spellInfo); - pGameObj->SetRespawnTime(duration > 0 ? duration/1000 : 0); - pGameObj->SetSpellId(m_spellInfo->Id); - - if(pGameObj->GetGoType() != GAMEOBJECT_TYPE_FLAGDROP) // make dropped flag clickable for other players (not set owner guid (created by) for this)... - m_caster->AddGameObject(pGameObj); - map->Add(pGameObj); - - if(pGameObj->GetMapId() == 489 && pGameObj->GetGoType() == GAMEOBJECT_TYPE_FLAGDROP) //WS - { - if(m_caster->GetTypeId() == TYPEID_PLAYER) - { - Player *pl = (Player*)m_caster; - BattleGround* bg = ((Player *)m_caster)->GetBattleGround(); - if(bg && bg->GetTypeID()==BATTLEGROUND_WS && bg->GetStatus() == STATUS_IN_PROGRESS) - { - uint32 team = ALLIANCE; - - if(pl->GetTeam() == team) - team = HORDE; - - ((BattleGroundWS*)bg)->SetDroppedFlagGUID(pGameObj->GetGUID(),team); - } - } - } - - if(pGameObj->GetMapId() == 566 && pGameObj->GetGoType() == GAMEOBJECT_TYPE_FLAGDROP) //EY - { - if(m_caster->GetTypeId() == TYPEID_PLAYER) - { - BattleGround* bg = ((Player *)m_caster)->GetBattleGround(); - if(bg && bg->GetTypeID()==BATTLEGROUND_EY && bg->GetStatus() == STATUS_IN_PROGRESS) - { - ((BattleGroundEY*)bg)->SetDroppedFlagGUID(pGameObj->GetGUID()); - } - } - } - - if(uint32 linkedEntry = pGameObj->GetLinkedGameObjectEntry()) - { - GameObject* linkedGO = new GameObject; - if(linkedGO->Create(objmgr.GenerateLowGuid(HIGHGUID_GAMEOBJECT), linkedEntry, map, - x, y, z, target->GetOrientation(), 0, 0, 0, 0, 100, 1)) - { - linkedGO->SetRespawnTime(duration > 0 ? duration/1000 : 0); - linkedGO->SetSpellId(m_spellInfo->Id); - - m_caster->AddGameObject(linkedGO); - map->Add(linkedGO); - } - else - { - delete linkedGO; - linkedGO = NULL; - return; - } - } -} - -void Spell::EffectScriptEffect(uint32 effIndex) -{ - // TODO: we must implement hunter pet summon at login there (spell 6962) - - // by spell id - switch(m_spellInfo->Id) - { - // Bending Shinbone - case 8856: - { - if(!itemTarget && m_caster->GetTypeId()!=TYPEID_PLAYER) - return; - - uint32 spell_id = 0; - switch(urand(1,5)) - { - case 1: spell_id = 8854; break; - default: spell_id = 8855; break; - } - - m_caster->CastSpell(m_caster,spell_id,true,NULL); - return; - } - - // Healthstone creating spells - case 6201: - case 6202: - case 5699: - case 11729: - case 11730: - case 27230: - { - uint32 itemtype; - uint32 rank = 0; - Unit::AuraList const& mDummyAuras = unitTarget->GetAurasByType(SPELL_AURA_DUMMY); - for(Unit::AuraList::const_iterator i = mDummyAuras.begin();i != mDummyAuras.end(); ++i) - { - if((*i)->GetId() == 18692) - { - rank = 1; - break; - } - else if((*i)->GetId() == 18693) - { - rank = 2; - break; - } - } - - static uint32 const itypes[6][3] = { - { 5512,19004,19005}, // Minor Healthstone - { 5511,19006,19007}, // Lesser Healthstone - { 5509,19008,19009}, // Healthstone - { 5510,19010,19011}, // Greater Healthstone - { 9421,19012,19013}, // Major Healthstone - {22103,22104,22105} // Master Healthstone - }; - - switch(m_spellInfo->Id) - { - case 6201: itemtype=itypes[0][rank];break; // Minor Healthstone - case 6202: itemtype=itypes[1][rank];break; // Lesser Healthstone - case 5699: itemtype=itypes[2][rank];break; // Healthstone - case 11729: itemtype=itypes[3][rank];break; // Greater Healthstone - case 11730: itemtype=itypes[4][rank];break; // Major Healthstone - case 27230: itemtype=itypes[5][rank];break; // Master Healthstone - default: - return; - } - DoCreateItem( effIndex, itemtype ); - return; - } - // Brittle Armor - need remove one 24575 Brittle Armor aura - case 24590: - unitTarget->RemoveSingleAuraFromStack(24575, 0); - unitTarget->RemoveSingleAuraFromStack(24575, 1); - return; - // Mercurial Shield - need remove one 26464 Mercurial Shield aura - case 26465: - unitTarget->RemoveSingleAuraFromStack(26464, 0); - return; - // Orb teleport spells - case 25140: - case 25143: - case 25650: - case 25652: - case 29128: - case 29129: - case 35376: - case 35727: - { - if(!unitTarget) - return; - - uint32 spellid; - switch(m_spellInfo->Id) - { - case 25140: spellid = 32571; break; - case 25143: spellid = 32572; break; - case 25650: spellid = 30140; break; - case 25652: spellid = 30141; break; - case 29128: spellid = 32568; break; - case 29129: spellid = 32569; break; - case 35376: spellid = 25649; break; - case 35727: spellid = 35730; break; - default: - return; - } - - unitTarget->CastSpell(unitTarget,spellid,false); - return; - } - - // Shadow Flame (All script effects, not just end ones to prevent player from dodging the last triggered spell) - case 22539: - case 22972: - case 22975: - case 22976: - case 22977: - case 22978: - case 22979: - case 22980: - case 22981: - case 22982: - case 22983: - case 22984: - case 22985: - { - if(!unitTarget || !unitTarget->isAlive()) - return; - - // Onyxia Scale Cloak - if(unitTarget->GetDummyAura(22683)) - return; - - // Shadow Flame - m_caster->CastSpell(unitTarget, 22682, true); - return; - } - break; - - // Summon Black Qiraji Battle Tank - case 26656: - { - if(!unitTarget) - return; - - // Prevent stacking of mounts - unitTarget->RemoveSpellsCausingAura(SPELL_AURA_MOUNTED); - - // Two separate mounts depending on area id (allows use both in and out of specific instance) - if (unitTarget->GetAreaId() == 3428) - unitTarget->CastSpell(unitTarget, 25863, false); - else - unitTarget->CastSpell(unitTarget, 26655, false); - break; - } - // Piccolo of the Flaming Fire - case 17512: - { - if(!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) - return; - unitTarget->HandleEmoteCommand(EMOTE_STATE_DANCE); - break; - } - - // Dreaming Glory - case 28698: - { - if(!unitTarget) - return; - unitTarget->CastSpell(unitTarget, 28694, true); - break; - } - - // Netherbloom - case 28702: - { - if(!unitTarget) - return; - // 25% chance of casting a random buff - if(roll_chance_i(75)) - return; - - // triggered spells are 28703 to 28707 - // Note: some sources say, that there was the possibility of - // receiving a debuff. However, this seems to be removed by a patch. - const uint32 spellid = 28703; - - // don't overwrite an existing aura - for(uint8 i=0; i<5; i++) - if(unitTarget->HasAura(spellid+i, 0)) - return; - unitTarget->CastSpell(unitTarget, spellid+urand(0, 4), true); - break; - } - - // Nightmare Vine - case 28720: - { - if(!unitTarget) - return; - // 25% chance of casting Nightmare Pollen - if(roll_chance_i(75)) - return; - unitTarget->CastSpell(unitTarget, 28721, true); - break; - } - - // Mirren's Drinking Hat - case 29830: - { - uint32 item = 0; - switch ( urand(1,6) ) - { - case 1: case 2: case 3: item = 23584; break;// Loch Modan Lager - case 4: case 5: item = 23585; break;// Stouthammer Lite - case 6: item = 23586; break;// Aerie Peak Pale Ale - } - if (item) - DoCreateItem(effIndex,item); - break; - } - // Improved Sprint - case 30918: - { - // Removes snares and roots. - uint32 mechanic_mask = (1<GetAuras(); - for(Unit::AuraMap::iterator iter = Auras.begin(), next; iter != Auras.end(); iter = next) - { - next = iter; - ++next; - Aura *aur = iter->second; - if (!aur->IsPositive()) //only remove negative spells - { - // check for mechanic mask - if(GetSpellMechanicMask(aur->GetSpellProto(), aur->GetEffIndex()) & mechanic_mask) - { - unitTarget->RemoveAurasDueToSpell(aur->GetId()); - if(Auras.empty()) - break; - else - next = Auras.begin(); - } - } - } - break; - } - case 41126: // Flame Crash - { - if(!unitTarget) - return; - - unitTarget->CastSpell(unitTarget, 41131, true); - break; - } - case 44876: // Force Cast - Portal Effect: Sunwell Isle - { - if(!unitTarget) - return; - - unitTarget->CastSpell(unitTarget, 44870, true); - break; - } - - // Goblin Weather Machine - case 46203: - { - if(!unitTarget) - return; - - uint32 spellId; - switch(rand()%4) - { - case 0: - spellId=46740; - break; - case 1: - spellId=46739; - break; - case 2: - spellId=46738; - break; - case 3: - spellId=46736; - break; - } - unitTarget->CastSpell(unitTarget, spellId, true); - break; - } - } - - if( m_spellInfo->SpellFamilyName == SPELLFAMILY_PALADIN ) - { - switch(m_spellInfo->SpellFamilyFlags) - { - // Judgement - case 0x800000: - { - if(!unitTarget || !unitTarget->isAlive()) - return; - uint32 spellId2 = 0; - - // all seals have aura dummy - Unit::AuraList const& m_dummyAuras = m_caster->GetAurasByType(SPELL_AURA_DUMMY); - for(Unit::AuraList::const_iterator itr = m_dummyAuras.begin(); itr != m_dummyAuras.end(); ++itr) - { - SpellEntry const *spellInfo = (*itr)->GetSpellProto(); - - // search seal (all seals have judgement's aura dummy spell id in 2 effect - if ( !spellInfo || !IsSealSpell((*itr)->GetSpellProto()) || (*itr)->GetEffIndex() != 2 ) - continue; - - // must be calculated base at raw base points in spell proto, GetModifier()->m_value for S.Righteousness modified by SPELLMOD_DAMAGE - spellId2 = (*itr)->GetSpellProto()->EffectBasePoints[2]+1; - - if(spellId2 <= 1) - continue; - - // found, remove seal - m_caster->RemoveAurasDueToSpell((*itr)->GetId()); - - // Sanctified Judgement - Unit::AuraList const& m_auras = m_caster->GetAurasByType(SPELL_AURA_DUMMY); - for(Unit::AuraList::const_iterator i = m_auras.begin(); i != m_auras.end(); ++i) - { - if ((*i)->GetSpellProto()->SpellIconID == 205 && (*i)->GetSpellProto()->Attributes == 0x01D0LL) - { - int32 chance = (*i)->GetModifier()->m_amount; - if ( roll_chance_i(chance) ) - { - int32 mana = spellInfo->manaCost; - if ( Player* modOwner = m_caster->GetSpellModOwner() ) - modOwner->ApplySpellMod(spellInfo->Id, SPELLMOD_COST, mana); - mana = int32(mana* 0.8f); - m_caster->CastCustomSpell(m_caster,31930,&mana,NULL,NULL,true,NULL,*i); - } - break; - } - } - - break; - } - - m_caster->CastSpell(unitTarget,spellId2,true); - return; - } - } - } - - // normal DB scripted effect - if(!unitTarget) - return; - - sLog.outDebug("Spell ScriptStart spellid %u in EffectScriptEffect ", m_spellInfo->Id); - sWorld.ScriptsStart(sSpellScripts, m_spellInfo->Id, m_caster, unitTarget); -} - -void Spell::EffectSanctuary(uint32 /*i*/) -{ - if(!unitTarget) - return; - //unitTarget->CombatStop(); - - unitTarget->CombatStop(); - unitTarget->getHostilRefManager().deleteReferences(); // stop all fighting - // Vanish allows to remove all threat and cast regular stealth so other spells can be used - if(m_spellInfo->SpellFamilyName == SPELLFAMILY_ROGUE && (m_spellInfo->SpellFamilyFlags & SPELLFAMILYFLAG_ROGUE_VANISH)) - { - ((Player *)m_caster)->RemoveSpellsCausingAura(SPELL_AURA_MOD_ROOT); - } -} - -void Spell::EffectAddComboPoints(uint32 /*i*/) -{ - if(!unitTarget) - return; - - if(m_caster->GetTypeId() != TYPEID_PLAYER) - return; - - if(damage <= 0) - return; - - ((Player*)m_caster)->AddComboPoints(unitTarget, damage); -} - -void Spell::EffectDuel(uint32 i) -{ - if(!m_caster || !unitTarget || m_caster->GetTypeId() != TYPEID_PLAYER || unitTarget->GetTypeId() != TYPEID_PLAYER) - return; - - Player *caster = (Player*)m_caster; - Player *target = (Player*)unitTarget; - - // caster or target already have requested duel - if( caster->duel || target->duel || target->GetSocial()->HasIgnore(caster->GetGUIDLow()) ) - return; - - // Players can only fight a duel with each other outside (=not inside dungeons and not in capital cities) - // Don't have to check the target's map since you cannot challenge someone across maps - if( caster->GetMapId() != 0 && caster->GetMapId() != 1 && caster->GetMapId() != 530) - { - SendCastResult(SPELL_FAILED_NO_DUELING); // Dueling isn't allowed here - return; - } - - AreaTableEntry const* casterAreaEntry = GetAreaEntryByAreaID(caster->GetZoneId()); - if(casterAreaEntry && (casterAreaEntry->flags & AREA_FLAG_CAPITAL) ) - { - SendCastResult(SPELL_FAILED_NO_DUELING); // Dueling isn't allowed here - return; - } - - AreaTableEntry const* targetAreaEntry = GetAreaEntryByAreaID(target->GetZoneId()); - if(targetAreaEntry && (targetAreaEntry->flags & AREA_FLAG_CAPITAL) ) - { - SendCastResult(SPELL_FAILED_NO_DUELING); // Dueling isn't allowed here - return; - } - - //CREATE DUEL FLAG OBJECT - GameObject* pGameObj = new GameObject; - - uint32 gameobject_id = m_spellInfo->EffectMiscValue[i]; - - Map *map = m_caster->GetMap(); - if(!pGameObj->Create(objmgr.GenerateLowGuid(HIGHGUID_GAMEOBJECT), gameobject_id, map, - m_caster->GetPositionX()+(unitTarget->GetPositionX()-m_caster->GetPositionX())/2 , - m_caster->GetPositionY()+(unitTarget->GetPositionY()-m_caster->GetPositionY())/2 , - m_caster->GetPositionZ(), - m_caster->GetOrientation(), 0, 0, 0, 0, 0, 1)) - { - delete pGameObj; - return; - } - - pGameObj->SetUInt32Value(GAMEOBJECT_FACTION, m_caster->getFaction() ); - pGameObj->SetUInt32Value(GAMEOBJECT_LEVEL, m_caster->getLevel()+1 ); - int32 duration = GetSpellDuration(m_spellInfo); - pGameObj->SetRespawnTime(duration > 0 ? duration/1000 : 0); - pGameObj->SetSpellId(m_spellInfo->Id); - - m_caster->AddGameObject(pGameObj); - map->Add(pGameObj); - //END - - // Send request - WorldPacket data(SMSG_DUEL_REQUESTED, 16); - data << pGameObj->GetGUID(); - data << caster->GetGUID(); - caster->GetSession()->SendPacket(&data); - target->GetSession()->SendPacket(&data); - - // create duel-info - DuelInfo *duel = new DuelInfo; - duel->initiator = caster; - duel->opponent = target; - duel->startTime = 0; - duel->startTimer = 0; - caster->duel = duel; - - DuelInfo *duel2 = new DuelInfo; - duel2->initiator = caster; - duel2->opponent = caster; - duel2->startTime = 0; - duel2->startTimer = 0; - target->duel = duel2; - - caster->SetUInt64Value(PLAYER_DUEL_ARBITER,pGameObj->GetGUID()); - target->SetUInt64Value(PLAYER_DUEL_ARBITER,pGameObj->GetGUID()); -} - -void Spell::EffectStuck(uint32 /*i*/) -{ - if(!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) - return; - - if(!sWorld.getConfig(CONFIG_CAST_UNSTUCK)) - return; - - Player* pTarget = (Player*)unitTarget; - - sLog.outDebug("Spell Effect: Stuck"); - sLog.outDetail("Player %s (guid %u) used auto-unstuck future at map %u (%f, %f, %f)", pTarget->GetName(), pTarget->GetGUIDLow(), m_caster->GetMapId(), m_caster->GetPositionX(), pTarget->GetPositionY(), pTarget->GetPositionZ()); - - if(pTarget->isInFlight()) - return; - - // homebind location is loaded always - pTarget->TeleportTo(pTarget->m_homebindMapId,pTarget->m_homebindX,pTarget->m_homebindY,pTarget->m_homebindZ,pTarget->GetOrientation(), (unitTarget==m_caster ? TELE_TO_SPELL : 0)); - - // Stuck spell trigger Hearthstone cooldown - SpellEntry const *spellInfo = sSpellStore.LookupEntry(8690); - if(!spellInfo) - return; - Spell spell(pTarget,spellInfo,true,0); - spell.SendSpellCooldown(); -} - -void Spell::EffectSummonPlayer(uint32 /*i*/) -{ - if(!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) - return; - - // Evil Twin (ignore player summon, but hide this for summoner) - if(unitTarget->GetDummyAura(23445)) - return; - - float x,y,z; - m_caster->GetClosePoint(x,y,z,unitTarget->GetObjectSize()); - - ((Player*)unitTarget)->SetSummonPoint(m_caster->GetMapId(),x,y,z); - - WorldPacket data(SMSG_SUMMON_REQUEST, 8+4+4); - data << uint64(m_caster->GetGUID()); // summoner guid - data << uint32(m_caster->GetZoneId()); // summoner zone - data << uint32(MAX_PLAYER_SUMMON_DELAY*1000); // auto decline after msecs - ((Player*)unitTarget)->GetSession()->SendPacket(&data); -} - -static ScriptInfo generateActivateCommand() -{ - ScriptInfo si; - si.command = SCRIPT_COMMAND_ACTIVATE_OBJECT; - return si; -} - -void Spell::EffectActivateObject(uint32 effect_idx) -{ - if(!gameObjTarget) - return; - - static ScriptInfo activateCommand = generateActivateCommand(); - - int32 delay_secs = m_spellInfo->EffectMiscValue[effect_idx]; - - sWorld.ScriptCommandStart(activateCommand, delay_secs, m_caster, gameObjTarget); -} - -void Spell::EffectSummonTotem(uint32 i) -{ - uint8 slot = 0; - switch(m_spellInfo->EffectMiscValueB[i]) - { - case SUMMON_TYPE_TOTEM_SLOT1: slot = 0; break; - case SUMMON_TYPE_TOTEM_SLOT2: slot = 1; break; - case SUMMON_TYPE_TOTEM_SLOT3: slot = 2; break; - case SUMMON_TYPE_TOTEM_SLOT4: slot = 3; break; - // Battle standard case - case SUMMON_TYPE_TOTEM: slot = 254; break; - // jewelery statue case, like totem without slot - case SUMMON_TYPE_GUARDIAN: slot = 255; break; - default: return; - } - - if(slot < MAX_TOTEM) - { - uint64 guid = m_caster->m_TotemSlot[slot]; - if(guid != 0) - { - Creature *OldTotem = ObjectAccessor::GetCreature(*m_caster, guid); - if(OldTotem && OldTotem->isTotem()) - ((Totem*)OldTotem)->UnSummon(); - } - } - - uint32 team = 0; - if (m_caster->GetTypeId()==TYPEID_PLAYER) - team = ((Player*)m_caster)->GetTeam(); - - Totem* pTotem = new Totem; - - if(!pTotem->Create(objmgr.GenerateLowGuid(HIGHGUID_UNIT), m_caster->GetMap(), m_spellInfo->EffectMiscValue[i], team )) - { - delete pTotem; - return; - } - - float angle = slot < MAX_TOTEM ? M_PI/MAX_TOTEM - (slot*2*M_PI/MAX_TOTEM) : 0; - - float x,y,z; - m_caster->GetClosePoint(x,y,z,pTotem->GetObjectSize(),2.0f,angle); - - // totem must be at same Z in case swimming caster and etc. - if( fabs( z - m_caster->GetPositionZ() ) > 5 ) - z = m_caster->GetPositionZ(); - - pTotem->Relocate(x, y, z, m_caster->GetOrientation()); - - if(slot < MAX_TOTEM) - m_caster->m_TotemSlot[slot] = pTotem->GetGUID(); - - pTotem->SetOwner(m_caster->GetGUID()); - pTotem->SetTypeBySummonSpell(m_spellInfo); // must be after Create call where m_spells initilized - - int32 duration=GetSpellDuration(m_spellInfo); - if(Player* modOwner = m_caster->GetSpellModOwner()) - modOwner->ApplySpellMod(m_spellInfo->Id,SPELLMOD_DURATION, duration); - pTotem->SetDuration(duration); - - if (damage) // if not spell info, DB values used - { - pTotem->SetMaxHealth(damage); - pTotem->SetHealth(damage); - } - - pTotem->SetUInt32Value(UNIT_CREATED_BY_SPELL,m_spellInfo->Id); - pTotem->SetFlag(UNIT_FIELD_FLAGS,UNIT_FLAG_PVP_ATTACKABLE); - - pTotem->ApplySpellImmune(m_spellInfo->Id,IMMUNITY_STATE,SPELL_AURA_MOD_FEAR,true); - pTotem->ApplySpellImmune(m_spellInfo->Id,IMMUNITY_STATE,SPELL_AURA_TRANSFORM,true); - - pTotem->Summon(m_caster); - - if(slot < MAX_TOTEM && m_caster->GetTypeId() == TYPEID_PLAYER) - { - WorldPacket data(SMSG_TOTEM_CREATED, 1+8+4+4); - data << uint8(slot); - data << uint64(pTotem->GetGUID()); - data << uint32(duration); - data << uint32(m_spellInfo->Id); - ((Player*)m_caster)->SendDirectMessage(&data); - } -} - -void Spell::EffectEnchantHeldItem(uint32 i) -{ - // this is only item spell effect applied to main-hand weapon of target player (players in area) - if(!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) - return; - - Player* item_owner = (Player*)unitTarget; - Item* item = item_owner->GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_MAINHAND); - - if(!item ) - return; - - // must be equipped - if(!item ->IsEquipped()) - return; - - if (m_spellInfo->EffectMiscValue[i]) - { - uint32 enchant_id = m_spellInfo->EffectMiscValue[i]; - int32 duration = GetSpellDuration(m_spellInfo); //Try duration index first .. - if(!duration) - duration = m_currentBasePoints[i]+1; //Base points after .. - if(!duration) - duration = 10; //10 seconds for enchants which don't have listed duration - - SpellItemEnchantmentEntry const *pEnchant = sSpellItemEnchantmentStore.LookupEntry(enchant_id); - if(!pEnchant) - return; - - // Always go to temp enchantment slot - EnchantmentSlot slot = TEMP_ENCHANTMENT_SLOT; - - // Enchantment will not be applied if a different one already exists - if(item->GetEnchantmentId(slot) && item->GetEnchantmentId(slot) != enchant_id) - return; - - // Apply the temporary enchantment - item->SetEnchantment(slot, enchant_id, duration*1000, 0); - item_owner->ApplyEnchantment(item,slot,true); - } -} - -void Spell::EffectDisEnchant(uint32 /*i*/) -{ - if(m_caster->GetTypeId() != TYPEID_PLAYER) - return; - - Player* p_caster = (Player*)m_caster; - if(!itemTarget || !itemTarget->GetProto()->DisenchantID) - return; - - p_caster->UpdateCraftSkill(m_spellInfo->Id); - - ((Player*)m_caster)->SendLoot(itemTarget->GetGUID(),LOOT_DISENCHANTING); - - // item will be removed at disenchanting end -} - -void Spell::EffectInebriate(uint32 /*i*/) -{ - if(!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) - return; - - Player *player = (Player*)unitTarget; - uint16 currentDrunk = player->GetDrunkValue(); - uint16 drunkMod = damage * 256; - if (currentDrunk + drunkMod > 0xFFFF) - currentDrunk = 0xFFFF; - else - currentDrunk += drunkMod; - player->SetDrunkValue(currentDrunk, m_CastItem?m_CastItem->GetEntry():0); -} - -void Spell::EffectFeedPet(uint32 i) -{ - if(m_caster->GetTypeId() != TYPEID_PLAYER) - return; - - Player *_player = (Player*)m_caster; - - if(!itemTarget) - return; - - Pet *pet = _player->GetPet(); - if(!pet) - return; - - if(!pet->isAlive()) - return; - - int32 benefit = pet->GetCurrentFoodBenefitLevel(itemTarget->GetProto()->ItemLevel); - if(benefit <= 0) - return; - - uint32 count = 1; - _player->DestroyItemCount(itemTarget,count,true); - // TODO: fix crash when a spell has two effects, both pointed at the same item target - - m_caster->CastCustomSpell(m_caster,m_spellInfo->EffectTriggerSpell[i],&benefit,NULL,NULL,true); -} - -void Spell::EffectDismissPet(uint32 /*i*/) -{ - if(m_caster->GetTypeId() != TYPEID_PLAYER) - return; - - Pet* pet = m_caster->GetPet(); - - // not let dismiss dead pet - if(!pet||!pet->isAlive()) - return; - - ((Player*)m_caster)->RemovePet(pet,PET_SAVE_NOT_IN_SLOT); -} - -void Spell::EffectSummonObject(uint32 i) -{ - uint32 go_id = m_spellInfo->EffectMiscValue[i]; - - uint8 slot = 0; - switch(m_spellInfo->Effect[i]) - { - case SPELL_EFFECT_SUMMON_OBJECT_SLOT1: slot = 0; break; - case SPELL_EFFECT_SUMMON_OBJECT_SLOT2: slot = 1; break; - case SPELL_EFFECT_SUMMON_OBJECT_SLOT3: slot = 2; break; - case SPELL_EFFECT_SUMMON_OBJECT_SLOT4: slot = 3; break; - default: return; - } - - uint64 guid = m_caster->m_ObjectSlot[slot]; - if(guid != 0) - { - GameObject* obj = NULL; - if( m_caster ) - obj = ObjectAccessor::GetGameObject(*m_caster, guid); - - if(obj) obj->Delete(); - m_caster->m_ObjectSlot[slot] = 0; - } - - GameObject* pGameObj = new GameObject; - - float rot2 = sin(m_caster->GetOrientation()/2); - float rot3 = cos(m_caster->GetOrientation()/2); - - float x,y,z; - // If dest location if present - if (m_targets.m_targetMask & TARGET_FLAG_DEST_LOCATION) - { - x = m_targets.m_destX; - y = m_targets.m_destY; - z = m_targets.m_destZ; - } - // Summon in random point all other units if location present - else - m_caster->GetClosePoint(x,y,z,DEFAULT_WORLD_OBJECT_SIZE); - - Map *map = m_caster->GetMap(); - if(!pGameObj->Create(objmgr.GenerateLowGuid(HIGHGUID_GAMEOBJECT), go_id, map, x, y, z, m_caster->GetOrientation(), 0, 0, rot2, rot3, 0, 1)) - { - delete pGameObj; - return; - } - - pGameObj->SetUInt32Value(GAMEOBJECT_LEVEL,m_caster->getLevel()); - int32 duration = GetSpellDuration(m_spellInfo); - pGameObj->SetRespawnTime(duration > 0 ? duration/1000 : 0); - pGameObj->SetSpellId(m_spellInfo->Id); - m_caster->AddGameObject(pGameObj); - - map->Add(pGameObj); - WorldPacket data(SMSG_GAMEOBJECT_SPAWN_ANIM_OBSOLETE, 8); - data << pGameObj->GetGUID(); - m_caster->SendMessageToSet(&data,true); - - m_caster->m_ObjectSlot[slot] = pGameObj->GetGUID(); -} - -void Spell::EffectResurrect(uint32 i) -{ - if(!unitTarget) - return; - if(unitTarget->GetTypeId() != TYPEID_PLAYER) - return; - - if(unitTarget->isAlive()) - return; - if(!unitTarget->IsInWorld()) - return; - - switch (m_spellInfo->Id) - { - // Defibrillate (Goblin Jumper Cables) have 33% chance on success - case 8342: - if (roll_chance_i(67)) - { - m_caster->CastSpell(m_caster, 8338, true, m_CastItem); - return; - } - break; - // Defibrillate (Goblin Jumper Cables XL) have 50% chance on success - case 22999: - if (roll_chance_i(50)) - { - m_caster->CastSpell(m_caster, 23055, true, m_CastItem); - return; - } - break; - default: - break; - } - - Player* pTarget = ((Player*)unitTarget); - - if(pTarget->isRessurectRequested()) // already have one active request - return; - - uint32 health = pTarget->GetMaxHealth() * damage / 100; - uint32 mana = pTarget->GetMaxPower(POWER_MANA) * damage / 100; - - pTarget->setResurrectRequestData(m_caster->GetGUID(), m_caster->GetMapId(), m_caster->GetPositionX(), m_caster->GetPositionY(), m_caster->GetPositionZ(), health, mana); - SendResurrectRequest(pTarget); -} - -void Spell::EffectAddExtraAttacks(uint32 /*i*/) -{ - if(!unitTarget || !unitTarget->isAlive()) - return; - - if( unitTarget->m_extraAttacks ) - return; - - unitTarget->m_extraAttacks = damage; -} - -void Spell::EffectParry(uint32 /*i*/) -{ - if (unitTarget->GetTypeId() == TYPEID_PLAYER) - { - ((Player*)unitTarget)->SetCanParry(true); - } -} - -void Spell::EffectMomentMove(uint32 i) -{ - if(unitTarget->isInFlight()) - return; - - if( m_spellInfo->rangeIndex== 1) //self range - { - uint32 mapid = m_caster->GetMapId(); - float dis = GetSpellRadius(sSpellRadiusStore.LookupEntry(m_spellInfo->EffectRadiusIndex[i])); - - // before caster - float fx,fy,fz; - unitTarget->GetClosePoint(fx,fy,fz,unitTarget->GetObjectSize(),dis); - float ox,oy,oz; - unitTarget->GetPosition(ox,oy,oz); - - float fx2,fy2,fz2; // getObjectHitPos overwrite last args in any result case - if(VMAP::VMapFactory::createOrGetVMapManager()->getObjectHitPos(mapid, ox,oy,oz+0.5, fx,fy,oz+0.5,fx2,fy2,fz2, -0.5)) - { - fx = fx2; - fy = fy2; - fz = fz2; - unitTarget->UpdateGroundPositionZ(fx,fy,fz); - } - - if(unitTarget->GetTypeId() == TYPEID_PLAYER) - ((Player*)unitTarget)->TeleportTo(mapid, fx, fy, fz, unitTarget->GetOrientation(), TELE_TO_NOT_LEAVE_COMBAT | TELE_TO_NOT_UNSUMMON_PET | (unitTarget==m_caster ? TELE_TO_SPELL : 0)); - else - MapManager::Instance().GetMap(mapid, unitTarget)->CreatureRelocation((Creature*)unitTarget, fx, fy, fz, unitTarget->GetOrientation()); - } -} - -void Spell::EffectReputation(uint32 i) -{ - if(!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) - return; - - Player *_player = (Player*)unitTarget; - - int32 rep_change = m_currentBasePoints[i]+1; // field store reputation change -1 - - uint32 faction_id = m_spellInfo->EffectMiscValue[i]; - - FactionEntry const* factionEntry = sFactionStore.LookupEntry(faction_id); - - if(!factionEntry) - return; - - _player->ModifyFactionReputation(factionEntry,rep_change); -} - -void Spell::EffectQuestComplete(uint32 i) -{ - if(m_caster->GetTypeId() != TYPEID_PLAYER) - return; - - Player *_player = (Player*)m_caster; - - uint32 quest_id = m_spellInfo->EffectMiscValue[i]; - _player->AreaExploredOrEventHappens(quest_id); -} - -void Spell::EffectSelfResurrect(uint32 i) -{ - if(!unitTarget || unitTarget->isAlive()) - return; - if(unitTarget->GetTypeId() != TYPEID_PLAYER) - return; - if(!unitTarget->IsInWorld()) - return; - - uint32 health = 0; - uint32 mana = 0; - - // flat case - if(damage < 0) - { - health = uint32(-damage); - mana = m_spellInfo->EffectMiscValue[i]; - } - // percent case - else - { - health = uint32(damage/100.0f*unitTarget->GetMaxHealth()); - if(unitTarget->GetMaxPower(POWER_MANA) > 0) - mana = uint32(damage/100.0f*unitTarget->GetMaxPower(POWER_MANA)); - } - - Player *plr = ((Player*)unitTarget); - plr->ResurrectPlayer(0.0f); - - plr->SetHealth( health ); - plr->SetPower(POWER_MANA, mana ); - plr->SetPower(POWER_RAGE, 0 ); - plr->SetPower(POWER_ENERGY, plr->GetMaxPower(POWER_ENERGY) ); - - plr->SpawnCorpseBones(); - - plr->SaveToDB(); -} - -void Spell::EffectSkinning(uint32 /*i*/) -{ - if(unitTarget->GetTypeId() != TYPEID_UNIT ) - return; - if(!m_caster || m_caster->GetTypeId() != TYPEID_PLAYER) - return; - - Creature* creature = (Creature*) unitTarget; - int32 targetLevel = creature->getLevel(); - - uint32 skill; - if(creature->GetCreatureInfo()->flag1 & 256) - skill = SKILL_HERBALISM; // special case - else if(creature->GetCreatureInfo()->flag1 & 512) - skill = SKILL_MINING; // special case - else - skill = SKILL_SKINNING; // normal case - - ((Player*)m_caster)->SendLoot(creature->GetGUID(),LOOT_SKINNING); - creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SKINNABLE); - - int32 reqValue = targetLevel < 10 ? 0 : targetLevel < 20 ? (targetLevel-10)*10 : targetLevel*5; - - int32 skillValue = ((Player*)m_caster)->GetPureSkillValue(skill); - - // Double chances for elites - ((Player*)m_caster)->UpdateGatherSkill(skill, skillValue, reqValue, creature->isElite() ? 2 : 1 ); -} - -void Spell::EffectCharge(uint32 /*i*/) -{ - if(!unitTarget || !m_caster) - return; - - float x, y, z; - unitTarget->GetContactPoint(m_caster, x, y, z); - if(unitTarget->GetTypeId() != TYPEID_PLAYER) - ((Creature *)unitTarget)->StopMoving(); - - // Only send MOVEMENTFLAG_WALK_MODE, client has strange issues with other move flags - m_caster->SendMonsterMove(x, y, z, 0, MOVEMENTFLAG_WALK_MODE, 1); - - if(m_caster->GetTypeId() != TYPEID_PLAYER) - MapManager::Instance().GetMap(m_caster->GetMapId(), m_caster)->CreatureRelocation((Creature*)m_caster,x,y,z,m_caster->GetOrientation()); - - // not all charge effects used in negative spells - if ( !IsPositiveSpell(m_spellInfo->Id)) - m_caster->Attack(unitTarget,true); -} - -void Spell::EffectSummonCritter(uint32 i) -{ - if(m_caster->GetTypeId() != TYPEID_PLAYER) - return; - Player* player = (Player*)m_caster; - - uint32 pet_entry = m_spellInfo->EffectMiscValue[i]; - if(!pet_entry) - return; - - Pet* old_critter = player->GetMiniPet(); - - // for same pet just despawn - if(old_critter && old_critter->GetEntry() == pet_entry) - { - player->RemoveMiniPet(); - return; - } - - // despawn old pet before summon new - if(old_critter) - player->RemoveMiniPet(); - - // summon new pet - Pet* critter = new Pet(MINI_PET); - - Map *map = m_caster->GetMap(); - uint32 pet_number = objmgr.GeneratePetNumber(); - if(!critter->Create(objmgr.GenerateLowGuid(HIGHGUID_PET), - map, pet_entry, pet_number)) - { - sLog.outError("Spell::EffectSummonCritter, spellid %u: no such creature entry %u", m_spellInfo->Id, pet_entry); - delete critter; - return; - } - - float x,y,z; - // If dest location if present - if (m_targets.m_targetMask & TARGET_FLAG_DEST_LOCATION) - { - x = m_targets.m_destX; - y = m_targets.m_destY; - z = m_targets.m_destZ; - } - // Summon if dest location not present near caster - else - m_caster->GetClosePoint(x,y,z,critter->GetObjectSize()); - - critter->Relocate(x,y,z,m_caster->GetOrientation()); - - if(!critter->IsPositionValid()) - { - sLog.outError("ERROR: Pet (guidlow %d, entry %d) not summoned. Suggested coordinates isn't valid (X: %d Y: ^%d)", critter->GetGUIDLow(), critter->GetEntry(), critter->GetPositionX(), critter->GetPositionY()); - delete critter; - return; - } - - critter->SetUInt64Value(UNIT_FIELD_SUMMONEDBY,m_caster->GetGUID()); - critter->SetUInt64Value(UNIT_FIELD_CREATEDBY,m_caster->GetGUID()); - critter->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE,m_caster->getFaction()); - critter->SetUInt32Value(UNIT_CREATED_BY_SPELL, m_spellInfo->Id); - - critter->AIM_Initialize(); - critter->InitPetCreateSpells(); // e.g. disgusting oozeling has a create spell as critter... - critter->SetMaxHealth(1); - critter->SetHealth(1); - critter->SetLevel(1); - - // set timer for unsummon - int32 duration = GetSpellDuration(m_spellInfo); - if(duration > 0) - critter->SetDuration(duration); - - std::string name = player->GetName(); - name.append(petTypeSuffix[critter->getPetType()]); - critter->SetName( name ); - player->SetMiniPet(critter); - - map->Add((Creature*)critter); -} - -void Spell::EffectKnockBack(uint32 i) -{ - if(!unitTarget || !m_caster) - return; - - // Effect only works on players - if(unitTarget->GetTypeId()!=TYPEID_PLAYER) - return; - - float vsin = sin(m_caster->GetAngle(unitTarget)); - float vcos = cos(m_caster->GetAngle(unitTarget)); - - WorldPacket data(SMSG_MOVE_KNOCK_BACK, (8+4+4+4+4+4)); - data.append(unitTarget->GetPackGUID()); - data << uint32(0); // Sequence - data << float(vcos); // x direction - data << float(vsin); // y direction - data << float(m_spellInfo->EffectMiscValue[i])/10; // Horizontal speed - data << float(damage/-10); // Z Movement speed (vertical) - - ((Player*)unitTarget)->GetSession()->SendPacket(&data); -} - -void Spell::EffectSendTaxi(uint32 i) -{ - if(!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) - return; - - TaxiPathEntry const* entry = sTaxiPathStore.LookupEntry(m_spellInfo->EffectMiscValue[i]); - if(!entry) - return; - - std::vector nodes; - - nodes.resize(2); - nodes[0] = entry->from; - nodes[1] = entry->to; - - uint32 mountid = 0; - switch(m_spellInfo->Id) - { - case 31606: //Stormcrow Amulet - mountid = 17447; - break; - case 45071: //Quest - Sunwell Daily - Dead Scar Bombing Run - case 45113: //Quest - Sunwell Daily - Ship Bombing Run - case 45353: //Quest - Sunwell Daily - Ship Bombing Run Return - mountid = 22840; - break; - case 34905: //Stealth Flight - mountid = 6851; - break; - } - - ((Player*)unitTarget)->ActivateTaxiPathTo(nodes,mountid); - -} - -void Spell::EffectPlayerPull(uint32 i) -{ - if(!unitTarget || !m_caster) - return; - - // Effect only works on players - if(unitTarget->GetTypeId()!=TYPEID_PLAYER) - return; - - float vsin = sin(unitTarget->GetAngle(m_caster)); - float vcos = cos(unitTarget->GetAngle(m_caster)); - - WorldPacket data(SMSG_MOVE_KNOCK_BACK, (8+4+4+4+4+4)); - data.append(unitTarget->GetPackGUID()); - data << uint32(0); // Sequence - data << float(vcos); // x direction - data << float(vsin); // y direction - // Horizontal speed - data << float(damage ? damage : unitTarget->GetDistance2d(m_caster)); - data << float(m_spellInfo->EffectMiscValue[i])/-10; // Z Movement speed - - ((Player*)unitTarget)->GetSession()->SendPacket(&data); -} - -void Spell::EffectDispelMechanic(uint32 i) -{ - if(!unitTarget) - return; - - uint32 mechanic = m_spellInfo->EffectMiscValue[i]; - - Unit::AuraMap& Auras = unitTarget->GetAuras(); - for(Unit::AuraMap::iterator iter = Auras.begin(), next; iter != Auras.end(); iter = next) - { - next = iter; - ++next; - SpellEntry const *spell = sSpellStore.LookupEntry(iter->second->GetSpellProto()->Id); - if(spell->Mechanic == mechanic || spell->EffectMechanic[iter->second->GetEffIndex()] == mechanic) - { - unitTarget->RemoveAurasDueToSpell(spell->Id); - if(Auras.empty()) - break; - else - next = Auras.begin(); - } - } - return; -} - -void Spell::EffectSummonDeadPet(uint32 /*i*/) -{ - if(m_caster->GetTypeId() != TYPEID_PLAYER) - return; - Player *_player = (Player*)m_caster; - Pet *pet = _player->GetPet(); - if(!pet) - return; - if(pet->isAlive()) - return; - if(damage < 0) - return; - pet->SetUInt32Value(UNIT_DYNAMIC_FLAGS, 0); - pet->RemoveFlag (UNIT_FIELD_FLAGS, UNIT_FLAG_SKINNABLE); - pet->setDeathState( ALIVE ); - pet->clearUnitState(UNIT_STAT_ALL_STATE); - pet->SetHealth( uint32(pet->GetMaxHealth()*(float(damage)/100))); - - pet->AIM_Initialize(); - - _player->PetSpellInitialize(); - pet->SavePetToDB(PET_SAVE_AS_CURRENT); -} - -void Spell::EffectDestroyAllTotems(uint32 /*i*/) -{ - float mana = 0; - for(int slot = 0; slot < MAX_TOTEM; ++slot) - { - if(!m_caster->m_TotemSlot[slot]) - continue; - - Creature* totem = ObjectAccessor::GetCreature(*m_caster,m_caster->m_TotemSlot[slot]); - if(totem && totem->isTotem()) - { - uint32 spell_id = totem->GetUInt32Value(UNIT_CREATED_BY_SPELL); - SpellEntry const* spellInfo = sSpellStore.LookupEntry(spell_id); - if(spellInfo) - mana += spellInfo->manaCost * damage / 100; - ((Totem*)totem)->UnSummon(); - } - } - - int32 gain = m_caster->ModifyPower(POWER_MANA,int32(mana)); - m_caster->SendEnergizeSpellLog(m_caster, m_spellInfo->Id, gain, POWER_MANA); -} - -void Spell::EffectDurabilityDamage(uint32 i) -{ - if(!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) - return; - - int32 slot = m_spellInfo->EffectMiscValue[i]; - - // FIXME: some spells effects have value -1/-2 - // Possibly its mean -1 all player equipped items and -2 all items - if(slot < 0) - { - ((Player*)unitTarget)->DurabilityPointsLossAll(damage,(slot < -1)); - return; - } - - // invalid slot value - if(slot >= INVENTORY_SLOT_BAG_END) - return; - - if(Item* item = ((Player*)unitTarget)->GetItemByPos(INVENTORY_SLOT_BAG_0,slot)) - ((Player*)unitTarget)->DurabilityPointsLoss(item,damage); -} - -void Spell::EffectDurabilityDamagePCT(uint32 i) -{ - if(!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) - return; - - int32 slot = m_spellInfo->EffectMiscValue[i]; - - // FIXME: some spells effects have value -1/-2 - // Possibly its mean -1 all player equipped items and -2 all items - if(slot < 0) - { - ((Player*)unitTarget)->DurabilityLossAll(double(damage)/100.0f,(slot < -1)); - return; - } - - // invalid slot value - if(slot >= INVENTORY_SLOT_BAG_END) - return; - - if(damage <= 0) - return; - - if(Item* item = ((Player*)unitTarget)->GetItemByPos(INVENTORY_SLOT_BAG_0,slot)) - ((Player*)unitTarget)->DurabilityLoss(item,double(damage)/100.0f); -} - -void Spell::EffectModifyThreatPercent(uint32 /*effIndex*/) -{ - if(!unitTarget) - return; - - unitTarget->getThreatManager().modifyThreatPercent(m_caster, damage); -} - -void Spell::EffectTransmitted(uint32 effIndex) -{ - uint32 name_id = m_spellInfo->EffectMiscValue[effIndex]; - - GameObjectInfo const* goinfo = objmgr.GetGameObjectInfo(name_id); - - if (!goinfo) - { - sLog.outErrorDb("Gameobject (Entry: %u) not exist and not created at spell (ID: %u) cast",name_id, m_spellInfo->Id); - return; - } - - float fx,fy,fz; - - if(m_targets.m_targetMask & TARGET_FLAG_DEST_LOCATION) - { - fx = m_targets.m_destX; - fy = m_targets.m_destY; - fz = m_targets.m_destZ; - } - //FIXME: this can be better check for most objects but still hack - else if(m_spellInfo->EffectRadiusIndex[effIndex] && m_spellInfo->speed==0) - { - float dis = GetSpellRadius(sSpellRadiusStore.LookupEntry(m_spellInfo->EffectRadiusIndex[effIndex])); - m_caster->GetClosePoint(fx,fy,fz,DEFAULT_WORLD_OBJECT_SIZE, dis); - } - else - { - float min_dis = GetSpellMinRange(sSpellRangeStore.LookupEntry(m_spellInfo->rangeIndex)); - float max_dis = GetSpellMaxRange(sSpellRangeStore.LookupEntry(m_spellInfo->rangeIndex)); - float dis = rand_norm() * (max_dis - min_dis) + min_dis; - - m_caster->GetClosePoint(fx,fy,fz,DEFAULT_WORLD_OBJECT_SIZE, dis); - } - - Map *cMap = m_caster->GetMap(); - - if(goinfo->type==GAMEOBJECT_TYPE_FISHINGNODE) - { - if ( !cMap->IsInWater(fx,fy,fz-0.5f)) // Hack to prevent fishing bobber from failing to land on fishing hole - { // but this is not proper, we really need to ignore not materialized objects - SendCastResult(SPELL_FAILED_NOT_HERE); - SendChannelUpdate(0); - return; - } - - // replace by water level in this case - fz = cMap->GetWaterLevel(fx,fy); - } - // if gameobject is summoning object, it should be spawned right on caster's position - else if(goinfo->type==GAMEOBJECT_TYPE_SUMMONING_RITUAL) - { - m_caster->GetPosition(fx,fy,fz); - } - - GameObject* pGameObj = new GameObject; - - if(!pGameObj->Create(objmgr.GenerateLowGuid(HIGHGUID_GAMEOBJECT), name_id, cMap, - fx, fy, fz, m_caster->GetOrientation(), 0, 0, 0, 0, 100, 1)) - { - delete pGameObj; - return; - } - - int32 duration = GetSpellDuration(m_spellInfo); - - switch(goinfo->type) - { - case GAMEOBJECT_TYPE_FISHINGNODE: - { - m_caster->SetUInt64Value(UNIT_FIELD_CHANNEL_OBJECT,pGameObj->GetGUID()); - // Orientation3 - pGameObj->SetFloatValue(GAMEOBJECT_ROTATION + 2, 0.88431775569915771 ); - // Orientation4 - pGameObj->SetFloatValue(GAMEOBJECT_ROTATION + 3, -0.4668855369091033 ); - m_caster->AddGameObject(pGameObj); // will removed at spell cancel - - // end time of range when possible catch fish (FISHING_BOBBER_READY_TIME..GetDuration(m_spellInfo)) - // start time == fish-FISHING_BOBBER_READY_TIME (0..GetDuration(m_spellInfo)-FISHING_BOBBER_READY_TIME) - int32 lastSec; - switch(urand(0, 3)) - { - case 0: lastSec = 3; break; - case 1: lastSec = 7; break; - case 2: lastSec = 13; break; - case 3: lastSec = 17; break; - } - - duration = duration - lastSec*1000 + FISHING_BOBBER_READY_TIME*1000; - break; - } - case GAMEOBJECT_TYPE_SUMMONING_RITUAL: - { - if(m_caster->GetTypeId()==TYPEID_PLAYER) - { - pGameObj->AddUniqueUse((Player*)m_caster); - m_caster->AddGameObject(pGameObj); // will removed at spell cancel - } - break; - } - case GAMEOBJECT_TYPE_FISHINGHOLE: - case GAMEOBJECT_TYPE_CHEST: - default: - { - break; - } - } - - pGameObj->SetRespawnTime(duration > 0 ? duration/1000 : 0); - - pGameObj->SetOwnerGUID(m_caster->GetGUID() ); - - pGameObj->SetUInt32Value(GAMEOBJECT_LEVEL, m_caster->getLevel() ); - pGameObj->SetSpellId(m_spellInfo->Id); - - DEBUG_LOG("AddObject at SpellEfects.cpp EffectTransmitted\n"); - //m_caster->AddGameObject(pGameObj); - //m_ObjToDel.push_back(pGameObj); - - cMap->Add(pGameObj); - - WorldPacket data(SMSG_GAMEOBJECT_SPAWN_ANIM_OBSOLETE, 8); - data << uint64(pGameObj->GetGUID()); - m_caster->SendMessageToSet(&data,true); - - if(uint32 linkedEntry = pGameObj->GetLinkedGameObjectEntry()) - { - GameObject* linkedGO = new GameObject; - if(linkedGO->Create(objmgr.GenerateLowGuid(HIGHGUID_GAMEOBJECT), linkedEntry, cMap, - fx, fy, fz, m_caster->GetOrientation(), 0, 0, 0, 0, 100, 1)) - { - linkedGO->SetRespawnTime(duration > 0 ? duration/1000 : 0); - linkedGO->SetUInt32Value(GAMEOBJECT_LEVEL, m_caster->getLevel() ); - linkedGO->SetSpellId(m_spellInfo->Id); - linkedGO->SetOwnerGUID(m_caster->GetGUID() ); - - MapManager::Instance().GetMap(linkedGO->GetMapId(), linkedGO)->Add(linkedGO); - } - else - { - delete linkedGO; - linkedGO = NULL; - return; - } - } -} - -void Spell::EffectProspecting(uint32 /*i*/) -{ - if(m_caster->GetTypeId() != TYPEID_PLAYER) - return; - - Player* p_caster = (Player*)m_caster; - if(!itemTarget || !(itemTarget->GetProto()->BagFamily & BAG_FAMILY_MASK_MINING_SUPP)) - return; - - if(itemTarget->GetCount() < 5) - return; - - if( sWorld.getConfig(CONFIG_SKILL_PROSPECTING)) - { - uint32 SkillValue = p_caster->GetPureSkillValue(SKILL_JEWELCRAFTING); - uint32 reqSkillValue = itemTarget->GetProto()->RequiredSkillRank; - p_caster->UpdateGatherSkill(SKILL_JEWELCRAFTING, SkillValue, reqSkillValue); - } - - ((Player*)m_caster)->SendLoot(itemTarget->GetGUID(), LOOT_PROSPECTING); -} - -void Spell::EffectSkill(uint32 /*i*/) -{ - sLog.outDebug("WORLD: SkillEFFECT"); -} - -void Spell::EffectSummonDemon(uint32 i) -{ - float px = m_targets.m_destX; - float py = m_targets.m_destY; - float pz = m_targets.m_destZ; - - Creature* Charmed = m_caster->SummonCreature(m_spellInfo->EffectMiscValue[i], px, py, pz, m_caster->GetOrientation(),TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,3600000); - if (!Charmed) - return; - - // might not always work correctly, maybe the creature that dies from CoD casts the effect on itself and is therefore the caster? - Charmed->SetLevel(m_caster->getLevel()); - - // TODO: Add damage/mana/hp according to level - - if (m_spellInfo->EffectMiscValue[i] == 89) // Inferno summon - { - // Enslave demon effect, without mana cost and cooldown - m_caster->CastSpell(Charmed, 20882, true); // FIXME: enslave does not scale with level, level 62+ minions cannot be enslaved - - // Inferno effect - Charmed->CastSpell(Charmed, 22703, true, 0); - } -} - -/* There is currently no need for this effect. We handle it in BattleGround.cpp - If we would handle the resurrection here, the spiritguide would instantly disappear as the - player revives, and so we wouldn't see the spirit heal visual effect on the npc. - This is why we use a half sec delay between the visual effect and the resurrection itself */ -void Spell::EffectSpiritHeal(uint32 /*i*/) -{ - /* - if(!unitTarget || unitTarget->isAlive()) - return; - if(unitTarget->GetTypeId() != TYPEID_PLAYER) - return; - if(!unitTarget->IsInWorld()) - return; - - //m_spellInfo->EffectBasePoints[i]; == 99 (percent?) - //((Player*)unitTarget)->setResurrect(m_caster->GetGUID(), unitTarget->GetPositionX(), unitTarget->GetPositionY(), unitTarget->GetPositionZ(), unitTarget->GetMaxHealth(), unitTarget->GetMaxPower(POWER_MANA)); - ((Player*)unitTarget)->ResurrectPlayer(1.0f); - ((Player*)unitTarget)->SpawnCorpseBones(); - */ -} - -// remove insignia spell effect -void Spell::EffectSkinPlayerCorpse(uint32 /*i*/) -{ - sLog.outDebug("Effect: SkinPlayerCorpse"); - if ( (m_caster->GetTypeId() != TYPEID_PLAYER) || (unitTarget->GetTypeId() != TYPEID_PLAYER) || (unitTarget->isAlive()) ) - return; - - ((Player*)unitTarget)->RemovedInsignia( (Player*)m_caster ); -} - -void Spell::EffectStealBeneficialBuff(uint32 i) -{ - sLog.outDebug("Effect: StealBeneficialBuff"); - - if(!unitTarget || unitTarget==m_caster) // can't steal from self - return; - - std::vector steal_list; - // Create dispel mask by dispel type - uint32 dispelMask = GetDispellMask( DispelType(m_spellInfo->EffectMiscValue[i]) ); - Unit::AuraMap const& auras = unitTarget->GetAuras(); - for(Unit::AuraMap::const_iterator itr = auras.begin(); itr != auras.end(); ++itr) - { - Aura *aur = (*itr).second; - if (aur && (1<GetSpellProto()->Dispel) & dispelMask) - { - // Need check for passive? this - if (aur->IsPositive() && !aur->IsPassive()) - steal_list.push_back(aur); - } - } - // Ok if exist some buffs for dispel try dispel it - if (!steal_list.empty()) - { - std::list < std::pair > success_list; - int32 list_size = steal_list.size(); - // Dispell N = damage buffs (or while exist buffs for dispel) - for (int32 count=0; count < damage && list_size > 0; ++count) - { - // Random select buff for dispel - Aura *aur = steal_list[urand(0, list_size-1)]; - // Not use chance for steal - // TODO possible need do it - success_list.push_back( std::pair(aur->GetId(),aur->GetCasterGUID())); - - // Remove buff from list for prevent doubles - for (std::vector::iterator j = steal_list.begin(); j != steal_list.end(); ) - { - Aura *stealed = *j; - if (stealed->GetId() == aur->GetId() && stealed->GetCasterGUID() == aur->GetCasterGUID()) - { - j = steal_list.erase(j); - --list_size; - } - else - ++j; - } - } - // Really try steal and send log - if (!success_list.empty()) - { - int32 count = success_list.size(); - WorldPacket data(SMSG_SPELLSTEALLOG, 8+8+4+1+4+count*5); - data.append(unitTarget->GetPackGUID()); // Victim GUID - data.append(m_caster->GetPackGUID()); // Caster GUID - data << uint32(m_spellInfo->Id); // Dispell spell id - data << uint8(0); // not used - data << uint32(count); // count - for (std::list >::iterator j = success_list.begin(); j != success_list.end(); ++j) - { - SpellEntry const* spellInfo = sSpellStore.LookupEntry(j->first); - data << uint32(spellInfo->Id); // Spell Id - data << uint8(0); // 0 - steals !=0 transfers - unitTarget->RemoveAurasDueToSpellBySteal(spellInfo->Id, j->second, m_caster); - } - m_caster->SendMessageToSet(&data, true); - } - } -} - -void Spell::EffectKillCredit(uint32 i) -{ - if(!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) - return; - - ((Player*)unitTarget)->KilledMonster(m_spellInfo->EffectMiscValue[i], 0); -} - -void Spell::EffectQuestFail(uint32 i) -{ - if(!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) - return; - - ((Player*)unitTarget)->FailQuest(m_spellInfo->EffectMiscValue[i]); -} +/* + * Copyright (C) 2005-2008 MaNGOS + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "Common.h" +#include "SharedDefines.h" +#include "Database/DatabaseEnv.h" +#include "WorldPacket.h" +#include "WorldSession.h" +#include "Opcodes.h" +#include "Log.h" +#include "UpdateMask.h" +#include "World.h" +#include "ObjectMgr.h" +#include "SpellMgr.h" +#include "Player.h" +#include "SkillExtraItems.h" +#include "Unit.h" +#include "CreatureAI.h" +#include "Spell.h" +#include "DynamicObject.h" +#include "SpellAuras.h" +#include "Group.h" +#include "UpdateData.h" +#include "MapManager.h" +#include "ObjectAccessor.h" +#include "SharedDefines.h" +#include "Pet.h" +#include "GameObject.h" +#include "GossipDef.h" +#include "Creature.h" +#include "Totem.h" +#include "CreatureAI.h" +#include "BattleGround.h" +#include "BattleGroundEY.h" +#include "BattleGroundWS.h" +#include "VMapFactory.h" +#include "Language.h" +#include "SocialMgr.h" +#include "Util.h" + +pEffect SpellEffects[TOTAL_SPELL_EFFECTS]= +{ + &Spell::EffectNULL, // 0 + &Spell::EffectInstaKill, // 1 SPELL_EFFECT_INSTAKILL + &Spell::EffectSchoolDMG, // 2 SPELL_EFFECT_SCHOOL_DAMAGE + &Spell::EffectDummy, // 3 SPELL_EFFECT_DUMMY + &Spell::EffectUnused, // 4 SPELL_EFFECT_PORTAL_TELEPORT unused + &Spell::EffectTeleportUnits, // 5 SPELL_EFFECT_TELEPORT_UNITS + &Spell::EffectApplyAura, // 6 SPELL_EFFECT_APPLY_AURA + &Spell::EffectEnvirinmentalDMG, // 7 SPELL_EFFECT_ENVIRONMENTAL_DAMAGE + &Spell::EffectPowerDrain, // 8 SPELL_EFFECT_POWER_DRAIN + &Spell::EffectHealthLeech, // 9 SPELL_EFFECT_HEALTH_LEECH + &Spell::EffectHeal, // 10 SPELL_EFFECT_HEAL + &Spell::EffectUnused, // 11 SPELL_EFFECT_BIND + &Spell::EffectNULL, // 12 SPELL_EFFECT_PORTAL + &Spell::EffectUnused, // 13 SPELL_EFFECT_RITUAL_BASE unused + &Spell::EffectUnused, // 14 SPELL_EFFECT_RITUAL_SPECIALIZE unused + &Spell::EffectUnused, // 15 SPELL_EFFECT_RITUAL_ACTIVATE_PORTAL unused + &Spell::EffectQuestComplete, // 16 SPELL_EFFECT_QUEST_COMPLETE + &Spell::EffectWeaponDmg, // 17 SPELL_EFFECT_WEAPON_DAMAGE_NOSCHOOL + &Spell::EffectResurrect, // 18 SPELL_EFFECT_RESURRECT + &Spell::EffectAddExtraAttacks, // 19 SPELL_EFFECT_ADD_EXTRA_ATTACKS + &Spell::EffectUnused, // 20 SPELL_EFFECT_DODGE one spell: Dodge + &Spell::EffectUnused, // 21 SPELL_EFFECT_EVADE one spell: Evade (DND) + &Spell::EffectParry, // 22 SPELL_EFFECT_PARRY + &Spell::EffectBlock, // 23 SPELL_EFFECT_BLOCK one spell: Block + &Spell::EffectCreateItem, // 24 SPELL_EFFECT_CREATE_ITEM + &Spell::EffectUnused, // 25 SPELL_EFFECT_WEAPON + &Spell::EffectUnused, // 26 SPELL_EFFECT_DEFENSE one spell: Defense + &Spell::EffectPersistentAA, // 27 SPELL_EFFECT_PERSISTENT_AREA_AURA + &Spell::EffectSummonType, // 28 SPELL_EFFECT_SUMMON + &Spell::EffectMomentMove, // 29 SPELL_EFFECT_LEAP + &Spell::EffectEnergize, // 30 SPELL_EFFECT_ENERGIZE + &Spell::EffectWeaponDmg, // 31 SPELL_EFFECT_WEAPON_PERCENT_DAMAGE + &Spell::EffectTriggerMissileSpell, // 32 SPELL_EFFECT_TRIGGER_MISSILE + &Spell::EffectOpenLock, // 33 SPELL_EFFECT_OPEN_LOCK + &Spell::EffectSummonChangeItem, // 34 SPELL_EFFECT_SUMMON_CHANGE_ITEM + &Spell::EffectApplyAreaAura, // 35 SPELL_EFFECT_APPLY_AREA_AURA_PARTY + &Spell::EffectLearnSpell, // 36 SPELL_EFFECT_LEARN_SPELL + &Spell::EffectUnused, // 37 SPELL_EFFECT_SPELL_DEFENSE one spell: SPELLDEFENSE (DND) + &Spell::EffectDispel, // 38 SPELL_EFFECT_DISPEL + &Spell::EffectUnused, // 39 SPELL_EFFECT_LANGUAGE + &Spell::EffectDualWield, // 40 SPELL_EFFECT_DUAL_WIELD + &Spell::EffectSummonWild, // 41 SPELL_EFFECT_SUMMON_WILD + &Spell::EffectSummonGuardian, // 42 SPELL_EFFECT_SUMMON_GUARDIAN + &Spell::EffectTeleUnitsFaceCaster, // 43 SPELL_EFFECT_TELEPORT_UNITS_FACE_CASTER + &Spell::EffectLearnSkill, // 44 SPELL_EFFECT_SKILL_STEP + &Spell::EffectAddHonor, // 45 SPELL_EFFECT_ADD_HONOR honor/pvp related + &Spell::EffectNULL, // 46 SPELL_EFFECT_SPAWN we must spawn pet there + &Spell::EffectTradeSkill, // 47 SPELL_EFFECT_TRADE_SKILL + &Spell::EffectUnused, // 48 SPELL_EFFECT_STEALTH one spell: Base Stealth + &Spell::EffectUnused, // 49 SPELL_EFFECT_DETECT one spell: Detect + &Spell::EffectTransmitted, // 50 SPELL_EFFECT_TRANS_DOOR + &Spell::EffectUnused, // 51 SPELL_EFFECT_FORCE_CRITICAL_HIT unused + &Spell::EffectUnused, // 52 SPELL_EFFECT_GUARANTEE_HIT one spell: zzOLDCritical Shot + &Spell::EffectEnchantItemPerm, // 53 SPELL_EFFECT_ENCHANT_ITEM + &Spell::EffectEnchantItemTmp, // 54 SPELL_EFFECT_ENCHANT_ITEM_TEMPORARY + &Spell::EffectTameCreature, // 55 SPELL_EFFECT_TAMECREATURE + &Spell::EffectSummonPet, // 56 SPELL_EFFECT_SUMMON_PET + &Spell::EffectLearnPetSpell, // 57 SPELL_EFFECT_LEARN_PET_SPELL + &Spell::EffectWeaponDmg, // 58 SPELL_EFFECT_WEAPON_DAMAGE + &Spell::EffectOpenSecretSafe, // 59 SPELL_EFFECT_OPEN_LOCK_ITEM + &Spell::EffectProficiency, // 60 SPELL_EFFECT_PROFICIENCY + &Spell::EffectSendEvent, // 61 SPELL_EFFECT_SEND_EVENT + &Spell::EffectPowerBurn, // 62 SPELL_EFFECT_POWER_BURN + &Spell::EffectThreat, // 63 SPELL_EFFECT_THREAT + &Spell::EffectTriggerSpell, // 64 SPELL_EFFECT_TRIGGER_SPELL + &Spell::EffectUnused, // 65 SPELL_EFFECT_HEALTH_FUNNEL unused + &Spell::EffectUnused, // 66 SPELL_EFFECT_POWER_FUNNEL unused + &Spell::EffectHealMaxHealth, // 67 SPELL_EFFECT_HEAL_MAX_HEALTH + &Spell::EffectInterruptCast, // 68 SPELL_EFFECT_INTERRUPT_CAST + &Spell::EffectDistract, // 69 SPELL_EFFECT_DISTRACT + &Spell::EffectPull, // 70 SPELL_EFFECT_PULL one spell: Distract Move + &Spell::EffectPickPocket, // 71 SPELL_EFFECT_PICKPOCKET + &Spell::EffectAddFarsight, // 72 SPELL_EFFECT_ADD_FARSIGHT + &Spell::EffectSummonGuardian, // 73 SPELL_EFFECT_SUMMON_POSSESSED + &Spell::EffectSummonTotem, // 74 SPELL_EFFECT_SUMMON_TOTEM + &Spell::EffectHealMechanical, // 75 SPELL_EFFECT_HEAL_MECHANICAL one spell: Mechanical Patch Kit + &Spell::EffectSummonObjectWild, // 76 SPELL_EFFECT_SUMMON_OBJECT_WILD + &Spell::EffectScriptEffect, // 77 SPELL_EFFECT_SCRIPT_EFFECT + &Spell::EffectUnused, // 78 SPELL_EFFECT_ATTACK + &Spell::EffectSanctuary, // 79 SPELL_EFFECT_SANCTUARY + &Spell::EffectAddComboPoints, // 80 SPELL_EFFECT_ADD_COMBO_POINTS + &Spell::EffectUnused, // 81 SPELL_EFFECT_CREATE_HOUSE one spell: Create House (TEST) + &Spell::EffectNULL, // 82 SPELL_EFFECT_BIND_SIGHT + &Spell::EffectDuel, // 83 SPELL_EFFECT_DUEL + &Spell::EffectStuck, // 84 SPELL_EFFECT_STUCK + &Spell::EffectSummonPlayer, // 85 SPELL_EFFECT_SUMMON_PLAYER + &Spell::EffectActivateObject, // 86 SPELL_EFFECT_ACTIVATE_OBJECT + &Spell::EffectSummonTotem, // 87 SPELL_EFFECT_SUMMON_TOTEM_SLOT1 + &Spell::EffectSummonTotem, // 88 SPELL_EFFECT_SUMMON_TOTEM_SLOT2 + &Spell::EffectSummonTotem, // 89 SPELL_EFFECT_SUMMON_TOTEM_SLOT3 + &Spell::EffectSummonTotem, // 90 SPELL_EFFECT_SUMMON_TOTEM_SLOT4 + &Spell::EffectUnused, // 91 SPELL_EFFECT_THREAT_ALL one spell: zzOLDBrainwash + &Spell::EffectEnchantHeldItem, // 92 SPELL_EFFECT_ENCHANT_HELD_ITEM + &Spell::EffectUnused, // 93 SPELL_EFFECT_SUMMON_PHANTASM + &Spell::EffectSelfResurrect, // 94 SPELL_EFFECT_SELF_RESURRECT + &Spell::EffectSkinning, // 95 SPELL_EFFECT_SKINNING + &Spell::EffectCharge, // 96 SPELL_EFFECT_CHARGE + &Spell::EffectSummonCritter, // 97 SPELL_EFFECT_SUMMON_CRITTER + &Spell::EffectKnockBack, // 98 SPELL_EFFECT_KNOCK_BACK + &Spell::EffectDisEnchant, // 99 SPELL_EFFECT_DISENCHANT + &Spell::EffectInebriate, //100 SPELL_EFFECT_INEBRIATE + &Spell::EffectFeedPet, //101 SPELL_EFFECT_FEED_PET + &Spell::EffectDismissPet, //102 SPELL_EFFECT_DISMISS_PET + &Spell::EffectReputation, //103 SPELL_EFFECT_REPUTATION + &Spell::EffectSummonObject, //104 SPELL_EFFECT_SUMMON_OBJECT_SLOT1 + &Spell::EffectSummonObject, //105 SPELL_EFFECT_SUMMON_OBJECT_SLOT2 + &Spell::EffectSummonObject, //106 SPELL_EFFECT_SUMMON_OBJECT_SLOT3 + &Spell::EffectSummonObject, //107 SPELL_EFFECT_SUMMON_OBJECT_SLOT4 + &Spell::EffectDispelMechanic, //108 SPELL_EFFECT_DISPEL_MECHANIC + &Spell::EffectSummonDeadPet, //109 SPELL_EFFECT_SUMMON_DEAD_PET + &Spell::EffectDestroyAllTotems, //110 SPELL_EFFECT_DESTROY_ALL_TOTEMS + &Spell::EffectDurabilityDamage, //111 SPELL_EFFECT_DURABILITY_DAMAGE + &Spell::EffectSummonDemon, //112 SPELL_EFFECT_SUMMON_DEMON + &Spell::EffectResurrectNew, //113 SPELL_EFFECT_RESURRECT_NEW + &Spell::EffectTaunt, //114 SPELL_EFFECT_ATTACK_ME + &Spell::EffectDurabilityDamagePCT, //115 SPELL_EFFECT_DURABILITY_DAMAGE_PCT + &Spell::EffectSkinPlayerCorpse, //116 SPELL_EFFECT_SKIN_PLAYER_CORPSE one spell: Remove Insignia, bg usage, required special corpse flags... + &Spell::EffectSpiritHeal, //117 SPELL_EFFECT_SPIRIT_HEAL one spell: Spirit Heal + &Spell::EffectSkill, //118 SPELL_EFFECT_SKILL professions and more + &Spell::EffectApplyAreaAura, //119 SPELL_EFFECT_APPLY_AREA_AURA_PET + &Spell::EffectUnused, //120 SPELL_EFFECT_TELEPORT_GRAVEYARD one spell: Graveyard Teleport Test + &Spell::EffectWeaponDmg, //121 SPELL_EFFECT_NORMALIZED_WEAPON_DMG + &Spell::EffectUnused, //122 SPELL_EFFECT_122 unused + &Spell::EffectSendTaxi, //123 SPELL_EFFECT_SEND_TAXI taxi/flight related (misc value is taxi path id) + &Spell::EffectPlayerPull, //124 SPELL_EFFECT_PLAYER_PULL opposite of knockback effect (pulls player twoard caster) + &Spell::EffectModifyThreatPercent, //125 SPELL_EFFECT_MODIFY_THREAT_PERCENT + &Spell::EffectStealBeneficialBuff, //126 SPELL_EFFECT_STEAL_BENEFICIAL_BUFF spell steal effect? + &Spell::EffectProspecting, //127 SPELL_EFFECT_PROSPECTING Prospecting spell + &Spell::EffectApplyAreaAura, //128 SPELL_EFFECT_APPLY_AREA_AURA_FRIEND + &Spell::EffectApplyAreaAura, //129 SPELL_EFFECT_APPLY_AREA_AURA_ENEMY + &Spell::EffectNULL, //130 SPELL_EFFECT_REDIRECT_THREAT + &Spell::EffectUnused, //131 SPELL_EFFECT_131 used in some test spells + &Spell::EffectNULL, //132 SPELL_EFFECT_PLAY_MUSIC sound id in misc value + &Spell::EffectUnlearnSpecialization, //133 SPELL_EFFECT_UNLEARN_SPECIALIZATION unlearn profession specialization + &Spell::EffectKillCredit, //134 SPELL_EFFECT_KILL_CREDIT misc value is creature entry + &Spell::EffectNULL, //135 SPELL_EFFECT_CALL_PET + &Spell::EffectHealPct, //136 SPELL_EFFECT_HEAL_PCT + &Spell::EffectEnergisePct, //137 SPELL_EFFECT_ENERGIZE_PCT + &Spell::EffectNULL, //138 SPELL_EFFECT_138 Leap + &Spell::EffectUnused, //139 SPELL_EFFECT_139 unused + &Spell::EffectForceCast, //140 SPELL_EFFECT_FORCE_CAST + &Spell::EffectNULL, //141 SPELL_EFFECT_141 damage and reduce speed? + &Spell::EffectTriggerSpellWithValue, //142 SPELL_EFFECT_TRIGGER_SPELL_WITH_VALUE + &Spell::EffectApplyAreaAura, //143 SPELL_EFFECT_APPLY_AREA_AURA_OWNER + &Spell::EffectNULL, //144 SPELL_EFFECT_144 Spectral Blast + &Spell::EffectNULL, //145 SPELL_EFFECT_145 Black Hole Effect + &Spell::EffectUnused, //146 SPELL_EFFECT_146 unused + &Spell::EffectQuestFail, //147 SPELL_EFFECT_QUEST_FAIL quest fail + &Spell::EffectUnused, //148 SPELL_EFFECT_148 unused + &Spell::EffectNULL, //149 SPELL_EFFECT_149 swoop + &Spell::EffectUnused, //150 SPELL_EFFECT_150 unused + &Spell::EffectTriggerRitualOfSummoning, //151 SPELL_EFFECT_TRIGGER_SPELL_2 + &Spell::EffectNULL, //152 SPELL_EFFECT_152 summon Refer-a-Friend + &Spell::EffectNULL, //153 SPELL_EFFECT_CREATE_PET misc value is creature entry +}; + +void Spell::EffectNULL(uint32 /*i*/) +{ + sLog.outDebug("WORLD: Spell Effect DUMMY"); +} + +void Spell::EffectUnused(uint32 /*i*/) +{ + // NOT USED BY ANY SPELL OR USELESS OR IMPLEMENTED IN DIFFERENT WAY IN MANGOS +} + +void Spell::EffectResurrectNew(uint32 i) +{ + if(!unitTarget || unitTarget->isAlive()) + return; + + if(unitTarget->GetTypeId() != TYPEID_PLAYER) + return; + + if(!unitTarget->IsInWorld()) + return; + + Player* pTarget = ((Player*)unitTarget); + + if(pTarget->isRessurectRequested()) // already have one active request + return; + + uint32 health = damage; + uint32 mana = m_spellInfo->EffectMiscValue[i]; + pTarget->setResurrectRequestData(m_caster->GetGUID(), m_caster->GetMapId(), m_caster->GetPositionX(), m_caster->GetPositionY(), m_caster->GetPositionZ(), health, mana); + SendResurrectRequest(pTarget); +} + +void Spell::EffectInstaKill(uint32 /*i*/) +{ + if( !unitTarget || !unitTarget->isAlive() ) + return; + + // Demonic Sacrifice + if(m_spellInfo->Id==18788 && unitTarget->GetTypeId()==TYPEID_UNIT) + { + uint32 entry = unitTarget->GetEntry(); + uint32 spellID; + switch(entry) + { + case 416: spellID=18789; break; //imp + case 417: spellID=18792; break; //fellhunter + case 1860: spellID=18790; break; //void + case 1863: spellID=18791; break; //succubus + case 17252: spellID=35701; break; //fellguard + default: + sLog.outError("EffectInstaKill: Unhandled creature entry (%u) case.",entry); + return; + } + + m_caster->CastSpell(m_caster,spellID,true); + } + + if(m_caster==unitTarget) // prevent interrupt message + finish(); + + uint32 health = unitTarget->GetHealth(); + m_caster->DealDamage(unitTarget, health, NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); +} + +void Spell::EffectEnvirinmentalDMG(uint32 i) +{ + uint32 absorb = 0; + uint32 resist = 0; + + // Note: this hack with damage replace required until GO casting not implemented + // environment damage spells already have around enemies targeting but this not help in case not existed GO casting support + // currently each enemy selected explicitly and self cast damage, we prevent apply self casted spell bonuses/etc + damage = m_spellInfo->EffectBasePoints[i]+m_spellInfo->EffectBaseDice[i]; + + m_caster->CalcAbsorbResist(m_caster,GetSpellSchoolMask(m_spellInfo), SPELL_DIRECT_DAMAGE, damage, &absorb, &resist); + + m_caster->SendSpellNonMeleeDamageLog(m_caster, m_spellInfo->Id, damage, GetSpellSchoolMask(m_spellInfo), absorb, resist, false, 0, false); + if(m_caster->GetTypeId() == TYPEID_PLAYER) + ((Player*)m_caster)->EnvironmentalDamage(m_caster->GetGUID(),DAMAGE_FIRE,damage); +} + +void Spell::EffectSchoolDMG(uint32 effect_idx) +{ + if( unitTarget && unitTarget->isAlive()) + { + switch(m_spellInfo->SpellFamilyName) + { + case SPELLFAMILY_GENERIC: + { + //Gore + if(m_spellInfo->SpellIconID == 2269 ) + { + damage+= rand()%2 ? damage : 0; + } + + switch(m_spellInfo->Id) // better way to check unknown + { + // Meteor like spells (divided damage to targets) + case 24340: case 26558: case 28884: // Meteor + case 36837: case 38903: case 41276: // Meteor + case 26789: // Shard of the Fallen Star + case 31436: // Malevolent Cleave + case 35181: // Dive Bomb + case 40810: case 43267: case 43268: // Saber Lash + case 42384: // Brutal Swipe + case 45150: // Meteor Slash + { + uint32 count = 0; + for(std::list::iterator ihit= m_UniqueTargetInfo.begin();ihit != m_UniqueTargetInfo.end();++ihit) + if(ihit->effectMask & (1<GetHealth() / 2; + if(damage < 200) + damage = 200; + break; + } + } + break; + } + + case SPELLFAMILY_MAGE: + { + // Arcane Blast + if(m_spellInfo->SpellFamilyFlags & 0x20000000LL) + { + m_caster->CastSpell(m_caster,36032,true); + } + break; + } + case SPELLFAMILY_WARRIOR: + { + // Bloodthirst + if(m_spellInfo->SpellFamilyFlags & 0x40000000000LL) + { + damage = uint32(damage * (m_caster->GetTotalAttackPowerValue(BASE_ATTACK)) / 100); + } + // Shield Slam + else if(m_spellInfo->SpellFamilyFlags & 0x100000000LL) + damage += int32(m_caster->GetShieldBlockValue()); + // Victory Rush + else if(m_spellInfo->SpellFamilyFlags & 0x10000000000LL) + { + damage = uint32(damage * m_caster->GetTotalAttackPowerValue(BASE_ATTACK) / 100); + m_caster->ModifyAuraState(AURA_STATE_WARRIOR_VICTORY_RUSH, false); + } + break; + } + case SPELLFAMILY_WARLOCK: + { + // Incinerate Rank 1 & 2 + if((m_spellInfo->SpellFamilyFlags & 0x00004000000000LL) && m_spellInfo->SpellIconID==2128) + { + // Incinerate does more dmg (dmg*0.25) if the target is Immolated. + if(unitTarget->HasAuraState(AURA_STATE_IMMOLATE)) + damage += int32(damage*0.25); + } + break; + } + case SPELLFAMILY_DRUID: + { + // Ferocious Bite + if((m_spellInfo->SpellFamilyFlags & 0x000800000) && m_spellInfo->SpellVisual==6587) + { + // converts each extra point of energy into ($f1+$AP/630) additional damage + float multiple = m_caster->GetTotalAttackPowerValue(BASE_ATTACK) / 630 + m_spellInfo->DmgMultiplier[effect_idx]; + damage += int32(m_caster->GetPower(POWER_ENERGY) * multiple); + m_caster->SetPower(POWER_ENERGY,0); + } + // Rake + else if(m_spellInfo->SpellFamilyFlags & 0x0000000000001000LL) + { + damage += int32(m_caster->GetTotalAttackPowerValue(BASE_ATTACK) / 100); + } + // Swipe + else if(m_spellInfo->SpellFamilyFlags & 0x0010000000000000LL) + { + damage += int32(m_caster->GetTotalAttackPowerValue(BASE_ATTACK)*0.08f); + } + // Starfire + else if ( m_spellInfo->SpellFamilyFlags & 0x0004LL ) + { + Unit::AuraList const& m_OverrideClassScript = m_caster->GetAurasByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS); + for(Unit::AuraList::const_iterator i = m_OverrideClassScript.begin(); i != m_OverrideClassScript.end(); ++i) + { + // Starfire Bonus (caster) + switch((*i)->GetModifier()->m_miscvalue) + { + case 5481: // Nordrassil Regalia - bonus + { + Unit::AuraList const& m_periodicDamageAuras = unitTarget->GetAurasByType(SPELL_AURA_PERIODIC_DAMAGE); + for(Unit::AuraList::const_iterator itr = m_periodicDamageAuras.begin(); itr != m_periodicDamageAuras.end(); ++itr) + { + // Moonfire or Insect Swarm (target debuff from any casters) + if ( (*itr)->GetSpellProto()->SpellFamilyFlags & 0x00200002LL ) + { + int32 mod = (*i)->GetModifier()->m_amount; + damage += damage*mod/100; + break; + } + } + break; + } + case 5148: //Improved Starfire - Ivory Idol of the Moongoddes Aura + { + damage += (*i)->GetModifier()->m_amount; + break; + } + } + } + } + //Mangle Bonus for the initial damage of Lacerate and Rake + if((m_spellInfo->SpellFamilyFlags==0x0000000000001000LL && m_spellInfo->SpellIconID==494) || + (m_spellInfo->SpellFamilyFlags==0x0000010000000000LL && m_spellInfo->SpellIconID==2246)) + { + Unit::AuraList const& mDummyAuras = unitTarget->GetAurasByType(SPELL_AURA_DUMMY); + for(Unit::AuraList::const_iterator i = mDummyAuras.begin(); i != mDummyAuras.end(); ++i) + if((*i)->GetSpellProto()->SpellFamilyFlags & 0x0000044000000000LL && (*i)->GetSpellProto()->SpellFamilyName==SPELLFAMILY_DRUID) + { + damage = int32(damage*(100.0f+(*i)->GetModifier()->m_amount)/100.0f); + break; + } + } + break; + } + case SPELLFAMILY_ROGUE: + { + // Envenom + if(m_caster->GetTypeId()==TYPEID_PLAYER && (m_spellInfo->SpellFamilyFlags & 0x800000000LL)) + { + // consume from stack dozes not more that have combo-points + if(uint32 combo = ((Player*)m_caster)->GetComboPoints()) + { + // count consumed deadly poison doses at target + uint32 doses = 0; + + // remove consumed poison doses + Unit::AuraList const& auras = unitTarget->GetAurasByType(SPELL_AURA_PERIODIC_DAMAGE); + for(Unit::AuraList::const_iterator itr = auras.begin(); itr!=auras.end() && combo;) + { + // Deadly poison (only attacker applied) + if( (*itr)->GetSpellProto()->SpellFamilyName==SPELLFAMILY_ROGUE && ((*itr)->GetSpellProto()->SpellFamilyFlags & 0x10000) && + (*itr)->GetSpellProto()->SpellVisual==5100 && (*itr)->GetCasterGUID()==m_caster->GetGUID() ) + { + --combo; + ++doses; + + unitTarget->RemoveSingleAuraFromStack((*itr)->GetId(), (*itr)->GetEffIndex()); + + itr = auras.begin(); + } + else + ++itr; + } + + damage *= doses; + damage += int32(((Player*)m_caster)->GetTotalAttackPowerValue(BASE_ATTACK) * 0.03f * doses); + + // Eviscerate and Envenom Bonus Damage (item set effect) + if(m_caster->GetDummyAura(37169)) + damage += ((Player*)m_caster)->GetComboPoints()*40; + } + } + // Eviscerate + else if((m_spellInfo->SpellFamilyFlags & 0x00020000LL) && m_caster->GetTypeId()==TYPEID_PLAYER) + { + if(uint32 combo = ((Player*)m_caster)->GetComboPoints()) + { + damage += int32(m_caster->GetTotalAttackPowerValue(BASE_ATTACK) * combo * 0.03f); + + // Eviscerate and Envenom Bonus Damage (item set effect) + if(m_caster->GetDummyAura(37169)) + damage += combo*40; + } + } + break; + } + case SPELLFAMILY_HUNTER: + { + // Mongoose Bite + if((m_spellInfo->SpellFamilyFlags & 0x000000002) && m_spellInfo->SpellVisual==342) + { + damage += int32(m_caster->GetTotalAttackPowerValue(BASE_ATTACK)*0.2); + } + // Arcane Shot + else if((m_spellInfo->SpellFamilyFlags & 0x00000800) && m_spellInfo->maxLevel > 0) + { + damage += int32(m_caster->GetTotalAttackPowerValue(RANGED_ATTACK)*0.15); + } + // Steady Shot + else if(m_spellInfo->SpellFamilyFlags & 0x100000000LL) + { + int32 base = irand((int32)m_caster->GetWeaponDamageRange(RANGED_ATTACK, MINDAMAGE),(int32)m_caster->GetWeaponDamageRange(RANGED_ATTACK, MAXDAMAGE)); + damage += int32(float(base)/m_caster->GetAttackTime(RANGED_ATTACK)*2800 + m_caster->GetTotalAttackPowerValue(RANGED_ATTACK)*0.2f); + } + //Explosive Trap Effect + else if(m_spellInfo->SpellFamilyFlags & 0x00000004) + { + damage += int32(m_caster->GetTotalAttackPowerValue(RANGED_ATTACK)*0.1); + } + break; + } + case SPELLFAMILY_PALADIN: + { + //Judgement of Vengeance + if((m_spellInfo->SpellFamilyFlags & 0x800000000LL) && m_spellInfo->SpellIconID==2292) + { + uint32 stacks = 0; + Unit::AuraList const& auras = unitTarget->GetAurasByType(SPELL_AURA_PERIODIC_DAMAGE); + for(Unit::AuraList::const_iterator itr = auras.begin(); itr!=auras.end(); ++itr) + if((*itr)->GetId() == 31803 && (*itr)->GetCasterGUID()==m_caster->GetGUID()) + ++stacks; + if(!stacks) + //No damage if the target isn't affected by this + damage = -1; + else + damage *= stacks; + } + break; + } + } + + if(damage >= 0) + { + uint32 finalDamage; + if(m_originalCaster) // m_caster only passive source of cast + finalDamage = m_originalCaster->SpellNonMeleeDamageLog(unitTarget, m_spellInfo->Id, damage, m_IsTriggeredSpell, true); + else + finalDamage = m_caster->SpellNonMeleeDamageLog(unitTarget, m_spellInfo->Id, damage, m_IsTriggeredSpell, true); + + // post effects + switch(m_spellInfo->SpellFamilyName) + { + case SPELLFAMILY_WARRIOR: + { + // Bloodthirst + if(m_spellInfo->SpellFamilyFlags & 0x40000000000LL) + { + uint32 BTAura = 0; + switch(m_spellInfo->Id) + { + case 23881: BTAura = 23885; break; + case 23892: BTAura = 23886; break; + case 23893: BTAura = 23887; break; + case 23894: BTAura = 23888; break; + case 25251: BTAura = 25252; break; + case 30335: BTAura = 30339; break; + default: + sLog.outError("Spell::EffectSchoolDMG: Spell %u not handled in BTAura",m_spellInfo->Id); + break; + } + + if (BTAura) + m_caster->CastSpell(m_caster,BTAura,true); + } + break; + } + case SPELLFAMILY_PRIEST: + { + // Shadow Word: Death + if(finalDamage > 0 && (m_spellInfo->SpellFamilyFlags & 0x0000000200000000LL) && unitTarget->isAlive()) + // deals damage equal to damage done to caster if victim is not killed + m_caster->SpellNonMeleeDamageLog( m_caster, m_spellInfo->Id, finalDamage, m_IsTriggeredSpell, false); + + break; + } + case SPELLFAMILY_PALADIN: + { + // Judgement of Blood + if(finalDamage > 0 && (m_spellInfo->SpellFamilyFlags & 0x0000000800000000LL) && m_spellInfo->SpellIconID==153) + { + int32 damagePoint = finalDamage * 33 / 100; + m_caster->CastCustomSpell(m_caster, 32220, &damagePoint, NULL, NULL, true); + } + break; + } + } + } + } +} + +void Spell::EffectDummy(uint32 i) +{ + if(!unitTarget && !gameObjTarget && !itemTarget) + return; + + // selection by spell family + switch(m_spellInfo->SpellFamilyName) + { + case SPELLFAMILY_GENERIC: + // Gnomish Poultryizer trinket + switch(m_spellInfo->Id ) + { + case 8063: // Deviate Fish + { + if(m_caster->GetTypeId() != TYPEID_PLAYER) + return; + + uint32 spell_id = 0; + switch(urand(1,5)) + { + case 1: spell_id = 8064; break; // Sleepy + case 2: spell_id = 8065; break; // Invigorate + case 3: spell_id = 8066; break; // Shrink + case 4: spell_id = 8067; break; // Party Time! + case 5: spell_id = 8068; break; // Healthy Spirit + } + m_caster->CastSpell(m_caster,spell_id,true,NULL); + return; + } + case 8213: // Savory Deviate Delight + { + if(m_caster->GetTypeId() != TYPEID_PLAYER) + return; + + uint32 spell_id = 0; + switch(urand(1,2)) + { + // Flip Out - ninja + case 1: spell_id = (m_caster->getGender() == GENDER_MALE ? 8219 : 8220); break; + // Yaaarrrr - pirate + case 2: spell_id = (m_caster->getGender() == GENDER_MALE ? 8221 : 8222); break; + } + m_caster->CastSpell(m_caster,spell_id,true,NULL); + return; + } + case 8593: // Symbol of life (restore creature to life) + case 31225: // Shimmering Vessel (restore creature to life) + { + if(!unitTarget || unitTarget->GetTypeId()!=TYPEID_UNIT) + return; + ((Creature*)unitTarget)->setDeathState(JUST_ALIVED); + return; + } + case 12162: // Deep wounds + case 12850: // (now good common check for this spells) + case 12868: + { + if(!unitTarget) + return; + + float damage; + // DW should benefit of attack power, damage percent mods etc. + // TODO: check if using offhand damage is correct and if it should be divided by 2 + if (m_caster->haveOffhandWeapon() && m_caster->getAttackTimer(BASE_ATTACK) > m_caster->getAttackTimer(OFF_ATTACK)) + damage = (m_caster->GetFloatValue(UNIT_FIELD_MINOFFHANDDAMAGE) + m_caster->GetFloatValue(UNIT_FIELD_MAXOFFHANDDAMAGE))/2; + else + damage = (m_caster->GetFloatValue(UNIT_FIELD_MINDAMAGE) + m_caster->GetFloatValue(UNIT_FIELD_MAXDAMAGE))/2; + + switch (m_spellInfo->Id) + { + case 12850: damage *= 0.2f; break; + case 12162: damage *= 0.4f; break; + case 12868: damage *= 0.6f; break; + default: + sLog.outError("Spell::EffectDummy: Spell %u not handled in DW",m_spellInfo->Id); + return; + }; + + int32 deepWoundsDotBasePoints0 = int32(damage / 4); + m_caster->CastCustomSpell(unitTarget, 12721, &deepWoundsDotBasePoints0, NULL, NULL, true, NULL); + return; + } + case 12975: //Last Stand + { + int32 healthModSpellBasePoints0 = int32(m_caster->GetMaxHealth()*0.3); + m_caster->CastCustomSpell(m_caster, 12976, &healthModSpellBasePoints0, NULL, NULL, true, NULL); + return; + } + case 13120: // net-o-matic + { + if(!unitTarget) + return; + + uint32 spell_id = 0; + + uint32 roll = urand(0, 99); + + if(roll < 2) // 2% for 30 sec self root (off-like chance unknown) + spell_id = 16566; + else if(roll < 4) // 2% for 20 sec root, charge to target (off-like chance unknown) + spell_id = 13119; + else // normal root + spell_id = 13099; + + m_caster->CastSpell(unitTarget,spell_id,true,NULL); + return; + } + case 13567: // Dummy Trigger + { + // can be used for different aura triggreing, so select by aura + if(!m_triggeredByAuraSpell || !unitTarget) + return; + + switch(m_triggeredByAuraSpell->Id) + { + case 26467: // Persistent Shield + m_caster->CastCustomSpell(unitTarget, 26470, &damage, NULL, NULL, true); + break; + default: + sLog.outError("EffectDummy: Non-handled case for spell 13567 for triggered aura %u",m_triggeredByAuraSpell->Id); + break; + } + return; + } + case 14185: // Preparation Rogue + { + if(m_caster->GetTypeId()!=TYPEID_PLAYER) + return; + + //immediately finishes the cooldown on certain Rogue abilities + const PlayerSpellMap& sp_list = ((Player *)m_caster)->GetSpellMap(); + for (PlayerSpellMap::const_iterator itr = sp_list.begin(); itr != sp_list.end(); ++itr) + { + uint32 classspell = itr->first; + SpellEntry const *spellInfo = sSpellStore.LookupEntry(classspell); + + if (spellInfo->SpellFamilyName == SPELLFAMILY_ROGUE && (spellInfo->SpellFamilyFlags & 0x26000000860LL)) + { + ((Player*)m_caster)->RemoveSpellCooldown(classspell); + + WorldPacket data(SMSG_CLEAR_COOLDOWN, (4+8)); + data << uint32(classspell); + data << uint64(m_caster->GetGUID()); + ((Player*)m_caster)->GetSession()->SendPacket(&data); + } + } + return; + } + case 15998: // Capture Worg Pup + case 29435: // Capture Female Kaliri Hatchling + { + if(!unitTarget || unitTarget->GetTypeId() != TYPEID_UNIT) + return; + + Creature* creatureTarget = (Creature*)unitTarget; + creatureTarget->setDeathState(JUST_DIED); + creatureTarget->RemoveCorpse(); + creatureTarget->SetHealth(0); // just for nice GM-mode view + return; + } + case 16589: // Noggenfogger Elixir + { + if(m_caster->GetTypeId()!=TYPEID_PLAYER) + return; + + uint32 spell_id = 0; + switch(urand(1,3)) + { + case 1: spell_id = 16595; break; + case 2: spell_id = 16593; break; + default:spell_id = 16591; break; + } + + m_caster->CastSpell(m_caster,spell_id,true,NULL); + return; + } + case 17251: // Spirit Healer Res + { + if(!unitTarget || !m_originalCaster) + return; + + if(m_originalCaster->GetTypeId() == TYPEID_PLAYER) + { + WorldPacket data(SMSG_SPIRIT_HEALER_CONFIRM, 8); + data << unitTarget->GetGUID(); + ((Player*)m_originalCaster)->GetSession()->SendPacket( &data ); + } + return; + } + case 17271: // Test Fetid Skull + { + if(!itemTarget && m_caster->GetTypeId()!=TYPEID_PLAYER) + return; + + uint32 spell_id = roll_chance_i(50) ? 17269 : 17270; + + m_caster->CastSpell(m_caster,spell_id,true,NULL); + return; + } + case 20577: // Cannibalize + if (unitTarget) + m_caster->CastSpell(m_caster,20578,false,NULL); + return; + case 23019: // Crystal Prison Dummy DND + { + if(!unitTarget || !unitTarget->isAlive() || unitTarget->GetTypeId() != TYPEID_UNIT || ((Creature*)unitTarget)->isPet()) + return; + + Creature* creatureTarget = (Creature*)unitTarget; + if(creatureTarget->isPet()) + return; + + creatureTarget->setDeathState(JUST_DIED); + creatureTarget->RemoveCorpse(); + creatureTarget->SetHealth(0); // just for nice GM-mode view + + GameObject* pGameObj = new GameObject; + + Map *map = creatureTarget->GetMap(); + + if(!pGameObj->Create(objmgr.GenerateLowGuid(HIGHGUID_GAMEOBJECT), 179644, map, + creatureTarget->GetPositionX(), creatureTarget->GetPositionY(), creatureTarget->GetPositionZ(), + creatureTarget->GetOrientation(), 0, 0, 0, 0, 100, 1) ) + { + delete pGameObj; + return; + } + + pGameObj->SetRespawnTime(creatureTarget->GetRespawnTime()-time(NULL)); + pGameObj->SetOwnerGUID(m_caster->GetGUID() ); + pGameObj->SetUInt32Value(GAMEOBJECT_LEVEL, m_caster->getLevel() ); + pGameObj->SetSpellId(m_spellInfo->Id); + + DEBUG_LOG("AddObject at SpellEfects.cpp EffectDummy\n"); + map->Add(pGameObj); + + WorldPacket data(SMSG_GAMEOBJECT_SPAWN_ANIM_OBSOLETE, 8); + data << uint64(pGameObj->GetGUID()); + m_caster->SendMessageToSet(&data,true); + + return; + } + case 23074: // Arc. Dragonling + if (!m_CastItem) return; + m_caster->CastSpell(m_caster,19804,true,m_CastItem); + return; + case 23075: // Mithril Mechanical Dragonling + if (!m_CastItem) return; + m_caster->CastSpell(m_caster,12749,true,m_CastItem); + return; + case 23076: // Mechanical Dragonling + if (!m_CastItem) return; + m_caster->CastSpell(m_caster,4073,true,m_CastItem); + return; + case 23133: // Gnomish Battle Chicken + if (!m_CastItem) return; + m_caster->CastSpell(m_caster,13166,true,m_CastItem); + return; + case 23448: // Ultrasafe Transporter: Gadgetzan - backfires + { + int32 r = irand(0, 119); + if ( r < 20 ) // 1/6 polymorph + m_caster->CastSpell(m_caster,23444,true); + else if ( r < 100 ) // 4/6 evil twin + m_caster->CastSpell(m_caster,23445,true); + else // 1/6 miss the target + m_caster->CastSpell(m_caster,36902,true); + return; + } + case 23453: // Ultrasafe Transporter: Gadgetzan + if ( roll_chance_i(50) ) // success + m_caster->CastSpell(m_caster,23441,true); + else // failure + m_caster->CastSpell(m_caster,23446,true); + return; + case 23645: // Hourglass Sand + m_caster->RemoveAurasDueToSpell(23170); + return; + case 23725: // Gift of Life (warrior bwl trinket) + m_caster->CastSpell(m_caster,23782,true); + m_caster->CastSpell(m_caster,23783,true); + return; + case 25860: // Reindeer Transformation + { + if (!m_caster->HasAuraType(SPELL_AURA_MOUNTED)) + return; + + float flyspeed = m_caster->GetSpeedRate(MOVE_FLY); + float speed = m_caster->GetSpeedRate(MOVE_RUN); + + m_caster->RemoveSpellsCausingAura(SPELL_AURA_MOUNTED); + + //5 different spells used depending on mounted speed and if mount can fly or not + if (flyspeed >= 4.1f) + m_caster->CastSpell(m_caster, 44827, true); //310% flying Reindeer + else if (flyspeed >= 3.8f) + m_caster->CastSpell(m_caster, 44825, true); //280% flying Reindeer + else if (flyspeed >= 1.6f) + m_caster->CastSpell(m_caster, 44824, true); //60% flying Reindeer + else if (speed >= 2.0f) + m_caster->CastSpell(m_caster, 25859, true); //100% ground Reindeer + else + m_caster->CastSpell(m_caster, 25858, true); //60% ground Reindeer + + return; + } + //case 26074: // Holiday Cheer + // return; -- implemented at client side + case 28006: // Arcane Cloaking + { + if( unitTarget->GetTypeId() == TYPEID_PLAYER ) + m_caster->CastSpell(unitTarget,29294,true); + return; + } + case 28730: // Arcane Torrent (Mana) + { + int32 count = 0; + Unit::AuraList const& m_dummyAuras = m_caster->GetAurasByType(SPELL_AURA_DUMMY); + for(Unit::AuraList::const_iterator i = m_dummyAuras.begin(); i != m_dummyAuras.end(); ++i) + if ((*i)->GetId() == 28734) + ++count; + if (count) + { + m_caster->RemoveAurasDueToSpell(28734); + int32 bp = damage * count; + m_caster->CastCustomSpell(m_caster, 28733, &bp, NULL, NULL, true); + } + return; + } + case 29200: // Purify Helboar Meat + { + if( m_caster->GetTypeId() != TYPEID_PLAYER ) + return; + + uint32 spell_id = roll_chance_i(50) ? 29277 : 29278; + + m_caster->CastSpell(m_caster,spell_id,true,NULL); + return; + } + case 29858: // Soulshatter + if (unitTarget && unitTarget->GetTypeId() == TYPEID_UNIT && unitTarget->IsHostileTo(m_caster)) + m_caster->CastSpell(unitTarget,32835,true); + return; + case 30458: // Nigh Invulnerability + if (!m_CastItem) return; + if(roll_chance_i(86)) // success + m_caster->CastSpell(m_caster, 30456, true, m_CastItem); + else // backfire in 14% casts + m_caster->CastSpell(m_caster, 30457, true, m_CastItem); + return; + case 30507: // Poultryizer + if (!m_CastItem) return; + if(roll_chance_i(80)) // success + m_caster->CastSpell(unitTarget, 30501, true, m_CastItem); + else // backfire 20% + m_caster->CastSpell(unitTarget, 30504, true, m_CastItem); + return; + case 33060: // Make a Wish + { + if(m_caster->GetTypeId()!=TYPEID_PLAYER) + return; + + uint32 spell_id = 0; + + switch(urand(1,5)) + { + case 1: spell_id = 33053; break; + case 2: spell_id = 33057; break; + case 3: spell_id = 33059; break; + case 4: spell_id = 33062; break; + case 5: spell_id = 33064; break; + } + + m_caster->CastSpell(m_caster,spell_id,true,NULL); + return; + } + case 35745: + { + uint32 spell_id; + switch(m_caster->GetAreaId()) + { + case 3900: spell_id = 35743; break; + case 3742: spell_id = 35744; break; + default: return; + } + + m_caster->CastSpell(m_caster,spell_id,true); + return; + } + case 37674: // Chaos Blast + if(unitTarget) + m_caster->CastSpell(unitTarget,37675,true); + return; + case 44875: // Complete Raptor Capture + { + if(!unitTarget || unitTarget->GetTypeId() != TYPEID_UNIT) + return; + + Creature* creatureTarget = (Creature*)unitTarget; + + creatureTarget->setDeathState(JUST_DIED); + creatureTarget->RemoveCorpse(); + creatureTarget->SetHealth(0); // just for nice GM-mode view + + //cast spell Raptor Capture Credit + m_caster->CastSpell(m_caster,42337,true,NULL); + return; + } + case 45030: // Impale Emissary + { + // Emissary of Hate Credit + m_caster->CastSpell(m_caster,45088,true); + return; + } + case 50243: // Teach Language + { + if(m_caster->GetTypeId() != TYPEID_PLAYER) + return; + + // spell has a 1/3 chance to trigger one of the below + if(roll_chance_i(66)) + return; + if(((Player*)m_caster)->GetTeam() == ALLIANCE) + { + // 1000001 - gnomish binary + m_caster->CastSpell(m_caster, 50242, true); + } + else + { + // 01001000 - goblin binary + m_caster->CastSpell(m_caster, 50246, true); + } + + return; + } + case 51582: //Rocket Boots Engaged (Rocket Boots Xtreme and Rocket Boots Xtreme Lite) + { + if(m_caster->GetTypeId() != TYPEID_PLAYER) + return; + + if(BattleGround* bg = ((Player*)m_caster)->GetBattleGround()) + bg->EventPlayerDroppedFlag((Player*)m_caster); + + m_caster->CastSpell(m_caster, 30452, true, NULL); + return; + } + } + + //All IconID Check in there + switch(m_spellInfo->SpellIconID) + { + // Berserking (troll racial traits) + case 1661: + { + uint32 healthPerc = uint32((float(m_caster->GetHealth())/m_caster->GetMaxHealth())*100); + int32 melee_mod = 10; + if (healthPerc <= 40) + melee_mod = 30; + if (healthPerc < 100 && healthPerc > 40) + melee_mod = 10+(100-healthPerc)/3; + + int32 hasteModBasePoints0 = melee_mod; // (EffectBasePoints[0]+1)-1+(5-melee_mod) = (melee_mod-1+1)-1+5-melee_mod = 5-1 + int32 hasteModBasePoints1 = (5-melee_mod); + int32 hasteModBasePoints2 = 5; + + // FIXME: custom spell required this aura state by some unknown reason, we not need remove it anyway + m_caster->ModifyAuraState(AURA_STATE_BERSERKING,true); + m_caster->CastCustomSpell(m_caster,26635,&hasteModBasePoints0,&hasteModBasePoints1,&hasteModBasePoints2,true,NULL); + return; + } + } + break; + case SPELLFAMILY_MAGE: + switch(m_spellInfo->Id ) + { + case 11958: // Cold Snap + { + if(m_caster->GetTypeId()!=TYPEID_PLAYER) + return; + + // immediately finishes the cooldown on Frost spells + const PlayerSpellMap& sp_list = ((Player *)m_caster)->GetSpellMap(); + for (PlayerSpellMap::const_iterator itr = sp_list.begin(); itr != sp_list.end(); ++itr) + { + if (itr->second->state == PLAYERSPELL_REMOVED) + continue; + + uint32 classspell = itr->first; + SpellEntry const *spellInfo = sSpellStore.LookupEntry(classspell); + + if( spellInfo->SpellFamilyName == SPELLFAMILY_MAGE && + (GetSpellSchoolMask(spellInfo) & SPELL_SCHOOL_MASK_FROST) && + spellInfo->Id != 11958 && GetSpellRecoveryTime(spellInfo) > 0 ) + { + ((Player*)m_caster)->RemoveSpellCooldown(classspell); + + WorldPacket data(SMSG_CLEAR_COOLDOWN, (4+8)); + data << uint32(classspell); + data << uint64(m_caster->GetGUID()); + ((Player*)m_caster)->GetSession()->SendPacket(&data); + } + } + return; + } + } + break; + case SPELLFAMILY_WARRIOR: + // Charge + if(m_spellInfo->SpellFamilyFlags & 0x1 && m_spellInfo->SpellVisual == 867) + { + int32 chargeBasePoints0 = damage; + m_caster->CastCustomSpell(m_caster,34846,&chargeBasePoints0,NULL,NULL,true); + return; + } + // Execute + if(m_spellInfo->SpellFamilyFlags & 0x20000000) + { + if(!unitTarget) + return; + + int32 basePoints0 = damage+int32(m_caster->GetPower(POWER_RAGE) * m_spellInfo->DmgMultiplier[i]); + m_caster->CastCustomSpell(unitTarget, 20647, &basePoints0, NULL, NULL, true, 0); + m_caster->SetPower(POWER_RAGE,0); + return; + } + if(m_spellInfo->Id==21977) //Warrior's Wrath + { + if(!unitTarget) + return; + + m_caster->CastSpell(unitTarget,21887,true); // spell mod + return; + } + break; + case SPELLFAMILY_WARLOCK: + //Life Tap (only it have this with dummy effect) + if (m_spellInfo->SpellFamilyFlags == 0x40000) + { + float cost = m_currentBasePoints[0]+1; + + if(Player* modOwner = m_caster->GetSpellModOwner()) + modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_COST, cost,this); + + int32 dmg = m_caster->SpellDamageBonus(m_caster, m_spellInfo,uint32(cost > 0 ? cost : 0), SPELL_DIRECT_DAMAGE); + + if(int32(m_caster->GetHealth()) > dmg) + { + // Shouldn't Appear in Combat Log + m_caster->ModifyHealth(-dmg); + + int32 mana = dmg; + + Unit::AuraList const& auraDummy = m_caster->GetAurasByType(SPELL_AURA_DUMMY); + for(Unit::AuraList::const_iterator itr = auraDummy.begin(); itr != auraDummy.end(); ++itr) + { + // only Imp. Life Tap have this in combination with dummy aura + if((*itr)->GetSpellProto()->SpellFamilyName==SPELLFAMILY_WARLOCK && (*itr)->GetSpellProto()->SpellIconID == 208) + mana = ((*itr)->GetModifier()->m_amount + 100)* mana / 100; + } + + m_caster->CastCustomSpell(m_caster,31818,&mana,NULL,NULL,true,NULL); + + // Mana Feed + int32 manaFeedVal = m_caster->CalculateSpellDamage(m_spellInfo,1, m_spellInfo->EffectBasePoints[1],m_caster); + manaFeedVal = manaFeedVal * mana / 100; + if(manaFeedVal > 0) + m_caster->CastCustomSpell(m_caster,32553,&manaFeedVal,NULL,NULL,true,NULL); + } + else + SendCastResult(SPELL_FAILED_FIZZLE); + return; + } + break; + case SPELLFAMILY_PRIEST: + switch(m_spellInfo->Id ) + { + case 28598: // Touch of Weakness triggered spell + { + if(!unitTarget || !m_triggeredByAuraSpell) + return; + + uint32 spellid = 0; + switch(m_triggeredByAuraSpell->Id) + { + case 2652: spellid = 2943; break; // Rank 1 + case 19261: spellid = 19249; break; // Rank 2 + case 19262: spellid = 19251; break; // Rank 3 + case 19264: spellid = 19252; break; // Rank 4 + case 19265: spellid = 19253; break; // Rank 5 + case 19266: spellid = 19254; break; // Rank 6 + case 25461: spellid = 25460; break; // Rank 7 + default: + sLog.outError("Spell::EffectDummy: Spell 28598 triggered by unhandeled spell %u",m_triggeredByAuraSpell->Id); + return; + } + m_caster->CastSpell(unitTarget, spellid, true, NULL); + return; + } + } + break; + case SPELLFAMILY_DRUID: + switch(m_spellInfo->Id ) + { + case 5420: // Tree of Life passive + { + // Tree of Life area effect + int32 health_mod = int32(m_caster->GetStat(STAT_SPIRIT)/4); + m_caster->CastCustomSpell(m_caster,34123,&health_mod,NULL,NULL,true,NULL); + return; + } + } + break; + case SPELLFAMILY_ROGUE: + switch(m_spellInfo->Id ) + { + case 31231: // Cheat Death + { + m_caster->CastSpell(m_caster,45182,true); + return; + } + case 5938: // Shiv + { + if(m_caster->GetTypeId() != TYPEID_PLAYER) + return; + + Player *pCaster = ((Player*)m_caster); + + Item *item = pCaster->GetWeaponForAttack(OFF_ATTACK); + if(!item) + return; + + // all poison enchantments is temporary + uint32 enchant_id = item->GetEnchantmentId(TEMP_ENCHANTMENT_SLOT); + if(!enchant_id) + return; + + SpellItemEnchantmentEntry const *pEnchant = sSpellItemEnchantmentStore.LookupEntry(enchant_id); + if(!pEnchant) + return; + + for (int s=0;s<3;s++) + { + if(pEnchant->type[s]!=ITEM_ENCHANTMENT_TYPE_COMBAT_SPELL) + continue; + + SpellEntry const* combatEntry = sSpellStore.LookupEntry(pEnchant->spellid[s]); + if(!combatEntry || combatEntry->Dispel != DISPEL_POISON) + continue; + + m_caster->CastSpell(unitTarget, combatEntry, true, item); + } + + m_caster->CastSpell(unitTarget, 5940, true); + return; + } + } + break; + case SPELLFAMILY_HUNTER: + // Steady Shot + if(m_spellInfo->SpellFamilyFlags & 0x100000000LL) + { + if( !unitTarget || !unitTarget->isAlive()) + return; + + bool found = false; + + // check dazed affect + Unit::AuraList const& decSpeedList = unitTarget->GetAurasByType(SPELL_AURA_MOD_DECREASE_SPEED); + for(Unit::AuraList::const_iterator iter = decSpeedList.begin(); iter != decSpeedList.end(); ++iter) + { + if((*iter)->GetSpellProto()->SpellIconID==15 && (*iter)->GetSpellProto()->Dispel==0) + { + found = true; + break; + } + } + + if(found) + m_caster->SpellNonMeleeDamageLog(unitTarget, m_spellInfo->Id, damage, m_IsTriggeredSpell, true); + return; + } + // Kill command + if(m_spellInfo->SpellFamilyFlags & 0x00080000000000LL) + { + if(m_caster->getClass()!=CLASS_HUNTER) + return; + + // clear hunter crit aura state + m_caster->ModifyAuraState(AURA_STATE_HUNTER_CRIT_STRIKE,false); + + // additional damage from pet to pet target + Pet* pet = m_caster->GetPet(); + if(!pet || !pet->getVictim()) + return; + + uint32 spell_id = 0; + switch (m_spellInfo->Id) + { + case 34026: spell_id = 34027; break; // rank 1 + default: + sLog.outError("Spell::EffectDummy: Spell %u not handled in KC",m_spellInfo->Id); + return; + } + + pet->CastSpell(pet->getVictim(), spell_id, true); + return; + } + + switch(m_spellInfo->Id) + { + case 23989: //Readiness talent + { + if(m_caster->GetTypeId()!=TYPEID_PLAYER) + return; + + //immediately finishes the cooldown for hunter abilities + const PlayerSpellMap& sp_list = ((Player *)m_caster)->GetSpellMap(); + for (PlayerSpellMap::const_iterator itr = sp_list.begin(); itr != sp_list.end(); ++itr) + { + uint32 classspell = itr->first; + SpellEntry const *spellInfo = sSpellStore.LookupEntry(classspell); + + if (spellInfo->SpellFamilyName == SPELLFAMILY_HUNTER && spellInfo->Id != 23989 && GetSpellRecoveryTime(spellInfo) > 0 ) + { + ((Player*)m_caster)->RemoveSpellCooldown(classspell); + + WorldPacket data(SMSG_CLEAR_COOLDOWN, (4+8)); + data << uint32(classspell); + data << uint64(m_caster->GetGUID()); + ((Player*)m_caster)->GetSession()->SendPacket(&data); + } + } + return; + } + case 37506: // Scatter Shot + { + if (m_caster->GetTypeId()!=TYPEID_PLAYER) + return; + + // break Auto Shot and autohit + m_caster->InterruptSpell(CURRENT_AUTOREPEAT_SPELL); + m_caster->AttackStop(); + ((Player*)m_caster)->SendAttackSwingCancelAttack(); + return; + } + } + break; + case SPELLFAMILY_PALADIN: + switch(m_spellInfo->SpellIconID) + { + case 156: // Holy Shock + { + if(!unitTarget) + return; + + int hurt = 0; + int heal = 0; + + switch(m_spellInfo->Id) + { + case 20473: hurt = 25912; heal = 25914; break; + case 20929: hurt = 25911; heal = 25913; break; + case 20930: hurt = 25902; heal = 25903; break; + case 27174: hurt = 27176; heal = 27175; break; + case 33072: hurt = 33073; heal = 33074; break; + default: + sLog.outError("Spell::EffectDummy: Spell %u not handled in HS",m_spellInfo->Id); + return; + } + + if(m_caster->IsFriendlyTo(unitTarget)) + m_caster->CastSpell(unitTarget, heal, true, 0); + else + m_caster->CastSpell(unitTarget, hurt, true, 0); + + return; + } + case 561: // Judgement of command + { + if(!unitTarget) + return; + + uint32 spell_id = m_currentBasePoints[i]+1; + SpellEntry const* spell_proto = sSpellStore.LookupEntry(spell_id); + if(!spell_proto) + return; + + if( !unitTarget->hasUnitState(UNIT_STAT_STUNDED) && m_caster->GetTypeId()==TYPEID_PLAYER) + { + // decreased damage (/2) for non-stunned target. + SpellModifier *mod = new SpellModifier; + mod->op = SPELLMOD_DAMAGE; + mod->value = -50; + mod->type = SPELLMOD_PCT; + mod->spellId = m_spellInfo->Id; + mod->effectId = i; + mod->lastAffected = NULL; + mod->mask = 0x0000020000000000LL; + mod->charges = 0; + + ((Player*)m_caster)->AddSpellMod(mod, true); + m_caster->CastSpell(unitTarget,spell_proto,true,NULL); + // mod deleted + ((Player*)m_caster)->AddSpellMod(mod, false); + } + else + m_caster->CastSpell(unitTarget,spell_proto,true,NULL); + + return; + } + } + + switch(m_spellInfo->Id) + { + case 31789: // Righteous Defense (step 1) + { + // 31989 -> dummy effect (step 1) + dummy effect (step 2) -> 31709 (taunt like spell for each target) + + // non-standard cast requirement check + if (!unitTarget || unitTarget->getAttackers().empty()) + { + // clear cooldown at fail + if(m_caster->GetTypeId()==TYPEID_PLAYER) + { + ((Player*)m_caster)->RemoveSpellCooldown(m_spellInfo->Id); + + WorldPacket data(SMSG_CLEAR_COOLDOWN, (4+8)); + data << uint32(m_spellInfo->Id); + data << uint64(m_caster->GetGUID()); + ((Player*)m_caster)->GetSession()->SendPacket(&data); + } + + SendCastResult(SPELL_FAILED_TARGET_AFFECTING_COMBAT); + return; + } + + // Righteous Defense (step 2) (in old version 31980 dummy effect) + // Clear targets for eff 1 + for(std::list::iterator ihit= m_UniqueTargetInfo.begin();ihit != m_UniqueTargetInfo.end();++ihit) + ihit->effectMask &= ~(1<<1); + + // not empty (checked) + Unit::AttackerSet const& attackers = unitTarget->getAttackers(); + + // chance to be selected from list + float chance = 100.0f/attackers.size(); + uint32 count=0; + for(Unit::AttackerSet::const_iterator aItr = attackers.begin(); aItr != attackers.end() && count < 3; ++aItr) + { + if(!roll_chance_f(chance)) + continue; + ++count; + AddUnitTarget((*aItr), 1); + } + + // now let next effect cast spell at each target. + return; + } + case 37877: // Blessing of Faith + { + if(!unitTarget) + return; + + uint32 spell_id = 0; + switch(unitTarget->getClass()) + { + case CLASS_DRUID: spell_id = 37878; break; + case CLASS_PALADIN: spell_id = 37879; break; + case CLASS_PRIEST: spell_id = 37880; break; + case CLASS_SHAMAN: spell_id = 37881; break; + default: return; // ignore for not healing classes + } + + m_caster->CastSpell(m_caster,spell_id,true); + return; + } + } + break; + case SPELLFAMILY_SHAMAN: + //Shaman Rockbiter Weapon + if (m_spellInfo->SpellFamilyFlags == 0x400000) + { + uint32 spell_id = 0; + switch(m_spellInfo->Id) + { + case 8017: spell_id = 36494; break; // Rank 1 + case 8018: spell_id = 36750; break; // Rank 2 + case 8019: spell_id = 36755; break; // Rank 3 + case 10399: spell_id = 36759; break; // Rank 4 + case 16314: spell_id = 36763; break; // Rank 5 + case 16315: spell_id = 36766; break; // Rank 6 + case 16316: spell_id = 36771; break; // Rank 7 + case 25479: spell_id = 36775; break; // Rank 8 + case 25485: spell_id = 36499; break; // Rank 9 + default: + sLog.outError("Spell::EffectDummy: Spell %u not handled in RW",m_spellInfo->Id); + return; + } + + SpellEntry const *spellInfo = sSpellStore.LookupEntry( spell_id ); + + if(!spellInfo) + { + sLog.outError("WORLD: unknown spell id %i\n", spell_id); + return; + } + + if(m_caster->GetTypeId() != TYPEID_PLAYER) + return; + + for(int i = BASE_ATTACK; i <= OFF_ATTACK; ++i) + { + if(Item* item = ((Player*)m_caster)->GetWeaponForAttack(WeaponAttackType(i))) + { + if(item->IsFitToSpellRequirements(m_spellInfo)) + { + Spell *spell = new Spell(m_caster, spellInfo, true); + + // enchanting spell selected by calculated damage-per-sec in enchanting effect + // at calculation applied affect from Elemental Weapons talent + // real enchantment damage-1 + spell->m_currentBasePoints[1] = damage-1; + + SpellCastTargets targets; + targets.setItemTarget( item ); + spell->prepare(&targets); + } + } + } + return; + } + + if(m_spellInfo->Id == 39610) // Mana-Tide Totem effect + { + if(!unitTarget || unitTarget->getPowerType() != POWER_MANA) + return; + + // Regenerate 6% of Total Mana Every 3 secs + int32 EffectBasePoints0 = unitTarget->GetMaxPower(POWER_MANA) * damage / 100; + m_caster->CastCustomSpell(unitTarget,39609,&EffectBasePoints0,NULL,NULL,true,NULL,NULL,m_originalCasterGUID); + return; + } + + break; + } + + // pet auras + if(PetAura const* petSpell = spellmgr.GetPetAura(m_spellInfo->Id)) + { + m_caster->AddPetAura(petSpell); + return; + } +} + +void Spell::EffectTriggerSpellWithValue(uint32 i) +{ + uint32 triggered_spell_id = m_spellInfo->EffectTriggerSpell[i]; + + // normal case + SpellEntry const *spellInfo = sSpellStore.LookupEntry( triggered_spell_id ); + + if(!spellInfo) + { + sLog.outError("EffectTriggerSpellWithValue of spell %u: triggering unknown spell id %i\n", m_spellInfo->Id,triggered_spell_id); + return; + } + + int32 bp = damage; + m_caster->CastCustomSpell(unitTarget,triggered_spell_id,&bp,&bp,&bp,true,NULL,NULL,m_originalCasterGUID); +} + +void Spell::EffectTriggerRitualOfSummoning(uint32 i) +{ + uint32 triggered_spell_id = m_spellInfo->EffectTriggerSpell[i]; + SpellEntry const *spellInfo = sSpellStore.LookupEntry( triggered_spell_id ); + + if(!spellInfo) + { + sLog.outError("EffectTriggerRitualOfSummoning of spell %u: triggering unknown spell id %i", m_spellInfo->Id,triggered_spell_id); + return; + } + + finish(); + Spell *spell = new Spell(m_caster, spellInfo, true); + + SpellCastTargets targets; + targets.setUnitTarget( unitTarget); + spell->prepare(&targets); + + m_caster->SetCurrentCastedSpell(spell); + spell->m_selfContainer = &(m_caster->m_currentSpells[spell->GetCurrentContainer()]); + +} + +void Spell::EffectForceCast(uint32 i) +{ + if( !unitTarget ) + return; + + uint32 triggered_spell_id = m_spellInfo->EffectTriggerSpell[i]; + + // normal case + SpellEntry const *spellInfo = sSpellStore.LookupEntry( triggered_spell_id ); + + if(!spellInfo) + { + sLog.outError("EffectForceCast of spell %u: triggering unknown spell id %i", m_spellInfo->Id,triggered_spell_id); + return; + } + + unitTarget->CastSpell(unitTarget,spellInfo,true,NULL,NULL,m_originalCasterGUID); +} + +void Spell::EffectTriggerSpell(uint32 i) +{ + uint32 triggered_spell_id = m_spellInfo->EffectTriggerSpell[i]; + + // special cases + switch(triggered_spell_id) + { + // Vanish + case 18461: + { + m_caster->RemoveSpellsCausingAura(SPELL_AURA_MOD_ROOT); + m_caster->RemoveSpellsCausingAura(SPELL_AURA_MOD_DECREASE_SPEED); + m_caster->RemoveSpellsCausingAura(SPELL_AURA_MOD_STALKED); + + // if this spell is given to NPC it must handle rest by it's own AI + if ( m_caster->GetTypeId() != TYPEID_PLAYER ) + return; + + // get highest rank of the Stealth spell + uint32 spellId = 0; + const PlayerSpellMap& sp_list = ((Player*)m_caster)->GetSpellMap(); + for (PlayerSpellMap::const_iterator itr = sp_list.begin(); itr != sp_list.end(); ++itr) + { + // only highest rank is shown in spell book, so simply check if shown in spell book + if(!itr->second->active || itr->second->disabled || itr->second->state == PLAYERSPELL_REMOVED) + continue; + + SpellEntry const *spellInfo = sSpellStore.LookupEntry(itr->first); + if (!spellInfo) + continue; + + if (spellInfo->SpellFamilyName == SPELLFAMILY_ROGUE && spellInfo->SpellFamilyFlags & SPELLFAMILYFLAG_ROGUE_STEALTH) + { + spellId = spellInfo->Id; + break; + } + } + + // no Stealth spell found + if (!spellId) + return; + + // reset cooldown on it if needed + if(((Player*)m_caster)->HasSpellCooldown(spellId)) + ((Player*)m_caster)->RemoveSpellCooldown(spellId); + + m_caster->CastSpell(m_caster, spellId, true); + return; + } + // just skip + case 23770: // Sayge's Dark Fortune of * + // not exist, common cooldown can be implemented in scripts if need. + return; + // Brittle Armor - (need add max stack of 24575 Brittle Armor) + case 29284: + { + const SpellEntry *spell = sSpellStore.LookupEntry(24575); + if (!spell) + return; + + for (int i=0; i < spell->StackAmount; ++i) + m_caster->CastSpell(unitTarget,spell->Id, true, m_CastItem, NULL, m_originalCasterGUID); + return; + } + // Mercurial Shield - (need add max stack of 26464 Mercurial Shield) + case 29286: + { + const SpellEntry *spell = sSpellStore.LookupEntry(26464); + if (!spell) + return; + + for (int i=0; i < spell->StackAmount; ++i) + m_caster->CastSpell(unitTarget,spell->Id, true, m_CastItem, NULL, m_originalCasterGUID); + return; + } + // Righteous Defense + case 31980: + { + m_caster->CastSpell(unitTarget, 31790, true,m_CastItem,NULL,m_originalCasterGUID); + return; + } + // Cloak of Shadows + case 35729 : + { + Unit::AuraMap& Auras = m_caster->GetAuras(); + for(Unit::AuraMap::iterator iter = Auras.begin(); iter != Auras.end(); ++iter) + { + // remove all harmful spells on you... + if( // ignore positive and passive auras + !iter->second->IsPositive() && !iter->second->IsPassive() && + // ignore physical auras + (GetSpellSchoolMask(iter->second->GetSpellProto()) & SPELL_SCHOOL_MASK_NORMAL)==0 && + // ignore immunity persistent spells + !( iter->second->GetSpellProto()->AttributesEx & 0x10000 ) ) + { + m_caster->RemoveAurasDueToSpell(iter->second->GetSpellProto()->Id); + iter = Auras.begin(); + } + } + return; + } + // Priest Shadowfiend (34433) need apply mana gain trigger aura on pet + case 41967: + { + if (Unit *pet = m_caster->GetPet()) + pet->CastSpell(pet, 28305, true); + return; + } + } + + // normal case + SpellEntry const *spellInfo = sSpellStore.LookupEntry( triggered_spell_id ); + + if(!spellInfo) + { + sLog.outError("EffectTriggerSpell of spell %u: triggering unknown spell id %i", m_spellInfo->Id,triggered_spell_id); + return; + } + + // some triggered spells require specific equipment + if(spellInfo->EquippedItemClass >=0 && m_caster->GetTypeId()==TYPEID_PLAYER) + { + // main hand weapon required + if(spellInfo->AttributesEx3 & SPELL_ATTR_EX3_MAIN_HAND) + { + Item* item = ((Player*)m_caster)->GetWeaponForAttack(BASE_ATTACK); + + // skip spell if no weapon in slot or broken + if(!item || item->IsBroken() ) + return; + + // skip spell if weapon not fit to triggered spell + if(!item->IsFitToSpellRequirements(spellInfo)) + return; + } + + // offhand hand weapon required + if(spellInfo->AttributesEx3 & SPELL_ATTR_EX3_REQ_OFFHAND) + { + Item* item = ((Player*)m_caster)->GetWeaponForAttack(OFF_ATTACK); + + // skip spell if no weapon in slot or broken + if(!item || item->IsBroken() ) + return; + + // skip spell if weapon not fit to triggered spell + if(!item->IsFitToSpellRequirements(spellInfo)) + return; + } + } + + // some triggered spells must be casted instantly (for example, if next effect case instant kill caster) + bool instant = false; + for(uint32 j = i+1; j < 3; ++j) + { + if(m_spellInfo->Effect[j]==SPELL_EFFECT_INSTAKILL && m_spellInfo->EffectImplicitTargetA[j]==TARGET_SELF) + { + instant = true; + break; + } + } + + if(instant) + { + if (unitTarget) + m_caster->CastSpell(unitTarget,spellInfo,true,m_CastItem,NULL,m_originalCasterGUID); + } + else + m_TriggerSpells.push_back(spellInfo); +} + +void Spell::EffectTriggerMissileSpell(uint32 effect_idx) +{ + uint32 triggered_spell_id = m_spellInfo->EffectTriggerSpell[effect_idx]; + + // normal case + SpellEntry const *spellInfo = sSpellStore.LookupEntry( triggered_spell_id ); + + if(!spellInfo) + { + sLog.outError("EffectTriggerMissileSpell of spell %u: triggering unknown spell id %effect_idx", m_spellInfo->Id,triggered_spell_id); + return; + } + + if (m_CastItem) + DEBUG_LOG("WORLD: cast Item spellId - %i", spellInfo->Id); + + Spell *spell = new Spell(m_caster, spellInfo, true, m_originalCasterGUID ); + + SpellCastTargets targets; + targets.setDestination(m_targets.m_destX,m_targets.m_destY,m_targets.m_destZ); + spell->m_CastItem = m_CastItem; + spell->prepare(&targets, NULL); +} + +void Spell::EffectTeleportUnits(uint32 i) +{ + if(!unitTarget || unitTarget->isInFlight()) + return; + + switch (m_spellInfo->EffectImplicitTargetB[i]) + { + case TARGET_INNKEEPER_COORDINATES: + { + // Only players can teleport to innkeeper + if (unitTarget->GetTypeId() != TYPEID_PLAYER) + return; + + ((Player*)unitTarget)->TeleportTo(((Player*)unitTarget)->m_homebindMapId,((Player*)unitTarget)->m_homebindX,((Player*)unitTarget)->m_homebindY,((Player*)unitTarget)->m_homebindZ,unitTarget->GetOrientation(),unitTarget==m_caster ? TELE_TO_SPELL : 0); + return; + } + case TARGET_TABLE_X_Y_Z_COORDINATES: + { + // TODO: Only players can teleport? + if (unitTarget->GetTypeId() != TYPEID_PLAYER) + return; + SpellTargetPosition const* st = spellmgr.GetSpellTargetPosition(m_spellInfo->Id); + if(!st) + { + sLog.outError( "Spell::EffectTeleportUnits - unknown Teleport coordinates for spell ID %u\n", m_spellInfo->Id ); + return; + } + ((Player*)unitTarget)->TeleportTo(st->target_mapId,st->target_X,st->target_Y,st->target_Z,st->target_Orientation,unitTarget==m_caster ? TELE_TO_SPELL : 0); + break; + } + case TARGET_BEHIND_VICTIM: + { + // Get selected target for player (or victim for units) + Unit *pTarget = NULL; + if(m_caster->GetTypeId() == TYPEID_PLAYER) + pTarget = ObjectAccessor::GetUnit(*m_caster, ((Player*)m_caster)->GetSelection()); + else + pTarget = m_caster->getVictim(); + // No target present - return + if (!pTarget) + return; + // Init dest coordinates + uint32 mapid = m_caster->GetMapId(); + float x = m_targets.m_destX; + float y = m_targets.m_destY; + float z = m_targets.m_destZ; + float orientation = pTarget->GetOrientation(); + // Teleport + if(unitTarget->GetTypeId() == TYPEID_PLAYER) + ((Player*)unitTarget)->TeleportTo(mapid, x, y, z, orientation, TELE_TO_NOT_LEAVE_COMBAT | TELE_TO_NOT_UNSUMMON_PET | (unitTarget==m_caster ? TELE_TO_SPELL : 0)); + else + { + MapManager::Instance().GetMap(mapid, m_caster)->CreatureRelocation((Creature*)unitTarget, x, y, z, orientation); + WorldPacket data; + unitTarget->BuildTeleportAckMsg(&data, x, y, z, orientation); + unitTarget->SendMessageToSet(&data, false); + } + return; + } + default: + { + // If not exist data for dest location - return + if(!(m_targets.m_targetMask & TARGET_FLAG_DEST_LOCATION)) + { + sLog.outError( "Spell::EffectTeleportUnits - unknown EffectImplicitTargetB[%u] = %u for spell ID %u\n", i, m_spellInfo->EffectImplicitTargetB[i], m_spellInfo->Id ); + return; + } + // Init dest coordinates + uint32 mapid = m_caster->GetMapId(); + float x = m_targets.m_destX; + float y = m_targets.m_destY; + float z = m_targets.m_destZ; + float orientation = unitTarget->GetOrientation(); + // Teleport + if(unitTarget->GetTypeId() == TYPEID_PLAYER) + ((Player*)unitTarget)->TeleportTo(mapid, x, y, z, orientation, TELE_TO_NOT_LEAVE_COMBAT | TELE_TO_NOT_UNSUMMON_PET | (unitTarget==m_caster ? TELE_TO_SPELL : 0)); + else + { + MapManager::Instance().GetMap(mapid, m_caster)->CreatureRelocation((Creature*)unitTarget, x, y, z, orientation); + WorldPacket data; + unitTarget->BuildTeleportAckMsg(&data, x, y, z, orientation); + unitTarget->SendMessageToSet(&data, false); + } + return; + } + } + + // post effects for TARGET_TABLE_X_Y_Z_COORDINATES + switch ( m_spellInfo->Id ) + { + // Dimensional Ripper - Everlook + case 23442: + { + int32 r = irand(0, 119); + if ( r >= 70 ) // 7/12 success + { + if ( r < 100 ) // 4/12 evil twin + m_caster->CastSpell(m_caster,23445,true); + else // 1/12 fire + m_caster->CastSpell(m_caster,23449,true); + } + return; + } + // Ultrasafe Transporter: Toshley's Station + case 36941: + { + if ( roll_chance_i(50) ) // 50% success + { + int32 rand_eff = urand(1,7); + switch ( rand_eff ) + { + case 1: + // soul split - evil + m_caster->CastSpell(m_caster,36900,true); + break; + case 2: + // soul split - good + m_caster->CastSpell(m_caster,36901,true); + break; + case 3: + // Increase the size + m_caster->CastSpell(m_caster,36895,true); + break; + case 4: + // Decrease the size + m_caster->CastSpell(m_caster,36893,true); + break; + case 5: + // Transform + { + if (((Player*)m_caster)->GetTeam() == ALLIANCE ) + m_caster->CastSpell(m_caster,36897,true); + else + m_caster->CastSpell(m_caster,36899,true); + break; + } + case 6: + // chicken + m_caster->CastSpell(m_caster,36940,true); + break; + case 7: + // evil twin + m_caster->CastSpell(m_caster,23445,true); + break; + } + } + return; + } + // Dimensional Ripper - Area 52 + case 36890: + { + if ( roll_chance_i(50) ) // 50% success + { + int32 rand_eff = urand(1,4); + switch ( rand_eff ) + { + case 1: + // soul split - evil + m_caster->CastSpell(m_caster,36900,true); + break; + case 2: + // soul split - good + m_caster->CastSpell(m_caster,36901,true); + break; + case 3: + // Increase the size + m_caster->CastSpell(m_caster,36895,true); + break; + case 4: + // Transform + { + if (((Player*)m_caster)->GetTeam() == ALLIANCE ) + m_caster->CastSpell(m_caster,36897,true); + else + m_caster->CastSpell(m_caster,36899,true); + break; + } + } + } + return; + } + } +} + +void Spell::EffectApplyAura(uint32 i) +{ + if(!unitTarget) + return; + + SpellImmuneList const& list = unitTarget->m_spellImmune[IMMUNITY_STATE]; + for(SpellImmuneList::const_iterator itr = list.begin(); itr != list.end(); ++itr) + if(itr->type == m_spellInfo->EffectApplyAuraName[i]) + return; + + // ghost spell check, allow apply any auras at player loading in ghost mode (will be cleanup after load) + if( !unitTarget->isAlive() && m_spellInfo->Id != 20584 && m_spellInfo->Id != 8326 && + (unitTarget->GetTypeId()!=TYPEID_PLAYER || !((Player*)unitTarget)->GetSession()->PlayerLoading()) ) + return; + + Unit* caster = m_originalCasterGUID ? m_originalCaster : m_caster; + if(!caster) + return; + + sLog.outDebug("Spell: Aura is: %u", m_spellInfo->EffectApplyAuraName[i]); + + Aura* Aur = CreateAura(m_spellInfo, i, &m_currentBasePoints[i], unitTarget, caster, m_CastItem); + + // Now Reduce spell duration using data received at spell hit + int32 duration = Aur->GetAuraMaxDuration(); + unitTarget->ApplyDiminishingToDuration(m_diminishGroup,duration,m_caster,m_diminishLevel); + Aur->setDiminishGroup(m_diminishGroup); + + // if Aura removed and deleted, do not continue. + if(duration== 0 && !(Aur->IsPermanent())) + { + delete Aur; + return; + } + + if(duration != Aur->GetAuraMaxDuration()) + { + Aur->SetAuraMaxDuration(duration); + Aur->SetAuraDuration(duration); + } + + bool added = unitTarget->AddAura(Aur); + + // Aura not added and deleted in AddAura call; + if (!added) + return; + + // found crash at character loading, broken pointer to Aur... + // Aur was deleted in AddAura()... + if(!Aur) + return; + + // TODO Make a way so it works for every related spell! + if(unitTarget->GetTypeId()==TYPEID_PLAYER) // Negative buff should only be applied on players + { + uint32 spellId = 0; + if(m_spellInfo->CasterAuraStateNot==AURA_STATE_WEAKENED_SOUL || m_spellInfo->TargetAuraStateNot==AURA_STATE_WEAKENED_SOUL) + spellId = 6788; // Weakened Soul + else if(m_spellInfo->CasterAuraStateNot==AURA_STATE_FORBEARANCE || m_spellInfo->TargetAuraStateNot==AURA_STATE_FORBEARANCE) + spellId = 25771; // Forbearance + else if(m_spellInfo->CasterAuraStateNot==AURA_STATE_HYPOTHERMIA) + spellId = 41425; // Hypothermia + else if (m_spellInfo->Mechanic == MECHANIC_BANDAGE) // Bandages + spellId = 11196; // Recently Bandaged + else if( (m_spellInfo->AttributesEx & 0x20) && (m_spellInfo->AttributesEx2 & 0x20000) ) + spellId = 23230; // Blood Fury - Healing Reduction + + SpellEntry const *AdditionalSpellInfo = sSpellStore.LookupEntry(spellId); + if (AdditionalSpellInfo) + { + // applied at target by target + Aura* AdditionalAura = CreateAura(AdditionalSpellInfo, 0, &m_currentBasePoints[0], unitTarget,unitTarget, 0); + unitTarget->AddAura(AdditionalAura); + sLog.outDebug("Spell: Additional Aura is: %u", AdditionalSpellInfo->EffectApplyAuraName[0]); + } + } + + // Prayer of Mending (jump animation), we need formal caster instead original for correct animation + if( m_spellInfo->SpellFamilyName == SPELLFAMILY_PRIEST && (m_spellInfo->SpellFamilyFlags & 0x00002000000000LL)) + m_caster->CastSpell(unitTarget,41637,true,NULL,Aur); +} + +void Spell::EffectUnlearnSpecialization( uint32 i ) +{ + if(!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) + return; + + Player *_player = (Player*)unitTarget; + uint32 spellToUnlearn = m_spellInfo->EffectTriggerSpell[i]; + + _player->removeSpell(spellToUnlearn); + + sLog.outDebug( "Spell: Player %u have unlearned spell %u from NpcGUID: %u", _player->GetGUIDLow(), spellToUnlearn, m_caster->GetGUIDLow() ); +} + +void Spell::EffectPowerDrain(uint32 i) +{ + if(m_spellInfo->EffectMiscValue[i] < 0 || m_spellInfo->EffectMiscValue[i] >= MAX_POWERS) + return; + + Powers drain_power = Powers(m_spellInfo->EffectMiscValue[i]); + + if(!unitTarget) + return; + if(!unitTarget->isAlive()) + return; + if(unitTarget->getPowerType() != drain_power) + return; + if(damage < 0) + return; + + uint32 curPower = unitTarget->GetPower(drain_power); + + //add spell damage bonus + damage=m_caster->SpellDamageBonus(unitTarget,m_spellInfo,uint32(damage),SPELL_DIRECT_DAMAGE); + + // resilience reduce mana draining effect at spell crit damage reduction (added in 2.4) + uint32 power = damage; + if ( drain_power == POWER_MANA && unitTarget->GetTypeId() == TYPEID_PLAYER ) + power -= ((Player*)unitTarget)->GetSpellCritDamageReduction(power); + + int32 new_damage; + if(curPower < power) + new_damage = curPower; + else + new_damage = power; + + unitTarget->ModifyPower(drain_power,-new_damage); + + if(drain_power == POWER_MANA) + { + float manaMultiplier = m_spellInfo->EffectMultipleValue[i]; + if(manaMultiplier==0) + manaMultiplier = 1; + + if(Player *modOwner = m_caster->GetSpellModOwner()) + modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_MULTIPLE_VALUE, manaMultiplier); + + int32 gain = int32(new_damage*manaMultiplier); + + m_caster->ModifyPower(POWER_MANA,gain); + //send log + m_caster->SendEnergizeSpellLog(m_caster, m_spellInfo->Id,gain,POWER_MANA,false); + } +} + +void Spell::EffectSendEvent(uint32 EffectIndex) +{ + if (m_caster->GetTypeId() == TYPEID_PLAYER && ((Player*)m_caster)->InBattleGround()) + { + BattleGround* bg = ((Player *)m_caster)->GetBattleGround(); + if(bg && bg->GetStatus() == STATUS_IN_PROGRESS) + { + switch(m_spellInfo->Id) + { + case 23333: // Pickup Horde Flag + /*do not uncomment . + if(bg->GetTypeID()==BATTLEGROUND_WS) + bg->EventPlayerClickedOnFlag((Player*)m_caster, this->gameObjTarget); + sLog.outDebug("Send Event Horde Flag Picked Up"); + break; + /* not used : + case 23334: // Drop Horde Flag + if(bg->GetTypeID()==BATTLEGROUND_WS) + bg->EventPlayerDroppedFlag((Player*)m_caster); + sLog.outDebug("Drop Horde Flag"); + break; + */ + case 23335: // Pickup Alliance Flag + /*do not uncomment ... (it will cause crash, because of null targetobject!) anyway this is a bad way to call that event, because it would cause recursion + if(bg->GetTypeID()==BATTLEGROUND_WS) + bg->EventPlayerClickedOnFlag((Player*)m_caster, this->gameObjTarget); + sLog.outDebug("Send Event Alliance Flag Picked Up"); + break; + /* not used : + case 23336: // Drop Alliance Flag + if(bg->GetTypeID()==BATTLEGROUND_WS) + bg->EventPlayerDroppedFlag((Player*)m_caster); + sLog.outDebug("Drop Alliance Flag"); + break; + case 23385: // Alliance Flag Returns + if(bg->GetTypeID()==BATTLEGROUND_WS) + bg->EventPlayerClickedOnFlag((Player*)m_caster, this->gameObjTarget); + sLog.outDebug("Alliance Flag Returned"); + break; + case 23386: // Horde Flag Returns + if(bg->GetTypeID()==BATTLEGROUND_WS) + bg->EventPlayerClickedOnFlag((Player*)m_caster, this->gameObjTarget); + sLog.outDebug("Horde Flag Returned"); + break;*/ + case 34976: + /* + if(bg->GetTypeID()==BATTLEGROUND_EY) + bg->EventPlayerClickedOnFlag((Player*)m_caster, this->gameObjTarget); + */ + break; + default: + sLog.outDebug("Unknown spellid %u in BG event", m_spellInfo->Id); + break; + } + } + } + sLog.outDebug("Spell ScriptStart %u for spellid %u in EffectSendEvent ", m_spellInfo->EffectMiscValue[EffectIndex], m_spellInfo->Id); + sWorld.ScriptsStart(sEventScripts, m_spellInfo->EffectMiscValue[EffectIndex], m_caster, focusObject); +} + +void Spell::EffectPowerBurn(uint32 i) +{ + if(m_spellInfo->EffectMiscValue[i] < 0 || m_spellInfo->EffectMiscValue[i] >= MAX_POWERS) + return; + + Powers powertype = Powers(m_spellInfo->EffectMiscValue[i]); + + if(!unitTarget) + return; + if(!unitTarget->isAlive()) + return; + if(unitTarget->getPowerType()!=powertype) + return; + if(damage < 0) + return; + + int32 curPower = int32(unitTarget->GetPower(powertype)); + + // resilience reduce mana draining effect at spell crit damage reduction (added in 2.4) + uint32 power = damage; + if ( powertype == POWER_MANA && unitTarget->GetTypeId() == TYPEID_PLAYER ) + power -= ((Player*)unitTarget)->GetSpellCritDamageReduction(power); + + int32 new_damage = (curPower < power) ? curPower : power; + + unitTarget->ModifyPower(powertype,-new_damage); + float multiplier = m_spellInfo->EffectMultipleValue[i]; + + if(Player *modOwner = m_caster->GetSpellModOwner()) + modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_MULTIPLE_VALUE, multiplier); + + new_damage = int32(new_damage*multiplier); + m_caster->SpellNonMeleeDamageLog(unitTarget, m_spellInfo->Id, new_damage, m_IsTriggeredSpell, true); +} + +void Spell::EffectHeal( uint32 /*i*/ ) +{ + if( unitTarget && unitTarget->isAlive() && damage >= 0) + { + // Try to get original caster + Unit *caster = m_originalCasterGUID ? m_originalCaster : m_caster; + + // Skip if m_originalCaster not available + if (!caster) + return; + + int32 addhealth = damage; + + // Vessel of the Naaru (Vial of the Sunwell trinket) + if (m_spellInfo->Id == 45064) + { + // Amount of heal - depends from stacked Holy Energy + int damageAmount = 0; + Unit::AuraList const& mDummyAuras = m_caster->GetAurasByType(SPELL_AURA_DUMMY); + for(Unit::AuraList::const_iterator i = mDummyAuras.begin();i != mDummyAuras.end(); ++i) + if((*i)->GetId() == 45062) + damageAmount+=(*i)->GetModifier()->m_amount; + if (damageAmount) + m_caster->RemoveAurasDueToSpell(45062); + + addhealth += damageAmount; + } + // Swiftmend - consumes Regrowth or Rejuvenation + else if (m_spellInfo->TargetAuraState == AURA_STATE_SWIFTMEND && unitTarget->HasAuraState(AURA_STATE_SWIFTMEND)) + { + Unit::AuraList const& RejorRegr = unitTarget->GetAurasByType(SPELL_AURA_PERIODIC_HEAL); + // find most short by duration + Aura *targetAura = NULL; + for(Unit::AuraList::const_iterator i = RejorRegr.begin(); i != RejorRegr.end(); ++i) + { + if((*i)->GetSpellProto()->SpellFamilyName == SPELLFAMILY_DRUID + && ((*i)->GetSpellProto()->SpellFamilyFlags == 0x40 || (*i)->GetSpellProto()->SpellFamilyFlags == 0x10) ) + { + if(!targetAura || (*i)->GetAuraDuration() < targetAura->GetAuraDuration()) + targetAura = *i; + } + } + + if(!targetAura) + { + sLog.outError("Target(GUID:" I64FMTD ") has aurastate AURA_STATE_SWIFTMEND but no matching aura.", unitTarget->GetGUID()); + return; + } + int idx = 0; + while(idx < 3) + { + if(targetAura->GetSpellProto()->EffectApplyAuraName[idx] == SPELL_AURA_PERIODIC_HEAL) + break; + idx++; + } + + int32 tickheal = caster->SpellHealingBonus(targetAura->GetSpellProto(), targetAura->GetModifier()->m_amount, DOT, unitTarget); + int32 tickcount = GetSpellDuration(targetAura->GetSpellProto()) / targetAura->GetSpellProto()->EffectAmplitude[idx]; + unitTarget->RemoveAurasDueToSpell(targetAura->GetId()); + + addhealth += tickheal * tickcount; + } + else + addhealth = caster->SpellHealingBonus(m_spellInfo, addhealth,HEAL, unitTarget); + + bool crit = caster->isSpellCrit(unitTarget, m_spellInfo, m_spellSchoolMask, m_attackType); + if (crit) + addhealth = caster->SpellCriticalBonus(m_spellInfo, addhealth, unitTarget); + caster->SendHealSpellLog(unitTarget, m_spellInfo->Id, addhealth, crit); + + int32 gain = unitTarget->ModifyHealth( int32(addhealth) ); + unitTarget->getHostilRefManager().threatAssist(m_caster, float(gain) * 0.5f, m_spellInfo); + + if(caster->GetTypeId()==TYPEID_PLAYER) + if(BattleGround *bg = ((Player*)caster)->GetBattleGround()) + bg->UpdatePlayerScore(((Player*)caster), SCORE_HEALING_DONE, gain); + + // ignore item heals + if(m_CastItem) + return; + + uint32 procHealer = PROC_FLAG_HEAL; + if (crit) + procHealer |= PROC_FLAG_CRIT_HEAL; + + m_caster->ProcDamageAndSpell(unitTarget,procHealer,PROC_FLAG_HEALED,addhealth,SPELL_SCHOOL_MASK_NONE,m_spellInfo,m_IsTriggeredSpell); + } +} + +void Spell::EffectHealPct( uint32 /*i*/ ) +{ + if( unitTarget && unitTarget->isAlive() && damage >= 0) + { + // Try to get original caster + Unit *caster = m_originalCasterGUID ? m_originalCaster : m_caster; + + // Skip if m_originalCaster not available + if (!caster) + return; + + uint32 addhealth = unitTarget->GetMaxHealth() * damage / 100; + caster->SendHealSpellLog(unitTarget, m_spellInfo->Id, addhealth, false); + + int32 gain = unitTarget->ModifyHealth( int32(addhealth) ); + unitTarget->getHostilRefManager().threatAssist(m_caster, float(gain) * 0.5f, m_spellInfo); + + if(caster->GetTypeId()==TYPEID_PLAYER) + if(BattleGround *bg = ((Player*)caster)->GetBattleGround()) + bg->UpdatePlayerScore(((Player*)caster), SCORE_HEALING_DONE, gain); + } +} + +void Spell::EffectHealMechanical( uint32 /*i*/ ) +{ + // Mechanic creature type should be correctly checked by targetCreatureType field + if( unitTarget && unitTarget->isAlive() && damage >= 0) + { + // Try to get original caster + Unit *caster = m_originalCasterGUID ? m_originalCaster : m_caster; + + // Skip if m_originalCaster not available + if (!caster) + return; + + uint32 addhealth = caster->SpellHealingBonus(m_spellInfo, uint32(damage), HEAL, unitTarget); + caster->SendHealSpellLog(unitTarget, m_spellInfo->Id, addhealth, false); + unitTarget->ModifyHealth( int32(damage) ); + } +} + +void Spell::EffectHealthLeech(uint32 i) +{ + if(!unitTarget) + return; + if(!unitTarget->isAlive()) + return; + + if(damage < 0) + return; + + sLog.outDebug("HealthLeech :%i", damage); + + float multiplier = m_spellInfo->EffectMultipleValue[i]; + + if(Player *modOwner = m_caster->GetSpellModOwner()) + modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_MULTIPLE_VALUE, multiplier); + + int32 new_damage = int32(damage*multiplier); + uint32 curHealth = unitTarget->GetHealth(); + new_damage = m_caster->SpellNonMeleeDamageLog(unitTarget, m_spellInfo->Id, new_damage, m_IsTriggeredSpell, true); + if(curHealth < new_damage) + new_damage = curHealth; + + if(m_caster->isAlive()) + { + new_damage = m_caster->SpellHealingBonus(m_spellInfo, new_damage, HEAL, m_caster); + + m_caster->ModifyHealth(new_damage); + + if(m_caster->GetTypeId() == TYPEID_PLAYER) + m_caster->SendHealSpellLog(m_caster, m_spellInfo->Id, uint32(new_damage)); + } +} + +void Spell::DoCreateItem(uint32 i, uint32 itemtype) +{ + if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) + return; + + Player* player = (Player*)unitTarget; + + uint32 newitemid = itemtype; + ItemPrototype const *pProto = objmgr.GetItemPrototype( newitemid ); + if(!pProto) + { + player->SendEquipError( EQUIP_ERR_ITEM_NOT_FOUND, NULL, NULL ); + return; + } + + uint32 num_to_add; + + // TODO: maybe all this can be replaced by using correct calculated `damage` value + if(pProto->Class != ITEM_CLASS_CONSUMABLE || m_spellInfo->SpellFamilyName != SPELLFAMILY_MAGE) + { + int32 basePoints = m_currentBasePoints[i]; + int32 randomPoints = m_spellInfo->EffectDieSides[i]; + if (randomPoints) + num_to_add = basePoints + irand(1, randomPoints); + else + num_to_add = basePoints + 1; + } + else if (pProto->MaxCount == 1) + num_to_add = 1; + else if(player->getLevel() >= m_spellInfo->spellLevel) + { + int32 basePoints = m_currentBasePoints[i]; + float pointPerLevel = m_spellInfo->EffectRealPointsPerLevel[i]; + num_to_add = basePoints + 1 + uint32((player->getLevel() - m_spellInfo->spellLevel)*pointPerLevel); + } + else + num_to_add = 2; + + if (num_to_add < 1) + num_to_add = 1; + if (num_to_add > pProto->Stackable) + num_to_add = pProto->Stackable; + + // init items_count to 1, since 1 item will be created regardless of specialization + int items_count=1; + // the chance to create additional items + float additionalCreateChance=0.0f; + // the maximum number of created additional items + uint8 additionalMaxNum=0; + // get the chance and maximum number for creating extra items + if ( canCreateExtraItems(player, m_spellInfo->Id, additionalCreateChance, additionalMaxNum) ) + { + // roll with this chance till we roll not to create or we create the max num + while ( roll_chance_f(additionalCreateChance) && items_count<=additionalMaxNum ) + ++items_count; + } + + // really will be created more items + num_to_add *= items_count; + + // can the player store the new item? + ItemPosCountVec dest; + uint32 no_space = 0; + uint8 msg = player->CanStoreNewItem( NULL_BAG, NULL_SLOT, dest, newitemid, num_to_add, &no_space ); + if( msg != EQUIP_ERR_OK ) + { + // convert to possible store amount + if( msg == EQUIP_ERR_INVENTORY_FULL || msg == EQUIP_ERR_CANT_CARRY_MORE_OF_THIS ) + num_to_add -= no_space; + else + { + // if not created by another reason from full inventory or unique items amount limitation + player->SendEquipError( msg, NULL, NULL ); + return; + } + } + + if(num_to_add) + { + // create the new item and store it + Item* pItem = player->StoreNewItem( dest, newitemid, true, Item::GenerateItemRandomPropertyId(newitemid)); + + // was it successful? return error if not + if(!pItem) + { + player->SendEquipError( EQUIP_ERR_ITEM_NOT_FOUND, NULL, NULL ); + return; + } + + // set the "Crafted by ..." property of the item + if( pItem->GetProto()->Class != ITEM_CLASS_CONSUMABLE && pItem->GetProto()->Class != ITEM_CLASS_QUEST) + pItem->SetUInt32Value(ITEM_FIELD_CREATOR,player->GetGUIDLow()); + + // send info to the client + if(pItem) + player->SendNewItem(pItem, num_to_add, true, true); + + // we succeeded in creating at least one item, so a levelup is possible + player->UpdateCraftSkill(m_spellInfo->Id); + } + + // for battleground marks send by mail if not add all expected + if(no_space > 0 ) + { + BattleGroundTypeId bgType; + switch(m_spellInfo->Id) + { + case SPELL_AV_MARK_WINNER: + case SPELL_AV_MARK_LOSER: + bgType = BATTLEGROUND_AV; + break; + case SPELL_WS_MARK_WINNER: + case SPELL_WS_MARK_LOSER: + bgType = BATTLEGROUND_WS; + break; + case SPELL_AB_MARK_WINNER: + case SPELL_AB_MARK_LOSER: + bgType = BATTLEGROUND_AB; + break; + default: + return; + } + + if(BattleGround* bg = sBattleGroundMgr.GetBattleGround(bgType)) + bg->SendRewardMarkByMail(player,newitemid,no_space); + } +} + +void Spell::EffectCreateItem(uint32 i) +{ + DoCreateItem(i,m_spellInfo->EffectItemType[i]); +} + +void Spell::EffectPersistentAA(uint32 i) +{ + float radius = GetSpellRadius(sSpellRadiusStore.LookupEntry(m_spellInfo->EffectRadiusIndex[i])); + + if(Player* modOwner = m_caster->GetSpellModOwner()) + modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_RADIUS, radius); + + int32 duration = GetSpellDuration(m_spellInfo); + DynamicObject* dynObj = new DynamicObject; + if(!dynObj->Create(objmgr.GenerateLowGuid(HIGHGUID_DYNAMICOBJECT), m_caster, m_spellInfo->Id, i, m_targets.m_destX, m_targets.m_destY, m_targets.m_destZ, duration, radius)) + { + delete dynObj; + return; + } + dynObj->SetUInt32Value(OBJECT_FIELD_TYPE, 65); + dynObj->SetUInt32Value(GAMEOBJECT_DISPLAYID, 368003); + dynObj->SetUInt32Value(DYNAMICOBJECT_BYTES, 0x01eeeeee); + m_caster->AddDynObject(dynObj); + MapManager::Instance().GetMap(dynObj->GetMapId(), dynObj)->Add(dynObj); +} + +void Spell::EffectEnergize(uint32 i) +{ + if(!unitTarget) + return; + if(!unitTarget->isAlive()) + return; + + if(m_spellInfo->EffectMiscValue[i] < 0 || m_spellInfo->EffectMiscValue[i] >= MAX_POWERS) + return; + + // Some level depends spells + int multipler = 0; + int level_diff = 0; + switch (m_spellInfo->Id) + { + // Restore Energy + case 9512: + level_diff = m_caster->getLevel() - 40; + multipler = 2; + break; + // Blood Fury + case 24571: + level_diff = m_caster->getLevel() - 60; + multipler = 10; + break; + // Burst of Energy + case 24532: + level_diff = m_caster->getLevel() - 60; + multipler = 4; + break; + default: + break; + } + + if (level_diff > 0) + damage -= multipler * level_diff; + + if(damage < 0) + return; + + Powers power = Powers(m_spellInfo->EffectMiscValue[i]); + + if(unitTarget->GetMaxPower(power) == 0) + return; + + unitTarget->ModifyPower(power,damage); + m_caster->SendEnergizeSpellLog(unitTarget, m_spellInfo->Id, damage, power); + + // Mad Alchemist's Potion + if (m_spellInfo->Id == 45051) + { + // find elixirs on target + uint32 elixir_mask = 0; + Unit::AuraMap& Auras = unitTarget->GetAuras(); + for(Unit::AuraMap::iterator itr = Auras.begin(); itr != Auras.end(); ++itr) + { + uint32 spell_id = itr->second->GetId(); + if(uint32 mask = spellmgr.GetSpellElixirMask(spell_id)) + elixir_mask |= mask; + } + + // get available elixir mask any not active type from battle/guardian (and flask if no any) + elixir_mask = (elixir_mask & ELIXIR_FLASK_MASK) ^ ELIXIR_FLASK_MASK; + + // get all available elixirs by mask and spell level + std::vector elixirs; + SpellElixirMap const& m_spellElixirs = spellmgr.GetSpellElixirMap(); + for(SpellElixirMap::const_iterator itr = m_spellElixirs.begin(); itr != m_spellElixirs.end(); ++itr) + { + if (itr->second & elixir_mask) + { + if (itr->second & (ELIXIR_UNSTABLE_MASK | ELIXIR_SHATTRATH_MASK)) + continue; + + SpellEntry const *spellInfo = sSpellStore.LookupEntry(itr->first); + if (spellInfo && (spellInfo->spellLevel < m_spellInfo->spellLevel || spellInfo->spellLevel > unitTarget->getLevel())) + continue; + + elixirs.push_back(itr->first); + } + } + + if (!elixirs.empty()) + { + // cast random elixir on target + uint32 rand_spell = urand(0,elixirs.size()-1); + m_caster->CastSpell(unitTarget,elixirs[rand_spell],true,m_CastItem); + } + } +} + +void Spell::EffectEnergisePct(uint32 i) +{ + if(!unitTarget) + return; + if(!unitTarget->isAlive()) + return; + + if(m_spellInfo->EffectMiscValue[i] < 0 || m_spellInfo->EffectMiscValue[i] >= MAX_POWERS) + return; + + Powers power = Powers(m_spellInfo->EffectMiscValue[i]); + + uint32 maxPower = unitTarget->GetMaxPower(power); + if(maxPower == 0) + return; + + uint32 gain = damage * maxPower / 100; + unitTarget->ModifyPower(power, gain); + m_caster->SendEnergizeSpellLog(unitTarget, m_spellInfo->Id, damage, power); +} + +void Spell::SendLoot(uint64 guid, LootType loottype) +{ + Player* player = (Player*)m_caster; + if (!player) + return; + + if (gameObjTarget) + { + switch (gameObjTarget->GetGoType()) + { + case GAMEOBJECT_TYPE_DOOR: + case GAMEOBJECT_TYPE_BUTTON: + gameObjTarget->UseDoorOrButton(); + sWorld.ScriptsStart(sGameObjectScripts, gameObjTarget->GetDBTableGUIDLow(), player, gameObjTarget); + return; + + case GAMEOBJECT_TYPE_QUESTGIVER: + // start or end quest + player->PrepareQuestMenu(guid); + player->SendPreparedQuest(guid); + return; + + case GAMEOBJECT_TYPE_SPELL_FOCUS: + // triggering linked GO + if(uint32 trapEntry = gameObjTarget->GetGOInfo()->spellFocus.linkedTrapId) + gameObjTarget->TriggeringLinkedGameObject(trapEntry,m_caster); + return; + + case GAMEOBJECT_TYPE_GOOBER: + // goober_scripts can be triggered if the player don't have the quest + if (gameObjTarget->GetGOInfo()->goober.eventId) + { + sLog.outDebug("Goober ScriptStart id %u for GO %u", gameObjTarget->GetGOInfo()->goober.eventId,gameObjTarget->GetDBTableGUIDLow()); + sWorld.ScriptsStart(sEventScripts, gameObjTarget->GetGOInfo()->goober.eventId, player, gameObjTarget); + } + + // cast goober spell + if (gameObjTarget->GetGOInfo()->goober.questId) + ///Quest require to be active for GO using + if(player->GetQuestStatus(gameObjTarget->GetGOInfo()->goober.questId) != QUEST_STATUS_INCOMPLETE) + return; + + gameObjTarget->AddUniqueUse(player); + gameObjTarget->SetLootState(GO_JUST_DEACTIVATED); + + //TODO? Objective counting called without spell check but with quest objective check + // if send spell id then this line will duplicate to spell casting call (double counting) + // So we or have this line and not required in quest_template have reqSpellIdN + // or must remove this line and required in DB have data in quest_template have reqSpellIdN for all quest using cases. + player->CastedCreatureOrGO(gameObjTarget->GetEntry(), gameObjTarget->GetGUID(), 0); + + // triggering linked GO + if(uint32 trapEntry = gameObjTarget->GetGOInfo()->goober.linkedTrapId) + gameObjTarget->TriggeringLinkedGameObject(trapEntry,m_caster); + + return; + + case GAMEOBJECT_TYPE_CHEST: + // TODO: possible must be moved to loot release (in different from linked triggering) + if (gameObjTarget->GetGOInfo()->chest.eventId) + { + sLog.outDebug("Chest ScriptStart id %u for GO %u", gameObjTarget->GetGOInfo()->chest.eventId,gameObjTarget->GetDBTableGUIDLow()); + sWorld.ScriptsStart(sEventScripts, gameObjTarget->GetGOInfo()->chest.eventId, player, gameObjTarget); + } + + // triggering linked GO + if(uint32 trapEntry = gameObjTarget->GetGOInfo()->chest.linkedTrapId) + gameObjTarget->TriggeringLinkedGameObject(trapEntry,m_caster); + + // Don't return, let loots been taken + } + } + + // Send loot + player->SendLoot(guid, loottype); +} + +void Spell::EffectOpenLock(uint32 /*i*/) +{ + if(!m_caster || m_caster->GetTypeId() != TYPEID_PLAYER) + { + sLog.outDebug( "WORLD: Open Lock - No Player Caster!"); + return; + } + + Player* player = (Player*)m_caster; + + LootType loottype = LOOT_CORPSE; + uint32 lockId = 0; + uint64 guid = 0; + + // Get lockId + if(gameObjTarget) + { + GameObjectInfo const* goInfo = gameObjTarget->GetGOInfo(); + // Arathi Basin banner opening ! + if( goInfo->type == GAMEOBJECT_TYPE_BUTTON && goInfo->button.noDamageImmune || + goInfo->type == GAMEOBJECT_TYPE_GOOBER && goInfo->goober.losOK ) + { + if(BattleGround *bg = player->GetBattleGround())// in battleground + { + if( !player->IsMounted() && // not mounted + !player->HasStealthAura() && // not stealthed + !player->HasInvisibilityAura() && // not invisible + player->isAlive() ) // live player + { + // check if it's correct bg + if(bg && bg->GetTypeID() == BATTLEGROUND_AB) + bg->EventPlayerClickedOnFlag(player, gameObjTarget); + + return; + } + } + } + else if (goInfo->type == GAMEOBJECT_TYPE_FLAGSTAND) + { + if(BattleGround *bg = player->GetBattleGround()) + if(bg->GetTypeID() == BATTLEGROUND_EY) + bg->EventPlayerClickedOnFlag(player, gameObjTarget); + return; + } + lockId = gameObjTarget->GetLockId(); + guid = gameObjTarget->GetGUID(); + } + else if(itemTarget) + { + lockId = itemTarget->GetProto()->LockID; + guid = itemTarget->GetGUID(); + } + else + { + sLog.outDebug( "WORLD: Open Lock - No GameObject/Item Target!"); + return; + } + + if(!lockId) // possible case for GO and maybe for items. + { + SendLoot(guid, loottype); + return; + } + + // Get LockInfo + LockEntry const *lockInfo = sLockStore.LookupEntry(lockId); + + if (!lockInfo) + { + sLog.outError( "Spell::EffectOpenLock: %s [guid = %u] has an unknown lockId: %u!", + (gameObjTarget ? "gameobject" : "item"), GUID_LOPART(guid), lockId); + SendCastResult(SPELL_FAILED_BAD_TARGETS); + return; + } + + // check key + for(int i = 0; i < 5; ++i) + { + // type==1 This means lockInfo->key[i] is an item + if(lockInfo->keytype[i]==LOCK_KEY_ITEM && lockInfo->key[i] && m_CastItem && m_CastItem->GetEntry()==lockInfo->key[i]) + { + SendLoot(guid, loottype); + return; + } + } + + uint32 SkillId = 0; + // Check and skill-up skill + if( m_spellInfo->Effect[1] == SPELL_EFFECT_SKILL ) + SkillId = m_spellInfo->EffectMiscValue[1]; + // pickpocketing spells + else if( m_spellInfo->EffectMiscValue[0] == LOCKTYPE_PICKLOCK ) + SkillId = SKILL_LOCKPICKING; + + // skill bonus provided by casting spell (mostly item spells) + uint32 spellSkillBonus = uint32(m_currentBasePoints[0]+1); + + uint32 reqSkillValue = lockInfo->requiredminingskill; + + if(lockInfo->requiredlockskill) // required pick lock skill applying + { + if(SkillId != SKILL_LOCKPICKING) // wrong skill (cheating?) + { + SendCastResult(SPELL_FAILED_FIZZLE); + return; + } + + reqSkillValue = lockInfo->requiredlockskill; + } + else if(SkillId == SKILL_LOCKPICKING) // apply picklock skill to wrong target + { + SendCastResult(SPELL_FAILED_BAD_TARGETS); + return; + } + + if ( SkillId ) + { + loottype = LOOT_SKINNING; + if ( player->GetSkillValue(SkillId) + spellSkillBonus < reqSkillValue ) + { + SendCastResult(SPELL_FAILED_LOW_CASTLEVEL); + return; + } + + // update skill if really known + uint32 SkillValue = player->GetPureSkillValue(SkillId); + if(SkillValue) // non only item base skill + { + if(gameObjTarget) + { + // Allow one skill-up until respawned + if ( !gameObjTarget->IsInSkillupList( player->GetGUIDLow() ) && + player->UpdateGatherSkill(SkillId, SkillValue, reqSkillValue) ) + gameObjTarget->AddToSkillupList( player->GetGUIDLow() ); + } + else if(itemTarget) + { + // Do one skill-up + uint32 SkillValue = player->GetPureSkillValue(SkillId); + player->UpdateGatherSkill(SkillId, SkillValue, reqSkillValue); + } + } + } + + SendLoot(guid, loottype); +} + +void Spell::EffectSummonChangeItem(uint32 i) +{ + if(m_caster->GetTypeId() != TYPEID_PLAYER) + return; + + Player *player = (Player*)m_caster; + + // applied only to using item + if(!m_CastItem) + return; + + // ... only to item in own inventory/bank/equip_slot + if(m_CastItem->GetOwnerGUID()!=player->GetGUID()) + return; + + uint32 newitemid = m_spellInfo->EffectItemType[i]; + if(!newitemid) + return; + + uint16 pos = m_CastItem->GetPos(); + + Item *pNewItem = Item::CreateItem( newitemid, 1, player); + if( !pNewItem ) + return; + + for(uint8 i= PERM_ENCHANTMENT_SLOT; i<=TEMP_ENCHANTMENT_SLOT; ++i) + { + if(m_CastItem->GetEnchantmentId(EnchantmentSlot(i))) + pNewItem->SetEnchantment(EnchantmentSlot(i), m_CastItem->GetEnchantmentId(EnchantmentSlot(i)), m_CastItem->GetEnchantmentDuration(EnchantmentSlot(i)), m_CastItem->GetEnchantmentCharges(EnchantmentSlot(i))); + } + + if(m_CastItem->GetUInt32Value(ITEM_FIELD_DURABILITY) < m_CastItem->GetUInt32Value(ITEM_FIELD_MAXDURABILITY)) + { + double loosePercent = 1 - m_CastItem->GetUInt32Value(ITEM_FIELD_DURABILITY) / double(m_CastItem->GetUInt32Value(ITEM_FIELD_MAXDURABILITY)); + player->DurabilityLoss(pNewItem, loosePercent); + } + + if( player->IsInventoryPos( pos ) ) + { + ItemPosCountVec dest; + uint8 msg = player->CanStoreItem( m_CastItem->GetBagSlot(), m_CastItem->GetSlot(), dest, pNewItem, true ); + if( msg == EQUIP_ERR_OK ) + { + player->DestroyItem(m_CastItem->GetBagSlot(), m_CastItem->GetSlot(),true); + + // prevent crash at access and unexpected charges counting with item update queue corrupt + if(m_CastItem==m_targets.getItemTarget()) + m_targets.setItemTarget(NULL); + + m_CastItem = NULL; + + player->StoreItem( dest, pNewItem, true); + return; + } + } + else if( player->IsBankPos ( pos ) ) + { + ItemPosCountVec dest; + uint8 msg = player->CanBankItem( m_CastItem->GetBagSlot(), m_CastItem->GetSlot(), dest, pNewItem, true ); + if( msg == EQUIP_ERR_OK ) + { + player->DestroyItem(m_CastItem->GetBagSlot(), m_CastItem->GetSlot(),true); + + // prevent crash at access and unexpected charges counting with item update queue corrupt + if(m_CastItem==m_targets.getItemTarget()) + m_targets.setItemTarget(NULL); + + m_CastItem = NULL; + + player->BankItem( dest, pNewItem, true); + return; + } + } + else if( player->IsEquipmentPos ( pos ) ) + { + uint16 dest; + uint8 msg = player->CanEquipItem( m_CastItem->GetSlot(), dest, pNewItem, true ); + if( msg == EQUIP_ERR_OK ) + { + player->DestroyItem(m_CastItem->GetBagSlot(), m_CastItem->GetSlot(),true); + + // prevent crash at access and unexpected charges counting with item update queue corrupt + if(m_CastItem==m_targets.getItemTarget()) + m_targets.setItemTarget(NULL); + + m_CastItem = NULL; + + player->EquipItem( dest, pNewItem, true); + player->AutoUnequipOffhandIfNeed(); + return; + } + } + + // fail + delete pNewItem; +} + +void Spell::EffectOpenSecretSafe(uint32 i) +{ + EffectOpenLock(i); //no difference for now +} + +void Spell::EffectProficiency(uint32 /*i*/) +{ + if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) + return; + Player *p_target = (Player*)unitTarget; + + uint32 subClassMask = m_spellInfo->EquippedItemSubClassMask; + if(m_spellInfo->EquippedItemClass == 2 && !(p_target->GetWeaponProficiency() & subClassMask)) + { + p_target->AddWeaponProficiency(subClassMask); + p_target->SendProficiency(uint8(0x02),p_target->GetWeaponProficiency()); + } + if(m_spellInfo->EquippedItemClass == 4 && !(p_target->GetArmorProficiency() & subClassMask)) + { + p_target->AddArmorProficiency(subClassMask); + p_target->SendProficiency(uint8(0x04),p_target->GetArmorProficiency()); + } +} + +void Spell::EffectApplyAreaAura(uint32 i) +{ + if(!unitTarget) + return; + if(!unitTarget->isAlive()) + return; + + AreaAura* Aur = new AreaAura(m_spellInfo, i, &m_currentBasePoints[i], unitTarget, m_caster, m_CastItem); + unitTarget->AddAura(Aur); +} + +void Spell::EffectSummonType(uint32 i) +{ + switch(m_spellInfo->EffectMiscValueB[i]) + { + case SUMMON_TYPE_GUARDIAN: + case SUMMON_TYPE_POSESSED: + case SUMMON_TYPE_POSESSED2: + EffectSummonGuardian(i); + break; + case SUMMON_TYPE_WILD: + EffectSummonWild(i); + break; + case SUMMON_TYPE_DEMON: + EffectSummonDemon(i); + break; + case SUMMON_TYPE_SUMMON: + EffectSummon(i); + break; + case SUMMON_TYPE_CRITTER: + case SUMMON_TYPE_CRITTER2: + EffectSummonCritter(i); + break; + case SUMMON_TYPE_TOTEM_SLOT1: + case SUMMON_TYPE_TOTEM_SLOT2: + case SUMMON_TYPE_TOTEM_SLOT3: + case SUMMON_TYPE_TOTEM_SLOT4: + case SUMMON_TYPE_TOTEM: + EffectSummonTotem(i); + break; + case SUMMON_TYPE_UNKNOWN1: + case SUMMON_TYPE_UNKNOWN2: + case SUMMON_TYPE_UNKNOWN3: + case SUMMON_TYPE_UNKNOWN4: + case SUMMON_TYPE_UNKNOWN5: + case SUMMON_TYPE_UNKNOWN6: + break; + default: + sLog.outError("EffectSummonType: Unhandled summon type %u", m_spellInfo->EffectMiscValueB[i]); + break; + } +} + +void Spell::EffectSummon(uint32 i) +{ + if(m_caster->GetPetGUID()) + return; + + if(!unitTarget) + return; + uint32 pet_entry = m_spellInfo->EffectMiscValue[i]; + if(!pet_entry) + return; + uint32 level = m_caster->getLevel(); + Pet* spawnCreature = new Pet(SUMMON_PET); + + if(spawnCreature->LoadPetFromDB(m_caster,pet_entry)) + { + // set timer for unsummon + int32 duration = GetSpellDuration(m_spellInfo); + if(duration > 0) + spawnCreature->SetDuration(duration); + + return; + } + + Map *map = m_caster->GetMap(); + uint32 pet_number = objmgr.GeneratePetNumber(); + if(!spawnCreature->Create(objmgr.GenerateLowGuid(HIGHGUID_PET),map,m_spellInfo->EffectMiscValue[i], pet_number)) + { + sLog.outErrorDb("Spell::EffectSummon: no such creature entry %u",m_spellInfo->EffectMiscValue[i]); + delete spawnCreature; + return; + } + + // Summon in dest location + float x,y,z; + if(m_targets.m_targetMask & TARGET_FLAG_DEST_LOCATION) + { + x = m_targets.m_destX; + y = m_targets.m_destY; + z = m_targets.m_destZ; + } + else + m_caster->GetClosePoint(x,y,z,spawnCreature->GetObjectSize()); + + spawnCreature->Relocate(x,y,z,-m_caster->GetOrientation()); + + if(!spawnCreature->IsPositionValid()) + { + sLog.outError("ERROR: Pet (guidlow %d, entry %d) not summoned. Suggested coordinates isn't valid (X: %d Y: ^%d)", spawnCreature->GetGUIDLow(), spawnCreature->GetEntry(), spawnCreature->GetPositionX(), spawnCreature->GetPositionY()); + delete spawnCreature; + return; + } + + // set timer for unsummon + int32 duration = GetSpellDuration(m_spellInfo); + if(duration > 0) + spawnCreature->SetDuration(duration); + + spawnCreature->SetUInt64Value(UNIT_FIELD_SUMMONEDBY,m_caster->GetGUID()); + spawnCreature->SetUInt32Value(UNIT_NPC_FLAGS , 0); + spawnCreature->setPowerType(POWER_MANA); + spawnCreature->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE,m_caster->getFaction()); + spawnCreature->SetUInt32Value(UNIT_FIELD_FLAGS,0); + spawnCreature->SetUInt32Value(UNIT_FIELD_BYTES_0,2048); + spawnCreature->SetUInt32Value(UNIT_FIELD_BYTES_1,0); + spawnCreature->SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP,0); + spawnCreature->SetUInt32Value(UNIT_FIELD_PETEXPERIENCE,0); + spawnCreature->SetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP,1000); + spawnCreature->SetUInt64Value(UNIT_FIELD_CREATEDBY, m_caster->GetGUID()); + spawnCreature->SetUInt32Value(UNIT_CREATED_BY_SPELL, m_spellInfo->Id); + + spawnCreature->InitStatsForLevel(level); + + spawnCreature->GetCharmInfo()->SetPetNumber(pet_number, false); + + spawnCreature->AIM_Initialize(); + spawnCreature->InitPetCreateSpells(); + spawnCreature->SetHealth(spawnCreature->GetMaxHealth()); + spawnCreature->SetPower(POWER_MANA, spawnCreature->GetMaxPower(POWER_MANA)); + + std::string name = m_caster->GetName(); + name.append(petTypeSuffix[spawnCreature->getPetType()]); + spawnCreature->SetName( name ); + + map->Add((Creature*)spawnCreature); + + if(m_caster->GetTypeId() == TYPEID_PLAYER) + { + m_caster->SetPet(spawnCreature); + spawnCreature->GetCharmInfo()->SetReactState( REACT_DEFENSIVE ); + spawnCreature->SavePetToDB(PET_SAVE_AS_CURRENT); + ((Player*)m_caster)->PetSpellInitialize(); + } +} + +void Spell::EffectLearnSpell(uint32 i) +{ + if(!unitTarget) + return; + + if(unitTarget->GetTypeId() != TYPEID_PLAYER) + { + if(m_caster->GetTypeId() == TYPEID_PLAYER) + EffectLearnPetSpell(i); + + return; + } + + Player *player = (Player*)unitTarget; + + uint32 spellToLearn = (m_spellInfo->Id==SPELL_ID_GENERIC_LEARN) ? damage : m_spellInfo->EffectTriggerSpell[i]; + player->learnSpell(spellToLearn); + + sLog.outDebug( "Spell: Player %u have learned spell %u from NpcGUID=%u", player->GetGUIDLow(), spellToLearn, m_caster->GetGUIDLow() ); +} + +void Spell::EffectDispel(uint32 i) +{ + if(!unitTarget) + return; + + // Fill possible dispell list + std::vector dispel_list; + + // Create dispel mask by dispel type + uint32 dispel_type = m_spellInfo->EffectMiscValue[i]; + uint32 dispelMask = GetDispellMask( DispelType(dispel_type) ); + Unit::AuraMap const& auras = unitTarget->GetAuras(); + for(Unit::AuraMap::const_iterator itr = auras.begin(); itr != auras.end(); ++itr) + { + Aura *aur = (*itr).second; + if (aur && (1<GetSpellProto()->Dispel) & dispelMask) + { + if(aur->GetSpellProto()->Dispel == DISPEL_MAGIC) + { + bool positive = true; + if (!aur->IsPositive()) + positive = false; + else + positive = (aur->GetSpellProto()->AttributesEx & SPELL_ATTR_EX_NEGATIVE)==0; + + // do not remove positive auras if friendly target + // negative auras if non-friendly target + if(positive == unitTarget->IsFriendlyTo(m_caster)) + continue; + } + // Add aura to dispel list + dispel_list.push_back(aur); + } + } + // Ok if exist some buffs for dispel try dispel it + if (!dispel_list.empty()) + { + std::list < std::pair > success_list;// (spell_id,casterGuid) + std::list < uint32 > fail_list; // spell_id + int32 list_size = dispel_list.size(); + // Dispell N = damage buffs (or while exist buffs for dispel) + for (int32 count=0; count < damage && list_size > 0; ++count) + { + // Random select buff for dispel + Aura *aur = dispel_list[urand(0, list_size-1)]; + + SpellEntry const* spellInfo = aur->GetSpellProto(); + // Base dispel chance + // TODO: possible chance depend from spell level?? + int32 miss_chance = 0; + // Apply dispel mod from aura caster + if (Unit *caster = aur->GetCaster()) + { + if ( Player* modOwner = caster->GetSpellModOwner() ) + modOwner->ApplySpellMod(spellInfo->Id, SPELLMOD_RESIST_DISPEL_CHANCE, miss_chance, this); + } + // Try dispel + if (roll_chance_i(miss_chance)) + fail_list.push_back(aur->GetId()); + else + success_list.push_back(std::pair(aur->GetId(),aur->GetCasterGUID())); + // Remove buff from list for prevent doubles + for (std::vector::iterator j = dispel_list.begin(); j != dispel_list.end(); ) + { + Aura *dispeled = *j; + if (dispeled->GetId() == aur->GetId() && dispeled->GetCasterGUID() == aur->GetCasterGUID()) + { + j = dispel_list.erase(j); + --list_size; + } + else + ++j; + } + } + // Send success log and really remove auras + if (!success_list.empty()) + { + int32 count = success_list.size(); + WorldPacket data(SMSG_SPELLDISPELLOG, 8+8+4+1+4+count*5); + data.append(unitTarget->GetPackGUID()); // Victim GUID + data.append(m_caster->GetPackGUID()); // Caster GUID + data << uint32(m_spellInfo->Id); // Dispell spell id + data << uint8(0); // not used + data << uint32(count); // count + for (std::list >::iterator j = success_list.begin(); j != success_list.end(); ++j) + { + SpellEntry const* spellInfo = sSpellStore.LookupEntry(j->first); + data << uint32(spellInfo->Id); // Spell Id + data << uint8(0); // 0 - dispeled !=0 cleansed + unitTarget->RemoveAurasDueToSpellByDispel(spellInfo->Id, j->second, m_caster); + } + m_caster->SendMessageToSet(&data, true); + + // On succes dispel + // Devour Magic + if (m_spellInfo->SpellFamilyName == SPELLFAMILY_WARLOCK && m_spellInfo->Category == 12) + { + uint32 heal_spell = 0; + switch (m_spellInfo->Id) + { + case 19505: heal_spell = 19658; break; + case 19731: heal_spell = 19732; break; + case 19734: heal_spell = 19733; break; + case 19736: heal_spell = 19735; break; + case 27276: heal_spell = 27278; break; + case 27277: heal_spell = 27279; break; + default: + sLog.outDebug("Spell for Devour Magic %d not handled in Spell::EffectDispel", m_spellInfo->Id); + break; + } + if (heal_spell) + m_caster->CastSpell(m_caster, heal_spell, true); + } + } + // Send fail log to client + if (!fail_list.empty()) + { + // Failed to dispell + WorldPacket data(SMSG_DISPEL_FAILED, 8+8+4+4*fail_list.size()); + data << uint64(m_caster->GetGUID()); // Caster GUID + data << uint64(unitTarget->GetGUID()); // Victim GUID + data << uint32(m_spellInfo->Id); // Dispell spell id + for (std::list< uint32 >::iterator j = fail_list.begin(); j != fail_list.end(); ++j) + data << uint32(*j); // Spell Id + m_caster->SendMessageToSet(&data, true); + } + } +} + +void Spell::EffectDualWield(uint32 /*i*/) +{ + if (unitTarget->GetTypeId() == TYPEID_PLAYER) + ((Player*)unitTarget)->SetCanDualWield(true); +} + +void Spell::EffectPull(uint32 /*i*/) +{ + // TODO: create a proper pull towards distract spell center for distract + sLog.outDebug("WORLD: Spell Effect DUMMY"); +} + +void Spell::EffectDistract(uint32 /*i*/) +{ + // Check for possible target + if (!unitTarget || unitTarget->isInCombat()) + return; + + // target must be OK to do this + if( unitTarget->hasUnitState(UNIT_STAT_CONFUSED | UNIT_STAT_STUNDED | UNIT_STAT_FLEEING ) ) + return; + + float angle = unitTarget->GetAngle(m_targets.m_destX, m_targets.m_destY); + + if ( unitTarget->GetTypeId() == TYPEID_PLAYER ) + { + // For players just turn them + WorldPacket data; + ((Player*)unitTarget)->BuildTeleportAckMsg(&data, unitTarget->GetPositionX(), unitTarget->GetPositionY(), unitTarget->GetPositionZ(), angle); + ((Player*)unitTarget)->GetSession()->SendPacket( &data ); + ((Player*)unitTarget)->SetPosition(unitTarget->GetPositionX(), unitTarget->GetPositionY(), unitTarget->GetPositionZ(), angle, false); + } + else + { + // Set creature Distracted, Stop it, And turn it + unitTarget->SetOrientation(angle); + unitTarget->StopMoving(); + unitTarget->GetMotionMaster()->MoveDistract(damage*1000); + } +} + +void Spell::EffectPickPocket(uint32 /*i*/) +{ + if( m_caster->GetTypeId() != TYPEID_PLAYER ) + return; + + // victim must be creature and attackable + if( !unitTarget || unitTarget->GetTypeId() != TYPEID_UNIT || m_caster->IsFriendlyTo(unitTarget) ) + return; + + // victim have to be alive and humanoid or undead + if( unitTarget->isAlive() && (unitTarget->GetCreatureTypeMask() &CREATURE_TYPEMASK_HUMANOID_OR_UNDEAD) != 0) + { + int32 chance = 10 + int32(m_caster->getLevel()) - int32(unitTarget->getLevel()); + + if (chance > irand(0, 19)) + { + // Stealing successful + //sLog.outDebug("Sending loot from pickpocket"); + ((Player*)m_caster)->SendLoot(unitTarget->GetGUID(),LOOT_PICKPOCKETING); + } + else + { + // Reveal action + get attack + m_caster->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); + if (((Creature*)unitTarget)->AI()) + ((Creature*)unitTarget)->AI()->AttackStart(m_caster); + } + } +} + +void Spell::EffectAddFarsight(uint32 i) +{ + float radius = GetSpellRadius(sSpellRadiusStore.LookupEntry(m_spellInfo->EffectRadiusIndex[i])); + int32 duration = GetSpellDuration(m_spellInfo); + DynamicObject* dynObj = new DynamicObject; + if(!dynObj->Create(objmgr.GenerateLowGuid(HIGHGUID_DYNAMICOBJECT), m_caster, m_spellInfo->Id, i, m_targets.m_destX, m_targets.m_destY, m_targets.m_destZ, duration, radius)) + { + delete dynObj; + return; + } + dynObj->SetUInt32Value(OBJECT_FIELD_TYPE, 65); + dynObj->SetUInt32Value(DYNAMICOBJECT_BYTES, 0x80000002); + m_caster->AddDynObject(dynObj); + MapManager::Instance().GetMap(dynObj->GetMapId(), dynObj)->Add(dynObj); + m_caster->SetUInt64Value(PLAYER_FARSIGHT, dynObj->GetGUID()); +} + +void Spell::EffectSummonWild(uint32 i) +{ + uint32 creature_entry = m_spellInfo->EffectMiscValue[i]; + if(!creature_entry) + return; + + uint32 level = m_caster->getLevel(); + + // level of creature summoned using engineering item based at engineering skill level + if(m_caster->GetTypeId()==TYPEID_PLAYER && m_CastItem) + { + ItemPrototype const *proto = m_CastItem->GetProto(); + if(proto && proto->RequiredSkill == SKILL_ENGINERING) + { + uint16 skill202 = ((Player*)m_caster)->GetSkillValue(SKILL_ENGINERING); + if(skill202) + { + level = skill202/5; + } + } + } + + // select center of summon position + float center_x = m_targets.m_destX; + float center_y = m_targets.m_destY; + float center_z = m_targets.m_destZ; + + float radius = GetSpellRadius(sSpellRadiusStore.LookupEntry(m_spellInfo->EffectRadiusIndex[i])); + + int32 amount = damage > 0 ? damage : 1; + + for(int32 count = 0; count < amount; ++count) + { + float px, py, pz; + // If dest location if present + if (m_targets.m_targetMask & TARGET_FLAG_DEST_LOCATION) + { + // Summon 1 unit in dest location + if (count == 0) + { + px = m_targets.m_destX; + py = m_targets.m_destY; + pz = m_targets.m_destZ; + } + // Summon in random point all other units if location present + else + m_caster->GetRandomPoint(center_x,center_y,center_z,radius,px,py,pz); + } + // Summon if dest location not present near caster + else + m_caster->GetClosePoint(px,py,pz,3.0f); + + int32 duration = GetSpellDuration(m_spellInfo); + + TempSummonType summonType = (duration == 0) ? TEMPSUMMON_DEAD_DESPAWN : TEMPSUMMON_TIMED_OR_DEAD_DESPAWN; + + m_caster->SummonCreature(creature_entry,px,py,pz,m_caster->GetOrientation(),summonType,duration); + } +} + +void Spell::EffectSummonGuardian(uint32 i) +{ + uint32 pet_entry = m_spellInfo->EffectMiscValue[i]; + if(!pet_entry) + return; + + // Jewelery statue case (totem like) + if(m_spellInfo->SpellIconID==2056) + { + EffectSummonTotem(i); + return; + } + + // set timer for unsummon + int32 duration = GetSpellDuration(m_spellInfo); + + // Search old Guardian only for players (if casted spell not have duration or cooldown) + // FIXME: some guardians have control spell applied and controlled by player and anyway player can't summon in this time + // so this code hack in fact + if( m_caster->GetTypeId() == TYPEID_PLAYER && (duration <= 0 || GetSpellRecoveryTime(m_spellInfo)==0) ) + if(((Player*)m_caster)->HasGuardianWithEntry(pet_entry)) + return; // find old guardian, ignore summon + + // in another case summon new + uint32 level = m_caster->getLevel(); + + // level of pet summoned using engineering item based at engineering skill level + if(m_caster->GetTypeId()==TYPEID_PLAYER && m_CastItem) + { + ItemPrototype const *proto = m_CastItem->GetProto(); + if(proto && proto->RequiredSkill == SKILL_ENGINERING) + { + uint16 skill202 = ((Player*)m_caster)->GetSkillValue(SKILL_ENGINERING); + if(skill202) + { + level = skill202/5; + } + } + } + + // select center of summon position + float center_x = m_targets.m_destX; + float center_y = m_targets.m_destY; + float center_z = m_targets.m_destZ; + + float radius = GetSpellRadius(sSpellRadiusStore.LookupEntry(m_spellInfo->EffectRadiusIndex[i])); + + int32 amount = damage > 0 ? damage : 1; + + for(int32 count = 0; count < amount; ++count) + { + Pet* spawnCreature = new Pet(GUARDIAN_PET); + + Map *map = m_caster->GetMap(); + uint32 pet_number = objmgr.GeneratePetNumber(); + if(!spawnCreature->Create(objmgr.GenerateLowGuid(HIGHGUID_PET), map,m_spellInfo->EffectMiscValue[i], pet_number)) + { + sLog.outError("no such creature entry %u",m_spellInfo->EffectMiscValue[i]); + delete spawnCreature; + return; + } + + float px, py, pz; + // If dest location if present + if (m_targets.m_targetMask & TARGET_FLAG_DEST_LOCATION) + { + // Summon 1 unit in dest location + if (count == 0) + { + px = m_targets.m_destX; + py = m_targets.m_destY; + pz = m_targets.m_destZ; + } + // Summon in random point all other units if location present + else + m_caster->GetRandomPoint(center_x,center_y,center_z,radius,px,py,pz); + } + // Summon if dest location not present near caster + else + m_caster->GetClosePoint(px,py,pz,spawnCreature->GetObjectSize()); + + spawnCreature->Relocate(px,py,pz,m_caster->GetOrientation()); + + if(!spawnCreature->IsPositionValid()) + { + sLog.outError("ERROR: Pet (guidlow %d, entry %d) not created base at creature. Suggested coordinates isn't valid (X: %d Y: ^%d)", spawnCreature->GetGUIDLow(), spawnCreature->GetEntry(), spawnCreature->GetPositionX(), spawnCreature->GetPositionY()); + delete spawnCreature; + return; + } + + if(duration > 0) + spawnCreature->SetDuration(duration); + + spawnCreature->SetUInt64Value(UNIT_FIELD_SUMMONEDBY,m_caster->GetGUID()); + spawnCreature->setPowerType(POWER_MANA); + spawnCreature->SetUInt32Value(UNIT_NPC_FLAGS , 0); + spawnCreature->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE,m_caster->getFaction()); + spawnCreature->SetUInt32Value(UNIT_FIELD_FLAGS,0); + spawnCreature->SetUInt32Value(UNIT_FIELD_BYTES_1,0); + spawnCreature->SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP,0); + spawnCreature->SetUInt64Value(UNIT_FIELD_CREATEDBY, m_caster->GetGUID()); + spawnCreature->SetUInt32Value(UNIT_CREATED_BY_SPELL, m_spellInfo->Id); + + spawnCreature->InitStatsForLevel(level); + spawnCreature->GetCharmInfo()->SetPetNumber(pet_number, false); + + spawnCreature->AIM_Initialize(); + + if(m_caster->GetTypeId()==TYPEID_PLAYER) + ((Player*)m_caster)->AddGuardian(spawnCreature); + + map->Add((Creature*)spawnCreature); + } +} + +void Spell::EffectTeleUnitsFaceCaster(uint32 i) +{ + if(!unitTarget) + return; + + if(unitTarget->isInFlight()) + return; + + uint32 mapid = m_caster->GetMapId(); + float dis = GetSpellRadius(sSpellRadiusStore.LookupEntry(m_spellInfo->EffectRadiusIndex[i])); + + float fx,fy,fz; + m_caster->GetClosePoint(fx,fy,fz,unitTarget->GetObjectSize(),dis); + + if(unitTarget->GetTypeId() == TYPEID_PLAYER) + ((Player*)unitTarget)->TeleportTo(mapid, fx, fy, fz, -m_caster->GetOrientation(), TELE_TO_NOT_LEAVE_COMBAT | TELE_TO_NOT_UNSUMMON_PET | (unitTarget==m_caster ? TELE_TO_SPELL : 0)); + else + MapManager::Instance().GetMap(mapid, m_caster)->CreatureRelocation((Creature*)m_caster, fx, fy, fz, -m_caster->GetOrientation()); +} + +void Spell::EffectLearnSkill(uint32 i) +{ + if(unitTarget->GetTypeId() != TYPEID_PLAYER) + return; + + if(damage < 0) + return; + + uint32 skillid = m_spellInfo->EffectMiscValue[i]; + uint16 skillval = ((Player*)unitTarget)->GetPureSkillValue(skillid); + ((Player*)unitTarget)->SetSkill(skillid, skillval?skillval:1, damage*75); +} + +void Spell::EffectAddHonor(uint32 /*i*/) +{ + if(unitTarget->GetTypeId() != TYPEID_PLAYER) + return; + + sLog.outDebug("SpellEffect::AddHonor called for spell_id %u , that rewards %d honor points to player: %u", m_spellInfo->Id, this->damage, ((Player*)unitTarget)->GetGUIDLow()); + + // TODO: find formula for honor reward based on player's level! + + // now fixed only for level 70 players: + if (((Player*)unitTarget)->getLevel() == 70) + ((Player*)unitTarget)->RewardHonor(NULL, 1, this->damage); +} + +void Spell::EffectTradeSkill(uint32 /*i*/) +{ + if(unitTarget->GetTypeId() != TYPEID_PLAYER) + return; + // uint32 skillid = m_spellInfo->EffectMiscValue[i]; + // uint16 skillmax = ((Player*)unitTarget)->(skillid); + // ((Player*)unitTarget)->SetSkill(skillid,skillval?skillval:1,skillmax+75); +} + +void Spell::EffectEnchantItemPerm(uint32 i) +{ + if(m_caster->GetTypeId() != TYPEID_PLAYER) + return; + if (!itemTarget) + return; + + Player* p_caster = (Player*)m_caster; + + p_caster->UpdateCraftSkill(m_spellInfo->Id); + + if (m_spellInfo->EffectMiscValue[i]) + { + uint32 enchant_id = m_spellInfo->EffectMiscValue[i]; + + SpellItemEnchantmentEntry const *pEnchant = sSpellItemEnchantmentStore.LookupEntry(enchant_id); + if(!pEnchant) + return; + + // item can be in trade slot and have owner diff. from caster + Player* item_owner = itemTarget->GetOwner(); + if(!item_owner) + return; + + if(item_owner!=p_caster && p_caster->GetSession()->GetSecurity() > SEC_PLAYER && sWorld.getConfig(CONFIG_GM_LOG_TRADE) ) + sLog.outCommand("GM %s (Account: %u) enchanting(perm): %s (Entry: %d) for player: %s (Account: %u)", + p_caster->GetName(),p_caster->GetSession()->GetAccountId(), + itemTarget->GetProto()->Name1,itemTarget->GetEntry(), + item_owner->GetName(),item_owner->GetSession()->GetAccountId()); + + // remove old enchanting before applying new if equipped + item_owner->ApplyEnchantment(itemTarget,PERM_ENCHANTMENT_SLOT,false); + + itemTarget->SetEnchantment(PERM_ENCHANTMENT_SLOT, enchant_id, 0, 0); + + // add new enchanting if equipped + item_owner->ApplyEnchantment(itemTarget,PERM_ENCHANTMENT_SLOT,true); + } +} + +void Spell::EffectEnchantItemTmp(uint32 i) +{ + if(m_caster->GetTypeId() != TYPEID_PLAYER) + return; + + Player* p_caster = (Player*)m_caster; + + if(!itemTarget) + return; + + uint32 enchant_id = m_spellInfo->EffectMiscValue[i]; + + // Shaman Rockbiter Weapon + if(i==0 && m_spellInfo->Effect[1]==SPELL_EFFECT_DUMMY) + { + int32 enchnting_damage = m_currentBasePoints[1]+1; + + // enchanting id selected by calculated damage-per-sec stored in Effect[1] base value + // with already applied percent bonus from Elemental Weapons talent + // Note: damage calculated (correctly) with rounding int32(float(v)) but + // RW enchantments applied damage int32(float(v)+0.5), this create 0..1 difference sometime + switch(enchnting_damage) + { + // Rank 1 + case 2: enchant_id = 29; break; // 0% [ 7% == 2, 14% == 2, 20% == 2] + // Rank 2 + case 4: enchant_id = 6; break; // 0% [ 7% == 4, 14% == 4] + case 5: enchant_id = 3025; break; // 20% + // Rank 3 + case 6: enchant_id = 1; break; // 0% [ 7% == 6, 14% == 6] + case 7: enchant_id = 3027; break; // 20% + // Rank 4 + case 9: enchant_id = 3032; break; // 0% [ 7% == 6] + case 10: enchant_id = 503; break; // 14% + case 11: enchant_id = 3031; break; // 20% + // Rank 5 + case 15: enchant_id = 3035; break; // 0% + case 16: enchant_id = 1663; break; // 7% + case 17: enchant_id = 3033; break; // 14% + case 18: enchant_id = 3034; break; // 20% + // Rank 6 + case 28: enchant_id = 3038; break; // 0% + case 29: enchant_id = 683; break; // 7% + case 31: enchant_id = 3036; break; // 14% + case 33: enchant_id = 3037; break; // 20% + // Rank 7 + case 40: enchant_id = 3041; break; // 0% + case 42: enchant_id = 1664; break; // 7% + case 45: enchant_id = 3039; break; // 14% + case 48: enchant_id = 3040; break; // 20% + // Rank 8 + case 49: enchant_id = 3044; break; // 0% + case 52: enchant_id = 2632; break; // 7% + case 55: enchant_id = 3042; break; // 14% + case 58: enchant_id = 3043; break; // 20% + // Rank 9 + case 62: enchant_id = 2633; break; // 0% + case 66: enchant_id = 3018; break; // 7% + case 70: enchant_id = 3019; break; // 14% + case 74: enchant_id = 3020; break; // 20% + default: + sLog.outError("Spell::EffectEnchantItemTmp: Damage %u not handled in S'RW",enchnting_damage); + return; + } + } + + if (!enchant_id) + { + sLog.outError("Spell %u Effect %u (SPELL_EFFECT_ENCHANT_ITEM_TEMPORARY) have 0 as enchanting id",m_spellInfo->Id,i); + return; + } + + SpellItemEnchantmentEntry const *pEnchant = sSpellItemEnchantmentStore.LookupEntry(enchant_id); + if(!pEnchant) + { + sLog.outError("Spell %u Effect %u (SPELL_EFFECT_ENCHANT_ITEM_TEMPORARY) have not existed enchanting id %u ",m_spellInfo->Id,i,enchant_id); + return; + } + + // select enchantment duration + uint32 duration; + + // rogue family enchantments exception by duration + if(m_spellInfo->Id==38615) + duration = 1800; // 30 mins + // other rogue family enchantments always 1 hour (some have spell damage=0, but some have wrong data in EffBasePoints) + else if(m_spellInfo->SpellFamilyName==SPELLFAMILY_ROGUE) + duration = 3600; // 1 hour + // shaman family enchantments + else if(m_spellInfo->SpellFamilyName==SPELLFAMILY_SHAMAN) + duration = 1800; // 30 mins + // other cases with this SpellVisual already selected + else if(m_spellInfo->SpellVisual==215) + duration = 1800; // 30 mins + // some fishing pole bonuses + else if(m_spellInfo->SpellVisual==563) + duration = 600; // 10 mins + // shaman rockbiter enchantments + else if(m_spellInfo->SpellVisual==0) + duration = 1800; // 30 mins + else if(m_spellInfo->Id==29702) + duration = 300; // 5 mins + else if(m_spellInfo->Id==37360) + duration = 300; // 5 mins + // default case + else + duration = 3600; // 1 hour + + // item can be in trade slot and have owner diff. from caster + Player* item_owner = itemTarget->GetOwner(); + if(!item_owner) + return; + + if(item_owner!=p_caster && p_caster->GetSession()->GetSecurity() > SEC_PLAYER && sWorld.getConfig(CONFIG_GM_LOG_TRADE) ) + sLog.outCommand("GM %s (Account: %u) enchanting(temp): %s (Entry: %d) for player: %s (Account: %u)", + p_caster->GetName(),p_caster->GetSession()->GetAccountId(), + itemTarget->GetProto()->Name1,itemTarget->GetEntry(), + item_owner->GetName(),item_owner->GetSession()->GetAccountId()); + + // remove old enchanting before applying new if equipped + item_owner->ApplyEnchantment(itemTarget,TEMP_ENCHANTMENT_SLOT,false); + + itemTarget->SetEnchantment(TEMP_ENCHANTMENT_SLOT, enchant_id, duration*1000, 0); + + // add new enchanting if equipped + item_owner->ApplyEnchantment(itemTarget,TEMP_ENCHANTMENT_SLOT,true); +} + +void Spell::EffectTameCreature(uint32 /*i*/) +{ + if(m_caster->GetPetGUID()) + return; + + if(!unitTarget) + return; + + if(unitTarget->GetTypeId() == TYPEID_PLAYER) + return; + + Creature* creatureTarget = (Creature*)unitTarget; + + if(creatureTarget->isPet()) + return; + + if(m_caster->getClass() == CLASS_HUNTER) + { + // cast finish successfully + //SendChannelUpdate(0); + finish(); + + Pet* pet = new Pet(HUNTER_PET); + + if(!pet->CreateBaseAtCreature(creatureTarget)) + { + delete pet; + return; + } + + creatureTarget->setDeathState(JUST_DIED); + creatureTarget->RemoveCorpse(); + creatureTarget->SetHealth(0); // just for nice GM-mode view + + pet->SetUInt64Value(UNIT_FIELD_SUMMONEDBY, m_caster->GetGUID()); + pet->SetUInt64Value(UNIT_FIELD_CREATEDBY, m_caster->GetGUID()); + pet->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE,m_caster->getFaction()); + pet->SetUInt32Value(UNIT_CREATED_BY_SPELL, m_spellInfo->Id); + + if(!pet->InitStatsForLevel(creatureTarget->getLevel())) + { + sLog.outError("ERROR: InitStatsForLevel() in EffectTameCreature failed! Pet deleted."); + delete pet; + return; + } + + // prepare visual effect for levelup + pet->SetUInt32Value(UNIT_FIELD_LEVEL,creatureTarget->getLevel()-1); + + pet->GetCharmInfo()->SetPetNumber(objmgr.GeneratePetNumber(), true); + // this enables pet details window (Shift+P) + pet->AIM_Initialize(); + pet->InitPetCreateSpells(); + pet->SetHealth(pet->GetMaxHealth()); + + MapManager::Instance().GetMap(pet->GetMapId(), pet)->Add((Creature*)pet); + + // visual effect for levelup + pet->SetUInt32Value(UNIT_FIELD_LEVEL,creatureTarget->getLevel()); + + if(m_caster->GetTypeId() == TYPEID_PLAYER) + { + m_caster->SetPet(pet); + pet->SavePetToDB(PET_SAVE_AS_CURRENT); + ((Player*)m_caster)->PetSpellInitialize(); + } + } +} + +void Spell::EffectSummonPet(uint32 i) +{ + uint32 petentry = m_spellInfo->EffectMiscValue[i]; + + Pet *OldSummon = m_caster->GetPet(); + + // if pet requested type already exist + if( OldSummon ) + { + if(petentry == 0 || OldSummon->GetEntry() == petentry) + { + // pet in corpse state can't be summoned + if( OldSummon->isDead() ) + return; + + MapManager::Instance().GetMap(OldSummon->GetMapId(), OldSummon)->Remove((Creature*)OldSummon,false); + OldSummon->SetMapId(m_caster->GetMapId()); + + float px, py, pz; + m_caster->GetClosePoint(px, py, pz, OldSummon->GetObjectSize()); + + OldSummon->Relocate(px, py, pz, OldSummon->GetOrientation()); + MapManager::Instance().GetMap(m_caster->GetMapId(), m_caster)->Add((Creature*)OldSummon); + + if(m_caster->GetTypeId() == TYPEID_PLAYER && OldSummon->isControlled() ) + { + ((Player*)m_caster)->PetSpellInitialize(); + } + return; + } + + if(m_caster->GetTypeId() == TYPEID_PLAYER) + ((Player*)m_caster)->RemovePet(OldSummon,(OldSummon->getPetType()==HUNTER_PET ? PET_SAVE_AS_DELETED : PET_SAVE_NOT_IN_SLOT),false); + else + return; + } + + Pet* NewSummon = new Pet; + + // petentry==0 for hunter "call pet" (current pet summoned if any) + if(NewSummon->LoadPetFromDB(m_caster,petentry)) + { + if(NewSummon->getPetType()==SUMMON_PET) + { + // Remove Demonic Sacrifice auras (known pet) + Unit::AuraList const& auraClassScripts = m_caster->GetAurasByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS); + for(Unit::AuraList::const_iterator itr = auraClassScripts.begin();itr!=auraClassScripts.end();) + { + if((*itr)->GetModifier()->m_miscvalue==2228) + { + m_caster->RemoveAurasDueToSpell((*itr)->GetId()); + itr = auraClassScripts.begin(); + } + else + ++itr; + } + } + + return; + } + + // not error in case fail hunter call pet + if(!petentry) + { + delete NewSummon; + return; + } + + CreatureInfo const* cInfo = sCreatureStorage.LookupEntry(petentry); + + if(!cInfo) + { + sLog.outError("EffectSummonPet: creature entry %u not found.",petentry); + delete NewSummon; + return; + } + + Map *map = m_caster->GetMap(); + uint32 pet_number = objmgr.GeneratePetNumber(); + if(!NewSummon->Create(objmgr.GenerateLowGuid(HIGHGUID_PET), map, petentry, pet_number)) + { + delete NewSummon; + return; + } + + float px, py, pz; + m_caster->GetClosePoint(px, py, pz, NewSummon->GetObjectSize()); + + NewSummon->Relocate(px, py, pz, m_caster->GetOrientation()); + + if(!NewSummon->IsPositionValid()) + { + sLog.outError("ERROR: Pet (guidlow %d, entry %d) not summoned. Suggested coordinates isn't valid (X: %d Y: ^%d)", NewSummon->GetGUIDLow(), NewSummon->GetEntry(), NewSummon->GetPositionX(), NewSummon->GetPositionY()); + delete NewSummon; + return; + } + + uint32 petlevel = m_caster->getLevel(); + NewSummon->setPetType(SUMMON_PET); + + uint32 faction = m_caster->getFaction(); + if(m_caster->GetTypeId() == TYPEID_UNIT && ((Creature*)m_caster)->isTotem()) + { + Unit* owner = ((Totem*)m_caster)->GetOwner(); + if(owner) + faction = owner->getFaction(); + NewSummon->GetCharmInfo()->SetReactState(REACT_AGGRESSIVE); + } + + NewSummon->SetUInt64Value(UNIT_FIELD_SUMMONEDBY, m_caster->GetGUID()); + NewSummon->SetUInt64Value(UNIT_FIELD_CREATEDBY, m_caster->GetGUID()); + NewSummon->SetUInt32Value(UNIT_NPC_FLAGS , 0); + NewSummon->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE, faction); + NewSummon->SetUInt32Value(UNIT_FIELD_BYTES_0,2048); + NewSummon->SetUInt32Value(UNIT_FIELD_BYTES_1,0); + NewSummon->SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP,time(NULL)); + NewSummon->SetUInt32Value(UNIT_FIELD_PETEXPERIENCE,0); + NewSummon->SetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP,1000); + NewSummon->SetUInt32Value(UNIT_CREATED_BY_SPELL, m_spellInfo->Id); + + NewSummon->GetCharmInfo()->SetPetNumber(pet_number, true); + // this enables pet details window (Shift+P) + + // this enables popup window (pet dismiss, cancel), hunter pet additional flags set later + NewSummon->SetUInt32Value(UNIT_FIELD_FLAGS,UNIT_FLAG_PVP_ATTACKABLE); + + NewSummon->InitStatsForLevel( petlevel); + NewSummon->InitPetCreateSpells(); + + if(NewSummon->getPetType()==SUMMON_PET) + { + // Remove Demonic Sacrifice auras (new pet) + Unit::AuraList const& auraClassScripts = m_caster->GetAurasByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS); + for(Unit::AuraList::const_iterator itr = auraClassScripts.begin();itr!=auraClassScripts.end();) + { + if((*itr)->GetModifier()->m_miscvalue==2228) + { + m_caster->RemoveAurasDueToSpell((*itr)->GetId()); + itr = auraClassScripts.begin(); + } + else + ++itr; + } + + // generate new name for summon pet + std::string new_name=objmgr.GeneratePetName(petentry); + if(!new_name.empty()) + NewSummon->SetName(new_name); + } + else if(NewSummon->getPetType()==HUNTER_PET) + NewSummon->SetByteValue(UNIT_FIELD_BYTES_2, 2, UNIT_RENAME_NOT_ALLOWED); + + NewSummon->AIM_Initialize(); + NewSummon->SetHealth(NewSummon->GetMaxHealth()); + NewSummon->SetPower(POWER_MANA, NewSummon->GetMaxPower(POWER_MANA)); + + map->Add((Creature*)NewSummon); + + m_caster->SetPet(NewSummon); + sLog.outDebug("New Pet has guid %u", NewSummon->GetGUIDLow()); + + if(m_caster->GetTypeId() == TYPEID_PLAYER) + { + NewSummon->SavePetToDB(PET_SAVE_AS_CURRENT); + ((Player*)m_caster)->PetSpellInitialize(); + } +} + +void Spell::EffectLearnPetSpell(uint32 i) +{ + if(m_caster->GetTypeId() != TYPEID_PLAYER) + return; + + Player *_player = (Player*)m_caster; + + Pet *pet = _player->GetPet(); + if(!pet) + return; + if(!pet->isAlive()) + return; + + SpellEntry const *learn_spellproto = sSpellStore.LookupEntry(m_spellInfo->EffectTriggerSpell[i]); + if(!learn_spellproto) + return; + + pet->SetTP(pet->m_TrainingPoints - pet->GetTPForSpell(learn_spellproto->Id)); + pet->learnSpell(learn_spellproto->Id); + + pet->SavePetToDB(PET_SAVE_AS_CURRENT); + _player->PetSpellInitialize(); +} + +void Spell::EffectTaunt(uint32 /*i*/) +{ + // this effect use before aura Taunt apply for prevent taunt already attacking target + // for spell as marked "non effective at already attacking target" + if(unitTarget && unitTarget->GetTypeId() != TYPEID_PLAYER) + { + if(unitTarget->getVictim()==m_caster) + { + SendCastResult(SPELL_FAILED_DONT_REPORT); + return; + } + } + + // Also use this effect to set the taunter's threat to the taunted creature's highest value + if(unitTarget->CanHaveThreatList() && unitTarget->getThreatManager().getCurrentVictim()) + unitTarget->getThreatManager().addThreat(m_caster,unitTarget->getThreatManager().getCurrentVictim()->getThreat()); +} + +void Spell::EffectWeaponDmg(uint32 i) +{ + if(!unitTarget) + return; + if(!unitTarget->isAlive()) + return; + + // multiple weapon dmg effect workaround + // execute only the last weapon damage + // and handle all effects at once + for (int j = 0; j < 3; j++) + { + switch(m_spellInfo->Effect[j]) + { + case SPELL_EFFECT_WEAPON_DAMAGE: + case SPELL_EFFECT_WEAPON_DAMAGE_NOSCHOOL: + case SPELL_EFFECT_NORMALIZED_WEAPON_DMG: + case SPELL_EFFECT_WEAPON_PERCENT_DAMAGE: + if (j < i) // we must calculate only at last weapon effect + return; + break; + } + } + + // some spell specific modifiers + bool customBonusDamagePercentMod = false; + float bonusDamagePercentMod = 1.0f; // applied to fixed effect damage bonus if set customBonusDamagePercentMod + float weaponDamagePercentMod = 1.0f; // applied to weapon damage (and to fixed effect damage bonus if customBonusDamagePercentMod not set + float totalDamagePercentMod = 1.0f; // applied to final bonus+weapon damage + bool normalized = false; + + int32 spell_bonus = 0; // bonus specific for spell + switch(m_spellInfo->SpellFamilyName) + { + case SPELLFAMILY_WARRIOR: + { + // Whirlwind, single only spell with 2 weapon white damage apply if have + if(m_caster->GetTypeId()==TYPEID_PLAYER && (m_spellInfo->SpellFamilyFlags & 0x00000400000000LL)) + { + if(((Player*)m_caster)->GetWeaponForAttack(OFF_ATTACK,true)) + spell_bonus += m_caster->CalculateDamage (OFF_ATTACK, normalized); + } + // Devastate bonus and sunder armor refresh + else if(m_spellInfo->SpellVisual == 671 && m_spellInfo->SpellIconID == 1508) + { + customBonusDamagePercentMod = true; + bonusDamagePercentMod = 0.0f; // only applied if auras found + + Unit::AuraList const& list = unitTarget->GetAurasByType(SPELL_AURA_MOD_RESISTANCE); + for(Unit::AuraList::const_iterator itr=list.begin();itr!=list.end();++itr) + { + SpellEntry const *proto = (*itr)->GetSpellProto(); + if(proto->SpellVisual == 406 && proto->SpellIconID == 565) + { + int32 duration = GetSpellDuration(proto); + (*itr)->SetAuraDuration(duration); + (*itr)->UpdateAuraDuration(); + bonusDamagePercentMod += 1.0f; // +100% + } + } + } + break; + } + case SPELLFAMILY_ROGUE: + { + // Ambush + if(m_spellInfo->SpellFamilyFlags & 0x00000200LL) + { + customBonusDamagePercentMod = true; + bonusDamagePercentMod = 2.5f; // 250% + } + // Mutilate (for each hand) + else if(m_spellInfo->SpellFamilyFlags & 0x600000000LL) + { + bool found = false; + // fast check + if(unitTarget->HasAuraState(AURA_STATE_DEADLY_POISON)) + found = true; + // full aura scan + else + { + Unit::AuraMap const& auras = unitTarget->GetAuras(); + for(Unit::AuraMap::const_iterator itr = auras.begin(); itr!=auras.end(); ++itr) + { + if(itr->second->GetSpellProto()->Dispel == DISPEL_POISON) + { + found = true; + break; + } + } + } + + if(found) + totalDamagePercentMod *= 1.5f; // 150% if poisoned + } + break; + } + case SPELLFAMILY_PALADIN: + { + // Seal of Command - receive benefit from Spell Damage and Healing + if(m_spellInfo->SpellFamilyFlags & 0x00000002000000LL) + { + spell_bonus += int32(0.20f*m_caster->SpellBaseDamageBonus(GetSpellSchoolMask(m_spellInfo))); + spell_bonus += int32(0.29f*m_caster->SpellBaseDamageBonusForVictim(GetSpellSchoolMask(m_spellInfo), unitTarget)); + } + break; + } + case SPELLFAMILY_SHAMAN: + { + // Skyshatter Harness item set bonus + // Stormstrike + if(m_spellInfo->SpellFamilyFlags & 0x001000000000LL) + { + Unit::AuraList const& m_OverrideClassScript = m_caster->GetAurasByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS); + for(Unit::AuraList::const_iterator i = m_OverrideClassScript.begin(); i != m_OverrideClassScript.end(); ++i) + { + // Stormstrike AP Buff + if ( (*i)->GetModifier()->m_miscvalue == 5634 ) + { + m_caster->CastSpell(m_caster,38430,true,NULL,*i); + break; + } + } + } + } + } + + int32 fixed_bonus = 0; + for (int j = 0; j < 3; j++) + { + switch(m_spellInfo->Effect[j]) + { + case SPELL_EFFECT_WEAPON_DAMAGE: + case SPELL_EFFECT_WEAPON_DAMAGE_NOSCHOOL: + fixed_bonus += CalculateDamage(j,unitTarget); + break; + case SPELL_EFFECT_NORMALIZED_WEAPON_DMG: + fixed_bonus += CalculateDamage(j,unitTarget); + normalized = true; + break; + case SPELL_EFFECT_WEAPON_PERCENT_DAMAGE: + weaponDamagePercentMod *= float(CalculateDamage(j,unitTarget)) / 100.0f; + + // applied only to prev.effects fixed damage + if(customBonusDamagePercentMod) + fixed_bonus = int32(fixed_bonus*bonusDamagePercentMod); + else + fixed_bonus = int32(fixed_bonus*weaponDamagePercentMod); + break; + default: + break; // not weapon damage effect, just skip + } + } + + // non-weapon damage + int32 bonus = spell_bonus + fixed_bonus; + + // apply to non-weapon bonus weapon total pct effect, weapon total flat effect included in weapon damage + if(bonus) + { + UnitMods unitMod; + switch(m_attackType) + { + default: + case BASE_ATTACK: unitMod = UNIT_MOD_DAMAGE_MAINHAND; break; + case OFF_ATTACK: unitMod = UNIT_MOD_DAMAGE_OFFHAND; break; + case RANGED_ATTACK: unitMod = UNIT_MOD_DAMAGE_RANGED; break; + } + + float weapon_total_pct = m_caster->GetModifierValue(unitMod, TOTAL_PCT); + bonus = int32(bonus*weapon_total_pct); + } + + // + weapon damage with applied weapon% dmg to base weapon damage in call + bonus += int32(m_caster->CalculateDamage(m_attackType, normalized)*weaponDamagePercentMod); + + // total damage + bonus = int32(bonus*totalDamagePercentMod); + + // prevent negative damage + uint32 eff_damage = uint32(bonus > 0 ? bonus : 0); + + const uint32 nohitMask = HITINFO_ABSORB | HITINFO_RESIST | HITINFO_MISS; + + uint32 hitInfo = 0; + VictimState victimState = VICTIMSTATE_NORMAL; + uint32 blocked_dmg = 0; + uint32 absorbed_dmg = 0; + uint32 resisted_dmg = 0; + CleanDamage cleanDamage = CleanDamage(0, BASE_ATTACK, MELEE_HIT_NORMAL ); + + m_caster->DoAttackDamage(unitTarget, &eff_damage, &cleanDamage, &blocked_dmg, m_spellSchoolMask, &hitInfo, &victimState, &absorbed_dmg, &resisted_dmg, m_attackType, m_spellInfo, m_IsTriggeredSpell); + + if ((hitInfo & nohitMask) && m_attackType != RANGED_ATTACK) // not send ranged miss/etc + m_caster->SendAttackStateUpdate(hitInfo & nohitMask, unitTarget, 1, m_spellSchoolMask, eff_damage, absorbed_dmg, resisted_dmg, VICTIMSTATE_NORMAL, blocked_dmg); + + bool criticalhit = (hitInfo & HITINFO_CRITICALHIT); + m_caster->SendSpellNonMeleeDamageLog(unitTarget, m_spellInfo->Id, eff_damage, m_spellSchoolMask, absorbed_dmg, resisted_dmg, false, blocked_dmg, criticalhit); + + if (eff_damage > (absorbed_dmg + resisted_dmg + blocked_dmg)) + { + eff_damage -= (absorbed_dmg + resisted_dmg + blocked_dmg); + } + else + { + cleanDamage.damage += eff_damage; + eff_damage = 0; + } + + // SPELL_SCHOOL_NORMAL use for weapon-like threat and rage calculation + m_caster->DealDamage(unitTarget, eff_damage, &cleanDamage, SPELL_DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, true); + + // Hemorrhage + if(m_spellInfo->SpellFamilyName==SPELLFAMILY_ROGUE && (m_spellInfo->SpellFamilyFlags & 0x2000000)) + { + if(m_caster->GetTypeId()==TYPEID_PLAYER) + ((Player*)m_caster)->AddComboPoints(unitTarget, 1); + } + // Mangle (Cat): CP + if(m_spellInfo->SpellFamilyName==SPELLFAMILY_DRUID && (m_spellInfo->SpellFamilyFlags==0x0000040000000000LL)) + { + if(m_caster->GetTypeId()==TYPEID_PLAYER) + ((Player*)m_caster)->AddComboPoints(unitTarget,1); + } + + + // take ammo + if(m_attackType == RANGED_ATTACK && m_caster->GetTypeId() == TYPEID_PLAYER) + { + Item *pItem = ((Player*)m_caster)->GetWeaponForAttack( RANGED_ATTACK ); + + // wands don't have ammo + if(!pItem || pItem->IsBroken() || pItem->GetProto()->SubClass==ITEM_SUBCLASS_WEAPON_WAND) + return; + + if( pItem->GetProto()->InventoryType == INVTYPE_THROWN ) + { + if(pItem->GetMaxStackCount()==1) + { + // decrease durability for non-stackable throw weapon + ((Player*)m_caster)->DurabilityPointLossForEquipSlot(EQUIPMENT_SLOT_RANGED); + } + else + { + // decrease items amount for stackable throw weapon + uint32 count = 1; + ((Player*)m_caster)->DestroyItemCount( pItem, count, true); + } + } + else if(uint32 ammo = ((Player*)m_caster)->GetUInt32Value(PLAYER_AMMO_ID)) + ((Player*)m_caster)->DestroyItemCount(ammo, 1, true); + } +} + +void Spell::EffectThreat(uint32 /*i*/) +{ + if(!unitTarget || !unitTarget->isAlive() || !m_caster->isAlive()) + return; + + if(!unitTarget->CanHaveThreatList()) + return; + + unitTarget->AddThreat(m_caster, float(damage)); +} + +void Spell::EffectHealMaxHealth(uint32 /*i*/) +{ + if(!unitTarget) + return; + if(!unitTarget->isAlive()) + return; + + uint32 heal = m_caster->GetMaxHealth(); + + int32 gain = unitTarget->ModifyHealth(heal); + unitTarget->getHostilRefManager().threatAssist(m_caster, float(gain) * 0.5f, m_spellInfo); + + m_caster->SendHealSpellLog(unitTarget, m_spellInfo->Id, heal); +} + +void Spell::EffectInterruptCast(uint32 /*i*/) +{ + if(!unitTarget) + return; + if(!unitTarget->isAlive()) + return; + + // TODO: not all spells that used this effect apply cooldown at school spells + // also exist case: apply cooldown to interrupted cast only and to all spells + for (uint32 i = CURRENT_FIRST_NON_MELEE_SPELL; i < CURRENT_MAX_SPELL; i++) + { + if (unitTarget->m_currentSpells[i]) + { + // check if we can interrupt spell + if ( unitTarget->m_currentSpells[i]->m_spellInfo->InterruptFlags & SPELL_INTERRUPT_FLAG_INTERRUPT && unitTarget->m_currentSpells[i]->m_spellInfo->PreventionType == SPELL_PREVENTION_TYPE_SILENCE ) + { + unitTarget->ProhibitSpellScholl(GetSpellSchoolMask(unitTarget->m_currentSpells[i]->m_spellInfo), GetSpellDuration(m_spellInfo)); + unitTarget->InterruptSpell(i,false); + } + } + } +} + +void Spell::EffectSummonObjectWild(uint32 i) +{ + uint32 gameobject_id = m_spellInfo->EffectMiscValue[i]; + + GameObject* pGameObj = new GameObject; + + WorldObject* target = focusObject; + if( !target ) + target = m_caster; + + float x,y,z; + if(m_targets.m_targetMask & TARGET_FLAG_DEST_LOCATION) + { + x = m_targets.m_destX; + y = m_targets.m_destY; + z = m_targets.m_destZ; + } + else + m_caster->GetClosePoint(x,y,z,DEFAULT_WORLD_OBJECT_SIZE); + + Map *map = target->GetMap(); + + if(!pGameObj->Create(objmgr.GenerateLowGuid(HIGHGUID_GAMEOBJECT), gameobject_id, map, + x, y, z, target->GetOrientation(), 0, 0, 0, 0, 100, 1)) + { + delete pGameObj; + return; + } + + int32 duration = GetSpellDuration(m_spellInfo); + pGameObj->SetRespawnTime(duration > 0 ? duration/1000 : 0); + pGameObj->SetSpellId(m_spellInfo->Id); + + if(pGameObj->GetGoType() != GAMEOBJECT_TYPE_FLAGDROP) // make dropped flag clickable for other players (not set owner guid (created by) for this)... + m_caster->AddGameObject(pGameObj); + map->Add(pGameObj); + + if(pGameObj->GetMapId() == 489 && pGameObj->GetGoType() == GAMEOBJECT_TYPE_FLAGDROP) //WS + { + if(m_caster->GetTypeId() == TYPEID_PLAYER) + { + Player *pl = (Player*)m_caster; + BattleGround* bg = ((Player *)m_caster)->GetBattleGround(); + if(bg && bg->GetTypeID()==BATTLEGROUND_WS && bg->GetStatus() == STATUS_IN_PROGRESS) + { + uint32 team = ALLIANCE; + + if(pl->GetTeam() == team) + team = HORDE; + + ((BattleGroundWS*)bg)->SetDroppedFlagGUID(pGameObj->GetGUID(),team); + } + } + } + + if(pGameObj->GetMapId() == 566 && pGameObj->GetGoType() == GAMEOBJECT_TYPE_FLAGDROP) //EY + { + if(m_caster->GetTypeId() == TYPEID_PLAYER) + { + BattleGround* bg = ((Player *)m_caster)->GetBattleGround(); + if(bg && bg->GetTypeID()==BATTLEGROUND_EY && bg->GetStatus() == STATUS_IN_PROGRESS) + { + ((BattleGroundEY*)bg)->SetDroppedFlagGUID(pGameObj->GetGUID()); + } + } + } + + if(uint32 linkedEntry = pGameObj->GetLinkedGameObjectEntry()) + { + GameObject* linkedGO = new GameObject; + if(linkedGO->Create(objmgr.GenerateLowGuid(HIGHGUID_GAMEOBJECT), linkedEntry, map, + x, y, z, target->GetOrientation(), 0, 0, 0, 0, 100, 1)) + { + linkedGO->SetRespawnTime(duration > 0 ? duration/1000 : 0); + linkedGO->SetSpellId(m_spellInfo->Id); + + m_caster->AddGameObject(linkedGO); + map->Add(linkedGO); + } + else + { + delete linkedGO; + linkedGO = NULL; + return; + } + } +} + +void Spell::EffectScriptEffect(uint32 effIndex) +{ + // TODO: we must implement hunter pet summon at login there (spell 6962) + + // by spell id + switch(m_spellInfo->Id) + { + // Bending Shinbone + case 8856: + { + if(!itemTarget && m_caster->GetTypeId()!=TYPEID_PLAYER) + return; + + uint32 spell_id = 0; + switch(urand(1,5)) + { + case 1: spell_id = 8854; break; + default: spell_id = 8855; break; + } + + m_caster->CastSpell(m_caster,spell_id,true,NULL); + return; + } + + // Healthstone creating spells + case 6201: + case 6202: + case 5699: + case 11729: + case 11730: + case 27230: + { + uint32 itemtype; + uint32 rank = 0; + Unit::AuraList const& mDummyAuras = unitTarget->GetAurasByType(SPELL_AURA_DUMMY); + for(Unit::AuraList::const_iterator i = mDummyAuras.begin();i != mDummyAuras.end(); ++i) + { + if((*i)->GetId() == 18692) + { + rank = 1; + break; + } + else if((*i)->GetId() == 18693) + { + rank = 2; + break; + } + } + + static uint32 const itypes[6][3] = { + { 5512,19004,19005}, // Minor Healthstone + { 5511,19006,19007}, // Lesser Healthstone + { 5509,19008,19009}, // Healthstone + { 5510,19010,19011}, // Greater Healthstone + { 9421,19012,19013}, // Major Healthstone + {22103,22104,22105} // Master Healthstone + }; + + switch(m_spellInfo->Id) + { + case 6201: itemtype=itypes[0][rank];break; // Minor Healthstone + case 6202: itemtype=itypes[1][rank];break; // Lesser Healthstone + case 5699: itemtype=itypes[2][rank];break; // Healthstone + case 11729: itemtype=itypes[3][rank];break; // Greater Healthstone + case 11730: itemtype=itypes[4][rank];break; // Major Healthstone + case 27230: itemtype=itypes[5][rank];break; // Master Healthstone + default: + return; + } + DoCreateItem( effIndex, itemtype ); + return; + } + // Brittle Armor - need remove one 24575 Brittle Armor aura + case 24590: + unitTarget->RemoveSingleAuraFromStack(24575, 0); + unitTarget->RemoveSingleAuraFromStack(24575, 1); + return; + // Mercurial Shield - need remove one 26464 Mercurial Shield aura + case 26465: + unitTarget->RemoveSingleAuraFromStack(26464, 0); + return; + // Orb teleport spells + case 25140: + case 25143: + case 25650: + case 25652: + case 29128: + case 29129: + case 35376: + case 35727: + { + if(!unitTarget) + return; + + uint32 spellid; + switch(m_spellInfo->Id) + { + case 25140: spellid = 32571; break; + case 25143: spellid = 32572; break; + case 25650: spellid = 30140; break; + case 25652: spellid = 30141; break; + case 29128: spellid = 32568; break; + case 29129: spellid = 32569; break; + case 35376: spellid = 25649; break; + case 35727: spellid = 35730; break; + default: + return; + } + + unitTarget->CastSpell(unitTarget,spellid,false); + return; + } + + // Shadow Flame (All script effects, not just end ones to prevent player from dodging the last triggered spell) + case 22539: + case 22972: + case 22975: + case 22976: + case 22977: + case 22978: + case 22979: + case 22980: + case 22981: + case 22982: + case 22983: + case 22984: + case 22985: + { + if(!unitTarget || !unitTarget->isAlive()) + return; + + // Onyxia Scale Cloak + if(unitTarget->GetDummyAura(22683)) + return; + + // Shadow Flame + m_caster->CastSpell(unitTarget, 22682, true); + return; + } + break; + + // Summon Black Qiraji Battle Tank + case 26656: + { + if(!unitTarget) + return; + + // Prevent stacking of mounts + unitTarget->RemoveSpellsCausingAura(SPELL_AURA_MOUNTED); + + // Two separate mounts depending on area id (allows use both in and out of specific instance) + if (unitTarget->GetAreaId() == 3428) + unitTarget->CastSpell(unitTarget, 25863, false); + else + unitTarget->CastSpell(unitTarget, 26655, false); + break; + } + // Piccolo of the Flaming Fire + case 17512: + { + if(!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) + return; + unitTarget->HandleEmoteCommand(EMOTE_STATE_DANCE); + break; + } + + // Dreaming Glory + case 28698: + { + if(!unitTarget) + return; + unitTarget->CastSpell(unitTarget, 28694, true); + break; + } + + // Netherbloom + case 28702: + { + if(!unitTarget) + return; + // 25% chance of casting a random buff + if(roll_chance_i(75)) + return; + + // triggered spells are 28703 to 28707 + // Note: some sources say, that there was the possibility of + // receiving a debuff. However, this seems to be removed by a patch. + const uint32 spellid = 28703; + + // don't overwrite an existing aura + for(uint8 i=0; i<5; i++) + if(unitTarget->HasAura(spellid+i, 0)) + return; + unitTarget->CastSpell(unitTarget, spellid+urand(0, 4), true); + break; + } + + // Nightmare Vine + case 28720: + { + if(!unitTarget) + return; + // 25% chance of casting Nightmare Pollen + if(roll_chance_i(75)) + return; + unitTarget->CastSpell(unitTarget, 28721, true); + break; + } + + // Mirren's Drinking Hat + case 29830: + { + uint32 item = 0; + switch ( urand(1,6) ) + { + case 1: case 2: case 3: item = 23584; break;// Loch Modan Lager + case 4: case 5: item = 23585; break;// Stouthammer Lite + case 6: item = 23586; break;// Aerie Peak Pale Ale + } + if (item) + DoCreateItem(effIndex,item); + break; + } + // Improved Sprint + case 30918: + { + // Removes snares and roots. + uint32 mechanic_mask = (1<GetAuras(); + for(Unit::AuraMap::iterator iter = Auras.begin(), next; iter != Auras.end(); iter = next) + { + next = iter; + ++next; + Aura *aur = iter->second; + if (!aur->IsPositive()) //only remove negative spells + { + // check for mechanic mask + if(GetSpellMechanicMask(aur->GetSpellProto(), aur->GetEffIndex()) & mechanic_mask) + { + unitTarget->RemoveAurasDueToSpell(aur->GetId()); + if(Auras.empty()) + break; + else + next = Auras.begin(); + } + } + } + break; + } + case 41126: // Flame Crash + { + if(!unitTarget) + return; + + unitTarget->CastSpell(unitTarget, 41131, true); + break; + } + case 44876: // Force Cast - Portal Effect: Sunwell Isle + { + if(!unitTarget) + return; + + unitTarget->CastSpell(unitTarget, 44870, true); + break; + } + + // Goblin Weather Machine + case 46203: + { + if(!unitTarget) + return; + + uint32 spellId; + switch(rand()%4) + { + case 0: + spellId=46740; + break; + case 1: + spellId=46739; + break; + case 2: + spellId=46738; + break; + case 3: + spellId=46736; + break; + } + unitTarget->CastSpell(unitTarget, spellId, true); + break; + } + } + + if( m_spellInfo->SpellFamilyName == SPELLFAMILY_PALADIN ) + { + switch(m_spellInfo->SpellFamilyFlags) + { + // Judgement + case 0x800000: + { + if(!unitTarget || !unitTarget->isAlive()) + return; + uint32 spellId2 = 0; + + // all seals have aura dummy + Unit::AuraList const& m_dummyAuras = m_caster->GetAurasByType(SPELL_AURA_DUMMY); + for(Unit::AuraList::const_iterator itr = m_dummyAuras.begin(); itr != m_dummyAuras.end(); ++itr) + { + SpellEntry const *spellInfo = (*itr)->GetSpellProto(); + + // search seal (all seals have judgement's aura dummy spell id in 2 effect + if ( !spellInfo || !IsSealSpell((*itr)->GetSpellProto()) || (*itr)->GetEffIndex() != 2 ) + continue; + + // must be calculated base at raw base points in spell proto, GetModifier()->m_value for S.Righteousness modified by SPELLMOD_DAMAGE + spellId2 = (*itr)->GetSpellProto()->EffectBasePoints[2]+1; + + if(spellId2 <= 1) + continue; + + // found, remove seal + m_caster->RemoveAurasDueToSpell((*itr)->GetId()); + + // Sanctified Judgement + Unit::AuraList const& m_auras = m_caster->GetAurasByType(SPELL_AURA_DUMMY); + for(Unit::AuraList::const_iterator i = m_auras.begin(); i != m_auras.end(); ++i) + { + if ((*i)->GetSpellProto()->SpellIconID == 205 && (*i)->GetSpellProto()->Attributes == 0x01D0LL) + { + int32 chance = (*i)->GetModifier()->m_amount; + if ( roll_chance_i(chance) ) + { + int32 mana = spellInfo->manaCost; + if ( Player* modOwner = m_caster->GetSpellModOwner() ) + modOwner->ApplySpellMod(spellInfo->Id, SPELLMOD_COST, mana); + mana = int32(mana* 0.8f); + m_caster->CastCustomSpell(m_caster,31930,&mana,NULL,NULL,true,NULL,*i); + } + break; + } + } + + break; + } + + m_caster->CastSpell(unitTarget,spellId2,true); + return; + } + } + } + + // normal DB scripted effect + if(!unitTarget) + return; + + sLog.outDebug("Spell ScriptStart spellid %u in EffectScriptEffect ", m_spellInfo->Id); + sWorld.ScriptsStart(sSpellScripts, m_spellInfo->Id, m_caster, unitTarget); +} + +void Spell::EffectSanctuary(uint32 /*i*/) +{ + if(!unitTarget) + return; + //unitTarget->CombatStop(); + + unitTarget->CombatStop(); + unitTarget->getHostilRefManager().deleteReferences(); // stop all fighting + // Vanish allows to remove all threat and cast regular stealth so other spells can be used + if(m_spellInfo->SpellFamilyName == SPELLFAMILY_ROGUE && (m_spellInfo->SpellFamilyFlags & SPELLFAMILYFLAG_ROGUE_VANISH)) + { + ((Player *)m_caster)->RemoveSpellsCausingAura(SPELL_AURA_MOD_ROOT); + } +} + +void Spell::EffectAddComboPoints(uint32 /*i*/) +{ + if(!unitTarget) + return; + + if(m_caster->GetTypeId() != TYPEID_PLAYER) + return; + + if(damage <= 0) + return; + + ((Player*)m_caster)->AddComboPoints(unitTarget, damage); +} + +void Spell::EffectDuel(uint32 i) +{ + if(!m_caster || !unitTarget || m_caster->GetTypeId() != TYPEID_PLAYER || unitTarget->GetTypeId() != TYPEID_PLAYER) + return; + + Player *caster = (Player*)m_caster; + Player *target = (Player*)unitTarget; + + // caster or target already have requested duel + if( caster->duel || target->duel || target->GetSocial()->HasIgnore(caster->GetGUIDLow()) ) + return; + + // Players can only fight a duel with each other outside (=not inside dungeons and not in capital cities) + // Don't have to check the target's map since you cannot challenge someone across maps + if( caster->GetMapId() != 0 && caster->GetMapId() != 1 && caster->GetMapId() != 530) + { + SendCastResult(SPELL_FAILED_NO_DUELING); // Dueling isn't allowed here + return; + } + + AreaTableEntry const* casterAreaEntry = GetAreaEntryByAreaID(caster->GetZoneId()); + if(casterAreaEntry && (casterAreaEntry->flags & AREA_FLAG_CAPITAL) ) + { + SendCastResult(SPELL_FAILED_NO_DUELING); // Dueling isn't allowed here + return; + } + + AreaTableEntry const* targetAreaEntry = GetAreaEntryByAreaID(target->GetZoneId()); + if(targetAreaEntry && (targetAreaEntry->flags & AREA_FLAG_CAPITAL) ) + { + SendCastResult(SPELL_FAILED_NO_DUELING); // Dueling isn't allowed here + return; + } + + //CREATE DUEL FLAG OBJECT + GameObject* pGameObj = new GameObject; + + uint32 gameobject_id = m_spellInfo->EffectMiscValue[i]; + + Map *map = m_caster->GetMap(); + if(!pGameObj->Create(objmgr.GenerateLowGuid(HIGHGUID_GAMEOBJECT), gameobject_id, map, + m_caster->GetPositionX()+(unitTarget->GetPositionX()-m_caster->GetPositionX())/2 , + m_caster->GetPositionY()+(unitTarget->GetPositionY()-m_caster->GetPositionY())/2 , + m_caster->GetPositionZ(), + m_caster->GetOrientation(), 0, 0, 0, 0, 0, 1)) + { + delete pGameObj; + return; + } + + pGameObj->SetUInt32Value(GAMEOBJECT_FACTION, m_caster->getFaction() ); + pGameObj->SetUInt32Value(GAMEOBJECT_LEVEL, m_caster->getLevel()+1 ); + int32 duration = GetSpellDuration(m_spellInfo); + pGameObj->SetRespawnTime(duration > 0 ? duration/1000 : 0); + pGameObj->SetSpellId(m_spellInfo->Id); + + m_caster->AddGameObject(pGameObj); + map->Add(pGameObj); + //END + + // Send request + WorldPacket data(SMSG_DUEL_REQUESTED, 16); + data << pGameObj->GetGUID(); + data << caster->GetGUID(); + caster->GetSession()->SendPacket(&data); + target->GetSession()->SendPacket(&data); + + // create duel-info + DuelInfo *duel = new DuelInfo; + duel->initiator = caster; + duel->opponent = target; + duel->startTime = 0; + duel->startTimer = 0; + caster->duel = duel; + + DuelInfo *duel2 = new DuelInfo; + duel2->initiator = caster; + duel2->opponent = caster; + duel2->startTime = 0; + duel2->startTimer = 0; + target->duel = duel2; + + caster->SetUInt64Value(PLAYER_DUEL_ARBITER,pGameObj->GetGUID()); + target->SetUInt64Value(PLAYER_DUEL_ARBITER,pGameObj->GetGUID()); +} + +void Spell::EffectStuck(uint32 /*i*/) +{ + if(!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) + return; + + if(!sWorld.getConfig(CONFIG_CAST_UNSTUCK)) + return; + + Player* pTarget = (Player*)unitTarget; + + sLog.outDebug("Spell Effect: Stuck"); + sLog.outDetail("Player %s (guid %u) used auto-unstuck future at map %u (%f, %f, %f)", pTarget->GetName(), pTarget->GetGUIDLow(), m_caster->GetMapId(), m_caster->GetPositionX(), pTarget->GetPositionY(), pTarget->GetPositionZ()); + + if(pTarget->isInFlight()) + return; + + // homebind location is loaded always + pTarget->TeleportTo(pTarget->m_homebindMapId,pTarget->m_homebindX,pTarget->m_homebindY,pTarget->m_homebindZ,pTarget->GetOrientation(), (unitTarget==m_caster ? TELE_TO_SPELL : 0)); + + // Stuck spell trigger Hearthstone cooldown + SpellEntry const *spellInfo = sSpellStore.LookupEntry(8690); + if(!spellInfo) + return; + Spell spell(pTarget,spellInfo,true,0); + spell.SendSpellCooldown(); +} + +void Spell::EffectSummonPlayer(uint32 /*i*/) +{ + if(!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) + return; + + // Evil Twin (ignore player summon, but hide this for summoner) + if(unitTarget->GetDummyAura(23445)) + return; + + float x,y,z; + m_caster->GetClosePoint(x,y,z,unitTarget->GetObjectSize()); + + ((Player*)unitTarget)->SetSummonPoint(m_caster->GetMapId(),x,y,z); + + WorldPacket data(SMSG_SUMMON_REQUEST, 8+4+4); + data << uint64(m_caster->GetGUID()); // summoner guid + data << uint32(m_caster->GetZoneId()); // summoner zone + data << uint32(MAX_PLAYER_SUMMON_DELAY*1000); // auto decline after msecs + ((Player*)unitTarget)->GetSession()->SendPacket(&data); +} + +static ScriptInfo generateActivateCommand() +{ + ScriptInfo si; + si.command = SCRIPT_COMMAND_ACTIVATE_OBJECT; + return si; +} + +void Spell::EffectActivateObject(uint32 effect_idx) +{ + if(!gameObjTarget) + return; + + static ScriptInfo activateCommand = generateActivateCommand(); + + int32 delay_secs = m_spellInfo->EffectMiscValue[effect_idx]; + + sWorld.ScriptCommandStart(activateCommand, delay_secs, m_caster, gameObjTarget); +} + +void Spell::EffectSummonTotem(uint32 i) +{ + uint8 slot = 0; + switch(m_spellInfo->EffectMiscValueB[i]) + { + case SUMMON_TYPE_TOTEM_SLOT1: slot = 0; break; + case SUMMON_TYPE_TOTEM_SLOT2: slot = 1; break; + case SUMMON_TYPE_TOTEM_SLOT3: slot = 2; break; + case SUMMON_TYPE_TOTEM_SLOT4: slot = 3; break; + // Battle standard case + case SUMMON_TYPE_TOTEM: slot = 254; break; + // jewelery statue case, like totem without slot + case SUMMON_TYPE_GUARDIAN: slot = 255; break; + default: return; + } + + if(slot < MAX_TOTEM) + { + uint64 guid = m_caster->m_TotemSlot[slot]; + if(guid != 0) + { + Creature *OldTotem = ObjectAccessor::GetCreature(*m_caster, guid); + if(OldTotem && OldTotem->isTotem()) + ((Totem*)OldTotem)->UnSummon(); + } + } + + uint32 team = 0; + if (m_caster->GetTypeId()==TYPEID_PLAYER) + team = ((Player*)m_caster)->GetTeam(); + + Totem* pTotem = new Totem; + + if(!pTotem->Create(objmgr.GenerateLowGuid(HIGHGUID_UNIT), m_caster->GetMap(), m_spellInfo->EffectMiscValue[i], team )) + { + delete pTotem; + return; + } + + float angle = slot < MAX_TOTEM ? M_PI/MAX_TOTEM - (slot*2*M_PI/MAX_TOTEM) : 0; + + float x,y,z; + m_caster->GetClosePoint(x,y,z,pTotem->GetObjectSize(),2.0f,angle); + + // totem must be at same Z in case swimming caster and etc. + if( fabs( z - m_caster->GetPositionZ() ) > 5 ) + z = m_caster->GetPositionZ(); + + pTotem->Relocate(x, y, z, m_caster->GetOrientation()); + + if(slot < MAX_TOTEM) + m_caster->m_TotemSlot[slot] = pTotem->GetGUID(); + + pTotem->SetOwner(m_caster->GetGUID()); + pTotem->SetTypeBySummonSpell(m_spellInfo); // must be after Create call where m_spells initilized + + int32 duration=GetSpellDuration(m_spellInfo); + if(Player* modOwner = m_caster->GetSpellModOwner()) + modOwner->ApplySpellMod(m_spellInfo->Id,SPELLMOD_DURATION, duration); + pTotem->SetDuration(duration); + + if (damage) // if not spell info, DB values used + { + pTotem->SetMaxHealth(damage); + pTotem->SetHealth(damage); + } + + pTotem->SetUInt32Value(UNIT_CREATED_BY_SPELL,m_spellInfo->Id); + pTotem->SetFlag(UNIT_FIELD_FLAGS,UNIT_FLAG_PVP_ATTACKABLE); + + pTotem->ApplySpellImmune(m_spellInfo->Id,IMMUNITY_STATE,SPELL_AURA_MOD_FEAR,true); + pTotem->ApplySpellImmune(m_spellInfo->Id,IMMUNITY_STATE,SPELL_AURA_TRANSFORM,true); + + pTotem->Summon(m_caster); + + if(slot < MAX_TOTEM && m_caster->GetTypeId() == TYPEID_PLAYER) + { + WorldPacket data(SMSG_TOTEM_CREATED, 1+8+4+4); + data << uint8(slot); + data << uint64(pTotem->GetGUID()); + data << uint32(duration); + data << uint32(m_spellInfo->Id); + ((Player*)m_caster)->SendDirectMessage(&data); + } +} + +void Spell::EffectEnchantHeldItem(uint32 i) +{ + // this is only item spell effect applied to main-hand weapon of target player (players in area) + if(!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) + return; + + Player* item_owner = (Player*)unitTarget; + Item* item = item_owner->GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_MAINHAND); + + if(!item ) + return; + + // must be equipped + if(!item ->IsEquipped()) + return; + + if (m_spellInfo->EffectMiscValue[i]) + { + uint32 enchant_id = m_spellInfo->EffectMiscValue[i]; + int32 duration = GetSpellDuration(m_spellInfo); //Try duration index first .. + if(!duration) + duration = m_currentBasePoints[i]+1; //Base points after .. + if(!duration) + duration = 10; //10 seconds for enchants which don't have listed duration + + SpellItemEnchantmentEntry const *pEnchant = sSpellItemEnchantmentStore.LookupEntry(enchant_id); + if(!pEnchant) + return; + + // Always go to temp enchantment slot + EnchantmentSlot slot = TEMP_ENCHANTMENT_SLOT; + + // Enchantment will not be applied if a different one already exists + if(item->GetEnchantmentId(slot) && item->GetEnchantmentId(slot) != enchant_id) + return; + + // Apply the temporary enchantment + item->SetEnchantment(slot, enchant_id, duration*1000, 0); + item_owner->ApplyEnchantment(item,slot,true); + } +} + +void Spell::EffectDisEnchant(uint32 /*i*/) +{ + if(m_caster->GetTypeId() != TYPEID_PLAYER) + return; + + Player* p_caster = (Player*)m_caster; + if(!itemTarget || !itemTarget->GetProto()->DisenchantID) + return; + + p_caster->UpdateCraftSkill(m_spellInfo->Id); + + ((Player*)m_caster)->SendLoot(itemTarget->GetGUID(),LOOT_DISENCHANTING); + + // item will be removed at disenchanting end +} + +void Spell::EffectInebriate(uint32 /*i*/) +{ + if(!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) + return; + + Player *player = (Player*)unitTarget; + uint16 currentDrunk = player->GetDrunkValue(); + uint16 drunkMod = damage * 256; + if (currentDrunk + drunkMod > 0xFFFF) + currentDrunk = 0xFFFF; + else + currentDrunk += drunkMod; + player->SetDrunkValue(currentDrunk, m_CastItem?m_CastItem->GetEntry():0); +} + +void Spell::EffectFeedPet(uint32 i) +{ + if(m_caster->GetTypeId() != TYPEID_PLAYER) + return; + + Player *_player = (Player*)m_caster; + + if(!itemTarget) + return; + + Pet *pet = _player->GetPet(); + if(!pet) + return; + + if(!pet->isAlive()) + return; + + int32 benefit = pet->GetCurrentFoodBenefitLevel(itemTarget->GetProto()->ItemLevel); + if(benefit <= 0) + return; + + uint32 count = 1; + _player->DestroyItemCount(itemTarget,count,true); + // TODO: fix crash when a spell has two effects, both pointed at the same item target + + m_caster->CastCustomSpell(m_caster,m_spellInfo->EffectTriggerSpell[i],&benefit,NULL,NULL,true); +} + +void Spell::EffectDismissPet(uint32 /*i*/) +{ + if(m_caster->GetTypeId() != TYPEID_PLAYER) + return; + + Pet* pet = m_caster->GetPet(); + + // not let dismiss dead pet + if(!pet||!pet->isAlive()) + return; + + ((Player*)m_caster)->RemovePet(pet,PET_SAVE_NOT_IN_SLOT); +} + +void Spell::EffectSummonObject(uint32 i) +{ + uint32 go_id = m_spellInfo->EffectMiscValue[i]; + + uint8 slot = 0; + switch(m_spellInfo->Effect[i]) + { + case SPELL_EFFECT_SUMMON_OBJECT_SLOT1: slot = 0; break; + case SPELL_EFFECT_SUMMON_OBJECT_SLOT2: slot = 1; break; + case SPELL_EFFECT_SUMMON_OBJECT_SLOT3: slot = 2; break; + case SPELL_EFFECT_SUMMON_OBJECT_SLOT4: slot = 3; break; + default: return; + } + + uint64 guid = m_caster->m_ObjectSlot[slot]; + if(guid != 0) + { + GameObject* obj = NULL; + if( m_caster ) + obj = ObjectAccessor::GetGameObject(*m_caster, guid); + + if(obj) obj->Delete(); + m_caster->m_ObjectSlot[slot] = 0; + } + + GameObject* pGameObj = new GameObject; + + float rot2 = sin(m_caster->GetOrientation()/2); + float rot3 = cos(m_caster->GetOrientation()/2); + + float x,y,z; + // If dest location if present + if (m_targets.m_targetMask & TARGET_FLAG_DEST_LOCATION) + { + x = m_targets.m_destX; + y = m_targets.m_destY; + z = m_targets.m_destZ; + } + // Summon in random point all other units if location present + else + m_caster->GetClosePoint(x,y,z,DEFAULT_WORLD_OBJECT_SIZE); + + Map *map = m_caster->GetMap(); + if(!pGameObj->Create(objmgr.GenerateLowGuid(HIGHGUID_GAMEOBJECT), go_id, map, x, y, z, m_caster->GetOrientation(), 0, 0, rot2, rot3, 0, 1)) + { + delete pGameObj; + return; + } + + pGameObj->SetUInt32Value(GAMEOBJECT_LEVEL,m_caster->getLevel()); + int32 duration = GetSpellDuration(m_spellInfo); + pGameObj->SetRespawnTime(duration > 0 ? duration/1000 : 0); + pGameObj->SetSpellId(m_spellInfo->Id); + m_caster->AddGameObject(pGameObj); + + map->Add(pGameObj); + WorldPacket data(SMSG_GAMEOBJECT_SPAWN_ANIM_OBSOLETE, 8); + data << pGameObj->GetGUID(); + m_caster->SendMessageToSet(&data,true); + + m_caster->m_ObjectSlot[slot] = pGameObj->GetGUID(); +} + +void Spell::EffectResurrect(uint32 i) +{ + if(!unitTarget) + return; + if(unitTarget->GetTypeId() != TYPEID_PLAYER) + return; + + if(unitTarget->isAlive()) + return; + if(!unitTarget->IsInWorld()) + return; + + switch (m_spellInfo->Id) + { + // Defibrillate (Goblin Jumper Cables) have 33% chance on success + case 8342: + if (roll_chance_i(67)) + { + m_caster->CastSpell(m_caster, 8338, true, m_CastItem); + return; + } + break; + // Defibrillate (Goblin Jumper Cables XL) have 50% chance on success + case 22999: + if (roll_chance_i(50)) + { + m_caster->CastSpell(m_caster, 23055, true, m_CastItem); + return; + } + break; + default: + break; + } + + Player* pTarget = ((Player*)unitTarget); + + if(pTarget->isRessurectRequested()) // already have one active request + return; + + uint32 health = pTarget->GetMaxHealth() * damage / 100; + uint32 mana = pTarget->GetMaxPower(POWER_MANA) * damage / 100; + + pTarget->setResurrectRequestData(m_caster->GetGUID(), m_caster->GetMapId(), m_caster->GetPositionX(), m_caster->GetPositionY(), m_caster->GetPositionZ(), health, mana); + SendResurrectRequest(pTarget); +} + +void Spell::EffectAddExtraAttacks(uint32 /*i*/) +{ + if(!unitTarget || !unitTarget->isAlive()) + return; + + if( unitTarget->m_extraAttacks ) + return; + + unitTarget->m_extraAttacks = damage; +} + +void Spell::EffectParry(uint32 /*i*/) +{ + if (unitTarget->GetTypeId() == TYPEID_PLAYER) + { + ((Player*)unitTarget)->SetCanParry(true); + } +} + +void Spell::EffectBlock(uint32 /*i*/) +{ + if (unitTarget->GetTypeId() != TYPEID_PLAYER) + return; + + ((Player*)unitTarget)->SetCanBlock(true); +} + +void Spell::EffectMomentMove(uint32 i) +{ + if(unitTarget->isInFlight()) + return; + + if( m_spellInfo->rangeIndex== 1) //self range + { + uint32 mapid = m_caster->GetMapId(); + float dis = GetSpellRadius(sSpellRadiusStore.LookupEntry(m_spellInfo->EffectRadiusIndex[i])); + + // before caster + float fx,fy,fz; + unitTarget->GetClosePoint(fx,fy,fz,unitTarget->GetObjectSize(),dis); + float ox,oy,oz; + unitTarget->GetPosition(ox,oy,oz); + + float fx2,fy2,fz2; // getObjectHitPos overwrite last args in any result case + if(VMAP::VMapFactory::createOrGetVMapManager()->getObjectHitPos(mapid, ox,oy,oz+0.5, fx,fy,oz+0.5,fx2,fy2,fz2, -0.5)) + { + fx = fx2; + fy = fy2; + fz = fz2; + unitTarget->UpdateGroundPositionZ(fx,fy,fz); + } + + if(unitTarget->GetTypeId() == TYPEID_PLAYER) + ((Player*)unitTarget)->TeleportTo(mapid, fx, fy, fz, unitTarget->GetOrientation(), TELE_TO_NOT_LEAVE_COMBAT | TELE_TO_NOT_UNSUMMON_PET | (unitTarget==m_caster ? TELE_TO_SPELL : 0)); + else + MapManager::Instance().GetMap(mapid, unitTarget)->CreatureRelocation((Creature*)unitTarget, fx, fy, fz, unitTarget->GetOrientation()); + } +} + +void Spell::EffectReputation(uint32 i) +{ + if(!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) + return; + + Player *_player = (Player*)unitTarget; + + int32 rep_change = m_currentBasePoints[i]+1; // field store reputation change -1 + + uint32 faction_id = m_spellInfo->EffectMiscValue[i]; + + FactionEntry const* factionEntry = sFactionStore.LookupEntry(faction_id); + + if(!factionEntry) + return; + + _player->ModifyFactionReputation(factionEntry,rep_change); +} + +void Spell::EffectQuestComplete(uint32 i) +{ + if(m_caster->GetTypeId() != TYPEID_PLAYER) + return; + + Player *_player = (Player*)m_caster; + + uint32 quest_id = m_spellInfo->EffectMiscValue[i]; + _player->AreaExploredOrEventHappens(quest_id); +} + +void Spell::EffectSelfResurrect(uint32 i) +{ + if(!unitTarget || unitTarget->isAlive()) + return; + if(unitTarget->GetTypeId() != TYPEID_PLAYER) + return; + if(!unitTarget->IsInWorld()) + return; + + uint32 health = 0; + uint32 mana = 0; + + // flat case + if(damage < 0) + { + health = uint32(-damage); + mana = m_spellInfo->EffectMiscValue[i]; + } + // percent case + else + { + health = uint32(damage/100.0f*unitTarget->GetMaxHealth()); + if(unitTarget->GetMaxPower(POWER_MANA) > 0) + mana = uint32(damage/100.0f*unitTarget->GetMaxPower(POWER_MANA)); + } + + Player *plr = ((Player*)unitTarget); + plr->ResurrectPlayer(0.0f); + + plr->SetHealth( health ); + plr->SetPower(POWER_MANA, mana ); + plr->SetPower(POWER_RAGE, 0 ); + plr->SetPower(POWER_ENERGY, plr->GetMaxPower(POWER_ENERGY) ); + + plr->SpawnCorpseBones(); + + plr->SaveToDB(); +} + +void Spell::EffectSkinning(uint32 /*i*/) +{ + if(unitTarget->GetTypeId() != TYPEID_UNIT ) + return; + if(!m_caster || m_caster->GetTypeId() != TYPEID_PLAYER) + return; + + Creature* creature = (Creature*) unitTarget; + int32 targetLevel = creature->getLevel(); + + uint32 skill; + if(creature->GetCreatureInfo()->flag1 & 256) + skill = SKILL_HERBALISM; // special case + else if(creature->GetCreatureInfo()->flag1 & 512) + skill = SKILL_MINING; // special case + else + skill = SKILL_SKINNING; // normal case + + ((Player*)m_caster)->SendLoot(creature->GetGUID(),LOOT_SKINNING); + creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SKINNABLE); + + int32 reqValue = targetLevel < 10 ? 0 : targetLevel < 20 ? (targetLevel-10)*10 : targetLevel*5; + + int32 skillValue = ((Player*)m_caster)->GetPureSkillValue(skill); + + // Double chances for elites + ((Player*)m_caster)->UpdateGatherSkill(skill, skillValue, reqValue, creature->isElite() ? 2 : 1 ); +} + +void Spell::EffectCharge(uint32 /*i*/) +{ + if(!unitTarget || !m_caster) + return; + + float x, y, z; + unitTarget->GetContactPoint(m_caster, x, y, z); + if(unitTarget->GetTypeId() != TYPEID_PLAYER) + ((Creature *)unitTarget)->StopMoving(); + + // Only send MOVEMENTFLAG_WALK_MODE, client has strange issues with other move flags + m_caster->SendMonsterMove(x, y, z, 0, MOVEMENTFLAG_WALK_MODE, 1); + + if(m_caster->GetTypeId() != TYPEID_PLAYER) + MapManager::Instance().GetMap(m_caster->GetMapId(), m_caster)->CreatureRelocation((Creature*)m_caster,x,y,z,m_caster->GetOrientation()); + + // not all charge effects used in negative spells + if ( !IsPositiveSpell(m_spellInfo->Id)) + m_caster->Attack(unitTarget,true); +} + +void Spell::EffectSummonCritter(uint32 i) +{ + if(m_caster->GetTypeId() != TYPEID_PLAYER) + return; + Player* player = (Player*)m_caster; + + uint32 pet_entry = m_spellInfo->EffectMiscValue[i]; + if(!pet_entry) + return; + + Pet* old_critter = player->GetMiniPet(); + + // for same pet just despawn + if(old_critter && old_critter->GetEntry() == pet_entry) + { + player->RemoveMiniPet(); + return; + } + + // despawn old pet before summon new + if(old_critter) + player->RemoveMiniPet(); + + // summon new pet + Pet* critter = new Pet(MINI_PET); + + Map *map = m_caster->GetMap(); + uint32 pet_number = objmgr.GeneratePetNumber(); + if(!critter->Create(objmgr.GenerateLowGuid(HIGHGUID_PET), + map, pet_entry, pet_number)) + { + sLog.outError("Spell::EffectSummonCritter, spellid %u: no such creature entry %u", m_spellInfo->Id, pet_entry); + delete critter; + return; + } + + float x,y,z; + // If dest location if present + if (m_targets.m_targetMask & TARGET_FLAG_DEST_LOCATION) + { + x = m_targets.m_destX; + y = m_targets.m_destY; + z = m_targets.m_destZ; + } + // Summon if dest location not present near caster + else + m_caster->GetClosePoint(x,y,z,critter->GetObjectSize()); + + critter->Relocate(x,y,z,m_caster->GetOrientation()); + + if(!critter->IsPositionValid()) + { + sLog.outError("ERROR: Pet (guidlow %d, entry %d) not summoned. Suggested coordinates isn't valid (X: %d Y: ^%d)", critter->GetGUIDLow(), critter->GetEntry(), critter->GetPositionX(), critter->GetPositionY()); + delete critter; + return; + } + + critter->SetUInt64Value(UNIT_FIELD_SUMMONEDBY,m_caster->GetGUID()); + critter->SetUInt64Value(UNIT_FIELD_CREATEDBY,m_caster->GetGUID()); + critter->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE,m_caster->getFaction()); + critter->SetUInt32Value(UNIT_CREATED_BY_SPELL, m_spellInfo->Id); + + critter->AIM_Initialize(); + critter->InitPetCreateSpells(); // e.g. disgusting oozeling has a create spell as critter... + critter->SetMaxHealth(1); + critter->SetHealth(1); + critter->SetLevel(1); + + // set timer for unsummon + int32 duration = GetSpellDuration(m_spellInfo); + if(duration > 0) + critter->SetDuration(duration); + + std::string name = player->GetName(); + name.append(petTypeSuffix[critter->getPetType()]); + critter->SetName( name ); + player->SetMiniPet(critter); + + map->Add((Creature*)critter); +} + +void Spell::EffectKnockBack(uint32 i) +{ + if(!unitTarget || !m_caster) + return; + + // Effect only works on players + if(unitTarget->GetTypeId()!=TYPEID_PLAYER) + return; + + float vsin = sin(m_caster->GetAngle(unitTarget)); + float vcos = cos(m_caster->GetAngle(unitTarget)); + + WorldPacket data(SMSG_MOVE_KNOCK_BACK, (8+4+4+4+4+4)); + data.append(unitTarget->GetPackGUID()); + data << uint32(0); // Sequence + data << float(vcos); // x direction + data << float(vsin); // y direction + data << float(m_spellInfo->EffectMiscValue[i])/10; // Horizontal speed + data << float(damage/-10); // Z Movement speed (vertical) + + ((Player*)unitTarget)->GetSession()->SendPacket(&data); +} + +void Spell::EffectSendTaxi(uint32 i) +{ + if(!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) + return; + + TaxiPathEntry const* entry = sTaxiPathStore.LookupEntry(m_spellInfo->EffectMiscValue[i]); + if(!entry) + return; + + std::vector nodes; + + nodes.resize(2); + nodes[0] = entry->from; + nodes[1] = entry->to; + + uint32 mountid = 0; + switch(m_spellInfo->Id) + { + case 31606: //Stormcrow Amulet + mountid = 17447; + break; + case 45071: //Quest - Sunwell Daily - Dead Scar Bombing Run + case 45113: //Quest - Sunwell Daily - Ship Bombing Run + case 45353: //Quest - Sunwell Daily - Ship Bombing Run Return + mountid = 22840; + break; + case 34905: //Stealth Flight + mountid = 6851; + break; + } + + ((Player*)unitTarget)->ActivateTaxiPathTo(nodes,mountid); + +} + +void Spell::EffectPlayerPull(uint32 i) +{ + if(!unitTarget || !m_caster) + return; + + // Effect only works on players + if(unitTarget->GetTypeId()!=TYPEID_PLAYER) + return; + + float vsin = sin(unitTarget->GetAngle(m_caster)); + float vcos = cos(unitTarget->GetAngle(m_caster)); + + WorldPacket data(SMSG_MOVE_KNOCK_BACK, (8+4+4+4+4+4)); + data.append(unitTarget->GetPackGUID()); + data << uint32(0); // Sequence + data << float(vcos); // x direction + data << float(vsin); // y direction + // Horizontal speed + data << float(damage ? damage : unitTarget->GetDistance2d(m_caster)); + data << float(m_spellInfo->EffectMiscValue[i])/-10; // Z Movement speed + + ((Player*)unitTarget)->GetSession()->SendPacket(&data); +} + +void Spell::EffectDispelMechanic(uint32 i) +{ + if(!unitTarget) + return; + + uint32 mechanic = m_spellInfo->EffectMiscValue[i]; + + Unit::AuraMap& Auras = unitTarget->GetAuras(); + for(Unit::AuraMap::iterator iter = Auras.begin(), next; iter != Auras.end(); iter = next) + { + next = iter; + ++next; + SpellEntry const *spell = sSpellStore.LookupEntry(iter->second->GetSpellProto()->Id); + if(spell->Mechanic == mechanic || spell->EffectMechanic[iter->second->GetEffIndex()] == mechanic) + { + unitTarget->RemoveAurasDueToSpell(spell->Id); + if(Auras.empty()) + break; + else + next = Auras.begin(); + } + } + return; +} + +void Spell::EffectSummonDeadPet(uint32 /*i*/) +{ + if(m_caster->GetTypeId() != TYPEID_PLAYER) + return; + Player *_player = (Player*)m_caster; + Pet *pet = _player->GetPet(); + if(!pet) + return; + if(pet->isAlive()) + return; + if(damage < 0) + return; + pet->SetUInt32Value(UNIT_DYNAMIC_FLAGS, 0); + pet->RemoveFlag (UNIT_FIELD_FLAGS, UNIT_FLAG_SKINNABLE); + pet->setDeathState( ALIVE ); + pet->clearUnitState(UNIT_STAT_ALL_STATE); + pet->SetHealth( uint32(pet->GetMaxHealth()*(float(damage)/100))); + + pet->AIM_Initialize(); + + _player->PetSpellInitialize(); + pet->SavePetToDB(PET_SAVE_AS_CURRENT); +} + +void Spell::EffectDestroyAllTotems(uint32 /*i*/) +{ + float mana = 0; + for(int slot = 0; slot < MAX_TOTEM; ++slot) + { + if(!m_caster->m_TotemSlot[slot]) + continue; + + Creature* totem = ObjectAccessor::GetCreature(*m_caster,m_caster->m_TotemSlot[slot]); + if(totem && totem->isTotem()) + { + uint32 spell_id = totem->GetUInt32Value(UNIT_CREATED_BY_SPELL); + SpellEntry const* spellInfo = sSpellStore.LookupEntry(spell_id); + if(spellInfo) + mana += spellInfo->manaCost * damage / 100; + ((Totem*)totem)->UnSummon(); + } + } + + int32 gain = m_caster->ModifyPower(POWER_MANA,int32(mana)); + m_caster->SendEnergizeSpellLog(m_caster, m_spellInfo->Id, gain, POWER_MANA); +} + +void Spell::EffectDurabilityDamage(uint32 i) +{ + if(!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) + return; + + int32 slot = m_spellInfo->EffectMiscValue[i]; + + // FIXME: some spells effects have value -1/-2 + // Possibly its mean -1 all player equipped items and -2 all items + if(slot < 0) + { + ((Player*)unitTarget)->DurabilityPointsLossAll(damage,(slot < -1)); + return; + } + + // invalid slot value + if(slot >= INVENTORY_SLOT_BAG_END) + return; + + if(Item* item = ((Player*)unitTarget)->GetItemByPos(INVENTORY_SLOT_BAG_0,slot)) + ((Player*)unitTarget)->DurabilityPointsLoss(item,damage); +} + +void Spell::EffectDurabilityDamagePCT(uint32 i) +{ + if(!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) + return; + + int32 slot = m_spellInfo->EffectMiscValue[i]; + + // FIXME: some spells effects have value -1/-2 + // Possibly its mean -1 all player equipped items and -2 all items + if(slot < 0) + { + ((Player*)unitTarget)->DurabilityLossAll(double(damage)/100.0f,(slot < -1)); + return; + } + + // invalid slot value + if(slot >= INVENTORY_SLOT_BAG_END) + return; + + if(damage <= 0) + return; + + if(Item* item = ((Player*)unitTarget)->GetItemByPos(INVENTORY_SLOT_BAG_0,slot)) + ((Player*)unitTarget)->DurabilityLoss(item,double(damage)/100.0f); +} + +void Spell::EffectModifyThreatPercent(uint32 /*effIndex*/) +{ + if(!unitTarget) + return; + + unitTarget->getThreatManager().modifyThreatPercent(m_caster, damage); +} + +void Spell::EffectTransmitted(uint32 effIndex) +{ + uint32 name_id = m_spellInfo->EffectMiscValue[effIndex]; + + GameObjectInfo const* goinfo = objmgr.GetGameObjectInfo(name_id); + + if (!goinfo) + { + sLog.outErrorDb("Gameobject (Entry: %u) not exist and not created at spell (ID: %u) cast",name_id, m_spellInfo->Id); + return; + } + + float fx,fy,fz; + + if(m_targets.m_targetMask & TARGET_FLAG_DEST_LOCATION) + { + fx = m_targets.m_destX; + fy = m_targets.m_destY; + fz = m_targets.m_destZ; + } + //FIXME: this can be better check for most objects but still hack + else if(m_spellInfo->EffectRadiusIndex[effIndex] && m_spellInfo->speed==0) + { + float dis = GetSpellRadius(sSpellRadiusStore.LookupEntry(m_spellInfo->EffectRadiusIndex[effIndex])); + m_caster->GetClosePoint(fx,fy,fz,DEFAULT_WORLD_OBJECT_SIZE, dis); + } + else + { + float min_dis = GetSpellMinRange(sSpellRangeStore.LookupEntry(m_spellInfo->rangeIndex)); + float max_dis = GetSpellMaxRange(sSpellRangeStore.LookupEntry(m_spellInfo->rangeIndex)); + float dis = rand_norm() * (max_dis - min_dis) + min_dis; + + m_caster->GetClosePoint(fx,fy,fz,DEFAULT_WORLD_OBJECT_SIZE, dis); + } + + Map *cMap = m_caster->GetMap(); + + if(goinfo->type==GAMEOBJECT_TYPE_FISHINGNODE) + { + if ( !cMap->IsInWater(fx,fy,fz-0.5f)) // Hack to prevent fishing bobber from failing to land on fishing hole + { // but this is not proper, we really need to ignore not materialized objects + SendCastResult(SPELL_FAILED_NOT_HERE); + SendChannelUpdate(0); + return; + } + + // replace by water level in this case + fz = cMap->GetWaterLevel(fx,fy); + } + // if gameobject is summoning object, it should be spawned right on caster's position + else if(goinfo->type==GAMEOBJECT_TYPE_SUMMONING_RITUAL) + { + m_caster->GetPosition(fx,fy,fz); + } + + GameObject* pGameObj = new GameObject; + + if(!pGameObj->Create(objmgr.GenerateLowGuid(HIGHGUID_GAMEOBJECT), name_id, cMap, + fx, fy, fz, m_caster->GetOrientation(), 0, 0, 0, 0, 100, 1)) + { + delete pGameObj; + return; + } + + int32 duration = GetSpellDuration(m_spellInfo); + + switch(goinfo->type) + { + case GAMEOBJECT_TYPE_FISHINGNODE: + { + m_caster->SetUInt64Value(UNIT_FIELD_CHANNEL_OBJECT,pGameObj->GetGUID()); + // Orientation3 + pGameObj->SetFloatValue(GAMEOBJECT_ROTATION + 2, 0.88431775569915771 ); + // Orientation4 + pGameObj->SetFloatValue(GAMEOBJECT_ROTATION + 3, -0.4668855369091033 ); + m_caster->AddGameObject(pGameObj); // will removed at spell cancel + + // end time of range when possible catch fish (FISHING_BOBBER_READY_TIME..GetDuration(m_spellInfo)) + // start time == fish-FISHING_BOBBER_READY_TIME (0..GetDuration(m_spellInfo)-FISHING_BOBBER_READY_TIME) + int32 lastSec; + switch(urand(0, 3)) + { + case 0: lastSec = 3; break; + case 1: lastSec = 7; break; + case 2: lastSec = 13; break; + case 3: lastSec = 17; break; + } + + duration = duration - lastSec*1000 + FISHING_BOBBER_READY_TIME*1000; + break; + } + case GAMEOBJECT_TYPE_SUMMONING_RITUAL: + { + if(m_caster->GetTypeId()==TYPEID_PLAYER) + { + pGameObj->AddUniqueUse((Player*)m_caster); + m_caster->AddGameObject(pGameObj); // will removed at spell cancel + } + break; + } + case GAMEOBJECT_TYPE_FISHINGHOLE: + case GAMEOBJECT_TYPE_CHEST: + default: + { + break; + } + } + + pGameObj->SetRespawnTime(duration > 0 ? duration/1000 : 0); + + pGameObj->SetOwnerGUID(m_caster->GetGUID() ); + + pGameObj->SetUInt32Value(GAMEOBJECT_LEVEL, m_caster->getLevel() ); + pGameObj->SetSpellId(m_spellInfo->Id); + + DEBUG_LOG("AddObject at SpellEfects.cpp EffectTransmitted\n"); + //m_caster->AddGameObject(pGameObj); + //m_ObjToDel.push_back(pGameObj); + + cMap->Add(pGameObj); + + WorldPacket data(SMSG_GAMEOBJECT_SPAWN_ANIM_OBSOLETE, 8); + data << uint64(pGameObj->GetGUID()); + m_caster->SendMessageToSet(&data,true); + + if(uint32 linkedEntry = pGameObj->GetLinkedGameObjectEntry()) + { + GameObject* linkedGO = new GameObject; + if(linkedGO->Create(objmgr.GenerateLowGuid(HIGHGUID_GAMEOBJECT), linkedEntry, cMap, + fx, fy, fz, m_caster->GetOrientation(), 0, 0, 0, 0, 100, 1)) + { + linkedGO->SetRespawnTime(duration > 0 ? duration/1000 : 0); + linkedGO->SetUInt32Value(GAMEOBJECT_LEVEL, m_caster->getLevel() ); + linkedGO->SetSpellId(m_spellInfo->Id); + linkedGO->SetOwnerGUID(m_caster->GetGUID() ); + + MapManager::Instance().GetMap(linkedGO->GetMapId(), linkedGO)->Add(linkedGO); + } + else + { + delete linkedGO; + linkedGO = NULL; + return; + } + } +} + +void Spell::EffectProspecting(uint32 /*i*/) +{ + if(m_caster->GetTypeId() != TYPEID_PLAYER) + return; + + Player* p_caster = (Player*)m_caster; + if(!itemTarget || !(itemTarget->GetProto()->BagFamily & BAG_FAMILY_MASK_MINING_SUPP)) + return; + + if(itemTarget->GetCount() < 5) + return; + + if( sWorld.getConfig(CONFIG_SKILL_PROSPECTING)) + { + uint32 SkillValue = p_caster->GetPureSkillValue(SKILL_JEWELCRAFTING); + uint32 reqSkillValue = itemTarget->GetProto()->RequiredSkillRank; + p_caster->UpdateGatherSkill(SKILL_JEWELCRAFTING, SkillValue, reqSkillValue); + } + + ((Player*)m_caster)->SendLoot(itemTarget->GetGUID(), LOOT_PROSPECTING); +} + +void Spell::EffectSkill(uint32 /*i*/) +{ + sLog.outDebug("WORLD: SkillEFFECT"); +} + +void Spell::EffectSummonDemon(uint32 i) +{ + float px = m_targets.m_destX; + float py = m_targets.m_destY; + float pz = m_targets.m_destZ; + + Creature* Charmed = m_caster->SummonCreature(m_spellInfo->EffectMiscValue[i], px, py, pz, m_caster->GetOrientation(),TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,3600000); + if (!Charmed) + return; + + // might not always work correctly, maybe the creature that dies from CoD casts the effect on itself and is therefore the caster? + Charmed->SetLevel(m_caster->getLevel()); + + // TODO: Add damage/mana/hp according to level + + if (m_spellInfo->EffectMiscValue[i] == 89) // Inferno summon + { + // Enslave demon effect, without mana cost and cooldown + m_caster->CastSpell(Charmed, 20882, true); // FIXME: enslave does not scale with level, level 62+ minions cannot be enslaved + + // Inferno effect + Charmed->CastSpell(Charmed, 22703, true, 0); + } +} + +/* There is currently no need for this effect. We handle it in BattleGround.cpp + If we would handle the resurrection here, the spiritguide would instantly disappear as the + player revives, and so we wouldn't see the spirit heal visual effect on the npc. + This is why we use a half sec delay between the visual effect and the resurrection itself */ +void Spell::EffectSpiritHeal(uint32 /*i*/) +{ + /* + if(!unitTarget || unitTarget->isAlive()) + return; + if(unitTarget->GetTypeId() != TYPEID_PLAYER) + return; + if(!unitTarget->IsInWorld()) + return; + + //m_spellInfo->EffectBasePoints[i]; == 99 (percent?) + //((Player*)unitTarget)->setResurrect(m_caster->GetGUID(), unitTarget->GetPositionX(), unitTarget->GetPositionY(), unitTarget->GetPositionZ(), unitTarget->GetMaxHealth(), unitTarget->GetMaxPower(POWER_MANA)); + ((Player*)unitTarget)->ResurrectPlayer(1.0f); + ((Player*)unitTarget)->SpawnCorpseBones(); + */ +} + +// remove insignia spell effect +void Spell::EffectSkinPlayerCorpse(uint32 /*i*/) +{ + sLog.outDebug("Effect: SkinPlayerCorpse"); + if ( (m_caster->GetTypeId() != TYPEID_PLAYER) || (unitTarget->GetTypeId() != TYPEID_PLAYER) || (unitTarget->isAlive()) ) + return; + + ((Player*)unitTarget)->RemovedInsignia( (Player*)m_caster ); +} + +void Spell::EffectStealBeneficialBuff(uint32 i) +{ + sLog.outDebug("Effect: StealBeneficialBuff"); + + if(!unitTarget || unitTarget==m_caster) // can't steal from self + return; + + std::vector steal_list; + // Create dispel mask by dispel type + uint32 dispelMask = GetDispellMask( DispelType(m_spellInfo->EffectMiscValue[i]) ); + Unit::AuraMap const& auras = unitTarget->GetAuras(); + for(Unit::AuraMap::const_iterator itr = auras.begin(); itr != auras.end(); ++itr) + { + Aura *aur = (*itr).second; + if (aur && (1<GetSpellProto()->Dispel) & dispelMask) + { + // Need check for passive? this + if (aur->IsPositive() && !aur->IsPassive()) + steal_list.push_back(aur); + } + } + // Ok if exist some buffs for dispel try dispel it + if (!steal_list.empty()) + { + std::list < std::pair > success_list; + int32 list_size = steal_list.size(); + // Dispell N = damage buffs (or while exist buffs for dispel) + for (int32 count=0; count < damage && list_size > 0; ++count) + { + // Random select buff for dispel + Aura *aur = steal_list[urand(0, list_size-1)]; + // Not use chance for steal + // TODO possible need do it + success_list.push_back( std::pair(aur->GetId(),aur->GetCasterGUID())); + + // Remove buff from list for prevent doubles + for (std::vector::iterator j = steal_list.begin(); j != steal_list.end(); ) + { + Aura *stealed = *j; + if (stealed->GetId() == aur->GetId() && stealed->GetCasterGUID() == aur->GetCasterGUID()) + { + j = steal_list.erase(j); + --list_size; + } + else + ++j; + } + } + // Really try steal and send log + if (!success_list.empty()) + { + int32 count = success_list.size(); + WorldPacket data(SMSG_SPELLSTEALLOG, 8+8+4+1+4+count*5); + data.append(unitTarget->GetPackGUID()); // Victim GUID + data.append(m_caster->GetPackGUID()); // Caster GUID + data << uint32(m_spellInfo->Id); // Dispell spell id + data << uint8(0); // not used + data << uint32(count); // count + for (std::list >::iterator j = success_list.begin(); j != success_list.end(); ++j) + { + SpellEntry const* spellInfo = sSpellStore.LookupEntry(j->first); + data << uint32(spellInfo->Id); // Spell Id + data << uint8(0); // 0 - steals !=0 transfers + unitTarget->RemoveAurasDueToSpellBySteal(spellInfo->Id, j->second, m_caster); + } + m_caster->SendMessageToSet(&data, true); + } + } +} + +void Spell::EffectKillCredit(uint32 i) +{ + if(!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) + return; + + ((Player*)unitTarget)->KilledMonster(m_spellInfo->EffectMiscValue[i], 0); +} + +void Spell::EffectQuestFail(uint32 i) +{ + if(!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) + return; + + ((Player*)unitTarget)->FailQuest(m_spellInfo->EffectMiscValue[i]); +} diff --git a/src/game/StatSystem.cpp b/src/game/StatSystem.cpp index b89346d937a..951a92cb5ad 100644 --- a/src/game/StatSystem.cpp +++ b/src/game/StatSystem.cpp @@ -1,955 +1,965 @@ -/* - * Copyright (C) 2005-2008 MaNGOS - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "Unit.h" -#include "Player.h" -#include "Pet.h" -#include "Creature.h" -#include "SharedDefines.h" -#include "SpellAuras.h" - -/*####################################### -######## ######## -######## PLAYERS STAT SYSTEM ######## -######## ######## -#######################################*/ - -bool Player::UpdateStats(Stats stat) -{ - if(stat > STAT_SPIRIT) - return false; - - // value = ((base_value * base_pct) + total_value) * total_pct - float value = GetTotalStatValue(stat); - - SetStat(stat, int32(value)); - - if(stat == STAT_STAMINA || stat == STAT_INTELLECT) - { - Pet *pet = GetPet(); - if(pet) - pet->UpdateStats(stat); - } - - switch(stat) - { - case STAT_STRENGTH: - UpdateAttackPowerAndDamage(); - UpdateShieldBlockValue(); - break; - case STAT_AGILITY: - UpdateArmor(); - UpdateAttackPowerAndDamage(true); - if(getClass() == CLASS_ROGUE || getClass() == CLASS_HUNTER || getClass() == CLASS_DRUID && m_form==FORM_CAT) - UpdateAttackPowerAndDamage(); - - UpdateAllCritPercentages(); - UpdateDodgePercentage(); - break; - - case STAT_STAMINA: UpdateMaxHealth(); break; - case STAT_INTELLECT: - UpdateMaxPower(POWER_MANA); - UpdateAllSpellCritChances(); - UpdateAttackPowerAndDamage(true); //SPELL_AURA_MOD_RANGED_ATTACK_POWER_OF_STAT_PERCENT, only intelect currently - UpdateArmor(); //SPELL_AURA_MOD_RESISTANCE_OF_INTELLECT_PERCENT, only armor currently - break; - - case STAT_SPIRIT: - break; - - default: - break; - } - UpdateSpellDamageAndHealingBonus(); - UpdateManaRegen(); - return true; -} - -void Player::UpdateSpellDamageAndHealingBonus() -{ - // Magic damage modifiers implemented in Unit::SpellDamageBonus - // This information for client side use only - // Get healing bonus for all schools - SetStatInt32Value(PLAYER_FIELD_MOD_HEALING_DONE_POS, SpellBaseHealingBonus(SPELL_SCHOOL_MASK_ALL)); - // Get damage bonus for all schools - for(int i = SPELL_SCHOOL_HOLY; i < MAX_SPELL_SCHOOL; i++) - SetStatInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS+i, SpellBaseDamageBonus(SpellSchoolMask(1 << i))); -} - -bool Player::UpdateAllStats() -{ - for (int i = STAT_STRENGTH; i < MAX_STATS; i++) - { - float value = GetTotalStatValue(Stats(i)); - SetStat(Stats(i), (int32)value); - } - - UpdateAttackPowerAndDamage(); - UpdateAttackPowerAndDamage(true); - UpdateArmor(); - UpdateMaxHealth(); - - for(int i = POWER_MANA; i < MAX_POWERS; i++) - UpdateMaxPower(Powers(i)); - - UpdateAllCritPercentages(); - UpdateAllSpellCritChances(); - UpdateDefenseBonusesMod(); - UpdateShieldBlockValue(); - UpdateSpellDamageAndHealingBonus(); - UpdateManaRegen(); - UpdateExpertise(BASE_ATTACK); - UpdateExpertise(OFF_ATTACK); - for (int i = SPELL_SCHOOL_NORMAL; i < MAX_SPELL_SCHOOL; i++) - UpdateResistances(i); - - return true; -} - -void Player::UpdateResistances(uint32 school) -{ - if(school > SPELL_SCHOOL_NORMAL) - { - float value = GetTotalAuraModValue(UnitMods(UNIT_MOD_RESISTANCE_START + school)); - SetResistance(SpellSchools(school), int32(value)); - - Pet *pet = GetPet(); - if(pet) - pet->UpdateResistances(school); - } - else - UpdateArmor(); -} - -void Player::UpdateArmor() -{ - float value = 0.0f; - UnitMods unitMod = UNIT_MOD_ARMOR; - - value = GetModifierValue(unitMod, BASE_VALUE); // base armor (from items) - value *= GetModifierValue(unitMod, BASE_PCT); // armor percent from items - value += GetStat(STAT_AGILITY) * 2.0f; // armor bonus from stats - value += GetModifierValue(unitMod, TOTAL_VALUE); - - //add dynamic flat mods - AuraList const& mResbyIntellect = GetAurasByType(SPELL_AURA_MOD_RESISTANCE_OF_STAT_PERCENT); - for(AuraList::const_iterator i = mResbyIntellect.begin();i != mResbyIntellect.end(); ++i) - { - Modifier* mod = (*i)->GetModifier(); - if(mod->m_miscvalue & SPELL_SCHOOL_MASK_NORMAL) - value += int32(GetStat(Stats((*i)->GetMiscBValue())) * mod->m_amount / 100.0f); - } - - value *= GetModifierValue(unitMod, TOTAL_PCT); - - SetArmor(int32(value)); - - Pet *pet = GetPet(); - if(pet) - pet->UpdateArmor(); -} - -float Player::GetHealthBonusFromStamina() -{ - float stamina = GetStat(STAT_STAMINA); - - float baseStam = stamina < 20 ? stamina : 20; - float moreStam = stamina - baseStam; - - return baseStam + (moreStam*10.0f); -} - -float Player::GetManaBonusFromIntellect() -{ - float intellect = GetStat(STAT_INTELLECT); - - float baseInt = intellect < 20 ? intellect : 20; - float moreInt = intellect - baseInt; - - return baseInt + (moreInt*15.0f); -} - -void Player::UpdateMaxHealth() -{ - UnitMods unitMod = UNIT_MOD_HEALTH; - - float value = GetModifierValue(unitMod, BASE_VALUE) + GetCreateHealth(); - value *= GetModifierValue(unitMod, BASE_PCT); - value += GetModifierValue(unitMod, TOTAL_VALUE) + GetHealthBonusFromStamina(); - value *= GetModifierValue(unitMod, TOTAL_PCT); - - SetMaxHealth((uint32)value); -} - -void Player::UpdateMaxPower(Powers power) -{ - UnitMods unitMod = UnitMods(UNIT_MOD_POWER_START + power); - - float bonusPower = (power == POWER_MANA) ? GetManaBonusFromIntellect() : 0; - - float value = GetModifierValue(unitMod, BASE_VALUE) + GetCreatePowers(power); - value *= GetModifierValue(unitMod, BASE_PCT); - value += GetModifierValue(unitMod, TOTAL_VALUE) + bonusPower; - value *= GetModifierValue(unitMod, TOTAL_PCT); - - SetMaxPower(power, uint32(value)); -} - -void Player::UpdateAttackPowerAndDamage(bool ranged ) -{ - float val2 = 0.0f; - float level = float(getLevel()); - - UnitMods unitMod = ranged ? UNIT_MOD_ATTACK_POWER_RANGED : UNIT_MOD_ATTACK_POWER; - - uint16 index = UNIT_FIELD_ATTACK_POWER; - uint16 index_mod = UNIT_FIELD_ATTACK_POWER_MODS; - uint16 index_mult = UNIT_FIELD_ATTACK_POWER_MULTIPLIER; - - if(ranged) - { - index = UNIT_FIELD_RANGED_ATTACK_POWER; - index_mod = UNIT_FIELD_RANGED_ATTACK_POWER_MODS; - index_mult = UNIT_FIELD_RANGED_ATTACK_POWER_MULTIPLIER; - - switch(getClass()) - { - case CLASS_HUNTER: val2 = level * 2.0f + GetStat(STAT_AGILITY) - 10.0f; break; - case CLASS_ROGUE: val2 = level + GetStat(STAT_AGILITY) - 10.0f; break; - case CLASS_WARRIOR:val2 = level + GetStat(STAT_AGILITY) - 10.0f; break; - case CLASS_DRUID: - switch(m_form) - { - case FORM_CAT: - case FORM_BEAR: - case FORM_DIREBEAR: - val2 = 0.0f; break; - default: - val2 = GetStat(STAT_AGILITY) - 10.0f; break; - } - break; - default: val2 = GetStat(STAT_AGILITY) - 10.0f; break; - } - } - else - { - switch(getClass()) - { - case CLASS_WARRIOR: val2 = level*3.0f + GetStat(STAT_STRENGTH)*2.0f - 20.0f; break; - case CLASS_PALADIN: val2 = level*3.0f + GetStat(STAT_STRENGTH)*2.0f - 20.0f; break; - case CLASS_ROGUE: val2 = level*2.0f + GetStat(STAT_STRENGTH) + GetStat(STAT_AGILITY) - 20.0f; break; - case CLASS_HUNTER: val2 = level*2.0f + GetStat(STAT_STRENGTH) + GetStat(STAT_AGILITY) - 20.0f; break; - case CLASS_SHAMAN: val2 = level*2.0f + GetStat(STAT_STRENGTH)*2.0f - 20.0f; break; - case CLASS_DRUID: - { - //Check if Predatory Strikes is skilled - float mLevelMult = 0.0; - switch(m_form) - { - case FORM_CAT: - case FORM_BEAR: - case FORM_DIREBEAR: - case FORM_MOONKIN: - { - Unit::AuraList const& mDummy = GetAurasByType(SPELL_AURA_DUMMY); - for(Unit::AuraList::const_iterator itr = mDummy.begin(); itr != mDummy.end(); ++itr) - { - // Predatory Strikes - if ((*itr)->GetSpellProto()->SpellIconID == 1563) - { - mLevelMult = (*itr)->GetModifier()->m_amount / 100.0f; - break; - } - } - break; - } - } - - switch(m_form) - { - case FORM_CAT: - val2 = getLevel()*(mLevelMult+2.0f) + GetStat(STAT_STRENGTH)*2.0f + GetStat(STAT_AGILITY) - 20.0f; break; - case FORM_BEAR: - case FORM_DIREBEAR: - val2 = getLevel()*(mLevelMult+3.0f) + GetStat(STAT_STRENGTH)*2.0f - 20.0f; break; - case FORM_MOONKIN: - val2 = getLevel()*(mLevelMult+1.5f) + GetStat(STAT_STRENGTH)*2.0f - 20.0f; break; - default: - val2 = GetStat(STAT_STRENGTH)*2.0f - 20.0f; break; - } - break; - } - case CLASS_MAGE: val2 = GetStat(STAT_STRENGTH) - 10.0f; break; - case CLASS_PRIEST: val2 = GetStat(STAT_STRENGTH) - 10.0f; break; - case CLASS_WARLOCK: val2 = GetStat(STAT_STRENGTH) - 10.0f; break; - } - } - - SetModifierValue(unitMod, BASE_VALUE, val2); - - float base_attPower = GetModifierValue(unitMod, BASE_VALUE) * GetModifierValue(unitMod, BASE_PCT); - float attPowerMod = GetModifierValue(unitMod, TOTAL_VALUE); - - //add dynamic flat mods - if( ranged && (getClassMask() & CLASSMASK_WAND_USERS)==0) - { - AuraList const& mRAPbyIntellect = GetAurasByType(SPELL_AURA_MOD_RANGED_ATTACK_POWER_OF_STAT_PERCENT); - for(AuraList::const_iterator i = mRAPbyIntellect.begin();i != mRAPbyIntellect.end(); ++i) - attPowerMod += int32(GetStat(Stats((*i)->GetModifier()->m_miscvalue)) * (*i)->GetModifier()->m_amount / 100.0f); - } - - float attPowerMultiplier = GetModifierValue(unitMod, TOTAL_PCT) - 1.0f; - - SetUInt32Value(index, (uint32)base_attPower); //UNIT_FIELD_(RANGED)_ATTACK_POWER field - SetUInt32Value(index_mod, (uint32)attPowerMod); //UNIT_FIELD_(RANGED)_ATTACK_POWER_MODS field - SetFloatValue(index_mult, attPowerMultiplier); //UNIT_FIELD_(RANGED)_ATTACK_POWER_MULTIPLIER field - - //automatically update weapon damage after attack power modification - if(ranged) - { - UpdateDamagePhysical(RANGED_ATTACK); - - Pet *pet = GetPet(); //update pet's AP - if(pet) - pet->UpdateAttackPowerAndDamage(); - } - else - { - UpdateDamagePhysical(BASE_ATTACK); - if(CanDualWield() && haveOffhandWeapon()) //allow update offhand damage only if player knows DualWield Spec and has equipped offhand weapon - UpdateDamagePhysical(OFF_ATTACK); - } -} - -void Player::UpdateShieldBlockValue() -{ - SetUInt32Value(PLAYER_SHIELD_BLOCK, GetShieldBlockValue()); -} - -void Player::CalculateMinMaxDamage(WeaponAttackType attType, bool normalized, float& min_damage, float& max_damage) -{ - UnitMods unitMod; - UnitMods attPower; - - switch(attType) - { - case BASE_ATTACK: - default: - unitMod = UNIT_MOD_DAMAGE_MAINHAND; - attPower = UNIT_MOD_ATTACK_POWER; - break; - case OFF_ATTACK: - unitMod = UNIT_MOD_DAMAGE_OFFHAND; - attPower = UNIT_MOD_ATTACK_POWER; - break; - case RANGED_ATTACK: - unitMod = UNIT_MOD_DAMAGE_RANGED; - attPower = UNIT_MOD_ATTACK_POWER_RANGED; - break; - } - - float att_speed = GetAPMultiplier(attType,normalized); - - float base_value = GetModifierValue(unitMod, BASE_VALUE) + GetTotalAttackPowerValue(attType)/ 14.0f * att_speed; - float base_pct = GetModifierValue(unitMod, BASE_PCT); - float total_value = GetModifierValue(unitMod, TOTAL_VALUE); - float total_pct = GetModifierValue(unitMod, TOTAL_PCT); - - float weapon_mindamage = GetWeaponDamageRange(attType, MINDAMAGE); - float weapon_maxdamage = GetWeaponDamageRange(attType, MAXDAMAGE); - - if (IsInFeralForm()) //check if player is druid and in cat or bear forms - { - uint32 lvl = getLevel(); - if ( lvl > 60 ) lvl = 60; - - weapon_mindamage = lvl*0.85*att_speed; - weapon_maxdamage = lvl*1.25*att_speed; - } - else if(!IsUseEquipedWeapon(attType==BASE_ATTACK)) //check if player not in form but still can't use weapon (broken/etc) - { - weapon_mindamage = BASE_MINDAMAGE; - weapon_maxdamage = BASE_MAXDAMAGE; - } - else if(attType == RANGED_ATTACK) //add ammo DPS to ranged damage - { - weapon_mindamage += GetAmmoDPS() * att_speed; - weapon_maxdamage += GetAmmoDPS() * att_speed; - } - - min_damage = ((base_value + weapon_mindamage) * base_pct + total_value) * total_pct; - max_damage = ((base_value + weapon_maxdamage) * base_pct + total_value) * total_pct; -} - -void Player::UpdateDamagePhysical(WeaponAttackType attType) -{ - float mindamage; - float maxdamage; - - CalculateMinMaxDamage(attType,false,mindamage,maxdamage); - - switch(attType) - { - case BASE_ATTACK: - default: - SetStatFloatValue(UNIT_FIELD_MINDAMAGE,mindamage); - SetStatFloatValue(UNIT_FIELD_MAXDAMAGE,maxdamage); - break; - case OFF_ATTACK: - SetStatFloatValue(UNIT_FIELD_MINOFFHANDDAMAGE,mindamage); - SetStatFloatValue(UNIT_FIELD_MAXOFFHANDDAMAGE,maxdamage); - break; - case RANGED_ATTACK: - SetStatFloatValue(UNIT_FIELD_MINRANGEDDAMAGE,mindamage); - SetStatFloatValue(UNIT_FIELD_MAXRANGEDDAMAGE,maxdamage); - break; - } -} - -void Player::UpdateDefenseBonusesMod() -{ - UpdateBlockPercentage(); - UpdateParryPercentage(); - UpdateDodgePercentage(); -} - -void Player::UpdateBlockPercentage() -{ - // Base value - float value = 5.0f; - // Modify value from defense skill - value += (int32(GetDefenseSkillValue()) - int32(GetMaxSkillValueForLevel())) * 0.04f; - // Increase from SPELL_AURA_MOD_BLOCK_PERCENT aura - value += GetTotalAuraModifier(SPELL_AURA_MOD_BLOCK_PERCENT); - // Increase from rating - value += GetRatingBonusValue(CR_BLOCK); - value = value < 0.0f ? 0.0f : value; - SetStatFloatValue(PLAYER_BLOCK_PERCENTAGE, value); -} - -void Player::UpdateCritPercentage(WeaponAttackType attType) -{ - BaseModGroup modGroup; - uint16 index; - CombatRating cr; - - switch(attType) - { - case OFF_ATTACK: - modGroup = OFFHAND_CRIT_PERCENTAGE; - index = PLAYER_OFFHAND_CRIT_PERCENTAGE; - cr = CR_CRIT_MELEE; - break; - case RANGED_ATTACK: - modGroup = RANGED_CRIT_PERCENTAGE; - index = PLAYER_RANGED_CRIT_PERCENTAGE; - cr = CR_CRIT_RANGED; - break; - case BASE_ATTACK: - default: - modGroup = CRIT_PERCENTAGE; - index = PLAYER_CRIT_PERCENTAGE; - cr = CR_CRIT_MELEE; - break; - } - - float value = GetTotalPercentageModValue(modGroup) + GetRatingBonusValue(cr); - // Modify crit from weapon skill and maximized defense skill of same level victim difference - value += (int32(GetWeaponSkillValue(attType)) - int32(GetMaxSkillValueForLevel())) * 0.04f; - value = value < 0.0f ? 0.0f : value; - SetStatFloatValue(index, value); -} - -void Player::UpdateAllCritPercentages() -{ - float value = GetMeleeCritFromAgility(); - - SetBaseModValue(CRIT_PERCENTAGE, PCT_MOD, value); - SetBaseModValue(OFFHAND_CRIT_PERCENTAGE, PCT_MOD, value); - SetBaseModValue(RANGED_CRIT_PERCENTAGE, PCT_MOD, value); - - UpdateCritPercentage(BASE_ATTACK); - UpdateCritPercentage(OFF_ATTACK); - UpdateCritPercentage(RANGED_ATTACK); -} - -void Player::UpdateParryPercentage() -{ - // Base parry - float value = 5.0f; - // Modify value from defense skill - value += (int32(GetDefenseSkillValue()) - int32(GetMaxSkillValueForLevel())) * 0.04f; - // Parry from SPELL_AURA_MOD_PARRY_PERCENT aura - value += GetTotalAuraModifier(SPELL_AURA_MOD_PARRY_PERCENT); - // Parry from rating - value += GetRatingBonusValue(CR_PARRY); - value = value < 0.0f ? 0.0f : value; - SetStatFloatValue(PLAYER_PARRY_PERCENTAGE, value); -} - -void Player::UpdateDodgePercentage() -{ - // Dodge from agility - float value = GetDodgeFromAgility(); - // Modify value from defense skill - value += (int32(GetDefenseSkillValue()) - int32(GetMaxSkillValueForLevel())) * 0.04f; - // Dodge from SPELL_AURA_MOD_DODGE_PERCENT aura - value += GetTotalAuraModifier(SPELL_AURA_MOD_DODGE_PERCENT); - // Dodge from rating - value += GetRatingBonusValue(CR_DODGE); - value = value < 0.0f ? 0.0f : value; - SetStatFloatValue(PLAYER_DODGE_PERCENTAGE, value); -} - -void Player::UpdateSpellCritChance(uint32 school) -{ - // For normal school set zero crit chance - if(school == SPELL_SCHOOL_NORMAL) - { - SetFloatValue(PLAYER_SPELL_CRIT_PERCENTAGE1, 0.0f); - return; - } - // For others recalculate it from: - float crit = 0.0f; - // Crit from Intellect - crit += GetSpellCritFromIntellect(); - // Increase crit from SPELL_AURA_MOD_SPELL_CRIT_CHANCE - crit += GetTotalAuraModifier(SPELL_AURA_MOD_SPELL_CRIT_CHANCE); - // Increase crit by school from SPELL_AURA_MOD_SPELL_CRIT_CHANCE_SCHOOL - crit += GetTotalAuraModifierByMiscMask(SPELL_AURA_MOD_SPELL_CRIT_CHANCE_SCHOOL, 1<GetSpellProto()->EquippedItemClass == -1) - expertise += (*itr)->GetModifier()->m_amount; - // item dependent spell - else if(weapon && weapon->IsFitToSpellRequirements((*itr)->GetSpellProto())) - expertise += (*itr)->GetModifier()->m_amount; - } - - if(expertise < 0) - expertise = 0; - - switch(attack) - { - case BASE_ATTACK: SetUInt32Value(PLAYER_EXPERTISE, expertise); break; - case OFF_ATTACK: SetUInt32Value(PLAYER_OFFHAND_EXPERTISE, expertise); break; - default: break; - } -} - -void Player::UpdateManaRegen() -{ - float Intellect = GetStat(STAT_INTELLECT); - // Mana regen from spirit and intellect - float power_regen = sqrt(Intellect) * OCTRegenMPPerSpirit(); - // Apply PCT bonus from SPELL_AURA_MOD_POWER_REGEN_PERCENT aura on spirit base regen - power_regen *= GetTotalAuraMultiplierByMiscValue(SPELL_AURA_MOD_POWER_REGEN_PERCENT, POWER_MANA); - - // Mana regen from SPELL_AURA_MOD_POWER_REGEN aura - float power_regen_mp5 = GetTotalAuraModifierByMiscValue(SPELL_AURA_MOD_POWER_REGEN, POWER_MANA) / 5.0f; - - // Get bonus from SPELL_AURA_MOD_MANA_REGEN_FROM_STAT aura - AuraList const& regenAura = GetAurasByType(SPELL_AURA_MOD_MANA_REGEN_FROM_STAT); - for(AuraList::const_iterator i = regenAura.begin();i != regenAura.end(); ++i) - { - Modifier* mod = (*i)->GetModifier(); - power_regen_mp5 += GetStat(Stats(mod->m_miscvalue)) * mod->m_amount / 500.0f; - } - - // Bonus from some dummy auras - AuraList const& mDummyAuras = GetAurasByType(SPELL_AURA_PERIODIC_DUMMY); - for(AuraList::const_iterator i = mDummyAuras.begin();i != mDummyAuras.end(); ++i) - if((*i)->GetId() == 34074) // Aspect of the Viper - { - power_regen_mp5 += (*i)->GetModifier()->m_amount * Intellect / 500.0f; - // Add regen bonus from level in this dummy - power_regen_mp5 += getLevel() * 35 / 100; - } - - // Set regen rate in cast state apply only on spirit based regen - int32 modManaRegenInterrupt = GetTotalAuraModifier(SPELL_AURA_MOD_MANA_REGEN_INTERRUPT); - if (modManaRegenInterrupt > 100) - modManaRegenInterrupt = 100; - SetStatFloatValue(PLAYER_FIELD_MOD_MANA_REGEN_INTERRUPT, power_regen_mp5 + power_regen * modManaRegenInterrupt / 100.0f); - - SetStatFloatValue(PLAYER_FIELD_MOD_MANA_REGEN, power_regen_mp5 + power_regen); -} - -void Player::_ApplyAllStatBonuses() -{ - SetCanModifyStats(false); - - _ApplyAllAuraMods(); - _ApplyAllItemMods(); - - SetCanModifyStats(true); - - UpdateAllStats(); -} - -void Player::_RemoveAllStatBonuses() -{ - SetCanModifyStats(false); - - _RemoveAllItemMods(); - _RemoveAllAuraMods(); - - SetCanModifyStats(true); - - UpdateAllStats(); -} - -/*####################################### -######## ######## -######## MOBS STAT SYSTEM ######## -######## ######## -#######################################*/ - -bool Creature::UpdateStats(Stats /*stat*/) -{ - return true; -} - -bool Creature::UpdateAllStats() -{ - UpdateMaxHealth(); - UpdateAttackPowerAndDamage(); - - for(int i = POWER_MANA; i < MAX_POWERS; ++i) - UpdateMaxPower(Powers(i)); - - for(int i = SPELL_SCHOOL_NORMAL; i < MAX_SPELL_SCHOOL; ++i) - UpdateResistances(i); - - return true; -} - -void Creature::UpdateResistances(uint32 school) -{ - if(school > SPELL_SCHOOL_NORMAL) - { - float value = GetTotalAuraModValue(UnitMods(UNIT_MOD_RESISTANCE_START + school)); - SetResistance(SpellSchools(school), int32(value)); - } - else - UpdateArmor(); -} - -void Creature::UpdateArmor() -{ - float value = GetTotalAuraModValue(UNIT_MOD_ARMOR); - SetArmor(int32(value)); -} - -void Creature::UpdateMaxHealth() -{ - float value = GetTotalAuraModValue(UNIT_MOD_HEALTH); - SetMaxHealth((uint32)value); -} - -void Creature::UpdateMaxPower(Powers power) -{ - UnitMods unitMod = UnitMods(UNIT_MOD_POWER_START + power); - - float value = GetTotalAuraModValue(unitMod); - SetMaxPower(power, uint32(value)); -} - -void Creature::UpdateAttackPowerAndDamage(bool ranged) -{ - if(ranged) - return; - - //automatically update weapon damage after attack power modification - UpdateDamagePhysical(BASE_ATTACK); -} - -void Creature::UpdateDamagePhysical(WeaponAttackType attType) -{ - if(attType > BASE_ATTACK) - return; - - UnitMods unitMod = UNIT_MOD_DAMAGE_MAINHAND; - - float att_speed = float(GetAttackTime(BASE_ATTACK))/1000.0f; - - float base_value = GetModifierValue(unitMod, BASE_VALUE) + GetTotalAttackPowerValue(attType)/ 14.0f * att_speed; - float base_pct = GetModifierValue(unitMod, BASE_PCT); - float total_value = GetModifierValue(unitMod, TOTAL_VALUE); - float total_pct = GetModifierValue(unitMod, TOTAL_PCT); - - float weapon_mindamage = GetWeaponDamageRange(BASE_ATTACK, MINDAMAGE); - float weapon_maxdamage = GetWeaponDamageRange(BASE_ATTACK, MAXDAMAGE); - - float mindamage = ((base_value + weapon_mindamage) * base_pct + total_value) * total_pct ; - float maxdamage = ((base_value + weapon_maxdamage) * base_pct + total_value) * total_pct ; - - SetStatFloatValue(UNIT_FIELD_MINDAMAGE, mindamage); - SetStatFloatValue(UNIT_FIELD_MAXDAMAGE, maxdamage); -} - -/*####################################### -######## ######## -######## PETS STAT SYSTEM ######## -######## ######## -#######################################*/ - -bool Pet::UpdateStats(Stats stat) -{ - if(stat > STAT_SPIRIT) - return false; - - // value = ((base_value * base_pct) + total_value) * total_pct - float value = GetTotalStatValue(stat); - - Unit *owner = GetOwner(); - if ( stat == STAT_STAMINA ) - { - if(owner) - value += float(owner->GetStat(stat)) * 0.3f; - } - //warlock's and mage's pets gain 30% of owner's intellect - else if ( stat == STAT_INTELLECT && getPetType() == SUMMON_PET ) - { - if(owner && (owner->getClass() == CLASS_WARLOCK || owner->getClass() == CLASS_MAGE) ) - value += float(owner->GetStat(stat)) * 0.3f; - } - - SetStat(stat, int32(value)); - - switch(stat) - { - case STAT_STRENGTH: UpdateAttackPowerAndDamage(); break; - case STAT_AGILITY: UpdateArmor(); break; - case STAT_STAMINA: UpdateMaxHealth(); break; - case STAT_INTELLECT: UpdateMaxPower(POWER_MANA); break; - case STAT_SPIRIT: - default: - break; - } - - return true; -} - -bool Pet::UpdateAllStats() -{ - for (int i = STAT_STRENGTH; i < MAX_STATS; i++) - UpdateStats(Stats(i)); - - for(int i = POWER_MANA; i < MAX_POWERS; i++) - UpdateMaxPower(Powers(i)); - - for (int i = SPELL_SCHOOL_NORMAL; i < MAX_SPELL_SCHOOL; i++) - UpdateResistances(i); - - return true; -} - -void Pet::UpdateResistances(uint32 school) -{ - if(school > SPELL_SCHOOL_NORMAL) - { - float value = GetTotalAuraModValue(UnitMods(UNIT_MOD_RESISTANCE_START + school)); - - Unit *owner = GetOwner(); - // hunter and warlock pets gain 40% of owner's resistance - if(owner && (getPetType() == HUNTER_PET || getPetType() == SUMMON_PET && owner->getClass() == CLASS_WARLOCK)) - value += float(owner->GetResistance(SpellSchools(school))) * 0.4f; - - SetResistance(SpellSchools(school), int32(value)); - } - else - UpdateArmor(); -} - -void Pet::UpdateArmor() -{ - float value = 0.0f; - float bonus_armor = 0.0f; - UnitMods unitMod = UNIT_MOD_ARMOR; - - Unit *owner = GetOwner(); - // hunter and warlock pets gain 35% of owner's armor value - if(owner && (getPetType() == HUNTER_PET || getPetType() == SUMMON_PET && owner->getClass() == CLASS_WARLOCK)) - bonus_armor = 0.35f * float(owner->GetArmor()); - - value = GetModifierValue(unitMod, BASE_VALUE); - value *= GetModifierValue(unitMod, BASE_PCT); - value += GetStat(STAT_AGILITY) * 2.0f; - value += GetModifierValue(unitMod, TOTAL_VALUE) + bonus_armor; - value *= GetModifierValue(unitMod, TOTAL_PCT); - - SetArmor(int32(value)); -} - -void Pet::UpdateMaxHealth() -{ - UnitMods unitMod = UNIT_MOD_HEALTH; - float stamina = GetStat(STAT_STAMINA) - GetCreateStat(STAT_STAMINA); - - float value = GetModifierValue(unitMod, BASE_VALUE) + GetCreateHealth(); - value *= GetModifierValue(unitMod, BASE_PCT); - value += GetModifierValue(unitMod, TOTAL_VALUE) + stamina * 10.0f; - value *= GetModifierValue(unitMod, TOTAL_PCT); - - SetMaxHealth((uint32)value); -} - -void Pet::UpdateMaxPower(Powers power) -{ - UnitMods unitMod = UnitMods(UNIT_MOD_POWER_START + power); - float addValue = (power == POWER_MANA) ? GetStat(STAT_INTELLECT) - GetCreateStat(STAT_INTELLECT) : 0.0f; - - float value = GetModifierValue(unitMod, BASE_VALUE) + GetCreatePowers(power); - value *= GetModifierValue(unitMod, BASE_PCT); - value += GetModifierValue(unitMod, TOTAL_VALUE) + addValue * 15.0f; - value *= GetModifierValue(unitMod, TOTAL_PCT); - - SetMaxPower(power, uint32(value)); -} - -void Pet::UpdateAttackPowerAndDamage(bool ranged) -{ - if(ranged) - return; - - float val = 0.0f; - float bonusAP = 0.0f; - UnitMods unitMod = UNIT_MOD_ATTACK_POWER; - - if(GetEntry() == 416) // imp's attack power - val = GetStat(STAT_STRENGTH) - 10.0f; - else - val = 2 * GetStat(STAT_STRENGTH) - 20.0f; - - Unit* owner = GetOwner(); - if( owner && owner->GetTypeId()==TYPEID_PLAYER) - { - if(getPetType() == HUNTER_PET) //hunter pets benefit from owner's attack power - { - bonusAP = owner->GetTotalAttackPowerValue(RANGED_ATTACK) * 0.22f; - SetBonusDamage( int32(owner->GetTotalAttackPowerValue(RANGED_ATTACK) * 0.125f)); - } - //demons benefit from warlocks shadow or fire damage - else if(getPetType() == SUMMON_PET && owner->getClass() == CLASS_WARLOCK) - { - int32 fire = int32(owner->GetUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS + SPELL_SCHOOL_FIRE)) - owner->GetUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_NEG + SPELL_SCHOOL_FIRE); - int32 shadow = int32(owner->GetUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS + SPELL_SCHOOL_SHADOW)) - owner->GetUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_NEG + SPELL_SCHOOL_SHADOW); - int32 maximum = (fire > shadow) ? fire : shadow; - if(maximum < 0) - maximum = 0; - SetBonusDamage( int32(maximum * 0.15f)); - bonusAP = maximum * 0.57f; - } - //water elementals benefit from mage's frost damage - else if(getPetType() == SUMMON_PET && owner->getClass() == CLASS_MAGE) - { - int32 frost = int32(owner->GetUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS + SPELL_SCHOOL_FROST)) - owner->GetUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_NEG + SPELL_SCHOOL_FROST); - if(frost < 0) - frost = 0; - SetBonusDamage( int32(frost * 0.4f)); - } - } - - SetModifierValue(UNIT_MOD_ATTACK_POWER, BASE_VALUE, val + bonusAP); - - //in BASE_VALUE of UNIT_MOD_ATTACK_POWER for creatures we store data of meleeattackpower field in DB - float base_attPower = GetModifierValue(unitMod, BASE_VALUE) * GetModifierValue(unitMod, BASE_PCT); - float attPowerMod = GetModifierValue(unitMod, TOTAL_VALUE); - float attPowerMultiplier = GetModifierValue(unitMod, TOTAL_PCT) - 1.0f; - - //UNIT_FIELD_(RANGED)_ATTACK_POWER field - SetUInt32Value(UNIT_FIELD_ATTACK_POWER, (uint32)base_attPower); - //UNIT_FIELD_(RANGED)_ATTACK_POWER_MODS field - SetUInt32Value(UNIT_FIELD_ATTACK_POWER_MODS, (uint32)attPowerMod); - //UNIT_FIELD_(RANGED)_ATTACK_POWER_MULTIPLIER field - SetFloatValue(UNIT_FIELD_ATTACK_POWER_MULTIPLIER, attPowerMultiplier); - - //automatically update weapon damage after attack power modification - UpdateDamagePhysical(BASE_ATTACK); -} - -void Pet::UpdateDamagePhysical(WeaponAttackType attType) -{ - if(attType > BASE_ATTACK) - return; - - UnitMods unitMod = UNIT_MOD_DAMAGE_MAINHAND; - - float att_speed = float(GetAttackTime(BASE_ATTACK))/1000.0f; - - float base_value = GetModifierValue(unitMod, BASE_VALUE) + GetTotalAttackPowerValue(attType)/ 14.0f * att_speed; - float base_pct = GetModifierValue(unitMod, BASE_PCT); - float total_value = GetModifierValue(unitMod, TOTAL_VALUE); - float total_pct = GetModifierValue(unitMod, TOTAL_PCT); - - float weapon_mindamage = GetWeaponDamageRange(BASE_ATTACK, MINDAMAGE); - float weapon_maxdamage = GetWeaponDamageRange(BASE_ATTACK, MAXDAMAGE); - - float mindamage = ((base_value + weapon_mindamage) * base_pct + total_value) * total_pct; - float maxdamage = ((base_value + weapon_maxdamage) * base_pct + total_value) * total_pct; - - // Pet's base damage changes depending on happiness - if (getPetType() == HUNTER_PET && attType == BASE_ATTACK) - { - switch(GetHappinessState()) - { - case HAPPY: - // 125% of normal damage - mindamage = mindamage * 1.25; - maxdamage = maxdamage * 1.25; - break; - case CONTENT: - // 100% of normal damage, nothing to modify - break; - case UNHAPPY: - // 75% of normal damage - mindamage = mindamage * 0.75; - maxdamage = maxdamage * 0.75; - break; - } - } - - SetStatFloatValue(UNIT_FIELD_MINDAMAGE, mindamage); - SetStatFloatValue(UNIT_FIELD_MAXDAMAGE, maxdamage); -} +/* + * Copyright (C) 2005-2008 MaNGOS + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "Unit.h" +#include "Player.h" +#include "Pet.h" +#include "Creature.h" +#include "SharedDefines.h" +#include "SpellAuras.h" + +/*####################################### +######## ######## +######## PLAYERS STAT SYSTEM ######## +######## ######## +#######################################*/ + +bool Player::UpdateStats(Stats stat) +{ + if(stat > STAT_SPIRIT) + return false; + + // value = ((base_value * base_pct) + total_value) * total_pct + float value = GetTotalStatValue(stat); + + SetStat(stat, int32(value)); + + if(stat == STAT_STAMINA || stat == STAT_INTELLECT) + { + Pet *pet = GetPet(); + if(pet) + pet->UpdateStats(stat); + } + + switch(stat) + { + case STAT_STRENGTH: + UpdateAttackPowerAndDamage(); + UpdateShieldBlockValue(); + break; + case STAT_AGILITY: + UpdateArmor(); + UpdateAttackPowerAndDamage(true); + if(getClass() == CLASS_ROGUE || getClass() == CLASS_HUNTER || getClass() == CLASS_DRUID && m_form==FORM_CAT) + UpdateAttackPowerAndDamage(); + + UpdateAllCritPercentages(); + UpdateDodgePercentage(); + break; + + case STAT_STAMINA: UpdateMaxHealth(); break; + case STAT_INTELLECT: + UpdateMaxPower(POWER_MANA); + UpdateAllSpellCritChances(); + UpdateAttackPowerAndDamage(true); //SPELL_AURA_MOD_RANGED_ATTACK_POWER_OF_STAT_PERCENT, only intelect currently + UpdateArmor(); //SPELL_AURA_MOD_RESISTANCE_OF_INTELLECT_PERCENT, only armor currently + break; + + case STAT_SPIRIT: + break; + + default: + break; + } + UpdateSpellDamageAndHealingBonus(); + UpdateManaRegen(); + return true; +} + +void Player::UpdateSpellDamageAndHealingBonus() +{ + // Magic damage modifiers implemented in Unit::SpellDamageBonus + // This information for client side use only + // Get healing bonus for all schools + SetStatInt32Value(PLAYER_FIELD_MOD_HEALING_DONE_POS, SpellBaseHealingBonus(SPELL_SCHOOL_MASK_ALL)); + // Get damage bonus for all schools + for(int i = SPELL_SCHOOL_HOLY; i < MAX_SPELL_SCHOOL; i++) + SetStatInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS+i, SpellBaseDamageBonus(SpellSchoolMask(1 << i))); +} + +bool Player::UpdateAllStats() +{ + for (int i = STAT_STRENGTH; i < MAX_STATS; i++) + { + float value = GetTotalStatValue(Stats(i)); + SetStat(Stats(i), (int32)value); + } + + UpdateAttackPowerAndDamage(); + UpdateAttackPowerAndDamage(true); + UpdateArmor(); + UpdateMaxHealth(); + + for(int i = POWER_MANA; i < MAX_POWERS; i++) + UpdateMaxPower(Powers(i)); + + UpdateAllCritPercentages(); + UpdateAllSpellCritChances(); + UpdateDefenseBonusesMod(); + UpdateShieldBlockValue(); + UpdateSpellDamageAndHealingBonus(); + UpdateManaRegen(); + UpdateExpertise(BASE_ATTACK); + UpdateExpertise(OFF_ATTACK); + for (int i = SPELL_SCHOOL_NORMAL; i < MAX_SPELL_SCHOOL; i++) + UpdateResistances(i); + + return true; +} + +void Player::UpdateResistances(uint32 school) +{ + if(school > SPELL_SCHOOL_NORMAL) + { + float value = GetTotalAuraModValue(UnitMods(UNIT_MOD_RESISTANCE_START + school)); + SetResistance(SpellSchools(school), int32(value)); + + Pet *pet = GetPet(); + if(pet) + pet->UpdateResistances(school); + } + else + UpdateArmor(); +} + +void Player::UpdateArmor() +{ + float value = 0.0f; + UnitMods unitMod = UNIT_MOD_ARMOR; + + value = GetModifierValue(unitMod, BASE_VALUE); // base armor (from items) + value *= GetModifierValue(unitMod, BASE_PCT); // armor percent from items + value += GetStat(STAT_AGILITY) * 2.0f; // armor bonus from stats + value += GetModifierValue(unitMod, TOTAL_VALUE); + + //add dynamic flat mods + AuraList const& mResbyIntellect = GetAurasByType(SPELL_AURA_MOD_RESISTANCE_OF_STAT_PERCENT); + for(AuraList::const_iterator i = mResbyIntellect.begin();i != mResbyIntellect.end(); ++i) + { + Modifier* mod = (*i)->GetModifier(); + if(mod->m_miscvalue & SPELL_SCHOOL_MASK_NORMAL) + value += int32(GetStat(Stats((*i)->GetMiscBValue())) * mod->m_amount / 100.0f); + } + + value *= GetModifierValue(unitMod, TOTAL_PCT); + + SetArmor(int32(value)); + + Pet *pet = GetPet(); + if(pet) + pet->UpdateArmor(); +} + +float Player::GetHealthBonusFromStamina() +{ + float stamina = GetStat(STAT_STAMINA); + + float baseStam = stamina < 20 ? stamina : 20; + float moreStam = stamina - baseStam; + + return baseStam + (moreStam*10.0f); +} + +float Player::GetManaBonusFromIntellect() +{ + float intellect = GetStat(STAT_INTELLECT); + + float baseInt = intellect < 20 ? intellect : 20; + float moreInt = intellect - baseInt; + + return baseInt + (moreInt*15.0f); +} + +void Player::UpdateMaxHealth() +{ + UnitMods unitMod = UNIT_MOD_HEALTH; + + float value = GetModifierValue(unitMod, BASE_VALUE) + GetCreateHealth(); + value *= GetModifierValue(unitMod, BASE_PCT); + value += GetModifierValue(unitMod, TOTAL_VALUE) + GetHealthBonusFromStamina(); + value *= GetModifierValue(unitMod, TOTAL_PCT); + + SetMaxHealth((uint32)value); +} + +void Player::UpdateMaxPower(Powers power) +{ + UnitMods unitMod = UnitMods(UNIT_MOD_POWER_START + power); + + float bonusPower = (power == POWER_MANA) ? GetManaBonusFromIntellect() : 0; + + float value = GetModifierValue(unitMod, BASE_VALUE) + GetCreatePowers(power); + value *= GetModifierValue(unitMod, BASE_PCT); + value += GetModifierValue(unitMod, TOTAL_VALUE) + bonusPower; + value *= GetModifierValue(unitMod, TOTAL_PCT); + + SetMaxPower(power, uint32(value)); +} + +void Player::UpdateAttackPowerAndDamage(bool ranged ) +{ + float val2 = 0.0f; + float level = float(getLevel()); + + UnitMods unitMod = ranged ? UNIT_MOD_ATTACK_POWER_RANGED : UNIT_MOD_ATTACK_POWER; + + uint16 index = UNIT_FIELD_ATTACK_POWER; + uint16 index_mod = UNIT_FIELD_ATTACK_POWER_MODS; + uint16 index_mult = UNIT_FIELD_ATTACK_POWER_MULTIPLIER; + + if(ranged) + { + index = UNIT_FIELD_RANGED_ATTACK_POWER; + index_mod = UNIT_FIELD_RANGED_ATTACK_POWER_MODS; + index_mult = UNIT_FIELD_RANGED_ATTACK_POWER_MULTIPLIER; + + switch(getClass()) + { + case CLASS_HUNTER: val2 = level * 2.0f + GetStat(STAT_AGILITY) - 10.0f; break; + case CLASS_ROGUE: val2 = level + GetStat(STAT_AGILITY) - 10.0f; break; + case CLASS_WARRIOR:val2 = level + GetStat(STAT_AGILITY) - 10.0f; break; + case CLASS_DRUID: + switch(m_form) + { + case FORM_CAT: + case FORM_BEAR: + case FORM_DIREBEAR: + val2 = 0.0f; break; + default: + val2 = GetStat(STAT_AGILITY) - 10.0f; break; + } + break; + default: val2 = GetStat(STAT_AGILITY) - 10.0f; break; + } + } + else + { + switch(getClass()) + { + case CLASS_WARRIOR: val2 = level*3.0f + GetStat(STAT_STRENGTH)*2.0f - 20.0f; break; + case CLASS_PALADIN: val2 = level*3.0f + GetStat(STAT_STRENGTH)*2.0f - 20.0f; break; + case CLASS_ROGUE: val2 = level*2.0f + GetStat(STAT_STRENGTH) + GetStat(STAT_AGILITY) - 20.0f; break; + case CLASS_HUNTER: val2 = level*2.0f + GetStat(STAT_STRENGTH) + GetStat(STAT_AGILITY) - 20.0f; break; + case CLASS_SHAMAN: val2 = level*2.0f + GetStat(STAT_STRENGTH)*2.0f - 20.0f; break; + case CLASS_DRUID: + { + //Check if Predatory Strikes is skilled + float mLevelMult = 0.0; + switch(m_form) + { + case FORM_CAT: + case FORM_BEAR: + case FORM_DIREBEAR: + case FORM_MOONKIN: + { + Unit::AuraList const& mDummy = GetAurasByType(SPELL_AURA_DUMMY); + for(Unit::AuraList::const_iterator itr = mDummy.begin(); itr != mDummy.end(); ++itr) + { + // Predatory Strikes + if ((*itr)->GetSpellProto()->SpellIconID == 1563) + { + mLevelMult = (*itr)->GetModifier()->m_amount / 100.0f; + break; + } + } + break; + } + } + + switch(m_form) + { + case FORM_CAT: + val2 = getLevel()*(mLevelMult+2.0f) + GetStat(STAT_STRENGTH)*2.0f + GetStat(STAT_AGILITY) - 20.0f; break; + case FORM_BEAR: + case FORM_DIREBEAR: + val2 = getLevel()*(mLevelMult+3.0f) + GetStat(STAT_STRENGTH)*2.0f - 20.0f; break; + case FORM_MOONKIN: + val2 = getLevel()*(mLevelMult+1.5f) + GetStat(STAT_STRENGTH)*2.0f - 20.0f; break; + default: + val2 = GetStat(STAT_STRENGTH)*2.0f - 20.0f; break; + } + break; + } + case CLASS_MAGE: val2 = GetStat(STAT_STRENGTH) - 10.0f; break; + case CLASS_PRIEST: val2 = GetStat(STAT_STRENGTH) - 10.0f; break; + case CLASS_WARLOCK: val2 = GetStat(STAT_STRENGTH) - 10.0f; break; + } + } + + SetModifierValue(unitMod, BASE_VALUE, val2); + + float base_attPower = GetModifierValue(unitMod, BASE_VALUE) * GetModifierValue(unitMod, BASE_PCT); + float attPowerMod = GetModifierValue(unitMod, TOTAL_VALUE); + + //add dynamic flat mods + if( ranged && (getClassMask() & CLASSMASK_WAND_USERS)==0) + { + AuraList const& mRAPbyIntellect = GetAurasByType(SPELL_AURA_MOD_RANGED_ATTACK_POWER_OF_STAT_PERCENT); + for(AuraList::const_iterator i = mRAPbyIntellect.begin();i != mRAPbyIntellect.end(); ++i) + attPowerMod += int32(GetStat(Stats((*i)->GetModifier()->m_miscvalue)) * (*i)->GetModifier()->m_amount / 100.0f); + } + + float attPowerMultiplier = GetModifierValue(unitMod, TOTAL_PCT) - 1.0f; + + SetUInt32Value(index, (uint32)base_attPower); //UNIT_FIELD_(RANGED)_ATTACK_POWER field + SetUInt32Value(index_mod, (uint32)attPowerMod); //UNIT_FIELD_(RANGED)_ATTACK_POWER_MODS field + SetFloatValue(index_mult, attPowerMultiplier); //UNIT_FIELD_(RANGED)_ATTACK_POWER_MULTIPLIER field + + //automatically update weapon damage after attack power modification + if(ranged) + { + UpdateDamagePhysical(RANGED_ATTACK); + + Pet *pet = GetPet(); //update pet's AP + if(pet) + pet->UpdateAttackPowerAndDamage(); + } + else + { + UpdateDamagePhysical(BASE_ATTACK); + if(CanDualWield() && haveOffhandWeapon()) //allow update offhand damage only if player knows DualWield Spec and has equipped offhand weapon + UpdateDamagePhysical(OFF_ATTACK); + } +} + +void Player::UpdateShieldBlockValue() +{ + SetUInt32Value(PLAYER_SHIELD_BLOCK, GetShieldBlockValue()); +} + +void Player::CalculateMinMaxDamage(WeaponAttackType attType, bool normalized, float& min_damage, float& max_damage) +{ + UnitMods unitMod; + UnitMods attPower; + + switch(attType) + { + case BASE_ATTACK: + default: + unitMod = UNIT_MOD_DAMAGE_MAINHAND; + attPower = UNIT_MOD_ATTACK_POWER; + break; + case OFF_ATTACK: + unitMod = UNIT_MOD_DAMAGE_OFFHAND; + attPower = UNIT_MOD_ATTACK_POWER; + break; + case RANGED_ATTACK: + unitMod = UNIT_MOD_DAMAGE_RANGED; + attPower = UNIT_MOD_ATTACK_POWER_RANGED; + break; + } + + float att_speed = GetAPMultiplier(attType,normalized); + + float base_value = GetModifierValue(unitMod, BASE_VALUE) + GetTotalAttackPowerValue(attType)/ 14.0f * att_speed; + float base_pct = GetModifierValue(unitMod, BASE_PCT); + float total_value = GetModifierValue(unitMod, TOTAL_VALUE); + float total_pct = GetModifierValue(unitMod, TOTAL_PCT); + + float weapon_mindamage = GetWeaponDamageRange(attType, MINDAMAGE); + float weapon_maxdamage = GetWeaponDamageRange(attType, MAXDAMAGE); + + if (IsInFeralForm()) //check if player is druid and in cat or bear forms + { + uint32 lvl = getLevel(); + if ( lvl > 60 ) lvl = 60; + + weapon_mindamage = lvl*0.85*att_speed; + weapon_maxdamage = lvl*1.25*att_speed; + } + else if(!IsUseEquipedWeapon(attType==BASE_ATTACK)) //check if player not in form but still can't use weapon (broken/etc) + { + weapon_mindamage = BASE_MINDAMAGE; + weapon_maxdamage = BASE_MAXDAMAGE; + } + else if(attType == RANGED_ATTACK) //add ammo DPS to ranged damage + { + weapon_mindamage += GetAmmoDPS() * att_speed; + weapon_maxdamage += GetAmmoDPS() * att_speed; + } + + min_damage = ((base_value + weapon_mindamage) * base_pct + total_value) * total_pct; + max_damage = ((base_value + weapon_maxdamage) * base_pct + total_value) * total_pct; +} + +void Player::UpdateDamagePhysical(WeaponAttackType attType) +{ + float mindamage; + float maxdamage; + + CalculateMinMaxDamage(attType,false,mindamage,maxdamage); + + switch(attType) + { + case BASE_ATTACK: + default: + SetStatFloatValue(UNIT_FIELD_MINDAMAGE,mindamage); + SetStatFloatValue(UNIT_FIELD_MAXDAMAGE,maxdamage); + break; + case OFF_ATTACK: + SetStatFloatValue(UNIT_FIELD_MINOFFHANDDAMAGE,mindamage); + SetStatFloatValue(UNIT_FIELD_MAXOFFHANDDAMAGE,maxdamage); + break; + case RANGED_ATTACK: + SetStatFloatValue(UNIT_FIELD_MINRANGEDDAMAGE,mindamage); + SetStatFloatValue(UNIT_FIELD_MAXRANGEDDAMAGE,maxdamage); + break; + } +} + +void Player::UpdateDefenseBonusesMod() +{ + UpdateBlockPercentage(); + UpdateParryPercentage(); + UpdateDodgePercentage(); +} + +void Player::UpdateBlockPercentage() +{ + // No block + float value = 0.0f; + if(CanBlock()) + { + // Base value + value = 5.0f; + // Modify value from defense skill + value += (int32(GetDefenseSkillValue()) - int32(GetMaxSkillValueForLevel())) * 0.04f; + // Increase from SPELL_AURA_MOD_BLOCK_PERCENT aura + value += GetTotalAuraModifier(SPELL_AURA_MOD_BLOCK_PERCENT); + // Increase from rating + value += GetRatingBonusValue(CR_BLOCK); + value = value < 0.0f ? 0.0f : value; + } + SetStatFloatValue(PLAYER_BLOCK_PERCENTAGE, value); +} + +void Player::UpdateCritPercentage(WeaponAttackType attType) +{ + BaseModGroup modGroup; + uint16 index; + CombatRating cr; + + switch(attType) + { + case OFF_ATTACK: + modGroup = OFFHAND_CRIT_PERCENTAGE; + index = PLAYER_OFFHAND_CRIT_PERCENTAGE; + cr = CR_CRIT_MELEE; + break; + case RANGED_ATTACK: + modGroup = RANGED_CRIT_PERCENTAGE; + index = PLAYER_RANGED_CRIT_PERCENTAGE; + cr = CR_CRIT_RANGED; + break; + case BASE_ATTACK: + default: + modGroup = CRIT_PERCENTAGE; + index = PLAYER_CRIT_PERCENTAGE; + cr = CR_CRIT_MELEE; + break; + } + + float value = GetTotalPercentageModValue(modGroup) + GetRatingBonusValue(cr); + // Modify crit from weapon skill and maximized defense skill of same level victim difference + value += (int32(GetWeaponSkillValue(attType)) - int32(GetMaxSkillValueForLevel())) * 0.04f; + value = value < 0.0f ? 0.0f : value; + SetStatFloatValue(index, value); +} + +void Player::UpdateAllCritPercentages() +{ + float value = GetMeleeCritFromAgility(); + + SetBaseModValue(CRIT_PERCENTAGE, PCT_MOD, value); + SetBaseModValue(OFFHAND_CRIT_PERCENTAGE, PCT_MOD, value); + SetBaseModValue(RANGED_CRIT_PERCENTAGE, PCT_MOD, value); + + UpdateCritPercentage(BASE_ATTACK); + UpdateCritPercentage(OFF_ATTACK); + UpdateCritPercentage(RANGED_ATTACK); +} + +void Player::UpdateParryPercentage() +{ + // No parry + float value = 0.0f; + if (CanParry()) + { + // Base parry + value = 5.0f; + // Modify value from defense skill + value += (int32(GetDefenseSkillValue()) - int32(GetMaxSkillValueForLevel())) * 0.04f; + // Parry from SPELL_AURA_MOD_PARRY_PERCENT aura + value += GetTotalAuraModifier(SPELL_AURA_MOD_PARRY_PERCENT); + // Parry from rating + value += GetRatingBonusValue(CR_PARRY); + value = value < 0.0f ? 0.0f : value; + } + SetStatFloatValue(PLAYER_PARRY_PERCENTAGE, value); +} + +void Player::UpdateDodgePercentage() +{ + // Dodge from agility + float value = GetDodgeFromAgility(); + // Modify value from defense skill + value += (int32(GetDefenseSkillValue()) - int32(GetMaxSkillValueForLevel())) * 0.04f; + // Dodge from SPELL_AURA_MOD_DODGE_PERCENT aura + value += GetTotalAuraModifier(SPELL_AURA_MOD_DODGE_PERCENT); + // Dodge from rating + value += GetRatingBonusValue(CR_DODGE); + value = value < 0.0f ? 0.0f : value; + SetStatFloatValue(PLAYER_DODGE_PERCENTAGE, value); +} + +void Player::UpdateSpellCritChance(uint32 school) +{ + // For normal school set zero crit chance + if(school == SPELL_SCHOOL_NORMAL) + { + SetFloatValue(PLAYER_SPELL_CRIT_PERCENTAGE1, 0.0f); + return; + } + // For others recalculate it from: + float crit = 0.0f; + // Crit from Intellect + crit += GetSpellCritFromIntellect(); + // Increase crit from SPELL_AURA_MOD_SPELL_CRIT_CHANCE + crit += GetTotalAuraModifier(SPELL_AURA_MOD_SPELL_CRIT_CHANCE); + // Increase crit by school from SPELL_AURA_MOD_SPELL_CRIT_CHANCE_SCHOOL + crit += GetTotalAuraModifierByMiscMask(SPELL_AURA_MOD_SPELL_CRIT_CHANCE_SCHOOL, 1<GetSpellProto()->EquippedItemClass == -1) + expertise += (*itr)->GetModifier()->m_amount; + // item dependent spell + else if(weapon && weapon->IsFitToSpellRequirements((*itr)->GetSpellProto())) + expertise += (*itr)->GetModifier()->m_amount; + } + + if(expertise < 0) + expertise = 0; + + switch(attack) + { + case BASE_ATTACK: SetUInt32Value(PLAYER_EXPERTISE, expertise); break; + case OFF_ATTACK: SetUInt32Value(PLAYER_OFFHAND_EXPERTISE, expertise); break; + default: break; + } +} + +void Player::UpdateManaRegen() +{ + float Intellect = GetStat(STAT_INTELLECT); + // Mana regen from spirit and intellect + float power_regen = sqrt(Intellect) * OCTRegenMPPerSpirit(); + // Apply PCT bonus from SPELL_AURA_MOD_POWER_REGEN_PERCENT aura on spirit base regen + power_regen *= GetTotalAuraMultiplierByMiscValue(SPELL_AURA_MOD_POWER_REGEN_PERCENT, POWER_MANA); + + // Mana regen from SPELL_AURA_MOD_POWER_REGEN aura + float power_regen_mp5 = GetTotalAuraModifierByMiscValue(SPELL_AURA_MOD_POWER_REGEN, POWER_MANA) / 5.0f; + + // Get bonus from SPELL_AURA_MOD_MANA_REGEN_FROM_STAT aura + AuraList const& regenAura = GetAurasByType(SPELL_AURA_MOD_MANA_REGEN_FROM_STAT); + for(AuraList::const_iterator i = regenAura.begin();i != regenAura.end(); ++i) + { + Modifier* mod = (*i)->GetModifier(); + power_regen_mp5 += GetStat(Stats(mod->m_miscvalue)) * mod->m_amount / 500.0f; + } + + // Bonus from some dummy auras + AuraList const& mDummyAuras = GetAurasByType(SPELL_AURA_PERIODIC_DUMMY); + for(AuraList::const_iterator i = mDummyAuras.begin();i != mDummyAuras.end(); ++i) + if((*i)->GetId() == 34074) // Aspect of the Viper + { + power_regen_mp5 += (*i)->GetModifier()->m_amount * Intellect / 500.0f; + // Add regen bonus from level in this dummy + power_regen_mp5 += getLevel() * 35 / 100; + } + + // Set regen rate in cast state apply only on spirit based regen + int32 modManaRegenInterrupt = GetTotalAuraModifier(SPELL_AURA_MOD_MANA_REGEN_INTERRUPT); + if (modManaRegenInterrupt > 100) + modManaRegenInterrupt = 100; + SetStatFloatValue(PLAYER_FIELD_MOD_MANA_REGEN_INTERRUPT, power_regen_mp5 + power_regen * modManaRegenInterrupt / 100.0f); + + SetStatFloatValue(PLAYER_FIELD_MOD_MANA_REGEN, power_regen_mp5 + power_regen); +} + +void Player::_ApplyAllStatBonuses() +{ + SetCanModifyStats(false); + + _ApplyAllAuraMods(); + _ApplyAllItemMods(); + + SetCanModifyStats(true); + + UpdateAllStats(); +} + +void Player::_RemoveAllStatBonuses() +{ + SetCanModifyStats(false); + + _RemoveAllItemMods(); + _RemoveAllAuraMods(); + + SetCanModifyStats(true); + + UpdateAllStats(); +} + +/*####################################### +######## ######## +######## MOBS STAT SYSTEM ######## +######## ######## +#######################################*/ + +bool Creature::UpdateStats(Stats /*stat*/) +{ + return true; +} + +bool Creature::UpdateAllStats() +{ + UpdateMaxHealth(); + UpdateAttackPowerAndDamage(); + + for(int i = POWER_MANA; i < MAX_POWERS; ++i) + UpdateMaxPower(Powers(i)); + + for(int i = SPELL_SCHOOL_NORMAL; i < MAX_SPELL_SCHOOL; ++i) + UpdateResistances(i); + + return true; +} + +void Creature::UpdateResistances(uint32 school) +{ + if(school > SPELL_SCHOOL_NORMAL) + { + float value = GetTotalAuraModValue(UnitMods(UNIT_MOD_RESISTANCE_START + school)); + SetResistance(SpellSchools(school), int32(value)); + } + else + UpdateArmor(); +} + +void Creature::UpdateArmor() +{ + float value = GetTotalAuraModValue(UNIT_MOD_ARMOR); + SetArmor(int32(value)); +} + +void Creature::UpdateMaxHealth() +{ + float value = GetTotalAuraModValue(UNIT_MOD_HEALTH); + SetMaxHealth((uint32)value); +} + +void Creature::UpdateMaxPower(Powers power) +{ + UnitMods unitMod = UnitMods(UNIT_MOD_POWER_START + power); + + float value = GetTotalAuraModValue(unitMod); + SetMaxPower(power, uint32(value)); +} + +void Creature::UpdateAttackPowerAndDamage(bool ranged) +{ + if(ranged) + return; + + //automatically update weapon damage after attack power modification + UpdateDamagePhysical(BASE_ATTACK); +} + +void Creature::UpdateDamagePhysical(WeaponAttackType attType) +{ + if(attType > BASE_ATTACK) + return; + + UnitMods unitMod = UNIT_MOD_DAMAGE_MAINHAND; + + float att_speed = float(GetAttackTime(BASE_ATTACK))/1000.0f; + + float base_value = GetModifierValue(unitMod, BASE_VALUE) + GetTotalAttackPowerValue(attType)/ 14.0f * att_speed; + float base_pct = GetModifierValue(unitMod, BASE_PCT); + float total_value = GetModifierValue(unitMod, TOTAL_VALUE); + float total_pct = GetModifierValue(unitMod, TOTAL_PCT); + + float weapon_mindamage = GetWeaponDamageRange(BASE_ATTACK, MINDAMAGE); + float weapon_maxdamage = GetWeaponDamageRange(BASE_ATTACK, MAXDAMAGE); + + float mindamage = ((base_value + weapon_mindamage) * base_pct + total_value) * total_pct ; + float maxdamage = ((base_value + weapon_maxdamage) * base_pct + total_value) * total_pct ; + + SetStatFloatValue(UNIT_FIELD_MINDAMAGE, mindamage); + SetStatFloatValue(UNIT_FIELD_MAXDAMAGE, maxdamage); +} + +/*####################################### +######## ######## +######## PETS STAT SYSTEM ######## +######## ######## +#######################################*/ + +bool Pet::UpdateStats(Stats stat) +{ + if(stat > STAT_SPIRIT) + return false; + + // value = ((base_value * base_pct) + total_value) * total_pct + float value = GetTotalStatValue(stat); + + Unit *owner = GetOwner(); + if ( stat == STAT_STAMINA ) + { + if(owner) + value += float(owner->GetStat(stat)) * 0.3f; + } + //warlock's and mage's pets gain 30% of owner's intellect + else if ( stat == STAT_INTELLECT && getPetType() == SUMMON_PET ) + { + if(owner && (owner->getClass() == CLASS_WARLOCK || owner->getClass() == CLASS_MAGE) ) + value += float(owner->GetStat(stat)) * 0.3f; + } + + SetStat(stat, int32(value)); + + switch(stat) + { + case STAT_STRENGTH: UpdateAttackPowerAndDamage(); break; + case STAT_AGILITY: UpdateArmor(); break; + case STAT_STAMINA: UpdateMaxHealth(); break; + case STAT_INTELLECT: UpdateMaxPower(POWER_MANA); break; + case STAT_SPIRIT: + default: + break; + } + + return true; +} + +bool Pet::UpdateAllStats() +{ + for (int i = STAT_STRENGTH; i < MAX_STATS; i++) + UpdateStats(Stats(i)); + + for(int i = POWER_MANA; i < MAX_POWERS; i++) + UpdateMaxPower(Powers(i)); + + for (int i = SPELL_SCHOOL_NORMAL; i < MAX_SPELL_SCHOOL; i++) + UpdateResistances(i); + + return true; +} + +void Pet::UpdateResistances(uint32 school) +{ + if(school > SPELL_SCHOOL_NORMAL) + { + float value = GetTotalAuraModValue(UnitMods(UNIT_MOD_RESISTANCE_START + school)); + + Unit *owner = GetOwner(); + // hunter and warlock pets gain 40% of owner's resistance + if(owner && (getPetType() == HUNTER_PET || getPetType() == SUMMON_PET && owner->getClass() == CLASS_WARLOCK)) + value += float(owner->GetResistance(SpellSchools(school))) * 0.4f; + + SetResistance(SpellSchools(school), int32(value)); + } + else + UpdateArmor(); +} + +void Pet::UpdateArmor() +{ + float value = 0.0f; + float bonus_armor = 0.0f; + UnitMods unitMod = UNIT_MOD_ARMOR; + + Unit *owner = GetOwner(); + // hunter and warlock pets gain 35% of owner's armor value + if(owner && (getPetType() == HUNTER_PET || getPetType() == SUMMON_PET && owner->getClass() == CLASS_WARLOCK)) + bonus_armor = 0.35f * float(owner->GetArmor()); + + value = GetModifierValue(unitMod, BASE_VALUE); + value *= GetModifierValue(unitMod, BASE_PCT); + value += GetStat(STAT_AGILITY) * 2.0f; + value += GetModifierValue(unitMod, TOTAL_VALUE) + bonus_armor; + value *= GetModifierValue(unitMod, TOTAL_PCT); + + SetArmor(int32(value)); +} + +void Pet::UpdateMaxHealth() +{ + UnitMods unitMod = UNIT_MOD_HEALTH; + float stamina = GetStat(STAT_STAMINA) - GetCreateStat(STAT_STAMINA); + + float value = GetModifierValue(unitMod, BASE_VALUE) + GetCreateHealth(); + value *= GetModifierValue(unitMod, BASE_PCT); + value += GetModifierValue(unitMod, TOTAL_VALUE) + stamina * 10.0f; + value *= GetModifierValue(unitMod, TOTAL_PCT); + + SetMaxHealth((uint32)value); +} + +void Pet::UpdateMaxPower(Powers power) +{ + UnitMods unitMod = UnitMods(UNIT_MOD_POWER_START + power); + float addValue = (power == POWER_MANA) ? GetStat(STAT_INTELLECT) - GetCreateStat(STAT_INTELLECT) : 0.0f; + + float value = GetModifierValue(unitMod, BASE_VALUE) + GetCreatePowers(power); + value *= GetModifierValue(unitMod, BASE_PCT); + value += GetModifierValue(unitMod, TOTAL_VALUE) + addValue * 15.0f; + value *= GetModifierValue(unitMod, TOTAL_PCT); + + SetMaxPower(power, uint32(value)); +} + +void Pet::UpdateAttackPowerAndDamage(bool ranged) +{ + if(ranged) + return; + + float val = 0.0f; + float bonusAP = 0.0f; + UnitMods unitMod = UNIT_MOD_ATTACK_POWER; + + if(GetEntry() == 416) // imp's attack power + val = GetStat(STAT_STRENGTH) - 10.0f; + else + val = 2 * GetStat(STAT_STRENGTH) - 20.0f; + + Unit* owner = GetOwner(); + if( owner && owner->GetTypeId()==TYPEID_PLAYER) + { + if(getPetType() == HUNTER_PET) //hunter pets benefit from owner's attack power + { + bonusAP = owner->GetTotalAttackPowerValue(RANGED_ATTACK) * 0.22f; + SetBonusDamage( int32(owner->GetTotalAttackPowerValue(RANGED_ATTACK) * 0.125f)); + } + //demons benefit from warlocks shadow or fire damage + else if(getPetType() == SUMMON_PET && owner->getClass() == CLASS_WARLOCK) + { + int32 fire = int32(owner->GetUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS + SPELL_SCHOOL_FIRE)) - owner->GetUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_NEG + SPELL_SCHOOL_FIRE); + int32 shadow = int32(owner->GetUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS + SPELL_SCHOOL_SHADOW)) - owner->GetUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_NEG + SPELL_SCHOOL_SHADOW); + int32 maximum = (fire > shadow) ? fire : shadow; + if(maximum < 0) + maximum = 0; + SetBonusDamage( int32(maximum * 0.15f)); + bonusAP = maximum * 0.57f; + } + //water elementals benefit from mage's frost damage + else if(getPetType() == SUMMON_PET && owner->getClass() == CLASS_MAGE) + { + int32 frost = int32(owner->GetUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS + SPELL_SCHOOL_FROST)) - owner->GetUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_NEG + SPELL_SCHOOL_FROST); + if(frost < 0) + frost = 0; + SetBonusDamage( int32(frost * 0.4f)); + } + } + + SetModifierValue(UNIT_MOD_ATTACK_POWER, BASE_VALUE, val + bonusAP); + + //in BASE_VALUE of UNIT_MOD_ATTACK_POWER for creatures we store data of meleeattackpower field in DB + float base_attPower = GetModifierValue(unitMod, BASE_VALUE) * GetModifierValue(unitMod, BASE_PCT); + float attPowerMod = GetModifierValue(unitMod, TOTAL_VALUE); + float attPowerMultiplier = GetModifierValue(unitMod, TOTAL_PCT) - 1.0f; + + //UNIT_FIELD_(RANGED)_ATTACK_POWER field + SetUInt32Value(UNIT_FIELD_ATTACK_POWER, (uint32)base_attPower); + //UNIT_FIELD_(RANGED)_ATTACK_POWER_MODS field + SetUInt32Value(UNIT_FIELD_ATTACK_POWER_MODS, (uint32)attPowerMod); + //UNIT_FIELD_(RANGED)_ATTACK_POWER_MULTIPLIER field + SetFloatValue(UNIT_FIELD_ATTACK_POWER_MULTIPLIER, attPowerMultiplier); + + //automatically update weapon damage after attack power modification + UpdateDamagePhysical(BASE_ATTACK); +} + +void Pet::UpdateDamagePhysical(WeaponAttackType attType) +{ + if(attType > BASE_ATTACK) + return; + + UnitMods unitMod = UNIT_MOD_DAMAGE_MAINHAND; + + float att_speed = float(GetAttackTime(BASE_ATTACK))/1000.0f; + + float base_value = GetModifierValue(unitMod, BASE_VALUE) + GetTotalAttackPowerValue(attType)/ 14.0f * att_speed; + float base_pct = GetModifierValue(unitMod, BASE_PCT); + float total_value = GetModifierValue(unitMod, TOTAL_VALUE); + float total_pct = GetModifierValue(unitMod, TOTAL_PCT); + + float weapon_mindamage = GetWeaponDamageRange(BASE_ATTACK, MINDAMAGE); + float weapon_maxdamage = GetWeaponDamageRange(BASE_ATTACK, MAXDAMAGE); + + float mindamage = ((base_value + weapon_mindamage) * base_pct + total_value) * total_pct; + float maxdamage = ((base_value + weapon_maxdamage) * base_pct + total_value) * total_pct; + + // Pet's base damage changes depending on happiness + if (getPetType() == HUNTER_PET && attType == BASE_ATTACK) + { + switch(GetHappinessState()) + { + case HAPPY: + // 125% of normal damage + mindamage = mindamage * 1.25; + maxdamage = maxdamage * 1.25; + break; + case CONTENT: + // 100% of normal damage, nothing to modify + break; + case UNHAPPY: + // 75% of normal damage + mindamage = mindamage * 0.75; + maxdamage = maxdamage * 0.75; + break; + } + } + + SetStatFloatValue(UNIT_FIELD_MINDAMAGE, mindamage); + SetStatFloatValue(UNIT_FIELD_MAXDAMAGE, maxdamage); +} diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index 442dbc1057b..18de56321de 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -1,10808 +1,10812 @@ -/* - * Copyright (C) 2005-2008 MaNGOS - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "Common.h" -#include "Log.h" -#include "Opcodes.h" -#include "WorldPacket.h" -#include "WorldSession.h" -#include "World.h" -#include "ObjectMgr.h" -#include "SpellMgr.h" -#include "Unit.h" -#include "QuestDef.h" -#include "Player.h" -#include "Creature.h" -#include "Spell.h" -#include "Group.h" -#include "SpellAuras.h" -#include "MapManager.h" -#include "ObjectAccessor.h" -#include "CreatureAI.h" -#include "Formulas.h" -#include "Pet.h" -#include "Util.h" -#include "Totem.h" -#include "BattleGround.h" -#include "InstanceSaveMgr.h" -#include "GridNotifiersImpl.h" -#include "CellImpl.h" -#include "Path.h" - -#include - -float baseMoveSpeed[MAX_MOVE_TYPE] = -{ - 2.5f, // MOVE_WALK - 7.0f, // MOVE_RUN - 1.25f, // MOVE_WALKBACK - 4.722222f, // MOVE_SWIM - 4.5f, // MOVE_SWIMBACK - 3.141594f, // MOVE_TURN - 7.0f, // MOVE_FLY - 4.5f, // MOVE_FLYBACK -}; - -// auraTypes contains attacker auras capable of proc'ing cast auras -static Unit::AuraTypeSet GenerateAttakerProcCastAuraTypes() -{ - static Unit::AuraTypeSet auraTypes; - auraTypes.insert(SPELL_AURA_DUMMY); - auraTypes.insert(SPELL_AURA_PROC_TRIGGER_SPELL); - auraTypes.insert(SPELL_AURA_MOD_HASTE); - auraTypes.insert(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS); - return auraTypes; -} - -// auraTypes contains victim auras capable of proc'ing cast auras -static Unit::AuraTypeSet GenerateVictimProcCastAuraTypes() -{ - static Unit::AuraTypeSet auraTypes; - auraTypes.insert(SPELL_AURA_DUMMY); - auraTypes.insert(SPELL_AURA_PRAYER_OF_MENDING); - auraTypes.insert(SPELL_AURA_PROC_TRIGGER_SPELL); - return auraTypes; -} - -// auraTypes contains auras capable of proc effect/damage (but not cast) for attacker -static Unit::AuraTypeSet GenerateAttakerProcEffectAuraTypes() -{ - static Unit::AuraTypeSet auraTypes; - auraTypes.insert(SPELL_AURA_MOD_DAMAGE_DONE); - auraTypes.insert(SPELL_AURA_PROC_TRIGGER_DAMAGE); - auraTypes.insert(SPELL_AURA_MOD_CASTING_SPEED); - auraTypes.insert(SPELL_AURA_MOD_RATING); - return auraTypes; -} - -// auraTypes contains auras capable of proc effect/damage (but not cast) for victim -static Unit::AuraTypeSet GenerateVictimProcEffectAuraTypes() -{ - static Unit::AuraTypeSet auraTypes; - auraTypes.insert(SPELL_AURA_MOD_RESISTANCE); - auraTypes.insert(SPELL_AURA_PROC_TRIGGER_DAMAGE); - auraTypes.insert(SPELL_AURA_MOD_PARRY_PERCENT); - auraTypes.insert(SPELL_AURA_MOD_BLOCK_PERCENT); - auraTypes.insert(SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN); - return auraTypes; -} - -static Unit::AuraTypeSet attackerProcCastAuraTypes = GenerateAttakerProcCastAuraTypes(); -static Unit::AuraTypeSet attackerProcEffectAuraTypes = GenerateAttakerProcEffectAuraTypes(); - -static Unit::AuraTypeSet victimProcCastAuraTypes = GenerateVictimProcCastAuraTypes(); -static Unit::AuraTypeSet victimProcEffectAuraTypes = GenerateVictimProcEffectAuraTypes(); - -// auraTypes contains auras capable of proc'ing for attacker and victim -static Unit::AuraTypeSet GenerateProcAuraTypes() -{ - Unit::AuraTypeSet auraTypes; - auraTypes.insert(attackerProcCastAuraTypes.begin(),attackerProcCastAuraTypes.end()); - auraTypes.insert(attackerProcEffectAuraTypes.begin(),attackerProcEffectAuraTypes.end()); - auraTypes.insert(victimProcCastAuraTypes.begin(),victimProcCastAuraTypes.end()); - auraTypes.insert(victimProcEffectAuraTypes.begin(),victimProcEffectAuraTypes.end()); - return auraTypes; -} - -static Unit::AuraTypeSet procAuraTypes = GenerateProcAuraTypes(); - -bool IsPassiveStackableSpell( uint32 spellId ) -{ - if(!IsPassiveSpell(spellId)) - return false; - - SpellEntry const* spellProto = sSpellStore.LookupEntry(spellId); - if(!spellProto) - return false; - - for(int j = 0; j < 3; ++j) - { - if(std::find(procAuraTypes.begin(),procAuraTypes.end(),spellProto->EffectApplyAuraName[j])!=procAuraTypes.end()) - return false; - } - - return true; -} - -Unit::Unit() -: WorldObject(), i_motionMaster(this), m_ThreatManager(this), m_HostilRefManager(this) -{ - m_objectType |= TYPEMASK_UNIT; - m_objectTypeId = TYPEID_UNIT; - // 2.3.2 - 0x70 - m_updateFlag = (UPDATEFLAG_HIGHGUID | UPDATEFLAG_LIVING | UPDATEFLAG_HASPOSITION); - - m_attackTimer[BASE_ATTACK] = 0; - m_attackTimer[OFF_ATTACK] = 0; - m_attackTimer[RANGED_ATTACK] = 0; - m_modAttackSpeedPct[BASE_ATTACK] = 1.0f; - m_modAttackSpeedPct[OFF_ATTACK] = 1.0f; - m_modAttackSpeedPct[RANGED_ATTACK] = 1.0f; - - m_extraAttacks = 0; - - m_state = 0; - m_form = FORM_NONE; - m_deathState = ALIVE; - - for (uint32 i = 0; i < CURRENT_MAX_SPELL; i++) - m_currentSpells[i] = NULL; - - m_addDmgOnce = 0; - - for(int i = 0; i < MAX_TOTEM; ++i) - m_TotemSlot[i] = 0; - - m_ObjectSlot[0] = m_ObjectSlot[1] = m_ObjectSlot[2] = m_ObjectSlot[3] = 0; - //m_Aura = NULL; - //m_AurasCheck = 2000; - //m_removeAuraTimer = 4; - //tmpAura = NULL; - waterbreath = false; - - m_Visibility = VISIBILITY_ON; - - m_detectInvisibilityMask = 0; - m_invisibilityMask = 0; - m_transform = 0; - m_ShapeShiftFormSpellId = 0; - m_canModifyStats = false; - - for (int i = 0; i < MAX_SPELL_IMMUNITY; i++) - m_spellImmune[i].clear(); - for (int i = 0; i < UNIT_MOD_END; i++) - { - m_auraModifiersGroup[i][BASE_VALUE] = 0.0f; - m_auraModifiersGroup[i][BASE_PCT] = 1.0f; - m_auraModifiersGroup[i][TOTAL_VALUE] = 0.0f; - m_auraModifiersGroup[i][TOTAL_PCT] = 1.0f; - } - // implement 50% base damage from offhand - m_auraModifiersGroup[UNIT_MOD_DAMAGE_OFFHAND][TOTAL_PCT] = 0.5f; - - for (int i = 0; i < 3; i++) - { - m_weaponDamage[i][MINDAMAGE] = BASE_MINDAMAGE; - m_weaponDamage[i][MAXDAMAGE] = BASE_MAXDAMAGE; - } - for (int i = 0; i < MAX_STATS; i++) - m_createStats[i] = 0.0f; - - m_attacking = NULL; - m_modMeleeHitChance = 0.0f; - m_modRangedHitChance = 0.0f; - m_modSpellHitChance = 0.0f; - m_baseSpellCritChance = 5; - - m_CombatTimer = 0; - m_lastManaUse = 0; - - //m_victimThreat = 0.0f; - for (int i = 0; i < MAX_SPELL_SCHOOL; ++i) - m_threatModifier[i] = 1.0f; - m_isSorted = true; - for (int i = 0; i < MAX_MOVE_TYPE; ++i) - m_speed_rate[i] = 1.0f; - - m_removedAuras = 0; - m_charmInfo = NULL; - m_unit_movement_flags = 0; - - // remove aurastates allowing special moves - for(int i=0; i < MAX_REACTIVE; ++i) - m_reactiveTimer[i] = 0; -} - -Unit::~Unit() -{ - // set current spells as deletable - for (uint32 i = 0; i < CURRENT_MAX_SPELL; i++) - { - // spell may be safely deleted now - if (m_currentSpells[i]) m_currentSpells[i]->SetDeletable(true); - m_currentSpells[i] = NULL; - } - - RemoveAllGameObjects(); - RemoveAllDynObjects(); - - if(m_charmInfo) delete m_charmInfo; -} - -void Unit::Update( uint32 p_time ) -{ - /*if(p_time > m_AurasCheck) - { - m_AurasCheck = 2000; - _UpdateAura(); - }else - m_AurasCheck -= p_time;*/ - - // WARNING! Order of execution here is important, do not change. - // Spells must be processed with event system BEFORE they go to _UpdateSpells. - // Or else we may have some SPELL_STATE_FINISHED spells stalled in pointers, that is bad. - m_Events.Update( p_time ); - _UpdateSpells( p_time ); - - // update combat timer only for players and pets - if (isInCombat() && (GetTypeId() == TYPEID_PLAYER || ((Creature*)this)->isPet() || ((Creature*)this)->isCharmed())) - { - // Check UNIT_STAT_MELEE_ATTACKING or UNIT_STAT_CHASE (without UNIT_STAT_FOLLOW in this case) so pets can reach far away - // targets without stopping half way there and running off. - // These flags are reset after target dies or another command is given. - if( m_HostilRefManager.isEmpty() ) - { - // m_CombatTimer set at aura start and it will be freeze until aura removing - if ( m_CombatTimer <= p_time ) - ClearInCombat(); - else - m_CombatTimer -= p_time; - } - } - - if(uint32 base_att = getAttackTimer(BASE_ATTACK)) - { - setAttackTimer(BASE_ATTACK, (p_time >= base_att ? 0 : base_att - p_time) ); - } - - // update abilities available only for fraction of time - UpdateReactives( p_time ); - - ModifyAuraState(AURA_STATE_HEALTHLESS_20_PERCENT, GetHealth() < GetMaxHealth()*0.20f); - ModifyAuraState(AURA_STATE_HEALTHLESS_35_PERCENT, GetHealth() < GetMaxHealth()*0.35f); - - i_motionMaster.UpdateMotion(p_time); -} - -bool Unit::haveOffhandWeapon() const -{ - if(GetTypeId() == TYPEID_PLAYER) - return ((Player*)this)->GetWeaponForAttack(OFF_ATTACK,true); - else - return false; -} - -void Unit::SendMonsterMoveWithSpeedToCurrentDestination(Player* player) -{ - float x, y, z; - if(GetMotionMaster()->GetDestination(x, y, z)) - SendMonsterMoveWithSpeed(x, y, z, GetUnitMovementFlags(), 0, player); -} - -void Unit::SendMonsterMoveWithSpeed(float x, float y, float z, uint32 MovementFlags, uint32 transitTime, Player* player) -{ - if (!transitTime) - { - float dx = x - GetPositionX(); - float dy = y - GetPositionY(); - float dz = z - GetPositionZ(); - - float dist = ((dx*dx) + (dy*dy) + (dz*dz)); - if(dist<0) - dist = 0; - else - dist = sqrt(dist); - - double speed = GetSpeed((MovementFlags & MOVEMENTFLAG_WALK_MODE) ? MOVE_WALK : MOVE_RUN); - if(speed<=0) - speed = 2.5f; - speed *= 0.001f; - transitTime = static_cast(dist / speed + 0.5); - } - //float orientation = (float)atan2((double)dy, (double)dx); - SendMonsterMove(x, y, z, 0, MovementFlags, transitTime, player); -} - -void Unit::SendMonsterMove(float NewPosX, float NewPosY, float NewPosZ, uint8 type, uint32 MovementFlags, uint32 Time, Player* player) -{ - WorldPacket data( SMSG_MONSTER_MOVE, (41 + GetPackGUID().size()) ); - data.append(GetPackGUID()); - - // Point A, starting location - data << GetPositionX() << GetPositionY() << GetPositionZ(); - // unknown field - unrelated to orientation - // seems to increment about 1000 for every 1.7 seconds - // for now, we'll just use mstime - data << getMSTime(); - - data << uint8(type); // unknown - switch(type) - { - case 0: // normal packet - break; - case 1: // stop packet - SendMessageToSet( &data, true ); - return; - case 3: // not used currently - data << uint64(0); // probably target guid - break; - case 4: // not used currently - data << float(0); // probably orientation - break; - } - - //Movement Flags (0x0 = walk, 0x100 = run, 0x200 = fly/swim) - data << uint32(MovementFlags); - - data << Time; // Time in between points - data << uint32(1); // 1 single waypoint - data << NewPosX << NewPosY << NewPosZ; // the single waypoint Point B - - if(player) - player->GetSession()->SendPacket(&data); - else - SendMessageToSet( &data, true ); -} - -void Unit::SendMonsterMoveByPath(Path const& path, uint32 start, uint32 end, uint32 MovementFlags) -{ - uint32 traveltime = uint32(path.GetTotalLength(start, end) * 32); - - uint32 pathSize = end-start; - - WorldPacket data( SMSG_MONSTER_MOVE, (GetPackGUID().size()+4+4+4+4+1+4+4+4+pathSize*4*3) ); - data.append(GetPackGUID()); - data << GetPositionX( ) - << GetPositionY( ) - << GetPositionZ( ); - data << GetOrientation( ); - data << uint8( 0 ); - data << uint32( MovementFlags ); - data << uint32( traveltime ); - data << uint32( pathSize ); - data.append( (char*)path.GetNodes(start), pathSize * 4 * 3 ); - - //WPAssert( data.size() == 37 + pathnodes.Size( ) * 4 * 3 ); - SendMessageToSet(&data, true); -} - -void Unit::resetAttackTimer(WeaponAttackType type) -{ - m_attackTimer[type] = uint32(GetAttackTime(type) * m_modAttackSpeedPct[type]); -} - -bool Unit::canReachWithAttack(Unit *pVictim) const -{ - assert(pVictim); - float reach = GetFloatValue(UNIT_FIELD_COMBATREACH); - if( reach <= 0.0f ) - reach = 1.0f; - return IsWithinDistInMap(pVictim, reach); -} - -void Unit::RemoveSpellsCausingAura(AuraType auraType) -{ - if (auraType >= TOTAL_AURAS) return; - AuraList::iterator iter, next; - for (iter = m_modAuras[auraType].begin(); iter != m_modAuras[auraType].end(); iter = next) - { - next = iter; - ++next; - - if (*iter) - { - RemoveAurasDueToSpell((*iter)->GetId()); - if (!m_modAuras[auraType].empty()) - next = m_modAuras[auraType].begin(); - else - return; - } - } -} - -bool Unit::HasAuraType(AuraType auraType) const -{ - return (!m_modAuras[auraType].empty()); -} - -/* Called by DealDamage for auras that have a chance to be dispelled on damage taken. */ -void Unit::RemoveSpellbyDamageTaken(AuraType auraType, uint32 damage) -{ - if(!HasAuraType(auraType)) - return; - - // The chance to dispell an aura depends on the damage taken with respect to the casters level. - uint32 max_dmg = getLevel() > 8 ? 25 * getLevel() - 150 : 50; - float chance = float(damage) / max_dmg * 100.0f; - if (roll_chance_f(chance)) - RemoveSpellsCausingAura(auraType); -} - -uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDamage, DamageEffectType damagetype, SpellSchoolMask damageSchoolMask, SpellEntry const *spellProto, bool durabilityLoss) -{ - if (!pVictim->isAlive() || pVictim->isInFlight() || pVictim->GetTypeId() == TYPEID_UNIT && ((Creature*)pVictim)->IsInEvadeMode()) - return 0; - - //You don't lose health from damage taken from another player while in a sanctuary - //You still see it in the combat log though - if(pVictim != this && GetTypeId() == TYPEID_PLAYER && pVictim->GetTypeId() == TYPEID_PLAYER) - { - const AreaTableEntry *area = GetAreaEntryByAreaID(pVictim->GetAreaId()); - if(area && area->flags & AREA_FLAG_SANCTUARY) //sanctuary - return 0; - } - - // remove affects from victim (including from 0 damage and DoTs) - if(pVictim != this) - pVictim->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); - - // remove affects from attacker at any non-DoT damage (including 0 damage) - if( damagetype != DOT) - { - RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); - RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH); - - if(pVictim != this) - RemoveSpellsCausingAura(SPELL_AURA_MOD_INVISIBILITY); - - if(pVictim->GetTypeId() == TYPEID_PLAYER && !pVictim->IsStandState() && !pVictim->hasUnitState(UNIT_STAT_STUNDED)) - pVictim->SetStandState(PLAYER_STATE_NONE); - } - - //Script Event damage Deal - if( GetTypeId()== TYPEID_UNIT && ((Creature *)this)->AI()) - ((Creature *)this)->AI()->DamageDeal(pVictim, damage); - //Script Event damage taken - if( pVictim->GetTypeId()== TYPEID_UNIT && ((Creature *)pVictim)->AI() ) - ((Creature *)pVictim)->AI()->DamageTaken(this, damage); - - if(!damage) - { - // Rage from physical damage received . - if(cleanDamage && cleanDamage->damage && (damageSchoolMask & SPELL_SCHOOL_MASK_NORMAL) && pVictim->GetTypeId() == TYPEID_PLAYER && (pVictim->getPowerType() == POWER_RAGE)) - ((Player*)pVictim)->RewardRage(cleanDamage->damage, 0, false); - - return 0; - } - - pVictim->RemoveSpellbyDamageTaken(SPELL_AURA_MOD_FEAR, damage); - // root type spells do not dispell the root effect - if(!spellProto || spellProto->Mechanic != MECHANIC_ROOT) - pVictim->RemoveSpellbyDamageTaken(SPELL_AURA_MOD_ROOT, damage); - - if(pVictim->GetTypeId() != TYPEID_PLAYER) - { - // no xp,health if type 8 /critters/ - if ( pVictim->GetCreatureType() == CREATURE_TYPE_CRITTER) - { - pVictim->setDeathState(JUST_DIED); - pVictim->SetHealth(0); - - // allow loot only if has loot_id in creature_template - CreatureInfo const* cInfo = ((Creature*)pVictim)->GetCreatureInfo(); - if(cInfo && cInfo->lootid) - pVictim->SetUInt32Value(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE); - - // some critters required for quests - if(GetTypeId() == TYPEID_PLAYER) - ((Player*)this)->KilledMonster(pVictim->GetEntry(),pVictim->GetGUID()); - - return damage; - } - - if(!pVictim->isInCombat() && ((Creature*)pVictim)->AI()) - ((Creature*)pVictim)->AI()->AttackStart(this); - } - - DEBUG_LOG("DealDamageStart"); - - uint32 health = pVictim->GetHealth(); - sLog.outDetail("deal dmg:%d to health:%d ",damage,health); - - // duel ends when player has 1 or less hp - bool duel_hasEnded = false; - if(pVictim->GetTypeId() == TYPEID_PLAYER && ((Player*)pVictim)->duel && damage >= (health-1)) - { - // prevent kill only if killed in duel and killed by opponent or opponent controlled creature - if(((Player*)pVictim)->duel->opponent==this || ((Player*)pVictim)->duel->opponent->GetGUID() == GetOwnerGUID()) - damage = health-1; - - duel_hasEnded = true; - } - //Get in CombatState - if(pVictim != this && damagetype != DOT) - { - SetInCombatWith(pVictim); - pVictim->SetInCombatWith(this); - - if(Player* attackedPlayer = pVictim->GetCharmerOrOwnerPlayerOrPlayerItself()) - SetContestedPvP(attackedPlayer); - } - - // Rage from Damage made (only from direct weapon damage) - if( cleanDamage && damagetype==DIRECT_DAMAGE && this != pVictim && GetTypeId() == TYPEID_PLAYER && (getPowerType() == POWER_RAGE)) - { - uint32 weaponSpeedHitFactor; - - switch(cleanDamage->attackType) - { - case BASE_ATTACK: - { - if(cleanDamage->hitOutCome == MELEE_HIT_CRIT) - weaponSpeedHitFactor = uint32(GetAttackTime(cleanDamage->attackType)/1000.0f * 7); - else - weaponSpeedHitFactor = uint32(GetAttackTime(cleanDamage->attackType)/1000.0f * 3.5f); - - ((Player*)this)->RewardRage(damage, weaponSpeedHitFactor, true); - - break; - } - case OFF_ATTACK: - { - if(cleanDamage->hitOutCome == MELEE_HIT_CRIT) - weaponSpeedHitFactor = uint32(GetAttackTime(cleanDamage->attackType)/1000.0f * 3.5f); - else - weaponSpeedHitFactor = uint32(GetAttackTime(cleanDamage->attackType)/1000.0f * 1.75f); - - ((Player*)this)->RewardRage(damage, weaponSpeedHitFactor, true); - - break; - } - case RANGED_ATTACK: - break; - } - } - - if(pVictim->GetTypeId() == TYPEID_PLAYER && GetTypeId() == TYPEID_PLAYER) - { - if(((Player*)pVictim)->InBattleGround()) - { - Player *killer = ((Player*)this); - if(killer != ((Player*)pVictim)) - if(BattleGround *bg = killer->GetBattleGround()) - bg->UpdatePlayerScore(killer, SCORE_DAMAGE_DONE, damage); - } - } - - if (pVictim->GetTypeId() == TYPEID_UNIT && !((Creature*)pVictim)->isPet() && !((Creature*)pVictim)->hasLootRecipient()) - ((Creature*)pVictim)->SetLootRecipient(this); - if (health <= damage) - { - // battleground things - if(pVictim->GetTypeId() == TYPEID_PLAYER && (((Player*)pVictim)->InBattleGround())) - { - Player *killed = ((Player*)pVictim); - Player *killer = NULL; - if(GetTypeId() == TYPEID_PLAYER) - killer = ((Player*)this); - else if(GetTypeId() == TYPEID_UNIT && ((Creature*)this)->isPet()) - { - Unit *owner = GetOwner(); - if(owner && owner->GetTypeId() == TYPEID_PLAYER) - killer = ((Player*)owner); - } - - if(killer) - if(BattleGround *bg = killed->GetBattleGround()) - bg->HandleKillPlayer(killed, killer); // drop flags and etc - } - - DEBUG_LOG("DealDamage: victim just died"); - - // find player: owner of controlled `this` or `this` itself maybe - Player *player = GetCharmerOrOwnerPlayerOrPlayerItself(); - - if(pVictim->GetTypeId() == TYPEID_UNIT && ((Creature*)pVictim)->GetLootRecipient()) - player = ((Creature*)pVictim)->GetLootRecipient(); - // Reward player, his pets, and group/raid members - // call kill spell proc event (before real die and combat stop to triggering auras removed at death/combat stop) - if(player && player!=pVictim) - if(player->RewardPlayerAndGroupAtKill(pVictim)) - player->ProcDamageAndSpell(pVictim,PROC_FLAG_KILL_XP_GIVER,PROC_FLAG_NONE); - - DEBUG_LOG("DealDamageAttackStop"); - - // stop combat - pVictim->CombatStop(); - pVictim->getHostilRefManager().deleteReferences(); - - bool damageFromSpiritOfRedemtionTalent = spellProto && spellProto->Id == 27795; - - // if talent known but not triggered (check priest class for speedup check) - Aura* spiritOfRedemtionTalentReady = NULL; - if( !damageFromSpiritOfRedemtionTalent && // not called from SPELL_AURA_SPIRIT_OF_REDEMPTION - pVictim->GetTypeId()==TYPEID_PLAYER && pVictim->getClass()==CLASS_PRIEST ) - { - AuraList const& vDummyAuras = pVictim->GetAurasByType(SPELL_AURA_DUMMY); - for(AuraList::const_iterator itr = vDummyAuras.begin(); itr != vDummyAuras.end(); ++itr) - { - if((*itr)->GetSpellProto()->SpellIconID==1654) - { - spiritOfRedemtionTalentReady = *itr; - break; - } - } - } - - DEBUG_LOG("SET JUST_DIED"); - if(!spiritOfRedemtionTalentReady) - pVictim->setDeathState(JUST_DIED); - - DEBUG_LOG("DealDamageHealth1"); - - if(spiritOfRedemtionTalentReady) - { - // save value before aura remove - uint32 ressSpellId = pVictim->GetUInt32Value(PLAYER_SELF_RES_SPELL); - if(!ressSpellId) - ressSpellId = ((Player*)pVictim)->GetResurrectionSpellId(); - - //Remove all expected to remove at death auras (most important negative case like DoT or periodic triggers) - pVictim->RemoveAllAurasOnDeath(); - - // restore for use at real death - pVictim->SetUInt32Value(PLAYER_SELF_RES_SPELL,ressSpellId); - - // FORM_SPIRITOFREDEMPTION and related auras - pVictim->CastSpell(pVictim,27827,true,NULL,spiritOfRedemtionTalentReady); - } - else - pVictim->SetHealth(0); - - // remember victim PvP death for corpse type and corpse reclaim delay - // at original death (not at SpiritOfRedemtionTalent timeout) - if( pVictim->GetTypeId()==TYPEID_PLAYER && !damageFromSpiritOfRedemtionTalent ) - ((Player*)pVictim)->SetPvPDeath(player!=NULL); - - // Call KilledUnit for creatures - if (GetTypeId() == TYPEID_UNIT && ((Creature*)this)->AI()) - ((Creature*)this)->AI()->KilledUnit(pVictim); - - // 10% durability loss on death - // clean InHateListOf - if (pVictim->GetTypeId() == TYPEID_PLAYER) - { - // only if not player and not controlled by player pet. And not at BG - if (durabilityLoss && !player && !((Player*)pVictim)->InBattleGround()) - { - DEBUG_LOG("We are dead, loosing 10 percents durability"); - ((Player*)pVictim)->DurabilityLossAll(0.10f,false); - // durability lost message - WorldPacket data(SMSG_DURABILITY_DAMAGE_DEATH, 0); - ((Player*)pVictim)->GetSession()->SendPacket(&data); - } - } - else // creature died - { - DEBUG_LOG("DealDamageNotPlayer"); - Creature *cVictim = (Creature*)pVictim; - - if(!cVictim->isPet()) - { - cVictim->DeleteThreatList(); - cVictim->SetUInt32Value(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE); - } - // Call creature just died function - if (cVictim->AI()) - cVictim->AI()->JustDied(this); - - // Dungeon specific stuff, only applies to players killing creatures - if(cVictim->GetInstanceId()) - { - Map *m = cVictim->GetMap(); - Player *creditedPlayer = GetCharmerOrOwnerPlayerOrPlayerItself(); - // TODO: do instance binding anyway if the charmer/owner is offline - - if(m->IsDungeon() && creditedPlayer) - { - if(m->IsRaid() || m->IsHeroic()) - { - if(cVictim->GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_INSTANCE_BIND) - ((InstanceMap *)m)->PermBindAllPlayers(creditedPlayer); - } - else - { - // the reset time is set but not added to the scheduler - // until the players leave the instance - time_t resettime = cVictim->GetRespawnTimeEx() + 2 * HOUR; - if(InstanceSave *save = sInstanceSaveManager.GetInstanceSave(cVictim->GetInstanceId())) - if(save->GetResetTime() < resettime) save->SetResetTime(resettime); - } - } - } - } - - // last damage from non duel opponent or opponent controlled creature - if(duel_hasEnded) - { - assert(pVictim->GetTypeId()==TYPEID_PLAYER); - Player *he = (Player*)pVictim; - - assert(he->duel); - - he->duel->opponent->CombatStopWithPets(true); - he->CombatStopWithPets(true); - - he->DuelComplete(DUEL_INTERUPTED); - } - } - else // if (health <= damage) - { - DEBUG_LOG("DealDamageAlive"); - - pVictim->ModifyHealth(- (int32)damage); - - // Check if health is below 20% (apply damage before to prevent case when after ProcDamageAndSpell health < damage - if(pVictim->GetHealth()*5 < pVictim->GetMaxHealth()) - { - uint32 procVictim = PROC_FLAG_NONE; - - // if just dropped below 20% (for CheatDeath) - if((pVictim->GetHealth()+damage)*5 > pVictim->GetMaxHealth()) - procVictim = PROC_FLAG_LOW_HEALTH; - - ProcDamageAndSpell(pVictim,PROC_FLAG_TARGET_LOW_HEALTH,procVictim); - } - - if(damagetype != DOT) - { - if(getVictim()) - { - // if have target and damage pVictim just call AI recation - if(pVictim != getVictim() && pVictim->GetTypeId()==TYPEID_UNIT && ((Creature*)pVictim)->AI()) - ((Creature*)pVictim)->AI()->AttackedBy(this); - } - else - { - // if not have main target then attack state with target (including AI call) - //start melee attacks only after melee hit - Attack(pVictim,(damagetype == DIRECT_DAMAGE)); - } - } - - // polymorphed and other negative transformed cases - if(pVictim->getTransForm() && pVictim->hasUnitState(UNIT_STAT_CONFUSED)) - pVictim->RemoveAurasDueToSpell(pVictim->getTransForm()); - - if(damagetype == DIRECT_DAMAGE|| damagetype == SPELL_DIRECT_DAMAGE) - pVictim->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_DIRECT_DAMAGE); - - if (pVictim->GetTypeId() != TYPEID_PLAYER) - { - if(spellProto && IsDamageToThreatSpell(spellProto)) - pVictim->AddThreat(this, damage*2, damageSchoolMask, spellProto); - else - pVictim->AddThreat(this, damage, damageSchoolMask, spellProto); - } - else // victim is a player - { - // Rage from damage received - if(this != pVictim && pVictim->getPowerType() == POWER_RAGE) - { - uint32 rage_damage = damage + (cleanDamage ? cleanDamage->damage : 0); - ((Player*)pVictim)->RewardRage(rage_damage, 0, false); - } - - // random durability for items (HIT TAKEN) - if (roll_chance_f(sWorld.getRate(RATE_DURABILITY_LOSS_DAMAGE))) - { - EquipmentSlots slot = EquipmentSlots(urand(0,EQUIPMENT_SLOT_END-1)); - ((Player*)pVictim)->DurabilityPointLossForEquipSlot(slot); - } - } - - if(GetTypeId()==TYPEID_PLAYER) - { - // random durability for items (HIT DONE) - if (roll_chance_f(sWorld.getRate(RATE_DURABILITY_LOSS_DAMAGE))) - { - EquipmentSlots slot = EquipmentSlots(urand(0,EQUIPMENT_SLOT_END-1)); - ((Player*)this)->DurabilityPointLossForEquipSlot(slot); - } - } - - // TODO: Store auras by interrupt flag to speed this up. - AuraMap& vAuras = pVictim->GetAuras(); - for (AuraMap::iterator i = vAuras.begin(), next; i != vAuras.end(); i = next) - { - const SpellEntry *se = i->second->GetSpellProto(); - next = i; ++next; - if( se->AuraInterruptFlags & AURA_INTERRUPT_FLAG_DAMAGE ) - { - bool remove = true; - if (se->procFlags & (1<<3)) - { - if (!roll_chance_i(se->procChance)) - remove = false; - } - if (remove) - { - pVictim->RemoveAurasDueToSpell(i->second->GetId()); - // FIXME: this may cause the auras with proc chance to be rerolled several times - next = vAuras.begin(); - } - } - } - - if (damagetype != NODAMAGE && damage && pVictim->GetTypeId() == TYPEID_PLAYER) - { - if( damagetype != DOT ) - { - for (uint32 i = CURRENT_FIRST_NON_MELEE_SPELL; i < CURRENT_MAX_SPELL; i++) - { - // skip channeled spell (processed differently below) - if (i == CURRENT_CHANNELED_SPELL) - continue; - - if(Spell* spell = pVictim->m_currentSpells[i]) - if(spell->getState() == SPELL_STATE_PREPARING) - spell->Delayed(); - } - } - - if(Spell* spell = pVictim->m_currentSpells[CURRENT_CHANNELED_SPELL]) - { - if (spell->getState() == SPELL_STATE_CASTING) - { - uint32 channelInterruptFlags = spell->m_spellInfo->ChannelInterruptFlags; - if( channelInterruptFlags & CHANNEL_FLAG_DELAY ) - { - if(pVictim!=this) //don't shorten the duration of channeling if you damage yourself - spell->DelayedChannel(); - } - else if( (channelInterruptFlags & (CHANNEL_FLAG_DAMAGE | CHANNEL_FLAG_DAMAGE2)) ) - { - sLog.outDetail("Spell %u canceled at damage!",spell->m_spellInfo->Id); - pVictim->InterruptSpell(CURRENT_CHANNELED_SPELL); - } - } - else if (spell->getState() == SPELL_STATE_DELAYED) - // break channeled spell in delayed state on damage - { - sLog.outDetail("Spell %u canceled at damage!",spell->m_spellInfo->Id); - pVictim->InterruptSpell(CURRENT_CHANNELED_SPELL); - } - } - } - - // last damage from duel opponent - if(duel_hasEnded) - { - assert(pVictim->GetTypeId()==TYPEID_PLAYER); - Player *he = (Player*)pVictim; - - assert(he->duel); - - he->SetHealth(1); - - he->duel->opponent->CombatStopWithPets(true); - he->CombatStopWithPets(true); - - he->CastSpell(he, 7267, true); // beg - he->DuelComplete(DUEL_WON); - } - } - - DEBUG_LOG("DealDamageEnd returned %d damage", damage); - - return damage; -} - -void Unit::CastStop(uint32 except_spellid) -{ - for (uint32 i = CURRENT_FIRST_NON_MELEE_SPELL; i < CURRENT_MAX_SPELL; i++) - if (m_currentSpells[i] && m_currentSpells[i]->m_spellInfo->Id!=except_spellid) - InterruptSpell(i,false); -} - -void Unit::CastSpell(Unit* Victim, uint32 spellId, bool triggered, Item *castItem, Aura* triggredByAura, uint64 originalCaster) -{ - SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellId ); - - if(!spellInfo) - { - sLog.outError("CastSpell: unknown spell id %i by caster: %s %u)", spellId,(GetTypeId()==TYPEID_PLAYER ? "player (GUID:" : "creature (Entry:"),(GetTypeId()==TYPEID_PLAYER ? GetGUIDLow() : GetEntry())); - return; - } - - CastSpell(Victim,spellInfo,triggered,castItem,triggredByAura, originalCaster); -} - -void Unit::CastSpell(Unit* Victim,SpellEntry const *spellInfo, bool triggered, Item *castItem, Aura* triggredByAura, uint64 originalCaster) -{ - if(!spellInfo) - { - sLog.outError("CastSpell: unknown spell by caster: %s %u)", (GetTypeId()==TYPEID_PLAYER ? "player (GUID:" : "creature (Entry:"),(GetTypeId()==TYPEID_PLAYER ? GetGUIDLow() : GetEntry())); - return; - } - - if (castItem) - DEBUG_LOG("WORLD: cast Item spellId - %i", spellInfo->Id); - - if(!originalCaster && triggredByAura) - originalCaster = triggredByAura->GetCasterGUID(); - - Spell *spell = new Spell(this, spellInfo, triggered, originalCaster ); - - SpellCastTargets targets; - targets.setUnitTarget( Victim ); - spell->m_CastItem = castItem; - spell->prepare(&targets, triggredByAura); -} - -void Unit::CastCustomSpell(Unit* Victim,uint32 spellId, int32 const* bp0, int32 const* bp1, int32 const* bp2, bool triggered, Item *castItem, Aura* triggredByAura, uint64 originalCaster) -{ - SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellId ); - - if(!spellInfo) - { - sLog.outError("CastCustomSpell: unknown spell id %i\n", spellId); - return; - } - - CastCustomSpell(Victim,spellInfo,bp0,bp1,bp2,triggered,castItem,triggredByAura, originalCaster); -} - -void Unit::CastCustomSpell(Unit* Victim,SpellEntry const *spellInfo, int32 const* bp0, int32 const* bp1, int32 const* bp2, bool triggered, Item *castItem, Aura* triggredByAura, uint64 originalCaster) -{ - if(!spellInfo) - { - sLog.outError("CastCustomSpell: unknown spell"); - return; - } - - if (castItem) - DEBUG_LOG("WORLD: cast Item spellId - %i", spellInfo->Id); - - if(!originalCaster && triggredByAura) - originalCaster = triggredByAura->GetCasterGUID(); - - Spell *spell = new Spell(this, spellInfo, triggered, originalCaster); - - if(bp0) - spell->m_currentBasePoints[0] = *bp0-int32(spellInfo->EffectBaseDice[0]); - - if(bp1) - spell->m_currentBasePoints[1] = *bp1-int32(spellInfo->EffectBaseDice[1]); - - if(bp2) - spell->m_currentBasePoints[2] = *bp2-int32(spellInfo->EffectBaseDice[2]); - - SpellCastTargets targets; - targets.setUnitTarget( Victim ); - spell->m_CastItem = castItem; - spell->prepare(&targets, triggredByAura); -} - -// used for scripting -void Unit::CastSpell(float x, float y, float z, uint32 spellId, bool triggered, Item *castItem, Aura* triggredByAura, uint64 originalCaster) -{ - SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellId ); - - if(!spellInfo) - { - sLog.outError("CastSpell(x,y,z): unknown spell id %i by caster: %s %u)", spellId,(GetTypeId()==TYPEID_PLAYER ? "player (GUID:" : "creature (Entry:"),(GetTypeId()==TYPEID_PLAYER ? GetGUIDLow() : GetEntry())); - return; - } - - CastSpell(x, y, z,spellInfo,triggered,castItem,triggredByAura, originalCaster); -} - -// used for scripting -void Unit::CastSpell(float x, float y, float z, SpellEntry const *spellInfo, bool triggered, Item *castItem, Aura* triggredByAura, uint64 originalCaster) -{ - if(!spellInfo) - { - sLog.outError("CastSpell(x,y,z): unknown spell by caster: %s %u)", (GetTypeId()==TYPEID_PLAYER ? "player (GUID:" : "creature (Entry:"),(GetTypeId()==TYPEID_PLAYER ? GetGUIDLow() : GetEntry())); - return; - } - - if (castItem) - DEBUG_LOG("WORLD: cast Item spellId - %i", spellInfo->Id); - - if(!originalCaster && triggredByAura) - originalCaster = triggredByAura->GetCasterGUID(); - - Spell *spell = new Spell(this, spellInfo, triggered, originalCaster ); - - SpellCastTargets targets; - targets.setDestination(x, y, z); - spell->m_CastItem = castItem; - spell->prepare(&targets, triggredByAura); -} - -void Unit::DealFlatDamage(Unit *pVictim, SpellEntry const *spellInfo, uint32 *damage, CleanDamage *cleanDamage, bool *crit, bool isTriggeredSpell) -{ - // TODO this in only generic way, check for exceptions - DEBUG_LOG("DealFlatDamage (BEFORE) >> DMG:%u", *damage); - - // Per-damage calss calculation - switch (spellInfo->DmgClass) - { - // Melee and Ranged Spells - case SPELL_DAMAGE_CLASS_RANGED: - case SPELL_DAMAGE_CLASS_MELEE: - { - // Calculate physical outcome - MeleeHitOutcome outcome = RollPhysicalOutcomeAgainst(pVictim, BASE_ATTACK, spellInfo); - - //Used to store the Hit Outcome - cleanDamage->hitOutCome = outcome; - - // Return miss/evade first (sends miss message) - switch(outcome) - { - case MELEE_HIT_EVADE: - { - SendAttackStateUpdate(HITINFO_MISS, pVictim, 1, GetSpellSchoolMask(spellInfo), 0, 0,0,VICTIMSTATE_EVADES,0); - *damage = 0; - return; - } - case MELEE_HIT_MISS: - { - SendAttackStateUpdate(HITINFO_MISS, pVictim, 1, GetSpellSchoolMask(spellInfo), 0, 0,0,VICTIMSTATE_NORMAL,0); - *damage = 0; - - if(GetTypeId()== TYPEID_PLAYER) - ((Player*)this)->UpdateWeaponSkill(BASE_ATTACK); - - CastMeleeProcDamageAndSpell(pVictim,0,GetSpellSchoolMask(spellInfo),BASE_ATTACK,MELEE_HIT_MISS,spellInfo,isTriggeredSpell); - return; - } - } - - // Hitinfo, Victimstate - uint32 hitInfo = HITINFO_NORMALSWING; - VictimState victimState = VICTIMSTATE_NORMAL; - - // Physical Damage - if ( GetSpellSchoolMask(spellInfo) & SPELL_SCHOOL_MASK_NORMAL ) - { - uint32 modDamage=*damage; - - // apply spellmod to Done damage - if(Player* modOwner = GetSpellModOwner()) - modOwner->ApplySpellMod(spellInfo->Id, SPELLMOD_DAMAGE, *damage); - - //Calculate armor mitigation - uint32 damageAfterArmor = CalcArmorReducedDamage(pVictim, *damage); - - // random durability for main hand weapon (ABSORB) - if(damageAfterArmor < *damage) - if(pVictim->GetTypeId() == TYPEID_PLAYER) - if (roll_chance_f(sWorld.getRate(RATE_DURABILITY_LOSS_ABSORB))) - ((Player*)pVictim)->DurabilityPointLossForEquipSlot(EquipmentSlots(urand(EQUIPMENT_SLOT_START,EQUIPMENT_SLOT_BACK))); - - cleanDamage->damage += *damage - damageAfterArmor; - *damage = damageAfterArmor; - } - // Magical Damage - else - { - // Calculate damage bonus - *damage = SpellDamageBonus(pVictim, spellInfo, *damage, SPELL_DIRECT_DAMAGE); - } - - // Classify outcome - switch (outcome) - { - case MELEE_HIT_BLOCK_CRIT: - case MELEE_HIT_CRIT: - { - uint32 bonusDmg = *damage; - - // Apply crit_damage bonus - if(Player* modOwner = GetSpellModOwner()) - modOwner->ApplySpellMod(spellInfo->Id, SPELLMOD_CRIT_DAMAGE_BONUS, bonusDmg); - - uint32 creatureTypeMask = pVictim->GetCreatureTypeMask(); - AuraList const& mDamageDoneVersus = GetAurasByType(SPELL_AURA_MOD_CRIT_PERCENT_VERSUS); - for(AuraList::const_iterator i = mDamageDoneVersus.begin();i != mDamageDoneVersus.end(); ++i) - if(creatureTypeMask & uint32((*i)->GetModifier()->m_miscvalue)) - bonusDmg = uint32(bonusDmg * ((*i)->GetModifier()->m_amount+100.0f)/100.0f); - - *damage += bonusDmg; - - // Resilience - reduce crit damage - if (pVictim->GetTypeId()==TYPEID_PLAYER) - { - uint32 resilienceReduction = ((Player*)pVictim)->GetMeleeCritDamageReduction(*damage); - cleanDamage->damage += resilienceReduction; - *damage -= resilienceReduction; - } - - *crit = true; - hitInfo |= HITINFO_CRITICALHIT; - - ModifyAuraState(AURA_STATE_CRIT, true); - StartReactiveTimer( REACTIVE_CRIT ); - - if(getClass()==CLASS_HUNTER) - { - ModifyAuraState(AURA_STATE_HUNTER_CRIT_STRIKE, true); - StartReactiveTimer( REACTIVE_HUNTER_CRIT ); - } - - if ( outcome == MELEE_HIT_BLOCK_CRIT ) - { - uint32 blocked_amount = uint32(pVictim->GetShieldBlockValue()); - if (blocked_amount >= *damage) - { - hitInfo |= HITINFO_SWINGNOHITSOUND; - victimState = VICTIMSTATE_BLOCKS; - cleanDamage->damage += *damage; // To Help Calculate Rage - *damage = 0; - } - else - { - // To Help Calculate Rage - cleanDamage->damage += blocked_amount; - *damage = *damage - blocked_amount; - } - - pVictim->ModifyAuraState(AURA_STATE_DEFENSE, true); - pVictim->StartReactiveTimer( REACTIVE_DEFENSE ); - - if(pVictim->GetTypeId() == TYPEID_PLAYER) - { - // Update defense - ((Player*)pVictim)->UpdateDefense(); - - // random durability for main hand weapon (BLOCK) - if (roll_chance_f(sWorld.getRate(RATE_DURABILITY_LOSS_BLOCK))) - ((Player*)pVictim)->DurabilityPointLossForEquipSlot(EQUIPMENT_SLOT_OFFHAND); - } - } - break; - } - case MELEE_HIT_PARRY: - { - cleanDamage->damage += *damage; // To Help Calculate Rage - *damage = 0; - victimState = VICTIMSTATE_PARRY; - - // Counter-attack ( explained in Unit::DoAttackDamage() ) - if(pVictim->GetTypeId()==TYPEID_PLAYER || !(((Creature*)pVictim)->GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_NO_PARRY_HASTEN) ) - { - // Get attack timers - float offtime = float(pVictim->getAttackTimer(OFF_ATTACK)); - float basetime = float(pVictim->getAttackTimer(BASE_ATTACK)); - - // Reduce attack time - if (pVictim->haveOffhandWeapon() && offtime < basetime) - { - float percent20 = pVictim->GetAttackTime(OFF_ATTACK) * 0.20; - float percent60 = 3 * percent20; - if(offtime > percent20 && offtime <= percent60) - { - pVictim->setAttackTimer(OFF_ATTACK, uint32(percent20)); - } - else if(offtime > percent60) - { - offtime -= 2 * percent20; - pVictim->setAttackTimer(OFF_ATTACK, uint32(offtime)); - } - } - else - { - float percent20 = pVictim->GetAttackTime(BASE_ATTACK) * 0.20; - float percent60 = 3 * percent20; - if(basetime > percent20 && basetime <= percent60) - { - pVictim->setAttackTimer(BASE_ATTACK, uint32(percent20)); - } - else if(basetime > percent60) - { - basetime -= 2 * percent20; - pVictim->setAttackTimer(BASE_ATTACK, uint32(basetime)); - } - } - } - - if(pVictim->GetTypeId() == TYPEID_PLAYER) - { - // Update victim defense ? - ((Player*)pVictim)->UpdateDefense(); - - // random durability for main hand weapon (PARRY) - if (roll_chance_f(sWorld.getRate(RATE_DURABILITY_LOSS_PARRY))) - ((Player*)pVictim)->DurabilityPointLossForEquipSlot(EQUIPMENT_SLOT_MAINHAND); - } - - // Set parry flags - pVictim->HandleEmoteCommand(EMOTE_ONESHOT_PARRYUNARMED); - - // Mongoose bite - set only Counterattack here - if (pVictim->getClass() == CLASS_HUNTER) - { - pVictim->ModifyAuraState(AURA_STATE_HUNTER_PARRY,true); - pVictim->StartReactiveTimer( REACTIVE_HUNTER_PARRY ); - } - else - { - pVictim->ModifyAuraState(AURA_STATE_DEFENSE, true); - pVictim->StartReactiveTimer( REACTIVE_DEFENSE ); - } - break; - } - case MELEE_HIT_DODGE: - { - if(pVictim->GetTypeId() == TYPEID_PLAYER) - ((Player*)pVictim)->UpdateDefense(); - - cleanDamage->damage += *damage; // To Help Calculate Rage - *damage = 0; - hitInfo |= HITINFO_SWINGNOHITSOUND; - victimState = VICTIMSTATE_DODGE; - - // Set dodge flags - pVictim->HandleEmoteCommand(EMOTE_ONESHOT_PARRYUNARMED); - - // Overpower - if (GetTypeId() == TYPEID_PLAYER && getClass() == CLASS_WARRIOR) - { - ((Player*)this)->AddComboPoints(pVictim, 1); - StartReactiveTimer( REACTIVE_OVERPOWER ); - } - - // Riposte - if (pVictim->getClass() != CLASS_ROGUE) - { - pVictim->ModifyAuraState(AURA_STATE_DEFENSE, true); - pVictim->StartReactiveTimer( REACTIVE_DEFENSE ); - } - break; - } - case MELEE_HIT_BLOCK: - { - uint32 blocked_amount = uint32(pVictim->GetShieldBlockValue()); - if (blocked_amount >= *damage) - { - hitInfo |= HITINFO_SWINGNOHITSOUND; - victimState = VICTIMSTATE_BLOCKS; - cleanDamage->damage += *damage; // To Help Calculate Rage - *damage = 0; - } - else - { - // To Help Calculate Rage - cleanDamage->damage += blocked_amount; - *damage = *damage - blocked_amount; - } - - pVictim->ModifyAuraState(AURA_STATE_DEFENSE, true); - pVictim->StartReactiveTimer( REACTIVE_DEFENSE ); - - if(pVictim->GetTypeId() == TYPEID_PLAYER) - { - // Update defense - ((Player*)pVictim)->UpdateDefense(); - - // random durability for main hand weapon (BLOCK) - if (roll_chance_f(sWorld.getRate(RATE_DURABILITY_LOSS_BLOCK))) - ((Player*)pVictim)->DurabilityPointLossForEquipSlot(EQUIPMENT_SLOT_OFFHAND); - } - break; - } - case MELEE_HIT_EVADE: // already processed early - case MELEE_HIT_MISS: // already processed early - case MELEE_HIT_GLANCING: - case MELEE_HIT_CRUSHING: - case MELEE_HIT_NORMAL: - break; - } - - // do all damage=0 cases here - if(*damage == 0) - CastMeleeProcDamageAndSpell(pVictim,0,GetSpellSchoolMask(spellInfo),BASE_ATTACK,outcome,spellInfo,isTriggeredSpell); - - break; - } - // Magical Attacks - case SPELL_DAMAGE_CLASS_NONE: - case SPELL_DAMAGE_CLASS_MAGIC: - { - // Calculate damage bonus - *damage = SpellDamageBonus(pVictim, spellInfo, *damage, SPELL_DIRECT_DAMAGE); - - *crit = isSpellCrit(pVictim, spellInfo, GetSpellSchoolMask(spellInfo), BASE_ATTACK); - if (*crit) - { - *damage = SpellCriticalBonus(spellInfo, *damage, pVictim); - - // Resilience - reduce crit damage - if (pVictim && pVictim->GetTypeId()==TYPEID_PLAYER) - { - uint32 damage_reduction = ((Player *)pVictim)->GetSpellCritDamageReduction(*damage); - if(*damage > damage_reduction) - *damage -= damage_reduction; - else - *damage = 0; - } - - cleanDamage->hitOutCome = MELEE_HIT_CRIT; - } - // spell proc all magic damage==0 case in this function - if(*damage == 0) - { - // Procflags - uint32 procAttacker = PROC_FLAG_HIT_SPELL; - uint32 procVictim = (PROC_FLAG_STRUCK_SPELL|PROC_FLAG_TAKE_DAMAGE); - - ProcDamageAndSpell(pVictim, procAttacker, procVictim, 0, GetSpellSchoolMask(spellInfo), spellInfo, isTriggeredSpell); - } - - break; - } - } - - // TODO this in only generic way, check for exceptions - DEBUG_LOG("DealFlatDamage (AFTER) >> DMG:%u", *damage); -} - -uint32 Unit::SpellNonMeleeDamageLog(Unit *pVictim, uint32 spellID, uint32 damage, bool isTriggeredSpell, bool useSpellDamage) -{ - if(!this || !pVictim) - return 0; - if(!this->isAlive() || !pVictim->isAlive()) - return 0; - - SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellID); - if(!spellInfo) - return 0; - - CleanDamage cleanDamage = CleanDamage(0, BASE_ATTACK, MELEE_HIT_NORMAL); - bool crit = false; - - if (useSpellDamage) - DealFlatDamage(pVictim, spellInfo, &damage, &cleanDamage, &crit, isTriggeredSpell); - - // If we actually dealt some damage (spell proc's for 0 damage (normal and magic) called in DealFlatDamage) - if(damage > 0) - { - // Calculate absorb & resists - uint32 absorb = 0; - uint32 resist = 0; - - CalcAbsorbResist(pVictim,GetSpellSchoolMask(spellInfo), SPELL_DIRECT_DAMAGE, damage, &absorb, &resist); - - //No more damage left, target absorbed and/or resisted all damage - if (damage > absorb + resist) - damage -= absorb + resist; //Remove Absorbed and Resisted from damage actually dealt - else - { - uint32 HitInfo = HITINFO_SWINGNOHITSOUND; - - if (absorb) - HitInfo |= HITINFO_ABSORB; - if (resist) - { - HitInfo |= HITINFO_RESIST; - ProcDamageAndSpell(pVictim, PROC_FLAG_TARGET_RESISTS, PROC_FLAG_RESIST_SPELL, 0, GetSpellSchoolMask(spellInfo), spellInfo,isTriggeredSpell); - } - - //Send resist - SendAttackStateUpdate(HitInfo, pVictim, 1, GetSpellSchoolMask(spellInfo), damage, absorb,resist,VICTIMSTATE_NORMAL,0); - return 0; - } - - // Deal damage done - damage = DealDamage(pVictim, damage, &cleanDamage, SPELL_DIRECT_DAMAGE, GetSpellSchoolMask(spellInfo), spellInfo, true); - - // Send damage log - sLog.outDetail("SpellNonMeleeDamageLog: %u (TypeId: %u) attacked %u (TypeId: %u) for %u dmg inflicted by %u,absorb is %u,resist is %u", - GetGUIDLow(), GetTypeId(), pVictim->GetGUIDLow(), pVictim->GetTypeId(), damage, spellID, absorb,resist); - - // Actual log sent to client - SendSpellNonMeleeDamageLog(pVictim, spellID, damage, GetSpellSchoolMask(spellInfo), absorb, resist, false, 0, crit); - - // Procflags - uint32 procAttacker = PROC_FLAG_HIT_SPELL; - uint32 procVictim = (PROC_FLAG_STRUCK_SPELL|PROC_FLAG_TAKE_DAMAGE); - - if (crit) - { - procAttacker |= PROC_FLAG_CRIT_SPELL; - procVictim |= PROC_FLAG_STRUCK_CRIT_SPELL; - } - - ProcDamageAndSpell(pVictim, procAttacker, procVictim, damage, GetSpellSchoolMask(spellInfo), spellInfo, isTriggeredSpell); - - return damage; - } - else - { - // all spell proc for 0 normal and magic damage called in DealFlatDamage - - //Check for rage - if(cleanDamage.damage) - // Rage from damage received. - if(pVictim->GetTypeId() == TYPEID_PLAYER && (pVictim->getPowerType() == POWER_RAGE)) - ((Player*)pVictim)->RewardRage(cleanDamage.damage, 0, false); - - return 0; - } -} - -void Unit::HandleEmoteCommand(uint32 anim_id) -{ - WorldPacket data( SMSG_EMOTE, 12 ); - data << anim_id << GetGUID(); - WPAssert(data.size() == 12); - - SendMessageToSet(&data, true); -} - -uint32 Unit::CalcArmorReducedDamage(Unit* pVictim, const uint32 damage) -{ - uint32 newdamage = 0; - float armor = pVictim->GetArmor(); - // Ignore enemy armor by SPELL_AURA_MOD_TARGET_RESISTANCE aura - armor += GetTotalAuraModifierByMiscMask(SPELL_AURA_MOD_TARGET_RESISTANCE, SPELL_SCHOOL_MASK_NORMAL); - - if (armor<0.0f) armor=0.0f; - - float tmpvalue = 0.0f; - if(getLevel() <= 59) //Level 1-59 - tmpvalue = armor / (armor + 400.0f + 85.0f * getLevel()); - else if(getLevel() < 70) //Level 60-69 - tmpvalue = armor / (armor - 22167.5f + 467.5f * getLevel()); - else //Level 70+ - tmpvalue = armor / (armor + 10557.5f); - - if(tmpvalue < 0.0f) - tmpvalue = 0.0f; - if(tmpvalue > 0.75f) - tmpvalue = 0.75f; - newdamage = uint32(damage - (damage * tmpvalue)); - - return (newdamage > 1) ? newdamage : 1; -} - -void Unit::CalcAbsorbResist(Unit *pVictim,SpellSchoolMask schoolMask, DamageEffectType damagetype, const uint32 damage, uint32 *absorb, uint32 *resist) -{ - if(!pVictim || !pVictim->isAlive() || !damage) - return; - - // Magic damage, check for resists - if ((schoolMask & SPELL_SCHOOL_MASK_NORMAL)==0) - { - // Get base victim resistance for school - float tmpvalue2 = (float)pVictim->GetResistance(GetFirstSchoolInMask(schoolMask)); - // Ignore resistance by self SPELL_AURA_MOD_TARGET_RESISTANCE aura - tmpvalue2 += (float)GetTotalAuraModifierByMiscMask(SPELL_AURA_MOD_TARGET_RESISTANCE, schoolMask); - - tmpvalue2 *= (float)(0.15f / getLevel()); - if (tmpvalue2 < 0.0f) - tmpvalue2 = 0.0f; - if (tmpvalue2 > 0.75f) - tmpvalue2 = 0.75f; - uint32 ran = urand(0, 100); - uint32 faq[4] = {24,6,4,6}; - uint8 m = 0; - float Binom = 0.0f; - for (uint8 i = 0; i < 4; i++) - { - Binom += 2400 *( powf(tmpvalue2, i) * powf( (1-tmpvalue2), (4-i)))/faq[i]; - if (ran > Binom ) - ++m; - else - break; - } - if (damagetype == DOT && m == 4) - *resist += uint32(damage - 1); - else - *resist += uint32(damage * m / 4); - if(*resist > damage) - *resist = damage; - } - else - *resist = 0; - - int32 RemainingDamage = damage - *resist; - - // absorb without mana cost - int32 reflectDamage = 0; - Aura* reflectAura = NULL; - AuraList const& vSchoolAbsorb = pVictim->GetAurasByType(SPELL_AURA_SCHOOL_ABSORB); - for(AuraList::const_iterator i = vSchoolAbsorb.begin(), next; i != vSchoolAbsorb.end() && RemainingDamage > 0; i = next) - { - next = i; ++next; - - if (((*i)->GetModifier()->m_miscvalue & schoolMask)==0) - continue; - - // Cheat Death - if((*i)->GetSpellProto()->SpellFamilyName==SPELLFAMILY_ROGUE && (*i)->GetSpellProto()->SpellIconID == 2109) - { - if (((Player*)pVictim)->HasSpellCooldown(31231)) - continue; - if (pVictim->GetHealth() <= RemainingDamage) - { - int32 chance = (*i)->GetModifier()->m_amount; - if (roll_chance_i(chance)) - { - pVictim->CastSpell(pVictim,31231,true); - ((Player*)pVictim)->AddSpellCooldown(31231,0,time(NULL)+60); - - // with health > 10% lost health until health==10%, in other case no losses - uint32 health10 = pVictim->GetMaxHealth()/10; - RemainingDamage = pVictim->GetHealth() > health10 ? pVictim->GetHealth() - health10 : 0; - } - } - continue; - } - - int32 currentAbsorb; - - //Reflective Shield - if ((pVictim != this) && (*i)->GetSpellProto()->SpellFamilyName == SPELLFAMILY_PRIEST && (*i)->GetSpellProto()->SpellFamilyFlags == 0x1) - { - if(Unit* caster = (*i)->GetCaster()) - { - AuraList const& vOverRideCS = caster->GetAurasByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS); - for(AuraList::const_iterator k = vOverRideCS.begin(); k != vOverRideCS.end(); ++k) - { - switch((*k)->GetModifier()->m_miscvalue) - { - case 5065: // Rank 1 - case 5064: // Rank 2 - case 5063: // Rank 3 - case 5062: // Rank 4 - case 5061: // Rank 5 - { - if(RemainingDamage >= (*i)->GetModifier()->m_amount) - reflectDamage = (*i)->GetModifier()->m_amount * (*k)->GetModifier()->m_amount/100; - else - reflectDamage = (*k)->GetModifier()->m_amount * RemainingDamage/100; - reflectAura = *i; - - } break; - default: break; - } - - if(reflectDamage) - break; - } - } - } - - if (RemainingDamage >= (*i)->GetModifier()->m_amount) - { - currentAbsorb = (*i)->GetModifier()->m_amount; - pVictim->RemoveAurasDueToSpell((*i)->GetId()); - next = vSchoolAbsorb.begin(); - } - else - { - currentAbsorb = RemainingDamage; - (*i)->GetModifier()->m_amount -= RemainingDamage; - } - - RemainingDamage -= currentAbsorb; - } - // do not cast spells while looping auras; auras can get invalid otherwise - if (reflectDamage) - pVictim->CastCustomSpell(this, 33619, &reflectDamage, NULL, NULL, true, NULL, reflectAura); - - // absorb by mana cost - AuraList const& vManaShield = pVictim->GetAurasByType(SPELL_AURA_MANA_SHIELD); - for(AuraList::const_iterator i = vManaShield.begin(), next; i != vManaShield.end() && RemainingDamage > 0; i = next) - { - next = i; ++next; - - // check damage school mask - if(((*i)->GetModifier()->m_miscvalue & schoolMask)==0) - continue; - - int32 currentAbsorb; - if (RemainingDamage >= (*i)->GetModifier()->m_amount) - currentAbsorb = (*i)->GetModifier()->m_amount; - else - currentAbsorb = RemainingDamage; - - float manaMultiplier = (*i)->GetSpellProto()->EffectMultipleValue[(*i)->GetEffIndex()]; - if(Player *modOwner = GetSpellModOwner()) - modOwner->ApplySpellMod((*i)->GetId(), SPELLMOD_MULTIPLE_VALUE, manaMultiplier); - - int32 maxAbsorb = int32(pVictim->GetPower(POWER_MANA) / manaMultiplier); - if (currentAbsorb > maxAbsorb) - currentAbsorb = maxAbsorb; - - (*i)->GetModifier()->m_amount -= currentAbsorb; - if((*i)->GetModifier()->m_amount <= 0) - { - pVictim->RemoveAurasDueToSpell((*i)->GetId()); - next = vManaShield.begin(); - } - - int32 manaReduction = int32(currentAbsorb * manaMultiplier); - pVictim->ApplyPowerMod(POWER_MANA, manaReduction, false); - - RemainingDamage -= currentAbsorb; - } - - AuraList const& vSplitDamageFlat = pVictim->GetAurasByType(SPELL_AURA_SPLIT_DAMAGE_FLAT); - for(AuraList::const_iterator i = vSplitDamageFlat.begin(), next; i != vSplitDamageFlat.end() && RemainingDamage >= 0; i = next) - { - next = i; ++next; - - // check damage school mask - if(((*i)->GetModifier()->m_miscvalue & schoolMask)==0) - continue; - - // Damage can be splitted only if aura has an alive caster - Unit *caster = (*i)->GetCaster(); - if(!caster || caster == pVictim || !caster->IsInWorld() || !caster->isAlive()) - continue; - - int32 currentAbsorb; - if (RemainingDamage >= (*i)->GetModifier()->m_amount) - currentAbsorb = (*i)->GetModifier()->m_amount; - else - currentAbsorb = RemainingDamage; - - RemainingDamage -= currentAbsorb; - - SendSpellNonMeleeDamageLog(caster, (*i)->GetSpellProto()->Id, currentAbsorb, schoolMask, 0, 0, false, 0, false); - - CleanDamage cleanDamage = CleanDamage(currentAbsorb, BASE_ATTACK, MELEE_HIT_NORMAL); - DealDamage(caster, currentAbsorb, &cleanDamage, DIRECT_DAMAGE, schoolMask, (*i)->GetSpellProto(), false); - } - - AuraList const& vSplitDamagePct = pVictim->GetAurasByType(SPELL_AURA_SPLIT_DAMAGE_PCT); - for(AuraList::const_iterator i = vSplitDamagePct.begin(), next; i != vSplitDamagePct.end() && RemainingDamage >= 0; i = next) - { - next = i; ++next; - - // check damage school mask - if(((*i)->GetModifier()->m_miscvalue & schoolMask)==0) - continue; - - // Damage can be splitted only if aura has an alive caster - Unit *caster = (*i)->GetCaster(); - if(!caster || caster == pVictim || !caster->IsInWorld() || !caster->isAlive()) - continue; - - int32 splitted = int32(RemainingDamage * (*i)->GetModifier()->m_amount / 100.0f); - - RemainingDamage -= splitted; - - SendSpellNonMeleeDamageLog(caster, (*i)->GetSpellProto()->Id, splitted, schoolMask, 0, 0, false, 0, false); - - CleanDamage cleanDamage = CleanDamage(splitted, BASE_ATTACK, MELEE_HIT_NORMAL); - DealDamage(caster, splitted, &cleanDamage, DIRECT_DAMAGE, schoolMask, (*i)->GetSpellProto(), false); - } - - *absorb = damage - RemainingDamage - *resist; -} - -void Unit::DoAttackDamage (Unit *pVictim, uint32 *damage, CleanDamage *cleanDamage, uint32 *blocked_amount, SpellSchoolMask damageSchoolMask, uint32 *hitInfo, VictimState *victimState, uint32 *absorbDamage, uint32 *resistDamage, WeaponAttackType attType, SpellEntry const *spellCasted, bool isTriggeredSpell) -{ - MeleeHitOutcome outcome; - - // If is casted Melee spell, calculate like physical - if(!spellCasted) - outcome = RollMeleeOutcomeAgainst (pVictim, attType); - else - outcome = RollPhysicalOutcomeAgainst (pVictim, attType, spellCasted); - - if(outcome == MELEE_HIT_MISS ||outcome == MELEE_HIT_DODGE ||outcome == MELEE_HIT_BLOCK ||outcome == MELEE_HIT_PARRY) - pVictim->AddThreat(this, 0.0f); - switch(outcome) - { - case MELEE_HIT_EVADE: - { - *hitInfo |= HITINFO_MISS; - *damage = 0; - cleanDamage->damage = 0; - return; - } - case MELEE_HIT_MISS: - { - *hitInfo |= HITINFO_MISS; - *damage = 0; - cleanDamage->damage = 0; - if(GetTypeId()== TYPEID_PLAYER) - ((Player*)this)->UpdateWeaponSkill(attType); - return; - } - } - - /// If this is a creature and it attacks from behind it has a probability to daze it's victim - if( (outcome==MELEE_HIT_CRIT || outcome==MELEE_HIT_CRUSHING || outcome==MELEE_HIT_NORMAL || outcome==MELEE_HIT_GLANCING) && - GetTypeId() != TYPEID_PLAYER && !((Creature*)this)->GetCharmerOrOwnerGUID() && !pVictim->HasInArc(M_PI, this) ) - { - // -probability is between 0% and 40% - // 20% base chance - float Probability = 20; - - //there is a newbie protection, at level 10 just 7% base chance; assuming linear function - if( pVictim->getLevel() < 30 ) - Probability = 0.65f*pVictim->getLevel()+0.5; - - uint32 VictimDefense=pVictim->GetDefenseSkillValue(this); - uint32 AttackerMeleeSkill=GetUnitMeleeSkill(pVictim); - - Probability *= AttackerMeleeSkill/(float)VictimDefense; - - if(Probability > 40.0f) - Probability = 40.0f; - - if(roll_chance_f(Probability)) - CastSpell(pVictim, 1604, true); - } - - //Calculate the damage after armor mitigation if SPELL_SCHOOL_NORMAL - if (damageSchoolMask & SPELL_SCHOOL_MASK_NORMAL) - { - uint32 damageAfterArmor = CalcArmorReducedDamage(pVictim, *damage); - - // random durability for main hand weapon (ABSORB) - if(damageAfterArmor < *damage) - if(pVictim->GetTypeId() == TYPEID_PLAYER) - if (roll_chance_f(sWorld.getRate(RATE_DURABILITY_LOSS_ABSORB))) - ((Player*)pVictim)->DurabilityPointLossForEquipSlot(EquipmentSlots(urand(EQUIPMENT_SLOT_START,EQUIPMENT_SLOT_BACK))); - - cleanDamage->damage += *damage - damageAfterArmor; - *damage = damageAfterArmor; - } - - if(GetTypeId() == TYPEID_PLAYER && pVictim->GetTypeId() != TYPEID_PLAYER && pVictim->GetCreatureType() != CREATURE_TYPE_CRITTER ) - ((Player*)this)->UpdateCombatSkills(pVictim, attType, outcome, false); - - if(GetTypeId() != TYPEID_PLAYER && pVictim->GetTypeId() == TYPEID_PLAYER) - ((Player*)pVictim)->UpdateCombatSkills(this, attType, outcome, true); - - switch (outcome) - { - case MELEE_HIT_BLOCK_CRIT: - case MELEE_HIT_CRIT: - { - //*hitInfo = 0xEA; - // 0xEA - *hitInfo = HITINFO_CRITICALHIT | HITINFO_NORMALSWING2 | 0x8; - - // Crit bonus calc - uint32 crit_bonus; - crit_bonus = *damage; - - // Apply crit_damage bonus for melee spells - if (spellCasted) - { - if(Player* modOwner = GetSpellModOwner()) - modOwner->ApplySpellMod(spellCasted->Id, SPELLMOD_CRIT_DAMAGE_BONUS, crit_bonus); - - uint32 creatureTypeMask = pVictim->GetCreatureTypeMask(); - AuraList const& mDamageDoneVersus = GetAurasByType(SPELL_AURA_MOD_CRIT_PERCENT_VERSUS); - for(AuraList::const_iterator i = mDamageDoneVersus.begin();i != mDamageDoneVersus.end(); ++i) - if(creatureTypeMask & uint32((*i)->GetModifier()->m_miscvalue)) - crit_bonus = uint32(crit_bonus * ((*i)->GetModifier()->m_amount+100.0f)/100.0f); - } - - *damage += crit_bonus; - - uint32 resilienceReduction = 0; - - if(attType == RANGED_ATTACK) - { - int32 mod = pVictim->GetTotalAuraModifier(SPELL_AURA_MOD_ATTACKER_RANGED_CRIT_DAMAGE); - *damage = int32((*damage) * float((100.0f + mod)/100.0f)); - // Resilience - reduce crit damage - if (pVictim->GetTypeId()==TYPEID_PLAYER) - resilienceReduction = ((Player*)pVictim)->GetRangedCritDamageReduction(*damage); - } - else - { - int32 mod = pVictim->GetTotalAuraModifier(SPELL_AURA_MOD_ATTACKER_MELEE_CRIT_DAMAGE); - mod += GetTotalAuraModifier(SPELL_AURA_MOD_CRIT_DAMAGE_BONUS_MELEE); - *damage = int32((*damage) * float((100.0f + mod)/100.0f)); - // Resilience - reduce crit damage - if (pVictim->GetTypeId()==TYPEID_PLAYER) - resilienceReduction = ((Player*)pVictim)->GetMeleeCritDamageReduction(*damage); - } - - *damage -= resilienceReduction; - cleanDamage->damage += resilienceReduction; - - if(GetTypeId() == TYPEID_PLAYER && pVictim->GetTypeId() != TYPEID_PLAYER && pVictim->GetCreatureType() != CREATURE_TYPE_CRITTER ) - ((Player*)this)->UpdateWeaponSkill(attType); - - ModifyAuraState(AURA_STATE_CRIT, true); - StartReactiveTimer( REACTIVE_CRIT ); - - if(getClass()==CLASS_HUNTER) - { - ModifyAuraState(AURA_STATE_HUNTER_CRIT_STRIKE, true); - StartReactiveTimer( REACTIVE_HUNTER_CRIT ); - } - - if ( outcome == MELEE_HIT_BLOCK_CRIT ) - { - *blocked_amount = pVictim->GetShieldBlockValue(); - - if (pVictim->GetUnitBlockChance()) - pVictim->HandleEmoteCommand(EMOTE_ONESHOT_PARRYSHIELD); - else - pVictim->HandleEmoteCommand(EMOTE_ONESHOT_PARRYUNARMED); - - //Only set VICTIMSTATE_BLOCK on a full block - if (*blocked_amount >= uint32(*damage)) - { - *victimState = VICTIMSTATE_BLOCKS; - *blocked_amount = uint32(*damage); - } - - if(pVictim->GetTypeId() == TYPEID_PLAYER) - { - // Update defense - ((Player*)pVictim)->UpdateDefense(); - - // random durability for main hand weapon (BLOCK) - if (roll_chance_f(sWorld.getRate(RATE_DURABILITY_LOSS_BLOCK))) - ((Player*)pVictim)->DurabilityPointLossForEquipSlot(EQUIPMENT_SLOT_OFFHAND); - } - - pVictim->ModifyAuraState(AURA_STATE_DEFENSE,true); - pVictim->StartReactiveTimer( REACTIVE_DEFENSE ); - break; - } - - pVictim->HandleEmoteCommand(EMOTE_ONESHOT_WOUNDCRITICAL); - break; - } - case MELEE_HIT_PARRY: - { - if(attType == RANGED_ATTACK) //range attack - no parry - { - outcome = MELEE_HIT_NORMAL; - break; - } - - cleanDamage->damage += *damage; - *damage = 0; - *victimState = VICTIMSTATE_PARRY; - - // instant (maybe with small delay) counter attack - { - float offtime = float(pVictim->getAttackTimer(OFF_ATTACK)); - float basetime = float(pVictim->getAttackTimer(BASE_ATTACK)); - - // after parry nearest next attack time will reduced at %40 from full attack time. - // The delay cannot be reduced to less than 20% of your weapon's base swing delay. - if (pVictim->haveOffhandWeapon() && offtime < basetime) - { - float percent20 = pVictim->GetAttackTime(OFF_ATTACK)*0.20; - float percent60 = 3*percent20; - // set to 20% if in range 20%...20+40% of full time - if(offtime > percent20 && offtime <= percent60) - { - pVictim->setAttackTimer(OFF_ATTACK,uint32(percent20)); - } - // decrease at %40 from full time - else if(offtime > percent60) - { - offtime -= 2*percent20; - pVictim->setAttackTimer(OFF_ATTACK,uint32(offtime)); - } - // ELSE not changed - } - else - { - float percent20 = pVictim->GetAttackTime(BASE_ATTACK)*0.20; - float percent60 = 3*percent20; - // set to 20% if in range 20%...20+40% of full time - if(basetime > percent20 && basetime <= percent60) - { - pVictim->setAttackTimer(BASE_ATTACK,uint32(percent20)); - } - // decrease at %40 from full time - else if(basetime > percent60) - { - basetime -= 2*percent20; - pVictim->setAttackTimer(BASE_ATTACK,uint32(basetime)); - } - // ELSE not changed - } - } - - if(pVictim->GetTypeId() == TYPEID_PLAYER) - { - // Update victim defense ? - ((Player*)pVictim)->UpdateDefense(); - - // random durability for main hand weapon (PARRY) - if (roll_chance_f(sWorld.getRate(RATE_DURABILITY_LOSS_PARRY))) - ((Player*)pVictim)->DurabilityPointLossForEquipSlot(EQUIPMENT_SLOT_MAINHAND); - } - - pVictim->HandleEmoteCommand(EMOTE_ONESHOT_PARRYUNARMED); - - if (pVictim->getClass() == CLASS_HUNTER) - { - pVictim->ModifyAuraState(AURA_STATE_HUNTER_PARRY,true); - pVictim->StartReactiveTimer( REACTIVE_HUNTER_PARRY ); - } - else - { - pVictim->ModifyAuraState(AURA_STATE_DEFENSE, true); - pVictim->StartReactiveTimer( REACTIVE_DEFENSE ); - } - - CastMeleeProcDamageAndSpell(pVictim, 0, damageSchoolMask, attType, outcome, spellCasted, isTriggeredSpell); - return; - } - case MELEE_HIT_DODGE: - { - if(attType == RANGED_ATTACK) //range attack - no dodge - { - outcome = MELEE_HIT_NORMAL; - break; - } - - cleanDamage->damage += *damage; - *damage = 0; - *victimState = VICTIMSTATE_DODGE; - - if(pVictim->GetTypeId() == TYPEID_PLAYER) - ((Player*)pVictim)->UpdateDefense(); - - pVictim->HandleEmoteCommand(EMOTE_ONESHOT_PARRYUNARMED); - - if (pVictim->getClass() != CLASS_ROGUE) // Riposte - { - pVictim->ModifyAuraState(AURA_STATE_DEFENSE, true); - pVictim->StartReactiveTimer( REACTIVE_DEFENSE ); - } - - // Overpower - if (GetTypeId() == TYPEID_PLAYER && getClass() == CLASS_WARRIOR) - { - ((Player*)this)->AddComboPoints(pVictim, 1); - StartReactiveTimer( REACTIVE_OVERPOWER ); - } - - CastMeleeProcDamageAndSpell(pVictim, 0, damageSchoolMask, attType, outcome, spellCasted, isTriggeredSpell); - return; - } - case MELEE_HIT_BLOCK: - { - *blocked_amount = pVictim->GetShieldBlockValue(); - - if (pVictim->GetUnitBlockChance()) - pVictim->HandleEmoteCommand(EMOTE_ONESHOT_PARRYSHIELD); - else - pVictim->HandleEmoteCommand(EMOTE_ONESHOT_PARRYUNARMED); - - //Only set VICTIMSTATE_BLOCK on a full block - if (*blocked_amount >= uint32(*damage)) - { - *victimState = VICTIMSTATE_BLOCKS; - *blocked_amount = uint32(*damage); - } - - if(pVictim->GetTypeId() == TYPEID_PLAYER) - { - // Update defense - ((Player*)pVictim)->UpdateDefense(); - - // random durability for main hand weapon (BLOCK) - if (roll_chance_f(sWorld.getRate(RATE_DURABILITY_LOSS_BLOCK))) - ((Player*)pVictim)->DurabilityPointLossForEquipSlot(EQUIPMENT_SLOT_OFFHAND); - } - - pVictim->ModifyAuraState(AURA_STATE_DEFENSE,true); - pVictim->StartReactiveTimer( REACTIVE_DEFENSE ); - - break; - } - case MELEE_HIT_GLANCING: - { - float reducePercent = 1.0f; //damage factor - - // calculate base values and mods - float baseLowEnd = 1.3; - float baseHighEnd = 1.2; - switch(getClass()) // lowering base values for casters - { - case CLASS_SHAMAN: - case CLASS_PRIEST: - case CLASS_MAGE: - case CLASS_WARLOCK: - case CLASS_DRUID: - baseLowEnd -= 0.7; - baseHighEnd -= 0.3; - break; - } - - float maxLowEnd = 0.6; - switch(getClass()) // upper for melee classes - { - case CLASS_WARRIOR: - case CLASS_ROGUE: - maxLowEnd = 0.91; //If the attacker is a melee class then instead the lower value of 0.91 - } - - // calculate values - int32 diff = int32(pVictim->GetDefenseSkillValue(this)) - int32(GetWeaponSkillValue(attType,pVictim)); - float lowEnd = baseLowEnd - ( 0.05f * diff ); - float highEnd = baseHighEnd - ( 0.03f * diff ); - - // apply max/min bounds - if ( lowEnd < 0.01f ) //the low end must not go bellow 0.01f - lowEnd = 0.01f; - else if ( lowEnd > maxLowEnd ) //the smaller value of this and 0.6 is kept as the low end - lowEnd = maxLowEnd; - - if ( highEnd < 0.2f ) //high end limits - highEnd = 0.2f; - if ( highEnd > 0.99f ) - highEnd = 0.99f; - - if(lowEnd > highEnd) // prevent negative range size - lowEnd = highEnd; - - reducePercent = lowEnd + rand_norm() * ( highEnd - lowEnd ); - - *damage = uint32(reducePercent * *damage); - cleanDamage->damage += *damage; - *hitInfo |= HITINFO_GLANCING; - break; - } - case MELEE_HIT_CRUSHING: - { - // 150% normal damage - *damage += (*damage / 2); - cleanDamage->damage = *damage; - *hitInfo |= HITINFO_CRUSHING; - // TODO: victimState, victim animation? - break; - } - default: - break; - } - - // apply melee damage bonus and absorb only if base damage not fully blocked to prevent negative damage or damage with full block - if(*victimState != VICTIMSTATE_BLOCKS) - { - MeleeDamageBonus(pVictim, damage,attType,spellCasted); - CalcAbsorbResist(pVictim, damageSchoolMask, DIRECT_DAMAGE, *damage-*blocked_amount, absorbDamage, resistDamage); - } - - if (*absorbDamage) *hitInfo |= HITINFO_ABSORB; - if (*resistDamage) *hitInfo |= HITINFO_RESIST; - - cleanDamage->damage += *blocked_amount; - - if (*damage <= *absorbDamage + *resistDamage + *blocked_amount) - { - //*hitInfo = 0x00010020; - //*hitInfo |= HITINFO_SWINGNOHITSOUND; - //*damageType = 0; - CastMeleeProcDamageAndSpell(pVictim, 0, damageSchoolMask, attType, outcome, spellCasted, isTriggeredSpell); - return; - } - - // update at damage Judgement aura duration that applied by attacker at victim - if(*damage) - { - AuraMap const& vAuras = pVictim->GetAuras(); - for(AuraMap::const_iterator itr = vAuras.begin(); itr != vAuras.end(); ++itr) - { - SpellEntry const *spellInfo = (*itr).second->GetSpellProto(); - if( (spellInfo->AttributesEx3 & 0x40000) && spellInfo->SpellFamilyName == SPELLFAMILY_PALADIN && - ((*itr).second->GetCasterGUID() == GetGUID() && (!spellCasted || spellCasted->Id == 35395)) ) - { - (*itr).second->SetAuraDuration((*itr).second->GetAuraMaxDuration()); - (*itr).second->UpdateAuraDuration(); - } - } - } - - CastMeleeProcDamageAndSpell(pVictim, (*damage - *absorbDamage - *resistDamage - *blocked_amount), damageSchoolMask, attType, outcome, spellCasted, isTriggeredSpell); - - // victim's damage shield - // yet another hack to fix crashes related to the aura getting removed during iteration - std::set alreadyDone; - uint32 removedAuras = pVictim->m_removedAuras; - AuraList const& vDamageShields = pVictim->GetAurasByType(SPELL_AURA_DAMAGE_SHIELD); - for(AuraList::const_iterator i = vDamageShields.begin(), next = vDamageShields.begin(); i != vDamageShields.end(); i = next) - { - ++next; - if (alreadyDone.find(*i) == alreadyDone.end()) - { - alreadyDone.insert(*i); - pVictim->SpellNonMeleeDamageLog(this, (*i)->GetId(), (*i)->GetModifier()->m_amount, false, false); - if (pVictim->m_removedAuras > removedAuras) - { - removedAuras = pVictim->m_removedAuras; - next = vDamageShields.begin(); - } - } - } -} - -void Unit::AttackerStateUpdate (Unit *pVictim, WeaponAttackType attType, bool extra ) -{ - if(hasUnitState(UNIT_STAT_CONFUSED | UNIT_STAT_STUNDED | UNIT_STAT_FLEEING) || HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PACIFIED) ) - return; - - if (!pVictim->isAlive()) - return; - - if(IsNonMeleeSpellCasted(false)) - return; - - uint32 hitInfo; - if (attType == BASE_ATTACK) - hitInfo = HITINFO_NORMALSWING2; - else if (attType == OFF_ATTACK) - hitInfo = HITINFO_LEFTSWING; - else - return; // ignore ranaged case - - uint32 extraAttacks = m_extraAttacks; - - // melee attack spell casted at main hand attack only - if (attType == BASE_ATTACK && m_currentSpells[CURRENT_MELEE_SPELL]) - { - m_currentSpells[CURRENT_MELEE_SPELL]->cast(); - - // not recent extra attack only at any non extra attack (melee spell case) - if(!extra && extraAttacks) - { - while(m_extraAttacks) - { - AttackerStateUpdate(pVictim, BASE_ATTACK, true); - if(m_extraAttacks > 0) - --m_extraAttacks; - } - } - - return; - } - - VictimState victimState = VICTIMSTATE_NORMAL; - - CleanDamage cleanDamage = CleanDamage(0, BASE_ATTACK, MELEE_HIT_NORMAL ); - uint32 blocked_dmg = 0; - uint32 absorbed_dmg = 0; - uint32 resisted_dmg = 0; - - SpellSchoolMask meleeSchoolMask = GetMeleeDamageSchoolMask(); - - if(pVictim->IsImmunedToDamage(meleeSchoolMask,true)) // use charges - { - SendAttackStateUpdate (HITINFO_NORMALSWING, pVictim, 1, meleeSchoolMask, 0, 0, 0, VICTIMSTATE_IS_IMMUNE, 0); - - // not recent extra attack only at any non extra attack (miss case) - if(!extra && extraAttacks) - { - while(m_extraAttacks) - { - AttackerStateUpdate(pVictim, BASE_ATTACK, true); - if(m_extraAttacks > 0) - --m_extraAttacks; - } - } - - return; - } - - uint32 damage = CalculateDamage (attType, false); - - DoAttackDamage (pVictim, &damage, &cleanDamage, &blocked_dmg, meleeSchoolMask, &hitInfo, &victimState, &absorbed_dmg, &resisted_dmg, attType); - - if (hitInfo & HITINFO_MISS) - //send miss - SendAttackStateUpdate (hitInfo, pVictim, 1, meleeSchoolMask, damage, absorbed_dmg, resisted_dmg, victimState, blocked_dmg); - else - { - //do animation - SendAttackStateUpdate (hitInfo, pVictim, 1, meleeSchoolMask, damage, absorbed_dmg, resisted_dmg, victimState, blocked_dmg); - - if (damage > (absorbed_dmg + resisted_dmg + blocked_dmg)) - damage -= (absorbed_dmg + resisted_dmg + blocked_dmg); - else - damage = 0; - - DealDamage (pVictim, damage, &cleanDamage, DIRECT_DAMAGE, meleeSchoolMask, NULL, true); - - if(GetTypeId() == TYPEID_PLAYER && pVictim->isAlive()) - { - for(int i = EQUIPMENT_SLOT_START; i < EQUIPMENT_SLOT_END; i++) - ((Player*)this)->CastItemCombatSpell(((Player*)this)->GetItemByPos(INVENTORY_SLOT_BAG_0,i),pVictim,attType); - } - } - - if (GetTypeId() == TYPEID_PLAYER) - DEBUG_LOG("AttackerStateUpdate: (Player) %u attacked %u (TypeId: %u) for %u dmg, absorbed %u, blocked %u, resisted %u.", - GetGUIDLow(), pVictim->GetGUIDLow(), pVictim->GetTypeId(), damage, absorbed_dmg, blocked_dmg, resisted_dmg); - else - DEBUG_LOG("AttackerStateUpdate: (NPC) %u attacked %u (TypeId: %u) for %u dmg, absorbed %u, blocked %u, resisted %u.", - GetGUIDLow(), pVictim->GetGUIDLow(), pVictim->GetTypeId(), damage, absorbed_dmg, blocked_dmg, resisted_dmg); - - // extra attack only at any non extra attack (normal case) - if(!extra && extraAttacks) - { - while(m_extraAttacks) - { - AttackerStateUpdate(pVictim, BASE_ATTACK, true); - if(m_extraAttacks > 0) - --m_extraAttacks; - } - } -} - -MeleeHitOutcome Unit::RollPhysicalOutcomeAgainst (Unit const *pVictim, WeaponAttackType attType, SpellEntry const *spellInfo) -{ - // Miss chance based on melee - float miss_chance = MeleeMissChanceCalc(pVictim, attType); - - // Critical hit chance - float crit_chance = GetUnitCriticalChance(attType, pVictim); - // this is to avoid compiler issue when declaring variables inside if - float block_chance, parry_chance, dodge_chance; - - // cannot be dodged/parried/blocked - if(spellInfo->Attributes & SPELL_ATTR_IMPOSSIBLE_DODGE_PARRY_BLOCK) - { - block_chance = 0.0f; - parry_chance = 0.0f; - dodge_chance = 0.0f; - } - else - { - // parry can be avoided only by some abilites - parry_chance = pVictim->GetUnitParryChance(); - // block might be bypassed by it as well - block_chance = pVictim->GetUnitBlockChance(); - // stunned target cannot dodge and this is check in GetUnitDodgeChance() - dodge_chance = pVictim->GetUnitDodgeChance(); - } - - // Only players can have Talent&Spell bonuses - if (GetTypeId() == TYPEID_PLAYER) - { - // Increase from SPELL_AURA_MOD_SPELL_CRIT_CHANCE_SCHOOL aura - crit_chance += GetTotalAuraModifierByMiscMask(SPELL_AURA_MOD_SPELL_CRIT_CHANCE_SCHOOL, spellInfo->SchoolMask); - - if( dodge_chance != 0.0f ) // if dodge chance is already 0, ignore talents fpr speed - { - AuraList const& mCanNotBeDodge = GetAurasByType(SPELL_AURA_IGNORE_COMBAT_RESULT); - for(AuraList::const_iterator i = mCanNotBeDodge.begin(); i != mCanNotBeDodge.end(); ++i) - { - // can't be dodged rogue finishing move - if((*i)->GetModifier()->m_miscvalue == VICTIMSTATE_DODGE) - { - if(spellInfo->SpellFamilyName==SPELLFAMILY_ROGUE && (spellInfo->SpellFamilyFlags & SPELLFAMILYFLAG_ROGUE__FINISHING_MOVE)) - { - dodge_chance = 0.0f; - break; - } - } - } - } - } - - // Spellmods - if(Player* modOwner = GetSpellModOwner()) - modOwner->ApplySpellMod(spellInfo->Id, SPELLMOD_CRITICAL_CHANCE, crit_chance); - - DEBUG_LOG("PHYSICAL OUTCOME: miss %f crit %f dodge %f parry %f block %f",miss_chance,crit_chance,dodge_chance,parry_chance, block_chance); - - return RollMeleeOutcomeAgainst(pVictim, attType, int32(crit_chance*100), int32(miss_chance*100),int32(dodge_chance*100),int32(parry_chance*100),int32(block_chance*100), true); -} - -MeleeHitOutcome Unit::RollMeleeOutcomeAgainst(const Unit *pVictim, WeaponAttackType attType) const -{ - // This is only wrapper - - // Miss chance based on melee - float miss_chance = MeleeMissChanceCalc(pVictim, attType); - - // Critical hit chance - float crit_chance = GetUnitCriticalChance(attType, pVictim); - - // stunned target cannot dodge and this is check in GetUnitDodgeChance() (returned 0 in this case) - float dodge_chance = pVictim->GetUnitDodgeChance(); - float block_chance = pVictim->GetUnitBlockChance(); - float parry_chance = pVictim->GetUnitParryChance(); - - // Useful if want to specify crit & miss chances for melee, else it could be removed - DEBUG_LOG("MELEE OUTCOME: miss %f crit %f dodge %f parry %f block %f", miss_chance,crit_chance,dodge_chance,parry_chance,block_chance); - - return RollMeleeOutcomeAgainst(pVictim, attType, int32(crit_chance*100), int32(miss_chance*100), int32(dodge_chance*100),int32(parry_chance*100),int32(block_chance*100), false); -} - -MeleeHitOutcome Unit::RollMeleeOutcomeAgainst (const Unit *pVictim, WeaponAttackType attType, int32 crit_chance, int32 miss_chance, int32 dodge_chance, int32 parry_chance, int32 block_chance, bool SpellCasted ) const -{ - if(pVictim->GetTypeId()==TYPEID_UNIT && ((Creature*)pVictim)->IsInEvadeMode()) - return MELEE_HIT_EVADE; - - int32 attackerMaxSkillValueForLevel = GetMaxSkillValueForLevel(pVictim); - int32 victimMaxSkillValueForLevel = pVictim->GetMaxSkillValueForLevel(this); - - int32 attackerWeaponSkill = GetWeaponSkillValue(attType,pVictim); - int32 victimDefenseSkill = pVictim->GetDefenseSkillValue(this); - - // bonus from skills is 0.04% - int32 skillBonus = 4 * ( attackerWeaponSkill - victimMaxSkillValueForLevel ); - int32 skillBonus2 = 4 * ( attackerMaxSkillValueForLevel - victimDefenseSkill ); - int32 sum = 0, tmp = 0; - int32 roll = urand (0, 10000); - - DEBUG_LOG ("RollMeleeOutcomeAgainst: skill bonus of %d for attacker", skillBonus); - DEBUG_LOG ("RollMeleeOutcomeAgainst: rolled %d, miss %d, dodge %d, parry %d, block %d, crit %d", - roll, miss_chance, dodge_chance, parry_chance, block_chance, crit_chance); - - tmp = miss_chance; - - if (tmp > 0 && roll < (sum += tmp )) - { - DEBUG_LOG ("RollMeleeOutcomeAgainst: MISS"); - return MELEE_HIT_MISS; - } - - // always crit against a sitting target (except 0 crit chance) - if( pVictim->GetTypeId() == TYPEID_PLAYER && crit_chance > 0 && !pVictim->IsStandState() ) - { - DEBUG_LOG ("RollMeleeOutcomeAgainst: CRIT (sitting victim)"); - return MELEE_HIT_CRIT; - } - - // Dodge chance - - // only players can't dodge if attacker is behind - if (pVictim->GetTypeId() == TYPEID_PLAYER && !pVictim->HasInArc(M_PI,this)) - { - DEBUG_LOG ("RollMeleeOutcomeAgainst: attack came from behind and victim was a player."); - } - else - { - // Reduce dodge chance by attacker expertise rating - if (GetTypeId() == TYPEID_PLAYER) - dodge_chance -= int32(((Player*)this)->GetExpertiseDodgeOrParryReduction(attType)*100); - - // Modify dodge chance by attacker SPELL_AURA_MOD_COMBAT_RESULT_CHANCE - dodge_chance+= GetTotalAuraModifierByMiscValue(SPELL_AURA_MOD_COMBAT_RESULT_CHANCE, VICTIMSTATE_DODGE); - - tmp = dodge_chance; - if ( (tmp > 0) // check if unit _can_ dodge - && ((tmp -= skillBonus) > 0) - && roll < (sum += tmp)) - { - DEBUG_LOG ("RollMeleeOutcomeAgainst: DODGE <%d, %d)", sum-tmp, sum); - return MELEE_HIT_DODGE; - } - } - - // parry & block chances - - // check if attack comes from behind, nobody can parry or block if attacker is behind - if (!pVictim->HasInArc(M_PI,this)) - { - DEBUG_LOG ("RollMeleeOutcomeAgainst: attack came from behind."); - } - else - { - // Reduce parry chance by attacker expertise rating - if (GetTypeId() == TYPEID_PLAYER) - parry_chance-= int32(((Player*)this)->GetExpertiseDodgeOrParryReduction(attType)*100); - - if(pVictim->GetTypeId()==TYPEID_PLAYER || !(((Creature*)pVictim)->GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_NO_PARRY) ) - { - int32 tmp = int32(parry_chance); - if ( (tmp > 0) // check if unit _can_ parry - && ((tmp -= skillBonus) > 0) - && (roll < (sum += tmp))) - { - DEBUG_LOG ("RollMeleeOutcomeAgainst: PARRY <%d, %d)", sum-tmp, sum); - return MELEE_HIT_PARRY; - } - } - - if(pVictim->GetTypeId()==TYPEID_PLAYER || !(((Creature*)pVictim)->GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_NO_BLOCK) ) - { - tmp = block_chance; - if ( (tmp > 0) // check if unit _can_ block - && ((tmp -= skillBonus) > 0) - && (roll < (sum += tmp))) - { - // Critical chance - tmp = crit_chance + skillBonus2; - if ( GetTypeId() == TYPEID_PLAYER && SpellCasted && tmp > 0 ) - { - if ( roll_chance_i(tmp/100)) - { - DEBUG_LOG ("RollMeleeOutcomeAgainst: BLOCKED CRIT"); - return MELEE_HIT_BLOCK_CRIT; - } - } - DEBUG_LOG ("RollMeleeOutcomeAgainst: BLOCK <%d, %d)", sum-tmp, sum); - return MELEE_HIT_BLOCK; - } - } - } - - // Critical chance - tmp = crit_chance + skillBonus2; - - if (tmp > 0 && roll < (sum += tmp)) - { - DEBUG_LOG ("RollMeleeOutcomeAgainst: CRIT <%d, %d)", sum-tmp, sum); - return MELEE_HIT_CRIT; - } - - // Max 40% chance to score a glancing blow against mobs that are higher level (can do only players and pets and not with ranged weapon) - if( attType != RANGED_ATTACK && !SpellCasted && - (GetTypeId() == TYPEID_PLAYER || ((Creature*)this)->isPet()) && - pVictim->GetTypeId() != TYPEID_PLAYER && !((Creature*)pVictim)->isPet() && - getLevel() < pVictim->getLevelForTarget(this) ) - { - // cap possible value (with bonuses > max skill) - int32 skill = attackerWeaponSkill; - int32 maxskill = attackerMaxSkillValueForLevel; - skill = (skill > maxskill) ? maxskill : skill; - - tmp = (10 + (victimDefenseSkill - skill)) * 100; - tmp = tmp > 4000 ? 4000 : tmp; - if (roll < (sum += tmp)) - { - DEBUG_LOG ("RollMeleeOutcomeAgainst: GLANCING <%d, %d)", sum-4000, sum); - return MELEE_HIT_GLANCING; - } - } - - if(GetTypeId()!=TYPEID_PLAYER && !(((Creature*)this)->GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_NO_CRUSH) && !((Creature*)this)->isPet() ) - { - // mobs can score crushing blows if they're 3 or more levels above victim - // or when their weapon skill is 15 or more above victim's defense skill - tmp = victimDefenseSkill; - int32 tmpmax = victimMaxSkillValueForLevel; - // having defense above your maximum (from items, talents etc.) has no effect - tmp = tmp > tmpmax ? tmpmax : tmp; - // tmp = mob's level * 5 - player's current defense skill - tmp = attackerMaxSkillValueForLevel - tmp; - if(tmp >= 15) - { - // add 2% chance per lacking skill point, min. is 15% - tmp = tmp * 200 - 1500; - if (roll < (sum += tmp)) - { - DEBUG_LOG ("RollMeleeOutcomeAgainst: CRUSHING <%d, %d)", sum-tmp, sum); - return MELEE_HIT_CRUSHING; - } - } - } - - DEBUG_LOG ("RollMeleeOutcomeAgainst: NORMAL"); - return MELEE_HIT_NORMAL; -} - -uint32 Unit::CalculateDamage (WeaponAttackType attType, bool normalized) -{ - float min_damage, max_damage; - - if (normalized && GetTypeId()==TYPEID_PLAYER) - ((Player*)this)->CalculateMinMaxDamage(attType,normalized,min_damage, max_damage); - else - { - switch (attType) - { - case RANGED_ATTACK: - min_damage = GetFloatValue(UNIT_FIELD_MINRANGEDDAMAGE); - max_damage = GetFloatValue(UNIT_FIELD_MAXRANGEDDAMAGE); - break; - case BASE_ATTACK: - min_damage = GetFloatValue(UNIT_FIELD_MINDAMAGE); - max_damage = GetFloatValue(UNIT_FIELD_MAXDAMAGE); - break; - case OFF_ATTACK: - min_damage = GetFloatValue(UNIT_FIELD_MINOFFHANDDAMAGE); - max_damage = GetFloatValue(UNIT_FIELD_MAXOFFHANDDAMAGE); - break; - // Just for good manner - default: - min_damage = 0.0f; - max_damage = 0.0f; - break; - } - } - - if (min_damage > max_damage) - { - std::swap(min_damage,max_damage); - } - - if(max_damage == 0.0f) - max_damage = 5.0f; - - return urand((uint32)min_damage, (uint32)max_damage); -} - -float Unit::CalculateLevelPenalty(SpellEntry const* spellProto) const -{ - if(spellProto->spellLevel <= 0) - return 1.0f; - - float LvlPenalty = 0.0f; - - if(spellProto->spellLevel < 20) - LvlPenalty = 20.0f - spellProto->spellLevel * 3.75f; - float LvlFactor = (float(spellProto->spellLevel) + 6.0f) / float(getLevel()); - if(LvlFactor > 1.0f) - LvlFactor = 1.0f; - - return (100.0f - LvlPenalty) * LvlFactor / 100.0f; -} - -void Unit::SendAttackStart(Unit* pVictim) -{ - WorldPacket data( SMSG_ATTACKSTART, 16 ); - data << GetGUID(); - data << pVictim->GetGUID(); - - SendMessageToSet(&data, true); - DEBUG_LOG( "WORLD: Sent SMSG_ATTACKSTART" ); -} - -void Unit::SendAttackStop(Unit* victim) -{ - if(!victim) - return; - - WorldPacket data( SMSG_ATTACKSTOP, (4+16) ); // we guess size - data.append(GetPackGUID()); - data.append(victim->GetPackGUID()); // can be 0x00... - data << uint32(0); // can be 0x1 - SendMessageToSet(&data, true); - sLog.outDetail("%s %u stopped attacking %s %u", (GetTypeId()==TYPEID_PLAYER ? "player" : "creature"), GetGUIDLow(), (victim->GetTypeId()==TYPEID_PLAYER ? "player" : "creature"),victim->GetGUIDLow()); - - /*if(victim->GetTypeId() == TYPEID_UNIT) - ((Creature*)victim)->AI().EnterEvadeMode(this);*/ -} - -/* -// Melee based spells can be miss, parry or dodge on this step -// Crit or block - determined on damage calculation phase! (and can be both in some time) -float Unit::MeleeSpellMissChance(Unit *pVictim, WeaponAttackType attType, int32 skillDiff, SpellEntry const *spell) -{ - // Calculate hit chance (more correct for chance mod) - int32 HitChance; - - // PvP - PvE melee chances - int32 lchance = pVictim->GetTypeId() == TYPEID_PLAYER ? 5 : 7; - int32 leveldif = pVictim->getLevelForTarget(this) - getLevelForTarget(pVictim); - if(leveldif < 3) - HitChance = 95 - leveldif; - else - HitChance = 93 - (leveldif - 2) * lchance; - - // Hit chance depends from victim auras - if(attType == RANGED_ATTACK) - HitChance += pVictim->GetTotalAuraModifier(SPELL_AURA_MOD_ATTACKER_RANGED_HIT_CHANCE); - else - HitChance += pVictim->GetTotalAuraModifier(SPELL_AURA_MOD_ATTACKER_MELEE_HIT_CHANCE); - - // Spellmod from SPELLMOD_RESIST_MISS_CHANCE - if(Player *modOwner = GetSpellModOwner()) - modOwner->ApplySpellMod(spell->Id, SPELLMOD_RESIST_MISS_CHANCE, HitChance); - - // Miss = 100 - hit - float miss_chance= 100.0f - HitChance; - - // Bonuses from attacker aura and ratings - if (attType == RANGED_ATTACK) - miss_chance -= m_modRangedHitChance; - else - miss_chance -= m_modMeleeHitChance; - - // bonus from skills is 0.04% - miss_chance -= skillDiff * 0.04f; - - // Limit miss chance from 0 to 60% - if (miss_chance < 0.0f) - return 0.0f; - if (miss_chance > 60.0f) - return 60.0f; - return miss_chance; -} - -// Melee based spells hit result calculations -SpellMissInfo Unit::MeleeSpellHitResult(Unit *pVictim, SpellEntry const *spell) -{ - WeaponAttackType attType = BASE_ATTACK; - - if (spell->DmgClass == SPELL_DAMAGE_CLASS_RANGED) - attType = RANGED_ATTACK; - - // bonus from skills is 0.04% per skill Diff - int32 attackerWeaponSkill = int32(GetWeaponSkillValue(attType,pVictim)); - int32 skillDiff = attackerWeaponSkill - int32(pVictim->GetMaxSkillValueForLevel(this)); - int32 fullSkillDiff = attackerWeaponSkill - int32(pVictim->GetDefenseSkillValue(this)); - - uint32 roll = urand (0, 10000); - uint32 missChance = uint32(MeleeSpellMissChance(pVictim, attType, fullSkillDiff, spell)*100.0f); - - // Roll miss - uint32 tmp = missChance; - if (roll < tmp) - return SPELL_MISS_MISS; - - // Same spells cannot be parry/dodge - if (spell->Attributes & SPELL_ATTR_IMPOSSIBLE_DODGE_PARRY_BLOCK) - return SPELL_MISS_NONE; - - // Ranged attack can`t miss too - if (attType == RANGED_ATTACK) - return SPELL_MISS_NONE; - - bool attackFromBehind = !pVictim->HasInArc(M_PI,this); - - // Roll dodge - int32 dodgeChance = int32(pVictim->GetUnitDodgeChance()*100.0f) - skillDiff * 4; - // Reduce enemy dodge chance by SPELL_AURA_MOD_COMBAT_RESULT_CHANCE - dodgeChance+= GetTotalAuraModifierByMiscValue(SPELL_AURA_MOD_COMBAT_RESULT_CHANCE, VICTIMSTATE_DODGE); - - // Reduce dodge chance by attacker expertise rating - if (GetTypeId() == TYPEID_PLAYER) - dodgeChance-=int32(((Player*)this)->GetExpertiseDodgeOrParryReduction(attType) * 100.0f); - if (dodgeChance < 0) - dodgeChance = 0; - - // Can`t dodge from behind in PvP (but its possible in PvE) - if (GetTypeId() == TYPEID_PLAYER && pVictim->GetTypeId() == TYPEID_PLAYER && attackFromBehind) - dodgeChance = 0; - - // Rogue talent`s cant be dodged - AuraList const& mCanNotBeDodge = GetAurasByType(SPELL_AURA_IGNORE_COMBAT_RESULT); - for(AuraList::const_iterator i = mCanNotBeDodge.begin(); i != mCanNotBeDodge.end(); ++i) - { - if((*i)->GetModifier()->m_miscvalue == VICTIMSTATE_DODGE) // can't be dodged rogue finishing move - { - if(spell->SpellFamilyName==SPELLFAMILY_ROGUE && (spell->SpellFamilyFlags & SPELLFAMILYFLAG_ROGUE__FINISHING_MOVE)) - { - dodgeChance = 0; - break; - } - } - } - - tmp += dodgeChance; - if (roll < tmp) - return SPELL_MISS_DODGE; - - // Roll parry - int32 parryChance = int32(pVictim->GetUnitParryChance()*100.0f) - skillDiff * 4; - // Reduce parry chance by attacker expertise rating - if (GetTypeId() == TYPEID_PLAYER) - parryChance-=int32(((Player*)this)->GetExpertiseDodgeOrParryReduction(attType) * 100.0f); - // Can`t parry from behind - if (parryChance < 0 || attackFromBehind) - parryChance = 0; - - tmp += parryChance; - if (roll < tmp) - return SPELL_MISS_PARRY; - - return SPELL_MISS_NONE; -}*/ - -// TODO need use unit spell resistances in calculations -SpellMissInfo Unit::MagicSpellHitResult(Unit *pVictim, SpellEntry const *spell) -{ - // Can`t miss on dead target (on skinning for example) - if (!pVictim->isAlive()) - return SPELL_MISS_NONE; - - SpellSchoolMask schoolMask = GetSpellSchoolMask(spell); - // PvP - PvE spell misschances per leveldif > 2 - int32 lchance = pVictim->GetTypeId() == TYPEID_PLAYER ? 7 : 11; - int32 leveldif = int32(pVictim->getLevelForTarget(this)) - int32(getLevelForTarget(pVictim)); - - // Base hit chance from attacker and victim levels - int32 modHitChance; - if(leveldif < 3) - modHitChance = 96 - leveldif; - else - modHitChance = 94 - (leveldif - 2) * lchance; - - // Spellmod from SPELLMOD_RESIST_MISS_CHANCE - if(Player *modOwner = GetSpellModOwner()) - modOwner->ApplySpellMod(spell->Id, SPELLMOD_RESIST_MISS_CHANCE, modHitChance); - // Increase from attacker SPELL_AURA_MOD_INCREASES_SPELL_PCT_TO_HIT auras - modHitChance+=GetTotalAuraModifierByMiscMask(SPELL_AURA_MOD_INCREASES_SPELL_PCT_TO_HIT, schoolMask); - // Chance hit from victim SPELL_AURA_MOD_ATTACKER_SPELL_HIT_CHANCE auras - modHitChance+= pVictim->GetTotalAuraModifierByMiscMask(SPELL_AURA_MOD_ATTACKER_SPELL_HIT_CHANCE, schoolMask); - // Reduce spell hit chance for Area of effect spells from victim SPELL_AURA_MOD_AOE_AVOIDANCE aura - if (IsAreaOfEffectSpell(spell)) - modHitChance-=pVictim->GetTotalAuraModifier(SPELL_AURA_MOD_AOE_AVOIDANCE); - // Reduce spell hit chance for dispel mechanic spells from victim SPELL_AURA_MOD_DISPEL_RESIST - if (IsDispelSpell(spell)) - modHitChance-=pVictim->GetTotalAuraModifier(SPELL_AURA_MOD_DISPEL_RESIST); - // Chance resist mechanic (select max value from every mechanic spell effect) - int32 resist_mech = 0; - // Get effects mechanic and chance - for(int eff = 0; eff < 3; ++eff) - { - int32 effect_mech = GetEffectMechanic(spell, eff); - if (effect_mech) - { - int32 temp = pVictim->GetTotalAuraModifierByMiscValue(SPELL_AURA_MOD_MECHANIC_RESISTANCE, effect_mech); - if (resist_mech < temp) - resist_mech = temp; - } - } - // Apply mod - modHitChance-=resist_mech; - - // Chance resist debuff - modHitChance-=pVictim->GetTotalAuraModifierByMiscValue(SPELL_AURA_MOD_DEBUFF_RESISTANCE, int32(spell->Dispel)); - - int32 HitChance = modHitChance * 100; - // Increase hit chance from attacker SPELL_AURA_MOD_SPELL_HIT_CHANCE and attacker ratings - HitChance += int32(m_modSpellHitChance*100.0f); - - // Decrease hit chance from victim rating bonus - if (pVictim->GetTypeId()==TYPEID_PLAYER) - HitChance -= int32(((Player*)pVictim)->GetRatingBonusValue(CR_HIT_TAKEN_SPELL)*100.0f); - - if (HitChance < 100) HitChance = 100; - if (HitChance > 9900) HitChance = 9900; - - uint32 rand = urand(0,10000); - if (rand > HitChance) - return SPELL_MISS_RESIST; - return SPELL_MISS_NONE; -} - -SpellMissInfo Unit::SpellHitResult(Unit *pVictim, SpellEntry const *spell, bool CanReflect) -{ - // Return evade for units in evade mode - if (pVictim->GetTypeId()==TYPEID_UNIT && ((Creature*)pVictim)->IsInEvadeMode()) - return SPELL_MISS_EVADE; - - // Check for immune (use charges) - if (pVictim->IsImmunedToSpell(spell,true)) - return SPELL_MISS_IMMUNE; - - // All positive spells can`t miss - // TODO: client not show miss log for this spells - so need find info for this in dbc and use it! - if (IsPositiveSpell(spell->Id)) - return SPELL_MISS_NONE; - - // Check for immune (use charges) - if (pVictim->IsImmunedToDamage(GetSpellSchoolMask(spell),true)) - return SPELL_MISS_IMMUNE; - - // Try victim reflect spell - if (CanReflect) - { - // specialized first - Unit::AuraList const& mReflectSpellsSchool = pVictim->GetAurasByType(SPELL_AURA_REFLECT_SPELLS_SCHOOL); - for(Unit::AuraList::const_iterator i = mReflectSpellsSchool.begin(); i != mReflectSpellsSchool.end(); ++i) - { - if((*i)->GetModifier()->m_miscvalue & GetSpellSchoolMask(spell)) - { - int32 reflectchance = (*i)->GetModifier()->m_amount; - if (reflectchance > 0 && roll_chance_i(reflectchance)) - { - if((*i)->m_procCharges > 0) - { - --(*i)->m_procCharges; - if((*i)->m_procCharges==0) - pVictim->RemoveAurasDueToSpell((*i)->GetId()); - } - return SPELL_MISS_REFLECT; - } - } - } - - // generic reflection - Unit::AuraList const& mReflectSpells = pVictim->GetAurasByType(SPELL_AURA_REFLECT_SPELLS); - for(Unit::AuraList::const_iterator i = mReflectSpells.begin(); i != mReflectSpells.end(); ++i) - { - int32 reflectchance = (*i)->GetModifier()->m_amount; - if (reflectchance > 0 && roll_chance_i(reflectchance)) - { - if((*i)->m_procCharges > 0) - { - --(*i)->m_procCharges; - if((*i)->m_procCharges==0) - pVictim->RemoveAurasDueToSpell((*i)->GetId()); - } - return SPELL_MISS_REFLECT; - } - } - } - - // Temporary solution for melee based spells and spells vs SPELL_SCHOOL_NORMAL (hit result calculated after) - for (int i=0;i<3;i++) - { - if (spell->Effect[i] == SPELL_EFFECT_WEAPON_DAMAGE || - spell->Effect[i] == SPELL_EFFECT_WEAPON_PERCENT_DAMAGE || - spell->Effect[i] == SPELL_EFFECT_NORMALIZED_WEAPON_DMG || - spell->Effect[i] == SPELL_EFFECT_WEAPON_DAMAGE_NOSCHOOL) - return SPELL_MISS_NONE; - } - - // TODO need use this code for spell hit result calculation - // now code commented for compotability - switch (spell->DmgClass) - { - case SPELL_DAMAGE_CLASS_RANGED: - case SPELL_DAMAGE_CLASS_MELEE: -// return MeleeSpellHitResult(pVictim, spell); - return SPELL_MISS_NONE; - case SPELL_DAMAGE_CLASS_NONE: - case SPELL_DAMAGE_CLASS_MAGIC: - return MagicSpellHitResult(pVictim, spell); - } - return SPELL_MISS_NONE; -} - -float Unit::MeleeMissChanceCalc(const Unit *pVictim, WeaponAttackType attType) const -{ - if(!pVictim) - return 0.0f; - - // Base misschance 5% - float misschance = 5.0f; - - // DualWield - Melee spells and physical dmg spells - 5% , white damage 24% - if (haveOffhandWeapon() && attType != RANGED_ATTACK) - { - bool isNormal = false; - for (uint32 i = CURRENT_FIRST_NON_MELEE_SPELL; i < CURRENT_MAX_SPELL; i++) - { - if( m_currentSpells[i] && (GetSpellSchoolMask(m_currentSpells[i]->m_spellInfo) & SPELL_SCHOOL_MASK_NORMAL) ) - { - isNormal = true; - break; - } - } - if (isNormal || m_currentSpells[CURRENT_MELEE_SPELL]) - { - misschance = 5.0f; - } - else - { - misschance = 24.0f; - } - } - - // PvP : PvE melee misschances per leveldif > 2 - int32 chance = pVictim->GetTypeId() == TYPEID_PLAYER ? 5 : 7; - - int32 leveldif = int32(pVictim->getLevelForTarget(this)) - int32(getLevelForTarget(pVictim)); - if(leveldif < 0) - leveldif = 0; - - // Hit chance from attacker based on ratings and auras - float m_modHitChance; - if (attType == RANGED_ATTACK) - m_modHitChance = m_modRangedHitChance; - else - m_modHitChance = m_modMeleeHitChance; - - if(leveldif < 3) - misschance += (leveldif - m_modHitChance); - else - misschance += ((leveldif - 2) * chance - m_modHitChance); - - // Hit chance for victim based on ratings - if (pVictim->GetTypeId()==TYPEID_PLAYER) - { - if (attType == RANGED_ATTACK) - misschance += ((Player*)pVictim)->GetRatingBonusValue(CR_HIT_TAKEN_RANGED); - else - misschance += ((Player*)pVictim)->GetRatingBonusValue(CR_HIT_TAKEN_MELEE); - } - - // Modify miss chance by victim auras - if(attType == RANGED_ATTACK) - misschance -= pVictim->GetTotalAuraModifier(SPELL_AURA_MOD_ATTACKER_RANGED_HIT_CHANCE); - else - misschance -= pVictim->GetTotalAuraModifier(SPELL_AURA_MOD_ATTACKER_MELEE_HIT_CHANCE); - - // Modify miss chance from skill difference ( bonus from skills is 0.04% ) - int32 skillBonus = int32(GetWeaponSkillValue(attType,pVictim)) - int32(pVictim->GetDefenseSkillValue(this)); - misschance -= skillBonus * 0.04f; - - // Limit miss chance from 0 to 60% - if ( misschance < 0.0f) - return 0.0f; - if ( misschance > 60.0f) - return 60.0f; - - return misschance; -} - -uint32 Unit::GetDefenseSkillValue(Unit const* target) const -{ - if(GetTypeId() == TYPEID_PLAYER) - { - // in PvP use full skill instead current skill value - uint32 value = (target && target->GetTypeId() == TYPEID_PLAYER) - ? ((Player*)this)->GetMaxSkillValue(SKILL_DEFENSE) - : ((Player*)this)->GetSkillValue(SKILL_DEFENSE); - value += uint32(((Player*)this)->GetRatingBonusValue(CR_DEFENSE_SKILL)); - return value; - } - else - return GetUnitMeleeSkill(target); -} - -float Unit::GetUnitDodgeChance() const -{ - if(hasUnitState(UNIT_STAT_STUNDED)) - return 0.0f; - if( GetTypeId() == TYPEID_PLAYER ) - return GetFloatValue(PLAYER_DODGE_PERCENTAGE); - else - { - if(((Creature const*)this)->isTotem()) - return 0.0f; - else - { - float dodge = 5.0f; - dodge += GetTotalAuraModifier(SPELL_AURA_MOD_DODGE_PERCENT); - return dodge > 0.0f ? dodge : 0.0f; - } - } -} - -float Unit::GetUnitParryChance() const -{ - if ( IsNonMeleeSpellCasted(false) || hasUnitState(UNIT_STAT_STUNDED)) - return 0.0f; - - float chance = 0.0f; - - if(GetTypeId() == TYPEID_PLAYER) - { - Player const* player = (Player const*)this; - if(player->CanParry() ) - { - Item *tmpitem = ((Player*)this)->GetWeaponForAttack(BASE_ATTACK,true); - if(!tmpitem) - tmpitem = ((Player*)this)->GetWeaponForAttack(OFF_ATTACK,true); - - if(tmpitem) - chance = GetFloatValue(PLAYER_PARRY_PERCENTAGE); - } - } - else if(GetTypeId() == TYPEID_UNIT) - { - if(GetCreatureType() == CREATURE_TYPE_HUMANOID) - { - chance = 5.0f; - chance += GetTotalAuraModifier(SPELL_AURA_MOD_PARRY_PERCENT); - } - } - - return chance > 0.0f ? chance : 0.0f; -} - -float Unit::GetUnitBlockChance() const -{ - if ( IsNonMeleeSpellCasted(false) || hasUnitState(UNIT_STAT_STUNDED)) - return 0.0f; - - if(GetTypeId() == TYPEID_PLAYER) - { - Item *tmpitem = ((Player const*)this)->GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND); - if(tmpitem && !tmpitem->IsBroken() && tmpitem->GetProto()->Block) - return GetFloatValue(PLAYER_BLOCK_PERCENTAGE); - else - return 0.0f; - } - else - { - if(((Creature const*)this)->isTotem()) - return 0.0f; - else - { - float block = 5.0f; - block += GetTotalAuraModifier(SPELL_AURA_MOD_BLOCK_PERCENT); - return block > 0.0f ? block : 0.0f; - } - } -} - -float Unit::GetUnitCriticalChance(WeaponAttackType attackType, const Unit *pVictim) const -{ - float crit; - - if(GetTypeId() == TYPEID_PLAYER) - { - switch(attackType) - { - case BASE_ATTACK: - crit = GetFloatValue( PLAYER_CRIT_PERCENTAGE ); - break; - case OFF_ATTACK: - crit = GetFloatValue( PLAYER_OFFHAND_CRIT_PERCENTAGE ); - break; - case RANGED_ATTACK: - crit = GetFloatValue( PLAYER_RANGED_CRIT_PERCENTAGE ); - break; - // Just for good manner - default: - crit = 0.0f; - break; - } - } - else - { - crit = 5.0f; - crit += GetTotalAuraModifier(SPELL_AURA_MOD_CRIT_PERCENT); - } - - // flat aura mods - if(attackType == RANGED_ATTACK) - crit += pVictim->GetTotalAuraModifier(SPELL_AURA_MOD_ATTACKER_RANGED_CRIT_CHANCE); - else - crit += pVictim->GetTotalAuraModifier(SPELL_AURA_MOD_ATTACKER_MELEE_CRIT_CHANCE); - - crit += pVictim->GetTotalAuraModifier(SPELL_AURA_MOD_ATTACKER_SPELL_AND_WEAPON_CRIT_CHANCE); - - // reduce crit chance from Rating for players - if (pVictim->GetTypeId()==TYPEID_PLAYER) - { - if (attackType==RANGED_ATTACK) - crit -= ((Player*)pVictim)->GetRatingBonusValue(CR_CRIT_TAKEN_RANGED); - else - crit -= ((Player*)pVictim)->GetRatingBonusValue(CR_CRIT_TAKEN_MELEE); - } - - if (crit < 0.0f) - crit = 0.0f; - return crit; -} - -uint32 Unit::GetWeaponSkillValue (WeaponAttackType attType, Unit const* target) const -{ - uint32 value = 0; - if(GetTypeId() == TYPEID_PLAYER) - { - Item* item = ((Player*)this)->GetWeaponForAttack(attType,true); - - // feral or unarmed skill only for base attack - if(attType != BASE_ATTACK && !item ) - return 0; - - if(((Player*)this)->IsInFeralForm()) - return GetMaxSkillValueForLevel(); // always maximized SKILL_FERAL_COMBAT in fact - - // weaon skill or (unarmed for base attack) - uint32 skill = item ? item->GetSkill() : SKILL_UNARMED; - - // in PvP use full skill instead current skill value - value = (target && target->GetTypeId() == TYPEID_PLAYER) - ? ((Player*)this)->GetMaxSkillValue(skill) - : ((Player*)this)->GetSkillValue(skill); - // Modify value from ratings - value += uint32(((Player*)this)->GetRatingBonusValue(CR_WEAPON_SKILL)); - switch (attType) - { - case BASE_ATTACK: value+=uint32(((Player*)this)->GetRatingBonusValue(CR_WEAPON_SKILL_MAINHAND));break; - case OFF_ATTACK: value+=uint32(((Player*)this)->GetRatingBonusValue(CR_WEAPON_SKILL_OFFHAND));break; - case RANGED_ATTACK: value+=uint32(((Player*)this)->GetRatingBonusValue(CR_WEAPON_SKILL_RANGED));break; - } - } - else - value = GetUnitMeleeSkill(target); - return value; -} - -void Unit::_UpdateSpells( uint32 time ) -{ - if(m_currentSpells[CURRENT_AUTOREPEAT_SPELL]) - _UpdateAutoRepeatSpell(); - - // remove finished spells from current pointers - for (uint32 i = 0; i < CURRENT_MAX_SPELL; i++) - { - if (m_currentSpells[i] && m_currentSpells[i]->getState() == SPELL_STATE_FINISHED) - { - m_currentSpells[i]->SetDeletable(true); // spell may be safely deleted now - m_currentSpells[i] = NULL; // remove pointer - } - } - - // TODO: Find a better way to prevent crash when multiple auras are removed. - m_removedAuras = 0; - for (AuraMap::iterator i = m_Auras.begin(); i != m_Auras.end(); ++i) - if ((*i).second) - (*i).second->SetUpdated(false); - - for (AuraMap::iterator i = m_Auras.begin(), next; i != m_Auras.end(); i = next) - { - next = i; - ++next; - if ((*i).second) - { - // prevent double update - if ((*i).second->IsUpdated()) - continue; - (*i).second->SetUpdated(true); - (*i).second->Update( time ); - // several auras can be deleted due to update - if (m_removedAuras) - { - if (m_Auras.empty()) break; - next = m_Auras.begin(); - m_removedAuras = 0; - } - } - } - - for (AuraMap::iterator i = m_Auras.begin(); i != m_Auras.end();) - { - if ((*i).second) - { - if ( !(*i).second->GetAuraDuration() && !((*i).second->IsPermanent() || ((*i).second->IsPassive())) ) - { - RemoveAura(i); - } - else - { - ++i; - } - } - else - { - ++i; - } - } - - if(!m_gameObj.empty()) - { - std::list::iterator ite1, dnext1; - for (ite1 = m_gameObj.begin(); ite1 != m_gameObj.end(); ite1 = dnext1) - { - dnext1 = ite1; - //(*i)->Update( difftime ); - if( !(*ite1)->isSpawned() ) - { - (*ite1)->SetOwnerGUID(0); - (*ite1)->SetRespawnTime(0); - (*ite1)->Delete(); - dnext1 = m_gameObj.erase(ite1); - } - else - ++dnext1; - } - } -} - -void Unit::_UpdateAutoRepeatSpell() -{ - //check "realtime" interrupts - if ( (GetTypeId() == TYPEID_PLAYER && ((Player*)this)->isMoving()) || IsNonMeleeSpellCasted(false,false,true) ) - { - // cancel wand shoot - if(m_currentSpells[CURRENT_AUTOREPEAT_SPELL]->m_spellInfo->Category == 351) - InterruptSpell(CURRENT_AUTOREPEAT_SPELL); - m_AutoRepeatFirstCast = true; - return; - } - - //apply delay - if ( m_AutoRepeatFirstCast && getAttackTimer(RANGED_ATTACK) < 500 ) - setAttackTimer(RANGED_ATTACK,500); - m_AutoRepeatFirstCast = false; - - //castroutine - if (isAttackReady(RANGED_ATTACK)) - { - // Check if able to cast - if(m_currentSpells[CURRENT_AUTOREPEAT_SPELL]->CanCast(true)) - { - InterruptSpell(CURRENT_AUTOREPEAT_SPELL); - return; - } - - // we want to shoot - Spell* spell = new Spell(this, m_currentSpells[CURRENT_AUTOREPEAT_SPELL]->m_spellInfo, true, 0); - spell->prepare(&(m_currentSpells[CURRENT_AUTOREPEAT_SPELL]->m_targets)); - - // all went good, reset attack - resetAttackTimer(RANGED_ATTACK); - } -} - -void Unit::SetCurrentCastedSpell( Spell * pSpell ) -{ - assert(pSpell); // NULL may be never passed here, use InterruptSpell or InterruptNonMeleeSpells - - uint32 CSpellType = pSpell->GetCurrentContainer(); - - pSpell->SetDeletable(false); // spell will not be deleted until gone from current pointers - if (pSpell == m_currentSpells[CSpellType]) return; // avoid breaking self - - // break same type spell if it is not delayed - InterruptSpell(CSpellType,false); - - // special breakage effects: - switch (CSpellType) - { - case CURRENT_GENERIC_SPELL: - { - // generic spells always break channeled not delayed spells - InterruptSpell(CURRENT_CHANNELED_SPELL,false); - - // autorepeat breaking - if ( m_currentSpells[CURRENT_AUTOREPEAT_SPELL] ) - { - // break autorepeat if not Auto Shot - if (m_currentSpells[CURRENT_AUTOREPEAT_SPELL]->m_spellInfo->Category == 351) - InterruptSpell(CURRENT_AUTOREPEAT_SPELL); - m_AutoRepeatFirstCast = true; - } - } break; - - case CURRENT_CHANNELED_SPELL: - { - // channel spells always break generic non-delayed and any channeled spells - InterruptSpell(CURRENT_GENERIC_SPELL,false); - InterruptSpell(CURRENT_CHANNELED_SPELL); - - // it also does break autorepeat if not Auto Shot - if ( m_currentSpells[CURRENT_AUTOREPEAT_SPELL] && - m_currentSpells[CURRENT_AUTOREPEAT_SPELL]->m_spellInfo->Category == 351 ) - InterruptSpell(CURRENT_AUTOREPEAT_SPELL); - } break; - - case CURRENT_AUTOREPEAT_SPELL: - { - // only Auto Shoot does not break anything - if (pSpell->m_spellInfo->Category == 351) - { - // generic autorepeats break generic non-delayed and channeled non-delayed spells - InterruptSpell(CURRENT_GENERIC_SPELL,false); - InterruptSpell(CURRENT_CHANNELED_SPELL,false); - } - // special action: set first cast flag - m_AutoRepeatFirstCast = true; - } break; - - default: - { - // other spell types don't break anything now - } break; - } - - // current spell (if it is still here) may be safely deleted now - if (m_currentSpells[CSpellType]) - m_currentSpells[CSpellType]->SetDeletable(true); - - // set new current spell - m_currentSpells[CSpellType] = pSpell; -} - -void Unit::InterruptSpell(uint32 spellType, bool withDelayed) -{ - assert(spellType < CURRENT_MAX_SPELL); - - if(m_currentSpells[spellType] && (withDelayed || m_currentSpells[spellType]->getState() != SPELL_STATE_DELAYED) ) - { - // send autorepeat cancel message for autorepeat spells - if (spellType == CURRENT_AUTOREPEAT_SPELL) - { - if(GetTypeId()==TYPEID_PLAYER) - ((Player*)this)->SendAutoRepeatCancel(); - } - - if (m_currentSpells[spellType]->getState() != SPELL_STATE_FINISHED) - m_currentSpells[spellType]->cancel(); - m_currentSpells[spellType]->SetDeletable(true); - m_currentSpells[spellType] = NULL; - } -} - -bool Unit::IsNonMeleeSpellCasted(bool withDelayed, bool skipChanneled, bool skipAutorepeat) const -{ - // We don't do loop here to explicitly show that melee spell is excluded. - // Maybe later some special spells will be excluded too. - - // generic spells are casted when they are not finished and not delayed - if ( m_currentSpells[CURRENT_GENERIC_SPELL] && - (m_currentSpells[CURRENT_GENERIC_SPELL]->getState() != SPELL_STATE_FINISHED) && - (withDelayed || m_currentSpells[CURRENT_GENERIC_SPELL]->getState() != SPELL_STATE_DELAYED) ) - return(true); - - // channeled spells may be delayed, but they are still considered casted - else if ( !skipChanneled && m_currentSpells[CURRENT_CHANNELED_SPELL] && - (m_currentSpells[CURRENT_CHANNELED_SPELL]->getState() != SPELL_STATE_FINISHED) ) - return(true); - - // autorepeat spells may be finished or delayed, but they are still considered casted - else if ( !skipAutorepeat && m_currentSpells[CURRENT_AUTOREPEAT_SPELL] ) - return(true); - - return(false); -} - -void Unit::InterruptNonMeleeSpells(bool withDelayed, uint32 spell_id) -{ - // generic spells are interrupted if they are not finished or delayed - if (m_currentSpells[CURRENT_GENERIC_SPELL] && (!spell_id || m_currentSpells[CURRENT_GENERIC_SPELL]->m_spellInfo->Id==spell_id)) - { - if ( (m_currentSpells[CURRENT_GENERIC_SPELL]->getState() != SPELL_STATE_FINISHED) && - (withDelayed || m_currentSpells[CURRENT_GENERIC_SPELL]->getState() != SPELL_STATE_DELAYED) ) - m_currentSpells[CURRENT_GENERIC_SPELL]->cancel(); - m_currentSpells[CURRENT_GENERIC_SPELL]->SetDeletable(true); - m_currentSpells[CURRENT_GENERIC_SPELL] = NULL; - } - - // autorepeat spells are interrupted if they are not finished or delayed - if (m_currentSpells[CURRENT_AUTOREPEAT_SPELL] && (!spell_id || m_currentSpells[CURRENT_AUTOREPEAT_SPELL]->m_spellInfo->Id==spell_id)) - { - // send disable autorepeat packet in any case - if(GetTypeId()==TYPEID_PLAYER) - ((Player*)this)->SendAutoRepeatCancel(); - - if ( (m_currentSpells[CURRENT_AUTOREPEAT_SPELL]->getState() != SPELL_STATE_FINISHED) && - (withDelayed || m_currentSpells[CURRENT_AUTOREPEAT_SPELL]->getState() != SPELL_STATE_DELAYED) ) - m_currentSpells[CURRENT_AUTOREPEAT_SPELL]->cancel(); - m_currentSpells[CURRENT_AUTOREPEAT_SPELL]->SetDeletable(true); - m_currentSpells[CURRENT_AUTOREPEAT_SPELL] = NULL; - } - - // channeled spells are interrupted if they are not finished, even if they are delayed - if (m_currentSpells[CURRENT_CHANNELED_SPELL] && (!spell_id || m_currentSpells[CURRENT_CHANNELED_SPELL]->m_spellInfo->Id==spell_id)) - { - if (m_currentSpells[CURRENT_CHANNELED_SPELL]->getState() != SPELL_STATE_FINISHED) - m_currentSpells[CURRENT_CHANNELED_SPELL]->cancel(); - m_currentSpells[CURRENT_CHANNELED_SPELL]->SetDeletable(true); - m_currentSpells[CURRENT_CHANNELED_SPELL] = NULL; - } -} - -Spell* Unit::FindCurrentSpellBySpellId(uint32 spell_id) const -{ - for (uint32 i = 0; i < CURRENT_MAX_SPELL; i++) - if(m_currentSpells[i] && m_currentSpells[i]->m_spellInfo->Id==spell_id) - return m_currentSpells[i]; - return NULL; -} - -bool Unit::isInFront(Unit const* target, float distance, float arc) const -{ - return IsWithinDistInMap(target, distance) && HasInArc( arc, target ); -} - -void Unit::SetInFront(Unit const* target) -{ - SetOrientation(GetAngle(target)); -} - -bool Unit::isInBack(Unit const* target, float distance, float arc) const -{ - return IsWithinDistInMap(target, distance) && !HasInArc( 2 * M_PI - arc, target ); -} - -bool Unit::isInAccessablePlaceFor(Creature const* c) const -{ - if(IsInWater()) - return c->canSwim(); - else - return c->canWalk(); -} - -bool Unit::IsInWater() const -{ - return MapManager::Instance().GetBaseMap(GetMapId())->IsInWater(GetPositionX(),GetPositionY(), GetPositionZ()); -} - -bool Unit::IsUnderWater() const -{ - return MapManager::Instance().GetBaseMap(GetMapId())->IsUnderWater(GetPositionX(),GetPositionY(),GetPositionZ()); -} - -void Unit::DeMorph() -{ - SetDisplayId(GetNativeDisplayId()); -} - -int32 Unit::GetTotalAuraModifier(AuraType auratype) const -{ - int32 modifier = 0; - - AuraList const& mTotalAuraList = GetAurasByType(auratype); - for(AuraList::const_iterator i = mTotalAuraList.begin();i != mTotalAuraList.end(); ++i) - modifier += (*i)->GetModifier()->m_amount; - - return modifier; -} - -float Unit::GetTotalAuraMultiplier(AuraType auratype) const -{ - float multipler = 1.0f; - - AuraList const& mTotalAuraList = GetAurasByType(auratype); - for(AuraList::const_iterator i = mTotalAuraList.begin();i != mTotalAuraList.end(); ++i) - multipler *= (100.0f + (*i)->GetModifier()->m_amount)/100.0f; - - return multipler; -} - -int32 Unit::GetMaxPositiveAuraModifier(AuraType auratype) const -{ - int32 modifier = 0; - - AuraList const& mTotalAuraList = GetAurasByType(auratype); - for(AuraList::const_iterator i = mTotalAuraList.begin();i != mTotalAuraList.end(); ++i) - if ((*i)->GetModifier()->m_amount > modifier) - modifier = (*i)->GetModifier()->m_amount; - - return modifier; -} - -int32 Unit::GetMaxNegativeAuraModifier(AuraType auratype) const -{ - int32 modifier = 0; - - AuraList const& mTotalAuraList = GetAurasByType(auratype); - for(AuraList::const_iterator i = mTotalAuraList.begin();i != mTotalAuraList.end(); ++i) - if ((*i)->GetModifier()->m_amount < modifier) - modifier = (*i)->GetModifier()->m_amount; - - return modifier; -} - -int32 Unit::GetTotalAuraModifierByMiscMask(AuraType auratype, uint32 misc_mask) const -{ - int32 modifier = 0; - - AuraList const& mTotalAuraList = GetAurasByType(auratype); - for(AuraList::const_iterator i = mTotalAuraList.begin();i != mTotalAuraList.end(); ++i) - { - Modifier* mod = (*i)->GetModifier(); - if (mod->m_miscvalue & misc_mask) - modifier += mod->m_amount; - } - return modifier; -} - -float Unit::GetTotalAuraMultiplierByMiscMask(AuraType auratype, uint32 misc_mask) const -{ - float multipler = 1.0f; - - AuraList const& mTotalAuraList = GetAurasByType(auratype); - for(AuraList::const_iterator i = mTotalAuraList.begin();i != mTotalAuraList.end(); ++i) - { - Modifier* mod = (*i)->GetModifier(); - if (mod->m_miscvalue & misc_mask) - multipler *= (100.0f + mod->m_amount)/100.0f; - } - return multipler; -} - -int32 Unit::GetMaxPositiveAuraModifierByMiscMask(AuraType auratype, uint32 misc_mask) const -{ - int32 modifier = 0; - - AuraList const& mTotalAuraList = GetAurasByType(auratype); - for(AuraList::const_iterator i = mTotalAuraList.begin();i != mTotalAuraList.end(); ++i) - { - Modifier* mod = (*i)->GetModifier(); - if (mod->m_miscvalue & misc_mask && mod->m_amount > modifier) - modifier = mod->m_amount; - } - - return modifier; -} - -int32 Unit::GetMaxNegativeAuraModifierByMiscMask(AuraType auratype, uint32 misc_mask) const -{ - int32 modifier = 0; - - AuraList const& mTotalAuraList = GetAurasByType(auratype); - for(AuraList::const_iterator i = mTotalAuraList.begin();i != mTotalAuraList.end(); ++i) - { - Modifier* mod = (*i)->GetModifier(); - if (mod->m_miscvalue & misc_mask && mod->m_amount < modifier) - modifier = mod->m_amount; - } - - return modifier; -} - -int32 Unit::GetTotalAuraModifierByMiscValue(AuraType auratype, int32 misc_value) const -{ - int32 modifier = 0; - - AuraList const& mTotalAuraList = GetAurasByType(auratype); - for(AuraList::const_iterator i = mTotalAuraList.begin();i != mTotalAuraList.end(); ++i) - { - Modifier* mod = (*i)->GetModifier(); - if (mod->m_miscvalue == misc_value) - modifier += mod->m_amount; - } - return modifier; -} - -float Unit::GetTotalAuraMultiplierByMiscValue(AuraType auratype, int32 misc_value) const -{ - float multipler = 1.0f; - - AuraList const& mTotalAuraList = GetAurasByType(auratype); - for(AuraList::const_iterator i = mTotalAuraList.begin();i != mTotalAuraList.end(); ++i) - { - Modifier* mod = (*i)->GetModifier(); - if (mod->m_miscvalue == misc_value) - multipler *= (100.0f + mod->m_amount)/100.0f; - } - return multipler; -} - -int32 Unit::GetMaxPositiveAuraModifierByMiscValue(AuraType auratype, int32 misc_value) const -{ - int32 modifier = 0; - - AuraList const& mTotalAuraList = GetAurasByType(auratype); - for(AuraList::const_iterator i = mTotalAuraList.begin();i != mTotalAuraList.end(); ++i) - { - Modifier* mod = (*i)->GetModifier(); - if (mod->m_miscvalue == misc_value && mod->m_amount > modifier) - modifier = mod->m_amount; - } - - return modifier; -} - -int32 Unit::GetMaxNegativeAuraModifierByMiscValue(AuraType auratype, int32 misc_value) const -{ - int32 modifier = 0; - - AuraList const& mTotalAuraList = GetAurasByType(auratype); - for(AuraList::const_iterator i = mTotalAuraList.begin();i != mTotalAuraList.end(); ++i) - { - Modifier* mod = (*i)->GetModifier(); - if (mod->m_miscvalue == misc_value && mod->m_amount < modifier) - modifier = mod->m_amount; - } - - return modifier; -} - -bool Unit::AddAura(Aura *Aur) -{ - // ghost spell check, allow apply any auras at player loading in ghost mode (will be cleanup after load) - if( !isAlive() && Aur->GetId() != 20584 && Aur->GetId() != 8326 && Aur->GetId() != 2584 && - (GetTypeId()!=TYPEID_PLAYER || !((Player*)this)->GetSession()->PlayerLoading()) ) - { - delete Aur; - return false; - } - - if(Aur->GetTarget() != this) - { - sLog.outError("Aura (spell %u eff %u) add to aura list of %s (lowguid: %u) but Aura target is %s (lowguid: %u)", - Aur->GetId(),Aur->GetEffIndex(),(GetTypeId()==TYPEID_PLAYER?"player":"creature"),GetGUIDLow(), - (Aur->GetTarget()->GetTypeId()==TYPEID_PLAYER?"player":"creature"),Aur->GetTarget()->GetGUIDLow()); - delete Aur; - return false; - } - - SpellEntry const* aurSpellInfo = Aur->GetSpellProto(); - - spellEffectPair spair = spellEffectPair(Aur->GetId(), Aur->GetEffIndex()); - AuraMap::iterator i = m_Auras.find( spair ); - - // take out same spell - if (i != m_Auras.end()) - { - // passive and persistent auras can stack with themselves any number of times - if (!Aur->IsPassive() && !Aur->IsPersistent()) - { - // replace aura if next will > spell StackAmount - if(aurSpellInfo->StackAmount) - { - if(m_Auras.count(spair) >= aurSpellInfo->StackAmount) - RemoveAura(i,AURA_REMOVE_BY_STACK); - } - // if StackAmount==0 not allow auras from same caster - else - { - for(AuraMap::iterator i2 = m_Auras.lower_bound(spair); i2 != m_Auras.upper_bound(spair); ++i2) - { - if(i2->second->GetCasterGUID()==Aur->GetCasterGUID()) - { - // can be only single (this check done at _each_ aura add - RemoveAura(i2,AURA_REMOVE_BY_STACK); - break; - } - - bool stop = false; - switch(aurSpellInfo->EffectApplyAuraName[Aur->GetEffIndex()]) - { - // DoT/HoT/etc - case SPELL_AURA_PERIODIC_DAMAGE: // allow stack - case SPELL_AURA_PERIODIC_DAMAGE_PERCENT: - case SPELL_AURA_PERIODIC_LEECH: - case SPELL_AURA_PERIODIC_HEAL: - case SPELL_AURA_OBS_MOD_HEALTH: - case SPELL_AURA_PERIODIC_MANA_LEECH: - case SPELL_AURA_PERIODIC_ENERGIZE: - case SPELL_AURA_OBS_MOD_MANA: - case SPELL_AURA_POWER_BURN_MANA: - break; - default: // not allow - // can be only single (this check done at _each_ aura add - RemoveAura(i2,AURA_REMOVE_BY_STACK); - stop = true; - break; - } - - if(stop) - break; - } - } - } - } - - // passive auras stack with all (except passive spell proc auras) - if ((!Aur->IsPassive() || !IsPassiveStackableSpell(Aur->GetId())) && - !(Aur->GetId() == 20584 || Aur->GetId() == 8326)) - { - if (!RemoveNoStackAurasDueToAura(Aur)) - { - delete Aur; - return false; // couldnt remove conflicting aura with higher rank - } - } - - // update single target auras list (before aura add to aura list, to prevent unexpected remove recently added aura) - if (IsSingleTargetSpell(aurSpellInfo) && Aur->GetTarget()) - { - // caster pointer can be deleted in time aura remove, find it by guid at each iteration - for(;;) - { - Unit* caster = Aur->GetCaster(); - if(!caster) // caster deleted and not required adding scAura - break; - - bool restart = false; - AuraList& scAuras = caster->GetSingleCastAuras(); - for(AuraList::iterator itr = scAuras.begin(); itr != scAuras.end(); ++itr) - { - if( (*itr)->GetTarget() != Aur->GetTarget() && - IsSingleTargetSpells((*itr)->GetSpellProto(),aurSpellInfo) ) - { - if ((*itr)->IsInUse()) - { - sLog.outError("Aura (Spell %u Effect %u) is in process but attempt removed at aura (Spell %u Effect %u) adding, need add stack rule for IsSingleTargetSpell", (*itr)->GetId(), (*itr)->GetEffIndex(),Aur->GetId(), Aur->GetEffIndex()); - continue; - } - (*itr)->GetTarget()->RemoveAura((*itr)->GetId(), (*itr)->GetEffIndex()); - restart = true; - break; - } - } - - if(!restart) - { - // done - scAuras.push_back(Aur); - break; - } - } - } - - // add aura, register in lists and arrays - Aur->_AddAura(); - m_Auras.insert(AuraMap::value_type(spellEffectPair(Aur->GetId(), Aur->GetEffIndex()), Aur)); - if (Aur->GetModifier()->m_auraname < TOTAL_AURAS) - { - m_modAuras[Aur->GetModifier()->m_auraname].push_back(Aur); - } - - Aur->ApplyModifier(true,true); - sLog.outDebug("Aura %u now is in use", Aur->GetModifier()->m_auraname); - return true; -} - -void Unit::RemoveRankAurasDueToSpell(uint32 spellId) -{ - SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellId); - if(!spellInfo) - return; - AuraMap::iterator i,next; - for (i = m_Auras.begin(); i != m_Auras.end(); i = next) - { - next = i; - ++next; - uint32 i_spellId = (*i).second->GetId(); - if((*i).second && i_spellId && i_spellId != spellId) - { - if(spellmgr.IsRankSpellDueToSpell(spellInfo,i_spellId)) - { - RemoveAurasDueToSpell(i_spellId); - - if( m_Auras.empty() ) - break; - else - next = m_Auras.begin(); - } - } - } -} - -bool Unit::RemoveNoStackAurasDueToAura(Aura *Aur) -{ - if (!Aur) - return false; - - SpellEntry const* spellProto = Aur->GetSpellProto(); - if (!spellProto) - return false; - - uint32 spellId = Aur->GetId(); - uint32 effIndex = Aur->GetEffIndex(); - - SpellSpecific spellId_spec = GetSpellSpecific(spellId); - - AuraMap::iterator i,next; - for (i = m_Auras.begin(); i != m_Auras.end(); i = next) - { - next = i; - ++next; - if (!(*i).second) continue; - - SpellEntry const* i_spellProto = (*i).second->GetSpellProto(); - - if (!i_spellProto) - continue; - - uint32 i_spellId = i_spellProto->Id; - - if(IsPassiveSpell(i_spellId)) - { - if(IsPassiveStackableSpell(i_spellId)) - continue; - - // passive non-stackable spells not stackable only with another rank of same spell - if (!spellmgr.IsRankSpellDueToSpell(spellProto, i_spellId)) - continue; - } - - uint32 i_effIndex = (*i).second->GetEffIndex(); - - if(i_spellId == spellId) continue; - - bool is_triggered_by_spell = false; - // prevent triggered aura of removing aura that triggered it - for(int j = 0; j < 3; ++j) - if (i_spellProto->EffectTriggerSpell[j] == spellProto->Id) - is_triggered_by_spell = true; - if (is_triggered_by_spell) continue; - - for(int j = 0; j < 3; ++j) - { - // prevent remove dummy triggered spells at next effect aura add - switch(spellProto->Effect[j]) // main spell auras added added after triggred spell - { - case SPELL_EFFECT_DUMMY: - switch(spellId) - { - case 5420: if(i_spellId==34123) is_triggered_by_spell = true; break; - } - break; - } - - if(is_triggered_by_spell) - break; - - // prevent remove form main spell by triggred passive spells - switch(i_spellProto->EffectApplyAuraName[j]) // main aura added before triggered spell - { - case SPELL_AURA_MOD_SHAPESHIFT: - switch(i_spellId) - { - case 24858: if(spellId==24905) is_triggered_by_spell = true; break; - case 33891: if(spellId==5420 || spellId==34123) is_triggered_by_spell = true; break; - case 34551: if(spellId==22688) is_triggered_by_spell = true; break; - } - break; - } - } - - if(!is_triggered_by_spell) - { - SpellSpecific i_spellId_spec = GetSpellSpecific(i_spellId); - - bool is_sspc = IsSingleFromSpellSpecificPerCaster(spellId_spec,i_spellId_spec); - - if( is_sspc && Aur->GetCasterGUID() == (*i).second->GetCasterGUID() ) - { - // cannot remove higher rank - if (spellmgr.IsRankSpellDueToSpell(spellProto, i_spellId)) - if(CompareAuraRanks(spellId, effIndex, i_spellId, i_effIndex) < 0) - return false; - - // Its a parent aura (create this aura in ApplyModifier) - if ((*i).second->IsInUse()) - { - sLog.outError("Aura (Spell %u Effect %u) is in process but attempt removed at aura (Spell %u Effect %u) adding, need add stack rule for Unit::RemoveNoStackAurasDueToAura", i->second->GetId(), i->second->GetEffIndex(),Aur->GetId(), Aur->GetEffIndex()); - continue; - } - RemoveAurasDueToSpell(i_spellId); - - if( m_Auras.empty() ) - break; - else - next = m_Auras.begin(); - } - else if( !is_sspc && spellmgr.IsNoStackSpellDueToSpell(spellId, i_spellId) ) - { - // Its a parent aura (create this aura in ApplyModifier) - if ((*i).second->IsInUse()) - { - sLog.outError("Aura (Spell %u Effect %u) is in process but attempt removed at aura (Spell %u Effect %u) adding, need add stack rule for Unit::RemoveNoStackAurasDueToAura", i->second->GetId(), i->second->GetEffIndex(),Aur->GetId(), Aur->GetEffIndex()); - continue; - } - RemoveAurasDueToSpell(i_spellId); - - if( m_Auras.empty() ) - break; - else - next = m_Auras.begin(); - } - // Potions stack aura by aura (elixirs/flask already checked) - else if( spellProto->SpellFamilyName == SPELLFAMILY_POTION && i_spellProto->SpellFamilyName == SPELLFAMILY_POTION ) - { - if (IsNoStackAuraDueToAura(spellId, effIndex, i_spellId, i_effIndex)) - { - if(CompareAuraRanks(spellId, effIndex, i_spellId, i_effIndex) < 0) - return false; // cannot remove higher rank - - // Its a parent aura (create this aura in ApplyModifier) - if ((*i).second->IsInUse()) - { - sLog.outError("Aura (Spell %u Effect %u) is in process but attempt removed at aura (Spell %u Effect %u) adding, need add stack rule for Unit::RemoveNoStackAurasDueToAura", i->second->GetId(), i->second->GetEffIndex(),Aur->GetId(), Aur->GetEffIndex()); - continue; - } - RemoveAura(i); - next = i; - } - } - } - } - return true; -} - -void Unit::RemoveAura(uint32 spellId, uint32 effindex, Aura* except) -{ - spellEffectPair spair = spellEffectPair(spellId, effindex); - for(AuraMap::iterator iter = m_Auras.lower_bound(spair); iter != m_Auras.upper_bound(spair);) - { - if(iter->second!=except) - { - RemoveAura(iter); - iter = m_Auras.lower_bound(spair); - } - else - ++iter; - } -} - -void Unit::RemoveAurasDueToSpellByDispel(uint32 spellId, uint64 casterGUID, Unit *dispeler) -{ - for (AuraMap::iterator iter = m_Auras.begin(); iter != m_Auras.end(); ) - { - Aura *aur = iter->second; - if (aur->GetId() == spellId && aur->GetCasterGUID() == casterGUID) - { - // Custom dispel case - // Unstable Affliction - if (aur->GetSpellProto()->SpellFamilyName == SPELLFAMILY_WARLOCK && (aur->GetSpellProto()->SpellFamilyFlags & 0x010000000000LL)) - { - int32 damage = aur->GetModifier()->m_amount*9; - uint64 caster_guid = aur->GetCasterGUID(); - - // Remove aura - RemoveAura(iter, AURA_REMOVE_BY_DISPEL); - - // backfire damage and silence - dispeler->CastCustomSpell(dispeler, 31117, &damage, NULL, NULL, true, NULL, NULL,caster_guid); - - iter = m_Auras.begin(); // iterator can be invalidate at cast if self-dispel - } - else - RemoveAura(iter, AURA_REMOVE_BY_DISPEL); - } - else - ++iter; - } -} - -void Unit::RemoveAurasDueToSpellBySteal(uint32 spellId, uint64 casterGUID, Unit *stealer) -{ - for (AuraMap::iterator iter = m_Auras.begin(); iter != m_Auras.end(); ) - { - Aura *aur = iter->second; - if (aur->GetId() == spellId && aur->GetCasterGUID() == casterGUID) - { - int32 basePoints = aur->GetBasePoints(); - // construct the new aura for the attacker - Aura * new_aur = CreateAura(aur->GetSpellProto(), aur->GetEffIndex(), &basePoints, stealer); - if(!new_aur) - continue; - - // set its duration and maximum duration - // max duration 2 minutes (in msecs) - int32 dur = aur->GetAuraDuration(); - const int32 max_dur = 2*MINUTE*1000; - new_aur->SetAuraMaxDuration( max_dur > dur ? dur : max_dur ); - new_aur->SetAuraDuration( max_dur > dur ? dur : max_dur ); - - // add the new aura to stealer - stealer->AddAura(new_aur); - - // Remove aura as dispel - RemoveAura(iter, AURA_REMOVE_BY_DISPEL); - } - else - ++iter; - } -} - -void Unit::RemoveAurasDueToSpellByCancel(uint32 spellId) -{ - for (AuraMap::iterator iter = m_Auras.begin(); iter != m_Auras.end(); ) - { - if (iter->second->GetId() == spellId) - RemoveAura(iter, AURA_REMOVE_BY_CANCEL); - else - ++iter; - } -} - -void Unit::RemoveAurasWithDispelType( DispelType type ) -{ - // Create dispel mask by dispel type - uint32 dispelMask = GetDispellMask(type); - // Dispel all existing auras vs current dispell type - AuraMap& auras = GetAuras(); - for(AuraMap::iterator itr = auras.begin(); itr != auras.end(); ) - { - SpellEntry const* spell = itr->second->GetSpellProto(); - if( (1<Dispel) & dispelMask ) - { - // Dispel aura - RemoveAurasDueToSpell(spell->Id); - itr = auras.begin(); - } - else - ++itr; - } -} - -void Unit::RemoveSingleAuraFromStack(uint32 spellId, uint32 effindex) -{ - AuraMap::iterator iter = m_Auras.find(spellEffectPair(spellId, effindex)); - if(iter != m_Auras.end()) - RemoveAura(iter); -} - -void Unit::RemoveAurasDueToSpell(uint32 spellId, Aura* except) -{ - for (int i = 0; i < 3; ++i) - RemoveAura(spellId,i,except); -} - -void Unit::RemoveAurasDueToItemSpell(Item* castItem,uint32 spellId) -{ - for (int k=0; k < 3; ++k) - { - spellEffectPair spair = spellEffectPair(spellId, k); - for (AuraMap::iterator iter = m_Auras.lower_bound(spair); iter != m_Auras.upper_bound(spair);) - { - if (iter->second->GetCastItemGUID() == castItem->GetGUID()) - { - RemoveAura(iter); - iter = m_Auras.upper_bound(spair); // overwrite by more appropriate - } - else - ++iter; - } - } -} - -void Unit::RemoveAurasWithInterruptFlags(uint32 flags) -{ - for (AuraMap::iterator iter = m_Auras.begin(); iter != m_Auras.end(); ) - { - if (iter->second->GetSpellProto()->AuraInterruptFlags & flags) - RemoveAura(iter); - else - ++iter; - } -} - -void Unit::RemoveNotOwnSingleTargetAuras() -{ - // single target auras from other casters - for (AuraMap::iterator iter = m_Auras.begin(); iter != m_Auras.end(); ) - { - if (iter->second->GetCasterGUID()!=GetGUID() && IsSingleTargetSpell(iter->second->GetSpellProto())) - RemoveAura(iter); - else - ++iter; - } - - // single target auras at other targets - AuraList& scAuras = GetSingleCastAuras(); - for (AuraList::iterator iter = scAuras.begin(); iter != scAuras.end(); ) - { - Aura* aura = *iter; - if (aura->GetTarget()!=this) - { - scAuras.erase(iter); // explicitly remove, instead waiting remove in RemoveAura - aura->GetTarget()->RemoveAura(aura->GetId(),aura->GetEffIndex()); - iter = scAuras.begin(); - } - else - ++iter; - } - -} - -void Unit::RemoveAura(AuraMap::iterator &i, AuraRemoveMode mode) -{ - if (IsSingleTargetSpell((*i).second->GetSpellProto())) - { - if(Unit* caster = (*i).second->GetCaster()) - { - AuraList& scAuras = caster->GetSingleCastAuras(); - scAuras.remove((*i).second); - } - else - { - sLog.outError("Couldn't find the caster of the single target aura, may crash later!"); - assert(false); - } - } - - if ((*i).second->GetModifier()->m_auraname < TOTAL_AURAS) - { - m_modAuras[(*i).second->GetModifier()->m_auraname].remove((*i).second); - } - - // remove from list before mods removing (prevent cyclic calls, mods added before including to aura list - use reverse order) - Aura* Aur = i->second; - // Set remove mode - Aur->SetRemoveMode(mode); - // some ShapeshiftBoosts at remove trigger removing other auras including parent Shapeshift aura - // remove aura from list before to prevent deleting it before - m_Auras.erase(i); - ++m_removedAuras; // internal count used by unit update - - // Status unsummoned at aura remove - Totem* statue = NULL; - if(IsChanneledSpell(Aur->GetSpellProto())) - if(Unit* caster = Aur->GetCaster()) - if(caster->GetTypeId()==TYPEID_UNIT && ((Creature*)caster)->isTotem() && ((Totem*)caster)->GetTotemType()==TOTEM_STATUE) - statue = ((Totem*)caster); - - sLog.outDebug("Aura %u now is remove mode %d",Aur->GetModifier()->m_auraname, mode); - Aur->ApplyModifier(false,true); - Aur->_RemoveAura(); - delete Aur; - - if(statue) - statue->UnSummon(); - - // only way correctly remove all auras from list - if( m_Auras.empty() ) - i = m_Auras.end(); - else - i = m_Auras.begin(); -} - -void Unit::RemoveAllAuras() -{ - while (!m_Auras.empty()) - { - AuraMap::iterator iter = m_Auras.begin(); - RemoveAura(iter); - } -} - -void Unit::RemoveAllAurasOnDeath() -{ - // used just after dieing to remove all visible auras - // and disable the mods for the passive ones - for(AuraMap::iterator iter = m_Auras.begin(); iter != m_Auras.end();) - { - if (!iter->second->IsPassive() && !iter->second->IsDeathPersistent()) - RemoveAura(iter, AURA_REMOVE_BY_DEATH); - else - ++iter; - } -} - -void Unit::DelayAura(uint32 spellId, uint32 effindex, int32 delaytime) -{ - AuraMap::iterator iter = m_Auras.find(spellEffectPair(spellId, effindex)); - if (iter != m_Auras.end()) - { - if (iter->second->GetAuraDuration() < delaytime) - iter->second->SetAuraDuration(0); - else - iter->second->SetAuraDuration(iter->second->GetAuraDuration() - delaytime); - iter->second->UpdateAuraDuration(); - sLog.outDebug("Aura %u partially interrupted on unit %u, new duration: %u ms",iter->second->GetModifier()->m_auraname, GetGUIDLow(), iter->second->GetAuraDuration()); - } -} - -void Unit::_RemoveAllAuraMods() -{ - for (AuraMap::iterator i = m_Auras.begin(); i != m_Auras.end(); ++i) - { - (*i).second->ApplyModifier(false); - } -} - -void Unit::_ApplyAllAuraMods() -{ - for (AuraMap::iterator i = m_Auras.begin(); i != m_Auras.end(); ++i) - { - (*i).second->ApplyModifier(true); - } -} - -Aura* Unit::GetAura(uint32 spellId, uint32 effindex) -{ - AuraMap::iterator iter = m_Auras.find(spellEffectPair(spellId, effindex)); - if (iter != m_Auras.end()) - return iter->second; - return NULL; -} - -void Unit::AddDynObject(DynamicObject* dynObj) -{ - m_dynObjGUIDs.push_back(dynObj->GetGUID()); -} - -void Unit::RemoveDynObject(uint32 spellid) -{ - if(m_dynObjGUIDs.empty()) - return; - for (DynObjectGUIDs::iterator i = m_dynObjGUIDs.begin(); i != m_dynObjGUIDs.end();) - { - DynamicObject* dynObj = ObjectAccessor::GetDynamicObject(*this,*m_dynObjGUIDs.begin()); - if(!dynObj) - { - i = m_dynObjGUIDs.erase(i); - } - else if(spellid == 0 || dynObj->GetSpellId() == spellid) - { - dynObj->Delete(); - i = m_dynObjGUIDs.erase(i); - } - else - ++i; - } -} - -void Unit::RemoveAllDynObjects() -{ - while(!m_dynObjGUIDs.empty()) - { - DynamicObject* dynObj = ObjectAccessor::GetDynamicObject(*this,*m_dynObjGUIDs.begin()); - if(dynObj) - dynObj->Delete(); - m_dynObjGUIDs.erase(m_dynObjGUIDs.begin()); - } -} - -DynamicObject * Unit::GetDynObject(uint32 spellId, uint32 effIndex) -{ - for (DynObjectGUIDs::iterator i = m_dynObjGUIDs.begin(); i != m_dynObjGUIDs.end();) - { - DynamicObject* dynObj = ObjectAccessor::GetDynamicObject(*this,*m_dynObjGUIDs.begin()); - if(!dynObj) - { - i = m_dynObjGUIDs.erase(i); - continue; - } - - if (dynObj->GetSpellId() == spellId && dynObj->GetEffIndex() == effIndex) - return dynObj; - ++i; - } - return NULL; -} - -DynamicObject * Unit::GetDynObject(uint32 spellId) -{ - for (DynObjectGUIDs::iterator i = m_dynObjGUIDs.begin(); i != m_dynObjGUIDs.end();) - { - DynamicObject* dynObj = ObjectAccessor::GetDynamicObject(*this,*m_dynObjGUIDs.begin()); - if(!dynObj) - { - i = m_dynObjGUIDs.erase(i); - continue; - } - - if (dynObj->GetSpellId() == spellId) - return dynObj; - ++i; - } - return NULL; -} - -void Unit::AddGameObject(GameObject* gameObj) -{ - assert(gameObj && gameObj->GetOwnerGUID()==0); - m_gameObj.push_back(gameObj); - gameObj->SetOwnerGUID(GetGUID()); -} - -void Unit::RemoveGameObject(GameObject* gameObj, bool del) -{ - assert(gameObj && gameObj->GetOwnerGUID()==GetGUID()); - - // GO created by some spell - if ( GetTypeId()==TYPEID_PLAYER && gameObj->GetSpellId() ) - { - SpellEntry const* createBySpell = sSpellStore.LookupEntry(gameObj->GetSpellId()); - // Need activate spell use for owner - if (createBySpell && createBySpell->Attributes & SPELL_ATTR_DISABLED_WHILE_ACTIVE) - ((Player*)this)->SendCooldownEvent(createBySpell); - } - gameObj->SetOwnerGUID(0); - m_gameObj.remove(gameObj); - if(del) - { - gameObj->SetRespawnTime(0); - gameObj->Delete(); - } -} - -void Unit::RemoveGameObject(uint32 spellid, bool del) -{ - if(m_gameObj.empty()) - return; - std::list::iterator i, next; - for (i = m_gameObj.begin(); i != m_gameObj.end(); i = next) - { - next = i; - if(spellid == 0 || (*i)->GetSpellId() == spellid) - { - (*i)->SetOwnerGUID(0); - if(del) - { - (*i)->SetRespawnTime(0); - (*i)->Delete(); - } - - next = m_gameObj.erase(i); - } - else - ++next; - } -} - -void Unit::RemoveAllGameObjects() -{ - // remove references to unit - for(std::list::iterator i = m_gameObj.begin(); i != m_gameObj.end();) - { - (*i)->SetOwnerGUID(0); - (*i)->SetRespawnTime(0); - (*i)->Delete(); - i = m_gameObj.erase(i); - } -} - -void Unit::SendSpellNonMeleeDamageLog(Unit *target,uint32 SpellID,uint32 Damage, SpellSchoolMask damageSchoolMask,uint32 AbsorbedDamage, uint32 Resist,bool PhysicalDamage, uint32 Blocked, bool CriticalHit) -{ - sLog.outDebug("Sending: SMSG_SPELLNONMELEEDAMAGELOG"); - WorldPacket data(SMSG_SPELLNONMELEEDAMAGELOG, (16+4+4+1+4+4+1+1+4+4+1)); // we guess size - data.append(target->GetPackGUID()); - data.append(GetPackGUID()); - data << uint32(SpellID); - data << uint32(Damage-AbsorbedDamage-Resist-Blocked); - data << uint8(damageSchoolMask); // spell school - data << uint32(AbsorbedDamage); // AbsorbedDamage - data << uint32(Resist); // resist - data << uint8(PhysicalDamage); // if 1, then client show spell name (example: %s's ranged shot hit %s for %u school or %s suffers %u school damage from %s's spell_name - data << uint8(0); // unk isFromAura - data << uint32(Blocked); // blocked - data << uint32(CriticalHit ? 0x27 : 0x25); // hitType, flags: 0x2 - SPELL_HIT_TYPE_CRIT, 0x10 - replace caster? - data << uint8(0); // isDebug? - SendMessageToSet( &data, true ); -} - -void Unit::SendSpellMiss(Unit *target, uint32 spellID, SpellMissInfo missInfo) -{ - WorldPacket data(SMSG_SPELLLOGMISS, (4+8+1+4+8+1)); - data << uint32(spellID); - data << uint64(GetGUID()); - data << uint8(0); // can be 0 or 1 - data << uint32(1); // target count - // for(i = 0; i < target count; ++i) - data << uint64(target->GetGUID()); // target GUID - data << uint8(missInfo); - // end loop - SendMessageToSet(&data, true); -} - -void Unit::SendAttackStateUpdate(uint32 HitInfo, Unit *target, uint8 SwingType, SpellSchoolMask damageSchoolMask, uint32 Damage, uint32 AbsorbDamage, uint32 Resist, VictimState TargetState, uint32 BlockedAmount) -{ - sLog.outDebug("WORLD: Sending SMSG_ATTACKERSTATEUPDATE"); - - WorldPacket data(SMSG_ATTACKERSTATEUPDATE, (16+45)); // we guess size - data << (uint32)HitInfo; - data.append(GetPackGUID()); - data.append(target->GetPackGUID()); - data << (uint32)(Damage-AbsorbDamage-Resist-BlockedAmount); - - data << (uint8)SwingType; // count? - - // for(i = 0; i < SwingType; ++i) - data << (uint32)damageSchoolMask; - data << (float)(Damage-AbsorbDamage-Resist-BlockedAmount); - // still need to double check damage - data << (uint32)(Damage-AbsorbDamage-Resist-BlockedAmount); - data << (uint32)AbsorbDamage; - data << (uint32)Resist; - // end loop - - data << (uint32)TargetState; - - if( AbsorbDamage == 0 ) //also 0x3E8 = 0x3E8, check when that happens - data << (uint32)0; - else - data << (uint32)-1; - - data << (uint32)0; - data << (uint32)BlockedAmount; - - SendMessageToSet( &data, true ); -} - -void Unit::ProcDamageAndSpell(Unit *pVictim, uint32 procAttacker, uint32 procVictim, uint32 damage, SpellSchoolMask damageSchoolMask, SpellEntry const *procSpell, bool isTriggeredSpell, WeaponAttackType attType) -{ - sLog.outDebug("ProcDamageAndSpell: attacker flags are 0x%x, victim flags 0x%x", procAttacker, procVictim); - if(procSpell) - sLog.outDebug("ProcDamageAndSpell: invoked due to spell id %u %s", procSpell->Id, (isTriggeredSpell?"(triggered)":"")); - - // Assign melee/ranged proc flags for magic attacks, that are actually melee/ranged abilities - // not assign for spell proc triggered spell to prevent infinity (or unexpacted 2-3 times) melee damage spell proc call with melee damage effect - // That is the question though if it's fully correct - if(procSpell && !isTriggeredSpell) - { - if(procSpell->DmgClass == SPELL_DAMAGE_CLASS_MELEE) - { - if(procAttacker & PROC_FLAG_HIT_SPELL) procAttacker |= PROC_FLAG_HIT_MELEE; - if(procAttacker & PROC_FLAG_CRIT_SPELL) procAttacker |= PROC_FLAG_CRIT_MELEE; - if(procVictim & PROC_FLAG_STRUCK_SPELL) procVictim |= PROC_FLAG_STRUCK_MELEE; - if(procVictim & PROC_FLAG_STRUCK_CRIT_SPELL) procVictim |= PROC_FLAG_STRUCK_CRIT_MELEE; - attType = BASE_ATTACK; // Melee abilities are assumed to be dealt with mainhand weapon - } - else if (procSpell->DmgClass == SPELL_DAMAGE_CLASS_RANGED) - { - if(procAttacker & PROC_FLAG_HIT_SPELL) procAttacker |= PROC_FLAG_HIT_RANGED; - if(procAttacker & PROC_FLAG_CRIT_SPELL) procAttacker |= PROC_FLAG_CRIT_RANGED; - if(procVictim & PROC_FLAG_STRUCK_SPELL) procVictim |= PROC_FLAG_STRUCK_RANGED; - if(procVictim & PROC_FLAG_STRUCK_CRIT_SPELL) procVictim |= PROC_FLAG_STRUCK_CRIT_RANGED; - attType = RANGED_ATTACK; - } - } - if(damage && (procVictim & (PROC_FLAG_STRUCK_MELEE|PROC_FLAG_STRUCK_RANGED|PROC_FLAG_STRUCK_SPELL))) - procVictim |= (PROC_FLAG_TAKE_DAMAGE|PROC_FLAG_TOUCH); - - // Not much to do if no flags are set. - if (procAttacker) - { - // procces auras that not generate casts at proc event before auras that generate casts to prevent proc aura added at prev. proc aura execute in set - ProcDamageAndSpellFor(false,pVictim,procAttacker,attackerProcEffectAuraTypes,attType, procSpell, damage, damageSchoolMask); - ProcDamageAndSpellFor(false,pVictim,procAttacker,attackerProcCastAuraTypes,attType, procSpell, damage, damageSchoolMask); - } - - // Now go on with a victim's events'n'auras - // Not much to do if no flags are set or there is no victim - if(pVictim && pVictim->isAlive() && procVictim) - { - // procces auras that not generate casts at proc event before auras that generate casts to prevent proc aura added at prev. proc aura execute in set - pVictim->ProcDamageAndSpellFor(true,this,procVictim,victimProcEffectAuraTypes,attType,procSpell, damage, damageSchoolMask); - pVictim->ProcDamageAndSpellFor(true,this,procVictim,victimProcCastAuraTypes,attType,procSpell, damage, damageSchoolMask); - } -} - -void Unit::CastMeleeProcDamageAndSpell(Unit* pVictim, uint32 damage, SpellSchoolMask damageSchoolMask, WeaponAttackType attType, MeleeHitOutcome outcome, SpellEntry const *spellCasted, bool isTriggeredSpell) -{ - if(!pVictim) - return; - - uint32 procAttacker = PROC_FLAG_NONE; - uint32 procVictim = PROC_FLAG_NONE; - - switch(outcome) - { - case MELEE_HIT_EVADE: - return; - case MELEE_HIT_MISS: - if(attType == BASE_ATTACK || attType == OFF_ATTACK) - { - procAttacker = PROC_FLAG_MISS; - } - break; - case MELEE_HIT_BLOCK_CRIT: - case MELEE_HIT_CRIT: - if(spellCasted && attType == BASE_ATTACK) - { - procAttacker |= PROC_FLAG_CRIT_SPELL; - procVictim |= PROC_FLAG_STRUCK_CRIT_SPELL; - if ( outcome == MELEE_HIT_BLOCK_CRIT ) - { - procVictim |= PROC_FLAG_BLOCK; - procAttacker |= PROC_FLAG_TARGET_BLOCK; - } - } - else if(attType == BASE_ATTACK || attType == OFF_ATTACK) - { - procAttacker = PROC_FLAG_HIT_MELEE | PROC_FLAG_CRIT_MELEE; - procVictim = PROC_FLAG_STRUCK_MELEE | PROC_FLAG_STRUCK_CRIT_MELEE; - } - else - { - procAttacker = PROC_FLAG_HIT_RANGED | PROC_FLAG_CRIT_RANGED; - procVictim = PROC_FLAG_STRUCK_RANGED | PROC_FLAG_STRUCK_CRIT_RANGED; - } - break; - case MELEE_HIT_PARRY: - procAttacker = PROC_FLAG_TARGET_DODGE_OR_PARRY; - procVictim = PROC_FLAG_PARRY; - break; - case MELEE_HIT_BLOCK: - procAttacker = PROC_FLAG_TARGET_BLOCK; - procVictim = PROC_FLAG_BLOCK; - break; - case MELEE_HIT_DODGE: - procAttacker = PROC_FLAG_TARGET_DODGE_OR_PARRY; - procVictim = PROC_FLAG_DODGE; - break; - case MELEE_HIT_CRUSHING: - if(attType == BASE_ATTACK || attType == OFF_ATTACK) - { - procAttacker = PROC_FLAG_HIT_MELEE | PROC_FLAG_CRIT_MELEE; - procVictim = PROC_FLAG_STRUCK_MELEE | PROC_FLAG_STRUCK_CRIT_MELEE; - } - else - { - procAttacker = PROC_FLAG_HIT_RANGED | PROC_FLAG_CRIT_RANGED; - procVictim = PROC_FLAG_STRUCK_RANGED | PROC_FLAG_STRUCK_CRIT_RANGED; - } - break; - default: - if(attType == BASE_ATTACK || attType == OFF_ATTACK) - { - procAttacker = PROC_FLAG_HIT_MELEE; - procVictim = PROC_FLAG_STRUCK_MELEE; - } - else - { - procAttacker = PROC_FLAG_HIT_RANGED; - procVictim = PROC_FLAG_STRUCK_RANGED; - } - break; - } - - if(damage > 0) - procVictim |= PROC_FLAG_TAKE_DAMAGE; - - if(procAttacker != PROC_FLAG_NONE || procVictim != PROC_FLAG_NONE) - ProcDamageAndSpell(pVictim, procAttacker, procVictim, damage, damageSchoolMask, spellCasted, isTriggeredSpell, attType); -} - -bool Unit::HandleHasteAuraProc(Unit *pVictim, SpellEntry const *hasteSpell, uint32 /*effIndex*/, uint32 damage, Aura* triggeredByAura, SpellEntry const * procSpell, uint32 /*procFlag*/, uint32 cooldown) -{ - Item* castItem = triggeredByAura->GetCastItemGUID() && GetTypeId()==TYPEID_PLAYER - ? ((Player*)this)->GetItemByGuid(triggeredByAura->GetCastItemGUID()) : NULL; - - uint32 triggered_spell_id = 0; - Unit* target = pVictim; - int32 basepoints0 = 0; - - switch(hasteSpell->SpellFamilyName) - { - case SPELLFAMILY_ROGUE: - { - switch(hasteSpell->Id) - { - // Blade Flurry - case 13877: - case 33735: - { - target = SelectNearbyTarget(); - if(!target) - return false; - basepoints0 = damage; - triggered_spell_id = 22482; - break; - } - } - break; - } - } - - // processed charge only counting case - if(!triggered_spell_id) - return true; - - SpellEntry const* triggerEntry = sSpellStore.LookupEntry(triggered_spell_id); - - if(!triggerEntry) - { - sLog.outError("Unit::HandleHasteAuraProc: Spell %u have not existed triggered spell %u",hasteSpell->Id,triggered_spell_id); - return false; - } - - // default case - if(!target || target!=this && !target->isAlive()) - return false; - - if( cooldown && GetTypeId()==TYPEID_PLAYER && ((Player*)this)->HasSpellCooldown(triggered_spell_id)) - return false; - - if(basepoints0) - CastCustomSpell(target,triggered_spell_id,&basepoints0,NULL,NULL,true,castItem,triggeredByAura); - else - CastSpell(target,triggered_spell_id,true,castItem,triggeredByAura); - - if( cooldown && GetTypeId()==TYPEID_PLAYER ) - ((Player*)this)->AddSpellCooldown(triggered_spell_id,0,time(NULL) + cooldown); - - return true; -} - -bool Unit::HandleDummyAuraProc(Unit *pVictim, SpellEntry const *dummySpell, uint32 effIndex, uint32 damage, Aura* triggeredByAura, SpellEntry const * procSpell, uint32 procFlag, uint32 cooldown) -{ - Item* castItem = triggeredByAura->GetCastItemGUID() && GetTypeId()==TYPEID_PLAYER - ? ((Player*)this)->GetItemByGuid(triggeredByAura->GetCastItemGUID()) : NULL; - - uint32 triggered_spell_id = 0; - Unit* target = pVictim; - int32 basepoints0 = 0; - - switch(dummySpell->SpellFamilyName) - { - case SPELLFAMILY_GENERIC: - { - switch (dummySpell->Id) - { - // Eye of Eye - case 9799: - case 25988: - { - // prevent damage back from weapon special attacks - if (!procSpell || procSpell->DmgClass != SPELL_DAMAGE_CLASS_MAGIC ) - return false; - - // return damage % to attacker but < 50% own total health - basepoints0 = triggeredByAura->GetModifier()->m_amount*int32(damage)/100; - if(basepoints0 > GetMaxHealth()/2) - basepoints0 = GetMaxHealth()/2; - - triggered_spell_id = 25997; - break; - } - // Sweeping Strikes - case 12328: - case 18765: - case 35429: - { - // prevent chain of triggred spell from same triggred spell - if(procSpell && procSpell->Id==26654) - return false; - - target = SelectNearbyTarget(); - if(!target) - return false; - - triggered_spell_id = 26654; - break; - } - // Unstable Power - case 24658: - { - if (!procSpell || procSpell->Id == 24659) - return false; - // Need remove one 24659 aura - RemoveSingleAuraFromStack(24659, 0); - RemoveSingleAuraFromStack(24659, 1); - return true; - } - // Restless Strength - case 24661: - { - // Need remove one 24662 aura - RemoveSingleAuraFromStack(24662, 0); - return true; - } - // Adaptive Warding (Frostfire Regalia set) - case 28764: - { - if(!procSpell) - return false; - - // find Mage Armor - bool found = false; - AuraList const& mRegenInterupt = GetAurasByType(SPELL_AURA_MOD_MANA_REGEN_INTERRUPT); - for(AuraList::const_iterator iter = mRegenInterupt.begin(); iter != mRegenInterupt.end(); ++iter) - { - if(SpellEntry const* iterSpellProto = (*iter)->GetSpellProto()) - { - if(iterSpellProto->SpellFamilyName==SPELLFAMILY_MAGE && (iterSpellProto->SpellFamilyFlags & 0x10000000)) - { - found=true; - break; - } - } - } - if(!found) - return false; - - switch(GetFirstSchoolInMask(GetSpellSchoolMask(procSpell))) - { - case SPELL_SCHOOL_NORMAL: - case SPELL_SCHOOL_HOLY: - return false; // ignored - case SPELL_SCHOOL_FIRE: triggered_spell_id = 28765; break; - case SPELL_SCHOOL_NATURE: triggered_spell_id = 28768; break; - case SPELL_SCHOOL_FROST: triggered_spell_id = 28766; break; - case SPELL_SCHOOL_SHADOW: triggered_spell_id = 28769; break; - case SPELL_SCHOOL_ARCANE: triggered_spell_id = 28770; break; - default: - return false; - } - - target = this; - break; - } - // Obsidian Armor (Justice Bearer`s Pauldrons shoulder) - case 27539: - { - if(!procSpell) - return false; - - // not from DoT - bool found = false; - for(int j = 0; j < 3; ++j) - { - if(procSpell->EffectApplyAuraName[j]==SPELL_AURA_PERIODIC_DAMAGE||procSpell->EffectApplyAuraName[j]==SPELL_AURA_PERIODIC_DAMAGE_PERCENT) - { - found = true; - break; - } - } - if(found) - return false; - - switch(GetFirstSchoolInMask(GetSpellSchoolMask(procSpell))) - { - case SPELL_SCHOOL_NORMAL: - return false; // ignore - case SPELL_SCHOOL_HOLY: triggered_spell_id = 27536; break; - case SPELL_SCHOOL_FIRE: triggered_spell_id = 27533; break; - case SPELL_SCHOOL_NATURE: triggered_spell_id = 27538; break; - case SPELL_SCHOOL_FROST: triggered_spell_id = 27534; break; - case SPELL_SCHOOL_SHADOW: triggered_spell_id = 27535; break; - case SPELL_SCHOOL_ARCANE: triggered_spell_id = 27540; break; - default: - return false; - } - - target = this; - break; - } - // Mana Leech (Passive) (Priest Pet Aura) - case 28305: - { - // Cast on owner - target = GetOwner(); - if(!target) - return false; - - basepoints0 = int32(damage * 2.5f); // manaregen - triggered_spell_id = 34650; - break; - } - // Mark of Malice - case 33493: - { - // Cast finish spell at last charge - if (triggeredByAura->m_procCharges > 1) - return false; - - target = this; - triggered_spell_id = 33494; - break; - } - // Twisted Reflection (boss spell) - case 21063: - triggered_spell_id = 21064; - break; - // Vampiric Aura (boss spell) - case 38196: - { - basepoints0 = 3 * damage; // 300% - if (basepoints0 < 0) - return false; - - triggered_spell_id = 31285; - target = this; - break; - } - // Aura of Madness (Darkmoon Card: Madness trinket) - //===================================================== - // 39511 Sociopath: +35 strength (Paladin, Rogue, Druid, Warrior) - // 40997 Delusional: +70 attack power (Rogue, Hunter, Paladin, Warrior, Druid) - // 40998 Kleptomania: +35 agility (Warrior, Rogue, Paladin, Hunter, Druid) - // 40999 Megalomania: +41 damage/healing (Druid, Shaman, Priest, Warlock, Mage, Paladin) - // 41002 Paranoia: +35 spell/melee/ranged crit strike rating (All classes) - // 41005 Manic: +35 haste (spell, melee and ranged) (All classes) - // 41009 Narcissism: +35 intellect (Druid, Shaman, Priest, Warlock, Mage, Paladin, Hunter) - // 41011 Martyr Complex: +35 stamina (All classes) - // 41406 Dementia: Every 5 seconds either gives you +5% damage/healing. (Druid, Shaman, Priest, Warlock, Mage, Paladin) - // 41409 Dementia: Every 5 seconds either gives you -5% damage/healing. (Druid, Shaman, Priest, Warlock, Mage, Paladin) - case 39446: - { - if(GetTypeId() != TYPEID_PLAYER) - return false; - - // Select class defined buff - switch (getClass()) - { - case CLASS_PALADIN: // 39511,40997,40998,40999,41002,41005,41009,41011,41409 - case CLASS_DRUID: // 39511,40997,40998,40999,41002,41005,41009,41011,41409 - { - uint32 RandomSpell[]={39511,40997,40998,40999,41002,41005,41009,41011,41409}; - triggered_spell_id = RandomSpell[ irand(0, sizeof(RandomSpell)/sizeof(uint32) - 1) ]; - break; - } - case CLASS_ROGUE: // 39511,40997,40998,41002,41005,41011 - case CLASS_WARRIOR: // 39511,40997,40998,41002,41005,41011 - { - uint32 RandomSpell[]={39511,40997,40998,41002,41005,41011}; - triggered_spell_id = RandomSpell[ irand(0, sizeof(RandomSpell)/sizeof(uint32) - 1) ]; - break; - } - case CLASS_PRIEST: // 40999,41002,41005,41009,41011,41406,41409 - case CLASS_SHAMAN: // 40999,41002,41005,41009,41011,41406,41409 - case CLASS_MAGE: // 40999,41002,41005,41009,41011,41406,41409 - case CLASS_WARLOCK: // 40999,41002,41005,41009,41011,41406,41409 - { - uint32 RandomSpell[]={40999,41002,41005,41009,41011,41406,41409}; - triggered_spell_id = RandomSpell[ irand(0, sizeof(RandomSpell)/sizeof(uint32) - 1) ]; - break; - } - case CLASS_HUNTER: // 40997,40999,41002,41005,41009,41011,41406,41409 - { - uint32 RandomSpell[]={40997,40999,41002,41005,41009,41011,41406,41409}; - triggered_spell_id = RandomSpell[ irand(0, sizeof(RandomSpell)/sizeof(uint32) - 1) ]; - break; - } - default: - return false; - } - - target = this; - if (roll_chance_i(10)) - ((Player*)this)->Say("This is Madness!", LANG_UNIVERSAL); - break; - } - /* - // TODO: need find item for aura and triggered spells - // Sunwell Exalted Caster Neck (??? neck) - // cast ??? Light's Wrath if Exalted by Aldor - // cast ??? Arcane Bolt if Exalted by Scryers*/ - case 46569: - return false; // disable for while - /* - { - if(GetTypeId() != TYPEID_PLAYER) - return false; - - // Get Aldor reputation rank - if (((Player *)this)->GetReputationRank(932) == REP_EXALTED) - { - target = this; - triggered_spell_id = ??? - break; - } - // Get Scryers reputation rank - if (((Player *)this)->GetReputationRank(934) == REP_EXALTED) - { - triggered_spell_id = ??? - break; - } - return false; - }/**/ - // Sunwell Exalted Caster Neck (Shattered Sun Pendant of Acumen neck) - // cast 45479 Light's Wrath if Exalted by Aldor - // cast 45429 Arcane Bolt if Exalted by Scryers - case 45481: - { - if(GetTypeId() != TYPEID_PLAYER) - return false; - - // Get Aldor reputation rank - if (((Player *)this)->GetReputationRank(932) == REP_EXALTED) - { - target = this; - triggered_spell_id = 45479; - break; - } - // Get Scryers reputation rank - if (((Player *)this)->GetReputationRank(934) == REP_EXALTED) - { - triggered_spell_id = 45429; - break; - } - return false; - } - // Sunwell Exalted Melee Neck (Shattered Sun Pendant of Might neck) - // cast 45480 Light's Strength if Exalted by Aldor - // cast 45428 Arcane Strike if Exalted by Scryers - case 45482: - { - if(GetTypeId() != TYPEID_PLAYER) - return false; - - // Get Aldor reputation rank - if (((Player *)this)->GetReputationRank(932) == REP_EXALTED) - { - target = this; - triggered_spell_id = 45480; - break; - } - // Get Scryers reputation rank - if (((Player *)this)->GetReputationRank(934) == REP_EXALTED) - { - triggered_spell_id = 45428; - break; - } - return false; - } - // Sunwell Exalted Tank Neck (Shattered Sun Pendant of Resolve neck) - // cast 45431 Arcane Insight if Exalted by Aldor - // cast 45432 Light's Ward if Exalted by Scryers - case 45483: - { - if(GetTypeId() != TYPEID_PLAYER) - return false; - - // Get Aldor reputation rank - if (((Player *)this)->GetReputationRank(932) == REP_EXALTED) - { - target = this; - triggered_spell_id = 45432; - break; - } - // Get Scryers reputation rank - if (((Player *)this)->GetReputationRank(934) == REP_EXALTED) - { - target = this; - triggered_spell_id = 45431; - break; - } - return false; - } - // Sunwell Exalted Healer Neck (Shattered Sun Pendant of Restoration neck) - // cast 45478 Light's Salvation if Exalted by Aldor - // cast 45430 Arcane Surge if Exalted by Scryers - case 45484: - { - if(GetTypeId() != TYPEID_PLAYER) - return false; - - // Get Aldor reputation rank - if (((Player *)this)->GetReputationRank(932) == REP_EXALTED) - { - target = this; - triggered_spell_id = 45478; - break; - } - // Get Scryers reputation rank - if (((Player *)this)->GetReputationRank(934) == REP_EXALTED) - { - triggered_spell_id = 45430; - break; - } - return false; - } - } - break; - } - case SPELLFAMILY_MAGE: - { - // Magic Absorption - if (dummySpell->SpellIconID == 459) // only this spell have SpellIconID == 459 and dummy aura - { - if (getPowerType() != POWER_MANA) - return false; - - // mana reward - basepoints0 = (triggeredByAura->GetModifier()->m_amount * GetMaxPower(POWER_MANA) / 100); - target = this; - triggered_spell_id = 29442; - break; - } - // Master of Elements - if (dummySpell->SpellIconID == 1920) - { - if(!procSpell) - return false; - - // mana cost save - basepoints0 = procSpell->manaCost * triggeredByAura->GetModifier()->m_amount/100; - if( basepoints0 <=0 ) - return false; - - target = this; - triggered_spell_id = 29077; - break; - } - switch(dummySpell->Id) - { - // Ignite - case 11119: - case 11120: - case 12846: - case 12847: - case 12848: - { - switch (dummySpell->Id) - { - case 11119: basepoints0 = int32(0.04f*damage); break; - case 11120: basepoints0 = int32(0.08f*damage); break; - case 12846: basepoints0 = int32(0.12f*damage); break; - case 12847: basepoints0 = int32(0.16f*damage); break; - case 12848: basepoints0 = int32(0.20f*damage); break; - default: - sLog.outError("Unit::HandleDummyAuraProc: non handled spell id: %u (IG)",dummySpell->Id); - return false; - } - - triggered_spell_id = 12654; - break; - } - // Combustion - case 11129: - { - //last charge and crit - if( triggeredByAura->m_procCharges <= 1 && (procFlag & PROC_FLAG_CRIT_SPELL) ) - { - RemoveAurasDueToSpell(28682); //-> remove Combustion auras - return true; // charge counting (will removed) - } - - CastSpell(this, 28682, true, castItem, triggeredByAura); - return(procFlag & PROC_FLAG_CRIT_SPELL);// charge update only at crit hits, no hidden cooldowns - } - } - break; - } - case SPELLFAMILY_WARRIOR: - { - // Retaliation - if(dummySpell->SpellFamilyFlags==0x0000000800000000LL) - { - // check attack comes not from behind - if (!HasInArc(M_PI, pVictim)) - return false; - - triggered_spell_id = 22858; - break; - } - break; - } - case SPELLFAMILY_WARLOCK: - { - // Seed of Corruption - if (dummySpell->SpellFamilyFlags & 0x0000001000000000LL) - { - Modifier* mod = triggeredByAura->GetModifier(); - // if damage is more than need or target die from damage deal finish spell - // FIX ME: not triggered currently at death - if( mod->m_amount <= damage || GetHealth() <= damage ) - { - // remember guid before aura delete - uint64 casterGuid = triggeredByAura->GetCasterGUID(); - - // Remove aura (before cast for prevent infinite loop handlers) - RemoveAurasDueToSpell(triggeredByAura->GetId()); - - // Cast finish spell (triggeredByAura already not exist!) - CastSpell(this, 27285, true, castItem, NULL, casterGuid); - return true; // no hidden cooldown - } - - // Damage counting - mod->m_amount-=damage; - return true; - } - // Seed of Corruption (Mobs cast) - no die req - if (dummySpell->SpellFamilyFlags == 0x00LL && dummySpell->SpellIconID == 1932) - { - Modifier* mod = triggeredByAura->GetModifier(); - // if damage is more than need deal finish spell - if( mod->m_amount <= damage ) - { - // remember guid before aura delete - uint64 casterGuid = triggeredByAura->GetCasterGUID(); - - // Remove aura (before cast for prevent infinite loop handlers) - RemoveAurasDueToSpell(triggeredByAura->GetId()); - - // Cast finish spell (triggeredByAura already not exist!) - CastSpell(this, 32865, true, castItem, NULL, casterGuid); - return true; // no hidden cooldown - } - // Damage counting - mod->m_amount-=damage; - return true; - } - switch(dummySpell->Id) - { - // Nightfall - case 18094: - case 18095: - { - target = this; - triggered_spell_id = 17941; - break; - } - //Soul Leech - case 30293: - case 30295: - case 30296: - { - // health - basepoints0 = int32(damage*triggeredByAura->GetModifier()->m_amount/100); - target = this; - triggered_spell_id = 30294; - break; - } - // Shadowflame (Voidheart Raiment set bonus) - case 37377: - { - triggered_spell_id = 37379; - break; - } - // Pet Healing (Corruptor Raiment or Rift Stalker Armor) - case 37381: - { - target = GetPet(); - if(!target) - return false; - - // heal amount - basepoints0 = damage * triggeredByAura->GetModifier()->m_amount/100; - triggered_spell_id = 37382; - break; - } - // Shadowflame Hellfire (Voidheart Raiment set bonus) - case 39437: - { - triggered_spell_id = 37378; - break; - } - } - break; - } - case SPELLFAMILY_PRIEST: - { - // Vampiric Touch - if( dummySpell->SpellFamilyFlags & 0x0000040000000000LL ) - { - if(!pVictim || !pVictim->isAlive()) - return false; - - // pVictim is caster of aura - if(triggeredByAura->GetCasterGUID() != pVictim->GetGUID()) - return false; - - // energize amount - basepoints0 = triggeredByAura->GetModifier()->m_amount*damage/100; - pVictim->CastCustomSpell(pVictim,34919,&basepoints0,NULL,NULL,true,castItem,triggeredByAura); - return true; // no hidden cooldown - } - switch(dummySpell->Id) - { - // Vampiric Embrace - case 15286: - { - if(!pVictim || !pVictim->isAlive()) - return false; - - // pVictim is caster of aura - if(triggeredByAura->GetCasterGUID() != pVictim->GetGUID()) - return false; - - // heal amount - basepoints0 = triggeredByAura->GetModifier()->m_amount*damage/100; - pVictim->CastCustomSpell(pVictim,15290,&basepoints0,NULL,NULL,true,castItem,triggeredByAura); - return true; // no hidden cooldown - } - // Priest Tier 6 Trinket (Ashtongue Talisman of Acumen) - case 40438: - { - // Shadow Word: Pain - if( procSpell->SpellFamilyFlags & 0x0000000000008000LL ) - triggered_spell_id = 40441; - // Renew - else if( procSpell->SpellFamilyFlags & 0x0000000000000010LL ) - triggered_spell_id = 40440; - else - return false; - - target = this; - break; - } - // Oracle Healing Bonus ("Garments of the Oracle" set) - case 26169: - { - // heal amount - basepoints0 = int32(damage * 10/100); - target = this; - triggered_spell_id = 26170; - break; - } - // Frozen Shadoweave (Shadow's Embrace set) warning! its not only priest set - case 39372: - { - if(!procSpell || (GetSpellSchoolMask(procSpell) & (SPELL_SCHOOL_MASK_FROST | SPELL_SCHOOL_MASK_SHADOW))==0 ) - return false; - - // heal amount - basepoints0 = int32(damage * 2 / 100); - target = this; - triggered_spell_id = 39373; - break; - } - // Vestments of Faith (Priest Tier 3) - 4 pieces bonus - case 28809: - { - triggered_spell_id = 28810; - break; - } - } - break; - } - case SPELLFAMILY_DRUID: - { - switch(dummySpell->Id) - { - // Healing Touch (Dreamwalker Raiment set) - case 28719: - { - // mana back - basepoints0 = int32(procSpell->manaCost * 30 / 100); - target = this; - triggered_spell_id = 28742; - break; - } - // Healing Touch Refund (Idol of Longevity trinket) - case 28847: - { - target = this; - triggered_spell_id = 28848; - break; - } - // Mana Restore (Malorne Raiment set / Malorne Regalia set) - case 37288: - case 37295: - { - target = this; - triggered_spell_id = 37238; - break; - } - // Druid Tier 6 Trinket - case 40442: - { - float chance; - - // Starfire - if( procSpell->SpellFamilyFlags & 0x0000000000000004LL ) - { - triggered_spell_id = 40445; - chance = 25.f; - } - // Rejuvenation - else if( procSpell->SpellFamilyFlags & 0x0000000000000010LL ) - { - triggered_spell_id = 40446; - chance = 25.f; - } - // Mangle (cat/bear) - else if( procSpell->SpellFamilyFlags & 0x0000044000000000LL ) - { - triggered_spell_id = 40452; - chance = 40.f; - } - else - return false; - - if (!roll_chance_f(chance)) - return false; - - target = this; - break; - } - // Maim Interrupt - case 44835: - { - // Deadly Interrupt Effect - triggered_spell_id = 32747; - break; - } - } - break; - } - case SPELLFAMILY_ROGUE: - { - switch(dummySpell->Id) - { - // Deadly Throw Interrupt - case 32748: - { - // Prevent cast Deadly Throw Interrupt on self from last effect (apply dummy) of Deadly Throw - if(this == pVictim) - return false; - - triggered_spell_id = 32747; - break; - } - } - // Quick Recovery - if( dummySpell->SpellIconID == 2116 ) - { - if(!procSpell) - return false; - - // only rogue's finishing moves (maybe need additional checks) - if( procSpell->SpellFamilyName!=SPELLFAMILY_ROGUE || - (procSpell->SpellFamilyFlags & SPELLFAMILYFLAG_ROGUE__FINISHING_MOVE) == 0) - return false; - - // energy cost save - basepoints0 = procSpell->manaCost * triggeredByAura->GetModifier()->m_amount/100; - if(basepoints0 <= 0) - return false; - - target = this; - triggered_spell_id = 31663; - break; - } - break; - } - case SPELLFAMILY_HUNTER: - { - // Thrill of the Hunt - if ( dummySpell->SpellIconID == 2236 ) - { - if(!procSpell) - return false; - - // mana cost save - basepoints0 = procSpell->manaCost * 40/100; - if(basepoints0 <= 0) - return false; - - target = this; - triggered_spell_id = 34720; - break; - } - break; - } - case SPELLFAMILY_PALADIN: - { - // Seal of Righteousness - melee proc dummy - if (dummySpell->SpellFamilyFlags&0x000000008000000LL && triggeredByAura->GetEffIndex()==0) - { - if(GetTypeId() != TYPEID_PLAYER) - return false; - - uint32 spellId; - switch (triggeredByAura->GetId()) - { - case 21084: spellId = 25742; break; // Rank 1 - case 20287: spellId = 25740; break; // Rank 2 - case 20288: spellId = 25739; break; // Rank 3 - case 20289: spellId = 25738; break; // Rank 4 - case 20290: spellId = 25737; break; // Rank 5 - case 20291: spellId = 25736; break; // Rank 6 - case 20292: spellId = 25735; break; // Rank 7 - case 20293: spellId = 25713; break; // Rank 8 - case 27155: spellId = 27156; break; // Rank 9 - default: - sLog.outError("Unit::HandleDummyAuraProc: non handled possibly SoR (Id = %u)", triggeredByAura->GetId()); - return false; - } - Item *item = ((Player*)this)->GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_MAINHAND); - float speed = (item ? item->GetProto()->Delay : BASE_ATTACK_TIME)/1000.0f; - - float damageBasePoints; - if(item && item->GetProto()->InventoryType == INVTYPE_2HWEAPON) - // two hand weapon - damageBasePoints=1.20f*triggeredByAura->GetModifier()->m_amount * 1.2f * 1.03f * speed/100.0f + 1; - else - // one hand weapon/no weapon - damageBasePoints=0.85f*ceil(triggeredByAura->GetModifier()->m_amount * 1.2f * 1.03f * speed/100.0f) - 1; - - int32 damagePoint = int32(damageBasePoints + 0.03f * (GetWeaponDamageRange(BASE_ATTACK,MINDAMAGE)+GetWeaponDamageRange(BASE_ATTACK,MAXDAMAGE))/2.0f) + 1; - - // apply damage bonuses manually - if(damagePoint >= 0) - damagePoint = SpellDamageBonus(pVictim, dummySpell, damagePoint, SPELL_DIRECT_DAMAGE); - - CastCustomSpell(pVictim,spellId,&damagePoint,NULL,NULL,true,NULL, triggeredByAura); - return true; // no hidden cooldown - } - // Seal of Blood do damage trigger - if(dummySpell->SpellFamilyFlags & 0x0000040000000000LL) - { - switch(triggeredByAura->GetEffIndex()) - { - case 0: - // prevent chain triggering - if(procSpell && procSpell->Id==31893 ) - return false; - - triggered_spell_id = 31893; - break; - case 1: - { - // damage - basepoints0 = triggeredByAura->GetModifier()->m_amount * damage / 100; - target = this; - triggered_spell_id = 32221; - break; - } - } - } - - switch(dummySpell->Id) - { - // Holy Power (Redemption Armor set) - case 28789: - { - if(!pVictim) - return false; - - // Set class defined buff - switch (pVictim->getClass()) - { - case CLASS_PALADIN: - case CLASS_PRIEST: - case CLASS_SHAMAN: - case CLASS_DRUID: - triggered_spell_id = 28795; // Increases the friendly target's mana regeneration by $s1 per 5 sec. for $d. - break; - case CLASS_MAGE: - case CLASS_WARLOCK: - triggered_spell_id = 28793; // Increases the friendly target's spell damage and healing by up to $s1 for $d. - break; - case CLASS_HUNTER: - case CLASS_ROGUE: - triggered_spell_id = 28791; // Increases the friendly target's attack power by $s1 for $d. - break; - case CLASS_WARRIOR: - triggered_spell_id = 28790; // Increases the friendly target's armor - break; - default: - return false; - } - break; - } - //Seal of Vengeance - case 31801: - { - if(effIndex != 0) // effect 1,2 used by seal unleashing code - return false; - - triggered_spell_id = 31803; - break; - } - // Spiritual Att. - case 31785: - case 33776: - { - // if healed by another unit (pVictim) - if(this == pVictim) - return false; - - // heal amount - basepoints0 = triggeredByAura->GetModifier()->m_amount*damage/100; - target = this; - triggered_spell_id = 31786; - break; - } - // Paladin Tier 6 Trinket (Ashtongue Talisman of Zeal) - case 40470: - { - if( !procSpell ) - return false; - - float chance; - - // Flash of light/Holy light - if( procSpell->SpellFamilyFlags & 0x00000000C0000000LL) - { - triggered_spell_id = 40471; - chance = 15.f; - } - // Judgement - else if( procSpell->SpellFamilyFlags & 0x0000000000800000LL ) - { - triggered_spell_id = 40472; - chance = 50.f; - } - else - return false; - - if (!roll_chance_f(chance)) - return false; - - break; - } - } - break; - } - case SPELLFAMILY_SHAMAN: - { - switch(dummySpell->Id) - { - // Totemic Power (The Earthshatterer set) - case 28823: - { - if( !pVictim ) - return false; - - // Set class defined buff - switch (pVictim->getClass()) - { - case CLASS_PALADIN: - case CLASS_PRIEST: - case CLASS_SHAMAN: - case CLASS_DRUID: - triggered_spell_id = 28824; // Increases the friendly target's mana regeneration by $s1 per 5 sec. for $d. - break; - case CLASS_MAGE: - case CLASS_WARLOCK: - triggered_spell_id = 28825; // Increases the friendly target's spell damage and healing by up to $s1 for $d. - break; - case CLASS_HUNTER: - case CLASS_ROGUE: - triggered_spell_id = 28826; // Increases the friendly target's attack power by $s1 for $d. - break; - case CLASS_WARRIOR: - triggered_spell_id = 28827; // Increases the friendly target's armor - break; - default: - return false; - } - break; - } - // Lesser Healing Wave (Totem of Flowing Water Relic) - case 28849: - { - target = this; - triggered_spell_id = 28850; - break; - } - // Windfury Weapon (Passive) 1-5 Ranks - case 33757: - { - if(GetTypeId()!=TYPEID_PLAYER) - return false; - - if(!castItem || !castItem->IsEquipped()) - return false; - - // custom cooldown processing case - if( cooldown && ((Player*)this)->HasSpellCooldown(dummySpell->Id)) - return false; - - uint32 spellId; - switch (castItem->GetEnchantmentId(EnchantmentSlot(TEMP_ENCHANTMENT_SLOT))) - { - case 283: spellId = 33757; break; //1 Rank - case 284: spellId = 33756; break; //2 Rank - case 525: spellId = 33755; break; //3 Rank - case 1669:spellId = 33754; break; //4 Rank - case 2636:spellId = 33727; break; //5 Rank - default: - { - sLog.outError("Unit::HandleDummyAuraProc: non handled item enchantment (rank?) %u for spell id: %u (Windfury)", - castItem->GetEnchantmentId(EnchantmentSlot(TEMP_ENCHANTMENT_SLOT)),dummySpell->Id); - return false; - } - } - - SpellEntry const* windfurySpellEntry = sSpellStore.LookupEntry(spellId); - if(!windfurySpellEntry) - { - sLog.outError("Unit::HandleDummyAuraProc: non existed spell id: %u (Windfury)",spellId); - return false; - } - - int32 extra_attack_power = CalculateSpellDamage(windfurySpellEntry,0,windfurySpellEntry->EffectBasePoints[0],pVictim); - - // Off-Hand case - if ( castItem->GetSlot() == EQUIPMENT_SLOT_OFFHAND ) - { - // Value gained from additional AP - basepoints0 = int32(extra_attack_power/14.0f * GetAttackTime(OFF_ATTACK)/1000/2); - triggered_spell_id = 33750; - } - // Main-Hand case - else - { - // Value gained from additional AP - basepoints0 = int32(extra_attack_power/14.0f * GetAttackTime(BASE_ATTACK)/1000); - triggered_spell_id = 25504; - } - - // apply cooldown before cast to prevent processing itself - if( cooldown ) - ((Player*)this)->AddSpellCooldown(dummySpell->Id,0,time(NULL) + cooldown); - - // Attack Twice - for ( uint32 i = 0; i<2; ++i ) - CastCustomSpell(pVictim,triggered_spell_id,&basepoints0,NULL,NULL,true,castItem,triggeredByAura); - - return true; - } - // Shaman Tier 6 Trinket - case 40463: - { - if( !procSpell ) - return false; - - float chance; - if (procSpell->SpellFamilyFlags & 0x0000000000000001LL) - { - triggered_spell_id = 40465; // Lightning Bolt - chance = 15.f; - } - else if (procSpell->SpellFamilyFlags & 0x0000000000000080LL) - { - triggered_spell_id = 40465; // Lesser Healing Wave - chance = 10.f; - } - else if (procSpell->SpellFamilyFlags & 0x0000001000000000LL) - { - triggered_spell_id = 40466; // Stormstrike - chance = 50.f; - } - else - return false; - - if (!roll_chance_f(chance)) - return false; - - target = this; - break; - } - } - - // Earth Shield - if(dummySpell->SpellFamilyFlags==0x40000000000LL) - { - if(GetTypeId() != TYPEID_PLAYER) - return false; - - // heal - basepoints0 = triggeredByAura->GetModifier()->m_amount; - target = this; - triggered_spell_id = 379; - break; - } - // Lightning Overload - if (dummySpell->SpellIconID == 2018) // only this spell have SpellFamily Shaman SpellIconID == 2018 and dummy aura - { - if(!procSpell || GetTypeId() != TYPEID_PLAYER || !pVictim ) - return false; - - // custom cooldown processing case - if( cooldown && GetTypeId()==TYPEID_PLAYER && ((Player*)this)->HasSpellCooldown(dummySpell->Id)) - return false; - - uint32 spellId = 0; - // Every Lightning Bolt and Chain Lightning spell have dublicate vs half damage and zero cost - switch (procSpell->Id) - { - // Lightning Bolt - case 403: spellId = 45284; break; // Rank 1 - case 529: spellId = 45286; break; // Rank 2 - case 548: spellId = 45287; break; // Rank 3 - case 915: spellId = 45288; break; // Rank 4 - case 943: spellId = 45289; break; // Rank 5 - case 6041: spellId = 45290; break; // Rank 6 - case 10391: spellId = 45291; break; // Rank 7 - case 10392: spellId = 45292; break; // Rank 8 - case 15207: spellId = 45293; break; // Rank 9 - case 15208: spellId = 45294; break; // Rank 10 - case 25448: spellId = 45295; break; // Rank 11 - case 25449: spellId = 45296; break; // Rank 12 - // Chain Lightning - case 421: spellId = 45297; break; // Rank 1 - case 930: spellId = 45298; break; // Rank 2 - case 2860: spellId = 45299; break; // Rank 3 - case 10605: spellId = 45300; break; // Rank 4 - case 25439: spellId = 45301; break; // Rank 5 - case 25442: spellId = 45302; break; // Rank 6 - default: - sLog.outError("Unit::HandleDummyAuraProc: non handled spell id: %u (LO)", procSpell->Id); - return false; - } - // No thread generated mod - SpellModifier *mod = new SpellModifier; - mod->op = SPELLMOD_THREAT; - mod->value = -100; - mod->type = SPELLMOD_PCT; - mod->spellId = dummySpell->Id; - mod->effectId = 0; - mod->lastAffected = NULL; - mod->mask = 0x0000000000000003LL; - mod->charges = 0; - ((Player*)this)->AddSpellMod(mod, true); - - // Remove cooldown (Chain Lightning - have Category Recovery time) - if (procSpell->SpellFamilyFlags & 0x0000000000000002LL) - ((Player*)this)->RemoveSpellCooldown(spellId); - - // Hmmm.. in most case spells alredy set half basepoints but... - // Lightning Bolt (2-10 rank) have full basepoint and half bonus from level - // As on wiki: - // BUG: Rank 2 to 10 (and maybe 11) of Lightning Bolt will proc another Bolt with FULL damage (not halved). This bug is known and will probably be fixed soon. - // So - no add changes :) - CastSpell(pVictim, spellId, true, castItem, triggeredByAura); - - ((Player*)this)->AddSpellMod(mod, false); - - if( cooldown && GetTypeId()==TYPEID_PLAYER ) - ((Player*)this)->AddSpellCooldown(dummySpell->Id,0,time(NULL) + cooldown); - - return true; - } - break; - } - default: - break; - } - - // processed charge only counting case - if(!triggered_spell_id) - return true; - - SpellEntry const* triggerEntry = sSpellStore.LookupEntry(triggered_spell_id); - - if(!triggerEntry) - { - sLog.outError("Unit::HandleDummyAuraProc: Spell %u have not existed triggered spell %u",dummySpell->Id,triggered_spell_id); - return false; - } - - // default case - if(!target || target!=this && !target->isAlive()) - return false; - - if( cooldown && GetTypeId()==TYPEID_PLAYER && ((Player*)this)->HasSpellCooldown(triggered_spell_id)) - return false; - - if(basepoints0) - CastCustomSpell(target,triggered_spell_id,&basepoints0,NULL,NULL,true,castItem,triggeredByAura); - else - CastSpell(target,triggered_spell_id,true,castItem,triggeredByAura); - - if( cooldown && GetTypeId()==TYPEID_PLAYER ) - ((Player*)this)->AddSpellCooldown(triggered_spell_id,0,time(NULL) + cooldown); - - return true; -} - -bool Unit::HandleProcTriggerSpell(Unit *pVictim, uint32 damage, Aura* triggeredByAura, SpellEntry const *procSpell, uint32 procFlags,WeaponAttackType attackType, uint32 cooldown) -{ - SpellEntry const* auraSpellInfo = triggeredByAura->GetSpellProto(); - - Item* castItem = triggeredByAura->GetCastItemGUID() && GetTypeId()==TYPEID_PLAYER - ? ((Player*)this)->GetItemByGuid(triggeredByAura->GetCastItemGUID()) : NULL; - - uint32 triggered_spell_id = auraSpellInfo->EffectTriggerSpell[triggeredByAura->GetEffIndex()]; - Unit* target = !(procFlags & PROC_FLAG_HEAL) && IsPositiveSpell(triggered_spell_id) ? this : pVictim; - int32 basepoints0 = 0; - - switch(auraSpellInfo->SpellFamilyName) - { - case SPELLFAMILY_GENERIC: - { - switch(auraSpellInfo->Id) - { - // Aegis of Preservation - case 23780: - //Aegis Heal (instead non-existed triggered spell) - triggered_spell_id = 23781; - target = this; - break; - // Elune's Touch (moonkin mana restore) - case 24905: - { - // Elune's Touch (instead non-existed triggered spell) - triggered_spell_id = 33926; - basepoints0 = int32(0.3f * GetTotalAttackPowerValue(BASE_ATTACK)); - target = this; - break; - } - // Enlightenment - case 29601: - { - // only for cast with mana price - if(!procSpell || procSpell->powerType!=POWER_MANA || procSpell->manaCost==0 && procSpell->ManaCostPercentage==0 && procSpell->manaCostPerlevel==0) - return false; - break; // fall through to normal cast - } - // Health Restore - case 33510: - { - // at melee hit call std triggered spell - if(procFlags & PROC_FLAG_HIT_MELEE) - break; // fall through to normal cast - - // Mark of Conquest - else (at range hit) called custom case - triggered_spell_id = 39557; - target = this; - break; - } - // Shaleskin - case 36576: - return true; // nothing to do - // Forgotten Knowledge (Blade of Wizardry) - case 38319: - // only for harmful enemy targeted spell - if(!pVictim || pVictim==this || !procSpell || IsPositiveSpell(procSpell->Id)) - return false; - break; // fall through to normal cast - // Aura of Wrath (Darkmoon Card: Wrath trinket bonus) - case 39442: - { - // proc only at non-crit hits - if(procFlags & (PROC_FLAG_CRIT_MELEE|PROC_FLAG_CRIT_RANGED|PROC_FLAG_CRIT_SPELL)) - return false; - break; // fall through to normal cast - } - // Augment Pain (Timbal's Focusing Crystal trinket bonus) - case 45054: - { - if(!procSpell) - return false; - - //only periodic damage can trigger spell - bool found = false; - for(int j = 0; j < 3; ++j) - { - if( procSpell->EffectApplyAuraName[j]==SPELL_AURA_PERIODIC_DAMAGE || - procSpell->EffectApplyAuraName[j]==SPELL_AURA_PERIODIC_DAMAGE_PERCENT || - procSpell->EffectApplyAuraName[j]==SPELL_AURA_PERIODIC_LEECH ) - { - found = true; - break; - } - } - if(!found) - return false; - - break; // fall through to normal cast - } - // Evasive Maneuvers (Commendation of Kael'thas) - case 45057: - { - // damage taken that reduces below 35% health - // does NOT mean you must have been >= 35% before - if (int32(GetHealth())-int32(damage) >= int32(GetMaxHealth()*0.35f)) - return false; - break; // fall through to normal cast - } - } - - switch(triggered_spell_id) - { - // Setup - case 15250: - { - // applied only for main target - if(!pVictim || pVictim != getVictim()) - return false; - - // continue normal case - break; - } - // Shamanistic Rage triggered spell - case 30824: - basepoints0 = int32(GetTotalAttackPowerValue(BASE_ATTACK)*triggeredByAura->GetModifier()->m_amount/100); - break; - } - break; - } - case SPELLFAMILY_MAGE: - { - switch(auraSpellInfo->SpellIconID) - { - // Blazing Speed - case 2127: - //Blazing Speed (instead non-existed triggered spell) - triggered_spell_id = 31643; - target = this; - break; - } - switch(auraSpellInfo->Id) - { - // Persistent Shield (Scarab Brooch) - case 26467: - basepoints0 = int32(damage * 0.15f); - break; - } - break; - } - case SPELLFAMILY_WARRIOR: - { - //Rampage - if((auraSpellInfo->SpellFamilyFlags & 0x100000) && auraSpellInfo->SpellIconID==2006) - { - //all ranks have effect[0]==AURA (Proc Trigger Spell, non-existed) - //and effect[1]==TriggerSpell - if(auraSpellInfo->Effect[1]!=SPELL_EFFECT_TRIGGER_SPELL) - { - sLog.outError("Unit::HandleProcTriggerSpell: Spell %u have wrong effect in RM",triggeredByAura->GetSpellProto()->Id); - return false; - } - triggered_spell_id = auraSpellInfo->EffectTriggerSpell[1]; - break; // fall through to normal cast - } - break; - } - case SPELLFAMILY_WARLOCK: - { - // Pyroclasm - if(auraSpellInfo->SpellFamilyFlags == 0x0000000000000000 && auraSpellInfo->SpellIconID==1137) - { - // last case for Hellfire that damage caster also but don't must stun caster - if( pVictim == this ) - return false; - - // custom chnace - float chance = 0; - switch (triggeredByAura->GetId()) - { - case 18096: chance = 13.0f; break; - case 18073: chance = 26.0f; break; - } - if (!roll_chance_f(chance)) - return false; - - // Pyroclasm (instead non-existed triggered spell) - triggered_spell_id = 18093; - target = pVictim; - break; - } - // Drain Soul - if(auraSpellInfo->SpellFamilyFlags & 0x0000000000004000) - { - bool found = false; - Unit::AuraList const& mAddFlatModifier = GetAurasByType(SPELL_AURA_ADD_FLAT_MODIFIER); - for(Unit::AuraList::const_iterator i = mAddFlatModifier.begin(); i != mAddFlatModifier.end(); ++i) - { - //Improved Drain Soul - if ((*i)->GetModifier()->m_miscvalue == SPELLMOD_CHANCE_OF_SUCCESS && (*i)->GetSpellProto()->SpellIconID == 113) - { - int32 value2 = CalculateSpellDamage((*i)->GetSpellProto(),2,(*i)->GetSpellProto()->EffectBasePoints[2],this); - basepoints0 = value2 * GetMaxPower(POWER_MANA) / 100; - - // Drain Soul - triggered_spell_id = 18371; - target = this; - found = true; - break; - } - } - if(!found) - return false; - break; // fall through to normal cast - } - break; - } - case SPELLFAMILY_PRIEST: - { - //Blessed Recovery - if(auraSpellInfo->SpellFamilyFlags == 0x00000000LL && auraSpellInfo->SpellIconID==1875) - { - switch (triggeredByAura->GetSpellProto()->Id) - { - case 27811: triggered_spell_id = 27813; break; - case 27815: triggered_spell_id = 27817; break; - case 27816: triggered_spell_id = 27818; break; - default: - sLog.outError("Unit::HandleProcTriggerSpell: Spell %u not handled in BR",triggeredByAura->GetSpellProto()->Id); - return false; - } - - int32 heal_amount = damage * triggeredByAura->GetModifier()->m_amount / 100; - basepoints0 = heal_amount/3; - target = this; - break; - } - // Shadowguard - if((auraSpellInfo->SpellFamilyFlags & 0x80000000LL) && auraSpellInfo->SpellVisual==7958) - { - switch(triggeredByAura->GetSpellProto()->Id) - { - case 18137: - triggered_spell_id = 28377; break; // Rank 1 - case 19308: - triggered_spell_id = 28378; break; // Rank 2 - case 19309: - triggered_spell_id = 28379; break; // Rank 3 - case 19310: - triggered_spell_id = 28380; break; // Rank 4 - case 19311: - triggered_spell_id = 28381; break; // Rank 5 - case 19312: - triggered_spell_id = 28382; break; // Rank 6 - case 25477: - triggered_spell_id = 28385; break; // Rank 7 - default: - sLog.outError("Unit::HandleProcTriggerSpell: Spell %u not handled in SG",triggeredByAura->GetSpellProto()->Id); - return false; - } - target = pVictim; - break; - } - break; - } - case SPELLFAMILY_DRUID: - { - switch(auraSpellInfo->Id) - { - // Leader of the Pack (triggering Improved Leader of the Pack heal) - case 24932: - { - if (triggeredByAura->GetModifier()->m_amount == 0) - return false; - basepoints0 = triggeredByAura->GetModifier()->m_amount * GetMaxHealth() / 100; - triggered_spell_id = 34299; - break; - }; - // Druid Forms Trinket (Druid Tier5 Trinket, triggers different spells per Form) - case 37336: - { - switch(m_form) - { - case FORM_BEAR: - case FORM_DIREBEAR: - triggered_spell_id=37340; break;// Ursine Blessing - case FORM_CAT: - triggered_spell_id=37341; break;// Feline Blessing - case FORM_TREE: - triggered_spell_id=37342; break;// Slyvan Blessing - case FORM_MOONKIN: - triggered_spell_id=37343; break;// Lunar Blessing - case FORM_NONE: - triggered_spell_id=37344; break;// Cenarion Blessing (for caster form, except FORM_MOONKIN) - default: - return false; - } - - target = this; - break; - } - } - break; - } - case SPELLFAMILY_ROGUE: - { - if(auraSpellInfo->SpellFamilyFlags == 0x0000000000000000LL) - { - switch(auraSpellInfo->SpellIconID) - { - // Combat Potency - case 2260: - { - // skip non offhand attacks - if(attackType!=OFF_ATTACK) - return false; - break; // fall through to normal cast - } - } - } - break; - } - case SPELLFAMILY_PALADIN: - { - if(auraSpellInfo->SpellFamilyFlags == 0x00000000LL) - { - switch(auraSpellInfo->Id) - { - // Lightning Capacitor - case 37657: - { - // trinket ProcTriggerSpell but for safe checks for player - if(!castItem || !pVictim || !pVictim->isAlive() || GetTypeId()!=TYPEID_PLAYER) - return false; - - if(((Player*)this)->HasSpellCooldown(37657)) - return false; - - // stacking - CastSpell(this, 37658, true, castItem, triggeredByAura); - // 2.5s cooldown before it can stack again, current system allow 1 sec step in cooldown - ((Player*)this)->AddSpellCooldown(37657,0,time(NULL)+(roll_chance_i(50) ? 2 : 3)); - - // counting - uint32 count = 0; - AuraList const& dummyAura = GetAurasByType(SPELL_AURA_DUMMY); - for(AuraList::const_iterator itr = dummyAura.begin(); itr != dummyAura.end(); ++itr) - if((*itr)->GetId()==37658) - ++count; - - // release at 3 aura in stack - if(count <= 2) - return true; // main triggered spell casted anyway - - RemoveAurasDueToSpell(37658); - CastSpell(pVictim, 37661, true, castItem, triggeredByAura); - return true; - } - // Healing Discount - case 37705: - // Healing Trance (instead non-existed triggered spell) - triggered_spell_id = 37706; - target = this; - break; - // HoTs on Heals (Fel Reaver's Piston trinket) - case 38299: - { - // at direct heal effect - if(!procSpell || !IsSpellHaveEffect(procSpell,SPELL_EFFECT_HEAL)) - return false; - - // single proc at time - AuraList const& scAuras = GetSingleCastAuras(); - for(AuraList::const_iterator itr = scAuras.begin(); itr != scAuras.end(); ++itr) - if((*itr)->GetId()==triggered_spell_id) - return false; - - // positive cast at victim instead self - target = pVictim; - break; - } - } - switch(auraSpellInfo->SpellIconID) - { - case 241: - { - switch(auraSpellInfo->EffectTriggerSpell[0]) - { - //Illumination - case 18350: - { - if(!procSpell) - return false; - - // procspell is triggered spell but we need mana cost of original casted spell - uint32 originalSpellId = procSpell->Id; - - // Holy Shock - if(procSpell->SpellFamilyName == SPELLFAMILY_PALADIN) - { - if(procSpell->SpellFamilyFlags & 0x0001000000000000LL) - { - switch(procSpell->Id) - { - case 25914: originalSpellId = 20473; break; - case 25913: originalSpellId = 20929; break; - case 25903: originalSpellId = 20930; break; - case 27175: originalSpellId = 27174; break; - case 33074: originalSpellId = 33072; break; - default: - sLog.outError("Unit::HandleProcTriggerSpell: Spell %u not handled in HShock",procSpell->Id); - return false; - } - } - } - - SpellEntry const *originalSpell = sSpellStore.LookupEntry(originalSpellId); - if(!originalSpell) - { - sLog.outError("Unit::HandleProcTriggerSpell: Spell %u unknown but selected as original in Illu",originalSpellId); - return false; - } - - // percent stored in effect 1 (class scripts) base points - int32 percent = auraSpellInfo->EffectBasePoints[1]+1; - - basepoints0 = originalSpell->manaCost*percent/100; - triggered_spell_id = 20272; - target = this; - break; - } - } - break; - } - } - } - if(auraSpellInfo->SpellFamilyFlags & 0x00080000) - { - switch(auraSpellInfo->SpellIconID) - { - //Judgement of Wisdom (overwrite non existing triggered spell call in spell.dbc - case 206: - { - if(!pVictim || !pVictim->isAlive()) - return false; - - uint32 spell = 0; - switch(triggeredByAura->GetSpellProto()->Id) - { - case 20186: - triggered_spell_id = 20268; // Rank 1 - break; - case 20354: - triggered_spell_id = 20352; // Rank 2 - break; - case 20355: - triggered_spell_id = 20353; // Rank 3 - break; - case 27164: - triggered_spell_id = 27165; // Rank 4 - break; - default: - sLog.outError("Unit::HandleProcTriggerSpell: Spell %u not handled in JoW",triggeredByAura->GetSpellProto()->Id); - return false; - } - - pVictim->CastSpell(pVictim,triggered_spell_id,true,castItem,triggeredByAura,GetGUID()); - return true; // no hidden cooldown - } - //Judgement of Light - case 299: - { - if(!pVictim || !pVictim->isAlive()) - return false; - - // overwrite non existing triggered spell call in spell.dbc - uint32 spell = 0; - switch(triggeredByAura->GetSpellProto()->Id) - { - case 20185: - triggered_spell_id = 20267; // Rank 1 - break; - case 20344: - triggered_spell_id = 20341; // Rank 2 - break; - case 20345: - triggered_spell_id = 20342; // Rank 3 - break; - case 20346: - triggered_spell_id = 20343; // Rank 4 - break; - case 27162: - triggered_spell_id = 27163; // Rank 5 - break; - default: - sLog.outError("Unit::HandleProcTriggerSpell: Spell %u not handled in JoL",triggeredByAura->GetSpellProto()->Id); - return false; - } - pVictim->CastSpell(pVictim,triggered_spell_id,true,castItem,triggeredByAura,GetGUID()); - return true; // no hidden cooldown - } - } - } - // custom check for proc spell - switch(auraSpellInfo->Id) - { - // Bonus Healing (item spell) - case 40971: - { - if(!pVictim || !pVictim->isAlive()) - return false; - - // bonus if health < 50% - if(pVictim->GetHealth() >= pVictim->GetMaxHealth()*triggeredByAura->GetModifier()->m_amount/100) - return false; - - // cast at target positive spell - target = pVictim; - break; - } - } - switch(triggered_spell_id) - { - // Seal of Command - case 20424: - // prevent chain of triggered spell from same triggered spell - if(procSpell && procSpell->Id==20424) - return false; - break; - } - break; - } - case SPELLFAMILY_SHAMAN: - { - if(auraSpellInfo->SpellFamilyFlags == 0x0000000000000000) - { - switch(auraSpellInfo->SpellIconID) - { - case 19: - { - switch(auraSpellInfo->Id) - { - case 23551: // Lightning Shield - Tier2: 8 pieces proc shield - { - // Lightning Shield (overwrite non existing triggered spell call in spell.dbc) - triggered_spell_id = 23552; - target = pVictim; - break; - } - case 23552: // Lightning Shield - trigger shield damage - { - // Lightning Shield (overwrite non existing triggered spell call in spell.dbc) - triggered_spell_id = 27635; - target = pVictim; - break; - } - } - break; - } - // Mana Surge (Shaman T1 bonus) - case 87: - { - if(!procSpell) - return false; - - basepoints0 = procSpell->manaCost * 35/100; - triggered_spell_id = 23571; - target = this; - break; - } - //Nature's Guardian - case 2013: - { - if(GetTypeId()!=TYPEID_PLAYER) - return false; - - // damage taken that reduces below 30% health - // does NOT mean you must have been >= 30% before - if (10*(int32(GetHealth())-int32(damage)) >= 3*GetMaxHealth()) - return false; - - triggered_spell_id = 31616; - - // need check cooldown now - if( cooldown && ((Player*)this)->HasSpellCooldown(triggered_spell_id)) - return false; - - basepoints0 = triggeredByAura->GetModifier()->m_amount * GetMaxHealth() / 100; - target = this; - if(pVictim && pVictim->isAlive()) - pVictim->getThreatManager().modifyThreatPercent(this,-10); - break; - } - } - } - - // Water Shield (we can't set cooldown for main spell - it's player casted spell - if((auraSpellInfo->SpellFamilyFlags & 0x0000002000000000LL) && auraSpellInfo->SpellVisual==7358) - { - target = this; - break; - } - - // Lightning Shield - if((auraSpellInfo->SpellFamilyFlags & 0x00000400) && auraSpellInfo->SpellVisual==37) - { - // overwrite non existing triggered spell call in spell.dbc - switch(triggeredByAura->GetSpellProto()->Id) - { - case 324: - triggered_spell_id = 26364; break; // Rank 1 - case 325: - triggered_spell_id = 26365; break; // Rank 2 - case 905: - triggered_spell_id = 26366; break; // Rank 3 - case 945: - triggered_spell_id = 26367; break; // Rank 4 - case 8134: - triggered_spell_id = 26369; break; // Rank 5 - case 10431: - triggered_spell_id = 26370; break; // Rank 6 - case 10432: - triggered_spell_id = 26363; break; // Rank 7 - case 25469: - triggered_spell_id = 26371; break; // Rank 8 - case 25472: - triggered_spell_id = 26372; break; // Rank 9 - default: - sLog.outError("Unit::HandleProcTriggerSpell: Spell %u not handled in LShield",triggeredByAura->GetSpellProto()->Id); - return false; - } - - target = pVictim; - break; - } - break; - } - } - - // standard non-dummy case - if(!triggered_spell_id) - { - sLog.outError("Unit::HandleProcTriggerSpell: Spell %u have 0 in EffectTriggered[%d], not handled custom case?",auraSpellInfo->Id,triggeredByAura->GetEffIndex()); - return false; - } - - SpellEntry const* triggerEntry = sSpellStore.LookupEntry(triggered_spell_id); - - if(!triggerEntry) - { - sLog.outError("Unit::HandleProcTriggerSpell: Spell %u have not existed EffectTriggered[%d]=%u, not handled custom case?",auraSpellInfo->Id,triggeredByAura->GetEffIndex(),triggered_spell_id); - return false; - } - - // not allow proc extra attack spell at extra attack - if( m_extraAttacks && IsSpellHaveEffect(triggerEntry,SPELL_EFFECT_ADD_EXTRA_ATTACKS) ) - return false; - - if( cooldown && GetTypeId()==TYPEID_PLAYER && ((Player*)this)->HasSpellCooldown(triggered_spell_id)) - return false; - - // default case - if(!target || target!=this && !target->isAlive()) - return false; - - if(basepoints0) - CastCustomSpell(target,triggered_spell_id,&basepoints0,NULL,NULL,true,castItem,triggeredByAura); - else - CastSpell(target,triggered_spell_id,true,castItem,triggeredByAura); - - if( cooldown && GetTypeId()==TYPEID_PLAYER ) - ((Player*)this)->AddSpellCooldown(triggered_spell_id,0,time(NULL) + cooldown); - - return true; -} - -bool Unit::HandleOverrideClassScriptAuraProc(Unit *pVictim, int32 scriptId, uint32 damage, Aura *triggeredByAura, SpellEntry const *procSpell, uint32 cooldown) -{ - if(!pVictim || !pVictim->isAlive()) - return false; - - Item* castItem = triggeredByAura->GetCastItemGUID() && GetTypeId()==TYPEID_PLAYER - ? ((Player*)this)->GetItemByGuid(triggeredByAura->GetCastItemGUID()) : NULL; - - uint32 triggered_spell_id = 0; - - switch(scriptId) - { - case 836: // Improved Blizzard (Rank 1) - { - if( !procSpell || procSpell->SpellVisual!=9487 ) - return false; - triggered_spell_id = 12484; - break; - } - case 988: // Improved Blizzard (Rank 2) - { - if( !procSpell || procSpell->SpellVisual!=9487 ) - return false; - triggered_spell_id = 12485; - break; - } - case 989: // Improved Blizzard (Rank 3) - { - if( !procSpell || procSpell->SpellVisual!=9487 ) - return false; - triggered_spell_id = 12486; - break; - } - case 4086: // Improved Mend Pet (Rank 1) - case 4087: // Improved Mend Pet (Rank 2) - { - int32 chance = triggeredByAura->GetSpellProto()->EffectBasePoints[triggeredByAura->GetEffIndex()]; - if(!roll_chance_i(chance)) - return false; - - triggered_spell_id = 24406; - break; - } - case 4533: // Dreamwalker Raiment 2 pieces bonus - { - // Chance 50% - if (!roll_chance_i(50)) - return false; - - switch (pVictim->getPowerType()) - { - case POWER_MANA: triggered_spell_id = 28722; break; - case POWER_RAGE: triggered_spell_id = 28723; break; - case POWER_ENERGY: triggered_spell_id = 28724; break; - default: - return false; - } - break; - } - case 4537: // Dreamwalker Raiment 6 pieces bonus - triggered_spell_id = 28750; // Blessing of the Claw - break; - case 5497: // Improved Mana Gems (Serpent-Coil Braid) - triggered_spell_id = 37445; // Mana Surge - break; - } - - // not processed - if(!triggered_spell_id) - return false; - - // standard non-dummy case - SpellEntry const* triggerEntry = sSpellStore.LookupEntry(triggered_spell_id); - - if(!triggerEntry) - { - sLog.outError("Unit::HandleOverrideClassScriptAuraProc: Spell %u triggering for class script id %u",triggered_spell_id,scriptId); - return false; - } - - if( cooldown && GetTypeId()==TYPEID_PLAYER && ((Player*)this)->HasSpellCooldown(triggered_spell_id)) - return false; - - CastSpell(pVictim, triggered_spell_id, true, castItem, triggeredByAura); - - if( cooldown && GetTypeId()==TYPEID_PLAYER ) - ((Player*)this)->AddSpellCooldown(triggered_spell_id,0,time(NULL) + cooldown); - - return true; -} - -void Unit::setPowerType(Powers new_powertype) -{ - SetByteValue(UNIT_FIELD_BYTES_0, 3, new_powertype); - - if(GetTypeId() == TYPEID_PLAYER) - { - if(((Player*)this)->GetGroup()) - ((Player*)this)->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_POWER_TYPE); - } - else if(((Creature*)this)->isPet()) - { - Pet *pet = ((Pet*)this); - if(pet->isControlled()) - { - Unit *owner = GetOwner(); - if(owner && (owner->GetTypeId() == TYPEID_PLAYER) && ((Player*)owner)->GetGroup()) - ((Player*)owner)->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_PET_POWER_TYPE); - } - } - - switch(new_powertype) - { - default: - case POWER_MANA: - break; - case POWER_RAGE: - SetMaxPower(POWER_RAGE,GetCreatePowers(POWER_RAGE)); - SetPower( POWER_RAGE,0); - break; - case POWER_FOCUS: - SetMaxPower(POWER_FOCUS,GetCreatePowers(POWER_FOCUS)); - SetPower( POWER_FOCUS,GetCreatePowers(POWER_FOCUS)); - break; - case POWER_ENERGY: - SetMaxPower(POWER_ENERGY,GetCreatePowers(POWER_ENERGY)); - SetPower( POWER_ENERGY,0); - break; - case POWER_HAPPINESS: - SetMaxPower(POWER_HAPPINESS,GetCreatePowers(POWER_HAPPINESS)); - SetPower(POWER_HAPPINESS,GetCreatePowers(POWER_HAPPINESS)); - break; - } -} - -FactionTemplateEntry const* Unit::getFactionTemplateEntry() const -{ - FactionTemplateEntry const* entry = sFactionTemplateStore.LookupEntry(getFaction()); - if(!entry) - { - static uint64 guid = 0; // prevent repeating spam same faction problem - - if(GetGUID() != guid) - { - if(GetTypeId() == TYPEID_PLAYER) - sLog.outError("Player %s have invalid faction (faction template id) #%u", ((Player*)this)->GetName(), getFaction()); - else - sLog.outError("Creature (template id: %u) have invalid faction (faction template id) #%u", ((Creature*)this)->GetCreatureInfo()->Entry, getFaction()); - guid = GetGUID(); - } - } - return entry; -} - -bool Unit::IsHostileTo(Unit const* unit) const -{ - // always non-hostile to self - if(unit==this) - return false; - - // always non-hostile to GM in GM mode - if(unit->GetTypeId()==TYPEID_PLAYER && ((Player const*)unit)->isGameMaster()) - return false; - - // always hostile to enemy - if(getVictim()==unit || unit->getVictim()==this) - return true; - - // test pet/charm masters instead pers/charmeds - Unit const* testerOwner = GetCharmerOrOwner(); - Unit const* targetOwner = unit->GetCharmerOrOwner(); - - // always hostile to owner's enemy - if(testerOwner && (testerOwner->getVictim()==unit || unit->getVictim()==testerOwner)) - return true; - - // always hostile to enemy owner - if(targetOwner && (getVictim()==targetOwner || targetOwner->getVictim()==this)) - return true; - - // always hostile to owner of owner's enemy - if(testerOwner && targetOwner && (testerOwner->getVictim()==targetOwner || targetOwner->getVictim()==testerOwner)) - return true; - - Unit const* tester = testerOwner ? testerOwner : this; - Unit const* target = targetOwner ? targetOwner : unit; - - // always non-hostile to target with common owner, or to owner/pet - if(tester==target) - return false; - - // special cases (Duel, etc) - if(tester->GetTypeId()==TYPEID_PLAYER && target->GetTypeId()==TYPEID_PLAYER) - { - Player const* pTester = (Player const*)tester; - Player const* pTarget = (Player const*)target; - - // Duel - if(pTester->duel && pTester->duel->opponent == pTarget && pTester->duel->startTime != 0) - return true; - - // Group - if(pTester->GetGroup() && pTester->GetGroup()==pTarget->GetGroup()) - return false; - - // Sanctuary - if(pTarget->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_SANCTUARY) && pTester->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_SANCTUARY)) - return false; - - // PvP FFA state - if(pTester->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_FFA_PVP) && pTarget->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_FFA_PVP)) - return true; - - //= PvP states - // Green/Blue (can't attack) - if(pTester->GetTeam()==pTarget->GetTeam()) - return false; - - // Red (can attack) if true, Blue/Yellow (can't attack) in another case - return pTester->IsPvP() && pTarget->IsPvP(); - } - - // faction base cases - FactionTemplateEntry const*tester_faction = tester->getFactionTemplateEntry(); - FactionTemplateEntry const*target_faction = target->getFactionTemplateEntry(); - if(!tester_faction || !target_faction) - return false; - - if(target->isAttackingPlayer() && tester->IsContestedGuard()) - return true; - - // PvC forced reaction and reputation case - if(tester->GetTypeId()==TYPEID_PLAYER) - { - // forced reaction - ForcedReactions::const_iterator forceItr = ((Player*)tester)->m_forcedReactions.find(target_faction->faction); - if(forceItr!=((Player*)tester)->m_forcedReactions.end()) - return forceItr->second <= REP_HOSTILE; - - // if faction have reputation then hostile state for tester at 100% dependent from at_war state - if(FactionEntry const* raw_target_faction = sFactionStore.LookupEntry(target_faction->faction)) - if(raw_target_faction->reputationListID >=0) - if(FactionState const* factionState = ((Player*)tester)->GetFactionState(raw_target_faction)) - return (factionState->Flags & FACTION_FLAG_AT_WAR); - } - // CvP forced reaction and reputation case - else if(target->GetTypeId()==TYPEID_PLAYER) - { - // forced reaction - ForcedReactions::const_iterator forceItr = ((Player const*)target)->m_forcedReactions.find(tester_faction->faction); - if(forceItr!=((Player const*)target)->m_forcedReactions.end()) - return forceItr->second <= REP_HOSTILE; - - // apply reputation state - FactionEntry const* raw_tester_faction = sFactionStore.LookupEntry(tester_faction->faction); - if(raw_tester_faction && raw_tester_faction->reputationListID >=0 ) - return ((Player const*)target)->GetReputationRank(raw_tester_faction) <= REP_HOSTILE; - } - - // common faction based case (CvC,PvC,CvP) - return tester_faction->IsHostileTo(*target_faction); -} - -bool Unit::IsFriendlyTo(Unit const* unit) const -{ - // always friendly to self - if(unit==this) - return true; - - // always friendly to GM in GM mode - if(unit->GetTypeId()==TYPEID_PLAYER && ((Player const*)unit)->isGameMaster()) - return true; - - // always non-friendly to enemy - if(getVictim()==unit || unit->getVictim()==this) - return false; - - // test pet/charm masters instead pers/charmeds - Unit const* testerOwner = GetCharmerOrOwner(); - Unit const* targetOwner = unit->GetCharmerOrOwner(); - - // always non-friendly to owner's enemy - if(testerOwner && (testerOwner->getVictim()==unit || unit->getVictim()==testerOwner)) - return false; - - // always non-friendly to enemy owner - if(targetOwner && (getVictim()==targetOwner || targetOwner->getVictim()==this)) - return false; - - // always non-friendly to owner of owner's enemy - if(testerOwner && targetOwner && (testerOwner->getVictim()==targetOwner || targetOwner->getVictim()==testerOwner)) - return false; - - Unit const* tester = testerOwner ? testerOwner : this; - Unit const* target = targetOwner ? targetOwner : unit; - - // always friendly to target with common owner, or to owner/pet - if(tester==target) - return true; - - // special cases (Duel) - if(tester->GetTypeId()==TYPEID_PLAYER && target->GetTypeId()==TYPEID_PLAYER) - { - Player const* pTester = (Player const*)tester; - Player const* pTarget = (Player const*)target; - - // Duel - if(pTester->duel && pTester->duel->opponent == target && pTester->duel->startTime != 0) - return false; - - // Group - if(pTester->GetGroup() && pTester->GetGroup()==pTarget->GetGroup()) - return true; - - // Sanctuary - if(pTarget->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_SANCTUARY) && pTester->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_SANCTUARY)) - return true; - - // PvP FFA state - if(pTester->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_FFA_PVP) && pTarget->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_FFA_PVP)) - return false; - - //= PvP states - // Green/Blue (non-attackable) - if(pTester->GetTeam()==pTarget->GetTeam()) - return true; - - // Blue (friendly/non-attackable) if not PVP, or Yellow/Red in another case (attackable) - return !pTarget->IsPvP(); - } - - // faction base cases - FactionTemplateEntry const*tester_faction = tester->getFactionTemplateEntry(); - FactionTemplateEntry const*target_faction = target->getFactionTemplateEntry(); - if(!tester_faction || !target_faction) - return false; - - if(target->isAttackingPlayer() && tester->IsContestedGuard()) - return false; - - // PvC forced reaction and reputation case - if(tester->GetTypeId()==TYPEID_PLAYER) - { - // forced reaction - ForcedReactions::const_iterator forceItr = ((Player const*)tester)->m_forcedReactions.find(target_faction->faction); - if(forceItr!=((Player const*)tester)->m_forcedReactions.end()) - return forceItr->second >= REP_FRIENDLY; - - // if faction have reputation then friendly state for tester at 100% dependent from at_war state - if(FactionEntry const* raw_target_faction = sFactionStore.LookupEntry(target_faction->faction)) - if(raw_target_faction->reputationListID >=0) - if(FactionState const* FactionState = ((Player*)tester)->GetFactionState(raw_target_faction)) - return !(FactionState->Flags & FACTION_FLAG_AT_WAR); - } - // CvP forced reaction and reputation case - else if(target->GetTypeId()==TYPEID_PLAYER) - { - // forced reaction - ForcedReactions::const_iterator forceItr = ((Player const*)target)->m_forcedReactions.find(tester_faction->faction); - if(forceItr!=((Player const*)target)->m_forcedReactions.end()) - return forceItr->second >= REP_FRIENDLY; - - // apply reputation state - if(FactionEntry const* raw_tester_faction = sFactionStore.LookupEntry(tester_faction->faction)) - if(raw_tester_faction->reputationListID >=0 ) - return ((Player const*)target)->GetReputationRank(raw_tester_faction) >= REP_FRIENDLY; - } - - // common faction based case (CvC,PvC,CvP) - return tester_faction->IsFriendlyTo(*target_faction); -} - -bool Unit::IsHostileToPlayers() const -{ - FactionTemplateEntry const* my_faction = getFactionTemplateEntry(); - if(!my_faction) - return false; - - FactionEntry const* raw_faction = sFactionStore.LookupEntry(my_faction->faction); - if(raw_faction && raw_faction->reputationListID >=0 ) - return false; - - return my_faction->IsHostileToPlayers(); -} - -bool Unit::IsNeutralToAll() const -{ - FactionTemplateEntry const* my_faction = getFactionTemplateEntry(); - if(!my_faction) - return true; - - FactionEntry const* raw_faction = sFactionStore.LookupEntry(my_faction->faction); - if(raw_faction && raw_faction->reputationListID >=0 ) - return false; - - return my_faction->IsNeutralToAll(); -} - -bool Unit::Attack(Unit *victim, bool meleeAttack) -{ - if(!victim || victim == this) - return false; - - // dead units can neither attack nor be attacked - if(!isAlive() || !victim->isAlive()) - return false; - - // player cannot attack in mount state - if(GetTypeId()==TYPEID_PLAYER && IsMounted()) - return false; - - // nobody can attack GM in GM-mode - if(victim->GetTypeId()==TYPEID_PLAYER) - { - if(((Player*)victim)->isGameMaster()) - return false; - } - else - { - if(((Creature*)victim)->IsInEvadeMode()) - return false; - } - - // remove SPELL_AURA_MOD_UNATTACKABLE at attack (in case non-interruptible spells stun aura applied also that not let attack) - if(HasAuraType(SPELL_AURA_MOD_UNATTACKABLE)) - RemoveSpellsCausingAura(SPELL_AURA_MOD_UNATTACKABLE); - - if (m_attacking) - { - if (m_attacking == victim) - { - // switch to melee attack from ranged/magic - if( meleeAttack && !hasUnitState(UNIT_STAT_MELEE_ATTACKING) ) - { - addUnitState(UNIT_STAT_MELEE_ATTACKING); - SendAttackStart(victim); - return true; - } - return false; - } - AttackStop(); - } - - //Set our target - SetUInt64Value(UNIT_FIELD_TARGET, victim->GetGUID()); - - if(meleeAttack) - addUnitState(UNIT_STAT_MELEE_ATTACKING); - m_attacking = victim; - m_attacking->_addAttacker(this); - - if(m_attacking->GetTypeId()==TYPEID_UNIT && ((Creature*)m_attacking)->AI()) - ((Creature*)m_attacking)->AI()->AttackedBy(this); - - if(GetTypeId()==TYPEID_UNIT) - { - WorldPacket data(SMSG_AI_REACTION, 12); - data << GetGUID(); - data << uint32(AI_REACTION_AGGRO); // Aggro sound - ((WorldObject*)this)->SendMessageToSet(&data, true); - - ((Creature*)this)->CallAssistence(); - ((Creature*)this)->SetCombatStartPosition(GetPositionX(), GetPositionY(), GetPositionZ()); - } - - // delay offhand weapon attack to next attack time - if(haveOffhandWeapon()) - resetAttackTimer(OFF_ATTACK); - - if(meleeAttack) - SendAttackStart(victim); - - return true; -} - -bool Unit::AttackStop() -{ - if (!m_attacking) - return false; - - Unit* victim = m_attacking; - - m_attacking->_removeAttacker(this); - m_attacking = NULL; - - //Clear our target - SetUInt64Value(UNIT_FIELD_TARGET, 0); - - clearUnitState(UNIT_STAT_MELEE_ATTACKING); - - InterruptSpell(CURRENT_MELEE_SPELL); - - if( GetTypeId()==TYPEID_UNIT ) - { - // reset call assistance - ((Creature*)this)->SetNoCallAssistence(false); - } - - SendAttackStop(victim); - - return true; -} - -void Unit::CombatStop(bool cast) -{ - if(cast& IsNonMeleeSpellCasted(false)) - InterruptNonMeleeSpells(false); - - AttackStop(); - RemoveAllAttackers(); - if( GetTypeId()==TYPEID_PLAYER ) - ((Player*)this)->SendAttackSwingCancelAttack(); // melee and ranged forced attack cancel - ClearInCombat(); -} - -void Unit::CombatStopWithPets(bool cast) -{ - CombatStop(cast); - if(Pet* pet = GetPet()) - pet->CombatStop(cast); - if(Unit* charm = GetCharm()) - charm->CombatStop(cast); - if(GetTypeId()==TYPEID_PLAYER) - { - GuardianPetList const& guardians = ((Player*)this)->GetGuardians(); - for(GuardianPetList::const_iterator itr = guardians.begin(); itr != guardians.end(); ++itr) - if(Unit* guardian = Unit::GetUnit(*this,*itr)) - guardian->CombatStop(cast); - } -} - -bool Unit::isAttackingPlayer() const -{ - if(hasUnitState(UNIT_STAT_ATTACK_PLAYER)) - return true; - - Pet* pet = GetPet(); - if(pet && pet->isAttackingPlayer()) - return true; - - Unit* charmed = GetCharm(); - if(charmed && charmed->isAttackingPlayer()) - return true; - - for (int8 i = 0; i < MAX_TOTEM; i++) - { - if(m_TotemSlot[i]) - { - Creature *totem = ObjectAccessor::GetCreature(*this, m_TotemSlot[i]); - if(totem && totem->isAttackingPlayer()) - return true; - } - } - - return false; -} - -void Unit::RemoveAllAttackers() -{ - while (!m_attackers.empty()) - { - AttackerSet::iterator iter = m_attackers.begin(); - if(!(*iter)->AttackStop()) - { - sLog.outError("WORLD: Unit has an attacker that isnt attacking it!"); - m_attackers.erase(iter); - } - } -} - -void Unit::ModifyAuraState(AuraState flag, bool apply) -{ - if (apply) - { - if (!HasFlag(UNIT_FIELD_AURASTATE, 1<<(flag-1))) - { - SetFlag(UNIT_FIELD_AURASTATE, 1<<(flag-1)); - if(GetTypeId() == TYPEID_PLAYER) - { - const PlayerSpellMap& sp_list = ((Player*)this)->GetSpellMap(); - for (PlayerSpellMap::const_iterator itr = sp_list.begin(); itr != sp_list.end(); ++itr) - { - if(itr->second->state == PLAYERSPELL_REMOVED) continue; - SpellEntry const *spellInfo = sSpellStore.LookupEntry(itr->first); - if (!spellInfo || !IsPassiveSpell(itr->first)) continue; - if (spellInfo->CasterAuraState == flag) - CastSpell(this, itr->first, true, NULL); - } - } - } - } - else - { - if (HasFlag(UNIT_FIELD_AURASTATE,1<<(flag-1))) - { - RemoveFlag(UNIT_FIELD_AURASTATE, 1<<(flag-1)); - Unit::AuraMap& tAuras = GetAuras(); - for (Unit::AuraMap::iterator itr = tAuras.begin(); itr != tAuras.end();) - { - SpellEntry const* spellProto = (*itr).second->GetSpellProto(); - if (spellProto->CasterAuraState == flag) - { - // exceptions (applied at state but not removed at state change) - // Rampage - if(spellProto->SpellIconID==2006 && spellProto->SpellFamilyName==SPELLFAMILY_WARRIOR && spellProto->SpellFamilyFlags==0x100000) - { - ++itr; - continue; - } - - RemoveAura(itr); - } - else - ++itr; - } - } - } -} - -Unit *Unit::GetOwner() const -{ - uint64 ownerid = GetOwnerGUID(); - if(!ownerid) - return NULL; - return ObjectAccessor::GetUnit(*this, ownerid); -} - -Unit *Unit::GetCharmer() const -{ - if(uint64 charmerid = GetCharmerGUID()) - return ObjectAccessor::GetUnit(*this, charmerid); - return NULL; -} - -Player* Unit::GetCharmerOrOwnerPlayerOrPlayerItself() -{ - uint64 guid = GetCharmerOrOwnerGUID(); - if(IS_PLAYER_GUID(guid)) - return ObjectAccessor::GetPlayer(*this, guid); - - return GetTypeId()==TYPEID_PLAYER ? (Player*)this : NULL; -} - -Pet* Unit::GetPet() const -{ - if(uint64 pet_guid = GetPetGUID()) - { - if(Pet* pet = ObjectAccessor::GetPet(pet_guid)) - return pet; - - sLog.outError("Unit::GetPet: Pet %u not exist.",GUID_LOPART(pet_guid)); - const_cast(this)->SetPet(0); - } - - return NULL; -} - -Unit* Unit::GetCharm() const -{ - if(uint64 charm_guid = GetCharmGUID()) - { - if(Unit* pet = ObjectAccessor::GetUnit(*this, charm_guid)) - return pet; - - sLog.outError("Unit::GetCharm: Charmed creature %u not exist.",GUID_LOPART(charm_guid)); - const_cast(this)->SetCharm(0); - } - - return NULL; -} - -void Unit::SetPet(Pet* pet) -{ - SetUInt64Value(UNIT_FIELD_SUMMON,pet ? pet->GetGUID() : 0); - - // FIXME: hack, speed must be set only at follow - if(pet) - for(int i = 0; i < MAX_MOVE_TYPE; ++i) - pet->SetSpeed(UnitMoveType(i),m_speed_rate[i],true); -} - -void Unit::SetCharm(Unit* charmed) -{ - SetUInt64Value(UNIT_FIELD_CHARM,charmed ? charmed->GetGUID() : 0); -} - -void Unit::UnsummonAllTotems() -{ - for (int8 i = 0; i < MAX_TOTEM; ++i) - { - if(!m_TotemSlot[i]) - continue; - - Creature *OldTotem = ObjectAccessor::GetCreature(*this, m_TotemSlot[i]); - if (OldTotem && OldTotem->isTotem()) - ((Totem*)OldTotem)->UnSummon(); - } -} - -void Unit::SendHealSpellLog(Unit *pVictim, uint32 SpellID, uint32 Damage, bool critical) -{ - // we guess size - WorldPacket data(SMSG_SPELLHEALLOG, (8+8+4+4+1)); - data.append(pVictim->GetPackGUID()); - data.append(GetPackGUID()); - data << uint32(SpellID); - data << uint32(Damage); - data << uint8(critical ? 1 : 0); - data << uint8(0); // unused in client? - SendMessageToSet(&data, true); -} - -void Unit::SendEnergizeSpellLog(Unit *pVictim, uint32 SpellID, uint32 Damage, Powers powertype, bool critical) -{ - WorldPacket data(SMSG_SPELLENERGIZELOG, (8+8+4+4+4+1)); - data.append(pVictim->GetPackGUID()); - data.append(GetPackGUID()); - data << uint32(SpellID); - data << uint32(powertype); - data << uint32(Damage); - //data << uint8(critical ? 1 : 0); // removed in 2.4.0 - SendMessageToSet(&data, true); -} - -uint32 Unit::SpellDamageBonus(Unit *pVictim, SpellEntry const *spellProto, uint32 pdamage, DamageEffectType damagetype) -{ - if(!spellProto || !pVictim || damagetype==DIRECT_DAMAGE ) - return pdamage; - - int32 BonusDamage = 0; - if( GetTypeId()==TYPEID_UNIT ) - { - // Pets just add their bonus damage to their spell damage - // note that their spell damage is just gain of their own auras - if (((Creature*)this)->isPet()) - { - BonusDamage = ((Pet*)this)->GetBonusDamage(); - } - // For totems get damage bonus from owner (statue isn't totem in fact) - else if (((Creature*)this)->isTotem() && ((Totem*)this)->GetTotemType()!=TOTEM_STATUE) - { - if(Unit* owner = GetOwner()) - return owner->SpellDamageBonus(pVictim, spellProto, pdamage, damagetype); - } - } - - // Damage Done - uint32 CastingTime = !IsChanneledSpell(spellProto) ? GetSpellCastTime(spellProto) : GetSpellDuration(spellProto); - - // Taken/Done fixed damage bonus auras - int32 DoneAdvertisedBenefit = SpellBaseDamageBonus(GetSpellSchoolMask(spellProto))+BonusDamage; - int32 TakenAdvertisedBenefit = SpellBaseDamageBonusForVictim(GetSpellSchoolMask(spellProto), pVictim); - - // Damage over Time spells bonus calculation - float DotFactor = 1.0f; - if(damagetype == DOT) - { - int32 DotDuration = GetSpellDuration(spellProto); - // 200% limit - if(DotDuration > 0) - { - if(DotDuration > 30000) DotDuration = 30000; - if(!IsChanneledSpell(spellProto)) DotFactor = DotDuration / 15000.0f; - int x = 0; - for(int j = 0; j < 3; j++) - { - if( spellProto->Effect[j] == SPELL_EFFECT_APPLY_AURA && ( - spellProto->EffectApplyAuraName[j] == SPELL_AURA_PERIODIC_DAMAGE || - spellProto->EffectApplyAuraName[j] == SPELL_AURA_PERIODIC_LEECH) ) - { - x = j; - break; - } - } - int DotTicks = 6; - if(spellProto->EffectAmplitude[x] != 0) - DotTicks = DotDuration / spellProto->EffectAmplitude[x]; - if(DotTicks) - { - DoneAdvertisedBenefit /= DotTicks; - TakenAdvertisedBenefit /= DotTicks; - } - } - } - - // Taken/Done total percent damage auras - float DoneTotalMod = 1.0f; - float TakenTotalMod = 1.0f; - - // ..done - AuraList const& mModDamagePercentDone = GetAurasByType(SPELL_AURA_MOD_DAMAGE_PERCENT_DONE); - for(AuraList::const_iterator i = mModDamagePercentDone.begin(); i != mModDamagePercentDone.end(); ++i) - { - if( ((*i)->GetModifier()->m_miscvalue & GetSpellSchoolMask(spellProto)) && - (*i)->GetSpellProto()->EquippedItemClass == -1 && - // -1 == any item class (not wand then) - (*i)->GetSpellProto()->EquippedItemInventoryTypeMask == 0 ) - // 0 == any inventory type (not wand then) - { - DoneTotalMod *= ((*i)->GetModifier()->m_amount+100.0f)/100.0f; - } - } - - uint32 creatureTypeMask = pVictim->GetCreatureTypeMask(); - AuraList const& mDamageDoneVersus = GetAurasByType(SPELL_AURA_MOD_DAMAGE_DONE_VERSUS); - for(AuraList::const_iterator i = mDamageDoneVersus.begin();i != mDamageDoneVersus.end(); ++i) - if(creatureTypeMask & uint32((*i)->GetModifier()->m_miscvalue)) - DoneTotalMod *= ((*i)->GetModifier()->m_amount+100.0f)/100.0f; - - // ..taken - AuraList const& mModDamagePercentTaken = pVictim->GetAurasByType(SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN); - for(AuraList::const_iterator i = mModDamagePercentTaken.begin(); i != mModDamagePercentTaken.end(); ++i) - if( (*i)->GetModifier()->m_miscvalue & GetSpellSchoolMask(spellProto) ) - TakenTotalMod *= ((*i)->GetModifier()->m_amount+100.0f)/100.0f; - - // .. taken pct: scripted (increases damage of * against targets *) - AuraList const& mOverrideClassScript = GetAurasByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS); - for(AuraList::const_iterator i = mOverrideClassScript.begin(); i != mOverrideClassScript.end(); ++i) - { - switch((*i)->GetModifier()->m_miscvalue) - { - //Molten Fury - case 4920: case 4919: - if(pVictim->HasAuraState(AURA_STATE_HEALTHLESS_20_PERCENT)) - TakenTotalMod *= (100.0f+(*i)->GetModifier()->m_amount)/100.0f; break; - } - } - // .. taken pct: dummy auras - AuraList const& mDummyAuras = pVictim->GetAurasByType(SPELL_AURA_DUMMY); - for(AuraList::const_iterator i = mDummyAuras.begin(); i != mDummyAuras.end(); ++i) - { - switch((*i)->GetSpellProto()->SpellIconID) - { - //Cheat Death - case 2109: - if( ((*i)->GetModifier()->m_miscvalue & GetSpellSchoolMask(spellProto)) ) - { - if(pVictim->GetTypeId() != TYPEID_PLAYER) - continue; - float mod = -((Player*)pVictim)->GetRatingBonusValue(CR_CRIT_TAKEN_SPELL)*2*4; - if (mod < (*i)->GetModifier()->m_amount) - mod = (*i)->GetModifier()->m_amount; - TakenTotalMod *= (mod+100.0f)/100.0f; - } - break; - //Mangle - case 2312: - for(int j=0;j<3;j++) - { - if(GetEffectMechanic(spellProto, j)==MECHANIC_BLEED) - { - TakenTotalMod *= (100.0f+(*i)->GetModifier()->m_amount)/100.0f; - break; - } - } - break; - } - } - - // Distribute Damage over multiple effects, reduce by AoE - CastingTime = GetCastingTimeForBonus( spellProto, damagetype, CastingTime ); - - // 50% for damage and healing spells for leech spells from damage bonus and 0% from healing - for(int j = 0; j < 3; ++j) - { - if( spellProto->Effect[j] == SPELL_EFFECT_HEALTH_LEECH || - spellProto->Effect[j] == SPELL_EFFECT_APPLY_AURA && spellProto->EffectApplyAuraName[j] == SPELL_AURA_PERIODIC_LEECH ) - { - CastingTime /= 2; - break; - } - } - - switch(spellProto->SpellFamilyName) - { - case SPELLFAMILY_MAGE: - // Ignite - do not modify, it is (8*Rank)% damage of procing Spell - if(spellProto->Id==12654) - { - return pdamage; - } - // Ice Lance - else if((spellProto->SpellFamilyFlags & 0x20000LL) && spellProto->SpellIconID == 186) - { - CastingTime /= 3; // applied 1/3 bonuses in case generic target - if(pVictim->isFrozen()) // and compensate this for frozen target. - TakenTotalMod *= 3.0f; - } - // Pyroblast - 115% of Fire Damage, DoT - 20% of Fire Damage - else if((spellProto->SpellFamilyFlags & 0x400000LL) && spellProto->SpellIconID == 184 ) - { - DotFactor = damagetype == DOT ? 0.2f : 1.0f; - CastingTime = damagetype == DOT ? 3500 : 4025; - } - // Fireball - 100% of Fire Damage, DoT - 0% of Fire Damage - else if((spellProto->SpellFamilyFlags & 0x1LL) && spellProto->SpellIconID == 185) - { - CastingTime = 3500; - DotFactor = damagetype == DOT ? 0.0f : 1.0f; - } - // Molten armor - else if (spellProto->SpellFamilyFlags & 0x0000000800000000LL) - { - CastingTime = 0; - } - // Arcane Missiles triggered spell - else if ((spellProto->SpellFamilyFlags & 0x200000LL) && spellProto->SpellIconID == 225) - { - CastingTime = 1000; - } - // Blizzard triggered spell - else if ((spellProto->SpellFamilyFlags & 0x80080LL) && spellProto->SpellIconID == 285) - { - CastingTime = 500; - } - break; - case SPELLFAMILY_WARLOCK: - // Life Tap - if((spellProto->SpellFamilyFlags & 0x40000LL) && spellProto->SpellIconID == 208) - { - CastingTime = 2800; // 80% from +shadow damage - DoneTotalMod = 1.0f; - TakenTotalMod = 1.0f; - } - // Dark Pact - else if((spellProto->SpellFamilyFlags & 0x80000000LL) && spellProto->SpellIconID == 154 && GetPetGUID()) - { - CastingTime = 3360; // 96% from +shadow damage - DoneTotalMod = 1.0f; - TakenTotalMod = 1.0f; - } - // Soul Fire - 115% of Fire Damage - else if((spellProto->SpellFamilyFlags & 0x8000000000LL) && spellProto->SpellIconID == 184) - { - CastingTime = 4025; - } - // Curse of Agony - 120% of Shadow Damage - else if((spellProto->SpellFamilyFlags & 0x0000000400LL) && spellProto->SpellIconID == 544) - { - DotFactor = 1.2f; - } - // Drain Mana - 0% of Shadow Damage - else if((spellProto->SpellFamilyFlags & 0x10LL) && spellProto->SpellIconID == 548) - { - CastingTime = 0; - } - // Drain Soul 214.3% - else if ((spellProto->SpellFamilyFlags & 0x4000LL) && spellProto->SpellIconID == 113 ) - { - CastingTime = 7500; - } - // Hellfire - else if ((spellProto->SpellFamilyFlags & 0x40LL) && spellProto->SpellIconID == 937) - { - CastingTime = damagetype == DOT ? 5000 : 500; // self damage seems to be so - } - // Unstable Affliction - 180% - else if (spellProto->Id == 31117 && spellProto->SpellIconID == 232) - { - CastingTime = 6300; - } - // Corruption 93% - else if ((spellProto->SpellFamilyFlags & 0x2LL) && spellProto->SpellIconID == 313) - { - DotFactor = 0.93f; - } - break; - case SPELLFAMILY_PALADIN: - // Consecration - 95% of Holy Damage - if((spellProto->SpellFamilyFlags & 0x20LL) && spellProto->SpellIconID == 51) - { - DotFactor = 0.95f; - CastingTime = 3500; - } - // Seal of Righteousness - 10.2%/9.8% ( based on weapon type ) of Holy Damage, multiplied by weapon speed - else if((spellProto->SpellFamilyFlags & 0x8000000LL) && spellProto->SpellIconID == 25) - { - Item *item = ((Player*)this)->GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_MAINHAND); - float wspeed = GetAttackTime(BASE_ATTACK)/1000.0f; - - if( item && item->GetProto()->InventoryType == INVTYPE_2HWEAPON) - CastingTime = uint32(wspeed*3500*0.102f); - else - CastingTime = uint32(wspeed*3500*0.098f); - } - // Judgement of Righteousness - 73% - else if ((spellProto->SpellFamilyFlags & 1024) && spellProto->SpellIconID == 25) - { - CastingTime = 2555; - } - // Seal of Vengeance - 17% per Fully Stacked Tick - 5 Applications - else if ((spellProto->SpellFamilyFlags & 0x80000000000LL) && spellProto->SpellIconID == 2292) - { - DotFactor = 0.17f; - CastingTime = 3500; - } - // Holy shield - 5% of Holy Damage - else if ((spellProto->SpellFamilyFlags & 0x4000000000LL) && spellProto->SpellIconID == 453) - { - CastingTime = 175; - } - // Blessing of Sanctuary - 0% - else if ((spellProto->SpellFamilyFlags & 0x10000000LL) && spellProto->SpellIconID == 29) - { - CastingTime = 0; - } - // Seal of Righteousness trigger - already computed for parent spell - else if ( spellProto->SpellFamilyName==SPELLFAMILY_PALADIN && spellProto->SpellIconID==25 && spellProto->AttributesEx4 & 0x00800000LL ) - { - return pdamage; - } - break; - case SPELLFAMILY_SHAMAN: - // totem attack - if (spellProto->SpellFamilyFlags & 0x000040000000LL) - { - if (spellProto->SpellIconID == 33) // Fire Nova totem attack must be 21.4%(untested) - CastingTime = 749; // ignore CastingTime and use as modifier - else if (spellProto->SpellIconID == 680) // Searing Totem attack 8% - CastingTime = 280; // ignore CastingTime and use as modifier - else if (spellProto->SpellIconID == 37) // Magma totem attack must be 6.67%(untested) - CastingTime = 234; // ignore CastingTimePenalty and use as modifier - } - // Lightning Shield (and proc shield from T2 8 pieces bonus ) 33% per charge - else if( (spellProto->SpellFamilyFlags & 0x00000000400LL) || spellProto->Id == 23552) - CastingTime = 1155; // ignore CastingTimePenalty and use as modifier - break; - case SPELLFAMILY_PRIEST: - // Mana Burn - 0% of Shadow Damage - if((spellProto->SpellFamilyFlags & 0x10LL) && spellProto->SpellIconID == 212) - { - CastingTime = 0; - } - // Mind Flay - 59% of Shadow Damage - else if((spellProto->SpellFamilyFlags & 0x800000LL) && spellProto->SpellIconID == 548) - { - CastingTime = 2065; - } - // Holy Fire - 86.71%, DoT - 16.5% - else if ((spellProto->SpellFamilyFlags & 0x100000LL) && spellProto->SpellIconID == 156) - { - DotFactor = damagetype == DOT ? 0.165f : 1.0f; - CastingTime = damagetype == DOT ? 3500 : 3035; - } - // Shadowguard - 28% per charge - else if ((spellProto->SpellFamilyFlags & 0x2000000LL) && spellProto->SpellIconID == 19) - { - CastingTime = 980; - } - // Touch of Weakeness - 10% - else if ((spellProto->SpellFamilyFlags & 0x80000LL) && spellProto->SpellIconID == 1591) - { - CastingTime = 350; - } - // Reflective Shield (back damage) - 0% (other spells fit to check not have damage effects/auras) - else if (spellProto->SpellFamilyFlags == 0 && spellProto->SpellIconID == 566) - { - CastingTime = 0; - } - // Holy Nova - 14% - else if ((spellProto->SpellFamilyFlags & 0x400000LL) && spellProto->SpellIconID == 1874) - { - CastingTime = 500; - } - break; - case SPELLFAMILY_DRUID: - // Hurricane triggered spell - if((spellProto->SpellFamilyFlags & 0x400000LL) && spellProto->SpellIconID == 220) - { - CastingTime = 500; - } - break; - case SPELLFAMILY_WARRIOR: - case SPELLFAMILY_HUNTER: - case SPELLFAMILY_ROGUE: - CastingTime = 0; - break; - default: - break; - } - - float LvlPenalty = CalculateLevelPenalty(spellProto); - - // Spellmod SpellDamage - float SpellModSpellDamage = 100.0f; - - if(Player* modOwner = GetSpellModOwner()) - modOwner->ApplySpellMod(spellProto->Id,SPELLMOD_SPELL_BONUS_DAMAGE,SpellModSpellDamage); - - SpellModSpellDamage /= 100.0f; - - float DoneActualBenefit = DoneAdvertisedBenefit * (CastingTime / 3500.0f) * DotFactor * SpellModSpellDamage * LvlPenalty; - float TakenActualBenefit = TakenAdvertisedBenefit * (CastingTime / 3500.0f) * DotFactor * LvlPenalty; - - float tmpDamage = (float(pdamage)+DoneActualBenefit)*DoneTotalMod; - - // Add flat bonus from spell damage versus - tmpDamage += GetTotalAuraModifierByMiscMask(SPELL_AURA_MOD_FLAT_SPELL_DAMAGE_VERSUS, creatureTypeMask); - - // apply spellmod to Done damage - if(Player* modOwner = GetSpellModOwner()) - modOwner->ApplySpellMod(spellProto->Id, damagetype == DOT ? SPELLMOD_DOT : SPELLMOD_DAMAGE, tmpDamage); - - tmpDamage = (tmpDamage+TakenActualBenefit)*TakenTotalMod; - - if( GetTypeId() == TYPEID_UNIT && !((Creature*)this)->isPet() ) - tmpDamage *= ((Creature*)this)->GetSpellDamageMod(((Creature*)this)->GetCreatureInfo()->rank); - - return tmpDamage > 0 ? uint32(tmpDamage) : 0; -} - -int32 Unit::SpellBaseDamageBonus(SpellSchoolMask schoolMask) -{ - int32 DoneAdvertisedBenefit = 0; - - // ..done - AuraList const& mDamageDone = GetAurasByType(SPELL_AURA_MOD_DAMAGE_DONE); - for(AuraList::const_iterator i = mDamageDone.begin();i != mDamageDone.end(); ++i) - if(((*i)->GetModifier()->m_miscvalue & schoolMask) != 0 && - (*i)->GetSpellProto()->EquippedItemClass == -1 && - // -1 == any item class (not wand then) - (*i)->GetSpellProto()->EquippedItemInventoryTypeMask == 0 ) - // 0 == any inventory type (not wand then) - DoneAdvertisedBenefit += (*i)->GetModifier()->m_amount; - - if (GetTypeId() == TYPEID_PLAYER) - { - // Damage bonus from stats - AuraList const& mDamageDoneOfStatPercent = GetAurasByType(SPELL_AURA_MOD_SPELL_DAMAGE_OF_STAT_PERCENT); - for(AuraList::const_iterator i = mDamageDoneOfStatPercent.begin();i != mDamageDoneOfStatPercent.end(); ++i) - { - if((*i)->GetModifier()->m_miscvalue & schoolMask) - { - SpellEntry const* iSpellProto = (*i)->GetSpellProto(); - uint8 eff = (*i)->GetEffIndex(); - - // stat used dependent from next effect aura SPELL_AURA_MOD_SPELL_HEALING presence and misc value (stat index) - Stats usedStat = STAT_INTELLECT; - if(eff < 2 && iSpellProto->EffectApplyAuraName[eff+1]==SPELL_AURA_MOD_SPELL_HEALING_OF_STAT_PERCENT) - usedStat = Stats(iSpellProto->EffectMiscValue[eff+1]); - - DoneAdvertisedBenefit += int32(GetStat(usedStat) * (*i)->GetModifier()->m_amount / 100.0f); - } - } - // ... and attack power - AuraList const& mDamageDonebyAP = GetAurasByType(SPELL_AURA_MOD_SPELL_DAMAGE_OF_ATTACK_POWER); - for(AuraList::const_iterator i =mDamageDonebyAP.begin();i != mDamageDonebyAP.end(); ++i) - if ((*i)->GetModifier()->m_miscvalue & schoolMask) - DoneAdvertisedBenefit += int32(GetTotalAttackPowerValue(BASE_ATTACK) * (*i)->GetModifier()->m_amount / 100.0f); - - } - return DoneAdvertisedBenefit; -} - -int32 Unit::SpellBaseDamageBonusForVictim(SpellSchoolMask schoolMask, Unit *pVictim) -{ - uint32 creatureTypeMask = pVictim->GetCreatureTypeMask(); - - int32 TakenAdvertisedBenefit = 0; - // ..done (for creature type by mask) in taken - AuraList const& mDamageDoneCreature = GetAurasByType(SPELL_AURA_MOD_DAMAGE_DONE_CREATURE); - for(AuraList::const_iterator i = mDamageDoneCreature.begin();i != mDamageDoneCreature.end(); ++i) - if(creatureTypeMask & uint32((*i)->GetModifier()->m_miscvalue)) - TakenAdvertisedBenefit += (*i)->GetModifier()->m_amount; - - // ..taken - AuraList const& mDamageTaken = pVictim->GetAurasByType(SPELL_AURA_MOD_DAMAGE_TAKEN); - for(AuraList::const_iterator i = mDamageTaken.begin();i != mDamageTaken.end(); ++i) - if(((*i)->GetModifier()->m_miscvalue & schoolMask) != 0) - TakenAdvertisedBenefit += (*i)->GetModifier()->m_amount; - - return TakenAdvertisedBenefit; -} - -bool Unit::isSpellCrit(Unit *pVictim, SpellEntry const *spellProto, SpellSchoolMask schoolMask, WeaponAttackType attackType) -{ - // not criting spell - if((spellProto->AttributesEx2 & SPELL_ATTR_EX2_CANT_CRIT)) - return false; - - float crit_chance = 0.0f; - switch(spellProto->DmgClass) - { - case SPELL_DAMAGE_CLASS_NONE: - return false; - case SPELL_DAMAGE_CLASS_MAGIC: - { - if (schoolMask & SPELL_SCHOOL_MASK_NORMAL) - crit_chance = 0.0f; - // For other schools - else if (GetTypeId() == TYPEID_PLAYER) - crit_chance = GetFloatValue( PLAYER_SPELL_CRIT_PERCENTAGE1 + GetFirstSchoolInMask(schoolMask)); - else - { - crit_chance = m_baseSpellCritChance; - crit_chance += GetTotalAuraModifierByMiscMask(SPELL_AURA_MOD_SPELL_CRIT_CHANCE_SCHOOL, schoolMask); - } - // taken - if (pVictim && !IsPositiveSpell(spellProto->Id)) - { - // Modify critical chance by victim SPELL_AURA_MOD_ATTACKER_SPELL_CRIT_CHANCE - crit_chance += pVictim->GetTotalAuraModifierByMiscMask(SPELL_AURA_MOD_ATTACKER_SPELL_CRIT_CHANCE, schoolMask); - // Modify critical chance by victim SPELL_AURA_MOD_ATTACKER_SPELL_AND_WEAPON_CRIT_CHANCE - crit_chance += pVictim->GetTotalAuraModifier(SPELL_AURA_MOD_ATTACKER_SPELL_AND_WEAPON_CRIT_CHANCE); - // Modify by player victim resilience - if (pVictim->GetTypeId() == TYPEID_PLAYER) - crit_chance -= ((Player*)pVictim)->GetRatingBonusValue(CR_CRIT_TAKEN_SPELL); - // scripted (increase crit chance ... against ... target by x% - if(pVictim->isFrozen()) // Shatter - { - AuraList const& mOverrideClassScript = GetAurasByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS); - for(AuraList::const_iterator i = mOverrideClassScript.begin(); i != mOverrideClassScript.end(); ++i) - { - switch((*i)->GetModifier()->m_miscvalue) - { - case 849: crit_chance+= 10.0f; break; //Shatter Rank 1 - case 910: crit_chance+= 20.0f; break; //Shatter Rank 2 - case 911: crit_chance+= 30.0f; break; //Shatter Rank 3 - case 912: crit_chance+= 40.0f; break; //Shatter Rank 4 - case 913: crit_chance+= 50.0f; break; //Shatter Rank 5 - } - } - } - } - break; - } - case SPELL_DAMAGE_CLASS_MELEE: - case SPELL_DAMAGE_CLASS_RANGED: - { - if (pVictim) - { - crit_chance = GetUnitCriticalChance(attackType, pVictim); - crit_chance+= (int32(GetMaxSkillValueForLevel(pVictim)) - int32(pVictim->GetDefenseSkillValue(this))) * 0.04f; - crit_chance+= GetTotalAuraModifierByMiscMask(SPELL_AURA_MOD_SPELL_CRIT_CHANCE_SCHOOL, schoolMask); - } - break; - } - default: - return false; - } - // percent done - // only players use intelligence for critical chance computations - if(Player* modOwner = GetSpellModOwner()) - modOwner->ApplySpellMod(spellProto->Id, SPELLMOD_CRITICAL_CHANCE, crit_chance); - - crit_chance = crit_chance > 0.0f ? crit_chance : 0.0f; - if (roll_chance_f(crit_chance)) - return true; - return false; -} - -uint32 Unit::SpellCriticalBonus(SpellEntry const *spellProto, uint32 damage, Unit *pVictim) -{ - // Calculate critical bonus - int32 crit_bonus; - switch(spellProto->DmgClass) - { - case SPELL_DAMAGE_CLASS_MELEE: // for melee based spells is 100% - case SPELL_DAMAGE_CLASS_RANGED: - // TODO: write here full calculation for melee/ranged spells - crit_bonus = damage; - break; - default: - crit_bonus = damage / 2; // for spells is 50% - break; - } - - // adds additional damage to crit_bonus (from talents) - if(Player* modOwner = GetSpellModOwner()) - modOwner->ApplySpellMod(spellProto->Id, SPELLMOD_CRIT_DAMAGE_BONUS, crit_bonus); - - if(pVictim) - { - uint32 creatureTypeMask = pVictim->GetCreatureTypeMask(); - crit_bonus = int32(crit_bonus * GetTotalAuraMultiplierByMiscMask(SPELL_AURA_MOD_CRIT_PERCENT_VERSUS, creatureTypeMask)); - } - - if(crit_bonus > 0) - damage += crit_bonus; - - return damage; -} - -uint32 Unit::SpellHealingBonus(SpellEntry const *spellProto, uint32 healamount, DamageEffectType damagetype, Unit *pVictim) -{ - // For totems get healing bonus from owner (statue isn't totem in fact) - if( GetTypeId()==TYPEID_UNIT && ((Creature*)this)->isTotem() && ((Totem*)this)->GetTotemType()!=TOTEM_STATUE) - if(Unit* owner = GetOwner()) - return owner->SpellHealingBonus(spellProto, healamount, damagetype, pVictim); - - // Healing Done - - // These Spells are doing fixed amount of healing (TODO found less hack-like check) - if(spellProto->Id == 15290 || spellProto->Id == 39373 || spellProto->Id == 33778 || spellProto->Id == 379 || spellProto->Id == 38395) - return healamount; - - - int32 AdvertisedBenefit = SpellBaseHealingBonus(GetSpellSchoolMask(spellProto)); - uint32 CastingTime = GetSpellCastTime(spellProto); - - // Healing Taken - AdvertisedBenefit += SpellBaseHealingBonusForVictim(GetSpellSchoolMask(spellProto), pVictim); - - // Blessing of Light dummy effects healing taken from Holy Light and Flash of Light - if (spellProto->SpellFamilyName == SPELLFAMILY_PALADIN && (spellProto->SpellFamilyFlags & 0x00000000C0000000LL)) - { - AuraList const& mDummyAuras = pVictim->GetAurasByType(SPELL_AURA_DUMMY); - for(AuraList::const_iterator i = mDummyAuras.begin();i != mDummyAuras.end(); ++i) - { - if((*i)->GetSpellProto()->SpellVisual == 9180) - { - // Flash of Light - if ((spellProto->SpellFamilyFlags & 0x0000000040000000LL) && (*i)->GetEffIndex() == 1) - AdvertisedBenefit += (*i)->GetModifier()->m_amount; - // Holy Light - else if ((spellProto->SpellFamilyFlags & 0x0000000080000000LL) && (*i)->GetEffIndex() == 0) - AdvertisedBenefit += (*i)->GetModifier()->m_amount; - } - } - } - - float ActualBenefit = 0.0f; - - if (AdvertisedBenefit != 0) - { - // Healing over Time spells - float DotFactor = 1.0f; - if(damagetype == DOT) - { - int32 DotDuration = GetSpellDuration(spellProto); - if(DotDuration > 0) - { - // 200% limit - if(DotDuration > 30000) DotDuration = 30000; - if(!IsChanneledSpell(spellProto)) DotFactor = DotDuration / 15000.0f; - int x = 0; - for(int j = 0; j < 3; j++) - { - if( spellProto->Effect[j] == SPELL_EFFECT_APPLY_AURA && ( - spellProto->EffectApplyAuraName[j] == SPELL_AURA_PERIODIC_HEAL || - spellProto->EffectApplyAuraName[j] == SPELL_AURA_PERIODIC_LEECH) ) - { - x = j; - break; - } - } - int DotTicks = 6; - if(spellProto->EffectAmplitude[x] != 0) - DotTicks = DotDuration / spellProto->EffectAmplitude[x]; - if(DotTicks) - AdvertisedBenefit /= DotTicks; - } - } - - // distribute healing to all effects, reduce AoE damage - CastingTime = GetCastingTimeForBonus( spellProto, damagetype, CastingTime ); - - // 0% bonus for damage and healing spells for leech spells from healing bonus - for(int j = 0; j < 3; ++j) - { - if( spellProto->Effect[j] == SPELL_EFFECT_HEALTH_LEECH || - spellProto->Effect[j] == SPELL_EFFECT_APPLY_AURA && spellProto->EffectApplyAuraName[j] == SPELL_AURA_PERIODIC_LEECH ) - { - CastingTime = 0; - break; - } - } - - // Exception - switch (spellProto->SpellFamilyName) - { - case SPELLFAMILY_SHAMAN: - // Healing stream from totem (add 6% per tick from hill bonus owner) - if (spellProto->SpellFamilyFlags & 0x000000002000LL) - CastingTime = 210; - // Earth Shield 30% per charge - else if (spellProto->SpellFamilyFlags & 0x40000000000LL) - CastingTime = 1050; - break; - case SPELLFAMILY_DRUID: - // Lifebloom - if (spellProto->SpellFamilyFlags & 0x1000000000LL) - { - CastingTime = damagetype == DOT ? 3500 : 1200; - DotFactor = damagetype == DOT ? 0.519f : 1.0f; - } - // Tranquility triggered spell - else if (spellProto->SpellFamilyFlags & 0x80LL) - CastingTime = 667; - // Rejuvenation - else if (spellProto->SpellFamilyFlags & 0x10LL) - DotFactor = 0.845f; - // Regrowth - else if (spellProto->SpellFamilyFlags & 0x40LL) - { - DotFactor = damagetype == DOT ? 0.705f : 1.0f; - CastingTime = damagetype == DOT ? 3500 : 1010; - } - break; - case SPELLFAMILY_PRIEST: - // Holy Nova - 14% - if ((spellProto->SpellFamilyFlags & 0x8000000LL) && spellProto->SpellIconID == 1874) - CastingTime = 500; - break; - case SPELLFAMILY_PALADIN: - // Seal and Judgement of Light - if ( spellProto->SpellFamilyFlags & 0x100040000LL ) - CastingTime = 0; - break; - case SPELLFAMILY_WARRIOR: - case SPELLFAMILY_ROGUE: - case SPELLFAMILY_HUNTER: - CastingTime = 0; - break; - } - - float LvlPenalty = CalculateLevelPenalty(spellProto); - - // Spellmod SpellDamage - float SpellModSpellDamage = 100.0f; - - if(Player* modOwner = GetSpellModOwner()) - modOwner->ApplySpellMod(spellProto->Id,SPELLMOD_SPELL_BONUS_DAMAGE,SpellModSpellDamage); - - SpellModSpellDamage /= 100.0f; - - ActualBenefit = (float)AdvertisedBenefit * ((float)CastingTime / 3500.0f) * DotFactor * SpellModSpellDamage * LvlPenalty; - } - - // use float as more appropriate for negative values and percent applying - float heal = healamount + ActualBenefit; - - // TODO: check for ALL/SPELLS type - // Healing done percent - AuraList const& mHealingDonePct = GetAurasByType(SPELL_AURA_MOD_HEALING_DONE_PERCENT); - for(AuraList::const_iterator i = mHealingDonePct.begin();i != mHealingDonePct.end(); ++i) - heal *= (100.0f + (*i)->GetModifier()->m_amount) / 100.0f; - - // apply spellmod to Done amount - if(Player* modOwner = GetSpellModOwner()) - modOwner->ApplySpellMod(spellProto->Id, damagetype == DOT ? SPELLMOD_DOT : SPELLMOD_DAMAGE, heal); - - // Healing Wave cast - if (spellProto->SpellFamilyName == SPELLFAMILY_SHAMAN && spellProto->SpellFamilyFlags & 0x0000000000000040LL) - { - // Search for Healing Way on Victim (stack up to 3 time) - int32 pctMod = 0; - Unit::AuraList const& auraDummy = pVictim->GetAurasByType(SPELL_AURA_DUMMY); - for(Unit::AuraList::const_iterator itr = auraDummy.begin(); itr!=auraDummy.end(); ++itr) - if((*itr)->GetId() == 29203) - pctMod += (*itr)->GetModifier()->m_amount; - // Apply bonus - if (pctMod) - heal = heal * (100 + pctMod) / 100; - } - - // Healing taken percent - float minval = pVictim->GetMaxNegativeAuraModifier(SPELL_AURA_MOD_HEALING_PCT); - if(minval) - heal *= (100.0f + minval) / 100.0f; - - float maxval = pVictim->GetMaxPositiveAuraModifier(SPELL_AURA_MOD_HEALING_PCT); - if(maxval) - heal *= (100.0f + maxval) / 100.0f; - - if (heal < 0) heal = 0; - - return uint32(heal); -} - -int32 Unit::SpellBaseHealingBonus(SpellSchoolMask schoolMask) -{ - int32 AdvertisedBenefit = 0; - - AuraList const& mHealingDone = GetAurasByType(SPELL_AURA_MOD_HEALING_DONE); - for(AuraList::const_iterator i = mHealingDone.begin();i != mHealingDone.end(); ++i) - if(((*i)->GetModifier()->m_miscvalue & schoolMask) != 0) - AdvertisedBenefit += (*i)->GetModifier()->m_amount; - - // Healing bonus of spirit, intellect and strength - if (GetTypeId() == TYPEID_PLAYER) - { - // Healing bonus from stats - AuraList const& mHealingDoneOfStatPercent = GetAurasByType(SPELL_AURA_MOD_SPELL_HEALING_OF_STAT_PERCENT); - for(AuraList::const_iterator i = mHealingDoneOfStatPercent.begin();i != mHealingDoneOfStatPercent.end(); ++i) - { - // stat used dependent from misc value (stat index) - Stats usedStat = Stats((*i)->GetSpellProto()->EffectMiscValue[(*i)->GetEffIndex()]); - AdvertisedBenefit += int32(GetStat(usedStat) * (*i)->GetModifier()->m_amount / 100.0f); - } - - // ... and attack power - AuraList const& mHealingDonebyAP = GetAurasByType(SPELL_AURA_MOD_SPELL_HEALING_OF_ATTACK_POWER); - for(AuraList::const_iterator i = mHealingDonebyAP.begin();i != mHealingDonebyAP.end(); ++i) - if ((*i)->GetModifier()->m_miscvalue & schoolMask) - AdvertisedBenefit += int32(GetTotalAttackPowerValue(BASE_ATTACK) * (*i)->GetModifier()->m_amount / 100.0f); - } - return AdvertisedBenefit; -} - -int32 Unit::SpellBaseHealingBonusForVictim(SpellSchoolMask schoolMask, Unit *pVictim) -{ - int32 AdvertisedBenefit = 0; - AuraList const& mDamageTaken = pVictim->GetAurasByType(SPELL_AURA_MOD_HEALING); - for(AuraList::const_iterator i = mDamageTaken.begin();i != mDamageTaken.end(); ++i) - if(((*i)->GetModifier()->m_miscvalue & schoolMask) != 0) - AdvertisedBenefit += (*i)->GetModifier()->m_amount; - return AdvertisedBenefit; -} - -bool Unit::IsImmunedToDamage(SpellSchoolMask shoolMask, bool useCharges) -{ - // no charges dependent checks - SpellImmuneList const& schoolList = m_spellImmune[IMMUNITY_SCHOOL]; - for (SpellImmuneList::const_iterator itr = schoolList.begin(); itr != schoolList.end(); ++itr) - if(itr->type & shoolMask) - return true; - - // charges dependent checks - SpellImmuneList const& damageList = m_spellImmune[IMMUNITY_DAMAGE]; - for (SpellImmuneList::const_iterator itr = damageList.begin(); itr != damageList.end(); ++itr) - { - if(itr->type & shoolMask) - { - if(useCharges) - { - AuraList const& auraDamageImmunity = GetAurasByType(SPELL_AURA_DAMAGE_IMMUNITY); - for(AuraList::const_iterator auraItr = auraDamageImmunity.begin(); auraItr != auraDamageImmunity.end(); ++auraItr) - { - if((*auraItr)->GetId()==itr->spellId) - { - if((*auraItr)->m_procCharges > 0) - { - --(*auraItr)->m_procCharges; - if((*auraItr)->m_procCharges==0) - RemoveAurasDueToSpell(itr->spellId); - } - break; - } - } - } - return true; - } - } - - return false; -} - -bool Unit::IsImmunedToSpell(SpellEntry const* spellInfo, bool useCharges) -{ - if (!spellInfo) - return false; - - // no charges first - - //FIX ME this hack: don't get feared if stunned - if (spellInfo->Mechanic == MECHANIC_FEAR ) - { - if ( hasUnitState(UNIT_STAT_STUNDED) ) - return true; - } - - // not have spells with charges currently - SpellImmuneList const& dispelList = m_spellImmune[IMMUNITY_DISPEL]; - for(SpellImmuneList::const_iterator itr = dispelList.begin(); itr != dispelList.end(); ++itr) - if(itr->type == spellInfo->Dispel) - return true; - - if( !(spellInfo->AttributesEx & SPELL_ATTR_EX_UNAFFECTED_BY_SCHOOL_IMMUNE)) // unaffected by school immunity - { - // not have spells with charges currently - SpellImmuneList const& schoolList = m_spellImmune[IMMUNITY_SCHOOL]; - for(SpellImmuneList::const_iterator itr = schoolList.begin(); itr != schoolList.end(); ++itr) - if( !(IsPositiveSpell(itr->spellId) && IsPositiveSpell(spellInfo->Id)) && - (itr->type & GetSpellSchoolMask(spellInfo)) ) - return true; - } - - // charges dependent checks - - SpellImmuneList const& mechanicList = m_spellImmune[IMMUNITY_MECHANIC]; - for(SpellImmuneList::const_iterator itr = mechanicList.begin(); itr != mechanicList.end(); ++itr) - { - if(itr->type == spellInfo->Mechanic) - { - if(useCharges) - { - AuraList const& auraMechImmunity = GetAurasByType(SPELL_AURA_MECHANIC_IMMUNITY); - for(AuraList::const_iterator auraItr = auraMechImmunity.begin(); auraItr != auraMechImmunity.end(); ++auraItr) - { - if((*auraItr)->GetId()==itr->spellId) - { - if((*auraItr)->m_procCharges > 0) - { - --(*auraItr)->m_procCharges; - if((*auraItr)->m_procCharges==0) - RemoveAurasDueToSpell(itr->spellId); - } - break; - } - } - } - return true; - } - } - - return false; -} - -bool Unit::IsImmunedToSpellEffect(uint32 effect, uint32 mechanic) const -{ - //If m_immuneToEffect type contain this effect type, IMMUNE effect. - SpellImmuneList const& effectList = m_spellImmune[IMMUNITY_EFFECT]; - for (SpellImmuneList::const_iterator itr = effectList.begin(); itr != effectList.end(); ++itr) - if(itr->type == effect) - return true; - - SpellImmuneList const& mechanicList = m_spellImmune[IMMUNITY_MECHANIC]; - for (SpellImmuneList::const_iterator itr = mechanicList.begin(); itr != mechanicList.end(); ++itr) - if(itr->type == mechanic) - return true; - - return false; -} - -bool Unit::IsDamageToThreatSpell(SpellEntry const * spellInfo) const -{ - if(!spellInfo) - return false; - - uint32 family = spellInfo->SpellFamilyName; - uint64 flags = spellInfo->SpellFamilyFlags; - - if((family == 5 && flags == 256) || //Searing Pain - (family == 6 && flags == 8192) || //Mind Blast - (family == 11 && flags == 1048576)) //Earth Shock - return true; - - return false; -} - -void Unit::MeleeDamageBonus(Unit *pVictim, uint32 *pdamage,WeaponAttackType attType, SpellEntry const *spellProto) -{ - if(!pVictim) - return; - - if(*pdamage == 0) - return; - - uint32 creatureTypeMask = pVictim->GetCreatureTypeMask(); - - // Taken/Done fixed damage bonus auras - int32 DoneFlatBenefit = 0; - int32 TakenFlatBenefit = 0; - - // ..done (for creature type by mask) in taken - AuraList const& mDamageDoneCreature = this->GetAurasByType(SPELL_AURA_MOD_DAMAGE_DONE_CREATURE); - for(AuraList::const_iterator i = mDamageDoneCreature.begin();i != mDamageDoneCreature.end(); ++i) - if(creatureTypeMask & uint32((*i)->GetModifier()->m_miscvalue)) - DoneFlatBenefit += (*i)->GetModifier()->m_amount; - - // ..done - // SPELL_AURA_MOD_DAMAGE_DONE included in weapon damage - - // ..done (base at attack power for marked target and base at attack power for creature type) - int32 APbonus = 0; - if(attType == RANGED_ATTACK) - { - APbonus += pVictim->GetTotalAuraModifier(SPELL_AURA_RANGED_ATTACK_POWER_ATTACKER_BONUS); - - // ..done (base at attack power and creature type) - AuraList const& mCreatureAttackPower = GetAurasByType(SPELL_AURA_MOD_RANGED_ATTACK_POWER_VERSUS); - for(AuraList::const_iterator i = mCreatureAttackPower.begin();i != mCreatureAttackPower.end(); ++i) - if(creatureTypeMask & uint32((*i)->GetModifier()->m_miscvalue)) - APbonus += (*i)->GetModifier()->m_amount; - } - else - { - APbonus += pVictim->GetTotalAuraModifier(SPELL_AURA_MELEE_ATTACK_POWER_ATTACKER_BONUS); - - // ..done (base at attack power and creature type) - AuraList const& mCreatureAttackPower = GetAurasByType(SPELL_AURA_MOD_MELEE_ATTACK_POWER_VERSUS); - for(AuraList::const_iterator i = mCreatureAttackPower.begin();i != mCreatureAttackPower.end(); ++i) - if(creatureTypeMask & uint32((*i)->GetModifier()->m_miscvalue)) - APbonus += (*i)->GetModifier()->m_amount; - } - - if (APbonus!=0) // Can be negative - { - bool normalized = false; - if(spellProto) - { - for (uint8 i = 0; i<3;i++) - { - if (spellProto->Effect[i] == SPELL_EFFECT_NORMALIZED_WEAPON_DMG) - { - normalized = true; - break; - } - } - } - - DoneFlatBenefit += int32(APbonus/14.0f * GetAPMultiplier(attType,normalized)); - } - - // ..taken - AuraList const& mDamageTaken = pVictim->GetAurasByType(SPELL_AURA_MOD_DAMAGE_TAKEN); - for(AuraList::const_iterator i = mDamageTaken.begin();i != mDamageTaken.end(); ++i) - if((*i)->GetModifier()->m_miscvalue & SPELL_SCHOOL_MASK_NORMAL) - TakenFlatBenefit += (*i)->GetModifier()->m_amount; - - if(attType!=RANGED_ATTACK) - TakenFlatBenefit += pVictim->GetTotalAuraModifier(SPELL_AURA_MOD_MELEE_DAMAGE_TAKEN); - else - TakenFlatBenefit += pVictim->GetTotalAuraModifier(SPELL_AURA_MOD_RANGED_DAMAGE_TAKEN); - - // Done/Taken total percent damage auras - float DoneTotalMod = 1; - float TakenTotalMod = 1; - - // ..done - // SPELL_AURA_MOD_DAMAGE_PERCENT_DONE included in weapon damage - // SPELL_AURA_MOD_OFFHAND_DAMAGE_PCT included in weapon damage - - AuraList const& mDamageDoneVersus = this->GetAurasByType(SPELL_AURA_MOD_DAMAGE_DONE_VERSUS); - for(AuraList::const_iterator i = mDamageDoneVersus.begin();i != mDamageDoneVersus.end(); ++i) - if(creatureTypeMask & uint32((*i)->GetModifier()->m_miscvalue)) - DoneTotalMod *= ((*i)->GetModifier()->m_amount+100.0f)/100.0f; - - // ..taken - AuraList const& mModDamagePercentTaken = pVictim->GetAurasByType(SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN); - for(AuraList::const_iterator i = mModDamagePercentTaken.begin(); i != mModDamagePercentTaken.end(); ++i) - if((*i)->GetModifier()->m_miscvalue & SPELL_SCHOOL_MASK_NORMAL) - TakenTotalMod *= ((*i)->GetModifier()->m_amount+100.0f)/100.0f; - - // .. taken pct: dummy auras - AuraList const& mDummyAuras = pVictim->GetAurasByType(SPELL_AURA_DUMMY); - for(AuraList::const_iterator i = mDummyAuras.begin(); i != mDummyAuras.end(); ++i) - { - switch((*i)->GetSpellProto()->SpellIconID) - { - //Cheat Death - case 2109: - if((*i)->GetModifier()->m_miscvalue & SPELL_SCHOOL_MASK_NORMAL) - { - if(pVictim->GetTypeId() != TYPEID_PLAYER) - continue; - float mod = ((Player*)pVictim)->GetRatingBonusValue(CR_CRIT_TAKEN_MELEE)*(-8.0f); - if (mod < (*i)->GetModifier()->m_amount) - mod = (*i)->GetModifier()->m_amount; - TakenTotalMod *= (mod+100.0f)/100.0f; - } - break; - //Mangle - case 2312: - if(spellProto==NULL) - break; - // Should increase Shred (initial Damage of Lacerate and Rake handled in Spell::EffectSchoolDMG) - if(spellProto->SpellFamilyName==SPELLFAMILY_DRUID && (spellProto->SpellFamilyFlags==0x00008000LL)) - TakenTotalMod *= (100.0f+(*i)->GetModifier()->m_amount)/100.0f; - break; - } - } - - // .. taken pct: class scripts - AuraList const& mclassScritAuras = GetAurasByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS); - for(AuraList::const_iterator i = mclassScritAuras.begin(); i != mclassScritAuras.end(); ++i) - { - switch((*i)->GetMiscValue()) - { - case 6427: case 6428: // Dirty Deeds - if(pVictim->HasAuraState(AURA_STATE_HEALTHLESS_35_PERCENT)) - { - Aura* eff0 = GetAura((*i)->GetId(),0); - if(!eff0 || (*i)->GetEffIndex()!=1) - { - sLog.outError("Spell structure of DD (%u) changed.",(*i)->GetId()); - continue; - } - - // effect 0 have expected value but in negative state - TakenTotalMod *= (-eff0->GetModifier()->m_amount+100.0f)/100.0f; - } - break; - } - } - - if(attType != RANGED_ATTACK) - { - AuraList const& mModMeleeDamageTakenPercent = pVictim->GetAurasByType(SPELL_AURA_MOD_MELEE_DAMAGE_TAKEN_PCT); - for(AuraList::const_iterator i = mModMeleeDamageTakenPercent.begin(); i != mModMeleeDamageTakenPercent.end(); ++i) - TakenTotalMod *= ((*i)->GetModifier()->m_amount+100.0f)/100.0f; - } - else - { - AuraList const& mModRangedDamageTakenPercent = pVictim->GetAurasByType(SPELL_AURA_MOD_RANGED_DAMAGE_TAKEN_PCT); - for(AuraList::const_iterator i = mModRangedDamageTakenPercent.begin(); i != mModRangedDamageTakenPercent.end(); ++i) - TakenTotalMod *= ((*i)->GetModifier()->m_amount+100.0f)/100.0f; - } - - float tmpDamage = float(int32(*pdamage) + DoneFlatBenefit) * DoneTotalMod; - - // apply spellmod to Done damage - if(spellProto) - { - if(Player* modOwner = GetSpellModOwner()) - modOwner->ApplySpellMod(spellProto->Id, SPELLMOD_DAMAGE, tmpDamage); - } - - tmpDamage = (tmpDamage + TakenFlatBenefit)*TakenTotalMod; - - // bonus result can be negative - *pdamage = tmpDamage > 0 ? uint32(tmpDamage) : 0; -} - -void Unit::ApplySpellImmune(uint32 spellId, uint32 op, uint32 type, bool apply) -{ - if (apply) - { - for (SpellImmuneList::iterator itr = m_spellImmune[op].begin(), next; itr != m_spellImmune[op].end(); itr = next) - { - next = itr; ++next; - if(itr->type == type) - { - m_spellImmune[op].erase(itr); - next = m_spellImmune[op].begin(); - } - } - SpellImmune Immune; - Immune.spellId = spellId; - Immune.type = type; - m_spellImmune[op].push_back(Immune); - } - else - { - for (SpellImmuneList::iterator itr = m_spellImmune[op].begin(); itr != m_spellImmune[op].end(); ++itr) - { - if(itr->spellId == spellId) - { - m_spellImmune[op].erase(itr); - break; - } - } - } - -} - -void Unit::ApplySpellDispelImmunity(const SpellEntry * spellProto, DispelType type, bool apply) -{ - ApplySpellImmune(spellProto->Id,IMMUNITY_DISPEL, type, apply); - - if (apply && spellProto->AttributesEx & SPELL_ATTR_EX_DISPEL_AURAS_ON_IMMUNITY) - RemoveAurasWithDispelType(type); -} - -float Unit::GetWeaponProcChance() const -{ - // normalized proc chance for weapon attack speed - // (odd formulae...) - if(isAttackReady(BASE_ATTACK)) - return (GetAttackTime(BASE_ATTACK) * 1.8f / 1000.0f); - else if (haveOffhandWeapon() && isAttackReady(OFF_ATTACK)) - return (GetAttackTime(OFF_ATTACK) * 1.6f / 1000.0f); - return 0; -} - -float Unit::GetPPMProcChance(uint32 WeaponSpeed, float PPM) const -{ - // proc per minute chance calculation - if (PPM <= 0) return 0.0f; - uint32 result = uint32((WeaponSpeed * PPM) / 600.0f); // result is chance in percents (probability = Speed_in_sec * (PPM / 60)) - return result; -} - -void Unit::Mount(uint32 mount) -{ - if(!mount) - return; - - RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_MOUNTING); - - SetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID, mount); - - SetFlag( UNIT_FIELD_FLAGS, UNIT_FLAG_MOUNT ); - - // unsummon pet - if(GetTypeId() == TYPEID_PLAYER) - { - Pet* pet = GetPet(); - if(pet) - { - if(pet->isControlled()) - { - ((Player*)this)->SetTemporaryUnsummonedPetNumber(pet->GetCharmInfo()->GetPetNumber()); - ((Player*)this)->SetOldPetSpell(pet->GetUInt32Value(UNIT_CREATED_BY_SPELL)); - } - - ((Player*)this)->RemovePet(NULL,PET_SAVE_NOT_IN_SLOT); - } - else - ((Player*)this)->SetTemporaryUnsummonedPetNumber(0); - } -} - -void Unit::Unmount() -{ - if(!IsMounted()) - return; - - RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_NOT_MOUNTED); - - SetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID, 0); - RemoveFlag( UNIT_FIELD_FLAGS, UNIT_FLAG_MOUNT ); - - // only resummon old pet if the player is already added to a map - // this prevents adding a pet to a not created map which would otherwise cause a crash - // (it could probably happen when logging in after a previous crash) - if(GetTypeId() == TYPEID_PLAYER && IsInWorld() && ((Player*)this)->GetTemporaryUnsummonedPetNumber() && isAlive()) - { - Pet* NewPet = new Pet; - if(!NewPet->LoadPetFromDB(this, 0, ((Player*)this)->GetTemporaryUnsummonedPetNumber(), true)) - delete NewPet; - - ((Player*)this)->SetTemporaryUnsummonedPetNumber(0); - } -} - -void Unit::SetInCombatWith(Unit* enemy) -{ - Unit* eOwner = enemy->GetCharmerOrOwnerOrSelf(); - if(eOwner->IsPvP()) - { - SetInCombatState(true); - return; - } - - //check for duel - if(eOwner->GetTypeId() == TYPEID_PLAYER && ((Player*)eOwner)->duel) - { - Unit const* myOwner = GetCharmerOrOwnerOrSelf(); - if(((Player const*)eOwner)->duel->opponent == myOwner) - { - SetInCombatState(true); - return; - } - } - SetInCombatState(false); -} - -void Unit::SetInCombatState(bool PvP) -{ - // only alive units can be in combat - if(!isAlive()) - return; - - if(PvP) - m_CombatTimer = 5000; - SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IN_COMBAT); - - if(isCharmed() || (GetTypeId()!=TYPEID_PLAYER && ((Creature*)this)->isPet())) - SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PET_IN_COMBAT); -} - -void Unit::ClearInCombat() -{ - m_CombatTimer = 0; - RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IN_COMBAT); - - if(isCharmed() || (GetTypeId()!=TYPEID_PLAYER && ((Creature*)this)->isPet())) - RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PET_IN_COMBAT); - - // Player's state will be cleared in Player::UpdateContestedPvP - if(GetTypeId()!=TYPEID_PLAYER) - clearUnitState(UNIT_STAT_ATTACK_PLAYER); -} - -bool Unit::isTargetableForAttack() const -{ - if (GetTypeId()==TYPEID_PLAYER && ((Player *)this)->isGameMaster()) - return false; - - if(HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE)) - return false; - - return isAlive() && !hasUnitState(UNIT_STAT_DIED)&& !isInFlight() /*&& !isStealth()*/; -} - -int32 Unit::ModifyHealth(int32 dVal) -{ - int32 gain = 0; - - if(dVal==0) - return 0; - - int32 curHealth = (int32)GetHealth(); - - int32 val = dVal + curHealth; - if(val <= 0) - { - SetHealth(0); - return -curHealth; - } - - int32 maxHealth = (int32)GetMaxHealth(); - - if(val < maxHealth) - { - SetHealth(val); - gain = val - curHealth; - } - else if(curHealth != maxHealth) - { - SetHealth(maxHealth); - gain = maxHealth - curHealth; - } - - return gain; -} - -int32 Unit::ModifyPower(Powers power, int32 dVal) -{ - int32 gain = 0; - - if(dVal==0) - return 0; - - int32 curPower = (int32)GetPower(power); - - int32 val = dVal + curPower; - if(val <= 0) - { - SetPower(power,0); - return -curPower; - } - - int32 maxPower = (int32)GetMaxPower(power); - - if(val < maxPower) - { - SetPower(power,val); - gain = val - curPower; - } - else if(curPower != maxPower) - { - SetPower(power,maxPower); - gain = maxPower - curPower; - } - - return gain; -} - -bool Unit::isVisibleForOrDetect(Unit const* u, bool detect, bool inVisibleList) const -{ - if(!u) - return false; - - // Always can see self - if (u==this) - return true; - - // player visible for other player if not logout and at same transport - // including case when player is out of world - bool at_same_transport = - GetTypeId() == TYPEID_PLAYER && u->GetTypeId()==TYPEID_PLAYER && - !((Player*)this)->GetSession()->PlayerLogout() && !((Player*)u)->GetSession()->PlayerLogout() && - !((Player*)this)->GetSession()->PlayerLoading() && !((Player*)u)->GetSession()->PlayerLoading() && - ((Player*)this)->GetTransport() && ((Player*)this)->GetTransport() == ((Player*)u)->GetTransport(); - - // not in world - if(!at_same_transport && (!IsInWorld() || !u->IsInWorld())) - return false; - - // forbidden to seen (at GM respawn command) - if(m_Visibility==VISIBILITY_RESPAWN) - return false; - - // always seen by owner - if(GetCharmerOrOwnerGUID()==u->GetGUID()) - return true; - - // Grid dead/alive checks - if( u->GetTypeId()==TYPEID_PLAYER) - { - // non visible at grid for any stealth state - if(!IsVisibleInGridForPlayer((Player *)u)) - return false; - - // if player is dead then he can't detect anyone in anycases - if(!u->isAlive()) - detect = false; - } - else - { - // all dead creatures/players not visible for any creatures - if(!u->isAlive() || !isAlive()) - return false; - } - - // different visible distance checks - if(u->isInFlight()) // what see player in flight - { - // use object grey distance for all (only see objects any way) - if (!IsWithinDistInMap(u,World::GetMaxVisibleDistanceInFlight()+(inVisibleList ? World::GetVisibleObjectGreyDistance() : 0.0f))) - return false; - } - else if(!isAlive()) // distance for show body - { - if (!IsWithinDistInMap(u,World::GetMaxVisibleDistanceForObject()+(inVisibleList ? World::GetVisibleObjectGreyDistance() : 0.0f))) - return false; - } - else if(GetTypeId()==TYPEID_PLAYER) // distance for show player - { - if(u->GetTypeId()==TYPEID_PLAYER) - { - // Players far than max visible distance for player or not in our map are not visible too - if (!at_same_transport && !IsWithinDistInMap(u,World::GetMaxVisibleDistanceForPlayer()+(inVisibleList ? World::GetVisibleUnitGreyDistance() : 0.0f))) - return false; - } - else - { - // Units far than max visible distance for creature or not in our map are not visible too - if (!IsWithinDistInMap(u,World::GetMaxVisibleDistanceForCreature()+(inVisibleList ? World::GetVisibleUnitGreyDistance() : 0.0f))) - return false; - } - } - else if(GetCharmerOrOwnerGUID()) // distance for show pet/charmed - { - // Pet/charmed far than max visible distance for player or not in our map are not visible too - if (!IsWithinDistInMap(u,World::GetMaxVisibleDistanceForPlayer()+(inVisibleList ? World::GetVisibleUnitGreyDistance() : 0.0f))) - return false; - } - else // distance for show creature - { - // Units far than max visible distance for creature or not in our map are not visible too - if (!IsWithinDistInMap(u,World::GetMaxVisibleDistanceForCreature()+(inVisibleList ? World::GetVisibleUnitGreyDistance() : 0.0f))) - return false; - } - - // Visible units, always are visible for all units, except for units under invisibility - if (m_Visibility == VISIBILITY_ON && u->m_invisibilityMask==0) - return true; - - // GMs see any players, not higher GMs and all units - if (u->GetTypeId() == TYPEID_PLAYER && ((Player *)u)->isGameMaster()) - { - if(GetTypeId() == TYPEID_PLAYER) - return ((Player *)this)->GetSession()->GetSecurity() <= ((Player *)u)->GetSession()->GetSecurity(); - else - return true; - } - - // non faction visibility non-breakable for non-GMs - if (m_Visibility == VISIBILITY_OFF) - return false; - - // raw invisibility - bool invisible = (m_invisibilityMask != 0 || u->m_invisibilityMask !=0); - - // detectable invisibility case - if( invisible && ( - // Invisible units, always are visible for units under same invisibility type - (m_invisibilityMask & u->m_invisibilityMask)!=0 || - // Invisible units, always are visible for unit that can detect this invisibility (have appropriate level for detect) - u->canDetectInvisibilityOf(this) || - // Units that can detect invisibility always are visible for units that can be detected - canDetectInvisibilityOf(u) )) - { - invisible = false; - } - - // special cases for always overwrite invisibility/stealth - if(invisible || m_Visibility == VISIBILITY_GROUP_STEALTH) - { - // non-hostile case - if (!u->IsHostileTo(this)) - { - // player see other player with stealth/invisibility only if he in same group or raid or same team (raid/team case dependent from conf setting) - if(GetTypeId()==TYPEID_PLAYER && u->GetTypeId()==TYPEID_PLAYER) - { - if(((Player*)this)->IsGroupVisibleFor(((Player*)u))) - return true; - - // else apply same rules as for hostile case (detecting check for stealth) - } - } - // hostile case - else - { - // Hunter mark functionality - AuraList const& auras = GetAurasByType(SPELL_AURA_MOD_STALKED); - for(AuraList::const_iterator iter = auras.begin(); iter != auras.end(); ++iter) - if((*iter)->GetCasterGUID()==u->GetGUID()) - return true; - - // else apply detecting check for stealth - } - - // none other cases for detect invisibility, so invisible - if(invisible) - return false; - - // else apply stealth detecting check - } - - // unit got in stealth in this moment and must ignore old detected state - if (m_Visibility == VISIBILITY_GROUP_NO_DETECT) - return false; - - // GM invisibility checks early, invisibility if any detectable, so if not stealth then visible - if (m_Visibility != VISIBILITY_GROUP_STEALTH) - return true; - - // NOW ONLY STEALTH CASE - - // stealth and detected and visible for some seconds - if (u->GetTypeId() == TYPEID_PLAYER && ((Player*)u)->m_DetectInvTimer > 300 && ((Player*)u)->HaveAtClient(this)) - return true; - - //if in non-detect mode then invisible for unit - if (!detect) - return false; - - // Special cases - - // If is attacked then stealth is lost, some creature can use stealth too - if( !getAttackers().empty() ) - return true; - - // If there is collision rogue is seen regardless of level difference - // TODO: check sizes in DB - float distance = GetDistance(u); - if (distance < 0.24f) - return true; - - //If a mob or player is stunned he will not be able to detect stealth - if (u->hasUnitState(UNIT_STAT_STUNDED) && (u != this)) - return false; - - // Creature can detect target only in aggro radius - if(u->GetTypeId() != TYPEID_PLAYER) - { - //Always invisible from back and out of aggro range - bool isInFront = u->isInFront(this,((Creature const*)u)->GetAttackDistance(this)); - if(!isInFront) - return false; - } - else - { - //Always invisible from back - bool isInFront = u->isInFront(this,(GetTypeId()==TYPEID_PLAYER || GetCharmerOrOwnerGUID()) ? World::GetMaxVisibleDistanceForPlayer() : World::GetMaxVisibleDistanceForCreature()); - if(!isInFront) - return false; - } - - // if doesn't have stealth detection (Shadow Sight), then check how stealthy the unit is, otherwise just check los - if(!u->HasAuraType(SPELL_AURA_DETECT_STEALTH)) - { - //Calculation if target is in front - - //Visible distance based on stealth value (stealth rank 4 300MOD, 10.5 - 3 = 7.5) - float visibleDistance = 10.5f - (GetTotalAuraModifier(SPELL_AURA_MOD_STEALTH)/100.0f); - - //Visible distance is modified by - //-Level Diff (every level diff = 1.0f in visible distance) - visibleDistance += int32(u->getLevelForTarget(this)) - int32(this->getLevelForTarget(u)); - - //This allows to check talent tree and will add addition stealth dependent on used points) - int32 stealthMod = GetTotalAuraModifier(SPELL_AURA_MOD_STEALTH_LEVEL); - if(stealthMod < 0) - stealthMod = 0; - - //-Stealth Mod(positive like Master of Deception) and Stealth Detection(negative like paranoia) - //based on wowwiki every 5 mod we have 1 more level diff in calculation - visibleDistance += (int32(u->GetTotalAuraModifier(SPELL_AURA_MOD_DETECT)) - stealthMod)/5.0f; - - if(distance > visibleDistance) - return false; - } - - // Now check is target visible with LoS - float ox,oy,oz; - u->GetPosition(ox,oy,oz); - return IsWithinLOS(ox,oy,oz); -} - -void Unit::SetVisibility(UnitVisibility x) -{ - m_Visibility = x; - - if(IsInWorld()) - { - Map *m = MapManager::Instance().GetMap(GetMapId(), this); - - if(GetTypeId()==TYPEID_PLAYER) - m->PlayerRelocation((Player*)this,GetPositionX(),GetPositionY(),GetPositionZ(),GetOrientation()); - else - m->CreatureRelocation((Creature*)this,GetPositionX(),GetPositionY(),GetPositionZ(),GetOrientation()); - } -} - -bool Unit::canDetectInvisibilityOf(Unit const* u) const -{ - if(uint32 mask = (m_detectInvisibilityMask & u->m_invisibilityMask)) - { - for(uint32 i = 0; i < 10; ++i) - { - if(((1 << i) & mask)==0) - continue; - - // find invisibility level - uint32 invLevel = 0; - Unit::AuraList const& iAuras = u->GetAurasByType(SPELL_AURA_MOD_INVISIBILITY); - for(Unit::AuraList::const_iterator itr = iAuras.begin(); itr != iAuras.end(); ++itr) - if(((*itr)->GetModifier()->m_miscvalue)==i && invLevel < (*itr)->GetModifier()->m_amount) - invLevel = (*itr)->GetModifier()->m_amount; - - // find invisibility detect level - uint32 detectLevel = 0; - Unit::AuraList const& dAuras = GetAurasByType(SPELL_AURA_MOD_INVISIBILITY_DETECTION); - for(Unit::AuraList::const_iterator itr = dAuras.begin(); itr != dAuras.end(); ++itr) - if(((*itr)->GetModifier()->m_miscvalue)==i && detectLevel < (*itr)->GetModifier()->m_amount) - detectLevel = (*itr)->GetModifier()->m_amount; - - if(i==6 && GetTypeId()==TYPEID_PLAYER) // special drunk detection case - { - detectLevel = ((Player*)this)->GetDrunkValue(); - } - - if(invLevel <= detectLevel) - return true; - } - } - - return false; -} - -void Unit::UpdateSpeed(UnitMoveType mtype, bool forced) -{ - int32 main_speed_mod = 0; - float stack_bonus = 1.0f; - float non_stack_bonus = 1.0f; - - switch(mtype) - { - case MOVE_WALK: - return; - case MOVE_RUN: - { - if (IsMounted()) // Use on mount auras - { - main_speed_mod = GetMaxPositiveAuraModifier(SPELL_AURA_MOD_INCREASE_MOUNTED_SPEED); - stack_bonus = GetTotalAuraMultiplier(SPELL_AURA_MOD_MOUNTED_SPEED_ALWAYS); - non_stack_bonus = (100.0f + GetMaxPositiveAuraModifier(SPELL_AURA_MOD_MOUNTED_SPEED_NOT_STACK))/100.0f; - } - else - { - main_speed_mod = GetMaxPositiveAuraModifier(SPELL_AURA_MOD_INCREASE_SPEED); - stack_bonus = GetTotalAuraMultiplier(SPELL_AURA_MOD_SPEED_ALWAYS); - non_stack_bonus = (100.0f + GetMaxPositiveAuraModifier(SPELL_AURA_MOD_SPEED_NOT_STACK))/100.0f; - } - break; - } - case MOVE_WALKBACK: - return; - case MOVE_SWIM: - { - main_speed_mod = GetMaxPositiveAuraModifier(SPELL_AURA_MOD_INCREASE_SWIM_SPEED); - break; - } - case MOVE_SWIMBACK: - return; - case MOVE_FLY: - { - if (IsMounted()) // Use on mount auras - main_speed_mod = GetMaxPositiveAuraModifier(SPELL_AURA_MOD_INCREASE_FLIGHT_SPEED); - else // Use not mount (shapeshift for example) auras (should stack) - main_speed_mod = GetTotalAuraModifier(SPELL_AURA_MOD_SPEED_FLIGHT); - stack_bonus = GetTotalAuraMultiplier(SPELL_AURA_MOD_FLIGHT_SPEED_ALWAYS); - non_stack_bonus = (100.0 + GetMaxPositiveAuraModifier(SPELL_AURA_MOD_FLIGHT_SPEED_NOT_STACK))/100.0f; - break; - } - case MOVE_FLYBACK: - return; - default: - sLog.outError("Unit::UpdateSpeed: Unsupported move type (%d)", mtype); - return; - } - - float bonus = non_stack_bonus > stack_bonus ? non_stack_bonus : stack_bonus; - // now we ready for speed calculation - float speed = main_speed_mod ? bonus*(100.0f + main_speed_mod)/100.0f : bonus; - - switch(mtype) - { - case MOVE_RUN: - case MOVE_SWIM: - case MOVE_FLY: - { - // Normalize speed by 191 aura SPELL_AURA_USE_NORMAL_MOVEMENT_SPEED if need - // TODO: possible affect only on MOVE_RUN - if(int32 normalization = GetMaxPositiveAuraModifier(SPELL_AURA_USE_NORMAL_MOVEMENT_SPEED)) - { - // Use speed from aura - float max_speed = normalization / baseMoveSpeed[mtype]; - if (speed > max_speed) - speed = max_speed; - } - break; - } - default: - break; - } - - // Apply strongest slow aura mod to speed - int32 slow = GetMaxNegativeAuraModifier(SPELL_AURA_MOD_DECREASE_SPEED); - if (slow) - speed *=(100.0f + slow)/100.0f; - SetSpeed(mtype, speed, forced); -} - -float Unit::GetSpeed( UnitMoveType mtype ) const -{ - return m_speed_rate[mtype]*baseMoveSpeed[mtype]; -} - -void Unit::SetSpeed(UnitMoveType mtype, float rate, bool forced) -{ - if (rate < 0) - rate = 0.0f; - - // Update speed only on change - if (m_speed_rate[mtype] == rate) - return; - - m_speed_rate[mtype] = rate; - - propagateSpeedChange(); - - // Send speed change packet only for player - if (GetTypeId()!=TYPEID_PLAYER) - return; - - WorldPacket data; - if(!forced) - { - switch(mtype) - { - case MOVE_WALK: - data.Initialize(MSG_MOVE_SET_WALK_SPEED, 8+4+1+4+4+4+4+4+4+4); - break; - case MOVE_RUN: - data.Initialize(MSG_MOVE_SET_RUN_SPEED, 8+4+1+4+4+4+4+4+4+4); - break; - case MOVE_WALKBACK: - data.Initialize(MSG_MOVE_SET_RUN_BACK_SPEED, 8+4+1+4+4+4+4+4+4+4); - break; - case MOVE_SWIM: - data.Initialize(MSG_MOVE_SET_SWIM_SPEED, 8+4+1+4+4+4+4+4+4+4); - break; - case MOVE_SWIMBACK: - data.Initialize(MSG_MOVE_SET_SWIM_BACK_SPEED, 8+4+1+4+4+4+4+4+4+4); - break; - case MOVE_TURN: - data.Initialize(MSG_MOVE_SET_TURN_RATE, 8+4+1+4+4+4+4+4+4+4); - break; - case MOVE_FLY: - data.Initialize(MSG_MOVE_SET_FLIGHT_SPEED, 8+4+1+4+4+4+4+4+4+4); - break; - case MOVE_FLYBACK: - data.Initialize(MSG_MOVE_SET_FLIGHT_BACK_SPEED, 8+4+1+4+4+4+4+4+4+4); - break; - default: - sLog.outError("Unit::SetSpeed: Unsupported move type (%d), data not sent to client.",mtype); - return; - } - - data.append(GetPackGUID()); - data << uint32(0); //movement flags - data << uint8(0); //unk - data << uint32(getMSTime()); - data << float(GetPositionX()); - data << float(GetPositionY()); - data << float(GetPositionZ()); - data << float(GetOrientation()); - data << uint32(0); //flag unk - data << float(GetSpeed(mtype)); - SendMessageToSet( &data, true ); - } - else - { - // register forced speed changes for WorldSession::HandleForceSpeedChangeAck - // and do it only for real sent packets and use run for run/mounted as client expected - ++((Player*)this)->m_forced_speed_changes[mtype]; - switch(mtype) - { - case MOVE_WALK: - data.Initialize(SMSG_FORCE_WALK_SPEED_CHANGE, 16); - break; - case MOVE_RUN: - data.Initialize(SMSG_FORCE_RUN_SPEED_CHANGE, 17); - break; - case MOVE_WALKBACK: - data.Initialize(SMSG_FORCE_RUN_BACK_SPEED_CHANGE, 16); - break; - case MOVE_SWIM: - data.Initialize(SMSG_FORCE_SWIM_SPEED_CHANGE, 16); - break; - case MOVE_SWIMBACK: - data.Initialize(SMSG_FORCE_SWIM_BACK_SPEED_CHANGE, 16); - break; - case MOVE_TURN: - data.Initialize(SMSG_FORCE_TURN_RATE_CHANGE, 16); - break; - case MOVE_FLY: - data.Initialize(SMSG_FORCE_FLIGHT_SPEED_CHANGE, 16); - break; - case MOVE_FLYBACK: - data.Initialize(SMSG_FORCE_FLIGHT_BACK_SPEED_CHANGE, 16); - break; - default: - sLog.outError("Unit::SetSpeed: Unsupported move type (%d), data not sent to client.",mtype); - return; - } - data.append(GetPackGUID()); - data << (uint32)0; - if (mtype == MOVE_RUN) - data << uint8(0); // new 2.1.0 - data << float(GetSpeed(mtype)); - SendMessageToSet( &data, true ); - } - if(Pet* pet = GetPet()) - pet->SetSpeed(MOVE_RUN, m_speed_rate[mtype],forced); -} - -void Unit::SetHover(bool on) -{ - if(on) - CastSpell(this,11010,true); - else - RemoveAurasDueToSpell(11010); -} - -void Unit::setDeathState(DeathState s) -{ - if (s != ALIVE && s!= JUST_ALIVED) - { - CombatStop(); - DeleteThreatList(); - ClearComboPointHolders(); // any combo points pointed to unit lost at it death - - if(IsNonMeleeSpellCasted(false)) - InterruptNonMeleeSpells(false); - } - - if (s == JUST_DIED) - { - RemoveAllAurasOnDeath(); - UnsummonAllTotems(); - - ModifyAuraState(AURA_STATE_HEALTHLESS_20_PERCENT, false); - ModifyAuraState(AURA_STATE_HEALTHLESS_35_PERCENT, false); - // remove aurastates allowing special moves - ClearAllReactives(); - ClearDiminishings(); - } - else if(s == JUST_ALIVED) - { - RemoveFlag (UNIT_FIELD_FLAGS, UNIT_FLAG_SKINNABLE); // clear skinnable for creature and player (at battleground) - } - - if (m_deathState != ALIVE && s == ALIVE) - { - //_ApplyAllAuraMods(); - } - m_deathState = s; -} - -/*######################################## -######## ######## -######## AGGRO SYSTEM ######## -######## ######## -########################################*/ -bool Unit::CanHaveThreatList() const -{ - // only creatures can have threat list - if( GetTypeId() != TYPEID_UNIT ) - return false; - - // only alive units can have threat list - if( !isAlive() ) - return false; - - // pets and totems can not have threat list - if( ((Creature*)this)->isPet() || ((Creature*)this)->isTotem() ) - return false; - - return true; -} - -//====================================================================== - -float Unit::ApplyTotalThreatModifier(float threat, SpellSchoolMask schoolMask) -{ - if(!HasAuraType(SPELL_AURA_MOD_THREAT)) - return threat; - - SpellSchools school = GetFirstSchoolInMask(schoolMask); - - return threat * m_threatModifier[school]; -} - -//====================================================================== - -void Unit::AddThreat(Unit* pVictim, float threat, SpellSchoolMask schoolMask, SpellEntry const *threatSpell) -{ - // Only mobs can manage threat lists - if(CanHaveThreatList()) - m_ThreatManager.addThreat(pVictim, threat, schoolMask, threatSpell); -} - -//====================================================================== - -void Unit::DeleteThreatList() -{ - m_ThreatManager.clearReferences(); -} - -//====================================================================== - -void Unit::TauntApply(Unit* taunter) -{ - assert(GetTypeId()== TYPEID_UNIT); - - if(!taunter || (taunter->GetTypeId() == TYPEID_PLAYER && ((Player*)taunter)->isGameMaster())) - return; - - if(!CanHaveThreatList()) - return; - - Unit *target = getVictim(); - if(target && target == taunter) - return; - - SetInFront(taunter); - if (((Creature*)this)->AI()) - ((Creature*)this)->AI()->AttackStart(taunter); - - m_ThreatManager.tauntApply(taunter); -} - -//====================================================================== - -void Unit::TauntFadeOut(Unit *taunter) -{ - assert(GetTypeId()== TYPEID_UNIT); - - if(!taunter || (taunter->GetTypeId() == TYPEID_PLAYER && ((Player*)taunter)->isGameMaster())) - return; - - if(!CanHaveThreatList()) - return; - - Unit *target = getVictim(); - if(!target || target != taunter) - return; - - if(m_ThreatManager.isThreatListEmpty()) - { - if(((Creature*)this)->AI()) - ((Creature*)this)->AI()->EnterEvadeMode(); - return; - } - - m_ThreatManager.tauntFadeOut(taunter); - target = m_ThreatManager.getHostilTarget(); - - if (target && target != taunter) - { - SetInFront(target); - if (((Creature*)this)->AI()) - ((Creature*)this)->AI()->AttackStart(target); - } -} - -//====================================================================== - -bool Unit::SelectHostilTarget() -{ - //function provides main threat functionality - //next-victim-selection algorithm and evade mode are called - //threat list sorting etc. - - assert(GetTypeId()== TYPEID_UNIT); - Unit* target = NULL; - - //This function only useful once AI has been initilazied - if (!((Creature*)this)->AI()) - return false; - - if(!m_ThreatManager.isThreatListEmpty()) - { - if(!HasAuraType(SPELL_AURA_MOD_TAUNT)) - { - target = m_ThreatManager.getHostilTarget(); - } - } - - if(target) - { - if(!hasUnitState(UNIT_STAT_STUNDED)) - SetInFront(target); - ((Creature*)this)->AI()->AttackStart(target); - return true; - } - - // no target but something prevent go to evade mode - if( !isInCombat() || HasAuraType(SPELL_AURA_MOD_TAUNT) ) - return false; - - // last case when creature don't must go to evade mode: - // it in combat but attacker not make any damage and not enter to aggro radius to have record in threat list - // for example at owner command to pet attack some far away creature - // Note: creature not have targeted movement generator but have attacker in this case - if( GetMotionMaster()->GetCurrentMovementGeneratorType() != TARGETED_MOTION_TYPE ) - { - for(AttackerSet::const_iterator itr = m_attackers.begin(); itr != m_attackers.end(); ++itr) - { - if( (*itr)->IsInMap(this) && (*itr)->isTargetableForAttack() && (*itr)->isInAccessablePlaceFor((Creature*)this) ) - return false; - } - } - - // enter in evade mode in other case - ((Creature*)this)->AI()->EnterEvadeMode(); - - return false; -} - -//====================================================================== -//====================================================================== -//====================================================================== - -int32 Unit::CalculateSpellDamage(SpellEntry const* spellProto, uint8 effect_index, int32 effBasePoints, Unit const* target) -{ - Player* unitPlayer = (GetTypeId() == TYPEID_PLAYER) ? (Player*)this : NULL; - - uint8 comboPoints = unitPlayer ? unitPlayer->GetComboPoints() : 0; - - int32 level = int32(getLevel()) - int32(spellProto->spellLevel); - if (level > spellProto->maxLevel && spellProto->maxLevel > 0) - level = spellProto->maxLevel; - - float basePointsPerLevel = spellProto->EffectRealPointsPerLevel[effect_index]; - float randomPointsPerLevel = spellProto->EffectDicePerLevel[effect_index]; - int32 basePoints = int32(effBasePoints + level * basePointsPerLevel); - int32 randomPoints = int32(spellProto->EffectDieSides[effect_index] + level * randomPointsPerLevel); - float comboDamage = spellProto->EffectPointsPerComboPoint[effect_index]; - - // prevent random generator from getting confused by spells casted with Unit::CastCustomSpell - int32 randvalue = spellProto->EffectBaseDice[effect_index] >= randomPoints ? spellProto->EffectBaseDice[effect_index]:irand(spellProto->EffectBaseDice[effect_index], randomPoints); - int32 value = basePoints + randvalue; - //random damage - if(comboDamage != 0 && unitPlayer && target && (target->GetGUID() == unitPlayer->GetComboTarget())) - value += (int32)(comboDamage * comboPoints); - - if(Player* modOwner = GetSpellModOwner()) - { - modOwner->ApplySpellMod(spellProto->Id,SPELLMOD_ALL_EFFECTS, value); - switch(effect_index) - { - case 0: - modOwner->ApplySpellMod(spellProto->Id,SPELLMOD_EFFECT1, value); - break; - case 1: - modOwner->ApplySpellMod(spellProto->Id,SPELLMOD_EFFECT2, value); - break; - case 2: - modOwner->ApplySpellMod(spellProto->Id,SPELLMOD_EFFECT3, value); - break; - } - } - - if(spellProto->Attributes & SPELL_ATTR_LEVEL_DAMAGE_CALCULATION && spellProto->spellLevel && - spellProto->Effect[effect_index] != SPELL_EFFECT_WEAPON_PERCENT_DAMAGE && - spellProto->Effect[effect_index] != SPELL_EFFECT_KNOCK_BACK) - value = int32(value*0.25f*exp(getLevel()*(70-spellProto->spellLevel)/1000.0f)); - - return value; -} - -int32 Unit::CalculateSpellDuration(SpellEntry const* spellProto, uint8 effect_index, Unit const* target) -{ - Player* unitPlayer = (GetTypeId() == TYPEID_PLAYER) ? (Player*)this : NULL; - - uint8 comboPoints = unitPlayer ? unitPlayer->GetComboPoints() : 0; - - int32 minduration = GetSpellDuration(spellProto); - int32 maxduration = GetSpellMaxDuration(spellProto); - - int32 duration; - - if( minduration != -1 && minduration != maxduration ) - duration = minduration + int32((maxduration - minduration) * comboPoints / 5); - else - duration = minduration; - - if (duration > 0) - { - int32 mechanic = GetEffectMechanic(spellProto, effect_index); - // Find total mod value (negative bonus) - int32 durationMod_always = target->GetTotalAuraModifierByMiscValue(SPELL_AURA_MECHANIC_DURATION_MOD, mechanic); - // Find max mod (negative bonus) - int32 durationMod_not_stack = target->GetMaxNegativeAuraModifierByMiscValue(SPELL_AURA_MECHANIC_DURATION_MOD_NOT_STACK, mechanic); - - int32 durationMod = 0; - // Select strongest negative mod - if (durationMod_always > durationMod_not_stack) - durationMod = durationMod_not_stack; - else - durationMod = durationMod_always; - - if (durationMod != 0) - duration = int32(int64(duration) * (100+durationMod) /100); - - if (duration < 0) duration = 0; - } - - return duration; -} - -DiminishingLevels Unit::GetDiminishing(DiminishingGroup group) -{ - for(Diminishing::iterator i = m_Diminishing.begin(); i != m_Diminishing.end(); ++i) - { - if(i->DRGroup != group) - continue; - - if(!i->hitCount) - return DIMINISHING_LEVEL_1; - - if(!i->hitTime) - return DIMINISHING_LEVEL_1; - - // If last spell was casted more than 15 seconds ago - reset the count. - if(i->stack==0 && getMSTimeDiff(i->hitTime,getMSTime()) > 15000) - { - i->hitCount = DIMINISHING_LEVEL_1; - return DIMINISHING_LEVEL_1; - } - // or else increase the count. - else - { - return DiminishingLevels(i->hitCount); - } - } - return DIMINISHING_LEVEL_1; -} - -void Unit::IncrDiminishing(DiminishingGroup group) -{ - // Checking for existing in the table - bool IsExist = false; - for(Diminishing::iterator i = m_Diminishing.begin(); i != m_Diminishing.end(); ++i) - { - if(i->DRGroup != group) - continue; - - IsExist = true; - if(i->hitCount < DIMINISHING_LEVEL_IMMUNE) - i->hitCount += 1; - - break; - } - - if(!IsExist) - m_Diminishing.push_back(DiminishingReturn(group,getMSTime(),DIMINISHING_LEVEL_2)); -} - -void Unit::ApplyDiminishingToDuration(DiminishingGroup group, int32 &duration,Unit* caster,DiminishingLevels Level) -{ - if(duration == -1 || group == DIMINISHING_NONE || caster->IsFriendlyTo(this) ) - return; - - // Duration of crowd control abilities on pvp target is limited by 10 sec. (2.2.0) - if(duration > 10000 && IsDiminishingReturnsGroupDurationLimited(group)) - { - // test pet/charm masters instead pets/charmeds - Unit const* targetOwner = GetCharmerOrOwner(); - Unit const* casterOwner = caster->GetCharmerOrOwner(); - - Unit const* target = targetOwner ? targetOwner : this; - Unit const* source = casterOwner ? casterOwner : caster; - - if(target->GetTypeId() == TYPEID_PLAYER && source->GetTypeId() == TYPEID_PLAYER) - duration = 10000; - } - - float mod = 1.0f; - - // Some diminishings applies to mobs too (for example, Stun) - if((GetDiminishingReturnsGroupType(group) == DRTYPE_PLAYER && GetTypeId() == TYPEID_PLAYER) || GetDiminishingReturnsGroupType(group) == DRTYPE_ALL) - { - DiminishingLevels diminish = Level; - switch(diminish) - { - case DIMINISHING_LEVEL_1: break; - case DIMINISHING_LEVEL_2: mod = 0.5f; break; - case DIMINISHING_LEVEL_3: mod = 0.25f; break; - case DIMINISHING_LEVEL_IMMUNE: mod = 0.0f;break; - default: break; - } - } - - duration = int32(duration * mod); -} - -void Unit::ApplyDiminishingAura( DiminishingGroup group, bool apply ) -{ - // Checking for existing in the table - for(Diminishing::iterator i = m_Diminishing.begin(); i != m_Diminishing.end(); ++i) - { - if(i->DRGroup != group) - continue; - - i->hitTime = getMSTime(); - - if(apply) - i->stack += 1; - else if(i->stack) - i->stack -= 1; - - break; - } -} - -Unit* Unit::GetUnit(WorldObject& object, uint64 guid) -{ - return ObjectAccessor::GetUnit(object,guid); -} - -bool Unit::isVisibleForInState( Player const* u, bool inVisibleList ) const -{ - return isVisibleForOrDetect(u,false,inVisibleList); -} - -uint32 Unit::GetCreatureType() const -{ - if(GetTypeId() == TYPEID_PLAYER) - { - SpellShapeshiftEntry const* ssEntry = sSpellShapeshiftStore.LookupEntry(((Player*)this)->m_form); - if(ssEntry && ssEntry->creatureType > 0) - return ssEntry->creatureType; - else - return CREATURE_TYPE_HUMANOID; - } - else - return ((Creature*)this)->GetCreatureInfo()->type; -} - -/*####################################### -######## ######## -######## STAT SYSTEM ######## -######## ######## -#######################################*/ - -bool Unit::HandleStatModifier(UnitMods unitMod, UnitModifierType modifierType, float amount, bool apply) -{ - if(unitMod >= UNIT_MOD_END || modifierType >= MODIFIER_TYPE_END) - { - sLog.outError("ERROR in HandleStatModifier(): nonexisted UnitMods or wrong UnitModifierType!"); - return false; - } - - float val = 1.0f; - - switch(modifierType) - { - case BASE_VALUE: - case TOTAL_VALUE: - m_auraModifiersGroup[unitMod][modifierType] += apply ? amount : -amount; - break; - case BASE_PCT: - case TOTAL_PCT: - if(amount <= -100.0f) //small hack-fix for -100% modifiers - amount = -200.0f; - - val = (100.0f + amount) / 100.0f; - m_auraModifiersGroup[unitMod][modifierType] *= apply ? val : (1.0f/val); - break; - - default: - break; - } - - if(!CanModifyStats()) - return false; - - switch(unitMod) - { - case UNIT_MOD_STAT_STRENGTH: - case UNIT_MOD_STAT_AGILITY: - case UNIT_MOD_STAT_STAMINA: - case UNIT_MOD_STAT_INTELLECT: - case UNIT_MOD_STAT_SPIRIT: UpdateStats(GetStatByAuraGroup(unitMod)); break; - - case UNIT_MOD_ARMOR: UpdateArmor(); break; - case UNIT_MOD_HEALTH: UpdateMaxHealth(); break; - - case UNIT_MOD_MANA: - case UNIT_MOD_RAGE: - case UNIT_MOD_FOCUS: - case UNIT_MOD_ENERGY: - case UNIT_MOD_HAPPINESS: UpdateMaxPower(GetPowerTypeByAuraGroup(unitMod)); break; - - case UNIT_MOD_RESISTANCE_HOLY: - case UNIT_MOD_RESISTANCE_FIRE: - case UNIT_MOD_RESISTANCE_NATURE: - case UNIT_MOD_RESISTANCE_FROST: - case UNIT_MOD_RESISTANCE_SHADOW: - case UNIT_MOD_RESISTANCE_ARCANE: UpdateResistances(GetSpellSchoolByAuraGroup(unitMod)); break; - - case UNIT_MOD_ATTACK_POWER: UpdateAttackPowerAndDamage(); break; - case UNIT_MOD_ATTACK_POWER_RANGED: UpdateAttackPowerAndDamage(true); break; - - case UNIT_MOD_DAMAGE_MAINHAND: UpdateDamagePhysical(BASE_ATTACK); break; - case UNIT_MOD_DAMAGE_OFFHAND: UpdateDamagePhysical(OFF_ATTACK); break; - case UNIT_MOD_DAMAGE_RANGED: UpdateDamagePhysical(RANGED_ATTACK); break; - - default: - break; - } - - return true; -} - -float Unit::GetModifierValue(UnitMods unitMod, UnitModifierType modifierType) const -{ - if( unitMod >= UNIT_MOD_END || modifierType >= MODIFIER_TYPE_END) - { - sLog.outError("ERROR: trial to access nonexisted modifier value from UnitMods!"); - return 0.0f; - } - - if(modifierType == TOTAL_PCT && m_auraModifiersGroup[unitMod][modifierType] <= 0.0f) - return 0.0f; - - return m_auraModifiersGroup[unitMod][modifierType]; -} - -float Unit::GetTotalStatValue(Stats stat) const -{ - UnitMods unitMod = UnitMods(UNIT_MOD_STAT_START + stat); - - if(m_auraModifiersGroup[unitMod][TOTAL_PCT] <= 0.0f) - return 0.0f; - - // value = ((base_value * base_pct) + total_value) * total_pct - float value = m_auraModifiersGroup[unitMod][BASE_VALUE] + GetCreateStat(stat); - value *= m_auraModifiersGroup[unitMod][BASE_PCT]; - value += m_auraModifiersGroup[unitMod][TOTAL_VALUE]; - value *= m_auraModifiersGroup[unitMod][TOTAL_PCT]; - - return value; -} - -float Unit::GetTotalAuraModValue(UnitMods unitMod) const -{ - if(unitMod >= UNIT_MOD_END) - { - sLog.outError("ERROR: trial to access nonexisted UnitMods in GetTotalAuraModValue()!"); - return 0.0f; - } - - if(m_auraModifiersGroup[unitMod][TOTAL_PCT] <= 0.0f) - return 0.0f; - - float value = m_auraModifiersGroup[unitMod][BASE_VALUE]; - value *= m_auraModifiersGroup[unitMod][BASE_PCT]; - value += m_auraModifiersGroup[unitMod][TOTAL_VALUE]; - value *= m_auraModifiersGroup[unitMod][TOTAL_PCT]; - - return value; -} - -SpellSchools Unit::GetSpellSchoolByAuraGroup(UnitMods unitMod) const -{ - SpellSchools school = SPELL_SCHOOL_NORMAL; - - switch(unitMod) - { - case UNIT_MOD_RESISTANCE_HOLY: school = SPELL_SCHOOL_HOLY; break; - case UNIT_MOD_RESISTANCE_FIRE: school = SPELL_SCHOOL_FIRE; break; - case UNIT_MOD_RESISTANCE_NATURE: school = SPELL_SCHOOL_NATURE; break; - case UNIT_MOD_RESISTANCE_FROST: school = SPELL_SCHOOL_FROST; break; - case UNIT_MOD_RESISTANCE_SHADOW: school = SPELL_SCHOOL_SHADOW; break; - case UNIT_MOD_RESISTANCE_ARCANE: school = SPELL_SCHOOL_ARCANE; break; - - default: - break; - } - - return school; -} - -Stats Unit::GetStatByAuraGroup(UnitMods unitMod) const -{ - Stats stat = STAT_STRENGTH; - - switch(unitMod) - { - case UNIT_MOD_STAT_STRENGTH: stat = STAT_STRENGTH; break; - case UNIT_MOD_STAT_AGILITY: stat = STAT_AGILITY; break; - case UNIT_MOD_STAT_STAMINA: stat = STAT_STAMINA; break; - case UNIT_MOD_STAT_INTELLECT: stat = STAT_INTELLECT; break; - case UNIT_MOD_STAT_SPIRIT: stat = STAT_SPIRIT; break; - - default: - break; - } - - return stat; -} - -Powers Unit::GetPowerTypeByAuraGroup(UnitMods unitMod) const -{ - Powers power = POWER_MANA; - - switch(unitMod) - { - case UNIT_MOD_MANA: power = POWER_MANA; break; - case UNIT_MOD_RAGE: power = POWER_RAGE; break; - case UNIT_MOD_FOCUS: power = POWER_FOCUS; break; - case UNIT_MOD_ENERGY: power = POWER_ENERGY; break; - case UNIT_MOD_HAPPINESS: power = POWER_HAPPINESS; break; - - default: - break; - } - - return power; -} - -float Unit::GetTotalAttackPowerValue(WeaponAttackType attType) const -{ - UnitMods unitMod = (attType == RANGED_ATTACK) ? UNIT_MOD_ATTACK_POWER_RANGED : UNIT_MOD_ATTACK_POWER; - - float val = GetTotalAuraModValue(unitMod); - if(val < 0.0f) - val = 0.0f; - - return val; -} - -float Unit::GetWeaponDamageRange(WeaponAttackType attType ,WeaponDamageRange type) const -{ - if (attType == OFF_ATTACK && !haveOffhandWeapon()) - return 0.0f; - - return m_weaponDamage[attType][type]; -} - -void Unit::SetLevel(uint32 lvl) -{ - SetUInt32Value(UNIT_FIELD_LEVEL, lvl); - - // group update - if ((GetTypeId() == TYPEID_PLAYER) && ((Player*)this)->GetGroup()) - ((Player*)this)->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_LEVEL); -} - -void Unit::SetHealth(uint32 val) -{ - uint32 maxHealth = GetMaxHealth(); - if(maxHealth < val) - val = maxHealth; - - SetUInt32Value(UNIT_FIELD_HEALTH, val); - - // group update - if(GetTypeId() == TYPEID_PLAYER) - { - if(((Player*)this)->GetGroup()) - ((Player*)this)->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_CUR_HP); - } - else if(((Creature*)this)->isPet()) - { - Pet *pet = ((Pet*)this); - if(pet->isControlled()) - { - Unit *owner = GetOwner(); - if(owner && (owner->GetTypeId() == TYPEID_PLAYER) && ((Player*)owner)->GetGroup()) - ((Player*)owner)->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_PET_CUR_HP); - } - } -} - -void Unit::SetMaxHealth(uint32 val) -{ - uint32 health = GetHealth(); - SetUInt32Value(UNIT_FIELD_MAXHEALTH, val); - - // group update - if(GetTypeId() == TYPEID_PLAYER) - { - if(((Player*)this)->GetGroup()) - ((Player*)this)->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_MAX_HP); - } - else if(((Creature*)this)->isPet()) - { - Pet *pet = ((Pet*)this); - if(pet->isControlled()) - { - Unit *owner = GetOwner(); - if(owner && (owner->GetTypeId() == TYPEID_PLAYER) && ((Player*)owner)->GetGroup()) - ((Player*)owner)->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_PET_MAX_HP); - } - } - - if(val < health) - SetHealth(val); -} - -void Unit::SetPower(Powers power, uint32 val) -{ - uint32 maxPower = GetMaxPower(power); - if(maxPower < val) - val = maxPower; - - SetStatInt32Value(UNIT_FIELD_POWER1 + power, val); - - // group update - if(GetTypeId() == TYPEID_PLAYER) - { - if(((Player*)this)->GetGroup()) - ((Player*)this)->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_CUR_POWER); - } - else if(((Creature*)this)->isPet()) - { - Pet *pet = ((Pet*)this); - if(pet->isControlled()) - { - Unit *owner = GetOwner(); - if(owner && (owner->GetTypeId() == TYPEID_PLAYER) && ((Player*)owner)->GetGroup()) - ((Player*)owner)->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_PET_CUR_POWER); - } - - // Update the pet's character sheet with happiness damage bonus - if(pet->getPetType() == HUNTER_PET && power == POWER_HAPPINESS) - { - pet->UpdateDamagePhysical(BASE_ATTACK); - } - } -} - -void Unit::SetMaxPower(Powers power, uint32 val) -{ - uint32 cur_power = GetPower(power); - SetStatInt32Value(UNIT_FIELD_MAXPOWER1 + power, val); - - // group update - if(GetTypeId() == TYPEID_PLAYER) - { - if(((Player*)this)->GetGroup()) - ((Player*)this)->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_MAX_POWER); - } - else if(((Creature*)this)->isPet()) - { - Pet *pet = ((Pet*)this); - if(pet->isControlled()) - { - Unit *owner = GetOwner(); - if(owner && (owner->GetTypeId() == TYPEID_PLAYER) && ((Player*)owner)->GetGroup()) - ((Player*)owner)->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_PET_MAX_POWER); - } - } - - if(val < cur_power) - SetPower(power, val); -} - -void Unit::ApplyPowerMod(Powers power, uint32 val, bool apply) -{ - ApplyModUInt32Value(UNIT_FIELD_POWER1+power, val, apply); - - // group update - if(GetTypeId() == TYPEID_PLAYER) - { - if(((Player*)this)->GetGroup()) - ((Player*)this)->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_CUR_POWER); - } - else if(((Creature*)this)->isPet()) - { - Pet *pet = ((Pet*)this); - if(pet->isControlled()) - { - Unit *owner = GetOwner(); - if(owner && (owner->GetTypeId() == TYPEID_PLAYER) && ((Player*)owner)->GetGroup()) - ((Player*)owner)->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_PET_CUR_POWER); - } - } -} - -void Unit::ApplyMaxPowerMod(Powers power, uint32 val, bool apply) -{ - ApplyModUInt32Value(UNIT_FIELD_MAXPOWER1+power, val, apply); - - // group update - if(GetTypeId() == TYPEID_PLAYER) - { - if(((Player*)this)->GetGroup()) - ((Player*)this)->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_MAX_POWER); - } - else if(((Creature*)this)->isPet()) - { - Pet *pet = ((Pet*)this); - if(pet->isControlled()) - { - Unit *owner = GetOwner(); - if(owner && (owner->GetTypeId() == TYPEID_PLAYER) && ((Player*)owner)->GetGroup()) - ((Player*)owner)->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_PET_MAX_POWER); - } - } -} - -void Unit::ApplyAuraProcTriggerDamage( Aura* aura, bool apply ) -{ - AuraList& tAuraProcTriggerDamage = m_modAuras[SPELL_AURA_PROC_TRIGGER_DAMAGE]; - if(apply) - tAuraProcTriggerDamage.push_back(aura); - else - tAuraProcTriggerDamage.remove(aura); -} - -uint32 Unit::GetCreatePowers( Powers power ) const -{ - // POWER_FOCUS and POWER_HAPPINESS only have hunter pet - switch(power) - { - case POWER_MANA: return GetCreateMana(); - case POWER_RAGE: return 1000; - case POWER_FOCUS: return (GetTypeId()==TYPEID_PLAYER || !((Creature const*)this)->isPet() || ((Pet const*)this)->getPetType()!=HUNTER_PET ? 0 : 100); - case POWER_ENERGY: return 100; - case POWER_HAPPINESS: return (GetTypeId()==TYPEID_PLAYER || !((Creature const*)this)->isPet() || ((Pet const*)this)->getPetType()!=HUNTER_PET ? 0 : 1050000); - } - - return 0; -} - -void Unit::AddToWorld() -{ - Object::AddToWorld(); -} - -void Unit::RemoveFromWorld() -{ - // cleanup - if(IsInWorld()) - { - RemoveNotOwnSingleTargetAuras(); - } - - Object::RemoveFromWorld(); -} - -void Unit::CleanupsBeforeDelete() -{ - if(m_uint32Values) // only for fully created object - { - InterruptNonMeleeSpells(true); - m_Events.KillAllEvents(); - CombatStop(); - ClearComboPointHolders(); - DeleteThreatList(); - getHostilRefManager().setOnlineOfflineState(false); - RemoveAllAuras(); - RemoveAllGameObjects(); - RemoveAllDynObjects(); - GetMotionMaster()->Clear(false); // remove different non-standard movement generators. - } - RemoveFromWorld(); -} - -CharmInfo* Unit::InitCharmInfo(Unit *charm) -{ - if(!m_charmInfo) - m_charmInfo = new CharmInfo(charm); - return m_charmInfo; -} - -CharmInfo::CharmInfo(Unit* unit) -: m_unit(unit), m_CommandState(COMMAND_FOLLOW), m_ReactSate(REACT_PASSIVE), m_petnumber(0) -{ - for(int i =0; i<4; ++i) - { - m_charmspells[i].spellId = 0; - m_charmspells[i].active = ACT_DISABLED; - } -} - -void CharmInfo::InitPetActionBar() -{ - // the first 3 SpellOrActions are attack, follow and stay - for(uint32 i = 0; i < 3; i++) - { - PetActionBar[i].Type = ACT_COMMAND; - PetActionBar[i].SpellOrAction = COMMAND_ATTACK - i; - - PetActionBar[i + 7].Type = ACT_REACTION; - PetActionBar[i + 7].SpellOrAction = COMMAND_ATTACK - i; - } - for(uint32 i=0; i < 4; i++) - { - PetActionBar[i + 3].Type = ACT_DISABLED; - PetActionBar[i + 3].SpellOrAction = 0; - } -} - -void CharmInfo::InitEmptyActionBar() -{ - for(uint32 x = 1; x < 10; ++x) - { - PetActionBar[x].Type = ACT_CAST; - PetActionBar[x].SpellOrAction = 0; - } - PetActionBar[0].Type = ACT_COMMAND; - PetActionBar[0].SpellOrAction = COMMAND_ATTACK; -} - -void CharmInfo::InitPossessCreateSpells() -{ - if(m_unit->GetTypeId() == TYPEID_PLAYER) - return; - - InitEmptyActionBar(); //charm action bar - - for(uint32 x = 0; x < CREATURE_MAX_SPELLS; ++x) - { - if (IsPassiveSpell(((Creature*)m_unit)->m_spells[x])) - m_unit->CastSpell(m_unit, ((Creature*)m_unit)->m_spells[x], true); - else - AddSpellToAB(0, ((Creature*)m_unit)->m_spells[x], ACT_CAST); - } -} - -void CharmInfo::InitCharmCreateSpells() -{ - if(m_unit->GetTypeId() == TYPEID_PLAYER) //charmed players don't have spells - { - InitEmptyActionBar(); - return; - } - - InitPetActionBar(); - - for(uint32 x = 0; x < CREATURE_MAX_SPELLS; ++x) - { - uint32 spellId = ((Creature*)m_unit)->m_spells[x]; - m_charmspells[x].spellId = spellId; - - if(!spellId) - continue; - - if (IsPassiveSpell(spellId)) - { - m_unit->CastSpell(m_unit, spellId, true); - m_charmspells[x].active = ACT_PASSIVE; - } - else - { - ActiveStates newstate; - bool onlyselfcast = true; - SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellId); - - if(!spellInfo) onlyselfcast = false; - for(uint32 i = 0;i<3 && onlyselfcast;++i) //non existent spell will not make any problems as onlyselfcast would be false -> break right away - { - if(spellInfo->EffectImplicitTargetA[i] != TARGET_SELF && spellInfo->EffectImplicitTargetA[i] != 0) - onlyselfcast = false; - } - - if(onlyselfcast || !IsPositiveSpell(spellId)) //only self cast and spells versus enemies are autocastable - newstate = ACT_DISABLED; - else - newstate = ACT_CAST; - - AddSpellToAB(0, spellId, newstate); - } - } -} - -bool CharmInfo::AddSpellToAB(uint32 oldid, uint32 newid, ActiveStates newstate) -{ - for(uint8 i = 0; i < 10; i++) - { - if((PetActionBar[i].Type == ACT_DISABLED || PetActionBar[i].Type == ACT_ENABLED || PetActionBar[i].Type == ACT_CAST) && PetActionBar[i].SpellOrAction == oldid) - { - PetActionBar[i].SpellOrAction = newid; - if(!oldid) - { - if(newstate == ACT_DECIDE) - PetActionBar[i].Type = ACT_DISABLED; - else - PetActionBar[i].Type = newstate; - } - - return true; - } - } - return false; -} - -void CharmInfo::ToggleCreatureAutocast(uint32 spellid, bool apply) -{ - if(IsPassiveSpell(spellid)) - return; - - for(uint32 x = 0; x < CREATURE_MAX_SPELLS; ++x) - { - if(spellid == m_charmspells[x].spellId) - { - m_charmspells[x].active = apply ? ACT_ENABLED : ACT_DISABLED; - } - } -} - -void CharmInfo::SetPetNumber(uint32 petnumber, bool statwindow) -{ - m_petnumber = petnumber; - if(statwindow) - m_unit->SetUInt32Value(UNIT_FIELD_PETNUMBER, m_petnumber); - else - m_unit->SetUInt32Value(UNIT_FIELD_PETNUMBER, 0); -} - -bool Unit::isFrozen() const -{ - AuraList const& mRoot = GetAurasByType(SPELL_AURA_MOD_ROOT); - for(AuraList::const_iterator i = mRoot.begin(); i != mRoot.end(); ++i) - if( GetSpellSchoolMask((*i)->GetSpellProto()) & SPELL_SCHOOL_MASK_FROST) - return true; - return false; -} - -struct ProcTriggeredData -{ - ProcTriggeredData(SpellEntry const * _spellInfo, uint32 _spellParam, Aura* _triggeredByAura, uint32 _cooldown) - : spellInfo(_spellInfo), spellParam(_spellParam), triggeredByAura(_triggeredByAura), - triggeredByAura_SpellPair(Unit::spellEffectPair(triggeredByAura->GetId(),triggeredByAura->GetEffIndex())), - cooldown(_cooldown) - {} - - SpellEntry const * spellInfo; - uint32 spellParam; - Aura* triggeredByAura; - Unit::spellEffectPair triggeredByAura_SpellPair; - uint32 cooldown; -}; - -typedef std::list< ProcTriggeredData > ProcTriggeredList; - -void Unit::ProcDamageAndSpellFor( bool isVictim, Unit * pTarget, uint32 procFlag, AuraTypeSet const& procAuraTypes, WeaponAttackType attType, SpellEntry const * procSpell, uint32 damage, SpellSchoolMask damageSchoolMask ) -{ - for(AuraTypeSet::const_iterator aur = procAuraTypes.begin(); aur != procAuraTypes.end(); ++aur) - { - // List of spells (effects) that proceed. Spell prototype and aura-specific value (damage for TRIGGER_DAMAGE) - ProcTriggeredList procTriggered; - - AuraList const& auras = GetAurasByType(*aur); - for(AuraList::const_iterator i = auras.begin(), next; i != auras.end(); i = next) - { - next = i; ++next; - - SpellEntry const *spellProto = (*i)->GetSpellProto(); - if(!spellProto) - continue; - - SpellProcEventEntry const *spellProcEvent = spellmgr.GetSpellProcEvent(spellProto->Id); - if(!spellProcEvent) - { - // used to prevent spam in log about same non-handled spells - static std::set nonHandledSpellProcSet; - - if(spellProto->procFlags != 0 && nonHandledSpellProcSet.find(spellProto->Id)==nonHandledSpellProcSet.end()) - { - sLog.outError("ProcDamageAndSpell: spell %u (%s aura source) not have record in `spell_proc_event`)",spellProto->Id,(isVictim?"a victim's":"an attacker's")); - nonHandledSpellProcSet.insert(spellProto->Id); - } - - // spell.dbc use totally different flags, that only can create problems if used. - continue; - } - - // Check spellProcEvent data requirements - if(!SpellMgr::IsSpellProcEventCanTriggeredBy(spellProcEvent, procSpell,procFlag)) - continue; - - // Check if current equipment allows aura to proc - if(!isVictim && GetTypeId() == TYPEID_PLAYER ) - { - if(spellProto->EquippedItemClass == ITEM_CLASS_WEAPON) - { - Item *item = ((Player*)this)->GetWeaponForAttack(attType,true); - - if(!item || !((1<GetProto()->SubClass) & spellProto->EquippedItemSubClassMask)) - continue; - } - else if(spellProto->EquippedItemClass == ITEM_CLASS_ARMOR) - { - // Check if player is wearing shield - Item *item = ((Player*)this)->GetShield(true); - if(!item || !((1<GetProto()->SubClass) & spellProto->EquippedItemSubClassMask)) - continue; - } - } - - float chance = (float)spellProto->procChance; - - if(Player* modOwner = GetSpellModOwner()) - modOwner->ApplySpellMod(spellProto->Id,SPELLMOD_CHANCE_OF_SUCCESS,chance); - - if(!isVictim && spellProcEvent->ppmRate != 0) - { - uint32 WeaponSpeed = GetAttackTime(attType); - chance = GetPPMProcChance(WeaponSpeed, spellProcEvent->ppmRate); - } - - if(roll_chance_f(chance)) - { - uint32 cooldown = spellProcEvent->cooldown; - - uint32 i_spell_eff = (*i)->GetEffIndex(); - - int32 i_spell_param; - switch(*aur) - { - case SPELL_AURA_PROC_TRIGGER_SPELL: - i_spell_param = procFlag; - break; - case SPELL_AURA_DUMMY: - case SPELL_AURA_PRAYER_OF_MENDING: - case SPELL_AURA_MOD_HASTE: - i_spell_param = i_spell_eff; - break; - case SPELL_AURA_OVERRIDE_CLASS_SCRIPTS: - i_spell_param = (*i)->GetModifier()->m_miscvalue; - break; - default: - i_spell_param = (*i)->GetModifier()->m_amount; - break; - } - - procTriggered.push_back( ProcTriggeredData(spellProto,i_spell_param,*i, cooldown) ); - } - } - - // Handle effects proceed this time - for(ProcTriggeredList::iterator i = procTriggered.begin(); i != procTriggered.end(); ++i) - { - // Some auras can be deleted in function called in this loop (except first, ofc) - // Until storing auras in std::multimap to hard check deleting by another way - if(i != procTriggered.begin()) - { - bool found = false; - AuraMap::const_iterator lower = GetAuras().lower_bound(i->triggeredByAura_SpellPair); - AuraMap::const_iterator upper = GetAuras().upper_bound(i->triggeredByAura_SpellPair); - for(AuraMap::const_iterator itr = lower; itr!= upper; ++itr) - { - if(itr->second==i->triggeredByAura) - { - found = true; - break; - } - } - - if(!found) - { - sLog.outError("Spell aura %u (id:%u effect:%u) has been deleted before call spell proc event handler",*aur,i->triggeredByAura_SpellPair.first,i->triggeredByAura_SpellPair.second); - sLog.outError("It can be deleted one from early proccesed auras:"); - for(ProcTriggeredList::iterator i2 = procTriggered.begin(); i != i2; ++i2) - sLog.outError(" Spell aura %u (id:%u effect:%u)",*aur,i2->triggeredByAura_SpellPair.first,i2->triggeredByAura_SpellPair.second); - sLog.outError(" "); - continue; - } - } - - // save charges existence before processing to prevent crash at access to deleted triggered aura after - bool triggeredByAuraWithCharges = i->triggeredByAura->m_procCharges > 0; - - bool casted = false; - switch(*aur) - { - case SPELL_AURA_PROC_TRIGGER_SPELL: - { - sLog.outDebug("ProcDamageAndSpell: casting spell %u (triggered by %s aura of spell %u)", i->spellInfo->Id,(isVictim?"a victim's":"an attacker's"),i->triggeredByAura->GetId()); - casted = HandleProcTriggerSpell(pTarget, damage, i->triggeredByAura, procSpell,i->spellParam,attType,i->cooldown); - break; - } - case SPELL_AURA_PROC_TRIGGER_DAMAGE: - { - sLog.outDebug("ProcDamageAndSpell: doing %u damage from spell id %u (triggered by %s aura of spell %u)", i->spellParam, i->spellInfo->Id,(isVictim?"a victim's":"an attacker's"),i->triggeredByAura->GetId()); - uint32 damage = i->spellParam; - SpellNonMeleeDamageLog(pTarget, i->spellInfo->Id, damage, true, true); - casted = true; - break; - } - case SPELL_AURA_DUMMY: - { - sLog.outDebug("ProcDamageAndSpell: casting spell id %u (triggered by %s dummy aura of spell %u)", i->spellInfo->Id,(isVictim?"a victim's":"an attacker's"),i->triggeredByAura->GetId()); - casted = HandleDummyAuraProc(pTarget, i->spellInfo, i->spellParam, damage, i->triggeredByAura, procSpell, procFlag,i->cooldown); - break; - } - case SPELL_AURA_PRAYER_OF_MENDING: - { - sLog.outDebug("ProcDamageAndSpell(mending): casting spell id %u (triggered by %s dummy aura of spell %u)", i->spellInfo->Id,(isVictim?"a victim's":"an attacker's"),i->triggeredByAura->GetId()); - - // aura can be deleted at casts - int32 heal = i->triggeredByAura->GetModifier()->m_amount; - uint64 caster_guid = i->triggeredByAura->GetCasterGUID(); - - // jumps - int32 jumps = i->triggeredByAura->m_procCharges-1; - - // current aura expire - i->triggeredByAura->m_procCharges = 1; // will removed at next charges decrease - - // next target selection - if(jumps > 0 && GetTypeId()==TYPEID_PLAYER && IS_PLAYER_GUID(caster_guid)) - { - Aura* aura = i->triggeredByAura; - - SpellEntry const* spellProto = aura->GetSpellProto(); - uint32 effIdx = aura->GetEffIndex(); - - float radius; - if (spellProto->EffectRadiusIndex[effIdx]) - radius = GetSpellRadius(sSpellRadiusStore.LookupEntry(spellProto->EffectRadiusIndex[effIdx])); - else - radius = GetSpellMaxRange(sSpellRangeStore.LookupEntry(spellProto->rangeIndex)); - - if(Player* caster = ((Player*)aura->GetCaster())) - { - caster->ApplySpellMod(spellProto->Id, SPELLMOD_RADIUS, radius,NULL); - - if(Player* target = ((Player*)this)->GetNextRandomRaidMember(radius)) - { - // aura will applied from caster, but spell casted from current aura holder - SpellModifier *mod = new SpellModifier; - mod->op = SPELLMOD_CHARGES; - mod->value = jumps-5; // negative - mod->type = SPELLMOD_FLAT; - mod->spellId = spellProto->Id; - mod->effectId = effIdx; - mod->lastAffected = NULL; - mod->mask = spellProto->SpellFamilyFlags; - mod->charges = 0; - - caster->AddSpellMod(mod, true); - CastCustomSpell(target,spellProto->Id,&heal,NULL,NULL,true,NULL,aura,caster->GetGUID()); - caster->AddSpellMod(mod, false); - } - } - } - - // heal - CastCustomSpell(this,33110,&heal,NULL,NULL,true,NULL,NULL,caster_guid); - casted = true; - break; - } - case SPELL_AURA_MOD_HASTE: - { - sLog.outDebug("ProcDamageAndSpell: casting spell id %u (triggered by %s haste aura of spell %u)", i->spellInfo->Id,(isVictim?"a victim's":"an attacker's"),i->triggeredByAura->GetId()); - casted = HandleHasteAuraProc(pTarget, i->spellInfo, i->spellParam, damage, i->triggeredByAura, procSpell, procFlag,i->cooldown); - break; - } - case SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN: - { - // nothing do, just charges counter - // but count only in case appropriate school damage - casted = i->triggeredByAura->GetModifier()->m_miscvalue & damageSchoolMask; - break; - } - case SPELL_AURA_OVERRIDE_CLASS_SCRIPTS: - { - sLog.outDebug("ProcDamageAndSpell: casting spell id %u (triggered by %s aura of spell %u)", i->spellInfo->Id,(isVictim?"a victim's":"an attacker's"),i->triggeredByAura->GetId()); - casted = HandleOverrideClassScriptAuraProc(pTarget, i->spellParam, damage, i->triggeredByAura, procSpell,i->cooldown); - break; - } - default: - { - // nothing do, just charges counter - casted = true; - break; - } - } - - // Update charge (aura can be removed by triggers) - if(casted && triggeredByAuraWithCharges) - { - // need found aura (can be dropped by triggers) - AuraMap::const_iterator lower = GetAuras().lower_bound(i->triggeredByAura_SpellPair); - AuraMap::const_iterator upper = GetAuras().upper_bound(i->triggeredByAura_SpellPair); - for(AuraMap::const_iterator itr = lower; itr!= upper; ++itr) - { - if(itr->second == i->triggeredByAura) - { - if(i->triggeredByAura->m_procCharges > 0) - i->triggeredByAura->m_procCharges -= 1; - - i->triggeredByAura->UpdateAuraCharges(); - break; - } - } - } - } - - // Safely remove auras with zero charges - for(AuraList::const_iterator i = auras.begin(), next; i != auras.end(); i = next) - { - next = i; ++next; - if((*i)->m_procCharges == 0) - { - RemoveAurasDueToSpell((*i)->GetId()); - next = auras.begin(); - } - } - } -} - -SpellSchoolMask Unit::GetMeleeDamageSchoolMask() const -{ - return SPELL_SCHOOL_MASK_NORMAL; -} - -Player* Unit::GetSpellModOwner() -{ - if(GetTypeId()==TYPEID_PLAYER) - return (Player*)this; - if(((Creature*)this)->isPet() || ((Creature*)this)->isTotem()) - { - Unit* owner = GetOwner(); - if(owner && owner->GetTypeId()==TYPEID_PLAYER) - return (Player*)owner; - } - return NULL; -} - -///----------Pet responses methods----------------- -void Unit::SendPetCastFail(uint32 spellid, uint8 msg) -{ - Unit *owner = GetCharmerOrOwner(); - if(!owner || owner->GetTypeId() != TYPEID_PLAYER) - return; - - WorldPacket data(SMSG_PET_CAST_FAILED, (4+1)); - data << uint32(spellid); - data << uint8(msg); - ((Player*)owner)->GetSession()->SendPacket(&data); -} - -void Unit::SendPetActionFeedback (uint8 msg) -{ - Unit* owner = GetOwner(); - if(!owner || owner->GetTypeId() != TYPEID_PLAYER) - return; - - WorldPacket data(SMSG_PET_ACTION_FEEDBACK, 1); - data << uint8(msg); - ((Player*)owner)->GetSession()->SendPacket(&data); -} - -void Unit::SendPetTalk (uint32 pettalk) -{ - Unit* owner = GetOwner(); - if(!owner || owner->GetTypeId() != TYPEID_PLAYER) - return; - - WorldPacket data(SMSG_PET_ACTION_SOUND, 8+4); - data << uint64(GetGUID()); - data << uint32(pettalk); - ((Player*)owner)->GetSession()->SendPacket(&data); -} - -void Unit::SendPetSpellCooldown (uint32 spellid, time_t cooltime) -{ - Unit* owner = GetOwner(); - if(!owner || owner->GetTypeId() != TYPEID_PLAYER) - return; - - WorldPacket data(SMSG_SPELL_COOLDOWN, 8+1+4+4); - data << uint64(GetGUID()); - data << uint8(0x0); - data << uint32(spellid); - data << uint32(cooltime); - - ((Player*)owner)->GetSession()->SendPacket(&data); -} - -void Unit::SendPetClearCooldown (uint32 spellid) -{ - Unit* owner = GetOwner(); - if(!owner || owner->GetTypeId() != TYPEID_PLAYER) - return; - - WorldPacket data(SMSG_CLEAR_COOLDOWN, (4+8)); - data << uint32(spellid); - data << uint64(GetGUID()); - ((Player*)owner)->GetSession()->SendPacket(&data); -} - -void Unit::SendPetAIReaction(uint64 guid) -{ - Unit* owner = GetOwner(); - if(!owner || owner->GetTypeId() != TYPEID_PLAYER) - return; - - WorldPacket data(SMSG_AI_REACTION, 12); - data << uint64(guid) << uint32(00000002); - ((Player*)owner)->GetSession()->SendPacket(&data); -} - -///----------End of Pet responses methods---------- - -void Unit::StopMoving() -{ - clearUnitState(UNIT_STAT_MOVING); - - // send explicit stop packet - // rely on vmaps here because for exemple stormwind is in air - float z = MapManager::Instance().GetBaseMap(GetMapId())->GetHeight(GetPositionX(), GetPositionY(), GetPositionZ(), true); - //if (fabs(GetPositionZ() - z) < 2.0f) - // Relocate(GetPositionX(), GetPositionY(), z); - Relocate(GetPositionX(), GetPositionY(),GetPositionZ()); - - SendMonsterMove(GetPositionX(), GetPositionY(), GetPositionZ(), 0, true, 0); - - // update position and orientation; - WorldPacket data; - BuildHeartBeatMsg(&data); - SendMessageToSet(&data,false); -} - -void Unit::SetFeared(bool apply, uint64 casterGUID, uint32 spellID) -{ - if( apply ) - { - if(HasAuraType(SPELL_AURA_PREVENTS_FLEEING)) - return; - - SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_FLEEING); - - GetMotionMaster()->MovementExpired(false); - CastStop(GetGUID()==casterGUID ? spellID : 0); - - Unit* caster = ObjectAccessor::GetUnit(*this,casterGUID); - - GetMotionMaster()->MoveFleeing(caster); // caster==NULL processed in MoveFleeing - } - else - { - RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_FLEEING); - - GetMotionMaster()->MovementExpired(false); - - if( GetTypeId() != TYPEID_PLAYER && isAlive() ) - { - // restore appropriate movement generator - if(getVictim()) - GetMotionMaster()->MoveChase(getVictim()); - else - GetMotionMaster()->Initialize(); - - // attack caster if can - Unit* caster = ObjectAccessor::GetObjectInWorld(casterGUID, (Unit*)NULL); - if(caster && caster != getVictim() && ((Creature*)this)->AI()) - ((Creature*)this)->AI()->AttackStart(caster); - } - } - - if (GetTypeId() == TYPEID_PLAYER) - ((Player*)this)->SetClientControl(this, !apply); -} - -void Unit::SetConfused(bool apply, uint64 casterGUID, uint32 spellID) -{ - if( apply ) - { - SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_CONFUSED); - - CastStop(GetGUID()==casterGUID ? spellID : 0); - - GetMotionMaster()->MoveConfused(); - } - else - { - RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_CONFUSED); - - GetMotionMaster()->MovementExpired(false); - - if (GetTypeId() == TYPEID_UNIT) - { - // if in combat restore movement generator - if(getVictim()) - GetMotionMaster()->MoveChase(getVictim()); - } - } - - if(GetTypeId() == TYPEID_PLAYER) - ((Player*)this)->SetClientControl(this, !apply); -} - -bool Unit::IsSitState() const -{ - uint8 s = getStandState(); - return s == PLAYER_STATE_SIT_CHAIR || s == PLAYER_STATE_SIT_LOW_CHAIR || - s == PLAYER_STATE_SIT_MEDIUM_CHAIR || s == PLAYER_STATE_SIT_HIGH_CHAIR || - s == PLAYER_STATE_SIT; -} - -bool Unit::IsStandState() const -{ - uint8 s = getStandState(); - return !IsSitState() && s != PLAYER_STATE_SLEEP && s != PLAYER_STATE_KNEEL; -} - -void Unit::SetStandState(uint8 state) -{ - SetByteValue(UNIT_FIELD_BYTES_1, 0, state); - - if (IsStandState()) - RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_NOT_SEATED); - - if(GetTypeId()==TYPEID_PLAYER) - { - WorldPacket data(SMSG_STANDSTATE_UPDATE, 1); - data << (uint8)state; - ((Player*)this)->GetSession()->SendPacket(&data); - } -} - -bool Unit::IsPolymorphed() const -{ - return GetSpellSpecific(getTransForm())==SPELL_MAGE_POLYMORPH; -} - -void Unit::SetDisplayId(uint32 modelId) -{ - SetUInt32Value(UNIT_FIELD_DISPLAYID, modelId); - - if(GetTypeId() == TYPEID_UNIT && ((Creature*)this)->isPet()) - { - Pet *pet = ((Pet*)this); - if(!pet->isControlled()) - return; - Unit *owner = GetOwner(); - if(owner && (owner->GetTypeId() == TYPEID_PLAYER) && ((Player*)owner)->GetGroup()) - ((Player*)owner)->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_PET_MODEL_ID); - } -} - -void Unit::ClearComboPointHolders() -{ - while(!m_ComboPointHolders.empty()) - { - uint32 lowguid = *m_ComboPointHolders.begin(); - - Player* plr = objmgr.GetPlayer(MAKE_NEW_GUID(lowguid, 0, HIGHGUID_PLAYER)); - if(plr && plr->GetComboTarget()==GetGUID()) // recheck for safe - plr->ClearComboPoints(); // remove also guid from m_ComboPointHolders; - else - m_ComboPointHolders.erase(lowguid); // or remove manually - } -} - -void Unit::ClearAllReactives() -{ - - for(int i=0; i < MAX_REACTIVE; ++i) - m_reactiveTimer[i] = 0; - - if (HasAuraState( AURA_STATE_DEFENSE)) - ModifyAuraState(AURA_STATE_DEFENSE, false); - if (getClass() == CLASS_HUNTER && HasAuraState( AURA_STATE_HUNTER_PARRY)) - ModifyAuraState(AURA_STATE_HUNTER_PARRY, false); - if (HasAuraState( AURA_STATE_CRIT)) - ModifyAuraState(AURA_STATE_CRIT, false); - if (getClass() == CLASS_HUNTER && HasAuraState( AURA_STATE_HUNTER_CRIT_STRIKE) ) - ModifyAuraState(AURA_STATE_HUNTER_CRIT_STRIKE, false); - - if(getClass() == CLASS_WARRIOR && GetTypeId() == TYPEID_PLAYER) - ((Player*)this)->ClearComboPoints(); -} - -void Unit::UpdateReactives( uint32 p_time ) -{ - for(int i = 0; i < MAX_REACTIVE; ++i) - { - ReactiveType reactive = ReactiveType(i); - - if(!m_reactiveTimer[reactive]) - continue; - - if ( m_reactiveTimer[reactive] <= p_time) - { - m_reactiveTimer[reactive] = 0; - - switch ( reactive ) - { - case REACTIVE_DEFENSE: - if (HasAuraState(AURA_STATE_DEFENSE)) - ModifyAuraState(AURA_STATE_DEFENSE, false); - break; - case REACTIVE_HUNTER_PARRY: - if ( getClass() == CLASS_HUNTER && HasAuraState(AURA_STATE_HUNTER_PARRY)) - ModifyAuraState(AURA_STATE_HUNTER_PARRY, false); - break; - case REACTIVE_CRIT: - if (HasAuraState(AURA_STATE_CRIT)) - ModifyAuraState(AURA_STATE_CRIT, false); - break; - case REACTIVE_HUNTER_CRIT: - if ( getClass() == CLASS_HUNTER && HasAuraState(AURA_STATE_HUNTER_CRIT_STRIKE) ) - ModifyAuraState(AURA_STATE_HUNTER_CRIT_STRIKE, false); - break; - case REACTIVE_OVERPOWER: - if(getClass() == CLASS_WARRIOR && GetTypeId() == TYPEID_PLAYER) - ((Player*)this)->ClearComboPoints(); - break; - default: - break; - } - } - else - { - m_reactiveTimer[reactive] -= p_time; - } - } -} - -Unit* Unit::SelectNearbyTarget() const -{ - CellPair p(MaNGOS::ComputeCellPair(GetPositionX(), GetPositionY())); - Cell cell(p); - cell.data.Part.reserved = ALL_DISTRICT; - cell.SetNoCreate(); - - std::list targets; - - { - MaNGOS::AnyUnfriendlyUnitInObjectRangeCheck u_check(this, this, ATTACK_DISTANCE); - MaNGOS::UnitListSearcher searcher(targets, u_check); - - TypeContainerVisitor, WorldTypeMapContainer > world_unit_searcher(searcher); - TypeContainerVisitor, GridTypeMapContainer > grid_unit_searcher(searcher); - - CellLock cell_lock(cell, p); - cell_lock->Visit(cell_lock, world_unit_searcher, *MapManager::Instance().GetMap(GetMapId(), this)); - cell_lock->Visit(cell_lock, grid_unit_searcher, *MapManager::Instance().GetMap(GetMapId(), this)); - } - - // remove current target - if(getVictim()) - targets.remove(getVictim()); - - // remove not LoS targets - for(std::list::iterator tIter = targets.begin(); tIter != targets.end();) - { - if(!IsWithinLOSInMap(*tIter)) - { - std::list::iterator tIter2 = tIter; - ++tIter; - targets.erase(tIter2); - } - else - ++tIter; - } - - // no appropriate targets - if(targets.empty()) - return NULL; - - // select random - uint32 rIdx = urand(0,targets.size()-1); - std::list::const_iterator tcIter = targets.begin(); - for(uint32 i = 0; i < rIdx; ++i) - ++tcIter; - - return *tcIter; -} - -void Unit::ApplyAttackTimePercentMod( WeaponAttackType att,float val, bool apply ) -{ - if(val > 0) - { - ApplyPercentModFloatVar(m_modAttackSpeedPct[att], val, !apply); - ApplyPercentModFloatValue(UNIT_FIELD_BASEATTACKTIME+att,val,!apply); - } - else - { - ApplyPercentModFloatVar(m_modAttackSpeedPct[att], -val, apply); - ApplyPercentModFloatValue(UNIT_FIELD_BASEATTACKTIME+att,-val,apply); - } -} - -void Unit::ApplyCastTimePercentMod(float val, bool apply ) -{ - if(val > 0) - ApplyPercentModFloatValue(UNIT_MOD_CAST_SPEED,val,!apply); - else - ApplyPercentModFloatValue(UNIT_MOD_CAST_SPEED,-val,apply); -} - -uint32 Unit::GetCastingTimeForBonus( SpellEntry const *spellProto, DamageEffectType damagetype, uint32 CastingTime ) -{ - if (CastingTime > 7000) CastingTime = 7000; - if (CastingTime < 1500) CastingTime = 1500; - - if(damagetype == DOT && !IsChanneledSpell(spellProto)) - CastingTime = 3500; - - int32 overTime = 0; - uint8 effects = 0; - bool DirectDamage = false; - bool AreaEffect = false; - - for ( uint32 i=0; i<3;i++) - { - switch ( spellProto->Effect[i] ) - { - case SPELL_EFFECT_SCHOOL_DAMAGE: - case SPELL_EFFECT_POWER_DRAIN: - case SPELL_EFFECT_HEALTH_LEECH: - case SPELL_EFFECT_ENVIRONMENTAL_DAMAGE: - case SPELL_EFFECT_POWER_BURN: - case SPELL_EFFECT_HEAL: - DirectDamage = true; - break; - case SPELL_EFFECT_APPLY_AURA: - switch ( spellProto->EffectApplyAuraName[i] ) - { - case SPELL_AURA_PERIODIC_DAMAGE: - case SPELL_AURA_PERIODIC_HEAL: - case SPELL_AURA_PERIODIC_LEECH: - if ( GetSpellDuration(spellProto) ) - overTime = GetSpellDuration(spellProto); - break; - default: - // -5% per additional effect - ++effects; - break; - } - default: - break; - } - - if(IsAreaEffectTarget(Targets(spellProto->EffectImplicitTargetA[i])) || IsAreaEffectTarget(Targets(spellProto->EffectImplicitTargetB[i]))) - AreaEffect = true; - } - - // Combined Spells with Both Over Time and Direct Damage - if ( overTime > 0 && CastingTime > 0 && DirectDamage ) - { - // mainly for DoTs which are 3500 here otherwise - uint32 OriginalCastTime = GetSpellCastTime(spellProto); - if (OriginalCastTime > 7000) OriginalCastTime = 7000; - if (OriginalCastTime < 1500) OriginalCastTime = 1500; - // Portion to Over Time - float PtOT = (overTime / 15000.f) / ((overTime / 15000.f) + (OriginalCastTime / 3500.f)); - - if ( damagetype == DOT ) - CastingTime = uint32(CastingTime * PtOT); - else if ( PtOT < 1.0f ) - CastingTime = uint32(CastingTime * (1 - PtOT)); - else - CastingTime = 0; - } - - // Area Effect Spells receive only half of bonus - if ( AreaEffect ) - CastingTime /= 2; - - // -5% of total per any additional effect - for ( uint8 i=0; i 175 ) - { - CastingTime -= 175; - } - else - { - CastingTime = 0; - break; - } - } - - return CastingTime; -} - -void Unit::UpdateAuraForGroup(uint8 slot) -{ - if(GetTypeId() == TYPEID_PLAYER) - { - Player* player = (Player*)this; - if(player->GetGroup()) - { - player->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_AURAS); - player->SetAuraUpdateMask(slot); - } - } - else if(GetTypeId() == TYPEID_UNIT && ((Creature*)this)->isPet()) - { - Pet *pet = ((Pet*)this); - if(pet->isControlled()) - { - Unit *owner = GetOwner(); - if(owner && (owner->GetTypeId() == TYPEID_PLAYER) && ((Player*)owner)->GetGroup()) - { - ((Player*)owner)->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_PET_AURAS); - pet->SetAuraUpdateMask(slot); - } - } - } -} - -float Unit::GetAPMultiplier(WeaponAttackType attType, bool normalized) -{ - if (!normalized || GetTypeId() != TYPEID_PLAYER) - return float(GetAttackTime(attType))/1000.0f; - - Item *Weapon = ((Player*)this)->GetWeaponForAttack(attType); - if (!Weapon) - return 2.4; // fist attack - - switch (Weapon->GetProto()->InventoryType) - { - case INVTYPE_2HWEAPON: - return 3.3; - case INVTYPE_RANGED: - case INVTYPE_RANGEDRIGHT: - case INVTYPE_THROWN: - return 2.8; - case INVTYPE_WEAPON: - case INVTYPE_WEAPONMAINHAND: - case INVTYPE_WEAPONOFFHAND: - default: - return Weapon->GetProto()->SubClass==ITEM_SUBCLASS_WEAPON_DAGGER ? 1.7 : 2.4; - } -} - -Aura* Unit::GetDummyAura( uint32 spell_id ) const -{ - Unit::AuraList const& mDummy = GetAurasByType(SPELL_AURA_DUMMY); - for(Unit::AuraList::const_iterator itr = mDummy.begin(); itr != mDummy.end(); ++itr) - if ((*itr)->GetId() == spell_id) - return *itr; - - return NULL; -} - -bool Unit::IsUnderLastManaUseEffect() const -{ - return getMSTimeDiff(m_lastManaUse,getMSTime()) < 5000; -} - -void Unit::SetContestedPvP(Player *attackedPlayer) -{ - Player* player = GetCharmerOrOwnerPlayerOrPlayerItself(); - - if(!player || attackedPlayer && (attackedPlayer == player || player->duel && player->duel->opponent == attackedPlayer)) - return; - - player->SetContestedPvPTimer(30000); - if(!player->hasUnitState(UNIT_STAT_ATTACK_PLAYER)) - { - player->addUnitState(UNIT_STAT_ATTACK_PLAYER); - player->SetFlag(PLAYER_FLAGS, PLAYER_FLAGS_CONTESTED_PVP); - // call MoveInLineOfSight for nearby contested guards - SetVisibility(GetVisibility()); - } - if(!hasUnitState(UNIT_STAT_ATTACK_PLAYER)) - { - addUnitState(UNIT_STAT_ATTACK_PLAYER); - // call MoveInLineOfSight for nearby contested guards - SetVisibility(GetVisibility()); - } -} - -void Unit::AddPetAura(PetAura const* petSpell) -{ - m_petAuras.insert(petSpell); - if(Pet* pet = GetPet()) - pet->CastPetAura(petSpell); -} - -void Unit::RemovePetAura(PetAura const* petSpell) -{ - m_petAuras.erase(petSpell); - if(Pet* pet = GetPet()) - pet->RemoveAurasDueToSpell(petSpell->GetAura(pet->GetEntry())); -} +/* + * Copyright (C) 2005-2008 MaNGOS + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "Common.h" +#include "Log.h" +#include "Opcodes.h" +#include "WorldPacket.h" +#include "WorldSession.h" +#include "World.h" +#include "ObjectMgr.h" +#include "SpellMgr.h" +#include "Unit.h" +#include "QuestDef.h" +#include "Player.h" +#include "Creature.h" +#include "Spell.h" +#include "Group.h" +#include "SpellAuras.h" +#include "MapManager.h" +#include "ObjectAccessor.h" +#include "CreatureAI.h" +#include "Formulas.h" +#include "Pet.h" +#include "Util.h" +#include "Totem.h" +#include "BattleGround.h" +#include "InstanceSaveMgr.h" +#include "GridNotifiersImpl.h" +#include "CellImpl.h" +#include "Path.h" + +#include + +float baseMoveSpeed[MAX_MOVE_TYPE] = +{ + 2.5f, // MOVE_WALK + 7.0f, // MOVE_RUN + 1.25f, // MOVE_WALKBACK + 4.722222f, // MOVE_SWIM + 4.5f, // MOVE_SWIMBACK + 3.141594f, // MOVE_TURN + 7.0f, // MOVE_FLY + 4.5f, // MOVE_FLYBACK +}; + +// auraTypes contains attacker auras capable of proc'ing cast auras +static Unit::AuraTypeSet GenerateAttakerProcCastAuraTypes() +{ + static Unit::AuraTypeSet auraTypes; + auraTypes.insert(SPELL_AURA_DUMMY); + auraTypes.insert(SPELL_AURA_PROC_TRIGGER_SPELL); + auraTypes.insert(SPELL_AURA_MOD_HASTE); + auraTypes.insert(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS); + return auraTypes; +} + +// auraTypes contains victim auras capable of proc'ing cast auras +static Unit::AuraTypeSet GenerateVictimProcCastAuraTypes() +{ + static Unit::AuraTypeSet auraTypes; + auraTypes.insert(SPELL_AURA_DUMMY); + auraTypes.insert(SPELL_AURA_PRAYER_OF_MENDING); + auraTypes.insert(SPELL_AURA_PROC_TRIGGER_SPELL); + return auraTypes; +} + +// auraTypes contains auras capable of proc effect/damage (but not cast) for attacker +static Unit::AuraTypeSet GenerateAttakerProcEffectAuraTypes() +{ + static Unit::AuraTypeSet auraTypes; + auraTypes.insert(SPELL_AURA_MOD_DAMAGE_DONE); + auraTypes.insert(SPELL_AURA_PROC_TRIGGER_DAMAGE); + auraTypes.insert(SPELL_AURA_MOD_CASTING_SPEED); + auraTypes.insert(SPELL_AURA_MOD_RATING); + return auraTypes; +} + +// auraTypes contains auras capable of proc effect/damage (but not cast) for victim +static Unit::AuraTypeSet GenerateVictimProcEffectAuraTypes() +{ + static Unit::AuraTypeSet auraTypes; + auraTypes.insert(SPELL_AURA_MOD_RESISTANCE); + auraTypes.insert(SPELL_AURA_PROC_TRIGGER_DAMAGE); + auraTypes.insert(SPELL_AURA_MOD_PARRY_PERCENT); + auraTypes.insert(SPELL_AURA_MOD_BLOCK_PERCENT); + auraTypes.insert(SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN); + return auraTypes; +} + +static Unit::AuraTypeSet attackerProcCastAuraTypes = GenerateAttakerProcCastAuraTypes(); +static Unit::AuraTypeSet attackerProcEffectAuraTypes = GenerateAttakerProcEffectAuraTypes(); + +static Unit::AuraTypeSet victimProcCastAuraTypes = GenerateVictimProcCastAuraTypes(); +static Unit::AuraTypeSet victimProcEffectAuraTypes = GenerateVictimProcEffectAuraTypes(); + +// auraTypes contains auras capable of proc'ing for attacker and victim +static Unit::AuraTypeSet GenerateProcAuraTypes() +{ + Unit::AuraTypeSet auraTypes; + auraTypes.insert(attackerProcCastAuraTypes.begin(),attackerProcCastAuraTypes.end()); + auraTypes.insert(attackerProcEffectAuraTypes.begin(),attackerProcEffectAuraTypes.end()); + auraTypes.insert(victimProcCastAuraTypes.begin(),victimProcCastAuraTypes.end()); + auraTypes.insert(victimProcEffectAuraTypes.begin(),victimProcEffectAuraTypes.end()); + return auraTypes; +} + +static Unit::AuraTypeSet procAuraTypes = GenerateProcAuraTypes(); + +bool IsPassiveStackableSpell( uint32 spellId ) +{ + if(!IsPassiveSpell(spellId)) + return false; + + SpellEntry const* spellProto = sSpellStore.LookupEntry(spellId); + if(!spellProto) + return false; + + for(int j = 0; j < 3; ++j) + { + if(std::find(procAuraTypes.begin(),procAuraTypes.end(),spellProto->EffectApplyAuraName[j])!=procAuraTypes.end()) + return false; + } + + return true; +} + +Unit::Unit() +: WorldObject(), i_motionMaster(this), m_ThreatManager(this), m_HostilRefManager(this) +{ + m_objectType |= TYPEMASK_UNIT; + m_objectTypeId = TYPEID_UNIT; + // 2.3.2 - 0x70 + m_updateFlag = (UPDATEFLAG_HIGHGUID | UPDATEFLAG_LIVING | UPDATEFLAG_HASPOSITION); + + m_attackTimer[BASE_ATTACK] = 0; + m_attackTimer[OFF_ATTACK] = 0; + m_attackTimer[RANGED_ATTACK] = 0; + m_modAttackSpeedPct[BASE_ATTACK] = 1.0f; + m_modAttackSpeedPct[OFF_ATTACK] = 1.0f; + m_modAttackSpeedPct[RANGED_ATTACK] = 1.0f; + + m_extraAttacks = 0; + + m_state = 0; + m_form = FORM_NONE; + m_deathState = ALIVE; + + for (uint32 i = 0; i < CURRENT_MAX_SPELL; i++) + m_currentSpells[i] = NULL; + + m_addDmgOnce = 0; + + for(int i = 0; i < MAX_TOTEM; ++i) + m_TotemSlot[i] = 0; + + m_ObjectSlot[0] = m_ObjectSlot[1] = m_ObjectSlot[2] = m_ObjectSlot[3] = 0; + //m_Aura = NULL; + //m_AurasCheck = 2000; + //m_removeAuraTimer = 4; + //tmpAura = NULL; + waterbreath = false; + + m_Visibility = VISIBILITY_ON; + + m_detectInvisibilityMask = 0; + m_invisibilityMask = 0; + m_transform = 0; + m_ShapeShiftFormSpellId = 0; + m_canModifyStats = false; + + for (int i = 0; i < MAX_SPELL_IMMUNITY; i++) + m_spellImmune[i].clear(); + for (int i = 0; i < UNIT_MOD_END; i++) + { + m_auraModifiersGroup[i][BASE_VALUE] = 0.0f; + m_auraModifiersGroup[i][BASE_PCT] = 1.0f; + m_auraModifiersGroup[i][TOTAL_VALUE] = 0.0f; + m_auraModifiersGroup[i][TOTAL_PCT] = 1.0f; + } + // implement 50% base damage from offhand + m_auraModifiersGroup[UNIT_MOD_DAMAGE_OFFHAND][TOTAL_PCT] = 0.5f; + + for (int i = 0; i < 3; i++) + { + m_weaponDamage[i][MINDAMAGE] = BASE_MINDAMAGE; + m_weaponDamage[i][MAXDAMAGE] = BASE_MAXDAMAGE; + } + for (int i = 0; i < MAX_STATS; i++) + m_createStats[i] = 0.0f; + + m_attacking = NULL; + m_modMeleeHitChance = 0.0f; + m_modRangedHitChance = 0.0f; + m_modSpellHitChance = 0.0f; + m_baseSpellCritChance = 5; + + m_CombatTimer = 0; + m_lastManaUse = 0; + + //m_victimThreat = 0.0f; + for (int i = 0; i < MAX_SPELL_SCHOOL; ++i) + m_threatModifier[i] = 1.0f; + m_isSorted = true; + for (int i = 0; i < MAX_MOVE_TYPE; ++i) + m_speed_rate[i] = 1.0f; + + m_removedAuras = 0; + m_charmInfo = NULL; + m_unit_movement_flags = 0; + + // remove aurastates allowing special moves + for(int i=0; i < MAX_REACTIVE; ++i) + m_reactiveTimer[i] = 0; +} + +Unit::~Unit() +{ + // set current spells as deletable + for (uint32 i = 0; i < CURRENT_MAX_SPELL; i++) + { + // spell may be safely deleted now + if (m_currentSpells[i]) m_currentSpells[i]->SetDeletable(true); + m_currentSpells[i] = NULL; + } + + RemoveAllGameObjects(); + RemoveAllDynObjects(); + + if(m_charmInfo) delete m_charmInfo; +} + +void Unit::Update( uint32 p_time ) +{ + /*if(p_time > m_AurasCheck) + { + m_AurasCheck = 2000; + _UpdateAura(); + }else + m_AurasCheck -= p_time;*/ + + // WARNING! Order of execution here is important, do not change. + // Spells must be processed with event system BEFORE they go to _UpdateSpells. + // Or else we may have some SPELL_STATE_FINISHED spells stalled in pointers, that is bad. + m_Events.Update( p_time ); + _UpdateSpells( p_time ); + + // update combat timer only for players and pets + if (isInCombat() && (GetTypeId() == TYPEID_PLAYER || ((Creature*)this)->isPet() || ((Creature*)this)->isCharmed())) + { + // Check UNIT_STAT_MELEE_ATTACKING or UNIT_STAT_CHASE (without UNIT_STAT_FOLLOW in this case) so pets can reach far away + // targets without stopping half way there and running off. + // These flags are reset after target dies or another command is given. + if( m_HostilRefManager.isEmpty() ) + { + // m_CombatTimer set at aura start and it will be freeze until aura removing + if ( m_CombatTimer <= p_time ) + ClearInCombat(); + else + m_CombatTimer -= p_time; + } + } + + if(uint32 base_att = getAttackTimer(BASE_ATTACK)) + { + setAttackTimer(BASE_ATTACK, (p_time >= base_att ? 0 : base_att - p_time) ); + } + + // update abilities available only for fraction of time + UpdateReactives( p_time ); + + ModifyAuraState(AURA_STATE_HEALTHLESS_20_PERCENT, GetHealth() < GetMaxHealth()*0.20f); + ModifyAuraState(AURA_STATE_HEALTHLESS_35_PERCENT, GetHealth() < GetMaxHealth()*0.35f); + + i_motionMaster.UpdateMotion(p_time); +} + +bool Unit::haveOffhandWeapon() const +{ + if(GetTypeId() == TYPEID_PLAYER) + return ((Player*)this)->GetWeaponForAttack(OFF_ATTACK,true); + else + return false; +} + +void Unit::SendMonsterMoveWithSpeedToCurrentDestination(Player* player) +{ + float x, y, z; + if(GetMotionMaster()->GetDestination(x, y, z)) + SendMonsterMoveWithSpeed(x, y, z, GetUnitMovementFlags(), 0, player); +} + +void Unit::SendMonsterMoveWithSpeed(float x, float y, float z, uint32 MovementFlags, uint32 transitTime, Player* player) +{ + if (!transitTime) + { + float dx = x - GetPositionX(); + float dy = y - GetPositionY(); + float dz = z - GetPositionZ(); + + float dist = ((dx*dx) + (dy*dy) + (dz*dz)); + if(dist<0) + dist = 0; + else + dist = sqrt(dist); + + double speed = GetSpeed((MovementFlags & MOVEMENTFLAG_WALK_MODE) ? MOVE_WALK : MOVE_RUN); + if(speed<=0) + speed = 2.5f; + speed *= 0.001f; + transitTime = static_cast(dist / speed + 0.5); + } + //float orientation = (float)atan2((double)dy, (double)dx); + SendMonsterMove(x, y, z, 0, MovementFlags, transitTime, player); +} + +void Unit::SendMonsterMove(float NewPosX, float NewPosY, float NewPosZ, uint8 type, uint32 MovementFlags, uint32 Time, Player* player) +{ + WorldPacket data( SMSG_MONSTER_MOVE, (41 + GetPackGUID().size()) ); + data.append(GetPackGUID()); + + // Point A, starting location + data << GetPositionX() << GetPositionY() << GetPositionZ(); + // unknown field - unrelated to orientation + // seems to increment about 1000 for every 1.7 seconds + // for now, we'll just use mstime + data << getMSTime(); + + data << uint8(type); // unknown + switch(type) + { + case 0: // normal packet + break; + case 1: // stop packet + SendMessageToSet( &data, true ); + return; + case 3: // not used currently + data << uint64(0); // probably target guid + break; + case 4: // not used currently + data << float(0); // probably orientation + break; + } + + //Movement Flags (0x0 = walk, 0x100 = run, 0x200 = fly/swim) + data << uint32(MovementFlags); + + data << Time; // Time in between points + data << uint32(1); // 1 single waypoint + data << NewPosX << NewPosY << NewPosZ; // the single waypoint Point B + + if(player) + player->GetSession()->SendPacket(&data); + else + SendMessageToSet( &data, true ); +} + +void Unit::SendMonsterMoveByPath(Path const& path, uint32 start, uint32 end, uint32 MovementFlags) +{ + uint32 traveltime = uint32(path.GetTotalLength(start, end) * 32); + + uint32 pathSize = end-start; + + WorldPacket data( SMSG_MONSTER_MOVE, (GetPackGUID().size()+4+4+4+4+1+4+4+4+pathSize*4*3) ); + data.append(GetPackGUID()); + data << GetPositionX( ) + << GetPositionY( ) + << GetPositionZ( ); + data << GetOrientation( ); + data << uint8( 0 ); + data << uint32( MovementFlags ); + data << uint32( traveltime ); + data << uint32( pathSize ); + data.append( (char*)path.GetNodes(start), pathSize * 4 * 3 ); + + //WPAssert( data.size() == 37 + pathnodes.Size( ) * 4 * 3 ); + SendMessageToSet(&data, true); +} + +void Unit::resetAttackTimer(WeaponAttackType type) +{ + m_attackTimer[type] = uint32(GetAttackTime(type) * m_modAttackSpeedPct[type]); +} + +bool Unit::canReachWithAttack(Unit *pVictim) const +{ + assert(pVictim); + float reach = GetFloatValue(UNIT_FIELD_COMBATREACH); + if( reach <= 0.0f ) + reach = 1.0f; + return IsWithinDistInMap(pVictim, reach); +} + +void Unit::RemoveSpellsCausingAura(AuraType auraType) +{ + if (auraType >= TOTAL_AURAS) return; + AuraList::iterator iter, next; + for (iter = m_modAuras[auraType].begin(); iter != m_modAuras[auraType].end(); iter = next) + { + next = iter; + ++next; + + if (*iter) + { + RemoveAurasDueToSpell((*iter)->GetId()); + if (!m_modAuras[auraType].empty()) + next = m_modAuras[auraType].begin(); + else + return; + } + } +} + +bool Unit::HasAuraType(AuraType auraType) const +{ + return (!m_modAuras[auraType].empty()); +} + +/* Called by DealDamage for auras that have a chance to be dispelled on damage taken. */ +void Unit::RemoveSpellbyDamageTaken(AuraType auraType, uint32 damage) +{ + if(!HasAuraType(auraType)) + return; + + // The chance to dispell an aura depends on the damage taken with respect to the casters level. + uint32 max_dmg = getLevel() > 8 ? 25 * getLevel() - 150 : 50; + float chance = float(damage) / max_dmg * 100.0f; + if (roll_chance_f(chance)) + RemoveSpellsCausingAura(auraType); +} + +uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDamage, DamageEffectType damagetype, SpellSchoolMask damageSchoolMask, SpellEntry const *spellProto, bool durabilityLoss) +{ + if (!pVictim->isAlive() || pVictim->isInFlight() || pVictim->GetTypeId() == TYPEID_UNIT && ((Creature*)pVictim)->IsInEvadeMode()) + return 0; + + //You don't lose health from damage taken from another player while in a sanctuary + //You still see it in the combat log though + if(pVictim != this && GetTypeId() == TYPEID_PLAYER && pVictim->GetTypeId() == TYPEID_PLAYER) + { + const AreaTableEntry *area = GetAreaEntryByAreaID(pVictim->GetAreaId()); + if(area && area->flags & AREA_FLAG_SANCTUARY) //sanctuary + return 0; + } + + // remove affects from victim (including from 0 damage and DoTs) + if(pVictim != this) + pVictim->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); + + // remove affects from attacker at any non-DoT damage (including 0 damage) + if( damagetype != DOT) + { + RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); + RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH); + + if(pVictim != this) + RemoveSpellsCausingAura(SPELL_AURA_MOD_INVISIBILITY); + + if(pVictim->GetTypeId() == TYPEID_PLAYER && !pVictim->IsStandState() && !pVictim->hasUnitState(UNIT_STAT_STUNDED)) + pVictim->SetStandState(PLAYER_STATE_NONE); + } + + //Script Event damage Deal + if( GetTypeId()== TYPEID_UNIT && ((Creature *)this)->AI()) + ((Creature *)this)->AI()->DamageDeal(pVictim, damage); + //Script Event damage taken + if( pVictim->GetTypeId()== TYPEID_UNIT && ((Creature *)pVictim)->AI() ) + ((Creature *)pVictim)->AI()->DamageTaken(this, damage); + + if(!damage) + { + // Rage from physical damage received . + if(cleanDamage && cleanDamage->damage && (damageSchoolMask & SPELL_SCHOOL_MASK_NORMAL) && pVictim->GetTypeId() == TYPEID_PLAYER && (pVictim->getPowerType() == POWER_RAGE)) + ((Player*)pVictim)->RewardRage(cleanDamage->damage, 0, false); + + return 0; + } + + pVictim->RemoveSpellbyDamageTaken(SPELL_AURA_MOD_FEAR, damage); + // root type spells do not dispell the root effect + if(!spellProto || spellProto->Mechanic != MECHANIC_ROOT) + pVictim->RemoveSpellbyDamageTaken(SPELL_AURA_MOD_ROOT, damage); + + if(pVictim->GetTypeId() != TYPEID_PLAYER) + { + // no xp,health if type 8 /critters/ + if ( pVictim->GetCreatureType() == CREATURE_TYPE_CRITTER) + { + pVictim->setDeathState(JUST_DIED); + pVictim->SetHealth(0); + + // allow loot only if has loot_id in creature_template + CreatureInfo const* cInfo = ((Creature*)pVictim)->GetCreatureInfo(); + if(cInfo && cInfo->lootid) + pVictim->SetUInt32Value(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE); + + // some critters required for quests + if(GetTypeId() == TYPEID_PLAYER) + ((Player*)this)->KilledMonster(pVictim->GetEntry(),pVictim->GetGUID()); + + return damage; + } + + if(!pVictim->isInCombat() && ((Creature*)pVictim)->AI()) + ((Creature*)pVictim)->AI()->AttackStart(this); + } + + DEBUG_LOG("DealDamageStart"); + + uint32 health = pVictim->GetHealth(); + sLog.outDetail("deal dmg:%d to health:%d ",damage,health); + + // duel ends when player has 1 or less hp + bool duel_hasEnded = false; + if(pVictim->GetTypeId() == TYPEID_PLAYER && ((Player*)pVictim)->duel && damage >= (health-1)) + { + // prevent kill only if killed in duel and killed by opponent or opponent controlled creature + if(((Player*)pVictim)->duel->opponent==this || ((Player*)pVictim)->duel->opponent->GetGUID() == GetOwnerGUID()) + damage = health-1; + + duel_hasEnded = true; + } + //Get in CombatState + if(pVictim != this && damagetype != DOT) + { + SetInCombatWith(pVictim); + pVictim->SetInCombatWith(this); + + if(Player* attackedPlayer = pVictim->GetCharmerOrOwnerPlayerOrPlayerItself()) + SetContestedPvP(attackedPlayer); + } + + // Rage from Damage made (only from direct weapon damage) + if( cleanDamage && damagetype==DIRECT_DAMAGE && this != pVictim && GetTypeId() == TYPEID_PLAYER && (getPowerType() == POWER_RAGE)) + { + uint32 weaponSpeedHitFactor; + + switch(cleanDamage->attackType) + { + case BASE_ATTACK: + { + if(cleanDamage->hitOutCome == MELEE_HIT_CRIT) + weaponSpeedHitFactor = uint32(GetAttackTime(cleanDamage->attackType)/1000.0f * 7); + else + weaponSpeedHitFactor = uint32(GetAttackTime(cleanDamage->attackType)/1000.0f * 3.5f); + + ((Player*)this)->RewardRage(damage, weaponSpeedHitFactor, true); + + break; + } + case OFF_ATTACK: + { + if(cleanDamage->hitOutCome == MELEE_HIT_CRIT) + weaponSpeedHitFactor = uint32(GetAttackTime(cleanDamage->attackType)/1000.0f * 3.5f); + else + weaponSpeedHitFactor = uint32(GetAttackTime(cleanDamage->attackType)/1000.0f * 1.75f); + + ((Player*)this)->RewardRage(damage, weaponSpeedHitFactor, true); + + break; + } + case RANGED_ATTACK: + break; + } + } + + if(pVictim->GetTypeId() == TYPEID_PLAYER && GetTypeId() == TYPEID_PLAYER) + { + if(((Player*)pVictim)->InBattleGround()) + { + Player *killer = ((Player*)this); + if(killer != ((Player*)pVictim)) + if(BattleGround *bg = killer->GetBattleGround()) + bg->UpdatePlayerScore(killer, SCORE_DAMAGE_DONE, damage); + } + } + + if (pVictim->GetTypeId() == TYPEID_UNIT && !((Creature*)pVictim)->isPet() && !((Creature*)pVictim)->hasLootRecipient()) + ((Creature*)pVictim)->SetLootRecipient(this); + if (health <= damage) + { + // battleground things + if(pVictim->GetTypeId() == TYPEID_PLAYER && (((Player*)pVictim)->InBattleGround())) + { + Player *killed = ((Player*)pVictim); + Player *killer = NULL; + if(GetTypeId() == TYPEID_PLAYER) + killer = ((Player*)this); + else if(GetTypeId() == TYPEID_UNIT && ((Creature*)this)->isPet()) + { + Unit *owner = GetOwner(); + if(owner && owner->GetTypeId() == TYPEID_PLAYER) + killer = ((Player*)owner); + } + + if(killer) + if(BattleGround *bg = killed->GetBattleGround()) + bg->HandleKillPlayer(killed, killer); // drop flags and etc + } + + DEBUG_LOG("DealDamage: victim just died"); + + // find player: owner of controlled `this` or `this` itself maybe + Player *player = GetCharmerOrOwnerPlayerOrPlayerItself(); + + if(pVictim->GetTypeId() == TYPEID_UNIT && ((Creature*)pVictim)->GetLootRecipient()) + player = ((Creature*)pVictim)->GetLootRecipient(); + // Reward player, his pets, and group/raid members + // call kill spell proc event (before real die and combat stop to triggering auras removed at death/combat stop) + if(player && player!=pVictim) + if(player->RewardPlayerAndGroupAtKill(pVictim)) + player->ProcDamageAndSpell(pVictim,PROC_FLAG_KILL_XP_GIVER,PROC_FLAG_NONE); + + DEBUG_LOG("DealDamageAttackStop"); + + // stop combat + pVictim->CombatStop(); + pVictim->getHostilRefManager().deleteReferences(); + + bool damageFromSpiritOfRedemtionTalent = spellProto && spellProto->Id == 27795; + + // if talent known but not triggered (check priest class for speedup check) + Aura* spiritOfRedemtionTalentReady = NULL; + if( !damageFromSpiritOfRedemtionTalent && // not called from SPELL_AURA_SPIRIT_OF_REDEMPTION + pVictim->GetTypeId()==TYPEID_PLAYER && pVictim->getClass()==CLASS_PRIEST ) + { + AuraList const& vDummyAuras = pVictim->GetAurasByType(SPELL_AURA_DUMMY); + for(AuraList::const_iterator itr = vDummyAuras.begin(); itr != vDummyAuras.end(); ++itr) + { + if((*itr)->GetSpellProto()->SpellIconID==1654) + { + spiritOfRedemtionTalentReady = *itr; + break; + } + } + } + + DEBUG_LOG("SET JUST_DIED"); + if(!spiritOfRedemtionTalentReady) + pVictim->setDeathState(JUST_DIED); + + DEBUG_LOG("DealDamageHealth1"); + + if(spiritOfRedemtionTalentReady) + { + // save value before aura remove + uint32 ressSpellId = pVictim->GetUInt32Value(PLAYER_SELF_RES_SPELL); + if(!ressSpellId) + ressSpellId = ((Player*)pVictim)->GetResurrectionSpellId(); + + //Remove all expected to remove at death auras (most important negative case like DoT or periodic triggers) + pVictim->RemoveAllAurasOnDeath(); + + // restore for use at real death + pVictim->SetUInt32Value(PLAYER_SELF_RES_SPELL,ressSpellId); + + // FORM_SPIRITOFREDEMPTION and related auras + pVictim->CastSpell(pVictim,27827,true,NULL,spiritOfRedemtionTalentReady); + } + else + pVictim->SetHealth(0); + + // remember victim PvP death for corpse type and corpse reclaim delay + // at original death (not at SpiritOfRedemtionTalent timeout) + if( pVictim->GetTypeId()==TYPEID_PLAYER && !damageFromSpiritOfRedemtionTalent ) + ((Player*)pVictim)->SetPvPDeath(player!=NULL); + + // Call KilledUnit for creatures + if (GetTypeId() == TYPEID_UNIT && ((Creature*)this)->AI()) + ((Creature*)this)->AI()->KilledUnit(pVictim); + + // 10% durability loss on death + // clean InHateListOf + if (pVictim->GetTypeId() == TYPEID_PLAYER) + { + // only if not player and not controlled by player pet. And not at BG + if (durabilityLoss && !player && !((Player*)pVictim)->InBattleGround()) + { + DEBUG_LOG("We are dead, loosing 10 percents durability"); + ((Player*)pVictim)->DurabilityLossAll(0.10f,false); + // durability lost message + WorldPacket data(SMSG_DURABILITY_DAMAGE_DEATH, 0); + ((Player*)pVictim)->GetSession()->SendPacket(&data); + } + } + else // creature died + { + DEBUG_LOG("DealDamageNotPlayer"); + Creature *cVictim = (Creature*)pVictim; + + if(!cVictim->isPet()) + { + cVictim->DeleteThreatList(); + cVictim->SetUInt32Value(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE); + } + // Call creature just died function + if (cVictim->AI()) + cVictim->AI()->JustDied(this); + + // Dungeon specific stuff, only applies to players killing creatures + if(cVictim->GetInstanceId()) + { + Map *m = cVictim->GetMap(); + Player *creditedPlayer = GetCharmerOrOwnerPlayerOrPlayerItself(); + // TODO: do instance binding anyway if the charmer/owner is offline + + if(m->IsDungeon() && creditedPlayer) + { + if(m->IsRaid() || m->IsHeroic()) + { + if(cVictim->GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_INSTANCE_BIND) + ((InstanceMap *)m)->PermBindAllPlayers(creditedPlayer); + } + else + { + // the reset time is set but not added to the scheduler + // until the players leave the instance + time_t resettime = cVictim->GetRespawnTimeEx() + 2 * HOUR; + if(InstanceSave *save = sInstanceSaveManager.GetInstanceSave(cVictim->GetInstanceId())) + if(save->GetResetTime() < resettime) save->SetResetTime(resettime); + } + } + } + } + + // last damage from non duel opponent or opponent controlled creature + if(duel_hasEnded) + { + assert(pVictim->GetTypeId()==TYPEID_PLAYER); + Player *he = (Player*)pVictim; + + assert(he->duel); + + he->duel->opponent->CombatStopWithPets(true); + he->CombatStopWithPets(true); + + he->DuelComplete(DUEL_INTERUPTED); + } + } + else // if (health <= damage) + { + DEBUG_LOG("DealDamageAlive"); + + pVictim->ModifyHealth(- (int32)damage); + + // Check if health is below 20% (apply damage before to prevent case when after ProcDamageAndSpell health < damage + if(pVictim->GetHealth()*5 < pVictim->GetMaxHealth()) + { + uint32 procVictim = PROC_FLAG_NONE; + + // if just dropped below 20% (for CheatDeath) + if((pVictim->GetHealth()+damage)*5 > pVictim->GetMaxHealth()) + procVictim = PROC_FLAG_LOW_HEALTH; + + ProcDamageAndSpell(pVictim,PROC_FLAG_TARGET_LOW_HEALTH,procVictim); + } + + if(damagetype != DOT) + { + if(getVictim()) + { + // if have target and damage pVictim just call AI recation + if(pVictim != getVictim() && pVictim->GetTypeId()==TYPEID_UNIT && ((Creature*)pVictim)->AI()) + ((Creature*)pVictim)->AI()->AttackedBy(this); + } + else + { + // if not have main target then attack state with target (including AI call) + //start melee attacks only after melee hit + Attack(pVictim,(damagetype == DIRECT_DAMAGE)); + } + } + + // polymorphed and other negative transformed cases + if(pVictim->getTransForm() && pVictim->hasUnitState(UNIT_STAT_CONFUSED)) + pVictim->RemoveAurasDueToSpell(pVictim->getTransForm()); + + if(damagetype == DIRECT_DAMAGE|| damagetype == SPELL_DIRECT_DAMAGE) + pVictim->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_DIRECT_DAMAGE); + + if (pVictim->GetTypeId() != TYPEID_PLAYER) + { + if(spellProto && IsDamageToThreatSpell(spellProto)) + pVictim->AddThreat(this, damage*2, damageSchoolMask, spellProto); + else + pVictim->AddThreat(this, damage, damageSchoolMask, spellProto); + } + else // victim is a player + { + // Rage from damage received + if(this != pVictim && pVictim->getPowerType() == POWER_RAGE) + { + uint32 rage_damage = damage + (cleanDamage ? cleanDamage->damage : 0); + ((Player*)pVictim)->RewardRage(rage_damage, 0, false); + } + + // random durability for items (HIT TAKEN) + if (roll_chance_f(sWorld.getRate(RATE_DURABILITY_LOSS_DAMAGE))) + { + EquipmentSlots slot = EquipmentSlots(urand(0,EQUIPMENT_SLOT_END-1)); + ((Player*)pVictim)->DurabilityPointLossForEquipSlot(slot); + } + } + + if(GetTypeId()==TYPEID_PLAYER) + { + // random durability for items (HIT DONE) + if (roll_chance_f(sWorld.getRate(RATE_DURABILITY_LOSS_DAMAGE))) + { + EquipmentSlots slot = EquipmentSlots(urand(0,EQUIPMENT_SLOT_END-1)); + ((Player*)this)->DurabilityPointLossForEquipSlot(slot); + } + } + + // TODO: Store auras by interrupt flag to speed this up. + AuraMap& vAuras = pVictim->GetAuras(); + for (AuraMap::iterator i = vAuras.begin(), next; i != vAuras.end(); i = next) + { + const SpellEntry *se = i->second->GetSpellProto(); + next = i; ++next; + if( se->AuraInterruptFlags & AURA_INTERRUPT_FLAG_DAMAGE ) + { + bool remove = true; + if (se->procFlags & (1<<3)) + { + if (!roll_chance_i(se->procChance)) + remove = false; + } + if (remove) + { + pVictim->RemoveAurasDueToSpell(i->second->GetId()); + // FIXME: this may cause the auras with proc chance to be rerolled several times + next = vAuras.begin(); + } + } + } + + if (damagetype != NODAMAGE && damage && pVictim->GetTypeId() == TYPEID_PLAYER) + { + if( damagetype != DOT ) + { + for (uint32 i = CURRENT_FIRST_NON_MELEE_SPELL; i < CURRENT_MAX_SPELL; i++) + { + // skip channeled spell (processed differently below) + if (i == CURRENT_CHANNELED_SPELL) + continue; + + if(Spell* spell = pVictim->m_currentSpells[i]) + if(spell->getState() == SPELL_STATE_PREPARING) + spell->Delayed(); + } + } + + if(Spell* spell = pVictim->m_currentSpells[CURRENT_CHANNELED_SPELL]) + { + if (spell->getState() == SPELL_STATE_CASTING) + { + uint32 channelInterruptFlags = spell->m_spellInfo->ChannelInterruptFlags; + if( channelInterruptFlags & CHANNEL_FLAG_DELAY ) + { + if(pVictim!=this) //don't shorten the duration of channeling if you damage yourself + spell->DelayedChannel(); + } + else if( (channelInterruptFlags & (CHANNEL_FLAG_DAMAGE | CHANNEL_FLAG_DAMAGE2)) ) + { + sLog.outDetail("Spell %u canceled at damage!",spell->m_spellInfo->Id); + pVictim->InterruptSpell(CURRENT_CHANNELED_SPELL); + } + } + else if (spell->getState() == SPELL_STATE_DELAYED) + // break channeled spell in delayed state on damage + { + sLog.outDetail("Spell %u canceled at damage!",spell->m_spellInfo->Id); + pVictim->InterruptSpell(CURRENT_CHANNELED_SPELL); + } + } + } + + // last damage from duel opponent + if(duel_hasEnded) + { + assert(pVictim->GetTypeId()==TYPEID_PLAYER); + Player *he = (Player*)pVictim; + + assert(he->duel); + + he->SetHealth(1); + + he->duel->opponent->CombatStopWithPets(true); + he->CombatStopWithPets(true); + + he->CastSpell(he, 7267, true); // beg + he->DuelComplete(DUEL_WON); + } + } + + DEBUG_LOG("DealDamageEnd returned %d damage", damage); + + return damage; +} + +void Unit::CastStop(uint32 except_spellid) +{ + for (uint32 i = CURRENT_FIRST_NON_MELEE_SPELL; i < CURRENT_MAX_SPELL; i++) + if (m_currentSpells[i] && m_currentSpells[i]->m_spellInfo->Id!=except_spellid) + InterruptSpell(i,false); +} + +void Unit::CastSpell(Unit* Victim, uint32 spellId, bool triggered, Item *castItem, Aura* triggredByAura, uint64 originalCaster) +{ + SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellId ); + + if(!spellInfo) + { + sLog.outError("CastSpell: unknown spell id %i by caster: %s %u)", spellId,(GetTypeId()==TYPEID_PLAYER ? "player (GUID:" : "creature (Entry:"),(GetTypeId()==TYPEID_PLAYER ? GetGUIDLow() : GetEntry())); + return; + } + + CastSpell(Victim,spellInfo,triggered,castItem,triggredByAura, originalCaster); +} + +void Unit::CastSpell(Unit* Victim,SpellEntry const *spellInfo, bool triggered, Item *castItem, Aura* triggredByAura, uint64 originalCaster) +{ + if(!spellInfo) + { + sLog.outError("CastSpell: unknown spell by caster: %s %u)", (GetTypeId()==TYPEID_PLAYER ? "player (GUID:" : "creature (Entry:"),(GetTypeId()==TYPEID_PLAYER ? GetGUIDLow() : GetEntry())); + return; + } + + if (castItem) + DEBUG_LOG("WORLD: cast Item spellId - %i", spellInfo->Id); + + if(!originalCaster && triggredByAura) + originalCaster = triggredByAura->GetCasterGUID(); + + Spell *spell = new Spell(this, spellInfo, triggered, originalCaster ); + + SpellCastTargets targets; + targets.setUnitTarget( Victim ); + spell->m_CastItem = castItem; + spell->prepare(&targets, triggredByAura); +} + +void Unit::CastCustomSpell(Unit* Victim,uint32 spellId, int32 const* bp0, int32 const* bp1, int32 const* bp2, bool triggered, Item *castItem, Aura* triggredByAura, uint64 originalCaster) +{ + SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellId ); + + if(!spellInfo) + { + sLog.outError("CastCustomSpell: unknown spell id %i\n", spellId); + return; + } + + CastCustomSpell(Victim,spellInfo,bp0,bp1,bp2,triggered,castItem,triggredByAura, originalCaster); +} + +void Unit::CastCustomSpell(Unit* Victim,SpellEntry const *spellInfo, int32 const* bp0, int32 const* bp1, int32 const* bp2, bool triggered, Item *castItem, Aura* triggredByAura, uint64 originalCaster) +{ + if(!spellInfo) + { + sLog.outError("CastCustomSpell: unknown spell"); + return; + } + + if (castItem) + DEBUG_LOG("WORLD: cast Item spellId - %i", spellInfo->Id); + + if(!originalCaster && triggredByAura) + originalCaster = triggredByAura->GetCasterGUID(); + + Spell *spell = new Spell(this, spellInfo, triggered, originalCaster); + + if(bp0) + spell->m_currentBasePoints[0] = *bp0-int32(spellInfo->EffectBaseDice[0]); + + if(bp1) + spell->m_currentBasePoints[1] = *bp1-int32(spellInfo->EffectBaseDice[1]); + + if(bp2) + spell->m_currentBasePoints[2] = *bp2-int32(spellInfo->EffectBaseDice[2]); + + SpellCastTargets targets; + targets.setUnitTarget( Victim ); + spell->m_CastItem = castItem; + spell->prepare(&targets, triggredByAura); +} + +// used for scripting +void Unit::CastSpell(float x, float y, float z, uint32 spellId, bool triggered, Item *castItem, Aura* triggredByAura, uint64 originalCaster) +{ + SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellId ); + + if(!spellInfo) + { + sLog.outError("CastSpell(x,y,z): unknown spell id %i by caster: %s %u)", spellId,(GetTypeId()==TYPEID_PLAYER ? "player (GUID:" : "creature (Entry:"),(GetTypeId()==TYPEID_PLAYER ? GetGUIDLow() : GetEntry())); + return; + } + + CastSpell(x, y, z,spellInfo,triggered,castItem,triggredByAura, originalCaster); +} + +// used for scripting +void Unit::CastSpell(float x, float y, float z, SpellEntry const *spellInfo, bool triggered, Item *castItem, Aura* triggredByAura, uint64 originalCaster) +{ + if(!spellInfo) + { + sLog.outError("CastSpell(x,y,z): unknown spell by caster: %s %u)", (GetTypeId()==TYPEID_PLAYER ? "player (GUID:" : "creature (Entry:"),(GetTypeId()==TYPEID_PLAYER ? GetGUIDLow() : GetEntry())); + return; + } + + if (castItem) + DEBUG_LOG("WORLD: cast Item spellId - %i", spellInfo->Id); + + if(!originalCaster && triggredByAura) + originalCaster = triggredByAura->GetCasterGUID(); + + Spell *spell = new Spell(this, spellInfo, triggered, originalCaster ); + + SpellCastTargets targets; + targets.setDestination(x, y, z); + spell->m_CastItem = castItem; + spell->prepare(&targets, triggredByAura); +} + +void Unit::DealFlatDamage(Unit *pVictim, SpellEntry const *spellInfo, uint32 *damage, CleanDamage *cleanDamage, bool *crit, bool isTriggeredSpell) +{ + // TODO this in only generic way, check for exceptions + DEBUG_LOG("DealFlatDamage (BEFORE) >> DMG:%u", *damage); + + // Per-damage calss calculation + switch (spellInfo->DmgClass) + { + // Melee and Ranged Spells + case SPELL_DAMAGE_CLASS_RANGED: + case SPELL_DAMAGE_CLASS_MELEE: + { + // Calculate physical outcome + MeleeHitOutcome outcome = RollPhysicalOutcomeAgainst(pVictim, BASE_ATTACK, spellInfo); + + //Used to store the Hit Outcome + cleanDamage->hitOutCome = outcome; + + // Return miss/evade first (sends miss message) + switch(outcome) + { + case MELEE_HIT_EVADE: + { + SendAttackStateUpdate(HITINFO_MISS, pVictim, 1, GetSpellSchoolMask(spellInfo), 0, 0,0,VICTIMSTATE_EVADES,0); + *damage = 0; + return; + } + case MELEE_HIT_MISS: + { + SendAttackStateUpdate(HITINFO_MISS, pVictim, 1, GetSpellSchoolMask(spellInfo), 0, 0,0,VICTIMSTATE_NORMAL,0); + *damage = 0; + + if(GetTypeId()== TYPEID_PLAYER) + ((Player*)this)->UpdateWeaponSkill(BASE_ATTACK); + + CastMeleeProcDamageAndSpell(pVictim,0,GetSpellSchoolMask(spellInfo),BASE_ATTACK,MELEE_HIT_MISS,spellInfo,isTriggeredSpell); + return; + } + } + + // Hitinfo, Victimstate + uint32 hitInfo = HITINFO_NORMALSWING; + VictimState victimState = VICTIMSTATE_NORMAL; + + // Physical Damage + if ( GetSpellSchoolMask(spellInfo) & SPELL_SCHOOL_MASK_NORMAL ) + { + uint32 modDamage=*damage; + + // apply spellmod to Done damage + if(Player* modOwner = GetSpellModOwner()) + modOwner->ApplySpellMod(spellInfo->Id, SPELLMOD_DAMAGE, *damage); + + //Calculate armor mitigation + uint32 damageAfterArmor = CalcArmorReducedDamage(pVictim, *damage); + + // random durability for main hand weapon (ABSORB) + if(damageAfterArmor < *damage) + if(pVictim->GetTypeId() == TYPEID_PLAYER) + if (roll_chance_f(sWorld.getRate(RATE_DURABILITY_LOSS_ABSORB))) + ((Player*)pVictim)->DurabilityPointLossForEquipSlot(EquipmentSlots(urand(EQUIPMENT_SLOT_START,EQUIPMENT_SLOT_BACK))); + + cleanDamage->damage += *damage - damageAfterArmor; + *damage = damageAfterArmor; + } + // Magical Damage + else + { + // Calculate damage bonus + *damage = SpellDamageBonus(pVictim, spellInfo, *damage, SPELL_DIRECT_DAMAGE); + } + + // Classify outcome + switch (outcome) + { + case MELEE_HIT_BLOCK_CRIT: + case MELEE_HIT_CRIT: + { + uint32 bonusDmg = *damage; + + // Apply crit_damage bonus + if(Player* modOwner = GetSpellModOwner()) + modOwner->ApplySpellMod(spellInfo->Id, SPELLMOD_CRIT_DAMAGE_BONUS, bonusDmg); + + uint32 creatureTypeMask = pVictim->GetCreatureTypeMask(); + AuraList const& mDamageDoneVersus = GetAurasByType(SPELL_AURA_MOD_CRIT_PERCENT_VERSUS); + for(AuraList::const_iterator i = mDamageDoneVersus.begin();i != mDamageDoneVersus.end(); ++i) + if(creatureTypeMask & uint32((*i)->GetModifier()->m_miscvalue)) + bonusDmg = uint32(bonusDmg * ((*i)->GetModifier()->m_amount+100.0f)/100.0f); + + *damage += bonusDmg; + + // Resilience - reduce crit damage + if (pVictim->GetTypeId()==TYPEID_PLAYER) + { + uint32 resilienceReduction = ((Player*)pVictim)->GetMeleeCritDamageReduction(*damage); + cleanDamage->damage += resilienceReduction; + *damage -= resilienceReduction; + } + + *crit = true; + hitInfo |= HITINFO_CRITICALHIT; + + ModifyAuraState(AURA_STATE_CRIT, true); + StartReactiveTimer( REACTIVE_CRIT ); + + if(getClass()==CLASS_HUNTER) + { + ModifyAuraState(AURA_STATE_HUNTER_CRIT_STRIKE, true); + StartReactiveTimer( REACTIVE_HUNTER_CRIT ); + } + + if ( outcome == MELEE_HIT_BLOCK_CRIT ) + { + uint32 blocked_amount = uint32(pVictim->GetShieldBlockValue()); + if (blocked_amount >= *damage) + { + hitInfo |= HITINFO_SWINGNOHITSOUND; + victimState = VICTIMSTATE_BLOCKS; + cleanDamage->damage += *damage; // To Help Calculate Rage + *damage = 0; + } + else + { + // To Help Calculate Rage + cleanDamage->damage += blocked_amount; + *damage = *damage - blocked_amount; + } + + pVictim->ModifyAuraState(AURA_STATE_DEFENSE, true); + pVictim->StartReactiveTimer( REACTIVE_DEFENSE ); + + if(pVictim->GetTypeId() == TYPEID_PLAYER) + { + // Update defense + ((Player*)pVictim)->UpdateDefense(); + + // random durability for main hand weapon (BLOCK) + if (roll_chance_f(sWorld.getRate(RATE_DURABILITY_LOSS_BLOCK))) + ((Player*)pVictim)->DurabilityPointLossForEquipSlot(EQUIPMENT_SLOT_OFFHAND); + } + } + break; + } + case MELEE_HIT_PARRY: + { + cleanDamage->damage += *damage; // To Help Calculate Rage + *damage = 0; + victimState = VICTIMSTATE_PARRY; + + // Counter-attack ( explained in Unit::DoAttackDamage() ) + if(pVictim->GetTypeId()==TYPEID_PLAYER || !(((Creature*)pVictim)->GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_NO_PARRY_HASTEN) ) + { + // Get attack timers + float offtime = float(pVictim->getAttackTimer(OFF_ATTACK)); + float basetime = float(pVictim->getAttackTimer(BASE_ATTACK)); + + // Reduce attack time + if (pVictim->haveOffhandWeapon() && offtime < basetime) + { + float percent20 = pVictim->GetAttackTime(OFF_ATTACK) * 0.20; + float percent60 = 3 * percent20; + if(offtime > percent20 && offtime <= percent60) + { + pVictim->setAttackTimer(OFF_ATTACK, uint32(percent20)); + } + else if(offtime > percent60) + { + offtime -= 2 * percent20; + pVictim->setAttackTimer(OFF_ATTACK, uint32(offtime)); + } + } + else + { + float percent20 = pVictim->GetAttackTime(BASE_ATTACK) * 0.20; + float percent60 = 3 * percent20; + if(basetime > percent20 && basetime <= percent60) + { + pVictim->setAttackTimer(BASE_ATTACK, uint32(percent20)); + } + else if(basetime > percent60) + { + basetime -= 2 * percent20; + pVictim->setAttackTimer(BASE_ATTACK, uint32(basetime)); + } + } + } + + if(pVictim->GetTypeId() == TYPEID_PLAYER) + { + // Update victim defense ? + ((Player*)pVictim)->UpdateDefense(); + + // random durability for main hand weapon (PARRY) + if (roll_chance_f(sWorld.getRate(RATE_DURABILITY_LOSS_PARRY))) + ((Player*)pVictim)->DurabilityPointLossForEquipSlot(EQUIPMENT_SLOT_MAINHAND); + } + + // Set parry flags + pVictim->HandleEmoteCommand(EMOTE_ONESHOT_PARRYUNARMED); + + // Mongoose bite - set only Counterattack here + if (pVictim->getClass() == CLASS_HUNTER) + { + pVictim->ModifyAuraState(AURA_STATE_HUNTER_PARRY,true); + pVictim->StartReactiveTimer( REACTIVE_HUNTER_PARRY ); + } + else + { + pVictim->ModifyAuraState(AURA_STATE_DEFENSE, true); + pVictim->StartReactiveTimer( REACTIVE_DEFENSE ); + } + break; + } + case MELEE_HIT_DODGE: + { + if(pVictim->GetTypeId() == TYPEID_PLAYER) + ((Player*)pVictim)->UpdateDefense(); + + cleanDamage->damage += *damage; // To Help Calculate Rage + *damage = 0; + hitInfo |= HITINFO_SWINGNOHITSOUND; + victimState = VICTIMSTATE_DODGE; + + // Set dodge flags + pVictim->HandleEmoteCommand(EMOTE_ONESHOT_PARRYUNARMED); + + // Overpower + if (GetTypeId() == TYPEID_PLAYER && getClass() == CLASS_WARRIOR) + { + ((Player*)this)->AddComboPoints(pVictim, 1); + StartReactiveTimer( REACTIVE_OVERPOWER ); + } + + // Riposte + if (pVictim->getClass() != CLASS_ROGUE) + { + pVictim->ModifyAuraState(AURA_STATE_DEFENSE, true); + pVictim->StartReactiveTimer( REACTIVE_DEFENSE ); + } + break; + } + case MELEE_HIT_BLOCK: + { + uint32 blocked_amount = uint32(pVictim->GetShieldBlockValue()); + if (blocked_amount >= *damage) + { + hitInfo |= HITINFO_SWINGNOHITSOUND; + victimState = VICTIMSTATE_BLOCKS; + cleanDamage->damage += *damage; // To Help Calculate Rage + *damage = 0; + } + else + { + // To Help Calculate Rage + cleanDamage->damage += blocked_amount; + *damage = *damage - blocked_amount; + } + + pVictim->ModifyAuraState(AURA_STATE_DEFENSE, true); + pVictim->StartReactiveTimer( REACTIVE_DEFENSE ); + + if(pVictim->GetTypeId() == TYPEID_PLAYER) + { + // Update defense + ((Player*)pVictim)->UpdateDefense(); + + // random durability for main hand weapon (BLOCK) + if (roll_chance_f(sWorld.getRate(RATE_DURABILITY_LOSS_BLOCK))) + ((Player*)pVictim)->DurabilityPointLossForEquipSlot(EQUIPMENT_SLOT_OFFHAND); + } + break; + } + case MELEE_HIT_EVADE: // already processed early + case MELEE_HIT_MISS: // already processed early + case MELEE_HIT_GLANCING: + case MELEE_HIT_CRUSHING: + case MELEE_HIT_NORMAL: + break; + } + + // do all damage=0 cases here + if(*damage == 0) + CastMeleeProcDamageAndSpell(pVictim,0,GetSpellSchoolMask(spellInfo),BASE_ATTACK,outcome,spellInfo,isTriggeredSpell); + + break; + } + // Magical Attacks + case SPELL_DAMAGE_CLASS_NONE: + case SPELL_DAMAGE_CLASS_MAGIC: + { + // Calculate damage bonus + *damage = SpellDamageBonus(pVictim, spellInfo, *damage, SPELL_DIRECT_DAMAGE); + + *crit = isSpellCrit(pVictim, spellInfo, GetSpellSchoolMask(spellInfo), BASE_ATTACK); + if (*crit) + { + *damage = SpellCriticalBonus(spellInfo, *damage, pVictim); + + // Resilience - reduce crit damage + if (pVictim && pVictim->GetTypeId()==TYPEID_PLAYER) + { + uint32 damage_reduction = ((Player *)pVictim)->GetSpellCritDamageReduction(*damage); + if(*damage > damage_reduction) + *damage -= damage_reduction; + else + *damage = 0; + } + + cleanDamage->hitOutCome = MELEE_HIT_CRIT; + } + // spell proc all magic damage==0 case in this function + if(*damage == 0) + { + // Procflags + uint32 procAttacker = PROC_FLAG_HIT_SPELL; + uint32 procVictim = (PROC_FLAG_STRUCK_SPELL|PROC_FLAG_TAKE_DAMAGE); + + ProcDamageAndSpell(pVictim, procAttacker, procVictim, 0, GetSpellSchoolMask(spellInfo), spellInfo, isTriggeredSpell); + } + + break; + } + } + + // TODO this in only generic way, check for exceptions + DEBUG_LOG("DealFlatDamage (AFTER) >> DMG:%u", *damage); +} + +uint32 Unit::SpellNonMeleeDamageLog(Unit *pVictim, uint32 spellID, uint32 damage, bool isTriggeredSpell, bool useSpellDamage) +{ + if(!this || !pVictim) + return 0; + if(!this->isAlive() || !pVictim->isAlive()) + return 0; + + SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellID); + if(!spellInfo) + return 0; + + CleanDamage cleanDamage = CleanDamage(0, BASE_ATTACK, MELEE_HIT_NORMAL); + bool crit = false; + + if (useSpellDamage) + DealFlatDamage(pVictim, spellInfo, &damage, &cleanDamage, &crit, isTriggeredSpell); + + // If we actually dealt some damage (spell proc's for 0 damage (normal and magic) called in DealFlatDamage) + if(damage > 0) + { + // Calculate absorb & resists + uint32 absorb = 0; + uint32 resist = 0; + + CalcAbsorbResist(pVictim,GetSpellSchoolMask(spellInfo), SPELL_DIRECT_DAMAGE, damage, &absorb, &resist); + + //No more damage left, target absorbed and/or resisted all damage + if (damage > absorb + resist) + damage -= absorb + resist; //Remove Absorbed and Resisted from damage actually dealt + else + { + uint32 HitInfo = HITINFO_SWINGNOHITSOUND; + + if (absorb) + HitInfo |= HITINFO_ABSORB; + if (resist) + { + HitInfo |= HITINFO_RESIST; + ProcDamageAndSpell(pVictim, PROC_FLAG_TARGET_RESISTS, PROC_FLAG_RESIST_SPELL, 0, GetSpellSchoolMask(spellInfo), spellInfo,isTriggeredSpell); + } + + //Send resist + SendAttackStateUpdate(HitInfo, pVictim, 1, GetSpellSchoolMask(spellInfo), damage, absorb,resist,VICTIMSTATE_NORMAL,0); + return 0; + } + + // Deal damage done + damage = DealDamage(pVictim, damage, &cleanDamage, SPELL_DIRECT_DAMAGE, GetSpellSchoolMask(spellInfo), spellInfo, true); + + // Send damage log + sLog.outDetail("SpellNonMeleeDamageLog: %u (TypeId: %u) attacked %u (TypeId: %u) for %u dmg inflicted by %u,absorb is %u,resist is %u", + GetGUIDLow(), GetTypeId(), pVictim->GetGUIDLow(), pVictim->GetTypeId(), damage, spellID, absorb,resist); + + // Actual log sent to client + SendSpellNonMeleeDamageLog(pVictim, spellID, damage, GetSpellSchoolMask(spellInfo), absorb, resist, false, 0, crit); + + // Procflags + uint32 procAttacker = PROC_FLAG_HIT_SPELL; + uint32 procVictim = (PROC_FLAG_STRUCK_SPELL|PROC_FLAG_TAKE_DAMAGE); + + if (crit) + { + procAttacker |= PROC_FLAG_CRIT_SPELL; + procVictim |= PROC_FLAG_STRUCK_CRIT_SPELL; + } + + ProcDamageAndSpell(pVictim, procAttacker, procVictim, damage, GetSpellSchoolMask(spellInfo), spellInfo, isTriggeredSpell); + + return damage; + } + else + { + // all spell proc for 0 normal and magic damage called in DealFlatDamage + + //Check for rage + if(cleanDamage.damage) + // Rage from damage received. + if(pVictim->GetTypeId() == TYPEID_PLAYER && (pVictim->getPowerType() == POWER_RAGE)) + ((Player*)pVictim)->RewardRage(cleanDamage.damage, 0, false); + + return 0; + } +} + +void Unit::HandleEmoteCommand(uint32 anim_id) +{ + WorldPacket data( SMSG_EMOTE, 12 ); + data << anim_id << GetGUID(); + WPAssert(data.size() == 12); + + SendMessageToSet(&data, true); +} + +uint32 Unit::CalcArmorReducedDamage(Unit* pVictim, const uint32 damage) +{ + uint32 newdamage = 0; + float armor = pVictim->GetArmor(); + // Ignore enemy armor by SPELL_AURA_MOD_TARGET_RESISTANCE aura + armor += GetTotalAuraModifierByMiscMask(SPELL_AURA_MOD_TARGET_RESISTANCE, SPELL_SCHOOL_MASK_NORMAL); + + if (armor<0.0f) armor=0.0f; + + float tmpvalue = 0.0f; + if(getLevel() <= 59) //Level 1-59 + tmpvalue = armor / (armor + 400.0f + 85.0f * getLevel()); + else if(getLevel() < 70) //Level 60-69 + tmpvalue = armor / (armor - 22167.5f + 467.5f * getLevel()); + else //Level 70+ + tmpvalue = armor / (armor + 10557.5f); + + if(tmpvalue < 0.0f) + tmpvalue = 0.0f; + if(tmpvalue > 0.75f) + tmpvalue = 0.75f; + newdamage = uint32(damage - (damage * tmpvalue)); + + return (newdamage > 1) ? newdamage : 1; +} + +void Unit::CalcAbsorbResist(Unit *pVictim,SpellSchoolMask schoolMask, DamageEffectType damagetype, const uint32 damage, uint32 *absorb, uint32 *resist) +{ + if(!pVictim || !pVictim->isAlive() || !damage) + return; + + // Magic damage, check for resists + if ((schoolMask & SPELL_SCHOOL_MASK_NORMAL)==0) + { + // Get base victim resistance for school + float tmpvalue2 = (float)pVictim->GetResistance(GetFirstSchoolInMask(schoolMask)); + // Ignore resistance by self SPELL_AURA_MOD_TARGET_RESISTANCE aura + tmpvalue2 += (float)GetTotalAuraModifierByMiscMask(SPELL_AURA_MOD_TARGET_RESISTANCE, schoolMask); + + tmpvalue2 *= (float)(0.15f / getLevel()); + if (tmpvalue2 < 0.0f) + tmpvalue2 = 0.0f; + if (tmpvalue2 > 0.75f) + tmpvalue2 = 0.75f; + uint32 ran = urand(0, 100); + uint32 faq[4] = {24,6,4,6}; + uint8 m = 0; + float Binom = 0.0f; + for (uint8 i = 0; i < 4; i++) + { + Binom += 2400 *( powf(tmpvalue2, i) * powf( (1-tmpvalue2), (4-i)))/faq[i]; + if (ran > Binom ) + ++m; + else + break; + } + if (damagetype == DOT && m == 4) + *resist += uint32(damage - 1); + else + *resist += uint32(damage * m / 4); + if(*resist > damage) + *resist = damage; + } + else + *resist = 0; + + int32 RemainingDamage = damage - *resist; + + // absorb without mana cost + int32 reflectDamage = 0; + Aura* reflectAura = NULL; + AuraList const& vSchoolAbsorb = pVictim->GetAurasByType(SPELL_AURA_SCHOOL_ABSORB); + for(AuraList::const_iterator i = vSchoolAbsorb.begin(), next; i != vSchoolAbsorb.end() && RemainingDamage > 0; i = next) + { + next = i; ++next; + + if (((*i)->GetModifier()->m_miscvalue & schoolMask)==0) + continue; + + // Cheat Death + if((*i)->GetSpellProto()->SpellFamilyName==SPELLFAMILY_ROGUE && (*i)->GetSpellProto()->SpellIconID == 2109) + { + if (((Player*)pVictim)->HasSpellCooldown(31231)) + continue; + if (pVictim->GetHealth() <= RemainingDamage) + { + int32 chance = (*i)->GetModifier()->m_amount; + if (roll_chance_i(chance)) + { + pVictim->CastSpell(pVictim,31231,true); + ((Player*)pVictim)->AddSpellCooldown(31231,0,time(NULL)+60); + + // with health > 10% lost health until health==10%, in other case no losses + uint32 health10 = pVictim->GetMaxHealth()/10; + RemainingDamage = pVictim->GetHealth() > health10 ? pVictim->GetHealth() - health10 : 0; + } + } + continue; + } + + int32 currentAbsorb; + + //Reflective Shield + if ((pVictim != this) && (*i)->GetSpellProto()->SpellFamilyName == SPELLFAMILY_PRIEST && (*i)->GetSpellProto()->SpellFamilyFlags == 0x1) + { + if(Unit* caster = (*i)->GetCaster()) + { + AuraList const& vOverRideCS = caster->GetAurasByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS); + for(AuraList::const_iterator k = vOverRideCS.begin(); k != vOverRideCS.end(); ++k) + { + switch((*k)->GetModifier()->m_miscvalue) + { + case 5065: // Rank 1 + case 5064: // Rank 2 + case 5063: // Rank 3 + case 5062: // Rank 4 + case 5061: // Rank 5 + { + if(RemainingDamage >= (*i)->GetModifier()->m_amount) + reflectDamage = (*i)->GetModifier()->m_amount * (*k)->GetModifier()->m_amount/100; + else + reflectDamage = (*k)->GetModifier()->m_amount * RemainingDamage/100; + reflectAura = *i; + + } break; + default: break; + } + + if(reflectDamage) + break; + } + } + } + + if (RemainingDamage >= (*i)->GetModifier()->m_amount) + { + currentAbsorb = (*i)->GetModifier()->m_amount; + pVictim->RemoveAurasDueToSpell((*i)->GetId()); + next = vSchoolAbsorb.begin(); + } + else + { + currentAbsorb = RemainingDamage; + (*i)->GetModifier()->m_amount -= RemainingDamage; + } + + RemainingDamage -= currentAbsorb; + } + // do not cast spells while looping auras; auras can get invalid otherwise + if (reflectDamage) + pVictim->CastCustomSpell(this, 33619, &reflectDamage, NULL, NULL, true, NULL, reflectAura); + + // absorb by mana cost + AuraList const& vManaShield = pVictim->GetAurasByType(SPELL_AURA_MANA_SHIELD); + for(AuraList::const_iterator i = vManaShield.begin(), next; i != vManaShield.end() && RemainingDamage > 0; i = next) + { + next = i; ++next; + + // check damage school mask + if(((*i)->GetModifier()->m_miscvalue & schoolMask)==0) + continue; + + int32 currentAbsorb; + if (RemainingDamage >= (*i)->GetModifier()->m_amount) + currentAbsorb = (*i)->GetModifier()->m_amount; + else + currentAbsorb = RemainingDamage; + + float manaMultiplier = (*i)->GetSpellProto()->EffectMultipleValue[(*i)->GetEffIndex()]; + if(Player *modOwner = GetSpellModOwner()) + modOwner->ApplySpellMod((*i)->GetId(), SPELLMOD_MULTIPLE_VALUE, manaMultiplier); + + int32 maxAbsorb = int32(pVictim->GetPower(POWER_MANA) / manaMultiplier); + if (currentAbsorb > maxAbsorb) + currentAbsorb = maxAbsorb; + + (*i)->GetModifier()->m_amount -= currentAbsorb; + if((*i)->GetModifier()->m_amount <= 0) + { + pVictim->RemoveAurasDueToSpell((*i)->GetId()); + next = vManaShield.begin(); + } + + int32 manaReduction = int32(currentAbsorb * manaMultiplier); + pVictim->ApplyPowerMod(POWER_MANA, manaReduction, false); + + RemainingDamage -= currentAbsorb; + } + + AuraList const& vSplitDamageFlat = pVictim->GetAurasByType(SPELL_AURA_SPLIT_DAMAGE_FLAT); + for(AuraList::const_iterator i = vSplitDamageFlat.begin(), next; i != vSplitDamageFlat.end() && RemainingDamage >= 0; i = next) + { + next = i; ++next; + + // check damage school mask + if(((*i)->GetModifier()->m_miscvalue & schoolMask)==0) + continue; + + // Damage can be splitted only if aura has an alive caster + Unit *caster = (*i)->GetCaster(); + if(!caster || caster == pVictim || !caster->IsInWorld() || !caster->isAlive()) + continue; + + int32 currentAbsorb; + if (RemainingDamage >= (*i)->GetModifier()->m_amount) + currentAbsorb = (*i)->GetModifier()->m_amount; + else + currentAbsorb = RemainingDamage; + + RemainingDamage -= currentAbsorb; + + SendSpellNonMeleeDamageLog(caster, (*i)->GetSpellProto()->Id, currentAbsorb, schoolMask, 0, 0, false, 0, false); + + CleanDamage cleanDamage = CleanDamage(currentAbsorb, BASE_ATTACK, MELEE_HIT_NORMAL); + DealDamage(caster, currentAbsorb, &cleanDamage, DIRECT_DAMAGE, schoolMask, (*i)->GetSpellProto(), false); + } + + AuraList const& vSplitDamagePct = pVictim->GetAurasByType(SPELL_AURA_SPLIT_DAMAGE_PCT); + for(AuraList::const_iterator i = vSplitDamagePct.begin(), next; i != vSplitDamagePct.end() && RemainingDamage >= 0; i = next) + { + next = i; ++next; + + // check damage school mask + if(((*i)->GetModifier()->m_miscvalue & schoolMask)==0) + continue; + + // Damage can be splitted only if aura has an alive caster + Unit *caster = (*i)->GetCaster(); + if(!caster || caster == pVictim || !caster->IsInWorld() || !caster->isAlive()) + continue; + + int32 splitted = int32(RemainingDamage * (*i)->GetModifier()->m_amount / 100.0f); + + RemainingDamage -= splitted; + + SendSpellNonMeleeDamageLog(caster, (*i)->GetSpellProto()->Id, splitted, schoolMask, 0, 0, false, 0, false); + + CleanDamage cleanDamage = CleanDamage(splitted, BASE_ATTACK, MELEE_HIT_NORMAL); + DealDamage(caster, splitted, &cleanDamage, DIRECT_DAMAGE, schoolMask, (*i)->GetSpellProto(), false); + } + + *absorb = damage - RemainingDamage - *resist; +} + +void Unit::DoAttackDamage (Unit *pVictim, uint32 *damage, CleanDamage *cleanDamage, uint32 *blocked_amount, SpellSchoolMask damageSchoolMask, uint32 *hitInfo, VictimState *victimState, uint32 *absorbDamage, uint32 *resistDamage, WeaponAttackType attType, SpellEntry const *spellCasted, bool isTriggeredSpell) +{ + MeleeHitOutcome outcome; + + // If is casted Melee spell, calculate like physical + if(!spellCasted) + outcome = RollMeleeOutcomeAgainst (pVictim, attType); + else + outcome = RollPhysicalOutcomeAgainst (pVictim, attType, spellCasted); + + if(outcome == MELEE_HIT_MISS ||outcome == MELEE_HIT_DODGE ||outcome == MELEE_HIT_BLOCK ||outcome == MELEE_HIT_PARRY) + pVictim->AddThreat(this, 0.0f); + switch(outcome) + { + case MELEE_HIT_EVADE: + { + *hitInfo |= HITINFO_MISS; + *damage = 0; + cleanDamage->damage = 0; + return; + } + case MELEE_HIT_MISS: + { + *hitInfo |= HITINFO_MISS; + *damage = 0; + cleanDamage->damage = 0; + if(GetTypeId()== TYPEID_PLAYER) + ((Player*)this)->UpdateWeaponSkill(attType); + return; + } + } + + /// If this is a creature and it attacks from behind it has a probability to daze it's victim + if( (outcome==MELEE_HIT_CRIT || outcome==MELEE_HIT_CRUSHING || outcome==MELEE_HIT_NORMAL || outcome==MELEE_HIT_GLANCING) && + GetTypeId() != TYPEID_PLAYER && !((Creature*)this)->GetCharmerOrOwnerGUID() && !pVictim->HasInArc(M_PI, this) ) + { + // -probability is between 0% and 40% + // 20% base chance + float Probability = 20; + + //there is a newbie protection, at level 10 just 7% base chance; assuming linear function + if( pVictim->getLevel() < 30 ) + Probability = 0.65f*pVictim->getLevel()+0.5; + + uint32 VictimDefense=pVictim->GetDefenseSkillValue(this); + uint32 AttackerMeleeSkill=GetUnitMeleeSkill(pVictim); + + Probability *= AttackerMeleeSkill/(float)VictimDefense; + + if(Probability > 40.0f) + Probability = 40.0f; + + if(roll_chance_f(Probability)) + CastSpell(pVictim, 1604, true); + } + + //Calculate the damage after armor mitigation if SPELL_SCHOOL_NORMAL + if (damageSchoolMask & SPELL_SCHOOL_MASK_NORMAL) + { + uint32 damageAfterArmor = CalcArmorReducedDamage(pVictim, *damage); + + // random durability for main hand weapon (ABSORB) + if(damageAfterArmor < *damage) + if(pVictim->GetTypeId() == TYPEID_PLAYER) + if (roll_chance_f(sWorld.getRate(RATE_DURABILITY_LOSS_ABSORB))) + ((Player*)pVictim)->DurabilityPointLossForEquipSlot(EquipmentSlots(urand(EQUIPMENT_SLOT_START,EQUIPMENT_SLOT_BACK))); + + cleanDamage->damage += *damage - damageAfterArmor; + *damage = damageAfterArmor; + } + + if(GetTypeId() == TYPEID_PLAYER && pVictim->GetTypeId() != TYPEID_PLAYER && pVictim->GetCreatureType() != CREATURE_TYPE_CRITTER ) + ((Player*)this)->UpdateCombatSkills(pVictim, attType, outcome, false); + + if(GetTypeId() != TYPEID_PLAYER && pVictim->GetTypeId() == TYPEID_PLAYER) + ((Player*)pVictim)->UpdateCombatSkills(this, attType, outcome, true); + + switch (outcome) + { + case MELEE_HIT_BLOCK_CRIT: + case MELEE_HIT_CRIT: + { + //*hitInfo = 0xEA; + // 0xEA + *hitInfo = HITINFO_CRITICALHIT | HITINFO_NORMALSWING2 | 0x8; + + // Crit bonus calc + uint32 crit_bonus; + crit_bonus = *damage; + + // Apply crit_damage bonus for melee spells + if (spellCasted) + { + if(Player* modOwner = GetSpellModOwner()) + modOwner->ApplySpellMod(spellCasted->Id, SPELLMOD_CRIT_DAMAGE_BONUS, crit_bonus); + + uint32 creatureTypeMask = pVictim->GetCreatureTypeMask(); + AuraList const& mDamageDoneVersus = GetAurasByType(SPELL_AURA_MOD_CRIT_PERCENT_VERSUS); + for(AuraList::const_iterator i = mDamageDoneVersus.begin();i != mDamageDoneVersus.end(); ++i) + if(creatureTypeMask & uint32((*i)->GetModifier()->m_miscvalue)) + crit_bonus = uint32(crit_bonus * ((*i)->GetModifier()->m_amount+100.0f)/100.0f); + } + + *damage += crit_bonus; + + uint32 resilienceReduction = 0; + + if(attType == RANGED_ATTACK) + { + int32 mod = pVictim->GetTotalAuraModifier(SPELL_AURA_MOD_ATTACKER_RANGED_CRIT_DAMAGE); + *damage = int32((*damage) * float((100.0f + mod)/100.0f)); + // Resilience - reduce crit damage + if (pVictim->GetTypeId()==TYPEID_PLAYER) + resilienceReduction = ((Player*)pVictim)->GetRangedCritDamageReduction(*damage); + } + else + { + int32 mod = pVictim->GetTotalAuraModifier(SPELL_AURA_MOD_ATTACKER_MELEE_CRIT_DAMAGE); + mod += GetTotalAuraModifier(SPELL_AURA_MOD_CRIT_DAMAGE_BONUS_MELEE); + *damage = int32((*damage) * float((100.0f + mod)/100.0f)); + // Resilience - reduce crit damage + if (pVictim->GetTypeId()==TYPEID_PLAYER) + resilienceReduction = ((Player*)pVictim)->GetMeleeCritDamageReduction(*damage); + } + + *damage -= resilienceReduction; + cleanDamage->damage += resilienceReduction; + + if(GetTypeId() == TYPEID_PLAYER && pVictim->GetTypeId() != TYPEID_PLAYER && pVictim->GetCreatureType() != CREATURE_TYPE_CRITTER ) + ((Player*)this)->UpdateWeaponSkill(attType); + + ModifyAuraState(AURA_STATE_CRIT, true); + StartReactiveTimer( REACTIVE_CRIT ); + + if(getClass()==CLASS_HUNTER) + { + ModifyAuraState(AURA_STATE_HUNTER_CRIT_STRIKE, true); + StartReactiveTimer( REACTIVE_HUNTER_CRIT ); + } + + if ( outcome == MELEE_HIT_BLOCK_CRIT ) + { + *blocked_amount = pVictim->GetShieldBlockValue(); + + if (pVictim->GetUnitBlockChance()) + pVictim->HandleEmoteCommand(EMOTE_ONESHOT_PARRYSHIELD); + else + pVictim->HandleEmoteCommand(EMOTE_ONESHOT_PARRYUNARMED); + + //Only set VICTIMSTATE_BLOCK on a full block + if (*blocked_amount >= uint32(*damage)) + { + *victimState = VICTIMSTATE_BLOCKS; + *blocked_amount = uint32(*damage); + } + + if(pVictim->GetTypeId() == TYPEID_PLAYER) + { + // Update defense + ((Player*)pVictim)->UpdateDefense(); + + // random durability for main hand weapon (BLOCK) + if (roll_chance_f(sWorld.getRate(RATE_DURABILITY_LOSS_BLOCK))) + ((Player*)pVictim)->DurabilityPointLossForEquipSlot(EQUIPMENT_SLOT_OFFHAND); + } + + pVictim->ModifyAuraState(AURA_STATE_DEFENSE,true); + pVictim->StartReactiveTimer( REACTIVE_DEFENSE ); + break; + } + + pVictim->HandleEmoteCommand(EMOTE_ONESHOT_WOUNDCRITICAL); + break; + } + case MELEE_HIT_PARRY: + { + if(attType == RANGED_ATTACK) //range attack - no parry + { + outcome = MELEE_HIT_NORMAL; + break; + } + + cleanDamage->damage += *damage; + *damage = 0; + *victimState = VICTIMSTATE_PARRY; + + // instant (maybe with small delay) counter attack + { + float offtime = float(pVictim->getAttackTimer(OFF_ATTACK)); + float basetime = float(pVictim->getAttackTimer(BASE_ATTACK)); + + // after parry nearest next attack time will reduced at %40 from full attack time. + // The delay cannot be reduced to less than 20% of your weapon's base swing delay. + if (pVictim->haveOffhandWeapon() && offtime < basetime) + { + float percent20 = pVictim->GetAttackTime(OFF_ATTACK)*0.20; + float percent60 = 3*percent20; + // set to 20% if in range 20%...20+40% of full time + if(offtime > percent20 && offtime <= percent60) + { + pVictim->setAttackTimer(OFF_ATTACK,uint32(percent20)); + } + // decrease at %40 from full time + else if(offtime > percent60) + { + offtime -= 2*percent20; + pVictim->setAttackTimer(OFF_ATTACK,uint32(offtime)); + } + // ELSE not changed + } + else + { + float percent20 = pVictim->GetAttackTime(BASE_ATTACK)*0.20; + float percent60 = 3*percent20; + // set to 20% if in range 20%...20+40% of full time + if(basetime > percent20 && basetime <= percent60) + { + pVictim->setAttackTimer(BASE_ATTACK,uint32(percent20)); + } + // decrease at %40 from full time + else if(basetime > percent60) + { + basetime -= 2*percent20; + pVictim->setAttackTimer(BASE_ATTACK,uint32(basetime)); + } + // ELSE not changed + } + } + + if(pVictim->GetTypeId() == TYPEID_PLAYER) + { + // Update victim defense ? + ((Player*)pVictim)->UpdateDefense(); + + // random durability for main hand weapon (PARRY) + if (roll_chance_f(sWorld.getRate(RATE_DURABILITY_LOSS_PARRY))) + ((Player*)pVictim)->DurabilityPointLossForEquipSlot(EQUIPMENT_SLOT_MAINHAND); + } + + pVictim->HandleEmoteCommand(EMOTE_ONESHOT_PARRYUNARMED); + + if (pVictim->getClass() == CLASS_HUNTER) + { + pVictim->ModifyAuraState(AURA_STATE_HUNTER_PARRY,true); + pVictim->StartReactiveTimer( REACTIVE_HUNTER_PARRY ); + } + else + { + pVictim->ModifyAuraState(AURA_STATE_DEFENSE, true); + pVictim->StartReactiveTimer( REACTIVE_DEFENSE ); + } + + CastMeleeProcDamageAndSpell(pVictim, 0, damageSchoolMask, attType, outcome, spellCasted, isTriggeredSpell); + return; + } + case MELEE_HIT_DODGE: + { + if(attType == RANGED_ATTACK) //range attack - no dodge + { + outcome = MELEE_HIT_NORMAL; + break; + } + + cleanDamage->damage += *damage; + *damage = 0; + *victimState = VICTIMSTATE_DODGE; + + if(pVictim->GetTypeId() == TYPEID_PLAYER) + ((Player*)pVictim)->UpdateDefense(); + + pVictim->HandleEmoteCommand(EMOTE_ONESHOT_PARRYUNARMED); + + if (pVictim->getClass() != CLASS_ROGUE) // Riposte + { + pVictim->ModifyAuraState(AURA_STATE_DEFENSE, true); + pVictim->StartReactiveTimer( REACTIVE_DEFENSE ); + } + + // Overpower + if (GetTypeId() == TYPEID_PLAYER && getClass() == CLASS_WARRIOR) + { + ((Player*)this)->AddComboPoints(pVictim, 1); + StartReactiveTimer( REACTIVE_OVERPOWER ); + } + + CastMeleeProcDamageAndSpell(pVictim, 0, damageSchoolMask, attType, outcome, spellCasted, isTriggeredSpell); + return; + } + case MELEE_HIT_BLOCK: + { + *blocked_amount = pVictim->GetShieldBlockValue(); + + if (pVictim->GetUnitBlockChance()) + pVictim->HandleEmoteCommand(EMOTE_ONESHOT_PARRYSHIELD); + else + pVictim->HandleEmoteCommand(EMOTE_ONESHOT_PARRYUNARMED); + + //Only set VICTIMSTATE_BLOCK on a full block + if (*blocked_amount >= uint32(*damage)) + { + *victimState = VICTIMSTATE_BLOCKS; + *blocked_amount = uint32(*damage); + } + + if(pVictim->GetTypeId() == TYPEID_PLAYER) + { + // Update defense + ((Player*)pVictim)->UpdateDefense(); + + // random durability for main hand weapon (BLOCK) + if (roll_chance_f(sWorld.getRate(RATE_DURABILITY_LOSS_BLOCK))) + ((Player*)pVictim)->DurabilityPointLossForEquipSlot(EQUIPMENT_SLOT_OFFHAND); + } + + pVictim->ModifyAuraState(AURA_STATE_DEFENSE,true); + pVictim->StartReactiveTimer( REACTIVE_DEFENSE ); + + break; + } + case MELEE_HIT_GLANCING: + { + float reducePercent = 1.0f; //damage factor + + // calculate base values and mods + float baseLowEnd = 1.3; + float baseHighEnd = 1.2; + switch(getClass()) // lowering base values for casters + { + case CLASS_SHAMAN: + case CLASS_PRIEST: + case CLASS_MAGE: + case CLASS_WARLOCK: + case CLASS_DRUID: + baseLowEnd -= 0.7; + baseHighEnd -= 0.3; + break; + } + + float maxLowEnd = 0.6; + switch(getClass()) // upper for melee classes + { + case CLASS_WARRIOR: + case CLASS_ROGUE: + maxLowEnd = 0.91; //If the attacker is a melee class then instead the lower value of 0.91 + } + + // calculate values + int32 diff = int32(pVictim->GetDefenseSkillValue(this)) - int32(GetWeaponSkillValue(attType,pVictim)); + float lowEnd = baseLowEnd - ( 0.05f * diff ); + float highEnd = baseHighEnd - ( 0.03f * diff ); + + // apply max/min bounds + if ( lowEnd < 0.01f ) //the low end must not go bellow 0.01f + lowEnd = 0.01f; + else if ( lowEnd > maxLowEnd ) //the smaller value of this and 0.6 is kept as the low end + lowEnd = maxLowEnd; + + if ( highEnd < 0.2f ) //high end limits + highEnd = 0.2f; + if ( highEnd > 0.99f ) + highEnd = 0.99f; + + if(lowEnd > highEnd) // prevent negative range size + lowEnd = highEnd; + + reducePercent = lowEnd + rand_norm() * ( highEnd - lowEnd ); + + *damage = uint32(reducePercent * *damage); + cleanDamage->damage += *damage; + *hitInfo |= HITINFO_GLANCING; + break; + } + case MELEE_HIT_CRUSHING: + { + // 150% normal damage + *damage += (*damage / 2); + cleanDamage->damage = *damage; + *hitInfo |= HITINFO_CRUSHING; + // TODO: victimState, victim animation? + break; + } + default: + break; + } + + // apply melee damage bonus and absorb only if base damage not fully blocked to prevent negative damage or damage with full block + if(*victimState != VICTIMSTATE_BLOCKS) + { + MeleeDamageBonus(pVictim, damage,attType,spellCasted); + CalcAbsorbResist(pVictim, damageSchoolMask, DIRECT_DAMAGE, *damage-*blocked_amount, absorbDamage, resistDamage); + } + + if (*absorbDamage) *hitInfo |= HITINFO_ABSORB; + if (*resistDamage) *hitInfo |= HITINFO_RESIST; + + cleanDamage->damage += *blocked_amount; + + if (*damage <= *absorbDamage + *resistDamage + *blocked_amount) + { + //*hitInfo = 0x00010020; + //*hitInfo |= HITINFO_SWINGNOHITSOUND; + //*damageType = 0; + CastMeleeProcDamageAndSpell(pVictim, 0, damageSchoolMask, attType, outcome, spellCasted, isTriggeredSpell); + return; + } + + // update at damage Judgement aura duration that applied by attacker at victim + if(*damage) + { + AuraMap const& vAuras = pVictim->GetAuras(); + for(AuraMap::const_iterator itr = vAuras.begin(); itr != vAuras.end(); ++itr) + { + SpellEntry const *spellInfo = (*itr).second->GetSpellProto(); + if( (spellInfo->AttributesEx3 & 0x40000) && spellInfo->SpellFamilyName == SPELLFAMILY_PALADIN && + ((*itr).second->GetCasterGUID() == GetGUID() && (!spellCasted || spellCasted->Id == 35395)) ) + { + (*itr).second->SetAuraDuration((*itr).second->GetAuraMaxDuration()); + (*itr).second->UpdateAuraDuration(); + } + } + } + + CastMeleeProcDamageAndSpell(pVictim, (*damage - *absorbDamage - *resistDamage - *blocked_amount), damageSchoolMask, attType, outcome, spellCasted, isTriggeredSpell); + + // victim's damage shield + // yet another hack to fix crashes related to the aura getting removed during iteration + std::set alreadyDone; + uint32 removedAuras = pVictim->m_removedAuras; + AuraList const& vDamageShields = pVictim->GetAurasByType(SPELL_AURA_DAMAGE_SHIELD); + for(AuraList::const_iterator i = vDamageShields.begin(), next = vDamageShields.begin(); i != vDamageShields.end(); i = next) + { + ++next; + if (alreadyDone.find(*i) == alreadyDone.end()) + { + alreadyDone.insert(*i); + pVictim->SpellNonMeleeDamageLog(this, (*i)->GetId(), (*i)->GetModifier()->m_amount, false, false); + if (pVictim->m_removedAuras > removedAuras) + { + removedAuras = pVictim->m_removedAuras; + next = vDamageShields.begin(); + } + } + } +} + +void Unit::AttackerStateUpdate (Unit *pVictim, WeaponAttackType attType, bool extra ) +{ + if(hasUnitState(UNIT_STAT_CONFUSED | UNIT_STAT_STUNDED | UNIT_STAT_FLEEING) || HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PACIFIED) ) + return; + + if (!pVictim->isAlive()) + return; + + if(IsNonMeleeSpellCasted(false)) + return; + + uint32 hitInfo; + if (attType == BASE_ATTACK) + hitInfo = HITINFO_NORMALSWING2; + else if (attType == OFF_ATTACK) + hitInfo = HITINFO_LEFTSWING; + else + return; // ignore ranaged case + + uint32 extraAttacks = m_extraAttacks; + + // melee attack spell casted at main hand attack only + if (attType == BASE_ATTACK && m_currentSpells[CURRENT_MELEE_SPELL]) + { + m_currentSpells[CURRENT_MELEE_SPELL]->cast(); + + // not recent extra attack only at any non extra attack (melee spell case) + if(!extra && extraAttacks) + { + while(m_extraAttacks) + { + AttackerStateUpdate(pVictim, BASE_ATTACK, true); + if(m_extraAttacks > 0) + --m_extraAttacks; + } + } + + return; + } + + VictimState victimState = VICTIMSTATE_NORMAL; + + CleanDamage cleanDamage = CleanDamage(0, BASE_ATTACK, MELEE_HIT_NORMAL ); + uint32 blocked_dmg = 0; + uint32 absorbed_dmg = 0; + uint32 resisted_dmg = 0; + + SpellSchoolMask meleeSchoolMask = GetMeleeDamageSchoolMask(); + + if(pVictim->IsImmunedToDamage(meleeSchoolMask,true)) // use charges + { + SendAttackStateUpdate (HITINFO_NORMALSWING, pVictim, 1, meleeSchoolMask, 0, 0, 0, VICTIMSTATE_IS_IMMUNE, 0); + + // not recent extra attack only at any non extra attack (miss case) + if(!extra && extraAttacks) + { + while(m_extraAttacks) + { + AttackerStateUpdate(pVictim, BASE_ATTACK, true); + if(m_extraAttacks > 0) + --m_extraAttacks; + } + } + + return; + } + + uint32 damage = CalculateDamage (attType, false); + + DoAttackDamage (pVictim, &damage, &cleanDamage, &blocked_dmg, meleeSchoolMask, &hitInfo, &victimState, &absorbed_dmg, &resisted_dmg, attType); + + if (hitInfo & HITINFO_MISS) + //send miss + SendAttackStateUpdate (hitInfo, pVictim, 1, meleeSchoolMask, damage, absorbed_dmg, resisted_dmg, victimState, blocked_dmg); + else + { + //do animation + SendAttackStateUpdate (hitInfo, pVictim, 1, meleeSchoolMask, damage, absorbed_dmg, resisted_dmg, victimState, blocked_dmg); + + if (damage > (absorbed_dmg + resisted_dmg + blocked_dmg)) + damage -= (absorbed_dmg + resisted_dmg + blocked_dmg); + else + damage = 0; + + DealDamage (pVictim, damage, &cleanDamage, DIRECT_DAMAGE, meleeSchoolMask, NULL, true); + + if(GetTypeId() == TYPEID_PLAYER && pVictim->isAlive()) + { + for(int i = EQUIPMENT_SLOT_START; i < EQUIPMENT_SLOT_END; i++) + ((Player*)this)->CastItemCombatSpell(((Player*)this)->GetItemByPos(INVENTORY_SLOT_BAG_0,i),pVictim,attType); + } + } + + if (GetTypeId() == TYPEID_PLAYER) + DEBUG_LOG("AttackerStateUpdate: (Player) %u attacked %u (TypeId: %u) for %u dmg, absorbed %u, blocked %u, resisted %u.", + GetGUIDLow(), pVictim->GetGUIDLow(), pVictim->GetTypeId(), damage, absorbed_dmg, blocked_dmg, resisted_dmg); + else + DEBUG_LOG("AttackerStateUpdate: (NPC) %u attacked %u (TypeId: %u) for %u dmg, absorbed %u, blocked %u, resisted %u.", + GetGUIDLow(), pVictim->GetGUIDLow(), pVictim->GetTypeId(), damage, absorbed_dmg, blocked_dmg, resisted_dmg); + + // extra attack only at any non extra attack (normal case) + if(!extra && extraAttacks) + { + while(m_extraAttacks) + { + AttackerStateUpdate(pVictim, BASE_ATTACK, true); + if(m_extraAttacks > 0) + --m_extraAttacks; + } + } +} + +MeleeHitOutcome Unit::RollPhysicalOutcomeAgainst (Unit const *pVictim, WeaponAttackType attType, SpellEntry const *spellInfo) +{ + // Miss chance based on melee + float miss_chance = MeleeMissChanceCalc(pVictim, attType); + + // Critical hit chance + float crit_chance = GetUnitCriticalChance(attType, pVictim); + // this is to avoid compiler issue when declaring variables inside if + float block_chance, parry_chance, dodge_chance; + + // cannot be dodged/parried/blocked + if(spellInfo->Attributes & SPELL_ATTR_IMPOSSIBLE_DODGE_PARRY_BLOCK) + { + block_chance = 0.0f; + parry_chance = 0.0f; + dodge_chance = 0.0f; + } + else + { + // parry can be avoided only by some abilites + parry_chance = pVictim->GetUnitParryChance(); + // block might be bypassed by it as well + block_chance = pVictim->GetUnitBlockChance(); + // stunned target cannot dodge and this is check in GetUnitDodgeChance() + dodge_chance = pVictim->GetUnitDodgeChance(); + } + + // Only players can have Talent&Spell bonuses + if (GetTypeId() == TYPEID_PLAYER) + { + // Increase from SPELL_AURA_MOD_SPELL_CRIT_CHANCE_SCHOOL aura + crit_chance += GetTotalAuraModifierByMiscMask(SPELL_AURA_MOD_SPELL_CRIT_CHANCE_SCHOOL, spellInfo->SchoolMask); + + if( dodge_chance != 0.0f ) // if dodge chance is already 0, ignore talents fpr speed + { + AuraList const& mCanNotBeDodge = GetAurasByType(SPELL_AURA_IGNORE_COMBAT_RESULT); + for(AuraList::const_iterator i = mCanNotBeDodge.begin(); i != mCanNotBeDodge.end(); ++i) + { + // can't be dodged rogue finishing move + if((*i)->GetModifier()->m_miscvalue == VICTIMSTATE_DODGE) + { + if(spellInfo->SpellFamilyName==SPELLFAMILY_ROGUE && (spellInfo->SpellFamilyFlags & SPELLFAMILYFLAG_ROGUE__FINISHING_MOVE)) + { + dodge_chance = 0.0f; + break; + } + } + } + } + } + + // Spellmods + if(Player* modOwner = GetSpellModOwner()) + modOwner->ApplySpellMod(spellInfo->Id, SPELLMOD_CRITICAL_CHANCE, crit_chance); + + DEBUG_LOG("PHYSICAL OUTCOME: miss %f crit %f dodge %f parry %f block %f",miss_chance,crit_chance,dodge_chance,parry_chance, block_chance); + + return RollMeleeOutcomeAgainst(pVictim, attType, int32(crit_chance*100), int32(miss_chance*100),int32(dodge_chance*100),int32(parry_chance*100),int32(block_chance*100), true); +} + +MeleeHitOutcome Unit::RollMeleeOutcomeAgainst(const Unit *pVictim, WeaponAttackType attType) const +{ + // This is only wrapper + + // Miss chance based on melee + float miss_chance = MeleeMissChanceCalc(pVictim, attType); + + // Critical hit chance + float crit_chance = GetUnitCriticalChance(attType, pVictim); + + // stunned target cannot dodge and this is check in GetUnitDodgeChance() (returned 0 in this case) + float dodge_chance = pVictim->GetUnitDodgeChance(); + float block_chance = pVictim->GetUnitBlockChance(); + float parry_chance = pVictim->GetUnitParryChance(); + + // Useful if want to specify crit & miss chances for melee, else it could be removed + DEBUG_LOG("MELEE OUTCOME: miss %f crit %f dodge %f parry %f block %f", miss_chance,crit_chance,dodge_chance,parry_chance,block_chance); + + return RollMeleeOutcomeAgainst(pVictim, attType, int32(crit_chance*100), int32(miss_chance*100), int32(dodge_chance*100),int32(parry_chance*100),int32(block_chance*100), false); +} + +MeleeHitOutcome Unit::RollMeleeOutcomeAgainst (const Unit *pVictim, WeaponAttackType attType, int32 crit_chance, int32 miss_chance, int32 dodge_chance, int32 parry_chance, int32 block_chance, bool SpellCasted ) const +{ + if(pVictim->GetTypeId()==TYPEID_UNIT && ((Creature*)pVictim)->IsInEvadeMode()) + return MELEE_HIT_EVADE; + + int32 attackerMaxSkillValueForLevel = GetMaxSkillValueForLevel(pVictim); + int32 victimMaxSkillValueForLevel = pVictim->GetMaxSkillValueForLevel(this); + + int32 attackerWeaponSkill = GetWeaponSkillValue(attType,pVictim); + int32 victimDefenseSkill = pVictim->GetDefenseSkillValue(this); + + // bonus from skills is 0.04% + int32 skillBonus = 4 * ( attackerWeaponSkill - victimMaxSkillValueForLevel ); + int32 skillBonus2 = 4 * ( attackerMaxSkillValueForLevel - victimDefenseSkill ); + int32 sum = 0, tmp = 0; + int32 roll = urand (0, 10000); + + DEBUG_LOG ("RollMeleeOutcomeAgainst: skill bonus of %d for attacker", skillBonus); + DEBUG_LOG ("RollMeleeOutcomeAgainst: rolled %d, miss %d, dodge %d, parry %d, block %d, crit %d", + roll, miss_chance, dodge_chance, parry_chance, block_chance, crit_chance); + + tmp = miss_chance; + + if (tmp > 0 && roll < (sum += tmp )) + { + DEBUG_LOG ("RollMeleeOutcomeAgainst: MISS"); + return MELEE_HIT_MISS; + } + + // always crit against a sitting target (except 0 crit chance) + if( pVictim->GetTypeId() == TYPEID_PLAYER && crit_chance > 0 && !pVictim->IsStandState() ) + { + DEBUG_LOG ("RollMeleeOutcomeAgainst: CRIT (sitting victim)"); + return MELEE_HIT_CRIT; + } + + // Dodge chance + + // only players can't dodge if attacker is behind + if (pVictim->GetTypeId() == TYPEID_PLAYER && !pVictim->HasInArc(M_PI,this)) + { + DEBUG_LOG ("RollMeleeOutcomeAgainst: attack came from behind and victim was a player."); + } + else + { + // Reduce dodge chance by attacker expertise rating + if (GetTypeId() == TYPEID_PLAYER) + dodge_chance -= int32(((Player*)this)->GetExpertiseDodgeOrParryReduction(attType)*100); + + // Modify dodge chance by attacker SPELL_AURA_MOD_COMBAT_RESULT_CHANCE + dodge_chance+= GetTotalAuraModifierByMiscValue(SPELL_AURA_MOD_COMBAT_RESULT_CHANCE, VICTIMSTATE_DODGE); + + tmp = dodge_chance; + if ( (tmp > 0) // check if unit _can_ dodge + && ((tmp -= skillBonus) > 0) + && roll < (sum += tmp)) + { + DEBUG_LOG ("RollMeleeOutcomeAgainst: DODGE <%d, %d)", sum-tmp, sum); + return MELEE_HIT_DODGE; + } + } + + // parry & block chances + + // check if attack comes from behind, nobody can parry or block if attacker is behind + if (!pVictim->HasInArc(M_PI,this)) + { + DEBUG_LOG ("RollMeleeOutcomeAgainst: attack came from behind."); + } + else + { + // Reduce parry chance by attacker expertise rating + if (GetTypeId() == TYPEID_PLAYER) + parry_chance-= int32(((Player*)this)->GetExpertiseDodgeOrParryReduction(attType)*100); + + if(pVictim->GetTypeId()==TYPEID_PLAYER || !(((Creature*)pVictim)->GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_NO_PARRY) ) + { + int32 tmp = int32(parry_chance); + if ( (tmp > 0) // check if unit _can_ parry + && ((tmp -= skillBonus) > 0) + && (roll < (sum += tmp))) + { + DEBUG_LOG ("RollMeleeOutcomeAgainst: PARRY <%d, %d)", sum-tmp, sum); + return MELEE_HIT_PARRY; + } + } + + if(pVictim->GetTypeId()==TYPEID_PLAYER || !(((Creature*)pVictim)->GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_NO_BLOCK) ) + { + tmp = block_chance; + if ( (tmp > 0) // check if unit _can_ block + && ((tmp -= skillBonus) > 0) + && (roll < (sum += tmp))) + { + // Critical chance + tmp = crit_chance + skillBonus2; + if ( GetTypeId() == TYPEID_PLAYER && SpellCasted && tmp > 0 ) + { + if ( roll_chance_i(tmp/100)) + { + DEBUG_LOG ("RollMeleeOutcomeAgainst: BLOCKED CRIT"); + return MELEE_HIT_BLOCK_CRIT; + } + } + DEBUG_LOG ("RollMeleeOutcomeAgainst: BLOCK <%d, %d)", sum-tmp, sum); + return MELEE_HIT_BLOCK; + } + } + } + + // Critical chance + tmp = crit_chance + skillBonus2; + + if (tmp > 0 && roll < (sum += tmp)) + { + DEBUG_LOG ("RollMeleeOutcomeAgainst: CRIT <%d, %d)", sum-tmp, sum); + return MELEE_HIT_CRIT; + } + + // Max 40% chance to score a glancing blow against mobs that are higher level (can do only players and pets and not with ranged weapon) + if( attType != RANGED_ATTACK && !SpellCasted && + (GetTypeId() == TYPEID_PLAYER || ((Creature*)this)->isPet()) && + pVictim->GetTypeId() != TYPEID_PLAYER && !((Creature*)pVictim)->isPet() && + getLevel() < pVictim->getLevelForTarget(this) ) + { + // cap possible value (with bonuses > max skill) + int32 skill = attackerWeaponSkill; + int32 maxskill = attackerMaxSkillValueForLevel; + skill = (skill > maxskill) ? maxskill : skill; + + tmp = (10 + (victimDefenseSkill - skill)) * 100; + tmp = tmp > 4000 ? 4000 : tmp; + if (roll < (sum += tmp)) + { + DEBUG_LOG ("RollMeleeOutcomeAgainst: GLANCING <%d, %d)", sum-4000, sum); + return MELEE_HIT_GLANCING; + } + } + + if(GetTypeId()!=TYPEID_PLAYER && !(((Creature*)this)->GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_NO_CRUSH) && !((Creature*)this)->isPet() ) + { + // mobs can score crushing blows if they're 3 or more levels above victim + // or when their weapon skill is 15 or more above victim's defense skill + tmp = victimDefenseSkill; + int32 tmpmax = victimMaxSkillValueForLevel; + // having defense above your maximum (from items, talents etc.) has no effect + tmp = tmp > tmpmax ? tmpmax : tmp; + // tmp = mob's level * 5 - player's current defense skill + tmp = attackerMaxSkillValueForLevel - tmp; + if(tmp >= 15) + { + // add 2% chance per lacking skill point, min. is 15% + tmp = tmp * 200 - 1500; + if (roll < (sum += tmp)) + { + DEBUG_LOG ("RollMeleeOutcomeAgainst: CRUSHING <%d, %d)", sum-tmp, sum); + return MELEE_HIT_CRUSHING; + } + } + } + + DEBUG_LOG ("RollMeleeOutcomeAgainst: NORMAL"); + return MELEE_HIT_NORMAL; +} + +uint32 Unit::CalculateDamage (WeaponAttackType attType, bool normalized) +{ + float min_damage, max_damage; + + if (normalized && GetTypeId()==TYPEID_PLAYER) + ((Player*)this)->CalculateMinMaxDamage(attType,normalized,min_damage, max_damage); + else + { + switch (attType) + { + case RANGED_ATTACK: + min_damage = GetFloatValue(UNIT_FIELD_MINRANGEDDAMAGE); + max_damage = GetFloatValue(UNIT_FIELD_MAXRANGEDDAMAGE); + break; + case BASE_ATTACK: + min_damage = GetFloatValue(UNIT_FIELD_MINDAMAGE); + max_damage = GetFloatValue(UNIT_FIELD_MAXDAMAGE); + break; + case OFF_ATTACK: + min_damage = GetFloatValue(UNIT_FIELD_MINOFFHANDDAMAGE); + max_damage = GetFloatValue(UNIT_FIELD_MAXOFFHANDDAMAGE); + break; + // Just for good manner + default: + min_damage = 0.0f; + max_damage = 0.0f; + break; + } + } + + if (min_damage > max_damage) + { + std::swap(min_damage,max_damage); + } + + if(max_damage == 0.0f) + max_damage = 5.0f; + + return urand((uint32)min_damage, (uint32)max_damage); +} + +float Unit::CalculateLevelPenalty(SpellEntry const* spellProto) const +{ + if(spellProto->spellLevel <= 0) + return 1.0f; + + float LvlPenalty = 0.0f; + + if(spellProto->spellLevel < 20) + LvlPenalty = 20.0f - spellProto->spellLevel * 3.75f; + float LvlFactor = (float(spellProto->spellLevel) + 6.0f) / float(getLevel()); + if(LvlFactor > 1.0f) + LvlFactor = 1.0f; + + return (100.0f - LvlPenalty) * LvlFactor / 100.0f; +} + +void Unit::SendAttackStart(Unit* pVictim) +{ + WorldPacket data( SMSG_ATTACKSTART, 16 ); + data << GetGUID(); + data << pVictim->GetGUID(); + + SendMessageToSet(&data, true); + DEBUG_LOG( "WORLD: Sent SMSG_ATTACKSTART" ); +} + +void Unit::SendAttackStop(Unit* victim) +{ + if(!victim) + return; + + WorldPacket data( SMSG_ATTACKSTOP, (4+16) ); // we guess size + data.append(GetPackGUID()); + data.append(victim->GetPackGUID()); // can be 0x00... + data << uint32(0); // can be 0x1 + SendMessageToSet(&data, true); + sLog.outDetail("%s %u stopped attacking %s %u", (GetTypeId()==TYPEID_PLAYER ? "player" : "creature"), GetGUIDLow(), (victim->GetTypeId()==TYPEID_PLAYER ? "player" : "creature"),victim->GetGUIDLow()); + + /*if(victim->GetTypeId() == TYPEID_UNIT) + ((Creature*)victim)->AI().EnterEvadeMode(this);*/ +} + +/* +// Melee based spells can be miss, parry or dodge on this step +// Crit or block - determined on damage calculation phase! (and can be both in some time) +float Unit::MeleeSpellMissChance(Unit *pVictim, WeaponAttackType attType, int32 skillDiff, SpellEntry const *spell) +{ + // Calculate hit chance (more correct for chance mod) + int32 HitChance; + + // PvP - PvE melee chances + int32 lchance = pVictim->GetTypeId() == TYPEID_PLAYER ? 5 : 7; + int32 leveldif = pVictim->getLevelForTarget(this) - getLevelForTarget(pVictim); + if(leveldif < 3) + HitChance = 95 - leveldif; + else + HitChance = 93 - (leveldif - 2) * lchance; + + // Hit chance depends from victim auras + if(attType == RANGED_ATTACK) + HitChance += pVictim->GetTotalAuraModifier(SPELL_AURA_MOD_ATTACKER_RANGED_HIT_CHANCE); + else + HitChance += pVictim->GetTotalAuraModifier(SPELL_AURA_MOD_ATTACKER_MELEE_HIT_CHANCE); + + // Spellmod from SPELLMOD_RESIST_MISS_CHANCE + if(Player *modOwner = GetSpellModOwner()) + modOwner->ApplySpellMod(spell->Id, SPELLMOD_RESIST_MISS_CHANCE, HitChance); + + // Miss = 100 - hit + float miss_chance= 100.0f - HitChance; + + // Bonuses from attacker aura and ratings + if (attType == RANGED_ATTACK) + miss_chance -= m_modRangedHitChance; + else + miss_chance -= m_modMeleeHitChance; + + // bonus from skills is 0.04% + miss_chance -= skillDiff * 0.04f; + + // Limit miss chance from 0 to 60% + if (miss_chance < 0.0f) + return 0.0f; + if (miss_chance > 60.0f) + return 60.0f; + return miss_chance; +} + +// Melee based spells hit result calculations +SpellMissInfo Unit::MeleeSpellHitResult(Unit *pVictim, SpellEntry const *spell) +{ + WeaponAttackType attType = BASE_ATTACK; + + if (spell->DmgClass == SPELL_DAMAGE_CLASS_RANGED) + attType = RANGED_ATTACK; + + // bonus from skills is 0.04% per skill Diff + int32 attackerWeaponSkill = int32(GetWeaponSkillValue(attType,pVictim)); + int32 skillDiff = attackerWeaponSkill - int32(pVictim->GetMaxSkillValueForLevel(this)); + int32 fullSkillDiff = attackerWeaponSkill - int32(pVictim->GetDefenseSkillValue(this)); + + uint32 roll = urand (0, 10000); + uint32 missChance = uint32(MeleeSpellMissChance(pVictim, attType, fullSkillDiff, spell)*100.0f); + + // Roll miss + uint32 tmp = missChance; + if (roll < tmp) + return SPELL_MISS_MISS; + + // Same spells cannot be parry/dodge + if (spell->Attributes & SPELL_ATTR_IMPOSSIBLE_DODGE_PARRY_BLOCK) + return SPELL_MISS_NONE; + + // Ranged attack can`t miss too + if (attType == RANGED_ATTACK) + return SPELL_MISS_NONE; + + bool attackFromBehind = !pVictim->HasInArc(M_PI,this); + + // Roll dodge + int32 dodgeChance = int32(pVictim->GetUnitDodgeChance()*100.0f) - skillDiff * 4; + // Reduce enemy dodge chance by SPELL_AURA_MOD_COMBAT_RESULT_CHANCE + dodgeChance+= GetTotalAuraModifierByMiscValue(SPELL_AURA_MOD_COMBAT_RESULT_CHANCE, VICTIMSTATE_DODGE); + + // Reduce dodge chance by attacker expertise rating + if (GetTypeId() == TYPEID_PLAYER) + dodgeChance-=int32(((Player*)this)->GetExpertiseDodgeOrParryReduction(attType) * 100.0f); + if (dodgeChance < 0) + dodgeChance = 0; + + // Can`t dodge from behind in PvP (but its possible in PvE) + if (GetTypeId() == TYPEID_PLAYER && pVictim->GetTypeId() == TYPEID_PLAYER && attackFromBehind) + dodgeChance = 0; + + // Rogue talent`s cant be dodged + AuraList const& mCanNotBeDodge = GetAurasByType(SPELL_AURA_IGNORE_COMBAT_RESULT); + for(AuraList::const_iterator i = mCanNotBeDodge.begin(); i != mCanNotBeDodge.end(); ++i) + { + if((*i)->GetModifier()->m_miscvalue == VICTIMSTATE_DODGE) // can't be dodged rogue finishing move + { + if(spell->SpellFamilyName==SPELLFAMILY_ROGUE && (spell->SpellFamilyFlags & SPELLFAMILYFLAG_ROGUE__FINISHING_MOVE)) + { + dodgeChance = 0; + break; + } + } + } + + tmp += dodgeChance; + if (roll < tmp) + return SPELL_MISS_DODGE; + + // Roll parry + int32 parryChance = int32(pVictim->GetUnitParryChance()*100.0f) - skillDiff * 4; + // Reduce parry chance by attacker expertise rating + if (GetTypeId() == TYPEID_PLAYER) + parryChance-=int32(((Player*)this)->GetExpertiseDodgeOrParryReduction(attType) * 100.0f); + // Can`t parry from behind + if (parryChance < 0 || attackFromBehind) + parryChance = 0; + + tmp += parryChance; + if (roll < tmp) + return SPELL_MISS_PARRY; + + return SPELL_MISS_NONE; +}*/ + +// TODO need use unit spell resistances in calculations +SpellMissInfo Unit::MagicSpellHitResult(Unit *pVictim, SpellEntry const *spell) +{ + // Can`t miss on dead target (on skinning for example) + if (!pVictim->isAlive()) + return SPELL_MISS_NONE; + + SpellSchoolMask schoolMask = GetSpellSchoolMask(spell); + // PvP - PvE spell misschances per leveldif > 2 + int32 lchance = pVictim->GetTypeId() == TYPEID_PLAYER ? 7 : 11; + int32 leveldif = int32(pVictim->getLevelForTarget(this)) - int32(getLevelForTarget(pVictim)); + + // Base hit chance from attacker and victim levels + int32 modHitChance; + if(leveldif < 3) + modHitChance = 96 - leveldif; + else + modHitChance = 94 - (leveldif - 2) * lchance; + + // Spellmod from SPELLMOD_RESIST_MISS_CHANCE + if(Player *modOwner = GetSpellModOwner()) + modOwner->ApplySpellMod(spell->Id, SPELLMOD_RESIST_MISS_CHANCE, modHitChance); + // Increase from attacker SPELL_AURA_MOD_INCREASES_SPELL_PCT_TO_HIT auras + modHitChance+=GetTotalAuraModifierByMiscMask(SPELL_AURA_MOD_INCREASES_SPELL_PCT_TO_HIT, schoolMask); + // Chance hit from victim SPELL_AURA_MOD_ATTACKER_SPELL_HIT_CHANCE auras + modHitChance+= pVictim->GetTotalAuraModifierByMiscMask(SPELL_AURA_MOD_ATTACKER_SPELL_HIT_CHANCE, schoolMask); + // Reduce spell hit chance for Area of effect spells from victim SPELL_AURA_MOD_AOE_AVOIDANCE aura + if (IsAreaOfEffectSpell(spell)) + modHitChance-=pVictim->GetTotalAuraModifier(SPELL_AURA_MOD_AOE_AVOIDANCE); + // Reduce spell hit chance for dispel mechanic spells from victim SPELL_AURA_MOD_DISPEL_RESIST + if (IsDispelSpell(spell)) + modHitChance-=pVictim->GetTotalAuraModifier(SPELL_AURA_MOD_DISPEL_RESIST); + // Chance resist mechanic (select max value from every mechanic spell effect) + int32 resist_mech = 0; + // Get effects mechanic and chance + for(int eff = 0; eff < 3; ++eff) + { + int32 effect_mech = GetEffectMechanic(spell, eff); + if (effect_mech) + { + int32 temp = pVictim->GetTotalAuraModifierByMiscValue(SPELL_AURA_MOD_MECHANIC_RESISTANCE, effect_mech); + if (resist_mech < temp) + resist_mech = temp; + } + } + // Apply mod + modHitChance-=resist_mech; + + // Chance resist debuff + modHitChance-=pVictim->GetTotalAuraModifierByMiscValue(SPELL_AURA_MOD_DEBUFF_RESISTANCE, int32(spell->Dispel)); + + int32 HitChance = modHitChance * 100; + // Increase hit chance from attacker SPELL_AURA_MOD_SPELL_HIT_CHANCE and attacker ratings + HitChance += int32(m_modSpellHitChance*100.0f); + + // Decrease hit chance from victim rating bonus + if (pVictim->GetTypeId()==TYPEID_PLAYER) + HitChance -= int32(((Player*)pVictim)->GetRatingBonusValue(CR_HIT_TAKEN_SPELL)*100.0f); + + if (HitChance < 100) HitChance = 100; + if (HitChance > 9900) HitChance = 9900; + + uint32 rand = urand(0,10000); + if (rand > HitChance) + return SPELL_MISS_RESIST; + return SPELL_MISS_NONE; +} + +SpellMissInfo Unit::SpellHitResult(Unit *pVictim, SpellEntry const *spell, bool CanReflect) +{ + // Return evade for units in evade mode + if (pVictim->GetTypeId()==TYPEID_UNIT && ((Creature*)pVictim)->IsInEvadeMode()) + return SPELL_MISS_EVADE; + + // Check for immune (use charges) + if (pVictim->IsImmunedToSpell(spell,true)) + return SPELL_MISS_IMMUNE; + + // All positive spells can`t miss + // TODO: client not show miss log for this spells - so need find info for this in dbc and use it! + if (IsPositiveSpell(spell->Id)) + return SPELL_MISS_NONE; + + // Check for immune (use charges) + if (pVictim->IsImmunedToDamage(GetSpellSchoolMask(spell),true)) + return SPELL_MISS_IMMUNE; + + // Try victim reflect spell + if (CanReflect) + { + // specialized first + Unit::AuraList const& mReflectSpellsSchool = pVictim->GetAurasByType(SPELL_AURA_REFLECT_SPELLS_SCHOOL); + for(Unit::AuraList::const_iterator i = mReflectSpellsSchool.begin(); i != mReflectSpellsSchool.end(); ++i) + { + if((*i)->GetModifier()->m_miscvalue & GetSpellSchoolMask(spell)) + { + int32 reflectchance = (*i)->GetModifier()->m_amount; + if (reflectchance > 0 && roll_chance_i(reflectchance)) + { + if((*i)->m_procCharges > 0) + { + --(*i)->m_procCharges; + if((*i)->m_procCharges==0) + pVictim->RemoveAurasDueToSpell((*i)->GetId()); + } + return SPELL_MISS_REFLECT; + } + } + } + + // generic reflection + Unit::AuraList const& mReflectSpells = pVictim->GetAurasByType(SPELL_AURA_REFLECT_SPELLS); + for(Unit::AuraList::const_iterator i = mReflectSpells.begin(); i != mReflectSpells.end(); ++i) + { + int32 reflectchance = (*i)->GetModifier()->m_amount; + if (reflectchance > 0 && roll_chance_i(reflectchance)) + { + if((*i)->m_procCharges > 0) + { + --(*i)->m_procCharges; + if((*i)->m_procCharges==0) + pVictim->RemoveAurasDueToSpell((*i)->GetId()); + } + return SPELL_MISS_REFLECT; + } + } + } + + // Temporary solution for melee based spells and spells vs SPELL_SCHOOL_NORMAL (hit result calculated after) + for (int i=0;i<3;i++) + { + if (spell->Effect[i] == SPELL_EFFECT_WEAPON_DAMAGE || + spell->Effect[i] == SPELL_EFFECT_WEAPON_PERCENT_DAMAGE || + spell->Effect[i] == SPELL_EFFECT_NORMALIZED_WEAPON_DMG || + spell->Effect[i] == SPELL_EFFECT_WEAPON_DAMAGE_NOSCHOOL) + return SPELL_MISS_NONE; + } + + // TODO need use this code for spell hit result calculation + // now code commented for compotability + switch (spell->DmgClass) + { + case SPELL_DAMAGE_CLASS_RANGED: + case SPELL_DAMAGE_CLASS_MELEE: +// return MeleeSpellHitResult(pVictim, spell); + return SPELL_MISS_NONE; + case SPELL_DAMAGE_CLASS_NONE: + case SPELL_DAMAGE_CLASS_MAGIC: + return MagicSpellHitResult(pVictim, spell); + } + return SPELL_MISS_NONE; +} + +float Unit::MeleeMissChanceCalc(const Unit *pVictim, WeaponAttackType attType) const +{ + if(!pVictim) + return 0.0f; + + // Base misschance 5% + float misschance = 5.0f; + + // DualWield - Melee spells and physical dmg spells - 5% , white damage 24% + if (haveOffhandWeapon() && attType != RANGED_ATTACK) + { + bool isNormal = false; + for (uint32 i = CURRENT_FIRST_NON_MELEE_SPELL; i < CURRENT_MAX_SPELL; i++) + { + if( m_currentSpells[i] && (GetSpellSchoolMask(m_currentSpells[i]->m_spellInfo) & SPELL_SCHOOL_MASK_NORMAL) ) + { + isNormal = true; + break; + } + } + if (isNormal || m_currentSpells[CURRENT_MELEE_SPELL]) + { + misschance = 5.0f; + } + else + { + misschance = 24.0f; + } + } + + // PvP : PvE melee misschances per leveldif > 2 + int32 chance = pVictim->GetTypeId() == TYPEID_PLAYER ? 5 : 7; + + int32 leveldif = int32(pVictim->getLevelForTarget(this)) - int32(getLevelForTarget(pVictim)); + if(leveldif < 0) + leveldif = 0; + + // Hit chance from attacker based on ratings and auras + float m_modHitChance; + if (attType == RANGED_ATTACK) + m_modHitChance = m_modRangedHitChance; + else + m_modHitChance = m_modMeleeHitChance; + + if(leveldif < 3) + misschance += (leveldif - m_modHitChance); + else + misschance += ((leveldif - 2) * chance - m_modHitChance); + + // Hit chance for victim based on ratings + if (pVictim->GetTypeId()==TYPEID_PLAYER) + { + if (attType == RANGED_ATTACK) + misschance += ((Player*)pVictim)->GetRatingBonusValue(CR_HIT_TAKEN_RANGED); + else + misschance += ((Player*)pVictim)->GetRatingBonusValue(CR_HIT_TAKEN_MELEE); + } + + // Modify miss chance by victim auras + if(attType == RANGED_ATTACK) + misschance -= pVictim->GetTotalAuraModifier(SPELL_AURA_MOD_ATTACKER_RANGED_HIT_CHANCE); + else + misschance -= pVictim->GetTotalAuraModifier(SPELL_AURA_MOD_ATTACKER_MELEE_HIT_CHANCE); + + // Modify miss chance from skill difference ( bonus from skills is 0.04% ) + int32 skillBonus = int32(GetWeaponSkillValue(attType,pVictim)) - int32(pVictim->GetDefenseSkillValue(this)); + misschance -= skillBonus * 0.04f; + + // Limit miss chance from 0 to 60% + if ( misschance < 0.0f) + return 0.0f; + if ( misschance > 60.0f) + return 60.0f; + + return misschance; +} + +uint32 Unit::GetDefenseSkillValue(Unit const* target) const +{ + if(GetTypeId() == TYPEID_PLAYER) + { + // in PvP use full skill instead current skill value + uint32 value = (target && target->GetTypeId() == TYPEID_PLAYER) + ? ((Player*)this)->GetMaxSkillValue(SKILL_DEFENSE) + : ((Player*)this)->GetSkillValue(SKILL_DEFENSE); + value += uint32(((Player*)this)->GetRatingBonusValue(CR_DEFENSE_SKILL)); + return value; + } + else + return GetUnitMeleeSkill(target); +} + +float Unit::GetUnitDodgeChance() const +{ + if(hasUnitState(UNIT_STAT_STUNDED)) + return 0.0f; + if( GetTypeId() == TYPEID_PLAYER ) + return GetFloatValue(PLAYER_DODGE_PERCENTAGE); + else + { + if(((Creature const*)this)->isTotem()) + return 0.0f; + else + { + float dodge = 5.0f; + dodge += GetTotalAuraModifier(SPELL_AURA_MOD_DODGE_PERCENT); + return dodge > 0.0f ? dodge : 0.0f; + } + } +} + +float Unit::GetUnitParryChance() const +{ + if ( IsNonMeleeSpellCasted(false) || hasUnitState(UNIT_STAT_STUNDED)) + return 0.0f; + + float chance = 0.0f; + + if(GetTypeId() == TYPEID_PLAYER) + { + Player const* player = (Player const*)this; + if(player->CanParry() ) + { + Item *tmpitem = player->GetWeaponForAttack(BASE_ATTACK,true); + if(!tmpitem) + tmpitem = player->GetWeaponForAttack(OFF_ATTACK,true); + + if(tmpitem) + chance = GetFloatValue(PLAYER_PARRY_PERCENTAGE); + } + } + else if(GetTypeId() == TYPEID_UNIT) + { + if(GetCreatureType() == CREATURE_TYPE_HUMANOID) + { + chance = 5.0f; + chance += GetTotalAuraModifier(SPELL_AURA_MOD_PARRY_PERCENT); + } + } + + return chance > 0.0f ? chance : 0.0f; +} + +float Unit::GetUnitBlockChance() const +{ + if ( IsNonMeleeSpellCasted(false) || hasUnitState(UNIT_STAT_STUNDED)) + return 0.0f; + + if(GetTypeId() == TYPEID_PLAYER) + { + Player const* player = (Player const*)this; + if(player->CanBlock() ) + { + Item *tmpitem = player->GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND); + if(tmpitem && !tmpitem->IsBroken() && tmpitem->GetProto()->Block) + return GetFloatValue(PLAYER_BLOCK_PERCENTAGE); + } + // is player but has no block ability or no not broken shield equiped + return 0.0f; + } + else + { + if(((Creature const*)this)->isTotem()) + return 0.0f; + else + { + float block = 5.0f; + block += GetTotalAuraModifier(SPELL_AURA_MOD_BLOCK_PERCENT); + return block > 0.0f ? block : 0.0f; + } + } +} + +float Unit::GetUnitCriticalChance(WeaponAttackType attackType, const Unit *pVictim) const +{ + float crit; + + if(GetTypeId() == TYPEID_PLAYER) + { + switch(attackType) + { + case BASE_ATTACK: + crit = GetFloatValue( PLAYER_CRIT_PERCENTAGE ); + break; + case OFF_ATTACK: + crit = GetFloatValue( PLAYER_OFFHAND_CRIT_PERCENTAGE ); + break; + case RANGED_ATTACK: + crit = GetFloatValue( PLAYER_RANGED_CRIT_PERCENTAGE ); + break; + // Just for good manner + default: + crit = 0.0f; + break; + } + } + else + { + crit = 5.0f; + crit += GetTotalAuraModifier(SPELL_AURA_MOD_CRIT_PERCENT); + } + + // flat aura mods + if(attackType == RANGED_ATTACK) + crit += pVictim->GetTotalAuraModifier(SPELL_AURA_MOD_ATTACKER_RANGED_CRIT_CHANCE); + else + crit += pVictim->GetTotalAuraModifier(SPELL_AURA_MOD_ATTACKER_MELEE_CRIT_CHANCE); + + crit += pVictim->GetTotalAuraModifier(SPELL_AURA_MOD_ATTACKER_SPELL_AND_WEAPON_CRIT_CHANCE); + + // reduce crit chance from Rating for players + if (pVictim->GetTypeId()==TYPEID_PLAYER) + { + if (attackType==RANGED_ATTACK) + crit -= ((Player*)pVictim)->GetRatingBonusValue(CR_CRIT_TAKEN_RANGED); + else + crit -= ((Player*)pVictim)->GetRatingBonusValue(CR_CRIT_TAKEN_MELEE); + } + + if (crit < 0.0f) + crit = 0.0f; + return crit; +} + +uint32 Unit::GetWeaponSkillValue (WeaponAttackType attType, Unit const* target) const +{ + uint32 value = 0; + if(GetTypeId() == TYPEID_PLAYER) + { + Item* item = ((Player*)this)->GetWeaponForAttack(attType,true); + + // feral or unarmed skill only for base attack + if(attType != BASE_ATTACK && !item ) + return 0; + + if(((Player*)this)->IsInFeralForm()) + return GetMaxSkillValueForLevel(); // always maximized SKILL_FERAL_COMBAT in fact + + // weaon skill or (unarmed for base attack) + uint32 skill = item ? item->GetSkill() : SKILL_UNARMED; + + // in PvP use full skill instead current skill value + value = (target && target->GetTypeId() == TYPEID_PLAYER) + ? ((Player*)this)->GetMaxSkillValue(skill) + : ((Player*)this)->GetSkillValue(skill); + // Modify value from ratings + value += uint32(((Player*)this)->GetRatingBonusValue(CR_WEAPON_SKILL)); + switch (attType) + { + case BASE_ATTACK: value+=uint32(((Player*)this)->GetRatingBonusValue(CR_WEAPON_SKILL_MAINHAND));break; + case OFF_ATTACK: value+=uint32(((Player*)this)->GetRatingBonusValue(CR_WEAPON_SKILL_OFFHAND));break; + case RANGED_ATTACK: value+=uint32(((Player*)this)->GetRatingBonusValue(CR_WEAPON_SKILL_RANGED));break; + } + } + else + value = GetUnitMeleeSkill(target); + return value; +} + +void Unit::_UpdateSpells( uint32 time ) +{ + if(m_currentSpells[CURRENT_AUTOREPEAT_SPELL]) + _UpdateAutoRepeatSpell(); + + // remove finished spells from current pointers + for (uint32 i = 0; i < CURRENT_MAX_SPELL; i++) + { + if (m_currentSpells[i] && m_currentSpells[i]->getState() == SPELL_STATE_FINISHED) + { + m_currentSpells[i]->SetDeletable(true); // spell may be safely deleted now + m_currentSpells[i] = NULL; // remove pointer + } + } + + // TODO: Find a better way to prevent crash when multiple auras are removed. + m_removedAuras = 0; + for (AuraMap::iterator i = m_Auras.begin(); i != m_Auras.end(); ++i) + if ((*i).second) + (*i).second->SetUpdated(false); + + for (AuraMap::iterator i = m_Auras.begin(), next; i != m_Auras.end(); i = next) + { + next = i; + ++next; + if ((*i).second) + { + // prevent double update + if ((*i).second->IsUpdated()) + continue; + (*i).second->SetUpdated(true); + (*i).second->Update( time ); + // several auras can be deleted due to update + if (m_removedAuras) + { + if (m_Auras.empty()) break; + next = m_Auras.begin(); + m_removedAuras = 0; + } + } + } + + for (AuraMap::iterator i = m_Auras.begin(); i != m_Auras.end();) + { + if ((*i).second) + { + if ( !(*i).second->GetAuraDuration() && !((*i).second->IsPermanent() || ((*i).second->IsPassive())) ) + { + RemoveAura(i); + } + else + { + ++i; + } + } + else + { + ++i; + } + } + + if(!m_gameObj.empty()) + { + std::list::iterator ite1, dnext1; + for (ite1 = m_gameObj.begin(); ite1 != m_gameObj.end(); ite1 = dnext1) + { + dnext1 = ite1; + //(*i)->Update( difftime ); + if( !(*ite1)->isSpawned() ) + { + (*ite1)->SetOwnerGUID(0); + (*ite1)->SetRespawnTime(0); + (*ite1)->Delete(); + dnext1 = m_gameObj.erase(ite1); + } + else + ++dnext1; + } + } +} + +void Unit::_UpdateAutoRepeatSpell() +{ + //check "realtime" interrupts + if ( (GetTypeId() == TYPEID_PLAYER && ((Player*)this)->isMoving()) || IsNonMeleeSpellCasted(false,false,true) ) + { + // cancel wand shoot + if(m_currentSpells[CURRENT_AUTOREPEAT_SPELL]->m_spellInfo->Category == 351) + InterruptSpell(CURRENT_AUTOREPEAT_SPELL); + m_AutoRepeatFirstCast = true; + return; + } + + //apply delay + if ( m_AutoRepeatFirstCast && getAttackTimer(RANGED_ATTACK) < 500 ) + setAttackTimer(RANGED_ATTACK,500); + m_AutoRepeatFirstCast = false; + + //castroutine + if (isAttackReady(RANGED_ATTACK)) + { + // Check if able to cast + if(m_currentSpells[CURRENT_AUTOREPEAT_SPELL]->CanCast(true)) + { + InterruptSpell(CURRENT_AUTOREPEAT_SPELL); + return; + } + + // we want to shoot + Spell* spell = new Spell(this, m_currentSpells[CURRENT_AUTOREPEAT_SPELL]->m_spellInfo, true, 0); + spell->prepare(&(m_currentSpells[CURRENT_AUTOREPEAT_SPELL]->m_targets)); + + // all went good, reset attack + resetAttackTimer(RANGED_ATTACK); + } +} + +void Unit::SetCurrentCastedSpell( Spell * pSpell ) +{ + assert(pSpell); // NULL may be never passed here, use InterruptSpell or InterruptNonMeleeSpells + + uint32 CSpellType = pSpell->GetCurrentContainer(); + + pSpell->SetDeletable(false); // spell will not be deleted until gone from current pointers + if (pSpell == m_currentSpells[CSpellType]) return; // avoid breaking self + + // break same type spell if it is not delayed + InterruptSpell(CSpellType,false); + + // special breakage effects: + switch (CSpellType) + { + case CURRENT_GENERIC_SPELL: + { + // generic spells always break channeled not delayed spells + InterruptSpell(CURRENT_CHANNELED_SPELL,false); + + // autorepeat breaking + if ( m_currentSpells[CURRENT_AUTOREPEAT_SPELL] ) + { + // break autorepeat if not Auto Shot + if (m_currentSpells[CURRENT_AUTOREPEAT_SPELL]->m_spellInfo->Category == 351) + InterruptSpell(CURRENT_AUTOREPEAT_SPELL); + m_AutoRepeatFirstCast = true; + } + } break; + + case CURRENT_CHANNELED_SPELL: + { + // channel spells always break generic non-delayed and any channeled spells + InterruptSpell(CURRENT_GENERIC_SPELL,false); + InterruptSpell(CURRENT_CHANNELED_SPELL); + + // it also does break autorepeat if not Auto Shot + if ( m_currentSpells[CURRENT_AUTOREPEAT_SPELL] && + m_currentSpells[CURRENT_AUTOREPEAT_SPELL]->m_spellInfo->Category == 351 ) + InterruptSpell(CURRENT_AUTOREPEAT_SPELL); + } break; + + case CURRENT_AUTOREPEAT_SPELL: + { + // only Auto Shoot does not break anything + if (pSpell->m_spellInfo->Category == 351) + { + // generic autorepeats break generic non-delayed and channeled non-delayed spells + InterruptSpell(CURRENT_GENERIC_SPELL,false); + InterruptSpell(CURRENT_CHANNELED_SPELL,false); + } + // special action: set first cast flag + m_AutoRepeatFirstCast = true; + } break; + + default: + { + // other spell types don't break anything now + } break; + } + + // current spell (if it is still here) may be safely deleted now + if (m_currentSpells[CSpellType]) + m_currentSpells[CSpellType]->SetDeletable(true); + + // set new current spell + m_currentSpells[CSpellType] = pSpell; +} + +void Unit::InterruptSpell(uint32 spellType, bool withDelayed) +{ + assert(spellType < CURRENT_MAX_SPELL); + + if(m_currentSpells[spellType] && (withDelayed || m_currentSpells[spellType]->getState() != SPELL_STATE_DELAYED) ) + { + // send autorepeat cancel message for autorepeat spells + if (spellType == CURRENT_AUTOREPEAT_SPELL) + { + if(GetTypeId()==TYPEID_PLAYER) + ((Player*)this)->SendAutoRepeatCancel(); + } + + if (m_currentSpells[spellType]->getState() != SPELL_STATE_FINISHED) + m_currentSpells[spellType]->cancel(); + m_currentSpells[spellType]->SetDeletable(true); + m_currentSpells[spellType] = NULL; + } +} + +bool Unit::IsNonMeleeSpellCasted(bool withDelayed, bool skipChanneled, bool skipAutorepeat) const +{ + // We don't do loop here to explicitly show that melee spell is excluded. + // Maybe later some special spells will be excluded too. + + // generic spells are casted when they are not finished and not delayed + if ( m_currentSpells[CURRENT_GENERIC_SPELL] && + (m_currentSpells[CURRENT_GENERIC_SPELL]->getState() != SPELL_STATE_FINISHED) && + (withDelayed || m_currentSpells[CURRENT_GENERIC_SPELL]->getState() != SPELL_STATE_DELAYED) ) + return(true); + + // channeled spells may be delayed, but they are still considered casted + else if ( !skipChanneled && m_currentSpells[CURRENT_CHANNELED_SPELL] && + (m_currentSpells[CURRENT_CHANNELED_SPELL]->getState() != SPELL_STATE_FINISHED) ) + return(true); + + // autorepeat spells may be finished or delayed, but they are still considered casted + else if ( !skipAutorepeat && m_currentSpells[CURRENT_AUTOREPEAT_SPELL] ) + return(true); + + return(false); +} + +void Unit::InterruptNonMeleeSpells(bool withDelayed, uint32 spell_id) +{ + // generic spells are interrupted if they are not finished or delayed + if (m_currentSpells[CURRENT_GENERIC_SPELL] && (!spell_id || m_currentSpells[CURRENT_GENERIC_SPELL]->m_spellInfo->Id==spell_id)) + { + if ( (m_currentSpells[CURRENT_GENERIC_SPELL]->getState() != SPELL_STATE_FINISHED) && + (withDelayed || m_currentSpells[CURRENT_GENERIC_SPELL]->getState() != SPELL_STATE_DELAYED) ) + m_currentSpells[CURRENT_GENERIC_SPELL]->cancel(); + m_currentSpells[CURRENT_GENERIC_SPELL]->SetDeletable(true); + m_currentSpells[CURRENT_GENERIC_SPELL] = NULL; + } + + // autorepeat spells are interrupted if they are not finished or delayed + if (m_currentSpells[CURRENT_AUTOREPEAT_SPELL] && (!spell_id || m_currentSpells[CURRENT_AUTOREPEAT_SPELL]->m_spellInfo->Id==spell_id)) + { + // send disable autorepeat packet in any case + if(GetTypeId()==TYPEID_PLAYER) + ((Player*)this)->SendAutoRepeatCancel(); + + if ( (m_currentSpells[CURRENT_AUTOREPEAT_SPELL]->getState() != SPELL_STATE_FINISHED) && + (withDelayed || m_currentSpells[CURRENT_AUTOREPEAT_SPELL]->getState() != SPELL_STATE_DELAYED) ) + m_currentSpells[CURRENT_AUTOREPEAT_SPELL]->cancel(); + m_currentSpells[CURRENT_AUTOREPEAT_SPELL]->SetDeletable(true); + m_currentSpells[CURRENT_AUTOREPEAT_SPELL] = NULL; + } + + // channeled spells are interrupted if they are not finished, even if they are delayed + if (m_currentSpells[CURRENT_CHANNELED_SPELL] && (!spell_id || m_currentSpells[CURRENT_CHANNELED_SPELL]->m_spellInfo->Id==spell_id)) + { + if (m_currentSpells[CURRENT_CHANNELED_SPELL]->getState() != SPELL_STATE_FINISHED) + m_currentSpells[CURRENT_CHANNELED_SPELL]->cancel(); + m_currentSpells[CURRENT_CHANNELED_SPELL]->SetDeletable(true); + m_currentSpells[CURRENT_CHANNELED_SPELL] = NULL; + } +} + +Spell* Unit::FindCurrentSpellBySpellId(uint32 spell_id) const +{ + for (uint32 i = 0; i < CURRENT_MAX_SPELL; i++) + if(m_currentSpells[i] && m_currentSpells[i]->m_spellInfo->Id==spell_id) + return m_currentSpells[i]; + return NULL; +} + +bool Unit::isInFront(Unit const* target, float distance, float arc) const +{ + return IsWithinDistInMap(target, distance) && HasInArc( arc, target ); +} + +void Unit::SetInFront(Unit const* target) +{ + SetOrientation(GetAngle(target)); +} + +bool Unit::isInBack(Unit const* target, float distance, float arc) const +{ + return IsWithinDistInMap(target, distance) && !HasInArc( 2 * M_PI - arc, target ); +} + +bool Unit::isInAccessablePlaceFor(Creature const* c) const +{ + if(IsInWater()) + return c->canSwim(); + else + return c->canWalk() || c->canFly(); +} + +bool Unit::IsInWater() const +{ + return MapManager::Instance().GetBaseMap(GetMapId())->IsInWater(GetPositionX(),GetPositionY(), GetPositionZ()); +} + +bool Unit::IsUnderWater() const +{ + return MapManager::Instance().GetBaseMap(GetMapId())->IsUnderWater(GetPositionX(),GetPositionY(),GetPositionZ()); +} + +void Unit::DeMorph() +{ + SetDisplayId(GetNativeDisplayId()); +} + +int32 Unit::GetTotalAuraModifier(AuraType auratype) const +{ + int32 modifier = 0; + + AuraList const& mTotalAuraList = GetAurasByType(auratype); + for(AuraList::const_iterator i = mTotalAuraList.begin();i != mTotalAuraList.end(); ++i) + modifier += (*i)->GetModifier()->m_amount; + + return modifier; +} + +float Unit::GetTotalAuraMultiplier(AuraType auratype) const +{ + float multipler = 1.0f; + + AuraList const& mTotalAuraList = GetAurasByType(auratype); + for(AuraList::const_iterator i = mTotalAuraList.begin();i != mTotalAuraList.end(); ++i) + multipler *= (100.0f + (*i)->GetModifier()->m_amount)/100.0f; + + return multipler; +} + +int32 Unit::GetMaxPositiveAuraModifier(AuraType auratype) const +{ + int32 modifier = 0; + + AuraList const& mTotalAuraList = GetAurasByType(auratype); + for(AuraList::const_iterator i = mTotalAuraList.begin();i != mTotalAuraList.end(); ++i) + if ((*i)->GetModifier()->m_amount > modifier) + modifier = (*i)->GetModifier()->m_amount; + + return modifier; +} + +int32 Unit::GetMaxNegativeAuraModifier(AuraType auratype) const +{ + int32 modifier = 0; + + AuraList const& mTotalAuraList = GetAurasByType(auratype); + for(AuraList::const_iterator i = mTotalAuraList.begin();i != mTotalAuraList.end(); ++i) + if ((*i)->GetModifier()->m_amount < modifier) + modifier = (*i)->GetModifier()->m_amount; + + return modifier; +} + +int32 Unit::GetTotalAuraModifierByMiscMask(AuraType auratype, uint32 misc_mask) const +{ + int32 modifier = 0; + + AuraList const& mTotalAuraList = GetAurasByType(auratype); + for(AuraList::const_iterator i = mTotalAuraList.begin();i != mTotalAuraList.end(); ++i) + { + Modifier* mod = (*i)->GetModifier(); + if (mod->m_miscvalue & misc_mask) + modifier += mod->m_amount; + } + return modifier; +} + +float Unit::GetTotalAuraMultiplierByMiscMask(AuraType auratype, uint32 misc_mask) const +{ + float multipler = 1.0f; + + AuraList const& mTotalAuraList = GetAurasByType(auratype); + for(AuraList::const_iterator i = mTotalAuraList.begin();i != mTotalAuraList.end(); ++i) + { + Modifier* mod = (*i)->GetModifier(); + if (mod->m_miscvalue & misc_mask) + multipler *= (100.0f + mod->m_amount)/100.0f; + } + return multipler; +} + +int32 Unit::GetMaxPositiveAuraModifierByMiscMask(AuraType auratype, uint32 misc_mask) const +{ + int32 modifier = 0; + + AuraList const& mTotalAuraList = GetAurasByType(auratype); + for(AuraList::const_iterator i = mTotalAuraList.begin();i != mTotalAuraList.end(); ++i) + { + Modifier* mod = (*i)->GetModifier(); + if (mod->m_miscvalue & misc_mask && mod->m_amount > modifier) + modifier = mod->m_amount; + } + + return modifier; +} + +int32 Unit::GetMaxNegativeAuraModifierByMiscMask(AuraType auratype, uint32 misc_mask) const +{ + int32 modifier = 0; + + AuraList const& mTotalAuraList = GetAurasByType(auratype); + for(AuraList::const_iterator i = mTotalAuraList.begin();i != mTotalAuraList.end(); ++i) + { + Modifier* mod = (*i)->GetModifier(); + if (mod->m_miscvalue & misc_mask && mod->m_amount < modifier) + modifier = mod->m_amount; + } + + return modifier; +} + +int32 Unit::GetTotalAuraModifierByMiscValue(AuraType auratype, int32 misc_value) const +{ + int32 modifier = 0; + + AuraList const& mTotalAuraList = GetAurasByType(auratype); + for(AuraList::const_iterator i = mTotalAuraList.begin();i != mTotalAuraList.end(); ++i) + { + Modifier* mod = (*i)->GetModifier(); + if (mod->m_miscvalue == misc_value) + modifier += mod->m_amount; + } + return modifier; +} + +float Unit::GetTotalAuraMultiplierByMiscValue(AuraType auratype, int32 misc_value) const +{ + float multipler = 1.0f; + + AuraList const& mTotalAuraList = GetAurasByType(auratype); + for(AuraList::const_iterator i = mTotalAuraList.begin();i != mTotalAuraList.end(); ++i) + { + Modifier* mod = (*i)->GetModifier(); + if (mod->m_miscvalue == misc_value) + multipler *= (100.0f + mod->m_amount)/100.0f; + } + return multipler; +} + +int32 Unit::GetMaxPositiveAuraModifierByMiscValue(AuraType auratype, int32 misc_value) const +{ + int32 modifier = 0; + + AuraList const& mTotalAuraList = GetAurasByType(auratype); + for(AuraList::const_iterator i = mTotalAuraList.begin();i != mTotalAuraList.end(); ++i) + { + Modifier* mod = (*i)->GetModifier(); + if (mod->m_miscvalue == misc_value && mod->m_amount > modifier) + modifier = mod->m_amount; + } + + return modifier; +} + +int32 Unit::GetMaxNegativeAuraModifierByMiscValue(AuraType auratype, int32 misc_value) const +{ + int32 modifier = 0; + + AuraList const& mTotalAuraList = GetAurasByType(auratype); + for(AuraList::const_iterator i = mTotalAuraList.begin();i != mTotalAuraList.end(); ++i) + { + Modifier* mod = (*i)->GetModifier(); + if (mod->m_miscvalue == misc_value && mod->m_amount < modifier) + modifier = mod->m_amount; + } + + return modifier; +} + +bool Unit::AddAura(Aura *Aur) +{ + // ghost spell check, allow apply any auras at player loading in ghost mode (will be cleanup after load) + if( !isAlive() && Aur->GetId() != 20584 && Aur->GetId() != 8326 && Aur->GetId() != 2584 && + (GetTypeId()!=TYPEID_PLAYER || !((Player*)this)->GetSession()->PlayerLoading()) ) + { + delete Aur; + return false; + } + + if(Aur->GetTarget() != this) + { + sLog.outError("Aura (spell %u eff %u) add to aura list of %s (lowguid: %u) but Aura target is %s (lowguid: %u)", + Aur->GetId(),Aur->GetEffIndex(),(GetTypeId()==TYPEID_PLAYER?"player":"creature"),GetGUIDLow(), + (Aur->GetTarget()->GetTypeId()==TYPEID_PLAYER?"player":"creature"),Aur->GetTarget()->GetGUIDLow()); + delete Aur; + return false; + } + + SpellEntry const* aurSpellInfo = Aur->GetSpellProto(); + + spellEffectPair spair = spellEffectPair(Aur->GetId(), Aur->GetEffIndex()); + AuraMap::iterator i = m_Auras.find( spair ); + + // take out same spell + if (i != m_Auras.end()) + { + // passive and persistent auras can stack with themselves any number of times + if (!Aur->IsPassive() && !Aur->IsPersistent()) + { + // replace aura if next will > spell StackAmount + if(aurSpellInfo->StackAmount) + { + if(m_Auras.count(spair) >= aurSpellInfo->StackAmount) + RemoveAura(i,AURA_REMOVE_BY_STACK); + } + // if StackAmount==0 not allow auras from same caster + else + { + for(AuraMap::iterator i2 = m_Auras.lower_bound(spair); i2 != m_Auras.upper_bound(spair); ++i2) + { + if(i2->second->GetCasterGUID()==Aur->GetCasterGUID()) + { + // can be only single (this check done at _each_ aura add + RemoveAura(i2,AURA_REMOVE_BY_STACK); + break; + } + + bool stop = false; + switch(aurSpellInfo->EffectApplyAuraName[Aur->GetEffIndex()]) + { + // DoT/HoT/etc + case SPELL_AURA_PERIODIC_DAMAGE: // allow stack + case SPELL_AURA_PERIODIC_DAMAGE_PERCENT: + case SPELL_AURA_PERIODIC_LEECH: + case SPELL_AURA_PERIODIC_HEAL: + case SPELL_AURA_OBS_MOD_HEALTH: + case SPELL_AURA_PERIODIC_MANA_LEECH: + case SPELL_AURA_PERIODIC_ENERGIZE: + case SPELL_AURA_OBS_MOD_MANA: + case SPELL_AURA_POWER_BURN_MANA: + break; + default: // not allow + // can be only single (this check done at _each_ aura add + RemoveAura(i2,AURA_REMOVE_BY_STACK); + stop = true; + break; + } + + if(stop) + break; + } + } + } + } + + // passive auras stack with all (except passive spell proc auras) + if ((!Aur->IsPassive() || !IsPassiveStackableSpell(Aur->GetId())) && + !(Aur->GetId() == 20584 || Aur->GetId() == 8326)) + { + if (!RemoveNoStackAurasDueToAura(Aur)) + { + delete Aur; + return false; // couldnt remove conflicting aura with higher rank + } + } + + // update single target auras list (before aura add to aura list, to prevent unexpected remove recently added aura) + if (IsSingleTargetSpell(aurSpellInfo) && Aur->GetTarget()) + { + // caster pointer can be deleted in time aura remove, find it by guid at each iteration + for(;;) + { + Unit* caster = Aur->GetCaster(); + if(!caster) // caster deleted and not required adding scAura + break; + + bool restart = false; + AuraList& scAuras = caster->GetSingleCastAuras(); + for(AuraList::iterator itr = scAuras.begin(); itr != scAuras.end(); ++itr) + { + if( (*itr)->GetTarget() != Aur->GetTarget() && + IsSingleTargetSpells((*itr)->GetSpellProto(),aurSpellInfo) ) + { + if ((*itr)->IsInUse()) + { + sLog.outError("Aura (Spell %u Effect %u) is in process but attempt removed at aura (Spell %u Effect %u) adding, need add stack rule for IsSingleTargetSpell", (*itr)->GetId(), (*itr)->GetEffIndex(),Aur->GetId(), Aur->GetEffIndex()); + continue; + } + (*itr)->GetTarget()->RemoveAura((*itr)->GetId(), (*itr)->GetEffIndex()); + restart = true; + break; + } + } + + if(!restart) + { + // done + scAuras.push_back(Aur); + break; + } + } + } + + // add aura, register in lists and arrays + Aur->_AddAura(); + m_Auras.insert(AuraMap::value_type(spellEffectPair(Aur->GetId(), Aur->GetEffIndex()), Aur)); + if (Aur->GetModifier()->m_auraname < TOTAL_AURAS) + { + m_modAuras[Aur->GetModifier()->m_auraname].push_back(Aur); + } + + Aur->ApplyModifier(true,true); + sLog.outDebug("Aura %u now is in use", Aur->GetModifier()->m_auraname); + return true; +} + +void Unit::RemoveRankAurasDueToSpell(uint32 spellId) +{ + SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellId); + if(!spellInfo) + return; + AuraMap::iterator i,next; + for (i = m_Auras.begin(); i != m_Auras.end(); i = next) + { + next = i; + ++next; + uint32 i_spellId = (*i).second->GetId(); + if((*i).second && i_spellId && i_spellId != spellId) + { + if(spellmgr.IsRankSpellDueToSpell(spellInfo,i_spellId)) + { + RemoveAurasDueToSpell(i_spellId); + + if( m_Auras.empty() ) + break; + else + next = m_Auras.begin(); + } + } + } +} + +bool Unit::RemoveNoStackAurasDueToAura(Aura *Aur) +{ + if (!Aur) + return false; + + SpellEntry const* spellProto = Aur->GetSpellProto(); + if (!spellProto) + return false; + + uint32 spellId = Aur->GetId(); + uint32 effIndex = Aur->GetEffIndex(); + + SpellSpecific spellId_spec = GetSpellSpecific(spellId); + + AuraMap::iterator i,next; + for (i = m_Auras.begin(); i != m_Auras.end(); i = next) + { + next = i; + ++next; + if (!(*i).second) continue; + + SpellEntry const* i_spellProto = (*i).second->GetSpellProto(); + + if (!i_spellProto) + continue; + + uint32 i_spellId = i_spellProto->Id; + + if(IsPassiveSpell(i_spellId)) + { + if(IsPassiveStackableSpell(i_spellId)) + continue; + + // passive non-stackable spells not stackable only with another rank of same spell + if (!spellmgr.IsRankSpellDueToSpell(spellProto, i_spellId)) + continue; + } + + uint32 i_effIndex = (*i).second->GetEffIndex(); + + if(i_spellId == spellId) continue; + + bool is_triggered_by_spell = false; + // prevent triggered aura of removing aura that triggered it + for(int j = 0; j < 3; ++j) + if (i_spellProto->EffectTriggerSpell[j] == spellProto->Id) + is_triggered_by_spell = true; + if (is_triggered_by_spell) continue; + + for(int j = 0; j < 3; ++j) + { + // prevent remove dummy triggered spells at next effect aura add + switch(spellProto->Effect[j]) // main spell auras added added after triggred spell + { + case SPELL_EFFECT_DUMMY: + switch(spellId) + { + case 5420: if(i_spellId==34123) is_triggered_by_spell = true; break; + } + break; + } + + if(is_triggered_by_spell) + break; + + // prevent remove form main spell by triggred passive spells + switch(i_spellProto->EffectApplyAuraName[j]) // main aura added before triggered spell + { + case SPELL_AURA_MOD_SHAPESHIFT: + switch(i_spellId) + { + case 24858: if(spellId==24905) is_triggered_by_spell = true; break; + case 33891: if(spellId==5420 || spellId==34123) is_triggered_by_spell = true; break; + case 34551: if(spellId==22688) is_triggered_by_spell = true; break; + } + break; + } + } + + if(!is_triggered_by_spell) + { + SpellSpecific i_spellId_spec = GetSpellSpecific(i_spellId); + + bool is_sspc = IsSingleFromSpellSpecificPerCaster(spellId_spec,i_spellId_spec); + + if( is_sspc && Aur->GetCasterGUID() == (*i).second->GetCasterGUID() ) + { + // cannot remove higher rank + if (spellmgr.IsRankSpellDueToSpell(spellProto, i_spellId)) + if(CompareAuraRanks(spellId, effIndex, i_spellId, i_effIndex) < 0) + return false; + + // Its a parent aura (create this aura in ApplyModifier) + if ((*i).second->IsInUse()) + { + sLog.outError("Aura (Spell %u Effect %u) is in process but attempt removed at aura (Spell %u Effect %u) adding, need add stack rule for Unit::RemoveNoStackAurasDueToAura", i->second->GetId(), i->second->GetEffIndex(),Aur->GetId(), Aur->GetEffIndex()); + continue; + } + RemoveAurasDueToSpell(i_spellId); + + if( m_Auras.empty() ) + break; + else + next = m_Auras.begin(); + } + else if( !is_sspc && spellmgr.IsNoStackSpellDueToSpell(spellId, i_spellId) ) + { + // Its a parent aura (create this aura in ApplyModifier) + if ((*i).second->IsInUse()) + { + sLog.outError("Aura (Spell %u Effect %u) is in process but attempt removed at aura (Spell %u Effect %u) adding, need add stack rule for Unit::RemoveNoStackAurasDueToAura", i->second->GetId(), i->second->GetEffIndex(),Aur->GetId(), Aur->GetEffIndex()); + continue; + } + RemoveAurasDueToSpell(i_spellId); + + if( m_Auras.empty() ) + break; + else + next = m_Auras.begin(); + } + // Potions stack aura by aura (elixirs/flask already checked) + else if( spellProto->SpellFamilyName == SPELLFAMILY_POTION && i_spellProto->SpellFamilyName == SPELLFAMILY_POTION ) + { + if (IsNoStackAuraDueToAura(spellId, effIndex, i_spellId, i_effIndex)) + { + if(CompareAuraRanks(spellId, effIndex, i_spellId, i_effIndex) < 0) + return false; // cannot remove higher rank + + // Its a parent aura (create this aura in ApplyModifier) + if ((*i).second->IsInUse()) + { + sLog.outError("Aura (Spell %u Effect %u) is in process but attempt removed at aura (Spell %u Effect %u) adding, need add stack rule for Unit::RemoveNoStackAurasDueToAura", i->second->GetId(), i->second->GetEffIndex(),Aur->GetId(), Aur->GetEffIndex()); + continue; + } + RemoveAura(i); + next = i; + } + } + } + } + return true; +} + +void Unit::RemoveAura(uint32 spellId, uint32 effindex, Aura* except) +{ + spellEffectPair spair = spellEffectPair(spellId, effindex); + for(AuraMap::iterator iter = m_Auras.lower_bound(spair); iter != m_Auras.upper_bound(spair);) + { + if(iter->second!=except) + { + RemoveAura(iter); + iter = m_Auras.lower_bound(spair); + } + else + ++iter; + } +} + +void Unit::RemoveAurasDueToSpellByDispel(uint32 spellId, uint64 casterGUID, Unit *dispeler) +{ + for (AuraMap::iterator iter = m_Auras.begin(); iter != m_Auras.end(); ) + { + Aura *aur = iter->second; + if (aur->GetId() == spellId && aur->GetCasterGUID() == casterGUID) + { + // Custom dispel case + // Unstable Affliction + if (aur->GetSpellProto()->SpellFamilyName == SPELLFAMILY_WARLOCK && (aur->GetSpellProto()->SpellFamilyFlags & 0x010000000000LL)) + { + int32 damage = aur->GetModifier()->m_amount*9; + uint64 caster_guid = aur->GetCasterGUID(); + + // Remove aura + RemoveAura(iter, AURA_REMOVE_BY_DISPEL); + + // backfire damage and silence + dispeler->CastCustomSpell(dispeler, 31117, &damage, NULL, NULL, true, NULL, NULL,caster_guid); + + iter = m_Auras.begin(); // iterator can be invalidate at cast if self-dispel + } + else + RemoveAura(iter, AURA_REMOVE_BY_DISPEL); + } + else + ++iter; + } +} + +void Unit::RemoveAurasDueToSpellBySteal(uint32 spellId, uint64 casterGUID, Unit *stealer) +{ + for (AuraMap::iterator iter = m_Auras.begin(); iter != m_Auras.end(); ) + { + Aura *aur = iter->second; + if (aur->GetId() == spellId && aur->GetCasterGUID() == casterGUID) + { + int32 basePoints = aur->GetBasePoints(); + // construct the new aura for the attacker + Aura * new_aur = CreateAura(aur->GetSpellProto(), aur->GetEffIndex(), &basePoints, stealer); + if(!new_aur) + continue; + + // set its duration and maximum duration + // max duration 2 minutes (in msecs) + int32 dur = aur->GetAuraDuration(); + const int32 max_dur = 2*MINUTE*1000; + new_aur->SetAuraMaxDuration( max_dur > dur ? dur : max_dur ); + new_aur->SetAuraDuration( max_dur > dur ? dur : max_dur ); + + // add the new aura to stealer + stealer->AddAura(new_aur); + + // Remove aura as dispel + RemoveAura(iter, AURA_REMOVE_BY_DISPEL); + } + else + ++iter; + } +} + +void Unit::RemoveAurasDueToSpellByCancel(uint32 spellId) +{ + for (AuraMap::iterator iter = m_Auras.begin(); iter != m_Auras.end(); ) + { + if (iter->second->GetId() == spellId) + RemoveAura(iter, AURA_REMOVE_BY_CANCEL); + else + ++iter; + } +} + +void Unit::RemoveAurasWithDispelType( DispelType type ) +{ + // Create dispel mask by dispel type + uint32 dispelMask = GetDispellMask(type); + // Dispel all existing auras vs current dispell type + AuraMap& auras = GetAuras(); + for(AuraMap::iterator itr = auras.begin(); itr != auras.end(); ) + { + SpellEntry const* spell = itr->second->GetSpellProto(); + if( (1<Dispel) & dispelMask ) + { + // Dispel aura + RemoveAurasDueToSpell(spell->Id); + itr = auras.begin(); + } + else + ++itr; + } +} + +void Unit::RemoveSingleAuraFromStack(uint32 spellId, uint32 effindex) +{ + AuraMap::iterator iter = m_Auras.find(spellEffectPair(spellId, effindex)); + if(iter != m_Auras.end()) + RemoveAura(iter); +} + +void Unit::RemoveAurasDueToSpell(uint32 spellId, Aura* except) +{ + for (int i = 0; i < 3; ++i) + RemoveAura(spellId,i,except); +} + +void Unit::RemoveAurasDueToItemSpell(Item* castItem,uint32 spellId) +{ + for (int k=0; k < 3; ++k) + { + spellEffectPair spair = spellEffectPair(spellId, k); + for (AuraMap::iterator iter = m_Auras.lower_bound(spair); iter != m_Auras.upper_bound(spair);) + { + if (iter->second->GetCastItemGUID() == castItem->GetGUID()) + { + RemoveAura(iter); + iter = m_Auras.upper_bound(spair); // overwrite by more appropriate + } + else + ++iter; + } + } +} + +void Unit::RemoveAurasWithInterruptFlags(uint32 flags) +{ + for (AuraMap::iterator iter = m_Auras.begin(); iter != m_Auras.end(); ) + { + if (iter->second->GetSpellProto()->AuraInterruptFlags & flags) + RemoveAura(iter); + else + ++iter; + } +} + +void Unit::RemoveNotOwnSingleTargetAuras() +{ + // single target auras from other casters + for (AuraMap::iterator iter = m_Auras.begin(); iter != m_Auras.end(); ) + { + if (iter->second->GetCasterGUID()!=GetGUID() && IsSingleTargetSpell(iter->second->GetSpellProto())) + RemoveAura(iter); + else + ++iter; + } + + // single target auras at other targets + AuraList& scAuras = GetSingleCastAuras(); + for (AuraList::iterator iter = scAuras.begin(); iter != scAuras.end(); ) + { + Aura* aura = *iter; + if (aura->GetTarget()!=this) + { + scAuras.erase(iter); // explicitly remove, instead waiting remove in RemoveAura + aura->GetTarget()->RemoveAura(aura->GetId(),aura->GetEffIndex()); + iter = scAuras.begin(); + } + else + ++iter; + } + +} + +void Unit::RemoveAura(AuraMap::iterator &i, AuraRemoveMode mode) +{ + if (IsSingleTargetSpell((*i).second->GetSpellProto())) + { + if(Unit* caster = (*i).second->GetCaster()) + { + AuraList& scAuras = caster->GetSingleCastAuras(); + scAuras.remove((*i).second); + } + else + { + sLog.outError("Couldn't find the caster of the single target aura, may crash later!"); + assert(false); + } + } + + if ((*i).second->GetModifier()->m_auraname < TOTAL_AURAS) + { + m_modAuras[(*i).second->GetModifier()->m_auraname].remove((*i).second); + } + + // remove from list before mods removing (prevent cyclic calls, mods added before including to aura list - use reverse order) + Aura* Aur = i->second; + // Set remove mode + Aur->SetRemoveMode(mode); + // some ShapeshiftBoosts at remove trigger removing other auras including parent Shapeshift aura + // remove aura from list before to prevent deleting it before + m_Auras.erase(i); + ++m_removedAuras; // internal count used by unit update + + // Status unsummoned at aura remove + Totem* statue = NULL; + if(IsChanneledSpell(Aur->GetSpellProto())) + if(Unit* caster = Aur->GetCaster()) + if(caster->GetTypeId()==TYPEID_UNIT && ((Creature*)caster)->isTotem() && ((Totem*)caster)->GetTotemType()==TOTEM_STATUE) + statue = ((Totem*)caster); + + sLog.outDebug("Aura %u now is remove mode %d",Aur->GetModifier()->m_auraname, mode); + Aur->ApplyModifier(false,true); + Aur->_RemoveAura(); + delete Aur; + + if(statue) + statue->UnSummon(); + + // only way correctly remove all auras from list + if( m_Auras.empty() ) + i = m_Auras.end(); + else + i = m_Auras.begin(); +} + +void Unit::RemoveAllAuras() +{ + while (!m_Auras.empty()) + { + AuraMap::iterator iter = m_Auras.begin(); + RemoveAura(iter); + } +} + +void Unit::RemoveAllAurasOnDeath() +{ + // used just after dieing to remove all visible auras + // and disable the mods for the passive ones + for(AuraMap::iterator iter = m_Auras.begin(); iter != m_Auras.end();) + { + if (!iter->second->IsPassive() && !iter->second->IsDeathPersistent()) + RemoveAura(iter, AURA_REMOVE_BY_DEATH); + else + ++iter; + } +} + +void Unit::DelayAura(uint32 spellId, uint32 effindex, int32 delaytime) +{ + AuraMap::iterator iter = m_Auras.find(spellEffectPair(spellId, effindex)); + if (iter != m_Auras.end()) + { + if (iter->second->GetAuraDuration() < delaytime) + iter->second->SetAuraDuration(0); + else + iter->second->SetAuraDuration(iter->second->GetAuraDuration() - delaytime); + iter->second->UpdateAuraDuration(); + sLog.outDebug("Aura %u partially interrupted on unit %u, new duration: %u ms",iter->second->GetModifier()->m_auraname, GetGUIDLow(), iter->second->GetAuraDuration()); + } +} + +void Unit::_RemoveAllAuraMods() +{ + for (AuraMap::iterator i = m_Auras.begin(); i != m_Auras.end(); ++i) + { + (*i).second->ApplyModifier(false); + } +} + +void Unit::_ApplyAllAuraMods() +{ + for (AuraMap::iterator i = m_Auras.begin(); i != m_Auras.end(); ++i) + { + (*i).second->ApplyModifier(true); + } +} + +Aura* Unit::GetAura(uint32 spellId, uint32 effindex) +{ + AuraMap::iterator iter = m_Auras.find(spellEffectPair(spellId, effindex)); + if (iter != m_Auras.end()) + return iter->second; + return NULL; +} + +void Unit::AddDynObject(DynamicObject* dynObj) +{ + m_dynObjGUIDs.push_back(dynObj->GetGUID()); +} + +void Unit::RemoveDynObject(uint32 spellid) +{ + if(m_dynObjGUIDs.empty()) + return; + for (DynObjectGUIDs::iterator i = m_dynObjGUIDs.begin(); i != m_dynObjGUIDs.end();) + { + DynamicObject* dynObj = ObjectAccessor::GetDynamicObject(*this,*m_dynObjGUIDs.begin()); + if(!dynObj) + { + i = m_dynObjGUIDs.erase(i); + } + else if(spellid == 0 || dynObj->GetSpellId() == spellid) + { + dynObj->Delete(); + i = m_dynObjGUIDs.erase(i); + } + else + ++i; + } +} + +void Unit::RemoveAllDynObjects() +{ + while(!m_dynObjGUIDs.empty()) + { + DynamicObject* dynObj = ObjectAccessor::GetDynamicObject(*this,*m_dynObjGUIDs.begin()); + if(dynObj) + dynObj->Delete(); + m_dynObjGUIDs.erase(m_dynObjGUIDs.begin()); + } +} + +DynamicObject * Unit::GetDynObject(uint32 spellId, uint32 effIndex) +{ + for (DynObjectGUIDs::iterator i = m_dynObjGUIDs.begin(); i != m_dynObjGUIDs.end();) + { + DynamicObject* dynObj = ObjectAccessor::GetDynamicObject(*this,*m_dynObjGUIDs.begin()); + if(!dynObj) + { + i = m_dynObjGUIDs.erase(i); + continue; + } + + if (dynObj->GetSpellId() == spellId && dynObj->GetEffIndex() == effIndex) + return dynObj; + ++i; + } + return NULL; +} + +DynamicObject * Unit::GetDynObject(uint32 spellId) +{ + for (DynObjectGUIDs::iterator i = m_dynObjGUIDs.begin(); i != m_dynObjGUIDs.end();) + { + DynamicObject* dynObj = ObjectAccessor::GetDynamicObject(*this,*m_dynObjGUIDs.begin()); + if(!dynObj) + { + i = m_dynObjGUIDs.erase(i); + continue; + } + + if (dynObj->GetSpellId() == spellId) + return dynObj; + ++i; + } + return NULL; +} + +void Unit::AddGameObject(GameObject* gameObj) +{ + assert(gameObj && gameObj->GetOwnerGUID()==0); + m_gameObj.push_back(gameObj); + gameObj->SetOwnerGUID(GetGUID()); +} + +void Unit::RemoveGameObject(GameObject* gameObj, bool del) +{ + assert(gameObj && gameObj->GetOwnerGUID()==GetGUID()); + + // GO created by some spell + if ( GetTypeId()==TYPEID_PLAYER && gameObj->GetSpellId() ) + { + SpellEntry const* createBySpell = sSpellStore.LookupEntry(gameObj->GetSpellId()); + // Need activate spell use for owner + if (createBySpell && createBySpell->Attributes & SPELL_ATTR_DISABLED_WHILE_ACTIVE) + ((Player*)this)->SendCooldownEvent(createBySpell); + } + gameObj->SetOwnerGUID(0); + m_gameObj.remove(gameObj); + if(del) + { + gameObj->SetRespawnTime(0); + gameObj->Delete(); + } +} + +void Unit::RemoveGameObject(uint32 spellid, bool del) +{ + if(m_gameObj.empty()) + return; + std::list::iterator i, next; + for (i = m_gameObj.begin(); i != m_gameObj.end(); i = next) + { + next = i; + if(spellid == 0 || (*i)->GetSpellId() == spellid) + { + (*i)->SetOwnerGUID(0); + if(del) + { + (*i)->SetRespawnTime(0); + (*i)->Delete(); + } + + next = m_gameObj.erase(i); + } + else + ++next; + } +} + +void Unit::RemoveAllGameObjects() +{ + // remove references to unit + for(std::list::iterator i = m_gameObj.begin(); i != m_gameObj.end();) + { + (*i)->SetOwnerGUID(0); + (*i)->SetRespawnTime(0); + (*i)->Delete(); + i = m_gameObj.erase(i); + } +} + +void Unit::SendSpellNonMeleeDamageLog(Unit *target,uint32 SpellID,uint32 Damage, SpellSchoolMask damageSchoolMask,uint32 AbsorbedDamage, uint32 Resist,bool PhysicalDamage, uint32 Blocked, bool CriticalHit) +{ + sLog.outDebug("Sending: SMSG_SPELLNONMELEEDAMAGELOG"); + WorldPacket data(SMSG_SPELLNONMELEEDAMAGELOG, (16+4+4+1+4+4+1+1+4+4+1)); // we guess size + data.append(target->GetPackGUID()); + data.append(GetPackGUID()); + data << uint32(SpellID); + data << uint32(Damage-AbsorbedDamage-Resist-Blocked); + data << uint8(damageSchoolMask); // spell school + data << uint32(AbsorbedDamage); // AbsorbedDamage + data << uint32(Resist); // resist + data << uint8(PhysicalDamage); // if 1, then client show spell name (example: %s's ranged shot hit %s for %u school or %s suffers %u school damage from %s's spell_name + data << uint8(0); // unk isFromAura + data << uint32(Blocked); // blocked + data << uint32(CriticalHit ? 0x27 : 0x25); // hitType, flags: 0x2 - SPELL_HIT_TYPE_CRIT, 0x10 - replace caster? + data << uint8(0); // isDebug? + SendMessageToSet( &data, true ); +} + +void Unit::SendSpellMiss(Unit *target, uint32 spellID, SpellMissInfo missInfo) +{ + WorldPacket data(SMSG_SPELLLOGMISS, (4+8+1+4+8+1)); + data << uint32(spellID); + data << uint64(GetGUID()); + data << uint8(0); // can be 0 or 1 + data << uint32(1); // target count + // for(i = 0; i < target count; ++i) + data << uint64(target->GetGUID()); // target GUID + data << uint8(missInfo); + // end loop + SendMessageToSet(&data, true); +} + +void Unit::SendAttackStateUpdate(uint32 HitInfo, Unit *target, uint8 SwingType, SpellSchoolMask damageSchoolMask, uint32 Damage, uint32 AbsorbDamage, uint32 Resist, VictimState TargetState, uint32 BlockedAmount) +{ + sLog.outDebug("WORLD: Sending SMSG_ATTACKERSTATEUPDATE"); + + WorldPacket data(SMSG_ATTACKERSTATEUPDATE, (16+45)); // we guess size + data << (uint32)HitInfo; + data.append(GetPackGUID()); + data.append(target->GetPackGUID()); + data << (uint32)(Damage-AbsorbDamage-Resist-BlockedAmount); + + data << (uint8)SwingType; // count? + + // for(i = 0; i < SwingType; ++i) + data << (uint32)damageSchoolMask; + data << (float)(Damage-AbsorbDamage-Resist-BlockedAmount); + // still need to double check damage + data << (uint32)(Damage-AbsorbDamage-Resist-BlockedAmount); + data << (uint32)AbsorbDamage; + data << (uint32)Resist; + // end loop + + data << (uint32)TargetState; + + if( AbsorbDamage == 0 ) //also 0x3E8 = 0x3E8, check when that happens + data << (uint32)0; + else + data << (uint32)-1; + + data << (uint32)0; + data << (uint32)BlockedAmount; + + SendMessageToSet( &data, true ); +} + +void Unit::ProcDamageAndSpell(Unit *pVictim, uint32 procAttacker, uint32 procVictim, uint32 damage, SpellSchoolMask damageSchoolMask, SpellEntry const *procSpell, bool isTriggeredSpell, WeaponAttackType attType) +{ + sLog.outDebug("ProcDamageAndSpell: attacker flags are 0x%x, victim flags 0x%x", procAttacker, procVictim); + if(procSpell) + sLog.outDebug("ProcDamageAndSpell: invoked due to spell id %u %s", procSpell->Id, (isTriggeredSpell?"(triggered)":"")); + + // Assign melee/ranged proc flags for magic attacks, that are actually melee/ranged abilities + // not assign for spell proc triggered spell to prevent infinity (or unexpacted 2-3 times) melee damage spell proc call with melee damage effect + // That is the question though if it's fully correct + if(procSpell && !isTriggeredSpell) + { + if(procSpell->DmgClass == SPELL_DAMAGE_CLASS_MELEE) + { + if(procAttacker & PROC_FLAG_HIT_SPELL) procAttacker |= PROC_FLAG_HIT_MELEE; + if(procAttacker & PROC_FLAG_CRIT_SPELL) procAttacker |= PROC_FLAG_CRIT_MELEE; + if(procVictim & PROC_FLAG_STRUCK_SPELL) procVictim |= PROC_FLAG_STRUCK_MELEE; + if(procVictim & PROC_FLAG_STRUCK_CRIT_SPELL) procVictim |= PROC_FLAG_STRUCK_CRIT_MELEE; + attType = BASE_ATTACK; // Melee abilities are assumed to be dealt with mainhand weapon + } + else if (procSpell->DmgClass == SPELL_DAMAGE_CLASS_RANGED) + { + if(procAttacker & PROC_FLAG_HIT_SPELL) procAttacker |= PROC_FLAG_HIT_RANGED; + if(procAttacker & PROC_FLAG_CRIT_SPELL) procAttacker |= PROC_FLAG_CRIT_RANGED; + if(procVictim & PROC_FLAG_STRUCK_SPELL) procVictim |= PROC_FLAG_STRUCK_RANGED; + if(procVictim & PROC_FLAG_STRUCK_CRIT_SPELL) procVictim |= PROC_FLAG_STRUCK_CRIT_RANGED; + attType = RANGED_ATTACK; + } + } + if(damage && (procVictim & (PROC_FLAG_STRUCK_MELEE|PROC_FLAG_STRUCK_RANGED|PROC_FLAG_STRUCK_SPELL))) + procVictim |= (PROC_FLAG_TAKE_DAMAGE|PROC_FLAG_TOUCH); + + // Not much to do if no flags are set. + if (procAttacker) + { + // procces auras that not generate casts at proc event before auras that generate casts to prevent proc aura added at prev. proc aura execute in set + ProcDamageAndSpellFor(false,pVictim,procAttacker,attackerProcEffectAuraTypes,attType, procSpell, damage, damageSchoolMask); + ProcDamageAndSpellFor(false,pVictim,procAttacker,attackerProcCastAuraTypes,attType, procSpell, damage, damageSchoolMask); + } + + // Now go on with a victim's events'n'auras + // Not much to do if no flags are set or there is no victim + if(pVictim && pVictim->isAlive() && procVictim) + { + // procces auras that not generate casts at proc event before auras that generate casts to prevent proc aura added at prev. proc aura execute in set + pVictim->ProcDamageAndSpellFor(true,this,procVictim,victimProcEffectAuraTypes,attType,procSpell, damage, damageSchoolMask); + pVictim->ProcDamageAndSpellFor(true,this,procVictim,victimProcCastAuraTypes,attType,procSpell, damage, damageSchoolMask); + } +} + +void Unit::CastMeleeProcDamageAndSpell(Unit* pVictim, uint32 damage, SpellSchoolMask damageSchoolMask, WeaponAttackType attType, MeleeHitOutcome outcome, SpellEntry const *spellCasted, bool isTriggeredSpell) +{ + if(!pVictim) + return; + + uint32 procAttacker = PROC_FLAG_NONE; + uint32 procVictim = PROC_FLAG_NONE; + + switch(outcome) + { + case MELEE_HIT_EVADE: + return; + case MELEE_HIT_MISS: + if(attType == BASE_ATTACK || attType == OFF_ATTACK) + { + procAttacker = PROC_FLAG_MISS; + } + break; + case MELEE_HIT_BLOCK_CRIT: + case MELEE_HIT_CRIT: + if(spellCasted && attType == BASE_ATTACK) + { + procAttacker |= PROC_FLAG_CRIT_SPELL; + procVictim |= PROC_FLAG_STRUCK_CRIT_SPELL; + if ( outcome == MELEE_HIT_BLOCK_CRIT ) + { + procVictim |= PROC_FLAG_BLOCK; + procAttacker |= PROC_FLAG_TARGET_BLOCK; + } + } + else if(attType == BASE_ATTACK || attType == OFF_ATTACK) + { + procAttacker = PROC_FLAG_HIT_MELEE | PROC_FLAG_CRIT_MELEE; + procVictim = PROC_FLAG_STRUCK_MELEE | PROC_FLAG_STRUCK_CRIT_MELEE; + } + else + { + procAttacker = PROC_FLAG_HIT_RANGED | PROC_FLAG_CRIT_RANGED; + procVictim = PROC_FLAG_STRUCK_RANGED | PROC_FLAG_STRUCK_CRIT_RANGED; + } + break; + case MELEE_HIT_PARRY: + procAttacker = PROC_FLAG_TARGET_DODGE_OR_PARRY; + procVictim = PROC_FLAG_PARRY; + break; + case MELEE_HIT_BLOCK: + procAttacker = PROC_FLAG_TARGET_BLOCK; + procVictim = PROC_FLAG_BLOCK; + break; + case MELEE_HIT_DODGE: + procAttacker = PROC_FLAG_TARGET_DODGE_OR_PARRY; + procVictim = PROC_FLAG_DODGE; + break; + case MELEE_HIT_CRUSHING: + if(attType == BASE_ATTACK || attType == OFF_ATTACK) + { + procAttacker = PROC_FLAG_HIT_MELEE | PROC_FLAG_CRIT_MELEE; + procVictim = PROC_FLAG_STRUCK_MELEE | PROC_FLAG_STRUCK_CRIT_MELEE; + } + else + { + procAttacker = PROC_FLAG_HIT_RANGED | PROC_FLAG_CRIT_RANGED; + procVictim = PROC_FLAG_STRUCK_RANGED | PROC_FLAG_STRUCK_CRIT_RANGED; + } + break; + default: + if(attType == BASE_ATTACK || attType == OFF_ATTACK) + { + procAttacker = PROC_FLAG_HIT_MELEE; + procVictim = PROC_FLAG_STRUCK_MELEE; + } + else + { + procAttacker = PROC_FLAG_HIT_RANGED; + procVictim = PROC_FLAG_STRUCK_RANGED; + } + break; + } + + if(damage > 0) + procVictim |= PROC_FLAG_TAKE_DAMAGE; + + if(procAttacker != PROC_FLAG_NONE || procVictim != PROC_FLAG_NONE) + ProcDamageAndSpell(pVictim, procAttacker, procVictim, damage, damageSchoolMask, spellCasted, isTriggeredSpell, attType); +} + +bool Unit::HandleHasteAuraProc(Unit *pVictim, SpellEntry const *hasteSpell, uint32 /*effIndex*/, uint32 damage, Aura* triggeredByAura, SpellEntry const * procSpell, uint32 /*procFlag*/, uint32 cooldown) +{ + Item* castItem = triggeredByAura->GetCastItemGUID() && GetTypeId()==TYPEID_PLAYER + ? ((Player*)this)->GetItemByGuid(triggeredByAura->GetCastItemGUID()) : NULL; + + uint32 triggered_spell_id = 0; + Unit* target = pVictim; + int32 basepoints0 = 0; + + switch(hasteSpell->SpellFamilyName) + { + case SPELLFAMILY_ROGUE: + { + switch(hasteSpell->Id) + { + // Blade Flurry + case 13877: + case 33735: + { + target = SelectNearbyTarget(); + if(!target) + return false; + basepoints0 = damage; + triggered_spell_id = 22482; + break; + } + } + break; + } + } + + // processed charge only counting case + if(!triggered_spell_id) + return true; + + SpellEntry const* triggerEntry = sSpellStore.LookupEntry(triggered_spell_id); + + if(!triggerEntry) + { + sLog.outError("Unit::HandleHasteAuraProc: Spell %u have not existed triggered spell %u",hasteSpell->Id,triggered_spell_id); + return false; + } + + // default case + if(!target || target!=this && !target->isAlive()) + return false; + + if( cooldown && GetTypeId()==TYPEID_PLAYER && ((Player*)this)->HasSpellCooldown(triggered_spell_id)) + return false; + + if(basepoints0) + CastCustomSpell(target,triggered_spell_id,&basepoints0,NULL,NULL,true,castItem,triggeredByAura); + else + CastSpell(target,triggered_spell_id,true,castItem,triggeredByAura); + + if( cooldown && GetTypeId()==TYPEID_PLAYER ) + ((Player*)this)->AddSpellCooldown(triggered_spell_id,0,time(NULL) + cooldown); + + return true; +} + +bool Unit::HandleDummyAuraProc(Unit *pVictim, SpellEntry const *dummySpell, uint32 effIndex, uint32 damage, Aura* triggeredByAura, SpellEntry const * procSpell, uint32 procFlag, uint32 cooldown) +{ + Item* castItem = triggeredByAura->GetCastItemGUID() && GetTypeId()==TYPEID_PLAYER + ? ((Player*)this)->GetItemByGuid(triggeredByAura->GetCastItemGUID()) : NULL; + + uint32 triggered_spell_id = 0; + Unit* target = pVictim; + int32 basepoints0 = 0; + + switch(dummySpell->SpellFamilyName) + { + case SPELLFAMILY_GENERIC: + { + switch (dummySpell->Id) + { + // Eye of Eye + case 9799: + case 25988: + { + // prevent damage back from weapon special attacks + if (!procSpell || procSpell->DmgClass != SPELL_DAMAGE_CLASS_MAGIC ) + return false; + + // return damage % to attacker but < 50% own total health + basepoints0 = triggeredByAura->GetModifier()->m_amount*int32(damage)/100; + if(basepoints0 > GetMaxHealth()/2) + basepoints0 = GetMaxHealth()/2; + + triggered_spell_id = 25997; + break; + } + // Sweeping Strikes + case 12328: + case 18765: + case 35429: + { + // prevent chain of triggred spell from same triggred spell + if(procSpell && procSpell->Id==26654) + return false; + + target = SelectNearbyTarget(); + if(!target) + return false; + + triggered_spell_id = 26654; + break; + } + // Unstable Power + case 24658: + { + if (!procSpell || procSpell->Id == 24659) + return false; + // Need remove one 24659 aura + RemoveSingleAuraFromStack(24659, 0); + RemoveSingleAuraFromStack(24659, 1); + return true; + } + // Restless Strength + case 24661: + { + // Need remove one 24662 aura + RemoveSingleAuraFromStack(24662, 0); + return true; + } + // Adaptive Warding (Frostfire Regalia set) + case 28764: + { + if(!procSpell) + return false; + + // find Mage Armor + bool found = false; + AuraList const& mRegenInterupt = GetAurasByType(SPELL_AURA_MOD_MANA_REGEN_INTERRUPT); + for(AuraList::const_iterator iter = mRegenInterupt.begin(); iter != mRegenInterupt.end(); ++iter) + { + if(SpellEntry const* iterSpellProto = (*iter)->GetSpellProto()) + { + if(iterSpellProto->SpellFamilyName==SPELLFAMILY_MAGE && (iterSpellProto->SpellFamilyFlags & 0x10000000)) + { + found=true; + break; + } + } + } + if(!found) + return false; + + switch(GetFirstSchoolInMask(GetSpellSchoolMask(procSpell))) + { + case SPELL_SCHOOL_NORMAL: + case SPELL_SCHOOL_HOLY: + return false; // ignored + case SPELL_SCHOOL_FIRE: triggered_spell_id = 28765; break; + case SPELL_SCHOOL_NATURE: triggered_spell_id = 28768; break; + case SPELL_SCHOOL_FROST: triggered_spell_id = 28766; break; + case SPELL_SCHOOL_SHADOW: triggered_spell_id = 28769; break; + case SPELL_SCHOOL_ARCANE: triggered_spell_id = 28770; break; + default: + return false; + } + + target = this; + break; + } + // Obsidian Armor (Justice Bearer`s Pauldrons shoulder) + case 27539: + { + if(!procSpell) + return false; + + // not from DoT + bool found = false; + for(int j = 0; j < 3; ++j) + { + if(procSpell->EffectApplyAuraName[j]==SPELL_AURA_PERIODIC_DAMAGE||procSpell->EffectApplyAuraName[j]==SPELL_AURA_PERIODIC_DAMAGE_PERCENT) + { + found = true; + break; + } + } + if(found) + return false; + + switch(GetFirstSchoolInMask(GetSpellSchoolMask(procSpell))) + { + case SPELL_SCHOOL_NORMAL: + return false; // ignore + case SPELL_SCHOOL_HOLY: triggered_spell_id = 27536; break; + case SPELL_SCHOOL_FIRE: triggered_spell_id = 27533; break; + case SPELL_SCHOOL_NATURE: triggered_spell_id = 27538; break; + case SPELL_SCHOOL_FROST: triggered_spell_id = 27534; break; + case SPELL_SCHOOL_SHADOW: triggered_spell_id = 27535; break; + case SPELL_SCHOOL_ARCANE: triggered_spell_id = 27540; break; + default: + return false; + } + + target = this; + break; + } + // Mana Leech (Passive) (Priest Pet Aura) + case 28305: + { + // Cast on owner + target = GetOwner(); + if(!target) + return false; + + basepoints0 = int32(damage * 2.5f); // manaregen + triggered_spell_id = 34650; + break; + } + // Mark of Malice + case 33493: + { + // Cast finish spell at last charge + if (triggeredByAura->m_procCharges > 1) + return false; + + target = this; + triggered_spell_id = 33494; + break; + } + // Twisted Reflection (boss spell) + case 21063: + triggered_spell_id = 21064; + break; + // Vampiric Aura (boss spell) + case 38196: + { + basepoints0 = 3 * damage; // 300% + if (basepoints0 < 0) + return false; + + triggered_spell_id = 31285; + target = this; + break; + } + // Aura of Madness (Darkmoon Card: Madness trinket) + //===================================================== + // 39511 Sociopath: +35 strength (Paladin, Rogue, Druid, Warrior) + // 40997 Delusional: +70 attack power (Rogue, Hunter, Paladin, Warrior, Druid) + // 40998 Kleptomania: +35 agility (Warrior, Rogue, Paladin, Hunter, Druid) + // 40999 Megalomania: +41 damage/healing (Druid, Shaman, Priest, Warlock, Mage, Paladin) + // 41002 Paranoia: +35 spell/melee/ranged crit strike rating (All classes) + // 41005 Manic: +35 haste (spell, melee and ranged) (All classes) + // 41009 Narcissism: +35 intellect (Druid, Shaman, Priest, Warlock, Mage, Paladin, Hunter) + // 41011 Martyr Complex: +35 stamina (All classes) + // 41406 Dementia: Every 5 seconds either gives you +5% damage/healing. (Druid, Shaman, Priest, Warlock, Mage, Paladin) + // 41409 Dementia: Every 5 seconds either gives you -5% damage/healing. (Druid, Shaman, Priest, Warlock, Mage, Paladin) + case 39446: + { + if(GetTypeId() != TYPEID_PLAYER) + return false; + + // Select class defined buff + switch (getClass()) + { + case CLASS_PALADIN: // 39511,40997,40998,40999,41002,41005,41009,41011,41409 + case CLASS_DRUID: // 39511,40997,40998,40999,41002,41005,41009,41011,41409 + { + uint32 RandomSpell[]={39511,40997,40998,40999,41002,41005,41009,41011,41409}; + triggered_spell_id = RandomSpell[ irand(0, sizeof(RandomSpell)/sizeof(uint32) - 1) ]; + break; + } + case CLASS_ROGUE: // 39511,40997,40998,41002,41005,41011 + case CLASS_WARRIOR: // 39511,40997,40998,41002,41005,41011 + { + uint32 RandomSpell[]={39511,40997,40998,41002,41005,41011}; + triggered_spell_id = RandomSpell[ irand(0, sizeof(RandomSpell)/sizeof(uint32) - 1) ]; + break; + } + case CLASS_PRIEST: // 40999,41002,41005,41009,41011,41406,41409 + case CLASS_SHAMAN: // 40999,41002,41005,41009,41011,41406,41409 + case CLASS_MAGE: // 40999,41002,41005,41009,41011,41406,41409 + case CLASS_WARLOCK: // 40999,41002,41005,41009,41011,41406,41409 + { + uint32 RandomSpell[]={40999,41002,41005,41009,41011,41406,41409}; + triggered_spell_id = RandomSpell[ irand(0, sizeof(RandomSpell)/sizeof(uint32) - 1) ]; + break; + } + case CLASS_HUNTER: // 40997,40999,41002,41005,41009,41011,41406,41409 + { + uint32 RandomSpell[]={40997,40999,41002,41005,41009,41011,41406,41409}; + triggered_spell_id = RandomSpell[ irand(0, sizeof(RandomSpell)/sizeof(uint32) - 1) ]; + break; + } + default: + return false; + } + + target = this; + if (roll_chance_i(10)) + ((Player*)this)->Say("This is Madness!", LANG_UNIVERSAL); + break; + } + /* + // TODO: need find item for aura and triggered spells + // Sunwell Exalted Caster Neck (??? neck) + // cast ??? Light's Wrath if Exalted by Aldor + // cast ??? Arcane Bolt if Exalted by Scryers*/ + case 46569: + return false; // disable for while + /* + { + if(GetTypeId() != TYPEID_PLAYER) + return false; + + // Get Aldor reputation rank + if (((Player *)this)->GetReputationRank(932) == REP_EXALTED) + { + target = this; + triggered_spell_id = ??? + break; + } + // Get Scryers reputation rank + if (((Player *)this)->GetReputationRank(934) == REP_EXALTED) + { + triggered_spell_id = ??? + break; + } + return false; + }/**/ + // Sunwell Exalted Caster Neck (Shattered Sun Pendant of Acumen neck) + // cast 45479 Light's Wrath if Exalted by Aldor + // cast 45429 Arcane Bolt if Exalted by Scryers + case 45481: + { + if(GetTypeId() != TYPEID_PLAYER) + return false; + + // Get Aldor reputation rank + if (((Player *)this)->GetReputationRank(932) == REP_EXALTED) + { + target = this; + triggered_spell_id = 45479; + break; + } + // Get Scryers reputation rank + if (((Player *)this)->GetReputationRank(934) == REP_EXALTED) + { + triggered_spell_id = 45429; + break; + } + return false; + } + // Sunwell Exalted Melee Neck (Shattered Sun Pendant of Might neck) + // cast 45480 Light's Strength if Exalted by Aldor + // cast 45428 Arcane Strike if Exalted by Scryers + case 45482: + { + if(GetTypeId() != TYPEID_PLAYER) + return false; + + // Get Aldor reputation rank + if (((Player *)this)->GetReputationRank(932) == REP_EXALTED) + { + target = this; + triggered_spell_id = 45480; + break; + } + // Get Scryers reputation rank + if (((Player *)this)->GetReputationRank(934) == REP_EXALTED) + { + triggered_spell_id = 45428; + break; + } + return false; + } + // Sunwell Exalted Tank Neck (Shattered Sun Pendant of Resolve neck) + // cast 45431 Arcane Insight if Exalted by Aldor + // cast 45432 Light's Ward if Exalted by Scryers + case 45483: + { + if(GetTypeId() != TYPEID_PLAYER) + return false; + + // Get Aldor reputation rank + if (((Player *)this)->GetReputationRank(932) == REP_EXALTED) + { + target = this; + triggered_spell_id = 45432; + break; + } + // Get Scryers reputation rank + if (((Player *)this)->GetReputationRank(934) == REP_EXALTED) + { + target = this; + triggered_spell_id = 45431; + break; + } + return false; + } + // Sunwell Exalted Healer Neck (Shattered Sun Pendant of Restoration neck) + // cast 45478 Light's Salvation if Exalted by Aldor + // cast 45430 Arcane Surge if Exalted by Scryers + case 45484: + { + if(GetTypeId() != TYPEID_PLAYER) + return false; + + // Get Aldor reputation rank + if (((Player *)this)->GetReputationRank(932) == REP_EXALTED) + { + target = this; + triggered_spell_id = 45478; + break; + } + // Get Scryers reputation rank + if (((Player *)this)->GetReputationRank(934) == REP_EXALTED) + { + triggered_spell_id = 45430; + break; + } + return false; + } + } + break; + } + case SPELLFAMILY_MAGE: + { + // Magic Absorption + if (dummySpell->SpellIconID == 459) // only this spell have SpellIconID == 459 and dummy aura + { + if (getPowerType() != POWER_MANA) + return false; + + // mana reward + basepoints0 = (triggeredByAura->GetModifier()->m_amount * GetMaxPower(POWER_MANA) / 100); + target = this; + triggered_spell_id = 29442; + break; + } + // Master of Elements + if (dummySpell->SpellIconID == 1920) + { + if(!procSpell) + return false; + + // mana cost save + basepoints0 = procSpell->manaCost * triggeredByAura->GetModifier()->m_amount/100; + if( basepoints0 <=0 ) + return false; + + target = this; + triggered_spell_id = 29077; + break; + } + switch(dummySpell->Id) + { + // Ignite + case 11119: + case 11120: + case 12846: + case 12847: + case 12848: + { + switch (dummySpell->Id) + { + case 11119: basepoints0 = int32(0.04f*damage); break; + case 11120: basepoints0 = int32(0.08f*damage); break; + case 12846: basepoints0 = int32(0.12f*damage); break; + case 12847: basepoints0 = int32(0.16f*damage); break; + case 12848: basepoints0 = int32(0.20f*damage); break; + default: + sLog.outError("Unit::HandleDummyAuraProc: non handled spell id: %u (IG)",dummySpell->Id); + return false; + } + + triggered_spell_id = 12654; + break; + } + // Combustion + case 11129: + { + //last charge and crit + if( triggeredByAura->m_procCharges <= 1 && (procFlag & PROC_FLAG_CRIT_SPELL) ) + { + RemoveAurasDueToSpell(28682); //-> remove Combustion auras + return true; // charge counting (will removed) + } + + CastSpell(this, 28682, true, castItem, triggeredByAura); + return(procFlag & PROC_FLAG_CRIT_SPELL);// charge update only at crit hits, no hidden cooldowns + } + } + break; + } + case SPELLFAMILY_WARRIOR: + { + // Retaliation + if(dummySpell->SpellFamilyFlags==0x0000000800000000LL) + { + // check attack comes not from behind + if (!HasInArc(M_PI, pVictim)) + return false; + + triggered_spell_id = 22858; + break; + } + break; + } + case SPELLFAMILY_WARLOCK: + { + // Seed of Corruption + if (dummySpell->SpellFamilyFlags & 0x0000001000000000LL) + { + Modifier* mod = triggeredByAura->GetModifier(); + // if damage is more than need or target die from damage deal finish spell + // FIX ME: not triggered currently at death + if( mod->m_amount <= damage || GetHealth() <= damage ) + { + // remember guid before aura delete + uint64 casterGuid = triggeredByAura->GetCasterGUID(); + + // Remove aura (before cast for prevent infinite loop handlers) + RemoveAurasDueToSpell(triggeredByAura->GetId()); + + // Cast finish spell (triggeredByAura already not exist!) + CastSpell(this, 27285, true, castItem, NULL, casterGuid); + return true; // no hidden cooldown + } + + // Damage counting + mod->m_amount-=damage; + return true; + } + // Seed of Corruption (Mobs cast) - no die req + if (dummySpell->SpellFamilyFlags == 0x00LL && dummySpell->SpellIconID == 1932) + { + Modifier* mod = triggeredByAura->GetModifier(); + // if damage is more than need deal finish spell + if( mod->m_amount <= damage ) + { + // remember guid before aura delete + uint64 casterGuid = triggeredByAura->GetCasterGUID(); + + // Remove aura (before cast for prevent infinite loop handlers) + RemoveAurasDueToSpell(triggeredByAura->GetId()); + + // Cast finish spell (triggeredByAura already not exist!) + CastSpell(this, 32865, true, castItem, NULL, casterGuid); + return true; // no hidden cooldown + } + // Damage counting + mod->m_amount-=damage; + return true; + } + switch(dummySpell->Id) + { + // Nightfall + case 18094: + case 18095: + { + target = this; + triggered_spell_id = 17941; + break; + } + //Soul Leech + case 30293: + case 30295: + case 30296: + { + // health + basepoints0 = int32(damage*triggeredByAura->GetModifier()->m_amount/100); + target = this; + triggered_spell_id = 30294; + break; + } + // Shadowflame (Voidheart Raiment set bonus) + case 37377: + { + triggered_spell_id = 37379; + break; + } + // Pet Healing (Corruptor Raiment or Rift Stalker Armor) + case 37381: + { + target = GetPet(); + if(!target) + return false; + + // heal amount + basepoints0 = damage * triggeredByAura->GetModifier()->m_amount/100; + triggered_spell_id = 37382; + break; + } + // Shadowflame Hellfire (Voidheart Raiment set bonus) + case 39437: + { + triggered_spell_id = 37378; + break; + } + } + break; + } + case SPELLFAMILY_PRIEST: + { + // Vampiric Touch + if( dummySpell->SpellFamilyFlags & 0x0000040000000000LL ) + { + if(!pVictim || !pVictim->isAlive()) + return false; + + // pVictim is caster of aura + if(triggeredByAura->GetCasterGUID() != pVictim->GetGUID()) + return false; + + // energize amount + basepoints0 = triggeredByAura->GetModifier()->m_amount*damage/100; + pVictim->CastCustomSpell(pVictim,34919,&basepoints0,NULL,NULL,true,castItem,triggeredByAura); + return true; // no hidden cooldown + } + switch(dummySpell->Id) + { + // Vampiric Embrace + case 15286: + { + if(!pVictim || !pVictim->isAlive()) + return false; + + // pVictim is caster of aura + if(triggeredByAura->GetCasterGUID() != pVictim->GetGUID()) + return false; + + // heal amount + basepoints0 = triggeredByAura->GetModifier()->m_amount*damage/100; + pVictim->CastCustomSpell(pVictim,15290,&basepoints0,NULL,NULL,true,castItem,triggeredByAura); + return true; // no hidden cooldown + } + // Priest Tier 6 Trinket (Ashtongue Talisman of Acumen) + case 40438: + { + // Shadow Word: Pain + if( procSpell->SpellFamilyFlags & 0x0000000000008000LL ) + triggered_spell_id = 40441; + // Renew + else if( procSpell->SpellFamilyFlags & 0x0000000000000010LL ) + triggered_spell_id = 40440; + else + return false; + + target = this; + break; + } + // Oracle Healing Bonus ("Garments of the Oracle" set) + case 26169: + { + // heal amount + basepoints0 = int32(damage * 10/100); + target = this; + triggered_spell_id = 26170; + break; + } + // Frozen Shadoweave (Shadow's Embrace set) warning! its not only priest set + case 39372: + { + if(!procSpell || (GetSpellSchoolMask(procSpell) & (SPELL_SCHOOL_MASK_FROST | SPELL_SCHOOL_MASK_SHADOW))==0 ) + return false; + + // heal amount + basepoints0 = int32(damage * 2 / 100); + target = this; + triggered_spell_id = 39373; + break; + } + // Vestments of Faith (Priest Tier 3) - 4 pieces bonus + case 28809: + { + triggered_spell_id = 28810; + break; + } + } + break; + } + case SPELLFAMILY_DRUID: + { + switch(dummySpell->Id) + { + // Healing Touch (Dreamwalker Raiment set) + case 28719: + { + // mana back + basepoints0 = int32(procSpell->manaCost * 30 / 100); + target = this; + triggered_spell_id = 28742; + break; + } + // Healing Touch Refund (Idol of Longevity trinket) + case 28847: + { + target = this; + triggered_spell_id = 28848; + break; + } + // Mana Restore (Malorne Raiment set / Malorne Regalia set) + case 37288: + case 37295: + { + target = this; + triggered_spell_id = 37238; + break; + } + // Druid Tier 6 Trinket + case 40442: + { + float chance; + + // Starfire + if( procSpell->SpellFamilyFlags & 0x0000000000000004LL ) + { + triggered_spell_id = 40445; + chance = 25.f; + } + // Rejuvenation + else if( procSpell->SpellFamilyFlags & 0x0000000000000010LL ) + { + triggered_spell_id = 40446; + chance = 25.f; + } + // Mangle (cat/bear) + else if( procSpell->SpellFamilyFlags & 0x0000044000000000LL ) + { + triggered_spell_id = 40452; + chance = 40.f; + } + else + return false; + + if (!roll_chance_f(chance)) + return false; + + target = this; + break; + } + // Maim Interrupt + case 44835: + { + // Deadly Interrupt Effect + triggered_spell_id = 32747; + break; + } + } + break; + } + case SPELLFAMILY_ROGUE: + { + switch(dummySpell->Id) + { + // Deadly Throw Interrupt + case 32748: + { + // Prevent cast Deadly Throw Interrupt on self from last effect (apply dummy) of Deadly Throw + if(this == pVictim) + return false; + + triggered_spell_id = 32747; + break; + } + } + // Quick Recovery + if( dummySpell->SpellIconID == 2116 ) + { + if(!procSpell) + return false; + + // only rogue's finishing moves (maybe need additional checks) + if( procSpell->SpellFamilyName!=SPELLFAMILY_ROGUE || + (procSpell->SpellFamilyFlags & SPELLFAMILYFLAG_ROGUE__FINISHING_MOVE) == 0) + return false; + + // energy cost save + basepoints0 = procSpell->manaCost * triggeredByAura->GetModifier()->m_amount/100; + if(basepoints0 <= 0) + return false; + + target = this; + triggered_spell_id = 31663; + break; + } + break; + } + case SPELLFAMILY_HUNTER: + { + // Thrill of the Hunt + if ( dummySpell->SpellIconID == 2236 ) + { + if(!procSpell) + return false; + + // mana cost save + basepoints0 = procSpell->manaCost * 40/100; + if(basepoints0 <= 0) + return false; + + target = this; + triggered_spell_id = 34720; + break; + } + break; + } + case SPELLFAMILY_PALADIN: + { + // Seal of Righteousness - melee proc dummy + if (dummySpell->SpellFamilyFlags&0x000000008000000LL && triggeredByAura->GetEffIndex()==0) + { + if(GetTypeId() != TYPEID_PLAYER) + return false; + + uint32 spellId; + switch (triggeredByAura->GetId()) + { + case 21084: spellId = 25742; break; // Rank 1 + case 20287: spellId = 25740; break; // Rank 2 + case 20288: spellId = 25739; break; // Rank 3 + case 20289: spellId = 25738; break; // Rank 4 + case 20290: spellId = 25737; break; // Rank 5 + case 20291: spellId = 25736; break; // Rank 6 + case 20292: spellId = 25735; break; // Rank 7 + case 20293: spellId = 25713; break; // Rank 8 + case 27155: spellId = 27156; break; // Rank 9 + default: + sLog.outError("Unit::HandleDummyAuraProc: non handled possibly SoR (Id = %u)", triggeredByAura->GetId()); + return false; + } + Item *item = ((Player*)this)->GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_MAINHAND); + float speed = (item ? item->GetProto()->Delay : BASE_ATTACK_TIME)/1000.0f; + + float damageBasePoints; + if(item && item->GetProto()->InventoryType == INVTYPE_2HWEAPON) + // two hand weapon + damageBasePoints=1.20f*triggeredByAura->GetModifier()->m_amount * 1.2f * 1.03f * speed/100.0f + 1; + else + // one hand weapon/no weapon + damageBasePoints=0.85f*ceil(triggeredByAura->GetModifier()->m_amount * 1.2f * 1.03f * speed/100.0f) - 1; + + int32 damagePoint = int32(damageBasePoints + 0.03f * (GetWeaponDamageRange(BASE_ATTACK,MINDAMAGE)+GetWeaponDamageRange(BASE_ATTACK,MAXDAMAGE))/2.0f) + 1; + + // apply damage bonuses manually + if(damagePoint >= 0) + damagePoint = SpellDamageBonus(pVictim, dummySpell, damagePoint, SPELL_DIRECT_DAMAGE); + + CastCustomSpell(pVictim,spellId,&damagePoint,NULL,NULL,true,NULL, triggeredByAura); + return true; // no hidden cooldown + } + // Seal of Blood do damage trigger + if(dummySpell->SpellFamilyFlags & 0x0000040000000000LL) + { + switch(triggeredByAura->GetEffIndex()) + { + case 0: + // prevent chain triggering + if(procSpell && procSpell->Id==31893 ) + return false; + + triggered_spell_id = 31893; + break; + case 1: + { + // damage + basepoints0 = triggeredByAura->GetModifier()->m_amount * damage / 100; + target = this; + triggered_spell_id = 32221; + break; + } + } + } + + switch(dummySpell->Id) + { + // Holy Power (Redemption Armor set) + case 28789: + { + if(!pVictim) + return false; + + // Set class defined buff + switch (pVictim->getClass()) + { + case CLASS_PALADIN: + case CLASS_PRIEST: + case CLASS_SHAMAN: + case CLASS_DRUID: + triggered_spell_id = 28795; // Increases the friendly target's mana regeneration by $s1 per 5 sec. for $d. + break; + case CLASS_MAGE: + case CLASS_WARLOCK: + triggered_spell_id = 28793; // Increases the friendly target's spell damage and healing by up to $s1 for $d. + break; + case CLASS_HUNTER: + case CLASS_ROGUE: + triggered_spell_id = 28791; // Increases the friendly target's attack power by $s1 for $d. + break; + case CLASS_WARRIOR: + triggered_spell_id = 28790; // Increases the friendly target's armor + break; + default: + return false; + } + break; + } + //Seal of Vengeance + case 31801: + { + if(effIndex != 0) // effect 1,2 used by seal unleashing code + return false; + + triggered_spell_id = 31803; + break; + } + // Spiritual Att. + case 31785: + case 33776: + { + // if healed by another unit (pVictim) + if(this == pVictim) + return false; + + // heal amount + basepoints0 = triggeredByAura->GetModifier()->m_amount*damage/100; + target = this; + triggered_spell_id = 31786; + break; + } + // Paladin Tier 6 Trinket (Ashtongue Talisman of Zeal) + case 40470: + { + if( !procSpell ) + return false; + + float chance; + + // Flash of light/Holy light + if( procSpell->SpellFamilyFlags & 0x00000000C0000000LL) + { + triggered_spell_id = 40471; + chance = 15.f; + } + // Judgement + else if( procSpell->SpellFamilyFlags & 0x0000000000800000LL ) + { + triggered_spell_id = 40472; + chance = 50.f; + } + else + return false; + + if (!roll_chance_f(chance)) + return false; + + break; + } + } + break; + } + case SPELLFAMILY_SHAMAN: + { + switch(dummySpell->Id) + { + // Totemic Power (The Earthshatterer set) + case 28823: + { + if( !pVictim ) + return false; + + // Set class defined buff + switch (pVictim->getClass()) + { + case CLASS_PALADIN: + case CLASS_PRIEST: + case CLASS_SHAMAN: + case CLASS_DRUID: + triggered_spell_id = 28824; // Increases the friendly target's mana regeneration by $s1 per 5 sec. for $d. + break; + case CLASS_MAGE: + case CLASS_WARLOCK: + triggered_spell_id = 28825; // Increases the friendly target's spell damage and healing by up to $s1 for $d. + break; + case CLASS_HUNTER: + case CLASS_ROGUE: + triggered_spell_id = 28826; // Increases the friendly target's attack power by $s1 for $d. + break; + case CLASS_WARRIOR: + triggered_spell_id = 28827; // Increases the friendly target's armor + break; + default: + return false; + } + break; + } + // Lesser Healing Wave (Totem of Flowing Water Relic) + case 28849: + { + target = this; + triggered_spell_id = 28850; + break; + } + // Windfury Weapon (Passive) 1-5 Ranks + case 33757: + { + if(GetTypeId()!=TYPEID_PLAYER) + return false; + + if(!castItem || !castItem->IsEquipped()) + return false; + + // custom cooldown processing case + if( cooldown && ((Player*)this)->HasSpellCooldown(dummySpell->Id)) + return false; + + uint32 spellId; + switch (castItem->GetEnchantmentId(EnchantmentSlot(TEMP_ENCHANTMENT_SLOT))) + { + case 283: spellId = 33757; break; //1 Rank + case 284: spellId = 33756; break; //2 Rank + case 525: spellId = 33755; break; //3 Rank + case 1669:spellId = 33754; break; //4 Rank + case 2636:spellId = 33727; break; //5 Rank + default: + { + sLog.outError("Unit::HandleDummyAuraProc: non handled item enchantment (rank?) %u for spell id: %u (Windfury)", + castItem->GetEnchantmentId(EnchantmentSlot(TEMP_ENCHANTMENT_SLOT)),dummySpell->Id); + return false; + } + } + + SpellEntry const* windfurySpellEntry = sSpellStore.LookupEntry(spellId); + if(!windfurySpellEntry) + { + sLog.outError("Unit::HandleDummyAuraProc: non existed spell id: %u (Windfury)",spellId); + return false; + } + + int32 extra_attack_power = CalculateSpellDamage(windfurySpellEntry,0,windfurySpellEntry->EffectBasePoints[0],pVictim); + + // Off-Hand case + if ( castItem->GetSlot() == EQUIPMENT_SLOT_OFFHAND ) + { + // Value gained from additional AP + basepoints0 = int32(extra_attack_power/14.0f * GetAttackTime(OFF_ATTACK)/1000/2); + triggered_spell_id = 33750; + } + // Main-Hand case + else + { + // Value gained from additional AP + basepoints0 = int32(extra_attack_power/14.0f * GetAttackTime(BASE_ATTACK)/1000); + triggered_spell_id = 25504; + } + + // apply cooldown before cast to prevent processing itself + if( cooldown ) + ((Player*)this)->AddSpellCooldown(dummySpell->Id,0,time(NULL) + cooldown); + + // Attack Twice + for ( uint32 i = 0; i<2; ++i ) + CastCustomSpell(pVictim,triggered_spell_id,&basepoints0,NULL,NULL,true,castItem,triggeredByAura); + + return true; + } + // Shaman Tier 6 Trinket + case 40463: + { + if( !procSpell ) + return false; + + float chance; + if (procSpell->SpellFamilyFlags & 0x0000000000000001LL) + { + triggered_spell_id = 40465; // Lightning Bolt + chance = 15.f; + } + else if (procSpell->SpellFamilyFlags & 0x0000000000000080LL) + { + triggered_spell_id = 40465; // Lesser Healing Wave + chance = 10.f; + } + else if (procSpell->SpellFamilyFlags & 0x0000001000000000LL) + { + triggered_spell_id = 40466; // Stormstrike + chance = 50.f; + } + else + return false; + + if (!roll_chance_f(chance)) + return false; + + target = this; + break; + } + } + + // Earth Shield + if(dummySpell->SpellFamilyFlags==0x40000000000LL) + { + if(GetTypeId() != TYPEID_PLAYER) + return false; + + // heal + basepoints0 = triggeredByAura->GetModifier()->m_amount; + target = this; + triggered_spell_id = 379; + break; + } + // Lightning Overload + if (dummySpell->SpellIconID == 2018) // only this spell have SpellFamily Shaman SpellIconID == 2018 and dummy aura + { + if(!procSpell || GetTypeId() != TYPEID_PLAYER || !pVictim ) + return false; + + // custom cooldown processing case + if( cooldown && GetTypeId()==TYPEID_PLAYER && ((Player*)this)->HasSpellCooldown(dummySpell->Id)) + return false; + + uint32 spellId = 0; + // Every Lightning Bolt and Chain Lightning spell have dublicate vs half damage and zero cost + switch (procSpell->Id) + { + // Lightning Bolt + case 403: spellId = 45284; break; // Rank 1 + case 529: spellId = 45286; break; // Rank 2 + case 548: spellId = 45287; break; // Rank 3 + case 915: spellId = 45288; break; // Rank 4 + case 943: spellId = 45289; break; // Rank 5 + case 6041: spellId = 45290; break; // Rank 6 + case 10391: spellId = 45291; break; // Rank 7 + case 10392: spellId = 45292; break; // Rank 8 + case 15207: spellId = 45293; break; // Rank 9 + case 15208: spellId = 45294; break; // Rank 10 + case 25448: spellId = 45295; break; // Rank 11 + case 25449: spellId = 45296; break; // Rank 12 + // Chain Lightning + case 421: spellId = 45297; break; // Rank 1 + case 930: spellId = 45298; break; // Rank 2 + case 2860: spellId = 45299; break; // Rank 3 + case 10605: spellId = 45300; break; // Rank 4 + case 25439: spellId = 45301; break; // Rank 5 + case 25442: spellId = 45302; break; // Rank 6 + default: + sLog.outError("Unit::HandleDummyAuraProc: non handled spell id: %u (LO)", procSpell->Id); + return false; + } + // No thread generated mod + SpellModifier *mod = new SpellModifier; + mod->op = SPELLMOD_THREAT; + mod->value = -100; + mod->type = SPELLMOD_PCT; + mod->spellId = dummySpell->Id; + mod->effectId = 0; + mod->lastAffected = NULL; + mod->mask = 0x0000000000000003LL; + mod->charges = 0; + ((Player*)this)->AddSpellMod(mod, true); + + // Remove cooldown (Chain Lightning - have Category Recovery time) + if (procSpell->SpellFamilyFlags & 0x0000000000000002LL) + ((Player*)this)->RemoveSpellCooldown(spellId); + + // Hmmm.. in most case spells alredy set half basepoints but... + // Lightning Bolt (2-10 rank) have full basepoint and half bonus from level + // As on wiki: + // BUG: Rank 2 to 10 (and maybe 11) of Lightning Bolt will proc another Bolt with FULL damage (not halved). This bug is known and will probably be fixed soon. + // So - no add changes :) + CastSpell(pVictim, spellId, true, castItem, triggeredByAura); + + ((Player*)this)->AddSpellMod(mod, false); + + if( cooldown && GetTypeId()==TYPEID_PLAYER ) + ((Player*)this)->AddSpellCooldown(dummySpell->Id,0,time(NULL) + cooldown); + + return true; + } + break; + } + default: + break; + } + + // processed charge only counting case + if(!triggered_spell_id) + return true; + + SpellEntry const* triggerEntry = sSpellStore.LookupEntry(triggered_spell_id); + + if(!triggerEntry) + { + sLog.outError("Unit::HandleDummyAuraProc: Spell %u have not existed triggered spell %u",dummySpell->Id,triggered_spell_id); + return false; + } + + // default case + if(!target || target!=this && !target->isAlive()) + return false; + + if( cooldown && GetTypeId()==TYPEID_PLAYER && ((Player*)this)->HasSpellCooldown(triggered_spell_id)) + return false; + + if(basepoints0) + CastCustomSpell(target,triggered_spell_id,&basepoints0,NULL,NULL,true,castItem,triggeredByAura); + else + CastSpell(target,triggered_spell_id,true,castItem,triggeredByAura); + + if( cooldown && GetTypeId()==TYPEID_PLAYER ) + ((Player*)this)->AddSpellCooldown(triggered_spell_id,0,time(NULL) + cooldown); + + return true; +} + +bool Unit::HandleProcTriggerSpell(Unit *pVictim, uint32 damage, Aura* triggeredByAura, SpellEntry const *procSpell, uint32 procFlags,WeaponAttackType attackType, uint32 cooldown) +{ + SpellEntry const* auraSpellInfo = triggeredByAura->GetSpellProto(); + + Item* castItem = triggeredByAura->GetCastItemGUID() && GetTypeId()==TYPEID_PLAYER + ? ((Player*)this)->GetItemByGuid(triggeredByAura->GetCastItemGUID()) : NULL; + + uint32 triggered_spell_id = auraSpellInfo->EffectTriggerSpell[triggeredByAura->GetEffIndex()]; + Unit* target = !(procFlags & PROC_FLAG_HEAL) && IsPositiveSpell(triggered_spell_id) ? this : pVictim; + int32 basepoints0 = 0; + + switch(auraSpellInfo->SpellFamilyName) + { + case SPELLFAMILY_GENERIC: + { + switch(auraSpellInfo->Id) + { + // Aegis of Preservation + case 23780: + //Aegis Heal (instead non-existed triggered spell) + triggered_spell_id = 23781; + target = this; + break; + // Elune's Touch (moonkin mana restore) + case 24905: + { + // Elune's Touch (instead non-existed triggered spell) + triggered_spell_id = 33926; + basepoints0 = int32(0.3f * GetTotalAttackPowerValue(BASE_ATTACK)); + target = this; + break; + } + // Enlightenment + case 29601: + { + // only for cast with mana price + if(!procSpell || procSpell->powerType!=POWER_MANA || procSpell->manaCost==0 && procSpell->ManaCostPercentage==0 && procSpell->manaCostPerlevel==0) + return false; + break; // fall through to normal cast + } + // Health Restore + case 33510: + { + // at melee hit call std triggered spell + if(procFlags & PROC_FLAG_HIT_MELEE) + break; // fall through to normal cast + + // Mark of Conquest - else (at range hit) called custom case + triggered_spell_id = 39557; + target = this; + break; + } + // Shaleskin + case 36576: + return true; // nothing to do + // Forgotten Knowledge (Blade of Wizardry) + case 38319: + // only for harmful enemy targeted spell + if(!pVictim || pVictim==this || !procSpell || IsPositiveSpell(procSpell->Id)) + return false; + break; // fall through to normal cast + // Aura of Wrath (Darkmoon Card: Wrath trinket bonus) + case 39442: + { + // proc only at non-crit hits + if(procFlags & (PROC_FLAG_CRIT_MELEE|PROC_FLAG_CRIT_RANGED|PROC_FLAG_CRIT_SPELL)) + return false; + break; // fall through to normal cast + } + // Augment Pain (Timbal's Focusing Crystal trinket bonus) + case 45054: + { + if(!procSpell) + return false; + + //only periodic damage can trigger spell + bool found = false; + for(int j = 0; j < 3; ++j) + { + if( procSpell->EffectApplyAuraName[j]==SPELL_AURA_PERIODIC_DAMAGE || + procSpell->EffectApplyAuraName[j]==SPELL_AURA_PERIODIC_DAMAGE_PERCENT || + procSpell->EffectApplyAuraName[j]==SPELL_AURA_PERIODIC_LEECH ) + { + found = true; + break; + } + } + if(!found) + return false; + + break; // fall through to normal cast + } + // Evasive Maneuvers (Commendation of Kael'thas) + case 45057: + { + // damage taken that reduces below 35% health + // does NOT mean you must have been >= 35% before + if (int32(GetHealth())-int32(damage) >= int32(GetMaxHealth()*0.35f)) + return false; + break; // fall through to normal cast + } + } + + switch(triggered_spell_id) + { + // Setup + case 15250: + { + // applied only for main target + if(!pVictim || pVictim != getVictim()) + return false; + + // continue normal case + break; + } + // Shamanistic Rage triggered spell + case 30824: + basepoints0 = int32(GetTotalAttackPowerValue(BASE_ATTACK)*triggeredByAura->GetModifier()->m_amount/100); + break; + } + break; + } + case SPELLFAMILY_MAGE: + { + switch(auraSpellInfo->SpellIconID) + { + // Blazing Speed + case 2127: + //Blazing Speed (instead non-existed triggered spell) + triggered_spell_id = 31643; + target = this; + break; + } + switch(auraSpellInfo->Id) + { + // Persistent Shield (Scarab Brooch) + case 26467: + basepoints0 = int32(damage * 0.15f); + break; + } + break; + } + case SPELLFAMILY_WARRIOR: + { + //Rampage + if((auraSpellInfo->SpellFamilyFlags & 0x100000) && auraSpellInfo->SpellIconID==2006) + { + //all ranks have effect[0]==AURA (Proc Trigger Spell, non-existed) + //and effect[1]==TriggerSpell + if(auraSpellInfo->Effect[1]!=SPELL_EFFECT_TRIGGER_SPELL) + { + sLog.outError("Unit::HandleProcTriggerSpell: Spell %u have wrong effect in RM",triggeredByAura->GetSpellProto()->Id); + return false; + } + triggered_spell_id = auraSpellInfo->EffectTriggerSpell[1]; + break; // fall through to normal cast + } + break; + } + case SPELLFAMILY_WARLOCK: + { + // Pyroclasm + if(auraSpellInfo->SpellFamilyFlags == 0x0000000000000000 && auraSpellInfo->SpellIconID==1137) + { + // last case for Hellfire that damage caster also but don't must stun caster + if( pVictim == this ) + return false; + + // custom chnace + float chance = 0; + switch (triggeredByAura->GetId()) + { + case 18096: chance = 13.0f; break; + case 18073: chance = 26.0f; break; + } + if (!roll_chance_f(chance)) + return false; + + // Pyroclasm (instead non-existed triggered spell) + triggered_spell_id = 18093; + target = pVictim; + break; + } + // Drain Soul + if(auraSpellInfo->SpellFamilyFlags & 0x0000000000004000) + { + bool found = false; + Unit::AuraList const& mAddFlatModifier = GetAurasByType(SPELL_AURA_ADD_FLAT_MODIFIER); + for(Unit::AuraList::const_iterator i = mAddFlatModifier.begin(); i != mAddFlatModifier.end(); ++i) + { + //Improved Drain Soul + if ((*i)->GetModifier()->m_miscvalue == SPELLMOD_CHANCE_OF_SUCCESS && (*i)->GetSpellProto()->SpellIconID == 113) + { + int32 value2 = CalculateSpellDamage((*i)->GetSpellProto(),2,(*i)->GetSpellProto()->EffectBasePoints[2],this); + basepoints0 = value2 * GetMaxPower(POWER_MANA) / 100; + + // Drain Soul + triggered_spell_id = 18371; + target = this; + found = true; + break; + } + } + if(!found) + return false; + break; // fall through to normal cast + } + break; + } + case SPELLFAMILY_PRIEST: + { + //Blessed Recovery + if(auraSpellInfo->SpellFamilyFlags == 0x00000000LL && auraSpellInfo->SpellIconID==1875) + { + switch (triggeredByAura->GetSpellProto()->Id) + { + case 27811: triggered_spell_id = 27813; break; + case 27815: triggered_spell_id = 27817; break; + case 27816: triggered_spell_id = 27818; break; + default: + sLog.outError("Unit::HandleProcTriggerSpell: Spell %u not handled in BR",triggeredByAura->GetSpellProto()->Id); + return false; + } + + int32 heal_amount = damage * triggeredByAura->GetModifier()->m_amount / 100; + basepoints0 = heal_amount/3; + target = this; + break; + } + // Shadowguard + if((auraSpellInfo->SpellFamilyFlags & 0x80000000LL) && auraSpellInfo->SpellVisual==7958) + { + switch(triggeredByAura->GetSpellProto()->Id) + { + case 18137: + triggered_spell_id = 28377; break; // Rank 1 + case 19308: + triggered_spell_id = 28378; break; // Rank 2 + case 19309: + triggered_spell_id = 28379; break; // Rank 3 + case 19310: + triggered_spell_id = 28380; break; // Rank 4 + case 19311: + triggered_spell_id = 28381; break; // Rank 5 + case 19312: + triggered_spell_id = 28382; break; // Rank 6 + case 25477: + triggered_spell_id = 28385; break; // Rank 7 + default: + sLog.outError("Unit::HandleProcTriggerSpell: Spell %u not handled in SG",triggeredByAura->GetSpellProto()->Id); + return false; + } + target = pVictim; + break; + } + break; + } + case SPELLFAMILY_DRUID: + { + switch(auraSpellInfo->Id) + { + // Leader of the Pack (triggering Improved Leader of the Pack heal) + case 24932: + { + if (triggeredByAura->GetModifier()->m_amount == 0) + return false; + basepoints0 = triggeredByAura->GetModifier()->m_amount * GetMaxHealth() / 100; + triggered_spell_id = 34299; + break; + }; + // Druid Forms Trinket (Druid Tier5 Trinket, triggers different spells per Form) + case 37336: + { + switch(m_form) + { + case FORM_BEAR: + case FORM_DIREBEAR: + triggered_spell_id=37340; break;// Ursine Blessing + case FORM_CAT: + triggered_spell_id=37341; break;// Feline Blessing + case FORM_TREE: + triggered_spell_id=37342; break;// Slyvan Blessing + case FORM_MOONKIN: + triggered_spell_id=37343; break;// Lunar Blessing + case FORM_NONE: + triggered_spell_id=37344; break;// Cenarion Blessing (for caster form, except FORM_MOONKIN) + default: + return false; + } + + target = this; + break; + } + } + break; + } + case SPELLFAMILY_ROGUE: + { + if(auraSpellInfo->SpellFamilyFlags == 0x0000000000000000LL) + { + switch(auraSpellInfo->SpellIconID) + { + // Combat Potency + case 2260: + { + // skip non offhand attacks + if(attackType!=OFF_ATTACK) + return false; + break; // fall through to normal cast + } + } + } + break; + } + case SPELLFAMILY_PALADIN: + { + if(auraSpellInfo->SpellFamilyFlags == 0x00000000LL) + { + switch(auraSpellInfo->Id) + { + // Lightning Capacitor + case 37657: + { + // trinket ProcTriggerSpell but for safe checks for player + if(!castItem || !pVictim || !pVictim->isAlive() || GetTypeId()!=TYPEID_PLAYER) + return false; + + if(((Player*)this)->HasSpellCooldown(37657)) + return false; + + // stacking + CastSpell(this, 37658, true, castItem, triggeredByAura); + // 2.5s cooldown before it can stack again, current system allow 1 sec step in cooldown + ((Player*)this)->AddSpellCooldown(37657,0,time(NULL)+(roll_chance_i(50) ? 2 : 3)); + + // counting + uint32 count = 0; + AuraList const& dummyAura = GetAurasByType(SPELL_AURA_DUMMY); + for(AuraList::const_iterator itr = dummyAura.begin(); itr != dummyAura.end(); ++itr) + if((*itr)->GetId()==37658) + ++count; + + // release at 3 aura in stack + if(count <= 2) + return true; // main triggered spell casted anyway + + RemoveAurasDueToSpell(37658); + CastSpell(pVictim, 37661, true, castItem, triggeredByAura); + return true; + } + // Healing Discount + case 37705: + // Healing Trance (instead non-existed triggered spell) + triggered_spell_id = 37706; + target = this; + break; + // HoTs on Heals (Fel Reaver's Piston trinket) + case 38299: + { + // at direct heal effect + if(!procSpell || !IsSpellHaveEffect(procSpell,SPELL_EFFECT_HEAL)) + return false; + + // single proc at time + AuraList const& scAuras = GetSingleCastAuras(); + for(AuraList::const_iterator itr = scAuras.begin(); itr != scAuras.end(); ++itr) + if((*itr)->GetId()==triggered_spell_id) + return false; + + // positive cast at victim instead self + target = pVictim; + break; + } + } + switch(auraSpellInfo->SpellIconID) + { + case 241: + { + switch(auraSpellInfo->EffectTriggerSpell[0]) + { + //Illumination + case 18350: + { + if(!procSpell) + return false; + + // procspell is triggered spell but we need mana cost of original casted spell + uint32 originalSpellId = procSpell->Id; + + // Holy Shock + if(procSpell->SpellFamilyName == SPELLFAMILY_PALADIN) + { + if(procSpell->SpellFamilyFlags & 0x0001000000000000LL) + { + switch(procSpell->Id) + { + case 25914: originalSpellId = 20473; break; + case 25913: originalSpellId = 20929; break; + case 25903: originalSpellId = 20930; break; + case 27175: originalSpellId = 27174; break; + case 33074: originalSpellId = 33072; break; + default: + sLog.outError("Unit::HandleProcTriggerSpell: Spell %u not handled in HShock",procSpell->Id); + return false; + } + } + } + + SpellEntry const *originalSpell = sSpellStore.LookupEntry(originalSpellId); + if(!originalSpell) + { + sLog.outError("Unit::HandleProcTriggerSpell: Spell %u unknown but selected as original in Illu",originalSpellId); + return false; + } + + // percent stored in effect 1 (class scripts) base points + int32 percent = auraSpellInfo->EffectBasePoints[1]+1; + + basepoints0 = originalSpell->manaCost*percent/100; + triggered_spell_id = 20272; + target = this; + break; + } + } + break; + } + } + } + if(auraSpellInfo->SpellFamilyFlags & 0x00080000) + { + switch(auraSpellInfo->SpellIconID) + { + //Judgement of Wisdom (overwrite non existing triggered spell call in spell.dbc + case 206: + { + if(!pVictim || !pVictim->isAlive()) + return false; + + uint32 spell = 0; + switch(triggeredByAura->GetSpellProto()->Id) + { + case 20186: + triggered_spell_id = 20268; // Rank 1 + break; + case 20354: + triggered_spell_id = 20352; // Rank 2 + break; + case 20355: + triggered_spell_id = 20353; // Rank 3 + break; + case 27164: + triggered_spell_id = 27165; // Rank 4 + break; + default: + sLog.outError("Unit::HandleProcTriggerSpell: Spell %u not handled in JoW",triggeredByAura->GetSpellProto()->Id); + return false; + } + + pVictim->CastSpell(pVictim,triggered_spell_id,true,castItem,triggeredByAura,GetGUID()); + return true; // no hidden cooldown + } + //Judgement of Light + case 299: + { + if(!pVictim || !pVictim->isAlive()) + return false; + + // overwrite non existing triggered spell call in spell.dbc + uint32 spell = 0; + switch(triggeredByAura->GetSpellProto()->Id) + { + case 20185: + triggered_spell_id = 20267; // Rank 1 + break; + case 20344: + triggered_spell_id = 20341; // Rank 2 + break; + case 20345: + triggered_spell_id = 20342; // Rank 3 + break; + case 20346: + triggered_spell_id = 20343; // Rank 4 + break; + case 27162: + triggered_spell_id = 27163; // Rank 5 + break; + default: + sLog.outError("Unit::HandleProcTriggerSpell: Spell %u not handled in JoL",triggeredByAura->GetSpellProto()->Id); + return false; + } + pVictim->CastSpell(pVictim,triggered_spell_id,true,castItem,triggeredByAura,GetGUID()); + return true; // no hidden cooldown + } + } + } + // custom check for proc spell + switch(auraSpellInfo->Id) + { + // Bonus Healing (item spell) + case 40971: + { + if(!pVictim || !pVictim->isAlive()) + return false; + + // bonus if health < 50% + if(pVictim->GetHealth() >= pVictim->GetMaxHealth()*triggeredByAura->GetModifier()->m_amount/100) + return false; + + // cast at target positive spell + target = pVictim; + break; + } + } + switch(triggered_spell_id) + { + // Seal of Command + case 20424: + // prevent chain of triggered spell from same triggered spell + if(procSpell && procSpell->Id==20424) + return false; + break; + } + break; + } + case SPELLFAMILY_SHAMAN: + { + if(auraSpellInfo->SpellFamilyFlags == 0x0000000000000000) + { + switch(auraSpellInfo->SpellIconID) + { + case 19: + { + switch(auraSpellInfo->Id) + { + case 23551: // Lightning Shield - Tier2: 8 pieces proc shield + { + // Lightning Shield (overwrite non existing triggered spell call in spell.dbc) + triggered_spell_id = 23552; + target = pVictim; + break; + } + case 23552: // Lightning Shield - trigger shield damage + { + // Lightning Shield (overwrite non existing triggered spell call in spell.dbc) + triggered_spell_id = 27635; + target = pVictim; + break; + } + } + break; + } + // Mana Surge (Shaman T1 bonus) + case 87: + { + if(!procSpell) + return false; + + basepoints0 = procSpell->manaCost * 35/100; + triggered_spell_id = 23571; + target = this; + break; + } + //Nature's Guardian + case 2013: + { + if(GetTypeId()!=TYPEID_PLAYER) + return false; + + // damage taken that reduces below 30% health + // does NOT mean you must have been >= 30% before + if (10*(int32(GetHealth())-int32(damage)) >= 3*GetMaxHealth()) + return false; + + triggered_spell_id = 31616; + + // need check cooldown now + if( cooldown && ((Player*)this)->HasSpellCooldown(triggered_spell_id)) + return false; + + basepoints0 = triggeredByAura->GetModifier()->m_amount * GetMaxHealth() / 100; + target = this; + if(pVictim && pVictim->isAlive()) + pVictim->getThreatManager().modifyThreatPercent(this,-10); + break; + } + } + } + + // Water Shield (we can't set cooldown for main spell - it's player casted spell + if((auraSpellInfo->SpellFamilyFlags & 0x0000002000000000LL) && auraSpellInfo->SpellVisual==7358) + { + target = this; + break; + } + + // Lightning Shield + if((auraSpellInfo->SpellFamilyFlags & 0x00000400) && auraSpellInfo->SpellVisual==37) + { + // overwrite non existing triggered spell call in spell.dbc + switch(triggeredByAura->GetSpellProto()->Id) + { + case 324: + triggered_spell_id = 26364; break; // Rank 1 + case 325: + triggered_spell_id = 26365; break; // Rank 2 + case 905: + triggered_spell_id = 26366; break; // Rank 3 + case 945: + triggered_spell_id = 26367; break; // Rank 4 + case 8134: + triggered_spell_id = 26369; break; // Rank 5 + case 10431: + triggered_spell_id = 26370; break; // Rank 6 + case 10432: + triggered_spell_id = 26363; break; // Rank 7 + case 25469: + triggered_spell_id = 26371; break; // Rank 8 + case 25472: + triggered_spell_id = 26372; break; // Rank 9 + default: + sLog.outError("Unit::HandleProcTriggerSpell: Spell %u not handled in LShield",triggeredByAura->GetSpellProto()->Id); + return false; + } + + target = pVictim; + break; + } + break; + } + } + + // standard non-dummy case + if(!triggered_spell_id) + { + sLog.outError("Unit::HandleProcTriggerSpell: Spell %u have 0 in EffectTriggered[%d], not handled custom case?",auraSpellInfo->Id,triggeredByAura->GetEffIndex()); + return false; + } + + SpellEntry const* triggerEntry = sSpellStore.LookupEntry(triggered_spell_id); + + if(!triggerEntry) + { + sLog.outError("Unit::HandleProcTriggerSpell: Spell %u have not existed EffectTriggered[%d]=%u, not handled custom case?",auraSpellInfo->Id,triggeredByAura->GetEffIndex(),triggered_spell_id); + return false; + } + + // not allow proc extra attack spell at extra attack + if( m_extraAttacks && IsSpellHaveEffect(triggerEntry,SPELL_EFFECT_ADD_EXTRA_ATTACKS) ) + return false; + + if( cooldown && GetTypeId()==TYPEID_PLAYER && ((Player*)this)->HasSpellCooldown(triggered_spell_id)) + return false; + + // default case + if(!target || target!=this && !target->isAlive()) + return false; + + if(basepoints0) + CastCustomSpell(target,triggered_spell_id,&basepoints0,NULL,NULL,true,castItem,triggeredByAura); + else + CastSpell(target,triggered_spell_id,true,castItem,triggeredByAura); + + if( cooldown && GetTypeId()==TYPEID_PLAYER ) + ((Player*)this)->AddSpellCooldown(triggered_spell_id,0,time(NULL) + cooldown); + + return true; +} + +bool Unit::HandleOverrideClassScriptAuraProc(Unit *pVictim, int32 scriptId, uint32 damage, Aura *triggeredByAura, SpellEntry const *procSpell, uint32 cooldown) +{ + if(!pVictim || !pVictim->isAlive()) + return false; + + Item* castItem = triggeredByAura->GetCastItemGUID() && GetTypeId()==TYPEID_PLAYER + ? ((Player*)this)->GetItemByGuid(triggeredByAura->GetCastItemGUID()) : NULL; + + uint32 triggered_spell_id = 0; + + switch(scriptId) + { + case 836: // Improved Blizzard (Rank 1) + { + if( !procSpell || procSpell->SpellVisual!=9487 ) + return false; + triggered_spell_id = 12484; + break; + } + case 988: // Improved Blizzard (Rank 2) + { + if( !procSpell || procSpell->SpellVisual!=9487 ) + return false; + triggered_spell_id = 12485; + break; + } + case 989: // Improved Blizzard (Rank 3) + { + if( !procSpell || procSpell->SpellVisual!=9487 ) + return false; + triggered_spell_id = 12486; + break; + } + case 4086: // Improved Mend Pet (Rank 1) + case 4087: // Improved Mend Pet (Rank 2) + { + int32 chance = triggeredByAura->GetSpellProto()->EffectBasePoints[triggeredByAura->GetEffIndex()]; + if(!roll_chance_i(chance)) + return false; + + triggered_spell_id = 24406; + break; + } + case 4533: // Dreamwalker Raiment 2 pieces bonus + { + // Chance 50% + if (!roll_chance_i(50)) + return false; + + switch (pVictim->getPowerType()) + { + case POWER_MANA: triggered_spell_id = 28722; break; + case POWER_RAGE: triggered_spell_id = 28723; break; + case POWER_ENERGY: triggered_spell_id = 28724; break; + default: + return false; + } + break; + } + case 4537: // Dreamwalker Raiment 6 pieces bonus + triggered_spell_id = 28750; // Blessing of the Claw + break; + case 5497: // Improved Mana Gems (Serpent-Coil Braid) + triggered_spell_id = 37445; // Mana Surge + break; + } + + // not processed + if(!triggered_spell_id) + return false; + + // standard non-dummy case + SpellEntry const* triggerEntry = sSpellStore.LookupEntry(triggered_spell_id); + + if(!triggerEntry) + { + sLog.outError("Unit::HandleOverrideClassScriptAuraProc: Spell %u triggering for class script id %u",triggered_spell_id,scriptId); + return false; + } + + if( cooldown && GetTypeId()==TYPEID_PLAYER && ((Player*)this)->HasSpellCooldown(triggered_spell_id)) + return false; + + CastSpell(pVictim, triggered_spell_id, true, castItem, triggeredByAura); + + if( cooldown && GetTypeId()==TYPEID_PLAYER ) + ((Player*)this)->AddSpellCooldown(triggered_spell_id,0,time(NULL) + cooldown); + + return true; +} + +void Unit::setPowerType(Powers new_powertype) +{ + SetByteValue(UNIT_FIELD_BYTES_0, 3, new_powertype); + + if(GetTypeId() == TYPEID_PLAYER) + { + if(((Player*)this)->GetGroup()) + ((Player*)this)->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_POWER_TYPE); + } + else if(((Creature*)this)->isPet()) + { + Pet *pet = ((Pet*)this); + if(pet->isControlled()) + { + Unit *owner = GetOwner(); + if(owner && (owner->GetTypeId() == TYPEID_PLAYER) && ((Player*)owner)->GetGroup()) + ((Player*)owner)->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_PET_POWER_TYPE); + } + } + + switch(new_powertype) + { + default: + case POWER_MANA: + break; + case POWER_RAGE: + SetMaxPower(POWER_RAGE,GetCreatePowers(POWER_RAGE)); + SetPower( POWER_RAGE,0); + break; + case POWER_FOCUS: + SetMaxPower(POWER_FOCUS,GetCreatePowers(POWER_FOCUS)); + SetPower( POWER_FOCUS,GetCreatePowers(POWER_FOCUS)); + break; + case POWER_ENERGY: + SetMaxPower(POWER_ENERGY,GetCreatePowers(POWER_ENERGY)); + SetPower( POWER_ENERGY,0); + break; + case POWER_HAPPINESS: + SetMaxPower(POWER_HAPPINESS,GetCreatePowers(POWER_HAPPINESS)); + SetPower(POWER_HAPPINESS,GetCreatePowers(POWER_HAPPINESS)); + break; + } +} + +FactionTemplateEntry const* Unit::getFactionTemplateEntry() const +{ + FactionTemplateEntry const* entry = sFactionTemplateStore.LookupEntry(getFaction()); + if(!entry) + { + static uint64 guid = 0; // prevent repeating spam same faction problem + + if(GetGUID() != guid) + { + if(GetTypeId() == TYPEID_PLAYER) + sLog.outError("Player %s have invalid faction (faction template id) #%u", ((Player*)this)->GetName(), getFaction()); + else + sLog.outError("Creature (template id: %u) have invalid faction (faction template id) #%u", ((Creature*)this)->GetCreatureInfo()->Entry, getFaction()); + guid = GetGUID(); + } + } + return entry; +} + +bool Unit::IsHostileTo(Unit const* unit) const +{ + // always non-hostile to self + if(unit==this) + return false; + + // always non-hostile to GM in GM mode + if(unit->GetTypeId()==TYPEID_PLAYER && ((Player const*)unit)->isGameMaster()) + return false; + + // always hostile to enemy + if(getVictim()==unit || unit->getVictim()==this) + return true; + + // test pet/charm masters instead pers/charmeds + Unit const* testerOwner = GetCharmerOrOwner(); + Unit const* targetOwner = unit->GetCharmerOrOwner(); + + // always hostile to owner's enemy + if(testerOwner && (testerOwner->getVictim()==unit || unit->getVictim()==testerOwner)) + return true; + + // always hostile to enemy owner + if(targetOwner && (getVictim()==targetOwner || targetOwner->getVictim()==this)) + return true; + + // always hostile to owner of owner's enemy + if(testerOwner && targetOwner && (testerOwner->getVictim()==targetOwner || targetOwner->getVictim()==testerOwner)) + return true; + + Unit const* tester = testerOwner ? testerOwner : this; + Unit const* target = targetOwner ? targetOwner : unit; + + // always non-hostile to target with common owner, or to owner/pet + if(tester==target) + return false; + + // special cases (Duel, etc) + if(tester->GetTypeId()==TYPEID_PLAYER && target->GetTypeId()==TYPEID_PLAYER) + { + Player const* pTester = (Player const*)tester; + Player const* pTarget = (Player const*)target; + + // Duel + if(pTester->duel && pTester->duel->opponent == pTarget && pTester->duel->startTime != 0) + return true; + + // Group + if(pTester->GetGroup() && pTester->GetGroup()==pTarget->GetGroup()) + return false; + + // Sanctuary + if(pTarget->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_SANCTUARY) && pTester->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_SANCTUARY)) + return false; + + // PvP FFA state + if(pTester->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_FFA_PVP) && pTarget->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_FFA_PVP)) + return true; + + //= PvP states + // Green/Blue (can't attack) + if(pTester->GetTeam()==pTarget->GetTeam()) + return false; + + // Red (can attack) if true, Blue/Yellow (can't attack) in another case + return pTester->IsPvP() && pTarget->IsPvP(); + } + + // faction base cases + FactionTemplateEntry const*tester_faction = tester->getFactionTemplateEntry(); + FactionTemplateEntry const*target_faction = target->getFactionTemplateEntry(); + if(!tester_faction || !target_faction) + return false; + + if(target->isAttackingPlayer() && tester->IsContestedGuard()) + return true; + + // PvC forced reaction and reputation case + if(tester->GetTypeId()==TYPEID_PLAYER) + { + // forced reaction + ForcedReactions::const_iterator forceItr = ((Player*)tester)->m_forcedReactions.find(target_faction->faction); + if(forceItr!=((Player*)tester)->m_forcedReactions.end()) + return forceItr->second <= REP_HOSTILE; + + // if faction have reputation then hostile state for tester at 100% dependent from at_war state + if(FactionEntry const* raw_target_faction = sFactionStore.LookupEntry(target_faction->faction)) + if(raw_target_faction->reputationListID >=0) + if(FactionState const* factionState = ((Player*)tester)->GetFactionState(raw_target_faction)) + return (factionState->Flags & FACTION_FLAG_AT_WAR); + } + // CvP forced reaction and reputation case + else if(target->GetTypeId()==TYPEID_PLAYER) + { + // forced reaction + ForcedReactions::const_iterator forceItr = ((Player const*)target)->m_forcedReactions.find(tester_faction->faction); + if(forceItr!=((Player const*)target)->m_forcedReactions.end()) + return forceItr->second <= REP_HOSTILE; + + // apply reputation state + FactionEntry const* raw_tester_faction = sFactionStore.LookupEntry(tester_faction->faction); + if(raw_tester_faction && raw_tester_faction->reputationListID >=0 ) + return ((Player const*)target)->GetReputationRank(raw_tester_faction) <= REP_HOSTILE; + } + + // common faction based case (CvC,PvC,CvP) + return tester_faction->IsHostileTo(*target_faction); +} + +bool Unit::IsFriendlyTo(Unit const* unit) const +{ + // always friendly to self + if(unit==this) + return true; + + // always friendly to GM in GM mode + if(unit->GetTypeId()==TYPEID_PLAYER && ((Player const*)unit)->isGameMaster()) + return true; + + // always non-friendly to enemy + if(getVictim()==unit || unit->getVictim()==this) + return false; + + // test pet/charm masters instead pers/charmeds + Unit const* testerOwner = GetCharmerOrOwner(); + Unit const* targetOwner = unit->GetCharmerOrOwner(); + + // always non-friendly to owner's enemy + if(testerOwner && (testerOwner->getVictim()==unit || unit->getVictim()==testerOwner)) + return false; + + // always non-friendly to enemy owner + if(targetOwner && (getVictim()==targetOwner || targetOwner->getVictim()==this)) + return false; + + // always non-friendly to owner of owner's enemy + if(testerOwner && targetOwner && (testerOwner->getVictim()==targetOwner || targetOwner->getVictim()==testerOwner)) + return false; + + Unit const* tester = testerOwner ? testerOwner : this; + Unit const* target = targetOwner ? targetOwner : unit; + + // always friendly to target with common owner, or to owner/pet + if(tester==target) + return true; + + // special cases (Duel) + if(tester->GetTypeId()==TYPEID_PLAYER && target->GetTypeId()==TYPEID_PLAYER) + { + Player const* pTester = (Player const*)tester; + Player const* pTarget = (Player const*)target; + + // Duel + if(pTester->duel && pTester->duel->opponent == target && pTester->duel->startTime != 0) + return false; + + // Group + if(pTester->GetGroup() && pTester->GetGroup()==pTarget->GetGroup()) + return true; + + // Sanctuary + if(pTarget->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_SANCTUARY) && pTester->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_SANCTUARY)) + return true; + + // PvP FFA state + if(pTester->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_FFA_PVP) && pTarget->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_FFA_PVP)) + return false; + + //= PvP states + // Green/Blue (non-attackable) + if(pTester->GetTeam()==pTarget->GetTeam()) + return true; + + // Blue (friendly/non-attackable) if not PVP, or Yellow/Red in another case (attackable) + return !pTarget->IsPvP(); + } + + // faction base cases + FactionTemplateEntry const*tester_faction = tester->getFactionTemplateEntry(); + FactionTemplateEntry const*target_faction = target->getFactionTemplateEntry(); + if(!tester_faction || !target_faction) + return false; + + if(target->isAttackingPlayer() && tester->IsContestedGuard()) + return false; + + // PvC forced reaction and reputation case + if(tester->GetTypeId()==TYPEID_PLAYER) + { + // forced reaction + ForcedReactions::const_iterator forceItr = ((Player const*)tester)->m_forcedReactions.find(target_faction->faction); + if(forceItr!=((Player const*)tester)->m_forcedReactions.end()) + return forceItr->second >= REP_FRIENDLY; + + // if faction have reputation then friendly state for tester at 100% dependent from at_war state + if(FactionEntry const* raw_target_faction = sFactionStore.LookupEntry(target_faction->faction)) + if(raw_target_faction->reputationListID >=0) + if(FactionState const* FactionState = ((Player*)tester)->GetFactionState(raw_target_faction)) + return !(FactionState->Flags & FACTION_FLAG_AT_WAR); + } + // CvP forced reaction and reputation case + else if(target->GetTypeId()==TYPEID_PLAYER) + { + // forced reaction + ForcedReactions::const_iterator forceItr = ((Player const*)target)->m_forcedReactions.find(tester_faction->faction); + if(forceItr!=((Player const*)target)->m_forcedReactions.end()) + return forceItr->second >= REP_FRIENDLY; + + // apply reputation state + if(FactionEntry const* raw_tester_faction = sFactionStore.LookupEntry(tester_faction->faction)) + if(raw_tester_faction->reputationListID >=0 ) + return ((Player const*)target)->GetReputationRank(raw_tester_faction) >= REP_FRIENDLY; + } + + // common faction based case (CvC,PvC,CvP) + return tester_faction->IsFriendlyTo(*target_faction); +} + +bool Unit::IsHostileToPlayers() const +{ + FactionTemplateEntry const* my_faction = getFactionTemplateEntry(); + if(!my_faction) + return false; + + FactionEntry const* raw_faction = sFactionStore.LookupEntry(my_faction->faction); + if(raw_faction && raw_faction->reputationListID >=0 ) + return false; + + return my_faction->IsHostileToPlayers(); +} + +bool Unit::IsNeutralToAll() const +{ + FactionTemplateEntry const* my_faction = getFactionTemplateEntry(); + if(!my_faction) + return true; + + FactionEntry const* raw_faction = sFactionStore.LookupEntry(my_faction->faction); + if(raw_faction && raw_faction->reputationListID >=0 ) + return false; + + return my_faction->IsNeutralToAll(); +} + +bool Unit::Attack(Unit *victim, bool meleeAttack) +{ + if(!victim || victim == this) + return false; + + // dead units can neither attack nor be attacked + if(!isAlive() || !victim->isAlive()) + return false; + + // player cannot attack in mount state + if(GetTypeId()==TYPEID_PLAYER && IsMounted()) + return false; + + // nobody can attack GM in GM-mode + if(victim->GetTypeId()==TYPEID_PLAYER) + { + if(((Player*)victim)->isGameMaster()) + return false; + } + else + { + if(((Creature*)victim)->IsInEvadeMode()) + return false; + } + + // remove SPELL_AURA_MOD_UNATTACKABLE at attack (in case non-interruptible spells stun aura applied also that not let attack) + if(HasAuraType(SPELL_AURA_MOD_UNATTACKABLE)) + RemoveSpellsCausingAura(SPELL_AURA_MOD_UNATTACKABLE); + + if (m_attacking) + { + if (m_attacking == victim) + { + // switch to melee attack from ranged/magic + if( meleeAttack && !hasUnitState(UNIT_STAT_MELEE_ATTACKING) ) + { + addUnitState(UNIT_STAT_MELEE_ATTACKING); + SendAttackStart(victim); + return true; + } + return false; + } + AttackStop(); + } + + //Set our target + SetUInt64Value(UNIT_FIELD_TARGET, victim->GetGUID()); + + if(meleeAttack) + addUnitState(UNIT_STAT_MELEE_ATTACKING); + m_attacking = victim; + m_attacking->_addAttacker(this); + + if(m_attacking->GetTypeId()==TYPEID_UNIT && ((Creature*)m_attacking)->AI()) + ((Creature*)m_attacking)->AI()->AttackedBy(this); + + if(GetTypeId()==TYPEID_UNIT) + { + WorldPacket data(SMSG_AI_REACTION, 12); + data << GetGUID(); + data << uint32(AI_REACTION_AGGRO); // Aggro sound + ((WorldObject*)this)->SendMessageToSet(&data, true); + + ((Creature*)this)->CallAssistence(); + ((Creature*)this)->SetCombatStartPosition(GetPositionX(), GetPositionY(), GetPositionZ()); + } + + // delay offhand weapon attack to next attack time + if(haveOffhandWeapon()) + resetAttackTimer(OFF_ATTACK); + + if(meleeAttack) + SendAttackStart(victim); + + return true; +} + +bool Unit::AttackStop() +{ + if (!m_attacking) + return false; + + Unit* victim = m_attacking; + + m_attacking->_removeAttacker(this); + m_attacking = NULL; + + //Clear our target + SetUInt64Value(UNIT_FIELD_TARGET, 0); + + clearUnitState(UNIT_STAT_MELEE_ATTACKING); + + InterruptSpell(CURRENT_MELEE_SPELL); + + if( GetTypeId()==TYPEID_UNIT ) + { + // reset call assistance + ((Creature*)this)->SetNoCallAssistence(false); + } + + SendAttackStop(victim); + + return true; +} + +void Unit::CombatStop(bool cast) +{ + if(cast& IsNonMeleeSpellCasted(false)) + InterruptNonMeleeSpells(false); + + AttackStop(); + RemoveAllAttackers(); + if( GetTypeId()==TYPEID_PLAYER ) + ((Player*)this)->SendAttackSwingCancelAttack(); // melee and ranged forced attack cancel + ClearInCombat(); +} + +void Unit::CombatStopWithPets(bool cast) +{ + CombatStop(cast); + if(Pet* pet = GetPet()) + pet->CombatStop(cast); + if(Unit* charm = GetCharm()) + charm->CombatStop(cast); + if(GetTypeId()==TYPEID_PLAYER) + { + GuardianPetList const& guardians = ((Player*)this)->GetGuardians(); + for(GuardianPetList::const_iterator itr = guardians.begin(); itr != guardians.end(); ++itr) + if(Unit* guardian = Unit::GetUnit(*this,*itr)) + guardian->CombatStop(cast); + } +} + +bool Unit::isAttackingPlayer() const +{ + if(hasUnitState(UNIT_STAT_ATTACK_PLAYER)) + return true; + + Pet* pet = GetPet(); + if(pet && pet->isAttackingPlayer()) + return true; + + Unit* charmed = GetCharm(); + if(charmed && charmed->isAttackingPlayer()) + return true; + + for (int8 i = 0; i < MAX_TOTEM; i++) + { + if(m_TotemSlot[i]) + { + Creature *totem = ObjectAccessor::GetCreature(*this, m_TotemSlot[i]); + if(totem && totem->isAttackingPlayer()) + return true; + } + } + + return false; +} + +void Unit::RemoveAllAttackers() +{ + while (!m_attackers.empty()) + { + AttackerSet::iterator iter = m_attackers.begin(); + if(!(*iter)->AttackStop()) + { + sLog.outError("WORLD: Unit has an attacker that isnt attacking it!"); + m_attackers.erase(iter); + } + } +} + +void Unit::ModifyAuraState(AuraState flag, bool apply) +{ + if (apply) + { + if (!HasFlag(UNIT_FIELD_AURASTATE, 1<<(flag-1))) + { + SetFlag(UNIT_FIELD_AURASTATE, 1<<(flag-1)); + if(GetTypeId() == TYPEID_PLAYER) + { + const PlayerSpellMap& sp_list = ((Player*)this)->GetSpellMap(); + for (PlayerSpellMap::const_iterator itr = sp_list.begin(); itr != sp_list.end(); ++itr) + { + if(itr->second->state == PLAYERSPELL_REMOVED) continue; + SpellEntry const *spellInfo = sSpellStore.LookupEntry(itr->first); + if (!spellInfo || !IsPassiveSpell(itr->first)) continue; + if (spellInfo->CasterAuraState == flag) + CastSpell(this, itr->first, true, NULL); + } + } + } + } + else + { + if (HasFlag(UNIT_FIELD_AURASTATE,1<<(flag-1))) + { + RemoveFlag(UNIT_FIELD_AURASTATE, 1<<(flag-1)); + Unit::AuraMap& tAuras = GetAuras(); + for (Unit::AuraMap::iterator itr = tAuras.begin(); itr != tAuras.end();) + { + SpellEntry const* spellProto = (*itr).second->GetSpellProto(); + if (spellProto->CasterAuraState == flag) + { + // exceptions (applied at state but not removed at state change) + // Rampage + if(spellProto->SpellIconID==2006 && spellProto->SpellFamilyName==SPELLFAMILY_WARRIOR && spellProto->SpellFamilyFlags==0x100000) + { + ++itr; + continue; + } + + RemoveAura(itr); + } + else + ++itr; + } + } + } +} + +Unit *Unit::GetOwner() const +{ + uint64 ownerid = GetOwnerGUID(); + if(!ownerid) + return NULL; + return ObjectAccessor::GetUnit(*this, ownerid); +} + +Unit *Unit::GetCharmer() const +{ + if(uint64 charmerid = GetCharmerGUID()) + return ObjectAccessor::GetUnit(*this, charmerid); + return NULL; +} + +Player* Unit::GetCharmerOrOwnerPlayerOrPlayerItself() +{ + uint64 guid = GetCharmerOrOwnerGUID(); + if(IS_PLAYER_GUID(guid)) + return ObjectAccessor::GetPlayer(*this, guid); + + return GetTypeId()==TYPEID_PLAYER ? (Player*)this : NULL; +} + +Pet* Unit::GetPet() const +{ + if(uint64 pet_guid = GetPetGUID()) + { + if(Pet* pet = ObjectAccessor::GetPet(pet_guid)) + return pet; + + sLog.outError("Unit::GetPet: Pet %u not exist.",GUID_LOPART(pet_guid)); + const_cast(this)->SetPet(0); + } + + return NULL; +} + +Unit* Unit::GetCharm() const +{ + if(uint64 charm_guid = GetCharmGUID()) + { + if(Unit* pet = ObjectAccessor::GetUnit(*this, charm_guid)) + return pet; + + sLog.outError("Unit::GetCharm: Charmed creature %u not exist.",GUID_LOPART(charm_guid)); + const_cast(this)->SetCharm(0); + } + + return NULL; +} + +void Unit::SetPet(Pet* pet) +{ + SetUInt64Value(UNIT_FIELD_SUMMON,pet ? pet->GetGUID() : 0); + + // FIXME: hack, speed must be set only at follow + if(pet) + for(int i = 0; i < MAX_MOVE_TYPE; ++i) + pet->SetSpeed(UnitMoveType(i),m_speed_rate[i],true); +} + +void Unit::SetCharm(Unit* charmed) +{ + SetUInt64Value(UNIT_FIELD_CHARM,charmed ? charmed->GetGUID() : 0); +} + +void Unit::UnsummonAllTotems() +{ + for (int8 i = 0; i < MAX_TOTEM; ++i) + { + if(!m_TotemSlot[i]) + continue; + + Creature *OldTotem = ObjectAccessor::GetCreature(*this, m_TotemSlot[i]); + if (OldTotem && OldTotem->isTotem()) + ((Totem*)OldTotem)->UnSummon(); + } +} + +void Unit::SendHealSpellLog(Unit *pVictim, uint32 SpellID, uint32 Damage, bool critical) +{ + // we guess size + WorldPacket data(SMSG_SPELLHEALLOG, (8+8+4+4+1)); + data.append(pVictim->GetPackGUID()); + data.append(GetPackGUID()); + data << uint32(SpellID); + data << uint32(Damage); + data << uint8(critical ? 1 : 0); + data << uint8(0); // unused in client? + SendMessageToSet(&data, true); +} + +void Unit::SendEnergizeSpellLog(Unit *pVictim, uint32 SpellID, uint32 Damage, Powers powertype, bool critical) +{ + WorldPacket data(SMSG_SPELLENERGIZELOG, (8+8+4+4+4+1)); + data.append(pVictim->GetPackGUID()); + data.append(GetPackGUID()); + data << uint32(SpellID); + data << uint32(powertype); + data << uint32(Damage); + //data << uint8(critical ? 1 : 0); // removed in 2.4.0 + SendMessageToSet(&data, true); +} + +uint32 Unit::SpellDamageBonus(Unit *pVictim, SpellEntry const *spellProto, uint32 pdamage, DamageEffectType damagetype) +{ + if(!spellProto || !pVictim || damagetype==DIRECT_DAMAGE ) + return pdamage; + + int32 BonusDamage = 0; + if( GetTypeId()==TYPEID_UNIT ) + { + // Pets just add their bonus damage to their spell damage + // note that their spell damage is just gain of their own auras + if (((Creature*)this)->isPet()) + { + BonusDamage = ((Pet*)this)->GetBonusDamage(); + } + // For totems get damage bonus from owner (statue isn't totem in fact) + else if (((Creature*)this)->isTotem() && ((Totem*)this)->GetTotemType()!=TOTEM_STATUE) + { + if(Unit* owner = GetOwner()) + return owner->SpellDamageBonus(pVictim, spellProto, pdamage, damagetype); + } + } + + // Damage Done + uint32 CastingTime = !IsChanneledSpell(spellProto) ? GetSpellCastTime(spellProto) : GetSpellDuration(spellProto); + + // Taken/Done fixed damage bonus auras + int32 DoneAdvertisedBenefit = SpellBaseDamageBonus(GetSpellSchoolMask(spellProto))+BonusDamage; + int32 TakenAdvertisedBenefit = SpellBaseDamageBonusForVictim(GetSpellSchoolMask(spellProto), pVictim); + + // Damage over Time spells bonus calculation + float DotFactor = 1.0f; + if(damagetype == DOT) + { + int32 DotDuration = GetSpellDuration(spellProto); + // 200% limit + if(DotDuration > 0) + { + if(DotDuration > 30000) DotDuration = 30000; + if(!IsChanneledSpell(spellProto)) DotFactor = DotDuration / 15000.0f; + int x = 0; + for(int j = 0; j < 3; j++) + { + if( spellProto->Effect[j] == SPELL_EFFECT_APPLY_AURA && ( + spellProto->EffectApplyAuraName[j] == SPELL_AURA_PERIODIC_DAMAGE || + spellProto->EffectApplyAuraName[j] == SPELL_AURA_PERIODIC_LEECH) ) + { + x = j; + break; + } + } + int DotTicks = 6; + if(spellProto->EffectAmplitude[x] != 0) + DotTicks = DotDuration / spellProto->EffectAmplitude[x]; + if(DotTicks) + { + DoneAdvertisedBenefit /= DotTicks; + TakenAdvertisedBenefit /= DotTicks; + } + } + } + + // Taken/Done total percent damage auras + float DoneTotalMod = 1.0f; + float TakenTotalMod = 1.0f; + + // ..done + AuraList const& mModDamagePercentDone = GetAurasByType(SPELL_AURA_MOD_DAMAGE_PERCENT_DONE); + for(AuraList::const_iterator i = mModDamagePercentDone.begin(); i != mModDamagePercentDone.end(); ++i) + { + if( ((*i)->GetModifier()->m_miscvalue & GetSpellSchoolMask(spellProto)) && + (*i)->GetSpellProto()->EquippedItemClass == -1 && + // -1 == any item class (not wand then) + (*i)->GetSpellProto()->EquippedItemInventoryTypeMask == 0 ) + // 0 == any inventory type (not wand then) + { + DoneTotalMod *= ((*i)->GetModifier()->m_amount+100.0f)/100.0f; + } + } + + uint32 creatureTypeMask = pVictim->GetCreatureTypeMask(); + AuraList const& mDamageDoneVersus = GetAurasByType(SPELL_AURA_MOD_DAMAGE_DONE_VERSUS); + for(AuraList::const_iterator i = mDamageDoneVersus.begin();i != mDamageDoneVersus.end(); ++i) + if(creatureTypeMask & uint32((*i)->GetModifier()->m_miscvalue)) + DoneTotalMod *= ((*i)->GetModifier()->m_amount+100.0f)/100.0f; + + // ..taken + AuraList const& mModDamagePercentTaken = pVictim->GetAurasByType(SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN); + for(AuraList::const_iterator i = mModDamagePercentTaken.begin(); i != mModDamagePercentTaken.end(); ++i) + if( (*i)->GetModifier()->m_miscvalue & GetSpellSchoolMask(spellProto) ) + TakenTotalMod *= ((*i)->GetModifier()->m_amount+100.0f)/100.0f; + + // .. taken pct: scripted (increases damage of * against targets *) + AuraList const& mOverrideClassScript = GetAurasByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS); + for(AuraList::const_iterator i = mOverrideClassScript.begin(); i != mOverrideClassScript.end(); ++i) + { + switch((*i)->GetModifier()->m_miscvalue) + { + //Molten Fury + case 4920: case 4919: + if(pVictim->HasAuraState(AURA_STATE_HEALTHLESS_20_PERCENT)) + TakenTotalMod *= (100.0f+(*i)->GetModifier()->m_amount)/100.0f; break; + } + } + // .. taken pct: dummy auras + AuraList const& mDummyAuras = pVictim->GetAurasByType(SPELL_AURA_DUMMY); + for(AuraList::const_iterator i = mDummyAuras.begin(); i != mDummyAuras.end(); ++i) + { + switch((*i)->GetSpellProto()->SpellIconID) + { + //Cheat Death + case 2109: + if( ((*i)->GetModifier()->m_miscvalue & GetSpellSchoolMask(spellProto)) ) + { + if(pVictim->GetTypeId() != TYPEID_PLAYER) + continue; + float mod = -((Player*)pVictim)->GetRatingBonusValue(CR_CRIT_TAKEN_SPELL)*2*4; + if (mod < (*i)->GetModifier()->m_amount) + mod = (*i)->GetModifier()->m_amount; + TakenTotalMod *= (mod+100.0f)/100.0f; + } + break; + //Mangle + case 2312: + for(int j=0;j<3;j++) + { + if(GetEffectMechanic(spellProto, j)==MECHANIC_BLEED) + { + TakenTotalMod *= (100.0f+(*i)->GetModifier()->m_amount)/100.0f; + break; + } + } + break; + } + } + + // Distribute Damage over multiple effects, reduce by AoE + CastingTime = GetCastingTimeForBonus( spellProto, damagetype, CastingTime ); + + // 50% for damage and healing spells for leech spells from damage bonus and 0% from healing + for(int j = 0; j < 3; ++j) + { + if( spellProto->Effect[j] == SPELL_EFFECT_HEALTH_LEECH || + spellProto->Effect[j] == SPELL_EFFECT_APPLY_AURA && spellProto->EffectApplyAuraName[j] == SPELL_AURA_PERIODIC_LEECH ) + { + CastingTime /= 2; + break; + } + } + + switch(spellProto->SpellFamilyName) + { + case SPELLFAMILY_MAGE: + // Ignite - do not modify, it is (8*Rank)% damage of procing Spell + if(spellProto->Id==12654) + { + return pdamage; + } + // Ice Lance + else if((spellProto->SpellFamilyFlags & 0x20000LL) && spellProto->SpellIconID == 186) + { + CastingTime /= 3; // applied 1/3 bonuses in case generic target + if(pVictim->isFrozen()) // and compensate this for frozen target. + TakenTotalMod *= 3.0f; + } + // Pyroblast - 115% of Fire Damage, DoT - 20% of Fire Damage + else if((spellProto->SpellFamilyFlags & 0x400000LL) && spellProto->SpellIconID == 184 ) + { + DotFactor = damagetype == DOT ? 0.2f : 1.0f; + CastingTime = damagetype == DOT ? 3500 : 4025; + } + // Fireball - 100% of Fire Damage, DoT - 0% of Fire Damage + else if((spellProto->SpellFamilyFlags & 0x1LL) && spellProto->SpellIconID == 185) + { + CastingTime = 3500; + DotFactor = damagetype == DOT ? 0.0f : 1.0f; + } + // Molten armor + else if (spellProto->SpellFamilyFlags & 0x0000000800000000LL) + { + CastingTime = 0; + } + // Arcane Missiles triggered spell + else if ((spellProto->SpellFamilyFlags & 0x200000LL) && spellProto->SpellIconID == 225) + { + CastingTime = 1000; + } + // Blizzard triggered spell + else if ((spellProto->SpellFamilyFlags & 0x80080LL) && spellProto->SpellIconID == 285) + { + CastingTime = 500; + } + break; + case SPELLFAMILY_WARLOCK: + // Life Tap + if((spellProto->SpellFamilyFlags & 0x40000LL) && spellProto->SpellIconID == 208) + { + CastingTime = 2800; // 80% from +shadow damage + DoneTotalMod = 1.0f; + TakenTotalMod = 1.0f; + } + // Dark Pact + else if((spellProto->SpellFamilyFlags & 0x80000000LL) && spellProto->SpellIconID == 154 && GetPetGUID()) + { + CastingTime = 3360; // 96% from +shadow damage + DoneTotalMod = 1.0f; + TakenTotalMod = 1.0f; + } + // Soul Fire - 115% of Fire Damage + else if((spellProto->SpellFamilyFlags & 0x8000000000LL) && spellProto->SpellIconID == 184) + { + CastingTime = 4025; + } + // Curse of Agony - 120% of Shadow Damage + else if((spellProto->SpellFamilyFlags & 0x0000000400LL) && spellProto->SpellIconID == 544) + { + DotFactor = 1.2f; + } + // Drain Mana - 0% of Shadow Damage + else if((spellProto->SpellFamilyFlags & 0x10LL) && spellProto->SpellIconID == 548) + { + CastingTime = 0; + } + // Drain Soul 214.3% + else if ((spellProto->SpellFamilyFlags & 0x4000LL) && spellProto->SpellIconID == 113 ) + { + CastingTime = 7500; + } + // Hellfire + else if ((spellProto->SpellFamilyFlags & 0x40LL) && spellProto->SpellIconID == 937) + { + CastingTime = damagetype == DOT ? 5000 : 500; // self damage seems to be so + } + // Unstable Affliction - 180% + else if (spellProto->Id == 31117 && spellProto->SpellIconID == 232) + { + CastingTime = 6300; + } + // Corruption 93% + else if ((spellProto->SpellFamilyFlags & 0x2LL) && spellProto->SpellIconID == 313) + { + DotFactor = 0.93f; + } + break; + case SPELLFAMILY_PALADIN: + // Consecration - 95% of Holy Damage + if((spellProto->SpellFamilyFlags & 0x20LL) && spellProto->SpellIconID == 51) + { + DotFactor = 0.95f; + CastingTime = 3500; + } + // Seal of Righteousness - 10.2%/9.8% ( based on weapon type ) of Holy Damage, multiplied by weapon speed + else if((spellProto->SpellFamilyFlags & 0x8000000LL) && spellProto->SpellIconID == 25) + { + Item *item = ((Player*)this)->GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_MAINHAND); + float wspeed = GetAttackTime(BASE_ATTACK)/1000.0f; + + if( item && item->GetProto()->InventoryType == INVTYPE_2HWEAPON) + CastingTime = uint32(wspeed*3500*0.102f); + else + CastingTime = uint32(wspeed*3500*0.098f); + } + // Judgement of Righteousness - 73% + else if ((spellProto->SpellFamilyFlags & 1024) && spellProto->SpellIconID == 25) + { + CastingTime = 2555; + } + // Seal of Vengeance - 17% per Fully Stacked Tick - 5 Applications + else if ((spellProto->SpellFamilyFlags & 0x80000000000LL) && spellProto->SpellIconID == 2292) + { + DotFactor = 0.17f; + CastingTime = 3500; + } + // Holy shield - 5% of Holy Damage + else if ((spellProto->SpellFamilyFlags & 0x4000000000LL) && spellProto->SpellIconID == 453) + { + CastingTime = 175; + } + // Blessing of Sanctuary - 0% + else if ((spellProto->SpellFamilyFlags & 0x10000000LL) && spellProto->SpellIconID == 29) + { + CastingTime = 0; + } + // Seal of Righteousness trigger - already computed for parent spell + else if ( spellProto->SpellFamilyName==SPELLFAMILY_PALADIN && spellProto->SpellIconID==25 && spellProto->AttributesEx4 & 0x00800000LL ) + { + return pdamage; + } + break; + case SPELLFAMILY_SHAMAN: + // totem attack + if (spellProto->SpellFamilyFlags & 0x000040000000LL) + { + if (spellProto->SpellIconID == 33) // Fire Nova totem attack must be 21.4%(untested) + CastingTime = 749; // ignore CastingTime and use as modifier + else if (spellProto->SpellIconID == 680) // Searing Totem attack 8% + CastingTime = 280; // ignore CastingTime and use as modifier + else if (spellProto->SpellIconID == 37) // Magma totem attack must be 6.67%(untested) + CastingTime = 234; // ignore CastingTimePenalty and use as modifier + } + // Lightning Shield (and proc shield from T2 8 pieces bonus ) 33% per charge + else if( (spellProto->SpellFamilyFlags & 0x00000000400LL) || spellProto->Id == 23552) + CastingTime = 1155; // ignore CastingTimePenalty and use as modifier + break; + case SPELLFAMILY_PRIEST: + // Mana Burn - 0% of Shadow Damage + if((spellProto->SpellFamilyFlags & 0x10LL) && spellProto->SpellIconID == 212) + { + CastingTime = 0; + } + // Mind Flay - 59% of Shadow Damage + else if((spellProto->SpellFamilyFlags & 0x800000LL) && spellProto->SpellIconID == 548) + { + CastingTime = 2065; + } + // Holy Fire - 86.71%, DoT - 16.5% + else if ((spellProto->SpellFamilyFlags & 0x100000LL) && spellProto->SpellIconID == 156) + { + DotFactor = damagetype == DOT ? 0.165f : 1.0f; + CastingTime = damagetype == DOT ? 3500 : 3035; + } + // Shadowguard - 28% per charge + else if ((spellProto->SpellFamilyFlags & 0x2000000LL) && spellProto->SpellIconID == 19) + { + CastingTime = 980; + } + // Touch of Weakeness - 10% + else if ((spellProto->SpellFamilyFlags & 0x80000LL) && spellProto->SpellIconID == 1591) + { + CastingTime = 350; + } + // Reflective Shield (back damage) - 0% (other spells fit to check not have damage effects/auras) + else if (spellProto->SpellFamilyFlags == 0 && spellProto->SpellIconID == 566) + { + CastingTime = 0; + } + // Holy Nova - 14% + else if ((spellProto->SpellFamilyFlags & 0x400000LL) && spellProto->SpellIconID == 1874) + { + CastingTime = 500; + } + break; + case SPELLFAMILY_DRUID: + // Hurricane triggered spell + if((spellProto->SpellFamilyFlags & 0x400000LL) && spellProto->SpellIconID == 220) + { + CastingTime = 500; + } + break; + case SPELLFAMILY_WARRIOR: + case SPELLFAMILY_HUNTER: + case SPELLFAMILY_ROGUE: + CastingTime = 0; + break; + default: + break; + } + + float LvlPenalty = CalculateLevelPenalty(spellProto); + + // Spellmod SpellDamage + float SpellModSpellDamage = 100.0f; + + if(Player* modOwner = GetSpellModOwner()) + modOwner->ApplySpellMod(spellProto->Id,SPELLMOD_SPELL_BONUS_DAMAGE,SpellModSpellDamage); + + SpellModSpellDamage /= 100.0f; + + float DoneActualBenefit = DoneAdvertisedBenefit * (CastingTime / 3500.0f) * DotFactor * SpellModSpellDamage * LvlPenalty; + float TakenActualBenefit = TakenAdvertisedBenefit * (CastingTime / 3500.0f) * DotFactor * LvlPenalty; + + float tmpDamage = (float(pdamage)+DoneActualBenefit)*DoneTotalMod; + + // Add flat bonus from spell damage versus + tmpDamage += GetTotalAuraModifierByMiscMask(SPELL_AURA_MOD_FLAT_SPELL_DAMAGE_VERSUS, creatureTypeMask); + + // apply spellmod to Done damage + if(Player* modOwner = GetSpellModOwner()) + modOwner->ApplySpellMod(spellProto->Id, damagetype == DOT ? SPELLMOD_DOT : SPELLMOD_DAMAGE, tmpDamage); + + tmpDamage = (tmpDamage+TakenActualBenefit)*TakenTotalMod; + + if( GetTypeId() == TYPEID_UNIT && !((Creature*)this)->isPet() ) + tmpDamage *= ((Creature*)this)->GetSpellDamageMod(((Creature*)this)->GetCreatureInfo()->rank); + + return tmpDamage > 0 ? uint32(tmpDamage) : 0; +} + +int32 Unit::SpellBaseDamageBonus(SpellSchoolMask schoolMask) +{ + int32 DoneAdvertisedBenefit = 0; + + // ..done + AuraList const& mDamageDone = GetAurasByType(SPELL_AURA_MOD_DAMAGE_DONE); + for(AuraList::const_iterator i = mDamageDone.begin();i != mDamageDone.end(); ++i) + if(((*i)->GetModifier()->m_miscvalue & schoolMask) != 0 && + (*i)->GetSpellProto()->EquippedItemClass == -1 && + // -1 == any item class (not wand then) + (*i)->GetSpellProto()->EquippedItemInventoryTypeMask == 0 ) + // 0 == any inventory type (not wand then) + DoneAdvertisedBenefit += (*i)->GetModifier()->m_amount; + + if (GetTypeId() == TYPEID_PLAYER) + { + // Damage bonus from stats + AuraList const& mDamageDoneOfStatPercent = GetAurasByType(SPELL_AURA_MOD_SPELL_DAMAGE_OF_STAT_PERCENT); + for(AuraList::const_iterator i = mDamageDoneOfStatPercent.begin();i != mDamageDoneOfStatPercent.end(); ++i) + { + if((*i)->GetModifier()->m_miscvalue & schoolMask) + { + SpellEntry const* iSpellProto = (*i)->GetSpellProto(); + uint8 eff = (*i)->GetEffIndex(); + + // stat used dependent from next effect aura SPELL_AURA_MOD_SPELL_HEALING presence and misc value (stat index) + Stats usedStat = STAT_INTELLECT; + if(eff < 2 && iSpellProto->EffectApplyAuraName[eff+1]==SPELL_AURA_MOD_SPELL_HEALING_OF_STAT_PERCENT) + usedStat = Stats(iSpellProto->EffectMiscValue[eff+1]); + + DoneAdvertisedBenefit += int32(GetStat(usedStat) * (*i)->GetModifier()->m_amount / 100.0f); + } + } + // ... and attack power + AuraList const& mDamageDonebyAP = GetAurasByType(SPELL_AURA_MOD_SPELL_DAMAGE_OF_ATTACK_POWER); + for(AuraList::const_iterator i =mDamageDonebyAP.begin();i != mDamageDonebyAP.end(); ++i) + if ((*i)->GetModifier()->m_miscvalue & schoolMask) + DoneAdvertisedBenefit += int32(GetTotalAttackPowerValue(BASE_ATTACK) * (*i)->GetModifier()->m_amount / 100.0f); + + } + return DoneAdvertisedBenefit; +} + +int32 Unit::SpellBaseDamageBonusForVictim(SpellSchoolMask schoolMask, Unit *pVictim) +{ + uint32 creatureTypeMask = pVictim->GetCreatureTypeMask(); + + int32 TakenAdvertisedBenefit = 0; + // ..done (for creature type by mask) in taken + AuraList const& mDamageDoneCreature = GetAurasByType(SPELL_AURA_MOD_DAMAGE_DONE_CREATURE); + for(AuraList::const_iterator i = mDamageDoneCreature.begin();i != mDamageDoneCreature.end(); ++i) + if(creatureTypeMask & uint32((*i)->GetModifier()->m_miscvalue)) + TakenAdvertisedBenefit += (*i)->GetModifier()->m_amount; + + // ..taken + AuraList const& mDamageTaken = pVictim->GetAurasByType(SPELL_AURA_MOD_DAMAGE_TAKEN); + for(AuraList::const_iterator i = mDamageTaken.begin();i != mDamageTaken.end(); ++i) + if(((*i)->GetModifier()->m_miscvalue & schoolMask) != 0) + TakenAdvertisedBenefit += (*i)->GetModifier()->m_amount; + + return TakenAdvertisedBenefit; +} + +bool Unit::isSpellCrit(Unit *pVictim, SpellEntry const *spellProto, SpellSchoolMask schoolMask, WeaponAttackType attackType) +{ + // not criting spell + if((spellProto->AttributesEx2 & SPELL_ATTR_EX2_CANT_CRIT)) + return false; + + float crit_chance = 0.0f; + switch(spellProto->DmgClass) + { + case SPELL_DAMAGE_CLASS_NONE: + return false; + case SPELL_DAMAGE_CLASS_MAGIC: + { + if (schoolMask & SPELL_SCHOOL_MASK_NORMAL) + crit_chance = 0.0f; + // For other schools + else if (GetTypeId() == TYPEID_PLAYER) + crit_chance = GetFloatValue( PLAYER_SPELL_CRIT_PERCENTAGE1 + GetFirstSchoolInMask(schoolMask)); + else + { + crit_chance = m_baseSpellCritChance; + crit_chance += GetTotalAuraModifierByMiscMask(SPELL_AURA_MOD_SPELL_CRIT_CHANCE_SCHOOL, schoolMask); + } + // taken + if (pVictim && !IsPositiveSpell(spellProto->Id)) + { + // Modify critical chance by victim SPELL_AURA_MOD_ATTACKER_SPELL_CRIT_CHANCE + crit_chance += pVictim->GetTotalAuraModifierByMiscMask(SPELL_AURA_MOD_ATTACKER_SPELL_CRIT_CHANCE, schoolMask); + // Modify critical chance by victim SPELL_AURA_MOD_ATTACKER_SPELL_AND_WEAPON_CRIT_CHANCE + crit_chance += pVictim->GetTotalAuraModifier(SPELL_AURA_MOD_ATTACKER_SPELL_AND_WEAPON_CRIT_CHANCE); + // Modify by player victim resilience + if (pVictim->GetTypeId() == TYPEID_PLAYER) + crit_chance -= ((Player*)pVictim)->GetRatingBonusValue(CR_CRIT_TAKEN_SPELL); + // scripted (increase crit chance ... against ... target by x% + if(pVictim->isFrozen()) // Shatter + { + AuraList const& mOverrideClassScript = GetAurasByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS); + for(AuraList::const_iterator i = mOverrideClassScript.begin(); i != mOverrideClassScript.end(); ++i) + { + switch((*i)->GetModifier()->m_miscvalue) + { + case 849: crit_chance+= 10.0f; break; //Shatter Rank 1 + case 910: crit_chance+= 20.0f; break; //Shatter Rank 2 + case 911: crit_chance+= 30.0f; break; //Shatter Rank 3 + case 912: crit_chance+= 40.0f; break; //Shatter Rank 4 + case 913: crit_chance+= 50.0f; break; //Shatter Rank 5 + } + } + } + } + break; + } + case SPELL_DAMAGE_CLASS_MELEE: + case SPELL_DAMAGE_CLASS_RANGED: + { + if (pVictim) + { + crit_chance = GetUnitCriticalChance(attackType, pVictim); + crit_chance+= (int32(GetMaxSkillValueForLevel(pVictim)) - int32(pVictim->GetDefenseSkillValue(this))) * 0.04f; + crit_chance+= GetTotalAuraModifierByMiscMask(SPELL_AURA_MOD_SPELL_CRIT_CHANCE_SCHOOL, schoolMask); + } + break; + } + default: + return false; + } + // percent done + // only players use intelligence for critical chance computations + if(Player* modOwner = GetSpellModOwner()) + modOwner->ApplySpellMod(spellProto->Id, SPELLMOD_CRITICAL_CHANCE, crit_chance); + + crit_chance = crit_chance > 0.0f ? crit_chance : 0.0f; + if (roll_chance_f(crit_chance)) + return true; + return false; +} + +uint32 Unit::SpellCriticalBonus(SpellEntry const *spellProto, uint32 damage, Unit *pVictim) +{ + // Calculate critical bonus + int32 crit_bonus; + switch(spellProto->DmgClass) + { + case SPELL_DAMAGE_CLASS_MELEE: // for melee based spells is 100% + case SPELL_DAMAGE_CLASS_RANGED: + // TODO: write here full calculation for melee/ranged spells + crit_bonus = damage; + break; + default: + crit_bonus = damage / 2; // for spells is 50% + break; + } + + // adds additional damage to crit_bonus (from talents) + if(Player* modOwner = GetSpellModOwner()) + modOwner->ApplySpellMod(spellProto->Id, SPELLMOD_CRIT_DAMAGE_BONUS, crit_bonus); + + if(pVictim) + { + uint32 creatureTypeMask = pVictim->GetCreatureTypeMask(); + crit_bonus = int32(crit_bonus * GetTotalAuraMultiplierByMiscMask(SPELL_AURA_MOD_CRIT_PERCENT_VERSUS, creatureTypeMask)); + } + + if(crit_bonus > 0) + damage += crit_bonus; + + return damage; +} + +uint32 Unit::SpellHealingBonus(SpellEntry const *spellProto, uint32 healamount, DamageEffectType damagetype, Unit *pVictim) +{ + // For totems get healing bonus from owner (statue isn't totem in fact) + if( GetTypeId()==TYPEID_UNIT && ((Creature*)this)->isTotem() && ((Totem*)this)->GetTotemType()!=TOTEM_STATUE) + if(Unit* owner = GetOwner()) + return owner->SpellHealingBonus(spellProto, healamount, damagetype, pVictim); + + // Healing Done + + // These Spells are doing fixed amount of healing (TODO found less hack-like check) + if(spellProto->Id == 15290 || spellProto->Id == 39373 || spellProto->Id == 33778 || spellProto->Id == 379 || spellProto->Id == 38395) + return healamount; + + + int32 AdvertisedBenefit = SpellBaseHealingBonus(GetSpellSchoolMask(spellProto)); + uint32 CastingTime = GetSpellCastTime(spellProto); + + // Healing Taken + AdvertisedBenefit += SpellBaseHealingBonusForVictim(GetSpellSchoolMask(spellProto), pVictim); + + // Blessing of Light dummy effects healing taken from Holy Light and Flash of Light + if (spellProto->SpellFamilyName == SPELLFAMILY_PALADIN && (spellProto->SpellFamilyFlags & 0x00000000C0000000LL)) + { + AuraList const& mDummyAuras = pVictim->GetAurasByType(SPELL_AURA_DUMMY); + for(AuraList::const_iterator i = mDummyAuras.begin();i != mDummyAuras.end(); ++i) + { + if((*i)->GetSpellProto()->SpellVisual == 9180) + { + // Flash of Light + if ((spellProto->SpellFamilyFlags & 0x0000000040000000LL) && (*i)->GetEffIndex() == 1) + AdvertisedBenefit += (*i)->GetModifier()->m_amount; + // Holy Light + else if ((spellProto->SpellFamilyFlags & 0x0000000080000000LL) && (*i)->GetEffIndex() == 0) + AdvertisedBenefit += (*i)->GetModifier()->m_amount; + } + } + } + + float ActualBenefit = 0.0f; + + if (AdvertisedBenefit != 0) + { + // Healing over Time spells + float DotFactor = 1.0f; + if(damagetype == DOT) + { + int32 DotDuration = GetSpellDuration(spellProto); + if(DotDuration > 0) + { + // 200% limit + if(DotDuration > 30000) DotDuration = 30000; + if(!IsChanneledSpell(spellProto)) DotFactor = DotDuration / 15000.0f; + int x = 0; + for(int j = 0; j < 3; j++) + { + if( spellProto->Effect[j] == SPELL_EFFECT_APPLY_AURA && ( + spellProto->EffectApplyAuraName[j] == SPELL_AURA_PERIODIC_HEAL || + spellProto->EffectApplyAuraName[j] == SPELL_AURA_PERIODIC_LEECH) ) + { + x = j; + break; + } + } + int DotTicks = 6; + if(spellProto->EffectAmplitude[x] != 0) + DotTicks = DotDuration / spellProto->EffectAmplitude[x]; + if(DotTicks) + AdvertisedBenefit /= DotTicks; + } + } + + // distribute healing to all effects, reduce AoE damage + CastingTime = GetCastingTimeForBonus( spellProto, damagetype, CastingTime ); + + // 0% bonus for damage and healing spells for leech spells from healing bonus + for(int j = 0; j < 3; ++j) + { + if( spellProto->Effect[j] == SPELL_EFFECT_HEALTH_LEECH || + spellProto->Effect[j] == SPELL_EFFECT_APPLY_AURA && spellProto->EffectApplyAuraName[j] == SPELL_AURA_PERIODIC_LEECH ) + { + CastingTime = 0; + break; + } + } + + // Exception + switch (spellProto->SpellFamilyName) + { + case SPELLFAMILY_SHAMAN: + // Healing stream from totem (add 6% per tick from hill bonus owner) + if (spellProto->SpellFamilyFlags & 0x000000002000LL) + CastingTime = 210; + // Earth Shield 30% per charge + else if (spellProto->SpellFamilyFlags & 0x40000000000LL) + CastingTime = 1050; + break; + case SPELLFAMILY_DRUID: + // Lifebloom + if (spellProto->SpellFamilyFlags & 0x1000000000LL) + { + CastingTime = damagetype == DOT ? 3500 : 1200; + DotFactor = damagetype == DOT ? 0.519f : 1.0f; + } + // Tranquility triggered spell + else if (spellProto->SpellFamilyFlags & 0x80LL) + CastingTime = 667; + // Rejuvenation + else if (spellProto->SpellFamilyFlags & 0x10LL) + DotFactor = 0.845f; + // Regrowth + else if (spellProto->SpellFamilyFlags & 0x40LL) + { + DotFactor = damagetype == DOT ? 0.705f : 1.0f; + CastingTime = damagetype == DOT ? 3500 : 1010; + } + break; + case SPELLFAMILY_PRIEST: + // Holy Nova - 14% + if ((spellProto->SpellFamilyFlags & 0x8000000LL) && spellProto->SpellIconID == 1874) + CastingTime = 500; + break; + case SPELLFAMILY_PALADIN: + // Seal and Judgement of Light + if ( spellProto->SpellFamilyFlags & 0x100040000LL ) + CastingTime = 0; + break; + case SPELLFAMILY_WARRIOR: + case SPELLFAMILY_ROGUE: + case SPELLFAMILY_HUNTER: + CastingTime = 0; + break; + } + + float LvlPenalty = CalculateLevelPenalty(spellProto); + + // Spellmod SpellDamage + float SpellModSpellDamage = 100.0f; + + if(Player* modOwner = GetSpellModOwner()) + modOwner->ApplySpellMod(spellProto->Id,SPELLMOD_SPELL_BONUS_DAMAGE,SpellModSpellDamage); + + SpellModSpellDamage /= 100.0f; + + ActualBenefit = (float)AdvertisedBenefit * ((float)CastingTime / 3500.0f) * DotFactor * SpellModSpellDamage * LvlPenalty; + } + + // use float as more appropriate for negative values and percent applying + float heal = healamount + ActualBenefit; + + // TODO: check for ALL/SPELLS type + // Healing done percent + AuraList const& mHealingDonePct = GetAurasByType(SPELL_AURA_MOD_HEALING_DONE_PERCENT); + for(AuraList::const_iterator i = mHealingDonePct.begin();i != mHealingDonePct.end(); ++i) + heal *= (100.0f + (*i)->GetModifier()->m_amount) / 100.0f; + + // apply spellmod to Done amount + if(Player* modOwner = GetSpellModOwner()) + modOwner->ApplySpellMod(spellProto->Id, damagetype == DOT ? SPELLMOD_DOT : SPELLMOD_DAMAGE, heal); + + // Healing Wave cast + if (spellProto->SpellFamilyName == SPELLFAMILY_SHAMAN && spellProto->SpellFamilyFlags & 0x0000000000000040LL) + { + // Search for Healing Way on Victim (stack up to 3 time) + int32 pctMod = 0; + Unit::AuraList const& auraDummy = pVictim->GetAurasByType(SPELL_AURA_DUMMY); + for(Unit::AuraList::const_iterator itr = auraDummy.begin(); itr!=auraDummy.end(); ++itr) + if((*itr)->GetId() == 29203) + pctMod += (*itr)->GetModifier()->m_amount; + // Apply bonus + if (pctMod) + heal = heal * (100 + pctMod) / 100; + } + + // Healing taken percent + float minval = pVictim->GetMaxNegativeAuraModifier(SPELL_AURA_MOD_HEALING_PCT); + if(minval) + heal *= (100.0f + minval) / 100.0f; + + float maxval = pVictim->GetMaxPositiveAuraModifier(SPELL_AURA_MOD_HEALING_PCT); + if(maxval) + heal *= (100.0f + maxval) / 100.0f; + + if (heal < 0) heal = 0; + + return uint32(heal); +} + +int32 Unit::SpellBaseHealingBonus(SpellSchoolMask schoolMask) +{ + int32 AdvertisedBenefit = 0; + + AuraList const& mHealingDone = GetAurasByType(SPELL_AURA_MOD_HEALING_DONE); + for(AuraList::const_iterator i = mHealingDone.begin();i != mHealingDone.end(); ++i) + if(((*i)->GetModifier()->m_miscvalue & schoolMask) != 0) + AdvertisedBenefit += (*i)->GetModifier()->m_amount; + + // Healing bonus of spirit, intellect and strength + if (GetTypeId() == TYPEID_PLAYER) + { + // Healing bonus from stats + AuraList const& mHealingDoneOfStatPercent = GetAurasByType(SPELL_AURA_MOD_SPELL_HEALING_OF_STAT_PERCENT); + for(AuraList::const_iterator i = mHealingDoneOfStatPercent.begin();i != mHealingDoneOfStatPercent.end(); ++i) + { + // stat used dependent from misc value (stat index) + Stats usedStat = Stats((*i)->GetSpellProto()->EffectMiscValue[(*i)->GetEffIndex()]); + AdvertisedBenefit += int32(GetStat(usedStat) * (*i)->GetModifier()->m_amount / 100.0f); + } + + // ... and attack power + AuraList const& mHealingDonebyAP = GetAurasByType(SPELL_AURA_MOD_SPELL_HEALING_OF_ATTACK_POWER); + for(AuraList::const_iterator i = mHealingDonebyAP.begin();i != mHealingDonebyAP.end(); ++i) + if ((*i)->GetModifier()->m_miscvalue & schoolMask) + AdvertisedBenefit += int32(GetTotalAttackPowerValue(BASE_ATTACK) * (*i)->GetModifier()->m_amount / 100.0f); + } + return AdvertisedBenefit; +} + +int32 Unit::SpellBaseHealingBonusForVictim(SpellSchoolMask schoolMask, Unit *pVictim) +{ + int32 AdvertisedBenefit = 0; + AuraList const& mDamageTaken = pVictim->GetAurasByType(SPELL_AURA_MOD_HEALING); + for(AuraList::const_iterator i = mDamageTaken.begin();i != mDamageTaken.end(); ++i) + if(((*i)->GetModifier()->m_miscvalue & schoolMask) != 0) + AdvertisedBenefit += (*i)->GetModifier()->m_amount; + return AdvertisedBenefit; +} + +bool Unit::IsImmunedToDamage(SpellSchoolMask shoolMask, bool useCharges) +{ + // no charges dependent checks + SpellImmuneList const& schoolList = m_spellImmune[IMMUNITY_SCHOOL]; + for (SpellImmuneList::const_iterator itr = schoolList.begin(); itr != schoolList.end(); ++itr) + if(itr->type & shoolMask) + return true; + + // charges dependent checks + SpellImmuneList const& damageList = m_spellImmune[IMMUNITY_DAMAGE]; + for (SpellImmuneList::const_iterator itr = damageList.begin(); itr != damageList.end(); ++itr) + { + if(itr->type & shoolMask) + { + if(useCharges) + { + AuraList const& auraDamageImmunity = GetAurasByType(SPELL_AURA_DAMAGE_IMMUNITY); + for(AuraList::const_iterator auraItr = auraDamageImmunity.begin(); auraItr != auraDamageImmunity.end(); ++auraItr) + { + if((*auraItr)->GetId()==itr->spellId) + { + if((*auraItr)->m_procCharges > 0) + { + --(*auraItr)->m_procCharges; + if((*auraItr)->m_procCharges==0) + RemoveAurasDueToSpell(itr->spellId); + } + break; + } + } + } + return true; + } + } + + return false; +} + +bool Unit::IsImmunedToSpell(SpellEntry const* spellInfo, bool useCharges) +{ + if (!spellInfo) + return false; + + // no charges first + + //FIX ME this hack: don't get feared if stunned + if (spellInfo->Mechanic == MECHANIC_FEAR ) + { + if ( hasUnitState(UNIT_STAT_STUNDED) ) + return true; + } + + // not have spells with charges currently + SpellImmuneList const& dispelList = m_spellImmune[IMMUNITY_DISPEL]; + for(SpellImmuneList::const_iterator itr = dispelList.begin(); itr != dispelList.end(); ++itr) + if(itr->type == spellInfo->Dispel) + return true; + + if( !(spellInfo->AttributesEx & SPELL_ATTR_EX_UNAFFECTED_BY_SCHOOL_IMMUNE)) // unaffected by school immunity + { + // not have spells with charges currently + SpellImmuneList const& schoolList = m_spellImmune[IMMUNITY_SCHOOL]; + for(SpellImmuneList::const_iterator itr = schoolList.begin(); itr != schoolList.end(); ++itr) + if( !(IsPositiveSpell(itr->spellId) && IsPositiveSpell(spellInfo->Id)) && + (itr->type & GetSpellSchoolMask(spellInfo)) ) + return true; + } + + // charges dependent checks + + SpellImmuneList const& mechanicList = m_spellImmune[IMMUNITY_MECHANIC]; + for(SpellImmuneList::const_iterator itr = mechanicList.begin(); itr != mechanicList.end(); ++itr) + { + if(itr->type == spellInfo->Mechanic) + { + if(useCharges) + { + AuraList const& auraMechImmunity = GetAurasByType(SPELL_AURA_MECHANIC_IMMUNITY); + for(AuraList::const_iterator auraItr = auraMechImmunity.begin(); auraItr != auraMechImmunity.end(); ++auraItr) + { + if((*auraItr)->GetId()==itr->spellId) + { + if((*auraItr)->m_procCharges > 0) + { + --(*auraItr)->m_procCharges; + if((*auraItr)->m_procCharges==0) + RemoveAurasDueToSpell(itr->spellId); + } + break; + } + } + } + return true; + } + } + + return false; +} + +bool Unit::IsImmunedToSpellEffect(uint32 effect, uint32 mechanic) const +{ + //If m_immuneToEffect type contain this effect type, IMMUNE effect. + SpellImmuneList const& effectList = m_spellImmune[IMMUNITY_EFFECT]; + for (SpellImmuneList::const_iterator itr = effectList.begin(); itr != effectList.end(); ++itr) + if(itr->type == effect) + return true; + + SpellImmuneList const& mechanicList = m_spellImmune[IMMUNITY_MECHANIC]; + for (SpellImmuneList::const_iterator itr = mechanicList.begin(); itr != mechanicList.end(); ++itr) + if(itr->type == mechanic) + return true; + + return false; +} + +bool Unit::IsDamageToThreatSpell(SpellEntry const * spellInfo) const +{ + if(!spellInfo) + return false; + + uint32 family = spellInfo->SpellFamilyName; + uint64 flags = spellInfo->SpellFamilyFlags; + + if((family == 5 && flags == 256) || //Searing Pain + (family == 6 && flags == 8192) || //Mind Blast + (family == 11 && flags == 1048576)) //Earth Shock + return true; + + return false; +} + +void Unit::MeleeDamageBonus(Unit *pVictim, uint32 *pdamage,WeaponAttackType attType, SpellEntry const *spellProto) +{ + if(!pVictim) + return; + + if(*pdamage == 0) + return; + + uint32 creatureTypeMask = pVictim->GetCreatureTypeMask(); + + // Taken/Done fixed damage bonus auras + int32 DoneFlatBenefit = 0; + int32 TakenFlatBenefit = 0; + + // ..done (for creature type by mask) in taken + AuraList const& mDamageDoneCreature = this->GetAurasByType(SPELL_AURA_MOD_DAMAGE_DONE_CREATURE); + for(AuraList::const_iterator i = mDamageDoneCreature.begin();i != mDamageDoneCreature.end(); ++i) + if(creatureTypeMask & uint32((*i)->GetModifier()->m_miscvalue)) + DoneFlatBenefit += (*i)->GetModifier()->m_amount; + + // ..done + // SPELL_AURA_MOD_DAMAGE_DONE included in weapon damage + + // ..done (base at attack power for marked target and base at attack power for creature type) + int32 APbonus = 0; + if(attType == RANGED_ATTACK) + { + APbonus += pVictim->GetTotalAuraModifier(SPELL_AURA_RANGED_ATTACK_POWER_ATTACKER_BONUS); + + // ..done (base at attack power and creature type) + AuraList const& mCreatureAttackPower = GetAurasByType(SPELL_AURA_MOD_RANGED_ATTACK_POWER_VERSUS); + for(AuraList::const_iterator i = mCreatureAttackPower.begin();i != mCreatureAttackPower.end(); ++i) + if(creatureTypeMask & uint32((*i)->GetModifier()->m_miscvalue)) + APbonus += (*i)->GetModifier()->m_amount; + } + else + { + APbonus += pVictim->GetTotalAuraModifier(SPELL_AURA_MELEE_ATTACK_POWER_ATTACKER_BONUS); + + // ..done (base at attack power and creature type) + AuraList const& mCreatureAttackPower = GetAurasByType(SPELL_AURA_MOD_MELEE_ATTACK_POWER_VERSUS); + for(AuraList::const_iterator i = mCreatureAttackPower.begin();i != mCreatureAttackPower.end(); ++i) + if(creatureTypeMask & uint32((*i)->GetModifier()->m_miscvalue)) + APbonus += (*i)->GetModifier()->m_amount; + } + + if (APbonus!=0) // Can be negative + { + bool normalized = false; + if(spellProto) + { + for (uint8 i = 0; i<3;i++) + { + if (spellProto->Effect[i] == SPELL_EFFECT_NORMALIZED_WEAPON_DMG) + { + normalized = true; + break; + } + } + } + + DoneFlatBenefit += int32(APbonus/14.0f * GetAPMultiplier(attType,normalized)); + } + + // ..taken + AuraList const& mDamageTaken = pVictim->GetAurasByType(SPELL_AURA_MOD_DAMAGE_TAKEN); + for(AuraList::const_iterator i = mDamageTaken.begin();i != mDamageTaken.end(); ++i) + if((*i)->GetModifier()->m_miscvalue & SPELL_SCHOOL_MASK_NORMAL) + TakenFlatBenefit += (*i)->GetModifier()->m_amount; + + if(attType!=RANGED_ATTACK) + TakenFlatBenefit += pVictim->GetTotalAuraModifier(SPELL_AURA_MOD_MELEE_DAMAGE_TAKEN); + else + TakenFlatBenefit += pVictim->GetTotalAuraModifier(SPELL_AURA_MOD_RANGED_DAMAGE_TAKEN); + + // Done/Taken total percent damage auras + float DoneTotalMod = 1; + float TakenTotalMod = 1; + + // ..done + // SPELL_AURA_MOD_DAMAGE_PERCENT_DONE included in weapon damage + // SPELL_AURA_MOD_OFFHAND_DAMAGE_PCT included in weapon damage + + AuraList const& mDamageDoneVersus = this->GetAurasByType(SPELL_AURA_MOD_DAMAGE_DONE_VERSUS); + for(AuraList::const_iterator i = mDamageDoneVersus.begin();i != mDamageDoneVersus.end(); ++i) + if(creatureTypeMask & uint32((*i)->GetModifier()->m_miscvalue)) + DoneTotalMod *= ((*i)->GetModifier()->m_amount+100.0f)/100.0f; + + // ..taken + AuraList const& mModDamagePercentTaken = pVictim->GetAurasByType(SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN); + for(AuraList::const_iterator i = mModDamagePercentTaken.begin(); i != mModDamagePercentTaken.end(); ++i) + if((*i)->GetModifier()->m_miscvalue & SPELL_SCHOOL_MASK_NORMAL) + TakenTotalMod *= ((*i)->GetModifier()->m_amount+100.0f)/100.0f; + + // .. taken pct: dummy auras + AuraList const& mDummyAuras = pVictim->GetAurasByType(SPELL_AURA_DUMMY); + for(AuraList::const_iterator i = mDummyAuras.begin(); i != mDummyAuras.end(); ++i) + { + switch((*i)->GetSpellProto()->SpellIconID) + { + //Cheat Death + case 2109: + if((*i)->GetModifier()->m_miscvalue & SPELL_SCHOOL_MASK_NORMAL) + { + if(pVictim->GetTypeId() != TYPEID_PLAYER) + continue; + float mod = ((Player*)pVictim)->GetRatingBonusValue(CR_CRIT_TAKEN_MELEE)*(-8.0f); + if (mod < (*i)->GetModifier()->m_amount) + mod = (*i)->GetModifier()->m_amount; + TakenTotalMod *= (mod+100.0f)/100.0f; + } + break; + //Mangle + case 2312: + if(spellProto==NULL) + break; + // Should increase Shred (initial Damage of Lacerate and Rake handled in Spell::EffectSchoolDMG) + if(spellProto->SpellFamilyName==SPELLFAMILY_DRUID && (spellProto->SpellFamilyFlags==0x00008000LL)) + TakenTotalMod *= (100.0f+(*i)->GetModifier()->m_amount)/100.0f; + break; + } + } + + // .. taken pct: class scripts + AuraList const& mclassScritAuras = GetAurasByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS); + for(AuraList::const_iterator i = mclassScritAuras.begin(); i != mclassScritAuras.end(); ++i) + { + switch((*i)->GetMiscValue()) + { + case 6427: case 6428: // Dirty Deeds + if(pVictim->HasAuraState(AURA_STATE_HEALTHLESS_35_PERCENT)) + { + Aura* eff0 = GetAura((*i)->GetId(),0); + if(!eff0 || (*i)->GetEffIndex()!=1) + { + sLog.outError("Spell structure of DD (%u) changed.",(*i)->GetId()); + continue; + } + + // effect 0 have expected value but in negative state + TakenTotalMod *= (-eff0->GetModifier()->m_amount+100.0f)/100.0f; + } + break; + } + } + + if(attType != RANGED_ATTACK) + { + AuraList const& mModMeleeDamageTakenPercent = pVictim->GetAurasByType(SPELL_AURA_MOD_MELEE_DAMAGE_TAKEN_PCT); + for(AuraList::const_iterator i = mModMeleeDamageTakenPercent.begin(); i != mModMeleeDamageTakenPercent.end(); ++i) + TakenTotalMod *= ((*i)->GetModifier()->m_amount+100.0f)/100.0f; + } + else + { + AuraList const& mModRangedDamageTakenPercent = pVictim->GetAurasByType(SPELL_AURA_MOD_RANGED_DAMAGE_TAKEN_PCT); + for(AuraList::const_iterator i = mModRangedDamageTakenPercent.begin(); i != mModRangedDamageTakenPercent.end(); ++i) + TakenTotalMod *= ((*i)->GetModifier()->m_amount+100.0f)/100.0f; + } + + float tmpDamage = float(int32(*pdamage) + DoneFlatBenefit) * DoneTotalMod; + + // apply spellmod to Done damage + if(spellProto) + { + if(Player* modOwner = GetSpellModOwner()) + modOwner->ApplySpellMod(spellProto->Id, SPELLMOD_DAMAGE, tmpDamage); + } + + tmpDamage = (tmpDamage + TakenFlatBenefit)*TakenTotalMod; + + // bonus result can be negative + *pdamage = tmpDamage > 0 ? uint32(tmpDamage) : 0; +} + +void Unit::ApplySpellImmune(uint32 spellId, uint32 op, uint32 type, bool apply) +{ + if (apply) + { + for (SpellImmuneList::iterator itr = m_spellImmune[op].begin(), next; itr != m_spellImmune[op].end(); itr = next) + { + next = itr; ++next; + if(itr->type == type) + { + m_spellImmune[op].erase(itr); + next = m_spellImmune[op].begin(); + } + } + SpellImmune Immune; + Immune.spellId = spellId; + Immune.type = type; + m_spellImmune[op].push_back(Immune); + } + else + { + for (SpellImmuneList::iterator itr = m_spellImmune[op].begin(); itr != m_spellImmune[op].end(); ++itr) + { + if(itr->spellId == spellId) + { + m_spellImmune[op].erase(itr); + break; + } + } + } + +} + +void Unit::ApplySpellDispelImmunity(const SpellEntry * spellProto, DispelType type, bool apply) +{ + ApplySpellImmune(spellProto->Id,IMMUNITY_DISPEL, type, apply); + + if (apply && spellProto->AttributesEx & SPELL_ATTR_EX_DISPEL_AURAS_ON_IMMUNITY) + RemoveAurasWithDispelType(type); +} + +float Unit::GetWeaponProcChance() const +{ + // normalized proc chance for weapon attack speed + // (odd formulae...) + if(isAttackReady(BASE_ATTACK)) + return (GetAttackTime(BASE_ATTACK) * 1.8f / 1000.0f); + else if (haveOffhandWeapon() && isAttackReady(OFF_ATTACK)) + return (GetAttackTime(OFF_ATTACK) * 1.6f / 1000.0f); + return 0; +} + +float Unit::GetPPMProcChance(uint32 WeaponSpeed, float PPM) const +{ + // proc per minute chance calculation + if (PPM <= 0) return 0.0f; + uint32 result = uint32((WeaponSpeed * PPM) / 600.0f); // result is chance in percents (probability = Speed_in_sec * (PPM / 60)) + return result; +} + +void Unit::Mount(uint32 mount) +{ + if(!mount) + return; + + RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_MOUNTING); + + SetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID, mount); + + SetFlag( UNIT_FIELD_FLAGS, UNIT_FLAG_MOUNT ); + + // unsummon pet + if(GetTypeId() == TYPEID_PLAYER) + { + Pet* pet = GetPet(); + if(pet) + { + if(pet->isControlled()) + { + ((Player*)this)->SetTemporaryUnsummonedPetNumber(pet->GetCharmInfo()->GetPetNumber()); + ((Player*)this)->SetOldPetSpell(pet->GetUInt32Value(UNIT_CREATED_BY_SPELL)); + } + + ((Player*)this)->RemovePet(NULL,PET_SAVE_NOT_IN_SLOT); + } + else + ((Player*)this)->SetTemporaryUnsummonedPetNumber(0); + } +} + +void Unit::Unmount() +{ + if(!IsMounted()) + return; + + RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_NOT_MOUNTED); + + SetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID, 0); + RemoveFlag( UNIT_FIELD_FLAGS, UNIT_FLAG_MOUNT ); + + // only resummon old pet if the player is already added to a map + // this prevents adding a pet to a not created map which would otherwise cause a crash + // (it could probably happen when logging in after a previous crash) + if(GetTypeId() == TYPEID_PLAYER && IsInWorld() && ((Player*)this)->GetTemporaryUnsummonedPetNumber() && isAlive()) + { + Pet* NewPet = new Pet; + if(!NewPet->LoadPetFromDB(this, 0, ((Player*)this)->GetTemporaryUnsummonedPetNumber(), true)) + delete NewPet; + + ((Player*)this)->SetTemporaryUnsummonedPetNumber(0); + } +} + +void Unit::SetInCombatWith(Unit* enemy) +{ + Unit* eOwner = enemy->GetCharmerOrOwnerOrSelf(); + if(eOwner->IsPvP()) + { + SetInCombatState(true); + return; + } + + //check for duel + if(eOwner->GetTypeId() == TYPEID_PLAYER && ((Player*)eOwner)->duel) + { + Unit const* myOwner = GetCharmerOrOwnerOrSelf(); + if(((Player const*)eOwner)->duel->opponent == myOwner) + { + SetInCombatState(true); + return; + } + } + SetInCombatState(false); +} + +void Unit::SetInCombatState(bool PvP) +{ + // only alive units can be in combat + if(!isAlive()) + return; + + if(PvP) + m_CombatTimer = 5000; + SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IN_COMBAT); + + if(isCharmed() || (GetTypeId()!=TYPEID_PLAYER && ((Creature*)this)->isPet())) + SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PET_IN_COMBAT); +} + +void Unit::ClearInCombat() +{ + m_CombatTimer = 0; + RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IN_COMBAT); + + if(isCharmed() || (GetTypeId()!=TYPEID_PLAYER && ((Creature*)this)->isPet())) + RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PET_IN_COMBAT); + + // Player's state will be cleared in Player::UpdateContestedPvP + if(GetTypeId()!=TYPEID_PLAYER) + clearUnitState(UNIT_STAT_ATTACK_PLAYER); +} + +bool Unit::isTargetableForAttack() const +{ + if (GetTypeId()==TYPEID_PLAYER && ((Player *)this)->isGameMaster()) + return false; + + if(HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE)) + return false; + + return isAlive() && !hasUnitState(UNIT_STAT_DIED)&& !isInFlight() /*&& !isStealth()*/; +} + +int32 Unit::ModifyHealth(int32 dVal) +{ + int32 gain = 0; + + if(dVal==0) + return 0; + + int32 curHealth = (int32)GetHealth(); + + int32 val = dVal + curHealth; + if(val <= 0) + { + SetHealth(0); + return -curHealth; + } + + int32 maxHealth = (int32)GetMaxHealth(); + + if(val < maxHealth) + { + SetHealth(val); + gain = val - curHealth; + } + else if(curHealth != maxHealth) + { + SetHealth(maxHealth); + gain = maxHealth - curHealth; + } + + return gain; +} + +int32 Unit::ModifyPower(Powers power, int32 dVal) +{ + int32 gain = 0; + + if(dVal==0) + return 0; + + int32 curPower = (int32)GetPower(power); + + int32 val = dVal + curPower; + if(val <= 0) + { + SetPower(power,0); + return -curPower; + } + + int32 maxPower = (int32)GetMaxPower(power); + + if(val < maxPower) + { + SetPower(power,val); + gain = val - curPower; + } + else if(curPower != maxPower) + { + SetPower(power,maxPower); + gain = maxPower - curPower; + } + + return gain; +} + +bool Unit::isVisibleForOrDetect(Unit const* u, bool detect, bool inVisibleList) const +{ + if(!u) + return false; + + // Always can see self + if (u==this) + return true; + + // player visible for other player if not logout and at same transport + // including case when player is out of world + bool at_same_transport = + GetTypeId() == TYPEID_PLAYER && u->GetTypeId()==TYPEID_PLAYER && + !((Player*)this)->GetSession()->PlayerLogout() && !((Player*)u)->GetSession()->PlayerLogout() && + !((Player*)this)->GetSession()->PlayerLoading() && !((Player*)u)->GetSession()->PlayerLoading() && + ((Player*)this)->GetTransport() && ((Player*)this)->GetTransport() == ((Player*)u)->GetTransport(); + + // not in world + if(!at_same_transport && (!IsInWorld() || !u->IsInWorld())) + return false; + + // forbidden to seen (at GM respawn command) + if(m_Visibility==VISIBILITY_RESPAWN) + return false; + + // always seen by owner + if(GetCharmerOrOwnerGUID()==u->GetGUID()) + return true; + + // Grid dead/alive checks + if( u->GetTypeId()==TYPEID_PLAYER) + { + // non visible at grid for any stealth state + if(!IsVisibleInGridForPlayer((Player *)u)) + return false; + + // if player is dead then he can't detect anyone in anycases + if(!u->isAlive()) + detect = false; + } + else + { + // all dead creatures/players not visible for any creatures + if(!u->isAlive() || !isAlive()) + return false; + } + + // different visible distance checks + if(u->isInFlight()) // what see player in flight + { + // use object grey distance for all (only see objects any way) + if (!IsWithinDistInMap(u,World::GetMaxVisibleDistanceInFlight()+(inVisibleList ? World::GetVisibleObjectGreyDistance() : 0.0f))) + return false; + } + else if(!isAlive()) // distance for show body + { + if (!IsWithinDistInMap(u,World::GetMaxVisibleDistanceForObject()+(inVisibleList ? World::GetVisibleObjectGreyDistance() : 0.0f))) + return false; + } + else if(GetTypeId()==TYPEID_PLAYER) // distance for show player + { + if(u->GetTypeId()==TYPEID_PLAYER) + { + // Players far than max visible distance for player or not in our map are not visible too + if (!at_same_transport && !IsWithinDistInMap(u,World::GetMaxVisibleDistanceForPlayer()+(inVisibleList ? World::GetVisibleUnitGreyDistance() : 0.0f))) + return false; + } + else + { + // Units far than max visible distance for creature or not in our map are not visible too + if (!IsWithinDistInMap(u,World::GetMaxVisibleDistanceForCreature()+(inVisibleList ? World::GetVisibleUnitGreyDistance() : 0.0f))) + return false; + } + } + else if(GetCharmerOrOwnerGUID()) // distance for show pet/charmed + { + // Pet/charmed far than max visible distance for player or not in our map are not visible too + if (!IsWithinDistInMap(u,World::GetMaxVisibleDistanceForPlayer()+(inVisibleList ? World::GetVisibleUnitGreyDistance() : 0.0f))) + return false; + } + else // distance for show creature + { + // Units far than max visible distance for creature or not in our map are not visible too + if (!IsWithinDistInMap(u,World::GetMaxVisibleDistanceForCreature()+(inVisibleList ? World::GetVisibleUnitGreyDistance() : 0.0f))) + return false; + } + + // Visible units, always are visible for all units, except for units under invisibility + if (m_Visibility == VISIBILITY_ON && u->m_invisibilityMask==0) + return true; + + // GMs see any players, not higher GMs and all units + if (u->GetTypeId() == TYPEID_PLAYER && ((Player *)u)->isGameMaster()) + { + if(GetTypeId() == TYPEID_PLAYER) + return ((Player *)this)->GetSession()->GetSecurity() <= ((Player *)u)->GetSession()->GetSecurity(); + else + return true; + } + + // non faction visibility non-breakable for non-GMs + if (m_Visibility == VISIBILITY_OFF) + return false; + + // raw invisibility + bool invisible = (m_invisibilityMask != 0 || u->m_invisibilityMask !=0); + + // detectable invisibility case + if( invisible && ( + // Invisible units, always are visible for units under same invisibility type + (m_invisibilityMask & u->m_invisibilityMask)!=0 || + // Invisible units, always are visible for unit that can detect this invisibility (have appropriate level for detect) + u->canDetectInvisibilityOf(this) || + // Units that can detect invisibility always are visible for units that can be detected + canDetectInvisibilityOf(u) )) + { + invisible = false; + } + + // special cases for always overwrite invisibility/stealth + if(invisible || m_Visibility == VISIBILITY_GROUP_STEALTH) + { + // non-hostile case + if (!u->IsHostileTo(this)) + { + // player see other player with stealth/invisibility only if he in same group or raid or same team (raid/team case dependent from conf setting) + if(GetTypeId()==TYPEID_PLAYER && u->GetTypeId()==TYPEID_PLAYER) + { + if(((Player*)this)->IsGroupVisibleFor(((Player*)u))) + return true; + + // else apply same rules as for hostile case (detecting check for stealth) + } + } + // hostile case + else + { + // Hunter mark functionality + AuraList const& auras = GetAurasByType(SPELL_AURA_MOD_STALKED); + for(AuraList::const_iterator iter = auras.begin(); iter != auras.end(); ++iter) + if((*iter)->GetCasterGUID()==u->GetGUID()) + return true; + + // else apply detecting check for stealth + } + + // none other cases for detect invisibility, so invisible + if(invisible) + return false; + + // else apply stealth detecting check + } + + // unit got in stealth in this moment and must ignore old detected state + if (m_Visibility == VISIBILITY_GROUP_NO_DETECT) + return false; + + // GM invisibility checks early, invisibility if any detectable, so if not stealth then visible + if (m_Visibility != VISIBILITY_GROUP_STEALTH) + return true; + + // NOW ONLY STEALTH CASE + + // stealth and detected and visible for some seconds + if (u->GetTypeId() == TYPEID_PLAYER && ((Player*)u)->m_DetectInvTimer > 300 && ((Player*)u)->HaveAtClient(this)) + return true; + + //if in non-detect mode then invisible for unit + if (!detect) + return false; + + // Special cases + + // If is attacked then stealth is lost, some creature can use stealth too + if( !getAttackers().empty() ) + return true; + + // If there is collision rogue is seen regardless of level difference + // TODO: check sizes in DB + float distance = GetDistance(u); + if (distance < 0.24f) + return true; + + //If a mob or player is stunned he will not be able to detect stealth + if (u->hasUnitState(UNIT_STAT_STUNDED) && (u != this)) + return false; + + // Creature can detect target only in aggro radius + if(u->GetTypeId() != TYPEID_PLAYER) + { + //Always invisible from back and out of aggro range + bool isInFront = u->isInFront(this,((Creature const*)u)->GetAttackDistance(this)); + if(!isInFront) + return false; + } + else + { + //Always invisible from back + bool isInFront = u->isInFront(this,(GetTypeId()==TYPEID_PLAYER || GetCharmerOrOwnerGUID()) ? World::GetMaxVisibleDistanceForPlayer() : World::GetMaxVisibleDistanceForCreature()); + if(!isInFront) + return false; + } + + // if doesn't have stealth detection (Shadow Sight), then check how stealthy the unit is, otherwise just check los + if(!u->HasAuraType(SPELL_AURA_DETECT_STEALTH)) + { + //Calculation if target is in front + + //Visible distance based on stealth value (stealth rank 4 300MOD, 10.5 - 3 = 7.5) + float visibleDistance = 10.5f - (GetTotalAuraModifier(SPELL_AURA_MOD_STEALTH)/100.0f); + + //Visible distance is modified by + //-Level Diff (every level diff = 1.0f in visible distance) + visibleDistance += int32(u->getLevelForTarget(this)) - int32(this->getLevelForTarget(u)); + + //This allows to check talent tree and will add addition stealth dependent on used points) + int32 stealthMod = GetTotalAuraModifier(SPELL_AURA_MOD_STEALTH_LEVEL); + if(stealthMod < 0) + stealthMod = 0; + + //-Stealth Mod(positive like Master of Deception) and Stealth Detection(negative like paranoia) + //based on wowwiki every 5 mod we have 1 more level diff in calculation + visibleDistance += (int32(u->GetTotalAuraModifier(SPELL_AURA_MOD_DETECT)) - stealthMod)/5.0f; + + if(distance > visibleDistance) + return false; + } + + // Now check is target visible with LoS + float ox,oy,oz; + u->GetPosition(ox,oy,oz); + return IsWithinLOS(ox,oy,oz); +} + +void Unit::SetVisibility(UnitVisibility x) +{ + m_Visibility = x; + + if(IsInWorld()) + { + Map *m = MapManager::Instance().GetMap(GetMapId(), this); + + if(GetTypeId()==TYPEID_PLAYER) + m->PlayerRelocation((Player*)this,GetPositionX(),GetPositionY(),GetPositionZ(),GetOrientation()); + else + m->CreatureRelocation((Creature*)this,GetPositionX(),GetPositionY(),GetPositionZ(),GetOrientation()); + } +} + +bool Unit::canDetectInvisibilityOf(Unit const* u) const +{ + if(uint32 mask = (m_detectInvisibilityMask & u->m_invisibilityMask)) + { + for(uint32 i = 0; i < 10; ++i) + { + if(((1 << i) & mask)==0) + continue; + + // find invisibility level + uint32 invLevel = 0; + Unit::AuraList const& iAuras = u->GetAurasByType(SPELL_AURA_MOD_INVISIBILITY); + for(Unit::AuraList::const_iterator itr = iAuras.begin(); itr != iAuras.end(); ++itr) + if(((*itr)->GetModifier()->m_miscvalue)==i && invLevel < (*itr)->GetModifier()->m_amount) + invLevel = (*itr)->GetModifier()->m_amount; + + // find invisibility detect level + uint32 detectLevel = 0; + Unit::AuraList const& dAuras = GetAurasByType(SPELL_AURA_MOD_INVISIBILITY_DETECTION); + for(Unit::AuraList::const_iterator itr = dAuras.begin(); itr != dAuras.end(); ++itr) + if(((*itr)->GetModifier()->m_miscvalue)==i && detectLevel < (*itr)->GetModifier()->m_amount) + detectLevel = (*itr)->GetModifier()->m_amount; + + if(i==6 && GetTypeId()==TYPEID_PLAYER) // special drunk detection case + { + detectLevel = ((Player*)this)->GetDrunkValue(); + } + + if(invLevel <= detectLevel) + return true; + } + } + + return false; +} + +void Unit::UpdateSpeed(UnitMoveType mtype, bool forced) +{ + int32 main_speed_mod = 0; + float stack_bonus = 1.0f; + float non_stack_bonus = 1.0f; + + switch(mtype) + { + case MOVE_WALK: + return; + case MOVE_RUN: + { + if (IsMounted()) // Use on mount auras + { + main_speed_mod = GetMaxPositiveAuraModifier(SPELL_AURA_MOD_INCREASE_MOUNTED_SPEED); + stack_bonus = GetTotalAuraMultiplier(SPELL_AURA_MOD_MOUNTED_SPEED_ALWAYS); + non_stack_bonus = (100.0f + GetMaxPositiveAuraModifier(SPELL_AURA_MOD_MOUNTED_SPEED_NOT_STACK))/100.0f; + } + else + { + main_speed_mod = GetMaxPositiveAuraModifier(SPELL_AURA_MOD_INCREASE_SPEED); + stack_bonus = GetTotalAuraMultiplier(SPELL_AURA_MOD_SPEED_ALWAYS); + non_stack_bonus = (100.0f + GetMaxPositiveAuraModifier(SPELL_AURA_MOD_SPEED_NOT_STACK))/100.0f; + } + break; + } + case MOVE_WALKBACK: + return; + case MOVE_SWIM: + { + main_speed_mod = GetMaxPositiveAuraModifier(SPELL_AURA_MOD_INCREASE_SWIM_SPEED); + break; + } + case MOVE_SWIMBACK: + return; + case MOVE_FLY: + { + if (IsMounted()) // Use on mount auras + main_speed_mod = GetMaxPositiveAuraModifier(SPELL_AURA_MOD_INCREASE_FLIGHT_SPEED); + else // Use not mount (shapeshift for example) auras (should stack) + main_speed_mod = GetTotalAuraModifier(SPELL_AURA_MOD_SPEED_FLIGHT); + stack_bonus = GetTotalAuraMultiplier(SPELL_AURA_MOD_FLIGHT_SPEED_ALWAYS); + non_stack_bonus = (100.0 + GetMaxPositiveAuraModifier(SPELL_AURA_MOD_FLIGHT_SPEED_NOT_STACK))/100.0f; + break; + } + case MOVE_FLYBACK: + return; + default: + sLog.outError("Unit::UpdateSpeed: Unsupported move type (%d)", mtype); + return; + } + + float bonus = non_stack_bonus > stack_bonus ? non_stack_bonus : stack_bonus; + // now we ready for speed calculation + float speed = main_speed_mod ? bonus*(100.0f + main_speed_mod)/100.0f : bonus; + + switch(mtype) + { + case MOVE_RUN: + case MOVE_SWIM: + case MOVE_FLY: + { + // Normalize speed by 191 aura SPELL_AURA_USE_NORMAL_MOVEMENT_SPEED if need + // TODO: possible affect only on MOVE_RUN + if(int32 normalization = GetMaxPositiveAuraModifier(SPELL_AURA_USE_NORMAL_MOVEMENT_SPEED)) + { + // Use speed from aura + float max_speed = normalization / baseMoveSpeed[mtype]; + if (speed > max_speed) + speed = max_speed; + } + break; + } + default: + break; + } + + // Apply strongest slow aura mod to speed + int32 slow = GetMaxNegativeAuraModifier(SPELL_AURA_MOD_DECREASE_SPEED); + if (slow) + speed *=(100.0f + slow)/100.0f; + SetSpeed(mtype, speed, forced); +} + +float Unit::GetSpeed( UnitMoveType mtype ) const +{ + return m_speed_rate[mtype]*baseMoveSpeed[mtype]; +} + +void Unit::SetSpeed(UnitMoveType mtype, float rate, bool forced) +{ + if (rate < 0) + rate = 0.0f; + + // Update speed only on change + if (m_speed_rate[mtype] == rate) + return; + + m_speed_rate[mtype] = rate; + + propagateSpeedChange(); + + // Send speed change packet only for player + if (GetTypeId()!=TYPEID_PLAYER) + return; + + WorldPacket data; + if(!forced) + { + switch(mtype) + { + case MOVE_WALK: + data.Initialize(MSG_MOVE_SET_WALK_SPEED, 8+4+1+4+4+4+4+4+4+4); + break; + case MOVE_RUN: + data.Initialize(MSG_MOVE_SET_RUN_SPEED, 8+4+1+4+4+4+4+4+4+4); + break; + case MOVE_WALKBACK: + data.Initialize(MSG_MOVE_SET_RUN_BACK_SPEED, 8+4+1+4+4+4+4+4+4+4); + break; + case MOVE_SWIM: + data.Initialize(MSG_MOVE_SET_SWIM_SPEED, 8+4+1+4+4+4+4+4+4+4); + break; + case MOVE_SWIMBACK: + data.Initialize(MSG_MOVE_SET_SWIM_BACK_SPEED, 8+4+1+4+4+4+4+4+4+4); + break; + case MOVE_TURN: + data.Initialize(MSG_MOVE_SET_TURN_RATE, 8+4+1+4+4+4+4+4+4+4); + break; + case MOVE_FLY: + data.Initialize(MSG_MOVE_SET_FLIGHT_SPEED, 8+4+1+4+4+4+4+4+4+4); + break; + case MOVE_FLYBACK: + data.Initialize(MSG_MOVE_SET_FLIGHT_BACK_SPEED, 8+4+1+4+4+4+4+4+4+4); + break; + default: + sLog.outError("Unit::SetSpeed: Unsupported move type (%d), data not sent to client.",mtype); + return; + } + + data.append(GetPackGUID()); + data << uint32(0); //movement flags + data << uint8(0); //unk + data << uint32(getMSTime()); + data << float(GetPositionX()); + data << float(GetPositionY()); + data << float(GetPositionZ()); + data << float(GetOrientation()); + data << uint32(0); //flag unk + data << float(GetSpeed(mtype)); + SendMessageToSet( &data, true ); + } + else + { + // register forced speed changes for WorldSession::HandleForceSpeedChangeAck + // and do it only for real sent packets and use run for run/mounted as client expected + ++((Player*)this)->m_forced_speed_changes[mtype]; + switch(mtype) + { + case MOVE_WALK: + data.Initialize(SMSG_FORCE_WALK_SPEED_CHANGE, 16); + break; + case MOVE_RUN: + data.Initialize(SMSG_FORCE_RUN_SPEED_CHANGE, 17); + break; + case MOVE_WALKBACK: + data.Initialize(SMSG_FORCE_RUN_BACK_SPEED_CHANGE, 16); + break; + case MOVE_SWIM: + data.Initialize(SMSG_FORCE_SWIM_SPEED_CHANGE, 16); + break; + case MOVE_SWIMBACK: + data.Initialize(SMSG_FORCE_SWIM_BACK_SPEED_CHANGE, 16); + break; + case MOVE_TURN: + data.Initialize(SMSG_FORCE_TURN_RATE_CHANGE, 16); + break; + case MOVE_FLY: + data.Initialize(SMSG_FORCE_FLIGHT_SPEED_CHANGE, 16); + break; + case MOVE_FLYBACK: + data.Initialize(SMSG_FORCE_FLIGHT_BACK_SPEED_CHANGE, 16); + break; + default: + sLog.outError("Unit::SetSpeed: Unsupported move type (%d), data not sent to client.",mtype); + return; + } + data.append(GetPackGUID()); + data << (uint32)0; + if (mtype == MOVE_RUN) + data << uint8(0); // new 2.1.0 + data << float(GetSpeed(mtype)); + SendMessageToSet( &data, true ); + } + if(Pet* pet = GetPet()) + pet->SetSpeed(MOVE_RUN, m_speed_rate[mtype],forced); +} + +void Unit::SetHover(bool on) +{ + if(on) + CastSpell(this,11010,true); + else + RemoveAurasDueToSpell(11010); +} + +void Unit::setDeathState(DeathState s) +{ + if (s != ALIVE && s!= JUST_ALIVED) + { + CombatStop(); + DeleteThreatList(); + ClearComboPointHolders(); // any combo points pointed to unit lost at it death + + if(IsNonMeleeSpellCasted(false)) + InterruptNonMeleeSpells(false); + } + + if (s == JUST_DIED) + { + RemoveAllAurasOnDeath(); + UnsummonAllTotems(); + + ModifyAuraState(AURA_STATE_HEALTHLESS_20_PERCENT, false); + ModifyAuraState(AURA_STATE_HEALTHLESS_35_PERCENT, false); + // remove aurastates allowing special moves + ClearAllReactives(); + ClearDiminishings(); + } + else if(s == JUST_ALIVED) + { + RemoveFlag (UNIT_FIELD_FLAGS, UNIT_FLAG_SKINNABLE); // clear skinnable for creature and player (at battleground) + } + + if (m_deathState != ALIVE && s == ALIVE) + { + //_ApplyAllAuraMods(); + } + m_deathState = s; +} + +/*######################################## +######## ######## +######## AGGRO SYSTEM ######## +######## ######## +########################################*/ +bool Unit::CanHaveThreatList() const +{ + // only creatures can have threat list + if( GetTypeId() != TYPEID_UNIT ) + return false; + + // only alive units can have threat list + if( !isAlive() ) + return false; + + // pets and totems can not have threat list + if( ((Creature*)this)->isPet() || ((Creature*)this)->isTotem() ) + return false; + + return true; +} + +//====================================================================== + +float Unit::ApplyTotalThreatModifier(float threat, SpellSchoolMask schoolMask) +{ + if(!HasAuraType(SPELL_AURA_MOD_THREAT)) + return threat; + + SpellSchools school = GetFirstSchoolInMask(schoolMask); + + return threat * m_threatModifier[school]; +} + +//====================================================================== + +void Unit::AddThreat(Unit* pVictim, float threat, SpellSchoolMask schoolMask, SpellEntry const *threatSpell) +{ + // Only mobs can manage threat lists + if(CanHaveThreatList()) + m_ThreatManager.addThreat(pVictim, threat, schoolMask, threatSpell); +} + +//====================================================================== + +void Unit::DeleteThreatList() +{ + m_ThreatManager.clearReferences(); +} + +//====================================================================== + +void Unit::TauntApply(Unit* taunter) +{ + assert(GetTypeId()== TYPEID_UNIT); + + if(!taunter || (taunter->GetTypeId() == TYPEID_PLAYER && ((Player*)taunter)->isGameMaster())) + return; + + if(!CanHaveThreatList()) + return; + + Unit *target = getVictim(); + if(target && target == taunter) + return; + + SetInFront(taunter); + if (((Creature*)this)->AI()) + ((Creature*)this)->AI()->AttackStart(taunter); + + m_ThreatManager.tauntApply(taunter); +} + +//====================================================================== + +void Unit::TauntFadeOut(Unit *taunter) +{ + assert(GetTypeId()== TYPEID_UNIT); + + if(!taunter || (taunter->GetTypeId() == TYPEID_PLAYER && ((Player*)taunter)->isGameMaster())) + return; + + if(!CanHaveThreatList()) + return; + + Unit *target = getVictim(); + if(!target || target != taunter) + return; + + if(m_ThreatManager.isThreatListEmpty()) + { + if(((Creature*)this)->AI()) + ((Creature*)this)->AI()->EnterEvadeMode(); + return; + } + + m_ThreatManager.tauntFadeOut(taunter); + target = m_ThreatManager.getHostilTarget(); + + if (target && target != taunter) + { + SetInFront(target); + if (((Creature*)this)->AI()) + ((Creature*)this)->AI()->AttackStart(target); + } +} + +//====================================================================== + +bool Unit::SelectHostilTarget() +{ + //function provides main threat functionality + //next-victim-selection algorithm and evade mode are called + //threat list sorting etc. + + assert(GetTypeId()== TYPEID_UNIT); + Unit* target = NULL; + + //This function only useful once AI has been initilazied + if (!((Creature*)this)->AI()) + return false; + + if(!m_ThreatManager.isThreatListEmpty()) + { + if(!HasAuraType(SPELL_AURA_MOD_TAUNT)) + { + target = m_ThreatManager.getHostilTarget(); + } + } + + if(target) + { + if(!hasUnitState(UNIT_STAT_STUNDED)) + SetInFront(target); + ((Creature*)this)->AI()->AttackStart(target); + return true; + } + + // no target but something prevent go to evade mode + if( !isInCombat() || HasAuraType(SPELL_AURA_MOD_TAUNT) ) + return false; + + // last case when creature don't must go to evade mode: + // it in combat but attacker not make any damage and not enter to aggro radius to have record in threat list + // for example at owner command to pet attack some far away creature + // Note: creature not have targeted movement generator but have attacker in this case + if( GetMotionMaster()->GetCurrentMovementGeneratorType() != TARGETED_MOTION_TYPE ) + { + for(AttackerSet::const_iterator itr = m_attackers.begin(); itr != m_attackers.end(); ++itr) + { + if( (*itr)->IsInMap(this) && (*itr)->isTargetableForAttack() && (*itr)->isInAccessablePlaceFor((Creature*)this) ) + return false; + } + } + + // enter in evade mode in other case + ((Creature*)this)->AI()->EnterEvadeMode(); + + return false; +} + +//====================================================================== +//====================================================================== +//====================================================================== + +int32 Unit::CalculateSpellDamage(SpellEntry const* spellProto, uint8 effect_index, int32 effBasePoints, Unit const* target) +{ + Player* unitPlayer = (GetTypeId() == TYPEID_PLAYER) ? (Player*)this : NULL; + + uint8 comboPoints = unitPlayer ? unitPlayer->GetComboPoints() : 0; + + int32 level = int32(getLevel()) - int32(spellProto->spellLevel); + if (level > spellProto->maxLevel && spellProto->maxLevel > 0) + level = spellProto->maxLevel; + + float basePointsPerLevel = spellProto->EffectRealPointsPerLevel[effect_index]; + float randomPointsPerLevel = spellProto->EffectDicePerLevel[effect_index]; + int32 basePoints = int32(effBasePoints + level * basePointsPerLevel); + int32 randomPoints = int32(spellProto->EffectDieSides[effect_index] + level * randomPointsPerLevel); + float comboDamage = spellProto->EffectPointsPerComboPoint[effect_index]; + + // prevent random generator from getting confused by spells casted with Unit::CastCustomSpell + int32 randvalue = spellProto->EffectBaseDice[effect_index] >= randomPoints ? spellProto->EffectBaseDice[effect_index]:irand(spellProto->EffectBaseDice[effect_index], randomPoints); + int32 value = basePoints + randvalue; + //random damage + if(comboDamage != 0 && unitPlayer && target && (target->GetGUID() == unitPlayer->GetComboTarget())) + value += (int32)(comboDamage * comboPoints); + + if(Player* modOwner = GetSpellModOwner()) + { + modOwner->ApplySpellMod(spellProto->Id,SPELLMOD_ALL_EFFECTS, value); + switch(effect_index) + { + case 0: + modOwner->ApplySpellMod(spellProto->Id,SPELLMOD_EFFECT1, value); + break; + case 1: + modOwner->ApplySpellMod(spellProto->Id,SPELLMOD_EFFECT2, value); + break; + case 2: + modOwner->ApplySpellMod(spellProto->Id,SPELLMOD_EFFECT3, value); + break; + } + } + + if(spellProto->Attributes & SPELL_ATTR_LEVEL_DAMAGE_CALCULATION && spellProto->spellLevel && + spellProto->Effect[effect_index] != SPELL_EFFECT_WEAPON_PERCENT_DAMAGE && + spellProto->Effect[effect_index] != SPELL_EFFECT_KNOCK_BACK) + value = int32(value*0.25f*exp(getLevel()*(70-spellProto->spellLevel)/1000.0f)); + + return value; +} + +int32 Unit::CalculateSpellDuration(SpellEntry const* spellProto, uint8 effect_index, Unit const* target) +{ + Player* unitPlayer = (GetTypeId() == TYPEID_PLAYER) ? (Player*)this : NULL; + + uint8 comboPoints = unitPlayer ? unitPlayer->GetComboPoints() : 0; + + int32 minduration = GetSpellDuration(spellProto); + int32 maxduration = GetSpellMaxDuration(spellProto); + + int32 duration; + + if( minduration != -1 && minduration != maxduration ) + duration = minduration + int32((maxduration - minduration) * comboPoints / 5); + else + duration = minduration; + + if (duration > 0) + { + int32 mechanic = GetEffectMechanic(spellProto, effect_index); + // Find total mod value (negative bonus) + int32 durationMod_always = target->GetTotalAuraModifierByMiscValue(SPELL_AURA_MECHANIC_DURATION_MOD, mechanic); + // Find max mod (negative bonus) + int32 durationMod_not_stack = target->GetMaxNegativeAuraModifierByMiscValue(SPELL_AURA_MECHANIC_DURATION_MOD_NOT_STACK, mechanic); + + int32 durationMod = 0; + // Select strongest negative mod + if (durationMod_always > durationMod_not_stack) + durationMod = durationMod_not_stack; + else + durationMod = durationMod_always; + + if (durationMod != 0) + duration = int32(int64(duration) * (100+durationMod) /100); + + if (duration < 0) duration = 0; + } + + return duration; +} + +DiminishingLevels Unit::GetDiminishing(DiminishingGroup group) +{ + for(Diminishing::iterator i = m_Diminishing.begin(); i != m_Diminishing.end(); ++i) + { + if(i->DRGroup != group) + continue; + + if(!i->hitCount) + return DIMINISHING_LEVEL_1; + + if(!i->hitTime) + return DIMINISHING_LEVEL_1; + + // If last spell was casted more than 15 seconds ago - reset the count. + if(i->stack==0 && getMSTimeDiff(i->hitTime,getMSTime()) > 15000) + { + i->hitCount = DIMINISHING_LEVEL_1; + return DIMINISHING_LEVEL_1; + } + // or else increase the count. + else + { + return DiminishingLevels(i->hitCount); + } + } + return DIMINISHING_LEVEL_1; +} + +void Unit::IncrDiminishing(DiminishingGroup group) +{ + // Checking for existing in the table + bool IsExist = false; + for(Diminishing::iterator i = m_Diminishing.begin(); i != m_Diminishing.end(); ++i) + { + if(i->DRGroup != group) + continue; + + IsExist = true; + if(i->hitCount < DIMINISHING_LEVEL_IMMUNE) + i->hitCount += 1; + + break; + } + + if(!IsExist) + m_Diminishing.push_back(DiminishingReturn(group,getMSTime(),DIMINISHING_LEVEL_2)); +} + +void Unit::ApplyDiminishingToDuration(DiminishingGroup group, int32 &duration,Unit* caster,DiminishingLevels Level) +{ + if(duration == -1 || group == DIMINISHING_NONE || caster->IsFriendlyTo(this) ) + return; + + // Duration of crowd control abilities on pvp target is limited by 10 sec. (2.2.0) + if(duration > 10000 && IsDiminishingReturnsGroupDurationLimited(group)) + { + // test pet/charm masters instead pets/charmeds + Unit const* targetOwner = GetCharmerOrOwner(); + Unit const* casterOwner = caster->GetCharmerOrOwner(); + + Unit const* target = targetOwner ? targetOwner : this; + Unit const* source = casterOwner ? casterOwner : caster; + + if(target->GetTypeId() == TYPEID_PLAYER && source->GetTypeId() == TYPEID_PLAYER) + duration = 10000; + } + + float mod = 1.0f; + + // Some diminishings applies to mobs too (for example, Stun) + if((GetDiminishingReturnsGroupType(group) == DRTYPE_PLAYER && GetTypeId() == TYPEID_PLAYER) || GetDiminishingReturnsGroupType(group) == DRTYPE_ALL) + { + DiminishingLevels diminish = Level; + switch(diminish) + { + case DIMINISHING_LEVEL_1: break; + case DIMINISHING_LEVEL_2: mod = 0.5f; break; + case DIMINISHING_LEVEL_3: mod = 0.25f; break; + case DIMINISHING_LEVEL_IMMUNE: mod = 0.0f;break; + default: break; + } + } + + duration = int32(duration * mod); +} + +void Unit::ApplyDiminishingAura( DiminishingGroup group, bool apply ) +{ + // Checking for existing in the table + for(Diminishing::iterator i = m_Diminishing.begin(); i != m_Diminishing.end(); ++i) + { + if(i->DRGroup != group) + continue; + + i->hitTime = getMSTime(); + + if(apply) + i->stack += 1; + else if(i->stack) + i->stack -= 1; + + break; + } +} + +Unit* Unit::GetUnit(WorldObject& object, uint64 guid) +{ + return ObjectAccessor::GetUnit(object,guid); +} + +bool Unit::isVisibleForInState( Player const* u, bool inVisibleList ) const +{ + return isVisibleForOrDetect(u,false,inVisibleList); +} + +uint32 Unit::GetCreatureType() const +{ + if(GetTypeId() == TYPEID_PLAYER) + { + SpellShapeshiftEntry const* ssEntry = sSpellShapeshiftStore.LookupEntry(((Player*)this)->m_form); + if(ssEntry && ssEntry->creatureType > 0) + return ssEntry->creatureType; + else + return CREATURE_TYPE_HUMANOID; + } + else + return ((Creature*)this)->GetCreatureInfo()->type; +} + +/*####################################### +######## ######## +######## STAT SYSTEM ######## +######## ######## +#######################################*/ + +bool Unit::HandleStatModifier(UnitMods unitMod, UnitModifierType modifierType, float amount, bool apply) +{ + if(unitMod >= UNIT_MOD_END || modifierType >= MODIFIER_TYPE_END) + { + sLog.outError("ERROR in HandleStatModifier(): nonexisted UnitMods or wrong UnitModifierType!"); + return false; + } + + float val = 1.0f; + + switch(modifierType) + { + case BASE_VALUE: + case TOTAL_VALUE: + m_auraModifiersGroup[unitMod][modifierType] += apply ? amount : -amount; + break; + case BASE_PCT: + case TOTAL_PCT: + if(amount <= -100.0f) //small hack-fix for -100% modifiers + amount = -200.0f; + + val = (100.0f + amount) / 100.0f; + m_auraModifiersGroup[unitMod][modifierType] *= apply ? val : (1.0f/val); + break; + + default: + break; + } + + if(!CanModifyStats()) + return false; + + switch(unitMod) + { + case UNIT_MOD_STAT_STRENGTH: + case UNIT_MOD_STAT_AGILITY: + case UNIT_MOD_STAT_STAMINA: + case UNIT_MOD_STAT_INTELLECT: + case UNIT_MOD_STAT_SPIRIT: UpdateStats(GetStatByAuraGroup(unitMod)); break; + + case UNIT_MOD_ARMOR: UpdateArmor(); break; + case UNIT_MOD_HEALTH: UpdateMaxHealth(); break; + + case UNIT_MOD_MANA: + case UNIT_MOD_RAGE: + case UNIT_MOD_FOCUS: + case UNIT_MOD_ENERGY: + case UNIT_MOD_HAPPINESS: UpdateMaxPower(GetPowerTypeByAuraGroup(unitMod)); break; + + case UNIT_MOD_RESISTANCE_HOLY: + case UNIT_MOD_RESISTANCE_FIRE: + case UNIT_MOD_RESISTANCE_NATURE: + case UNIT_MOD_RESISTANCE_FROST: + case UNIT_MOD_RESISTANCE_SHADOW: + case UNIT_MOD_RESISTANCE_ARCANE: UpdateResistances(GetSpellSchoolByAuraGroup(unitMod)); break; + + case UNIT_MOD_ATTACK_POWER: UpdateAttackPowerAndDamage(); break; + case UNIT_MOD_ATTACK_POWER_RANGED: UpdateAttackPowerAndDamage(true); break; + + case UNIT_MOD_DAMAGE_MAINHAND: UpdateDamagePhysical(BASE_ATTACK); break; + case UNIT_MOD_DAMAGE_OFFHAND: UpdateDamagePhysical(OFF_ATTACK); break; + case UNIT_MOD_DAMAGE_RANGED: UpdateDamagePhysical(RANGED_ATTACK); break; + + default: + break; + } + + return true; +} + +float Unit::GetModifierValue(UnitMods unitMod, UnitModifierType modifierType) const +{ + if( unitMod >= UNIT_MOD_END || modifierType >= MODIFIER_TYPE_END) + { + sLog.outError("ERROR: trial to access nonexisted modifier value from UnitMods!"); + return 0.0f; + } + + if(modifierType == TOTAL_PCT && m_auraModifiersGroup[unitMod][modifierType] <= 0.0f) + return 0.0f; + + return m_auraModifiersGroup[unitMod][modifierType]; +} + +float Unit::GetTotalStatValue(Stats stat) const +{ + UnitMods unitMod = UnitMods(UNIT_MOD_STAT_START + stat); + + if(m_auraModifiersGroup[unitMod][TOTAL_PCT] <= 0.0f) + return 0.0f; + + // value = ((base_value * base_pct) + total_value) * total_pct + float value = m_auraModifiersGroup[unitMod][BASE_VALUE] + GetCreateStat(stat); + value *= m_auraModifiersGroup[unitMod][BASE_PCT]; + value += m_auraModifiersGroup[unitMod][TOTAL_VALUE]; + value *= m_auraModifiersGroup[unitMod][TOTAL_PCT]; + + return value; +} + +float Unit::GetTotalAuraModValue(UnitMods unitMod) const +{ + if(unitMod >= UNIT_MOD_END) + { + sLog.outError("ERROR: trial to access nonexisted UnitMods in GetTotalAuraModValue()!"); + return 0.0f; + } + + if(m_auraModifiersGroup[unitMod][TOTAL_PCT] <= 0.0f) + return 0.0f; + + float value = m_auraModifiersGroup[unitMod][BASE_VALUE]; + value *= m_auraModifiersGroup[unitMod][BASE_PCT]; + value += m_auraModifiersGroup[unitMod][TOTAL_VALUE]; + value *= m_auraModifiersGroup[unitMod][TOTAL_PCT]; + + return value; +} + +SpellSchools Unit::GetSpellSchoolByAuraGroup(UnitMods unitMod) const +{ + SpellSchools school = SPELL_SCHOOL_NORMAL; + + switch(unitMod) + { + case UNIT_MOD_RESISTANCE_HOLY: school = SPELL_SCHOOL_HOLY; break; + case UNIT_MOD_RESISTANCE_FIRE: school = SPELL_SCHOOL_FIRE; break; + case UNIT_MOD_RESISTANCE_NATURE: school = SPELL_SCHOOL_NATURE; break; + case UNIT_MOD_RESISTANCE_FROST: school = SPELL_SCHOOL_FROST; break; + case UNIT_MOD_RESISTANCE_SHADOW: school = SPELL_SCHOOL_SHADOW; break; + case UNIT_MOD_RESISTANCE_ARCANE: school = SPELL_SCHOOL_ARCANE; break; + + default: + break; + } + + return school; +} + +Stats Unit::GetStatByAuraGroup(UnitMods unitMod) const +{ + Stats stat = STAT_STRENGTH; + + switch(unitMod) + { + case UNIT_MOD_STAT_STRENGTH: stat = STAT_STRENGTH; break; + case UNIT_MOD_STAT_AGILITY: stat = STAT_AGILITY; break; + case UNIT_MOD_STAT_STAMINA: stat = STAT_STAMINA; break; + case UNIT_MOD_STAT_INTELLECT: stat = STAT_INTELLECT; break; + case UNIT_MOD_STAT_SPIRIT: stat = STAT_SPIRIT; break; + + default: + break; + } + + return stat; +} + +Powers Unit::GetPowerTypeByAuraGroup(UnitMods unitMod) const +{ + Powers power = POWER_MANA; + + switch(unitMod) + { + case UNIT_MOD_MANA: power = POWER_MANA; break; + case UNIT_MOD_RAGE: power = POWER_RAGE; break; + case UNIT_MOD_FOCUS: power = POWER_FOCUS; break; + case UNIT_MOD_ENERGY: power = POWER_ENERGY; break; + case UNIT_MOD_HAPPINESS: power = POWER_HAPPINESS; break; + + default: + break; + } + + return power; +} + +float Unit::GetTotalAttackPowerValue(WeaponAttackType attType) const +{ + UnitMods unitMod = (attType == RANGED_ATTACK) ? UNIT_MOD_ATTACK_POWER_RANGED : UNIT_MOD_ATTACK_POWER; + + float val = GetTotalAuraModValue(unitMod); + if(val < 0.0f) + val = 0.0f; + + return val; +} + +float Unit::GetWeaponDamageRange(WeaponAttackType attType ,WeaponDamageRange type) const +{ + if (attType == OFF_ATTACK && !haveOffhandWeapon()) + return 0.0f; + + return m_weaponDamage[attType][type]; +} + +void Unit::SetLevel(uint32 lvl) +{ + SetUInt32Value(UNIT_FIELD_LEVEL, lvl); + + // group update + if ((GetTypeId() == TYPEID_PLAYER) && ((Player*)this)->GetGroup()) + ((Player*)this)->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_LEVEL); +} + +void Unit::SetHealth(uint32 val) +{ + uint32 maxHealth = GetMaxHealth(); + if(maxHealth < val) + val = maxHealth; + + SetUInt32Value(UNIT_FIELD_HEALTH, val); + + // group update + if(GetTypeId() == TYPEID_PLAYER) + { + if(((Player*)this)->GetGroup()) + ((Player*)this)->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_CUR_HP); + } + else if(((Creature*)this)->isPet()) + { + Pet *pet = ((Pet*)this); + if(pet->isControlled()) + { + Unit *owner = GetOwner(); + if(owner && (owner->GetTypeId() == TYPEID_PLAYER) && ((Player*)owner)->GetGroup()) + ((Player*)owner)->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_PET_CUR_HP); + } + } +} + +void Unit::SetMaxHealth(uint32 val) +{ + uint32 health = GetHealth(); + SetUInt32Value(UNIT_FIELD_MAXHEALTH, val); + + // group update + if(GetTypeId() == TYPEID_PLAYER) + { + if(((Player*)this)->GetGroup()) + ((Player*)this)->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_MAX_HP); + } + else if(((Creature*)this)->isPet()) + { + Pet *pet = ((Pet*)this); + if(pet->isControlled()) + { + Unit *owner = GetOwner(); + if(owner && (owner->GetTypeId() == TYPEID_PLAYER) && ((Player*)owner)->GetGroup()) + ((Player*)owner)->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_PET_MAX_HP); + } + } + + if(val < health) + SetHealth(val); +} + +void Unit::SetPower(Powers power, uint32 val) +{ + uint32 maxPower = GetMaxPower(power); + if(maxPower < val) + val = maxPower; + + SetStatInt32Value(UNIT_FIELD_POWER1 + power, val); + + // group update + if(GetTypeId() == TYPEID_PLAYER) + { + if(((Player*)this)->GetGroup()) + ((Player*)this)->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_CUR_POWER); + } + else if(((Creature*)this)->isPet()) + { + Pet *pet = ((Pet*)this); + if(pet->isControlled()) + { + Unit *owner = GetOwner(); + if(owner && (owner->GetTypeId() == TYPEID_PLAYER) && ((Player*)owner)->GetGroup()) + ((Player*)owner)->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_PET_CUR_POWER); + } + + // Update the pet's character sheet with happiness damage bonus + if(pet->getPetType() == HUNTER_PET && power == POWER_HAPPINESS) + { + pet->UpdateDamagePhysical(BASE_ATTACK); + } + } +} + +void Unit::SetMaxPower(Powers power, uint32 val) +{ + uint32 cur_power = GetPower(power); + SetStatInt32Value(UNIT_FIELD_MAXPOWER1 + power, val); + + // group update + if(GetTypeId() == TYPEID_PLAYER) + { + if(((Player*)this)->GetGroup()) + ((Player*)this)->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_MAX_POWER); + } + else if(((Creature*)this)->isPet()) + { + Pet *pet = ((Pet*)this); + if(pet->isControlled()) + { + Unit *owner = GetOwner(); + if(owner && (owner->GetTypeId() == TYPEID_PLAYER) && ((Player*)owner)->GetGroup()) + ((Player*)owner)->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_PET_MAX_POWER); + } + } + + if(val < cur_power) + SetPower(power, val); +} + +void Unit::ApplyPowerMod(Powers power, uint32 val, bool apply) +{ + ApplyModUInt32Value(UNIT_FIELD_POWER1+power, val, apply); + + // group update + if(GetTypeId() == TYPEID_PLAYER) + { + if(((Player*)this)->GetGroup()) + ((Player*)this)->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_CUR_POWER); + } + else if(((Creature*)this)->isPet()) + { + Pet *pet = ((Pet*)this); + if(pet->isControlled()) + { + Unit *owner = GetOwner(); + if(owner && (owner->GetTypeId() == TYPEID_PLAYER) && ((Player*)owner)->GetGroup()) + ((Player*)owner)->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_PET_CUR_POWER); + } + } +} + +void Unit::ApplyMaxPowerMod(Powers power, uint32 val, bool apply) +{ + ApplyModUInt32Value(UNIT_FIELD_MAXPOWER1+power, val, apply); + + // group update + if(GetTypeId() == TYPEID_PLAYER) + { + if(((Player*)this)->GetGroup()) + ((Player*)this)->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_MAX_POWER); + } + else if(((Creature*)this)->isPet()) + { + Pet *pet = ((Pet*)this); + if(pet->isControlled()) + { + Unit *owner = GetOwner(); + if(owner && (owner->GetTypeId() == TYPEID_PLAYER) && ((Player*)owner)->GetGroup()) + ((Player*)owner)->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_PET_MAX_POWER); + } + } +} + +void Unit::ApplyAuraProcTriggerDamage( Aura* aura, bool apply ) +{ + AuraList& tAuraProcTriggerDamage = m_modAuras[SPELL_AURA_PROC_TRIGGER_DAMAGE]; + if(apply) + tAuraProcTriggerDamage.push_back(aura); + else + tAuraProcTriggerDamage.remove(aura); +} + +uint32 Unit::GetCreatePowers( Powers power ) const +{ + // POWER_FOCUS and POWER_HAPPINESS only have hunter pet + switch(power) + { + case POWER_MANA: return GetCreateMana(); + case POWER_RAGE: return 1000; + case POWER_FOCUS: return (GetTypeId()==TYPEID_PLAYER || !((Creature const*)this)->isPet() || ((Pet const*)this)->getPetType()!=HUNTER_PET ? 0 : 100); + case POWER_ENERGY: return 100; + case POWER_HAPPINESS: return (GetTypeId()==TYPEID_PLAYER || !((Creature const*)this)->isPet() || ((Pet const*)this)->getPetType()!=HUNTER_PET ? 0 : 1050000); + } + + return 0; +} + +void Unit::AddToWorld() +{ + Object::AddToWorld(); +} + +void Unit::RemoveFromWorld() +{ + // cleanup + if(IsInWorld()) + { + RemoveNotOwnSingleTargetAuras(); + } + + Object::RemoveFromWorld(); +} + +void Unit::CleanupsBeforeDelete() +{ + if(m_uint32Values) // only for fully created object + { + InterruptNonMeleeSpells(true); + m_Events.KillAllEvents(); + CombatStop(); + ClearComboPointHolders(); + DeleteThreatList(); + getHostilRefManager().setOnlineOfflineState(false); + RemoveAllAuras(); + RemoveAllGameObjects(); + RemoveAllDynObjects(); + GetMotionMaster()->Clear(false); // remove different non-standard movement generators. + } + RemoveFromWorld(); +} + +CharmInfo* Unit::InitCharmInfo(Unit *charm) +{ + if(!m_charmInfo) + m_charmInfo = new CharmInfo(charm); + return m_charmInfo; +} + +CharmInfo::CharmInfo(Unit* unit) +: m_unit(unit), m_CommandState(COMMAND_FOLLOW), m_ReactSate(REACT_PASSIVE), m_petnumber(0) +{ + for(int i =0; i<4; ++i) + { + m_charmspells[i].spellId = 0; + m_charmspells[i].active = ACT_DISABLED; + } +} + +void CharmInfo::InitPetActionBar() +{ + // the first 3 SpellOrActions are attack, follow and stay + for(uint32 i = 0; i < 3; i++) + { + PetActionBar[i].Type = ACT_COMMAND; + PetActionBar[i].SpellOrAction = COMMAND_ATTACK - i; + + PetActionBar[i + 7].Type = ACT_REACTION; + PetActionBar[i + 7].SpellOrAction = COMMAND_ATTACK - i; + } + for(uint32 i=0; i < 4; i++) + { + PetActionBar[i + 3].Type = ACT_DISABLED; + PetActionBar[i + 3].SpellOrAction = 0; + } +} + +void CharmInfo::InitEmptyActionBar() +{ + for(uint32 x = 1; x < 10; ++x) + { + PetActionBar[x].Type = ACT_CAST; + PetActionBar[x].SpellOrAction = 0; + } + PetActionBar[0].Type = ACT_COMMAND; + PetActionBar[0].SpellOrAction = COMMAND_ATTACK; +} + +void CharmInfo::InitPossessCreateSpells() +{ + if(m_unit->GetTypeId() == TYPEID_PLAYER) + return; + + InitEmptyActionBar(); //charm action bar + + for(uint32 x = 0; x < CREATURE_MAX_SPELLS; ++x) + { + if (IsPassiveSpell(((Creature*)m_unit)->m_spells[x])) + m_unit->CastSpell(m_unit, ((Creature*)m_unit)->m_spells[x], true); + else + AddSpellToAB(0, ((Creature*)m_unit)->m_spells[x], ACT_CAST); + } +} + +void CharmInfo::InitCharmCreateSpells() +{ + if(m_unit->GetTypeId() == TYPEID_PLAYER) //charmed players don't have spells + { + InitEmptyActionBar(); + return; + } + + InitPetActionBar(); + + for(uint32 x = 0; x < CREATURE_MAX_SPELLS; ++x) + { + uint32 spellId = ((Creature*)m_unit)->m_spells[x]; + m_charmspells[x].spellId = spellId; + + if(!spellId) + continue; + + if (IsPassiveSpell(spellId)) + { + m_unit->CastSpell(m_unit, spellId, true); + m_charmspells[x].active = ACT_PASSIVE; + } + else + { + ActiveStates newstate; + bool onlyselfcast = true; + SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellId); + + if(!spellInfo) onlyselfcast = false; + for(uint32 i = 0;i<3 && onlyselfcast;++i) //non existent spell will not make any problems as onlyselfcast would be false -> break right away + { + if(spellInfo->EffectImplicitTargetA[i] != TARGET_SELF && spellInfo->EffectImplicitTargetA[i] != 0) + onlyselfcast = false; + } + + if(onlyselfcast || !IsPositiveSpell(spellId)) //only self cast and spells versus enemies are autocastable + newstate = ACT_DISABLED; + else + newstate = ACT_CAST; + + AddSpellToAB(0, spellId, newstate); + } + } +} + +bool CharmInfo::AddSpellToAB(uint32 oldid, uint32 newid, ActiveStates newstate) +{ + for(uint8 i = 0; i < 10; i++) + { + if((PetActionBar[i].Type == ACT_DISABLED || PetActionBar[i].Type == ACT_ENABLED || PetActionBar[i].Type == ACT_CAST) && PetActionBar[i].SpellOrAction == oldid) + { + PetActionBar[i].SpellOrAction = newid; + if(!oldid) + { + if(newstate == ACT_DECIDE) + PetActionBar[i].Type = ACT_DISABLED; + else + PetActionBar[i].Type = newstate; + } + + return true; + } + } + return false; +} + +void CharmInfo::ToggleCreatureAutocast(uint32 spellid, bool apply) +{ + if(IsPassiveSpell(spellid)) + return; + + for(uint32 x = 0; x < CREATURE_MAX_SPELLS; ++x) + { + if(spellid == m_charmspells[x].spellId) + { + m_charmspells[x].active = apply ? ACT_ENABLED : ACT_DISABLED; + } + } +} + +void CharmInfo::SetPetNumber(uint32 petnumber, bool statwindow) +{ + m_petnumber = petnumber; + if(statwindow) + m_unit->SetUInt32Value(UNIT_FIELD_PETNUMBER, m_petnumber); + else + m_unit->SetUInt32Value(UNIT_FIELD_PETNUMBER, 0); +} + +bool Unit::isFrozen() const +{ + AuraList const& mRoot = GetAurasByType(SPELL_AURA_MOD_ROOT); + for(AuraList::const_iterator i = mRoot.begin(); i != mRoot.end(); ++i) + if( GetSpellSchoolMask((*i)->GetSpellProto()) & SPELL_SCHOOL_MASK_FROST) + return true; + return false; +} + +struct ProcTriggeredData +{ + ProcTriggeredData(SpellEntry const * _spellInfo, uint32 _spellParam, Aura* _triggeredByAura, uint32 _cooldown) + : spellInfo(_spellInfo), spellParam(_spellParam), triggeredByAura(_triggeredByAura), + triggeredByAura_SpellPair(Unit::spellEffectPair(triggeredByAura->GetId(),triggeredByAura->GetEffIndex())), + cooldown(_cooldown) + {} + + SpellEntry const * spellInfo; + uint32 spellParam; + Aura* triggeredByAura; + Unit::spellEffectPair triggeredByAura_SpellPair; + uint32 cooldown; +}; + +typedef std::list< ProcTriggeredData > ProcTriggeredList; + +void Unit::ProcDamageAndSpellFor( bool isVictim, Unit * pTarget, uint32 procFlag, AuraTypeSet const& procAuraTypes, WeaponAttackType attType, SpellEntry const * procSpell, uint32 damage, SpellSchoolMask damageSchoolMask ) +{ + for(AuraTypeSet::const_iterator aur = procAuraTypes.begin(); aur != procAuraTypes.end(); ++aur) + { + // List of spells (effects) that proceed. Spell prototype and aura-specific value (damage for TRIGGER_DAMAGE) + ProcTriggeredList procTriggered; + + AuraList const& auras = GetAurasByType(*aur); + for(AuraList::const_iterator i = auras.begin(), next; i != auras.end(); i = next) + { + next = i; ++next; + + SpellEntry const *spellProto = (*i)->GetSpellProto(); + if(!spellProto) + continue; + + SpellProcEventEntry const *spellProcEvent = spellmgr.GetSpellProcEvent(spellProto->Id); + if(!spellProcEvent) + { + // used to prevent spam in log about same non-handled spells + static std::set nonHandledSpellProcSet; + + if(spellProto->procFlags != 0 && nonHandledSpellProcSet.find(spellProto->Id)==nonHandledSpellProcSet.end()) + { + sLog.outError("ProcDamageAndSpell: spell %u (%s aura source) not have record in `spell_proc_event`)",spellProto->Id,(isVictim?"a victim's":"an attacker's")); + nonHandledSpellProcSet.insert(spellProto->Id); + } + + // spell.dbc use totally different flags, that only can create problems if used. + continue; + } + + // Check spellProcEvent data requirements + if(!SpellMgr::IsSpellProcEventCanTriggeredBy(spellProcEvent, procSpell,procFlag)) + continue; + + // Check if current equipment allows aura to proc + if(!isVictim && GetTypeId() == TYPEID_PLAYER ) + { + if(spellProto->EquippedItemClass == ITEM_CLASS_WEAPON) + { + Item *item = ((Player*)this)->GetWeaponForAttack(attType,true); + + if(!item || !((1<GetProto()->SubClass) & spellProto->EquippedItemSubClassMask)) + continue; + } + else if(spellProto->EquippedItemClass == ITEM_CLASS_ARMOR) + { + // Check if player is wearing shield + Item *item = ((Player*)this)->GetShield(true); + if(!item || !((1<GetProto()->SubClass) & spellProto->EquippedItemSubClassMask)) + continue; + } + } + + float chance = (float)spellProto->procChance; + + if(Player* modOwner = GetSpellModOwner()) + modOwner->ApplySpellMod(spellProto->Id,SPELLMOD_CHANCE_OF_SUCCESS,chance); + + if(!isVictim && spellProcEvent->ppmRate != 0) + { + uint32 WeaponSpeed = GetAttackTime(attType); + chance = GetPPMProcChance(WeaponSpeed, spellProcEvent->ppmRate); + } + + if(roll_chance_f(chance)) + { + uint32 cooldown = spellProcEvent->cooldown; + + uint32 i_spell_eff = (*i)->GetEffIndex(); + + int32 i_spell_param; + switch(*aur) + { + case SPELL_AURA_PROC_TRIGGER_SPELL: + i_spell_param = procFlag; + break; + case SPELL_AURA_DUMMY: + case SPELL_AURA_PRAYER_OF_MENDING: + case SPELL_AURA_MOD_HASTE: + i_spell_param = i_spell_eff; + break; + case SPELL_AURA_OVERRIDE_CLASS_SCRIPTS: + i_spell_param = (*i)->GetModifier()->m_miscvalue; + break; + default: + i_spell_param = (*i)->GetModifier()->m_amount; + break; + } + + procTriggered.push_back( ProcTriggeredData(spellProto,i_spell_param,*i, cooldown) ); + } + } + + // Handle effects proceed this time + for(ProcTriggeredList::iterator i = procTriggered.begin(); i != procTriggered.end(); ++i) + { + // Some auras can be deleted in function called in this loop (except first, ofc) + // Until storing auras in std::multimap to hard check deleting by another way + if(i != procTriggered.begin()) + { + bool found = false; + AuraMap::const_iterator lower = GetAuras().lower_bound(i->triggeredByAura_SpellPair); + AuraMap::const_iterator upper = GetAuras().upper_bound(i->triggeredByAura_SpellPair); + for(AuraMap::const_iterator itr = lower; itr!= upper; ++itr) + { + if(itr->second==i->triggeredByAura) + { + found = true; + break; + } + } + + if(!found) + { + sLog.outError("Spell aura %u (id:%u effect:%u) has been deleted before call spell proc event handler",*aur,i->triggeredByAura_SpellPair.first,i->triggeredByAura_SpellPair.second); + sLog.outError("It can be deleted one from early proccesed auras:"); + for(ProcTriggeredList::iterator i2 = procTriggered.begin(); i != i2; ++i2) + sLog.outError(" Spell aura %u (id:%u effect:%u)",*aur,i2->triggeredByAura_SpellPair.first,i2->triggeredByAura_SpellPair.second); + sLog.outError(" "); + continue; + } + } + + // save charges existence before processing to prevent crash at access to deleted triggered aura after + bool triggeredByAuraWithCharges = i->triggeredByAura->m_procCharges > 0; + + bool casted = false; + switch(*aur) + { + case SPELL_AURA_PROC_TRIGGER_SPELL: + { + sLog.outDebug("ProcDamageAndSpell: casting spell %u (triggered by %s aura of spell %u)", i->spellInfo->Id,(isVictim?"a victim's":"an attacker's"),i->triggeredByAura->GetId()); + casted = HandleProcTriggerSpell(pTarget, damage, i->triggeredByAura, procSpell,i->spellParam,attType,i->cooldown); + break; + } + case SPELL_AURA_PROC_TRIGGER_DAMAGE: + { + sLog.outDebug("ProcDamageAndSpell: doing %u damage from spell id %u (triggered by %s aura of spell %u)", i->spellParam, i->spellInfo->Id,(isVictim?"a victim's":"an attacker's"),i->triggeredByAura->GetId()); + uint32 damage = i->spellParam; + SpellNonMeleeDamageLog(pTarget, i->spellInfo->Id, damage, true, true); + casted = true; + break; + } + case SPELL_AURA_DUMMY: + { + sLog.outDebug("ProcDamageAndSpell: casting spell id %u (triggered by %s dummy aura of spell %u)", i->spellInfo->Id,(isVictim?"a victim's":"an attacker's"),i->triggeredByAura->GetId()); + casted = HandleDummyAuraProc(pTarget, i->spellInfo, i->spellParam, damage, i->triggeredByAura, procSpell, procFlag,i->cooldown); + break; + } + case SPELL_AURA_PRAYER_OF_MENDING: + { + sLog.outDebug("ProcDamageAndSpell(mending): casting spell id %u (triggered by %s dummy aura of spell %u)", i->spellInfo->Id,(isVictim?"a victim's":"an attacker's"),i->triggeredByAura->GetId()); + + // aura can be deleted at casts + int32 heal = i->triggeredByAura->GetModifier()->m_amount; + uint64 caster_guid = i->triggeredByAura->GetCasterGUID(); + + // jumps + int32 jumps = i->triggeredByAura->m_procCharges-1; + + // current aura expire + i->triggeredByAura->m_procCharges = 1; // will removed at next charges decrease + + // next target selection + if(jumps > 0 && GetTypeId()==TYPEID_PLAYER && IS_PLAYER_GUID(caster_guid)) + { + Aura* aura = i->triggeredByAura; + + SpellEntry const* spellProto = aura->GetSpellProto(); + uint32 effIdx = aura->GetEffIndex(); + + float radius; + if (spellProto->EffectRadiusIndex[effIdx]) + radius = GetSpellRadius(sSpellRadiusStore.LookupEntry(spellProto->EffectRadiusIndex[effIdx])); + else + radius = GetSpellMaxRange(sSpellRangeStore.LookupEntry(spellProto->rangeIndex)); + + if(Player* caster = ((Player*)aura->GetCaster())) + { + caster->ApplySpellMod(spellProto->Id, SPELLMOD_RADIUS, radius,NULL); + + if(Player* target = ((Player*)this)->GetNextRandomRaidMember(radius)) + { + // aura will applied from caster, but spell casted from current aura holder + SpellModifier *mod = new SpellModifier; + mod->op = SPELLMOD_CHARGES; + mod->value = jumps-5; // negative + mod->type = SPELLMOD_FLAT; + mod->spellId = spellProto->Id; + mod->effectId = effIdx; + mod->lastAffected = NULL; + mod->mask = spellProto->SpellFamilyFlags; + mod->charges = 0; + + caster->AddSpellMod(mod, true); + CastCustomSpell(target,spellProto->Id,&heal,NULL,NULL,true,NULL,aura,caster->GetGUID()); + caster->AddSpellMod(mod, false); + } + } + } + + // heal + CastCustomSpell(this,33110,&heal,NULL,NULL,true,NULL,NULL,caster_guid); + casted = true; + break; + } + case SPELL_AURA_MOD_HASTE: + { + sLog.outDebug("ProcDamageAndSpell: casting spell id %u (triggered by %s haste aura of spell %u)", i->spellInfo->Id,(isVictim?"a victim's":"an attacker's"),i->triggeredByAura->GetId()); + casted = HandleHasteAuraProc(pTarget, i->spellInfo, i->spellParam, damage, i->triggeredByAura, procSpell, procFlag,i->cooldown); + break; + } + case SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN: + { + // nothing do, just charges counter + // but count only in case appropriate school damage + casted = i->triggeredByAura->GetModifier()->m_miscvalue & damageSchoolMask; + break; + } + case SPELL_AURA_OVERRIDE_CLASS_SCRIPTS: + { + sLog.outDebug("ProcDamageAndSpell: casting spell id %u (triggered by %s aura of spell %u)", i->spellInfo->Id,(isVictim?"a victim's":"an attacker's"),i->triggeredByAura->GetId()); + casted = HandleOverrideClassScriptAuraProc(pTarget, i->spellParam, damage, i->triggeredByAura, procSpell,i->cooldown); + break; + } + default: + { + // nothing do, just charges counter + casted = true; + break; + } + } + + // Update charge (aura can be removed by triggers) + if(casted && triggeredByAuraWithCharges) + { + // need found aura (can be dropped by triggers) + AuraMap::const_iterator lower = GetAuras().lower_bound(i->triggeredByAura_SpellPair); + AuraMap::const_iterator upper = GetAuras().upper_bound(i->triggeredByAura_SpellPair); + for(AuraMap::const_iterator itr = lower; itr!= upper; ++itr) + { + if(itr->second == i->triggeredByAura) + { + if(i->triggeredByAura->m_procCharges > 0) + i->triggeredByAura->m_procCharges -= 1; + + i->triggeredByAura->UpdateAuraCharges(); + break; + } + } + } + } + + // Safely remove auras with zero charges + for(AuraList::const_iterator i = auras.begin(), next; i != auras.end(); i = next) + { + next = i; ++next; + if((*i)->m_procCharges == 0) + { + RemoveAurasDueToSpell((*i)->GetId()); + next = auras.begin(); + } + } + } +} + +SpellSchoolMask Unit::GetMeleeDamageSchoolMask() const +{ + return SPELL_SCHOOL_MASK_NORMAL; +} + +Player* Unit::GetSpellModOwner() +{ + if(GetTypeId()==TYPEID_PLAYER) + return (Player*)this; + if(((Creature*)this)->isPet() || ((Creature*)this)->isTotem()) + { + Unit* owner = GetOwner(); + if(owner && owner->GetTypeId()==TYPEID_PLAYER) + return (Player*)owner; + } + return NULL; +} + +///----------Pet responses methods----------------- +void Unit::SendPetCastFail(uint32 spellid, uint8 msg) +{ + Unit *owner = GetCharmerOrOwner(); + if(!owner || owner->GetTypeId() != TYPEID_PLAYER) + return; + + WorldPacket data(SMSG_PET_CAST_FAILED, (4+1)); + data << uint32(spellid); + data << uint8(msg); + ((Player*)owner)->GetSession()->SendPacket(&data); +} + +void Unit::SendPetActionFeedback (uint8 msg) +{ + Unit* owner = GetOwner(); + if(!owner || owner->GetTypeId() != TYPEID_PLAYER) + return; + + WorldPacket data(SMSG_PET_ACTION_FEEDBACK, 1); + data << uint8(msg); + ((Player*)owner)->GetSession()->SendPacket(&data); +} + +void Unit::SendPetTalk (uint32 pettalk) +{ + Unit* owner = GetOwner(); + if(!owner || owner->GetTypeId() != TYPEID_PLAYER) + return; + + WorldPacket data(SMSG_PET_ACTION_SOUND, 8+4); + data << uint64(GetGUID()); + data << uint32(pettalk); + ((Player*)owner)->GetSession()->SendPacket(&data); +} + +void Unit::SendPetSpellCooldown (uint32 spellid, time_t cooltime) +{ + Unit* owner = GetOwner(); + if(!owner || owner->GetTypeId() != TYPEID_PLAYER) + return; + + WorldPacket data(SMSG_SPELL_COOLDOWN, 8+1+4+4); + data << uint64(GetGUID()); + data << uint8(0x0); + data << uint32(spellid); + data << uint32(cooltime); + + ((Player*)owner)->GetSession()->SendPacket(&data); +} + +void Unit::SendPetClearCooldown (uint32 spellid) +{ + Unit* owner = GetOwner(); + if(!owner || owner->GetTypeId() != TYPEID_PLAYER) + return; + + WorldPacket data(SMSG_CLEAR_COOLDOWN, (4+8)); + data << uint32(spellid); + data << uint64(GetGUID()); + ((Player*)owner)->GetSession()->SendPacket(&data); +} + +void Unit::SendPetAIReaction(uint64 guid) +{ + Unit* owner = GetOwner(); + if(!owner || owner->GetTypeId() != TYPEID_PLAYER) + return; + + WorldPacket data(SMSG_AI_REACTION, 12); + data << uint64(guid) << uint32(00000002); + ((Player*)owner)->GetSession()->SendPacket(&data); +} + +///----------End of Pet responses methods---------- + +void Unit::StopMoving() +{ + clearUnitState(UNIT_STAT_MOVING); + + // send explicit stop packet + // rely on vmaps here because for exemple stormwind is in air + float z = MapManager::Instance().GetBaseMap(GetMapId())->GetHeight(GetPositionX(), GetPositionY(), GetPositionZ(), true); + //if (fabs(GetPositionZ() - z) < 2.0f) + // Relocate(GetPositionX(), GetPositionY(), z); + Relocate(GetPositionX(), GetPositionY(),GetPositionZ()); + + SendMonsterMove(GetPositionX(), GetPositionY(), GetPositionZ(), 0, true, 0); + + // update position and orientation; + WorldPacket data; + BuildHeartBeatMsg(&data); + SendMessageToSet(&data,false); +} + +void Unit::SetFeared(bool apply, uint64 casterGUID, uint32 spellID) +{ + if( apply ) + { + if(HasAuraType(SPELL_AURA_PREVENTS_FLEEING)) + return; + + SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_FLEEING); + + GetMotionMaster()->MovementExpired(false); + CastStop(GetGUID()==casterGUID ? spellID : 0); + + Unit* caster = ObjectAccessor::GetUnit(*this,casterGUID); + + GetMotionMaster()->MoveFleeing(caster); // caster==NULL processed in MoveFleeing + } + else + { + RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_FLEEING); + + GetMotionMaster()->MovementExpired(false); + + if( GetTypeId() != TYPEID_PLAYER && isAlive() ) + { + // restore appropriate movement generator + if(getVictim()) + GetMotionMaster()->MoveChase(getVictim()); + else + GetMotionMaster()->Initialize(); + + // attack caster if can + Unit* caster = ObjectAccessor::GetObjectInWorld(casterGUID, (Unit*)NULL); + if(caster && caster != getVictim() && ((Creature*)this)->AI()) + ((Creature*)this)->AI()->AttackStart(caster); + } + } + + if (GetTypeId() == TYPEID_PLAYER) + ((Player*)this)->SetClientControl(this, !apply); +} + +void Unit::SetConfused(bool apply, uint64 casterGUID, uint32 spellID) +{ + if( apply ) + { + SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_CONFUSED); + + CastStop(GetGUID()==casterGUID ? spellID : 0); + + GetMotionMaster()->MoveConfused(); + } + else + { + RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_CONFUSED); + + GetMotionMaster()->MovementExpired(false); + + if (GetTypeId() == TYPEID_UNIT) + { + // if in combat restore movement generator + if(getVictim()) + GetMotionMaster()->MoveChase(getVictim()); + } + } + + if(GetTypeId() == TYPEID_PLAYER) + ((Player*)this)->SetClientControl(this, !apply); +} + +bool Unit::IsSitState() const +{ + uint8 s = getStandState(); + return s == PLAYER_STATE_SIT_CHAIR || s == PLAYER_STATE_SIT_LOW_CHAIR || + s == PLAYER_STATE_SIT_MEDIUM_CHAIR || s == PLAYER_STATE_SIT_HIGH_CHAIR || + s == PLAYER_STATE_SIT; +} + +bool Unit::IsStandState() const +{ + uint8 s = getStandState(); + return !IsSitState() && s != PLAYER_STATE_SLEEP && s != PLAYER_STATE_KNEEL; +} + +void Unit::SetStandState(uint8 state) +{ + SetByteValue(UNIT_FIELD_BYTES_1, 0, state); + + if (IsStandState()) + RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_NOT_SEATED); + + if(GetTypeId()==TYPEID_PLAYER) + { + WorldPacket data(SMSG_STANDSTATE_UPDATE, 1); + data << (uint8)state; + ((Player*)this)->GetSession()->SendPacket(&data); + } +} + +bool Unit::IsPolymorphed() const +{ + return GetSpellSpecific(getTransForm())==SPELL_MAGE_POLYMORPH; +} + +void Unit::SetDisplayId(uint32 modelId) +{ + SetUInt32Value(UNIT_FIELD_DISPLAYID, modelId); + + if(GetTypeId() == TYPEID_UNIT && ((Creature*)this)->isPet()) + { + Pet *pet = ((Pet*)this); + if(!pet->isControlled()) + return; + Unit *owner = GetOwner(); + if(owner && (owner->GetTypeId() == TYPEID_PLAYER) && ((Player*)owner)->GetGroup()) + ((Player*)owner)->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_PET_MODEL_ID); + } +} + +void Unit::ClearComboPointHolders() +{ + while(!m_ComboPointHolders.empty()) + { + uint32 lowguid = *m_ComboPointHolders.begin(); + + Player* plr = objmgr.GetPlayer(MAKE_NEW_GUID(lowguid, 0, HIGHGUID_PLAYER)); + if(plr && plr->GetComboTarget()==GetGUID()) // recheck for safe + plr->ClearComboPoints(); // remove also guid from m_ComboPointHolders; + else + m_ComboPointHolders.erase(lowguid); // or remove manually + } +} + +void Unit::ClearAllReactives() +{ + + for(int i=0; i < MAX_REACTIVE; ++i) + m_reactiveTimer[i] = 0; + + if (HasAuraState( AURA_STATE_DEFENSE)) + ModifyAuraState(AURA_STATE_DEFENSE, false); + if (getClass() == CLASS_HUNTER && HasAuraState( AURA_STATE_HUNTER_PARRY)) + ModifyAuraState(AURA_STATE_HUNTER_PARRY, false); + if (HasAuraState( AURA_STATE_CRIT)) + ModifyAuraState(AURA_STATE_CRIT, false); + if (getClass() == CLASS_HUNTER && HasAuraState( AURA_STATE_HUNTER_CRIT_STRIKE) ) + ModifyAuraState(AURA_STATE_HUNTER_CRIT_STRIKE, false); + + if(getClass() == CLASS_WARRIOR && GetTypeId() == TYPEID_PLAYER) + ((Player*)this)->ClearComboPoints(); +} + +void Unit::UpdateReactives( uint32 p_time ) +{ + for(int i = 0; i < MAX_REACTIVE; ++i) + { + ReactiveType reactive = ReactiveType(i); + + if(!m_reactiveTimer[reactive]) + continue; + + if ( m_reactiveTimer[reactive] <= p_time) + { + m_reactiveTimer[reactive] = 0; + + switch ( reactive ) + { + case REACTIVE_DEFENSE: + if (HasAuraState(AURA_STATE_DEFENSE)) + ModifyAuraState(AURA_STATE_DEFENSE, false); + break; + case REACTIVE_HUNTER_PARRY: + if ( getClass() == CLASS_HUNTER && HasAuraState(AURA_STATE_HUNTER_PARRY)) + ModifyAuraState(AURA_STATE_HUNTER_PARRY, false); + break; + case REACTIVE_CRIT: + if (HasAuraState(AURA_STATE_CRIT)) + ModifyAuraState(AURA_STATE_CRIT, false); + break; + case REACTIVE_HUNTER_CRIT: + if ( getClass() == CLASS_HUNTER && HasAuraState(AURA_STATE_HUNTER_CRIT_STRIKE) ) + ModifyAuraState(AURA_STATE_HUNTER_CRIT_STRIKE, false); + break; + case REACTIVE_OVERPOWER: + if(getClass() == CLASS_WARRIOR && GetTypeId() == TYPEID_PLAYER) + ((Player*)this)->ClearComboPoints(); + break; + default: + break; + } + } + else + { + m_reactiveTimer[reactive] -= p_time; + } + } +} + +Unit* Unit::SelectNearbyTarget() const +{ + CellPair p(MaNGOS::ComputeCellPair(GetPositionX(), GetPositionY())); + Cell cell(p); + cell.data.Part.reserved = ALL_DISTRICT; + cell.SetNoCreate(); + + std::list targets; + + { + MaNGOS::AnyUnfriendlyUnitInObjectRangeCheck u_check(this, this, ATTACK_DISTANCE); + MaNGOS::UnitListSearcher searcher(targets, u_check); + + TypeContainerVisitor, WorldTypeMapContainer > world_unit_searcher(searcher); + TypeContainerVisitor, GridTypeMapContainer > grid_unit_searcher(searcher); + + CellLock cell_lock(cell, p); + cell_lock->Visit(cell_lock, world_unit_searcher, *MapManager::Instance().GetMap(GetMapId(), this)); + cell_lock->Visit(cell_lock, grid_unit_searcher, *MapManager::Instance().GetMap(GetMapId(), this)); + } + + // remove current target + if(getVictim()) + targets.remove(getVictim()); + + // remove not LoS targets + for(std::list::iterator tIter = targets.begin(); tIter != targets.end();) + { + if(!IsWithinLOSInMap(*tIter)) + { + std::list::iterator tIter2 = tIter; + ++tIter; + targets.erase(tIter2); + } + else + ++tIter; + } + + // no appropriate targets + if(targets.empty()) + return NULL; + + // select random + uint32 rIdx = urand(0,targets.size()-1); + std::list::const_iterator tcIter = targets.begin(); + for(uint32 i = 0; i < rIdx; ++i) + ++tcIter; + + return *tcIter; +} + +void Unit::ApplyAttackTimePercentMod( WeaponAttackType att,float val, bool apply ) +{ + if(val > 0) + { + ApplyPercentModFloatVar(m_modAttackSpeedPct[att], val, !apply); + ApplyPercentModFloatValue(UNIT_FIELD_BASEATTACKTIME+att,val,!apply); + } + else + { + ApplyPercentModFloatVar(m_modAttackSpeedPct[att], -val, apply); + ApplyPercentModFloatValue(UNIT_FIELD_BASEATTACKTIME+att,-val,apply); + } +} + +void Unit::ApplyCastTimePercentMod(float val, bool apply ) +{ + if(val > 0) + ApplyPercentModFloatValue(UNIT_MOD_CAST_SPEED,val,!apply); + else + ApplyPercentModFloatValue(UNIT_MOD_CAST_SPEED,-val,apply); +} + +uint32 Unit::GetCastingTimeForBonus( SpellEntry const *spellProto, DamageEffectType damagetype, uint32 CastingTime ) +{ + if (CastingTime > 7000) CastingTime = 7000; + if (CastingTime < 1500) CastingTime = 1500; + + if(damagetype == DOT && !IsChanneledSpell(spellProto)) + CastingTime = 3500; + + int32 overTime = 0; + uint8 effects = 0; + bool DirectDamage = false; + bool AreaEffect = false; + + for ( uint32 i=0; i<3;i++) + { + switch ( spellProto->Effect[i] ) + { + case SPELL_EFFECT_SCHOOL_DAMAGE: + case SPELL_EFFECT_POWER_DRAIN: + case SPELL_EFFECT_HEALTH_LEECH: + case SPELL_EFFECT_ENVIRONMENTAL_DAMAGE: + case SPELL_EFFECT_POWER_BURN: + case SPELL_EFFECT_HEAL: + DirectDamage = true; + break; + case SPELL_EFFECT_APPLY_AURA: + switch ( spellProto->EffectApplyAuraName[i] ) + { + case SPELL_AURA_PERIODIC_DAMAGE: + case SPELL_AURA_PERIODIC_HEAL: + case SPELL_AURA_PERIODIC_LEECH: + if ( GetSpellDuration(spellProto) ) + overTime = GetSpellDuration(spellProto); + break; + default: + // -5% per additional effect + ++effects; + break; + } + default: + break; + } + + if(IsAreaEffectTarget(Targets(spellProto->EffectImplicitTargetA[i])) || IsAreaEffectTarget(Targets(spellProto->EffectImplicitTargetB[i]))) + AreaEffect = true; + } + + // Combined Spells with Both Over Time and Direct Damage + if ( overTime > 0 && CastingTime > 0 && DirectDamage ) + { + // mainly for DoTs which are 3500 here otherwise + uint32 OriginalCastTime = GetSpellCastTime(spellProto); + if (OriginalCastTime > 7000) OriginalCastTime = 7000; + if (OriginalCastTime < 1500) OriginalCastTime = 1500; + // Portion to Over Time + float PtOT = (overTime / 15000.f) / ((overTime / 15000.f) + (OriginalCastTime / 3500.f)); + + if ( damagetype == DOT ) + CastingTime = uint32(CastingTime * PtOT); + else if ( PtOT < 1.0f ) + CastingTime = uint32(CastingTime * (1 - PtOT)); + else + CastingTime = 0; + } + + // Area Effect Spells receive only half of bonus + if ( AreaEffect ) + CastingTime /= 2; + + // -5% of total per any additional effect + for ( uint8 i=0; i 175 ) + { + CastingTime -= 175; + } + else + { + CastingTime = 0; + break; + } + } + + return CastingTime; +} + +void Unit::UpdateAuraForGroup(uint8 slot) +{ + if(GetTypeId() == TYPEID_PLAYER) + { + Player* player = (Player*)this; + if(player->GetGroup()) + { + player->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_AURAS); + player->SetAuraUpdateMask(slot); + } + } + else if(GetTypeId() == TYPEID_UNIT && ((Creature*)this)->isPet()) + { + Pet *pet = ((Pet*)this); + if(pet->isControlled()) + { + Unit *owner = GetOwner(); + if(owner && (owner->GetTypeId() == TYPEID_PLAYER) && ((Player*)owner)->GetGroup()) + { + ((Player*)owner)->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_PET_AURAS); + pet->SetAuraUpdateMask(slot); + } + } + } +} + +float Unit::GetAPMultiplier(WeaponAttackType attType, bool normalized) +{ + if (!normalized || GetTypeId() != TYPEID_PLAYER) + return float(GetAttackTime(attType))/1000.0f; + + Item *Weapon = ((Player*)this)->GetWeaponForAttack(attType); + if (!Weapon) + return 2.4; // fist attack + + switch (Weapon->GetProto()->InventoryType) + { + case INVTYPE_2HWEAPON: + return 3.3; + case INVTYPE_RANGED: + case INVTYPE_RANGEDRIGHT: + case INVTYPE_THROWN: + return 2.8; + case INVTYPE_WEAPON: + case INVTYPE_WEAPONMAINHAND: + case INVTYPE_WEAPONOFFHAND: + default: + return Weapon->GetProto()->SubClass==ITEM_SUBCLASS_WEAPON_DAGGER ? 1.7 : 2.4; + } +} + +Aura* Unit::GetDummyAura( uint32 spell_id ) const +{ + Unit::AuraList const& mDummy = GetAurasByType(SPELL_AURA_DUMMY); + for(Unit::AuraList::const_iterator itr = mDummy.begin(); itr != mDummy.end(); ++itr) + if ((*itr)->GetId() == spell_id) + return *itr; + + return NULL; +} + +bool Unit::IsUnderLastManaUseEffect() const +{ + return getMSTimeDiff(m_lastManaUse,getMSTime()) < 5000; +} + +void Unit::SetContestedPvP(Player *attackedPlayer) +{ + Player* player = GetCharmerOrOwnerPlayerOrPlayerItself(); + + if(!player || attackedPlayer && (attackedPlayer == player || player->duel && player->duel->opponent == attackedPlayer)) + return; + + player->SetContestedPvPTimer(30000); + if(!player->hasUnitState(UNIT_STAT_ATTACK_PLAYER)) + { + player->addUnitState(UNIT_STAT_ATTACK_PLAYER); + player->SetFlag(PLAYER_FLAGS, PLAYER_FLAGS_CONTESTED_PVP); + // call MoveInLineOfSight for nearby contested guards + SetVisibility(GetVisibility()); + } + if(!hasUnitState(UNIT_STAT_ATTACK_PLAYER)) + { + addUnitState(UNIT_STAT_ATTACK_PLAYER); + // call MoveInLineOfSight for nearby contested guards + SetVisibility(GetVisibility()); + } +} + +void Unit::AddPetAura(PetAura const* petSpell) +{ + m_petAuras.insert(petSpell); + if(Pet* pet = GetPet()) + pet->CastPetAura(petSpell); +} + +void Unit::RemovePetAura(PetAura const* petSpell) +{ + m_petAuras.erase(petSpell); + if(Pet* pet = GetPet()) + pet->RemoveAurasDueToSpell(petSpell->GetAura(pet->GetEntry())); +} diff --git a/src/game/Unit.h b/src/game/Unit.h index b16b5e9ab2d..be35c13a9d3 100644 --- a/src/game/Unit.h +++ b/src/game/Unit.h @@ -1,1331 +1,1336 @@ -/* - * Copyright (C) 2005-2008 MaNGOS - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef __UNIT_H -#define __UNIT_H - -#include "Common.h" -#include "Object.h" -#include "Opcodes.h" -#include "Mthread.h" -#include "SpellAuraDefines.h" -#include "UpdateFields.h" -#include "SharedDefines.h" -#include "ThreatManager.h" -#include "HostilRefManager.h" -#include "FollowerReference.h" -#include "FollowerRefManager.h" -#include "Utilities/EventProcessor.h" -#include "MotionMaster.h" -#include "Database/DBCStructure.h" -#include - -enum SpellInterruptFlags -{ - SPELL_INTERRUPT_FLAG_MOVEMENT = 0x01, - SPELL_INTERRUPT_FLAG_DAMAGE = 0x02, - SPELL_INTERRUPT_FLAG_INTERRUPT = 0x04, - SPELL_INTERRUPT_FLAG_AUTOATTACK = 0x08, - //SPELL_INTERRUPT_FLAG_TURNING = 0x10 // not turning - maybe _complete_ interrupt on direct damage? -}; - -enum SpellChannelInterruptFlags -{ - CHANNEL_FLAG_DAMAGE = 0x0002, - CHANNEL_FLAG_MOVEMENT = 0x0008, - CHANNEL_FLAG_TURNING = 0x0010, - CHANNEL_FLAG_DAMAGE2 = 0x0080, - CHANNEL_FLAG_DELAY = 0x4000 -}; - -enum SpellAuraInterruptFlags -{ - AURA_INTERRUPT_FLAG_UNK0 = 0x00000001, // 0 removed when getting hit by a negative spell? - AURA_INTERRUPT_FLAG_DAMAGE = 0x00000002, // 1 removed by any damage - AURA_INTERRUPT_FLAG_UNK2 = 0x00000004, // 2 - AURA_INTERRUPT_FLAG_MOVE = 0x00000008, // 3 removed by any movement - AURA_INTERRUPT_FLAG_TURNING = 0x00000010, // 4 removed by any turning - AURA_INTERRUPT_FLAG_ENTER_COMBAT = 0x00000020, // 5 removed by entering combat - AURA_INTERRUPT_FLAG_NOT_MOUNTED = 0x00000040, // 6 removed by unmounting - AURA_INTERRUPT_FLAG_NOT_ABOVEWATER = 0x00000080, // 7 removed by entering water - AURA_INTERRUPT_FLAG_NOT_UNDERWATER = 0x00000100, // 8 removed by leaving water - AURA_INTERRUPT_FLAG_NOT_SHEATHED = 0x00000200, // 9 removed by unsheathing - AURA_INTERRUPT_FLAG_UNK10 = 0x00000400, // 10 - AURA_INTERRUPT_FLAG_UNK11 = 0x00000800, // 11 - AURA_INTERRUPT_FLAG_UNK12 = 0x00001000, // 12 removed by attack? - AURA_INTERRUPT_FLAG_UNK13 = 0x00002000, // 13 - AURA_INTERRUPT_FLAG_UNK14 = 0x00004000, // 14 - AURA_INTERRUPT_FLAG_UNK15 = 0x00008000, // 15 removed by casting a spell? - AURA_INTERRUPT_FLAG_UNK16 = 0x00010000, // 16 - AURA_INTERRUPT_FLAG_MOUNTING = 0x00020000, // 17 removed by mounting - AURA_INTERRUPT_FLAG_NOT_SEATED = 0x00040000, // 18 removed by standing up - AURA_INTERRUPT_FLAG_CHANGE_MAP = 0x00080000, // 19 leaving map/getting teleported - AURA_INTERRUPT_FLAG_UNK20 = 0x00100000, // 20 - AURA_INTERRUPT_FLAG_UNK21 = 0x00200000, // 21 - AURA_INTERRUPT_FLAG_UNK22 = 0x00400000, // 22 - AURA_INTERRUPT_FLAG_ENTER_PVP_COMBAT = 0x00800000, // 23 removed by entering pvp combat - AURA_INTERRUPT_FLAG_DIRECT_DAMAGE = 0x01000000 // 24 removed by any direct damage -}; - -enum SpellModOp -{ - SPELLMOD_DAMAGE = 0, - SPELLMOD_DURATION = 1, - SPELLMOD_THREAT = 2, - SPELLMOD_EFFECT1 = 3, - SPELLMOD_CHARGES = 4, - SPELLMOD_RANGE = 5, - SPELLMOD_RADIUS = 6, - SPELLMOD_CRITICAL_CHANCE = 7, - SPELLMOD_ALL_EFFECTS = 8, - SPELLMOD_NOT_LOSE_CASTING_TIME = 9, - SPELLMOD_CASTING_TIME = 10, - SPELLMOD_COOLDOWN = 11, - SPELLMOD_EFFECT2 = 12, - // spellmod 13 unused - SPELLMOD_COST = 14, - SPELLMOD_CRIT_DAMAGE_BONUS = 15, - SPELLMOD_RESIST_MISS_CHANCE = 16, - SPELLMOD_JUMP_TARGETS = 17, - SPELLMOD_CHANCE_OF_SUCCESS = 18, - SPELLMOD_ACTIVATION_TIME = 19, - SPELLMOD_EFFECT_PAST_FIRST = 20, - SPELLMOD_CASTING_TIME_OLD = 21, - SPELLMOD_DOT = 22, - SPELLMOD_EFFECT3 = 23, - SPELLMOD_SPELL_BONUS_DAMAGE = 24, - // spellmod 25, 26 unused - SPELLMOD_MULTIPLE_VALUE = 27, - SPELLMOD_RESIST_DISPEL_CHANCE = 28 -}; - -#define MAX_SPELLMOD 32 - -#define BASE_MINDAMAGE 1.0f -#define BASE_MAXDAMAGE 2.0f -#define BASE_ATTACK_TIME 2000 - -// high byte (3 from 0..3) of UNIT_FIELD_BYTES_2 -enum ShapeshiftForm -{ - FORM_NONE = 0x00, - FORM_CAT = 0x01, - FORM_TREE = 0x02, - FORM_TRAVEL = 0x03, - FORM_AQUA = 0x04, - FORM_BEAR = 0x05, - FORM_AMBIENT = 0x06, - FORM_GHOUL = 0x07, - FORM_DIREBEAR = 0x08, - FORM_CREATUREBEAR = 0x0E, - FORM_CREATURECAT = 0x0F, - FORM_GHOSTWOLF = 0x10, - FORM_BATTLESTANCE = 0x11, - FORM_DEFENSIVESTANCE = 0x12, - FORM_BERSERKERSTANCE = 0x13, - FORM_TEST = 0x14, - FORM_ZOMBIE = 0x15, - FORM_FLIGHT_EPIC = 0x1B, - FORM_SHADOW = 0x1C, - FORM_FLIGHT = 0x1D, - FORM_STEALTH = 0x1E, - FORM_MOONKIN = 0x1F, - FORM_SPIRITOFREDEMPTION = 0x20 -}; - -// low byte ( 0 from 0..3 ) of UNIT_FIELD_BYTES_2 -enum SheathState -{ - SHEATH_STATE_UNARMED = 0, // non prepared weapon - SHEATH_STATE_MELEE = 1, // prepared melee weapon - SHEATH_STATE_RANGED = 2 // prepared ranged weapon -}; - -// byte (1 from 0..3) of UNIT_FIELD_BYTES_2 -enum UnitBytes2_Flags -{ - UNIT_BYTE2_FLAG_UNK0 = 0x01, - UNIT_BYTE2_FLAG_UNK1 = 0x02, - UNIT_BYTE2_FLAG_UNK2 = 0x04, - UNIT_BYTE2_FLAG_UNK3 = 0x08, - UNIT_BYTE2_FLAG_AURAS = 0x10, // show possitive auras as positive, and allow its dispel - UNIT_BYTE2_FLAG_UNK5 = 0x20, - UNIT_BYTE2_FLAG_UNK6 = 0x40, - UNIT_BYTE2_FLAG_UNK7 = 0x80 -}; - -// byte (2 from 0..3) of UNIT_FIELD_BYTES_2 -enum UnitRename -{ - UNIT_RENAME_NOT_ALLOWED = 0x02, - UNIT_RENAME_ALLOWED = 0x03 -}; - -#define CREATURE_MAX_SPELLS 4 - -enum Swing -{ - NOSWING = 0, - SINGLEHANDEDSWING = 1, - TWOHANDEDSWING = 2 -}; - -enum VictimState -{ - VICTIMSTATE_UNKNOWN1 = 0, - VICTIMSTATE_NORMAL = 1, - VICTIMSTATE_DODGE = 2, - VICTIMSTATE_PARRY = 3, - VICTIMSTATE_INTERRUPT = 4, - VICTIMSTATE_BLOCKS = 5, - VICTIMSTATE_EVADES = 6, - VICTIMSTATE_IS_IMMUNE = 7, - VICTIMSTATE_DEFLECTS = 8 -}; - -enum HitInfo -{ - HITINFO_NORMALSWING = 0x00000000, - HITINFO_UNK1 = 0x00000001, // req correct packet structure - HITINFO_NORMALSWING2 = 0x00000002, - HITINFO_LEFTSWING = 0x00000004, - HITINFO_MISS = 0x00000010, - HITINFO_ABSORB = 0x00000020, // plays absorb sound - HITINFO_RESIST = 0x00000040, // resisted atleast some damage - HITINFO_CRITICALHIT = 0x00000080, - HITINFO_GLANCING = 0x00004000, - HITINFO_CRUSHING = 0x00008000, - HITINFO_NOACTION = 0x00010000, - HITINFO_SWINGNOHITSOUND = 0x00080000 -}; - -//i would like to remove this: (it is defined in item.h -enum InventorySlot -{ - NULL_BAG = 0, - NULL_SLOT = 255 -}; - -struct FactionTemplateEntry; -struct Modifier; -struct SpellEntry; -struct SpellEntryExt; - -class Aura; -class Creature; -class Spell; -class DynamicObject; -class GameObject; -class Item; -class Pet; -class Path; -class PetAura; - -struct SpellImmune -{ - uint32 type; - uint32 spellId; -}; - -typedef std::list SpellImmuneList; - -enum UnitModifierType -{ - BASE_VALUE = 0, - BASE_PCT = 1, - TOTAL_VALUE = 2, - TOTAL_PCT = 3, - MODIFIER_TYPE_END = 4 -}; - -enum WeaponDamageRange -{ - MINDAMAGE, - MAXDAMAGE -}; - -enum DamageTypeToSchool -{ - RESISTANCE, - DAMAGE_DEALT, - DAMAGE_TAKEN -}; - -enum AuraRemoveMode -{ - AURA_REMOVE_BY_DEFAULT, - AURA_REMOVE_BY_STACK, // at replace by semillar aura - AURA_REMOVE_BY_CANCEL, - AURA_REMOVE_BY_DISPEL, - AURA_REMOVE_BY_DEATH -}; - -enum UnitMods -{ - UNIT_MOD_STAT_STRENGTH, // UNIT_MOD_STAT_STRENGTH..UNIT_MOD_STAT_SPIRIT must be in existed order, it's accessed by index values of Stats enum. - UNIT_MOD_STAT_AGILITY, - UNIT_MOD_STAT_STAMINA, - UNIT_MOD_STAT_INTELLECT, - UNIT_MOD_STAT_SPIRIT, - UNIT_MOD_HEALTH, - UNIT_MOD_MANA, // UNIT_MOD_MANA..UNIT_MOD_HAPPINESS must be in existed order, it's accessed by index values of Powers enum. - UNIT_MOD_RAGE, - UNIT_MOD_FOCUS, - UNIT_MOD_ENERGY, - UNIT_MOD_HAPPINESS, - UNIT_MOD_ARMOR, // UNIT_MOD_ARMOR..UNIT_MOD_RESISTANCE_ARCANE must be in existed order, it's accessed by index values of SpellSchools enum. - UNIT_MOD_RESISTANCE_HOLY, - UNIT_MOD_RESISTANCE_FIRE, - UNIT_MOD_RESISTANCE_NATURE, - UNIT_MOD_RESISTANCE_FROST, - UNIT_MOD_RESISTANCE_SHADOW, - UNIT_MOD_RESISTANCE_ARCANE, - UNIT_MOD_ATTACK_POWER, - UNIT_MOD_ATTACK_POWER_RANGED, - UNIT_MOD_DAMAGE_MAINHAND, - UNIT_MOD_DAMAGE_OFFHAND, - UNIT_MOD_DAMAGE_RANGED, - UNIT_MOD_END, - // synonyms - UNIT_MOD_STAT_START = UNIT_MOD_STAT_STRENGTH, - UNIT_MOD_STAT_END = UNIT_MOD_STAT_SPIRIT + 1, - UNIT_MOD_RESISTANCE_START = UNIT_MOD_ARMOR, - UNIT_MOD_RESISTANCE_END = UNIT_MOD_RESISTANCE_ARCANE + 1, - UNIT_MOD_POWER_START = UNIT_MOD_MANA, - UNIT_MOD_POWER_END = UNIT_MOD_HAPPINESS + 1 -}; - -enum BaseModGroup -{ - CRIT_PERCENTAGE, - RANGED_CRIT_PERCENTAGE, - OFFHAND_CRIT_PERCENTAGE, - SHIELD_BLOCK_VALUE, - BASEMOD_END -}; - -enum BaseModType -{ - FLAT_MOD, - PCT_MOD -}; - -#define MOD_END (PCT_MOD+1) - -enum DeathState -{ - ALIVE = 0, - JUST_DIED = 1, - CORPSE = 2, - DEAD = 3, - JUST_ALIVED = 4 -}; - -enum UnitState -{ - UNIT_STAT_DIED = 0x0001, - UNIT_STAT_MELEE_ATTACKING = 0x0002, // player is melee attacking someone - //UNIT_STAT_MELEE_ATTACK_BY = 0x0004, // player is melee attack by someone - UNIT_STAT_STUNDED = 0x0008, - UNIT_STAT_ROAMING = 0x0010, - UNIT_STAT_CHASE = 0x0020, - UNIT_STAT_SEARCHING = 0x0040, - UNIT_STAT_FLEEING = 0x0080, - UNIT_STAT_MOVING = (UNIT_STAT_ROAMING | UNIT_STAT_CHASE | UNIT_STAT_SEARCHING | UNIT_STAT_FLEEING), - UNIT_STAT_IN_FLIGHT = 0x0100, // player is in flight mode - UNIT_STAT_FOLLOW = 0x0200, - UNIT_STAT_ROOT = 0x0400, - UNIT_STAT_CONFUSED = 0x0800, - UNIT_STAT_DISTRACTED = 0x1000, - UNIT_STAT_ISOLATED = 0x2000, // area auras do not affect other players - UNIT_STAT_ATTACK_PLAYER = 0x4000, - UNIT_STAT_ALL_STATE = 0xffff //(UNIT_STAT_STOPPED | UNIT_STAT_MOVING | UNIT_STAT_IN_COMBAT | UNIT_STAT_IN_FLIGHT) -}; - -enum UnitMoveType -{ - MOVE_WALK = 0, - MOVE_RUN = 1, - MOVE_WALKBACK = 2, - MOVE_SWIM = 3, - MOVE_SWIMBACK = 4, - MOVE_TURN = 5, - MOVE_FLY = 6, - MOVE_FLYBACK = 7 -}; - -#define MAX_MOVE_TYPE 8 - -extern float baseMoveSpeed[MAX_MOVE_TYPE]; - -enum WeaponAttackType -{ - BASE_ATTACK = 0, - OFF_ATTACK = 1, - RANGED_ATTACK = 2 -}; - -#define MAX_ATTACK 3 - -enum CombatRating -{ - CR_WEAPON_SKILL = 0, - CR_DEFENSE_SKILL = 1, - CR_DODGE = 2, - CR_PARRY = 3, - CR_BLOCK = 4, - CR_HIT_MELEE = 5, - CR_HIT_RANGED = 6, - CR_HIT_SPELL = 7, - CR_CRIT_MELEE = 8, - CR_CRIT_RANGED = 9, - CR_CRIT_SPELL = 10, - CR_HIT_TAKEN_MELEE = 11, - CR_HIT_TAKEN_RANGED = 12, - CR_HIT_TAKEN_SPELL = 13, - CR_CRIT_TAKEN_MELEE = 14, - CR_CRIT_TAKEN_RANGED = 15, - CR_CRIT_TAKEN_SPELL = 16, - CR_HASTE_MELEE = 17, - CR_HASTE_RANGED = 18, - CR_HASTE_SPELL = 19, - CR_WEAPON_SKILL_MAINHAND = 20, - CR_WEAPON_SKILL_OFFHAND = 21, - CR_WEAPON_SKILL_RANGED = 22, - CR_EXPERTISE = 23 -}; - -#define MAX_COMBAT_RATING 24 - -enum DamageEffectType -{ - DIRECT_DAMAGE = 0, // used for normal weapon damage (not for class abilities or spells) - SPELL_DIRECT_DAMAGE = 1, // spell/class abilities damage - DOT = 2, - HEAL = 3, - NODAMAGE = 4, // used also in case when damage applied to health but not applied to spell channelInterruptFlags/etc - SELF_DAMAGE = 5 -}; - -enum UnitVisibility -{ - VISIBILITY_OFF = 0, // absolute, not detectable, GM-like, can see all other - VISIBILITY_ON = 1, - VISIBILITY_GROUP_STEALTH = 2, // detect chance, seen and can see group members - VISIBILITY_GROUP_INVISIBILITY = 3, // invisibility, can see and can be seen only another invisible unit or invisible detection unit, set only if not stealthed, and in checks not used (mask used instead) - VISIBILITY_GROUP_NO_DETECT = 4, // state just at stealth apply for update Grid state. Don't remove, otherwise stealth spells will break - VISIBILITY_RESPAWN = 5 // special totally not detectable visibility for force delete object at respawn command -}; - -// Value masks for UNIT_FIELD_FLAGS -enum UnitFlags -{ - UNIT_FLAG_UNKNOWN7 = 0x00000001, - UNIT_FLAG_NON_ATTACKABLE = 0x00000002, // not attackable - UNIT_FLAG_DISABLE_MOVE = 0x00000004, - UNIT_FLAG_PVP_ATTACKABLE = 0x00000008, // allow apply pvp rules to attackable state in addition to faction dependent state - UNIT_FLAG_RENAME = 0x00000010, - UNIT_FLAG_PREPARATION = 0x00000020, // don't take reagents for spells with SPELL_ATTR_EX5_NO_REAGENT_WHILE_PREP - UNIT_FLAG_UNKNOWN9 = 0x00000040, - UNIT_FLAG_NOT_ATTACKABLE_1 = 0x00000080, // ?? (UNIT_FLAG_PVP_ATTACKABLE | UNIT_FLAG_NOT_ATTACKABLE_1) is NON_PVP_ATTACKABLE - UNIT_FLAG_UNKNOWN2 = 0x00000100, // 2.0.8 - UNIT_FLAG_UNKNOWN11 = 0x00000200, - UNIT_FLAG_LOOTING = 0x00000400, // loot animation - UNIT_FLAG_PET_IN_COMBAT = 0x00000800, // in combat?, 2.0.8 - UNIT_FLAG_PVP = 0x00001000, - UNIT_FLAG_SILENCED = 0x00002000, // silenced, 2.1.1 - UNIT_FLAG_UNKNOWN4 = 0x00004000, // 2.0.8 - UNIT_FLAG_UNKNOWN13 = 0x00008000, - UNIT_FLAG_UNKNOWN14 = 0x00010000, - UNIT_FLAG_PACIFIED = 0x00020000, - UNIT_FLAG_DISABLE_ROTATE = 0x00040000, // stunned, 2.1.1 - UNIT_FLAG_IN_COMBAT = 0x00080000, - UNIT_FLAG_TAXI_FLIGHT = 0x00100000, // disable casting at client side spell not allowed by taxi flight (mounted?), probably used with 0x4 flag - UNIT_FLAG_DISARMED = 0x00200000, // disable melee spells casting..., "Required melee weapon" added to melee spells tooltip. - UNIT_FLAG_CONFUSED = 0x00400000, - UNIT_FLAG_FLEEING = 0x00800000, - UNIT_FLAG_UNKNOWN5 = 0x01000000, // used in spell Eyes of the Beast for pet... - UNIT_FLAG_NOT_SELECTABLE = 0x02000000, - UNIT_FLAG_SKINNABLE = 0x04000000, - UNIT_FLAG_MOUNT = 0x08000000, - UNIT_FLAG_UNKNOWN17 = 0x10000000, - UNIT_FLAG_UNKNOWN6 = 0x20000000, // used in Feing Death spell - UNIT_FLAG_SHEATHE = 0x40000000 -}; - -// Value masks for UNIT_FIELD_FLAGS_2 -enum UnitFlags2 -{ - UNIT_FLAG2_FEIGN_DEATH = 0x00000001, - UNIT_FLAG2_COMPREHEND_LANG= 0x00000008, - UNIT_FLAG2_FORCE_MOVE = 0x00000040 -}; - -/// Non Player Character flags -enum NPCFlags -{ - UNIT_NPC_FLAG_NONE = 0x00000000, - UNIT_NPC_FLAG_GOSSIP = 0x00000001, // 100% - UNIT_NPC_FLAG_QUESTGIVER = 0x00000002, // guessed, probably ok - UNIT_NPC_FLAG_UNK1 = 0x00000004, - UNIT_NPC_FLAG_UNK2 = 0x00000008, - UNIT_NPC_FLAG_TRAINER = 0x00000010, // 100% - UNIT_NPC_FLAG_TRAINER_CLASS = 0x00000020, // 100% - UNIT_NPC_FLAG_TRAINER_PROFESSION = 0x00000040, // 100% - UNIT_NPC_FLAG_VENDOR = 0x00000080, // 100% - UNIT_NPC_FLAG_VENDOR_AMMO = 0x00000100, // 100%, general goods vendor - UNIT_NPC_FLAG_VENDOR_FOOD = 0x00000200, // 100% - UNIT_NPC_FLAG_VENDOR_POISON = 0x00000400, // guessed - UNIT_NPC_FLAG_VENDOR_REAGENT = 0x00000800, // 100% - UNIT_NPC_FLAG_REPAIR = 0x00001000, // 100% - UNIT_NPC_FLAG_FLIGHTMASTER = 0x00002000, // 100% - UNIT_NPC_FLAG_SPIRITHEALER = 0x00004000, // guessed - UNIT_NPC_FLAG_SPIRITGUIDE = 0x00008000, // guessed - UNIT_NPC_FLAG_INNKEEPER = 0x00010000, // 100% - UNIT_NPC_FLAG_BANKER = 0x00020000, // 100% - UNIT_NPC_FLAG_PETITIONER = 0x00040000, // 100% 0xC0000 = guild petitions, 0x40000 = arena team petitions - UNIT_NPC_FLAG_TABARDDESIGNER = 0x00080000, // 100% - UNIT_NPC_FLAG_BATTLEMASTER = 0x00100000, // 100% - UNIT_NPC_FLAG_AUCTIONEER = 0x00200000, // 100% - UNIT_NPC_FLAG_STABLEMASTER = 0x00400000, // 100% - UNIT_NPC_FLAG_GUILD_BANKER = 0x00800000, // cause client to send 997 opcode - UNIT_NPC_FLAG_UNK3 = 0x01000000, // cause client to send 1015 opcode - UNIT_NPC_FLAG_GUARD = 0x10000000, // custom flag for guards -}; - -enum MovementFlags -{ - MOVEMENTFLAG_NONE = 0x00000000, - MOVEMENTFLAG_FORWARD = 0x00000001, - MOVEMENTFLAG_BACKWARD = 0x00000002, - MOVEMENTFLAG_STRAFE_LEFT = 0x00000004, - MOVEMENTFLAG_STRAFE_RIGHT = 0x00000008, - MOVEMENTFLAG_LEFT = 0x00000010, - MOVEMENTFLAG_RIGHT = 0x00000020, - MOVEMENTFLAG_PITCH_UP = 0x00000040, - MOVEMENTFLAG_PITCH_DOWN = 0x00000080, - MOVEMENTFLAG_WALK_MODE = 0x00000100, // Walking - MOVEMENTFLAG_ONTRANSPORT = 0x00000200, // Used for flying on some creatures - MOVEMENTFLAG_LEVITATING = 0x00000400, - MOVEMENTFLAG_FLY_UNK1 = 0x00000800, - MOVEMENTFLAG_JUMPING = 0x00001000, - MOVEMENTFLAG_UNK4 = 0x00002000, - MOVEMENTFLAG_FALLING = 0x00004000, - // 0x8000, 0x10000, 0x20000, 0x40000, 0x80000, 0x100000 - MOVEMENTFLAG_SWIMMING = 0x00200000, // appears with fly flag also - MOVEMENTFLAG_FLY_UP = 0x00400000, - MOVEMENTFLAG_CAN_FLY = 0x00800000, - MOVEMENTFLAG_FLYING = 0x01000000, - MOVEMENTFLAG_FLYING2 = 0x02000000, // Actual flying mode - MOVEMENTFLAG_SPLINE = 0x04000000, // used for flight paths - MOVEMENTFLAG_SPLINE2 = 0x08000000, // used for flight paths - MOVEMENTFLAG_WATERWALKING = 0x10000000, // prevent unit from falling through water - MOVEMENTFLAG_SAFE_FALL = 0x20000000, // active rogue safe fall spell (passive) - MOVEMENTFLAG_UNK3 = 0x40000000 -}; - -enum DiminishingLevels -{ - DIMINISHING_LEVEL_1 = 0, - DIMINISHING_LEVEL_2 = 1, - DIMINISHING_LEVEL_3 = 2, - DIMINISHING_LEVEL_IMMUNE = 3 -}; - -struct DiminishingReturn -{ - DiminishingReturn(DiminishingGroup group, uint32 t, uint32 count) : DRGroup(group), hitTime(t), hitCount(count), stack(0) {} - - DiminishingGroup DRGroup:16; - uint16 stack:16; - uint32 hitTime; - uint32 hitCount; -}; - -enum MeleeHitOutcome -{ - MELEE_HIT_EVADE, MELEE_HIT_MISS, MELEE_HIT_DODGE, MELEE_HIT_BLOCK, MELEE_HIT_PARRY, - MELEE_HIT_GLANCING, MELEE_HIT_CRIT, MELEE_HIT_CRUSHING, MELEE_HIT_NORMAL, MELEE_HIT_BLOCK_CRIT -}; -struct CleanDamage -{ - CleanDamage(uint32 _damage, WeaponAttackType _attackType, MeleeHitOutcome _hitOutCome) : - damage(_damage), attackType(_attackType), hitOutCome(_hitOutCome) {} - - uint32 damage; - WeaponAttackType attackType; - MeleeHitOutcome hitOutCome; -}; - -struct UnitActionBarEntry -{ - uint32 Type; - uint32 SpellOrAction; -}; - -#define MAX_DECLINED_NAME_CASES 5 - -struct DeclinedName -{ - std::string name[MAX_DECLINED_NAME_CASES]; -}; - -enum CurrentSpellTypes -{ - CURRENT_MELEE_SPELL = 0, - CURRENT_FIRST_NON_MELEE_SPELL = 1, // just counter - CURRENT_GENERIC_SPELL = 1, - CURRENT_AUTOREPEAT_SPELL = 2, - CURRENT_CHANNELED_SPELL = 3, - CURRENT_MAX_SPELL = 4 // just counter -}; - -enum ActiveStates -{ - ACT_ENABLED = 0xC100, - ACT_DISABLED = 0x8100, - ACT_COMMAND = 0x0700, - ACT_REACTION = 0x0600, - ACT_CAST = 0x0100, - ACT_PASSIVE = 0x0000, - ACT_DECIDE = 0x0001 -}; - -enum ReactStates -{ - REACT_PASSIVE = 0, - REACT_DEFENSIVE = 1, - REACT_AGGRESSIVE = 2 -}; - -enum CommandStates -{ - COMMAND_STAY = 0, - COMMAND_FOLLOW = 1, - COMMAND_ATTACK = 2, - COMMAND_ABANDON = 3 -}; - -struct CharmSpellEntry -{ - uint16 spellId; - uint16 active; -}; - -struct CharmInfo -{ - public: - explicit CharmInfo(Unit* unit); - uint32 GetPetNumber() const { return m_petnumber; } - void SetPetNumber(uint32 petnumber, bool statwindow); - - void SetCommandState(CommandStates st) { m_CommandState = st; } - CommandStates GetCommandState() { return m_CommandState; } - bool HasCommandState(CommandStates state) { return (m_CommandState == state); } - void SetReactState(ReactStates st) { m_ReactSate = st; } - ReactStates GetReactState() { return m_ReactSate; } - bool HasReactState(ReactStates state) { return (m_ReactSate == state); } - - void InitPossessCreateSpells(); - void InitCharmCreateSpells(); - void InitPetActionBar(); - void InitEmptyActionBar(); - //return true if successful - bool AddSpellToAB(uint32 oldid, uint32 newid, ActiveStates newstate = ACT_DECIDE); - void ToggleCreatureAutocast(uint32 spellid, bool apply); - - UnitActionBarEntry* GetActionBarEntry(uint8 index) { return &(PetActionBar[index]); } - CharmSpellEntry* GetCharmSpell(uint8 index) { return &(m_charmspells[index]); } - private: - Unit* m_unit; - UnitActionBarEntry PetActionBar[10]; - CharmSpellEntry m_charmspells[4]; - CommandStates m_CommandState; - ReactStates m_ReactSate; - uint32 m_petnumber; -}; - -// for clearing special attacks -#define REACTIVE_TIMER_START 4000 - -enum ReactiveType -{ - REACTIVE_DEFENSE = 1, - REACTIVE_HUNTER_PARRY = 2, - REACTIVE_CRIT = 3, - REACTIVE_HUNTER_CRIT = 4, - REACTIVE_OVERPOWER = 5 -}; - -#define MAX_REACTIVE 6 -#define MAX_TOTEM 4 - -// delay time next attack to prevent client attack animation problems -#define ATTACK_DISPLAY_DELAY 200 - -class MANGOS_DLL_SPEC Unit : public WorldObject -{ - public: - typedef std::set AttackerSet; - typedef std::pair spellEffectPair; - typedef std::multimap< spellEffectPair, Aura*> AuraMap; - typedef std::list AuraList; - typedef std::list Diminishing; - typedef std::set AuraTypeSet; - typedef std::set ComboPointHolderSet; - - virtual ~Unit ( ); - - void AddToWorld(); - void RemoveFromWorld(); - - void CleanupsBeforeDelete(); // used in ~Creature/~Player (or before mass creature delete to remove cross-references to already deleted units) - - DiminishingLevels GetDiminishing(DiminishingGroup group); - void IncrDiminishing(DiminishingGroup group); - void ApplyDiminishingToDuration(DiminishingGroup group, int32 &duration,Unit* caster, DiminishingLevels Level); - void ApplyDiminishingAura(DiminishingGroup group, bool apply); - void ClearDiminishings() { m_Diminishing.clear(); } - - virtual void Update( uint32 time ); - - void setAttackTimer(WeaponAttackType type, uint32 time) { m_attackTimer[type] = time; } - void resetAttackTimer(WeaponAttackType type = BASE_ATTACK); - uint32 getAttackTimer(WeaponAttackType type) const { return m_attackTimer[type]; } - bool isAttackReady(WeaponAttackType type = BASE_ATTACK) const { return m_attackTimer[type] == 0; } - bool haveOffhandWeapon() const; - bool canReachWithAttack(Unit *pVictim) const; - uint32 m_extraAttacks; - - void _addAttacker(Unit *pAttacker) // must be called only from Unit::Attack(Unit*) - { - AttackerSet::iterator itr = m_attackers.find(pAttacker); - if(itr == m_attackers.end()) - m_attackers.insert(pAttacker); - } - void _removeAttacker(Unit *pAttacker) // must be called only from Unit::AttackStop() - { - AttackerSet::iterator itr = m_attackers.find(pAttacker); - if(itr != m_attackers.end()) - m_attackers.erase(itr); - } - Unit * getAttackerForHelper() // If someone wants to help, who to give them - { - if (getVictim() != NULL) - return getVictim(); - - if (!m_attackers.empty()) - return *(m_attackers.begin()); - - return NULL; - } - bool Attack(Unit *victim, bool meleeAttack); - void CastStop(uint32 except_spellid = 0); - bool AttackStop(); - void RemoveAllAttackers(); - AttackerSet const& getAttackers() const { return m_attackers; } - bool isAttackingPlayer() const; - Unit* getVictim() const { return m_attacking; } - void CombatStop(bool cast = false); - void CombatStopWithPets(bool cast = false); - Unit* SelectNearbyTarget() const; - - void addUnitState(uint32 f) { m_state |= f; } - bool hasUnitState(const uint32 f) const { return (m_state & f); } - void clearUnitState(uint32 f) { m_state &= ~f; } - bool CanFreeMove() const - { - return !hasUnitState(UNIT_STAT_CONFUSED | UNIT_STAT_FLEEING | UNIT_STAT_IN_FLIGHT | - UNIT_STAT_ROOT | UNIT_STAT_STUNDED | UNIT_STAT_DISTRACTED ) && GetOwnerGUID()==0; - } - - uint32 getLevel() const { return GetUInt32Value(UNIT_FIELD_LEVEL); } - virtual uint32 getLevelForTarget(Unit const* /*target*/) const { return getLevel(); } - void SetLevel(uint32 lvl); - uint8 getRace() const { return GetByteValue(UNIT_FIELD_BYTES_0, 0); } - uint32 getRaceMask() const { return 1 << (getRace()-1); } - uint8 getClass() const { return GetByteValue(UNIT_FIELD_BYTES_0, 1); } - uint32 getClassMask() const { return 1 << (getClass()-1); } - uint8 getGender() const { return GetByteValue(UNIT_FIELD_BYTES_0, 2); } - - float GetStat(Stats stat) const { return float(GetUInt32Value(UNIT_FIELD_STAT0+stat)); } - void SetStat(Stats stat, int32 val) { SetStatInt32Value(UNIT_FIELD_STAT0+stat, val); } - uint32 GetArmor() const { return GetResistance(SPELL_SCHOOL_NORMAL) ; } - void SetArmor(int32 val) { SetResistance(SPELL_SCHOOL_NORMAL, val); } - - uint32 GetResistance(SpellSchools school) const { return GetUInt32Value(UNIT_FIELD_RESISTANCES+school); } - void SetResistance(SpellSchools school, int32 val) { SetStatInt32Value(UNIT_FIELD_RESISTANCES+school,val); } - - uint32 GetHealth() const { return GetUInt32Value(UNIT_FIELD_HEALTH); } - uint32 GetMaxHealth() const { return GetUInt32Value(UNIT_FIELD_MAXHEALTH); } - void SetHealth( uint32 val); - void SetMaxHealth(uint32 val); - int32 ModifyHealth(int32 val); - - Powers getPowerType() const { return Powers(GetByteValue(UNIT_FIELD_BYTES_0, 3)); } - void setPowerType(Powers power); - uint32 GetPower( Powers power) const { return GetUInt32Value(UNIT_FIELD_POWER1 +power); } - uint32 GetMaxPower(Powers power) const { return GetUInt32Value(UNIT_FIELD_MAXPOWER1+power); } - void SetPower( Powers power, uint32 val); - void SetMaxPower(Powers power, uint32 val); - int32 ModifyPower(Powers power, int32 val); - void ApplyPowerMod(Powers power, uint32 val, bool apply); - void ApplyMaxPowerMod(Powers power, uint32 val, bool apply); - - uint32 GetAttackTime(WeaponAttackType att) const { return (uint32)(GetFloatValue(UNIT_FIELD_BASEATTACKTIME+att)/m_modAttackSpeedPct[att]); } - void SetAttackTime(WeaponAttackType att, uint32 val) { SetFloatValue(UNIT_FIELD_BASEATTACKTIME+att,val*m_modAttackSpeedPct[att]); } - void ApplyAttackTimePercentMod(WeaponAttackType att,float val, bool apply); - void ApplyCastTimePercentMod(float val, bool apply); - - // faction template id - uint32 getFaction() const { return GetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE); } - void setFaction(uint32 faction) { SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE, faction ); } - FactionTemplateEntry const* getFactionTemplateEntry() const; - bool IsHostileTo(Unit const* unit) const; - bool IsHostileToPlayers() const; - bool IsFriendlyTo(Unit const* unit) const; - bool IsNeutralToAll() const; - bool IsContestedGuard() const - { - if(FactionTemplateEntry const* entry = getFactionTemplateEntry()) - return entry->IsContestedGuardFaction(); - - return false; - } - bool IsPvP() const { return HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP); } - void SetPvP(bool state) { if(state) SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP); else RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP); } - uint32 GetCreatureType() const; - uint32 GetCreatureTypeMask() const - { - uint32 creatureType = GetCreatureType(); - return (creatureType >= 1) ? (1 << (creatureType - 1)) : 0; - } - - uint8 getStandState() const { return GetByteValue(UNIT_FIELD_BYTES_1, 0); } - bool IsSitState() const; - bool IsStandState() const; - void SetStandState(uint8 state); - - bool IsMounted() const { return HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_MOUNT ); } - uint32 GetMountID() const { return GetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID); } - void Mount(uint32 mount); - void Unmount(); - - uint16 GetMaxSkillValueForLevel(Unit const* target = NULL) const { return (target ? getLevelForTarget(target) : getLevel()) * 5; } - uint32 DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDamage, DamageEffectType damagetype, SpellSchoolMask damageSchoolMask, SpellEntry const *spellProto, bool durabilityLoss); - void DealFlatDamage(Unit *pVictim, SpellEntry const *spellInfo, uint32 *damage, CleanDamage *cleanDamage, bool *crit = false, bool isTriggeredSpell = false); - void DoAttackDamage(Unit *pVictim, uint32 *damage, CleanDamage *cleanDamage, uint32 *blocked_amount, SpellSchoolMask damageSchoolMask, uint32 *hitInfo, VictimState *victimState, uint32 *absorbDamage, uint32 *resistDamage, WeaponAttackType attType, SpellEntry const *spellCasted = NULL, bool isTriggeredSpell = false); - - void CastMeleeProcDamageAndSpell(Unit* pVictim, uint32 damage, SpellSchoolMask damageSchoolMask, WeaponAttackType attType, MeleeHitOutcome outcome, SpellEntry const *spellCasted = NULL, bool isTriggeredSpell = false); - void ProcDamageAndSpell(Unit *pVictim, uint32 procAttacker, uint32 procVictim, uint32 damage = 0, SpellSchoolMask damageSchoolMask = SPELL_SCHOOL_MASK_NONE, SpellEntry const *procSpell = NULL, bool isTriggeredSpell = false, WeaponAttackType attType = BASE_ATTACK); - void HandleEmoteCommand(uint32 anim_id); - void AttackerStateUpdate (Unit *pVictim, WeaponAttackType attType = BASE_ATTACK, bool extra = false ); - - float MeleeMissChanceCalc(const Unit *pVictim, WeaponAttackType attType) const; - SpellMissInfo MagicSpellHitResult(Unit *pVictim, SpellEntry const *spell); - SpellMissInfo SpellHitResult(Unit *pVictim, SpellEntry const *spell, bool canReflect = false); - - float GetUnitDodgeChance() const; - float GetUnitParryChance() const; - float GetUnitBlockChance() const; - float GetUnitCriticalChance(WeaponAttackType attackType, const Unit *pVictim) const; - - virtual uint32 GetShieldBlockValue() const =0; - uint32 GetUnitMeleeSkill(Unit const* target = NULL) const { return (target ? getLevelForTarget(target) : getLevel()) * 5; } - uint32 GetDefenseSkillValue(Unit const* target = NULL) const; - uint32 GetWeaponSkillValue(WeaponAttackType attType, Unit const* target = NULL) const; - float GetWeaponProcChance() const; - float GetPPMProcChance(uint32 WeaponSpeed, float PPM) const; - MeleeHitOutcome RollPhysicalOutcomeAgainst (const Unit *pVictim, WeaponAttackType attType, SpellEntry const *spellInfo); - MeleeHitOutcome RollMeleeOutcomeAgainst (const Unit *pVictim, WeaponAttackType attType) const; - MeleeHitOutcome RollMeleeOutcomeAgainst (const Unit *pVictim, WeaponAttackType attType, int32 crit_chance, int32 miss_chance, int32 dodge_chance, int32 parry_chance, int32 block_chance, bool SpellCasted ) const; - - bool isVendor() const { return HasFlag( UNIT_NPC_FLAGS, UNIT_NPC_FLAG_VENDOR ); } - bool isTrainer() const { return HasFlag( UNIT_NPC_FLAGS, UNIT_NPC_FLAG_TRAINER ); } - bool isQuestGiver() const { return HasFlag( UNIT_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER ); } - bool isGossip() const { return HasFlag( UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP ); } - bool isTaxi() const { return HasFlag( UNIT_NPC_FLAGS, UNIT_NPC_FLAG_FLIGHTMASTER ); } - bool isGuildMaster() const { return HasFlag( UNIT_NPC_FLAGS, UNIT_NPC_FLAG_PETITIONER ); } - bool isBattleMaster() const { return HasFlag( UNIT_NPC_FLAGS, UNIT_NPC_FLAG_BATTLEMASTER ); } - bool isBanker() const { return HasFlag( UNIT_NPC_FLAGS, UNIT_NPC_FLAG_BANKER ); } - bool isInnkeeper() const { return HasFlag( UNIT_NPC_FLAGS, UNIT_NPC_FLAG_INNKEEPER ); } - bool isSpiritHealer() const { return HasFlag( UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPIRITHEALER ); } - bool isSpiritGuide() const { return HasFlag( UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPIRITGUIDE ); } - bool isTabardDesigner()const { return HasFlag( UNIT_NPC_FLAGS, UNIT_NPC_FLAG_TABARDDESIGNER ); } - bool isAuctioner() const { return HasFlag( UNIT_NPC_FLAGS, UNIT_NPC_FLAG_AUCTIONEER ); } - bool isArmorer() const { return HasFlag( UNIT_NPC_FLAGS, UNIT_NPC_FLAG_REPAIR ); } - bool isServiceProvider() const - { - return HasFlag( UNIT_NPC_FLAGS, - UNIT_NPC_FLAG_VENDOR | UNIT_NPC_FLAG_TRAINER | UNIT_NPC_FLAG_FLIGHTMASTER | - UNIT_NPC_FLAG_PETITIONER | UNIT_NPC_FLAG_BATTLEMASTER | UNIT_NPC_FLAG_BANKER | - UNIT_NPC_FLAG_INNKEEPER | UNIT_NPC_FLAG_GUARD | UNIT_NPC_FLAG_SPIRITHEALER | - UNIT_NPC_FLAG_SPIRITGUIDE | UNIT_NPC_FLAG_TABARDDESIGNER | UNIT_NPC_FLAG_AUCTIONEER ); - } - bool isSpiritService() const { return HasFlag( UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPIRITHEALER | UNIT_NPC_FLAG_SPIRITGUIDE ); } - - //Need fix or use this - bool isGuard() const { return HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GUARD); } - - bool isInFlight() const { return hasUnitState(UNIT_STAT_IN_FLIGHT); } - - bool isInCombat() const { return HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IN_COMBAT); } - void SetInCombatState(bool PvP); - void SetInCombatWith(Unit* enemy); - void ClearInCombat(); - uint32 GetCombatTimer() const { return m_CombatTimer; } - - bool HasAuraType(AuraType auraType) const; - bool HasAura(uint32 spellId, uint32 effIndex) const - { return m_Auras.find(spellEffectPair(spellId, effIndex)) != m_Auras.end(); } - - bool virtual HasSpell(uint32 /*spellID*/) const { return false; } - - bool HasStealthAura() const { return HasAuraType(SPELL_AURA_MOD_STEALTH); } - bool HasInvisibilityAura() const { return HasAuraType(SPELL_AURA_MOD_INVISIBILITY); } - bool isFeared() const { return HasAuraType(SPELL_AURA_MOD_FEAR); } - bool isInRoots() const { return HasAuraType(SPELL_AURA_MOD_ROOT); } - bool IsPolymorphed() const; - - bool isFrozen() const; - - void RemoveSpellbyDamageTaken(AuraType auraType, uint32 damage); - - bool isTargetableForAttack() const; - virtual bool IsInWater() const; - virtual bool IsUnderWater() const; - bool isInAccessablePlaceFor(Creature const* c) const; - - void SendHealSpellLog(Unit *pVictim, uint32 SpellID, uint32 Damage, bool critical = false); - void SendEnergizeSpellLog(Unit *pVictim, uint32 SpellID, uint32 Damage,Powers powertype, bool critical = false); - uint32 SpellNonMeleeDamageLog(Unit *pVictim, uint32 spellID, uint32 damage, bool isTriggeredSpell = false, bool useSpellDamage = true); - void CastSpell(Unit* Victim, uint32 spellId, bool triggered, Item *castItem = NULL, Aura* triggredByAura = NULL, uint64 originalCaster = 0); - void CastSpell(Unit* Victim,SpellEntry const *spellInfo, bool triggered, Item *castItem= NULL, Aura* triggredByAura = NULL, uint64 originalCaster = 0); - void CastCustomSpell(Unit* Victim, uint32 spellId, int32 const* bp0, int32 const* bp1, int32 const* bp2, bool triggered, Item *castItem= NULL, Aura* triggredByAura = NULL, uint64 originalCaster = 0); - void CastCustomSpell(Unit* Victim,SpellEntry const *spellInfo, int32 const* bp0, int32 const* bp1, int32 const* bp2, bool triggered, Item *castItem= NULL, Aura* triggredByAura = NULL, uint64 originalCaster = 0); - void CastSpell(float x, float y, float z, uint32 spellId, bool triggered, Item *castItem = NULL, Aura* triggredByAura = NULL, uint64 originalCaster = 0); - void CastSpell(float x, float y, float z, SpellEntry const *spellInfo, bool triggered, Item *castItem = NULL, Aura* triggredByAura = NULL, uint64 originalCaster = 0); - - bool IsDamageToThreatSpell(SpellEntry const * spellInfo) const; - - void DeMorph(); - - void SendAttackStateUpdate(uint32 HitInfo, Unit *target, uint8 SwingType, SpellSchoolMask damageSchoolMask, uint32 Damage, uint32 AbsorbDamage, uint32 Resist, VictimState TargetState, uint32 BlockedAmount); - void SendSpellNonMeleeDamageLog(Unit *target,uint32 SpellID,uint32 Damage, SpellSchoolMask damageSchoolMask,uint32 AbsorbedDamage, uint32 Resist,bool PhysicalDamage, uint32 Blocked, bool CriticalHit = false); - void SendSpellMiss(Unit *target, uint32 spellID, SpellMissInfo missInfo); - - void SendMonsterMove(float NewPosX, float NewPosY, float NewPosZ, uint8 type, uint32 MovementFlags, uint32 Time, Player* player = NULL); - void SendMonsterMoveByPath(Path const& path, uint32 start, uint32 end, uint32 MovementFlags); - void SendMonsterMoveWithSpeed(float x, float y, float z, uint32 MovementFlags, uint32 transitTime = 0, Player* player = NULL); - void SendMonsterMoveWithSpeedToCurrentDestination(Player* player = NULL); - - virtual void MoveOutOfRange(Player &) { }; - - bool isAlive() const { return (m_deathState == ALIVE); }; - bool isDead() const { return ( m_deathState == DEAD || m_deathState == CORPSE ); }; - DeathState getDeathState() { return m_deathState; }; - virtual void setDeathState(DeathState s); // overwrited in Creature/Player/Pet - - uint64 const& GetOwnerGUID() const { return GetUInt64Value(UNIT_FIELD_SUMMONEDBY); } - uint64 GetPetGUID() const { return GetUInt64Value(UNIT_FIELD_SUMMON); } - uint64 GetCharmerGUID() const { return GetUInt64Value(UNIT_FIELD_CHARMEDBY); } - uint64 GetCharmGUID() const { return GetUInt64Value(UNIT_FIELD_CHARM); } - void SetCharmerGUID(uint64 owner) { SetUInt64Value(UNIT_FIELD_CHARMEDBY, owner); } - - uint64 GetCharmerOrOwnerGUID() const { return GetCharmerGUID() ? GetCharmerGUID() : GetOwnerGUID(); } - uint64 GetCharmerOrOwnerOrOwnGUID() const - { - if(uint64 guid = GetCharmerOrOwnerGUID()) - return guid; - return GetGUID(); - } - bool isCharmedOwnedByPlayerOrPlayer() const { return IS_PLAYER_GUID(GetCharmerOrOwnerOrOwnGUID()); } - - Player* GetSpellModOwner(); - - Unit* GetOwner() const; - Pet* GetPet() const; - Unit* GetCharmer() const; - Unit* GetCharm() const; - Unit* GetCharmerOrOwner() const { return GetCharmerGUID() ? GetCharmer() : GetOwner(); } - Unit* GetCharmerOrOwnerOrSelf() - { - if(Unit* u = GetCharmerOrOwner()) - return u; - - return this; - } - Player* GetCharmerOrOwnerPlayerOrPlayerItself(); - - void SetPet(Pet* pet); - void SetCharm(Unit* pet); - bool isCharmed() const { return GetCharmerGUID() != 0; } - - CharmInfo* GetCharmInfo() { return m_charmInfo; } - CharmInfo* InitCharmInfo(Unit* charm); - - bool AddAura(Aura *aur); - - void RemoveAura(AuraMap::iterator &i, AuraRemoveMode mode = AURA_REMOVE_BY_DEFAULT); - void RemoveAura(uint32 spellId, uint32 effindex, Aura* except = NULL); - void RemoveSingleAuraFromStack(uint32 spellId, uint32 effindex); - void RemoveAurasDueToSpell(uint32 spellId, Aura* except = NULL); - void RemoveAurasDueToItemSpell(Item* castItem,uint32 spellId); - void RemoveAurasDueToSpellByDispel(uint32 spellId, uint64 casterGUID, Unit *dispeler); - void RemoveAurasDueToSpellBySteal(uint32 spellId, uint64 casterGUID, Unit *stealer); - void RemoveAurasDueToSpellByCancel(uint32 spellId); - void RemoveNotOwnSingleTargetAuras(); - - void RemoveSpellsCausingAura(AuraType auraType); - void RemoveRankAurasDueToSpell(uint32 spellId); - bool RemoveNoStackAurasDueToAura(Aura *Aur); - void RemoveAurasWithInterruptFlags(uint32 flags); - void RemoveAurasWithDispelType( DispelType type ); - - void RemoveAllAuras(); - void RemoveAllAurasOnDeath(); - void DelayAura(uint32 spellId, uint32 effindex, int32 delaytime); - - float GetResistanceBuffMods(SpellSchools school, bool positive) const { return GetFloatValue(positive ? UNIT_FIELD_RESISTANCEBUFFMODSPOSITIVE+school : UNIT_FIELD_RESISTANCEBUFFMODSNEGATIVE+school ); } - void SetResistanceBuffMods(SpellSchools school, bool positive, float val) { SetFloatValue(positive ? UNIT_FIELD_RESISTANCEBUFFMODSPOSITIVE+school : UNIT_FIELD_RESISTANCEBUFFMODSNEGATIVE+school,val); } - void ApplyResistanceBuffModsMod(SpellSchools school, bool positive, float val, bool apply) { ApplyModSignedFloatValue(positive ? UNIT_FIELD_RESISTANCEBUFFMODSPOSITIVE+school : UNIT_FIELD_RESISTANCEBUFFMODSNEGATIVE+school, val, apply); } - void ApplyResistanceBuffModsPercentMod(SpellSchools school, bool positive, float val, bool apply) { ApplyPercentModFloatValue(positive ? UNIT_FIELD_RESISTANCEBUFFMODSPOSITIVE+school : UNIT_FIELD_RESISTANCEBUFFMODSNEGATIVE+school, val, apply); } - void InitStatBuffMods() - { - for(int i = STAT_STRENGTH; i < MAX_STATS; ++i) SetFloatValue(UNIT_FIELD_POSSTAT0+i, 0); - for(int i = STAT_STRENGTH; i < MAX_STATS; ++i) SetFloatValue(UNIT_FIELD_NEGSTAT0+i, 0); - } - void ApplyStatBuffMod(Stats stat, float val, bool apply) { ApplyModSignedFloatValue((val > 0 ? UNIT_FIELD_POSSTAT0+stat : UNIT_FIELD_NEGSTAT0+stat), val, apply); } - void ApplyStatPercentBuffMod(Stats stat, float val, bool apply) - { - ApplyPercentModFloatValue(UNIT_FIELD_POSSTAT0+stat, val, apply); - ApplyPercentModFloatValue(UNIT_FIELD_NEGSTAT0+stat, val, apply); - } - void SetCreateStat(Stats stat, float val) { m_createStats[stat] = val; } - void SetCreateHealth(uint32 val) { SetUInt32Value(UNIT_FIELD_BASE_HEALTH, val); } - uint32 GetCreateHealth() const { return GetUInt32Value(UNIT_FIELD_BASE_HEALTH); } - void SetCreateMana(uint32 val) { SetUInt32Value(UNIT_FIELD_BASE_MANA, val); } - uint32 GetCreateMana() const { return GetUInt32Value(UNIT_FIELD_BASE_MANA); } - uint32 GetCreatePowers(Powers power) const; - float GetPosStat(Stats stat) const { return GetFloatValue(UNIT_FIELD_POSSTAT0+stat); } - float GetNegStat(Stats stat) const { return GetFloatValue(UNIT_FIELD_NEGSTAT0+stat); } - float GetCreateStat(Stats stat) const { return m_createStats[stat]; } - - void SetCurrentCastedSpell(Spell * pSpell); - virtual void ProhibitSpellScholl(SpellSchoolMask /*idSchoolMask*/, uint32 /*unTimeMs*/ ) { } - void InterruptSpell(uint32 spellType, bool withDelayed = true); - - // set withDelayed to true to account delayed spells as casted - // delayed+channeled spells are always accounted as casted - // we can skip channeled or delayed checks using flags - bool IsNonMeleeSpellCasted(bool withDelayed, bool skipChanneled = false, bool skipAutorepeat = false) const; - - // set withDelayed to true to interrupt delayed spells too - // delayed+channeled spells are always interrupted - void InterruptNonMeleeSpells(bool withDelayed, uint32 spellid = 0); - - Spell* FindCurrentSpellBySpellId(uint32 spell_id) const; - - Spell* m_currentSpells[CURRENT_MAX_SPELL]; - - uint32 m_addDmgOnce; - uint64 m_TotemSlot[MAX_TOTEM]; - uint64 m_ObjectSlot[4]; - uint32 m_detectInvisibilityMask; - uint32 m_invisibilityMask; - uint32 m_ShapeShiftFormSpellId; - ShapeshiftForm m_form; - float m_modMeleeHitChance; - float m_modRangedHitChance; - float m_modSpellHitChance; - int32 m_baseSpellCritChance; - - float m_threatModifier[MAX_SPELL_SCHOOL]; - float m_modAttackSpeedPct[3]; - - // Event handler - EventProcessor m_Events; - - // stat system - bool HandleStatModifier(UnitMods unitMod, UnitModifierType modifierType, float amount, bool apply); - void SetModifierValue(UnitMods unitMod, UnitModifierType modifierType, float value) { m_auraModifiersGroup[unitMod][modifierType] = value; } - float GetModifierValue(UnitMods unitMod, UnitModifierType modifierType) const; - float GetTotalStatValue(Stats stat) const; - float GetTotalAuraModValue(UnitMods unitMod) const; - SpellSchools GetSpellSchoolByAuraGroup(UnitMods unitMod) const; - Stats GetStatByAuraGroup(UnitMods unitMod) const; - Powers GetPowerTypeByAuraGroup(UnitMods unitMod) const; - bool CanModifyStats() const { return m_canModifyStats; } - void SetCanModifyStats(bool modifyStats) { m_canModifyStats = modifyStats; } - virtual bool UpdateStats(Stats stat) = 0; - virtual bool UpdateAllStats() = 0; - virtual void UpdateResistances(uint32 school) = 0; - virtual void UpdateArmor() = 0; - virtual void UpdateMaxHealth() = 0; - virtual void UpdateMaxPower(Powers power) = 0; - virtual void UpdateAttackPowerAndDamage(bool ranged = false) = 0; - virtual void UpdateDamagePhysical(WeaponAttackType attType) = 0; - float GetTotalAttackPowerValue(WeaponAttackType attType) const; - float GetWeaponDamageRange(WeaponAttackType attType ,WeaponDamageRange type) const; - void SetBaseWeaponDamage(WeaponAttackType attType ,WeaponDamageRange damageRange, float value) { m_weaponDamage[attType][damageRange] = value; } - - bool isInFront(Unit const* target,float distance, float arc = M_PI) const; - void SetInFront(Unit const* target); - bool isInBack(Unit const* target, float distance, float arc = M_PI) const; - - // Visibility system - UnitVisibility GetVisibility() const { return m_Visibility; } - void SetVisibility(UnitVisibility x); - - // common function for visibility checks for player/creatures with detection code - bool isVisibleForOrDetect(Unit const* u, bool detect, bool inVisibleList = false) const; - bool canDetectInvisibilityOf(Unit const* u) const; - - // virtual functions for all world objects types - bool isVisibleForInState(Player const* u, bool inVisibleList) const; - // function for low level grid visibility checks in player/creature cases - virtual bool IsVisibleInGridForPlayer(Player* pl) const = 0; - - bool waterbreath; - AuraList & GetSingleCastAuras() { return m_scAuras; } - AuraList const& GetSingleCastAuras() const { return m_scAuras; } - SpellImmuneList m_spellImmune[MAX_SPELL_IMMUNITY]; - - // Threat related methodes - bool CanHaveThreatList() const; - void AddThreat(Unit* pVictim, float threat, SpellSchoolMask schoolMask = SPELL_SCHOOL_MASK_NORMAL, SpellEntry const *threatSpell = NULL); - float ApplyTotalThreatModifier(float threat, SpellSchoolMask schoolMask = SPELL_SCHOOL_MASK_NORMAL); - void DeleteThreatList(); - bool SelectHostilTarget(); - void TauntApply(Unit* pVictim); - void TauntFadeOut(Unit *taunter); - ThreatManager& getThreatManager() { return m_ThreatManager; } - void addHatedBy(HostilReference* pHostilReference) { m_HostilRefManager.insertFirst(pHostilReference); }; - void removeHatedBy(HostilReference* /*pHostilReference*/ ) { /* nothing to do yet */ } - HostilRefManager& getHostilRefManager() { return m_HostilRefManager; } - - Aura* GetAura(uint32 spellId, uint32 effindex); - AuraMap & GetAuras() { return m_Auras; } - AuraMap const& GetAuras() const { return m_Auras; } - AuraList const& GetAurasByType(AuraType type) const { return m_modAuras[type]; } - void ApplyAuraProcTriggerDamage(Aura* aura, bool apply); - - int32 GetTotalAuraModifier(AuraType auratype) const; - float GetTotalAuraMultiplier(AuraType auratype) const; - int32 GetMaxPositiveAuraModifier(AuraType auratype) const; - int32 GetMaxNegativeAuraModifier(AuraType auratype) const; - - int32 GetTotalAuraModifierByMiscMask(AuraType auratype, uint32 misc_mask) const; - float GetTotalAuraMultiplierByMiscMask(AuraType auratype, uint32 misc_mask) const; - int32 GetMaxPositiveAuraModifierByMiscMask(AuraType auratype, uint32 misc_mask) const; - int32 GetMaxNegativeAuraModifierByMiscMask(AuraType auratype, uint32 misc_mask) const; - - int32 GetTotalAuraModifierByMiscValue(AuraType auratype, int32 misc_value) const; - float GetTotalAuraMultiplierByMiscValue(AuraType auratype, int32 misc_value) const; - int32 GetMaxPositiveAuraModifierByMiscValue(AuraType auratype, int32 misc_value) const; - int32 GetMaxNegativeAuraModifierByMiscValue(AuraType auratype, int32 misc_value) const; - - Aura* GetDummyAura(uint32 spell_id) const; - - uint32 GetDisplayId() { return GetUInt32Value(UNIT_FIELD_DISPLAYID); } - void SetDisplayId(uint32 modelId); - uint32 GetNativeDisplayId() { return GetUInt32Value(UNIT_FIELD_NATIVEDISPLAYID); } - void SetNativeDisplayId(uint32 modelId) { SetUInt32Value(UNIT_FIELD_NATIVEDISPLAYID, modelId); } - void setTransForm(uint32 spellid) { m_transform = spellid;} - uint32 getTransForm() const { return m_transform;} - void AddDynObject(DynamicObject* dynObj); - void RemoveDynObject(uint32 spellid); - void RemoveDynObjectWithGUID(uint64 guid) { m_dynObjGUIDs.remove(guid); } - void RemoveAllDynObjects(); - void AddGameObject(GameObject* gameObj); - void RemoveGameObject(GameObject* gameObj, bool del); - void RemoveGameObject(uint32 spellid, bool del); - void RemoveAllGameObjects(); - DynamicObject *GetDynObject(uint32 spellId, uint32 effIndex); - DynamicObject *GetDynObject(uint32 spellId); - uint32 CalculateDamage(WeaponAttackType attType, bool normalized); - float GetAPMultiplier(WeaponAttackType attType, bool normalized); - void ModifyAuraState(AuraState flag, bool apply); - bool HasAuraState(AuraState flag) const { return HasFlag(UNIT_FIELD_AURASTATE, 1<<(flag-1)); } - void UnsummonAllTotems(); - int32 SpellBaseDamageBonus(SpellSchoolMask schoolMask); - int32 SpellBaseHealingBonus(SpellSchoolMask schoolMask); - int32 SpellBaseDamageBonusForVictim(SpellSchoolMask schoolMask, Unit *pVictim); - int32 SpellBaseHealingBonusForVictim(SpellSchoolMask schoolMask, Unit *pVictim); - uint32 SpellDamageBonus(Unit *pVictim, SpellEntry const *spellProto, uint32 damage, DamageEffectType damagetype); - uint32 SpellHealingBonus(SpellEntry const *spellProto, uint32 healamount, DamageEffectType damagetype, Unit *pVictim); - bool isSpellCrit(Unit *pVictim, SpellEntry const *spellProto, SpellSchoolMask schoolMask, WeaponAttackType attackType); - uint32 SpellCriticalBonus(SpellEntry const *spellProto, uint32 damage, Unit *pVictim); - - void SetLastManaUse(uint32 spellCastTime) { m_lastManaUse = spellCastTime; } - bool IsUnderLastManaUseEffect() const; - - void SetContestedPvP(Player *attackedPlayer = NULL); - - void MeleeDamageBonus(Unit *pVictim, uint32 *damage, WeaponAttackType attType, SpellEntry const *spellProto = NULL); - uint32 GetCastingTimeForBonus( SpellEntry const *spellProto, DamageEffectType damagetype, uint32 CastingTime ); - - void ApplySpellImmune(uint32 spellId, uint32 op, uint32 type, bool apply); - void ApplySpellDispelImmunity(const SpellEntry * spellProto, DispelType type, bool apply); - virtual bool IsImmunedToSpell(SpellEntry const* spellInfo, bool useCharges = false); - // redefined in Creature - bool IsImmunedToDamage(SpellSchoolMask meleeSchoolMask, bool useCharges = false); - virtual bool IsImmunedToSpellEffect(uint32 effect, uint32 mechanic) const; - // redefined in Creature - - uint32 CalcArmorReducedDamage(Unit* pVictim, const uint32 damage); - void CalcAbsorbResist(Unit *pVictim, SpellSchoolMask schoolMask, DamageEffectType damagetype, const uint32 damage, uint32 *absorb, uint32 *resist); - - void UpdateSpeed(UnitMoveType mtype, bool forced); - float GetSpeed( UnitMoveType mtype ) const; - float GetSpeedRate( UnitMoveType mtype ) const { return m_speed_rate[mtype]; } - void SetSpeed(UnitMoveType mtype, float rate, bool forced = false); - - void SetHover(bool on); - bool isHover() const { return HasAuraType(SPELL_AURA_HOVER); } - - void _RemoveAllAuraMods(); - void _ApplyAllAuraMods(); - - int32 CalculateSpellDamage(SpellEntry const* spellProto, uint8 effect_index, int32 basePoints, Unit const* target); - int32 CalculateSpellDuration(SpellEntry const* spellProto, uint8 effect_index, Unit const* target); - float CalculateLevelPenalty(SpellEntry const* spellProto) const; - - void addFollower(FollowerReference* pRef) { m_FollowingRefManager.insertFirst(pRef); } - void removeFollower(FollowerReference* /*pRef*/ ) { /* nothing to do yet */ } - static Unit* GetUnit(WorldObject& object, uint64 guid); - - MotionMaster* GetMotionMaster() { return &i_motionMaster; } - - bool IsStopped() const { return !(hasUnitState(UNIT_STAT_MOVING)); } - void StopMoving(); - - void AddUnitMovementFlag(uint32 f) { m_unit_movement_flags |= f; } - void RemoveUnitMovementFlag(uint32 f) - { - uint32 oldval = m_unit_movement_flags; - m_unit_movement_flags = oldval & ~f; - } - uint32 HasUnitMovementFlag(uint32 f) const { return m_unit_movement_flags & f; } - uint32 GetUnitMovementFlags() const { return m_unit_movement_flags; } - void SetUnitMovementFlags(uint32 f) { m_unit_movement_flags = f; } - - void SetFeared(bool apply, uint64 casterGUID = 0, uint32 spellID = 0); - void SetConfused(bool apply, uint64 casterGUID = 0, uint32 spellID = 0); - - void AddComboPointHolder(uint32 lowguid) { m_ComboPointHolders.insert(lowguid); } - void RemoveComboPointHolder(uint32 lowguid) { m_ComboPointHolders.erase(lowguid); } - void ClearComboPointHolders(); - - ///----------Pet responses methods----------------- - void SendPetCastFail(uint32 spellid, uint8 msg); - void SendPetActionFeedback (uint8 msg); - void SendPetTalk (uint32 pettalk); - void SendPetSpellCooldown (uint32 spellid, time_t cooltime); - void SendPetClearCooldown (uint32 spellid); - void SendPetAIReaction(uint64 guid); - ///----------End of Pet responses methods---------- - - void propagateSpeedChange() { GetMotionMaster()->propagateSpeedChange(); } - - // reactive attacks - void ClearAllReactives(); - void StartReactiveTimer( ReactiveType reactive ) { m_reactiveTimer[reactive] = REACTIVE_TIMER_START;} - void UpdateReactives(uint32 p_time); - - // group updates - void UpdateAuraForGroup(uint8 slot); - - // pet auras - typedef std::set PetAuraSet; - PetAuraSet m_petAuras; - void AddPetAura(PetAura const* petSpell); - void RemovePetAura(PetAura const* petSpell); - - protected: - explicit Unit (); - - void _UpdateSpells(uint32 time); - - void _UpdateAutoRepeatSpell(); - bool m_AutoRepeatFirstCast; - - uint32 m_attackTimer[MAX_ATTACK]; - - float m_createStats[MAX_STATS]; - - AttackerSet m_attackers; - Unit* m_attacking; - - DeathState m_deathState; - - AuraMap m_Auras; - - std::list m_scAuras; // casted singlecast auras - - typedef std::list DynObjectGUIDs; - DynObjectGUIDs m_dynObjGUIDs; - - std::list m_gameObj; - bool m_isSorted; - uint32 m_transform; - uint32 m_removedAuras; - - AuraList m_modAuras[TOTAL_AURAS]; - float m_auraModifiersGroup[UNIT_MOD_END][MODIFIER_TYPE_END]; - float m_weaponDamage[MAX_ATTACK][2]; - bool m_canModifyStats; - //std::list< spellEffectPair > AuraSpells[TOTAL_AURAS]; // TODO: use this if ok for mem - - float m_speed_rate[MAX_MOVE_TYPE]; - - CharmInfo *m_charmInfo; - - virtual SpellSchoolMask GetMeleeDamageSchoolMask() const; - - MotionMaster i_motionMaster; - uint32 m_unit_movement_flags; - - uint32 m_reactiveTimer[MAX_REACTIVE]; - - private: - void SendAttackStop(Unit* victim); // only from AttackStop(Unit*) - void SendAttackStart(Unit* pVictim); // only from Unit::AttackStart(Unit*) - - void ProcDamageAndSpellFor( bool isVictim, Unit * pTarget, uint32 procFlag, AuraTypeSet const& procAuraTypes, WeaponAttackType attType, SpellEntry const * procSpell, uint32 damage, SpellSchoolMask damageSchoolMask ); - bool HandleDummyAuraProc(Unit *pVictim, SpellEntry const *spellProto, uint32 effIndex, uint32 damage, Aura* triggredByAura, SpellEntry const * procSpell, uint32 procFlag,uint32 cooldown); - bool HandleProcTriggerSpell(Unit *pVictim,uint32 damage, Aura* triggredByAura, SpellEntry const *procSpell, uint32 procFlags,WeaponAttackType attType,uint32 cooldown); - bool HandleHasteAuraProc(Unit *pVictim, SpellEntry const *spellProto, uint32 effIndex, uint32 damage, Aura* triggredByAura, SpellEntry const * procSpell, uint32 procFlag,uint32 cooldown); - bool HandleOverrideClassScriptAuraProc(Unit *pVictim, int32 scriptId, uint32 damage, Aura* triggredByAura, SpellEntry const *procSpell,uint32 cooldown); - uint32 m_state; // Even derived shouldn't modify - uint32 m_CombatTimer; - uint32 m_lastManaUse; // msecs - - UnitVisibility m_Visibility; - - Diminishing m_Diminishing; - // Manage all Units threatening us - ThreatManager m_ThreatManager; - // Manage all Units that are threatened by us - HostilRefManager m_HostilRefManager; - - FollowerRefManager m_FollowingRefManager; - - ComboPointHolderSet m_ComboPointHolders; -}; -#endif +/* + * Copyright (C) 2005-2008 MaNGOS + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef __UNIT_H +#define __UNIT_H + +#include "Common.h" +#include "Object.h" +#include "Opcodes.h" +#include "Mthread.h" +#include "SpellAuraDefines.h" +#include "UpdateFields.h" +#include "SharedDefines.h" +#include "ThreatManager.h" +#include "HostilRefManager.h" +#include "FollowerReference.h" +#include "FollowerRefManager.h" +#include "Utilities/EventProcessor.h" +#include "MotionMaster.h" +#include "Database/DBCStructure.h" +#include + +enum SpellInterruptFlags +{ + SPELL_INTERRUPT_FLAG_MOVEMENT = 0x01, + SPELL_INTERRUPT_FLAG_DAMAGE = 0x02, + SPELL_INTERRUPT_FLAG_INTERRUPT = 0x04, + SPELL_INTERRUPT_FLAG_AUTOATTACK = 0x08, + //SPELL_INTERRUPT_FLAG_TURNING = 0x10 // not turning - maybe _complete_ interrupt on direct damage? +}; + +enum SpellChannelInterruptFlags +{ + CHANNEL_FLAG_DAMAGE = 0x0002, + CHANNEL_FLAG_MOVEMENT = 0x0008, + CHANNEL_FLAG_TURNING = 0x0010, + CHANNEL_FLAG_DAMAGE2 = 0x0080, + CHANNEL_FLAG_DELAY = 0x4000 +}; + +enum SpellAuraInterruptFlags +{ + AURA_INTERRUPT_FLAG_UNK0 = 0x00000001, // 0 removed when getting hit by a negative spell? + AURA_INTERRUPT_FLAG_DAMAGE = 0x00000002, // 1 removed by any damage + AURA_INTERRUPT_FLAG_UNK2 = 0x00000004, // 2 + AURA_INTERRUPT_FLAG_MOVE = 0x00000008, // 3 removed by any movement + AURA_INTERRUPT_FLAG_TURNING = 0x00000010, // 4 removed by any turning + AURA_INTERRUPT_FLAG_ENTER_COMBAT = 0x00000020, // 5 removed by entering combat + AURA_INTERRUPT_FLAG_NOT_MOUNTED = 0x00000040, // 6 removed by unmounting + AURA_INTERRUPT_FLAG_NOT_ABOVEWATER = 0x00000080, // 7 removed by entering water + AURA_INTERRUPT_FLAG_NOT_UNDERWATER = 0x00000100, // 8 removed by leaving water + AURA_INTERRUPT_FLAG_NOT_SHEATHED = 0x00000200, // 9 removed by unsheathing + AURA_INTERRUPT_FLAG_UNK10 = 0x00000400, // 10 + AURA_INTERRUPT_FLAG_UNK11 = 0x00000800, // 11 + AURA_INTERRUPT_FLAG_UNK12 = 0x00001000, // 12 removed by attack? + AURA_INTERRUPT_FLAG_UNK13 = 0x00002000, // 13 + AURA_INTERRUPT_FLAG_UNK14 = 0x00004000, // 14 + AURA_INTERRUPT_FLAG_UNK15 = 0x00008000, // 15 removed by casting a spell? + AURA_INTERRUPT_FLAG_UNK16 = 0x00010000, // 16 + AURA_INTERRUPT_FLAG_MOUNTING = 0x00020000, // 17 removed by mounting + AURA_INTERRUPT_FLAG_NOT_SEATED = 0x00040000, // 18 removed by standing up + AURA_INTERRUPT_FLAG_CHANGE_MAP = 0x00080000, // 19 leaving map/getting teleported + AURA_INTERRUPT_FLAG_UNK20 = 0x00100000, // 20 + AURA_INTERRUPT_FLAG_UNK21 = 0x00200000, // 21 + AURA_INTERRUPT_FLAG_UNK22 = 0x00400000, // 22 + AURA_INTERRUPT_FLAG_ENTER_PVP_COMBAT = 0x00800000, // 23 removed by entering pvp combat + AURA_INTERRUPT_FLAG_DIRECT_DAMAGE = 0x01000000 // 24 removed by any direct damage +}; + +enum SpellModOp +{ + SPELLMOD_DAMAGE = 0, + SPELLMOD_DURATION = 1, + SPELLMOD_THREAT = 2, + SPELLMOD_EFFECT1 = 3, + SPELLMOD_CHARGES = 4, + SPELLMOD_RANGE = 5, + SPELLMOD_RADIUS = 6, + SPELLMOD_CRITICAL_CHANCE = 7, + SPELLMOD_ALL_EFFECTS = 8, + SPELLMOD_NOT_LOSE_CASTING_TIME = 9, + SPELLMOD_CASTING_TIME = 10, + SPELLMOD_COOLDOWN = 11, + SPELLMOD_EFFECT2 = 12, + // spellmod 13 unused + SPELLMOD_COST = 14, + SPELLMOD_CRIT_DAMAGE_BONUS = 15, + SPELLMOD_RESIST_MISS_CHANCE = 16, + SPELLMOD_JUMP_TARGETS = 17, + SPELLMOD_CHANCE_OF_SUCCESS = 18, + SPELLMOD_ACTIVATION_TIME = 19, + SPELLMOD_EFFECT_PAST_FIRST = 20, + SPELLMOD_CASTING_TIME_OLD = 21, + SPELLMOD_DOT = 22, + SPELLMOD_EFFECT3 = 23, + SPELLMOD_SPELL_BONUS_DAMAGE = 24, + // spellmod 25, 26 unused + SPELLMOD_MULTIPLE_VALUE = 27, + SPELLMOD_RESIST_DISPEL_CHANCE = 28 +}; + +#define MAX_SPELLMOD 32 + +enum SpellFacingFlags +{ + SPELL_FACING_FLAG_INFRONT = 0x0001 +}; + +#define BASE_MINDAMAGE 1.0f +#define BASE_MAXDAMAGE 2.0f +#define BASE_ATTACK_TIME 2000 + +// high byte (3 from 0..3) of UNIT_FIELD_BYTES_2 +enum ShapeshiftForm +{ + FORM_NONE = 0x00, + FORM_CAT = 0x01, + FORM_TREE = 0x02, + FORM_TRAVEL = 0x03, + FORM_AQUA = 0x04, + FORM_BEAR = 0x05, + FORM_AMBIENT = 0x06, + FORM_GHOUL = 0x07, + FORM_DIREBEAR = 0x08, + FORM_CREATUREBEAR = 0x0E, + FORM_CREATURECAT = 0x0F, + FORM_GHOSTWOLF = 0x10, + FORM_BATTLESTANCE = 0x11, + FORM_DEFENSIVESTANCE = 0x12, + FORM_BERSERKERSTANCE = 0x13, + FORM_TEST = 0x14, + FORM_ZOMBIE = 0x15, + FORM_FLIGHT_EPIC = 0x1B, + FORM_SHADOW = 0x1C, + FORM_FLIGHT = 0x1D, + FORM_STEALTH = 0x1E, + FORM_MOONKIN = 0x1F, + FORM_SPIRITOFREDEMPTION = 0x20 +}; + +// low byte ( 0 from 0..3 ) of UNIT_FIELD_BYTES_2 +enum SheathState +{ + SHEATH_STATE_UNARMED = 0, // non prepared weapon + SHEATH_STATE_MELEE = 1, // prepared melee weapon + SHEATH_STATE_RANGED = 2 // prepared ranged weapon +}; + +// byte (1 from 0..3) of UNIT_FIELD_BYTES_2 +enum UnitBytes2_Flags +{ + UNIT_BYTE2_FLAG_UNK0 = 0x01, + UNIT_BYTE2_FLAG_UNK1 = 0x02, + UNIT_BYTE2_FLAG_UNK2 = 0x04, + UNIT_BYTE2_FLAG_UNK3 = 0x08, + UNIT_BYTE2_FLAG_AURAS = 0x10, // show possitive auras as positive, and allow its dispel + UNIT_BYTE2_FLAG_UNK5 = 0x20, + UNIT_BYTE2_FLAG_UNK6 = 0x40, + UNIT_BYTE2_FLAG_UNK7 = 0x80 +}; + +// byte (2 from 0..3) of UNIT_FIELD_BYTES_2 +enum UnitRename +{ + UNIT_RENAME_NOT_ALLOWED = 0x02, + UNIT_RENAME_ALLOWED = 0x03 +}; + +#define CREATURE_MAX_SPELLS 4 + +enum Swing +{ + NOSWING = 0, + SINGLEHANDEDSWING = 1, + TWOHANDEDSWING = 2 +}; + +enum VictimState +{ + VICTIMSTATE_UNKNOWN1 = 0, + VICTIMSTATE_NORMAL = 1, + VICTIMSTATE_DODGE = 2, + VICTIMSTATE_PARRY = 3, + VICTIMSTATE_INTERRUPT = 4, + VICTIMSTATE_BLOCKS = 5, + VICTIMSTATE_EVADES = 6, + VICTIMSTATE_IS_IMMUNE = 7, + VICTIMSTATE_DEFLECTS = 8 +}; + +enum HitInfo +{ + HITINFO_NORMALSWING = 0x00000000, + HITINFO_UNK1 = 0x00000001, // req correct packet structure + HITINFO_NORMALSWING2 = 0x00000002, + HITINFO_LEFTSWING = 0x00000004, + HITINFO_MISS = 0x00000010, + HITINFO_ABSORB = 0x00000020, // plays absorb sound + HITINFO_RESIST = 0x00000040, // resisted atleast some damage + HITINFO_CRITICALHIT = 0x00000080, + HITINFO_GLANCING = 0x00004000, + HITINFO_CRUSHING = 0x00008000, + HITINFO_NOACTION = 0x00010000, + HITINFO_SWINGNOHITSOUND = 0x00080000 +}; + +//i would like to remove this: (it is defined in item.h +enum InventorySlot +{ + NULL_BAG = 0, + NULL_SLOT = 255 +}; + +struct FactionTemplateEntry; +struct Modifier; +struct SpellEntry; +struct SpellEntryExt; + +class Aura; +class Creature; +class Spell; +class DynamicObject; +class GameObject; +class Item; +class Pet; +class Path; +class PetAura; + +struct SpellImmune +{ + uint32 type; + uint32 spellId; +}; + +typedef std::list SpellImmuneList; + +enum UnitModifierType +{ + BASE_VALUE = 0, + BASE_PCT = 1, + TOTAL_VALUE = 2, + TOTAL_PCT = 3, + MODIFIER_TYPE_END = 4 +}; + +enum WeaponDamageRange +{ + MINDAMAGE, + MAXDAMAGE +}; + +enum DamageTypeToSchool +{ + RESISTANCE, + DAMAGE_DEALT, + DAMAGE_TAKEN +}; + +enum AuraRemoveMode +{ + AURA_REMOVE_BY_DEFAULT, + AURA_REMOVE_BY_STACK, // at replace by semillar aura + AURA_REMOVE_BY_CANCEL, + AURA_REMOVE_BY_DISPEL, + AURA_REMOVE_BY_DEATH +}; + +enum UnitMods +{ + UNIT_MOD_STAT_STRENGTH, // UNIT_MOD_STAT_STRENGTH..UNIT_MOD_STAT_SPIRIT must be in existed order, it's accessed by index values of Stats enum. + UNIT_MOD_STAT_AGILITY, + UNIT_MOD_STAT_STAMINA, + UNIT_MOD_STAT_INTELLECT, + UNIT_MOD_STAT_SPIRIT, + UNIT_MOD_HEALTH, + UNIT_MOD_MANA, // UNIT_MOD_MANA..UNIT_MOD_HAPPINESS must be in existed order, it's accessed by index values of Powers enum. + UNIT_MOD_RAGE, + UNIT_MOD_FOCUS, + UNIT_MOD_ENERGY, + UNIT_MOD_HAPPINESS, + UNIT_MOD_ARMOR, // UNIT_MOD_ARMOR..UNIT_MOD_RESISTANCE_ARCANE must be in existed order, it's accessed by index values of SpellSchools enum. + UNIT_MOD_RESISTANCE_HOLY, + UNIT_MOD_RESISTANCE_FIRE, + UNIT_MOD_RESISTANCE_NATURE, + UNIT_MOD_RESISTANCE_FROST, + UNIT_MOD_RESISTANCE_SHADOW, + UNIT_MOD_RESISTANCE_ARCANE, + UNIT_MOD_ATTACK_POWER, + UNIT_MOD_ATTACK_POWER_RANGED, + UNIT_MOD_DAMAGE_MAINHAND, + UNIT_MOD_DAMAGE_OFFHAND, + UNIT_MOD_DAMAGE_RANGED, + UNIT_MOD_END, + // synonyms + UNIT_MOD_STAT_START = UNIT_MOD_STAT_STRENGTH, + UNIT_MOD_STAT_END = UNIT_MOD_STAT_SPIRIT + 1, + UNIT_MOD_RESISTANCE_START = UNIT_MOD_ARMOR, + UNIT_MOD_RESISTANCE_END = UNIT_MOD_RESISTANCE_ARCANE + 1, + UNIT_MOD_POWER_START = UNIT_MOD_MANA, + UNIT_MOD_POWER_END = UNIT_MOD_HAPPINESS + 1 +}; + +enum BaseModGroup +{ + CRIT_PERCENTAGE, + RANGED_CRIT_PERCENTAGE, + OFFHAND_CRIT_PERCENTAGE, + SHIELD_BLOCK_VALUE, + BASEMOD_END +}; + +enum BaseModType +{ + FLAT_MOD, + PCT_MOD +}; + +#define MOD_END (PCT_MOD+1) + +enum DeathState +{ + ALIVE = 0, + JUST_DIED = 1, + CORPSE = 2, + DEAD = 3, + JUST_ALIVED = 4 +}; + +enum UnitState +{ + UNIT_STAT_DIED = 0x0001, + UNIT_STAT_MELEE_ATTACKING = 0x0002, // player is melee attacking someone + //UNIT_STAT_MELEE_ATTACK_BY = 0x0004, // player is melee attack by someone + UNIT_STAT_STUNDED = 0x0008, + UNIT_STAT_ROAMING = 0x0010, + UNIT_STAT_CHASE = 0x0020, + UNIT_STAT_SEARCHING = 0x0040, + UNIT_STAT_FLEEING = 0x0080, + UNIT_STAT_MOVING = (UNIT_STAT_ROAMING | UNIT_STAT_CHASE | UNIT_STAT_SEARCHING | UNIT_STAT_FLEEING), + UNIT_STAT_IN_FLIGHT = 0x0100, // player is in flight mode + UNIT_STAT_FOLLOW = 0x0200, + UNIT_STAT_ROOT = 0x0400, + UNIT_STAT_CONFUSED = 0x0800, + UNIT_STAT_DISTRACTED = 0x1000, + UNIT_STAT_ISOLATED = 0x2000, // area auras do not affect other players + UNIT_STAT_ATTACK_PLAYER = 0x4000, + UNIT_STAT_ALL_STATE = 0xffff //(UNIT_STAT_STOPPED | UNIT_STAT_MOVING | UNIT_STAT_IN_COMBAT | UNIT_STAT_IN_FLIGHT) +}; + +enum UnitMoveType +{ + MOVE_WALK = 0, + MOVE_RUN = 1, + MOVE_WALKBACK = 2, + MOVE_SWIM = 3, + MOVE_SWIMBACK = 4, + MOVE_TURN = 5, + MOVE_FLY = 6, + MOVE_FLYBACK = 7 +}; + +#define MAX_MOVE_TYPE 8 + +extern float baseMoveSpeed[MAX_MOVE_TYPE]; + +enum WeaponAttackType +{ + BASE_ATTACK = 0, + OFF_ATTACK = 1, + RANGED_ATTACK = 2 +}; + +#define MAX_ATTACK 3 + +enum CombatRating +{ + CR_WEAPON_SKILL = 0, + CR_DEFENSE_SKILL = 1, + CR_DODGE = 2, + CR_PARRY = 3, + CR_BLOCK = 4, + CR_HIT_MELEE = 5, + CR_HIT_RANGED = 6, + CR_HIT_SPELL = 7, + CR_CRIT_MELEE = 8, + CR_CRIT_RANGED = 9, + CR_CRIT_SPELL = 10, + CR_HIT_TAKEN_MELEE = 11, + CR_HIT_TAKEN_RANGED = 12, + CR_HIT_TAKEN_SPELL = 13, + CR_CRIT_TAKEN_MELEE = 14, + CR_CRIT_TAKEN_RANGED = 15, + CR_CRIT_TAKEN_SPELL = 16, + CR_HASTE_MELEE = 17, + CR_HASTE_RANGED = 18, + CR_HASTE_SPELL = 19, + CR_WEAPON_SKILL_MAINHAND = 20, + CR_WEAPON_SKILL_OFFHAND = 21, + CR_WEAPON_SKILL_RANGED = 22, + CR_EXPERTISE = 23 +}; + +#define MAX_COMBAT_RATING 24 + +enum DamageEffectType +{ + DIRECT_DAMAGE = 0, // used for normal weapon damage (not for class abilities or spells) + SPELL_DIRECT_DAMAGE = 1, // spell/class abilities damage + DOT = 2, + HEAL = 3, + NODAMAGE = 4, // used also in case when damage applied to health but not applied to spell channelInterruptFlags/etc + SELF_DAMAGE = 5 +}; + +enum UnitVisibility +{ + VISIBILITY_OFF = 0, // absolute, not detectable, GM-like, can see all other + VISIBILITY_ON = 1, + VISIBILITY_GROUP_STEALTH = 2, // detect chance, seen and can see group members + VISIBILITY_GROUP_INVISIBILITY = 3, // invisibility, can see and can be seen only another invisible unit or invisible detection unit, set only if not stealthed, and in checks not used (mask used instead) + VISIBILITY_GROUP_NO_DETECT = 4, // state just at stealth apply for update Grid state. Don't remove, otherwise stealth spells will break + VISIBILITY_RESPAWN = 5 // special totally not detectable visibility for force delete object at respawn command +}; + +// Value masks for UNIT_FIELD_FLAGS +enum UnitFlags +{ + UNIT_FLAG_UNKNOWN7 = 0x00000001, + UNIT_FLAG_NON_ATTACKABLE = 0x00000002, // not attackable + UNIT_FLAG_DISABLE_MOVE = 0x00000004, + UNIT_FLAG_PVP_ATTACKABLE = 0x00000008, // allow apply pvp rules to attackable state in addition to faction dependent state + UNIT_FLAG_RENAME = 0x00000010, + UNIT_FLAG_PREPARATION = 0x00000020, // don't take reagents for spells with SPELL_ATTR_EX5_NO_REAGENT_WHILE_PREP + UNIT_FLAG_UNKNOWN9 = 0x00000040, + UNIT_FLAG_NOT_ATTACKABLE_1 = 0x00000080, // ?? (UNIT_FLAG_PVP_ATTACKABLE | UNIT_FLAG_NOT_ATTACKABLE_1) is NON_PVP_ATTACKABLE + UNIT_FLAG_UNKNOWN2 = 0x00000100, // 2.0.8 + UNIT_FLAG_UNKNOWN11 = 0x00000200, + UNIT_FLAG_LOOTING = 0x00000400, // loot animation + UNIT_FLAG_PET_IN_COMBAT = 0x00000800, // in combat?, 2.0.8 + UNIT_FLAG_PVP = 0x00001000, + UNIT_FLAG_SILENCED = 0x00002000, // silenced, 2.1.1 + UNIT_FLAG_UNKNOWN4 = 0x00004000, // 2.0.8 + UNIT_FLAG_UNKNOWN13 = 0x00008000, + UNIT_FLAG_UNKNOWN14 = 0x00010000, + UNIT_FLAG_PACIFIED = 0x00020000, + UNIT_FLAG_DISABLE_ROTATE = 0x00040000, // stunned, 2.1.1 + UNIT_FLAG_IN_COMBAT = 0x00080000, + UNIT_FLAG_TAXI_FLIGHT = 0x00100000, // disable casting at client side spell not allowed by taxi flight (mounted?), probably used with 0x4 flag + UNIT_FLAG_DISARMED = 0x00200000, // disable melee spells casting..., "Required melee weapon" added to melee spells tooltip. + UNIT_FLAG_CONFUSED = 0x00400000, + UNIT_FLAG_FLEEING = 0x00800000, + UNIT_FLAG_UNKNOWN5 = 0x01000000, // used in spell Eyes of the Beast for pet... + UNIT_FLAG_NOT_SELECTABLE = 0x02000000, + UNIT_FLAG_SKINNABLE = 0x04000000, + UNIT_FLAG_MOUNT = 0x08000000, + UNIT_FLAG_UNKNOWN17 = 0x10000000, + UNIT_FLAG_UNKNOWN6 = 0x20000000, // used in Feing Death spell + UNIT_FLAG_SHEATHE = 0x40000000 +}; + +// Value masks for UNIT_FIELD_FLAGS_2 +enum UnitFlags2 +{ + UNIT_FLAG2_FEIGN_DEATH = 0x00000001, + UNIT_FLAG2_COMPREHEND_LANG= 0x00000008, + UNIT_FLAG2_FORCE_MOVE = 0x00000040 +}; + +/// Non Player Character flags +enum NPCFlags +{ + UNIT_NPC_FLAG_NONE = 0x00000000, + UNIT_NPC_FLAG_GOSSIP = 0x00000001, // 100% + UNIT_NPC_FLAG_QUESTGIVER = 0x00000002, // guessed, probably ok + UNIT_NPC_FLAG_UNK1 = 0x00000004, + UNIT_NPC_FLAG_UNK2 = 0x00000008, + UNIT_NPC_FLAG_TRAINER = 0x00000010, // 100% + UNIT_NPC_FLAG_TRAINER_CLASS = 0x00000020, // 100% + UNIT_NPC_FLAG_TRAINER_PROFESSION = 0x00000040, // 100% + UNIT_NPC_FLAG_VENDOR = 0x00000080, // 100% + UNIT_NPC_FLAG_VENDOR_AMMO = 0x00000100, // 100%, general goods vendor + UNIT_NPC_FLAG_VENDOR_FOOD = 0x00000200, // 100% + UNIT_NPC_FLAG_VENDOR_POISON = 0x00000400, // guessed + UNIT_NPC_FLAG_VENDOR_REAGENT = 0x00000800, // 100% + UNIT_NPC_FLAG_REPAIR = 0x00001000, // 100% + UNIT_NPC_FLAG_FLIGHTMASTER = 0x00002000, // 100% + UNIT_NPC_FLAG_SPIRITHEALER = 0x00004000, // guessed + UNIT_NPC_FLAG_SPIRITGUIDE = 0x00008000, // guessed + UNIT_NPC_FLAG_INNKEEPER = 0x00010000, // 100% + UNIT_NPC_FLAG_BANKER = 0x00020000, // 100% + UNIT_NPC_FLAG_PETITIONER = 0x00040000, // 100% 0xC0000 = guild petitions, 0x40000 = arena team petitions + UNIT_NPC_FLAG_TABARDDESIGNER = 0x00080000, // 100% + UNIT_NPC_FLAG_BATTLEMASTER = 0x00100000, // 100% + UNIT_NPC_FLAG_AUCTIONEER = 0x00200000, // 100% + UNIT_NPC_FLAG_STABLEMASTER = 0x00400000, // 100% + UNIT_NPC_FLAG_GUILD_BANKER = 0x00800000, // cause client to send 997 opcode + UNIT_NPC_FLAG_UNK3 = 0x01000000, // cause client to send 1015 opcode + UNIT_NPC_FLAG_GUARD = 0x10000000, // custom flag for guards +}; + +enum MovementFlags +{ + MOVEMENTFLAG_NONE = 0x00000000, + MOVEMENTFLAG_FORWARD = 0x00000001, + MOVEMENTFLAG_BACKWARD = 0x00000002, + MOVEMENTFLAG_STRAFE_LEFT = 0x00000004, + MOVEMENTFLAG_STRAFE_RIGHT = 0x00000008, + MOVEMENTFLAG_LEFT = 0x00000010, + MOVEMENTFLAG_RIGHT = 0x00000020, + MOVEMENTFLAG_PITCH_UP = 0x00000040, + MOVEMENTFLAG_PITCH_DOWN = 0x00000080, + MOVEMENTFLAG_WALK_MODE = 0x00000100, // Walking + MOVEMENTFLAG_ONTRANSPORT = 0x00000200, // Used for flying on some creatures + MOVEMENTFLAG_LEVITATING = 0x00000400, + MOVEMENTFLAG_FLY_UNK1 = 0x00000800, + MOVEMENTFLAG_JUMPING = 0x00001000, + MOVEMENTFLAG_UNK4 = 0x00002000, + MOVEMENTFLAG_FALLING = 0x00004000, + // 0x8000, 0x10000, 0x20000, 0x40000, 0x80000, 0x100000 + MOVEMENTFLAG_SWIMMING = 0x00200000, // appears with fly flag also + MOVEMENTFLAG_FLY_UP = 0x00400000, + MOVEMENTFLAG_CAN_FLY = 0x00800000, + MOVEMENTFLAG_FLYING = 0x01000000, + MOVEMENTFLAG_FLYING2 = 0x02000000, // Actual flying mode + MOVEMENTFLAG_SPLINE = 0x04000000, // used for flight paths + MOVEMENTFLAG_SPLINE2 = 0x08000000, // used for flight paths + MOVEMENTFLAG_WATERWALKING = 0x10000000, // prevent unit from falling through water + MOVEMENTFLAG_SAFE_FALL = 0x20000000, // active rogue safe fall spell (passive) + MOVEMENTFLAG_UNK3 = 0x40000000 +}; + +enum DiminishingLevels +{ + DIMINISHING_LEVEL_1 = 0, + DIMINISHING_LEVEL_2 = 1, + DIMINISHING_LEVEL_3 = 2, + DIMINISHING_LEVEL_IMMUNE = 3 +}; + +struct DiminishingReturn +{ + DiminishingReturn(DiminishingGroup group, uint32 t, uint32 count) : DRGroup(group), hitTime(t), hitCount(count), stack(0) {} + + DiminishingGroup DRGroup:16; + uint16 stack:16; + uint32 hitTime; + uint32 hitCount; +}; + +enum MeleeHitOutcome +{ + MELEE_HIT_EVADE, MELEE_HIT_MISS, MELEE_HIT_DODGE, MELEE_HIT_BLOCK, MELEE_HIT_PARRY, + MELEE_HIT_GLANCING, MELEE_HIT_CRIT, MELEE_HIT_CRUSHING, MELEE_HIT_NORMAL, MELEE_HIT_BLOCK_CRIT +}; +struct CleanDamage +{ + CleanDamage(uint32 _damage, WeaponAttackType _attackType, MeleeHitOutcome _hitOutCome) : + damage(_damage), attackType(_attackType), hitOutCome(_hitOutCome) {} + + uint32 damage; + WeaponAttackType attackType; + MeleeHitOutcome hitOutCome; +}; + +struct UnitActionBarEntry +{ + uint32 Type; + uint32 SpellOrAction; +}; + +#define MAX_DECLINED_NAME_CASES 5 + +struct DeclinedName +{ + std::string name[MAX_DECLINED_NAME_CASES]; +}; + +enum CurrentSpellTypes +{ + CURRENT_MELEE_SPELL = 0, + CURRENT_FIRST_NON_MELEE_SPELL = 1, // just counter + CURRENT_GENERIC_SPELL = 1, + CURRENT_AUTOREPEAT_SPELL = 2, + CURRENT_CHANNELED_SPELL = 3, + CURRENT_MAX_SPELL = 4 // just counter +}; + +enum ActiveStates +{ + ACT_ENABLED = 0xC100, + ACT_DISABLED = 0x8100, + ACT_COMMAND = 0x0700, + ACT_REACTION = 0x0600, + ACT_CAST = 0x0100, + ACT_PASSIVE = 0x0000, + ACT_DECIDE = 0x0001 +}; + +enum ReactStates +{ + REACT_PASSIVE = 0, + REACT_DEFENSIVE = 1, + REACT_AGGRESSIVE = 2 +}; + +enum CommandStates +{ + COMMAND_STAY = 0, + COMMAND_FOLLOW = 1, + COMMAND_ATTACK = 2, + COMMAND_ABANDON = 3 +}; + +struct CharmSpellEntry +{ + uint16 spellId; + uint16 active; +}; + +struct CharmInfo +{ + public: + explicit CharmInfo(Unit* unit); + uint32 GetPetNumber() const { return m_petnumber; } + void SetPetNumber(uint32 petnumber, bool statwindow); + + void SetCommandState(CommandStates st) { m_CommandState = st; } + CommandStates GetCommandState() { return m_CommandState; } + bool HasCommandState(CommandStates state) { return (m_CommandState == state); } + void SetReactState(ReactStates st) { m_ReactSate = st; } + ReactStates GetReactState() { return m_ReactSate; } + bool HasReactState(ReactStates state) { return (m_ReactSate == state); } + + void InitPossessCreateSpells(); + void InitCharmCreateSpells(); + void InitPetActionBar(); + void InitEmptyActionBar(); + //return true if successful + bool AddSpellToAB(uint32 oldid, uint32 newid, ActiveStates newstate = ACT_DECIDE); + void ToggleCreatureAutocast(uint32 spellid, bool apply); + + UnitActionBarEntry* GetActionBarEntry(uint8 index) { return &(PetActionBar[index]); } + CharmSpellEntry* GetCharmSpell(uint8 index) { return &(m_charmspells[index]); } + private: + Unit* m_unit; + UnitActionBarEntry PetActionBar[10]; + CharmSpellEntry m_charmspells[4]; + CommandStates m_CommandState; + ReactStates m_ReactSate; + uint32 m_petnumber; +}; + +// for clearing special attacks +#define REACTIVE_TIMER_START 4000 + +enum ReactiveType +{ + REACTIVE_DEFENSE = 1, + REACTIVE_HUNTER_PARRY = 2, + REACTIVE_CRIT = 3, + REACTIVE_HUNTER_CRIT = 4, + REACTIVE_OVERPOWER = 5 +}; + +#define MAX_REACTIVE 6 +#define MAX_TOTEM 4 + +// delay time next attack to prevent client attack animation problems +#define ATTACK_DISPLAY_DELAY 200 + +class MANGOS_DLL_SPEC Unit : public WorldObject +{ + public: + typedef std::set AttackerSet; + typedef std::pair spellEffectPair; + typedef std::multimap< spellEffectPair, Aura*> AuraMap; + typedef std::list AuraList; + typedef std::list Diminishing; + typedef std::set AuraTypeSet; + typedef std::set ComboPointHolderSet; + + virtual ~Unit ( ); + + void AddToWorld(); + void RemoveFromWorld(); + + void CleanupsBeforeDelete(); // used in ~Creature/~Player (or before mass creature delete to remove cross-references to already deleted units) + + DiminishingLevels GetDiminishing(DiminishingGroup group); + void IncrDiminishing(DiminishingGroup group); + void ApplyDiminishingToDuration(DiminishingGroup group, int32 &duration,Unit* caster, DiminishingLevels Level); + void ApplyDiminishingAura(DiminishingGroup group, bool apply); + void ClearDiminishings() { m_Diminishing.clear(); } + + virtual void Update( uint32 time ); + + void setAttackTimer(WeaponAttackType type, uint32 time) { m_attackTimer[type] = time; } + void resetAttackTimer(WeaponAttackType type = BASE_ATTACK); + uint32 getAttackTimer(WeaponAttackType type) const { return m_attackTimer[type]; } + bool isAttackReady(WeaponAttackType type = BASE_ATTACK) const { return m_attackTimer[type] == 0; } + bool haveOffhandWeapon() const; + bool canReachWithAttack(Unit *pVictim) const; + uint32 m_extraAttacks; + + void _addAttacker(Unit *pAttacker) // must be called only from Unit::Attack(Unit*) + { + AttackerSet::iterator itr = m_attackers.find(pAttacker); + if(itr == m_attackers.end()) + m_attackers.insert(pAttacker); + } + void _removeAttacker(Unit *pAttacker) // must be called only from Unit::AttackStop() + { + AttackerSet::iterator itr = m_attackers.find(pAttacker); + if(itr != m_attackers.end()) + m_attackers.erase(itr); + } + Unit * getAttackerForHelper() // If someone wants to help, who to give them + { + if (getVictim() != NULL) + return getVictim(); + + if (!m_attackers.empty()) + return *(m_attackers.begin()); + + return NULL; + } + bool Attack(Unit *victim, bool meleeAttack); + void CastStop(uint32 except_spellid = 0); + bool AttackStop(); + void RemoveAllAttackers(); + AttackerSet const& getAttackers() const { return m_attackers; } + bool isAttackingPlayer() const; + Unit* getVictim() const { return m_attacking; } + void CombatStop(bool cast = false); + void CombatStopWithPets(bool cast = false); + Unit* SelectNearbyTarget() const; + + void addUnitState(uint32 f) { m_state |= f; } + bool hasUnitState(const uint32 f) const { return (m_state & f); } + void clearUnitState(uint32 f) { m_state &= ~f; } + bool CanFreeMove() const + { + return !hasUnitState(UNIT_STAT_CONFUSED | UNIT_STAT_FLEEING | UNIT_STAT_IN_FLIGHT | + UNIT_STAT_ROOT | UNIT_STAT_STUNDED | UNIT_STAT_DISTRACTED ) && GetOwnerGUID()==0; + } + + uint32 getLevel() const { return GetUInt32Value(UNIT_FIELD_LEVEL); } + virtual uint32 getLevelForTarget(Unit const* /*target*/) const { return getLevel(); } + void SetLevel(uint32 lvl); + uint8 getRace() const { return GetByteValue(UNIT_FIELD_BYTES_0, 0); } + uint32 getRaceMask() const { return 1 << (getRace()-1); } + uint8 getClass() const { return GetByteValue(UNIT_FIELD_BYTES_0, 1); } + uint32 getClassMask() const { return 1 << (getClass()-1); } + uint8 getGender() const { return GetByteValue(UNIT_FIELD_BYTES_0, 2); } + + float GetStat(Stats stat) const { return float(GetUInt32Value(UNIT_FIELD_STAT0+stat)); } + void SetStat(Stats stat, int32 val) { SetStatInt32Value(UNIT_FIELD_STAT0+stat, val); } + uint32 GetArmor() const { return GetResistance(SPELL_SCHOOL_NORMAL) ; } + void SetArmor(int32 val) { SetResistance(SPELL_SCHOOL_NORMAL, val); } + + uint32 GetResistance(SpellSchools school) const { return GetUInt32Value(UNIT_FIELD_RESISTANCES+school); } + void SetResistance(SpellSchools school, int32 val) { SetStatInt32Value(UNIT_FIELD_RESISTANCES+school,val); } + + uint32 GetHealth() const { return GetUInt32Value(UNIT_FIELD_HEALTH); } + uint32 GetMaxHealth() const { return GetUInt32Value(UNIT_FIELD_MAXHEALTH); } + void SetHealth( uint32 val); + void SetMaxHealth(uint32 val); + int32 ModifyHealth(int32 val); + + Powers getPowerType() const { return Powers(GetByteValue(UNIT_FIELD_BYTES_0, 3)); } + void setPowerType(Powers power); + uint32 GetPower( Powers power) const { return GetUInt32Value(UNIT_FIELD_POWER1 +power); } + uint32 GetMaxPower(Powers power) const { return GetUInt32Value(UNIT_FIELD_MAXPOWER1+power); } + void SetPower( Powers power, uint32 val); + void SetMaxPower(Powers power, uint32 val); + int32 ModifyPower(Powers power, int32 val); + void ApplyPowerMod(Powers power, uint32 val, bool apply); + void ApplyMaxPowerMod(Powers power, uint32 val, bool apply); + + uint32 GetAttackTime(WeaponAttackType att) const { return (uint32)(GetFloatValue(UNIT_FIELD_BASEATTACKTIME+att)/m_modAttackSpeedPct[att]); } + void SetAttackTime(WeaponAttackType att, uint32 val) { SetFloatValue(UNIT_FIELD_BASEATTACKTIME+att,val*m_modAttackSpeedPct[att]); } + void ApplyAttackTimePercentMod(WeaponAttackType att,float val, bool apply); + void ApplyCastTimePercentMod(float val, bool apply); + + // faction template id + uint32 getFaction() const { return GetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE); } + void setFaction(uint32 faction) { SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE, faction ); } + FactionTemplateEntry const* getFactionTemplateEntry() const; + bool IsHostileTo(Unit const* unit) const; + bool IsHostileToPlayers() const; + bool IsFriendlyTo(Unit const* unit) const; + bool IsNeutralToAll() const; + bool IsContestedGuard() const + { + if(FactionTemplateEntry const* entry = getFactionTemplateEntry()) + return entry->IsContestedGuardFaction(); + + return false; + } + bool IsPvP() const { return HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP); } + void SetPvP(bool state) { if(state) SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP); else RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP); } + uint32 GetCreatureType() const; + uint32 GetCreatureTypeMask() const + { + uint32 creatureType = GetCreatureType(); + return (creatureType >= 1) ? (1 << (creatureType - 1)) : 0; + } + + uint8 getStandState() const { return GetByteValue(UNIT_FIELD_BYTES_1, 0); } + bool IsSitState() const; + bool IsStandState() const; + void SetStandState(uint8 state); + + bool IsMounted() const { return HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_MOUNT ); } + uint32 GetMountID() const { return GetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID); } + void Mount(uint32 mount); + void Unmount(); + + uint16 GetMaxSkillValueForLevel(Unit const* target = NULL) const { return (target ? getLevelForTarget(target) : getLevel()) * 5; } + uint32 DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDamage, DamageEffectType damagetype, SpellSchoolMask damageSchoolMask, SpellEntry const *spellProto, bool durabilityLoss); + void DealFlatDamage(Unit *pVictim, SpellEntry const *spellInfo, uint32 *damage, CleanDamage *cleanDamage, bool *crit = false, bool isTriggeredSpell = false); + void DoAttackDamage(Unit *pVictim, uint32 *damage, CleanDamage *cleanDamage, uint32 *blocked_amount, SpellSchoolMask damageSchoolMask, uint32 *hitInfo, VictimState *victimState, uint32 *absorbDamage, uint32 *resistDamage, WeaponAttackType attType, SpellEntry const *spellCasted = NULL, bool isTriggeredSpell = false); + + void CastMeleeProcDamageAndSpell(Unit* pVictim, uint32 damage, SpellSchoolMask damageSchoolMask, WeaponAttackType attType, MeleeHitOutcome outcome, SpellEntry const *spellCasted = NULL, bool isTriggeredSpell = false); + void ProcDamageAndSpell(Unit *pVictim, uint32 procAttacker, uint32 procVictim, uint32 damage = 0, SpellSchoolMask damageSchoolMask = SPELL_SCHOOL_MASK_NONE, SpellEntry const *procSpell = NULL, bool isTriggeredSpell = false, WeaponAttackType attType = BASE_ATTACK); + void HandleEmoteCommand(uint32 anim_id); + void AttackerStateUpdate (Unit *pVictim, WeaponAttackType attType = BASE_ATTACK, bool extra = false ); + + float MeleeMissChanceCalc(const Unit *pVictim, WeaponAttackType attType) const; + SpellMissInfo MagicSpellHitResult(Unit *pVictim, SpellEntry const *spell); + SpellMissInfo SpellHitResult(Unit *pVictim, SpellEntry const *spell, bool canReflect = false); + + float GetUnitDodgeChance() const; + float GetUnitParryChance() const; + float GetUnitBlockChance() const; + float GetUnitCriticalChance(WeaponAttackType attackType, const Unit *pVictim) const; + + virtual uint32 GetShieldBlockValue() const =0; + uint32 GetUnitMeleeSkill(Unit const* target = NULL) const { return (target ? getLevelForTarget(target) : getLevel()) * 5; } + uint32 GetDefenseSkillValue(Unit const* target = NULL) const; + uint32 GetWeaponSkillValue(WeaponAttackType attType, Unit const* target = NULL) const; + float GetWeaponProcChance() const; + float GetPPMProcChance(uint32 WeaponSpeed, float PPM) const; + MeleeHitOutcome RollPhysicalOutcomeAgainst (const Unit *pVictim, WeaponAttackType attType, SpellEntry const *spellInfo); + MeleeHitOutcome RollMeleeOutcomeAgainst (const Unit *pVictim, WeaponAttackType attType) const; + MeleeHitOutcome RollMeleeOutcomeAgainst (const Unit *pVictim, WeaponAttackType attType, int32 crit_chance, int32 miss_chance, int32 dodge_chance, int32 parry_chance, int32 block_chance, bool SpellCasted ) const; + + bool isVendor() const { return HasFlag( UNIT_NPC_FLAGS, UNIT_NPC_FLAG_VENDOR ); } + bool isTrainer() const { return HasFlag( UNIT_NPC_FLAGS, UNIT_NPC_FLAG_TRAINER ); } + bool isQuestGiver() const { return HasFlag( UNIT_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER ); } + bool isGossip() const { return HasFlag( UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP ); } + bool isTaxi() const { return HasFlag( UNIT_NPC_FLAGS, UNIT_NPC_FLAG_FLIGHTMASTER ); } + bool isGuildMaster() const { return HasFlag( UNIT_NPC_FLAGS, UNIT_NPC_FLAG_PETITIONER ); } + bool isBattleMaster() const { return HasFlag( UNIT_NPC_FLAGS, UNIT_NPC_FLAG_BATTLEMASTER ); } + bool isBanker() const { return HasFlag( UNIT_NPC_FLAGS, UNIT_NPC_FLAG_BANKER ); } + bool isInnkeeper() const { return HasFlag( UNIT_NPC_FLAGS, UNIT_NPC_FLAG_INNKEEPER ); } + bool isSpiritHealer() const { return HasFlag( UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPIRITHEALER ); } + bool isSpiritGuide() const { return HasFlag( UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPIRITGUIDE ); } + bool isTabardDesigner()const { return HasFlag( UNIT_NPC_FLAGS, UNIT_NPC_FLAG_TABARDDESIGNER ); } + bool isAuctioner() const { return HasFlag( UNIT_NPC_FLAGS, UNIT_NPC_FLAG_AUCTIONEER ); } + bool isArmorer() const { return HasFlag( UNIT_NPC_FLAGS, UNIT_NPC_FLAG_REPAIR ); } + bool isServiceProvider() const + { + return HasFlag( UNIT_NPC_FLAGS, + UNIT_NPC_FLAG_VENDOR | UNIT_NPC_FLAG_TRAINER | UNIT_NPC_FLAG_FLIGHTMASTER | + UNIT_NPC_FLAG_PETITIONER | UNIT_NPC_FLAG_BATTLEMASTER | UNIT_NPC_FLAG_BANKER | + UNIT_NPC_FLAG_INNKEEPER | UNIT_NPC_FLAG_GUARD | UNIT_NPC_FLAG_SPIRITHEALER | + UNIT_NPC_FLAG_SPIRITGUIDE | UNIT_NPC_FLAG_TABARDDESIGNER | UNIT_NPC_FLAG_AUCTIONEER ); + } + bool isSpiritService() const { return HasFlag( UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPIRITHEALER | UNIT_NPC_FLAG_SPIRITGUIDE ); } + + //Need fix or use this + bool isGuard() const { return HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GUARD); } + + bool isInFlight() const { return hasUnitState(UNIT_STAT_IN_FLIGHT); } + + bool isInCombat() const { return HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IN_COMBAT); } + void SetInCombatState(bool PvP); + void SetInCombatWith(Unit* enemy); + void ClearInCombat(); + uint32 GetCombatTimer() const { return m_CombatTimer; } + + bool HasAuraType(AuraType auraType) const; + bool HasAura(uint32 spellId, uint32 effIndex) const + { return m_Auras.find(spellEffectPair(spellId, effIndex)) != m_Auras.end(); } + + bool virtual HasSpell(uint32 /*spellID*/) const { return false; } + + bool HasStealthAura() const { return HasAuraType(SPELL_AURA_MOD_STEALTH); } + bool HasInvisibilityAura() const { return HasAuraType(SPELL_AURA_MOD_INVISIBILITY); } + bool isFeared() const { return HasAuraType(SPELL_AURA_MOD_FEAR); } + bool isInRoots() const { return HasAuraType(SPELL_AURA_MOD_ROOT); } + bool IsPolymorphed() const; + + bool isFrozen() const; + + void RemoveSpellbyDamageTaken(AuraType auraType, uint32 damage); + + bool isTargetableForAttack() const; + virtual bool IsInWater() const; + virtual bool IsUnderWater() const; + bool isInAccessablePlaceFor(Creature const* c) const; + + void SendHealSpellLog(Unit *pVictim, uint32 SpellID, uint32 Damage, bool critical = false); + void SendEnergizeSpellLog(Unit *pVictim, uint32 SpellID, uint32 Damage,Powers powertype, bool critical = false); + uint32 SpellNonMeleeDamageLog(Unit *pVictim, uint32 spellID, uint32 damage, bool isTriggeredSpell = false, bool useSpellDamage = true); + void CastSpell(Unit* Victim, uint32 spellId, bool triggered, Item *castItem = NULL, Aura* triggredByAura = NULL, uint64 originalCaster = 0); + void CastSpell(Unit* Victim,SpellEntry const *spellInfo, bool triggered, Item *castItem= NULL, Aura* triggredByAura = NULL, uint64 originalCaster = 0); + void CastCustomSpell(Unit* Victim, uint32 spellId, int32 const* bp0, int32 const* bp1, int32 const* bp2, bool triggered, Item *castItem= NULL, Aura* triggredByAura = NULL, uint64 originalCaster = 0); + void CastCustomSpell(Unit* Victim,SpellEntry const *spellInfo, int32 const* bp0, int32 const* bp1, int32 const* bp2, bool triggered, Item *castItem= NULL, Aura* triggredByAura = NULL, uint64 originalCaster = 0); + void CastSpell(float x, float y, float z, uint32 spellId, bool triggered, Item *castItem = NULL, Aura* triggredByAura = NULL, uint64 originalCaster = 0); + void CastSpell(float x, float y, float z, SpellEntry const *spellInfo, bool triggered, Item *castItem = NULL, Aura* triggredByAura = NULL, uint64 originalCaster = 0); + + bool IsDamageToThreatSpell(SpellEntry const * spellInfo) const; + + void DeMorph(); + + void SendAttackStateUpdate(uint32 HitInfo, Unit *target, uint8 SwingType, SpellSchoolMask damageSchoolMask, uint32 Damage, uint32 AbsorbDamage, uint32 Resist, VictimState TargetState, uint32 BlockedAmount); + void SendSpellNonMeleeDamageLog(Unit *target,uint32 SpellID,uint32 Damage, SpellSchoolMask damageSchoolMask,uint32 AbsorbedDamage, uint32 Resist,bool PhysicalDamage, uint32 Blocked, bool CriticalHit = false); + void SendSpellMiss(Unit *target, uint32 spellID, SpellMissInfo missInfo); + + void SendMonsterMove(float NewPosX, float NewPosY, float NewPosZ, uint8 type, uint32 MovementFlags, uint32 Time, Player* player = NULL); + void SendMonsterMoveByPath(Path const& path, uint32 start, uint32 end, uint32 MovementFlags); + void SendMonsterMoveWithSpeed(float x, float y, float z, uint32 MovementFlags, uint32 transitTime = 0, Player* player = NULL); + void SendMonsterMoveWithSpeedToCurrentDestination(Player* player = NULL); + + virtual void MoveOutOfRange(Player &) { }; + + bool isAlive() const { return (m_deathState == ALIVE); }; + bool isDead() const { return ( m_deathState == DEAD || m_deathState == CORPSE ); }; + DeathState getDeathState() { return m_deathState; }; + virtual void setDeathState(DeathState s); // overwrited in Creature/Player/Pet + + uint64 const& GetOwnerGUID() const { return GetUInt64Value(UNIT_FIELD_SUMMONEDBY); } + uint64 GetPetGUID() const { return GetUInt64Value(UNIT_FIELD_SUMMON); } + uint64 GetCharmerGUID() const { return GetUInt64Value(UNIT_FIELD_CHARMEDBY); } + uint64 GetCharmGUID() const { return GetUInt64Value(UNIT_FIELD_CHARM); } + void SetCharmerGUID(uint64 owner) { SetUInt64Value(UNIT_FIELD_CHARMEDBY, owner); } + + uint64 GetCharmerOrOwnerGUID() const { return GetCharmerGUID() ? GetCharmerGUID() : GetOwnerGUID(); } + uint64 GetCharmerOrOwnerOrOwnGUID() const + { + if(uint64 guid = GetCharmerOrOwnerGUID()) + return guid; + return GetGUID(); + } + bool isCharmedOwnedByPlayerOrPlayer() const { return IS_PLAYER_GUID(GetCharmerOrOwnerOrOwnGUID()); } + + Player* GetSpellModOwner(); + + Unit* GetOwner() const; + Pet* GetPet() const; + Unit* GetCharmer() const; + Unit* GetCharm() const; + Unit* GetCharmerOrOwner() const { return GetCharmerGUID() ? GetCharmer() : GetOwner(); } + Unit* GetCharmerOrOwnerOrSelf() + { + if(Unit* u = GetCharmerOrOwner()) + return u; + + return this; + } + Player* GetCharmerOrOwnerPlayerOrPlayerItself(); + + void SetPet(Pet* pet); + void SetCharm(Unit* pet); + bool isCharmed() const { return GetCharmerGUID() != 0; } + + CharmInfo* GetCharmInfo() { return m_charmInfo; } + CharmInfo* InitCharmInfo(Unit* charm); + + bool AddAura(Aura *aur); + + void RemoveAura(AuraMap::iterator &i, AuraRemoveMode mode = AURA_REMOVE_BY_DEFAULT); + void RemoveAura(uint32 spellId, uint32 effindex, Aura* except = NULL); + void RemoveSingleAuraFromStack(uint32 spellId, uint32 effindex); + void RemoveAurasDueToSpell(uint32 spellId, Aura* except = NULL); + void RemoveAurasDueToItemSpell(Item* castItem,uint32 spellId); + void RemoveAurasDueToSpellByDispel(uint32 spellId, uint64 casterGUID, Unit *dispeler); + void RemoveAurasDueToSpellBySteal(uint32 spellId, uint64 casterGUID, Unit *stealer); + void RemoveAurasDueToSpellByCancel(uint32 spellId); + void RemoveNotOwnSingleTargetAuras(); + + void RemoveSpellsCausingAura(AuraType auraType); + void RemoveRankAurasDueToSpell(uint32 spellId); + bool RemoveNoStackAurasDueToAura(Aura *Aur); + void RemoveAurasWithInterruptFlags(uint32 flags); + void RemoveAurasWithDispelType( DispelType type ); + + void RemoveAllAuras(); + void RemoveAllAurasOnDeath(); + void DelayAura(uint32 spellId, uint32 effindex, int32 delaytime); + + float GetResistanceBuffMods(SpellSchools school, bool positive) const { return GetFloatValue(positive ? UNIT_FIELD_RESISTANCEBUFFMODSPOSITIVE+school : UNIT_FIELD_RESISTANCEBUFFMODSNEGATIVE+school ); } + void SetResistanceBuffMods(SpellSchools school, bool positive, float val) { SetFloatValue(positive ? UNIT_FIELD_RESISTANCEBUFFMODSPOSITIVE+school : UNIT_FIELD_RESISTANCEBUFFMODSNEGATIVE+school,val); } + void ApplyResistanceBuffModsMod(SpellSchools school, bool positive, float val, bool apply) { ApplyModSignedFloatValue(positive ? UNIT_FIELD_RESISTANCEBUFFMODSPOSITIVE+school : UNIT_FIELD_RESISTANCEBUFFMODSNEGATIVE+school, val, apply); } + void ApplyResistanceBuffModsPercentMod(SpellSchools school, bool positive, float val, bool apply) { ApplyPercentModFloatValue(positive ? UNIT_FIELD_RESISTANCEBUFFMODSPOSITIVE+school : UNIT_FIELD_RESISTANCEBUFFMODSNEGATIVE+school, val, apply); } + void InitStatBuffMods() + { + for(int i = STAT_STRENGTH; i < MAX_STATS; ++i) SetFloatValue(UNIT_FIELD_POSSTAT0+i, 0); + for(int i = STAT_STRENGTH; i < MAX_STATS; ++i) SetFloatValue(UNIT_FIELD_NEGSTAT0+i, 0); + } + void ApplyStatBuffMod(Stats stat, float val, bool apply) { ApplyModSignedFloatValue((val > 0 ? UNIT_FIELD_POSSTAT0+stat : UNIT_FIELD_NEGSTAT0+stat), val, apply); } + void ApplyStatPercentBuffMod(Stats stat, float val, bool apply) + { + ApplyPercentModFloatValue(UNIT_FIELD_POSSTAT0+stat, val, apply); + ApplyPercentModFloatValue(UNIT_FIELD_NEGSTAT0+stat, val, apply); + } + void SetCreateStat(Stats stat, float val) { m_createStats[stat] = val; } + void SetCreateHealth(uint32 val) { SetUInt32Value(UNIT_FIELD_BASE_HEALTH, val); } + uint32 GetCreateHealth() const { return GetUInt32Value(UNIT_FIELD_BASE_HEALTH); } + void SetCreateMana(uint32 val) { SetUInt32Value(UNIT_FIELD_BASE_MANA, val); } + uint32 GetCreateMana() const { return GetUInt32Value(UNIT_FIELD_BASE_MANA); } + uint32 GetCreatePowers(Powers power) const; + float GetPosStat(Stats stat) const { return GetFloatValue(UNIT_FIELD_POSSTAT0+stat); } + float GetNegStat(Stats stat) const { return GetFloatValue(UNIT_FIELD_NEGSTAT0+stat); } + float GetCreateStat(Stats stat) const { return m_createStats[stat]; } + + void SetCurrentCastedSpell(Spell * pSpell); + virtual void ProhibitSpellScholl(SpellSchoolMask /*idSchoolMask*/, uint32 /*unTimeMs*/ ) { } + void InterruptSpell(uint32 spellType, bool withDelayed = true); + + // set withDelayed to true to account delayed spells as casted + // delayed+channeled spells are always accounted as casted + // we can skip channeled or delayed checks using flags + bool IsNonMeleeSpellCasted(bool withDelayed, bool skipChanneled = false, bool skipAutorepeat = false) const; + + // set withDelayed to true to interrupt delayed spells too + // delayed+channeled spells are always interrupted + void InterruptNonMeleeSpells(bool withDelayed, uint32 spellid = 0); + + Spell* FindCurrentSpellBySpellId(uint32 spell_id) const; + + Spell* m_currentSpells[CURRENT_MAX_SPELL]; + + uint32 m_addDmgOnce; + uint64 m_TotemSlot[MAX_TOTEM]; + uint64 m_ObjectSlot[4]; + uint32 m_detectInvisibilityMask; + uint32 m_invisibilityMask; + uint32 m_ShapeShiftFormSpellId; + ShapeshiftForm m_form; + float m_modMeleeHitChance; + float m_modRangedHitChance; + float m_modSpellHitChance; + int32 m_baseSpellCritChance; + + float m_threatModifier[MAX_SPELL_SCHOOL]; + float m_modAttackSpeedPct[3]; + + // Event handler + EventProcessor m_Events; + + // stat system + bool HandleStatModifier(UnitMods unitMod, UnitModifierType modifierType, float amount, bool apply); + void SetModifierValue(UnitMods unitMod, UnitModifierType modifierType, float value) { m_auraModifiersGroup[unitMod][modifierType] = value; } + float GetModifierValue(UnitMods unitMod, UnitModifierType modifierType) const; + float GetTotalStatValue(Stats stat) const; + float GetTotalAuraModValue(UnitMods unitMod) const; + SpellSchools GetSpellSchoolByAuraGroup(UnitMods unitMod) const; + Stats GetStatByAuraGroup(UnitMods unitMod) const; + Powers GetPowerTypeByAuraGroup(UnitMods unitMod) const; + bool CanModifyStats() const { return m_canModifyStats; } + void SetCanModifyStats(bool modifyStats) { m_canModifyStats = modifyStats; } + virtual bool UpdateStats(Stats stat) = 0; + virtual bool UpdateAllStats() = 0; + virtual void UpdateResistances(uint32 school) = 0; + virtual void UpdateArmor() = 0; + virtual void UpdateMaxHealth() = 0; + virtual void UpdateMaxPower(Powers power) = 0; + virtual void UpdateAttackPowerAndDamage(bool ranged = false) = 0; + virtual void UpdateDamagePhysical(WeaponAttackType attType) = 0; + float GetTotalAttackPowerValue(WeaponAttackType attType) const; + float GetWeaponDamageRange(WeaponAttackType attType ,WeaponDamageRange type) const; + void SetBaseWeaponDamage(WeaponAttackType attType ,WeaponDamageRange damageRange, float value) { m_weaponDamage[attType][damageRange] = value; } + + bool isInFront(Unit const* target,float distance, float arc = M_PI) const; + void SetInFront(Unit const* target); + bool isInBack(Unit const* target, float distance, float arc = M_PI) const; + + // Visibility system + UnitVisibility GetVisibility() const { return m_Visibility; } + void SetVisibility(UnitVisibility x); + + // common function for visibility checks for player/creatures with detection code + bool isVisibleForOrDetect(Unit const* u, bool detect, bool inVisibleList = false) const; + bool canDetectInvisibilityOf(Unit const* u) const; + + // virtual functions for all world objects types + bool isVisibleForInState(Player const* u, bool inVisibleList) const; + // function for low level grid visibility checks in player/creature cases + virtual bool IsVisibleInGridForPlayer(Player* pl) const = 0; + + bool waterbreath; + AuraList & GetSingleCastAuras() { return m_scAuras; } + AuraList const& GetSingleCastAuras() const { return m_scAuras; } + SpellImmuneList m_spellImmune[MAX_SPELL_IMMUNITY]; + + // Threat related methodes + bool CanHaveThreatList() const; + void AddThreat(Unit* pVictim, float threat, SpellSchoolMask schoolMask = SPELL_SCHOOL_MASK_NORMAL, SpellEntry const *threatSpell = NULL); + float ApplyTotalThreatModifier(float threat, SpellSchoolMask schoolMask = SPELL_SCHOOL_MASK_NORMAL); + void DeleteThreatList(); + bool SelectHostilTarget(); + void TauntApply(Unit* pVictim); + void TauntFadeOut(Unit *taunter); + ThreatManager& getThreatManager() { return m_ThreatManager; } + void addHatedBy(HostilReference* pHostilReference) { m_HostilRefManager.insertFirst(pHostilReference); }; + void removeHatedBy(HostilReference* /*pHostilReference*/ ) { /* nothing to do yet */ } + HostilRefManager& getHostilRefManager() { return m_HostilRefManager; } + + Aura* GetAura(uint32 spellId, uint32 effindex); + AuraMap & GetAuras() { return m_Auras; } + AuraMap const& GetAuras() const { return m_Auras; } + AuraList const& GetAurasByType(AuraType type) const { return m_modAuras[type]; } + void ApplyAuraProcTriggerDamage(Aura* aura, bool apply); + + int32 GetTotalAuraModifier(AuraType auratype) const; + float GetTotalAuraMultiplier(AuraType auratype) const; + int32 GetMaxPositiveAuraModifier(AuraType auratype) const; + int32 GetMaxNegativeAuraModifier(AuraType auratype) const; + + int32 GetTotalAuraModifierByMiscMask(AuraType auratype, uint32 misc_mask) const; + float GetTotalAuraMultiplierByMiscMask(AuraType auratype, uint32 misc_mask) const; + int32 GetMaxPositiveAuraModifierByMiscMask(AuraType auratype, uint32 misc_mask) const; + int32 GetMaxNegativeAuraModifierByMiscMask(AuraType auratype, uint32 misc_mask) const; + + int32 GetTotalAuraModifierByMiscValue(AuraType auratype, int32 misc_value) const; + float GetTotalAuraMultiplierByMiscValue(AuraType auratype, int32 misc_value) const; + int32 GetMaxPositiveAuraModifierByMiscValue(AuraType auratype, int32 misc_value) const; + int32 GetMaxNegativeAuraModifierByMiscValue(AuraType auratype, int32 misc_value) const; + + Aura* GetDummyAura(uint32 spell_id) const; + + uint32 GetDisplayId() { return GetUInt32Value(UNIT_FIELD_DISPLAYID); } + void SetDisplayId(uint32 modelId); + uint32 GetNativeDisplayId() { return GetUInt32Value(UNIT_FIELD_NATIVEDISPLAYID); } + void SetNativeDisplayId(uint32 modelId) { SetUInt32Value(UNIT_FIELD_NATIVEDISPLAYID, modelId); } + void setTransForm(uint32 spellid) { m_transform = spellid;} + uint32 getTransForm() const { return m_transform;} + void AddDynObject(DynamicObject* dynObj); + void RemoveDynObject(uint32 spellid); + void RemoveDynObjectWithGUID(uint64 guid) { m_dynObjGUIDs.remove(guid); } + void RemoveAllDynObjects(); + void AddGameObject(GameObject* gameObj); + void RemoveGameObject(GameObject* gameObj, bool del); + void RemoveGameObject(uint32 spellid, bool del); + void RemoveAllGameObjects(); + DynamicObject *GetDynObject(uint32 spellId, uint32 effIndex); + DynamicObject *GetDynObject(uint32 spellId); + uint32 CalculateDamage(WeaponAttackType attType, bool normalized); + float GetAPMultiplier(WeaponAttackType attType, bool normalized); + void ModifyAuraState(AuraState flag, bool apply); + bool HasAuraState(AuraState flag) const { return HasFlag(UNIT_FIELD_AURASTATE, 1<<(flag-1)); } + void UnsummonAllTotems(); + int32 SpellBaseDamageBonus(SpellSchoolMask schoolMask); + int32 SpellBaseHealingBonus(SpellSchoolMask schoolMask); + int32 SpellBaseDamageBonusForVictim(SpellSchoolMask schoolMask, Unit *pVictim); + int32 SpellBaseHealingBonusForVictim(SpellSchoolMask schoolMask, Unit *pVictim); + uint32 SpellDamageBonus(Unit *pVictim, SpellEntry const *spellProto, uint32 damage, DamageEffectType damagetype); + uint32 SpellHealingBonus(SpellEntry const *spellProto, uint32 healamount, DamageEffectType damagetype, Unit *pVictim); + bool isSpellCrit(Unit *pVictim, SpellEntry const *spellProto, SpellSchoolMask schoolMask, WeaponAttackType attackType); + uint32 SpellCriticalBonus(SpellEntry const *spellProto, uint32 damage, Unit *pVictim); + + void SetLastManaUse(uint32 spellCastTime) { m_lastManaUse = spellCastTime; } + bool IsUnderLastManaUseEffect() const; + + void SetContestedPvP(Player *attackedPlayer = NULL); + + void MeleeDamageBonus(Unit *pVictim, uint32 *damage, WeaponAttackType attType, SpellEntry const *spellProto = NULL); + uint32 GetCastingTimeForBonus( SpellEntry const *spellProto, DamageEffectType damagetype, uint32 CastingTime ); + + void ApplySpellImmune(uint32 spellId, uint32 op, uint32 type, bool apply); + void ApplySpellDispelImmunity(const SpellEntry * spellProto, DispelType type, bool apply); + virtual bool IsImmunedToSpell(SpellEntry const* spellInfo, bool useCharges = false); + // redefined in Creature + bool IsImmunedToDamage(SpellSchoolMask meleeSchoolMask, bool useCharges = false); + virtual bool IsImmunedToSpellEffect(uint32 effect, uint32 mechanic) const; + // redefined in Creature + + uint32 CalcArmorReducedDamage(Unit* pVictim, const uint32 damage); + void CalcAbsorbResist(Unit *pVictim, SpellSchoolMask schoolMask, DamageEffectType damagetype, const uint32 damage, uint32 *absorb, uint32 *resist); + + void UpdateSpeed(UnitMoveType mtype, bool forced); + float GetSpeed( UnitMoveType mtype ) const; + float GetSpeedRate( UnitMoveType mtype ) const { return m_speed_rate[mtype]; } + void SetSpeed(UnitMoveType mtype, float rate, bool forced = false); + + void SetHover(bool on); + bool isHover() const { return HasAuraType(SPELL_AURA_HOVER); } + + void _RemoveAllAuraMods(); + void _ApplyAllAuraMods(); + + int32 CalculateSpellDamage(SpellEntry const* spellProto, uint8 effect_index, int32 basePoints, Unit const* target); + int32 CalculateSpellDuration(SpellEntry const* spellProto, uint8 effect_index, Unit const* target); + float CalculateLevelPenalty(SpellEntry const* spellProto) const; + + void addFollower(FollowerReference* pRef) { m_FollowingRefManager.insertFirst(pRef); } + void removeFollower(FollowerReference* /*pRef*/ ) { /* nothing to do yet */ } + static Unit* GetUnit(WorldObject& object, uint64 guid); + + MotionMaster* GetMotionMaster() { return &i_motionMaster; } + + bool IsStopped() const { return !(hasUnitState(UNIT_STAT_MOVING)); } + void StopMoving(); + + void AddUnitMovementFlag(uint32 f) { m_unit_movement_flags |= f; } + void RemoveUnitMovementFlag(uint32 f) + { + uint32 oldval = m_unit_movement_flags; + m_unit_movement_flags = oldval & ~f; + } + uint32 HasUnitMovementFlag(uint32 f) const { return m_unit_movement_flags & f; } + uint32 GetUnitMovementFlags() const { return m_unit_movement_flags; } + void SetUnitMovementFlags(uint32 f) { m_unit_movement_flags = f; } + + void SetFeared(bool apply, uint64 casterGUID = 0, uint32 spellID = 0); + void SetConfused(bool apply, uint64 casterGUID = 0, uint32 spellID = 0); + + void AddComboPointHolder(uint32 lowguid) { m_ComboPointHolders.insert(lowguid); } + void RemoveComboPointHolder(uint32 lowguid) { m_ComboPointHolders.erase(lowguid); } + void ClearComboPointHolders(); + + ///----------Pet responses methods----------------- + void SendPetCastFail(uint32 spellid, uint8 msg); + void SendPetActionFeedback (uint8 msg); + void SendPetTalk (uint32 pettalk); + void SendPetSpellCooldown (uint32 spellid, time_t cooltime); + void SendPetClearCooldown (uint32 spellid); + void SendPetAIReaction(uint64 guid); + ///----------End of Pet responses methods---------- + + void propagateSpeedChange() { GetMotionMaster()->propagateSpeedChange(); } + + // reactive attacks + void ClearAllReactives(); + void StartReactiveTimer( ReactiveType reactive ) { m_reactiveTimer[reactive] = REACTIVE_TIMER_START;} + void UpdateReactives(uint32 p_time); + + // group updates + void UpdateAuraForGroup(uint8 slot); + + // pet auras + typedef std::set PetAuraSet; + PetAuraSet m_petAuras; + void AddPetAura(PetAura const* petSpell); + void RemovePetAura(PetAura const* petSpell); + + protected: + explicit Unit (); + + void _UpdateSpells(uint32 time); + + void _UpdateAutoRepeatSpell(); + bool m_AutoRepeatFirstCast; + + uint32 m_attackTimer[MAX_ATTACK]; + + float m_createStats[MAX_STATS]; + + AttackerSet m_attackers; + Unit* m_attacking; + + DeathState m_deathState; + + AuraMap m_Auras; + + std::list m_scAuras; // casted singlecast auras + + typedef std::list DynObjectGUIDs; + DynObjectGUIDs m_dynObjGUIDs; + + std::list m_gameObj; + bool m_isSorted; + uint32 m_transform; + uint32 m_removedAuras; + + AuraList m_modAuras[TOTAL_AURAS]; + float m_auraModifiersGroup[UNIT_MOD_END][MODIFIER_TYPE_END]; + float m_weaponDamage[MAX_ATTACK][2]; + bool m_canModifyStats; + //std::list< spellEffectPair > AuraSpells[TOTAL_AURAS]; // TODO: use this if ok for mem + + float m_speed_rate[MAX_MOVE_TYPE]; + + CharmInfo *m_charmInfo; + + virtual SpellSchoolMask GetMeleeDamageSchoolMask() const; + + MotionMaster i_motionMaster; + uint32 m_unit_movement_flags; + + uint32 m_reactiveTimer[MAX_REACTIVE]; + + private: + void SendAttackStop(Unit* victim); // only from AttackStop(Unit*) + void SendAttackStart(Unit* pVictim); // only from Unit::AttackStart(Unit*) + + void ProcDamageAndSpellFor( bool isVictim, Unit * pTarget, uint32 procFlag, AuraTypeSet const& procAuraTypes, WeaponAttackType attType, SpellEntry const * procSpell, uint32 damage, SpellSchoolMask damageSchoolMask ); + bool HandleDummyAuraProc(Unit *pVictim, SpellEntry const *spellProto, uint32 effIndex, uint32 damage, Aura* triggredByAura, SpellEntry const * procSpell, uint32 procFlag,uint32 cooldown); + bool HandleProcTriggerSpell(Unit *pVictim,uint32 damage, Aura* triggredByAura, SpellEntry const *procSpell, uint32 procFlags,WeaponAttackType attType,uint32 cooldown); + bool HandleHasteAuraProc(Unit *pVictim, SpellEntry const *spellProto, uint32 effIndex, uint32 damage, Aura* triggredByAura, SpellEntry const * procSpell, uint32 procFlag,uint32 cooldown); + bool HandleOverrideClassScriptAuraProc(Unit *pVictim, int32 scriptId, uint32 damage, Aura* triggredByAura, SpellEntry const *procSpell,uint32 cooldown); + uint32 m_state; // Even derived shouldn't modify + uint32 m_CombatTimer; + uint32 m_lastManaUse; // msecs + + UnitVisibility m_Visibility; + + Diminishing m_Diminishing; + // Manage all Units threatening us + ThreatManager m_ThreatManager; + // Manage all Units that are threatened by us + HostilRefManager m_HostilRefManager; + + FollowerRefManager m_FollowingRefManager; + + ComboPointHolderSet m_ComboPointHolders; +}; +#endif diff --git a/src/game/WaypointMovementGenerator.cpp b/src/game/WaypointMovementGenerator.cpp index 0389e2ebc4b..48f739fa6a1 100644 --- a/src/game/WaypointMovementGenerator.cpp +++ b/src/game/WaypointMovementGenerator.cpp @@ -1,648 +1,652 @@ -/* - * Copyright (C) 2005-2008 MaNGOS - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* -creature_movement Table - -alter table creature_movement add `text1` varchar(255) default NULL; -alter table creature_movement add `text2` varchar(255) default NULL; -alter table creature_movement add `text3` varchar(255) default NULL; -alter table creature_movement add `text4` varchar(255) default NULL; -alter table creature_movement add `text5` varchar(255) default NULL; -alter table creature_movement add `emote` int(10) unsigned default '0'; -alter table creature_movement add `spell` int(5) unsigned default '0'; -alter table creature_movement add `wpguid` int(11) default '0'; - -*/ - -#include - -#include "WaypointMovementGenerator.h" -#include "ObjectMgr.h" -#include "Creature.h" -#include "DestinationHolderImp.h" -#include "CreatureAI.h" -#include "WaypointManager.h" - -#include - -//-----------------------------------------------// -void -WaypointMovementGenerator::LoadPath(Creature &c) -{ - sLog.outDetail("LoadPath: loading waypoint path for creature %d,%d", c.GetGUIDLow(), c.GetDBTableGUIDLow()); - - i_path = WaypointMgr.GetPath(c.GetDBTableGUIDLow()); - if(!i_path) - { - sLog.outErrorDb("WaypointMovementGenerator::LoadPath: creature %s(%d) doesn't have waypoint path", c.GetName(), c.GetDBTableGUIDLow()); - return; - } - - uint32 node_count = i_path->size(); - i_hasDone.resize(node_count); - for(uint32 i = 0; i < node_count-1; i++) - i_hasDone[i] = false; - - // to prevent a misbehaviour inside "update" - // update is always called with the next wp - but the wpSys needs the current - // so when the routine is called the first time, wpSys gets the last waypoint - // and this prevents the system from performing text/emote, etc - i_hasDone[node_count - 1] = true; -} - -void -WaypointMovementGenerator::ClearWaypoints() -{ - i_path = NULL; -} - -void -WaypointMovementGenerator::Initialize() -{ -} - -bool -WaypointMovementGenerator::Update(Creature &creature, const uint32 &diff) -{ - if(!&creature) - return true; - - // Waypoint movement can be switched on/off - // This is quite handy for escort quests and other stuff - if(creature.hasUnitState(UNIT_STAT_ROOT | UNIT_STAT_STUNDED | UNIT_STAT_DISTRACTED)) - return true; - - // prevent a crash at empty waypoint path. - if(!i_path || i_path->empty()) - return true; - - // i_path was modified by chat commands for example - if(i_path->size() != i_hasDone.size()) - i_hasDone.resize(i_path->size()); - if(i_currentNode >= i_path->size()) - i_currentNode = 0; - - CreatureTraveller traveller(creature); - - i_nextMoveTime.Update(diff); - i_destinationHolder.UpdateTraveller(traveller, diff, false, true); - - // creature has been stoped in middle of the waypoint segment - if (!i_destinationHolder.HasArrived() && creature.IsStopped()) - { - if( i_nextMoveTime.Passed()) // Timer has elapsed, meaning this part controlled it - { - SetStopedByPlayer(false); - // Now we re-set destination to same node and start travel - creature.addUnitState(UNIT_STAT_ROAMING); - const WaypointNode &node = i_path->at(i_currentNode); - i_destinationHolder.SetDestination(traveller, node.x, node.y, node.z); - i_nextMoveTime.Reset(i_destinationHolder.GetTotalTravelTime()); - } - else // if( !i_nextMoveTime.Passed()) - { // unexpected end of timer && creature stopped && not at end of segment - if (!IsStopedByPlayer()) - { // Put 30 seconds delay - i_destinationHolder.IncreaseTravelTime(STOP_TIME_FOR_PLAYER); - i_nextMoveTime.Reset(STOP_TIME_FOR_PLAYER); - SetStopedByPlayer(true); // Mark we did it - } - } - return true; // Abort here this update - } - - if( creature.IsStopped()) - { - uint32 idx = i_currentNode > 0 ? i_currentNode-1 : i_path->size()-1; - - if (!i_hasDone[idx]) - { - if (i_path->at(idx).orientation !=100) - creature.SetOrientation(i_path->at(idx).orientation); - - if(WaypointBehavior *behavior = i_path->at(idx).behavior) - { - if(behavior->emote != 0) - creature.SetUInt32Value(UNIT_NPC_EMOTESTATE,behavior->emote); - if(behavior->spell != 0) - creature.CastSpell(&creature,behavior->spell, false); - if(behavior->model1 != 0) - creature.SetDisplayId(behavior->model1); - if(!behavior->text[0].empty()) - { - // Only one text is set - if( !behavior->text[1].empty() ) - { - // Select one from max 5 texts (0 and 1 laready checked) - int i = 2; - for( ; i < 5; ++i ) - if( behavior->text[i].empty() ) - break; - - creature.Say(behavior->text[rand() % i].c_str(), 0, 0); - - } - else - creature.Say(behavior->text[0].c_str(), 0, 0); - } - - i_hasDone[idx] = true; - MovementInform(creature); - } // wpBehaviour found - } // HasDone == false - } // i_creature.IsStopped() - - if( i_nextMoveTime.Passed() ) // This is at the end of waypoint segment or has been stopped by player - { - if( creature.IsStopped() ) // If stopped then begin a new move segment - { - creature.addUnitState(UNIT_STAT_ROAMING); - const WaypointNode &node = i_path->at(i_currentNode); - i_destinationHolder.SetDestination(traveller, node.x, node.y, node.z); - i_nextMoveTime.Reset(i_destinationHolder.GetTotalTravelTime()); - uint32 idx = i_currentNode > 0 ? i_currentNode-1 : i_path->size()-1; - - if (i_path->at(idx).orientation !=100) - creature.SetOrientation(i_path->at(idx).orientation); - - if(WaypointBehavior *behavior = i_path->at(idx).behavior ) - { - i_hasDone[idx] = false; - if(behavior->model2 != 0) - creature.SetDisplayId(behavior->model2); - - creature.SetUInt32Value(UNIT_NPC_EMOTESTATE, 0); - } - } - else // If not stopped then stop it and set the reset of TimeTracker to waittime - { - creature.StopMoving(); - SetStopedByPlayer(false); - i_nextMoveTime.Reset(i_path->at(i_currentNode).delay); - ++i_currentNode; - if( i_currentNode >= i_path->size() ) - i_currentNode = 0; - } - } - return true; -} - -void WaypointMovementGenerator::MovementInform(Creature &unit) -{ - if(unit.AI()) - unit.AI()->MovementInform(WAYPOINT_MOTION_TYPE, i_currentNode); -} - -//----------------------------------------------------// -void -FlightPathMovementGenerator::LoadPath(Player &) -{ - objmgr.GetTaxiPathNodes(i_pathId, i_path,i_mapIds); -} - -uint32 -FlightPathMovementGenerator::GetPathAtMapEnd() const -{ - if(i_currentNode >= i_mapIds.size()) - return i_mapIds.size(); - - uint32 curMapId = i_mapIds[i_currentNode]; - for(uint32 i = i_currentNode; i < i_mapIds.size(); ++i) - { - if(i_mapIds[i] != curMapId) - return i; - } - - return i_mapIds.size(); -} - -void -FlightPathMovementGenerator::Initialize(Player &player) -{ - player.getHostilRefManager().setOnlineOfflineState(false); - player.addUnitState(UNIT_STAT_IN_FLIGHT); - player.SetFlag(UNIT_FIELD_FLAGS,UNIT_FLAG_DISABLE_MOVE | UNIT_FLAG_TAXI_FLIGHT); - LoadPath(player); - Traveller traveller(player); - // do not send movement, it was sent already - i_destinationHolder.SetDestination(traveller, i_path[i_currentNode].x, i_path[i_currentNode].y, i_path[i_currentNode].z, false); - - player.SendMonsterMoveByPath(GetPath(),GetCurrentNode(),GetPathAtMapEnd(),MOVEMENTFLAG_WALK_MODE|MOVEMENTFLAG_ONTRANSPORT); -} - -void FlightPathMovementGenerator::Finalize(Player & player) -{ - - float x, y, z; - i_destinationHolder.GetLocationNow(player.GetMapId(), x, y, z); - player.SetPosition(x, y, z, player.GetOrientation()); - - player.clearUnitState(UNIT_STAT_IN_FLIGHT); - player.Unmount(); - player.RemoveFlag(UNIT_FIELD_FLAGS,UNIT_FLAG_DISABLE_MOVE | UNIT_FLAG_TAXI_FLIGHT); - - if(player.m_taxi.empty()) - { - player.getHostilRefManager().setOnlineOfflineState(true); - if(player.pvpInfo.inHostileArea) - player.CastSpell(&player, 2479, true); - - player.SetUnitMovementFlags(MOVEMENTFLAG_WALK_MODE); - player.StopMoving(); - } -} - -bool -FlightPathMovementGenerator::Update(Player &player, const uint32 &diff) -{ - if( MovementInProgress() ) - { - Traveller traveller(player); - if( i_destinationHolder.UpdateTraveller(traveller, diff, false) ) - { - i_destinationHolder.ResetUpdate(FLIGHT_TRAVEL_UPDATE); - if( i_destinationHolder.HasArrived() ) - { - uint32 curMap = i_mapIds[i_currentNode]; - ++i_currentNode; - if( MovementInProgress() ) - { - DEBUG_LOG("loading node %u for player %s", i_currentNode, player.GetName()); - if(i_mapIds[i_currentNode]==curMap) - { - // do not send movement, it was sent already - i_destinationHolder.SetDestination(traveller, i_path[i_currentNode].x, i_path[i_currentNode].y, i_path[i_currentNode].z, false); - } - return true; - } - //else HasArrived() - } - else - return true; - } - else - return true; - } - - // we have arrived at the end of the path - return false; -} - -void -FlightPathMovementGenerator::SetCurrentNodeAfterTeleport() -{ - if(i_mapIds.empty()) - return; - - uint32 map0 = i_mapIds[0]; - for(int i = 1; i < i_mapIds.size(); ++i) - { - if(i_mapIds[i]!=map0) - { - i_currentNode = i; - return; - } - } -} - -// -// Unique1's ASTAR Pathfinding Code... For future use & reference... -// - -#ifdef __PATHFINDING__ - -int GetFCost(int to, int num, int parentNum, float *gcost); // Below... - -int ShortenASTARRoute(short int *pathlist, int number) -{ // Wrote this to make the routes a little smarter (shorter)... No point looping back to the same places... Unique1 - short int temppathlist[MAX_PATHLIST_NODES]; - int count = 0; - // int count2 = 0; - int temp, temp2; - int link; - int upto = 0; - - for (temp = number; temp >= 0; temp--) - { - qboolean shortened = qfalse; - - for (temp2 = 0; temp2 < temp; temp2++) - { - for (link = 0; link < nodes[pathlist[temp]].enodenum; link++) - { - if (nodes[pathlist[temp]].links[link].flags & PATH_BLOCKED) - continue; - - //if ((bot->client->ps.eFlags & EF_TANK) && nodes[bot->current_node].links[link].flags & PATH_NOTANKS) //if this path is blocked, skip it - // continue; - - //if (nodes[nodes[pathlist[temp]].links[link].targetNode].origin[2] > nodes[pathlist[temp]].origin[2] + 32) - // continue; - - if (nodes[pathlist[temp]].links[link].targetNode == pathlist[temp2]) - { // Found a shorter route... - //if (OrgVisible(nodes[pathlist[temp2]].origin, nodes[pathlist[temp]].origin, -1)) - { - temppathlist[count] = pathlist[temp2]; - temp = temp2; - ++count; - shortened = qtrue; - } - } - } - } - - if (!shortened) - { - temppathlist[count] = pathlist[temp]; - ++count; - } - } - - upto = count; - - for (temp = 0; temp < count; temp++) - { - pathlist[temp] = temppathlist[upto]; - --upto; - } - - G_Printf("ShortenASTARRoute: Path size reduced from %i to %i nodes...n", number, count); - return count; -} - -/* -=========================================================================== -CreatePathAStar -This function uses the A* pathfinding algorithm to determine the -shortest path between any two nodes. -It's fairly complex, so I'm not really going to explain it much. -Look up A* and binary heaps for more info. -pathlist stores the ideal path between the nodes, in reverse order, -and the return value is the number of nodes in that path -=========================================================================== -*/ -int CreatePathAStar(gentity_t *bot, int from, int to, short int *pathlist) -{ - //all the data we have to hold...since we can't do dynamic allocation, has to be MAX_NODES - //we can probably lower this later - eg, the open list should never have more than at most a few dozen items on it - short int openlist[MAX_NODES+1]; //add 1 because it's a binary heap, and they don't use 0 - 1 is the first used index - float gcost[MAX_NODES]; - int fcost[MAX_NODES]; - char list[MAX_NODES]; //0 is neither, 1 is open, 2 is closed - char because it's the smallest data type - short int parent[MAX_NODES]; - - short int numOpen = 0; - short int atNode, temp, newnode=-1; - qboolean found = qfalse; - int count = -1; - float gc; - int i, u, v, m; - vec3_t vec; - - //clear out all the arrays - memset(openlist, 0, sizeof(short int)*(MAX_NODES+1)); - memset(fcost, 0, sizeof(int)*MAX_NODES); - memset(list, 0, sizeof(char)*MAX_NODES); - memset(parent, 0, sizeof(short int)*MAX_NODES); - memset(gcost, -1, sizeof(float)*MAX_NODES); - - //make sure we have valid data before calculating everything - if ((from == NODE_INVALID) || (to == NODE_INVALID) || (from >= MAX_NODES) || (to >= MAX_NODES) || (from == to)) - return -1; - - openlist[1] = from; //add the starting node to the open list - ++numOpen; - gcost[from] = 0; //its f and g costs are obviously 0 - fcost[from] = 0; - - while (1) - { - if (numOpen != 0) //if there are still items in the open list - { - //pop the top item off of the list - atNode = openlist[1]; - list[atNode] = 2; //put the node on the closed list so we don't check it again - --numOpen; - - openlist[1] = openlist[numOpen+1]; //move the last item in the list to the top position - v = 1; - - //this while loop reorders the list so that the new lowest fcost is at the top again - while (1) - { - u = v; - if ((2*u+1) < numOpen) //if both children exist - { - if (fcost[openlist[u]] >= fcost[openlist[2*u]]) - v = 2*u; - if (fcost[openlist[v]] >= fcost[openlist[2*u+1]]) - v = 2*u+1; - } - else - { - if ((2*u) < numOpen) //if only one child exists - { - if (fcost[openlist[u]] >= fcost[openlist[2*u]]) - v = 2*u; - } - } - - if (u != v) //if they're out of order, swap this item with its parent - { - temp = openlist[u]; - openlist[u] = openlist[v]; - openlist[v] = temp; - } - else - break; - } - - for (i = 0; i < nodes[atNode].enodenum; i++) //loop through all the links for this node - { - newnode = nodes[atNode].links[i].targetNode; - - //if this path is blocked, skip it - if (nodes[atNode].links[i].flags & PATH_BLOCKED) - continue; - //if this path is blocked, skip it - if (bot->client && (bot->client->ps.eFlags & EF_TANK) && nodes[atNode].links[i].flags & PATH_NOTANKS) - continue; - //skip any unreachable nodes - if (bot->client && (nodes[newnode].type & NODE_ALLY_UNREACHABLE) && (bot->client->sess.sessionTeam == TEAM_ALLIES)) - continue; - if (bot->client && (nodes[newnode].type & NODE_AXIS_UNREACHABLE) && (bot->client->sess.sessionTeam == TEAM_AXIS)) - continue; - - if (list[newnode] == 2) //if this node is on the closed list, skip it - continue; - - if (list[newnode] != 1) //if this node is not already on the open list - { - openlist[++numOpen] = newnode; //add the new node to the open list - list[newnode] = 1; - parent[newnode] = atNode; //record the node's parent - - if (newnode == to) //if we've found the goal, don't keep computing paths! - break; //this will break the 'for' and go all the way to 'if (list[to] == 1)' - - //store it's f cost value - fcost[newnode] = GetFCost(to, newnode, parent[newnode], gcost); - - //this loop re-orders the heap so that the lowest fcost is at the top - m = numOpen; - while (m != 1) //while this item isn't at the top of the heap already - { - //if it has a lower fcost than its parent - if (fcost[openlist[m]] <= fcost[openlist[m/2]]) - { - temp = openlist[m/2]; - openlist[m/2] = openlist[m]; - openlist[m] = temp; //swap them - m /= 2; - } - else - break; - } - } - else //if this node is already on the open list - { - gc = gcost[atNode]; - VectorSubtract(nodes[newnode].origin, nodes[atNode].origin, vec); - gc += VectorLength(vec); //calculate what the gcost would be if we reached this node along the current path - - if (gc < gcost[newnode]) //if the new gcost is less (ie, this path is shorter than what we had before) - { - parent[newnode] = atNode; //set the new parent for this node - gcost[newnode] = gc; //and the new g cost - - for (i = 1; i < numOpen; i++) //loop through all the items on the open list - { - if (openlist[i] == newnode) //find this node in the list - { - //calculate the new fcost and store it - fcost[newnode] = GetFCost(to, newnode, parent[newnode], gcost); - - //reorder the list again, with the lowest fcost item on top - m = i; - while (m != 1) - { - //if the item has a lower fcost than it's parent - if (fcost[openlist[m]] < fcost[openlist[m/2]]) - { - temp = openlist[m/2]; - openlist[m/2] = openlist[m]; - openlist[m] = temp; //swap them - m /= 2; - } - else - break; - } - break; //exit the 'for' loop because we already changed this node - } //if - } //for - } //if (gc < gcost[newnode]) - } //if (list[newnode] != 1) --> else - } //for (loop through links) - } //if (numOpen != 0) - else - { - found = qfalse; //there is no path between these nodes - break; - } - - if (list[to] == 1) //if the destination node is on the open list, we're done - { - found = qtrue; - break; - } - } //while (1) - - if (found == qtrue) //if we found a path - { - //G_Printf("%s - path found!n", bot->client->pers.netname); - count = 0; - - temp = to; //start at the end point - while (temp != from) //travel along the path (backwards) until we reach the starting point - { - pathlist[count++] = temp; //add the node to the pathlist and increment the count - temp = parent[temp]; //move to the parent of this node to continue the path - } - - pathlist[count++] = from; //add the beginning node to the end of the pathlist - - #ifdef __BOT_SHORTEN_ROUTING__ - count = ShortenASTARRoute(pathlist, count); // This isn't working... Dunno why.. Unique1 - #endif //__BOT_SHORTEN_ROUTING__ - } - else - { - //G_Printf("^1*** ^4BOT DEBUG^5: (CreatePathAStar) There is no route between node ^7%i^5 and node ^7%i^5.n", from, to); - count = CreateDumbRoute(from, to, pathlist); - - if (count > 0) - { - #ifdef __BOT_SHORTEN_ROUTING__ - count = ShortenASTARRoute(pathlist, count); // This isn't working... Dunno why.. Unique1 - #endif //__BOT_SHORTEN_ROUTING__ - return count; - } - } - - return count; //return the number of nodes in the path, -1 if not found -} - -/* -=========================================================================== -GetFCost -Utility function used by A* pathfinding to calculate the -cost to move between nodes towards a goal. Using the A* -algorithm F = G + H, G here is the distance along the node -paths the bot must travel, and H is the straight-line distance -to the goal node. -Returned as an int because more precision is unnecessary and it -will slightly speed up heap access -=========================================================================== -*/ -int GetFCost(int to, int num, int parentNum, float *gcost) -{ - float gc = 0; - float hc = 0; - vec3_t v; - - if (gcost[num] == -1) - { - if (parentNum != -1) - { - gc = gcost[parentNum]; - VectorSubtract(nodes[num].origin, nodes[parentNum].origin, v); - gc += VectorLength(v); - } - gcost[num] = gc; - } - else - gc = gcost[num]; - - VectorSubtract(nodes[to].origin, nodes[num].origin, v); - hc = VectorLength(v); - - return (int)(gc + hc); -} -#endif //__PATHFINDING__ +/* + * Copyright (C) 2005-2008 MaNGOS + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* +creature_movement Table + +alter table creature_movement add `text1` varchar(255) default NULL; +alter table creature_movement add `text2` varchar(255) default NULL; +alter table creature_movement add `text3` varchar(255) default NULL; +alter table creature_movement add `text4` varchar(255) default NULL; +alter table creature_movement add `text5` varchar(255) default NULL; +alter table creature_movement add `emote` int(10) unsigned default '0'; +alter table creature_movement add `spell` int(5) unsigned default '0'; +alter table creature_movement add `wpguid` int(11) default '0'; + +*/ + +#include + +#include "WaypointMovementGenerator.h" +#include "ObjectMgr.h" +#include "Creature.h" +#include "DestinationHolderImp.h" +#include "CreatureAI.h" +#include "WaypointManager.h" + +#include + +//-----------------------------------------------// +void +WaypointMovementGenerator::LoadPath(Creature &c) +{ + sLog.outDetail("LoadPath: loading waypoint path for creature %d,%d", c.GetGUIDLow(), c.GetDBTableGUIDLow()); + + i_path = WaypointMgr.GetPath(c.GetDBTableGUIDLow()); + if(!i_path) + { + sLog.outErrorDb("WaypointMovementGenerator::LoadPath: creature %s(%d) doesn't have waypoint path", c.GetName(), c.GetDBTableGUIDLow()); + return; + } + + uint32 node_count = i_path->size(); + i_hasDone.resize(node_count); + for(uint32 i = 0; i < node_count-1; i++) + i_hasDone[i] = false; + + // to prevent a misbehaviour inside "update" + // update is always called with the next wp - but the wpSys needs the current + // so when the routine is called the first time, wpSys gets the last waypoint + // and this prevents the system from performing text/emote, etc + i_hasDone[node_count - 1] = true; +} + +void +WaypointMovementGenerator::ClearWaypoints() +{ + i_path = NULL; +} + +void +WaypointMovementGenerator::Initialize() +{ +} + +bool +WaypointMovementGenerator::Update(Creature &creature, const uint32 &diff) +{ + if(!&creature) + return true; + + // Waypoint movement can be switched on/off + // This is quite handy for escort quests and other stuff + if(creature.hasUnitState(UNIT_STAT_ROOT | UNIT_STAT_STUNDED | UNIT_STAT_DISTRACTED)) + return true; + + // prevent a crash at empty waypoint path. + if(!i_path || i_path->empty()) + return true; + + // i_path was modified by chat commands for example + if(i_path->size() != i_hasDone.size()) + i_hasDone.resize(i_path->size()); + if(i_currentNode >= i_path->size()) + i_currentNode = 0; + + CreatureTraveller traveller(creature); + + i_nextMoveTime.Update(diff); + i_destinationHolder.UpdateTraveller(traveller, diff, false, true); + + // creature has been stoped in middle of the waypoint segment + if (!i_destinationHolder.HasArrived() && creature.IsStopped()) + { + if( i_nextMoveTime.Passed()) // Timer has elapsed, meaning this part controlled it + { + SetStopedByPlayer(false); + // Now we re-set destination to same node and start travel + creature.addUnitState(UNIT_STAT_ROAMING); + if (creature.canFly()) + creature.SetUnitMovementFlags(MOVEMENTFLAG_FLYING2); + const WaypointNode &node = i_path->at(i_currentNode); + i_destinationHolder.SetDestination(traveller, node.x, node.y, node.z); + i_nextMoveTime.Reset(i_destinationHolder.GetTotalTravelTime()); + } + else // if( !i_nextMoveTime.Passed()) + { // unexpected end of timer && creature stopped && not at end of segment + if (!IsStopedByPlayer()) + { // Put 30 seconds delay + i_destinationHolder.IncreaseTravelTime(STOP_TIME_FOR_PLAYER); + i_nextMoveTime.Reset(STOP_TIME_FOR_PLAYER); + SetStopedByPlayer(true); // Mark we did it + } + } + return true; // Abort here this update + } + + if( creature.IsStopped()) + { + uint32 idx = i_currentNode > 0 ? i_currentNode-1 : i_path->size()-1; + + if (!i_hasDone[idx]) + { + if (i_path->at(idx).orientation !=100) + creature.SetOrientation(i_path->at(idx).orientation); + + if(WaypointBehavior *behavior = i_path->at(idx).behavior) + { + if(behavior->emote != 0) + creature.SetUInt32Value(UNIT_NPC_EMOTESTATE,behavior->emote); + if(behavior->spell != 0) + creature.CastSpell(&creature,behavior->spell, false); + if(behavior->model1 != 0) + creature.SetDisplayId(behavior->model1); + if(!behavior->text[0].empty()) + { + // Only one text is set + if( !behavior->text[1].empty() ) + { + // Select one from max 5 texts (0 and 1 laready checked) + int i = 2; + for( ; i < 5; ++i ) + if( behavior->text[i].empty() ) + break; + + creature.Say(behavior->text[rand() % i].c_str(), 0, 0); + + } + else + creature.Say(behavior->text[0].c_str(), 0, 0); + } + + i_hasDone[idx] = true; + MovementInform(creature); + } // wpBehaviour found + } // HasDone == false + } // i_creature.IsStopped() + + if( i_nextMoveTime.Passed() ) // This is at the end of waypoint segment or has been stopped by player + { + if( creature.IsStopped() ) // If stopped then begin a new move segment + { + creature.addUnitState(UNIT_STAT_ROAMING); + if (creature.canFly()) + creature.SetUnitMovementFlags(MOVEMENTFLAG_FLYING2); + const WaypointNode &node = i_path->at(i_currentNode); + i_destinationHolder.SetDestination(traveller, node.x, node.y, node.z); + i_nextMoveTime.Reset(i_destinationHolder.GetTotalTravelTime()); + uint32 idx = i_currentNode > 0 ? i_currentNode-1 : i_path->size()-1; + + if (i_path->at(idx).orientation !=100) + creature.SetOrientation(i_path->at(idx).orientation); + + if(WaypointBehavior *behavior = i_path->at(idx).behavior ) + { + i_hasDone[idx] = false; + if(behavior->model2 != 0) + creature.SetDisplayId(behavior->model2); + + creature.SetUInt32Value(UNIT_NPC_EMOTESTATE, 0); + } + } + else // If not stopped then stop it and set the reset of TimeTracker to waittime + { + creature.StopMoving(); + SetStopedByPlayer(false); + i_nextMoveTime.Reset(i_path->at(i_currentNode).delay); + ++i_currentNode; + if( i_currentNode >= i_path->size() ) + i_currentNode = 0; + } + } + return true; +} + +void WaypointMovementGenerator::MovementInform(Creature &unit) +{ + if(unit.AI()) + unit.AI()->MovementInform(WAYPOINT_MOTION_TYPE, i_currentNode); +} + +//----------------------------------------------------// +void +FlightPathMovementGenerator::LoadPath(Player &) +{ + objmgr.GetTaxiPathNodes(i_pathId, i_path,i_mapIds); +} + +uint32 +FlightPathMovementGenerator::GetPathAtMapEnd() const +{ + if(i_currentNode >= i_mapIds.size()) + return i_mapIds.size(); + + uint32 curMapId = i_mapIds[i_currentNode]; + for(uint32 i = i_currentNode; i < i_mapIds.size(); ++i) + { + if(i_mapIds[i] != curMapId) + return i; + } + + return i_mapIds.size(); +} + +void +FlightPathMovementGenerator::Initialize(Player &player) +{ + player.getHostilRefManager().setOnlineOfflineState(false); + player.addUnitState(UNIT_STAT_IN_FLIGHT); + player.SetFlag(UNIT_FIELD_FLAGS,UNIT_FLAG_DISABLE_MOVE | UNIT_FLAG_TAXI_FLIGHT); + LoadPath(player); + Traveller traveller(player); + // do not send movement, it was sent already + i_destinationHolder.SetDestination(traveller, i_path[i_currentNode].x, i_path[i_currentNode].y, i_path[i_currentNode].z, false); + + player.SendMonsterMoveByPath(GetPath(),GetCurrentNode(),GetPathAtMapEnd(),MOVEMENTFLAG_WALK_MODE|MOVEMENTFLAG_ONTRANSPORT); +} + +void FlightPathMovementGenerator::Finalize(Player & player) +{ + + float x, y, z; + i_destinationHolder.GetLocationNow(player.GetMapId(), x, y, z); + player.SetPosition(x, y, z, player.GetOrientation()); + + player.clearUnitState(UNIT_STAT_IN_FLIGHT); + player.Unmount(); + player.RemoveFlag(UNIT_FIELD_FLAGS,UNIT_FLAG_DISABLE_MOVE | UNIT_FLAG_TAXI_FLIGHT); + + if(player.m_taxi.empty()) + { + player.getHostilRefManager().setOnlineOfflineState(true); + if(player.pvpInfo.inHostileArea) + player.CastSpell(&player, 2479, true); + + player.SetUnitMovementFlags(MOVEMENTFLAG_WALK_MODE); + player.StopMoving(); + } +} + +bool +FlightPathMovementGenerator::Update(Player &player, const uint32 &diff) +{ + if( MovementInProgress() ) + { + Traveller traveller(player); + if( i_destinationHolder.UpdateTraveller(traveller, diff, false) ) + { + i_destinationHolder.ResetUpdate(FLIGHT_TRAVEL_UPDATE); + if( i_destinationHolder.HasArrived() ) + { + uint32 curMap = i_mapIds[i_currentNode]; + ++i_currentNode; + if( MovementInProgress() ) + { + DEBUG_LOG("loading node %u for player %s", i_currentNode, player.GetName()); + if(i_mapIds[i_currentNode]==curMap) + { + // do not send movement, it was sent already + i_destinationHolder.SetDestination(traveller, i_path[i_currentNode].x, i_path[i_currentNode].y, i_path[i_currentNode].z, false); + } + return true; + } + //else HasArrived() + } + else + return true; + } + else + return true; + } + + // we have arrived at the end of the path + return false; +} + +void +FlightPathMovementGenerator::SetCurrentNodeAfterTeleport() +{ + if(i_mapIds.empty()) + return; + + uint32 map0 = i_mapIds[0]; + for(int i = 1; i < i_mapIds.size(); ++i) + { + if(i_mapIds[i]!=map0) + { + i_currentNode = i; + return; + } + } +} + +// +// Unique1's ASTAR Pathfinding Code... For future use & reference... +// + +#ifdef __PATHFINDING__ + +int GetFCost(int to, int num, int parentNum, float *gcost); // Below... + +int ShortenASTARRoute(short int *pathlist, int number) +{ // Wrote this to make the routes a little smarter (shorter)... No point looping back to the same places... Unique1 + short int temppathlist[MAX_PATHLIST_NODES]; + int count = 0; + // int count2 = 0; + int temp, temp2; + int link; + int upto = 0; + + for (temp = number; temp >= 0; temp--) + { + qboolean shortened = qfalse; + + for (temp2 = 0; temp2 < temp; temp2++) + { + for (link = 0; link < nodes[pathlist[temp]].enodenum; link++) + { + if (nodes[pathlist[temp]].links[link].flags & PATH_BLOCKED) + continue; + + //if ((bot->client->ps.eFlags & EF_TANK) && nodes[bot->current_node].links[link].flags & PATH_NOTANKS) //if this path is blocked, skip it + // continue; + + //if (nodes[nodes[pathlist[temp]].links[link].targetNode].origin[2] > nodes[pathlist[temp]].origin[2] + 32) + // continue; + + if (nodes[pathlist[temp]].links[link].targetNode == pathlist[temp2]) + { // Found a shorter route... + //if (OrgVisible(nodes[pathlist[temp2]].origin, nodes[pathlist[temp]].origin, -1)) + { + temppathlist[count] = pathlist[temp2]; + temp = temp2; + ++count; + shortened = qtrue; + } + } + } + } + + if (!shortened) + { + temppathlist[count] = pathlist[temp]; + ++count; + } + } + + upto = count; + + for (temp = 0; temp < count; temp++) + { + pathlist[temp] = temppathlist[upto]; + --upto; + } + + G_Printf("ShortenASTARRoute: Path size reduced from %i to %i nodes...n", number, count); + return count; +} + +/* +=========================================================================== +CreatePathAStar +This function uses the A* pathfinding algorithm to determine the +shortest path between any two nodes. +It's fairly complex, so I'm not really going to explain it much. +Look up A* and binary heaps for more info. +pathlist stores the ideal path between the nodes, in reverse order, +and the return value is the number of nodes in that path +=========================================================================== +*/ +int CreatePathAStar(gentity_t *bot, int from, int to, short int *pathlist) +{ + //all the data we have to hold...since we can't do dynamic allocation, has to be MAX_NODES + //we can probably lower this later - eg, the open list should never have more than at most a few dozen items on it + short int openlist[MAX_NODES+1]; //add 1 because it's a binary heap, and they don't use 0 - 1 is the first used index + float gcost[MAX_NODES]; + int fcost[MAX_NODES]; + char list[MAX_NODES]; //0 is neither, 1 is open, 2 is closed - char because it's the smallest data type + short int parent[MAX_NODES]; + + short int numOpen = 0; + short int atNode, temp, newnode=-1; + qboolean found = qfalse; + int count = -1; + float gc; + int i, u, v, m; + vec3_t vec; + + //clear out all the arrays + memset(openlist, 0, sizeof(short int)*(MAX_NODES+1)); + memset(fcost, 0, sizeof(int)*MAX_NODES); + memset(list, 0, sizeof(char)*MAX_NODES); + memset(parent, 0, sizeof(short int)*MAX_NODES); + memset(gcost, -1, sizeof(float)*MAX_NODES); + + //make sure we have valid data before calculating everything + if ((from == NODE_INVALID) || (to == NODE_INVALID) || (from >= MAX_NODES) || (to >= MAX_NODES) || (from == to)) + return -1; + + openlist[1] = from; //add the starting node to the open list + ++numOpen; + gcost[from] = 0; //its f and g costs are obviously 0 + fcost[from] = 0; + + while (1) + { + if (numOpen != 0) //if there are still items in the open list + { + //pop the top item off of the list + atNode = openlist[1]; + list[atNode] = 2; //put the node on the closed list so we don't check it again + --numOpen; + + openlist[1] = openlist[numOpen+1]; //move the last item in the list to the top position + v = 1; + + //this while loop reorders the list so that the new lowest fcost is at the top again + while (1) + { + u = v; + if ((2*u+1) < numOpen) //if both children exist + { + if (fcost[openlist[u]] >= fcost[openlist[2*u]]) + v = 2*u; + if (fcost[openlist[v]] >= fcost[openlist[2*u+1]]) + v = 2*u+1; + } + else + { + if ((2*u) < numOpen) //if only one child exists + { + if (fcost[openlist[u]] >= fcost[openlist[2*u]]) + v = 2*u; + } + } + + if (u != v) //if they're out of order, swap this item with its parent + { + temp = openlist[u]; + openlist[u] = openlist[v]; + openlist[v] = temp; + } + else + break; + } + + for (i = 0; i < nodes[atNode].enodenum; i++) //loop through all the links for this node + { + newnode = nodes[atNode].links[i].targetNode; + + //if this path is blocked, skip it + if (nodes[atNode].links[i].flags & PATH_BLOCKED) + continue; + //if this path is blocked, skip it + if (bot->client && (bot->client->ps.eFlags & EF_TANK) && nodes[atNode].links[i].flags & PATH_NOTANKS) + continue; + //skip any unreachable nodes + if (bot->client && (nodes[newnode].type & NODE_ALLY_UNREACHABLE) && (bot->client->sess.sessionTeam == TEAM_ALLIES)) + continue; + if (bot->client && (nodes[newnode].type & NODE_AXIS_UNREACHABLE) && (bot->client->sess.sessionTeam == TEAM_AXIS)) + continue; + + if (list[newnode] == 2) //if this node is on the closed list, skip it + continue; + + if (list[newnode] != 1) //if this node is not already on the open list + { + openlist[++numOpen] = newnode; //add the new node to the open list + list[newnode] = 1; + parent[newnode] = atNode; //record the node's parent + + if (newnode == to) //if we've found the goal, don't keep computing paths! + break; //this will break the 'for' and go all the way to 'if (list[to] == 1)' + + //store it's f cost value + fcost[newnode] = GetFCost(to, newnode, parent[newnode], gcost); + + //this loop re-orders the heap so that the lowest fcost is at the top + m = numOpen; + while (m != 1) //while this item isn't at the top of the heap already + { + //if it has a lower fcost than its parent + if (fcost[openlist[m]] <= fcost[openlist[m/2]]) + { + temp = openlist[m/2]; + openlist[m/2] = openlist[m]; + openlist[m] = temp; //swap them + m /= 2; + } + else + break; + } + } + else //if this node is already on the open list + { + gc = gcost[atNode]; + VectorSubtract(nodes[newnode].origin, nodes[atNode].origin, vec); + gc += VectorLength(vec); //calculate what the gcost would be if we reached this node along the current path + + if (gc < gcost[newnode]) //if the new gcost is less (ie, this path is shorter than what we had before) + { + parent[newnode] = atNode; //set the new parent for this node + gcost[newnode] = gc; //and the new g cost + + for (i = 1; i < numOpen; i++) //loop through all the items on the open list + { + if (openlist[i] == newnode) //find this node in the list + { + //calculate the new fcost and store it + fcost[newnode] = GetFCost(to, newnode, parent[newnode], gcost); + + //reorder the list again, with the lowest fcost item on top + m = i; + while (m != 1) + { + //if the item has a lower fcost than it's parent + if (fcost[openlist[m]] < fcost[openlist[m/2]]) + { + temp = openlist[m/2]; + openlist[m/2] = openlist[m]; + openlist[m] = temp; //swap them + m /= 2; + } + else + break; + } + break; //exit the 'for' loop because we already changed this node + } //if + } //for + } //if (gc < gcost[newnode]) + } //if (list[newnode] != 1) --> else + } //for (loop through links) + } //if (numOpen != 0) + else + { + found = qfalse; //there is no path between these nodes + break; + } + + if (list[to] == 1) //if the destination node is on the open list, we're done + { + found = qtrue; + break; + } + } //while (1) + + if (found == qtrue) //if we found a path + { + //G_Printf("%s - path found!n", bot->client->pers.netname); + count = 0; + + temp = to; //start at the end point + while (temp != from) //travel along the path (backwards) until we reach the starting point + { + pathlist[count++] = temp; //add the node to the pathlist and increment the count + temp = parent[temp]; //move to the parent of this node to continue the path + } + + pathlist[count++] = from; //add the beginning node to the end of the pathlist + + #ifdef __BOT_SHORTEN_ROUTING__ + count = ShortenASTARRoute(pathlist, count); // This isn't working... Dunno why.. Unique1 + #endif //__BOT_SHORTEN_ROUTING__ + } + else + { + //G_Printf("^1*** ^4BOT DEBUG^5: (CreatePathAStar) There is no route between node ^7%i^5 and node ^7%i^5.n", from, to); + count = CreateDumbRoute(from, to, pathlist); + + if (count > 0) + { + #ifdef __BOT_SHORTEN_ROUTING__ + count = ShortenASTARRoute(pathlist, count); // This isn't working... Dunno why.. Unique1 + #endif //__BOT_SHORTEN_ROUTING__ + return count; + } + } + + return count; //return the number of nodes in the path, -1 if not found +} + +/* +=========================================================================== +GetFCost +Utility function used by A* pathfinding to calculate the +cost to move between nodes towards a goal. Using the A* +algorithm F = G + H, G here is the distance along the node +paths the bot must travel, and H is the straight-line distance +to the goal node. +Returned as an int because more precision is unnecessary and it +will slightly speed up heap access +=========================================================================== +*/ +int GetFCost(int to, int num, int parentNum, float *gcost) +{ + float gc = 0; + float hc = 0; + vec3_t v; + + if (gcost[num] == -1) + { + if (parentNum != -1) + { + gc = gcost[parentNum]; + VectorSubtract(nodes[num].origin, nodes[parentNum].origin, v); + gc += VectorLength(v); + } + gcost[num] = gc; + } + else + gc = gcost[num]; + + VectorSubtract(nodes[to].origin, nodes[num].origin, v); + hc = VectorLength(v); + + return (int)(gc + hc); +} +#endif //__PATHFINDING__ diff --git a/src/game/World.cpp b/src/game/World.cpp index 8546778ae21..b3929fa73a9 100644 --- a/src/game/World.cpp +++ b/src/game/World.cpp @@ -1,2460 +1,2546 @@ -/* - * Copyright (C) 2005-2008 MaNGOS - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/** \file - \ingroup world -*/ - -#include "Common.h" -#include "Database/DatabaseEnv.h" -#include "Config/ConfigEnv.h" -#include "SystemConfig.h" -#include "Log.h" -#include "Opcodes.h" -#include "WorldSession.h" -#include "WorldPacket.h" -#include "Weather.h" -#include "Player.h" -#include "SkillExtraItems.h" -#include "SkillDiscovery.h" -#include "World.h" -#include "ObjectMgr.h" -#include "SpellMgr.h" -#include "Chat.h" -#include "Database/DBCStores.h" -#include "LootMgr.h" -#include "ItemEnchantmentMgr.h" -#include "MapManager.h" -#include "ScriptCalls.h" -#include "CreatureAIRegistry.h" -#include "Policies/SingletonImp.h" -#include "BattleGroundMgr.h" -#include "TemporarySummon.h" -#include "WaypointMovementGenerator.h" -#include "VMapFactory.h" -#include "GlobalEvents.h" -#include "GameEvent.h" -#include "Database/DatabaseImpl.h" -#include "WorldSocket.h" -#include "GridNotifiersImpl.h" -#include "CellImpl.h" -#include "InstanceSaveMgr.h" -#include "WaypointManager.h" -#include "Util.h" - -INSTANTIATE_SINGLETON_1( World ); - -volatile bool World::m_stopEvent = false; -volatile uint32 World::m_worldLoopCounter = 0; - -float World::m_MaxVisibleDistanceForCreature = DEFAULT_VISIBILITY_DISTANCE; -float World::m_MaxVisibleDistanceForPlayer = DEFAULT_VISIBILITY_DISTANCE; -float World::m_MaxVisibleDistanceForObject = DEFAULT_VISIBILITY_DISTANCE; -float World::m_MaxVisibleDistanceInFlight = DEFAULT_VISIBILITY_DISTANCE; -float World::m_VisibleUnitGreyDistance = 0; -float World::m_VisibleObjectGreyDistance = 0; - -// ServerMessages.dbc -enum ServerMessageType -{ - SERVER_MSG_SHUTDOWN_TIME = 1, - SERVER_MSG_RESTART_TIME = 2, - SERVER_MSG_STRING = 3, - SERVER_MSG_SHUTDOWN_CANCELLED = 4, - SERVER_MSG_RESTART_CANCELLED = 5 -}; - -struct ScriptAction -{ - uint64 sourceGUID; - uint64 targetGUID; - uint64 ownerGUID; // owner of source if source is item - ScriptInfo const* script; // pointer to static script data -}; - -/// World constructor -World::World() -{ - m_playerLimit = 0; - m_allowMovement = true; - m_ShutdownMask = 0; - m_ShutdownTimer = 0; - m_gameTime=time(NULL); - m_startTime=m_gameTime; - m_maxActiveSessionCount = 0; - m_maxQueuedSessionCount = 0; - m_resultQueue = NULL; - m_NextDailyQuestReset = 0; - - m_defaultDbcLocale = LOCALE_enUS; - m_availableDbcLocaleMask = 0; -} - -/// World destructor -World::~World() -{ - ///- Empty the kicked session set - for (std::set::iterator itr = m_kicked_sessions.begin(); itr != m_kicked_sessions.end(); ++itr) - delete *itr; - - m_kicked_sessions.clear(); - - ///- Empty the WeatherMap - for (WeatherMap::iterator itr = m_weathers.begin(); itr != m_weathers.end(); ++itr) - delete itr->second; - - m_weathers.clear(); - - VMAP::VMapFactory::clear(); - - if(m_resultQueue) delete m_resultQueue; -} - -/// Find a player in a specified zone -Player* World::FindPlayerInZone(uint32 zone) -{ - ///- circle through active sessions and return the first player found in the zone - SessionMap::iterator itr; - for (itr = m_sessions.begin(); itr != m_sessions.end(); ++itr) - { - if(!itr->second) - continue; - Player *player = itr->second->GetPlayer(); - if(!player) - continue; - if( player->IsInWorld() && player->GetZoneId() == zone ) - { - // Used by the weather system. We return the player to broadcast the change weather message to him and all players in the zone. - return player; - } - } - return NULL; -} - -/// Find a session by its id -WorldSession* World::FindSession(uint32 id) const -{ - SessionMap::const_iterator itr = m_sessions.find(id); - - if(itr != m_sessions.end()) - return itr->second; // also can return NULL for kicked session - else - return NULL; -} - -/// Remove a given session -bool World::RemoveSession(uint32 id) -{ - ///- Find the session, kick the user, but we can't delete session at this moment to prevent iterator invalidation - SessionMap::iterator itr = m_sessions.find(id); - - if(itr != m_sessions.end() && itr->second) - { - if (itr->second->PlayerLoading()) - return false; - itr->second->KickPlayer(); - } - - return true; -} - -/// Add a session to the session list -void World::AddSession(WorldSession* s) -{ - ASSERT(s); - - WorldSession* old = m_sessions[s->GetAccountId()]; - m_sessions[s->GetAccountId()] = s; - - // if session already exist, prepare to it deleting at next world update - if(old) - m_kicked_sessions.insert(old); -} - -int32 World::GetQueuePos(WorldSocket* socket) -{ - uint32 position = 1; - - for(Queue::iterator iter = m_QueuedPlayer.begin(); iter != m_QueuedPlayer.end(); ++iter, ++position) - if((*iter) == socket) - return position; - - return 0; -} - -void World::AddQueuedPlayer(WorldSocket* socket) -{ - m_QueuedPlayer.push_back(socket); -} - -void World::RemoveQueuedPlayer(WorldSocket* socket) -{ - // sessions count including queued to remove (if removed_session set) - uint32 sessions = GetActiveSessionCount(); - - uint32 position = 1; - Queue::iterator iter = m_QueuedPlayer.begin(); - - // if session not queued then we need decrease sessions count (Remove socked callet before session removing from session list) - bool decrease_session = true; - - // search socket to remove and count skipped positions - for(;iter != m_QueuedPlayer.end(); ++iter, ++position) - { - if(*iter==socket) - { - Queue::iterator iter2 = iter; - ++iter; - m_QueuedPlayer.erase(iter2); - decrease_session = false; // removing queued session - break; - } - } - - // iter point to next socked after removed or end() - // position store position of removed socket and then new position next socket after removed - - // decrease for case session queued for removing - if(decrease_session && sessions) - --sessions; - - // accept first in queue - if( (!m_playerLimit || sessions < m_playerLimit) && !m_QueuedPlayer.empty() ) - { - WorldSocket * socket = m_QueuedPlayer.front(); - socket->SendAuthWaitQue(0); - m_QueuedPlayer.pop_front(); - - // update iter to point first queued socket or end() if queue is empty now - iter = m_QueuedPlayer.begin(); - position = 1; - } - - // update position from iter to end() - // iter point to first not updated socket, position store new position - for(; iter != m_QueuedPlayer.end(); ++iter, ++position) - (*iter)->SendAuthWaitQue(position); -} - -/// Find a Weather object by the given zoneid -Weather* World::FindWeather(uint32 id) const -{ - WeatherMap::const_iterator itr = m_weathers.find(id); - - if(itr != m_weathers.end()) - return itr->second; - else - return 0; -} - -/// Remove a Weather object for the given zoneid -void World::RemoveWeather(uint32 id) -{ - // not called at the moment. Kept for completeness - WeatherMap::iterator itr = m_weathers.find(id); - - if(itr != m_weathers.end()) - { - delete itr->second; - m_weathers.erase(itr); - } -} - -/// Add a Weather object to the list -Weather* World::AddWeather(uint32 zone_id) -{ - WeatherZoneChances const* weatherChances = objmgr.GetWeatherChances(zone_id); - - // zone not have weather, ignore - if(!weatherChances) - return NULL; - - Weather* w = new Weather(zone_id,weatherChances); - m_weathers[w->GetZone()] = w; - w->ReGenerate(); - w->UpdateWeather(); - return w; -} - -/// Initialize config values -void World::LoadConfigSettings(bool reload) -{ - if(reload) - { - if(!sConfig.Reload()) - { - sLog.outError("World settings reload fail: can't read settings from %s.",sConfig.GetFilename().c_str()); - return; - } - //TODO Check if config is outdated - } - - ///- Read the player limit and the Message of the day from the config file - SetPlayerLimit( sConfig.GetIntDefault("PlayerLimit", DEFAULT_PLAYER_LIMIT), true ); - SetMotd( sConfig.GetStringDefault("Motd", "Welcome to the Massive Network Game Object Server." ) ); - - ///- Read all rates from the config file - rate_values[RATE_HEALTH] = sConfig.GetFloatDefault("Rate.Health", 1); - if(rate_values[RATE_HEALTH] < 0) - { - sLog.outError("Rate.Health (%f) mustbe > 0. Using 1 instead.",rate_values[RATE_HEALTH]); - rate_values[RATE_HEALTH] = 1; - } - rate_values[RATE_POWER_MANA] = sConfig.GetFloatDefault("Rate.Mana", 1); - if(rate_values[RATE_POWER_MANA] < 0) - { - sLog.outError("Rate.Mana (%f) mustbe > 0. Using 1 instead.",rate_values[RATE_POWER_MANA]); - rate_values[RATE_POWER_MANA] = 1; - } - rate_values[RATE_POWER_RAGE_INCOME] = sConfig.GetFloatDefault("Rate.Rage.Income", 1); - rate_values[RATE_POWER_RAGE_LOSS] = sConfig.GetFloatDefault("Rate.Rage.Loss", 1); - if(rate_values[RATE_POWER_RAGE_LOSS] < 0) - { - sLog.outError("Rate.Rage.Loss (%f) mustbe > 0. Using 1 instead.",rate_values[RATE_POWER_RAGE_LOSS]); - rate_values[RATE_POWER_RAGE_LOSS] = 1; - } - rate_values[RATE_POWER_FOCUS] = sConfig.GetFloatDefault("Rate.Focus", 1.0f); - rate_values[RATE_LOYALTY] = sConfig.GetFloatDefault("Rate.Loyalty", 1.0f); - rate_values[RATE_SKILL_DISCOVERY] = sConfig.GetFloatDefault("Rate.Skill.Discovery", 1.0f); - rate_values[RATE_DROP_ITEM_POOR] = sConfig.GetFloatDefault("Rate.Drop.Item.Poor", 1.0f); - rate_values[RATE_DROP_ITEM_NORMAL] = sConfig.GetFloatDefault("Rate.Drop.Item.Normal", 1.0f); - rate_values[RATE_DROP_ITEM_UNCOMMON] = sConfig.GetFloatDefault("Rate.Drop.Item.Uncommon", 1.0f); - rate_values[RATE_DROP_ITEM_RARE] = sConfig.GetFloatDefault("Rate.Drop.Item.Rare", 1.0f); - rate_values[RATE_DROP_ITEM_EPIC] = sConfig.GetFloatDefault("Rate.Drop.Item.Epic", 1.0f); - rate_values[RATE_DROP_ITEM_LEGENDARY] = sConfig.GetFloatDefault("Rate.Drop.Item.Legendary", 1.0f); - rate_values[RATE_DROP_ITEM_ARTIFACT] = sConfig.GetFloatDefault("Rate.Drop.Item.Artifact", 1.0f); - rate_values[RATE_DROP_ITEM_REFERENCED] = sConfig.GetFloatDefault("Rate.Drop.Item.Referenced", 1.0f); - rate_values[RATE_DROP_MONEY] = sConfig.GetFloatDefault("Rate.Drop.Money", 1.0f); - rate_values[RATE_XP_KILL] = sConfig.GetFloatDefault("Rate.XP.Kill", 1.0f); - rate_values[RATE_XP_QUEST] = sConfig.GetFloatDefault("Rate.XP.Quest", 1.0f); - rate_values[RATE_XP_EXPLORE] = sConfig.GetFloatDefault("Rate.XP.Explore", 1.0f); - rate_values[RATE_XP_PAST_70] = sConfig.GetFloatDefault("Rate.XP.PastLevel70", 1.0f); - rate_values[RATE_REPUTATION_GAIN] = sConfig.GetFloatDefault("Rate.Reputation.Gain", 1.0f); - rate_values[RATE_CREATURE_NORMAL_DAMAGE] = sConfig.GetFloatDefault("Rate.Creature.Normal.Damage", 1.0f); - rate_values[RATE_CREATURE_ELITE_ELITE_DAMAGE] = sConfig.GetFloatDefault("Rate.Creature.Elite.Elite.Damage", 1.0f); - rate_values[RATE_CREATURE_ELITE_RAREELITE_DAMAGE] = sConfig.GetFloatDefault("Rate.Creature.Elite.RAREELITE.Damage", 1.0f); - rate_values[RATE_CREATURE_ELITE_WORLDBOSS_DAMAGE] = sConfig.GetFloatDefault("Rate.Creature.Elite.WORLDBOSS.Damage", 1.0f); - rate_values[RATE_CREATURE_ELITE_RARE_DAMAGE] = sConfig.GetFloatDefault("Rate.Creature.Elite.RARE.Damage", 1.0f); - rate_values[RATE_CREATURE_NORMAL_HP] = sConfig.GetFloatDefault("Rate.Creature.Normal.HP", 1.0f); - rate_values[RATE_CREATURE_ELITE_ELITE_HP] = sConfig.GetFloatDefault("Rate.Creature.Elite.Elite.HP", 1.0f); - rate_values[RATE_CREATURE_ELITE_RAREELITE_HP] = sConfig.GetFloatDefault("Rate.Creature.Elite.RAREELITE.HP", 1.0f); - rate_values[RATE_CREATURE_ELITE_WORLDBOSS_HP] = sConfig.GetFloatDefault("Rate.Creature.Elite.WORLDBOSS.HP", 1.0f); - rate_values[RATE_CREATURE_ELITE_RARE_HP] = sConfig.GetFloatDefault("Rate.Creature.Elite.RARE.HP", 1.0f); - rate_values[RATE_CREATURE_NORMAL_SPELLDAMAGE] = sConfig.GetFloatDefault("Rate.Creature.Normal.SpellDamage", 1.0f); - rate_values[RATE_CREATURE_ELITE_ELITE_SPELLDAMAGE] = sConfig.GetFloatDefault("Rate.Creature.Elite.Elite.SpellDamage", 1.0f); - rate_values[RATE_CREATURE_ELITE_RAREELITE_SPELLDAMAGE] = sConfig.GetFloatDefault("Rate.Creature.Elite.RAREELITE.SpellDamage", 1.0f); - rate_values[RATE_CREATURE_ELITE_WORLDBOSS_SPELLDAMAGE] = sConfig.GetFloatDefault("Rate.Creature.Elite.WORLDBOSS.SpellDamage", 1.0f); - rate_values[RATE_CREATURE_ELITE_RARE_SPELLDAMAGE] = sConfig.GetFloatDefault("Rate.Creature.Elite.RARE.SpellDamage", 1.0f); - rate_values[RATE_CREATURE_AGGRO] = sConfig.GetFloatDefault("Rate.Creature.Aggro", 1.0f); - rate_values[RATE_REST_INGAME] = sConfig.GetFloatDefault("Rate.Rest.InGame", 1.0f); - rate_values[RATE_REST_OFFLINE_IN_TAVERN_OR_CITY] = sConfig.GetFloatDefault("Rate.Rest.Offline.InTavernOrCity", 1.0f); - rate_values[RATE_REST_OFFLINE_IN_WILDERNESS] = sConfig.GetFloatDefault("Rate.Rest.Offline.InWilderness", 1.0f); - rate_values[RATE_DAMAGE_FALL] = sConfig.GetFloatDefault("Rate.Damage.Fall", 1.0f); - rate_values[RATE_AUCTION_TIME] = sConfig.GetFloatDefault("Rate.Auction.Time", 1.0f); - rate_values[RATE_AUCTION_DEPOSIT] = sConfig.GetFloatDefault("Rate.Auction.Deposit", 1.0f); - rate_values[RATE_AUCTION_CUT] = sConfig.GetFloatDefault("Rate.Auction.Cut", 1.0f); - rate_values[RATE_HONOR] = sConfig.GetFloatDefault("Rate.Honor",1.0f); - rate_values[RATE_MINING_AMOUNT] = sConfig.GetFloatDefault("Rate.Mining.Amount",1.0f); - rate_values[RATE_MINING_NEXT] = sConfig.GetFloatDefault("Rate.Mining.Next",1.0f); - rate_values[RATE_INSTANCE_RESET_TIME] = sConfig.GetFloatDefault("Rate.InstanceResetTime",1.0f); - rate_values[RATE_TALENT] = sConfig.GetFloatDefault("Rate.Talent",1.0f); - if(rate_values[RATE_TALENT] < 0.0f) - { - sLog.outError("Rate.Talent (%f) mustbe > 0. Using 1 instead.",rate_values[RATE_TALENT]); - rate_values[RATE_TALENT] = 1.0f; - } - rate_values[RATE_CORPSE_DECAY_LOOTED] = sConfig.GetFloatDefault("Rate.Corpse.Decay.Looted",0.1f); - - rate_values[RATE_TARGET_POS_RECALCULATION_RANGE] = sConfig.GetFloatDefault("TargetPosRecalculateRange",1.5f); - if(rate_values[RATE_TARGET_POS_RECALCULATION_RANGE] < CONTACT_DISTANCE) - { - sLog.outError("TargetPosRecalculateRange (%f) must be >= %f. Using %f instead.",rate_values[RATE_TARGET_POS_RECALCULATION_RANGE],CONTACT_DISTANCE,CONTACT_DISTANCE); - rate_values[RATE_TARGET_POS_RECALCULATION_RANGE] = CONTACT_DISTANCE; - } - else if(rate_values[RATE_TARGET_POS_RECALCULATION_RANGE] > ATTACK_DISTANCE) - { - sLog.outError("TargetPosRecalculateRange (%f) must be <= %f. Using %f instead.",rate_values[RATE_TARGET_POS_RECALCULATION_RANGE],ATTACK_DISTANCE,ATTACK_DISTANCE); - rate_values[RATE_TARGET_POS_RECALCULATION_RANGE] = ATTACK_DISTANCE; - } - - rate_values[RATE_DURABILITY_LOSS_DAMAGE] = sConfig.GetFloatDefault("DurabilityLossChance.Damage",0.5f); - if(rate_values[RATE_DURABILITY_LOSS_DAMAGE] < 0.0f) - { - sLog.outError("DurabilityLossChance.Damage (%f) must be >=0. Using 0.0 instead.",rate_values[RATE_DURABILITY_LOSS_DAMAGE]); - rate_values[RATE_DURABILITY_LOSS_DAMAGE] = 0.0f; - } - rate_values[RATE_DURABILITY_LOSS_ABSORB] = sConfig.GetFloatDefault("DurabilityLossChance.Absorb",0.5f); - if(rate_values[RATE_DURABILITY_LOSS_ABSORB] < 0.0f) - { - sLog.outError("DurabilityLossChance.Absorb (%f) must be >=0. Using 0.0 instead.",rate_values[RATE_DURABILITY_LOSS_ABSORB]); - rate_values[RATE_DURABILITY_LOSS_ABSORB] = 0.0f; - } - rate_values[RATE_DURABILITY_LOSS_PARRY] = sConfig.GetFloatDefault("DurabilityLossChance.Parry",0.05f); - if(rate_values[RATE_DURABILITY_LOSS_PARRY] < 0.0f) - { - sLog.outError("DurabilityLossChance.Parry (%f) must be >=0. Using 0.0 instead.",rate_values[RATE_DURABILITY_LOSS_PARRY]); - rate_values[RATE_DURABILITY_LOSS_PARRY] = 0.0f; - } - rate_values[RATE_DURABILITY_LOSS_BLOCK] = sConfig.GetFloatDefault("DurabilityLossChance.Block",0.05f); - if(rate_values[RATE_DURABILITY_LOSS_BLOCK] < 0.0f) - { - sLog.outError("DurabilityLossChance.Block (%f) must be >=0. Using 0.0 instead.",rate_values[RATE_DURABILITY_LOSS_BLOCK]); - rate_values[RATE_DURABILITY_LOSS_BLOCK] = 0.0f; - } - - ///- Read other configuration items from the config file - - m_configs[CONFIG_COMPRESSION] = sConfig.GetIntDefault("Compression", 1); - if(m_configs[CONFIG_COMPRESSION] < 1 || m_configs[CONFIG_COMPRESSION] > 9) - { - sLog.outError("Compression level (%i) must be in range 1..9. Using default compression level (1).",m_configs[CONFIG_COMPRESSION]); - m_configs[CONFIG_COMPRESSION] = 1; - } - m_configs[CONFIG_ADDON_CHANNEL] = sConfig.GetBoolDefault("AddonChannel", true); - m_configs[CONFIG_GRID_UNLOAD] = sConfig.GetBoolDefault("GridUnload", true); - m_configs[CONFIG_INTERVAL_SAVE] = sConfig.GetIntDefault("PlayerSaveInterval", 900000); - - m_configs[CONFIG_INTERVAL_GRIDCLEAN] = sConfig.GetIntDefault("GridCleanUpDelay", 300000); - if(m_configs[CONFIG_INTERVAL_GRIDCLEAN] < MIN_GRID_DELAY) - { - sLog.outError("GridCleanUpDelay (%i) must be greater %u. Use this minimal value.",m_configs[CONFIG_INTERVAL_GRIDCLEAN],MIN_GRID_DELAY); - m_configs[CONFIG_INTERVAL_GRIDCLEAN] = MIN_GRID_DELAY; - } - if(reload) - MapManager::Instance().SetGridCleanUpDelay(m_configs[CONFIG_INTERVAL_GRIDCLEAN]); - - m_configs[CONFIG_INTERVAL_MAPUPDATE] = sConfig.GetIntDefault("MapUpdateInterval", 100); - if(m_configs[CONFIG_INTERVAL_MAPUPDATE] < MIN_MAP_UPDATE_DELAY) - { - sLog.outError("MapUpdateInterval (%i) must be greater %u. Use this minimal value.",m_configs[CONFIG_INTERVAL_MAPUPDATE],MIN_MAP_UPDATE_DELAY); - m_configs[CONFIG_INTERVAL_MAPUPDATE] = MIN_MAP_UPDATE_DELAY; - } - if(reload) - MapManager::Instance().SetMapUpdateInterval(m_configs[CONFIG_INTERVAL_MAPUPDATE]); - - m_configs[CONFIG_INTERVAL_CHANGEWEATHER] = sConfig.GetIntDefault("ChangeWeatherInterval", 600000); - - if(reload) - { - uint32 val = sConfig.GetIntDefault("WorldServerPort", DEFAULT_WORLDSERVER_PORT); - if(val!=m_configs[CONFIG_PORT_WORLD]) - sLog.outError("WorldServerPort option can't be changed at mangosd.conf reload, using current value (%u).",m_configs[CONFIG_PORT_WORLD]); - } - else - m_configs[CONFIG_PORT_WORLD] = sConfig.GetIntDefault("WorldServerPort", DEFAULT_WORLDSERVER_PORT); - - if(reload) - { - uint32 val = sConfig.GetIntDefault("SocketSelectTime", DEFAULT_SOCKET_SELECT_TIME); - if(val!=m_configs[CONFIG_SOCKET_SELECTTIME]) - sLog.outError("SocketSelectTime option can't be changed at mangosd.conf reload, using current value (%u).",m_configs[DEFAULT_SOCKET_SELECT_TIME]); - } - else - m_configs[CONFIG_SOCKET_SELECTTIME] = sConfig.GetIntDefault("SocketSelectTime", DEFAULT_SOCKET_SELECT_TIME); - - - m_configs[CONFIG_TCP_NO_DELAY] = sConfig.GetBoolDefault("TcpNoDelay", false); - m_configs[CONFIG_GROUP_XP_DISTANCE] = sConfig.GetIntDefault("MaxGroupXPDistance", 74); - /// \todo Add MonsterSight and GuarderSight (with meaning) in mangosd.conf or put them as define - m_configs[CONFIG_SIGHT_MONSTER] = sConfig.GetIntDefault("MonsterSight", 50); - m_configs[CONFIG_SIGHT_GUARDER] = sConfig.GetIntDefault("GuarderSight", 50); - - if(reload) - { - uint32 val = sConfig.GetIntDefault("GameType", 0); - if(val!=m_configs[CONFIG_GAME_TYPE]) - sLog.outError("GameType option can't be changed at mangosd.conf reload, using current value (%u).",m_configs[CONFIG_GAME_TYPE]); - } - else - m_configs[CONFIG_GAME_TYPE] = sConfig.GetIntDefault("GameType", 0); - - if(reload) - { - uint32 val = sConfig.GetIntDefault("RealmZone", REALM_ZONE_DEVELOPMENT); - if(val!=m_configs[CONFIG_REALM_ZONE]) - sLog.outError("RealmZone option can't be changed at mangosd.conf reload, using current value (%u).",m_configs[CONFIG_REALM_ZONE]); - } - else - m_configs[CONFIG_REALM_ZONE] = sConfig.GetIntDefault("RealmZone", REALM_ZONE_DEVELOPMENT); - - m_configs[CONFIG_ALLOW_TWO_SIDE_ACCOUNTS] = sConfig.GetBoolDefault("AllowTwoSide.Accounts", false); - m_configs[CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHAT] = sConfig.GetBoolDefault("AllowTwoSide.Interaction.Chat",false); - m_configs[CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHANNEL] = sConfig.GetBoolDefault("AllowTwoSide.Interaction.Channel",false); - m_configs[CONFIG_ALLOW_TWO_SIDE_INTERACTION_GROUP] = sConfig.GetBoolDefault("AllowTwoSide.Interaction.Group",false); - m_configs[CONFIG_ALLOW_TWO_SIDE_INTERACTION_GUILD] = sConfig.GetBoolDefault("AllowTwoSide.Interaction.Guild",false); - m_configs[CONFIG_ALLOW_TWO_SIDE_INTERACTION_AUCTION] = sConfig.GetBoolDefault("AllowTwoSide.Interaction.Auction",false); - m_configs[CONFIG_ALLOW_TWO_SIDE_INTERACTION_MAIL] = sConfig.GetBoolDefault("AllowTwoSide.Interaction.Mail",false); - m_configs[CONFIG_ALLOW_TWO_SIDE_WHO_LIST] = sConfig.GetBoolDefault("AllowTwoSide.WhoList", false); - m_configs[CONFIG_ALLOW_TWO_SIDE_ADD_FRIEND] = sConfig.GetBoolDefault("AllowTwoSide.AddFriend", false); - m_configs[CONFIG_STRICT_PLAYER_NAMES] = sConfig.GetIntDefault("StrictPlayerNames", 0); - m_configs[CONFIG_STRICT_CHARTER_NAMES] = sConfig.GetIntDefault("StrictCharterNames", 0); - m_configs[CONFIG_STRICT_PET_NAMES] = sConfig.GetIntDefault("StrictPetNames", 0); - - m_configs[CONFIG_CHARACTERS_CREATING_DISABLED] = sConfig.GetIntDefault("CharactersCreatingDisabled", 0); - - m_configs[CONFIG_CHARACTERS_PER_REALM] = sConfig.GetIntDefault("CharactersPerRealm", 10); - if(m_configs[CONFIG_CHARACTERS_PER_REALM] < 1 || m_configs[CONFIG_CHARACTERS_PER_REALM] > 10) - { - sLog.outError("CharactersPerRealm (%i) must be in range 1..10. Set to 10.",m_configs[CONFIG_CHARACTERS_PER_REALM]); - m_configs[CONFIG_CHARACTERS_PER_REALM] = 10; - } - - // must be after CONFIG_CHARACTERS_PER_REALM - m_configs[CONFIG_CHARACTERS_PER_ACCOUNT] = sConfig.GetIntDefault("CharactersPerAccount", 50); - if(m_configs[CONFIG_CHARACTERS_PER_ACCOUNT] < m_configs[CONFIG_CHARACTERS_PER_REALM]) - { - sLog.outError("CharactersPerAccount (%i) can't be less than CharactersPerRealm (%i).",m_configs[CONFIG_CHARACTERS_PER_ACCOUNT],m_configs[CONFIG_CHARACTERS_PER_REALM]); - m_configs[CONFIG_CHARACTERS_PER_ACCOUNT] = m_configs[CONFIG_CHARACTERS_PER_REALM]; - } - - m_configs[CONFIG_SKIP_CINEMATICS] = sConfig.GetIntDefault("SkipCinematics", 0); - if(m_configs[CONFIG_SKIP_CINEMATICS] < 0 || m_configs[CONFIG_SKIP_CINEMATICS] > 2) - { - sLog.outError("SkipCinematics (%i) must be in range 0..2. Set to 0.",m_configs[CONFIG_SKIP_CINEMATICS]); - m_configs[CONFIG_SKIP_CINEMATICS] = 0; - } - - - if(reload) - { - uint32 val = sConfig.GetIntDefault("MaxPlayerLevel", 60); - if(val!=m_configs[CONFIG_MAX_PLAYER_LEVEL]) - sLog.outError("MaxPlayerLevel option can't be changed at mangosd.conf reload, using current value (%u).",m_configs[CONFIG_MAX_PLAYER_LEVEL]); - } - else - m_configs[CONFIG_MAX_PLAYER_LEVEL] = sConfig.GetIntDefault("MaxPlayerLevel", 60); - if(m_configs[CONFIG_MAX_PLAYER_LEVEL] > 255) - { - sLog.outError("MaxPlayerLevel (%i) must be in range 1..255. Set to 255.",m_configs[CONFIG_MAX_PLAYER_LEVEL]); - m_configs[CONFIG_MAX_PLAYER_LEVEL] = 255; - } - - m_configs[CONFIG_START_PLAYER_LEVEL] = sConfig.GetIntDefault("StartPlayerLevel", 1); - if(m_configs[CONFIG_START_PLAYER_LEVEL] < 1) - { - sLog.outError("StartPlayerLevel (%i) must be in range 1..MaxPlayerLevel(%u). Set to 1.",m_configs[CONFIG_START_PLAYER_LEVEL],m_configs[CONFIG_MAX_PLAYER_LEVEL]); - m_configs[CONFIG_START_PLAYER_LEVEL] = 1; - } - else if(m_configs[CONFIG_START_PLAYER_LEVEL] > m_configs[CONFIG_MAX_PLAYER_LEVEL]) - { - sLog.outError("StartPlayerLevel (%i) must be in range 1..MaxPlayerLevel(%u). Set to %u.",m_configs[CONFIG_START_PLAYER_LEVEL],m_configs[CONFIG_MAX_PLAYER_LEVEL],m_configs[CONFIG_MAX_PLAYER_LEVEL]); - m_configs[CONFIG_START_PLAYER_LEVEL] = m_configs[CONFIG_MAX_PLAYER_LEVEL]; - } - m_configs[CONFIG_MAX_HONOR_POINTS] = sConfig.GetIntDefault("MaxHonorPoints", 75000); - m_configs[CONFIG_MAX_ARENA_POINTS] = sConfig.GetIntDefault("MaxArenaPoints", 5000); - - m_configs[CONFIG_INSTANCE_IGNORE_LEVEL] = sConfig.GetBoolDefault("Instance.IgnoreLevel", false); - m_configs[CONFIG_INSTANCE_IGNORE_RAID] = sConfig.GetBoolDefault("Instance.IgnoreRaid", false); - - m_configs[CONFIG_BATTLEGROUND_CAST_DESERTER] = sConfig.GetBoolDefault("Battleground.CastDeserter", true); - m_configs[CONFIG_BATTLEGROUND_QUEUE_ANNOUNCER_ENABLE] = sConfig.GetBoolDefault("Battleground.QueueAnnouncer.Enable", true); - m_configs[CONFIG_BATTLEGROUND_QUEUE_ANNOUNCER_PLAYERONLY] = sConfig.GetBoolDefault("Battleground.QueueAnnouncer.PlayerOnly", false); - - m_configs[CONFIG_CAST_UNSTUCK] = sConfig.GetBoolDefault("CastUnstuck", true); - m_configs[CONFIG_INSTANCE_RESET_TIME_HOUR] = sConfig.GetIntDefault("Instance.ResetTimeHour", 4); - m_configs[CONFIG_INSTANCE_UNLOAD_DELAY] = sConfig.GetIntDefault("Instance.UnloadDelay", 1800000); - - m_configs[CONFIG_MAX_PRIMARY_TRADE_SKILL] = sConfig.GetIntDefault("MaxPrimaryTradeSkill", 2); - m_configs[CONFIG_MIN_PETITION_SIGNS] = sConfig.GetIntDefault("MinPetitionSigns", 9); - if(m_configs[CONFIG_MIN_PETITION_SIGNS] > 9) - { - sLog.outError("MinPetitionSigns (%i) must be in range 0..9. Set to 9.",m_configs[CONFIG_MIN_PETITION_SIGNS]); - m_configs[CONFIG_MIN_PETITION_SIGNS] = 9; - } - - m_configs[CONFIG_GM_WISPERING_TO] = sConfig.GetBoolDefault("GM.WhisperingTo",false); - m_configs[CONFIG_GM_IN_GM_LIST] = sConfig.GetBoolDefault("GM.InGMList",false); - m_configs[CONFIG_GM_IN_WHO_LIST] = sConfig.GetBoolDefault("GM.InWhoList",false); - m_configs[CONFIG_GM_LOGIN_STATE] = sConfig.GetIntDefault("GM.LoginState",2); - m_configs[CONFIG_GM_LOG_TRADE] = sConfig.GetBoolDefault("GM.LogTrade", false); - - m_configs[CONFIG_GROUP_VISIBILITY] = sConfig.GetIntDefault("Visibility.GroupMode",0); - - m_configs[CONFIG_MAIL_DELIVERY_DELAY] = sConfig.GetIntDefault("MailDeliveryDelay",HOUR); - - m_configs[CONFIG_UPTIME_UPDATE] = sConfig.GetIntDefault("UpdateUptimeInterval", 10); - if(m_configs[CONFIG_UPTIME_UPDATE]<=0) - { - sLog.outError("UpdateUptimeInterval (%i) must be > 0, set to default 10.",m_configs[CONFIG_UPTIME_UPDATE]); - m_configs[CONFIG_UPTIME_UPDATE] = 10; - } - if(reload) - { - m_timers[WUPDATE_UPTIME].SetInterval(m_configs[CONFIG_UPTIME_UPDATE]*MINUTE*1000); - m_timers[WUPDATE_UPTIME].Reset(); - } - - m_configs[CONFIG_SKILL_CHANCE_ORANGE] = sConfig.GetIntDefault("SkillChance.Orange",100); - m_configs[CONFIG_SKILL_CHANCE_YELLOW] = sConfig.GetIntDefault("SkillChance.Yellow",75); - m_configs[CONFIG_SKILL_CHANCE_GREEN] = sConfig.GetIntDefault("SkillChance.Green",25); - m_configs[CONFIG_SKILL_CHANCE_GREY] = sConfig.GetIntDefault("SkillChance.Grey",0); - - m_configs[CONFIG_SKILL_CHANCE_MINING_STEPS] = sConfig.GetIntDefault("SkillChance.MiningSteps",75); - m_configs[CONFIG_SKILL_CHANCE_SKINNING_STEPS] = sConfig.GetIntDefault("SkillChance.SkinningSteps",75); - - m_configs[CONFIG_SKILL_PROSPECTING] = sConfig.GetBoolDefault("SkillChance.Prospecting",false); - - m_configs[CONFIG_SKILL_GAIN_CRAFTING] = sConfig.GetIntDefault("SkillGain.Crafting", 1); - if(m_configs[CONFIG_SKILL_GAIN_CRAFTING] < 0) - { - sLog.outError("SkillGain.Crafting (%i) can't be negative. Set to 1.",m_configs[CONFIG_SKILL_GAIN_CRAFTING]); - m_configs[CONFIG_SKILL_GAIN_CRAFTING] = 1; - } - - m_configs[CONFIG_SKILL_GAIN_DEFENSE] = sConfig.GetIntDefault("SkillGain.Defense", 1); - if(m_configs[CONFIG_SKILL_GAIN_DEFENSE] < 0) - { - sLog.outError("SkillGain.Defense (%i) can't be negative. Set to 1.",m_configs[CONFIG_SKILL_GAIN_DEFENSE]); - m_configs[CONFIG_SKILL_GAIN_DEFENSE] = 1; - } - - m_configs[CONFIG_SKILL_GAIN_GATHERING] = sConfig.GetIntDefault("SkillGain.Gathering", 1); - if(m_configs[CONFIG_SKILL_GAIN_GATHERING] < 0) - { - sLog.outError("SkillGain.Gathering (%i) can't be negative. Set to 1.",m_configs[CONFIG_SKILL_GAIN_GATHERING]); - m_configs[CONFIG_SKILL_GAIN_GATHERING] = 1; - } - - m_configs[CONFIG_SKILL_GAIN_WEAPON] = sConfig.GetIntDefault("SkillGain.Weapon", 1); - if(m_configs[CONFIG_SKILL_GAIN_WEAPON] < 0) - { - sLog.outError("SkillGain.Weapon (%i) can't be negative. Set to 1.",m_configs[CONFIG_SKILL_GAIN_WEAPON]); - m_configs[CONFIG_SKILL_GAIN_WEAPON] = 1; - } - - m_configs[CONFIG_MAX_OVERSPEED_PINGS] = sConfig.GetIntDefault("MaxOverspeedPings",2); - if(m_configs[CONFIG_MAX_OVERSPEED_PINGS] != 0 && m_configs[CONFIG_MAX_OVERSPEED_PINGS] < 2) - { - sLog.outError("MaxOverspeedPings (%i) must be in range 2..infinity (or 0 to disable check. Set to 2.",m_configs[CONFIG_MAX_OVERSPEED_PINGS]); - m_configs[CONFIG_MAX_OVERSPEED_PINGS] = 2; - } - - m_configs[CONFIG_SAVE_RESPAWN_TIME_IMMEDIATLY] = sConfig.GetBoolDefault("SaveRespawnTimeImmediately",true); - m_configs[CONFIG_WEATHER] = sConfig.GetBoolDefault("ActivateWeather",true); - - if(reload) - { - uint32 val = sConfig.GetIntDefault("Expansion",1); - if(val!=m_configs[CONFIG_EXPANSION]) - sLog.outError("Expansion option can't be changed at mangosd.conf reload, using current value (%u).",m_configs[CONFIG_EXPANSION]); - } - else - m_configs[CONFIG_EXPANSION] = sConfig.GetIntDefault("Expansion",1); - - m_configs[CONFIG_CHATFLOOD_MESSAGE_COUNT] = sConfig.GetIntDefault("ChatFlood.MessageCount",10); - m_configs[CONFIG_CHATFLOOD_MESSAGE_DELAY] = sConfig.GetIntDefault("ChatFlood.MessageDelay",1); - m_configs[CONFIG_CHATFLOOD_MUTE_TIME] = sConfig.GetIntDefault("ChatFlood.MuteTime",10); - - m_configs[CONFIG_EVENT_ANNOUNCE] = sConfig.GetIntDefault("Event.Announce",0); - - m_configs[CONFIG_CREATURE_FAMILY_ASSISTEMCE_RADIUS] = sConfig.GetIntDefault("CreatureFamilyAssistenceRadius",10); - - m_configs[CONFIG_WORLD_BOSS_LEVEL_DIFF] = sConfig.GetIntDefault("WorldBossLevelDiff",3); - - // note: disable value (-1) will assigned as 0xFFFFFFF, to prevent overflow at calculations limit it to max possible player level (255) - m_configs[CONFIG_QUEST_LOW_LEVEL_HIDE_DIFF] = sConfig.GetIntDefault("Quests.LowLevelHideDiff",4); - if(m_configs[CONFIG_QUEST_LOW_LEVEL_HIDE_DIFF] > 255) - m_configs[CONFIG_QUEST_LOW_LEVEL_HIDE_DIFF] = 255; - m_configs[CONFIG_QUEST_HIGH_LEVEL_HIDE_DIFF] = sConfig.GetIntDefault("Quests.HighLevelHideDiff",7); - if(m_configs[CONFIG_QUEST_HIGH_LEVEL_HIDE_DIFF] > 255) - m_configs[CONFIG_QUEST_HIGH_LEVEL_HIDE_DIFF] = 255; - - m_configs[CONFIG_DETECT_POS_COLLISION] = sConfig.GetBoolDefault("DetectPosCollision", true); - - m_configs[CONFIG_RESTRICTED_LFG_CHANNEL] = sConfig.GetBoolDefault("Channel.RestrictedLfg", true); - m_configs[CONFIG_SILENTLY_GM_JOIN_TO_CHANNEL] = sConfig.GetBoolDefault("Channel.SilentlyGMJoin", false); - - m_configs[CONFIG_TALENTS_INSPECTING] = sConfig.GetBoolDefault("TalentsInspecting", true); - m_configs[CONFIG_CHAT_FAKE_MESSAGE_PREVENTING] = sConfig.GetBoolDefault("ChatFakeMessagePreventing", false); - - m_configs[CONFIG_CORPSE_DECAY_NORMAL] = sConfig.GetIntDefault("Corpse.Decay.NORMAL", 60); - m_configs[CONFIG_CORPSE_DECAY_RARE] = sConfig.GetIntDefault("Corpse.Decay.RARE", 300); - m_configs[CONFIG_CORPSE_DECAY_ELITE] = sConfig.GetIntDefault("Corpse.Decay.ELITE", 300); - m_configs[CONFIG_CORPSE_DECAY_RAREELITE] = sConfig.GetIntDefault("Corpse.Decay.RAREELITE", 300); - m_configs[CONFIG_CORPSE_DECAY_WORLDBOSS] = sConfig.GetIntDefault("Corpse.Decay.WORLDBOSS", 3600); - - m_configs[CONFIG_DEATH_SICKNESS_LEVEL] = sConfig.GetIntDefault("Death.SicknessLevel", 11); - m_configs[CONFIG_DEATH_CORPSE_RECLAIM_DELAY_PVP] = sConfig.GetBoolDefault("Death.CorpseReclaimDelay.PvP", true); - m_configs[CONFIG_DEATH_CORPSE_RECLAIM_DELAY_PVE] = sConfig.GetBoolDefault("Death.CorpseReclaimDelay.PvE", true); - - m_configs[CONFIG_THREAT_RADIUS] = sConfig.GetIntDefault("ThreatRadius", 100); - - // always use declined names in the russian client - m_configs[CONFIG_DECLINED_NAMES_USED] = - (m_configs[CONFIG_REALM_ZONE] == REALM_ZONE_RUSSIAN) ? true : sConfig.GetBoolDefault("DeclinedNames", false); - - m_configs[CONFIG_LISTEN_RANGE_SAY] = sConfig.GetIntDefault("ListenRange.Say", 25); - m_configs[CONFIG_LISTEN_RANGE_TEXTEMOTE] = sConfig.GetIntDefault("ListenRange.TextEmote", 25); - m_configs[CONFIG_LISTEN_RANGE_YELL] = sConfig.GetIntDefault("ListenRange.Yell", 300); - - - m_VisibleUnitGreyDistance = sConfig.GetFloatDefault("Visibility.Distance.Grey.Unit", 1); - if(m_VisibleUnitGreyDistance > MAX_VISIBILITY_DISTANCE) - { - sLog.outError("Visibility.Distance.Grey.Unit can't be greater %f",MAX_VISIBILITY_DISTANCE); - m_VisibleUnitGreyDistance = MAX_VISIBILITY_DISTANCE; - } - m_VisibleObjectGreyDistance = sConfig.GetFloatDefault("Visibility.Distance.Grey.Object", 10); - if(m_VisibleObjectGreyDistance > MAX_VISIBILITY_DISTANCE) - { - sLog.outError("Visibility.Distance.Grey.Object can't be greater %f",MAX_VISIBILITY_DISTANCE); - m_VisibleObjectGreyDistance = MAX_VISIBILITY_DISTANCE; - } - - m_MaxVisibleDistanceForCreature = sConfig.GetFloatDefault("Visibility.Distance.Creature", DEFAULT_VISIBILITY_DISTANCE); - if(m_MaxVisibleDistanceForCreature < 45*sWorld.getRate(RATE_CREATURE_AGGRO)) - { - sLog.outError("Visibility.Distance.Creature can't be less max aggro radius %f",45*sWorld.getRate(RATE_CREATURE_AGGRO)); - m_MaxVisibleDistanceForCreature = 45*sWorld.getRate(RATE_CREATURE_AGGRO); - } - else if(m_MaxVisibleDistanceForCreature + m_VisibleUnitGreyDistance > MAX_VISIBILITY_DISTANCE) - { - sLog.outError("Visibility. Distance .Creature can't be greater %f",MAX_VISIBILITY_DISTANCE - m_VisibleUnitGreyDistance); - m_MaxVisibleDistanceForCreature = MAX_VISIBILITY_DISTANCE-m_VisibleUnitGreyDistance; - } - m_MaxVisibleDistanceForPlayer = sConfig.GetFloatDefault("Visibility.Distance.Player", DEFAULT_VISIBILITY_DISTANCE); - if(m_MaxVisibleDistanceForPlayer < 45*sWorld.getRate(RATE_CREATURE_AGGRO)) - { - sLog.outError("Visibility.Distance.Player can't be less max aggro radius %f",45*sWorld.getRate(RATE_CREATURE_AGGRO)); - m_MaxVisibleDistanceForPlayer = 45*sWorld.getRate(RATE_CREATURE_AGGRO); - } - else if(m_MaxVisibleDistanceForPlayer + m_VisibleUnitGreyDistance > MAX_VISIBILITY_DISTANCE) - { - sLog.outError("Visibility.Distance.Player can't be greater %f",MAX_VISIBILITY_DISTANCE - m_VisibleUnitGreyDistance); - m_MaxVisibleDistanceForPlayer = MAX_VISIBILITY_DISTANCE - m_VisibleUnitGreyDistance; - } - m_MaxVisibleDistanceForObject = sConfig.GetFloatDefault("Visibility.Distance.Gameobject", DEFAULT_VISIBILITY_DISTANCE); - if(m_MaxVisibleDistanceForObject < INTERACTION_DISTANCE) - { - sLog.outError("Visibility.Distance.Object can't be less max aggro radius %f",float(INTERACTION_DISTANCE)); - m_MaxVisibleDistanceForObject = INTERACTION_DISTANCE; - } - else if(m_MaxVisibleDistanceForObject + m_VisibleObjectGreyDistance > MAX_VISIBILITY_DISTANCE) - { - sLog.outError("Visibility.Distance.Object can't be greater %f",MAX_VISIBILITY_DISTANCE-m_VisibleObjectGreyDistance); - m_MaxVisibleDistanceForObject = MAX_VISIBILITY_DISTANCE - m_VisibleObjectGreyDistance; - } - m_MaxVisibleDistanceInFlight = sConfig.GetFloatDefault("Visibility.Distance.InFlight", DEFAULT_VISIBILITY_DISTANCE); - if(m_MaxVisibleDistanceInFlight + m_VisibleObjectGreyDistance > MAX_VISIBILITY_DISTANCE) - { - sLog.outError("Visibility.Distance.InFlight can't be greater %f",MAX_VISIBILITY_DISTANCE-m_VisibleObjectGreyDistance); - m_MaxVisibleDistanceInFlight = MAX_VISIBILITY_DISTANCE - m_VisibleObjectGreyDistance; - } - - ///- Read the "Data" directory from the config file - std::string dataPath = sConfig.GetStringDefault("DataDir","./"); - if( dataPath.at(dataPath.length()-1)!='/' && dataPath.at(dataPath.length()-1)!='\\' ) - dataPath.append("/"); - - if(reload) - { - if(dataPath!=m_dataPath) - sLog.outError("DataDir option can't be changed at mangosd.conf reload, using current value (%s).",m_dataPath.c_str()); - } - else - { - m_dataPath = dataPath; - sLog.outString("Using DataDir %s",m_dataPath.c_str()); - } - - bool enableLOS = sConfig.GetBoolDefault("vmap.enableLOS", false); - bool enableHeight = sConfig.GetBoolDefault("vmap.enableHeight", false); - std::string ignoreMapIds = sConfig.GetStringDefault("vmap.ignoreMapIds", ""); - std::string ignoreSpellIds = sConfig.GetStringDefault("vmap.ignoreSpellIds", ""); - VMAP::VMapFactory::createOrGetVMapManager()->setEnableLineOfSightCalc(enableLOS); - VMAP::VMapFactory::createOrGetVMapManager()->setEnableHeightCalc(enableHeight); - VMAP::VMapFactory::createOrGetVMapManager()->preventMapsFromBeingUsed(ignoreMapIds.c_str()); - VMAP::VMapFactory::preventSpellsFromBeingTestedForLoS(ignoreSpellIds.c_str()); - sLog.outString( "WORLD: VMap support included. LineOfSight:%i, getHeight:%i",enableLOS, enableHeight); - sLog.outString( "WORLD: VMap data directory is: %svmaps",m_dataPath.c_str()); - sLog.outString( "WORLD: VMap config keys are: vmap.enableLOS, vmap.enableHeight, vmap.ignoreMapIds, vmap.ignoreSpellIds"); -} - -/// Initialize the World -void World::SetInitialWorldSettings() -{ - ///- Initialize the random number generator - srand((unsigned int)time(NULL)); - - ///- Initialize config settings - LoadConfigSettings(); - - ///- Init highest guids before any table loading to prevent using not initialized guids in some code. - objmgr.SetHighestGuids(); - - ///- Check the existence of the map files for all races' startup areas. - if( !MapManager::ExistMapAndVMap(0,-6240.32f, 331.033f) - ||!MapManager::ExistMapAndVMap(0,-8949.95f,-132.493f) - ||!MapManager::ExistMapAndVMap(0,-8949.95f,-132.493f) - ||!MapManager::ExistMapAndVMap(1,-618.518f,-4251.67f) - ||!MapManager::ExistMapAndVMap(0, 1676.35f, 1677.45f) - ||!MapManager::ExistMapAndVMap(1, 10311.3f, 832.463f) - ||!MapManager::ExistMapAndVMap(1,-2917.58f,-257.98f) - ||m_configs[CONFIG_EXPANSION] && ( - !MapManager::ExistMapAndVMap(530,10349.6f,-6357.29f) || !MapManager::ExistMapAndVMap(530,-3961.64f,-13931.2f) ) ) - { - sLog.outError("Correct *.map files not found in path '%smaps' or *.vmap/*vmdir files in '%svmaps'. Please place *.map/*.vmap/*.vmdir files in appropriate directories or correct the DataDir value in the mangosd.conf file.",m_dataPath.c_str(),m_dataPath.c_str()); - exit(1); - } - - ///- Loading strings. Getting no records means core load has to be canceled because no error message can be output. - sLog.outString( "" ); - sLog.outString( "Loading MaNGOS strings..." ); - if (!objmgr.LoadMangosStrings()) - exit(1); // Error message displayed in function already - - ///- Update the realm entry in the database with the realm type from the config file - //No SQL injection as values are treated as integers - - // not send custom type REALM_FFA_PVP to realm list - uint32 server_type = IsFFAPvPRealm() ? REALM_TYPE_PVP : getConfig(CONFIG_GAME_TYPE); - uint32 realm_zone = getConfig(CONFIG_REALM_ZONE); - loginDatabase.PExecute("UPDATE realmlist SET icon = %u, timezone = %u WHERE id = '%d'", server_type, realm_zone, realmID); - - ///- Remove the bones after a restart - CharacterDatabase.PExecute("DELETE FROM corpse WHERE corpse_type = '0'"); - - ///- Load the DBC files - sLog.outString("Initialize data stores..."); - LoadDBCStores(m_dataPath); - DetectDBCLang(); - - sLog.outString( "Loading InstanceTemplate" ); - objmgr.LoadInstanceTemplate(); - - sLog.outString( "Loading SkillLineAbilityMultiMap Data..." ); - spellmgr.LoadSkillLineAbilityMap(); - - ///- Clean up and pack instances - sLog.outString( "Cleaning up instances..." ); - sInstanceSaveManager.CleanupInstances(); // must be called before `creature_respawn`/`gameobject_respawn` tables - - sLog.outString( "Packing instances..." ); - sInstanceSaveManager.PackInstances(); - - sLog.outString( "Loading Localization strings..." ); - objmgr.LoadCreatureLocales(); - objmgr.LoadGameObjectLocales(); - objmgr.LoadItemLocales(); - objmgr.LoadQuestLocales(); - objmgr.LoadNpcTextLocales(); - objmgr.LoadPageTextLocales(); - objmgr.SetDBCLocaleIndex(GetDefaultDbcLocale()); // Get once for all the locale index of DBC language (console/broadcasts) - - sLog.outString( "Loading Page Texts..." ); - objmgr.LoadPageTexts(); - - sLog.outString( "Loading Game Object Templates..." ); // must be after LoadPageTexts - objmgr.LoadGameobjectInfo(); - - sLog.outString( "Loading Spell Chain Data..." ); - spellmgr.LoadSpellChains(); - - sLog.outString( "Loading Spell Elixir types..." ); - spellmgr.LoadSpellElixirs(); - - sLog.outString( "Loading Spell Learn Skills..." ); - spellmgr.LoadSpellLearnSkills(); // must be after LoadSpellChains - - sLog.outString( "Loading Spell Learn Spells..." ); - spellmgr.LoadSpellLearnSpells(); - - sLog.outString( "Loading Spell Proc Event conditions..." ); - spellmgr.LoadSpellProcEvents(); - - sLog.outString( "Loading Aggro Spells Definitions..."); - spellmgr.LoadSpellThreats(); - - sLog.outString( "Loading NPC Texts..." ); - objmgr.LoadGossipText(); - - sLog.outString( "Loading Item Random Enchantments Table..." ); - LoadRandomEnchantmentsTable(); - - sLog.outString( "Loading Items..." ); // must be after LoadRandomEnchantmentsTable and LoadPageTexts - objmgr.LoadItemPrototypes(); - - sLog.outString( "Loading Item Texts..." ); - objmgr.LoadItemTexts(); - - sLog.outString( "Loading Creature Model Based Info Data..." ); - objmgr.LoadCreatureModelInfo(); - - sLog.outString( "Loading Equipment templates..."); - objmgr.LoadEquipmentTemplates(); - - sLog.outString( "Loading Creature templates..." ); - objmgr.LoadCreatureTemplates(); - - sLog.outString( "Loading SpellsScriptTarget..."); - spellmgr.LoadSpellScriptTarget(); // must be after LoadCreatureTemplates and LoadGameobjectInfo - - sLog.outString( "Loading Creature Reputation OnKill Data..." ); - objmgr.LoadReputationOnKill(); - - sLog.outString( "Loading Pet Create Spells..." ); - objmgr.LoadPetCreateSpells(); - - sLog.outString( "Loading Creature Data..." ); - objmgr.LoadCreatures(); - - sLog.outString( "Loading Creature Addon Data..." ); - objmgr.LoadCreatureAddons(); // must be after LoadCreatureTemplates() and LoadCreatures() - - sLog.outString( "Loading Creature Respawn Data..." ); // must be after PackInstances() - objmgr.LoadCreatureRespawnTimes(); - - sLog.outString( "Loading Gameobject Data..." ); - objmgr.LoadGameobjects(); - - sLog.outString( "Loading Gameobject Respawn Data..." ); // must be after PackInstances() - objmgr.LoadGameobjectRespawnTimes(); - - sLog.outString( "Loading Game Event Data..."); - gameeventmgr.LoadFromDB(); - - sLog.outString( "Loading Weather Data..." ); - objmgr.LoadWeatherZoneChances(); - - sLog.outString( "Loading Quests..." ); - objmgr.LoadQuests(); // must be loaded after DBCs, creature_template, item_template, gameobject tables - - sLog.outString( "Loading Quests Relations..." ); - objmgr.LoadQuestRelations(); // must be after quest load - - sLog.outString( "Loading AreaTrigger definitions..." ); - objmgr.LoadAreaTriggerTeleports(); // must be after item template load - - sLog.outString( "Loading Quest Area Triggers..." ); - objmgr.LoadQuestAreaTriggers(); // must be after LoadQuests - - sLog.outString( "Loading Tavern Area Triggers..." ); - objmgr.LoadTavernAreaTriggers(); - - sLog.outString( "Loading AreaTrigger script names..." ); - objmgr.LoadAreaTriggerScripts(); - - - sLog.outString( "Loading Graveyard-zone links..."); - objmgr.LoadGraveyardZones(); - - sLog.outString( "Loading Spell target coordinates..." ); - spellmgr.LoadSpellTargetPositions(); - - sLog.outString( "Loading SpellAffect definitions..." ); - spellmgr.LoadSpellAffects(); - - sLog.outString( "Loading spell pet auras..." ); - spellmgr.LoadSpellPetAuras(); - - sLog.outString( "Loading player Create Info & Level Stats..." ); - objmgr.LoadPlayerInfo(); - - sLog.outString( "Loading Exploration BaseXP Data..." ); - objmgr.LoadExplorationBaseXP(); - - sLog.outString( "Loading Pet Name Parts..." ); - objmgr.LoadPetNames(); - - sLog.outString( "Loading the max pet number..." ); - objmgr.LoadPetNumber(); - - sLog.outString( "Loading pet level stats..." ); - objmgr.LoadPetLevelInfo(); - - sLog.outString( "Loading Player Corpses..." ); - objmgr.LoadCorpses(); - - sLog.outString( "Loading Loot Tables..." ); - LoadLootTables(); - - sLog.outString( "Loading Skill Discovery Table..." ); - LoadSkillDiscoveryTable(); - - sLog.outString( "Loading Skill Extra Item Table..." ); - LoadSkillExtraItemTable(); - - sLog.outString( "Loading Skill Fishing base level requirements..." ); - objmgr.LoadFishingBaseSkillLevel(); - - ///- Load dynamic data tables from the database - sLog.outString( "Loading Auctions..." ); - objmgr.LoadAuctionItems(); - objmgr.LoadAuctions(); - - sLog.outString( "Loading Guilds..." ); - objmgr.LoadGuilds(); - - sLog.outString( "Loading ArenaTeams..." ); - objmgr.LoadArenaTeams(); - - sLog.outString( "Loading Groups..." ); - objmgr.LoadGroups(); - - sLog.outString( "Loading ReservedNames..." ); - objmgr.LoadReservedPlayersNames(); - - sLog.outString( "Loading GameObject for quests..." ); - objmgr.LoadGameObjectForQuests(); - - sLog.outString( "Loading BattleMasters..." ); - objmgr.LoadBattleMastersEntry(); - - sLog.outString( "Loading Waypoints..." ); - WaypointMgr.Load(); - - ///- Handle outdated emails (delete/return) - sLog.outString( "Returning old mails..." ); - objmgr.ReturnOrDeleteOldMails(false); - - ///- Load and initialize scripts - sLog.outString( "Loading Scripts..." ); - objmgr.LoadQuestStartScripts(); // must be after load Creature/Gameobject(Template/Data) and QuestTemplate - objmgr.LoadQuestEndScripts(); // must be after load Creature/Gameobject(Template/Data) and QuestTemplate - objmgr.LoadSpellScripts(); // must be after load Creature/Gameobject(Template/Data) - objmgr.LoadGameObjectScripts(); // must be after load Creature/Gameobject(Template/Data) - objmgr.LoadEventScripts(); // must be after load Creature/Gameobject(Template/Data) - - sLog.outString( "Initializing Scripts..." ); - if(!LoadScriptingModule()) - exit(1); - - ///- Initialize game time and timers - sLog.outString( "DEBUG:: Initialize game time and timers" ); - m_gameTime = time(NULL); - m_startTime=m_gameTime; - - tm local; - time_t curr; - time(&curr); - local=*(localtime(&curr)); // dereference and assign - char isoDate[128]; - sprintf( isoDate, "%04d-%02d-%02d %02d:%02d:%02d", - local.tm_year+1900, local.tm_mon+1, local.tm_mday, local.tm_hour, local.tm_min, local.tm_sec); - - WorldDatabase.PExecute("INSERT INTO uptime (startstring, starttime, uptime) VALUES('%s', %ld, 0)", isoDate, m_startTime ); - - m_timers[WUPDATE_OBJECTS].SetInterval(0); - m_timers[WUPDATE_SESSIONS].SetInterval(0); - m_timers[WUPDATE_WEATHERS].SetInterval(1000); - m_timers[WUPDATE_AUCTIONS].SetInterval(MINUTE*1000); //set auction update interval to 1 minute - m_timers[WUPDATE_UPTIME].SetInterval(m_configs[CONFIG_UPTIME_UPDATE]*MINUTE*1000); - //Update "uptime" table based on configuration entry in minutes. - m_timers[WUPDATE_CORPSES].SetInterval(20*MINUTE*1000); //erase corpses every 20 minutes - - //to set mailtimer to return mails every day between 4 and 5 am - //mailtimer is increased when updating auctions - //one second is 1000 -(tested on win system) - mail_timer = ((((localtime( &m_gameTime )->tm_hour + 20) % 24)* HOUR * 1000) / m_timers[WUPDATE_AUCTIONS].GetInterval() ); - //1440 - mail_timer_expires = ( (DAY * 1000) / (m_timers[WUPDATE_AUCTIONS].GetInterval())); - sLog.outDebug("Mail timer set to: %u, mail return is called every %u minutes", mail_timer, mail_timer_expires); - - ///- Initilize static helper structures - AIRegistry::Initialize(); - WaypointMovementGenerator::Initialize(); - Player::InitVisibleBits(); - - ///- Initialize MapManager - sLog.outString( "Starting Map System" ); - MapManager::Instance().Initialize(); - - ///- Initialize Battlegrounds - sLog.outString( "Starting BattleGround System" ); - sBattleGroundMgr.CreateInitialBattleGrounds(); - - //Not sure if this can be moved up in the sequence (with static data loading) as it uses MapManager - sLog.outString( "Loading Transports..." ); - MapManager::Instance().LoadTransports(); - - sLog.outString("Deleting expired bans..." ); - loginDatabase.Execute("DELETE FROM ip_banned WHERE unbandate<=UNIX_TIMESTAMP() AND unbandate<>bandate"); - - sLog.outString("Calculate next daily quest reset time..." ); - InitDailyQuestResetTime(); - - sLog.outString("Starting Game Event system..." ); - uint32 nextGameEvent = gameeventmgr.Initialize(); - m_timers[WUPDATE_EVENTS].SetInterval(nextGameEvent); //depend on next event - - sLog.outString( "WORLD: World initialized" ); -} -void World::DetectDBCLang() -{ - uint32 m_lang_confid = sConfig.GetIntDefault("DBC.Locale", 255); - - if(m_lang_confid != 255 && m_lang_confid >= MAX_LOCALE) - { - sLog.outError("Incorrect DBC.Locale! Must be >= 0 and < %d (set to 0)",MAX_LOCALE); - m_lang_confid = LOCALE_enUS; - } - - ChrRacesEntry const* race = sChrRacesStore.LookupEntry(1); - - std::string availableLocalsStr; - - int default_locale = MAX_LOCALE; - for (int i = MAX_LOCALE-1; i >= 0; --i) - { - if ( strlen(race->name[i]) > 0) // check by race names - { - default_locale = i; - m_availableDbcLocaleMask |= (1 << i); - availableLocalsStr += localeNames[i]; - availableLocalsStr += " "; - } - } - - if( default_locale != m_lang_confid && m_lang_confid < MAX_LOCALE && - (m_availableDbcLocaleMask & (1 << m_lang_confid)) ) - { - default_locale = m_lang_confid; - } - - if(default_locale >= MAX_LOCALE) - { - sLog.outError("Unable to determine your DBC Locale! (corrupt DBC?)"); - exit(1); - } - - m_defaultDbcLocale = LocaleConstant(default_locale); - - sLog.outString("Using %s DBC Locale as default. All available DBC locales: %s",localeNames[m_defaultDbcLocale],availableLocalsStr.empty() ? "" : availableLocalsStr.c_str()); -} - -/// Update the World ! -void World::Update(time_t diff) -{ - ///- Update the different timers - for(int i = 0; i < WUPDATE_COUNT; i++) - if(m_timers[i].GetCurrent()>=0) - m_timers[i].Update(diff); - else m_timers[i].SetCurrent(0); - - ///- Update the game time and check for shutdown time - _UpdateGameTime(); - - /// Handle daily quests reset time - if(m_gameTime > m_NextDailyQuestReset) - { - ResetDailyQuests(); - m_NextDailyQuestReset += DAY; - } - - ///
  • Handle auctions when the timer has passed - if (m_timers[WUPDATE_AUCTIONS].Passed()) - { - m_timers[WUPDATE_AUCTIONS].Reset(); - - ///- Update mails (return old mails with item, or delete them) - //(tested... works on win) - if (++mail_timer > mail_timer_expires) - { - mail_timer = 0; - objmgr.ReturnOrDeleteOldMails(true); - } - - AuctionHouseObject* AuctionMap; - for (int i = 0; i < 3; i++) - { - switch (i) - { - case 0: - AuctionMap = objmgr.GetAuctionsMap( 6 );//horde - break; - case 1: - AuctionMap = objmgr.GetAuctionsMap( 2 );//alliance - break; - case 2: - AuctionMap = objmgr.GetAuctionsMap( 7 );//neutral - break; - } - - ///- Handle expired auctions - AuctionHouseObject::AuctionEntryMap::iterator itr,next; - for (itr = AuctionMap->GetAuctionsBegin(); itr != AuctionMap->GetAuctionsEnd();itr = next) - { - next = itr; - ++next; - if (m_gameTime > (itr->second->time)) - { - ///- Either cancel the auction if there was no bidder - if (itr->second->bidder == 0) - { - objmgr.SendAuctionExpiredMail( itr->second ); - } - ///- Or perform the transaction - else - { - //we should send an "item sold" message if the seller is online - //we send the item to the winner - //we send the money to the seller - objmgr.SendAuctionSuccessfulMail( itr->second ); - objmgr.SendAuctionWonMail( itr->second ); - } - - ///- In any case clear the auction - //No SQL injection (Id is integer) - CharacterDatabase.PExecute("DELETE FROM auctionhouse WHERE id = '%u'",itr->second->Id); - objmgr.RemoveAItem(itr->second->item_guidlow); - delete itr->second; - AuctionMap->RemoveAuction(itr->first); - } - } - } - } - - ///
  • Handle session updates when the timer has passed - if (m_timers[WUPDATE_SESSIONS].Passed()) - { - m_timers[WUPDATE_SESSIONS].Reset(); - - UpdateSessions(diff); - } - - ///
  • Handle weather updates when the timer has passed - if (m_timers[WUPDATE_WEATHERS].Passed()) - { - m_timers[WUPDATE_WEATHERS].Reset(); - - ///- Send an update signal to Weather objects - WeatherMap::iterator itr, next; - for (itr = m_weathers.begin(); itr != m_weathers.end(); itr = next) - { - next = itr; - ++next; - - ///- and remove Weather objects for zones with no player - //As interval > WorldTick - if(!itr->second->Update(m_timers[WUPDATE_WEATHERS].GetInterval())) - { - delete itr->second; - m_weathers.erase(itr); - } - } - } - ///
  • Update uptime table - if (m_timers[WUPDATE_UPTIME].Passed()) - { - uint32 tmpDiff = (m_gameTime - m_startTime); - uint32 maxClientsNum = sWorld.GetMaxActiveSessionCount(); - - m_timers[WUPDATE_UPTIME].Reset(); - WorldDatabase.PExecute("UPDATE uptime SET uptime = %d, maxplayers = %d WHERE starttime = " I64FMTD, tmpDiff, maxClientsNum, uint64(m_startTime)); - } - - ///
  • Handle all other objects - if (m_timers[WUPDATE_OBJECTS].Passed()) - { - m_timers[WUPDATE_OBJECTS].Reset(); - ///- Update objects when the timer has passed (maps, transport, creatures,...) - MapManager::Instance().Update(diff); // As interval = 0 - - ///- Process necessary scripts - if (!m_scriptSchedule.empty()) - ScriptsProcess(); - - sBattleGroundMgr.Update(diff); - } - - // execute callbacks from sql queries that were queued recently - UpdateResultQueue(); - - ///- Erase corpses once every 20 minutes - if (m_timers[WUPDATE_CORPSES].Passed()) - { - m_timers[WUPDATE_CORPSES].Reset(); - - CorpsesErase(); - } - - ///- Process Game events when necessary - if (m_timers[WUPDATE_EVENTS].Passed()) - { - m_timers[WUPDATE_EVENTS].Reset(); // to give time for Update() to be processed - uint32 nextGameEvent = gameeventmgr.Update(); - m_timers[WUPDATE_EVENTS].SetInterval(nextGameEvent); - m_timers[WUPDATE_EVENTS].Reset(); - } - - ///
- ///- Move all creatures with "delayed move" and remove and delete all objects with "delayed remove" - MapManager::Instance().DoDelayedMovesAndRemoves(); - - // update the instance reset times - sInstanceSaveManager.Update(); - - // And last, but not least handle the issued cli commands - ProcessCliCommands(); -} - -/// Put scripts in the execution queue -void World::ScriptsStart(ScriptMapMap const& scripts, uint32 id, Object* source, Object* target) -{ - ///- Find the script map - ScriptMapMap::const_iterator s = scripts.find(id); - if (s == scripts.end()) - return; - - // prepare static data - uint64 sourceGUID = source->GetGUID(); - uint64 targetGUID = target ? target->GetGUID() : (uint64)0; - uint64 ownerGUID = (source->GetTypeId()==TYPEID_ITEM) ? ((Item*)source)->GetOwnerGUID() : (uint64)0; - - ///- Schedule script execution for all scripts in the script map - ScriptMap const *s2 = &(s->second); - bool immedScript = false; - for (ScriptMap::const_iterator iter = s2->begin(); iter != s2->end(); ++iter) - { - ScriptAction sa; - sa.sourceGUID = sourceGUID; - sa.targetGUID = targetGUID; - sa.ownerGUID = ownerGUID; - - sa.script = &iter->second; - m_scriptSchedule.insert(std::pair(m_gameTime + iter->first, sa)); - if (iter->first == 0) - immedScript = true; - } - ///- If one of the effects should be immediate, launch the script execution - if (immedScript) - ScriptsProcess(); -} - -void World::ScriptCommandStart(ScriptInfo const& script, uint32 delay, Object* source, Object* target) -{ - // NOTE: script record _must_ exist until command executed - - // prepare static data - uint64 sourceGUID = source->GetGUID(); - uint64 targetGUID = target ? target->GetGUID() : (uint64)0; - uint64 ownerGUID = (source->GetTypeId()==TYPEID_ITEM) ? ((Item*)source)->GetOwnerGUID() : (uint64)0; - - ScriptAction sa; - sa.sourceGUID = sourceGUID; - sa.targetGUID = targetGUID; - sa.ownerGUID = ownerGUID; - - sa.script = &script; - m_scriptSchedule.insert(std::pair(m_gameTime + delay, sa)); - - ///- If effects should be immediate, launch the script execution - if(delay == 0) - ScriptsProcess(); -} - -/// Process queued scripts -void World::ScriptsProcess() -{ - if (m_scriptSchedule.empty()) - return; - - ///- Process overdue queued scripts - std::multimap::iterator iter = m_scriptSchedule.begin(); - // ok as multimap is a *sorted* associative container - while (!m_scriptSchedule.empty() && (iter->first <= m_gameTime)) - { - ScriptAction const& step = iter->second; - - Object* source = NULL; - - if(step.sourceGUID) - { - switch(GUID_HIPART(step.sourceGUID)) - { - case HIGHGUID_ITEM: - // case HIGHGUID_CONTAINER: ==HIGHGUID_ITEM - { - Player* player = HashMapHolder::Find(step.ownerGUID); - if(player) - source = player->GetItemByGuid(step.sourceGUID); - break; - } - case HIGHGUID_UNIT: - source = HashMapHolder::Find(step.sourceGUID); - break; - case HIGHGUID_PET: - source = HashMapHolder::Find(step.sourceGUID); - break; - case HIGHGUID_PLAYER: - source = HashMapHolder::Find(step.sourceGUID); - break; - case HIGHGUID_GAMEOBJECT: - source = HashMapHolder::Find(step.sourceGUID); - break; - case HIGHGUID_CORPSE: - source = HashMapHolder::Find(step.sourceGUID); - break; - default: - sLog.outError("*_script source with unsupported high guid value %u",GUID_HIPART(step.sourceGUID)); - break; - } - } - - Object* target = NULL; - - if(step.targetGUID) - { - switch(GUID_HIPART(step.targetGUID)) - { - case HIGHGUID_UNIT: - target = HashMapHolder::Find(step.targetGUID); - break; - case HIGHGUID_PET: - target = HashMapHolder::Find(step.targetGUID); - break; - case HIGHGUID_PLAYER: // empty GUID case also - target = HashMapHolder::Find(step.targetGUID); - break; - case HIGHGUID_GAMEOBJECT: - target = HashMapHolder::Find(step.targetGUID); - break; - case HIGHGUID_CORPSE: - target = HashMapHolder::Find(step.targetGUID); - break; - default: - sLog.outError("*_script source with unsupported high guid value %u",GUID_HIPART(step.targetGUID)); - break; - } - } - - switch (step.script->command) - { - case SCRIPT_COMMAND_TALK: - { - if(!source) - { - sLog.outError("SCRIPT_COMMAND_TALK call for NULL creature."); - break; - } - - if(source->GetTypeId()!=TYPEID_UNIT) - { - sLog.outError("SCRIPT_COMMAND_TALK call for non-creature (TypeId: %u), skipping.",source->GetTypeId()); - break; - } - if(step.script->datalong > 3) - { - sLog.outError("SCRIPT_COMMAND_TALK invalid chat type (%u), skipping.",step.script->datalong); - break; - } - - uint64 unit_target = target ? target->GetGUID() : 0; - - //datalong 0=normal say, 1=whisper, 2=yell, 3=emote text - switch(step.script->datalong) - { - case 0: // Say - ((Creature *)source)->Say(step.script->datatext.c_str(), LANG_UNIVERSAL, unit_target); - break; - case 1: // Whisper - if(!unit_target) - { - sLog.outError("SCRIPT_COMMAND_TALK attempt to whisper (%u) NULL, skipping.",step.script->datalong); - break; - } - ((Creature *)source)->Whisper(step.script->datatext.c_str(),unit_target); - break; - case 2: // Yell - ((Creature *)source)->Yell(step.script->datatext.c_str(), LANG_UNIVERSAL, unit_target); - break; - case 3: // Emote text - ((Creature *)source)->TextEmote(step.script->datatext.c_str(), unit_target); - break; - default: - break; // must be already checked at load - } - break; - } - - case SCRIPT_COMMAND_EMOTE: - if(!source) - { - sLog.outError("SCRIPT_COMMAND_EMOTE call for NULL creature."); - break; - } - - if(source->GetTypeId()!=TYPEID_UNIT) - { - sLog.outError("SCRIPT_COMMAND_EMOTE call for non-creature (TypeId: %u), skipping.",source->GetTypeId()); - break; - } - - ((Creature *)source)->HandleEmoteCommand(step.script->datalong); - break; - case SCRIPT_COMMAND_FIELD_SET: - if(!source) - { - sLog.outError("SCRIPT_COMMAND_FIELD_SET call for NULL object."); - break; - } - if(step.script->datalong <= OBJECT_FIELD_ENTRY || step.script->datalong >= source->GetValuesCount()) - { - sLog.outError("SCRIPT_COMMAND_FIELD_SET call for wrong field %u (max count: %u) in object (TypeId: %u).", - step.script->datalong,source->GetValuesCount(),source->GetTypeId()); - break; - } - - source->SetUInt32Value(step.script->datalong, step.script->datalong2); - break; - case SCRIPT_COMMAND_MOVE_TO: - if(!source) - { - sLog.outError("SCRIPT_COMMAND_MOVE_TO call for NULL creature."); - break; - } - - if(source->GetTypeId()!=TYPEID_UNIT) - { - sLog.outError("SCRIPT_COMMAND_MOVE_TO call for non-creature (TypeId: %u), skipping.",source->GetTypeId()); - break; - } - ((Unit *)source)->SendMonsterMoveWithSpeed(step.script->x, step.script->y, step.script->z, ((Unit *)source)->GetUnitMovementFlags(), step.script->datalong2 ); - MapManager::Instance().GetMap(((Unit *)source)->GetMapId(), ((Unit *)source))->CreatureRelocation(((Creature *)source), step.script->x, step.script->y, step.script->z, 0); - break; - case SCRIPT_COMMAND_FLAG_SET: - if(!source) - { - sLog.outError("SCRIPT_COMMAND_FLAG_SET call for NULL object."); - break; - } - if(step.script->datalong <= OBJECT_FIELD_ENTRY || step.script->datalong >= source->GetValuesCount()) - { - sLog.outError("SCRIPT_COMMAND_FLAG_SET call for wrong field %u (max count: %u) in object (TypeId: %u).", - step.script->datalong,source->GetValuesCount(),source->GetTypeId()); - break; - } - - source->SetFlag(step.script->datalong, step.script->datalong2); - break; - case SCRIPT_COMMAND_FLAG_REMOVE: - if(!source) - { - sLog.outError("SCRIPT_COMMAND_FLAG_REMOVE call for NULL object."); - break; - } - if(step.script->datalong <= OBJECT_FIELD_ENTRY || step.script->datalong >= source->GetValuesCount()) - { - sLog.outError("SCRIPT_COMMAND_FLAG_REMOVE call for wrong field %u (max count: %u) in object (TypeId: %u).", - step.script->datalong,source->GetValuesCount(),source->GetTypeId()); - break; - } - - source->RemoveFlag(step.script->datalong, step.script->datalong2); - break; - - case SCRIPT_COMMAND_TELEPORT_TO: - { - // accept player in any one from target/source arg - if (!target && !source) - { - sLog.outError("SCRIPT_COMMAND_TELEPORT_TO call for NULL object."); - break; - } - - // must be only Player - if((!target || target->GetTypeId() != TYPEID_PLAYER) && (!source || source->GetTypeId() != TYPEID_PLAYER)) - { - sLog.outError("SCRIPT_COMMAND_TELEPORT_TO call for non-player (TypeIdSource: %u)(TypeIdTarget: %u), skipping.", source ? source->GetTypeId() : 0, target ? target->GetTypeId() : 0); - break; - } - - Player* pSource = target && target->GetTypeId() == TYPEID_PLAYER ? (Player*)target : (Player*)source; - - pSource->TeleportTo(step.script->datalong, step.script->x, step.script->y, step.script->z, step.script->o); - break; - } - - case SCRIPT_COMMAND_TEMP_SUMMON_CREATURE: - { - if(!step.script->datalong) // creature not specified - { - sLog.outError("SCRIPT_COMMAND_TEMP_SUMMON_CREATURE call for NULL creature."); - break; - } - - if(!source) - { - sLog.outError("SCRIPT_COMMAND_TEMP_SUMMON_CREATURE call for NULL world object."); - break; - } - - WorldObject* summoner = dynamic_cast(source); - - if(!summoner) - { - sLog.outError("SCRIPT_COMMAND_TEMP_SUMMON_CREATURE call for non-WorldObject (TypeId: %u), skipping.",source->GetTypeId()); - break; - } - - float x = step.script->x; - float y = step.script->y; - float z = step.script->z; - float o = step.script->o; - - Creature* pCreature = summoner->SummonCreature(step.script->datalong, x, y, z, o,TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,step.script->datalong2); - if (!pCreature) - { - sLog.outError("SCRIPT_COMMAND_TEMP_SUMMON failed for creature (entry: %u).",step.script->datalong); - break; - } - - break; - } - - case SCRIPT_COMMAND_RESPAWN_GAMEOBJECT: - { - if(!step.script->datalong) // gameobject not specified - { - sLog.outError("SCRIPT_COMMAND_RESPAWN_GAMEOBJECT call for NULL gameobject."); - break; - } - - if(!source) - { - sLog.outError("SCRIPT_COMMAND_RESPAWN_GAMEOBJECT call for NULL world object."); - break; - } - - WorldObject* summoner = dynamic_cast(source); - - if(!summoner) - { - sLog.outError("SCRIPT_COMMAND_RESPAWN_GAMEOBJECT call for non-WorldObject (TypeId: %u), skipping.",source->GetTypeId()); - break; - } - - GameObject *go = NULL; - int32 time_to_despawn = step.script->datalong2<5 ? 5 : (int32)step.script->datalong2; - - CellPair p(MaNGOS::ComputeCellPair(summoner->GetPositionX(), summoner->GetPositionY())); - Cell cell(p); - cell.data.Part.reserved = ALL_DISTRICT; - - MaNGOS::GameObjectWithDbGUIDCheck go_check(*summoner,step.script->datalong); - MaNGOS::GameObjectSearcher checker(go,go_check); - - TypeContainerVisitor, GridTypeMapContainer > object_checker(checker); - CellLock cell_lock(cell, p); - cell_lock->Visit(cell_lock, object_checker, *MapManager::Instance().GetMap(summoner->GetMapId(), summoner)); - - if ( !go ) - { - sLog.outError("SCRIPT_COMMAND_RESPAWN_GAMEOBJECT failed for gameobject(guid: %u).", step.script->datalong); - break; - } - - if( go->GetGoType()==GAMEOBJECT_TYPE_FISHINGNODE || - go->GetGoType()==GAMEOBJECT_TYPE_FISHINGNODE || - go->GetGoType()==GAMEOBJECT_TYPE_DOOR || - go->GetGoType()==GAMEOBJECT_TYPE_BUTTON || - go->GetGoType()==GAMEOBJECT_TYPE_TRAP ) - { - sLog.outError("SCRIPT_COMMAND_RESPAWN_GAMEOBJECT can not be used with gameobject of type %u (guid: %u).", uint32(go->GetGoType()), step.script->datalong); - break; - } - - if( go->isSpawned() ) - break; //gameobject already spawned - - go->SetLootState(GO_READY); - go->SetRespawnTime(time_to_despawn); //despawn object in ? seconds - - MapManager::Instance().GetMap(go->GetMapId(), go)->Add(go); - break; - } - case SCRIPT_COMMAND_OPEN_DOOR: - { - if(!step.script->datalong) // door not specified - { - sLog.outError("SCRIPT_COMMAND_OPEN_DOOR call for NULL door."); - break; - } - - if(!source) - { - sLog.outError("SCRIPT_COMMAND_OPEN_DOOR call for NULL unit."); - break; - } - - if(!source->isType(TYPEMASK_UNIT)) // must be any Unit (creature or player) - { - sLog.outError("SCRIPT_COMMAND_OPEN_DOOR call for non-unit (TypeId: %u), skipping.",source->GetTypeId()); - break; - } - - Unit* caster = (Unit*)source; - - GameObject *door = NULL; - int32 time_to_close = step.script->datalong2 < 15 ? 15 : (int32)step.script->datalong2; - - CellPair p(MaNGOS::ComputeCellPair(caster->GetPositionX(), caster->GetPositionY())); - Cell cell(p); - cell.data.Part.reserved = ALL_DISTRICT; - - MaNGOS::GameObjectWithDbGUIDCheck go_check(*caster,step.script->datalong); - MaNGOS::GameObjectSearcher checker(door,go_check); - - TypeContainerVisitor, GridTypeMapContainer > object_checker(checker); - CellLock cell_lock(cell, p); - cell_lock->Visit(cell_lock, object_checker, *MapManager::Instance().GetMap(caster->GetMapId(), (Unit*)source)); - - if ( !door ) - { - sLog.outError("SCRIPT_COMMAND_OPEN_DOOR failed for gameobject(guid: %u).", step.script->datalong); - break; - } - if ( door->GetGoType() != GAMEOBJECT_TYPE_DOOR ) - { - sLog.outError("SCRIPT_COMMAND_OPEN_DOOR failed for non-door(GoType: %u).", door->GetGoType()); - break; - } - - if( !door->GetGoState() ) - break; //door already open - - door->UseDoorOrButton(time_to_close); - - if(target && target->isType(TYPEMASK_GAMEOBJECT) && ((GameObject*)target)->GetGoType()==GAMEOBJECT_TYPE_BUTTON) - ((GameObject*)target)->UseDoorOrButton(time_to_close); - break; - } - case SCRIPT_COMMAND_CLOSE_DOOR: - { - if(!step.script->datalong) // guid for door not specified - { - sLog.outError("SCRIPT_COMMAND_CLOSE_DOOR call for NULL door."); - break; - } - - if(!source) - { - sLog.outError("SCRIPT_COMMAND_CLOSE_DOOR call for NULL unit."); - break; - } - - if(!source->isType(TYPEMASK_UNIT)) // must be any Unit (creature or player) - { - sLog.outError("SCRIPT_COMMAND_CLOSE_DOOR call for non-unit (TypeId: %u), skipping.",source->GetTypeId()); - break; - } - - Unit* caster = (Unit*)source; - - GameObject *door = NULL; - int32 time_to_open = step.script->datalong2 < 15 ? 15 : (int32)step.script->datalong2; - - CellPair p(MaNGOS::ComputeCellPair(caster->GetPositionX(), caster->GetPositionY())); - Cell cell(p); - cell.data.Part.reserved = ALL_DISTRICT; - - MaNGOS::GameObjectWithDbGUIDCheck go_check(*caster,step.script->datalong); - MaNGOS::GameObjectSearcher checker(door,go_check); - - TypeContainerVisitor, GridTypeMapContainer > object_checker(checker); - CellLock cell_lock(cell, p); - cell_lock->Visit(cell_lock, object_checker, *MapManager::Instance().GetMap(caster->GetMapId(), (Unit*)source)); - - if ( !door ) - { - sLog.outError("SCRIPT_COMMAND_CLOSE_DOOR failed for gameobject(guid: %u).", step.script->datalong); - break; - } - if ( door->GetGoType() != GAMEOBJECT_TYPE_DOOR ) - { - sLog.outError("SCRIPT_COMMAND_CLOSE_DOOR failed for non-door(GoType: %u).", door->GetGoType()); - break; - } - - if( door->GetGoState() ) - break; //door already closed - - door->UseDoorOrButton(time_to_open); - - if(target && target->isType(TYPEMASK_GAMEOBJECT) && ((GameObject*)target)->GetGoType()==GAMEOBJECT_TYPE_BUTTON) - ((GameObject*)target)->UseDoorOrButton(time_to_open); - - break; - } - case SCRIPT_COMMAND_QUEST_EXPLORED: - { - if(!source) - { - sLog.outError("SCRIPT_COMMAND_QUEST_EXPLORED call for NULL source."); - break; - } - - if(!target) - { - sLog.outError("SCRIPT_COMMAND_QUEST_EXPLORED call for NULL target."); - break; - } - - // when script called for item spell casting then target == (unit or GO) and source is player - WorldObject* worldObject; - Player* player; - - if(target->GetTypeId()==TYPEID_PLAYER) - { - if(source->GetTypeId()!=TYPEID_UNIT && source->GetTypeId()!=TYPEID_GAMEOBJECT) - { - sLog.outError("SCRIPT_COMMAND_QUEST_EXPLORED call for non-creature and non-gameobject (TypeId: %u), skipping.",source->GetTypeId()); - break; - } - - worldObject = (WorldObject*)source; - player = (Player*)target; - } - else - { - if(target->GetTypeId()!=TYPEID_UNIT && target->GetTypeId()!=TYPEID_GAMEOBJECT) - { - sLog.outError("SCRIPT_COMMAND_QUEST_EXPLORED call for non-creature and non-gameobject (TypeId: %u), skipping.",target->GetTypeId()); - break; - } - - if(source->GetTypeId()!=TYPEID_PLAYER) - { - sLog.outError("SCRIPT_COMMAND_QUEST_EXPLORED call for non-player(TypeId: %u), skipping.",source->GetTypeId()); - break; - } - - worldObject = (WorldObject*)target; - player = (Player*)source; - } - - // quest id and flags checked at script loading - if( (worldObject->GetTypeId()!=TYPEID_UNIT || ((Unit*)worldObject)->isAlive()) && - (step.script->datalong2==0 || worldObject->IsWithinDistInMap(player,float(step.script->datalong2))) ) - player->AreaExploredOrEventHappens(step.script->datalong); - else - player->FailQuest(step.script->datalong); - - break; - } - - case SCRIPT_COMMAND_ACTIVATE_OBJECT: - { - if(!source) - { - sLog.outError("SCRIPT_COMMAND_ACTIVATE_OBJECT must have source caster."); - break; - } - - if(!source->isType(TYPEMASK_UNIT)) - { - sLog.outError("SCRIPT_COMMAND_ACTIVATE_OBJECT source caster isn't unit (TypeId: %u), skipping.",source->GetTypeId()); - break; - } - - if(!target) - { - sLog.outError("SCRIPT_COMMAND_ACTIVATE_OBJECT call for NULL gameobject."); - break; - } - - if(target->GetTypeId()!=TYPEID_GAMEOBJECT) - { - sLog.outError("SCRIPT_COMMAND_ACTIVATE_OBJECT call for non-gameobject (TypeId: %u), skipping.",target->GetTypeId()); - break; - } - - Unit* caster = (Unit*)source; - - GameObject *go = (GameObject*)target; - - go->Use(caster); - break; - } - - case SCRIPT_COMMAND_REMOVE_AURA: - { - Object* cmdTarget = step.script->datalong2 ? source : target; - - if(!cmdTarget) - { - sLog.outError("SCRIPT_COMMAND_REMOVE_AURA call for NULL %s.",step.script->datalong2 ? "source" : "target"); - break; - } - - if(!cmdTarget->isType(TYPEMASK_UNIT)) - { - sLog.outError("SCRIPT_COMMAND_REMOVE_AURA %s isn't unit (TypeId: %u), skipping.",step.script->datalong2 ? "source" : "target",cmdTarget->GetTypeId()); - break; - } - - ((Unit*)cmdTarget)->RemoveAurasDueToSpell(step.script->datalong); - break; - } - - case SCRIPT_COMMAND_CAST_SPELL: - { - if(!source) - { - sLog.outError("SCRIPT_COMMAND_CAST_SPELL must have source caster."); - break; - } - - if(!source->isType(TYPEMASK_UNIT)) - { - sLog.outError("SCRIPT_COMMAND_CAST_SPELL source caster isn't unit (TypeId: %u), skipping.",source->GetTypeId()); - break; - } - - Object* cmdTarget = step.script->datalong2 ? source : target; - - if(!cmdTarget) - { - sLog.outError("SCRIPT_COMMAND_CAST_SPELL call for NULL %s.",step.script->datalong2 ? "source" : "target"); - break; - } - - if(!cmdTarget->isType(TYPEMASK_UNIT)) - { - sLog.outError("SCRIPT_COMMAND_CAST_SPELL %s isn't unit (TypeId: %u), skipping.",step.script->datalong2 ? "source" : "target",cmdTarget->GetTypeId()); - break; - } - - Unit* spellTarget = (Unit*)cmdTarget; - - //TODO: when GO cast implemented, code below must be updated accordingly to also allow GO spell cast - ((Unit*)source)->CastSpell(spellTarget,step.script->datalong,false); - - break; - } - - default: - sLog.outError("Unknown script command %u called.",step.script->command); - break; - } - - m_scriptSchedule.erase(iter); - - iter = m_scriptSchedule.begin(); - } - return; -} - -/// Send a packet to all players (except self if mentioned) -void World::SendGlobalMessage(WorldPacket *packet, WorldSession *self, uint32 team) -{ - SessionMap::iterator itr; - for (itr = m_sessions.begin(); itr != m_sessions.end(); itr++) - { - if (itr->second && - itr->second->GetPlayer() && - itr->second->GetPlayer()->IsInWorld() && - itr->second != self && - (team == 0 || itr->second->GetPlayer()->GetTeam() == team) ) - { - itr->second->SendPacket(packet); - } - } -} - -/// Send a System Message to all players (except self if mentioned) -void World::SendWorldText(int32 string_id, ...) -{ - std::vector > data_cache; // 0 = default, i => i-1 locale index - - for(SessionMap::iterator itr = m_sessions.begin(); itr != m_sessions.end(); ++itr) - { - if(!itr->second || !itr->second->GetPlayer() || !itr->second->GetPlayer()->IsInWorld() ) - continue; - - uint32 loc_idx = itr->second->GetSessionDbLocaleIndex(); - uint32 cache_idx = loc_idx+1; - - std::vector* data_list; - - // create if not cached yet - if(data_cache.size() < cache_idx+1 || data_cache[cache_idx].empty()) - { - if(data_cache.size() < cache_idx+1) - data_cache.resize(cache_idx+1); - - data_list = &data_cache[cache_idx]; - - char const* text = objmgr.GetMangosString(string_id,loc_idx); - - char buf[1000]; - - va_list argptr; - va_start( argptr, string_id ); - vsnprintf( buf,1000, text, argptr ); - va_end( argptr ); - - char* pos = &buf[0]; - - while(char* line = ChatHandler::LineFromMessage(pos)) - { - WorldPacket* data = new WorldPacket(); - ChatHandler::FillMessageData(data, NULL, CHAT_MSG_SYSTEM, LANG_UNIVERSAL, NULL, 0, line, NULL); - data_list->push_back(data); - } - } - else - data_list = &data_cache[cache_idx]; - - for(int i = 0; i < data_list->size(); ++i) - itr->second->SendPacket((*data_list)[i]); - } - - // free memory - for(int i = 0; i < data_cache.size(); ++i) - for(int j = 0; j < data_cache[i].size(); ++j) - delete data_cache[i][j]; -} - -/// Send a packet to all players (or players selected team) in the zone (except self if mentioned) -void World::SendZoneMessage(uint32 zone, WorldPacket *packet, WorldSession *self, uint32 team) -{ - SessionMap::iterator itr; - for (itr = m_sessions.begin(); itr != m_sessions.end(); itr++) - { - if (itr->second && - itr->second->GetPlayer() && - itr->second->GetPlayer()->IsInWorld() && - itr->second->GetPlayer()->GetZoneId() == zone && - itr->second != self && - (team == 0 || itr->second->GetPlayer()->GetTeam() == team) ) - { - itr->second->SendPacket(packet); - } - } -} - -/// Send a System Message to all players in the zone (except self if mentioned) -void World::SendZoneText(uint32 zone, const char* text, WorldSession *self, uint32 team) -{ - WorldPacket data; - ChatHandler::FillMessageData(&data, NULL, CHAT_MSG_SYSTEM, LANG_UNIVERSAL, NULL, 0, text, NULL); - SendZoneMessage(zone, &data, self,team); -} - -/// Kick (and save) all players -void World::KickAll() -{ - // session not removed at kick and will removed in next update tick - for (SessionMap::iterator itr = m_sessions.begin(); itr != m_sessions.end(); ++itr) - itr->second->KickPlayer(); -} - -/// Kick (and save) all players with security level less `sec` -void World::KickAllLess(AccountTypes sec) -{ - // session not removed at kick and will removed in next update tick - for (SessionMap::iterator itr = m_sessions.begin(); itr != m_sessions.end(); ++itr) - if(itr->second->GetSecurity() < sec) - itr->second->KickPlayer(); -} - -/// Kick all queued players -void World::KickAllQueued() -{ - // session not removed at kick and will removed in next update tick - for (Queue::iterator itr = m_QueuedPlayer.begin(); itr != m_QueuedPlayer.end(); ++itr) - if(WorldSession* session = (*itr)->GetSession()) - session->KickPlayer(); - - m_QueuedPlayer.empty(); -} - -/// Kick (and save) the designated player -bool World::KickPlayer(std::string playerName) -{ - SessionMap::iterator itr; - - // session not removed at kick and will removed in next update tick - for (itr = m_sessions.begin(); itr != m_sessions.end(); ++itr) - { - if(!itr->second) - continue; - Player *player = itr->second->GetPlayer(); - if(!player) - continue; - if( player->IsInWorld() ) - { - if (playerName == player->GetName()) - { - itr->second->KickPlayer(); - return true; - } - } - } - return false; -} - -/// Ban an account or ban an IP address, duration will be parsed using TimeStringToSecs if it is positive, otherwise permban -uint8 World::BanAccount(std::string type, std::string nameOrIP, std::string duration, std::string reason, std::string author) -{ - loginDatabase.escape_string(nameOrIP); - loginDatabase.escape_string(reason); - std::string safe_author=author; - loginDatabase.escape_string(safe_author); - - if(type != "ip" && !normalizePlayerName(nameOrIP)) - return BAN_NOTFOUND; // Nobody to ban - - uint32 duration_secs = TimeStringToSecs(duration); - QueryResult *resultAccounts = NULL; //used for kicking - - ///- Update the database with ban information - - if(type=="ip") - { - //No SQL injection as strings are escaped - resultAccounts = loginDatabase.PQuery("SELECT id FROM account WHERE last_ip = '%s'",nameOrIP.c_str()); - loginDatabase.PExecute("INSERT INTO ip_banned VALUES ('%s',UNIX_TIMESTAMP(),UNIX_TIMESTAMP()+%u,'%s','%s')",nameOrIP.c_str(),duration_secs,safe_author.c_str(),reason.c_str()); - } - else if(type=="account") - { - //No SQL injection as string is escaped - resultAccounts = loginDatabase.PQuery("SELECT id FROM account WHERE username = '%s'",nameOrIP.c_str()); - } - else if(type=="character") - { - //No SQL injection as string is escaped - resultAccounts = CharacterDatabase.PQuery("SELECT account FROM characters WHERE name = '%s'",nameOrIP.c_str()); - } - else - return BAN_SYNTAX_ERROR; //Syntax problem - - if(!resultAccounts) - if(type=="ip") - return BAN_SUCCESS; // ip correctly banned but nobody affected (yet) - else - return BAN_NOTFOUND; // Nobody to ban - - ///- Disconnect all affected players (for IP it can be several) - do - { - Field* fieldsAccount = resultAccounts->Fetch(); - uint32 account = fieldsAccount->GetUInt32(); - - if(type != "ip") - //No SQL injection as strings are escaped - loginDatabase.PExecute("INSERT INTO account_banned VALUES ('%u', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()+%u, '%s', '%s', '1')", - account,duration_secs,safe_author.c_str(),reason.c_str()); - - WorldSession* sess = FindSession(account); - if( sess ) - if(std::string(sess->GetPlayerName()) != author) - sess->KickPlayer(); - } - while( resultAccounts->NextRow() ); - - delete resultAccounts; - return BAN_SUCCESS; -} - -/// Remove a ban from an account or IP address -bool World::RemoveBanAccount(std::string type, std::string nameOrIP) -{ - if(type == "ip") - { - loginDatabase.escape_string(nameOrIP); - loginDatabase.PExecute("DELETE FROM ip_banned WHERE ip = '%s'",nameOrIP.c_str()); - } - else - { - uint32 account=0; - if(type == "account") - { - //NO SQL injection as name is escaped - loginDatabase.escape_string(nameOrIP); - QueryResult *resultAccounts = loginDatabase.PQuery("SELECT id FROM account WHERE username = '%s'",nameOrIP.c_str()); - if(!resultAccounts) - return false; - Field* fieldsAccount = resultAccounts->Fetch(); - account = fieldsAccount->GetUInt32(); - - delete resultAccounts; - } - else if(type == "character") - { - if(!normalizePlayerName(nameOrIP)) - return false; - - //NO SQL injection as name is escaped - loginDatabase.escape_string(nameOrIP); - QueryResult *resultAccounts = CharacterDatabase.PQuery("SELECT account FROM characters WHERE name = '%s'",nameOrIP.c_str()); - if(!resultAccounts) - return false; - Field* fieldsAccount = resultAccounts->Fetch(); - account = fieldsAccount->GetUInt32(); - - delete resultAccounts; - } - if(!account) - return false; - //NO SQL injection as account is uint32 - loginDatabase.PExecute("UPDATE account_banned SET active = '0' WHERE id = '%u'",account); - } - return true; -} - -/// Update the game time -void World::_UpdateGameTime() -{ - ///- update the time - time_t thisTime = time(NULL); - uint32 elapsed = uint32(thisTime - m_gameTime); - m_gameTime = thisTime; - - ///- if there is a shutdown timer - if(m_ShutdownTimer > 0 && elapsed > 0) - { - ///- ... and it is overdue, stop the world (set m_stopEvent) - if( m_ShutdownTimer <= elapsed ) - { - if(!(m_ShutdownMask & SHUTDOWN_MASK_IDLE) || GetActiveAndQueuedSessionCount()==0) - m_stopEvent = true; - else - m_ShutdownTimer = 1; // minimum timer value to wait idle state - } - ///- ... else decrease it and if necessary display a shutdown countdown to the users - else - { - m_ShutdownTimer -= elapsed; - - ShutdownMsg(); - } - } -} - -/// Shutdown the server -void World::ShutdownServ(uint32 time, uint32 options) -{ - m_ShutdownMask = options; - - ///- If the shutdown time is 0, set m_stopEvent (except if shutdown is 'idle' with remaining sessions) - if(time==0) - { - if(!(options & SHUTDOWN_MASK_IDLE) || GetActiveAndQueuedSessionCount()==0) - m_stopEvent = true; - else - m_ShutdownTimer = 1; //So that the session count is re-evaluated at next world tick - } - ///- Else set the shutdown timer and warn users - else - { - m_ShutdownTimer = time; - ShutdownMsg(true); - } -} - -/// Display a shutdown message to the user(s) -void World::ShutdownMsg(bool show, Player* player) -{ - // not show messages for idle shutdown mode - if(m_ShutdownMask & SHUTDOWN_MASK_IDLE) - return; - - ///- Display a message every 12 hours, hours, 5 minutes, minute, 5 seconds and finally seconds - if ( show || - (m_ShutdownTimer < 10) || - // < 30 sec; every 5 sec - (m_ShutdownTimer<30 && (m_ShutdownTimer % 5 )==0) || - // < 5 min ; every 1 min - (m_ShutdownTimer<5*MINUTE && (m_ShutdownTimer % MINUTE )==0) || - // < 30 min ; every 5 min - (m_ShutdownTimer<30*MINUTE && (m_ShutdownTimer % (5*MINUTE))==0) || - // < 12 h ; every 1 h - (m_ShutdownTimer<12*HOUR && (m_ShutdownTimer % HOUR )==0) || - // > 12 h ; every 12 h - (m_ShutdownTimer>12*HOUR && (m_ShutdownTimer % (12*HOUR) )==0)) - { - std::string str = secsToTimeString(m_ShutdownTimer); - - uint32 msgid = (m_ShutdownMask & SHUTDOWN_MASK_RESTART) ? SERVER_MSG_RESTART_TIME : SERVER_MSG_SHUTDOWN_TIME; - - SendServerMessage(msgid,str.c_str(),player); - DEBUG_LOG("Server is %s in %s",(m_ShutdownMask & SHUTDOWN_MASK_RESTART ? "restart" : "shuttingdown"),str.c_str()); - } -} - -/// Cancel a planned server shutdown -void World::ShutdownCancel() -{ - if(!m_ShutdownTimer) - return; - - uint32 msgid = (m_ShutdownMask & SHUTDOWN_MASK_RESTART) ? SERVER_MSG_RESTART_CANCELLED : SERVER_MSG_SHUTDOWN_CANCELLED; - - m_ShutdownMask = 0; - m_ShutdownTimer = 0; - SendServerMessage(msgid); - - DEBUG_LOG("Server %s cancelled.",(m_ShutdownMask & SHUTDOWN_MASK_RESTART ? "restart" : "shuttingdown")); -} - -/// Send a server message to the user(s) -void World::SendServerMessage(uint32 type, const char *text, Player* player) -{ - WorldPacket data(SMSG_SERVER_MESSAGE, 50); // guess size - data << uint32(type); - if(type <= SERVER_MSG_STRING) - data << text; - - if(player) - player->GetSession()->SendPacket(&data); - else - SendGlobalMessage( &data ); -} - -void World::UpdateSessions( time_t diff ) -{ - ///- Delete kicked sessions at add new session - for (std::set::iterator itr = m_kicked_sessions.begin(); itr != m_kicked_sessions.end(); ++itr) - delete *itr; - m_kicked_sessions.clear(); - - ///- Then send an update signal to remaining ones - for (SessionMap::iterator itr = m_sessions.begin(), next; itr != m_sessions.end(); itr = next) - { - next = itr; - ++next; - - if(!itr->second) - continue; - - ///- and remove not active sessions from the list - if(!itr->second->Update(diff)) // As interval = 0 - { - delete itr->second; - m_sessions.erase(itr); - } - } -} - -// This handles the issued and queued CLI commands -void World::ProcessCliCommands() -{ - if (cliCmdQueue.empty()) return; - - CliCommandHolder *command; - pPrintf p_zprintf; - while (!cliCmdQueue.empty()) - { - sLog.outDebug("CLI command under processing..."); - command = cliCmdQueue.next(); - command->Execute(); - p_zprintf=command->GetOutputMethod(); - delete command; - } - // print the console message here so it looks right - p_zprintf("mangos>"); -} - -void World::InitResultQueue() -{ - m_resultQueue = new SqlResultQueue; - CharacterDatabase.SetResultQueue(m_resultQueue); -} - -void World::UpdateResultQueue() -{ - m_resultQueue->Update(); -} - -void World::UpdateRealmCharCount(uint32 accountId) -{ - CharacterDatabase.AsyncPQuery(this, &World::_UpdateRealmCharCount, accountId, - "SELECT COUNT(guid) FROM characters WHERE account = '%u'", accountId); -} - -void World::_UpdateRealmCharCount(QueryResult *resultCharCount, uint32 accountId) -{ - if (resultCharCount) - { - Field *fields = resultCharCount->Fetch(); - uint32 charCount = fields[0].GetUInt32(); - delete resultCharCount; - loginDatabase.PExecute("DELETE FROM realmcharacters WHERE acctid= '%d' AND realmid = '%d'", accountId, realmID); - loginDatabase.PExecute("INSERT INTO realmcharacters (numchars, acctid, realmid) VALUES (%u, %u, %u)", charCount, accountId, realmID); - } -} - -void World::InitDailyQuestResetTime() -{ - time_t mostRecentQuestTime; - - QueryResult* result = CharacterDatabase.Query("SELECT MAX(time) FROM character_queststatus_daily"); - if(result) - { - Field *fields = result->Fetch(); - - mostRecentQuestTime = (time_t)fields[0].GetUInt64(); - delete result; - } - else - mostRecentQuestTime = 0; - - // client built-in time for reset is 6:00 AM - // FIX ME: client not show day start time - time_t curTime = time(NULL); - tm localTm = *localtime(&curTime); - localTm.tm_hour = 6; - localTm.tm_min = 0; - localTm.tm_sec = 0; - - // current day reset time - time_t curDayResetTime = mktime(&localTm); - - // last reset time before current moment - time_t resetTime = (curTime < curDayResetTime) ? curDayResetTime - DAY : curDayResetTime; - - // need reset (if we have quest time before last reset time (not processed by some reason) - if(mostRecentQuestTime && mostRecentQuestTime <= resetTime) - m_NextDailyQuestReset = mostRecentQuestTime; - else - { - // plan next reset time - m_NextDailyQuestReset = (curTime >= curDayResetTime) ? curDayResetTime + DAY : curDayResetTime; - } -} - -void World::ResetDailyQuests() -{ - sLog.outDetail("Daily quests reset for all characters."); - CharacterDatabase.Execute("DELETE FROM character_queststatus_daily"); - for(SessionMap::iterator itr = m_sessions.begin(); itr != m_sessions.end(); ++itr) - if(itr->second->GetPlayer()) - itr->second->GetPlayer()->ResetDailyQuestStatus(); -} - -void World::SetPlayerLimit( int32 limit, bool needUpdate ) -{ - if(limit < -SEC_ADMINISTRATOR) - limit = -SEC_ADMINISTRATOR; - - // lock update need - bool db_update_need = needUpdate || (limit < 0) != (m_playerLimit < 0) || (limit < 0 && m_playerLimit < 0 && limit != m_playerLimit); - - m_playerLimit = limit; - - if(db_update_need) - loginDatabase.PExecute("UPDATE realmlist SET allowedSecurityLevel = '%u' WHERE id = '%d'",uint8(GetPlayerSecurityLimit()),realmID); -} - -void World::UpdateMaxSessionCounters() -{ - m_maxActiveSessionCount = std::max(m_maxActiveSessionCount,uint32(m_sessions.size()-m_QueuedPlayer.size())); - m_maxQueuedSessionCount = std::max(m_maxQueuedSessionCount,uint32(m_QueuedPlayer.size())); -} +/* + * Copyright (C) 2005-2008 MaNGOS + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/** \file + \ingroup world +*/ + +#include "Common.h" +//#include "WorldSocket.h" +#include "Database/DatabaseEnv.h" +#include "Config/ConfigEnv.h" +#include "SystemConfig.h" +#include "Log.h" +#include "Opcodes.h" +#include "WorldSession.h" +#include "WorldPacket.h" +#include "Weather.h" +#include "Player.h" +#include "SkillExtraItems.h" +#include "SkillDiscovery.h" +#include "World.h" +#include "ObjectMgr.h" +#include "SpellMgr.h" +#include "Chat.h" +#include "Database/DBCStores.h" +#include "LootMgr.h" +#include "ItemEnchantmentMgr.h" +#include "MapManager.h" +#include "ScriptCalls.h" +#include "CreatureAIRegistry.h" +#include "Policies/SingletonImp.h" +#include "BattleGroundMgr.h" +#include "TemporarySummon.h" +#include "WaypointMovementGenerator.h" +#include "VMapFactory.h" +#include "GlobalEvents.h" +#include "GameEvent.h" +#include "Database/DatabaseImpl.h" +#include "GridNotifiersImpl.h" +#include "CellImpl.h" +#include "InstanceSaveMgr.h" +#include "WaypointManager.h" +#include "Util.h" + +INSTANTIATE_SINGLETON_1( World ); + +volatile bool World::m_stopEvent = false; +volatile uint32 World::m_worldLoopCounter = 0; + +float World::m_MaxVisibleDistanceForCreature = DEFAULT_VISIBILITY_DISTANCE; +float World::m_MaxVisibleDistanceForPlayer = DEFAULT_VISIBILITY_DISTANCE; +float World::m_MaxVisibleDistanceForObject = DEFAULT_VISIBILITY_DISTANCE; +float World::m_MaxVisibleDistanceInFlight = DEFAULT_VISIBILITY_DISTANCE; +float World::m_VisibleUnitGreyDistance = 0; +float World::m_VisibleObjectGreyDistance = 0; + +// ServerMessages.dbc +enum ServerMessageType +{ + SERVER_MSG_SHUTDOWN_TIME = 1, + SERVER_MSG_RESTART_TIME = 2, + SERVER_MSG_STRING = 3, + SERVER_MSG_SHUTDOWN_CANCELLED = 4, + SERVER_MSG_RESTART_CANCELLED = 5 +}; + +struct ScriptAction +{ + uint64 sourceGUID; + uint64 targetGUID; + uint64 ownerGUID; // owner of source if source is item + ScriptInfo const* script; // pointer to static script data +}; + +/// World constructor +World::World() +{ + m_playerLimit = 0; + m_allowMovement = true; + m_ShutdownMask = 0; + m_ShutdownTimer = 0; + m_gameTime=time(NULL); + m_startTime=m_gameTime; + m_maxActiveSessionCount = 0; + m_maxQueuedSessionCount = 0; + m_resultQueue = NULL; + m_NextDailyQuestReset = 0; + + m_defaultDbcLocale = LOCALE_enUS; + m_availableDbcLocaleMask = 0; +} + +/// World destructor +World::~World() +{ + ///- Empty the kicked session set + for (std::set::iterator itr = m_kicked_sessions.begin(); itr != m_kicked_sessions.end(); ++itr) + delete *itr; + + m_kicked_sessions.clear(); + + ///- Empty the WeatherMap + for (WeatherMap::iterator itr = m_weathers.begin(); itr != m_weathers.end(); ++itr) + delete itr->second; + + m_weathers.clear(); + + VMAP::VMapFactory::clear(); + + if(m_resultQueue) delete m_resultQueue; + + //TODO free addSessQueue +} + +/// Find a player in a specified zone +Player* World::FindPlayerInZone(uint32 zone) +{ + ///- circle through active sessions and return the first player found in the zone + SessionMap::iterator itr; + for (itr = m_sessions.begin(); itr != m_sessions.end(); ++itr) + { + if(!itr->second) + continue; + Player *player = itr->second->GetPlayer(); + if(!player) + continue; + if( player->IsInWorld() && player->GetZoneId() == zone ) + { + // Used by the weather system. We return the player to broadcast the change weather message to him and all players in the zone. + return player; + } + } + return NULL; +} + +/// Find a session by its id +WorldSession* World::FindSession(uint32 id) const +{ + SessionMap::const_iterator itr = m_sessions.find(id); + + if(itr != m_sessions.end()) + return itr->second; // also can return NULL for kicked session + else + return NULL; +} + +/// Remove a given session +bool World::RemoveSession(uint32 id) +{ + ///- Find the session, kick the user, but we can't delete session at this moment to prevent iterator invalidation + SessionMap::iterator itr = m_sessions.find(id); + + if(itr != m_sessions.end() && itr->second) + { + if (itr->second->PlayerLoading()) + return false; + itr->second->KickPlayer(); + } + + return true; +} + +void World::AddSession(WorldSession* s) +{ + addSessQueue.add(s); +} + +void +World::AddSession_ (WorldSession* s) +{ + ASSERT (s); + + //NOTE - Still there is race condition in WorldSession* being used in the Sockets + + ///- kick already loaded player with same account (if any) and remove session + ///- if player is in loading and want to load again, return + if (!RemoveSession (s->GetAccountId ())) + { + s->KickPlayer (); + m_kicked_sessions.insert (s); + return; + } + + WorldSession* old = m_sessions[s->GetAccountId ()]; + m_sessions[s->GetAccountId ()] = s; + + // if session already exist, prepare to it deleting at next world update + // NOTE - KickPlayer() should be called on "old" in RemoveSession() + if (old) + m_kicked_sessions.insert (old); + + uint32 Sessions = GetActiveAndQueuedSessionCount (); + uint32 pLimit = GetPlayerAmountLimit (); + uint32 QueueSize = GetQueueSize (); //number of players in the queue + bool inQueue = false; + //so we don't count the user trying to + //login as a session and queue the socket that we are using + --Sessions; + + if (pLimit > 0 && Sessions >= pLimit && s->GetSecurity () == SEC_PLAYER ) + { + AddQueuedPlayer (s); + UpdateMaxSessionCounters (); + sLog.outDetail ("PlayerQueue: Account id %u is in Queue Position (%u).", s->GetAccountId (), ++QueueSize); + return; + } + + WorldPacket packet(SMSG_AUTH_RESPONSE, 1 + 4 + 1 + 4 + 1); + packet << uint8 (AUTH_OK); + packet << uint32 (0); // unknown random value... + packet << uint8 (0); + packet << uint32 (0); + packet << uint8 (s->IsTBC () ? 1 : 0); // 0 - normal, 1 - TBC, must be set in database manually for each account + s->SendPacket (&packet); + + UpdateMaxSessionCounters (); + + // Updates the population + if (pLimit > 0) + { + float popu = GetActiveSessionCount (); //updated number of users on the server + popu /= pLimit; + popu *= 2; + loginDatabase.PExecute ("UPDATE realmlist SET population = '%f' WHERE id = '%d'", popu, realmID); + sLog.outDetail ("Server Population (%f).", popu); + } +} + +int32 World::GetQueuePos(WorldSession* sess) +{ + uint32 position = 1; + + for(Queue::iterator iter = m_QueuedPlayer.begin(); iter != m_QueuedPlayer.end(); ++iter, ++position) + if((*iter) == sess) + return position; + + return 0; +} + +void World::AddQueuedPlayer(WorldSession* sess) +{ + m_QueuedPlayer.push_back (sess); + + // The 1st SMSG_AUTH_RESPONSE needs to contain other info too. + WorldPacket packet (SMSG_AUTH_RESPONSE, 1 + 4 + 1 + 4 + 1); + packet << uint8 (AUTH_WAIT_QUEUE); + packet << uint32 (0); // unknown random value... + packet << uint8 (0); + packet << uint32 (0); + packet << uint8 (sess->IsTBC () ? 1 : 0); // 0 - normal, 1 - TBC, must be set in database manually for each account + packet << uint32(GetQueuePos (sess)); + sess->SendPacket (&packet); + + //sess->SendAuthWaitQue (GetQueuePos (sess)); +} + +void World::RemoveQueuedPlayer(WorldSession* sess) +{ + // sessions count including queued to remove (if removed_session set) + uint32 sessions = GetActiveSessionCount(); + + uint32 position = 1; + Queue::iterator iter = m_QueuedPlayer.begin(); + + // if session not queued then we need decrease sessions count (Remove socked callet before session removing from session list) + bool decrease_session = true; + + // search to remove and count skipped positions + for(;iter != m_QueuedPlayer.end(); ++iter, ++position) + { + if(*iter==sess) + { + Queue::iterator iter2 = iter; + ++iter; + m_QueuedPlayer.erase(iter2); + decrease_session = false; // removing queued session + break; + } + } + + // iter point to next socked after removed or end() + // position store position of removed socket and then new position next socket after removed + + // decrease for case session queued for removing + if(decrease_session && sessions) + --sessions; + + // accept first in queue + if( (!m_playerLimit || sessions < m_playerLimit) && !m_QueuedPlayer.empty() ) + { + WorldSession * socket = m_QueuedPlayer.front(); + socket->SendAuthWaitQue(0); + m_QueuedPlayer.pop_front(); + + // update iter to point first queued socket or end() if queue is empty now + iter = m_QueuedPlayer.begin(); + position = 1; + } + + // update position from iter to end() + // iter point to first not updated socket, position store new position + for(; iter != m_QueuedPlayer.end(); ++iter, ++position) + (*iter)->SendAuthWaitQue(position); +} + +/// Find a Weather object by the given zoneid +Weather* World::FindWeather(uint32 id) const +{ + WeatherMap::const_iterator itr = m_weathers.find(id); + + if(itr != m_weathers.end()) + return itr->second; + else + return 0; +} + +/// Remove a Weather object for the given zoneid +void World::RemoveWeather(uint32 id) +{ + // not called at the moment. Kept for completeness + WeatherMap::iterator itr = m_weathers.find(id); + + if(itr != m_weathers.end()) + { + delete itr->second; + m_weathers.erase(itr); + } +} + +/// Add a Weather object to the list +Weather* World::AddWeather(uint32 zone_id) +{ + WeatherZoneChances const* weatherChances = objmgr.GetWeatherChances(zone_id); + + // zone not have weather, ignore + if(!weatherChances) + return NULL; + + Weather* w = new Weather(zone_id,weatherChances); + m_weathers[w->GetZone()] = w; + w->ReGenerate(); + w->UpdateWeather(); + return w; +} + +/// Initialize config values +void World::LoadConfigSettings(bool reload) +{ + if(reload) + { + if(!sConfig.Reload()) + { + sLog.outError("World settings reload fail: can't read settings from %s.",sConfig.GetFilename().c_str()); + return; + } + //TODO Check if config is outdated + } + + ///- Read the player limit and the Message of the day from the config file + SetPlayerLimit( sConfig.GetIntDefault("PlayerLimit", DEFAULT_PLAYER_LIMIT), true ); + SetMotd( sConfig.GetStringDefault("Motd", "Welcome to the Massive Network Game Object Server." ) ); + + ///- Read all rates from the config file + rate_values[RATE_HEALTH] = sConfig.GetFloatDefault("Rate.Health", 1); + if(rate_values[RATE_HEALTH] < 0) + { + sLog.outError("Rate.Health (%f) mustbe > 0. Using 1 instead.",rate_values[RATE_HEALTH]); + rate_values[RATE_HEALTH] = 1; + } + rate_values[RATE_POWER_MANA] = sConfig.GetFloatDefault("Rate.Mana", 1); + if(rate_values[RATE_POWER_MANA] < 0) + { + sLog.outError("Rate.Mana (%f) mustbe > 0. Using 1 instead.",rate_values[RATE_POWER_MANA]); + rate_values[RATE_POWER_MANA] = 1; + } + rate_values[RATE_POWER_RAGE_INCOME] = sConfig.GetFloatDefault("Rate.Rage.Income", 1); + rate_values[RATE_POWER_RAGE_LOSS] = sConfig.GetFloatDefault("Rate.Rage.Loss", 1); + if(rate_values[RATE_POWER_RAGE_LOSS] < 0) + { + sLog.outError("Rate.Rage.Loss (%f) mustbe > 0. Using 1 instead.",rate_values[RATE_POWER_RAGE_LOSS]); + rate_values[RATE_POWER_RAGE_LOSS] = 1; + } + rate_values[RATE_POWER_FOCUS] = sConfig.GetFloatDefault("Rate.Focus", 1.0f); + rate_values[RATE_LOYALTY] = sConfig.GetFloatDefault("Rate.Loyalty", 1.0f); + rate_values[RATE_SKILL_DISCOVERY] = sConfig.GetFloatDefault("Rate.Skill.Discovery", 1.0f); + rate_values[RATE_DROP_ITEM_POOR] = sConfig.GetFloatDefault("Rate.Drop.Item.Poor", 1.0f); + rate_values[RATE_DROP_ITEM_NORMAL] = sConfig.GetFloatDefault("Rate.Drop.Item.Normal", 1.0f); + rate_values[RATE_DROP_ITEM_UNCOMMON] = sConfig.GetFloatDefault("Rate.Drop.Item.Uncommon", 1.0f); + rate_values[RATE_DROP_ITEM_RARE] = sConfig.GetFloatDefault("Rate.Drop.Item.Rare", 1.0f); + rate_values[RATE_DROP_ITEM_EPIC] = sConfig.GetFloatDefault("Rate.Drop.Item.Epic", 1.0f); + rate_values[RATE_DROP_ITEM_LEGENDARY] = sConfig.GetFloatDefault("Rate.Drop.Item.Legendary", 1.0f); + rate_values[RATE_DROP_ITEM_ARTIFACT] = sConfig.GetFloatDefault("Rate.Drop.Item.Artifact", 1.0f); + rate_values[RATE_DROP_ITEM_REFERENCED] = sConfig.GetFloatDefault("Rate.Drop.Item.Referenced", 1.0f); + rate_values[RATE_DROP_MONEY] = sConfig.GetFloatDefault("Rate.Drop.Money", 1.0f); + rate_values[RATE_XP_KILL] = sConfig.GetFloatDefault("Rate.XP.Kill", 1.0f); + rate_values[RATE_XP_QUEST] = sConfig.GetFloatDefault("Rate.XP.Quest", 1.0f); + rate_values[RATE_XP_EXPLORE] = sConfig.GetFloatDefault("Rate.XP.Explore", 1.0f); + rate_values[RATE_XP_PAST_70] = sConfig.GetFloatDefault("Rate.XP.PastLevel70", 1.0f); + rate_values[RATE_REPUTATION_GAIN] = sConfig.GetFloatDefault("Rate.Reputation.Gain", 1.0f); + rate_values[RATE_CREATURE_NORMAL_DAMAGE] = sConfig.GetFloatDefault("Rate.Creature.Normal.Damage", 1.0f); + rate_values[RATE_CREATURE_ELITE_ELITE_DAMAGE] = sConfig.GetFloatDefault("Rate.Creature.Elite.Elite.Damage", 1.0f); + rate_values[RATE_CREATURE_ELITE_RAREELITE_DAMAGE] = sConfig.GetFloatDefault("Rate.Creature.Elite.RAREELITE.Damage", 1.0f); + rate_values[RATE_CREATURE_ELITE_WORLDBOSS_DAMAGE] = sConfig.GetFloatDefault("Rate.Creature.Elite.WORLDBOSS.Damage", 1.0f); + rate_values[RATE_CREATURE_ELITE_RARE_DAMAGE] = sConfig.GetFloatDefault("Rate.Creature.Elite.RARE.Damage", 1.0f); + rate_values[RATE_CREATURE_NORMAL_HP] = sConfig.GetFloatDefault("Rate.Creature.Normal.HP", 1.0f); + rate_values[RATE_CREATURE_ELITE_ELITE_HP] = sConfig.GetFloatDefault("Rate.Creature.Elite.Elite.HP", 1.0f); + rate_values[RATE_CREATURE_ELITE_RAREELITE_HP] = sConfig.GetFloatDefault("Rate.Creature.Elite.RAREELITE.HP", 1.0f); + rate_values[RATE_CREATURE_ELITE_WORLDBOSS_HP] = sConfig.GetFloatDefault("Rate.Creature.Elite.WORLDBOSS.HP", 1.0f); + rate_values[RATE_CREATURE_ELITE_RARE_HP] = sConfig.GetFloatDefault("Rate.Creature.Elite.RARE.HP", 1.0f); + rate_values[RATE_CREATURE_NORMAL_SPELLDAMAGE] = sConfig.GetFloatDefault("Rate.Creature.Normal.SpellDamage", 1.0f); + rate_values[RATE_CREATURE_ELITE_ELITE_SPELLDAMAGE] = sConfig.GetFloatDefault("Rate.Creature.Elite.Elite.SpellDamage", 1.0f); + rate_values[RATE_CREATURE_ELITE_RAREELITE_SPELLDAMAGE] = sConfig.GetFloatDefault("Rate.Creature.Elite.RAREELITE.SpellDamage", 1.0f); + rate_values[RATE_CREATURE_ELITE_WORLDBOSS_SPELLDAMAGE] = sConfig.GetFloatDefault("Rate.Creature.Elite.WORLDBOSS.SpellDamage", 1.0f); + rate_values[RATE_CREATURE_ELITE_RARE_SPELLDAMAGE] = sConfig.GetFloatDefault("Rate.Creature.Elite.RARE.SpellDamage", 1.0f); + rate_values[RATE_CREATURE_AGGRO] = sConfig.GetFloatDefault("Rate.Creature.Aggro", 1.0f); + rate_values[RATE_REST_INGAME] = sConfig.GetFloatDefault("Rate.Rest.InGame", 1.0f); + rate_values[RATE_REST_OFFLINE_IN_TAVERN_OR_CITY] = sConfig.GetFloatDefault("Rate.Rest.Offline.InTavernOrCity", 1.0f); + rate_values[RATE_REST_OFFLINE_IN_WILDERNESS] = sConfig.GetFloatDefault("Rate.Rest.Offline.InWilderness", 1.0f); + rate_values[RATE_DAMAGE_FALL] = sConfig.GetFloatDefault("Rate.Damage.Fall", 1.0f); + rate_values[RATE_AUCTION_TIME] = sConfig.GetFloatDefault("Rate.Auction.Time", 1.0f); + rate_values[RATE_AUCTION_DEPOSIT] = sConfig.GetFloatDefault("Rate.Auction.Deposit", 1.0f); + rate_values[RATE_AUCTION_CUT] = sConfig.GetFloatDefault("Rate.Auction.Cut", 1.0f); + rate_values[RATE_HONOR] = sConfig.GetFloatDefault("Rate.Honor",1.0f); + rate_values[RATE_MINING_AMOUNT] = sConfig.GetFloatDefault("Rate.Mining.Amount",1.0f); + rate_values[RATE_MINING_NEXT] = sConfig.GetFloatDefault("Rate.Mining.Next",1.0f); + rate_values[RATE_INSTANCE_RESET_TIME] = sConfig.GetFloatDefault("Rate.InstanceResetTime",1.0f); + rate_values[RATE_TALENT] = sConfig.GetFloatDefault("Rate.Talent",1.0f); + if(rate_values[RATE_TALENT] < 0.0f) + { + sLog.outError("Rate.Talent (%f) mustbe > 0. Using 1 instead.",rate_values[RATE_TALENT]); + rate_values[RATE_TALENT] = 1.0f; + } + rate_values[RATE_CORPSE_DECAY_LOOTED] = sConfig.GetFloatDefault("Rate.Corpse.Decay.Looted",0.1f); + + rate_values[RATE_TARGET_POS_RECALCULATION_RANGE] = sConfig.GetFloatDefault("TargetPosRecalculateRange",1.5f); + if(rate_values[RATE_TARGET_POS_RECALCULATION_RANGE] < CONTACT_DISTANCE) + { + sLog.outError("TargetPosRecalculateRange (%f) must be >= %f. Using %f instead.",rate_values[RATE_TARGET_POS_RECALCULATION_RANGE],CONTACT_DISTANCE,CONTACT_DISTANCE); + rate_values[RATE_TARGET_POS_RECALCULATION_RANGE] = CONTACT_DISTANCE; + } + else if(rate_values[RATE_TARGET_POS_RECALCULATION_RANGE] > ATTACK_DISTANCE) + { + sLog.outError("TargetPosRecalculateRange (%f) must be <= %f. Using %f instead.",rate_values[RATE_TARGET_POS_RECALCULATION_RANGE],ATTACK_DISTANCE,ATTACK_DISTANCE); + rate_values[RATE_TARGET_POS_RECALCULATION_RANGE] = ATTACK_DISTANCE; + } + + rate_values[RATE_DURABILITY_LOSS_DAMAGE] = sConfig.GetFloatDefault("DurabilityLossChance.Damage",0.5f); + if(rate_values[RATE_DURABILITY_LOSS_DAMAGE] < 0.0f) + { + sLog.outError("DurabilityLossChance.Damage (%f) must be >=0. Using 0.0 instead.",rate_values[RATE_DURABILITY_LOSS_DAMAGE]); + rate_values[RATE_DURABILITY_LOSS_DAMAGE] = 0.0f; + } + rate_values[RATE_DURABILITY_LOSS_ABSORB] = sConfig.GetFloatDefault("DurabilityLossChance.Absorb",0.5f); + if(rate_values[RATE_DURABILITY_LOSS_ABSORB] < 0.0f) + { + sLog.outError("DurabilityLossChance.Absorb (%f) must be >=0. Using 0.0 instead.",rate_values[RATE_DURABILITY_LOSS_ABSORB]); + rate_values[RATE_DURABILITY_LOSS_ABSORB] = 0.0f; + } + rate_values[RATE_DURABILITY_LOSS_PARRY] = sConfig.GetFloatDefault("DurabilityLossChance.Parry",0.05f); + if(rate_values[RATE_DURABILITY_LOSS_PARRY] < 0.0f) + { + sLog.outError("DurabilityLossChance.Parry (%f) must be >=0. Using 0.0 instead.",rate_values[RATE_DURABILITY_LOSS_PARRY]); + rate_values[RATE_DURABILITY_LOSS_PARRY] = 0.0f; + } + rate_values[RATE_DURABILITY_LOSS_BLOCK] = sConfig.GetFloatDefault("DurabilityLossChance.Block",0.05f); + if(rate_values[RATE_DURABILITY_LOSS_BLOCK] < 0.0f) + { + sLog.outError("DurabilityLossChance.Block (%f) must be >=0. Using 0.0 instead.",rate_values[RATE_DURABILITY_LOSS_BLOCK]); + rate_values[RATE_DURABILITY_LOSS_BLOCK] = 0.0f; + } + + ///- Read other configuration items from the config file + + m_configs[CONFIG_COMPRESSION] = sConfig.GetIntDefault("Compression", 1); + if(m_configs[CONFIG_COMPRESSION] < 1 || m_configs[CONFIG_COMPRESSION] > 9) + { + sLog.outError("Compression level (%i) must be in range 1..9. Using default compression level (1).",m_configs[CONFIG_COMPRESSION]); + m_configs[CONFIG_COMPRESSION] = 1; + } + m_configs[CONFIG_ADDON_CHANNEL] = sConfig.GetBoolDefault("AddonChannel", true); + m_configs[CONFIG_GRID_UNLOAD] = sConfig.GetBoolDefault("GridUnload", true); + m_configs[CONFIG_INTERVAL_SAVE] = sConfig.GetIntDefault("PlayerSaveInterval", 900000); + + m_configs[CONFIG_INTERVAL_GRIDCLEAN] = sConfig.GetIntDefault("GridCleanUpDelay", 300000); + if(m_configs[CONFIG_INTERVAL_GRIDCLEAN] < MIN_GRID_DELAY) + { + sLog.outError("GridCleanUpDelay (%i) must be greater %u. Use this minimal value.",m_configs[CONFIG_INTERVAL_GRIDCLEAN],MIN_GRID_DELAY); + m_configs[CONFIG_INTERVAL_GRIDCLEAN] = MIN_GRID_DELAY; + } + if(reload) + MapManager::Instance().SetGridCleanUpDelay(m_configs[CONFIG_INTERVAL_GRIDCLEAN]); + + m_configs[CONFIG_INTERVAL_MAPUPDATE] = sConfig.GetIntDefault("MapUpdateInterval", 100); + if(m_configs[CONFIG_INTERVAL_MAPUPDATE] < MIN_MAP_UPDATE_DELAY) + { + sLog.outError("MapUpdateInterval (%i) must be greater %u. Use this minimal value.",m_configs[CONFIG_INTERVAL_MAPUPDATE],MIN_MAP_UPDATE_DELAY); + m_configs[CONFIG_INTERVAL_MAPUPDATE] = MIN_MAP_UPDATE_DELAY; + } + if(reload) + MapManager::Instance().SetMapUpdateInterval(m_configs[CONFIG_INTERVAL_MAPUPDATE]); + + m_configs[CONFIG_INTERVAL_CHANGEWEATHER] = sConfig.GetIntDefault("ChangeWeatherInterval", 600000); + + if(reload) + { + uint32 val = sConfig.GetIntDefault("WorldServerPort", DEFAULT_WORLDSERVER_PORT); + if(val!=m_configs[CONFIG_PORT_WORLD]) + sLog.outError("WorldServerPort option can't be changed at mangosd.conf reload, using current value (%u).",m_configs[CONFIG_PORT_WORLD]); + } + else + m_configs[CONFIG_PORT_WORLD] = sConfig.GetIntDefault("WorldServerPort", DEFAULT_WORLDSERVER_PORT); + + if(reload) + { + uint32 val = sConfig.GetIntDefault("SocketSelectTime", DEFAULT_SOCKET_SELECT_TIME); + if(val!=m_configs[CONFIG_SOCKET_SELECTTIME]) + sLog.outError("SocketSelectTime option can't be changed at mangosd.conf reload, using current value (%u).",m_configs[DEFAULT_SOCKET_SELECT_TIME]); + } + else + m_configs[CONFIG_SOCKET_SELECTTIME] = sConfig.GetIntDefault("SocketSelectTime", DEFAULT_SOCKET_SELECT_TIME); + + + m_configs[CONFIG_TCP_NO_DELAY] = sConfig.GetBoolDefault("TcpNoDelay", false); + m_configs[CONFIG_GROUP_XP_DISTANCE] = sConfig.GetIntDefault("MaxGroupXPDistance", 74); + /// \todo Add MonsterSight and GuarderSight (with meaning) in mangosd.conf or put them as define + m_configs[CONFIG_SIGHT_MONSTER] = sConfig.GetIntDefault("MonsterSight", 50); + m_configs[CONFIG_SIGHT_GUARDER] = sConfig.GetIntDefault("GuarderSight", 50); + + if(reload) + { + uint32 val = sConfig.GetIntDefault("GameType", 0); + if(val!=m_configs[CONFIG_GAME_TYPE]) + sLog.outError("GameType option can't be changed at mangosd.conf reload, using current value (%u).",m_configs[CONFIG_GAME_TYPE]); + } + else + m_configs[CONFIG_GAME_TYPE] = sConfig.GetIntDefault("GameType", 0); + + if(reload) + { + uint32 val = sConfig.GetIntDefault("RealmZone", REALM_ZONE_DEVELOPMENT); + if(val!=m_configs[CONFIG_REALM_ZONE]) + sLog.outError("RealmZone option can't be changed at mangosd.conf reload, using current value (%u).",m_configs[CONFIG_REALM_ZONE]); + } + else + m_configs[CONFIG_REALM_ZONE] = sConfig.GetIntDefault("RealmZone", REALM_ZONE_DEVELOPMENT); + + m_configs[CONFIG_ALLOW_TWO_SIDE_ACCOUNTS] = sConfig.GetBoolDefault("AllowTwoSide.Accounts", false); + m_configs[CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHAT] = sConfig.GetBoolDefault("AllowTwoSide.Interaction.Chat",false); + m_configs[CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHANNEL] = sConfig.GetBoolDefault("AllowTwoSide.Interaction.Channel",false); + m_configs[CONFIG_ALLOW_TWO_SIDE_INTERACTION_GROUP] = sConfig.GetBoolDefault("AllowTwoSide.Interaction.Group",false); + m_configs[CONFIG_ALLOW_TWO_SIDE_INTERACTION_GUILD] = sConfig.GetBoolDefault("AllowTwoSide.Interaction.Guild",false); + m_configs[CONFIG_ALLOW_TWO_SIDE_INTERACTION_AUCTION] = sConfig.GetBoolDefault("AllowTwoSide.Interaction.Auction",false); + m_configs[CONFIG_ALLOW_TWO_SIDE_INTERACTION_MAIL] = sConfig.GetBoolDefault("AllowTwoSide.Interaction.Mail",false); + m_configs[CONFIG_ALLOW_TWO_SIDE_WHO_LIST] = sConfig.GetBoolDefault("AllowTwoSide.WhoList", false); + m_configs[CONFIG_ALLOW_TWO_SIDE_ADD_FRIEND] = sConfig.GetBoolDefault("AllowTwoSide.AddFriend", false); + m_configs[CONFIG_STRICT_PLAYER_NAMES] = sConfig.GetIntDefault("StrictPlayerNames", 0); + m_configs[CONFIG_STRICT_CHARTER_NAMES] = sConfig.GetIntDefault("StrictCharterNames", 0); + m_configs[CONFIG_STRICT_PET_NAMES] = sConfig.GetIntDefault("StrictPetNames", 0); + + m_configs[CONFIG_CHARACTERS_CREATING_DISABLED] = sConfig.GetIntDefault("CharactersCreatingDisabled", 0); + + m_configs[CONFIG_CHARACTERS_PER_REALM] = sConfig.GetIntDefault("CharactersPerRealm", 10); + if(m_configs[CONFIG_CHARACTERS_PER_REALM] < 1 || m_configs[CONFIG_CHARACTERS_PER_REALM] > 10) + { + sLog.outError("CharactersPerRealm (%i) must be in range 1..10. Set to 10.",m_configs[CONFIG_CHARACTERS_PER_REALM]); + m_configs[CONFIG_CHARACTERS_PER_REALM] = 10; + } + + // must be after CONFIG_CHARACTERS_PER_REALM + m_configs[CONFIG_CHARACTERS_PER_ACCOUNT] = sConfig.GetIntDefault("CharactersPerAccount", 50); + if(m_configs[CONFIG_CHARACTERS_PER_ACCOUNT] < m_configs[CONFIG_CHARACTERS_PER_REALM]) + { + sLog.outError("CharactersPerAccount (%i) can't be less than CharactersPerRealm (%i).",m_configs[CONFIG_CHARACTERS_PER_ACCOUNT],m_configs[CONFIG_CHARACTERS_PER_REALM]); + m_configs[CONFIG_CHARACTERS_PER_ACCOUNT] = m_configs[CONFIG_CHARACTERS_PER_REALM]; + } + + m_configs[CONFIG_SKIP_CINEMATICS] = sConfig.GetIntDefault("SkipCinematics", 0); + if(m_configs[CONFIG_SKIP_CINEMATICS] < 0 || m_configs[CONFIG_SKIP_CINEMATICS] > 2) + { + sLog.outError("SkipCinematics (%i) must be in range 0..2. Set to 0.",m_configs[CONFIG_SKIP_CINEMATICS]); + m_configs[CONFIG_SKIP_CINEMATICS] = 0; + } + + + if(reload) + { + uint32 val = sConfig.GetIntDefault("MaxPlayerLevel", 60); + if(val!=m_configs[CONFIG_MAX_PLAYER_LEVEL]) + sLog.outError("MaxPlayerLevel option can't be changed at mangosd.conf reload, using current value (%u).",m_configs[CONFIG_MAX_PLAYER_LEVEL]); + } + else + m_configs[CONFIG_MAX_PLAYER_LEVEL] = sConfig.GetIntDefault("MaxPlayerLevel", 60); + if(m_configs[CONFIG_MAX_PLAYER_LEVEL] > 255) + { + sLog.outError("MaxPlayerLevel (%i) must be in range 1..255. Set to 255.",m_configs[CONFIG_MAX_PLAYER_LEVEL]); + m_configs[CONFIG_MAX_PLAYER_LEVEL] = 255; + } + + m_configs[CONFIG_START_PLAYER_LEVEL] = sConfig.GetIntDefault("StartPlayerLevel", 1); + if(m_configs[CONFIG_START_PLAYER_LEVEL] < 1) + { + sLog.outError("StartPlayerLevel (%i) must be in range 1..MaxPlayerLevel(%u). Set to 1.",m_configs[CONFIG_START_PLAYER_LEVEL],m_configs[CONFIG_MAX_PLAYER_LEVEL]); + m_configs[CONFIG_START_PLAYER_LEVEL] = 1; + } + else if(m_configs[CONFIG_START_PLAYER_LEVEL] > m_configs[CONFIG_MAX_PLAYER_LEVEL]) + { + sLog.outError("StartPlayerLevel (%i) must be in range 1..MaxPlayerLevel(%u). Set to %u.",m_configs[CONFIG_START_PLAYER_LEVEL],m_configs[CONFIG_MAX_PLAYER_LEVEL],m_configs[CONFIG_MAX_PLAYER_LEVEL]); + m_configs[CONFIG_START_PLAYER_LEVEL] = m_configs[CONFIG_MAX_PLAYER_LEVEL]; + } + m_configs[CONFIG_MAX_HONOR_POINTS] = sConfig.GetIntDefault("MaxHonorPoints", 75000); + m_configs[CONFIG_MAX_ARENA_POINTS] = sConfig.GetIntDefault("MaxArenaPoints", 5000); + + m_configs[CONFIG_INSTANCE_IGNORE_LEVEL] = sConfig.GetBoolDefault("Instance.IgnoreLevel", false); + m_configs[CONFIG_INSTANCE_IGNORE_RAID] = sConfig.GetBoolDefault("Instance.IgnoreRaid", false); + + m_configs[CONFIG_BATTLEGROUND_CAST_DESERTER] = sConfig.GetBoolDefault("Battleground.CastDeserter", true); + m_configs[CONFIG_BATTLEGROUND_QUEUE_ANNOUNCER_ENABLE] = sConfig.GetBoolDefault("Battleground.QueueAnnouncer.Enable", true); + m_configs[CONFIG_BATTLEGROUND_QUEUE_ANNOUNCER_PLAYERONLY] = sConfig.GetBoolDefault("Battleground.QueueAnnouncer.PlayerOnly", false); + + m_configs[CONFIG_CAST_UNSTUCK] = sConfig.GetBoolDefault("CastUnstuck", true); + m_configs[CONFIG_INSTANCE_RESET_TIME_HOUR] = sConfig.GetIntDefault("Instance.ResetTimeHour", 4); + m_configs[CONFIG_INSTANCE_UNLOAD_DELAY] = sConfig.GetIntDefault("Instance.UnloadDelay", 1800000); + + m_configs[CONFIG_MAX_PRIMARY_TRADE_SKILL] = sConfig.GetIntDefault("MaxPrimaryTradeSkill", 2); + m_configs[CONFIG_MIN_PETITION_SIGNS] = sConfig.GetIntDefault("MinPetitionSigns", 9); + if(m_configs[CONFIG_MIN_PETITION_SIGNS] > 9) + { + sLog.outError("MinPetitionSigns (%i) must be in range 0..9. Set to 9.",m_configs[CONFIG_MIN_PETITION_SIGNS]); + m_configs[CONFIG_MIN_PETITION_SIGNS] = 9; + } + + m_configs[CONFIG_GM_WISPERING_TO] = sConfig.GetBoolDefault("GM.WhisperingTo",false); + m_configs[CONFIG_GM_IN_GM_LIST] = sConfig.GetBoolDefault("GM.InGMList",false); + m_configs[CONFIG_GM_IN_WHO_LIST] = sConfig.GetBoolDefault("GM.InWhoList",false); + m_configs[CONFIG_GM_LOGIN_STATE] = sConfig.GetIntDefault("GM.LoginState",2); + m_configs[CONFIG_GM_LOG_TRADE] = sConfig.GetBoolDefault("GM.LogTrade", false); + + m_configs[CONFIG_GROUP_VISIBILITY] = sConfig.GetIntDefault("Visibility.GroupMode",0); + + m_configs[CONFIG_MAIL_DELIVERY_DELAY] = sConfig.GetIntDefault("MailDeliveryDelay",HOUR); + + m_configs[CONFIG_UPTIME_UPDATE] = sConfig.GetIntDefault("UpdateUptimeInterval", 10); + if(m_configs[CONFIG_UPTIME_UPDATE]<=0) + { + sLog.outError("UpdateUptimeInterval (%i) must be > 0, set to default 10.",m_configs[CONFIG_UPTIME_UPDATE]); + m_configs[CONFIG_UPTIME_UPDATE] = 10; + } + if(reload) + { + m_timers[WUPDATE_UPTIME].SetInterval(m_configs[CONFIG_UPTIME_UPDATE]*MINUTE*1000); + m_timers[WUPDATE_UPTIME].Reset(); + } + + m_configs[CONFIG_SKILL_CHANCE_ORANGE] = sConfig.GetIntDefault("SkillChance.Orange",100); + m_configs[CONFIG_SKILL_CHANCE_YELLOW] = sConfig.GetIntDefault("SkillChance.Yellow",75); + m_configs[CONFIG_SKILL_CHANCE_GREEN] = sConfig.GetIntDefault("SkillChance.Green",25); + m_configs[CONFIG_SKILL_CHANCE_GREY] = sConfig.GetIntDefault("SkillChance.Grey",0); + + m_configs[CONFIG_SKILL_CHANCE_MINING_STEPS] = sConfig.GetIntDefault("SkillChance.MiningSteps",75); + m_configs[CONFIG_SKILL_CHANCE_SKINNING_STEPS] = sConfig.GetIntDefault("SkillChance.SkinningSteps",75); + + m_configs[CONFIG_SKILL_PROSPECTING] = sConfig.GetBoolDefault("SkillChance.Prospecting",false); + + m_configs[CONFIG_SKILL_GAIN_CRAFTING] = sConfig.GetIntDefault("SkillGain.Crafting", 1); + if(m_configs[CONFIG_SKILL_GAIN_CRAFTING] < 0) + { + sLog.outError("SkillGain.Crafting (%i) can't be negative. Set to 1.",m_configs[CONFIG_SKILL_GAIN_CRAFTING]); + m_configs[CONFIG_SKILL_GAIN_CRAFTING] = 1; + } + + m_configs[CONFIG_SKILL_GAIN_DEFENSE] = sConfig.GetIntDefault("SkillGain.Defense", 1); + if(m_configs[CONFIG_SKILL_GAIN_DEFENSE] < 0) + { + sLog.outError("SkillGain.Defense (%i) can't be negative. Set to 1.",m_configs[CONFIG_SKILL_GAIN_DEFENSE]); + m_configs[CONFIG_SKILL_GAIN_DEFENSE] = 1; + } + + m_configs[CONFIG_SKILL_GAIN_GATHERING] = sConfig.GetIntDefault("SkillGain.Gathering", 1); + if(m_configs[CONFIG_SKILL_GAIN_GATHERING] < 0) + { + sLog.outError("SkillGain.Gathering (%i) can't be negative. Set to 1.",m_configs[CONFIG_SKILL_GAIN_GATHERING]); + m_configs[CONFIG_SKILL_GAIN_GATHERING] = 1; + } + + m_configs[CONFIG_SKILL_GAIN_WEAPON] = sConfig.GetIntDefault("SkillGain.Weapon", 1); + if(m_configs[CONFIG_SKILL_GAIN_WEAPON] < 0) + { + sLog.outError("SkillGain.Weapon (%i) can't be negative. Set to 1.",m_configs[CONFIG_SKILL_GAIN_WEAPON]); + m_configs[CONFIG_SKILL_GAIN_WEAPON] = 1; + } + + m_configs[CONFIG_MAX_OVERSPEED_PINGS] = sConfig.GetIntDefault("MaxOverspeedPings",2); + if(m_configs[CONFIG_MAX_OVERSPEED_PINGS] != 0 && m_configs[CONFIG_MAX_OVERSPEED_PINGS] < 2) + { + sLog.outError("MaxOverspeedPings (%i) must be in range 2..infinity (or 0 to disable check. Set to 2.",m_configs[CONFIG_MAX_OVERSPEED_PINGS]); + m_configs[CONFIG_MAX_OVERSPEED_PINGS] = 2; + } + + m_configs[CONFIG_SAVE_RESPAWN_TIME_IMMEDIATLY] = sConfig.GetBoolDefault("SaveRespawnTimeImmediately",true); + m_configs[CONFIG_WEATHER] = sConfig.GetBoolDefault("ActivateWeather",true); + + if(reload) + { + uint32 val = sConfig.GetIntDefault("Expansion",1); + if(val!=m_configs[CONFIG_EXPANSION]) + sLog.outError("Expansion option can't be changed at mangosd.conf reload, using current value (%u).",m_configs[CONFIG_EXPANSION]); + } + else + m_configs[CONFIG_EXPANSION] = sConfig.GetIntDefault("Expansion",1); + + m_configs[CONFIG_CHATFLOOD_MESSAGE_COUNT] = sConfig.GetIntDefault("ChatFlood.MessageCount",10); + m_configs[CONFIG_CHATFLOOD_MESSAGE_DELAY] = sConfig.GetIntDefault("ChatFlood.MessageDelay",1); + m_configs[CONFIG_CHATFLOOD_MUTE_TIME] = sConfig.GetIntDefault("ChatFlood.MuteTime",10); + + m_configs[CONFIG_EVENT_ANNOUNCE] = sConfig.GetIntDefault("Event.Announce",0); + + m_configs[CONFIG_CREATURE_FAMILY_ASSISTEMCE_RADIUS] = sConfig.GetIntDefault("CreatureFamilyAssistenceRadius",10); + + m_configs[CONFIG_WORLD_BOSS_LEVEL_DIFF] = sConfig.GetIntDefault("WorldBossLevelDiff",3); + + // note: disable value (-1) will assigned as 0xFFFFFFF, to prevent overflow at calculations limit it to max possible player level (255) + m_configs[CONFIG_QUEST_LOW_LEVEL_HIDE_DIFF] = sConfig.GetIntDefault("Quests.LowLevelHideDiff",4); + if(m_configs[CONFIG_QUEST_LOW_LEVEL_HIDE_DIFF] > 255) + m_configs[CONFIG_QUEST_LOW_LEVEL_HIDE_DIFF] = 255; + m_configs[CONFIG_QUEST_HIGH_LEVEL_HIDE_DIFF] = sConfig.GetIntDefault("Quests.HighLevelHideDiff",7); + if(m_configs[CONFIG_QUEST_HIGH_LEVEL_HIDE_DIFF] > 255) + m_configs[CONFIG_QUEST_HIGH_LEVEL_HIDE_DIFF] = 255; + + m_configs[CONFIG_DETECT_POS_COLLISION] = sConfig.GetBoolDefault("DetectPosCollision", true); + + m_configs[CONFIG_RESTRICTED_LFG_CHANNEL] = sConfig.GetBoolDefault("Channel.RestrictedLfg", true); + m_configs[CONFIG_SILENTLY_GM_JOIN_TO_CHANNEL] = sConfig.GetBoolDefault("Channel.SilentlyGMJoin", false); + + m_configs[CONFIG_TALENTS_INSPECTING] = sConfig.GetBoolDefault("TalentsInspecting", true); + m_configs[CONFIG_CHAT_FAKE_MESSAGE_PREVENTING] = sConfig.GetBoolDefault("ChatFakeMessagePreventing", false); + + m_configs[CONFIG_CORPSE_DECAY_NORMAL] = sConfig.GetIntDefault("Corpse.Decay.NORMAL", 60); + m_configs[CONFIG_CORPSE_DECAY_RARE] = sConfig.GetIntDefault("Corpse.Decay.RARE", 300); + m_configs[CONFIG_CORPSE_DECAY_ELITE] = sConfig.GetIntDefault("Corpse.Decay.ELITE", 300); + m_configs[CONFIG_CORPSE_DECAY_RAREELITE] = sConfig.GetIntDefault("Corpse.Decay.RAREELITE", 300); + m_configs[CONFIG_CORPSE_DECAY_WORLDBOSS] = sConfig.GetIntDefault("Corpse.Decay.WORLDBOSS", 3600); + + m_configs[CONFIG_DEATH_SICKNESS_LEVEL] = sConfig.GetIntDefault("Death.SicknessLevel", 11); + m_configs[CONFIG_DEATH_CORPSE_RECLAIM_DELAY_PVP] = sConfig.GetBoolDefault("Death.CorpseReclaimDelay.PvP", true); + m_configs[CONFIG_DEATH_CORPSE_RECLAIM_DELAY_PVE] = sConfig.GetBoolDefault("Death.CorpseReclaimDelay.PvE", true); + + m_configs[CONFIG_THREAT_RADIUS] = sConfig.GetIntDefault("ThreatRadius", 100); + + // always use declined names in the russian client + m_configs[CONFIG_DECLINED_NAMES_USED] = + (m_configs[CONFIG_REALM_ZONE] == REALM_ZONE_RUSSIAN) ? true : sConfig.GetBoolDefault("DeclinedNames", false); + + m_configs[CONFIG_LISTEN_RANGE_SAY] = sConfig.GetIntDefault("ListenRange.Say", 25); + m_configs[CONFIG_LISTEN_RANGE_TEXTEMOTE] = sConfig.GetIntDefault("ListenRange.TextEmote", 25); + m_configs[CONFIG_LISTEN_RANGE_YELL] = sConfig.GetIntDefault("ListenRange.Yell", 300); + + + m_VisibleUnitGreyDistance = sConfig.GetFloatDefault("Visibility.Distance.Grey.Unit", 1); + if(m_VisibleUnitGreyDistance > MAX_VISIBILITY_DISTANCE) + { + sLog.outError("Visibility.Distance.Grey.Unit can't be greater %f",MAX_VISIBILITY_DISTANCE); + m_VisibleUnitGreyDistance = MAX_VISIBILITY_DISTANCE; + } + m_VisibleObjectGreyDistance = sConfig.GetFloatDefault("Visibility.Distance.Grey.Object", 10); + if(m_VisibleObjectGreyDistance > MAX_VISIBILITY_DISTANCE) + { + sLog.outError("Visibility.Distance.Grey.Object can't be greater %f",MAX_VISIBILITY_DISTANCE); + m_VisibleObjectGreyDistance = MAX_VISIBILITY_DISTANCE; + } + + m_MaxVisibleDistanceForCreature = sConfig.GetFloatDefault("Visibility.Distance.Creature", DEFAULT_VISIBILITY_DISTANCE); + if(m_MaxVisibleDistanceForCreature < 45*sWorld.getRate(RATE_CREATURE_AGGRO)) + { + sLog.outError("Visibility.Distance.Creature can't be less max aggro radius %f",45*sWorld.getRate(RATE_CREATURE_AGGRO)); + m_MaxVisibleDistanceForCreature = 45*sWorld.getRate(RATE_CREATURE_AGGRO); + } + else if(m_MaxVisibleDistanceForCreature + m_VisibleUnitGreyDistance > MAX_VISIBILITY_DISTANCE) + { + sLog.outError("Visibility. Distance .Creature can't be greater %f",MAX_VISIBILITY_DISTANCE - m_VisibleUnitGreyDistance); + m_MaxVisibleDistanceForCreature = MAX_VISIBILITY_DISTANCE-m_VisibleUnitGreyDistance; + } + m_MaxVisibleDistanceForPlayer = sConfig.GetFloatDefault("Visibility.Distance.Player", DEFAULT_VISIBILITY_DISTANCE); + if(m_MaxVisibleDistanceForPlayer < 45*sWorld.getRate(RATE_CREATURE_AGGRO)) + { + sLog.outError("Visibility.Distance.Player can't be less max aggro radius %f",45*sWorld.getRate(RATE_CREATURE_AGGRO)); + m_MaxVisibleDistanceForPlayer = 45*sWorld.getRate(RATE_CREATURE_AGGRO); + } + else if(m_MaxVisibleDistanceForPlayer + m_VisibleUnitGreyDistance > MAX_VISIBILITY_DISTANCE) + { + sLog.outError("Visibility.Distance.Player can't be greater %f",MAX_VISIBILITY_DISTANCE - m_VisibleUnitGreyDistance); + m_MaxVisibleDistanceForPlayer = MAX_VISIBILITY_DISTANCE - m_VisibleUnitGreyDistance; + } + m_MaxVisibleDistanceForObject = sConfig.GetFloatDefault("Visibility.Distance.Gameobject", DEFAULT_VISIBILITY_DISTANCE); + if(m_MaxVisibleDistanceForObject < INTERACTION_DISTANCE) + { + sLog.outError("Visibility.Distance.Object can't be less max aggro radius %f",float(INTERACTION_DISTANCE)); + m_MaxVisibleDistanceForObject = INTERACTION_DISTANCE; + } + else if(m_MaxVisibleDistanceForObject + m_VisibleObjectGreyDistance > MAX_VISIBILITY_DISTANCE) + { + sLog.outError("Visibility.Distance.Object can't be greater %f",MAX_VISIBILITY_DISTANCE-m_VisibleObjectGreyDistance); + m_MaxVisibleDistanceForObject = MAX_VISIBILITY_DISTANCE - m_VisibleObjectGreyDistance; + } + m_MaxVisibleDistanceInFlight = sConfig.GetFloatDefault("Visibility.Distance.InFlight", DEFAULT_VISIBILITY_DISTANCE); + if(m_MaxVisibleDistanceInFlight + m_VisibleObjectGreyDistance > MAX_VISIBILITY_DISTANCE) + { + sLog.outError("Visibility.Distance.InFlight can't be greater %f",MAX_VISIBILITY_DISTANCE-m_VisibleObjectGreyDistance); + m_MaxVisibleDistanceInFlight = MAX_VISIBILITY_DISTANCE - m_VisibleObjectGreyDistance; + } + + ///- Read the "Data" directory from the config file + std::string dataPath = sConfig.GetStringDefault("DataDir","./"); + if( dataPath.at(dataPath.length()-1)!='/' && dataPath.at(dataPath.length()-1)!='\\' ) + dataPath.append("/"); + + if(reload) + { + if(dataPath!=m_dataPath) + sLog.outError("DataDir option can't be changed at mangosd.conf reload, using current value (%s).",m_dataPath.c_str()); + } + else + { + m_dataPath = dataPath; + sLog.outString("Using DataDir %s",m_dataPath.c_str()); + } + + bool enableLOS = sConfig.GetBoolDefault("vmap.enableLOS", false); + bool enableHeight = sConfig.GetBoolDefault("vmap.enableHeight", false); + std::string ignoreMapIds = sConfig.GetStringDefault("vmap.ignoreMapIds", ""); + std::string ignoreSpellIds = sConfig.GetStringDefault("vmap.ignoreSpellIds", ""); + VMAP::VMapFactory::createOrGetVMapManager()->setEnableLineOfSightCalc(enableLOS); + VMAP::VMapFactory::createOrGetVMapManager()->setEnableHeightCalc(enableHeight); + VMAP::VMapFactory::createOrGetVMapManager()->preventMapsFromBeingUsed(ignoreMapIds.c_str()); + VMAP::VMapFactory::preventSpellsFromBeingTestedForLoS(ignoreSpellIds.c_str()); + sLog.outString( "WORLD: VMap support included. LineOfSight:%i, getHeight:%i",enableLOS, enableHeight); + sLog.outString( "WORLD: VMap data directory is: %svmaps",m_dataPath.c_str()); + sLog.outString( "WORLD: VMap config keys are: vmap.enableLOS, vmap.enableHeight, vmap.ignoreMapIds, vmap.ignoreSpellIds"); +} + +/// Initialize the World +void World::SetInitialWorldSettings() +{ + ///- Initialize the random number generator + srand((unsigned int)time(NULL)); + + ///- Initialize config settings + LoadConfigSettings(); + + ///- Init highest guids before any table loading to prevent using not initialized guids in some code. + objmgr.SetHighestGuids(); + + ///- Check the existence of the map files for all races' startup areas. + if( !MapManager::ExistMapAndVMap(0,-6240.32f, 331.033f) + ||!MapManager::ExistMapAndVMap(0,-8949.95f,-132.493f) + ||!MapManager::ExistMapAndVMap(0,-8949.95f,-132.493f) + ||!MapManager::ExistMapAndVMap(1,-618.518f,-4251.67f) + ||!MapManager::ExistMapAndVMap(0, 1676.35f, 1677.45f) + ||!MapManager::ExistMapAndVMap(1, 10311.3f, 832.463f) + ||!MapManager::ExistMapAndVMap(1,-2917.58f,-257.98f) + ||m_configs[CONFIG_EXPANSION] && ( + !MapManager::ExistMapAndVMap(530,10349.6f,-6357.29f) || !MapManager::ExistMapAndVMap(530,-3961.64f,-13931.2f) ) ) + { + sLog.outError("Correct *.map files not found in path '%smaps' or *.vmap/*vmdir files in '%svmaps'. Please place *.map/*.vmap/*.vmdir files in appropriate directories or correct the DataDir value in the mangosd.conf file.",m_dataPath.c_str(),m_dataPath.c_str()); + exit(1); + } + + ///- Loading strings. Getting no records means core load has to be canceled because no error message can be output. + sLog.outString( "" ); + sLog.outString( "Loading MaNGOS strings..." ); + if (!objmgr.LoadMangosStrings()) + exit(1); // Error message displayed in function already + + ///- Update the realm entry in the database with the realm type from the config file + //No SQL injection as values are treated as integers + + // not send custom type REALM_FFA_PVP to realm list + uint32 server_type = IsFFAPvPRealm() ? REALM_TYPE_PVP : getConfig(CONFIG_GAME_TYPE); + uint32 realm_zone = getConfig(CONFIG_REALM_ZONE); + loginDatabase.PExecute("UPDATE realmlist SET icon = %u, timezone = %u WHERE id = '%d'", server_type, realm_zone, realmID); + + ///- Remove the bones after a restart + CharacterDatabase.PExecute("DELETE FROM corpse WHERE corpse_type = '0'"); + + ///- Load the DBC files + sLog.outString("Initialize data stores..."); + LoadDBCStores(m_dataPath); + DetectDBCLang(); + + sLog.outString( "Loading InstanceTemplate" ); + objmgr.LoadInstanceTemplate(); + + sLog.outString( "Loading SkillLineAbilityMultiMap Data..." ); + spellmgr.LoadSkillLineAbilityMap(); + + ///- Clean up and pack instances + sLog.outString( "Cleaning up instances..." ); + sInstanceSaveManager.CleanupInstances(); // must be called before `creature_respawn`/`gameobject_respawn` tables + + sLog.outString( "Packing instances..." ); + sInstanceSaveManager.PackInstances(); + + sLog.outString( "Loading Localization strings..." ); + objmgr.LoadCreatureLocales(); + objmgr.LoadGameObjectLocales(); + objmgr.LoadItemLocales(); + objmgr.LoadQuestLocales(); + objmgr.LoadNpcTextLocales(); + objmgr.LoadPageTextLocales(); + objmgr.SetDBCLocaleIndex(GetDefaultDbcLocale()); // Get once for all the locale index of DBC language (console/broadcasts) + + sLog.outString( "Loading Page Texts..." ); + objmgr.LoadPageTexts(); + + sLog.outString( "Loading Game Object Templates..." ); // must be after LoadPageTexts + objmgr.LoadGameobjectInfo(); + + sLog.outString( "Loading Spell Chain Data..." ); + spellmgr.LoadSpellChains(); + + sLog.outString( "Loading Spell Elixir types..." ); + spellmgr.LoadSpellElixirs(); + + sLog.outString( "Loading Spell Learn Skills..." ); + spellmgr.LoadSpellLearnSkills(); // must be after LoadSpellChains + + sLog.outString( "Loading Spell Learn Spells..." ); + spellmgr.LoadSpellLearnSpells(); + + sLog.outString( "Loading Spell Proc Event conditions..." ); + spellmgr.LoadSpellProcEvents(); + + sLog.outString( "Loading Aggro Spells Definitions..."); + spellmgr.LoadSpellThreats(); + + sLog.outString( "Loading NPC Texts..." ); + objmgr.LoadGossipText(); + + sLog.outString( "Loading Item Random Enchantments Table..." ); + LoadRandomEnchantmentsTable(); + + sLog.outString( "Loading Items..." ); // must be after LoadRandomEnchantmentsTable and LoadPageTexts + objmgr.LoadItemPrototypes(); + + sLog.outString( "Loading Item Texts..." ); + objmgr.LoadItemTexts(); + + sLog.outString( "Loading Creature Model Based Info Data..." ); + objmgr.LoadCreatureModelInfo(); + + sLog.outString( "Loading Equipment templates..."); + objmgr.LoadEquipmentTemplates(); + + sLog.outString( "Loading Creature templates..." ); + objmgr.LoadCreatureTemplates(); + + sLog.outString( "Loading SpellsScriptTarget..."); + spellmgr.LoadSpellScriptTarget(); // must be after LoadCreatureTemplates and LoadGameobjectInfo + + sLog.outString( "Loading Creature Reputation OnKill Data..." ); + objmgr.LoadReputationOnKill(); + + sLog.outString( "Loading Pet Create Spells..." ); + objmgr.LoadPetCreateSpells(); + + sLog.outString( "Loading Creature Data..." ); + objmgr.LoadCreatures(); + + sLog.outString( "Loading Creature Addon Data..." ); + objmgr.LoadCreatureAddons(); // must be after LoadCreatureTemplates() and LoadCreatures() + + sLog.outString( "Loading Creature Respawn Data..." ); // must be after PackInstances() + objmgr.LoadCreatureRespawnTimes(); + + sLog.outString( "Loading Gameobject Data..." ); + objmgr.LoadGameobjects(); + + sLog.outString( "Loading Gameobject Respawn Data..." ); // must be after PackInstances() + objmgr.LoadGameobjectRespawnTimes(); + + sLog.outString( "Loading Game Event Data..."); + gameeventmgr.LoadFromDB(); + + sLog.outString( "Loading Weather Data..." ); + objmgr.LoadWeatherZoneChances(); + + sLog.outString( "Loading Quests..." ); + objmgr.LoadQuests(); // must be loaded after DBCs, creature_template, item_template, gameobject tables + + sLog.outString( "Loading Quests Relations..." ); + objmgr.LoadQuestRelations(); // must be after quest load + + sLog.outString( "Loading AreaTrigger definitions..." ); + objmgr.LoadAreaTriggerTeleports(); // must be after item template load + + sLog.outString( "Loading Quest Area Triggers..." ); + objmgr.LoadQuestAreaTriggers(); // must be after LoadQuests + + sLog.outString( "Loading Tavern Area Triggers..." ); + objmgr.LoadTavernAreaTriggers(); + + sLog.outString( "Loading AreaTrigger script names..." ); + objmgr.LoadAreaTriggerScripts(); + + + sLog.outString( "Loading Graveyard-zone links..."); + objmgr.LoadGraveyardZones(); + + sLog.outString( "Loading Spell target coordinates..." ); + spellmgr.LoadSpellTargetPositions(); + + sLog.outString( "Loading SpellAffect definitions..." ); + spellmgr.LoadSpellAffects(); + + sLog.outString( "Loading spell pet auras..." ); + spellmgr.LoadSpellPetAuras(); + + sLog.outString( "Loading player Create Info & Level Stats..." ); + objmgr.LoadPlayerInfo(); + + sLog.outString( "Loading Exploration BaseXP Data..." ); + objmgr.LoadExplorationBaseXP(); + + sLog.outString( "Loading Pet Name Parts..." ); + objmgr.LoadPetNames(); + + sLog.outString( "Loading the max pet number..." ); + objmgr.LoadPetNumber(); + + sLog.outString( "Loading pet level stats..." ); + objmgr.LoadPetLevelInfo(); + + sLog.outString( "Loading Player Corpses..." ); + objmgr.LoadCorpses(); + + sLog.outString( "Loading Loot Tables..." ); + LoadLootTables(); + + sLog.outString( "Loading Skill Discovery Table..." ); + LoadSkillDiscoveryTable(); + + sLog.outString( "Loading Skill Extra Item Table..." ); + LoadSkillExtraItemTable(); + + sLog.outString( "Loading Skill Fishing base level requirements..." ); + objmgr.LoadFishingBaseSkillLevel(); + + ///- Load dynamic data tables from the database + sLog.outString( "Loading Auctions..." ); + objmgr.LoadAuctionItems(); + objmgr.LoadAuctions(); + + sLog.outString( "Loading Guilds..." ); + objmgr.LoadGuilds(); + + sLog.outString( "Loading ArenaTeams..." ); + objmgr.LoadArenaTeams(); + + sLog.outString( "Loading Groups..." ); + objmgr.LoadGroups(); + + sLog.outString( "Loading ReservedNames..." ); + objmgr.LoadReservedPlayersNames(); + + sLog.outString( "Loading GameObject for quests..." ); + objmgr.LoadGameObjectForQuests(); + + sLog.outString( "Loading BattleMasters..." ); + objmgr.LoadBattleMastersEntry(); + + sLog.outString( "Loading GameTeleports..." ); + objmgr.LoadGameTele(); + + sLog.outString( "Loading Npc Text Id..." ); + objmgr.LoadNpcTextId(); // must be after load Creature and NpcText + + sLog.outString( "Loading vendors..." ); + objmgr.LoadVendors(); // must be after load CreatureTemplate and ItemTemplate + + sLog.outString( "Loading trainers..." ); + objmgr.LoadTrainerSpell(); // must be after load CreatureTemplate + + sLog.outString( "Loading Waypoints..." ); + WaypointMgr.Load(); + + ///- Handle outdated emails (delete/return) + sLog.outString( "Returning old mails..." ); + objmgr.ReturnOrDeleteOldMails(false); + + ///- Load and initialize scripts + sLog.outString( "Loading Scripts..." ); + objmgr.LoadQuestStartScripts(); // must be after load Creature/Gameobject(Template/Data) and QuestTemplate + objmgr.LoadQuestEndScripts(); // must be after load Creature/Gameobject(Template/Data) and QuestTemplate + objmgr.LoadSpellScripts(); // must be after load Creature/Gameobject(Template/Data) + objmgr.LoadGameObjectScripts(); // must be after load Creature/Gameobject(Template/Data) + objmgr.LoadEventScripts(); // must be after load Creature/Gameobject(Template/Data) + + sLog.outString( "Initializing Scripts..." ); + if(!LoadScriptingModule()) + exit(1); + + ///- Initialize game time and timers + sLog.outString( "DEBUG:: Initialize game time and timers" ); + m_gameTime = time(NULL); + m_startTime=m_gameTime; + + tm local; + time_t curr; + time(&curr); + local=*(localtime(&curr)); // dereference and assign + char isoDate[128]; + sprintf( isoDate, "%04d-%02d-%02d %02d:%02d:%02d", + local.tm_year+1900, local.tm_mon+1, local.tm_mday, local.tm_hour, local.tm_min, local.tm_sec); + + WorldDatabase.PExecute("INSERT INTO uptime (startstring, starttime, uptime) VALUES('%s', %ld, 0)", isoDate, m_startTime ); + + m_timers[WUPDATE_OBJECTS].SetInterval(0); + m_timers[WUPDATE_SESSIONS].SetInterval(0); + m_timers[WUPDATE_WEATHERS].SetInterval(1000); + m_timers[WUPDATE_AUCTIONS].SetInterval(MINUTE*1000); //set auction update interval to 1 minute + m_timers[WUPDATE_UPTIME].SetInterval(m_configs[CONFIG_UPTIME_UPDATE]*MINUTE*1000); + //Update "uptime" table based on configuration entry in minutes. + m_timers[WUPDATE_CORPSES].SetInterval(20*MINUTE*1000); //erase corpses every 20 minutes + + //to set mailtimer to return mails every day between 4 and 5 am + //mailtimer is increased when updating auctions + //one second is 1000 -(tested on win system) + mail_timer = ((((localtime( &m_gameTime )->tm_hour + 20) % 24)* HOUR * 1000) / m_timers[WUPDATE_AUCTIONS].GetInterval() ); + //1440 + mail_timer_expires = ( (DAY * 1000) / (m_timers[WUPDATE_AUCTIONS].GetInterval())); + sLog.outDebug("Mail timer set to: %u, mail return is called every %u minutes", mail_timer, mail_timer_expires); + + ///- Initilize static helper structures + AIRegistry::Initialize(); + WaypointMovementGenerator::Initialize(); + Player::InitVisibleBits(); + + ///- Initialize MapManager + sLog.outString( "Starting Map System" ); + MapManager::Instance().Initialize(); + + ///- Initialize Battlegrounds + sLog.outString( "Starting BattleGround System" ); + sBattleGroundMgr.CreateInitialBattleGrounds(); + + //Not sure if this can be moved up in the sequence (with static data loading) as it uses MapManager + sLog.outString( "Loading Transports..." ); + MapManager::Instance().LoadTransports(); + + sLog.outString("Deleting expired bans..." ); + loginDatabase.Execute("DELETE FROM ip_banned WHERE unbandate<=UNIX_TIMESTAMP() AND unbandate<>bandate"); + + sLog.outString("Calculate next daily quest reset time..." ); + InitDailyQuestResetTime(); + + sLog.outString("Starting Game Event system..." ); + uint32 nextGameEvent = gameeventmgr.Initialize(); + m_timers[WUPDATE_EVENTS].SetInterval(nextGameEvent); //depend on next event + + sLog.outString( "WORLD: World initialized" ); +} +void World::DetectDBCLang() +{ + uint32 m_lang_confid = sConfig.GetIntDefault("DBC.Locale", 255); + + if(m_lang_confid != 255 && m_lang_confid >= MAX_LOCALE) + { + sLog.outError("Incorrect DBC.Locale! Must be >= 0 and < %d (set to 0)",MAX_LOCALE); + m_lang_confid = LOCALE_enUS; + } + + ChrRacesEntry const* race = sChrRacesStore.LookupEntry(1); + + std::string availableLocalsStr; + + int default_locale = MAX_LOCALE; + for (int i = MAX_LOCALE-1; i >= 0; --i) + { + if ( strlen(race->name[i]) > 0) // check by race names + { + default_locale = i; + m_availableDbcLocaleMask |= (1 << i); + availableLocalsStr += localeNames[i]; + availableLocalsStr += " "; + } + } + + if( default_locale != m_lang_confid && m_lang_confid < MAX_LOCALE && + (m_availableDbcLocaleMask & (1 << m_lang_confid)) ) + { + default_locale = m_lang_confid; + } + + if(default_locale >= MAX_LOCALE) + { + sLog.outError("Unable to determine your DBC Locale! (corrupt DBC?)"); + exit(1); + } + + m_defaultDbcLocale = LocaleConstant(default_locale); + + sLog.outString("Using %s DBC Locale as default. All available DBC locales: %s",localeNames[m_defaultDbcLocale],availableLocalsStr.empty() ? "" : availableLocalsStr.c_str()); +} + +/// Update the World ! +void World::Update(time_t diff) +{ + ///- Update the different timers + for(int i = 0; i < WUPDATE_COUNT; i++) + if(m_timers[i].GetCurrent()>=0) + m_timers[i].Update(diff); + else m_timers[i].SetCurrent(0); + + ///- Update the game time and check for shutdown time + _UpdateGameTime(); + + /// Handle daily quests reset time + if(m_gameTime > m_NextDailyQuestReset) + { + ResetDailyQuests(); + m_NextDailyQuestReset += DAY; + } + + ///
  • Handle auctions when the timer has passed + if (m_timers[WUPDATE_AUCTIONS].Passed()) + { + m_timers[WUPDATE_AUCTIONS].Reset(); + + ///- Update mails (return old mails with item, or delete them) + //(tested... works on win) + if (++mail_timer > mail_timer_expires) + { + mail_timer = 0; + objmgr.ReturnOrDeleteOldMails(true); + } + + AuctionHouseObject* AuctionMap; + for (int i = 0; i < 3; i++) + { + switch (i) + { + case 0: + AuctionMap = objmgr.GetAuctionsMap( 6 );//horde + break; + case 1: + AuctionMap = objmgr.GetAuctionsMap( 2 );//alliance + break; + case 2: + AuctionMap = objmgr.GetAuctionsMap( 7 );//neutral + break; + } + + ///- Handle expired auctions + AuctionHouseObject::AuctionEntryMap::iterator itr,next; + for (itr = AuctionMap->GetAuctionsBegin(); itr != AuctionMap->GetAuctionsEnd();itr = next) + { + next = itr; + ++next; + if (m_gameTime > (itr->second->time)) + { + ///- Either cancel the auction if there was no bidder + if (itr->second->bidder == 0) + { + objmgr.SendAuctionExpiredMail( itr->second ); + } + ///- Or perform the transaction + else + { + //we should send an "item sold" message if the seller is online + //we send the item to the winner + //we send the money to the seller + objmgr.SendAuctionSuccessfulMail( itr->second ); + objmgr.SendAuctionWonMail( itr->second ); + } + + ///- In any case clear the auction + //No SQL injection (Id is integer) + CharacterDatabase.PExecute("DELETE FROM auctionhouse WHERE id = '%u'",itr->second->Id); + objmgr.RemoveAItem(itr->second->item_guidlow); + delete itr->second; + AuctionMap->RemoveAuction(itr->first); + } + } + } + } + + ///
  • Handle session updates when the timer has passed + if (m_timers[WUPDATE_SESSIONS].Passed()) + { + m_timers[WUPDATE_SESSIONS].Reset(); + + UpdateSessions(diff); + } + + ///
  • Handle weather updates when the timer has passed + if (m_timers[WUPDATE_WEATHERS].Passed()) + { + m_timers[WUPDATE_WEATHERS].Reset(); + + ///- Send an update signal to Weather objects + WeatherMap::iterator itr, next; + for (itr = m_weathers.begin(); itr != m_weathers.end(); itr = next) + { + next = itr; + ++next; + + ///- and remove Weather objects for zones with no player + //As interval > WorldTick + if(!itr->second->Update(m_timers[WUPDATE_WEATHERS].GetInterval())) + { + delete itr->second; + m_weathers.erase(itr); + } + } + } + ///
  • Update uptime table + if (m_timers[WUPDATE_UPTIME].Passed()) + { + uint32 tmpDiff = (m_gameTime - m_startTime); + uint32 maxClientsNum = sWorld.GetMaxActiveSessionCount(); + + m_timers[WUPDATE_UPTIME].Reset(); + WorldDatabase.PExecute("UPDATE uptime SET uptime = %d, maxplayers = %d WHERE starttime = " I64FMTD, tmpDiff, maxClientsNum, uint64(m_startTime)); + } + + ///
  • Handle all other objects + if (m_timers[WUPDATE_OBJECTS].Passed()) + { + m_timers[WUPDATE_OBJECTS].Reset(); + ///- Update objects when the timer has passed (maps, transport, creatures,...) + MapManager::Instance().Update(diff); // As interval = 0 + + ///- Process necessary scripts + if (!m_scriptSchedule.empty()) + ScriptsProcess(); + + sBattleGroundMgr.Update(diff); + } + + // execute callbacks from sql queries that were queued recently + UpdateResultQueue(); + + ///- Erase corpses once every 20 minutes + if (m_timers[WUPDATE_CORPSES].Passed()) + { + m_timers[WUPDATE_CORPSES].Reset(); + + CorpsesErase(); + } + + ///- Process Game events when necessary + if (m_timers[WUPDATE_EVENTS].Passed()) + { + m_timers[WUPDATE_EVENTS].Reset(); // to give time for Update() to be processed + uint32 nextGameEvent = gameeventmgr.Update(); + m_timers[WUPDATE_EVENTS].SetInterval(nextGameEvent); + m_timers[WUPDATE_EVENTS].Reset(); + } + + ///
+ ///- Move all creatures with "delayed move" and remove and delete all objects with "delayed remove" + MapManager::Instance().DoDelayedMovesAndRemoves(); + + // update the instance reset times + sInstanceSaveManager.Update(); + + // And last, but not least handle the issued cli commands + ProcessCliCommands(); +} + +/// Put scripts in the execution queue +void World::ScriptsStart(ScriptMapMap const& scripts, uint32 id, Object* source, Object* target) +{ + ///- Find the script map + ScriptMapMap::const_iterator s = scripts.find(id); + if (s == scripts.end()) + return; + + // prepare static data + uint64 sourceGUID = source->GetGUID(); + uint64 targetGUID = target ? target->GetGUID() : (uint64)0; + uint64 ownerGUID = (source->GetTypeId()==TYPEID_ITEM) ? ((Item*)source)->GetOwnerGUID() : (uint64)0; + + ///- Schedule script execution for all scripts in the script map + ScriptMap const *s2 = &(s->second); + bool immedScript = false; + for (ScriptMap::const_iterator iter = s2->begin(); iter != s2->end(); ++iter) + { + ScriptAction sa; + sa.sourceGUID = sourceGUID; + sa.targetGUID = targetGUID; + sa.ownerGUID = ownerGUID; + + sa.script = &iter->second; + m_scriptSchedule.insert(std::pair(m_gameTime + iter->first, sa)); + if (iter->first == 0) + immedScript = true; + } + ///- If one of the effects should be immediate, launch the script execution + if (immedScript) + ScriptsProcess(); +} + +void World::ScriptCommandStart(ScriptInfo const& script, uint32 delay, Object* source, Object* target) +{ + // NOTE: script record _must_ exist until command executed + + // prepare static data + uint64 sourceGUID = source->GetGUID(); + uint64 targetGUID = target ? target->GetGUID() : (uint64)0; + uint64 ownerGUID = (source->GetTypeId()==TYPEID_ITEM) ? ((Item*)source)->GetOwnerGUID() : (uint64)0; + + ScriptAction sa; + sa.sourceGUID = sourceGUID; + sa.targetGUID = targetGUID; + sa.ownerGUID = ownerGUID; + + sa.script = &script; + m_scriptSchedule.insert(std::pair(m_gameTime + delay, sa)); + + ///- If effects should be immediate, launch the script execution + if(delay == 0) + ScriptsProcess(); +} + +/// Process queued scripts +void World::ScriptsProcess() +{ + if (m_scriptSchedule.empty()) + return; + + ///- Process overdue queued scripts + std::multimap::iterator iter = m_scriptSchedule.begin(); + // ok as multimap is a *sorted* associative container + while (!m_scriptSchedule.empty() && (iter->first <= m_gameTime)) + { + ScriptAction const& step = iter->second; + + Object* source = NULL; + + if(step.sourceGUID) + { + switch(GUID_HIPART(step.sourceGUID)) + { + case HIGHGUID_ITEM: + // case HIGHGUID_CONTAINER: ==HIGHGUID_ITEM + { + Player* player = HashMapHolder::Find(step.ownerGUID); + if(player) + source = player->GetItemByGuid(step.sourceGUID); + break; + } + case HIGHGUID_UNIT: + source = HashMapHolder::Find(step.sourceGUID); + break; + case HIGHGUID_PET: + source = HashMapHolder::Find(step.sourceGUID); + break; + case HIGHGUID_PLAYER: + source = HashMapHolder::Find(step.sourceGUID); + break; + case HIGHGUID_GAMEOBJECT: + source = HashMapHolder::Find(step.sourceGUID); + break; + case HIGHGUID_CORPSE: + source = HashMapHolder::Find(step.sourceGUID); + break; + default: + sLog.outError("*_script source with unsupported high guid value %u",GUID_HIPART(step.sourceGUID)); + break; + } + } + + Object* target = NULL; + + if(step.targetGUID) + { + switch(GUID_HIPART(step.targetGUID)) + { + case HIGHGUID_UNIT: + target = HashMapHolder::Find(step.targetGUID); + break; + case HIGHGUID_PET: + target = HashMapHolder::Find(step.targetGUID); + break; + case HIGHGUID_PLAYER: // empty GUID case also + target = HashMapHolder::Find(step.targetGUID); + break; + case HIGHGUID_GAMEOBJECT: + target = HashMapHolder::Find(step.targetGUID); + break; + case HIGHGUID_CORPSE: + target = HashMapHolder::Find(step.targetGUID); + break; + default: + sLog.outError("*_script source with unsupported high guid value %u",GUID_HIPART(step.targetGUID)); + break; + } + } + + switch (step.script->command) + { + case SCRIPT_COMMAND_TALK: + { + if(!source) + { + sLog.outError("SCRIPT_COMMAND_TALK call for NULL creature."); + break; + } + + if(source->GetTypeId()!=TYPEID_UNIT) + { + sLog.outError("SCRIPT_COMMAND_TALK call for non-creature (TypeId: %u), skipping.",source->GetTypeId()); + break; + } + if(step.script->datalong > 3) + { + sLog.outError("SCRIPT_COMMAND_TALK invalid chat type (%u), skipping.",step.script->datalong); + break; + } + + uint64 unit_target = target ? target->GetGUID() : 0; + + //datalong 0=normal say, 1=whisper, 2=yell, 3=emote text + switch(step.script->datalong) + { + case 0: // Say + ((Creature *)source)->Say(step.script->datatext.c_str(), LANG_UNIVERSAL, unit_target); + break; + case 1: // Whisper + if(!unit_target) + { + sLog.outError("SCRIPT_COMMAND_TALK attempt to whisper (%u) NULL, skipping.",step.script->datalong); + break; + } + ((Creature *)source)->Whisper(step.script->datatext.c_str(),unit_target); + break; + case 2: // Yell + ((Creature *)source)->Yell(step.script->datatext.c_str(), LANG_UNIVERSAL, unit_target); + break; + case 3: // Emote text + ((Creature *)source)->TextEmote(step.script->datatext.c_str(), unit_target); + break; + default: + break; // must be already checked at load + } + break; + } + + case SCRIPT_COMMAND_EMOTE: + if(!source) + { + sLog.outError("SCRIPT_COMMAND_EMOTE call for NULL creature."); + break; + } + + if(source->GetTypeId()!=TYPEID_UNIT) + { + sLog.outError("SCRIPT_COMMAND_EMOTE call for non-creature (TypeId: %u), skipping.",source->GetTypeId()); + break; + } + + ((Creature *)source)->HandleEmoteCommand(step.script->datalong); + break; + case SCRIPT_COMMAND_FIELD_SET: + if(!source) + { + sLog.outError("SCRIPT_COMMAND_FIELD_SET call for NULL object."); + break; + } + if(step.script->datalong <= OBJECT_FIELD_ENTRY || step.script->datalong >= source->GetValuesCount()) + { + sLog.outError("SCRIPT_COMMAND_FIELD_SET call for wrong field %u (max count: %u) in object (TypeId: %u).", + step.script->datalong,source->GetValuesCount(),source->GetTypeId()); + break; + } + + source->SetUInt32Value(step.script->datalong, step.script->datalong2); + break; + case SCRIPT_COMMAND_MOVE_TO: + if(!source) + { + sLog.outError("SCRIPT_COMMAND_MOVE_TO call for NULL creature."); + break; + } + + if(source->GetTypeId()!=TYPEID_UNIT) + { + sLog.outError("SCRIPT_COMMAND_MOVE_TO call for non-creature (TypeId: %u), skipping.",source->GetTypeId()); + break; + } + ((Unit *)source)->SendMonsterMoveWithSpeed(step.script->x, step.script->y, step.script->z, ((Unit *)source)->GetUnitMovementFlags(), step.script->datalong2 ); + MapManager::Instance().GetMap(((Unit *)source)->GetMapId(), ((Unit *)source))->CreatureRelocation(((Creature *)source), step.script->x, step.script->y, step.script->z, 0); + break; + case SCRIPT_COMMAND_FLAG_SET: + if(!source) + { + sLog.outError("SCRIPT_COMMAND_FLAG_SET call for NULL object."); + break; + } + if(step.script->datalong <= OBJECT_FIELD_ENTRY || step.script->datalong >= source->GetValuesCount()) + { + sLog.outError("SCRIPT_COMMAND_FLAG_SET call for wrong field %u (max count: %u) in object (TypeId: %u).", + step.script->datalong,source->GetValuesCount(),source->GetTypeId()); + break; + } + + source->SetFlag(step.script->datalong, step.script->datalong2); + break; + case SCRIPT_COMMAND_FLAG_REMOVE: + if(!source) + { + sLog.outError("SCRIPT_COMMAND_FLAG_REMOVE call for NULL object."); + break; + } + if(step.script->datalong <= OBJECT_FIELD_ENTRY || step.script->datalong >= source->GetValuesCount()) + { + sLog.outError("SCRIPT_COMMAND_FLAG_REMOVE call for wrong field %u (max count: %u) in object (TypeId: %u).", + step.script->datalong,source->GetValuesCount(),source->GetTypeId()); + break; + } + + source->RemoveFlag(step.script->datalong, step.script->datalong2); + break; + + case SCRIPT_COMMAND_TELEPORT_TO: + { + // accept player in any one from target/source arg + if (!target && !source) + { + sLog.outError("SCRIPT_COMMAND_TELEPORT_TO call for NULL object."); + break; + } + + // must be only Player + if((!target || target->GetTypeId() != TYPEID_PLAYER) && (!source || source->GetTypeId() != TYPEID_PLAYER)) + { + sLog.outError("SCRIPT_COMMAND_TELEPORT_TO call for non-player (TypeIdSource: %u)(TypeIdTarget: %u), skipping.", source ? source->GetTypeId() : 0, target ? target->GetTypeId() : 0); + break; + } + + Player* pSource = target && target->GetTypeId() == TYPEID_PLAYER ? (Player*)target : (Player*)source; + + pSource->TeleportTo(step.script->datalong, step.script->x, step.script->y, step.script->z, step.script->o); + break; + } + + case SCRIPT_COMMAND_TEMP_SUMMON_CREATURE: + { + if(!step.script->datalong) // creature not specified + { + sLog.outError("SCRIPT_COMMAND_TEMP_SUMMON_CREATURE call for NULL creature."); + break; + } + + if(!source) + { + sLog.outError("SCRIPT_COMMAND_TEMP_SUMMON_CREATURE call for NULL world object."); + break; + } + + WorldObject* summoner = dynamic_cast(source); + + if(!summoner) + { + sLog.outError("SCRIPT_COMMAND_TEMP_SUMMON_CREATURE call for non-WorldObject (TypeId: %u), skipping.",source->GetTypeId()); + break; + } + + float x = step.script->x; + float y = step.script->y; + float z = step.script->z; + float o = step.script->o; + + Creature* pCreature = summoner->SummonCreature(step.script->datalong, x, y, z, o,TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,step.script->datalong2); + if (!pCreature) + { + sLog.outError("SCRIPT_COMMAND_TEMP_SUMMON failed for creature (entry: %u).",step.script->datalong); + break; + } + + break; + } + + case SCRIPT_COMMAND_RESPAWN_GAMEOBJECT: + { + if(!step.script->datalong) // gameobject not specified + { + sLog.outError("SCRIPT_COMMAND_RESPAWN_GAMEOBJECT call for NULL gameobject."); + break; + } + + if(!source) + { + sLog.outError("SCRIPT_COMMAND_RESPAWN_GAMEOBJECT call for NULL world object."); + break; + } + + WorldObject* summoner = dynamic_cast(source); + + if(!summoner) + { + sLog.outError("SCRIPT_COMMAND_RESPAWN_GAMEOBJECT call for non-WorldObject (TypeId: %u), skipping.",source->GetTypeId()); + break; + } + + GameObject *go = NULL; + int32 time_to_despawn = step.script->datalong2<5 ? 5 : (int32)step.script->datalong2; + + CellPair p(MaNGOS::ComputeCellPair(summoner->GetPositionX(), summoner->GetPositionY())); + Cell cell(p); + cell.data.Part.reserved = ALL_DISTRICT; + + MaNGOS::GameObjectWithDbGUIDCheck go_check(*summoner,step.script->datalong); + MaNGOS::GameObjectSearcher checker(go,go_check); + + TypeContainerVisitor, GridTypeMapContainer > object_checker(checker); + CellLock cell_lock(cell, p); + cell_lock->Visit(cell_lock, object_checker, *MapManager::Instance().GetMap(summoner->GetMapId(), summoner)); + + if ( !go ) + { + sLog.outError("SCRIPT_COMMAND_RESPAWN_GAMEOBJECT failed for gameobject(guid: %u).", step.script->datalong); + break; + } + + if( go->GetGoType()==GAMEOBJECT_TYPE_FISHINGNODE || + go->GetGoType()==GAMEOBJECT_TYPE_FISHINGNODE || + go->GetGoType()==GAMEOBJECT_TYPE_DOOR || + go->GetGoType()==GAMEOBJECT_TYPE_BUTTON || + go->GetGoType()==GAMEOBJECT_TYPE_TRAP ) + { + sLog.outError("SCRIPT_COMMAND_RESPAWN_GAMEOBJECT can not be used with gameobject of type %u (guid: %u).", uint32(go->GetGoType()), step.script->datalong); + break; + } + + if( go->isSpawned() ) + break; //gameobject already spawned + + go->SetLootState(GO_READY); + go->SetRespawnTime(time_to_despawn); //despawn object in ? seconds + + MapManager::Instance().GetMap(go->GetMapId(), go)->Add(go); + break; + } + case SCRIPT_COMMAND_OPEN_DOOR: + { + if(!step.script->datalong) // door not specified + { + sLog.outError("SCRIPT_COMMAND_OPEN_DOOR call for NULL door."); + break; + } + + if(!source) + { + sLog.outError("SCRIPT_COMMAND_OPEN_DOOR call for NULL unit."); + break; + } + + if(!source->isType(TYPEMASK_UNIT)) // must be any Unit (creature or player) + { + sLog.outError("SCRIPT_COMMAND_OPEN_DOOR call for non-unit (TypeId: %u), skipping.",source->GetTypeId()); + break; + } + + Unit* caster = (Unit*)source; + + GameObject *door = NULL; + int32 time_to_close = step.script->datalong2 < 15 ? 15 : (int32)step.script->datalong2; + + CellPair p(MaNGOS::ComputeCellPair(caster->GetPositionX(), caster->GetPositionY())); + Cell cell(p); + cell.data.Part.reserved = ALL_DISTRICT; + + MaNGOS::GameObjectWithDbGUIDCheck go_check(*caster,step.script->datalong); + MaNGOS::GameObjectSearcher checker(door,go_check); + + TypeContainerVisitor, GridTypeMapContainer > object_checker(checker); + CellLock cell_lock(cell, p); + cell_lock->Visit(cell_lock, object_checker, *MapManager::Instance().GetMap(caster->GetMapId(), (Unit*)source)); + + if ( !door ) + { + sLog.outError("SCRIPT_COMMAND_OPEN_DOOR failed for gameobject(guid: %u).", step.script->datalong); + break; + } + if ( door->GetGoType() != GAMEOBJECT_TYPE_DOOR ) + { + sLog.outError("SCRIPT_COMMAND_OPEN_DOOR failed for non-door(GoType: %u).", door->GetGoType()); + break; + } + + if( !door->GetGoState() ) + break; //door already open + + door->UseDoorOrButton(time_to_close); + + if(target && target->isType(TYPEMASK_GAMEOBJECT) && ((GameObject*)target)->GetGoType()==GAMEOBJECT_TYPE_BUTTON) + ((GameObject*)target)->UseDoorOrButton(time_to_close); + break; + } + case SCRIPT_COMMAND_CLOSE_DOOR: + { + if(!step.script->datalong) // guid for door not specified + { + sLog.outError("SCRIPT_COMMAND_CLOSE_DOOR call for NULL door."); + break; + } + + if(!source) + { + sLog.outError("SCRIPT_COMMAND_CLOSE_DOOR call for NULL unit."); + break; + } + + if(!source->isType(TYPEMASK_UNIT)) // must be any Unit (creature or player) + { + sLog.outError("SCRIPT_COMMAND_CLOSE_DOOR call for non-unit (TypeId: %u), skipping.",source->GetTypeId()); + break; + } + + Unit* caster = (Unit*)source; + + GameObject *door = NULL; + int32 time_to_open = step.script->datalong2 < 15 ? 15 : (int32)step.script->datalong2; + + CellPair p(MaNGOS::ComputeCellPair(caster->GetPositionX(), caster->GetPositionY())); + Cell cell(p); + cell.data.Part.reserved = ALL_DISTRICT; + + MaNGOS::GameObjectWithDbGUIDCheck go_check(*caster,step.script->datalong); + MaNGOS::GameObjectSearcher checker(door,go_check); + + TypeContainerVisitor, GridTypeMapContainer > object_checker(checker); + CellLock cell_lock(cell, p); + cell_lock->Visit(cell_lock, object_checker, *MapManager::Instance().GetMap(caster->GetMapId(), (Unit*)source)); + + if ( !door ) + { + sLog.outError("SCRIPT_COMMAND_CLOSE_DOOR failed for gameobject(guid: %u).", step.script->datalong); + break; + } + if ( door->GetGoType() != GAMEOBJECT_TYPE_DOOR ) + { + sLog.outError("SCRIPT_COMMAND_CLOSE_DOOR failed for non-door(GoType: %u).", door->GetGoType()); + break; + } + + if( door->GetGoState() ) + break; //door already closed + + door->UseDoorOrButton(time_to_open); + + if(target && target->isType(TYPEMASK_GAMEOBJECT) && ((GameObject*)target)->GetGoType()==GAMEOBJECT_TYPE_BUTTON) + ((GameObject*)target)->UseDoorOrButton(time_to_open); + + break; + } + case SCRIPT_COMMAND_QUEST_EXPLORED: + { + if(!source) + { + sLog.outError("SCRIPT_COMMAND_QUEST_EXPLORED call for NULL source."); + break; + } + + if(!target) + { + sLog.outError("SCRIPT_COMMAND_QUEST_EXPLORED call for NULL target."); + break; + } + + // when script called for item spell casting then target == (unit or GO) and source is player + WorldObject* worldObject; + Player* player; + + if(target->GetTypeId()==TYPEID_PLAYER) + { + if(source->GetTypeId()!=TYPEID_UNIT && source->GetTypeId()!=TYPEID_GAMEOBJECT) + { + sLog.outError("SCRIPT_COMMAND_QUEST_EXPLORED call for non-creature and non-gameobject (TypeId: %u), skipping.",source->GetTypeId()); + break; + } + + worldObject = (WorldObject*)source; + player = (Player*)target; + } + else + { + if(target->GetTypeId()!=TYPEID_UNIT && target->GetTypeId()!=TYPEID_GAMEOBJECT) + { + sLog.outError("SCRIPT_COMMAND_QUEST_EXPLORED call for non-creature and non-gameobject (TypeId: %u), skipping.",target->GetTypeId()); + break; + } + + if(source->GetTypeId()!=TYPEID_PLAYER) + { + sLog.outError("SCRIPT_COMMAND_QUEST_EXPLORED call for non-player(TypeId: %u), skipping.",source->GetTypeId()); + break; + } + + worldObject = (WorldObject*)target; + player = (Player*)source; + } + + // quest id and flags checked at script loading + if( (worldObject->GetTypeId()!=TYPEID_UNIT || ((Unit*)worldObject)->isAlive()) && + (step.script->datalong2==0 || worldObject->IsWithinDistInMap(player,float(step.script->datalong2))) ) + player->AreaExploredOrEventHappens(step.script->datalong); + else + player->FailQuest(step.script->datalong); + + break; + } + + case SCRIPT_COMMAND_ACTIVATE_OBJECT: + { + if(!source) + { + sLog.outError("SCRIPT_COMMAND_ACTIVATE_OBJECT must have source caster."); + break; + } + + if(!source->isType(TYPEMASK_UNIT)) + { + sLog.outError("SCRIPT_COMMAND_ACTIVATE_OBJECT source caster isn't unit (TypeId: %u), skipping.",source->GetTypeId()); + break; + } + + if(!target) + { + sLog.outError("SCRIPT_COMMAND_ACTIVATE_OBJECT call for NULL gameobject."); + break; + } + + if(target->GetTypeId()!=TYPEID_GAMEOBJECT) + { + sLog.outError("SCRIPT_COMMAND_ACTIVATE_OBJECT call for non-gameobject (TypeId: %u), skipping.",target->GetTypeId()); + break; + } + + Unit* caster = (Unit*)source; + + GameObject *go = (GameObject*)target; + + go->Use(caster); + break; + } + + case SCRIPT_COMMAND_REMOVE_AURA: + { + Object* cmdTarget = step.script->datalong2 ? source : target; + + if(!cmdTarget) + { + sLog.outError("SCRIPT_COMMAND_REMOVE_AURA call for NULL %s.",step.script->datalong2 ? "source" : "target"); + break; + } + + if(!cmdTarget->isType(TYPEMASK_UNIT)) + { + sLog.outError("SCRIPT_COMMAND_REMOVE_AURA %s isn't unit (TypeId: %u), skipping.",step.script->datalong2 ? "source" : "target",cmdTarget->GetTypeId()); + break; + } + + ((Unit*)cmdTarget)->RemoveAurasDueToSpell(step.script->datalong); + break; + } + + case SCRIPT_COMMAND_CAST_SPELL: + { + if(!source) + { + sLog.outError("SCRIPT_COMMAND_CAST_SPELL must have source caster."); + break; + } + + if(!source->isType(TYPEMASK_UNIT)) + { + sLog.outError("SCRIPT_COMMAND_CAST_SPELL source caster isn't unit (TypeId: %u), skipping.",source->GetTypeId()); + break; + } + + Object* cmdTarget = step.script->datalong2 ? source : target; + + if(!cmdTarget) + { + sLog.outError("SCRIPT_COMMAND_CAST_SPELL call for NULL %s.",step.script->datalong2 ? "source" : "target"); + break; + } + + if(!cmdTarget->isType(TYPEMASK_UNIT)) + { + sLog.outError("SCRIPT_COMMAND_CAST_SPELL %s isn't unit (TypeId: %u), skipping.",step.script->datalong2 ? "source" : "target",cmdTarget->GetTypeId()); + break; + } + + Unit* spellTarget = (Unit*)cmdTarget; + + //TODO: when GO cast implemented, code below must be updated accordingly to also allow GO spell cast + ((Unit*)source)->CastSpell(spellTarget,step.script->datalong,false); + + break; + } + + default: + sLog.outError("Unknown script command %u called.",step.script->command); + break; + } + + m_scriptSchedule.erase(iter); + + iter = m_scriptSchedule.begin(); + } + return; +} + +/// Send a packet to all players (except self if mentioned) +void World::SendGlobalMessage(WorldPacket *packet, WorldSession *self, uint32 team) +{ + SessionMap::iterator itr; + for (itr = m_sessions.begin(); itr != m_sessions.end(); itr++) + { + if (itr->second && + itr->second->GetPlayer() && + itr->second->GetPlayer()->IsInWorld() && + itr->second != self && + (team == 0 || itr->second->GetPlayer()->GetTeam() == team) ) + { + itr->second->SendPacket(packet); + } + } +} + +/// Send a System Message to all players (except self if mentioned) +void World::SendWorldText(int32 string_id, ...) +{ + std::vector > data_cache; // 0 = default, i => i-1 locale index + + for(SessionMap::iterator itr = m_sessions.begin(); itr != m_sessions.end(); ++itr) + { + if(!itr->second || !itr->second->GetPlayer() || !itr->second->GetPlayer()->IsInWorld() ) + continue; + + uint32 loc_idx = itr->second->GetSessionDbLocaleIndex(); + uint32 cache_idx = loc_idx+1; + + std::vector* data_list; + + // create if not cached yet + if(data_cache.size() < cache_idx+1 || data_cache[cache_idx].empty()) + { + if(data_cache.size() < cache_idx+1) + data_cache.resize(cache_idx+1); + + data_list = &data_cache[cache_idx]; + + char const* text = objmgr.GetMangosString(string_id,loc_idx); + + char buf[1000]; + + va_list argptr; + va_start( argptr, string_id ); + vsnprintf( buf,1000, text, argptr ); + va_end( argptr ); + + char* pos = &buf[0]; + + while(char* line = ChatHandler::LineFromMessage(pos)) + { + WorldPacket* data = new WorldPacket(); + ChatHandler::FillMessageData(data, NULL, CHAT_MSG_SYSTEM, LANG_UNIVERSAL, NULL, 0, line, NULL); + data_list->push_back(data); + } + } + else + data_list = &data_cache[cache_idx]; + + for(int i = 0; i < data_list->size(); ++i) + itr->second->SendPacket((*data_list)[i]); + } + + // free memory + for(int i = 0; i < data_cache.size(); ++i) + for(int j = 0; j < data_cache[i].size(); ++j) + delete data_cache[i][j]; +} + +/// Send a packet to all players (or players selected team) in the zone (except self if mentioned) +void World::SendZoneMessage(uint32 zone, WorldPacket *packet, WorldSession *self, uint32 team) +{ + SessionMap::iterator itr; + for (itr = m_sessions.begin(); itr != m_sessions.end(); itr++) + { + if (itr->second && + itr->second->GetPlayer() && + itr->second->GetPlayer()->IsInWorld() && + itr->second->GetPlayer()->GetZoneId() == zone && + itr->second != self && + (team == 0 || itr->second->GetPlayer()->GetTeam() == team) ) + { + itr->second->SendPacket(packet); + } + } +} + +/// Send a System Message to all players in the zone (except self if mentioned) +void World::SendZoneText(uint32 zone, const char* text, WorldSession *self, uint32 team) +{ + WorldPacket data; + ChatHandler::FillMessageData(&data, NULL, CHAT_MSG_SYSTEM, LANG_UNIVERSAL, NULL, 0, text, NULL); + SendZoneMessage(zone, &data, self,team); +} + +/// Kick (and save) all players +void World::KickAll() +{ + // session not removed at kick and will removed in next update tick + for (SessionMap::iterator itr = m_sessions.begin(); itr != m_sessions.end(); ++itr) + itr->second->KickPlayer(); +} + +/// Kick (and save) all players with security level less `sec` +void World::KickAllLess(AccountTypes sec) +{ + // session not removed at kick and will removed in next update tick + for (SessionMap::iterator itr = m_sessions.begin(); itr != m_sessions.end(); ++itr) + if(itr->second->GetSecurity() < sec) + itr->second->KickPlayer(); +} + +/// Kick all queued players +void World::KickAllQueued() +{ + // session not removed at kick and will removed in next update tick + //TODO here +// for (Queue::iterator itr = m_QueuedPlayer.begin(); itr != m_QueuedPlayer.end(); ++itr) +// if(WorldSession* session = (*itr)->GetSession()) +// session->KickPlayer(); + + m_QueuedPlayer.empty(); +} + +/// Kick (and save) the designated player +bool World::KickPlayer(std::string playerName) +{ + SessionMap::iterator itr; + + // session not removed at kick and will removed in next update tick + for (itr = m_sessions.begin(); itr != m_sessions.end(); ++itr) + { + if(!itr->second) + continue; + Player *player = itr->second->GetPlayer(); + if(!player) + continue; + if( player->IsInWorld() ) + { + if (playerName == player->GetName()) + { + itr->second->KickPlayer(); + return true; + } + } + } + return false; +} + +/// Ban an account or ban an IP address, duration will be parsed using TimeStringToSecs if it is positive, otherwise permban +uint8 World::BanAccount(std::string type, std::string nameOrIP, std::string duration, std::string reason, std::string author) +{ + loginDatabase.escape_string(nameOrIP); + loginDatabase.escape_string(reason); + std::string safe_author=author; + loginDatabase.escape_string(safe_author); + + if(type != "ip" && !normalizePlayerName(nameOrIP)) + return BAN_NOTFOUND; // Nobody to ban + + uint32 duration_secs = TimeStringToSecs(duration); + QueryResult *resultAccounts = NULL; //used for kicking + + ///- Update the database with ban information + + if(type=="ip") + { + //No SQL injection as strings are escaped + resultAccounts = loginDatabase.PQuery("SELECT id FROM account WHERE last_ip = '%s'",nameOrIP.c_str()); + loginDatabase.PExecute("INSERT INTO ip_banned VALUES ('%s',UNIX_TIMESTAMP(),UNIX_TIMESTAMP()+%u,'%s','%s')",nameOrIP.c_str(),duration_secs,safe_author.c_str(),reason.c_str()); + } + else if(type=="account") + { + //No SQL injection as string is escaped + resultAccounts = loginDatabase.PQuery("SELECT id FROM account WHERE username = '%s'",nameOrIP.c_str()); + } + else if(type=="character") + { + //No SQL injection as string is escaped + resultAccounts = CharacterDatabase.PQuery("SELECT account FROM characters WHERE name = '%s'",nameOrIP.c_str()); + } + else + return BAN_SYNTAX_ERROR; //Syntax problem + + if(!resultAccounts) + if(type=="ip") + return BAN_SUCCESS; // ip correctly banned but nobody affected (yet) + else + return BAN_NOTFOUND; // Nobody to ban + + ///- Disconnect all affected players (for IP it can be several) + do + { + Field* fieldsAccount = resultAccounts->Fetch(); + uint32 account = fieldsAccount->GetUInt32(); + + if(type != "ip") + //No SQL injection as strings are escaped + loginDatabase.PExecute("INSERT INTO account_banned VALUES ('%u', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()+%u, '%s', '%s', '1')", + account,duration_secs,safe_author.c_str(),reason.c_str()); + + WorldSession* sess = FindSession(account); + if( sess ) + if(std::string(sess->GetPlayerName()) != author) + sess->KickPlayer(); + } + while( resultAccounts->NextRow() ); + + delete resultAccounts; + return BAN_SUCCESS; +} + +/// Remove a ban from an account or IP address +bool World::RemoveBanAccount(std::string type, std::string nameOrIP) +{ + if(type == "ip") + { + loginDatabase.escape_string(nameOrIP); + loginDatabase.PExecute("DELETE FROM ip_banned WHERE ip = '%s'",nameOrIP.c_str()); + } + else + { + uint32 account=0; + if(type == "account") + { + //NO SQL injection as name is escaped + loginDatabase.escape_string(nameOrIP); + QueryResult *resultAccounts = loginDatabase.PQuery("SELECT id FROM account WHERE username = '%s'",nameOrIP.c_str()); + if(!resultAccounts) + return false; + Field* fieldsAccount = resultAccounts->Fetch(); + account = fieldsAccount->GetUInt32(); + + delete resultAccounts; + } + else if(type == "character") + { + if(!normalizePlayerName(nameOrIP)) + return false; + + //NO SQL injection as name is escaped + loginDatabase.escape_string(nameOrIP); + QueryResult *resultAccounts = CharacterDatabase.PQuery("SELECT account FROM characters WHERE name = '%s'",nameOrIP.c_str()); + if(!resultAccounts) + return false; + Field* fieldsAccount = resultAccounts->Fetch(); + account = fieldsAccount->GetUInt32(); + + delete resultAccounts; + } + if(!account) + return false; + //NO SQL injection as account is uint32 + loginDatabase.PExecute("UPDATE account_banned SET active = '0' WHERE id = '%u'",account); + } + return true; +} + +/// Update the game time +void World::_UpdateGameTime() +{ + ///- update the time + time_t thisTime = time(NULL); + uint32 elapsed = uint32(thisTime - m_gameTime); + m_gameTime = thisTime; + + ///- if there is a shutdown timer + if(m_ShutdownTimer > 0 && elapsed > 0) + { + ///- ... and it is overdue, stop the world (set m_stopEvent) + if( m_ShutdownTimer <= elapsed ) + { + if(!(m_ShutdownMask & SHUTDOWN_MASK_IDLE) || GetActiveAndQueuedSessionCount()==0) + m_stopEvent = true; + else + m_ShutdownTimer = 1; // minimum timer value to wait idle state + } + ///- ... else decrease it and if necessary display a shutdown countdown to the users + else + { + m_ShutdownTimer -= elapsed; + + ShutdownMsg(); + } + } +} + +/// Shutdown the server +void World::ShutdownServ(uint32 time, uint32 options) +{ + m_ShutdownMask = options; + + ///- If the shutdown time is 0, set m_stopEvent (except if shutdown is 'idle' with remaining sessions) + if(time==0) + { + if(!(options & SHUTDOWN_MASK_IDLE) || GetActiveAndQueuedSessionCount()==0) + m_stopEvent = true; + else + m_ShutdownTimer = 1; //So that the session count is re-evaluated at next world tick + } + ///- Else set the shutdown timer and warn users + else + { + m_ShutdownTimer = time; + ShutdownMsg(true); + } +} + +/// Display a shutdown message to the user(s) +void World::ShutdownMsg(bool show, Player* player) +{ + // not show messages for idle shutdown mode + if(m_ShutdownMask & SHUTDOWN_MASK_IDLE) + return; + + ///- Display a message every 12 hours, hours, 5 minutes, minute, 5 seconds and finally seconds + if ( show || + (m_ShutdownTimer < 10) || + // < 30 sec; every 5 sec + (m_ShutdownTimer<30 && (m_ShutdownTimer % 5 )==0) || + // < 5 min ; every 1 min + (m_ShutdownTimer<5*MINUTE && (m_ShutdownTimer % MINUTE )==0) || + // < 30 min ; every 5 min + (m_ShutdownTimer<30*MINUTE && (m_ShutdownTimer % (5*MINUTE))==0) || + // < 12 h ; every 1 h + (m_ShutdownTimer<12*HOUR && (m_ShutdownTimer % HOUR )==0) || + // > 12 h ; every 12 h + (m_ShutdownTimer>12*HOUR && (m_ShutdownTimer % (12*HOUR) )==0)) + { + std::string str = secsToTimeString(m_ShutdownTimer); + + uint32 msgid = (m_ShutdownMask & SHUTDOWN_MASK_RESTART) ? SERVER_MSG_RESTART_TIME : SERVER_MSG_SHUTDOWN_TIME; + + SendServerMessage(msgid,str.c_str(),player); + DEBUG_LOG("Server is %s in %s",(m_ShutdownMask & SHUTDOWN_MASK_RESTART ? "restart" : "shuttingdown"),str.c_str()); + } +} + +/// Cancel a planned server shutdown +void World::ShutdownCancel() +{ + if(!m_ShutdownTimer) + return; + + uint32 msgid = (m_ShutdownMask & SHUTDOWN_MASK_RESTART) ? SERVER_MSG_RESTART_CANCELLED : SERVER_MSG_SHUTDOWN_CANCELLED; + + m_ShutdownMask = 0; + m_ShutdownTimer = 0; + SendServerMessage(msgid); + + DEBUG_LOG("Server %s cancelled.",(m_ShutdownMask & SHUTDOWN_MASK_RESTART ? "restart" : "shuttingdown")); +} + +/// Send a server message to the user(s) +void World::SendServerMessage(uint32 type, const char *text, Player* player) +{ + WorldPacket data(SMSG_SERVER_MESSAGE, 50); // guess size + data << uint32(type); + if(type <= SERVER_MSG_STRING) + data << text; + + if(player) + player->GetSession()->SendPacket(&data); + else + SendGlobalMessage( &data ); +} + +void World::UpdateSessions( time_t diff ) +{ + while(!addSessQueue.empty()) + { + WorldSession* sess = addSessQueue.next (); + AddSession_ (sess); + } + + ///- Delete kicked sessions at add new session + for (std::set::iterator itr = m_kicked_sessions.begin(); itr != m_kicked_sessions.end(); ++itr) + delete *itr; + m_kicked_sessions.clear(); + + ///- Then send an update signal to remaining ones + for (SessionMap::iterator itr = m_sessions.begin(), next; itr != m_sessions.end(); itr = next) + { + next = itr; + ++next; + + if(!itr->second) + continue; + + ///- and remove not active sessions from the list + if(!itr->second->Update(diff)) // As interval = 0 + { + delete itr->second; + m_sessions.erase(itr); + } + } +} + +// This handles the issued and queued CLI commands +void World::ProcessCliCommands() +{ + if (cliCmdQueue.empty()) return; + + CliCommandHolder *command; + pPrintf p_zprintf; + while (!cliCmdQueue.empty()) + { + sLog.outDebug("CLI command under processing..."); + command = cliCmdQueue.next(); + command->Execute(); + p_zprintf=command->GetOutputMethod(); + delete command; + } + // print the console message here so it looks right + p_zprintf("mangos>"); +} + +void World::InitResultQueue() +{ + m_resultQueue = new SqlResultQueue; + CharacterDatabase.SetResultQueue(m_resultQueue); +} + +void World::UpdateResultQueue() +{ + m_resultQueue->Update(); +} + +void World::UpdateRealmCharCount(uint32 accountId) +{ + CharacterDatabase.AsyncPQuery(this, &World::_UpdateRealmCharCount, accountId, + "SELECT COUNT(guid) FROM characters WHERE account = '%u'", accountId); +} + +void World::_UpdateRealmCharCount(QueryResult *resultCharCount, uint32 accountId) +{ + if (resultCharCount) + { + Field *fields = resultCharCount->Fetch(); + uint32 charCount = fields[0].GetUInt32(); + delete resultCharCount; + loginDatabase.PExecute("DELETE FROM realmcharacters WHERE acctid= '%d' AND realmid = '%d'", accountId, realmID); + loginDatabase.PExecute("INSERT INTO realmcharacters (numchars, acctid, realmid) VALUES (%u, %u, %u)", charCount, accountId, realmID); + } +} + +void World::InitDailyQuestResetTime() +{ + time_t mostRecentQuestTime; + + QueryResult* result = CharacterDatabase.Query("SELECT MAX(time) FROM character_queststatus_daily"); + if(result) + { + Field *fields = result->Fetch(); + + mostRecentQuestTime = (time_t)fields[0].GetUInt64(); + delete result; + } + else + mostRecentQuestTime = 0; + + // client built-in time for reset is 6:00 AM + // FIX ME: client not show day start time + time_t curTime = time(NULL); + tm localTm = *localtime(&curTime); + localTm.tm_hour = 6; + localTm.tm_min = 0; + localTm.tm_sec = 0; + + // current day reset time + time_t curDayResetTime = mktime(&localTm); + + // last reset time before current moment + time_t resetTime = (curTime < curDayResetTime) ? curDayResetTime - DAY : curDayResetTime; + + // need reset (if we have quest time before last reset time (not processed by some reason) + if(mostRecentQuestTime && mostRecentQuestTime <= resetTime) + m_NextDailyQuestReset = mostRecentQuestTime; + else + { + // plan next reset time + m_NextDailyQuestReset = (curTime >= curDayResetTime) ? curDayResetTime + DAY : curDayResetTime; + } +} + +void World::ResetDailyQuests() +{ + sLog.outDetail("Daily quests reset for all characters."); + CharacterDatabase.Execute("DELETE FROM character_queststatus_daily"); + for(SessionMap::iterator itr = m_sessions.begin(); itr != m_sessions.end(); ++itr) + if(itr->second->GetPlayer()) + itr->second->GetPlayer()->ResetDailyQuestStatus(); +} + +void World::SetPlayerLimit( int32 limit, bool needUpdate ) +{ + if(limit < -SEC_ADMINISTRATOR) + limit = -SEC_ADMINISTRATOR; + + // lock update need + bool db_update_need = needUpdate || (limit < 0) != (m_playerLimit < 0) || (limit < 0 && m_playerLimit < 0 && limit != m_playerLimit); + + m_playerLimit = limit; + + if(db_update_need) + loginDatabase.PExecute("UPDATE realmlist SET allowedSecurityLevel = '%u' WHERE id = '%d'",uint8(GetPlayerSecurityLimit()),realmID); +} + +void World::UpdateMaxSessionCounters() +{ + m_maxActiveSessionCount = std::max(m_maxActiveSessionCount,uint32(m_sessions.size()-m_QueuedPlayer.size())); + m_maxQueuedSessionCount = std::max(m_maxQueuedSessionCount,uint32(m_QueuedPlayer.size())); +} diff --git a/src/game/World.h b/src/game/World.h index 56450832ab9..cf5b9e5ba42 100644 --- a/src/game/World.h +++ b/src/game/World.h @@ -362,10 +362,10 @@ class World void SetPlayerLimit(int32 limit, bool needUpdate = false); //player Queue - typedef std::list Queue; - void AddQueuedPlayer(WorldSocket* Socket); - void RemoveQueuedPlayer(WorldSocket* Socket); - int32 GetQueuePos(WorldSocket* Socket); + typedef std::list Queue; + void AddQueuedPlayer(WorldSession*); + void RemoveQueuedPlayer(WorldSession*); + int32 GetQueuePos(WorldSession*); uint32 GetQueueSize() const { return m_QueuedPlayer.size(); } /// \todo Actions on m_allowMovement still to be implemented @@ -525,6 +525,10 @@ class World //Player Queue Queue m_QueuedPlayer; + + //sessions that are added async + void AddSession_(WorldSession* s); + ZThread::LockedQueue addSessQueue; }; extern uint32 realmID; diff --git a/src/game/WorldSession.cpp b/src/game/WorldSession.cpp index eaba12b4a10..9ec9624182c 100644 --- a/src/game/WorldSession.cpp +++ b/src/game/WorldSession.cpp @@ -20,6 +20,7 @@ \ingroup u2w */ +#include "WorldSocket.h" #include "Common.h" #include "Database/DatabaseEnv.h" #include "Log.h" @@ -42,10 +43,15 @@ /// WorldSession constructor WorldSession::WorldSession(uint32 id, WorldSocket *sock, uint32 sec, bool tbc, time_t mute_time, LocaleConstant locale) : LookingForGroup_auto_join(false), LookingForGroup_auto_add(false), m_muteTime(mute_time), -_player(NULL), _socket(sock),_security(sec), _accountId(id), m_isTBC(tbc), +_player(NULL), m_Socket(sock),_security(sec), _accountId(id), m_isTBC(tbc), m_sessionDbcLocale(sWorld.GetAvailableDbcLocale(locale)), m_sessionDbLocaleIndex(objmgr.GetIndexForLocale(locale)), _logoutTime(0), m_playerLoading(false), m_playerLogout(false), m_playerRecentlyLogout(false), m_latency(0) { + if (sock) + { + m_Address = sock->GetRemoteAddress (); + sock->AddReference (); + } } /// WorldSession destructor @@ -56,10 +62,12 @@ WorldSession::~WorldSession() LogoutPlayer(true); /// - If have unclosed socket, close it - if(_socket) - _socket->CloseSocket(); - - _socket = NULL; + if (m_Socket) + { + m_Socket->CloseSocket (); + m_Socket->RemoveReference (); + m_Socket = NULL; + } ///- empty incoming packet queue while(!_recvQueue.empty()) @@ -67,6 +75,8 @@ WorldSession::~WorldSession() WorldPacket *packet = _recvQueue.next(); delete packet; } + + sWorld.RemoveQueuedPlayer(this); } void WorldSession::SizeError(WorldPacket const& packet, uint32 size) const @@ -81,16 +91,10 @@ char const* WorldSession::GetPlayerName() const return GetPlayer() ? GetPlayer()->GetName() : ""; } -/// Set the WorldSocket associated with this session -void WorldSession::SetSocket(WorldSocket *sock) -{ - _socket = sock; -} - /// Send a packet to the client void WorldSession::SendPacket(WorldPacket const* packet) { - if (!_socket) + if (!m_Socket) return; #ifdef MANGOS_DEBUG // Code for network use statistic @@ -124,16 +128,18 @@ void WorldSession::SendPacket(WorldPacket const* packet) sendLastPacketCount = 1; sendLastPacketBytes = packet->wpos(); // wpos is real written size } - #endif // !MANGOS_DEBUG +#endif // !MANGOS_DEBUG - _socket->SendPacket(packet); + if (m_Socket->SendPacket (*packet) == -1) + { + m_Socket->CloseSocket (); + } } /// Add an incoming packet to the queue -void WorldSession::QueuePacket(WorldPacket& packet) +void WorldSession::QueuePacket(WorldPacket* new_packet) { - WorldPacket *pck = new WorldPacket(packet); - _recvQueue.add(pck); + _recvQueue.add(new_packet); } /// Logging helper for unexpected opcodes @@ -148,6 +154,13 @@ void WorldSession::logUnexpectedOpcode(WorldPacket* packet, const char *reason) /// Update the WorldSession (triggered by World update) bool WorldSession::Update(uint32 /*diff*/) { + if (m_Socket) + if (m_Socket->IsClosed ()) + { + m_Socket->RemoveReference (); + m_Socket = NULL; + } + WorldPacket *packet; ///- Retrieve packets from the receive queue and call the appropriate handlers @@ -210,10 +223,10 @@ bool WorldSession::Update(uint32 /*diff*/) ///- If necessary, log the player out time_t currTime = time(NULL); - if (!_socket || (ShouldLogOut(currTime) && !m_playerLoading)) + if (!m_Socket || (ShouldLogOut(currTime) && !m_playerLoading)) LogoutPlayer(true); - if (!_socket) + if (!m_Socket) return false; //Will remove this session from the world session map return true; @@ -343,7 +356,7 @@ void WorldSession::LogoutPlayer(bool Save) // remove player from the group if he is: // a) in group; b) not in raid group; c) logging out normally (not being kicked or disconnected) - if(_player->GetGroup() && !_player->GetGroup()->isRaidGroup() && _socket) + if(_player->GetGroup() && !_player->GetGroup()->isRaidGroup() && m_Socket) _player->RemoveFromGroup(); ///- Remove the player from the world @@ -385,12 +398,10 @@ void WorldSession::LogoutPlayer(bool Save) /// Kick a player out of the World void WorldSession::KickPlayer() { - if(!_socket) - return; - - // player will be logout and session will removed in next update tick - _socket->CloseSocket(); - _socket = NULL; + if (m_Socket) + { + m_Socket->CloseSocket (); + } } /// Cancel channeling handler @@ -461,3 +472,22 @@ void WorldSession::Handle_Depricated( WorldPacket& recvPacket ) LookupOpcodeName(recvPacket.GetOpcode()), recvPacket.GetOpcode()); } + +void WorldSession::SendAuthWaitQue(uint32 position) + { + if(position == 0) + { + WorldPacket packet( SMSG_AUTH_RESPONSE, 1 ); + packet << uint8( AUTH_OK ); + SendPacket(&packet); + } + else + { + WorldPacket packet( SMSG_AUTH_RESPONSE, 5 ); + packet << uint8( AUTH_WAIT_QUEUE ); + packet << uint32 (position); + SendPacket(&packet); + } + } + + diff --git a/src/game/WorldSession.h b/src/game/WorldSession.h index 05df0afe3a8..0f46af26c94 100644 --- a/src/game/WorldSession.h +++ b/src/game/WorldSession.h @@ -88,7 +88,7 @@ class MANGOS_DLL_SPEC WorldSession Player* GetPlayer() const { return _player; } char const* GetPlayerName() const; void SetSecurity(uint32 security) { _security = security; } - void SetSocket(WorldSocket *sock); + std::string& GetRemoteAddress() { return m_Address; } void SetPlayer(Player *plr) { _player = plr; } bool IsTBC() const { return m_isTBC; } @@ -110,8 +110,11 @@ class MANGOS_DLL_SPEC WorldSession void LogoutPlayer(bool Save); void KickPlayer(); - void QueuePacket(WorldPacket& packet); + void QueuePacket(WorldPacket* new_packet); bool Update(uint32 diff); + + /// Handle the authentication waiting queue (to be completed) + void SendAuthWaitQue(uint32 position); //void SendTestCreatureQueryOpcode( uint32 entry, uint64 guid, uint32 testvalue ); void SendNameQueryOpcode(Player* p); @@ -618,7 +621,8 @@ class MANGOS_DLL_SPEC WorldSession // logging helper void logUnexpectedOpcode(WorldPacket *packet, const char * reason); Player *_player; - WorldSocket *_socket; + WorldSocket *m_Socket; + std::string m_Address; uint32 _security; uint32 _accountId; diff --git a/src/game/WorldSocket.cpp b/src/game/WorldSocket.cpp index d52c0962862..cb1c0233b4d 100644 --- a/src/game/WorldSocket.cpp +++ b/src/game/WorldSocket.cpp @@ -1,4 +1,4 @@ -/* +/* * Copyright (C) 2005-2008 MaNGOS * * This program is free software; you can redistribute it and/or modify @@ -16,649 +16,1074 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/** \file - \ingroup u2w -*/ - #include "Common.h" -#include "Log.h" +#include "WorldSocket.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "Util.h" +#include "World.h" +#include "WorldPacket.h" +#include "SharedDefines.h" +#include "ByteBuffer.h" +#include "AddonHandler.h" #include "Opcodes.h" #include "Database/DatabaseEnv.h" #include "Auth/Sha1.h" -#include "WorldPacket.h" -#include "WorldSocket.h" #include "WorldSession.h" -#include "World.h" #include "WorldSocketMgr.h" -#include "Policies/SingletonImp.h" +#include "Log.h" #include "WorldLog.h" -#include "AddonHandler.h" -#include "sockets/Utility.h" -#include "Util.h" -// GCC have alternative #pragma pack(N) syntax and old gcc version not support pack(push,N), also any gcc version not support it at some platform #if defined( __GNUC__ ) #pragma pack(1) #else #pragma pack(push,1) #endif -/// Client Packet Header -struct ClientPktHeader -{ - uint16 size; - uint32 cmd; -}; - -/// Server Packet Header struct ServerPktHeader { - uint16 size; - uint16 cmd; + ACE_UINT16 size; + ACE_UINT16 cmd; +}; + +struct ClientPktHeader +{ + ACE_UINT16 size; + ACE_UINT32 cmd; }; -// GCC have alternative #pragma pack() syntax and old gcc version not support pack(pop), also any gcc version not support it at some platform #if defined( __GNUC__ ) #pragma pack() #else #pragma pack(pop) #endif -#define SOCKET_CHECK_PACKET_SIZE(P,S) if((P).size() < (S)) return SizeError((P),(S)); +// used when testing to alow login without password and encryption +// #define _NETCODE_FAKE_AUTH -/// WorldSocket construction and initialization. -WorldSocket::WorldSocket(ISocketHandler &sh): TcpSocket(sh), _cmd(0), _remaining(0), _session(NULL) +WorldSocket::WorldSocket (void) : +WorldHandler (), +m_Session (0), +m_RecvWPct (0), +m_RecvPct (), +m_Header (sizeof (ClientPktHeader)), +m_OutBuffer (0), +m_OutBufferSize (65536), +m_OutActive (false), +m_Seed (static_cast (rand32 ())), +m_OverSpeedPings (0), +m_LastPingTime (ACE_Time_Value::zero) { - _seed = static_cast(rand32()); - m_LastPingMSTime = 0; // first time it will counted as overspeed maybe, but this is not important - m_OverSpeedPings = 0; - - if (sWorld.getConfig(CONFIG_TCP_NO_DELAY)) - SetTcpNodelay(true); + this->reference_counting_policy ().value (ACE_Event_Handler::Reference_Counting_Policy::ENABLED); } -/// WorldSocket destructor -WorldSocket::~WorldSocket() +WorldSocket::~WorldSocket (void) { - if(_session) - _session->SetSocket(0); + if (m_RecvWPct) + delete m_RecvWPct; - WorldPacket *packet; + if (m_OutBuffer) + m_OutBuffer->release (); - ///- Go through the to-be-sent queue and delete remaining packets - while(!_sendQueue.empty()) + this->closing_ = true; + + this->peer ().close (); + + WorldPacket* pct; + while (m_PacketQueue.dequeue_head (pct) == 0) + delete pct; +} + +bool +WorldSocket::IsClosed (void) const +{ + return this->closing_; +} + +void +WorldSocket::CloseSocket (void) +{ + { + ACE_GUARD (LockType, Guard, m_OutBufferLock); + + if (this->closing_) + return; + + this->closing_ = true; + + this->peer ().close_writer (); + } + + { + ACE_GUARD (LockType, Guard, m_SessionLock); + + m_Session = NULL; + } + +} + +const std::string& +WorldSocket::GetRemoteAddress (void) const +{ + return m_Address; +} + +int +WorldSocket::SendPacket (const WorldPacket& pct) +{ + ACE_GUARD_RETURN (LockType, Guard, m_OutBufferLock, -1); + + if (this->closing_) + return -1; + + // Dump outgoing packet. + if (sWorldLog.LogWorld ()) { - packet = _sendQueue.next(); - delete packet; - } -} + sWorldLog.Log ("SERVER:\nSOCKET: %u\nLENGTH: %u\nOPCODE: %s (0x%.4X)\nDATA:\n", + (uint32) get_handle (), + pct.size (), + LookupOpcodeName (pct.GetOpcode ()), + pct.GetOpcode ()); -/// Copy the packet to the to-be-sent queue -void WorldSocket::SendPacket(WorldPacket const* packet) -{ - WorldPacket *pck = new WorldPacket(*packet); - ASSERT(pck); - _sendQueue.add(pck); -} - -/// On client connection -void WorldSocket::OnAccept() -{ - ///- Add the current socket to the list of sockets to be managed (WorldSocketMgr) - sWorldSocketMgr.AddSocket(this); - Utility::ResolveLocal(); - - ///- Send a AUTH_CHALLENGE packet - WorldPacket packet( SMSG_AUTH_CHALLENGE, 4 ); - packet << _seed; - - SendPacket(&packet); -} - -/// Read the client transmitted data -void WorldSocket::OnRead() -{ - TcpSocket::OnRead(); - - while(1) - { - ///- Read the packet header and decipher it (if needed) - if (!_remaining) + uint32 p = 0; + while (p < pct.size ()) { - if (ibuf.GetLength() < 6) - break; + for (uint32 j = 0; j < 16 && p < pct.size (); j++) + sWorldLog.Log ("%.2X ", const_cast(pct)[p++]); - ClientPktHeader hdr; - - ibuf.Read((char *)&hdr, 6); - _crypt.DecryptRecv((uint8 *)&hdr, 6); - - _remaining = ntohs(hdr.size) - 4; - _cmd = hdr.cmd; + sWorldLog.Log ("\n"); } - if (ibuf.GetLength() < _remaining) - break; + sWorldLog.Log ("\n\n"); + } - ///- Read the remaining of the packet - WorldPacket packet((uint16)_cmd, _remaining); + if (iSendPacket (pct) == -1) + { + WorldPacket* npct; - packet.resize(_remaining); - if(_remaining) ibuf.Read((char*)packet.contents(), _remaining); - _remaining = 0; + ACE_NEW_RETURN (npct, WorldPacket (pct), -1); - ///- If log of world packets is enable, log the incoming packet - if( sWorldLog.LogWorld() ) + // NOTE maybe check of the size of the queue can be good ? + // to make it bounded instead of unbounded + if (m_PacketQueue.enqueue_tail (npct) == -1) { - sWorldLog.Log("CLIENT:\nSOCKET: %u\nLENGTH: %u\nOPCODE: %s (0x%.4X)\nDATA:\n", - (uint32)GetSocket(), - packet.size(), - LookupOpcodeName(packet.GetOpcode()), - packet.GetOpcode()); - - uint32 p = 0; - while (p < packet.size()) - { - for (uint32 j = 0; j < 16 && p < packet.size(); j++) - sWorldLog.Log("%.2X ", packet[p++]); - sWorldLog.Log("\n"); - } - sWorldLog.Log("\n\n"); - } - - ///- If the packet is PING, KEEP_ALIVE or AUTH_SESSION, handle immediately - switch (_cmd) - { - case CMSG_KEEP_ALIVE: - break; // just ignore, network connectivity timeout preventing - case CMSG_PING: - { - _HandlePing(packet); - break; - } - case CMSG_AUTH_SESSION: - { - _HandleAuthSession(packet); - break; - } - default: - { - ///- Else, put it in the world session queue for this user (need to be already authenticated) - if (_session) - _session->QueuePacket(packet); - else - sLog.outDetail("Received out of place packet with cmdid 0x%.4X", _cmd); - break; - } - } - } -} - -/// On socket closing -void WorldSocket::CloseSocket() -{ - ///- Set CloseAndDelete flag for TcpSocket class - SetCloseAndDelete(true); - - ///- Set _session to NULL. Prevent crashes - _session = NULL; -} - -/// On socket deleting -void WorldSocket::OnDelete() -{ - ///- Stop sending remaining data through this socket - if (_session) - { - _session->SetSocket(NULL); - // Session deleted from World session list at socket==0, This is only back reference from socket to session. - _session = NULL; - } - - ///- Remove the socket from the WorldSocketMgr list - sWorldSocketMgr.RemoveSocket(this); - - ///- Removes socket from player queue - sWorld.RemoveQueuedPlayer(this); -} - -/// Handle the client authentication packet -void WorldSocket::_HandleAuthSession(WorldPacket& recvPacket) -{ - uint8 digest[20]; - uint32 clientSeed; - uint32 unk2; - uint32 BuiltNumberClient; - uint32 id, security; - bool tbc = false; - std::string account; - Sha1Hash sha1; - BigNumber v, s, g, N, x, I; - WorldPacket packet, SendAddonPacked; - - BigNumber K; - - SOCKET_CHECK_PACKET_SIZE(recvPacket,4+4+1+4+20); - - ///- Read the content of the packet - recvPacket >> BuiltNumberClient; // for now no use - recvPacket >> unk2; - recvPacket >> account; - - // recheck size - SOCKET_CHECK_PACKET_SIZE(recvPacket,4+4+(account.size()+1)+4+20); - - recvPacket >> clientSeed; - recvPacket.read(digest, 20); - - sLog.outDebug("Auth: client %u, unk2 %u, account %s, clientseed %u", BuiltNumberClient, unk2, account.c_str(), clientSeed); - - ///- Normalize account name - //utf8ToUpperOnlyLatin(account); -- client already send account in expected form - - ///- Get the account information from the realmd database - std::string safe_account = account; // Duplicate, else will screw the SHA hash verification below - loginDatabase.escape_string(safe_account); - //No SQL injection, username escaped. - // 0 1 2 3 4 5 6 7 8 9 10 - QueryResult *result = loginDatabase.PQuery("SELECT id, gmlevel, sessionkey, last_ip, locked, sha_pass_hash, v, s, tbc, mutetime, locale FROM account WHERE username = '%s'", safe_account.c_str()); - - ///- Stop if the account is not found - if ( !result ) - { - packet.Initialize( SMSG_AUTH_RESPONSE, 1 ); - packet << uint8( AUTH_UNKNOWN_ACCOUNT ); - SendPacket( &packet ); - sLog.outDetail( "SOCKET: Sent Auth Response (unknown account)." ); - return; - } - - Field* fields = result->Fetch(); - - tbc = fields[8].GetUInt8() && sWorld.getConfig(CONFIG_EXPANSION) > 0; - - N.SetHexStr("894B645E89E1535BBDAD5B8B290650530801B18EBFBF5E8FAB3C82872A3E9BB7"); - g.SetDword(7); - I.SetHexStr(fields[5].GetString()); - - //In case of leading zeros in the I hash, restore them - uint8 mDigest[SHA_DIGEST_LENGTH]; - memset(mDigest,0,SHA_DIGEST_LENGTH); - if (I.GetNumBytes() <= SHA_DIGEST_LENGTH) - memcpy(mDigest,I.AsByteArray(),I.GetNumBytes()); - - std::reverse(mDigest,mDigest+SHA_DIGEST_LENGTH); - - s.SetHexStr(fields[7].GetString()); - sha1.UpdateData(s.AsByteArray(), s.GetNumBytes()); - sha1.UpdateData(mDigest, SHA_DIGEST_LENGTH); - sha1.Finalize(); - x.SetBinary(sha1.GetDigest(), sha1.GetLength()); - v = g.ModExp(x, N); - - const char* sStr = s.AsHexStr(); //Must be freed by OPENSSL_free() - const char* vStr = v.AsHexStr(); //Must be freed by OPENSSL_free() - const char* vold = fields[6].GetString(); - sLog.outDebug("SOCKET: (s,v) check s: %s v_old: %s v_new: %s", sStr, vold, vStr ); - loginDatabase.PExecute("UPDATE account SET v = '0', s = '0' WHERE username = '%s'", safe_account.c_str()); - if ( !vold || strcmp( vStr, vold ) ) - { - packet.Initialize( SMSG_AUTH_RESPONSE, 1 ); - packet << uint8( AUTH_UNKNOWN_ACCOUNT ); - SendPacket( &packet ); - sLog.outDetail( "SOCKET: User not logged."); - delete result; - OPENSSL_free((void*)sStr); - OPENSSL_free((void*)vStr); - return; - } - OPENSSL_free((void*)sStr); - OPENSSL_free((void*)vStr); - - ///- Re-check ip locking (same check as in realmd). - if(fields[4].GetUInt8() == 1) // if ip is locked - { - if ( strcmp(fields[3].GetString(),GetRemoteAddress().c_str()) ) - { - packet.Initialize( SMSG_AUTH_RESPONSE, 1 ); - packet << uint8( AUTH_FAILED ); - SendPacket( &packet ); - - sLog.outDetail( "SOCKET: Sent Auth Response (Account IP differs)." ); - delete result; - return; + delete npct; + sLog.outError ("WorldSocket::SendPacket: m_PacketQueue.enqueue_tail failed"); + return -1; } } - id = fields[0].GetUInt32(); - security = fields[1].GetUInt16(); - K.SetHexStr(fields[2].GetString()); - time_t mutetime = time_t(fields[9].GetUInt64()); - - LocaleConstant locale = LocaleConstant(fields[10].GetUInt8()); - if (locale>=MAX_LOCALE) - locale=LOCALE_enUS; - - delete result; - - ///- Re-check account ban (same check as in realmd) /// TO DO: why on earth do 2 checks for same thing? - QueryResult *banresult = loginDatabase.PQuery("SELECT bandate,unbandate FROM account_banned WHERE id = '%u' AND active = 1", id); - if(banresult) // if account banned - { - packet.Initialize( SMSG_AUTH_RESPONSE, 1 ); - packet << uint8( AUTH_BANNED ); - SendPacket( &packet ); - - sLog.outDetail( "SOCKET: Sent Auth Response (Account banned)." ); - delete banresult; - return; - } - - ///- Check locked state for server - AccountTypes allowedAccountType = sWorld.GetPlayerSecurityLimit(); - if( allowedAccountType > SEC_PLAYER && security < allowedAccountType) - { - WorldPacket Packet(SMSG_AUTH_RESPONSE, 1); - Packet << uint8(AUTH_UNAVAILABLE); - SendPacket(&Packet); - return; - } - - ///- kick already loaded player with same account (if any) and remove session - ///- if player is in loading and want to load again, return - if(!sWorld.RemoveSession(id)) - { - return; - } - - ///- Check that Key and account name are the same on client and server - Sha1Hash sha; - - uint32 t = 0; - uint32 seed = _seed; - - sha.UpdateData(account); - sha.UpdateData((uint8 *)&t, 4); - sha.UpdateData((uint8 *)&clientSeed, 4); - sha.UpdateData((uint8 *)&seed, 4); - sha.UpdateBigNumbers(&K, NULL); - sha.Finalize(); - - if (memcmp(sha.GetDigest(), digest, 20)) - { - packet.Initialize( SMSG_AUTH_RESPONSE, 1 ); - packet << uint8( AUTH_FAILED ); - SendPacket( &packet ); - - sLog.outDetail( "SOCKET: Sent Auth Response (authentication failed)." ); - return; - } - - ///- Initialize the encryption with the Key - _crypt.SetKey(&K); - _crypt.Init(); - - ///- Send 'Auth is ok' - packet.Initialize( SMSG_AUTH_RESPONSE, 1+4+1+4+1 ); - packet << uint8( AUTH_OK ); - packet << uint32(0); // unknown random value... - packet << uint8(0); // can be 0 and 2 - packet << uint32(0); // const 0 - packet << uint8(tbc ? 1 : 0); // 0 - normal, 1 - TBC, must be set in database manually for each account - SendPacket(&packet); - - ///- Create a new WorldSession for the player and add it to the World - _session = new WorldSession(id, this,security,tbc,mutetime,locale); - sWorld.AddSession(_session); - - if(sLog.IsOutDebug()) // optimize disabled debug output - { - sLog.outDebug( "SOCKET: Client '%s' authenticated successfully.", account.c_str() ); - sLog.outDebug( "Account: '%s' Logged in from IP %s.", account.c_str(), GetRemoteAddress().c_str()); - } - - ///- Update the last_ip in the database - //No SQL injection, username escaped. - std::string address = GetRemoteAddress(); - loginDatabase.escape_string(address); - loginDatabase.PExecute("UPDATE account SET last_ip = '%s' WHERE username = '%s'",address.c_str(), safe_account.c_str()); - - // do small delay (10ms) at accepting successful authed connection to prevent dropping packets by client - // don't must harm anyone (let login ~100 accounts in 1 sec ;) ) - #ifdef WIN32 - Sleep(10); - #else - ZThread::Thread::sleep(10); - #endif - - ///- Check that we do not exceed the maximum number of online players in the realm - uint32 Sessions = sWorld.GetActiveAndQueuedSessionCount(); - uint32 pLimit = sWorld.GetPlayerAmountLimit(); - uint32 QueueSize = sWorld.GetQueueSize(); //number of players in the queue - bool inQueue = false; - --Sessions; //so we don't count the user trying to login as a session and queue the socket that we are using - - if( pLimit > 0 && Sessions >= pLimit && security == SEC_PLAYER ) - { - sWorld.AddQueuedPlayer(this); - SendAuthWaitQue(sWorld.GetQueuePos(this)); - sWorld.UpdateMaxSessionCounters(); - sLog.outDetail( "PlayerQueue: %s is in Queue Position (%u).",safe_account.c_str(),++QueueSize); - inQueue = true; - } - - ///- Create and send the Addon packet - if(sAddOnHandler.BuildAddonPacket(&recvPacket, &SendAddonPacked)) - SendPacket(&SendAddonPacked); - - if(inQueue) - return; - - sWorld.UpdateMaxSessionCounters(); - - // Updates the population - if (pLimit > 0) - { - float popu = sWorld.GetActiveSessionCount(); //updated number of users on the server - popu /= pLimit; - popu *= 2; - loginDatabase.PExecute("UPDATE realmlist SET population = '%f' WHERE id = '%d'",popu,realmID); - sLog.outDetail( "Server Population (%f).",popu); - } - - return; + return 0; } -/// Handle the Ping packet -void WorldSocket::_HandlePing(WorldPacket& recvPacket) +long +WorldSocket::AddReference (void) { - uint32 ping; - uint32 latency; + return static_cast (this->add_reference ()); +} - CHECK_PACKET_SIZE(recvPacket,8); +long +WorldSocket::RemoveReference (void) +{ + return static_cast (this->remove_reference ()); +} - ///- Get the ping packet content - recvPacket >> ping; - recvPacket >> latency; +int +WorldSocket::open (void *a) +{ + ACE_UNUSED_ARG (a); - if (_session ) - _session->SetLatency(latency); + // Prevent double call to this func. + if (m_OutBuffer) + return -1; - ///- check ping speed for players - if(_session && _session->GetSecurity() == SEC_PLAYER) + // This will also prevent the socket from being Updated + // while we are initializing it. + m_OutActive = true; + + // Hook for the manager. + if (sWorldSocketMgr->OnSocketOpen (this) == -1) + return -1; + + // Allocate the buffer. + ACE_NEW_RETURN (m_OutBuffer, ACE_Message_Block (m_OutBufferSize), -1); + + // Store peer address. + ACE_INET_Addr remote_addr; + + if (this->peer ().get_remote_addr (remote_addr) == -1) { - uint32 cur_mstime = getMSTime(); + sLog.outError ("WorldSocket::open: peer ().get_remote_addr errno = %s", ACE_OS::strerror (errno)); + return -1; + } - // can overflow and start from 0 - uint32 diff_mstime = getMSTimeDiff(m_LastPingMSTime,cur_mstime); - m_LastPingMSTime = cur_mstime; - if(diff_mstime < 27000) // should be 30000 (=30 secs), add little tolerance + m_Address = remote_addr.get_host_addr (); + + // Send startup packet. + WorldPacket packet (SMSG_AUTH_CHALLENGE, 4); + packet << m_Seed; + + if (SendPacket (packet) == -1) + return -1; + + // Register with ACE Reactor + if (this->reactor ()->register_handler + (this, + ACE_Event_Handler::READ_MASK | ACE_Event_Handler::WRITE_MASK) == -1) + { + sLog.outError ("WorldSocket::open: unable to register client handler errno = %s", ACE_OS::strerror (errno)); + return -1; + } + + // reactor takes care of the socket from now on + this->remove_reference (); + + return 0; +} + +int +WorldSocket::close (int) +{ + this->shutdown (); + + this->closing_ = true; + + this->remove_reference (); + + return 0; +} + +int +WorldSocket::handle_input (ACE_HANDLE) +{ + if (this->closing_) + return -1; + + switch (this->handle_input_missing_data ()) + { + case -1 : + { + if ((errno == EWOULDBLOCK) || + (errno == EAGAIN)) + { + //return 0; + return this->Update (); // interesting line ,isnt it ? + } + + DEBUG_LOG ("WorldSocket::handle_input: Peer error closing connection errno = %s", ACE_OS::strerror (errno)); + + return -1; + } + case 0: + { + DEBUG_LOG ("WorldSocket::handle_input: Peer has closed connection\n"); + + errno = ECONNRESET; + + return -1; + } + case 1: + return 1; + } + + //return 0; + return this->Update (); // another interesting line ;) +} + +int +WorldSocket::handle_output (ACE_HANDLE) +{ + ACE_GUARD_RETURN (LockType, Guard, m_OutBufferLock, -1); + + if (this->closing_) + return -1; + + const size_t send_len = m_OutBuffer->length (); + + if (send_len == 0) + return this->cancel_wakeup_output (Guard); + +// TODO SO_NOSIGPIPE on platforms that support it +#ifdef MSG_NOSIGNAL + ssize_t n = this->peer ().send (m_OutBuffer->rd_ptr (), send_len, MSG_NOSIGNAL); +#else + ssize_t n = this->peer ().send (m_OutBuffer->rd_ptr (), send_len); +#endif // MSG_NOSIGNAL + + if (n == 0) + return -1; + else if (n == -1) + { + if (errno == EWOULDBLOCK || errno == EAGAIN) + return this->schedule_wakeup_output (Guard); + + return -1; + } + else if (n < send_len) //now n > 0 + { + m_OutBuffer->rd_ptr (static_cast (n)); + + // move the data to the base of the buffer + m_OutBuffer->crunch (); + + return this->schedule_wakeup_output (Guard); + } + else //now n == send_len + { + m_OutBuffer->reset (); + + if (!iFlushPacketQueue ()) + return this->cancel_wakeup_output (Guard); + else + return this->schedule_wakeup_output (Guard); + } + + ACE_NOTREACHED (return 0); +} + +int +WorldSocket::handle_close (ACE_HANDLE h, ACE_Reactor_Mask) +{ + // Critical section + { + ACE_GUARD_RETURN (LockType, Guard, m_OutBufferLock, -1); + + this->closing_ = true; + + if (h == ACE_INVALID_HANDLE) + this->peer ().close_writer (); + } + + // Critical section + { + ACE_GUARD_RETURN (LockType, Guard, m_SessionLock, -1); + + m_Session = NULL; + } + + return 0; +} + +int +WorldSocket::Update (void) +{ + if (this->closing_) + return -1; + + if (m_OutActive || m_OutBuffer->length () == 0) + return 0; + + return this->handle_output (this->get_handle ()); +} + +int +WorldSocket::handle_input_header (void) +{ + ACE_ASSERT (m_RecvWPct == NULL); + + if (m_Header.length () != sizeof (ClientPktHeader)) + { + sLog.outError ("WorldSocket::handle_input_header: internal error: invalid header"); + errno = EINVAL; + return -1; + } + + m_Crypt.DecryptRecv ((ACE_UINT8*) m_Header.rd_ptr (), sizeof (ClientPktHeader)); + + ClientPktHeader& header = *((ClientPktHeader*) m_Header.rd_ptr ()); + + header.size = ACE_NTOHS (header.size); + +#if ACE_BYTE_ORDER == ACE_BIG_ENDIAN + header.cmd = ACE_SWAP_LONG (header.cmd) +#endif // ACE_BIG_ENDIAN + + if ((header.size < 4) || + (header.size > 10240) || + (header.cmd <= 0) || + (header.cmd > 10240) + ) + { + sLog.outError ("WorldSocket::handle_input_header: client sent mailformed packet size = %d , cmd = %d", + header.size, + header.cmd); + + errno = EINVAL; + return -1; + } + + header.size -= 4; + + ACE_NEW_RETURN (m_RecvWPct, WorldPacket ((uint16) header.cmd, header.size), -1); + + if(header.size > 0) + { + m_RecvWPct->resize (header.size); + m_RecvPct.base ((char*) m_RecvWPct->contents (), m_RecvWPct->size ()); + } + else + { + ACE_ASSERT(m_RecvPct.space() == 0); + } + + + return 0; +} + +int +WorldSocket::handle_input_payload (void) +{ + // set errno properly here on error !!! + // now have a header and payload + + ACE_ASSERT (m_RecvPct.space () == 0); + ACE_ASSERT (m_Header.space () == 0); + ACE_ASSERT (m_RecvWPct != NULL); + + const int ret = this->ProcessIncoming (m_RecvWPct); + + m_RecvPct.base (NULL, 0); + m_RecvPct.reset (); + m_RecvWPct = NULL; + + m_Header.reset (); + + if (ret == -1) + errno = EINVAL; + + return ret; +} + +int +WorldSocket::handle_input_missing_data (void) +{ + char buf [1024]; + + ACE_Data_Block db (sizeof (buf), + ACE_Message_Block::MB_DATA, + buf, + 0, + 0, + ACE_Message_Block::DONT_DELETE, + 0); + + ACE_Message_Block message_block (&db, + ACE_Message_Block::DONT_DELETE, + 0); + + const size_t recv_size = message_block.space (); + + const ssize_t n = this->peer ().recv (message_block.wr_ptr (), + recv_size); + + if (n <= 0) + return n; + + message_block.wr_ptr (n); + + while (message_block.length () > 0) + { + if (m_Header.space () > 0) { - ++m_OverSpeedPings; + //need to recieve the header + const size_t to_header = (message_block.length () > m_Header.space () ? m_Header.space () : message_block.length ()); + m_Header.copy (message_block.rd_ptr (), to_header); + message_block.rd_ptr (to_header); - uint32 max_count = sWorld.getConfig(CONFIG_MAX_OVERSPEED_PINGS); - if(max_count && m_OverSpeedPings > max_count) + if (m_Header.space () > 0) { - sLog.outBasic("Player %s from account id %u kicked for overspeed ping packets from client (non-playable connection lags or cheating) ",_session->GetPlayerName(),_session->GetAccountId()); - _session->KickPlayer(); - return; + //couldnt recieve the whole header this time + ACE_ASSERT (message_block.length () == 0); + errno = EWOULDBLOCK; + return -1; + } + + //we just recieved nice new header + if (this->handle_input_header () == -1) + { + ACE_ASSERT ((errno != EWOULDBLOCK) && (errno != EAGAIN)); + return -1; } } - else - m_OverSpeedPings = 0; - } - - ///- And put the pong answer in the to-be-sent queue - WorldPacket packet( SMSG_PONG, 4 ); - packet << ping; - SendPacket(&packet); - - return; -} - -/// Handle the update order for the socket -void WorldSocket::SendSinglePacket() -{ - WorldPacket *packet; - ServerPktHeader hdr; - - ///- If we have packet to send - if (!_sendQueue.empty()) - { - packet = _sendQueue.next(); - - hdr.size = ntohs((uint16)packet->size() + 2); - hdr.cmd = packet->GetOpcode(); - - if( sWorldLog.LogWorld() ) + // Its possible on some error situations that this happens + // for example on closing when epoll recieves more chunked data and stuff + // hope this is not hack ,as proper m_RecvWPct is asserted around + if (!m_RecvWPct) { - sWorldLog.Log("SERVER:\nSOCKET: %u\nLENGTH: %u\nOPCODE: %s (0x%.4X)\nDATA:\n", - (uint32)GetSocket(), - packet->size(), - LookupOpcodeName(packet->GetOpcode()), - packet->GetOpcode()); - - uint32 p = 0; - while (p < packet->size()) - { - for (uint32 j = 0; j < 16 && p < packet->size(); j++) - sWorldLog.Log("%.2X ", (*packet)[p++]); - - sWorldLog.Log("\n"); - } - - sWorldLog.Log("\n\n"); + sLog.outError ("Forsing close on input m_RecvWPct = NULL"); + errno = EINVAL; + return -1; } - ///- Encrypt (if needed) the header - _crypt.EncryptSend((uint8*)&hdr, 4); + // We have full readed header, now check the data payload + if (m_RecvPct.space () > 0) + { + //need more data in the payload + const size_t to_data = (message_block.length () > m_RecvPct.space () ? m_RecvPct.space () : message_block.length ()); + m_RecvPct.copy (message_block.rd_ptr (), to_data); + message_block.rd_ptr (to_data); - ///- Send the header and body to the client - TcpSocket::SendBuf((char*)&hdr, 4); - if(!packet->empty()) TcpSocket::SendBuf((char*)packet->contents(), packet->size()); + if (m_RecvPct.space () > 0) + { + //couldnt recieve the whole data this time + ACE_ASSERT (message_block.length () == 0); + errno = EWOULDBLOCK; + return -1; + } + } - delete packet; + //just recieved fresh new payload + if (this->handle_input_payload () == -1) + { + ACE_ASSERT ((errno != EWOULDBLOCK) && (errno != EAGAIN)); + return -1; + } } + + return n == recv_size ? 1 : 2; } -void WorldSocket::Update(time_t diff) +int +WorldSocket::cancel_wakeup_output (GuardType& g) { - const uint32 SEND_PACKETS_MAX = 100; - const uint32 SEND_BUFFER_SIZE = 1024; + if (!m_OutActive) + return 0; - uint8 sendBuffer[SEND_BUFFER_SIZE]; + m_OutActive = false; - while (!_sendQueue.empty()) + g.release (); + + if (this->reactor ()->cancel_wakeup + (this, ACE_Event_Handler::WRITE_MASK) == -1) { - bool haveBigPacket = false; - uint32 bufferSize = 0; + // would be good to store errno from reactor with errno guard + sLog.outError ("WorldSocket::cancel_wakeup_output"); + return -1; + } - ///- While we have packets to send - for (uint32 packetCount = 0; (packetCount < SEND_PACKETS_MAX) && !_sendQueue.empty(); packetCount++) + return 0; +} + +int +WorldSocket::schedule_wakeup_output (GuardType& g) +{ + if (m_OutActive) + return 0; + + m_OutActive = true; + + g.release (); + + if (this->reactor ()->schedule_wakeup + (this, ACE_Event_Handler::WRITE_MASK) == -1) + { + sLog.outError ("WorldSocket::schedule_wakeup_output"); + return -1; + } + + return 0; +} + +int +WorldSocket::ProcessIncoming (WorldPacket* new_pct) +{ + ACE_ASSERT (new_pct); + + // manage memory ;) + ACE_Auto_Ptr aptr (new_pct); + + const ACE_UINT16 opcode = new_pct->GetOpcode (); + + if (this->closing_) + return -1; + + // dump recieved packet + if (sWorldLog.LogWorld ()) + { + sWorldLog.Log ("CLIENT:\nSOCKET: %u\nLENGTH: %u\nOPCODE: %s (0x%.4X)\nDATA:\n", + (uint32) get_handle (), + new_pct->size (), + LookupOpcodeName (new_pct->GetOpcode ()), + new_pct->GetOpcode ()); + + uint32 p = 0; + while (p < new_pct->size ()) { - ServerPktHeader *hdr = (ServerPktHeader*)&sendBuffer[bufferSize]; + for (uint32 j = 0; j < 16 && p < new_pct->size (); j++) + sWorldLog.Log ("%.2X ", (*new_pct)[p++]); + sWorldLog.Log ("\n"); + } + sWorldLog.Log ("\n\n"); + } - // check merge possibility. - WorldPacket *front = _sendQueue.front(); - uint32 packetSize = front->size(); + // like one switch ;) + if (opcode == CMSG_PING) + { + return HandlePing (*new_pct); + } + else if (opcode == CMSG_AUTH_SESSION) + { + if (m_Session) + { + sLog.outError ("WorldSocket::ProcessIncoming: Player send CMSG_AUTH_SESSION again"); + return -1; + } - if ((sizeof(*hdr) + packetSize) > SEND_BUFFER_SIZE) + return HandleAuthSession (*new_pct); + } + else if (opcode == CMSG_KEEP_ALIVE) + { + DEBUG_LOG ("CMSG_KEEP_ALIVE ,size: %d", new_pct->size ()); + + return 0; + } + else + { + ACE_GUARD_RETURN (LockType, Guard, m_SessionLock, -1); + + if (m_Session != NULL) + { + // OK ,give the packet to WorldSession + aptr.release (); + // WARNINIG here we call it with locks held. + // Its possible to cause deadlock if QueuePacket calls back + m_Session->QueuePacket (new_pct); + return 0; + } + else + { + sLog.outError ("WorldSocket::ProcessIncoming: Client not authed opcode = ", opcode); + return -1; + } + } + + ACE_NOTREACHED (return 0); +} + +int +WorldSocket::HandleAuthSession (WorldPacket& recvPacket) +{ + uint8 digest[20]; + uint32 clientSeed; + uint32 unk2; + uint32 BuiltNumberClient; + uint32 id, security; + bool tbc = false; + LocaleConstant locale; + std::string account; + Sha1Hash sha1; + BigNumber v, s, g, N, x, I; + WorldPacket packet, SendAddonPacked; + + BigNumber K; + + if (recvPacket.size () < (4 + 4 + 1 + 4 + 20)) + { + sLog.outError ("WorldSocket::HandleAuthSession: wrong packet size"); + return -1; + } + + // Read the content of the packet + recvPacket >> BuiltNumberClient; // for now no use + recvPacket >> unk2; + recvPacket >> account; + + if (recvPacket.size () < (4 + 4 + (account.size () + 1) + 4 + 20)) + { + sLog.outError ("WorldSocket::HandleAuthSession: wrong packet size second check"); + return -1; + } + + recvPacket >> clientSeed; + recvPacket.read (digest, 20); + + DEBUG_LOG ("WorldSocket::HandleAuthSession: client %u, unk2 %u, account %s, clientseed %u", + BuiltNumberClient, + unk2, + account.c_str (), + clientSeed); + +#if defined _NETCODE_FAKE_AUTH + bool dontchechtheacc = false; + uint8 digest_fake[sizeof (digest)]; + memset ((void*) digest_fake, '\0', sizeof (digest_fake)); + if (memcmp ((void*) digest, (void*) digest_fake, sizeof (digest_fake)) == 0) + { + dontchechtheacc = true; + } +#endif //_NETCODE_FAKE_AUTH + + // Get the account information from the realmd database + std::string safe_account = account; // Duplicate, else will screw the SHA hash verification below + loginDatabase.escape_string (safe_account); + // No SQL injection, username escaped. + + QueryResult *result = + loginDatabase.PQuery ("SELECT " + "id, " //0 + "gmlevel, " //1 + "sessionkey, " //2 + "last_ip, " //3 + "locked, " //4 + "sha_pass_hash, " //5 + "v, " //6 + "s, " //7 + "tbc, " //8 + "mutetime, " //9 + "locale " //10 + "FROM account " + "WHERE username = '%s'", + safe_account.c_str ()); + + // Stop if the account is not found + if (!result) + { + packet.Initialize (SMSG_AUTH_RESPONSE, 1); + packet << uint8 (AUTH_UNKNOWN_ACCOUNT); + + SendPacket (packet); + + sLog.outError ("WorldSocket::HandleAuthSession: Sent Auth Response (unknown account)."); + return -1; + } + + Field* fields = result->Fetch (); + + tbc = fields[8].GetUInt8 () && sWorld.getConfig (CONFIG_EXPANSION) > 0; + + N.SetHexStr ("894B645E89E1535BBDAD5B8B290650530801B18EBFBF5E8FAB3C82872A3E9BB7"); + g.SetDword (7); + I.SetHexStr (fields[5].GetString ()); + + //In case of leading zeros in the I hash, restore them + uint8 mDigest[SHA_DIGEST_LENGTH]; + memset (mDigest, 0, SHA_DIGEST_LENGTH); + + if (I.GetNumBytes () <= SHA_DIGEST_LENGTH) + memcpy (mDigest, I.AsByteArray (), I.GetNumBytes ()); + + std::reverse (mDigest, mDigest + SHA_DIGEST_LENGTH); + + s.SetHexStr (fields[7].GetString ()); + sha1.UpdateData (s.AsByteArray (), s.GetNumBytes ()); + sha1.UpdateData (mDigest, SHA_DIGEST_LENGTH); + sha1.Finalize (); + x.SetBinary (sha1.GetDigest (), sha1.GetLength ()); + v = g.ModExp (x, N); + + const char* sStr = s.AsHexStr (); //Must be freed by OPENSSL_free() + const char* vStr = v.AsHexStr (); //Must be freed by OPENSSL_free() + const char* vold = fields[6].GetString (); + + DEBUG_LOG ("WorldSocket::HandleAuthSession: (s,v) check s: %s v_old: %s v_new: %s", + sStr, + vold, + vStr); + + loginDatabase.PExecute ("UPDATE account " + "SET " + "v = '0', " + "s = '0' " + "WHERE username = '%s'", + safe_account.c_str ()); + +#if defined _NETCODE_FAKE_AUTH + if (!dontchechtheacc) + { +#endif + if (!vold || strcmp (vStr, vold)) + { + packet.Initialize (SMSG_AUTH_RESPONSE, 1); + packet << uint8 (AUTH_UNKNOWN_ACCOUNT); + SendPacket (packet); + delete result; + OPENSSL_free ((void*) sStr); + OPENSSL_free ((void*) vStr); + + sLog.outError ("WorldSocket::HandleAuthSession: User not logged."); + return -1; + } +#if defined _NETCODE_FAKE_AUTH + } +#endif + + OPENSSL_free ((void*) sStr); + OPENSSL_free ((void*) vStr); + + ///- Re-check ip locking (same check as in realmd). + if (fields[4].GetUInt8 () == 1) // if ip is locked + { + if (strcmp (fields[3].GetString (), GetRemoteAddress ().c_str ())) + { + packet.Initialize (SMSG_AUTH_RESPONSE, 1); + packet << uint8 (AUTH_FAILED); + SendPacket (packet); + + delete result; + sLog.outError ("WorldSocket::HandleAuthSession: Sent Auth Response (Account IP differs)."); + return -1; + } + } + + id = fields[0].GetUInt32 (); + security = fields[1].GetUInt16 (); + K.SetHexStr (fields[2].GetString ()); + + time_t mutetime = time_t (fields[9].GetUInt64 ()); + + locale = LocaleConstant (fields[10].GetUInt8 ()); + if (locale >= MAX_LOCALE) + locale = LOCALE_enUS; + + delete result; + +#if defined _NETCODE_FAKE_AUTH + if (!dontchechtheacc) + { +#endif + // Re-check account ban (same check as in realmd) + QueryResult *banresult = + loginDatabase.PQuery ("SELECT " + "bandate, " + "unbandate " + "FROM account_banned " + "WHERE id = '%u' " + "AND active = 1", + id); + + if (banresult) // if account banned + { + packet.Initialize (SMSG_AUTH_RESPONSE, 1); + packet << uint8 (AUTH_BANNED); + SendPacket (packet); + + delete banresult; + + sLog.outError ("WorldSocket::HandleAuthSession: Sent Auth Response (Account banned)."); + return -1; + } + + // Check locked state for server + AccountTypes allowedAccountType = sWorld.GetPlayerSecurityLimit (); + + if (allowedAccountType > SEC_PLAYER && security < allowedAccountType) + { + WorldPacket Packet (SMSG_AUTH_RESPONSE, 1); + Packet << uint8 (AUTH_UNAVAILABLE); + + SendPacket (packet); + + sLog.outBasic ("WorldSocket::HandleAuthSession: User tryes to login but his security level is not enough"); + return -1; + } + + // Check that Key and account name are the same on client and server + Sha1Hash sha; + + uint32 t = 0; + uint32 seed = m_Seed; + + sha.UpdateData (account); + sha.UpdateData ((uint8 *) & t, 4); + sha.UpdateData ((uint8 *) & clientSeed, 4); + sha.UpdateData ((uint8 *) & seed, 4); + sha.UpdateBigNumbers (&K, NULL); + sha.Finalize (); + + if (memcmp (sha.GetDigest (), digest, 20)) + { + packet.Initialize (SMSG_AUTH_RESPONSE, 1); + packet << uint8 (AUTH_FAILED); + + SendPacket (packet); + + sLog.outError ("WorldSocket::HandleAuthSession: Sent Auth Response (authentification failed)."); + return -1; + } +#if defined _NETCODE_FAKE_AUTH + } +#endif + + std::string address = this->GetRemoteAddress (); + + DEBUG_LOG ("WorldSocket::HandleAuthSession: Client '%s' authenticated successfully from %s.", + account.c_str (), + address.c_str ()); + + // Update the last_ip in the database + // No SQL injection, username escaped. + loginDatabase.escape_string (address); + + loginDatabase.PExecute ("UPDATE account " + "SET last_ip = '%s' " + "WHERE username = '%s'", + address.c_str (), + safe_account.c_str ()); + + // TODO protect here probably ? + // Althought atm the socket is singlethreaded + ACE_NEW_RETURN (m_Session, WorldSession (id, this, security, tbc, mutetime, locale), -1); + +#if defined _NETCODE_FAKE_AUTH + if (!dontchechtheacc) + { +#endif + this->m_Crypt.SetKey (&K); + this->m_Crypt.Init (); +#if defined _NETCODE_FAKE_AUTH + } +#endif + + // In case needed sometime the second arg is in microseconds 1 000 000 = 1 sec + ACE_OS::sleep (ACE_Time_Value (0, 10000)); + + // TODO error handling + sWorld.AddSession (this->m_Session); + + // Create and send the Addon packet + if (sAddOnHandler.BuildAddonPacket (&recvPacket, &SendAddonPacked)) + SendPacket (SendAddonPacked); + + return 0; +} + +int +WorldSocket::HandlePing (WorldPacket& recvPacket) +{ + uint32 ping; + uint32 latency; + + if (recvPacket.size () < 8) + { + sLog.outError ("WorldSocket::_HandlePing wrong packet size"); + return -1; + } + + // Get the ping packet content + recvPacket >> ping; + recvPacket >> latency; + + if (m_LastPingTime == ACE_Time_Value::zero) + m_LastPingTime = ACE_OS::gettimeofday (); // for 1st ping + else + { + ACE_Time_Value cur_time = ACE_OS::gettimeofday (); + ACE_Time_Value diff_time (cur_time); + diff_time -= m_LastPingTime; + m_LastPingTime = cur_time; + + if (diff_time < ACE_Time_Value (27)) + { + ++m_OverSpeedPings; + + uint32 max_count = sWorld.getConfig (CONFIG_MAX_OVERSPEED_PINGS); + + if (max_count && m_OverSpeedPings > max_count) { - haveBigPacket = true; - break; - } + ACE_GUARD_RETURN (LockType, Guard, m_SessionLock, -1); - if ((bufferSize + sizeof(*hdr) + packetSize) > sizeof(sendBuffer)) - break; - - // can be merged - WorldPacket *packet = _sendQueue.next(); - - hdr->size = ntohs((uint16)packetSize + 2); - hdr->cmd = packet->GetOpcode(); - - if( sWorldLog.LogWorld() ) - { - sWorldLog.Log("SERVER:\nSOCKET: %u\nLENGTH: %u\nOPCODE: %s (0x%.4X)\nDATA:\n", - (uint32)GetSocket(), - packetSize, - LookupOpcodeName(packet->GetOpcode()), - packet->GetOpcode()); - - uint32 p = 0; - while (p < packetSize) + if (m_Session && m_Session->GetSecurity () == SEC_PLAYER) { - for (uint32 j = 0; j < 16 && p < packetSize; j++) - sWorldLog.Log("%.2X ", (*packet)[p++]); + sLog.outError ("WorldSocket::HandlePing: Player kicked for " + "overspeeded pings adress = %s", + GetRemoteAddress ().c_str ()); - sWorldLog.Log("\n"); + return -1; } - - sWorldLog.Log("\n\n"); } - - ///- Encrypt (if needed) the header - _crypt.EncryptSend((uint8*)hdr, sizeof(*hdr)); - bufferSize += sizeof(*hdr); - - if (packetSize) - { - memcpy(&sendBuffer[bufferSize], packet->contents(), packetSize); - bufferSize += packetSize; - } - - ///- Send the header and body to the client - delete packet; } - - // send merged packets - if (bufferSize) TcpSocket::SendBuf((char*)sendBuffer, bufferSize); - // send too big non-merged packet - if (haveBigPacket) SendSinglePacket(); + else + m_OverSpeedPings = 0; } -} -/// Handle the authentication waiting queue (to be completed) -void WorldSocket::SendAuthWaitQue(uint32 position) -{ - if(position == 0) - { - WorldPacket packet( SMSG_AUTH_RESPONSE, 1 ); - packet << uint8( AUTH_OK ); - SendPacket(&packet); - } + // critical section + { + ACE_GUARD_RETURN (LockType, Guard, m_SessionLock, -1); + + if (m_Session) + m_Session->SetLatency (latency); else - { - WorldPacket packet( SMSG_AUTH_RESPONSE, 5 ); - packet << uint8( AUTH_WAIT_QUEUE ); - packet << uint32 (position); //amount of players in queue - SendPacket(&packet); - } + { + sLog.outError ("WorldSocket::HandlePing: peer sent CMSG_PING, " + "but is not authenticated or got recently kicked," + " adress = %s", + this->GetRemoteAddress ().c_str ()); + return -1; + } + } + + WorldPacket packet (SMSG_PONG, 4); + packet << ping; + return this->SendPacket (packet); } -void WorldSocket::SizeError(WorldPacket const& packet, uint32 size) const +int +WorldSocket::iSendPacket (const WorldPacket& pct) { - sLog.outError("Client send packet %s (%u) with size %u but expected %u (attempt crash server?), skipped", - LookupOpcodeName(packet.GetOpcode()),packet.GetOpcode(),packet.size(),size); + if (m_OutBuffer->space () < pct.size () + sizeof (ServerPktHeader)) + { + errno = ENOBUFS; + return -1; + } + + ServerPktHeader header; + + header.cmd = pct.GetOpcode (); + +#if ACE_BYTE_ORDER == ACE_BIG_ENDIAN + header.cmd = ACE_SWAP_WORD (header.cmd) +#endif + + header.size = (uint16) pct.size () + 2; + header.size = ACE_HTONS (header.size); + + m_Crypt.EncryptSend ((uint8*) & header, sizeof (header)); + + if (m_OutBuffer->copy ((char*) & header, sizeof (header)) == -1) + ACE_ASSERT (false); + + if (!pct.empty ()) + if (m_OutBuffer->copy ((char*) pct.contents (), pct.size ()) == -1) + ACE_ASSERT (false); + + return 0; +} + +bool +WorldSocket::iFlushPacketQueue () +{ + WorldPacket *pct; + bool haveone = false; + + while (m_PacketQueue.dequeue_head (pct) == 0) + { + if (iSendPacket (*pct) == -1) + { + if (m_PacketQueue.enqueue_head (pct) == -1) + { + delete pct; + sLog.outError ("WorldSocket::iFlushPacketQueue m_PacketQueue->enqueue_head"); + return false; + } + + break; + } + else + { + haveone = true; + delete pct; + } + } + + return haveone; } diff --git a/src/game/WorldSocket.h b/src/game/WorldSocket.h index 26f8fb882f0..96b8f5eda38 100644 --- a/src/game/WorldSocket.h +++ b/src/game/WorldSocket.h @@ -1,4 +1,4 @@ -/* +/* * Copyright (C) 2005-2008 MaNGOS * * This program is free software; you can redistribute it and/or modify @@ -16,164 +16,218 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/// \addtogroup u2w -/// @{ -/// \file +/** \addtogroup u2w User to World Communication + * @{ + * \file WorldSocket.h + * \author Derex + */ -#ifndef __WORLDSOCKET_H -#define __WORLDSOCKET_H +#ifndef _WORLDSOCKET_H +#define _WORLDSOCKET_H -#include "sockets/TcpSocket.h" -#include "Auth/AuthCrypt.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include -enum ResponseCodes -{ - RESPONSE_SUCCESS = 0x00, - RESPONSE_FAILURE = 0x01, - RESPONSE_CANCELLED = 0x02, - RESPONSE_DISCONNECTED = 0x03, - RESPONSE_FAILED_TO_CONNECT = 0x04, - RESPONSE_CONNECTED = 0x05, - RESPONSE_VERSION_MISMATCH = 0x06, +#if !defined (ACE_LACKS_PRAGMA_ONCE) +#pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ - CSTATUS_CONNECTING = 0x07, - CSTATUS_NEGOTIATING_SECURITY = 0x08, - CSTATUS_NEGOTIATION_COMPLETE = 0x09, - CSTATUS_NEGOTIATION_FAILED = 0x0A, - CSTATUS_AUTHENTICATING = 0x0B, - - AUTH_OK = 0x0C, - AUTH_FAILED = 0x0D, - AUTH_REJECT = 0x0E, - AUTH_BAD_SERVER_PROOF = 0x0F, - AUTH_UNAVAILABLE = 0x10, - AUTH_SYSTEM_ERROR = 0x11, - AUTH_BILLING_ERROR = 0x12, - AUTH_BILLING_EXPIRED = 0x13, - AUTH_VERSION_MISMATCH = 0x14, - AUTH_UNKNOWN_ACCOUNT = 0x15, - AUTH_INCORRECT_PASSWORD = 0x16, - AUTH_SESSION_EXPIRED = 0x17, - AUTH_SERVER_SHUTTING_DOWN = 0x18, - AUTH_ALREADY_LOGGING_IN = 0x19, - AUTH_LOGIN_SERVER_NOT_FOUND = 0x1A, - AUTH_WAIT_QUEUE = 0x1B, - AUTH_BANNED = 0x1C, - AUTH_ALREADY_ONLINE = 0x1D, - AUTH_NO_TIME = 0x1E, - AUTH_DB_BUSY = 0x1F, - AUTH_SUSPENDED = 0x20, - AUTH_PARENTAL_CONTROL = 0x21, - AUTH_LOCKED_ENFORCED = 0x22, - - REALM_LIST_IN_PROGRESS = 0x23, - REALM_LIST_SUCCESS = 0x24, - REALM_LIST_FAILED = 0x25, - REALM_LIST_INVALID = 0x26, - REALM_LIST_REALM_NOT_FOUND = 0x27, - - ACCOUNT_CREATE_IN_PROGRESS = 0x28, - ACCOUNT_CREATE_SUCCESS = 0x29, - ACCOUNT_CREATE_FAILED = 0x2A, - - CHAR_LIST_RETRIEVING = 0x2B, - CHAR_LIST_RETRIEVED = 0x2C, - CHAR_LIST_FAILED = 0x2D, - - CHAR_CREATE_IN_PROGRESS = 0x2E, - CHAR_CREATE_SUCCESS = 0x2F, - CHAR_CREATE_ERROR = 0x30, - CHAR_CREATE_FAILED = 0x31, - CHAR_CREATE_NAME_IN_USE = 0x32, - CHAR_CREATE_DISABLED = 0x33, - CHAR_CREATE_PVP_TEAMS_VIOLATION = 0x34, - CHAR_CREATE_SERVER_LIMIT = 0x35, - CHAR_CREATE_ACCOUNT_LIMIT = 0x36, - CHAR_CREATE_SERVER_QUEUE = 0x37, - CHAR_CREATE_ONLY_EXISTING = 0x38, - CHAR_CREATE_EXPANSION = 0x39, - - CHAR_DELETE_IN_PROGRESS = 0x3A, - CHAR_DELETE_SUCCESS = 0x3B, - CHAR_DELETE_FAILED = 0x3C, - CHAR_DELETE_FAILED_LOCKED_FOR_TRANSFER = 0x3D, - CHAR_DELETE_FAILED_GUILD_LEADER = 0x3E, - CHAR_DELETE_FAILED_ARENA_CAPTAIN = 0x3F, - - CHAR_LOGIN_IN_PROGRESS = 0x40, - CHAR_LOGIN_SUCCESS = 0x41, - CHAR_LOGIN_NO_WORLD = 0x42, - CHAR_LOGIN_DUPLICATE_CHARACTER = 0x43, - CHAR_LOGIN_NO_INSTANCES = 0x44, - CHAR_LOGIN_FAILED = 0x45, - CHAR_LOGIN_DISABLED = 0x46, - CHAR_LOGIN_NO_CHARACTER = 0x47, - CHAR_LOGIN_LOCKED_FOR_TRANSFER = 0x48, - CHAR_LOGIN_LOCKED_BY_BILLING = 0x49, - - CHAR_NAME_SUCCESS = 0x4A, - CHAR_NAME_FAILURE = 0x4B, - CHAR_NAME_NO_NAME = 0x4C, - CHAR_NAME_TOO_SHORT = 0x4D, - CHAR_NAME_TOO_LONG = 0x4E, - CHAR_NAME_INVALID_CHARACTER = 0x4F, - CHAR_NAME_MIXED_LANGUAGES = 0x50, - CHAR_NAME_PROFANE = 0x51, - CHAR_NAME_RESERVED = 0x52, - CHAR_NAME_INVALID_APOSTROPHE = 0x53, - CHAR_NAME_MULTIPLE_APOSTROPHES = 0x54, - CHAR_NAME_THREE_CONSECUTIVE = 0x55, - CHAR_NAME_INVALID_SPACE = 0x56, - CHAR_NAME_CONSECUTIVE_SPACES = 0x57, - CHAR_NAME_RUSSIAN_CONSECUTIVE_SILENT_CHARACTERS = 0x58, - CHAR_NAME_RUSSIAN_SILENT_CHARACTER_AT_BEGINNING_OR_END = 0x59, - CHAR_NAME_DECLENSION_DOESNT_MATCH_BASE_NAME = 0x5A, -}; +#include "Common.h" +#include "Auth/AuthCrypt.h" +class ACE_Message_Block; class WorldPacket; -class SocketHandler; class WorldSession; -/// Handle connection with the client software -class WorldSocket : public TcpSocket +/// Handler that can communicate over stream sockets. +typedef ACE_Svc_Handler WorldHandler; + +/** + * WorldSocket. + * + * This class is responsible for the comunication with + * remote clients. + * Most methods return -1 on failure. + * The class uses refferece counting. + * + * For output the class uses one buffer (64K usually) and + * a queue where it stores packet if there is no place on + * the queue. The reason this is done, is because the server + * does realy a lot of small-size writes to it, and it doesn't + * scale well to allocate memory for every. When something is + * writen to the output buffer the socket is not immideately + * activated for output (again for the same reason), there + * is 10ms celling (thats why there is Update() method). + * This concept is simmilar to TCP_CORK, but TCP_CORK + * usses 200ms celling. As result overhead generated by + * sending packets from "producer" threads is minimal, + * and doing a lot of writes with small size is tollerated. + * + * The calls to Upate () method are managed by WorldSocketMgr + * and ReactorRunnable. + * + * For input ,the class uses one 1024 bytes buffer on stack + * to which it does recv() calls. And then recieved data is + * distributed where its needed. 1024 matches pritey well the + * traffic generated by client for now. + * + * The input/output do speculative reads/writes (AKA it tryes + * to read all data avaible in the kernel buffer or tryes to + * write everything avaible in userspace buffer), + * which is ok for using with Level and Edge Trigered IO + * notification. + * + */ +class WorldSocket : protected WorldHandler { - public: - WorldSocket(ISocketHandler&); - ~WorldSocket(); +public: + /// Declare some friends + friend class ACE_Acceptor< WorldSocket, ACE_SOCK_ACCEPTOR >; + friend class WorldSocketMgr; + friend class ReactorRunnable; - void SendPacket(WorldPacket const* packet); - void CloseSocket(); + /// Declare the acceptor for this class + typedef ACE_Acceptor< WorldSocket, ACE_SOCK_ACCEPTOR > Acceptor; - void OnAccept(); - void OnRead(); - void OnDelete(); + /// Mutex type used for various syncronizations. + typedef ACE_Thread_Mutex LockType; + typedef ACE_Guard GuardType; - void Update(time_t diff); - // Player Queue - void SendAuthWaitQue(uint32 position); + /// Queue for storing packets for which there is no space. + typedef ACE_Unbounded_Queue< WorldPacket* > PacketQueueT; - WorldSession* GetSession() const { return _session; } - protected: - void SendSinglePacket(); + /// Check if socket is closed. + bool IsClosed (void) const; - protected: - void _HandleAuthSession(WorldPacket& recvPacket); - void _HandlePing(WorldPacket& recvPacket); + /// Close the socket. + void CloseSocket (void); - private: - AuthCrypt _crypt; - uint32 _seed; - uint32 _cmd; - uint16 _remaining; - WorldSession* _session; + /// Get address of connected peer. + const std::string& GetRemoteAddress (void) const; - ZThread::LockedQueue _sendQueue; + /// Send A packet on the socket, this function is reentrant. + /// @param pct packet to send + /// @return -1 of failure + int SendPacket (const WorldPacket& pct); - uint32 m_LastPingMSTime; - uint32 m_OverSpeedPings; + /// Add refference to this object. + long AddReference (void); - // internal checks - void SizeError(WorldPacket const& packet, uint32 size) const; + /// Remove refference to this object. + long RemoveReference (void); + +protected: + /// things called by ACE framework. + WorldSocket (void); + virtual ~WorldSocket (void); + + /// Called on open ,the void* is the acceptor. + virtual int open (void *); + + /// Called on failures inside of the acceptor, don't call from your code. + virtual int close (int); + + /// Called when we can read from the socket. + virtual int handle_input (ACE_HANDLE = ACE_INVALID_HANDLE); + + /// Called when the socket can write. + virtual int handle_output (ACE_HANDLE = ACE_INVALID_HANDLE); + + /// Called when connection is closed or error happens. + virtual int handle_close (ACE_HANDLE = ACE_INVALID_HANDLE, + ACE_Reactor_Mask = ACE_Event_Handler::ALL_EVENTS_MASK); + + /// Called by WorldSocketMgr/ReactorRunnable. + int Update (void); + +private: + /// Helper functions for processing incoming data. + int handle_input_header (void); + int handle_input_payload (void); + int handle_input_missing_data (void); + + /// Help functions to mark/unmark the socket for output. + /// @param g the guard is for m_OutBufferLock, the function will release it + int cancel_wakeup_output (GuardType& g); + int schedule_wakeup_output (GuardType& g); + + /// process one incoming packet. + /// @param new_pct received packet ,note that you need to delete it. + int ProcessIncoming (WorldPacket* new_pct); + + /// Called by ProcessIncoming() on CMSG_AUTH_SESSION. + int HandleAuthSession (WorldPacket& recvPacket); + + /// Called by ProcessIncoming() on CMSG_PING. + int HandlePing (WorldPacket& recvPacket); + + /// Try to write WorldPacket to m_OutBuffer ,return -1 if no space + /// Need to be called with m_OutBufferLock lock held + int iSendPacket (const WorldPacket& pct); + + /// Flush m_PacketQueue if there are packets in it + /// Need to be called with m_OutBufferLock lock held + /// @return true if it wrote to the buffer ( AKA you need + /// to mark the socket for output ). + bool iFlushPacketQueue (); + +private: + /// Time in which the last ping was received + ACE_Time_Value m_LastPingTime; + + /// Keep track of overspeed pings ,to prevent ping flood. + uint32 m_OverSpeedPings; + + /// Address of the remote peer + std::string m_Address; + + /// Class used for managing encryption of the headers + AuthCrypt m_Crypt; + + /// Mutex lock to protect m_Session + LockType m_SessionLock; + + /// Session to which recieved packets are routed + WorldSession* m_Session; + + /// here are stored the fragmens of the recieved data + WorldPacket* m_RecvWPct; + + /// This block actually refers to m_RecvWPct contents, + /// which alows easy and safe writing to it. + /// It wont free memory when its deleted. m_RecvWPct takes care of freeing. + ACE_Message_Block m_RecvPct; + + /// Fragment of the recieved header. + ACE_Message_Block m_Header; + + /// Mutex for protecting otuput related data. + LockType m_OutBufferLock; + + /// Buffer used for writing output. + ACE_Message_Block *m_OutBuffer; + + /// Size of the m_OutBuffer. + size_t m_OutBufferSize; + + /// Here are stored packets for which there was no space on m_OutBuffer, + /// this alows not-to kick player if its buffer is overflowed. + PacketQueueT m_PacketQueue; + + /// True if the socket is registered with the reactor for output + bool m_OutActive; + + uint32 m_Seed; }; -#endif + +#endif /* _WORLDSOCKET_H */ + /// @} diff --git a/src/game/WorldSocketMgr.cpp b/src/game/WorldSocketMgr.cpp index 0281d200109..7af1389e92a 100644 --- a/src/game/WorldSocketMgr.cpp +++ b/src/game/WorldSocketMgr.cpp @@ -16,40 +16,355 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/** \file - \ingroup u2w -*/ +/** \file WorldSocketMgr.cpp + * \ingroup u2w + * \author Derex + */ -#include "Common.h" -#include "WorldSocket.h" #include "WorldSocketMgr.h" -#include "Policies/SingletonImp.h" -INSTANTIATE_SINGLETON_1( WorldSocketMgr ); +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include -/// WorldSocketMgr constructor -WorldSocketMgr::WorldSocketMgr() +#include + +#include "Log.h" +#include "Common.h" +#include "Config/ConfigEnv.h" +#include "Database/DatabaseEnv.h" +#include "WorldSocket.h" + +/** + * This is a helper class to WorldSocketMgr ,that manages + * network threads, and assigning connections from acceptor thread + * to other network threads + */ +class ReactorRunnable : protected ACE_Task_Base { +public: + + ReactorRunnable () : + m_ThreadId (-1), + m_Connections (0), + m_Reactor (0) + { + ACE_Reactor_Impl* imp = 0; + +#if defined (ACE_HAS_EVENT_POLL) || defined (ACE_HAS_DEV_POLL) + imp = new ACE_Dev_Poll_Reactor (); + + imp->max_notify_iterations (128); + imp->restart (1); +#else + imp = new ACE_TP_Reactor (); + imp->max_notify_iterations (128); +#endif + + m_Reactor = new ACE_Reactor (imp, 1); + } + + virtual + ~ReactorRunnable () + { + this->Stop (); + this->Wait (); + + if (m_Reactor) + delete m_Reactor; + } + + void + Stop () + { + m_Reactor->end_reactor_event_loop (); + } + + int + Start () + { + if (m_ThreadId != -1) + return -1; + + return (m_ThreadId = this->activate ()); + } + + void + Wait () + { + ACE_Task_Base::wait (); + } + + long + Connections () + { + return static_cast (m_Connections.value ()); + } + + int + AddSocket (WorldSocket* sock) + { + ACE_GUARD_RETURN (ACE_Thread_Mutex, Guard, m_NewSockets_Lock, -1); + + ++m_Connections; + sock->AddReference(); + sock->reactor (m_Reactor); + m_NewSockets.insert (sock); + + return 0; + } + + ACE_Reactor* GetReactor () + { + return m_Reactor; + } + +protected: + + void + AddNewSockets () + { + ACE_GUARD (ACE_Thread_Mutex, Guard, m_NewSockets_Lock); + + if (m_NewSockets.empty ()) + return; + + for (SocketSet::iterator i = m_NewSockets.begin (); i != m_NewSockets.end (); ++i) + { + WorldSocket* sock = (*i); + + if (sock->IsClosed ()) + { + sock->RemoveReference (); + --m_Connections; + } + else + m_Sockets.insert (sock); + } + + m_NewSockets.clear (); + } + + virtual int + svc (void) + { + DEBUG_LOG ("Network Thread Starting"); + + WorldDatabase.ThreadStart (); + + ACE_ASSERT (m_Reactor); + + SocketSet::iterator i, t; + + while (!m_Reactor->reactor_event_loop_done ()) + { + // dont be too smart to move this outside the loop + // the run_reactor_event_loop will modify interval + ACE_Time_Value interval (0, 10000); + + if (m_Reactor->run_reactor_event_loop (interval) == -1) + break; + + AddNewSockets (); + + for (i = m_Sockets.begin (); i != m_Sockets.end ();) + { + if ((*i)->Update () == -1) + { + t = i; + i++; + (*t)->CloseSocket (); + (*t)->RemoveReference (); + --m_Connections; + m_Sockets.erase (t); + } + else + i++; + } + } + + WorldDatabase.ThreadEnd (); + + DEBUG_LOG ("Network Thread Exitting"); + + return 0; + } + +private: + typedef ACE_Atomic_Op AtomicInt; + typedef std::set SocketSet; + + ACE_Reactor* m_Reactor; + AtomicInt m_Connections; + int m_ThreadId; + + SocketSet m_Sockets; + + SocketSet m_NewSockets; + ACE_Thread_Mutex m_NewSockets_Lock; +}; + + + +WorldSocketMgr::WorldSocketMgr () : +m_NetThreadsCount (0), +m_NetThreads (0), +m_SockOutKBuff (-1), +m_SockOutUBuff (65536), +m_UseNoDelay (true), +m_Acceptor (0) {} + +WorldSocketMgr::~WorldSocketMgr () +{ + if (m_NetThreads) + delete [] m_NetThreads; + + if(m_Acceptor) + delete m_Acceptor; } -/// Add a WorldSocket to the set -void WorldSocketMgr::AddSocket(WorldSocket *s) +int +WorldSocketMgr::StartReactiveIO (ACE_UINT16 port, const char* address) { - m_sockets.insert(s); -} + m_UseNoDelay = sConfig.GetBoolDefault ("Network.TcpNodelay", true); -/// Remove a WorldSocket to the set -void WorldSocketMgr::RemoveSocket(WorldSocket *s) -{ - m_sockets.erase(s); -} + int num_threads = sConfig.GetIntDefault ("Network.Threads", 1); -/// Triggers an 'update' to all sockets in the set -void WorldSocketMgr::Update(time_t diff) -{ - SocketSet::iterator i; - for(i = m_sockets.begin(); i != m_sockets.end(); i++) + if (num_threads <= 0) { - (*i)->Update(diff); + sLog.outError ("Network.Threads is wrong in your config file"); + return -1; + } + + m_NetThreadsCount = static_cast (num_threads + 1); + + m_NetThreads = new ReactorRunnable[m_NetThreadsCount]; + + sLog.outBasic ("Max alowed socket connections %d",ACE::max_handles ()); + + m_SockOutKBuff = sConfig.GetIntDefault ("Network.OutKBuff", -1); // -1 means use default + + m_SockOutUBuff = sConfig.GetIntDefault ("Network.OutUBuff", 65536); + + if ( m_SockOutUBuff <= 0 ) + { + sLog.outError ("Network.OutUBuff is wrong in your config file"); + return -1; + } + + WorldSocket::Acceptor *acc = new WorldSocket::Acceptor; + m_Acceptor = acc; + + ACE_INET_Addr listen_addr (port, address); + + if (acc->open (listen_addr, m_NetThreads[0].GetReactor (), ACE_NONBLOCK) == -1) + { + sLog.outError ("Failed to open acceptor ,check if the port is free"); + return -1; + } + + for (size_t i = 0; i < m_NetThreadsCount; ++i) + m_NetThreads[i].Start (); + + return 0; +} + +int +WorldSocketMgr::StartNetwork (ACE_UINT16 port, const char* address) +{ + if (!sLog.IsOutDebug ()) + ACE_Log_Msg::instance ()->priority_mask (LM_ERROR, ACE_Log_Msg::PROCESS); + + if (this->StartReactiveIO (port, address) == -1) + return -1; + + return 0; +} + +void +WorldSocketMgr::StopNetwork () +{ + if (m_Acceptor) + { + WorldSocket::Acceptor* acc = dynamic_cast (m_Acceptor); + + if (acc) + acc->close (); + } + + if (m_NetThreadsCount != 0) + { + for (size_t i = 0; i < m_NetThreadsCount; ++i) + m_NetThreads[i].Stop (); + } + + this->Wait (); +} + +void +WorldSocketMgr::Wait () +{ + if (m_NetThreadsCount != 0) + { + for (size_t i = 0; i < m_NetThreadsCount; ++i) + m_NetThreads[i].Wait (); } } + +int +WorldSocketMgr::OnSocketOpen (WorldSocket* sock) +{ + // set some options here + if (m_SockOutKBuff >= 0) + if (sock->peer ().set_option (SOL_SOCKET, + SO_SNDBUF, + (void*) & m_SockOutKBuff, + sizeof (int)) == -1 && errno != ENOTSUP) + { + sLog.outError ("WorldSocketMgr::OnSocketOpen set_option SO_SNDBUF"); + return -1; + } + + static const int ndoption = 1; + + // Set TCP_NODELAY. + if (m_UseNoDelay) + if (sock->peer ().set_option (ACE_IPPROTO_TCP, + TCP_NODELAY, + (void*) & ndoption, + sizeof (int)) == -1) + { + sLog.outError ("WorldSocketMgr::OnSocketOpen: peer ().set_option TCP_NODELAY errno = %s", ACE_OS::strerror (errno)); + return -1; + } + + sock->m_OutBufferSize = static_cast (m_SockOutUBuff); + + // we skip the Acceptor Thread + size_t min = 1; + + ACE_ASSERT (m_NetThreadsCount >= 1); + + for (size_t i = 1; i < m_NetThreadsCount; ++i) + if (m_NetThreads[i].Connections () < m_NetThreads[min].Connections ()) + min = i; + + return m_NetThreads[min].AddSocket (sock); + + return 0; +} + +WorldSocketMgr* +WorldSocketMgr::Instance () +{ + return ACE_Singleton::instance(); +} diff --git a/src/game/WorldSocketMgr.h b/src/game/WorldSocketMgr.h index 5a26d739f4a..923efa02fe1 100644 --- a/src/game/WorldSocketMgr.h +++ b/src/game/WorldSocketMgr.h @@ -16,32 +16,62 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/// \addtogroup u2w User to World Communication -/// @{ -/// \file +/** \addtogroup u2w User to World Communication + * @{ + * \file WorldSocketMgr.h + * \author Derex + */ #ifndef __WORLDSOCKETMGR_H #define __WORLDSOCKETMGR_H -#include "Policies/Singleton.h" +#include +#include +#include class WorldSocket; +class ReactorRunnable; +class ACE_Event_Handler; -/// Manages the list of connected WorldSockets -class WorldSocketMgr +/// Manages all sockets connected to peers and network threads +class WorldSocketMgr { - public: - WorldSocketMgr(); +public: + friend class WorldSocket; + friend class ACE_Singleton; - void AddSocket(WorldSocket *s); - void RemoveSocket(WorldSocket *s); - void Update(time_t diff); - - private: - typedef std::set SocketSet; - SocketSet m_sockets; + /// Start network, listen at address:port . + int StartNetwork (ACE_UINT16 port, const char* address); + + /// Stops all network threads, It will wait for all running threads . + void StopNetwork (); + + /// Wait untill all network threads have "joined" . + void Wait (); + + /// Make this class singleton . + static WorldSocketMgr* Instance (); + +private: + int OnSocketOpen(WorldSocket* sock); + + int StartReactiveIO(ACE_UINT16 port, const char* address); + +private: + WorldSocketMgr (); + virtual ~WorldSocketMgr (); + + ReactorRunnable* m_NetThreads; + size_t m_NetThreadsCount; + + int m_SockOutKBuff; + int m_SockOutUBuff; + bool m_UseNoDelay; + + ACE_Event_Handler* m_Acceptor; }; -#define sWorldSocketMgr MaNGOS::Singleton::Instance() +#define sWorldSocketMgr WorldSocketMgr::Instance () + #endif /// @} diff --git a/src/shared/Common.h b/src/shared/Common.h index 4e93ad71eb2..36d6bc5e5ae 100644 --- a/src/shared/Common.h +++ b/src/shared/Common.h @@ -19,6 +19,44 @@ #ifndef MANGOSSERVER_COMMON_H #define MANGOSSERVER_COMMON_H +// config.h needs to be included 1st +// TODO this thingy looks like hack ,but its not, need to +// make separate header however, because It makes mess here. +#ifdef HAVE_CONFIG_H +// Remove Some things that we will define +// This is in case including another config.h +// before trinity config.h +#ifdef PACKAGE +#undef PACKAGE +#endif //PACKAGE +#ifdef PACKAGE_BUGREPORT +#undef PACKAGE_BUGREPORT +#endif //PACKAGE_BUGREPORT +#ifdef PACKAGE_NAME +#undef PACKAGE_NAME +#endif //PACKAGE_NAME +#ifdef PACKAGE_STRING +#undef PACKAGE_STRING +#endif //PACKAGE_STRING +#ifdef PACKAGE_TARNAME +#undef PACKAGE_TARNAME +#endif //PACKAGE_TARNAME +#ifdef PACKAGE_VERSION +#undef PACKAGE_VERSION +#endif //PACKAGE_VERSION +#ifdef VERSION +#undef VERSION +#endif //VERSION +# include "config.h" +#undef PACKAGE +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION +#undef VERSION +#endif //HAVE_CONFIG_H + #include "Platform/Define.h" #if COMPILER == COMPILER_MICROSOFT @@ -43,10 +81,6 @@ #endif // __SHOW_STUPID_WARNINGS__ #endif // __GNUC__ -#ifdef HAVE_CONFIG_H -# include -#endif - #include "Utilities/HashMap.h" #include #include @@ -76,8 +110,8 @@ #include #if PLATFORM == PLATFORM_WINDOWS -# define FD_SETSIZE 1024 -# include +# define FD_SETSIZE 4096 +# include // XP winver - needed to compile with standard leak check in MemoryLeaks.h // uncomment later if needed //#define _WIN32_WINNT 0x0501 diff --git a/src/shared/Database/DBCStructure.h b/src/shared/Database/DBCStructure.h index c0370180511..b01268d2ed4 100644 --- a/src/shared/Database/DBCStructure.h +++ b/src/shared/Database/DBCStructure.h @@ -1,937 +1,937 @@ -/* - * Copyright (C) 2005-2008 MaNGOS - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef DBCSTRUCTURE_H -#define DBCSTRUCTURE_H - -#include "Platform/Define.h" - -#include -#include -#include - -// Structures using to access raw DBC data and required packing to portability - -// GCC have alternative #pragma pack(N) syntax and old gcc version not support pack(push,N), also any gcc version not support it at some platform -#if defined( __GNUC__ ) -#pragma pack(1) -#else -#pragma pack(push,1) -#endif - -enum AreaTeams -{ - AREATEAM_NONE = 0, - AREATEAM_ALLY = 2, - AREATEAM_HORDE = 4 -}; - -enum AreaFlags -{ - AREA_FLAG_SNOW = 0x00000001, // snow (only Dun Morogh, Naxxramas, Razorfen Downs and Winterspring) - AREA_FLAG_UNK1 = 0x00000002, // unknown, (only Naxxramas and Razorfen Downs) - AREA_FLAG_UNK2 = 0x00000004, // Only used on development map - AREA_FLAG_SLAVE_CAPITAL = 0x00000008, // slave capital city flag? - AREA_FLAG_UNK3 = 0x00000010, // unknown - AREA_FLAG_SLAVE_CAPITAL2 = 0x00000020, // slave capital city flag? - AREA_FLAG_UNK4 = 0x00000040, // many zones have this flag - AREA_FLAG_ARENA = 0x00000080, // arena, both instanced and world arenas - AREA_FLAG_CAPITAL = 0x00000100, // main capital city flag - AREA_FLAG_CITY = 0x00000200, // only for one zone named "City" (where it located?) - AREA_FLAG_OUTLAND = 0x00000400, // outland zones? (only Eye of the Storm not have this flag, but have 0x00004000 flag) - AREA_FLAG_SANCTUARY = 0x00000800, // sanctuary area (PvP disabled) - AREA_FLAG_NEED_FLY = 0x00001000, // only Netherwing Ledge, Socrethar's Seat, Tempest Keep, The Arcatraz, The Botanica, The Mechanar, Sorrow Wing Point, Dragonspine Ridge, Netherwing Mines, Dragonmaw Base Camp, Dragonmaw Skyway - AREA_FLAG_UNUSED1 = 0x00002000, // not used now (no area/zones with this flag set in 2.4.2) - AREA_FLAG_OUTLAND2 = 0x00004000, // outland zones? (only Circle of Blood Arena not have this flag, but have 0x00000400 flag) - AREA_FLAG_PVP = 0x00008000, // pvp objective area? (Death's Door also has this flag although it's no pvp object area) - AREA_FLAG_ARENA_INSTANCE = 0x00010000, // used by instanced arenas only - AREA_FLAG_UNUSED2 = 0x00020000, // not used now (no area/zones with this flag set in 2.4.2) - AREA_FLAG_UNK5 = 0x00040000, // just used for Amani Pass, Hatchet Hills - AREA_FLAG_LOWLEVEL = 0x00100000 // used for some starting areas with area_level <=15 -}; - -enum FactionTemplateFlags -{ - FACTION_TEMPLATE_FLAG_CONTESTED_GUARD = 0x00001000, // faction will attack players that were involved in PvP combats -}; - -struct AreaTableEntry -{ - uint32 ID; // 0 - uint32 mapid; // 1 - uint32 zone; // 2 if 0 then it's zone, else it's zone id of this area - uint32 exploreFlag; // 3, main index - uint32 flags; // 4, unknown value but 312 for all cities - // 5-9 unused - int32 area_level; // 10 - char* area_name[16]; // 11-26 - // 27, string flags, unused - uint32 team; // 28 -}; - -struct AreaTriggerEntry -{ - uint32 id; // 0 - uint32 mapid; // 1 - float x; // 2 - float y; // 3 - float z; // 4 - float radius; // 5 - float box_x; // 6 extent x edge - float box_y; // 7 extent y edge - float box_z; // 8 extent z edge - float box_orientation; // 9 extent rotation by about z axis -}; - -struct BankBagSlotPricesEntry -{ - uint32 ID; - uint32 price; -}; - -struct BattlemasterListEntry -{ - uint32 id; // 0 - uint32 mapid[3]; // 1-3 mapid - // 4-8 unused - uint32 type; // 9 (3 - BG, 4 - arena) - uint32 minlvl; // 10 - uint32 maxlvl; // 11 - uint32 maxplayersperteam; // 12 - // 13-14 unused - char* name[16]; // 15-30 - // 31 string flag, unused - // 32 unused -}; - -struct CharTitlesEntry -{ - uint32 ID; // 0, title ids, for example in Quest::GetCharTitleId() - //uint32 unk1; // 1 flags? - //char* name[16]; // 2-17, unused - // 18 string flag, unused - //char* name2[16]; // 19-34, unused - // 35 string flag, unused - uint32 bit_index; // 36 used in PLAYER_CHOSEN_TITLE and 1<